From b9c0619828ef4d28e496a7ef5e04b93507e00553 Mon Sep 17 00:00:00 2001 From: Blake Warner Date: Sat, 12 Feb 2022 14:50:06 -0500 Subject: [PATCH] cpp conversion --- ...a_static.c => fra_message_data_static.cpp} | 3 +- ...a_static.c => ger_message_data_static.cpp} | 3 +- ...a_static.c => nes_message_data_static.cpp} | 4 +- ...static.c => staff_message_data_static.cpp} | 4 +- include/audiomgr.h | 8 +- include/code_800ACE70.h | 4 +- include/color.h | 12 +- include/command_macros_base.h | 2 +- include/def/PreRender.h | 65 +- include/def/TwoHeadArena.h | 35 +- include/def/aisetfreq.h | 5 +- include/def/aisetnextbuf.h | 5 +- include/def/assert.h | 5 +- include/def/audioMgr.h | 13 +- include/def/audio_data.h | 1 + include/def/audio_effects.h | 20 +- include/def/audio_heap.h | 31 +- include/def/audio_init_params.h | 5 + include/def/audio_load.h | 33 +- include/def/audio_playback.h | 43 +- include/def/audio_seqplayer.h | 17 +- include/def/audio_sound_params.h | 1 + include/def/audio_synthesis.h | 5 +- include/def/cartrominit.h | 6 +- include/def/code_800430A0.h | 8 +- include/def/code_80043480.h | 18 +- include/def/code_80069420.h | 5 +- include/def/code_8006BA00.h | 9 +- include/def/code_8006C3A0.h | 9 +- include/def/code_8006C510.h | 6 +- include/def/code_80097A00.h | 13 +- include/def/code_800A9F30.h | 14 +- include/def/code_800ACE70.h | 14 +- include/def/code_800AD920.h | 14 +- include/def/code_800BB0A0.h | 8 +- include/def/code_800C3C20.h | 5 +- include/def/code_800D2E30.h | 8 +- include/def/code_800D31A0.h | 6 - include/def/code_800E4FE0.h | 20 +- include/def/code_800E6840.h | 6 +- include/def/code_800EC960.h | 81 +- include/def/code_800F7260.h | 26 +- include/def/code_800F9280.h | 18 +- include/def/code_800FBCE0.h | 6 +- include/def/code_800FC620.h | 8 +- include/def/code_800FCE80.h | 14 +- include/def/code_800FD970.h | 12 +- include/def/code_80106860.h | 5 +- include/def/code_801068B0.h | 5 +- include/def/contpfs.h | 13 +- include/def/contquery.h | 8 +- include/def/contramread.h | 5 +- include/def/contramwrite.h | 6 +- include/def/contreaddata.h | 9 +- include/def/controller.h | 9 +- include/def/contsetch.h | 5 +- include/def/cosf.h | 6 +- include/def/coss.h | 5 +- include/def/crc.h | 6 +- include/def/db_camera.h | 10 +- include/def/debug_malloc.h | 20 +- include/def/devmgr.h | 5 +- include/def/dmadata.h | 1 + include/def/dpgetstat.h | 5 +- include/def/dpsetstat.h | 5 +- include/def/driverominit.h | 6 +- include/def/epidma.h | 7 +- include/def/epirawdma.h | 6 +- include/def/epirawread.h | 6 +- include/def/epiwrite.h | 6 +- include/def/fault.h | 51 +- include/def/fault_drawer.h | 22 +- include/def/flg_set.h | 6 +- include/def/game.h | 23 +- include/def/gamealloc.h | 20 +- include/def/gfxbuffers.h | 1 + include/def/gfxprint.h | 32 +- include/def/graph.h | 23 +- include/def/idle.h | 7 +- include/def/irqmgr.h | 38 +- include/def/jpegdecoder.h | 11 +- include/def/jpegutils.h | 15 +- include/def/listalloc.h | 17 +- include/def/logutils.h | 14 +- include/def/lookat.h | 6 +- include/def/lookathil.h | 7 +- include/def/mempak.h | 12 +- include/def/mtxf2l.h | 8 +- include/def/mtxuty-cvt.h | 5 +- include/def/normalize.h | 5 +- include/def/ortho.h | 6 +- include/def/padmgr.h | 19 +- include/def/padsetup.h | 7 +- include/def/padutils.h | 22 +- include/def/perspective.h | 6 +- include/def/pfsallocatefile.h | 8 +- include/def/pfschecker.h | 9 +- include/def/pfsdeletefile.h | 8 +- include/def/pfsfilestate.h | 7 +- include/def/pfsfindfile.h | 6 +- include/def/pfsfreeblocks.h | 6 +- include/def/pfsgetstatus.h | 9 +- include/def/pfsinitpak.h | 8 +- include/def/pfsisplug.h | 9 +- include/def/pfsreadwritefile.h | 7 +- include/def/pfsselectbank.h | 6 +- include/def/piacs.h | 7 +- include/def/pigetcmdq.h | 6 +- include/def/pimgr.h | 6 +- include/def/pirawdma.h | 5 +- include/def/position.h | 6 +- include/def/printutils.h | 6 +- include/def/rotate.h | 6 +- include/def/scale.h | 5 +- include/def/sched.h | 26 +- include/def/shrink_window.h | 11 +- include/def/si.h | 5 +- include/def/siacs.h | 7 +- include/def/sinf.h | 6 +- include/def/sins.h | 5 +- include/def/sirawdma.h | 5 +- include/def/sirawread.h | 5 +- include/def/sirawwrite.h | 5 +- include/def/sleep.h | 9 +- include/def/sp.h | 5 +- include/def/speed_meter.h | 24 +- include/def/spgetstat.h | 5 +- include/def/sprawdma.h | 5 +- include/def/sprintf.h | 8 - include/def/spsetpc.h | 5 +- include/def/spsetstat.h | 5 +- include/def/sptask.h | 7 +- include/def/sptaskyield.h | 5 +- include/def/stackcheck.h | 10 +- include/def/sys_cfb.h | 5 +- include/def/sys_math.h | 9 +- include/def/sys_math3d.h | 64 +- include/def/sys_math_atan.h | 6 +- include/def/sys_matrix.h | 42 +- include/def/sys_ucode.h | 10 +- include/def/system_malloc.h | 22 +- include/def/title_setup.h | 8 +- include/def/translate.h | 5 +- include/def/us2dex.h | 5 +- include/def/vi.h | 5 +- include/def/viblack.h | 5 +- include/def/viextend.h | 5 +- include/def/vigetcurrcontext.h | 6 +- include/def/vigetcurrframebuf.h | 5 +- include/def/vigetnextframebuf.h | 5 +- include/def/vimodefpallan1.h | 1 + include/def/vimodempallan1.h | 1 + include/def/vimodentsclan1.h | 1 + include/def/vimodepallan1.h | 1 + include/def/visetevent.h | 6 +- include/def/visetmode.h | 6 +- include/def/visetspecial.h | 5 +- include/def/visetxscale.h | 5 +- include/def/visetyscale.h | 5 +- include/def/viswapbuf.h | 5 +- include/def/viswapcontext.h | 5 +- include/def/xldtob.h | 6 +- include/def/xlitob.h | 6 +- include/def/xprintf.h | 5 +- include/def/z_DLF.h | 7 +- include/def/z_actor.h | 205 +- include/def/z_actor_dlftbls.h | 7 +- include/def/z_bgcheck.h | 125 +- include/def/z_camera.h | 39 +- include/def/z_cheap_proc.h | 7 +- include/def/z_collision_btltbls.h | 7 +- include/def/z_collision_check.h | 115 +- include/def/z_common_data.h | 5 +- include/def/z_construct.h | 9 +- include/def/z_debug.h | 11 +- include/def/z_demo.h | 13 +- include/def/z_draw.h | 6 +- include/def/z_eff_blure.h | 28 +- include/def/z_eff_shield_particle.h | 17 +- include/def/z_eff_spark.h | 17 +- include/def/z_eff_ss_dead.h | 12 +- include/def/z_effect.h | 14 +- include/def/z_effect_soft_sprite.h | 17 +- include/def/z_effect_soft_sprite_dlftbls.h | 1 + include/def/z_effect_soft_sprite_old_init.h | 93 +- include/def/z_elf_message.h | 7 +- include/def/z_en_item00.h | 11 +- include/def/z_face_reaction.h | 6 +- include/def/z_fbdemo.h | 26 +- include/def/z_fbdemo_circle.h | 31 +- include/def/z_fbdemo_fade.h | 28 +- include/def/z_fbdemo_triforce.h | 28 +- include/def/z_fbdemo_wipe1.h | 28 +- include/def/z_fcurve_data_skelanime.h | 15 +- include/def/z_file_choose.h | 11 +- include/def/z_frame_advance.h | 8 +- include/def/z_game_dlftbls.h | 1 + include/def/z_game_over.h | 8 +- include/def/z_horse.h | 15 +- include/def/z_kaleido_manager.h | 10 +- include/def/z_kaleido_scope_call.h | 9 +- include/def/z_kaleido_setup.h | 8 +- include/def/z_kanfont.h | 9 +- include/def/z_kankyo.h | 53 +- include/def/z_lib.h | 45 +- include/def/z_lifemeter.h | 12 +- include/def/z_lights.h | 31 +- include/def/z_malloc.h | 19 - include/def/z_map_data.h | 1 + include/def/z_map_exp.h | 15 +- include/def/z_map_mark.h | 8 +- include/def/z_message_PAL.h | 17 +- include/def/z_msgevent.h | 5 +- include/def/z_olib.h | 16 +- include/def/z_onepointdemo.h | 14 +- include/def/z_opening.h | 11 +- include/def/z_parameter.h | 34 +- include/def/z_path.h | 11 +- include/def/z_play.h | 51 +- include/def/z_player_call.h | 5 +- include/def/z_player_lib.h | 59 +- include/def/z_prenmi.h | 8 +- include/def/z_prenmi_buff.h | 14 +- include/def/z_quake.h | 33 +- include/def/z_rcp.h | 54 +- include/def/z_room.h | 16 +- include/def/z_sample.h | 11 +- include/def/z_scene.h | 15 +- include/def/z_scene_table.h | 8 +- include/def/z_select.h | 11 +- include/def/z_skelanime.h | 77 +- include/def/z_skin.h | 22 +- include/def/z_skin_awb.h | 15 +- include/def/z_skin_matrix.h | 19 +- include/def/z_sram.h | 19 +- include/def/z_ss_sram.h | 7 +- include/def/z_std_dma.h | 34 +- include/def/z_title.h | 11 +- include/def/z_view.h | 36 +- include/def/z_vimode.h | 19 +- include/def/z_vismono.h | 23 +- include/def/z_vr_box.h | 7 +- include/def/z_vr_box_draw.h | 9 +- include/fp.h | 2 - include/gfx.h | 24 +- include/gfx_align.h | 10 +- include/gfxapi.h | 18 + include/global.h | 2 - include/hack.h | 25 - include/ichain.h | 8 +- include/kaleido.h | 24 +- include/libc.bak/math.h | 4 +- include/libc.bak/stdlib.h | 8 +- include/listalloc.h | 4 +- include/macros.h | 6 +- include/message_data_static.h | 27 +- include/n64fault.h | 20 +- include/n64mapdata.h | 8 +- include/padmgr.h | 12 +- include/porting_defs.h | 1 + include/quake.h | 16 +- include/sched.h | 24 +- include/sequence.h | 8 +- include/speedmeter.h | 12 +- include/ultra64/abi.h | 81 +- include/ultra64/controller.h | 32 +- include/ultra64/exception.h | 12 +- include/ultra64/gbi.h | 176 +- include/ultra64/gs2dex.h | 39 +- include/ultra64/internal.h | 8 +- include/ultra64/message.h | 4 +- include/ultra64/pfs.h | 24 +- include/ultra64/pi.h | 34 +- include/ultra64/printf.h | 5 +- include/ultra64/sptask.h | 8 +- include/ultra64/thread.h | 12 +- include/ultra64/time.h | 4 +- include/ultra64/types.h | 151 +- include/ultra64/vi.h | 20 +- include/view.h | 8 +- include/z64.h | 24 +- include/z64actor.h | 136 +- include/z64animation.h | 150 +- include/z64audio.h | 510 +- include/z64bgcheck.h | 69 +- include/z64camera.h | 352 +- include/z64collision_check.h | 152 +- include/z64cutscene.h | 60 +- include/z64cutscene_commands.h | 102 +- include/z64dma.h | 8 +- include/z64effect.h | 72 +- include/z64environment.h | 28 +- include/z64file.h | 12 +- include/z64game.h | 42 +- include/z64global.h | 8 +- include/z64item.h | 36 +- include/z64jpeg.h | 32 +- include/z64light.h | 32 +- include/z64map_mark.h | 8 +- include/z64math.h | 65 +- include/z64message.h | 36 +- include/z64object.h | 8 +- include/z64player.h | 44 +- include/z64render.h | 16 +- include/z64save.h | 48 +- include/z64scene.h | 240 +- include/z64sram.h | 8 +- include/z64transition.h | 24 +- include/z_fbdemo_circle.h | 2 +- include/z_file_choose.h | 4 +- include/z_opening.h | 4 +- include/z_player.h | 2 +- include/z_prenmi_buff.h | 8 +- include/z_scene_table.h | 4 +- include/z_select.h | 10 +- include/z_title.h | 4 +- include/z_vismono.h | 8 +- oldfuncs.h | 32 +- src/boot/{assert.c => assert.cpp} | 2 +- src/boot/{boot_main.c => boot_main.cpp} | 0 src/boot/build.c | 4 - src/boot/build.cpp | 1 + src/boot/{idle.c => idle.cpp} | 0 src/boot/{logutils.c => logutils.cpp} | 0 src/boot/{stackcheck.c => stackcheck.cpp} | 4 +- src/boot/{z_std_dma.c => z_std_dma.cpp} | 34 +- src/buffers/{gfxbuffers.c => gfxbuffers.cpp} | 0 src/buffers/{heaps.c => heaps.cpp} | 0 src/buffers/{zbuffer.c => zbuffer.cpp} | 0 src/code/{PreRender.c => PreRender.cpp} | 251 +- src/code/{TwoHeadArena.c => TwoHeadArena.cpp} | 18 +- src/code/__osMalloc.c | 830 - src/code/{audioMgr.c => audioMgr.cpp} | 0 src/code/{audio_data.c => audio_data.cpp} | 0 .../{audio_effects.c => audio_effects.cpp} | 0 src/code/{audio_heap.c => audio_heap.cpp} | 49 +- ...io_init_params.c => audio_init_params.cpp} | 4 +- src/code/{audio_load.c => audio_load.cpp} | 167 +- .../{audio_playback.c => audio_playback.cpp} | 14 +- ...{audio_seqplayer.c => audio_seqplayer.cpp} | 12 +- ..._sound_params.c => audio_sound_params.cpp} | 0 ...{audio_synthesis.c => audio_synthesis.cpp} | 31 +- .../{code_800430A0.c => code_800430A0.cpp} | 0 .../{code_80043480.c => code_80043480.cpp} | 0 .../{code_80069420.c => code_80069420.cpp} | 0 .../{code_8006BA00.c => code_8006BA00.cpp} | 0 .../{code_8006C3A0.c => code_8006C3A0.cpp} | 0 .../{code_8006C510.c => code_8006C510.cpp} | 0 .../{code_80097A00.c => code_80097A00.cpp} | 0 .../{code_800A9F30.c => code_800A9F30.cpp} | 0 .../{code_800ACE70.c => code_800ACE70.cpp} | 30 +- .../{code_800AD920.c => code_800AD920.cpp} | 34 +- .../{code_800BB0A0.c => code_800BB0A0.cpp} | 0 .../{code_800C3C20.c => code_800C3C20.cpp} | 0 .../{code_800D2E30.c => code_800D2E30.cpp} | 0 .../{code_800D31A0.c => code_800D31A0.cpp} | 0 .../{code_800E4FE0.c => code_800E4FE0.cpp} | 10 +- .../{code_800E6840.c => code_800E6840.cpp} | 0 .../{code_800EC960.c => code_800EC960.cpp} | 0 .../{code_800F7260.c => code_800F7260.cpp} | 0 .../{code_800F9280.c => code_800F9280.cpp} | 10 +- .../{code_800FBCE0.c => code_800FBCE0.cpp} | 0 .../{code_800FC620.c => code_800FC620.cpp} | 3 +- .../{code_800FCE80.c => code_800FCE80.cpp} | 2 - .../{code_800FD970.c => code_800FD970.cpp} | 0 .../{code_801067F0.c => code_801067F0.cpp} | 0 .../{code_80106860.c => code_80106860.cpp} | 2 +- .../{code_801068B0.c => code_801068B0.cpp} | 4 +- src/code/{db_camera.c => db_camera.cpp} | 107 +- src/code/{debug_malloc.c => debug_malloc.cpp} | 0 src/code/{fault.c => fault.cpp} | 0 src/code/{fault_drawer.c => fault_drawer.cpp} | 0 src/code/{flg_set.c => flg_set.cpp} | 0 src/code/{game.c => game.cpp} | 10 +- src/code/gamealloc.c | 85 - src/code/gamealloc.cpp | 85 + src/code/{gfxprint.c => gfxprint.cpp} | 210 +- src/code/{graph.c => graph.cpp} | 17 +- src/code/{irqmgr.c => irqmgr.cpp} | 20 +- src/code/{jpegdecoder.c => jpegdecoder.cpp} | 2 +- src/code/{jpegutils.c => jpegutils.cpp} | 0 src/code/listalloc.c | 66 - src/code/listalloc.cpp | 66 + src/code/{logseverity.c => logseverity.cpp} | 0 src/code/{mempak.c => mempak.cpp} | 0 src/code/{mtxuty-cvt.c => mtxuty-cvt.cpp} | 0 src/code/{padmgr.c => padmgr.cpp} | 7 +- src/code/{padsetup.c => padsetup.cpp} | 0 src/code/{padutils.c => padutils.cpp} | 0 src/code/{printutils.c => printutils.cpp} | 0 src/code/{sched.c => sched.cpp} | 0 .../{shrink_window.c => shrink_window.cpp} | 0 src/code/{sleep.c => sleep.cpp} | 0 src/code/{speed_meter.c => speed_meter.cpp} | 50 +- src/code/{sys_cfb.c => sys_cfb.cpp} | 0 src/code/{sys_math.c => sys_math.cpp} | 0 src/code/{sys_math3d.c => sys_math3d.cpp} | 0 .../{sys_math_atan.c => sys_math_atan.cpp} | 0 src/code/{sys_matrix.c => sys_matrix.cpp} | 14 +- src/code/{sys_ucode.c => sys_ucode.cpp} | 2 +- .../{system_malloc.c => system_malloc.cpp} | 0 src/code/{title_setup.c => title_setup.cpp} | 0 src/code/{z_DLF.c => z_DLF.cpp} | 0 src/code/{z_actor.c => z_actor.cpp} | 70 +- ...{z_actor_dlftbls.c => z_actor_dlftbls.cpp} | 17 - src/code/{z_bgcheck.c => z_bgcheck.cpp} | 94 +- src/code/{z_camera.c => z_camera.cpp} | 9 +- .../{z_camera_data.c => z_camera_data.cpp} | 0 src/code/{z_cheap_proc.c => z_cheap_proc.cpp} | 0 ...sion_btltbls.c => z_collision_btltbls.cpp} | 0 ...ollision_check.c => z_collision_check.cpp} | 12 +- .../{z_common_data.c => z_common_data.cpp} | 0 src/code/{z_construct.c => z_construct.cpp} | 16 +- src/code/{z_debug.c => z_debug.cpp} | 0 ...{z_debug_display.c => z_debug_display.cpp} | 0 src/code/{z_demo.c => z_demo.cpp} | 58 +- src/code/{z_draw.c => z_draw.cpp} | 0 src/code/{z_eff_blure.c => z_eff_blure.cpp} | 422 +- src/code/z_eff_shield_particle.c | 229 - src/code/z_eff_shield_particle.cpp | 229 + src/code/{z_eff_spark.c => z_eff_spark.cpp} | 162 +- .../{z_eff_ss_dead.c => z_eff_ss_dead.cpp} | 0 src/code/{z_effect.c => z_effect.cpp} | 0 ...soft_sprite.c => z_effect_soft_sprite.cpp} | 7 +- ...bls.c => z_effect_soft_sprite_dlftbls.cpp} | 0 ...it.c => z_effect_soft_sprite_old_init.cpp} | 24 +- .../{z_elf_message.c => z_elf_message.cpp} | 0 src/code/z_en_a_keep.c | 376 - src/code/z_en_a_keep.cpp | 376 + src/code/{z_en_item00.c => z_en_item00.cpp} | 496 +- ...{z_face_reaction.c => z_face_reaction.cpp} | 0 src/code/z_fbdemo.c | 238 - src/code/z_fbdemo.cpp | 238 + ...{z_fbdemo_circle.c => z_fbdemo_circle.cpp} | 144 +- .../{z_fbdemo_fade.c => z_fbdemo_fade.cpp} | 82 +- src/code/z_fbdemo_triforce.c | 137 - src/code/z_fbdemo_triforce.cpp | 137 + .../{z_fbdemo_wipe1.c => z_fbdemo_wipe1.cpp} | 100 +- ...kelanime.c => z_fcurve_data_skelanime.cpp} | 16 +- ...{z_frame_advance.c => z_frame_advance.cpp} | 0 .../{z_game_dlftbls.c => z_game_dlftbls.cpp} | 0 src/code/{z_game_over.c => z_game_over.cpp} | 0 src/code/{z_horse.c => z_horse.cpp} | 0 src/code/{z_jpeg.c => z_jpeg.cpp} | 14 +- ...aleido_manager.c => z_kaleido_manager.cpp} | 30 +- ..._scope_call.c => z_kaleido_scope_call.cpp} | 4 +- ...{z_kaleido_setup.c => z_kaleido_setup.cpp} | 0 src/code/{z_kanfont.c => z_kanfont.cpp} | 2 +- src/code/{z_kankyo.c => z_kankyo.cpp} | 14 +- src/code/{z_lib.c => z_lib.cpp} | 0 src/code/{z_lifemeter.c => z_lifemeter.cpp} | 4 +- src/code/{z_lights.c => z_lights.cpp} | 6 +- src/code/{z_malloc.c => z_malloc.cpp} | 0 src/code/{z_map_data.c => z_map_data.cpp} | 0 src/code/{z_map_exp.c => z_map_exp.cpp} | 4 +- src/code/{z_map_mark.c => z_map_mark.cpp} | 4 +- .../{z_message_PAL.c => z_message_PAL.cpp} | 22 +- src/code/{z_moji.c => z_moji.cpp} | 0 src/code/{z_msgevent.c => z_msgevent.cpp} | 0 src/code/{z_olib.c => z_olib.cpp} | 0 .../{z_onepointdemo.c => z_onepointdemo.cpp} | 2 +- ...intdemo_data.c => z_onepointdemo_data.cpp} | 0 src/code/{z_parameter.c => z_parameter.cpp} | 22 +- src/code/{z_path.c => z_path.cpp} | 2 +- src/code/{z_play.c => z_play.cpp} | 53 +- .../{z_player_call.c => z_player_call.cpp} | 8 +- src/code/{z_player_lib.c => z_player_lib.cpp} | 537 +- src/code/z_prenmi.c | 69 - src/code/z_prenmi.cpp | 69 + src/code/z_prenmi_buff.c | 26 - src/code/z_prenmi_buff.cpp | 26 + src/code/{z_quake.c => z_quake.cpp} | 0 src/code/{z_rcp.c => z_rcp.cpp} | 10 +- src/code/{z_room.c => z_room.cpp} | 34 +- src/code/{z_sample.c => z_sample.cpp} | 52 +- src/code/{z_scene.c => z_scene.cpp} | 43 +- .../{z_scene_table.c => z_scene_table.cpp} | 13 +- src/code/{z_skelanime.c => z_skelanime.cpp} | 101 +- src/code/{z_skin.c => z_skin.cpp} | 28 +- src/code/{z_skin_awb.c => z_skin_awb.cpp} | 30 +- .../{z_skin_matrix.c => z_skin_matrix.cpp} | 2 +- src/code/{z_sram.c => z_sram.cpp} | 2 +- src/code/{z_ss_sram.c => z_ss_sram.cpp} | 0 src/code/{z_view.c => z_view.cpp} | 30 +- src/code/{z_vimode.c => z_vimode.cpp} | 8 +- src/code/{z_vismono.c => z_vismono.cpp} | 74 +- src/code/{z_vr_box.c => z_vr_box.cpp} | 174 +- .../{z_vr_box_draw.c => z_vr_box_draw.cpp} | 36 +- src/dmadata/{dmadata.c => dmadata.cpp} | 2 +- ..._message_field.c => elf_message_field.cpp} | 0 ...lf_message_ydan.c => elf_message_ydan.cpp} | 0 src/libultra/gu/{cosf.c => cosf.cpp} | 2 +- src/libultra/gu/{coss.c => coss.cpp} | 0 src/libultra/gu/{lookat.c => lookat.cpp} | 0 .../gu/{lookathil.c => lookathil.cpp} | 0 src/libultra/gu/{mtxf2l.c => mtxf2l.cpp} | 8 +- .../gu/{normalize.c => normalize.cpp} | 0 src/libultra/gu/{ortho.c => ortho.cpp} | 0 .../gu/{perspective.c => perspective.cpp} | 5 +- src/libultra/gu/{position.c => position.cpp} | 3 +- src/libultra/gu/{rotate.c => rotate.cpp} | 3 +- src/libultra/gu/{scale.c => scale.cpp} | 6 +- src/libultra/gu/{sinf.c => sinf.cpp} | 2 +- src/libultra/gu/{sins.c => sins.cpp} | 2 +- src/libultra/gu/{sintable.c => sintable.cpp} | 0 src/libultra/gu/{sqrtf.c => sqrtf.cpp} | 0 .../gu/{translate.c => translate.cpp} | 6 +- src/libultra/gu/{us2dex.c => us2dex.cpp} | 0 src/libultra/io/{aigetlen.c => aigetlen.cpp} | 0 .../io/{aisetfreq.c => aisetfreq.cpp} | 0 .../io/{aisetnextbuf.c => aisetnextbuf.cpp} | 0 .../io/{cartrominit.c => cartrominit.cpp} | 0 src/libultra/io/{contpfs.c => contpfs.cpp} | 0 .../io/{contquery.c => contquery.cpp} | 0 .../io/{contramread.c => contramread.cpp} | 0 .../io/{contramwrite.c => contramwrite.cpp} | 0 .../io/{contreaddata.c => contreaddata.cpp} | 0 .../io/{controller.c => controller.cpp} | 0 .../io/{contsetch.c => contsetch.cpp} | 0 src/libultra/io/{crc.c => crc.cpp} | 0 src/libultra/io/{devmgr.c => devmgr.cpp} | 0 .../io/{dpgetstat.c => dpgetstat.cpp} | 0 .../io/{dpsetstat.c => dpsetstat.cpp} | 0 .../io/{driverominit.c => driverominit.cpp} | 0 src/libultra/io/{epidma.c => epidma.cpp} | 0 .../io/{epirawdma.c => epirawdma.cpp} | 0 .../io/{epirawread.c => epirawread.cpp} | 0 src/libultra/io/{epiwrite.c => epiwrite.cpp} | 0 src/libultra/io/{motor.c => motor.cpp} | 0 ...{pfsallocatefile.c => pfsallocatefile.cpp} | 0 .../io/{pfschecker.c => pfschecker.cpp} | 0 .../io/{pfsdeletefile.c => pfsdeletefile.cpp} | 0 .../io/{pfsfilestate.c => pfsfilestate.cpp} | 0 .../io/{pfsfindfile.c => pfsfindfile.cpp} | 0 .../io/{pfsfreeblocks.c => pfsfreeblocks.cpp} | 0 .../io/{pfsgetstatus.c => pfsgetstatus.cpp} | 0 .../io/{pfsinitpak.c => pfsinitpak.cpp} | 0 .../io/{pfsisplug.c => pfsisplug.cpp} | 0 ...fsreadwritefile.c => pfsreadwritefile.cpp} | 0 .../io/{pfsselectbank.c => pfsselectbank.cpp} | 0 src/libultra/io/{piacs.c => piacs.cpp} | 0 .../io/{pigetcmdq.c => pigetcmdq.cpp} | 0 src/libultra/io/{pimgr.c => pimgr.cpp} | 0 src/libultra/io/{pirawdma.c => pirawdma.cpp} | 0 src/libultra/io/{si.c => si.cpp} | 0 src/libultra/io/{siacs.c => siacs.cpp} | 0 src/libultra/io/{sirawdma.c => sirawdma.cpp} | 0 .../io/{sirawread.c => sirawread.cpp} | 0 .../io/{sirawwrite.c => sirawwrite.cpp} | 0 src/libultra/io/{sp.c => sp.cpp} | 0 .../io/{spgetstat.c => spgetstat.cpp} | 0 src/libultra/io/{sprawdma.c => sprawdma.cpp} | 0 src/libultra/io/{spsetpc.c => spsetpc.cpp} | 0 .../io/{spsetstat.c => spsetstat.cpp} | 0 src/libultra/io/{sptask.c => sptask.cpp} | 0 .../io/{sptaskyield.c => sptaskyield.cpp} | 0 .../io/{sptaskyielded.c => sptaskyielded.cpp} | 0 src/libultra/io/{vi.c => vi.cpp} | 0 src/libultra/io/{viblack.c => viblack.cpp} | 0 src/libultra/io/{viextend.c => viextend.cpp} | 0 ...igetcurrcontext.c => vigetcurrcontext.cpp} | 0 ...etcurrframebuf.c => vigetcurrframebuf.cpp} | 0 ...etnextframebuf.c => vigetnextframebuf.cpp} | 0 src/libultra/io/{vimgr.c => vimgr.cpp} | 0 .../{vimodefpallan1.c => vimodefpallan1.cpp} | 0 .../{vimodempallan1.c => vimodempallan1.cpp} | 0 .../{vimodentsclan1.c => vimodentsclan1.cpp} | 0 .../io/{vimodepallan1.c => vimodepallan1.cpp} | 0 .../io/{visetevent.c => visetevent.cpp} | 0 .../io/{visetmode.c => visetmode.cpp} | 0 .../io/{visetspecial.c => visetspecial.cpp} | 0 .../io/{visetxscale.c => visetxscale.cpp} | 0 .../io/{visetyscale.c => visetyscale.cpp} | 0 .../io/{viswapbuf.c => viswapbuf.cpp} | 0 .../io/{viswapcontext.c => viswapcontext.cpp} | 0 src/libultra/rmon/{sprintf.c => sprintf.cpp} | 0 src/libultra/rmon/{xldtob.c => xldtob.cpp} | 3 +- src/libultra/rmon/{xlitob.c => xlitob.cpp} | 2 +- src/libultra/rmon/{xprintf.c => xprintf.cpp} | 2 +- .../{z_arms_hook.c => z_arms_hook.cpp} | 218 +- .../{z_arrow_fire.c => z_arrow_fire.cpp} | 174 +- .../{z_arrow_ice.c => z_arrow_ice.cpp} | 174 +- .../{z_arrow_light.c => z_arrow_light.cpp} | 174 +- .../ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c | 480 - .../ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp | 478 + .../ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c | 547 - .../ovl_Bg_Bdan_Switch/z_bg_bdan_switch.cpp | 547 + .../actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.c | 93 - .../ovl_Bg_Bom_Guard/z_bg_bom_guard.cpp | 93 + .../{z_bg_bombwall.c => z_bg_bombwall.cpp} | 160 +- .../actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c | 230 - .../ovl_Bg_Bowl_Wall/z_bg_bowl_wall.cpp | 230 + .../{z_bg_breakwall.c => z_bg_breakwall.cpp} | 144 +- .../actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c | 187 - .../actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.cpp | 187 + .../actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c | 202 - .../actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.cpp | 202 + .../{z_bg_dodoago.c => z_bg_dodoago.cpp} | 196 +- ...{z_bg_dy_yoseizo.c => z_bg_dy_yoseizo.cpp} | 666 +- ...g_ganon_otyuka.c => z_bg_ganon_otyuka.cpp} | 176 +- .../ovl_Bg_Gate_Shutter/z_bg_gate_shutter.c | 144 - .../ovl_Bg_Gate_Shutter/z_bg_gate_shutter.cpp | 144 + ..._bg_gjyo_bridge.c => z_bg_gjyo_bridge.cpp} | 62 +- .../ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c | 221 - .../z_bg_gnd_darkmeiro.cpp | 221 + .../ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c | 158 - .../z_bg_gnd_firemeiro.cpp | 158 + ...g_gnd_iceblock.c => z_bg_gnd_iceblock.cpp} | 188 +- ...g_gnd_nisekabe.c => z_bg_gnd_nisekabe.cpp} | 20 +- ...gnd_soulmeiro.c => z_bg_gnd_soulmeiro.cpp} | 96 +- .../{z_bg_haka.c => z_bg_haka.cpp} | 104 +- .../{z_bg_haka_gate.c => z_bg_haka_gate.cpp} | 246 +- .../actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c | 229 - .../ovl_Bg_Haka_Huta/z_bg_haka_huta.cpp | 229 + ..._bg_haka_megane.c => z_bg_haka_megane.cpp} | 58 +- .../ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.c | 229 - .../z_bg_haka_meganebg.cpp | 228 + ...{z_bg_haka_sgami.c => z_bg_haka_sgami.cpp} | 147 +- .../actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c | 248 - .../ovl_Bg_Haka_Ship/z_bg_haka_ship.cpp | 248 + .../actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c | 564 - .../ovl_Bg_Haka_Trap/z_bg_haka_trap.cpp | 564 + .../{z_bg_haka_tubo.c => z_bg_haka_tubo.cpp} | 134 +- ...{z_bg_haka_water.c => z_bg_haka_water.cpp} | 92 +- .../actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c | 423 - .../actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.cpp | 423 + ..._bg_heavy_block.c => z_bg_heavy_block.cpp} | 258 +- .../ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c | 271 - .../z_bg_hidan_curtain.cpp | 271 + ...{z_bg_hidan_dalm.c => z_bg_hidan_dalm.cpp} | 110 +- .../z_bg_hidan_firewall.c | 223 - .../z_bg_hidan_firewall.cpp | 223 + .../ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c | 151 - .../ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.cpp | 151 + .../ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.c | 287 - .../ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.cpp | 287 + ...hidan_hamstep.c => z_bg_hidan_hamstep.cpp} | 238 +- ..._bg_hidan_hrock.c => z_bg_hidan_hrock.cpp} | 122 +- .../ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c | 172 - .../ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp | 172 + ...rerukabe.c => z_bg_hidan_kowarerukabe.cpp} | 118 +- .../ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c | 414 - .../ovl_Bg_Hidan_Rock/z_bg_hidan_rock.cpp | 414 + ...dan_rsekizou.c => z_bg_hidan_rsekizou.cpp} | 97 +- ...hidan_sekizou.c => z_bg_hidan_sekizou.cpp} | 186 +- .../ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c | 311 - .../ovl_Bg_Hidan_Sima/z_bg_hidan_sima.cpp | 311 + .../ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c | 135 - .../ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.cpp | 135 + ..._bg_ice_objects.c => z_bg_ice_objects.cpp} | 126 +- ..._bg_ice_shelter.c => z_bg_ice_shelter.cpp} | 190 +- .../ovl_Bg_Ice_Shutter/z_bg_ice_shutter.c | 143 - .../ovl_Bg_Ice_Shutter/z_bg_ice_shutter.cpp | 143 + .../ovl_Bg_Ice_Turara/z_bg_ice_turara.c | 212 - .../ovl_Bg_Ice_Turara/z_bg_ice_turara.cpp | 212 + .../{z_bg_ingate.c => z_bg_ingate.cpp} | 48 +- ...{z_bg_jya_1flift.c => z_bg_jya_1flift.cpp} | 132 +- .../z_bg_jya_amishutter.c | 135 - .../z_bg_jya_amishutter.cpp | 135 + ...jya_bigmirror.c => z_bg_jya_bigmirror.cpp} | 108 +- .../{z_bg_jya_block.c => z_bg_jya_block.cpp} | 20 +- ...a_bombchuiwa.c => z_bg_jya_bombchuiwa.cpp} | 146 +- ..._bg_jya_bombiwa.c => z_bg_jya_bombiwa.cpp} | 74 +- .../{z_bg_jya_cobra.c => z_bg_jya_cobra.cpp} | 286 +- ..._bg_jya_goroiwa.c => z_bg_jya_goroiwa.cpp} | 136 +- ...jya_haheniron.c => z_bg_jya_haheniron.cpp} | 130 +- ..._bg_jya_ironobj.c => z_bg_jya_ironobj.cpp} | 108 +- .../ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c | 137 - .../ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.cpp | 137 + .../{z_bg_jya_lift.c => z_bg_jya_lift.cpp} | 94 +- ...{z_bg_jya_megami.c => z_bg_jya_megami.cpp} | 182 +- ...a_zurerukabe.c => z_bg_jya_zurerukabe.cpp} | 98 +- ..._bg_menkuri_eye.c => z_bg_menkuri_eye.cpp} | 72 +- ...nkuri_kaiten.c => z_bg_menkuri_kaiten.cpp} | 22 +- ...i_nisekabe.c => z_bg_menkuri_nisekabe.cpp} | 18 +- ...{z_bg_mizu_bwall.c => z_bg_mizu_bwall.cpp} | 274 +- ..._bg_mizu_movebg.c => z_bg_mizu_movebg.cpp} | 158 +- .../ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c | 179 - .../ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp | 179 + .../{z_bg_mizu_uzu.c => z_bg_mizu_uzu.cpp} | 30 +- ...{z_bg_mizu_water.c => z_bg_mizu_water.cpp} | 166 +- .../{z_bg_mjin.c => z_bg_mjin.cpp} | 52 +- .../ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c | 269 - .../ovl_Bg_Mori_Bigst/z_bg_mori_bigst.cpp | 269 + .../ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c | 274 - .../z_bg_mori_elevator.cpp | 274 + .../ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c | 311 - .../ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.cpp | 311 + .../ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c | 184 - .../z_bg_mori_hashira4.cpp | 184 + .../ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c | 292 - .../ovl_Bg_Mori_Hineri/z_bg_mori_hineri.cpp | 292 + ...g_mori_idomizu.c => z_bg_mori_idomizu.cpp} | 110 +- ..._kaitenkabe.c => z_bg_mori_kaitenkabe.cpp} | 114 +- .../z_bg_mori_rakkatenjo.c | 247 - .../z_bg_mori_rakkatenjo.cpp | 247 + .../actors/ovl_Bg_Po_Event/z_bg_po_event.c | 649 - .../actors/ovl_Bg_Po_Event/z_bg_po_event.cpp | 649 + ..._bg_po_syokudai.c => z_bg_po_syokudai.cpp} | 58 +- .../{z_bg_pushbox.c => z_bg_pushbox.cpp} | 48 +- .../ovl_Bg_Relay_Objects/z_bg_relay_objects.c | 222 - .../z_bg_relay_objects.cpp | 222 + ...g_spot00_break.c => z_bg_spot00_break.cpp} | 22 +- ...00_hanebasi.c => z_bg_spot00_hanebasi.cpp} | 144 +- ...g_spot01_fusya.c => z_bg_spot01_fusya.cpp} | 36 +- ...dohashira.c => z_bg_spot01_idohashira.cpp} | 140 +- ...ot01_idomizu.c => z_bg_spot01_idomizu.cpp} | 30 +- ...ot01_idosoko.c => z_bg_spot01_idosoko.cpp} | 30 +- ...01_objects2.c => z_bg_spot01_objects2.cpp} | 58 +- ...ot02_objects.c => z_bg_spot02_objects.cpp} | 156 +- ..._bg_spot03_taki.c => z_bg_spot03_taki.cpp} | 111 +- ..._bg_spot05_soko.c => z_bg_spot05_soko.cpp} | 54 +- .../z_bg_spot06_objects.c | 525 - .../z_bg_spot06_objects.cpp | 525 + ..._bg_spot07_taki.c => z_bg_spot07_taki.cpp} | 34 +- ...udankabe.c => z_bg_spot08_bakudankabe.cpp} | 74 +- .../z_bg_spot08_iceblock.c | 457 - .../z_bg_spot08_iceblock.cpp | 457 + ...{z_bg_spot09_obj.c => z_bg_spot09_obj.cpp} | 80 +- ...udankabe.c => z_bg_spot11_bakudankabe.cpp} | 54 +- ...g_spot11_oasis.c => z_bg_spot11_oasis.cpp} | 72 +- .../ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c | 151 - .../ovl_Bg_Spot12_Gate/z_bg_spot12_gate.cpp | 151 + .../ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c | 143 - .../ovl_Bg_Spot12_Saku/z_bg_spot12_saku.cpp | 143 + .../ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c | 376 - .../ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.cpp | 376 + ..._bg_spot15_saku.c => z_bg_spot15_saku.cpp} | 74 +- ..._bombstone.c => z_bg_spot16_bombstone.cpp} | 286 +- ...16_doughnut.c => z_bg_spot16_doughnut.cpp} | 80 +- ...udankabe.c => z_bg_spot17_bakudankabe.cpp} | 44 +- ...g_spot17_funen.c => z_bg_spot17_funen.cpp} | 14 +- .../ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c | 466 - .../z_bg_spot18_basket.cpp | 466 + ..._bg_spot18_futa.c => z_bg_spot18_futa.cpp} | 26 +- .../ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c | 294 - .../ovl_Bg_Spot18_Obj/z_bg_spot18_obj.cpp | 294 + .../z_bg_spot18_shutter.c | 149 - .../z_bg_spot18_shutter.cpp | 149 + .../{z_bg_sst_floor.c => z_bg_sst_floor.cpp} | 64 +- ..._bg_toki_hikari.c => z_bg_toki_hikari.cpp} | 90 +- .../{z_bg_toki_swd.c => z_bg_toki_swd.cpp} | 74 +- ..._1.c => z_bg_toki_swd_cutscene_data_1.cpp} | 0 ..._2.c => z_bg_toki_swd_cutscene_data_2.cpp} | 0 ..._3.c => z_bg_toki_swd_cutscene_data_3.cpp} | 0 .../{z_bg_treemouth.c => z_bg_treemouth.cpp} | 112 +- ...ata.c => z_bg_treemouth_cutscene_data.cpp} | 0 .../{z_bg_umajump.c => z_bg_umajump.cpp} | 20 +- .../{z_bg_vb_sima.c => z_bg_vb_sima.cpp} | 36 +- .../actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c | 203 - .../ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.cpp | 203 + .../ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c | 218 - .../ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.cpp | 218 + .../actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c | 472 - .../actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.cpp | 472 + .../ovl_Bg_Zg/{z_bg_zg.c => z_bg_zg.cpp} | 84 +- .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 1725 -- .../ovl_Boss_Dodongo/z_boss_dodongo.cpp | 1725 ++ ...dodongo_data.c => z_boss_dodongo_data.cpp} | 2 +- src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c | 1997 --- src/overlays/actors/ovl_Boss_Fd/z_boss_fd.cpp | 1997 +++ ..._boss_fd_colchk.c => z_boss_fd_colchk.cpp} | 0 src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c | 1231 -- .../actors/ovl_Boss_Fd2/z_boss_fd2.cpp | 1231 ++ ...oss_fd2_colchk.c => z_boss_fd2_colchk.cpp} | 0 .../actors/ovl_Boss_Ganon/z_boss_ganon.c | 5040 ------ .../actors/ovl_Boss_Ganon/z_boss_ganon.cpp | 5039 ++++++ .../actors/ovl_Boss_Ganon2/z_boss_ganon2.c | 3093 ---- .../actors/ovl_Boss_Ganon2/z_boss_ganon2.cpp | 3093 ++++ ...s_ganon2_data.c => z_boss_ganon2_data.cpp} | 2 +- .../ovl_Boss_Ganondrof/z_boss_ganondrof.c | 1540 -- .../ovl_Boss_Ganondrof/z_boss_ganondrof.cpp | 1540 ++ .../actors/ovl_Boss_Goma/z_boss_goma.c | 2165 --- .../actors/ovl_Boss_Goma/z_boss_goma.cpp | 2165 +++ .../{z_boss_mo.c => z_boss_mo.cpp} | 2236 +-- ..._boss_mo_colchk.c => z_boss_mo_colchk.cpp} | 0 src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c | 3244 ---- .../actors/ovl_Boss_Sst/z_boss_sst.cpp | 3244 ++++ ...oss_sst_colchk.c => z_boss_sst_colchk.cpp} | 0 .../{z_boss_tw.c => z_boss_tw.cpp} | 3362 ++-- src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h | 2 +- .../{z_boss_va.c => z_boss_va.cpp} | 2364 +-- .../{z_demo_6k.c => z_demo_6k.cpp} | 522 +- src/overlays/actors/ovl_Demo_Du/z_demo_du.c | 1059 -- src/overlays/actors/ovl_Demo_Du/z_demo_du.cpp | 1059 ++ ...ene_data.c => z_demo_du_cutscene_data.cpp} | 0 src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c | 1352 -- src/overlays/actors/ovl_Demo_Ec/z_demo_ec.cpp | 1352 ++ .../{z_demo_effect.c => z_demo_effect.cpp} | 1366 +- .../{z_demo_ext.c => z_demo_ext.cpp} | 142 +- .../{z_demo_geff.c => z_demo_geff.cpp} | 108 +- src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c | 1476 -- src/overlays/actors/ovl_Demo_Gj/z_demo_gj.cpp | 1476 ++ src/overlays/actors/ovl_Demo_Go/z_demo_go.c | 362 - src/overlays/actors/ovl_Demo_Go/z_demo_go.cpp | 362 + .../{z_demo_gt.c => z_demo_gt.cpp} | 702 +- .../{z_demo_ik.c => z_demo_ik.cpp} | 300 +- src/overlays/actors/ovl_Demo_Ik/z_demo_ik.h | 4 +- src/overlays/actors/ovl_Demo_Im/z_demo_im.c | 1226 -- src/overlays/actors/ovl_Demo_Im/z_demo_im.cpp | 1226 ++ ...ene_data.c => z_demo_im_cutscene_data.cpp} | 0 .../{z_demo_kankyo.c => z_demo_kankyo.cpp} | 464 +- ...ta1.c => z_demo_kankyo_cutscene_data1.cpp} | 0 ...ta2.c => z_demo_kankyo_cutscene_data2.cpp} | 0 ...ta3.c => z_demo_kankyo_cutscene_data3.cpp} | 0 ...ta4.c => z_demo_kankyo_cutscene_data4.cpp} | 0 ...ta5.c => z_demo_kankyo_cutscene_data5.cpp} | 0 ...ta6.c => z_demo_kankyo_cutscene_data6.cpp} | 0 ...ta7.c => z_demo_kankyo_cutscene_data7.cpp} | 0 ...ta8.c => z_demo_kankyo_cutscene_data8.cpp} | 0 .../{z_demo_kekkai.c => z_demo_kekkai.cpp} | 184 +- .../actors/ovl_Demo_Kekkai/z_demo_kekkai.h | 11 +- src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c | 836 - src/overlays/actors/ovl_Demo_Sa/z_demo_sa.cpp | 836 + ...ene_data.c => z_demo_sa_cutscene_data.cpp} | 0 .../{z_demo_shd.c => z_demo_shd.cpp} | 54 +- .../{z_demo_tre_lgt.c => z_demo_tre_lgt.cpp} | 84 +- .../{z_door_ana.c => z_door_ana.cpp} | 106 +- .../{z_door_gerudo.c => z_door_gerudo.cpp} | 76 +- .../{z_door_killer.c => z_door_killer.cpp} | 346 +- .../{z_door_shutter.c => z_door_shutter.cpp} | 486 +- .../{z_door_toki.c => z_door_toki.cpp} | 20 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 1064 -- .../actors/ovl_Door_Warp1/z_door_warp1.cpp | 1064 ++ .../{z_efc_erupc.c => z_efc_erupc.cpp} | 86 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 380 - .../actors/ovl_Eff_Dust/z_eff_dust.cpp | 380 + src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h | 11 +- .../{z_elf_msg.c => z_elf_msg.cpp} | 98 +- src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c | 173 - .../actors/ovl_Elf_Msg2/z_elf_msg2.cpp | 173 + src/overlays/actors/ovl_En_Am/z_en_am.c | 989 -- src/overlays/actors/ovl_En_Am/z_en_am.cpp | 989 ++ src/overlays/actors/ovl_En_Ani/z_en_ani.c | 341 - src/overlays/actors/ovl_En_Ani/z_en_ani.cpp | 341 + .../actors/ovl_En_Anubice/z_en_anubice.c | 502 - .../actors/ovl_En_Anubice/z_en_anubice.cpp | 502 + .../ovl_En_Anubice_Fire/z_en_anubice_fire.c | 270 - .../ovl_En_Anubice_Fire/z_en_anubice_fire.cpp | 270 + .../ovl_En_Anubice_Tag/z_en_anubice_tag.c | 110 - .../ovl_En_Anubice_Tag/z_en_anubice_tag.cpp | 110 + .../{z_en_arow_trap.c => z_en_arow_trap.cpp} | 28 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 512 - .../actors/ovl_En_Arrow/z_en_arrow.cpp | 512 + .../ovl_En_Attack_Niw/z_en_attack_niw.c | 411 - .../ovl_En_Attack_Niw/z_en_attack_niw.cpp | 411 + src/overlays/actors/ovl_En_Ba/z_en_ba.c | 533 - src/overlays/actors/ovl_En_Ba/z_en_ba.cpp | 533 + src/overlays/actors/ovl_En_Bb/z_en_bb.c | 1367 -- src/overlays/actors/ovl_En_Bb/z_en_bb.cpp | 1367 ++ .../actors/ovl_En_Bdfire/z_en_bdfire.c | 238 - .../actors/ovl_En_Bdfire/z_en_bdfire.cpp | 238 + .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 916 - .../actors/ovl_En_Bigokuta/z_en_bigokuta.cpp | 916 + src/overlays/actors/ovl_En_Bili/z_en_bili.c | 784 - src/overlays/actors/ovl_En_Bili/z_en_bili.cpp | 784 + src/overlays/actors/ovl_En_Bird/z_en_bird.c | 138 - src/overlays/actors/ovl_En_Bird/z_en_bird.cpp | 138 + .../{z_en_blkobj.c => z_en_blkobj.cpp} | 88 +- .../ovl_En_Bom/{z_en_bom.c => z_en_bom.cpp} | 168 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 547 - .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.cpp | 547 + .../ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c | 229 - .../ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.cpp | 229 + .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 531 - .../actors/ovl_En_Bom_Chu/z_en_bom_chu.cpp | 531 + .../{z_en_bombf.c => z_en_bombf.cpp} | 250 +- .../{z_en_boom.c => z_en_boom.cpp} | 118 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 667 - src/overlays/actors/ovl_En_Box/z_en_box.cpp | 667 + src/overlays/actors/ovl_En_Brob/z_en_brob.c | 339 - src/overlays/actors/ovl_En_Brob/z_en_brob.cpp | 339 + src/overlays/actors/ovl_En_Brob/z_en_brob.h | 2 +- .../actors/ovl_En_Bubble/z_en_bubble.c | 449 - .../actors/ovl_En_Bubble/z_en_bubble.cpp | 449 + src/overlays/actors/ovl_En_Butte/z_en_butte.c | 447 - .../actors/ovl_En_Butte/z_en_butte.cpp | 447 + src/overlays/actors/ovl_En_Bw/z_en_bw.c | 918 - src/overlays/actors/ovl_En_Bw/z_en_bw.cpp | 918 + .../ovl_En_Bx/{z_en_bx.c => z_en_bx.cpp} | 112 +- .../{z_en_changer.c => z_en_changer.cpp} | 128 +- .../{z_en_clear_tag.c => z_en_clear_tag.cpp} | 446 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 404 - src/overlays/actors/ovl_En_Cow/z_en_cow.cpp | 404 + src/overlays/actors/ovl_En_Crow/z_en_crow.c | 522 - src/overlays/actors/ovl_En_Crow/z_en_crow.cpp | 522 + .../ovl_En_Cs/{z_en_cs.c => z_en_cs.cpp} | 286 +- .../{z_en_daiku.c => z_en_daiku.cpp} | 380 +- .../z_en_daiku_kakariko.c | 567 - .../z_en_daiku_kakariko.cpp | 567 + .../actors/ovl_En_Dekubaba/z_en_dekubaba.c | 1330 -- .../actors/ovl_En_Dekubaba/z_en_dekubaba.cpp | 1330 ++ .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 546 - .../actors/ovl_En_Dekunuts/z_en_dekunuts.cpp | 546 + src/overlays/actors/ovl_En_Dh/z_en_dh.c | 595 - src/overlays/actors/ovl_En_Dh/z_en_dh.cpp | 595 + src/overlays/actors/ovl_En_Dha/z_en_dha.c | 475 - src/overlays/actors/ovl_En_Dha/z_en_dha.cpp | 475 + .../ovl_En_Diving_Game/z_en_diving_game.c | 588 - .../ovl_En_Diving_Game/z_en_diving_game.cpp | 588 + src/overlays/actors/ovl_En_Dns/z_en_dns.c | 513 - src/overlays/actors/ovl_En_Dns/z_en_dns.cpp | 513 + .../{z_en_dnt_demo.c => z_en_dnt_demo.cpp} | 210 +- .../actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c | 461 - .../actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.cpp | 461 + .../actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c | 903 - .../ovl_En_Dnt_Nomal/z_en_dnt_nomal.cpp | 903 + .../actors/ovl_En_Dodojr/z_en_dodojr.c | 663 - .../actors/ovl_En_Dodojr/z_en_dodojr.cpp | 663 + .../actors/ovl_En_Dodongo/z_en_dodongo.c | 981 -- .../actors/ovl_En_Dodongo/z_en_dodongo.cpp | 981 ++ src/overlays/actors/ovl_En_Dog/z_en_dog.c | 485 - src/overlays/actors/ovl_En_Dog/z_en_dog.cpp | 485 + .../{z_en_door.c => z_en_door.cpp} | 222 +- src/overlays/actors/ovl_En_Ds/z_en_ds.c | 291 - src/overlays/actors/ovl_En_Ds/z_en_ds.cpp | 291 + .../ovl_En_Du/{z_en_du.c => z_en_du.cpp} | 424 +- .../{z_en_dy_extra.c => z_en_dy_extra.cpp} | 86 +- .../ovl_En_Eg/{z_en_eg.c => z_en_eg.cpp} | 16 +- src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c | 731 - .../actors/ovl_En_Eiyer/z_en_eiyer.cpp | 731 + src/overlays/actors/ovl_En_Elf/z_en_elf.c | 1576 -- src/overlays/actors/ovl_En_Elf/z_en_elf.cpp | 1576 ++ .../{z_en_encount1.c => z_en_encount1.cpp} | 202 +- .../{z_en_encount2.c => z_en_encount2.cpp} | 166 +- .../actors/ovl_En_Ex_Item/z_en_ex_item.c | 529 - .../actors/ovl_En_Ex_Item/z_en_ex_item.cpp | 529 + .../actors/ovl_En_Ex_Item/z_en_ex_item.h | 2 +- .../actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c | 407 - .../actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.cpp | 407 + .../ovl_En_Fd/{z_en_fd.c => z_en_fd.cpp} | 540 +- src/overlays/actors/ovl_En_Fd/z_en_fd.h | 3 +- .../actors/ovl_En_Fd_Fire/z_en_fd_fire.c | 296 - .../actors/ovl_En_Fd_Fire/z_en_fd_fire.cpp | 296 + .../actors/ovl_En_Fd_Fire/z_en_fd_fire.h | 2 +- .../actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c | 773 - .../actors/ovl_En_Fhg_Fire/z_en_fhg_fire.cpp | 773 + .../actors/ovl_En_Fire_Rock/z_en_fire_rock.c | 402 - .../ovl_En_Fire_Rock/z_en_fire_rock.cpp | 402 + .../actors/ovl_En_Firefly/z_en_firefly.c | 847 - .../actors/ovl_En_Firefly/z_en_firefly.cpp | 847 + src/overlays/actors/ovl_En_Fish/z_en_fish.c | 777 - src/overlays/actors/ovl_En_Fish/z_en_fish.cpp | 777 + .../actors/ovl_En_Floormas/z_en_floormas.c | 1155 -- .../actors/ovl_En_Floormas/z_en_floormas.cpp | 1155 ++ .../actors/ovl_En_Floormas/z_en_floormas.h | 5 +- src/overlays/actors/ovl_En_Fr/z_en_fr.c | 1099 -- src/overlays/actors/ovl_En_Fr/z_en_fr.cpp | 1099 ++ .../ovl_En_Fu/{z_en_fu.c => z_en_fu.cpp} | 198 +- src/overlays/actors/ovl_En_Fw/z_en_fw.c | 497 - src/overlays/actors/ovl_En_Fw/z_en_fw.cpp | 497 + src/overlays/actors/ovl_En_Fw/z_en_fw.h | 2 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 902 - src/overlays/actors/ovl_En_Fz/z_en_fz.cpp | 902 + .../{z_en_g_switch.c => z_en_g_switch.cpp} | 406 +- ...{z_en_ganon_mant.c => z_en_ganon_mant.cpp} | 138 +- ..._en_ganon_organ.c => z_en_ganon_organ.cpp} | 10 +- src/overlays/actors/ovl_En_Gb/z_en_gb.c | 569 - src/overlays/actors/ovl_En_Gb/z_en_gb.cpp | 569 + src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 826 - src/overlays/actors/ovl_En_Ge1/z_en_ge1.cpp | 826 + src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 670 - src/overlays/actors/ovl_En_Ge2/z_en_ge2.cpp | 670 + src/overlays/actors/ovl_En_Ge3/z_en_ge3.c | 304 - src/overlays/actors/ovl_En_Ge3/z_en_ge3.cpp | 304 + src/overlays/actors/ovl_En_GeldB/z_en_geldb.c | 1659 -- .../actors/ovl_En_GeldB/z_en_geldb.cpp | 1659 ++ .../{z_en_girla.c => z_en_girla.cpp} | 554 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 346 - src/overlays/actors/ovl_En_Gm/z_en_gm.cpp | 346 + .../ovl_En_Go/{z_en_go.c => z_en_go.cpp} | 754 +- src/overlays/actors/ovl_En_Go2/z_en_go2.c | 2073 --- src/overlays/actors/ovl_En_Go2/z_en_go2.cpp | 2073 +++ src/overlays/actors/ovl_En_Goma/z_en_goma.c | 922 - src/overlays/actors/ovl_En_Goma/z_en_goma.cpp | 922 + .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 769 - .../actors/ovl_En_Goroiwa/z_en_goroiwa.cpp | 769 + src/overlays/actors/ovl_En_Gs/z_en_gs.c | 628 - src/overlays/actors/ovl_En_Gs/z_en_gs.cpp | 628 + .../{z_en_guest.c => z_en_guest.cpp} | 142 +- src/overlays/actors/ovl_En_Guest/z_en_guest.h | 2 +- .../{z_en_hata.c => z_en_hata.cpp} | 68 +- .../actors/ovl_En_Heishi1/z_en_heishi1.c | 506 - .../actors/ovl_En_Heishi1/z_en_heishi1.cpp | 506 + .../actors/ovl_En_Heishi2/z_en_heishi2.c | 880 - .../actors/ovl_En_Heishi2/z_en_heishi2.cpp | 880 + .../actors/ovl_En_Heishi3/z_en_heishi3.c | 262 - .../actors/ovl_En_Heishi3/z_en_heishi3.cpp | 262 + .../actors/ovl_En_Heishi4/z_en_heishi4.c | 395 - .../actors/ovl_En_Heishi4/z_en_heishi4.cpp | 395 + .../actors/ovl_En_Hintnuts/z_en_hintnuts.c | 553 - .../actors/ovl_En_Hintnuts/z_en_hintnuts.cpp | 553 + .../{z_en_holl.c => z_en_holl.cpp} | 194 +- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 553 - .../actors/ovl_En_Honotrap/z_en_honotrap.cpp | 553 + src/overlays/actors/ovl_En_Horse/z_en_horse.c | 3867 ----- .../actors/ovl_En_Horse/z_en_horse.cpp | 3869 +++++ ...game_check.c => z_en_horse_game_check.cpp} | 256 +- .../z_en_horse_game_check.h | 2 +- .../ovl_En_Horse_Ganon/z_en_horse_ganon.c | 343 - .../ovl_En_Horse_Ganon/z_en_horse_ganon.cpp | 343 + .../z_en_horse_link_child.c | 638 - .../z_en_horse_link_child.cpp | 638 + .../ovl_En_Horse_Normal/z_en_horse_normal.c | 730 - .../ovl_En_Horse_Normal/z_en_horse_normal.cpp | 730 + .../ovl_En_Horse_Zelda/z_en_horse_zelda.c | 287 - .../ovl_En_Horse_Zelda/z_en_horse_zelda.cpp | 287 + src/overlays/actors/ovl_En_Hs/z_en_hs.c | 310 - src/overlays/actors/ovl_En_Hs/z_en_hs.cpp | 310 + src/overlays/actors/ovl_En_Hs2/z_en_hs2.c | 177 - src/overlays/actors/ovl_En_Hs2/z_en_hs2.cpp | 177 + .../ovl_En_Hy/{z_en_hy.c => z_en_hy.cpp} | 480 +- .../actors/ovl_En_Ice_Hono/z_en_ice_hono.c | 407 - .../actors/ovl_En_Ice_Hono/z_en_ice_hono.cpp | 407 + src/overlays/actors/ovl_En_Ik/z_en_ik.c | 1483 -- src/overlays/actors/ovl_En_Ik/z_en_ik.cpp | 1483 ++ .../ovl_En_In/{z_en_in.c => z_en_in.cpp} | 602 +- .../actors/ovl_En_Insect/z_en_insect.c | 805 - .../actors/ovl_En_Insect/z_en_insect.cpp | 805 + .../{z_en_ishi.c => z_en_ishi.cpp} | 320 +- .../ovl_En_It/{z_en_it.c => z_en_it.cpp} | 22 +- src/overlays/actors/ovl_En_Jj/z_en_jj.c | 335 - src/overlays/actors/ovl_En_Jj/z_en_jj.cpp | 335 + ...scene_data.c => z_en_jj_cutscene_data.cpp} | 0 src/overlays/actors/ovl_En_Js/z_en_js.c | 243 - src/overlays/actors/ovl_En_Js/z_en_js.cpp | 243 + .../{z_en_jsjutan.c => z_en_jsjutan.cpp} | 132 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 359 - .../actors/ovl_En_Kakasi/z_en_kakasi.cpp | 359 + .../actors/ovl_En_Kakasi2/z_en_kakasi2.c | 234 - .../actors/ovl_En_Kakasi2/z_en_kakasi2.cpp | 234 + .../actors/ovl_En_Kakasi3/z_en_kakasi3.c | 451 - .../actors/ovl_En_Kakasi3/z_en_kakasi3.cpp | 451 + .../{z_en_kanban.c => z_en_kanban.cpp} | 644 +- ...{z_en_kanban_gfx.c => z_en_kanban_gfx.cpp} | 0 .../actors/ovl_En_Karebaba/z_en_karebaba.c | 553 - .../actors/ovl_En_Karebaba/z_en_karebaba.cpp | 553 + .../ovl_En_Ko/{z_en_ko.c => z_en_ko.cpp} | 656 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 515 - src/overlays/actors/ovl_En_Kusa/z_en_kusa.cpp | 515 + src/overlays/actors/ovl_En_Kz/z_en_kz.c | 516 - src/overlays/actors/ovl_En_Kz/z_en_kz.cpp | 516 + .../{z_en_light.c => z_en_light.cpp} | 98 +- .../{z_en_lightbox.c => z_en_lightbox.cpp} | 22 +- .../{z_en_m_fire1.c => z_en_m_fire1.cpp} | 26 +- .../{z_en_m_thunder.c => z_en_m_thunder.cpp} | 250 +- .../ovl_En_Ma1/{z_en_ma1.c => z_en_ma1.cpp} | 228 +- .../ovl_En_Ma2/{z_en_ma2.c => z_en_ma2.cpp} | 212 +- .../ovl_En_Ma3/{z_en_ma3.c => z_en_ma3.cpp} | 158 +- .../ovl_En_Mag/{z_en_mag.c => z_en_mag.cpp} | 270 +- src/overlays/actors/ovl_En_Mb/z_en_mb.c | 1571 -- src/overlays/actors/ovl_En_Mb/z_en_mb.cpp | 1571 ++ src/overlays/actors/ovl_En_Md/z_en_md.c | 860 - src/overlays/actors/ovl_En_Md/z_en_md.cpp | 860 + src/overlays/actors/ovl_En_Mk/z_en_mk.c | 383 - src/overlays/actors/ovl_En_Mk/z_en_mk.cpp | 383 + .../ovl_En_Mm/{z_en_mm.c => z_en_mm.cpp} | 310 +- .../ovl_En_Mm2/{z_en_mm2.c => z_en_mm2.cpp} | 228 +- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 197 - src/overlays/actors/ovl_En_Ms/z_en_ms.cpp | 197 + .../ovl_En_Mu/{z_en_mu.c => z_en_mu.cpp} | 100 +- src/overlays/actors/ovl_En_Nb/z_en_nb.c | 1555 -- src/overlays/actors/ovl_En_Nb/z_en_nb.cpp | 1555 ++ ...scene_data.c => z_en_nb_cutscene_data.cpp} | 0 src/overlays/actors/ovl_En_Niw/z_en_niw.c | 1240 -- src/overlays/actors/ovl_En_Niw/z_en_niw.cpp | 1240 ++ .../actors/ovl_En_Niw_Girl/z_en_niw_girl.c | 274 - .../actors/ovl_En_Niw_Girl/z_en_niw_girl.cpp | 274 + .../actors/ovl_En_Niw_Lady/z_en_niw_lady.c | 596 - .../actors/ovl_En_Niw_Lady/z_en_niw_lady.cpp | 594 + .../{z_en_nutsball.c => z_en_nutsball.cpp} | 104 +- .../ovl_En_Nwc/{z_en_nwc.c => z_en_nwc.cpp} | 78 +- src/overlays/actors/ovl_En_Ny/z_en_ny.c | 616 - src/overlays/actors/ovl_En_Ny/z_en_ny.cpp | 616 + .../ovl_En_OE2/{z_en_oe2.c => z_en_oe2.cpp} | 14 +- ...arina_effect.c => z_en_okarina_effect.cpp} | 44 +- ..._en_okarina_tag.c => z_en_okarina_tag.cpp} | 194 +- ...a.c => z_en_okarina_tag_cutscene_data.cpp} | 0 src/overlays/actors/ovl_En_Okuta/z_en_okuta.c | 737 - .../actors/ovl_En_Okuta/z_en_okuta.cpp | 737 + .../{z_en_ossan.c => z_en_ossan.cpp} | 1584 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 1438 -- src/overlays/actors/ovl_En_Owl/z_en_owl.cpp | 1438 ++ .../{z_en_part.c => z_en_part.cpp} | 210 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 1096 -- .../actors/ovl_En_Peehat/z_en_peehat.cpp | 1096 ++ .../actors/ovl_En_Po_Desert/z_en_po_desert.c | 283 - .../ovl_En_Po_Desert/z_en_po_desert.cpp | 283 + .../actors/ovl_En_Po_Field/z_en_po_field.c | 1022 -- .../actors/ovl_En_Po_Field/z_en_po_field.cpp | 1022 ++ .../actors/ovl_En_Po_Relay/z_en_po_relay.c | 423 - .../actors/ovl_En_Po_Relay/z_en_po_relay.cpp | 423 + .../ovl_En_Po_Sisters/z_en_po_sisters.c | 1436 -- .../ovl_En_Po_Sisters/z_en_po_sisters.cpp | 1436 ++ src/overlays/actors/ovl_En_Poh/z_en_poh.c | 1219 -- src/overlays/actors/ovl_En_Poh/z_en_poh.cpp | 1219 ++ .../{z_en_pu_box.c => z_en_pu_box.cpp} | 26 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 940 - src/overlays/actors/ovl_En_Rd/z_en_rd.cpp | 940 + src/overlays/actors/ovl_En_Reeba/z_en_reeba.c | 678 - .../actors/ovl_En_Reeba/z_en_reeba.cpp | 678 + ..._en_river_sound.c => z_en_river_sound.cpp} | 86 +- src/overlays/actors/ovl_En_Rl/z_en_rl.c | 401 - src/overlays/actors/ovl_En_Rl/z_en_rl.cpp | 401 + src/overlays/actors/ovl_En_Rr/z_en_rr.c | 917 - src/overlays/actors/ovl_En_Rr/z_en_rr.cpp | 917 + src/overlays/actors/ovl_En_Ru1/z_en_ru1.c | 2385 --- src/overlays/actors/ovl_En_Ru1/z_en_ru1.cpp | 2385 +++ ...cene_data.c => z_en_ru1_cutscene_data.cpp} | 0 src/overlays/actors/ovl_En_Ru2/z_en_ru2.c | 842 - src/overlays/actors/ovl_En_Ru2/z_en_ru2.cpp | 842 + ...cene_data.c => z_en_ru2_cutscene_data.cpp} | 0 src/overlays/actors/ovl_En_Sa/z_en_sa.c | 800 - src/overlays/actors/ovl_En_Sa/z_en_sa.cpp | 800 + src/overlays/actors/ovl_En_Sb/z_en_sb.c | 512 - src/overlays/actors/ovl_En_Sb/z_en_sb.cpp | 512 + ...n_scene_change.c => z_en_scene_change.cpp} | 20 +- .../ovl_En_Sda/{z_en_sda.c => z_en_sda.cpp} | 28 +- .../actors/ovl_En_Shopnuts/z_en_shopnuts.c | 315 - .../actors/ovl_En_Shopnuts/z_en_shopnuts.cpp | 315 + .../ovl_En_Si/{z_en_si.c => z_en_si.cpp} | 98 +- .../actors/ovl_En_Siofuki/z_en_siofuki.c | 324 - .../actors/ovl_En_Siofuki/z_en_siofuki.cpp | 324 + src/overlays/actors/ovl_En_Skb/z_en_skb.c | 566 - src/overlays/actors/ovl_En_Skb/z_en_skb.cpp | 566 + src/overlays/actors/ovl_En_Skj/z_en_skj.c | 1675 -- src/overlays/actors/ovl_En_Skj/z_en_skj.cpp | 1675 ++ .../{z_en_skjneedle.c => z_en_skjneedle.cpp} | 50 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 899 - src/overlays/actors/ovl_En_Ssh/z_en_ssh.cpp | 899 + src/overlays/actors/ovl_En_St/z_en_st.c | 1093 -- src/overlays/actors/ovl_En_St/z_en_st.cpp | 1093 ++ src/overlays/actors/ovl_En_St/z_en_st.h | 2 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 424 - src/overlays/actors/ovl_En_Sth/z_en_sth.cpp | 424 + .../{z_en_stream.c => z_en_stream.cpp} | 38 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 1029 -- src/overlays/actors/ovl_En_Sw/z_en_sw.cpp | 1029 ++ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 2 +- ..._en_syateki_itm.c => z_en_syateki_itm.cpp} | 246 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 523 - .../ovl_En_Syateki_Man/z_en_syateki_man.cpp | 523 + .../ovl_En_Syateki_Niw/z_en_syateki_niw.c | 805 - .../ovl_En_Syateki_Niw/z_en_syateki_niw.cpp | 805 + src/overlays/actors/ovl_En_Ta/z_en_ta.c | 1241 -- src/overlays/actors/ovl_En_Ta/z_en_ta.cpp | 1241 ++ .../ovl_En_Takara_Man/z_en_takara_man.c | 237 - .../ovl_En_Takara_Man/z_en_takara_man.cpp | 237 + .../{z_en_tana.c => z_en_tana.cpp} | 10 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 2072 --- src/overlays/actors/ovl_En_Test/z_en_test.cpp | 2072 +++ .../ovl_En_Tg/{z_en_tg.c => z_en_tg.cpp} | 86 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 1024 -- src/overlays/actors/ovl_En_Tite/z_en_tite.cpp | 1024 ++ .../ovl_En_Tk/{z_en_tk.c => z_en_tk.cpp} | 396 +- .../{z_en_torch.c => z_en_torch.cpp} | 10 +- .../{z_en_torch2.c => z_en_torch2.cpp} | 428 +- .../{z_en_toryo.c => z_en_toryo.cpp} | 176 +- src/overlays/actors/ovl_En_Toryo/z_en_toryo.h | 2 +- src/overlays/actors/ovl_En_Tp/z_en_tp.c | 778 - src/overlays/actors/ovl_En_Tp/z_en_tp.cpp | 778 + src/overlays/actors/ovl_En_Tr/z_en_tr.c | 541 - src/overlays/actors/ovl_En_Tr/z_en_tr.cpp | 541 + .../{z_en_trap.c => z_en_trap.cpp} | 208 +- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 300 - .../ovl_En_Tubo_Trap/z_en_tubo_trap.cpp | 300 + src/overlays/actors/ovl_En_Vali/z_en_vali.c | 824 - src/overlays/actors/ovl_En_Vali/z_en_vali.cpp | 824 + .../{z_en_vase.c => z_en_vase.cpp} | 10 +- .../{z_en_vb_ball.c => z_en_vb_ball.cpp} | 178 +- .../{z_en_viewer.c => z_en_viewer.cpp} | 438 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 568 - src/overlays/actors/ovl_En_Vm/z_en_vm.cpp | 568 + .../{z_en_wall_tubo.c => z_en_wall_tubo.cpp} | 64 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 668 - .../actors/ovl_En_Wallmas/z_en_wallmas.cpp | 668 + ..._en_weather_tag.c => z_en_weather_tag.cpp} | 168 +- .../actors/ovl_En_Weiyer/z_en_weiyer.c | 662 - .../actors/ovl_En_Weiyer/z_en_weiyer.cpp | 662 + src/overlays/actors/ovl_En_Wf/z_en_wf.c | 1503 -- src/overlays/actors/ovl_En_Wf/z_en_wf.cpp | 1503 ++ .../ovl_En_Wonder_Item/z_en_wonder_item.c | 354 - .../ovl_En_Wonder_Item/z_en_wonder_item.cpp | 354 + ..._en_wonder_talk.c => z_en_wonder_talk.cpp} | 194 +- ...n_wonder_talk2.c => z_en_wonder_talk2.cpp} | 202 +- .../actors/ovl_En_Wood02/z_en_wood02.c | 471 - .../actors/ovl_En_Wood02/z_en_wood02.cpp | 471 + src/overlays/actors/ovl_En_Xc/z_en_xc.c | 2448 --- src/overlays/actors/ovl_En_Xc/z_en_xc.cpp | 2448 +++ ...yabusame_mark.c => z_en_yabusame_mark.cpp} | 116 +- .../actors/ovl_En_Yukabyun/z_en_yukabyun.c | 167 - .../actors/ovl_En_Yukabyun/z_en_yukabyun.cpp | 167 + src/overlays/actors/ovl_En_Zf/z_en_zf.c | 2439 --- src/overlays/actors/ovl_En_Zf/z_en_zf.cpp | 2439 +++ src/overlays/actors/ovl_En_Zl1/z_en_zl1.c | 644 - src/overlays/actors/ovl_En_Zl1/z_en_zl1.cpp | 644 + ...camera_data.c => z_en_zl1_camera_data.cpp} | 0 ...cene_data.c => z_en_zl1_cutscene_data.cpp} | 0 src/overlays/actors/ovl_En_Zl2/z_en_zl2.c | 1708 -- src/overlays/actors/ovl_En_Zl2/z_en_zl2.cpp | 1708 ++ src/overlays/actors/ovl_En_Zl3/z_en_zl3.c | 2798 --- src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp | 2798 +++ .../ovl_En_Zl4/{z_en_zl4.c => z_en_zl4.cpp} | 864 +- ...cene_data.c => z_en_zl4_cutscene_data.cpp} | 0 .../ovl_En_Zo/{z_en_zo.c => z_en_zo.cpp} | 402 +- src/overlays/actors/ovl_En_fHG/z_en_fhg.c | 743 - src/overlays/actors/ovl_En_fHG/z_en_fhg.cpp | 743 + .../{z_end_title.c => z_end_title.cpp} | 44 +- .../{z_fishing.c => z_fishing.cpp} | 1606 +- .../{z_item_b_heart.c => z_item_b_heart.cpp} | 44 +- .../ovl_Item_Etcetera/z_item_etcetera.c | 225 - .../ovl_Item_Etcetera/z_item_etcetera.cpp | 225 + .../{z_item_inbox.c => z_item_inbox.cpp} | 28 +- .../actors/ovl_Item_Ocarina/z_item_ocarina.c | 209 - .../ovl_Item_Ocarina/z_item_ocarina.cpp | 209 + .../actors/ovl_Item_Shield/z_item_shield.c | 238 - .../actors/ovl_Item_Shield/z_item_shield.cpp | 238 + .../{z_magic_dark.c => z_magic_dark.cpp} | 126 +- .../{z_magic_fire.c => z_magic_fire.cpp} | 170 +- .../{z_magic_wind.c => z_magic_wind.cpp} | 96 +- .../actors/ovl_Magic_Wind/z_magic_wind.h | 2 +- .../{z_mir_ray.c => z_mir_ray.cpp} | 228 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 961 -- .../actors/ovl_Obj_Bean/z_obj_bean.cpp | 961 ++ ...{z_obj_blockstop.c => z_obj_blockstop.cpp} | 20 +- .../{z_obj_bombiwa.c => z_obj_bombiwa.cpp} | 50 +- .../{z_obj_comb.c => z_obj_comb.cpp} | 102 +- .../{z_obj_dekujr.c => z_obj_dekujr.cpp} | 80 +- .../{z_obj_elevator.c => z_obj_elevator.cpp} | 72 +- .../{z_obj_hamishi.c => z_obj_hamishi.cpp} | 116 +- .../{z_obj_hana.c => z_obj_hana.cpp} | 38 +- .../{z_obj_hsblock.c => z_obj_hsblock.cpp} | 94 +- .../{z_obj_ice_poly.c => z_obj_ice_poly.cpp} | 124 +- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 297 - .../actors/ovl_Obj_Kibako/z_obj_kibako.cpp | 297 + .../{z_obj_kibako2.c => z_obj_kibako2.cpp} | 92 +- src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c | 232 - .../actors/ovl_Obj_Lift/z_obj_lift.cpp | 232 + .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 511 - .../ovl_Obj_Lightswitch/z_obj_lightswitch.cpp | 511 + ...bj_makekinsuta.c => z_obj_makekinsuta.cpp} | 38 +- ..._makeoshihiki.c => z_obj_makeoshihiki.cpp} | 2 +- src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c | 421 - .../actors/ovl_Obj_Mure/z_obj_mure.cpp | 421 + .../actors/ovl_Obj_Mure2/z_obj_mure2.c | 227 - .../actors/ovl_Obj_Mure2/z_obj_mure2.cpp | 227 + .../actors/ovl_Obj_Mure3/z_obj_mure3.c | 203 - .../actors/ovl_Obj_Mure3/z_obj_mure3.cpp | 203 + .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 694 - .../ovl_Obj_Oshihiki/z_obj_oshihiki.cpp | 694 + ...{z_obj_roomtimer.c => z_obj_roomtimer.cpp} | 56 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 807 - .../actors/ovl_Obj_Switch/z_obj_switch.cpp | 807 + .../{z_obj_syokudai.c => z_obj_syokudai.cpp} | 154 +- .../ovl_Obj_Timeblock/z_obj_timeblock.c | 357 - .../ovl_Obj_Timeblock/z_obj_timeblock.cpp | 357 + .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 350 - .../actors/ovl_Obj_Tsubo/z_obj_tsubo.cpp | 350 + .../ovl_Obj_Warp2block/z_obj_warp2block.c | 330 - .../ovl_Obj_Warp2block/z_obj_warp2block.cpp | 330 + .../ovl_Object_Kankyo/z_object_kankyo.c | 955 -- .../ovl_Object_Kankyo/z_object_kankyo.cpp | 955 ++ .../{z_oceff_spot.c => z_oceff_spot.cpp} | 96 +- .../{z_oceff_storm.c => z_oceff_storm.cpp} | 118 +- .../{z_oceff_wipe.c => z_oceff_wipe.cpp} | 40 +- .../{z_oceff_wipe2.c => z_oceff_wipe2.cpp} | 36 +- .../{z_oceff_wipe3.c => z_oceff_wipe3.cpp} | 36 +- .../{z_oceff_wipe4.c => z_oceff_wipe4.cpp} | 38 +- .../{z_shot_sun.c => z_shot_sun.cpp} | 114 +- .../actors/ovl_player_actor/z_player.c | 14224 --------------- .../actors/ovl_player_actor/z_player.cpp | 14225 ++++++++++++++++ .../{z_eff_ss_blast.c => z_eff_ss_blast.cpp} | 70 +- .../{z_eff_ss_bomb.c => z_eff_ss_bomb.cpp} | 52 +- .../{z_eff_ss_bomb2.c => z_eff_ss_bomb2.cpp} | 124 +- ...{z_eff_ss_bubble.c => z_eff_ss_bubble.cpp} | 60 +- ...{z_eff_ss_d_fire.c => z_eff_ss_d_fire.cpp} | 92 +- ..._eff_ss_dead_db.c => z_eff_ss_dead_db.cpp} | 112 +- .../ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c | 151 - .../z_eff_ss_dead_dd.cpp | 151 + ..._eff_ss_dead_ds.c => z_eff_ss_dead_ds.cpp} | 86 +- ...s_dead_sound.c => z_eff_ss_dead_sound.cpp} | 32 +- .../z_eff_ss_dt_bubble.c | 112 - .../z_eff_ss_dt_bubble.cpp | 112 + .../ovl_Effect_Ss_Dust/z_eff_ss_dust.c | 196 - .../ovl_Effect_Ss_Dust/z_eff_ss_dust.cpp | 196 + ..._eff_ss_en_fire.c => z_eff_ss_en_fire.cpp} | 100 +- .../ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c | 173 - .../ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.cpp | 173 + .../{z_eff_ss_extra.c => z_eff_ss_extra.cpp} | 54 +- ..._eff_ss_fcircle.c => z_eff_ss_fcircle.cpp} | 70 +- ..._ss_fhg_flash.c => z_eff_ss_fhg_flash.cpp} | 156 +- ..._ss_fire_tail.c => z_eff_ss_fire_tail.cpp} | 104 +- ...{z_eff_ss_g_fire.c => z_eff_ss_g_fire.cpp} | 54 +- ..._eff_ss_g_magma.c => z_eff_ss_g_magma.cpp} | 52 +- ...ff_ss_g_magma2.c => z_eff_ss_g_magma2.cpp} | 94 +- ...ff_ss_g_ripple.c => z_eff_ss_g_ripple.cpp} | 90 +- .../ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c | 150 - .../ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.cpp | 150 + .../z_eff_ss_g_splash.c | 142 - .../z_eff_ss_g_splash.cpp | 142 + .../{z_eff_ss_hahen.c => z_eff_ss_hahen.cpp} | 104 +- ..._eff_ss_hitmark.c => z_eff_ss_hitmark.cpp} | 76 +- ..._ss_ice_piece.c => z_eff_ss_ice_piece.cpp} | 58 +- ..._ss_ice_smoke.c => z_eff_ss_ice_smoke.cpp} | 56 +- ...{z_eff_ss_k_fire.c => z_eff_ss_k_fire.cpp} | 74 +- .../ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c | 429 - .../ovl_Effect_Ss_Kakera/z_eff_ss_kakera.cpp | 429 + .../z_eff_ss_kirakira.c | 160 - .../z_eff_ss_kirakira.cpp | 160 + ..._ss_lightning.c => z_eff_ss_lightning.cpp} | 84 +- ...{z_eff_ss_sibuki.c => z_eff_ss_sibuki.cpp} | 92 +- ..._eff_ss_sibuki2.c => z_eff_ss_sibuki2.cpp} | 58 +- ...h_ball.c => z_eff_ss_solder_srch_ball.cpp} | 36 +- .../{z_eff_ss_stick.c => z_eff_ss_stick.cpp} | 44 +- ...{z_eff_ss_stone1.c => z_eff_ss_stone1.cpp} | 32 +- .../ovl_file_choose/z_file_choose.c | 1926 --- .../ovl_file_choose/z_file_choose.cpp | 1927 +++ .../ovl_file_choose/z_file_copy_erase.c | 1082 -- .../ovl_file_choose/z_file_copy_erase.cpp | 1082 ++ ...e_nameset_PAL.c => z_file_nameset_PAL.cpp} | 574 +- ...nameset_data.c => z_file_nameset_data.cpp} | 2 +- .../{z_opening.c => z_opening.cpp} | 30 +- .../ovl_select/{z_select.c => z_select.cpp} | 263 +- .../ovl_title/{z_title.c => z_title.cpp} | 124 +- ...aleido_collect.c => z_kaleido_collect.cpp} | 0 ...{z_kaleido_debug.c => z_kaleido_debug.cpp} | 0 ...do_equipment.c => z_kaleido_equipment.cpp} | 5 +- .../{z_kaleido_item.c => z_kaleido_item.cpp} | 0 ...aleido_map_PAL.c => z_kaleido_map_PAL.cpp} | 0 ..._kaleido_prompt.c => z_kaleido_prompt.cpp} | 0 ...do_scope_PAL.c => z_kaleido_scope_PAL.cpp} | 69 +- .../{z_lmap_mark.c => z_lmap_mark.cpp} | 0 ..._lmap_mark_data.c => z_lmap_mark_data.cpp} | 0 ...{z_map_mark_data.c => z_map_mark_data.cpp} | 0 src/port/code_800F9280.c | 1 - src/port/code_800F9280.cpp | 1 + src/port/controller/keyboard.cpp | 4 +- src/port/{main.c => main.cpp} | 11 +- src/port/pc_main.cpp | 48 +- src/port/player/players.cpp | 4 +- src/port/{rsp.c => rsp.cpp} | 0 src/port/{rsp_boot.c => rsp_boot.cpp} | 0 src/port/ultra_reimplementation.cpp | 422 +- src/port/window/sdl/window_sdl2.cpp | 7 +- src/port/window/window.cpp | 2 - tools/ZAPD/ZAPD/Declaration.cpp | 6 +- tools/gen_headers.py | 86 +- tools/remove_typedef.py | 15 +- variables_old.txt | 2 + vs/OOT.vcxproj | 3381 ++-- vs/OOT.vcxproj.filters | 3376 ++-- 1351 files changed, 206650 insertions(+), 209645 deletions(-) rename assets/text/{fra_message_data_static.c => fra_message_data_static.cpp} (60%) rename assets/text/{ger_message_data_static.c => ger_message_data_static.cpp} (60%) rename assets/text/{nes_message_data_static.c => nes_message_data_static.cpp} (66%) rename assets/text/{staff_message_data_static.c => staff_message_data_static.cpp} (57%) delete mode 100644 include/def/sprintf.h create mode 100644 include/gfxapi.h rename src/boot/{assert.c => assert.cpp} (93%) rename src/boot/{boot_main.c => boot_main.cpp} (100%) delete mode 100644 src/boot/build.c create mode 100644 src/boot/build.cpp rename src/boot/{idle.c => idle.cpp} (100%) rename src/boot/{logutils.c => logutils.cpp} (100%) rename src/boot/{stackcheck.c => stackcheck.cpp} (97%) rename src/boot/{z_std_dma.c => z_std_dma.cpp} (60%) rename src/buffers/{gfxbuffers.c => gfxbuffers.cpp} (100%) rename src/buffers/{heaps.c => heaps.cpp} (100%) rename src/buffers/{zbuffer.c => zbuffer.cpp} (100%) rename src/code/{PreRender.c => PreRender.cpp} (63%) rename src/code/{TwoHeadArena.c => TwoHeadArena.cpp} (84%) delete mode 100644 src/code/__osMalloc.c rename src/code/{audioMgr.c => audioMgr.cpp} (100%) rename src/code/{audio_data.c => audio_data.cpp} (100%) rename src/code/{audio_effects.c => audio_effects.cpp} (100%) rename src/code/{audio_heap.c => audio_heap.cpp} (96%) rename src/code/{audio_init_params.c => audio_init_params.cpp} (98%) rename src/code/{audio_load.c => audio_load.cpp} (91%) rename src/code/{audio_playback.c => audio_playback.cpp} (98%) rename src/code/{audio_seqplayer.c => audio_seqplayer.cpp} (99%) rename src/code/{audio_sound_params.c => audio_sound_params.cpp} (100%) rename src/code/{audio_synthesis.c => audio_synthesis.cpp} (98%) rename src/code/{code_800430A0.c => code_800430A0.cpp} (100%) rename src/code/{code_80043480.c => code_80043480.cpp} (100%) rename src/code/{code_80069420.c => code_80069420.cpp} (100%) rename src/code/{code_8006BA00.c => code_8006BA00.cpp} (100%) rename src/code/{code_8006C3A0.c => code_8006C3A0.cpp} (100%) rename src/code/{code_8006C510.c => code_8006C510.cpp} (100%) rename src/code/{code_80097A00.c => code_80097A00.cpp} (100%) rename src/code/{code_800A9F30.c => code_800A9F30.cpp} (100%) rename src/code/{code_800ACE70.c => code_800ACE70.cpp} (83%) rename src/code/{code_800AD920.c => code_800AD920.cpp} (71%) rename src/code/{code_800BB0A0.c => code_800BB0A0.cpp} (100%) rename src/code/{code_800C3C20.c => code_800C3C20.cpp} (100%) rename src/code/{code_800D2E30.c => code_800D2E30.cpp} (100%) rename src/code/{code_800D31A0.c => code_800D31A0.cpp} (100%) rename src/code/{code_800E4FE0.c => code_800E4FE0.cpp} (98%) rename src/code/{code_800E6840.c => code_800E6840.cpp} (100%) rename src/code/{code_800EC960.c => code_800EC960.cpp} (100%) rename src/code/{code_800F7260.c => code_800F7260.cpp} (100%) rename src/code/{code_800F9280.c => code_800F9280.cpp} (99%) rename src/code/{code_800FBCE0.c => code_800FBCE0.cpp} (100%) rename src/code/{code_800FC620.c => code_800FC620.cpp} (96%) rename src/code/{code_800FCE80.c => code_800FCE80.cpp} (98%) rename src/code/{code_800FD970.c => code_800FD970.cpp} (100%) rename src/code/{code_801067F0.c => code_801067F0.cpp} (100%) rename src/code/{code_80106860.c => code_80106860.cpp} (92%) rename src/code/{code_801068B0.c => code_801068B0.cpp} (92%) rename src/code/{db_camera.c => db_camera.cpp} (96%) rename src/code/{debug_malloc.c => debug_malloc.cpp} (100%) rename src/code/{fault.c => fault.cpp} (100%) rename src/code/{fault_drawer.c => fault_drawer.cpp} (100%) rename src/code/{flg_set.c => flg_set.cpp} (100%) rename src/code/{game.c => game.cpp} (98%) delete mode 100644 src/code/gamealloc.c create mode 100644 src/code/gamealloc.cpp rename src/code/{gfxprint.c => gfxprint.cpp} (75%) rename src/code/{graph.c => graph.cpp} (96%) rename src/code/{irqmgr.c => irqmgr.cpp} (52%) rename src/code/{jpegdecoder.c => jpegdecoder.cpp} (98%) rename src/code/{jpegutils.c => jpegutils.cpp} (100%) delete mode 100644 src/code/listalloc.c create mode 100644 src/code/listalloc.cpp rename src/code/{logseverity.c => logseverity.cpp} (100%) rename src/code/{mempak.c => mempak.cpp} (100%) rename src/code/{mtxuty-cvt.c => mtxuty-cvt.cpp} (100%) rename src/code/{padmgr.c => padmgr.cpp} (98%) rename src/code/{padsetup.c => padsetup.cpp} (100%) rename src/code/{padutils.c => padutils.cpp} (100%) rename src/code/{printutils.c => printutils.cpp} (100%) rename src/code/{sched.c => sched.cpp} (100%) rename src/code/{shrink_window.c => shrink_window.cpp} (100%) rename src/code/{sleep.c => sleep.cpp} (100%) rename src/code/{speed_meter.c => speed_meter.cpp} (84%) rename src/code/{sys_cfb.c => sys_cfb.cpp} (100%) rename src/code/{sys_math.c => sys_math.cpp} (100%) rename src/code/{sys_math3d.c => sys_math3d.cpp} (100%) rename src/code/{sys_math_atan.c => sys_math_atan.cpp} (100%) rename src/code/{sys_matrix.c => sys_matrix.cpp} (98%) rename src/code/{sys_ucode.c => sys_ucode.cpp} (94%) rename src/code/{system_malloc.c => system_malloc.cpp} (100%) rename src/code/{title_setup.c => title_setup.cpp} (100%) rename src/code/{z_DLF.c => z_DLF.cpp} (100%) rename src/code/{z_actor.c => z_actor.cpp} (98%) rename src/code/{z_actor_dlftbls.c => z_actor_dlftbls.cpp} (77%) rename src/code/{z_bgcheck.c => z_bgcheck.cpp} (98%) rename src/code/{z_camera.c => z_camera.cpp} (99%) rename src/code/{z_camera_data.c => z_camera_data.cpp} (100%) rename src/code/{z_cheap_proc.c => z_cheap_proc.cpp} (100%) rename src/code/{z_collision_btltbls.c => z_collision_btltbls.cpp} (100%) rename src/code/{z_collision_check.c => z_collision_check.cpp} (99%) rename src/code/{z_common_data.c => z_common_data.cpp} (100%) rename src/code/{z_construct.c => z_construct.cpp} (95%) rename src/code/{z_debug.c => z_debug.cpp} (100%) rename src/code/{z_debug_display.c => z_debug_display.cpp} (100%) rename src/code/{z_demo.c => z_demo.cpp} (97%) rename src/code/{z_draw.c => z_draw.cpp} (100%) rename src/code/{z_eff_blure.c => z_eff_blure.cpp} (70%) delete mode 100644 src/code/z_eff_shield_particle.c create mode 100644 src/code/z_eff_shield_particle.cpp rename src/code/{z_eff_spark.c => z_eff_spark.cpp} (55%) rename src/code/{z_eff_ss_dead.c => z_eff_ss_dead.cpp} (100%) rename src/code/{z_effect.c => z_effect.cpp} (100%) rename src/code/{z_effect_soft_sprite.c => z_effect_soft_sprite.cpp} (98%) rename src/code/{z_effect_soft_sprite_dlftbls.c => z_effect_soft_sprite_dlftbls.cpp} (100%) rename src/code/{z_effect_soft_sprite_old_init.c => z_effect_soft_sprite_old_init.cpp} (98%) rename src/code/{z_elf_message.c => z_elf_message.cpp} (100%) delete mode 100644 src/code/z_en_a_keep.c create mode 100644 src/code/z_en_a_keep.cpp rename src/code/{z_en_item00.c => z_en_item00.cpp} (69%) rename src/code/{z_face_reaction.c => z_face_reaction.cpp} (100%) delete mode 100644 src/code/z_fbdemo.c create mode 100644 src/code/z_fbdemo.cpp rename src/code/{z_fbdemo_circle.c => z_fbdemo_circle.cpp} (55%) rename src/code/{z_fbdemo_fade.c => z_fbdemo_fade.cpp} (55%) delete mode 100644 src/code/z_fbdemo_triforce.c create mode 100644 src/code/z_fbdemo_triforce.cpp rename src/code/{z_fbdemo_wipe1.c => z_fbdemo_wipe1.cpp} (55%) rename src/code/{z_fcurve_data_skelanime.c => z_fcurve_data_skelanime.cpp} (90%) rename src/code/{z_frame_advance.c => z_frame_advance.cpp} (100%) rename src/code/{z_game_dlftbls.c => z_game_dlftbls.cpp} (100%) rename src/code/{z_game_over.c => z_game_over.cpp} (100%) rename src/code/{z_horse.c => z_horse.cpp} (100%) rename src/code/{z_jpeg.c => z_jpeg.cpp} (96%) rename src/code/{z_kaleido_manager.c => z_kaleido_manager.cpp} (71%) rename src/code/{z_kaleido_scope_call.c => z_kaleido_scope_call.cpp} (95%) rename src/code/{z_kaleido_setup.c => z_kaleido_setup.cpp} (100%) rename src/code/{z_kanfont.c => z_kanfont.cpp} (95%) rename src/code/{z_kankyo.c => z_kankyo.cpp} (99%) rename src/code/{z_lib.c => z_lib.cpp} (100%) rename src/code/{z_lifemeter.c => z_lifemeter.cpp} (99%) rename src/code/{z_lights.c => z_lights.cpp} (99%) rename src/code/{z_malloc.c => z_malloc.cpp} (100%) rename src/code/{z_map_data.c => z_map_data.cpp} (100%) rename src/code/{z_map_exp.c => z_map_exp.cpp} (98%) rename src/code/{z_map_mark.c => z_map_mark.cpp} (98%) rename src/code/{z_message_PAL.c => z_message_PAL.cpp} (99%) rename src/code/{z_moji.c => z_moji.cpp} (100%) rename src/code/{z_msgevent.c => z_msgevent.cpp} (100%) rename src/code/{z_olib.c => z_olib.cpp} (100%) rename src/code/{z_onepointdemo.c => z_onepointdemo.cpp} (99%) rename src/code/{z_onepointdemo_data.c => z_onepointdemo_data.cpp} (100%) rename src/code/{z_parameter.c => z_parameter.cpp} (99%) rename src/code/{z_path.c => z_path.cpp} (94%) rename src/code/{z_play.c => z_play.cpp} (97%) rename src/code/{z_player_call.c => z_player_call.cpp} (88%) rename src/code/{z_player_lib.c => z_player_lib.cpp} (71%) delete mode 100644 src/code/z_prenmi.c create mode 100644 src/code/z_prenmi.cpp delete mode 100644 src/code/z_prenmi_buff.c create mode 100644 src/code/z_prenmi_buff.cpp rename src/code/{z_quake.c => z_quake.cpp} (100%) rename src/code/{z_rcp.c => z_rcp.cpp} (99%) rename src/code/{z_room.c => z_room.cpp} (94%) rename src/code/{z_sample.c => z_sample.cpp} (59%) rename src/code/{z_scene.c => z_scene.cpp} (88%) rename src/code/{z_scene_table.c => z_scene_table.cpp} (99%) rename src/code/{z_skelanime.c => z_skelanime.cpp} (93%) rename src/code/{z_skin.c => z_skin.cpp} (83%) rename src/code/{z_skin_awb.c => z_skin_awb.cpp} (79%) rename src/code/{z_skin_matrix.c => z_skin_matrix.cpp} (99%) rename src/code/{z_sram.c => z_sram.cpp} (99%) rename src/code/{z_ss_sram.c => z_ss_sram.cpp} (100%) rename src/code/{z_view.c => z_view.cpp} (95%) rename src/code/{z_vimode.c => z_vimode.cpp} (98%) rename src/code/{z_vismono.c => z_vismono.cpp} (61%) rename src/code/{z_vr_box.c => z_vr_box.cpp} (86%) rename src/code/{z_vr_box_draw.c => z_vr_box_draw.cpp} (66%) rename src/dmadata/{dmadata.c => dmadata.cpp} (82%) rename src/elf_message/{elf_message_field.c => elf_message_field.cpp} (100%) rename src/elf_message/{elf_message_ydan.c => elf_message_ydan.cpp} (100%) rename src/libultra/gu/{cosf.c => cosf.cpp} (98%) rename src/libultra/gu/{coss.c => coss.cpp} (100%) rename src/libultra/gu/{lookat.c => lookat.cpp} (100%) rename src/libultra/gu/{lookathil.c => lookathil.cpp} (100%) rename src/libultra/gu/{mtxf2l.c => mtxf2l.cpp} (88%) rename src/libultra/gu/{normalize.c => normalize.cpp} (100%) rename src/libultra/gu/{ortho.c => ortho.cpp} (100%) rename src/libultra/gu/{perspective.c => perspective.cpp} (94%) rename src/libultra/gu/{position.c => position.cpp} (97%) rename src/libultra/gu/{rotate.c => rotate.cpp} (95%) rename src/libultra/gu/{scale.c => scale.cpp} (82%) rename src/libultra/gu/{sinf.c => sinf.cpp} (98%) rename src/libultra/gu/{sins.c => sins.cpp} (93%) rename src/libultra/gu/{sintable.c => sintable.cpp} (100%) rename src/libultra/gu/{sqrtf.c => sqrtf.cpp} (100%) rename src/libultra/gu/{translate.c => translate.cpp} (81%) rename src/libultra/gu/{us2dex.c => us2dex.cpp} (100%) rename src/libultra/io/{aigetlen.c => aigetlen.cpp} (100%) rename src/libultra/io/{aisetfreq.c => aisetfreq.cpp} (100%) rename src/libultra/io/{aisetnextbuf.c => aisetnextbuf.cpp} (100%) rename src/libultra/io/{cartrominit.c => cartrominit.cpp} (100%) rename src/libultra/io/{contpfs.c => contpfs.cpp} (100%) rename src/libultra/io/{contquery.c => contquery.cpp} (100%) rename src/libultra/io/{contramread.c => contramread.cpp} (100%) rename src/libultra/io/{contramwrite.c => contramwrite.cpp} (100%) rename src/libultra/io/{contreaddata.c => contreaddata.cpp} (100%) rename src/libultra/io/{controller.c => controller.cpp} (100%) rename src/libultra/io/{contsetch.c => contsetch.cpp} (100%) rename src/libultra/io/{crc.c => crc.cpp} (100%) rename src/libultra/io/{devmgr.c => devmgr.cpp} (100%) rename src/libultra/io/{dpgetstat.c => dpgetstat.cpp} (100%) rename src/libultra/io/{dpsetstat.c => dpsetstat.cpp} (100%) rename src/libultra/io/{driverominit.c => driverominit.cpp} (100%) rename src/libultra/io/{epidma.c => epidma.cpp} (100%) rename src/libultra/io/{epirawdma.c => epirawdma.cpp} (100%) rename src/libultra/io/{epirawread.c => epirawread.cpp} (100%) rename src/libultra/io/{epiwrite.c => epiwrite.cpp} (100%) rename src/libultra/io/{motor.c => motor.cpp} (100%) rename src/libultra/io/{pfsallocatefile.c => pfsallocatefile.cpp} (100%) rename src/libultra/io/{pfschecker.c => pfschecker.cpp} (100%) rename src/libultra/io/{pfsdeletefile.c => pfsdeletefile.cpp} (100%) rename src/libultra/io/{pfsfilestate.c => pfsfilestate.cpp} (100%) rename src/libultra/io/{pfsfindfile.c => pfsfindfile.cpp} (100%) rename src/libultra/io/{pfsfreeblocks.c => pfsfreeblocks.cpp} (100%) rename src/libultra/io/{pfsgetstatus.c => pfsgetstatus.cpp} (100%) rename src/libultra/io/{pfsinitpak.c => pfsinitpak.cpp} (100%) rename src/libultra/io/{pfsisplug.c => pfsisplug.cpp} (100%) rename src/libultra/io/{pfsreadwritefile.c => pfsreadwritefile.cpp} (100%) rename src/libultra/io/{pfsselectbank.c => pfsselectbank.cpp} (100%) rename src/libultra/io/{piacs.c => piacs.cpp} (100%) rename src/libultra/io/{pigetcmdq.c => pigetcmdq.cpp} (100%) rename src/libultra/io/{pimgr.c => pimgr.cpp} (100%) rename src/libultra/io/{pirawdma.c => pirawdma.cpp} (100%) rename src/libultra/io/{si.c => si.cpp} (100%) rename src/libultra/io/{siacs.c => siacs.cpp} (100%) rename src/libultra/io/{sirawdma.c => sirawdma.cpp} (100%) rename src/libultra/io/{sirawread.c => sirawread.cpp} (100%) rename src/libultra/io/{sirawwrite.c => sirawwrite.cpp} (100%) rename src/libultra/io/{sp.c => sp.cpp} (100%) rename src/libultra/io/{spgetstat.c => spgetstat.cpp} (100%) rename src/libultra/io/{sprawdma.c => sprawdma.cpp} (100%) rename src/libultra/io/{spsetpc.c => spsetpc.cpp} (100%) rename src/libultra/io/{spsetstat.c => spsetstat.cpp} (100%) rename src/libultra/io/{sptask.c => sptask.cpp} (100%) rename src/libultra/io/{sptaskyield.c => sptaskyield.cpp} (100%) rename src/libultra/io/{sptaskyielded.c => sptaskyielded.cpp} (100%) rename src/libultra/io/{vi.c => vi.cpp} (100%) rename src/libultra/io/{viblack.c => viblack.cpp} (100%) rename src/libultra/io/{viextend.c => viextend.cpp} (100%) rename src/libultra/io/{vigetcurrcontext.c => vigetcurrcontext.cpp} (100%) rename src/libultra/io/{vigetcurrframebuf.c => vigetcurrframebuf.cpp} (100%) rename src/libultra/io/{vigetnextframebuf.c => vigetnextframebuf.cpp} (100%) rename src/libultra/io/{vimgr.c => vimgr.cpp} (100%) rename src/libultra/io/{vimodefpallan1.c => vimodefpallan1.cpp} (100%) rename src/libultra/io/{vimodempallan1.c => vimodempallan1.cpp} (100%) rename src/libultra/io/{vimodentsclan1.c => vimodentsclan1.cpp} (100%) rename src/libultra/io/{vimodepallan1.c => vimodepallan1.cpp} (100%) rename src/libultra/io/{visetevent.c => visetevent.cpp} (100%) rename src/libultra/io/{visetmode.c => visetmode.cpp} (100%) rename src/libultra/io/{visetspecial.c => visetspecial.cpp} (100%) rename src/libultra/io/{visetxscale.c => visetxscale.cpp} (100%) rename src/libultra/io/{visetyscale.c => visetyscale.cpp} (100%) rename src/libultra/io/{viswapbuf.c => viswapbuf.cpp} (100%) rename src/libultra/io/{viswapcontext.c => viswapcontext.cpp} (100%) rename src/libultra/rmon/{sprintf.c => sprintf.cpp} (100%) rename src/libultra/rmon/{xldtob.c => xldtob.cpp} (99%) rename src/libultra/rmon/{xlitob.c => xlitob.cpp} (98%) rename src/libultra/rmon/{xprintf.c => xprintf.cpp} (99%) rename src/overlays/actors/ovl_Arms_Hook/{z_arms_hook.c => z_arms_hook.cpp} (53%) rename src/overlays/actors/ovl_Arrow_Fire/{z_arrow_fire.c => z_arrow_fire.cpp} (52%) rename src/overlays/actors/ovl_Arrow_Ice/{z_arrow_ice.c => z_arrow_ice.cpp} (51%) rename src/overlays/actors/ovl_Arrow_Light/{z_arrow_light.c => z_arrow_light.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c create mode 100644 src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c create mode 100644 src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.c create mode 100644 src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.cpp rename src/overlays/actors/ovl_Bg_Bombwall/{z_bg_bombwall.c => z_bg_bombwall.cpp} (50%) delete mode 100644 src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c create mode 100644 src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.cpp rename src/overlays/actors/ovl_Bg_Breakwall/{z_bg_breakwall.c => z_bg_breakwall.cpp} (64%) delete mode 100644 src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c create mode 100644 src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c create mode 100644 src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.cpp rename src/overlays/actors/ovl_Bg_Dodoago/{z_bg_dodoago.c => z_bg_dodoago.cpp} (51%) rename src/overlays/actors/ovl_Bg_Dy_Yoseizo/{z_bg_dy_yoseizo.c => z_bg_dy_yoseizo.cpp} (52%) rename src/overlays/actors/ovl_Bg_Ganon_Otyuka/{z_bg_ganon_otyuka.c => z_bg_ganon_otyuka.cpp} (63%) delete mode 100644 src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.c create mode 100644 src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.cpp rename src/overlays/actors/ovl_Bg_Gjyo_Bridge/{z_bg_gjyo_bridge.c => z_bg_gjyo_bridge.cpp} (59%) delete mode 100644 src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c create mode 100644 src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c create mode 100644 src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.cpp rename src/overlays/actors/ovl_Bg_Gnd_Iceblock/{z_bg_gnd_iceblock.c => z_bg_gnd_iceblock.cpp} (55%) rename src/overlays/actors/ovl_Bg_Gnd_Nisekabe/{z_bg_gnd_nisekabe.c => z_bg_gnd_nisekabe.cpp} (76%) rename src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/{z_bg_gnd_soulmeiro.c => z_bg_gnd_soulmeiro.cpp} (67%) rename src/overlays/actors/ovl_Bg_Haka/{z_bg_haka.c => z_bg_haka.cpp} (54%) rename src/overlays/actors/ovl_Bg_Haka_Gate/{z_bg_haka_gate.c => z_bg_haka_gate.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c create mode 100644 src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.cpp rename src/overlays/actors/ovl_Bg_Haka_Megane/{z_bg_haka_megane.c => z_bg_haka_megane.cpp} (63%) delete mode 100644 src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.c create mode 100644 src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.cpp rename src/overlays/actors/ovl_Bg_Haka_Sgami/{z_bg_haka_sgami.c => z_bg_haka_sgami.cpp} (53%) delete mode 100644 src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c create mode 100644 src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c create mode 100644 src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.cpp rename src/overlays/actors/ovl_Bg_Haka_Tubo/{z_bg_haka_tubo.c => z_bg_haka_tubo.cpp} (57%) rename src/overlays/actors/ovl_Bg_Haka_Water/{z_bg_haka_water.c => z_bg_haka_water.cpp} (53%) delete mode 100644 src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c create mode 100644 src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.cpp rename src/overlays/actors/ovl_Bg_Heavy_Block/{z_bg_heavy_block.c => z_bg_heavy_block.cpp} (62%) delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.cpp rename src/overlays/actors/ovl_Bg_Hidan_Dalm/{z_bg_hidan_dalm.c => z_bg_hidan_dalm.cpp} (59%) delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.cpp rename src/overlays/actors/ovl_Bg_Hidan_Hamstep/{z_bg_hidan_hamstep.c => z_bg_hidan_hamstep.cpp} (51%) rename src/overlays/actors/ovl_Bg_Hidan_Hrock/{z_bg_hidan_hrock.c => z_bg_hidan_hrock.cpp} (57%) delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp rename src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/{z_bg_hidan_kowarerukabe.c => z_bg_hidan_kowarerukabe.cpp} (66%) delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.cpp rename src/overlays/actors/ovl_Bg_Hidan_Rsekizou/{z_bg_hidan_rsekizou.c => z_bg_hidan_rsekizou.cpp} (66%) rename src/overlays/actors/ovl_Bg_Hidan_Sekizou/{z_bg_hidan_sekizou.c => z_bg_hidan_sekizou.cpp} (60%) delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c create mode 100644 src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.cpp rename src/overlays/actors/ovl_Bg_Ice_Objects/{z_bg_ice_objects.c => z_bg_ice_objects.cpp} (57%) rename src/overlays/actors/ovl_Bg_Ice_Shelter/{z_bg_ice_shelter.c => z_bg_ice_shelter.cpp} (62%) delete mode 100644 src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.c create mode 100644 src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c create mode 100644 src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.cpp rename src/overlays/actors/ovl_Bg_Ingate/{z_bg_ingate.c => z_bg_ingate.cpp} (63%) rename src/overlays/actors/ovl_Bg_Jya_1flift/{z_bg_jya_1flift.c => z_bg_jya_1flift.cpp} (50%) delete mode 100644 src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c create mode 100644 src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.cpp rename src/overlays/actors/ovl_Bg_Jya_Bigmirror/{z_bg_jya_bigmirror.c => z_bg_jya_bigmirror.cpp} (67%) rename src/overlays/actors/ovl_Bg_Jya_Block/{z_bg_jya_block.c => z_bg_jya_block.cpp} (81%) rename src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/{z_bg_jya_bombchuiwa.c => z_bg_jya_bombchuiwa.cpp} (56%) rename src/overlays/actors/ovl_Bg_Jya_Bombiwa/{z_bg_jya_bombiwa.c => z_bg_jya_bombiwa.cpp} (64%) rename src/overlays/actors/ovl_Bg_Jya_Cobra/{z_bg_jya_cobra.c => z_bg_jya_cobra.cpp} (60%) rename src/overlays/actors/ovl_Bg_Jya_Goroiwa/{z_bg_jya_goroiwa.c => z_bg_jya_goroiwa.cpp} (53%) rename src/overlays/actors/ovl_Bg_Jya_Haheniron/{z_bg_jya_haheniron.c => z_bg_jya_haheniron.cpp} (52%) rename src/overlays/actors/ovl_Bg_Jya_Ironobj/{z_bg_jya_ironobj.c => z_bg_jya_ironobj.cpp} (67%) delete mode 100644 src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c create mode 100644 src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.cpp rename src/overlays/actors/ovl_Bg_Jya_Lift/{z_bg_jya_lift.c => z_bg_jya_lift.cpp} (52%) rename src/overlays/actors/ovl_Bg_Jya_Megami/{z_bg_jya_megami.c => z_bg_jya_megami.cpp} (62%) rename src/overlays/actors/ovl_Bg_Jya_Zurerukabe/{z_bg_jya_zurerukabe.c => z_bg_jya_zurerukabe.cpp} (56%) rename src/overlays/actors/ovl_Bg_Menkuri_Eye/{z_bg_menkuri_eye.c => z_bg_menkuri_eye.cpp} (58%) rename src/overlays/actors/ovl_Bg_Menkuri_Kaiten/{z_bg_menkuri_kaiten.c => z_bg_menkuri_kaiten.cpp} (69%) rename src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/{z_bg_menkuri_nisekabe.c => z_bg_menkuri_nisekabe.cpp} (77%) rename src/overlays/actors/ovl_Bg_Mizu_Bwall/{z_bg_mizu_bwall.c => z_bg_mizu_bwall.cpp} (62%) rename src/overlays/actors/ovl_Bg_Mizu_Movebg/{z_bg_mizu_movebg.c => z_bg_mizu_movebg.cpp} (68%) delete mode 100644 src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c create mode 100644 src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp rename src/overlays/actors/ovl_Bg_Mizu_Uzu/{z_bg_mizu_uzu.c => z_bg_mizu_uzu.cpp} (66%) rename src/overlays/actors/ovl_Bg_Mizu_Water/{z_bg_mizu_water.c => z_bg_mizu_water.cpp} (62%) rename src/overlays/actors/ovl_Bg_Mjin/{z_bg_mjin.c => z_bg_mjin.cpp} (68%) delete mode 100644 src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c create mode 100644 src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c create mode 100644 src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c create mode 100644 src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c create mode 100644 src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c create mode 100644 src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.cpp rename src/overlays/actors/ovl_Bg_Mori_Idomizu/{z_bg_mori_idomizu.c => z_bg_mori_idomizu.cpp} (58%) rename src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/{z_bg_mori_kaitenkabe.c => z_bg_mori_kaitenkabe.cpp} (52%) delete mode 100644 src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c create mode 100644 src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c create mode 100644 src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.cpp rename src/overlays/actors/ovl_Bg_Po_Syokudai/{z_bg_po_syokudai.c => z_bg_po_syokudai.cpp} (72%) rename src/overlays/actors/ovl_Bg_Pushbox/{z_bg_pushbox.c => z_bg_pushbox.cpp} (56%) delete mode 100644 src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c create mode 100644 src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.cpp rename src/overlays/actors/ovl_Bg_Spot00_Break/{z_bg_spot00_break.c => z_bg_spot00_break.cpp} (75%) rename src/overlays/actors/ovl_Bg_Spot00_Hanebasi/{z_bg_spot00_hanebasi.c => z_bg_spot00_hanebasi.cpp} (62%) rename src/overlays/actors/ovl_Bg_Spot01_Fusya/{z_bg_spot01_fusya.c => z_bg_spot01_fusya.cpp} (71%) rename src/overlays/actors/ovl_Bg_Spot01_Idohashira/{z_bg_spot01_idohashira.c => z_bg_spot01_idohashira.cpp} (66%) rename src/overlays/actors/ovl_Bg_Spot01_Idomizu/{z_bg_spot01_idomizu.c => z_bg_spot01_idomizu.cpp} (75%) rename src/overlays/actors/ovl_Bg_Spot01_Idosoko/{z_bg_spot01_idosoko.c => z_bg_spot01_idosoko.cpp} (69%) rename src/overlays/actors/ovl_Bg_Spot01_Objects2/{z_bg_spot01_objects2.c => z_bg_spot01_objects2.cpp} (68%) rename src/overlays/actors/ovl_Bg_Spot02_Objects/{z_bg_spot02_objects.c => z_bg_spot02_objects.cpp} (67%) rename src/overlays/actors/ovl_Bg_Spot03_Taki/{z_bg_spot03_taki.c => z_bg_spot03_taki.cpp} (52%) rename src/overlays/actors/ovl_Bg_Spot05_Soko/{z_bg_spot05_soko.c => z_bg_spot05_soko.cpp} (56%) delete mode 100644 src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c create mode 100644 src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.cpp rename src/overlays/actors/ovl_Bg_Spot07_Taki/{z_bg_spot07_taki.c => z_bg_spot07_taki.cpp} (81%) rename src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/{z_bg_spot08_bakudankabe.c => z_bg_spot08_bakudankabe.cpp} (65%) delete mode 100644 src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c create mode 100644 src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.cpp rename src/overlays/actors/ovl_Bg_Spot09_Obj/{z_bg_spot09_obj.c => z_bg_spot09_obj.cpp} (61%) rename src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/{z_bg_spot11_bakudankabe.c => z_bg_spot11_bakudankabe.cpp} (70%) rename src/overlays/actors/ovl_Bg_Spot11_Oasis/{z_bg_spot11_oasis.c => z_bg_spot11_oasis.cpp} (67%) delete mode 100644 src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c create mode 100644 src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c create mode 100644 src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c create mode 100644 src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.cpp rename src/overlays/actors/ovl_Bg_Spot15_Saku/{z_bg_spot15_saku.c => z_bg_spot15_saku.cpp} (50%) rename src/overlays/actors/ovl_Bg_Spot16_Bombstone/{z_bg_spot16_bombstone.c => z_bg_spot16_bombstone.cpp} (59%) rename src/overlays/actors/ovl_Bg_Spot16_Doughnut/{z_bg_spot16_doughnut.c => z_bg_spot16_doughnut.cpp} (68%) rename src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/{z_bg_spot17_bakudankabe.c => z_bg_spot17_bakudankabe.cpp} (75%) rename src/overlays/actors/ovl_Bg_Spot17_Funen/{z_bg_spot17_funen.c => z_bg_spot17_funen.cpp} (86%) delete mode 100644 src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c create mode 100644 src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.cpp rename src/overlays/actors/ovl_Bg_Spot18_Futa/{z_bg_spot18_futa.c => z_bg_spot18_futa.cpp} (69%) delete mode 100644 src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c create mode 100644 src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.c create mode 100644 src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.cpp rename src/overlays/actors/ovl_Bg_Sst_Floor/{z_bg_sst_floor.c => z_bg_sst_floor.cpp} (63%) rename src/overlays/actors/ovl_Bg_Toki_Hikari/{z_bg_toki_hikari.c => z_bg_toki_hikari.cpp} (61%) rename src/overlays/actors/ovl_Bg_Toki_Swd/{z_bg_toki_swd.c => z_bg_toki_swd.cpp} (65%) rename src/overlays/actors/ovl_Bg_Toki_Swd/{z_bg_toki_swd_cutscene_data_1.c => z_bg_toki_swd_cutscene_data_1.cpp} (100%) rename src/overlays/actors/ovl_Bg_Toki_Swd/{z_bg_toki_swd_cutscene_data_2.c => z_bg_toki_swd_cutscene_data_2.cpp} (100%) rename src/overlays/actors/ovl_Bg_Toki_Swd/{z_bg_toki_swd_cutscene_data_3.c => z_bg_toki_swd_cutscene_data_3.cpp} (100%) rename src/overlays/actors/ovl_Bg_Treemouth/{z_bg_treemouth.c => z_bg_treemouth.cpp} (65%) rename src/overlays/actors/ovl_Bg_Treemouth/{z_bg_treemouth_cutscene_data.c => z_bg_treemouth_cutscene_data.cpp} (100%) rename src/overlays/actors/ovl_Bg_Umajump/{z_bg_umajump.c => z_bg_umajump.cpp} (73%) rename src/overlays/actors/ovl_Bg_Vb_Sima/{z_bg_vb_sima.c => z_bg_vb_sima.cpp} (81%) delete mode 100644 src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c create mode 100644 src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c create mode 100644 src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.cpp delete mode 100644 src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c create mode 100644 src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.cpp rename src/overlays/actors/ovl_Bg_Zg/{z_bg_zg.c => z_bg_zg.cpp} (54%) delete mode 100644 src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c create mode 100644 src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.cpp rename src/overlays/actors/ovl_Boss_Dodongo/{z_boss_dodongo_data.c => z_boss_dodongo_data.cpp} (99%) delete mode 100644 src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c create mode 100644 src/overlays/actors/ovl_Boss_Fd/z_boss_fd.cpp rename src/overlays/actors/ovl_Boss_Fd/{z_boss_fd_colchk.c => z_boss_fd_colchk.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c create mode 100644 src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.cpp rename src/overlays/actors/ovl_Boss_Fd2/{z_boss_fd2_colchk.c => z_boss_fd2_colchk.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c create mode 100644 src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.cpp delete mode 100644 src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c create mode 100644 src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.cpp rename src/overlays/actors/ovl_Boss_Ganon2/{z_boss_ganon2_data.c => z_boss_ganon2_data.cpp} (99%) delete mode 100644 src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c create mode 100644 src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.cpp delete mode 100644 src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c create mode 100644 src/overlays/actors/ovl_Boss_Goma/z_boss_goma.cpp rename src/overlays/actors/ovl_Boss_Mo/{z_boss_mo.c => z_boss_mo.cpp} (55%) rename src/overlays/actors/ovl_Boss_Mo/{z_boss_mo_colchk.c => z_boss_mo_colchk.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c create mode 100644 src/overlays/actors/ovl_Boss_Sst/z_boss_sst.cpp rename src/overlays/actors/ovl_Boss_Sst/{z_boss_sst_colchk.c => z_boss_sst_colchk.cpp} (100%) rename src/overlays/actors/ovl_Boss_Tw/{z_boss_tw.c => z_boss_tw.cpp} (55%) rename src/overlays/actors/ovl_Boss_Va/{z_boss_va.c => z_boss_va.cpp} (55%) rename src/overlays/actors/ovl_Demo_6K/{z_demo_6k.c => z_demo_6k.cpp} (55%) delete mode 100644 src/overlays/actors/ovl_Demo_Du/z_demo_du.c create mode 100644 src/overlays/actors/ovl_Demo_Du/z_demo_du.cpp rename src/overlays/actors/ovl_Demo_Du/{z_demo_du_cutscene_data.c => z_demo_du_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c create mode 100644 src/overlays/actors/ovl_Demo_Ec/z_demo_ec.cpp rename src/overlays/actors/ovl_Demo_Effect/{z_demo_effect.c => z_demo_effect.cpp} (54%) rename src/overlays/actors/ovl_Demo_Ext/{z_demo_ext.c => z_demo_ext.cpp} (56%) rename src/overlays/actors/ovl_Demo_Geff/{z_demo_geff.c => z_demo_geff.cpp} (63%) delete mode 100644 src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c create mode 100644 src/overlays/actors/ovl_Demo_Gj/z_demo_gj.cpp delete mode 100644 src/overlays/actors/ovl_Demo_Go/z_demo_go.c create mode 100644 src/overlays/actors/ovl_Demo_Go/z_demo_go.cpp rename src/overlays/actors/ovl_Demo_Gt/{z_demo_gt.c => z_demo_gt.cpp} (67%) rename src/overlays/actors/ovl_Demo_Ik/{z_demo_ik.c => z_demo_ik.cpp} (58%) delete mode 100644 src/overlays/actors/ovl_Demo_Im/z_demo_im.c create mode 100644 src/overlays/actors/ovl_Demo_Im/z_demo_im.cpp rename src/overlays/actors/ovl_Demo_Im/{z_demo_im_cutscene_data.c => z_demo_im_cutscene_data.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo.c => z_demo_kankyo.cpp} (66%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data1.c => z_demo_kankyo_cutscene_data1.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data2.c => z_demo_kankyo_cutscene_data2.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data3.c => z_demo_kankyo_cutscene_data3.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data4.c => z_demo_kankyo_cutscene_data4.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data5.c => z_demo_kankyo_cutscene_data5.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data6.c => z_demo_kankyo_cutscene_data6.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data7.c => z_demo_kankyo_cutscene_data7.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kankyo/{z_demo_kankyo_cutscene_data8.c => z_demo_kankyo_cutscene_data8.cpp} (100%) rename src/overlays/actors/ovl_Demo_Kekkai/{z_demo_kekkai.c => z_demo_kekkai.cpp} (66%) delete mode 100644 src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c create mode 100644 src/overlays/actors/ovl_Demo_Sa/z_demo_sa.cpp rename src/overlays/actors/ovl_Demo_Sa/{z_demo_sa_cutscene_data.c => z_demo_sa_cutscene_data.cpp} (100%) rename src/overlays/actors/ovl_Demo_Shd/{z_demo_shd.c => z_demo_shd.cpp} (72%) rename src/overlays/actors/ovl_Demo_Tre_Lgt/{z_demo_tre_lgt.c => z_demo_tre_lgt.cpp} (66%) rename src/overlays/actors/ovl_Door_Ana/{z_door_ana.c => z_door_ana.cpp} (54%) rename src/overlays/actors/ovl_Door_Gerudo/{z_door_gerudo.c => z_door_gerudo.cpp} (59%) rename src/overlays/actors/ovl_Door_Killer/{z_door_killer.c => z_door_killer.cpp} (51%) rename src/overlays/actors/ovl_Door_Shutter/{z_door_shutter.c => z_door_shutter.cpp} (52%) rename src/overlays/actors/ovl_Door_Toki/{z_door_toki.c => z_door_toki.cpp} (67%) delete mode 100644 src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c create mode 100644 src/overlays/actors/ovl_Door_Warp1/z_door_warp1.cpp rename src/overlays/actors/ovl_Efc_Erupc/{z_efc_erupc.c => z_efc_erupc.cpp} (74%) delete mode 100644 src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c create mode 100644 src/overlays/actors/ovl_Eff_Dust/z_eff_dust.cpp rename src/overlays/actors/ovl_Elf_Msg/{z_elf_msg.c => z_elf_msg.cpp} (56%) delete mode 100644 src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c create mode 100644 src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.cpp delete mode 100644 src/overlays/actors/ovl_En_Am/z_en_am.c create mode 100644 src/overlays/actors/ovl_En_Am/z_en_am.cpp delete mode 100644 src/overlays/actors/ovl_En_Ani/z_en_ani.c create mode 100644 src/overlays/actors/ovl_En_Ani/z_en_ani.cpp delete mode 100644 src/overlays/actors/ovl_En_Anubice/z_en_anubice.c create mode 100644 src/overlays/actors/ovl_En_Anubice/z_en_anubice.cpp delete mode 100644 src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c create mode 100644 src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.cpp delete mode 100644 src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c create mode 100644 src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.cpp rename src/overlays/actors/ovl_En_Arow_Trap/{z_en_arow_trap.c => z_en_arow_trap.cpp} (61%) delete mode 100644 src/overlays/actors/ovl_En_Arrow/z_en_arrow.c create mode 100644 src/overlays/actors/ovl_En_Arrow/z_en_arrow.cpp delete mode 100644 src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c create mode 100644 src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.cpp delete mode 100644 src/overlays/actors/ovl_En_Ba/z_en_ba.c create mode 100644 src/overlays/actors/ovl_En_Ba/z_en_ba.cpp delete mode 100644 src/overlays/actors/ovl_En_Bb/z_en_bb.c create mode 100644 src/overlays/actors/ovl_En_Bb/z_en_bb.cpp delete mode 100644 src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c create mode 100644 src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.cpp delete mode 100644 src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c create mode 100644 src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.cpp delete mode 100644 src/overlays/actors/ovl_En_Bili/z_en_bili.c create mode 100644 src/overlays/actors/ovl_En_Bili/z_en_bili.cpp delete mode 100644 src/overlays/actors/ovl_En_Bird/z_en_bird.c create mode 100644 src/overlays/actors/ovl_En_Bird/z_en_bird.cpp rename src/overlays/actors/ovl_En_Blkobj/{z_en_blkobj.c => z_en_blkobj.cpp} (59%) rename src/overlays/actors/ovl_En_Bom/{z_en_bom.c => z_en_bom.cpp} (64%) delete mode 100644 src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c create mode 100644 src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.cpp delete mode 100644 src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c create mode 100644 src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.cpp delete mode 100644 src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c create mode 100644 src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.cpp rename src/overlays/actors/ovl_En_Bombf/{z_en_bombf.c => z_en_bombf.cpp} (62%) rename src/overlays/actors/ovl_En_Boom/{z_en_boom.c => z_en_boom.cpp} (66%) delete mode 100644 src/overlays/actors/ovl_En_Box/z_en_box.c create mode 100644 src/overlays/actors/ovl_En_Box/z_en_box.cpp delete mode 100644 src/overlays/actors/ovl_En_Brob/z_en_brob.c create mode 100644 src/overlays/actors/ovl_En_Brob/z_en_brob.cpp delete mode 100644 src/overlays/actors/ovl_En_Bubble/z_en_bubble.c create mode 100644 src/overlays/actors/ovl_En_Bubble/z_en_bubble.cpp delete mode 100644 src/overlays/actors/ovl_En_Butte/z_en_butte.c create mode 100644 src/overlays/actors/ovl_En_Butte/z_en_butte.cpp delete mode 100644 src/overlays/actors/ovl_En_Bw/z_en_bw.c create mode 100644 src/overlays/actors/ovl_En_Bw/z_en_bw.cpp rename src/overlays/actors/ovl_En_Bx/{z_en_bx.c => z_en_bx.cpp} (63%) rename src/overlays/actors/ovl_En_Changer/{z_en_changer.c => z_en_changer.cpp} (72%) rename src/overlays/actors/ovl_En_Clear_Tag/{z_en_clear_tag.c => z_en_clear_tag.cpp} (68%) delete mode 100644 src/overlays/actors/ovl_En_Cow/z_en_cow.c create mode 100644 src/overlays/actors/ovl_En_Cow/z_en_cow.cpp delete mode 100644 src/overlays/actors/ovl_En_Crow/z_en_crow.c create mode 100644 src/overlays/actors/ovl_En_Crow/z_en_crow.cpp rename src/overlays/actors/ovl_En_Cs/{z_en_cs.c => z_en_cs.cpp} (55%) rename src/overlays/actors/ovl_En_Daiku/{z_en_daiku.c => z_en_daiku.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c create mode 100644 src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.cpp delete mode 100644 src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c create mode 100644 src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.cpp delete mode 100644 src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c create mode 100644 src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.cpp delete mode 100644 src/overlays/actors/ovl_En_Dh/z_en_dh.c create mode 100644 src/overlays/actors/ovl_En_Dh/z_en_dh.cpp delete mode 100644 src/overlays/actors/ovl_En_Dha/z_en_dha.c create mode 100644 src/overlays/actors/ovl_En_Dha/z_en_dha.cpp delete mode 100644 src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c create mode 100644 src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.cpp delete mode 100644 src/overlays/actors/ovl_En_Dns/z_en_dns.c create mode 100644 src/overlays/actors/ovl_En_Dns/z_en_dns.cpp rename src/overlays/actors/ovl_En_Dnt_Demo/{z_en_dnt_demo.c => z_en_dnt_demo.cpp} (59%) delete mode 100644 src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c create mode 100644 src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.cpp delete mode 100644 src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c create mode 100644 src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.cpp delete mode 100644 src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c create mode 100644 src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.cpp delete mode 100644 src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c create mode 100644 src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.cpp delete mode 100644 src/overlays/actors/ovl_En_Dog/z_en_dog.c create mode 100644 src/overlays/actors/ovl_En_Dog/z_en_dog.cpp rename src/overlays/actors/ovl_En_Door/{z_en_door.c => z_en_door.cpp} (52%) delete mode 100644 src/overlays/actors/ovl_En_Ds/z_en_ds.c create mode 100644 src/overlays/actors/ovl_En_Ds/z_en_ds.cpp rename src/overlays/actors/ovl_En_Du/{z_en_du.c => z_en_du.cpp} (50%) rename src/overlays/actors/ovl_En_Dy_Extra/{z_en_dy_extra.c => z_en_dy_extra.cpp} (56%) rename src/overlays/actors/ovl_En_Eg/{z_en_eg.c => z_en_eg.cpp} (85%) delete mode 100644 src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c create mode 100644 src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.cpp delete mode 100644 src/overlays/actors/ovl_En_Elf/z_en_elf.c create mode 100644 src/overlays/actors/ovl_En_Elf/z_en_elf.cpp rename src/overlays/actors/ovl_En_Encount1/{z_en_encount1.c => z_en_encount1.cpp} (59%) rename src/overlays/actors/ovl_En_Encount2/{z_en_encount2.c => z_en_encount2.cpp} (73%) delete mode 100644 src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c create mode 100644 src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.cpp delete mode 100644 src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c create mode 100644 src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.cpp rename src/overlays/actors/ovl_En_Fd/{z_en_fd.c => z_en_fd.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.c create mode 100644 src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.cpp delete mode 100644 src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c create mode 100644 src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.cpp delete mode 100644 src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c create mode 100644 src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.cpp delete mode 100644 src/overlays/actors/ovl_En_Firefly/z_en_firefly.c create mode 100644 src/overlays/actors/ovl_En_Firefly/z_en_firefly.cpp delete mode 100644 src/overlays/actors/ovl_En_Fish/z_en_fish.c create mode 100644 src/overlays/actors/ovl_En_Fish/z_en_fish.cpp delete mode 100644 src/overlays/actors/ovl_En_Floormas/z_en_floormas.c create mode 100644 src/overlays/actors/ovl_En_Floormas/z_en_floormas.cpp delete mode 100644 src/overlays/actors/ovl_En_Fr/z_en_fr.c create mode 100644 src/overlays/actors/ovl_En_Fr/z_en_fr.cpp rename src/overlays/actors/ovl_En_Fu/{z_en_fu.c => z_en_fu.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_En_Fw/z_en_fw.c create mode 100644 src/overlays/actors/ovl_En_Fw/z_en_fw.cpp delete mode 100644 src/overlays/actors/ovl_En_Fz/z_en_fz.c create mode 100644 src/overlays/actors/ovl_En_Fz/z_en_fz.cpp rename src/overlays/actors/ovl_En_G_Switch/{z_en_g_switch.c => z_en_g_switch.cpp} (51%) rename src/overlays/actors/ovl_En_Ganon_Mant/{z_en_ganon_mant.c => z_en_ganon_mant.cpp} (78%) rename src/overlays/actors/ovl_En_Ganon_Organ/{z_en_ganon_organ.c => z_en_ganon_organ.cpp} (92%) delete mode 100644 src/overlays/actors/ovl_En_Gb/z_en_gb.c create mode 100644 src/overlays/actors/ovl_En_Gb/z_en_gb.cpp delete mode 100644 src/overlays/actors/ovl_En_Ge1/z_en_ge1.c create mode 100644 src/overlays/actors/ovl_En_Ge1/z_en_ge1.cpp delete mode 100644 src/overlays/actors/ovl_En_Ge2/z_en_ge2.c create mode 100644 src/overlays/actors/ovl_En_Ge2/z_en_ge2.cpp delete mode 100644 src/overlays/actors/ovl_En_Ge3/z_en_ge3.c create mode 100644 src/overlays/actors/ovl_En_Ge3/z_en_ge3.cpp delete mode 100644 src/overlays/actors/ovl_En_GeldB/z_en_geldb.c create mode 100644 src/overlays/actors/ovl_En_GeldB/z_en_geldb.cpp rename src/overlays/actors/ovl_En_GirlA/{z_en_girla.c => z_en_girla.cpp} (72%) delete mode 100644 src/overlays/actors/ovl_En_Gm/z_en_gm.c create mode 100644 src/overlays/actors/ovl_En_Gm/z_en_gm.cpp rename src/overlays/actors/ovl_En_Go/{z_en_go.c => z_en_go.cpp} (52%) delete mode 100644 src/overlays/actors/ovl_En_Go2/z_en_go2.c create mode 100644 src/overlays/actors/ovl_En_Go2/z_en_go2.cpp delete mode 100644 src/overlays/actors/ovl_En_Goma/z_en_goma.c create mode 100644 src/overlays/actors/ovl_En_Goma/z_en_goma.cpp delete mode 100644 src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c create mode 100644 src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp delete mode 100644 src/overlays/actors/ovl_En_Gs/z_en_gs.c create mode 100644 src/overlays/actors/ovl_En_Gs/z_en_gs.cpp rename src/overlays/actors/ovl_En_Guest/{z_en_guest.c => z_en_guest.cpp} (54%) rename src/overlays/actors/ovl_En_Hata/{z_en_hata.c => z_en_hata.cpp} (62%) delete mode 100644 src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c create mode 100644 src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.cpp delete mode 100644 src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c create mode 100644 src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.cpp delete mode 100644 src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c create mode 100644 src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.cpp delete mode 100644 src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c create mode 100644 src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.cpp delete mode 100644 src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.c create mode 100644 src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.cpp rename src/overlays/actors/ovl_En_Holl/{z_en_holl.c => z_en_holl.cpp} (56%) delete mode 100644 src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c create mode 100644 src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.cpp delete mode 100644 src/overlays/actors/ovl_En_Horse/z_en_horse.c create mode 100644 src/overlays/actors/ovl_En_Horse/z_en_horse.cpp rename src/overlays/actors/ovl_En_Horse_Game_Check/{z_en_horse_game_check.c => z_en_horse_game_check.cpp} (61%) delete mode 100644 src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c create mode 100644 src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.cpp delete mode 100644 src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c create mode 100644 src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.cpp delete mode 100644 src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c create mode 100644 src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.cpp delete mode 100644 src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c create mode 100644 src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.cpp delete mode 100644 src/overlays/actors/ovl_En_Hs/z_en_hs.c create mode 100644 src/overlays/actors/ovl_En_Hs/z_en_hs.cpp delete mode 100644 src/overlays/actors/ovl_En_Hs2/z_en_hs2.c create mode 100644 src/overlays/actors/ovl_En_Hs2/z_en_hs2.cpp rename src/overlays/actors/ovl_En_Hy/{z_en_hy.c => z_en_hy.cpp} (69%) delete mode 100644 src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c create mode 100644 src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.cpp delete mode 100644 src/overlays/actors/ovl_En_Ik/z_en_ik.c create mode 100644 src/overlays/actors/ovl_En_Ik/z_en_ik.cpp rename src/overlays/actors/ovl_En_In/{z_en_in.c => z_en_in.cpp} (55%) delete mode 100644 src/overlays/actors/ovl_En_Insect/z_en_insect.c create mode 100644 src/overlays/actors/ovl_En_Insect/z_en_insect.cpp rename src/overlays/actors/ovl_En_Ishi/{z_en_ishi.c => z_en_ishi.cpp} (51%) rename src/overlays/actors/ovl_En_It/{z_en_it.c => z_en_it.cpp} (69%) delete mode 100644 src/overlays/actors/ovl_En_Jj/z_en_jj.c create mode 100644 src/overlays/actors/ovl_En_Jj/z_en_jj.cpp rename src/overlays/actors/ovl_En_Jj/{z_en_jj_cutscene_data.c => z_en_jj_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Js/z_en_js.c create mode 100644 src/overlays/actors/ovl_En_Js/z_en_js.cpp rename src/overlays/actors/ovl_En_Jsjutan/{z_en_jsjutan.c => z_en_jsjutan.cpp} (73%) delete mode 100644 src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c create mode 100644 src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.cpp delete mode 100644 src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.c create mode 100644 src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.cpp delete mode 100644 src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c create mode 100644 src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.cpp rename src/overlays/actors/ovl_En_Kanban/{z_en_kanban.c => z_en_kanban.cpp} (51%) rename src/overlays/actors/ovl_En_Kanban/{z_en_kanban_gfx.c => z_en_kanban_gfx.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c create mode 100644 src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.cpp rename src/overlays/actors/ovl_En_Ko/{z_en_ko.c => z_en_ko.cpp} (62%) delete mode 100644 src/overlays/actors/ovl_En_Kusa/z_en_kusa.c create mode 100644 src/overlays/actors/ovl_En_Kusa/z_en_kusa.cpp delete mode 100644 src/overlays/actors/ovl_En_Kz/z_en_kz.c create mode 100644 src/overlays/actors/ovl_En_Kz/z_en_kz.cpp rename src/overlays/actors/ovl_En_Light/{z_en_light.c => z_en_light.cpp} (62%) rename src/overlays/actors/ovl_En_Lightbox/{z_en_lightbox.c => z_en_lightbox.cpp} (87%) rename src/overlays/actors/ovl_En_M_Fire1/{z_en_m_fire1.c => z_en_m_fire1.cpp} (68%) rename src/overlays/actors/ovl_En_M_Thunder/{z_en_m_thunder.c => z_en_m_thunder.cpp} (58%) rename src/overlays/actors/ovl_En_Ma1/{z_en_ma1.c => z_en_ma1.cpp} (60%) rename src/overlays/actors/ovl_En_Ma2/{z_en_ma2.c => z_en_ma2.cpp} (59%) rename src/overlays/actors/ovl_En_Ma3/{z_en_ma3.c => z_en_ma3.cpp} (68%) rename src/overlays/actors/ovl_En_Mag/{z_en_mag.c => z_en_mag.cpp} (68%) delete mode 100644 src/overlays/actors/ovl_En_Mb/z_en_mb.c create mode 100644 src/overlays/actors/ovl_En_Mb/z_en_mb.cpp delete mode 100644 src/overlays/actors/ovl_En_Md/z_en_md.c create mode 100644 src/overlays/actors/ovl_En_Md/z_en_md.cpp delete mode 100644 src/overlays/actors/ovl_En_Mk/z_en_mk.c create mode 100644 src/overlays/actors/ovl_En_Mk/z_en_mk.cpp rename src/overlays/actors/ovl_En_Mm/{z_en_mm.c => z_en_mm.cpp} (58%) rename src/overlays/actors/ovl_En_Mm2/{z_en_mm2.c => z_en_mm2.cpp} (56%) delete mode 100644 src/overlays/actors/ovl_En_Ms/z_en_ms.c create mode 100644 src/overlays/actors/ovl_En_Ms/z_en_ms.cpp rename src/overlays/actors/ovl_En_Mu/{z_en_mu.c => z_en_mu.cpp} (63%) delete mode 100644 src/overlays/actors/ovl_En_Nb/z_en_nb.c create mode 100644 src/overlays/actors/ovl_En_Nb/z_en_nb.cpp rename src/overlays/actors/ovl_En_Nb/{z_en_nb_cutscene_data.c => z_en_nb_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Niw/z_en_niw.c create mode 100644 src/overlays/actors/ovl_En_Niw/z_en_niw.cpp delete mode 100644 src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c create mode 100644 src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.cpp delete mode 100644 src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c create mode 100644 src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.cpp rename src/overlays/actors/ovl_En_Nutsball/{z_en_nutsball.c => z_en_nutsball.cpp} (55%) rename src/overlays/actors/ovl_En_Nwc/{z_en_nwc.c => z_en_nwc.cpp} (76%) delete mode 100644 src/overlays/actors/ovl_En_Ny/z_en_ny.c create mode 100644 src/overlays/actors/ovl_En_Ny/z_en_ny.cpp rename src/overlays/actors/ovl_En_OE2/{z_en_oe2.c => z_en_oe2.cpp} (72%) rename src/overlays/actors/ovl_En_Okarina_Effect/{z_en_okarina_effect.c => z_en_okarina_effect.cpp} (75%) rename src/overlays/actors/ovl_En_Okarina_Tag/{z_en_okarina_tag.c => z_en_okarina_tag.cpp} (59%) rename src/overlays/actors/ovl_En_Okarina_Tag/{z_en_okarina_tag_cutscene_data.c => z_en_okarina_tag_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Okuta/z_en_okuta.c create mode 100644 src/overlays/actors/ovl_En_Okuta/z_en_okuta.cpp rename src/overlays/actors/ovl_En_Ossan/{z_en_ossan.c => z_en_ossan.cpp} (53%) delete mode 100644 src/overlays/actors/ovl_En_Owl/z_en_owl.c create mode 100644 src/overlays/actors/ovl_En_Owl/z_en_owl.cpp rename src/overlays/actors/ovl_En_Part/{z_en_part.c => z_en_part.cpp} (50%) delete mode 100644 src/overlays/actors/ovl_En_Peehat/z_en_peehat.c create mode 100644 src/overlays/actors/ovl_En_Peehat/z_en_peehat.cpp delete mode 100644 src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c create mode 100644 src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.cpp delete mode 100644 src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c create mode 100644 src/overlays/actors/ovl_En_Po_Field/z_en_po_field.cpp delete mode 100644 src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c create mode 100644 src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.cpp delete mode 100644 src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c create mode 100644 src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp delete mode 100644 src/overlays/actors/ovl_En_Poh/z_en_poh.c create mode 100644 src/overlays/actors/ovl_En_Poh/z_en_poh.cpp rename src/overlays/actors/ovl_En_Pu_box/{z_en_pu_box.c => z_en_pu_box.cpp} (81%) delete mode 100644 src/overlays/actors/ovl_En_Rd/z_en_rd.c create mode 100644 src/overlays/actors/ovl_En_Rd/z_en_rd.cpp delete mode 100644 src/overlays/actors/ovl_En_Reeba/z_en_reeba.c create mode 100644 src/overlays/actors/ovl_En_Reeba/z_en_reeba.cpp rename src/overlays/actors/ovl_En_River_Sound/{z_en_river_sound.c => z_en_river_sound.cpp} (70%) delete mode 100644 src/overlays/actors/ovl_En_Rl/z_en_rl.c create mode 100644 src/overlays/actors/ovl_En_Rl/z_en_rl.cpp delete mode 100644 src/overlays/actors/ovl_En_Rr/z_en_rr.c create mode 100644 src/overlays/actors/ovl_En_Rr/z_en_rr.cpp delete mode 100644 src/overlays/actors/ovl_En_Ru1/z_en_ru1.c create mode 100644 src/overlays/actors/ovl_En_Ru1/z_en_ru1.cpp rename src/overlays/actors/ovl_En_Ru1/{z_en_ru1_cutscene_data.c => z_en_ru1_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Ru2/z_en_ru2.c create mode 100644 src/overlays/actors/ovl_En_Ru2/z_en_ru2.cpp rename src/overlays/actors/ovl_En_Ru2/{z_en_ru2_cutscene_data.c => z_en_ru2_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Sa/z_en_sa.c create mode 100644 src/overlays/actors/ovl_En_Sa/z_en_sa.cpp delete mode 100644 src/overlays/actors/ovl_En_Sb/z_en_sb.c create mode 100644 src/overlays/actors/ovl_En_Sb/z_en_sb.cpp rename src/overlays/actors/ovl_En_Scene_Change/{z_en_scene_change.c => z_en_scene_change.cpp} (71%) rename src/overlays/actors/ovl_En_Sda/{z_en_sda.c => z_en_sda.cpp} (94%) delete mode 100644 src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.c create mode 100644 src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.cpp rename src/overlays/actors/ovl_En_Si/{z_en_si.c => z_en_si.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c create mode 100644 src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.cpp delete mode 100644 src/overlays/actors/ovl_En_Skb/z_en_skb.c create mode 100644 src/overlays/actors/ovl_En_Skb/z_en_skb.cpp delete mode 100644 src/overlays/actors/ovl_En_Skj/z_en_skj.c create mode 100644 src/overlays/actors/ovl_En_Skj/z_en_skj.cpp rename src/overlays/actors/ovl_En_Skjneedle/{z_en_skjneedle.c => z_en_skjneedle.cpp} (66%) delete mode 100644 src/overlays/actors/ovl_En_Ssh/z_en_ssh.c create mode 100644 src/overlays/actors/ovl_En_Ssh/z_en_ssh.cpp delete mode 100644 src/overlays/actors/ovl_En_St/z_en_st.c create mode 100644 src/overlays/actors/ovl_En_St/z_en_st.cpp delete mode 100644 src/overlays/actors/ovl_En_Sth/z_en_sth.c create mode 100644 src/overlays/actors/ovl_En_Sth/z_en_sth.cpp rename src/overlays/actors/ovl_En_Stream/{z_en_stream.c => z_en_stream.cpp} (75%) delete mode 100644 src/overlays/actors/ovl_En_Sw/z_en_sw.c create mode 100644 src/overlays/actors/ovl_En_Sw/z_en_sw.cpp rename src/overlays/actors/ovl_En_Syateki_Itm/{z_en_syateki_itm.c => z_en_syateki_itm.cpp} (52%) delete mode 100644 src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c create mode 100644 src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.cpp delete mode 100644 src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c create mode 100644 src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.cpp delete mode 100644 src/overlays/actors/ovl_En_Ta/z_en_ta.c create mode 100644 src/overlays/actors/ovl_En_Ta/z_en_ta.cpp delete mode 100644 src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c create mode 100644 src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.cpp rename src/overlays/actors/ovl_En_Tana/{z_en_tana.c => z_en_tana.cpp} (92%) delete mode 100644 src/overlays/actors/ovl_En_Test/z_en_test.c create mode 100644 src/overlays/actors/ovl_En_Test/z_en_test.cpp rename src/overlays/actors/ovl_En_Tg/{z_en_tg.c => z_en_tg.cpp} (64%) delete mode 100644 src/overlays/actors/ovl_En_Tite/z_en_tite.c create mode 100644 src/overlays/actors/ovl_En_Tite/z_en_tite.cpp rename src/overlays/actors/ovl_En_Tk/{z_en_tk.c => z_en_tk.cpp} (55%) rename src/overlays/actors/ovl_En_Torch/{z_en_torch.c => z_en_torch.cpp} (78%) rename src/overlays/actors/ovl_En_Torch2/{z_en_torch2.c => z_en_torch2.cpp} (60%) rename src/overlays/actors/ovl_En_Toryo/{z_en_toryo.c => z_en_toryo.cpp} (67%) delete mode 100644 src/overlays/actors/ovl_En_Tp/z_en_tp.c create mode 100644 src/overlays/actors/ovl_En_Tp/z_en_tp.cpp delete mode 100644 src/overlays/actors/ovl_En_Tr/z_en_tr.c create mode 100644 src/overlays/actors/ovl_En_Tr/z_en_tr.cpp rename src/overlays/actors/ovl_En_Trap/{z_en_trap.c => z_en_trap.cpp} (64%) delete mode 100644 src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c create mode 100644 src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.cpp delete mode 100644 src/overlays/actors/ovl_En_Vali/z_en_vali.c create mode 100644 src/overlays/actors/ovl_En_Vali/z_en_vali.cpp rename src/overlays/actors/ovl_En_Vase/{z_en_vase.c => z_en_vase.cpp} (80%) rename src/overlays/actors/ovl_En_Vb_Ball/{z_en_vb_ball.c => z_en_vb_ball.cpp} (60%) rename src/overlays/actors/ovl_En_Viewer/{z_en_viewer.c => z_en_viewer.cpp} (63%) delete mode 100644 src/overlays/actors/ovl_En_Vm/z_en_vm.c create mode 100644 src/overlays/actors/ovl_En_Vm/z_en_vm.cpp rename src/overlays/actors/ovl_En_Wall_Tubo/{z_en_wall_tubo.c => z_en_wall_tubo.cpp} (66%) delete mode 100644 src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c create mode 100644 src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.cpp rename src/overlays/actors/ovl_En_Weather_Tag/{z_en_weather_tag.c => z_en_weather_tag.cpp} (59%) delete mode 100644 src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c create mode 100644 src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.cpp delete mode 100644 src/overlays/actors/ovl_En_Wf/z_en_wf.c create mode 100644 src/overlays/actors/ovl_En_Wf/z_en_wf.cpp delete mode 100644 src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c create mode 100644 src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.cpp rename src/overlays/actors/ovl_En_Wonder_Talk/{z_en_wonder_talk.c => z_en_wonder_talk.cpp} (50%) rename src/overlays/actors/ovl_En_Wonder_Talk2/{z_en_wonder_talk2.c => z_en_wonder_talk2.cpp} (52%) delete mode 100644 src/overlays/actors/ovl_En_Wood02/z_en_wood02.c create mode 100644 src/overlays/actors/ovl_En_Wood02/z_en_wood02.cpp delete mode 100644 src/overlays/actors/ovl_En_Xc/z_en_xc.c create mode 100644 src/overlays/actors/ovl_En_Xc/z_en_xc.cpp rename src/overlays/actors/ovl_En_Yabusame_Mark/{z_en_yabusame_mark.c => z_en_yabusame_mark.cpp} (62%) delete mode 100644 src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c create mode 100644 src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.cpp delete mode 100644 src/overlays/actors/ovl_En_Zf/z_en_zf.c create mode 100644 src/overlays/actors/ovl_En_Zf/z_en_zf.cpp delete mode 100644 src/overlays/actors/ovl_En_Zl1/z_en_zl1.c create mode 100644 src/overlays/actors/ovl_En_Zl1/z_en_zl1.cpp rename src/overlays/actors/ovl_En_Zl1/{z_en_zl1_camera_data.c => z_en_zl1_camera_data.cpp} (100%) rename src/overlays/actors/ovl_En_Zl1/{z_en_zl1_cutscene_data.c => z_en_zl1_cutscene_data.cpp} (100%) delete mode 100644 src/overlays/actors/ovl_En_Zl2/z_en_zl2.c create mode 100644 src/overlays/actors/ovl_En_Zl2/z_en_zl2.cpp delete mode 100644 src/overlays/actors/ovl_En_Zl3/z_en_zl3.c create mode 100644 src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp rename src/overlays/actors/ovl_En_Zl4/{z_en_zl4.c => z_en_zl4.cpp} (57%) rename src/overlays/actors/ovl_En_Zl4/{z_en_zl4_cutscene_data.c => z_en_zl4_cutscene_data.cpp} (100%) rename src/overlays/actors/ovl_En_Zo/{z_en_zo.c => z_en_zo.cpp} (60%) delete mode 100644 src/overlays/actors/ovl_En_fHG/z_en_fhg.c create mode 100644 src/overlays/actors/ovl_En_fHG/z_en_fhg.cpp rename src/overlays/actors/ovl_End_Title/{z_end_title.c => z_end_title.cpp} (80%) rename src/overlays/actors/ovl_Fishing/{z_fishing.c => z_fishing.cpp} (77%) rename src/overlays/actors/ovl_Item_B_Heart/{z_item_b_heart.c => z_item_b_heart.cpp} (69%) delete mode 100644 src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c create mode 100644 src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.cpp rename src/overlays/actors/ovl_Item_Inbox/{z_item_inbox.c => z_item_inbox.cpp} (62%) delete mode 100644 src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c create mode 100644 src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.cpp delete mode 100644 src/overlays/actors/ovl_Item_Shield/z_item_shield.c create mode 100644 src/overlays/actors/ovl_Item_Shield/z_item_shield.cpp rename src/overlays/actors/ovl_Magic_Dark/{z_magic_dark.c => z_magic_dark.cpp} (67%) rename src/overlays/actors/ovl_Magic_Fire/{z_magic_fire.c => z_magic_fire.cpp} (56%) rename src/overlays/actors/ovl_Magic_Wind/{z_magic_wind.c => z_magic_wind.cpp} (60%) rename src/overlays/actors/ovl_Mir_Ray/{z_mir_ray.c => z_mir_ray.cpp} (69%) delete mode 100644 src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c create mode 100644 src/overlays/actors/ovl_Obj_Bean/z_obj_bean.cpp rename src/overlays/actors/ovl_Obj_Blockstop/{z_obj_blockstop.c => z_obj_blockstop.cpp} (74%) rename src/overlays/actors/ovl_Obj_Bombiwa/{z_obj_bombiwa.c => z_obj_bombiwa.cpp} (71%) rename src/overlays/actors/ovl_Obj_Comb/{z_obj_comb.c => z_obj_comb.cpp} (61%) rename src/overlays/actors/ovl_Obj_Dekujr/{z_obj_dekujr.c => z_obj_dekujr.cpp} (65%) rename src/overlays/actors/ovl_Obj_Elevator/{z_obj_elevator.c => z_obj_elevator.cpp} (54%) rename src/overlays/actors/ovl_Obj_Hamishi/{z_obj_hamishi.c => z_obj_hamishi.cpp} (51%) rename src/overlays/actors/ovl_Obj_Hana/{z_obj_hana.c => z_obj_hana.cpp} (71%) rename src/overlays/actors/ovl_Obj_Hsblock/{z_obj_hsblock.c => z_obj_hsblock.cpp} (53%) rename src/overlays/actors/ovl_Obj_Ice_Poly/{z_obj_ice_poly.c => z_obj_ice_poly.cpp} (55%) delete mode 100644 src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c create mode 100644 src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.cpp rename src/overlays/actors/ovl_Obj_Kibako2/{z_obj_kibako2.c => z_obj_kibako2.cpp} (58%) delete mode 100644 src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c create mode 100644 src/overlays/actors/ovl_Obj_Lift/z_obj_lift.cpp delete mode 100644 src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c create mode 100644 src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.cpp rename src/overlays/actors/ovl_Obj_Makekinsuta/{z_obj_makekinsuta.c => z_obj_makekinsuta.cpp} (50%) rename src/overlays/actors/ovl_Obj_Makeoshihiki/{z_obj_makeoshihiki.c => z_obj_makeoshihiki.cpp} (98%) delete mode 100644 src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c create mode 100644 src/overlays/actors/ovl_Obj_Mure/z_obj_mure.cpp delete mode 100644 src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c create mode 100644 src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.cpp delete mode 100644 src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c create mode 100644 src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.cpp delete mode 100644 src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c create mode 100644 src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.cpp rename src/overlays/actors/ovl_Obj_Roomtimer/{z_obj_roomtimer.c => z_obj_roomtimer.cpp} (51%) delete mode 100644 src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c create mode 100644 src/overlays/actors/ovl_Obj_Switch/z_obj_switch.cpp rename src/overlays/actors/ovl_Obj_Syokudai/{z_obj_syokudai.c => z_obj_syokudai.cpp} (60%) delete mode 100644 src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c create mode 100644 src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp delete mode 100644 src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c create mode 100644 src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.cpp delete mode 100644 src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c create mode 100644 src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp delete mode 100644 src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c create mode 100644 src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.cpp rename src/overlays/actors/ovl_Oceff_Spot/{z_oceff_spot.c => z_oceff_spot.cpp} (56%) rename src/overlays/actors/ovl_Oceff_Storm/{z_oceff_storm.c => z_oceff_storm.cpp} (57%) rename src/overlays/actors/ovl_Oceff_Wipe/{z_oceff_wipe.c => z_oceff_wipe.cpp} (81%) rename src/overlays/actors/ovl_Oceff_Wipe2/{z_oceff_wipe2.c => z_oceff_wipe2.cpp} (81%) rename src/overlays/actors/ovl_Oceff_Wipe3/{z_oceff_wipe3.c => z_oceff_wipe3.cpp} (81%) rename src/overlays/actors/ovl_Oceff_Wipe4/{z_oceff_wipe4.c => z_oceff_wipe4.cpp} (79%) rename src/overlays/actors/ovl_Shot_Sun/{z_shot_sun.c => z_shot_sun.cpp} (59%) delete mode 100644 src/overlays/actors/ovl_player_actor/z_player.c create mode 100644 src/overlays/actors/ovl_player_actor/z_player.cpp rename src/overlays/effects/ovl_Effect_Ss_Blast/{z_eff_ss_blast.c => z_eff_ss_blast.cpp} (52%) rename src/overlays/effects/ovl_Effect_Ss_Bomb/{z_eff_ss_bomb.c => z_eff_ss_bomb.cpp} (69%) rename src/overlays/effects/ovl_Effect_Ss_Bomb2/{z_eff_ss_bomb2.c => z_eff_ss_bomb2.cpp} (59%) rename src/overlays/effects/ovl_Effect_Ss_Bubble/{z_eff_ss_bubble.c => z_eff_ss_bubble.cpp} (56%) rename src/overlays/effects/ovl_Effect_Ss_D_Fire/{z_eff_ss_d_fire.c => z_eff_ss_d_fire.cpp} (56%) rename src/overlays/effects/ovl_Effect_Ss_Dead_Db/{z_eff_ss_dead_db.c => z_eff_ss_dead_db.cpp} (50%) delete mode 100644 src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.cpp rename src/overlays/effects/ovl_Effect_Ss_Dead_Ds/{z_eff_ss_dead_ds.c => z_eff_ss_dead_ds.cpp} (56%) rename src/overlays/effects/ovl_Effect_Ss_Dead_Sound/{z_eff_ss_dead_sound.c => z_eff_ss_dead_sound.cpp} (62%) delete mode 100644 src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.cpp delete mode 100644 src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.cpp rename src/overlays/effects/ovl_Effect_Ss_En_Fire/{z_eff_ss_en_fire.c => z_eff_ss_en_fire.cpp} (53%) delete mode 100644 src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.cpp rename src/overlays/effects/ovl_Effect_Ss_Extra/{z_eff_ss_extra.c => z_eff_ss_extra.cpp} (69%) rename src/overlays/effects/ovl_Effect_Ss_Fcircle/{z_eff_ss_fcircle.c => z_eff_ss_fcircle.cpp} (55%) rename src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/{z_eff_ss_fhg_flash.c => z_eff_ss_fhg_flash.cpp} (68%) rename src/overlays/effects/ovl_Effect_Ss_Fire_Tail/{z_eff_ss_fire_tail.c => z_eff_ss_fire_tail.cpp} (54%) rename src/overlays/effects/ovl_Effect_Ss_G_Fire/{z_eff_ss_g_fire.c => z_eff_ss_g_fire.cpp} (57%) rename src/overlays/effects/ovl_Effect_Ss_G_Magma/{z_eff_ss_g_magma.c => z_eff_ss_g_magma.cpp} (58%) rename src/overlays/effects/ovl_Effect_Ss_G_Magma2/{z_eff_ss_g_magma2.c => z_eff_ss_g_magma2.cpp} (57%) rename src/overlays/effects/ovl_Effect_Ss_G_Ripple/{z_eff_ss_g_ripple.c => z_eff_ss_g_ripple.cpp} (54%) delete mode 100644 src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.cpp delete mode 100644 src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.cpp rename src/overlays/effects/ovl_Effect_Ss_Hahen/{z_eff_ss_hahen.c => z_eff_ss_hahen.cpp} (50%) rename src/overlays/effects/ovl_Effect_Ss_HitMark/{z_eff_ss_hitmark.c => z_eff_ss_hitmark.cpp} (61%) rename src/overlays/effects/ovl_Effect_Ss_Ice_Piece/{z_eff_ss_ice_piece.c => z_eff_ss_ice_piece.cpp} (63%) rename src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/{z_eff_ss_ice_smoke.c => z_eff_ss_ice_smoke.cpp} (69%) rename src/overlays/effects/ovl_Effect_Ss_K_Fire/{z_eff_ss_k_fire.c => z_eff_ss_k_fire.cpp} (62%) delete mode 100644 src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.cpp delete mode 100644 src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c create mode 100644 src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.cpp rename src/overlays/effects/ovl_Effect_Ss_Lightning/{z_eff_ss_lightning.c => z_eff_ss_lightning.cpp} (58%) rename src/overlays/effects/ovl_Effect_Ss_Sibuki/{z_eff_ss_sibuki.c => z_eff_ss_sibuki.cpp} (51%) rename src/overlays/effects/ovl_Effect_Ss_Sibuki2/{z_eff_ss_sibuki2.c => z_eff_ss_sibuki2.cpp} (64%) rename src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/{z_eff_ss_solder_srch_ball.c => z_eff_ss_solder_srch_ball.cpp} (57%) rename src/overlays/effects/ovl_Effect_Ss_Stick/{z_eff_ss_stick.c => z_eff_ss_stick.cpp} (68%) rename src/overlays/effects/ovl_Effect_Ss_Stone1/{z_eff_ss_stone1.c => z_eff_ss_stone1.cpp} (83%) delete mode 100644 src/overlays/gamestates/ovl_file_choose/z_file_choose.c create mode 100644 src/overlays/gamestates/ovl_file_choose/z_file_choose.cpp delete mode 100644 src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c create mode 100644 src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.cpp rename src/overlays/gamestates/ovl_file_choose/{z_file_nameset_PAL.c => z_file_nameset_PAL.cpp} (57%) rename src/overlays/gamestates/ovl_file_choose/{z_file_nameset_data.c => z_file_nameset_data.cpp} (90%) rename src/overlays/gamestates/ovl_opening/{z_opening.c => z_opening.cpp} (76%) rename src/overlays/gamestates/ovl_select/{z_select.c => z_select.cpp} (79%) rename src/overlays/gamestates/ovl_title/{z_title.c => z_title.cpp} (60%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_collect.c => z_kaleido_collect.cpp} (100%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_debug.c => z_kaleido_debug.cpp} (100%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_equipment.c => z_kaleido_equipment.cpp} (99%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_item.c => z_kaleido_item.cpp} (100%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_map_PAL.c => z_kaleido_map_PAL.cpp} (100%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_prompt.c => z_kaleido_prompt.cpp} (100%) rename src/overlays/misc/ovl_kaleido_scope/{z_kaleido_scope_PAL.c => z_kaleido_scope_PAL.cpp} (98%) rename src/overlays/misc/ovl_kaleido_scope/{z_lmap_mark.c => z_lmap_mark.cpp} (100%) rename src/overlays/misc/ovl_kaleido_scope/{z_lmap_mark_data.c => z_lmap_mark_data.cpp} (100%) rename src/overlays/misc/ovl_map_mark_data/{z_map_mark_data.c => z_map_mark_data.cpp} (100%) delete mode 100644 src/port/code_800F9280.c create mode 100644 src/port/code_800F9280.cpp rename src/port/{main.c => main.cpp} (93%) rename src/port/{rsp.c => rsp.cpp} (100%) rename src/port/{rsp_boot.c => rsp_boot.cpp} (100%) diff --git a/assets/text/fra_message_data_static.c b/assets/text/fra_message_data_static.cpp similarity index 60% rename from assets/text/fra_message_data_static.c rename to assets/text/fra_message_data_static.cpp index abad26c54..3cbe3357f 100644 --- a/assets/text/fra_message_data_static.c +++ b/assets/text/fra_message_data_static.cpp @@ -1,8 +1,9 @@ #define MESSAGE_DATA_STATIC #include "message_data_fmt.h" +#include "message_data_static.h" #define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - const char _message_##textId##_fra[sizeof(fraMessage)] = { fraMessage END }; + const char _message_##textId##_fra[sizeof(fraMessage END)] = { fraMessage END }; #include "assets/text/message_data.enc.h" diff --git a/assets/text/ger_message_data_static.c b/assets/text/ger_message_data_static.cpp similarity index 60% rename from assets/text/ger_message_data_static.c rename to assets/text/ger_message_data_static.cpp index c4b8229a0..1e8984750 100644 --- a/assets/text/ger_message_data_static.c +++ b/assets/text/ger_message_data_static.cpp @@ -1,8 +1,9 @@ #define MESSAGE_DATA_STATIC #include "message_data_fmt.h" +#include "message_data_static.h" #define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - const char _message_##textId##_ger[sizeof(gerMessage)] = { gerMessage END }; + const char _message_##textId##_ger[sizeof(gerMessage END)] = { gerMessage END }; #include "assets/text/message_data.enc.h" diff --git a/assets/text/nes_message_data_static.c b/assets/text/nes_message_data_static.cpp similarity index 66% rename from assets/text/nes_message_data_static.c rename to assets/text/nes_message_data_static.cpp index 2c37692d2..1f8014fb2 100644 --- a/assets/text/nes_message_data_static.c +++ b/assets/text/nes_message_data_static.cpp @@ -1,12 +1,14 @@ #define MESSAGE_DATA_STATIC #include "message_data_fmt.h" +#include "message_data_static.h" #define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - const char _message_##textId##_nes[sizeof(nesMessage)] = { nesMessage END }; + const char _message_##textId##_nes[sizeof(nesMessage END)] = { nesMessage END }; #define DEFINE_MESSAGE_FFFC #include "assets/text/message_data.enc.h" + #undef DEFINE_MESSAGE_FFFC diff --git a/assets/text/staff_message_data_static.c b/assets/text/staff_message_data_static.cpp similarity index 57% rename from assets/text/staff_message_data_static.c rename to assets/text/staff_message_data_static.cpp index 5ad50b044..027481d36 100644 --- a/assets/text/staff_message_data_static.c +++ b/assets/text/staff_message_data_static.cpp @@ -1,8 +1,10 @@ #define MESSAGE_DATA_STATIC #include "message_data_fmt.h" +#include "message_data_static.h" #define DEFINE_MESSAGE(textId, type, yPos, staffMessage) \ - const char _message_##textId##_staff[sizeof(staffMessage)] = { staffMessage END }; + const char _message_##textId##_staff[sizeof(staffMessage END)] = { staffMessage END }; #include "assets/text/message_data_staff.enc.h" + diff --git a/include/audiomgr.h b/include/audiomgr.h index 5580713ad..c9a74298e 100644 --- a/include/audiomgr.h +++ b/include/audiomgr.h @@ -3,13 +3,13 @@ #include "sched.h" #include "z64math.h" -typedef struct { +struct SoundSource { /* 0x00 */ u16 countdown; /* 0x04 */ Vec3f originPos; /* 0x10 */ Vec3f relativePos; -} SoundSource; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct AudioMgr { /* 0x0000 */ IrqMgr* irqMgr; /* 0x0004 */ SchedContext* sched; /* 0x0008 */ OSScTask audioTask; @@ -25,7 +25,7 @@ typedef struct { /* 0x00E0 */ OSMesg unk_E0; /* 0x00E4 */ char unk_E4[0x04]; /* 0x00E8 */ OSThread unk_E8; -} AudioMgr; // size = 0x298 +}; // size = 0x298 extern Vec3f D_801333D4; extern f32 D_801333E0; diff --git a/include/code_800ACE70.h b/include/code_800ACE70.h index 3b844c928..b6bf37eef 100644 --- a/include/code_800ACE70.h +++ b/include/code_800ACE70.h @@ -1,10 +1,10 @@ #pragma once // Vis... -typedef struct { +struct struct_801664F0 { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; /* 0x08 */ Color_RGBA8_u32 color; /* 0x0C */ Color_RGBA8_u32 envColor; -} struct_801664F0; // size = 0x10 +}; // size = 0x10 diff --git a/include/color.h b/include/color.h index bd75e3838..88b3827b7 100644 --- a/include/color.h +++ b/include/color.h @@ -1,12 +1,12 @@ #pragma once -typedef struct { +struct Color_RGB8 { u8 r, g, b; -} Color_RGB8; +}; -typedef struct { +struct Color_RGBA8 { u8 r, g, b, a; -} Color_RGBA8; +}; // only use when necessary for alignment purposes typedef union { @@ -16,9 +16,9 @@ typedef union { u32 rgba; } Color_RGBA8_u32; -typedef struct { +struct Color_RGBAf { f32 r, g, b, a; -} Color_RGBAf; +}; typedef union { struct { diff --git a/include/command_macros_base.h b/include/command_macros_base.h index 6cf955e80..030bd8351 100644 --- a/include/command_macros_base.h +++ b/include/command_macros_base.h @@ -57,6 +57,6 @@ #endif #endif -#define CMD_PTR(a) (void*)(a) +#define CMD_PTR(a) (uintptr_t)(a) #endif diff --git a/include/def/PreRender.h b/include/def/PreRender.h index 659d00a3f..840728dc8 100644 --- a/include/def/PreRender.h +++ b/include/def/PreRender.h @@ -1,44 +1,23 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_PRERENDER_C -void PreRender_Calc(PreRender* this); -void PreRender_Destroy(PreRender* this); -void PreRender_Init(PreRender* this); -void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf); -void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg); -void func_800C0F28(PreRender* this, Gfx** gfxp, void* buf, void* bufSave); -void func_800C1258(PreRender* this, Gfx** gfxp); -void func_800C170C(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave, u32 r, u32 g, u32 b, u32 a); -void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave); -void func_800C1B24(PreRender* this, Gfx** gfxp, void* fbuf, void* cvgSave); -void func_800C1E9C(PreRender* this, Gfx** gfxp); -void func_800C1F20(PreRender* this, Gfx** gfxp); -void func_800C1FA4(PreRender* this, Gfx** gfxp); -void func_800C20B4(PreRender* this, Gfx** gfxp); -void func_800C2118(PreRender* this, Gfx** gfxp); -void func_800C213C(PreRender* this, Gfx** gfxp); -void func_800C24BC(PreRender* this, Gfx** gfxp); -void func_800C24E0(PreRender* this, Gfx** gfxp); -void func_800C2500(PreRender* this, s32 x, s32 y); -void func_800C2FE4(PreRender* this); -#else -void PreRender_Calc(struct PreRender* this); -void PreRender_Destroy(struct PreRender* this); -void PreRender_Init(struct PreRender* this); -void PreRender_SetValues(struct PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf); -void PreRender_SetValuesSave(struct PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg); -void func_800C0F28(struct PreRender* this, Gfx** gfxp, void* buf, void* bufSave); -void func_800C1258(struct PreRender* this, Gfx** gfxp); -void func_800C170C(struct PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave, u32 r, u32 g, u32 b, u32 a); -void func_800C1AE8(struct PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave); -void func_800C1B24(struct PreRender* this, Gfx** gfxp, void* fbuf, void* cvgSave); -void func_800C1E9C(struct PreRender* this, Gfx** gfxp); -void func_800C1F20(struct PreRender* this, Gfx** gfxp); -void func_800C1FA4(struct PreRender* this, Gfx** gfxp); -void func_800C20B4(struct PreRender* this, Gfx** gfxp); -void func_800C2118(struct PreRender* this, Gfx** gfxp); -void func_800C213C(struct PreRender* this, Gfx** gfxp); -void func_800C24BC(struct PreRender* this, Gfx** gfxp); -void func_800C24E0(struct PreRender* this, Gfx** gfxp); -void func_800C2500(struct PreRender* this, s32 x, s32 y); -void func_800C2FE4(struct PreRender* this); -#endif +struct PreRender; + +void PreRender_Calc(PreRender* pthis); +void PreRender_Destroy(PreRender* pthis); +void PreRender_Init(PreRender* pthis); +void PreRender_SetValues(PreRender* pthis, u32 width, u32 height, void* fbuf, void* zbuf); +void PreRender_SetValuesSave(PreRender* pthis, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg); +void func_800C0F28(PreRender* pthis, Gfx** gfxp, void* buf, void* bufSave); +void func_800C1258(PreRender* pthis, Gfx** gfxp); +void func_800C170C(PreRender* pthis, Gfx** gfxp, void* fbuf, void* fbufSave, u32 r, u32 g, u32 b, u32 a); +void func_800C1AE8(PreRender* pthis, Gfx** gfxp, void* fbuf, void* fbufSave); +void func_800C1B24(PreRender* pthis, Gfx** gfxp, void* fbuf, void* cvgSave); +void func_800C1E9C(PreRender* pthis, Gfx** gfxp); +void func_800C1F20(PreRender* pthis, Gfx** gfxp); +void func_800C1FA4(PreRender* pthis, Gfx** gfxp); +void func_800C20B4(PreRender* pthis, Gfx** gfxp); +void func_800C2118(PreRender* pthis, Gfx** gfxp); +void func_800C213C(PreRender* pthis, Gfx** gfxp); +void func_800C24BC(PreRender* pthis, Gfx** gfxp); +void func_800C24E0(PreRender* pthis, Gfx** gfxp); +void func_800C2500(PreRender* pthis, s32 x, s32 y); +void func_800C2FE4(PreRender* pthis); diff --git a/include/def/TwoHeadArena.h b/include/def/TwoHeadArena.h index b0817cc07..03c92d9e2 100644 --- a/include/def/TwoHeadArena.h +++ b/include/def/TwoHeadArena.h @@ -1,5 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_TWOHEADARENA_C +struct TwoHeadArena; +struct TwoHeadGfxArena; + void* THA_AllocEnd(TwoHeadArena* tha, u32 size); void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask); void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size); @@ -29,34 +31,3 @@ Gfx* THGA_GetTail(TwoHeadGfxArena* thga); void THGA_Init(TwoHeadGfxArena* thga); u32 THGA_IsCrash(TwoHeadGfxArena* thga); void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start); -#else -void* THA_AllocEnd(struct TwoHeadArena* tha, u32 size); -void* THA_AllocEndAlign(struct TwoHeadArena* tha, u32 size, u32 mask); -void* THA_AllocEndAlign16(struct TwoHeadArena* tha, u32 size); -void* THA_AllocStart(struct TwoHeadArena* tha, u32 size); -void* THA_AllocStart1(struct TwoHeadArena* tha); -void THA_Ct(struct TwoHeadArena* tha, void* ptr, u32 size); -void THA_Dt(struct TwoHeadArena* tha); -void* THA_GetHead(struct TwoHeadArena* tha); -s32 THA_GetSize(struct TwoHeadArena* tha); -void* THA_GetTail(struct TwoHeadArena* tha); -void THA_Init(struct TwoHeadArena* tha); -u32 THA_IsCrash(struct TwoHeadArena* tha); -void THA_SetHead(struct TwoHeadArena* tha, void* start); -Gfx* THGA_AllocEnd(struct TwoHeadGfxArena* thga, u32 size); -Gfx* THGA_AllocEnd16(struct TwoHeadGfxArena* thga); -Gfx* THGA_AllocEnd64(struct TwoHeadGfxArena* thga); -Gfx* THGA_AllocEndArray16(struct TwoHeadGfxArena* thga, u32 count); -Gfx* THGA_AllocEndArray64(struct TwoHeadGfxArena* thga, u32 count); -Gfx* THGA_AllocStart8(struct TwoHeadGfxArena* thga); -Gfx* THGA_AllocStart8Wrapper(struct TwoHeadGfxArena* thga); -Gfx* THGA_AllocStartArray8(struct TwoHeadGfxArena* thga, u32 count); -void THGA_Ct(struct TwoHeadGfxArena* thga, Gfx* start, u32 size); -void THGA_Dt(struct TwoHeadGfxArena* thga); -Gfx* THGA_GetHead(struct TwoHeadGfxArena* thga); -s32 THGA_GetSize(struct TwoHeadGfxArena* thga); -Gfx* THGA_GetTail(struct TwoHeadGfxArena* thga); -void THGA_Init(struct TwoHeadGfxArena* thga); -u32 THGA_IsCrash(struct TwoHeadGfxArena* thga); -void THGA_SetHead(struct TwoHeadGfxArena* thga, Gfx* start); -#endif diff --git a/include/def/aisetfreq.h b/include/def/aisetfreq.h index 7545e87d7..20d9ad40c 100644 --- a/include/def/aisetfreq.h +++ b/include/def/aisetfreq.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_AISETFREQ_C + s32 osAiSetFrequency(u32 frequency); -#else -s32 osAiSetFrequency(u32 frequency); -#endif diff --git a/include/def/aisetnextbuf.h b/include/def/aisetnextbuf.h index b8208d9a2..9c9a3d915 100644 --- a/include/def/aisetnextbuf.h +++ b/include/def/aisetnextbuf.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_AISETNEXTBUF_C + s32 osAiSetNextBuffer(void*, u32); -#else -s32 osAiSetNextBuffer(void*, u32); -#endif diff --git a/include/def/assert.h b/include/def/assert.h index 3376150af..dce27a082 100644 --- a/include/def/assert.h +++ b/include/def/assert.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_BOOT_ASSERT_C + void __assert(const char* exp, const char* file, s32 line); -#else -void __assert(const char* exp, const char* file, s32 line); -#endif diff --git a/include/def/audioMgr.h b/include/def/audioMgr.h index 5d2c5d9c7..66e2b5c4f 100644 --- a/include/def/audioMgr.h +++ b/include/def/audioMgr.h @@ -1,16 +1,11 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_AUDIOMGR_C +struct AudioMgr; +struct SchedContext; +struct IrqMgr; + void AudioMgr_HandlePRENMI(AudioMgr* audioMgr); void AudioMgr_HandleRetrace(AudioMgr* audioMgr); void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr); void AudioMgr_ThreadEntry(void* arg0); void AudioMgr_Unlock(AudioMgr* audioMgr); void func_800C3C80(AudioMgr* audioMgr); -#else -void AudioMgr_HandlePRENMI(struct AudioMgr* audioMgr); -void AudioMgr_HandleRetrace(struct AudioMgr* audioMgr); -void AudioMgr_Init(struct AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, struct SchedContext* sched, struct IrqMgr* irqMgr); -void AudioMgr_ThreadEntry(void* arg0); -void AudioMgr_Unlock(struct AudioMgr* audioMgr); -void func_800C3C80(struct AudioMgr* audioMgr); -#endif diff --git a/include/def/audio_data.h b/include/def/audio_data.h index aa8516cc4..c3504ad3c 100644 --- a/include/def/audio_data.h +++ b/include/def/audio_data.h @@ -1,4 +1,5 @@ #pragma once +struct AdsrEnvelope; extern s16 D_8012FBA8[]; extern f32 gBendPitchOneOctaveFrequencies[256]; diff --git a/include/def/audio_effects.h b/include/def/audio_effects.h index 7a3c39bbd..e52ec0e41 100644 --- a/include/def/audio_effects.h +++ b/include/def/audio_effects.h @@ -1,5 +1,11 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_AUDIO_EFFECTS_C +struct AdsrEnvelope; +struct Portamento; +struct VibratoState; +struct Note; +struct SequenceChannel; +struct SequencePlayer; + void Audio_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut); f32 Audio_AdsrUpdate(AdsrState* adsr); f32 Audio_GetPortamentoFreqScale(Portamento* p); @@ -10,15 +16,3 @@ void Audio_NoteVibratoInit(Note* note); void Audio_NoteVibratoUpdate(Note* note); void Audio_SequenceChannelProcessSound(SequenceChannel* channel, s32 recalculateVolume, s32 b); void Audio_SequencePlayerProcessSound(SequencePlayer* seqPlayer); -#else -void Audio_AdsrInit(AdsrState* adsr, struct AdsrEnvelope* envelope, s16* volOut); -f32 Audio_AdsrUpdate(AdsrState* adsr); -f32 Audio_GetPortamentoFreqScale(struct Portamento* p); -f32 Audio_GetVibratoFreqScale(struct VibratoState* vib); -s16 Audio_GetVibratoPitchChange(struct VibratoState* vib); -void Audio_NotePortamentoInit(struct Note* note); -void Audio_NoteVibratoInit(struct Note* note); -void Audio_NoteVibratoUpdate(struct Note* note); -void Audio_SequenceChannelProcessSound(struct SequenceChannel* channel, s32 recalculateVolume, s32 b); -void Audio_SequencePlayerProcessSound(struct SequencePlayer* seqPlayer); -#endif diff --git a/include/def/audio_heap.h b/include/def/audio_heap.h index 752257ad9..0a811f4a9 100644 --- a/include/def/audio_heap.h +++ b/include/def/audio_heap.h @@ -1,5 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_AUDIO_HEAP_C +struct AudioAllocPool; +struct AudioPersistentCache; +struct AudioTemporaryCache; + void* AudioHeap_Alloc(AudioAllocPool* pool, u32 size); void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, u32 size); void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id); @@ -24,29 +27,3 @@ void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); void AudioHeap_TemporaryCacheClear(AudioTemporaryCache* temporary); void AudioHeap_WritebackDCache(void* mem, u32 size); -#else -void* AudioHeap_Alloc(struct AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocAttemptExternal(struct AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id); -void* AudioHeap_AllocDmaMemory(struct AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocDmaMemoryZeroed(struct AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size); -void AudioHeap_AllocPoolInit(struct AudioAllocPool* pool, void* mem, u32 size); -void* AudioHeap_AllocSampleCache(u32 size, s32 fontId, void* sampleAddr, s8 medium, s32 cache); -void* AudioHeap_AllocZeroed(struct AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocZeroedAttemptExternal(struct AudioAllocPool* pool, u32 size); -void AudioHeap_ApplySampleBankCache(s32 sampleBankId); -void AudioHeap_DiscardFont(s32 fontId); -void AudioHeap_DiscardSequence(s32 seqId); -void AudioHeap_Init(void); -void AudioHeap_InitMainPools(s32 sizeForAudioInitPool); -void AudioHeap_LoadFilter(s16* filter, s32 filter1, s32 filter2); -void AudioHeap_PersistentCacheClear(struct AudioPersistentCache* persistent); -void AudioHeap_PopCache(s32 tableType); -s32 AudioHeap_ResetStep(void); -void* AudioHeap_SearchCaches(s32 tableType, s32 arg1, s32 id); -void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); -void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); -void AudioHeap_TemporaryCacheClear(struct AudioTemporaryCache* temporary); -void AudioHeap_WritebackDCache(void* mem, u32 size); -#endif diff --git a/include/def/audio_init_params.h b/include/def/audio_init_params.h index fe597f091..02ae936e4 100644 --- a/include/def/audio_init_params.h +++ b/include/def/audio_init_params.h @@ -1,4 +1,9 @@ #pragma once +struct AudioContextInitSizes; +struct AudioContext; +struct AudioSpec; extern const s16 D_8014A6C0[]; extern const AudioContextInitSizes D_8014A6C4; +extern AudioContext gAudioContext; +extern AudioSpec gAudioSpecs[18]; diff --git a/include/def/audio_load.h b/include/def/audio_load.h index ab74acf46..89c5ce0df 100644 --- a/include/def/audio_load.h +++ b/include/def/audio_load.h @@ -1,14 +1,14 @@ #pragma once +struct OSMesgQueue; extern s32 gAudioContextInitalized; -#ifdef INTERNAL_SRC_CODE_AUDIO_LOAD_C void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue); void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); void AudioLoad_DecreaseSampleDmaTtls(void); void AudioLoad_DiscardSeqFonts(s32 seqId); -void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, s32 medium); +void* AudioLoad_DmaSampleData(Pointer devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* arg1); void AudioLoad_Init(void* heap, u32 heapSize); void AudioLoad_InitAsyncLoads(void); @@ -30,32 +30,3 @@ s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2); s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 arg2); s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1); -#else -void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, struct OSMesgQueue* retQueue); -void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, struct OSMesgQueue* retQueue); -void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, struct OSMesgQueue* retQueue); -void AudioLoad_DecreaseSampleDmaTtls(void); -void AudioLoad_DiscardSeqFonts(s32 seqId); -void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, s32 medium); -u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* arg1); -void AudioLoad_Init(void* heap, u32 heapSize); -void AudioLoad_InitAsyncLoads(void); -void AudioLoad_InitSampleDmaBuffers(s32 arg0); -void AudioLoad_InitScriptLoads(void); -void AudioLoad_InitSlowLoads(void); -s32 AudioLoad_IsFontLoadComplete(s32 fontId); -s32 AudioLoad_IsSeqLoadComplete(s32 seqId); -void AudioLoad_LoadPermanentSamples(void); -void AudioLoad_ProcessLoads(s32 resetStatus); -void AudioLoad_ProcessScriptLoads(void); -void AudioLoad_ScriptLoad(s32 tableType, s32 arg1, s8* arg2); -void AudioLoad_SetDmaHandler(DmaHandler callback); -void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); -void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); -s32 AudioLoad_SlowLoadSample(s32 arg0, s32 arg1, s8* arg2); -s32 AudioLoad_SlowLoadSeq(s32 playerIdx, u8* ramAddr, s8* arg2); -s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2); -s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 arg2); -s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); -void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1); -#endif diff --git a/include/def/audio_playback.h b/include/def/audio_playback.h index 8c3068c37..8afe7aee6 100644 --- a/include/def/audio_playback.h +++ b/include/def/audio_playback.h @@ -1,5 +1,13 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_AUDIO_PLAYBACK_C +struct SequenceLayer; +struct Note; +struct NotePool; +struct AudioListItem; +struct Drum; +struct Instrument; +struct SoundFontSound; +struct NoteSubAttributes; + Note* Audio_AllocNote(SequenceLayer* layer); Note* Audio_AllocNoteFromActive(NotePool* pool, SequenceLayer* layer); Note* Audio_AllocNoteFromDecaying(NotePool* pool, SequenceLayer* layer); @@ -31,36 +39,3 @@ void Audio_SeqLayerNoteDecay(SequenceLayer* layer); void Audio_SeqLayerNoteRelease(SequenceLayer* layer); s32 Audio_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value); void func_800E82C0(Note* note, SequenceLayer* layer); -#else -struct Note* Audio_AllocNote(struct SequenceLayer* layer); -struct Note* Audio_AllocNoteFromActive(struct NotePool* pool, struct SequenceLayer* layer); -struct Note* Audio_AllocNoteFromDecaying(struct NotePool* pool, struct SequenceLayer* layer); -struct Note* Audio_AllocNoteFromDisabled(struct NotePool* pool, struct SequenceLayer* layer); -void Audio_AudioListPushFront(struct AudioListItem* list, struct AudioListItem* item); -void Audio_AudioListRemove(struct AudioListItem* item); -s32 Audio_BuildSyntheticWave(struct Note* note, struct SequenceLayer* layer, s32 waveId); -struct Note* Audio_FindNodeWithPrioLessThan(struct AudioListItem* list, s32 limit); -struct Drum* Audio_GetDrum(s32 fontId, s32 drumId); -struct Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId); -struct SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId); -void Audio_InitNoteFreeList(void); -void Audio_InitNoteList(struct AudioListItem* list); -void Audio_InitNoteLists(struct NotePool* pool); -void Audio_InitNoteSub(struct Note* note, NoteSubEu* sub, struct NoteSubAttributes* attrs); -void Audio_InitSyntheticWave(struct Note* note, struct SequenceLayer* layer); -struct SoundFontSound* Audio_InstrumentGetSound(struct Instrument* instrument, s32 semitone); -void Audio_NoteDisable(struct Note* note); -void Audio_NoteInit(struct Note* note); -void Audio_NoteInitAll(void); -void Audio_NoteInitForLayer(struct Note* note, struct SequenceLayer* layer); -void Audio_NotePoolClear(struct NotePool* pool); -void Audio_NotePoolFill(struct NotePool* pool, s32 count); -void Audio_NoteReleaseAndTakeOwnership(struct Note* note, struct SequenceLayer* layer); -void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput); -void Audio_ProcessNotes(void); -void Audio_SeqLayerDecayRelease(struct SequenceLayer* layer, s32 target); -void Audio_SeqLayerNoteDecay(struct SequenceLayer* layer); -void Audio_SeqLayerNoteRelease(struct SequenceLayer* layer); -s32 Audio_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value); -void func_800E82C0(struct Note* note, struct SequenceLayer* layer); -#endif diff --git a/include/def/audio_seqplayer.h b/include/def/audio_seqplayer.h index 8fb4a0f3b..7c5d50be2 100644 --- a/include/def/audio_seqplayer.h +++ b/include/def/audio_seqplayer.h @@ -1,5 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_AUDIO_SEQPLAYER_C +struct AudioListItem; +struct SequencePlayer; +struct SequenceChannel; + void* AudioSeq_AudioListPopBack(AudioListItem* list); void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); @@ -10,15 +13,3 @@ void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer); -#else -void* AudioSeq_AudioListPopBack(struct AudioListItem* list); -void AudioSeq_AudioListPushBack(struct AudioListItem* list, struct AudioListItem* item); -void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); -void AudioSeq_InitSequencePlayers(void); -void AudioSeq_ProcessSequences(s32 arg0); -void AudioSeq_ResetSequencePlayer(struct SequencePlayer* seqPlayer); -void AudioSeq_SequenceChannelDisable(struct SequenceChannel* channel); -void AudioSeq_SequencePlayerDisable(struct SequencePlayer* seqPlayer); -void AudioSeq_SequencePlayerDisableAsFinished(struct SequencePlayer* seqPlayer); -void AudioSeq_SkipForwardSequence(struct SequencePlayer* seqPlayer); -#endif diff --git a/include/def/audio_sound_params.h b/include/def/audio_sound_params.h index 71373c3db..9dde2a1f1 100644 --- a/include/def/audio_sound_params.h +++ b/include/def/audio_sound_params.h @@ -1,3 +1,4 @@ #pragma once +struct SoundParams; extern SoundParams* gSoundParams[7]; diff --git a/include/def/audio_synthesis.h b/include/def/audio_synthesis.h index 4ed84592c..77fed8300 100644 --- a/include/def/audio_synthesis.h +++ b/include/def/audio_synthesis.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_AUDIO_SYNTHESIS_C + Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen); -#else -Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen); -#endif diff --git a/include/def/cartrominit.h b/include/def/cartrominit.h index b8aa9e2f5..b06b0465e 100644 --- a/include/def/cartrominit.h +++ b/include/def/cartrominit.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_CARTROMINIT_C +struct OSPiHandle; + OSPiHandle* osCartRomInit(void); -#else -struct OSPiHandle* osCartRomInit(void); -#endif diff --git a/include/def/code_800430A0.h b/include/def/code_800430A0.h index 30c2b9bb6..2ed42df14 100644 --- a/include/def/code_800430A0.h +++ b/include/def/code_800430A0.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800430A0_C +struct CollisionContext; +struct Actor; + void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId); s32 func_800433A4(CollisionContext* colCtx, s32 bgId, Actor* actor); -#else -void func_80043334(struct CollisionContext* colCtx, struct Actor* actor, s32 bgId); -s32 func_800433A4(struct CollisionContext* colCtx, s32 bgId, struct Actor* actor); -#endif diff --git a/include/def/code_80043480.h b/include/def/code_80043480.h index e6b885fe1..f401ce310 100644 --- a/include/def/code_80043480.h +++ b/include/def/code_80043480.h @@ -1,5 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_80043480_C +struct DynaPolyActor; +struct CollisionContext; +struct GlobalContext; + void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags); void func_800434A0(DynaPolyActor* dynaActor); void func_800434A8(DynaPolyActor* dynaActor); @@ -11,16 +14,3 @@ s32 func_8004356C(DynaPolyActor* dynaActor); s32 func_80043590(DynaPolyActor* dynaActor); s32 func_800435B4(DynaPolyActor* dynaActor); s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); -#else -void DynaPolyActor_Init(struct DynaPolyActor* dynaActor, s32 flags); -void func_800434A0(struct DynaPolyActor* dynaActor); -void func_800434A8(struct DynaPolyActor* dynaActor); -void func_800434C8(struct CollisionContext* colCtx, s32 floorBgId); -void func_80043508(struct CollisionContext* colCtx, s32 floorBgId); -void func_80043538(struct DynaPolyActor* dynaActor); -s32 func_80043548(struct DynaPolyActor* dynaActor); -s32 func_8004356C(struct DynaPolyActor* dynaActor); -s32 func_80043590(struct DynaPolyActor* dynaActor); -s32 func_800435B4(struct DynaPolyActor* dynaActor); -s32 func_800435D8(struct GlobalContext* globalCtx, struct DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); -#endif diff --git a/include/def/code_80069420.h b/include/def/code_80069420.h index 94af22fa5..44c0a0a2b 100644 --- a/include/def/code_80069420.h +++ b/include/def/code_80069420.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_80069420_C + void* MemCopy(void* dest, void* src, s32 size); -#else -void* MemCopy(void* dest, void* src, s32 size); -#endif diff --git a/include/def/code_8006BA00.h b/include/def/code_8006BA00.h index fbc48f10c..fcc521ef6 100644 --- a/include/def/code_8006BA00.h +++ b/include/def/code_8006BA00.h @@ -1,10 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_8006BA00_C +struct GlobalContext; +struct Vec3f; + void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId); void func_8006BA00(GlobalContext* globalCtx); void func_8006BA30(GlobalContext* globalCtx); -#else -void Audio_PlaySoundAtPosition(struct GlobalContext* globalCtx, struct Vec3f* pos, s32 duration, u16 sfxId); -void func_8006BA00(struct GlobalContext* globalCtx); -void func_8006BA30(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/code_8006C3A0.h b/include/def/code_8006C3A0.h index 62ee95a3a..6794a3c1a 100644 --- a/include/def/code_8006C3A0.h +++ b/include/def/code_8006C3A0.h @@ -1,12 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_8006C3A0_C +struct GlobalContext; + s32 Flags_GetEnv(GlobalContext* globalCtx, s16 flag); void Flags_SetEnv(GlobalContext* globalCtx, s16 flag); void Flags_UnsetAllEnv(GlobalContext* globalCtx); void Flags_UnsetEnv(GlobalContext* globalCtx, s16 flag); -#else -s32 Flags_GetEnv(struct GlobalContext* globalCtx, s16 flag); -void Flags_SetEnv(struct GlobalContext* globalCtx, s16 flag); -void Flags_UnsetAllEnv(struct GlobalContext* globalCtx); -void Flags_UnsetEnv(struct GlobalContext* globalCtx, s16 flag); -#endif diff --git a/include/def/code_8006C510.h b/include/def/code_8006C510.h index eb2edc115..ed514e1c9 100644 --- a/include/def/code_8006C510.h +++ b/include/def/code_8006C510.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_8006C510_C +struct TransformData; + f32 func_8006C5A8(f32 target, TransformData* transData, s32 refIdx); -#else -f32 func_8006C5A8(f32 target, struct TransformData* transData, s32 refIdx); -#endif diff --git a/include/def/code_80097A00.h b/include/def/code_80097A00.h index 7e1b5f5b8..6947f0d24 100644 --- a/include/def/code_80097A00.h +++ b/include/def/code_80097A00.h @@ -1,4 +1,5 @@ #pragma once +struct GlobalContext; extern u32 gBitFlags[32]; extern u16 gEquipMasks[4]; @@ -7,21 +8,13 @@ extern u8 gEquipShifts[4]; extern u32 gGsFlagsMasks[4]; extern u32 gGsFlagsShifts[4]; extern void* gItemIcons[0x82]; -#ifndef N64_VERSION -extern u8* gItemIconsGray[86][32*32]; -extern void* gItemIconsCurrent[86];//Points to either the original or the grayscale version -#endif +extern void* gItemIconsCurrent[86]; +extern void* gItemIconsGray[86][32*32]; extern u8 gItemSlots[56]; extern u16 gUpgradeCapacities[8][4]; extern u32 gUpgradeMasks[8]; extern u8 gUpgradeShifts[8]; -#ifdef INTERNAL_SRC_CODE_CODE_80097A00_C void Inventory_ChangeEquipment(s16 equipment, u16 value); void Inventory_ChangeUpgrade(s16 upgrade, s16 value); u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment); -#else -void Inventory_ChangeEquipment(s16 equipment, u16 value); -void Inventory_ChangeUpgrade(s16 upgrade, s16 value); -u8 Inventory_DeleteEquipment(struct GlobalContext* globalCtx, s16 equipment); -#endif diff --git a/include/def/code_800A9F30.h b/include/def/code_800A9F30.h index b16444284..2e89692c6 100644 --- a/include/def/code_800A9F30.h +++ b/include/def/code_800A9F30.h @@ -1,5 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800A9F30_C +struct PadMgr; + void func_800A9F30(PadMgr*, s32); void func_800A9F6C(f32, u8, u8, u8); void func_800AA000(f32, u8, u8, u8); @@ -9,14 +10,3 @@ u32 func_800AA148(); void func_800AA15C(); void func_800AA16C(); void func_800AA178(u32); -#else -void func_800A9F30(struct PadMgr*, s32); -void func_800A9F6C(f32, u8, u8, u8); -void func_800AA000(f32, u8, u8, u8); -void func_800AA0B4(void); -void func_800AA0F0(void); -u32 func_800AA148(void); -void func_800AA15C(void); -void func_800AA16C(void); -void func_800AA178(u32); -#endif diff --git a/include/def/code_800ACE70.h b/include/def/code_800ACE70.h index 9e144e6f7..87f7c593f 100644 --- a/include/def/code_800ACE70.h +++ b/include/def/code_800ACE70.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800ACE70_C -void func_800ACE70(struct_801664F0* this); -void func_800ACE90(struct_801664F0* this); -void func_800ACE98(struct_801664F0* this, Gfx** gfxp); -#else -void func_800ACE70(struct struct_801664F0* this); -void func_800ACE90(struct struct_801664F0* this); -void func_800ACE98(struct struct_801664F0* this, Gfx** gfxp); -#endif +struct struct_801664F0; + +void func_800ACE70(struct_801664F0* pthis); +void func_800ACE90(struct_801664F0* pthis); +void func_800ACE98(struct_801664F0* pthis, Gfx** gfxp); diff --git a/include/def/code_800AD920.h b/include/def/code_800AD920.h index fc0c6f663..433a3e665 100644 --- a/include/def/code_800AD920.h +++ b/include/def/code_800AD920.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800AD920_C -void func_800AD920(struct_80166500* this); -void func_800AD950(struct_80166500* this); -void func_800AD958(struct_80166500* this, Gfx** gfxp); -#else -void func_800AD920(struct struct_80166500* this); -void func_800AD950(struct struct_80166500* this); -void func_800AD958(struct struct_80166500* this, Gfx** gfxp); -#endif +struct struct_80166500; + +void func_800AD920(struct_80166500* pthis); +void func_800AD950(struct_80166500* pthis); +void func_800AD958(struct_80166500* pthis, Gfx** gfxp); diff --git a/include/def/code_800BB0A0.h b/include/def/code_800BB0A0.h index 0cefd1db1..833584b62 100644 --- a/include/def/code_800BB0A0.h +++ b/include/def/code_800BB0A0.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800BB0A0_C +struct Vec3f; +struct CutsceneCameraPoint; + void func_800BB0A0(f32 u, Vec3f* pos, f32* roll, f32* viewAngle, f32* point0, f32* point1, f32* point2, f32* point3); s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s16* keyframe, f32* curFrame); -#else -void func_800BB0A0(f32 u, struct Vec3f* pos, f32* roll, f32* viewAngle, f32* point0, f32* point1, f32* point2, f32* point3); -s32 func_800BB2B4(struct Vec3f* pos, f32* roll, f32* fov, struct CutsceneCameraPoint* point, s16* keyframe, f32* curFrame); -#endif diff --git a/include/def/code_800C3C20.h b/include/def/code_800C3C20.h index f1eb93f32..f4c4bd1cd 100644 --- a/include/def/code_800C3C20.h +++ b/include/def/code_800C3C20.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800C3C20_C + void func_800C3C20(void); -#else -void func_800C3C20(void); -#endif diff --git a/include/def/code_800D2E30.h b/include/def/code_800D2E30.h index f65bb009b..7f096faa0 100644 --- a/include/def/code_800D2E30.h +++ b/include/def/code_800D2E30.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800D2E30_C +struct UnkRumbleStruct; + void func_800D2E30(UnkRumbleStruct* arg0); void func_800D3140(UnkRumbleStruct* arg0); void func_800D3178(UnkRumbleStruct* arg0); -#else -void func_800D2E30(struct UnkRumbleStruct* arg0); -void func_800D3140(struct UnkRumbleStruct* arg0); -void func_800D3178(struct UnkRumbleStruct* arg0); -#endif diff --git a/include/def/code_800D31A0.h b/include/def/code_800D31A0.h index 827ae04e4..49cbdc9ef 100644 --- a/include/def/code_800D31A0.h +++ b/include/def/code_800D31A0.h @@ -2,12 +2,6 @@ extern u32 gIsCtrlr2Valid; -#ifdef INTERNAL_SRC_CODE_CODE_800D31A0_C void func_800D31A0(void); void func_800D31F0(void); void func_800D3210(void); -#else -void func_800D31A0(void); -void func_800D31F0(void); -void func_800D3210(void); -#endif diff --git a/include/def/code_800E4FE0.h b/include/def/code_800E4FE0.h index ca5a72ff2..94b960bd6 100644 --- a/include/def/code_800E4FE0.h +++ b/include/def/code_800E4FE0.h @@ -1,5 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800E4FE0_C +struct AudioTask; + void Audio_InitMesgQueues(void); u32 Audio_NextRandom(void); void Audio_PreNMIInternal(void); @@ -14,19 +15,4 @@ u8* func_800E5E84(s32 arg0, u32* arg1); s32 func_800E5EDC(void); s32 func_800E5F88(s32 arg0); s32 func_800E6680(void); -#else -void Audio_InitMesgQueues(void); -u32 Audio_NextRandom(void); -void Audio_PreNMIInternal(void); -void Audio_QueueCmdF32(u32 arg0, f32 arg1); -void Audio_QueueCmdS32(u32 arg0, s32 arg1); -void Audio_QueueCmdS8(u32 arg0, s8 arg1); -void Audio_QueueCmdU16(u32 arg0, u16 arg1); -s32 Audio_ScheduleProcessCmds(void); -struct AudioTask* func_800E4FE0(void); -u32 func_800E5E20(u32* arg0); -u8* func_800E5E84(s32 arg0, u32* arg1); -s32 func_800E5EDC(void); -s32 func_800E5F88(s32 arg0); -s32 func_800E6680(void); -#endif +u32 osGetCount(void); diff --git a/include/def/code_800E6840.h b/include/def/code_800E6840.h index ca9bfb1a9..3502612ee 100644 --- a/include/def/code_800E6840.h +++ b/include/def/code_800E6840.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800E6840_C + void Audio_InvalDCache(void* buf, s32 size); void Audio_WritebackDCache(void* mem, s32 size); -#else -void Audio_InvalDCache(void* buf, s32 size); -void Audio_WritebackDCache(void* mem, s32 size); -#endif diff --git a/include/def/code_800EC960.h b/include/def/code_800EC960.h index 910837805..e90ed1623 100644 --- a/include/def/code_800EC960.h +++ b/include/def/code_800EC960.h @@ -1,4 +1,8 @@ #pragma once +struct Vec3f; +struct OcarinaStaff; +struct OcarinaSongInfo; +struct OcarinaNote; extern u8 gChannelsPerBank[4][7]; extern u8* gFrogsSongPtr; @@ -9,7 +13,6 @@ extern OcarinaNote* gScarecrowCustomSongPtr; extern u8* gScarecrowSpawnSongPtr; extern u8 gUsedChannelsPerBank[4][7]; -#ifdef INTERNAL_SRC_CODE_CODE_800EC960_C void AudioDebug_ScrPrt(const s8* str, u16 num); void Audio_ClearSariaBgm(void); void Audio_ClearSariaBgm2(void); @@ -84,79 +87,3 @@ void func_800F6D58(u8, u8, u8); void func_800F6FB4(u8); void func_800F7170(void); void func_800F71BC(s32 arg0); -#else -void AudioDebug_ScrPrt(const s8* str, u16 num); -void Audio_ClearSariaBgm(void); -void Audio_ClearSariaBgm2(void); -void Audio_ClearSariaBgmAtPos(struct Vec3f* pos); -void Audio_Init(void); -void Audio_InitSound(void); -struct OcarinaStaff* Audio_OcaGetDisplayingStaff(void); -struct OcarinaStaff* Audio_OcaGetPlayingStaff(void); -struct OcarinaStaff* Audio_OcaGetRecordingStaff(void); -s32 Audio_OcaMemoryGameGenNote(void); -void Audio_OcaMemoryGameStart(u8 minigameIdx); -void Audio_OcaSetInstrument(u8); -void Audio_OcaSetRecordingState(u8); -void Audio_OcaSetSongPlayback(s8 songIdxPlusOne, s8 playbackState); -void Audio_PlayFanfare(u16); -void Audio_PlaySariaBgm(struct Vec3f* pos, u16 seqId, u16 distMax); -void Audio_PlaySoundIfNotInCutscene(u16 sfxId); -void Audio_PlaySoundIncreasinglyTransposed(struct Vec3f* pos, s16 sfxId, u8* semitones); -void Audio_PlaySoundRandom(struct Vec3f* pos, u16 baseSfxId, u8 randLim); -void Audio_PlaySoundRiver(struct Vec3f* pos, f32 freqScale); -void Audio_PlaySoundTransposed(struct Vec3f* pos, u16 sfxId, s8 semitone); -void Audio_PlaySoundWaterfall(struct Vec3f* pos, f32 freqScale); -void Audio_PreNMI(void); -void Audio_ResetIncreasingTranspose(void); -void Audio_SetBaseFilter(u8); -void Audio_SetBgmEnemyVolume(f32 dist); -void Audio_SetCodeReverb(s8 reverb); -void Audio_SetCutsceneFlag(s8 flag); -void Audio_SetEnvReverb(s8 reverb); -void Audio_SetExtraFilter(u8); -void Audio_SetSequenceMode(u8 seqMode); -void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx); -void func_800ECC04(u16); -void func_800EE824(void); -void func_800F3054(void); -void func_800F3F3C(u8); -void func_800F4010(struct Vec3f* pos, u16 sfxId, f32); -void func_800F4138(struct Vec3f* pos, u16 sfxId, f32); -void func_800F4190(struct Vec3f* pos, u16 sfxId); -void func_800F4254(struct Vec3f* pos, u8 arg1); -void func_800F436C(struct Vec3f*, u16 sfxId, f32 arg2); -void func_800F4414(struct Vec3f*, u16 sfxId, f32 arg2); -void func_800F44EC(s8 arg0, s8 arg1); -void func_800F4524(struct Vec3f* pos, u16 sfxId, s8 arg2); -void func_800F47BC(void); -void func_800F47FC(void); -void func_800F483C(u8 targetVol, u8 volFadeTimer); -void func_800F4870(u8); -void func_800F4A54(u8); -void func_800F4C58(struct Vec3f* pos, u16 sfxId, u8); -void func_800F4E30(struct Vec3f* pos, f32); -void func_800F5510(u16 seqId); -void func_800F5550(u16 seqId); -void func_800F5718(void); -void func_800F574C(f32 arg0, u8 arg2); -void func_800F5918(void); -void func_800F595C(u16); -void func_800F59E8(u16); -s32 func_800F5A58(u8); -void func_800F5ACC(u16 bgmID); -void func_800F5B58(void); -void func_800F5BF0(u8 arg0); -void func_800F5C2C(void); -void func_800F5E18(u8 playerIdx, u16 seqId, u8 fadeTimer, s8 arg3, s8 arg4); -void func_800F6268(f32 dist, u16); -void func_800F64E0(u8 arg0); -void func_800F6584(u8 arg0); -void func_800F6700(s8 outputMode); -void func_800F6964(u16); -void func_800F6AB0(u16); -void func_800F6D58(u8, u8, u8); -void func_800F6FB4(u8); -void func_800F7170(void); -void func_800F71BC(s32 arg0); -#endif diff --git a/include/def/code_800F7260.h b/include/def/code_800F7260.h index aa32dd1f7..abf496193 100644 --- a/include/def/code_800F7260.h +++ b/include/def/code_800F7260.h @@ -1,4 +1,9 @@ #pragma once +struct Vec3f; +struct unk_D_8016E750; +struct ActiveSound; +struct AudioContext; +struct SoundBankEntry; extern char D_80133390[]; extern char D_80133398[]; @@ -19,7 +24,6 @@ extern u8 gSoundBankMuted[]; extern SoundBankEntry* gSoundBanks[7]; extern u32 sAudioSeqCmds[0x100]; -#ifdef INTERNAL_SRC_CODE_CODE_800F7260_C void Audio_ChooseActiveSounds(u8 bankId); void Audio_ClearBGMMute(u8 channelIdx); u8 Audio_IsSfxPlaying(u32 sfxId); @@ -38,23 +42,3 @@ void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId); void Audio_StopSfxByTokenAndId(u8, u16); void func_800F8884(u8, Vec3f*); void func_800F8F88(void); -#else -void Audio_ChooseActiveSounds(u8 bankId); -void Audio_ClearBGMMute(u8 channelIdx); -u8 Audio_IsSfxPlaying(u32 sfxId); -void Audio_PlayActiveSounds(u8 bankId); -void Audio_PlaySoundGeneral(u16 sfxId, struct Vec3f* pos, u8 token, f32* freqScale, f32* a4, s8* reverbAdd); -void Audio_ProcessSoundRequest(void); -void Audio_ProcessSoundRequests(void); -void Audio_QueueSeqCmdMute(u8 channelIdx); -void Audio_ResetSounds(void); -void Audio_SetSoundBanksMute(u16 muteMask); -void Audio_StopSfxByBank(u8 bankId); -void Audio_StopSfxById(u32 sfxId); -void Audio_StopSfxByPos(struct Vec3f*); -void Audio_StopSfxByPosAndBank(u8, struct Vec3f*); -void Audio_StopSfxByPosAndId(struct Vec3f* pos, u16 sfxId); -void Audio_StopSfxByTokenAndId(u8, u16); -void func_800F8884(u8, struct Vec3f*); -void func_800F8F88(void); -#endif diff --git a/include/def/code_800F9280.h b/include/def/code_800F9280.h index fd0ea2e7b..a8a26a387 100644 --- a/include/def/code_800F9280.h +++ b/include/def/code_800F9280.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800F9280_C + void Audio_ProcessSeqCmd(u32); void Audio_ProcessSeqCmds(void); void Audio_QueueSeqCmd(u32 bgmID); @@ -14,19 +14,3 @@ void func_800FA3DC(void); u8 func_800FAD34(void); void func_800FADF8(void); void func_800FAEB4(void); -#else -void Audio_ProcessSeqCmd(u32); -void Audio_ProcessSeqCmds(void); -void Audio_QueueSeqCmd(u32 bgmID); -void Audio_SetVolScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); -void func_800F9280(u8 playerIdx, u8 seqId, u8 arg2, u16 fadeTimer); -void func_800F9474(u8, u16); -u16 func_800FA0B4(u8 a0); -s32 func_800FA11C(u32 arg0, u32 arg1); -void func_800FA174(u8); -void func_800FA18C(u8, u8); -void func_800FA3DC(void); -u8 func_800FAD34(void); -void func_800FADF8(void); -void func_800FAEB4(void); -#endif diff --git a/include/def/code_800FBCE0.h b/include/def/code_800FBCE0.h index 68f64e4c4..4f89ea622 100644 --- a/include/def/code_800FBCE0.h +++ b/include/def/code_800FBCE0.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800FBCE0_C + void func_800FBCE0(); void func_800FBFD8(void); -#else -void func_800FBCE0(void); -void func_800FBFD8(void); -#endif diff --git a/include/def/code_800FC620.h b/include/def/code_800FC620.h index 874caab9b..fdd69b8d3 100644 --- a/include/def/code_800FC620.h +++ b/include/def/code_800FC620.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800FC620_C -s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddress); + +s32 Overlay_Load(Pointer vRomStart, Pointer vRomEnd, Pointer vRamStart, Pointer vRamEnd, Pointer allocatedVRamAddress); void SystemHeap_Init(void* start, u32 size); -#else -s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddress); -void SystemHeap_Init(void* start, u32 size); -#endif diff --git a/include/def/code_800FCE80.h b/include/def/code_800FCE80.h index 4ace0f040..7fee4fd35 100644 --- a/include/def/code_800FCE80.h +++ b/include/def/code_800FCE80.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800FCE80_C + f32 Math_FAcosF(f32 x); f32 Math_FAsinF(f32 x); f32 Math_FAtan2F(f32 y, f32 x); @@ -10,15 +10,3 @@ f32 Math_FNearbyIntF(f32 x); f32 Math_FRoundF(f32 x); f32 Math_FTanF(f32 x); f32 Math_FTruncF(f32 x); -#else -f32 Math_FAcosF(f32 x); -f32 Math_FAsinF(f32 x); -f32 Math_FAtan2F(f32 y, f32 x); -f32 Math_FAtanF(f32 x); -f32 Math_FCeilF(f32 x); -f32 Math_FFloorF(f32 x); -f32 Math_FNearbyIntF(f32 x); -f32 Math_FRoundF(f32 x); -f32 Math_FTanF(f32 x); -f32 Math_FTruncF(f32 x); -#endif diff --git a/include/def/code_800FD970.h b/include/def/code_800FD970.h index 769274a18..b77811f01 100644 --- a/include/def/code_800FD970.h +++ b/include/def/code_800FD970.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_800FD970_C + f32 Rand_Centered(void); f32 Rand_Centered_Variable(u32* rndNum); u32 Rand_Next(void); @@ -8,13 +8,3 @@ void Rand_Seed(u32 seed); void Rand_Seed_Variable(u32* rndNum, u32 seed); f32 Rand_ZeroOne(void); f32 Rand_ZeroOne_Variable(u32* rndNum); -#else -f32 Rand_Centered(void); -f32 Rand_Centered_Variable(u32* rndNum); -u32 Rand_Next(void); -u32 Rand_Next_Variable(u32* rndNum); -void Rand_Seed(u32 seed); -void Rand_Seed_Variable(u32* rndNum, u32 seed); -f32 Rand_ZeroOne(void); -f32 Rand_ZeroOne_Variable(u32* rndNum); -#endif diff --git a/include/def/code_80106860.h b/include/def/code_80106860.h index 1c1152649..7c3134fb6 100644 --- a/include/def/code_80106860.h +++ b/include/def/code_80106860.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_80106860_C + void* z_memset(void* ptr, s32 val, size_t size); -#else -void* z_memset(void* ptr, s32 val, size_t size); -#endif diff --git a/include/def/code_801068B0.h b/include/def/code_801068B0.h index 1170dec7d..913c6f418 100644 --- a/include/def/code_801068B0.h +++ b/include/def/code_801068B0.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_CODE_801068B0_C + void* func_801068B0(void* dst, void* src, size_t size); -#else -void* func_801068B0(void* dst, void* src, size_t size); -#endif diff --git a/include/def/contpfs.h b/include/def/contpfs.h index 3510e9dbf..74106fe37 100644 --- a/include/def/contpfs.h +++ b/include/def/contpfs.h @@ -1,8 +1,10 @@ #pragma once +struct OSPfs; +struct __OSPackId; +struct __OSInode; extern u8 __osPfsInodeCacheBank; -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTPFS_C s32 __osCheckId(OSPfs* pfs); s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check); s32 __osGetId(OSPfs* pfs); @@ -10,12 +12,3 @@ s32 __osIdCheckSum(u16* ptr, u16* csum, u16* icsum); s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank); s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid); u16 __osSumcalc(u8* ptr, s32 length); -#else -s32 __osCheckId(struct OSPfs* pfs); -s32 __osCheckPackId(struct OSPfs* pfs, struct __OSPackId* check); -s32 __osGetId(struct OSPfs* pfs); -s32 __osIdCheckSum(u16* ptr, u16* csum, u16* icsum); -s32 __osPfsRWInode(struct OSPfs* pfs, struct __OSInode* inode, u8 flag, u8 bank); -s32 __osRepairPackId(struct OSPfs* pfs, struct __OSPackId* badid, struct __OSPackId* newid); -u16 __osSumcalc(u8* ptr, s32 length); -#endif diff --git a/include/def/contquery.h b/include/def/contquery.h index 189cf72f5..708723019 100644 --- a/include/def/contquery.h +++ b/include/def/contquery.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTQUERY_C +struct OSContStatus; +struct OSMesgQueue; + void osContGetQuery(OSContStatus* data); s32 osContStartQuery(OSMesgQueue* mq); -#else -void osContGetQuery(struct OSContStatus* data); -s32 osContStartQuery(struct OSMesgQueue* mq); -#endif diff --git a/include/def/contramread.h b/include/def/contramread.h index d4643c81d..f7d5ed13c 100644 --- a/include/def/contramread.h +++ b/include/def/contramread.h @@ -1,9 +1,6 @@ #pragma once +struct OSMesgQueue; extern s32 __osPfsLastChannel; -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTRAMREAD_C s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data); -#else -s32 __osContRamRead(struct OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data); -#endif diff --git a/include/def/contramwrite.h b/include/def/contramwrite.h index 3a59acb93..ddb7c5788 100644 --- a/include/def/contramwrite.h +++ b/include/def/contramwrite.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTRAMWRITE_C +struct OSMesgQueue; + s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force); -#else -s32 __osContRamWrite(struct OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force); -#endif diff --git a/include/def/contreaddata.h b/include/def/contreaddata.h index aab400285..c9923d706 100644 --- a/include/def/contreaddata.h +++ b/include/def/contreaddata.h @@ -1,10 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTREADDATA_C +struct OSContPad; +struct OSMesgQueue; + void __osPackReadData(void); void osContGetReadData(OSContPad* pad); s32 osContStartReadData(OSMesgQueue* mq); -#else -void __osPackReadData(void); -void osContGetReadData(struct OSContPad* pad); -s32 osContStartReadData(struct OSMesgQueue* mq); -#endif diff --git a/include/def/controller.h b/include/def/controller.h index 96e2e998e..88b4c4d20 100644 --- a/include/def/controller.h +++ b/include/def/controller.h @@ -1,15 +1,12 @@ #pragma once +struct OSContStatus; +struct OSMesgQueue; +struct OSPifRam; extern u8 __osContLastPoll; extern u8 __osMaxControllers; extern OSPifRam __osPifInternalBuff; -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTROLLER_C void __osContGetInitData(u8* ctl_present_bitfield, OSContStatus* status); void __osPackRequestData(u8 poll); s32 osContInit(OSMesgQueue* mq, u8* ctl_present_bitfield, OSContStatus* status); -#else -void __osContGetInitData(u8* ctl_present_bitfield, struct OSContStatus* status); -void __osPackRequestData(u8 poll); -s32 osContInit(struct OSMesgQueue* mq, u8* ctl_present_bitfield, struct OSContStatus* status); -#endif diff --git a/include/def/contsetch.h b/include/def/contsetch.h index 2d6086903..b0dbb71e7 100644 --- a/include/def/contsetch.h +++ b/include/def/contsetch.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_CONTSETCH_C + s32 osContSetCh(u8 ch); -#else -s32 osContSetCh(u8 ch); -#endif diff --git a/include/def/cosf.h b/include/def/cosf.h index 01180f583..e2dfd4541 100644 --- a/include/def/cosf.h +++ b/include/def/cosf.h @@ -1,6 +1,2 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_COSF_C -f32 cosf(f32); -#else -f32 cosf(f32); -#endif +#include diff --git a/include/def/coss.h b/include/def/coss.h index 1b004bc45..dc5e7465d 100644 --- a/include/def/coss.h +++ b/include/def/coss.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_COSS_C + s16 coss(u16); -#else -s16 coss(u16); -#endif diff --git a/include/def/crc.h b/include/def/crc.h index 29a522308..1832ffeb9 100644 --- a/include/def/crc.h +++ b/include/def/crc.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_CRC_C + u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); -#else -u8 __osContAddressCrc(u16 addr); -u8 __osContDataCrc(u8* data); -#endif diff --git a/include/def/db_camera.h b/include/def/db_camera.h index fb0ef650a..5e1a2a421 100644 --- a/include/def/db_camera.h +++ b/include/def/db_camera.h @@ -1,12 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_DB_CAMERA_C +struct DbCamera; +struct Camera; + void DbCamera_Init(DbCamera* dbCamera, Camera* cameraPtr); void DbCamera_Reset(Camera* cam, DbCamera* dbCam); void DbCamera_Update(DbCamera* dbCamera, Camera* cam); void DbgCamera_Enable(DbCamera* dbCamera, Camera* cam); -#else -void DbCamera_Init(struct DbCamera* dbCamera, struct Camera* cameraPtr); -void DbCamera_Reset(struct Camera* cam, struct DbCamera* dbCam); -void DbCamera_Update(struct DbCamera* dbCamera, struct Camera* cam); -void DbgCamera_Enable(struct DbCamera* dbCamera, struct Camera* cam); -#endif diff --git a/include/def/debug_malloc.h b/include/def/debug_malloc.h index 60722269b..25f6bab11 100644 --- a/include/def/debug_malloc.h +++ b/include/def/debug_malloc.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_DEBUG_MALLOC_C + void* DebugArena_Calloc(u32 num, u32 size); void DebugArena_Check(void); void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); @@ -16,21 +16,3 @@ void* DebugArena_MallocR(u32 size); void* DebugArena_MallocRDebug(u32 size, const char* file, s32 line); void* DebugArena_Realloc(void* ptr, u32 newSize); void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); -#else -void* DebugArena_Calloc(u32 num, u32 size); -void DebugArena_Check(void); -void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); -void DebugArena_Cleanup(void); -void DebugArena_Display(void); -void DebugArena_Free(void* ptr); -void DebugArena_FreeDebug(void* ptr, const char* file, s32 line); -void DebugArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc); -void DebugArena_Init(void* start, u32 size); -u8 DebugArena_IsInitalized(void); -void* DebugArena_Malloc(u32 size); -void* DebugArena_MallocDebug(u32 size, const char* file, s32 line); -void* DebugArena_MallocR(u32 size); -void* DebugArena_MallocRDebug(u32 size, const char* file, s32 line); -void* DebugArena_Realloc(void* ptr, u32 newSize); -void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); -#endif diff --git a/include/def/devmgr.h b/include/def/devmgr.h index fd0121d90..b03586743 100644 --- a/include/def/devmgr.h +++ b/include/def/devmgr.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_DEVMGR_C + void __osDevMgrMain(void* arg); -#else -void __osDevMgrMain(void* arg); -#endif diff --git a/include/def/dmadata.h b/include/def/dmadata.h index f57f7a3d8..e23196ff9 100644 --- a/include/def/dmadata.h +++ b/include/def/dmadata.h @@ -1,3 +1,4 @@ #pragma once +struct DmaEntry; extern DmaEntry gDmaDataTable[0x60C]; diff --git a/include/def/dpgetstat.h b/include/def/dpgetstat.h index 0bbaebf7d..4d6e52f98 100644 --- a/include/def/dpgetstat.h +++ b/include/def/dpgetstat.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_DPGETSTAT_C + u32 osDpGetStatus(void); -#else -u32 osDpGetStatus(void); -#endif diff --git a/include/def/dpsetstat.h b/include/def/dpsetstat.h index 83ccf79dc..24b9b2d82 100644 --- a/include/def/dpsetstat.h +++ b/include/def/dpsetstat.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_DPSETSTAT_C + void osDpSetStatus(u32 status); -#else -void osDpSetStatus(u32 status); -#endif diff --git a/include/def/driverominit.h b/include/def/driverominit.h index 29c5a5675..e428eec70 100644 --- a/include/def/driverominit.h +++ b/include/def/driverominit.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_DRIVEROMINIT_C +struct OSPiHandle; + OSPiHandle* osDriveRomInit(void); -#else -struct OSPiHandle* osDriveRomInit(void); -#endif diff --git a/include/def/epidma.h b/include/def/epidma.h index 967ec79cb..1c49c6714 100644 --- a/include/def/epidma.h +++ b/include/def/epidma.h @@ -1,6 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_EPIDMA_C +struct OSPiHandle; +struct OSIoMesg; + s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction); -#else -s32 osEPiStartDma(struct OSPiHandle* handle, struct OSIoMesg* mb, s32 direction); -#endif diff --git a/include/def/epirawdma.h b/include/def/epirawdma.h index ed7945951..5d20ab950 100644 --- a/include/def/epirawdma.h +++ b/include/def/epirawdma.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_EPIRAWDMA_C +struct OSPiHandle; + s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size); -#else -s32 __osEPiRawStartDma(struct OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size); -#endif diff --git a/include/def/epirawread.h b/include/def/epirawread.h index fac44bfb2..8f723dd4d 100644 --- a/include/def/epirawread.h +++ b/include/def/epirawread.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_EPIRAWREAD_C +struct OSPiHandle; + s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); -#else -s32 __osEPiRawReadIo(struct OSPiHandle* handle, u32 devAddr, u32* data); -#endif diff --git a/include/def/epiwrite.h b/include/def/epiwrite.h index ac9886ef0..50ded27f3 100644 --- a/include/def/epiwrite.h +++ b/include/def/epiwrite.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_EPIWRITE_C +struct OSPiHandle; + s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); -#else -s32 osEPiWriteIo(struct OSPiHandle* handle, u32 devAddr, u32 data); -#endif diff --git a/include/def/fault.h b/include/def/fault.h index 0b86a1c5e..55448651b 100644 --- a/include/def/fault.h +++ b/include/def/fault.h @@ -1,8 +1,13 @@ #pragma once +struct FaultAddrConvClient; +struct FaultClient; +struct OSThread; +struct Input; +struct FaultClientContext; +struct FaultThreadStruct; extern FaultThreadStruct gFaultStruct; -#ifdef INTERNAL_SRC_CODE_FAULT_C void Fault_AddAddrConvClient(FaultAddrConvClient*, void*, void*); void Fault_AddClient(FaultClient*, void*, void*, void*); void Fault_AddHungupAndCrash(const char*, u32); @@ -45,47 +50,3 @@ void Fault_WaitForButtonCombo(); void Fault_WaitForInput(); u32 Fault_WaitForInputImpl(); void Fault_WalkStack(u32* spPtr, u32* pcPtr, u32* raPtr); -#else -void Fault_AddAddrConvClient(struct FaultAddrConvClient*, void*, void*); -void Fault_AddClient(struct FaultClient*, void*, void*, void*); -void Fault_AddHungupAndCrash(const char*, u32); -void Fault_AddHungupAndCrashImpl(const char*, const char*); -void Fault_ClientProcessThread(void* arg); -void Fault_CommitFB(void); -u32 Fault_ConvertAddress(struct FaultAddrConvClient*); -void Fault_DrawCornerRec(u16); -void Fault_DrawMemDump(u32, u32, u32, u32); -void Fault_DrawMemDumpPage(const char*, u32*, u32); -void Fault_DrawRec(s32, s32, s32, s32, u16); -void Fault_DrawStackTrace(struct OSThread* thread, s32 x, s32 y, s32 height); -void Fault_FillScreenBlack(void); -void Fault_FillScreenRed(void); -struct OSThread* Fault_FindFaultedThread(void); -void Fault_HangupFaultClient(const char*, const char*); -void Fault_Init(void); -void Fault_LogFPCR(u32); -void Fault_LogFReg(s32, f32*); -void Fault_LogStackTrace(struct OSThread* thread, s32 height); -void Fault_LogThreadContext(struct OSThread*); -void Fault_PadCallback(struct Input*); -void Fault_PrintFPCR(u32); -void Fault_PrintFReg(s32, f32*); -void Fault_PrintThreadContext(struct OSThread*); -u32 Fault_ProcessClient(u32, u32, u32); -void Fault_ProcessClientContext(struct FaultClientContext*); -void Fault_ProcessClients(void); -void Fault_RemoveAddrConvClient(struct FaultAddrConvClient*); -void Fault_RemoveClient(struct FaultClient*); -void Fault_ResumeThread(struct OSThread*); -void Fault_SetFB(void*, u16, u16); -void Fault_Sleep(u32); -void Fault_SleepImpl(u32); -void Fault_ThreadEntry(void*); -void Fault_UpdatePad(void); -void Fault_UpdatePadImpl(void); -void Fault_Wait5Seconds(void); -void Fault_WaitForButtonCombo(void); -void Fault_WaitForInput(void); -u32 Fault_WaitForInputImpl(void); -void Fault_WalkStack(u32* spPtr, u32* pcPtr, u32* raPtr); -#endif diff --git a/include/def/fault_drawer.h b/include/def/fault_drawer.h index 543e3ef3d..9ba8a9af0 100644 --- a/include/def/fault_drawer.h +++ b/include/def/fault_drawer.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_FAULT_DRAWER_C + s32 FaultDrawer_ColorToPrintColor(u16); void FaultDrawer_DrawChar(char); void FaultDrawer_DrawRecImpl(s32, s32, s32, s32, u16); @@ -14,25 +14,7 @@ void FaultDrawer_SetDefault(); void FaultDrawer_SetDrawerFB(void*, u16, u16); void FaultDrawer_SetFontColor(u16); void FaultDrawer_SetForeColor(u16); +void FaultDrawer_SetInputCallback(void (*)()); void FaultDrawer_SetOsSyncPrintfEnabled(u32); void FaultDrawer_UpdatePrintColor(); void FaultDrawer_VPrintf(const char*, char*); -#else -s32 FaultDrawer_ColorToPrintColor(u16); -void FaultDrawer_DrawChar(char); -void FaultDrawer_DrawRecImpl(s32, s32, s32, s32, u16); -void FaultDrawer_DrawText(s32, s32, const char*, ...); -void FaultDrawer_FillScreen(void); -void* FaultDrawer_FormatStringFunc(void*, const char*, u32); -void FaultDrawer_Printf(const char*, ...); -void FaultDrawer_SetBackColor(u16); -void FaultDrawer_SetCharPad(s8, s8); -void FaultDrawer_SetCursor(s32, s32); -void FaultDrawer_SetDefault(void); -void FaultDrawer_SetDrawerFB(void*, u16, u16); -void FaultDrawer_SetFontColor(u16); -void FaultDrawer_SetForeColor(u16); -void FaultDrawer_SetOsSyncPrintfEnabled(u32); -void FaultDrawer_UpdatePrintColor(void); -void FaultDrawer_VPrintf(const char*, char*); -#endif diff --git a/include/def/flg_set.h b/include/def/flg_set.h index a9ae98a75..4e2ef6c4a 100644 --- a/include/def/flg_set.h +++ b/include/def/flg_set.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_FLG_SET_C +struct GlobalContext; + void FlagSet_Update(GlobalContext* globalCtx); -#else -void FlagSet_Update(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/game.h b/include/def/game.h index 37c1d4185..ec76eae72 100644 --- a/include/def/game.h +++ b/include/def/game.h @@ -1,11 +1,14 @@ #pragma once +struct GameState; +struct GraphicsContext; +struct OSViMode; extern u32 gViConfigFeatures; extern f32 gViConfigXScale; extern f32 gViConfigYScale; +extern OSViMode osViModeNtscLan1; -#ifdef INTERNAL_SRC_CODE_GAME_C -void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line); +void* GameState_Alloc(GameState* gameState, size_t size, const char* file, s32 line); void GameState_Destroy(GameState* gameState); void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx); void GameState_DrawInputDisplay(u16 input, Gfx** gfx); @@ -19,19 +22,3 @@ void GameState_ReqPadData(GameState* gameState); void GameState_SetFBFilter(Gfx** gfx); void GameState_SetFrameBuffer(GraphicsContext* gfxCtx); void GameState_Update(GameState* gameState); -#else -void* GameState_Alloc(struct GameState* gameState, size_t size, char* file, s32 line); -void GameState_Destroy(struct GameState* gameState); -void GameState_Draw(struct GameState* gameState, struct GraphicsContext* gfxCtx); -void GameState_DrawInputDisplay(u16 input, Gfx** gfx); -void GameState_FaultPrint(void); -GameStateFunc GameState_GetInit(struct GameState* gameState); -void GameState_Init(struct GameState* gameState, GameStateFunc init, struct GraphicsContext* gfxCtx); -void GameState_InitArena(struct GameState* gameState, size_t size); -u32 GameState_IsRunning(struct GameState* gameState); -void GameState_Realloc(struct GameState* gameState, size_t size); -void GameState_ReqPadData(struct GameState* gameState); -void GameState_SetFBFilter(Gfx** gfx); -void GameState_SetFrameBuffer(struct GraphicsContext* gfxCtx); -void GameState_Update(struct GameState* gameState); -#endif diff --git a/include/def/gamealloc.h b/include/def/gamealloc.h index e2608320d..4609acda0 100644 --- a/include/def/gamealloc.h +++ b/include/def/gamealloc.h @@ -1,14 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_GAMEALLOC_C -void GameAlloc_Cleanup(GameAlloc* this); -void GameAlloc_Free(GameAlloc* this, void* data); -void GameAlloc_Init(GameAlloc* this); -void* GameAlloc_Malloc(GameAlloc* this, u32 size); -void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line); -#else -void GameAlloc_Cleanup(struct GameAlloc* this); -void GameAlloc_Free(struct GameAlloc* this, void* data); -void GameAlloc_Init(struct GameAlloc* this); -void* GameAlloc_Malloc(struct GameAlloc* this, u32 size); -void* GameAlloc_MallocDebug(struct GameAlloc* this, u32 size, const char* file, s32 line); -#endif +struct GameAlloc; + +void GameAlloc_Cleanup(GameAlloc* pthis); +void GameAlloc_Free(GameAlloc* pthis, void* data); +void GameAlloc_Init(GameAlloc* pthis); +void* GameAlloc_Malloc(GameAlloc* pthis, u32 size); +void* GameAlloc_MallocDebug(GameAlloc* pthis, u32 size, const char* file, s32 line); diff --git a/include/def/gfxbuffers.h b/include/def/gfxbuffers.h index d6d209669..351e00791 100644 --- a/include/def/gfxbuffers.h +++ b/include/def/gfxbuffers.h @@ -1,4 +1,5 @@ #pragma once +struct GfxPool; extern GfxPool gGfxPools[2]; extern u64 gGfxSPTaskOutputBuffer[0x3000]; diff --git a/include/def/gfxprint.h b/include/def/gfxprint.h index d1b8596bf..8f5d64494 100644 --- a/include/def/gfxprint.h +++ b/include/def/gfxprint.h @@ -1,22 +1,12 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_GFXPRINT_C -Gfx* GfxPrint_Close(GfxPrint* this); -void GfxPrint_Destroy(GfxPrint* this); -void GfxPrint_Init(GfxPrint* this); -void GfxPrint_Open(GfxPrint* this, Gfx* dList); -s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...); -void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y); -void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a); -void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y); -void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y); -#else -Gfx* GfxPrint_Close(struct GfxPrint* this); -void GfxPrint_Destroy(struct GfxPrint* this); -void GfxPrint_Init(struct GfxPrint* this); -void GfxPrint_Open(struct GfxPrint* this, Gfx* dList); -s32 GfxPrint_Printf(struct GfxPrint* this, const char* fmt, ...); -void GfxPrint_SetBasePosPx(struct GfxPrint* this, s32 x, s32 y); -void GfxPrint_SetColor(struct GfxPrint* this, u32 r, u32 g, u32 b, u32 a); -void GfxPrint_SetPos(struct GfxPrint* this, s32 x, s32 y); -void GfxPrint_SetPosPx(struct GfxPrint* this, s32 x, s32 y); -#endif +struct GfxPrint; + +Gfx* GfxPrint_Close(GfxPrint* pthis); +void GfxPrint_Destroy(GfxPrint* pthis); +void GfxPrint_Init(GfxPrint* pthis); +void GfxPrint_Open(GfxPrint* pthis, Gfx* dList); +s32 GfxPrint_Printf(GfxPrint* pthis, const char* fmt, ...); +void GfxPrint_SetBasePosPx(GfxPrint* pthis, s32 x, s32 y); +void GfxPrint_SetColor(GfxPrint* pthis, u32 r, u32 g, u32 b, u32 a); +void GfxPrint_SetPos(GfxPrint* pthis, s32 x, s32 y); +void GfxPrint_SetPosPx(GfxPrint* pthis, s32 x, s32 y); diff --git a/include/def/graph.h b/include/def/graph.h index 31403b387..9d095cb42 100644 --- a/include/def/graph.h +++ b/include/def/graph.h @@ -1,5 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_GRAPH_C +struct GraphicsContext; +struct GameState; +struct GameStateOverlay; + void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size); void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size); Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); @@ -16,21 +19,3 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx); void Graph_ThreadEntry(void*); void Graph_UCodeFaultClient(Gfx* workBuf); void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState); -#else -void* Graph_Alloc(struct GraphicsContext* gfxCtx, size_t size); -void* Graph_Alloc2(struct GraphicsContext* gfxCtx, size_t size); -Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); -void Graph_CloseDisps(Gfx** dispRefs, struct GraphicsContext* gfxCtx, const char* file, s32 line); -void Graph_Destroy(struct GraphicsContext* gfxCtx); -void Graph_DisassembleUCode(Gfx* workBuf); -void* Graph_DlistAlloc(Gfx** gfx, u32 size); -struct GameStateOverlay* Graph_GetNextGameState(struct GameState* gameState); -Gfx* Graph_GfxPlusOne(Gfx* gfx); -void Graph_Init(struct GraphicsContext* gfxCtx); -void Graph_InitTHGA(struct GraphicsContext* gfxCtx); -void Graph_OpenDisps(Gfx** dispRefs, struct GraphicsContext* gfxCtx, const char* file, s32 line); -void Graph_TaskSet00(struct GraphicsContext* gfxCtx); -void Graph_ThreadEntry(void*); -void Graph_UCodeFaultClient(Gfx* workBuf); -void Graph_Update(struct GraphicsContext* gfxCtx, struct GameState* gameState); -#endif diff --git a/include/def/idle.h b/include/def/idle.h index 5828b0acb..5a0bf2aa2 100644 --- a/include/def/idle.h +++ b/include/def/idle.h @@ -1,4 +1,6 @@ #pragma once +struct OSMesgQueue; +struct OSViMode; extern s8 D_80009430; extern u8 D_80013960; @@ -10,10 +12,5 @@ extern vu8 gViConfigUseDefault; extern f32 gViConfigXScale; extern f32 gViConfigYScale; -#ifdef INTERNAL_SRC_BOOT_IDLE_C void Idle_ThreadEntry(void* arg); void Main_ThreadEntry(void* arg); -#else -void Idle_ThreadEntry(void* arg); -void Main_ThreadEntry(void* arg); -#endif diff --git a/include/def/irqmgr.h b/include/def/irqmgr.h index 2ce9a12ae..05b9014bf 100644 --- a/include/def/irqmgr.h +++ b/include/def/irqmgr.h @@ -1,32 +1,20 @@ #pragma once +struct IrqMgr; +struct IrqMgrClient; +struct OSMesgQueue; extern vu32 gIrqMgrResetStatus; extern volatile OSTime gIrqMgrRetraceTime; -#ifdef INTERNAL_SRC_CODE_IRQMGR_C -void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ); +void IrqMgr_AddClient(IrqMgr* pthis, IrqMgrClient* c, OSMesgQueue* msgQ); void IrqMgr_CheckStack(); -void IrqMgr_HandlePRENMI450(IrqMgr* this); -void IrqMgr_HandlePRENMI480(IrqMgr* this); -void IrqMgr_HandlePRENMI500(IrqMgr* this); -void IrqMgr_HandlePreNMI(IrqMgr* this); -void IrqMgr_HandleRetrace(IrqMgr* this); -void IrqMgr_Init(IrqMgr* this, void* stack, OSPri pri, u8 retraceCount); -void IrqMgr_JamMesgForClient(IrqMgr* this, OSMesg msg); -void IrqMgr_RemoveClient(IrqMgr* this, IrqMgrClient* c); -void IrqMgr_SendMesgForClient(IrqMgr* this, OSMesg msg); +void IrqMgr_HandlePRENMI450(IrqMgr* pthis); +void IrqMgr_HandlePRENMI480(IrqMgr* pthis); +void IrqMgr_HandlePRENMI500(IrqMgr* pthis); +void IrqMgr_HandlePreNMI(IrqMgr* pthis); +void IrqMgr_HandleRetrace(IrqMgr* pthis); +void IrqMgr_Init(IrqMgr* pthis, void* stack, OSPri pri, u8 retraceCount); +void IrqMgr_JamMesgForClient(IrqMgr* pthis, OSMesg msg); +void IrqMgr_RemoveClient(IrqMgr* pthis, IrqMgrClient* c); +void IrqMgr_SendMesgForClient(IrqMgr* pthis, OSMesg msg); void IrqMgr_ThreadEntry(void* arg0); -#else -void IrqMgr_AddClient(struct IrqMgr* this, struct IrqMgrClient* c, struct OSMesgQueue* msgQ); -void IrqMgr_CheckStack(void); -void IrqMgr_HandlePRENMI450(struct IrqMgr* this); -void IrqMgr_HandlePRENMI480(struct IrqMgr* this); -void IrqMgr_HandlePRENMI500(struct IrqMgr* this); -void IrqMgr_HandlePreNMI(struct IrqMgr* this); -void IrqMgr_HandleRetrace(struct IrqMgr* this); -void IrqMgr_Init(struct IrqMgr* this, void* stack, OSPri pri, u8 retraceCount); -void IrqMgr_JamMesgForClient(struct IrqMgr* this, OSMesg msg); -void IrqMgr_RemoveClient(struct IrqMgr* this, struct IrqMgrClient* c); -void IrqMgr_SendMesgForClient(struct IrqMgr* this, OSMesg msg); -void IrqMgr_ThreadEntry(void* arg0); -#endif diff --git a/include/def/jpegdecoder.h b/include/def/jpegdecoder.h index 5b64e32b2..03323c49b 100644 --- a/include/def/jpegdecoder.h +++ b/include/def/jpegdecoder.h @@ -1,12 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_JPEGDECODER_C +struct JpegDecoder; +struct JpegDecoderState; +struct JpegHuffmanTable; + s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state); s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount); s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk); u16 JpegDecoder_ReadBits(u8 len); -#else -s32 JpegDecoder_Decode(struct JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, struct JpegDecoderState* state); -s32 JpegDecoder_ParseNextSymbol(struct JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount); -s32 JpegDecoder_ProcessMcu(struct JpegHuffmanTable* hTable0, struct JpegHuffmanTable* hTable1, u16* mcu, s16* unk); -u16 JpegDecoder_ReadBits(u8 len); -#endif diff --git a/include/def/jpegutils.h b/include/def/jpegutils.h index d6d847814..afe8b3f2e 100644 --- a/include/def/jpegutils.h +++ b/include/def/jpegutils.h @@ -1,5 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_JPEGUTILS_C +struct JpegHuffmanTable; +struct JpegHuffmanTableOld; +struct JpegQuantizationTable; + s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes); s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths); u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count); @@ -8,13 +11,3 @@ u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* c void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count); s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes); void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc); -#else -s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes); -s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths); -u32 JpegUtils_ProcessHuffmanTable(u8* dht, struct JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count); -u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, struct JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc); -u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, struct JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes); -void JpegUtils_ProcessQuantizationTable(u8* dqt, struct JpegQuantizationTable* qt, u8 count); -s32 JpegUtils_SetHuffmanTable(u8* data, struct JpegHuffmanTable* ht, u16* codes); -void JpegUtils_SetHuffmanTableOld(u8* data, struct JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc); -#endif diff --git a/include/def/listalloc.h b/include/def/listalloc.h index 5945a1741..0af1e7771 100644 --- a/include/def/listalloc.h +++ b/include/def/listalloc.h @@ -1,12 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_LISTALLOC_C -void* ListAlloc_Alloc(ListAlloc* this, u32 size); -void ListAlloc_Free(ListAlloc* this, void* data); -void ListAlloc_FreeAll(ListAlloc* this); -ListAlloc* ListAlloc_Init(ListAlloc* this); -#else -void* ListAlloc_Alloc(struct ListAlloc* this, u32 size); -void ListAlloc_Free(struct ListAlloc* this, void* data); -void ListAlloc_FreeAll(struct ListAlloc* this); -struct ListAlloc* ListAlloc_Init(struct ListAlloc* this); -#endif +struct ListAlloc; + +void* ListAlloc_Alloc(ListAlloc* pthis, u32 size); +void ListAlloc_Free(ListAlloc* pthis, void* data); +void ListAlloc_FreeAll(ListAlloc* pthis); +ListAlloc* ListAlloc_Init(ListAlloc* pthis); diff --git a/include/def/logutils.h b/include/def/logutils.h index a95a597f3..4071f46e2 100644 --- a/include/def/logutils.h +++ b/include/def/logutils.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_BOOT_LOGUTILS_C + void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* file, s32 line); f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min, const char* maxName, f32 max); s32 LogUtils_CheckIntRange(const char* exp, s32 line, const char* valueName, s32 value, const char* minName, s32 min, const char* maxName, s32 max); @@ -10,15 +10,3 @@ void LogUtils_LogHexDump(void* ptr, s32 size0); void LogUtils_LogPointer(s32 value, u32 max, void* ptr, const char* name, const char* file, s32 line); void LogUtils_LogThreadId(const char* name, s32 line); void LogUtils_ResetHungup(void); -#else -void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* file, s32 line); -f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min, const char* maxName, f32 max); -s32 LogUtils_CheckIntRange(const char* exp, s32 line, const char* valueName, s32 value, const char* minName, s32 min, const char* maxName, s32 max); -void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, s32 line); -void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, s32 line); -void LogUtils_HungupThread(const char* name, s32 line); -void LogUtils_LogHexDump(void* ptr, s32 size0); -void LogUtils_LogPointer(s32 value, u32 max, void* ptr, const char* name, const char* file, s32 line); -void LogUtils_LogThreadId(const char* name, s32 line); -void LogUtils_ResetHungup(void); -#endif diff --git a/include/def/lookat.h b/include/def/lookat.h index 9d478ae5f..fa9b494da 100644 --- a/include/def/lookat.h +++ b/include/def/lookat.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_LOOKAT_C + void guLookAt(Mtx*, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); void guLookAtF(f32 mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); -#else -void guLookAt(struct Mtx*, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); -void guLookAtF(f32 mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); -#endif diff --git a/include/def/lookathil.h b/include/def/lookathil.h index c0555c97b..dc6a80abc 100644 --- a/include/def/lookathil.h +++ b/include/def/lookathil.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_LOOKATHIL_C +struct LookAt; + void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); -#else -void guLookAtHilite(struct Mtx* m, struct LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); -void guLookAtHiliteF(f32 mf[4][4], struct LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); -#endif diff --git a/include/def/mempak.h b/include/def/mempak.h index 24fb9312c..5b6584f79 100644 --- a/include/def/mempak.h +++ b/include/def/mempak.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_MEMPAK_C + s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size); s32 Mempak_DeleteFile(s32 controllerNb, char idx); s32 Mempak_FindFile(s32 controllerNb, char start, char end); @@ -8,13 +8,3 @@ s32 Mempak_GetFreeBytes(s32 controllerNb); s32 Mempak_Init(s32 controllerNb); s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size); s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size); -#else -s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size); -s32 Mempak_DeleteFile(s32 controllerNb, char idx); -s32 Mempak_FindFile(s32 controllerNb, char start, char end); -s32 Mempak_GetFileSize(s32 controllerNb, char idx); -s32 Mempak_GetFreeBytes(s32 controllerNb); -s32 Mempak_Init(s32 controllerNb); -s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size); -s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size); -#endif diff --git a/include/def/mtxf2l.h b/include/def/mtxf2l.h index a94b4b12a..dbf7845e0 100644 --- a/include/def/mtxf2l.h +++ b/include/def/mtxf2l.h @@ -1,12 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_MTXF2L_C + void guMtxF2L(MtxF* m1, Mtx* m2); void guMtxIdent(Mtx*); void guMtxIdentF(f32 mf[4][4]); void guMtxL2F(MtxF* m1, Mtx* m2); -#else -void guMtxF2L(MtxF* m1, struct Mtx* m2); -void guMtxIdent(struct Mtx*); -void guMtxIdentF(f32 mf[4][4]); -void guMtxL2F(MtxF* m1, struct Mtx* m2); -#endif diff --git a/include/def/mtxuty-cvt.h b/include/def/mtxuty-cvt.h index e8666c523..eeeaee132 100644 --- a/include/def/mtxuty-cvt.h +++ b/include/def/mtxuty-cvt.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_MTXUTY_CVT_C + void MtxConv_F2L(Mtx* m1, MtxF* m2); -#else -void MtxConv_F2L(struct Mtx* m1, MtxF* m2); -#endif diff --git a/include/def/normalize.h b/include/def/normalize.h index d79d3ab80..7cc74d1ed 100644 --- a/include/def/normalize.h +++ b/include/def/normalize.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_NORMALIZE_C + void guNormalize(f32* x, f32* y, f32* z); -#else -void guNormalize(f32* x, f32* y, f32* z); -#endif diff --git a/include/def/ortho.h b/include/def/ortho.h index a91ce7e12..8a0867394 100644 --- a/include/def/ortho.h +++ b/include/def/ortho.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_ORTHO_C + void guOrtho(Mtx*, f32, f32, f32, f32, f32, f32, f32); void guOrthoF(f32[4][4], f32, f32, f32, f32, f32, f32, f32); -#else -void guOrtho(struct Mtx*, f32, f32, f32, f32, f32, f32, f32); -void guOrthoF(f32[4][4], f32, f32, f32, f32, f32, f32, f32); -#endif diff --git a/include/def/padmgr.h b/include/def/padmgr.h index 61cd8ded4..5b3cb3285 100644 --- a/include/def/padmgr.h +++ b/include/def/padmgr.h @@ -1,5 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_PADMGR_C +struct PadMgr; +struct OSMesgQueue; +struct IrqMgr; + void PadMgr_HandlePreNMI(PadMgr* padmgr); void PadMgr_HandleRetraceMsg(PadMgr* padmgr); void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* siIntMsgQ, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack); @@ -12,17 +15,3 @@ void PadMgr_RumbleSet(PadMgr* padmgr, u8* ctrlrRumbles); void PadMgr_RumbleStop(PadMgr* padmgr); void PadMgr_UnlockPadData(PadMgr* padmgr); void PadMgr_UnlockSerialMesgQueue(PadMgr* padmgr, OSMesgQueue* ctrlrqueue); -#else -void PadMgr_HandlePreNMI(struct PadMgr* padmgr); -void PadMgr_HandleRetraceMsg(struct PadMgr* padmgr); -void PadMgr_Init(struct PadMgr* padmgr, struct OSMesgQueue* siIntMsgQ, struct IrqMgr* irqMgr, OSId id, OSPri priority, void* stack); -void PadMgr_LockPadData(struct PadMgr* padmgr); -struct OSMesgQueue* PadMgr_LockSerialMesgQueue(struct PadMgr* padmgr); -void PadMgr_ProcessInputs(struct PadMgr* padmgr); -void PadMgr_RumbleControl(struct PadMgr* padmgr); -void PadMgr_RumbleReset(struct PadMgr* padmgr); -void PadMgr_RumbleSet(struct PadMgr* padmgr, u8* ctrlrRumbles); -void PadMgr_RumbleStop(struct PadMgr* padmgr); -void PadMgr_UnlockPadData(struct PadMgr* padmgr); -void PadMgr_UnlockSerialMesgQueue(struct PadMgr* padmgr, struct OSMesgQueue* ctrlrqueue); -#endif diff --git a/include/def/padsetup.h b/include/def/padsetup.h index 0758092e3..f33a9c596 100644 --- a/include/def/padsetup.h +++ b/include/def/padsetup.h @@ -1,6 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_PADSETUP_C +struct OSMesgQueue; +struct OSContStatus; + s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); -#else -s32 PadSetup_Init(struct OSMesgQueue* mq, u8* outMask, struct OSContStatus* status); -#endif diff --git a/include/def/padutils.h b/include/def/padutils.h index 203b2f704..4b70ebe6f 100644 --- a/include/def/padutils.h +++ b/include/def/padutils.h @@ -1,5 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_PADUTILS_C +struct Input; + u32 PadUtils_CheckCur(Input* input, u16 key); u32 PadUtils_CheckCurExact(Input* input, u16 value); u32 PadUtils_CheckPressed(Input* input, u16 key); @@ -17,22 +18,3 @@ void PadUtils_ResetPressRel(Input* input); void PadUtils_SetRelXY(Input* input, s32 x, s32 y); void PadUtils_UpdateRelXY(Input* input); void func_800FCB70(void); -#else -u32 PadUtils_CheckCur(struct Input* input, u16 key); -u32 PadUtils_CheckCurExact(struct Input* input, u16 value); -u32 PadUtils_CheckPressed(struct Input* input, u16 key); -u32 PadUtils_CheckReleased(struct Input* input, u16 key); -u16 PadUtils_GetCurButton(struct Input* input); -s8 PadUtils_GetCurX(struct Input* input); -s8 PadUtils_GetCurY(struct Input* input); -u16 PadUtils_GetPressButton(struct Input* input); -s8 PadUtils_GetRelX(struct Input* input); -s8 PadUtils_GetRelXImpl(struct Input* input); -s8 PadUtils_GetRelY(struct Input* input); -s8 PadUtils_GetRelYImpl(struct Input* input); -void PadUtils_Init(struct Input* input); -void PadUtils_ResetPressRel(struct Input* input); -void PadUtils_SetRelXY(struct Input* input, s32 x, s32 y); -void PadUtils_UpdateRelXY(struct Input* input); -void func_800FCB70(void); -#endif diff --git a/include/def/perspective.h b/include/def/perspective.h index f1785fc36..8d767747f 100644 --- a/include/def/perspective.h +++ b/include/def/perspective.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_PERSPECTIVE_C + void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); -#else -void guPerspective(struct Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); -void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); -#endif diff --git a/include/def/pfsallocatefile.h b/include/def/pfsallocatefile.h index 7afe301a4..42e16e0d3 100644 --- a/include/def/pfsallocatefile.h +++ b/include/def/pfsallocatefile.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSALLOCATEFILE_C +struct OSPfs; +struct __OSInode; + s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage); s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 length, s32* fileNo); -#else -s32 __osPfsDeclearPage(struct OSPfs* pfs, struct __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage); -s32 osPfsAllocateFile(struct OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 length, s32* fileNo); -#endif diff --git a/include/def/pfschecker.h b/include/def/pfschecker.h index eff4324ca..63a41b312 100644 --- a/include/def/pfschecker.h +++ b/include/def/pfschecker.h @@ -1,10 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSCHECKER_C +struct OSPfs; +struct __OSInodeCache; + s32 func_80105788(OSPfs* pfs, __OSInodeCache* cache); s32 func_80105A60(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache); s32 osPfsChecker(OSPfs* pfs); -#else -s32 func_80105788(struct OSPfs* pfs, struct __OSInodeCache* cache); -s32 func_80105A60(struct OSPfs* pfs, __OSInodeUnit fpage, struct __OSInodeCache* cache); -s32 osPfsChecker(struct OSPfs* pfs); -#endif diff --git a/include/def/pfsdeletefile.h b/include/def/pfsdeletefile.h index 2de719d68..a9403a395 100644 --- a/include/def/pfsdeletefile.h +++ b/include/def/pfsdeletefile.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSDELETEFILE_C +struct OSPfs; +struct __OSInode; + s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 initialPage, u8 bank, __OSInodeUnit* finalPage); s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName); -#else -s32 __osPfsReleasePages(struct OSPfs* pfs, struct __OSInode* inode, u8 initialPage, u8 bank, __OSInodeUnit* finalPage); -s32 osPfsDeleteFile(struct OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName); -#endif diff --git a/include/def/pfsfilestate.h b/include/def/pfsfilestate.h index 9f9b7731c..3dbf5dafe 100644 --- a/include/def/pfsfilestate.h +++ b/include/def/pfsfilestate.h @@ -1,6 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSFILESTATE_C +struct OSPfs; +struct OSPfsState; + s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state); -#else -s32 osPfsFileState(struct OSPfs* pfs, s32 fileNo, struct OSPfsState* state); -#endif diff --git a/include/def/pfsfindfile.h b/include/def/pfsfindfile.h index c90d7b740..7e342cdea 100644 --- a/include/def/pfsfindfile.h +++ b/include/def/pfsfindfile.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSFINDFILE_C +struct OSPfs; + s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo); -#else -s32 osPfsFindFile(struct OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo); -#endif diff --git a/include/def/pfsfreeblocks.h b/include/def/pfsfreeblocks.h index ce204fea9..b4a9dc559 100644 --- a/include/def/pfsfreeblocks.h +++ b/include/def/pfsfreeblocks.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSFREEBLOCKS_C +struct OSPfs; + s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); -#else -s32 osPfsFreeBlocks(struct OSPfs* pfs, s32* leftoverBytes); -#endif diff --git a/include/def/pfsgetstatus.h b/include/def/pfsgetstatus.h index 9a8cf35d6..68d53ec26 100644 --- a/include/def/pfsgetstatus.h +++ b/include/def/pfsgetstatus.h @@ -1,13 +1,10 @@ #pragma once +struct OSContStatus; +struct OSMesgQueue; +struct OSPifRam; extern OSPifRam gPifMempakBuf; -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSGETSTATUS_C void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData); s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel); void __osPfsRequestOneChannel(s32 channel, u8 poll); -#else -void __osPfsGetOneChannelData(s32 channel, struct OSContStatus* contData); -s32 __osPfsGetStatus(struct OSMesgQueue* queue, s32 channel); -void __osPfsRequestOneChannel(s32 channel, u8 poll); -#endif diff --git a/include/def/pfsinitpak.h b/include/def/pfsinitpak.h index 890592d38..fd49f5538 100644 --- a/include/def/pfsinitpak.h +++ b/include/def/pfsinitpak.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSINITPAK_C +struct OSPfs; +struct OSMesgQueue; + s32 __osPfsCheckRamArea(OSPfs* pfs); s32 osPfsInitPak(OSMesgQueue* mq, OSPfs* pfs, s32 channel); -#else -s32 __osPfsCheckRamArea(struct OSPfs* pfs); -s32 osPfsInitPak(struct OSMesgQueue* mq, struct OSPfs* pfs, s32 channel); -#endif diff --git a/include/def/pfsisplug.h b/include/def/pfsisplug.h index 7f358c582..9ad8a66c3 100644 --- a/include/def/pfsisplug.h +++ b/include/def/pfsisplug.h @@ -1,10 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSISPLUG_C +struct OSContStatus; +struct OSMesgQueue; + void __osPfsGetInitData(u8* pattern, OSContStatus* contData); void __osPfsRequestData(u8 poll); s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern); -#else -void __osPfsGetInitData(u8* pattern, struct OSContStatus* contData); -void __osPfsRequestData(u8 poll); -s32 osPfsIsPlug(struct OSMesgQueue* mq, u8* pattern); -#endif diff --git a/include/def/pfsreadwritefile.h b/include/def/pfsreadwritefile.h index 4351a2263..988fa3f06 100644 --- a/include/def/pfsreadwritefile.h +++ b/include/def/pfsreadwritefile.h @@ -1,11 +1,8 @@ #pragma once +struct OSPfs; +struct __OSInode; extern __OSInode __osPfsInodeCache; -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSREADWRITEFILE_C s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page); s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data); -#else -s32 __osPfsGetNextPage(struct OSPfs* pfs, u8* bank, struct __OSInode* inode, __OSInodeUnit* page); -s32 osPfsReadWriteFile(struct OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data); -#endif diff --git a/include/def/pfsselectbank.h b/include/def/pfsselectbank.h index b465e8e09..337ea8fd3 100644 --- a/include/def/pfsselectbank.h +++ b/include/def/pfsselectbank.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PFSSELECTBANK_C +struct OSPfs; + s32 __osPfsSelectBank(OSPfs* pfs, u8 bank); -#else -s32 __osPfsSelectBank(struct OSPfs* pfs, u8 bank); -#endif diff --git a/include/def/piacs.h b/include/def/piacs.h index 14bbcde54..2898279c2 100644 --- a/include/def/piacs.h +++ b/include/def/piacs.h @@ -1,14 +1,9 @@ #pragma once +struct OSMesgQueue; extern OSMesgQueue __osPiAccessQueue; extern u32 __osPiAccessQueueEnabled; -#ifdef INTERNAL_SRC_LIBULTRA_IO_PIACS_C void __osPiCreateAccessQueue(void); void __osPiGetAccess(void); void __osPiRelAccess(void); -#else -void __osPiCreateAccessQueue(void); -void __osPiGetAccess(void); -void __osPiRelAccess(void); -#endif diff --git a/include/def/pigetcmdq.h b/include/def/pigetcmdq.h index ce0940829..e81c33506 100644 --- a/include/def/pigetcmdq.h +++ b/include/def/pigetcmdq.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PIGETCMDQ_C +struct OSMesgQueue; + OSMesgQueue* osPiGetCmdQueue(void); -#else -struct OSMesgQueue* osPiGetCmdQueue(void); -#endif diff --git a/include/def/pimgr.h b/include/def/pimgr.h index b233811f7..6755b9008 100644 --- a/include/def/pimgr.h +++ b/include/def/pimgr.h @@ -1,12 +1,10 @@ #pragma once +struct OSMesgQueue; +struct OSPiHandle; extern OSPiHandle __Dom1SpeedParam; extern OSPiHandle __Dom2SpeedParam; extern OSPiHandle* __osCurrentHandle[]; extern OSPiHandle* __osPiTable; -#ifdef INTERNAL_SRC_LIBULTRA_IO_PIMGR_C void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt); -#else -void osCreatePiManager(OSPri pri, struct OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt); -#endif diff --git a/include/def/pirawdma.h b/include/def/pirawdma.h index 8beea17ef..44ac10751 100644 --- a/include/def/pirawdma.h +++ b/include/def/pirawdma.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_PIRAWDMA_C + s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size); -#else -s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size); -#endif diff --git a/include/def/position.h b/include/def/position.h index 00559eb44..ba801e7bb 100644 --- a/include/def/position.h +++ b/include/def/position.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_POSITION_C + void guPosition(Mtx*, f32, f32, f32, f32, f32, f32, f32); void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); -#else -void guPosition(struct Mtx*, f32, f32, f32, f32, f32, f32, f32); -void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); -#endif diff --git a/include/def/printutils.h b/include/def/printutils.h index f3da8e9a4..730fcb8ca 100644 --- a/include/def/printutils.h +++ b/include/def/printutils.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_PRINTUTILS_C + s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); -#else -s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); -s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); -#endif diff --git a/include/def/rotate.h b/include/def/rotate.h index c423594d7..00a9381de 100644 --- a/include/def/rotate.h +++ b/include/def/rotate.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_ROTATE_C + void guRotate(Mtx*, f32 angle, f32 x, f32 y, f32 z); void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z); -#else -void guRotate(struct Mtx*, f32 angle, f32 x, f32 y, f32 z); -void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z); -#endif diff --git a/include/def/scale.h b/include/def/scale.h index 1526d761c..3ab4633c5 100644 --- a/include/def/scale.h +++ b/include/def/scale.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_SCALE_C + void guScale(Mtx* m, f32 x, f32 y, f32 z); -#else -void guScale(struct Mtx* m, f32 x, f32 y, f32 z); -#endif diff --git a/include/def/sched.h b/include/def/sched.h index 68374f8a9..df3808900 100644 --- a/include/def/sched.h +++ b/include/def/sched.h @@ -1,5 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SCHED_C +struct SchedContext; +struct IrqMgr; +struct OSScTask; +struct CfbInfo; + void Sched_HandleEntry(SchedContext* sc); void Sched_HandleRDPDone(SchedContext* sc); void Sched_HandleRSPDone(SchedContext* sc); @@ -18,23 +22,3 @@ void Sched_Yield(SchedContext* sc); void func_800C84E4(SchedContext* sc, CfbInfo* cfbInfo); OSScTask* func_800C89D4(SchedContext* sc, OSScTask* task); void func_800C8BC4(SchedContext* sc, OSScTask* task); -#else -void Sched_HandleEntry(struct SchedContext* sc); -void Sched_HandleRDPDone(struct SchedContext* sc); -void Sched_HandleRSPDone(struct SchedContext* sc); -void Sched_HandleReset(struct SchedContext* sc); -void Sched_HandleRetrace(struct SchedContext* sc); -void Sched_HandleStart(struct SchedContext* sc); -void Sched_Init(struct SchedContext* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, struct IrqMgr* irqMgr); -u32 Sched_IsComplete(struct SchedContext* sc, struct OSScTask* task); -void Sched_QueueTask(struct SchedContext* sc, struct OSScTask* task); -void Sched_RunTask(struct SchedContext* sc, struct OSScTask* spTask, struct OSScTask* dpTask); -s32 Sched_Schedule(struct SchedContext* sc, struct OSScTask** sp, struct OSScTask** dp, s32 state); -void Sched_SendEntryMsg(struct SchedContext* sc); -void Sched_SwapFrameBuffer(struct CfbInfo* cfbInfo); -void Sched_ThreadEntry(void* arg); -void Sched_Yield(struct SchedContext* sc); -void func_800C84E4(struct SchedContext* sc, struct CfbInfo* cfbInfo); -struct OSScTask* func_800C89D4(struct SchedContext* sc, struct OSScTask* task); -void func_800C8BC4(struct SchedContext* sc, struct OSScTask* task); -#endif diff --git a/include/def/shrink_window.h b/include/def/shrink_window.h index 0bd381082..94e1036a9 100644 --- a/include/def/shrink_window.h +++ b/include/def/shrink_window.h @@ -1,5 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SHRINK_WINDOW_C + void ShrinkWindow_Destroy(void); u32 ShrinkWindow_GetCurrentVal(void); u32 ShrinkWindow_GetVal(void); @@ -7,12 +7,3 @@ void ShrinkWindow_Init(void); void ShrinkWindow_SetCurrentVal(s32 nowVal); void ShrinkWindow_SetVal(s32 value); void ShrinkWindow_Update(s32 updateRate); -#else -void ShrinkWindow_Destroy(void); -u32 ShrinkWindow_GetCurrentVal(void); -u32 ShrinkWindow_GetVal(void); -void ShrinkWindow_Init(void); -void ShrinkWindow_SetCurrentVal(s32 nowVal); -void ShrinkWindow_SetVal(s32 value); -void ShrinkWindow_Update(s32 updateRate); -#endif diff --git a/include/def/si.h b/include/def/si.h index 4f7fb1ee0..d9ed49285 100644 --- a/include/def/si.h +++ b/include/def/si.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SI_C + s32 __osSiDeviceBusy(void); -#else -s32 __osSiDeviceBusy(void); -#endif diff --git a/include/def/siacs.h b/include/def/siacs.h index 0345b231b..11b020436 100644 --- a/include/def/siacs.h +++ b/include/def/siacs.h @@ -1,10 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SIACS_C + void __osSiCreateAccessQueue(void); void __osSiGetAccess(void); void __osSiRelAccess(void); -#else -void __osSiCreateAccessQueue(void); -void __osSiGetAccess(void); -void __osSiRelAccess(void); -#endif diff --git a/include/def/sinf.h b/include/def/sinf.h index 7e9f07eec..e2dfd4541 100644 --- a/include/def/sinf.h +++ b/include/def/sinf.h @@ -1,6 +1,2 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_SINF_C -f32 sinf(f32); -#else -f32 sinf(f32); -#endif +#include diff --git a/include/def/sins.h b/include/def/sins.h index 4f429d018..312d97058 100644 --- a/include/def/sins.h +++ b/include/def/sins.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_SINS_C + s16 sins(u16); -#else -s16 sins(u16); -#endif diff --git a/include/def/sirawdma.h b/include/def/sirawdma.h index 2b5c32554..a9a990485 100644 --- a/include/def/sirawdma.h +++ b/include/def/sirawdma.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SIRAWDMA_C + s32 __osSiRawStartDma(s32 dir, void* addr); -#else -s32 __osSiRawStartDma(s32 dir, void* addr); -#endif diff --git a/include/def/sirawread.h b/include/def/sirawread.h index 02801735d..c2a795cb6 100644 --- a/include/def/sirawread.h +++ b/include/def/sirawread.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SIRAWREAD_C + s32 __osSiRawReadIo(void* devAddr, u32* dst); -#else -s32 __osSiRawReadIo(void* devAddr, u32* dst); -#endif diff --git a/include/def/sirawwrite.h b/include/def/sirawwrite.h index 217e984f5..2878423d4 100644 --- a/include/def/sirawwrite.h +++ b/include/def/sirawwrite.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SIRAWWRITE_C + s32 __osSiRawWriteIo(void* devAddr, u32 val); -#else -s32 __osSiRawWriteIo(void* devAddr, u32 val); -#endif diff --git a/include/def/sleep.h b/include/def/sleep.h index 136b6ae22..dca0c5a61 100644 --- a/include/def/sleep.h +++ b/include/def/sleep.h @@ -1,14 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SLEEP_C + void Sleep_Cycles(OSTime cycles); void Sleep_Msec(u32 ms); void Sleep_Nsec(u32 nsec); void Sleep_Sec(u32 sec); void Sleep_Usec(u32 usec); -#else -void Sleep_Cycles(OSTime cycles); -void Sleep_Msec(u32 ms); -void Sleep_Nsec(u32 nsec); -void Sleep_Sec(u32 sec); -void Sleep_Usec(u32 usec); -#endif diff --git a/include/def/sp.h b/include/def/sp.h index 329988b4a..e4a627c20 100644 --- a/include/def/sp.h +++ b/include/def/sp.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SP_C + u32 __osSpDeviceBusy(void); -#else -u32 __osSpDeviceBusy(void); -#endif diff --git a/include/def/speed_meter.h b/include/def/speed_meter.h index c8df40ab0..ca2ff9ddd 100644 --- a/include/def/speed_meter.h +++ b/include/def/speed_meter.h @@ -1,4 +1,8 @@ #pragma once +struct SpeedMeter; +struct GraphicsContext; +struct GameState; +struct SpeedMeterAllocEntry; extern volatile OSTime D_8016A520; extern volatile OSTime D_8016A528; @@ -13,20 +17,10 @@ extern volatile OSTime gRSPAudioTotalTime; extern volatile OSTime gRSPGFXTotalTime; extern volatile OSTime gRSPOtherTotalTime; -#ifdef INTERNAL_SRC_CODE_SPEED_METER_C -void SpeedMeter_Destroy(SpeedMeter* this); +void SpeedMeter_Destroy(SpeedMeter* pthis); void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, GameState* state); -void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxCtx); -void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx); -void SpeedMeter_Init(SpeedMeter* this); +void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* pthis, GraphicsContext* gfxCtx); +void SpeedMeter_DrawTimeEntries(SpeedMeter* pthis, GraphicsContext* gfxCtx); +void SpeedMeter_Init(SpeedMeter* pthis); void SpeedMeter_InitAllocEntry(SpeedMeterAllocEntry* entry, u32 maxval, u32 val, u16 backColor, u16 foreColor, u32 ulx, u32 lrx, u32 uly, u32 lry); -void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y); -#else -void SpeedMeter_Destroy(struct SpeedMeter* this); -void SpeedMeter_DrawAllocEntries(struct SpeedMeter* meter, struct GraphicsContext* gfxCtx, struct GameState* state); -void SpeedMeter_DrawAllocEntry(struct SpeedMeterAllocEntry* this, struct GraphicsContext* gfxCtx); -void SpeedMeter_DrawTimeEntries(struct SpeedMeter* this, struct GraphicsContext* gfxCtx); -void SpeedMeter_Init(struct SpeedMeter* this); -void SpeedMeter_InitAllocEntry(struct SpeedMeterAllocEntry* entry, u32 maxval, u32 val, u16 backColor, u16 foreColor, u32 ulx, u32 lrx, u32 uly, u32 lry); -void SpeedMeter_InitImpl(struct SpeedMeter* this, u32 arg1, u32 y); -#endif +void SpeedMeter_InitImpl(SpeedMeter* pthis, u32 arg1, u32 y); diff --git a/include/def/spgetstat.h b/include/def/spgetstat.h index 4ac275df9..cabe1fc6e 100644 --- a/include/def/spgetstat.h +++ b/include/def/spgetstat.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SPGETSTAT_C + u32 __osSpGetStatus(void); -#else -u32 __osSpGetStatus(void); -#endif diff --git a/include/def/sprawdma.h b/include/def/sprawdma.h index 70b28baa4..96fff75ca 100644 --- a/include/def/sprawdma.h +++ b/include/def/sprawdma.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SPRAWDMA_C + s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, u32 size); -#else -s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, u32 size); -#endif diff --git a/include/def/sprintf.h b/include/def/sprintf.h deleted file mode 100644 index 7cf7ad1d1..000000000 --- a/include/def/sprintf.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#ifdef INTERNAL_SRC_LIBULTRA_RMON_SPRINTF_C -s32 sprintf(char* dst, const char* fmt, ...); -s32 vsprintf(char* dst, const char* fmt, va_list args); -#else -s32 sprintf(char* dst, const char* fmt, ...); -s32 vsprintf(char* dst, const char* fmt, va_list args); -#endif diff --git a/include/def/spsetpc.h b/include/def/spsetpc.h index 7c235143e..89d868937 100644 --- a/include/def/spsetpc.h +++ b/include/def/spsetpc.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SPSETPC_C + s32 __osSpSetPc(void* pc); -#else -s32 __osSpSetPc(void* pc); -#endif diff --git a/include/def/spsetstat.h b/include/def/spsetstat.h index d94ecd860..1925b1788 100644 --- a/include/def/spsetstat.h +++ b/include/def/spsetstat.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SPSETSTAT_C + void __osSpSetStatus(u32 status); -#else -void __osSpSetStatus(u32 status); -#endif diff --git a/include/def/sptask.h b/include/def/sptask.h index 01055c214..c840eff2d 100644 --- a/include/def/sptask.h +++ b/include/def/sptask.h @@ -1,10 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SPTASK_C + OSTask* _VirtualToPhysicalTask(OSTask* intp); void osSpTaskLoad(OSTask* task); void osSpTaskStartGo(OSTask* task); -#else -OSTask* _VirtualToPhysicalTask(OSTask* intp); -void osSpTaskLoad(OSTask* task); -void osSpTaskStartGo(OSTask* task); -#endif diff --git a/include/def/sptaskyield.h b/include/def/sptaskyield.h index 7ed4d0a3c..ebd0e8337 100644 --- a/include/def/sptaskyield.h +++ b/include/def/sptaskyield.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_SPTASKYIELD_C + void osSpTaskYield(void); -#else -void osSpTaskYield(void); -#endif diff --git a/include/def/stackcheck.h b/include/def/stackcheck.h index eb5cadd55..e857d7011 100644 --- a/include/def/stackcheck.h +++ b/include/def/stackcheck.h @@ -1,14 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_BOOT_STACKCHECK_C +struct StackEntry; + u32 StackCheck_Check(StackEntry* entry); u32 StackCheck_CheckAll(void); void StackCheck_Cleanup(StackEntry* entry); StackStatus StackCheck_GetState(StackEntry* entry); void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 initValue, s32 minSpace, const char* name); -#else -u32 StackCheck_Check(struct StackEntry* entry); -u32 StackCheck_CheckAll(void); -void StackCheck_Cleanup(struct StackEntry* entry); -StackStatus StackCheck_GetState(struct StackEntry* entry); -void StackCheck_Init(struct StackEntry* entry, void* stackTop, void* stackBottom, u32 initValue, s32 minSpace, const char* name); -#endif diff --git a/include/def/sys_cfb.h b/include/def/sys_cfb.h index 2cf3cdec5..551dc6a53 100644 --- a/include/def/sys_cfb.h +++ b/include/def/sys_cfb.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SYS_CFB_C + void SysCfb_Init(s32 n64dd); -#else -void SysCfb_Init(s32 n64dd); -#endif diff --git a/include/def/sys_math.h b/include/def/sys_math.h index 4fc8f7901..63740c74d 100644 --- a/include/def/sys_math.h +++ b/include/def/sys_math.h @@ -1,14 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SYS_MATH_C + f32 Math_CosF(f32 angle); f32 Math_Factorial(s32 n); f32 Math_FactorialF(f32 n); f32 Math_PowF(f32 base, s32 exp); f32 Math_SinF(f32 angle); -#else -f32 Math_CosF(f32 angle); -f32 Math_Factorial(s32 n); -f32 Math_FactorialF(f32 n); -f32 Math_PowF(f32 base, s32 exp); -f32 Math_SinF(f32 angle); -#endif diff --git a/include/def/sys_math3d.h b/include/def/sys_math3d.h index 990058d62..f43efedb3 100644 --- a/include/def/sys_math3d.h +++ b/include/def/sys_math3d.h @@ -1,5 +1,11 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SYS_MATH3D_C +struct Vec3f; +struct Cylinder16; +struct TriNorm; +struct Linef; +struct Sphere16; +struct Plane; + f32 Math3D_Cos(Vec3f* a, Vec3f* b); s32 Math3D_CosOut(Vec3f* a, Vec3f* b, f32* dst); s32 Math3D_CylOutsideCyl(Cylinder16* ca, Cylinder16* cb, f32* deadSpace); @@ -54,59 +60,3 @@ f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b); s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z); s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); -#else -f32 Math3D_Cos(struct Vec3f* a, struct Vec3f* b); -s32 Math3D_CosOut(struct Vec3f* a, struct Vec3f* b, f32* dst); -s32 Math3D_CylOutsideCyl(struct Cylinder16* ca, struct Cylinder16* cb, f32* deadSpace); -s32 Math3D_CylOutsideCylDist(struct Cylinder16* ca, struct Cylinder16* cb, f32* deadSpace, f32* xzDist); -s32 Math3D_CylTriVsIntersect(struct Cylinder16* cyl, struct TriNorm* tri, struct Vec3f* intersect); -s32 Math3D_CylVsLineSeg(struct Cylinder16* cyl, struct Vec3f* linePointA, struct Vec3f* linePointB, struct Vec3f* intersectA, struct Vec3f* intersectB); -s32 Math3D_CylVsTri(struct Cylinder16* cyl, struct TriNorm* tri); -void Math3D_DefPlane(struct Vec3f* va, struct Vec3f* vb, struct Vec3f* vc, f32* nx, f32* ny, f32* nz, f32* originDist); -f32 Math3D_Dist1DSq(f32 a, f32 b); -f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1); -f32 Math3D_DistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, struct Vec3f* p); -void Math3D_LineClosestToPoint(struct Linef* line, struct Vec3f* pos, struct Vec3f* closestPoint); -s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, struct Vec3f* linePointA, struct Vec3f* linePointB, struct Vec3f* intersect, s32 fromFront); -void Math3D_LineSplitRatio(struct Vec3f* v0, struct Vec3f* v1, f32 ratio, struct Vec3f* ret); -s32 Math3D_LineVsCube(struct Vec3f* min, struct Vec3f* max, struct Vec3f* a, struct Vec3f* b); -s32 Math3D_LineVsSph(struct Sphere16* sphere, struct Linef* line); -s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, struct Vec3f* linePointA, struct Vec3f* linePointB, struct Vec3f* closestPoint); -s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, struct Vec3f* point, struct Vec3f* closestPoint); -s32 Math3D_PointDistToLine2D(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); -s32 Math3D_PointInSquare2D(f32 upperLeftX, f32 lowerRightX, f32 upperLeftY, f32 lowerRightY, f32 x, f32 y); -s32 Math3D_PointRelativeToCubeEdges(struct Vec3f* point, struct Vec3f* min, struct Vec3f* max); -s32 Math3D_PointRelativeToCubeFaces(struct Vec3f* point, struct Vec3f* min, struct Vec3f* max); -s32 Math3D_PointRelativeToCubeVertices(struct Vec3f* point, struct Vec3f* min, struct Vec3f* max); -void Math3D_RotateXZPlane(struct Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d); -s32 Math3D_SphVsCylOverlapCenterDist(struct Sphere16* sph, struct Cylinder16* cyl, f32* overlapSize, f32* centerDist); -s32 Math3D_SphVsCylOverlapDist(struct Sphere16* sph, struct Cylinder16* cyl, f32* overlapSize); -s32 Math3D_SphVsSph(struct Sphere16* sphereA, struct Sphere16* sphereB); -s32 Math3D_SphVsSphOverlap(struct Sphere16* sphereA, struct Sphere16* sphereB, f32* overlapSize); -s32 Math3D_SphVsSphOverlapCenter(struct Sphere16* sphereA, struct Sphere16* sphereB, f32* overlapSize, f32* centerDist); -void Math3D_SurfaceNorm(struct Vec3f* va, struct Vec3f* vb, struct Vec3f* vc, struct Vec3f* normal); -s32 Math3D_TriChkLineSegParaXIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect, f32 x0, f32 x1); -s32 Math3D_TriChkLineSegParaYIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 y0, f32 y1); -s32 Math3D_TriChkLineSegParaZDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, struct Plane* plane, f32 x, f32 y, f32 chkDist); -s32 Math3D_TriChkLineSegParaZIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1); -s32 Math3D_TriChkPointParaXDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, struct Plane* plane, f32 y, f32 z, f32 chkDist); -s32 Math3D_TriChkPointParaXIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect); -s32 Math3D_TriChkPointParaYDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, struct Plane* plane, f32 z, f32 x, f32 chkDist); -s32 Math3D_TriChkPointParaYIntersectDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); -s32 Math3D_TriChkPointParaYIntersectInsideTri(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); -s32 Math3D_TriChkPointParaYSlopedY(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 z, f32 x); -s32 Math3D_TriChkPointParaZIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect); -void Math3D_TriNorm(struct TriNorm* tri, struct Vec3f* va, struct Vec3f* vb, struct Vec3f* vc); -s32 Math3D_TriVsSphIntersect(struct Sphere16* sphere, struct TriNorm* tri, struct Vec3f* intersectPoint); -s32 Math3D_TriVsTriIntersect(struct TriNorm* ta, struct TriNorm* tb, struct Vec3f* intersect); -f32 Math3D_UDistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, struct Vec3f* p); -f32 Math3D_Vec3fDistSq(struct Vec3f* a, struct Vec3f* b); -f32 Math3D_Vec3fMagnitude(struct Vec3f* vec); -f32 Math3D_Vec3fMagnitudeSq(struct Vec3f* vec); -void Math3D_Vec3fReflect(struct Vec3f* vec, struct Vec3f* normal, struct Vec3f* reflVec); -void Math3D_Vec3f_Cross(struct Vec3f* a, struct Vec3f* b, struct Vec3f* ret); -f32 Math3D_Vec3f_DistXYZ(struct Vec3f* a, struct Vec3f* b); -s32 Math3D_XYInSphere(struct Sphere16* sphere, f32 x, f32 y); -s32 Math3D_XZInSphere(struct Sphere16* sphere, f32 x, f32 z); -s32 Math3D_YZInSphere(struct Sphere16* sphere, f32 y, f32 z); -#endif diff --git a/include/def/sys_math_atan.h b/include/def/sys_math_atan.h index 5d2b7fe21..a3f11370b 100644 --- a/include/def/sys_math_atan.h +++ b/include/def/sys_math_atan.h @@ -1,8 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SYS_MATH_ATAN_C + f32 Math_Atan2F(f32 x, f32 y); s16 Math_Atan2S(f32 x, f32 y); -#else -f32 Math_Atan2F(f32 x, f32 y); -s16 Math_Atan2S(f32 x, f32 y); -#endif diff --git a/include/def/sys_matrix.h b/include/def/sys_matrix.h index 8cee74b32..f9d38a037 100644 --- a/include/def/sys_matrix.h +++ b/include/def/sys_matrix.h @@ -1,9 +1,12 @@ #pragma once +struct GameState; +struct GraphicsContext; +struct Vec3s; +struct Vec3f; extern Mtx gMtxClear; extern MtxF gMtxFClear; -#ifdef INTERNAL_SRC_CODE_SYS_MATRIX_C MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line); void Matrix_Get(MtxF* dest); void Matrix_Init(GameState* gameState); @@ -16,7 +19,7 @@ void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); void Matrix_Mult(MtxF* mf, u8 mode); void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line); +Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, s32 line); void Matrix_Pop(void); void Matrix_Push(void); void Matrix_Put(MtxF* src); @@ -26,41 +29,10 @@ void Matrix_RotateY(f32 y, u8 mode); void Matrix_RotateZ(f32 z, u8 mode); void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode); -Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line); +void Matrix_ScaleTrans(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 posX, f32 posY, f32 posZ); +Mtx* Matrix_ToMtx(Mtx* dest, const char* file, s32 line); void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode); void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); void Matrix_Transpose(MtxF* mf); void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec); void func_800D1FD4(MtxF* mf); -void Matrix_ScaleTrans(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 posX, f32 posY, f32 posZ); -#else -MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line); -void Matrix_Get(MtxF* dest); -void Matrix_Init(struct GameState* gameState); -void Matrix_MtxFCopy(MtxF* dest, MtxF* src); -struct Mtx* Matrix_MtxFToMtx(MtxF* src, struct Mtx* dest); -struct Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx); -void Matrix_MtxFToYXZRotS(MtxF* mf, struct Vec3s* rotDest, s32 flag); -void Matrix_MtxFToZYXRotS(MtxF* mf, struct Vec3s* rotDest, s32 flag); -void Matrix_MtxToMtxF(struct Mtx* src, MtxF* dest); -void Matrix_Mult(MtxF* mf, u8 mode); -void Matrix_MultVec3f(struct Vec3f* src, struct Vec3f* dest); -void Matrix_MultVec3fExt(struct Vec3f* src, struct Vec3f* dest, MtxF* mf); -struct Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx, char* file, s32 line); -void Matrix_Pop(void); -void Matrix_Push(void); -void Matrix_Put(MtxF* src); -void Matrix_RotateAxis(f32 f, struct Vec3f* vec, u8 mode); -void Matrix_RotateX(f32 x, u8 mode); -void Matrix_RotateY(f32 y, u8 mode); -void Matrix_RotateZ(f32 z, u8 mode); -void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); -void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode); -struct Mtx* Matrix_ToMtx(struct Mtx* dest, char* file, s32 line); -void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode); -void Matrix_TranslateRotateZYX(struct Vec3f* translation, struct Vec3s* rotation); -void Matrix_Transpose(MtxF* mf); -void func_800D1694(f32 x, f32 y, f32 z, struct Vec3s* vec); -void func_800D1FD4(MtxF* mf); -void Matrix_ScaleTrans(struct Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 posX, f32 posY, f32 posZ); -#endif diff --git a/include/def/sys_ucode.h b/include/def/sys_ucode.h index e1b72a262..50dff38dc 100644 --- a/include/def/sys_ucode.h +++ b/include/def/sys_ucode.h @@ -1,16 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_SYS_UCODE_C + u64* SysUcode_GetUCode(void); u64* SysUcode_GetUCodeBoot(void); u64 SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCodeData(void); -u64 SysUcode_GetUCodeSize(void); u64 SysUcode_GetUCodeDataSize(void); -#else -u64* SysUcode_GetUCode(void); -u64* SysUcode_GetUCodeBoot(void); -u64 SysUcode_GetUCodeBootSize(void); -u64* SysUcode_GetUCodeData(void); u64 SysUcode_GetUCodeSize(void); -u64 SysUcode_GetUCodeDataSize(void); -#endif diff --git a/include/def/system_malloc.h b/include/def/system_malloc.h index f87d542df..1b75fb5f6 100644 --- a/include/def/system_malloc.h +++ b/include/def/system_malloc.h @@ -1,9 +1,9 @@ #pragma once +struct Arena; -//extern Arena gSystemArena; +extern Arena gSystemArena; extern s32 gSystemArenaLogSeverity; -#ifdef INTERNAL_SRC_CODE_SYSTEM_MALLOC_C void* SystemArena_Calloc(u32 num, u32 size); void SystemArena_Check(void); void SystemArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); @@ -20,21 +20,3 @@ void* SystemArena_MallocR(u32 size); void* SystemArena_MallocRDebug(u32 size, const char* file, s32 line); void* SystemArena_Realloc(void* ptr, u32 newSize); void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); -#else -void* SystemArena_Calloc(u32 num, u32 size); -void SystemArena_Check(void); -void SystemArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); -void SystemArena_Cleanup(void); -void SystemArena_Display(void); -void SystemArena_Free(void* ptr); -void SystemArena_FreeDebug(void* ptr, const char* file, s32 line); -void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc); -void SystemArena_Init(void* start, u32 size); -u8 SystemArena_IsInitalized(void); -void* SystemArena_Malloc(u32 size); -void* SystemArena_MallocDebug(u32 size, const char* file, s32 line); -void* SystemArena_MallocR(u32 size); -void* SystemArena_MallocRDebug(u32 size, const char* file, s32 line); -void* SystemArena_Realloc(void* ptr, u32 newSize); -void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); -#endif diff --git a/include/def/title_setup.h b/include/def/title_setup.h index 746cb883a..61965901e 100644 --- a/include/def/title_setup.h +++ b/include/def/title_setup.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_TITLE_SETUP_C +struct GameState; + void TitleSetup_Destroy(GameState* gameState); void TitleSetup_Init(GameState* gameState); void TitleSetup_InitImpl(GameState* gameState); -#else -void TitleSetup_Destroy(struct GameState* gameState); -void TitleSetup_Init(struct GameState* gameState); -void TitleSetup_InitImpl(struct GameState* gameState); -#endif diff --git a/include/def/translate.h b/include/def/translate.h index 9b14c32e2..3aa9e3bcd 100644 --- a/include/def/translate.h +++ b/include/def/translate.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_TRANSLATE_C + void guTranslate(Mtx* m, f32 x, f32 y, f32 z); -#else -void guTranslate(struct Mtx* m, f32 x, f32 y, f32 z); -#endif diff --git a/include/def/us2dex.h b/include/def/us2dex.h index 6836fd9bf..88a9ff532 100644 --- a/include/def/us2dex.h +++ b/include/def/us2dex.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_GU_US2DEX_C + void guS2DInitBg(uObjBg* bg); -#else -void guS2DInitBg(uObjBg* bg); -#endif diff --git a/include/def/vi.h b/include/def/vi.h index 0fec5f9d6..409dfd135 100644 --- a/include/def/vi.h +++ b/include/def/vi.h @@ -1,10 +1,7 @@ #pragma once +struct OSViContext; extern OSViContext* __osViCurr; extern OSViContext* __osViNext; -#ifdef INTERNAL_SRC_LIBULTRA_IO_VI_C void __osViInit(void); -#else -void __osViInit(void); -#endif diff --git a/include/def/viblack.h b/include/def/viblack.h index 458c119d1..b0a7c3bfb 100644 --- a/include/def/viblack.h +++ b/include/def/viblack.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VIBLACK_C + void osViBlack(u8 active); -#else -void osViBlack(u8 active); -#endif diff --git a/include/def/viextend.h b/include/def/viextend.h index 5966623d0..6e473bfea 100644 --- a/include/def/viextend.h +++ b/include/def/viextend.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VIEXTEND_C + void osViExtendVStart(u32 arg0); -#else -void osViExtendVStart(u32 arg0); -#endif diff --git a/include/def/vigetcurrcontext.h b/include/def/vigetcurrcontext.h index 44d0f9543..2c1d18252 100644 --- a/include/def/vigetcurrcontext.h +++ b/include/def/vigetcurrcontext.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VIGETCURRCONTEXT_C +struct OSViContext; + OSViContext* __osViGetCurrentContext(void); -#else -struct OSViContext* __osViGetCurrentContext(void); -#endif diff --git a/include/def/vigetcurrframebuf.h b/include/def/vigetcurrframebuf.h index 6a4b00c91..01935c29d 100644 --- a/include/def/vigetcurrframebuf.h +++ b/include/def/vigetcurrframebuf.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VIGETCURRFRAMEBUF_C + u32* osViGetCurrentFramebuffer(void); -#else -u32* osViGetCurrentFramebuffer(void); -#endif diff --git a/include/def/vigetnextframebuf.h b/include/def/vigetnextframebuf.h index ac0dfcb46..860d9a288 100644 --- a/include/def/vigetnextframebuf.h +++ b/include/def/vigetnextframebuf.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VIGETNEXTFRAMEBUF_C + void* osViGetNextFramebuffer(void); -#else -void* osViGetNextFramebuffer(void); -#endif diff --git a/include/def/vimodefpallan1.h b/include/def/vimodefpallan1.h index 6561fe34d..79bfc91c2 100644 --- a/include/def/vimodefpallan1.h +++ b/include/def/vimodefpallan1.h @@ -1,3 +1,4 @@ #pragma once +struct OSViMode; extern OSViMode osViModeFpalLan1; diff --git a/include/def/vimodempallan1.h b/include/def/vimodempallan1.h index f9dbdd433..f0d97dbd0 100644 --- a/include/def/vimodempallan1.h +++ b/include/def/vimodempallan1.h @@ -1,3 +1,4 @@ #pragma once +struct OSViMode; extern OSViMode osViModeMpalLan1; diff --git a/include/def/vimodentsclan1.h b/include/def/vimodentsclan1.h index eeb85c42c..ba38895b9 100644 --- a/include/def/vimodentsclan1.h +++ b/include/def/vimodentsclan1.h @@ -1,3 +1,4 @@ #pragma once +struct OSViMode; extern OSViMode osViModeNtscLan1; diff --git a/include/def/vimodepallan1.h b/include/def/vimodepallan1.h index 7ed17c0e9..de4001ee8 100644 --- a/include/def/vimodepallan1.h +++ b/include/def/vimodepallan1.h @@ -1,3 +1,4 @@ #pragma once +struct OSViMode; extern OSViMode osViModePalLan1; diff --git a/include/def/visetevent.h b/include/def/visetevent.h index 6f42ef8ad..6a4ae9770 100644 --- a/include/def/visetevent.h +++ b/include/def/visetevent.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISETEVENT_C +struct OSMesgQueue; + void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount); -#else -void osViSetEvent(struct OSMesgQueue* mq, OSMesg m, u32 retraceCount); -#endif diff --git a/include/def/visetmode.h b/include/def/visetmode.h index 383e40955..8ab07305e 100644 --- a/include/def/visetmode.h +++ b/include/def/visetmode.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISETMODE_C +struct OSViMode; + void osViSetMode(OSViMode* mode); -#else -void osViSetMode(struct OSViMode* mode); -#endif diff --git a/include/def/visetspecial.h b/include/def/visetspecial.h index 9ab46a880..78db52207 100644 --- a/include/def/visetspecial.h +++ b/include/def/visetspecial.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISETSPECIAL_C + void osViSetSpecialFeatures(u32 func); -#else -void osViSetSpecialFeatures(u32 func); -#endif diff --git a/include/def/visetxscale.h b/include/def/visetxscale.h index afcd6bc2d..d555e6bfb 100644 --- a/include/def/visetxscale.h +++ b/include/def/visetxscale.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISETXSCALE_C + void osViSetXScale(f32 value); -#else -void osViSetXScale(f32 value); -#endif diff --git a/include/def/visetyscale.h b/include/def/visetyscale.h index 8975f77b8..7c86eeb1e 100644 --- a/include/def/visetyscale.h +++ b/include/def/visetyscale.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISETYSCALE_C + void osViSetYScale(f32 scale); -#else -void osViSetYScale(f32 scale); -#endif diff --git a/include/def/viswapbuf.h b/include/def/viswapbuf.h index 3145497ff..7fdb36be5 100644 --- a/include/def/viswapbuf.h +++ b/include/def/viswapbuf.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISWAPBUF_C + void osViSwapBuffer(void* vaddr); -#else -void osViSwapBuffer(void* vaddr); -#endif diff --git a/include/def/viswapcontext.h b/include/def/viswapcontext.h index 9fffa561e..deb028558 100644 --- a/include/def/viswapcontext.h +++ b/include/def/viswapcontext.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_IO_VISWAPCONTEXT_C + void __osViSwapContext(void); -#else -void __osViSwapContext(void); -#endif diff --git a/include/def/xldtob.h b/include/def/xldtob.h index 390bd5127..406b251d7 100644 --- a/include/def/xldtob.h +++ b/include/def/xldtob.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_RMON_XLDTOB_C +struct _Pft; + void _Ldtob(_Pft* args, u8 type); -#else -void _Ldtob(struct _Pft* args, u8 type); -#endif diff --git a/include/def/xlitob.h b/include/def/xlitob.h index d6584cfb2..87b146324 100644 --- a/include/def/xlitob.h +++ b/include/def/xlitob.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_RMON_XLITOB_C +struct _Pft; + void _Litob(_Pft* args, u8 type); -#else -void _Litob(struct _Pft* args, u8 type); -#endif diff --git a/include/def/xprintf.h b/include/def/xprintf.h index 802c9cd84..429c78a22 100644 --- a/include/def/xprintf.h +++ b/include/def/xprintf.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_LIBULTRA_RMON_XPRINTF_C + s32 _Printf(PrintCallback, void* arg, const char* fmt, va_list ap); -#else -s32 _Printf(PrintCallback, void* arg, const char* fmt, va_list ap); -#endif diff --git a/include/def/z_DLF.h b/include/def/z_DLF.h index 52c84dbf9..62436713e 100644 --- a/include/def/z_DLF.h +++ b/include/def/z_DLF.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_DLF_C +struct GameStateOverlay; + void Overlay_FreeGameState(GameStateOverlay* overlayEntry); void Overlay_LoadGameState(GameStateOverlay* overlayEntry); -#else -void Overlay_FreeGameState(struct GameStateOverlay* overlayEntry); -void Overlay_LoadGameState(struct GameStateOverlay* overlayEntry); -#endif diff --git a/include/def/z_actor.h b/include/def/z_actor.h index 1c4605fe0..d0f5ca8cf 100644 --- a/include/def/z_actor.h +++ b/include/def/z_actor.h @@ -1,8 +1,29 @@ #pragma once +struct Actor; +struct Lights; +struct GlobalContext; +struct ActorShape; +struct ActorContext; +struct Collider; +struct PosRot; +struct Vec3f; +struct Player; +struct ColliderInfo; +struct ColliderJntSph; +struct ActorEntry; +struct BodyBreak; +struct TitleCardContext; +struct TargetContext; +struct DynaPolyActor; +struct GraphicsContext; +struct CollisionPoly; +struct struct_80034A14_arg1; +struct SkelAnime; +struct struct_80034EC0_Entry; +struct Vec3s; extern Gfx D_80116280[]; -#ifdef INTERNAL_SRC_CODE_Z_ACTOR_C void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx); void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx); @@ -28,6 +49,7 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); f32 Actor_HeightDiff(Actor* actorA, Actor* actorB); s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 angle); s32 Actor_IsFacingPlayer(Actor* actor, s16 angle); +s32 Actor_IsInUncullZone(GlobalContext* globalCtx, Actor* actorB, Vec3f* projectedPos, f32 projectedW); s32 Actor_IsMounted(GlobalContext* globalCtx, Actor* horse); s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor); void Actor_Kill(Actor* actor); @@ -146,7 +168,6 @@ void func_8002F994(Actor* actor, s32 arg1); s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos); void func_800304B0(GlobalContext* globalCtx); void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry); -s32 Actor_IsInUncullZone(GlobalContext* globalCtx, Actor* actorB, Vec3f* projectedPos, f32 projectedW); void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx); void func_80031A28(GlobalContext* globalCtx, ActorContext* actorCtx); void func_80031B14(GlobalContext* globalCtx, ActorContext* actorCtx); @@ -163,6 +184,7 @@ void func_80033E88(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3); void func_8003424C(GlobalContext* globalCtx, Vec3f* arg1); Hilite* func_800342EC(Vec3f* object, GlobalContext* globalCtx); Hilite* func_8003435C(Vec3f* object, GlobalContext* globalCtx); +s32 func_800343CC(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 interactRange, u16 (*unkFunc1)(GlobalContext*, Actor*), s16 (*unkFunc2)(GlobalContext*, Actor*)); s16 func_800347E8(s16 arg0); void func_80034A14(Actor* actor, struct_80034A14_arg1* arg1, s16 arg2, s16 arg3); void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); @@ -180,182 +202,3 @@ void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2); u16 func_80037C30(GlobalContext* globalCtx, s16 arg1); s32 func_80037D98(GlobalContext* globalCtx, Actor* actor, s16 arg2, s32* arg3); s32 func_80038290(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* arg3, Vec3f arg4); -#else -void ActorShadow_DrawCircle(struct Actor* actor, struct Lights* lights, struct GlobalContext* globalCtx); -void ActorShadow_DrawFeet(struct Actor* actor, struct Lights* lights, struct GlobalContext* globalCtx); -void ActorShadow_DrawHorse(struct Actor* actor, struct Lights* lights, struct GlobalContext* globalCtx); -void ActorShadow_DrawWhiteCircle(struct Actor* actor, struct Lights* lights, struct GlobalContext* globalCtx); -void ActorShape_Init(struct ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale); -s32 Actor_ActorAIsFacingActorB(struct Actor* actorA, struct Actor* actorB, s16 angle); -s32 Actor_ActorAIsFacingAndNearActorB(struct Actor* actorA, struct Actor* actorB, f32 range, s16 angle); -s32 Actor_ActorBIsFacingActorA(struct Actor* actorA, struct Actor* actorB, s16 angle); -u8 Actor_ApplyDamage(struct Actor* actor); -void Actor_ChangeCategory(struct GlobalContext* globalCtx, struct ActorContext* actorCtx, struct Actor* actor, u8 actorCategory); -struct Actor* Actor_Delete(struct ActorContext* actorCtx, struct Actor* actor, struct GlobalContext* globalCtx); -void Actor_DrawDoorLock(struct GlobalContext* globalCtx, s32 arg1, s32 arg2); -struct Actor* Actor_Find(struct ActorContext* actorCtx, s32 actorId, s32 actorCategory); -struct Actor* Actor_FindNearby(struct GlobalContext* globalCtx, struct Actor* refActor, s16 actorId, u8 actorCategory, f32 range); -struct Actor* Actor_GetCollidedExplosive(struct GlobalContext* globalCtx, struct Collider* collider); -struct PosRot* Actor_GetFocus(struct PosRot* arg0, struct Actor* actor); -struct Actor* Actor_GetProjectileActor(struct GlobalContext* globalCtx, struct Actor* refActor, f32 radius); -void Actor_GetScreenPos(struct GlobalContext* globalCtx, struct Actor* actor, s16* x, s16* y); -struct PosRot* Actor_GetWorld(struct PosRot* arg0, struct Actor* actor); -struct PosRot* Actor_GetWorldPosShapeRot(struct PosRot* arg0, struct Actor* actor); -u32 Actor_HasNoParent(struct Actor* actor, struct GlobalContext* globalCtx); -u32 Actor_HasParent(struct Actor* actor, struct GlobalContext* globalCtx); -f32 Actor_HeightDiff(struct Actor* actorA, struct Actor* actorB); -s32 Actor_IsFacingAndNearPlayer(struct Actor* actor, f32 range, s16 angle); -s32 Actor_IsFacingPlayer(struct Actor* actor, s16 angle); -s32 Actor_IsMounted(struct GlobalContext* globalCtx, struct Actor* horse); -s32 Actor_IsTargeted(struct GlobalContext* globalCtx, struct Actor* actor); -void Actor_Kill(struct Actor* actor); -void Actor_MountHorse(struct GlobalContext* globalCtx, struct Player* player, struct Actor* horse); -void Actor_MoveForward(struct Actor* actor); -void Actor_Noop(struct Actor* actor, struct GlobalContext* globalCtx); -s32 Actor_NotMounted(struct GlobalContext* globalCtx, struct Actor* horse); -s32 Actor_OtherIsTargeted(struct GlobalContext* globalCtx, struct Actor* actor); -u32 Actor_ProcessTalkRequest(struct Actor* actor, struct GlobalContext* globalCtx); -void Actor_SetColorFilter(struct Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 xluFlag, s16 duration); -void Actor_SetDropFlag(struct Actor* actor, struct ColliderInfo* colBody, s32 freezeFlag); -void Actor_SetDropFlagJntSph(struct Actor* actor, struct ColliderJntSph* colBody, s32 freezeFlag); -void Actor_SetFeetPos(struct Actor* actor, s32 limbIndex, s32 leftFootIndex, struct Vec3f* leftFootPos, s32 rightFootIndex, struct Vec3f* rightFootPos); -void Actor_SetFocus(struct Actor* actor, f32 offset); -void Actor_SetObjectDependency(struct GlobalContext* globalCtx, struct Actor* actor); -u32 Actor_SetRideActor(struct GlobalContext* globalCtx, struct Actor* horse, s32 arg2); -void Actor_SetScale(struct Actor* actor, f32 scale); -void Actor_SetTextWithPrefix(struct GlobalContext* globalCtx, struct Actor* actor, s16 textIdLower); -struct Actor* Actor_Spawn(struct ActorContext* actorCtx, struct GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s16 params); -struct Actor* Actor_SpawnAsChild(struct ActorContext* actorCtx, struct Actor* parent, struct GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s16 params); -struct Actor* Actor_SpawnEntry(struct ActorContext* actorCtx, struct ActorEntry* actorEntry, struct GlobalContext* globalCtx); -void Actor_SpawnFloorDustRing(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* posXZ, f32 radius, s32 amountMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); -void Actor_SpawnTransitionActors(struct GlobalContext* globalCtx, struct ActorContext* actorCtx); -s16 Actor_TestFloorInDirection(struct Actor* actor, struct GlobalContext* globalCtx, f32 distance, s16 angle); -u32 Actor_TextboxIsClosing(struct Actor* actor, struct GlobalContext* globalCtx); -void Actor_UpdateAll(struct GlobalContext* globalCtx, struct ActorContext* actorCtx); -void Actor_UpdateBgCheckInfo(struct GlobalContext* globalCtx, struct Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, s32 flags); -f32 Actor_WorldDistXYZToActor(struct Actor* actorA, struct Actor* actorB); -f32 Actor_WorldDistXYZToPoint(struct Actor* actor, struct Vec3f* refPoint); -f32 Actor_WorldDistXZToActor(struct Actor* actorA, struct Actor* actorB); -f32 Actor_WorldDistXZToPoint(struct Actor* actor, struct Vec3f* refPoint); -s16 Actor_WorldPitchTowardActor(struct Actor* actorA, struct Actor* actorB); -s16 Actor_WorldPitchTowardPoint(struct Actor* actor, struct Vec3f* refPoint); -s16 Actor_WorldYawTowardActor(struct Actor* actorA, struct Actor* actorB); -s16 Actor_WorldYawTowardPoint(struct Actor* actor, struct Vec3f* refPoint); -void Audio_PlayActorSound2(struct Actor* actor, u16 sfxId); -void BodyBreak_Alloc(struct BodyBreak* bodyBreak, s32 count, struct GlobalContext* globalCtx); -void BodyBreak_SetInfo(struct BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList, s16 objectId); -s32 BodyBreak_SpawnParts(struct Actor* actor, struct BodyBreak* bodyBreak, struct GlobalContext* globalCtx, s16 type); -void Enemy_StartFinishingBlow(struct GlobalContext* globalCtx, struct Actor* actor); -s32 Flags_GetClear(struct GlobalContext* globalCtx, s32 flag); -s32 Flags_GetCollectible(struct GlobalContext* globalCtx, s32 flag); -s32 Flags_GetEventChkInf(s32 flag); -s32 Flags_GetInfTable(s32 flag); -s32 Flags_GetSwitch(struct GlobalContext* globalCtx, s32 flag); -s32 Flags_GetTempClear(struct GlobalContext* globalCtx, s32 flag); -s32 Flags_GetTreasure(struct GlobalContext* globalCtx, s32 flag); -s32 Flags_GetUnknown(struct GlobalContext* globalCtx, s32 flag); -void Flags_SetClear(struct GlobalContext* globalCtx, s32 flag); -void Flags_SetCollectible(struct GlobalContext* globalCtx, s32 flag); -void Flags_SetEventChkInf(s32 flag); -void Flags_SetInfTable(s32 flag); -void Flags_SetSwitch(struct GlobalContext* globalCtx, s32 flag); -void Flags_SetTempClear(struct GlobalContext* globalCtx, s32 flag); -void Flags_SetTreasure(struct GlobalContext* globalCtx, s32 flag); -void Flags_SetUnknown(struct GlobalContext* globalCtx, s32 flag); -void Flags_UnsetClear(struct GlobalContext* globalCtx, s32 flag); -void Flags_UnsetSwitch(struct GlobalContext* globalCtx, s32 flag); -void Flags_UnsetTempClear(struct GlobalContext* globalCtx, s32 flag); -void Flags_UnsetUnknown(struct GlobalContext* globalCtx, s32 flag); -f32 Player_GetHeight(struct Player* player); -s32 Player_IsFacingActor(struct Actor* actor, s16 angle, struct GlobalContext* globalCtx); -f32 Rand_CenteredFloat(f32 f); -f32 Rand_ZeroFloat(f32 f); -void TitleCard_InitBossName(struct GlobalContext* globalCtx, struct TitleCardContext* titleCtx, void* texture, s16 x, s16 y, u8 width, u8 height); -void TitleCard_InitPlaceName(struct GlobalContext* globalCtx, struct TitleCardContext* titleCtx, void* texture, s32 x, s32 y, s32 width, s32 height, s32 delay); -void func_8002BE04(struct GlobalContext* globalCtx, struct Vec3f* arg1, struct Vec3f* arg2, f32* arg3); -void func_8002C124(struct TargetContext* targetCtx, struct GlobalContext* globalCtx); -s32 func_8002D53C(struct GlobalContext* globalCtx, struct TitleCardContext* titleCtx); -void func_8002D7EC(struct Actor* actor); -void func_8002D868(struct Actor* actor); -void func_8002D908(struct Actor* actor); -void func_8002D97C(struct Actor* actor); -void func_8002D9A4(struct Actor* actor, f32 arg1); -void func_8002DBD0(struct Actor* actor, struct Vec3f* result, struct Vec3f* arg2); -f32 func_8002DCE4(struct Player* player); -s32 func_8002DD6C(struct Player* player); -s32 func_8002DD78(struct Player* player); -s32 func_8002DDE4(struct GlobalContext* globalCtx); -s32 func_8002DDF4(struct GlobalContext* globalCtx); -void func_8002DE04(struct GlobalContext* globalCtx, struct Actor* actorA, struct Actor* actorB); -void func_8002DE74(struct GlobalContext* globalCtx, struct Player* player); -s32 func_8002DEEC(struct Player* player); -void func_8002DF18(struct GlobalContext* globalCtx, struct Player* player); -s32 func_8002DF38(struct GlobalContext* globalCtx, struct Actor* actor, u8 csMode); -s32 func_8002DF54(struct GlobalContext* globalCtx, struct Actor* actor, u8 arg2); -void func_8002DF90(struct DynaPolyActor* dynaActor); -void func_8002DFA4(struct DynaPolyActor* dynaActor, f32 arg1, s16 arg2); -Hilite* func_8002EABC(struct Vec3f* object, struct Vec3f* eye, struct Vec3f* lightDir, struct GraphicsContext* gfxCtx); -Hilite* func_8002EB44(struct Vec3f* object, struct Vec3f* eye, struct Vec3f* lightDir, struct GraphicsContext* gfxCtx); -void func_8002EBCC(struct Actor* actor, struct GlobalContext* globalCtx, s32 flag); -void func_8002ED80(struct Actor* actor, struct GlobalContext* globalCtx, s32 flag); -s32 func_8002F0C8(struct Actor* actor, struct Player* player, s32 arg2); -s32 func_8002F1C4(struct Actor* actor, struct GlobalContext* globalCtx, f32 arg2, f32 arg3, u32 arg4); -s32 func_8002F298(struct Actor* actor, struct GlobalContext* globalCtx, f32 arg2, u32 arg3); -s32 func_8002F2CC(struct Actor* actor, struct GlobalContext* globalCtx, f32 arg2); -s32 func_8002F2F4(struct Actor* actor, struct GlobalContext* globalCtx); -s8 func_8002F368(struct GlobalContext* globalCtx); -s32 func_8002F434(struct Actor* actor, struct GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange); -void func_8002F554(struct Actor* actor, struct GlobalContext* globalCtx, s32 getItemId); -void func_8002F580(struct Actor* actor, struct GlobalContext* globalCtx); -void func_8002F5C4(struct Actor* actorA, struct Actor* actorB, struct GlobalContext* globalCtx); -void func_8002F5F0(struct Actor* actor, struct GlobalContext* globalCtx); -void func_8002F698(struct GlobalContext* globalCtx, struct Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6); -void func_8002F6D4(struct GlobalContext* globalCtx, struct Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5); -void func_8002F71C(struct GlobalContext* globalCtx, struct Actor* actor, f32 arg2, s16 arg3, f32 arg4); -void func_8002F758(struct GlobalContext* globalCtx, struct Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5); -void func_8002F7A0(struct GlobalContext* globalCtx, struct Actor* actor, f32 arg2, s16 arg3, f32 arg4); -void func_8002F7DC(struct Actor* actor, u16 sfxId); -void func_8002F850(struct GlobalContext* globalCtx, struct Actor* actor); -void func_8002F8F0(struct Actor* actor, u16 sfxId); -void func_8002F91C(struct Actor* actor, u16 sfxId); -void func_8002F948(struct Actor* actor, u16 sfxId); -void func_8002F974(struct Actor* actor, u16 sfxId); -void func_8002F994(struct Actor* actor, s32 arg1); -s32 func_8002F9EC(struct GlobalContext* globalCtx, struct Actor* actor, CollisionPoly* poly, s32 bgId, struct Vec3f* pos); -void func_800304B0(struct GlobalContext* globalCtx); -void func_800304DC(struct GlobalContext* globalCtx, struct ActorContext* actorCtx, struct ActorEntry* actorEntry); -s32 Actor_IsInUncullZone(GlobalContext* globalCtx, Actor* actorB, Vec3f* projectedPos, f32 projectedW); -void func_800315AC(struct GlobalContext* globalCtx, struct ActorContext* actorCtx); -void func_80031A28(struct GlobalContext* globalCtx, struct ActorContext* actorCtx); -void func_80031B14(struct GlobalContext* globalCtx, struct ActorContext* actorCtx); -void func_80031C3C(struct ActorContext* actorCtx, struct GlobalContext* globalCtx); -struct Actor* func_80032AF0(struct GlobalContext* globalCtx, struct ActorContext* actorCtx, struct Actor** actorPtr, struct Player* player); -s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3); -void func_80033480(struct GlobalContext* globalCtx, struct Vec3f* posBase, f32 randRangeDiameter, s32 amountMinusOne, s16 scaleBase, s16 scaleStep, u8 arg6); -struct Actor* func_80033684(struct GlobalContext* globalCtx, struct Actor* explosiveActor); -f32 func_80033AEC(struct Vec3f* arg0, struct Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5); -void func_80033C30(struct Vec3f* arg0, struct Vec3f* arg1, u8 alpha, struct GlobalContext* globalCtx); -void func_80033DB8(struct GlobalContext* globalCtx, s16 arg1, s16 arg2); -void func_80033E1C(struct GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3); -void func_80033E88(struct Actor* actor, struct GlobalContext* globalCtx, s16 arg2, s16 arg3); -void func_8003424C(struct GlobalContext* globalCtx, struct Vec3f* arg1); -Hilite* func_800342EC(struct Vec3f* object, struct GlobalContext* globalCtx); -Hilite* func_8003435C(struct Vec3f* object, struct GlobalContext* globalCtx); -s16 func_800347E8(s16 arg0); -void func_80034A14(struct Actor* actor, struct struct_80034A14_arg1* arg1, s16 arg2, s16 arg3); -void func_80034BA0(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, struct Actor* actor, s16 alpha); -void func_80034CC4(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, struct Actor* actor, s16 alpha); -s16 func_80034DD4(struct Actor* actor, struct GlobalContext* globalCtx, s16 arg2, f32 arg3); -void func_80034EC0(struct SkelAnime* skelAnime, struct struct_80034EC0_Entry* animations, s32 index); -void func_80034F54(struct GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); -s32 func_800354B4(struct GlobalContext* globalCtx, struct Actor* actor, f32 range, s16 arg3, s16 arg4, s16 arg5); -void func_8003555C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void func_800355B8(struct GlobalContext* globalCtx, struct Vec3f* pos); -u8 func_800355E4(struct GlobalContext* globalCtx, struct Collider* collider); -void func_80035844(struct Vec3f* arg0, struct Vec3f* arg1, struct Vec3s* arg2, s32 arg3); -struct Actor* func_800358DC(struct Actor* actor, struct Vec3f* spawnPos, struct Vec3s* spawnRot, f32* arg3, s32 timer, s16* unused, struct GlobalContext* globalCtx, s16 params, s32 arg8); -void func_800359B8(struct Actor* actor, s16 arg1, struct Vec3s* arg2); -u16 func_80037C30(struct GlobalContext* globalCtx, s16 arg1); -s32 func_80037D98(struct GlobalContext* globalCtx, struct Actor* actor, s16 arg2, s32* arg3); -s32 func_80038290(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3s* arg2, struct Vec3s* arg3, struct Vec3f arg4); -#endif diff --git a/include/def/z_actor_dlftbls.h b/include/def/z_actor_dlftbls.h index 4d9146fb1..6ee565b4b 100644 --- a/include/def/z_actor_dlftbls.h +++ b/include/def/z_actor_dlftbls.h @@ -1,14 +1,9 @@ #pragma once +struct ActorOverlay; extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; extern s32 gMaxActorId; -#ifdef INTERNAL_SRC_CODE_Z_ACTOR_DLFTBLS_C void ActorOverlayTable_Cleanup(void); void ActorOverlayTable_Init(void); void ActorOverlayTable_LogPrint(void); -#else -void ActorOverlayTable_Cleanup(void); -void ActorOverlayTable_Init(void); -void ActorOverlayTable_LogPrint(void); -#endif diff --git a/include/def/z_bgcheck.h b/include/def/z_bgcheck.h index adcc36ede..e986f689b 100644 --- a/include/def/z_bgcheck.h +++ b/include/def/z_bgcheck.h @@ -1,5 +1,21 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_BGCHECK_C +struct CollisionContext; +struct GlobalContext; +struct CollisionHeader; +struct Vec3f; +struct CollisionPoly; +struct Actor; +struct SSList; +struct StaticLookup; +struct Vec3i; +struct DynaRaycast; +struct SSNodeList; +struct DynaCollisionContext; +struct DynaPolyActor; +struct DynaSSNodeList; +struct Vec3s; +struct WaterBox; + void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader); s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkOneFace); @@ -55,8 +71,8 @@ s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Ac void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna); void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna); u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList*); -void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys); -u16 SSNodeList_GetNextNodeIdx(SSNodeList* this); +void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* pthis, s32 tblMax, s32 numPolys); +u16 SSNodeList_GetNextNodeIdx(SSNodeList* pthis); void SSNodeList_Initialize(SSNodeList*); u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); @@ -101,106 +117,3 @@ u32 func_80041EC8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041F10(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint); s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); -#else -void BgCheck_Allocate(struct CollisionContext* colCtx, struct GlobalContext* globalCtx, struct CollisionHeader* colHeader); -s32 BgCheck_AnyCheckCeiling(struct CollisionContext* colCtx, f32* outY, struct Vec3f* pos, f32 checkHeight); -s32 BgCheck_AnyLineTest1(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkOneFace); -s32 BgCheck_AnyLineTest2(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace); -s32 BgCheck_AnyLineTest3(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -f32 BgCheck_AnyRaycastFloor1(struct CollisionContext* colCtx, CollisionPoly* outPoly, struct Vec3f* pos); -f32 BgCheck_AnyRaycastFloor2(struct CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, struct Vec3f* pos); -s32 BgCheck_CameraLineTest1(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_CameraLineTest2(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -f32 BgCheck_CameraRaycastFloor2(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Vec3f* pos); -s32 BgCheck_CheckDynaCeiling(struct CollisionContext* colCtx, u16 xpFlags, f32* outY, struct Vec3f* pos, f32 chkDist, CollisionPoly** outPoly, s32* outBgId, struct Actor* actor); -s32 BgCheck_CheckLineAgainstDyna(struct CollisionContext* colCtx, u16 xpFlags, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, f32* distSq, s32* outBgId, struct Actor* actor, f32 chkDist, s32 bccFlags); -s32 BgCheck_CheckLineAgainstSSList(struct SSList* headNodeId, struct CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* outPos, CollisionPoly** outPoly, f32* outDistSq, f32 chkDist, s32 bccFlags); -s32 BgCheck_CheckLineImpl(struct CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32* bgId, struct Actor* actor, f32 chkDist, u32 bccFlags); -s32 BgCheck_CheckStaticCeiling(struct StaticLookup* lookup, u16 xpFlags, struct CollisionContext* colCtx, f32* outY, struct Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly); -s32 BgCheck_CheckWallImpl(struct CollisionContext* colCtx, u16 xpFlags, struct Vec3f* posResult, struct Vec3f* posNext, struct Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, struct Actor* actor, f32 checkHeight, u8 argA); -void BgCheck_DrawDynaCollision(struct GlobalContext*, struct CollisionContext*); -void BgCheck_DrawStaticCollision(struct GlobalContext*, struct CollisionContext*); -s32 BgCheck_EntityCheckCeiling(struct CollisionContext* colCtx, f32* arg1, struct Vec3f* arg2, f32 arg3, CollisionPoly** outPoly, s32* outBgId, struct Actor* actor); -s32 BgCheck_EntityLineTest1(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_EntityLineTest2(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, struct Actor* actor); -s32 BgCheck_EntityLineTest3(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, struct Actor* actor, f32 chkDist); -f32 BgCheck_EntityRaycastFloor1(struct CollisionContext* colCtx, CollisionPoly** outPoly, struct Vec3f* pos); -f32 BgCheck_EntityRaycastFloor2(struct GlobalContext* globalCtx, struct CollisionContext* colCtx, CollisionPoly** outPoly, struct Vec3f* pos); -f32 BgCheck_EntityRaycastFloor3(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Vec3f* pos); -f32 BgCheck_EntityRaycastFloor4(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Actor* actor, struct Vec3f* arg4); -f32 BgCheck_EntityRaycastFloor5(struct GlobalContext* globalCtx, struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Actor* actor, struct Vec3f* pos); -f32 BgCheck_EntityRaycastFloor6(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Actor* actor, struct Vec3f* pos, f32 chkDist); -f32 BgCheck_EntityRaycastFloor7(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Actor* actor, struct Vec3f* pos); -f32 BgCheck_EntityRaycastFloor8(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Actor* actor, struct Vec3f* pos); -f32 BgCheck_EntityRaycastFloor9(struct CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, struct Vec3f* pos); -s32 BgCheck_EntitySphVsWall1(struct CollisionContext* colCtx, struct Vec3f* posResult, struct Vec3f* posNext, struct Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, f32 checkHeight); -s32 BgCheck_EntitySphVsWall2(struct CollisionContext* colCtx, struct Vec3f* posResult, struct Vec3f* posNext, struct Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, f32 checkHeight); -s32 BgCheck_EntitySphVsWall3(struct CollisionContext* colCtx, struct Vec3f* posResult, struct Vec3f* posNext, struct Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, struct Actor* actor, f32 checkHeight); -s32 BgCheck_EntitySphVsWall4(struct CollisionContext* colCtx, struct Vec3f* posResult, struct Vec3f* posNext, struct Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, struct Actor* actor, f32 checkHeight); -void BgCheck_GetStaticLookupIndicesFromPos(struct CollisionContext* colCtx, struct Vec3f* pos, struct Vec3i* arg2); -s32 BgCheck_PosInStaticBoundingBox(struct CollisionContext* colCtx, struct Vec3f* pos); -s32 BgCheck_ProjectileLineTest(struct CollisionContext* colCtx, struct Vec3f* posA, struct Vec3f* posB, struct Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -f32 BgCheck_RaycastFloorDyna(struct DynaRaycast* dynaRaycast); -void BgCheck_ResetPolyCheckTbl(struct SSNodeList* nodeList, s32 numPolys); -s32 BgCheck_SphVsDynaWall(struct CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, struct Vec3f* pos, f32 radius, CollisionPoly** outPoly, s32* outBgId, struct Actor* actor); -s32 BgCheck_SphVsFirstDynaPoly(struct CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, struct Vec3f* center, f32 radius, struct Actor* actor, u16 bciFlags); -s32 BgCheck_SphVsFirstPoly(struct CollisionContext* colCtx, struct Vec3f* center, f32 radius); -void CollisionHeader_GetVirtual(void* colHeader, struct CollisionHeader** dest); -f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, struct Vec3f* point); -void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, struct CollisionContext* colCtx, struct Vec3f* dest); -void DynaPoly_Alloc(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna); -void DynaPoly_DeleteBgActor(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna, s32 bgId); -struct DynaPolyActor* DynaPoly_GetActor(struct CollisionContext* colCtx, s32 bgId); -void DynaPoly_Init(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna); -s32 DynaPoly_IsBgIdBgActor(s32 bgId); -s32 DynaPoly_SetBgActor(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna, struct Actor* actor, struct CollisionHeader* colHeader); -void DynaPoly_Setup(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna); -void DynaPoly_UpdateBgActorTransforms(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna); -u16 DynaSSNodeList_GetNextNodeIdx(struct DynaSSNodeList*); -void SSNodeList_Alloc(struct GlobalContext* globalCtx, struct SSNodeList* this, s32 tblMax, s32 numPolys); -u16 SSNodeList_GetNextNodeIdx(struct SSNodeList* this); -void SSNodeList_Initialize(struct SSNodeList*); -u32 SurfaceType_GetCamDataIndex(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -struct Vec3s* SurfaceType_GetCamPosData(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u16 SurfaceType_GetCameraSType(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetConveyorDirection(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetConveyorSpeed(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetEcho(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetLightSettingIndex(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u16 SurfaceType_GetNumCameras(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetSceneExitIndex(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u16 SurfaceType_GetSfx(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetSlope(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 SurfaceType_IsConveyor(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_IsHookshotSurface(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_IsHorseBlocked(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 SurfaceType_IsIgnoredByEntities(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 SurfaceType_IsIgnoredByProjectiles(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_IsWallDamage(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 WaterBox_GetCamDataIndex(struct CollisionContext* colCtx, struct WaterBox* waterBox); -u16 WaterBox_GetCameraSType(struct CollisionContext* colCtx, struct WaterBox* waterBox); -u32 WaterBox_GetLightSettingIndex(struct CollisionContext* colCtx, struct WaterBox* waterBox); -s32 WaterBox_GetSurface1(struct GlobalContext* globalCtx, struct CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, struct WaterBox** outWaterBox); -s32 WaterBox_GetSurface2(struct GlobalContext* globalCtx, struct CollisionContext* colCtx, struct Vec3f* pos, f32 surfaceChkDist, struct WaterBox** outWaterBox); -s32 WaterBox_GetSurfaceImpl(struct GlobalContext* globalCtx, struct CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, struct WaterBox** outWaterBox); -void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest); -void func_8003EBF8(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna, s32 bgId); -void func_8003EC50(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna, s32 bgId); -void func_8003ECA8(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna, s32 bgId); -void func_8003EE6C(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna); -void func_8003F8EC(struct GlobalContext* globalCtx, struct DynaCollisionContext* dyna, struct Actor* actor); -void func_800418D0(struct CollisionContext* colCtx, struct GlobalContext* globalCtx); -u16 func_80041A4C(struct CollisionContext* colCtx, u32 camId, s32 bgId); -struct Vec3s* func_80041C10(struct CollisionContext* colCtx, s32 camId, s32 bgId); -u32 func_80041D4C(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041D70(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041DB8(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041DE4(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041E18(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041E4C(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041EA4(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041EC8(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041F10(struct CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, struct Vec3f* point, struct Vec3f* closestPoint); -s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, struct Vec3f* pointA, struct Vec3f* pointB, struct Vec3f* closestPoint); -#endif diff --git a/include/def/z_camera.h b/include/def/z_camera.h index b695a766e..60f0f9037 100644 --- a/include/def/z_camera.h +++ b/include/def/z_camera.h @@ -1,5 +1,14 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_CAMERA_C +struct Camera; +struct Actor; +struct Vec3s; +struct Vec3f; +struct View; +struct CollisionContext; +struct GlobalContext; +struct Player; +struct CutsceneCameraPoint; + s32 Camera_AddQuake(Camera* camera, s32 arg1, s16 y, s32 countdown); s32 Camera_ChangeDataIdx(Camera* camera, s32 camDataIdx); s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 camDataIdx, f32 arg3, s16 timer1, s16 timer2, s16 timer3); @@ -26,31 +35,3 @@ s16 func_8005ACFC(Camera* camera, s16 arg1); s16 func_8005AD1C(Camera* camera, s16 arg1); s32 func_8005B198(void); s16 func_8005B1A4(Camera* camera); -#else -s32 Camera_AddQuake(struct Camera* camera, s32 arg1, s16 y, s32 countdown); -s32 Camera_ChangeDataIdx(struct Camera* camera, s32 camDataIdx); -s32 Camera_ChangeDoorCam(struct Camera* camera, struct Actor* doorActor, s16 camDataIdx, f32 arg3, s16 timer1, s16 timer2, s16 timer3); -s32 Camera_ChangeMode(struct Camera* camera, s16 mode); -s32 Camera_ChangeSetting(struct Camera* camera, s16 setting); -s16 Camera_ChangeStatus(struct Camera* camera, s16 status); -s32 Camera_CheckValidMode(struct Camera* camera, s16 mode); -s32 Camera_Copy(struct Camera* dstCamera, struct Camera* srcCamera); -void Camera_Finish(struct Camera* camera); -struct Vec3s* Camera_GetCamDir(struct Vec3s* dir, struct Camera* camera); -s16 Camera_GetCamDirPitch(struct Camera* camera); -s16 Camera_GetCamDirYaw(struct Camera* camera); -s16 Camera_GetInputDirYaw(struct Camera* camera); -struct Vec3f* Camera_GetSkyboxOffset(struct Vec3f* dst, struct Camera* camera); -void Camera_Init(struct Camera* camera, struct View* view, struct CollisionContext* colCtx, struct GlobalContext* globalCtx); -void Camera_InitPlayerSettings(struct Camera* camera, struct Player* player); -s32 Camera_ResetAnim(struct Camera* camera); -s32 Camera_SetCSParams(struct Camera* camera, struct CutsceneCameraPoint* atPoints, struct CutsceneCameraPoint* eyePoints, struct Player* player, s16 relativeToPlayer); -void Camera_SetCameraData(struct Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, UNK_TYPE arg6); -s32 Camera_SetParam(struct Camera* camera, s32 param, void* value); -struct Vec3s Camera_Update(struct Camera* camera); -s32 func_8005AC48(struct Camera* camera, s16 arg1); -s16 func_8005ACFC(struct Camera* camera, s16 arg1); -s16 func_8005AD1C(struct Camera* camera, s16 arg1); -s32 func_8005B198(void); -s16 func_8005B1A4(struct Camera* camera); -#endif diff --git a/include/def/z_cheap_proc.h b/include/def/z_cheap_proc.h index a66fb187f..9c6195056 100644 --- a/include/def/z_cheap_proc.h +++ b/include/def/z_cheap_proc.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_CHEAP_PROC_C +struct GlobalContext; + void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist); void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist); -#else -void Gfx_DrawDListOpa(struct GlobalContext* globalCtx, Gfx* dlist); -void Gfx_DrawDListXlu(struct GlobalContext* globalCtx, Gfx* dlist); -#endif diff --git a/include/def/z_collision_btltbls.h b/include/def/z_collision_btltbls.h index 0762a5cb8..96c25605c 100644 --- a/include/def/z_collision_btltbls.h +++ b/include/def/z_collision_btltbls.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_COLLISION_BTLTBLS_C +struct DamageTable; + void DamageTable_Clear(DamageTable* table); DamageTable* DamageTable_Get(s32 index); -#else -void DamageTable_Clear(struct DamageTable* table); -struct DamageTable* DamageTable_Get(s32 index); -#endif diff --git a/include/def/z_collision_check.h b/include/def/z_collision_check.h index db703186a..670879a5c 100644 --- a/include/def/z_collision_check.h +++ b/include/def/z_collision_check.h @@ -1,5 +1,34 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_COLLISION_CHECK_C +struct GlobalContext; +struct ColliderCylinder; +struct ColliderJntSph; +struct OcLine; +struct ColliderQuad; +struct ColliderTris; +struct Collider; +struct GraphicsContext; +struct Vec3f; +struct Actor; +struct ColliderCylinderInit; +struct Vec3s; +struct ColliderCylinderInitToActor; +struct ColliderCylinderInitType1; +struct ColliderJntSphInit; +struct ColliderJntSphElement; +struct ColliderJntSphInitType1; +struct ColliderJntSphInitToActor; +struct ColliderQuadInit; +struct ColliderQuadInitType1; +struct ColliderTrisInit; +struct ColliderTrisElement; +struct ColliderTrisInitType1; +struct ColliderTrisElementDimInit; +struct CollisionCheckContext; +struct CollisionCheckInfo; +struct DamageTable; +struct CollisionCheckInfoInit; +struct CollisionCheckInfoInit2; + s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collider); s32 Collider_DestroyJntSph(GlobalContext* globalCtx, ColliderJntSph* collider); s32 Collider_DestroyLine(GlobalContext* globalCtx, OcLine* line); @@ -82,87 +111,3 @@ void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec3f* v, Vec3f* actorPos); void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* b, Vec3f* actorPos); void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v); -#else -s32 Collider_DestroyCylinder(struct GlobalContext* globalCtx, struct ColliderCylinder* collider); -s32 Collider_DestroyJntSph(struct GlobalContext* globalCtx, struct ColliderJntSph* collider); -s32 Collider_DestroyLine(struct GlobalContext* globalCtx, struct OcLine* line); -s32 Collider_DestroyQuad(struct GlobalContext* globalCtx, struct ColliderQuad* collider); -s32 Collider_DestroyTris(struct GlobalContext* globalCtx, struct ColliderTris* tris); -void Collider_Draw(struct GlobalContext* globalCtx, struct Collider* collider); -void Collider_DrawPoly(struct GraphicsContext* gfxCtx, struct Vec3f* vA, struct Vec3f* vB, struct Vec3f* vC, u8 r, u8 g, u8 b); -void Collider_DrawRedPoly(struct GraphicsContext* gfxCtx, struct Vec3f* vA, struct Vec3f* vB, struct Vec3f* vC); -s32 Collider_FreeJntSph(struct GlobalContext* globalCtx, struct ColliderJntSph* collider); -s32 Collider_FreeTris(struct GlobalContext* globalCtx, struct ColliderTris* tris); -s32 Collider_InitCylinder(struct GlobalContext* globalCtx, struct ColliderCylinder* collider); -s32 Collider_InitJntSph(struct GlobalContext* globalCtx, struct ColliderJntSph* collider); -s32 Collider_InitLine(struct GlobalContext* globalCtx, struct OcLine* line); -s32 Collider_InitQuad(struct GlobalContext* globalCtx, struct ColliderQuad* collider); -s32 Collider_InitTris(struct GlobalContext* globalCtx, struct ColliderTris* tris); -s32 Collider_ResetCylinderAC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetCylinderAT(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetCylinderOC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetJntSphAC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetJntSphAT(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetJntSphOC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetLineOC(struct GlobalContext* globalCtx, struct OcLine* line); -s32 Collider_ResetQuadAC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetQuadAT(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetQuadOC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetTrisAC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetTrisAT(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_ResetTrisOC(struct GlobalContext* globalCtx, struct Collider* collider); -s32 Collider_SetCylinder(struct GlobalContext* globalCtx, struct ColliderCylinder* collider, struct Actor* actor, struct ColliderCylinderInit* src); -void Collider_SetCylinderPosition(struct ColliderCylinder* collider, struct Vec3s* pos); -s32 Collider_SetCylinderToActor(struct GlobalContext* globalCtx, struct ColliderCylinder* collider, struct ColliderCylinderInitToActor* src); -s32 Collider_SetCylinderType1(struct GlobalContext* globalCtx, struct ColliderCylinder* collider, struct Actor* actor, struct ColliderCylinderInitType1* src); -s32 Collider_SetJntSph(struct GlobalContext* globalCtx, struct ColliderJntSph* dest, struct Actor* actor, struct ColliderJntSphInit* src, struct ColliderJntSphElement* elements); -s32 Collider_SetJntSphAlloc(struct GlobalContext* globalCtx, struct ColliderJntSph* dest, struct Actor* actor, struct ColliderJntSphInit* src); -s32 Collider_SetJntSphAllocType1(struct GlobalContext* globalCtx, struct ColliderJntSph* dest, struct Actor* actor, struct ColliderJntSphInitType1* src); -s32 Collider_SetJntSphToActor(struct GlobalContext* globalCtx, struct ColliderJntSph* dest, struct ColliderJntSphInitToActor* src); -s32 Collider_SetLine(struct GlobalContext* globalCtx, struct OcLine* dest, struct OcLine* src); -s32 Collider_SetLinePoints(struct GlobalContext* globalCtx, struct OcLine* ocLine, struct Vec3f* a, struct Vec3f* b); -s32 Collider_SetQuad(struct GlobalContext* globalCtx, struct ColliderQuad* collider, struct Actor* actor, struct ColliderQuadInit* src); -s32 Collider_SetQuadType1(struct GlobalContext* globalCtx, struct ColliderQuad* collider, struct Actor* actor, struct ColliderQuadInitType1* src); -void Collider_SetQuadVertices(struct ColliderQuad* collider, struct Vec3f* a, struct Vec3f* b, struct Vec3f* c, struct Vec3f* d); -s32 Collider_SetTris(struct GlobalContext* globalCtx, struct ColliderTris* dest, struct Actor* actor, struct ColliderTrisInit* src, struct ColliderTrisElement* elements); -s32 Collider_SetTrisAlloc(struct GlobalContext* globalCtx, struct ColliderTris* dest, struct Actor* actor, struct ColliderTrisInit* src); -s32 Collider_SetTrisAllocType1(struct GlobalContext* globalCtx, struct ColliderTris* dest, struct Actor* actor, struct ColliderTrisInitType1* src); -void Collider_SetTrisDim(struct GlobalContext* globalCtx, struct ColliderTris* collider, s32 index, struct ColliderTrisElementDimInit* init); -void Collider_SetTrisVertices(struct ColliderTris* collider, s32 index, struct Vec3f* a, struct Vec3f* b, struct Vec3f* c); -void Collider_UpdateCylinder(struct Actor* actor, struct ColliderCylinder* collider); -void Collider_UpdateSpheres(s32 limb, struct ColliderJntSph* collider); -void CollisionCheck_AT(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_BlueBlood(struct GlobalContext* globalCtx, struct Collider* collider, struct Vec3f* v); -void CollisionCheck_ClearContext(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, struct Vec3f* actorPos, struct Vec3f* itemPos, struct Vec3f* itemProjPos, struct Vec3f* out1, struct Vec3f* out2); -void CollisionCheck_Damage(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_DestroyContext(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_DisableSAC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_DrawCollision(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_EnableSAC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -u8 CollisionCheck_GetSwordDamage(s32 dmgFlags); -void CollisionCheck_InitContext(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_InitInfo(struct CollisionCheckInfo* info); -s32 CollisionCheck_LineOCCheck(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Vec3f* a, struct Vec3f* b, struct Actor** exclusions, s32 numExclusions); -s32 CollisionCheck_LineOCCheckAll(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Vec3f* a, struct Vec3f* b); -void CollisionCheck_OC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx); -void CollisionCheck_ResetDamage(struct CollisionCheckInfo* info); -s32 CollisionCheck_SetAC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Collider* collider); -s32 CollisionCheck_SetAC_SAC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Collider* collider, s32 index); -s32 CollisionCheck_SetAT(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Collider* collider); -s32 CollisionCheck_SetAT_SAC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Collider* collider, s32 index); -void CollisionCheck_SetInfo(struct CollisionCheckInfo* info, struct DamageTable* damageTable, struct CollisionCheckInfoInit* init); -void CollisionCheck_SetInfo2(struct CollisionCheckInfo* info, struct DamageTable* damageTable, struct CollisionCheckInfoInit2* init); -void CollisionCheck_SetInfoGetDamageTable(struct CollisionCheckInfo* info, s32 index, struct CollisionCheckInfoInit2* init); -void CollisionCheck_SetInfoNoDamageTable(struct CollisionCheckInfo* info, struct CollisionCheckInfoInit* init); -s32 CollisionCheck_SetOC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Collider* collider); -s32 CollisionCheck_SetOCLine(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct OcLine* collider); -s32 CollisionCheck_SetOC_SAC(struct GlobalContext* globalCtx, struct CollisionCheckContext* colChkCtx, struct Collider* collider, s32 index); -void CollisionCheck_SpawnRedBlood(struct GlobalContext* globalCtx, struct Vec3f* v); -void CollisionCheck_SpawnShieldParticles(struct GlobalContext* globalCtx, struct Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetal(struct GlobalContext* globalCtx, struct Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetal2(struct GlobalContext* globalCtx, struct Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetalSound(struct GlobalContext* globalCtx, struct Vec3f* v, struct Vec3f* actorPos); -void CollisionCheck_SpawnShieldParticlesWood(struct GlobalContext* globalCtx, struct Vec3f* b, struct Vec3f* actorPos); -void CollisionCheck_SpawnWaterDroplets(struct GlobalContext* globalCtx, struct Vec3f* v); -#endif diff --git a/include/def/z_common_data.h b/include/def/z_common_data.h index 07803b727..d1554927b 100644 --- a/include/def/z_common_data.h +++ b/include/def/z_common_data.h @@ -1,9 +1,6 @@ #pragma once +struct SaveContext; extern SaveContext gSaveContext; -#ifdef INTERNAL_SRC_CODE_Z_COMMON_DATA_C void SaveContext_Init(void); -#else -void SaveContext_Init(void); -#endif diff --git a/include/def/z_construct.h b/include/def/z_construct.h index 0ad7811aa..2a8223958 100644 --- a/include/def/z_construct.h +++ b/include/def/z_construct.h @@ -1,12 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_CONSTRUCT_C +struct GlobalContext; + void Message_Init(GlobalContext* globalCtx); void func_80110990(GlobalContext* globalCtx); void func_801109B0(GlobalContext* globalCtx); void func_80112098(GlobalContext* globalCtx); -#else -void Message_Init(struct GlobalContext* globalCtx); -void func_80110990(struct GlobalContext* globalCtx); -void func_801109B0(struct GlobalContext* globalCtx); -void func_80112098(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_debug.h b/include/def/z_debug.h index aca94ca07..d6da8b4ef 100644 --- a/include/def/z_debug.h +++ b/include/def/z_debug.h @@ -1,17 +1,12 @@ #pragma once +struct Input; +struct GraphicsContext; +struct GameInfo; extern GameInfo* gGameInfo; -#ifdef INTERNAL_SRC_CODE_Z_DEBUG_C void func_800636C0(void); void func_8006375C(s32 arg0, s32 arg1, const char* text); void func_8006376C(u8 x, u8 y, u8 colorId, const char* text); void func_8006390C(Input* input); void func_80063D7C(GraphicsContext* gfxCtx); -#else -void func_800636C0(void); -void func_8006375C(s32 arg0, s32 arg1, const char* text); -void func_8006376C(u8 x, u8 y, u8 colorId, const char* text); -void func_8006390C(struct Input* input); -void func_80063D7C(struct GraphicsContext* gfxCtx); -#endif diff --git a/include/def/z_demo.h b/include/def/z_demo.h index c3d3a2d04..920c5dbbf 100644 --- a/include/def/z_demo.h +++ b/include/def/z_demo.h @@ -1,11 +1,12 @@ #pragma once +struct GlobalContext; +struct CutsceneContext; extern u16 D_8015FCC0; extern u16 D_8015FCC2; extern u16 D_8015FCC4; extern u8 D_8015FCC8; -#ifdef INTERNAL_SRC_CODE_Z_DEMO_C void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx); void Cutscene_HandleEntranceTriggers(GlobalContext* globalCtx); void Cutscene_SetSegment(GlobalContext* globalCtx, void* segment); @@ -14,13 +15,3 @@ void func_80064520(GlobalContext* globalCtx, CutsceneContext* csCtx); void func_80064534(GlobalContext* globalCtx, CutsceneContext* csCtx); void func_80064558(GlobalContext* globalCtx, CutsceneContext* csCtx); void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx); -#else -void Cutscene_HandleConditionalTriggers(struct GlobalContext* globalCtx); -void Cutscene_HandleEntranceTriggers(struct GlobalContext* globalCtx); -void Cutscene_SetSegment(struct GlobalContext* globalCtx, void* segment); -void func_8006450C(struct GlobalContext* globalCtx, struct CutsceneContext* csCtx); -void func_80064520(struct GlobalContext* globalCtx, struct CutsceneContext* csCtx); -void func_80064534(struct GlobalContext* globalCtx, struct CutsceneContext* csCtx); -void func_80064558(struct GlobalContext* globalCtx, struct CutsceneContext* csCtx); -void func_800645A0(struct GlobalContext* globalCtx, struct CutsceneContext* csCtx); -#endif diff --git a/include/def/z_draw.h b/include/def/z_draw.h index 408609624..aa1de8890 100644 --- a/include/def/z_draw.h +++ b/include/def/z_draw.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_DRAW_C +struct GlobalContext; + void GetItem_Draw(GlobalContext* globalCtx, s16 drawId); -#else -void GetItem_Draw(struct GlobalContext* globalCtx, s16 drawId); -#endif diff --git a/include/def/z_eff_blure.h b/include/def/z_eff_blure.h index f96f0edb3..fa82779c2 100644 --- a/include/def/z_eff_blure.h +++ b/include/def/z_eff_blure.h @@ -1,18 +1,12 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFF_BLURE_C -void EffectBlure_AddSpace(EffectBlure* this); -void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2); -void EffectBlure_Destroy(void* thisx); -void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx); -void EffectBlure_Init1(void* thisx, void* initParamsx); -void EffectBlure_Init2(void* thisx, void* initParamsx); -s32 EffectBlure_Update(void* thisx); -#else -void EffectBlure_AddSpace(struct EffectBlure* this); -void EffectBlure_AddVertex(struct EffectBlure* this, struct Vec3f* p1, struct Vec3f* p2); -void EffectBlure_Destroy(void* thisx); -void EffectBlure_Draw(void* thisx, struct GraphicsContext* gfxCtx); -void EffectBlure_Init1(void* thisx, void* initParamsx); -void EffectBlure_Init2(void* thisx, void* initParamsx); -s32 EffectBlure_Update(void* thisx); -#endif +struct EffectBlure; +struct Vec3f; +struct GraphicsContext; + +void EffectBlure_AddSpace(EffectBlure* pthis); +void EffectBlure_AddVertex(EffectBlure* pthis, Vec3f* p1, Vec3f* p2); +void EffectBlure_Destroy(void* pthisx); +void EffectBlure_Draw(void* pthisx, GraphicsContext* gfxCtx); +void EffectBlure_Init1(void* pthisx, void* initParamsx); +void EffectBlure_Init2(void* pthisx, void* initParamsx); +s32 EffectBlure_Update(void* pthisx); diff --git a/include/def/z_eff_shield_particle.h b/include/def/z_eff_shield_particle.h index e6fc8005a..691f61d78 100644 --- a/include/def/z_eff_shield_particle.h +++ b/include/def/z_eff_shield_particle.h @@ -1,12 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFF_SHIELD_PARTICLE_C -void EffectShieldParticle_Destroy(void* thisx); -void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx); -void EffectShieldParticle_Init(void* thisx, void* initParamsx); -s32 EffectShieldParticle_Update(void* thisx); -#else -void EffectShieldParticle_Destroy(void* thisx); -void EffectShieldParticle_Draw(void* thisx, struct GraphicsContext* gfxCtx); -void EffectShieldParticle_Init(void* thisx, void* initParamsx); -s32 EffectShieldParticle_Update(void* thisx); -#endif +struct GraphicsContext; + +void EffectShieldParticle_Destroy(void* pthisx); +void EffectShieldParticle_Draw(void* pthisx, GraphicsContext* gfxCtx); +void EffectShieldParticle_Init(void* pthisx, void* initParamsx); +s32 EffectShieldParticle_Update(void* pthisx); diff --git a/include/def/z_eff_spark.h b/include/def/z_eff_spark.h index d6841be41..b7bc517dc 100644 --- a/include/def/z_eff_spark.h +++ b/include/def/z_eff_spark.h @@ -1,12 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFF_SPARK_C -void EffectSpark_Destroy(void* thisx); -void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx); -void EffectSpark_Init(void* thisx, void* initParamsx); -s32 EffectSpark_Update(void* thisx); -#else -void EffectSpark_Destroy(void* thisx); -void EffectSpark_Draw(void* thisx, struct GraphicsContext* gfxCtx); -void EffectSpark_Init(void* thisx, void* initParamsx); -s32 EffectSpark_Update(void* thisx); -#endif +struct GraphicsContext; + +void EffectSpark_Destroy(void* pthisx); +void EffectSpark_Draw(void* pthisx, GraphicsContext* gfxCtx); +void EffectSpark_Init(void* pthisx, void* initParamsx); +s32 EffectSpark_Update(void* pthisx); diff --git a/include/def/z_eff_ss_dead.h b/include/def/z_eff_ss_dead.h index 9a6afef04..a15949eaf 100644 --- a/include/def/z_eff_ss_dead.h +++ b/include/def/z_eff_ss_dead.h @@ -1,16 +1,10 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFF_SS_DEAD_C +struct GlobalContext; +struct Color_RGBA8; + void func_80026230(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); void func_80026400(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); void func_80026608(GlobalContext* globalCtx); void func_80026690(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); void func_80026860(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); void func_80026A6C(GlobalContext* globalCtx); -#else -void func_80026230(struct GlobalContext* globalCtx, struct Color_RGBA8* color, s16 arg2, s16 arg3); -void func_80026400(struct GlobalContext* globalCtx, struct Color_RGBA8* color, s16 arg2, s16 arg3); -void func_80026608(struct GlobalContext* globalCtx); -void func_80026690(struct GlobalContext* globalCtx, struct Color_RGBA8* color, s16 arg2, s16 arg3); -void func_80026860(struct GlobalContext* globalCtx, struct Color_RGBA8* color, s16 arg2, s16 arg3); -void func_80026A6C(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_effect.h b/include/def/z_effect.h index 0c9553288..b86fe762c 100644 --- a/include/def/z_effect.h +++ b/include/def/z_effect.h @@ -1,5 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFFECT_C +struct GlobalContext; +struct GraphicsContext; + void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams); void Effect_Delete(GlobalContext* globalCtx, s32 index); void Effect_DeleteAll(GlobalContext* globalCtx); @@ -8,13 +10,3 @@ void* Effect_GetByIndex(s32 index); GlobalContext* Effect_GetGlobalCtx(void); void Effect_InitContext(GlobalContext* globalCtx); void Effect_UpdateAll(GlobalContext* globalCtx); -#else -void Effect_Add(struct GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams); -void Effect_Delete(struct GlobalContext* globalCtx, s32 index); -void Effect_DeleteAll(struct GlobalContext* globalCtx); -void Effect_DrawAll(struct GraphicsContext* gfxCtx); -void* Effect_GetByIndex(s32 index); -struct GlobalContext* Effect_GetGlobalCtx(void); -void Effect_InitContext(struct GlobalContext* globalCtx); -void Effect_UpdateAll(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_effect_soft_sprite.h b/include/def/z_effect_soft_sprite.h index 9c310c719..59835aa05 100644 --- a/include/def/z_effect_soft_sprite.h +++ b/include/def/z_effect_soft_sprite.h @@ -1,5 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFFECT_SOFT_SPRITE_C +struct GlobalContext; +struct EffectSs; + void EffectSs_ClearAll(GlobalContext* globalCtx); void EffectSs_Delete(EffectSs* effectSs); void EffectSs_DrawAll(GlobalContext* globalCtx); @@ -11,16 +13,3 @@ void EffectSs_UpdateAll(GlobalContext* globalCtx); s16 func_80027DD4(s16 arg0, s16 arg1, s32 arg2); s16 func_80027E34(s16 arg0, s16 arg1, f32 arg2); u8 func_80027E84(u8 arg0, u8 arg1, f32 arg2); -#else -void EffectSs_ClearAll(struct GlobalContext* globalCtx); -void EffectSs_Delete(struct EffectSs* effectSs); -void EffectSs_DrawAll(struct GlobalContext* globalCtx); -void EffectSs_InitInfo(struct GlobalContext* globalCtx, s32 tableSize); -void EffectSs_Insert(struct GlobalContext* globalCtx, struct EffectSs* effectSs); -void EffectSs_Reset(struct EffectSs* effectSs); -void EffectSs_Spawn(struct GlobalContext* globalCtx, s32 type, s32 priority, void* initParams); -void EffectSs_UpdateAll(struct GlobalContext* globalCtx); -s16 func_80027DD4(s16 arg0, s16 arg1, s32 arg2); -s16 func_80027E34(s16 arg0, s16 arg1, f32 arg2); -u8 func_80027E84(u8 arg0, u8 arg1, f32 arg2); -#endif diff --git a/include/def/z_effect_soft_sprite_dlftbls.h b/include/def/z_effect_soft_sprite_dlftbls.h index 8dc848933..ab6173c26 100644 --- a/include/def/z_effect_soft_sprite_dlftbls.h +++ b/include/def/z_effect_soft_sprite_dlftbls.h @@ -1,3 +1,4 @@ #pragma once +struct EffectSsOverlay; extern EffectSsOverlay gEffectSsOverlayTable[EFFECT_SS_TYPE_MAX]; diff --git a/include/def/z_effect_soft_sprite_old_init.h b/include/def/z_effect_soft_sprite_old_init.h index bf469832d..fd77dcc1c 100644 --- a/include/def/z_effect_soft_sprite_old_init.h +++ b/include/def/z_effect_soft_sprite_old_init.h @@ -1,5 +1,11 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EFFECT_SOFT_SPRITE_OLD_INIT_C +struct GlobalContext; +struct Vec3f; +struct Color_RGBA8; +struct Actor; +struct Vec3s; +struct EffectSs; + void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life); void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 life); void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); @@ -63,7 +69,7 @@ void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos); void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected); void EffectSsStick_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 yaw); void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 arg2); -void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture); +void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* pthis, void* texture); void func_8002829C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); void func_80028304(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); void func_8002836C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); @@ -81,86 +87,3 @@ void func_8002881C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* void func_80028858(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void func_80028990(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void func_80028A54(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); -#else -void EffectSsBlast_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life); -void EffectSsBlast_SpawnShockwave(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 life); -void EffectSsBlast_SpawnWhiteCustomScale(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 life); -void EffectSsBlast_SpawnWhiteShockwave(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void EffectSsBomb2_SpawnFade(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void EffectSsBomb2_SpawnLayered(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep); -void EffectSsBomb_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void EffectSsBubble_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); -void EffectSsDFire_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s32 life); -void EffectSsDFire_SpawnFixedScale(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 alpha, s16 fadeDelay); -void EffectSsDeadDb_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 primR, s16 primG, s16 primB, s16 primA, s16 envR, s16 envG, s16 envB, s16 unused, s32 arg14, s16 playSound); -void EffectSsDeadDd_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 primR, s16 primG, s16 primB, s16 alpha, s16 envR, s16 envG, s16 envB, s16 alphaStep, s32 life); -void EffectSsDeadDd_SpawnRandYellow(struct GlobalContext* globalCtx, struct Vec3f* pos, s16 scale, s16 scaleStep, f32 randPosScale, s32 randIter, s32 life); -void EffectSsDeadDs_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s32 life); -void EffectSsDeadDs_SpawnStationary(struct GlobalContext* globalCtx, struct Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life); -void EffectSsDeadSound_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, u16 sfxId, s16 lowerPriority, s16 repeatMode, s32 life); -void EffectSsDeadSound_SpawnStationary(struct GlobalContext* globalCtx, struct Vec3f* pos, u16 sfxId, s16 lowerPriority, s16 repeatMode, s32 life); -void EffectSsDtBubble_SpawnColorProfile(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 life, s16 colorProfile, s16 randXZ); -void EffectSsDtBubble_SpawnCustomColor(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); -void EffectSsDust_Spawn(struct GlobalContext* globalCtx, u16 drawFlags, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode); -void EffectSsEnFire_SpawnVec3f(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, s16 scale, s16 unk_12, s16 flags, s16 bodyPart); -void EffectSsEnFire_SpawnVec3s(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3s* vec, s16 scale, s16 arg4, s16 flags, s16 bodyPart); -void EffectSsEnIce_Spawn(struct GlobalContext* arg0, struct Vec3f* pos, f32 scale, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s32 life); -void EffectSsEnIce_SpawnFlyingVec3f(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, s16 primR, s16 primG, s16 primB, s16 primA, s16 envR, s16 envG, s16 envB, f32 scale); -void EffectSsEnIce_SpawnFlyingVec3s(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3s* pos, s16 primR, s16 primG, s16 primB, s16 primA, s16 envR, s16 envG, s16 envB, f32 scale); -void EffectSsExtra_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scoreIdx); -void EffectSsFCircle_Spawn(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, s16 radius, s16 height); -void EffectSsFhgFlash_SpawnLightBall(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, u8 param); -void EffectSsFhgFlash_SpawnShock(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, s16 scale, u8 param); -void EffectSsFireTail_Spawn(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, f32 scale, struct Vec3f* arg4, s16 arg5, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 type, s16 bodyPart, s32 life); -void EffectSsFireTail_SpawnFlame(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, f32 arg3, s16 bodyPart, f32 colorIntensity); -void EffectSsFireTail_SpawnFlameOnPlayer(struct GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity); -void EffectSsGFire_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos); -void EffectSsGMagma2_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 updateRate, s16 drawMode, s16 scale); -void EffectSsGMagma_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos); -void EffectSsGRipple_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, s16 radius, s16 radiusMax, s16 life); -void EffectSsGSpk_SpawnAccel(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void EffectSsGSpk_SpawnFuse(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void EffectSsGSpk_SpawnNoAccel(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void EffectSsGSpk_SpawnRandColor(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep); -void EffectSsGSpk_SpawnSmall(struct GlobalContext* globalCtx, struct Actor* actor, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor); -void EffectSsGSplash_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 type, s16 scale); -void EffectSsHahen_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 unused, s16 scale, s16 objId, s16 life, Gfx* dList); -void EffectSsHahen_SpawnBurst(struct GlobalContext* globalCtx, struct Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); -void EffectSsHitMark_Spawn(struct GlobalContext* globalCtx, s32 type, s16 scale, struct Vec3f* pos); -void EffectSsHitMark_SpawnCustomScale(struct GlobalContext* globalCtx, s32 type, s16 scale, struct Vec3f* pos); -void EffectSsHitMark_SpawnFixedScale(struct GlobalContext* globalCtx, s32 type, struct Vec3f* pos); -void EffectSsIcePiece_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, f32 scale, struct Vec3f* velocity, struct Vec3f* accel, s32 life); -void EffectSsIcePiece_SpawnBurst(struct GlobalContext* globalCtx, struct Vec3f* refPos, f32 scale); -void EffectSsIceSmoke_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale); -void EffectSsKFire_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scaleMax, u8 type); -void EffectSsKakera_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); -void EffectSsKiraKira_SpawnDispersed(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s32 life); -void EffectSsKiraKira_SpawnFocused(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s32 life); -void EffectSsKiraKira_SpawnSmall(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor); -void EffectSsKiraKira_SpawnSmallYellow(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void EffectSsLightning_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 yaw, s16 life, s16 numBolts); -void EffectSsSibuki2_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale); -void EffectSsSibuki_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 moveDelay, s16 direction, s16 scale); -void EffectSsSibuki_SpawnBurst(struct GlobalContext* globalCtx, struct Vec3f* pos); -void EffectSsSolderSrchBall_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 unused, s16* linkDetected); -void EffectSsStick_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, s16 yaw); -void EffectSsStone1_Spawn(struct GlobalContext* globalCtx, struct Vec3f* pos, s32 arg2); -void EffectSs_DrawGEffect(struct GlobalContext* globalCtx, struct EffectSs* this, void* texture); -void func_8002829C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_80028304(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_8002836C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800283D4(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_8002843C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800284A4(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_80028510(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_8002857C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void func_800285EC(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel); -void func_8002865C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep); -void func_800286CC(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep); -void func_8002873C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 life); -void func_800287AC(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, s16 scale, s16 scaleStep, s16 life); -void func_8002881C(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor); -void func_80028858(struct GlobalContext* globalCtx, struct Vec3f* pos, struct Vec3f* velocity, struct Vec3f* accel, struct Color_RGBA8* primColor, struct Color_RGBA8* envColor); -void func_80028990(struct GlobalContext* globalCtx, f32 randScale, struct Vec3f* srcPos); -void func_80028A54(struct GlobalContext* globalCtx, f32 randScale, struct Vec3f* srcPos); -#endif diff --git a/include/def/z_elf_message.h b/include/def/z_elf_message.h index b405b1da7..e14024606 100644 --- a/include/def/z_elf_message.h +++ b/include/def/z_elf_message.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_ELF_MESSAGE_C +struct GlobalContext; + u16 ElfMessage_GetCUpText(GlobalContext* globalCtx); u16 ElfMessage_GetSariaText(GlobalContext* globalCtx); -#else -u16 ElfMessage_GetCUpText(struct GlobalContext* globalCtx); -u16 ElfMessage_GetSariaText(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_en_item00.h b/include/def/z_en_item00.h index d2830e770..89cb76185 100644 --- a/include/def/z_en_item00.h +++ b/include/def/z_en_item00.h @@ -1,10 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_EN_ITEM00_C +struct GlobalContext; +struct Vec3f; +struct EnItem00; +struct Actor; + EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params); EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params); void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params); -#else -struct EnItem00* Item_DropCollectible(struct GlobalContext* globalCtx, struct Vec3f* spawnPos, s16 params); -struct EnItem00* Item_DropCollectible2(struct GlobalContext* globalCtx, struct Vec3f* spawnPos, s16 params); -void Item_DropCollectibleRandom(struct GlobalContext* globalCtx, struct Actor* fromActor, struct Vec3f* spawnPos, s16 params); -#endif diff --git a/include/def/z_face_reaction.h b/include/def/z_face_reaction.h index 8d4d56216..02d95adf5 100644 --- a/include/def/z_face_reaction.h +++ b/include/def/z_face_reaction.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FACE_REACTION_C +struct GlobalContext; + u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet); -#else -u16 Text_GetFaceReaction(struct GlobalContext* globalCtx, u32 reactionSet); -#endif diff --git a/include/def/z_fbdemo.h b/include/def/z_fbdemo.h index 96703e7a6..f35492136 100644 --- a/include/def/z_fbdemo.h +++ b/include/def/z_fbdemo.h @@ -1,18 +1,10 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FBDEMO_C -void TransitionUnk_Destroy(TransitionUnk* this); -void TransitionUnk_Draw(TransitionUnk* this, Gfx**); -TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col); -void TransitionUnk_InitData(TransitionUnk* this); -void TransitionUnk_InitGraphics(TransitionUnk* this); -void TransitionUnk_SetData(TransitionUnk* this); -void func_800B23E8(TransitionUnk* this); -#else -void TransitionUnk_Destroy(struct TransitionUnk* this); -void TransitionUnk_Draw(struct TransitionUnk* this, Gfx**); -struct TransitionUnk* TransitionUnk_Init(struct TransitionUnk* this, s32 row, s32 col); -void TransitionUnk_InitData(struct TransitionUnk* this); -void TransitionUnk_InitGraphics(struct TransitionUnk* this); -void TransitionUnk_SetData(struct TransitionUnk* this); -void func_800B23E8(struct TransitionUnk* this); -#endif +struct TransitionUnk; + +void TransitionUnk_Destroy(TransitionUnk* pthis); +void TransitionUnk_Draw(TransitionUnk* pthis, Gfx**); +TransitionUnk* TransitionUnk_Init(TransitionUnk* pthis, s32 row, s32 col); +void TransitionUnk_InitData(TransitionUnk* pthis); +void TransitionUnk_InitGraphics(TransitionUnk* pthis); +void TransitionUnk_SetData(TransitionUnk* pthis); +void func_800B23E8(TransitionUnk* pthis); diff --git a/include/def/z_fbdemo_circle.h b/include/def/z_fbdemo_circle.h index 2324b62a5..fb7e34511 100644 --- a/include/def/z_fbdemo_circle.h +++ b/include/def/z_fbdemo_circle.h @@ -1,22 +1,11 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FBDEMO_CIRCLE_C -void TransitionCircle_Destroy(void* thisx); -void TransitionCircle_Draw(void* thisx, Gfx** gfxP); -void* TransitionCircle_Init(void* thisx); -s32 TransitionCircle_IsDone(void* thisx); -void TransitionCircle_SetColor(void* thisx, u32 color); -void TransitionCircle_SetEnvColor(void* thisx, u32 color); -void TransitionCircle_SetType(void* thisx, s32 type); -void TransitionCircle_Start(void* thisx); -void TransitionCircle_Update(void* thisx, s32 updateRate); -#else -void TransitionCircle_Destroy(void* thisx); -void TransitionCircle_Draw(void* thisx, Gfx** gfxP); -void* TransitionCircle_Init(void* thisx); -s32 TransitionCircle_IsDone(void* thisx); -void TransitionCircle_SetColor(void* thisx, u32 color); -void TransitionCircle_SetEnvColor(void* thisx, u32 color); -void TransitionCircle_SetType(void* thisx, s32 type); -void TransitionCircle_Start(void* thisx); -void TransitionCircle_Update(void* thisx, s32 updateRate); -#endif + +void TransitionCircle_Destroy(void* pthisx); +void TransitionCircle_Draw(void* pthisx, Gfx** gfxP); +void* TransitionCircle_Init(void* pthisx); +s32 TransitionCircle_IsDone(void* pthisx); +void TransitionCircle_SetColor(void* pthisx, u32 color); +void TransitionCircle_SetEnvColor(void* pthisx, u32 color); +void TransitionCircle_SetType(void* pthisx, s32 type); +void TransitionCircle_Start(void* pthisx); +void TransitionCircle_Update(void* pthisx, s32 updateRate); diff --git a/include/def/z_fbdemo_fade.h b/include/def/z_fbdemo_fade.h index 77d17c876..31ac29e0d 100644 --- a/include/def/z_fbdemo_fade.h +++ b/include/def/z_fbdemo_fade.h @@ -1,20 +1,10 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FBDEMO_FADE_C -void TransitionFade_Destroy(void* this); -void TransitionFade_Draw(void* this, Gfx** gfxP); -void* TransitionFade_Init(void* this); -s32 TransitionFade_IsDone(void* this); -void TransitionFade_SetColor(void* this, u32 color); -void TransitionFade_SetType(void* this, s32 type); -void TransitionFade_Start(void* this); -void TransitionFade_Update(void* this, s32 updateRate); -#else -void TransitionFade_Destroy(void* this); -void TransitionFade_Draw(void* this, Gfx** gfxP); -void* TransitionFade_Init(void* this); -s32 TransitionFade_IsDone(void* this); -void TransitionFade_SetColor(void* this, u32 color); -void TransitionFade_SetType(void* this, s32 type); -void TransitionFade_Start(void* this); -void TransitionFade_Update(void* this, s32 updateRate); -#endif + +void TransitionFade_Destroy(void* pthis); +void TransitionFade_Draw(void* pthis, Gfx** gfxP); +void* TransitionFade_Init(void* pthis); +s32 TransitionFade_IsDone(void* pthis); +void TransitionFade_SetColor(void* pthis, u32 color); +void TransitionFade_SetType(void* pthis, s32 type); +void TransitionFade_Start(void* pthis); +void TransitionFade_Update(void* pthis, s32 updateRate); diff --git a/include/def/z_fbdemo_triforce.h b/include/def/z_fbdemo_triforce.h index 1bcb31091..d4c88500c 100644 --- a/include/def/z_fbdemo_triforce.h +++ b/include/def/z_fbdemo_triforce.h @@ -1,20 +1,10 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FBDEMO_TRIFORCE_C -void TransitionTriforce_Destroy(void* this); -void TransitionTriforce_Draw(void* this, Gfx** gfxP); -void* TransitionTriforce_Init(void* this); -s32 TransitionTriforce_IsDone(void* this); -void TransitionTriforce_SetColor(void* this, u32 color); -void TransitionTriforce_SetType(void* this, s32 type); -void TransitionTriforce_Start(void* this); -void TransitionTriforce_Update(void* this, s32 updateRate); -#else -void TransitionTriforce_Destroy(void* this); -void TransitionTriforce_Draw(void* this, Gfx** gfxP); -void* TransitionTriforce_Init(void* this); -s32 TransitionTriforce_IsDone(void* this); -void TransitionTriforce_SetColor(void* this, u32 color); -void TransitionTriforce_SetType(void* this, s32 type); -void TransitionTriforce_Start(void* this); -void TransitionTriforce_Update(void* this, s32 updateRate); -#endif + +void TransitionTriforce_Destroy(void* pthis); +void TransitionTriforce_Draw(void* pthis, Gfx** gfxP); +void* TransitionTriforce_Init(void* pthis); +s32 TransitionTriforce_IsDone(void* pthis); +void TransitionTriforce_SetColor(void* pthis, u32 color); +void TransitionTriforce_SetType(void* pthis, s32 type); +void TransitionTriforce_Start(void* pthis); +void TransitionTriforce_Update(void* pthis, s32 updateRate); diff --git a/include/def/z_fbdemo_wipe1.h b/include/def/z_fbdemo_wipe1.h index c74a83ca5..2f9f7d0fc 100644 --- a/include/def/z_fbdemo_wipe1.h +++ b/include/def/z_fbdemo_wipe1.h @@ -1,20 +1,10 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FBDEMO_WIPE1_C -void TransitionWipe_Destroy(void* this); -void TransitionWipe_Draw(void* this, Gfx** gfxP); -void* TransitionWipe_Init(void* this); -s32 TransitionWipe_IsDone(void* this); -void TransitionWipe_SetColor(void* this, u32 color); -void TransitionWipe_SetType(void* this, s32 type); -void TransitionWipe_Start(void* this); -void TransitionWipe_Update(void* this, s32 updateRate); -#else -void TransitionWipe_Destroy(void* this); -void TransitionWipe_Draw(void* this, Gfx** gfxP); -void* TransitionWipe_Init(void* this); -s32 TransitionWipe_IsDone(void* this); -void TransitionWipe_SetColor(void* this, u32 color); -void TransitionWipe_SetType(void* this, s32 type); -void TransitionWipe_Start(void* this); -void TransitionWipe_Update(void* this, s32 updateRate); -#endif + +void TransitionWipe_Destroy(void* pthis); +void TransitionWipe_Draw(void* pthis, Gfx** gfxP); +void* TransitionWipe_Init(void* pthis); +s32 TransitionWipe_IsDone(void* pthis); +void TransitionWipe_SetColor(void* pthis, u32 color); +void TransitionWipe_SetType(void* pthis, s32 type); +void TransitionWipe_Start(void* pthis); +void TransitionWipe_Update(void* pthis, s32 updateRate); diff --git a/include/def/z_fcurve_data_skelanime.h b/include/def/z_fcurve_data_skelanime.h index fd48ed3c2..a26a306fb 100644 --- a/include/def/z_fcurve_data_skelanime.h +++ b/include/def/z_fcurve_data_skelanime.h @@ -1,16 +1,13 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FCURVE_DATA_SKELANIME_C +struct SkelAnimeCurve; +struct GlobalContext; +struct Actor; +struct SkelCurveLimbList; +struct TransformUpdateIndex; + void SkelCurve_Clear(SkelAnimeCurve* skelCurve); void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data); s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx); void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -#else -void SkelCurve_Clear(struct SkelAnimeCurve* skelCurve); -void SkelCurve_Destroy(struct GlobalContext* globalCtx, struct SkelAnimeCurve* skelCurve); -void SkelCurve_Draw(struct Actor* actor, struct GlobalContext* globalCtx, struct SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data); -s32 SkelCurve_Init(struct GlobalContext* globalCtx, struct SkelAnimeCurve* skelCurve, struct SkelCurveLimbList* limbListSeg, struct TransformUpdateIndex* transUpdIdx); -void SkelCurve_SetAnim(struct SkelAnimeCurve* skelCurve, struct TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); -s32 SkelCurve_Update(struct GlobalContext* globalCtx, struct SkelAnimeCurve* skelCurve); -#endif diff --git a/include/def/z_file_choose.h b/include/def/z_file_choose.h index ea4ef11dd..34df90ce6 100644 --- a/include/def/z_file_choose.h +++ b/include/def/z_file_choose.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_FILE_CHOOSE_Z_FILE_CHOOSE_C -void FileChoose_Destroy(GameState* thisx); -void FileChoose_Init(GameState* thisx); -#else -void FileChoose_Destroy(struct GameState* thisx); -void FileChoose_Init(struct GameState* thisx); -#endif +struct GameState; + +void FileChoose_Destroy(GameState* pthisx); +void FileChoose_Init(GameState* pthisx); diff --git a/include/def/z_frame_advance.h b/include/def/z_frame_advance.h index 0ed592606..cccb7fd05 100644 --- a/include/def/z_frame_advance.h +++ b/include/def/z_frame_advance.h @@ -1,8 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_FRAME_ADVANCE_C +struct FrameAdvanceContext; +struct Input; + void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); -#else -void FrameAdvance_Init(struct FrameAdvanceContext* frameAdvCtx); -s32 FrameAdvance_Update(struct FrameAdvanceContext* frameAdvCtx, struct Input* input); -#endif diff --git a/include/def/z_game_dlftbls.h b/include/def/z_game_dlftbls.h index b8a391199..5dd795f86 100644 --- a/include/def/z_game_dlftbls.h +++ b/include/def/z_game_dlftbls.h @@ -1,3 +1,4 @@ #pragma once +struct GameStateOverlay; extern GameStateOverlay gGameStateOverlayTable[6]; diff --git a/include/def/z_game_over.h b/include/def/z_game_over.h index c4b077761..424e3bafb 100644 --- a/include/def/z_game_over.h +++ b/include/def/z_game_over.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_GAME_OVER_C +struct GlobalContext; + void GameOver_FadeInLights(GlobalContext* globalCtx); void GameOver_Init(GlobalContext* globalCtx); void GameOver_Update(GlobalContext* globalCtx); -#else -void GameOver_FadeInLights(struct GlobalContext* globalCtx); -void GameOver_Init(struct GlobalContext* globalCtx); -void GameOver_Update(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_horse.h b/include/def/z_horse.h index 636dd8e0f..1a4ed6e13 100644 --- a/include/def/z_horse.h +++ b/include/def/z_horse.h @@ -1,5 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_HORSE_C +struct GlobalContext; +struct Player; +struct Actor; +struct Vec3f; + s32 func_8006CFC0(s32 scene); void func_8006D074(GlobalContext* globalCtx); void func_8006D0AC(GlobalContext* globalCtx); @@ -7,12 +11,3 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player); void func_8006D684(GlobalContext* globalCtx, Player* player); void func_8006DC68(GlobalContext* globalCtx, Player* player); void func_8006DD9C(Actor* actor, Vec3f* arg1, s16 arg2); -#else -s32 func_8006CFC0(s32 scene); -void func_8006D074(struct GlobalContext* globalCtx); -void func_8006D0AC(struct GlobalContext* globalCtx); -void func_8006D0EC(struct GlobalContext* globalCtx, struct Player* player); -void func_8006D684(struct GlobalContext* globalCtx, struct Player* player); -void func_8006DC68(struct GlobalContext* globalCtx, struct Player* player); -void func_8006DD9C(struct Actor* actor, struct Vec3f* arg1, s16 arg2); -#endif diff --git a/include/def/z_kaleido_manager.h b/include/def/z_kaleido_manager.h index 19924719d..6b6e4295a 100644 --- a/include/def/z_kaleido_manager.h +++ b/include/def/z_kaleido_manager.h @@ -1,19 +1,13 @@ #pragma once +struct KaleidoMgrOverlay; +struct GlobalContext; extern u8 gBossMarkState; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[KALEIDO_OVL_MAX]; -#ifdef INTERNAL_SRC_CODE_Z_KALEIDO_MANAGER_C void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl); void KaleidoManager_Destroy(); void* KaleidoManager_GetRamAddr(void* vram); void KaleidoManager_Init(GlobalContext* globalCtx); void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl); -#else -void KaleidoManager_ClearOvl(struct KaleidoMgrOverlay* ovl); -void KaleidoManager_Destroy(void); -void* KaleidoManager_GetRamAddr(void* vram); -void KaleidoManager_Init(struct GlobalContext* globalCtx); -void KaleidoManager_LoadOvl(struct KaleidoMgrOverlay* ovl); -#endif diff --git a/include/def/z_kaleido_scope_call.h b/include/def/z_kaleido_scope_call.h index 6fb3f53f2..a78c16d73 100644 --- a/include/def/z_kaleido_scope_call.h +++ b/include/def/z_kaleido_scope_call.h @@ -1,18 +1,11 @@ #pragma once +struct GlobalContext; extern f32 gBossMarkScale; extern PauseMapMarksData* gLoadedPauseMarkDataTable; -#ifdef INTERNAL_SRC_CODE_Z_KALEIDO_SCOPE_CALL_C void KaleidoScopeCall_Destroy(GlobalContext* globalCtx); void KaleidoScopeCall_Draw(GlobalContext* globalCtx); void KaleidoScopeCall_Init(GlobalContext* globalCtx); void KaleidoScopeCall_LoadPlayer(); void KaleidoScopeCall_Update(GlobalContext* globalCtx); -#else -void KaleidoScopeCall_Destroy(struct GlobalContext* globalCtx); -void KaleidoScopeCall_Draw(struct GlobalContext* globalCtx); -void KaleidoScopeCall_Init(struct GlobalContext* globalCtx); -void KaleidoScopeCall_LoadPlayer(void); -void KaleidoScopeCall_Update(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_kaleido_setup.h b/include/def/z_kaleido_setup.h index fd9807bd4..fda2011dc 100644 --- a/include/def/z_kaleido_setup.h +++ b/include/def/z_kaleido_setup.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_KALEIDO_SETUP_C +struct GlobalContext; + void KaleidoSetup_Destroy(GlobalContext* globalCtx); void KaleidoSetup_Init(GlobalContext* globalCtx); void KaleidoSetup_Update(GlobalContext* globalCtx); -#else -void KaleidoSetup_Destroy(struct GlobalContext* globalCtx); -void KaleidoSetup_Init(struct GlobalContext* globalCtx); -void KaleidoSetup_Update(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_kanfont.h b/include/def/z_kanfont.h index bb86e0134..b548c41c8 100644 --- a/include/def/z_kanfont.h +++ b/include/def/z_kanfont.h @@ -1,12 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_KANFONT_C +struct Font; + void Font_LoadChar(Font* font, u8 character, u16 codePointIndex); void Font_LoadMessageBoxIcon(Font* font, u16 icon); void Font_LoadOrderedFont(Font* font); void func_8006EE50(Font* font, u16 arg1, u16 arg2); -#else -void Font_LoadChar(struct Font* font, u8 character, u16 codePointIndex); -void Font_LoadMessageBoxIcon(struct Font* font, u16 icon); -void Font_LoadOrderedFont(struct Font* font); -void func_8006EE50(struct Font* font, u16 arg1, u16 arg2); -#endif diff --git a/include/def/z_kankyo.h b/include/def/z_kankyo.h index 3df00cb7f..e84b5f175 100644 --- a/include/def/z_kankyo.h +++ b/include/def/z_kankyo.h @@ -1,4 +1,17 @@ #pragma once +struct GlobalContext; +struct EnvironmentContext; +struct View; +struct GraphicsContext; +struct Vec3f; +struct LightContext; +struct PauseContext; +struct MessageContext; +struct GameOverContext; +struct SkyboxContext; +struct struct_8011FC1C; +struct LightningStrike; +struct SkyboxFile; extern u8 D_8011FB34; extern u8 D_8011FB38; @@ -14,7 +27,6 @@ extern SkyboxFile gSkyboxFiles[]; extern u16 gTimeIncrement; extern u8 gWeatherMode; -#ifdef INTERNAL_SRC_CODE_Z_KANKYO_C void Environment_AddLightningBolts(GlobalContext* globalCtx, u8 num); void Environment_AdjustLights(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4); void Environment_ClearBgsDayCount(void); @@ -52,42 +64,3 @@ void func_80074CE8(GlobalContext* globalCtx, u32 arg1); void func_800758AC(GlobalContext* globalCtx); void func_80077624(GlobalContext* globalCtx); void func_80077684(GlobalContext* globalCtx); -#else -void Environment_AddLightningBolts(struct GlobalContext* globalCtx, u8 num); -void Environment_AdjustLights(struct GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4); -void Environment_ClearBgsDayCount(void); -void Environment_DisableUnderwaterLights(struct GlobalContext* globalCtx); -void Environment_DrawCustomLensFlare(struct GlobalContext* globalCtx); -void Environment_DrawLensFlare(struct GlobalContext* globalCtx, struct EnvironmentContext* envCtx, struct View* view, struct GraphicsContext* gfxCtx, struct Vec3f pos, s32 unused, s16 arg6, f32 arg7, s16 arg8, u8 arg9); -void Environment_DrawLightning(struct GlobalContext* globalCtx, s32 unused); -void Environment_DrawRain(struct GlobalContext* globalCtx, struct View* view, struct GraphicsContext* gfxCtx); -void Environment_DrawSandstorm(struct GlobalContext* globalCtx, u8 sandstormState); -void Environment_DrawSkyboxFilters(struct GlobalContext* globalCtx); -void Environment_DrawSunAndMoon(struct GlobalContext* globalCtx); -void Environment_DrawSunLensFlare(struct GlobalContext* globalCtx, struct EnvironmentContext* envCtx, struct View* view, struct GraphicsContext* gfxCtx, struct Vec3f pos, s32 unused); -void Environment_EnableUnderwaterLights(struct GlobalContext* globalCtx, s32 waterLightsIndex); -void Environment_FadeInGameOverLights(struct GlobalContext* globalCtx); -void Environment_FadeOutGameOverLights(struct GlobalContext* globalCtx); -void Environment_FillScreen(struct GraphicsContext* gfxCtx, u8 red, u8 green, u8 blue, u8 alpha, u8 drawFlags); -void Environment_ForcePlaySequence(u16); -s32 Environment_GetBgsDayCount(void); -u16 Environment_GetPixelDepth(s32 x, s32 y); -s32 Environment_GetTotalDays(void); -void Environment_GraphCallback(struct GraphicsContext* gfxCtx, void* param); -void Environment_Init(struct GlobalContext* globalCtx, struct EnvironmentContext* envCtx, s32 unused); -void Environment_InitGameOverLights(struct GlobalContext* globalCtx); -s32 Environment_IsForcedSequenceDisabled(void); -f32 Environment_LerpWeight(u16 max, u16 min, u16 val); -f32 Environment_LerpWeightAccelDecel(u16 endFrame, u16 startFrame, u16 curFrame, u16 accelDuration, u16 decelDuration); -u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minStep); -u8 Environment_SmoothStepToU8(u8* pvalue, u8 target, u8 scale, u8 step, u8 minStep); -void Environment_Update(struct GlobalContext* globalCtx, struct EnvironmentContext* envCtx, struct LightContext* lightCtx, struct PauseContext* pauseCtx, struct MessageContext* msgCtx, struct GameOverContext* gameOverCtx, struct GraphicsContext* gfxCtx); -void Environment_UpdateLightningStrike(struct GlobalContext* globalCtx); -void Environment_UpdateSkybox(u8 skyboxId, struct EnvironmentContext* envCtx, struct SkyboxContext* skyboxCtx); -void Environment_WarpSongLeave(struct GlobalContext* globalCtx); -s32 func_8006F0A0(s32 arg0); -void func_80074CE8(struct GlobalContext* globalCtx, u32 arg1); -void func_800758AC(struct GlobalContext* globalCtx); -void func_80077624(struct GlobalContext* globalCtx); -void func_80077684(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_lib.h b/include/def/z_lib.h index b0ff5ee45..57a54cdb1 100644 --- a/include/def/z_lib.h +++ b/include/def/z_lib.h @@ -1,5 +1,11 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_LIB_C +struct Actor; +struct InitChainEntry; +struct Color_RGBA8; +struct Vec3f; +struct Vec3s; +struct Input; + void Actor_ProcessInitChain(Actor* actor, InitChainEntry* initChain); void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void Lib_MemSet(u8* dest, size_t size, u8 val); @@ -35,40 +41,3 @@ void func_80077D10(f32* arg0, s16* arg1, Input* input); void func_80078884(u16 sfxId); void func_800788CC(u16 sfxId); void func_80078914(Vec3f* arg0, u16 sfxId); -#else -void Actor_ProcessInitChain(struct Actor* actor, struct InitChainEntry* initChain); -void Color_RGBA8_Copy(struct Color_RGBA8* dst, struct Color_RGBA8* src); -void Lib_MemSet(u8* dest, size_t size, u8 val); -void Math_ApproachF(f32* pValue, f32 target, f32 fraction, f32 step); -void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 step); -void Math_ApproachZeroF(f32* pValue, f32 fraction, f32 step); -s32 Math_AsymStepToF(f32* pValue, f32 target, f32 incrStep, f32 decrStep); -f32 Math_CosS(s16 angle); -s32 Math_ScaledStepToS(s16* pValue, s16 target, s16 step); -f32 Math_SinS(s16 angle); -f32 Math_SmoothStepToDegF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); -f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); -s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); -s32 Math_StepToAngleS(s16* pValue, s16 target, s16 step); -s32 Math_StepToF(f32* pValue, f32 target, f32 step); -s32 Math_StepToS(s16* pValue, s16 target, s16 step); -s32 Math_StepUntilAngleS(s16* pValue, s16 limit, s16 step); -s32 Math_StepUntilF(f32* pValue, f32 limit, f32 step); -s32 Math_StepUntilS(s16* pValue, s16 limit, s16 step); -void Math_Vec3f_Copy(struct Vec3f* dest, struct Vec3f* src); -void Math_Vec3f_Diff(struct Vec3f* a, struct Vec3f* b, struct Vec3f* dest); -f32 Math_Vec3f_DistXYZ(struct Vec3f* a, struct Vec3f* b); -f32 Math_Vec3f_DistXYZAndStoreDiff(struct Vec3f* a, struct Vec3f* b, struct Vec3f* dest); -f32 Math_Vec3f_DistXZ(struct Vec3f* a, struct Vec3f* b); -s16 Math_Vec3f_Pitch(struct Vec3f* a, struct Vec3f* b); -void Math_Vec3f_Scale(struct Vec3f* vec, f32 scaleF); -void Math_Vec3f_Sum(struct Vec3f* a, struct Vec3f* b, struct Vec3f* dest); -s16 Math_Vec3f_Yaw(struct Vec3f* a, struct Vec3f* b); -void Math_Vec3s_DiffToVec3f(struct Vec3f* dest, struct Vec3s* a, struct Vec3s* b); -void Math_Vec3s_ToVec3f(struct Vec3f* dest, struct Vec3s* src); -s16 Rand_S16Offset(s16 base, s16 range); -void func_80077D10(f32* arg0, s16* arg1, struct Input* input); -void func_80078884(u16 sfxId); -void func_800788CC(u16 sfxId); -void func_80078914(struct Vec3f* arg0, u16 sfxId); -#endif diff --git a/include/def/z_lifemeter.h b/include/def/z_lifemeter.h index 5f3a28d58..f1ad3b366 100644 --- a/include/def/z_lifemeter.h +++ b/include/def/z_lifemeter.h @@ -1,14 +1,8 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_LIFEMETER_C +struct GlobalContext; + void HealthMeter_Draw(GlobalContext* globalCtx); -void HealthMeter_UpdateBeatingHeart(GlobalContext* globalCtx); void HealthMeter_Init(GlobalContext* globalCtx); u32 HealthMeter_IsCritical(void); void HealthMeter_Update(GlobalContext* globalCtx); -#else -void HealthMeter_Draw(struct GlobalContext* globalCtx); -void HealthMeter_UpdateBeatingHeart(struct GlobalContext* globalCtx); -void HealthMeter_Init(struct GlobalContext* globalCtx); -u32 HealthMeter_IsCritical(void); -void HealthMeter_Update(struct GlobalContext* globalCtx); -#endif +void HealthMeter_UpdateBeatingHeart(GlobalContext* globalCtx); diff --git a/include/def/z_lights.h b/include/def/z_lights.h index 9d3633083..e9359c298 100644 --- a/include/def/z_lights.h +++ b/include/def/z_lights.h @@ -1,5 +1,12 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_LIGHTS_C +struct GlobalContext; +struct LightContext; +struct LightInfo; +struct LightNode; +struct GraphicsContext; +struct Lights; +struct Vec3f; + void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx); void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx); void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx); @@ -20,25 +27,3 @@ void Lights_PointNoGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, void Lights_PointSetColorAndRadius(LightInfo* info, u8 r, u8 g, u8 b, s16 radius); void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type); void Lights_Reset(Lights* lights, u8 ambentR, u8 ambentG, u8 ambentB); -#else -void LightContext_DestroyList(struct GlobalContext* globalCtx, struct LightContext* lightCtx); -void LightContext_Init(struct GlobalContext* globalCtx, struct LightContext* lightCtx); -void LightContext_InitList(struct GlobalContext* globalCtx, struct LightContext* lightCtx); -struct LightNode* LightContext_InsertLight(struct GlobalContext* globalCtx, struct LightContext* lightCtx, struct LightInfo* info); -struct Lights* LightContext_NewLights(struct LightContext* lightCtx, struct GraphicsContext* gfxCtx); -void LightContext_RemoveLight(struct GlobalContext* globalCtx, struct LightContext* lightCtx, struct LightNode* node); -void LightContext_SetAmbientColor(struct LightContext* lightCtx, u8 r, u8 g, u8 b); -void LightContext_SetFog(struct LightContext* lightCtx, u8 arg1, u8 arg2, u8 arg3, s16 numLights, s16 arg5); -void Lights_BindAll(struct Lights* lights, struct LightNode* listHead, struct Vec3f* vec); -void Lights_DirectionalSetInfo(struct LightInfo* info, s8 x, s8 y, s8 z, u8 r, u8 g, u8 b); -void Lights_Draw(struct Lights* lights, struct GraphicsContext* gfxCtx); -void Lights_DrawGlow(struct GlobalContext* globalCtx); -void Lights_GlowCheck(struct GlobalContext* globalCtx); -struct Lights* Lights_New(struct GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB); -struct Lights* Lights_NewAndDraw(struct GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB, u8 numLights, u8 r, u8 g, u8 b, s8 x, s8 y, s8 z); -void Lights_PointGlowSetInfo(struct LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); -void Lights_PointNoGlowSetInfo(struct LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); -void Lights_PointSetColorAndRadius(struct LightInfo* info, u8 r, u8 g, u8 b, s16 radius); -void Lights_PointSetInfo(struct LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type); -void Lights_Reset(struct Lights* lights, u8 ambentR, u8 ambentG, u8 ambentB); -#endif diff --git a/include/def/z_malloc.h b/include/def/z_malloc.h index 2eef24391..a089b3db2 100644 --- a/include/def/z_malloc.h +++ b/include/def/z_malloc.h @@ -2,7 +2,6 @@ extern s32 gZeldaArenaLogSeverity; -#ifdef INTERNAL_SRC_CODE_Z_MALLOC_C void* ZeldaArena_Calloc(u32 num, u32 size); void ZeldaArena_Check(); void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); @@ -19,21 +18,3 @@ void* ZeldaArena_MallocR(u32 size); void* ZeldaArena_MallocRDebug(u32 size, const char* file, s32 line); void* ZeldaArena_Realloc(void* ptr, u32 newSize); void* ZeldaArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); -#else -void* ZeldaArena_Calloc(u32 num, u32 size); -void ZeldaArena_Check(void); -void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); -void ZeldaArena_Cleanup(void); -void ZeldaArena_Display(void); -void ZeldaArena_Free(void* ptr); -void ZeldaArena_FreeDebug(void* ptr, const char* file, s32 line); -void ZeldaArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc); -void ZeldaArena_Init(void* start, u32 size); -u8 ZeldaArena_IsInitalized(void); -void* ZeldaArena_Malloc(u32 size); -void* ZeldaArena_MallocDebug(u32 size, const char* file, s32 line); -void* ZeldaArena_MallocR(u32 size); -void* ZeldaArena_MallocRDebug(u32 size, const char* file, s32 line); -void* ZeldaArena_Realloc(void* ptr, u32 newSize); -void* ZeldaArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); -#endif diff --git a/include/def/z_map_data.h b/include/def/z_map_data.h index 9eed79980..1228ad655 100644 --- a/include/def/z_map_data.h +++ b/include/def/z_map_data.h @@ -1,3 +1,4 @@ #pragma once +struct MapData; extern MapData gMapDataTable; diff --git a/include/def/z_map_exp.h b/include/def/z_map_exp.h index 91f0562d2..c481e41d7 100644 --- a/include/def/z_map_exp.h +++ b/include/def/z_map_exp.h @@ -1,8 +1,9 @@ #pragma once +struct GlobalContext; +struct MapData; -//extern MapData* gMapData; +extern MapData* gMapData; -#ifdef INTERNAL_SRC_CODE_Z_MAP_EXP_C void Map_Destroy(GlobalContext* globalCtx); void Map_Init(GlobalContext* globalCtx); void Map_InitData(GlobalContext* globalCtx, s16 room); @@ -11,13 +12,3 @@ void Map_SavePlayerInitialInfo(GlobalContext* globalCtx); void Map_SetFloorPalettesData(GlobalContext* globalCtx, s16 floor); void Map_Update(GlobalContext* globalCtx); void Minimap_Draw(GlobalContext* globalCtx); -#else -void Map_Destroy(struct GlobalContext* globalCtx); -void Map_Init(struct GlobalContext* globalCtx); -void Map_InitData(struct GlobalContext* globalCtx, s16 room); -void Map_InitRoomData(struct GlobalContext* globalCtx, s16 room); -void Map_SavePlayerInitialInfo(struct GlobalContext* globalCtx); -void Map_SetFloorPalettesData(struct GlobalContext* globalCtx, s16 floor); -void Map_Update(struct GlobalContext* globalCtx); -void Minimap_Draw(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_map_mark.h b/include/def/z_map_mark.h index 6360869f6..f641105e2 100644 --- a/include/def/z_map_mark.h +++ b/include/def/z_map_mark.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_MAP_MARK_C +struct GlobalContext; + void MapMark_ClearPointers(GlobalContext* globalCtx); void MapMark_Draw(GlobalContext* globalCtx); void MapMark_Init(GlobalContext* globalCtx); -#else -void MapMark_ClearPointers(struct GlobalContext* globalCtx); -void MapMark_Draw(struct GlobalContext* globalCtx); -void MapMark_Init(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_message_PAL.h b/include/def/z_message_PAL.h index 637d1b309..909ce22dc 100644 --- a/include/def/z_message_PAL.h +++ b/include/def/z_message_PAL.h @@ -1,8 +1,10 @@ #pragma once +struct GlobalContext; +struct MessageContext; +struct Actor; extern s16 gOcarinaSongItemMap[]; -#ifdef INTERNAL_SRC_CODE_Z_MESSAGE_PAL_C void Message_CloseTextbox(GlobalContext*); void Message_ContinueTextbox(GlobalContext* globalCtx, u16 textId); void Message_Draw(GlobalContext* globalCtx); @@ -14,16 +16,3 @@ void Message_Update(GlobalContext* globalCtx); void Message_UpdateOcarinaGame(GlobalContext* globalCtx); void func_8010BD58(GlobalContext* globalCtx, u16 arg1); void func_8010BD88(GlobalContext* globalCtx, u16 arg1); -#else -void Message_CloseTextbox(struct GlobalContext*); -void Message_ContinueTextbox(struct GlobalContext* globalCtx, u16 textId); -void Message_Draw(struct GlobalContext* globalCtx); -u8 Message_GetState(struct MessageContext* msgCtx); -void Message_SetTables(void); -u8 Message_ShouldAdvance(struct GlobalContext* globalCtx); -void Message_StartTextbox(struct GlobalContext* globalCtx, u16 textId, struct Actor* actor); -void Message_Update(struct GlobalContext* globalCtx); -void Message_UpdateOcarinaGame(struct GlobalContext* globalCtx); -void func_8010BD58(struct GlobalContext* globalCtx, u16 arg1); -void func_8010BD88(struct GlobalContext* globalCtx, u16 arg1); -#endif diff --git a/include/def/z_msgevent.h b/include/def/z_msgevent.h index 49ffef5a5..4d9fd0dc6 100644 --- a/include/def/z_msgevent.h +++ b/include/def/z_msgevent.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_MSGEVENT_C + void MsgEvent_SendNullTask(void); -#else -void MsgEvent_SendNullTask(void); -#endif diff --git a/include/def/z_olib.h b/include/def/z_olib.h index 4337d3378..8d4389e4c 100644 --- a/include/def/z_olib.h +++ b/include/def/z_olib.h @@ -1,5 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_OLIB_C +struct Vec3f; +struct VecSph; + f32 OLib_ClampMaxDist(f32 val, f32 max); f32 OLib_ClampMinDist(f32 val, f32 min); Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b); @@ -10,15 +12,3 @@ f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec); VecSph* OLib_Vec3fToVecSphGeo(VecSph* arg0, Vec3f* arg1); Vec3f* OLib_VecSphGeoToVec3f(Vec3f* dest, VecSph* sph); -#else -f32 OLib_ClampMaxDist(f32 val, f32 max); -f32 OLib_ClampMinDist(f32 val, f32 min); -struct Vec3f* OLib_Vec3fDiffRad(struct Vec3f* dest, struct Vec3f* a, struct Vec3f* b); -struct VecSph* OLib_Vec3fDiffToVecSphGeo(struct VecSph* arg0, struct Vec3f* a, struct Vec3f* b); -f32 OLib_Vec3fDist(struct Vec3f* a, struct Vec3f* b); -struct Vec3f* OLib_Vec3fDistNormalize(struct Vec3f* dest, struct Vec3f* a, struct Vec3f* b); -f32 OLib_Vec3fDistXZ(struct Vec3f* a, struct Vec3f* b); -struct VecSph* OLib_Vec3fToVecSph(struct VecSph* dest, struct Vec3f* vec); -struct VecSph* OLib_Vec3fToVecSphGeo(struct VecSph* arg0, struct Vec3f* arg1); -struct Vec3f* OLib_VecSphGeoToVec3f(struct Vec3f* dest, struct VecSph* sph); -#endif diff --git a/include/def/z_onepointdemo.h b/include/def/z_onepointdemo.h index d8d100ba2..4fa6eb71a 100644 --- a/include/def/z_onepointdemo.h +++ b/include/def/z_onepointdemo.h @@ -1,5 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_ONEPOINTDEMO_C +struct GlobalContext; +struct Actor; + s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor); s32 OnePointCutscene_AttentionSetSfx(GlobalContext* globalCtx, Actor* actor, s32 sfxId); s32 OnePointCutscene_CheckForCategory(GlobalContext* globalCtx, s32 actorCategory); @@ -8,13 +10,3 @@ void OnePointCutscene_EnableAttention(void); s16 OnePointCutscene_EndCutscene(GlobalContext* globalCtx, s16 camIdx); s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* actor, s16 camIdx); void OnePointCutscene_Noop(GlobalContext* globalCtx, s32 arg1); -#else -s32 OnePointCutscene_Attention(struct GlobalContext* globalCtx, struct Actor* actor); -s32 OnePointCutscene_AttentionSetSfx(struct GlobalContext* globalCtx, struct Actor* actor, s32 sfxId); -s32 OnePointCutscene_CheckForCategory(struct GlobalContext* globalCtx, s32 actorCategory); -void OnePointCutscene_DisableAttention(void); -void OnePointCutscene_EnableAttention(void); -s16 OnePointCutscene_EndCutscene(struct GlobalContext* globalCtx, s16 camIdx); -s16 OnePointCutscene_Init(struct GlobalContext* globalCtx, s16 csId, s16 timer, struct Actor* actor, s16 camIdx); -void OnePointCutscene_Noop(struct GlobalContext* globalCtx, s32 arg1); -#endif diff --git a/include/def/z_opening.h b/include/def/z_opening.h index de41b7cee..487cbb2d9 100644 --- a/include/def/z_opening.h +++ b/include/def/z_opening.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_OPENING_Z_OPENING_C -void Opening_Destroy(GameState* thisx); -void Opening_Init(GameState* thisx); -#else -void Opening_Destroy(struct GameState* thisx); -void Opening_Init(struct GameState* thisx); -#endif +struct GameState; + +void Opening_Destroy(GameState* pthisx); +void Opening_Init(GameState* pthisx); diff --git a/include/def/z_parameter.h b/include/def/z_parameter.h index f8dfe9d72..99be98eb4 100644 --- a/include/def/z_parameter.h +++ b/include/def/z_parameter.h @@ -1,9 +1,9 @@ #pragma once +struct GlobalContext; extern s16 gSpoilingItemReverts[3]; extern s16 gSpoilingItems[3]; -#ifdef INTERNAL_SRC_CODE_Z_PARAMETER_C s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange); void Interface_ChangeAlpha(u16 alphaType); void Interface_Draw(GlobalContext* globalCtx); @@ -34,35 +34,3 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2); void func_80088AA0(s16 seconds); void func_80088AF0(GlobalContext* globalCtx); void func_80088B34(s16 arg0); -#else -s32 Health_ChangeBy(struct GlobalContext* globalCtx, s16 healthChange); -void Interface_ChangeAlpha(u16 alphaType); -void Interface_Draw(struct GlobalContext* globalCtx); -void Interface_InitHorsebackArchery(struct GlobalContext* globalCtx); -void Interface_LoadActionLabelB(struct GlobalContext* globalCtx, u16 action); -void Interface_LoadItemIcon1(struct GlobalContext* globalCtx, u16 button); -void Interface_LoadItemIcon2(struct GlobalContext* globalCtx, u16 button); -void Interface_SetDoAction(struct GlobalContext* globalCtx, u16 action); -void Interface_SetNaviCall(struct GlobalContext* globalCtx, u16 naviCallState); -void Interface_SetSceneRestrictions(struct GlobalContext* globalCtx); -void Interface_Update(struct GlobalContext* globalCtx); -void Inventory_ChangeAmmo(s16 item, s16 ammoChange); -s32 Inventory_ConsumeFairy(struct GlobalContext* globalCtx); -void Inventory_DeleteItem(u16 item, u16 invSlot); -s32 Inventory_HasEmptyBottle(void); -s32 Inventory_HasSpecificBottle(u8 bottleItem); -s32 Inventory_ReplaceItem(struct GlobalContext* globalCtx, u16 oldItem, u16 newItem); -void Inventory_SwapAgeEquipment(void); -void Inventory_UpdateBottleItem(struct GlobalContext* globalCtx, u8 item, u8 cButton); -u8 Item_CheckObtainability(u8 item); -u8 Item_Give(struct GlobalContext* globalCtx, u8 item); -void Magic_Fill(struct GlobalContext* globalCtx); -void Rupees_ChangeBy(s16 rupeeChange); -void func_800849EC(struct GlobalContext* globalCtx); -void func_80084BF4(struct GlobalContext* globalCtx, u16 flag); -void func_800876C8(struct GlobalContext* globalCtx); -s32 func_80087708(struct GlobalContext* globalCtx, s16 arg1, s16 arg2); -void func_80088AA0(s16 seconds); -void func_80088AF0(struct GlobalContext* globalCtx); -void func_80088B34(s16 arg0); -#endif diff --git a/include/def/z_path.h b/include/def/z_path.h index 153334060..f164e9afd 100644 --- a/include/def/z_path.h +++ b/include/def/z_path.h @@ -1,10 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_PATH_C +struct Path; +struct Vec3f; +struct GlobalContext; +struct Actor; + void Path_CopyLastPoint(Path* path, Vec3f* dest); Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); -#else -void Path_CopyLastPoint(struct Path* path, struct Vec3f* dest); -struct Path* Path_GetByIndex(struct GlobalContext* globalCtx, s16 index, s16 max); -f32 Path_OrientAndGetDistSq(struct Actor* actor, struct Path* path, s16 waypoint, s16* yaw); -#endif diff --git a/include/def/z_play.h b/include/def/z_play.h index 18f5e2e33..64cb1061c 100644 --- a/include/def/z_play.h +++ b/include/def/z_play.h @@ -1,10 +1,16 @@ #pragma once +struct GlobalContext; +struct Vec3f; +struct GameState; +struct Camera; +struct RomFile; +struct Player; +struct Actor; extern void* D_8012D1F0; extern Color_RGBA8_u32 D_801614B0; extern s32 gTrnsnUnkState; -#ifdef INTERNAL_SRC_CODE_Z_PLAY_C s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx); s32 Gameplay_CameraChangeSetting(GlobalContext* globalCtx, s16 camId, s16 arg2); s32 Gameplay_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); @@ -15,13 +21,13 @@ void Gameplay_ClearAllSubCameras(GlobalContext* globalCtx); void Gameplay_ClearCamera(GlobalContext* globalCtx, s16 camId); void Gameplay_CopyCamera(GlobalContext* globalCtx, s16 camId1, s16 camId2); s16 Gameplay_CreateSubCamera(GlobalContext* globalCtx); -void Gameplay_Destroy(GameState* thisx); +void Gameplay_Destroy(GameState* pthisx); s16 Gameplay_GetActiveCamId(GlobalContext* globalCtx); Camera* Gameplay_GetCamera(GlobalContext* globalCtx, s16 camId); s32 Gameplay_InCsMode(GlobalContext* globalCtx); -void Gameplay_Init(GameState* thisx); +void Gameplay_Init(GameState* pthisx); void* Gameplay_LoadFile(GlobalContext* globalCtx, RomFile* file); -void Gameplay_Main(GameState* thisx); +void Gameplay_Main(GameState* pthisx); void Gameplay_SaveSceneFlags(GlobalContext* globalCtx); s32 Gameplay_SetCameraRoll(GlobalContext* globalCtx, s16 camId, s16 roll); Gfx* Gameplay_SetFog(GlobalContext* globalCtx, Gfx* gfx); @@ -40,40 +46,3 @@ void func_800C08AC(GlobalContext* globalCtx, s16 camId, s16 arg2); s32 func_800C0CB8(GlobalContext* globalCtx); s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw); s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* pos); -#else -s32 FrameAdvance_IsEnabled(struct GlobalContext* globalCtx); -s32 Gameplay_CameraChangeSetting(struct GlobalContext* globalCtx, s16 camId, s16 arg2); -s32 Gameplay_CameraSetAtEye(struct GlobalContext* globalCtx, s16 camId, struct Vec3f* at, struct Vec3f* eye); -s32 Gameplay_CameraSetAtEyeUp(struct GlobalContext* globalCtx, s16 camId, struct Vec3f* at, struct Vec3f* eye, struct Vec3f* up); -s32 Gameplay_CameraSetFov(struct GlobalContext* globalCtx, s16 camId, f32 fov); -s16 Gameplay_ChangeCameraStatus(struct GlobalContext* globalCtx, s16 camId, s16 status); -void Gameplay_ClearAllSubCameras(struct GlobalContext* globalCtx); -void Gameplay_ClearCamera(struct GlobalContext* globalCtx, s16 camId); -void Gameplay_CopyCamera(struct GlobalContext* globalCtx, s16 camId1, s16 camId2); -s16 Gameplay_CreateSubCamera(struct GlobalContext* globalCtx); -void Gameplay_Destroy(struct GameState* thisx); -s16 Gameplay_GetActiveCamId(struct GlobalContext* globalCtx); -struct Camera* Gameplay_GetCamera(struct GlobalContext* globalCtx, s16 camId); -s32 Gameplay_InCsMode(struct GlobalContext* globalCtx); -void Gameplay_Init(struct GameState* thisx); -void* Gameplay_LoadFile(struct GlobalContext* globalCtx, struct RomFile* file); -void Gameplay_Main(struct GameState* thisx); -void Gameplay_SaveSceneFlags(struct GlobalContext* globalCtx); -s32 Gameplay_SetCameraRoll(struct GlobalContext* globalCtx, s16 camId, s16 roll); -Gfx* Gameplay_SetFog(struct GlobalContext* globalCtx, Gfx* gfx); -void Gameplay_SetupRespawnPoint(struct GlobalContext* globalCtx, s32 respawnMode, s32 playerParams); -void Gameplay_SpawnScene(struct GlobalContext* globalCtx, s32 sceneNum, s32 spawn); -void Gameplay_TriggerRespawn(struct GlobalContext* globalCtx); -void Gameplay_TriggerVoidOut(struct GlobalContext* globalCtx); -void func_800BC490(struct GlobalContext* globalCtx, s16 point); -s32 func_800BC56C(struct GlobalContext* globalCtx, s16 arg1); -void func_800BC590(struct GlobalContext* globalCtx); -void func_800BC5E0(struct GlobalContext* globalCtx, s32 arg1); -f32 func_800BFCB8(struct GlobalContext* globalCtx, MtxF* mf, struct Vec3f* vec); -void func_800C016C(struct GlobalContext* globalCtx, struct Vec3f* src, struct Vec3f* dest); -s32 func_800C0808(struct GlobalContext* globalCtx, s16 camId, struct Player* player, s16 arg3); -void func_800C08AC(struct GlobalContext* globalCtx, s16 camId, s16 arg2); -s32 func_800C0CB8(struct GlobalContext* globalCtx); -s32 func_800C0D34(struct GlobalContext* globalCtx, struct Actor* actor, s16* yaw); -s32 func_800C0DB4(struct GlobalContext* globalCtx, struct Vec3f* pos); -#endif diff --git a/include/def/z_player_call.h b/include/def/z_player_call.h index bb08d3e44..0fdf2692c 100644 --- a/include/def/z_player_call.h +++ b/include/def/z_player_call.h @@ -1,6 +1,3 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_PLAYER_CALL_C + void PlayerCall_InitFuncPtrs(void); -#else -void PlayerCall_InitFuncPtrs(void); -#endif diff --git a/include/def/z_player_lib.h b/include/def/z_player_lib.h index 89a928b92..4c97e9a0a 100644 --- a/include/def/z_player_lib.h +++ b/include/def/z_player_lib.h @@ -1,4 +1,13 @@ #pragma once +struct Player; +struct GlobalContext; +struct Vec3f; +struct Actor; +struct Vec3s; +struct ColliderQuad; +struct WeaponInfo; +struct SkelAnime; +struct FlexSkeletonHeader; extern Gfx* D_80125DE8[]; extern Gfx* D_80125E08[]; @@ -9,7 +18,6 @@ extern Gfx gCullFrontDList[]; extern u8 gPlayerModelTypes[][5]; extern FlexSkeletonHeader* gPlayerSkelHeaders[2]; -#ifdef INTERNAL_SRC_CODE_Z_PLAYER_LIB_C s32 Player_ActionToBottle(Player* player, s32 actionParam); s32 Player_ActionToExplosive(Player* player, s32 actionParam); s32 Player_ActionToMagicSpell(Player* player, s32 actionParam); @@ -46,7 +54,7 @@ s32 func_8008EF44(GlobalContext* globalCtx, s32 ammo); s32 func_8008F128(Player* player); s32 func_8008F2BC(Player* player, s32 actionParam); s32 func_8008F2F8(GlobalContext* globalCtx); -void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* this); +void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* pthis); s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data); s32 func_80090014(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data); s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data); @@ -55,50 +63,3 @@ u8 func_80090480(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* w void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* data); u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime); void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots); -#else -s32 Player_ActionToBottle(struct Player* player, s32 actionParam); -s32 Player_ActionToExplosive(struct Player* player, s32 actionParam); -s32 Player_ActionToMagicSpell(struct Player* player, s32 actionParam); -s32 Player_ActionToModelGroup(struct Player* player, s32 actionParam); -s32 Player_ActionToSword(s32 actionParam); -void Player_DrawGetItem(struct GlobalContext* globalCtx, struct Player* player); -s32 Player_GetBottleHeld(struct Player* player); -s32 Player_GetExplosiveHeld(struct Player* player); -u8 Player_GetMask(struct GlobalContext* globalCtx); -s32 Player_GetStrength(void); -s32 Player_GetSwordHeld(struct Player* player); -s32 Player_HasMirrorShieldEquipped(struct GlobalContext* globalCtx); -s32 Player_HasMirrorShieldSetToDraw(struct GlobalContext* globalCtx); -s32 Player_HoldsBrokenKnife(struct Player* player); -s32 Player_HoldsHookshot(struct Player* player); -s32 Player_HoldsTwoHandedWeapon(struct Player* player); -s32 Player_InBlockingCsMode(struct GlobalContext* globalCtx, struct Player* player); -s32 Player_InCsMode(struct GlobalContext* globalCtx); -s32 Player_IsBurningStickInRange(struct GlobalContext* globalCtx, struct Vec3f* pos, f32 radius, f32 arg3); -s32 Player_IsChildWithHylianShield(struct Player* player); -void Player_SetBootData(struct GlobalContext* globalCtx, struct Player* player); -void Player_SetEquipmentData(struct GlobalContext* globalCtx, struct Player* player); -void Player_SetModelGroup(struct Player* player, s32 modelGroup); -void Player_SetModels(struct Player* player, s32 modelGroup); -void Player_SetModelsForHoldingShield(struct Player* player); -struct Player* Player_UnsetMask(struct GlobalContext* globalCtx); -void Player_UpdateBottleHeld(struct GlobalContext* globalCtx, struct Player* player, s32 item, s32 actionParam); -s32 func_8008E9C4(struct Player* player); -void func_8008EC70(struct Player* player); -void func_8008EDF0(struct Player* player); -void func_8008EE08(struct Player* player); -void func_8008EEAC(struct GlobalContext* globalCtx, struct Actor* actor); -s32 func_8008EF44(struct GlobalContext* globalCtx, s32 ammo); -s32 func_8008F128(struct Player* player); -s32 func_8008F2BC(struct Player* player, s32 actionParam); -s32 func_8008F2F8(struct GlobalContext* globalCtx); -void func_8008F470(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* this); -s32 func_8008FCC8(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, struct Vec3f* pos, struct Vec3s* rot, void* data); -s32 func_80090014(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, struct Vec3f* pos, struct Vec3s* rot, void* data); -s32 func_800902F0(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, struct Vec3f* pos, struct Vec3s* rot, void* data); -s32 func_80090440(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, struct Vec3f* pos, struct Vec3s* rot, void* data); -u8 func_80090480(struct GlobalContext* globalCtx, struct ColliderQuad* collider, struct WeaponInfo* weaponDim, struct Vec3f* newTip, struct Vec3f* newBase); -void func_80090D20(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, struct Vec3s* rot, void* data); -u32 func_80091738(struct GlobalContext* globalCtx, u8* segment, struct SkelAnime* skelAnime); -void func_8009214C(struct GlobalContext* globalCtx, u8* segment, struct SkelAnime* skelAnime, struct Vec3f* pos, struct Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots); -#endif diff --git a/include/def/z_prenmi.h b/include/def/z_prenmi.h index 2e3470f12..85e64e6ec 100644 --- a/include/def/z_prenmi.h +++ b/include/def/z_prenmi.h @@ -1,6 +1,4 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_PRENMI_C -void PreNMI_Init(GameState* thisx); -#else -void PreNMI_Init(struct GameState* thisx); -#endif +struct GameState; + +void PreNMI_Init(GameState* pthisx); diff --git a/include/def/z_prenmi_buff.h b/include/def/z_prenmi_buff.h index b815f4493..d119a1ea4 100644 --- a/include/def/z_prenmi_buff.h +++ b/include/def/z_prenmi_buff.h @@ -1,10 +1,6 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_PRENMI_BUFF_C -void PreNmiBuff_Init(PreNmiBuff* this); -u32 PreNmiBuff_IsResetting(PreNmiBuff* this); -void PreNmiBuff_SetReset(PreNmiBuff* this); -#else -void PreNmiBuff_Init(struct PreNmiBuff* this); -u32 PreNmiBuff_IsResetting(struct PreNmiBuff* this); -void PreNmiBuff_SetReset(struct PreNmiBuff* this); -#endif +struct PreNmiBuff; + +void PreNmiBuff_Init(PreNmiBuff* pthis); +u32 PreNmiBuff_IsResetting(PreNmiBuff* pthis); +void PreNmiBuff_SetReset(PreNmiBuff* pthis); diff --git a/include/def/z_quake.h b/include/def/z_quake.h index 7226e172f..04b3c5058 100644 --- a/include/def/z_quake.h +++ b/include/def/z_quake.h @@ -1,5 +1,12 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_QUAKE_C +struct Camera; +struct QuakeRequest; +struct Vec3f; +struct VecSph; +struct QuakeCamCalc; +struct ShakeInfo; +struct SubQuakeRequest14; + s16 Quake_Add(Camera* cam, u32 callbackIdx); QuakeRequest* Quake_AddImpl(Camera* cam, u32 callbackIdx); Vec3f* Quake_AddVec(Vec3f* dst, Vec3f* arg1, VecSph* arg2); @@ -22,27 +29,3 @@ u32 Quake_SetSpeed(s16 idx, s16 value); u32 Quake_SetUnkValues(s16 idx, s16 arg1, SubQuakeRequest14 arg2); QuakeRequest* Quake_SetValue(s16 idx, s16 valueType, s16 value); void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x); -#else -s16 Quake_Add(struct Camera* cam, u32 callbackIdx); -struct QuakeRequest* Quake_AddImpl(struct Camera* cam, u32 callbackIdx); -struct Vec3f* Quake_AddVec(struct Vec3f* dst, struct Vec3f* arg1, struct VecSph* arg2); -s16 Quake_Calc(struct Camera* camera, struct QuakeCamCalc* camData); -s16 Quake_Callback1(struct QuakeRequest* req, struct ShakeInfo* shake); -s16 Quake_Callback2(struct QuakeRequest* req, struct ShakeInfo* shake); -s16 Quake_Callback3(struct QuakeRequest* req, struct ShakeInfo* shake); -s16 Quake_Callback4(struct QuakeRequest* req, struct ShakeInfo* shake); -s16 Quake_Callback5(struct QuakeRequest* req, struct ShakeInfo* shake); -s16 Quake_Callback6(struct QuakeRequest* req, struct ShakeInfo* shake); -s16 Quake_GetCountdown(s16 idx); -s16 Quake_GetFreeIndex(void); -struct QuakeRequest* Quake_GetRequest(s16 idx); -void Quake_Init(void); -void Quake_Remove(struct QuakeRequest* req); -u32 Quake_RemoveFromIdx(s16 idx); -u32 Quake_SetCountdown(s16 idx, s16 value); -u32 Quake_SetQuakeValues(s16 idx, s16 y, s16 x, s16 zoom, s16 rotZ); -u32 Quake_SetSpeed(s16 idx, s16 value); -u32 Quake_SetUnkValues(s16 idx, s16 arg1, struct SubQuakeRequest14 arg2); -struct QuakeRequest* Quake_SetValue(s16 idx, s16 valueType, s16 value); -void Quake_UpdateShakeInfo(struct QuakeRequest* req, struct ShakeInfo* shake, f32 y, f32 x); -#endif diff --git a/include/def/z_rcp.h b/include/def/z_rcp.h index 2ee941dda..23a6d355f 100644 --- a/include/def/z_rcp.h +++ b/include/def/z_rcp.h @@ -1,10 +1,12 @@ #pragma once +struct GraphicsContext; +struct GlobalContext; extern Gfx gEmptyDL[]; -#ifdef INTERNAL_SRC_CODE_Z_RCP_C Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height); Gfx* Gfx_CallSetupDL(Gfx* gfx, u32 i); +void Gfx_ClearDisplay(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a); Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); @@ -48,54 +50,4 @@ void func_80094BC4(GraphicsContext* gfxCtx); void func_80094C50(GraphicsContext* gfxCtx); void func_80094D28(Gfx** gfxp); Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y); -void Gfx_ClearDisplay(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); void func_80095974(GraphicsContext* gfxCtx); -#else -Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height); -Gfx* Gfx_CallSetupDL(Gfx* gfx, u32 i); -Gfx* Gfx_EnvColor(struct GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a); -Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); -Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); -Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); -Gfx* Gfx_TexScroll(struct GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height); -Gfx* Gfx_TwoTexScroll(struct GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2); -Gfx* Gfx_TwoTexScrollEnvColor(struct GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a); -Gfx* func_800937C0(Gfx* gfx); -Gfx* func_80093808(Gfx* gfx); -void func_800938B4(struct GraphicsContext* gfxCtx); -void func_8009398C(struct GraphicsContext* gfxCtx); -void func_80093AD0(struct GraphicsContext* gfxCtx); -void func_80093BA8(struct GraphicsContext* gfxCtx); -void func_80093C14(struct GraphicsContext* gfxCtx); -void func_80093C80(struct GlobalContext* globalCtx); -void func_80093D18(struct GraphicsContext* gfxCtx); -void func_80093D84(struct GraphicsContext* gfxCtx); -Gfx* func_80093F34(Gfx* gfx); -Gfx* func_80093F58(Gfx* gfx); -void func_80094044(struct GraphicsContext* gfxCtx); -void func_800940B0(struct GraphicsContext* gfxCtx); -Gfx* func_8009411C(Gfx* gfx); -void func_80094140(struct GraphicsContext* gfxCtx); -void func_800942F0(struct GraphicsContext* gfxCtx); -void func_8009435C(struct GraphicsContext* gfxCtx); -void func_800943C8(struct GraphicsContext* gfxCtx); -Gfx* func_800944A0(Gfx* gfx); -void func_800944C4(struct GraphicsContext* gfxCtx); -void func_80094520(struct GraphicsContext* gfxCtx); -void func_8009457C(Gfx** gfxp); -void func_800945A0(struct GraphicsContext* gfxCtx); -void func_8009460C(struct GraphicsContext* gfxCtx); -void func_80094678(struct GraphicsContext* gfxCtx); -Gfx* func_800946E4(Gfx* gfx); -Gfx* func_800947AC(Gfx* gfx); -Gfx* func_80094968(Gfx* gfx); -void func_800949A8(struct GraphicsContext* gfxCtx); -void func_80094A14(struct GraphicsContext* gfxCtx); -void func_80094B58(struct GraphicsContext* gfxCtx); -void func_80094BC4(struct GraphicsContext* gfxCtx); -void func_80094C50(struct GraphicsContext* gfxCtx); -void func_80094D28(Gfx** gfxp); -Gfx* func_80094E78(struct GraphicsContext* gfxCtx, u32 x, u32 y); -void Gfx_ClearDisplay(struct GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); -void func_80095974(struct GraphicsContext* gfxCtx); -#endif diff --git a/include/def/z_room.h b/include/def/z_room.h index 17e911f20..3e80efb32 100644 --- a/include/def/z_room.h +++ b/include/def/z_room.h @@ -1,5 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_ROOM_C +struct GlobalContext; +struct Room; +struct Input; +struct RoomContext; + void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags); void func_80095AA0(GlobalContext* globalCtx, Room* room, Input* arg2, UNK_TYPE arg3); void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 mode0, u16 tlutCount, f32 frameX, f32 frameY); @@ -8,13 +12,3 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx); s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum); s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx); void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx); -#else -void Room_Draw(struct GlobalContext* globalCtx, struct Room* room, u32 flags); -void func_80095AA0(struct GlobalContext* globalCtx, struct Room* room, struct Input* arg2, UNK_TYPE arg3); -void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 mode0, u16 tlutCount, f32 frameX, f32 frameY); -void func_80096FD4(struct GlobalContext* globalCtx, struct Room* room); -u32 func_80096FE8(struct GlobalContext* globalCtx, struct RoomContext* roomCtx); -s32 func_8009728C(struct GlobalContext* globalCtx, struct RoomContext* roomCtx, s32 roomNum); -s32 func_800973FC(struct GlobalContext* globalCtx, struct RoomContext* roomCtx); -void func_80097534(struct GlobalContext* globalCtx, struct RoomContext* roomCtx); -#endif diff --git a/include/def/z_sample.h b/include/def/z_sample.h index 6f08aec2f..397e5ceaf 100644 --- a/include/def/z_sample.h +++ b/include/def/z_sample.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_SAMPLE_C -void Sample_Destroy(GameState* thisx); -void Sample_Init(GameState* thisx); -#else -void Sample_Destroy(struct GameState* thisx); -void Sample_Init(struct GameState* thisx); -#endif +struct GameState; + +void Sample_Destroy(GameState* pthisx); +void Sample_Init(GameState* pthisx); diff --git a/include/def/z_scene.h b/include/def/z_scene.h index c4a668df5..8cc87e02f 100644 --- a/include/def/z_scene.h +++ b/include/def/z_scene.h @@ -1,10 +1,14 @@ #pragma once +struct ObjectContext; +struct GlobalContext; +struct GameState; +struct TransitionActorContext; +struct RomFile; extern s16 gLinkObjectIds[2]; extern RomFile gObjectTable[OBJECT_ID_MAX]; extern u32 gObjectTableSize; -#ifdef INTERNAL_SRC_CODE_Z_SCENE_C s32 Object_GetIndex(ObjectContext* objectCtx, s32 objectId); void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx); s32 Object_IsLoaded(ObjectContext* objectCtx, s32 bankIndex); @@ -12,12 +16,3 @@ void Object_UpdateBank(ObjectContext* objectCtx); s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd); void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx); void func_800981B8(ObjectContext* objectCtx); -#else -s32 Object_GetIndex(struct ObjectContext* objectCtx, s32 objectId); -void Object_InitBank(struct GlobalContext* globalCtx, struct ObjectContext* objectCtx); -s32 Object_IsLoaded(struct ObjectContext* objectCtx, s32 bankIndex); -void Object_UpdateBank(struct ObjectContext* objectCtx); -s32 Scene_ExecuteCommands(struct GlobalContext* globalCtx, SceneCmd* sceneCmd); -void TransitionActor_InitContext(struct GameState* state, struct TransitionActorContext* transiActorCtx); -void func_800981B8(struct ObjectContext* objectCtx); -#endif diff --git a/include/def/z_scene_table.h b/include/def/z_scene_table.h index 119e79d3f..6af02f8f5 100644 --- a/include/def/z_scene_table.h +++ b/include/def/z_scene_table.h @@ -1,12 +1,10 @@ #pragma once +struct GlobalContext; +struct EntranceInfo; +struct SceneTableEntry; extern EntranceInfo gEntranceTable[1556]; extern SceneTableEntry gSceneTable[SCENE_ID_MAX]; -#ifdef INTERNAL_SRC_CODE_Z_SCENE_TABLE_C void Scene_Draw(GlobalContext* globalCtx); void func_800994A0(GlobalContext* globalCtx); -#else -void Scene_Draw(struct GlobalContext* globalCtx); -void func_800994A0(struct GlobalContext* globalCtx); -#endif diff --git a/include/def/z_select.h b/include/def/z_select.h index 11208551f..e00b728c2 100644 --- a/include/def/z_select.h +++ b/include/def/z_select.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_SELECT_Z_SELECT_C -void Select_Destroy(GameState* thisx); -void Select_Init(GameState* thisx); -#else -void Select_Destroy(struct GameState* thisx); -void Select_Init(struct GameState* thisx); -#endif +struct GameState; + +void Select_Destroy(GameState* pthisx); +void Select_Init(GameState* pthisx); diff --git a/include/def/z_skelanime.h b/include/def/z_skelanime.h index 6c7b3be7b..beef807ae 100644 --- a/include/def/z_skelanime.h +++ b/include/def/z_skelanime.h @@ -1,5 +1,16 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_SKELANIME_C +struct GlobalContext; +struct AnimationContext; +struct Vec3s; +struct LinkAnimationHeader; +struct Actor; +struct SkelAnime; +struct AnimationHeader; +struct LegacyAnimationHeader; +struct SkeletonHeader; +struct FlexSkeletonHeader; +struct Vec3f; + void AnimationContext_DisableQueue(GlobalContext* globalCtx); void AnimationContext_Reset(AnimationContext* animationCtx); void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); @@ -62,67 +73,3 @@ s32 SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonH void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* target, f32 weight); s32 SkelAnime_Update(SkelAnime* skelAnime); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -#else -void AnimationContext_DisableQueue(struct GlobalContext* globalCtx); -void AnimationContext_Reset(struct AnimationContext* animationCtx); -void AnimationContext_SetCopyAll(struct GlobalContext* globalCtx, s32 vecCount, struct Vec3s* dst, struct Vec3s* src); -void AnimationContext_SetCopyFalse(struct GlobalContext* globalCtx, s32 vecCount, struct Vec3s* dst, struct Vec3s* src, u8* copyFlag); -void AnimationContext_SetCopyTrue(struct GlobalContext* globalCtx, s32 vecCount, struct Vec3s* dst, struct Vec3s* src, u8* copyFlag); -void AnimationContext_SetInterp(struct GlobalContext* globalCtx, s32 vecCount, struct Vec3s* base, struct Vec3s* mod, f32 weight); -void AnimationContext_SetLoadFrame(struct GlobalContext* globalCtx, struct LinkAnimationHeader* animation, s32 frame, s32 limbCount, struct Vec3s* frameTable); -void AnimationContext_SetMoveActor(struct GlobalContext* globalCtx, struct Actor* actor, struct SkelAnime* skelAnime, f32 arg3); -void AnimationContext_SetNextQueue(struct GlobalContext* globalCtx); -void AnimationContext_Update(struct GlobalContext* globalCtx, struct AnimationContext* animationCtx); -void Animation_Change(struct SkelAnime* skelAnime, struct AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); -void Animation_ChangeImpl(struct SkelAnime* skelAnime, struct AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames, s8 taper); -void Animation_EndLoop(struct SkelAnime* skelAnime); -s16 Animation_GetLastFrame(void* animation); -s16 Animation_GetLastFrameLegacy(struct LegacyAnimationHeader* animation); -s16 Animation_GetLength(void* animation); -s16 Animation_GetLengthLegacy(struct LegacyAnimationHeader* animation); -s16 Animation_GetLimbCountLegacy(struct LegacyAnimationHeader* animation); -void Animation_MorphToLoop(struct SkelAnime* skelAnime, struct AnimationHeader* animation, f32 morphFrames); -void Animation_MorphToPlayOnce(struct SkelAnime* skelAnime, struct AnimationHeader* animation, f32 morphFrames); -s32 Animation_OnFrame(struct SkelAnime* skelAnime, f32 frame); -void Animation_PlayLoop(struct SkelAnime* skelAnime, struct AnimationHeader* animation); -void Animation_PlayLoopSetSpeed(struct SkelAnime* skelAnime, struct AnimationHeader* animation, f32 playSpeed); -void Animation_PlayOnce(struct SkelAnime* skelAnime, struct AnimationHeader* animation); -void Animation_PlayOnceSetSpeed(struct SkelAnime* skelAnime, struct AnimationHeader* animation, f32 playSpeed); -void Animation_Reverse(struct SkelAnime* skelAnime); -void Animation_SetMorph(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, f32 morphFrames); -void LinkAnimation_AnimateFrame(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime); -void LinkAnimation_BlendToJoint(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation1, f32 frame1, struct LinkAnimationHeader* animation2, f32 frame2, f32 weight, struct Vec3s* blendTable); -void LinkAnimation_BlendToMorph(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation1, f32 frame1, struct LinkAnimationHeader* animation2, f32 frame2, f32 weight, struct Vec3s* blendTable); -void LinkAnimation_Change(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); -void LinkAnimation_CopyJointToMorph(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime); -void LinkAnimation_CopyMorphToJoint(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime); -void LinkAnimation_EndLoop(struct SkelAnime* skelAnime); -void LinkAnimation_InterpJointMorph(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, f32 frame); -void LinkAnimation_LoadToJoint(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation, f32 frame); -void LinkAnimation_LoadToMorph(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation, f32 frame); -s32 LinkAnimation_OnFrame(struct SkelAnime* skelAnime, f32 frame); -void LinkAnimation_PlayLoop(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation); -void LinkAnimation_PlayLoopSetSpeed(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation, f32 playSpeed); -void LinkAnimation_PlayOnce(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation); -void LinkAnimation_PlayOnceSetSpeed(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct LinkAnimationHeader* animation, f32 playSpeed); -void LinkAnimation_SetUpdateFunction(struct SkelAnime* skelAnime); -s32 LinkAnimation_Update(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime); -void SkelAnime_CopyFrameTable(struct SkelAnime* skelAnime, struct Vec3s* dst, struct Vec3s* src); -void SkelAnime_CopyFrameTableFalse(struct SkelAnime* skelAnime, struct Vec3s* dst, struct Vec3s* src, u8* copyFlag); -void SkelAnime_CopyFrameTableTrue(struct SkelAnime* skelAnime, struct Vec3s* dst, struct Vec3s* src, u8* copyFlag); -Gfx* SkelAnime_Draw(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx); -Gfx* SkelAnime_DrawFlex(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx); -void SkelAnime_DrawFlexLod(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 dListIndex); -void SkelAnime_DrawFlexOpa(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg); -void SkelAnime_DrawLod(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 dListIndex); -void SkelAnime_DrawOpa(struct GlobalContext* globalCtx, void** skeleton, struct Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg); -void SkelAnime_Free(struct SkelAnime* skelAnime, struct GlobalContext* globalCtx); -s32 SkelAnime_GetFrameDataLegacy(struct LegacyAnimationHeader* animation, s32 frame, struct Vec3s* frameTable); -s32 SkelAnime_Init(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct SkeletonHeader* skeletonHeaderSeg, struct AnimationHeader* animation, struct Vec3s* jointTable, struct Vec3s* morphTable, s32 limbCount); -s32 SkelAnime_InitFlex(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct FlexSkeletonHeader* skeletonHeaderSeg, struct AnimationHeader* animation, struct Vec3s* jointTable, struct Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitLink(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct FlexSkeletonHeader* skeletonHeaderSeg, struct LinkAnimationHeader* animation, s32 initFlags, struct Vec3s* jointTable, struct Vec3s* morphTable, s32 limbCount); -s32 SkelAnime_InitSkin(struct GlobalContext* globalCtx, struct SkelAnime* skelAnime, struct SkeletonHeader* skeletonHeaderSeg, struct AnimationHeader* animation); -void SkelAnime_InterpFrameTable(s32 limbCount, struct Vec3s* dst, struct Vec3s* start, struct Vec3s* target, f32 weight); -s32 SkelAnime_Update(struct SkelAnime* skelAnime); -void SkelAnime_UpdateTranslation(struct SkelAnime* skelAnime, struct Vec3f* pos, s16 angle); -#endif diff --git a/include/def/z_skin.h b/include/def/z_skin.h index 321547ed1..b642d4ff9 100644 --- a/include/def/z_skin.h +++ b/include/def/z_skin.h @@ -1,22 +1,18 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_SKIN_C +struct Struct_800A57C0; +struct Struct_800A598C; +struct Vec3f; +struct GraphicsContext; +struct PSkinAwb; +struct Actor; +struct GlobalContext; + void func_800A57C0(MtxF* mtx, Struct_800A57C0* arg1, Struct_800A598C* arg2, Vtx* arg3, Vec3f* arg4); void func_800A598C(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 arg3); void func_800A5E28(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 arg3, s32 arg4); void func_800A5F60(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, Gfx* arg3, s32 arg4); void func_800A60D8(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5, s32 arg6, s32 arg7); void func_800A6330(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, s32 arg4); -void func_800A6360(Actor* this, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5); +void func_800A6360(Actor* pthis, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5); void func_800A63CC(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5, s32 arg6, s32 arg7); void func_800A6408(PSkinAwb* skin, s32 joint, Vec3f* arg2, Vec3f* arg3); -#else -void func_800A57C0(MtxF* mtx, struct Struct_800A57C0* arg1, struct Struct_800A598C* arg2, Vtx* arg3, struct Vec3f* arg4); -void func_800A598C(struct GraphicsContext* gfxCtx, struct PSkinAwb* skin, s32 limbIndex, s32 arg3); -void func_800A5E28(struct GraphicsContext* gfxCtx, struct PSkinAwb* skin, s32 limbIndex, s32 arg3, s32 arg4); -void func_800A5F60(struct GraphicsContext* gfxCtx, struct PSkinAwb* skin, s32 limbIndex, Gfx* arg3, s32 arg4); -void func_800A60D8(struct Actor* actor, struct GlobalContext* globalCtx, struct PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5, s32 arg6, s32 arg7); -void func_800A6330(struct Actor* actor, struct GlobalContext* globalCtx, struct PSkinAwb* skin, SkinCallback callback, s32 arg4); -void func_800A6360(struct Actor* this, struct GlobalContext* globalCtx, struct PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5); -void func_800A63CC(struct Actor* actor, struct GlobalContext* globalCtx, struct PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5, s32 arg6, s32 arg7); -void func_800A6408(struct PSkinAwb* skin, s32 joint, struct Vec3f* arg2, struct Vec3f* arg3); -#endif diff --git a/include/def/z_skin_awb.h b/include/def/z_skin_awb.h index d4db96648..d4239ab03 100644 --- a/include/def/z_skin_awb.h +++ b/include/def/z_skin_awb.h @@ -1,14 +1,13 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_SKIN_AWB_C +struct GlobalContext; +struct PSkinAwb; +struct SkeletonHeader; +struct AnimationHeader; +struct SkinLimb; +struct Actor; + void func_800A6460(GlobalContext* globalCtx, PSkinAwb* skin, s32 arg2); void func_800A663C(GlobalContext* globalCtx, PSkinAwb* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader); void func_800A6888(GlobalContext* globalCtx, PSkinAwb* skin); s32 func_800A698C(PSkinAwb* skin, SkinLimb** limbs, MtxF* arg2, u8 arg3, u8 arg4); s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3); -#else -void func_800A6460(struct GlobalContext* globalCtx, struct PSkinAwb* skin, s32 arg2); -void func_800A663C(struct GlobalContext* globalCtx, struct PSkinAwb* skin, struct SkeletonHeader* skeletonHeader, struct AnimationHeader* animationHeader); -void func_800A6888(struct GlobalContext* globalCtx, struct PSkinAwb* skin); -s32 func_800A698C(struct PSkinAwb* skin, struct SkinLimb** limbs, MtxF* arg2, u8 arg3, u8 arg4); -s32 func_800A6AC4(struct PSkinAwb* skin, MtxF* arg1, struct Actor* actor, s32 arg3); -#endif diff --git a/include/def/z_skin_matrix.h b/include/def/z_skin_matrix.h index e006eea9b..2f445eaff 100644 --- a/include/def/z_skin_matrix.h +++ b/include/def/z_skin_matrix.h @@ -1,5 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_SKIN_MATRIX_C +struct GraphicsContext; +struct Vec3f; + void SkinMatrix_GetClear(MtxF** mf); s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); @@ -13,18 +15,3 @@ void SkinMatrix_SetTranslateRotateZYX(MtxF* dest, s16 rotX, s16 rotY, s16 rotZ, void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void func_800A7EC0(MtxF* mf, s16 a, f32 x, f32 y, f32 z); -#else -void SkinMatrix_GetClear(MtxF** mf); -s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); -void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); -void SkinMatrix_MtxFMtxFMult(MtxF* mfA, MtxF* mfB, MtxF* dest); -struct Mtx* SkinMatrix_MtxFToNewMtx(struct GraphicsContext* gfxCtx, MtxF* src); -void SkinMatrix_SetRotateZYX(MtxF* mf, s16 x, s16 y, s16 z); -void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z); -void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z); -void SkinMatrix_SetTranslateRotateYXZScale(MtxF* dest, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY, f32 translateZ); -void SkinMatrix_SetTranslateRotateZYX(MtxF* dest, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY, f32 translateZ); -void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, struct Vec3f* src, struct Vec3f* dest); -void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, struct Vec3f* src, struct Vec3f* xyzDest, f32* wDest); -void func_800A7EC0(MtxF* mf, s16 a, f32 x, f32 y, f32 z); -#endif diff --git a/include/def/z_sram.h b/include/def/z_sram.h index 030e7e1a5..462c29957 100644 --- a/include/def/z_sram.h +++ b/include/def/z_sram.h @@ -1,8 +1,11 @@ #pragma once +struct GameState; +struct SramContext; +struct FileChooseContext; +struct GlobalContext; extern u16 gSramSlotOffsets[]; -#ifdef INTERNAL_SRC_CODE_Z_SRAM_C void Sram_Alloc(GameState* gameState, SramContext* sramCtx); void Sram_CopySave(FileChooseContext* fileChoose, SramContext* sramCtx); void Sram_EraseSave(FileChooseContext* fileChoose, SramContext* sramCtx); @@ -15,17 +18,3 @@ void Sram_OpenSave(SramContext* sramCtx); void Sram_VerifyAndLoadAllSaves(FileChooseContext* fileChoose, SramContext* sramCtx); void Sram_WriteSave(SramContext* sramCtx); void Sram_WriteSramHeader(SramContext* sramCtx); -#else -void Sram_Alloc(struct GameState* gameState, struct SramContext* sramCtx); -void Sram_CopySave(struct FileChooseContext* fileChoose, struct SramContext* sramCtx); -void Sram_EraseSave(struct FileChooseContext* fileChoose, struct SramContext* sramCtx); -void Sram_Init(struct GlobalContext* globalCtx, struct SramContext* sramCtx); -void Sram_InitDebugSave(void); -void Sram_InitNewSave(void); -void Sram_InitSave(struct FileChooseContext* fileChoose, struct SramContext* sramCtx); -void Sram_InitSram(struct GameState* gameState, struct SramContext* sramCtx); -void Sram_OpenSave(struct SramContext* sramCtx); -void Sram_VerifyAndLoadAllSaves(struct FileChooseContext* fileChoose, struct SramContext* sramCtx); -void Sram_WriteSave(struct SramContext* sramCtx); -void Sram_WriteSramHeader(struct SramContext* sramCtx); -#endif diff --git a/include/def/z_ss_sram.h b/include/def/z_ss_sram.h index 0e435c24b..7afd78279 100644 --- a/include/def/z_ss_sram.h +++ b/include/def/z_ss_sram.h @@ -1,10 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_SS_SRAM_C + void SsSram_Dma(void* dramAddr, size_t size, s32 direction); void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, u8 handlePulse, u32 handleSpeed); void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction); -#else -void SsSram_Dma(void* dramAddr, size_t size, s32 direction); -void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, u8 handlePulse, u32 handleSpeed); -void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction); -#endif diff --git a/include/def/z_std_dma.h b/include/def/z_std_dma.h index f3dc824d1..008e08060 100644 --- a/include/def/z_std_dma.h +++ b/include/def/z_std_dma.h @@ -1,34 +1,22 @@ #pragma once +struct OSPiHandle; +struct OSIoMesg; +struct DmaRequest; +struct OSMesgQueue; extern u32 D_80009460; extern u32 gDmaMgrDmaBuffSize; -#ifdef INTERNAL_SRC_BOOT_Z_STD_DMA_C s32 DmaMgr_CompareName(const char* name1, const char* name2); s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size); +s32 DmaMgr_DmaRomToRam(Pointer rom, Pointer ram, size_t size); void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc); -const char* DmaMgr_GetFileName(u32 vrom); -const char* DmaMgr_GetFileNameImpl(u32 vrom); +const char* DmaMgr_GetFileName(Pointer vrom); +const char* DmaMgr_GetFileNameImpl(Pointer vrom); void DmaMgr_Init(void); void DmaMgr_ProcessMsg(DmaRequest* req); -s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size); -s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 line); -s32 DmaMgr_SendRequest2(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line); -s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg); +s32 DmaMgr_SendRequest0(Pointer ram, Pointer vrom, u32 size); +s32 DmaMgr_SendRequest1(Pointer ram0, Pointer vrom, size_t size, const char* file, s32 line); +s32 DmaMgr_SendRequest2(DmaRequest* req, Pointer ram, Pointer vrom, size_t size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line); +s32 DmaMgr_SendRequestImpl(DmaRequest* req, Pointer ram, Pointer vrom, size_t size, u32 unk, OSMesgQueue* queue, OSMesg msg); void DmaMgr_ThreadEntry(void* arg0); -#else -s32 DmaMgr_CompareName(const char* name1, const char* name2); -s32 DmaMgr_DmaHandler(struct OSPiHandle* pihandle, struct OSIoMesg* mb, s32 direction); -s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size); -void DmaMgr_Error(struct DmaRequest* req, const char* file, const char* errorName, const char* errorDesc); -const char* DmaMgr_GetFileName(u32 vrom); -const char* DmaMgr_GetFileNameImpl(u32 vrom); -void DmaMgr_Init(void); -void DmaMgr_ProcessMsg(struct DmaRequest* req); -s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size); -s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 line); -s32 DmaMgr_SendRequest2(struct DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk5, struct OSMesgQueue* queue, OSMesg msg, const char* file, s32 line); -s32 DmaMgr_SendRequestImpl(struct DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, struct OSMesgQueue* queue, OSMesg msg); -void DmaMgr_ThreadEntry(void* arg0); -#endif diff --git a/include/def/z_title.h b/include/def/z_title.h index b7f1a86d7..630951960 100644 --- a/include/def/z_title.h +++ b/include/def/z_title.h @@ -1,8 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_TITLE_Z_TITLE_C -void Title_Destroy(GameState* thisx); -void Title_Init(GameState* thisx); -#else -void Title_Destroy(struct GameState* thisx); -void Title_Init(struct GameState* thisx); -#endif +struct GameState; + +void Title_Destroy(GameState* pthisx); +void Title_Init(GameState* pthisx); diff --git a/include/def/z_view.h b/include/def/z_view.h index 13cc72930..824cf7cbe 100644 --- a/include/def/z_view.h +++ b/include/def/z_view.h @@ -1,5 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_VIEW_C +struct View; +struct Viewport; +struct GraphicsContext; +struct Vec3f; + void View_Free(View* view); void View_GetScale(View* view, f32* scale); void View_GetViewport(View* view, Viewport* viewport); @@ -28,33 +32,3 @@ s32 func_800AB560(View* view); s32 func_800AB944(View* view); s32 func_800AB9EC(View* view, s32 arg1, Gfx** p); s32 func_800ABE74(f32 eyeX, f32 eyeY, f32 eyeZ); -#else -void View_Free(struct View* view); -void View_GetScale(struct View* view, f32* scale); -void View_GetViewport(struct View* view, struct Viewport* viewport); -void View_Init(struct View*, struct GraphicsContext*); -struct View* View_New(struct GraphicsContext* gfxCtx); -void View_SetScale(struct View* view, f32 scale); -void View_SetViewport(struct View* view, struct Viewport* viewport); -void func_800AA358(struct View* view, struct Vec3f* eye, struct Vec3f* lookAt, struct Vec3f* up); -void func_800AA3F0(struct View* view, struct Vec3f* eye, struct Vec3f* lookAt, struct Vec3f* up); -void func_800AA460(struct View* view, f32 fovy, f32 near, f32 far); -void func_800AA48C(struct View* view, f32* fovy, f32* near, f32* far); -void func_800AA4A8(struct View* view, f32 fovy, f32 near, f32 far); -void func_800AA4E0(struct View* view, f32* fovy, f32* near, f32* far); -void func_800AA76C(struct View* view, f32 arg1, f32 arg2, f32 arg3); -void func_800AA78C(struct View* view, f32 arg1, f32 arg2, f32 arg3); -s32 func_800AA7AC(struct View* view, f32 arg1); -void func_800AA7B8(struct View* view); -void func_800AA814(struct View* view); -void func_800AA840(struct View* view, struct Vec3f vec1, struct Vec3f vec2, f32 arg3); -s32 func_800AA890(struct View* view, struct Mtx* mtx); -void func_800AAA50(struct View* view, s32 arg1); -s32 func_800AAA9C(struct View* view); -s32 func_800AB0A8(struct View* view); -s32 func_800AB2C4(struct View* view); -s32 func_800AB560(struct View* view); -s32 func_800AB944(struct View* view); -s32 func_800AB9EC(struct View* view, s32 arg1, Gfx** p); -s32 func_800ABE74(f32 eyeX, f32 eyeY, f32 eyeZ); -#endif diff --git a/include/def/z_vimode.h b/include/def/z_vimode.h index 098242cb6..a6978a348 100644 --- a/include/def/z_vimode.h +++ b/include/def/z_vimode.h @@ -1,5 +1,13 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_VIMODE_C +struct OSViMode; + +extern s32 gScreenHeight; +extern s32 gScreenWidth; +extern OSViMode osViModeFpalLan1; +extern OSViMode osViModeMpalLan1; +extern OSViMode osViModeNtscLan1; +extern OSViMode osViModePalLan1; + void ViMode_Configure(ViMode* viMode, s32 mode, s32 type, s32 unk_70, s32 unk_74, s32 unk_78, s32 unk_7C, s32 width, s32 height, s32 unk_left, s32 unk_right, s32 unk_top, s32 unk_bottom); void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures); void ViMode_Destroy(ViMode* viMode); @@ -7,12 +15,3 @@ void ViMode_Init(ViMode* viMode); void ViMode_Load(ViMode* viMode); void ViMode_LogPrint(OSViMode* viMode); void ViMode_Save(ViMode* viMode); -#else -void ViMode_Configure(ViMode* viMode, s32 mode, s32 type, s32 unk_70, s32 unk_74, s32 unk_78, s32 unk_7C, s32 width, s32 height, s32 unk_left, s32 unk_right, s32 unk_top, s32 unk_bottom); -void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures); -void ViMode_Destroy(ViMode* viMode); -void ViMode_Init(ViMode* viMode); -void ViMode_Load(ViMode* viMode); -void ViMode_LogPrint(struct OSViMode* viMode); -void ViMode_Save(ViMode* viMode); -#endif diff --git a/include/def/z_vismono.h b/include/def/z_vismono.h index e74fa2f82..0d4dd2044 100644 --- a/include/def/z_vismono.h +++ b/include/def/z_vismono.h @@ -1,16 +1,9 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_VISMONO_C -void VisMono_Destroy(VisMono* this); -void VisMono_Draw(VisMono* this, Gfx** gfxp); -void VisMono_DrawOld(VisMono* this); -Gfx* VisMono_DrawTexture(VisMono* this, Gfx* gfx); -void VisMono_Init(VisMono* this); -void VisMono_UpdateTexture(VisMono* this, u16* tex); -#else -void VisMono_Destroy(struct VisMono* this); -void VisMono_Draw(struct VisMono* this, Gfx** gfxp); -void VisMono_DrawOld(struct VisMono* this); -Gfx* VisMono_DrawTexture(struct VisMono* this, Gfx* gfx); -void VisMono_Init(struct VisMono* this); -void VisMono_UpdateTexture(struct VisMono* this, u16* tex); -#endif +struct VisMono; + +void VisMono_Destroy(VisMono* pthis); +void VisMono_Draw(VisMono* pthis, Gfx** gfxp); +void VisMono_DrawOld(VisMono* pthis); +Gfx* VisMono_DrawTexture(VisMono* pthis, Gfx* gfx); +void VisMono_Init(VisMono* pthis); +void VisMono_UpdateTexture(VisMono* pthis, u16* tex); diff --git a/include/def/z_vr_box.h b/include/def/z_vr_box.h index 663df5d6c..44a534f68 100644 --- a/include/def/z_vr_box.h +++ b/include/def/z_vr_box.h @@ -1,6 +1,5 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_VR_BOX_C +struct GameState; +struct SkyboxContext; + void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId); -#else -void Skybox_Init(struct GameState* state, struct SkyboxContext* skyboxCtx, s16 skyboxId); -#endif diff --git a/include/def/z_vr_box_draw.h b/include/def/z_vr_box_draw.h index 55b855439..c1187dd26 100644 --- a/include/def/z_vr_box_draw.h +++ b/include/def/z_vr_box_draw.h @@ -1,10 +1,7 @@ #pragma once -#ifdef INTERNAL_SRC_CODE_Z_VR_BOX_DRAW_C +struct SkyboxContext; +struct GraphicsContext; + void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); void SkyboxDraw_Update(SkyboxContext* skyboxCtx); Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); -#else -void SkyboxDraw_Draw(struct SkyboxContext* skyboxCtx, struct GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); -void SkyboxDraw_Update(struct SkyboxContext* skyboxCtx); -struct Mtx* SkyboxDraw_UpdateMatrix(struct SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); -#endif diff --git a/include/fp.h b/include/fp.h index c733be914..421f020ec 100644 --- a/include/fp.h +++ b/include/fp.h @@ -28,7 +28,5 @@ s32 lnearbyint(f64 x); f32 roundf(f32 x); f64 round(f64 x); -s32 lroundf(f32 x); -s32 lround(f64 x); #endif diff --git a/include/gfx.h b/include/gfx.h index 345bb3fd3..a54052718 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -7,26 +7,26 @@ #include "color.h" -typedef struct { +struct FrameBufferSwap { /* 0x0000 */ u16* curBuffer; /* 0x0004 */ u16* nextBuffer; -} FrameBufferSwap; +}; -typedef struct { +struct TwoHeadArena { /* 0x0000 */ u32 size; /* 0x0004 */ void* bufp; /* 0x0008 */ void* head; /* 0x000C */ void* tail; -} TwoHeadArena; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct TwoHeadGfxArena { /* 0x0000 */ u32 size; /* 0x0004 */ Gfx* bufp; /* 0x0008 */ Gfx* p; /* 0x000C */ Gfx* d; -} TwoHeadGfxArena; // size = 0x10 +}; // size = 0x10 -typedef struct GraphicsContext { +struct GraphicsContext { /* 0x0000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" /* 0x0004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1" /* 0x0008 */ char unk_008[0x08]; // Unused, could this be pointers to "Zelda 2" / "Zelda 3" @@ -57,9 +57,9 @@ typedef struct GraphicsContext { /* 0x02F4 */ f32 xScale; /* 0x02F8 */ f32 yScale; /* 0x02FC */ char unk_2FC[0x04]; -} GraphicsContext; // size = 0x300 +}; // size = 0x300 -typedef struct { +struct GfxPool { /* 0x00000 */ u16 headMagic; // GFXPOOL_HEAD_MAGIC /* 0x00008 */ Gfx polyOpaBuffer[0x17E0]; /* 0x0BF08 */ Gfx polyXluBuffer[0x800]; @@ -67,10 +67,10 @@ typedef struct { /* 0x11F08 */ Gfx workBuffer[0x80]; /* 0x11308 */ Gfx unusedBuffer[0x20]; /* 0x12408 */ u16 tailMagic; // GFXPOOL_TAIL_MAGIC -} GfxPool; // size = 0x12410 +}; // size = 0x12410 -typedef struct { +struct GfxPrint { /* 0x00 */ PrintCallback callback; /* 0x04 */ Gfx* dList; /* 0x08 */ u16 posX; @@ -80,7 +80,7 @@ typedef struct { /* 0x0F */ u8 flags; /* 0x10 */ Color_RGBA8_u32 color; /* 0x14 */ char unk_14[0x1C]; // unused -} GfxPrint; // size = 0x30 +}; // size = 0x30 /* void Graph_InitTHGA(struct GraphicsContext* gfxCtx); diff --git a/include/gfx_align.h b/include/gfx_align.h index 722eb2840..8986a5bb8 100644 --- a/include/gfx_align.h +++ b/include/gfx_align.h @@ -1,9 +1,9 @@ #pragma once - -extern u64 gfx_width(); -extern u64 gfx_height(); -extern float gfx_ar_ratio(); - +extern "C" { + u64 gfx_width(); + u64 gfx_height(); + float gfx_ar_ratio(); +} #define GFX_DIMENSIONS_ASPECT_RATIO ((float)gfx_width() / (float)gfx_height()) #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * GFX_DIMENSIONS_ASPECT_RATIO + (v)) #define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * GFX_DIMENSIONS_ASPECT_RATIO - (v)) diff --git a/include/gfxapi.h b/include/gfxapi.h new file mode 100644 index 000000000..09858a856 --- /dev/null +++ b/include/gfxapi.h @@ -0,0 +1,18 @@ +#pragma once + +struct GameInfo; + +extern "C" +{ + void gfx_init(const char* romName, OSViMode* viMode); + void gfx_shutdown(); + bool gfx_start_frame(); + void gfx_end_frame(); + void gfx_fbe_sync(GraphicsContext* gfxCtx, GameInfo* GameInfo); + int gfx_fbe_is_enabled(); + void gfx_fbe_enable(int enable); + void gfx_force_43(bool enable); // From GlideN64 + void gfx_run(OSTask_t* task, u32 sz); +} + + diff --git a/include/global.h b/include/global.h index 0a42ff528..a1f9cd4e8 100644 --- a/include/global.h +++ b/include/global.h @@ -7,8 +7,6 @@ #define _LANGUAGE_C_PLUS_PLUS #endif -/*#include "functions.h" -#include "variables.h"*/ #include "macros.h" #include diff --git a/include/hack.h b/include/hack.h index f0d467c6a..45dcbb04b 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1,28 +1,3 @@ #pragma once -struct CollisionPoly // TODO FIX HACK, remove this when converting to c++ -{ - /* 0x00 */ u16 type; - union - { - u16 vtxData[3]; - struct - { - /* 0x02 */ u16 flags_vIA; // 0xE000 is poly exclusion flags (xpFlags), 0x1FFF is vtxId - /* 0x04 */ u16 flags_vIB; // 0xE000 is flags, 0x1FFF is vtxId - // 0x2000 = poly IsConveyor surface - /* 0x06 */ u16 vIC; - }; - }; - /* 0x08 */ Vec3s normal; // Unit normal vector - // Value ranges from -0x7FFF to 0x7FFF, representing -1.0 to 1.0; 0x8000 is invalid - /* 0x0E */ s16 dist; // Plane distance from origin along the normal -}; // size = 0x10 - -struct OcarinaStaff -{ - u8 noteIdx; - u8 state; // original name: "status" - u8 pos; // original name: "locate" -}; diff --git a/include/ichain.h b/include/ichain.h index 37af91057..53d7bf1e7 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -1,14 +1,14 @@ #ifndef ICHAIN_H #define ICHAIN_H -typedef struct { +struct InitChainEntry { u32 cont: 1; u32 type: 4; u32 offset: 11; s32 value: 16; -} InitChainEntry; +}; -typedef enum { +enum InitChainType { /* 0x0 */ ICHAINTYPE_U8, // sets byte /* 0x1 */ ICHAINTYPE_S8, /* 0x2 */ ICHAINTYPE_U16, // sets short @@ -20,7 +20,7 @@ typedef enum { /* 0x8 */ ICHAINTYPE_VEC3F, // sets Vec3f members /* 0x9 */ ICHAINTYPE_VEC3F_DIV1000, // sets Vec3f members divided by 1000 /* 0xA */ ICHAINTYPE_VEC3S // sets Vec3s members -} InitChainType; +}; /** * ICHAIN macros generate an init chain entry of the following form: diff --git a/include/kaleido.h b/include/kaleido.h index 53e7121b6..12e0ac389 100644 --- a/include/kaleido.h +++ b/include/kaleido.h @@ -3,7 +3,7 @@ #include "ultra64/types.h" #include "view.h" -typedef struct { +struct KaleidoMgrOverlay { /* 0x00 */ void* loadedRamAddr; /* 0x04 */ uintptr_t vromStart; /* 0x08 */ uintptr_t vromEnd; @@ -11,28 +11,28 @@ typedef struct { /* 0x10 */ void* vramEnd; /* 0x14 */ u32 offset; // loadedRamAddr - vramStart /* 0x18 */ const char* name; -} KaleidoMgrOverlay; // size = 0x1C +}; // size = 0x1C -typedef enum { +enum KaleidoOverlayType { /* 0x00 */ KALEIDO_OVL_KALEIDO_SCOPE, /* 0x01 */ KALEIDO_OVL_PLAYER_ACTOR, /* 0x02 */ KALEIDO_OVL_MAX -} KaleidoOverlayType; +}; #define PAUSE_ITEM_NONE 999 #define PAUSE_CURSOR_PAGE_LEFT 10 #define PAUSE_CURSOR_PAGE_RIGHT 11 -typedef enum { +enum PauseMenuPage { /* 0x00 */ PAUSE_ITEM, /* 0x01 */ PAUSE_MAP, /* 0x02 */ PAUSE_QUEST, /* 0x03 */ PAUSE_EQUIP, /* 0x04 */ PAUSE_WORLD_MAP -} PauseMenuPage; +}; -typedef struct { +struct PauseContext { /* 0x0000 */ View view; /* 0x0128 */ u8* iconItemSegment; /* 0x012C */ u8* iconItem24Segment; @@ -103,26 +103,26 @@ typedef struct { /* 0x0266 */ u8 worldMapPoints[20]; // 0 = hidden; 1 = displayed; 2 = highlighted /* 0x027A */ u8 tradeQuestLocation; /* 0x027C */ SkelAnime playerSkelAnime; -} PauseContext; // size = 0x2C0 +}; // size = 0x2C0 #define PAUSE_MAP_MARK_NONE -1 #define PAUSE_MAP_MARK_CHEST 0 #define PAUSE_MAP_MARK_BOSS 1 -typedef struct { +struct PauseMapMarkPoint { /* 0x00 */ s16 chestFlag; // chest icon is only displayed if this flag is not set for the current room, -1 for no flag /* 0x04 */ f32 x, y; // coordinates to place the icon (top-left corner) -} PauseMapMarkPoint; // size = 0x0C +}; // size = 0x0C -typedef struct { +struct PauseMapMarkData { /* 0x00 */ s16 markType; // 0 for the chest icon, 1 for the boss skull icon, -1 for none /* 0x04 */ s32 unk_04; /* 0x08 */ const Vtx* vtx; /* 0x0C */ s32 vtxCount; /* 0x10 */ s32 count; // number of icons to display /* 0x14 */ PauseMapMarkPoint points[12]; -} PauseMapMarkData; // size = 0xA4 +}; // size = 0xA4 typedef PauseMapMarkData PauseMapMarksData[3]; diff --git a/include/libc.bak/math.h b/include/libc.bak/math.h index bceffad22..bb39c70e9 100644 --- a/include/libc.bak/math.h +++ b/include/libc.bak/math.h @@ -19,10 +19,10 @@ typedef union { f64 d; } du; -typedef union { +union fu { u32 i; f32 f; -} fu; +}; extern f32 __libm_qnan_f; diff --git a/include/libc.bak/stdlib.h b/include/libc.bak/stdlib.h index 75657d8db..43aa14f36 100644 --- a/include/libc.bak/stdlib.h +++ b/include/libc.bak/stdlib.h @@ -3,14 +3,14 @@ #include "ultra64.h" -typedef struct lldiv_t { +struct lldiv_t { s64 quot; s64 rem; -} lldiv_t; +}; -typedef struct ldiv_t { +struct ldiv_t { s32 quot; s32 rem; -} ldiv_t; +}; #endif diff --git a/include/listalloc.h b/include/listalloc.h index 8fdf5ae3c..9b75366a6 100644 --- a/include/listalloc.h +++ b/include/listalloc.h @@ -1,7 +1,7 @@ #pragma once -typedef struct ListAlloc { +struct ListAlloc { /* 0x00 */ struct ListAlloc* prev; /* 0x04 */ struct ListAlloc* next; -} ListAlloc; // size = 0x8 +}; // size = 0x8 diff --git a/include/macros.h b/include/macros.h index 16ccff198..f4742a955 100644 --- a/include/macros.h +++ b/include/macros.h @@ -4,9 +4,9 @@ #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) -#define VIRTUAL_TO_PHYSICAL(addr) ((void*)(addr)) -#define PHYSICAL_TO_VIRTUAL(addr) ((void*)(addr)) -#define SEGMENTED_TO_VIRTUAL(addr) ((void*)(addr)) +#define VIRTUAL_TO_PHYSICAL(addr) (addr) +#define PHYSICAL_TO_VIRTUAL(addr) (addr) +#define SEGMENTED_TO_VIRTUAL(addr) (addr) #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN32(val) (((val) + 0x1F) & ~0x1F) diff --git a/include/message_data_static.h b/include/message_data_static.h index 676175e4d..b26d2f708 100644 --- a/include/message_data_static.h +++ b/include/message_data_static.h @@ -4,7 +4,7 @@ #include "global.h" #include "message_data_fmt.h" -typedef enum { +enum TextBoxType { /* 0 */ TEXTBOX_TYPE_BLACK, /* 1 */ TEXTBOX_TYPE_WOODEN, /* 2 */ TEXTBOX_TYPE_BLUE, @@ -12,44 +12,45 @@ typedef enum { /* 4 */ TEXTBOX_TYPE_NONE_BOTTOM, /* 5 */ TEXTBOX_TYPE_NONE_NO_SHADOW, /* 11 */ TEXTBOX_TYPE_CREDITS = 11 -} TextBoxType; +}; -typedef enum { +enum TextBoxBackground { /* 0 */ TEXTBOX_BG_CROSS -} TextBoxBackground; +}; -typedef enum { +enum TextBoxPosition { /* 0 */ TEXTBOX_POS_VARIABLE, /* 1 */ TEXTBOX_POS_TOP, /* 2 */ TEXTBOX_POS_BOTTOM, /* 3 */ TEXTBOX_POS_MIDDLE -} TextBoxPosition; +}; -typedef struct { +struct MessageTableEntry { u16 textId; u8 typePos; const char* segment; u32 length; -} MessageTableEntry; +}; /* * Message Symbol Declarations */ #define DEFINE_MESSAGE(textId, type, yPos, staffMessage) \ - extern const char _message_##textId##_staff[]; + extern "C" const char _message_##textId##_staff[]; #include "text/message_data_staff.h" #undef DEFINE_MESSAGE #define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - extern const char _message_##textId##_nes[]; \ - extern const char _message_##textId##_ger[]; \ - extern const char _message_##textId##_fra[]; + extern "C" const char _message_##textId##_nes[]; \ + extern "C" const char _message_##textId##_ger[]; \ + extern "C" const char _message_##textId##_fra[]; #include "text/message_data.h" -extern const char _message_0xFFFC_nes[72]; +extern "C" const char _message_0xFFFC_nes[73]; + #undef DEFINE_MESSAGE diff --git a/include/n64fault.h b/include/n64fault.h index 82e3ee28c..71359c1b4 100644 --- a/include/n64fault.h +++ b/include/n64fault.h @@ -3,29 +3,29 @@ #include "sched.h" #include "padmgr.h" -typedef struct FaultClient { +struct FaultClient { /* 0x00 */ struct FaultClient* next; /* 0x04 */ u32 callback; /* 0x08 */ u32 param1; /* 0x0C */ u32 param2; -} FaultClient; // size = 0x10 +}; // size = 0x10 -typedef struct FaultAddrConvClient { +struct FaultAddrConvClient { /* 0x00 */ struct FaultAddrConvClient* next; /* 0x04 */ u32 callback; /* 0x08 */ u32 param; -} FaultAddrConvClient; // size = 0xC +}; // size = 0xC -typedef struct { +struct FaultClientContext { /* 0x00 */ u32 (*callback)(u32, u32); /* 0x04 */ u32 param0; /* 0x08 */ u32 param1; /* 0x0C */ u32 ret; /* 0x10 */ OSMesgQueue* queue; /* 0x14 */ OSMesg msg; -} FaultClientContext; // size = 0x18 +}; // size = 0x18 -typedef struct FaultThreadStruct { +struct FaultThreadStruct { /* 0x000 */ OSThread thread; /* 0x1B0 */ u8 unk_1B0[0x600]; /* 0x7B0 */ OSMesgQueue queue; @@ -44,9 +44,9 @@ typedef struct FaultThreadStruct { /* 0x844 */ void* fb; /* 0x848 */ u32 currClientThreadSp; /* 0x84C */ u8 unk_84C[4]; -} FaultThreadStruct; // size = 0x850 +}; // size = 0x850 -typedef struct { +struct FaultDrawer { /* 0x00 */ u16* fb; /* 0x04 */ u16 w; /* 0x08 */ u16 h; @@ -67,4 +67,4 @@ typedef struct { /* 0x34 */ u8 escCode; // bool /* 0x35 */ u8 osSyncPrintfEnabled; /* 0x38 */ void (*inputCallback)(); -} FaultDrawer; // size = 0x3C +}; // size = 0x3C diff --git a/include/n64mapdata.h b/include/n64mapdata.h index a84e6c87d..cc38617a3 100644 --- a/include/n64mapdata.h +++ b/include/n64mapdata.h @@ -1,7 +1,7 @@ #pragma once #include "ultra64/types.h" -typedef enum { +enum FloorID { /* 1 */ F_8F = 1, /* 2 */ F_7F, /* 3 */ F_6F, @@ -18,12 +18,12 @@ typedef enum { /* 14 */ F_B6, /* 15 */ F_B7, /* 16 */ F_B8 -} FloorID; +}; // All arrays pointed in this struct are indexed by "map indexes" // In dungeons, the map index corresponds to the dungeon index (which also indexes keys, items, etc) // In overworld areas, the map index corresponds to the overworld area index (spot 00, 01, etc) -typedef struct { +struct MapData { /* 0x00 */ s16 (*floorTexIndexOffset)[8]; // dungeon texture index offset by floor /* 0x04 */ s16* bossFloor; // floor the boss is on /* 0x08 */ s16 (*roomPalette)[32]; // map palette by room @@ -53,7 +53,7 @@ typedef struct { /* 0x64 */ u8 (*switchToRoom)[51]; // room to go to /* 0x68 */ u8 (*floorID)[8]; /* 0x6C */ s16* skullFloorIconY; // dungeon big skull icon Y pos -} MapData; // size = 0x70 +}; // size = 0x70 void Map_SavePlayerInitialInfo(struct GlobalContext* globalCtx); void Map_SetFloorPalettesData(struct GlobalContext* globalCtx, s16 floor); diff --git a/include/padmgr.h b/include/padmgr.h index e9efc32f9..abcb3ee58 100644 --- a/include/padmgr.h +++ b/include/padmgr.h @@ -3,14 +3,14 @@ #include "ultra64/controller.h" #include "ultra64/pfs.h" -typedef struct { +struct Input { /* 0x00 */ OSContPad cur; /* 0x06 */ OSContPad prev; /* 0x0C */ OSContPad press; // X/Y store delta from last frame /* 0x12 */ OSContPad rel; // X/Y store adjusted -} Input; // size = 0x18 +}; // size = 0x18 -typedef struct PadMgr { +struct PadMgr { /* 0x0000 */ OSContStatus padStatus[4]; /* 0x0010 */ OSMesg serialMsgBuf[1]; /* 0x0014 */ OSMesg lockMsgBuf[1]; @@ -35,9 +35,9 @@ typedef struct PadMgr { /* 0x045E */ u8 preNMIShutdown; /* 0x0460 */ void (*retraceCallback)(struct PadMgr* padmgr, s32 unk464); /* 0x0464 */ u32 retraceCallbackValue; -} PadMgr; // size = 0x468 +}; // size = 0x468 -typedef struct { +struct UnkRumbleStruct { /* 0x000 */ u8 rumbleEnable[4]; /* 0x004 */ u8 unk_04[0x40]; /* 0x044 */ u8 unk_44[0x40]; @@ -51,7 +51,7 @@ typedef struct { /* 0x10B */ u8 unk_10B; /* 0x10C */ u8 unk_10C; /* 0x10D */ u8 unk_10D; -} UnkRumbleStruct; // size = 0x10E +}; // size = 0x10E extern PadMgr gPadMgr; extern u32 gIsCtrlr2Valid; diff --git a/include/porting_defs.h b/include/porting_defs.h index a07da2320..e24680537 100644 --- a/include/porting_defs.h +++ b/include/porting_defs.h @@ -41,3 +41,4 @@ #define POINTER_ADD(a, b) ((uintptr_t)a + (uintptr_t)b) #define POINTER_SUB(a, b) (MAX((uintptr_t)a, (uintptr_t)b) - MIN((uintptr_t)a, (uintptr_t)b)) +#define POINTER_SUB2(a, b) (MAX((uintptr_t)a.get(), (uintptr_t)b.get()) - MIN((uintptr_t)a.get(), (uintptr_t)b.get())) diff --git a/include/quake.h b/include/quake.h index ef830578c..bdd7bb787 100644 --- a/include/quake.h +++ b/include/quake.h @@ -3,13 +3,13 @@ #include "z64camera.h" #include "z64math.h" -typedef struct { +struct SubQuakeRequest14 { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; /* 0x04 */ s16 unk_04; -} SubQuakeRequest14; +}; -typedef struct { +struct QuakeRequest { /* 0x00 */ s16 randIdx; /* 0x02 */ s16 countdownMax; /* 0x04 */ Camera* cam; @@ -23,24 +23,24 @@ typedef struct { /* 0x1C */ s16 unk_1C; /* 0x1E */ s16 countdown; /* 0x20 */ s16 camPtrIdx; -} QuakeRequest; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct ShakeInfo { /* 0x00 */ Vec3f vec1; /* 0x0C */ Vec3f vec2; /* 0x18 */ s16 rotZ; /* 0x1A */ s16 unk_1A; /* 0x1C */ s16 zoom; -} ShakeInfo; // size = 0x1E +}; // size = 0x1E -typedef struct { +struct QuakeCamCalc { /* 0x00 */ Vec3f atOffset; /* 0x0C */ Vec3f eyeOffset; /* 0x18 */ s16 rotZ; /* 0x1A */ s16 unk_1A; /* 0x1C */ s16 zoom; /* 0x20 */ f32 unk_20; -} QuakeCamCalc; // size = 0x24 +}; // size = 0x24 /* Vec3f* Quake_AddVec(Vec3f* dst, Vec3f* arg1, VecSph* arg2); diff --git a/include/sched.h b/include/sched.h index ace70cb48..ffbd18a5e 100644 --- a/include/sched.h +++ b/include/sched.h @@ -25,17 +25,17 @@ #define OS_SC_RCP_MASK 0x0003 #define OS_SC_TYPE_MASK 0x0007 -typedef struct { +struct OSScMsg { /* 0x00 */ s16 type; /* 0x02 */ char misc[0x1E]; -} OSScMsg; // size = 0x20 +}; // size = 0x20 -typedef struct IrqMgrClient { +struct IrqMgrClient { /* 0x00 */ struct IrqMgrClient* prev; /* 0x04 */ OSMesgQueue* queue; -} IrqMgrClient; +}; -typedef struct { +struct IrqMgr { /* 0x000 */ OSScMsg retraceMsg; // this apparently got moved from OSSched /* 0x020 */ OSScMsg prenmiMsg; // this apparently got moved from OSSched /* 0x040 */ OSScMsg nmiMsg; @@ -47,9 +47,9 @@ typedef struct { /* 0x250 */ OSTime resetTime; /* 0x258 */ OSTimer timer; /* 0x278 */ OSTime retraceTime; -} IrqMgr; // size = 0x280 +}; // size = 0x280 -typedef struct CfbInfo { +struct CfbInfo { /* 0x00 */ u16* fb1; /* 0x04 */ u16* swapBuffer; /* 0x08 */ struct OSViMode* viMode; @@ -60,9 +60,9 @@ typedef struct CfbInfo { /* 0x13 */ u8 unk_13; /* 0x14 */ f32 xScale; /* 0x18 */ f32 yScale; -} CfbInfo; // size = 0x1C +}; // size = 0x1C -typedef struct OSScTask { +struct OSScTask { /* 0x00 */ struct OSScTask* next; /* 0x04 */ u32 state; /* 0x08 */ u32 flags; @@ -70,9 +70,9 @@ typedef struct OSScTask { /* 0x10 */ OSTask list; /* 0x50 */ OSMesgQueue* msgQ; /* 0x54 */ OSMesg msg; -} OSScTask; +}; -typedef struct { +struct SchedContext { /* 0x0000 */ OSMesgQueue interruptQ; /* 0x0018 */ OSMesg intBuf[8]; /* 0x0038 */ OSMesgQueue cmdQ; @@ -91,7 +91,7 @@ typedef struct { /* 0x0220 */ CfbInfo* pendingSwapBuf2; /* 0x0220 */ UNK_TYPE4 unk_24C; /* 0x0250 */ IrqMgrClient irqClient; -} SchedContext; // size = 0x258 +}; // size = 0x258 extern SchedContext gSchedContext; diff --git a/include/sequence.h b/include/sequence.h index c29fb200e..2fc2fb5da 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -117,18 +117,18 @@ #define NA_BGM_NATURE_SFX_RAIN 0x80 // Related to rain #define NA_BGM_DISABLED 0xFFFF -typedef enum { +enum SequencePlayerId { /* 0 */ SEQ_PLAYER_BGM_MAIN, /* 1 */ SEQ_PLAYER_FANFARE, /* 2 */ SEQ_PLAYER_SFX, /* 3 */ SEQ_PLAYER_BGM_SUB -} SequencePlayerId; +}; -typedef enum { +enum SequenceMode { /* 0 */ SEQ_MODE_DEFAULT, /* 1 */ SEQ_MODE_ENEMY, /* 2 */ SEQ_MODE_STILL, // Not moving or first-person view /* 3 */ SEQ_MODE_IGNORE -} SequenceMode; +}; #endif diff --git a/include/speedmeter.h b/include/speedmeter.h index 352cfb58d..f6bf20c31 100644 --- a/include/speedmeter.h +++ b/include/speedmeter.h @@ -2,13 +2,13 @@ #include "ultra64/types.h" #include "ultra64/time.h" -typedef struct { +struct SpeedMeter { /* 0x00 */ char unk_00[0x18]; /* 0x18 */ s32 unk_18; /* 0x1C */ s32 y; -} SpeedMeter; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct SpeedMeterAllocEntry { /* 0x00 */ s32 maxval; /* 0x04 */ s32 val; /* 0x08 */ u16 backColor; @@ -17,14 +17,14 @@ typedef struct { /* 0x10 */ s32 lrx; /* 0x14 */ s32 uly; /* 0x18 */ s32 lry; -} SpeedMeterAllocEntry; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct SpeedMeterTimeEntry { /* 0x00 */ volatile OSTime* time; /* 0x04 */ u8 x; /* 0x05 */ u8 y; /* 0x06 */ u16 color; -} SpeedMeterTimeEntry; // size = 0x08 +}; // size = 0x08 extern volatile OSTime D_8016A520; extern volatile OSTime D_8016A528; diff --git a/include/ultra64/abi.h b/include/ultra64/abi.h index 7e6208113..00cc4c33c 100644 --- a/include/ultra64/abi.h +++ b/include/ultra64/abi.h @@ -51,147 +51,148 @@ * Data Structures. */ -typedef struct { +struct Aadpcm { u32 cmd : 8; u32 flags : 8; u32 gain : 16; u32 addr; -} Aadpcm; +}; -typedef struct { +struct Apolef { u32 cmd : 8; u32 flags : 8; u32 gain : 16; u32 addr; -} Apolef; +}; -typedef struct { +struct Aenvelope { u32 cmd : 8; u32 flags : 8; u32 pad1 : 16; u32 addr; -} Aenvelope; +}; -typedef struct { +struct Aclearbuff { u32 cmd : 8; u32 pad1 : 8; u32 dmem : 16; u32 pad2 : 16; u32 count : 16; -} Aclearbuff; +}; -typedef struct { +struct Ainterleave { u32 cmd : 8; u32 pad1 : 8; u32 pad2 : 16; u32 inL : 16; u32 inR : 16; -} Ainterleave; +}; -typedef struct { +struct Aloadbuff { u32 cmd : 8; u32 pad1 : 24; u32 addr; -} Aloadbuff; +}; -typedef struct { +struct Aenvmixer { u32 cmd : 8; u32 flags : 8; u32 pad1 : 16; u32 addr; -} Aenvmixer; +}; -typedef struct { +struct Amixer { u32 cmd : 8; u32 flags : 8; u32 gain : 16; u32 dmemi : 16; u32 dmemo : 16; -} Amixer; +}; -typedef struct { +struct Apan { u32 cmd : 8; u32 flags : 8; u32 dmem2 : 16; u32 addr; -} Apan; +}; -typedef struct { +struct Aresample { u32 cmd : 8; u32 flags : 8; u32 pitch : 16; u32 addr; -} Aresample; +}; -typedef struct { +struct Areverb { u32 cmd : 8; u32 flags : 8; u32 pad1 : 16; u32 addr; -} Areverb; +}; -typedef struct { +struct Asavebuff { u32 cmd : 8; u32 pad1 : 24; u32 addr; -} Asavebuff; +}; -typedef struct { +struct Asegment { u32 cmd : 8; u32 pad1 : 24; u32 pad2 : 2; u32 number : 4; u32 base : 24; -} Asegment; +}; -typedef struct { +struct Asetbuff { u32 cmd : 8; u32 flags : 8; u32 dmemin : 16; u32 dmemout : 16; u32 count : 16; -} Asetbuff; +}; -typedef struct { +struct Asetvol { u32 cmd : 8; u32 flags : 8; u32 vol : 16; u32 voltgt : 16; u32 volrate : 16; -} Asetvol; +}; -typedef struct { +struct Admemmove { u32 cmd : 8; u32 pad1 : 8; u32 dmemin : 16; u32 dmemout : 16; u32 count : 16; -} Admemmove; +}; -typedef struct { +struct Aloadadpcm { u32 cmd : 8; u32 pad1 : 8; u32 count : 16; u32 addr; -} Aloadadpcm; +}; -typedef struct { +struct Asetloop { u32 cmd : 8; u32 pad1 : 8; u32 pad2 : 16; u32 addr; -} Asetloop; +}; /* * Generic Acmd Packet */ -typedef struct { +struct Awords { uintptr_t w0; uintptr_t w1; -} Awords; +}; -typedef union { +union Acmd +{ Awords words; Aadpcm adpcm; Apolef polef; @@ -211,7 +212,7 @@ typedef union { Amixer mixer; Asetloop setloop; long long int force_union_align; /* dummy, force alignment */ -} Acmd; +}; /* * ADPCM State diff --git a/include/ultra64/controller.h b/include/ultra64/controller.h index 3758f937c..8f0180228 100644 --- a/include/ultra64/controller.h +++ b/include/ultra64/controller.h @@ -98,34 +98,34 @@ #define BTN_B 0x4000 #define BTN_A 0x8000 -typedef struct { +struct OSPifRam { /* 0x00 */ u32 ram[15]; /* 0x3C */ uintptr_t status; -} OSPifRam; // size = 0x40 +}; // size = 0x40 -typedef struct { +struct OSContStatus { /* 0x00 */ u16 type; /* 0x02 */ u8 status; /* 0x03 */ u8 errnum; -} OSContStatus; // size = 0x04 +}; // size = 0x04 -typedef struct { +struct OSContPad { /* 0x00 */ u16 button; /* 0x02 */ s8 stick_x; /* 0x03 */ s8 stick_y; /* 0x04 */ u8 errnum; -} OSContPad; // size = 0x06 +}; // size = 0x06 -typedef struct { +struct OSContRamIo { /* 0x00 */ void* address; /* 0x04 */ u8 databuffer[32]; /* 0x24 */ u8 addressCrc; /* 0x25 */ u8 dataCrc; /* 0x26 */ u8 errnum; -} OSContRamIo; // size = 0x28 +}; // size = 0x28 // Original name: __OSContRequesFormat -typedef struct { +struct __OSContRequestHeader { /* 0x00 */ u8 align; /* 0x01 */ u8 txsize; /* 0x02 */ u8 rxsize; @@ -134,20 +134,20 @@ typedef struct { /* 0x05 */ u8 typel; /* 0x06 */ u8 status; /* 0x07 */ u8 align1; -} __OSContRequestHeader; // size = 0x8 +}; // size = 0x8 // Original name: __OSContRequesHeaderFormatShort -typedef struct { +struct __OSContRequestHeaderAligned { /* 0x00 */ u8 txsize; /* 0x01 */ u8 rxsize; /* 0x02 */ u8 poll; /* 0x03 */ u8 typeh; /* 0x04 */ u8 typel; /* 0x05 */ u8 status; -} __OSContRequestHeaderAligned; // size = 0x6 +}; // size = 0x6 // Original Name: __OSContRamReadFormat -typedef struct { +struct __OSContRamHeader { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 txsize; /* 0x02 */ u8 rxsize; @@ -156,10 +156,10 @@ typedef struct { /* 0x05 */ u8 lo; /* 0x06 */ u8 data[BLOCKSIZE]; /* 0x26 */ u8 datacrc; -} __OSContRamHeader; // size = 0x27 +}; // size = 0x27 // Original name: __OSContReadFormat -typedef struct { +struct __OSContReadHeader { /* 0x00 */ u8 align; /* 0x01 */ u8 txsize; /* 0x02 */ u8 rxsize; @@ -167,6 +167,6 @@ typedef struct { /* 0x04 */ u16 button; /* 0x06 */ s8 joyX; /* 0x07 */ s8 joyY; -} __OSContReadHeader; // size = 0x8 +}; // size = 0x8 #endif diff --git a/include/ultra64/exception.h b/include/ultra64/exception.h index 7207ba30a..aa3271bb0 100644 --- a/include/ultra64/exception.h +++ b/include/ultra64/exception.h @@ -27,14 +27,10 @@ typedef u32 OSIntMask; typedef u32 OSHWIntr; -typedef struct { +struct __osHwInt { /* 0x00 */ void* callback; /* 0x04 */ void* sp; -} __osHwInt; // size = 0x08 - -#ifdef __cplusplus -extern "C" { -#endif +}; // size = 0x08 OSIntMask osSetIntMask(OSIntMask); @@ -46,8 +42,4 @@ void __osResetGlobalIntMask(OSHWIntr mask); extern __osHwInt __osHwIntTable[]; -#ifdef __cplusplus -} -#endif - #endif diff --git a/include/ultra64/gbi.h b/include/ultra64/gbi.h index 00c71d0b9..3064dd59e 100644 --- a/include/ultra64/gbi.h +++ b/include/ultra64/gbi.h @@ -1020,35 +1020,35 @@ /* * Vertex (set up for use with colors) */ -typedef struct { +struct Vtx_t { short ob[3]; /* x, y, z */ unsigned short flag; short tc[2]; /* texture coord */ unsigned char cn[4]; /* color & alpha */ -} Vtx_t; +}; /* * Vertex (set up for use with normals) */ -typedef struct { +struct Vtx_tn { short ob[3]; /* x, y, z */ unsigned short flag; short tc[2]; /* texture coord */ signed char n[3]; /* normal */ unsigned char a; /* alpha */ -} Vtx_tn; +}; -typedef union { +union Vtx { Vtx_t v; /* Use this one for colors */ Vtx_tn n; /* Use this one for normals */ long long int force_structure_alignment; -} Vtx; +}; /* * Sprite structure */ -typedef struct { +struct uSprite_t { void *SourceImagePointer; void *TlutPointer; short Stride; @@ -1063,22 +1063,22 @@ typedef struct { /* padding to bring structure size to 64 bit allignment */ char dummy[4]; -} uSprite_t; +}; -typedef union { +union uSprite { uSprite_t s; /* Need to make sure this is 64 bit aligned */ long long int force_structure_allignment[3]; -} uSprite; +}; /* * Triangle face */ -typedef struct { +struct Tri { unsigned char flag; unsigned char v[3]; -} Tri; +}; /* * Viewport @@ -1114,16 +1114,16 @@ typedef struct { * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, G_MAXZ, 0, * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, 0, 0, */ -typedef struct { +struct Vp_t { short vscale[4]; /* scale, 2 bits fraction */ short vtrans[4]; /* translate, 2 bits fraction */ /* both the above arrays are padded to 64-bit boundary */ -} Vp_t; +}; -typedef union { +union Vp { Vp_t vp; long long int force_structure_alignment; -} Vp; +}; /* * MOVEMEM indices @@ -1280,89 +1280,89 @@ typedef union { * */ -typedef struct { +struct Light_t { unsigned char col[3]; /* diffuse light value (rgba) */ char pad1; unsigned char colc[3]; /* copy of diffuse light value (rgba) */ char pad2; signed char dir[3]; /* direction of light (normalized) */ char pad3; -} Light_t; +}; -typedef struct { +struct Ambient_t { unsigned char col[3]; /* ambient light value (rgba) */ char pad1; unsigned char colc[3]; /* copy of ambient light value (rgba) */ char pad2; -} Ambient_t; +}; -typedef struct { +struct Hilite_t { int x1,y1,x2,y2; /* texture offsets for highlight 1/2 */ -} Hilite_t; +}; -typedef union { +union Light { Light_t l; long long int force_structure_alignment[2]; -} Light; +}; -typedef union { +union Ambient { Ambient_t l; long long int force_structure_alignment[1]; -} Ambient; +}; -typedef struct { +struct Lightsn { Ambient a; Light l[7]; -} Lightsn; +}; -typedef struct { +struct Lights0 { Ambient a; Light l[1]; -} Lights0; +}; -typedef struct { +struct Lights1 { Ambient a; Light l[1]; -} Lights1; +}; -typedef struct { +struct Lights2 { Ambient a; Light l[2]; -} Lights2; +}; -typedef struct { +struct Lights3 { Ambient a; Light l[3]; -} Lights3; +}; -typedef struct { +struct Lights4 { Ambient a; Light l[4]; -} Lights4; +}; -typedef struct { +struct Lights5 { Ambient a; Light l[5]; -} Lights5; +}; -typedef struct { +struct Lights6 { Ambient a; Light l[6]; -} Lights6; +}; -typedef struct { +struct Lights7 { Ambient a; Light l[7]; -} Lights7; +}; -typedef struct { +struct LookAt { Light l[2]; -} LookAt; +}; -typedef union { +union Hilite { Hilite_t h; long int force_structure_alignment[4]; -} Hilite; +}; #define gdSPDefLights0(ar,ag,ab) \ { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ @@ -1422,28 +1422,28 @@ typedef union { /* * Graphics DMA Packet */ -typedef struct { +struct Gdma { int cmd:8; unsigned int par:8; unsigned int len:16; uintptr_t addr; -} Gdma; +}; /* * Graphics Immediate Mode Packet types */ -typedef struct { +struct Gtri { int cmd:8; int pad:24; Tri tri; -} Gtri; +}; -typedef struct { +struct Gpopmtx { int cmd:8; int pad1:24; int pad2:24; int param:8; -} Gpopmtx; +}; /* * typedef struct { @@ -1454,81 +1454,81 @@ typedef struct { * int base:24; * } Gsegment; */ -typedef struct { +struct Gsegment { int cmd:8; int pad0:8; int mw_index:8; int number:8; int pad1:8; int base:24; -} Gsegment; +}; -typedef struct { +struct GsetothermodeL { int cmd:8; int pad0:8; int sft:8; int len:8; unsigned int data:32; -} GsetothermodeL; +}; -typedef struct { +struct GsetothermodeH { int cmd:8; int pad0:8; int sft:8; int len:8; unsigned int data:32; -} GsetothermodeH; +}; -typedef struct { +struct Gtexture { unsigned char cmd; unsigned char lodscale; unsigned char tile; unsigned char on; unsigned short s; unsigned short t; -} Gtexture; +}; -typedef struct { +struct Gline3D { int cmd:8; int pad:24; Tri line; -} Gline3D; +}; -typedef struct { +struct Gperspnorm { int cmd:8; int pad1:24; short int pad2; short int scale; -} Gperspnorm; +}; /* * RDP Packet types */ -typedef struct { +struct Gsetimg { int cmd:8; unsigned int fmt:3; unsigned int siz:2; unsigned int pad:7; unsigned int wd:12; /* really only 10 bits, extra */ uintptr_t dram; /* to account for 1024 */ -} Gsetimg; +}; -typedef struct { +struct Gsetcombine { int cmd:8; unsigned int muxs0:24; unsigned int muxs1:32; -} Gsetcombine; +}; -typedef struct { +struct Gsetcolor { unsigned char cmd:8; unsigned char pad; unsigned char prim_min_level; unsigned char prim_level; unsigned long color; -} Gsetcolor; +}; -typedef struct { +struct Gfillrect { int cmd:8; int x0:10; int x0frac:2; @@ -1539,9 +1539,9 @@ typedef struct { int x1frac:2; int y1:10; int y1frac:2; -} Gfillrect; +}; -typedef struct { +struct Gsettile { int cmd:8; unsigned int fmt:3; unsigned int siz:2; @@ -1559,9 +1559,9 @@ typedef struct { unsigned int ms:1; unsigned int masks:4; unsigned int shifts:4; -} Gsettile; +}; -typedef struct { +struct Gloadtile { int cmd:8; unsigned int sl:12; unsigned int tl:12; @@ -1569,7 +1569,7 @@ typedef struct { unsigned int tile:3; unsigned int sh:12; unsigned int th:12; -} Gloadtile; +}; typedef Gloadtile Gloadblock; @@ -1577,7 +1577,7 @@ typedef Gloadtile Gsettilesize; typedef Gloadtile Gloadtlut; -typedef struct { +struct Gtexrect { unsigned int cmd:8; /* command */ unsigned int xl:12; /* X coordinate of upper left */ unsigned int yl:12; /* Y coordinate of upper left */ @@ -1589,7 +1589,7 @@ typedef struct { unsigned int t:16; /* T texture coord at top left */ unsigned int dsdx:16;/* Change in S per change in X */ unsigned int dtdy:16;/* Change in T per change in Y */ -} Gtexrect; +}; #define MakeTexRect(xh,yh,flip,tile,xl,yl,s,t,dsdx,dtdy) \ G_TEXRECT, xh, yh, 0, flip, 0, tile, xl, yl, s, t, dsdx, dtdy @@ -1597,35 +1597,35 @@ typedef struct { /* * Textured rectangles are 128 bits not 64 bits */ -typedef struct { +struct TexRect { unsigned long w0; unsigned long w1; unsigned long w2; unsigned long w3; -} TexRect; +}; /* * Generic Gfx Packet */ -typedef struct { +struct Gwords { uintptr_t w0; uintptr_t w1; -} Gwords; +}; #ifdef EXTENDED_GFX -typedef struct { +struct GDwords { uintptr_t w0; uintptr_t w1; uintptr_t w2; uintptr_t w3; -} GDwords; +}; #endif /* * This union is the fundamental type of the display list. * It is, by law, exactly 64 bits in size. */ -typedef union { +union Gfx { Gwords words; #ifdef EXTENDED_GFX GDwords dwords; @@ -1648,7 +1648,7 @@ typedef union { Gsettilesize settilesize; Gloadtlut loadtlut; // long long int force_structure_alignment; -} Gfx; +}; static_assert(sizeof(Gwords) == (WORD_BITS / 8 * 2), "Gwords is incorrect size"); static_assert(sizeof(Gdma) == (WORD_BITS / 8 * 2), "Gdma is incorrect size"); diff --git a/include/ultra64/gs2dex.h b/include/ultra64/gs2dex.h index 5c0bc7175..d21b5f71c 100644 --- a/include/ultra64/gs2dex.h +++ b/include/ultra64/gs2dex.h @@ -1,10 +1,6 @@ #ifndef GS2DEX_H #define GS2DEX_H -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - /*===========================================================================* * Macro *===========================================================================*/ @@ -91,11 +87,11 @@ typedef struct { } uObjScaleBg_t; /* 40 bytes */ -typedef union { +union uObjBg { uObjBg_t b; uObjScaleBg_t s; long long int force_structure_alignment; -} uObjBg; +}; /*---------------------------------------------------------------------------* * 2D Objects @@ -103,7 +99,7 @@ typedef union { #define G_OBJ_FLAG_FLIPS 1<<0 /* inversion to S-direction */ #define G_OBJ_FLAG_FLIPT 1<<4 /* nversion to T-direction */ -typedef struct { +struct uObjSprite_t { s16 objX; /* s10.2 OBJ x-coordinate of upper-left end */ u16 scaleW; /* u5.10 Scaling of u5.10 width direction */ u16 imageW; /* u10.5 width of u10.5 texture (length of S-direction) */ @@ -118,38 +114,38 @@ typedef struct { u8 imageSiz; /* size of texel - G_IM_SIZ_* */ u8 imagePal; /* pallet number (0-7) */ u8 imageFlags; /* The display flag - G_OBJ_FLAG_FLIP* */ -} uObjSprite_t; /* 24 bytes */ +}; /* 24 bytes */ -typedef union { +union uObjSprite { uObjSprite_t s; long long int force_structure_alignment; -} uObjSprite; +}; /*---------------------------------------------------------------------------* * 2D Matrix *---------------------------------------------------------------------------*/ -typedef struct { +struct uObjMtx_t { s32 A, B, C, D; /* s15.16 */ s16 X, Y; /* s10.2 */ u16 BaseScaleX; /* u5.10 */ u16 BaseScaleY; /* u5.10 */ -} uObjMtx_t; /* 24 bytes */ +}; /* 24 bytes */ -typedef union { +union uObjMtx { uObjMtx_t m; long long int force_structure_alignment; -} uObjMtx; +}; -typedef struct { +struct uObjSubMtx_t { s16 X, Y; /* s10.2 */ u16 BaseScaleX; /* u5.10 */ u16 BaseScaleY; /* u5.10 */ -} uObjSubMtx_t; /* 8 bytes */ +}; /* 8 bytes */ -typedef union { +union uObjSubMtx { uObjSubMtx_t m; long long int force_structure_alignment; -} uObjSubMtx; +}; /*---------------------------------------------------------------------------* * Loading into TMEM @@ -200,12 +196,12 @@ typedef struct { u32 mask; /* STATE mask */ } uObjTxtrTLUT_t; /* 24 bytes */ -typedef union { +union uObjTxtr { uObjTxtrBlock_t block; uObjTxtrTile_t tile; uObjTxtrTLUT_t tlut; long long int force_structure_alignment; -} uObjTxtr; +}; /*---------------------------------------------------------------------------* * Loading into TMEM & 2D Objects @@ -371,9 +367,6 @@ extern void guS2DInitBg(uObjBg *); extern void guS2DEmuBgRect1Cyc(Gfx **, uObjBg *); #endif -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif #endif /* GS2DEX_H */ /*======== End of gs2dex.h ========*/ diff --git a/include/ultra64/internal.h b/include/ultra64/internal.h index a301f4a70..2872cd327 100644 --- a/include/ultra64/internal.h +++ b/include/ultra64/internal.h @@ -3,7 +3,7 @@ #include "pi.h" -typedef struct { +struct OSMgrArgs { /* 0x00 */ u32 initialized; /* 0x04 */ OSThread* mgrThread; /* 0x08 */ OSMesgQueue* cmdQueue; @@ -11,12 +11,12 @@ typedef struct { /* 0x10 */ OSMesgQueue* acccessQueue; /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); -} OSMgrArgs; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct __OSEventState { /* 0x00 */ OSMesgQueue* queue; /* 0x04 */ OSMesg msg; -} __OSEventState; // size = 0x08 +}; // size = 0x08 extern OSMgrArgs __osPiDevMgr; extern __OSEventState __osEventStateTab[]; diff --git a/include/ultra64/message.h b/include/ultra64/message.h index d463ec4c6..3eb3c305e 100644 --- a/include/ultra64/message.h +++ b/include/ultra64/message.h @@ -27,13 +27,13 @@ typedef u32 OSEvent; #define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ #define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ -typedef struct OSMesgQueue { +struct OSMesgQueue { /* 0x00 */ OSThread* mtqueue; /* 0x04 */ OSThread* fullqueue; /* 0x08 */ s32 validCount; /* 0x0C */ s32 first; /* 0x10 */ s32 msgCount; /* 0x14 */ OSMesg* msg; -} OSMesgQueue; // size = 0x18 +}; // size = 0x18 #endif diff --git a/include/ultra64/pfs.h b/include/ultra64/pfs.h index 8c13a3b45..1780a277f 100644 --- a/include/ultra64/pfs.h +++ b/include/ultra64/pfs.h @@ -69,7 +69,7 @@ #define PFS_INODE_DIST_MAP (PFS_BANK_LAPPED_BY * PFS_SECTOR_PER_BANK) #define PFS_SECTOR_SIZE (PFS_INODE_SIZE_PER_PAGE/PFS_SECTOR_PER_BANK) -typedef struct { +struct OSPfs { /* 0x00 */ s32 status; /* 0x04 */ OSMesgQueue* queue; /* 0x08 */ s32 channel; @@ -83,15 +83,15 @@ typedef struct { /* 0x60 */ s32 inodeStartPage; /* page # */ /* 0x64 */ u8 banks; /* 0x65 */ u8 activebank; -} OSPfs; // size = 0x68 +}; // size = 0x68 -typedef struct { +struct OSPfsState { /* 0x00 */ u32 file_size; /* bytes */ /* 0x04 */ u32 game_code; /* 0x08 */ u16 company_code; /* 0x0C */ char ext_name[4]; /* 0x10 */ char game_name[16]; -} OSPfsState; // size = 0x20 +}; // size = 0x20 typedef union { struct { @@ -101,11 +101,11 @@ typedef union { /* 0x00 */ u16 ipage; } __OSInodeUnit; // size = 0x02 -typedef struct { +struct __OSInode { /* 0x00 */ __OSInodeUnit inodePage[128]; -} __OSInode; // size = 0x100 +}; // size = 0x100 -typedef struct { +struct __OSDir { /* 0x00 */ u32 game_code; /* 0x04 */ u16 company_code; /* 0x06 */ __OSInodeUnit start_page; @@ -114,9 +114,9 @@ typedef struct { /* 0x0A */ u16 data_sum; /* 0x0C */ u8 ext_name[PFS_FILE_EXT_LEN]; /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN]; -} __OSDir; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct __OSPackId { /* 0x00 */ u32 repaired; /* 0x04 */ u32 random; /* 0x08 */ u64 serialMid; @@ -126,12 +126,12 @@ typedef struct { /* 0x1B */ u8 version; /* 0x1C */ u16 checksum; /* 0x1E */ u16 invertedChecksum; -} __OSPackId; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct __OSInodeCache { /* 0x000 */ __OSInode inode; /* 0x100 */ u8 bank; /* 0x101 */ u8 map[PFS_INODE_DIST_MAP]; -} __OSInodeCache; // size = 0x202 +}; // size = 0x202 #endif diff --git a/include/ultra64/pi.h b/include/ultra64/pi.h index 855718995..cf3f4487c 100644 --- a/include/ultra64/pi.h +++ b/include/ultra64/pi.h @@ -3,27 +3,27 @@ #include "message.h" -typedef struct { +struct __OSBlockInfo { /* 0x00 */ u32 errStatus; /* 0x04 */ void* dramAddr; /* 0x08 */ void* C2Addr; /* 0x0C */ u32 sectorSize; /* 0x10 */ u32 C1ErrNum; /* 0x14 */ u32 C1ErrSector[4]; -} __OSBlockInfo; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct __OSTranxInfo { /* 0x00 */ u32 cmdType; /* 0x04 */ u16 transferMode; /* 0x06 */ u16 blockNum; /* 0x08 */ s32 sectorNum; - /* 0x0C */ u32 devAddr; + /* 0x0C */ Pointer devAddr; /* 0x10 */ u32 bmCtlShadow; /* 0x14 */ u32 seqCtlShadow; /* 0x18 */ __OSBlockInfo block[2]; -} __OSTranxInfo; // size = 0x60 +}; // size = 0x60 -typedef struct OSPiHandle { +struct OSPiHandle { /* 0x00 */ struct OSPiHandle* next; /* 0x04 */ u8 type; /* 0x05 */ u8 latency; @@ -31,30 +31,30 @@ typedef struct OSPiHandle { /* 0x07 */ u8 relDuration; /* 0x08 */ u8 pulse; /* 0x09 */ u8 domain; - /* 0x0C */ u32 baseAddress; + /* 0x0C */ Pointer baseAddress; /* 0x10 */ u32 speed; /* 0x14 */ __OSTranxInfo transferInfo; -} OSPiHandle; // size = 0x74 +}; // size = 0x74 -typedef struct { +struct OSPiInfo { /* 0x00 */ u8 type; - /* 0x04 */ u32 address; -} OSPiInfo; // size = 0x08 + /* 0x04 */ Pointer address; +}; // size = 0x08 -typedef struct { +struct OSIoMesgHdr { /* 0x00 */ u16 type; /* 0x02 */ u8 pri; /* 0x03 */ u8 status; /* 0x04 */ OSMesgQueue* retQueue; -} OSIoMesgHdr; // size = 0x08 +}; // size = 0x08 -typedef struct { +struct OSIoMesg { /* 0x00 */ OSIoMesgHdr hdr; - /* 0x08 */ void* dramAddr; - /* 0x0C */ u32 devAddr; + /* 0x08 */ Pointer dramAddr; + /* 0x0C */ Pointer devAddr; /* 0x10 */ size_t size; /* 0x14 */ OSPiHandle* piHandle; -} OSIoMesg; // size = 0x18 +}; // size = 0x18 #define OS_READ 0 // device -> RDRAM #define OS_WRITE 1 // device <- RDRAM diff --git a/include/ultra64/printf.h b/include/ultra64/printf.h index 7724432f6..4abde93ba 100644 --- a/include/ultra64/printf.h +++ b/include/ultra64/printf.h @@ -3,7 +3,8 @@ #include "types.h" -typedef struct { +struct _Pft +{ /* 0x0 */ union { /* 0x0 */ s64 ll; /* 0x0 */ f64 ld; @@ -20,7 +21,7 @@ typedef struct { /* 0x2C */ u32 nchar; /* 0x30 */ u32 flags; /* 0x34 */ u8 qual; -} _Pft; // size = 0x38 +}; // size = 0x38 typedef void* (*PrintCallback)(void*, const char*, u32); diff --git a/include/ultra64/sptask.h b/include/ultra64/sptask.h index 06b4f7709..b8bbf2a76 100644 --- a/include/ultra64/sptask.h +++ b/include/ultra64/sptask.h @@ -28,7 +28,7 @@ #define OS_YIELD_DATA_SIZE 0xC00 -typedef struct { +struct OSTask_t { /* 0x00 */ u32 type; /* 0x04 */ u32 flags; @@ -52,12 +52,12 @@ typedef struct { /* 0x38 */ u64* yield_data_ptr; /* 0x3C */ u32 yield_data_size; -} OSTask_t; // size = 0x40 +}; // size = 0x40 -typedef union { +union OSTask { OSTask_t t; long long int force_structure_alignment; -} OSTask; +}; typedef u32 OSYieldResult; diff --git a/include/ultra64/thread.h b/include/ultra64/thread.h index 69cbc775f..988ceeaf7 100644 --- a/include/ultra64/thread.h +++ b/include/ultra64/thread.h @@ -30,7 +30,7 @@ typedef union { } f; } __OSfp; // size = 0x08 -typedef struct { +struct __OSThreadContext { /* 0x000 */ u64 at, v0, v1, a0, a1, a2, a3; /* 0x038 */ u64 t0, t1, t2, t3, t4, t5, t6, t7; /* 0x078 */ u64 s0, s1, s2, s3, s4, s5, s6, s7; @@ -40,15 +40,15 @@ typedef struct { /* 0x10C */ u32 fpcsr; /* 0x110 */ __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; /* 0x150 */ __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; -} __OSThreadContext; // size = 0x190 +}; // size = 0x190 -typedef struct { +struct __OSThreadprofile { /* 0x00 */ u32 flag; /* 0x04 */ u32 count; /* 0x08 */ u64 time; -} __OSThreadprofile; // size = 0x10 +}; // size = 0x10 -typedef struct OSThread { +struct OSThread { /* 0x00 */ struct OSThread* next; /* 0x04 */ OSPri priority; /* 0x08 */ struct OSThread** queue; @@ -59,6 +59,6 @@ typedef struct OSThread { /* 0x18 */ s32 fp; /* 0x1C */ __OSThreadprofile* thprof; /* 0x20 */ __OSThreadContext context; -} OSThread; // size = 0x1B0 +}; // size = 0x1B0 #endif diff --git a/include/ultra64/time.h b/include/ultra64/time.h index 5c6650b7d..4bf8b38bb 100644 --- a/include/ultra64/time.h +++ b/include/ultra64/time.h @@ -5,13 +5,13 @@ typedef u64 OSTime; -typedef struct OSTimer { +struct OSTimer { /* 0x00 */ struct OSTimer* next; /* 0x04 */ struct OSTimer* prev; /* 0x08 */ OSTime interval; /* 0x10 */ OSTime value; /* 0x18 */ OSMesgQueue* mq; /* 0x1C */ OSMesg msg; -} OSTimer; // size = 0x20 +}; // size = 0x20 #endif diff --git a/include/ultra64/types.h b/include/ultra64/types.h index d134afb69..5067b6f76 100644 --- a/include/ultra64/types.h +++ b/include/ultra64/types.h @@ -40,9 +40,9 @@ typedef union { long long int forc_structure_alignment; } Mtx; #else -typedef struct { +struct Mtx { float m[4][4]; -} Mtx; +}; #endif typedef float MtxF_t[4][4]; @@ -56,3 +56,150 @@ typedef union { }; } MtxF; +class Pointer +{ + public: + constexpr Pointer() : m_address(0) + { + } + + constexpr Pointer(uintptr_t address) : m_address(address) + { + } + + constexpr Pointer(int address) : m_address(address) + { + } + + constexpr Pointer(const void* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(void* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(const s8* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(s8* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(const u8* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(u8* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(const s16* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(s16* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(const u16* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(u16* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(const s32* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(s32* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(const u32* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer(u32* address) : m_address((uintptr_t)address) + { + } + + constexpr Pointer operator + (const Pointer& b) const + { + return Pointer(m_address + b.m_address); + } + + constexpr Pointer operator-(const Pointer& b) const + { + return Pointer(m_address - b.m_address); + } + + Pointer& operator+=(const Pointer& b) + { + m_address += b.m_address; + return *this; + } + + Pointer& operator+=(const uintptr_t b) + { + m_address += b; + return *this; + } + + Pointer& operator-=(const Pointer& b) + { + m_address -= b.m_address; + return *this; + } + + Pointer& operator-=(const uintptr_t b) + { + m_address -= b; + return *this; + } + + bool operator==(uintptr_t n) const + { + return n == m_address; + } + + bool operator==(int n) const + { + return n == m_address; + } + + bool operator!=(uintptr_t n) const + { + return n != m_address; + } + + bool operator!=(int n) const + { + return n != m_address; + } + + uintptr_t size() + { + return m_address; + } + + uintptr_t get() + { + return m_address; + } + + void* buffer() + { + return (void*)m_address; + } + + void* c_str() + { + return (char*)m_address; + } + private: + uintptr_t m_address; +}; diff --git a/include/ultra64/vi.h b/include/ultra64/vi.h index f4f34af5b..88cca1117 100644 --- a/include/ultra64/vi.h +++ b/include/ultra64/vi.h @@ -25,7 +25,7 @@ #define OS_VI_UNK1000 0x1000 #define OS_VI_UNK2000 0x2000 -typedef struct { +struct OSViCommonRegs { /* 0x00 */ u32 ctrl; /* 0x04 */ u32 width; /* 0x08 */ u32 burst; @@ -35,29 +35,29 @@ typedef struct { /* 0x18 */ u32 hStart; /* 0x1C */ u32 xScale; /* 0x20 */ u32 vCurrent; -} OSViCommonRegs; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct OSViFieldRegs { /* 0x00 */ u32 origin; /* 0x04 */ u32 yScale; /* 0x08 */ u32 vStart; /* 0x0C */ u32 vBurst; /* 0x10 */ u32 vIntr; -} OSViFieldRegs; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct OSViMode { /* 0x00 */ u8 type; /* 0x04 */ OSViCommonRegs comRegs; /* 0x24 */ OSViFieldRegs fldRegs[2]; -} OSViMode; // size = 0x4C +}; // size = 0x4C -typedef struct { +struct __OSViScale { /* 0x0 */ f32 factor; /* 0x4 */ u16 offset; /* 0x8 */ u32 scale; -} __OSViScale; // size = 0x0C +}; // size = 0x0C -typedef struct { +struct OSViContext { /* 0x00 */ u16 state; /* 0x02 */ u16 retraceCount; /* 0x04 */ void* buffer; @@ -67,7 +67,7 @@ typedef struct { /* 0x14 */ OSMesg* msg; /* 0x18 */ __OSViScale x; /* 0x24 */ __OSViScale y; -} OSViContext; // size = 0x30 +}; // size = 0x30 #define OS_VI_NTSC_LPN1 0 /* NTSC */ #define OS_VI_NTSC_LPF1 1 diff --git a/include/view.h b/include/view.h index 99dca26e4..8b14987cb 100644 --- a/include/view.h +++ b/include/view.h @@ -3,14 +3,14 @@ #include "z64math.h" #include "ultra64/gbi.h" -typedef struct { +struct Viewport { /* 0x0000 */ s32 topY; // uly (upper left y) /* 0x0004 */ s32 bottomY; // lry (lower right y) /* 0x0008 */ s32 leftX; // ulx (upper left x) /* 0x000C */ s32 rightX; // lrx (lower right x) -} Viewport; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct View { /* 0x0000 */ s32 magic; // string literal "VIEW" / 0x56494557 /* 0x0004 */ struct GraphicsContext* gfxCtx; /* 0x0008 */ Viewport viewport; @@ -34,4 +34,4 @@ typedef struct { /* 0x011C */ u16 normal; // used to normalize the projection matrix /* 0x0120 */ s32 flags; /* 0x0124 */ s32 unk_124; -} View; // size = 0x128 +}; // size = 0x128 diff --git a/include/z64.h b/include/z64.h index ea5a9e32e..0091eb9a9 100644 --- a/include/z64.h +++ b/include/z64.h @@ -25,22 +25,22 @@ #define REGION_NATIVE REGION_EU -typedef struct { +struct SequenceContext { /* 0x00 */ u8 seqId; /* 0x01 */ u8 natureAmbienceId; -} SequenceContext; // size = 0x2 +}; // size = 0x2 -typedef struct { +struct ElfMessage { /* 0x00 */ u8 byte0; /* 0x01 */ u8 byte1; /* 0x02 */ u8 byte2; /* 0x03 */ u8 byte3; -} ElfMessage; // size = 0x4 +}; // size = 0x4 -typedef struct StackEntry { +struct StackEntry { /* 0x00 */ struct StackEntry* next; /* 0x04 */ struct StackEntry* prev; /* 0x08 */ uintptr_t head; @@ -48,22 +48,22 @@ typedef struct StackEntry { /* 0x10 */ u32 initValue; /* 0x14 */ s32 minSpace; /* 0x18 */ const char* name; -} StackEntry; +}; -typedef enum { +enum StackStatus { STACK_STATUS_OK = 0, STACK_STATUS_WARNING = 1, STACK_STATUS_OVERFLOW = 2 -} StackStatus; +}; -typedef struct { +struct ISVDbg { /* 0x00 */ u32 magic; // IS64 /* 0x04 */ u32 get; /* 0x08 */ u8 unk_08[0x14-0x08]; /* 0x14 */ u32 put; /* 0x18 */ u8 unk_18[0x20-0x18]; /* 0x20 */ u8 data[0x10000-0x20]; -} ISVDbg; +}; typedef struct { /* 0x00 */ char name[0x18]; @@ -84,14 +84,14 @@ typedef struct { -typedef struct OverlayRelocationSection { +struct OverlayRelocationSection { /* 0x00 */ u32 textSize; /* 0x04 */ u32 dataSize; /* 0x08 */ u32 rodataSize; /* 0x0C */ u32 bssSize; /* 0x10 */ u32 nRelocations; /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; // size >= 0x18 +}; // size >= 0x18 #define NUM_SEGMENTS (16) extern uintptr_t gSegments[NUM_SEGMENTS]; diff --git a/include/z64actor.h b/include/z64actor.h index 22ed107d5..066b25b08 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -12,12 +12,13 @@ #define MASS_IMMOVABLE 0xFF // Cannot be pushed by OC collisions #define MASS_HEAVY 0xFE // Can only be pushed by OC collisions with IMMOVABLE and HEAVY objects. -typedef enum { +enum DynaPolyMoveFlag +{ DPM_UNK = 0, DPM_PLAYER = 1, DPM_ENEMY = 2, DPM_UNK3 = 3 -} DynaPolyMoveFlag; +}; struct Actor; struct GlobalContext; @@ -28,14 +29,14 @@ typedef void (*ActorShadowFunc)(struct Actor*, struct Lights*, struct GlobalCont typedef u16 (*callback1_800343CC)(struct GlobalContext*, struct Actor*); typedef s16 (*callback2_800343CC)(struct GlobalContext*, struct Actor*); -typedef struct { +struct ActorEntry { /* 0x00 */ s16 id; /* 0x02 */ Vec3s pos; /* 0x08 */ Vec3s rot; /* 0x0E */ s16 params; -} ActorEntry; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct ActorInit { /* 0x00 */ s16 id; /* 0x02 */ u8 category; // Classifies actor and determines when it will update or draw /* 0x04 */ u32 flags; @@ -45,46 +46,48 @@ typedef struct { /* 0x14 */ ActorFunc destroy; // Destructor /* 0x18 */ ActorFunc update; // Update Function /* 0x1C */ ActorFunc draw; // Draw function -} ActorInit; // size = 0x20 +}; // size = 0x20 -typedef enum { +enum AllocType +{ /* 0 */ ALLOCTYPE_NORMAL, /* 1 */ ALLOCTYPE_ABSOLUTE, /* 2 */ ALLOCTYPE_PERMANENT -} AllocType; +}; -typedef struct { - /* 0x00 */ uintptr_t vromStart; - /* 0x04 */ uintptr_t vromEnd; - /* 0x08 */ void* vramStart; - /* 0x0C */ void* vramEnd; - /* 0x10 */ void* loadedRamAddr; // original name: "allocp" +struct ActorOverlay { + /* 0x00 */ Pointer vromStart; + /* 0x04 */ Pointer vromEnd; + /* 0x08 */ Pointer vramStart; + /* 0x0C */ Pointer vramEnd; + /* 0x10 */ Pointer loadedRamAddr; // original name: "allocp" /* 0x14 */ ActorInit* initInfo; - /* 0x18 */ char* name; + /* 0x18 */ const char* name; /* 0x1C */ u16 allocType; /* 0x1E */ s8 numLoaded; // original name: "clients" -} ActorOverlay; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct DamageTable +{ u8 table[32]; -} DamageTable; +}; -typedef struct { +struct CollisionCheckInfoInit { /* 0x00 */ u8 health; /* 0x02 */ s16 cylRadius; /* 0x04 */ s16 cylHeight; /* 0x06 */ u8 mass; -} CollisionCheckInfoInit; +}; -typedef struct { +struct CollisionCheckInfoInit2 { /* 0x00 */ u8 health; /* 0x02 */ s16 cylRadius; /* 0x04 */ s16 cylHeight; /* 0x06 */ s16 cylYShift; /* 0x08 */ u8 mass; -} CollisionCheckInfoInit2; +}; -typedef struct { +struct CollisionCheckInfo { /* 0x00 */ DamageTable* damageTable; /* 0x04 */ Vec3f displacement; // Amount to correct velocity (0x5C) by when colliding into a body /* 0x10 */ s16 cylRadius; // Used for various purposes @@ -96,9 +99,9 @@ typedef struct { /* 0x19 */ u8 damageEffect; // Stores what effect should occur when hit by a weapon /* 0x1A */ u8 atHitEffect; // Stores what effect should occur when AT connects with an AC /* 0x1B */ u8 acHitEffect; // Stores what effect should occur when AC is touched by an AT -} CollisionCheckInfo; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct ActorShape { /* 0x00 */ Vec3s rot; // Current actor shape rotation /* 0x06 */ s16 face; // Used to index eyebrow/eye/mouth textures. Only used by player /* 0x08 */ f32 yOffset; // Model y axis offset. Represents model space units @@ -107,7 +110,7 @@ typedef struct { /* 0x14 */ u8 shadowAlpha; // Default is 255 /* 0x15 */ u8 feetFloorFlags; // Set if the actor's foot is clipped under the floor. & 1 is right foot, & 2 is left /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDraw -} ActorShape; // size = 0x30 +}; // size = 0x30 #define ACTOR_FLAG_0 (1 << 0) #define ACTOR_FLAG_2 (1 << 2) @@ -138,7 +141,7 @@ typedef struct { #define ACTOR_FLAG_27 (1 << 27) #define ACTOR_FLAG_28 (1 << 28) -typedef struct Actor { +struct Actor { /* 0x000 */ s16 id; // Actor ID /* 0x002 */ u8 category; // Actor category. Refer to the corresponding enum for values /* 0x003 */ s8 room; // Room number the actor is in. -1 denotes that the actor won't despawn on a room change @@ -195,12 +198,13 @@ typedef struct Actor { /* 0x134 */ ActorFunc draw; // Draw Routine. Called by `Actor_Draw` /* 0x138 */ ActorOverlay* overlayEntry; // Pointer to the overlay table entry for this actor /* 0x13C */ char dbgPad[0x10]; // Padding that only exists in the debug rom -} Actor; // size = 0x14C +}; // size = 0x14C -typedef enum { +enum ActorFootIndex +{ /* 0 */ FOOT_LEFT, /* 1 */ FOOT_RIGHT -} ActorFootIndex; +}; /* BgCheckFlags WIP documentation: @@ -226,7 +230,7 @@ if neither of the above are set : blue 0x2000 : translucent, else opaque */ -typedef struct DynaPolyActor { +struct DynaPolyActor { /* 0x000 */ struct Actor actor; /* 0x14C */ s32 bgId; /* 0x150 */ f32 unk_150; @@ -236,22 +240,23 @@ typedef struct DynaPolyActor { /* 0x15C */ u32 unk_15C; /* 0x160 */ u8 unk_160; /* 0x162 */ s16 unk_162; -} DynaPolyActor; // size = 0x164 +}; // size = 0x164 -typedef struct { +struct BodyBreak { /* 0x00 */ MtxF* matrices; /* 0x04 */ s16* objectIds; /* 0x08 */ s16 count; /* 0x0C */ Gfx** dLists; /* 0x10 */ s32 val; // used for various purposes: both a status indicator and counter /* 0x14 */ s32 prevLimbIndex; -} BodyBreak; +}; #define BODYBREAK_OBJECT_DEFAULT -1 // use the same object as the actor #define BODYBREAK_STATUS_READY -1 #define BODYBREAK_STATUS_FINISHED 0 -typedef enum { +enum Item00Type +{ /* 0x00 */ ITEM00_RUPEE_GREEN, /* 0x01 */ ITEM00_RUPEE_BLUE, /* 0x02 */ ITEM00_RUPEE_RED, @@ -278,13 +283,13 @@ typedef enum { /* 0x17 */ ITEM00_TUNIC_ZORA, /* 0x18 */ ITEM00_TUNIC_GORON, /* 0x19 */ ITEM00_BOMBS_SPECIAL -} Item00Type; +}; struct EnItem00; typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct GlobalContext*); -typedef struct EnItem00 { +struct EnItem00 { /* 0x000 */ Actor actor; /* 0x14C */ EnItem00ActionFunc actionFunc; /* 0x150 */ s16 collectibleFlag; @@ -295,10 +300,11 @@ typedef struct EnItem00 { /* 0x15A */ s16 unk_15A; /* 0x15C */ f32 scale; /* 0x160 */ ColliderCylinder collider; -} EnItem00; // size = 0x1AC +}; // size = 0x1AC // Only A_OBJ_SIGNPOST_OBLONG and A_OBJ_SIGNPOST_ARROW are used in room files. -typedef enum { +enum AObjType +{ /* 0x00 */ A_OBJ_BLOCK_SMALL, /* 0x01 */ A_OBJ_BLOCK_LARGE, /* 0x02 */ A_OBJ_BLOCK_HUGE, @@ -312,13 +318,13 @@ typedef enum { /* 0x0A */ A_OBJ_SIGNPOST_ARROW, /* 0x0B */ A_OBJ_BOULDER_FRAGMENT, /* 0x0C */ A_OBJ_MAX -} AObjType; +}; struct EnAObj; typedef void (*EnAObjActionFunc)(struct EnAObj*, struct GlobalContext*); -typedef struct EnAObj { +struct EnAObj { /* 0x000 */ DynaPolyActor dyna; /* 0x164 */ EnAObjActionFunc actionFunc; /* 0x168 */ s32 rotateWaitTimer; @@ -329,9 +335,10 @@ typedef struct EnAObj { /* 0x174 */ s16 rotSpeedX; /* 0x178 */ f32 focusYoffset; /* 0x17C */ ColliderCylinder collider; -} EnAObj; // size = 0x1C8 +}; // size = 0x1C8 -typedef enum { +enum ActorCategory +{ /* 0x00 */ ACTORCAT_SWITCH, /* 0x01 */ ACTORCAT_BG, /* 0x02 */ ACTORCAT_PLAYER, @@ -344,34 +351,34 @@ typedef enum { /* 0x09 */ ACTORCAT_BOSS, /* 0x0A */ ACTORCAT_DOOR, /* 0x0B */ ACTORCAT_CHEST -} ActorCategory; +}; #define DEFINE_ACTOR(_0, enum, _2) enum, #define DEFINE_ACTOR_INTERNAL(_0, enum, _2) enum, #define DEFINE_ACTOR_UNSET(enum) enum, -typedef enum { +enum ActorID { #include "tables/actor_table.h" /* 0x0192 */ ACTOR_ID_MAX // originally "ACTOR_DLF_MAX" -} ActorID; +}; #undef DEFINE_ACTOR #undef DEFINE_ACTOR_INTERNAL #undef DEFINE_ACTOR_UNSET -typedef enum { +enum DoorLockType { DOORLOCK_NORMAL, DOORLOCK_BOSS, DOORLOCK_NORMAL_SPIRIT -} DoorLockType; +}; -typedef struct { +struct TargetContextEntry { /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unk_0C; // radius? /* 0x10 */ Color_RGB8 color; -} TargetContextEntry; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct TitleCardContext { /* 0x00 */ void* texture; /* 0x04 */ s16 x; /* 0x06 */ s16 y; @@ -381,9 +388,9 @@ typedef struct { /* 0x0B */ u8 delayTimer; // how long the title card waits to appear /* 0x0C */ s16 alpha; /* 0x0E */ s16 intensity; -} TitleCardContext; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct TargetContext { /* 0x00 */ Vec3f naviRefPos; // possibly wrong /* 0x0C */ Vec3f targetCenterPos; /* 0x18 */ Color_RGBAf naviInner; @@ -401,14 +408,15 @@ typedef struct { /* 0x8C */ Actor* unk_8C; /* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY /* 0x94 */ Actor* unk_94; -} TargetContext; // size = 0x98 +}; // size = 0x98 -typedef struct { +struct ActorListEntry { /* 0x00 */ s32 length; // number of actors loaded of this category /* 0x04 */ Actor* head; // pointer to head of the linked list of this category (most recent actor added) -} ActorListEntry; // size = 0x08 +}; // size = 0x08 -typedef struct { +struct ActorContext +{ /* 0x0000 */ u8 freezeFlashTimer; /* 0x0001 */ char unk_01[0x01]; /* 0x0002 */ u8 unk_02; @@ -432,9 +440,9 @@ typedef struct { /* 0x0128 */ TitleCardContext titleCtx; /* 0x0138 */ char unk_138[0x04]; /* 0x013C */ void* absoluteSpace; // Space used to allocate actor overlays of alloc type 1 -} ActorContext; // size = 0x140 +}; // size = 0x140 -typedef struct { +struct struct_80034A14_arg1 { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; /* 0x04 */ s16 unk_04; @@ -444,26 +452,26 @@ typedef struct { /* 0x14 */ f32 unk_14; /* 0x18 */ Vec3f unk_18; /* 0x24 */ s16 unk_24; -} struct_80034A14_arg1; // size = 0x28 +}; // size = 0x28 // Some animation related structure -typedef struct { +struct struct_80034EC0_Entry { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playbackSpeed; /* 0x08 */ f32 startFrame; /* 0x0C */ f32 frameCount; /* 0x10 */ u8 mode; /* 0x14 */ f32 transitionRate; -} struct_80034EC0_Entry; // size = 0x18 +}; // size = 0x18 // Another animation related structure -typedef struct { +struct struct_D_80AA1678 { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 frameCount; /* 0x08 */ u8 mode; /* 0x0C */ f32 transitionRate; -} struct_D_80AA1678; // size = 0x10 +}; // size = 0x10 /* void ActorShape_Init(ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale); diff --git a/include/z64animation.h b/include/z64animation.h index 54df55a2f..9c4cff2c2 100755 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -14,103 +14,103 @@ struct SkelAnime; #define ANIM_FLAG_UPDATEY (1 << 1) #define ANIM_FLAG_NOMOVE (1 << 4) -typedef enum { +enum AnimationModes { /* 0 */ ANIMMODE_LOOP, /* 1 */ ANIMMODE_LOOP_INTERP, /* 2 */ ANIMMODE_ONCE, /* 3 */ ANIMMODE_ONCE_INTERP, /* 4 */ ANIMMODE_LOOP_PARTIAL, /* 5 */ ANIMMODE_LOOP_PARTIAL_INTERP -} AnimationModes; +}; -typedef enum { +enum AnimationTapers { /* -1 */ ANIMTAPER_DECEL = -1, /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL -} AnimationTapers; +}; -typedef struct { +struct StandardLimb { /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent /* 0x06 */ u8 child; /* 0x07 */ u8 sibling; /* 0x08 */ Gfx* dList; -} StandardLimb; // size = 0xC +}; // size = 0xC -typedef struct { +struct LodLimb { /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent /* 0x06 */ u8 child; /* 0x07 */ u8 sibling; /* 0x08 */ Gfx* dLists[2]; // Near and far -} LodLimb; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct SkinLimb { /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent /* 0x06 */ u8 child; /* 0x07 */ u8 sibling; /* 0x08 */ s32 unk_8; // Type of data contained in segment /* 0x0C */ void* segment; // Segment address of data. Currently unclear what. -} SkinLimb; // size = 0x10 +}; // size = 0x10 -typedef struct LegacyLimb { +struct LegacyLimb { /* 0x000 */ Gfx* dList; /* 0x004 */ Vec3f trans; /* 0x010 */ Vec3s rot; /* 0x018 */ struct LegacyLimb* sibling; /* 0x01C */ struct LegacyLimb* child; -} LegacyLimb; // size = 0x20 +}; // size = 0x20 // Model has limbs with only rigid meshes -typedef struct { +struct SkeletonHeader { /* 0x00 */ void** segment; /* 0x04 */ u8 limbCount; -} SkeletonHeader; // size = 0x8 +}; // size = 0x8 // Model has limbs with flexible meshes -typedef struct { +struct FlexSkeletonHeader { /* 0x00 */ SkeletonHeader sh; /* 0x08 */ u8 dListCount; -} FlexSkeletonHeader; // size = 0xC +}; // size = 0xC // Index into the frame data table. -typedef struct { +struct JointIndex { /* 0x00 */ u16 x; /* 0x02 */ u16 y; /* 0x04 */ u16 z; -} JointIndex; // size = 0x06 +}; // size = 0x06 -typedef struct { +struct AnimationHeaderCommon { /* 0x00 */ s16 frameCount; -} AnimationHeaderCommon; +}; -typedef struct { +struct LinkAnimationHeader { /* 0x00 */ AnimationHeaderCommon common; /* 0x04 */ void* segment; -} LinkAnimationHeader; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct AnimationHeader { /* 0x00 */ AnimationHeaderCommon common; /* 0x04 */ s16* frameData; // "tbl" /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" /* 0x0C */ u16 staticIndexMax; -} AnimationHeader; // size = 0x10 +}; // size = 0x10 // Unused -typedef struct { +struct JointKey { /* 0x00 */ s16 xMax; /* 0x02 */ s16 x; /* 0x04 */ s16 yMax; /* 0x06 */ s16 y; /* 0x08 */ s16 zMax; /* 0x0A */ s16 z; -} JointKey; // size = 0x0C +}; // size = 0x0C // Unused -typedef struct { +struct LegacyAnimationHeader { /* 0x00 */ s16 frameCount; /* 0x02 */ s16 limbCount; /* 0x04 */ s16* frameData; /* 0x08 */ JointKey* jointKey; -} LegacyAnimationHeader; // size = 0xC +}; // size = 0xC typedef s32 (*OverrideLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void*); @@ -122,114 +122,114 @@ typedef s32 (*OverrideLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, typedef void (*PostLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void*, Gfx** gfx); -typedef enum { +enum AnimationType { ANIMENTRY_LOADFRAME, ANIMENTRY_COPYALL, ANIMENTRY_INTERP, ANIMENTRY_COPYTRUE, ANIMENTRY_COPYFALSE, ANIMENTRY_MOVEACTOR -} AnimationType; +}; -typedef struct { +struct AnimEntryLoadFrame { /* 0x000 */ DmaRequest req; /* 0x020 */ OSMesgQueue msgQueue; /* 0x038 */ OSMesg msg; -} AnimEntryLoadFrame; // size = 0x3C +}; // size = 0x3C -typedef struct { +struct AnimEntryCopyAll { /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; /* 0x004 */ Vec3s* dst; /* 0x008 */ Vec3s* src; -} AnimEntryCopyAll; // size = 0xC +}; // size = 0xC -typedef struct { +struct AnimEntryInterp { /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; /* 0x004 */ Vec3s* base; /* 0x008 */ Vec3s* mod; /* 0x00C */ f32 weight; -} AnimEntryInterp; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct AnimEntryCopyTrue { /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; /* 0x004 */ Vec3s* dst; /* 0x008 */ Vec3s* src; /* 0x00C */ u8* copyFlag; -} AnimEntryCopyTrue; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct AnimEntryCopyFalse { /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; /* 0x004 */ Vec3s* dst; /* 0x008 */ Vec3s* src; /* 0x00C */ u8* copyFlag; -} AnimEntryCopyFalse; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct AnimEntryMoveActor { /* 0x000 */ struct Actor* actor; /* 0x004 */ struct SkelAnime* skelAnime; /* 0x008 */ f32 unk_08; -} AnimEntryMoveActor; // size = 0xC +}; // size = 0xC -typedef union { +union AnimationEntryData { AnimEntryLoadFrame load; AnimEntryCopyAll copy; AnimEntryInterp interp; AnimEntryCopyTrue copy1; AnimEntryCopyFalse copy0; AnimEntryMoveActor move; -} AnimationEntryData; // size = 0x3C +}; // size = 0x3C -typedef struct { +struct AnimationEntry { /* 0x00 */ u8 type; /* 0x04 */ AnimationEntryData data; -} AnimationEntry; // size = 0x40 +}; // size = 0x40 -typedef struct AnimationContext { +struct AnimationContext { s16 animationCount; AnimationEntry entries[ANIMATION_ENTRY_MAX]; -} AnimationContext; // size = 0xC84 +}; // size = 0xC84 typedef void (*AnimationEntryCallback)(struct GlobalContext* globalCtx, AnimationEntryData* data); // fcurve_skelanime structs -typedef struct { +struct TransformData { /* 0x0000 */ u16 unk_00; // appears to be flags /* 0x0002 */ s16 unk_02; /* 0x0004 */ s16 unk_04; /* 0x0006 */ s16 unk_06; /* 0x0008 */ f32 unk_08; -} TransformData; // size = 0xC +}; // size = 0xC -typedef struct { +struct TransformUpdateIndex { /* 0x0000 */ u8* refIndex; /* 0x0004 */ TransformData* transformData; /* 0x0008 */ s16* copyValues; /* 0x000C */ s16 unk_0C; /* 0x000E */ s16 unk_0E; -} TransformUpdateIndex; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct SkelCurveLimb { /* 0x0000 */ u8 firstChildIdx; /* 0x0001 */ u8 nextLimbIdx; /* 0x0004 */ Gfx* dList[2]; -} SkelCurveLimb; // size = 0xC +}; // size = 0xC -typedef struct { +struct SkelCurveLimbList { /* 0x0000 */ SkelCurveLimb** limbs; /* 0x0004 */ u8 limbCount; -} SkelCurveLimbList; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct LimbTransform { /* 0x0000 */ Vec3s scale; /* 0x0006 */ Vec3s rot; /* 0x000C */ Vec3s pos; -} LimbTransform; // size = 0x12 +}; // size = 0x12 -typedef struct { +struct SkelAnimeCurve { /* 0x0000 */ u8 limbCount; /* 0x0004 */ SkelCurveLimb** limbList; /* 0x0008 */ TransformUpdateIndex* transUpdIdx; @@ -238,14 +238,14 @@ typedef struct { /* 0x0014 */ f32 animSpeed; /* 0x0018 */ f32 animCurFrame; /* 0x001C */ LimbTransform* transforms; -} SkelAnimeCurve; // size = 0x20 +}; // size = 0x20 typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void*); typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void*); typedef s32 (*AnimUpdateFunc)(); -typedef struct SkelAnime { +struct SkelAnime { /* 0x00 */ u8 limbCount; // Number of limbs in the skeleton /* 0x01 */ u8 mode; // 0: loop, 2: play once, 4: partial loop. +1 to interpolate between frames. /* 0x02 */ u8 dListCount; // Number of display lists in a flexible skeleton @@ -261,15 +261,15 @@ typedef struct SkelAnime { /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph - /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph + /* 0x30 */ s32 (*update)(GlobalContext*, SkelAnime*); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. /* 0x38 */ Vec3s prevTransl; // Previous modelspace translation. /* 0x3E */ Vec3s baseTransl; // Base modelspace translation. -} SkelAnime; // size = 0x44 +}; // size = 0x44 -typedef struct { +struct Struct_800A57C0 { /* 0x000 */ u16 unk_0; /* 0x002 */ s16 unk_2; /* 0x004 */ s16 unk_4; @@ -277,43 +277,43 @@ typedef struct { /* 0x007 */ s8 unk_7; /* 0x008 */ s8 unk_8; /* 0x009 */ u8 unk_9; -} Struct_800A57C0; // size = 0xA +}; // size = 0xA -typedef struct { +struct Struct_800A598C_2 { /* 0x000 */ u8 unk_0; /* 0x002 */ s16 x; /* 0x004 */ s16 y; /* 0x006 */ s16 z; /* 0x008 */ u8 unk_8; -} Struct_800A598C_2; // size = 0xA +}; // size = 0xA -typedef struct { +struct Struct_800A598C { /* 0x000 */ u16 unk_0; /* 0x002 */ u16 unk_2; /* 0x004 */ u16 unk_4; /* 0x008 */ Struct_800A57C0* unk_8; /* 0x00C */ Struct_800A598C_2* unk_C; -} Struct_800A598C; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Struct_800A5E28 { /* 0x000 */ u16 unk_0; /* 0x002 */ u16 unk_2; /* 0x004 */ Struct_800A598C* unk_4; /* 0x008 */ Gfx* unk_8; -} Struct_800A5E28; // size = 0xC +}; // size = 0xC -typedef struct { +struct SkinAvb { /* 0x000 */ u8 unk_0; /* 0x004 */ Vtx* buf[2]; -} SkinAvb; // size = 0xC +}; // size = 0xC -typedef struct { +struct PSkinAwb { /* 0x000 */ SkeletonHeader* skeletonHeader; /* 0x004 */ MtxF mtx; /* 0x044 */ s32 avbCount; /* 0x048 */ SkinAvb* avbTbl; /* 0x04C */ SkelAnime skelAnime; -} PSkinAwb; // size = 0x90 +}; // size = 0x90 typedef void (*SkinCallback)(struct Actor*, struct GlobalContext*, PSkinAwb*); typedef s32 (*SkinCallback2)(struct Actor*, struct GlobalContext*, s32, PSkinAwb*); diff --git a/include/z64audio.h b/include/z64audio.h index 9e69c5142..1ed048539 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -20,7 +20,9 @@ #define AIBUF_LEN 0x580 -typedef enum { +union Acmd; + +enum AdsrStatus { /* 0 */ ADSR_STATE_DISABLED, /* 1 */ ADSR_STATE_INITIAL, /* 2 */ ADSR_STATE_START_LOOP, @@ -30,36 +32,36 @@ typedef enum { /* 6 */ ADSR_STATE_DECAY, /* 7 */ ADSR_STATE_RELEASE, /* 8 */ ADSR_STATE_SUSTAIN -} AdsrStatus; +}; -typedef enum { +enum SampleMedium { /* 0 */ MEDIUM_RAM, /* 1 */ MEDIUM_UNK, /* 2 */ MEDIUM_CART, /* 3 */ MEDIUM_DISK_DRIVE -} SampleMedium; +}; -typedef enum { +enum SampleCodec { /* 0 */ CODEC_ADPCM, /* 1 */ CODEC_S8, /* 2 */ CODEC_S16_INMEMORY, /* 3 */ CODEC_SMALL_ADPCM, /* 4 */ CODEC_REVERB, /* 5 */ CODEC_S16 -} SampleCodec; +}; -typedef enum { +enum SampleBankTableType { /* 0 */ SEQUENCE_TABLE, /* 1 */ FONT_TABLE, /* 2 */ SAMPLE_TABLE -} SampleBankTableType; +}; -typedef enum { +enum AudioCacheType { /* 0 */ CACHE_TEMPORARY, /* 1 */ CACHE_PERSISTENT, /* 2 */ CACHE_EITHER, /* 3 */ CACHE_PERMANENT -} AudioCacheType; +}; typedef s32 (*DmaHandler)(struct OSPiHandle* handle, struct OSIoMesg* mb, s32 direction); @@ -85,44 +87,44 @@ typedef struct AudioListItem { /* 0x0C */ struct NotePool* pool; } AudioListItem; // size = 0x10 -typedef struct NotePool { +struct NotePool { /* 0x00 */ AudioListItem disabled; /* 0x10 */ AudioListItem decaying; /* 0x20 */ AudioListItem releasing; /* 0x30 */ AudioListItem active; -} NotePool; +}; // Pitch sliding by up to one octave in the positive direction. Negative // direction is "supported" by setting extent to be negative. The code // exterpolates exponentially in the wrong direction in that case, but that // doesn't prevent seqplayer from doing it, AFAICT. -typedef struct { +struct Portamento { /* 0x00 */ u8 mode; // bit 0x80 denotes something; the rest are an index 0-5 /* 0x02 */ u16 cur; /* 0x04 */ u16 speed; /* 0x08 */ f32 extent; -} Portamento; // size = 0xC +}; // size = 0xC -typedef struct { +struct AdsrEnvelope { /* 0x0 */ s16 delay; /* 0x2 */ s16 arg; -} AdsrEnvelope; // size = 0x4 +}; // size = 0x4 -typedef struct { +struct AdpcmLoop { /* 0x00 */ u32 start; /* 0x04 */ u32 end; /* 0x08 */ u32 count; /* 0x0C */ char unk_0C[0x4]; /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned -} AdpcmLoop; // size = 0x30 (or 0x10) +}; // size = 0x30 (or 0x10) -typedef struct { +struct AdpcmBook { /* 0x00 */ s32 order; /* 0x04 */ s32 npredictors; /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned -} AdpcmBook; // size >= 0x8 +}; // size >= 0x8 -typedef struct { +struct SoundFontSample { #ifdef LITTLE_ENDIAN u32 size : 24; u32 unk_bit25 : 1; @@ -139,23 +141,22 @@ typedef struct { /* 0x04 */ u8* sampleAddr; /* 0x08 */ AdpcmLoop* loop; /* 0x0C */ AdpcmBook* book; -} SoundFontSample; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct SoundFontSound { /* 0x00 */ SoundFontSample* sample; /* 0x04 */ f32 tuning; // frequency scale factor -} SoundFontSound; // size = 0x8 +}; // size = 0x8 -typedef enum -{ +enum AudioCacheLoadType { CACHE_LOAD_PERMANENT = 0, CACHE_LOAD_PERSISTENT, CACHE_LOAD_TEMPORARY, CACHE_LOAD_EITHER, CACHE_LOAD_EITHER_NOSYNC -} AudioCacheLoadType; +}; -typedef struct { +struct ReverbRingBufferItem { /* 0x00 */ s16 numSamplesAfterDownsampling; // never read /* 0x02 */ s16 chunkLen; // never read /* 0x04 */ s16* toDownsampleLeft; @@ -166,9 +167,9 @@ typedef struct { /* 0x14 */ u16 unk_14; /* 0x16 */ u16 unk_16; /* 0x18 */ u16 unk_18; -} ReverbRingBufferItem; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct SynthesisReverb { /* 0x000 */ u8 resampleFlags; /* 0x001 */ u8 useReverb; /* 0x002 */ u8 framesToIgnore; @@ -206,9 +207,9 @@ typedef struct { /* 0x280 */ SoundFontSound sound; /* 0x288 */ SoundFontSample sample; /* 0x298 */ AdpcmLoop loop; -} SynthesisReverb; // size = 0x2C8 +}; // size = 0x2C8 -typedef struct { +struct Instrument { /* 0x00 */ u8 loaded; /* 0x01 */ u8 normalRangeLo; /* 0x02 */ u8 normalRangeHi; @@ -217,17 +218,17 @@ typedef struct { /* 0x08 */ SoundFontSound lowNotesSound; /* 0x10 */ SoundFontSound normalNotesSound; /* 0x18 */ SoundFontSound highNotesSound; -} Instrument; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct Drum { /* 0x00 */ u8 releaseRate; /* 0x01 */ u8 pan; /* 0x02 */ u8 loaded; /* 0x04 */ SoundFontSound sound; /* 0x14 */ AdsrEnvelope* envelope; -} Drum; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct SoundFont { /* 0x00 */ u8 numInstruments; /* 0x01 */ u8 numDrums; /* 0x02 */ u8 sampleBankId1; @@ -236,18 +237,18 @@ typedef struct { /* 0x08 */ Instrument** instruments; /* 0x0C */ Drum** drums; /* 0x10 */ SoundFontSound* soundEffects; -} SoundFont; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct SeqScriptState { /* 0x00 */ u8* pc; /* 0x04 */ u8* stack[4]; /* 0x14 */ u8 remLoopIters[4]; /* 0x18 */ u8 depth; /* 0x19 */ s8 value; -} SeqScriptState; // size = 0x1C +}; // size = 0x1C // Also known as a Group, according to debug strings. -typedef struct { +struct SequencePlayer { #ifdef LITTLE_ENDIAN u8 unk_0b1 : 1; u8 stopScript : 1; @@ -298,13 +299,13 @@ typedef struct { /* 0x0E0 */ u32 scriptCounter; /* 0x0E4 */ char unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp /* 0x158 */ s8 soundScriptIO[8]; -} SequencePlayer; // size = 0x160 +}; // size = 0x160 -typedef struct { +struct AdsrSettings { /* 0x0 */ u8 releaseRate; /* 0x1 */ u8 sustain; /* 0x4 */ AdsrEnvelope* envelope; -} AdsrSettings; // size = 0x8 +}; // size = 0x8 typedef struct { /* 0x00 */ union { @@ -336,7 +337,7 @@ typedef struct { /* 0x1C */ AdsrEnvelope* envelope; } AdsrState; -typedef struct { +struct StereoData { #ifdef LITTLE_ENDIAN u8 usesHeadsetPanEffects : 1; u8 stereoHeadsetEffects : 1; @@ -352,14 +353,14 @@ typedef struct { u8 stereoHeadsetEffects : 1; u8 usesHeadsetPanEffects : 1; #endif -} StereoData; +}; -typedef union { +union Stereo { /* 0x00 */ StereoData s; /* 0x00 */ u8 asByte; -} Stereo; +}; -typedef struct { +struct NoteAttributes { /* 0x00 */ u8 reverb; /* 0x01 */ u8 unk_1; /* 0x02 */ u8 pan; @@ -370,7 +371,7 @@ typedef struct { /* 0x0C */ f32 velocity; /* 0x10 */ s16* filter; /* 0x14 */ s16 filterBuf[8]; -} NoteAttributes; // size = 0x24 +}; // size = 0x24 // Also known as a SubTrack, according to sm64 debug strings. typedef struct SequenceChannel { @@ -454,7 +455,7 @@ typedef struct SequenceChannel { } SequenceChannel; // size = 0xD4 // Might also be known as a Track, according to sm64 debug strings (?). -typedef struct SequenceLayer { +struct SequenceLayer { #ifdef LITTLE_ENDIAN u8 notePropertiesNeedInit : 1; u8 bit1 : 1; // "has initialized continuous notes"? @@ -504,18 +505,18 @@ typedef struct SequenceLayer { /* 0x50 */ SequenceChannel* channel; /* 0x54 */ SeqScriptState scriptState; /* 0x70 */ AudioListItem listItem; -} SequenceLayer; // size = 0x80 +}; // size = 0x80 -typedef struct { +struct NoteSynthesisBuffers { /* 0x0000 */ s16 adpcmdecState[0x10]; /* 0x0020 */ s16 finalResampleState[0x10]; /* 0x0040 */ s16 mixEnvelopeState[0x28]; /* 0x0090 */ s16 panResampleState[0x10]; /* 0x00B0 */ s16 panSamplesBuffer[0x20]; /* 0x00F0 */ s16 dummyResampleState[0x10]; -} NoteSynthesisBuffers; // size = 0x110 +}; // size = 0x110 -typedef struct { +struct NoteSynthesisState { /* 0x00 */ u8 restart; /* 0x01 */ u8 sampleDmaIndex; /* 0x02 */ u8 prevHeadsetPanRight; @@ -533,9 +534,9 @@ typedef struct { /* 0x1A */ u8 unk_1A; /* 0x1C */ u16 unk_1C; /* 0x1E */ u16 unk_1E; -} NoteSynthesisState; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct VibratoState { /* 0x00 */ struct SequenceChannel* channel; /* 0x04 */ u32 time; /* 0x08 */ s16* curve; @@ -545,9 +546,9 @@ typedef struct { /* 0x16 */ u16 rateChangeTimer; /* 0x18 */ u16 extentChangeTimer; /* 0x1A */ u16 delay; -} VibratoState; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct NotePlaybackState { /* 0x00 */ u8 priority; /* 0x01 */ u8 waveId; /* 0x02 */ u8 sampleCountIndex; @@ -563,7 +564,7 @@ typedef struct { /* 0x1C */ NoteAttributes attributes; /* 0x40 */ AdsrState adsr; // may contain portamento, vibratoState, if those are not part of Note itself -} NotePlaybackState; +}; typedef struct { struct { @@ -620,7 +621,7 @@ typedef struct { /* 0x18 */ char pad_18[0x8]; } NoteSubEu; // size = 0x20 -typedef struct Note { +struct Note { /* 0x00 */ AudioListItem listItem; /* 0x10 */ NoteSynthesisState synthesisState; /* 0x30 */ NotePlaybackState playbackState; @@ -629,9 +630,9 @@ typedef struct Note { /* 0xB8 */ char unk_B8[0x4]; /* 0xBC */ u32 unk_BC; /* 0xC0 */ NoteSubEu noteSubEu; -} Note; // size = 0xE0 +}; // size = 0xE0 -typedef struct { +struct ReverbSettings { /* 0x00 */ u8 downsampleRate; /* 0x02 */ u16 windowSize; /* 0x04 */ u16 unk_4; @@ -644,9 +645,9 @@ typedef struct { /* 0x12 */ u16 unk_12; /* 0x14 */ s16 lowPassFilterCutoffLeft; /* 0x16 */ s16 lowPassFilterCutoffRight; -} ReverbSettings; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct AudioSpec { /* 0x00 */ u32 frequency; /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; @@ -666,9 +667,9 @@ typedef struct { /* 0x2C */ u32 temporarySampleMem; /* 0x30 */ s32 persistentSampleCacheMem; /* 0x34 */ s32 temporarySampleCacheMem; -} AudioSpec; // size = 0x38 +}; // size = 0x38 -typedef struct { +struct AudioBufferParameters { /* 0x00 */ s16 specUnk4; /* 0x02 */ u16 frequency; /* 0x04 */ u16 aiFrequency; @@ -684,23 +685,23 @@ typedef struct { /* 0x1C */ f32 updatesPerFrameInv; /* 0x20 */ f32 unkUpdatesPerFrameScaled; /* 0x24 */ f32 unk_24; -} AudioBufferParameters; +}; -typedef struct { +struct AudioAllocPool { /* 0x0 */ u8* start; /* 0x4 */ u8* cur; /* 0x8 */ s32 size; /* 0xC */ s32 count; -} AudioAllocPool; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct AudioCacheEntry { /* 0x0 */ u8* ptr; /* 0x4 */ u32 size; /* 0x8 */ s16 tableType; /* 0xA */ s16 id; -} AudioCacheEntry; // size = 0xC +}; // size = 0xC -typedef struct { +struct SampleCacheEntry { /* 0x00 */ s8 inUse; /* 0x01 */ s8 origMedium; /* 0x02 */ s8 sampleBankId; @@ -708,57 +709,57 @@ typedef struct { /* 0x08 */ u8* allocatedAddr; /* 0x0C */ void* sampleAddr; /* 0x10 */ u32 size; -} SampleCacheEntry; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct AudioSampleCache { /* 0x000 */ AudioAllocPool pool; /* 0x010 */ SampleCacheEntry entries[32]; /* 0x290 */ s32 size; -} AudioSampleCache; // size = 0x294 +}; // size = 0x294 -typedef struct { +struct AudioPersistentCache { /* 0x00*/ u32 numEntries; /* 0x04*/ AudioAllocPool pool; /* 0x14*/ AudioCacheEntry entries[16]; -} AudioPersistentCache; // size = 0xD4 +}; // size = 0xD4 -typedef struct { +struct AudioTemporaryCache { /* 0x00*/ u32 nextSide; /* 0x04*/ AudioAllocPool pool; /* 0x14*/ AudioCacheEntry entries[2]; -} AudioTemporaryCache; // size = 0x3C +}; // size = 0x3C -typedef struct { +struct AudioCache { /* 0x000*/ AudioPersistentCache persistent; /* 0x0D4*/ AudioTemporaryCache temporary; /* 0x100*/ u8 unk_100[0x10]; -} AudioCache; // size = 0x110 +}; // size = 0x110 -typedef struct { +struct AudioPoolSplit2 { u32 wantPersistent; u32 wantTemporary; -} AudioPoolSplit2; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct AudioPoolSplit3 { u32 wantSeq; u32 wantFont; u32 wantSample; -} AudioPoolSplit3; // size = 0xC +}; // size = 0xC -typedef struct { +struct AudioPoolSplit4 { u32 wantSeq; u32 wantFont; u32 wantSample; u32 wantCustom; -} AudioPoolSplit4; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct AudioPreloadReq { /* 0x00 */ u32 endAndMediumKey; /* 0x04 */ SoundFontSample* sample; /* 0x08 */ u8* ramAddr; /* 0x0C */ u32 encodedInfo; /* 0x10 */ s32 isFree; -} AudioPreloadReq; // size = 0x14 +}; // size = 0x14 typedef struct { union{ @@ -791,7 +792,7 @@ typedef struct { }; } AudioCmd; -typedef struct { +struct AudioAsyncLoad { /* 0x00 */ s8 status; /* 0x01 */ s8 delay; /* 0x02 */ s8 medium; @@ -806,14 +807,14 @@ typedef struct { /* 0x24 */ OSMesgQueue msgQueue; /* 0x3C */ OSMesg msg; /* 0x40 */ OSIoMesg ioMesg; -} AudioAsyncLoad; // size = 0x58 +}; // size = 0x58 -typedef struct { +struct AudioSlowLoad { /* 0x00 */ u8 medium; /* 0x01 */ u8 seqOrFontId; /* 0x02 */ u16 instId; /* 0x04 */ s32 unkMediumParam; - /* 0x08 */ s32 curDevAddr; + /* 0x08 */ Pointer curDevAddr; /* 0x0C */ u8* curRamAddr; /* 0x10 */ u8* ramAddr; /* 0x14 */ s32 status; @@ -823,9 +824,9 @@ typedef struct { /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; /* 0x4C */ OSIoMesg ioMesg; -} AudioSlowLoad; // size = 0x64 +}; // size = 0x64 -typedef struct AudioTableEntry { +struct AudioTableEntry { /* 0x00 */ uintptr_t romAddr; /* 0x04 */ u32 size; /* 0x08 */ s8 medium; @@ -833,43 +834,42 @@ typedef struct AudioTableEntry { /* 0x0A */ s16 shortData1; /* 0x0C */ s16 shortData2; /* 0x0E */ s16 shortData3; -} AudioTableEntry; // size = 0x10 +}; // size = 0x10 -typedef struct AudioTable { +struct AudioTable { /* 0x00 */ s16 numEntries; /* 0x02 */ s16 unkMediumParam; /* 0x04 */ uintptr_t romAddr; /* 0x08 */ char pad[0x8]; /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) -} AudioTable; // size >= 0x20 +}; // size >= 0x20 -typedef struct AudioTableDef -{ +struct AudioTableDef { /* 0x00 */ s16 numEntries; /* 0x02 */ s16 unkMediumParam; /* 0x04 */ uintptr_t romAddr; /* 0x08 */ char pad[0x8]; /* 0x10 */ AudioTableEntry entries[]; // (dynamic size) -} AudioTableDef; // size >= 0x20 +}; // size >= 0x20 -typedef struct { +struct AudioTask { /* 0x00 */ OSTask task; /* 0x40 */ OSMesgQueue* taskQueue; /* 0x44 */ void* unk_44; // probably a message that gets unused. /* 0x48 */ char unk_48[0x8]; -} AudioTask; // size = 0x50 +}; // size = 0x50 -typedef struct { +struct SampleDma { /* 0x00 */ u8* ramAddr; - /* 0x04 */ u32 devAddr; + /* 0x04 */ Pointer devAddr; /* 0x08 */ u16 sizeUnused; /* 0x0A */ u16 size; /* 0x0C */ u8 unused; /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded -} SampleDma; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct AudioContext { /* 0x0000 */ char unk_0000; /* 0x0001 */ s8 numSynthesisReverbs; /* 0x0002 */ u16 unk_2; @@ -931,8 +931,8 @@ typedef struct { /* 0x28A0 */ s32 curAudioFrameDmaCount; /* 0x28A4 */ s32 rspTaskIdx; /* 0x28A8 */ s32 curAIBufIdx; - /* 0x28AC */ struct Acmd* abiCmdBufs[2]; - /* 0x28B4 */ struct Acmd* curAbiCmdBuf; + /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28B4 */ Acmd* curAbiCmdBuf; /* 0x28B8 */ AudioTask* currTask; /* 0x28BC */ char unk_28BC[0x4]; /* 0x28C0 */ AudioTask rspTask[2]; @@ -993,9 +993,9 @@ typedef struct { /* 0x5C3C */ OSMesg audioResetMesgs[1]; /* 0x5C40 */ OSMesg cmdProcMsgs[4]; /* 0x5C50 */ AudioCmd cmdBuf[0x100]; -} AudioContext; // size = 0x6450 +}; // size = 0x6450 -typedef struct { +struct NoteSubAttributes { /* 0x00 */ u8 reverbVol; /* 0x01 */ u8 unk_1; /* 0x02 */ u8 pan; @@ -1006,15 +1006,15 @@ typedef struct { /* 0x10 */ s16* filter; /* 0x14 */ u8 unk_14; /* 0x16 */ u16 unk_16; -} NoteSubAttributes; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct AudioContextInitSizes { /* 0x00 */ u32 heapSize; /* 0x04 */ u32 initPoolSize; /* 0x08 */ u32 permanentPoolSize; -} AudioContextInitSizes; // size = 0xC +}; // size = 0xC -typedef struct { +struct unk_50_s { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -1023,9 +1023,9 @@ typedef struct { /* 0x14 */ f32 unk_14; /* 0x18 */ f32 unk_18; /* 0x1C */ u16 unk_1C; -} unk_50_s; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct unk_D_8016E750 { /* 0x000 */ f32 volCur; /* 0x004 */ f32 volTarget; /* 0x008 */ f32 unk_08; @@ -1051,9 +1051,9 @@ typedef struct { /* 0x258 */ u16 unk_258; /* 0x25C */ u32 unk_25C; /* 0x260 */ u8 unk_260; -} unk_D_8016E750; // size = 0x264 +}; // size = 0x264 -typedef enum { +enum SoundBankTypes { /* 0 */ BANK_PLAYER, /* 1 */ BANK_ITEM, /* 2 */ BANK_ENV, @@ -1061,18 +1061,18 @@ typedef enum { /* 4 */ BANK_SYSTEM, /* 5 */ BANK_OCARINA, /* 6 */ BANK_VOICE -} SoundBankTypes; +}; -typedef enum { +enum SfxState { /* 0 */ SFX_STATE_EMPTY, /* 1 */ SFX_STATE_QUEUED, /* 2 */ SFX_STATE_READY, /* 3 */ SFX_STATE_PLAYING_REFRESH, /* 4 */ SFX_STATE_PLAYING_1, /* 5 */ SFX_STATE_PLAYING_2 -} SfxState; +}; -typedef struct { +struct SoundBankEntry { /* 0x00 */ f32* posX; /* 0x04 */ f32* posY; /* 0x08 */ f32* posZ; @@ -1091,7 +1091,7 @@ typedef struct { /* 0x2D */ u8 next; /* 0x2E */ u8 channelIdx; /* 0x2F */ u8 unk_2F; -} SoundBankEntry; // size = 0x30 +}; // size = 0x30 /* * SFX IDs @@ -1114,17 +1114,17 @@ typedef struct { #define SFX_INDEX(sfxId) ((sfxId) & 0x01FF) #define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId)) -typedef struct { +struct ActiveSound { u32 priority; // lower is more prioritized u8 entryIndex; -} ActiveSound; +}; -typedef struct { +struct SoundParams { u8 importance; u16 params; -} SoundParams; +}; -typedef struct { +struct OcarinaNote { /* 0x0000 */ u8 noteIdx; /* 0x0001 */ u8 unk_01; /* 0x0002 */ u16 unk_02; @@ -1132,270 +1132,32 @@ typedef struct { /* 0x0005 */ u8 vibrato; /* 0x0006 */ s8 tone; /* 0x0007 */ u8 semitone; -} OcarinaNote; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct OcarinaSongInfo { u8 len; u8 notesIdx[8]; -} OcarinaSongInfo; +}; -typedef struct { +struct OcarinaStaff { u8 noteIdx; u8 state; // original name: "status" u8 pos; // original name: "locate" -} OcarinaStaff; +}; -typedef enum { +enum OcarinaNoteIdx { /* 0 */ OCARINA_NOTE_A, /* 1 */ OCARINA_NOTE_C_DOWN, /* 2 */ OCARINA_NOTE_C_RIGHT, /* 3 */ OCARINA_NOTE_C_LEFT, /* 4 */ OCARINA_NOTE_C_UP, /* -1 */ OCARINA_NOTE_INVALID = 0xFF -} OcarinaNoteIdx; +}; #define gTatumsPerBeat (D_8014A6C0[1]) extern void(*D_801755D0)(void); -/* -Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen); -void AudioHeap_DiscardFont(s32 fontId); -void AudioHeap_DiscardSequence(s32 seqId); -void AudioHeap_WritebackDCache(void* mem, u32 size); -void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocDmaMemoryZeroed(AudioAllocPool* pool, u32 size); -void* AudioHeap_AllocZeroed(AudioAllocPool* pool, u32 size); -void* AudioHeap_Alloc(AudioAllocPool* pool, u32 size); -void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* mem, u32 size); -void AudioHeap_PersistentCacheClear(AudioPersistentCache* persistent); -void AudioHeap_TemporaryCacheClear(AudioTemporaryCache* temporary); -void AudioHeap_PopCache(s32 tableType); -void AudioHeap_InitMainPools(s32 sizeForAudioInitPool); -void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id); -void* AudioHeap_SearchCaches(s32 tableType, s32 arg1, s32 id); -void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); -void AudioHeap_LoadFilter(s16* filter, s32 filter1, s32 filter2); -s32 AudioHeap_ResetStep(void); -void AudioHeap_Init(void); -void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); -void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size); -void* AudioHeap_AllocSampleCache(u32 size, s32 fontId, void* sampleAddr, s8 medium, s32 cache); -void AudioHeap_ApplySampleBankCache(s32 sampleBankId); -void AudioLoad_DecreaseSampleDmaTtls(void); -void* AudioLoad_DmaSampleData(uintptr_t devAddr, u32 size, s32 arg2, u8* dmaIndexRef, s32 medium); -void AudioLoad_InitSampleDmaBuffers(s32 arg0); -s32 AudioLoad_IsFontLoadComplete(s32 fontId); -s32 AudioLoad_IsSeqLoadComplete(s32 seqId); -void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); -void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); -void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1); -s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); -void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); -void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue); -void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); -u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* arg1); -void AudioLoad_DiscardSeqFonts(s32 seqId); -s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2); -s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 arg2); -void AudioLoad_ProcessLoads(s32 resetStatus); -void AudioLoad_SetDmaHandler(DmaHandler callback); -void AudioLoad_Init(void* heap, u32 heapSize); -void AudioLoad_InitSlowLoads(void); -s32 AudioLoad_SlowLoadSample(s32 arg0, s32 arg1, s8* arg2); -s32 AudioLoad_SlowLoadSeq(s32 playerIdx, u8* ramAddr, s8* arg2); -void AudioLoad_InitAsyncLoads(void); -void AudioLoad_LoadPermanentSamples(void); -void AudioLoad_ScriptLoad(s32 tableType, s32 arg1, s8* arg2); -void AudioLoad_ProcessScriptLoads(void); -void AudioLoad_InitScriptLoads(void); -AudioTask* func_800E4FE0(void); -void Audio_QueueCmdF32(u32 arg0, f32 arg1); -void Audio_QueueCmdS32(u32 arg0, s32 arg1); -void Audio_QueueCmdS8(u32 arg0, s8 arg1); -void Audio_QueueCmdU16(u32 arg0, u16 arg1); -s32 Audio_ScheduleProcessCmds(void); -u32 func_800E5E20(u32* arg0); -u8* func_800E5E84(s32 arg0, u32* arg1); -s32 func_800E5EDC(void); -s32 func_800E5F88(s32 arg0); -void Audio_PreNMIInternal(void); -s32 func_800E6680(void); -u32 Audio_NextRandom(void); -void Audio_InitMesgQueues(void); -void Audio_InvalDCache(void* buf, s32 size); -void Audio_WritebackDCache(void* mem, s32 size); -s32 osAiSetNextBuffer(void*, u32); -void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs); -void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput); -void Audio_NoteInit(Note* note); -void Audio_NoteDisable(Note* note); -void Audio_ProcessNotes(void); -SoundFontSound* Audio_InstrumentGetSound(Instrument* instrument, s32 semitone); -Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId); -Drum* Audio_GetDrum(s32 fontId, s32 drumId); -SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId); -s32 Audio_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value); -void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target); -void Audio_SeqLayerNoteDecay(SequenceLayer* layer); -void Audio_SeqLayerNoteRelease(SequenceLayer* layer); -s32 Audio_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveId); -void Audio_InitSyntheticWave(Note* note, SequenceLayer* layer); -void Audio_InitNoteList(AudioListItem* list); -void Audio_InitNoteLists(NotePool* pool); -void Audio_InitNoteFreeList(void); -void Audio_NotePoolClear(NotePool* pool); -void Audio_NotePoolFill(NotePool* pool, s32 count); -void Audio_AudioListPushFront(AudioListItem* list, AudioListItem* item); -void Audio_AudioListRemove(AudioListItem* item); -Note* Audio_FindNodeWithPrioLessThan(AudioListItem* list, s32 limit); -void Audio_NoteInitForLayer(Note* note, SequenceLayer* layer); -void func_800E82C0(Note* note, SequenceLayer* layer); -void Audio_NoteReleaseAndTakeOwnership(Note* note, SequenceLayer* layer); -Note* Audio_AllocNoteFromDisabled(NotePool* pool, SequenceLayer* layer); -Note* Audio_AllocNoteFromDecaying(NotePool* pool, SequenceLayer* layer); -Note* Audio_AllocNoteFromActive(NotePool* pool, SequenceLayer* layer); -Note* Audio_AllocNote(SequenceLayer* layer); -void Audio_NoteInitAll(void); -void Audio_SequenceChannelProcessSound(SequenceChannel* channel, s32 recalculateVolume, s32 b); -void Audio_SequencePlayerProcessSound(SequencePlayer* seqPlayer); -f32 Audio_GetPortamentoFreqScale(Portamento* p); -s16 Audio_GetVibratoPitchChange(VibratoState* vib); -f32 Audio_GetVibratoFreqScale(VibratoState* vib); -void Audio_NoteVibratoUpdate(Note* note); -void Audio_NoteVibratoInit(Note* note); -void Audio_NotePortamentoInit(Note* note); -void Audio_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut); -f32 Audio_AdsrUpdate(AdsrState* adsr); -void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); -void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); -void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); -void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); -void* AudioSeq_AudioListPopBack(AudioListItem* list); -void AudioSeq_ProcessSequences(s32 arg0); -void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer); -void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); -void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); -void AudioSeq_InitSequencePlayers(void); -void func_800ECC04(u16); -void Audio_OcaSetInstrument(u8); -void Audio_OcaSetSongPlayback(s8 songIdxPlusOne, s8 playbackState); -void Audio_OcaSetRecordingState(u8); -OcarinaStaff* Audio_OcaGetRecordingStaff(void); -OcarinaStaff* Audio_OcaGetPlayingStaff(void); -OcarinaStaff* Audio_OcaGetDisplayingStaff(void); -void Audio_OcaMemoryGameStart(u8 minigameIdx); -s32 Audio_OcaMemoryGameGenNote(void); -void func_800EE824(void); -void AudioDebug_ScrPrt(const s8* str, u16 num); -void func_800F3054(void); -void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx); -void func_800F3F3C(u8); -void func_800F4010(Vec3f* pos, u16 sfxId, f32); -void Audio_PlaySoundRandom(Vec3f* pos, u16 baseSfxId, u8 randLim); -void func_800F4138(Vec3f* pos, u16 sfxId, f32); -void func_800F4190(Vec3f* pos, u16 sfxId); -void func_800F436C(Vec3f* pos, u16 sfxId, f32 arg2); -void func_800F4414(Vec3f* pos, u16 sfxId, f32); -void func_800F44EC(s8 arg0, s8 arg1); -void func_800F4524(Vec3f* pos, u16 sfxId, s8 arg2); -void func_800F4254(Vec3f* pos, u8 arg1); -void func_800F436C(Vec3f*, u16 sfxId, f32 arg2); -void func_800F4414(Vec3f*, u16 sfxId, f32 arg2); -void Audio_PlaySoundRiver(Vec3f* pos, f32 freqScale); -void Audio_PlaySoundWaterfall(Vec3f* pos, f32 freqScale); -void func_800F47BC(void); -void func_800F47FC(void); -void func_800F483C(u8 targetVol, u8 volFadeTimer); -void func_800F4870(u8); -void func_800F4A54(u8); -void Audio_PlaySoundIncreasinglyTransposed(Vec3f* pos, s16 sfxId, u8* semitones); -void Audio_ResetIncreasingTranspose(void); -void Audio_PlaySoundTransposed(Vec3f* pos, u16 sfxId, s8 semitone); -void func_800F4C58(Vec3f* pos, u16 sfxId, u8); -void func_800F4E30(Vec3f* pos, f32); -void Audio_ClearSariaBgm(void); -void Audio_ClearSariaBgmAtPos(Vec3f* pos); -void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax); -void Audio_ClearSariaBgm2(void); -void func_800F5510(u16 seqId); -void func_800F5550(u16 seqId); -void func_800F574C(f32 arg0, u8 arg2); -void func_800F5718(void); -void func_800F5918(void); -void func_800F595C(u16); -void func_800F59E8(u16); -s32 func_800F5A58(u8); -void func_800F5ACC(u16 bgmID); -void func_800F5B58(void); -void func_800F5BF0(u8 arg0); -void Audio_PlayFanfare(u16); -void func_800F5C2C(void); -void func_800F5E18(u8 playerIdx, u16 seqId, u8 fadeTimer, s8 arg3, s8 arg4); -void Audio_SetSequenceMode(u8 seqMode); -void Audio_SetBgmEnemyVolume(f32 dist); -void func_800F6268(f32 dist, u16); -void func_800F64E0(u8 arg0); -void func_800F6584(u8 arg0); -void Audio_SetEnvReverb(s8 reverb); -void Audio_SetCodeReverb(s8 reverb); -void func_800F6700(s8 outputMode); -void Audio_SetBaseFilter(u8); -void Audio_SetExtraFilter(u8); -void Audio_SetCutsceneFlag(s8 flag); -void Audio_PlaySoundIfNotInCutscene(u16 sfxId); -void func_800F6964(u16); -void func_800F6AB0(u16); -// ? Audio_DisableAllSeq(?); -// ? func_800F6BB8(?); -void Audio_PreNMI(); -// ? func_800F6C34(?); -void func_800F6D58(u8, u8, u8); -// ? func_800F6E7C(?); -void func_800F6FB4(u8); -void Audio_Init(); -void Audio_InitSound(); -void func_800F7170(void); -void func_800F71BC(s32 arg0); -void Audio_SetSoundBanksMute(u16 muteMask); -void Audio_QueueSeqCmdMute(u8 channelIdx); -void Audio_ClearBGMMute(u8 channelIdx); -void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* a4, s8* reverbAdd); -void Audio_ProcessSoundRequest(void); -void Audio_ChooseActiveSounds(u8 bankId); -void Audio_PlayActiveSounds(u8 bankId); -void Audio_StopSfxByBank(u8 bankId); -void func_800F8884(u8, Vec3f*); -void Audio_StopSfxByPosAndBank(u8, Vec3f*); -void Audio_StopSfxByPos(Vec3f*); -void func_800F9280(u8 playerIdx, u8 seqId, u8 arg2, u16 fadeTimer); -void Audio_QueueSeqCmd(u32 bgmID); -void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId); -void Audio_StopSfxByTokenAndId(u8, u16); -void Audio_StopSfxById(u32 sfxId); -void Audio_ProcessSoundRequests(void); -void func_800F8F88(void); -u8 Audio_IsSfxPlaying(u32 sfxId); -void Audio_ResetSounds(void); -void func_800F9474(u8, u16); -void func_800F94FC(u32); -void Audio_ProcessSeqCmd(u32); -void Audio_ProcessSeqCmds(void); - -u16 func_800FA0B4(u8); -s32 func_800FA11C(u32 arg0, u32 arg1); -void func_800FA174(u8); -void func_800FA18C(u8, u8); -void Audio_SetVolScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); -void func_800FA3DC(void); -u8 func_800FAD34(void); -void func_800FADF8(void); -void func_800FAEB4(void); -*/ - - extern AudioContext gAudioContext; extern OcarinaNote* gScarecrowCustomSongPtr; extern u8* gScarecrowSpawnSongPtr; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index c10f0d91e..668848581 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -28,13 +28,14 @@ struct DynaPolyActor; #define WATERBOX_ROOM(p) ((p >> 13) & 0x3F) -typedef struct { +struct ScaleRotPos { Vec3f scale; Vec3s rot; Vec3f pos; -} ScaleRotPos; +}; -typedef struct { +struct CollisionPoly +{ /* 0x00 */ u16 type; union { u16 vtxData[3]; @@ -49,15 +50,15 @@ typedef struct { // Value ranges from -0x7FFF to 0x7FFF, representing -1.0 to 1.0; 0x8000 is invalid /* 0x0E */ s16 dist; // Plane distance from origin along the normal -} CollisionPoly; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct CamData { /* 0x00 */ u16 cameraSType; /* 0x02 */ s16 numCameras; /* 0x04 */ Vec3s* camPosData; -} CamData; +}; -typedef struct { +struct WaterBox { /* 0x00 */ s16 xMin; /* 0x02 */ s16 ySurface; /* 0x04 */ s16 zMin; @@ -69,16 +70,16 @@ typedef struct { // 0x0007_E000 = Room Index, 0x3F = all rooms // 0x0000_1F00 = Lighting Settings Index // 0x0000_00FF = CamData index -} WaterBox; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct SurfaceType { u32 data[2]; // Type 1 // 0x0800_0000 = wall damage -} SurfaceType; +}; -typedef struct { +struct CollisionHeader { /* 0x00 */ Vec3s minBounds; // minimum coordinates of poly bounding box /* 0x06 */ Vec3s maxBounds; // maximum coordinates of poly bounding box /* 0x0C */ u16 numVertices; @@ -89,45 +90,45 @@ typedef struct { /* 0x20 */ CamData* cameraDataList; /* 0x24 */ u16 numWaterBoxes; /* 0x28 */ WaterBox* waterBoxes; -} CollisionHeader; // original name: BGDataInfo +}; // original name: BGDataInfo -typedef struct { +struct SSNode { s16 polyId; u16 next; // next SSNode index -} SSNode; +}; -typedef struct { +struct SSList { u16 head; // first SSNode index -} SSList; +}; -typedef struct { +struct SSNodeList { /* 0x00 */ u16 max; // original name: short_slist_node_size /* 0x02 */ u16 count; // original name: short_slist_node_last_index /* 0x04 */ SSNode* tbl; // original name: short_slist_node_tbl /* 0x08 */ u8* polyCheckTbl; // points to an array of bytes, one per static poly. Zero initialized when starting a // bg check, and set to 1 if that poly has already been tested. -} SSNodeList; +}; -typedef struct { +struct DynaSSNodeList { SSNode* tbl; s32 count; s32 max; -} DynaSSNodeList; +}; -typedef struct { +struct StaticLookup { SSList floor; SSList wall; SSList ceiling; -} StaticLookup; +}; -typedef struct { +struct DynaLookup { u16 polyStartIndex; SSList ceiling; SSList wall; SSList floor; -} DynaLookup; +}; -typedef struct { +struct BgActor { /* 0x00 */ struct Actor* actor; /* 0x04 */ CollisionHeader* colHeader; /* 0x08 */ DynaLookup dynaLookup; @@ -137,9 +138,9 @@ typedef struct { /* 0x54 */ Sphere16 boundingSphere; /* 0x5C */ f32 minY; /* 0x60 */ f32 maxY; -} BgActor; // size = 0x64 +}; // size = 0x64 -typedef struct { +struct DynaCollisionContext { /* 0x0000 */ u8 bitFlag; /* 0x0004 */ BgActor bgActors[BG_ACTOR_MAX]; /* 0x138C */ u16 bgActorFlags[BG_ACTOR_MAX]; // & 0x0008 = no dyna ceiling @@ -149,9 +150,9 @@ typedef struct { /* 0x1404 */ s32 polyNodesMax; /* 0x1408 */ s32 polyListMax; /* 0x140C */ s32 vtxListMax; -} DynaCollisionContext; // size = 0x1410 +}; // size = 0x1410 -typedef struct CollisionContext { +struct CollisionContext { /* 0x00 */ CollisionHeader* colHeader; // scene's static collision /* 0x04 */ Vec3f minBounds; // minimum coordinates of collision bounding box /* 0x10 */ Vec3f maxBounds; // maximum coordinates of collision bounding box @@ -162,9 +163,9 @@ typedef struct CollisionContext { /* 0x44 */ SSNodeList polyNodes; /* 0x50 */ DynaCollisionContext dyna; /* 0x1460 */ u32 memSize; // Size of all allocated memory plus CollisionContext -} CollisionContext; // size = 0x1464 +}; // size = 0x1464 -typedef struct { +struct DynaRaycast { /* 0x00 */ struct GlobalContext* globalCtx; /* 0x04 */ struct CollisionContext* colCtx; /* 0x08 */ u16 xpFlags; @@ -177,9 +178,9 @@ typedef struct { /* 0x24 */ f32 chkDist; /* 0x28 */ DynaCollisionContext* dyna; /* 0x2C */ SSList* ssList; -} DynaRaycast; +}; -typedef struct { +struct DynaLineTest { /* 0x00 */ struct CollisionContext* colCtx; /* 0x04 */ u16 xpFlags; /* 0x08 */ DynaCollisionContext* dyna; @@ -191,7 +192,7 @@ typedef struct { /* 0x20 */ s32 chkOneFace; // bccFlags & 0x8 /* 0x24 */ f32* distSq; // distance from posA to poly squared /* 0x28 */ f32 chkDist; // distance from poly -} DynaLineTest; +}; /* struct DynaSSNodeList; diff --git a/include/z64camera.h b/include/z64camera.h index e5a7f4b6f..7ecede994 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -23,7 +23,7 @@ #define PARENT_CAM(cam) ((cam)->globalCtx->cameraPtrs[(cam)->parentCamIdx]) #define CHILD_CAM(cam) ((cam)->globalCtx->cameraPtrs[(cam)->childCamIdx]) -typedef enum { +enum CameraSettingType { /* 0x00 */ CAM_SET_NONE, /* 0x01 */ CAM_SET_NORMAL0, /* 0x02 */ CAM_SET_NORMAL1, @@ -91,9 +91,9 @@ typedef enum { /* 0x40 */ CAM_SET_PIVOT_FROM_SIDE, // Fixed side view, allows rotation of camera (eg. Potion Shop, Meadow at fairy grotto) "CIRCLE7" /* 0x41 */ CAM_SET_NORMAL4, /* 0x42 */ CAM_SET_MAX -} CameraSettingType; +}; -typedef enum { +enum CameraModeType { /* 0x00 */ CAM_MODE_NORMAL, /* 0x01 */ CAM_MODE_TARGET, // "PARALLEL" /* 0x02 */ CAM_MODE_FOLLOWTARGET, // "KEEPON" @@ -116,9 +116,9 @@ typedef enum { /* 0x13 */ CAM_MODE_PUSHPULL, /* 0x14 */ CAM_MODE_FOLLOWBOOMERANG, // "BOOKEEPON" /* 0x15 */ CAM_MODE_MAX -} CameraModeType; +}; -typedef enum { +enum CameraFuncType { /* 0x00 */ CAM_FUNC_NONE, /* 0x01 */ CAM_FUNC_NORM0, /* 0x02 */ CAM_FUNC_NORM1, @@ -191,9 +191,9 @@ typedef enum { /* 0x45 */ CAM_FUNC_SPEC8, /* 0x46 */ CAM_FUNC_SPEC9, /* 0x47 */ CAM_FUNC_MAX -} CameraFuncType; +}; -typedef struct { +struct SwingAnimation { /* 0x00 */ Vec3f collisionClosePoint; /* 0x0C */ CollisionPoly* atEyePoly; /* 0x10 */ f32 swingUpdateRate; @@ -201,9 +201,9 @@ typedef struct { /* 0x16 */ s16 unk_16; /* 0x18 */ s16 unk_18; /* 0x1A */ s16 swingUpdateRateTimer; -} SwingAnimation; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct Normal1Anim { /* 0x00 */ SwingAnimation swing; /* 0x1C */ f32 yOffset; /* 0x20 */ f32 unk_20; @@ -211,9 +211,9 @@ typedef struct { /* 0x26 */ s16 swingYawTarget; /* 0x28 */ s16 unk_28; /* 0x2A */ s16 startSwingTimer; -} Normal1Anim; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct Normal1 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 distMin; /* 0x08 */ f32 distMax; @@ -225,9 +225,9 @@ typedef struct { /* 0x20 */ s16 pitchTarget; /* 0x22 */ s16 interfaceFlags; /* 0x24 */ Normal1Anim anim; -} Normal1; // size = 0x50 +}; // size = 0x50 -typedef struct { +struct Normal2Anim { /* 0x00 */ Vec3f unk_00; /* 0x0C */ Vec3f unk_0C; /* 0x18 */ f32 unk_18; @@ -236,9 +236,9 @@ typedef struct { /* 0x22 */ s16 unk_22; /* 0x24 */ f32 unk_24; /* 0x28 */ s16 unk_28; -} Normal2Anim; // size = 0x2A +}; // size = 0x2A -typedef struct { +struct Normal2 { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -249,9 +249,9 @@ typedef struct { /* 0x1C */ s16 unk_1C; /* 0x1E */ s16 interfaceFlags; /* 0x20 */ Normal2Anim anim; -} Normal2; // size = 0x4A +}; // size = 0x4A -typedef struct { +struct Normal3Anim { /* 0x00 */ SwingAnimation swing; /* 0x1C */ f32 unk_1C; /* 0x20 */ f32 unk_20; @@ -259,9 +259,9 @@ typedef struct { /* 0x26 */ s16 yawUpdAmt; /* 0x28 */ s16 yawTimer; /* 0x2A */ s16 distTimer; -} Normal3Anim; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct Normal3 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 distMin; /* 0x08 */ f32 distMax; @@ -272,9 +272,9 @@ typedef struct { /* 0x1C */ s16 pitchTarget; /* 0x1E */ s16 interfaceFlags; /* 0x20 */ Normal3Anim anim; -} Normal3; // size = 0x4C +}; // size = 0x4C -typedef struct { +struct Parallel1Anim { /* 0x00 */ Vec3f unk_00; /* 0x0C */ f32 yTarget; /* 0x10 */ s16 unk_10; @@ -282,9 +282,9 @@ typedef struct { /* 0x14 */ s16 pitchTarget; /* 0x16 */ s16 unk_16; /* 0x18 */ s16 animTimer; -} Parallel1Anim; // size = 0x1A +}; // size = 0x1A -typedef struct { +struct Parallel1 { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 distTarget; /* 0x08 */ f32 unk_08; @@ -297,16 +297,16 @@ typedef struct { /* 0x22 */ s16 yawTarget; /* 0x24 */ s16 interfaceFlags; /* 0x28 */ Parallel1Anim anim; -} Parallel1; // size = 0x42 +}; // size = 0x42 -typedef struct { +struct Jump1Anim { /* 0x00 */ SwingAnimation swing; /* 0x1C */ f32 unk_1C; /* 0x20 */ VecSph unk_20; -} Jump1Anim; // size = 0x28 +}; // size = 0x28 -typedef struct { +struct Jump1 { /* 0x00 */ f32 atYOffset; /* 0x04 */ f32 distMin; /* 0x08 */ f32 distMax; @@ -316,18 +316,18 @@ typedef struct { /* 0x18 */ f32 atLERPScaleMax; /* 0x1C */ s16 interfaceFlags; /* 0x20 */ Jump1Anim anim; -} Jump1; // size = 0x48 +}; // size = 0x48 -typedef struct { +struct Jump2Anim { /* 0x0 */ f32 floorY; /* 0x4 */ s16 yawTarget; /* 0x6 */ s16 initYawDiff; // unused, set but not read. /* 0x8 */ s16 yawAdj; /* 0xA */ s16 onFloor; // unused, set but not read /* 0xC */ s16 animTimer; -} Jump2Anim; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Jump2 { /* 0x00 */ f32 atYOffset; /* 0x04 */ f32 minDist; /* 0x08 */ f32 maxDist; @@ -338,16 +338,16 @@ typedef struct { /* 0x1C */ f32 atLERPStepScale; /* 0x20 */ s16 interfaceFlags; /* 0x24 */ Jump2Anim anim; -} Jump2; // size = 0x34 +}; // size = 0x34 -typedef struct { +struct Jump3Anim { /* 0x00 */ SwingAnimation swing; /* 0x1C */ f32 unk_1C; /* 0x20 */ s16 animTimer; /* 0x22 */ s16 mode; -} Jump3Anim; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct Jump3 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 distMin; /* 0x08 */ f32 distMax; @@ -359,9 +359,9 @@ typedef struct { /* 0x20 */ s16 pitchTarget; /* 0x22 */ s16 interfaceFlags; /* 0x24 */ Jump3Anim anim; -} Jump3; // size = 0x48 +}; // size = 0x48 -typedef struct { +struct Battle1Anim { /* 0x00 */ f32 initialEyeToAtDist; /* 0x04 */ f32 roll; /* 0x08 */ f32 yPosOffset; @@ -372,9 +372,9 @@ typedef struct { /* 0x18 */ s16 initialEyeToAtPitch; /* 0x1A */ s16 animTimer; /* 0x1C */ s16 chargeTimer; -} Battle1Anim; // size = 0x1E +}; // size = 0x1E -typedef struct { +struct Battle1 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 distance; /* 0x08 */ f32 swingYawInitial; @@ -388,13 +388,13 @@ typedef struct { /* 0x28 */ f32 atLERPScaleOffGround; /* 0x2C */ s16 flags; /* 0x30 */ Battle1Anim anim; -} Battle1; // size = 0x50 +}; // size = 0x50 -typedef struct { +struct Battle4Anim { /* 0x0000 */ s16 animTimer; -} Battle4Anim; // size = 0x2 +}; // size = 0x2 -typedef struct { +struct Battle4 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 rTarget; /* 0x08 */ s16 pitchTarget; @@ -404,9 +404,9 @@ typedef struct { /* 0x18 */ s16 interfaceFlags; /* 0x1A */ s16 unk_1A; /* 0x1C */ Battle4Anim anim; -} Battle4; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct Keep1Anim { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -415,9 +415,9 @@ typedef struct { /* 0x12 */ s16 unk_12; /* 0x14 */ s16 unk_14; /* 0x16 */ s16 unk_16; -} Keep1Anim; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct KeepOn1 { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -432,16 +432,16 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ s16 interfaceFlags; /* 0x34 */ Keep1Anim anim; -} KeepOn1; // size = 0x4C +}; // size = 0x4C -typedef struct { +struct Keep3Anim { /* 0x00 */ Vec3f eyeToAtTarget; // esentially a VecSph, but all floats. /* 0x0C */ struct Actor* target; /* 0x10 */ Vec3f atTarget; /* 0x1C */ s16 animTimer; -} Keep3Anim; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct KeepOn3 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 minDist; /* 0x08 */ f32 maxDist; @@ -455,9 +455,9 @@ typedef struct { /* 0x28 */ s16 initTimer; /* 0x2A */ s16 flags; /* 0x2C */ Keep3Anim anim; -} KeepOn3; // size = 0x4C +}; // size = 0x4C -typedef struct { +struct KeepOn4_Unk20 { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -466,9 +466,9 @@ typedef struct { /* 0x10 */ s16 unk_10; /* 0x12 */ s16 unk_12; /* 0x14 */ s16 unk_14; -} KeepOn4_Unk20; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct KeepOn4 { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -479,82 +479,82 @@ typedef struct { /* 0x1C */ s16 unk_1C; /* 0x1E */ s16 unk_1E; /* 0x20 */ KeepOn4_Unk20 unk_20; -} KeepOn4; // size = 0x34 +}; // size = 0x34 -typedef struct { +struct KeepOn0Anim { /* 0x0 */ f32 fovTarget; /* 0x4 */ s16 animTimer; -} KeepOn0Anim; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct KeepOn0 { /* 0x00 */ f32 fovScale; /* 0x04 */ f32 yawScale; /* 0x08 */ s16 timerInit; /* 0x0A */ s16 interfaceFlags; /* 0x0C */ KeepOn0Anim anim; -} KeepOn0; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct Fixed1Anim { /* 0x00 */ PosRot eyePosRotTarget; /* 0x14 */ s16 fov; -} Fixed1Anim; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct Fixed1 { /* 0x00 */ f32 unk_00; // seems to be unused? /* 0x04 */ f32 lerpStep; /* 0x08 */ f32 fov; /* 0x0C */ s16 interfaceFlags; /* 0x10 */ Fixed1Anim anim; -} Fixed1; // size = 0x28 +}; // size = 0x28 -typedef struct { +struct Fixed2InitParams { /* 0x0 */ Vec3f eye; /* 0xC */ s16 fov; -} Fixed2InitParams; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Fixed2 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 eyeStepScale; /* 0x08 */ f32 posStepScale; /* 0x0C */ f32 fov; /* 0x10 */ s16 interfaceFlags; /* 0x14 */ Fixed2InitParams initParams; -} Fixed2; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct Fixed3Anim { /* 0x0 */ Vec3s rot; /* 0x6 */ s16 fov; /* 0x8 */ s16 updDirTimer; /* 0xA */ s16 jfifId; -} Fixed3Anim; // size = 0xC +}; // size = 0xC -typedef struct { +struct Fixed3 { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Fixed3Anim anim; -} Fixed3; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Fixed4Anim { /* 0x0 */ Vec3f eyeTarget; /* 0xC */ f32 followSpeed; -} Fixed4Anim; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Fixed4 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 speedToEyePos; /* 0x08 */ f32 followSpeed; /* 0x0C */ f32 fov; /* 0x10 */ s16 interfaceFlags; /* 0x14 */ Fixed4Anim anim; -} Fixed4; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct Subj3Anim { /* 0x0 */ f32 r; /* 0x4 */ s16 yaw; /* 0x6 */ s16 pitch; /* 0x8 */ s16 animTimer; -} Subj3Anim; // size = 0xC +}; // size = 0xC -typedef struct { +struct Subj3 { /* 0x00 */ f32 eyeNextYOffset; /* 0x04 */ f32 eyeDist; /* 0x08 */ f32 eyeNextDist; @@ -563,9 +563,9 @@ typedef struct { /* 0x1C */ f32 fovTarget; /* 0x20 */ s16 interfaceFlags; /* 0x24 */ Subj3Anim anim; -} Subj3; // size = 0x30 +}; // size = 0x30 -typedef struct { +struct Subj4Anim { /* 0x00 */ Linef unk_00; /* 0x18 */ f32 unk_18; /* 0x1C */ f32 unk_1C; @@ -576,35 +576,35 @@ typedef struct { /* 0x2E */ s16 unk_2E; /* 0x30 */ s16 unk_30; /* 0x32 */ s16 unk_32; -} Subj4Anim; // size = 0x34 +}; // size = 0x34 -typedef struct { +struct Subj4 { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Subj4Anim anim; -} Subj4; // size = 0x38 +}; // size = 0x38 -typedef struct { +struct Data4InitParams { /* 0x00 */ PosRot eyePosRot; /* 0x14 */ char unk_14[0x8]; /* 0x1C */ s16 fov; /* 0x1E */ s16 jfifId; -} Data4InitParams; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct Data4 { /* 0x0 */ f32 yOffset; /* 0x4 */ f32 fov; /* 0x8 */ s16 interfaceFlags; /* 0xC */ Data4InitParams initParams; -} Data4; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct Unique1Anim { /* 0x0 */ f32 unk_00; // unused /* 0x4 */ s16 yawTarget; /* 0x6 */ s16 yawTargetAdj; /* 0x8 */ s16 timer; -} Unique1Anim; // size = 0xC +}; // size = 0xC -typedef struct { +struct Unique1 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 distMin; /* 0x08 */ f32 distMax; @@ -614,76 +614,76 @@ typedef struct { /* 0x18 */ s16 pitchTarget; /* 0x1A */ s16 interfaceFlags; /* 0x1C */ Unique1Anim anim; -} Unique1; // size = 0x28 +}; // size = 0x28 -typedef struct { +struct Unique2Unk10 { /* 0x0 */ f32 unk_00; /* 0x4 */ s16 unk_04; -} Unique2Unk10; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct Unique2 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 distTarget; /* 0x08 */ f32 fovTarget; /* 0x0C */ s16 interfaceFlags; /* 0x10 */ Unique2Unk10 unk_10; // unused, values set but not read. -} Unique2; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct Unique3Anim { /* 0x0 */ f32 initialFov; /* 0x4 */ f32 initialDist; -} Unique3Anim; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct Unique3Params { /* 0x0 */ f32 yOffset; /* 0x4 */ f32 fov; /* 0x8 */ s16 interfaceFlags; -} Unique3Params; // size = 0xC +}; // size = 0xC -typedef struct { +struct DoorParams { /* 0x0 */ struct Actor* doorActor; /* 0x4 */ s16 camDataIdx; /* 0x6 */ s16 timer1; /* 0x8 */ s16 timer2; /* 0xA */ s16 timer3; -} DoorParams; // size = 0xC +}; // size = 0xC -typedef struct { +struct Unique3 { /* 0x00 */ DoorParams doorParams; /* 0x0C */ Unique3Params params; /* 0x18 */ Unique3Anim anim; -} Unique3; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct Unique0Anim { /* 0x00 */ Vec3f initalPos; /* 0x0C */ s16 animTimer; /* 0x10 */ Linef sceneCamPosPlayerLine; -} Unique0Anim; // size = 0x28 +}; // size = 0x28 -typedef struct { +struct Unique0Params { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Unique0Anim anim; -} Unique0Params; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct Unique0 { /* 0x0 */ DoorParams doorParams; /* 0xC */ Unique0Params uniq0; -} Unique0; // size = 0x38 +}; // size = 0x38 -typedef struct { +struct Unique6 { /* 0x0 */ s16 interfaceFlags; -} Unique6; // size = 0x4 +}; // size = 0x4 -typedef union { +union Unique7Unk8 { /* 0x0 */ Vec3s unk_00; -} Unique7Unk8; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct Unique7 { /* 0x0 */ f32 fov; /* 0x4 */ s16 interfaceFlags; /* 0x6 */ s16 align; /* 0x8 */ Unique7Unk8 unk_08; // unk_08 goes unused. -} Unique7; // size = 0x10 +}; // size = 0x10 /** initFlags * & 0x00FF = atInitFlags @@ -698,7 +698,7 @@ typedef struct { * 0x10: ? unused * 0x20: focus on player */ -typedef struct { +struct OnePointCsFull { /* 0x00 */ u8 actionFlags; /* 0x01 */ u8 unk_01; /* 0x02 */ s16 initFlags; @@ -708,9 +708,9 @@ typedef struct { /* 0x0C */ f32 lerpStepScale; /* 0x10 */ Vec3f atTargetInit; /* 0x1C */ Vec3f eyeTargetInit; -} OnePointCsFull; /* size = 0x28 */ +}; /* size = 0x28 */ -typedef struct { +struct Unique9Anim { /* 0x00 */ OnePointCsFull* curKeyFrame; /* 0x04 */ Vec3f atTarget; /* 0x10 */ Vec3f eyeTarget; @@ -722,93 +722,93 @@ typedef struct { /* 0x38 */ s16 unk_38; /* 0x3A */ s16 isNewKeyFrame; /* 0x3C */ s16 keyFrameTimer; -} Unique9Anim; // size = 0x3E +}; // size = 0x3E -typedef struct { +struct Unique9 { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Unique9Anim anim; -} Unique9; // size = 0x40 +}; // size = 0x40 -typedef struct { +struct Unique9OnePointCs { /* 0x0 */ s32 keyFrameCnt; /* 0x4 */ OnePointCsFull* keyFrames; /* 0x8 */ Unique9 uniq9; -} Unique9OnePointCs; // size = 0x48 +}; // size = 0x48 -typedef struct { +struct Demo1Anim { /* 0x0 */ f32 curFrame; /* 0x4 */ s16 keyframe; -} Demo1Anim; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct Demo1 { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Demo1Anim anim; -} Demo1; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct Demo3Anim { /* 0x00 */ Vec3f initialAt; /* 0x0C */ f32 unk_0C; /* 0x10 */ s16 animFrame; /* 0x12 */ s16 yawDir; -} Demo3Anim; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct Demo3 { /* 0x0 */ f32 fov; /* 0x4 */ f32 unk_04; // unused /* 0x8 */ s16 interfaceFlags; /* 0xC */ Demo3Anim anim; -} Demo3; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct Demo6Anim { /* 0x0 */ s16 animTimer; /* 0x4 */ Vec3f atTarget; -} Demo6Anim; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Demo6 { /* 0x0 */ s16 interfaceFlags; /* 0x2 */ s16 unk_02; /* 0x4 */ Demo6Anim anim; -} Demo6; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct Demo9Anim { /* 0x0 */ f32 curFrame; /* 0x4 */ s16 keyframe; /* 0x6 */ s16 doLERPAt; /* 0x8 */ s16 finishAction; /* 0xA */ s16 animTimer; -} Demo9Anim; // size = 0xC +}; // size = 0xC -typedef struct { +struct Demo9 { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Demo9Anim anim; -} Demo9; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct OnePointCsCamera { /* 0x0 */ CutsceneCameraPoint* atPoints; /* 0x4 */ CutsceneCameraPoint* eyePoints; /* 0x8 */ s16 actionParameters; /* 0xA */ s16 initTimer; -} OnePointCsCamera; // size = 0xC +}; // size = 0xC -typedef struct { +struct Demo9OnePointCs { /* 0x0 */ OnePointCsCamera onePointCs; /* 0xC */ Demo9 demo9; -} Demo9OnePointCs; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct Special0 { /* 0x0 */ f32 lerpAtScale; /* 0x4 */ s16 interfaceFlags; -} Special0; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct Special4 { /* 0x0 */ s16 initalTimer; -} Special4; // size = 0x4 +}; // size = 0x4 -typedef struct { +struct Special5Anim { /* 0x0 */ s16 animTimer; -} Special5Anim; // size = 0x4 +}; // size = 0x4 -typedef struct Special5 { +struct Special5 { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 eyeDist; /* 0x08 */ f32 minDistForRot; @@ -819,48 +819,48 @@ typedef struct Special5 { /* 0x18 */ s16 interfaceFlags; /* 0x1A */ s16 unk_1A; /* 0x1C */ Special5Anim anim; -} Special5; // size = 0x20 +}; // size = 0x20 -typedef struct Special7 { +struct Special7 { /* 0x0 */ s16 idx; -} Special7; // size = 0x4 +}; // size = 0x4 -typedef struct Special6Anim { +struct Special6Anim { /* 0x0 */ f32 initalPlayerY; /* 0x4 */ s16 animTimer; -} Special6Anim; // size = 0x8 +}; // size = 0x8 -typedef struct Special6 { +struct Special6 { /* 0x0 */ s16 interfaceFlags; /* 0x4 */ Special6Anim anim; -} Special6; // size = 0xC +}; // size = 0xC -typedef struct { +struct Special9Anim { /* 0x0 */ s16 targetYaw; -} Special9Anim; // size = 0x2 +}; // size = 0x2 -typedef struct Special9Params { +struct Special9Params { /* 0x0 */ f32 yOffset; /* 0x4 */ f32 unk_04; /* 0x8 */ s16 interfaceFlags; /* 0xA */ s16 unk_0A; /* 0xC */ Special9Anim anim; -} Special9Params; // size = 0x10 +}; // size = 0x10 -typedef struct Special9 { +struct Special9 { /* 0x0 */ DoorParams doorParams; /* 0xC */ Special9Params params; -} Special9; // size = 0x1C +}; // size = 0x1C -typedef struct CamColChk { +struct CamColChk { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f norm; /* 0x18 */ CollisionPoly* poly; /* 0x1C */ VecSph sphNorm; /* 0x24 */ s32 bgId; -} CamColChk; // size = 0x28 +}; // size = 0x28 -typedef struct Camera { +struct Camera { /* 0x000 */ char paramData[0x50]; /* 0x050 */ Vec3f at; /* 0x05C */ Vec3f eye; @@ -921,13 +921,13 @@ typedef struct Camera { /* 0x166 */ s16 prevCamDataIdx; /* 0x168 */ s16 csId; /* 0x16A */ s16 unk_16A; -} Camera; // size = 0x16C +}; // size = 0x16C /** * Debug Camera */ -typedef struct DbCameraSub { +struct DbCameraSub { /* 0x0000 */ s16 mode; /* 0x0002 */ s16 nFrames; /* 0x0004 */ s16 nPoints; @@ -942,9 +942,9 @@ typedef struct DbCameraSub { /* 0x1046 */ s16 demoCtrlActionIdx; // e (?), s (save), l (load), c (clear) /* 0x1048 */ s16 demoCtrlToggleSwitch; /* 0x104A */ Vec3s unk_104A; -} DbCameraSub; // size = 0x1050 +}; // size = 0x1050 -typedef struct DbCamera { +struct DbCamera { /* 0x00 */ s32 unk_00; /* 0x04 */ Vec3f at; /* 0x10 */ Vec3f eye; @@ -965,9 +965,9 @@ typedef struct DbCamera { /* 0x78 */ s16 unk_78; /* 0x7A */ s16 unk_7A; /* 0x7C */ DbCameraSub sub; -} DbCamera; // size = 0x10CC +}; // size = 0x10CC -typedef struct DbCameraCut { +struct DbCameraCut { /* 0x00 */ char letter; /* 0x01 */ u8 unk_01; /* 0x02 */ s16 mode; @@ -975,9 +975,9 @@ typedef struct DbCameraCut { /* 0x08 */ CutsceneCameraPoint* lookAt; /* 0x0C */ s16 nFrames; /* 0x0E */ s16 nPoints; -} DbCameraCut; // size = 0x10 +}; // size = 0x10 -typedef struct DbCameraAnim { +struct DbCameraAnim { /* 0x00 */ f32 curFrame; /* 0x04 */ f32 unk_04; // frame count? /* 0x08 */ s16 keyframe; @@ -987,7 +987,7 @@ typedef struct DbCameraAnim { /* 0x1C */ Vec3f lookAtPos; /* 0x28 */ f32 roll; /* 0x2C */ f32 fov; -} DbCameraAnim; // size = 0x30 +}; // size = 0x30 /* void Camera_Init(Camera* camera, struct View* view, struct CollisionContext* colCtx, struct GlobalContext* globalCtx); diff --git a/include/z64collision_check.h b/include/z64collision_check.h index 4a95cc9e6..c795abf6a 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -6,7 +6,7 @@ #define COLLISION_CHECK_OC_MAX 50 #define COLLISION_CHECK_OC_LINE_MAX 3 -typedef struct { +struct Collider { /* 0x00 */ struct Actor* actor; // Attached actor /* 0x04 */ struct Actor* at; // Actor attached to what it collided with as an AT collider. /* 0x08 */ struct Actor* ac; // Actor attached to what it collided with as an AC collider. @@ -17,53 +17,53 @@ typedef struct { /* 0x13 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with. /* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. /* 0x15 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} Collider; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct ColliderInit { /* 0x00 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. /* 0x01 */ u8 atFlags; // Information flags for AT collisions. /* 0x02 */ u8 acFlags; // Information flags for OC collisions. /* 0x03 */ u8 ocFlags1; // Information flags for OC collisions. /* 0x04 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with. /* 0x05 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} ColliderInit; // size = 0x06 +}; // size = 0x06 -typedef struct { +struct ColliderInitType1 { /* 0x00 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. /* 0x01 */ u8 atFlags; // Information flags for AT collisions. /* 0x02 */ u8 acFlags; // Information flags for AC collisions. /* 0x03 */ u8 ocFlags1; // Information flags for OC collisions. /* 0x04 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} ColliderInitType1; // size = 0x05 +}; // size = 0x05 -typedef struct { +struct ColliderInitToActor { /* 0x00 */ struct Actor* actor; /* 0x04 */ u8 atFlags; // Information flags for AT collisions. /* 0x05 */ u8 acFlags; // Information flags for AC collisions. /* 0x06 */ u8 ocFlags1; // Information flags for OC collisions. /* 0x07 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} ColliderInitToActor; // size = 0x08 +}; // size = 0x08 -typedef struct { +struct ColliderTouch { /* 0x00 */ u32 dmgFlags; // Toucher damage type flags. /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) /* 0x05 */ u8 damage; // Damage or Stun Timer -} ColliderTouch; // size = 0x08 +}; // size = 0x08 -typedef struct { +struct ColliderBump { /* 0x00 */ u32 dmgFlags; // Bumper damage type flags. /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) /* 0x05 */ u8 defense; // Damage Resistance /* 0x06 */ Vec3s hitPos; // Point of contact -} ColliderBump; // size = 0x0C +}; // size = 0x0C -typedef struct { +struct ColliderBumpInit { /* 0x00 */ u32 dmgFlags; // Bumper exclusion mask /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) /* 0x05 */ u8 defense; // Damage Resistance -} ColliderBumpInit; // size = 0x08 +}; // size = 0x08 -typedef struct ColliderInfo { +struct ColliderInfo { /* 0x00 */ ColliderTouch toucher; // Damage properties when acting as an AT collider /* 0x08 */ ColliderBump bumper; // Damage properties when acting as an AC collider /* 0x14 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown. @@ -74,160 +74,160 @@ typedef struct ColliderInfo { /* 0x1C */ Collider* acHit; // object touching this element's AC collider /* 0x20 */ struct ColliderInfo* atHitInfo; // element that hit the AT collider /* 0x24 */ struct ColliderInfo* acHitInfo; // element that hit the AC collider -} ColliderInfo; // size = 0x28 +}; // size = 0x28 -typedef struct { +struct ColliderInfoInit { /* 0x00 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown. /* 0x04 */ ColliderTouch toucher; // Damage properties when acting as an AT collider /* 0x0C */ ColliderBumpInit bumper; // Damage properties when acting as an AC collider /* 0x14 */ u8 toucherFlags; // Information flags for AT collisions /* 0x15 */ u8 bumperFlags; // Information flags for AC collisions /* 0x16 */ u8 ocElemFlags; // Information flags for OC collisions -} ColliderInfoInit; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct ColliderJntSphElementDim { /* 0x00 */ Sphere16 modelSphere; // model space sphere /* 0x08 */ Sphere16 worldSphere; // world space sphere /* 0x10 */ f32 scale; // world space sphere = model * scale * 0.01 /* 0x14 */ u8 limb; // attached limb -} ColliderJntSphElementDim; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct ColliderJntSphElementDimInit { /* 0x00 */ u8 limb; // attached limb /* 0x02 */ Sphere16 modelSphere; // model space sphere /* 0x0A */ s16 scale; // world space sphere = model * scale * 0.01 -} ColliderJntSphElementDimInit; // size = 0x0C +}; // size = 0x0C -typedef struct { +struct ColliderJntSphElement { /* 0x00 */ ColliderInfo info; /* 0x28 */ ColliderJntSphElementDim dim; -} ColliderJntSphElement; // size = 0x40 +}; // size = 0x40 -typedef struct { +struct ColliderJntSphElementInit { /* 0x00 */ ColliderInfoInit info; /* 0x18 */ ColliderJntSphElementDimInit dim; -} ColliderJntSphElementInit; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct ColliderJntSph { /* 0x00 */ Collider base; /* 0x18 */ s32 count; /* 0x1C */ ColliderJntSphElement* elements; -} ColliderJntSph; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct ColliderJntSphInit { /* 0x00 */ ColliderInit base; /* 0x08 */ s32 count; /* 0x0C */ ColliderJntSphElementInit* elements; -} ColliderJntSphInit; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct ColliderJntSphInitType1 { /* 0x00 */ ColliderInitType1 base; /* 0x08 */ s32 count; /* 0x0C */ ColliderJntSphElementInit* elements; -} ColliderJntSphInitType1; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct ColliderJntSphInitToActor { /* 0x00 */ ColliderInitToActor base; /* 0x08 */ s32 count; /* 0x0C */ ColliderJntSphElementInit* elements; -} ColliderJntSphInitToActor; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct ColliderCylinder { /* 0x00 */ Collider base; /* 0x18 */ ColliderInfo info; /* 0x40 */ Cylinder16 dim; -} ColliderCylinder; // size = 0x4C +}; // size = 0x4C -typedef struct { +struct ColliderCylinderInit { /* 0x00 */ ColliderInit base; /* 0x08 */ ColliderInfoInit info; /* 0x20 */ Cylinder16 dim; -} ColliderCylinderInit; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct ColliderCylinderInitType1 { /* 0x00 */ ColliderInitType1 base; /* 0x08 */ ColliderInfoInit info; /* 0x20 */ Cylinder16 dim; -} ColliderCylinderInitType1; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct ColliderCylinderInitToActor { /* 0x00 */ ColliderInitToActor base; /* 0x08 */ ColliderInfoInit info; /* 0x20 */ Cylinder16 dim; -} ColliderCylinderInitToActor; // size = 0x2C +}; // size = 0x2C -typedef struct { +struct ColliderTrisElementDimInit { /* 0x00 */ Vec3f vtx[3]; -} ColliderTrisElementDimInit; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct ColliderTrisElement { /* 0x00 */ ColliderInfo info; /* 0x28 */ TriNorm dim; -} ColliderTrisElement; // size = 0x5C +}; // size = 0x5C -typedef struct { +struct ColliderTrisElementInit { /* 0x00 */ ColliderInfoInit info; /* 0x18 */ ColliderTrisElementDimInit dim; -} ColliderTrisElementInit; // size = 0x3C +}; // size = 0x3C -typedef struct { +struct ColliderTris { /* 0x00 */ Collider base; /* 0x18 */ s32 count; /* 0x1C */ ColliderTrisElement* elements; -} ColliderTris; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct ColliderTrisInit { /* 0x00 */ ColliderInit base; /* 0x08 */ s32 count; /* 0x0C */ ColliderTrisElementInit* elements; -} ColliderTrisInit; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct ColliderTrisInitType1 { /* 0x00 */ ColliderInitType1 base; /* 0x08 */ s32 count; /* 0x0C */ ColliderTrisElementInit* elements; -} ColliderTrisInitType1; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct ColliderQuadDim { /* 0x00 */ Vec3f quad[4]; /* 0x30 */ Vec3s dcMid; // midpoint of vectors d, c /* 0x36 */ Vec3s baMid; // midpoint of vectors b, a /* 0x3C */ f32 acDist; // distance to nearest AC collision this frame. -} ColliderQuadDim; // size = 0x40 +}; // size = 0x40 -typedef struct { +struct ColliderQuadDimInit { /* 0x00 */ Vec3f quad[4]; -} ColliderQuadDimInit; // size = 0x30 +}; // size = 0x30 -typedef struct { +struct ColliderQuadElement { /* 0x00 */ ColliderInfo info; /* 0x24 */ ColliderQuadDim dim; -} ColliderQuadElement; // size = 0x68 +}; // size = 0x68 -typedef struct { +struct ColliderQuad { /* 0x00 */ Collider base; /* 0x18 */ ColliderInfo info; /* 0x40 */ ColliderQuadDim dim; -} ColliderQuad; // size = 0x80 +}; // size = 0x80 -typedef struct { +struct ColliderQuadInit { /* 0x00 */ ColliderInit base; /* 0x08 */ ColliderInfoInit info; /* 0x20 */ ColliderQuadDimInit dim; -} ColliderQuadInit; // size = 0x50 +}; // size = 0x50 -typedef struct { +struct ColliderQuadInitType1 { /* 0x00 */ ColliderInitType1 base; /* 0x08 */ ColliderInfoInit info; /* 0x20 */ ColliderQuadDimInit dim; -} ColliderQuadInitType1; // size = 0x50 +}; // size = 0x50 -typedef struct { +struct OcLine { /* 0x00 */ Linef line; /* 0x18 */ u16 ocFlags; -} OcLine; // size = 0x1C +}; // size = 0x1C -typedef enum { +enum ColliderType { /* 0 */ COLTYPE_HIT0, // Blue blood, white hitmark /* 1 */ COLTYPE_HIT1, // No blood, dust hitmark /* 2 */ COLTYPE_HIT2, // Green blood, dust hitmark @@ -242,15 +242,15 @@ typedef enum { /* 11 */ COLTYPE_WOOD, /* 12 */ COLTYPE_HARD, /* 13 */ COLTYPE_TREE -} ColliderType; +}; -typedef enum { +enum ColliderShape { /* 0 */ COLSHAPE_JNTSPH, /* 1 */ COLSHAPE_CYLINDER, /* 2 */ COLSHAPE_TRIS, /* 3 */ COLSHAPE_QUAD, /* 4 */ COLSHAPE_INVALID -} ColliderShape; +}; /** * Affects the sound Link's sword makes when hitting it, hookability, @@ -258,7 +258,7 @@ typedef enum { * are == or !=. Will probably need more actors decomped to truly * understand what this is. */ -typedef enum { +enum ElementType { /* 0 */ ELEMTYPE_UNK0, /* 1 */ ELEMTYPE_UNK1, /* 2 */ ELEMTYPE_UNK2, @@ -267,7 +267,7 @@ typedef enum { /* 5 */ ELEMTYPE_UNK5, /* 6 */ ELEMTYPE_UNK6, /* 7 */ ELEMTYPE_UNK7 -} ElementType; +}; #define AT_NONE 0 // No flags set. Cannot have AT collisions when set as AT #define AT_ON (1 << 0) // Can have AT collisions when set as AT @@ -384,7 +384,7 @@ typedef enum { #define DMG_RANGED (DMG_ARROW | DMG_HOOKSHOT | DMG_SLINGSHOT) #define DMG_DEFAULT ~(DMG_SHIELD | DMG_MIR_RAY) -typedef struct { +struct CollisionCheckContext { /* 0x000 */ s16 colATCount; /* 0x002 */ u16 sacFlags; /* 0x004 */ Collider* colAT[COLLISION_CHECK_AT_MAX]; @@ -394,7 +394,7 @@ typedef struct { /* 0x1C4 */ Collider* colOC[COLLISION_CHECK_OC_MAX]; /* 0x28C */ s32 colLineCount; /* 0x290 */ OcLine* colLine[COLLISION_CHECK_OC_LINE_MAX]; -} CollisionCheckContext; // size = 0x29C +}; // size = 0x29C diff --git a/include/z64cutscene.h b/include/z64cutscene.h index f279be915..8941428ba 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -3,85 +3,85 @@ #include "ultra64.h" #include "z64math.h" -typedef struct { +struct EntranceCutscene { /* 0x00 */ u16 entrance; // entrance index upon which the cutscene should trigger /* 0x02 */ u8 ageRestriction; // 0 for adult only, 1 for child only, 2 for both ages /* 0x03 */ u8 flag; // eventChkInf flag bound to the entrance cutscene /* 0x04 */ void* segAddr; // segment offset location of the cutscene -} EntranceCutscene; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct CutsceneCameraPoint { /* 0x00 */ s8 continueFlag; /* 0x01 */ s8 cameraRoll; /* 0x02 */ u16 nextPointFrame; /* 0x04 */ f32 viewAngle; // in degrees /* 0x08 */ Vec3s pos; -} CutsceneCameraPoint; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct CutsceneCameraAngle { /* 0x00 */ Vec3f at; /* 0x0C */ Vec3f eye; /* 0x18 */ s16 roll; /* 0x1A */ s16 fov; -} CutsceneCameraAngle; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct CutsceneCameraMove { /* 0x0 */ CutsceneCameraPoint* atPoints; /* 0x4 */ CutsceneCameraPoint* eyePoints; /* 0x8 */ s16 relativeToPlayer; -} CutsceneCameraMove; // size = 0xC +}; // size = 0xC -typedef struct { +struct CsCmdBase { /* 0x00 */ u16 base; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; -} CsCmdBase; // size = 0x6 +}; // size = 0x6 -typedef struct { +struct CsCmdEnvLighting { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 setting; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; -} CsCmdEnvLighting; // size = 0x6 +}; // size = 0x6 -typedef struct { +struct CsCmdMusicChange { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 sequence; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; -} CsCmdMusicChange; // size = 0x6 +}; // size = 0x6 -typedef struct { +struct CsCmdMusicFade { /* 0x00 */ u16 type; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; -} CsCmdMusicFade; // size = 0x6 +}; // size = 0x6 -typedef struct { +struct CsCmdUnknown9 { /* 0x00 */ u16 unk_00; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; /* 0x06 */ u8 unk_06; /* 0x07 */ u8 unk_07; /* 0x08 */ u8 unk_08; -} CsCmdUnknown9; // size = 0xA +}; // size = 0xA -typedef struct { +struct CsCmdDayTime { /* 0x00 */ u16 unk_00; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; /* 0x06 */ u8 hour; /* 0x07 */ u8 minute; -} CsCmdDayTime; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct CsCmdTextbox { /* 0x00 */ u16 base; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; /* 0x06 */ u16 type; /* 0x08 */ u16 textId1; /* 0x0A */ u16 textId2; -} CsCmdTextbox; // size = 0xC +}; // size = 0xC typedef struct { /* 0x00 */ u16 action; // "dousa" @@ -96,15 +96,15 @@ typedef struct { /* 0x24 */ Vec3i normal; } CsCmdActorAction; // size = 0x30 -typedef enum { +enum CutsceneState { CS_STATE_IDLE, CS_STATE_SKIPPABLE_INIT, CS_STATE_SKIPPABLE_EXEC, CS_STATE_UNSKIPPABLE_INIT, CS_STATE_UNSKIPPABLE_EXEC -} CutsceneState; +}; -typedef enum { +enum CutsceneCmd { CS_CMD_00 = 0x0000, CS_CMD_CAM_EYE = 0x0001, CS_CMD_CAM_AT = 0x0002, @@ -135,7 +135,7 @@ typedef enum { CS_CMD_SETTIME = 0x008C, CS_CMD_TERMINATOR = 0x03E8, CS_CMD_END = 0xFFFF -} CutsceneCmd; +}; /** * Special type for blocks of cutscene data, asm-processor checks @@ -160,7 +160,7 @@ typedef union CutsceneData { #define CS_CMD_STOP -1 // TODO confirm correctness, clarify names -typedef enum { +enum CutsceneTerminatorDestination { /* 0x00 */ INVALID_DESTINATION_0, /* 0x01 */ CUTSCENE_MAP_GANON_HORSE, /* 0x02 */ CUTSCENE_MAP_THREE_GODESSES_POST_DEKU_TREE, @@ -281,9 +281,9 @@ typedef enum { /* 0x75 */ HYRULE_FIELD_SKY, /* 0x76 */ GANON_BATTLE_TOWER_COLLAPSE, /* 0x77 */ ZELDAS_COURTYARD_RECEIVE_LETTER -} CutsceneTerminatorDestination; +}; -typedef struct { +struct CutsceneContext { /* 0x00 */ char unk_00[0x4]; /* 0x04 */ void* segment; /* 0x08 */ u8 state; @@ -298,7 +298,7 @@ typedef struct { /* 0x20 */ CutsceneCameraPoint* cameraPosition; /* 0x24 */ CsCmdActorAction* linkAction; /* 0x28 */ CsCmdActorAction* npcActions[10]; // "npcdemopnt" -} CutsceneContext; // size = 0x50 +}; // size = 0x50 void func_8006450C(struct GlobalContext* globalCtx, CutsceneContext* csCtx); void func_80064520(struct GlobalContext* globalCtx, CutsceneContext* csCtx); diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index b9e62f7fe..399922d7d 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -11,7 +11,7 @@ * eeeeeeee nnnnnnnn * size = 0x8 */ -#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) CMD_W(totalEntries), CMD_W(endFrame) +#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) (s32)CMD_W(totalEntries), (s32)CMD_W(endFrame) /** * ARGS @@ -22,7 +22,7 @@ */ #define CS_CAM_POS_LIST CS_CAM_EYE_LIST #define CS_CAM_EYE_LIST(startFrame, endFrame) \ - CS_CMD_CAM_EYE, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) + CS_CMD_CAM_EYE, (s32)CMD_HH(0x0001, startFrame), (s32)CMD_HH(endFrame, 0x0000) /** * ARGS @@ -35,7 +35,7 @@ */ #define CS_CAM_POS CS_CAM_EYE #define CS_CAM_EYE(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) + (s32)CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), (s32)CMD_HH(xPos, yPos), (s32)CMD_HH(zPos, unused) /** * ARGS @@ -46,7 +46,7 @@ */ #define CS_CAM_FOCUS_POINT_LIST CS_CAM_AT_LIST #define CS_CAM_AT_LIST(startFrame, endFrame) \ - CS_CMD_CAM_AT, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) + CS_CMD_CAM_AT, (s32)CMD_HH(0x0001, startFrame), (s32)CMD_HH(endFrame, 0x0000) /** * ARGS @@ -59,7 +59,7 @@ */ #define CS_CAM_FOCUS_POINT CS_CAM_AT #define CS_CAM_AT(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) + (s32)CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), (s32)CMD_HH(xPos, yPos), (s32)CMD_HH(zPos, unused) /** * ARGS @@ -68,7 +68,7 @@ * 00000003 eeeeeeee * size = 0x8 */ -#define CS_MISC_LIST(entries) CS_CMD_MISC, CMD_W(entries) +#define CS_MISC_LIST(entries) CS_CMD_MISC, (s32)CMD_W(entries) /** * ARGS @@ -79,9 +79,9 @@ * size = 0x30 */ #define CS_MISC(unk, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8, unused9, unused10) \ - CMD_HH(unk, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), CMD_W(unused8), CMD_W(unused9), CMD_W(unused10) + (s32)CMD_HH(unk, startFrame), (s32)CMD_HH(endFrame, unused0), \ + (s32)CMD_W(unused1), (s32)CMD_W(unused2), (s32)CMD_W(unused3), (s32)CMD_W(unused4), (s32)CMD_W(unused5), \ + (s32)CMD_W(unused6), (s32)CMD_W(unused7), (s32)CMD_W(unused8), (s32)CMD_W(unused9), (s32)CMD_W(unused10) /** * ARGS @@ -90,7 +90,7 @@ * 00000004 eeeeeeee * size = 0x8 */ -#define CS_LIGHTING_LIST(entries) CS_CMD_SET_LIGHTING, CMD_W(entries) +#define CS_LIGHTING_LIST(entries) CS_CMD_SET_LIGHTING, (s32)CMD_W(entries) /** * ARGS @@ -101,9 +101,9 @@ * size = 0x30 */ #define CS_LIGHTING(setting, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(setting, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 + (s32)CMD_HH(setting, startFrame), (s32)CMD_HH(endFrame, unused0), \ + (s32)CMD_W(unused1), (s32)CMD_W(unused2), (s32)CMD_W(unused3), (s32)CMD_W(unused4), (s32)CMD_W(unused5), \ + (s32)CMD_W(unused6), (s32)CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 /** * ARGS @@ -115,7 +115,7 @@ */ #define CS_CAM_POS_PLAYER_LIST CS_CAM_EYE_REL_TO_PLAYER_LIST #define CS_CAM_EYE_REL_TO_PLAYER_LIST(startFrame, endFrame) \ - CS_CMD_CAM_EYE_REL_TO_PLAYER, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) + CS_CMD_CAM_EYE_REL_TO_PLAYER, (s32)CMD_HH(0x0001, startFrame), (s32)CMD_HH(endFrame, 0x0000) /** * ARGS @@ -128,7 +128,7 @@ */ #define CS_CAM_POS_PLAYER CS_CAM_EYE_REL_TO_PLAYER #define CS_CAM_EYE_REL_TO_PLAYER(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) + (s32)CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), (s32)CMD_HH(xPos, yPos), (s32)CMD_HH(zPos, unused) /** * ARGS @@ -140,7 +140,7 @@ */ #define CS_CAM_FOCUS_POINT_PLAYER_LIST CS_CAM_AT_REL_TO_PLAYER_LIST #define CS_CAM_AT_REL_TO_PLAYER_LIST(startFrame, endFrame) \ - CS_CMD_CAM_AT_REL_TO_PLAYER, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) + CS_CMD_CAM_AT_REL_TO_PLAYER, (s32)CMD_HH(0x0001, startFrame), (s32)CMD_HH(endFrame, 0x0000) /** * ARGS * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), @@ -152,7 +152,7 @@ */ #define CS_CAM_FOCUS_POINT_PLAYER CS_CAM_AT_REL_TO_PLAYER #define CS_CAM_AT_REL_TO_PLAYER(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) + (s32)CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), (s32)CMD_HH(xPos, yPos), (s32)CMD_HH(zPos, unused) /** * ARGS @@ -163,7 +163,7 @@ * size = 0xC */ #define CS_CMD_07_LIST(unk, startFrame, endFrame, unused) \ - CS_CMD_07, CMD_HH(unk, startFrame), CMD_HH(endFrame, unused) + CS_CMD_07, (s32)CMD_HH(unk, startFrame), (s32)CMD_HH(endFrame, unused) /** * ARGS @@ -175,7 +175,7 @@ * size = 0x10 */ #define CS_CMD_07(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) + (s32)CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), (s32)CMD_HH(xPos, yPos), (s32)CMD_HH(zPos, unused) /** * ARGS @@ -186,7 +186,7 @@ * size = 0xC */ #define CS_CMD_08_LIST(unk, startFrame, endFrame, unused) \ - CS_CMD_08, CMD_HH(unk, startFrame), CMD_HH(endFrame, unused) + CS_CMD_08, (s32)CMD_HH(unk, startFrame), (s32)CMD_HH(endFrame, unused) /** * ARGS @@ -198,7 +198,7 @@ * size = 0x10 */ #define CS_CMD_08(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) + (s32)CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), (s32)CMD_HH(xPos, yPos), (s32)CMD_HH(zPos, unused) /** * ARGS @@ -207,7 +207,7 @@ * 00000009 eeeeeeee * size = 0x8 */ -#define CS_CMD_09_LIST(entries) CS_CMD_09, CMD_W(entries) +#define CS_CMD_09_LIST(entries) CS_CMD_09, (s32)CMD_W(entries) /** * ARGS @@ -218,7 +218,7 @@ * size = 0xC */ #define CS_CMD_09(unk, startFrame, endFrame, unk2, unk3, unk4, unused0, unused1) \ - CMD_HH(unk, startFrame), CMD_HBB(endFrame, unk2, unk3), CMD_BBH(unk4, unused0, unused1) + (s32)CMD_HH(unk, startFrame), (s32)CMD_HBB(endFrame, unk2, unk3), (s32)CMD_BBH(unk4, unused0, unused1) /** * ARGS @@ -227,7 +227,7 @@ * cccccccc eeeeeeee * size = 0x8 */ -#define CS_UNK_DATA_LIST(cmdType, entries) CMD_W(cmdType), CMD_W(entries) +#define CS_UNK_DATA_LIST(cmdType, entries) (s32)CMD_W(cmdType), (s32)CMD_W(entries) /** * ARGS @@ -238,8 +238,8 @@ * size = 0x30 */ #define CS_UNK_DATA(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8, unk9, unk10, unk11, unk12) \ - CMD_W(unk1), CMD_W(unk2), CMD_W(unk3), CMD_W(unk4), CMD_W(unk5), CMD_W(unk6), \ - CMD_W(unk7), CMD_W(unk8), CMD_W(unk9), CMD_W(unk10), CMD_W(unk11), CMD_W(unk12) + (s32)CMD_W(unk1), (s32)CMD_W(unk2), (s32)CMD_W(unk3), (s32)CMD_W(unk4), (s32)CMD_W(unk5), (s32)CMD_W(unk6), \ + (s32)CMD_W(unk7), (s32)CMD_W(unk8), (s32)CMD_W(unk9), (s32)CMD_W(unk10), (s32)CMD_W(unk11), (s32)CMD_W(unk12) /** * ARGS @@ -248,7 +248,7 @@ * cccccccc eeeeeeee * size = 0x8 */ -#define CS_NPC_ACTION_LIST(cmdType, entries) CMD_W(cmdType), CMD_W(entries) +#define CS_NPC_ACTION_LIST(cmdType, entries) (s32)CMD_W(cmdType), (s32)CMD_W(entries) /** * ARGS @@ -262,9 +262,9 @@ * size = 0x30 */ #define CS_NPC_ACTION(npcAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ - CMD_HH(npcAction, startFrame), CMD_HH(endFrame, rotX), CMD_HH(rotY, rotZ), \ - CMD_W(startX), CMD_W(startY), CMD_W(startZ), \ - CMD_W(endX), CMD_W(endY), CMD_W(endZ), \ + (s32)(CMD_HH(npcAction, startFrame)), (s32)CMD_HH(endFrame, rotX), (s32)CMD_HH(rotY, rotZ), \ + (s32)CMD_W(startX), (s32)CMD_W(startY), (s32)CMD_W(startZ), \ + (s32)CMD_W(endX), (s32)CMD_W(endY), (s32)CMD_W(endZ), \ CMD_F(normX), CMD_F(normY), CMD_F(normZ) /** @@ -274,7 +274,7 @@ * cccccccc eeeeeeee * size = 0x8 */ -#define CS_PLAYER_ACTION_LIST(entries) CS_CMD_SET_PLAYER_ACTION, CMD_W(entries) +#define CS_PLAYER_ACTION_LIST(entries) CS_CMD_SET_PLAYER_ACTION, (s32)CMD_W(entries) /** * ARGS @@ -297,7 +297,7 @@ * 00000013 eeeeeeee * size = 0x8 */ -#define CS_TEXT_LIST(entries) CS_CMD_TEXTBOX, CMD_W(entries) +#define CS_TEXT_LIST(entries) CS_CMD_TEXTBOX, (s32)CMD_W(entries) /** * ARGS @@ -308,7 +308,7 @@ * size = 0xC */ #define CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \ - CMD_HH(messageId, startFrame), CMD_HH(endFrame, type), CMD_HH(topOptionBranch, bottomOptionBranch) + (s32)CMD_HH(messageId, startFrame), (s32)CMD_HH(endFrame, type), (s32)CMD_HH(topOptionBranch, bottomOptionBranch) /** * ARGS @@ -339,7 +339,7 @@ * size = 0x10 */ #define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \ - CS_CMD_SCENE_TRANS_FX, 0x00000001, CMD_HH(transitionType, startFrame), CMD_HH(endFrame, endFrame) + CS_CMD_SCENE_TRANS_FX, 0x00000001, (s32)CMD_HH(transitionType, startFrame), (s32)CMD_HH(endFrame, endFrame) /** * ARGS @@ -348,7 +348,7 @@ * 00000056 eeeeeeee * size = 0x8 */ -#define CS_PLAY_BGM_LIST(entries) CS_CMD_PLAYBGM, CMD_W(entries) +#define CS_PLAY_BGM_LIST(entries) CS_CMD_PLAYBGM, (s32)CMD_W(entries) /** * ARGS @@ -359,9 +359,9 @@ * size = 0x30 */ #define CS_PLAY_BGM(sequence, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(sequence, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 + (s32)CMD_HH(sequence, startFrame), (s32)CMD_HH(endFrame, unused0), \ + (s32)CMD_W(unused1), (s32)CMD_W(unused2), (s32)CMD_W(unused3), (s32)CMD_W(unused4), (s32)CMD_W(unused5), \ + (s32)CMD_W(unused6), (s32)CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 /** * ARGS @@ -370,7 +370,7 @@ * 00000057 eeeeeeee * size = 0x8 */ -#define CS_STOP_BGM_LIST(entries) CS_CMD_STOPBGM, CMD_W(entries) +#define CS_STOP_BGM_LIST(entries) CS_CMD_STOPBGM, (s32)CMD_W(entries) /** * ARGS @@ -381,9 +381,9 @@ * size = 0x30 */ #define CS_STOP_BGM(sequence, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(sequence, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 + (s32)CMD_HH(sequence, startFrame), (s32)CMD_HH(endFrame, unused0), \ + (s32)CMD_W(unused1), (s32)CMD_W(unused2), (s32)CMD_W(unused3), (s32)CMD_W(unused4), (s32)CMD_W(unused5), \ + (s32)CMD_W(unused6), (s32)CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 /** * ARGS @@ -392,7 +392,7 @@ * 0000007C eeeeeeee * size = 0x8 */ -#define CS_FADE_BGM_LIST(entries) CS_CMD_FADEBGM, CMD_W(entries) +#define CS_FADE_BGM_LIST(entries) CS_CMD_FADEBGM, (s32)CMD_W(entries) /** * ARGS @@ -403,9 +403,9 @@ * size = 0x30 */ #define CS_FADE_BGM(fadeType, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(fadeType, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 + (s32)CMD_HH(fadeType, startFrame), (s32)CMD_HH(endFrame, unused0), \ + (s32)CMD_W(unused1), (s32)CMD_W(unused2), (s32)CMD_W(unused3), (s32)CMD_W(unused4), (s32)CMD_W(unused5), \ + (s32)CMD_W(unused6), (s32)CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 /** * ARGS @@ -414,7 +414,7 @@ * 0000008C eeeeeeee * size = 0x8 */ -#define CS_TIME_LIST(entries) CS_CMD_SETTIME, CMD_W(entries) +#define CS_TIME_LIST(entries) CS_CMD_SETTIME, (s32)CMD_W(entries) /** * ARGS @@ -425,9 +425,9 @@ * size = 0xC */ #define CS_TIME(unk, startFrame, endFrame, hour, min, unused) \ - CMD_HH(unk, startFrame), \ + (s32)CMD_HH(unk, startFrame), \ CMD_HBB(endFrame, hour, min), \ - CMD_W(unused) + (s32)CMD_W(unused) /** * ARGS @@ -438,11 +438,11 @@ * size = 0x10 */ #define CS_TERMINATOR(dest, startFrame, endFrame) \ - CS_CMD_TERMINATOR, 0x00000001, CMD_HH(dest, startFrame), CMD_HH(endFrame, endFrame) + CS_CMD_TERMINATOR, 0x00000001, (s32)CMD_HH(dest, startFrame), (s32)CMD_HH(endFrame, endFrame) /** * Marks the end of a cutscene */ -#define CS_END() 0xFFFFFFFF, 0x00000000 +#define CS_END() (s32)0xFFFFFFFF, (s32)0x00000000 #endif diff --git a/include/z64dma.h b/include/z64dma.h index 0a3ef67e9..429a2966a 100755 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -3,7 +3,7 @@ #include "ultra64.h" -typedef struct { +struct DmaRequest { /* 0x00 */ void* vromAddr; // VROM address (source) /* 0x04 */ void* dramAddr; // DRAM address (destination) /* 0x08 */ uintptr_t size; // File Transfer size @@ -12,13 +12,13 @@ typedef struct { /* 0x14 */ s32 unk_14; /* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message /* 0x1C */ OSMesg notifyMsg; // Completion notification message -} DmaRequest; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct DmaEntry { /* 0x00 */ void* vromStart; /* 0x04 */ void* vromEnd; /* 0x08 */ void* romStart; /* 0x0C */ void* romEnd; -} DmaEntry; +}; #endif diff --git a/include/z64effect.h b/include/z64effect.h index 9c4e08df6..71df626ec 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -14,20 +14,20 @@ struct GlobalContext; #define TOTAL_EFFECT_COUNT SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT -typedef struct { +struct EffectStatus { /* 0x00 */ u8 active; /* 0x01 */ u8 unk_01; /* 0x02 */ u8 unk_02; -} EffectStatus; // size = 0x03 +}; // size = 0x03 -typedef struct { +struct EffectSparkElement { /* 0x00 */ Vec3f velocity; /* 0x0C */ Vec3f position; /* 0x18 */ Vec3s unkVelocity; /* 0x1E */ Vec3s unkPosition; -} EffectSparkElement; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct EffectSparkInit { /* 0x000 */ Vec3s position; /* 0x008 */ s32 numElements; // "table_size"; calculated as uDiv * vDiv + 2 /* 0x00C */ EffectSparkElement elements[32]; @@ -39,9 +39,9 @@ typedef struct { /* 0x4AC */ Color_RGBA8 colorEnd[4]; /* 0x4BC */ s32 timer; /* 0x4C0 */ s32 duration; -} EffectSparkInit; // size = 0x4C4 +}; // size = 0x4C4 -typedef struct { +struct EffectSpark { /* 0x000 */ Vec3s position; /* 0x008 */ s32 numElements; // "table_size"; calculated as uDiv * vDiv + 2 /* 0x00C */ EffectSparkElement elements[32]; @@ -53,17 +53,17 @@ typedef struct { /* 0x4AC */ Color_RGBA8 colorEnd[4]; /* 0x4BC */ s32 timer; /* 0x4C0 */ s32 duration; -} EffectSpark; // size = 0x4C4 +}; // size = 0x4C4 -typedef struct { +struct EffectBlureElement { /* 0x00 */ s32 state; /* 0x04 */ s32 timer; /* 0x08 */ Vec3s p1; /* 0x0E */ Vec3s p2; /* 0x14 */ u16 flags; -} EffectBlureElement; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct EffectBlureInit1 { /* 0x000 */ char unk_00[0x184]; /* 0x184 */ u8 p1StartColor[4]; /* 0x188 */ u8 p2StartColor[4]; @@ -72,9 +72,9 @@ typedef struct { /* 0x194 */ s32 elemDuration; /* 0x198 */ s32 unkFlag; /* 0x19C */ s32 calcMode; -} EffectBlureInit1; // size = 0x1A0 +}; // size = 0x1A0 -typedef struct { +struct EffectBlureInit2 { /* 0x00 */ s32 calcMode; /* 0x04 */ u16 flags; /* 0x06 */ s16 addAngleChange; @@ -88,9 +88,9 @@ typedef struct { /* 0x1B */ u8 mode4Param; /* 0x1C */ Color_RGBA8 altPrimColor; // used with drawMode 1 /* 0x20 */ Color_RGBA8 altEnvColor; // used with drawMode 1 -} EffectBlureInit2; // size = 0x24 +}; // size = 0x24 -typedef struct { +struct EffectBlure { /* 0x000 */ EffectBlureElement elements[16]; /* 0x180 */ s32 calcMode; /* 0x184 */ f32 mode4Param; @@ -107,9 +107,9 @@ typedef struct { /* 0x1A1 */ u8 drawMode; // 0: simple; 1: simple with alt colors; 2+: smooth /* 0x1A2 */ Color_RGBA8 altPrimColor; // used with drawMode 1 /* 0x1A6 */ Color_RGBA8 altEnvColor; // used with drawMode 1 -} EffectBlure; // size = 0x1AC +}; // size = 0x1AC -typedef struct { +struct EffectShieldParticleElement { /* 0x00 */ f32 initialSpeed; /* 0x04 */ f32 endXChange; /* 0x08 */ f32 endX; @@ -117,9 +117,9 @@ typedef struct { /* 0x10 */ f32 startX; /* 0x14 */ s16 yaw; /* 0x16 */ s16 pitch; -} EffectShieldParticleElement; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct EffectShieldParticleInit { /* 0x00 */ u8 numElements; /* 0x02 */ Vec3s position; /* 0x08 */ Color_RGBA8 primColorStart; @@ -134,9 +134,9 @@ typedef struct { /* 0x2C */ u8 duration; /* 0x2E */ LightPoint lightPoint; /* 0x3C */ s32 lightDecay; // halves light radius every frame when set to 1 -} EffectShieldParticleInit; // size = 0x40 +}; // size = 0x40 -typedef struct { +struct EffectShieldParticle { /* 0x000 */ EffectShieldParticleElement elements[16]; /* 0x180 */ u8 numElements; /* 0x182 */ Vec3s position; @@ -155,7 +155,7 @@ typedef struct { /* 0x1B2 */ LightInfo lightInfo; /* 0x1C0 */ LightNode* lightNode; /* 0x1C4 */ s32 lightDecay; // halves light radius every frame when set to 1 -} EffectShieldParticle; // size = 0x1C8 +}; // size = 0x1C8 typedef struct { /* 0x0000 */ struct GlobalContext* globalCtx; @@ -173,20 +173,20 @@ typedef struct { } /* 0x388C */ shieldParticles[SHIELD_PARTICLE_COUNT]; } EffectContext; // size = 0x3DF0 -typedef struct { +struct EffectInfo { /* 0x00 */ u32 size; /* 0x04 */ void (*init)(void* effect, void* initParams); /* 0x08 */ void (*destroy)(void* effect); /* 0x0C */ s32 (*update)(void* effect); /* 0x10 */ void (*draw)(void* effect, struct GraphicsContext* gfxCtx); -} EffectInfo; // size = 0x14 +}; // size = 0x14 -typedef enum { +enum EffectType { /* 0x00 */ EFFECT_SPARK, /* 0x01 */ EFFECT_BLURE1, /* 0x02 */ EFFECT_BLURE2, /* 0x03 */ EFFECT_SHIELD_PARTICLE -} EffectType; +}; /* Effect Soft Sprites */ @@ -196,12 +196,12 @@ typedef u32 (*EffectSsInitFunc)(struct GlobalContext* globalCtx, u32 index, stru typedef void (*EffectSsUpdateFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* effectSs); typedef void (*EffectSsDrawFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* effectSs); -typedef struct { +struct EffectSsInit { /* 0x00 */ u32 type; /* 0x04 */ EffectSsInitFunc init; -} EffectSsInit; // size = 0x08 +}; // size = 0x08 -typedef struct { +struct EffectSsOverlay { /* 0x00 */ uintptr_t vromStart; /* 0x04 */ uintptr_t vromEnd; /* 0x08 */ void* vramStart; @@ -209,9 +209,9 @@ typedef struct { /* 0x10 */ void* loadedRamAddr; /* 0x14 */ EffectSsInit* initInfo; /* 0x18 */ u8 unk_18; -} EffectSsOverlay; // size = 0x1C +}; // size = 0x1C -typedef struct EffectSs { +struct EffectSs { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; @@ -225,13 +225,13 @@ typedef struct EffectSs { /* 0x76 */ s16 life; // -1 means this entry is free /* 0x78 */ u8 priority; // Lower value means higher priority /* 0x79 */ u8 type; -} EffectSs; // size = 0x7A +}; // size = 0x7A -typedef struct { +struct EffectSsInfo { /* 0x00 */ EffectSs* table; // "data_table" /* 0x04 */ s32 searchStartIndex; /* 0x08 */ s32 tableSize; -} EffectSsInfo; // size = 0x0C +}; // size = 0x0C /* G Effect Regs */ @@ -251,10 +251,10 @@ typedef struct { #define DEFINE_EFFECT_SS(_0, enum) enum, #define DEFINE_EFFECT_SS_UNSET(enum) enum, -typedef enum { +enum EffectSsType { #include "tables/effect_ss_table.h" /* 0x25 */ EFFECT_SS_TYPE_MAX // originally "EFFECT_SS2_TYPE_LAST_LABEL" -} EffectSsType; +}; #undef DEFINE_EFFECT_SS #undef DEFINE_EFFECT_SS_UNSET diff --git a/include/z64environment.h b/include/z64environment.h index 09718c303..a30cf54e8 100644 --- a/include/z64environment.h +++ b/include/z64environment.h @@ -7,19 +7,19 @@ #define FILL_SCREEN_OPA (1 << 0) #define FILL_SCREEN_XLU (1 << 1) -typedef enum { +enum LightningMode { /* 0 */ LIGHTNING_MODE_OFF, // no lightning /* 1 */ LIGHTNING_MODE_ON, // request ligtning strikes at random intervals /* 2 */ LIGHTNING_MODE_LAST // request one lightning strike before turning off -} LightningMode; +}; -typedef enum { +enum LightningStrikeState { /* 0 */ LIGHTNING_STRIKE_WAIT, // wait between lightning strikes. request bolts when timer hits 0 /* 1 */ LIGHTNING_STRIKE_START, // fade in the flash. note: bolts are requested in the previous state /* 2 */ LIGHTNING_STRIKE_END // fade out the flash and go back to wait -} LightningStrikeState; +}; -typedef enum { +enum SkyboxDmaState { /* 0 */ SKYBOX_DMA_INACTIVE, /* 1 */ SKYBOX_DMA_FILE1_START, /* 2 */ SKYBOX_DMA_FILE1_DONE, @@ -27,27 +27,27 @@ typedef enum { /* 11 */ SKYBOX_DMA_FILE2_START = 11, /* 12 */ SKYBOX_DMA_FILE2_DONE, /* 13 */ SKYBOX_DMA_PAL2_START -} SkyboxDmaState; +}; -typedef struct { +struct LightningStrike { /* 0x00 */ u8 state; /* 0x01 */ u8 flashRed; /* 0x02 */ u8 flashGreen; /* 0x03 */ u8 flashBlue; /* 0x04 */ u8 flashAlphaTarget; /* 0x08 */ f32 delayTimer; -} LightningStrike; // size = 0xC +}; // size = 0xC // describes what skybox files and blending modes to use depending on time of day -typedef struct { +struct struct_8011FC1C { /* 0x00 */ u16 startTime; /* 0x02 */ u16 endTime; /* 0x04 */ u8 blend; // if true, blend between.. skyboxes? palettes? /* 0x05 */ u8 skybox1Index; // whats the difference between _pal and non _pal files? /* 0x06 */ u8 skybox2Index; -} struct_8011FC1C; // size = 0x8 +}; // size = 0x8 -typedef struct { +struct EnvLightSettings { /* 0x00 */ u8 ambientColor[3]; /* 0x03 */ s8 light1Dir[3]; /* 0x06 */ u8 light1Color[3]; @@ -56,11 +56,11 @@ typedef struct { /* 0x0F */ u8 fogColor[3]; /* 0x12 */ s16 fogNear; /* 0x14 */ s16 fogFar; -} EnvLightSettings; // size = 0x16 +}; // size = 0x16 // 1.0: 801D8EC4 // dbg: 80222A44 -typedef struct { +struct EnvironmentContext { /* 0x00 */ char unk_00[0x02]; /* 0x02 */ u16 timeIncrement; // how many units of time that pass every update /* 0x04 */ Vec3f sunPos; // moon position can be found by negating the sun position @@ -123,7 +123,7 @@ typedef struct { /* 0xEE */ u8 unk_EE[4]; /* 0xF2 */ u8 unk_F2[4]; /* 0xF6 */ char unk_F6[0x06]; -} EnvironmentContext; // size = 0xFC +}; // size = 0xFC u16 Environment_GetPixelDepth(s32 x, s32 y); void Environment_GraphCallback(struct GraphicsContext* gfxCtx, void* param); diff --git a/include/z64file.h b/include/z64file.h index 47201f5ad..c44a0d877 100644 --- a/include/z64file.h +++ b/include/z64file.h @@ -1,14 +1,14 @@ #pragma once -typedef struct { - /* 0x00 */ void* vromStart; - /* 0x04 */ void* vromEnd; -} RomFile; // size = 0x8 +struct RomFile { + /* 0x00 */ Pointer vromStart; + /* 0x04 */ Pointer vromEnd; +}; // size = 0x8 -typedef struct { +struct SkyboxFile { /* 0x00 */ RomFile file; /* 0x08 */ RomFile palette; -} SkyboxFile; // size = 0x10 +}; // size = 0x10 #define ROM_FILE(name) \ { (uintptr_t) name, (uintptr_t)name + sizeof(name) } diff --git a/include/z64game.h b/include/z64game.h index ae663d1fc..ac0be8b64 100644 --- a/include/z64game.h +++ b/include/z64game.h @@ -8,19 +8,19 @@ struct GameState; typedef void (*GameStateFunc)(struct GameState* gameState); -typedef struct GameAllocEntry { +struct GameAllocEntry { /* 0x00 */ struct GameAllocEntry* next; /* 0x04 */ struct GameAllocEntry* prev; /* 0x08 */ u32 size; /* 0x0C */ u32 unk_0C; -} GameAllocEntry; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct GameAlloc { /* 0x00 */ GameAllocEntry base; /* 0x10 */ GameAllocEntry* head; -} GameAlloc; // size = 0x14 +}; // size = 0x14 -typedef struct GameState { +struct GameState { /* 0x00 */ GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; /* 0x08 */ GameStateFunc destroy; // "cleanup" @@ -32,9 +32,9 @@ typedef struct GameState { /* 0x98 */ u32 running; /* 0x9C */ u32 frames; /* 0xA0 */ u32 unk_A0; -} GameState; // size = 0xA4 +}; // size = 0xA4 -typedef enum { +enum GameOverState { /* 00 */ GAMEOVER_INACTIVE, /* 01 */ GAMEOVER_DEATH_START, /* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for link to fall and hit the ground @@ -45,34 +45,34 @@ typedef enum { /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for link to fall and hit the ground /* 23 */ GAMEOVER_REVIVE_WAIT_FAIRY, // wait for the fairy to rise all the way up out of links body /* 24 */ GAMEOVER_REVIVE_FADE_OUT // fade out the game over lights as link is revived and gets back up -} GameOverState; +}; -typedef struct { +struct GameOverContext { /* 0x00 */ u16 state; -} GameOverContext; // size = 0x2 +}; // size = 0x2 -typedef struct { +struct HorseStruct { /* 0x00 */ char unk[0x4]; /* 0x04 */ MtxF mf; -} HorseStruct; +}; // Game Info aka. Static Context (dbg ram start: 80210A10) // Data normally accessed through REG macros (see regs.h) -typedef struct { +struct GameInfo { /* 0x00 */ s32 regPage; // 1 is first page /* 0x04 */ s32 regGroup; // "register" group (R, RS, RO, RP etc.) /* 0x08 */ s32 regCur; // selected register within page /* 0x0C */ s32 dpadLast; /* 0x10 */ s32 repeat; /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // 0xAE0 entries -} GameInfo; // size = 0x15D4 +}; // size = 0x15D4 -typedef struct { - /* 0x00 */ void* loadedRamAddr; - /* 0x04 */ void* vromStart; // if applicable - /* 0x08 */ void* vromEnd; // if applicable - /* 0x0C */ void* vramStart; // if applicable - /* 0x10 */ void* vramEnd; // if applicable +struct GameStateOverlay { + /* 0x00 */ Pointer loadedRamAddr; + /* 0x04 */ Pointer vromStart; // if applicable + /* 0x08 */ Pointer vromEnd; // if applicable + /* 0x0C */ Pointer vramStart; // if applicable + /* 0x10 */ Pointer vramEnd; // if applicable /* 0x14 */ UNK_PTR unk_14; /* 0x18 */ void* init; // initializes and executes the given context /* 0x1C */ void* destroy; // deconstructs the context, and sets the next context to load @@ -80,6 +80,6 @@ typedef struct { /* 0x24 */ UNK_PTR unk_24; /* 0x28 */ UNK_TYPE4 unk_28; /* 0x2C */ u32 instanceSize; -} GameStateOverlay; // size = 0x30 +}; // size = 0x30 extern GameInfo* gGameInfo; diff --git a/include/z64global.h b/include/z64global.h index b94473bfd..252f5a8cd 100644 --- a/include/z64global.h +++ b/include/z64global.h @@ -17,10 +17,10 @@ #include "z64bgcheck.h" #include "z64sram.h" -typedef struct { +struct FrameAdvanceContext { /* 0x00 */ s32 enabled; /* 0x04 */ s32 timer; -} FrameAdvanceContext; // size = 0x8 +}; // size = 0x8 typedef struct { union { @@ -43,7 +43,7 @@ typedef struct { } TransitionContext; // size = 0x250 // Global Context (dbg ram start: 80212020) -typedef struct GlobalContext { +struct GlobalContext { /* 0x00000 */ GameState state; /* 0x000A4 */ s16 sceneNum; /* 0x000A6 */ u8 sceneConfig; @@ -122,4 +122,4 @@ typedef struct GlobalContext { /* 0x1242B */ u8 unk_1242B; /* 0x1242C */ SceneTableEntry* loadedScene; /* 0x12430 */ char unk_12430[0xE8]; -} GlobalContext; // size = 0x12518 +}; // size = 0x12518 diff --git a/include/z64item.h b/include/z64item.h index 7609e604a..48af80d7d 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -1,14 +1,14 @@ #ifndef Z64ITEM_H #define Z64ITEM_H -typedef enum { +enum EquipmentType { /* 0x00 */ EQUIP_SWORD, /* 0x01 */ EQUIP_SHIELD, /* 0x02 */ EQUIP_TUNIC, /* 0x03 */ EQUIP_BOOTS -} EquipmentType; +}; -typedef enum { +enum UpgradeType { /* 0x00 */ UPG_QUIVER, /* 0x01 */ UPG_BOMB_BAG, /* 0x02 */ UPG_STRENGTH, @@ -17,9 +17,9 @@ typedef enum { /* 0x05 */ UPG_BULLET_BAG, /* 0x06 */ UPG_STICKS, /* 0x07 */ UPG_NUTS -} UpgradeType; +}; -typedef enum { +enum QuestItem { /* 0x00 */ QUEST_MEDALLION_FOREST, /* 0x01 */ QUEST_MEDALLION_FIRE, /* 0x02 */ QUEST_MEDALLION_WATER, @@ -45,15 +45,15 @@ typedef enum { /* 0x16 */ QUEST_GERUDO_CARD, /* 0x17 */ QUEST_SKULL_TOKEN, /* 0x18 */ QUEST_HEART_PIECE -} QuestItem; +}; -typedef enum { +enum DungeonItem { /* 0x00 */ DUNGEON_KEY_BOSS, /* 0x01 */ DUNGEON_COMPASS, /* 0x02 */ DUNGEON_MAP -} DungeonItem; +}; -typedef enum { +enum InventorySlot { /* 0x00 */ SLOT_STICK, /* 0x01 */ SLOT_NUT, /* 0x02 */ SLOT_BOMB, @@ -79,9 +79,9 @@ typedef enum { /* 0x16 */ SLOT_TRADE_ADULT, /* 0x17 */ SLOT_TRADE_CHILD, /* 0xFF */ SLOT_NONE = 0xFF -} InventorySlot; +}; -typedef enum { +enum ItemID { /* 0x00 */ ITEM_STICK, /* 0x01 */ ITEM_NUT, /* 0x02 */ ITEM_BOMB, @@ -241,13 +241,13 @@ typedef enum { /* 0xFC */ ITEM_LAST_USED = 0xFC, /* 0xFE */ ITEM_NONE_FE = 0xFE, /* 0xFF */ ITEM_NONE = 0xFF -} ItemID; +}; #define ITEM_TRADE_CHILD ITEM_WEIRD_EGG #define ITEM_TRADE_ADULT ITEM_POCKET_EGG // Get Item result may vary depending on context (chest/shop/scrub/drop) -typedef enum { +enum GetItemID { /* 0x00 */ GI_NONE, /* 0x01 */ GI_BOMBS_5, /* 0x02 */ GI_NUTS_5, @@ -375,9 +375,9 @@ typedef enum { /* 0x7C */ GI_ICE_TRAP, // freezes link when opened from a chest /* 0x7D */ GI_TEXT_0, // no model appears over Link, shows text id 0 (pocket egg) /* 0x7E */ GI_MAX -} GetItemID; +}; -typedef enum { +enum GetItemDrawID { /* 0x00 */ GID_BOTTLE, /* 0x01 */ GID_KEY_SMALL, /* 0x02 */ GID_SONG_MINUET, @@ -496,9 +496,9 @@ typedef enum { /* 0x73 */ GID_SWORD_KOKIRI, /* 0x74 */ GID_SKULL_TOKEN_2, /* 0x75 */ GID_MAX -} GetItemDrawID; +}; -typedef enum { +enum ExchangeItemID { /* 0x00 */ EXCH_ITEM_NONE, /* 0x01 */ EXCH_ITEM_LETTER_ZELDA, /* 0x02 */ EXCH_ITEM_WEIRD_EGG, @@ -530,7 +530,7 @@ typedef enum { /* 0x1C */ EXCH_ITEM_BIG_POE, /* 0x1D */ EXCH_ITEM_LETTER_RUTO, /* 0x1E */ EXCH_ITEM_MAX -} ExchangeItemID; +}; extern s16 gSpoilingItems[3]; extern s16 gSpoilingItemReverts[3]; diff --git a/include/z64jpeg.h b/include/z64jpeg.h index 71bf5fa16..4d22f3685 100644 --- a/include/z64jpeg.h +++ b/include/z64jpeg.h @@ -2,25 +2,25 @@ #include "ultra64/types.h" #include "sched.h" -typedef struct { +struct JpegQuantizationTable { /* 0x00 */ u16 table[8 * 8]; -} JpegQuantizationTable; // size = 0x80 +}; // size = 0x80 -typedef struct { +struct JpegHuffmanTable { /* 0x00 */ u8 codeOffs[16]; /* 0x10 */ u16 codesA[16]; /* 0x30 */ u16 codesB[16]; /* 0x50 */ u8* symbols; -} JpegHuffmanTable; // size = 0x54 +}; // size = 0x54 // this struct might be inaccurate but it's not used outside jpegutils.c anyways -typedef struct { +struct JpegHuffmanTableOld { /* 0x000 */ u8 codeOffs[16]; /* 0x010 */ u16 dcCodes[120]; /* 0x100 */ u16 acCodes[256]; -} JpegHuffmanTableOld; // size = 0x300 +}; // size = 0x300 -typedef struct { +struct JpegTaskData { /* 0x00 */ u32 address; /* 0x04 */ u32 mbCount; /* 0x08 */ u32 mode; @@ -28,9 +28,9 @@ typedef struct { /* 0x10 */ u32 qTableUPtr; /* 0x14 */ u32 qTableVPtr; /* 0x18 */ char unk_18[0x8]; -} JpegTaskData; // size = 0x20 +}; // size = 0x20 -typedef struct { +struct JpegWork { /* 0x000 */ JpegTaskData taskData; /* 0x020 */ char yieldData[0x200]; /* 0x220 */ JpegQuantizationTable qTableY; @@ -39,17 +39,17 @@ typedef struct { /* 0x3A0 */ u8 codesLengths[0x110]; /* 0x4B0 */ u16 codes[0x108]; /* 0x6C0 */ u16 data[4][0x180]; -} JpegWork; // size = 0x12C0 +}; // size = 0x12C0 -typedef struct { +struct JpegDecoder { /* 0x00 */ void* imageData; /* 0x04 */ u8 mode; /* 0x05 */ u8 unk_05; /* 0x08 */ JpegHuffmanTable* hTablePtrs[4]; /* 0x18 */ u8 unk_18; -} JpegDecoder; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct JpegContext { /* 0x00 */ u8 dqtCount; /* 0x04 */ u8* dqtPtr[3]; /* 0x10 */ u8 dhtCount; @@ -62,9 +62,9 @@ typedef struct { /* 0x98 */ OSMesgQueue mq; /* 0xB0 */ OSMesg msg; /* 0xB4 */ JpegWork* workBuf; -} JpegContext; // size = 0xB8 +}; // size = 0xB8 -typedef struct { +struct JpegDecoderState { /* 0x00 */ u32 byteIdx; /* 0x04 */ u8 bitIdx; /* 0x05 */ u8 dontSkip; @@ -72,7 +72,7 @@ typedef struct { /* 0x0C */ s16 unk_0C; /* 0x0E */ s16 unk_0E; /* 0x10 */ s16 unk_10; -} JpegDecoderState; // size = 0x14 +}; // size = 0x14 void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count); s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths); diff --git a/include/z64light.h b/include/z64light.h index bee30dd8f..e6c57b2e8 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -5,56 +5,56 @@ #include "z64math.h" #include "color.h" -typedef struct { +struct LightPoint { /* 0x0 */ s16 x; /* 0x2 */ s16 y; /* 0x4 */ s16 z; /* 0x6 */ u8 color[3]; /* 0x9 */ u8 drawGlow; /* 0xA */ s16 radius; -} LightPoint; // size = 0xC +}; // size = 0xC -typedef struct { +struct LightDirectional { /* 0x0 */ s8 x; /* 0x1 */ s8 y; /* 0x2 */ s8 z; /* 0x3 */ u8 color[3]; -} LightDirectional; // size = 0x6 +}; // size = 0x6 -typedef union { +union LightParams { LightPoint point; LightDirectional dir; -} LightParams; // size = 0xC +}; // size = 0xC -typedef struct { +struct LightInfo { /* 0x0 */ u8 type; /* 0x2 */ LightParams params; -} LightInfo; // size = 0xE +}; // size = 0xE -typedef struct Lights { +struct Lights { /* 0x00 */ u8 numLights; /* 0x08 */ Lightsn l; -} Lights; // size = 0x80 +}; // size = 0x80 -typedef struct LightNode { +struct LightNode { /* 0x0 */ LightInfo* info; /* 0x4 */ struct LightNode* prev; /* 0x8 */ struct LightNode* next; -} LightNode; // size = 0xC +}; // size = 0xC -typedef struct { +struct LightContext { /* 0x0 */ LightNode* listHead; /* 0x4 */ u8 ambientColor[3]; /* 0x7 */ u8 fogColor[3]; /* 0xA */ s16 fogNear; // how close until fog starts taking effect. range 0 - 1000 /* 0xC */ s16 fogFar; // how far until fog starts to saturate. range 0 - 1000 -} LightContext; // size = 0x10 +}; // size = 0x10 -typedef enum { +enum LightType { /* 0x00 */ LIGHT_POINT_NOGLOW, /* 0x01 */ LIGHT_DIRECTIONAL, /* 0x02 */ LIGHT_POINT_GLOW -} LightType; +}; typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec); diff --git a/include/z64map_mark.h b/include/z64map_mark.h index d86219784..3792ed7fc 100644 --- a/include/z64map_mark.h +++ b/include/z64map_mark.h @@ -7,16 +7,16 @@ #define MAP_MARK_CHEST 0 #define MAP_MARK_BOSS 1 -typedef struct { +struct MapMarkPoint { /* 0x00 */ s8 chestFlag; // chest icon is only displayed if this flag is not set for the current room /* 0x01 */ u8 x, y; // coordinates to place the icon (top-left corner), relative to the minimap texture -} MapMarkPoint; // size = 0x3 +}; // size = 0x3 -typedef struct { +struct MapMarkIconData { /* 0x00 */ s8 markType; // 0 for the chest icon, 1 for the boss skull icon, -1 for none /* 0x01 */ u8 count; // number of icons to display /* 0x02 */ MapMarkPoint points[12]; -} MapMarkIconData; // size = 0x26 +}; // size = 0x26 typedef MapMarkIconData MapMarkData[3]; // size = 0x72 diff --git a/include/z64math.h b/include/z64math.h index a86f5b516..a4b825802 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -4,87 +4,86 @@ #define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z) -typedef enum { +enum MatrixMode { MTXMODE_NEW, // generates a new matrix MTXMODE_APPLY // applies transformation to the current matrix -} MatrixMode; +}; -typedef struct Vec2f { +struct Vec2f { f32 x, y; -} Vec2f; // size = 0x08 +}; // size = 0x08 -typedef struct Vec3f { +struct Vec3f { f32 x, y, z; -} Vec3f; // size = 0x0C +}; // size = 0x0C -typedef struct Vec3us { +struct Vec3us { u16 x, y, z; -} Vec3us; // size = 0x06 +}; // size = 0x06 -typedef struct Vec3s { +struct Vec3s { s16 x, y, z; -} Vec3s; // size = 0x06 +}; // size = 0x06 -typedef struct Vec3i { +struct Vec3i { s32 x, y, z; -} Vec3i; // size = 0x0C +}; // size = 0x0C -typedef struct Sphere16 { +struct Sphere16 { Vec3s center; s16 radius; -} Sphere16; // size = 0x08 +}; // size = 0x08 -typedef struct { +struct Spheref { Vec3f center; f32 radius; -} Spheref; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct Plane { Vec3f normal; f32 originDist; -} Plane; // size = 0x10 +}; // size = 0x10 -typedef struct { +struct TriNorm { Vec3f vtx[3]; Plane plane; -} TriNorm; // size = 0x34 +}; // size = 0x34 -typedef struct { +struct Cylinder16 { /* 0x0000 */ s16 radius; /* 0x0002 */ s16 height; /* 0x0004 */ s16 yShift; /* 0x0006 */ Vec3s pos; -} Cylinder16; // size = 0x0C +}; // size = 0x0C -typedef struct { +struct Cylinderf { /* 0x00 */ f32 radius; /* 0x04 */ f32 height; /* 0x08 */ f32 yShift; /* 0x0C */ Vec3f pos; -} Cylinderf; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct InfiniteLine { /* 0x0000 */ Vec3f point; /* 0x000C */ Vec3f dir; -} InfiniteLine; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct Linef { /* 0x0000 */ Vec3f a; /* 0x000C */ Vec3f b; -} Linef; // size = 0x18 +}; // size = 0x18 // Defines a point in the spherical coordinate system -typedef struct { +struct VecSph { /* 0x00 */ f32 r; // radius /* 0x04 */ s16 pitch; // polar (zenith) angle /* 0x06 */ s16 yaw; // azimuthal angle -} VecSph; // size = 0x08 +}; // size = 0x08 -typedef struct -{ +struct PosRot { Vec3f pos; Vec3s rot; -} PosRot; // size = 0x14 +}; // size = 0x14 #define LERP(x, y, scale) (((y) - (x)) * (scale) + (x)) #define LERP32(x, y, scale) ((s32)(((y) - (x)) * (scale)) + (x)) diff --git a/include/z64message.h b/include/z64message.h index 72ba5601d..66cf2c6ae 100644 --- a/include/z64message.h +++ b/include/z64message.h @@ -15,7 +15,7 @@ typedef enum { LANGUAGE_ENG, LANGUAGE_GER, LANGUAGE_FRA, LANGUAGE_MAX } Language // TODO get these properties from the textures themselves #define MESSAGE_STATIC_TEX_SIZE 0x1000 -typedef enum { +enum MessageMode { /* 0x00 */ MSGMODE_NONE, /* 0x01 */ MSGMODE_TEXT_START, /* 0x02 */ MSGMODE_TEXT_BOX_GROWING, @@ -73,9 +73,9 @@ typedef enum { /* 0x36 */ MSGMODE_TEXT_CLOSING, /* 0x37 */ MSGMODE_PAUSED // Causes the message system to do nothing until external code sets a new message mode or // calls a public function -} MessageMode; +}; -typedef enum { +enum TextState { /* 0 */ TEXT_STATE_NONE, /* 1 */ TEXT_STATE_DONE_HAS_NEXT, /* 2 */ TEXT_STATE_CLOSING, @@ -87,11 +87,11 @@ typedef enum { /* 8 */ TEXT_STATE_8, /* 9 */ TEXT_STATE_9, /* 10 */ TEXT_STATE_AWAITING_NEXT -} TextState; +}; -typedef struct { - /* 0x0000 */ u32 msgOffset; - /* 0x0004 */ u32 msgLength; +struct Font { + /* 0x0000 */ Pointer msgOffset; + /* 0x0004 */ size_t msgLength; /* 0x0008 */ u8 charTexBuf[FONT_CHAR_TEX_SIZE * 120]; /* 0x3C08 */ u8 iconBuf[FONT_CHAR_TEX_SIZE]; /* 0x3C88 */ u8 fontBuf[FONT_CHAR_TEX_SIZE * 320]; @@ -99,7 +99,7 @@ typedef struct { /* 0xDC88 */ char msgBuf[1280]; /* 0xDC88 */ u16 msgBufWide[640]; }; -} Font; // size = 0xE188 +}; // size = 0xE188 #define TEXTBOX_ENDTYPE_DEFAULT 0x00 #define TEXTBOX_ENDTYPE_2_CHOICE 0x10 @@ -109,7 +109,7 @@ typedef struct { #define TEXTBOX_ENDTYPE_EVENT 0x50 #define TEXTBOX_ENDTYPE_FADING 0x60 -typedef struct { +struct MessageContext { /* 0x0000 */ View view; /* 0x0128 */ Font font; /* 0xE2B0 */ void* textboxSegment; // original name: "fukidashiSegment" @@ -162,9 +162,9 @@ typedef struct { /* 0xE40C */ s16 disableWarpSongs; // warp song flag set by scene commands /* 0xE40E */ s16 unk_E40E; // ocarina related /* 0xE410 */ u8 lastOcaNoteIdx; -} MessageContext; // size = 0xE418 +}; // size = 0xE418 -typedef enum { +enum DoAction { /* 0x00 */ DO_ACTION_ATTACK, /* 0x01 */ DO_ACTION_CHECK, /* 0x02 */ DO_ACTION_ENTER, @@ -196,9 +196,9 @@ typedef enum { /* 0x1B */ DO_ACTION_7, /* 0x1C */ DO_ACTION_8, /* 0x1D */ DO_ACTION_MAX -} DoAction; +}; -typedef enum { +enum OcarinaSongId { /* 0 */ OCARINA_SONG_MINUET, /* 1 */ OCARINA_SONG_BOLERO, /* 2 */ OCARINA_SONG_SERENADE, @@ -216,9 +216,9 @@ typedef enum { /* 14 */ OCARINA_SONG_MAX, /* 14 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX // anything larger than 13 is considered the long scarecrow's song -} OcarinaSongId; +}; -typedef enum { +enum OcarinaSongActionIDs { /* 0x00 */ OCARINA_ACTION_UNK_0, // acts like free play but never set /* 0x01 */ OCARINA_ACTION_FREE_PLAY, /* 0x02 */ OCARINA_ACTION_TEACH_MINUET, // Song demonstrations by teachers @@ -269,9 +269,9 @@ typedef enum { /* 0x2F */ OCARINA_ACTION_FROGS, /* 0x30 */ OCARINA_ACTION_CHECK_NOWARP, // Check for any of sarias - storms /* 0x31 */ OCARINA_ACTION_CHECK_NOWARP_DONE -} OcarinaSongActionIDs; +}; -typedef enum { +enum OcarinaMode { /* 0x00 */ OCARINA_MODE_00, /* 0x01 */ OCARINA_MODE_01, /* 0x02 */ OCARINA_MODE_02, @@ -288,4 +288,4 @@ typedef enum { /* 0x0D */ OCARINA_MODE_0D, /* 0x0E */ OCARINA_MODE_0E, /* 0x0F */ OCARINA_MODE_0F -} OcarinaMode; +}; diff --git a/include/z64object.h b/include/z64object.h index 7fb5567a6..ed35a1a58 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -4,16 +4,16 @@ #define DEFINE_OBJECT_NULL(_0, enum) enum, #define DEFINE_OBJECT_UNSET(enum) enum, -typedef enum { +enum ObjectID { #include "tables/object_table.h" /* 0x0192 */ OBJECT_ID_MAX -} ObjectID; +}; #undef DEFINE_OBJECT #undef DEFINE_OBJECT_NULL #undef DEFINE_OBJECT_UNSET -typedef struct { +struct ObjectContext { void* spaceStart; void* spaceEnd; // original name: "endSegment" u8 num; // number of objects in bank @@ -21,7 +21,7 @@ typedef struct { u8 mainKeepIndex; // "gameplay_keep" index in bank u8 subKeepIndex; // "gameplay_field_keep" or "gameplay_dangeon_keep" index in bank s16* objectEntry; -} ObjectContext; // size = 0x518 +}; // size = 0x518 extern u32 gObjectTableSize; extern RomFile gObjectTable[OBJECT_ID_MAX]; diff --git a/include/z64player.h b/include/z64player.h index b762961bb..7073fc1f7 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -5,22 +5,22 @@ struct Player; -typedef enum { +enum PlayerShield { /* 0x00 */ PLAYER_SHIELD_NONE, /* 0x01 */ PLAYER_SHIELD_DEKU, /* 0x02 */ PLAYER_SHIELD_HYLIAN, /* 0x03 */ PLAYER_SHIELD_MIRROR, /* 0x04 */ PLAYER_SHIELD_MAX -} PlayerShield; +}; -typedef enum { +enum PlayerTunic { /* 0x00 */ PLAYER_TUNIC_KOKIRI, /* 0x01 */ PLAYER_TUNIC_GORON, /* 0x02 */ PLAYER_TUNIC_ZORA, /* 0x03 */ PLAYER_TUNIC_MAX -} PlayerTunic; +}; -typedef enum { +enum PlayerBoots { /* 0x00 */ PLAYER_BOOTS_NORMAL, /* 0x01 */ PLAYER_BOOTS_IRON, /* 0x02 */ PLAYER_BOOTS_HOVER, @@ -29,17 +29,17 @@ typedef enum { /* 0x04 */ PLAYER_BOOTS_IRON_UNDERWATER, /* 0x05 */ PLAYER_BOOTS_NORMAL_CHILD, /* 0x06 */ PLAYER_BOOTS_MAX -} PlayerBoots; +}; -typedef enum { +enum PlayerStrength { /* 0x00 */ PLAYER_STR_NONE, /* 0x01 */ PLAYER_STR_BRACELET, /* 0x02 */ PLAYER_STR_SILVER_G, /* 0x03 */ PLAYER_STR_GOLD_G, /* 0x04 */ PLAYER_STR_MAX -} PlayerStrength; +}; -typedef enum { +enum PlayerMask { /* 0x00 */ PLAYER_MASK_NONE, /* 0x01 */ PLAYER_MASK_KEATON, /* 0x02 */ PLAYER_MASK_SKULL, @@ -50,9 +50,9 @@ typedef enum { /* 0x07 */ PLAYER_MASK_GERUDO, /* 0x08 */ PLAYER_MASK_TRUTH, /* 0x09 */ PLAYER_MASK_MAX -} PlayerMask; +}; -typedef enum { +enum PlayerActionParam { /* 0x00 */ PLAYER_AP_NONE, /* 0x01 */ PLAYER_AP_LAST_USED, /* 0x02 */ PLAYER_AP_FISHING_POLE, @@ -121,9 +121,9 @@ typedef enum { /* 0x41 */ PLAYER_AP_MASK_TRUTH, /* 0x42 */ PLAYER_AP_LENS, /* 0x43 */ PLAYER_AP_MAX -} PlayerActionParam; +}; -typedef enum { +enum PlayerLimb { /* 0x00 */ PLAYER_LIMB_NONE, /* 0x01 */ PLAYER_LIMB_ROOT, /* 0x02 */ PLAYER_LIMB_WAIST, @@ -147,20 +147,20 @@ typedef enum { /* 0x14 */ PLAYER_LIMB_SHEATH, /* 0x15 */ PLAYER_LIMB_TORSO, /* 0x16 */ PLAYER_LIMB_MAX -} PlayerLimb; +}; -typedef enum { +enum PlayerDoorType { /* -1 */ PLAYER_DOORTYPE_AJAR = -1, /* 0 */ PLAYER_DOORTYPE_NONE, /* 1 */ PLAYER_DOORTYPE_HANDLE, /* 2 */ PLAYER_DOORTYPE_SLIDING, /* 3 */ PLAYER_DOORTYPE_FAKE -} PlayerDoorType; +}; #define PLAYER_LIMB_BUF_COUNT PLAYER_LIMB_MAX + 2 // 2 extra entries in limb buffers? -typedef struct { +struct PlayerAgeProperties { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; @@ -194,19 +194,19 @@ typedef struct { /* 0xBC */ LinkAnimationHeader* unk_BC[2]; /* 0xC4 */ LinkAnimationHeader* unk_C4[2]; /* 0xCC */ LinkAnimationHeader* unk_CC[2]; -} PlayerAgeProperties; // size = 0xD4 +}; // size = 0xD4 -typedef struct { +struct WeaponInfo { /* 0x00 */ s32 active; /* 0x04 */ Vec3f tip; /* 0x10 */ Vec3f base; -} WeaponInfo; // size = 0x1C +}; // size = 0x1C typedef void (*PlayerFunc674)(struct Player*, struct GlobalContext*); typedef s32 (*PlayerFunc82C)(struct Player*, struct GlobalContext*); typedef void (*PlayerFuncA74)(struct GlobalContext*, struct Player*); -typedef struct Player { +struct Player { /* 0x0000 */ Actor actor; /* 0x014C */ s8 currentTunic; // current tunic from `PlayerTunic` /* 0x014D */ s8 currentSword; // current sword Item ID @@ -381,6 +381,6 @@ typedef struct Player { /* 0x0A86 */ s8 unk_A86; /* 0x0A87 */ u8 unk_A87; /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position -} Player; // size = 0xA94 +}; // size = 0xA94 #endif diff --git a/include/z64render.h b/include/z64render.h index 650d3b178..9a4031fe2 100644 --- a/include/z64render.h +++ b/include/z64render.h @@ -5,7 +5,7 @@ #include "listalloc.h" #include "gfx.h" -typedef enum { +enum SkyboxId { /* 0x00 */ SKYBOX_NONE, /* 0x01 */ SKYBOX_NORMAL_SKY, /* 0x02 */ SKYBOX_BAZAAR, @@ -34,21 +34,21 @@ typedef enum { /* 0x21 */ SKYBOX_HOUSE_SARIA, /* 0x22 */ SKYBOX_HOUSE_ALLEY, /* 0x27 */ SKYBOX_UNSET_27 = 39 -} SkyboxId; +}; -typedef struct { +struct SkyboxContext { /* 0x000 */ char unk_00[0x128]; /* 0x128 */ void* staticSegments[2]; - /* 0x130 */ u16 (*palettes)[256]; - /* 0x134 */ Gfx (*dListBuf)[150]; + /* 0x130 */ u16* palettes; // TODO CHECK u16 (*palettes)[256]; + /* 0x134 */ Gfx* dListBuf; // TODO CHECK Gfx (*dListBuf)[150]; /* 0x138 */ Gfx* unk_138; /* 0x13C */ Vtx* roomVtx; /* 0x140 */ s16 unk_140; /* 0x144 */ Vec3f rot; /* 0x150 */ char unk_150[0x10]; -} SkyboxContext; // size = 0x160 +}; // size = 0x160 -typedef struct { +struct PreRender { /* 0x00 */ s32 width; /* 0x04 */ s32 height; /* 0x08 */ s32 widthSave; @@ -68,4 +68,4 @@ typedef struct { /* 0x40 */ s32 lry; /* 0x44 */ ListAlloc alloc; /* 0x4C */ u32 unk_4C; -} PreRender; // size = 0x50 +}; // size = 0x50 diff --git a/include/z64save.h b/include/z64save.h index 1a9196255..dd3071a05 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -3,13 +3,13 @@ #include "ultra64.h" #include "z64math.h" -typedef struct { +struct ItemEquips { /* 0x00 */ u8 buttonItems[4]; /* 0x04 */ u8 cButtonSlots[3]; /* 0x08 */ u16 equipment; -} ItemEquips; // size = 0x0A +}; // size = 0x0A -typedef struct { +struct Inventory { /* 0x00 */ u8 items[24]; /* 0x18 */ s8 ammo[16]; /* 0x28 */ u16 equipment; @@ -19,9 +19,9 @@ typedef struct { /* 0x48 */ s8 dungeonKeys[19]; /* 0x5B */ s8 defenseHearts; /* 0x5C */ s16 gsTokens; -} Inventory; // size = 0x5E +}; // size = 0x5E -typedef struct { +struct SavedSceneFlags { /* 0x00 */ u32 chest; /* 0x04 */ u32 swch; /* 0x08 */ u32 clear; @@ -29,15 +29,15 @@ typedef struct { /* 0x10 */ u32 unk; /* 0x14 */ u32 rooms; /* 0x18 */ u32 floors; -} SavedSceneFlags; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct HorseData { /* 0x00 */ s16 scene; /* 0x02 */ Vec3s pos; /* 0x08 */ s16 angle; -} HorseData; // size = 0x0A +}; // size = 0x0A -typedef struct { +struct RespawnData { /* 0x00 */ Vec3f pos; /* 0x0C */ s16 yaw; /* 0x0E */ s16 playerParams; @@ -46,9 +46,9 @@ typedef struct { /* 0x13 */ s8 data; /* 0x14 */ u32 tempSwchFlags; /* 0x18 */ u32 tempCollectFlags; -} RespawnData; // size = 0x1C +}; // size = 0x1C -typedef struct { +struct FaroresWindData { /* 0x00 */ Vec3i pos; /* 0x0C */ s32 yaw; /* 0x10 */ s32 playerParams; @@ -57,9 +57,9 @@ typedef struct { /* 0x1C */ s32 set; /* 0x20 */ s32 tempSwchFlags; /* 0x24 */ s32 tempCollectFlags; -} FaroresWindData; // size = 0x28 +}; // size = 0x28 -typedef struct { +struct SaveContext { /* 0x0000 */ s32 entranceIndex; // start of `save` substruct, originally called "memory" /* 0x0004 */ s32 linkAge; // 0: Adult; 1: Child /* 0x0008 */ s32 cutsceneIndex; @@ -172,29 +172,29 @@ typedef struct { /* 0x1420 */ s16 worldMapArea; /* 0x1422 */ s16 sunsSongState; // controls the effects of suns song /* 0x1424 */ s16 healthAccumulator; -} SaveContext; // size = 0x1428 +}; // size = 0x1428 -typedef enum { +enum RespawnMode { /* 0x00 */ RESPAWN_MODE_DOWN, /* Normal Void Outs */ /* 0x01 */ RESPAWN_MODE_RETURN, /* Grotto Returnpoints */ /* 0x02 */ RESPAWN_MODE_TOP /* Farore's Wind */ -} RespawnMode; +}; -typedef enum { +enum ButtonStatus { /* 0x00 */ BTN_ENABLED, /* 0xFF */ BTN_DISABLED = 0xFF -} ButtonStatus; +}; -typedef enum { +enum ChamberCutsceneNum { /* 0x00 */ CHAMBER_CS_FOREST, /* 0x01 */ CHAMBER_CS_FIRE, /* 0x02 */ CHAMBER_CS_WATER, /* 0x03 */ CHAMBER_CS_SPIRIT, /* 0x04 */ CHAMBER_CS_SHADOW, /* 0x05 */ CHAMBER_CS_LIGHT -} ChamberCutsceneNum; +}; -typedef enum { +enum HighScores { /* 0x00 */ HS_HBA, // horseback archery /* 0x01 */ HS_POE_POINTS, /* 0x02 */ HS_FISHING, @@ -202,14 +202,14 @@ typedef enum { /* 0x04 */ HS_MARATHON, /* 0x05 */ HS_UNK_05, /* 0x06 */ HS_DAMPE_RACE -} HighScores; +}; -typedef enum { +enum SunsSongState { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing /* 2 */ SUNSSONG_SPEED_TIME, // suns was played where time passes, speed up the advancement of time /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads -} SunsSongState; +}; #define LINK_IS_ADULT (gSaveContext.linkAge == 0) #define LINK_IS_CHILD (gSaveContext.linkAge == 1) diff --git a/include/z64scene.h b/include/z64scene.h index d12a5b96a..d6940d5de 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -9,43 +9,43 @@ #pragma pack(push, 4) -typedef struct { +struct SCmdBase { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ uintptr_t data2; -} SCmdBase; +}; -typedef struct { +struct SCmdSpawnList { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdSpawnList; +}; -typedef struct { +struct SCmdActorList { /* 0x00 */ u8 code; /* 0x01 */ u8 num; /* 0x04 */ void* segment; -} SCmdActorList; +}; -typedef struct { +struct SCmdUnused02 { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdUnused02; +}; -typedef struct { +struct SCmdColHeader { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdColHeader; +}; -typedef struct { +struct SCmdRoomList { /* 0x00 */ u8 code; /* 0x01 */ u8 num; /* 0x04 */ void* segment; -} SCmdRoomList; +}; -typedef struct { +struct SCmdWindSettings { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x02 */ char pad[2]; @@ -53,156 +53,156 @@ typedef struct { /* 0x05 */ u8 y; /* 0x06 */ u8 z; /* 0x07 */ u8 unk_07; -} SCmdWindSettings; +}; -typedef struct { +struct SCmdEntranceList { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdEntranceList; +}; -typedef struct { +struct SCmdSpecialFiles { /* 0x00 */ u8 code; /* 0x01 */ u8 cUpElfMsgNum; /* 0x04 */ uintptr_t keepObjectId; -} SCmdSpecialFiles; +}; -typedef struct { +struct SCmdRoomBehavior { /* 0x00 */ u8 code; /* 0x01 */ u8 gpFlag1; /* 0x04 */ uintptr_t gpFlag2; -} SCmdRoomBehavior; +}; -typedef struct { +struct SCmdMesh { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdMesh; +}; -typedef struct { +struct SCmdObjectList { /* 0x00 */ u8 code; /* 0x01 */ u8 num; /* 0x04 */ void* segment; -} SCmdObjectList; +}; -typedef struct { +struct SCmdLightList { /* 0x00 */ u8 code; /* 0x01 */ u8 num; /* 0x04 */ void* segment; -} SCmdLightList; +}; -typedef struct { +struct SCmdPathList { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdPathList; +}; -typedef struct { +struct SCmdTransiActorList { /* 0x00 */ u8 code; /* 0x01 */ u8 num; /* 0x04 */ void* segment; -} SCmdTransiActorList; +}; -typedef struct { +struct SCmdLightSettingList { /* 0x00 */ u8 code; /* 0x01 */ u8 num; /* 0x04 */ void* segment; -} SCmdLightSettingList; +}; -typedef struct { +struct SCmdTimeSettings { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x02 */ char pad[2]; /* 0x04 */ u8 hour; /* 0x05 */ u8 min; /* 0x06 */ u8 unk_06; -} SCmdTimeSettings; +}; -typedef struct { +struct SCmdSkyboxSettings { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x02 */ char pad[2]; /* 0x04 */ u8 skyboxId; /* 0x05 */ u8 unk_05; /* 0x06 */ u8 unk_06; -} SCmdSkyboxSettings; +}; -typedef struct { +struct SCmdSkyboxDisables { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x02 */ char pad[2]; /* 0x04 */ u8 unk_04; /* 0x05 */ u8 unk_05; -} SCmdSkyboxDisables; +}; -typedef struct { +struct SCmdEndMarker { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ uintptr_t data2; -} SCmdEndMarker; +}; -typedef struct { +struct SCmdExitList { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdExitList; +}; -typedef struct { +struct SCmdSoundSettings { /* 0x00 */ u8 code; /* 0x01 */ u8 specId; /* 0x02 */ char pad[4]; /* 0x06 */ u8 natureAmbienceId; /* 0x07 */ u8 seqId; -} SCmdSoundSettings; +}; -typedef struct { +struct SCmdEchoSettings { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x02 */ char pad[5]; /* 0x07 */ u8 echo; -} SCmdEchoSettings; +}; -typedef struct { +struct SCmdCutsceneData { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdCutsceneData; +}; -typedef struct { +struct SCmdAltHeaders { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ void* segment; -} SCmdAltHeaders; +}; -typedef struct { +struct SCmdMiscSettings { /* 0x00 */ u8 code; /* 0x01 */ u8 cameraMovement; /* 0x04 */ uintptr_t area; -} SCmdMiscSettings; +}; -typedef struct { +struct MeshHeaderBase { u8 headerType; -} MeshHeaderBase; +}; -typedef struct { +struct MeshHeader0 { MeshHeaderBase base; u8 numEntries; - struct Gfx* dListStart; - struct Gfx* dListEnd; -} MeshHeader0; + Gfx* dListStart; + Gfx* dListEnd; +}; -typedef struct { - struct Gfx* opaqueDList; - struct Gfx* translucentDList; -} MeshEntry0; +struct MeshEntry0 { + Gfx* opaqueDList; + Gfx* translucentDList; +}; -typedef struct { +struct MeshHeader1Base { MeshHeaderBase base; u8 format; - u32 entryRecord; -} MeshHeader1Base; + Pointer entryRecord; +}; -typedef struct { +struct MeshHeader1Single { MeshHeader1Base base; void* imagePtr; // 0x08 u32 unknown; // 0x0C @@ -213,15 +213,15 @@ typedef struct { u8 imageSize; // 0x19 u16 imagePal; // 0x1A u16 imageFlip; // 0x1C -} MeshHeader1Single; +}; -typedef struct { +struct MeshHeader1Multi { MeshHeader1Base base; u8 bgCnt; void* bgRecordPtr; -} MeshHeader1Multi; +}; -typedef struct { +struct BackgroundRecord { u16 unknown; // 0x00 s8 bgID; // 0x02 void* imagePtr; // 0x04 @@ -233,23 +233,23 @@ typedef struct { u8 imageSize; // 0x15 u16 imagePal; // 0x16 u16 imageFlip; // 0x18 -} BackgroundRecord; +}; -typedef struct { +struct MeshEntry2 { s16 playerXMax, playerZMax; s16 playerXMin, playerZMin; - struct Gfx* opaqueDList; - struct Gfx* translucentDList; -} MeshEntry2; + Gfx* opaqueDList; + Gfx* translucentDList; +}; -typedef struct { +struct MeshHeader2 { MeshHeaderBase base; u8 numEntries; - struct Gfx* dListStart; - struct Gfx* dListEnd; -} MeshHeader2; + Gfx* dListStart; + Gfx* dListEnd; +}; -typedef struct { +struct LightSettings { /* 0x00 */ u8 ambientColor[3]; /* 0x03 */ s8 diffuseDir1[3]; /* 0x06 */ u8 diffuseColor1[3]; @@ -258,14 +258,14 @@ typedef struct { /* 0x0F */ u8 fogColor[3]; /* 0x12 */ u16 fogNear; /* 0x14 */ u16 fogFar; -} LightSettings; // size = 0x16 +}; // size = 0x16 -typedef struct { +struct Path { /* 0x00 */ u8 count; // number of points in the path /* 0x04 */ struct Vec3s* points; // Segment Address to the array of points -} Path; // size = 0x8 +}; // size = 0x8 -typedef union { +union SceneCmd { SCmdBase base; SCmdSpawnList spawnList; SCmdActorList actorList; @@ -292,9 +292,9 @@ typedef union { SCmdEchoSettings echoSettings; SCmdMiscSettings miscSettings; SCmdAltHeaders altHeaders; -} SceneCmd; // size = 0x8 +}; // size = 0x8 -typedef enum { +enum SceneID { /* 0x00 */ SCENE_YDAN, /* 0x01 */ SCENE_DDAN, /* 0x02 */ SCENE_BDAN, @@ -407,11 +407,11 @@ typedef enum { /* 0x6C */ SCENE_SASATEST, /* 0x6D */ SCENE_TESTROOM, /* 0x6E */ SCENE_ID_MAX -} SceneID; +}; // Scene commands -typedef enum { +enum SceneCommandTypeID { /* 0x00 */ SCENE_CMD_ID_SPAWN_LIST, /* 0x01 */ SCENE_CMD_ID_ACTOR_LIST, /* 0x02 */ SCENE_CMD_ID_UNUSED_02, @@ -438,7 +438,7 @@ typedef enum { /* 0x17 */ SCENE_CMD_ID_CUTSCENE_DATA, /* 0x18 */ SCENE_CMD_ID_ALTERNATE_HEADER_LIST, /* 0x19 */ SCENE_CMD_ID_MISC_SETTINGS -} SceneCommandTypeID; +}; #define SCENE_CMD_SPAWN_LIST(numSpawns, spawnList) \ { SCENE_CMD_ID_SPAWN_LIST, numSpawns, CMD_PTR(spawnList) } @@ -520,7 +520,7 @@ typedef enum { { SCENE_CMD_ID_MISC_SETTINGS, camMode, CMD_W(worldMapLocation) } -typedef struct { +struct SceneTableEntry { RomFile sceneFile; RomFile titleFile; u8 unk_10; @@ -528,47 +528,47 @@ typedef struct { u8 unk_12; u8 unk_13; SceneCmd* cmds; -} SceneTableEntry; // size = 0x14 +}; // size = 0x14 #pragma pack(pop) -typedef struct { - /* 0x00 */ struct Gfx* opa; - /* 0x04 */ struct Gfx* xlu; -} PolygonDlist; // size = 0x8 +struct PolygonDlist { + /* 0x00 */ Gfx* opa; + /* 0x04 */ Gfx* xlu; +}; // size = 0x8 -typedef struct { +struct ZPolygon { /* 0x00 */ u8 type; /* 0x01 */ u8 num; // number of dlist entries /* 0x04 */ void* start; /* 0x08 */ void* end; -} ZPolygon; // size = 0xC +}; // size = 0xC -typedef struct { +struct PolygonType0 { /* 0x00 */ u8 type; /* 0x01 */ u8 num; // number of dlist entries /* 0x04 */ void* start; /* 0x08 */ void* end; -} PolygonType0; // size = 0xC +}; // size = 0xC -typedef struct { +struct BgImage { /* 0x00 */ u16 unk_00; /* 0x02 */ u8 id; - /* 0x04 */ u32 source; + /* 0x04 */ Pointer source; /* 0x08 */ u32 unk_0C; - /* 0x0C */ u32 tlut; + /* 0x0C */ Pointer tlut; /* 0x10 */ u16 width; /* 0x12 */ u16 height; /* 0x14 */ u8 fmt; /* 0x15 */ u8 siz; /* 0x16 */ u16 mode0; /* 0x18 */ u16 tlutCount; -} BgImage; // size = 0x1C +}; // size = 0x1C typedef struct { /* 0x00 */ u8 type; /* 0x01 */ u8 format; // 1 = single, 2 = multi - /* 0x04 */ struct Gfx* dlist; + /* 0x04 */ Gfx* dlist; union { struct { /* 0x08 */ void* source; @@ -588,28 +588,28 @@ typedef struct { }; } PolygonType1; -typedef struct { +struct PolygonDlist2 { /* 0x00 */ Vec3s pos; /* 0x06 */ s16 unk_06; - /* 0x08 */ struct Gfx* opa; - /* 0x0C */ struct Gfx* xlu; -} PolygonDlist2; // size = 0x8 + /* 0x08 */ Gfx* opa; + /* 0x0C */ Gfx* xlu; +}; // size = 0x8 -typedef struct { +struct PolygonType2 { /* 0x00 */ u8 type; /* 0x01 */ u8 num; // number of dlist entries /* 0x04 */ void* start; /* 0x08 */ void* end; -} PolygonType2; // size = 0xC +}; // size = 0xC -typedef union { +union Mesh { ZPolygon polygon; PolygonType0 polygon0; PolygonType1 polygon1; PolygonType2 polygon2; -} Mesh; // "Ground Shape" +}; // "Ground Shape" -typedef struct { +struct Room { /* 0x00 */ s8 num; /* 0x01 */ u8 unk_01; /* 0x02 */ u8 unk_02; @@ -619,9 +619,9 @@ typedef struct { /* 0x08 */ Mesh* mesh; // original name: "ground_shape" /* 0x0C */ void* segment; /* 0x10 */ char unk_10[0x4]; -} Room; // size = 0x14 +}; // size = 0x14 -typedef struct { +struct RoomContext { /* 0x00 */ Room curRoom; /* 0x14 */ Room prevRoom; /* 0x30 */ u8 unk_30; @@ -631,7 +631,7 @@ typedef struct { /* 0x58 */ OSMesgQueue loadQueue; /* 0x70 */ OSMesg loadMsg; /* 0x74 */ s16 unk_74[2]; // context-specific data used by the current scene draw config -} RoomContext; // size = 0x78 +}; // size = 0x78 typedef struct { struct { @@ -644,13 +644,13 @@ typedef struct { /* 0x0E */ s16 params; } TransitionActorEntry; // size = 0x10 -typedef struct { +struct TransitionActorContext { /* 0x00 */ u8 numActors; /* 0x04 */ TransitionActorEntry* list; -} TransitionActorContext; +}; -typedef struct { +struct EntranceEntry { /* 0x00 */ u8 spawn; /* 0x01 */ u8 room; -} EntranceEntry; +}; diff --git a/include/z64sram.h b/include/z64sram.h index 2bfe74494..3f64503ba 100644 --- a/include/z64sram.h +++ b/include/z64sram.h @@ -1,16 +1,16 @@ #pragma once -typedef struct { +struct SramContext { /* 0x00 */ u8* readBuff; -} SramContext; // size = 0x4 +}; // size = 0x4 #define SRAM_SIZE 0x8000 #define SRAM_HEADER_SIZE 0x10 -typedef enum { +enum SramHeaderField { /* 0x00 */ SRAM_HEADER_SOUND, /* 0x01 */ SRAM_HEADER_ZTARGET, /* 0x02 */ SRAM_HEADER_LANGUAGE, /* 0x03 */ SRAM_HEADER_MAGIC // must be the value of `sZeldaMagic` for save to be considered valid -} SramHeaderField; +}; diff --git a/include/z64transition.h b/include/z64transition.h index 2adb6f604..3724cb442 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -4,12 +4,12 @@ #include "ultra64.h" #include "color.h" -typedef struct { +struct TransitionUnkData { f32 unk_0; f32 unk_4; -} TransitionUnkData; +}; -typedef struct { +struct TransitionUnk { /* 0x00 */ s32 row; /* 0x04 */ s32 col; /* 0x08 */ s32 frame; @@ -21,9 +21,9 @@ typedef struct { /* 0x98 */ Mtx unk_98; /* 0xD8 */ Gfx* gfx; // "gfxtbl" /* 0xDC */ u16* zBuffer; -} TransitionUnk; // size = 0xE0 +}; // size = 0xE0 -typedef struct { +struct TransitionWipe { /* 0x000 */ Color_RGBA8_u32 color; /* 0x004 */ Color_RGBA8_u32 envColor; /* 0x008 */ u8 direction; @@ -35,17 +35,17 @@ typedef struct { /* 0x018 */ Mtx projection; /* 0x058 */ Mtx lookAt; /* 0x098 */ Mtx modelView[2][3]; -} TransitionWipe; // size = 0x218 +}; // size = 0x218 -typedef struct { +struct TransitionFade { /* 0x000 */ u8 fadeType; /* 0x001 */ u8 isDone; /* 0x002 */ u8 fadeDirection; /* 0x004 */ Color_RGBA8_u32 fadeColor; /* 0x008 */ u16 fadeTimer; -} TransitionFade; // size = 0xC +}; // size = 0xC -typedef struct { +struct TransitionCircle { /* 0x000 */ Color_RGBA8_u32 color; /* 0x004 */ Color_RGBA8_u32 envColor; /* 0x008 */ s32 texX; @@ -62,9 +62,9 @@ typedef struct { /* 0x060 */ Mtx lookAt; /* 0x0A0 */ void* texture; /* 0x0A8 */ Mtx modelView[2][3]; -} TransitionCircle; // size = 0x228; +}; // size = 0x228; -typedef struct { +struct TransitionTriforce { /* 0x000 */ Color_RGBA8_u32 color; /* 0x004 */ f32 transPos; /* 0x008 */ f32 step; @@ -73,6 +73,6 @@ typedef struct { /* 0x018 */ Mtx projection; /* 0x058 */ s32 frame; /* 0x060 */ Mtx modelView[2][3]; -} TransitionTriforce; // size = 0x1E0; +}; // size = 0x1E0; #endif diff --git a/include/z_fbdemo_circle.h b/include/z_fbdemo_circle.h index 28a8dfb1d..3eed9a80e 100644 --- a/include/z_fbdemo_circle.h +++ b/include/z_fbdemo_circle.h @@ -5,7 +5,7 @@ void TransitionCircle_Start(void* thissx); void* TransitionCircle_Init(void* thissx); void TransitionCircle_Destroy(void* thissx); void TransitionCircle_Update(void* thissx, s32 updateRate); -void TransitionCircle_Draw(void* thissx, struct Gfx** gfxP); +void TransitionCircle_Draw(void* thissx, Gfx** gfxP); s32 TransitionCircle_IsDone(void* thissx); void TransitionCircle_SetType(void* thissx, s32 type); void TransitionCircle_SetColor(void* thissx, u32 color); diff --git a/include/z_file_choose.h b/include/z_file_choose.h index e35aafa14..d21967b27 100644 --- a/include/z_file_choose.h +++ b/include/z_file_choose.h @@ -5,7 +5,7 @@ #include "z64message.h" #include "z64render.h" -typedef struct { +struct FileChooseContext { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* windowVtx; /* 0x000A8 */ u8* staticSegment; @@ -82,7 +82,7 @@ typedef struct { /* 0x1CAD2 */ s16 kbdY; /* 0x1CAD4 */ s16 newFileNameCharCount; /* 0x1CAD6 */ s16 unk_1CAD6[5]; -} FileChooseContext; // size = 0x1CAE0 +}; // size = 0x1CAE0 void FileChoose_Init(GameState* thissx); void FileChoose_Destroy(GameState* thissx); diff --git a/include/z_opening.h b/include/z_opening.h index 6355d76ee..febebfe75 100644 --- a/include/z_opening.h +++ b/include/z_opening.h @@ -2,10 +2,10 @@ #include "z64game.h" #include "view.h" -typedef struct { +struct OpeningContext { /* 0x0000 */ GameState state; /* 0x00A8 */ View view; -} OpeningContext; // size = 0x1D0 +}; // size = 0x1D0 void Opening_Init(GameState* thissx); void Opening_Destroy(GameState* thissx); diff --git a/include/z_player.h b/include/z_player.h index 277557f0b..e057812fb 100644 --- a/include/z_player.h +++ b/include/z_player.h @@ -40,7 +40,7 @@ s32 Player_GetExplosiveHeld(struct Player* player); void Player_DrawGetItem(struct GlobalContext* globalCtx, struct Player* player); -struct Gfx* Gameplay_SetFog(struct GlobalContext* globalCtx, struct Gfx* gfx); +Gfx* Gameplay_SetFog(struct GlobalContext* globalCtx, Gfx* gfx); void Gameplay_Destroy(GameState* thissx); void Gameplay_Init(GameState* thissx); void Gameplay_Main(GameState* thissx); diff --git a/include/z_prenmi_buff.h b/include/z_prenmi_buff.h index 311d6df84..aee893253 100644 --- a/include/z_prenmi_buff.h +++ b/include/z_prenmi_buff.h @@ -2,18 +2,18 @@ #include "ultra64/time.h" #include "z64game.h" -typedef struct { +struct PreNmiBuff { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; /* 0x08 */ OSTime duration; /* 0x10 */ OSTime resetTime; -} PreNmiBuff; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) +}; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) -typedef struct PreNMIContext { +struct PreNMIContext { /* 0x00 */ GameState state; /* 0xA4 */ u32 timer; /* 0xA8 */ UNK_TYPE4 unk_A8; -} PreNMIContext; // size = 0xAC +}; // size = 0xAC void Audio_PreNMIInternal(void); void Audio_PreNMI(); diff --git a/include/z_scene_table.h b/include/z_scene_table.h index 94cac5ca4..0d7cd918c 100644 --- a/include/z_scene_table.h +++ b/include/z_scene_table.h @@ -1,10 +1,10 @@ #pragma once -typedef struct { +struct EntranceInfo { /* 0x00 */ s8 scene; /* 0x01 */ s8 spawn; /* 0x02 */ u16 field; -} EntranceInfo; // size = 0x4 +}; // size = 0x4 extern EntranceInfo gEntranceTable[1556]; extern SceneTableEntry gSceneTable[SCENE_ID_MAX]; diff --git a/include/z_select.h b/include/z_select.h index 70243f83e..80e96dcf9 100644 --- a/include/z_select.h +++ b/include/z_select.h @@ -3,13 +3,13 @@ struct SelectContext; -typedef struct { - /* 0x00 */ char* name; +struct SceneSelectEntry { + /* 0x00 */ const char* name; /* 0x04 */ void (*loadFunc)(struct SelectContext*, s32); /* 0x08 */ s32 entranceIndex; -} SceneSelectEntry; // size = 0xC +}; // size = 0xC -typedef struct SelectContext { +struct SelectContext { /* 0x0000 */ GameState state; /* 0x00A8 */ View view; /* 0x01D0 */ s32 count; @@ -29,7 +29,7 @@ typedef struct SelectContext { /* 0x0230 */ s32 lockDown; /* 0x0234 */ s32 unk_234; // unused /* 0x0238 */ u8* staticSegment; -} SelectContext; // size = 0x240 +}; // size = 0x240 void Select_Init(GameState* thissx); void Select_Destroy(GameState* thissx); diff --git a/include/z_title.h b/include/z_title.h index 875e0cb93..a7d7325ad 100644 --- a/include/z_title.h +++ b/include/z_title.h @@ -6,7 +6,7 @@ #include "z64sram.h" -typedef struct { +struct TitleContext { /* 0x0000 */ GameState state; /* 0x00A4 */ u8* staticSegment; /* 0x00A8 */ View view; @@ -20,7 +20,7 @@ typedef struct { /* 0x01E0 */ char unk_1E0[0x01]; /* 0x01E1 */ u8 exit; /* 0x01E2 */ char unk_1E2[0x06]; -} TitleContext; // size = 0x1E8 +}; // size = 0x1E8 void Title_Init(GameState* thissx); void Title_Destroy(GameState* thissx); diff --git a/include/z_vismono.h b/include/z_vismono.h index e442694f7..e1f12897c 100644 --- a/include/z_vismono.h +++ b/include/z_vismono.h @@ -3,18 +3,18 @@ #include "color.h" #include "gfx.h" -typedef struct { +struct VisMono { /* 0x00 */ u32 unk_00; /* 0x04 */ u32 setScissor; /* 0x08 */ Color_RGBA8_u32 primColor; /* 0x0C */ Color_RGBA8_u32 envColor; /* 0x10 */ u16* tlut; /* 0x14 */ Gfx* monoDl; -} VisMono; // size = 0x18 +}; // size = 0x18 -typedef struct { +struct struct_80166500 { /* 0x00 */ u32 useRgba; /* 0x04 */ u32 setScissor; /* 0x08 */ Color_RGBA8_u32 primColor; /* 0x08 */ Color_RGBA8_u32 envColor; -} struct_80166500; // size = 0x10 +}; // size = 0x10 diff --git a/oldfuncs.h b/oldfuncs.h index 65fb6a4f3..aa6ee7c99 100644 --- a/oldfuncs.h +++ b/oldfuncs.h @@ -5,18 +5,18 @@ void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 mode); void ViConfig_UpdateBlack(void); s32 DmaMgr_CompareName(const char* name1, const char* name2); -s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size); +s32 DmaMgr_DmaRomToRam(Pointer rom, Pointer ram, size_t size); s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc); -const char* DmaMgr_GetFileNameImpl(u32 vrom); -const char* DmaMgr_GetFileName(u32 vrom); +const char* DmaMgr_GetFileNameImpl(Pointer vrom); +const char* DmaMgr_GetFileName(Pointer vrom); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg0); -s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg); -s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size); +s32 DmaMgr_SendRequestImpl(DmaRequest* req, Pointer ram, Pointer vrom, size_t size, u32 unk, OSMesgQueue* queue, OSMesg msg); +s32 DmaMgr_SendRequest0(Pointer ram, Pointer vrom, u32 size); void DmaMgr_Init(void); -s32 DmaMgr_SendRequest2(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line); -s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 line); +s32 DmaMgr_SendRequest2(DmaRequest* req, Pointer ram, Pointer vrom, size_t size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line); +s32 DmaMgr_SendRequest1(Pointer ram0, Pointer vrom, size_t size, const char* file, s32 line); void* Yaz0_FirstDMA(void); void* Yaz0_NextDMA(void* curSrcPos); void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst); @@ -51,7 +51,6 @@ void LogUtils_LogThreadId(const char* name, s32 line); void LogUtils_HungupThread(const char* name, s32 line); void LogUtils_ResetHungup(void); s32 vsprintf(char* dst, const char* fmt, va_list args); -s32 sprintf(char* dst, const char* fmt, ...); void __osPiCreateAccessQueue(void); void __osPiGetAccess(void); void __osPiRelAccess(void); @@ -1024,11 +1023,13 @@ void func_80096FD4(GlobalContext* globalCtx, Room* room); u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx); s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum); s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx); +void HealthMeter_UpdateBeatingHeart(GlobalContext* globalCtx); void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags); void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx); void Sample_Destroy(GameState* thisx); void Sample_Init(GameState* thisx); void Inventory_ChangeEquipment(s16 equipment, u16 value); +void Gfx_ClearDisplay(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment); void Inventory_ChangeUpgrade(s16 upgrade, s16 value); void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx); @@ -1383,7 +1384,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g void GameState_Destroy(GameState* gameState); GameStateFunc GameState_GetInit(GameState* gameState); u32 GameState_IsRunning(GameState* gameState); -void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line); +void* GameState_Alloc(GameState* gameState, size_t size, const char* file, s32 line); void func_800C55D0(GameAlloc* this); void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line); void* GameAlloc_Malloc(GameAlloc* this, u32 size); @@ -1529,8 +1530,9 @@ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec); Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); -Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line); +Mtx* Matrix_ToMtx(Mtx* dest, const char* file, s32 line); +void Matrix_ScaleTrans(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 posX, f32 posY, f32 posZ); +Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, s32 line); Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx); void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); void Matrix_MtxFCopy(MtxF* dest, MtxF* src); @@ -1546,7 +1548,9 @@ void func_800D2CEC(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f u64* SysUcode_GetUCodeBoot(void); u64 SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); +u64 SysUcode_GetUCodeSize(void); u64* SysUcode_GetUCodeData(void); +u64 SysUcode_GetUCodeDataSize(void); void func_800D2E30(UnkRumbleStruct* arg0); void func_800D3140(UnkRumbleStruct* arg0); void func_800D3178(UnkRumbleStruct* arg0); @@ -1671,7 +1675,7 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size); void* AudioHeap_AllocSampleCache(u32 size, s32 fontId, void* sampleAddr, s8 medium, s32 cache); void AudioHeap_ApplySampleBankCache(s32 sampleBankId); void AudioLoad_DecreaseSampleDmaTtls(void); -void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, s32 medium); +void* AudioLoad_DmaSampleData(Pointer devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); void AudioLoad_InitSampleDmaBuffers(s32 arg0); s32 AudioLoad_IsFontLoadComplete(s32 fontId); s32 AudioLoad_IsSeqLoadComplete(s32 seqId); @@ -1890,7 +1894,7 @@ void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* void MtxConv_F2L(Mtx* m1, MtxF* m2); void MtxConv_L2F(MtxF* m1, Mtx* m2); void Overlay_Relocate(void* allocatedVRamAddress, OverlayRelocationSection* overlayInfo, void* vRamAddress); -s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddress); +s32 Overlay_Load(Pointer vRomStart, Pointer vRomEnd, Pointer vRamStart, Pointer vRamEnd, Pointer allocatedVRamAddress); void SystemHeap_Init(void* start, u32 size); void PadUtils_Init(Input* input); void func_800FCB70(void); @@ -2008,7 +2012,6 @@ s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* out u16 JpegDecoder_ReadBits(u8 len); s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); void guScale(Mtx* m, f32 x, f32 y, f32 z); -f32 sinf(f32); s16 sins(u16); OSTask* _VirtualToPhysicalTask(OSTask* intp); void osSpTaskLoad(OSTask* task); @@ -2068,7 +2071,6 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 initialPage, u8 bank, __OSInodeUnit* finalPage); void guOrthoF(f32[4][4], f32, f32, f32, f32, f32, f32, f32); void guOrtho(Mtx*, f32, f32, f32, f32, f32, f32, f32); -f32 cosf(f32); s16 coss(u16); void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount); s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern); diff --git a/src/boot/assert.c b/src/boot/assert.cpp similarity index 93% rename from src/boot/assert.c rename to src/boot/assert.cpp index dc9e2f2cd..280aa78bd 100644 --- a/src/boot/assert.c +++ b/src/boot/assert.cpp @@ -1,7 +1,7 @@ #define INTERNAL_SRC_BOOT_ASSERT_C #include "global.h" #include "def/assert.h" -#include "def/sprintf.h" +#include void __assert(const char* exp, const char* file, s32 line) { char msg[256]; diff --git a/src/boot/boot_main.c b/src/boot/boot_main.cpp similarity index 100% rename from src/boot/boot_main.c rename to src/boot/boot_main.cpp diff --git a/src/boot/build.c b/src/boot/build.c deleted file mode 100644 index 79bc20b00..000000000 --- a/src/boot/build.c +++ /dev/null @@ -1,4 +0,0 @@ -const char gBuildTeam[] = "Open Ocarina Team"; -const char gBuildDate[] = __DATE__; -const char gBuildTime[] = __TIME__; -const char gBuildMakeOption[] = ""; diff --git a/src/boot/build.cpp b/src/boot/build.cpp new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/boot/build.cpp @@ -0,0 +1 @@ + diff --git a/src/boot/idle.c b/src/boot/idle.cpp similarity index 100% rename from src/boot/idle.c rename to src/boot/idle.cpp diff --git a/src/boot/logutils.c b/src/boot/logutils.cpp similarity index 100% rename from src/boot/logutils.c rename to src/boot/logutils.cpp diff --git a/src/boot/stackcheck.c b/src/boot/stackcheck.cpp similarity index 97% rename from src/boot/stackcheck.c rename to src/boot/stackcheck.cpp index 8f3264843..a3ce22fcc 100644 --- a/src/boot/stackcheck.c +++ b/src/boot/stackcheck.cpp @@ -107,10 +107,10 @@ StackStatus StackCheck_GetState(StackEntry* entry) { osSyncPrintf(VT_RST); if (ret != STACK_STATUS_OK) { - LogUtils_LogHexDump(entry->head, entry->tail - entry->head); + LogUtils_LogHexDump((void*)entry->head, entry->tail - entry->head); } - return ret; + return (StackStatus)ret; } u32 StackCheck_CheckAll(void) { diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.cpp similarity index 60% rename from src/boot/z_std_dma.c rename to src/boot/z_std_dma.cpp index 6f5808089..b82c60510 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.cpp @@ -26,12 +26,17 @@ u32 sDmaMgrDataExistError = 0; #include "def/string.h" #include "def/z_std_dma.h" +static void _memcpy(Pointer dest, Pointer src, size_t size) +{ + memcpy((void*)dest.get(), (void*)src.get(), size); +} + s32 DmaMgr_CompareName(const char* name1, const char* name2) { return strcmp(name1, name2); } -s32 DmaMgr_DmaRomToRam(void* rom, void* ram, uintptr_t size) { - memcpy(ram, rom, size); +s32 DmaMgr_DmaRomToRam(Pointer rom, Pointer ram, size_t size) { + _memcpy(ram, rom, size); return 0; } @@ -39,18 +44,14 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { return 0; } -void DmaMgr_DmaFromDriveRom(void* ram, void* rom, u32 size) { - return; -} - void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) { } -const char* DmaMgr_GetFileNameImpl(void* vrom) { +const char* DmaMgr_GetFileNameImpl(Pointer vrom) { return NULL; } -const char* DmaMgr_GetFileName(void* vrom) { +const char* DmaMgr_GetFileName(Pointer vrom) { return NULL; } @@ -60,28 +61,29 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { void DmaMgr_ThreadEntry(void* arg0) { } -s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, void* vrom, uintptr_t size, u32 unk, OSMesgQueue* queue, +s32 DmaMgr_SendRequestImpl(DmaRequest* req, Pointer ram, Pointer vrom, size_t size, u32 unk, OSMesgQueue* queue, OSMesg msg) { - memcpy(ram, vrom, size); + _memcpy(ram, vrom, size); return 0; } -s32 DmaMgr_SendRequest0(void* ram, void* vrom, uintptr_t size) { - memcpy(ram, vrom, size); +s32 DmaMgr_SendRequest0(Pointer ram, Pointer vrom, size_t size) { + _memcpy(ram, vrom, size); return 0; } void DmaMgr_Init(void) { } -s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, void* vrom, uintptr_t size, u32 unk5, OSMesgQueue* queue, +s32 DmaMgr_SendRequest2(DmaRequest* req, Pointer ram, Pointer vrom, size_t size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line) { - memcpy(ram, vrom, size); + _memcpy(ram, vrom, size); return 0; } -s32 DmaMgr_SendRequest1(void* ram0, void* vrom, uintptr_t size, const char* file, s32 line) { - memcpy(ram0, vrom, size); +s32 DmaMgr_SendRequest1(Pointer ram0, Pointer vrom, size_t size, const char* file, s32 line) +{ + _memcpy(ram0, vrom, size); return 0; } diff --git a/src/buffers/gfxbuffers.c b/src/buffers/gfxbuffers.cpp similarity index 100% rename from src/buffers/gfxbuffers.c rename to src/buffers/gfxbuffers.cpp diff --git a/src/buffers/heaps.c b/src/buffers/heaps.cpp similarity index 100% rename from src/buffers/heaps.c rename to src/buffers/heaps.cpp diff --git a/src/buffers/zbuffer.c b/src/buffers/zbuffer.cpp similarity index 100% rename from src/buffers/zbuffer.c rename to src/buffers/zbuffer.cpp diff --git a/src/code/PreRender.c b/src/code/PreRender.cpp similarity index 63% rename from src/code/PreRender.c rename to src/code/PreRender.cpp index a97cf647c..c953e9477 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.cpp @@ -6,49 +6,50 @@ #include "regs.h" #include "z64game.h" #include +#include #include "def/PreRender.h" #include "def/listalloc.h" #include "def/logutils.h" -void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg) { - this->widthSave = width; - this->heightSave = height; - this->fbufSave = fbuf; - this->cvgSave = cvg; - this->zbufSave = zbuf; - this->ulxSave = 0; - this->ulySave = 0; - this->lrxSave = width - 1; - this->lrySave = height - 1; +void PreRender_SetValuesSave(PreRender* pthis, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg) { + pthis->widthSave = width; + pthis->heightSave = height; + pthis->fbufSave = (u16*)fbuf; + pthis->cvgSave = (u8*)cvg; + pthis->zbufSave = (u16*)zbuf; + pthis->ulxSave = 0; + pthis->ulySave = 0; + pthis->lrxSave = width - 1; + pthis->lrySave = height - 1; } -void PreRender_Init(PreRender* this) { - bzero(this, sizeof(PreRender)); - ListAlloc_Init(&this->alloc); +void PreRender_Init(PreRender* pthis) { + bzero(pthis, sizeof(PreRender)); + ListAlloc_Init(&pthis->alloc); } -void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf) { - this->width = width; - this->height = height; - this->fbuf = fbuf; - this->zbuf = zbuf; - this->ulx = 0; - this->uly = 0; - this->lrx = width - 1; - this->lry = height - 1; +void PreRender_SetValues(PreRender* pthis, u32 width, u32 height, void* fbuf, void* zbuf) { + pthis->width = width; + pthis->height = height; + pthis->fbuf = (u16*)fbuf; + pthis->zbuf = (u16*)zbuf; + pthis->ulx = 0; + pthis->uly = 0; + pthis->lrx = width - 1; + pthis->lry = height - 1; } -void PreRender_Destroy(PreRender* this) { - ListAlloc_FreeAll(&this->alloc); +void PreRender_Destroy(PreRender* pthis) { + ListAlloc_FreeAll(&pthis->alloc); } -void func_800C0F28(PreRender* this, Gfx** gfxp, void* buf, void* bufSave) { +void func_800C0F28(PreRender* pthis, Gfx** gfxp, void* buf, void* bufSave) { Gfx* gfx; s32 x; s32 x2; s32 dx; - LogUtils_CheckNullPointer("this", this, "../PreRender.c", 215); + LogUtils_CheckNullPointer("pthis", pthis, "../PreRender.c", 215); LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 216); gfx = *gfxp; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 218); @@ -58,16 +59,16 @@ void func_800C0F28(PreRender* this, Gfx** gfxp, void* buf, void* bufSave) { G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, bufSave); - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, bufSave); + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, pthis->width, pthis->height); - dx = 0x1000 / (this->width * 2); + dx = 0x1000 / (pthis->width * 2); - x = this->height; + x = pthis->height; x2 = 0; while (x > 0) { s32 uls = 0; - s32 lrs = this->width - 1; + s32 lrs = pthis->width - 1; s32 ult; s32 lrt; @@ -75,7 +76,7 @@ void func_800C0F28(PreRender* this, Gfx** gfxp, void* buf, void* bufSave) { ult = x2; lrt = (ult + dx) - 1; - gDPLoadTextureTile(gfx++, buf, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->height, uls, ult, lrs, lrt, 0, + gDPLoadTextureTile(gfx++, buf, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->height, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(gfx++, uls << 2, ult << 2, lrs << 2, lrt << 2, G_TX_RENDERTILE, uls << 5, ult << 5, 4 << 10, @@ -86,17 +87,17 @@ void func_800C0F28(PreRender* this, Gfx** gfxp, void* buf, void* bufSave) { } gDPPipeSync(gfx++); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->fbuf); *gfxp = gfx; } -void func_800C1258(PreRender* this, Gfx** gfxp) { +void func_800C1258(PreRender* pthis, Gfx** gfxp) { Gfx* gfx; s32 y; s32 y2; s32 dy; - LogUtils_CheckNullPointer("this", this, "../PreRender.c", 278); + LogUtils_CheckNullPointer("pthis", pthis, "../PreRender.c", 278); LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 279); gfx = *gfxp; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 281); @@ -106,12 +107,12 @@ void func_800C1258(PreRender* this, Gfx** gfxp) { G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, this->ulx, this->uly, this->lrx + 1, this->lry + 1); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->fbuf); + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, pthis->ulx, pthis->uly, pthis->lrx + 1, pthis->lry + 1); - dy = 0x1000 / ((this->lrxSave - this->ulxSave + 1) * 2); + dy = 0x1000 / ((pthis->lrxSave - pthis->ulxSave + 1) * 2); - y = (this->lrySave - this->ulySave) + 1; + y = (pthis->lrySave - pthis->ulySave) + 1; y2 = 0; while (y > 0) { s32 ult; @@ -120,33 +121,33 @@ void func_800C1258(PreRender* this, Gfx** gfxp) { dy = CLAMP_MAX(dy, y); - ult = this->ulySave + y2; + ult = pthis->ulySave + y2; lrt = (ult + dy) - 1; - uly = this->uly + y2; + uly = pthis->uly + y2; - gDPLoadTextureTile(gfx++, this->fbufSave, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->widthSave, this->height - 1, - this->ulxSave, ult, this->lrxSave, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPLoadTextureTile(gfx++, pthis->fbufSave, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->widthSave, pthis->height - 1, + pthis->ulxSave, ult, pthis->lrxSave, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(gfx++, this->ulx << 2, uly << 2, this->lrx << 2, (uly + dy - 1) << 2, G_TX_RENDERTILE, - this->ulxSave << 5, ult << 5, 4 << 10, 1 << 10); + gSPTextureRectangle(gfx++, pthis->ulx << 2, uly << 2, pthis->lrx << 2, (uly + dy - 1) << 2, G_TX_RENDERTILE, + pthis->ulxSave << 5, ult << 5, 4 << 10, 1 << 10); y -= dy; y2 += dy; } gDPPipeSync(gfx++); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->fbuf); + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, pthis->width, pthis->height); *gfxp = gfx; } -void func_800C170C(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave, u32 r, u32 g, u32 b, u32 a) { +void func_800C170C(PreRender* pthis, Gfx** gfxp, void* fbuf, void* fbufSave, u32 r, u32 g, u32 b, u32 a) { Gfx* gfx; s32 x; s32 x2; s32 dx; - LogUtils_CheckNullPointer("this", this, "../PreRender.c", 343); + LogUtils_CheckNullPointer("pthis", pthis, "../PreRender.c", 343); LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 344); gfx = *gfxp; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 346); @@ -159,16 +160,16 @@ void func_800C170C(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave, u32 gDPSetEnvColor(gfx++, r, g, b, a); gDPSetCombineLERP(gfx++, 0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1); gDPSetCombineLERP(gfx++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, 1, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, 1); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, fbufSave); - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, fbufSave); + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, pthis->width, pthis->height); - dx = 0x1000 / (this->width * 2); + dx = 0x1000 / (pthis->width * 2); - x = this->height; + x = pthis->height; x2 = 0; while (x > 0) { s32 uls = 0; - s32 lrs = this->width - 1; + s32 lrs = pthis->width - 1; s32 ult; s32 lrt; @@ -176,7 +177,7 @@ void func_800C170C(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave, u32 ult = x2; lrt = x2 + dx - 1; - gDPLoadTextureTile(gfx++, fbuf, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->height, uls, ult, lrs, lrt, 0, + gDPLoadTextureTile(gfx++, fbuf, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->height, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -188,21 +189,21 @@ void func_800C170C(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave, u32 } gDPPipeSync(gfx++); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->fbuf); *gfxp = gfx; } -void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave) { - func_800C170C(this, gfxp, fbuf, fbufSave, 255, 255, 255, 255); +void func_800C1AE8(PreRender* pthis, Gfx** gfxp, void* fbuf, void* fbufSave) { + func_800C170C(pthis, gfxp, fbuf, fbufSave, 255, 255, 255, 255); } -void func_800C1B24(PreRender* this, Gfx** gfxp, void* fbuf, void* cvgSave) { +void func_800C1B24(PreRender* pthis, Gfx** gfxp, void* fbuf, void* cvgSave) { Gfx* gfx; s32 x; s32 x2; s32 dx; - LogUtils_CheckNullPointer("this", this, "../PreRender.c", 422); + LogUtils_CheckNullPointer("pthis", pthis, "../PreRender.c", 422); LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 423); gfx = *gfxp; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 425); @@ -213,16 +214,16 @@ void func_800C1B24(PreRender* this, Gfx** gfxp, void* fbuf, void* cvgSave) { G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_PASS | G_RM_OPA_CI2); gDPSetCombineLERP(gfx++, 0, 0, 0, TEXEL0, 0, 0, 0, 0, 0, 0, 0, TEXEL0, 0, 0, 0, 0); - gDPSetColorImage(gfx++, G_IM_FMT_I, G_IM_SIZ_8b, this->width, cvgSave); - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); + gDPSetColorImage(gfx++, G_IM_FMT_I, G_IM_SIZ_8b, pthis->width, cvgSave); + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, pthis->width, pthis->height); - dx = 0x1000 / (this->width * 2); + dx = 0x1000 / (pthis->width * 2); - x = this->height; + x = pthis->height; x2 = 0; while (x > 0) { s32 uls = 0; - s32 lrs = this->width - 1; + s32 lrs = pthis->width - 1; s32 ult; s32 lrt; @@ -230,7 +231,7 @@ void func_800C1B24(PreRender* this, Gfx** gfxp, void* fbuf, void* cvgSave) { ult = x2; lrt = x2 + dx - 1; - gDPLoadTextureTile(gfx++, fbuf, G_IM_FMT_IA, G_IM_SIZ_16b, this->width, this->height, uls, ult, lrs, lrt, 0, + gDPLoadTextureTile(gfx++, fbuf, G_IM_FMT_IA, G_IM_SIZ_16b, pthis->width, pthis->height, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -241,29 +242,29 @@ void func_800C1B24(PreRender* this, Gfx** gfxp, void* fbuf, void* cvgSave) { } gDPPipeSync(gfx++); - gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, pthis->fbuf); *gfxp = gfx; } -void func_800C1E9C(PreRender* this, Gfx** gfxp) { - LogUtils_CheckNullPointer("this->zbuf_save", this->zbufSave, "../PreRender.c", 481); - LogUtils_CheckNullPointer("this->zbuf", this->zbuf, "../PreRender.c", 482); +void func_800C1E9C(PreRender* pthis, Gfx** gfxp) { + LogUtils_CheckNullPointer("pthis->zbuf_save", pthis->zbufSave, "../PreRender.c", 481); + LogUtils_CheckNullPointer("pthis->zbuf", pthis->zbuf, "../PreRender.c", 482); - if ((this->zbufSave != NULL) && (this->zbuf != NULL)) { - func_800C0F28(this, gfxp, this->zbuf, this->zbufSave); + if ((pthis->zbufSave != NULL) && (pthis->zbuf != NULL)) { + func_800C0F28(pthis, gfxp, pthis->zbuf, pthis->zbufSave); } } -void func_800C1F20(PreRender* this, Gfx** gfxp) { - LogUtils_CheckNullPointer("this->fbuf_save", this->fbufSave, "../PreRender.c", 495); - LogUtils_CheckNullPointer("this->fbuf", this->fbuf, "../PreRender.c", 496); +void func_800C1F20(PreRender* pthis, Gfx** gfxp) { + LogUtils_CheckNullPointer("pthis->fbuf_save", pthis->fbufSave, "../PreRender.c", 495); + LogUtils_CheckNullPointer("pthis->fbuf", pthis->fbuf, "../PreRender.c", 496); - if ((this->fbufSave != NULL) && (this->fbuf != NULL)) { - func_800C1AE8(this, gfxp, this->fbuf, this->fbufSave); + if ((pthis->fbufSave != NULL) && (pthis->fbuf != NULL)) { + func_800C1AE8(pthis, gfxp, pthis->fbuf, pthis->fbufSave); } } -void func_800C1FA4(PreRender* this, Gfx** gfxp) { +void func_800C1FA4(PreRender* pthis, Gfx** gfxp) { Gfx* gfx = *gfxp; gDPPipeSync(gfx++); @@ -273,34 +274,34 @@ void func_800C1FA4(PreRender* this, Gfx** gfxp) { G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_VISCVG | G_RM_VISCVG2); - gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); - gDPFillRectangle(gfx++, 0, 0, this->width, this->height); + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, pthis->width, pthis->height); + gDPFillRectangle(gfx++, 0, 0, pthis->width, pthis->height); gDPPipeSync(gfx++); *gfxp = gfx; } -void func_800C20B4(PreRender* this, Gfx** gfxp) { - func_800C1FA4(this, gfxp); - LogUtils_CheckNullPointer("this->cvg_save", this->cvgSave, "../PreRender.c", 532); - if (this->cvgSave != NULL) { - func_800C1B24(this, gfxp, this->fbuf, this->cvgSave); +void func_800C20B4(PreRender* pthis, Gfx** gfxp) { + func_800C1FA4(pthis, gfxp); + LogUtils_CheckNullPointer("pthis->cvg_save", pthis->cvgSave, "../PreRender.c", 532); + if (pthis->cvgSave != NULL) { + func_800C1B24(pthis, gfxp, pthis->fbuf, pthis->cvgSave); } } -void func_800C2118(PreRender* this, Gfx** gfxp) { - func_800C0F28(this, gfxp, this->zbufSave, this->zbuf); +void func_800C2118(PreRender* pthis, Gfx** gfxp) { + func_800C0F28(pthis, gfxp, pthis->zbufSave, pthis->zbuf); } -void func_800C213C(PreRender* this, Gfx** gfxp) { +void func_800C213C(PreRender* pthis, Gfx** gfxp) { Gfx* gfx; s32 y; s32 y2; s32 dy; s32 rtile = 1; - if (this->cvgSave != NULL) { - LogUtils_CheckNullPointer("this", this, "../PreRender.c", 563); + if (pthis->cvgSave != NULL) { + LogUtils_CheckNullPointer("pthis", pthis, "../PreRender.c", 563); LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 564); gfx = *gfxp; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 566); @@ -317,11 +318,11 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { dy = 4; - y = this->height; + y = pthis->height; y2 = 0; while (y > 0) { s32 uls = 0; - s32 lrs = this->width - 1; + s32 lrs = pthis->width - 1; s32 ult; s32 lrt; @@ -330,11 +331,11 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { ult = y2; lrt = (y2 + dy - 1); - gDPLoadMultiTile(gfx++, this->fbufSave, 0x0000, G_TX_RENDERTILE, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, - this->height, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, + gDPLoadMultiTile(gfx++, pthis->fbufSave, 0x0000, G_TX_RENDERTILE, G_IM_FMT_RGBA, G_IM_SIZ_16b, pthis->width, + pthis->height, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadMultiTile(gfx++, this->cvgSave, 0x0160, rtile, G_IM_FMT_I, G_IM_SIZ_8b, this->width, this->height, + gDPLoadMultiTile(gfx++, pthis->cvgSave, 0x0160, rtile, G_IM_FMT_I, G_IM_SIZ_8b, pthis->width, pthis->height, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -350,15 +351,15 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { } } -void func_800C24BC(PreRender* this, Gfx** gfxp) { - func_800C0F28(this, gfxp, this->fbufSave, this->fbuf); +void func_800C24BC(PreRender* pthis, Gfx** gfxp) { + func_800C0F28(pthis, gfxp, pthis->fbufSave, pthis->fbuf); } -void func_800C24E0(PreRender* this, Gfx** gfxp) { - func_800C1258(this, gfxp); +void func_800C24E0(PreRender* pthis, Gfx** gfxp) { + func_800C1258(pthis, gfxp); } -void func_800C2500(PreRender* this, s32 x, s32 y) { +void func_800C2500(PreRender* pthis, s32 x, s32 y) { s32 i; s32 j; s32 buffA[3 * 5]; @@ -381,7 +382,7 @@ void func_800C2500(PreRender* this, s32 x, s32 y) { u32 pxB3; /* - Picture this as a 3x5 rectangle where the middle pixel (index 7) correspond to (x, y) + Picture pthis as a 3x5 rectangle where the middle pixel (index 7) correspond to (x, y) _ _ _ _ _ | 0 1 2 3 4 | | 5 6 7 8 9 | @@ -394,20 +395,20 @@ void func_800C2500(PreRender* this, s32 x, s32 y) { if (x1 < 0) { x1 = 0; - } else if (x1 > (this->width - 1)) { - x1 = this->width - 1; + } else if (x1 > (pthis->width - 1)) { + x1 = pthis->width - 1; } if (y1 < 0) { y1 = 0; - } else if (y1 > (this->height - 1)) { - y1 = this->height - 1; + } else if (y1 > (pthis->height - 1)) { + y1 = pthis->height - 1; } - pxIn.rgba = this->fbufSave[x1 + y1 * this->width]; + pxIn.rgba = pthis->fbufSave[x1 + y1 * pthis->width]; buffR[i] = (pxIn.r << 3) | (pxIn.r >> 2); buffG[i] = (pxIn.g << 3) | (pxIn.g >> 2); buffB[i] = (pxIn.b << 3) | (pxIn.b >> 2); - buffA[i] = this->cvgSave[x1 + y1 * this->width] >> 5; // A + buffA[i] = pthis->cvgSave[x1 + y1 * pthis->width] >> 5; // A } if (buffA[7] == 7) { @@ -475,34 +476,34 @@ void func_800C2500(PreRender* this, s32 x, s32 y) { pxOut.g = pxG3 >> 3; pxOut.b = pxB3 >> 3; pxOut.a = 1; - this->fbufSave[x + y * this->width] = pxOut.rgba; + pthis->fbufSave[x + y * pthis->width] = pxOut.rgba; } -void func_800C2FE4(PreRender* this) { +void func_800C2FE4(PreRender* pthis) { s32 x; s32 y; s32 phi_v0; - u8* buffR = alloca(this->width); - u8* buffG = alloca(this->width); - u8* buffB = alloca(this->width); + u8* buffR = (u8*)alloca(pthis->width); + u8* buffG = (u8*)alloca(pthis->width); + u8* buffB = (u8*)alloca(pthis->width); s32 pad[3]; s32 pxR; s32 pxG; s32 pxB; - for (y = 0; y < this->height; y++) { - for (x = 0; x < this->width; x++) { + for (y = 0; y < pthis->height; y++) { + for (x = 0; x < pthis->width; x++) { Color_RGBA16 pxIn; - pxIn.rgba = this->fbufSave[x + y * this->width]; + pxIn.rgba = pthis->fbufSave[x + y * pthis->width]; buffR[x] = pxIn.r; buffG[x] = pxIn.g; buffB[x] = pxIn.b; } - for (x = 1; x < this->width - 1; x++) { + for (x = 1; x < pthis->width - 1; x++) { Color_RGBA16 pxOut; - s32 a = this->cvgSave[x + y * this->width]; + s32 a = pthis->cvgSave[x + y * pthis->width]; a >>= 5; if (a == 7) { @@ -543,31 +544,31 @@ void func_800C2FE4(PreRender* this) { pxOut.b = pxB; pxOut.a = 1; } - this->fbufSave[x + y * this->width] = pxOut.rgba; + pthis->fbufSave[x + y * pthis->width] = pxOut.rgba; } } } -void PreRender_Calc(PreRender* this) { +void PreRender_Calc(PreRender* pthis) { s32 x; s32 y; - if ((this->cvgSave != NULL) && (this->fbufSave != NULL)) { + if ((pthis->cvgSave != NULL) && (pthis->fbufSave != NULL)) { - for (y = 0; y < this->height; y++) { - for (x = 0; x < this->width; x++) { - s32 a = this->cvgSave[x + y * this->width]; + for (y = 0; y < pthis->height; y++) { + for (x = 0; x < pthis->width; x++) { + s32 a = pthis->cvgSave[x + y * pthis->width]; a >>= 5; a++; if (a != 8) { - //func_800C2500(this, x, y);//Disabled post processing + //func_800C2500(pthis, x, y);//Disabled post processing } } } if (HREG(80) == 0xF ? HREG(81) : 0) { - func_800C2FE4(this); + func_800C2FE4(pthis); } } } diff --git a/src/code/TwoHeadArena.c b/src/code/TwoHeadArena.cpp similarity index 84% rename from src/code/TwoHeadArena.c rename to src/code/TwoHeadArena.cpp index 7d1039351..f3f3fdcbd 100644 --- a/src/code/TwoHeadArena.c +++ b/src/code/TwoHeadArena.cpp @@ -26,7 +26,7 @@ s32 THGA_GetSize(TwoHeadGfxArena* thga) { } Gfx* THGA_GetHead(TwoHeadGfxArena* thga) { - return THA_GetHead((TwoHeadArena*)thga); + return (Gfx*)THA_GetHead((TwoHeadArena*)thga); } void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start) { @@ -34,11 +34,11 @@ void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start) { } Gfx* THGA_GetTail(TwoHeadGfxArena* thga) { - return THA_GetTail((TwoHeadArena*)thga); + return (Gfx*)THA_GetTail((TwoHeadArena*)thga); } Gfx* THGA_AllocStartArray8(TwoHeadGfxArena* thga, u32 count) { - return THA_AllocStart((TwoHeadArena*)thga, count * 8); + return (Gfx*)THA_AllocStart((TwoHeadArena*)thga, count * 8); } Gfx* THGA_AllocStart8(TwoHeadGfxArena* thga) { @@ -50,7 +50,7 @@ Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) { } Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size) { - return THA_AllocEnd((TwoHeadArena*)thga, size); + return (Gfx*)THA_AllocEnd((TwoHeadArena*)thga, size); } Gfx* THGA_AllocEndArray64(TwoHeadGfxArena* thga, u32 count) { @@ -84,7 +84,7 @@ void* THA_GetTail(TwoHeadArena* tha) { void* THA_AllocStart(TwoHeadArena* tha, u32 size) { void* start = tha->head; - tha->head = POINTER_ADD(tha->head, size); + tha->head = (void*)POINTER_ADD(tha->head, size); return start; } @@ -105,7 +105,7 @@ void* THA_AllocEnd(TwoHeadArena* tha, u32 size) { mask = (size >= 0x10) ? ~0xF : 0; } - tha->tail = (((uintptr_t)tha->tail & mask) - size) & mask; + tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask); return tha->tail; } @@ -118,12 +118,12 @@ void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size) { uintptr_t b = a - size; uintptr_t c = b & mask; - tha->tail = (((uintptr_t)tha->tail & mask) - size) & (u64)mask; + tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & (u64)mask); return tha->tail; } void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, uintptr_t mask) { - tha->tail = (((uintptr_t)tha->tail & mask) - size) & mask; + tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask); return tha->tail; } @@ -137,7 +137,7 @@ u32 THA_IsCrash(TwoHeadArena* tha) { void THA_Init(TwoHeadArena* tha) { tha->head = tha->bufp; - tha->tail = POINTER_ADD(tha->bufp, tha->size); + tha->tail = (void*)POINTER_ADD(tha->bufp, tha->size); } void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size) { diff --git a/src/code/__osMalloc.c b/src/code/__osMalloc.c deleted file mode 100644 index 81111d6e1..000000000 --- a/src/code/__osMalloc.c +++ /dev/null @@ -1,830 +0,0 @@ -#define INTERNAL_SRC_CODE_OSMALLOC_C -#ifndef USE_NATIVE_MALLOC -#include "global.h" -#include "vt.h" -#include "def/__osMalloc.h" -#include "def/code_80106860.h" -#include "def/code_801068B0.h" -#include "def/createmesgqueue.h" -#include "def/fault_drawer.h" -#include "def/getthreadid.h" -#include "def/gettime.h" -#include "def/recvmesg.h" -#include "def/xprintf.h" - -#define FILL_ALLOCBLOCK (1 << 0) -#define FILL_FREEBLOCK (1 << 1) -#define CHECK_FREE_BLOCK (1 << 2) - -#define NODE_MAGIC (0x7373) - -#define BLOCK_UNINIT_MAGIC (0xAB) -#define BLOCK_UNINIT_MAGIC_32 (0xABABABAB) -#define BLOCK_ALLOC_MAGIC (0xCD) -#define BLOCK_ALLOC_MAGIC_32 (0xCDCDCDCD) -#define BLOCK_FREE_MAGIC (0xEF) -#define BLOCK_FREE_MAGIC_32 (0xEFEFEFEF) - -OSMesg sArenaLockMsg; -u32 __osMalloc_FreeBlockTest_Enable; - -u32 ArenaImpl_GetFillAllocBlock(Arena* arena) { - return (arena->flag & FILL_ALLOCBLOCK) != 0; -} -u32 ArenaImpl_GetFillFreeBlock(Arena* arena) { - return (arena->flag & FILL_FREEBLOCK) != 0; -} -u32 ArenaImpl_GetCheckFreeBlock(Arena* arena) { - return (arena->flag & CHECK_FREE_BLOCK) != 0; -} - -void ArenaImpl_SetFillAllocBlock(Arena* arena) { - arena->flag |= FILL_ALLOCBLOCK; -} -void ArenaImpl_SetFillFreeBlock(Arena* arena) { - arena->flag |= FILL_FREEBLOCK; -} -void ArenaImpl_SetCheckFreeBlock(Arena* arena) { - arena->flag |= CHECK_FREE_BLOCK; -} - -void ArenaImpl_UnsetFillAllocBlock(Arena* arena) { - arena->flag &= ~FILL_ALLOCBLOCK; -} -void ArenaImpl_UnsetFillFreeBlock(Arena* arena) { - arena->flag &= ~FILL_FREEBLOCK; -} -void ArenaImpl_UnsetCheckFreeBlock(Arena* arena) { - arena->flag &= ~CHECK_FREE_BLOCK; -} - -void ArenaImpl_SetDebugInfo(ArenaNode* node, const char* file, s32 line, Arena* arena) { - node->filename = file; - node->line = line; - node->threadId = osGetThreadId(NULL); - node->arena = arena; - node->time = osGetTime(); -} - -void ArenaImpl_LockInit(Arena* arena) { - osCreateMesgQueue(&arena->lock, &sArenaLockMsg, 1); -} - -void ArenaImpl_Lock(Arena* arena) { - osSendMesg(&arena->lock, NULL, OS_MESG_BLOCK); -} - -void ArenaImpl_Unlock(Arena* arena) { - osRecvMesg(&arena->lock, NULL, OS_MESG_BLOCK); -} - -ArenaNode* ArenaImpl_GetNextBlock(ArenaNode* node) { - ArenaNode* next = node->next; - - if (next != NULL && (next == NULL || (next->magic != NODE_MAGIC))) { - osSyncPrintf(VT_COL(RED, WHITE) "Emergency! Memory leak detected! (block=%08x)\n" VT_RST, next); - next = NULL; - node->next = NULL; - } - return next; -} - -ArenaNode* ArenaImpl_GetPrevBlock(ArenaNode* node) { - ArenaNode* prev = node->prev; - - if (prev != NULL && (prev == NULL || (prev->magic != NODE_MAGIC))) { - osSyncPrintf(VT_COL(RED, WHITE) "Emergency! Memory leak detected! (block=%08x)\n" VT_RST, prev); - prev = NULL; - node->prev = NULL; - } - return prev; -} - -ArenaNode* ArenaImpl_GetLastBlock(Arena* arena) { - ArenaNode* last = NULL; - ArenaNode* iter; - - if (arena != NULL && arena->head != NULL && arena->head->magic == NODE_MAGIC) { - iter = arena->head; - while (iter != NULL) { - last = iter; - iter = ArenaImpl_GetNextBlock(iter); - } - } - return last; -} - -void __osMallocInit(Arena* arena, void* start, u32 size) { - bzero(arena, sizeof(Arena)); - ArenaImpl_LockInit(arena); - __osMallocAddBlock(arena, start, size); - arena->isInit = true; -} - -void __osMallocAddBlock(Arena* arena, void* start, s32 size) { - intptr_t diff; - intptr_t size2; - ArenaNode* firstNode; - ArenaNode* lastNode; - - if (start != NULL) { - firstNode = (ArenaNode*)ALIGN16((uintptr_t)start); - diff = POINTER_SUB(firstNode, start); - size2 = (size - diff) & ~0xF; - - if (size2 > (s32)sizeof(ArenaNode)) { - z_memset(firstNode, BLOCK_UNINIT_MAGIC, size2); // memset - firstNode->next = NULL; - firstNode->prev = NULL; - firstNode->size = size2 - sizeof(ArenaNode); - firstNode->isFree = true; - firstNode->magic = NODE_MAGIC; - ArenaImpl_Lock(arena); - lastNode = ArenaImpl_GetLastBlock(arena); - if (lastNode == NULL) { - arena->head = firstNode; - arena->start = start; - } else { - firstNode->prev = lastNode; - lastNode->next = firstNode; - } - ArenaImpl_Unlock(arena); - } - } -} - -void ArenaImpl_RemoveAllBlocks(Arena* arena) { - ArenaNode* iter; - ArenaNode* next; - - ArenaImpl_Lock(arena); - - iter = arena->head; - while (iter != NULL) { - next = ArenaImpl_GetNextBlock(iter); - z_memset(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); // memset - iter = next; - } - - ArenaImpl_Unlock(arena); -} - -void __osMallocCleanup(Arena* arena) { - ArenaImpl_RemoveAllBlocks(arena); - bzero(arena, sizeof(*arena)); -} - -u8 __osMallocIsInitalized(Arena* arena) { - return arena->isInit; -} - -void __osMalloc_FreeBlockTest(Arena* arena, ArenaNode* node) { - ArenaNode* node2 = node; - u32* start; - u32* end; - u32* iter; - - if (__osMalloc_FreeBlockTest_Enable) { - start = (u32*)((uintptr_t)node + sizeof(ArenaNode)); - end = (u32*)((uintptr_t)start + node2->size); - iter = start; - - while (iter < end) { - if (*iter != BLOCK_UNINIT_MAGIC_32 && *iter != BLOCK_FREE_MAGIC_32) { - osSyncPrintf( - VT_COL(RED, WHITE) "Emergency! Memory leak detected! (block=%08x s=%08x e=%08x p=%08x)\n" VT_RST, node, - start, end, iter); - __osDisplayArena(arena); - return; - } - iter++; - } - } -} - -void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line) { - ArenaNode* iter; - u32 blockSize; - ArenaNode* newNode; - void* alloc = NULL; - ArenaNode* next; - - iter = arena->head; - size = ALIGN16(size); - blockSize = ALIGN16(size) + sizeof(ArenaNode); - - while (iter != NULL) { - if (iter->isFree && iter->size >= size) { - if (arena->flag & CHECK_FREE_BLOCK) { - __osMalloc_FreeBlockTest(arena, iter); - } - - if (blockSize < iter->size) { - newNode = (ArenaNode*)((uintptr_t)iter + blockSize); - newNode->next = ArenaImpl_GetNextBlock(iter); - newNode->prev = iter; - newNode->size = iter->size - blockSize; - newNode->isFree = true; - newNode->magic = NODE_MAGIC; - - iter->next = newNode; - iter->size = size; - next = ArenaImpl_GetNextBlock(newNode); - if (next) { - next->prev = newNode; - } - } - - iter->isFree = false; - ArenaImpl_SetDebugInfo(iter, file, line, arena); - alloc = (void*)((uintptr_t)iter + sizeof(ArenaNode)); - if (arena->flag & FILL_ALLOCBLOCK) { - z_memset(alloc, BLOCK_ALLOC_MAGIC, size); - } - - break; - } - - iter = ArenaImpl_GetNextBlock(iter); - } - - return alloc; -} - -void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line) { - void* alloc; - - ArenaImpl_Lock(arena); - alloc = __osMalloc_NoLockDebug(arena, size, file, line); - ArenaImpl_Unlock(arena); - - return alloc; -} - -void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) { - ArenaNode* iter; - ArenaNode* newNode; - u32 blockSize; - ArenaNode* next; - void* allocR = NULL; - - size = ALIGN16(size); - ArenaImpl_Lock(arena); - iter = ArenaImpl_GetLastBlock(arena); - - while (iter != NULL) { - if (iter->isFree && iter->size >= size) { - if (arena->flag & CHECK_FREE_BLOCK) { - __osMalloc_FreeBlockTest(arena, iter); - } - - blockSize = ALIGN16(size) + sizeof(ArenaNode); - if (blockSize < iter->size) { - newNode = (ArenaNode*)((uintptr_t)iter + (iter->size - size)); - newNode->next = ArenaImpl_GetNextBlock(iter); - newNode->prev = iter; - newNode->size = size; - newNode->magic = NODE_MAGIC; - - iter->next = newNode; - iter->size -= blockSize; - next = ArenaImpl_GetNextBlock(newNode); - if (next) { - next->prev = newNode; - } - iter = newNode; - } - - iter->isFree = false; - ArenaImpl_SetDebugInfo(iter, file, line, arena); - allocR = (void*)((u32)iter + sizeof(ArenaNode)); - if (arena->flag & FILL_ALLOCBLOCK) { - z_memset(allocR, BLOCK_ALLOC_MAGIC, size); - } - - break; - } - - iter = ArenaImpl_GetPrevBlock(iter); - } - ArenaImpl_Unlock(arena); - - return allocR; -} - -void* __osMalloc_NoLock(Arena* arena, u32 size) { - ArenaNode* iter; - u32 blockSize; - ArenaNode* newNode; - void* alloc = NULL; - ArenaNode* next; - - iter = arena->head; - size = ALIGN16(size); - blockSize = ALIGN16(size) + sizeof(ArenaNode); - - while (iter != NULL) { - - if (iter->isFree && iter->size >= size) { - if (arena->flag & CHECK_FREE_BLOCK) { - __osMalloc_FreeBlockTest(arena, iter); - } - - if (blockSize < iter->size) { - newNode = (ArenaNode*)((uintptr_t)iter + blockSize); - newNode->next = ArenaImpl_GetNextBlock(iter); - newNode->prev = iter; - newNode->size = iter->size - blockSize; - newNode->isFree = true; - newNode->magic = NODE_MAGIC; - - iter->next = newNode; - iter->size = size; - next = ArenaImpl_GetNextBlock(newNode); - if (next) { - next->prev = newNode; - } - } - - iter->isFree = false; - ArenaImpl_SetDebugInfo(iter, NULL, 0, arena); - alloc = (void*)((uintptr_t)iter + sizeof(ArenaNode)); - if (arena->flag & FILL_ALLOCBLOCK) { - z_memset(alloc, BLOCK_ALLOC_MAGIC, size); - } - break; - } - - iter = ArenaImpl_GetNextBlock(iter); - } - - return alloc; -} - -void* __osMalloc(Arena* arena, u32 size) { - void* alloc; - - ArenaImpl_Lock(arena); - alloc = __osMalloc_NoLock(arena, size); - ArenaImpl_Unlock(arena); - - return alloc; -} - -void* __osMallocR(Arena* arena, u32 size) { - ArenaNode* iter; - ArenaNode* newNode; - u32 blockSize; - ArenaNode* next; - void* alloc = NULL; - - size = ALIGN16(size); - ArenaImpl_Lock(arena); - iter = ArenaImpl_GetLastBlock(arena); - - while (iter != NULL) { - if (iter->isFree && iter->size >= size) { - if (arena->flag & CHECK_FREE_BLOCK) { - __osMalloc_FreeBlockTest(arena, iter); - } - - blockSize = ALIGN16(size) + sizeof(ArenaNode); - if (blockSize < iter->size) { - newNode = (ArenaNode*)((uintptr_t)iter + (iter->size - size)); - newNode->next = ArenaImpl_GetNextBlock(iter); - newNode->prev = iter; - newNode->size = size; - newNode->magic = NODE_MAGIC; - - iter->next = newNode; - iter->size -= blockSize; - next = ArenaImpl_GetNextBlock(newNode); - if (next) { - next->prev = newNode; - } - iter = newNode; - } - - iter->isFree = false; - ArenaImpl_SetDebugInfo(iter, NULL, 0, arena); - alloc = (void*)((uintptr_t)iter + sizeof(ArenaNode)); - if (arena->flag & FILL_ALLOCBLOCK) { - z_memset(alloc, BLOCK_ALLOC_MAGIC, size); - } - break; - } - iter = ArenaImpl_GetPrevBlock(iter); - } - ArenaImpl_Unlock(arena); - - return alloc; -} - -void __osFree_NoLock(Arena* arena, void* ptr) { - ArenaNode* node; - ArenaNode* next; - ArenaNode* prev; - ArenaNode* newNext; - - if (ptr == NULL) { - return; - } - - node = (ArenaNode*)((uintptr_t)ptr - sizeof(ArenaNode)); - if (node == NULL || node->magic != NODE_MAGIC) { - // "__osFree: Unauthorized release (%08x)" - osSyncPrintf(VT_COL(RED, WHITE) "__osFree: Unauthorized release (%08x)\n" VT_RST, ptr); - return; - } - if (node->isFree) { - osSyncPrintf(VT_COL(RED, WHITE) "__osFree: Double release (%08x)\n" VT_RST, ptr); // "__osFree: Double release (%08x)" - return; - } - if (arena != node->arena && arena != NULL) { - // "__osFree:Tried to release in a different way than when it was secured (%08x:%08x)" - osSyncPrintf(VT_COL(RED, WHITE) "__osFree:Tried to release in a different way than when it was secured (%08x:%08x)\n" VT_RST, arena, - node->arena); - return; - } - - next = ArenaImpl_GetNextBlock(node); - prev = ArenaImpl_GetPrevBlock(node); - node->isFree = true; - ArenaImpl_SetDebugInfo(node, NULL, 0, arena); - - if (arena->flag & FILL_FREEBLOCK) { - z_memset((uintptr_t)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size); - } - - newNext = next; - if ((uintptr_t)next == (uintptr_t)node + sizeof(ArenaNode) + node->size && next->isFree) { - newNext = ArenaImpl_GetNextBlock(next); - if (newNext != NULL) { - newNext->prev = node; - } - - node->size += next->size + sizeof(ArenaNode); - if (arena->flag & FILL_FREEBLOCK) { - z_memset(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode)); - } - node->next = newNext; - next = newNext; - } - - if (prev != NULL && prev->isFree && (uintptr_t)node == (uintptr_t)prev + sizeof(ArenaNode) + prev->size) { - if (next) { - next->prev = prev; - } - prev->next = next; - prev->size += node->size + sizeof(ArenaNode); - if (arena->flag & FILL_FREEBLOCK) { - z_memset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode)); - } - } -} - -void __osFree(Arena* arena, void* ptr) { - ArenaImpl_Lock(arena); - __osFree_NoLock(arena, ptr); - ArenaImpl_Unlock(arena); -} - -void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) { - ArenaNode* node; - ArenaNode* next; - ArenaNode* prev; - ArenaNode* newNext; - - if (ptr == NULL) { - return; - } - - node = (ArenaNode*)((uintptr_t)ptr - sizeof(ArenaNode)); - if (node == NULL || node->magic != NODE_MAGIC) { - // "__osFree: Unauthorized release (%08x)" - osSyncPrintf(VT_COL(RED, WHITE) "__osFree: Unauthorized release (%08x) [%s:%d ]\n" VT_RST, ptr, file, line); - return; - } - if (node->isFree) { - // "__osFree: Double release (%08x)" - osSyncPrintf(VT_COL(RED, WHITE) "__osFree: Double release (%08x) [%s:%d ]\n" VT_RST, ptr, file, line); - return; - } - if (arena != node->arena && arena != NULL) { - // "__osFree:Tried to release in a different way than when it was secured (%08x:%08x)" - osSyncPrintf(VT_COL(RED, WHITE) "__osFree:Tried to release in a different way than when it was secured (%08x:%08x)\n" VT_RST, arena, - node->arena); - return; - } - - next = ArenaImpl_GetNextBlock(node); - prev = ArenaImpl_GetPrevBlock(node); - node->isFree = true; - ArenaImpl_SetDebugInfo(node, file, line, arena); - - if (arena->flag & FILL_FREEBLOCK) { - z_memset((uintptr_t)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size); - } - - newNext = node->next; - if ((uintptr_t)next == (uintptr_t)node + sizeof(ArenaNode) + node->size && next->isFree) { - newNext = ArenaImpl_GetNextBlock(next); - if (newNext != NULL) { - newNext->prev = node; - } - - node->size += next->size + sizeof(ArenaNode); - if (arena->flag & FILL_FREEBLOCK) { - z_memset(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode)); - } - node->next = newNext; - next = newNext; - } - - if (prev != NULL && prev->isFree && (uintptr_t)node == (uintptr_t)prev + sizeof(ArenaNode) + prev->size) { - if (next != NULL) { - next->prev = prev; - } - prev->next = next; - prev->size += node->size + sizeof(ArenaNode); - if (arena->flag & FILL_FREEBLOCK) { - z_memset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode)); - } - } -} - -void __osFreeDebug(Arena* arena, void* ptr, const char* file, s32 line) { - ArenaImpl_Lock(arena); - __osFree_NoLockDebug(arena, ptr, file, line); - ArenaImpl_Unlock(arena); -} - -void* __osRealloc(Arena* arena, void* ptr, u32 newSize) { - void* newAlloc; - ArenaNode* node; - ArenaNode* next; - ArenaNode* newNext; - ArenaNode* overNext; - ArenaNode* newNext2; - ArenaNode* next2; - uintptr_t sizeDiff; - ArenaNode* overNext2; - ArenaNode localCopy; - u32 blockSize; - s32 pad; - - newSize = ALIGN16(newSize); - osSyncPrintf("__osRealloc(%08x, %d)\n", ptr, newSize); - ArenaImpl_Lock(arena); - - if (ptr == NULL) { - ptr = __osMalloc_NoLock(arena, newSize); - } else if (newSize == 0) { - __osFree_NoLock(arena, ptr); - ptr = NULL; - } else { - node = (ArenaNode*)((uintptr_t)ptr - sizeof(ArenaNode)); - if (newSize == node->size) { - // "Does nothing because the memory block size does not change" - osSyncPrintf("Does nothing because the memory block size does not change\n"); - } else if (node->size < newSize) { - next = ArenaImpl_GetNextBlock(node); - sizeDiff = newSize - node->size; - if ((uintptr_t)next == ((uintptr_t)node + node->size + sizeof(ArenaNode)) && next->isFree && next->size >= sizeDiff) { - // "Merge because there is a free block after the current memory block" - osSyncPrintf("Merge because there is a free block after the current memory block\n"); - next->size -= sizeDiff; - overNext = ArenaImpl_GetNextBlock(next); - newNext = (ArenaNode*)((uintptr_t)next + sizeDiff); - if (overNext != NULL) { - overNext->prev = newNext; - } - node->next = newNext; - node->size = newSize; - func_801068B0(newNext, next, sizeof(ArenaNode)); // memcpy - } else { - // "Allocate a new memory block and move the contents" - osSyncPrintf("Allocate a new memory block and move the contents\n"); - newAlloc = __osMalloc_NoLock(arena, newSize); - if (newAlloc != NULL) { - bcopy(ptr, newAlloc, node->size); - __osFree_NoLock(arena, ptr); - } - ptr = newAlloc; - } - } else if (newSize < node->size) { - next2 = ArenaImpl_GetNextBlock(node); - if (next2 != NULL && next2->isFree) { - blockSize = ALIGN16(newSize) + sizeof(ArenaNode); - // "Increased free block behind current memory block" - osSyncPrintf("Increased free block behind current memory block\n"); - newNext2 = (ArenaNode*)((uintptr_t)node + blockSize); - localCopy = *next2; - *newNext2 = localCopy; - newNext2->size += node->size - newSize; - node->next = newNext2; - node->size = newSize; - overNext2 = ArenaImpl_GetNextBlock(newNext2); - if (overNext2 != NULL) { - overNext2->prev = newNext2; - } - } else if (newSize + sizeof(ArenaNode) < node->size) { - blockSize = ALIGN16(newSize) + sizeof(ArenaNode); - // "Generated because there is no free block after the current memory block" - osSyncPrintf("Generated because there is no free block after the current memory block\n"); - newNext2 = (ArenaNode*)((uintptr_t)node + blockSize); - newNext2->next = ArenaImpl_GetNextBlock(node); - newNext2->prev = node; - newNext2->size = node->size - blockSize; - newNext2->isFree = true; - newNext2->magic = NODE_MAGIC; - node->next = newNext2; - node->size = newSize; - overNext2 = ArenaImpl_GetNextBlock(newNext2); - if (overNext2 != NULL) { - overNext2->prev = newNext2; - } - } else { - // "There is no room to generate free blocks" - osSyncPrintf("There is no room to generate free blocks\n"); - ptr = NULL; - } - } - } - ArenaImpl_Unlock(arena); - - return ptr; -} - -void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, s32 line) { - return __osRealloc(arena, ptr, newSize); -} - -void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAlloc) { - ArenaNode* iter; - - ArenaImpl_Lock(arena); - - *outMaxFree = 0; - *outFree = 0; - *outAlloc = 0; - - iter = arena->head; - while (iter != NULL) { - if (iter->isFree) { - *outFree += iter->size; - if (*outMaxFree < iter->size) { - *outMaxFree = iter->size; - } - } else { - *outAlloc += iter->size; - } - - iter = ArenaImpl_GetNextBlock(iter); - } - - ArenaImpl_Unlock(arena); -} - -void __osDisplayArena(Arena* arena) { - size_t freeSize; - size_t allocatedSize; - size_t maxFree; - ArenaNode* iter; - ArenaNode* next; - - if (!__osMallocIsInitalized(arena)) { - osSyncPrintf("Arena is not initalized\n"); // "Arena is not initalized" - return; - } - - ArenaImpl_Lock(arena); - - maxFree = 0; - freeSize = 0; - allocatedSize = 0; - - osSyncPrintf("Arena contents (0x%08x)\n", arena); // "Arena contents (0x%08x)" - // "Memory node range status size [time s ms us ns: TID: src: line]" - osSyncPrintf("Memory node range status size [time s ms us ns: TID: src: line\n"); - - iter = arena->head; - while (iter != NULL) { - if (iter != NULL && iter->magic == NODE_MAGIC) { - next = iter->next; - osSyncPrintf("%08x-%08x%c %s %08x", iter, ((uintptr_t)iter + sizeof(ArenaNode) + iter->size), - (next == NULL) ? '$' : (iter != next->prev ? '!' : ' '), - iter->isFree ? "Free" : "Secure", //? "Free" : "Secure" - iter->size); - - if (!iter->isFree) { - osSyncPrintf(" [%016llu:%2d:%s:%d]", OS_CYCLES_TO_NSEC(iter->time), iter->threadId, - iter->filename != NULL ? iter->filename : "**NULL**", iter->line); - } - - osSyncPrintf("\n"); - - if (iter->isFree) { - freeSize += iter->size; - if (maxFree < iter->size) { - maxFree = iter->size; - } - } else { - allocatedSize += iter->size; - } - } else { - osSyncPrintf("%08x Block Invalid\n", iter); - next = NULL; - } - iter = next; - } - - // "Total reserved node size 0x%08x bytes" - osSyncPrintf("Total reserved node size 0x%08x bytes\n", allocatedSize); - // "Total free node size 0x%08x bytes" - osSyncPrintf("Total free node size 0x%08x bytes\n", freeSize); - // "Maximum free node size 0x%08x bytes" - osSyncPrintf("Maximum free node size 0x%08x bytes\n", maxFree); - - ArenaImpl_Unlock(arena); -} - -void ArenaImpl_FaultClient(Arena* arena) { - size_t freeSize; - size_t allocatedSize; - size_t maxFree; - ArenaNode* iter; - ArenaNode* next; - - FaultDrawer_Printf("ARENA INFO (0x%08x)\n", arena); - if (!__osMallocIsInitalized(arena)) { - FaultDrawer_Printf("Arena is uninitalized\n", arena); - return; - } - - maxFree = 0; - freeSize = 0; - allocatedSize = 0; - - FaultDrawer_Printf("Memory Block Region status size\n"); - - iter = arena->head; - while (iter != NULL) { - if (iter != NULL && iter->magic == NODE_MAGIC) { - next = iter->next; - FaultDrawer_Printf("%08x-%08x%c %s %08x", iter, ((uintptr_t)iter + sizeof(ArenaNode) + iter->size), - (!next) ? '$' : (iter != next->prev ? '!' : ' '), iter->isFree ? "F" : "A", iter->size); - - FaultDrawer_Printf("\n"); - - if (iter->isFree) { - freeSize += iter->size; - if (maxFree < iter->size) { - maxFree = iter->size; - } - } else { - allocatedSize += iter->size; - } - } else { - FaultDrawer_SetFontColor(0xF801); - FaultDrawer_Printf("%08x Block Invalid\n", iter); - next = NULL; - } - iter = next; - } - - FaultDrawer_SetFontColor(0x7F1); - FaultDrawer_Printf("Total Alloc Block Size %08x\n", allocatedSize); - FaultDrawer_Printf("Total Free Block Size %08x\n", freeSize); - FaultDrawer_Printf("Largest Free Block Size %08x\n", maxFree); -} - -u32 __osCheckArena(Arena* arena) { - ArenaNode* iter; - u32 error = 0; - - ArenaImpl_Lock(arena); - // "Checking the contents of the arena. . . (%08x)" - osSyncPrintf("Checking the contents of the arena. . . (%08x)\n", arena); - iter = arena->head; - while (iter != NULL) { - if (iter && iter->magic == NODE_MAGIC) { - // "Oops!! (%08x %08x)" - osSyncPrintf(VT_COL(RED, WHITE) "Oops!! (%08x %08x)\n" VT_RST, iter, iter->magic); - error = 1; - break; - } - iter = ArenaImpl_GetNextBlock(iter); - } - if (error == 0) { - osSyncPrintf("The arena is still going well\n"); // "The arena is still going well" - } - ArenaImpl_Unlock(arena); - - return error; -} - -u8 func_800FF334(Arena* arena) { - return arena->unk_20; -} -#endif \ No newline at end of file diff --git a/src/code/audioMgr.c b/src/code/audioMgr.cpp similarity index 100% rename from src/code/audioMgr.c rename to src/code/audioMgr.cpp diff --git a/src/code/audio_data.c b/src/code/audio_data.cpp similarity index 100% rename from src/code/audio_data.c rename to src/code/audio_data.cpp diff --git a/src/code/audio_effects.c b/src/code/audio_effects.cpp similarity index 100% rename from src/code/audio_effects.c rename to src/code/audio_effects.cpp diff --git a/src/code/audio_heap.c b/src/code/audio_heap.cpp similarity index 96% rename from src/code/audio_heap.c rename to src/code/audio_heap.cpp index 49d5157bb..313987403 100644 --- a/src/code/audio_heap.c +++ b/src/code/audio_heap.cpp @@ -166,7 +166,7 @@ void* AudioHeap_AllocDmaMemoryZeroed(AudioAllocPool* pool, u32 size) { } void* AudioHeap_AllocZeroed(AudioAllocPool* pool, u32 size) { - u8* ret = AudioHeap_Alloc(pool, size); + u8* ret = (u8*)AudioHeap_Alloc(pool, size); u8* ptr; if (ret != NULL) { @@ -253,7 +253,7 @@ void AudioHeap_PopCache(s32 tableType) { } entryPtr = persistent->entries[persistent->numEntries - 1].ptr; - persistentPool->cur = entryPtr; + persistentPool->cur = (u8*)entryPtr; persistentPool->count--; if (tableType == SAMPLE_TABLE) { @@ -552,7 +552,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) { } mem = AudioHeap_Alloc(&loadedPool->persistent.pool, size); - loadedPool->persistent.entries[loadedPool->persistent.numEntries].ptr = mem; + loadedPool->persistent.entries[loadedPool->persistent.numEntries].ptr = (u8*)mem; if (mem == NULL) { switch (cache) { @@ -902,20 +902,17 @@ void AudioHeap_Init(void) { AudioHeap_TemporaryCachesInit(&gAudioContext.temporaryCommonPoolSplit); AudioHeap_ResetLoadStatus(); - gAudioContext.notes = - AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, gAudioContext.numNotes * sizeof(Note)); + gAudioContext.notes = (Note*)AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, gAudioContext.numNotes * sizeof(Note)); Audio_NoteInitAll(); Audio_InitNoteFreeList(); - gAudioContext.noteSubsEu = - AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, gAudioContext.audioBufferParameters.updatesPerFrame * - gAudioContext.numNotes * sizeof(NoteSubEu)); + gAudioContext.noteSubsEu = (NoteSubEu*)AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, gAudioContext.audioBufferParameters.updatesPerFrame * gAudioContext.numNotes * sizeof(NoteSubEu)); for (i = 0; i != 2; i++) { - gAudioContext.abiCmdBufs[i] = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, + gAudioContext.abiCmdBufs[i] = (Acmd*)AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, gAudioContext.maxAudioCmds * sizeof(u64)); } - gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.notesAndBuffersPool, 0x100 * sizeof(f32)); + gAudioContext.unk_3520 = (f32*)AudioHeap_Alloc(&gAudioContext.notesAndBuffersPool, 0x100 * sizeof(f32)); func_800DDE3C(); for (i = 0; i < 4; i++) { gAudioContext.synthesisReverbs[i].useReverb = 0; @@ -939,9 +936,9 @@ void AudioHeap_Init(void) { reverb->unk_08 = settings->unk_12; reverb->useReverb = 8; reverb->leftRingBuf = - AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, reverb->windowSize * sizeof(s16)); + (s16*)AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, reverb->windowSize * sizeof(s16)); reverb->rightRingBuf = - AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, reverb->windowSize * sizeof(s16)); + (s16*)AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, reverb->windowSize * sizeof(s16)); reverb->nextRingBufPos = 0; reverb->unk_20 = 0; reverb->curFrame = 0; @@ -966,26 +963,26 @@ void AudioHeap_Init(void) { reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, 0x20); reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, 0x20); for (j = 0; j < gAudioContext.audioBufferParameters.updatesPerFrame; j++) { - mem = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, 0x340); + mem = (s16*)AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, 0x340); reverb->items[0][j].toDownsampleLeft = mem; reverb->items[0][j].toDownsampleRight = mem + 0x1A0 / sizeof(s16); - mem = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, 0x340); + mem = (s16*)AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.notesAndBuffersPool, 0x340); reverb->items[1][j].toDownsampleLeft = mem; reverb->items[1][j].toDownsampleRight = mem + 0x1A0 / sizeof(s16); } } if (settings->lowPassFilterCutoffLeft != 0) { - reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40); - reverb->filterLeft = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16)); + reverb->filterLeftState = (s16*)AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40); + reverb->filterLeft = (s16*)AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16)); AudioHeap_LoadLowPassFilter(reverb->filterLeft, settings->lowPassFilterCutoffLeft); } else { reverb->filterLeft = NULL; } if (settings->lowPassFilterCutoffRight != 0) { - reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40); - reverb->filterRight = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16)); + reverb->filterRightState = (s16*)AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.notesAndBuffersPool, 0x40); + reverb->filterRight = (s16*)AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 8 * sizeof(s16)); AudioHeap_LoadLowPassFilter(reverb->filterRight, settings->lowPassFilterCutoffRight); } else { reverb->filterRight = NULL; @@ -1026,7 +1023,7 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size) { index = gAudioContext.permanentPool.count; ret = AudioHeap_Alloc(&gAudioContext.permanentPool, size); - gAudioContext.permanentCache[index].ptr = ret; + gAudioContext.permanentCache[index].ptr = (u8*)ret; if (ret == NULL) { return NULL; } @@ -1153,7 +1150,7 @@ SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(u32 size) { ret = &pool->entries[index]; ret->inUse = true; - ret->allocatedAddr = mem; + ret->allocatedAddr = (u8*)mem; ret->size = size; return ret; } @@ -1218,7 +1215,7 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { if (sample != NULL) { if (sample->sampleAddr == entry->allocatedAddr) { - sample->sampleAddr = entry->sampleAddr; + sample->sampleAddr = (u8*)entry->sampleAddr; sample->medium = entry->origMedium; } } @@ -1236,7 +1233,7 @@ SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(u32 size) { } entry = &pool->entries[pool->size]; entry->inUse = true; - entry->allocatedAddr = mem; + entry->allocatedAddr = (u8*)mem; entry->size = size; pool->size++; return entry; @@ -1280,9 +1277,9 @@ void AudioHeap_DiscardSampleCaches(void) { } typedef struct { - u32 oldAddr; - u32 newAddr; - u32 size; + uintptr_t oldAddr; + uintptr_t newAddr; + size_t size; u8 newMedium; } StorageChange; @@ -1327,7 +1324,7 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { sampleBankTable = gAudioContext.sampleBankTable; numFonts = gAudioContext.soundFontTable->numEntries; - change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); + change.oldAddr = (uintptr_t)AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); if (change.oldAddr == 0) { return; } diff --git a/src/code/audio_init_params.c b/src/code/audio_init_params.cpp similarity index 98% rename from src/code/audio_init_params.c rename to src/code/audio_init_params.cpp index 5834d194f..2030aaa9c 100644 --- a/src/code/audio_init_params.c +++ b/src/code/audio_init_params.cpp @@ -4,8 +4,8 @@ #include "def/audio_init_params.h" u8 D_8016F0E0[0xA0]; // unused -AudioContext gAudioContext; -void (*D_801755D0)(void); +extern AudioContext gAudioContext; +void (*D_801755D0)(void) = NULL; s32 D_801755D8[3]; // unused const s16 D_8014A6C0[] = { diff --git a/src/code/audio_load.c b/src/code/audio_load.cpp similarity index 91% rename from src/code/audio_load.c rename to src/code/audio_load.cpp index 12e96c04e..7d9c913a0 100644 --- a/src/code/audio_load.c +++ b/src/code/audio_load.cpp @@ -65,9 +65,9 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate); u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId); void* AudioLoad_SearchCaches(s32 tableType, s32 id); AudioTable* AudioLoad_GetLoadTable(s32 tableType); -void AudioLoad_SyncDma(u32 devAddr, u8* addr, u32 size, s32 medium); -void AudioLoad_SyncDmaUnkMedium(u32 devAddr, u8* addr, u32 size, s32 unkMediumParam); -s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void* ramAddr, u32 size, +void AudioLoad_SyncDma(Pointer devAddr, Pointer addr, size_t size, s32 medium); +void AudioLoad_SyncDmaUnkMedium(Pointer devAddr, Pointer addr, size_t size, s32 unkMediumParam); +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, Pointer devAddr, Pointer ramAddr, size_t size, OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue); AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAddr, void* ramAddr, s32 size, s32 medium, @@ -80,7 +80,7 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId); s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, s32 size); void AudioLoad_ProcessSlowLoads(s32 resetStatus); -void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, s32 size, s32 arg3); +void AudioLoad_DmaSlowCopyUnkMedium(Pointer devAddr, Pointer ramAddr, size_t size, s32 arg3); OSMesgQueue sScriptLoadQueue; OSMesg sScriptLoadMesgBuf[0x10]; @@ -127,11 +127,11 @@ void AudioLoad_DecreaseSampleDmaTtls(void) { gAudioContext.unused2628 = 0; } -void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, s32 medium) { +void* AudioLoad_DmaSampleData(Pointer devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) { s32 pad1; SampleDma* dma = NULL; s32 hasDma = false; - u32 dmaDevAddr; + Pointer dmaDevAddr; u32 pad2; u32 dmaIndex; u32 transfer; @@ -141,7 +141,7 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, if (arg2 != 0 || *dmaIndexRef >= gAudioContext.sampleDmaListSize1) { for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { dma = &gAudioContext.sampleDmas[i]; - bufferPos = devAddr - dma->devAddr; + bufferPos = (devAddr - dma->devAddr).get(); if (0 <= bufferPos && (u32)bufferPos <= dma->size - size) { // We already have a DMA request for this memory range. if (dma->ttl == 0 && @@ -159,7 +159,7 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, } dma->ttl = 32; *dmaIndexRef = (u8)i; - return &dma->ramAddr[devAddr - dma->devAddr]; + return &dma->ramAddr[(devAddr - dma->devAddr).get()]; } } @@ -179,7 +179,7 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, dma = gAudioContext.sampleDmas + *dmaIndexRef; i = 0; again: - bufferPos = devAddr - dma->devAddr; + bufferPos = (devAddr - dma->devAddr).get(); if (0 <= bufferPos && (u32)bufferPos <= dma->size - size) { // We already have DMA for this memory range. if (dma->ttl == 0) { @@ -195,7 +195,7 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, gAudioContext.sampleDmaReuseQueue1RdPos++; } dma->ttl = 2; - return dma->ramAddr + (devAddr - dma->devAddr); + return dma->ramAddr + (devAddr - dma->devAddr).get(); } dma = gAudioContext.sampleDmas + i++; if (i <= gAudioContext.sampleDmaListSize1) { @@ -214,15 +214,15 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, s32 arg2, u8* dmaIndexRef, } transfer = dma->size; - dmaDevAddr = devAddr & ~0xF; + dmaDevAddr = devAddr.get() & ~0xF; dma->ttl = 3; dma->devAddr = dmaDevAddr; dma->sizeUnused = transfer; AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, - OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, + OS_READ, dmaDevAddr.get(), dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, "SUPERDMA"); *dmaIndexRef = dmaIndex; - return (devAddr - dmaDevAddr) + dma->ramAddr; + return (devAddr - dmaDevAddr).get() + dma->ramAddr; } void AudioLoad_InitSampleDmaBuffers(s32 arg0) { @@ -233,13 +233,13 @@ void AudioLoad_InitSampleDmaBuffers(s32 arg0) { gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize1; gAudioContext.sampleDmas = - AudioHeap_Alloc(&gAudioContext.notesAndBuffersPool, + (SampleDma*)AudioHeap_Alloc(&gAudioContext.notesAndBuffersPool, 4 * gAudioContext.numNotes * sizeof(SampleDma) * gAudioContext.audioBufferParameters.specUnk4); t2 = 3 * gAudioContext.numNotes * gAudioContext.audioBufferParameters.specUnk4; for (i = 0; i < t2; i++) { dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; dma->ramAddr = - AudioHeap_AllocAttemptExternal(&gAudioContext.notesAndBuffersPool, gAudioContext.sampleDmaBufSize); + (u8*)AudioHeap_AllocAttemptExternal(&gAudioContext.notesAndBuffersPool, gAudioContext.sampleDmaBufSize); if (dma->ramAddr == NULL) { break; } else { @@ -270,7 +270,7 @@ void AudioLoad_InitSampleDmaBuffers(s32 arg0) { for (j = 0; j < gAudioContext.numNotes; j++) { dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; dma->ramAddr = - AudioHeap_AllocAttemptExternal(&gAudioContext.notesAndBuffersPool, gAudioContext.sampleDmaBufSize); + (u8*)AudioHeap_AllocAttemptExternal(&gAudioContext.notesAndBuffersPool, gAudioContext.sampleDmaBufSize); if (dma->ramAddr == NULL) { break; } else { @@ -381,7 +381,7 @@ void AudioLoad_InitTable(AudioTable* table, void* romAddr, u16 unkMediumParam) { LoadTable(table); table->unkMediumParam = unkMediumParam; - table->romAddr = romAddr; + table->romAddr = (uintptr_t)romAddr; for (i = 0; i < table->numEntries; i++) { if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) { @@ -448,7 +448,7 @@ s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium); } sample->medium = MEDIUM_RAM; - sample->sampleAddr = sampleAddr; + sample->sampleAddr = (u8*)sampleAddr; } } return 0; @@ -482,7 +482,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) { - osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); + osSendMesg(retQueue, (OSMesg)0xFFFFFFFF, OS_MESG_NOBLOCK); } } @@ -632,14 +632,14 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId) { return NULL; } - return AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate); + return (u8*)AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate); } u32 AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) { return AudioLoad_TrySyncLoadSampleBank(sampleBankId, outMedium, true); } -u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) { +static uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) { void* ret; AudioTable* sampleBankTable; u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId); @@ -652,7 +652,7 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad AudioLoad_SetSampleFontLoadStatus(realTableId, 2); } *outMedium = MEDIUM_RAM; - return ret; + return (u32)ret; } cachePolicy = sampleBankTable->entries[sampleBankId].cachePolicy; @@ -664,7 +664,7 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad ret = AudioLoad_SyncLoad(SAMPLE_TABLE, sampleBankId, &noLoad); if (ret != NULL) { *outMedium = MEDIUM_RAM; - return ret; + return (uintptr_t)ret; } *outMedium = sampleBankTable->entries[sampleBankId].medium; @@ -731,7 +731,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { size = table->entries[realId].size; size = ALIGN16(size); medium = table->entries[id].medium; - cachePolicy = table->entries[id].cachePolicy; + cachePolicy = (AudioCacheLoadType)table->entries[id].cachePolicy; romAddr = table->entries[realId].romAddr; switch (cachePolicy) { case CACHE_LOAD_PERMANENT: @@ -763,9 +763,9 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { *didAllocate = true; if (medium == MEDIUM_UNK) { - AudioLoad_SyncDmaUnkMedium(romAddr, mem, size, (s16)table->unkMediumParam); + AudioLoad_SyncDmaUnkMedium(romAddr, (u8*)mem, size, (s16)table->unkMediumParam); } else { - AudioLoad_SyncDma(romAddr, mem, size, medium); + AudioLoad_SyncDma(romAddr, (u8*)mem, size, medium); } status = cachePolicy == 0 ? 5 : 2; @@ -839,8 +839,8 @@ static_assert(sizeof(SoundFontSound) == 0x8, "SoundFontSound is incorrect size") static_assert(sizeof(SoundFont) == 0x14, "SoundFont is incorrect size"); void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo) { - u32 reloc; - u32 reloc2; + uintptr_t reloc; + uintptr_t reloc2; Instrument* inst; Drum* drum; SoundFontSound* sfx; @@ -852,35 +852,35 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo #define BASE_OFFSET(x) (void*)((BEE32((uintptr_t)x)) + (u32)(mem)) //#define BASE_OFFSET(x) (void*)(((uintptr_t)x) + (u32)(mem)) - reloc2 = ptrs[0]; + reloc2 = (uintptr_t)ptrs[0]; if ((reloc2 != 0) && (numDrums != 0)) { ptrs[0] = BASE_OFFSET(reloc2); for (i = 0; i < numDrums; i++) { - reloc = ((Drum**)ptrs[0])[i]; + reloc = (uintptr_t)((Drum**)ptrs[0])[i]; //reloc = (Drum*)ptrs[0] + i; if (reloc != 0) { - reloc = BASE_OFFSET(reloc); - drum = reloc; - ((Drum**)ptrs[0])[i] = drum = reloc; + reloc = (uintptr_t)BASE_OFFSET(reloc); + drum = (Drum*)reloc; + ((Drum**)ptrs[0])[i] = drum = (Drum*)reloc; if (!drum->loaded) { AudioLoad_RelocateSample(&drum->sound, mem, relocInfo); - reloc = drum->envelope; - drum->envelope = BASE_OFFSET(reloc); + reloc = (uintptr_t)drum->envelope; + drum->envelope = (AdsrEnvelope*)BASE_OFFSET(reloc); drum->loaded = 1; } } } } - reloc2 = ptrs[1]; + reloc2 = (uintptr_t)ptrs[1]; if ((reloc2 != 0) && (numSfx != 0)) { ptrs[1] = BASE_OFFSET(reloc2); for (i = 0; i < numSfx; i++) { - reloc = (SoundFontSound*)ptrs[1] + i; + reloc = (uintptr_t)((SoundFontSound*)ptrs[1] + i); if (reloc != 0) { - sfx = reloc; + sfx = (SoundFontSound*)reloc; if (sfx->sample != NULL) { AudioLoad_RelocateSample(sfx, mem, relocInfo); } @@ -894,9 +894,8 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo for (i = 2; i <= 2 + numInstruments - 1; i++) { if (ptrs[i] != NULL) { - inst = ptrs[i]; ptrs[i] = BASE_OFFSET(ptrs[i]); - inst = ptrs[i]; + inst = (Instrument*)ptrs[i]; if (!inst->loaded) { if (inst->normalRangeLo != 0) { AudioLoad_RelocateSample(&inst->lowNotesSound, mem, relocInfo); @@ -906,8 +905,8 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo AudioLoad_RelocateSample(&inst->highNotesSound, mem, relocInfo); } - reloc = inst->envelope; - inst->envelope = BASE_OFFSET(reloc); + reloc = (uintptr_t)inst->envelope; + inst->envelope = (AdsrEnvelope*)BASE_OFFSET(reloc); inst->loaded = 1; } } @@ -915,17 +914,17 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo #undef BASE_OFFSET - gAudioContext.soundFonts[fontId].drums = ptrs[0]; - gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; + gAudioContext.soundFonts[fontId].drums = (Drum**)ptrs[0]; + gAudioContext.soundFonts[fontId].soundEffects = (SoundFontSound*)ptrs[1]; gAudioContext.soundFonts[fontId].instruments = (Instrument**)(ptrs + 2); } -void AudioLoad_SyncDma(u32 devAddr, u8* addr, u32 size, s32 medium) { +static void AudioLoad_SyncDma(Pointer devAddr, Pointer addr, size_t size, s32 medium) { OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue; OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg; size = ALIGN16(size); - Audio_InvalDCache(addr, size); + Audio_InvalDCache(addr.buffer(), size); while (true) { if (size < 0x400) { @@ -934,8 +933,8 @@ void AudioLoad_SyncDma(u32 devAddr, u8* addr, u32 size, s32 medium) { AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, addr, 0x400, msgQueue, medium, "FastCopy"); osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); size -= 0x400; - devAddr += 0x400; - addr += 0x400; + devAddr = devAddr + 0x400; + addr = addr + 0x400; } if (size != 0) { @@ -944,11 +943,11 @@ void AudioLoad_SyncDma(u32 devAddr, u8* addr, u32 size, s32 medium) { } } -void AudioLoad_SyncDmaUnkMedium(u32 devAddr, u8* addr, u32 size, s32 unkMediumParam) { +static void AudioLoad_SyncDmaUnkMedium(Pointer devAddr, Pointer addr, size_t size, s32 unkMediumParam) { return; } -s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void* ramAddr, u32 size, +static s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, Pointer devAddr, Pointer ramAddr, size_t size, OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) { OSPiHandle* handle; @@ -975,10 +974,10 @@ s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void mesg->hdr.pri = priority; mesg->hdr.retQueue = reqQueue; - mesg->dramAddr = ramAddr; - mesg->devAddr = devAddr; + mesg->dramAddr = (void*)ramAddr.get(); + mesg->devAddr = (void*)devAddr.get(); mesg->size = size; - memcpy(ramAddr, devAddr, size); + memcpy((void*)ramAddr.get(), (void*)devAddr.get(), size); //handle->transferInfo.cmdType = 2; //sDmaHandler(handle, mesg, direction); return 0; @@ -1026,7 +1025,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ret = AudioLoad_SearchCaches(tableType, realId); if (ret != NULL) { status = 2; - osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK); + osSendMesg(retQueue, (OSMesg)MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK); } else { sp50 = AudioLoad_GetLoadTable(tableType); size = sp50->entries[realId].size; @@ -1179,7 +1178,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { gAudioContext.audioHeapSize = D_8014A6C4.heapSize; } else { void** hp = &heap; - gAudioContext.audioHeap = *hp; + gAudioContext.audioHeap = (u8*)*hp; gAudioContext.audioHeapSize = heapSize; } @@ -1190,24 +1189,24 @@ void AudioLoad_Init(void* heap, u32 heapSize) { AudioHeap_InitMainPools(D_8014A6C4.initPoolSize); for (i = 0; i < 3; i++) { - gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + gAudioContext.aiBuffers[i] = (s16*)AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); } gAudioContext.sequenceTable = (AudioTable*)&gSequenceTable; gAudioContext.soundFontTable = (AudioTable*)&gSoundFontTable; gAudioContext.sampleBankTable = (AudioTable*)&gSampleBankTable; - gAudioContext.sequenceFontTable = gSequenceFontTable; + gAudioContext.sequenceFontTable = (u8*)gSequenceFontTable; gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries; gAudioContext.audioResetSpecIdToLoad = 0; gAudioContext.resetStatus = 1; AudioHeap_ResetStep(); - AudioLoad_InitTable(gAudioContext.sequenceTable, Audioseq, 0); - AudioLoad_InitTable(gAudioContext.soundFontTable, Audiobank_le, 0); - AudioLoad_InitTable(gAudioContext.sampleBankTable, Audiotable, 0); + AudioLoad_InitTable(gAudioContext.sequenceTable, (void*)Audioseq, 0); + AudioLoad_InitTable(gAudioContext.soundFontTable, (void*)Audiobank_le, 0); + AudioLoad_InitTable(gAudioContext.sampleBankTable, (void*)Audiotable, 0); numFonts = gAudioContext.soundFontTable->numEntries; - gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + gAudioContext.soundFonts = (SoundFont*)AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); for (i = 0; i < numFonts; i++) { AudioLoad_InitSoundFontMeta(i); @@ -1251,7 +1250,7 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { slowLoad->sample = *sample; slowLoad->isDone = isDone; slowLoad->curRamAddr = - AudioHeap_AllocSampleCache(sample->size, fontId, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + (u8*)AudioHeap_AllocSampleCache(sample->size, fontId, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); if (slowLoad->curRamAddr == NULL) { if (sample->medium == MEDIUM_UNK || sample->codec == CODEC_S16_INMEMORY) { @@ -1377,7 +1376,7 @@ void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, s32 size) { &slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY"); } -void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, s32 size, s32 arg3) { +static void AudioLoad_DmaSlowCopyUnkMedium(Pointer devAddr, Pointer ramAddr, size_t size, s32 arg3) { } s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { @@ -1459,8 +1458,8 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoad(u32 devAddr, void* ramAddr, u32 size, s asyncLoad->status = LOAD_STATUS_START; asyncLoad->curDevAddr = devAddr; - asyncLoad->ramAddr = ramAddr; - asyncLoad->curRamAddr = ramAddr; + asyncLoad->ramAddr = (u8*)ramAddr; + asyncLoad->curRamAddr = (u8*)ramAddr; asyncLoad->bytesRemaining = size; if (nChunks == 0) { @@ -1551,8 +1550,8 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { break; } - doneMsg = asyncLoad->retMsg; - if (1) {} + doneMsg = (OSMesg)asyncLoad->retMsg; + asyncLoad->status = LOAD_STATUS_WAITING; osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK); } @@ -1625,19 +1624,19 @@ void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocIn void* reloc; if (BEE32((u32)sound->sample) <= 0x80000000) { - sample = sound->sample = RELOC(sound->sample, mem); + sample = sound->sample = (SoundFontSample*)RELOC(sound->sample, mem); if (sample->size != 0 && sample->unk_bit25 != 1) { - sample->loop = RELOC(sample->loop, mem); - sample->book = RELOC(sample->book, mem); + sample->loop = (AdpcmLoop*)RELOC(sample->loop, mem); + sample->book = (AdpcmBook*)RELOC(sample->book, mem); // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. switch (BEE32(sample->medium)) { case 0: - sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); + sample->sampleAddr = (u8*)RELOC(sample->sampleAddr, relocInfo->baseAddr1); sample->medium = relocInfo->medium1; break; case 1: - sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); + sample->sampleAddr = (u8*)RELOC(sample->sampleAddr, relocInfo->baseAddr2); sample->medium = relocInfo->medium2; break; case 2: @@ -1692,26 +1691,26 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Rel switch (async) { case false: if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } else if (sample->medium == MEDIUM_DISK_DRIVE) { - addr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } break; case true: if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } else if (sample->medium == MEDIUM_DISK_DRIVE) { - addr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } break; @@ -1955,20 +1954,20 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo switch (async) { case false: if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } break; case true: if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + addr = (u8*)AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } break; @@ -1985,7 +1984,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo sample->sampleAddr = addr; sample->medium = MEDIUM_RAM; } else { - AudioLoad_SyncDma((u32)sample->sampleAddr, addr, sample->size, sample->medium); + AudioLoad_SyncDma(sample->sampleAddr, addr, sample->size, sample->medium); sample->sampleAddr = addr; sample->medium = MEDIUM_RAM; } @@ -1997,7 +1996,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo preload->ramAddr = addr; preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; preload->isFree = false; - preload->endAndMediumKey = (u32)sample->sampleAddr + sample->size + sample->medium; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; gAudioContext.preloadSampleStackTop++; break; } diff --git a/src/code/audio_playback.c b/src/code/audio_playback.cpp similarity index 98% rename from src/code/audio_playback.c rename to src/code/audio_playback.cpp index b10164f65..569b24e4e 100644 --- a/src/code/audio_playback.c +++ b/src/code/audio_playback.cpp @@ -418,7 +418,7 @@ s32 Audio_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* val if (index >= gAudioContext.soundFonts[fontId].numDrums) { return -3; } - gAudioContext.soundFonts[fontId].drums[index] = value; + gAudioContext.soundFonts[fontId].drums[index] = (Drum*)value; break; case 1: @@ -432,7 +432,7 @@ s32 Audio_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* val if (index >= gAudioContext.soundFonts[fontId].numInstruments) { return -3; } - gAudioContext.soundFonts[fontId].instruments[index] = value; + gAudioContext.soundFonts[fontId].instruments[index] = (Instrument*)value; break; } @@ -696,7 +696,7 @@ void Audio_NotePoolFill(NotePool* pool, s32 count) { } while (j < count) { - note = AudioSeq_AudioListPopBack(source); + note = (Note*)AudioSeq_AudioListPopBack(source); if (note == NULL) { break; } @@ -749,7 +749,7 @@ Note* Audio_FindNodeWithPrioLessThan(AudioListItem* list, s32 limit) { return NULL; } - return best->u.value; + return (Note*)best->u.value; } void Audio_NoteInitForLayer(Note* note, SequenceLayer* layer) { @@ -805,7 +805,7 @@ void Audio_NoteReleaseAndTakeOwnership(Note* note, SequenceLayer* layer) { } Note* Audio_AllocNoteFromDisabled(NotePool* pool, SequenceLayer* layer) { - Note* note = AudioSeq_AudioListPopBack(&pool->disabled); + auto note = (Note*)AudioSeq_AudioListPopBack(&pool->disabled); if (note != NULL) { Audio_NoteInitForLayer(note, layer); Audio_AudioListPushFront(&pool->active, ¬e->listItem); @@ -814,7 +814,7 @@ Note* Audio_AllocNoteFromDisabled(NotePool* pool, SequenceLayer* layer) { } Note* Audio_AllocNoteFromDecaying(NotePool* pool, SequenceLayer* layer) { - Note* note = AudioSeq_AudioListPopBack(&pool->decaying); + auto note = (Note*)AudioSeq_AudioListPopBack(&pool->decaying); if (note != NULL) { Audio_NoteReleaseAndTakeOwnership(note, layer); AudioSeq_AudioListPushBack(&pool->releasing, ¬e->listItem); @@ -941,6 +941,6 @@ void Audio_NoteInitAll(void) { note->portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->unk_BC = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x1E0); + note->synthesisState.synthesisBuffers = (NoteSynthesisBuffers*)AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x1E0); } } diff --git a/src/code/audio_seqplayer.c b/src/code/audio_seqplayer.cpp similarity index 99% rename from src/code/audio_seqplayer.c rename to src/code/audio_seqplayer.cpp index 8bf185d5e..9af6a47db 100644 --- a/src/code/audio_seqplayer.c +++ b/src/code/audio_seqplayer.cpp @@ -178,7 +178,7 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIdx) { if (channel->layers[layerIdx] == NULL) { SequenceLayer* layer; - layer = AudioSeq_AudioListPopBack(&gAudioContext.layerFreeList); + layer = (SequenceLayer*)AudioSeq_AudioListPopBack(&gAudioContext.layerFreeList); channel->layers[layerIdx] = layer; if (layer == NULL) { channel->layers[layerIdx] = NULL; @@ -286,7 +286,7 @@ void AudioSeq_SequenceChannelEnable(SequencePlayer* seqPlayer, u8 channelIdx, vo channel->enabled = true; channel->finished = false; channel->scriptState.depth = 0; - channel->scriptState.pc = script; + channel->scriptState.pc = (u8*)script; channel->delay = 0; for (i = 0; i < 4; i++) { if (channel->layers[i] != NULL) { @@ -1044,7 +1044,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xC2: offset = (u16)parameters[0]; - channel->dynTable = (void*)&seqPlayer->seqData[offset]; + channel->dynTable = (u8 (*)[][2])&seqPlayer->seqData[offset]; break; case 0xC5: if (scriptState->value != -1) { @@ -1052,7 +1052,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { data = (*channel->dynTable)[scriptState->value]; offset = (u16)((data[0] << 8) + data[1]); - channel->dynTable = (void*)&seqPlayer->seqData[offset]; + channel->dynTable = (u8 (*)[][2])&seqPlayer->seqData[offset]; } break; case 0xEB: @@ -1333,7 +1333,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->unk_22 = *(u16*)(seqPlayer->seqData + (u32)(offset + scriptState->value * 2)); break; case 0xB4: - channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22]; + channel->dynTable = (u8 (*)[][2])&seqPlayer->seqData[channel->unk_22]; break; case 0xB5: channel->unk_22 = ((u16*)(channel->dynTable))[scriptState->value]; @@ -1817,7 +1817,7 @@ void AudioSeq_InitSequencePlayerChannels(s32 playerIdx) { s32 i, j; for (i = 0; i < 0x10; i++) { - seqPlayer->channels[i] = AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, sizeof(SequenceChannel)); + seqPlayer->channels[i] = (SequenceChannel*)AudioHeap_AllocZeroed(&gAudioContext.notesAndBuffersPool, sizeof(SequenceChannel)); if (seqPlayer->channels[i] == NULL) { seqPlayer->channels[i] = &gAudioContext.sequenceChannelNone; } else { diff --git a/src/code/audio_sound_params.c b/src/code/audio_sound_params.cpp similarity index 100% rename from src/code/audio_sound_params.c rename to src/code/audio_sound_params.cpp diff --git a/src/code/audio_synthesis.c b/src/code/audio_synthesis.cpp similarity index 98% rename from src/code/audio_synthesis.c rename to src/code/audio_synthesis.cpp index c7fa66e39..aabc26b13 100644 --- a/src/code/audio_synthesis.c +++ b/src/code/audio_synthesis.cpp @@ -2,6 +2,7 @@ #include "ultra64.h" #include "global.h" #include "z64audio.h" +//#include "ultra64/abi.h" #include "def/audio_data.h" #include "def/audio_load.h" #include "def/audio_seqplayer.h" @@ -184,7 +185,7 @@ Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen) gAudioContext.synthesisReverbs[j].curFrame ^= 1; } - *cmdCnt = cmdP - cmdStart; + *cmdCnt = (s32)(cmdP - cmdStart); return cmdP; } @@ -392,12 +393,13 @@ void AudioSynth_EnvSetup1(Acmd* cmd, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { void func_800DBD08(void) { } -void AudioSynth_LoadBuffer(Acmd* cmd, s32 arg1, s32 arg2, s32 arg3) { - aLoadBuffer(cmd, arg3, arg1, arg2); +static void AudioSynth_LoadBuffer(Acmd* cmd, s32 arg1, s32 arg2, Pointer arg3) { + aLoadBuffer(cmd, arg3.get(), arg1, arg2); } -void AudioSynth_SaveBuffer(Acmd* cmd, s32 arg1, s32 arg2, s32 arg3) { - aSaveBuffer(cmd, arg1, arg3, arg2); +static void AudioSynth_SaveBuffer(Acmd* cmd, s32 arg1, s32 arg2, Pointer address) +{ + aSaveBuffer(cmd, arg1, address.get(), arg2); } void AudioSynth_EnvSetup2(Acmd* cmd, s32 volLeft, s32 volRight) { @@ -454,12 +456,12 @@ void func_800DBE64(void) { void func_800DBE6C(void) { } -void AudioSynth_LoadFilter(Acmd* cmd, s32 flags, s32 countOrBuf, s32 addr) { - aFilter(cmd, flags, countOrBuf, addr); +void AudioSynth_LoadFilter(Acmd* cmd, s32 flags, s32 countOrBuf, Pointer addr) { + aFilter(cmd, flags, countOrBuf, addr.get()); } -void AudioSynth_LoadFilterCount(Acmd* cmd, s32 count, s32 addr) { - aFilter(cmd, 2, count, addr); +static void AudioSynth_LoadFilterCount(Acmd* cmd, s32 count, Pointer addr) { + aFilter(cmd, 2, count, addr.get()); } Acmd* AudioSynth_LoadRingBuffer1(Acmd* cmd, s32 arg1, SynthesisReverb* reverb, s16 bufIndex) { @@ -544,8 +546,7 @@ Acmd* AudioSynth_SaveReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 bufIn } else { // Downsampling is done later by CPU when RSP is done, therefore we need to have // double buffering. Left and right buffers are adjacent in memory. - AudioSynth_SaveBuffer(cmd++, DMEM_WET_LEFT_CH, DEFAULT_LEN_2CH, - reverb->items[reverb->curFrame][bufIndex].toDownsampleLeft); + AudioSynth_SaveBuffer(cmd++, DMEM_WET_LEFT_CH, DEFAULT_LEN_2CH, reverb->items[reverb->curFrame][bufIndex].toDownsampleLeft); } reverb->resampleFlags = 0; @@ -689,7 +690,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS s32 temp_v1_6; void* buf; s32 nSamplesToDecode; - u32 sampleAddr; + Pointer sampleAddr; u32 samplesLenFixedPoint; s32 samplesLenAdjusted; s32 nSamplesProcessed; @@ -701,7 +702,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS s32 frameSize = 0; // TODO HACK not sure why this isnt being set s32 nFramesToDecode; s32 skipInitialSamples = 16; // TODO HACK not sure why this isnt being set - s32 sampleDataStart = 0; // TODO HACK not sure why this isnt being set + Pointer sampleDataStart; u8* sampleData; s32 nParts; s32 curPart; @@ -875,11 +876,11 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16; sampleDataOffset = frameIndex * frameSize; if (audioFontSample->medium == MEDIUM_RAM) { - sampleData = (u8*)(sampleDataStart + sampleDataOffset + sampleAddr); + sampleData = (u8*)(sampleDataStart + sampleDataOffset + sampleAddr).get(); } else if (audioFontSample->medium == MEDIUM_UNK) { return cmd; } else { - sampleData = AudioLoad_DmaSampleData(sampleDataStart + sampleDataOffset + sampleAddr, + sampleData = (u8*)AudioLoad_DmaSampleData(sampleDataStart + sampleDataOffset + sampleAddr, ALIGN16((nFramesToDecode * frameSize) + 0x10), flags, &synthState->sampleDmaIndex, audioFontSample->medium); } diff --git a/src/code/code_800430A0.c b/src/code/code_800430A0.cpp similarity index 100% rename from src/code/code_800430A0.c rename to src/code/code_800430A0.cpp diff --git a/src/code/code_80043480.c b/src/code/code_80043480.cpp similarity index 100% rename from src/code/code_80043480.c rename to src/code/code_80043480.cpp diff --git a/src/code/code_80069420.c b/src/code/code_80069420.cpp similarity index 100% rename from src/code/code_80069420.c rename to src/code/code_80069420.cpp diff --git a/src/code/code_8006BA00.c b/src/code/code_8006BA00.cpp similarity index 100% rename from src/code/code_8006BA00.c rename to src/code/code_8006BA00.cpp diff --git a/src/code/code_8006C3A0.c b/src/code/code_8006C3A0.cpp similarity index 100% rename from src/code/code_8006C3A0.c rename to src/code/code_8006C3A0.cpp diff --git a/src/code/code_8006C510.c b/src/code/code_8006C510.cpp similarity index 100% rename from src/code/code_8006C510.c rename to src/code/code_8006C510.cpp diff --git a/src/code/code_80097A00.c b/src/code/code_80097A00.cpp similarity index 100% rename from src/code/code_80097A00.c rename to src/code/code_80097A00.cpp diff --git a/src/code/code_800A9F30.c b/src/code/code_800A9F30.cpp similarity index 100% rename from src/code/code_800A9F30.c rename to src/code/code_800A9F30.cpp diff --git a/src/code/code_800ACE70.c b/src/code/code_800ACE70.cpp similarity index 83% rename from src/code/code_800ACE70.c rename to src/code/code_800ACE70.cpp index 44d089199..6af9756b5 100644 --- a/src/code/code_800ACE70.c +++ b/src/code/code_800ACE70.cpp @@ -4,7 +4,7 @@ #include "code_800ACE70.h" #include "def/code_800ACE70.h" -// Note : This file is related to z_vismono, the original name was probably z_vis Gfx D_8012AC00[] = { @@ -54,44 +54,44 @@ Gfx D_8012AC58[] = { }; // Init -void func_800ACE70(struct_801664F0* this) { - this->type = 0; - this->setScissor = false; - this->color.r = 255; - this->color.g = 255; - this->color.b = 255; - this->color.a = 255; +void func_800ACE70(struct_801664F0* pthis) { + pthis->type = 0; + pthis->setScissor = false; + pthis->color.r = 255; + pthis->color.g = 255; + pthis->color.b = 255; + pthis->color.a = 255; } // Destroy -void func_800ACE90(struct_801664F0* this) { +void func_800ACE90(struct_801664F0* pthis) { } // Draw -void func_800ACE98(struct_801664F0* this, Gfx** gfxp) { +void func_800ACE98(struct_801664F0* pthis, Gfx** gfxp) { Gfx* gfx = *gfxp; gDPPipeSync(gfx++); gDPSetPrimDepth(gfx++, -1, -1); - if (this->setScissor == true) { + if (pthis->setScissor == true) { gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } - switch (this->type) { + switch (pthis->type) { case 1: gSPDisplayList(gfx++, D_8012AC40); break; case 2: - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); + gDPSetColor(gfx++, G_SETPRIMCOLOR, pthis->color.rgba); gSPDisplayList(gfx++, D_8012AC58); break; case 3: - gDPSetColor(gfx++, G_SETBLENDCOLOR, this->color.rgba); + gDPSetColor(gfx++, G_SETBLENDCOLOR, pthis->color.rgba); gSPDisplayList(gfx++, D_8012AC00); break; case 4: - gDPSetColor(gfx++, G_SETFOGCOLOR, this->color.rgba); + gDPSetColor(gfx++, G_SETFOGCOLOR, pthis->color.rgba); gSPDisplayList(gfx++, D_8012AC28); break; } diff --git a/src/code/code_800AD920.c b/src/code/code_800AD920.cpp similarity index 71% rename from src/code/code_800AD920.c rename to src/code/code_800AD920.cpp index dc2e38444..e4f3a577f 100644 --- a/src/code/code_800AD920.c +++ b/src/code/code_800AD920.cpp @@ -10,33 +10,33 @@ u16 D_0E000000[0x800000]; // TODO FIX random size set, not sure what this is // Init -void func_800AD920(struct_80166500* this) { - this->useRgba = false; - this->setScissor = false; - this->primColor.r = 255; - this->primColor.g = 255; - this->primColor.b = 255; - this->primColor.a = 255; - this->envColor.a = 255; - this->envColor.r = 0; - this->envColor.g = 0; - this->envColor.b = 0; +void func_800AD920(struct_80166500* pthis) { + pthis->useRgba = false; + pthis->setScissor = false; + pthis->primColor.r = 255; + pthis->primColor.g = 255; + pthis->primColor.b = 255; + pthis->primColor.a = 255; + pthis->envColor.a = 255; + pthis->envColor.r = 0; + pthis->envColor.g = 0; + pthis->envColor.b = 0; } // Destroy -void func_800AD950(struct_80166500* this) { +void func_800AD950(struct_80166500* pthis) { } // Draw -void func_800AD958(struct_80166500* this, Gfx** gfxp) { +void func_800AD958(struct_80166500* pthis, Gfx** gfxp) { Gfx* gfx = *gfxp; u16* tex = D_0E000000; - s32 fmt = this->useRgba == false ? G_IM_FMT_IA : G_IM_FMT_RGBA; + s32 fmt = pthis->useRgba == false ? G_IM_FMT_IA : G_IM_FMT_RGBA; s32 y; s32 height = 6; gDPPipeSync(gfx++); - if (this->setScissor == true) { + if (pthis->setScissor == true) { gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } @@ -47,8 +47,8 @@ void func_800AD958(struct_80166500* this, Gfx** gfxp) { gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT); - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); - gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + gDPSetColor(gfx++, G_SETPRIMCOLOR, pthis->primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, pthis->envColor.rgba); for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { gDPLoadTextureBlock(gfx++, tex, fmt, G_IM_SIZ_16b, SCREEN_WIDTH, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, diff --git a/src/code/code_800BB0A0.c b/src/code/code_800BB0A0.cpp similarity index 100% rename from src/code/code_800BB0A0.c rename to src/code/code_800BB0A0.cpp diff --git a/src/code/code_800C3C20.c b/src/code/code_800C3C20.cpp similarity index 100% rename from src/code/code_800C3C20.c rename to src/code/code_800C3C20.cpp diff --git a/src/code/code_800D2E30.c b/src/code/code_800D2E30.cpp similarity index 100% rename from src/code/code_800D2E30.c rename to src/code/code_800D2E30.cpp diff --git a/src/code/code_800D31A0.c b/src/code/code_800D31A0.cpp similarity index 100% rename from src/code/code_800D31A0.c rename to src/code/code_800D31A0.cpp diff --git a/src/code/code_800E4FE0.c b/src/code/code_800E4FE0.cpp similarity index 98% rename from src/code/code_800E4FE0.c rename to src/code/code_800E4FE0.cpp index 92c66055a..0084781d9 100644 --- a/src/code/code_800E4FE0.c +++ b/src/code/code_800E4FE0.cpp @@ -86,7 +86,7 @@ AudioTask* func_800E5000(void) { } } - osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); + osSendMesg(gAudioContext.taskStartQueueP, (OSMesg)gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); gAudioContext.rspTaskIdx ^= 1; gAudioContext.curAIBufIdx++; gAudioContext.curAIBufIdx %= 3; @@ -133,7 +133,7 @@ AudioTask* func_800E5000(void) { if (gAudioContext.resetStatus != 0) { if (AudioHeap_ResetStep() == 0) { if (gAudioContext.resetStatus == 0) { - osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); + osSendMesg(gAudioContext.audioResetQueueP, (OSMesg)gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); } sWaitingAudioTask = NULL; @@ -237,10 +237,10 @@ void func_800E5584(AudioCmd* cmd) { return; case 0x82: AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2); - func_800E59AC(cmd->arg0, cmd->data); + func_800E59AC(cmd->arg0, (s32)cmd->data); return; case 0x85: - AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->data); + AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, (s32)cmd->data); return; case 0x83: if (gAudioContext.seqPlayers[cmd->arg0].enabled) { @@ -375,7 +375,7 @@ void Audio_QueueCmd(u32 opArgs, void** data) { AudioCmd* cmd = &gAudioContext.cmdBuf[gAudioContext.cmdWrPos & 0xFF]; cmd->opArgs = opArgs; // BE32(opArgs); - cmd->data = (u32)*data; // BE32((u32)*data); // TODO FIX broke in 64 bit + cmd->data = *data; // BE32((u32)*data); // TODO FIX broke in 64 bit gAudioContext.cmdWrPos++; diff --git a/src/code/code_800E6840.c b/src/code/code_800E6840.cpp similarity index 100% rename from src/code/code_800E6840.c rename to src/code/code_800E6840.cpp diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.cpp similarity index 100% rename from src/code/code_800EC960.c rename to src/code/code_800EC960.cpp diff --git a/src/code/code_800F7260.c b/src/code/code_800F7260.cpp similarity index 100% rename from src/code/code_800F7260.c rename to src/code/code_800F7260.cpp diff --git a/src/code/code_800F9280.c b/src/code/code_800F9280.cpp similarity index 99% rename from src/code/code_800F9280.c rename to src/code/code_800F9280.cpp index 76bb7a3a9..cd6528c83 100644 --- a/src/code/code_800F9280.c +++ b/src/code/code_800F9280.cpp @@ -9,9 +9,13 @@ #include "def/code_800F7260.h" #include "def/code_800F9280.h" -extern u8 sSeqCmdRdPos; -extern u8 sSeqCmdWrPos; -extern u8 D_80133410[]; +u8 sSeqCmdWrPos = 0; +u8 sSeqCmdRdPos = 0; +u8 D_80133408 = 0; +u8 D_8013340C = 1; +u8 D_80133410[] = {0, 1, 2, 3}; +u8 gAudioSpecId = 0; +u8 D_80133418 = 0; // TODO: clean up these macros. They are similar to ones in code_800EC960.c but without casts. #define Audio_StartSeq(playerIdx, fadeTimer, seqId) \ diff --git a/src/code/code_800FBCE0.c b/src/code/code_800FBCE0.cpp similarity index 100% rename from src/code/code_800FBCE0.c rename to src/code/code_800FBCE0.cpp diff --git a/src/code/code_800FC620.c b/src/code/code_800FC620.cpp similarity index 96% rename from src/code/code_800FC620.c rename to src/code/code_800FC620.cpp index 285847215..236a9afbe 100644 --- a/src/code/code_800FC620.c +++ b/src/code/code_800FC620.cpp @@ -25,7 +25,8 @@ char D_80134488[0x18] = { 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, }; -s32 Overlay_Load(void* vRomStart, void* vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddr) { +s32 Overlay_Load(Pointer vRomStart, Pointer vRomEnd, Pointer vRamStart, Pointer vRamEnd, Pointer allocatedVRamAddr) +{ return 0; } diff --git a/src/code/code_800FCE80.c b/src/code/code_800FCE80.cpp similarity index 98% rename from src/code/code_800FCE80.c rename to src/code/code_800FCE80.cpp index 9c7d27249..d5e86db49 100644 --- a/src/code/code_800FCE80.c +++ b/src/code/code_800FCE80.cpp @@ -2,8 +2,6 @@ #include "global.h" #include "fp.h" #include "def/code_800FCE80.h" -#include "def/cosf.h" -#include "def/sinf.h" s32 gUseAtanContFrac; diff --git a/src/code/code_800FD970.c b/src/code/code_800FD970.cpp similarity index 100% rename from src/code/code_800FD970.c rename to src/code/code_800FD970.cpp diff --git a/src/code/code_801067F0.c b/src/code/code_801067F0.cpp similarity index 100% rename from src/code/code_801067F0.c rename to src/code/code_801067F0.cpp diff --git a/src/code/code_80106860.c b/src/code/code_80106860.cpp similarity index 92% rename from src/code/code_80106860.c rename to src/code/code_80106860.cpp index 915367511..f72cd2305 100644 --- a/src/code/code_80106860.c +++ b/src/code/code_80106860.cpp @@ -4,7 +4,7 @@ // memset used in __osMalloc, z_quake, z_view, and z_camera void* z_memset(void* ptr, s32 val, size_t size) { - u8* sp4 = ptr; + u8* sp4 = (u8*)ptr; register s32 a3; for (a3 = size--; a3 != 0; a3 = size--) { diff --git a/src/code/code_801068B0.c b/src/code/code_801068B0.cpp similarity index 92% rename from src/code/code_801068B0.c rename to src/code/code_801068B0.cpp index 7b71a5e34..8d9476119 100644 --- a/src/code/code_801068B0.c +++ b/src/code/code_801068B0.cpp @@ -4,8 +4,8 @@ // memmove used in __osMalloc.c void* func_801068B0(void* dst, void* src, size_t size) { - u8* spC = dst; - u8* sp8 = src; + u8* spC = (u8*)dst; + u8* sp8 = (u8*)src; register s32 a3; if (spC == sp8) { diff --git a/src/code/db_camera.c b/src/code/db_camera.cpp similarity index 96% rename from src/code/db_camera.c rename to src/code/db_camera.cpp index 148c7351f..a1c84f6a7 100644 --- a/src/code/db_camera.c +++ b/src/code/db_camera.cpp @@ -24,56 +24,57 @@ static GlobalContext* sGlobalCtx; +#define NO_UB // TODO: cleanup these arrays and UB access -char* D_8012CEE0[] = { GFXP_KATAKANA "キ-フレ-ム" GFXP_HIRAGANA "ガ" }; -char* D_8012CEE4 = GFXP_HIRAGANA "タリマセン。"; -char* D_8012CEE8 = GFXP_HIRAGANA "サイセイデキマセン"; -char* D_8012CEEC = GFXP_HIRAGANA "サイセイシュウリョウ"; -char* D_8012CEF0 = GFXP_HIRAGANA "サイセイチュウ!"; +const char* D_8012CEE0[] = { GFXP_KATAKANA "キ-フレ-ム" GFXP_HIRAGANA "ガ" }; +const char* D_8012CEE4 = GFXP_HIRAGANA "タリマセン。"; +const char* D_8012CEE8 = GFXP_HIRAGANA "サイセイデキマセン"; +const char* D_8012CEEC = GFXP_HIRAGANA "サイセイシュウリョウ"; +const char* D_8012CEF0 = GFXP_HIRAGANA "サイセイチュウ!"; -char* D_8012CEF4 = "DEMO CAMERA TOOL"; -char* D_8012CEF8[] = { GFXP_HIRAGANA "モウハイリマセン", GFXP_HIRAGANA "トウロク テンメ", GFXP_HIRAGANA "ヘンコウ / " }; -char* D_8012CF04 = "> >"; -char* D_8012CF08 = "< <"; -char* D_8012CF0C = "< >"; -char* D_8012CF10 = GFXP_KATAKANA "*プレイヤ-*"; -char* D_8012CF14 = GFXP_KATAKANA "Eモ-ド" GFXP_HIRAGANA " ソウタイ"; -char* D_8012CF18[] = { GFXP_KATAKANA "Eモ-ド" GFXP_HIRAGANA "ゼッタイ", GFXP_HIRAGANA "ガメン" GFXP_KATAKANA " デモ", +const char* D_8012CEF4 = "DEMO CAMERA TOOL"; +const char* D_8012CEF8[] = {GFXP_HIRAGANA "モウハイリマセン", GFXP_HIRAGANA "トウロク テンメ", GFXP_HIRAGANA "ヘンコウ / "}; +const char* D_8012CF04 = "> >"; +const char* D_8012CF08 = "< <"; +const char* D_8012CF0C = "< >"; +const char* D_8012CF10 = GFXP_KATAKANA "*プレイヤ-*"; +const char* D_8012CF14 = GFXP_KATAKANA "Eモ-ド" GFXP_HIRAGANA " ソウタイ"; +const char* D_8012CF18[] = {GFXP_KATAKANA "Eモ-ド" GFXP_HIRAGANA "ゼッタイ", GFXP_HIRAGANA "ガメン" GFXP_KATAKANA " デモ", GFXP_HIRAGANA "ガメン フツウ" }; -char* D_8012CF24[] = { GFXP_HIRAGANA "Pジカン MAX", GFXP_KATAKANA "リンク" GFXP_HIRAGANA " キオク", +const char* D_8012CF24[] = {GFXP_HIRAGANA "Pジカン MAX", GFXP_KATAKANA "リンク" GFXP_HIRAGANA " キオク", GFXP_KATAKANA "リンク" GFXP_HIRAGANA " ムシ" }; -char* D_8012CF30 = GFXP_HIRAGANA "*ミテルイチ*"; -char* D_8012CF34 = GFXP_KATAKANA "*カメラ" GFXP_HIRAGANA "イチ*"; -char* D_8012CF38 = "DEBUG CAMERA"; -char* D_8012CF3C = GFXP_KATAKANA "センタ-/ロック"; -char* D_8012CF40 = GFXP_KATAKANA "センタ-/フリ-"; +const char* D_8012CF30 = GFXP_HIRAGANA "*ミテルイチ*"; +const char* D_8012CF34 = GFXP_KATAKANA "*カメラ" GFXP_HIRAGANA "イチ*"; +const char* D_8012CF38 = "DEBUG CAMERA"; +const char* D_8012CF3C = GFXP_KATAKANA "センタ-/ロック"; +const char* D_8012CF40 = GFXP_KATAKANA "センタ-/フリ-"; -char* D_8012CF44 = "DEMO CONTROL"; -char* D_8012CF48 = GFXP_KATAKANA "メモリ" GFXP_HIRAGANA "ガタリマセン"; -char* D_8012CF4C = "p"; -char* D_8012CF50[] = { "e", "s", "l", "c" }; +const char* D_8012CF44 = "DEMO CONTROL"; +const char* D_8012CF48 = GFXP_KATAKANA "メモリ" GFXP_HIRAGANA "ガタリマセン"; +const char* D_8012CF4C = "p"; +const char* D_8012CF50[] = { "e", "s", "l", "c" }; -char* D_8012CF60[] = { GFXP_KATAKANA "メモリパック" }; // "Mempak" -char* D_8012CF64 = GFXP_KATAKANA "セーブ"; // "Save" -char* D_8012CF68 = GFXP_KATAKANA "ロード"; // "Load" -char* D_8012CF6C = GFXP_KATAKANA "クリア-"; // "Clear" -char* D_8012CF70 = GFXP_HIRAGANA "ヲヌカナイデネ"; +const char* D_8012CF60[] = { GFXP_KATAKANA "メモリパック" }; // "Mempak" +const char* D_8012CF64 = GFXP_KATAKANA "セーブ"; // "Save" +const char* D_8012CF68 = GFXP_KATAKANA "ロード"; // "Load" +const char* D_8012CF6C = GFXP_KATAKANA "クリア-"; // "Clear" +const char* D_8012CF70 = GFXP_HIRAGANA "ヲヌカナイデネ"; -char* D_8012CF74 = "FREE BYTE"; -char* D_8012CF78 = "NEED BYTE"; -char* D_8012CF7C = GFXP_KATAKANA "*メモリ-パック*"; -char* D_8012CF80 = GFXP_HIRAGANA "ヲミツケラレマセン"; -char* D_8012CF84 = GFXP_KATAKANA "ファイル " GFXP_HIRAGANA "ヲ"; -char* D_8012CF88[] = { GFXP_HIRAGANA "シテモイイデスカ?", GFXP_HIRAGANA "ゲンザイヘンシュウチュウノ", +const char* D_8012CF74 = "FREE BYTE"; +const char* D_8012CF78 = "NEED BYTE"; +const char* D_8012CF7C = GFXP_KATAKANA "*メモリ-パック*"; +const char* D_8012CF80 = GFXP_HIRAGANA "ヲミツケラレマセン"; +const char* D_8012CF84 = GFXP_KATAKANA "ファイル " GFXP_HIRAGANA "ヲ"; +const char* D_8012CF88[] = { GFXP_HIRAGANA "シテモイイデスカ?", GFXP_HIRAGANA "ゲンザイヘンシュウチュウノ", GFXP_KATAKANA "ファイル" GFXP_HIRAGANA "ハハキサレマス" }; -char* D_8012CF94 = GFXP_HIRAGANA "ハイ"; -char* D_8012CF98 = GFXP_HIRAGANA "イイエ"; -char* D_8012CF9C[] = { GFXP_HIRAGANA "シテイマス", GFXP_HIRAGANA "ウワガキ" }; -char* D_8012CFA4 = GFXP_HIRAGANA "シマシタ"; -char* D_8012CFA8 = "USE BYTE"; -char* D_8012CFAC = GFXP_HIRAGANA "ニシッパイ"; +const char* D_8012CF94 = GFXP_HIRAGANA "ハイ"; +const char* D_8012CF98 = GFXP_HIRAGANA "イイエ"; +const char* D_8012CF9C[] = { GFXP_HIRAGANA "シテイマス", GFXP_HIRAGANA "ウワガキ" }; +const char* D_8012CFA4 = GFXP_HIRAGANA "シマシタ"; +const char* D_8012CFA8 = "USE BYTE"; +const char* D_8012CFAC = GFXP_HIRAGANA "ニシッパイ"; -char* D_8012CFB0 = GFXP_KATAKANA "Eモ-ド" GFXP_HIRAGANA " コテイ"; +const char* D_8012CFB0 = GFXP_KATAKANA "Eモ-ド" GFXP_HIRAGANA " コテイ"; char D_8012CFB4[] = GFXP_KATAKANA "フレ-ム "; char D_8012CFC4[] = GFXP_KATAKANA "キ- / "; char D_8012CFD0[] = GFXP_HIRAGANA "(センタ-テン)\0\0\0\0\0"; @@ -1092,14 +1093,18 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { if (dbCamera->sub.unkIdx == 0x80) { func_8006376C(0x10, 0x1A, 1, D_8012CEF8[0]); } else if (dbCamera->sub.unkIdx == (dbCamera->sub.nPoints - 1)) { +#ifndef NO_UB D_8012CEE0[7][10] = (dbCamera->sub.nPoints / 10) + '0'; D_8012CEE0[7][11] = (dbCamera->sub.nPoints % 10) + '0'; +#endif func_8006376C(0xF, 0x1A, 1, D_8012CEE0[7]); } else { +#ifndef NO_UB D_8012CEE0[8][10] = ((dbCamera->sub.unkIdx + 1) / 10) + '0'; D_8012CEE0[8][11] = ((dbCamera->sub.unkIdx + 1) % 10) + '0'; D_8012CEE0[8][13] = ((dbCamera->sub.nPoints - 1) / 10) + '0'; D_8012CEE0[8][14] = ((dbCamera->sub.nPoints - 1) % 10) + '0'; +#endif func_8006376C(0xF, 0x1A, 1, D_8012CEE0[8]); } @@ -1503,14 +1508,14 @@ char DbCamera_InitCut(s32 idx, DbCameraSub* sub) { D_80161250[0x3F + sDbCameraCuts[idx].letter] = 'O'; i = sub->nPoints * sizeof(CutsceneCameraPoint); - sDbCameraCuts[idx].lookAt = DebugArena_MallocDebug(i, "../db_camera.c", 2748); + sDbCameraCuts[idx].lookAt = (CutsceneCameraPoint*)DebugArena_MallocDebug(i, "../db_camera.c", 2748); if (sDbCameraCuts[idx].lookAt == NULL) { // "Debug camera memory allocation failure" osSyncPrintf("%s: %d: Debug camera memory allocation failure!!\n", "../db_camera.c", 2751); return '?'; } - sDbCameraCuts[idx].position = DebugArena_MallocDebug(i, "../db_camera.c", 2754); + sDbCameraCuts[idx].position = (CutsceneCameraPoint*)DebugArena_MallocDebug(i, "../db_camera.c", 2754); if (sDbCameraCuts[idx].position == NULL) { // "Debug camera memory allocation failure" osSyncPrintf("%s: %d: Debug camera memory allocation failure!!\n", "../db_camera.c", 2757); @@ -1588,7 +1593,7 @@ s32 DbCamera_LoadCallback(char* c) { if (sDbCameraCuts[i].letter != '?') { size = sDbCameraCuts[i].nPoints * sizeof(CutsceneCameraPoint); - sDbCameraCuts[i].lookAt = DebugArena_MallocDebug(ALIGN32(size), "../db_camera.c", 2844); + sDbCameraCuts[i].lookAt = (CutsceneCameraPoint*)DebugArena_MallocDebug(ALIGN32(size), "../db_camera.c", 2844); if (sDbCameraCuts[i].lookAt == NULL) { // "Debug camera memory allocation failure" osSyncPrintf("%s: %d: Debug camera memory allocation failure!!\n", "../db_camera.c", 2847); @@ -1599,7 +1604,7 @@ s32 DbCamera_LoadCallback(char* c) { } off += ALIGN32(size); - sDbCameraCuts[i].position = DebugArena_MallocDebug(ALIGN32(size), "../db_camera.c", 2855); + sDbCameraCuts[i].position = (CutsceneCameraPoint*)DebugArena_MallocDebug(ALIGN32(size), "../db_camera.c", 2855); if (sDbCameraCuts[i].position == NULL) { // "Debug camera memory allocation failure" osSyncPrintf("%s: %d: Debug camera memory allocation failure!!\n", "../db_camera.c", 2858); @@ -1842,7 +1847,9 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { &D_801333E8); dbCamera->sub.demoCtrlToggleSwitch ^= 1; } +#ifndef NO_UB D_8012CEE0[41][9] = sCurFileIdx + 'A'; +#endif func_8006376C(0xA, 7, 5, D_8012CEE0[41]); func_8006376C(0x10, 7, 5, D_8012CF60[dbCamera->sub.demoCtrlActionIdx]); func_8006376C(0x14, 7, 5, D_8012CF88[0]); @@ -1866,7 +1873,9 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.demoCtrlMenu++; } else { dbCamera->sub.demoCtrlToggleSwitch ^= 1; +#ifndef NO_UB D_8012CF84[9] = sCurFileIdx + 'A'; +#endif func_8006376C(0xD, 7, 5, D_8012CF88[-1]); // todo: find something better func_8006376C(0x12, 7, 5, D_8012CF80); func_8006376C(0xD, 9, dbCamera->sub.demoCtrlToggleSwitch ? 1 : 6, "PRESS B BUTTON"); @@ -1883,12 +1892,14 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { case DEMO_CTRL_MENU(ACTION_SAVE, MENU_CALLBACK): case DEMO_CTRL_MENU(ACTION_LOAD, MENU_CALLBACK): case DEMO_CTRL_MENU(ACTION_CLEAR, MENU_CALLBACK): { +#ifndef NO_UB D_8012CEE0[41][9] = sCurFileIdx + 'A'; +#endif func_8006376C(0xC, 7, 5, D_8012CEE0[41]); func_8006376C(0x12, 7, 5, D_8012CF60[dbCamera->sub.demoCtrlActionIdx]); func_8006376C(0x16, 7, 5, D_8012CF9C[0]); - if (callbacks[dbCamera->sub.demoCtrlActionIdx - 1](&D_8012CF84[9])) { + if (callbacks[dbCamera->sub.demoCtrlActionIdx - 1]((char*)&D_8012CF84[9])) { dbCamera->sub.demoCtrlMenu++; return 1; } else { @@ -1901,7 +1912,9 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { case DEMO_CTRL_MENU(ACTION_LOAD, MENU_SUCCESS): case DEMO_CTRL_MENU(ACTION_CLEAR, MENU_SUCCESS): { dbCamera->sub.demoCtrlToggleSwitch ^= 1; +#ifndef NO_UB D_8012CEE0[41][9] = sCurFileIdx + 'A'; +#endif func_8006376C(0xD, 7, 5, D_8012CEE0[41]); func_8006376C(0x13, 7, 5, D_8012CF60[dbCamera->sub.demoCtrlMenu / 100]); func_8006376C(0x17, 7, 5, D_8012CFA4); @@ -1923,7 +1936,9 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { case DEMO_CTRL_MENU(ACTION_LOAD, MENU_ERROR): case DEMO_CTRL_MENU(ACTION_CLEAR, MENU_ERROR): { dbCamera->sub.demoCtrlToggleSwitch ^= 1; +#ifndef NO_UB D_8012CEE0[41][9] = sCurFileIdx + 'A'; +#endif func_8006376C(0xD, 7, 5, D_8012CEE0[(dbCamera->sub.demoCtrlMenu / 100) + 32]); func_8006376C(0x11, 7, 5, D_8012CFAC); func_8006376C(0x17, 7, 5, D_8012CFA4); diff --git a/src/code/debug_malloc.c b/src/code/debug_malloc.cpp similarity index 100% rename from src/code/debug_malloc.c rename to src/code/debug_malloc.cpp diff --git a/src/code/fault.c b/src/code/fault.cpp similarity index 100% rename from src/code/fault.c rename to src/code/fault.cpp diff --git a/src/code/fault_drawer.c b/src/code/fault_drawer.cpp similarity index 100% rename from src/code/fault_drawer.c rename to src/code/fault_drawer.cpp diff --git a/src/code/flg_set.c b/src/code/flg_set.cpp similarity index 100% rename from src/code/flg_set.c rename to src/code/flg_set.cpp diff --git a/src/code/game.c b/src/code/game.cpp similarity index 98% rename from src/code/game.c rename to src/code/game.cpp index eedf8184f..7a26c70d7 100644 --- a/src/code/game.c +++ b/src/code/game.cpp @@ -49,9 +49,9 @@ extern OSViMode osViModeFpalLan1; void KaleidoScope_SetupGrayIcons(); -f32 gViConfigXScale; -f32 gViConfigYScale; -u32 gViConfigFeatures; +f32 gViConfigXScale = 1.0; +f32 gViConfigYScale = 1.0; +u32 gViConfigFeatures = OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF; OSViMode osViModeNtscLan1 = { 2, // type @@ -189,7 +189,7 @@ void func_800C4344(GameState* gameState) { HREG(81) = 0; // & 0xFFFFFFFF necessary for matching. hexDumpSize = (HREG(83) == 0 ? 0x100 : HREG(83) * 0x10) & 0xFFFFFFFF; - LogUtils_LogHexDump(PHYSICAL_TO_VIRTUAL(HREG(82) << 8), hexDumpSize); + LogUtils_LogHexDump((void*)PHYSICAL_TO_VIRTUAL(HREG(82) << 8), hexDumpSize); } } } @@ -529,7 +529,7 @@ u32 GameState_IsRunning(GameState* gameState) { return gameState->running; } -void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) { +void* GameState_Alloc(GameState* gameState, size_t size, const char* file, s32 line) { void* ret; if (THA_IsCrash(&gameState->tha)) { diff --git a/src/code/gamealloc.c b/src/code/gamealloc.c deleted file mode 100644 index 296c13127..000000000 --- a/src/code/gamealloc.c +++ /dev/null @@ -1,85 +0,0 @@ -#define INTERNAL_SRC_CODE_GAMEALLOC_C -#include "global.h" -#include "z64game.h" -#include "def/gamealloc.h" -#include "def/logutils.h" -#include "def/system_malloc.h" - -void GameAlloc_Log(GameAlloc* this) { - GameAllocEntry* iter; - - osSyncPrintf("this = %08x\n", this); - - iter = this->base.next; - while (iter != &this->base) { - osSyncPrintf("ptr = %08x size = %d\n", iter, iter->size); - iter = iter->next; - } -} - -void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line) { - GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line); - - if (ptr != NULL) { - ptr->size = size; - ptr->prev = this->head; - this->head->next = ptr; - this->head = ptr; - ptr->next = &this->base; - this->base.prev = this->head; - return ptr + 1; - } else { - return NULL; - } -} - -void* GameAlloc_Malloc(GameAlloc* this, u32 size) { - GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), "../gamealloc.c", 93); - - if (ptr != NULL) { - ptr->size = size; - ptr->prev = this->head; - this->head->next = ptr; - this->head = ptr; - ptr->next = &this->base; - this->base.prev = this->head; - return ptr + 1; - } else { - return NULL; - } -} - -void GameAlloc_Free(GameAlloc* this, void* data) { - GameAllocEntry* ptr; - - if (data != NULL) { - ptr = &((GameAllocEntry*)data)[-1]; - LogUtils_CheckNullPointer("ptr->prev", ptr->prev, "../gamealloc.c", 120); - LogUtils_CheckNullPointer("ptr->next", ptr->next, "../gamealloc.c", 121); - ptr->prev->next = ptr->next; - ptr->next->prev = ptr->prev; - this->head = this->base.prev; - SystemArena_FreeDebug(ptr, "../gamealloc.c", 125); - } -} - -void GameAlloc_Cleanup(GameAlloc* this) { - GameAllocEntry* next = this->base.next; - GameAllocEntry* cur; - - while (&this->base != next) { - cur = next; - next = next->next; - SystemArena_FreeDebug(cur, "../gamealloc.c", 145); - } - - this->head = &this->base; - this->base.next = &this->base; - this->base.prev = &this->base; -} - -void GameAlloc_Init(GameAlloc* this) { - this->head = &this->base; - this->base.next = &this->base; - this->base.prev = &this->base; -} diff --git a/src/code/gamealloc.cpp b/src/code/gamealloc.cpp new file mode 100644 index 000000000..bba42f2b6 --- /dev/null +++ b/src/code/gamealloc.cpp @@ -0,0 +1,85 @@ +#define INTERNAL_SRC_CODE_GAMEALLOC_C +#include "global.h" +#include "z64game.h" +#include "def/gamealloc.h" +#include "def/logutils.h" +#include "def/system_malloc.h" + +void GameAlloc_Log(GameAlloc* pthis) { + GameAllocEntry* iter; + + osSyncPrintf("pthis = %08x\n", pthis); + + iter = pthis->base.next; + while (iter != &pthis->base) { + osSyncPrintf("ptr = %08x size = %d\n", iter, iter->size); + iter = iter->next; + } +} + +void* GameAlloc_MallocDebug(GameAlloc* pthis, u32 size, const char* file, s32 line) { + GameAllocEntry* ptr = (GameAllocEntry*)SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line); + + if (ptr != NULL) { + ptr->size = size; + ptr->prev = pthis->head; + pthis->head->next = ptr; + pthis->head = ptr; + ptr->next = &pthis->base; + pthis->base.prev = pthis->head; + return ptr + 1; + } else { + return NULL; + } +} + +void* GameAlloc_Malloc(GameAlloc* pthis, u32 size) { + GameAllocEntry* ptr = (GameAllocEntry*)SystemArena_MallocDebug(size + sizeof(GameAllocEntry), "../gamealloc.c", 93); + + if (ptr != NULL) { + ptr->size = size; + ptr->prev = pthis->head; + pthis->head->next = ptr; + pthis->head = ptr; + ptr->next = &pthis->base; + pthis->base.prev = pthis->head; + return ptr + 1; + } else { + return NULL; + } +} + +void GameAlloc_Free(GameAlloc* pthis, void* data) { + GameAllocEntry* ptr; + + if (data != NULL) { + ptr = &((GameAllocEntry*)data)[-1]; + LogUtils_CheckNullPointer("ptr->prev", ptr->prev, "../gamealloc.c", 120); + LogUtils_CheckNullPointer("ptr->next", ptr->next, "../gamealloc.c", 121); + ptr->prev->next = ptr->next; + ptr->next->prev = ptr->prev; + pthis->head = pthis->base.prev; + SystemArena_FreeDebug(ptr, "../gamealloc.c", 125); + } +} + +void GameAlloc_Cleanup(GameAlloc* pthis) { + GameAllocEntry* next = pthis->base.next; + GameAllocEntry* cur; + + while (&pthis->base != next) { + cur = next; + next = next->next; + SystemArena_FreeDebug(cur, "../gamealloc.c", 145); + } + + pthis->head = &pthis->base; + pthis->base.next = &pthis->base; + pthis->base.prev = &pthis->base; +} + +void GameAlloc_Init(GameAlloc* pthis) { + pthis->head = &pthis->base; + pthis->base.next = &pthis->base; + pthis->base.prev = &pthis->base; +} diff --git a/src/code/gfxprint.c b/src/code/gfxprint.cpp similarity index 75% rename from src/code/gfxprint.c rename to src/code/gfxprint.cpp index c8d9e4bd5..d38308a72 100644 --- a/src/code/gfxprint.c +++ b/src/code/gfxprint.cpp @@ -140,153 +140,153 @@ u8 sGfxPrintFontData[(16 * 256) / 2] = { // Can be used to set GFXP_FLAG_ENLARGE by default static u8 sDefaultSpecialFlags; -void GfxPrint_Setup(GfxPrint* this) { +void GfxPrint_Setup(GfxPrint* pthis) { s32 width = 16; s32 height = 256; s32 i; - gDPPipeSync(this->dList++); - gDPSetOtherMode(this->dList++, + gDPPipeSync(pthis->dList++); + gDPSetOtherMode(pthis->dList++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_IA16 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); - gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA); - gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPSetCombineMode(pthis->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA); + gDPLoadTextureBlock_4b(pthis->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT); + gDPLoadTLUT(pthis->dList++, 64, 256, sGfxPrintFontTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + gDPSetTile(pthis->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPSetTileSize(this->dList++, i * 2, 0, 0, 60, 1020); + gDPSetTileSize(pthis->dList++, i * 2, 0, 0, 60, 1020); } - gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); + gDPSetColor(pthis->dList++, G_SETPRIMCOLOR, pthis->color.rgba); - gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, + gDPLoadMultiTile_4b(pthis->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dList++, 16, 320, sGfxPrintRainbowTLUT); + gDPLoadTLUT(pthis->dList++, 16, 320, sGfxPrintRainbowTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, + gDPSetTile(pthis->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD); - gDPSetTileSize(this->dList++, i * 2 + 1, 0, 0, 4, 28); + gDPSetTileSize(pthis->dList++, i * 2 + 1, 0, 0, 4, 28); } } -void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a) { - this->color.r = r; - this->color.g = g; - this->color.b = b; - this->color.a = a; - gDPPipeSync(this->dList++); - gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); +void GfxPrint_SetColor(GfxPrint* pthis, u32 r, u32 g, u32 b, u32 a) { + pthis->color.r = r; + pthis->color.g = g; + pthis->color.b = b; + pthis->color.a = a; + gDPPipeSync(pthis->dList++); + gDPSetColor(pthis->dList++, G_SETPRIMCOLOR, pthis->color.rgba); } -void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y) { - this->posX = this->baseX + (x * 4); - this->posY = this->baseY + (y * 4); +void GfxPrint_SetPosPx(GfxPrint* pthis, s32 x, s32 y) { + pthis->posX = pthis->baseX + (x * 4); + pthis->posY = pthis->baseY + (y * 4); } -void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y) { - GfxPrint_SetPosPx(this, x * 8, y * 8); +void GfxPrint_SetPos(GfxPrint* pthis, s32 x, s32 y) { + GfxPrint_SetPosPx(pthis, x * 8, y * 8); } -void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) { - this->baseX = x * 4; - this->baseY = y * 4; +void GfxPrint_SetBasePosPx(GfxPrint* pthis, s32 x, s32 y) { + pthis->baseX = x * 4; + pthis->baseY = y * 4; } -void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) { +void GfxPrint_PrintCharImpl(GfxPrint* pthis, u8 c) { u32 tile = (c & 0xFF) * 2; - if (this->flags & GFXP_FLAG_UPDATE) { - this->flags &= ~GFXP_FLAG_UPDATE; + if (pthis->flags & GFXP_FLAG_UPDATE) { + pthis->flags &= ~GFXP_FLAG_UPDATE; - gDPPipeSync(this->dList++); - if (this->flags & GFXP_FLAG_RAINBOW) { - gDPSetTextureLUT(this->dList++, G_TT_RGBA16); - gDPSetCycleType(this->dList++, G_CYC_2CYCLE); - gDPSetRenderMode(this->dList++, G_RM_OPA_CI, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dList++, G_CC_INTERFERENCE, G_CC_PASS2); + gDPPipeSync(pthis->dList++); + if (pthis->flags & GFXP_FLAG_RAINBOW) { + gDPSetTextureLUT(pthis->dList++, G_TT_RGBA16); + gDPSetCycleType(pthis->dList++, G_CYC_2CYCLE); + gDPSetRenderMode(pthis->dList++, G_RM_OPA_CI, G_RM_XLU_SURF2); + gDPSetCombineMode(pthis->dList++, G_CC_INTERFERENCE, G_CC_PASS2); } else { - gDPSetTextureLUT(this->dList++, G_TT_IA16); - gDPSetCycleType(this->dList++, G_CYC_1CYCLE); - gDPSetRenderMode(this->dList++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dList++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); + gDPSetTextureLUT(pthis->dList++, G_TT_IA16); + gDPSetCycleType(pthis->dList++, G_CYC_1CYCLE); + gDPSetRenderMode(pthis->dList++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(pthis->dList++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); } } - if (this->flags & GFXP_FLAG_SHADOW) { - gDPSetColor(this->dList++, G_SETPRIMCOLOR, 0); + if (pthis->flags & GFXP_FLAG_SHADOW) { + gDPSetColor(pthis->dList++, G_SETPRIMCOLOR, 0); - if (this->flags & GFXP_FLAG_ENLARGE) { - gSPTextureRectangle(this->dList++, (this->posX + 4) << 1, (this->posY + 4) << 1, (this->posX + 4 + 32) << 1, - (this->posY + 4 + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9, + if (pthis->flags & GFXP_FLAG_ENLARGE) { + gSPTextureRectangle(pthis->dList++, (pthis->posX + 4) << 1, (pthis->posY + 4) << 1, (pthis->posX + 4 + 32) << 1, + (pthis->posY + 4 + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9, 1 << 9); } else { - gSPTextureRectangle(this->dList++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, + gSPTextureRectangle(pthis->dList++, pthis->posX + 4, pthis->posY + 4, pthis->posX + 4 + 32, pthis->posY + 4 + 32, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 10, 1 << 10); } - gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); + gDPSetColor(pthis->dList++, G_SETPRIMCOLOR, pthis->color.rgba); } - if (this->flags & GFXP_FLAG_ENLARGE) { - gSPTextureRectangle(this->dList++, (this->posX) << 1, (this->posY) << 1, (this->posX + 32) << 1, - (this->posY + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9, 1 << 9); + if (pthis->flags & GFXP_FLAG_ENLARGE) { + gSPTextureRectangle(pthis->dList++, (pthis->posX) << 1, (pthis->posY) << 1, (pthis->posX + 32) << 1, + (pthis->posY + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9, 1 << 9); } else { - gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, tile, + gSPTextureRectangle(pthis->dList++, pthis->posX, pthis->posY, pthis->posX + 32, pthis->posY + 32, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 10, 1 << 10); } - this->posX += 32; + pthis->posX += 32; } -void GfxPrint_PrintChar(GfxPrint* this, u8 c) { +void GfxPrint_PrintChar(GfxPrint* pthis, u8 c) { u8 charParam = c; if (c == ' ') { - this->posX += 32; + pthis->posX += 32; } else if (c > ' ' && c < 0x7F) { - GfxPrint_PrintCharImpl(this, charParam); + GfxPrint_PrintCharImpl(pthis, charParam); } else if (c >= 0xA0 && c < 0xE0) { - if (this->flags & GFXP_FLAG_HIRAGANA) { + if (pthis->flags & GFXP_FLAG_HIRAGANA) { if (c < 0xC0) { charParam = c - 0x20; } else { charParam = c + 0x20; } } - GfxPrint_PrintCharImpl(this, charParam); + GfxPrint_PrintCharImpl(pthis, charParam); } else { switch (c) { case '\0': break; case '\n': - this->posY += 32; + pthis->posY += 32; case '\r': - this->posX = this->baseX; + pthis->posX = pthis->baseX; break; case '\t': do { - GfxPrint_PrintCharImpl(this, ' '); - } while ((this->posX - this->baseX) % 256); + GfxPrint_PrintCharImpl(pthis, ' '); + } while ((pthis->posX - pthis->baseX) % 256); break; case GFXP_HIRAGANA_CHAR: - this->flags |= GFXP_FLAG_HIRAGANA; + pthis->flags |= GFXP_FLAG_HIRAGANA; break; case GFXP_KATAKANA_CHAR: - this->flags &= ~GFXP_FLAG_HIRAGANA; + pthis->flags &= ~GFXP_FLAG_HIRAGANA; break; case GFXP_RAINBOW_ON_CHAR: - this->flags |= GFXP_FLAG_RAINBOW; - this->flags |= GFXP_FLAG_UPDATE; + pthis->flags |= GFXP_FLAG_RAINBOW; + pthis->flags |= GFXP_FLAG_UPDATE; break; case GFXP_RAINBOW_OFF_CHAR: - this->flags &= ~GFXP_FLAG_RAINBOW; - this->flags |= GFXP_FLAG_UPDATE; + pthis->flags &= ~GFXP_FLAG_RAINBOW; + pthis->flags |= GFXP_FLAG_UPDATE; break; case GFXP_UNUSED_CHAR: default: @@ -295,87 +295,87 @@ void GfxPrint_PrintChar(GfxPrint* this, u8 c) { } } -void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, u32 charSize, u32 charCount) { +void GfxPrint_PrintStringWithSize(GfxPrint* pthis, const void* buffer, u32 charSize, u32 charCount) { const char* str = (const char*)buffer; u32 count = charSize * charCount; while (count != 0) { - GfxPrint_PrintChar(this, *(str++)); + GfxPrint_PrintChar(pthis, *(str++)); count--; } } -void GfxPrint_PrintString(GfxPrint* this, const char* str) { +void GfxPrint_PrintString(GfxPrint* pthis, const char* str) { while (*str != '\0') { - GfxPrint_PrintChar(this, *(str++)); + GfxPrint_PrintChar(pthis, *(str++)); } } void* GfxPrint_Callback(void* arg, const char* str, u32 size) { - GfxPrint* this = arg; + auto pthis = (GfxPrint*)arg; - GfxPrint_PrintStringWithSize(this, str, sizeof(char), size); + GfxPrint_PrintStringWithSize(pthis, str, sizeof(char), size); - return this; + return pthis; } -void GfxPrint_Init(GfxPrint* this) { - this->flags &= ~GFXP_FLAG_OPEN; +void GfxPrint_Init(GfxPrint* pthis) { + pthis->flags &= ~GFXP_FLAG_OPEN; - this->callback = GfxPrint_Callback; - this->dList = NULL; - this->posX = 0; - this->posY = 0; - this->baseX = 0; - this->baseY = 0; - this->color.rgba = 0; + pthis->callback = GfxPrint_Callback; + pthis->dList = NULL; + pthis->posX = 0; + pthis->posY = 0; + pthis->baseX = 0; + pthis->baseY = 0; + pthis->color.rgba = 0; - this->flags &= ~GFXP_FLAG_HIRAGANA; - this->flags &= ~GFXP_FLAG_RAINBOW; - this->flags |= GFXP_FLAG_SHADOW; - this->flags |= GFXP_FLAG_UPDATE; + pthis->flags &= ~GFXP_FLAG_HIRAGANA; + pthis->flags &= ~GFXP_FLAG_RAINBOW; + pthis->flags |= GFXP_FLAG_SHADOW; + pthis->flags |= GFXP_FLAG_UPDATE; if (sDefaultSpecialFlags & GFXP_FLAG_ENLARGE) { - this->flags |= GFXP_FLAG_ENLARGE; + pthis->flags |= GFXP_FLAG_ENLARGE; } else { - this->flags &= ~GFXP_FLAG_ENLARGE; + pthis->flags &= ~GFXP_FLAG_ENLARGE; } } -void GfxPrint_Destroy(GfxPrint* this) { +void GfxPrint_Destroy(GfxPrint* pthis) { } -void GfxPrint_Open(GfxPrint* this, Gfx* dList) { - if (!(this->flags & GFXP_FLAG_OPEN)) { - this->flags |= GFXP_FLAG_OPEN; - this->dList = dList; - GfxPrint_Setup(this); +void GfxPrint_Open(GfxPrint* pthis, Gfx* dList) { + if (!(pthis->flags & GFXP_FLAG_OPEN)) { + pthis->flags |= GFXP_FLAG_OPEN; + pthis->dList = dList; + GfxPrint_Setup(pthis); } else { osSyncPrintf("gfxprint_open:2重オープンです\n"); } } -Gfx* GfxPrint_Close(GfxPrint* this) { +Gfx* GfxPrint_Close(GfxPrint* pthis) { Gfx* ret; - this->flags &= ~GFXP_FLAG_OPEN; - gDPPipeSync(this->dList++); - ret = this->dList; - this->dList = NULL; + pthis->flags &= ~GFXP_FLAG_OPEN; + gDPPipeSync(pthis->dList++); + ret = pthis->dList; + pthis->dList = NULL; return ret; } -s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { - return PrintUtils_VPrintf(&this->callback, fmt, args); +s32 GfxPrint_VPrintf(GfxPrint* pthis, const char* fmt, va_list args) { + return PrintUtils_VPrintf(&pthis->callback, fmt, args); } -s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { +s32 GfxPrint_Printf(GfxPrint* pthis, const char* fmt, ...) { s32 ret; va_list args = 0; va_start(args, fmt); - ret = GfxPrint_VPrintf(this, fmt, args); + ret = GfxPrint_VPrintf(pthis, fmt, args); va_end(args); diff --git a/src/code/graph.c b/src/code/graph.cpp similarity index 96% rename from src/code/graph.c rename to src/code/graph.cpp index 07d303433..b01a535b4 100644 --- a/src/code/graph.c +++ b/src/code/graph.cpp @@ -12,6 +12,7 @@ #include "title_setup.h" #include "z_title.h" #include "gfx.h" +#include "gfxapi.h" #include "sched.h" #include "z64save.h" #include "speedmeter.h" @@ -29,7 +30,6 @@ #include "def/logutils.h" #include "def/sched.h" #include "def/speed_meter.h" -#include "def/sprintf.h" #include "def/sys_ucode.h" #include "def/system_malloc.h" #include "def/z_DLF.h" @@ -52,12 +52,6 @@ FaultClient sGraphUcodeFaultClient; uintptr_t SysCfb_GetFbPtr(s32 idx); -bool gfx_start_frame(); -void gfx_end_frame(); -void gfx_fbe_sync(GraphicsContext* gfxCtx, GameInfo* GameInfo); -int gfx_fbe_is_enabled(); -void gfx_fbe_enable(int enable); - bool isRunning(); void Graph_DisassembleUCode(Gfx* workBuf) { @@ -271,7 +265,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { if (HREG(80) == 7 && HREG(81) != 0) { if (HREG(82) == 3) { - Fault_AddClient(&sGraphUcodeFaultClient, Graph_UCodeFaultClient, gfxCtx->workBuffer, "do_count_fault"); + Fault_AddClient(&sGraphUcodeFaultClient, Graph_UCodeFaultClient, gfxCtx->workBuffer, (void*)"do_count_fault"); } Graph_DisassembleUCode(gfxCtx->workBuffer); @@ -390,16 +384,13 @@ void Graph_ThreadEntry(void* arg0) { size = ovl->instanceSize; osSyncPrintf("Class size = %d bytes\n", size); // "Class size = %d bytes" - gameState = SystemArena_MallocDebug(size * 2, "../graph.c", 1196); + gameState = (GameState*)SystemArena_MallocDebug(size * 2, "../graph.c", 1196); memset(gameState, 0, size * 2); if (!gameState) { osSyncPrintf("Failure to secure\n"); // "Failure to secure" - - sprintf(faultMsg, "CLASS SIZE= %d bytes", size); - Fault_AddHungupAndCrashImpl("GAME CLASS MALLOC FAILED", faultMsg); } - GameState_Init(gameState, ovl->init, &gfxCtx); + GameState_Init(gameState, (GameStateFunc)ovl->init, &gfxCtx); while (GameState_IsRunning(gameState) && isRunning()) { if(gfx_start_frame()) diff --git a/src/code/irqmgr.c b/src/code/irqmgr.cpp similarity index 52% rename from src/code/irqmgr.c rename to src/code/irqmgr.cpp index 086d3d8de..40415f73c 100644 --- a/src/code/irqmgr.c +++ b/src/code/irqmgr.cpp @@ -21,38 +21,38 @@ u32 sIrqMgrRetraceCount = 0; #define STATUS_PRENMI 1 #define STATUS_NMI 2 -void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) { +void IrqMgr_AddClient(IrqMgr* pthis, IrqMgrClient* c, OSMesgQueue* msgQ) { } -void IrqMgr_RemoveClient(IrqMgr* this, IrqMgrClient* c) { +void IrqMgr_RemoveClient(IrqMgr* pthis, IrqMgrClient* c) { } -void IrqMgr_SendMesgForClient(IrqMgr* this, OSMesg msg) { +void IrqMgr_SendMesgForClient(IrqMgr* pthis, OSMesg msg) { } -void IrqMgr_JamMesgForClient(IrqMgr* this, OSMesg msg) { +void IrqMgr_JamMesgForClient(IrqMgr* pthis, OSMesg msg) { } -void IrqMgr_HandlePreNMI(IrqMgr* this) { +void IrqMgr_HandlePreNMI(IrqMgr* pthis) { } void IrqMgr_CheckStack() { } -void IrqMgr_HandlePRENMI450(IrqMgr* this) { +void IrqMgr_HandlePRENMI450(IrqMgr* pthis) { } -void IrqMgr_HandlePRENMI480(IrqMgr* this) { +void IrqMgr_HandlePRENMI480(IrqMgr* pthis) { } -void IrqMgr_HandlePRENMI500(IrqMgr* this) { +void IrqMgr_HandlePRENMI500(IrqMgr* pthis) { } -void IrqMgr_HandleRetrace(IrqMgr* this) { +void IrqMgr_HandleRetrace(IrqMgr* pthis) { } void IrqMgr_ThreadEntry(void* arg0) { } -void IrqMgr_Init(IrqMgr* this, void* stack, OSPri pri, u8 retraceCount) { +void IrqMgr_Init(IrqMgr* pthis, void* stack, OSPri pri, u8 retraceCount) { } diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.cpp similarity index 98% rename from src/code/jpegdecoder.c rename to src/code/jpegdecoder.cpp index 62387c658..dfdff9e69 100644 --- a/src/code/jpegdecoder.c +++ b/src/code/jpegdecoder.cpp @@ -24,7 +24,7 @@ s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollo JpegHuffmanTable* hTable3; inc = 0; - sJpegBitStreamPtr = decoder->imageData; + sJpegBitStreamPtr = (u8*)decoder->imageData; if (decoder->mode == 0) { unkCount = 2; } else { diff --git a/src/code/jpegutils.c b/src/code/jpegutils.cpp similarity index 100% rename from src/code/jpegutils.c rename to src/code/jpegutils.cpp diff --git a/src/code/listalloc.c b/src/code/listalloc.c deleted file mode 100644 index e6a6d00c6..000000000 --- a/src/code/listalloc.c +++ /dev/null @@ -1,66 +0,0 @@ -#define INTERNAL_SRC_CODE_LISTALLOC_C -#include "global.h" -#include "listalloc.h" -#include "def/listalloc.h" -#include "def/system_malloc.h" - -ListAlloc* ListAlloc_Init(ListAlloc* this) { - this->prev = NULL; - this->next = NULL; - return this; -} - -void* ListAlloc_Alloc(ListAlloc* this, u32 size) { - ListAlloc* ptr = SystemArena_MallocDebug(size + sizeof(ListAlloc), "../listalloc.c", 40); - ListAlloc* next; - - if (ptr == NULL) { - return NULL; - } - - next = this->next; - if (next != NULL) { - next->next = ptr; - } - - ptr->prev = next; - ptr->next = NULL; - this->next = ptr; - - if (this->prev == NULL) { - this->prev = ptr; - } - - return (u8*)ptr + sizeof(ListAlloc); -} - -void ListAlloc_Free(ListAlloc* this, void* data) { - ListAlloc* ptr = &((ListAlloc*)data)[-1]; - - if (ptr->prev != NULL) { - ptr->prev->next = ptr->next; - } - - if (ptr->next != NULL) { - ptr->next->prev = ptr->prev; - } - - if (this->prev == ptr) { - this->prev = ptr->next; - } - - if (this->next == ptr) { - this->next = ptr->prev; - } - - SystemArena_FreeDebug(ptr, "../listalloc.c", 72); -} - -void ListAlloc_FreeAll(ListAlloc* this) { - ListAlloc* iter = this->prev; - - while (iter != NULL) { - ListAlloc_Free(this, (u8*)iter + sizeof(ListAlloc)); - iter = this->prev; - } -} diff --git a/src/code/listalloc.cpp b/src/code/listalloc.cpp new file mode 100644 index 000000000..30ddf2fd6 --- /dev/null +++ b/src/code/listalloc.cpp @@ -0,0 +1,66 @@ +#define INTERNAL_SRC_CODE_LISTALLOC_C +#include "global.h" +#include "listalloc.h" +#include "def/listalloc.h" +#include "def/system_malloc.h" + +ListAlloc* ListAlloc_Init(ListAlloc* pthis) { + pthis->prev = NULL; + pthis->next = NULL; + return pthis; +} + +void* ListAlloc_Alloc(ListAlloc* pthis, u32 size) { + ListAlloc* ptr = (ListAlloc*)SystemArena_MallocDebug(size + sizeof(ListAlloc), "../listalloc.c", 40); + ListAlloc* next; + + if (ptr == NULL) { + return NULL; + } + + next = pthis->next; + if (next != NULL) { + next->next = ptr; + } + + ptr->prev = next; + ptr->next = NULL; + pthis->next = ptr; + + if (pthis->prev == NULL) { + pthis->prev = ptr; + } + + return (u8*)ptr + sizeof(ListAlloc); +} + +void ListAlloc_Free(ListAlloc* pthis, void* data) { + ListAlloc* ptr = &((ListAlloc*)data)[-1]; + + if (ptr->prev != NULL) { + ptr->prev->next = ptr->next; + } + + if (ptr->next != NULL) { + ptr->next->prev = ptr->prev; + } + + if (pthis->prev == ptr) { + pthis->prev = ptr->next; + } + + if (pthis->next == ptr) { + pthis->next = ptr->prev; + } + + SystemArena_FreeDebug(ptr, "../listalloc.c", 72); +} + +void ListAlloc_FreeAll(ListAlloc* pthis) { + ListAlloc* iter = pthis->prev; + + while (iter != NULL) { + ListAlloc_Free(pthis, (u8*)iter + sizeof(ListAlloc)); + iter = pthis->prev; + } +} diff --git a/src/code/logseverity.c b/src/code/logseverity.cpp similarity index 100% rename from src/code/logseverity.c rename to src/code/logseverity.cpp diff --git a/src/code/mempak.c b/src/code/mempak.cpp similarity index 100% rename from src/code/mempak.c rename to src/code/mempak.cpp diff --git a/src/code/mtxuty-cvt.c b/src/code/mtxuty-cvt.cpp similarity index 100% rename from src/code/mtxuty-cvt.c rename to src/code/mtxuty-cvt.cpp diff --git a/src/code/padmgr.c b/src/code/padmgr.cpp similarity index 98% rename from src/code/padmgr.c rename to src/code/padmgr.cpp index cc7cf306f..2ba11e308 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.cpp @@ -6,8 +6,11 @@ #include "def/padmgr.h" #include "def/padutils.h" -void hid_init(); -void hid_update(); +extern "C" +{ + void hid_init(); + void hid_update(); +} s32 D_8012D280 = 1; diff --git a/src/code/padsetup.c b/src/code/padsetup.cpp similarity index 100% rename from src/code/padsetup.c rename to src/code/padsetup.cpp diff --git a/src/code/padutils.c b/src/code/padutils.cpp similarity index 100% rename from src/code/padutils.c rename to src/code/padutils.cpp diff --git a/src/code/printutils.c b/src/code/printutils.cpp similarity index 100% rename from src/code/printutils.c rename to src/code/printutils.cpp diff --git a/src/code/sched.c b/src/code/sched.cpp similarity index 100% rename from src/code/sched.c rename to src/code/sched.cpp diff --git a/src/code/shrink_window.c b/src/code/shrink_window.cpp similarity index 100% rename from src/code/shrink_window.c rename to src/code/shrink_window.cpp diff --git a/src/code/sleep.c b/src/code/sleep.cpp similarity index 100% rename from src/code/sleep.c rename to src/code/sleep.cpp diff --git a/src/code/speed_meter.c b/src/code/speed_meter.cpp similarity index 84% rename from src/code/speed_meter.c rename to src/code/speed_meter.cpp index 83b0c730b..775b1758c 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.cpp @@ -43,20 +43,20 @@ SpeedMeterTimeEntry sSpeedMeterTimeEntryArray[] = { gDPFillRectangle(gfx, (ulx), (uly), (lrx), (lry)); \ gDPPipeSync(gfx); -void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y) { - LogUtils_CheckNullPointer("this", this, "../speed_meter.c", 181); - this->unk_18 = arg1; - this->y = y; +void SpeedMeter_InitImpl(SpeedMeter* pthis, u32 arg1, u32 y) { + LogUtils_CheckNullPointer("pthis", pthis, "../speed_meter.c", 181); + pthis->unk_18 = arg1; + pthis->y = y; } -void SpeedMeter_Init(SpeedMeter* this) { - SpeedMeter_InitImpl(this, 32, 22); +void SpeedMeter_Init(SpeedMeter* pthis) { + SpeedMeter_InitImpl(pthis, 32, 22); } -void SpeedMeter_Destroy(SpeedMeter* this) { +void SpeedMeter_Destroy(SpeedMeter* pthis) { } -void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) { +void SpeedMeter_DrawTimeEntries(SpeedMeter* pthis, GraphicsContext* gfxCtx) { s32 pad[2]; u32 baseX = 32; s32 temp; @@ -67,8 +67,8 @@ void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) { u32 pad2[3]; Gfx* gfx; - uly = this->y; - lry = this->y + 2; + uly = pthis->y; + lry = pthis->y + 2; OPEN_DISPS(gfxCtx, "../speed_meter.c", 225); @@ -116,26 +116,26 @@ void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../speed_meter.c", 276); } -void SpeedMeter_InitAllocEntry(SpeedMeterAllocEntry* this, u32 maxval, u32 val, u16 backColor, u16 foreColor, u32 ulx, +void SpeedMeter_InitAllocEntry(SpeedMeterAllocEntry* pthis, u32 maxval, u32 val, u16 backColor, u16 foreColor, u32 ulx, u32 lrx, u32 uly, u32 lry) { - this->maxval = maxval; - this->val = val; - this->backColor = backColor; - this->foreColor = foreColor; - this->ulx = ulx; - this->lrx = lrx; - this->uly = uly; - this->lry = lry; + pthis->maxval = maxval; + pthis->val = val; + pthis->backColor = backColor; + pthis->foreColor = foreColor; + pthis->ulx = ulx; + pthis->lrx = lrx; + pthis->uly = uly; + pthis->lry = lry; } -void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxCtx) { +void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* pthis, GraphicsContext* gfxCtx) { s32 usedOff; View view; Gfx* gfx; - if (this->maxval == 0) { + if (pthis->maxval == 0) { osSyncPrintf(VT_FGCOL(RED)); - LOG_NUM("this->maxval", this->maxval, "../speed_meter.c", 313); + LOG_NUM("pthis->maxval", pthis->maxval, "../speed_meter.c", 313); osSyncPrintf(VT_RST); } else { OPEN_DISPS(gfxCtx, "../speed_meter.c", 318); @@ -154,9 +154,9 @@ void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxC G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - usedOff = ((this->lrx - this->ulx) * this->val) / this->maxval + this->ulx; - DrawRec(gfx++, this->backColor, usedOff, this->uly, this->lrx, this->lry); - DrawRec(gfx++, this->foreColor, this->ulx, this->uly, usedOff, this->lry); + usedOff = ((pthis->lrx - pthis->ulx) * pthis->val) / pthis->maxval + pthis->ulx; + DrawRec(gfx++, pthis->backColor, usedOff, pthis->uly, pthis->lrx, pthis->lry); + DrawRec(gfx++, pthis->foreColor, pthis->ulx, pthis->uly, usedOff, pthis->lry); gDPPipeSync(gfx++); diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.cpp similarity index 100% rename from src/code/sys_cfb.c rename to src/code/sys_cfb.cpp diff --git a/src/code/sys_math.c b/src/code/sys_math.cpp similarity index 100% rename from src/code/sys_math.c rename to src/code/sys_math.cpp diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.cpp similarity index 100% rename from src/code/sys_math3d.c rename to src/code/sys_math3d.cpp diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.cpp similarity index 100% rename from src/code/sys_math_atan.c rename to src/code/sys_math_atan.cpp diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.cpp similarity index 98% rename from src/code/sys_matrix.c rename to src/code/sys_matrix.cpp index f203deab8..3e441c1a7 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.cpp @@ -8,11 +8,9 @@ #include "z64memory.h" #include "z64skinmatrix.h" #include "def/code_800FCE80.h" -#include "def/cosf.h" #include "def/game.h" #include "def/graph.h" #include "def/mtxf2l.h" -#include "def/sinf.h" #include "def/sys_matrix.h" #include "def/z_lib.h" #include "def/z_skin_matrix.h" @@ -38,7 +36,7 @@ MtxF* sMatrixStack; // "Matrix_stack" MtxF* sCurrentMatrix; // "Matrix_now" void Matrix_Init(GameState* gameState) { - sCurrentMatrix = GameState_Alloc(gameState, 20 * sizeof(MtxF), "../sys_matrix.c", 153); + sCurrentMatrix = (MtxF*)GameState_Alloc(gameState, 20 * sizeof(MtxF), "../sys_matrix.c", 153); sMatrixStack = sCurrentMatrix; } @@ -618,16 +616,16 @@ Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) { return dest; } -Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line) { - return Matrix_MtxFToMtx(Matrix_CheckFloats(sCurrentMatrix, file, line), dest); +Mtx* Matrix_ToMtx(Mtx* dest, const char* file, s32 line) { + return Matrix_MtxFToMtx(sCurrentMatrix, dest); } -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line) { - return Matrix_ToMtx(Graph_Alloc(gfxCtx, sizeof(Mtx)), file, line); +Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, s32 line) { + return Matrix_ToMtx((Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)), file, line); } Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) { - return Matrix_MtxFToMtx(src, Graph_Alloc(gfxCtx, sizeof(Mtx))); + return Matrix_MtxFToMtx(src, (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx))); } void Matrix_MultVec3f(Vec3f* src, Vec3f* dest) { diff --git a/src/code/sys_ucode.c b/src/code/sys_ucode.cpp similarity index 94% rename from src/code/sys_ucode.c rename to src/code/sys_ucode.cpp index 79a623fc7..147ba7da6 100644 --- a/src/code/sys_ucode.c +++ b/src/code/sys_ucode.cpp @@ -7,7 +7,7 @@ u64* D_8012DBA0 = (u64*)&D_80155F50; u64* D_8012DBA4 = (u64*)&D_80157580; u64* SysUcode_GetUCodeBoot(void) { - return &D_80009320; + return (u64*)&D_80009320; } u64 SysUcode_GetUCodeBootSize(void) { diff --git a/src/code/system_malloc.c b/src/code/system_malloc.cpp similarity index 100% rename from src/code/system_malloc.c rename to src/code/system_malloc.cpp diff --git a/src/code/title_setup.c b/src/code/title_setup.cpp similarity index 100% rename from src/code/title_setup.c rename to src/code/title_setup.cpp diff --git a/src/code/z_DLF.c b/src/code/z_DLF.cpp similarity index 100% rename from src/code/z_DLF.c rename to src/code/z_DLF.cpp diff --git a/src/code/z_actor.c b/src/code/z_actor.cpp similarity index 98% rename from src/code/z_actor.c rename to src/code/z_actor.cpp index ef4d537b6..a3ea68c48 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.cpp @@ -24,12 +24,10 @@ #include "def/code_800FC620.h" #include "def/code_800FCE80.h" #include "def/code_800FD970.h" -#include "def/cosf.h" #include "def/fault.h" #include "def/fault_drawer.h" #include "def/graph.h" #include "def/lookathil.h" -#include "def/sinf.h" #include "def/sys_math.h" #include "def/sys_math_atan.h" #include "def/sys_matrix.h" @@ -727,7 +725,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, s32 width, s32 height, s32 delay) { SceneTableEntry* loadedScene = globalCtx->loadedScene; - size_t size = POINTER_SUB(loadedScene->titleFile.vromEnd, loadedScene->titleFile.vromStart); + size_t size = (loadedScene->titleFile.vromEnd - loadedScene->titleFile.vromStart).size(); if ((size != 0) && (size <= 0x3000)) { DmaMgr_SendRequest1(texture, loadedScene->titleFile.vromStart, size, "../z_actor.c", 2765); @@ -849,7 +847,7 @@ void Actor_SetScale(Actor* actor, f32 scale) { } void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) { - gSegments[6] = gObjectTable[actor->objBankIndex].vromStart; + gSegments[6] = gObjectTable[actor->objBankIndex].vromStart.get(); } void Actor_Init(Actor* actor, GlobalContext* globalCtx) { @@ -877,7 +875,7 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { void Actor_Destroy(Actor* actor, GlobalContext* globalCtx) { ActorOverlay* overlayEntry; - char* name; + const char* name; if (actor->destroy != NULL) { actor->destroy(actor, globalCtx); @@ -1357,14 +1355,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe Mtx D_8015BBA8; Gfx* func_8002E830(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx, Gfx* gfx, Hilite** hilite) { - LookAt* lookAt; - f32 correctedEyeX; + LookAt* lookAt = (LookAt*)Graph_Alloc(gfxCtx, sizeof(LookAt)); + f32 correctedEyeX = (eye->x == object->x) && (eye->z == object->z) ? eye->x + 0.001f : eye->x; - lookAt = Graph_Alloc(gfxCtx, sizeof(LookAt)); - - correctedEyeX = (eye->x == object->x) && (eye->z == object->z) ? eye->x + 0.001f : eye->x; - - *hilite = Graph_Alloc(gfxCtx, sizeof(Hilite)); + *hilite = (Hilite*)Graph_Alloc(gfxCtx, sizeof(Hilite)); if (HREG(80) == 6) { osSyncPrintf("z_actor.c 3529 eye=[%f(%f) %f %f] object=[%f %f %f] light_direction=[%f %f %f]\n", correctedEyeX, @@ -1424,7 +1418,7 @@ void func_8002EBCC(Actor* actor, GlobalContext* globalCtx, s32 flag) { hilite = func_8002EABC(&actor->world.pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); if (flag != 0) { - displayList = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 4384); @@ -1450,7 +1444,7 @@ void func_8002ED80(Actor* actor, GlobalContext* globalCtx, s32 flag) { hilite = func_8002EB44(&actor->world.pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); if (flag != 0) { - displayList = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 4429); @@ -2186,7 +2180,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { void Actor_FaultPrint(Actor* actor, char* command) { ActorOverlay* overlayEntry; - char* name; + const char* name; if ((actor == NULL) || (actor->overlayEntry == NULL)) { FaultDrawer_SetCursor(48, 24); @@ -2210,8 +2204,6 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { FaultClient faultClient; Lights* lights; - Fault_AddClient(&faultClient, Actor_FaultPrint, actor, "Actor_draw"); - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 6035); lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); @@ -2232,8 +2224,8 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); Actor_SetObjectDependency(globalCtx, actor); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[actor->objBankIndex].vromStart); - gSPSegment(POLY_XLU_DISP++, 0x06, gObjectTable[actor->objBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[actor->objBankIndex].vromStart.get()); + gSPSegment(POLY_XLU_DISP++, 0x06, gObjectTable[actor->objBankIndex].vromStart.get()); if (actor->colorFilterTimer != 0) { Color_RGBA8 color = { 0, 0, 0, 255 }; @@ -2417,7 +2409,7 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { while (actor != NULL) { ActorOverlay* overlayEntry = actor->overlayEntry; - char* actorName = overlayEntry->name != NULL ? overlayEntry->name : ""; + const char* actorName = overlayEntry->name != NULL ? overlayEntry->name : ""; gDPNoOpString(POLY_OPA_DISP++, actorName, i); gDPNoOpString(POLY_XLU_DISP++, actorName, i); @@ -2636,7 +2628,7 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { osSyncPrintf("Actor client is now 0\n"); // "Actor client is now 0" } - if (actorOverlay->loadedRamAddr != NULL) { + if (actorOverlay->loadedRamAddr.buffer() != NULL) { if (actorOverlay->allocType & ALLOCTYPE_PERMANENT) { if (HREG(20) != 0) { osSyncPrintf("Overlay will not be deallocated\n"); // "Overlay will not be deallocated" @@ -2651,7 +2643,7 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { if (HREG(20) != 0) { osSyncPrintf("Overlay deallocated\n"); // "Overlay deallocated" } - ZeldaArena_FreeDebug(actorOverlay->loadedRamAddr, "../z_actor.c", 6834); + ZeldaArena_FreeDebug(actorOverlay->loadedRamAddr.buffer(), "../z_actor.c", 6834); actorOverlay->loadedRamAddr = NULL; } } @@ -2671,7 +2663,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId s32 objBankIndex; ActorOverlay* overlayEntry; uintptr_t temp; - char* name; + const char* name; overlayEntry = &gActorOverlayTable[actorId]; ASSERT(actorId < ACTOR_ID_MAX, "profile < ACTOR_DLF_MAX", "../z_actor.c", 6883); @@ -2689,14 +2681,14 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId return NULL; } - if (overlayEntry->vramStart == 0) { + if (overlayEntry->vramStart.buffer() == 0) { if (HREG(20) != 0) { osSyncPrintf("Not an overlay\n"); // "Not an overlay" } actorInit = overlayEntry->initInfo; } else { - if (overlayEntry->loadedRamAddr != NULL) { + if (overlayEntry->loadedRamAddr.buffer() != NULL) { if (HREG(20) != 0) { osSyncPrintf("Already loaded\n"); // "Already loaded" } @@ -2725,15 +2717,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId return NULL; } - Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd, - overlayEntry->loadedRamAddr); - - osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("OVL(a):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", overlayEntry->vramStart, - overlayEntry->vramEnd, overlayEntry->loadedRamAddr, - (uintptr_t)overlayEntry->loadedRamAddr + (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart, - (uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr, name); - osSyncPrintf(VT_RST); + Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd, overlayEntry->loadedRamAddr); overlayEntry->numLoaded = 0; } @@ -2763,7 +2747,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId return NULL; } - actor = ZeldaArena_MallocDebug(actorInit->instanceSize, name, 1); + actor = (Actor*)ZeldaArena_MallocDebug(actorInit->instanceSize, name, 1); if (actor == NULL) { // "Actor class cannot be reserved! %s " @@ -2867,7 +2851,7 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalCo } Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx) { - char* name; + const char* name; Player* player; Actor* newHead; ActorOverlay* overlayEntry; @@ -3081,15 +3065,15 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, GlobalContext* globalCtx) u32 objectIdsSize; matricesSize = (count + 1) * sizeof(*bodyBreak->matrices); - bodyBreak->matrices = ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540); + bodyBreak->matrices = (MtxF*)ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540); if (bodyBreak->matrices != NULL) { dListsSize = (count + 1) * sizeof(*bodyBreak->dLists); - bodyBreak->dLists = ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543); + bodyBreak->dLists = (Gfx**)ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543); if (bodyBreak->dLists != NULL) { objectIdsSize = (count + 1) * sizeof(*bodyBreak->objectIds); - bodyBreak->objectIds = ZeldaArena_MallocDebug(objectIdsSize, "../z_actor.c", 7546); + bodyBreak->objectIds = (s16*)ZeldaArena_MallocDebug(objectIdsSize, "../z_actor.c", 7546); if (bodyBreak->objectIds != NULL) { Lib_MemSet((u8*)bodyBreak->matrices, matricesSize, 0); @@ -3839,7 +3823,7 @@ void func_80034A14(Actor* actor, struct_80034A14_arg1* arg1, s16 arg2, s16 arg3) Gfx* func_80034B28(GraphicsContext* gfxCtx) { Gfx* displayList; - displayList = Graph_Alloc(gfxCtx, sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); gSPEndDisplayList(displayList); return displayList; @@ -3849,7 +3833,7 @@ Gfx* func_80034B54(GraphicsContext* gfxCtx) { Gfx* displayListHead; Gfx* displayList; - displayList = displayListHead = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + displayList = displayListHead = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); gDPSetRenderMode(displayListHead++, G_RM_FOG_SHADE_A, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | @@ -3972,7 +3956,7 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) { return ret; } -#include "z_cheap_proc.c" +#include "z_cheap_proc.cpp" u8 func_800353E8(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); @@ -4156,7 +4140,7 @@ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, if (spawnedEnPart != NULL) { spawnedEnPart->actor.scale = actor->scale; spawnedEnPart->actor.speedXZ = arg3[0]; - spawnedEnPart->displayList = arg8; + spawnedEnPart->displayList = (Gfx*)arg8; spawnedEnPart->action = 2; spawnedEnPart->timer = timer; spawnedEnPart->rotZ = arg3[1]; diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.cpp similarity index 77% rename from src/code/z_actor_dlftbls.c rename to src/code/z_actor_dlftbls.cpp index aedd2b07b..2980a6a36 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.cpp @@ -73,23 +73,6 @@ void ActorOverlayTable_LogPrint(void) { } void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { - ActorOverlay* overlayEntry; - u32 overlaySize; - s32 i; - - FaultDrawer_SetCharPad(-2, 0); - - FaultDrawer_Printf("actor_dlftbls %u\n", gMaxActorId); - FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n"); - - for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { - overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; - if (overlayEntry->loadedRamAddr != NULL) { - FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, - (uintptr_t)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, - overlayEntry->name != NULL ? overlayEntry->name : ""); - } - } } void ActorOverlayTable_Init(void) { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.cpp similarity index 98% rename from src/code/z_bgcheck.c rename to src/code/z_bgcheck.cpp index 695dcf790..9a4f05914 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.cpp @@ -56,7 +56,7 @@ u16 D_80119E10[14] = { /** * original name: T_BGCheck_PosErrorCheck */ -s32 BgCheck_PosErrorCheck(Vec3f* pos, char* file, s32 line) { +static s32 BgCheck_PosErrorCheck(Vec3f* pos, const char* file, s32 line) { if (pos->x >= BGCHECK_XYZ_ABSMAX || pos->x <= -BGCHECK_XYZ_ABSMAX || pos->y >= BGCHECK_XYZ_ABSMAX || pos->y <= -BGCHECK_XYZ_ABSMAX || pos->z >= BGCHECK_XYZ_ABSMAX || pos->z <= -BGCHECK_XYZ_ABSMAX) { osSyncPrintf(VT_FGCOL(RED)); @@ -117,7 +117,7 @@ void DynaSSNodeList_Initialize(GlobalContext* globalCtx, DynaSSNodeList* nodeLis * Initialize DynaSSNodeList tbl */ void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* nodeList, s32 max) { - nodeList->tbl = THA_AllocEndAlign(&globalCtx->state.tha, max * sizeof(SSNode), -2); + nodeList->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.tha, max * sizeof(SSNode), -2); ASSERT(nodeList->tbl != NULL, "psst->tbl != NULL", "../z_bgcheck.c", 1811); @@ -173,7 +173,7 @@ s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vtxList) { s32 c; s16 min; - //! @bug Due to rounding errors, some polys with a slight slope have a y normal of 1.0f/-1.0f. As such, this + //! @bug Due to rounding errors, some polys with a slight slope have a y normal of 1.0f/-1.0f. As such, pthis //! optimization returns the wrong minimum y for a subset of these polys. if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) { return vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].y; @@ -1579,7 +1579,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis colCtx->subdivAmount.z = 16; } } - colCtx->lookupTbl = THA_AllocEndAlign( + colCtx->lookupTbl = (StaticLookup*)THA_AllocEndAlign( &globalCtx->state.tha, colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1); if (colCtx->lookupTbl == NULL) { @@ -1603,7 +1603,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis sizeof(CollisionContext); if (customNodeListMax > 0) { // tblMax is set without checking if customNodeListMax will result in a memory overflow - // this is a non-issue as long as sceneSubdivisionList.nodeListMax is -1 + // pthis is a non-issue as long as sceneSubdivisionList.nodeListMax is -1 tblMax = customNodeListMax; } else { if (colCtx->memSize < memSize) { @@ -2414,11 +2414,11 @@ s32 BgCheck_SphVsFirstWall(CollisionContext* colCtx, Vec3f* center, f32 radius) /** * Init SSNodeList */ -void SSNodeList_Initialize(SSNodeList* this) { - this->max = 0; - this->count = 0; - this->tbl = NULL; - this->polyCheckTbl = NULL; +void SSNodeList_Initialize(SSNodeList* pthis) { + pthis->max = 0; + pthis->count = 0; + pthis->tbl = NULL; + pthis->polyCheckTbl = NULL; } /** @@ -2426,28 +2426,28 @@ void SSNodeList_Initialize(SSNodeList* this) { * tblMax is the number of SSNode records to allocate * numPolys is the number of polygons defined within the CollisionHeader */ -void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys) { - this->max = tblMax; - this->count = 0; - this->tbl = THA_AllocEndAlign(&globalCtx->state.tha, tblMax * sizeof(SSNode), -2); +void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* pthis, s32 tblMax, s32 numPolys) { + pthis->max = tblMax; + pthis->count = 0; + pthis->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.tha, tblMax * sizeof(SSNode), -2); - ASSERT(this->tbl != NULL, "this->short_slist_node_tbl != NULL", "../z_bgcheck.c", 5975); + ASSERT(pthis->tbl != NULL, "pthis->short_slist_node_tbl != NULL", "../z_bgcheck.c", 5975); - this->polyCheckTbl = GameState_Alloc(&globalCtx->state, numPolys, "../z_bgcheck.c", 5979); + pthis->polyCheckTbl = (u8*)GameState_Alloc(&globalCtx->state, numPolys, "../z_bgcheck.c", 5979); - ASSERT(this->polyCheckTbl != NULL, "this->polygon_check != NULL", "../z_bgcheck.c", 5981); + ASSERT(pthis->polyCheckTbl != NULL, "pthis->polygon_check != NULL", "../z_bgcheck.c", 5981); } /** * Get next SSNodeList SSNode */ -SSNode* SSNodeList_GetNextNode(SSNodeList* this) { - SSNode* result = &this->tbl[this->count]; +SSNode* SSNodeList_GetNextNode(SSNodeList* pthis) { + SSNode* result = &pthis->tbl[pthis->count]; - this->count++; - ASSERT(this->count < this->max, "this->short_slist_node_last_index < this->short_slist_node_size", "../z_bgcheck.c", + pthis->count++; + ASSERT(pthis->count < pthis->max, "pthis->short_slist_node_last_index < pthis->short_slist_node_size", "../z_bgcheck.c", 5998); - if (!(this->count < this->max)) { + if (!(pthis->count < pthis->max)) { return NULL; } return result; @@ -2456,10 +2456,10 @@ SSNode* SSNodeList_GetNextNode(SSNodeList* this) { /** * Get next SSNodeList SSNode index */ -u16 SSNodeList_GetNextNodeIdx(SSNodeList* this) { - u16 new_index = this->count++; +u16 SSNodeList_GetNextNodeIdx(SSNodeList* pthis) { + u16 new_index = pthis->count++; - ASSERT(new_index < this->max, "new_index < this->short_slist_node_size", "../z_bgcheck.c", 6021); + ASSERT(new_index < pthis->max, "new_index < pthis->short_slist_node_size", "../z_bgcheck.c", 6021); return new_index; } @@ -2564,7 +2564,7 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) { * Allocate dyna.polyList */ void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) { - *polyList = THA_AllocEndAlign(&globalCtx->state.tha, numPolys * sizeof(CollisionPoly), -2); + *polyList = (CollisionPoly*)THA_AllocEndAlign(&globalCtx->state.tha, numPolys * sizeof(CollisionPoly), -2); ASSERT(*polyList != NULL, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6247); } @@ -2579,7 +2579,7 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) { * Allocate dyna.vtxList */ void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) { - *vtxList = THA_AllocEndAlign(&globalCtx->state.tha, numVtx * sizeof(Vec3s), -2); + *vtxList = (Vec3s*)THA_AllocEndAlign(&globalCtx->state.tha, numVtx * sizeof(Vec3s), -2); ASSERT(*vtxList != NULL, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6277); } @@ -2883,7 +2883,7 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 *newPoly = pbgdata->polyList[i]; - // Yeah, this is all kinds of fake, but my God, it matches. + // Yeah, pthis is all kinds of fake, but my God, it matches. newPoly->flags_vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) | ((*newPoly).flags_vIA & 0xE000); newPoly->flags_vIB = @@ -3783,18 +3783,18 @@ s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionP * SEGMENTED_TO_VIRTUAL CollisionHeader members */ void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) { - colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); - colHeader->polyList = SEGMENTED_TO_VIRTUAL(colHeader->polyList); - colHeader->surfaceTypeList = SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList); - colHeader->cameraDataList = SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList); - colHeader->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes); + colHeader->vtxList = (Vec3s*)SEGMENTED_TO_VIRTUAL(colHeader->vtxList); + colHeader->polyList = (CollisionPoly*)SEGMENTED_TO_VIRTUAL(colHeader->polyList); + colHeader->surfaceTypeList = (SurfaceType*)SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList); + colHeader->cameraDataList = (CamData*)SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList); + colHeader->waterBoxes = (WaterBox*)SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes); } /** * Convert CollisionHeader Segmented to Virtual addressing */ void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) { - *dest = SEGMENTED_TO_VIRTUAL(colHeader); + *dest = (CollisionHeader*)SEGMENTED_TO_VIRTUAL(colHeader); CollisionHeader_SegmentedToVirtual(*dest); } @@ -3838,7 +3838,7 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, return 0; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == (SurfaceType*)gSegments[0]) { return 0; } return surfaceTypes[poly->type].data[dataIdx]; @@ -3881,11 +3881,11 @@ u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s3 return 0; } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == (CamData*)gSegments[0]) { return 0; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == (SurfaceType*)gSegments[0]) { return 0; } return func_80041A4C(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); @@ -3903,7 +3903,7 @@ u16 func_80041B24(CollisionContext* colCtx, u32 camId, s32 bgId) { } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == (CamData*)gSegments[0]) { return 0; } return camData[camId].numCameras; @@ -3921,11 +3921,11 @@ u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 return 0; } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == (CamData*)gSegments[0]) { return 0; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == (SurfaceType*)gSegments[0]) { return 0; } return func_80041B24(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); @@ -3942,7 +3942,7 @@ Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId) { return NULL; } cameraDataList = colHeader->cameraDataList; - if (cameraDataList == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (cameraDataList == (CamData*)gSegments[0]) { return NULL; } return (Vec3s*)SEGMENTED_TO_VIRTUAL(cameraDataList[camId].camPosData); @@ -3960,11 +3960,11 @@ Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, return NULL; } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == (CamData*)gSegments[0]) { return NULL; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == (SurfaceType*)gSegments[0]) { return NULL; } return func_80041C10(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); @@ -4206,7 +4206,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u32 room; WaterBox* curWaterBox; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == (WaterBox*)gSegments[0]) { return false; } @@ -4242,7 +4242,7 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec WaterBox* waterBox; WaterBox* waterBoxList = colHeader->waterBoxes; // unused, needed for matching - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == (WaterBox*)gSegments[0]) { *outWaterBox = NULL; return -1; } @@ -4289,7 +4289,7 @@ u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox) { s32 camId = WaterBox_GetCamDataIndex(colCtx, waterBox); CamData* camData = colCtx->colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == (CamData*)gSegments[0]) { return 0; } @@ -4317,7 +4317,7 @@ s32 func_800425B0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 u32 room; WaterBox* curWaterBox; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == (WaterBox*)gSegments[0]) { return false; } diff --git a/src/code/z_camera.c b/src/code/z_camera.cpp similarity index 99% rename from src/code/z_camera.c rename to src/code/z_camera.cpp index 6b94b5e7e..b551c0169 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.cpp @@ -18,7 +18,6 @@ #include "def/code_80106860.h" #include "def/db_camera.h" #include "def/shrink_window.h" -#include "def/sinf.h" #include "def/sys_math3d.h" #include "def/z_actor.h" #include "def/z_bgcheck.h" @@ -62,7 +61,7 @@ s32 Camera_CheckWater(Camera* camera); #define FLG_ADJSLOPE (1 << 0) #define FLG_OFFGROUND (1 << 7) -#include "z_camera_data.c" +#include "z_camera_data.cpp" /*===============================================================*/ @@ -5510,7 +5509,7 @@ s32 Camera_Unique9(Camera* camera) { return true; } -void Camera_DebugPrintSplineArray(char* name, s16 length, CutsceneCameraPoint cameraPoints[]) { +static void Camera_DebugPrintSplineArray(const char* name, s16 length, CutsceneCameraPoint cameraPoints[]) { s32 i; osSyncPrintf("static SplinedatZ %s[] = {\n", name); @@ -6043,7 +6042,7 @@ s32 Camera_Demo5(Camera* camera) { pad = sDemo5PrevSfxFrame - camera->globalCtx->state.frames; if ((pad >= 0x33) || (pad < -0x32)) { - func_80078884(camera->data1); + func_80078884((u16)camera->data1); } sDemo5PrevSfxFrame = camera->globalCtx->state.frames; @@ -6803,7 +6802,7 @@ s32 Camera_Special9(Camera* camera) { } Camera* Camera_Create(View* view, CollisionContext* colCtx, GlobalContext* globalCtx) { - Camera* newCamera = ZeldaArena_MallocDebug(sizeof(*newCamera), "../z_camera.c", 9370); + Camera* newCamera = (Camera*)ZeldaArena_MallocDebug(sizeof(*newCamera), "../z_camera.c", 9370); if (newCamera != NULL) { osSyncPrintf(VT_FGCOL(BLUE) "camera: create --- allocate %d byte" VT_RST "\n", sizeof(*newCamera) * 4); diff --git a/src/code/z_camera_data.c b/src/code/z_camera_data.cpp similarity index 100% rename from src/code/z_camera_data.c rename to src/code/z_camera_data.cpp diff --git a/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.cpp similarity index 100% rename from src/code/z_cheap_proc.c rename to src/code/z_cheap_proc.cpp diff --git a/src/code/z_collision_btltbls.c b/src/code/z_collision_btltbls.cpp similarity index 100% rename from src/code/z_collision_btltbls.c rename to src/code/z_collision_btltbls.cpp diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.cpp similarity index 99% rename from src/code/z_collision_check.c rename to src/code/z_collision_check.cpp index b888084db..4fa137f58 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.cpp @@ -86,7 +86,7 @@ void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, gSPSetGeometryMode(POLY_OPA_DISP++, G_LIGHTING); gDPPipeSync(POLY_OPA_DISP++); - vtxTbl = Graph_Alloc(gfxCtx, 3 * sizeof(Vtx)); + vtxTbl = (Vtx*)Graph_Alloc(gfxCtx, 3 * sizeof(Vtx)); ASSERT(vtxTbl != NULL, "vtx_tbl != NULL", "../z_collision_check.c", 726); vtxTbl[0].n.ob[0] = vA->x; @@ -384,7 +384,7 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* dest, Co Collider_SetBaseToActor(globalCtx, &dest->base, &src->base); dest->count = src->count; - dest->elements = ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1443); + dest->elements = (ColliderJntSphElement*)ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1443); if (dest->elements == NULL) { dest->count = 0; @@ -413,7 +413,7 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* dest, Collider_SetBaseType1(globalCtx, &dest->base, actor, &src->base); dest->count = src->count; - dest->elements = ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1490); + dest->elements = (ColliderJntSphElement*)ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1490); if (dest->elements == NULL) { dest->count = 0; @@ -441,7 +441,7 @@ s32 Collider_SetJntSphAlloc(GlobalContext* globalCtx, ColliderJntSph* dest, Acto Collider_SetBase(globalCtx, &dest->base, actor, &src->base); dest->count = src->count; - dest->elements = ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1551); + dest->elements = (ColliderJntSphElement*)ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1551); if (dest->elements == NULL) { dest->count = 0; @@ -751,7 +751,7 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* dest, Act Collider_SetBaseType1(globalCtx, &dest->base, actor, &src->base); dest->count = src->count; - dest->elements = ZeldaArena_MallocDebug(dest->count * sizeof(ColliderTrisElement), "../z_collision_check.c", 2156); + dest->elements = (ColliderTrisElement*)ZeldaArena_MallocDebug(dest->count * sizeof(ColliderTrisElement), "../z_collision_check.c", 2156); if (dest->elements == NULL) { dest->count = 0; osSyncPrintf(VT_FGCOL(RED)); @@ -777,7 +777,7 @@ s32 Collider_SetTrisAlloc(GlobalContext* globalCtx, ColliderTris* dest, Actor* a Collider_SetBase(globalCtx, &dest->base, actor, &src->base); dest->count = src->count; - dest->elements = ZeldaArena_MallocDebug(dest->count * sizeof(ColliderTrisElement), "../z_collision_check.c", 2207); + dest->elements = (ColliderTrisElement*)ZeldaArena_MallocDebug(dest->count * sizeof(ColliderTrisElement), "../z_collision_check.c", 2207); if (dest->elements == NULL) { osSyncPrintf(VT_FGCOL(RED)); diff --git a/src/code/z_common_data.c b/src/code/z_common_data.cpp similarity index 100% rename from src/code/z_common_data.c rename to src/code/z_common_data.cpp diff --git a/src/code/z_construct.c b/src/code/z_construct.cpp similarity index 95% rename from src/code/z_construct.c rename to src/code/z_construct.cpp index 9c697f6ad..e048b1adf 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.cpp @@ -54,8 +54,8 @@ void func_801109B0(GlobalContext* globalCtx) { doActionOffset = 0x5700; } - interfaceCtx->doActionSegment1 = do_action_static_lut[doActionOffset / 0x180]; - interfaceCtx->doActionSegment2 = do_action_static_lut[(doActionOffset / 0x180) + 1]; + interfaceCtx->doActionSegment1 = (u8*)do_action_static_lut[doActionOffset / 0x180]; + interfaceCtx->doActionSegment2 = (u8*)do_action_static_lut[(doActionOffset / 0x180) + 1]; if (gSaveContext.language == LANGUAGE_ENG) { doActionOffset = 0x480; @@ -65,7 +65,7 @@ void func_801109B0(GlobalContext* globalCtx) { doActionOffset = 0x5B80; } - interfaceCtx->doActionSegment3 = do_action_static_lut[doActionOffset / 0x180]; + interfaceCtx->doActionSegment3 = (u8*)do_action_static_lut[doActionOffset / 0x180]; osSyncPrintf("Register_Item[%x, %x, %x, %x]\n", gSaveContext.equips.buttonItems[0], gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], @@ -77,21 +77,21 @@ void func_801109B0(GlobalContext* globalCtx) { interfaceCtx->iconItemSegment4 = NULL; if (gSaveContext.equips.buttonItems[0] < 0xF0) { - interfaceCtx->iconItemSegment1 = icon_item_static_lut[gSaveContext.equips.buttonItems[0]]; + interfaceCtx->iconItemSegment1 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[0]]; } else if (gSaveContext.equips.buttonItems[0] != 0xFF) { - interfaceCtx->iconItemSegment1 = icon_item_static_lut[gSaveContext.equips.buttonItems[0]]; + interfaceCtx->iconItemSegment1 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[0]]; } if (gSaveContext.equips.buttonItems[1] < 0xF0) { - interfaceCtx->iconItemSegment2 = icon_item_static_lut[gSaveContext.equips.buttonItems[1]]; + interfaceCtx->iconItemSegment2 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[1]]; } if (gSaveContext.equips.buttonItems[2] < 0xF0) { - interfaceCtx->iconItemSegment3 = icon_item_static_lut[gSaveContext.equips.buttonItems[2]]; + interfaceCtx->iconItemSegment3 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[2]]; } if (gSaveContext.equips.buttonItems[3] < 0xF0) { - interfaceCtx->iconItemSegment4 = icon_item_static_lut[gSaveContext.equips.buttonItems[3]]; + interfaceCtx->iconItemSegment4 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[3]]; } osSyncPrintf("EVENT=%d\n", ((void)0, gSaveContext.timer1State)); diff --git a/src/code/z_debug.c b/src/code/z_debug.cpp similarity index 100% rename from src/code/z_debug.c rename to src/code/z_debug.cpp diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.cpp similarity index 100% rename from src/code/z_debug_display.c rename to src/code/z_debug_display.cpp diff --git a/src/code/z_demo.c b/src/code/z_demo.cpp similarity index 97% rename from src/code/z_demo.c rename to src/code/z_demo.cpp index b34fb778d..a93e33c20 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.cpp @@ -1626,7 +1626,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - func_80064824(globalCtx, csCtx, (void*)cutscenePtr); + func_80064824(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1634,7 +1634,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetLighting(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_SetLighting(globalCtx, csCtx, (CsCmdEnvLighting*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1642,7 +1642,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlayBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_PlayBGM(globalCtx, csCtx, (CsCmdMusicChange*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1650,7 +1650,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_StopBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_StopBGM(globalCtx, csCtx, (CsCmdMusicChange*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1658,7 +1658,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_FadeBGM(globalCtx, csCtx, (CsCmdMusicFade*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1666,7 +1666,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_09(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_09(globalCtx, csCtx, (CsCmdUnknown9*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 3; } break; @@ -1674,7 +1674,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCopy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - func_80065134(globalCtx, csCtx, (void*)cutscenePtr); + func_80065134(globalCtx, csCtx, (CsCmdDayTime*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 3; } break; @@ -1684,7 +1684,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->linkAction = (void*)cutscenePtr; + csCtx->linkAction = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1712,7 +1712,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[0] = (void*)cutscenePtr; + csCtx->npcActions[0] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1740,7 +1740,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[1] = (void*)cutscenePtr; + csCtx->npcActions[1] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1764,7 +1764,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[2] = (void*)cutscenePtr; + csCtx->npcActions[2] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1787,7 +1787,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[3] = (void*)cutscenePtr; + csCtx->npcActions[3] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1806,7 +1806,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[4] = (void*)cutscenePtr; + csCtx->npcActions[4] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1823,7 +1823,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[5] = (void*)cutscenePtr; + csCtx->npcActions[5] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1841,7 +1841,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[6] = (void*)cutscenePtr; + csCtx->npcActions[6] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1858,7 +1858,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[7] = (void*)cutscenePtr; + csCtx->npcActions[7] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1869,7 +1869,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[8] = (void*)cutscenePtr; + csCtx->npcActions[8] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } @@ -1880,32 +1880,32 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if ((cmd->startFrame < csCtx->frames) && (csCtx->frames <= cmd->endFrame)) { - csCtx->npcActions[9] = (void*)cutscenePtr; + csCtx->npcActions[9] = (CsCmdActorAction*)cutscenePtr; } cutscenePtr += sizeof(CutsceneData) * 12; } break; case CS_CMD_CAM_EYE: - cutscenePtr += Cutscene_Command_CameraPositions(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_CameraPositions(globalCtx, csCtx, (u8*)cutscenePtr, 0); break; case CS_CMD_CAM_EYE_REL_TO_PLAYER: - cutscenePtr += Cutscene_Command_CameraPositions(globalCtx, csCtx, (void*)cutscenePtr, 1); + cutscenePtr += Cutscene_Command_CameraPositions(globalCtx, csCtx, (u8*)cutscenePtr, 1); break; case CS_CMD_CAM_AT: - cutscenePtr += Cutscene_Command_CameraFocus(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_CameraFocus(globalCtx, csCtx, (u8*)cutscenePtr, 0); break; case CS_CMD_CAM_AT_REL_TO_PLAYER: - cutscenePtr += Cutscene_Command_CameraFocus(globalCtx, csCtx, (void*)cutscenePtr, 1); + cutscenePtr += Cutscene_Command_CameraFocus(globalCtx, csCtx, (u8*)cutscenePtr, 1); break; case CS_CMD_07: - cutscenePtr += Cutscene_Command_07(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_07(globalCtx, csCtx, (u8*)cutscenePtr, 0); break; case CS_CMD_08: - cutscenePtr += Cutscene_Command_08(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_08(globalCtx, csCtx, (u8*)cutscenePtr, 0); break; case CS_CMD_TERMINATOR: cutscenePtr += 4; - Cutscene_Command_Terminator(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_Terminator(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += 8; break; case CS_CMD_TEXTBOX: @@ -1914,14 +1914,14 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if (cmd->base != 0xFFFF) { - Cutscene_Command_Textbox(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_Textbox(globalCtx, csCtx, (CsCmdTextbox*)cutscenePtr); } cutscenePtr += sizeof(CutsceneData) * 3; } break; case CS_CMD_SCENE_TRANS_FX: cutscenePtr += sizeof(CutsceneData); - Cutscene_Command_TransitionFX(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_TransitionFX(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 2; break; default: @@ -1960,9 +1960,9 @@ void func_80068C3C(GlobalContext* globalCtx, CutsceneContext* csCtx) { csCtx->frames++; if (dREG(95) != 0) { - Cutscene_ProcessCommands(globalCtx, csCtx, D_8012D1F0); + Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)D_8012D1F0); } else { - Cutscene_ProcessCommands(globalCtx, csCtx, globalCtx->csCtx.segment); + Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.segment); } } } diff --git a/src/code/z_draw.c b/src/code/z_draw.cpp similarity index 100% rename from src/code/z_draw.c rename to src/code/z_draw.cpp diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.cpp similarity index 70% rename from src/code/z_eff_blure.c rename to src/code/z_eff_blure.cpp index 7dd72de89..a1afab96d 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.cpp @@ -15,7 +15,7 @@ #include "def/z_rcp.h" #include "def/z_skin_matrix.h" -void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { +void EffectBlure_AddVertex(EffectBlure* pthis, Vec3f* p1, Vec3f* p2) { EffectBlureElement* elem; s32 numElements; Vec3f sp16C; @@ -29,18 +29,18 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { Vec3f sp44; Vec3f sp38; - if (this != NULL) { - numElements = this->numElements; + if (pthis != NULL) { + numElements = pthis->numElements; if (numElements >= 16) { // "Blure vertex addition processing: Table over %d" osSyncPrintf("Blure vertex addition processing: Table over %d\n", numElements); return; } - elem = &this->elements[numElements]; + elem = &pthis->elements[numElements]; elem->state = 1; - if (!(this->flags & 2)) { + if (!(pthis->flags & 2)) { elem->p1.x = p1->x; elem->p1.y = p1->y; elem->p1.z = p1->z; @@ -62,7 +62,7 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { Math_Vec3f_Scale(&sp154, scale); SkinMatrix_SetTranslate(&sp110, sp160.x, sp160.y, sp160.z); - func_800A7EC0(&spD0, this->addAngle, sp154.x, sp154.y, sp154.z); + func_800A7EC0(&spD0, pthis->addAngle, sp154.x, sp154.y, sp154.z); SkinMatrix_MtxFMtxFMult(&sp110, &spD0, &sp90); SkinMatrix_SetTranslate(&sp110, -sp160.x, -sp160.y, -sp160.z); SkinMatrix_MtxFMtxFMult(&sp90, &sp110, &sp50); @@ -79,38 +79,38 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { } elem->timer = 1; - this->numElements++; + pthis->numElements++; } } -void EffectBlure_AddSpace(EffectBlure* this) { +void EffectBlure_AddSpace(EffectBlure* pthis) { EffectBlureElement* elem; s32 numElements; - if (this != NULL) { - numElements = this->numElements; + if (pthis != NULL) { + numElements = pthis->numElements; if (numElements >= 16) { // "Blure space addition processing: Table over %d" osSyncPrintf("Blure space addition processing: Table over %d\n", numElements); return; } - elem = &this->elements[numElements]; + elem = &pthis->elements[numElements]; elem->state = 0; elem->timer = 1; - this->numElements++; + pthis->numElements++; } } -void EffectBlure_InitElements(EffectBlure* this) { +void EffectBlure_InitElements(EffectBlure* pthis) { EffectBlureElement* elem; s32 i; - this->numElements = 0; + pthis->numElements = 0; for (i = 0; i < 16; i++) { - elem = &this->elements[i]; + elem = &pthis->elements[i]; elem->state = 2; elem->p1.x = 0; @@ -124,116 +124,116 @@ void EffectBlure_InitElements(EffectBlure* this) { } } -void EffectBlure_Init1(void* thisx, void* initParamsx) { - EffectBlure* this = (EffectBlure*)thisx; +void EffectBlure_Init1(void* pthisx, void* initParamsx) { + EffectBlure* pthis = (EffectBlure*)pthisx; EffectBlureInit1* initParams = (EffectBlureInit1*)initParamsx; - if ((this != NULL) && (initParams != NULL)) { - EffectBlure_InitElements(this); - this->p1StartColor.r = initParams->p1StartColor[0]; - this->p2StartColor.r = initParams->p2StartColor[0]; - this->p1EndColor.r = initParams->p1EndColor[0]; - this->p2EndColor.r = initParams->p2EndColor[0]; - this->p1StartColor.g = initParams->p1StartColor[1]; - this->p2StartColor.g = initParams->p2StartColor[1]; - this->p1EndColor.g = initParams->p1EndColor[1]; - this->p2EndColor.g = initParams->p2EndColor[1]; - this->p1StartColor.b = initParams->p1StartColor[2]; - this->p2StartColor.b = initParams->p2StartColor[2]; - this->p1EndColor.b = initParams->p1EndColor[2]; - this->p2EndColor.b = initParams->p2EndColor[2]; - this->p1StartColor.a = initParams->p1StartColor[3]; - this->p2StartColor.a = initParams->p2StartColor[3]; - this->p1EndColor.a = initParams->p1EndColor[3]; - this->p2EndColor.a = initParams->p2EndColor[3]; - this->elemDuration = initParams->elemDuration; - this->unkFlag = initParams->unkFlag; - this->calcMode = initParams->calcMode; - this->flags = 0; - this->addAngleChange = 0; - this->addAngle = 0; - this->drawMode = 0; - this->altPrimColor.r = 0; - this->altPrimColor.g = 0; - this->altPrimColor.b = 0; - this->altPrimColor.a = 0; - this->altEnvColor.r = 0; - this->altEnvColor.g = 0; - this->altEnvColor.b = 0; - this->altEnvColor.a = 0; - this->mode4Param = 1.0f; + if ((pthis != NULL) && (initParams != NULL)) { + EffectBlure_InitElements(pthis); + pthis->p1StartColor.r = initParams->p1StartColor[0]; + pthis->p2StartColor.r = initParams->p2StartColor[0]; + pthis->p1EndColor.r = initParams->p1EndColor[0]; + pthis->p2EndColor.r = initParams->p2EndColor[0]; + pthis->p1StartColor.g = initParams->p1StartColor[1]; + pthis->p2StartColor.g = initParams->p2StartColor[1]; + pthis->p1EndColor.g = initParams->p1EndColor[1]; + pthis->p2EndColor.g = initParams->p2EndColor[1]; + pthis->p1StartColor.b = initParams->p1StartColor[2]; + pthis->p2StartColor.b = initParams->p2StartColor[2]; + pthis->p1EndColor.b = initParams->p1EndColor[2]; + pthis->p2EndColor.b = initParams->p2EndColor[2]; + pthis->p1StartColor.a = initParams->p1StartColor[3]; + pthis->p2StartColor.a = initParams->p2StartColor[3]; + pthis->p1EndColor.a = initParams->p1EndColor[3]; + pthis->p2EndColor.a = initParams->p2EndColor[3]; + pthis->elemDuration = initParams->elemDuration; + pthis->unkFlag = initParams->unkFlag; + pthis->calcMode = initParams->calcMode; + pthis->flags = 0; + pthis->addAngleChange = 0; + pthis->addAngle = 0; + pthis->drawMode = 0; + pthis->altPrimColor.r = 0; + pthis->altPrimColor.g = 0; + pthis->altPrimColor.b = 0; + pthis->altPrimColor.a = 0; + pthis->altEnvColor.r = 0; + pthis->altEnvColor.g = 0; + pthis->altEnvColor.b = 0; + pthis->altEnvColor.a = 0; + pthis->mode4Param = 1.0f; } } -void EffectBlure_Init2(void* thisx, void* initParamsx) { - EffectBlure* this = (EffectBlure*)thisx; +void EffectBlure_Init2(void* pthisx, void* initParamsx) { + EffectBlure* pthis = (EffectBlure*)pthisx; EffectBlureInit2* initParams = (EffectBlureInit2*)initParamsx; - if ((this != NULL) && (initParams != NULL)) { - EffectBlure_InitElements(this); - this->p1StartColor.r = initParams->p1StartColor[0]; - this->p2StartColor.r = initParams->p2StartColor[0]; - this->p1EndColor.r = initParams->p1EndColor[0]; - this->p2EndColor.r = initParams->p2EndColor[0]; - this->p1StartColor.g = initParams->p1StartColor[1]; - this->p2StartColor.g = initParams->p2StartColor[1]; - this->p1EndColor.g = initParams->p1EndColor[1]; - this->p2EndColor.g = initParams->p2EndColor[1]; - this->p1StartColor.b = initParams->p1StartColor[2]; - this->p2StartColor.b = initParams->p2StartColor[2]; - this->p1EndColor.b = initParams->p1EndColor[2]; - this->p2EndColor.b = initParams->p2EndColor[2]; - this->p1StartColor.a = initParams->p1StartColor[3]; - this->p2StartColor.a = initParams->p2StartColor[3]; - this->p1EndColor.a = initParams->p1EndColor[3]; - this->p2EndColor.a = initParams->p2EndColor[3]; - this->elemDuration = initParams->elemDuration; - this->unkFlag = initParams->unkFlag; - this->calcMode = initParams->calcMode; - this->flags = initParams->flags; - this->drawMode = initParams->drawMode; - this->addAngleChange = initParams->addAngleChange; - this->addAngle = 0; - this->mode4Param = initParams->mode4Param; - this->altPrimColor = initParams->altPrimColor; - this->altEnvColor = initParams->altEnvColor; + if ((pthis != NULL) && (initParams != NULL)) { + EffectBlure_InitElements(pthis); + pthis->p1StartColor.r = initParams->p1StartColor[0]; + pthis->p2StartColor.r = initParams->p2StartColor[0]; + pthis->p1EndColor.r = initParams->p1EndColor[0]; + pthis->p2EndColor.r = initParams->p2EndColor[0]; + pthis->p1StartColor.g = initParams->p1StartColor[1]; + pthis->p2StartColor.g = initParams->p2StartColor[1]; + pthis->p1EndColor.g = initParams->p1EndColor[1]; + pthis->p2EndColor.g = initParams->p2EndColor[1]; + pthis->p1StartColor.b = initParams->p1StartColor[2]; + pthis->p2StartColor.b = initParams->p2StartColor[2]; + pthis->p1EndColor.b = initParams->p1EndColor[2]; + pthis->p2EndColor.b = initParams->p2EndColor[2]; + pthis->p1StartColor.a = initParams->p1StartColor[3]; + pthis->p2StartColor.a = initParams->p2StartColor[3]; + pthis->p1EndColor.a = initParams->p1EndColor[3]; + pthis->p2EndColor.a = initParams->p2EndColor[3]; + pthis->elemDuration = initParams->elemDuration; + pthis->unkFlag = initParams->unkFlag; + pthis->calcMode = initParams->calcMode; + pthis->flags = initParams->flags; + pthis->drawMode = initParams->drawMode; + pthis->addAngleChange = initParams->addAngleChange; + pthis->addAngle = 0; + pthis->mode4Param = initParams->mode4Param; + pthis->altPrimColor = initParams->altPrimColor; + pthis->altEnvColor = initParams->altEnvColor; } } -void EffectBlure_Destroy(void* thisx) { +void EffectBlure_Destroy(void* pthisx) { } -s32 EffectBlure_Update(void* thisx) { - EffectBlure* this = (EffectBlure*)thisx; +s32 EffectBlure_Update(void* pthisx) { + EffectBlure* pthis = (EffectBlure*)pthisx; s32 i; - if (this == NULL) { + if (pthis == NULL) { return 0; } - if (this->numElements == 0) { + if (pthis->numElements == 0) { return 0; } while (true) { - if (this->elements[0].state == 0) { + if (pthis->elements[0].state == 0) { for (i = 0; i < 15; i++) { - this->elements[i] = this->elements[i + 1]; + pthis->elements[i] = pthis->elements[i + 1]; } - this->elements[i].state = 2; - this->elements[i].p1.x = 0; - this->elements[i].p1.y = 0; - this->elements[i].p1.z = 0; - this->elements[i].p2.x = 0; - this->elements[i].p2.y = 0; - this->elements[i].p2.z = 0; - this->elements[i].flags = 0; - this->elements[i].timer = 0; + pthis->elements[i].state = 2; + pthis->elements[i].p1.x = 0; + pthis->elements[i].p1.y = 0; + pthis->elements[i].p1.z = 0; + pthis->elements[i].p2.x = 0; + pthis->elements[i].p2.y = 0; + pthis->elements[i].p2.z = 0; + pthis->elements[i].flags = 0; + pthis->elements[i].timer = 0; - this->numElements--; - if (this->numElements <= 0) { - this->numElements = 0; + pthis->numElements--; + if (pthis->numElements <= 0) { + pthis->numElements = 0; return 0; } } else { @@ -241,38 +241,38 @@ s32 EffectBlure_Update(void* thisx) { } } - if (this->elements[0].state == 2) { + if (pthis->elements[0].state == 2) { return 0; } - for (i = 0; i < this->numElements; i++) { - this->elements[i].timer++; + for (i = 0; i < pthis->numElements; i++) { + pthis->elements[i].timer++; } - if (this->elemDuration < this->elements[0].timer) { + if (pthis->elemDuration < pthis->elements[0].timer) { for (i = 0; i < 15; i++) { - this->elements[i] = this->elements[i + 1]; + pthis->elements[i] = pthis->elements[i + 1]; } - this->elements[i].state = 2; - this->elements[i].p1.x = 0; - this->elements[i].p1.y = 0; - this->elements[i].p1.z = 0; - this->elements[i].p2.x = 0; - this->elements[i].p2.y = 0; - this->elements[i].p2.z = 0; - this->elements[i].flags = 0; - this->elements[i].timer = 0; + pthis->elements[i].state = 2; + pthis->elements[i].p1.x = 0; + pthis->elements[i].p1.y = 0; + pthis->elements[i].p1.z = 0; + pthis->elements[i].p2.x = 0; + pthis->elements[i].p2.y = 0; + pthis->elements[i].p2.z = 0; + pthis->elements[i].flags = 0; + pthis->elements[i].timer = 0; - this->numElements--; - if (this->numElements <= 0) { - this->numElements = 0; + pthis->numElements--; + if (pthis->numElements <= 0) { + pthis->numElements = 0; return 0; } return 0; } - this->addAngle += this->addAngleChange; + pthis->addAngle += pthis->addAngleChange; return 0; } @@ -313,13 +313,13 @@ void EffectBlure_UpdateFlags(EffectBlureElement* elem) { } } -void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3s* vec1, Vec3s* vec2, +void EffectBlure_GetComputedValues(EffectBlure* pthis, s32 index, f32 ratio, Vec3s* vec1, Vec3s* vec2, Color_RGBA8* color1, Color_RGBA8* color2) { Vec3s sp30; f32 mode4Param; - EffectBlureElement* elem = &this->elements[index]; + EffectBlureElement* elem = &pthis->elements[index]; - switch (this->calcMode) { + switch (pthis->calcMode) { case 1: vec1->x = func_80027E34(elem->p1.x, elem->p2.x, ratio); vec1->y = func_80027E34(elem->p1.y, elem->p2.y, ratio); @@ -353,7 +353,7 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 sp30.x = elem->p1.x - elem->p2.x; sp30.y = elem->p1.y - elem->p2.y; sp30.z = elem->p1.z - elem->p2.z; - mode4Param = this->mode4Param - 1.0f; + mode4Param = pthis->mode4Param - 1.0f; vec1->x = (sp30.x * 0.5f * mode4Param * ratio) + elem->p1.x; vec1->y = (sp30.y * 0.5f * mode4Param * ratio) + elem->p1.y; @@ -378,22 +378,22 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 //sp30 = sp30; // Optimized out but seems necessary to match stack usage - if (this->flags & 0x10) { + if (pthis->flags & 0x10) { color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; } else { - color1->r = func_80027E84(this->p1StartColor.r, this->p1EndColor.r, ratio); - color1->g = func_80027E84(this->p1StartColor.g, this->p1EndColor.g, ratio); - color1->b = func_80027E84(this->p1StartColor.b, this->p1EndColor.b, ratio); - color1->a = func_80027E84(this->p1StartColor.a, this->p1EndColor.a, ratio); - color2->r = func_80027E84(this->p2StartColor.r, this->p2EndColor.r, ratio); - color2->g = func_80027E84(this->p2StartColor.g, this->p2EndColor.g, ratio); - color2->b = func_80027E84(this->p2StartColor.b, this->p2EndColor.b, ratio); - color2->a = func_80027E84(this->p2StartColor.a, this->p2EndColor.a, ratio); + color1->r = func_80027E84(pthis->p1StartColor.r, pthis->p1EndColor.r, ratio); + color1->g = func_80027E84(pthis->p1StartColor.g, pthis->p1EndColor.g, ratio); + color1->b = func_80027E84(pthis->p1StartColor.b, pthis->p1EndColor.b, ratio); + color1->a = func_80027E84(pthis->p1StartColor.a, pthis->p1EndColor.a, ratio); + color2->r = func_80027E84(pthis->p2StartColor.r, pthis->p2EndColor.r, ratio); + color2->g = func_80027E84(pthis->p2StartColor.g, pthis->p2EndColor.g, ratio); + color2->b = func_80027E84(pthis->p2StartColor.b, pthis->p2EndColor.b, ratio); + color2->a = func_80027E84(pthis->p2StartColor.a, pthis->p2EndColor.a, ratio); } } -void EffectBlure_SetupSmooth(EffectBlure* this, GraphicsContext* gfxCtx) { +void EffectBlure_SetupSmooth(EffectBlure* pthis, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 809); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); @@ -402,7 +402,7 @@ void EffectBlure_SetupSmooth(EffectBlure* this, GraphicsContext* gfxCtx) { } // original name: "SQ_NoInterpolate_disp" -void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* elem, s32 index, +void EffectBlure_DrawElemNoInterpolation(EffectBlure* pthis, EffectBlureElement* elem, s32 index, GraphicsContext* gfxCtx) { static Vtx_t baseVtx = VTX_T(0, 0, 0, 0, 0, 255, 255, 255, 255); Vtx* vtx; @@ -417,9 +417,9 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 838); - Math_Vec3s_ToVec3f(&sp6C, &this->elements[0].p2); + Math_Vec3s_ToVec3f(&sp6C, &pthis->elements[0].p2); - vtx = Graph_Alloc(gfxCtx, sizeof(Vtx[4])); + vtx = (Vtx*)Graph_Alloc(gfxCtx, sizeof(Vtx[4])); if (vtx == NULL) { // "Vertices cannot be secured." osSyncPrintf("z_eff_blure.c::SQ_NoInterpolate_disp() Vertices cannot be secured.\n"); @@ -429,8 +429,8 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* vtx[2].v = baseVtx; vtx[3].v = baseVtx; - ratio = (f32)elem->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index, ratio, &sp8C, &sp84, &sp7C, &sp78); + ratio = (f32)elem->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, index, ratio, &sp8C, &sp84, &sp7C, &sp78); sp60.x = sp84.x; sp60.y = sp84.y; @@ -460,8 +460,8 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* vtx[1].v.cn[2] = sp7C.b; vtx[1].v.cn[3] = sp7C.a; - ratio = (f32)(elem + 1)->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index + 1, ratio, &sp8C, &sp84, &sp7C, &sp78); + ratio = (f32)(elem + 1)->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, index + 1, ratio, &sp8C, &sp84, &sp7C, &sp78); sp60.x = sp8C.x; sp60.y = sp8C.y; @@ -498,7 +498,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 932); } -void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElement* elem, s32 index, +void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* pthis, EffectBlureElement* elem, s32 index, GraphicsContext* gfxCtx) { static Vtx_t baseVtx = VTX_T(0, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); Vtx* vtx; @@ -528,15 +528,15 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 971); - Math_Vec3s_ToVec3f(&sp138, &this->elements[0].p2); + Math_Vec3s_ToVec3f(&sp138, &pthis->elements[0].p2); - ratio = (f32)elem->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index, ratio, &sp1EC, &sp1E4, &sp1A4, &sp1A0); + ratio = (f32)elem->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, index, ratio, &sp1EC, &sp1E4, &sp1A4, &sp1A0); Math_Vec3s_ToVec3f(&sp1CC, &sp1EC); Math_Vec3s_ToVec3f(&sp1C0, &sp1E4); - ratio = (f32)(elem + 1)->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index + 1, ratio, &sp1EC, &sp1E4, &sp19C, &sp198); + ratio = (f32)(elem + 1)->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, index + 1, ratio, &sp1EC, &sp1E4, &sp19C, &sp198); Math_Vec3s_ToVec3f(&sp18C, &sp1EC); Math_Vec3s_ToVec3f(&sp180, &sp1E4); @@ -549,8 +549,8 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem ASSERT(index - 1 >= 0, "index - 1 >= 0", "../z_eff_blure.c", 1005); - ratio = (f32)(elem - 1)->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index - 1, ratio, &sp1EC, &sp1E4, &sp1DC, &sp1D8); + ratio = (f32)(elem - 1)->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, index - 1, ratio, &sp1EC, &sp1E4, &sp1DC, &sp1D8); Math_Vec3s_ToVec3f(&sp118, &sp1EC); Math_Vec3s_ToVec3f(&sp10C, &sp1E4); Math_Vec3f_Diff(&sp18C, &sp118, &sp1B4); @@ -567,10 +567,10 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem Vec3f sp100; Vec3f spF4; - ASSERT(index + 2 < this->numElements, "index + 2 < this2->now_edge_num", "../z_eff_blure.c", 1032); + ASSERT(index + 2 < pthis->numElements, "index + 2 < pthis2->now_edge_num", "../z_eff_blure.c", 1032); - ratio = (f32)(elem + 2)->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index + 2, ratio, &sp1EC, &sp1E4, &sp1DC, &sp1D8); + ratio = (f32)(elem + 2)->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, index + 2, ratio, &sp1EC, &sp1E4, &sp1DC, &sp1D8); Math_Vec3s_ToVec3f(&sp100, &sp1EC); Math_Vec3s_ToVec3f(&spF4, &sp1E4); Math_Vec3f_Diff(&sp100, &sp1CC, &sp174); @@ -580,7 +580,7 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem Math_Vec3f_Scale(&sp174, 0.5f); Math_Vec3f_Scale(&sp168, 0.5f); - vtx = Graph_Alloc(gfxCtx, sizeof(Vtx[16])); + vtx = (Vtx*)Graph_Alloc(gfxCtx, sizeof(Vtx[16])); if (vtx == NULL) { // "Vertices cannot be secured." osSyncPrintf("z_eff_blure.c::SQ_HermiteInterpolate_disp() Vertices cannot be secured.\n"); @@ -671,8 +671,8 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 1184); } -void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) { - EffectBlure* this = this2; +void EffectBlure_DrawSmooth(EffectBlure* pthis2, GraphicsContext* gfxCtx) { + EffectBlure* pthis = pthis2; EffectBlureElement* elem; s32 i; MtxF spDC; @@ -682,22 +682,22 @@ void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 1201); - if (this->numElements < 2) { + if (pthis->numElements < 2) { return; } - this->elements[0].flags &= ~3; - this->elements[0].flags |= 2; + pthis->elements[0].flags &= ~3; + pthis->elements[0].flags |= 2; - for (elem = &this->elements[1]; elem < this->elements + this->numElements - 1; elem++) { + for (elem = &pthis->elements[1]; elem < pthis->elements + pthis->numElements - 1; elem++) { EffectBlure_UpdateFlags(elem); } - this->elements[this->numElements - 1].flags &= ~3; - this->elements[this->numElements - 1].flags |= 2; + pthis->elements[pthis->numElements - 1].flags &= ~3; + pthis->elements[pthis->numElements - 1].flags |= 2; - EffectBlure_SetupSmooth(this, gfxCtx); - SkinMatrix_SetTranslate(&spDC, this->elements[0].p2.x, this->elements[0].p2.y, this->elements[0].p2.z); + EffectBlure_SetupSmooth(pthis, gfxCtx); + SkinMatrix_SetTranslate(&spDC, pthis->elements[0].p2.x, pthis->elements[0].p2.y, pthis->elements[0].p2.z); SkinMatrix_SetScale(&sp9C, 0.1f, 0.1f, 0.1f); SkinMatrix_MtxFMtxFMult(&spDC, &sp9C, &sp5C); @@ -708,7 +708,7 @@ void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - for (i = 0, elem = &this->elements[0]; elem < this->elements + this->numElements - 1; i++, elem++) { + for (i = 0, elem = &pthis->elements[0]; elem < pthis->elements + pthis->numElements - 1; i++, elem++) { if ((elem->state == 0) || ((elem + 1)->state == 0)) { continue; } @@ -716,16 +716,16 @@ void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) { (((elem->flags & 3) == 2) && (((elem + 1)->flags & 3) == 0)) || (((elem->flags & 3) == 0) && (((elem + 1)->flags & 3) == 2)) || (((elem->flags & 3) == 2) && (((elem + 1)->flags & 3) == 2))) { - EffectBlure_DrawElemNoInterpolation(this, elem, i, gfxCtx); + EffectBlure_DrawElemNoInterpolation(pthis, elem, i, gfxCtx); } else { - EffectBlure_DrawElemHermiteInterpolation(this, elem, i, gfxCtx); + EffectBlure_DrawElemHermiteInterpolation(pthis, elem, i, gfxCtx); } } CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 1263); } -void EffectBlure_SetupSimple(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) { +void EffectBlure_SetupSimple(GraphicsContext* gfxCtx, EffectBlure* pthis, Vtx* vtx) { OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 1280); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); @@ -733,7 +733,7 @@ void EffectBlure_SetupSimple(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vt CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 1285); } -void EffectBlure_SetupSimpleAlt(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) { +void EffectBlure_SetupSimpleAlt(GraphicsContext* gfxCtx, EffectBlure* pthis, Vtx* vtx) { OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 1294); gDPPipeSync(POLY_XLU_DISP++); @@ -753,12 +753,12 @@ void EffectBlure_SetupSimpleAlt(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, this->altEnvColor.r, this->altEnvColor.g, this->altEnvColor.b, this->altEnvColor.a); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->altEnvColor.r, pthis->altEnvColor.g, pthis->altEnvColor.b, pthis->altEnvColor.a); CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 1329); } -void (*sSetupHandlers[])(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) = { +void (*sSetupHandlers[])(GraphicsContext* gfxCtx, EffectBlure* pthis, Vtx* vtx) = { EffectBlure_SetupSimple, EffectBlure_SetupSimpleAlt, }; @@ -766,12 +766,12 @@ void (*sSetupHandlers[])(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) = s32 D_80115788 = 0; // unused // original name: "EffectBlureInfo2_disp_makeDisplayList" -void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) { +void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* pthis, Vtx* vtx) { Mtx* mtx; OPEN_DISPS(gfxCtx, "../z_eff_blure.c", 1356); - sSetupHandlers[this->drawMode](gfxCtx, this, vtx); + sSetupHandlers[pthis->drawMode](gfxCtx, pthis, vtx); gDPPipeSync(POLY_XLU_DISP++); { @@ -789,11 +789,11 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, j = 0; - for (i = 0; i < this->numElements - 1; i++) { - if (this->drawMode == 1) { - alphaRatio = (f32)this->elements[i].timer / (f32)this->elemDuration; - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, this->altPrimColor.r, this->altPrimColor.g, - this->altPrimColor.b, this->altPrimColor.a * (1.0f - alphaRatio)); + for (i = 0; i < pthis->numElements - 1; i++) { + if (pthis->drawMode == 1) { + alphaRatio = (f32)pthis->elements[i].timer / (f32)pthis->elemDuration; + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, pthis->altPrimColor.r, pthis->altPrimColor.g, + pthis->altPrimColor.b, pthis->altPrimColor.a * (1.0f - alphaRatio)); gDPPipeSync(POLY_XLU_DISP++); } @@ -802,7 +802,7 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0); gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); - if (this->flags & 4) { + if (pthis->flags & 4) { sp1B0.x = ((f32)vtx[4 * i + 0].v.ob[0] + (f32)vtx[4 * i + 1].v.ob[0]) * 0.5f; sp1B0.y = ((f32)vtx[4 * i + 0].v.ob[1] + (f32)vtx[4 * i + 1].v.ob[1]) * 0.5f; sp1B0.z = ((f32)vtx[4 * i + 0].v.ob[2] + (f32)vtx[4 * i + 1].v.ob[2]) * 0.5f; @@ -858,8 +858,8 @@ Vtx_t D_801157CC[] = { VTX_T(0, 0, 0, 2048, 0, 0xFF, 0xFF, 0xFF, 0xFF), }; -void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { - EffectBlure* this = this2; +void EffectBlure_DrawSimple(EffectBlure* pthis2, GraphicsContext* gfxCtx) { + EffectBlure* pthis = pthis2; Vtx* vtx; Vtx* vtxIter; EffectBlureElement* elem; @@ -872,10 +872,10 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { Color_RGBA8 sp64; Color_RGBA8 sp60; - if (this->numElements >= 2) { - vtxCount = this->numElements * 4; + if (pthis->numElements >= 2) { + vtxCount = pthis->numElements * 4; - vtx = Graph_Alloc(gfxCtx, vtxCount * sizeof(Vtx)); + vtx = (Vtx*)Graph_Alloc(gfxCtx, vtxCount * sizeof(Vtx)); if (vtx == NULL) { // "Vertices cannot be secured. Forced termination" osSyncPrintf("Vertices cannot be secured. Forced termination\n"); @@ -888,8 +888,8 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { vtxIter++; } - if (this->numElements >= 2) { - for (elem = this->elements; elem < this->elements + this->numElements - 2; elem++) { + if (pthis->numElements >= 2) { + for (elem = pthis->elements; elem < pthis->elements + pthis->numElements - 2; elem++) { for (i = 0; i < 4; i++) { vtxIter->v = D_801157CC[i]; vtxIter++; @@ -897,11 +897,11 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { } } - for (i = 0; i < this->numElements; i++) { - elem = &this->elements[i]; + for (i = 0; i < pthis->numElements; i++) { + elem = &pthis->elements[i]; - ratio = (f32)elem->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, i, ratio, &sp74, &sp6C, &sp64, &sp60); + ratio = (f32)elem->timer / (f32)pthis->elemDuration; + EffectBlure_GetComputedValues(pthis, i, ratio, &sp74, &sp6C, &sp64, &sp60); j = i * 4 - 2; if (j >= 0) { @@ -948,12 +948,12 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { } } - EffectBlure_DrawSimpleVertices(gfxCtx, this, vtx); + EffectBlure_DrawSimpleVertices(gfxCtx, pthis, vtx); } } -void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { - EffectBlure* this = (EffectBlure*)thisx; +void EffectBlure_Draw(void* pthisx, GraphicsContext* gfxCtx) { + EffectBlure* pthis = (EffectBlure*)pthisx; Vtx* vtx; EffectBlureElement* elem; s32 i; @@ -964,24 +964,24 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->numElements != 0) { - if (this->flags == 0) { + if (pthis->numElements != 0) { + if (pthis->flags == 0) { func_800942F0(gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - vtx = Graph_Alloc(gfxCtx, sizeof(Vtx[32])); + vtx = (Vtx*)Graph_Alloc(gfxCtx, sizeof(Vtx[32])); if (vtx == NULL) { // "Blure display: Vertex table could not be secured" osSyncPrintf("Blure display: Vertex table could not be secured\n"); } else { j = 0; - for (i = 0; i < this->numElements; i++) { - elem = &this->elements[i]; + for (i = 0; i < pthis->numElements; i++) { + elem = &pthis->elements[i]; if (elem->state == 1) { - f32 ratio = (f32)elem->timer / (f32)this->elemDuration; + f32 ratio = (f32)elem->timer / (f32)pthis->elemDuration; - switch (this->calcMode) { + switch (pthis->calcMode) { case 1: vtx[j].v.ob[0] = func_80027E34(elem->p1.x, elem->p2.x, ratio); vtx[j].v.ob[1] = func_80027E34(elem->p1.y, elem->p2.y, ratio); @@ -1022,19 +1022,19 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_80027E84(this->p1StartColor.r, this->p1EndColor.r, ratio); - vtx[j].v.cn[1] = func_80027E84(this->p1StartColor.g, this->p1EndColor.g, ratio); - vtx[j].v.cn[2] = func_80027E84(this->p1StartColor.b, this->p1EndColor.b, ratio); - vtx[j].v.cn[3] = func_80027E84(this->p1StartColor.a, this->p1EndColor.a, ratio); + vtx[j].v.cn[0] = func_80027E84(pthis->p1StartColor.r, pthis->p1EndColor.r, ratio); + vtx[j].v.cn[1] = func_80027E84(pthis->p1StartColor.g, pthis->p1EndColor.g, ratio); + vtx[j].v.cn[2] = func_80027E84(pthis->p1StartColor.b, pthis->p1EndColor.b, ratio); + vtx[j].v.cn[3] = func_80027E84(pthis->p1StartColor.a, pthis->p1EndColor.a, ratio); j++; vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_80027E84(this->p2StartColor.r, this->p2EndColor.r, ratio); - vtx[j].v.cn[1] = func_80027E84(this->p2StartColor.g, this->p2EndColor.g, ratio); - vtx[j].v.cn[2] = func_80027E84(this->p2StartColor.b, this->p2EndColor.b, ratio); - vtx[j].v.cn[3] = func_80027E84(this->p2StartColor.a, this->p2EndColor.a, ratio); + vtx[j].v.cn[0] = func_80027E84(pthis->p2StartColor.r, pthis->p2EndColor.r, ratio); + vtx[j].v.cn[1] = func_80027E84(pthis->p2StartColor.g, pthis->p2EndColor.g, ratio); + vtx[j].v.cn[2] = func_80027E84(pthis->p2StartColor.b, pthis->p2EndColor.b, ratio); + vtx[j].v.cn[3] = func_80027E84(pthis->p2StartColor.a, pthis->p2EndColor.a, ratio); j++; } } @@ -1044,8 +1044,8 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { gSPVertex(POLY_XLU_DISP++, vtx, 32, 0); phi_t2 = 0; - for (i = 0; i < this->numElements; i++) { - elem = &this->elements[i]; + for (i = 0; i < pthis->numElements; i++) { + elem = &pthis->elements[i]; if (elem->state == 0) { phi_t2 = 0; @@ -1057,7 +1057,7 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { if (1) {} // Necessary to match - if (this->unkFlag == 1) { + if (pthis->unkFlag == 1) { phi_t2 = 0; } } @@ -1065,10 +1065,10 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { } } } - } else if (this->drawMode < 2) { - EffectBlure_DrawSimple(this, gfxCtx); + } else if (pthis->drawMode < 2) { + EffectBlure_DrawSimple(pthis, gfxCtx); } else { - EffectBlure_DrawSmooth(this, gfxCtx); + EffectBlure_DrawSmooth(pthis, gfxCtx); } } diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c deleted file mode 100644 index bce289924..000000000 --- a/src/code/z_eff_shield_particle.c +++ /dev/null @@ -1,229 +0,0 @@ -#define INTERNAL_SRC_CODE_Z_EFF_SHIELD_PARTICLE_C -#include "global.h" -#include "vt.h" -#include "z64animation.h" -#include "z64effect.h" -#include "z64camera.h" -#include "z64global.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_eff_shield_particle.h" -#include "def/z_effect.h" -#include "def/z_lights.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" -#include "def/graph.h" // FORCE - -static Vtx sVertices[5] = { - VTX(-32, -32, 0, 0, 1024, 0xFF, 0xFF, 0xFF, 0xFF), - VTX(32, 32, 0, 1024, 0, 0xFF, 0xFF, 0xFF, 0xFF), - VTX(-32, 32, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), - VTX(32, -32, 0, 1024, 1024, 0xFF, 0xFF, 0xFF, 0xFF), -}; - -// original name: "EffectShieldParticle_ct" -void EffectShieldParticle_Init(void* thisx, void* initParamsx) { - EffectShieldParticle* this = (EffectShieldParticle*)thisx; - EffectShieldParticleInit* initParams = (EffectShieldParticleInit*)initParamsx; - EffectShieldParticleElement* elem; - - if ((this != NULL) && (initParams != NULL)) { - this->numElements = initParams->numElements; - if (this->numElements > ARRAY_COUNT(this->elements)) { - osSyncPrintf(VT_FGCOL(RED)); - osSyncPrintf("EffectShieldParticle_ct():パーティクル数がオーバしてます。\n"); - osSyncPrintf(VT_RST); - return; - } - - this->position = initParams->position; - this->primColorStart = initParams->primColorStart; - this->envColorStart = initParams->envColorStart; - this->primColorMid = initParams->primColorMid; - this->envColorMid = initParams->envColorMid; - this->primColorEnd = initParams->primColorEnd; - this->envColorEnd = initParams->envColorEnd; - this->deceleration = initParams->deceleration; - this->maxInitialSpeed = initParams->maxInitialSpeed; - this->lengthCutoff = initParams->lengthCutoff; - this->duration = initParams->duration; - this->timer = 0; - - for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { - elem->initialSpeed = (Rand_ZeroOne() * (this->maxInitialSpeed * 0.5f)) + (this->maxInitialSpeed * 0.5f); - elem->endX = 0.0f; - elem->startXChange = 0.0f; - elem->startX = 0.0f; - elem->endXChange = elem->initialSpeed; - elem->yaw = Rand_ZeroOne() * 65534.0f; - elem->pitch = Rand_ZeroOne() * 65534.0f; - } - - this->lightDecay = initParams->lightDecay; - if (this->lightDecay == true) { - this->lightInfo.type = LIGHT_POINT_NOGLOW; - this->lightInfo.params.point = initParams->lightPoint; - this->lightNode = - LightContext_InsertLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &this->lightInfo); - } else { - this->lightNode = NULL; - } - } -} - -void EffectShieldParticle_Destroy(void* thisx) { - EffectShieldParticle* this = (EffectShieldParticle*)thisx; - - if ((this != NULL) && (this->lightDecay == true)) { - if (this->lightNode == Effect_GetGlobalCtx()->lightCtx.listHead) { - Effect_GetGlobalCtx()->lightCtx.listHead = this->lightNode->next; - } - LightContext_RemoveLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, this->lightNode); - } -} - -s32 EffectShieldParticle_Update(void* thisx) { - EffectShieldParticle* this = (EffectShieldParticle*)thisx; - EffectShieldParticleElement* elem; - - if (this == NULL) { - return 0; - } - - for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { - elem->endXChange -= this->deceleration; - if (elem->endXChange < 0.0f) { - elem->endXChange = 0.0f; - } - - if (elem->startXChange > 0.0f) { - elem->startXChange -= this->deceleration; - if (elem->startXChange < 0.0f) { - elem->startXChange = 0.0f; - } - } - - elem->endX += elem->endXChange; - elem->startX += elem->startXChange; - - if ((elem->startXChange == 0.0f) && (this->lengthCutoff < (elem->endX - elem->startX))) { - elem->startXChange = elem->initialSpeed; - } - } - - if (this->lightDecay == true) { - this->lightInfo.params.point.radius /= 2; - } - - this->timer++; - - if (this->duration < this->timer) { - return 1; - } - - return 0; -} - -void EffectShieldParticle_GetColors(EffectShieldParticle* this, Color_RGBA8* primColor, Color_RGBA8* envColor) { - s32 halfDuration = this->duration * 0.5f; - f32 ratio; - - if (halfDuration == 0) { - primColor->r = this->primColorStart.r; - primColor->g = this->primColorStart.g; - primColor->b = this->primColorStart.b; - primColor->a = this->primColorStart.a; - envColor->r = this->envColorStart.r; - envColor->g = this->envColorStart.g; - envColor->b = this->envColorStart.b; - envColor->a = this->envColorStart.a; - } else if (this->timer < halfDuration) { - ratio = this->timer / (f32)halfDuration; - primColor->r = this->primColorStart.r + (this->primColorMid.r - this->primColorStart.r) * ratio; - primColor->g = this->primColorStart.g + (this->primColorMid.g - this->primColorStart.g) * ratio; - primColor->b = this->primColorStart.b + (this->primColorMid.b - this->primColorStart.b) * ratio; - primColor->a = this->primColorStart.a + (this->primColorMid.a - this->primColorStart.a) * ratio; - envColor->r = this->envColorStart.r + (this->envColorMid.r - this->envColorStart.r) * ratio; - envColor->g = this->envColorStart.g + (this->envColorMid.g - this->envColorStart.g) * ratio; - envColor->b = this->envColorStart.b + (this->envColorMid.b - this->envColorStart.b) * ratio; - envColor->a = this->envColorStart.a + (this->envColorMid.a - this->envColorStart.a) * ratio; - } else { - ratio = (this->timer - halfDuration) / (f32)halfDuration; - primColor->r = this->primColorMid.r + (this->primColorEnd.r - this->primColorMid.r) * ratio; - primColor->g = this->primColorMid.g + (this->primColorEnd.g - this->primColorMid.g) * ratio; - primColor->b = this->primColorMid.b + (this->primColorEnd.b - this->primColorMid.b) * ratio; - primColor->a = this->primColorMid.a + (this->primColorEnd.a - this->primColorMid.a) * ratio; - envColor->r = this->envColorMid.r + (this->envColorEnd.r - this->envColorMid.r) * ratio; - envColor->g = this->envColorMid.g + (this->envColorEnd.g - this->envColorMid.g) * ratio; - envColor->b = this->envColorMid.b + (this->envColorEnd.b - this->envColorMid.b) * ratio; - envColor->a = this->envColorMid.a + (this->envColorEnd.a - this->envColorMid.a) * ratio; - } -} - -void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { - EffectShieldParticle* this = (EffectShieldParticle*)thisx; - EffectShieldParticleElement* elem; - Color_RGBA8 primColor; - Color_RGBA8 envColor; - - OPEN_DISPS(gfxCtx, "../z_eff_shield_particle.c", 272); - - if (this != NULL) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); - - gDPSetCycleType(POLY_XLU_DISP++, G_CYC_2CYCLE); - gDPPipeSync(POLY_XLU_DISP++); - gSPTexture(POLY_XLU_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); - - gDPLoadTextureBlock(POLY_XLU_DISP++, gUnknownCircle6Tex, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); - - gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, 0, 0, - 0, COMBINED, 0, 0, 0, COMBINED); - gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); - gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); - gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); - - EffectShieldParticle_GetColors(this, &primColor, &envColor); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, primColor.r, primColor.g, primColor.b, primColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, envColor.a); - gDPPipeSync(POLY_XLU_DISP++); - - for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { - Mtx* mtx; - MtxF sp104; - MtxF spC4; - MtxF sp84; - f32 temp1 = (s16)((elem->endX + elem->startX) * 0.5f); - f32 temp2 = elem->endX - elem->startX; - f32 temp3 = (s16)((temp2 * (1.0f / 64.0f)) / 0.02f); - - if (temp3 < 1.0f) { - temp3 = 1.0f; - } - - SkinMatrix_SetTranslate(&spC4, this->position.x, this->position.y, this->position.z); - SkinMatrix_SetRotateZYX(&sp104, 0, elem->yaw, 0); - SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); - SkinMatrix_SetRotateZYX(&sp104, 0, 0, elem->pitch); - SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); - SkinMatrix_SetTranslate(&sp104, temp1, 0.0f, 0.0f); - SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); - SkinMatrix_SetScale(&sp104, temp3 * 0.02f, 0.02f, 0.02f); - SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); - - mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &spC4); - if (mtx == NULL) { - break; - } - - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPVertex(POLY_XLU_DISP++, sVertices, 4, 0); - gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 3, 1, 0); - } - } - - CLOSE_DISPS(gfxCtx, "../z_eff_shield_particle.c", 359); -} diff --git a/src/code/z_eff_shield_particle.cpp b/src/code/z_eff_shield_particle.cpp new file mode 100644 index 000000000..00fb3d487 --- /dev/null +++ b/src/code/z_eff_shield_particle.cpp @@ -0,0 +1,229 @@ +#define INTERNAL_SRC_CODE_Z_EFF_SHIELD_PARTICLE_C +#include "global.h" +#include "vt.h" +#include "z64animation.h" +#include "z64effect.h" +#include "z64camera.h" +#include "z64global.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_eff_shield_particle.h" +#include "def/z_effect.h" +#include "def/z_lights.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" +#include "def/graph.h" // FORCE + +static Vtx sVertices[5] = { + VTX(-32, -32, 0, 0, 1024, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(32, 32, 0, 1024, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(-32, 32, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(32, -32, 0, 1024, 1024, 0xFF, 0xFF, 0xFF, 0xFF), +}; + +// original name: "EffectShieldParticle_ct" +void EffectShieldParticle_Init(void* thisx, void* initParamsx) { + EffectShieldParticle* pthis = (EffectShieldParticle*)thisx; + EffectShieldParticleInit* initParams = (EffectShieldParticleInit*)initParamsx; + EffectShieldParticleElement* elem; + + if ((pthis != NULL) && (initParams != NULL)) { + pthis->numElements = initParams->numElements; + if (pthis->numElements > ARRAY_COUNT(pthis->elements)) { + osSyncPrintf(VT_FGCOL(RED)); + osSyncPrintf("EffectShieldParticle_ct():パーティクル数がオーバしてます。\n"); + osSyncPrintf(VT_RST); + return; + } + + pthis->position = initParams->position; + pthis->primColorStart = initParams->primColorStart; + pthis->envColorStart = initParams->envColorStart; + pthis->primColorMid = initParams->primColorMid; + pthis->envColorMid = initParams->envColorMid; + pthis->primColorEnd = initParams->primColorEnd; + pthis->envColorEnd = initParams->envColorEnd; + pthis->deceleration = initParams->deceleration; + pthis->maxInitialSpeed = initParams->maxInitialSpeed; + pthis->lengthCutoff = initParams->lengthCutoff; + pthis->duration = initParams->duration; + pthis->timer = 0; + + for (elem = &pthis->elements[0]; elem < &pthis->elements[pthis->numElements]; elem++) { + elem->initialSpeed = (Rand_ZeroOne() * (pthis->maxInitialSpeed * 0.5f)) + (pthis->maxInitialSpeed * 0.5f); + elem->endX = 0.0f; + elem->startXChange = 0.0f; + elem->startX = 0.0f; + elem->endXChange = elem->initialSpeed; + elem->yaw = Rand_ZeroOne() * 65534.0f; + elem->pitch = Rand_ZeroOne() * 65534.0f; + } + + pthis->lightDecay = initParams->lightDecay; + if (pthis->lightDecay == true) { + pthis->lightInfo.type = LIGHT_POINT_NOGLOW; + pthis->lightInfo.params.point = initParams->lightPoint; + pthis->lightNode = + LightContext_InsertLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &pthis->lightInfo); + } else { + pthis->lightNode = NULL; + } + } +} + +void EffectShieldParticle_Destroy(void* thisx) { + EffectShieldParticle* pthis = (EffectShieldParticle*)thisx; + + if ((pthis != NULL) && (pthis->lightDecay == true)) { + if (pthis->lightNode == Effect_GetGlobalCtx()->lightCtx.listHead) { + Effect_GetGlobalCtx()->lightCtx.listHead = pthis->lightNode->next; + } + LightContext_RemoveLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, pthis->lightNode); + } +} + +s32 EffectShieldParticle_Update(void* thisx) { + EffectShieldParticle* pthis = (EffectShieldParticle*)thisx; + EffectShieldParticleElement* elem; + + if (pthis == NULL) { + return 0; + } + + for (elem = &pthis->elements[0]; elem < &pthis->elements[pthis->numElements]; elem++) { + elem->endXChange -= pthis->deceleration; + if (elem->endXChange < 0.0f) { + elem->endXChange = 0.0f; + } + + if (elem->startXChange > 0.0f) { + elem->startXChange -= pthis->deceleration; + if (elem->startXChange < 0.0f) { + elem->startXChange = 0.0f; + } + } + + elem->endX += elem->endXChange; + elem->startX += elem->startXChange; + + if ((elem->startXChange == 0.0f) && (pthis->lengthCutoff < (elem->endX - elem->startX))) { + elem->startXChange = elem->initialSpeed; + } + } + + if (pthis->lightDecay == true) { + pthis->lightInfo.params.point.radius /= 2; + } + + pthis->timer++; + + if (pthis->duration < pthis->timer) { + return 1; + } + + return 0; +} + +void EffectShieldParticle_GetColors(EffectShieldParticle* pthis, Color_RGBA8* primColor, Color_RGBA8* envColor) { + s32 halfDuration = pthis->duration * 0.5f; + f32 ratio; + + if (halfDuration == 0) { + primColor->r = pthis->primColorStart.r; + primColor->g = pthis->primColorStart.g; + primColor->b = pthis->primColorStart.b; + primColor->a = pthis->primColorStart.a; + envColor->r = pthis->envColorStart.r; + envColor->g = pthis->envColorStart.g; + envColor->b = pthis->envColorStart.b; + envColor->a = pthis->envColorStart.a; + } else if (pthis->timer < halfDuration) { + ratio = pthis->timer / (f32)halfDuration; + primColor->r = pthis->primColorStart.r + (pthis->primColorMid.r - pthis->primColorStart.r) * ratio; + primColor->g = pthis->primColorStart.g + (pthis->primColorMid.g - pthis->primColorStart.g) * ratio; + primColor->b = pthis->primColorStart.b + (pthis->primColorMid.b - pthis->primColorStart.b) * ratio; + primColor->a = pthis->primColorStart.a + (pthis->primColorMid.a - pthis->primColorStart.a) * ratio; + envColor->r = pthis->envColorStart.r + (pthis->envColorMid.r - pthis->envColorStart.r) * ratio; + envColor->g = pthis->envColorStart.g + (pthis->envColorMid.g - pthis->envColorStart.g) * ratio; + envColor->b = pthis->envColorStart.b + (pthis->envColorMid.b - pthis->envColorStart.b) * ratio; + envColor->a = pthis->envColorStart.a + (pthis->envColorMid.a - pthis->envColorStart.a) * ratio; + } else { + ratio = (pthis->timer - halfDuration) / (f32)halfDuration; + primColor->r = pthis->primColorMid.r + (pthis->primColorEnd.r - pthis->primColorMid.r) * ratio; + primColor->g = pthis->primColorMid.g + (pthis->primColorEnd.g - pthis->primColorMid.g) * ratio; + primColor->b = pthis->primColorMid.b + (pthis->primColorEnd.b - pthis->primColorMid.b) * ratio; + primColor->a = pthis->primColorMid.a + (pthis->primColorEnd.a - pthis->primColorMid.a) * ratio; + envColor->r = pthis->envColorMid.r + (pthis->envColorEnd.r - pthis->envColorMid.r) * ratio; + envColor->g = pthis->envColorMid.g + (pthis->envColorEnd.g - pthis->envColorMid.g) * ratio; + envColor->b = pthis->envColorMid.b + (pthis->envColorEnd.b - pthis->envColorMid.b) * ratio; + envColor->a = pthis->envColorMid.a + (pthis->envColorEnd.a - pthis->envColorMid.a) * ratio; + } +} + +void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { + EffectShieldParticle* pthis = (EffectShieldParticle*)thisx; + EffectShieldParticleElement* elem; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + OPEN_DISPS(gfxCtx, "../z_eff_shield_particle.c", 272); + + if (pthis != NULL) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); + + gDPSetCycleType(POLY_XLU_DISP++, G_CYC_2CYCLE); + gDPPipeSync(POLY_XLU_DISP++); + gSPTexture(POLY_XLU_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + + gDPLoadTextureBlock(POLY_XLU_DISP++, gUnknownCircle6Tex, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, 0, 0, + 0, COMBINED, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); + gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); + + EffectShieldParticle_GetColors(pthis, &primColor, &envColor); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, primColor.r, primColor.g, primColor.b, primColor.a); + gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, envColor.a); + gDPPipeSync(POLY_XLU_DISP++); + + for (elem = &pthis->elements[0]; elem < &pthis->elements[pthis->numElements]; elem++) { + Mtx* mtx; + MtxF sp104; + MtxF spC4; + MtxF sp84; + f32 temp1 = (s16)((elem->endX + elem->startX) * 0.5f); + f32 temp2 = elem->endX - elem->startX; + f32 temp3 = (s16)((temp2 * (1.0f / 64.0f)) / 0.02f); + + if (temp3 < 1.0f) { + temp3 = 1.0f; + } + + SkinMatrix_SetTranslate(&spC4, pthis->position.x, pthis->position.y, pthis->position.z); + SkinMatrix_SetRotateZYX(&sp104, 0, elem->yaw, 0); + SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); + SkinMatrix_SetRotateZYX(&sp104, 0, 0, elem->pitch); + SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); + SkinMatrix_SetTranslate(&sp104, temp1, 0.0f, 0.0f); + SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); + SkinMatrix_SetScale(&sp104, temp3 * 0.02f, 0.02f, 0.02f); + SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &spC4); + if (mtx == NULL) { + break; + } + + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(POLY_XLU_DISP++, sVertices, 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 3, 1, 0); + } + } + + CLOSE_DISPS(gfxCtx, "../z_eff_shield_particle.c", 359); +} diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.cpp similarity index 55% rename from src/code/z_eff_spark.c rename to src/code/z_eff_spark.cpp index 81ffd4409..001dfda4d 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.cpp @@ -15,69 +15,69 @@ // original name: "spark" void EffectSpark_Init(void* thisx, void* initParamsx) { - EffectSpark* this = (EffectSpark*)thisx; + EffectSpark* pthis = (EffectSpark*)thisx; EffectSparkInit* initParams = (EffectSparkInit*)initParamsx; EffectSparkElement* elem; f32 velocityNorm; s32 i; - if ((this != NULL) && (initParams != NULL)) { + if ((pthis != NULL) && (initParams != NULL)) { if ((initParams->uDiv == 0) || (initParams->vDiv == 0)) { osSyncPrintf("spark():u_div,v_div 0では困る。\n"); // "u_div,v_div 0 is not good." return; } - this->position = initParams->position; - this->speed = initParams->speed; - this->gravity = initParams->gravity; - this->uDiv = initParams->uDiv; - this->vDiv = initParams->vDiv; - this->colorStart[0].r = initParams->colorStart[0].r; - this->colorStart[0].g = initParams->colorStart[0].g; - this->colorStart[0].b = initParams->colorStart[0].b; - this->colorStart[0].a = initParams->colorStart[0].a; - this->colorStart[1].r = initParams->colorStart[1].r; - this->colorStart[1].g = initParams->colorStart[1].g; - this->colorStart[1].b = initParams->colorStart[1].b; - this->colorStart[1].a = initParams->colorStart[1].a; - this->colorStart[2].r = initParams->colorStart[2].r; - this->colorStart[2].g = initParams->colorStart[2].g; - this->colorStart[2].b = initParams->colorStart[2].b; - this->colorStart[2].a = initParams->colorStart[2].a; - this->colorStart[3].r = initParams->colorStart[3].r; - this->colorStart[3].g = initParams->colorStart[3].g; - this->colorStart[3].b = initParams->colorStart[3].b; - this->colorStart[3].a = initParams->colorStart[3].a; - this->colorEnd[0].r = initParams->colorEnd[0].r; - this->colorEnd[0].g = initParams->colorEnd[0].g; - this->colorEnd[0].b = initParams->colorEnd[0].b; - this->colorEnd[0].a = initParams->colorEnd[0].a; - this->colorEnd[1].r = initParams->colorEnd[1].r; - this->colorEnd[1].g = initParams->colorEnd[1].g; - this->colorEnd[1].b = initParams->colorEnd[1].b; - this->colorEnd[1].a = initParams->colorEnd[1].a; - this->colorEnd[2].r = initParams->colorEnd[2].r; - this->colorEnd[2].g = initParams->colorEnd[2].g; - this->colorEnd[2].b = initParams->colorEnd[2].b; - this->colorEnd[2].a = initParams->colorEnd[2].a; - this->colorEnd[3].r = initParams->colorEnd[3].r; - this->colorEnd[3].g = initParams->colorEnd[3].g; - this->colorEnd[3].b = initParams->colorEnd[3].b; - this->colorEnd[3].a = initParams->colorEnd[3].a; - this->duration = initParams->duration; + pthis->position = initParams->position; + pthis->speed = initParams->speed; + pthis->gravity = initParams->gravity; + pthis->uDiv = initParams->uDiv; + pthis->vDiv = initParams->vDiv; + pthis->colorStart[0].r = initParams->colorStart[0].r; + pthis->colorStart[0].g = initParams->colorStart[0].g; + pthis->colorStart[0].b = initParams->colorStart[0].b; + pthis->colorStart[0].a = initParams->colorStart[0].a; + pthis->colorStart[1].r = initParams->colorStart[1].r; + pthis->colorStart[1].g = initParams->colorStart[1].g; + pthis->colorStart[1].b = initParams->colorStart[1].b; + pthis->colorStart[1].a = initParams->colorStart[1].a; + pthis->colorStart[2].r = initParams->colorStart[2].r; + pthis->colorStart[2].g = initParams->colorStart[2].g; + pthis->colorStart[2].b = initParams->colorStart[2].b; + pthis->colorStart[2].a = initParams->colorStart[2].a; + pthis->colorStart[3].r = initParams->colorStart[3].r; + pthis->colorStart[3].g = initParams->colorStart[3].g; + pthis->colorStart[3].b = initParams->colorStart[3].b; + pthis->colorStart[3].a = initParams->colorStart[3].a; + pthis->colorEnd[0].r = initParams->colorEnd[0].r; + pthis->colorEnd[0].g = initParams->colorEnd[0].g; + pthis->colorEnd[0].b = initParams->colorEnd[0].b; + pthis->colorEnd[0].a = initParams->colorEnd[0].a; + pthis->colorEnd[1].r = initParams->colorEnd[1].r; + pthis->colorEnd[1].g = initParams->colorEnd[1].g; + pthis->colorEnd[1].b = initParams->colorEnd[1].b; + pthis->colorEnd[1].a = initParams->colorEnd[1].a; + pthis->colorEnd[2].r = initParams->colorEnd[2].r; + pthis->colorEnd[2].g = initParams->colorEnd[2].g; + pthis->colorEnd[2].b = initParams->colorEnd[2].b; + pthis->colorEnd[2].a = initParams->colorEnd[2].a; + pthis->colorEnd[3].r = initParams->colorEnd[3].r; + pthis->colorEnd[3].g = initParams->colorEnd[3].g; + pthis->colorEnd[3].b = initParams->colorEnd[3].b; + pthis->colorEnd[3].a = initParams->colorEnd[3].a; + pthis->duration = initParams->duration; - this->numElements = (this->uDiv * this->vDiv) + 2; - if (this->numElements > ARRAY_COUNT(this->elements)) { + pthis->numElements = (pthis->uDiv * pthis->vDiv) + 2; + if (pthis->numElements > ARRAY_COUNT(pthis->elements)) { osSyncPrintf("table_sizeオーバー\n"); // "over table_size" return; } - for (i = 0; i < this->numElements; i++) { - elem = &this->elements[i]; + for (i = 0; i < pthis->numElements; i++) { + elem = &pthis->elements[i]; - elem->position.x = this->position.x; - elem->position.y = this->position.y; - elem->position.z = this->position.z; + elem->position.x = pthis->position.x; + elem->position.y = pthis->position.y; + elem->position.z = pthis->position.z; elem->velocity.x = Rand_ZeroOne() - 0.5f; elem->velocity.y = Rand_ZeroOne() - 0.5f; elem->velocity.z = Rand_ZeroOne() - 0.5f; @@ -85,12 +85,12 @@ void EffectSpark_Init(void* thisx, void* initParamsx) { velocityNorm = sqrtf(SQ(elem->velocity.x) + SQ(elem->velocity.y) + SQ(elem->velocity.z)); if (!(fabsf(velocityNorm) < 0.008f)) { - elem->velocity.x *= this->speed * (1.0f / velocityNorm); - elem->velocity.y *= this->speed * (1.0f / velocityNorm); - elem->velocity.z *= this->speed * (1.0f / velocityNorm); + elem->velocity.x *= pthis->speed * (1.0f / velocityNorm); + elem->velocity.y *= pthis->speed * (1.0f / velocityNorm); + elem->velocity.z *= pthis->speed * (1.0f / velocityNorm); } else { elem->velocity.x = elem->velocity.z = 0.0f; - elem->velocity.y = this->speed; + elem->velocity.y = pthis->speed; } elem->unkVelocity.x = 30000.0f - Rand_ZeroOne() * 15000.0f; @@ -101,7 +101,7 @@ void EffectSpark_Init(void* thisx, void* initParamsx) { elem->unkPosition.z = Rand_ZeroOne() * 65534.0f; } - this->timer = 0; + pthis->timer = 0; } } @@ -110,29 +110,29 @@ void EffectSpark_Destroy(void* thisx) { // original name: "EffectSparkInfo_proc" s32 EffectSpark_Update(void* thisx) { - EffectSpark* this = (EffectSpark*)thisx; + EffectSpark* pthis = (EffectSpark*)thisx; EffectSparkElement* elem; s32 i; - if (this == NULL) { + if (pthis == NULL) { osSyncPrintf("EffectSparkInfo_proc():Spark Pointer is NULL\n"); } - for (i = 0; i < this->numElements; i++) { - elem = &this->elements[i]; + for (i = 0; i < pthis->numElements; i++) { + elem = &pthis->elements[i]; elem->position.x += elem->velocity.x; elem->position.y += elem->velocity.y; elem->position.z += elem->velocity.z; - elem->velocity.y += this->gravity; + elem->velocity.y += pthis->gravity; elem->unkPosition.x += elem->unkVelocity.x; elem->unkPosition.y += elem->unkVelocity.y; elem->unkPosition.z += elem->unkVelocity.z; } - this->timer++; + pthis->timer++; - if (this->duration < this->timer) { + if (pthis->duration < pthis->timer) { return 1; } else { return 0; @@ -142,7 +142,7 @@ s32 EffectSpark_Update(void* thisx) { // original name: "EffectSparkInfo_disp" void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { Vtx* vertices; - EffectSpark* this = (EffectSpark*)thisx; + EffectSpark* pthis = (EffectSpark*)thisx; GlobalContext* globalCtx = Effect_GetGlobalCtx(); s32 i; s32 j; @@ -166,7 +166,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_eff_spark.c", 293); - if (this != NULL) { + if (pthis != NULL) { gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); @@ -183,7 +183,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); gDPPipeSync(POLY_XLU_DISP++); - vertices = Graph_Alloc(gfxCtx, this->numElements * sizeof(Vtx[4])); + vertices = (Vtx*)Graph_Alloc(gfxCtx, pthis->numElements * sizeof(Vtx[4])); if (vertices == NULL) { // "Memory Allocation Failure graph_malloc" osSyncPrintf("EffectSparkInfo_disp():メモリー確保失敗 graph_malloc\n"); @@ -192,30 +192,30 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { j = 0; - ratio = (f32)this->timer / (f32)this->duration; - sp1D3 = this->colorStart[0].r + ((f32)this->colorEnd[0].r - (f32)this->colorStart[0].r) * ratio; - sp1D2 = this->colorStart[0].g + ((f32)this->colorEnd[0].g - (f32)this->colorStart[0].g) * ratio; - sp1D1 = this->colorStart[0].b + ((f32)this->colorEnd[0].b - (f32)this->colorStart[0].b) * ratio; - sp1D0 = this->colorStart[0].a + ((f32)this->colorEnd[0].a - (f32)this->colorStart[0].a) * ratio; - sp1CF = this->colorStart[1].r + ((f32)this->colorEnd[1].r - (f32)this->colorStart[1].r) * ratio; - sp1CE = this->colorStart[1].g + ((f32)this->colorEnd[1].g - (f32)this->colorStart[1].g) * ratio; - sp1CD = this->colorStart[1].b + ((f32)this->colorEnd[1].b - (f32)this->colorStart[1].b) * ratio; - sp1CC = this->colorStart[1].a + ((f32)this->colorEnd[1].a - (f32)this->colorStart[1].a) * ratio; - sp1CB = this->colorStart[2].r + ((f32)this->colorEnd[2].r - (f32)this->colorStart[2].r) * ratio; - sp1CA = this->colorStart[2].g + ((f32)this->colorEnd[2].g - (f32)this->colorStart[2].g) * ratio; - sp1C9 = this->colorStart[2].b + ((f32)this->colorEnd[2].b - (f32)this->colorStart[2].b) * ratio; - sp1C8 = this->colorStart[2].a + ((f32)this->colorEnd[2].a - (f32)this->colorStart[2].a) * ratio; - sp1C7 = this->colorStart[3].r + ((f32)this->colorEnd[3].r - (f32)this->colorStart[3].r) * ratio; - sp1C6 = this->colorStart[3].g + ((f32)this->colorEnd[3].g - (f32)this->colorStart[3].g) * ratio; - sp1C5 = this->colorStart[3].b + ((f32)this->colorEnd[3].b - (f32)this->colorStart[3].b) * ratio; - sp1C4 = this->colorStart[3].a + ((f32)this->colorEnd[3].a - (f32)this->colorStart[3].a) * ratio; + ratio = (f32)pthis->timer / (f32)pthis->duration; + sp1D3 = pthis->colorStart[0].r + ((f32)pthis->colorEnd[0].r - (f32)pthis->colorStart[0].r) * ratio; + sp1D2 = pthis->colorStart[0].g + ((f32)pthis->colorEnd[0].g - (f32)pthis->colorStart[0].g) * ratio; + sp1D1 = pthis->colorStart[0].b + ((f32)pthis->colorEnd[0].b - (f32)pthis->colorStart[0].b) * ratio; + sp1D0 = pthis->colorStart[0].a + ((f32)pthis->colorEnd[0].a - (f32)pthis->colorStart[0].a) * ratio; + sp1CF = pthis->colorStart[1].r + ((f32)pthis->colorEnd[1].r - (f32)pthis->colorStart[1].r) * ratio; + sp1CE = pthis->colorStart[1].g + ((f32)pthis->colorEnd[1].g - (f32)pthis->colorStart[1].g) * ratio; + sp1CD = pthis->colorStart[1].b + ((f32)pthis->colorEnd[1].b - (f32)pthis->colorStart[1].b) * ratio; + sp1CC = pthis->colorStart[1].a + ((f32)pthis->colorEnd[1].a - (f32)pthis->colorStart[1].a) * ratio; + sp1CB = pthis->colorStart[2].r + ((f32)pthis->colorEnd[2].r - (f32)pthis->colorStart[2].r) * ratio; + sp1CA = pthis->colorStart[2].g + ((f32)pthis->colorEnd[2].g - (f32)pthis->colorStart[2].g) * ratio; + sp1C9 = pthis->colorStart[2].b + ((f32)pthis->colorEnd[2].b - (f32)pthis->colorStart[2].b) * ratio; + sp1C8 = pthis->colorStart[2].a + ((f32)pthis->colorEnd[2].a - (f32)pthis->colorStart[2].a) * ratio; + sp1C7 = pthis->colorStart[3].r + ((f32)pthis->colorEnd[3].r - (f32)pthis->colorStart[3].r) * ratio; + sp1C6 = pthis->colorStart[3].g + ((f32)pthis->colorEnd[3].g - (f32)pthis->colorStart[3].g) * ratio; + sp1C5 = pthis->colorStart[3].b + ((f32)pthis->colorEnd[3].b - (f32)pthis->colorStart[3].b) * ratio; + sp1C4 = pthis->colorStart[3].a + ((f32)pthis->colorEnd[3].a - (f32)pthis->colorStart[3].a) * ratio; - for (i = 0; i < this->numElements; i++) { + for (i = 0; i < pthis->numElements; i++) { MtxF sp12C; MtxF spEC; MtxF spAC; MtxF sp6C; - EffectSparkElement* elem = &this->elements[i]; + EffectSparkElement* elem = &pthis->elements[i]; Mtx* mtx; f32 temp; diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.cpp similarity index 100% rename from src/code/z_eff_ss_dead.c rename to src/code/z_eff_ss_dead.cpp diff --git a/src/code/z_effect.c b/src/code/z_effect.cpp similarity index 100% rename from src/code/z_effect.c rename to src/code/z_effect.cpp diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.cpp similarity index 98% rename from src/code/z_effect_soft_sprite.c rename to src/code/z_effect_soft_sprite.cpp index ba2a04bd0..fc19e9ecc 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.cpp @@ -27,7 +27,7 @@ void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) { } sEffectSsInfo.table = - GameState_Alloc(&globalCtx->state, tableSize * sizeof(EffectSs), "../z_effect_soft_sprite.c", 289); + (EffectSs*)GameState_Alloc(&globalCtx->state, tableSize * sizeof(EffectSs), "../z_effect_soft_sprite.c", 289); ASSERT(sEffectSsInfo.table != NULL, "EffectSS2Info.data_table != NULL", "../z_effect_soft_sprite.c", 290); sEffectSsInfo.searchStartIndex = 0; @@ -294,10 +294,7 @@ void EffectSs_UpdateAll(GlobalContext* globalCtx) { void EffectSs_Draw(GlobalContext* globalCtx, s32 index) { EffectSs* effectSs = &sEffectSsInfo.table[index]; EffectSs* effectSs2 = &sEffectSsInfo.table[2]; - if(effectSs == 0xCCCCCCCC || effectSs->draw == 0x11110110) - { - return; - } + if (effectSs->draw != NULL) { effectSs->draw(globalCtx, index, effectSs); } diff --git a/src/code/z_effect_soft_sprite_dlftbls.c b/src/code/z_effect_soft_sprite_dlftbls.cpp similarity index 100% rename from src/code/z_effect_soft_sprite_dlftbls.c rename to src/code/z_effect_soft_sprite_dlftbls.cpp diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.cpp similarity index 98% rename from src/code/z_effect_soft_sprite_old_init.c rename to src/code/z_effect_soft_sprite_old_init.cpp index b2e501b2d..d6c2d5c22 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.cpp @@ -54,9 +54,9 @@ static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -// effects that use this draw function are responsible for making sure their regs line up with the usage here +// effects that use pthis draw function are responsible for making sure their regs line up with the usage here -void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture) { +void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* pthis, void* texture) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; f32 scale; MtxF mfTrans; @@ -65,16 +65,16 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur MtxF mfTrans11DA0; s32 pad1; Mtx* mtx; - void* object = gObjectTable[this->rgObjBankIdx].vromStart; + void* object = gObjectTable[pthis->rgObjBankIdx].vromStart.buffer(); OPEN_DISPS(gfxCtx, "../z_effect_soft_sprite_old_init.c", 196); - scale = this->rgScale * 0.0025f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + scale = pthis->rgScale * 0.0025f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, scale); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); @@ -83,10 +83,10 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(texture)); func_80094C50(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rgPrimColorR, this->rgPrimColorG, this->rgPrimColorB, - this->rgPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rgEnvColorR, this->rgEnvColorG, this->rgEnvColorB, this->rgEnvColorA); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rgPrimColorR, pthis->rgPrimColorG, pthis->rgPrimColorB, + pthis->rgPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rgEnvColorR, pthis->rgEnvColorG, pthis->rgEnvColorB, pthis->rgEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } CLOSE_DISPS(gfxCtx, "../z_effect_soft_sprite_old_init.c", 243); @@ -748,7 +748,7 @@ void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 sc * Spawn a light ball effect * * param changes the color of the ball. Refer to FhgFlashLightBallParam for the options. - * Note: this type requires OBJECT_FHG to be loaded + * Note: pthis type requires OBJECT_FHG to be loaded */ void EffectSsFhgFlash_SpawnLightBall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, u8 param) { @@ -1188,7 +1188,7 @@ void EffectSsDeadSound_SpawnStationary(GlobalContext* globalCtx, Vec3f* pos, u16 /** * Spawn an Ice Smoke effect * - * Note: this effect requires OBJECT_FZ to be loaded + * Note: pthis effect requires OBJECT_FZ to be loaded */ void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { EffectSsIceSmokeInitParams initParams; diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.cpp similarity index 100% rename from src/code/z_elf_message.c rename to src/code/z_elf_message.cpp diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c deleted file mode 100644 index 7713bd5de..000000000 --- a/src/code/z_en_a_keep.c +++ /dev/null @@ -1,376 +0,0 @@ -#define INTERNAL_SRC_CODE_Z_EN_A_KEEP_C -#include "global.h" -#include "vt.h" -#include "z64global.h" -#include "sfx.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/graph.h" // FORCE - -#define FLAGS ACTOR_FLAG_4 - -void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnAObj_WaitFinishedTalking(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_WaitTalk(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_BlockRot(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_BoulderFragment(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_Block(EnAObj* this, GlobalContext* globalCtx); - -void EnAObj_SetupWaitTalk(EnAObj* this, s16 type); -void EnAObj_SetupBlockRot(EnAObj* this, s16 type); -void EnAObj_SetupBoulderFragment(EnAObj* this, s16 type); -void EnAObj_SetupBlock(EnAObj* this, s16 type); - -const ActorInit En_A_Obj_InitVars = { - ACTOR_EN_A_OBJ, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnAObj), - (ActorFunc)EnAObj_Init, - (ActorFunc)EnAObj_Destroy, - (ActorFunc)EnAObj_Update, - (ActorFunc)EnAObj_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ALL, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 25, 60, 0, { 0, 0, 0 } }, -}; - -static CollisionHeader D_06000730; // gHookshotTargetCol ? - -static CollisionHeader* sColHeaders[] = { - &gLargerCubeCol, // A_OBJ_GRASS_CLUMP, A_OBJ_TREE_STUMP - &gLargerCubeCol, // A_OBJ_BLOCK_LARGE, A_OBJ_BLOCK_HUGE - &gSmallerFlatBlockCol, // unused - &gLargerFlatBlockCol, // A_OBJ_BLOCK_SMALL_ROT, A_OBJ_BLOCK_LARGE_ROT - &gSmallerCubeCol, // unused - &D_06000730, // A_OBJ_UNKNOWN_6 -}; - -static Gfx* sDLists[] = { - gFlatBlockDL, - gFlatBlockDL, - gFlatBlockDL, - gFlatRotBlockDL, - gFlatRotBlockDL, - gSmallCubeDL, - /* gHookshotPostDL ? */ 0x06000210, - gGrassBladesDL, - gTreeStumpDL, - gSignRectangularDL, - gSignDirectionalDL, - gBoulderFragmentsDL, -}; - -void EnAObj_SetupAction(EnAObj* this, EnAObjActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { - CollisionHeader* colHeader = NULL; - s32 pad; - EnAObj* this = (EnAObj*)thisx; - f32 shadowScale = 6.0f; - - this->textId = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - - switch (thisx->params) { - case A_OBJ_BLOCK_SMALL: - Actor_SetScale(thisx, 0.025f); - break; - case A_OBJ_BLOCK_LARGE: - Actor_SetScale(thisx, 0.05f); - break; - case A_OBJ_BLOCK_HUGE: - case A_OBJ_CUBE_SMALL: - case A_OBJ_UNKNOWN_6: - Actor_SetScale(thisx, 0.1f); - break; - case A_OBJ_BLOCK_SMALL_ROT: - Actor_SetScale(thisx, 0.005f); - break; - case A_OBJ_BLOCK_LARGE_ROT: - default: - Actor_SetScale(thisx, 0.01f); - break; - } - - if (thisx->params >= A_OBJ_SIGNPOST_OBLONG) { - shadowScale = 12.0f; - } - - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, shadowScale); - - thisx->focus.pos = thisx->world.pos; - this->dyna.bgId = BGACTOR_NEG_ONE; - this->dyna.unk_160 = 0; - this->dyna.unk_15C = DPM_UNK; - thisx->uncullZoneDownward = 1200.0f; - thisx->uncullZoneScale = 200.0f; - - switch (thisx->params) { - case A_OBJ_BLOCK_LARGE: - case A_OBJ_BLOCK_HUGE: - this->dyna.bgId = 1; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BG); - EnAObj_SetupBlock(this, thisx->params); - break; - case A_OBJ_BLOCK_SMALL_ROT: - case A_OBJ_BLOCK_LARGE_ROT: - this->dyna.bgId = 3; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BG); - EnAObj_SetupBlockRot(this, thisx->params); - break; - case A_OBJ_UNKNOWN_6: - // clang-format off - thisx->flags |= ACTOR_FLAG_0; this->dyna.bgId = 5; this->focusYoffset = 10.0f; - // clang-format on - thisx->gravity = -2.0f; - EnAObj_SetupWaitTalk(this, thisx->params); - break; - case A_OBJ_GRASS_CLUMP: - case A_OBJ_TREE_STUMP: - this->dyna.bgId = 0; - EnAObj_SetupWaitTalk(this, thisx->params); - break; - case A_OBJ_SIGNPOST_OBLONG: - case A_OBJ_SIGNPOST_ARROW: - thisx->textId = (this->textId & 0xFF) | 0x300; - // clang-format off - thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; thisx->targetArrowOffset = 500.0f; - // clang-format on - this->focusYoffset = 45.0f; - EnAObj_SetupWaitTalk(this, thisx->params); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - thisx->colChkInfo.mass = MASS_IMMOVABLE; - thisx->targetMode = 0; - break; - case A_OBJ_BOULDER_FRAGMENT: - thisx->gravity = -1.5f; - EnAObj_SetupBoulderFragment(this, thisx->params); - break; - default: - thisx->gravity = -2.0f; - EnAObj_SetupWaitTalk(this, thisx->params); - break; - } - - if (thisx->params <= A_OBJ_BLOCK_LARGE_ROT) { // A_OBJ_BLOCK_* - thisx->colChkInfo.mass = MASS_IMMOVABLE; - } - - if (this->dyna.bgId != BGACTOR_NEG_ONE) { - CollisionHeader_GetVirtual(sColHeaders[this->dyna.bgId], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - } -} - -void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnAObj* this = (EnAObj*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - - switch (this->dyna.actor.params) { - case A_OBJ_SIGNPOST_OBLONG: - case A_OBJ_SIGNPOST_ARROW: - Collider_DestroyCylinder(globalCtx, &this->collider); - break; - } -} - -void EnAObj_WaitFinishedTalking(EnAObj* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { - EnAObj_SetupWaitTalk(this, this->dyna.actor.params); - } -} - -void EnAObj_SetupWaitTalk(EnAObj* this, s16 type) { - EnAObj_SetupAction(this, EnAObj_WaitTalk); -} - -void EnAObj_WaitTalk(EnAObj* this, GlobalContext* globalCtx) { - s16 relYawTowardsPlayer; - - if (this->dyna.actor.textId != 0) { - relYawTowardsPlayer = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; - if (ABS(relYawTowardsPlayer) < 0x2800 || - (this->dyna.actor.params == A_OBJ_SIGNPOST_ARROW && ABS(relYawTowardsPlayer) > 0x5800)) { - if (Actor_ProcessTalkRequest(&this->dyna.actor, globalCtx)) { - EnAObj_SetupAction(this, EnAObj_WaitFinishedTalking); - } else { - func_8002F2F4(&this->dyna.actor, globalCtx); - } - } - } -} - -void EnAObj_SetupBlockRot(EnAObj* this, s16 type) { - this->rotateState = 0; - this->rotateWaitTimer = 10; - this->dyna.actor.world.rot.y = 0; - this->dyna.actor.shape.rot = this->dyna.actor.world.rot; - EnAObj_SetupAction(this, EnAObj_BlockRot); -} - -void EnAObj_BlockRot(EnAObj* this, GlobalContext* globalCtx) { - if (this->rotateState == 0) { - if (this->dyna.unk_160 != 0) { - this->rotateState++; - this->rotateForTimer = 20; - - if ((s16)(this->dyna.actor.yawTowardsPlayer + 0x4000) < 0) { - this->rotSpeedX = -0x3E8; - } else { - this->rotSpeedX = 0x3E8; - } - - if (this->dyna.actor.yawTowardsPlayer < 0) { - this->rotSpeedY = -this->rotSpeedX; - } else { - this->rotSpeedY = this->rotSpeedX; - } - } - } else { - if (this->rotateWaitTimer != 0) { - this->rotateWaitTimer--; - } else { - this->dyna.actor.shape.rot.y += this->rotSpeedY; - this->dyna.actor.shape.rot.x += this->rotSpeedX; - this->rotateForTimer--; - this->dyna.actor.gravity = -1.0f; - - if (this->rotateForTimer == 0) { - this->dyna.actor.world.pos = this->dyna.actor.home.pos; - this->rotateState = 0; - this->rotateWaitTimer = 10; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.gravity = 0.0f; - this->dyna.actor.shape.rot = this->dyna.actor.world.rot; - } - } - } -} - -void EnAObj_SetupBoulderFragment(EnAObj* this, s16 type) { - EnAObj_SetupAction(this, EnAObj_BoulderFragment); -} - -void EnAObj_BoulderFragment(EnAObj* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->dyna.actor.speedXZ, 1.0f, 1.0f, 0.5f, 0.0f); - this->dyna.actor.shape.rot.x += this->dyna.actor.world.rot.x >> 1; - this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z >> 1; - - if (this->dyna.actor.speedXZ != 0.0f && this->dyna.actor.bgCheckFlags & 0x8) { - this->dyna.actor.world.rot.y = - this->dyna.actor.wallYaw - this->dyna.actor.world.rot.y + this->dyna.actor.wallYaw - 0x8000; - if (1) {} - this->dyna.actor.bgCheckFlags &= ~0x8; - } - - if (this->dyna.actor.bgCheckFlags & 0x2) { - if (this->dyna.actor.velocity.y < -8.0f) { - this->dyna.actor.velocity.y *= -0.6f; - this->dyna.actor.speedXZ *= 0.6f; - this->dyna.actor.bgCheckFlags &= ~0x3; - } else { - Actor_Kill(&this->dyna.actor); - } - } -} - -void EnAObj_SetupBlock(EnAObj* this, s16 type) { - this->dyna.actor.uncullZoneDownward = 1200.0f; - this->dyna.actor.uncullZoneScale = 720.0f; - EnAObj_SetupAction(this, EnAObj_Block); -} - -void EnAObj_Block(EnAObj* this, GlobalContext* globalCtx) { - this->dyna.actor.speedXZ += this->dyna.unk_150; - this->dyna.actor.world.rot.y = this->dyna.unk_158; - this->dyna.actor.speedXZ = CLAMP(this->dyna.actor.speedXZ, -2.5f, 2.5f); - - Math_SmoothStepToF(&this->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - - if (this->dyna.actor.speedXZ != 0.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); - } - - this->dyna.unk_154 = 0.0f; - this->dyna.unk_150 = 0.0f; -} - -void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { - EnAObj* this = (EnAObj*)thisx; - - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->dyna.actor); - - if (this->dyna.actor.gravity != 0.0f) { - if (this->dyna.actor.params != A_OBJ_BOULDER_FRAGMENT) { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 5.0f, 40.0f, 0.0f, 0x1D); - } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 5.0f, 20.0f, 0.0f, 0x1D); - } - } - - this->dyna.actor.focus.pos = this->dyna.actor.world.pos; - this->dyna.actor.focus.pos.y += this->focusYoffset; - - switch (this->dyna.actor.params) { - case A_OBJ_SIGNPOST_OBLONG: - case A_OBJ_SIGNPOST_ARROW: - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - break; - } -} - -void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 type = thisx->params; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 701); - - func_80093D18(globalCtx->state.gfxCtx); - - if (type >= A_OBJ_MAX) { - type = A_OBJ_BOULDER_FRAGMENT; - } - - if (thisx->params == A_OBJ_BOULDER_FRAGMENT) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 60, 60, 60, 50); - } - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 712), - G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_OPA_DISP++, sDLists[type]); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 715); -} diff --git a/src/code/z_en_a_keep.cpp b/src/code/z_en_a_keep.cpp new file mode 100644 index 000000000..8f78798ef --- /dev/null +++ b/src/code/z_en_a_keep.cpp @@ -0,0 +1,376 @@ +#define INTERNAL_SRC_CODE_Z_EN_A_KEEP_C +#include "global.h" +#include "vt.h" +#include "z64global.h" +#include "sfx.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/graph.h" // FORCE + +#define FLAGS ACTOR_FLAG_4 + +void EnAObj_Init(Actor* pthisx, GlobalContext* globalCtx); +void EnAObj_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void EnAObj_Update(Actor* pthisx, GlobalContext* globalCtx); +void EnAObj_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void EnAObj_WaitFinishedTalking(EnAObj* pthis, GlobalContext* globalCtx); +void EnAObj_WaitTalk(EnAObj* pthis, GlobalContext* globalCtx); +void EnAObj_BlockRot(EnAObj* pthis, GlobalContext* globalCtx); +void EnAObj_BoulderFragment(EnAObj* pthis, GlobalContext* globalCtx); +void EnAObj_Block(EnAObj* pthis, GlobalContext* globalCtx); + +void EnAObj_SetupWaitTalk(EnAObj* pthis, s16 type); +void EnAObj_SetupBlockRot(EnAObj* pthis, s16 type); +void EnAObj_SetupBoulderFragment(EnAObj* pthis, s16 type); +void EnAObj_SetupBlock(EnAObj* pthis, s16 type); + +ActorInit En_A_Obj_InitVars = { + ACTOR_EN_A_OBJ, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnAObj), + (ActorFunc)EnAObj_Init, + (ActorFunc)EnAObj_Destroy, + (ActorFunc)EnAObj_Update, + (ActorFunc)EnAObj_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ALL, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 25, 60, 0, { 0, 0, 0 } }, +}; + +static CollisionHeader D_06000730; // gHookshotTargetCol ? + +static CollisionHeader* sColHeaders[] = { + &gLargerCubeCol, // A_OBJ_GRASS_CLUMP, A_OBJ_TREE_STUMP + &gLargerCubeCol, // A_OBJ_BLOCK_LARGE, A_OBJ_BLOCK_HUGE + &gSmallerFlatBlockCol, // unused + &gLargerFlatBlockCol, // A_OBJ_BLOCK_SMALL_ROT, A_OBJ_BLOCK_LARGE_ROT + &gSmallerCubeCol, // unused + &D_06000730, // A_OBJ_UNKNOWN_6 +}; + +static Gfx* sDLists[] = { + gFlatBlockDL, + gFlatBlockDL, + gFlatBlockDL, + gFlatRotBlockDL, + gFlatRotBlockDL, + gSmallCubeDL, + /* gHookshotPostDL ? */ (Gfx*)0x06000211, + gGrassBladesDL, + gTreeStumpDL, + gSignRectangularDL, + gSignDirectionalDL, + gBoulderFragmentsDL, +}; + +void EnAObj_SetupAction(EnAObj* pthis, EnAObjActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnAObj_Init(Actor* pthisx, GlobalContext* globalCtx) { + CollisionHeader* colHeader = NULL; + s32 pad; + EnAObj* pthis = (EnAObj*)pthisx; + f32 shadowScale = 6.0f; + + pthis->textId = (pthisx->params >> 8) & 0xFF; + pthisx->params &= 0xFF; + + switch (pthisx->params) { + case A_OBJ_BLOCK_SMALL: + Actor_SetScale(pthisx, 0.025f); + break; + case A_OBJ_BLOCK_LARGE: + Actor_SetScale(pthisx, 0.05f); + break; + case A_OBJ_BLOCK_HUGE: + case A_OBJ_CUBE_SMALL: + case A_OBJ_UNKNOWN_6: + Actor_SetScale(pthisx, 0.1f); + break; + case A_OBJ_BLOCK_SMALL_ROT: + Actor_SetScale(pthisx, 0.005f); + break; + case A_OBJ_BLOCK_LARGE_ROT: + default: + Actor_SetScale(pthisx, 0.01f); + break; + } + + if (pthisx->params >= A_OBJ_SIGNPOST_OBLONG) { + shadowScale = 12.0f; + } + + ActorShape_Init(&pthisx->shape, 0.0f, ActorShadow_DrawCircle, shadowScale); + + pthisx->focus.pos = pthisx->world.pos; + pthis->dyna.bgId = BGACTOR_NEG_ONE; + pthis->dyna.unk_160 = 0; + pthis->dyna.unk_15C = DPM_UNK; + pthisx->uncullZoneDownward = 1200.0f; + pthisx->uncullZoneScale = 200.0f; + + switch (pthisx->params) { + case A_OBJ_BLOCK_LARGE: + case A_OBJ_BLOCK_HUGE: + pthis->dyna.bgId = 1; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, pthisx, ACTORCAT_BG); + EnAObj_SetupBlock(pthis, pthisx->params); + break; + case A_OBJ_BLOCK_SMALL_ROT: + case A_OBJ_BLOCK_LARGE_ROT: + pthis->dyna.bgId = 3; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, pthisx, ACTORCAT_BG); + EnAObj_SetupBlockRot(pthis, pthisx->params); + break; + case A_OBJ_UNKNOWN_6: + // clang-format off + pthisx->flags |= ACTOR_FLAG_0; pthis->dyna.bgId = 5; pthis->focusYoffset = 10.0f; + // clang-format on + pthisx->gravity = -2.0f; + EnAObj_SetupWaitTalk(pthis, pthisx->params); + break; + case A_OBJ_GRASS_CLUMP: + case A_OBJ_TREE_STUMP: + pthis->dyna.bgId = 0; + EnAObj_SetupWaitTalk(pthis, pthisx->params); + break; + case A_OBJ_SIGNPOST_OBLONG: + case A_OBJ_SIGNPOST_ARROW: + pthisx->textId = (pthis->textId & 0xFF) | 0x300; + // clang-format off + pthisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; pthisx->targetArrowOffset = 500.0f; + // clang-format on + pthis->focusYoffset = 45.0f; + EnAObj_SetupWaitTalk(pthis, pthisx->params); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, pthisx, &sCylinderInit); + pthisx->colChkInfo.mass = MASS_IMMOVABLE; + pthisx->targetMode = 0; + break; + case A_OBJ_BOULDER_FRAGMENT: + pthisx->gravity = -1.5f; + EnAObj_SetupBoulderFragment(pthis, pthisx->params); + break; + default: + pthisx->gravity = -2.0f; + EnAObj_SetupWaitTalk(pthis, pthisx->params); + break; + } + + if (pthisx->params <= A_OBJ_BLOCK_LARGE_ROT) { // A_OBJ_BLOCK_* + pthisx->colChkInfo.mass = MASS_IMMOVABLE; + } + + if (pthis->dyna.bgId != BGACTOR_NEG_ONE) { + CollisionHeader_GetVirtual(sColHeaders[pthis->dyna.bgId], &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, pthisx, colHeader); + } +} + +void EnAObj_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + EnAObj* pthis = (EnAObj*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + + switch (pthis->dyna.actor.params) { + case A_OBJ_SIGNPOST_OBLONG: + case A_OBJ_SIGNPOST_ARROW: + Collider_DestroyCylinder(globalCtx, &pthis->collider); + break; + } +} + +void EnAObj_WaitFinishedTalking(EnAObj* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->dyna.actor, globalCtx)) { + EnAObj_SetupWaitTalk(pthis, pthis->dyna.actor.params); + } +} + +void EnAObj_SetupWaitTalk(EnAObj* pthis, s16 type) { + EnAObj_SetupAction(pthis, EnAObj_WaitTalk); +} + +void EnAObj_WaitTalk(EnAObj* pthis, GlobalContext* globalCtx) { + s16 relYawTowardsPlayer; + + if (pthis->dyna.actor.textId != 0) { + relYawTowardsPlayer = pthis->dyna.actor.yawTowardsPlayer - pthis->dyna.actor.shape.rot.y; + if (ABS(relYawTowardsPlayer) < 0x2800 || + (pthis->dyna.actor.params == A_OBJ_SIGNPOST_ARROW && ABS(relYawTowardsPlayer) > 0x5800)) { + if (Actor_ProcessTalkRequest(&pthis->dyna.actor, globalCtx)) { + EnAObj_SetupAction(pthis, EnAObj_WaitFinishedTalking); + } else { + func_8002F2F4(&pthis->dyna.actor, globalCtx); + } + } + } +} + +void EnAObj_SetupBlockRot(EnAObj* pthis, s16 type) { + pthis->rotateState = 0; + pthis->rotateWaitTimer = 10; + pthis->dyna.actor.world.rot.y = 0; + pthis->dyna.actor.shape.rot = pthis->dyna.actor.world.rot; + EnAObj_SetupAction(pthis, EnAObj_BlockRot); +} + +void EnAObj_BlockRot(EnAObj* pthis, GlobalContext* globalCtx) { + if (pthis->rotateState == 0) { + if (pthis->dyna.unk_160 != 0) { + pthis->rotateState++; + pthis->rotateForTimer = 20; + + if ((s16)(pthis->dyna.actor.yawTowardsPlayer + 0x4000) < 0) { + pthis->rotSpeedX = -0x3E8; + } else { + pthis->rotSpeedX = 0x3E8; + } + + if (pthis->dyna.actor.yawTowardsPlayer < 0) { + pthis->rotSpeedY = -pthis->rotSpeedX; + } else { + pthis->rotSpeedY = pthis->rotSpeedX; + } + } + } else { + if (pthis->rotateWaitTimer != 0) { + pthis->rotateWaitTimer--; + } else { + pthis->dyna.actor.shape.rot.y += pthis->rotSpeedY; + pthis->dyna.actor.shape.rot.x += pthis->rotSpeedX; + pthis->rotateForTimer--; + pthis->dyna.actor.gravity = -1.0f; + + if (pthis->rotateForTimer == 0) { + pthis->dyna.actor.world.pos = pthis->dyna.actor.home.pos; + pthis->rotateState = 0; + pthis->rotateWaitTimer = 10; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.gravity = 0.0f; + pthis->dyna.actor.shape.rot = pthis->dyna.actor.world.rot; + } + } + } +} + +void EnAObj_SetupBoulderFragment(EnAObj* pthis, s16 type) { + EnAObj_SetupAction(pthis, EnAObj_BoulderFragment); +} + +void EnAObj_BoulderFragment(EnAObj* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->dyna.actor.speedXZ, 1.0f, 1.0f, 0.5f, 0.0f); + pthis->dyna.actor.shape.rot.x += pthis->dyna.actor.world.rot.x >> 1; + pthis->dyna.actor.shape.rot.z += pthis->dyna.actor.world.rot.z >> 1; + + if (pthis->dyna.actor.speedXZ != 0.0f && pthis->dyna.actor.bgCheckFlags & 0x8) { + pthis->dyna.actor.world.rot.y = + pthis->dyna.actor.wallYaw - pthis->dyna.actor.world.rot.y + pthis->dyna.actor.wallYaw - 0x8000; + if (1) {} + pthis->dyna.actor.bgCheckFlags &= ~0x8; + } + + if (pthis->dyna.actor.bgCheckFlags & 0x2) { + if (pthis->dyna.actor.velocity.y < -8.0f) { + pthis->dyna.actor.velocity.y *= -0.6f; + pthis->dyna.actor.speedXZ *= 0.6f; + pthis->dyna.actor.bgCheckFlags &= ~0x3; + } else { + Actor_Kill(&pthis->dyna.actor); + } + } +} + +void EnAObj_SetupBlock(EnAObj* pthis, s16 type) { + pthis->dyna.actor.uncullZoneDownward = 1200.0f; + pthis->dyna.actor.uncullZoneScale = 720.0f; + EnAObj_SetupAction(pthis, EnAObj_Block); +} + +void EnAObj_Block(EnAObj* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.speedXZ += pthis->dyna.unk_150; + pthis->dyna.actor.world.rot.y = pthis->dyna.unk_158; + pthis->dyna.actor.speedXZ = CLAMP(pthis->dyna.actor.speedXZ, -2.5f, 2.5f); + + Math_SmoothStepToF(&pthis->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + + if (pthis->dyna.actor.speedXZ != 0.0f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } + + pthis->dyna.unk_154 = 0.0f; + pthis->dyna.unk_150 = 0.0f; +} + +void EnAObj_Update(Actor* pthisx, GlobalContext* globalCtx) { + EnAObj* pthis = (EnAObj*)pthisx; + + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->dyna.actor); + + if (pthis->dyna.actor.gravity != 0.0f) { + if (pthis->dyna.actor.params != A_OBJ_BOULDER_FRAGMENT) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 5.0f, 40.0f, 0.0f, 0x1D); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 5.0f, 20.0f, 0.0f, 0x1D); + } + } + + pthis->dyna.actor.focus.pos = pthis->dyna.actor.world.pos; + pthis->dyna.actor.focus.pos.y += pthis->focusYoffset; + + switch (pthis->dyna.actor.params) { + case A_OBJ_SIGNPOST_OBLONG: + case A_OBJ_SIGNPOST_ARROW: + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + break; + } +} + +void EnAObj_Draw(Actor* pthisx, GlobalContext* globalCtx) { + s32 type = pthisx->params; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 701); + + func_80093D18(globalCtx->state.gfxCtx); + + if (type >= A_OBJ_MAX) { + type = A_OBJ_BOULDER_FRAGMENT; + } + + if (pthisx->params == A_OBJ_BOULDER_FRAGMENT) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 60, 60, 60, 50); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 712), + G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, sDLists[type]); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 715); +} diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.cpp similarity index 69% rename from src/code/z_en_item00.c rename to src/code/z_en_item00.cpp index ff8f6a5d8..4afee8d8d 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.cpp @@ -27,22 +27,22 @@ #define FLAGS 0 -void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnItem00_Init(Actor* pthisx, GlobalContext* globalCtx); +void EnItem00_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void EnItem00_Update(Actor* pthisx, GlobalContext* globalCtx); +void EnItem00_Draw(Actor* pthisx, GlobalContext* globalCtx); -void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx); -void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx); -void func_8001E304(EnItem00* this, GlobalContext* globalCtx); -void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx); +void func_8001DFC8(EnItem00* pthis, GlobalContext* globalCtx); +void func_8001E1C8(EnItem00* pthis, GlobalContext* globalCtx); +void func_8001E304(EnItem00* pthis, GlobalContext* globalCtx); +void func_8001E5C8(EnItem00* pthis, GlobalContext* globalCtx); -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx); +void EnItem00_DrawRupee(EnItem00* pthis, GlobalContext* globalCtx); +void EnItem00_DrawCollectible(EnItem00* pthis, GlobalContext* globalCtx); +void EnItem00_DrawHeartContainer(EnItem00* pthis, GlobalContext* globalCtx); +void EnItem00_DrawHeartPiece(EnItem00* pthis, GlobalContext* globalCtx); -const ActorInit En_Item00_InitVars = { +ActorInit En_Item00_InitVars = { ACTOR_EN_ITEM00, ACTORCAT_MISC, FLAGS, @@ -346,76 +346,76 @@ static u8 sDropQuantities[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 0, 0, 0, 0, }; -void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnItem00_SetupAction(EnItem00* pthis, EnItem00ActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { - EnItem00* this = (EnItem00*)thisx; +void EnItem00_Init(Actor* pthisx, GlobalContext* globalCtx) { + EnItem00* pthis = (EnItem00*)pthisx; s32 pad; f32 yOffset = 980.0f; f32 shadowScale = 6.0f; s32 getItemId = GI_NONE; - s16 spawnParam8000 = this->actor.params & 0x8000; + s16 spawnParam8000 = pthis->actor.params & 0x8000; s32 pad1; - this->collectibleFlag = (this->actor.params & 0x3F00) >> 8; + pthis->collectibleFlag = (pthis->actor.params & 0x3F00) >> 8; - this->actor.params &= 0xFF; + pthis->actor.params &= 0xFF; - if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) { - Actor_Kill(&this->actor); + if (Flags_GetCollectible(globalCtx, pthis->collectibleFlag)) { + Actor_Kill(&pthis->actor); return; } - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); - this->unk_158 = 1; + pthis->unk_158 = 1; - switch (this->actor.params) { + switch (pthis->actor.params) { case ITEM00_RUPEE_GREEN: case ITEM00_RUPEE_BLUE: case ITEM00_RUPEE_RED: - Actor_SetScale(&this->actor, 0.015f); - this->scale = 0.015f; + Actor_SetScale(&pthis->actor, 0.015f); + pthis->scale = 0.015f; yOffset = 750.0f; break; case ITEM00_SMALL_KEY: - this->unk_158 = 0; - Actor_SetScale(&this->actor, 0.03f); - this->scale = 0.03f; + pthis->unk_158 = 0; + Actor_SetScale(&pthis->actor, 0.03f); + pthis->scale = 0.03f; yOffset = 350.0f; break; case ITEM00_HEART_PIECE: - this->unk_158 = 0; + pthis->unk_158 = 0; yOffset = 650.0f; - Actor_SetScale(&this->actor, 0.02f); - this->scale = 0.02f; + Actor_SetScale(&pthis->actor, 0.02f); + pthis->scale = 0.02f; break; case ITEM00_HEART: - this->actor.home.rot.z = Rand_CenteredFloat(65535.0f); + pthis->actor.home.rot.z = Rand_CenteredFloat(65535.0f); yOffset = 430.0f; - Actor_SetScale(&this->actor, 0.02f); - this->scale = 0.02f; + Actor_SetScale(&pthis->actor, 0.02f); + pthis->scale = 0.02f; break; case ITEM00_HEART_CONTAINER: yOffset = 430.0f; - this->unk_158 = 0; - Actor_SetScale(&this->actor, 0.02f); - this->scale = 0.02f; + pthis->unk_158 = 0; + Actor_SetScale(&pthis->actor, 0.02f); + pthis->scale = 0.02f; break; case ITEM00_ARROWS_SINGLE: yOffset = 400.0f; - Actor_SetScale(&this->actor, 0.02f); - this->scale = 0.02f; + Actor_SetScale(&pthis->actor, 0.02f); + pthis->scale = 0.02f; break; case ITEM00_ARROWS_SMALL: case ITEM00_ARROWS_MEDIUM: case ITEM00_ARROWS_LARGE: - Actor_SetScale(&this->actor, 0.035f); - this->scale = 0.035f; + Actor_SetScale(&pthis->actor, 0.035f); + pthis->scale = 0.035f; yOffset = 250.0f; break; case ITEM00_BOMBS_A: @@ -425,80 +425,80 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_MAGIC_SMALL: case ITEM00_SEEDS: case ITEM00_BOMBS_SPECIAL: - Actor_SetScale(&this->actor, 0.03f); - this->scale = 0.03f; + Actor_SetScale(&pthis->actor, 0.03f); + pthis->scale = 0.03f; yOffset = 320.0f; break; case ITEM00_MAGIC_LARGE: - Actor_SetScale(&this->actor, 0.045 - 1e-10); - this->scale = 0.045 - 1e-10; + Actor_SetScale(&pthis->actor, 0.045 - 1e-10); + pthis->scale = 0.045 - 1e-10; yOffset = 320.0f; break; case ITEM00_RUPEE_ORANGE: - Actor_SetScale(&this->actor, 0.045 - 1e-10); - this->scale = 0.045 - 1e-10; + Actor_SetScale(&pthis->actor, 0.045 - 1e-10); + pthis->scale = 0.045 - 1e-10; yOffset = 750.0f; break; case ITEM00_RUPEE_PURPLE: - Actor_SetScale(&this->actor, 0.03f); - this->scale = 0.03f; + Actor_SetScale(&pthis->actor, 0.03f); + pthis->scale = 0.03f; yOffset = 750.0f; break; case ITEM00_FLEXIBLE: yOffset = 500.0f; - Actor_SetScale(&this->actor, 0.01f); - this->scale = 0.01f; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->scale = 0.01f; break; case ITEM00_SHIELD_DEKU: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_1); - Actor_SetObjectDependency(globalCtx, &this->actor); - Actor_SetScale(&this->actor, 0.5f); - this->scale = 0.5f; + pthis->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_1); + Actor_SetObjectDependency(globalCtx, &pthis->actor); + Actor_SetScale(&pthis->actor, 0.5f); + pthis->scale = 0.5f; yOffset = 0.0f; shadowScale = 0.6f; - this->actor.world.rot.x = 0x4000; + pthis->actor.world.rot.x = 0x4000; break; case ITEM00_SHIELD_HYLIAN: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2); - Actor_SetObjectDependency(globalCtx, &this->actor); - Actor_SetScale(&this->actor, 0.5f); - this->scale = 0.5f; + pthis->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2); + Actor_SetObjectDependency(globalCtx, &pthis->actor); + Actor_SetScale(&pthis->actor, 0.5f); + pthis->scale = 0.5f; yOffset = 0.0f; shadowScale = 0.6f; - this->actor.world.rot.x = 0x4000; + pthis->actor.world.rot.x = 0x4000; break; case ITEM00_TUNIC_ZORA: case ITEM00_TUNIC_GORON: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_CLOTHES); - Actor_SetObjectDependency(globalCtx, &this->actor); - Actor_SetScale(&this->actor, 0.5f); - this->scale = 0.5f; + pthis->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_CLOTHES); + Actor_SetObjectDependency(globalCtx, &pthis->actor); + Actor_SetScale(&pthis->actor, 0.5f); + pthis->scale = 0.5f; yOffset = 0.0f; shadowScale = 0.6f; - this->actor.world.rot.x = 0x4000; + pthis->actor.world.rot.x = 0x4000; break; } - this->unk_156 = 0; - ActorShape_Init(&this->actor.shape, yOffset, ActorShadow_DrawCircle, shadowScale); - this->actor.shape.shadowAlpha = 180; - this->actor.focus.pos = this->actor.world.pos; - this->getItemId = GI_NONE; + pthis->unk_156 = 0; + ActorShape_Init(&pthis->actor.shape, yOffset, ActorShadow_DrawCircle, shadowScale); + pthis->actor.shape.shadowAlpha = 180; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->getItemId = GI_NONE; if (!spawnParam8000) { - EnItem00_SetupAction(this, func_8001DFC8); - this->unk_15A = -1; + EnItem00_SetupAction(pthis, func_8001DFC8); + pthis->unk_15A = -1; return; } - this->unk_15A = 15; - this->unk_154 = 35; + pthis->unk_15A = 15; + pthis->unk_154 = 35; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; - switch (this->actor.params) { + switch (pthis->actor.params) { case ITEM00_RUPEE_GREEN: Item_Give(globalCtx, ITEM_RUPEE_GREEN); break; @@ -564,183 +564,183 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { break; } - if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { - func_8002F554(&this->actor, globalCtx, getItemId); + if ((getItemId != GI_NONE) && !Actor_HasParent(&pthis->actor, globalCtx)) { + func_8002F554(&pthis->actor, globalCtx, getItemId); } - EnItem00_SetupAction(this, func_8001E5C8); - this->actionFunc(this, globalCtx); + EnItem00_SetupAction(pthis, func_8001E5C8); + pthis->actionFunc(pthis, globalCtx); } -void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnItem00* this = (EnItem00*)thisx; +void EnItem00_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + EnItem00* pthis = (EnItem00*)pthisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) { - if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk_15A < 0)) || - (this->actor.params == ITEM00_HEART_PIECE)) { - this->actor.shape.rot.y += 960; +void func_8001DFC8(EnItem00* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params <= ITEM00_RUPEE_RED) || ((pthis->actor.params == ITEM00_HEART) && (pthis->unk_15A < 0)) || + (pthis->actor.params == ITEM00_HEART_PIECE)) { + pthis->actor.shape.rot.y += 960; } else { - if ((this->actor.params >= ITEM00_SHIELD_DEKU) && (this->actor.params != ITEM00_BOMBS_SPECIAL)) { - if (this->unk_15A == -1) { - if (Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x - 0x4000, 2, 3000, 1500) == + if ((pthis->actor.params >= ITEM00_SHIELD_DEKU) && (pthis->actor.params != ITEM00_BOMBS_SPECIAL)) { + if (pthis->unk_15A == -1) { + if (Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->actor.world.rot.x - 0x4000, 2, 3000, 1500) == 0) { - this->unk_15A = -2; + pthis->unk_15A = -2; } } else { - if (Math_SmoothStepToS(&this->actor.shape.rot.x, -this->actor.world.rot.x - 0x4000, 2, 3000, 1500) == + if (Math_SmoothStepToS(&pthis->actor.shape.rot.x, -pthis->actor.world.rot.x - 0x4000, 2, 3000, 1500) == 0) { - this->unk_15A = -1; + pthis->unk_15A = -1; } } - Math_SmoothStepToS(&this->actor.world.rot.x, 0, 2, 2500, 500); + Math_SmoothStepToS(&pthis->actor.world.rot.x, 0, 2, 2500, 500); } } - if (this->actor.params == ITEM00_HEART_PIECE) { - this->actor.shape.yOffset = Math_SinS(this->actor.shape.rot.y) * 150.0f + 850.0f; + if (pthis->actor.params == ITEM00_HEART_PIECE) { + pthis->actor.shape.yOffset = Math_SinS(pthis->actor.shape.rot.y) * 150.0f + 850.0f; } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if (this->unk_154 == 0) { - if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) && - (this->actor.params != ITEM00_HEART_CONTAINER)) { - this->unk_154 = -1; + if (pthis->unk_154 == 0) { + if ((pthis->actor.params != ITEM00_SMALL_KEY) && (pthis->actor.params != ITEM00_HEART_PIECE) && + (pthis->actor.params != ITEM00_HEART_CONTAINER)) { + pthis->unk_154 = -1; } } - if (this->unk_15A == 0) { - if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) && - (this->actor.params != ITEM00_HEART_CONTAINER)) { - Actor_Kill(&this->actor); + if (pthis->unk_15A == 0) { + if ((pthis->actor.params != ITEM00_SMALL_KEY) && (pthis->actor.params != ITEM00_HEART_PIECE) && + (pthis->actor.params != ITEM00_HEART_CONTAINER)) { + Actor_Kill(&pthis->actor); } } - if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 0x0001)) { - EnItem00_SetupAction(this, func_8001E1C8); + if ((pthis->actor.gravity != 0.0f) && !(pthis->actor.bgCheckFlags & 0x0001)) { + EnItem00_SetupAction(pthis, func_8001E1C8); } } -void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) { +void func_8001E1C8(EnItem00* pthis, GlobalContext* globalCtx) { f32 originalVelocity; Vec3f effectPos; - if (this->actor.params <= ITEM00_RUPEE_RED) { - this->actor.shape.rot.y += 960; + if (pthis->actor.params <= ITEM00_RUPEE_RED) { + pthis->actor.shape.rot.y += 960; } if (globalCtx->gameplayFrames & 1) { - effectPos.x = this->actor.world.pos.x + Rand_CenteredFloat(10.0f); - effectPos.y = this->actor.world.pos.y + Rand_CenteredFloat(10.0f); - effectPos.z = this->actor.world.pos.z + Rand_CenteredFloat(10.0f); + effectPos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(10.0f); + effectPos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(10.0f); + effectPos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(10.0f); EffectSsKiraKira_SpawnSmall(globalCtx, &effectPos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if (this->actor.bgCheckFlags & 0x0003) { - originalVelocity = this->actor.velocity.y; + if (pthis->actor.bgCheckFlags & 0x0003) { + originalVelocity = pthis->actor.velocity.y; if (originalVelocity > -2.0f) { - EnItem00_SetupAction(this, func_8001DFC8); - this->actor.velocity.y = 0.0f; + EnItem00_SetupAction(pthis, func_8001DFC8); + pthis->actor.velocity.y = 0.0f; } else { - this->actor.velocity.y = originalVelocity * -0.8f; - this->actor.bgCheckFlags &= ~1; + pthis->actor.velocity.y = originalVelocity * -0.8f; + pthis->actor.bgCheckFlags &= ~1; } } } -void func_8001E304(EnItem00* this, GlobalContext* globalCtx) { +void func_8001E304(EnItem00* pthis, GlobalContext* globalCtx) { s32 pad; Vec3f pos; s32 rotOffset; - this->unk_15A++; + pthis->unk_15A++; - if (this->actor.params == ITEM00_HEART) { - if (this->actor.velocity.y < 0.0f) { - this->actor.speedXZ = 0.0f; - this->actor.gravity = -0.4f; - if (this->actor.velocity.y < -1.5f) { - this->actor.velocity.y = -1.5f; + if (pthis->actor.params == ITEM00_HEART) { + if (pthis->actor.velocity.y < 0.0f) { + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = -0.4f; + if (pthis->actor.velocity.y < -1.5f) { + pthis->actor.velocity.y = -1.5f; } - this->actor.home.rot.z += (s16)((this->actor.velocity.y + 3.0f) * 1000.0f); - this->actor.world.pos.x += - Math_CosS(this->actor.yawTowardsPlayer) * (-3.0f * Math_CosS(this->actor.home.rot.z)); - this->actor.world.pos.z += - Math_SinS(this->actor.yawTowardsPlayer) * (-3.0f * Math_CosS(this->actor.home.rot.z)); + pthis->actor.home.rot.z += (s16)((pthis->actor.velocity.y + 3.0f) * 1000.0f); + pthis->actor.world.pos.x += + Math_CosS(pthis->actor.yawTowardsPlayer) * (-3.0f * Math_CosS(pthis->actor.home.rot.z)); + pthis->actor.world.pos.z += + Math_SinS(pthis->actor.yawTowardsPlayer) * (-3.0f * Math_CosS(pthis->actor.home.rot.z)); } } - if (this->actor.params <= ITEM00_RUPEE_RED) { - this->actor.shape.rot.y += 960; - } else if ((this->actor.params >= ITEM00_SHIELD_DEKU) && (this->actor.params != ITEM00_BOMBS_SPECIAL)) { - this->actor.world.rot.x -= 700; - this->actor.shape.rot.y += 400; - this->actor.shape.rot.x = this->actor.world.rot.x - 0x4000; + if (pthis->actor.params <= ITEM00_RUPEE_RED) { + pthis->actor.shape.rot.y += 960; + } else if ((pthis->actor.params >= ITEM00_SHIELD_DEKU) && (pthis->actor.params != ITEM00_BOMBS_SPECIAL)) { + pthis->actor.world.rot.x -= 700; + pthis->actor.shape.rot.y += 400; + pthis->actor.shape.rot.x = pthis->actor.world.rot.x - 0x4000; } - if (this->actor.velocity.y <= 2.0f) { - rotOffset = (u16)this->actor.shape.rot.z + 10000; + if (pthis->actor.velocity.y <= 2.0f) { + rotOffset = (u16)pthis->actor.shape.rot.z + 10000; if (rotOffset < 65535) { - this->actor.shape.rot.z += 10000; + pthis->actor.shape.rot.z += 10000; } else { - this->actor.shape.rot.z = -1; + pthis->actor.shape.rot.z = -1; } } if (!(globalCtx->gameplayFrames & 1)) { - pos.x = this->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * 10.0f; - pos.y = this->actor.world.pos.y + (Rand_ZeroOne() - 0.5f) * 10.0f; - pos.z = this->actor.world.pos.z + (Rand_ZeroOne() - 0.5f) * 10.0f; + pos.x = pthis->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * 10.0f; + pos.y = pthis->actor.world.pos.y + (Rand_ZeroOne() - 0.5f) * 10.0f; + pos.z = pthis->actor.world.pos.z + (Rand_ZeroOne() - 0.5f) * 10.0f; EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if (this->actor.bgCheckFlags & 0x0003) { - EnItem00_SetupAction(this, func_8001DFC8); - this->actor.shape.rot.z = 0; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + if (pthis->actor.bgCheckFlags & 0x0003) { + EnItem00_SetupAction(pthis, func_8001DFC8); + pthis->actor.shape.rot.z = 0; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; } } -void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx) { +void func_8001E5C8(EnItem00* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->getItemId != GI_NONE) { - if (!Actor_HasParent(&this->actor, globalCtx)) { - func_8002F434(&this->actor, globalCtx, this->getItemId, 50.0f, 80.0f); - this->unk_15A++; + if (pthis->getItemId != GI_NONE) { + if (!Actor_HasParent(&pthis->actor, globalCtx)) { + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 50.0f, 80.0f); + pthis->unk_15A++; } else { - this->getItemId = GI_NONE; + pthis->getItemId = GI_NONE; } } - if (this->unk_15A == 0) { - Actor_Kill(&this->actor); + if (pthis->unk_15A == 0) { + Actor_Kill(&pthis->actor); return; } - this->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos = player->actor.world.pos; - if (this->actor.params <= ITEM00_RUPEE_RED) { - this->actor.shape.rot.y += 960; - } else if (this->actor.params == ITEM00_HEART) { - this->actor.shape.rot.y = 0; + if (pthis->actor.params <= ITEM00_RUPEE_RED) { + pthis->actor.shape.rot.y += 960; + } else if (pthis->actor.params == ITEM00_HEART) { + pthis->actor.shape.rot.y = 0; } - this->actor.world.pos.y += 40.0f + Math_SinS(this->unk_15A * 15000) * (this->unk_15A * 0.3f); + pthis->actor.world.pos.y += 40.0f + Math_SinS(pthis->unk_15A * 15000) * (pthis->unk_15A * 0.3f); if (LINK_IS_ADULT) { - this->actor.world.pos.y += 20.0f; + pthis->actor.world.pos.y += 20.0f; } } // The BSS in the function acted weird in the past. It is matching now but might cause issues in the future -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Update(Actor* pthisx, GlobalContext* globalCtx) { static u32 D_80157D90; static s16 D_80157D94[1]; s16* params; @@ -749,26 +749,26 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { s16 sp3A = 0; s16 i; u32* temp; - EnItem00* this = (EnItem00*)thisx; + EnItem00* pthis = (EnItem00*)pthisx; s32 pad; - if (this->unk_15A > 0) { - this->unk_15A--; + if (pthis->unk_15A > 0) { + pthis->unk_15A--; } - if ((this->unk_15A > 0) && (this->unk_15A < 41) && (this->unk_154 <= 0)) { - this->unk_156 = this->unk_15A; + if ((pthis->unk_15A > 0) && (pthis->unk_15A < 41) && (pthis->unk_154 <= 0)) { + pthis->unk_156 = pthis->unk_15A; } - this->actionFunc(this, globalCtx); - Math_SmoothStepToF(&this->actor.scale.x, this->scale, 0.1f, this->scale * 0.1f, 0.0f); + pthis->actionFunc(pthis, globalCtx); + Math_SmoothStepToF(&pthis->actor.scale.x, pthis->scale, 0.1f, pthis->scale * 0.1f, 0.0f); temp = &D_80157D90; - this->actor.scale.z = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.x; + pthis->actor.scale.z = pthis->actor.scale.x; + pthis->actor.scale.y = pthis->actor.scale.x; - if (this->actor.gravity) { - if (this->actor.bgCheckFlags & 0x0003) { + if (pthis->actor.gravity) { + if (pthis->actor.bgCheckFlags & 0x0003) { if (*temp != globalCtx->gameplayFrames) { D_80157D90 = globalCtx->gameplayFrames; D_80157D94[0] = 0; @@ -789,35 +789,35 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { } else { sp3A = 1; - Actor_MoveForward(&this->actor); + Actor_MoveForward(&pthis->actor); } if (sp3A || D_80157D94[0]) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 15.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 15.0f, 15.0f, 0x1D); - if (this->actor.floorHeight <= -10000.0f) { - Actor_Kill(&this->actor); + if (pthis->actor.floorHeight <= -10000.0f) { + Actor_Kill(&pthis->actor); return; } } } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - if ((this->actor.params == ITEM00_SHIELD_DEKU) || (this->actor.params == ITEM00_SHIELD_HYLIAN) || - (this->actor.params == ITEM00_TUNIC_ZORA) || (this->actor.params == ITEM00_TUNIC_GORON)) { - this->actor.shape.yOffset = Math_CosS(this->actor.shape.rot.x) * 37.0f; - this->actor.shape.yOffset = ABS(this->actor.shape.yOffset); + if ((pthis->actor.params == ITEM00_SHIELD_DEKU) || (pthis->actor.params == ITEM00_SHIELD_HYLIAN) || + (pthis->actor.params == ITEM00_TUNIC_ZORA) || (pthis->actor.params == ITEM00_TUNIC_GORON)) { + pthis->actor.shape.yOffset = Math_CosS(pthis->actor.shape.rot.x) * 37.0f; + pthis->actor.shape.yOffset = ABS(pthis->actor.shape.yOffset); } - if (this->unk_154 > 0) { + if (pthis->unk_154 > 0) { return; } - if (!((this->actor.xzDistToPlayer <= 30.0f) && (this->actor.yDistToPlayer >= -50.0f) && - (this->actor.yDistToPlayer <= 50.0f))) { - if (!Actor_HasParent(&this->actor, globalCtx)) { + if (!((pthis->actor.xzDistToPlayer <= 30.0f) && (pthis->actor.yDistToPlayer >= -50.0f) && + (pthis->actor.yDistToPlayer <= 50.0f))) { + if (!Actor_HasParent(&pthis->actor, globalCtx)) { return; } } @@ -826,7 +826,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { return; } - switch (this->actor.params) { + switch (pthis->actor.params) { case ITEM00_RUPEE_GREEN: Item_Give(globalCtx, ITEM_RUPEE_GREEN); break; @@ -904,10 +904,10 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { break; } - params = &this->actor.params; + params = &pthis->actor.params; - if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { - func_8002F554(&this->actor, globalCtx, getItemId); + if ((getItemId != GI_NONE) && !Actor_HasParent(&pthis->actor, globalCtx)) { + func_8002F554(&pthis->actor, globalCtx, getItemId); } switch (*params) { @@ -918,9 +918,9 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_SHIELD_HYLIAN: case ITEM00_TUNIC_ZORA: case ITEM00_TUNIC_GORON: - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, this->collectibleFlag); - Actor_Kill(&this->actor); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Flags_SetCollectible(globalCtx, pthis->collectibleFlag); + Actor_Kill(&pthis->actor); } return; } @@ -928,58 +928,58 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if ((*params <= ITEM00_RUPEE_RED) || (*params == ITEM00_RUPEE_ORANGE)) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else if (getItemId != GI_NONE) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, this->collectibleFlag); - Actor_Kill(&this->actor); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Flags_SetCollectible(globalCtx, pthis->collectibleFlag); + Actor_Kill(&pthis->actor); } return; } else { Audio_PlaySoundGeneral(NA_SE_SY_GET_ITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Flags_SetCollectible(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, pthis->collectibleFlag); - this->unk_15A = 15; - this->unk_154 = 35; - this->actor.shape.rot.z = 0; - this->actor.speedXZ = 0; - this->actor.velocity.y = 0; - this->actor.gravity = 0; + pthis->unk_15A = 15; + pthis->unk_154 = 35; + pthis->actor.shape.rot.z = 0; + pthis->actor.speedXZ = 0; + pthis->actor.velocity.y = 0; + pthis->actor.gravity = 0; - Actor_SetScale(&this->actor, this->scale); + Actor_SetScale(&pthis->actor, pthis->scale); - this->getItemId = GI_NONE; - EnItem00_SetupAction(this, func_8001E5C8); + pthis->getItemId = GI_NONE; + EnItem00_SetupAction(pthis, func_8001E5C8); } -void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnItem00* this = (EnItem00*)thisx; +void EnItem00_Draw(Actor* pthisx, GlobalContext* globalCtx) { + EnItem00* pthis = (EnItem00*)pthisx; f32 mtxScale; - if (!(this->unk_156 & this->unk_158)) { - switch (this->actor.params) { + if (!(pthis->unk_156 & pthis->unk_158)) { + switch (pthis->actor.params) { case ITEM00_RUPEE_GREEN: case ITEM00_RUPEE_BLUE: case ITEM00_RUPEE_RED: case ITEM00_RUPEE_ORANGE: case ITEM00_RUPEE_PURPLE: - EnItem00_DrawRupee(this, globalCtx); + EnItem00_DrawRupee(pthis, globalCtx); break; case ITEM00_HEART_PIECE: - EnItem00_DrawHeartPiece(this, globalCtx); + EnItem00_DrawHeartPiece(pthis, globalCtx); break; case ITEM00_HEART_CONTAINER: - EnItem00_DrawHeartContainer(this, globalCtx); + EnItem00_DrawHeartContainer(pthis, globalCtx); break; case ITEM00_HEART: - if (this->unk_15A < 0) { - if (this->unk_15A == -1) { + if (pthis->unk_15A < 0) { + if (pthis->unk_15A == -1) { s32 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART); if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) { - this->actor.objBankIndex = bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); - this->unk_15A = -2; + pthis->actor.objBankIndex = bankIndex; + Actor_SetObjectDependency(globalCtx, &pthis->actor); + pthis->unk_15A = -2; } } else { mtxScale = 16.0f; @@ -1001,7 +1001,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_MAGIC_SMALL: case ITEM00_SEEDS: case ITEM00_SMALL_KEY: - EnItem00_DrawCollectible(this, globalCtx); + EnItem00_DrawCollectible(pthis, globalCtx); break; case ITEM00_SHIELD_DEKU: GetItem_Draw(globalCtx, GID_SHIELD_DEKU); @@ -1024,19 +1024,19 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { /** * Draw Function used for Rupee types of En_Item00. */ -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawRupee(EnItem00* pthis, GlobalContext* globalCtx) { s32 pad; s32 texIndex; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1546); func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); - if (this->actor.params <= ITEM00_RUPEE_RED) { - texIndex = this->actor.params; + if (pthis->actor.params <= ITEM00_RUPEE_RED) { + texIndex = pthis->actor.params; } else { - texIndex = this->actor.params - 0x10; + texIndex = pthis->actor.params - 0x10; } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1562), @@ -1052,16 +1052,16 @@ void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { /** * Draw Function used for most collectible types of En_Item00 (ammo, bombs, sticks, nuts, magic...). */ -void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx) { - s32 texIndex = this->actor.params - 3; +void EnItem00_DrawCollectible(EnItem00* pthis, GlobalContext* globalCtx) { + s32 texIndex = pthis->actor.params - 3; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1594); POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - if (this->actor.params == ITEM00_BOMBS_SPECIAL) { + if (pthis->actor.params == ITEM00_BOMBS_SPECIAL) { texIndex = 1; - } else if (this->actor.params >= ITEM00_ARROWS_SMALL) { + } else if (pthis->actor.params >= ITEM00_ARROWS_SMALL) { texIndex -= 3; } @@ -1079,19 +1079,19 @@ void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx) { /** * Draw Function used for the Heart Container type of En_Item00. */ -void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawHeartContainer(EnItem00* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1623); func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1634), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gHeartPieceExteriorDL); func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1644), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gHeartContainerInteriorDL); @@ -1102,13 +1102,13 @@ void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx) { /** * Draw Function used for the Piece of Heart type of En_Item00. */ -void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawHeartPiece(EnItem00* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1658); func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1670), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); @@ -1133,7 +1133,7 @@ s16 func_8001F404(s16 dropId) { } } - // This is convoluted but it seems like it must be a single condition to match + // pthis is convoluted but it seems like it must be a single condition to match // clang-format off if (((dropId == ITEM00_BOMBS_A || dropId == ITEM00_BOMBS_SPECIAL || dropId == ITEM00_BOMBS_B) && INV_CONTENT(ITEM_BOMB) == ITEM_NONE) || ((dropId == ITEM00_ARROWS_SMALL || dropId == ITEM00_ARROWS_MEDIUM || dropId == ITEM00_ARROWS_LARGE) && INV_CONTENT(ITEM_BOW) == ITEM_NONE) || @@ -1162,7 +1162,7 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 pa params &= 0x3FFF; if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) { - // TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf) + // TODO: Prevent the cast to EnItem00 here since pthis is a different actor (En_Elf) spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, @@ -1205,7 +1205,7 @@ EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 p params &= 0x3FFF; if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) { - // TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf) + // TODO: Prevent the cast to EnItem00 here since pthis is a different actor (En_Elf) spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, diff --git a/src/code/z_face_reaction.c b/src/code/z_face_reaction.cpp similarity index 100% rename from src/code/z_face_reaction.c rename to src/code/z_face_reaction.cpp diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c deleted file mode 100644 index e92235e27..000000000 --- a/src/code/z_fbdemo.c +++ /dev/null @@ -1,238 +0,0 @@ -#define INTERNAL_SRC_CODE_Z_FBDEMO_C -#include "global.h" -#include "gfx.h" -#include "z64transition.h" -#include "def/mtxf2l.h" -#include "def/ortho.h" -#include "def/sleep.h" -#include "def/system_malloc.h" -#include "def/z_fbdemo.h" - -Gfx D_8012AFB0[] = { - gsDPPipeSync(), - gsDPSetCycleType(G_CYC_FILL), - gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, 0x0F000000), - gsDPSetFillColor((GPACK_RGBA5551(65, 65, 65, 1) << 16) | GPACK_RGBA5551(65, 65, 65, 1)), - gsDPFillRectangle(0, 0, 319, 239), - gsDPPipeSync(), - gsDPSetFillColor((GPACK_RGBA5551(65, 65, 255, 1) << 16) | GPACK_RGBA5551(65, 65, 255, 1)), - gsDPFillRectangle(20, 20, 300, 220), - gsDPPipeSync(), - gsSPEndDisplayList(), -}; - -Gfx D_8012B000[] = { - gsDPPipeSync(), - gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON), - gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | - G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), - gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), - gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_1PRIMITIVE, - G_AC_NONE | G_ZS_PIXEL | G_RM_AA_OPA_SURF | G_RM_AA_OPA_SURF2), - gsSPEndDisplayList(), -}; - -void TransitionUnk_InitGraphics(TransitionUnk* this) { - s32 row2; - s32 pad2; - s32 pad3; - Vtx_t* vtx2; - s32 frame; - s32 rowTex; - s32 row; - Gfx* gfx; - Vtx* vtx; - s32 col; - s32 colTex; - - guMtxIdent(&this->modelView); - guMtxIdent(&this->unk_98); - guOrtho(&this->projection, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -1000.0f, 1000.0f, 1.0f); - - for (frame = 0; frame < 2; frame++) { - this->frame = frame; - vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; - for (colTex = 0, col = 0; col < this->col + 1; colTex += 0x20, col++) { - for (rowTex = 0, row = 0; row < this->row + 1; row++) { - vtx2 = &vtx->v; - vtx++; - - vtx2->tc[0] = rowTex << 6; - vtx2->ob[0] = row * 0x20; - vtx2->ob[1] = col * 0x20; - vtx2->ob[2] = -5; - vtx2->flag = 0; - vtx2->tc[1] = colTex << 6; - vtx2->cn[0] = 0; - vtx2->cn[1] = 0; - vtx2->cn[2] = 120; - vtx2->cn[3] = 255; - rowTex += 0x20; - } - } - } - - gfx = this->gfx; - for (colTex = 0, col = 0; col < this->col; colTex += 0x20, col++) { - - gSPVertex(gfx++, SEGMENT_ADDR(0xA, (u32)col * (this->row + 1) * sizeof(Vtx)), 2 * (this->row + 1), 0); - - for (rowTex = 0, row = 0, row2 = 0; row < this->row;) { - gDPPipeSync(gfx++); - - gDPLoadTextureTile(gfx++, SEGMENT_ADDR(0xB, 0), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SCREEN_HEIGHT, - rowTex, colTex, rowTex + 0x20, colTex + 0x20, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - - gSP1Quadrangle(gfx++, row, row + 1, row2 + this->row + 2, this->row + row2 + 1, 0); - - rowTex += 0x20; - row2++; - row++; - } - } - - gDPPipeSync(gfx++); - gSPEndDisplayList(gfx++); - - LOG_NUM("this->col * (1 + this->row * (1 + 7 + 1)) + 1 + 1", this->col * (1 + this->row * 9) + 2, "../z_fbdemo.c", - 144); - LOG_NUM("gp - this->gfxtbl", gfx - this->gfx, "../z_fbdemo.c", 145); -} - -void TransitionUnk_InitData(TransitionUnk* this) { - s32 col; - s32 row; - - for (col = 0; col < this->col + 1; col++) { - for (row = 0; row < this->row + 1; row++) { - (this->unk_0C + row + col * (this->row + 1))->unk_0 = row * 32; - (this->unk_0C + row + col * (this->row + 1))->unk_4 = col * 32; - } - } -} - -void TransitionUnk_Destroy(TransitionUnk* this) { - osSyncPrintf("fbdemo_cleanup(%08x)\n", this); - osSyncPrintf("msleep(100);\n"); - Sleep_Msec(100); - - if (this->unk_0C != NULL) { - SystemArena_FreeDebug(this->unk_0C, "../z_fbdemo.c", 180); - this->unk_0C = NULL; - } - if (this->vtxFrame1 != NULL) { - SystemArena_FreeDebug(this->vtxFrame1, "../z_fbdemo.c", 181); - this->vtxFrame1 = NULL; - } - if (this->vtxFrame2 != NULL) { - SystemArena_FreeDebug(this->vtxFrame2, "../z_fbdemo.c", 182); - this->vtxFrame2 = NULL; - } - if (this->gfx != NULL) { - SystemArena_FreeDebug(this->gfx, "../z_fbdemo.c", 183); - this->gfx = NULL; - } -} - -TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col) { - osSyncPrintf("fbdemo_init(%08x, %d, %d)\n", this, row, col); - bzero(this, sizeof(*this)); - this->frame = 0; - this->row = row; - this->col = col; - this->unk_0C = SystemArena_MallocDebug((row + 1) * sizeof(TransitionUnkData) * (col + 1), "../z_fbdemo.c", 195); - this->vtxFrame1 = SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 196); - this->vtxFrame2 = SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 197); - this->gfx = SystemArena_MallocDebug((this->col * (1 + this->row * 9) + 2) * sizeof(Gfx), "../z_fbdemo.c", 198); - - if (this->unk_0C == NULL || this->vtxFrame1 == NULL || this->vtxFrame2 == NULL || this->gfx == NULL) { - osSyncPrintf("fbdemo_init allocation error\n"); - if (this->unk_0C != NULL) { - SystemArena_FreeDebug(this->unk_0C, "../z_fbdemo.c", 202); - this->unk_0C = NULL; - } - if (this->vtxFrame1 != NULL) { - SystemArena_FreeDebug(this->vtxFrame1, "../z_fbdemo.c", 203); - this->vtxFrame1 = NULL; - } - if (this->vtxFrame2 != NULL) { - SystemArena_FreeDebug(this->vtxFrame2, "../z_fbdemo.c", 204); - this->vtxFrame2 = NULL; - } - if (this->gfx != NULL) { - SystemArena_FreeDebug(this->gfx, "../z_fbdemo.c", 205); - this->gfx = NULL; - } - return NULL; - } - TransitionUnk_InitGraphics(this); - TransitionUnk_InitData(this); - this->frame = 0; - - return this; -} - -void TransitionUnk_SetData(TransitionUnk* this) { - s32 col; - Vtx* vtx; - s32 row; - - for (col = 0; col < this->col + 1; col++) { - for (row = 0; row < this->row + 1; row++) { - vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; - (vtx + row + col * (this->row + 1))->v.ob[0] = (this->unk_0C + row + col * (this->row + 1))->unk_0; - vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; - (vtx + row + col * (this->row + 1))->v.ob[1] = (this->unk_0C + row + col * (this->row + 1))->unk_4; - } - } -} - -void TransitionUnk_Draw(TransitionUnk* this, Gfx** gfxP) { - Gfx* gfx = *gfxP; - - gSPDisplayList(gfx++, D_8012B000); - TransitionUnk_SetData(this); - gSPMatrix(gfx++, &this->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - gSPMatrix(gfx++, &this->modelView, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(gfx++, 0xA, this->frame == 0 ? this->vtxFrame1 : this->vtxFrame2); - gSPSegment(gfx++, 0xB, this->zBuffer); - gSPDisplayList(gfx++, D_8012B000); - gSPDisplayList(gfx++, this->gfx); - gDPPipeSync(gfx++); - this->frame ^= 1; - *gfxP = gfx; -} - -void TransitionUnk_Update(TransitionUnk* this) { - f32 temp_f00; - f32 temp_f12; - s32 col; - f32 phi_f14; - s32 row; - - for (col = 0; col < this->col + 1; col++) { - for (row = 0; row < this->row + 1; row++) { - temp_f00 = - (this->unk_0C + row + col * (this->row + 1))->unk_0 - (this->unk_0C + 5 + 4 * (this->row + 1))->unk_0; - temp_f12 = - (this->unk_0C + row + col * (this->row + 1))->unk_4 - (this->unk_0C + 5 + 4 * (this->row + 1))->unk_4; - phi_f14 = (SQ(temp_f00) + SQ(temp_f12)) / 100.0f; - if (phi_f14 != 0.0f) { - if (phi_f14 < 1.0f) { - phi_f14 = 1.0f; - } - (this->unk_0C + row + col * (this->row + 1))->unk_0 -= temp_f00 / phi_f14; - (this->unk_0C + row + col * (this->row + 1))->unk_4 -= temp_f12 / phi_f14; - } - } - } -} - -void func_800B23E8(TransitionUnk* this) { -} - -s32 func_800B23F0(TransitionUnk* this) { - return 0; -} diff --git a/src/code/z_fbdemo.cpp b/src/code/z_fbdemo.cpp new file mode 100644 index 000000000..66b56e7e2 --- /dev/null +++ b/src/code/z_fbdemo.cpp @@ -0,0 +1,238 @@ +#define INTERNAL_SRC_CODE_Z_FBDEMO_C +#include "global.h" +#include "gfx.h" +#include "z64transition.h" +#include "def/mtxf2l.h" +#include "def/ortho.h" +#include "def/sleep.h" +#include "def/system_malloc.h" +#include "def/z_fbdemo.h" + +Gfx D_8012AFB0[] = { + gsDPPipeSync(), + gsDPSetCycleType(G_CYC_FILL), + gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, 0x0F000000), + gsDPSetFillColor((GPACK_RGBA5551(65, 65, 65, 1) << 16) | GPACK_RGBA5551(65, 65, 65, 1)), + gsDPFillRectangle(0, 0, 319, 239), + gsDPPipeSync(), + gsDPSetFillColor((GPACK_RGBA5551(65, 65, 255, 1) << 16) | GPACK_RGBA5551(65, 65, 255, 1)), + gsDPFillRectangle(20, 20, 300, 220), + gsDPPipeSync(), + gsSPEndDisplayList(), +}; + +Gfx D_8012B000[] = { + gsDPPipeSync(), + gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_AA_OPA_SURF | G_RM_AA_OPA_SURF2), + gsSPEndDisplayList(), +}; + +void TransitionUnk_InitGraphics(TransitionUnk* pthis) { + s32 row2; + s32 pad2; + s32 pad3; + Vtx_t* vtx2; + s32 frame; + s32 rowTex; + s32 row; + Gfx* gfx; + Vtx* vtx; + s32 col; + s32 colTex; + + guMtxIdent(&pthis->modelView); + guMtxIdent(&pthis->unk_98); + guOrtho(&pthis->projection, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -1000.0f, 1000.0f, 1.0f); + + for (frame = 0; frame < 2; frame++) { + pthis->frame = frame; + vtx = (pthis->frame == 0) ? pthis->vtxFrame1 : pthis->vtxFrame2; + for (colTex = 0, col = 0; col < pthis->col + 1; colTex += 0x20, col++) { + for (rowTex = 0, row = 0; row < pthis->row + 1; row++) { + vtx2 = &vtx->v; + vtx++; + + vtx2->tc[0] = rowTex << 6; + vtx2->ob[0] = row * 0x20; + vtx2->ob[1] = col * 0x20; + vtx2->ob[2] = -5; + vtx2->flag = 0; + vtx2->tc[1] = colTex << 6; + vtx2->cn[0] = 0; + vtx2->cn[1] = 0; + vtx2->cn[2] = 120; + vtx2->cn[3] = 255; + rowTex += 0x20; + } + } + } + + gfx = pthis->gfx; + for (colTex = 0, col = 0; col < pthis->col; colTex += 0x20, col++) { + + gSPVertex(gfx++, SEGMENT_ADDR(0xA, (u32)col * (pthis->row + 1) * sizeof(Vtx)), 2 * (pthis->row + 1), 0); + + for (rowTex = 0, row = 0, row2 = 0; row < pthis->row;) { + gDPPipeSync(gfx++); + + gDPLoadTextureTile(gfx++, SEGMENT_ADDR(0xB, 0), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SCREEN_HEIGHT, + rowTex, colTex, rowTex + 0x20, colTex + 0x20, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(gfx++, row, row + 1, row2 + pthis->row + 2, pthis->row + row2 + 1, 0); + + rowTex += 0x20; + row2++; + row++; + } + } + + gDPPipeSync(gfx++); + gSPEndDisplayList(gfx++); + + LOG_NUM("pthis->col * (1 + pthis->row * (1 + 7 + 1)) + 1 + 1", pthis->col * (1 + pthis->row * 9) + 2, "../z_fbdemo.c", + 144); + LOG_NUM("gp - pthis->gfxtbl", gfx - pthis->gfx, "../z_fbdemo.c", 145); +} + +void TransitionUnk_InitData(TransitionUnk* pthis) { + s32 col; + s32 row; + + for (col = 0; col < pthis->col + 1; col++) { + for (row = 0; row < pthis->row + 1; row++) { + (pthis->unk_0C + row + col * (pthis->row + 1))->unk_0 = row * 32; + (pthis->unk_0C + row + col * (pthis->row + 1))->unk_4 = col * 32; + } + } +} + +void TransitionUnk_Destroy(TransitionUnk* pthis) { + osSyncPrintf("fbdemo_cleanup(%08x)\n", pthis); + osSyncPrintf("msleep(100);\n"); + Sleep_Msec(100); + + if (pthis->unk_0C != NULL) { + SystemArena_FreeDebug(pthis->unk_0C, "../z_fbdemo.c", 180); + pthis->unk_0C = NULL; + } + if (pthis->vtxFrame1 != NULL) { + SystemArena_FreeDebug(pthis->vtxFrame1, "../z_fbdemo.c", 181); + pthis->vtxFrame1 = NULL; + } + if (pthis->vtxFrame2 != NULL) { + SystemArena_FreeDebug(pthis->vtxFrame2, "../z_fbdemo.c", 182); + pthis->vtxFrame2 = NULL; + } + if (pthis->gfx != NULL) { + SystemArena_FreeDebug(pthis->gfx, "../z_fbdemo.c", 183); + pthis->gfx = NULL; + } +} + +TransitionUnk* TransitionUnk_Init(TransitionUnk* pthis, s32 row, s32 col) { + osSyncPrintf("fbdemo_init(%08x, %d, %d)\n", pthis, row, col); + bzero(pthis, sizeof(*pthis)); + pthis->frame = 0; + pthis->row = row; + pthis->col = col; + pthis->unk_0C = (TransitionUnkData*)SystemArena_MallocDebug((row + 1) * sizeof(TransitionUnkData) * (col + 1), "../z_fbdemo.c", 195); + pthis->vtxFrame1 = (Vtx*)SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 196); + pthis->vtxFrame2 = (Vtx*)SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 197); + pthis->gfx = (Gfx*)SystemArena_MallocDebug((pthis->col * (1 + pthis->row * 9) + 2) * sizeof(Gfx), "../z_fbdemo.c", 198); + + if (pthis->unk_0C == NULL || pthis->vtxFrame1 == NULL || pthis->vtxFrame2 == NULL || pthis->gfx == NULL) { + osSyncPrintf("fbdemo_init allocation error\n"); + if (pthis->unk_0C != NULL) { + SystemArena_FreeDebug(pthis->unk_0C, "../z_fbdemo.c", 202); + pthis->unk_0C = NULL; + } + if (pthis->vtxFrame1 != NULL) { + SystemArena_FreeDebug(pthis->vtxFrame1, "../z_fbdemo.c", 203); + pthis->vtxFrame1 = NULL; + } + if (pthis->vtxFrame2 != NULL) { + SystemArena_FreeDebug(pthis->vtxFrame2, "../z_fbdemo.c", 204); + pthis->vtxFrame2 = NULL; + } + if (pthis->gfx != NULL) { + SystemArena_FreeDebug(pthis->gfx, "../z_fbdemo.c", 205); + pthis->gfx = NULL; + } + return NULL; + } + TransitionUnk_InitGraphics(pthis); + TransitionUnk_InitData(pthis); + pthis->frame = 0; + + return pthis; +} + +void TransitionUnk_SetData(TransitionUnk* pthis) { + s32 col; + Vtx* vtx; + s32 row; + + for (col = 0; col < pthis->col + 1; col++) { + for (row = 0; row < pthis->row + 1; row++) { + vtx = (pthis->frame == 0) ? pthis->vtxFrame1 : pthis->vtxFrame2; + (vtx + row + col * (pthis->row + 1))->v.ob[0] = (pthis->unk_0C + row + col * (pthis->row + 1))->unk_0; + vtx = (pthis->frame == 0) ? pthis->vtxFrame1 : pthis->vtxFrame2; + (vtx + row + col * (pthis->row + 1))->v.ob[1] = (pthis->unk_0C + row + col * (pthis->row + 1))->unk_4; + } + } +} + +void TransitionUnk_Draw(TransitionUnk* pthis, Gfx** gfxP) { + Gfx* gfx = *gfxP; + + gSPDisplayList(gfx++, D_8012B000); + TransitionUnk_SetData(pthis); + gSPMatrix(gfx++, &pthis->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, &pthis->modelView, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(gfx++, 0xA, pthis->frame == 0 ? pthis->vtxFrame1 : pthis->vtxFrame2); + gSPSegment(gfx++, 0xB, pthis->zBuffer); + gSPDisplayList(gfx++, D_8012B000); + gSPDisplayList(gfx++, pthis->gfx); + gDPPipeSync(gfx++); + pthis->frame ^= 1; + *gfxP = gfx; +} + +void TransitionUnk_Update(TransitionUnk* pthis) { + f32 temp_f00; + f32 temp_f12; + s32 col; + f32 phi_f14; + s32 row; + + for (col = 0; col < pthis->col + 1; col++) { + for (row = 0; row < pthis->row + 1; row++) { + temp_f00 = + (pthis->unk_0C + row + col * (pthis->row + 1))->unk_0 - (pthis->unk_0C + 5 + 4 * (pthis->row + 1))->unk_0; + temp_f12 = + (pthis->unk_0C + row + col * (pthis->row + 1))->unk_4 - (pthis->unk_0C + 5 + 4 * (pthis->row + 1))->unk_4; + phi_f14 = (SQ(temp_f00) + SQ(temp_f12)) / 100.0f; + if (phi_f14 != 0.0f) { + if (phi_f14 < 1.0f) { + phi_f14 = 1.0f; + } + (pthis->unk_0C + row + col * (pthis->row + 1))->unk_0 -= temp_f00 / phi_f14; + (pthis->unk_0C + row + col * (pthis->row + 1))->unk_4 -= temp_f12 / phi_f14; + } + } + } +} + +void func_800B23E8(TransitionUnk* pthis) { +} + +s32 func_800B23F0(TransitionUnk* pthis) { + return 0; +} diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.cpp similarity index 55% rename from src/code/z_fbdemo_circle.c rename to src/code/z_fbdemo_circle.cpp index 001f329df..666cd254e 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.cpp @@ -10,7 +10,7 @@ Gfx sCircleNullDList[] = { gsSPEndDisplayList(), }; -#include "code/fbdemo_circle/z_fbdemo_circle.c" +#include "code/fbdemo_circle/z_fbdemo_circle.cpp" #include "def/code_800F7260.h" #include "def/lookat.h" #include "def/perspective.h" @@ -48,97 +48,97 @@ Gfx sCircleDList[] = { }; void TransitionCircle_Start(void* thisx) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; - this->isDone = 0; + pthis->isDone = 0; - switch (this->effect) { + switch (pthis->effect) { case 1: - this->texture = sCircleWipeWaveTex; + pthis->texture = sCircleWipeWaveTex; break; case 2: - this->texture = sCircleWipeRippleTex; + pthis->texture = sCircleWipeRippleTex; break; case 3: - this->texture = sCircleWipeStarburstTex; + pthis->texture = sCircleWipeStarburstTex; break; default: - this->texture = sCircleWipeDefaultTex; + pthis->texture = sCircleWipeDefaultTex; break; } - if (this->speed == 0) { - this->step = 0x14; + if (pthis->speed == 0) { + pthis->step = 0x14; } else { - this->step = 0xA; + pthis->step = 0xA; } - if (this->typeColor == 0) { - this->color.rgba = RGBA8(0, 0, 0, 255); - } else if (this->typeColor == 1) { - this->color.rgba = RGBA8(160, 160, 160, 255); - } else if (this->typeColor == 2) { + if (pthis->typeColor == 0) { + pthis->color.rgba = RGBA8(0, 0, 0, 255); + } else if (pthis->typeColor == 1) { + pthis->color.rgba = RGBA8(160, 160, 160, 255); + } else if (pthis->typeColor == 2) { // yes, really. - this->color.r = 100; - this->color.g = 100; - this->color.b = 100; - this->color.a = 255; + pthis->color.r = 100; + pthis->color.g = 100; + pthis->color.b = 100; + pthis->color.a = 255; } else { - this->step = 0x28; - this->color.rgba = this->effect == 1 ? RGBA8(0, 0, 0, 255) : RGBA8(160, 160, 160, 255); + pthis->step = 0x28; + pthis->color.rgba = pthis->effect == 1 ? RGBA8(0, 0, 0, 255) : RGBA8(160, 160, 160, 255); } - if (this->unk_14 != 0) { - this->texY = 0; - if (this->typeColor == 3) { - this->texY = 0xFA; + if (pthis->unk_14 != 0) { + pthis->texY = 0; + if (pthis->typeColor == 3) { + pthis->texY = 0xFA; } } else { - this->texY = 0x1F4; - if (this->effect == 2) { + pthis->texY = 0x1F4; + if (pthis->effect == 2) { Audio_PlaySoundGeneral(NA_SE_OC_SECRET_WARP_OUT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } - guPerspective(&this->projection, &this->normal, 60.0f, (4.0f / 3.0f), 10.0f, 12800.0f, 1.0f); - guLookAt(&this->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); + guPerspective(&pthis->projection, &pthis->normal, 60.0f, (4.0f / 3.0f), 10.0f, 12800.0f, 1.0f); + guLookAt(&pthis->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); } void* TransitionCircle_Init(void* thisx) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; - bzero(this, sizeof(*this)); - return this; + bzero(pthis, sizeof(*pthis)); + return pthis; } void TransitionCircle_Destroy(void* thisx) { } void TransitionCircle_Update(void* thisx, s32 updateRate) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; s32 temp_t2; s32 temp_t3; - if (this->unk_14 != 0) { - if (this->texY == 0) { - if (this->effect == 2) { + if (pthis->unk_14 != 0) { + if (pthis->texY == 0) { + if (pthis->effect == 2) { Audio_PlaySoundGeneral(NA_SE_OC_SECRET_WARP_IN, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } - this->texY += this->step * 3 / updateRate; - if (this->texY >= 0x1F4) { - this->texY = 0x1F4; - this->isDone = 1; + pthis->texY += pthis->step * 3 / updateRate; + if (pthis->texY >= 0x1F4) { + pthis->texY = 0x1F4; + pthis->isDone = 1; } } else { - this->texY -= this->step * 3 / updateRate; - if (this->typeColor != 3) { - if (this->texY <= 0) { - this->texY = 0; - this->isDone = 1; + pthis->texY -= pthis->step * 3 / updateRate; + if (pthis->typeColor != 3) { + if (pthis->texY <= 0) { + pthis->texY = 0; + pthis->isDone = 1; } } else { - if (this->texY < 0xFB) { - this->texY = 0xFA; - this->isDone = 1; + if (pthis->texY < 0xFB) { + pthis->texY = 0xFA; + pthis->isDone = 1; } } } @@ -147,25 +147,25 @@ void TransitionCircle_Update(void* thisx, s32 updateRate) { void TransitionCircle_Draw(void* thisx, Gfx** gfxP) { Gfx* gfx = *gfxP; Mtx* modelView; - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; Gfx* texScroll; // These variables are a best guess based on the other transition types. f32 tPos = 0.0f; f32 rot = 0.0f; f32 scale = 14.8f; - modelView = this->modelView[this->frame]; + modelView = pthis->modelView[pthis->frame]; - this->frame ^= 1; + pthis->frame ^= 1; gDPPipeSync(gfx++); - texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0x10, 0x40); + texScroll = Gfx_BranchTexScroll(&gfx, pthis->texX, pthis->texY, 0x10, 0x40); gSPSegment(gfx++, 9, texScroll); - gSPSegment(gfx++, 8, this->texture); - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); - gDPSetColor(gfx++, G_SETENVCOLOR, this->color.rgba); - gSPMatrix(gfx++, &this->projection, G_MTX_PROJECTION | G_MTX_LOAD); - gSPPerspNormalize(gfx++, this->normal); - gSPMatrix(gfx++, &this->lookAt, G_MTX_PROJECTION | G_MTX_NOPUSH | G_MTX_MUL); + gSPSegment(gfx++, 8, pthis->texture); + gDPSetColor(gfx++, G_SETPRIMCOLOR, pthis->color.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, pthis->color.rgba); + gSPMatrix(gfx++, &pthis->projection, G_MTX_PROJECTION | G_MTX_LOAD); + gSPPerspNormalize(gfx++, pthis->normal); + gSPMatrix(gfx++, &pthis->lookAt, G_MTX_PROJECTION | G_MTX_NOPUSH | G_MTX_MUL); if (scale != 1.0f) { guScale(&modelView[0], scale, scale, 1.0f); @@ -187,34 +187,34 @@ void TransitionCircle_Draw(void* thisx, Gfx** gfxP) { } s32 TransitionCircle_IsDone(void* thisx) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; - return this->isDone; + return pthis->isDone; } void TransitionCircle_SetType(void* thisx, s32 type) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; if (type & 0x80) { - this->unk_14 = (type >> 5) & 0x1; - this->typeColor = (type >> 3) & 0x3; - this->speed = type & 0x1; - this->effect = (type >> 1) & 0x3; + pthis->unk_14 = (type >> 5) & 0x1; + pthis->typeColor = (type >> 3) & 0x3; + pthis->speed = type & 0x1; + pthis->effect = (type >> 1) & 0x3; } else if (type == 1) { - this->unk_14 = 1; + pthis->unk_14 = 1; } else { - this->unk_14 = 0; + pthis->unk_14 = 0; } } void TransitionCircle_SetColor(void* thisx, u32 color) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; - this->color.rgba = color; + pthis->color.rgba = color; } void TransitionCircle_SetEnvColor(void* thisx, u32 envColor) { - TransitionCircle* this = (TransitionCircle*)thisx; + TransitionCircle* pthis = (TransitionCircle*)thisx; - this->envColor.rgba = envColor; + pthis->envColor.rgba = envColor; } diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.cpp similarity index 55% rename from src/code/z_fbdemo_fade.c rename to src/code/z_fbdemo_fade.cpp index 4439745aa..7da3b9061 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.cpp @@ -22,57 +22,57 @@ static Gfx sRCPSetupFade[] = { gsSPEndDisplayList(), }; -void TransitionFade_Start(void* thisx) { - TransitionFade* this = (TransitionFade*)thisx; +void TransitionFade_Start(void* pthisx) { + TransitionFade* pthis = (TransitionFade*)pthisx; - switch (this->fadeType) { + switch (pthis->fadeType) { case 0: break; case 1: - this->fadeTimer = 0; - this->fadeColor.a = this->fadeDirection != 0 ? 0xFF : 0; + pthis->fadeTimer = 0; + pthis->fadeColor.a = pthis->fadeDirection != 0 ? 0xFF : 0; break; case 2: - this->fadeColor.a = 0; + pthis->fadeColor.a = 0; break; } - this->isDone = 0; + pthis->isDone = 0; } -void* TransitionFade_Init(void* thisx) { - TransitionFade* this = (TransitionFade*)thisx; +void* TransitionFade_Init(void* pthisx) { + TransitionFade* pthis = (TransitionFade*)pthisx; - bzero(this, sizeof(*this)); - return this; + bzero(pthis, sizeof(*pthis)); + return pthis; } -void TransitionFade_Destroy(void* thisx) { +void TransitionFade_Destroy(void* pthisx) { } -void TransitionFade_Update(void* thisx, s32 updateRate) { +void TransitionFade_Update(void* pthisx, s32 updateRate) { s32 alpha; s16 newAlpha; - TransitionFade* this = (TransitionFade*)thisx; + TransitionFade* pthis = (TransitionFade*)pthisx; - switch (this->fadeType) { + switch (pthis->fadeType) { case 0: break; case 1: - this->fadeTimer += updateRate; - if (this->fadeTimer >= gSaveContext.fadeDuration) { - this->fadeTimer = gSaveContext.fadeDuration; - this->isDone = 1; + pthis->fadeTimer += updateRate; + if (pthis->fadeTimer >= gSaveContext.fadeDuration) { + pthis->fadeTimer = gSaveContext.fadeDuration; + pthis->isDone = 1; } if (!gSaveContext.fadeDuration) { // "Divide by 0! Zero is included in ZCommonGet fade_speed" osSyncPrintf(VT_COL(RED, WHITE) "0除算! ZCommonGet fade_speed に0がはいってる" VT_RST); } - alpha = (255.0f * this->fadeTimer) / ((void)0, gSaveContext.fadeDuration); - this->fadeColor.a = (this->fadeDirection != 0) ? 255 - alpha : alpha; + alpha = (255.0f * pthis->fadeTimer) / ((void)0, gSaveContext.fadeDuration); + pthis->fadeColor.a = (pthis->fadeDirection != 0) ? 255 - alpha : alpha; break; case 2: - newAlpha = this->fadeColor.a; + newAlpha = pthis->fadeColor.a; if (iREG(50) != 0) { if (iREG(50) < 0) { if (Math_StepToS(&newAlpha, 255, 255)) { @@ -82,19 +82,19 @@ void TransitionFade_Update(void* thisx, s32 updateRate) { Math_StepToS(&iREG(50), 20, 60); if (Math_StepToS(&newAlpha, 0, iREG(50))) { iREG(50) = 0; - this->isDone = 1; + pthis->isDone = 1; } } } - this->fadeColor.a = newAlpha; + pthis->fadeColor.a = newAlpha; break; } } -void TransitionFade_Draw(void* thisx, Gfx** gfxP) { - TransitionFade* this = (TransitionFade*)thisx; +void TransitionFade_Draw(void* pthisx, Gfx** gfxP) { + TransitionFade* pthis = (TransitionFade*)pthisx; Gfx* gfx; - Color_RGBA8_u32* color = &this->fadeColor; + Color_RGBA8_u32* color = &pthis->fadeColor; if (color->a > 0) { gfx = *gfxP; @@ -106,30 +106,30 @@ void TransitionFade_Draw(void* thisx, Gfx** gfxP) { } } -s32 TransitionFade_IsDone(void* thisx) { - TransitionFade* this = (TransitionFade*)thisx; +s32 TransitionFade_IsDone(void* pthisx) { + TransitionFade* pthis = (TransitionFade*)pthisx; - return this->isDone; + return pthis->isDone; } -void TransitionFade_SetColor(void* thisx, u32 color) { - TransitionFade* this = (TransitionFade*)thisx; +void TransitionFade_SetColor(void* pthisx, u32 color) { + TransitionFade* pthis = (TransitionFade*)pthisx; - this->fadeColor.rgba = color; + pthis->fadeColor.rgba = color; } -void TransitionFade_SetType(void* thisx, s32 type) { - TransitionFade* this = (TransitionFade*)thisx; +void TransitionFade_SetType(void* pthisx, s32 type) { + TransitionFade* pthis = (TransitionFade*)pthisx; if (type == 1) { - this->fadeType = 1; - this->fadeDirection = 1; + pthis->fadeType = 1; + pthis->fadeDirection = 1; } else if (type == 2) { - this->fadeType = 1; - this->fadeDirection = 0; + pthis->fadeType = 1; + pthis->fadeDirection = 0; } else if (type == 3) { - this->fadeType = 2; + pthis->fadeType = 2; } else { - this->fadeType = 0; + pthis->fadeType = 0; } } diff --git a/src/code/z_fbdemo_triforce.c b/src/code/z_fbdemo_triforce.c deleted file mode 100644 index 701e1ba18..000000000 --- a/src/code/z_fbdemo_triforce.c +++ /dev/null @@ -1,137 +0,0 @@ -#define INTERNAL_SRC_CODE_Z_FBDEMO_TRIFORCE_C -#include "global.h" -#include "z64transition.h" -#include "code/fbdemo_triforce/z_fbdemo_triforce.c" -#include "def/ortho.h" -#include "def/rotate.h" -#include "def/scale.h" -#include "def/translate.h" -#include "def/z_fbdemo_triforce.h" - -void TransitionTriforce_Start(void* thisx) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - - switch (this->state) { - case 1: - case 2: - this->transPos = 1.0f; - return; - } - this->transPos = 0.03f; -} - -void* TransitionTriforce_Init(void* thisx) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - - bzero(this, sizeof(*this)); - guOrtho(&this->projection, -160.0f, 160.0f, -120.0f, 120.0f, -1000.0f, 1000.0f, 1.0f); - this->transPos = 1.0f; - this->state = 2; - this->step = 0.015f; - this->fadeDirection = 1; - return this; -} - -void TransitionTriforce_Destroy(void* thisx) { -} - -void TransitionTriforce_Update(void* thisx, s32 updateRate) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - f32 temp_f0; - s32 i; - - for (i = updateRate; i > 0; i--) { - if (this->state == 1) { - this->transPos = CLAMP_MIN(this->transPos * (1.0f - this->step), 0.03f); - } else if (this->state == 2) { - this->transPos = CLAMP_MIN(this->transPos - this->step, 0.03f); - } else if (this->state == 3) { - this->transPos = CLAMP_MAX(this->transPos / (1.0f - this->step), 1.0f); - } else if (this->state == 4) { - this->transPos = CLAMP_MAX(this->transPos + this->step, 1.0f); - } - } -} - -void TransitionTriforce_SetColor(void* thisx, u32 color) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - - this->color.rgba = color; -} - -void TransitionTriforce_SetType(void* thisx, s32 type) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - - this->fadeDirection = type; -} - -// unused -void TransitionTriforce_SetState(void* thisx, s32 state) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - - this->state = state; -} - -void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) { - Gfx* gfx = *gfxP; - Mtx* modelView; - f32 scale; - TransitionTriforce* this = (TransitionTriforce*)thisx; - s32 pad; - f32 rotation = this->transPos * 360.0f; - - modelView = this->modelView[this->frame]; - scale = this->transPos * 0.625f; - this->frame ^= 1; - osSyncPrintf("rate=%f tx=%f ty=%f rotate=%f\n", this->transPos, 0.0f, 0.0f, rotation); - guScale(&modelView[0], scale, scale, 1.0f); - guRotate(&modelView[1], rotation, 0.0f, 0.0f, 1.0f); - guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); - gDPPipeSync(gfx++); - gSPDisplayList(gfx++, sTriforceWipeDL); - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); - gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); - gSPMatrix(gfx++, &this->projection, G_MTX_LOAD | G_MTX_PROJECTION); - gSPMatrix(gfx++, &modelView[0], G_MTX_LOAD); - gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MODELVIEW | G_MTX_MUL); - gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MODELVIEW | G_MTX_MUL); - gSPVertex(gfx++, sTriforceWipeVtx, 10, 0); - if (!TransitionTriforce_IsDone(this)) { - switch (this->fadeDirection) { - case 1: - gSP2Triangles(gfx++, 0, 4, 5, 0, 4, 1, 3, 0); - gSP1Triangle(gfx++, 5, 3, 2, 0); - break; - case 2: - gSP2Triangles(gfx++, 3, 4, 5, 0, 0, 2, 6, 0); - gSP2Triangles(gfx++, 0, 6, 7, 0, 1, 0, 7, 0); - gSP2Triangles(gfx++, 1, 7, 8, 0, 1, 8, 9, 0); - gSP2Triangles(gfx++, 1, 9, 2, 0, 2, 9, 6, 0); - break; - } - } else { - switch (this->fadeDirection) { - case 1: - break; - case 2: - gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0); - break; - } - } - gDPPipeSync(gfx++); - *gfxP = gfx; -} - -s32 TransitionTriforce_IsDone(void* thisx) { - TransitionTriforce* this = (TransitionTriforce*)thisx; - - s32 ret = 0; - - if (this->state == 1 || this->state == 2) { - return this->transPos <= 0.03f; - - } else if (this->state == 3 || this->state == 4) { - return this->transPos >= 1.0f; - } - return ret; -} diff --git a/src/code/z_fbdemo_triforce.cpp b/src/code/z_fbdemo_triforce.cpp new file mode 100644 index 000000000..23d99b6b3 --- /dev/null +++ b/src/code/z_fbdemo_triforce.cpp @@ -0,0 +1,137 @@ +#define INTERNAL_SRC_CODE_Z_FBDEMO_TRIFORCE_C +#include "global.h" +#include "z64transition.h" +#include "code/fbdemo_triforce/z_fbdemo_triforce.cpp" +#include "def/ortho.h" +#include "def/rotate.h" +#include "def/scale.h" +#include "def/translate.h" +#include "def/z_fbdemo_triforce.h" + +void TransitionTriforce_Start(void* pthisx) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + + switch (pthis->state) { + case 1: + case 2: + pthis->transPos = 1.0f; + return; + } + pthis->transPos = 0.03f; +} + +void* TransitionTriforce_Init(void* pthisx) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + + bzero(pthis, sizeof(*pthis)); + guOrtho(&pthis->projection, -160.0f, 160.0f, -120.0f, 120.0f, -1000.0f, 1000.0f, 1.0f); + pthis->transPos = 1.0f; + pthis->state = 2; + pthis->step = 0.015f; + pthis->fadeDirection = 1; + return pthis; +} + +void TransitionTriforce_Destroy(void* pthisx) { +} + +void TransitionTriforce_Update(void* pthisx, s32 updateRate) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + f32 temp_f0; + s32 i; + + for (i = updateRate; i > 0; i--) { + if (pthis->state == 1) { + pthis->transPos = CLAMP_MIN(pthis->transPos * (1.0f - pthis->step), 0.03f); + } else if (pthis->state == 2) { + pthis->transPos = CLAMP_MIN(pthis->transPos - pthis->step, 0.03f); + } else if (pthis->state == 3) { + pthis->transPos = CLAMP_MAX(pthis->transPos / (1.0f - pthis->step), 1.0f); + } else if (pthis->state == 4) { + pthis->transPos = CLAMP_MAX(pthis->transPos + pthis->step, 1.0f); + } + } +} + +void TransitionTriforce_SetColor(void* pthisx, u32 color) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + + pthis->color.rgba = color; +} + +void TransitionTriforce_SetType(void* pthisx, s32 type) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + + pthis->fadeDirection = type; +} + +// unused +void TransitionTriforce_SetState(void* pthisx, s32 state) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + + pthis->state = state; +} + +void TransitionTriforce_Draw(void* pthisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + Mtx* modelView; + f32 scale; + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + s32 pad; + f32 rotation = pthis->transPos * 360.0f; + + modelView = pthis->modelView[pthis->frame]; + scale = pthis->transPos * 0.625f; + pthis->frame ^= 1; + osSyncPrintf("rate=%f tx=%f ty=%f rotate=%f\n", pthis->transPos, 0.0f, 0.0f, rotation); + guScale(&modelView[0], scale, scale, 1.0f); + guRotate(&modelView[1], rotation, 0.0f, 0.0f, 1.0f); + guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); + gDPPipeSync(gfx++); + gSPDisplayList(gfx++, sTriforceWipeDL); + gDPSetColor(gfx++, G_SETPRIMCOLOR, pthis->color.rgba); + gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gSPMatrix(gfx++, &pthis->projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, &modelView[0], G_MTX_LOAD); + gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MODELVIEW | G_MTX_MUL); + gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MODELVIEW | G_MTX_MUL); + gSPVertex(gfx++, sTriforceWipeVtx, 10, 0); + if (!TransitionTriforce_IsDone(pthis)) { + switch (pthis->fadeDirection) { + case 1: + gSP2Triangles(gfx++, 0, 4, 5, 0, 4, 1, 3, 0); + gSP1Triangle(gfx++, 5, 3, 2, 0); + break; + case 2: + gSP2Triangles(gfx++, 3, 4, 5, 0, 0, 2, 6, 0); + gSP2Triangles(gfx++, 0, 6, 7, 0, 1, 0, 7, 0); + gSP2Triangles(gfx++, 1, 7, 8, 0, 1, 8, 9, 0); + gSP2Triangles(gfx++, 1, 9, 2, 0, 2, 9, 6, 0); + break; + } + } else { + switch (pthis->fadeDirection) { + case 1: + break; + case 2: + gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0); + break; + } + } + gDPPipeSync(gfx++); + *gfxP = gfx; +} + +s32 TransitionTriforce_IsDone(void* pthisx) { + TransitionTriforce* pthis = (TransitionTriforce*)pthisx; + + s32 ret = 0; + + if (pthis->state == 1 || pthis->state == 2) { + return pthis->transPos <= 0.03f; + + } else if (pthis->state == 3 || pthis->state == 4) { + return pthis->transPos >= 1.0f; + } + return ret; +} diff --git a/src/code/z_fbdemo_wipe1.c b/src/code/z_fbdemo_wipe1.cpp similarity index 55% rename from src/code/z_fbdemo_wipe1.c rename to src/code/z_fbdemo_wipe1.cpp index ee825415d..48f44b876 100644 --- a/src/code/z_fbdemo_wipe1.c +++ b/src/code/z_fbdemo_wipe1.cpp @@ -2,7 +2,7 @@ #include "global.h" #include "z64transition.h" #include "z64save.h" -#include "code/fbdemo_wipe1/z_fbdemo_wipe1.c" +#include "code/fbdemo_wipe1/z_fbdemo_wipe1.cpp" #include "def/lookat.h" #include "def/perspective.h" #include "def/rotate.h" @@ -46,72 +46,72 @@ Gfx sWipeSyncDList[] = { gsSPEndDisplayList(), }; -void TransitionWipe_Start(void* thisx) { - TransitionWipe* this = (TransitionWipe*)thisx; +void TransitionWipe_Start(void* pthisx) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; - this->isDone = 0; + pthis->isDone = 0; - if (this->direction) { - this->texY = 0x14D; + if (pthis->direction) { + pthis->texY = 0x14D; } else { - this->texY = 0x264; + pthis->texY = 0x264; } - guPerspective(&this->projection, &this->normal, 60.0f, (4.0 / 3.0f), 10.0f, 12800.0f, 1.0f); - guLookAt(&this->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); + guPerspective(&pthis->projection, &pthis->normal, 60.0f, (4.0 / 3.0f), 10.0f, 12800.0f, 1.0f); + guLookAt(&pthis->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); } -void* TransitionWipe_Init(void* thisx) { - TransitionWipe* this = (TransitionWipe*)thisx; +void* TransitionWipe_Init(void* pthisx) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; - bzero(this, sizeof(*this)); - return this; + bzero(pthis, sizeof(*pthis)); + return pthis; } -void TransitionWipe_Destroy(void* thisx) { +void TransitionWipe_Destroy(void* pthisx) { } -void TransitionWipe_Update(void* thisx, s32 updateRate) { - TransitionWipe* this = (TransitionWipe*)thisx; +void TransitionWipe_Update(void* pthisx, s32 updateRate) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; u8 unk1419; - if (this->direction != 0) { + if (pthis->direction != 0) { unk1419 = gSaveContext.unk_1419; - this->texY += (unk1419 * 3) / updateRate; - if (this->texY >= 0x264) { - this->texY = 0x264; - this->isDone = 1; + pthis->texY += (unk1419 * 3) / updateRate; + if (pthis->texY >= 0x264) { + pthis->texY = 0x264; + pthis->isDone = 1; } } else { unk1419 = gSaveContext.unk_1419; - this->texY -= (unk1419 * 3) / updateRate; - if (this->texY < 0x14E) { - this->texY = 0x14D; - this->isDone = 1; + pthis->texY -= (unk1419 * 3) / updateRate; + if (pthis->texY < 0x14E) { + pthis->texY = 0x14D; + pthis->isDone = 1; } } } -void TransitionWipe_Draw(void* thisx, Gfx** gfxP) { +void TransitionWipe_Draw(void* pthisx, Gfx** gfxP) { Gfx* gfx = *gfxP; Mtx* modelView; - TransitionWipe* this = (TransitionWipe*)thisx; + TransitionWipe* pthis = (TransitionWipe*)pthisx; s32 pad[4]; Gfx* tex; - modelView = this->modelView[this->frame]; + modelView = pthis->modelView[pthis->frame]; - this->frame ^= 1; + pthis->frame ^= 1; guScale(&modelView[0], 0.56f, 0.56f, 1.0f); guRotate(&modelView[1], 0.0f, 0.0f, 0.0f, 1.0f); guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); gDPPipeSync(gfx++); - tex = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0, 0); + tex = Gfx_BranchTexScroll(&gfx, pthis->texX, pthis->texY, 0, 0); gSPSegment(gfx++, 8, tex); - gDPSetPrimColor(gfx++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); - gSPMatrix(gfx++, &this->projection, G_MTX_LOAD | G_MTX_PROJECTION); - gSPPerspNormalize(gfx++, this->normal); - gSPMatrix(gfx++, &this->lookAt, G_MTX_MUL | G_MTX_PROJECTION); + gDPSetPrimColor(gfx++, 0, 0x80, pthis->color.r, pthis->color.g, pthis->color.b, 255); + gSPMatrix(gfx++, &pthis->projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPPerspNormalize(gfx++, pthis->normal); + gSPMatrix(gfx++, &pthis->lookAt, G_MTX_MUL | G_MTX_PROJECTION); gSPMatrix(gfx++, &modelView[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); @@ -120,36 +120,36 @@ void TransitionWipe_Draw(void* thisx, Gfx** gfxP) { *gfxP = gfx; } -s32 TransitionWipe_IsDone(void* thisx) { - TransitionWipe* this = (TransitionWipe*)thisx; +s32 TransitionWipe_IsDone(void* pthisx) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; - return this->isDone; + return pthis->isDone; } -void TransitionWipe_SetType(void* thisx, s32 type) { - TransitionWipe* this = (TransitionWipe*)thisx; +void TransitionWipe_SetType(void* pthisx, s32 type) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; if (type == 1) { - this->direction = 1; + pthis->direction = 1; } else { - this->direction = 0; + pthis->direction = 0; } - if (this->direction != 0) { - this->texY = 0x14D; + if (pthis->direction != 0) { + pthis->texY = 0x14D; } else { - this->texY = 0x264; + pthis->texY = 0x264; } } -void TransitionWipe_SetColor(void* thisx, u32 color) { - TransitionWipe* this = (TransitionWipe*)thisx; +void TransitionWipe_SetColor(void* pthisx, u32 color) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; - this->color.rgba = color; + pthis->color.rgba = color; } -void TransitionWipe_SetEnvColor(void* thisx, u32 color) { - TransitionWipe* this = (TransitionWipe*)thisx; +void TransitionWipe_SetEnvColor(void* pthisx, u32 color) { + TransitionWipe* pthis = (TransitionWipe*)pthisx; - this->envColor.rgba = color; + pthis->envColor.rgba = color; } diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.cpp similarity index 90% rename from src/code/z_fcurve_data_skelanime.c rename to src/code/z_fcurve_data_skelanime.cpp index fb4bb6b87..6288c7998 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.cpp @@ -22,12 +22,12 @@ void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = SEGMENTED_TO_VIRTUAL(limbListSeg); + SkelCurveLimbList* limbList = (SkelCurveLimbList*)SEGMENTED_TO_VIRTUAL(limbListSeg); skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = SEGMENTED_TO_VIRTUAL(limbList->limbs); + skelCurve->limbList = (SkelCurveLimb**)SEGMENTED_TO_VIRTUAL(limbList->limbs); - skelCurve->transforms = ZeldaArena_MallocDebug(sizeof(*skelCurve->transforms) * skelCurve->limbCount, + skelCurve->transforms = (LimbTransform*)ZeldaArena_MallocDebug(sizeof(*skelCurve->transforms) * skelCurve->limbCount, "../z_fcurve_data_skelanime.c", 125); ASSERT(skelCurve->transforms != NULL, "this->now_joint != NULL", "../z_fcurve_data_skelanime.c", 127); skelCurve->animCurFrame = 0.0f; @@ -61,10 +61,10 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { f32 transformValue; s32 j; - transformIndex = SEGMENTED_TO_VIRTUAL(skelCurve->transUpdIdx); - transformRefIdx = SEGMENTED_TO_VIRTUAL(transformIndex->refIndex); - transData = SEGMENTED_TO_VIRTUAL(transformIndex->transformData); - transformCopyValues = SEGMENTED_TO_VIRTUAL(transformIndex->copyValues); + transformIndex = (TransformUpdateIndex*)SEGMENTED_TO_VIRTUAL(skelCurve->transUpdIdx); + transformRefIdx = (u8*)SEGMENTED_TO_VIRTUAL(transformIndex->refIndex); + transData = (TransformData*)SEGMENTED_TO_VIRTUAL(transformIndex->transformData); + transformCopyValues = (u16*)SEGMENTED_TO_VIRTUAL(transformIndex->copyValues); transforms = (s16*)skelCurve->transforms; skelCurve->animCurFrame += skelCurve->animSpeed * R_UPDATE_RATE * 0.5f; @@ -102,7 +102,7 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { - SkelCurveLimb* limb = SEGMENTED_TO_VIRTUAL(skelCurve->limbList[limbIndex]); + SkelCurveLimb* limb = (SkelCurveLimb*)SEGMENTED_TO_VIRTUAL(skelCurve->limbList[limbIndex]); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279); diff --git a/src/code/z_frame_advance.c b/src/code/z_frame_advance.cpp similarity index 100% rename from src/code/z_frame_advance.c rename to src/code/z_frame_advance.cpp diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.cpp similarity index 100% rename from src/code/z_game_dlftbls.c rename to src/code/z_game_dlftbls.cpp diff --git a/src/code/z_game_over.c b/src/code/z_game_over.cpp similarity index 100% rename from src/code/z_game_over.c rename to src/code/z_game_over.cpp diff --git a/src/code/z_horse.c b/src/code/z_horse.cpp similarity index 100% rename from src/code/z_horse.c rename to src/code/z_horse.cpp diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.cpp similarity index 96% rename from src/code/z_jpeg.c rename to src/code/z_jpeg.cpp index ae3b9d771..c27ce83d3 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.cpp @@ -51,12 +51,12 @@ void Jpeg_ScheduleDecoderTask(JpegContext* ctx) { JpegWork* workBuf = ctx->workBuf; s32 pad[2]; - workBuf->taskData.address = PHYSICAL_TO_VIRTUAL(&workBuf->data); + workBuf->taskData.address = (uintptr_t)PHYSICAL_TO_VIRTUAL(&workBuf->data); workBuf->taskData.mode = ctx->mode; workBuf->taskData.mbCount = 4; - workBuf->taskData.qTableYPtr = PHYSICAL_TO_VIRTUAL(&workBuf->qTableY); - workBuf->taskData.qTableUPtr = PHYSICAL_TO_VIRTUAL(&workBuf->qTableU); - workBuf->taskData.qTableVPtr = PHYSICAL_TO_VIRTUAL(&workBuf->qTableV); + workBuf->taskData.qTableYPtr = (uintptr_t)PHYSICAL_TO_VIRTUAL(&workBuf->qTableY); + workBuf->taskData.qTableUPtr = (uintptr_t)PHYSICAL_TO_VIRTUAL(&workBuf->qTableU); + workBuf->taskData.qTableVPtr = (uintptr_t)PHYSICAL_TO_VIRTUAL(&workBuf->qTableV); sJpegTask.flags = 0; sJpegTask.ucode_boot = SysUcode_GetUCodeBoot(); @@ -254,7 +254,7 @@ s32 Jpeg_Decode2(void* data, void* zbuffer, void* work, u32 workSize) { OSTime time; OSTime curTime; - workBuff = work; + workBuff = (JpegWork*)work; time = osGetTime(); // (?) I guess MB_SIZE=0x180, PROC_OF_MBS=5 which means data is not a part of JpegWork @@ -269,7 +269,7 @@ s32 Jpeg_Decode2(void* data, void* zbuffer, void* work, u32 workSize) { time = curTime; ctx.workBuf = workBuff; - Jpeg_ParseMarkers(data, &ctx); + Jpeg_ParseMarkers((u8*)data, &ctx); curTime = osGetTime(); diff = curTime - time; @@ -344,7 +344,7 @@ s32 Jpeg_Decode2(void* data, void* zbuffer, void* work, u32 workSize) { Jpeg_ScheduleDecoderTask(&ctx); for (j = 0; j < ARRAY_COUNT(workBuff->data); j++) { - Jpeg_CopyToZbuffer(workBuff->data[j], zbuffer, x, y); + Jpeg_CopyToZbuffer(workBuff->data[j], (u16*)zbuffer, x, y); x++; if (x >= 20) { diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.cpp similarity index 71% rename from src/code/z_kaleido_manager.c rename to src/code/z_kaleido_manager.cpp index 80fdbc470..36122568d 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.cpp @@ -26,7 +26,7 @@ KaleidoMgrOverlay* gKaleidoMgrCurOvl = NULL; u8 gBossMarkState = 0; void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) { - ovl->loadedRamAddr = ovl->vromStart; + ovl->loadedRamAddr = (void*)ovl->vromStart; Overlay_Load(ovl->vromStart, ovl->vromEnd, ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr); ovl->offset = 0; // POINTER_SUB(ovl->loadedRamAddr, ovl->vramStart); @@ -76,32 +76,6 @@ void KaleidoManager_Destroy() { sKaleidoAreaPtr = NULL; } -// NOTE: this function looks messed up and probably doesn't work how it was intended to void* KaleidoManager_GetRamAddr(void* vram) { - return vram; // TODO FIX - KaleidoMgrOverlay* iter = gKaleidoMgrCurOvl; - KaleidoMgrOverlay* ovl = iter; - u32 i; - - if (ovl == NULL) { - iter = &gKaleidoMgrOverlayTable[0]; - for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { - if (((uintptr_t)vram >= (uintptr_t)iter->vramStart) && ((uintptr_t)iter->vramEnd >= (uintptr_t)vram)) { - KaleidoManager_LoadOvl(iter); - ovl = iter; - goto KaleidoManager_GetRamAddr_end; - } - //! @bug Probably missing iter++ here - } - - osSyncPrintf("Abnormal\n"); // "Abnormal" - return NULL; - } - -KaleidoManager_GetRamAddr_end: - if ((ovl == NULL) || ((uintptr_t)vram < (uintptr_t)ovl->vramStart) || ((uintptr_t)vram >= (uintptr_t)ovl->vramEnd)) { - return NULL; - } - - return (void*)((uintptr_t)vram + ovl->offset); + return vram; } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.cpp similarity index 95% rename from src/code/z_kaleido_scope_call.c rename to src/code/z_kaleido_scope_call.cpp index bd8e115fa..f2a8f3cf1 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.cpp @@ -44,8 +44,8 @@ void KaleidoScopeCall_Init(GlobalContext* globalCtx) { // "Kaleidoscope replacement construction" osSyncPrintf("Kaleidoscope replacement construction \n"); - sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(KaleidoScope_Update); - sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(KaleidoScope_Draw); + sKaleidoScopeUpdateFunc = (void (*)(GlobalContext *))KaleidoManager_GetRamAddr(KaleidoScope_Update); + sKaleidoScopeDrawFunc = (void (*)(GlobalContext*))KaleidoManager_GetRamAddr(KaleidoScope_Draw); KaleidoSetup_Init(globalCtx); } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.cpp similarity index 100% rename from src/code/z_kaleido_setup.c rename to src/code/z_kaleido_setup.cpp diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.cpp similarity index 95% rename from src/code/z_kanfont.c rename to src/code/z_kanfont.cpp index 92aa62e9c..91640f96e 100644 --- a/src/code/z_kanfont.c +++ b/src/code/z_kanfont.cpp @@ -42,7 +42,7 @@ void Font_LoadOrderedFont(Font* font) { font->msgOffset = 0; - DmaMgr_SendRequest1(font->msgBuf, _message_0xFFFC_nes, sizeof(_message_0xFFFC_nes), "../z_kanfont.c", + DmaMgr_SendRequest1(font->msgBuf, (char*)_message_0xFFFC_nes, sizeof(_message_0xFFFC_nes), "../z_kanfont.c", 122); for (fontBufIndex = 0, codePointIndex = 0; font->msgBuf[codePointIndex] != MESSAGE_END; codePointIndex++) { diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.cpp similarity index 99% rename from src/code/z_kankyo.c rename to src/code/z_kankyo.cpp index 580356f11..4cf229ffb 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.cpp @@ -722,7 +722,7 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) { envCtx->skyboxDmaState = SKYBOX_DMA_FILE1_START; - size = POINTER_SUB(gSkyboxFiles[newSkybox1Index].file.vromEnd, gSkyboxFiles[newSkybox1Index].file.vromStart); + size = POINTER_SUB2(gSkyboxFiles[newSkybox1Index].file.vromEnd, gSkyboxFiles[newSkybox1Index].file.vromStart); osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->staticSegments[0], @@ -734,7 +734,7 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon if ((envCtx->skybox2Index != newSkybox2Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) { envCtx->skyboxDmaState = SKYBOX_DMA_FILE2_START; - size = POINTER_SUB(gSkyboxFiles[newSkybox2Index].file.vromEnd, gSkyboxFiles[newSkybox2Index].file.vromStart); + size = POINTER_SUB2(gSkyboxFiles[newSkybox2Index].file.vromEnd, gSkyboxFiles[newSkybox2Index].file.vromStart); osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->staticSegments[1], @@ -748,14 +748,14 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon envCtx->skyboxDmaState = SKYBOX_DMA_PAL1_START; if ((newSkybox1Index & 1) ^ ((newSkybox1Index & 4) >> 2)) { - size = POINTER_SUB(gSkyboxFiles[newSkybox1Index].palette.vromEnd, gSkyboxFiles[newSkybox1Index].palette.vromStart); + size = POINTER_SUB2(gSkyboxFiles[newSkybox1Index].palette.vromEnd, gSkyboxFiles[newSkybox1Index].palette.vromStart); osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->palettes, gSkyboxFiles[newSkybox1Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1307); } else { - size = POINTER_SUB(gSkyboxFiles[newSkybox1Index].palette.vromEnd, gSkyboxFiles[newSkybox1Index].palette.vromStart); + size = POINTER_SUB2(gSkyboxFiles[newSkybox1Index].palette.vromEnd, gSkyboxFiles[newSkybox1Index].palette.vromStart); osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); DmaMgr_SendRequest2(&envCtx->dmaRequest, POINTER_ADD(skyboxCtx->palettes, size), gSkyboxFiles[newSkybox1Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, @@ -767,14 +767,14 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon envCtx->skyboxDmaState = SKYBOX_DMA_PAL2_START; if ((newSkybox2Index & 1) ^ ((newSkybox2Index & 4) >> 2)) { - size = POINTER_SUB(gSkyboxFiles[newSkybox2Index].palette.vromEnd, gSkyboxFiles[newSkybox2Index].palette.vromStart); + size = POINTER_SUB2(gSkyboxFiles[newSkybox2Index].palette.vromEnd, gSkyboxFiles[newSkybox2Index].palette.vromStart); osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->palettes, gSkyboxFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1342); } else { - size = POINTER_SUB(gSkyboxFiles[newSkybox2Index].palette.vromEnd, gSkyboxFiles[newSkybox2Index].palette.vromStart); + size = POINTER_SUB2(gSkyboxFiles[newSkybox2Index].palette.vromEnd, gSkyboxFiles[newSkybox2Index].palette.vromStart); osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); DmaMgr_SendRequest2(&envCtx->dmaRequest, POINTER_ADD(skyboxCtx->palettes, size), gSkyboxFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, @@ -900,7 +900,7 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li s32 adjustment; if ((((void)0, gSaveContext.gameMode) != 0) && (((void)0, gSaveContext.gameMode) != 3)) { - func_800AA16C(globalCtx); + func_800AA16C(); } if (pauseCtx->state == 0) { diff --git a/src/code/z_lib.c b/src/code/z_lib.cpp similarity index 100% rename from src/code/z_lib.c rename to src/code/z_lib.cpp diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.cpp similarity index 99% rename from src/code/z_lifemeter.c rename to src/code/z_lifemeter.cpp index b989bd23b..61da77da7 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.cpp @@ -394,7 +394,7 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { } if (curBgImgLoaded != heartBgImg) { - curBgImgLoaded = heartBgImg; + curBgImgLoaded = (u8*)heartBgImg; gDPLoadTextureBlock(OVERLAY_DISP++, heartBgImg, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -447,7 +447,7 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { { //Calculate the matrix for the beating heart //The code below is an optimized way of calling Matrix_Translate() and Matrix_Scale() - Mtx* matrix = Graph_Alloc(gfxCtx, sizeof(Mtx)); + Mtx* matrix = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); Matrix_ScaleTrans(matrix, 1.0f - (0.32f * beatingHeartPulsingSize), 1.0f - (0.32f * beatingHeartPulsingSize), 1.0f - (0.32f * beatingHeartPulsingSize), -130.0f + offsetX, 94.5f - offsetY, 0.0f); gSPMatrix(OVERLAY_DISP++, matrix, G_MTX_MODELVIEW | G_MTX_LOAD); diff --git a/src/code/z_lights.c b/src/code/z_lights.cpp similarity index 99% rename from src/code/z_lights.c rename to src/code/z_lights.cpp index dd9409a10..07c7aab5c 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.cpp @@ -295,7 +295,7 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 Lights* lights; s32 i; - lights = Graph_Alloc(gfxCtx, sizeof(Lights)); + lights = (Lights*)Graph_Alloc(gfxCtx, sizeof(Lights)); lights->l.a.l.col[0] = lights->l.a.l.colc[0] = ambientR; lights->l.a.l.col[1] = lights->l.a.l.colc[1] = ambientG; @@ -317,9 +317,7 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 } Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB) { - Lights* lights; - - lights = Graph_Alloc(gfxCtx, sizeof(Lights)); + auto lights = (Lights*)Graph_Alloc(gfxCtx, sizeof(Lights)); lights->l.a.l.col[0] = lights->l.a.l.colc[0] = ambientR; lights->l.a.l.col[1] = lights->l.a.l.colc[1] = ambientG; diff --git a/src/code/z_malloc.c b/src/code/z_malloc.cpp similarity index 100% rename from src/code/z_malloc.c rename to src/code/z_malloc.cpp diff --git a/src/code/z_map_data.c b/src/code/z_map_data.cpp similarity index 100% rename from src/code/z_map_data.c rename to src/code/z_map_data.cpp diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.cpp similarity index 98% rename from src/code/z_map_exp.c rename to src/code/z_map_exp.cpp index ec4dbf786..1ed74c945 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.cpp @@ -156,7 +156,7 @@ void Map_InitData(GlobalContext* globalCtx, s16 room) { osSyncPrintf(VT_RST); sEntranceIconMapIndex = extendedMapIndex; - interfaceCtx->mapSegment1 = POINTER_ADD(_map_grand_staticSegmentRomStart, gMapData->owMinimapTexOffset[extendedMapIndex]); + interfaceCtx->mapSegment1 = (u8*)POINTER_ADD(_map_grand_staticSegmentRomStart, gMapData->owMinimapTexOffset[extendedMapIndex]); //interfaceCtx->mapSegment = map_grand_static_lut[extendedMapIndex]; interfaceCtx->unk_258 = mapIndex; @@ -184,7 +184,7 @@ void Map_InitData(GlobalContext* globalCtx, s16 room) { osSyncPrintf("デクの樹ダンジョンMAP テクスチャDMA(%x) scene_id_offset=%d VREG(30)=%d\n", room, mapIndex, VREG(30)); osSyncPrintf(VT_RST); - globalCtx->interfaceCtx.mapSegment1 = map_i_static_lut[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]; + globalCtx->interfaceCtx.mapSegment1 = (u8*)map_i_static_lut[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]; R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room]; R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room]; Map_SetFloorPalettesData(globalCtx, VREG(30)); diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.cpp similarity index 98% rename from src/code/z_map_mark.c rename to src/code/z_map_mark.cpp index 8a7c44751..6cedc3edd 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.cpp @@ -78,8 +78,8 @@ void MapMark_Init(GlobalContext* globalCtx) { Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr); - sLoadedMarkDataTable = gMapMarkDataTable; - sLoadedMarkDataTable = overlay->vramTable; + sLoadedMarkDataTable = (MapMarkData**)gMapMarkDataTable; + sLoadedMarkDataTable = (MapMarkData**)overlay->vramTable; } void MapMark_ClearPointers(GlobalContext* globalCtx) { diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.cpp similarity index 99% rename from src/code/z_message_PAL.c rename to src/code/z_message_PAL.cpp index 2c7f050bc..cd651ee4d 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.cpp @@ -70,40 +70,38 @@ u16 sOcarinaSongBitFlags = 0; // ocarina bit flags #define MESSAGE_DATA_STATIC #include "message_data_fmt.h" + MessageTableEntry sNesMessageEntryTable[] = { -#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - { textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_nes, sizeof(nesMessage) }, +#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) {textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_nes, sizeof(nesMessage)}, #define DEFINE_MESSAGE_FFFC #include "text/message_data.h" #undef DEFINE_MESSAGE_FFFC #undef DEFINE_MESSAGE - { 0xFFFF, 0, NULL, 0 }, + {0xFFFF, 0, NULL, 0}, }; MessageTableEntry sGerMessageEntryTable[] = { -#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - { textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_ger, sizeof(gerMessage) }, +#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) {textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_ger, sizeof(gerMessage)}, #include "text/message_data.h" #undef DEFINE_MESSAGE - { 0xFFFF, 0, NULL, 0 }, + {0xFFFF, 0, NULL, 0}, }; MessageTableEntry sFraMessageEntryTable[] = { -#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \ - { textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_fra, sizeof(fraMessage) }, +#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) {textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_fra, sizeof(fraMessage)}, #include "text/message_data.h" #undef DEFINE_MESSAGE - { 0xFFFF, 0, NULL, 0 }, + {0xFFFF, 0, NULL, 0}, }; MessageTableEntry sStaffMessageEntryTable[] = { -#define DEFINE_MESSAGE(textId, type, yPos, staffMessage) \ - { textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_staff, sizeof(staffMessage) }, +#define DEFINE_MESSAGE(textId, type, yPos, staffMessage) {textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_staff, sizeof(staffMessage)}, #include "text/message_data_staff.h" #undef DEFINE_MESSAGE - { 0xFFFF, 0, NULL, 0 }, + {0xFFFF, 0, NULL, 0}, }; + #undef HS_HORSE_ARCHERY #undef HS_POE_POINTS #undef HS_LARGEST_FISH diff --git a/src/code/z_moji.c b/src/code/z_moji.cpp similarity index 100% rename from src/code/z_moji.c rename to src/code/z_moji.cpp diff --git a/src/code/z_msgevent.c b/src/code/z_msgevent.cpp similarity index 100% rename from src/code/z_msgevent.c rename to src/code/z_msgevent.cpp diff --git a/src/code/z_olib.c b/src/code/z_olib.cpp similarity index 100% rename from src/code/z_olib.c rename to src/code/z_olib.cpp diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.cpp similarity index 99% rename from src/code/z_onepointdemo.c rename to src/code/z_onepointdemo.cpp index 1f8856e4b..b7f7658f7 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.cpp @@ -13,7 +13,7 @@ static s16 sDisableAttention = false; static s16 sUnused = -1; static s32 sPrevFrameCs1100 = -4096; -#include "z_onepointdemo_data.c" +#include "z_onepointdemo_data.cpp" #include "def/code_800FCE80.h" #include "def/code_800FD970.h" #include "def/z_actor.h" diff --git a/src/code/z_onepointdemo_data.c b/src/code/z_onepointdemo_data.cpp similarity index 100% rename from src/code/z_onepointdemo_data.c rename to src/code/z_onepointdemo_data.cpp diff --git a/src/code/z_parameter.c b/src/code/z_parameter.cpp similarity index 99% rename from src/code/z_parameter.c rename to src/code/z_parameter.cpp index 745f63fd7..491008cae 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.cpp @@ -1296,16 +1296,16 @@ void Interface_LoadItemIcon1(GlobalContext* globalCtx, u16 button) { switch(button) { case 0: - interfaceCtx->iconItemSegment1 = icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; + interfaceCtx->iconItemSegment1 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; break; case 1: - interfaceCtx->iconItemSegment2 = icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; + interfaceCtx->iconItemSegment2 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; break; case 2: - interfaceCtx->iconItemSegment3 = icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; + interfaceCtx->iconItemSegment3 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; break; case 3: - interfaceCtx->iconItemSegment4 = icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; + interfaceCtx->iconItemSegment4 = (u8*)icon_item_static_lut[gSaveContext.equips.buttonItems[button]]; break; default: return; @@ -2097,17 +2097,17 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 l switch(loadOffset) // TODO CHECK { case 0: - interfaceCtx->doActionSegment1 = do_action_static_lut[action]; + interfaceCtx->doActionSegment1 = (u8*)do_action_static_lut[action]; break; case 1: - interfaceCtx->doActionSegment2 = do_action_static_lut[action]; + interfaceCtx->doActionSegment2 = (u8*)do_action_static_lut[action]; break; default: break; } } else { - gSegments[7] = VIRTUAL_TO_PHYSICAL(interfaceCtx->doActionSegment1); - func_80086D5C(SEGMENTED_TO_VIRTUAL(sDoActionTextures[loadOffset]), DO_ACTION_TEX_SIZE / 4); + gSegments[7] = (uintptr_t)VIRTUAL_TO_PHYSICAL(interfaceCtx->doActionSegment1); + func_80086D5C((s32*)SEGMENTED_TO_VIRTUAL(sDoActionTextures[loadOffset]), DO_ACTION_TEX_SIZE / 4); } } @@ -2161,7 +2161,7 @@ void Interface_LoadActionLabelB(GlobalContext* globalCtx, u16 action) { interfaceCtx->unk_1FC = action; - interfaceCtx->doActionSegment2 = do_action_static_lut[action]; + interfaceCtx->doActionSegment2 = (u8*)do_action_static_lut[action]; interfaceCtx->unk_1FA = 1; } @@ -2927,7 +2927,7 @@ void Interface_InitVertices(GlobalContext* globalCtx) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; s16 i; - interfaceCtx->actionVtx = Graph_Alloc(globalCtx->state.gfxCtx, 8 * sizeof(Vtx)); + interfaceCtx->actionVtx = (Vtx*)Graph_Alloc(globalCtx->state.gfxCtx, 8 * sizeof(Vtx)); // clang-format off interfaceCtx->actionVtx[0].v.ob[0] = @@ -2976,7 +2976,7 @@ void Interface_InitVertices(GlobalContext* globalCtx) { interfaceCtx->actionVtx[5].v.tc[0] = interfaceCtx->actionVtx[7].v.tc[0] = 1536; interfaceCtx->actionVtx[6].v.tc[1] = interfaceCtx->actionVtx[7].v.tc[1] = 512; - interfaceCtx->beatingHeartVtx = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Vtx)); + interfaceCtx->beatingHeartVtx = (Vtx*)Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Vtx)); interfaceCtx->beatingHeartVtx[0].v.ob[0] = interfaceCtx->beatingHeartVtx[2].v.ob[0] = -8; interfaceCtx->beatingHeartVtx[1].v.ob[0] = interfaceCtx->beatingHeartVtx[3].v.ob[0] = 8; diff --git a/src/code/z_path.c b/src/code/z_path.cpp similarity index 94% rename from src/code/z_path.c rename to src/code/z_path.cpp index 19352336c..66ff1454c 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.cpp @@ -26,7 +26,7 @@ f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { return -1.0; } - pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points); pointPos = &pointPos[waypoint]; dx = pointPos->x - actor->world.pos.x; diff --git a/src/code/z_play.c b/src/code/z_play.cpp similarity index 97% rename from src/code/z_play.c rename to src/code/z_play.cpp index 8838bf3c0..144c60084 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.cpp @@ -17,6 +17,7 @@ #include "z_opening.h" #include "z_scene_table.h" #include "z_file_choose.h" +#include "gfxapi.h" #include #include "def/PreRender.h" #include "def/TwoHeadArena.h" @@ -75,7 +76,7 @@ #include "def/z_vr_box_draw.h" #include "def/zbuffer.h" -void gfx_force_43(bool enable);//From GlideN64 + void Gameplay_Main(GameState* thisx); void Gameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s32 spawn); @@ -517,7 +518,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { osSyncPrintf("object_exchange_rom_address %u\n", gObjectTableSize); osSyncPrintf("RomStart RomEnd Size\n"); for (i = 0; i < gObjectTableSize; i++) { - s32 size = POINTER_SUB(gObjectTable[i].vromEnd, gObjectTable[i].vromStart); + s32 size = POINTER_SUB2(gObjectTable[i].vromEnd, gObjectTable[i].vromStart); osSyncPrintf("%08x-%08x %08x(%8.3fKB)\n", gObjectTable[i].vromStart, gObjectTable[i].vromEnd, size, size / 1024.0f); @@ -530,9 +531,9 @@ void Gameplay_Update(GlobalContext* globalCtx) { ActorOverlayTable_LogPrint(); } - gSegments[4] = VIRTUAL_TO_PHYSICAL(gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart); - gSegments[5] = VIRTUAL_TO_PHYSICAL(gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart); - gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); + gSegments[4] = gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart.get(); + gSegments[5] = gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart.get(); + gSegments[2] = (uintptr_t)globalCtx->sceneSegment; if (FrameAdvance_Update(&globalCtx->frameAdvCtx, &input[1])) { if ((globalCtx->transitionMode == 0) && (globalCtx->sceneLoadFlag != 0)) { @@ -1152,21 +1153,21 @@ void Gameplay_Draw(GlobalContext* globalCtx) { OPEN_DISPS(gfxCtx, "../z_play.c", 3907); - gSegments[4] = VIRTUAL_TO_PHYSICAL(gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart); - gSegments[5] = VIRTUAL_TO_PHYSICAL(gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart); - gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); + gSegments[4] = gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart.get(); + gSegments[5] = gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart.get(); + gSegments[2] = (uintptr_t)VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gSPSegment(POLY_XLU_DISP++, 0x00, NULL); gSPSegment(OVERLAY_DISP++, 0x00, NULL); - gSPSegment(POLY_OPA_DISP++, 0x04, gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart); - gSPSegment(POLY_XLU_DISP++, 0x04, gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart); - gSPSegment(OVERLAY_DISP++, 0x04, gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x04, gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart.get()); + gSPSegment(POLY_XLU_DISP++, 0x04, gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart.get()); + gSPSegment(OVERLAY_DISP++, 0x04, gObjectTable[globalCtx->objectCtx.mainKeepIndex].vromStart.get()); - gSPSegment(POLY_OPA_DISP++, 0x05, gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart); - gSPSegment(POLY_XLU_DISP++, 0x05, gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart); - gSPSegment(OVERLAY_DISP++, 0x05, gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x05, gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart.get()); + gSPSegment(POLY_XLU_DISP++, 0x05, gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart.get()); + gSPSegment(OVERLAY_DISP++, 0x05, gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart.get()); gSPSegment(POLY_OPA_DISP++, 0x02, globalCtx->sceneSegment); gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); @@ -1193,8 +1194,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) { 0.0f; // This transpose is where the viewing matrix is properly converted into a billboard matrix Matrix_Transpose(&globalCtx->billboardMtxF); - globalCtx->billboardMtx = Matrix_MtxFToMtx(Matrix_CheckFloats(&globalCtx->billboardMtxF, "../z_play.c", 4005), - Graph_Alloc(gfxCtx, sizeof(Mtx))); + globalCtx->billboardMtx = Matrix_MtxFToMtx(&globalCtx->billboardMtxF, (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx))); gSPSegment(POLY_OPA_DISP++, 0x01, globalCtx->billboardMtx); @@ -1519,18 +1519,7 @@ f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) { } void* Gameplay_LoadFile(GlobalContext* globalCtx, RomFile* file) { - return file->vromStart; - /* unused because we are always in memory */ -#if 0 - u32 size; - void* allocp; - - size = POINTER_SUB(file->vromEnd, file->vromStart); - allocp = GameState_Alloc(&globalCtx->state, size, "../z_play.c", 4692); - DmaMgr_SendRequest1(allocp, file->vromStart, size, "../z_play.c", 4694); - - return allocp; -#endif + return file->vromStart.buffer(); } void Gameplay_InitEnvironment(GlobalContext* globalCtx, s16 skyboxId) { @@ -1554,7 +1543,7 @@ void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn) { YREG(15) = 0; gSaveContext.worldMapArea = 0; - Scene_ExecuteCommands(globalCtx, globalCtx->sceneSegment); + Scene_ExecuteCommands(globalCtx, (SceneCmd*)globalCtx->sceneSegment); Gameplay_InitEnvironment(globalCtx, globalCtx->skyboxId); } @@ -1567,13 +1556,13 @@ void Gameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s32 spawn) { globalCtx->sceneNum = sceneNum; globalCtx->sceneConfig = scene->config; - osSyncPrintf("\nSCENE SIZE %fK\n", POINTER_SUB(scene->sceneFile.vromEnd, scene->sceneFile.vromStart) / 1024.0f); + osSyncPrintf("\nSCENE SIZE %fK\n", POINTER_SUB2(scene->sceneFile.vromEnd, scene->sceneFile.vromStart) / 1024.0f); - globalCtx->sceneSegment = Gameplay_LoadFile(globalCtx, &scene->cmds); + globalCtx->sceneSegment = (void*)scene->cmds; scene->unk_13 = 0; ASSERT(globalCtx->sceneSegment != NULL, "this->sceneSegment != NULL", "../z_play.c", 4960); - gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); + gSegments[2] = (uintptr_t)VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); Gameplay_InitScene(globalCtx, spawn); diff --git a/src/code/z_player_call.c b/src/code/z_player_call.cpp similarity index 88% rename from src/code/z_player_call.c rename to src/code/z_player_call.cpp index 378ed7935..ecb1a6566 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.cpp @@ -37,10 +37,10 @@ void Player_Draw(Actor* thisx, GlobalContext* globalCtx); }; void PlayerCall_InitFuncPtrs(void) { - sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init); - sPlayerCallDestroyFunc = KaleidoManager_GetRamAddr(Player_Destroy); - sPlayerCallUpdateFunc = KaleidoManager_GetRamAddr(Player_Update); - sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw); + sPlayerCallInitFunc = Player_Init; + sPlayerCallDestroyFunc = Player_Destroy; + sPlayerCallUpdateFunc = Player_Update; + sPlayerCallDrawFunc = Player_Draw; } void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.cpp similarity index 71% rename from src/code/z_player_lib.c rename to src/code/z_player_lib.cpp index 1a1892ed4..4c3855f05 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.cpp @@ -313,20 +313,20 @@ Vec3f sGetItemRefPos; s32 D_80160014; s32 D_80160018; -void Player_SetBootData(GlobalContext* globalCtx, Player* this) { +void Player_SetBootData(GlobalContext* globalCtx, Player* pthis) { s32 currentBoots; s16* bootRegs; REG(27) = 2000; REG(48) = 370; - currentBoots = this->currentBoots; + currentBoots = pthis->currentBoots; if (currentBoots == PLAYER_BOOTS_NORMAL) { if (!LINK_IS_ADULT) { currentBoots = PLAYER_BOOTS_NORMAL_CHILD; } } else if (currentBoots == PLAYER_BOOTS_IRON) { - if (this->stateFlags1 & 0x8000000) { + if (pthis->stateFlags1 & 0x8000000) { currentBoots = PLAYER_BOOTS_IRON_UNDERWATER; } REG(27) = 500; @@ -357,142 +357,142 @@ void Player_SetBootData(GlobalContext* globalCtx, Player* this) { } } -s32 Player_InBlockingCsMode(GlobalContext* globalCtx, Player* this) { - return (this->stateFlags1 & 0x20000080) || (this->csMode != 0) || (globalCtx->sceneLoadFlag == 0x14) || - (this->stateFlags1 & 1) || (this->stateFlags3 & 0x80) || - ((gSaveContext.unk_13F0 != 0) && (Player_ActionToMagicSpell(this, this->itemActionParam) >= 0)); +s32 Player_InBlockingCsMode(GlobalContext* globalCtx, Player* pthis) { + return (pthis->stateFlags1 & 0x20000080) || (pthis->csMode != 0) || (globalCtx->sceneLoadFlag == 0x14) || + (pthis->stateFlags1 & 1) || (pthis->stateFlags3 & 0x80) || + ((gSaveContext.unk_13F0 != 0) && (Player_ActionToMagicSpell(pthis, pthis->itemActionParam) >= 0)); } s32 Player_InCsMode(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - return Player_InBlockingCsMode(globalCtx, this) || (this->unk_6AD == 4); + return Player_InBlockingCsMode(globalCtx, pthis) || (pthis->unk_6AD == 4); } -s32 func_8008E9C4(Player* this) { - return (this->stateFlags1 & 0x10); +s32 func_8008E9C4(Player* pthis) { + return (pthis->stateFlags1 & 0x10); } -s32 Player_IsChildWithHylianShield(Player* this) { - return gSaveContext.linkAge != 0 && (this->currentShield == PLAYER_SHIELD_HYLIAN); +s32 Player_IsChildWithHylianShield(Player* pthis) { + return gSaveContext.linkAge != 0 && (pthis->currentShield == PLAYER_SHIELD_HYLIAN); } -s32 Player_ActionToModelGroup(Player* this, s32 actionParam) { +s32 Player_ActionToModelGroup(Player* pthis, s32 actionParam) { s32 modelGroup = sActionModelGroups[actionParam]; - if ((modelGroup == 2) && Player_IsChildWithHylianShield(this)) { + if ((modelGroup == 2) && Player_IsChildWithHylianShield(pthis)) { return 1; } else { return modelGroup; } } -void Player_SetModelsForHoldingShield(Player* this) { - if ((this->stateFlags1 & 0x400000) && - ((this->itemActionParam < 0) || (this->itemActionParam == this->heldItemActionParam))) { - if (!Player_HoldsTwoHandedWeapon(this) && !Player_IsChildWithHylianShield(this)) { - this->rightHandType = 10; - this->rightHandDLists = &sPlayerDListGroups[10][(void)0, gSaveContext.linkAge]; - if (this->sheathType == 18) { - this->sheathType = 16; - } else if (this->sheathType == 19) { - this->sheathType = 17; +void Player_SetModelsForHoldingShield(Player* pthis) { + if ((pthis->stateFlags1 & 0x400000) && + ((pthis->itemActionParam < 0) || (pthis->itemActionParam == pthis->heldItemActionParam))) { + if (!Player_HoldsTwoHandedWeapon(pthis) && !Player_IsChildWithHylianShield(pthis)) { + pthis->rightHandType = 10; + pthis->rightHandDLists = &sPlayerDListGroups[10][(void)0, gSaveContext.linkAge]; + if (pthis->sheathType == 18) { + pthis->sheathType = 16; + } else if (pthis->sheathType == 19) { + pthis->sheathType = 17; } - this->sheathDLists = &sPlayerDListGroups[this->sheathType][(void)0, gSaveContext.linkAge]; - this->modelAnimType = 2; - this->itemActionParam = -1; + pthis->sheathDLists = &sPlayerDListGroups[pthis->sheathType][(void)0, gSaveContext.linkAge]; + pthis->modelAnimType = 2; + pthis->itemActionParam = -1; } } } -void Player_SetModels(Player* this, s32 modelGroup) { - this->leftHandType = gPlayerModelTypes[modelGroup][1]; - this->rightHandType = gPlayerModelTypes[modelGroup][2]; - this->sheathType = gPlayerModelTypes[modelGroup][3]; +void Player_SetModels(Player* pthis, s32 modelGroup) { + pthis->leftHandType = gPlayerModelTypes[modelGroup][1]; + pthis->rightHandType = gPlayerModelTypes[modelGroup][2]; + pthis->sheathType = gPlayerModelTypes[modelGroup][3]; - this->leftHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][1]][(void)0, gSaveContext.linkAge]; - this->rightHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][2]][(void)0, gSaveContext.linkAge]; - this->sheathDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][3]][(void)0, gSaveContext.linkAge]; - this->waistDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][4]][(void)0, gSaveContext.linkAge]; + pthis->leftHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][1]][(void)0, gSaveContext.linkAge]; + pthis->rightHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][2]][(void)0, gSaveContext.linkAge]; + pthis->sheathDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][3]][(void)0, gSaveContext.linkAge]; + pthis->waistDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][4]][(void)0, gSaveContext.linkAge]; - Player_SetModelsForHoldingShield(this); + Player_SetModelsForHoldingShield(pthis); } -void Player_SetModelGroup(Player* this, s32 modelGroup) { - this->modelGroup = modelGroup; +void Player_SetModelGroup(Player* pthis, s32 modelGroup) { + pthis->modelGroup = modelGroup; if (modelGroup == 1) { - this->modelAnimType = 0; + pthis->modelAnimType = 0; } else { - this->modelAnimType = gPlayerModelTypes[modelGroup][0]; + pthis->modelAnimType = gPlayerModelTypes[modelGroup][0]; } - if ((this->modelAnimType < 3) && (this->currentShield == PLAYER_SHIELD_NONE)) { - this->modelAnimType = 0; + if ((pthis->modelAnimType < 3) && (pthis->currentShield == PLAYER_SHIELD_NONE)) { + pthis->modelAnimType = 0; } - Player_SetModels(this, modelGroup); + Player_SetModels(pthis, modelGroup); } -void func_8008EC70(Player* this) { - this->itemActionParam = this->heldItemActionParam; - Player_SetModelGroup(this, Player_ActionToModelGroup(this, this->heldItemActionParam)); - this->unk_6AD = 0; +void func_8008EC70(Player* pthis) { + pthis->itemActionParam = pthis->heldItemActionParam; + Player_SetModelGroup(pthis, Player_ActionToModelGroup(pthis, pthis->heldItemActionParam)); + pthis->unk_6AD = 0; } -void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this) { - if (this->csMode != 0x56) { - this->currentShield = CUR_EQUIP_VALUE(EQUIP_SHIELD); - this->currentTunic = CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1; - this->currentBoots = CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1; - this->currentSword = B_BTN_ITEM; - Player_SetModelGroup(this, Player_ActionToModelGroup(this, this->heldItemActionParam)); - Player_SetBootData(globalCtx, this); +void Player_SetEquipmentData(GlobalContext* globalCtx, Player* pthis) { + if (pthis->csMode != 0x56) { + pthis->currentShield = CUR_EQUIP_VALUE(EQUIP_SHIELD); + pthis->currentTunic = CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1; + pthis->currentBoots = CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1; + pthis->currentSword = B_BTN_ITEM; + Player_SetModelGroup(pthis, Player_ActionToModelGroup(pthis, pthis->heldItemActionParam)); + Player_SetBootData(globalCtx, pthis); } } -void Player_UpdateBottleHeld(GlobalContext* globalCtx, Player* this, s32 item, s32 actionParam) { - Inventory_UpdateBottleItem(globalCtx, item, this->heldItemButton); +void Player_UpdateBottleHeld(GlobalContext* globalCtx, Player* pthis, s32 item, s32 actionParam) { + Inventory_UpdateBottleItem(globalCtx, item, pthis->heldItemButton); if (item != ITEM_BOTTLE) { - this->heldItemId = item; - this->heldItemActionParam = actionParam; + pthis->heldItemId = item; + pthis->heldItemActionParam = actionParam; } - this->itemActionParam = actionParam; + pthis->itemActionParam = actionParam; } -void func_8008EDF0(Player* this) { - this->unk_664 = NULL; - this->stateFlags2 &= ~0x2000; +void func_8008EDF0(Player* pthis) { + pthis->unk_664 = NULL; + pthis->stateFlags2 &= ~0x2000; } -void func_8008EE08(Player* this) { - if ((this->actor.bgCheckFlags & 1) || (this->stateFlags1 & 0x8A00000) || - (!(this->stateFlags1 & 0xC0000) && ((this->actor.world.pos.y - this->actor.floorHeight) < 100.0f))) { - this->stateFlags1 &= ~0x400F8000; - } else if (!(this->stateFlags1 & 0x2C0000)) { - this->stateFlags1 |= 0x80000; +void func_8008EE08(Player* pthis) { + if ((pthis->actor.bgCheckFlags & 1) || (pthis->stateFlags1 & 0x8A00000) || + (!(pthis->stateFlags1 & 0xC0000) && ((pthis->actor.world.pos.y - pthis->actor.floorHeight) < 100.0f))) { + pthis->stateFlags1 &= ~0x400F8000; + } else if (!(pthis->stateFlags1 & 0x2C0000)) { + pthis->stateFlags1 |= 0x80000; } - func_8008EDF0(this); + func_8008EDF0(pthis); } void func_8008EEAC(GlobalContext* globalCtx, Actor* actor) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - func_8008EE08(this); - this->unk_664 = actor; - this->unk_684 = actor; - this->stateFlags1 |= 0x10000; + func_8008EE08(pthis); + pthis->unk_664 = actor; + pthis->unk_684 = actor; + pthis->stateFlags1 |= 0x10000; Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, actor); Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), 2); } s32 func_8008EF30(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - return (this->stateFlags1 & 0x800000); + return (pthis->stateFlags1 & 0x800000); } s32 func_8008EF44(GlobalContext* globalCtx, s32 ammo) { @@ -501,12 +501,12 @@ s32 func_8008EF44(GlobalContext* globalCtx, s32 ammo) { } s32 Player_IsBurningStickInRange(GlobalContext* globalCtx, Vec3f* pos, f32 xzRange, f32 yRange) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); Vec3f diff; s32 pad; - if ((this->heldItemActionParam == PLAYER_AP_STICK) && (this->unk_860 != 0)) { - Math_Vec3f_Diff(&this->swordInfo[0].tip, pos, &diff); + if ((pthis->heldItemActionParam == PLAYER_AP_STICK) && (pthis->unk_860 != 0)) { + Math_Vec3f_Diff(&pthis->swordInfo[0].tip, pos, &diff); return ((SQ(diff.x) + SQ(diff.z)) <= SQ(xzRange)) && (0.0f <= diff.y) && (diff.y <= yRange); } else { return false; @@ -526,32 +526,32 @@ s32 Player_GetStrength(void) { } u8 Player_GetMask(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - return this->currentMask; + return pthis->currentMask; } Player* Player_UnsetMask(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - this->currentMask = PLAYER_MASK_NONE; + pthis->currentMask = PLAYER_MASK_NONE; - return this; + return pthis; } s32 Player_HasMirrorShieldEquipped(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - return (this->currentShield == PLAYER_SHIELD_MIRROR); + return (pthis->currentShield == PLAYER_SHIELD_MIRROR); } s32 Player_HasMirrorShieldSetToDraw(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); - return (this->rightHandType == 10) && (this->currentShield == PLAYER_SHIELD_MIRROR); + return (pthis->rightHandType == 10) && (pthis->currentShield == PLAYER_SHIELD_MIRROR); } -s32 Player_ActionToMagicSpell(Player* this, s32 actionParam) { +s32 Player_ActionToMagicSpell(Player* pthis, s32 actionParam) { s32 magicSpell = actionParam - PLAYER_AP_MAGIC_SPELL_15; if ((magicSpell >= 0) && (magicSpell < 6)) { @@ -561,12 +561,12 @@ s32 Player_ActionToMagicSpell(Player* this, s32 actionParam) { } } -s32 Player_HoldsHookshot(Player* this) { - return (this->heldItemActionParam == PLAYER_AP_HOOKSHOT) || (this->heldItemActionParam == PLAYER_AP_LONGSHOT); +s32 Player_HoldsHookshot(Player* pthis) { + return (pthis->heldItemActionParam == PLAYER_AP_HOOKSHOT) || (pthis->heldItemActionParam == PLAYER_AP_LONGSHOT); } -s32 func_8008F128(Player* this) { - return Player_HoldsHookshot(this) && (this->heldActor == NULL); +s32 func_8008F128(Player* pthis) { + return Player_HoldsHookshot(pthis) && (pthis->heldActor == NULL); } s32 Player_ActionToSword(s32 actionParam) { @@ -579,23 +579,23 @@ s32 Player_ActionToSword(s32 actionParam) { } } -s32 Player_GetSwordHeld(Player* this) { - return Player_ActionToSword(this->heldItemActionParam); +s32 Player_GetSwordHeld(Player* pthis) { + return Player_ActionToSword(pthis->heldItemActionParam); } -s32 Player_HoldsTwoHandedWeapon(Player* this) { - if ((this->heldItemActionParam >= PLAYER_AP_SWORD_BGS) && (this->heldItemActionParam <= PLAYER_AP_HAMMER)) { +s32 Player_HoldsTwoHandedWeapon(Player* pthis) { + if ((pthis->heldItemActionParam >= PLAYER_AP_SWORD_BGS) && (pthis->heldItemActionParam <= PLAYER_AP_HAMMER)) { return 1; } else { return 0; } } -s32 Player_HoldsBrokenKnife(Player* this) { - return (this->heldItemActionParam == PLAYER_AP_SWORD_BGS) && (gSaveContext.swordHealth <= 0.0f); +s32 Player_HoldsBrokenKnife(Player* pthis) { + return (pthis->heldItemActionParam == PLAYER_AP_SWORD_BGS) && (gSaveContext.swordHealth <= 0.0f); } -s32 Player_ActionToBottle(Player* this, s32 actionParam) { +s32 Player_ActionToBottle(Player* pthis, s32 actionParam) { s32 bottle = actionParam - PLAYER_AP_BOTTLE; if ((bottle >= 0) && (bottle < 13)) { @@ -605,11 +605,11 @@ s32 Player_ActionToBottle(Player* this, s32 actionParam) { } } -s32 Player_GetBottleHeld(Player* this) { - return Player_ActionToBottle(this, this->heldItemActionParam); +s32 Player_GetBottleHeld(Player* pthis) { + return Player_ActionToBottle(pthis, pthis->heldItemActionParam); } -s32 Player_ActionToExplosive(Player* this, s32 actionParam) { +s32 Player_ActionToExplosive(Player* pthis, s32 actionParam) { s32 explosive = actionParam - PLAYER_AP_BOMB; if ((explosive >= 0) && (explosive < 2)) { @@ -619,11 +619,11 @@ s32 Player_ActionToExplosive(Player* this, s32 actionParam) { } } -s32 Player_GetExplosiveHeld(Player* this) { - return Player_ActionToExplosive(this, this->heldItemActionParam); +s32 Player_GetExplosiveHeld(Player* pthis) { + return Player_ActionToExplosive(pthis, pthis->heldItemActionParam); } -s32 func_8008F2BC(Player* this, s32 actionParam) { +s32 func_8008F2BC(Player* pthis, s32 actionParam) { s32 sword = 0; if (actionParam != PLAYER_AP_LAST_USED) { @@ -640,16 +640,16 @@ return_neg: } s32 func_8008F2F8(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); + Player* pthis = GET_PLAYER(globalCtx); TextTriggerEntry* triggerEntry; s32 var; if (globalCtx->roomCtx.curRoom.unk_02 == 3) { // Room is hot var = 0; - } else if ((this->unk_840 > 80) && - ((this->currentBoots == PLAYER_BOOTS_IRON) || (this->unk_840 >= 300))) { // Deep underwater - var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) ? 1 : 3; - } else if (this->stateFlags1 & 0x8000000) { // Swimming + } else if ((pthis->unk_840 > 80) && + ((pthis->currentBoots == PLAYER_BOOTS_IRON) || (pthis->unk_840 >= 300))) { // Deep underwater + var = ((pthis->currentBoots == PLAYER_BOOTS_IRON) && (pthis->actor.bgCheckFlags & 1)) ? 1 : 3; + } else if (pthis->stateFlags1 & 0x8000000) { // Swimming var = 2; } else { return 0; @@ -662,9 +662,9 @@ s32 func_8008F2F8(GlobalContext* globalCtx) { if (0) {} if ((triggerEntry->flag != 0) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && - (((var == 0) && (this->currentTunic != PLAYER_TUNIC_GORON)) || - (((var == 1) || (var == 3)) && (this->currentBoots == PLAYER_BOOTS_IRON) && - (this->currentTunic != PLAYER_TUNIC_ZORA)))) { + (((var == 0) && (pthis->currentTunic != PLAYER_TUNIC_GORON)) || + (((var == 1) || (var == 3)) && (pthis->currentBoots == PLAYER_BOOTS_IRON) && + (pthis->currentTunic != PLAYER_TUNIC_ZORA)))) { Message_StartTextbox(globalCtx, triggerEntry->textId, NULL); gSaveContext.textTriggerFlags |= triggerEntry->flag; } @@ -788,7 +788,7 @@ f32 D_80126068[] = { 5.0f, 3.0f }; Vec3f D_80126070 = { 0.0f, -300.0f, 0.0f }; -void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, +void func_8008F87C(GlobalContext* globalCtx, Player* pthis, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, s32 thighLimbIndex, s32 shinLimbIndex, s32 footLimbIndex) { Vec3f spA4; Vec3f sp98; @@ -812,13 +812,13 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, s16 temp2; s32 temp3; - if ((this->actor.scale.y >= 0.0f) && !(this->stateFlags1 & 0x80) && - (Player_ActionToMagicSpell(this, this->itemActionParam) < 0)) { + if ((pthis->actor.scale.y >= 0.0f) && !(pthis->stateFlags1 & 0x80) && + (Player_ActionToMagicSpell(pthis, pthis->itemActionParam) < 0)) { s32 pad; sp7C = D_80126058[(void)0, gSaveContext.linkAge]; sp78 = D_80126060[(void)0, gSaveContext.linkAge]; - sp74 = D_80126068[(void)0, gSaveContext.linkAge] - this->unk_6C4; + sp74 = D_80126068[(void)0, gSaveContext.linkAge] - pthis->unk_6C4; Matrix_Push(); Matrix_TranslateRotateZYX(pos, rot); @@ -831,7 +831,7 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, footprintPos.y += 15.0f; - sp80 = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74; + sp80 = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &sp88, &sp84, &pthis->actor, &footprintPos) + sp74; if (sp98.y < sp80) { sp70 = sp98.x - spA4.x; @@ -881,30 +881,30 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, } } -s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Player* this = (Player*)thisx; +s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* pthisx) { + Player* pthis = (Player*)pthisx; if (limbIndex == PLAYER_LIMB_ROOT) { - D_80160014 = this->leftHandType; - D_80160018 = this->rightHandType; - D_80160000 = &this->swordInfo[2].base; + D_80160014 = pthis->leftHandType; + D_80160018 = pthis->rightHandType; + D_80160000 = &pthis->swordInfo[2].base; if (!LINK_IS_ADULT) { - if (!(this->skelAnime.moveFlags & 4) || (this->skelAnime.moveFlags & 1)) { + if (!(pthis->skelAnime.moveFlags & 4) || (pthis->skelAnime.moveFlags & 1)) { pos->x *= 0.64f; pos->z *= 0.64f; } - if (!(this->skelAnime.moveFlags & 4) || (this->skelAnime.moveFlags & 2)) { + if (!(pthis->skelAnime.moveFlags & 4) || (pthis->skelAnime.moveFlags & 2)) { pos->y *= 0.64f; } } - pos->y -= this->unk_6C4; + pos->y -= pthis->unk_6C4; - if (this->unk_6C2 != 0) { - Matrix_Translate(pos->x, ((Math_CosS(this->unk_6C2) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY); - Matrix_RotateX(this->unk_6C2 * (M_PI / 0x8000), MTXMODE_APPLY); + if (pthis->unk_6C2 != 0) { + Matrix_Translate(pos->x, ((Math_CosS(pthis->unk_6C2) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY); + Matrix_RotateX(pthis->unk_6C2 * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); pos->x = pos->y = pos->z = 0.0f; rot->x = rot->y = rot->z = 0; @@ -915,28 +915,28 @@ s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p } if (limbIndex == PLAYER_LIMB_HEAD) { - rot->x += this->unk_6BA; - rot->y -= this->unk_6B8; - rot->z += this->unk_6B6; + rot->x += pthis->unk_6BA; + rot->y -= pthis->unk_6B8; + rot->z += pthis->unk_6B6; } else if (limbIndex == PLAYER_LIMB_UPPER) { - if (this->unk_6B0 != 0) { + if (pthis->unk_6B0 != 0) { Matrix_RotateZ(0x44C * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateY(this->unk_6B0 * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->unk_6B0 * (M_PI / 0x8000), MTXMODE_APPLY); } - if (this->unk_6BE != 0) { - Matrix_RotateY(this->unk_6BE * (M_PI / 0x8000), MTXMODE_APPLY); + if (pthis->unk_6BE != 0) { + Matrix_RotateY(pthis->unk_6BE * (M_PI / 0x8000), MTXMODE_APPLY); } - if (this->unk_6BC != 0) { - Matrix_RotateX(this->unk_6BC * (M_PI / 0x8000), MTXMODE_APPLY); + if (pthis->unk_6BC != 0) { + Matrix_RotateX(pthis->unk_6BC * (M_PI / 0x8000), MTXMODE_APPLY); } - if (this->unk_6C0 != 0) { - Matrix_RotateZ(this->unk_6C0 * (M_PI / 0x8000), MTXMODE_APPLY); + if (pthis->unk_6C0 != 0) { + Matrix_RotateZ(pthis->unk_6C0 * (M_PI / 0x8000), MTXMODE_APPLY); } } else if (limbIndex == PLAYER_LIMB_L_THIGH) { - func_8008F87C(globalCtx, this, &this->skelAnime, pos, rot, PLAYER_LIMB_L_THIGH, PLAYER_LIMB_L_SHIN, + func_8008F87C(globalCtx, pthis, &pthis->skelAnime, pos, rot, PLAYER_LIMB_L_THIGH, PLAYER_LIMB_L_SHIN, PLAYER_LIMB_L_FOOT); } else if (limbIndex == PLAYER_LIMB_R_THIGH) { - func_8008F87C(globalCtx, this, &this->skelAnime, pos, rot, PLAYER_LIMB_R_THIGH, PLAYER_LIMB_R_SHIN, + func_8008F87C(globalCtx, pthis, &pthis->skelAnime, pos, rot, PLAYER_LIMB_R_THIGH, PLAYER_LIMB_R_SHIN, PLAYER_LIMB_R_FOOT); return false; } else { @@ -947,42 +947,42 @@ s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -s32 func_80090014(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Player* this = (Player*)thisx; +s32 func_80090014(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* pthisx) { + Player* pthis = (Player*)pthisx; - if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, thisx)) { + if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, pthisx)) { if (limbIndex == PLAYER_LIMB_L_HAND) { - Gfx** dLists = this->leftHandDLists; + Gfx** dLists = pthis->leftHandDLists; if ((D_80160014 == 4) && (gSaveContext.swordHealth <= 0.0f)) { dLists += 4; - } else if ((D_80160014 == 6) && (this->stateFlags1 & 0x2000000)) { + } else if ((D_80160014 == 6) && (pthis->stateFlags1 & 0x2000000)) { dLists = &D_80125E08[gSaveContext.linkAge]; D_80160014 = 0; - } else if ((this->leftHandType == 0) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { + } else if ((pthis->leftHandType == 0) && (pthis->actor.speedXZ > 2.0f) && !(pthis->stateFlags1 & 0x8000000)) { dLists = &D_80125E18[gSaveContext.linkAge]; D_80160014 = 1; } *dList = dLists[sDListsLodOffset]; } else if (limbIndex == PLAYER_LIMB_R_HAND) { - Gfx** dLists = this->rightHandDLists; + Gfx** dLists = pthis->rightHandDLists; if (D_80160018 == 10) { - dLists += this->currentShield * 4; - } else if ((this->rightHandType == 8) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { + dLists += pthis->currentShield * 4; + } else if ((pthis->rightHandType == 8) && (pthis->actor.speedXZ > 2.0f) && !(pthis->stateFlags1 & 0x8000000)) { dLists = &D_80125E58[gSaveContext.linkAge]; D_80160018 = 9; } *dList = dLists[sDListsLodOffset]; } else if (limbIndex == PLAYER_LIMB_SHEATH) { - Gfx** dLists = this->sheathDLists; + Gfx** dLists = pthis->sheathDLists; int dListOffset = 0; - if ((this->sheathType == 18) || (this->sheathType == 19)) { - dLists += this->currentShield * 4; - if (!LINK_IS_ADULT && (this->currentShield < PLAYER_SHIELD_HYLIAN) && + if ((pthis->sheathType == 18) || (pthis->sheathType == 19)) { + dLists += pthis->currentShield * 4; + if (!LINK_IS_ADULT && (pthis->currentShield < PLAYER_SHIELD_HYLIAN) && (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI)) { dLists += 16; /* Figure out which array we want to truly be in */ @@ -991,24 +991,24 @@ s32 func_80090014(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p dLists = D_80125D68; } } - } else if (!LINK_IS_ADULT && ((this->sheathType == 16) || (this->sheathType == 17)) && + } else if (!LINK_IS_ADULT && ((pthis->sheathType == 16) || (pthis->sheathType == 17)) && (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI)) { dLists = D_80125D68; } *dList = dLists[sDListsLodOffset+dListOffset]; } else if (limbIndex == PLAYER_LIMB_WAIST) { - *dList = this->waistDLists[sDListsLodOffset]; + *dList = pthis->waistDLists[sDListsLodOffset]; } } return false; } -s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Player* this = (Player*)thisx; +s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* pthisx) { + Player* pthis = (Player*)pthisx; - if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, thisx)) { - if (this->unk_6AD != 2) { + if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, pthisx)) { + if (pthis->unk_6AD != 2) { *dList = NULL; } else if (limbIndex == PLAYER_LIMB_L_FOREARM) { *dList = sArmOutDLs[(void)0, gSaveContext.linkAge]; @@ -1019,7 +1019,7 @@ s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p } else if (limbIndex == PLAYER_LIMB_R_FOREARM) { *dList = D_80125F30[(void)0, gSaveContext.linkAge]; } else if (limbIndex == PLAYER_LIMB_R_HAND) { - *dList = Player_HoldsHookshot(this) ? gLinkAdultRightHandHoldingHookshotFarDL + *dList = Player_HoldsHookshot(pthis) ? gLinkAdultRightHandHoldingHookshotFarDL : sHoldingFirstPersonWeaponDLs[(void)0, gSaveContext.linkAge]; } else { *dList = NULL; @@ -1029,8 +1029,8 @@ s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -s32 func_80090440(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, thisx)) { +s32 func_80090440(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* pthisx) { + if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, pthisx)) { *dList = NULL; } @@ -1066,7 +1066,7 @@ u8 func_80090480(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* w } } -void func_80090604(GlobalContext* globalCtx, Player* this, ColliderQuad* collider, Vec3f* quadSrc) { +void func_80090604(GlobalContext* globalCtx, Player* pthis, ColliderQuad* collider, Vec3f* quadSrc) { static u8 shieldColTypes[PLAYER_SHIELD_MAX] = { COLTYPE_METAL, COLTYPE_WOOD, @@ -1074,10 +1074,10 @@ void func_80090604(GlobalContext* globalCtx, Player* this, ColliderQuad* collide COLTYPE_METAL, }; - if (this->stateFlags1 & 0x400000) { + if (pthis->stateFlags1 & 0x400000) { Vec3f quadDest[4]; - this->shieldQuad.base.colType = shieldColTypes[this->currentShield]; + pthis->shieldQuad.base.colType = shieldColTypes[pthis->currentShield]; Matrix_MultVec3f(&quadSrc[0], &quadDest[0]); Matrix_MultVec3f(&quadSrc[1], &quadDest[1]); @@ -1100,37 +1100,37 @@ Vec3f D_801260A4[3] = { { 0.0f, -400.0f, 1000.0f }, }; -void func_800906D4(GlobalContext* globalCtx, Player* this, Vec3f* newTipPos) { +void func_800906D4(GlobalContext* globalCtx, Player* pthis, Vec3f* newTipPos) { Vec3f newBasePos[3]; Matrix_MultVec3f(&D_801260A4[0], &newBasePos[0]); Matrix_MultVec3f(&D_801260A4[1], &newBasePos[1]); Matrix_MultVec3f(&D_801260A4[2], &newBasePos[2]); - if (func_80090480(globalCtx, NULL, &this->swordInfo[0], &newTipPos[0], &newBasePos[0]) && - !(this->stateFlags1 & 0x400000)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->swordEffectIndex), &this->swordInfo[0].tip, - &this->swordInfo[0].base); + if (func_80090480(globalCtx, NULL, &pthis->swordInfo[0], &newTipPos[0], &newBasePos[0]) && + !(pthis->stateFlags1 & 0x400000)) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->swordEffectIndex), &pthis->swordInfo[0].tip, + &pthis->swordInfo[0].base); } - if ((this->swordState > 0) && ((this->swordAnimation < 0x18) || (this->stateFlags2 & 0x20000))) { - func_80090480(globalCtx, &this->swordQuads[0], &this->swordInfo[1], &newTipPos[1], &newBasePos[1]); - func_80090480(globalCtx, &this->swordQuads[1], &this->swordInfo[2], &newTipPos[2], &newBasePos[2]); + if ((pthis->swordState > 0) && ((pthis->swordAnimation < 0x18) || (pthis->stateFlags2 & 0x20000))) { + func_80090480(globalCtx, &pthis->swordQuads[0], &pthis->swordInfo[1], &newTipPos[1], &newBasePos[1]); + func_80090480(globalCtx, &pthis->swordQuads[1], &pthis->swordInfo[2], &newTipPos[2], &newBasePos[2]); } } -void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPos, s32 drawIdPlusOne) { - f32 height = (this->exchangeItemId != EXCH_ITEM_NONE) ? 6.0f : 14.0f; +void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* pthis, Vec3f* refPos, s32 drawIdPlusOne) { + f32 height = (pthis->exchangeItemId != EXCH_ITEM_NONE) ? 6.0f : 14.0f; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2401); - gSegments[6] = VIRTUAL_TO_PHYSICAL(this->giObjectSegment); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(pthis->giObjectSegment); - gSPSegment(POLY_OPA_DISP++, 0x06, this->giObjectSegment); - gSPSegment(POLY_XLU_DISP++, 0x06, this->giObjectSegment); + gSPSegment(POLY_OPA_DISP++, 0x06, pthis->giObjectSegment); + gSPSegment(POLY_XLU_DISP++, 0x06, pthis->giObjectSegment); - Matrix_Translate(refPos->x + (3.3f * Math_SinS(this->actor.shape.rot.y)), refPos->y + height, - refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_CosS(this->actor.shape.rot.y)), MTXMODE_NEW); + Matrix_Translate(refPos->x + (3.3f * Math_SinS(pthis->actor.shape.rot.y)), refPos->y + height, + refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_CosS(pthis->actor.shape.rot.y)), MTXMODE_NEW); Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); @@ -1139,19 +1139,19 @@ void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPo CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2421); } -void Player_DrawGetItem(GlobalContext* globalCtx, Player* this) { - if (!this->giObjectLoading || !osRecvMesg(&this->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK)) { - this->giObjectLoading = false; - Player_DrawGetItemImpl(globalCtx, this, &sGetItemRefPos, ABS(this->unk_862)); +void Player_DrawGetItem(GlobalContext* globalCtx, Player* pthis) { + if (!pthis->giObjectLoading || !osRecvMesg(&pthis->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK)) { + pthis->giObjectLoading = false; + Player_DrawGetItemImpl(globalCtx, pthis, &sGetItemRefPos, ABS(pthis->unk_862)); } } -void func_80090A28(Player* this, Vec3f* vecs) { +void func_80090A28(Player* pthis, Vec3f* vecs) { D_8012608C.x = D_80126080.x; - if (this->unk_845 >= 3) { - this->unk_845 += 1; - D_8012608C.x *= 1.0f + ((9 - this->unk_845) * 0.1f); + if (pthis->unk_845 >= 3) { + pthis->unk_845 += 1; + D_8012608C.x *= 1.0f + ((9 - pthis->unk_845) * 0.1f); } D_8012608C.x += 1200.0f; @@ -1162,7 +1162,7 @@ void func_80090A28(Player* this, Vec3f* vecs) { Matrix_MultVec3f(&D_80126098, &vecs[2]); } -void Player_DrawHookshotReticle(GlobalContext* globalCtx, Player* this, f32 arg2) { +void Player_DrawHookshotReticle(GlobalContext* globalCtx, Player* pthis, f32 arg2) { static Vec3f D_801260C8 = { -500.0f, -100.0f, 0.0f }; CollisionPoly* sp9C; s32 bgId; @@ -1194,7 +1194,7 @@ void Player_DrawHookshotReticle(GlobalContext* globalCtx, Player* this, f32 arg2 gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2587), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(OVERLAY_DISP++, 0x06, gObjectTable[this->actor.objBankIndex].vromStart); + gSPSegment(OVERLAY_DISP++, 0x06, gObjectTable[pthis->actor.objBankIndex].vromStart.get()); gSPDisplayList(OVERLAY_DISP++, gLinkAdultHookshotReticleDL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2592); @@ -1247,8 +1247,8 @@ Vec3f D_801261E0[] = { { 200.0f, 200.0f, 0.0f }, }; -void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - Player* this = (Player*)thisx; +void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* pthisx) { + Player* pthis = (Player*)pthisx; if (*dList != NULL) { Matrix_MultVec3f(&D_8012602C, D_80160000); @@ -1258,45 +1258,45 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* MtxF sp14C; Actor* hookedActor; - Math_Vec3f_Copy(&this->leftHandPos, D_80160000); + Math_Vec3f_Copy(&pthis->leftHandPos, D_80160000); - if (this->itemActionParam == PLAYER_AP_STICK) { + if (pthis->itemActionParam == PLAYER_AP_STICK) { Vec3f sp124[3]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2633); - if (this->actor.scale.y >= 0.0f) { - D_80126080.x = this->unk_85C * 5000.0f; - func_80090A28(this, sp124); - if (this->swordState != 0) { - func_800906D4(globalCtx, this, sp124); + if (pthis->actor.scale.y >= 0.0f) { + D_80126080.x = pthis->unk_85C * 5000.0f; + func_80090A28(pthis, sp124); + if (pthis->swordState != 0) { + func_800906D4(globalCtx, pthis, sp124); } else { - Math_Vec3f_Copy(&this->swordInfo[0].tip, &sp124[0]); + Math_Vec3f_Copy(&pthis->swordInfo[0].tip, &sp124[0]); } } Matrix_Translate(-428.26f, 267.2f, -33.82f, MTXMODE_APPLY); Matrix_RotateZYX(-0x8000, 0, 0x4000, MTXMODE_APPLY); - Matrix_Scale(1.0f, this->unk_85C, 1.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, pthis->unk_85C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2653), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gLinkChildLinkDekuStickDL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2656); - } else if ((this->actor.scale.y >= 0.0f) && (this->swordState != 0)) { + } else if ((pthis->actor.scale.y >= 0.0f) && (pthis->swordState != 0)) { Vec3f spE4[3]; - if (Player_HoldsBrokenKnife(this)) { + if (Player_HoldsBrokenKnife(pthis)) { D_80126080.x = 1500.0f; } else { - D_80126080.x = sSwordLengths[Player_GetSwordHeld(this)]; + D_80126080.x = sSwordLengths[Player_GetSwordHeld(pthis)]; } - func_80090A28(this, spE4); - func_800906D4(globalCtx, this, spE4); - } else if ((*dList != NULL) && (this->leftHandType == 7)) { - Color_RGB8* bottleColor = &sBottleColors[Player_ActionToBottle(this, this->itemActionParam)]; + func_80090A28(pthis, spE4); + func_800906D4(globalCtx, pthis, spE4); + } else if ((*dList != NULL) && (pthis->leftHandType == 7)) { + Color_RGB8* bottleColor = &sBottleColors[Player_ActionToBottle(pthis, pthis->itemActionParam)]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2710); @@ -1308,37 +1308,37 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2717); } - if (this->actor.scale.y >= 0.0f) { - if (!Player_HoldsHookshot(this) && ((hookedActor = this->heldActor) != NULL)) { - if (this->stateFlags1 & 0x200) { + if (pthis->actor.scale.y >= 0.0f) { + if (!Player_HoldsHookshot(pthis) && ((hookedActor = pthis->heldActor) != NULL)) { + if (pthis->stateFlags1 & 0x200) { Matrix_MultVec3f(&D_80126128, &hookedActor->world.pos); Matrix_RotateZYX(0x69E8, -0x5708, 0x458E, MTXMODE_APPLY); Matrix_Get(&sp14C); Matrix_MtxFToYXZRotS(&sp14C, &hookedActor->world.rot, 0); hookedActor->shape.rot = hookedActor->world.rot; - } else if (this->stateFlags1 & 0x800) { + } else if (pthis->stateFlags1 & 0x800) { Vec3s spB8; Matrix_Get(&sp14C); Matrix_MtxFToYXZRotS(&sp14C, &spB8, 0); if (hookedActor->flags & ACTOR_FLAG_17) { - hookedActor->world.rot.x = hookedActor->shape.rot.x = spB8.x - this->unk_3BC.x; + hookedActor->world.rot.x = hookedActor->shape.rot.x = spB8.x - pthis->unk_3BC.x; } else { - hookedActor->world.rot.y = hookedActor->shape.rot.y = this->actor.shape.rot.y + this->unk_3BC.y; + hookedActor->world.rot.y = hookedActor->shape.rot.y = pthis->actor.shape.rot.y + pthis->unk_3BC.y; } } } else { - Matrix_Get(&this->mf_9E0); - Matrix_MtxFToYXZRotS(&this->mf_9E0, &this->unk_3BC, 0); + Matrix_Get(&pthis->mf_9E0); + Matrix_MtxFToYXZRotS(&pthis->mf_9E0, &pthis->unk_3BC, 0); } } } else if (limbIndex == PLAYER_LIMB_R_HAND) { - Actor* heldActor = this->heldActor; + Actor* heldActor = pthis->heldActor; - if (this->rightHandType == 0xFF) { - Matrix_Get(&this->shieldMf); - } else if ((this->rightHandType == 11) || (this->rightHandType == 12)) { + if (pthis->rightHandType == 0xFF) { + Matrix_Get(&pthis->shieldMf); + } else if ((pthis->rightHandType == 11) || (pthis->rightHandType == 12)) { BowStringData* stringData = &sBowStringData[gSaveContext.linkAge]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2783); @@ -1346,30 +1346,30 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Matrix_Push(); Matrix_Translate(stringData->pos.x, stringData->pos.y, stringData->pos.z, MTXMODE_APPLY); - if ((this->stateFlags1 & 0x200) && (this->unk_860 >= 0) && (this->unk_834 <= 10)) { + if ((pthis->stateFlags1 & 0x200) && (pthis->unk_860 >= 0) && (pthis->unk_834 <= 10)) { Vec3f sp90; f32 distXYZ; Matrix_MultVec3f(&D_8012602C, &sp90); distXYZ = Math_Vec3f_DistXYZ(D_80160000, &sp90); - this->unk_858 = distXYZ - 3.0f; + pthis->unk_858 = distXYZ - 3.0f; if (distXYZ < 3.0f) { - this->unk_858 = 0.0f; + pthis->unk_858 = 0.0f; } else { - this->unk_858 *= 1.6f; - if (this->unk_858 > 1.0f) { - this->unk_858 = 1.0f; + pthis->unk_858 *= 1.6f; + if (pthis->unk_858 > 1.0f) { + pthis->unk_858 = 1.0f; } } - this->unk_85C = -0.5f; + pthis->unk_85C = -0.5f; } - Matrix_Scale(1.0f, this->unk_858, 1.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, pthis->unk_858, 1.0f, MTXMODE_APPLY); if (!LINK_IS_ADULT) { - Matrix_RotateZ(this->unk_858 * -0.2f, MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_858 * -0.2f, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2804), @@ -1379,15 +1379,15 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2809); - } else if ((this->actor.scale.y >= 0.0f) && (this->rightHandType == 10)) { - Matrix_Get(&this->shieldMf); - func_80090604(globalCtx, this, &this->shieldQuad, D_80126154); + } else if ((pthis->actor.scale.y >= 0.0f) && (pthis->rightHandType == 10)) { + Matrix_Get(&pthis->shieldMf); + func_80090604(globalCtx, pthis, &pthis->shieldQuad, D_80126154); } - if (this->actor.scale.y >= 0.0f) { - if ((this->heldItemActionParam == PLAYER_AP_HOOKSHOT) || - (this->heldItemActionParam == PLAYER_AP_LONGSHOT)) { - Matrix_MultVec3f(&D_80126184, &this->unk_3C8); + if (pthis->actor.scale.y >= 0.0f) { + if ((pthis->heldItemActionParam == PLAYER_AP_HOOKSHOT) || + (pthis->heldItemActionParam == PLAYER_AP_LONGSHOT)) { + Matrix_MultVec3f(&D_80126184, &pthis->unk_3C8); if (heldActor != NULL) { MtxF sp44; @@ -1399,44 +1399,44 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Matrix_MtxFToYXZRotS(&sp44, &heldActor->world.rot, 0); heldActor->shape.rot = heldActor->world.rot; - if (func_8002DD78(this) != 0) { + if (func_8002DD78(pthis) != 0) { Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY); Player_DrawHookshotReticle( - globalCtx, this, (this->heldItemActionParam == PLAYER_AP_HOOKSHOT) ? 38600.0f : 77600.0f); + globalCtx, pthis, (pthis->heldItemActionParam == PLAYER_AP_HOOKSHOT) ? 38600.0f : 77600.0f); } } } - if ((this->unk_862 != 0) || ((func_8002DD6C(this) == 0) && (heldActor != NULL))) { - if (!(this->stateFlags1 & 0x400) && (this->unk_862 != 0) && (this->exchangeItemId != EXCH_ITEM_NONE)) { - Math_Vec3f_Copy(&sGetItemRefPos, &this->leftHandPos); + if ((pthis->unk_862 != 0) || ((func_8002DD6C(pthis) == 0) && (heldActor != NULL))) { + if (!(pthis->stateFlags1 & 0x400) && (pthis->unk_862 != 0) && (pthis->exchangeItemId != EXCH_ITEM_NONE)) { + Math_Vec3f_Copy(&sGetItemRefPos, &pthis->leftHandPos); } else { - sGetItemRefPos.x = (this->bodyPartsPos[15].x + this->leftHandPos.x) * 0.5f; - sGetItemRefPos.y = (this->bodyPartsPos[15].y + this->leftHandPos.y) * 0.5f; - sGetItemRefPos.z = (this->bodyPartsPos[15].z + this->leftHandPos.z) * 0.5f; + sGetItemRefPos.x = (pthis->bodyPartsPos[15].x + pthis->leftHandPos.x) * 0.5f; + sGetItemRefPos.y = (pthis->bodyPartsPos[15].y + pthis->leftHandPos.y) * 0.5f; + sGetItemRefPos.z = (pthis->bodyPartsPos[15].z + pthis->leftHandPos.z) * 0.5f; } - if (this->unk_862 == 0) { + if (pthis->unk_862 == 0) { Math_Vec3f_Copy(&heldActor->world.pos, &sGetItemRefPos); } } } - } else if (this->actor.scale.y >= 0.0f) { + } else if (pthis->actor.scale.y >= 0.0f) { if (limbIndex == PLAYER_LIMB_SHEATH) { - if ((this->rightHandType != 10) && (this->rightHandType != 0xFF)) { - if (Player_IsChildWithHylianShield(this)) { - func_80090604(globalCtx, this, &this->shieldQuad, D_8012619C); + if ((pthis->rightHandType != 10) && (pthis->rightHandType != 0xFF)) { + if (Player_IsChildWithHylianShield(pthis)) { + func_80090604(globalCtx, pthis, &pthis->shieldQuad, D_8012619C); } Matrix_TranslateRotateZYX(&D_801261CC, &D_801261D8); - Matrix_Get(&this->shieldMf); + Matrix_Get(&pthis->shieldMf); } } else if (limbIndex == PLAYER_LIMB_HEAD) { - Matrix_MultVec3f(&D_801260D4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_801260D4, &pthis->actor.focus.pos); } else { Vec3f* vec = &D_801261E0[((void)0, gSaveContext.linkAge)]; - Actor_SetFeetPos(&this->actor, limbIndex, PLAYER_LIMB_L_FOOT, vec, PLAYER_LIMB_R_FOOT, vec); + Actor_SetFeetPos(&pthis->actor, limbIndex, PLAYER_LIMB_L_FOOT, vec, PLAYER_LIMB_R_FOOT, vec); } } } @@ -1446,21 +1446,20 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { u32 size; void* ptr; - size = POINTER_SUB(gObjectTable[OBJECT_GAMEPLAY_KEEP].vromEnd, gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart); + size = (gObjectTable[OBJECT_GAMEPLAY_KEEP].vromEnd - gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart).size(); ptr = segment + 0x3800; DmaMgr_SendRequest1(ptr, gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart, size, "../z_player_lib.c", 2982); - size = POINTER_SUB(gObjectTable[linkObjectId].vromEnd, gObjectTable[linkObjectId].vromStart); + size = (gObjectTable[linkObjectId].vromEnd - gObjectTable[linkObjectId].vromStart).size(); ptr = segment + 0x8800; DmaMgr_SendRequest1(ptr, gObjectTable[linkObjectId].vromStart, size, "../z_player_lib.c", 2988); ptr = (void*)ALIGN16(POINTER_ADD(ptr, size)); - gSegments[4] = VIRTUAL_TO_PHYSICAL(segment + 0x3800); - gSegments[6] = VIRTUAL_TO_PHYSICAL(segment + 0x8800); + gSegments[4] = (uintptr_t)VIRTUAL_TO_PHYSICAL(segment + 0x3800); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(segment + 0x8800); - SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.linkAge], &gPlayerAnim_003238, 9, - ptr, ptr, PLAYER_LIMB_MAX); + SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.linkAge], &gPlayerAnim_003238, 9, (Vec3s*)ptr, (Vec3s*)ptr, PLAYER_LIMB_MAX); return size + 0x8800 + 0x90; } @@ -1468,7 +1467,7 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { u8 D_801261F8[] = { 2, 2, 5 }; s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* arg) { - u8* ptr = arg; + u8* ptr = (u8*)arg; /* AddressSanitizer: global-buffer-overflow on address ptr[0] = 0 */ ptr[0] = MAX(ptr[0], 1); u8 modelGroup = D_801261F8[ptr[0] - 1]; @@ -1519,8 +1518,8 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime Gfx* opaRef; Gfx* xluRef; u16 perspNorm; - Mtx* perspMtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx)); - Mtx* lookAtMtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx)); + Mtx* perspMtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx)); + Mtx* lookAtMtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx)); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 3129); @@ -1620,8 +1619,8 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, Vec3s* srcTable; s32 i; - gSegments[4] = VIRTUAL_TO_PHYSICAL(segment + 0x3800); - gSegments[6] = VIRTUAL_TO_PHYSICAL(segment + 0x8800); + gSegments[4] = (uintptr_t)VIRTUAL_TO_PHYSICAL(segment + 0x3800); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(segment + 0x8800); if (!LINK_IS_ADULT) { if (shield == PLAYER_SHIELD_DEKU) { @@ -1639,7 +1638,7 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, } } - srcTable = SEGMENTED_TO_VIRTUAL(srcTable); + srcTable = (Vec3s*)SEGMENTED_TO_VIRTUAL(srcTable); destTable = skelAnime->jointTable; for (i = 0; i < skelAnime->limbCount; i++) { *destTable++ = *srcTable++; diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c deleted file mode 100644 index ce3aeda75..000000000 --- a/src/code/z_prenmi.c +++ /dev/null @@ -1,69 +0,0 @@ -#define INTERNAL_SRC_CODE_Z_PRENMI_C -#include "global.h" -#include "z_prenmi_buff.h" -#include "vt.h" -#include "def/z_prenmi.h" -#include "def/z_rcp.h" -#include "def/graph.h" // FORCE - -void func_80092320(PreNMIContext* this) { - this->state.running = false; - this->state.init = NULL; - this->state.size = 0; -} - -void PreNMI_Update(PreNMIContext* this) { - osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_move\n" VT_RST); - - // Strings existing only in rodata - if (0) { - osSyncPrintf("../z_prenmi.c"); - osSyncPrintf("(int)volume = %d\n"); - } - - if (this->timer == 0) { - func_80092320(this); - return; - } - - this->timer--; -} - -void PreNMI_Draw(PreNMIContext* this) { - GraphicsContext* gfxCtx = this->state.gfxCtx; - - osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_draw\n" VT_RST); - - OPEN_DISPS(gfxCtx, "../z_prenmi.c", 96); - - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); - Gfx_ClearDisplay(gfxCtx, 0, 0, 0); - func_800940B0(gfxCtx); - gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); - gDPFillRectangle(POLY_OPA_DISP++, 0, this->timer + 100, SCREEN_WIDTH - 1, this->timer + 100); - - CLOSE_DISPS(gfxCtx, "../z_prenmi.c", 112); -} - -void PreNMI_Main(GameState* thisx) { - PreNMIContext* this = (PreNMIContext*)thisx; - - PreNMI_Update(this); - PreNMI_Draw(this); - - this->state.unk_A0 = 1; -} - -void PreNMI_Destroy(GameState* thisx) { -} - -void PreNMI_Init(GameState* thisx) { - PreNMIContext* this = (PreNMIContext*)thisx; - - this->state.main = PreNMI_Main; - this->state.destroy = PreNMI_Destroy; - this->timer = 30; - this->unk_A8 = 10; - - R_UPDATE_RATE = 1; -} diff --git a/src/code/z_prenmi.cpp b/src/code/z_prenmi.cpp new file mode 100644 index 000000000..2d79abacd --- /dev/null +++ b/src/code/z_prenmi.cpp @@ -0,0 +1,69 @@ +#define INTERNAL_SRC_CODE_Z_PRENMI_C +#include "global.h" +#include "z_prenmi_buff.h" +#include "vt.h" +#include "def/z_prenmi.h" +#include "def/z_rcp.h" +#include "def/graph.h" // FORCE + +void func_80092320(PreNMIContext* pthis) { + pthis->state.running = false; + pthis->state.init = NULL; + pthis->state.size = 0; +} + +void PreNMI_Update(PreNMIContext* pthis) { + osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_move\n" VT_RST); + + // Strings existing only in rodata + if (0) { + osSyncPrintf("../z_prenmi.c"); + osSyncPrintf("(int)volume = %d\n"); + } + + if (pthis->timer == 0) { + func_80092320(pthis); + return; + } + + pthis->timer--; +} + +void PreNMI_Draw(PreNMIContext* pthis) { + GraphicsContext* gfxCtx = pthis->state.gfxCtx; + + osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_draw\n" VT_RST); + + OPEN_DISPS(gfxCtx, "../z_prenmi.c", 96); + + gSPSegment(POLY_OPA_DISP++, 0x00, NULL); + Gfx_ClearDisplay(gfxCtx, 0, 0, 0); + func_800940B0(gfxCtx); + gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); + gDPFillRectangle(POLY_OPA_DISP++, 0, pthis->timer + 100, SCREEN_WIDTH - 1, pthis->timer + 100); + + CLOSE_DISPS(gfxCtx, "../z_prenmi.c", 112); +} + +void PreNMI_Main(GameState* pthisx) { + PreNMIContext* pthis = (PreNMIContext*)pthisx; + + PreNMI_Update(pthis); + PreNMI_Draw(pthis); + + pthis->state.unk_A0 = 1; +} + +void PreNMI_Destroy(GameState* pthisx) { +} + +void PreNMI_Init(GameState* pthisx) { + PreNMIContext* pthis = (PreNMIContext*)pthisx; + + pthis->state.main = PreNMI_Main; + pthis->state.destroy = PreNMI_Destroy; + pthis->timer = 30; + pthis->unk_A8 = 10; + + R_UPDATE_RATE = 1; +} diff --git a/src/code/z_prenmi_buff.c b/src/code/z_prenmi_buff.c deleted file mode 100644 index b96964465..000000000 --- a/src/code/z_prenmi_buff.c +++ /dev/null @@ -1,26 +0,0 @@ -#define INTERNAL_SRC_CODE_Z_PRENMI_BUFF_C -#include "global.h" -#include "z_prenmi_buff.h" -#include "def/gettime.h" -#include "def/z_prenmi_buff.h" - -#define COLD_RESET 0 -#define NMI 1 - -void PreNmiBuff_Init(PreNmiBuff* this) { - this->resetting = false; - - this->resetCount = 0; - this->duration = 0; - - this->resetTime = 0; -} - -void PreNmiBuff_SetReset(PreNmiBuff* this) { - this->resetting = true; - this->resetTime = osGetTime(); -} - -u32 PreNmiBuff_IsResetting(PreNmiBuff* this) { - return this->resetting; -} diff --git a/src/code/z_prenmi_buff.cpp b/src/code/z_prenmi_buff.cpp new file mode 100644 index 000000000..cd4b041c2 --- /dev/null +++ b/src/code/z_prenmi_buff.cpp @@ -0,0 +1,26 @@ +#define INTERNAL_SRC_CODE_Z_PRENMI_BUFF_C +#include "global.h" +#include "z_prenmi_buff.h" +#include "def/gettime.h" +#include "def/z_prenmi_buff.h" + +#define COLD_RESET 0 +#define NMI 1 + +void PreNmiBuff_Init(PreNmiBuff* pthis) { + pthis->resetting = false; + + pthis->resetCount = 0; + pthis->duration = 0; + + pthis->resetTime = 0; +} + +void PreNmiBuff_SetReset(PreNmiBuff* pthis) { + pthis->resetting = true; + pthis->resetTime = osGetTime(); +} + +u32 PreNmiBuff_IsResetting(PreNmiBuff* pthis) { + return pthis->resetting; +} diff --git a/src/code/z_quake.c b/src/code/z_quake.cpp similarity index 100% rename from src/code/z_quake.c rename to src/code/z_quake.cpp diff --git a/src/code/z_rcp.c b/src/code/z_rcp.cpp similarity index 99% rename from src/code/z_rcp.c rename to src/code/z_rcp.cpp index 0030f3970..fae99be96 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.cpp @@ -1373,7 +1373,7 @@ void func_80094D4C(GraphicsContext* gfxCtx) { } Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); gDPTileSync(displayList); gDPSetTileSize(displayList + 1, 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); @@ -1391,7 +1391,7 @@ Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y) { } Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Graph_Alloc(gfxCtx, 3 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, 3 * sizeof(Gfx)); x %= 2048; y %= 2048; @@ -1405,7 +1405,7 @@ Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height) Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2) { - Gfx* displayList = Graph_Alloc(gfxCtx, 5 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, 5 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; @@ -1423,7 +1423,7 @@ Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 wi Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList = Graph_Alloc(gfxCtx, 6 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, 6 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; @@ -1441,7 +1441,7 @@ Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1 } Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); gDPSetEnvColor(displayList, r, g, b, a); gSPEndDisplayList(displayList + 1); diff --git a/src/code/z_room.c b/src/code/z_room.cpp similarity index 94% rename from src/code/z_room.c rename to src/code/z_room.cpp index 54076527a..ff98b0b5b 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.cpp @@ -86,7 +86,7 @@ void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags) { } polygon0 = &room->mesh->polygon0; - polygonDlist = SEGMENTED_TO_VIRTUAL(polygon0->start); + polygonDlist = (PolygonDlist*)SEGMENTED_TO_VIRTUAL(polygon0->start); for (i = 0; i < polygon0->num; i++) { if ((flags & 1) && (polygonDlist->opa != NULL)) { gSPDisplayList(POLY_OPA_DISP++, polygonDlist->opa); @@ -147,7 +147,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { } polygon2 = &room->mesh->polygon2; - polygonDlist = SEGMENTED_TO_VIRTUAL(polygon2->start); + polygonDlist = (PolygonDlist2*)SEGMENTED_TO_VIRTUAL(polygon2->start); spA4 = spB8; ASSERT(polygon2->num <= SHAPE_SORT_MAX, "polygon2->num <= SHAPE_SORT_MAX", "../z_room.c", 317); @@ -295,14 +295,14 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h bg->b.imageY = 0; bg->b.imageH = height * 4; bg->b.frameY = frameY * 4; - bg->b.imagePtr = source; + bg->b.imagePtr = (u64*)source; bg->b.imageLoad = G_BGLT_LOADTILE; bg->b.imageFmt = fmt; bg->b.imageSiz = siz; bg->b.imagePal = 0; bg->b.imageFlip = 0; - displayListHead = (void*)(bg + 1); + displayListHead = (Gfx*)(bg + 1); if (fmt == G_IM_FMT_CI) { gDPLoadTLUT(displayListHead++, tlutCount, 256, tlut); } else { @@ -354,7 +354,7 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { camera = GET_ACTIVE_CAM(globalCtx); sp9C = (camera->setting == CAM_SET_PREREND_FIXED); polygon1 = &room->mesh->polygon1; - polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); + polygonDlist = (PolygonDlist*)SEGMENTED_TO_VIRTUAL(polygon1->dlist); sp98 = (flags & 1) && sp9C && polygon1->single.source && !(SREG(25) & 1); sp94 = (flags & 1) && polygonDlist->opa && !(SREG(25) & 2); sp90 = (flags & 2) && polygonDlist->xlu && !(SREG(25) & 4); @@ -417,7 +417,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { player = GET_PLAYER(globalCtx); player->actor.params = (player->actor.params & 0xFF00) | camId; - bgImage = SEGMENTED_TO_VIRTUAL(polygon1->multi.list); + bgImage = (BgImage*)SEGMENTED_TO_VIRTUAL(polygon1->multi.list); for (i = 0; i < polygon1->multi.count; i++) { if (bgImage->id == camId) { return bgImage; @@ -449,9 +449,9 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { camera = GET_ACTIVE_CAM(globalCtx); sp98 = (camera->setting == CAM_SET_PREREND_FIXED); polygon1 = &room->mesh->polygon1; - polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); + polygonDlist = (PolygonDlist*)SEGMENTED_TO_VIRTUAL(polygon1->dlist); bgImage = func_80096A74(polygon1, globalCtx); - sp94 = (flags & 1) && sp98 && bgImage->source && !(SREG(25) & 1); + sp94 = (flags & 1) && sp98 && bgImage->source.get() && !(SREG(25) & 1); sp90 = (flags & 1) && polygonDlist->opa && !(SREG(25) & 2); sp8C = (flags & 2) && polygonDlist->xlu && !(SREG(25) & 4); @@ -472,7 +472,7 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { Vec3f sp5C; spA8 = POLY_OPA_DISP; Camera_GetSkyboxOffset(&sp5C, camera); - func_8009638C(&spA8, bgImage->source, bgImage->tlut, bgImage->width, bgImage->height, bgImage->fmt, + func_8009638C(&spA8, bgImage->source.buffer(), bgImage->tlut.buffer(), bgImage->width, bgImage->height, bgImage->fmt, bgImage->siz, bgImage->mode0, bgImage->tlutCount, (sp5C.x + sp5C.z) * 1.2f + sp5C.y * 0.6f, sp5C.y * 2.4f + (sp5C.x + sp5C.z) * 0.3f); POLY_OPA_DISP = spA8; @@ -524,7 +524,7 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { u32 cumulRoomSize; for (i = 0; i < globalCtx->numRooms; i++) { - roomSize = POINTER_SUB(roomList[i].vromEnd, roomList[i].vromStart); + roomSize = POINTER_SUB2(roomList[i].vromEnd, roomList[i].vromStart); osSyncPrintf("ROOM%d size=%d\n", i, roomSize); if (maxRoomSize < roomSize) { maxRoomSize = roomSize; @@ -540,8 +540,8 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { for (j = 0; j < globalCtx->transiActorCtx.numActors; j++) { frontRoom = transitionActor->sides[0].room; backRoom = transitionActor->sides[1].room; - frontRoomSize = (frontRoom < 0) ? 0 : POINTER_SUB(roomList[frontRoom].vromEnd, roomList[frontRoom].vromStart); - backRoomSize = (backRoom < 0) ? 0 : POINTER_SUB(roomList[backRoom].vromEnd, roomList[backRoom].vromStart); + frontRoomSize = (frontRoom < 0) ? 0 : POINTER_SUB2(roomList[frontRoom].vromEnd, roomList[frontRoom].vromStart); + backRoomSize = (backRoom < 0) ? 0 : POINTER_SUB2(roomList[backRoom].vromEnd, roomList[backRoom].vromStart); cumulRoomSize = (frontRoom != backRoom) ? frontRoomSize + backRoomSize : frontRoomSize; osSyncPrintf("DOOR%d=<%d> ROOM1=<%d, %d> ROOM2=<%d, %d>\n", j, cumulRoomSize, frontRoom, frontRoomSize, @@ -575,13 +575,13 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { ASSERT(roomNum < globalCtx->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); - size = POINTER_SUB(globalCtx->roomList[roomNum].vromEnd, globalCtx->roomList[roomNum].vromStart); + size = POINTER_SUB2(globalCtx->roomList[roomNum].vromEnd, globalCtx->roomList[roomNum].vromStart); /*roomCtx->unk_34 = (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, globalCtx->roomList[roomNum].vromStart, size, 0, &roomCtx->loadQueue, NULL, "../z_room.c", 1036);*/ - roomCtx->unk_34 = globalCtx->roomList[roomNum].vromStart; + roomCtx->unk_34 = globalCtx->roomList[roomNum].vromStart.buffer(); roomCtx->unk_30 ^= 1; return 1; @@ -595,9 +595,9 @@ s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { roomCtx->status = 0; roomCtx->curRoom.segment = roomCtx->unk_34; - gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); + gSegments[3] = (uintptr_t)VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); - Scene_ExecuteCommands(globalCtx, roomCtx->curRoom.segment); + Scene_ExecuteCommands(globalCtx, (SceneCmd*)roomCtx->curRoom.segment); Player_SetBootData(globalCtx, GET_PLAYER(globalCtx)); Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx); @@ -612,7 +612,7 @@ s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) { if (room->segment != NULL) { - gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment); + gSegments[3] = (uintptr_t)VIRTUAL_TO_PHYSICAL(room->segment); ASSERT(room->mesh->polygon.type < ARRAY_COUNTU(sRoomDrawHandlers), "this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125); sRoomDrawHandlers[room->mesh->polygon.type](globalCtx, room, flags); diff --git a/src/code/z_sample.c b/src/code/z_sample.cpp similarity index 59% rename from src/code/z_sample.c rename to src/code/z_sample.cpp index 72590d3ee..f70bbd90b 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.cpp @@ -15,21 +15,21 @@ #include "def/z_view.h" #include "def/z_play.h" // FORCE -void Sample_HandleStateChange(SampleContext* this) { - if (CHECK_BTN_ALL(this->state.input[0].press.button, BTN_START)) { - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); - this->state.running = false; +void Sample_HandleStateChange(SampleContext* pthis) { + if (CHECK_BTN_ALL(pthis->state.input[0].press.button, BTN_START)) { + SET_NEXT_GAMESTATE(&pthis->state, Gameplay_Init, GlobalContext); + pthis->state.running = false; } } -void Sample_Draw(SampleContext* this) { - GraphicsContext* gfxCtx = this->state.gfxCtx; - View* view = &this->view; +void Sample_Draw(SampleContext* pthis) { + GraphicsContext* gfxCtx = pthis->state.gfxCtx; + View* view = &pthis->view; OPEN_DISPS(gfxCtx, "../z_sample.c", 62); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); - gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); + gSPSegment(POLY_OPA_DISP++, 0x01, pthis->staticSegment); Gfx_ClearDisplay(gfxCtx, 0, 0, 0); @@ -37,7 +37,7 @@ void Sample_Draw(SampleContext* this) { func_800AAA50(view, 15); { - Mtx* mtx = Graph_Alloc(gfxCtx, sizeof(Mtx)); + Mtx* mtx = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); guPosition(mtx, SREG(37), SREG(38), SREG(39), 1.0f, SREG(40), SREG(41), SREG(42)); gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD); @@ -54,19 +54,19 @@ void Sample_Draw(SampleContext* this) { CLOSE_DISPS(gfxCtx, "../z_sample.c", 111); } -void Sample_Main(GameState* thisx) { - SampleContext* this = (SampleContext*)thisx; +void Sample_Main(GameState* pthisx) { + SampleContext* pthis = (SampleContext*)pthisx; - Sample_Draw(this); - Sample_HandleStateChange(this); + Sample_Draw(pthis); + Sample_HandleStateChange(pthis); } -void Sample_Destroy(GameState* thisx) { +void Sample_Destroy(GameState* pthisx) { } -void Sample_SetupView(SampleContext* this) { - View* view = &this->view; - GraphicsContext* gfxCtx = this->state.gfxCtx; +void Sample_SetupView(SampleContext* pthis) { + View* view = &pthis->view; + GraphicsContext* gfxCtx = pthis->state.gfxCtx; View_Init(view, gfxCtx); SET_FULLSCREEN_VIEWPORT(view); @@ -91,21 +91,21 @@ void Sample_SetupView(SampleContext* this) { } } -void Sample_LoadTitleStatic(SampleContext* this) { +void Sample_LoadTitleStatic(SampleContext* pthis) { u32 size = _title_staticSegmentRomEnd - _title_staticSegmentRomStart; - this->staticSegment = GameState_Alloc(&this->state, size, "../z_sample.c", 163); - DmaMgr_SendRequest1(this->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164); + pthis->staticSegment = (u8*)GameState_Alloc(&pthis->state, size, "../z_sample.c", 163); + DmaMgr_SendRequest1(pthis->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164); } -void Sample_Init(GameState* thisx) { - SampleContext* this = (SampleContext*)thisx; +void Sample_Init(GameState* pthisx) { + SampleContext* pthis = (SampleContext*)pthisx; - this->state.main = Sample_Main; - this->state.destroy = Sample_Destroy; + pthis->state.main = Sample_Main; + pthis->state.destroy = Sample_Destroy; R_UPDATE_RATE = 1; - Sample_SetupView(this); - Sample_LoadTitleStatic(this); + Sample_SetupView(pthis); + Sample_LoadTitleStatic(pthis); SREG(37) = 0; SREG(38) = 0; SREG(39) = 0; diff --git a/src/code/z_scene.c b/src/code/z_scene.cpp similarity index 88% rename from src/code/z_scene.c rename to src/code/z_scene.cpp index b75ad111f..dc91b9338 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.cpp @@ -33,7 +33,7 @@ { (uintptr_t) name, (uintptr_t)name + sizeof(name) } #endif -static bool (*gSceneCmdHandlers[26])(GlobalContext*, SceneCmd*); +extern bool (*gSceneCmdHandlers[26])(GlobalContext*, const SceneCmd*); RomFile sNaviMsgFiles[]; @@ -155,7 +155,7 @@ bool cmd_00_unknown(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x01: Actor List bool cmd_actor_list(GlobalContext* globalCtx, const SceneCmd* cmd) { globalCtx->numSetupActors = cmd->actorList.num; - globalCtx->setupActorList = SEGMENTED_TO_VIRTUAL(cmd->actorList.segment); + globalCtx->setupActorList = (ActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->actorList.segment); return true; } @@ -167,13 +167,13 @@ bool cmd_02_unused(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x03: Collision Header bool cmd_collision_header(GlobalContext* globalCtx, const SceneCmd* cmd) { - CollisionHeader* colHeader = SEGMENTED_TO_VIRTUAL(cmd->colHeader.segment); + CollisionHeader* colHeader = (CollisionHeader*)SEGMENTED_TO_VIRTUAL(cmd->colHeader.segment); - colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); - colHeader->polyList = SEGMENTED_TO_VIRTUAL(colHeader->polyList); - colHeader->surfaceTypeList = SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList); - colHeader->cameraDataList = SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList); - colHeader->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes); + colHeader->vtxList = (Vec3s*)SEGMENTED_TO_VIRTUAL(colHeader->vtxList); + colHeader->polyList = (CollisionPoly*)SEGMENTED_TO_VIRTUAL(colHeader->polyList); + colHeader->surfaceTypeList = (SurfaceType*)SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList); + colHeader->cameraDataList = (CamData*)SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList); + colHeader->waterBoxes = (WaterBox*)SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes); BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); return true; @@ -182,13 +182,13 @@ bool cmd_collision_header(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x04: Room List bool cmd_room_list(GlobalContext* globalCtx, const SceneCmd* cmd) { globalCtx->numRooms = cmd->roomList.num; - globalCtx->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.segment); + globalCtx->roomList = (RomFile*)SEGMENTED_TO_VIRTUAL(cmd->roomList.segment); return true; } // Scene Command 0x06: Entrance List bool cmd_entrance_list(GlobalContext* globalCtx, const SceneCmd* cmd) { - globalCtx->setupEntranceList = SEGMENTED_TO_VIRTUAL(cmd->entranceList.segment); + globalCtx->setupEntranceList = (EntranceEntry*)SEGMENTED_TO_VIRTUAL(cmd->entranceList.segment); return true; } @@ -196,11 +196,11 @@ bool cmd_entrance_list(GlobalContext* globalCtx, const SceneCmd* cmd) { bool cmd_special_files(GlobalContext* globalCtx, const SceneCmd* cmd) { if (cmd->specialFiles.keepObjectId != 0) { globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.keepObjectId); - gSegments[5] = gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart; + gSegments[5] = gObjectTable[globalCtx->objectCtx.subKeepIndex].vromStart.get(); } if (cmd->specialFiles.cUpElfMsgNum != 0) { - globalCtx->cUpElfMsgs = Gameplay_LoadFile(globalCtx, &sNaviMsgFiles[cmd->specialFiles.cUpElfMsgNum - 1]); + globalCtx->cUpElfMsgs = (ElfMessage*)Gameplay_LoadFile(globalCtx, &sNaviMsgFiles[cmd->specialFiles.cUpElfMsgNum - 1]); } return true; } @@ -216,13 +216,13 @@ bool cmd_room_behavior(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x0A: Mesh Header bool cmd_mesh_header(GlobalContext* globalCtx, const SceneCmd* cmd) { - globalCtx->roomCtx.curRoom.mesh = SEGMENTED_TO_VIRTUAL(cmd->mesh.segment); + globalCtx->roomCtx.curRoom.mesh = (Mesh*)SEGMENTED_TO_VIRTUAL(cmd->mesh.segment); return true; } // Scene Command 0x0B: Object List bool cmd_object_list(GlobalContext* globalCtx, const SceneCmd* cmd) { - globalCtx->objectCtx.objectEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.segment); + globalCtx->objectCtx.objectEntry = (s16*)SEGMENTED_TO_VIRTUAL(cmd->objectList.segment); globalCtx->objectCtx.num = cmd->objectList.num; return true; } @@ -230,7 +230,7 @@ bool cmd_object_list(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x0C: Light List bool cmd_light_list(GlobalContext* globalCtx, const SceneCmd* cmd) { s32 i; - LightInfo* lightInfo = SEGMENTED_TO_VIRTUAL(cmd->lightList.segment); + LightInfo* lightInfo = (LightInfo*)SEGMENTED_TO_VIRTUAL(cmd->lightList.segment); for (i = 0; i < cmd->lightList.num; i++) { LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo); @@ -241,26 +241,25 @@ bool cmd_light_list(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x0D: Path List bool cmd_path_list(GlobalContext* globalCtx, const SceneCmd* cmd) { - globalCtx->setupPathList = SEGMENTED_TO_VIRTUAL(cmd->pathList.segment); + globalCtx->setupPathList = (Path*)SEGMENTED_TO_VIRTUAL(cmd->pathList.segment); return true; } // Scene Command 0x0E: Transition Actor List bool cmd_transition_actor_list(GlobalContext* globalCtx, const SceneCmd* cmd) { globalCtx->transiActorCtx.numActors = cmd->transiActorList.num; - globalCtx->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.segment); + globalCtx->transiActorCtx.list = (TransitionActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->transiActorList.segment); return true; } void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) { transiActorCtx->numActors = 0; - return true; } // Scene Command 0x0F: Light Setting List bool cmd_light_setting_list(GlobalContext* globalCtx, const SceneCmd* cmd) { globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num; - globalCtx->envCtx.lightSettingsList = SEGMENTED_TO_VIRTUAL(cmd->lightSettingList.segment); + globalCtx->envCtx.lightSettingsList = (EnvLightSettings*)SEGMENTED_TO_VIRTUAL(cmd->lightSettingList.segment); return true; } @@ -332,7 +331,7 @@ bool cmd_wind_settings(GlobalContext* globalCtx, const SceneCmd* cmd) { // Scene Command 0x13: Exit List bool cmd_exit_list(GlobalContext* globalCtx, const SceneCmd* cmd) { - globalCtx->setupExitList = SEGMENTED_TO_VIRTUAL(cmd->exitList.segment); + globalCtx->setupExitList = (s16*)SEGMENTED_TO_VIRTUAL(cmd->exitList.segment); return true; } @@ -373,7 +372,7 @@ bool cmd_alternate_headers(GlobalContext* globalCtx, const SceneCmd* cmd) { if (1) {} if (altHeader != NULL) { - Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader)); + Scene_ExecuteCommands(globalCtx, (SceneCmd*)SEGMENTED_TO_VIRTUAL(altHeader)); return false; } else { // "Coughh! There is no specified dataaaaa!" @@ -387,7 +386,7 @@ bool cmd_alternate_headers(GlobalContext* globalCtx, const SceneCmd* cmd) { osSyncPrintf("\nそこで、大人の昼データを使用するでええっす!!"); if (altHeader != NULL) { - Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader)); + Scene_ExecuteCommands(globalCtx, (SceneCmd*)SEGMENTED_TO_VIRTUAL(altHeader)); return false; } } diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.cpp similarity index 99% rename from src/code/z_scene_table.c rename to src/code/z_scene_table.cpp index 2297978a9..bc71deb48 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.cpp @@ -140,7 +140,6 @@ extern Gfx gEmptyDL[]; #include "def/code_800FD970.h" #include "def/coss.h" #include "def/graph.h" -#include "def/sinf.h" #include "def/sys_matrix.h" #include "def/z_actor.h" #include "def/z_common_data.h" @@ -1286,7 +1285,7 @@ void* sDCLavaFloorTextures[] = { void func_80099878(GlobalContext* globalCtx) { u32 gameplayFrames; s32 pad; - Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx[3])); + Gfx* displayListHead = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx[3])); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4905); @@ -1324,7 +1323,7 @@ void func_80099878(GlobalContext* globalCtx) { // Scene Draw Config 30 void func_80099BD8(GlobalContext* globalCtx) { f32 temp; - Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Gfx)); + Gfx* displayListHead = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Gfx)); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5069); @@ -1926,7 +1925,7 @@ void func_8009CC00(GlobalContext* globalCtx) { Gfx* Gfx_TwoTexScrollPrimColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList = Graph_Alloc(gfxCtx, 10 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, 10 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; @@ -2120,7 +2119,7 @@ void func_8009DA30(GlobalContext* globalCtx) { u32 gameplayFrames; Gfx* displayListHead; - displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 3 * sizeof(Gfx)); + displayListHead = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 3 * sizeof(Gfx)); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6814); @@ -2218,7 +2217,7 @@ void func_8009E0B8(GlobalContext* globalCtx) { spA3 = 128; spA0 = 500; - displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 6 * sizeof(Gfx)); + displayListHead = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 6 * sizeof(Gfx)); if (1) {} if (1) {} @@ -2494,7 +2493,7 @@ void func_8009F40C(GlobalContext* globalCtx) { // Scene Draw Config 14 void func_8009F5D4(GlobalContext* globalCtx) { - Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 3 * sizeof(Gfx)); + Gfx* displayListHead = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 3 * sizeof(Gfx)); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7461); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.cpp similarity index 93% rename from src/code/z_skelanime.c rename to src/code/z_skelanime.cpp index d00cc06be..df4dc7d7a 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.cpp @@ -28,9 +28,9 @@ s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 SkelAnime_LoopFull(SkelAnime* skelAnime); -s32 SkelAnime_Once(SkelAnime* skelAnime); -s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); +s32 SkelAnime_LoopFull(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 SkelAnime_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 SkelAnime_LoopPartial(GlobalContext* globalCtx, SkelAnime* skelAnime); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); @@ -211,7 +211,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); + Mtx* mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -428,7 +428,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); + Mtx* mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -443,7 +443,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Matrix_Push(); - rootLimb = SEGMENTED_TO_VIRTUAL(skeleton[0]); + rootLimb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]); pos.x = jointTable[0].x; pos.y = jointTable[0].y; @@ -485,9 +485,9 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi * Indices above limit are offsets to a frame data array indexed by the frame. */ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable) { - AnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); - JointIndex* jointIndices = SEGMENTED_TO_VIRTUAL(animHeader->jointIndices); - s16* frameData = SEGMENTED_TO_VIRTUAL(animHeader->frameData); + AnimationHeader* animHeader = (AnimationHeader*)SEGMENTED_TO_VIRTUAL(animation); + JointIndex* jointIndices = (JointIndex*)SEGMENTED_TO_VIRTUAL(animHeader->jointIndices); + s16* frameData = (s16*)SEGMENTED_TO_VIRTUAL(animHeader->frameData); s16* staticData = &frameData[0]; s16* dynamicData = &frameData[frame]; u16 staticIndexMax = animHeader->staticIndexMax; @@ -504,13 +504,13 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount } s16 Animation_GetLength(void* animation) { - AnimationHeaderCommon* common = SEGMENTED_TO_VIRTUAL(animation); + AnimationHeaderCommon* common = (AnimationHeaderCommon*)SEGMENTED_TO_VIRTUAL(animation); return common->frameCount; } s16 Animation_GetLastFrame(void* animation) { - AnimationHeaderCommon* common = SEGMENTED_TO_VIRTUAL(animation); + AnimationHeaderCommon* common = (AnimationHeaderCommon*)SEGMENTED_TO_VIRTUAL(animation); // Loads an unsigned half for some reason. return (u16)common->frameCount - 1; } @@ -684,7 +684,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx)); + Mtx* mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -736,10 +736,10 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT * Used by the legacy animation format */ s32 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable) { - LegacyAnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); + LegacyAnimationHeader* animHeader = (LegacyAnimationHeader*)SEGMENTED_TO_VIRTUAL(animation); s32 limbCount = animHeader->limbCount; - JointKey* key = SEGMENTED_TO_VIRTUAL(animHeader->jointKey); - s16* frameData = SEGMENTED_TO_VIRTUAL(animHeader->frameData); + JointKey* key = (JointKey*)SEGMENTED_TO_VIRTUAL(animHeader->jointKey); + s16* frameData = (s16*)SEGMENTED_TO_VIRTUAL(animHeader->frameData); s16* staticData = &frameData[0]; s16* dynamicData = &frameData[frame]; s32 i; @@ -764,7 +764,7 @@ s32 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Ve * Used by legacy animation format */ s16 Animation_GetLimbCountLegacy(LegacyAnimationHeader* animation) { - LegacyAnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); + LegacyAnimationHeader* animHeader = (LegacyAnimationHeader*)SEGMENTED_TO_VIRTUAL(animation); return animHeader->limbCount; } @@ -773,7 +773,7 @@ s16 Animation_GetLimbCountLegacy(LegacyAnimationHeader* animation) { * Used by legacy animation format */ s16 Animation_GetLengthLegacy(LegacyAnimationHeader* animation) { - LegacyAnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); + LegacyAnimationHeader* animHeader = (LegacyAnimationHeader*)SEGMENTED_TO_VIRTUAL(animation); return animHeader->frameCount; } @@ -782,7 +782,7 @@ s16 Animation_GetLengthLegacy(LegacyAnimationHeader* animation) { * Used by legacy animation format */ s16 Animation_GetLastFrameLegacy(LegacyAnimationHeader* animation) { - LegacyAnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); + LegacyAnimationHeader* animHeader = (LegacyAnimationHeader*)SEGMENTED_TO_VIRTUAL(animation); return animHeader->frameCount - 1; } @@ -859,7 +859,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_LOADFRAME); if (entry != NULL) { - LinkAnimationHeader* linkAnimHeader = SEGMENTED_TO_VIRTUAL(animation); + LinkAnimationHeader* linkAnimHeader = (LinkAnimationHeader*)SEGMENTED_TO_VIRTUAL(animation); void* ram = frameTable; osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); @@ -1059,7 +1059,7 @@ void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animati void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount) { - FlexSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + FlexSkeletonHeader* skeletonHeader = (FlexSkeletonHeader*)SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); s32 headerJointCount = skeletonHeader->sh.limbCount; s32 limbCount; size_t allocSize; @@ -1078,15 +1078,15 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel skelAnime->dListCount = skeletonHeader->dListCount; allocSize = limbCount * sizeof(Vec3s); - skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->sh.segment); + skelAnime->skeleton = (void**)SEGMENTED_TO_VIRTUAL(skeletonHeader->sh.segment); if (flags & 8) { allocSize += 2; } if (jointTable == NULL) { - skelAnime->jointTable = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2364); - skelAnime->morphTable = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2365); + skelAnime->jointTable = (Vec3s*)ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2364); + skelAnime->morphTable = (Vec3s*)ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2365); } else { ASSERT(limbBufCount == limbCount, "joint_buff_num == joint_num", "../z_skelanime.c", 2369); @@ -1148,7 +1148,7 @@ s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { * jointTable and morphTable */ void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetLoadFrame(globalCtx, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, + AnimationContext_SetLoadFrame(globalCtx, (LinkAnimationHeader*)skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); if (skelAnime->morphWeight != 0) { f32 updateRate = R_UPDATE_RATE * 0.5f; @@ -1399,15 +1399,13 @@ s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) { */ s32 SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { - SkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + SkeletonHeader* skeletonHeader = (SkeletonHeader*)SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->limbCount + 1; - skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->segment); + skelAnime->skeleton = (void**)SEGMENTED_TO_VIRTUAL(skeletonHeader->segment); if (jointTable == NULL) { - skelAnime->jointTable = - ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->jointTable), "../z_skelanime.c", 2968); - skelAnime->morphTable = - ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->morphTable), "../z_skelanime.c", 2969); + skelAnime->jointTable = (Vec3s*)ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->jointTable), "../z_skelanime.c", 2968); + skelAnime->morphTable = (Vec3s*)ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->morphTable), "../z_skelanime.c", 2969); } else { ASSERT(limbCount == skelAnime->limbCount, "joint_buff_num == this->joint_num", "../z_skelanime.c", 2973); skelAnime->jointTable = jointTable; @@ -1430,18 +1428,16 @@ s32 SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeade */ s32 SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { - FlexSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + FlexSkeletonHeader* skeletonHeader = (FlexSkeletonHeader*)SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->sh.limbCount + 1; skelAnime->dListCount = skeletonHeader->dListCount; - skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->sh.segment); + skelAnime->skeleton = (void**)SEGMENTED_TO_VIRTUAL(skeletonHeader->sh.segment); if (jointTable == NULL) { - skelAnime->jointTable = - ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->jointTable), "../z_skelanime.c", 3047); + skelAnime->jointTable = (Vec3s*)ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->jointTable), "../z_skelanime.c", 3047); - skelAnime->morphTable = - ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->morphTable), "../z_skelanime.c", 3048); + skelAnime->morphTable = (Vec3s*)ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->morphTable), "../z_skelanime.c", 3048); } else { ASSERT(limbCount == skelAnime->limbCount, "joint_buff_num == this->joint_num", "../z_skelanime.c", 3052); skelAnime->jointTable = jointTable; @@ -1465,14 +1461,12 @@ s32 SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkele */ s32 SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation) { - SkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + SkeletonHeader* skeletonHeader = (SkeletonHeader*)SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->limbCount + 1; - skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->segment); - skelAnime->jointTable = - ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->jointTable), "../z_skelanime.c", 3120); - skelAnime->morphTable = - ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->morphTable), "../z_skelanime.c", 3121); + skelAnime->skeleton = (void**)SEGMENTED_TO_VIRTUAL(skeletonHeader->segment); + skelAnime->jointTable = (Vec3s*)ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->jointTable), "../z_skelanime.c", 3120); + skelAnime->morphTable = (Vec3s*)ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->morphTable), "../z_skelanime.c", 3121); if ((skelAnime->jointTable == NULL) || (skelAnime->morphTable == NULL)) { osSyncPrintf(VT_FGCOL(RED)); // "Memory allocation error" @@ -1505,13 +1499,14 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update(nullptr, skelAnime); } /** * Morphs from the pose in jointTable to the one in morphTable, advancing the morph but not the animation frame */ -s32 SkelAnime_Morph(SkelAnime* skelAnime) { +static s32 SkelAnime_Morph(GlobalContext* context, SkelAnime* skelAnime) +{ f32 prevMorphWeight = skelAnime->morphWeight; f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f); @@ -1529,7 +1524,8 @@ s32 SkelAnime_Morph(SkelAnime* skelAnime) { * Performs a tapered morph from the pose in jointTable to the one in morphTable, advancing the morph but not the * animation frame */ -s32 SkelAnime_MorphTaper(SkelAnime* skelAnime) { +static s32 SkelAnime_MorphTaper(GlobalContext* context, SkelAnime* skelAnime) +{ s16 prevPhase = skelAnime->morphWeight * 0x4000; s16 curPhase; f32 prevWeight; @@ -1565,7 +1561,7 @@ s32 SkelAnime_MorphTaper(SkelAnime* skelAnime) { void SkelAnime_AnimateFrame(SkelAnime* skelAnime) { Vec3s nextjointTable[100]; - SkelAnime_GetFrameData(skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); + SkelAnime_GetFrameData((AnimationHeader*)skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); if (skelAnime->mode & ANIM_INTERP) { s32 frame = skelAnime->curFrame; f32 partialFrame = skelAnime->curFrame - frame; @@ -1573,7 +1569,7 @@ void SkelAnime_AnimateFrame(SkelAnime* skelAnime) { if (++frame >= (s32)skelAnime->animLength) { frame = 0; } - SkelAnime_GetFrameData(skelAnime->animation, frame, skelAnime->limbCount, nextjointTable); + SkelAnime_GetFrameData((AnimationHeader*)skelAnime->animation, frame, skelAnime->limbCount, nextjointTable); SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, nextjointTable, partialFrame); } @@ -1593,7 +1589,8 @@ void SkelAnime_AnimateFrame(SkelAnime* skelAnime) { /** * Advances an animation that loops over its full length and updates the frame tables */ -s32 SkelAnime_LoopFull(SkelAnime* skelAnime) { +static s32 SkelAnime_LoopFull(GlobalContext* context, SkelAnime* skelAnime) +{ f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f); skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1609,7 +1606,8 @@ s32 SkelAnime_LoopFull(SkelAnime* skelAnime) { /** * Advances an animation that loops over part of its length and updates the frame tables */ -s32 SkelAnime_LoopPartial(SkelAnime* skelAnime) { +static s32 SkelAnime_LoopPartial(GlobalContext* context, SkelAnime* skelAnime) +{ f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f); skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1626,11 +1624,12 @@ s32 SkelAnime_LoopPartial(SkelAnime* skelAnime) { /** * Advances an animation that stops at endFrame and returns true when it is reached. */ -s32 SkelAnime_Once(SkelAnime* skelAnime) { +static s32 SkelAnime_Once(GlobalContext* context, SkelAnime* skelAnime) +{ f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f); if (skelAnime->curFrame == skelAnime->endFrame) { - SkelAnime_GetFrameData(skelAnime->animation, (s32)skelAnime->curFrame, skelAnime->limbCount, + SkelAnime_GetFrameData((AnimationHeader*)skelAnime->animation, (s32)skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); SkelAnime_AnimateFrame(skelAnime); return 1; diff --git a/src/code/z_skin.c b/src/code/z_skin.cpp similarity index 83% rename from src/code/z_skin.c rename to src/code/z_skin.cpp index d719da1ff..e4268a9ae 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.cpp @@ -65,7 +65,7 @@ void func_800A598C(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 a OPEN_DISPS(gfxCtx, "../z_skin.c", 254); skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); - data = SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); + data = (Struct_800A5E28*)SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); temp_2 = (Struct_800A598C*)SEGMENTED_TO_VIRTUAL(data->unk_4); avb = &skin->avbTbl[limbIndex]; @@ -132,8 +132,8 @@ void func_800A5E28(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 a Struct_800A5E28* temp_t9; OPEN_DISPS(gfxCtx, "../z_skin.c", 364); - skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); - temp_t9 = SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); + skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); + temp_t9 = (Struct_800A5E28*)SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); if (!(arg4 & 1)) { func_800A598C(gfxCtx, skin, limbIndex, arg3); } @@ -147,9 +147,9 @@ void func_800A5F60(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, Gfx* s32 pad; OPEN_DISPS(gfxCtx, "../z_skin.c", 395); - skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); + skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); if (arg3 == NULL) { - gfx = ((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment; + gfx = (Gfx*)(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); } if (gfx != NULL) { Mtx* mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &D_801600C0[limbIndex]); @@ -176,7 +176,7 @@ void func_800A60D8(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinC if ((arg7 & 1) == 0) { func_800A6AC4(skin, &D_801600C0[0], actor, arg5); } - skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); + skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); if ((arg7 & 2) == 0) { Mtx* mtx; @@ -207,23 +207,23 @@ close_disps: CLOSE_DISPS(gfxCtx, "../z_skin.c", 534); } -void func_800A6330(Actor* this, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, s32 arg4) { - func_800A60D8(this, globalCtx, skin, callback, NULL, arg4, 0, 0); +void func_800A6330(Actor* pthis, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, s32 arg4) { + func_800A60D8(pthis, globalCtx, skin, callback, NULL, arg4, 0, 0); } -void func_800A6360(Actor* this, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, +void func_800A6360(Actor* pthis, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5) { - func_800A60D8(this, globalCtx, skin, callback, arg4, arg5, 0, 0); + func_800A60D8(pthis, globalCtx, skin, callback, arg4, arg5, 0, 0); } -void func_800A6394(Actor* this, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, +void func_800A6394(Actor* pthis, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5, s32 arg6) { - func_800A60D8(this, globalCtx, skin, callback, arg4, arg5, arg6, 0); + func_800A60D8(pthis, globalCtx, skin, callback, arg4, arg5, arg6, 0); } -void func_800A63CC(Actor* this, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, +void func_800A63CC(Actor* pthis, GlobalContext* globalCtx, PSkinAwb* skin, SkinCallback callback, SkinCallback2 arg4, s32 arg5, s32 arg6, s32 arg7) { - func_800A60D8(this, globalCtx, skin, callback, arg4, arg5, arg6, arg7); + func_800A60D8(pthis, globalCtx, skin, callback, arg4, arg5, arg6, arg7); } void func_800A6408(PSkinAwb* skin, s32 joint, Vec3f* arg2, Vec3f* arg3) { diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.cpp similarity index 79% rename from src/code/z_skin_awb.c rename to src/code/z_skin_awb.cpp index bcb36ab20..a425b3aba 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.cpp @@ -10,9 +10,9 @@ void func_800A6460(GlobalContext* globalCtx, PSkinAwb* skin, s32 limbIndex) { s32 i; - SkinLimb** skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); - Struct_800A5E28* temp_v1 = SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); - Struct_800A598C* temp_v0 = SEGMENTED_TO_VIRTUAL(temp_v1->unk_4); + auto skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); + auto temp_v1 = (Struct_800A5E28*)SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment); + auto temp_v0 = (Struct_800A598C*)SEGMENTED_TO_VIRTUAL(temp_v1->unk_4); Struct_800A598C* phi_s0; Struct_800A57C0* temp_s1; @@ -20,7 +20,7 @@ void func_800A6460(GlobalContext* globalCtx, PSkinAwb* skin, s32 limbIndex) { Vtx* temp2 = skin->avbTbl[limbIndex].buf[i]; for (phi_s0 = temp_v0; phi_s0 < temp_v0 + temp_v1->unk_2; phi_s0++) { - Struct_800A57C0* phi_s1 = SEGMENTED_TO_VIRTUAL(phi_s0->unk_8); + auto phi_s1 = (Struct_800A57C0*)SEGMENTED_TO_VIRTUAL(phi_s0->unk_8); for (temp_s1 = phi_s1; temp_s1 < phi_s1 + phi_s0->unk_0; temp_s1++) { Vtx* temp_t5_3 = &temp2[temp_s1->unk_0]; @@ -39,19 +39,19 @@ void func_800A663C(GlobalContext* globalCtx, PSkinAwb* skin, SkeletonHeader* ske s32 limbCount; s32 i; SkinLimb** skeleton; - SkeletonHeader* virtSkelHeader = SEGMENTED_TO_VIRTUAL(skeletonHeader); + auto virtSkelHeader = (SkeletonHeader*)SEGMENTED_TO_VIRTUAL(skeletonHeader); skin->avbCount = virtSkelHeader->limbCount; skin->skeletonHeader = virtSkelHeader; - skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); + skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); limbCount = skin->skeletonHeader->limbCount; - skin->avbTbl = ZeldaArena_MallocDebug(limbCount * sizeof(SkinAvb), "../z_skin_awb.c", 212); + skin->avbTbl = (SkinAvb*)ZeldaArena_MallocDebug(limbCount * sizeof(SkinAvb), "../z_skin_awb.c", 212); ASSERT(skin->avbTbl != NULL, "pskin_awb->avb_tbl != NULL", "../z_skin_awb.c", 214); for (i = 0; i < limbCount; i++) { SkinAvb* avbEntry = &skin->avbTbl[i]; - SkinLimb* limb = SEGMENTED_TO_VIRTUAL(skeleton[i]); + auto limb = (SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[i]); if ((limb->unk_8 != 4) || (limb->segment == NULL)) { avbEntry->unk_0 = 0; @@ -59,12 +59,12 @@ void func_800A663C(GlobalContext* globalCtx, PSkinAwb* skin, SkeletonHeader* ske avbEntry->buf[0] = NULL; avbEntry->buf[1] = NULL; } else { - Struct_800A5E28* temp_s1 = SEGMENTED_TO_VIRTUAL(((void)0, limb->segment)); + auto temp_s1 = (Struct_800A5E28*)SEGMENTED_TO_VIRTUAL(((void)0, limb->segment)); avbEntry->unk_0 = 0; - avbEntry->buf[0] = ZeldaArena_MallocDebug(temp_s1->unk_0 * sizeof(Vtx), "../z_skin_awb.c", 235); + avbEntry->buf[0] = (Vtx*)ZeldaArena_MallocDebug(temp_s1->unk_0 * sizeof(Vtx), "../z_skin_awb.c", 235); ASSERT(avbEntry->buf[0] != NULL, "psavb->buf[0] != NULL", "../z_skin_awb.c", 237); - avbEntry->buf[1] = ZeldaArena_MallocDebug(temp_s1->unk_0 * sizeof(Vtx), "../z_skin_awb.c", 240); + avbEntry->buf[1] = (Vtx*)ZeldaArena_MallocDebug(temp_s1->unk_0 * sizeof(Vtx), "../z_skin_awb.c", 240); ASSERT(avbEntry->buf[1] != NULL, "psavb->buf[1] != NULL", "../z_skin_awb.c", 242); func_800A6460(globalCtx, skin, i); } @@ -96,7 +96,7 @@ void func_800A6888(GlobalContext* globalCtx, PSkinAwb* arg1) { s32 func_800A698C(PSkinAwb* skin, SkinLimb** skeleton, MtxF* mf, u8 parentIndex, u8 limbIndex) { s32 pad; - SkinLimb* limb = SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]); + auto limb = (SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]); MtxF* mtx; s32 temp_ret; MtxF sp28; @@ -136,7 +136,7 @@ s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3) { f32 yTransl; f32 xTransl; f32 zTransl; - SkinLimb** skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); + auto skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); Vec3s* jointRot = &skin->skelAnime.jointTable[0]; jointRot++; @@ -163,7 +163,7 @@ s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3) { } jointRot++; for (i = 1; i < skin->skeletonHeader->limbCount; i++) { - SkinLimb* limb = SEGMENTED_TO_VIRTUAL(skeleton[i]); + auto limb = (SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[i]); xTransl = limb->jointPos.x; yTransl = limb->jointPos.y; @@ -180,7 +180,7 @@ s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3) { actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), actor->world.pos.z); - temp_ret = func_800A698C(skin, SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment), arg1, 0xFF, 0); + temp_ret = func_800A698C(skin, (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment), arg1, 0xFF, 0); if (!temp_ret) { // func_800A698C only returns false return temp_ret; } diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.cpp similarity index 99% rename from src/code/z_skin_matrix.c rename to src/code/z_skin_matrix.cpp index 514f71f0d..e696597a0 100644 --- a/src/code/z_skin_matrix.c +++ b/src/code/z_skin_matrix.cpp @@ -600,7 +600,7 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { } Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src) { - Mtx* mtx = Graph_Alloc(gfxCtx, sizeof(Mtx)); + Mtx* mtx = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); if (mtx == NULL) { osSyncPrintf("Skin_Matrix_to_Mtx_new() 確保失敗:NULLを返して終了\n", mtx); diff --git a/src/code/z_sram.c b/src/code/z_sram.cpp similarity index 99% rename from src/code/z_sram.c rename to src/code/z_sram.cpp index b06452560..e171213c7 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.cpp @@ -888,7 +888,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { } void Sram_Alloc(GameState* gameState, SramContext* sramCtx) { - sramCtx->readBuff = GameState_Alloc(gameState, SRAM_SIZE, "../z_sram.c", 1294); + sramCtx->readBuff = (u8*)GameState_Alloc(gameState, SRAM_SIZE, "../z_sram.c", 1294); ASSERT(sramCtx->readBuff != NULL, "sram->read_buff != NULL", "../z_sram.c", 1295); } diff --git a/src/code/z_ss_sram.c b/src/code/z_ss_sram.cpp similarity index 100% rename from src/code/z_ss_sram.c rename to src/code/z_ss_sram.cpp diff --git a/src/code/z_view.c b/src/code/z_view.cpp similarity index 95% rename from src/code/z_view.c rename to src/code/z_view.cpp index e6826a59e..6238b06d0 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.cpp @@ -39,7 +39,7 @@ void View_ViewportToVp(Vp* dest, Viewport* src) { } View* View_New(GraphicsContext* gfxCtx) { - View* view = SystemArena_MallocDebug(sizeof(View), "../z_view.c", 285); + View* view = (View*)SystemArena_MallocDebug(sizeof(View), "../z_view.c", 285); if (view != NULL) { z_memset(view, 0, sizeof(View)); // memset @@ -292,7 +292,7 @@ s32 func_800AAA9C(View* view) { OPEN_DISPS(gfxCtx, "../z_view.c", 596); - vp = Graph_Alloc(gfxCtx, sizeof(Vp)); + vp = (Vp*)Graph_Alloc(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -301,7 +301,7 @@ s32 func_800AAA9C(View* view) { gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); - projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); + projection = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; @@ -346,7 +346,7 @@ s32 func_800AAA9C(View* view) { gSPPerspNormalize(POLY_XLU_DISP++, view->normal); gSPMatrix(POLY_XLU_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = Graph_Alloc(gfxCtx, sizeof(Mtx)); + viewing = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; @@ -389,7 +389,7 @@ s32 func_800AB0A8(View* view) { OPEN_DISPS(gfxCtx, "../z_view.c", 726); - vp = Graph_Alloc(gfxCtx, sizeof(Vp)); + vp = (Vp*)Graph_Alloc(gfxCtx, sizeof(Vp)); LogUtils_CheckNullPointer("vp", vp, "../z_view.c", 730); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -400,7 +400,7 @@ s32 func_800AB0A8(View* view) { gSPViewport(POLY_XLU_DISP++, vp); gSPViewport(OVERLAY_DISP++, vp); - projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); + projection = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 744); view->projectionPtr = projection; @@ -426,7 +426,7 @@ s32 func_800AB2C4(View* view) { OPEN_DISPS(gfxCtx, "../z_view.c", 777); - vp = Graph_Alloc(gfxCtx, sizeof(Vp)); + vp = (Vp*)Graph_Alloc(gfxCtx, sizeof(Vp)); LogUtils_CheckNullPointer("vp", vp, "../z_view.c", 781); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -436,7 +436,7 @@ s32 func_800AB2C4(View* view) { view->viewport.bottomY); gSPViewport(OVERLAY_DISP++, vp); - projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); + projection = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 791); view->projectionPtr = projection; @@ -464,7 +464,7 @@ s32 func_800AB560(View* view) { OPEN_DISPS(gfxCtx, "../z_view.c", 816); - vp = Graph_Alloc(gfxCtx, sizeof(Vp)); + vp = (Vp*)Graph_Alloc(gfxCtx, sizeof(Vp)); LogUtils_CheckNullPointer("vp", vp, "../z_view.c", 821); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -474,7 +474,7 @@ s32 func_800AB560(View* view) { view->viewport.bottomY); gSPViewport(OVERLAY_DISP++, vp); - projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); + projection = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 833); view->projectionPtr = projection; @@ -489,7 +489,7 @@ s32 func_800AB560(View* view) { gSPPerspNormalize(OVERLAY_DISP++, view->normal); gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = Graph_Alloc(gfxCtx, sizeof(Mtx)); + viewing = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("viewing", viewing, "../z_view.c", 848); view->viewingPtr = viewing; @@ -536,7 +536,7 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { arg1 = (view->flags & arg1) | (arg1 >> 4); if (arg1 & 2) { - vp = Graph_Alloc(gfxCtx, sizeof(Vp)); + vp = (Vp*)Graph_Alloc(gfxCtx, sizeof(Vp)); LogUtils_CheckNullPointer("vp", vp, "../z_view.c", 910); View_ViewportToVp(vp, &view->viewport); @@ -549,7 +549,7 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { } if (arg1 & 8) { - projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); + projection = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 921); view->projectionPtr = projection; @@ -560,7 +560,7 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { gSPMatrix(gfx++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } else if (arg1 & 6) { - projection = Graph_Alloc(gfxCtx, sizeof(Mtx)); + projection = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 932); view->projectionPtr = projection; @@ -577,7 +577,7 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { } if (arg1 & 1) { - viewing = Graph_Alloc(gfxCtx, sizeof(Mtx)); + viewing = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); LogUtils_CheckNullPointer("viewing", viewing, "../z_view.c", 948); view->viewingPtr = viewing; diff --git a/src/code/z_vimode.c b/src/code/z_vimode.cpp similarity index 98% rename from src/code/z_vimode.c rename to src/code/z_vimode.cpp index dffa74b86..50fa80332 100644 --- a/src/code/z_vimode.c +++ b/src/code/z_vimode.cpp @@ -5,12 +5,12 @@ #include "def/z_vimode.h" #include "z64game.h" -extern u32 osTvType; +u32 osTvType = OS_TV_NTSC; -s32 gScreenWidth; -s32 gScreenHeight; +s32 gScreenWidth = SCREEN_WIDTH; +s32 gScreenHeight = SCREEN_HEIGHT; -OSViMode osViModeNtscLan1; +extern OSViMode osViModeNtscLan1; OSViMode osViModeMpalLan1; OSViMode osViModePalLan1; OSViMode osViModeFpalLan1; diff --git a/src/code/z_vismono.c b/src/code/z_vismono.cpp similarity index 61% rename from src/code/z_vismono.c rename to src/code/z_vismono.cpp index cddda96b2..5ca66b875 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.cpp @@ -7,31 +7,31 @@ #include "def/z_vismono.h" // (Note: 80 = SCREEN_HEIGHT/3, see VisMono_DrawTexture) -// This may not have been kept up-to-date with the code, 1+1+1+80*(7+2+2+3)+1+1 makes more sense +// pthis may not have been kept up-to-date with the code, 1+1+1+80*(7+2+2+3)+1+1 makes more sense #define DLSIZE (1 + 3 + 1 + 1 + 80 * (7 + 2 + 2 + 3) + 1) // framebuffer static u16 D_0F000000[SCREEN_HEIGHT * SCREEN_WIDTH * 4]; -void VisMono_Init(VisMono* this) { - bzero(this, sizeof(VisMono)); - this->unk_00 = 0; - this->setScissor = false; - this->primColor.r = 255; - this->primColor.g = 255; - this->primColor.b = 255; - this->primColor.a = 255; - this->envColor.r = 0; - this->envColor.g = 0; - this->envColor.b = 0; - this->envColor.a = 0; +void VisMono_Init(VisMono* pthis) { + bzero(pthis, sizeof(VisMono)); + pthis->unk_00 = 0; + pthis->setScissor = false; + pthis->primColor.r = 255; + pthis->primColor.g = 255; + pthis->primColor.b = 255; + pthis->primColor.a = 255; + pthis->envColor.r = 0; + pthis->envColor.g = 0; + pthis->envColor.b = 0; + pthis->envColor.a = 0; } -void VisMono_Destroy(VisMono* this) { - SystemArena_FreeDebug(this->monoDl, "../z_vismono.c", 137); +void VisMono_Destroy(VisMono* pthis) { + SystemArena_FreeDebug(pthis->monoDl, "../z_vismono.c", 137); } -void VisMono_UpdateTexture(VisMono* this, u16* tex) { +void VisMono_UpdateTexture(VisMono* pthis, u16* tex) { s32 i; for (i = 0; i < 256; i++) { @@ -40,7 +40,7 @@ void VisMono_UpdateTexture(VisMono* this, u16* tex) { } } -Gfx* VisMono_DrawTexture(VisMono* this, Gfx* gfx) { +Gfx* VisMono_DrawTexture(VisMono* pthis, Gfx* gfx) { s32 y; s32 height = 3; u16* tex = D_0F000000; @@ -76,35 +76,35 @@ Gfx* VisMono_DrawTexture(VisMono* this, Gfx* gfx) { return gfx; } -void VisMono_Draw(VisMono* this, Gfx** gfxp) { +void VisMono_Draw(VisMono* pthis, Gfx** gfxp) { Gfx* gfx = *gfxp; u16* tlut; Gfx* monoDL; Gfx* glistpEnd; - if (this->tlut) { - tlut = this->tlut; + if (pthis->tlut) { + tlut = pthis->tlut; } else { - tlut = Graph_DlistAlloc(&gfx, 256 * sizeof(u16)); - VisMono_UpdateTexture(this, tlut); + tlut = (u16*)Graph_DlistAlloc(&gfx, 256 * sizeof(u16)); + VisMono_UpdateTexture(pthis, tlut); } - if (this->monoDl) { - monoDL = this->monoDl; + if (pthis->monoDl) { + monoDL = pthis->monoDl; } else { - monoDL = Graph_DlistAlloc(&gfx, DLSIZE * sizeof(Gfx)); - glistpEnd = VisMono_DrawTexture(this, monoDL); + monoDL = (Gfx*)Graph_DlistAlloc(&gfx, DLSIZE * sizeof(Gfx)); + glistpEnd = VisMono_DrawTexture(pthis, monoDL); ASSERT(glistpEnd <= monoDL + DLSIZE, "glistp_end <= mono_dl + DLSIZE", "../z_vismono.c", 262); } gDPPipeSync(gfx++); - if (this->setScissor == true) { + if (pthis->setScissor == true) { gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } - gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); - gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + gDPSetColor(gfx++, G_SETPRIMCOLOR, pthis->primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, pthis->envColor.rgba); gDPLoadTLUT_pal256(gfx++, tlut); @@ -114,17 +114,17 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) { *gfxp = gfx; } -void VisMono_DrawOld(VisMono* this) { +void VisMono_DrawOld(VisMono* pthis) { Gfx* glistpEnd; - if (!this->tlut) { - this->tlut = SystemArena_MallocDebug(256 * sizeof(u16), "../z_vismono.c", 283); - VisMono_UpdateTexture(this, this->tlut); + if (!pthis->tlut) { + pthis->tlut = (u16*)SystemArena_MallocDebug(256 * sizeof(u16), "../z_vismono.c", 283); + VisMono_UpdateTexture(pthis, pthis->tlut); } - if (!this->monoDl) { - this->monoDl = SystemArena_MallocDebug(DLSIZE * sizeof(Gfx), "../z_vismono.c", 289); - glistpEnd = VisMono_DrawTexture(this, this->monoDl); - ASSERT(glistpEnd <= this->monoDl + DLSIZE, "glistp_end <= this->mono_dl + DLSIZE", "../z_vismono.c", 292); + if (!pthis->monoDl) { + pthis->monoDl = (Gfx*)SystemArena_MallocDebug(DLSIZE * sizeof(Gfx), "../z_vismono.c", 289); + glistpEnd = VisMono_DrawTexture(pthis, pthis->monoDl); + ASSERT(glistpEnd <= pthis->monoDl + DLSIZE, "glistp_end <= pthis->mono_dl + DLSIZE", "../z_vismono.c", 292); } } diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.cpp similarity index 86% rename from src/code/z_vr_box.c rename to src/code/z_vr_box.cpp index 1a7a63d73..946ffbbc2 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.cpp @@ -170,7 +170,7 @@ s32 func_800ADBB0(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s3 } for (phi_a2_4 = 0, sp424 = 0; sp424 < 2; sp424++) { - skyboxCtx->unk_138 = skyboxCtx->dListBuf[arg9 + sp424]; + skyboxCtx->unk_138 = &skyboxCtx->dListBuf[arg9 + sp424]; for (i = 0; i < 0x20; i++) { index = D_8012ACA0[sp424][i]; @@ -279,7 +279,7 @@ s32 func_800AE2C0(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s3 } break; } - skyboxCtx->unk_138 = &skyboxCtx->dListBuf[2 * lut_index]; + skyboxCtx->unk_138 = &skyboxCtx->dListBuf[2 * lut_index]; // TODO CHECK for (i = 0; i < 0x20; i++) { index = D_8012ADD8[i]; @@ -417,7 +417,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox } } - size = POINTER_SUB(gSkyboxFiles[skybox1Index].file.vromEnd, gSkyboxFiles[skybox1Index].file.vromStart); + size = (gSkyboxFiles[skybox1Index].file.vromEnd - gSkyboxFiles[skybox1Index].file.vromStart).size(); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1054); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1055); @@ -426,7 +426,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox 1058); //skyboxCtx->staticSegments[0] = gSkyboxFiles[skybox1Index].file.vromStart; - size = POINTER_SUB(gSkyboxFiles[skybox2Index].file.vromEnd, gSkyboxFiles[skybox2Index].file.vromStart); + size = (gSkyboxFiles[skybox2Index].file.vromEnd - gSkyboxFiles[skybox2Index].file.vromStart).size(); skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1060); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1061); @@ -436,9 +436,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox //skyboxCtx->staticSegments[1] = gSkyboxFiles[skybox2Index].file.vromStart; if ((skybox1Index & 1) ^ ((skybox1Index & 4) >> 2)) { - size = POINTER_SUB(gSkyboxFiles[skybox1Index].palette.vromEnd, gSkyboxFiles[skybox1Index].palette.vromStart); + size = (gSkyboxFiles[skybox1Index].palette.vromEnd - gSkyboxFiles[skybox1Index].palette.vromStart).size(); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1072); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1072); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1073); @@ -447,9 +447,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(POINTER_ADD(skyboxCtx->palettes, size), gSkyboxFiles[skybox2Index].palette.vromStart, size, "../z_vr_box.c", 1077); } else { - size = POINTER_SUB(gSkyboxFiles[skybox1Index].palette.vromEnd, gSkyboxFiles[skybox1Index].palette.vromStart); + size = (gSkyboxFiles[skybox1Index].palette.vromEnd - gSkyboxFiles[skybox1Index].palette.vromStart).size(); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1085); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1085); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1086); @@ -463,7 +463,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_BAZAAR: skyboxCtx->unk_140 = 1; - start = vr_SP1a_static; + start = (void*)vr_SP1a_static; size = sizeof(vr_SP1a_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1127); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -471,16 +471,16 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1129); - start = vr_SP1a_pal_static; + start = (void*)vr_SP1a_pal_static; size = sizeof(vr_SP1a_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1132); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1132); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1133); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1134); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_OVERCAST_SUNSET: - start = vr_cloud2_static; + start = (void*)vr_cloud2_static; size = sizeof(vr_cloud2_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1155); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -494,9 +494,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[1], start, size, "../z_vr_box.c", 1166); - start = vr_cloud2_pal_static; + start = (void*)vr_cloud2_pal_static; size = sizeof(vr_cloud2_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1170); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1170); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1171); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1173); @@ -505,7 +505,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_MARKET_ADULT: skyboxCtx->unk_140 = 1; - start = vr_RUVR_static; + start = (void*)vr_RUVR_static; size = sizeof(vr_RUVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1182); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -513,17 +513,17 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1184); - start = vr_RUVR_pal_static; + start = (void*)vr_RUVR_pal_static; size = sizeof(vr_RUVR_pal_static); osSyncPrintf("SIZE = %d\n", size); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1188); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1188); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1189); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1190); break; case SKYBOX_CUTSCENE_MAP: - start = vr_holy0_static; + start = (void*)vr_holy0_static; size = sizeof(vr_holy0_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1196); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -531,7 +531,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1200); - start = vr_holy1_static; + start = (void*)vr_holy1_static; size = sizeof(vr_holy1_static); skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1203); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", @@ -539,19 +539,19 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[1], start, size, "../z_vr_box.c", 1207); - start = vr_holy0_pal_static; + start = (void*)vr_holy0_pal_static; size = sizeof(vr_holy0_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1211); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1211); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1212); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1214); - DmaMgr_SendRequest1(POINTER_ADD(skyboxCtx->palettes, size), vr_holy1_pal_static, size, + DmaMgr_SendRequest1(POINTER_ADD(skyboxCtx->palettes, size), (u8*)vr_holy1_pal_static, size, "../z_vr_box.c", 1216); break; case SKYBOX_HOUSE_LINK: skyboxCtx->unk_140 = 1; - start = vr_LHVR_static; + start = (void*)vr_LHVR_static; size = sizeof(vr_LHVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1226); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -559,9 +559,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1228); - start = vr_LHVR_pal_static; + start = (void*)vr_LHVR_pal_static; size = sizeof(vr_LHVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1231); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1231); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1232); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1233); @@ -569,7 +569,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_MARKET_CHILD_DAY: skyboxCtx->unk_140 = 1; - start = vr_MDVR_static; + start = (void*)vr_MDVR_static; size = sizeof(vr_MDVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1257); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -577,9 +577,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1259); - start = vr_MDVR_pal_static; + start = (void*)vr_MDVR_pal_static; size = sizeof(vr_MDVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1262); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1262); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1263); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1264); @@ -587,7 +587,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_MARKET_CHILD_NIGHT: skyboxCtx->unk_140 = 1; - start = vr_MNVR_static; + start = (void*)vr_MNVR_static; size = sizeof(vr_MNVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1271); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -595,11 +595,11 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1273); - start = vr_MNVR_pal_static; + start = (void*)vr_MNVR_pal_static; size = sizeof(vr_MNVR_pal_static); osSyncPrintf("SIZE = %d\n", size); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1277); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1277); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1278); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1279); @@ -607,7 +607,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HAPPY_MASK_SHOP: skyboxCtx->unk_140 = 1; - start = vr_FCVR_static; + start = (void*)vr_FCVR_static; size = sizeof(vr_FCVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1286); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -615,9 +615,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1288); - start = vr_FCVR_pal_static; + start = (void*)vr_FCVR_pal_static; size = sizeof(vr_FCVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1291); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1291); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1292); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1293); @@ -626,7 +626,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS: skyboxCtx->unk_140 = 1; - start = vr_KHVR_static; + start = (void*)vr_KHVR_static; size = sizeof(vr_KHVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1301); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -634,9 +634,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1303); - start = vr_KHVR_pal_static; + start = (void*)vr_KHVR_pal_static; size = sizeof(vr_KHVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1306); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1306); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1307); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1308); @@ -644,7 +644,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_OF_TWINS: skyboxCtx->unk_140 = 2; - start = vr_K3VR_static; + start = (void*)vr_K3VR_static; size = sizeof(vr_K3VR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1331); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -652,9 +652,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1333); - start = vr_K3VR_pal_static; + start = (void*)vr_K3VR_pal_static; size = sizeof(vr_K3VR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1336); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1336); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1337); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1338); @@ -662,7 +662,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_STABLES: skyboxCtx->unk_140 = 1; - start = vr_MLVR_static; + start = (void*)vr_MLVR_static; size = sizeof(vr_MLVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1345); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -670,9 +670,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1347); - start = vr_MLVR_pal_static; + start = (void*)vr_MLVR_pal_static; size = sizeof(vr_MLVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1350); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1350); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1351); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1352); @@ -680,7 +680,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_KAKARIKO: skyboxCtx->unk_140 = 1; - start = vr_KKRVR_static; + start = (void*)vr_KKRVR_static; size = sizeof(vr_KKRVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1359); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -688,9 +688,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1361); - start = vr_KKRVR_pal_static; + start = (void*)vr_KKRVR_pal_static; size = sizeof(vr_KKRVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1364); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1364); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1365); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1366); @@ -698,7 +698,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_KOKIRI_SHOP: skyboxCtx->unk_140 = 1; - start = vr_KSVR_static; + start = (void*)vr_KSVR_static; size = sizeof(vr_KSVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1373); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -706,9 +706,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1375); - start = vr_KSVR_pal_static; + start = (void*)vr_KSVR_pal_static; size = sizeof(vr_KSVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1378); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1378); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1379); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1380); @@ -717,7 +717,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_GORON_SHOP: skyboxCtx->unk_140 = 1; - start = vr_GLVR_static; + start = (void*)vr_GLVR_static; size = sizeof(vr_GLVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1405); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -725,9 +725,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1407); - start = vr_GLVR_pal_static; + start = (void*)vr_GLVR_pal_static; size = sizeof(vr_GLVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1410); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1410); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1411); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1412); @@ -736,7 +736,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_ZORA_SHOP: skyboxCtx->unk_140 = 1; - start = vr_ZRVR_static; + start = (void*)vr_ZRVR_static; size = sizeof(vr_ZRVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1420); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -744,9 +744,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1422); - start = vr_ZRVR_pal_static; + start = (void*)vr_ZRVR_pal_static; size = sizeof(vr_ZRVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1425); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1425); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1426); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1427); @@ -755,7 +755,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_POTION_SHOP_KAKARIKO: skyboxCtx->unk_140 = 1; - start = vr_DGVR_static; + start = (void*)vr_DGVR_static; size = sizeof(vr_DGVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1451); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -763,9 +763,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1453); - start = vr_DGVR_pal_static; + start = (void*)vr_DGVR_pal_static; size = sizeof(vr_DGVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1456); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1456); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1457); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1458); @@ -774,7 +774,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_POTION_SHOP_MARKET: skyboxCtx->unk_140 = 1; - start = vr_ALVR_static; + start = (void*)vr_ALVR_static; size = sizeof(vr_ALVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1466); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -782,9 +782,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1468); - start = vr_ALVR_pal_static; + start = (void*)vr_ALVR_pal_static; size = sizeof(vr_ALVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1471); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1471); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1472); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1473); @@ -793,7 +793,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_BOMBCHU_SHOP: skyboxCtx->unk_140 = 1; - start = vr_NSVR_static; + start = (void*)vr_NSVR_static; size = sizeof(vr_NSVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1481); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -801,9 +801,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1483); - start = vr_NSVR_pal_static; + start = (void*)vr_NSVR_pal_static; size = sizeof(vr_NSVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1486); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1486); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1487); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1488); @@ -812,7 +812,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_RICHARD: skyboxCtx->unk_140 = 1; - start = vr_IPVR_static; + start = (void*)vr_IPVR_static; size = sizeof(vr_IPVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1512); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -820,9 +820,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1514); - start = vr_IPVR_pal_static; + start = (void*)vr_IPVR_pal_static; size = sizeof(vr_IPVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1517); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1517); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1518); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1519); @@ -830,7 +830,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_IMPA: skyboxCtx->unk_140 = 1; - start = vr_LBVR_static; + start = (void*)vr_LBVR_static; size = sizeof(vr_LBVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1526); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -838,9 +838,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1528); - start = vr_LBVR_pal_static; + start = (void*)vr_LBVR_pal_static; size = sizeof(vr_LBVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1531); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1531); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1532); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1533); @@ -848,7 +848,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_TENT: skyboxCtx->unk_140 = 2; - start = vr_TTVR_static; + start = (void*)vr_TTVR_static; size = sizeof(vr_TTVR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1540); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -856,9 +856,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1542); - start = vr_TTVR_pal_static; + start = (void*)vr_TTVR_pal_static; size = sizeof(vr_TTVR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1545); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1545); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1546); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1547); @@ -866,7 +866,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_MIDO: skyboxCtx->unk_140 = 2; - start = vr_K4VR_static; + start = (void*)vr_K4VR_static; size = sizeof(vr_K4VR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1560); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -874,9 +874,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1562); - start = vr_K4VR_pal_static; + start = (void*)vr_K4VR_pal_static; size = sizeof(vr_K4VR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1565); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1565); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1566); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1567); @@ -884,7 +884,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_SARIA: skyboxCtx->unk_140 = 2; - start = vr_K5VR_static; + start = (void*)vr_K5VR_static; size = sizeof(vr_K5VR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1574); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -892,9 +892,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1576); - start = vr_K5VR_pal_static; + start = (void*)vr_K5VR_pal_static; size = sizeof(vr_K5VR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1579); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1579); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1580); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1581); @@ -902,7 +902,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_HOUSE_ALLEY: skyboxCtx->unk_140 = 2; - start = vr_KR3VR_static; + start = (void*)vr_KR3VR_static; size = sizeof(vr_KR3VR_static); skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1588); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", @@ -910,9 +910,9 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1590); - start = vr_KR3VR_pal_static; + start = (void*)vr_KR3VR_pal_static; size = sizeof(vr_KR3VR_pal_static); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1593); + skyboxCtx->palettes = (u16*)GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1593); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1594); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1595); @@ -938,24 +938,24 @@ void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) { osSyncPrintf(VT_FGCOL(GREEN)); if (skyboxCtx->unk_140 != 0) { - skyboxCtx->dListBuf = GameState_Alloc(state, 8 * 150 * sizeof(Gfx), "../z_vr_box.c", 1636); + skyboxCtx->dListBuf = (Gfx*)GameState_Alloc(state, 8 * 150 * sizeof(Gfx), "../z_vr_box.c", 1636); ASSERT(skyboxCtx->dListBuf != NULL, "vr_box->dpList != NULL", "../z_vr_box.c", 1637); - skyboxCtx->roomVtx = GameState_Alloc(state, 256 * sizeof(Vtx), "../z_vr_box.c", 1639); + skyboxCtx->roomVtx = (Vtx*)GameState_Alloc(state, 256 * sizeof(Vtx), "../z_vr_box.c", 1639); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1640); func_800AEFC8(skyboxCtx, skyboxId); } else { - skyboxCtx->dListBuf = GameState_Alloc(state, 12 * 150 * sizeof(Gfx), "../z_vr_box.c", 1643); + skyboxCtx->dListBuf = (Gfx*)GameState_Alloc(state, 12 * 150 * sizeof(Gfx), "../z_vr_box.c", 1643); ASSERT(skyboxCtx->dListBuf != NULL, "vr_box->dpList != NULL", "../z_vr_box.c", 1644); if (skyboxId == SKYBOX_CUTSCENE_MAP) { - skyboxCtx->roomVtx = GameState_Alloc(state, 192 * sizeof(Vtx), "../z_vr_box.c", 1648); + skyboxCtx->roomVtx = (Vtx*)GameState_Alloc(state, 192 * sizeof(Vtx), "../z_vr_box.c", 1648); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1649); func_800AF178(skyboxCtx, 6); } else { - skyboxCtx->roomVtx = GameState_Alloc(state, 160 * sizeof(Vtx), "../z_vr_box.c", 1653); + skyboxCtx->roomVtx = (Vtx*)GameState_Alloc(state, 160 * sizeof(Vtx), "../z_vr_box.c", 1653); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1654); func_800AF178(skyboxCtx, 5); diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.cpp similarity index 66% rename from src/code/z_vr_box_draw.c rename to src/code/z_vr_box_draw.cpp index c918c6862..4792d7882 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.cpp @@ -31,7 +31,7 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 0, 0, 0, blend); gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON); - sSkyboxDrawMatrix = Graph_Alloc(gfxCtx, sizeof(Mtx)); + sSkyboxDrawMatrix = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); @@ -49,37 +49,37 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT); if (skyboxCtx->unk_140) { - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[1]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[0]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[1]); gDPPipeSync(POLY_OPA_DISP++); - gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[1]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[3]); + gDPLoadTLUT_pal256(POLY_OPA_DISP++, &skyboxCtx->palettes[1]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[2]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[3]); if (skyboxId != SKYBOX_BAZAAR) { if (skyboxId <= SKYBOX_HOUSE_KAKARIKO || skyboxId > SKYBOX_BOMBCHU_SHOP) { gDPPipeSync(POLY_OPA_DISP++); - gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[2]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[5]); + gDPLoadTLUT_pal256(POLY_OPA_DISP++, &skyboxCtx->palettes[2]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[4]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[5]); gDPPipeSync(POLY_OPA_DISP++); if (skyboxCtx->unk_140 != 2) { - gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[3]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[7]); + gDPLoadTLUT_pal256(POLY_OPA_DISP++, &skyboxCtx->palettes[3]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[6]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[7]); } } } } else { - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[8]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[0]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[2]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[4]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[6]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[8]); if (skyboxId == SKYBOX_CUTSCENE_MAP) { - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[10]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[10]); } } diff --git a/src/dmadata/dmadata.c b/src/dmadata/dmadata.cpp similarity index 82% rename from src/dmadata/dmadata.c rename to src/dmadata/dmadata.cpp index 3c7990b3c..333dcdf1c 100644 --- a/src/dmadata/dmadata.c +++ b/src/dmadata/dmadata.cpp @@ -13,7 +13,7 @@ // dmadata Table definition #define DEFINE_DMA_ENTRY(name) \ - { (uintptr_t)_##name##SegmentRomStart, (uintptr_t)_##name##SegmentRomEnd, (uintptr_t)_##name##SegmentRomStart, 0 }, + { (void*)_##name##SegmentRomStart, (void*)_##name##SegmentRomEnd, (void*)_##name##SegmentRomStart, 0 }, DmaEntry gDmaDataTable[] = { #include "tables/dmadata_table.h" diff --git a/src/elf_message/elf_message_field.c b/src/elf_message/elf_message_field.cpp similarity index 100% rename from src/elf_message/elf_message_field.c rename to src/elf_message/elf_message_field.cpp diff --git a/src/elf_message/elf_message_ydan.c b/src/elf_message/elf_message_ydan.cpp similarity index 100% rename from src/elf_message/elf_message_ydan.c rename to src/elf_message/elf_message_ydan.cpp diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.cpp similarity index 98% rename from src/libultra/gu/cosf.c rename to src/libultra/gu/cosf.cpp index d59c2d982..801bcc006 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.cpp @@ -1,7 +1,7 @@ #define INTERNAL_SRC_LIBULTRA_GU_COSF_C #include "ultra64.h" #include "global.h" -#include "def/cosf.h" + /* static const du P[] = { { 0x3FF00000, 0x00000000 }, { 0xBFC55554, 0xBC83656D }, { 0x3F8110ED, 0x3804C2A0 }, diff --git a/src/libultra/gu/coss.c b/src/libultra/gu/coss.cpp similarity index 100% rename from src/libultra/gu/coss.c rename to src/libultra/gu/coss.cpp diff --git a/src/libultra/gu/lookat.c b/src/libultra/gu/lookat.cpp similarity index 100% rename from src/libultra/gu/lookat.c rename to src/libultra/gu/lookat.cpp diff --git a/src/libultra/gu/lookathil.c b/src/libultra/gu/lookathil.cpp similarity index 100% rename from src/libultra/gu/lookathil.c rename to src/libultra/gu/lookathil.cpp diff --git a/src/libultra/gu/mtxf2l.c b/src/libultra/gu/mtxf2l.cpp similarity index 88% rename from src/libultra/gu/mtxf2l.c rename to src/libultra/gu/mtxf2l.cpp index 4a5085e5f..b26a01505 100644 --- a/src/libultra/gu/mtxf2l.c +++ b/src/libultra/gu/mtxf2l.cpp @@ -10,7 +10,7 @@ void guMtxF2L(MtxF* mf, Mtx* m) { } void guMtxL2F(MtxF* mf, Mtx* m) { - Matrix_MtxToMtxF(mf, m); + Matrix_MtxToMtxF(m, mf); } #else void guMtxF2L(float mf[4][4], Mtx* m) { @@ -33,9 +33,9 @@ void guMtxIdentF(float mf[4][4]) { void guMtxIdent(Mtx* m) { #ifndef GBI_FLOATS - float mf[4][4]; - guMtxIdentF(mf); - guMtxF2L(mf, m); + MtxF mf; + guMtxIdentF(mf.mf); + guMtxF2L(&mf, m); #else guMtxIdentF(m->m); #endif diff --git a/src/libultra/gu/normalize.c b/src/libultra/gu/normalize.cpp similarity index 100% rename from src/libultra/gu/normalize.c rename to src/libultra/gu/normalize.cpp diff --git a/src/libultra/gu/ortho.c b/src/libultra/gu/ortho.cpp similarity index 100% rename from src/libultra/gu/ortho.c rename to src/libultra/gu/ortho.cpp diff --git a/src/libultra/gu/perspective.c b/src/libultra/gu/perspective.cpp similarity index 94% rename from src/libultra/gu/perspective.c rename to src/libultra/gu/perspective.cpp index 059b7cac8..50ae9cd33 100644 --- a/src/libultra/gu/perspective.c +++ b/src/libultra/gu/perspective.cpp @@ -1,10 +1,11 @@ #define INTERNAL_SRC_LIBULTRA_GU_PERSPECTIVE_C #include "global.h" #include "ultra64/gu.h" -#include "def/cosf.h" +//#include "def/cosf.h" #include "def/mtxf2l.h" #include "def/perspective.h" -#include "def/sinf.h" +//#include "def/sinf.h" +#include void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale) { f32 yscale; diff --git a/src/libultra/gu/position.c b/src/libultra/gu/position.cpp similarity index 97% rename from src/libultra/gu/position.c rename to src/libultra/gu/position.cpp index 4307b24e3..1784274a0 100644 --- a/src/libultra/gu/position.c +++ b/src/libultra/gu/position.cpp @@ -1,9 +1,8 @@ #define INTERNAL_SRC_LIBULTRA_GU_POSITION_C #include "global.h" -#include "def/cosf.h" +#include #include "def/mtxf2l.h" #include "def/position.h" -#include "def/sinf.h" /** * guPositionF diff --git a/src/libultra/gu/rotate.c b/src/libultra/gu/rotate.cpp similarity index 95% rename from src/libultra/gu/rotate.c rename to src/libultra/gu/rotate.cpp index 98c6b162b..13422a273 100644 --- a/src/libultra/gu/rotate.c +++ b/src/libultra/gu/rotate.cpp @@ -1,10 +1,9 @@ #define INTERNAL_SRC_LIBULTRA_GU_ROTATE_C #include "global.h" -#include "def/cosf.h" +#include #include "def/mtxf2l.h" #include "def/normalize.h" #include "def/rotate.h" -#include "def/sinf.h" void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) { static f32 D_80134D10 = M_PI / 180.0f; diff --git a/src/libultra/gu/scale.c b/src/libultra/gu/scale.cpp similarity index 82% rename from src/libultra/gu/scale.c rename to src/libultra/gu/scale.cpp index 9b56448cb..bb9195c13 100644 --- a/src/libultra/gu/scale.c +++ b/src/libultra/gu/scale.cpp @@ -11,7 +11,7 @@ void guScaleF(float mf[4][4], float x, float y, float z) { mf[3][3] = 1.0; } void guScale(Mtx *m, float x, float y, float z) { - float mf[4][4]; - guScaleF(mf, x, y, z); - guMtxF2L(mf, m); + MtxF mf; + guScaleF(mf.mf, x, y, z); + guMtxF2L(&mf, m); } diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.cpp similarity index 98% rename from src/libultra/gu/sinf.c rename to src/libultra/gu/sinf.cpp index 38ba4f6f3..6b557bcf2 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.cpp @@ -1,7 +1,7 @@ #define INTERNAL_SRC_LIBULTRA_GU_SINF_C #include "global.h" #include "ultra64.h" -#include "def/sinf.h" + /* static const du P[] = { { 0x3FF00000, 0x00000000 }, { 0xBFC55554, 0xBC83656D }, { 0x3F8110ED, 0x3804C2A0 }, diff --git a/src/libultra/gu/sins.c b/src/libultra/gu/sins.cpp similarity index 93% rename from src/libultra/gu/sins.c rename to src/libultra/gu/sins.cpp index 76d62f44c..e3fb7f399 100644 --- a/src/libultra/gu/sins.c +++ b/src/libultra/gu/sins.cpp @@ -1,6 +1,6 @@ #define INTERNAL_SRC_LIBULTRA_GU_SINS_C #include "ultra64.h" -#include "sintable.c" +#include "sintable.cpp" #include "def/sins.h" s16 sins(u16 x) { diff --git a/src/libultra/gu/sintable.c b/src/libultra/gu/sintable.cpp similarity index 100% rename from src/libultra/gu/sintable.c rename to src/libultra/gu/sintable.cpp diff --git a/src/libultra/gu/sqrtf.c b/src/libultra/gu/sqrtf.cpp similarity index 100% rename from src/libultra/gu/sqrtf.c rename to src/libultra/gu/sqrtf.cpp diff --git a/src/libultra/gu/translate.c b/src/libultra/gu/translate.cpp similarity index 81% rename from src/libultra/gu/translate.c rename to src/libultra/gu/translate.cpp index 595c2a553..60f73d546 100644 --- a/src/libultra/gu/translate.c +++ b/src/libultra/gu/translate.cpp @@ -10,7 +10,7 @@ void guTranslateF(float m[4][4], float x, float y, float z) { m[3][2] = z; } void guTranslate(Mtx *m, float x, float y, float z) { - float mf[4][4]; - guTranslateF(mf, x, y, z); - guMtxF2L(mf, m); + MtxF mf; + guTranslateF(mf.mf, x, y, z); + guMtxF2L(&mf, m); } diff --git a/src/libultra/gu/us2dex.c b/src/libultra/gu/us2dex.cpp similarity index 100% rename from src/libultra/gu/us2dex.c rename to src/libultra/gu/us2dex.cpp diff --git a/src/libultra/io/aigetlen.c b/src/libultra/io/aigetlen.cpp similarity index 100% rename from src/libultra/io/aigetlen.c rename to src/libultra/io/aigetlen.cpp diff --git a/src/libultra/io/aisetfreq.c b/src/libultra/io/aisetfreq.cpp similarity index 100% rename from src/libultra/io/aisetfreq.c rename to src/libultra/io/aisetfreq.cpp diff --git a/src/libultra/io/aisetnextbuf.c b/src/libultra/io/aisetnextbuf.cpp similarity index 100% rename from src/libultra/io/aisetnextbuf.c rename to src/libultra/io/aisetnextbuf.cpp diff --git a/src/libultra/io/cartrominit.c b/src/libultra/io/cartrominit.cpp similarity index 100% rename from src/libultra/io/cartrominit.c rename to src/libultra/io/cartrominit.cpp diff --git a/src/libultra/io/contpfs.c b/src/libultra/io/contpfs.cpp similarity index 100% rename from src/libultra/io/contpfs.c rename to src/libultra/io/contpfs.cpp diff --git a/src/libultra/io/contquery.c b/src/libultra/io/contquery.cpp similarity index 100% rename from src/libultra/io/contquery.c rename to src/libultra/io/contquery.cpp diff --git a/src/libultra/io/contramread.c b/src/libultra/io/contramread.cpp similarity index 100% rename from src/libultra/io/contramread.c rename to src/libultra/io/contramread.cpp diff --git a/src/libultra/io/contramwrite.c b/src/libultra/io/contramwrite.cpp similarity index 100% rename from src/libultra/io/contramwrite.c rename to src/libultra/io/contramwrite.cpp diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.cpp similarity index 100% rename from src/libultra/io/contreaddata.c rename to src/libultra/io/contreaddata.cpp diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.cpp similarity index 100% rename from src/libultra/io/controller.c rename to src/libultra/io/controller.cpp diff --git a/src/libultra/io/contsetch.c b/src/libultra/io/contsetch.cpp similarity index 100% rename from src/libultra/io/contsetch.c rename to src/libultra/io/contsetch.cpp diff --git a/src/libultra/io/crc.c b/src/libultra/io/crc.cpp similarity index 100% rename from src/libultra/io/crc.c rename to src/libultra/io/crc.cpp diff --git a/src/libultra/io/devmgr.c b/src/libultra/io/devmgr.cpp similarity index 100% rename from src/libultra/io/devmgr.c rename to src/libultra/io/devmgr.cpp diff --git a/src/libultra/io/dpgetstat.c b/src/libultra/io/dpgetstat.cpp similarity index 100% rename from src/libultra/io/dpgetstat.c rename to src/libultra/io/dpgetstat.cpp diff --git a/src/libultra/io/dpsetstat.c b/src/libultra/io/dpsetstat.cpp similarity index 100% rename from src/libultra/io/dpsetstat.c rename to src/libultra/io/dpsetstat.cpp diff --git a/src/libultra/io/driverominit.c b/src/libultra/io/driverominit.cpp similarity index 100% rename from src/libultra/io/driverominit.c rename to src/libultra/io/driverominit.cpp diff --git a/src/libultra/io/epidma.c b/src/libultra/io/epidma.cpp similarity index 100% rename from src/libultra/io/epidma.c rename to src/libultra/io/epidma.cpp diff --git a/src/libultra/io/epirawdma.c b/src/libultra/io/epirawdma.cpp similarity index 100% rename from src/libultra/io/epirawdma.c rename to src/libultra/io/epirawdma.cpp diff --git a/src/libultra/io/epirawread.c b/src/libultra/io/epirawread.cpp similarity index 100% rename from src/libultra/io/epirawread.c rename to src/libultra/io/epirawread.cpp diff --git a/src/libultra/io/epiwrite.c b/src/libultra/io/epiwrite.cpp similarity index 100% rename from src/libultra/io/epiwrite.c rename to src/libultra/io/epiwrite.cpp diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.cpp similarity index 100% rename from src/libultra/io/motor.c rename to src/libultra/io/motor.cpp diff --git a/src/libultra/io/pfsallocatefile.c b/src/libultra/io/pfsallocatefile.cpp similarity index 100% rename from src/libultra/io/pfsallocatefile.c rename to src/libultra/io/pfsallocatefile.cpp diff --git a/src/libultra/io/pfschecker.c b/src/libultra/io/pfschecker.cpp similarity index 100% rename from src/libultra/io/pfschecker.c rename to src/libultra/io/pfschecker.cpp diff --git a/src/libultra/io/pfsdeletefile.c b/src/libultra/io/pfsdeletefile.cpp similarity index 100% rename from src/libultra/io/pfsdeletefile.c rename to src/libultra/io/pfsdeletefile.cpp diff --git a/src/libultra/io/pfsfilestate.c b/src/libultra/io/pfsfilestate.cpp similarity index 100% rename from src/libultra/io/pfsfilestate.c rename to src/libultra/io/pfsfilestate.cpp diff --git a/src/libultra/io/pfsfindfile.c b/src/libultra/io/pfsfindfile.cpp similarity index 100% rename from src/libultra/io/pfsfindfile.c rename to src/libultra/io/pfsfindfile.cpp diff --git a/src/libultra/io/pfsfreeblocks.c b/src/libultra/io/pfsfreeblocks.cpp similarity index 100% rename from src/libultra/io/pfsfreeblocks.c rename to src/libultra/io/pfsfreeblocks.cpp diff --git a/src/libultra/io/pfsgetstatus.c b/src/libultra/io/pfsgetstatus.cpp similarity index 100% rename from src/libultra/io/pfsgetstatus.c rename to src/libultra/io/pfsgetstatus.cpp diff --git a/src/libultra/io/pfsinitpak.c b/src/libultra/io/pfsinitpak.cpp similarity index 100% rename from src/libultra/io/pfsinitpak.c rename to src/libultra/io/pfsinitpak.cpp diff --git a/src/libultra/io/pfsisplug.c b/src/libultra/io/pfsisplug.cpp similarity index 100% rename from src/libultra/io/pfsisplug.c rename to src/libultra/io/pfsisplug.cpp diff --git a/src/libultra/io/pfsreadwritefile.c b/src/libultra/io/pfsreadwritefile.cpp similarity index 100% rename from src/libultra/io/pfsreadwritefile.c rename to src/libultra/io/pfsreadwritefile.cpp diff --git a/src/libultra/io/pfsselectbank.c b/src/libultra/io/pfsselectbank.cpp similarity index 100% rename from src/libultra/io/pfsselectbank.c rename to src/libultra/io/pfsselectbank.cpp diff --git a/src/libultra/io/piacs.c b/src/libultra/io/piacs.cpp similarity index 100% rename from src/libultra/io/piacs.c rename to src/libultra/io/piacs.cpp diff --git a/src/libultra/io/pigetcmdq.c b/src/libultra/io/pigetcmdq.cpp similarity index 100% rename from src/libultra/io/pigetcmdq.c rename to src/libultra/io/pigetcmdq.cpp diff --git a/src/libultra/io/pimgr.c b/src/libultra/io/pimgr.cpp similarity index 100% rename from src/libultra/io/pimgr.c rename to src/libultra/io/pimgr.cpp diff --git a/src/libultra/io/pirawdma.c b/src/libultra/io/pirawdma.cpp similarity index 100% rename from src/libultra/io/pirawdma.c rename to src/libultra/io/pirawdma.cpp diff --git a/src/libultra/io/si.c b/src/libultra/io/si.cpp similarity index 100% rename from src/libultra/io/si.c rename to src/libultra/io/si.cpp diff --git a/src/libultra/io/siacs.c b/src/libultra/io/siacs.cpp similarity index 100% rename from src/libultra/io/siacs.c rename to src/libultra/io/siacs.cpp diff --git a/src/libultra/io/sirawdma.c b/src/libultra/io/sirawdma.cpp similarity index 100% rename from src/libultra/io/sirawdma.c rename to src/libultra/io/sirawdma.cpp diff --git a/src/libultra/io/sirawread.c b/src/libultra/io/sirawread.cpp similarity index 100% rename from src/libultra/io/sirawread.c rename to src/libultra/io/sirawread.cpp diff --git a/src/libultra/io/sirawwrite.c b/src/libultra/io/sirawwrite.cpp similarity index 100% rename from src/libultra/io/sirawwrite.c rename to src/libultra/io/sirawwrite.cpp diff --git a/src/libultra/io/sp.c b/src/libultra/io/sp.cpp similarity index 100% rename from src/libultra/io/sp.c rename to src/libultra/io/sp.cpp diff --git a/src/libultra/io/spgetstat.c b/src/libultra/io/spgetstat.cpp similarity index 100% rename from src/libultra/io/spgetstat.c rename to src/libultra/io/spgetstat.cpp diff --git a/src/libultra/io/sprawdma.c b/src/libultra/io/sprawdma.cpp similarity index 100% rename from src/libultra/io/sprawdma.c rename to src/libultra/io/sprawdma.cpp diff --git a/src/libultra/io/spsetpc.c b/src/libultra/io/spsetpc.cpp similarity index 100% rename from src/libultra/io/spsetpc.c rename to src/libultra/io/spsetpc.cpp diff --git a/src/libultra/io/spsetstat.c b/src/libultra/io/spsetstat.cpp similarity index 100% rename from src/libultra/io/spsetstat.c rename to src/libultra/io/spsetstat.cpp diff --git a/src/libultra/io/sptask.c b/src/libultra/io/sptask.cpp similarity index 100% rename from src/libultra/io/sptask.c rename to src/libultra/io/sptask.cpp diff --git a/src/libultra/io/sptaskyield.c b/src/libultra/io/sptaskyield.cpp similarity index 100% rename from src/libultra/io/sptaskyield.c rename to src/libultra/io/sptaskyield.cpp diff --git a/src/libultra/io/sptaskyielded.c b/src/libultra/io/sptaskyielded.cpp similarity index 100% rename from src/libultra/io/sptaskyielded.c rename to src/libultra/io/sptaskyielded.cpp diff --git a/src/libultra/io/vi.c b/src/libultra/io/vi.cpp similarity index 100% rename from src/libultra/io/vi.c rename to src/libultra/io/vi.cpp diff --git a/src/libultra/io/viblack.c b/src/libultra/io/viblack.cpp similarity index 100% rename from src/libultra/io/viblack.c rename to src/libultra/io/viblack.cpp diff --git a/src/libultra/io/viextend.c b/src/libultra/io/viextend.cpp similarity index 100% rename from src/libultra/io/viextend.c rename to src/libultra/io/viextend.cpp diff --git a/src/libultra/io/vigetcurrcontext.c b/src/libultra/io/vigetcurrcontext.cpp similarity index 100% rename from src/libultra/io/vigetcurrcontext.c rename to src/libultra/io/vigetcurrcontext.cpp diff --git a/src/libultra/io/vigetcurrframebuf.c b/src/libultra/io/vigetcurrframebuf.cpp similarity index 100% rename from src/libultra/io/vigetcurrframebuf.c rename to src/libultra/io/vigetcurrframebuf.cpp diff --git a/src/libultra/io/vigetnextframebuf.c b/src/libultra/io/vigetnextframebuf.cpp similarity index 100% rename from src/libultra/io/vigetnextframebuf.c rename to src/libultra/io/vigetnextframebuf.cpp diff --git a/src/libultra/io/vimgr.c b/src/libultra/io/vimgr.cpp similarity index 100% rename from src/libultra/io/vimgr.c rename to src/libultra/io/vimgr.cpp diff --git a/src/libultra/io/vimodefpallan1.c b/src/libultra/io/vimodefpallan1.cpp similarity index 100% rename from src/libultra/io/vimodefpallan1.c rename to src/libultra/io/vimodefpallan1.cpp diff --git a/src/libultra/io/vimodempallan1.c b/src/libultra/io/vimodempallan1.cpp similarity index 100% rename from src/libultra/io/vimodempallan1.c rename to src/libultra/io/vimodempallan1.cpp diff --git a/src/libultra/io/vimodentsclan1.c b/src/libultra/io/vimodentsclan1.cpp similarity index 100% rename from src/libultra/io/vimodentsclan1.c rename to src/libultra/io/vimodentsclan1.cpp diff --git a/src/libultra/io/vimodepallan1.c b/src/libultra/io/vimodepallan1.cpp similarity index 100% rename from src/libultra/io/vimodepallan1.c rename to src/libultra/io/vimodepallan1.cpp diff --git a/src/libultra/io/visetevent.c b/src/libultra/io/visetevent.cpp similarity index 100% rename from src/libultra/io/visetevent.c rename to src/libultra/io/visetevent.cpp diff --git a/src/libultra/io/visetmode.c b/src/libultra/io/visetmode.cpp similarity index 100% rename from src/libultra/io/visetmode.c rename to src/libultra/io/visetmode.cpp diff --git a/src/libultra/io/visetspecial.c b/src/libultra/io/visetspecial.cpp similarity index 100% rename from src/libultra/io/visetspecial.c rename to src/libultra/io/visetspecial.cpp diff --git a/src/libultra/io/visetxscale.c b/src/libultra/io/visetxscale.cpp similarity index 100% rename from src/libultra/io/visetxscale.c rename to src/libultra/io/visetxscale.cpp diff --git a/src/libultra/io/visetyscale.c b/src/libultra/io/visetyscale.cpp similarity index 100% rename from src/libultra/io/visetyscale.c rename to src/libultra/io/visetyscale.cpp diff --git a/src/libultra/io/viswapbuf.c b/src/libultra/io/viswapbuf.cpp similarity index 100% rename from src/libultra/io/viswapbuf.c rename to src/libultra/io/viswapbuf.cpp diff --git a/src/libultra/io/viswapcontext.c b/src/libultra/io/viswapcontext.cpp similarity index 100% rename from src/libultra/io/viswapcontext.c rename to src/libultra/io/viswapcontext.cpp diff --git a/src/libultra/rmon/sprintf.c b/src/libultra/rmon/sprintf.cpp similarity index 100% rename from src/libultra/rmon/sprintf.c rename to src/libultra/rmon/sprintf.cpp diff --git a/src/libultra/rmon/xldtob.c b/src/libultra/rmon/xldtob.cpp similarity index 99% rename from src/libultra/rmon/xldtob.c rename to src/libultra/rmon/xldtob.cpp index af061af37..faa9d9c1a 100644 --- a/src/libultra/rmon/xldtob.c +++ b/src/libultra/rmon/xldtob.cpp @@ -2,8 +2,9 @@ #include "global.h" #include #include "ultra64/printf.h" -#include "def/string.h" +//#include "def/string.h" #include "def/xldtob.h" +#include #define BUFF_LEN 0x20 diff --git a/src/libultra/rmon/xlitob.c b/src/libultra/rmon/xlitob.cpp similarity index 98% rename from src/libultra/rmon/xlitob.c rename to src/libultra/rmon/xlitob.cpp index cb64e386b..f0f0a65c0 100644 --- a/src/libultra/rmon/xlitob.c +++ b/src/libultra/rmon/xlitob.cpp @@ -3,7 +3,7 @@ #include "ultra64/printf.h" #include #include -#include "def/string.h" +#include #include "def/xlitob.h" #define BUFF_LEN 0x18 diff --git a/src/libultra/rmon/xprintf.c b/src/libultra/rmon/xprintf.cpp similarity index 99% rename from src/libultra/rmon/xprintf.c rename to src/libultra/rmon/xprintf.cpp index 5c58474a1..91a44a595 100644 --- a/src/libultra/rmon/xprintf.c +++ b/src/libultra/rmon/xprintf.cpp @@ -205,7 +205,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { break; case 'p': - px->v.ll = va_arg(*pap, void*); + px->v.ll = (s64)va_arg(*pap, void*); px->s = (char*)&ac[px->n0]; _Litob(px, 'x'); break; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.cpp similarity index 53% rename from src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c rename to src/overlays/actors/ovl_Arms_Hook/z_arms_hook.cpp index 108ddd846..f13609c6f 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.cpp @@ -16,15 +16,15 @@ #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) -void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx); -void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx); -void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArmsHook_Init(Actor* pthisx, GlobalContext* globalCtx); +void ArmsHook_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void ArmsHook_Update(Actor* pthisx, GlobalContext* globalCtx); +void ArmsHook_Draw(Actor* pthisx, GlobalContext* globalCtx); -void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx); -void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx); +void ArmsHook_Wait(ArmsHook* pthis, GlobalContext* globalCtx); +void ArmsHook_Shoot(ArmsHook* pthis, GlobalContext* globalCtx); -const ActorInit Arms_Hook_InitVars = { +ActorInit Arms_Hook_InitVars = { ACTOR_ARMS_HOOK, ACTORCAT_ITEMACTION, FLAGS, @@ -71,86 +71,86 @@ static Vec3f D_80865B94 = { 0.0f, -500.0f, -3000.0f }; static Vec3f D_80865BA0 = { 0.0f, 500.0f, 1200.0f }; static Vec3f D_80865BAC = { 0.0f, -500.0f, 1200.0f }; -void ArmsHook_SetupAction(ArmsHook* this, ArmsHookActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ArmsHook_SetupAction(ArmsHook* pthis, ArmsHookActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx) { - ArmsHook* this = (ArmsHook*)thisx; +void ArmsHook_Init(Actor* pthisx, GlobalContext* globalCtx) { + ArmsHook* pthis = (ArmsHook*)pthisx; - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); - ArmsHook_SetupAction(this, ArmsHook_Wait); - this->unk_1E8 = this->actor.world.pos; + Collider_InitQuad(globalCtx, &pthis->collider); + Collider_SetQuad(globalCtx, &pthis->collider, &pthis->actor, &sQuadInit); + ArmsHook_SetupAction(pthis, ArmsHook_Wait); + pthis->unk_1E8 = pthis->actor.world.pos; } -void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ArmsHook* this = (ArmsHook*)thisx; +void ArmsHook_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + ArmsHook* pthis = (ArmsHook*)pthisx; - if (this->grabbed != NULL) { - this->grabbed->flags &= ~ACTOR_FLAG_13; + if (pthis->grabbed != NULL) { + pthis->grabbed->flags &= ~ACTOR_FLAG_13; } - Collider_DestroyQuad(globalCtx, &this->collider); + Collider_DestroyQuad(globalCtx, &pthis->collider); } -void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) { - if (this->actor.parent == NULL) { +void ArmsHook_Wait(ArmsHook* pthis, GlobalContext* globalCtx) { + if (pthis->actor.parent == NULL) { Player* player = GET_PLAYER(globalCtx); // get correct timer length for hookshot or longshot s32 length = (player->heldItemActionParam == PLAYER_AP_HOOKSHOT) ? 13 : 26; - ArmsHook_SetupAction(this, ArmsHook_Shoot); - func_8002D9A4(&this->actor, 20.0f); - this->actor.parent = &GET_PLAYER(globalCtx)->actor; - this->timer = length; + ArmsHook_SetupAction(pthis, ArmsHook_Shoot); + func_8002D9A4(&pthis->actor, 20.0f); + pthis->actor.parent = &GET_PLAYER(globalCtx)->actor; + pthis->timer = length; } } -void func_80865044(ArmsHook* this) { - this->actor.child = this->actor.parent; - this->actor.parent->parent = &this->actor; +void func_80865044(ArmsHook* pthis) { + pthis->actor.child = pthis->actor.parent; + pthis->actor.parent->parent = &pthis->actor; } -s32 ArmsHook_AttachToPlayer(ArmsHook* this, Player* player) { - player->actor.child = &this->actor; - player->heldActor = &this->actor; - if (this->actor.child != NULL) { +s32 ArmsHook_AttachToPlayer(ArmsHook* pthis, Player* player) { + player->actor.child = &pthis->actor; + player->heldActor = &pthis->actor; + if (pthis->actor.child != NULL) { player->actor.parent = NULL; - this->actor.child = NULL; + pthis->actor.child = NULL; return true; } return false; } -void ArmsHook_DetachHookFromActor(ArmsHook* this) { - if (this->grabbed != NULL) { - this->grabbed->flags &= ~ACTOR_FLAG_13; - this->grabbed = NULL; +void ArmsHook_DetachHookFromActor(ArmsHook* pthis) { + if (pthis->grabbed != NULL) { + pthis->grabbed->flags &= ~ACTOR_FLAG_13; + pthis->grabbed = NULL; } } -s32 ArmsHook_CheckForCancel(ArmsHook* this) { - Player* player = (Player*)this->actor.parent; +s32 ArmsHook_CheckForCancel(ArmsHook* pthis) { + Player* player = (Player*)pthis->actor.parent; if (Player_HoldsHookshot(player)) { if ((player->itemActionParam != player->heldItemActionParam) || (player->actor.flags & ACTOR_FLAG_8) || ((player->stateFlags1 & 0x4000080))) { - this->timer = 0; - ArmsHook_DetachHookFromActor(this); - Math_Vec3f_Copy(&this->actor.world.pos, &player->unk_3C8); + pthis->timer = 0; + ArmsHook_DetachHookFromActor(pthis); + Math_Vec3f_Copy(&pthis->actor.world.pos, &player->unk_3C8); return 1; } } return 0; } -void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { +void ArmsHook_AttachHookToActor(ArmsHook* pthis, Actor* actor) { actor->flags |= ACTOR_FLAG_13; - this->grabbed = actor; - Math_Vec3f_Diff(&actor->world.pos, &this->actor.world.pos, &this->grabbedDistDiff); + pthis->grabbed = actor; + Math_Vec3f_Diff(&actor->world.pos, &pthis->actor.world.pos, &pthis->grabbedDistDiff); } -void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { +void ArmsHook_Shoot(ArmsHook* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Actor* touchedActor; Actor* grabbed; @@ -172,52 +172,52 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { f32 velocity; s32 pad1; - if ((this->actor.parent == NULL) || (!Player_HoldsHookshot(player))) { - ArmsHook_DetachHookFromActor(this); - Actor_Kill(&this->actor); + if ((pthis->actor.parent == NULL) || (!Player_HoldsHookshot(player))) { + ArmsHook_DetachHookFromActor(pthis); + Actor_Kill(&pthis->actor); return; } func_8002F8F0(&player->actor, NA_SE_IT_HOOKSHOT_CHAIN - SFX_FLAG); - ArmsHook_CheckForCancel(this); + ArmsHook_CheckForCancel(pthis); - if ((this->timer != 0) && (this->collider.base.atFlags & AT_HIT) && - (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { - touchedActor = this->collider.base.at; + if ((pthis->timer != 0) && (pthis->collider.base.atFlags & AT_HIT) && + (pthis->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { + touchedActor = pthis->collider.base.at; if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_9 | ACTOR_FLAG_10))) { - if (this->collider.info.atHitInfo->bumperFlags & BUMP_HOOKABLE) { - ArmsHook_AttachHookToActor(this, touchedActor); + if (pthis->collider.info.atHitInfo->bumperFlags & BUMP_HOOKABLE) { + ArmsHook_AttachHookToActor(pthis, touchedActor); if (CHECK_FLAG_ALL(touchedActor->flags, ACTOR_FLAG_10)) { - func_80865044(this); + func_80865044(pthis); } } } - this->timer = 0; - Audio_PlaySoundGeneral(NA_SE_IT_ARROW_STICK_CRE, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + pthis->timer = 0; + Audio_PlaySoundGeneral(NA_SE_IT_ARROW_STICK_CRE, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (DECR(this->timer) == 0) { - grabbed = this->grabbed; + } else if (DECR(pthis->timer) == 0) { + grabbed = pthis->grabbed; if (grabbed != NULL) { if ((grabbed->update == NULL) || !CHECK_FLAG_ALL(grabbed->flags, ACTOR_FLAG_13)) { grabbed = NULL; - this->grabbed = NULL; - } else if (this->actor.child != NULL) { - sp94 = Actor_WorldDistXYZToActor(&this->actor, grabbed); - sp90 = sqrtf(SQ(this->grabbedDistDiff.x) + SQ(this->grabbedDistDiff.y) + SQ(this->grabbedDistDiff.z)); - Math_Vec3f_Diff(&grabbed->world.pos, &this->grabbedDistDiff, &this->actor.world.pos); + pthis->grabbed = NULL; + } else if (pthis->actor.child != NULL) { + sp94 = Actor_WorldDistXYZToActor(&pthis->actor, grabbed); + sp90 = sqrtf(SQ(pthis->grabbedDistDiff.x) + SQ(pthis->grabbedDistDiff.y) + SQ(pthis->grabbedDistDiff.z)); + Math_Vec3f_Diff(&grabbed->world.pos, &pthis->grabbedDistDiff, &pthis->actor.world.pos); if (50.0f < (sp94 - sp90)) { - ArmsHook_DetachHookFromActor(this); + ArmsHook_DetachHookFromActor(pthis); grabbed = NULL; } } } - bodyDistDiff = Math_Vec3f_DistXYZAndStoreDiff(&player->unk_3C8, &this->actor.world.pos, &bodyDistDiffVec); + bodyDistDiff = Math_Vec3f_DistXYZAndStoreDiff(&player->unk_3C8, &pthis->actor.world.pos, &bodyDistDiffVec); if (bodyDistDiff < 30.0f) { velocity = 0.0f; phi_f16 = 0.0f; } else { - if (this->actor.child != NULL) { + if (pthis->actor.child != NULL) { velocity = 30.0f; } else if (grabbed != NULL) { velocity = 50.0f; @@ -235,14 +235,14 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { newPos.y = bodyDistDiffVec.y * velocity; newPos.z = bodyDistDiffVec.z * velocity; - if (this->actor.child == NULL) { + if (pthis->actor.child == NULL) { if ((grabbed != NULL) && (grabbed->id == ACTOR_BG_SPOT06_OBJECTS)) { - Math_Vec3f_Diff(&grabbed->world.pos, &this->grabbedDistDiff, &this->actor.world.pos); + Math_Vec3f_Diff(&grabbed->world.pos, &pthis->grabbedDistDiff, &pthis->actor.world.pos); phi_f16 = 1.0f; } else { - Math_Vec3f_Sum(&player->unk_3C8, &newPos, &this->actor.world.pos); + Math_Vec3f_Sum(&player->unk_3C8, &newPos, &pthis->actor.world.pos); if (grabbed != NULL) { - Math_Vec3f_Sum(&this->actor.world.pos, &this->grabbedDistDiff, &grabbed->world.pos); + Math_Vec3f_Sum(&pthis->actor.world.pos, &pthis->grabbedDistDiff, &grabbed->world.pos); } } } else { @@ -252,64 +252,64 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } if (phi_f16 < 50.0f) { - ArmsHook_DetachHookFromActor(this); + ArmsHook_DetachHookFromActor(pthis); if (phi_f16 == 0.0f) { - ArmsHook_SetupAction(this, ArmsHook_Wait); - if (ArmsHook_AttachToPlayer(this, player)) { - Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &player->actor.velocity); + ArmsHook_SetupAction(pthis, ArmsHook_Wait); + if (ArmsHook_AttachToPlayer(pthis, player)) { + Math_Vec3f_Diff(&pthis->actor.world.pos, &player->actor.world.pos, &player->actor.velocity); player->actor.velocity.y -= 20.0f; } } } } else { - Actor_MoveForward(&this->actor); - Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff); - Math_Vec3f_Sum(&this->unk_1E8, &prevFrameDiff, &this->unk_1E8); - this->actor.shape.rot.x = Math_Atan2S(this->actor.speedXZ, -this->actor.velocity.y); - sp60.x = this->unk_1F4.x - (this->unk_1E8.x - this->unk_1F4.x); - sp60.y = this->unk_1F4.y - (this->unk_1E8.y - this->unk_1F4.y); - sp60.z = this->unk_1F4.z - (this->unk_1E8.z - this->unk_1F4.z); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &this->unk_1E8, &sp78, &poly, true, true, true, true, + Actor_MoveForward(&pthis->actor); + Math_Vec3f_Diff(&pthis->actor.world.pos, &pthis->actor.prevPos, &prevFrameDiff); + Math_Vec3f_Sum(&pthis->unk_1E8, &prevFrameDiff, &pthis->unk_1E8); + pthis->actor.shape.rot.x = Math_Atan2S(pthis->actor.speedXZ, -pthis->actor.velocity.y); + sp60.x = pthis->unk_1F4.x - (pthis->unk_1E8.x - pthis->unk_1F4.x); + sp60.y = pthis->unk_1F4.y - (pthis->unk_1E8.y - pthis->unk_1F4.y); + sp60.z = pthis->unk_1F4.z - (pthis->unk_1E8.z - pthis->unk_1F4.z); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &pthis->unk_1E8, &sp78, &poly, true, true, true, true, &bgId) && - !func_8002F9EC(globalCtx, &this->actor, poly, bgId, &sp78)) { + !func_8002F9EC(globalCtx, &pthis->actor, poly, bgId, &sp78)) { sp5C = COLPOLY_GET_NORMAL(poly->normal.x); sp58 = COLPOLY_GET_NORMAL(poly->normal.z); - Math_Vec3f_Copy(&this->actor.world.pos, &sp78); - this->actor.world.pos.x += 10.0f * sp5C; - this->actor.world.pos.z += 10.0f * sp58; - this->timer = 0; + Math_Vec3f_Copy(&pthis->actor.world.pos, &sp78); + pthis->actor.world.pos.x += 10.0f * sp5C; + pthis->actor.world.pos.z += 10.0f * sp58; + pthis->timer = 0; if (SurfaceType_IsHookshotSurface(&globalCtx->colCtx, poly, bgId)) { if (bgId != BGCHECK_SCENE) { dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); if (dynaPolyActor != NULL) { - ArmsHook_AttachHookToActor(this, &dynaPolyActor->actor); + ArmsHook_AttachHookToActor(pthis, &dynaPolyActor->actor); } } - func_80865044(this); - Audio_PlaySoundGeneral(NA_SE_IT_HOOKSHOT_STICK_OBJ, &this->actor.projectedPos, 4, &D_801333E0, + func_80865044(pthis); + Audio_PlaySoundGeneral(NA_SE_IT_HOOKSHOT_STICK_OBJ, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &this->actor.world.pos); - Audio_PlaySoundGeneral(NA_SE_IT_HOOKSHOT_REFLECT, &this->actor.projectedPos, 4, &D_801333E0, + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &pthis->actor.world.pos); + Audio_PlaySoundGeneral(NA_SE_IT_HOOKSHOT_REFLECT, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } else if (CHECK_BTN_ANY(globalCtx->state.input[0].press.button, (BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN))) { - this->timer = 0; + pthis->timer = 0; } } } -void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx) { - ArmsHook* this = (ArmsHook*)thisx; +void ArmsHook_Update(Actor* pthisx, GlobalContext* globalCtx) { + ArmsHook* pthis = (ArmsHook*)pthisx; - this->actionFunc(this, globalCtx); - this->unk_1F4 = this->unk_1E8; + pthis->actionFunc(pthis, globalCtx); + pthis->unk_1F4 = pthis->unk_1E8; } -void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ArmsHook_Draw(Actor* pthisx, GlobalContext* globalCtx) { s32 pad; - ArmsHook* this = (ArmsHook*)thisx; + ArmsHook* pthis = (ArmsHook*)pthisx; Player* player = GET_PLAYER(globalCtx); Vec3f sp78; Vec3f sp6C; @@ -320,24 +320,24 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { if ((player->actor.draw != NULL) && (player->rightHandType == 15)) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arms_hook.c", 850); - if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { - Matrix_MultVec3f(&D_80865B70, &this->unk_1E8); + if ((ArmsHook_Shoot != pthis->actionFunc) || (pthis->timer <= 0)) { + Matrix_MultVec3f(&D_80865B70, &pthis->unk_1E8); Matrix_MultVec3f(&D_80865B88, &sp6C); Matrix_MultVec3f(&D_80865B94, &sp60); - this->hookInfo.active = 0; + pthis->hookInfo.active = 0; } else { - Matrix_MultVec3f(&D_80865B7C, &this->unk_1E8); + Matrix_MultVec3f(&D_80865B7C, &pthis->unk_1E8); Matrix_MultVec3f(&D_80865BA0, &sp6C); Matrix_MultVec3f(&D_80865BAC, &sp60); } - func_80090480(globalCtx, &this->collider, &this->hookInfo, &sp6C, &sp60); + func_80090480(globalCtx, &pthis->collider, &pthis->hookInfo, &sp6C, &sp60); func_80093D18(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_arms_hook.c", 895), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gLinkAdultHookshotTipDL); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Math_Vec3f_Diff(&player->unk_3C8, &this->actor.world.pos, &sp78); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Math_Vec3f_Diff(&player->unk_3C8, &pthis->actor.world.pos, &sp78); sp58 = SQ(sp78.x) + SQ(sp78.z); sp5C = sqrtf(sp58); Matrix_RotateY(Math_FAtan2F(sp78.x, sp78.z), MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.cpp similarity index 52% rename from src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c rename to src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.cpp index cc7b7e364..3f641dfdb 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.cpp @@ -11,16 +11,16 @@ #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_25) -void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx); -void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx); -void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArrowFire_Init(Actor* pthisx, GlobalContext* globalCtx); +void ArrowFire_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void ArrowFire_Update(Actor* pthisx, GlobalContext* globalCtx); +void ArrowFire_Draw(Actor* pthisx, GlobalContext* globalCtx); -void ArrowFire_Charge(ArrowFire* this, GlobalContext* globalCtx); -void ArrowFire_Fly(ArrowFire* this, GlobalContext* globalCtx); -void ArrowFire_Hit(ArrowFire* this, GlobalContext* globalCtx); +void ArrowFire_Charge(ArrowFire* pthis, GlobalContext* globalCtx); +void ArrowFire_Fly(ArrowFire* pthis, GlobalContext* globalCtx); +void ArrowFire_Hit(ArrowFire* pthis, GlobalContext* globalCtx); -#include "overlays/ovl_Arrow_Fire/ovl_Arrow_Fire.c" +#include "overlays/ovl_Arrow_Fire/ovl_Arrow_Fire.cpp" #include "def/sys_matrix.h" #include "def/z_actor.h" #include "def/z_lib.h" @@ -28,7 +28,7 @@ void ArrowFire_Hit(ArrowFire* this, GlobalContext* globalCtx); #include "def/z_rcp.h" #include "def/graph.h" // FORCE -const ActorInit Arrow_Fire_InitVars = { +ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, ACTORCAT_ITEMACTION, FLAGS, @@ -44,52 +44,52 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ArrowFire_SetupAction(ArrowFire* pthis, ArrowFireActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { - ArrowFire* this = (ArrowFire*)thisx; +void ArrowFire_Init(Actor* pthisx, GlobalContext* globalCtx) { + ArrowFire* pthis = (ArrowFire*)pthisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->radius = 0; - this->unk_158 = 1.0f; - ArrowFire_SetupAction(this, ArrowFire_Charge); - Actor_SetScale(&this->actor, 0.01f); - this->alpha = 160; - this->timer = 0; - this->unk_15C = 0.0f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->radius = 0; + pthis->unk_158 = 1.0f; + ArrowFire_SetupAction(pthis, ArrowFire_Charge); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->alpha = 160; + pthis->timer = 0; + pthis->unk_15C = 0.0f; } -void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ArrowFire_Destroy(Actor* pthisx, GlobalContext* globalCtx) { func_800876C8(globalCtx); LOG_STRING("消滅", "../z_arrow_fire.c", 421); // "Disappearance" } -void ArrowFire_Charge(ArrowFire* this, GlobalContext* globalCtx) { +void ArrowFire_Charge(ArrowFire* pthis, GlobalContext* globalCtx) { EnArrow* arrow; - arrow = (EnArrow*)this->actor.parent; + arrow = (EnArrow*)pthis->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->radius < 10) { - this->radius += 1; + if (pthis->radius < 10) { + pthis->radius += 1; } // copy position and rotation from arrow - this->actor.world.pos = arrow->actor.world.pos; - this->actor.shape.rot = arrow->actor.shape.rot; + pthis->actor.world.pos = arrow->actor.world.pos; + pthis->actor.shape.rot = arrow->actor.shape.rot; - func_8002F974(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG); + func_8002F974(&pthis->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG); // if arrow has no parent, player has fired the arrow if (arrow->actor.parent == NULL) { - this->unkPos = this->actor.world.pos; - this->radius = 10; - ArrowFire_SetupAction(this, ArrowFire_Fly); - this->alpha = 255; + pthis->unkPos = pthis->actor.world.pos; + pthis->radius = 10; + ArrowFire_SetupAction(pthis, ArrowFire_Fly); + pthis->alpha = 255; } } @@ -99,117 +99,117 @@ void func_80865ECC(Vec3f* unkPos, Vec3f* firePos, f32 scale) { unkPos->z += ((firePos->z - unkPos->z) * scale); } -void ArrowFire_Hit(ArrowFire* this, GlobalContext* globalCtx) { +void ArrowFire_Hit(ArrowFire* pthis, GlobalContext* globalCtx) { f32 scale; f32 offset; u16 timer; - if (this->actor.projectedW < 50.0f) { + if (pthis->actor.projectedW < 50.0f) { scale = 10.0f; } else { - if (950.0f < this->actor.projectedW) { + if (950.0f < pthis->actor.projectedW) { scale = 310.0f; } else { - scale = this->actor.projectedW; + scale = pthis->actor.projectedW; scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; } } - timer = this->timer; + timer = pthis->timer; if (timer != 0) { - this->timer -= 1; + pthis->timer -= 1; - if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + if (pthis->timer >= 8) { + offset = ((pthis->timer - 8) * (1.0f / 24.0f)); offset = SQ(offset); - this->radius = (((1.0f - offset) * scale) + 10.0f); - this->unk_158 += ((2.0f - this->unk_158) * 0.1f); - if (this->timer < 16) { + pthis->radius = (((1.0f - offset) * scale) + 10.0f); + pthis->unk_158 += ((2.0f - pthis->unk_158) * 0.1f); + if (pthis->timer < 16) { if (1) {} - this->alpha = ((this->timer * 0x23) - 0x118); + pthis->alpha = ((pthis->timer * 0x23) - 0x118); } } } - if (this->timer >= 9) { - if (this->unk_15C < 1.0f) { - this->unk_15C += 0.25f; + if (pthis->timer >= 9) { + if (pthis->unk_15C < 1.0f) { + pthis->unk_15C += 0.25f; } } else { - if (this->unk_15C > 0.0f) { - this->unk_15C -= 0.125f; + if (pthis->unk_15C > 0.0f) { + pthis->unk_15C -= 0.125f; } } - if (this->timer < 8) { - this->alpha = 0; + if (pthis->timer < 8) { + pthis->alpha = 0; } - if (this->timer == 0) { - this->timer = 255; - Actor_Kill(&this->actor); + if (pthis->timer == 0) { + pthis->timer = 255; + Actor_Kill(&pthis->actor); } } -void ArrowFire_Fly(ArrowFire* this, GlobalContext* globalCtx) { +void ArrowFire_Fly(ArrowFire* pthis, GlobalContext* globalCtx) { EnArrow* arrow; f32 distanceScaled; s32 pad; - arrow = (EnArrow*)this->actor.parent; + arrow = (EnArrow*)pthis->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } // copy position and rotation from arrow - this->actor.world.pos = arrow->actor.world.pos; - this->actor.shape.rot = arrow->actor.shape.rot; - distanceScaled = Math_Vec3f_DistXYZ(&this->unkPos, &this->actor.world.pos) * (1.0f / 24.0f); - this->unk_158 = distanceScaled; + pthis->actor.world.pos = arrow->actor.world.pos; + pthis->actor.shape.rot = arrow->actor.shape.rot; + distanceScaled = Math_Vec3f_DistXYZ(&pthis->unkPos, &pthis->actor.world.pos) * (1.0f / 24.0f); + pthis->unk_158 = distanceScaled; if (distanceScaled < 1.0f) { - this->unk_158 = 1.0f; + pthis->unk_158 = 1.0f; } - func_80865ECC(&this->unkPos, &this->actor.world.pos, 0.05f); + func_80865ECC(&pthis->unkPos, &pthis->actor.world.pos, 0.05f); if (arrow->hitFlags & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_FRAME); - ArrowFire_SetupAction(this, ArrowFire_Hit); - this->timer = 32; - this->alpha = 255; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_EXPLOSION_FRAME); + ArrowFire_SetupAction(pthis, ArrowFire_Hit); + pthis->timer = 32; + pthis->alpha = 255; } else if (arrow->timer < 34) { - if (this->alpha < 35) { - Actor_Kill(&this->actor); + if (pthis->alpha < 35) { + Actor_Kill(&pthis->actor); } else { - this->alpha -= 0x19; + pthis->alpha -= 0x19; } } } -void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) { - ArrowFire* this = (ArrowFire*)thisx; +void ArrowFire_Update(Actor* pthisx, GlobalContext* globalCtx) { + ArrowFire* pthis = (ArrowFire*)pthisx; if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || globalCtx->msgCtx.msgMode == MSGMODE_SONG_PLAYED) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } } -void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { - ArrowFire* this = (ArrowFire*)thisx; +void ArrowFire_Draw(Actor* pthisx, GlobalContext* globalCtx2) { + ArrowFire* pthis = (ArrowFire*)pthisx; GlobalContext* globalCtx = globalCtx2; u32 stateFrames; EnArrow* arrow; Actor* tranform; stateFrames = globalCtx->state.frames; - arrow = (EnArrow*)this->actor.parent; + arrow = (EnArrow*)pthis->actor.parent; if (1) {} - if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + if ((arrow != NULL) && (arrow->actor.update != NULL) && (pthis->timer < 255)) { if (1) {} - tranform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; + tranform = (arrow->hitFlags & 2) ? &pthis->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arrow_fire.c", 618); @@ -220,10 +220,10 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw red effect over the screen when arrow hits - if (this->unk_15C > 0) { + if (pthis->unk_15C > 0) { POLY_XLU_DISP = func_800937C0(POLY_XLU_DISP); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(40.0f * this->unk_15C) & 0xFF, 0, 0, - (s32)(150.0f * this->unk_15C) & 0xFF); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(40.0f * pthis->unk_15C) & 0xFF, 0, 0, + (s32)(150.0f * pthis->unk_15C) & 0xFF); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); gDPFillRectangle(POLY_XLU_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); @@ -231,15 +231,15 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { // Draw fire on the arrow func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, pthis->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); Matrix_RotateZYX(0x4000, 0x0, 0x0, MTXMODE_APPLY); - if (this->timer != 0) { + if (pthis->timer != 0) { Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } - Matrix_Scale(this->radius * 0.2f, this->unk_158 * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_Scale(pthis->radius * 0.2f, pthis->unk_158 * 4.0f, pthis->radius * 0.2f, MTXMODE_APPLY); Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_arrow_fire.c", 666), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.cpp similarity index 51% rename from src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c rename to src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.cpp index e15281686..c844adcb8 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.cpp @@ -12,23 +12,23 @@ #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_25) -void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx); -void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); -void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArrowIce_Init(Actor* pthisx, GlobalContext* globalCtx); +void ArrowIce_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void ArrowIce_Update(Actor* pthisx, GlobalContext* globalCtx); +void ArrowIce_Draw(Actor* pthisx, GlobalContext* globalCtx); -void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx); +void ArrowIce_Charge(ArrowIce* pthis, GlobalContext* globalCtx); +void ArrowIce_Fly(ArrowIce* pthis, GlobalContext* globalCtx); +void ArrowIce_Hit(ArrowIce* pthis, GlobalContext* globalCtx); -#include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" +#include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.cpp" #include "def/sys_matrix.h" #include "def/z_actor.h" #include "def/z_lib.h" #include "def/z_parameter.h" #include "def/z_rcp.h" -const ActorInit Arrow_Ice_InitVars = { +ActorInit Arrow_Ice_InitVars = { ACTOR_ARROW_ICE, ACTORCAT_ITEMACTION, FLAGS, @@ -44,52 +44,52 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -void ArrowIce_SetupAction(ArrowIce* this, ArrowIceActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ArrowIce_SetupAction(ArrowIce* pthis, ArrowIceActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx) { - ArrowIce* this = (ArrowIce*)thisx; +void ArrowIce_Init(Actor* pthisx, GlobalContext* globalCtx) { + ArrowIce* pthis = (ArrowIce*)pthisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->radius = 0; - this->unk_160 = 1.0f; - ArrowIce_SetupAction(this, ArrowIce_Charge); - Actor_SetScale(&this->actor, 0.01f); - this->alpha = 100; - this->timer = 0; - this->unk_164 = 0.0f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->radius = 0; + pthis->unk_160 = 1.0f; + ArrowIce_SetupAction(pthis, ArrowIce_Charge); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->alpha = 100; + pthis->timer = 0; + pthis->unk_164 = 0.0f; } -void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ArrowIce_Destroy(Actor* pthisx, GlobalContext* globalCtx) { func_800876C8(globalCtx); LOG_STRING("消滅", "../z_arrow_ice.c", 415); // "Disappearance" } -void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Charge(ArrowIce* pthis, GlobalContext* globalCtx) { EnArrow* arrow; - arrow = (EnArrow*)this->actor.parent; + arrow = (EnArrow*)pthis->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->radius < 10) { - this->radius += 1; + if (pthis->radius < 10) { + pthis->radius += 1; } // copy position and rotation from arrow - this->actor.world.pos = arrow->actor.world.pos; - this->actor.shape.rot = arrow->actor.shape.rot; + pthis->actor.world.pos = arrow->actor.world.pos; + pthis->actor.shape.rot = arrow->actor.shape.rot; - func_8002F974(&this->actor, NA_SE_PL_ARROW_CHARGE_ICE - SFX_FLAG); + func_8002F974(&pthis->actor, NA_SE_PL_ARROW_CHARGE_ICE - SFX_FLAG); // if arrow has no parent, player has fired the arrow if (arrow->actor.parent == NULL) { - this->unkPos = this->actor.world.pos; - this->radius = 10; - ArrowIce_SetupAction(this, ArrowIce_Fly); - this->alpha = 255; + pthis->unkPos = pthis->actor.world.pos; + pthis->radius = 10; + ArrowIce_SetupAction(pthis, ArrowIce_Fly); + pthis->alpha = 255; } } @@ -99,115 +99,115 @@ void func_80867E8C(Vec3f* unkPos, Vec3f* icePos, f32 scale) { unkPos->z += ((icePos->z - unkPos->z) * scale); } -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Hit(ArrowIce* pthis, GlobalContext* globalCtx) { f32 scale; f32 offset; u16 timer; - if (this->actor.projectedW < 50.0f) { + if (pthis->actor.projectedW < 50.0f) { scale = 10.0f; } else { - if (950.0f < this->actor.projectedW) { + if (950.0f < pthis->actor.projectedW) { scale = 310.0f; } else { - scale = this->actor.projectedW; + scale = pthis->actor.projectedW; scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; } } - timer = this->timer; + timer = pthis->timer; if (timer != 0) { - this->timer -= 1; + pthis->timer -= 1; - if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + if (pthis->timer >= 8) { + offset = ((pthis->timer - 8) * (1.0f / 24.0f)); offset = SQ(offset); - this->radius = (((1.0f - offset) * scale) + 10.0f); - this->unk_160 += ((2.0f - this->unk_160) * 0.1f); - if (this->timer < 16) { + pthis->radius = (((1.0f - offset) * scale) + 10.0f); + pthis->unk_160 += ((2.0f - pthis->unk_160) * 0.1f); + if (pthis->timer < 16) { if (1) {} - this->alpha = ((this->timer * 0x23) - 0x118); + pthis->alpha = ((pthis->timer * 0x23) - 0x118); } } } - if (this->timer >= 9) { - if (this->unk_164 < 1.0f) { - this->unk_164 += 0.25f; + if (pthis->timer >= 9) { + if (pthis->unk_164 < 1.0f) { + pthis->unk_164 += 0.25f; } } else { - if (this->unk_164 > 0.0f) { - this->unk_164 -= 0.125f; + if (pthis->unk_164 > 0.0f) { + pthis->unk_164 -= 0.125f; } } - if (this->timer < 8) { - this->alpha = 0; + if (pthis->timer < 8) { + pthis->alpha = 0; } - if (this->timer == 0) { - this->timer = 255; - Actor_Kill(&this->actor); + if (pthis->timer == 0) { + pthis->timer = 255; + Actor_Kill(&pthis->actor); } } -void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Fly(ArrowIce* pthis, GlobalContext* globalCtx) { EnArrow* arrow; f32 distanceScaled; s32 pad; - arrow = (EnArrow*)this->actor.parent; + arrow = (EnArrow*)pthis->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } // copy position and rotation from arrow - this->actor.world.pos = arrow->actor.world.pos; - this->actor.shape.rot = arrow->actor.shape.rot; - distanceScaled = Math_Vec3f_DistXYZ(&this->unkPos, &this->actor.world.pos) * (1.0f / 24.0f); - this->unk_160 = distanceScaled; + pthis->actor.world.pos = arrow->actor.world.pos; + pthis->actor.shape.rot = arrow->actor.shape.rot; + distanceScaled = Math_Vec3f_DistXYZ(&pthis->unkPos, &pthis->actor.world.pos) * (1.0f / 24.0f); + pthis->unk_160 = distanceScaled; if (distanceScaled < 1.0f) { - this->unk_160 = 1.0f; + pthis->unk_160 = 1.0f; } - func_80867E8C(&this->unkPos, &this->actor.world.pos, 0.05f); + func_80867E8C(&pthis->unkPos, &pthis->actor.world.pos, 0.05f); if (arrow->hitFlags & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_ICE); - ArrowIce_SetupAction(this, ArrowIce_Hit); - this->timer = 32; - this->alpha = 255; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_EXPLOSION_ICE); + ArrowIce_SetupAction(pthis, ArrowIce_Hit); + pthis->timer = 32; + pthis->alpha = 255; } else if (arrow->timer < 34) { - if (this->alpha < 35) { - Actor_Kill(&this->actor); + if (pthis->alpha < 35) { + Actor_Kill(&pthis->actor); } else { - this->alpha -= 0x19; + pthis->alpha -= 0x19; } } } -void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx) { - ArrowIce* this = (ArrowIce*)thisx; +void ArrowIce_Update(Actor* pthisx, GlobalContext* globalCtx) { + ArrowIce* pthis = (ArrowIce*)pthisx; if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || globalCtx->msgCtx.msgMode == MSGMODE_SONG_PLAYED) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } } -void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { - ArrowIce* this = (ArrowIce*)thisx; +void ArrowIce_Draw(Actor* pthisx, GlobalContext* globalCtx) { + ArrowIce* pthis = (ArrowIce*)pthisx; s32 pad; Actor* tranform; u32 stateFrames = globalCtx->state.frames; - EnArrow* arrow = (EnArrow*)this->actor.parent; + EnArrow* arrow = (EnArrow*)pthis->actor.parent; if (1) {} - if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + if ((arrow != NULL) && (arrow->actor.update != NULL) && (pthis->timer < 255)) { if (1) {} - tranform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; + tranform = (arrow->hitFlags & 2) ? &pthis->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arrow_ice.c", 610); @@ -218,10 +218,10 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw blue effect over the screen when arrow hits - if (this->unk_164 > 0) { + if (pthis->unk_164 > 0) { POLY_XLU_DISP = func_800937C0(POLY_XLU_DISP); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, (s32)(10.0f * this->unk_164) & 0xFF, - (s32)(50.0f * this->unk_164) & 0xFF, (s32)(150.0f * this->unk_164) & 0xFF); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, (s32)(10.0f * pthis->unk_164) & 0xFF, + (s32)(50.0f * pthis->unk_164) & 0xFF, (s32)(150.0f * pthis->unk_164) & 0xFF); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); gDPFillRectangle(POLY_XLU_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); @@ -229,15 +229,15 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { // Draw ice on the arrow func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, this->alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, pthis->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128); Matrix_RotateZYX(0x4000, 0x0, 0x0, MTXMODE_APPLY); - if (this->timer != 0) { + if (pthis->timer != 0) { Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } - Matrix_Scale(this->radius * 0.2f, this->unk_160 * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_Scale(pthis->radius * 0.2f, pthis->unk_160 * 3.0f, pthis->radius * 0.2f, MTXMODE_APPLY); Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_arrow_ice.c", 660), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.cpp similarity index 51% rename from src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c rename to src/overlays/actors/ovl_Arrow_Light/z_arrow_light.cpp index 542760b32..44650a375 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.cpp @@ -12,23 +12,23 @@ #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_25) -void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx); -void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx); -void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArrowLight_Init(Actor* pthisx, GlobalContext* globalCtx); +void ArrowLight_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void ArrowLight_Update(Actor* pthisx, GlobalContext* globalCtx); +void ArrowLight_Draw(Actor* pthisx, GlobalContext* globalCtx); -void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Charge(ArrowLight* pthis, GlobalContext* globalCtx); +void ArrowLight_Fly(ArrowLight* pthis, GlobalContext* globalCtx); +void ArrowLight_Hit(ArrowLight* pthis, GlobalContext* globalCtx); -#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c" +#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.cpp" #include "def/sys_matrix.h" #include "def/z_actor.h" #include "def/z_lib.h" #include "def/z_parameter.h" #include "def/z_rcp.h" -const ActorInit Arrow_Light_InitVars = { +ActorInit Arrow_Light_InitVars = { ACTOR_ARROW_LIGHT, ACTORCAT_ITEMACTION, FLAGS, @@ -44,51 +44,51 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ArrowLight_SetupAction(ArrowLight* pthis, ArrowLightActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { - ArrowLight* this = (ArrowLight*)thisx; +void ArrowLight_Init(Actor* pthisx, GlobalContext* globalCtx) { + ArrowLight* pthis = (ArrowLight*)pthisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->radius = 0; - this->unk_160 = 1.0f; - ArrowLight_SetupAction(this, ArrowLight_Charge); - Actor_SetScale(&this->actor, 0.01f); - this->alpha = 130; - this->timer = 0; - this->unk_164 = 0.0f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->radius = 0; + pthis->unk_160 = 1.0f; + ArrowLight_SetupAction(pthis, ArrowLight_Charge); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->alpha = 130; + pthis->timer = 0; + pthis->unk_164 = 0.0f; } -void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ArrowLight_Destroy(Actor* pthisx, GlobalContext* globalCtx) { func_800876C8(globalCtx); LOG_STRING("消滅", "../z_arrow_light.c", 403); // "Disappearance" } -void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) { - EnArrow* arrow = (EnArrow*)this->actor.parent; +void ArrowLight_Charge(ArrowLight* pthis, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)pthis->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->radius < 10) { - this->radius += 1; + if (pthis->radius < 10) { + pthis->radius += 1; } // copy position and rotation from arrow - this->actor.world.pos = arrow->actor.world.pos; - this->actor.shape.rot = arrow->actor.shape.rot; + pthis->actor.world.pos = arrow->actor.world.pos; + pthis->actor.shape.rot = arrow->actor.shape.rot; - func_8002F974(&this->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG); + func_8002F974(&pthis->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG); // if arrow has no parent, player has fired the arrow if (arrow->actor.parent == NULL) { - this->unkPos = this->actor.world.pos; - this->radius = 10; - ArrowLight_SetupAction(this, ArrowLight_Fly); - this->alpha = 255; + pthis->unkPos = pthis->actor.world.pos; + pthis->radius = 10; + ArrowLight_SetupAction(pthis, ArrowLight_Fly); + pthis->alpha = 255; } } @@ -98,114 +98,114 @@ void func_80869E6C(Vec3f* unkPos, Vec3f* lightPos, f32 scale) { unkPos->z += ((lightPos->z - unkPos->z) * scale); } -void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { +void ArrowLight_Hit(ArrowLight* pthis, GlobalContext* globalCtx) { f32 scale; f32 offset; u16 timer; - if (this->actor.projectedW < 50.0f) { + if (pthis->actor.projectedW < 50.0f) { scale = 10.0f; } else { - if (950.0f < this->actor.projectedW) { + if (950.0f < pthis->actor.projectedW) { scale = 310.0f; } else { - scale = this->actor.projectedW; + scale = pthis->actor.projectedW; scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; } } - timer = this->timer; + timer = pthis->timer; if (timer != 0) { - this->timer -= 1; + pthis->timer -= 1; - if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + if (pthis->timer >= 8) { + offset = ((pthis->timer - 8) * (1.0f / 24.0f)); offset = SQ(offset); - this->radius = (((1.0f - offset) * scale) + 10.0f); - this->unk_160 += ((2.0f - this->unk_160) * 0.1f); - if (this->timer < 16) { + pthis->radius = (((1.0f - offset) * scale) + 10.0f); + pthis->unk_160 += ((2.0f - pthis->unk_160) * 0.1f); + if (pthis->timer < 16) { if (1) {} - this->alpha = ((this->timer * 0x23) - 0x118); + pthis->alpha = ((pthis->timer * 0x23) - 0x118); } } } - if (this->timer >= 9) { - if (this->unk_164 < 1.0f) { - this->unk_164 += 0.25f; + if (pthis->timer >= 9) { + if (pthis->unk_164 < 1.0f) { + pthis->unk_164 += 0.25f; } } else { - if (this->unk_164 > 0.0f) { - this->unk_164 -= 0.125f; + if (pthis->unk_164 > 0.0f) { + pthis->unk_164 -= 0.125f; } } - if (this->timer < 8) { - this->alpha = 0; + if (pthis->timer < 8) { + pthis->alpha = 0; } - if (this->timer == 0) { - this->timer = 255; - Actor_Kill(&this->actor); + if (pthis->timer == 0) { + pthis->timer = 255; + Actor_Kill(&pthis->actor); } } -void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { - EnArrow* arrow = (EnArrow*)this->actor.parent; +void ArrowLight_Fly(ArrowLight* pthis, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)pthis->actor.parent; f32 distanceScaled; s32 pad; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } // copy position and rotation from parent arrow - this->actor.world.pos = arrow->actor.world.pos; - this->actor.shape.rot = arrow->actor.shape.rot; - distanceScaled = Math_Vec3f_DistXYZ(&this->unkPos, &this->actor.world.pos) * (1.0f / 24.0f); - this->unk_160 = distanceScaled; + pthis->actor.world.pos = arrow->actor.world.pos; + pthis->actor.shape.rot = arrow->actor.shape.rot; + distanceScaled = Math_Vec3f_DistXYZ(&pthis->unkPos, &pthis->actor.world.pos) * (1.0f / 24.0f); + pthis->unk_160 = distanceScaled; if (distanceScaled < 1.0f) { - this->unk_160 = 1.0f; + pthis->unk_160 = 1.0f; } - func_80869E6C(&this->unkPos, &this->actor.world.pos, 0.05f); + func_80869E6C(&pthis->unkPos, &pthis->actor.world.pos, 0.05f); if (arrow->hitFlags & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); - ArrowLight_SetupAction(this, ArrowLight_Hit); - this->timer = 32; - this->alpha = 255; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_EXPLOSION_LIGHT); + ArrowLight_SetupAction(pthis, ArrowLight_Hit); + pthis->timer = 32; + pthis->alpha = 255; } else if (arrow->timer < 34) { - if (this->alpha < 35) { - Actor_Kill(&this->actor); + if (pthis->alpha < 35) { + Actor_Kill(&pthis->actor); } else { - this->alpha -= 0x19; + pthis->alpha -= 0x19; } } } -void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) { - ArrowLight* this = (ArrowLight*)thisx; +void ArrowLight_Update(Actor* pthisx, GlobalContext* globalCtx) { + ArrowLight* pthis = (ArrowLight*)pthisx; if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || globalCtx->msgCtx.msgMode == MSGMODE_SONG_PLAYED) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } } -void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { - ArrowLight* this = (ArrowLight*)thisx; +void ArrowLight_Draw(Actor* pthisx, GlobalContext* globalCtx) { + ArrowLight* pthis = (ArrowLight*)pthisx; s32 pad; u32 stateFrames = globalCtx->state.frames; - EnArrow* arrow = (EnArrow*)this->actor.parent; + EnArrow* arrow = (EnArrow*)pthis->actor.parent; Actor* tranform; if (1) {} - if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + if ((arrow != NULL) && (arrow->actor.update != NULL) && (pthis->timer < 255)) { if (1) {} - tranform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; + tranform = (arrow->hitFlags & 2) ? &pthis->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arrow_light.c", 598); @@ -216,10 +216,10 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw yellow effect over the screen when arrow hits - if (this->unk_164 > 0) { + if (pthis->unk_164 > 0) { POLY_XLU_DISP = func_800937C0(POLY_XLU_DISP); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(30.0f * this->unk_164) & 0xFF, - (s32)(40.0f * this->unk_164) & 0xFF, 0, (s32)(150.0f * this->unk_164) & 0xFF); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(30.0f * pthis->unk_164) & 0xFF, + (s32)(40.0f * pthis->unk_164) & 0xFF, 0, (s32)(150.0f * pthis->unk_164) & 0xFF); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); gDPFillRectangle(POLY_XLU_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); @@ -227,15 +227,15 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { // Draw light on the arrow func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, pthis->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); Matrix_RotateZYX(0x4000, 0x0, 0x0, MTXMODE_APPLY); - if (this->timer != 0) { + if (pthis->timer != 0) { Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } - Matrix_Scale(this->radius * 0.2f, this->unk_160 * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_Scale(pthis->radius * 0.2f, pthis->unk_160 * 4.0f, pthis->radius * 0.2f, MTXMODE_APPLY); Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_arrow_light.c", 648), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c deleted file mode 100644 index 3b395682a..000000000 --- a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c +++ /dev/null @@ -1,480 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BDAN_OBJECTS_Z_BG_BDAN_OBJECTS_C -#include "actor_common.h" -/* - * File: z_bg_bdan_objects.c - * Overlay: ovl_Bg_Bdan_Objects - * Description: Lord Jabu-Jabu Objects - */ - -#include "z_bg_bdan_objects.h" -#include "objects/object_bdan_objects/object_bdan_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_play.h" -#include "def/z_quake.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgBdanObjects_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBdanObjects_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBdanObjects_Update(Actor* thisx, GlobalContext* globalCtx); -void BgBdanObjects_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8086C054(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C1A0(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C29C(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C55C(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C5BC(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C618(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C6EC(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C76C(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C7D0(BgBdanObjects* this, GlobalContext* globalCtx); -void BgBdanObjects_DoNothing(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C874(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C9A8(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086C9F0(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086CABC(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086CB10(BgBdanObjects* this, GlobalContext* globalCtx); -void func_8086CB8C(BgBdanObjects* this, GlobalContext* globalCtx); - -const ActorInit Bg_Bdan_Objects_InitVars = { - ACTOR_BG_BDAN_OBJECTS, - ACTORCAT_BG, - FLAGS, - OBJECT_BDAN_OBJECTS, - sizeof(BgBdanObjects), - (ActorFunc)BgBdanObjects_Init, - (ActorFunc)BgBdanObjects_Destroy, - (ActorFunc)BgBdanObjects_Update, - (ActorFunc)BgBdanObjects_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_NONE, - OCELEM_NONE, - }, - { 0x00BB, 0x0050, 0x0000, { 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -static Gfx* sDLists[] = { - gJabuObjectsLargeRotatingSpikePlatformDL, - gJabuElevatorPlatformDL, - gJabuWaterDL, - gJabuFallingPlatformDL, -}; - -s32 BgBdanObjects_GetContactRu1(BgBdanObjects* this, s32 arg1) { - switch (arg1) { - case 0: - return this->cameraSetting == CAM_SET_NORMAL0; - case 4: - return gSaveContext.infTable[20] & 0x40; - case 3: - return this->cameraSetting == CAM_SET_DUNGEON1; - default: - osSyncPrintf("Bg_Bdan_Objects_Get_Contact_Ru1\nそんな受信モードは無い%d!!!!!!!!\n"); - return -1; - } -} - -void BgBdanObjects_SetContactRu1(BgBdanObjects* this, s32 arg1) { - switch (arg1) { - case 1: - this->cameraSetting = CAM_SET_NORMAL1; - break; - case 2: - this->cameraSetting = CAM_SET_DUNGEON0; - break; - case 4: - gSaveContext.infTable[20] |= 0x40; - break; - default: - osSyncPrintf("Bg_Bdan_Objects_Set_Contact_Ru1\nそんな送信モードは無い%d!!!!!!!!\n"); - } -} - -void BgBdanObjects_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgBdanObjects* this = (BgBdanObjects*)thisx; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - this->switchFlag = (thisx->params >> 8) & 0x3F; - thisx->params &= 0xFF; - if (thisx->params == 2) { - thisx->flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - globalCtx->colCtx.colHeader->waterBoxes[7].ySurface = thisx->world.pos.y; - this->actionFunc = func_8086C9A8; - return; - } - if (thisx->params == 0) { - CollisionHeader_GetVirtual(&gJabuBigOctoPlatformCol, &colHeader); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - thisx->world.pos.y += -79.0f; - if (Flags_GetClear(globalCtx, thisx->room)) { - Flags_SetSwitch(globalCtx, this->switchFlag); - this->actionFunc = func_8086C6EC; - } else { - if (BgBdanObjects_GetContactRu1(this, 4)) { - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_BIGOKUTA, - thisx->home.pos.x, thisx->home.pos.y, thisx->home.pos.z, 0, - thisx->shape.rot.y + 0x8000, 0, 3) != NULL) { - thisx->child->world.pos.z = thisx->child->home.pos.z + 263.0f; - } - thisx->world.rot.y = 0; - this->actionFunc = func_8086C618; - thisx->world.pos.y = thisx->home.pos.y + -70.0f; - } else { - Flags_SetSwitch(globalCtx, this->switchFlag); - this->timer = 0; - this->actionFunc = func_8086C054; - } - } - } else { - if (thisx->params == 1) { - CollisionHeader_GetVirtual(&gJabuElevatorCol, &colHeader); - this->timer = 512; - this->switchFlag = 0; - this->actionFunc = func_8086C874; - } else { - CollisionHeader_GetVirtual(&gJabuLoweringPlatformCol, &colHeader); - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actionFunc = BgBdanObjects_DoNothing; - thisx->world.pos.y = thisx->home.pos.y - 400.0f; - } else { - this->actionFunc = func_8086CB10; - } - } - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); -} - -void BgBdanObjects_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgBdanObjects* this = (BgBdanObjects*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if (thisx->params == 0) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void func_8086C054(BgBdanObjects* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (BgBdanObjects_GetContactRu1(this, 0)) { - if (this->dyna.actor.xzDistToPlayer < 250.0f) { - BgBdanObjects_SetContactRu1(this, 1); - this->timer = 20; - OnePointCutscene_Init(globalCtx, 3070, -99, &this->dyna.actor, MAIN_CAM); - player->actor.world.pos.x = -1130.0f; - player->actor.world.pos.y = -1025.0f; - player->actor.world.pos.z = -3300.0f; - func_800AA000(0.0f, 0xFF, 0x14, 0x96); - } - } else if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->actionFunc = func_8086C1A0; - } - } - - if (!Gameplay_InCsMode(globalCtx) && !BgBdanObjects_GetContactRu1(this, 0)) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + -79.0f; - } else { - this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y + -79.0f) - 5.0f; - } -} - -void func_8086C1A0(BgBdanObjects* this, GlobalContext* globalCtx) { - if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 500.0f, 0.5f, 7.5f, 1.0f) < - 0.1f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_A); - this->actionFunc = func_8086C29C; - this->timer = 30; - BgBdanObjects_SetContactRu1(this, 2); - func_800AA000(0.0f, 0xFF, 0x14, 0x96); - } else { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - func_800AA000(0.0f, 0x78, 0x14, 0xA); - this->timer = 11; - } - func_8002F974(&this->dyna.actor, NA_SE_EV_BUYOSTAND_RISING - SFX_FLAG); - } -} - -void func_8086C29C(BgBdanObjects* this, GlobalContext* globalCtx) { - s32 temp; - - if (this->timer != 0) { - this->timer--; - if (this->timer == 0) { - temp = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); - Quake_SetSpeed(temp, 0x3A98); - Quake_SetQuakeValues(temp, 0, 1, 0xFA, 1); - Quake_SetCountdown(temp, 0xA); - } - } - - if (BgBdanObjects_GetContactRu1(this, 3)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_BIGOKUTA, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 140.0f, - this->dyna.actor.world.pos.z, 0, this->dyna.actor.shape.rot.y + 0x8000, 0, 0); - BgBdanObjects_SetContactRu1(this, 4); - this->timer = 10; - this->actionFunc = func_8086C55C; - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - } -} - -void func_8086C3D8(BgBdanObjects* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->dyna.actor.velocity.y += 0.5f; - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + -70.0f, - this->dyna.actor.velocity.y)) { - this->dyna.actor.world.rot.y = 0; - this->timer = 60; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); - this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y + 140.0f; - this->actionFunc = func_8086C5BC; - OnePointCutscene_Init(globalCtx, 3080, -99, this->dyna.actor.child, MAIN_CAM); - player->actor.world.pos.x = -1130.0f; - player->actor.world.pos.y = -1025.0f; - player->actor.world.pos.z = -3500.0f; - player->actor.shape.rot.y = 0x7530; - player->actor.world.rot.y = player->actor.shape.rot.y; - func_800AA000(0.0f, 0xFF, 0x1E, 0x96); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_BUYOSTAND_FALL - SFX_FLAG); - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - func_800AA000(0.0f, 0x78, 0x14, 0xA); - this->timer = 11; - } - if (this->dyna.actor.child != NULL) { - this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y + 140.0f; - } - } -} - -void func_8086C55C(BgBdanObjects* this, GlobalContext* globalCtx) { - this->timer--; - - if (this->timer == 0) { - Flags_UnsetSwitch(globalCtx, this->switchFlag); - } else if (this->timer == -40) { - this->timer = 0; - this->actionFunc = func_8086C3D8; - } -} - -void func_8086C5BC(BgBdanObjects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if ((this->timer == 0) && (this->dyna.actor.child != NULL)) { - if (this->dyna.actor.child->params == 2) { - this->actionFunc = func_8086C618; - } else if (this->dyna.actor.child->params == 0) { - this->dyna.actor.child->params = 1; - } - } -} - -void func_8086C618(BgBdanObjects* this, GlobalContext* globalCtx) { - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { - Flags_SetSwitch(globalCtx, this->switchFlag); - this->dyna.actor.home.rot.y = (s16)(this->dyna.actor.shape.rot.y + 0x2000) & 0xC000; - this->actionFunc = func_8086C6EC; - } else { - this->dyna.actor.shape.rot.y += this->dyna.actor.world.rot.y; - func_800F436C(&this->dyna.actor.projectedPos, 0x2063, ABS(this->dyna.actor.world.rot.y) / 512.0f); - } -} - -void func_8086C6EC(BgBdanObjects* this, GlobalContext* globalCtx) { - s32 cond = Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y, 0x200); - - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + -125.0f, 3.0f)) { - if (cond) { - this->actionFunc = func_8086C76C; - } - } -} - -void func_8086C76C(BgBdanObjects* this, GlobalContext* globalCtx) { - if (func_8004356C(&this->dyna)) { - if (this->dyna.actor.xzDistToPlayer < 120.0f) { - this->actionFunc = func_8086C7D0; - OnePointCutscene_Init(globalCtx, 3090, -99, &this->dyna.actor, MAIN_CAM); - } - } -} - -void func_8086C7D0(BgBdanObjects* this, GlobalContext* globalCtx) { - if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 965.0f, 0.5f, 15.0f, 0.2f) < - 0.01f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_A); - this->actionFunc = BgBdanObjects_DoNothing; - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_BUYOSTAND_RISING - SFX_FLAG); - } -} - -void BgBdanObjects_DoNothing(BgBdanObjects* this, GlobalContext* globalCtx) { -} - -void func_8086C874(BgBdanObjects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->switchFlag == 0) { - if (func_8004356C(&this->dyna)) { - this->cameraSetting = globalCtx->cameraPtrs[MAIN_CAM]->setting; - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_NORMAL2); - func_8005AD1C(globalCtx->cameraPtrs[MAIN_CAM], 4); - this->switchFlag = 10; - } - } else { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_NORMAL2); - if (!func_8004356C(&this->dyna)) { - if (this->switchFlag != 0) { - this->switchFlag--; - } - } - if (this->switchFlag == 0) { - if (1) {} - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], this->cameraSetting); - func_8005ACFC(globalCtx->cameraPtrs[MAIN_CAM], 4); - } - } - this->dyna.actor.world.pos.y = - this->dyna.actor.home.pos.y - (sinf(this->timer * (M_PI / 256.0f)) * 471.24f); // pi * 150 - if (this->timer == 0) { - this->timer = 512; - } -} - -void func_8086C9A8(BgBdanObjects* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->timer = 100; - this->actionFunc = func_8086C9F0; - } -} - -void func_8086C9F0(BgBdanObjects* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 0.5f)) { - Flags_UnsetSwitch(globalCtx, this->switchFlag); - this->actionFunc = func_8086C9A8; - } - func_8002F948(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); - } else { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 75.0f, 0.5f)) { - this->actionFunc = func_8086CABC; - } - func_8002F948(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); - } - globalCtx->colCtx.colHeader->waterBoxes[7].ySurface = this->dyna.actor.world.pos.y; -} - -void func_8086CABC(BgBdanObjects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - func_8002F994(&this->dyna.actor, this->timer); - if (this->timer == 0) { - this->actionFunc = func_8086C9F0; - } -} - -void func_8086CB10(BgBdanObjects* this, GlobalContext* globalCtx) { - if (func_8004356C(&this->dyna)) { - Flags_SetSwitch(globalCtx, this->switchFlag); - this->timer = 50; - this->actionFunc = func_8086CB8C; - this->dyna.actor.home.pos.y -= 200.0f; - OnePointCutscene_Init(globalCtx, 3100, 51, &this->dyna.actor, MAIN_CAM); - } -} - -void func_8086CB8C(BgBdanObjects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - (cosf(this->timer * (M_PI / 50.0f)) * 200.0f); - - if (this->timer == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); - this->actionFunc = BgBdanObjects_DoNothing; - Gameplay_CopyCamera(globalCtx, MAIN_CAM, SUBCAM_ACTIVE); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_BUYOSTAND_FALL - SFX_FLAG); - } -} - -void BgBdanObjects_Update(Actor* thisx, GlobalContext* globalCtx) { - BgBdanObjects* this = (BgBdanObjects*)thisx; - - Actor_SetFocus(thisx, 50.0f); - this->actionFunc(this, globalCtx); -} - -void BgBdanObjects_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgBdanObjects* this = (BgBdanObjects*)thisx; - - if (thisx->params == 0) { - if (this->actionFunc == func_8086C054) { - if (((thisx->home.pos.y + -79.0f) - 5.0f) < thisx->world.pos.y) { - Matrix_Translate(0.0f, -50.0f, 0.0f, MTXMODE_APPLY); - } - } - } - - if (thisx->params == 2) { - Gfx_DrawDListXlu(globalCtx, gJabuWaterDL); - } else { - Gfx_DrawDListOpa(globalCtx, sDLists[thisx->params]); - } -} diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp new file mode 100644 index 000000000..ce6cfd78e --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp @@ -0,0 +1,478 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BDAN_OBJECTS_Z_BG_BDAN_OBJECTS_C +#include "actor_common.h" +/* + * File: z_bg_bdan_objects.c + * Overlay: ovl_Bg_Bdan_Objects + * Description: Lord Jabu-Jabu Objects + */ + +#include "z_bg_bdan_objects.h" +#include "objects/object_bdan_objects/object_bdan_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_play.h" +#include "def/z_quake.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgBdanObjects_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgBdanObjects_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgBdanObjects_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgBdanObjects_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void func_8086C054(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C1A0(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C29C(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C55C(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C5BC(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C618(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C6EC(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C76C(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C7D0(BgBdanObjects* pthis, GlobalContext* globalCtx); +void BgBdanObjects_DoNothing(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C874(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C9A8(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086C9F0(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086CABC(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086CB10(BgBdanObjects* pthis, GlobalContext* globalCtx); +void func_8086CB8C(BgBdanObjects* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Bdan_Objects_InitVars = { + ACTOR_BG_BDAN_OBJECTS, + ACTORCAT_BG, + FLAGS, + OBJECT_BDAN_OBJECTS, + sizeof(BgBdanObjects), + (ActorFunc)BgBdanObjects_Init, + (ActorFunc)BgBdanObjects_Destroy, + (ActorFunc)BgBdanObjects_Update, + (ActorFunc)BgBdanObjects_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, + { 0x00BB, 0x0050, 0x0000, { 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +static Gfx* sDLists[] = { + gJabuObjectsLargeRotatingSpikePlatformDL, + gJabuElevatorPlatformDL, + gJabuWaterDL, + gJabuFallingPlatformDL, +}; + +s32 BgBdanObjects_GetContactRu1(BgBdanObjects* pthis, s32 arg1) { + switch (arg1) { + case 0: + return pthis->cameraSetting == CAM_SET_NORMAL0; + case 4: + return gSaveContext.infTable[20] & 0x40; + case 3: + return pthis->cameraSetting == CAM_SET_DUNGEON1; + default: + osSyncPrintf("Bg_Bdan_Objects_Get_Contact_Ru1\nそんな受信モードは無い%d!!!!!!!!\n"); + return -1; + } +} + +void BgBdanObjects_SetContactRu1(BgBdanObjects* pthis, s32 arg1) { + switch (arg1) { + case 1: + pthis->cameraSetting = CAM_SET_NORMAL1; + break; + case 2: + pthis->cameraSetting = CAM_SET_DUNGEON0; + break; + case 4: + gSaveContext.infTable[20] |= 0x40; + break; + default: + osSyncPrintf("Bg_Bdan_Objects_Set_Contact_Ru1\nそんな送信モードは無い%d!!!!!!!!\n"); + } +} + +void BgBdanObjects_Init(Actor* pthisx, GlobalContext* globalCtx) { + s32 pad; + BgBdanObjects* pthis = (BgBdanObjects*)pthisx; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + pthis->switchFlag = (pthisx->params >> 8) & 0x3F; + pthisx->params &= 0xFF; + if (pthisx->params == 2) { + pthisx->flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + globalCtx->colCtx.colHeader->waterBoxes[7].ySurface = pthisx->world.pos.y; + pthis->actionFunc = func_8086C9A8; + return; + } + if (pthisx->params == 0) { + CollisionHeader_GetVirtual(&gJabuBigOctoPlatformCol, &colHeader); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + pthisx->world.pos.y += -79.0f; + if (Flags_GetClear(globalCtx, pthisx->room)) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + pthis->actionFunc = func_8086C6EC; + } else { + if (BgBdanObjects_GetContactRu1(pthis, 4)) { + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_BIGOKUTA, + pthisx->home.pos.x, pthisx->home.pos.y, pthisx->home.pos.z, 0, + pthisx->shape.rot.y + 0x8000, 0, 3) != NULL) { + pthisx->child->world.pos.z = pthisx->child->home.pos.z + 263.0f; + } + pthisx->world.rot.y = 0; + pthis->actionFunc = func_8086C618; + pthisx->world.pos.y = pthisx->home.pos.y + -70.0f; + } else { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + pthis->timer = 0; + pthis->actionFunc = func_8086C054; + } + } + } else { + if (pthisx->params == 1) { + CollisionHeader_GetVirtual(&gJabuElevatorCol, &colHeader); + pthis->timer = 512; + pthis->switchFlag = 0; + pthis->actionFunc = func_8086C874; + } else { + CollisionHeader_GetVirtual(&gJabuLoweringPlatformCol, &colHeader); + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actionFunc = BgBdanObjects_DoNothing; + pthisx->world.pos.y = pthisx->home.pos.y - 400.0f; + } else { + pthis->actionFunc = func_8086CB10; + } + } + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, pthisx, colHeader); +} + +void BgBdanObjects_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgBdanObjects* pthis = (BgBdanObjects*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if (pthisx->params == 0) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void func_8086C054(BgBdanObjects* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (BgBdanObjects_GetContactRu1(pthis, 0)) { + if (pthis->dyna.actor.xzDistToPlayer < 250.0f) { + BgBdanObjects_SetContactRu1(pthis, 1); + pthis->timer = 20; + OnePointCutscene_Init(globalCtx, 3070, -99, &pthis->dyna.actor, MAIN_CAM); + player->actor.world.pos.x = -1130.0f; + player->actor.world.pos.y = -1025.0f; + player->actor.world.pos.z = -3300.0f; + func_800AA000(0.0f, 0xFF, 0x14, 0x96); + } + } else if (pthis->timer != 0) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + pthis->actionFunc = func_8086C1A0; + } + } + + if (!Gameplay_InCsMode(globalCtx) && !BgBdanObjects_GetContactRu1(pthis, 0)) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + -79.0f; + } else { + pthis->dyna.actor.world.pos.y = (pthis->dyna.actor.home.pos.y + -79.0f) - 5.0f; + } +} + +void func_8086C1A0(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 500.0f, 0.5f, 7.5f, 1.0f) < + 0.1f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_A); + pthis->actionFunc = func_8086C29C; + pthis->timer = 30; + BgBdanObjects_SetContactRu1(pthis, 2); + func_800AA000(0.0f, 0xFF, 0x14, 0x96); + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + func_800AA000(0.0f, 0x78, 0x14, 0xA); + pthis->timer = 11; + } + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_RISING - SFX_FLAG); + } +} + +void func_8086C29C(BgBdanObjects* pthis, GlobalContext* globalCtx) { + s32 temp; + + if (pthis->timer != 0) { + pthis->timer--; + if (pthis->timer == 0) { + temp = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); + Quake_SetSpeed(temp, 0x3A98); + Quake_SetQuakeValues(temp, 0, 1, 0xFA, 1); + Quake_SetCountdown(temp, 0xA); + } + } + + if (BgBdanObjects_GetContactRu1(pthis, 3)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_BIGOKUTA, + pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y + 140.0f, + pthis->dyna.actor.world.pos.z, 0, pthis->dyna.actor.shape.rot.y + 0x8000, 0, 0); + BgBdanObjects_SetContactRu1(pthis, 4); + pthis->timer = 10; + pthis->actionFunc = func_8086C55C; + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + } +} + +void func_8086C3D8(BgBdanObjects* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->dyna.actor.velocity.y += 0.5f; + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + -70.0f, + pthis->dyna.actor.velocity.y)) { + pthis->dyna.actor.world.rot.y = 0; + pthis->timer = 60; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); + pthis->dyna.actor.child->world.pos.y = pthis->dyna.actor.world.pos.y + 140.0f; + pthis->actionFunc = func_8086C5BC; + OnePointCutscene_Init(globalCtx, 3080, -99, pthis->dyna.actor.child, MAIN_CAM); + player->actor.world.pos.x = -1130.0f; + player->actor.world.pos.y = -1025.0f; + player->actor.world.pos.z = -3500.0f; + player->actor.shape.rot.y = 0x7530; + player->actor.world.rot.y = player->actor.shape.rot.y; + func_800AA000(0.0f, 0xFF, 0x1E, 0x96); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_FALL - SFX_FLAG); + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + func_800AA000(0.0f, 0x78, 0x14, 0xA); + pthis->timer = 11; + } + if (pthis->dyna.actor.child != NULL) { + pthis->dyna.actor.child->world.pos.y = pthis->dyna.actor.world.pos.y + 140.0f; + } + } +} + +void func_8086C55C(BgBdanObjects* pthis, GlobalContext* globalCtx) { + pthis->timer--; + + if (pthis->timer == 0) { + Flags_UnsetSwitch(globalCtx, pthis->switchFlag); + } else if (pthis->timer == -40) { + pthis->timer = 0; + pthis->actionFunc = func_8086C3D8; + } +} + +void func_8086C5BC(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if ((pthis->timer == 0) && (pthis->dyna.actor.child != NULL)) { + if (pthis->dyna.actor.child->params == 2) { + pthis->actionFunc = func_8086C618; + } else if (pthis->dyna.actor.child->params == 0) { + pthis->dyna.actor.child->params = 1; + } + } +} + +void func_8086C618(BgBdanObjects* pthis, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (Flags_GetClear(globalCtx, pthis->dyna.actor.room)) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + pthis->dyna.actor.home.rot.y = (s16)(pthis->dyna.actor.shape.rot.y + 0x2000) & 0xC000; + pthis->actionFunc = func_8086C6EC; + } else { + pthis->dyna.actor.shape.rot.y += pthis->dyna.actor.world.rot.y; + func_800F436C(&pthis->dyna.actor.projectedPos, 0x2063, ABS(pthis->dyna.actor.world.rot.y) / 512.0f); + } +} + +void func_8086C6EC(BgBdanObjects* pthis, GlobalContext* globalCtx) { + s32 cond = Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.y, pthis->dyna.actor.home.rot.y, 0x200); + + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + -125.0f, 3.0f)) { + if (cond) { + pthis->actionFunc = func_8086C76C; + } + } +} + +void func_8086C76C(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (func_8004356C(&pthis->dyna)) { + if (pthis->dyna.actor.xzDistToPlayer < 120.0f) { + pthis->actionFunc = func_8086C7D0; + OnePointCutscene_Init(globalCtx, 3090, -99, &pthis->dyna.actor, MAIN_CAM); + } + } +} + +void func_8086C7D0(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 965.0f, 0.5f, 15.0f, 0.2f) < + 0.01f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_A); + pthis->actionFunc = BgBdanObjects_DoNothing; + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_RISING - SFX_FLAG); + } +} + +void BgBdanObjects_DoNothing(BgBdanObjects* pthis, GlobalContext* globalCtx) { +} + +void func_8086C874(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->switchFlag == 0) { + if (func_8004356C(&pthis->dyna)) { + pthis->cameraSetting = globalCtx->cameraPtrs[MAIN_CAM]->setting; + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_NORMAL2); + func_8005AD1C(globalCtx->cameraPtrs[MAIN_CAM], 4); + pthis->switchFlag = 10; + } + } else { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_NORMAL2); + if (!func_8004356C(&pthis->dyna)) { + if (pthis->switchFlag != 0) { + pthis->switchFlag--; + } + } + if (pthis->switchFlag == 0) { + if (1) {} + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], pthis->cameraSetting); + func_8005ACFC(globalCtx->cameraPtrs[MAIN_CAM], 4); + } + } + pthis->dyna.actor.world.pos.y = + pthis->dyna.actor.home.pos.y - (sinf(pthis->timer * (M_PI / 256.0f)) * 471.24f); // pi * 150 + if (pthis->timer == 0) { + pthis->timer = 512; + } +} + +void func_8086C9A8(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->timer = 100; + pthis->actionFunc = func_8086C9F0; + } +} + +void func_8086C9F0(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 0.5f)) { + Flags_UnsetSwitch(globalCtx, pthis->switchFlag); + pthis->actionFunc = func_8086C9A8; + } + func_8002F948(&pthis->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + } else { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 75.0f, 0.5f)) { + pthis->actionFunc = func_8086CABC; + } + func_8002F948(&pthis->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + } + globalCtx->colCtx.colHeader->waterBoxes[7].ySurface = pthis->dyna.actor.world.pos.y; +} + +void func_8086CABC(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + func_8002F994(&pthis->dyna.actor, pthis->timer); + if (pthis->timer == 0) { + pthis->actionFunc = func_8086C9F0; + } +} + +void func_8086CB10(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (func_8004356C(&pthis->dyna)) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + pthis->timer = 50; + pthis->actionFunc = func_8086CB8C; + pthis->dyna.actor.home.pos.y -= 200.0f; + OnePointCutscene_Init(globalCtx, 3100, 51, &pthis->dyna.actor, MAIN_CAM); + } +} + +void func_8086CB8C(BgBdanObjects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - (cosf(pthis->timer * (M_PI / 50.0f)) * 200.0f); + + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); + pthis->actionFunc = BgBdanObjects_DoNothing; + Gameplay_CopyCamera(globalCtx, MAIN_CAM, SUBCAM_ACTIVE); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_FALL - SFX_FLAG); + } +} + +void BgBdanObjects_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgBdanObjects* pthis = (BgBdanObjects*)pthisx; + + Actor_SetFocus(pthisx, 50.0f); + pthis->actionFunc(pthis, globalCtx); +} + +void BgBdanObjects_Draw(Actor* pthisx, GlobalContext* globalCtx) { + BgBdanObjects* pthis = (BgBdanObjects*)pthisx; + + if (pthisx->params == 0) { + if (pthis->actionFunc == func_8086C054) { + if (((pthisx->home.pos.y + -79.0f) - 5.0f) < pthisx->world.pos.y) { + Matrix_Translate(0.0f, -50.0f, 0.0f, MTXMODE_APPLY); + } + } + } + + if (pthisx->params == 2) { + Gfx_DrawDListXlu(globalCtx, gJabuWaterDL); + } else { + Gfx_DrawDListOpa(globalCtx, sDLists[pthisx->params]); + } +} diff --git a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c deleted file mode 100644 index abc5e6273..000000000 --- a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c +++ /dev/null @@ -1,547 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BDAN_SWITCH_Z_BG_BDAN_SWITCH_C -#include "actor_common.h" -/* - * File: z_bg_bdan_switch.c - * Overlay: ovl_Bg_Bdan_Switch - * Description: Switches Inside Lord Jabu-Jabu - */ - -#include "z_bg_bdan_switch.h" -#include "objects/object_bdan_objects/object_bdan_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgBdanSwitch_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBdanSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBdanSwitch_Update(Actor* thisx, GlobalContext* globalCtx); -void BgBdanSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8086D5C4(BgBdanSwitch* this); -void func_8086D5E0(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D67C(BgBdanSwitch* this); -void func_8086D694(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D730(BgBdanSwitch* this); -void func_8086D754(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D7FC(BgBdanSwitch* this); -void func_8086D80C(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D86C(BgBdanSwitch* this); -void func_8086D888(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D8BC(BgBdanSwitch* this); -void func_8086D8CC(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D95C(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086D9F8(BgBdanSwitch* this); -void func_8086DA1C(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086DAB4(BgBdanSwitch* this); -void func_8086DAC4(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086DB24(BgBdanSwitch* this); -void func_8086DB40(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086DB4C(BgBdanSwitch* this); -void func_8086DB68(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086DC30(BgBdanSwitch* this); -void func_8086DC48(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086DCCC(BgBdanSwitch* this); -void func_8086DCE8(BgBdanSwitch* this, GlobalContext* globalCtx); -void func_8086DDA8(BgBdanSwitch* this); -void func_8086DDC0(BgBdanSwitch* this, GlobalContext* globalCtx); - -const ActorInit Bg_Bdan_Switch_InitVars = { - ACTOR_BG_BDAN_SWITCH, - ACTORCAT_SWITCH, - FLAGS, - OBJECT_BDAN_OBJECTS, - sizeof(BgBdanSwitch), - (ActorFunc)BgBdanSwitch_Init, - (ActorFunc)BgBdanSwitch_Destroy, - (ActorFunc)BgBdanSwitch_Update, - (ActorFunc)BgBdanSwitch_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xEFC1FFFE, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, 120, 0 }, 370 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), -}; - -static Vec3f D_8086E0E0 = { 0.0f, 140.0f, 0.0f }; - -void BgBdanSwitch_InitDynaPoly(BgBdanSwitch* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { - s16 pad1; - CollisionHeader* colHeader = NULL; - s16 pad2; - - DynaPolyActor_Init(&this->dyna, flag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_bdan_switch.c", 325, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgBdanSwitch_InitCollision(BgBdanSwitch* this, GlobalContext* globalCtx) { - Actor* actor = &this->dyna.actor; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, actor, &sJntSphInit, this->colliderItems); -} - -void func_8086D0EC(BgBdanSwitch* this) { - if (this->unk_1CC > 0) { - this->unk_1CC += 0x5DC; - } else { - this->unk_1CC += 0xFA0; - } - - switch (this->dyna.actor.params & 0xFF) { - case BLUE: - case YELLOW_HEAVY: - case YELLOW: - this->unk_1D4 = ((Math_CosS(this->unk_1CC) * 0.5f) + (53.000004f / 6.0f)) * 0.012f; - this->unk_1D0 = ((Math_CosS(this->unk_1CC) * 0.5f) + 20.5f) * (this->unk_1C8 * 0.0050000004f); - this->dyna.actor.scale.y = this->unk_1C8 * 0.1f; - break; - case YELLOW_TALL_1: - case YELLOW_TALL_2: - this->unk_1D4 = ((Math_CosS(this->unk_1CC) * 0.5f) + (43.0f / 6.0f)) * 0.0075000003f; - this->unk_1D0 = ((Math_CosS(this->unk_1CC) * 0.5f) + 20.5f) * (this->unk_1C8 * 0.0050000004f); - this->dyna.actor.scale.y = this->unk_1C8 * 0.1f; - } - this->dyna.actor.shape.yOffset = 1.2f / this->unk_1D0; -} - -void BgBdanSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { - BgBdanSwitch* this = (BgBdanSwitch*)thisx; - s32 pad; - s16 type; - s32 flag; - - type = this->dyna.actor.params & 0xFF; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (type == YELLOW_TALL_1 || type == YELLOW_TALL_2) { - this->dyna.actor.scale.z = 0.05f; - this->dyna.actor.scale.x = 0.05f; - } else { - this->dyna.actor.scale.z = 0.1f; - this->dyna.actor.scale.x = 0.1f; - } - this->dyna.actor.scale.y = 0.0f; - Actor_SetFocus(&this->dyna.actor, 10.0f); - - switch (type) { - case BLUE: - case YELLOW_HEAVY: - case YELLOW: - BgBdanSwitch_InitDynaPoly(this, globalCtx, &gJabuFloorSwitchCol, DPM_PLAYER); - break; - case YELLOW_TALL_1: - case YELLOW_TALL_2: - BgBdanSwitch_InitCollision(this, globalCtx); - this->dyna.actor.flags |= ACTOR_FLAG_0; - this->dyna.actor.targetMode = 4; - break; - } - - flag = Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - - switch (type) { - case BLUE: - case YELLOW: - if (flag) { - func_8086D730(this); - } else { - func_8086D5C4(this); - } - break; - case YELLOW_HEAVY: - if (flag) { - func_8086DB24(this); - } else { - func_8086D86C(this); - } - break; - case YELLOW_TALL_1: - case YELLOW_TALL_2: - if (flag) { - func_8086DCCC(this); - } else { - func_8086DB4C(this); - } - break; - default: - osSyncPrintf("不正な ARG_DATA(arg_data 0x%04x)(%s %d)\n", this->dyna.actor.params, "../z_bg_bdan_switch.c", - 454); - Actor_Kill(&this->dyna.actor); - return; - } - osSyncPrintf("(巨大魚ダンジョン 専用スイッチ)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void BgBdanSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgBdanSwitch* this = (BgBdanSwitch*)thisx; - - switch (this->dyna.actor.params & 0xFF) { - case BLUE: - case YELLOW_HEAVY: - case YELLOW: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - break; - case YELLOW_TALL_1: - case YELLOW_TALL_2: - Collider_DestroyJntSph(globalCtx, &this->collider); - break; - } -} - -void func_8086D4B4(BgBdanSwitch* this, GlobalContext* globalCtx) { - s32 pad; - s32 type; - - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - type = this->dyna.actor.params & 0xFF; - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - if (type == BLUE || type == YELLOW_TALL_2) { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); - } else { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->dyna.actor, NA_SE_SY_CORRECT_CHIME); - } - } -} - -void func_8086D548(BgBdanSwitch* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - Flags_UnsetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - if ((this->dyna.actor.params & 0xFF) == YELLOW_TALL_2) { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); - } - } -} - -void func_8086D5C4(BgBdanSwitch* this) { - this->actionFunc = func_8086D5E0; - this->unk_1C8 = 1.0f; -} - -void func_8086D5E0(BgBdanSwitch* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xFF) { - case BLUE: - if (func_800435B4(&this->dyna)) { - func_8086D67C(this); - func_8086D4B4(this, globalCtx); - } - break; - case YELLOW: - if (func_8004356C(&this->dyna)) { - func_8086D67C(this); - func_8086D4B4(this, globalCtx); - } - break; - } -} - -void func_8086D67C(BgBdanSwitch* this) { - this->actionFunc = func_8086D694; - this->unk_1DA = 0x64; -} - -void func_8086D694(BgBdanSwitch* this, GlobalContext* globalCtx) { - if ((func_8005B198() == this->dyna.actor.category) || (this->unk_1DA <= 0)) { - this->unk_1C8 -= 0.2f; - if (this->unk_1C8 <= 0.1f) { - func_8086D730(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); - } - } -} - -void func_8086D730(BgBdanSwitch* this) { - this->unk_1C8 = 0.1f; - this->actionFunc = func_8086D754; - this->unk_1D8 = 6; -} - -void func_8086D754(BgBdanSwitch* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xFF) { - case BLUE: - if (!func_800435B4(&this->dyna)) { - if (this->unk_1D8 <= 0) { - func_8086D7FC(this); - func_8086D548(this, globalCtx); - } - } else { - this->unk_1D8 = 6; - } - break; - case YELLOW: - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - func_8086D7FC(this); - } - break; - } -} - -void func_8086D7FC(BgBdanSwitch* this) { - this->actionFunc = func_8086D80C; -} - -void func_8086D80C(BgBdanSwitch* this, GlobalContext* globalCtx) { - this->unk_1C8 += 0.2f; - if (this->unk_1C8 >= 1.0f) { - func_8086D5C4(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - } -} - -void func_8086D86C(BgBdanSwitch* this) { - this->actionFunc = func_8086D888; - this->unk_1C8 = 1.0f; -} - -void func_8086D888(BgBdanSwitch* this, GlobalContext* globalCtx) { - if (func_8004356C(&this->dyna)) { - func_8086D8BC(this); - } -} - -void func_8086D8BC(BgBdanSwitch* this) { - this->actionFunc = func_8086D8CC; -} - -void func_8086D8CC(BgBdanSwitch* this, GlobalContext* globalCtx) { - this->unk_1C8 -= 0.2f; - if (this->unk_1C8 <= 0.6f) { - func_8086D9F8(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); - } -} - -void func_8086D944(BgBdanSwitch* this) { - this->actionFunc = func_8086D95C; - this->unk_1DA = 0x64; -} - -void func_8086D95C(BgBdanSwitch* this, GlobalContext* globalCtx) { - if ((func_8005B198() == this->dyna.actor.category) || (this->unk_1DA <= 0)) { - this->unk_1C8 -= 0.2f; - if (this->unk_1C8 <= 0.1f) { - func_8086DB24(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); - } - } -} - -void func_8086D9F8(BgBdanSwitch* this) { - this->unk_1C8 = 0.6f; - this->actionFunc = func_8086DA1C; - this->unk_1D8 = 6; -} - -void func_8086DA1C(BgBdanSwitch* this, GlobalContext* globalCtx) { - Actor* heldActor = GET_PLAYER(globalCtx)->heldActor; - - if (func_8004356C(&this->dyna)) { - if (heldActor != NULL && heldActor->id == ACTOR_EN_RU1) { - if (this->unk_1D8 <= 0) { - func_8086D944(this); - func_8086D4B4(this, globalCtx); - } - } else { - this->unk_1D8 = 6; - } - } else { - if (this->unk_1D8 <= 0) { - func_8086DAB4(this); - } - } -} - -void func_8086DAB4(BgBdanSwitch* this) { - this->actionFunc = func_8086DAC4; -} - -void func_8086DAC4(BgBdanSwitch* this, GlobalContext* globalCtx) { - this->unk_1C8 += 0.2f; - if (this->unk_1C8 >= 1.0f) { - func_8086D86C(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - } -} - -void func_8086DB24(BgBdanSwitch* this) { - this->unk_1C8 = 0.1f; - this->actionFunc = func_8086DB40; -} - -void func_8086DB40(BgBdanSwitch* this, GlobalContext* globalCtx) { -} - -void func_8086DB4C(BgBdanSwitch* this) { - this->actionFunc = func_8086DB68; - this->unk_1C8 = 2.0f; -} - -void func_8086DB68(BgBdanSwitch* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xFF) { - default: - return; - case YELLOW_TALL_1: - if (((this->collider.base.acFlags & AC_HIT) != 0) && this->unk_1D8 <= 0) { - this->unk_1D8 = 0xA; - func_8086DC30(this); - func_8086D4B4(this, globalCtx); - } - break; - case YELLOW_TALL_2: - if (((this->collider.base.acFlags & AC_HIT) != 0) && ((this->unk_1DC & 2) == 0) && this->unk_1D8 <= 0) { - this->unk_1D8 = 0xA; - func_8086DC30(this); - func_8086D4B4(this, globalCtx); - } - break; - } -} - -void func_8086DC30(BgBdanSwitch* this) { - this->actionFunc = func_8086DC48; - this->unk_1DA = 0x64; -} - -void func_8086DC48(BgBdanSwitch* this, GlobalContext* globalCtx) { - if ((func_8005B198() == this->dyna.actor.category) || (this->unk_1DA <= 0)) { - this->unk_1C8 -= 0.3f; - if (this->unk_1C8 <= 1.0f) { - func_8086DCCC(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - } - } -} - -void func_8086DCCC(BgBdanSwitch* this) { - this->actionFunc = func_8086DCE8; - this->unk_1C8 = 1.0f; -} - -void func_8086DCE8(BgBdanSwitch* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xFF) { - case YELLOW_TALL_1: - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - func_8086DDA8(this); - } - break; - case YELLOW_TALL_2: - if (((this->collider.base.acFlags & AC_HIT) != 0) && ((this->unk_1DC & 2) == 0) && (this->unk_1D8 <= 0)) { - this->unk_1D8 = 0xA; - func_8086DDA8(this); - func_8086D548(this, globalCtx); - } - break; - } -} - -void func_8086DDA8(BgBdanSwitch* this) { - this->actionFunc = func_8086DDC0; - this->unk_1DA = 0x64; -} - -void func_8086DDC0(BgBdanSwitch* this, GlobalContext* globalCtx) { - if ((((this->dyna.actor.params & 0xFF) != YELLOW_TALL_2) || (func_8005B198() == this->dyna.actor.category)) || - (this->unk_1DA <= 0)) { - this->unk_1C8 += 0.3f; - if (this->unk_1C8 >= 2.0f) { - func_8086DB4C(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - } - } -} - -void BgBdanSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgBdanSwitch* this = (BgBdanSwitch*)thisx; - s32 type; - - if (this->unk_1DA > 0) { - this->unk_1DA--; - } - this->actionFunc(this, globalCtx); - func_8086D0EC(this); - type = this->dyna.actor.params & 0xFF; - if (type != 3 && type != 4) { - this->unk_1D8--; - } else { - if (!Player_InCsMode(globalCtx) && this->unk_1D8 > 0) { - this->unk_1D8--; - } - this->unk_1DC = this->collider.base.acFlags; - this->collider.base.acFlags &= ~AC_HIT; - this->collider.elements[0].dim.modelSphere.radius = this->unk_1D4 * 370.0f; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void func_8086DF58(BgBdanSwitch* this, GlobalContext* globalCtx, Gfx* dlist) { - func_800D1694(this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + (this->dyna.actor.shape.yOffset * this->unk_1D0), - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_Scale(this->unk_1D4, this->unk_1D0, this->unk_1D4, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, dlist); -} - -void BgBdanSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgBdanSwitch* this = (BgBdanSwitch*)thisx; - - switch (this->dyna.actor.params & 0xFF) { - case YELLOW_HEAVY: - case YELLOW: - func_8086DF58(this, globalCtx, gJabuYellowFloorSwitchDL); - break; - case YELLOW_TALL_1: - case YELLOW_TALL_2: - func_8086DF58(this, globalCtx, gJabuYellowFloorSwitchDL); - Collider_UpdateSpheres(0, &this->collider); - Matrix_MultVec3f(&D_8086E0E0, &this->dyna.actor.focus.pos); - break; - case BLUE: - func_8086DF58(this, globalCtx, gJabuBlueFloorSwitchDL); - break; - } -} diff --git a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.cpp b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.cpp new file mode 100644 index 000000000..95ffee783 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.cpp @@ -0,0 +1,547 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BDAN_SWITCH_Z_BG_BDAN_SWITCH_C +#include "actor_common.h" +/* + * File: z_bg_bdan_switch.c + * Overlay: ovl_Bg_Bdan_Switch + * Description: Switches Inside Lord Jabu-Jabu + */ + +#include "z_bg_bdan_switch.h" +#include "objects/object_bdan_objects/object_bdan_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgBdanSwitch_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgBdanSwitch_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgBdanSwitch_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgBdanSwitch_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void func_8086D5C4(BgBdanSwitch* pthis); +void func_8086D5E0(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D67C(BgBdanSwitch* pthis); +void func_8086D694(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D730(BgBdanSwitch* pthis); +void func_8086D754(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D7FC(BgBdanSwitch* pthis); +void func_8086D80C(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D86C(BgBdanSwitch* pthis); +void func_8086D888(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D8BC(BgBdanSwitch* pthis); +void func_8086D8CC(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D95C(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086D9F8(BgBdanSwitch* pthis); +void func_8086DA1C(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086DAB4(BgBdanSwitch* pthis); +void func_8086DAC4(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086DB24(BgBdanSwitch* pthis); +void func_8086DB40(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086DB4C(BgBdanSwitch* pthis); +void func_8086DB68(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086DC30(BgBdanSwitch* pthis); +void func_8086DC48(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086DCCC(BgBdanSwitch* pthis); +void func_8086DCE8(BgBdanSwitch* pthis, GlobalContext* globalCtx); +void func_8086DDA8(BgBdanSwitch* pthis); +void func_8086DDC0(BgBdanSwitch* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Bdan_Switch_InitVars = { + ACTOR_BG_BDAN_SWITCH, + ACTORCAT_SWITCH, + FLAGS, + OBJECT_BDAN_OBJECTS, + sizeof(BgBdanSwitch), + (ActorFunc)BgBdanSwitch_Init, + (ActorFunc)BgBdanSwitch_Destroy, + (ActorFunc)BgBdanSwitch_Update, + (ActorFunc)BgBdanSwitch_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xEFC1FFFE, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 120, 0 }, 370 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), +}; + +static Vec3f D_8086E0E0 = { 0.0f, 140.0f, 0.0f }; + +void BgBdanSwitch_InitDynaPoly(BgBdanSwitch* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { + s16 pad1; + CollisionHeader* colHeader = NULL; + s16 pad2; + + DynaPolyActor_Init(&pthis->dyna, flag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_bdan_switch.c", 325, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgBdanSwitch_InitCollision(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + Actor* actor = &pthis->dyna.actor; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, actor, &sJntSphInit, pthis->colliderItems); +} + +void func_8086D0EC(BgBdanSwitch* pthis) { + if (pthis->unk_1CC > 0) { + pthis->unk_1CC += 0x5DC; + } else { + pthis->unk_1CC += 0xFA0; + } + + switch (pthis->dyna.actor.params & 0xFF) { + case BLUE: + case YELLOW_HEAVY: + case YELLOW: + pthis->unk_1D4 = ((Math_CosS(pthis->unk_1CC) * 0.5f) + (53.000004f / 6.0f)) * 0.012f; + pthis->unk_1D0 = ((Math_CosS(pthis->unk_1CC) * 0.5f) + 20.5f) * (pthis->unk_1C8 * 0.0050000004f); + pthis->dyna.actor.scale.y = pthis->unk_1C8 * 0.1f; + break; + case YELLOW_TALL_1: + case YELLOW_TALL_2: + pthis->unk_1D4 = ((Math_CosS(pthis->unk_1CC) * 0.5f) + (43.0f / 6.0f)) * 0.0075000003f; + pthis->unk_1D0 = ((Math_CosS(pthis->unk_1CC) * 0.5f) + 20.5f) * (pthis->unk_1C8 * 0.0050000004f); + pthis->dyna.actor.scale.y = pthis->unk_1C8 * 0.1f; + } + pthis->dyna.actor.shape.yOffset = 1.2f / pthis->unk_1D0; +} + +void BgBdanSwitch_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgBdanSwitch* pthis = (BgBdanSwitch*)pthisx; + s32 pad; + s16 type; + s32 flag; + + type = pthis->dyna.actor.params & 0xFF; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + if (type == YELLOW_TALL_1 || type == YELLOW_TALL_2) { + pthis->dyna.actor.scale.z = 0.05f; + pthis->dyna.actor.scale.x = 0.05f; + } else { + pthis->dyna.actor.scale.z = 0.1f; + pthis->dyna.actor.scale.x = 0.1f; + } + pthis->dyna.actor.scale.y = 0.0f; + Actor_SetFocus(&pthis->dyna.actor, 10.0f); + + switch (type) { + case BLUE: + case YELLOW_HEAVY: + case YELLOW: + BgBdanSwitch_InitDynaPoly(pthis, globalCtx, &gJabuFloorSwitchCol, DPM_PLAYER); + break; + case YELLOW_TALL_1: + case YELLOW_TALL_2: + BgBdanSwitch_InitCollision(pthis, globalCtx); + pthis->dyna.actor.flags |= ACTOR_FLAG_0; + pthis->dyna.actor.targetMode = 4; + break; + } + + flag = Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + + switch (type) { + case BLUE: + case YELLOW: + if (flag) { + func_8086D730(pthis); + } else { + func_8086D5C4(pthis); + } + break; + case YELLOW_HEAVY: + if (flag) { + func_8086DB24(pthis); + } else { + func_8086D86C(pthis); + } + break; + case YELLOW_TALL_1: + case YELLOW_TALL_2: + if (flag) { + func_8086DCCC(pthis); + } else { + func_8086DB4C(pthis); + } + break; + default: + osSyncPrintf("不正な ARG_DATA(arg_data 0x%04x)(%s %d)\n", pthis->dyna.actor.params, "../z_bg_bdan_switch.c", + 454); + Actor_Kill(&pthis->dyna.actor); + return; + } + osSyncPrintf("(巨大魚ダンジョン 専用スイッチ)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void BgBdanSwitch_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgBdanSwitch* pthis = (BgBdanSwitch*)pthisx; + + switch (pthis->dyna.actor.params & 0xFF) { + case BLUE: + case YELLOW_HEAVY: + case YELLOW: + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + break; + case YELLOW_TALL_1: + case YELLOW_TALL_2: + Collider_DestroyJntSph(globalCtx, &pthis->collider); + break; + } +} + +void func_8086D4B4(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 type; + + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + type = pthis->dyna.actor.params & 0xFF; + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + if (type == BLUE || type == YELLOW_TALL_2) { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + } else { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->dyna.actor, NA_SE_SY_CORRECT_CHIME); + } + } +} + +void func_8086D548(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + Flags_UnsetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + if ((pthis->dyna.actor.params & 0xFF) == YELLOW_TALL_2) { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + } + } +} + +void func_8086D5C4(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086D5E0; + pthis->unk_1C8 = 1.0f; +} + +void func_8086D5E0(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xFF) { + case BLUE: + if (func_800435B4(&pthis->dyna)) { + func_8086D67C(pthis); + func_8086D4B4(pthis, globalCtx); + } + break; + case YELLOW: + if (func_8004356C(&pthis->dyna)) { + func_8086D67C(pthis); + func_8086D4B4(pthis, globalCtx); + } + break; + } +} + +void func_8086D67C(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086D694; + pthis->unk_1DA = 0x64; +} + +void func_8086D694(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + if ((func_8005B198() == pthis->dyna.actor.category) || (pthis->unk_1DA <= 0)) { + pthis->unk_1C8 -= 0.2f; + if (pthis->unk_1C8 <= 0.1f) { + func_8086D730(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); + } + } +} + +void func_8086D730(BgBdanSwitch* pthis) { + pthis->unk_1C8 = 0.1f; + pthis->actionFunc = func_8086D754; + pthis->unk_1D8 = 6; +} + +void func_8086D754(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xFF) { + case BLUE: + if (!func_800435B4(&pthis->dyna)) { + if (pthis->unk_1D8 <= 0) { + func_8086D7FC(pthis); + func_8086D548(pthis, globalCtx); + } + } else { + pthis->unk_1D8 = 6; + } + break; + case YELLOW: + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8086D7FC(pthis); + } + break; + } +} + +void func_8086D7FC(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086D80C; +} + +void func_8086D80C(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + pthis->unk_1C8 += 0.2f; + if (pthis->unk_1C8 >= 1.0f) { + func_8086D5C4(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } +} + +void func_8086D86C(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086D888; + pthis->unk_1C8 = 1.0f; +} + +void func_8086D888(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + if (func_8004356C(&pthis->dyna)) { + func_8086D8BC(pthis); + } +} + +void func_8086D8BC(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086D8CC; +} + +void func_8086D8CC(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + pthis->unk_1C8 -= 0.2f; + if (pthis->unk_1C8 <= 0.6f) { + func_8086D9F8(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); + } +} + +void func_8086D944(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086D95C; + pthis->unk_1DA = 0x64; +} + +void func_8086D95C(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + if ((func_8005B198() == pthis->dyna.actor.category) || (pthis->unk_1DA <= 0)) { + pthis->unk_1C8 -= 0.2f; + if (pthis->unk_1C8 <= 0.1f) { + func_8086DB24(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); + } + } +} + +void func_8086D9F8(BgBdanSwitch* pthis) { + pthis->unk_1C8 = 0.6f; + pthis->actionFunc = func_8086DA1C; + pthis->unk_1D8 = 6; +} + +void func_8086DA1C(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + Actor* heldActor = GET_PLAYER(globalCtx)->heldActor; + + if (func_8004356C(&pthis->dyna)) { + if (heldActor != NULL && heldActor->id == ACTOR_EN_RU1) { + if (pthis->unk_1D8 <= 0) { + func_8086D944(pthis); + func_8086D4B4(pthis, globalCtx); + } + } else { + pthis->unk_1D8 = 6; + } + } else { + if (pthis->unk_1D8 <= 0) { + func_8086DAB4(pthis); + } + } +} + +void func_8086DAB4(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086DAC4; +} + +void func_8086DAC4(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + pthis->unk_1C8 += 0.2f; + if (pthis->unk_1C8 >= 1.0f) { + func_8086D86C(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } +} + +void func_8086DB24(BgBdanSwitch* pthis) { + pthis->unk_1C8 = 0.1f; + pthis->actionFunc = func_8086DB40; +} + +void func_8086DB40(BgBdanSwitch* pthis, GlobalContext* globalCtx) { +} + +void func_8086DB4C(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086DB68; + pthis->unk_1C8 = 2.0f; +} + +void func_8086DB68(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xFF) { + default: + return; + case YELLOW_TALL_1: + if (((pthis->collider.base.acFlags & AC_HIT) != 0) && pthis->unk_1D8 <= 0) { + pthis->unk_1D8 = 0xA; + func_8086DC30(pthis); + func_8086D4B4(pthis, globalCtx); + } + break; + case YELLOW_TALL_2: + if (((pthis->collider.base.acFlags & AC_HIT) != 0) && ((pthis->unk_1DC & 2) == 0) && pthis->unk_1D8 <= 0) { + pthis->unk_1D8 = 0xA; + func_8086DC30(pthis); + func_8086D4B4(pthis, globalCtx); + } + break; + } +} + +void func_8086DC30(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086DC48; + pthis->unk_1DA = 0x64; +} + +void func_8086DC48(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + if ((func_8005B198() == pthis->dyna.actor.category) || (pthis->unk_1DA <= 0)) { + pthis->unk_1C8 -= 0.3f; + if (pthis->unk_1C8 <= 1.0f) { + func_8086DCCC(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } + } +} + +void func_8086DCCC(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086DCE8; + pthis->unk_1C8 = 1.0f; +} + +void func_8086DCE8(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xFF) { + case YELLOW_TALL_1: + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8086DDA8(pthis); + } + break; + case YELLOW_TALL_2: + if (((pthis->collider.base.acFlags & AC_HIT) != 0) && ((pthis->unk_1DC & 2) == 0) && (pthis->unk_1D8 <= 0)) { + pthis->unk_1D8 = 0xA; + func_8086DDA8(pthis); + func_8086D548(pthis, globalCtx); + } + break; + } +} + +void func_8086DDA8(BgBdanSwitch* pthis) { + pthis->actionFunc = func_8086DDC0; + pthis->unk_1DA = 0x64; +} + +void func_8086DDC0(BgBdanSwitch* pthis, GlobalContext* globalCtx) { + if ((((pthis->dyna.actor.params & 0xFF) != YELLOW_TALL_2) || (func_8005B198() == pthis->dyna.actor.category)) || + (pthis->unk_1DA <= 0)) { + pthis->unk_1C8 += 0.3f; + if (pthis->unk_1C8 >= 2.0f) { + func_8086DB4C(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } + } +} + +void BgBdanSwitch_Update(Actor* pthisx, GlobalContext* globalCtx) { + s32 pad; + BgBdanSwitch* pthis = (BgBdanSwitch*)pthisx; + s32 type; + + if (pthis->unk_1DA > 0) { + pthis->unk_1DA--; + } + pthis->actionFunc(pthis, globalCtx); + func_8086D0EC(pthis); + type = pthis->dyna.actor.params & 0xFF; + if (type != 3 && type != 4) { + pthis->unk_1D8--; + } else { + if (!Player_InCsMode(globalCtx) && pthis->unk_1D8 > 0) { + pthis->unk_1D8--; + } + pthis->unk_1DC = pthis->collider.base.acFlags; + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->collider.elements[0].dim.modelSphere.radius = pthis->unk_1D4 * 370.0f; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void func_8086DF58(BgBdanSwitch* pthis, GlobalContext* globalCtx, Gfx* dlist) { + func_800D1694(pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y + (pthis->dyna.actor.shape.yOffset * pthis->unk_1D0), + pthis->dyna.actor.world.pos.z, &pthis->dyna.actor.shape.rot); + Matrix_Scale(pthis->unk_1D4, pthis->unk_1D0, pthis->unk_1D4, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, dlist); +} + +void BgBdanSwitch_Draw(Actor* pthisx, GlobalContext* globalCtx) { + BgBdanSwitch* pthis = (BgBdanSwitch*)pthisx; + + switch (pthis->dyna.actor.params & 0xFF) { + case YELLOW_HEAVY: + case YELLOW: + func_8086DF58(pthis, globalCtx, gJabuYellowFloorSwitchDL); + break; + case YELLOW_TALL_1: + case YELLOW_TALL_2: + func_8086DF58(pthis, globalCtx, gJabuYellowFloorSwitchDL); + Collider_UpdateSpheres(0, &pthis->collider); + Matrix_MultVec3f(&D_8086E0E0, &pthis->dyna.actor.focus.pos); + break; + case BLUE: + func_8086DF58(pthis, globalCtx, gJabuBlueFloorSwitchDL); + break; + } +} diff --git a/src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.c b/src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.c deleted file mode 100644 index a2fe1178a..000000000 --- a/src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.c +++ /dev/null @@ -1,93 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BOM_GUARD_Z_BG_BOM_GUARD_C -#include "actor_common.h" -/* - * File: z_bg_bom_guard.c - * Overlay: Bg_Bom_Guard - * Description: Bombchu Bowling Alley Walls - */ - -#include "z_bg_bom_guard.h" -#include "overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h" -#include "objects/object_bowl/object_bowl.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/z_bgcheck.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgBomGuard_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBomGuard_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBomGuard_Update(Actor* thisx, GlobalContext* globalCtx); - -void func_8086E638(BgBomGuard* this, GlobalContext* globalCtx); - -const ActorInit Bg_Bom_Guard_InitVars = { - ACTOR_BG_BOM_GUARD, - ACTORCAT_PROP, - FLAGS, - OBJECT_BOWL, - sizeof(BgBomGuard), - (ActorFunc)BgBomGuard_Init, - (ActorFunc)BgBomGuard_Destroy, - (ActorFunc)BgBomGuard_Update, - NULL, -}; - -void BgBomGuard_SetupAction(BgBomGuard* this, BgBomGuardActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void BgBomGuard_Init(Actor* thisx, GlobalContext* globalCtx) { - BgBomGuard* this = (BgBomGuard*)thisx; - s32 pad[2]; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gBowlingDefaultCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 透明ガード出現 ☆☆☆☆☆ \n" VT_RST); - - thisx->scale.x = 1.0f; - thisx->scale.y = 1.0f; - thisx->scale.z = 1.0f; - this->unk_16C = thisx->world.pos; - BgBomGuard_SetupAction(this, func_8086E638); -} - -void BgBomGuard_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgBomGuard* this = (BgBomGuard*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_8086E638(BgBomGuard* this, GlobalContext* globalCtx) { - Actor* it = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; - Actor* thisx = &this->dyna.actor; - - this->unk_168 = 0; - - while (it != 0) { - if (it->id == ACTOR_EN_BOM_BOWL_MAN) { - if ((((EnBomBowlMan*)it)->minigamePlayStatus != 0) && (fabsf(globalCtx->view.eye.x) > -20.0f) && - (fabsf(globalCtx->view.eye.y) > 110.0f)) { - this->unk_168 = 1; - } - break; - } - it = it->next; - } - - if (this->unk_168 == 0) { - thisx->world.pos.y = sREG(64) + -200.0f; - } else { - thisx->world.pos.y = 0.0f; - } -} - -void BgBomGuard_Update(Actor* thisx, GlobalContext* globalCtx) { - BgBomGuard* this = (BgBomGuard*)thisx; - - this->actionFunc(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.cpp b/src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.cpp new file mode 100644 index 000000000..c14a51a19 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Bom_Guard/z_bg_bom_guard.cpp @@ -0,0 +1,93 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BOM_GUARD_Z_BG_BOM_GUARD_C +#include "actor_common.h" +/* + * File: z_bg_bom_guard.c + * Overlay: Bg_Bom_Guard + * Description: Bombchu Bowling Alley Walls + */ + +#include "z_bg_bom_guard.h" +#include "overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h" +#include "objects/object_bowl/object_bowl.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/z_bgcheck.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgBomGuard_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgBomGuard_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgBomGuard_Update(Actor* pthisx, GlobalContext* globalCtx); + +void func_8086E638(BgBomGuard* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Bom_Guard_InitVars = { + ACTOR_BG_BOM_GUARD, + ACTORCAT_PROP, + FLAGS, + OBJECT_BOWL, + sizeof(BgBomGuard), + (ActorFunc)BgBomGuard_Init, + (ActorFunc)BgBomGuard_Destroy, + (ActorFunc)BgBomGuard_Update, + NULL, +}; + +void BgBomGuard_SetupAction(BgBomGuard* pthis, BgBomGuardActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void BgBomGuard_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgBomGuard* pthis = (BgBomGuard*)pthisx; + s32 pad[2]; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gBowlingDefaultCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, pthisx, colHeader); + + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 透明ガード出現 ☆☆☆☆☆ \n" VT_RST); + + pthisx->scale.x = 1.0f; + pthisx->scale.y = 1.0f; + pthisx->scale.z = 1.0f; + pthis->unk_16C = pthisx->world.pos; + BgBomGuard_SetupAction(pthis, func_8086E638); +} + +void BgBomGuard_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgBomGuard* pthis = (BgBomGuard*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_8086E638(BgBomGuard* pthis, GlobalContext* globalCtx) { + Actor* it = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; + Actor* pthisx = &pthis->dyna.actor; + + pthis->unk_168 = 0; + + while (it != 0) { + if (it->id == ACTOR_EN_BOM_BOWL_MAN) { + if ((((EnBomBowlMan*)it)->minigamePlayStatus != 0) && (fabsf(globalCtx->view.eye.x) > -20.0f) && + (fabsf(globalCtx->view.eye.y) > 110.0f)) { + pthis->unk_168 = 1; + } + break; + } + it = it->next; + } + + if (pthis->unk_168 == 0) { + pthisx->world.pos.y = sREG(64) + -200.0f; + } else { + pthisx->world.pos.y = 0.0f; + } +} + +void BgBomGuard_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgBomGuard* pthis = (BgBomGuard*)pthisx; + + pthis->actionFunc(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.c b/src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.cpp similarity index 50% rename from src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.c rename to src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.cpp index 6cdde621e..53ab69b8a 100644 --- a/src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.cpp @@ -18,16 +18,16 @@ #define FLAGS ACTOR_FLAG_22 -void BgBombwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBombwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgBombwall_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgBombwall_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgBombwall_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgBombwall_Draw(Actor* pthisx, GlobalContext* globalCtx); -void func_8086ED50(BgBombwall* this, GlobalContext* globalCtx); -void func_8086ED70(BgBombwall* this, GlobalContext* globalCtx); -void func_8086EDFC(BgBombwall* this, GlobalContext* globalCtx); -void func_8086EE40(BgBombwall* this, GlobalContext* globalCtx); -void func_8086EE94(BgBombwall* this, GlobalContext* globalCtx); +void func_8086ED50(BgBombwall* pthis, GlobalContext* globalCtx); +void func_8086ED70(BgBombwall* pthis, GlobalContext* globalCtx); +void func_8086EDFC(BgBombwall* pthis, GlobalContext* globalCtx); +void func_8086EE40(BgBombwall* pthis, GlobalContext* globalCtx); +void func_8086EE94(BgBombwall* pthis, GlobalContext* globalCtx); static ColliderTrisElementInit sTrisElementsInit[3] = { { @@ -78,7 +78,7 @@ static ColliderTrisInit sTrisInit = { sTrisElementsInit, }; -const ActorInit Bg_Bombwall_InitVars = { +ActorInit Bg_Bombwall_InitVars = { ACTOR_BG_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -90,19 +90,19 @@ const ActorInit Bg_Bombwall_InitVars = { (ActorFunc)BgBombwall_Draw, }; -void BgBombwall_InitDynapoly(BgBombwall* this, GlobalContext* globalCtx) { +void BgBombwall_InitDynapoly(BgBombwall* pthis, GlobalContext* globalCtx) { s32 pad; s32 pad2; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gBgBombwallCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + if (pthis->dyna.bgId == BG_ACTOR_MAX) { // "Warning : move BG login failed" osSyncPrintf("Warning : move BG 登録失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_bombwall.c", 243, - this->dyna.actor.params); + pthis->dyna.actor.params); } } @@ -118,26 +118,26 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void BgBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgBombwall_Init(Actor* pthisx, GlobalContext* globalCtx) { s32 i; s32 j; Vec3f vecs[3]; Vec3f sp80; s32 pad; - BgBombwall* this = (BgBombwall*)thisx; - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + BgBombwall* pthis = (BgBombwall*)pthisx; + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Actor_SetScale(&this->dyna.actor, 0.1f); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + Actor_SetScale(&pthis->dyna.actor, 0.1f); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - func_8086EE94(this, globalCtx); + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + func_8086EE94(pthis, globalCtx); } else { - BgBombwall_InitDynapoly(this, globalCtx); - this->unk_2A2 |= 2; - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderItems); + BgBombwall_InitDynapoly(pthis, globalCtx); + pthis->unk_2A2 |= 2; + Collider_InitTris(globalCtx, &pthis->collider); + Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInit, pthis->colliderItems); for (i = 0; i <= 2; i++) { for (j = 0; j <= 2; j++) { @@ -147,51 +147,51 @@ void BgBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { BgBombwall_RotateVec(&vecs[j], &sp80, sin, cos); - vecs[j].x += this->dyna.actor.world.pos.x; - vecs[j].y += this->dyna.actor.world.pos.y; - vecs[j].z += this->dyna.actor.world.pos.z; + vecs[j].x += pthis->dyna.actor.world.pos.x; + vecs[j].y += pthis->dyna.actor.world.pos.y; + vecs[j].z += pthis->dyna.actor.world.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &vecs[0], &vecs[1], &vecs[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vecs[0], &vecs[1], &vecs[2]); } - this->unk_2A2 |= 1; - func_8086ED50(this, globalCtx); + pthis->unk_2A2 |= 1; + func_8086ED50(pthis, globalCtx); } - osSyncPrintf("(field keep 汎用爆弾壁)(arg_data 0x%04x)(angY %d)\n", this->dyna.actor.params, - this->dyna.actor.shape.rot.y); + osSyncPrintf("(field keep 汎用爆弾壁)(arg_data 0x%04x)(angY %d)\n", pthis->dyna.actor.params, + pthis->dyna.actor.shape.rot.y); } -void BgBombwall_DestroyCollision(BgBombwall* this, GlobalContext* globalCtx) { - if (this->unk_2A2 & 2) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->unk_2A2 &= ~2; +void BgBombwall_DestroyCollision(BgBombwall* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2A2 & 2) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->unk_2A2 &= ~2; } - if (this->unk_2A2 & 1) { - Collider_DestroyTris(globalCtx, &this->collider); - this->unk_2A2 &= ~1; + if (pthis->unk_2A2 & 1) { + Collider_DestroyTris(globalCtx, &pthis->collider); + pthis->unk_2A2 &= ~1; } } -void BgBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgBombwall* this = (BgBombwall*)thisx; +void BgBombwall_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgBombwall* pthis = (BgBombwall*)pthisx; - BgBombwall_DestroyCollision(this, globalCtx); + BgBombwall_DestroyCollision(pthis, globalCtx); } static Vec3s D_8086F010[] = { { 40, 85, 21 }, { -43, 107, 14 }, { -1, 142, 14 }, { -27, 44, 27 }, { 28, 24, 20 }, { -39, 54, 21 }, { 49, 50, 20 }, }; -void func_8086EB5C(BgBombwall* this, GlobalContext* globalCtx) { +void func_8086EB5C(BgBombwall* pthis, GlobalContext* globalCtx) { s16 rand; s16 rand2; Vec3f sp88; s32 i; - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); - Vec3f* pos = &this->dyna.actor.world.pos; + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); + Vec3f* pos = &pthis->dyna.actor.world.pos; f32 temp; f32 new_var; @@ -213,56 +213,56 @@ void func_8086EB5C(BgBombwall* this, GlobalContext* globalCtx) { func_80033480(globalCtx, &sp88, 40.0f, 4, 0xA, 0x32, 1); } -void func_8086ED50(BgBombwall* this, GlobalContext* globalCtx) { - this->dList = gBgBombwallNormalDL; - this->actionFunc = func_8086ED70; +void func_8086ED50(BgBombwall* pthis, GlobalContext* globalCtx) { + pthis->dList = gBgBombwallNormalDL; + pthis->actionFunc = func_8086ED70; } -void func_8086ED70(BgBombwall* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - func_8086EDFC(this, globalCtx); - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - } else if (this->dyna.actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +void func_8086ED70(BgBombwall* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + func_8086EDFC(pthis, globalCtx); + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + } else if (pthis->dyna.actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void func_8086EDFC(BgBombwall* this, GlobalContext* globalCtx) { - this->dList = gBgBombwallNormalDL; - this->unk_2A0 = 1; - func_8086EB5C(this, globalCtx); - this->actionFunc = func_8086EE40; +void func_8086EDFC(BgBombwall* pthis, GlobalContext* globalCtx) { + pthis->dList = gBgBombwallNormalDL; + pthis->unk_2A0 = 1; + func_8086EB5C(pthis, globalCtx); + pthis->actionFunc = func_8086EE40; } -void func_8086EE40(BgBombwall* this, GlobalContext* globalCtx) { - if (this->unk_2A0 > 0) { - this->unk_2A0--; +void func_8086EE40(BgBombwall* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2A0 > 0) { + pthis->unk_2A0--; } else { - func_8086EE94(this, globalCtx); + func_8086EE94(pthis, globalCtx); - if (((this->dyna.actor.params >> 0xF) & 1) != 0) { + if (((pthis->dyna.actor.params >> 0xF) & 1) != 0) { func_80078884(NA_SE_SY_CORRECT_CHIME); } } } -void func_8086EE94(BgBombwall* this, GlobalContext* globalCtx) { - this->dList = gBgBombwallBrokenDL; - BgBombwall_DestroyCollision(this, globalCtx); - this->actionFunc = NULL; +void func_8086EE94(BgBombwall* pthis, GlobalContext* globalCtx) { + pthis->dList = gBgBombwallBrokenDL; + BgBombwall_DestroyCollision(pthis, globalCtx); + pthis->actionFunc = NULL; } -void BgBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { - BgBombwall* this = (BgBombwall*)thisx; +void BgBombwall_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgBombwall* pthis = (BgBombwall*)pthisx; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } } -void BgBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgBombwall* this = (BgBombwall*)thisx; +void BgBombwall_Draw(Actor* pthisx, GlobalContext* globalCtx) { + BgBombwall* pthis = (BgBombwall*)pthisx; - Gfx_DrawDListOpa(globalCtx, this->dList); + Gfx_DrawDListOpa(globalCtx, pthis->dList); } diff --git a/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c b/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c deleted file mode 100644 index 88ff29ecd..000000000 --- a/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.c +++ /dev/null @@ -1,230 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BOWL_WALL_Z_BG_BOWL_WALL_C -#include "actor_common.h" -/* - * File: z_bg_bowl_wall.c - * Overlay: Bg_Bowl_Wall - * Description: Bombchu Bowling Alley Wall - */ - -#include "z_bg_bowl_wall.h" -#include "overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_bowl/object_bowl.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_quake.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgBowlWall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBowlWall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBowlWall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgBowlWall_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgBowlWall_SpawnBullseyes(BgBowlWall* this, GlobalContext* globalCtx); -void BgBowlWall_WaitForHit(BgBowlWall* this, GlobalContext* globalCtx); -void BgBowlWall_FallDoEffects(BgBowlWall* this, GlobalContext* globalCtx); -void BgBowlWall_FinishFall(BgBowlWall* this, GlobalContext* globalCtx); -void BgBowlWall_Reset(BgBowlWall* this, GlobalContext* globalCtx); - -const ActorInit Bg_Bowl_Wall_InitVars = { - ACTOR_BG_BOWL_WALL, - ACTORCAT_PROP, - FLAGS, - OBJECT_BOWL, - sizeof(BgBowlWall), - (ActorFunc)BgBowlWall_Init, - (ActorFunc)BgBowlWall_Destroy, - (ActorFunc)BgBowlWall_Update, - (ActorFunc)BgBowlWall_Draw, -}; - -static Vec3f sBullseyeOffset[] = { - { 0.0f, 210.0f, -20.0f }, - { 0.0f, 170.0f, -20.0f }, - { -170.0f, 0.0f, -20.0f }, - { 170.0f, 0.0f, -20.0f }, -}; - -static s16 sTargetRot[] = { 0x0000, 0x0000, 0x3FFF, -0x3FFF }; - -void BgBowlWall_Init(Actor* thisx, GlobalContext* globalCtx) { - BgBowlWall* this = (BgBowlWall*)thisx; - s32 pad1; - s32 pad2; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - - if (this->dyna.actor.params == 0) { - CollisionHeader_GetVirtual(&gBowlingFirstAndFinalRoundCol, &colHeader); - } else { - CollisionHeader_GetVirtual(&gBowlingSecondRoundCol, &colHeader); - } - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->initPos = this->dyna.actor.world.pos; - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ ボーリングおじゃま壁発生 ☆☆☆☆☆ %d\n" VT_RST, this->dyna.actor.params); - this->actionFunc = BgBowlWall_SpawnBullseyes; - this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = 1.0f; -} - -void BgBowlWall_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgBowlWall* this = (BgBowlWall*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgBowlWall_SpawnBullseyes(BgBowlWall* this, GlobalContext* globalCtx) { - s32 pad; - EnWallTubo* bullseye; - Actor* lookForGirl; - s16 type; - - type = this->dyna.actor.params; - if (type != 0) { - type += (s16)Rand_ZeroFloat(2.99f); - this->dyna.actor.shape.rot.z = this->dyna.actor.world.rot.z = sTargetRot[type]; - osSyncPrintf("\n\n"); - } - this->bullseyeCenter.x = sBullseyeOffset[type].x + this->dyna.actor.world.pos.x; - this->bullseyeCenter.y = sBullseyeOffset[type].y + this->dyna.actor.world.pos.y; - this->bullseyeCenter.z = sBullseyeOffset[type].z + this->dyna.actor.world.pos.z; - if (1) {} - bullseye = (EnWallTubo*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_WALL_TUBO, - this->bullseyeCenter.x, this->bullseyeCenter.y, this->bullseyeCenter.z, - 0, 0, 0, this->dyna.actor.params); - if (bullseye != NULL) { - bullseye->explosionCenter = this->bullseyeCenter; - if (type != 0) { - bullseye->explosionCenter = this->bullseyeCenter = this->dyna.actor.world.pos; - } - if (this->chuGirl == NULL) { - lookForGirl = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; - while (lookForGirl != NULL) { - if (lookForGirl->id != ACTOR_EN_BOM_BOWL_MAN) { - lookForGirl = lookForGirl->next; - } else { - this->chuGirl = (EnBomBowlMan*)lookForGirl; - break; - } - } - } - this->actionFunc = BgBowlWall_WaitForHit; - } -} - -void BgBowlWall_WaitForHit(BgBowlWall* this, GlobalContext* globalCtx) { - if (this->isHit) { - this->actionFunc = BgBowlWall_FallDoEffects; - } -} - -void BgBowlWall_FallDoEffects(BgBowlWall* this, GlobalContext* globalCtx) { - s16 pad; - Vec3f effectAccel = { 0.0f, 0.1f, 0.0f }; - Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; - Vec3f effectPos; - s16 quakeIndex; - s32 wallFallen; - s32 i; - - wallFallen = false; - - if (this->dyna.actor.params == 0) { // wall collapses backwards - Math_SmoothStepToS(&this->dyna.actor.shape.rot.x, -0x3E80, 3, 500, 0); - this->dyna.actor.world.rot.x = this->dyna.actor.shape.rot.x; - if (this->dyna.actor.shape.rot.x < -0x3C1E) { - wallFallen = true; - } - } else { // wall slides downwards - Math_ApproachF(&this->dyna.actor.world.pos.y, this->initPos.y - 450.0f, 0.3f, 10.0f); - if (this->dyna.actor.world.pos.y < (this->initPos.y - 400.0f)) { - wallFallen = true; - } - } - - if (wallFallen) { - for (i = 0; i < 15; i++) { - effectPos.x = Rand_CenteredFloat(300.0f) + this->bullseyeCenter.x; - effectPos.y = -100.0f; - effectPos.z = Rand_CenteredFloat(400.0f) + this->bullseyeCenter.z; - EffectSsBomb2_SpawnLayered(globalCtx, &effectPos, &effectVelocity, &effectAccel, 100, 30); - effectPos.y = -50.0f; - EffectSsHahen_SpawnBurst(globalCtx, &effectPos, 10.0f, 0, 50, 15, 3, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); - } - quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); - Quake_SetSpeed(quakeIndex, 0x7FFF); - Quake_SetQuakeValues(quakeIndex, 300, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 30); - this->timer = 20; - this->actionFunc = BgBowlWall_FinishFall; - } -} - -void BgBowlWall_FinishFall(BgBowlWall* this, GlobalContext* globalCtx) { - if (this->timer >= 2) { - if (this->dyna.actor.params == 0) { - Math_SmoothStepToS(&this->dyna.actor.shape.rot.x, -0x3E80, 1, 200, 0); - } else { - Math_ApproachF(&this->dyna.actor.world.pos.y, this->initPos.y - 450.0f, 0.3f, 10.0f); - } - } else if (this->timer == 1) { - this->dyna.actor.world.rot.x = this->dyna.actor.shape.rot.x = 0; - this->dyna.actor.world.pos.y = this->initPos.y - 450.0f; - this->chuGirl->wallStatus[this->dyna.actor.params] = 2; - this->actionFunc = BgBowlWall_Reset; - } -} - -void BgBowlWall_Reset(BgBowlWall* this, GlobalContext* globalCtx) { - if (this->chuGirl->wallStatus[this->dyna.actor.params] != 2) { - Math_ApproachF(&this->dyna.actor.world.pos.y, this->initPos.y, 0.3f, 50.0f); - if (fabsf(this->dyna.actor.world.pos.y - this->initPos.y) <= 10.0f) { - this->dyna.actor.world.pos.y = this->initPos.y; - this->isHit = false; - this->actionFunc = BgBowlWall_SpawnBullseyes; - } - } -} - -void BgBowlWall_Update(Actor* thisx, GlobalContext* globalCtx) { - BgBowlWall* this = (BgBowlWall*)thisx; - - if (this->timer != 0) { - this->timer--; - } - - this->actionFunc(this, globalCtx); -} - -void BgBowlWall_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BgBowlWall* this = (BgBowlWall*)thisx; - u32 frames; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_bowl_wall.c", 441); - - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x8, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, -2 * (frames = globalCtx->state.frames), 16, 16)); - gDPPipeSync(POLY_OPA_DISP++); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_bowl_wall.c", 453), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (this->dyna.actor.params == 0) { - gSPDisplayList(POLY_OPA_DISP++, gBowlingRound1WallDL); - } else { - gSPDisplayList(POLY_OPA_DISP++, gBowlingRound2WallDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_bowl_wall.c", 464); -} diff --git a/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.cpp b/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.cpp new file mode 100644 index 000000000..e830ee185 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Bowl_Wall/z_bg_bowl_wall.cpp @@ -0,0 +1,230 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_BOWL_WALL_Z_BG_BOWL_WALL_C +#include "actor_common.h" +/* + * File: z_bg_bowl_wall.c + * Overlay: Bg_Bowl_Wall + * Description: Bombchu Bowling Alley Wall + */ + +#include "z_bg_bowl_wall.h" +#include "overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_bowl/object_bowl.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_quake.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgBowlWall_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgBowlWall_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgBowlWall_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgBowlWall_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void BgBowlWall_SpawnBullseyes(BgBowlWall* pthis, GlobalContext* globalCtx); +void BgBowlWall_WaitForHit(BgBowlWall* pthis, GlobalContext* globalCtx); +void BgBowlWall_FallDoEffects(BgBowlWall* pthis, GlobalContext* globalCtx); +void BgBowlWall_FinishFall(BgBowlWall* pthis, GlobalContext* globalCtx); +void BgBowlWall_Reset(BgBowlWall* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Bowl_Wall_InitVars = { + ACTOR_BG_BOWL_WALL, + ACTORCAT_PROP, + FLAGS, + OBJECT_BOWL, + sizeof(BgBowlWall), + (ActorFunc)BgBowlWall_Init, + (ActorFunc)BgBowlWall_Destroy, + (ActorFunc)BgBowlWall_Update, + (ActorFunc)BgBowlWall_Draw, +}; + +static Vec3f sBullseyeOffset[] = { + { 0.0f, 210.0f, -20.0f }, + { 0.0f, 170.0f, -20.0f }, + { -170.0f, 0.0f, -20.0f }, + { 170.0f, 0.0f, -20.0f }, +}; + +static s16 sTargetRot[] = { 0x0000, 0x0000, 0x3FFF, -0x3FFF }; + +void BgBowlWall_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgBowlWall* pthis = (BgBowlWall*)pthisx; + s32 pad1; + s32 pad2; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + + if (pthis->dyna.actor.params == 0) { + CollisionHeader_GetVirtual(&gBowlingFirstAndFinalRoundCol, &colHeader); + } else { + CollisionHeader_GetVirtual(&gBowlingSecondRoundCol, &colHeader); + } + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->initPos = pthis->dyna.actor.world.pos; + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ ボーリングおじゃま壁発生 ☆☆☆☆☆ %d\n" VT_RST, pthis->dyna.actor.params); + pthis->actionFunc = BgBowlWall_SpawnBullseyes; + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.y = pthis->dyna.actor.scale.z = 1.0f; +} + +void BgBowlWall_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgBowlWall* pthis = (BgBowlWall*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgBowlWall_SpawnBullseyes(BgBowlWall* pthis, GlobalContext* globalCtx) { + s32 pad; + EnWallTubo* bullseye; + Actor* lookForGirl; + s16 type; + + type = pthis->dyna.actor.params; + if (type != 0) { + type += (s16)Rand_ZeroFloat(2.99f); + pthis->dyna.actor.shape.rot.z = pthis->dyna.actor.world.rot.z = sTargetRot[type]; + osSyncPrintf("\n\n"); + } + pthis->bullseyeCenter.x = sBullseyeOffset[type].x + pthis->dyna.actor.world.pos.x; + pthis->bullseyeCenter.y = sBullseyeOffset[type].y + pthis->dyna.actor.world.pos.y; + pthis->bullseyeCenter.z = sBullseyeOffset[type].z + pthis->dyna.actor.world.pos.z; + if (1) {} + bullseye = (EnWallTubo*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_WALL_TUBO, + pthis->bullseyeCenter.x, pthis->bullseyeCenter.y, pthis->bullseyeCenter.z, + 0, 0, 0, pthis->dyna.actor.params); + if (bullseye != NULL) { + bullseye->explosionCenter = pthis->bullseyeCenter; + if (type != 0) { + bullseye->explosionCenter = pthis->bullseyeCenter = pthis->dyna.actor.world.pos; + } + if (pthis->chuGirl == NULL) { + lookForGirl = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; + while (lookForGirl != NULL) { + if (lookForGirl->id != ACTOR_EN_BOM_BOWL_MAN) { + lookForGirl = lookForGirl->next; + } else { + pthis->chuGirl = (EnBomBowlMan*)lookForGirl; + break; + } + } + } + pthis->actionFunc = BgBowlWall_WaitForHit; + } +} + +void BgBowlWall_WaitForHit(BgBowlWall* pthis, GlobalContext* globalCtx) { + if (pthis->isHit) { + pthis->actionFunc = BgBowlWall_FallDoEffects; + } +} + +void BgBowlWall_FallDoEffects(BgBowlWall* pthis, GlobalContext* globalCtx) { + s16 pad; + Vec3f effectAccel = { 0.0f, 0.1f, 0.0f }; + Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; + Vec3f effectPos; + s16 quakeIndex; + s32 wallFallen; + s32 i; + + wallFallen = false; + + if (pthis->dyna.actor.params == 0) { // wall collapses backwards + Math_SmoothStepToS(&pthis->dyna.actor.shape.rot.x, -0x3E80, 3, 500, 0); + pthis->dyna.actor.world.rot.x = pthis->dyna.actor.shape.rot.x; + if (pthis->dyna.actor.shape.rot.x < -0x3C1E) { + wallFallen = true; + } + } else { // wall slides downwards + Math_ApproachF(&pthis->dyna.actor.world.pos.y, pthis->initPos.y - 450.0f, 0.3f, 10.0f); + if (pthis->dyna.actor.world.pos.y < (pthis->initPos.y - 400.0f)) { + wallFallen = true; + } + } + + if (wallFallen) { + for (i = 0; i < 15; i++) { + effectPos.x = Rand_CenteredFloat(300.0f) + pthis->bullseyeCenter.x; + effectPos.y = -100.0f; + effectPos.z = Rand_CenteredFloat(400.0f) + pthis->bullseyeCenter.z; + EffectSsBomb2_SpawnLayered(globalCtx, &effectPos, &effectVelocity, &effectAccel, 100, 30); + effectPos.y = -50.0f; + EffectSsHahen_SpawnBurst(globalCtx, &effectPos, 10.0f, 0, 50, 15, 3, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + } + quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); + Quake_SetSpeed(quakeIndex, 0x7FFF); + Quake_SetQuakeValues(quakeIndex, 300, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 30); + pthis->timer = 20; + pthis->actionFunc = BgBowlWall_FinishFall; + } +} + +void BgBowlWall_FinishFall(BgBowlWall* pthis, GlobalContext* globalCtx) { + if (pthis->timer >= 2) { + if (pthis->dyna.actor.params == 0) { + Math_SmoothStepToS(&pthis->dyna.actor.shape.rot.x, -0x3E80, 1, 200, 0); + } else { + Math_ApproachF(&pthis->dyna.actor.world.pos.y, pthis->initPos.y - 450.0f, 0.3f, 10.0f); + } + } else if (pthis->timer == 1) { + pthis->dyna.actor.world.rot.x = pthis->dyna.actor.shape.rot.x = 0; + pthis->dyna.actor.world.pos.y = pthis->initPos.y - 450.0f; + pthis->chuGirl->wallStatus[pthis->dyna.actor.params] = 2; + pthis->actionFunc = BgBowlWall_Reset; + } +} + +void BgBowlWall_Reset(BgBowlWall* pthis, GlobalContext* globalCtx) { + if (pthis->chuGirl->wallStatus[pthis->dyna.actor.params] != 2) { + Math_ApproachF(&pthis->dyna.actor.world.pos.y, pthis->initPos.y, 0.3f, 50.0f); + if (fabsf(pthis->dyna.actor.world.pos.y - pthis->initPos.y) <= 10.0f) { + pthis->dyna.actor.world.pos.y = pthis->initPos.y; + pthis->isHit = false; + pthis->actionFunc = BgBowlWall_SpawnBullseyes; + } + } +} + +void BgBowlWall_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgBowlWall* pthis = (BgBowlWall*)pthisx; + + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actionFunc(pthis, globalCtx); +} + +void BgBowlWall_Draw(Actor* pthisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgBowlWall* pthis = (BgBowlWall*)pthisx; + u32 frames; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_bowl_wall.c", 441); + + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x8, + Gfx_TexScroll(globalCtx->state.gfxCtx, 0, -2 * (frames = globalCtx->state.frames), 16, 16)); + gDPPipeSync(POLY_OPA_DISP++); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_bowl_wall.c", 453), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (pthis->dyna.actor.params == 0) { + gSPDisplayList(POLY_OPA_DISP++, gBowlingRound1WallDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gBowlingRound2WallDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_bowl_wall.c", 464); +} diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp similarity index 64% rename from src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c rename to src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp index 89e834109..a5853bb7d 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp @@ -31,16 +31,16 @@ typedef struct { /* 0x08 */ s8 colType; } BombableWallInfo; -void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgBreakwall_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgBreakwall_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgBreakwall_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgBreakwall_Draw(Actor* pthisx, GlobalContext* globalCtx); -void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx); -void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx); -void BgBreakwall_LavaCoverMove(BgBreakwall* this, GlobalContext* globalCtx); +void BgBreakwall_WaitForObject(BgBreakwall* pthis, GlobalContext* globalCtx); +void BgBreakwall_Wait(BgBreakwall* pthis, GlobalContext* globalCtx); +void BgBreakwall_LavaCoverMove(BgBreakwall* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Breakwall_InitVars = { +ActorInit Bg_Breakwall_InitVars = { ACTOR_BG_BREAKWALL, ACTORCAT_BG, FLAGS, @@ -86,58 +86,58 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; -void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgBreakwall_SetupAction(BgBreakwall* pthis, BgBreakwallActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { - BgBreakwall* this = (BgBreakwall*)thisx; +void BgBreakwall_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgBreakwall* pthis = (BgBreakwall*)pthisx; s32 pad; - s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; + s32 wallType = ((pthis->dyna.actor.params >> 13) & 3) & 0xFF; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - this->bombableWallDList = sBombableWallInfo[wallType].dList; - this->colType = sBombableWallInfo[wallType].colType; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + pthis->bombableWallDList = sBombableWallInfo[wallType].dList; + pthis->colType = sBombableWallInfo[wallType].colType; - if (this->colType == 1) { - this->dyna.actor.world.rot.x = 0x4000; + if (pthis->colType == 1) { + pthis->dyna.actor.world.rot.x = 0x4000; } - if (this->bombableWallDList != NULL) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - Actor_Kill(&this->dyna.actor); + if (pthis->bombableWallDList != NULL) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + Actor_Kill(&pthis->dyna.actor); return; } - ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sQuadInit); + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, NULL, 0.0f); + Collider_InitQuad(globalCtx, &pthis->collider); + Collider_SetQuad(globalCtx, &pthis->collider, &pthis->dyna.actor, &sQuadInit); } else { - this->dyna.actor.world.pos.y -= 40.0f; + pthis->dyna.actor.world.pos.y -= 40.0f; } - this->bankIndex = (wallType >= BWALL_KD_FLOOR) ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_KINGDODONGO) + pthis->bankIndex = (wallType >= BWALL_KD_FLOOR) ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_KINGDODONGO) : Object_GetIndex(&globalCtx->objectCtx, OBJECT_BWALL); - if (this->bankIndex < 0) { - Actor_Kill(&this->dyna.actor); + if (pthis->bankIndex < 0) { + Actor_Kill(&pthis->dyna.actor); } else { - BgBreakwall_SetupAction(this, BgBreakwall_WaitForObject); + BgBreakwall_SetupAction(pthis, BgBreakwall_WaitForObject); } } -void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgBreakwall* this = (BgBreakwall*)thisx; +void BgBreakwall_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgBreakwall* pthis = (BgBreakwall*)pthisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } /** * Spawns fragments using ACTOR_EN_A_OBJ whenever the wall or floor is exploded. * Returns the last spawned actor */ -Actor* BgBreakwall_SpawnFragments(GlobalContext* globalCtx, BgBreakwall* this, Vec3f* pos, f32 velocity, f32 scaleY, +Actor* BgBreakwall_SpawnFragments(GlobalContext* globalCtx, BgBreakwall* pthis, Vec3f* pos, f32 velocity, f32 scaleY, f32 scaleX, s32 count, f32 accel) { Actor* actor = NULL; Vec3f actorPos; @@ -175,10 +175,10 @@ Actor* BgBreakwall_SpawnFragments(GlobalContext* globalCtx, BgBreakwall* this, V } for (i = 0; i < count; angle2 += 0x4000, i++) { - angle1 = ABS(this->dyna.actor.world.rot.y) + angle2; - Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + angle1 = ABS(pthis->dyna.actor.world.rot.y) + angle2; + Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, + Matrix_RotateZYX(pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, MTXMODE_APPLY); Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); @@ -200,7 +200,7 @@ Actor* BgBreakwall_SpawnFragments(GlobalContext* globalCtx, BgBreakwall* this, V actor->world.rot.y += (s16)((Rand_ZeroOne() - 0.5f) * 3000.0f); actor->world.rot.x = (s16)(Rand_ZeroOne() * 3500.0f) + 2000; actor->world.rot.z = (s16)(Rand_ZeroOne() * 3500.0f) + 2000; - actor->parent = &this->dyna.actor; + actor->parent = &pthis->dyna.actor; actor->scale.x = actorScaleList[k].x + Rand_CenteredFloat(0.001f); actor->scale.y = actorScaleList[k].y + Rand_CenteredFloat(0.001f); actor->scale.z = actorScaleList[k].z + Rand_CenteredFloat(0.001f); @@ -215,22 +215,22 @@ Actor* BgBreakwall_SpawnFragments(GlobalContext* globalCtx, BgBreakwall* this, V /** * Sets up the collision model as well is the object dependency and action function to use. */ -void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { +void BgBreakwall_WaitForObject(BgBreakwall* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->bankIndex)) { CollisionHeader* colHeader = NULL; - s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; + s32 wallType = ((pthis->dyna.actor.params >> 13) & 3) & 0xFF; - this->dyna.actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); - this->dyna.actor.flags &= ~ACTOR_FLAG_4; - this->dyna.actor.draw = BgBreakwall_Draw; + pthis->dyna.actor.objBankIndex = pthis->bankIndex; + Actor_SetObjectDependency(globalCtx, &pthis->dyna.actor); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; + pthis->dyna.actor.draw = BgBreakwall_Draw; CollisionHeader_GetVirtual(sBombableWallInfo[wallType].colHeader, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); if (wallType == BWALL_KD_LAVA_COVER) { - BgBreakwall_SetupAction(this, BgBreakwall_LavaCoverMove); + BgBreakwall_SetupAction(pthis, BgBreakwall_LavaCoverMove); } else { - BgBreakwall_SetupAction(this, BgBreakwall_Wait); + BgBreakwall_SetupAction(pthis, BgBreakwall_Wait); } } } @@ -239,28 +239,28 @@ void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx) { * Checks for an explosion using quad collision. If the wall or floor is exploded then it will spawn fragments and * despawn itself. */ -void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & 2) { +void BgBreakwall_Wait(BgBreakwall* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & 2) { Vec3f effectPos; - s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; + s32 wallType = ((pthis->dyna.actor.params >> 13) & 3) & 0xFF; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); effectPos.y = effectPos.z = effectPos.x = 0.0f; - if (this->dyna.actor.world.rot.x == 0) { + if (pthis->dyna.actor.world.rot.x == 0) { effectPos.y = 55.0f; } else { effectPos.z = 25.0f; effectPos.y = -10.0f; } - BgBreakwall_SpawnFragments(globalCtx, this, &effectPos, 0.0f, 6.4f, 5.0f, 1, 2.0f); - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); + BgBreakwall_SpawnFragments(globalCtx, pthis, &effectPos, 0.0f, 6.4f, 5.0f, 1, 2.0f); + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); if (wallType == BWALL_KD_FLOOR) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_EXPLOSION); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_EXPLOSION); } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WALL_BROKEN); } if ((wallType == BWALL_DC_ENTRANCE) && (!(Flags_GetEventChkInf(0xB0)))) { @@ -271,11 +271,11 @@ void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) { func_8002DF54(globalCtx, NULL, 0x31); } - if (this->dyna.actor.params < 0) { + if (pthis->dyna.actor.params < 0) { Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } @@ -283,14 +283,14 @@ void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) { * Moves the actor's y position to cover the lava floor in King Dodongo's lair after he is defeated so the player is no * longer hurt by the lava. */ -void BgBreakwall_LavaCoverMove(BgBreakwall* this, GlobalContext* globalCtx) { - Math_StepToF(&this->dyna.actor.world.pos.y, KREG(80) + this->dyna.actor.home.pos.y, 1.0f); +void BgBreakwall_LavaCoverMove(BgBreakwall* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->dyna.actor.world.pos.y, KREG(80) + pthis->dyna.actor.home.pos.y, 1.0f); } -void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) { - BgBreakwall* this = (BgBreakwall*)thisx; +void BgBreakwall_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgBreakwall* pthis = (BgBreakwall*)pthisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } /** @@ -302,21 +302,21 @@ static Vec3f sColQuadList[][4] = { { { 10.0f, 0.0f, 10.0f }, { -10.0f, 0.0f, 10.0f }, { 10.0f, 0.0f, -10.0f }, { -10.0f, 0.0f, -10.0f } }, }; -void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgBreakwall_Draw(Actor* pthisx, GlobalContext* globalCtx) { s32 pad; - BgBreakwall* this = (BgBreakwall*)thisx; + BgBreakwall* pthis = (BgBreakwall*)pthisx; - if (this->bombableWallDList != NULL) { + if (pthis->bombableWallDList != NULL) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_breakwall.c", 767); func_80093D18(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_breakwall.c", 771), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->bombableWallDList); + gSPDisplayList(POLY_OPA_DISP++, pthis->bombableWallDList); - if (this->colType >= 0) { + if (pthis->colType >= 0) { Vec3f colQuad[4]; - Vec3f* src = &sColQuadList[this->colType][0]; + Vec3f* src = &sColQuadList[pthis->colType][0]; Vec3f* dst = &colQuad[0]; s32 i; @@ -324,8 +324,8 @@ void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_MultVec3f(src++, dst++); } - Collider_SetQuadVertices(&this->collider, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_SetQuadVertices(&pthis->collider, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_breakwall.c", 822); diff --git a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c deleted file mode 100644 index a8afaccc5..000000000 --- a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c +++ /dev/null @@ -1,187 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_DDAN_JD_Z_BG_DDAN_JD_C -#include "actor_common.h" -/* - * File: z_bg_ddan_jd.c - * Overlay: ovl_Bg_Ddan_Jd - * Description: Rising stone platform (Dodongo's Cavern) - */ - -#include "z_bg_ddan_jd.h" -#include "objects/object_ddan_objects/object_ddan_objects.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgDdanJd_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDdanJd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDdanJd_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDdanJd_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgDdanJd_Idle(BgDdanJd* this, GlobalContext* globalCtx); -void BgDdanJd_Move(BgDdanJd* this, GlobalContext* globalCtx); - -const ActorInit Bg_Ddan_Jd_InitVars = { - ACTOR_BG_DDAN_JD, - ACTORCAT_BG, - FLAGS, - OBJECT_DDAN_OBJECTS, - sizeof(BgDdanJd), - (ActorFunc)BgDdanJd_Init, - (ActorFunc)BgDdanJd_Destroy, - (ActorFunc)BgDdanJd_Update, - (ActorFunc)BgDdanJd_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -typedef enum { - /* 0 */ STATE_GO_BOTTOM, - /* 1 */ STATE_GO_MIDDLE_FROM_BOTTOM, - /* 2 */ STATE_GO_MIDDLE_FROM_TOP, - /* 3 */ STATE_GO_TOP -} BgDdanJdState; - -#define MOVE_HEIGHT_MIDDLE 140.0f -#define MOVE_HEIGHT_TOP 700.0f - -#define IDLE_FRAMES 100 - -// Since ySpeed is used to determine if the platform should rise to the top of the dungeon, these must be assigned -// different values in order for the shortcut to work correctly -#define DEFAULT_Y_SPEED 1 -#define SHORTCUT_Y_SPEED 5 - -void BgDdanJd_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgDdanJd* this = (BgDdanJd*)thisx; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(&gDodongoRisingPlatformCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->idleTimer = IDLE_FRAMES; - this->state = STATE_GO_BOTTOM; - - // Missing check for actor.params < 0x40. This will cause inconsistent behavior if params >= 0x40 and the bound - // switch state is turned on while in the same room, as the shortcut behavior won't become enabled until the actor - // is reloaded. - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { - this->ySpeed = SHORTCUT_Y_SPEED; - } else { - this->ySpeed = DEFAULT_Y_SPEED; - } - this->actionFunc = BgDdanJd_Idle; -} - -void BgDdanJd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgDdanJd* this = (BgDdanJd*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgDdanJd_Idle(BgDdanJd* this, GlobalContext* globalCtx) { - if (this->idleTimer != 0) { - this->idleTimer--; - } - - // if this is the platform that rises all the way to the top, and the switch state has just changed to on - if (this->ySpeed == DEFAULT_Y_SPEED && this->dyna.actor.params < 0x40 && - Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { - this->ySpeed = SHORTCUT_Y_SPEED; - this->state = STATE_GO_MIDDLE_FROM_BOTTOM; - this->idleTimer = 0; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; - OnePointCutscene_Init(globalCtx, 3060, -99, &this->dyna.actor, MAIN_CAM); - } - if (this->idleTimer == 0) { - this->idleTimer = IDLE_FRAMES; - if (this->state == STATE_GO_BOTTOM) { - this->state = STATE_GO_MIDDLE_FROM_BOTTOM; - this->targetY = this->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; - } else if (this->state == STATE_GO_MIDDLE_FROM_BOTTOM) { - // If the platform has been activated as a shortcut - if (this->ySpeed != DEFAULT_Y_SPEED) { - this->state = STATE_GO_TOP; - this->targetY = this->dyna.actor.home.pos.y + MOVE_HEIGHT_TOP; - } else { - this->state = STATE_GO_BOTTOM; - this->targetY = this->dyna.actor.home.pos.y; - } - } else if (this->state == STATE_GO_MIDDLE_FROM_TOP) { - // If the platform has been activated as a shortcut - if (this->ySpeed != DEFAULT_Y_SPEED) { - this->state = STATE_GO_TOP; - this->targetY = this->dyna.actor.home.pos.y + MOVE_HEIGHT_TOP; - } else { - this->state = STATE_GO_BOTTOM; - this->targetY = this->dyna.actor.home.pos.y; - } - } else if (this->state == STATE_GO_TOP) { - this->state = STATE_GO_MIDDLE_FROM_TOP; - this->targetY = this->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; - } - this->actionFunc = BgDdanJd_Move; - } -} - -// Handles dust particles and sfx when moving -void BgDdanJd_MoveEffects(BgDdanJd* this, GlobalContext* globalCtx) { - Vec3f dustPos; - - // Generate random dust particles at the platform's base. - dustPos.y = this->dyna.actor.home.pos.y; - if (globalCtx->gameplayFrames & 1) { - dustPos.x = this->dyna.actor.world.pos.x + 65.0f; - dustPos.z = Rand_CenteredFloat(110.0f) + this->dyna.actor.world.pos.z; - func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); - dustPos.x = this->dyna.actor.world.pos.x - 65.0f; - dustPos.z = Rand_CenteredFloat(110.0f) + this->dyna.actor.world.pos.z; - func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); - } else { - dustPos.x = Rand_CenteredFloat(110.0f) + this->dyna.actor.world.pos.x; - dustPos.z = this->dyna.actor.world.pos.z + 65.0f; - func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); - dustPos.x = Rand_CenteredFloat(110.0f) + this->dyna.actor.world.pos.x; - dustPos.z = this->dyna.actor.world.pos.z - 65.0f; - func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); - } - if (this->ySpeed == SHORTCUT_Y_SPEED) { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); - } -} - -// Implements the platform's movement state -void BgDdanJd_Move(BgDdanJd* this, GlobalContext* globalCtx) { - // if this is the platform that rises all the way to the top, and the switch state has just changed to on - if (this->ySpeed == DEFAULT_Y_SPEED && this->dyna.actor.params < 0x40 && - Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { - this->ySpeed = SHORTCUT_Y_SPEED; - this->state = STATE_GO_MIDDLE_FROM_BOTTOM; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; - this->idleTimer = 0; - this->actionFunc = BgDdanJd_Idle; - OnePointCutscene_Init(globalCtx, 3060, -99, &this->dyna.actor, MAIN_CAM); - } else if (Math_StepToF(&this->dyna.actor.world.pos.y, this->targetY, this->ySpeed)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_PILLAR_MOVE_STOP); - this->actionFunc = BgDdanJd_Idle; - } - BgDdanJd_MoveEffects(this, globalCtx); -} - -void BgDdanJd_Update(Actor* thisx, GlobalContext* globalCtx) { - BgDdanJd* this = (BgDdanJd*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgDdanJd_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gDodongoRisingPlatformDL); -} diff --git a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.cpp b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.cpp new file mode 100644 index 000000000..9c097ca65 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.cpp @@ -0,0 +1,187 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_DDAN_JD_Z_BG_DDAN_JD_C +#include "actor_common.h" +/* + * File: z_bg_ddan_jd.c + * Overlay: ovl_Bg_Ddan_Jd + * Description: Rising stone platform (Dodongo's Cavern) + */ + +#include "z_bg_ddan_jd.h" +#include "objects/object_ddan_objects/object_ddan_objects.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgDdanJd_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgDdanJd_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgDdanJd_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgDdanJd_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void BgDdanJd_Idle(BgDdanJd* pthis, GlobalContext* globalCtx); +void BgDdanJd_Move(BgDdanJd* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Ddan_Jd_InitVars = { + ACTOR_BG_DDAN_JD, + ACTORCAT_BG, + FLAGS, + OBJECT_DDAN_OBJECTS, + sizeof(BgDdanJd), + (ActorFunc)BgDdanJd_Init, + (ActorFunc)BgDdanJd_Destroy, + (ActorFunc)BgDdanJd_Update, + (ActorFunc)BgDdanJd_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +typedef enum { + /* 0 */ STATE_GO_BOTTOM, + /* 1 */ STATE_GO_MIDDLE_FROM_BOTTOM, + /* 2 */ STATE_GO_MIDDLE_FROM_TOP, + /* 3 */ STATE_GO_TOP +} BgDdanJdState; + +#define MOVE_HEIGHT_MIDDLE 140.0f +#define MOVE_HEIGHT_TOP 700.0f + +#define IDLE_FRAMES 100 + +// Since ySpeed is used to determine if the platform should rise to the top of the dungeon, these must be assigned +// different values in order for the shortcut to work correctly +#define DEFAULT_Y_SPEED 1 +#define SHORTCUT_Y_SPEED 5 + +void BgDdanJd_Init(Actor* pthisx, GlobalContext* globalCtx) { + s32 pad; + BgDdanJd* pthis = (BgDdanJd*)pthisx; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(&gDodongoRisingPlatformCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->idleTimer = IDLE_FRAMES; + pthis->state = STATE_GO_BOTTOM; + + // Missing check for actor.params < 0x40. This will cause inconsistent behavior if params >= 0x40 and the bound + // switch state is turned on while in the same room, as the shortcut behavior won't become enabled until the actor + // is reloaded. + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params)) { + pthis->ySpeed = SHORTCUT_Y_SPEED; + } else { + pthis->ySpeed = DEFAULT_Y_SPEED; + } + pthis->actionFunc = BgDdanJd_Idle; +} + +void BgDdanJd_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgDdanJd* pthis = (BgDdanJd*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgDdanJd_Idle(BgDdanJd* pthis, GlobalContext* globalCtx) { + if (pthis->idleTimer != 0) { + pthis->idleTimer--; + } + + // if pthis is the platform that rises all the way to the top, and the switch state has just changed to on + if (pthis->ySpeed == DEFAULT_Y_SPEED && pthis->dyna.actor.params < 0x40 && + Flags_GetSwitch(globalCtx, pthis->dyna.actor.params)) { + pthis->ySpeed = SHORTCUT_Y_SPEED; + pthis->state = STATE_GO_MIDDLE_FROM_BOTTOM; + pthis->idleTimer = 0; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; + OnePointCutscene_Init(globalCtx, 3060, -99, &pthis->dyna.actor, MAIN_CAM); + } + if (pthis->idleTimer == 0) { + pthis->idleTimer = IDLE_FRAMES; + if (pthis->state == STATE_GO_BOTTOM) { + pthis->state = STATE_GO_MIDDLE_FROM_BOTTOM; + pthis->targetY = pthis->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; + } else if (pthis->state == STATE_GO_MIDDLE_FROM_BOTTOM) { + // If the platform has been activated as a shortcut + if (pthis->ySpeed != DEFAULT_Y_SPEED) { + pthis->state = STATE_GO_TOP; + pthis->targetY = pthis->dyna.actor.home.pos.y + MOVE_HEIGHT_TOP; + } else { + pthis->state = STATE_GO_BOTTOM; + pthis->targetY = pthis->dyna.actor.home.pos.y; + } + } else if (pthis->state == STATE_GO_MIDDLE_FROM_TOP) { + // If the platform has been activated as a shortcut + if (pthis->ySpeed != DEFAULT_Y_SPEED) { + pthis->state = STATE_GO_TOP; + pthis->targetY = pthis->dyna.actor.home.pos.y + MOVE_HEIGHT_TOP; + } else { + pthis->state = STATE_GO_BOTTOM; + pthis->targetY = pthis->dyna.actor.home.pos.y; + } + } else if (pthis->state == STATE_GO_TOP) { + pthis->state = STATE_GO_MIDDLE_FROM_TOP; + pthis->targetY = pthis->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; + } + pthis->actionFunc = BgDdanJd_Move; + } +} + +// Handles dust particles and sfx when moving +void BgDdanJd_MoveEffects(BgDdanJd* pthis, GlobalContext* globalCtx) { + Vec3f dustPos; + + // Generate random dust particles at the platform's base. + dustPos.y = pthis->dyna.actor.home.pos.y; + if (globalCtx->gameplayFrames & 1) { + dustPos.x = pthis->dyna.actor.world.pos.x + 65.0f; + dustPos.z = Rand_CenteredFloat(110.0f) + pthis->dyna.actor.world.pos.z; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + dustPos.x = pthis->dyna.actor.world.pos.x - 65.0f; + dustPos.z = Rand_CenteredFloat(110.0f) + pthis->dyna.actor.world.pos.z; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + } else { + dustPos.x = Rand_CenteredFloat(110.0f) + pthis->dyna.actor.world.pos.x; + dustPos.z = pthis->dyna.actor.world.pos.z + 65.0f; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + dustPos.x = Rand_CenteredFloat(110.0f) + pthis->dyna.actor.world.pos.x; + dustPos.z = pthis->dyna.actor.world.pos.z - 65.0f; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + } + if (pthis->ySpeed == SHORTCUT_Y_SPEED) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + } +} + +// Implements the platform's movement state +void BgDdanJd_Move(BgDdanJd* pthis, GlobalContext* globalCtx) { + // if pthis is the platform that rises all the way to the top, and the switch state has just changed to on + if (pthis->ySpeed == DEFAULT_Y_SPEED && pthis->dyna.actor.params < 0x40 && + Flags_GetSwitch(globalCtx, pthis->dyna.actor.params)) { + pthis->ySpeed = SHORTCUT_Y_SPEED; + pthis->state = STATE_GO_MIDDLE_FROM_BOTTOM; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + MOVE_HEIGHT_MIDDLE; + pthis->idleTimer = 0; + pthis->actionFunc = BgDdanJd_Idle; + OnePointCutscene_Init(globalCtx, 3060, -99, &pthis->dyna.actor, MAIN_CAM); + } else if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->targetY, pthis->ySpeed)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_PILLAR_MOVE_STOP); + pthis->actionFunc = BgDdanJd_Idle; + } + BgDdanJd_MoveEffects(pthis, globalCtx); +} + +void BgDdanJd_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgDdanJd* pthis = (BgDdanJd*)pthisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgDdanJd_Draw(Actor* pthisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gDodongoRisingPlatformDL); +} diff --git a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c deleted file mode 100644 index 9ac67fc78..000000000 --- a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c +++ /dev/null @@ -1,202 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_DDAN_KD_Z_BG_DDAN_KD_C -#include "actor_common.h" -/* - * File: z_bg_ddan_kd.c - * Overlay: ovl_Bg_Ddan_Kd - * Description: Falling stairs in Dodongo's Cavern - */ - -#include "z_bg_ddan_kd.h" -#include "objects/object_ddan_objects/object_ddan_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgDdanKd_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDdanKd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDdanKd_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDdanKd_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgDdanKd_CheckForExplosions(BgDdanKd* this, GlobalContext* globalCtx); -void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx); -void BgDdanKd_DoNothing(BgDdanKd* this, GlobalContext* globalCtx); - -const ActorInit Bg_Ddan_Kd_InitVars = { - ACTOR_BG_DDAN_KD, - ACTORCAT_BG, - FLAGS, - OBJECT_DDAN_OBJECTS, - sizeof(BgDdanKd), - (ActorFunc)BgDdanKd_Init, - (ActorFunc)BgDdanKd_Destroy, - (ActorFunc)BgDdanKd_Update, - (ActorFunc)BgDdanKd_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ALL, - OC1_NONE, - OC2_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 245, 180, -400, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 32767, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 32767, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 32767, ICHAIN_STOP), -}; - -void BgDdanKd_SetupAction(BgDdanKd* this, BgDdanKdActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void BgDdanKd_Init(Actor* thisx, GlobalContext* globalCtx) { - BgDdanKd* this = (BgDdanKd*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - this->prevExplosive = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - CollisionHeader_GetVirtual(&gDodongoFallingStairsCol, &colHeader); - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (!Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { - BgDdanKd_SetupAction(this, BgDdanKd_CheckForExplosions); - } else { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 200.0f - 20.0f; - BgDdanKd_SetupAction(this, BgDdanKd_DoNothing); - } -} - -void BgDdanKd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgDdanKd* this = (BgDdanKd*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void BgDdanKd_CheckForExplosions(BgDdanKd* this, GlobalContext* globalCtx) { - Actor* explosive; - - explosive = Actor_GetCollidedExplosive(globalCtx, &this->collider.base); - if (explosive != NULL) { - osSyncPrintf("dam %d\n", this->dyna.actor.colChkInfo.damage); - explosive->params = 2; - } - - if ((explosive != NULL) && (this->prevExplosive != NULL) && (explosive != this->prevExplosive) && - (Math_Vec3f_DistXZ(&this->prevExplosivePos, &explosive->world.pos) > 80.0f)) { - BgDdanKd_SetupAction(this, BgDdanKd_LowerStairs); - OnePointCutscene_Init(globalCtx, 3050, 999, &this->dyna.actor, MAIN_CAM); - } else { - if (this->timer != 0) { - this->timer--; - } else { - this->prevExplosive = explosive; - if (explosive != NULL) { - this->timer = 13; - this->prevExplosivePos = explosive->world.pos; - } - } - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx) { - static Vec3f velocity = { 0.0f, 5.0f, 0.0f }; - static Vec3f accel = { 0.0f, -0.45f, 0.0f }; - Vec3f pos1; - Vec3f pos2; - f32 effectStrength; - - Math_SmoothStepToF(&this->dyna.actor.speedXZ, 4.0f, 0.5f, 0.025f, 0.0f); - func_800AA000(500.0f, 0x78, 0x14, 0xA); - - if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 200.0f - 20.0f, 0.075f, - this->dyna.actor.speedXZ, 0.0075f) == 0.0f) { - Flags_SetSwitch(globalCtx, this->dyna.actor.params); - BgDdanKd_SetupAction(this, BgDdanKd_DoNothing); - } else { - effectStrength = - (this->dyna.actor.prevPos.y - this->dyna.actor.world.pos.y) + (this->dyna.actor.speedXZ * 0.25f); - - if (globalCtx->state.frames & 1) { - pos1 = pos2 = this->dyna.actor.world.pos; - - if (globalCtx->state.frames & 2) { - pos1.z += 210.0f + Rand_ZeroOne() * 230.0f; - pos2.z += 210.0f + Rand_ZeroOne() * 230.0f; - } else { - pos1.z += 330.0f + Rand_ZeroOne() * 240.0f; - pos2.z += 330.0f + Rand_ZeroOne() * 240.0f; - } - pos1.x += 80.0f + Rand_ZeroOne() * 10.0f; - pos2.x -= 80.0f + Rand_ZeroOne() * 10.0f; - pos1.y = this->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne(); - pos2.y = this->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne(); - - func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); - func_80033480(globalCtx, &pos2, 20.0f, 1, effectStrength * 135.0f, 60, 1); - - velocity.x = Rand_CenteredFloat(3.0f); - velocity.z = Rand_CenteredFloat(3.0f); - - func_8003555C(globalCtx, &pos1, &velocity, &accel); - func_8003555C(globalCtx, &pos2, &velocity, &accel); - - pos1 = this->dyna.actor.world.pos; - pos1.z += 560.0f + Rand_ZeroOne() * 5.0f; - pos1.x += (Rand_ZeroOne() - 0.5f) * 160.0f; - pos1.y = Rand_ZeroOne() * 3.0f + (this->dyna.actor.floorHeight + 20.0f); - - func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); - func_8003555C(globalCtx, &pos1, &velocity, &accel); - } - Camera_AddQuake(&globalCtx->mainCamera, 0, effectStrength * 0.6f, 3); - Audio_PlaySoundGeneral(NA_SE_EV_PILLAR_SINK - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - } -} - -void BgDdanKd_DoNothing(BgDdanKd* this, GlobalContext* globalCtx) { -} - -void BgDdanKd_Update(Actor* thisx, GlobalContext* globalCtx) { - BgDdanKd* this = (BgDdanKd*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgDdanKd_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gDodongoFallingStairsDL); -} diff --git a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.cpp b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.cpp new file mode 100644 index 000000000..42a9dc6d6 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.cpp @@ -0,0 +1,202 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_DDAN_KD_Z_BG_DDAN_KD_C +#include "actor_common.h" +/* + * File: z_bg_ddan_kd.c + * Overlay: ovl_Bg_Ddan_Kd + * Description: Falling stairs in Dodongo's Cavern + */ + +#include "z_bg_ddan_kd.h" +#include "objects/object_ddan_objects/object_ddan_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgDdanKd_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgDdanKd_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgDdanKd_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgDdanKd_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void BgDdanKd_CheckForExplosions(BgDdanKd* pthis, GlobalContext* globalCtx); +void BgDdanKd_LowerStairs(BgDdanKd* pthis, GlobalContext* globalCtx); +void BgDdanKd_DoNothing(BgDdanKd* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Ddan_Kd_InitVars = { + ACTOR_BG_DDAN_KD, + ACTORCAT_BG, + FLAGS, + OBJECT_DDAN_OBJECTS, + sizeof(BgDdanKd), + (ActorFunc)BgDdanKd_Init, + (ActorFunc)BgDdanKd_Destroy, + (ActorFunc)BgDdanKd_Update, + (ActorFunc)BgDdanKd_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ALL, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 245, 180, -400, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 32767, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 32767, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 32767, ICHAIN_STOP), +}; + +void BgDdanKd_SetupAction(BgDdanKd* pthis, BgDdanKdActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void BgDdanKd_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgDdanKd* pthis = (BgDdanKd*)pthisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + pthis->prevExplosive = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + CollisionHeader_GetVirtual(&gDodongoFallingStairsCol, &colHeader); + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (!Flags_GetSwitch(globalCtx, pthis->dyna.actor.params)) { + BgDdanKd_SetupAction(pthis, BgDdanKd_CheckForExplosions); + } else { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - 200.0f - 20.0f; + BgDdanKd_SetupAction(pthis, BgDdanKd_DoNothing); + } +} + +void BgDdanKd_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgDdanKd* pthis = (BgDdanKd*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void BgDdanKd_CheckForExplosions(BgDdanKd* pthis, GlobalContext* globalCtx) { + Actor* explosive; + + explosive = Actor_GetCollidedExplosive(globalCtx, &pthis->collider.base); + if (explosive != NULL) { + osSyncPrintf("dam %d\n", pthis->dyna.actor.colChkInfo.damage); + explosive->params = 2; + } + + if ((explosive != NULL) && (pthis->prevExplosive != NULL) && (explosive != pthis->prevExplosive) && + (Math_Vec3f_DistXZ(&pthis->prevExplosivePos, &explosive->world.pos) > 80.0f)) { + BgDdanKd_SetupAction(pthis, BgDdanKd_LowerStairs); + OnePointCutscene_Init(globalCtx, 3050, 999, &pthis->dyna.actor, MAIN_CAM); + } else { + if (pthis->timer != 0) { + pthis->timer--; + } else { + pthis->prevExplosive = explosive; + if (explosive != NULL) { + pthis->timer = 13; + pthis->prevExplosivePos = explosive->world.pos; + } + } + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void BgDdanKd_LowerStairs(BgDdanKd* pthis, GlobalContext* globalCtx) { + static Vec3f velocity = { 0.0f, 5.0f, 0.0f }; + static Vec3f accel = { 0.0f, -0.45f, 0.0f }; + Vec3f pos1; + Vec3f pos2; + f32 effectStrength; + + Math_SmoothStepToF(&pthis->dyna.actor.speedXZ, 4.0f, 0.5f, 0.025f, 0.0f); + func_800AA000(500.0f, 0x78, 0x14, 0xA); + + if (Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 200.0f - 20.0f, 0.075f, + pthis->dyna.actor.speedXZ, 0.0075f) == 0.0f) { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params); + BgDdanKd_SetupAction(pthis, BgDdanKd_DoNothing); + } else { + effectStrength = + (pthis->dyna.actor.prevPos.y - pthis->dyna.actor.world.pos.y) + (pthis->dyna.actor.speedXZ * 0.25f); + + if (globalCtx->state.frames & 1) { + pos1 = pos2 = pthis->dyna.actor.world.pos; + + if (globalCtx->state.frames & 2) { + pos1.z += 210.0f + Rand_ZeroOne() * 230.0f; + pos2.z += 210.0f + Rand_ZeroOne() * 230.0f; + } else { + pos1.z += 330.0f + Rand_ZeroOne() * 240.0f; + pos2.z += 330.0f + Rand_ZeroOne() * 240.0f; + } + pos1.x += 80.0f + Rand_ZeroOne() * 10.0f; + pos2.x -= 80.0f + Rand_ZeroOne() * 10.0f; + pos1.y = pthis->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne(); + pos2.y = pthis->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne(); + + func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); + func_80033480(globalCtx, &pos2, 20.0f, 1, effectStrength * 135.0f, 60, 1); + + velocity.x = Rand_CenteredFloat(3.0f); + velocity.z = Rand_CenteredFloat(3.0f); + + func_8003555C(globalCtx, &pos1, &velocity, &accel); + func_8003555C(globalCtx, &pos2, &velocity, &accel); + + pos1 = pthis->dyna.actor.world.pos; + pos1.z += 560.0f + Rand_ZeroOne() * 5.0f; + pos1.x += (Rand_ZeroOne() - 0.5f) * 160.0f; + pos1.y = Rand_ZeroOne() * 3.0f + (pthis->dyna.actor.floorHeight + 20.0f); + + func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); + func_8003555C(globalCtx, &pos1, &velocity, &accel); + } + Camera_AddQuake(&globalCtx->mainCamera, 0, effectStrength * 0.6f, 3); + Audio_PlaySoundGeneral(NA_SE_EV_PILLAR_SINK - SFX_FLAG, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + } +} + +void BgDdanKd_DoNothing(BgDdanKd* pthis, GlobalContext* globalCtx) { +} + +void BgDdanKd_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgDdanKd* pthis = (BgDdanKd*)pthisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgDdanKd_Draw(Actor* pthisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gDodongoFallingStairsDL); +} diff --git a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.cpp similarity index 51% rename from src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c rename to src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.cpp index 0c6c0d98f..8da18ce03 100644 --- a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c +++ b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.cpp @@ -23,17 +23,17 @@ #define FLAGS 0 -void BgDodoago_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDodoago_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDodoago_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDodoago_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDodoago_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgDodoago_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgDodoago_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgDodoago_Draw(Actor* pthisx, GlobalContext* globalCtx); -void BgDodoago_WaitExplosives(BgDodoago* this, GlobalContext* globalCtx); -void BgDodoago_OpenJaw(BgDodoago* this, GlobalContext* globalCtx); -void BgDodoago_DoNothing(BgDodoago* this, GlobalContext* globalCtx); -void BgDodoago_LightOneEye(BgDodoago* this, GlobalContext* globalCtx); +void BgDodoago_WaitExplosives(BgDodoago* pthis, GlobalContext* globalCtx); +void BgDodoago_OpenJaw(BgDodoago* pthis, GlobalContext* globalCtx); +void BgDodoago_DoNothing(BgDodoago* pthis, GlobalContext* globalCtx); +void BgDodoago_LightOneEye(BgDodoago* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Dodoago_InitVars = { +ActorInit Bg_Dodoago_InitVars = { ACTOR_BG_DODOAGO, ACTORCAT_BG, FLAGS, @@ -93,8 +93,8 @@ static u8 sUnused[90]; // unknown length static s32 sTimer; -void BgDodoago_SetupAction(BgDodoago* this, BgDodoagoActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgDodoago_SetupAction(BgDodoago* pthis, BgDodoagoActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgDodoago_SpawnSparkles(Vec3f* meanPos, GlobalContext* globalCtx) { @@ -120,98 +120,98 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -void BgDodoago_Init(Actor* thisx, GlobalContext* globalCtx) { - BgDodoago* this = (BgDodoago*)thisx; +void BgDodoago_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgDodoago* pthis = (BgDodoago*)pthisx; s32 pad; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gDodongoLowerJawCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, NULL, 0.0f); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - BgDodoago_SetupAction(this, BgDodoago_DoNothing); - this->dyna.actor.shape.rot.x = 0x1333; + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + BgDodoago_SetupAction(pthis, BgDodoago_DoNothing); + pthis->dyna.actor.shape.rot.x = 0x1333; globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] = globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] = 255; return; } - Collider_InitCylinder(globalCtx, &this->colliderMain); - Collider_InitCylinder(globalCtx, &this->colliderLeft); - Collider_InitCylinder(globalCtx, &this->colliderRight); - Collider_SetCylinder(globalCtx, &this->colliderMain, &this->dyna.actor, &sColCylinderInitMain); - Collider_SetCylinder(globalCtx, &this->colliderLeft, &this->dyna.actor, &sColCylinderInitLeftRight); - Collider_SetCylinder(globalCtx, &this->colliderRight, &this->dyna.actor, &sColCylinderInitLeftRight); + Collider_InitCylinder(globalCtx, &pthis->colliderMain); + Collider_InitCylinder(globalCtx, &pthis->colliderLeft); + Collider_InitCylinder(globalCtx, &pthis->colliderRight); + Collider_SetCylinder(globalCtx, &pthis->colliderMain, &pthis->dyna.actor, &sColCylinderInitMain); + Collider_SetCylinder(globalCtx, &pthis->colliderLeft, &pthis->dyna.actor, &sColCylinderInitLeftRight); + Collider_SetCylinder(globalCtx, &pthis->colliderRight, &pthis->dyna.actor, &sColCylinderInitLeftRight); - BgDodoago_SetupAction(this, BgDodoago_WaitExplosives); + BgDodoago_SetupAction(pthis, BgDodoago_WaitExplosives); sDisableBombCatcher = false; } -void BgDodoago_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgDodoago* this = (BgDodoago*)thisx; +void BgDodoago_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgDodoago* pthis = (BgDodoago*)pthisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->colliderMain); - Collider_DestroyCylinder(globalCtx, &this->colliderLeft); - Collider_DestroyCylinder(globalCtx, &this->colliderRight); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->colliderMain); + Collider_DestroyCylinder(globalCtx, &pthis->colliderLeft); + Collider_DestroyCylinder(globalCtx, &pthis->colliderRight); } -void BgDodoago_WaitExplosives(BgDodoago* this, GlobalContext* globalCtx) { - Actor* explosive = Actor_GetCollidedExplosive(globalCtx, &this->colliderMain.base); +void BgDodoago_WaitExplosives(BgDodoago* pthis, GlobalContext* globalCtx) { + Actor* explosive = Actor_GetCollidedExplosive(globalCtx, &pthis->colliderMain.base); if (explosive != NULL) { - this->state = - (Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &explosive->world.pos) >= this->dyna.actor.shape.rot.y) + pthis->state = + (Math_Vec3f_Yaw(&pthis->dyna.actor.world.pos, &explosive->world.pos) >= pthis->dyna.actor.shape.rot.y) ? BGDODOAGO_EYE_RIGHT : BGDODOAGO_EYE_LEFT; - if (((globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] == 255) && (this->state == BGDODOAGO_EYE_RIGHT)) || - ((globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] == 255) && (this->state == BGDODOAGO_EYE_LEFT))) { - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - this->state = 0; + if (((globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] == 255) && (pthis->state == BGDODOAGO_EYE_RIGHT)) || + ((globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] == 255) && (pthis->state == BGDODOAGO_EYE_LEFT))) { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + pthis->state = 0; Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - BgDodoago_SetupAction(this, BgDodoago_OpenJaw); - OnePointCutscene_Init(globalCtx, 3380, 160, &this->dyna.actor, MAIN_CAM); - } else if (globalCtx->roomCtx.unk_74[this->state] == 0) { - OnePointCutscene_Init(globalCtx, 3065, 40, &this->dyna.actor, MAIN_CAM); - BgDodoago_SetupAction(this, BgDodoago_LightOneEye); + BgDodoago_SetupAction(pthis, BgDodoago_OpenJaw); + OnePointCutscene_Init(globalCtx, 3380, 160, &pthis->dyna.actor, MAIN_CAM); + } else if (globalCtx->roomCtx.unk_74[pthis->state] == 0) { + OnePointCutscene_Init(globalCtx, 3065, 40, &pthis->dyna.actor, MAIN_CAM); + BgDodoago_SetupAction(pthis, BgDodoago_LightOneEye); Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - OnePointCutscene_Init(globalCtx, 3065, 20, &this->dyna.actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 3065, 20, &pthis->dyna.actor, MAIN_CAM); Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); sTimer += 30; return; } - // the flag is never set back to false, so this only runs once + // the flag is never set back to false, so pthis only runs once if (!sFirstExplosiveFlag) { - // this disables the bomb catcher (see BgDodoago_Update) for a few seconds - this->dyna.actor.parent = explosive; + // pthis disables the bomb catcher (see BgDodoago_Update) for a few seconds + pthis->dyna.actor.parent = explosive; sFirstExplosiveFlag = true; sTimer = 50; } } else if (Flags_GetEventChkInf(0xB0)) { - Collider_UpdateCylinder(&this->dyna.actor, &this->colliderMain); - Collider_UpdateCylinder(&this->dyna.actor, &this->colliderLeft); - Collider_UpdateCylinder(&this->dyna.actor, &this->colliderRight); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->colliderMain); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->colliderLeft); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->colliderRight); - this->colliderMain.dim.pos.z += 200; + pthis->colliderMain.dim.pos.z += 200; - this->colliderLeft.dim.pos.z += 215; - this->colliderLeft.dim.pos.x += 90; + pthis->colliderLeft.dim.pos.z += 215; + pthis->colliderLeft.dim.pos.x += 90; - this->colliderRight.dim.pos.z += 215; - this->colliderRight.dim.pos.x -= 90; + pthis->colliderRight.dim.pos.z += 215; + pthis->colliderRight.dim.pos.x -= 90; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderMain.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderLeft.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderRight.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderMain.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLeft.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderRight.base); } } -void BgDodoago_OpenJaw(BgDodoago* this, GlobalContext* globalCtx) { +void BgDodoago_OpenJaw(BgDodoago* pthis, GlobalContext* globalCtx) { Vec3f pos; Vec3f dustOffsets[] = { { 0.0f, -200.0f, 430.0f }, { 20.0f, -200.0f, 420.0f }, { -20.0f, -200.0f, 420.0f }, @@ -236,69 +236,69 @@ void BgDodoago_OpenJaw(BgDodoago* this, GlobalContext* globalCtx) { if (sTimer == 108) { for (i = ARRAY_COUNT(dustOffsets) - 1; i >= 0; i--) { - pos.x = dustOffsets[i].x + this->dyna.actor.world.pos.x; - pos.y = dustOffsets[i].y + this->dyna.actor.world.pos.y; - pos.z = dustOffsets[i].z + this->dyna.actor.world.pos.z; + pos.x = dustOffsets[i].x + pthis->dyna.actor.world.pos.x; + pos.y = dustOffsets[i].y + pthis->dyna.actor.world.pos.y; + pos.z = dustOffsets[i].z + pthis->dyna.actor.world.pos.z; func_80033480(globalCtx, &pos, 2.0f, 3, 200, 75, 1); } } - pos.x = this->dyna.actor.world.pos.x + 200.0f; - pos.y = this->dyna.actor.world.pos.y - 20.0f; - pos.z = this->dyna.actor.world.pos.z + 100.0f; + pos.x = pthis->dyna.actor.world.pos.x + 200.0f; + pos.y = pthis->dyna.actor.world.pos.y - 20.0f; + pos.z = pthis->dyna.actor.world.pos.z + 100.0f; BgDodoago_SpawnSparkles(&pos, globalCtx); - pos.x = this->dyna.actor.world.pos.x - 200.0f; - pos.y = this->dyna.actor.world.pos.y - 20.0f; - pos.z = this->dyna.actor.world.pos.z + 100.0f; + pos.x = pthis->dyna.actor.world.pos.x - 200.0f; + pos.y = pthis->dyna.actor.world.pos.y - 20.0f; + pos.z = pthis->dyna.actor.world.pos.z + 100.0f; BgDodoago_SpawnSparkles(&pos, globalCtx); - Math_StepToS(&this->state, 100, 3); + Math_StepToS(&pthis->state, 100, 3); func_800AA000(500.0f, 0x78, 0x14, 0xA); - if (Math_SmoothStepToS(&this->dyna.actor.shape.rot.x, 0x1333, 110 - this->state, 0x3E8, 0x32) == 0) { - BgDodoago_SetupAction(this, BgDodoago_DoNothing); - Audio_PlaySoundGeneral(NA_SE_EV_STONE_BOUND, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, + if (Math_SmoothStepToS(&pthis->dyna.actor.shape.rot.x, 0x1333, 110 - pthis->state, 0x3E8, 0x32) == 0) { + BgDodoago_SetupAction(pthis, BgDodoago_DoNothing); + Audio_PlaySoundGeneral(NA_SE_EV_STONE_BOUND, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - Audio_PlaySoundGeneral(NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } -void BgDodoago_DoNothing(BgDodoago* this, GlobalContext* globalCtx) { +void BgDodoago_DoNothing(BgDodoago* pthis, GlobalContext* globalCtx) { } -void BgDodoago_LightOneEye(BgDodoago* this, GlobalContext* globalCtx) { - globalCtx->roomCtx.unk_74[this->state] += 5; +void BgDodoago_LightOneEye(BgDodoago* pthis, GlobalContext* globalCtx) { + globalCtx->roomCtx.unk_74[pthis->state] += 5; - if (globalCtx->roomCtx.unk_74[this->state] == 255) { - BgDodoago_SetupAction(this, BgDodoago_WaitExplosives); + if (globalCtx->roomCtx.unk_74[pthis->state] == 255) { + BgDodoago_SetupAction(pthis, BgDodoago_WaitExplosives); } } -void BgDodoago_Update(Actor* thisx, GlobalContext* globalCtx) { - BgDodoago* this = (BgDodoago*)thisx; +void BgDodoago_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgDodoago* pthis = (BgDodoago*)pthisx; Actor* actor; EnBom* bomb; - if (this->dyna.actor.parent == NULL) { - // this is a "bomb catcher", it kills the XZ speed and sets the timer for bombs that are dropped through the + if (pthis->dyna.actor.parent == NULL) { + // pthis is a "bomb catcher", it kills the XZ speed and sets the timer for bombs that are dropped through the // holes in the bridge above the skull - if ((this->colliderLeft.base.ocFlags1 & OC1_HIT) || (this->colliderRight.base.ocFlags1 & OC1_HIT)) { + if ((pthis->colliderLeft.base.ocFlags1 & OC1_HIT) || (pthis->colliderRight.base.ocFlags1 & OC1_HIT)) { - if (this->colliderLeft.base.ocFlags1 & OC1_HIT) { - actor = this->colliderLeft.base.oc; + if (pthis->colliderLeft.base.ocFlags1 & OC1_HIT) { + actor = pthis->colliderLeft.base.oc; } else { - actor = this->colliderRight.base.oc; + actor = pthis->colliderRight.base.oc; } - this->colliderLeft.base.ocFlags1 &= ~OC1_HIT; - this->colliderRight.base.ocFlags1 &= ~OC1_HIT; + pthis->colliderLeft.base.ocFlags1 &= ~OC1_HIT; + pthis->colliderRight.base.ocFlags1 &= ~OC1_HIT; if (actor->category == ACTORCAT_EXPLOSIVE && actor->id == ACTOR_EN_BOM && actor->params == 0) { bomb = (EnBom*)actor; // disable the bomb catcher for a few seconds - this->dyna.actor.parent = &bomb->actor; + pthis->dyna.actor.parent = &bomb->actor; bomb->timer = 50; bomb->actor.speedXZ = 0.0f; sTimer = 0; @@ -306,20 +306,20 @@ void BgDodoago_Update(Actor* thisx, GlobalContext* globalCtx) { } } else { sTimer++; - Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F); + Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); if (!sDisableBombCatcher && sTimer > 140) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - // this prevents clearing the actor's parent pointer, effectively disabling the bomb catcher + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + // pthis prevents clearing the actor's parent pointer, effectively disabling the bomb catcher sDisableBombCatcher++; } else { - this->dyna.actor.parent = NULL; + pthis->dyna.actor.parent = NULL; } } } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } -void BgDodoago_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgDodoago_Draw(Actor* pthisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_dodoago.c", 672); if (Flags_GetEventChkInf(0xB0)) { diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.cpp similarity index 52% rename from src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c rename to src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.cpp index 9cf458620..e288921eb 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.cpp @@ -38,36 +38,36 @@ typedef enum { /* 2 */ FAIRY_SPELL_NAYRUS_LOVE } BgDyYoseizoSpellType; -void BgDyYoseizo_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDyYoseizo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDyYoseizo_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDyYoseizo_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDyYoseizo_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgDyYoseizo_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgDyYoseizo_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgDyYoseizo_Draw(Actor* pthisx, GlobalContext* globalCtx); -void BgDyYoseizo_CheckMagicAcquired(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SetupSpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_CompleteSpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SetupGreetPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_GreetPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SetupHealPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_HealPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SayFarewell_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SetupSpinShrink(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SpinShrink(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_Vanish(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SetupSpinGrow_Reward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_SpinGrowSetupGive_Reward(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx); +void BgDyYoseizo_CheckMagicAcquired(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_ChooseType(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SetupSpinGrow_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SpinGrow_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_CompleteSpinGrow_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SetupGreetPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_GreetPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SetupHealPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_HealPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SayFarewell_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SetupSpinShrink(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SpinShrink(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_Vanish(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SetupSpinGrow_Reward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_SpinGrowSetupGive_Reward(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_Give_Reward(BgDyYoseizo* pthis, GlobalContext* globalCtx); -void BgDyYoseizo_ParticleInit(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, +void BgDyYoseizo_ParticleInit(BgDyYoseizo* pthis, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, Color_RGB8* primColor, Color_RGB8* envColor, f32 scale, s16 life, s16 type); -void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx); -void BgDyYoseizo_ParticleDraw(BgDyYoseizo* this, GlobalContext* globalCtx); +void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* pthis, GlobalContext* globalCtx); +void BgDyYoseizo_ParticleDraw(BgDyYoseizo* pthis, GlobalContext* globalCtx); static s32 sUnusedGetItemIds[] = { GI_FARORES_WIND, GI_NAYRUS_LOVE, GI_DINS_FIRE }; -const ActorInit Bg_Dy_Yoseizo_InitVars = { +ActorInit Bg_Dy_Yoseizo_InitVars = { ACTOR_BG_DY_YOSEIZO, ACTORCAT_PROP, FLAGS, @@ -79,35 +79,35 @@ const ActorInit Bg_Dy_Yoseizo_InitVars = { NULL, }; -void BgDyYoseizo_Init(Actor* thisx, GlobalContext* globalCtx2) { +void BgDyYoseizo_Init(Actor* pthisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgDyYoseizo* this = (BgDyYoseizo*)thisx; + BgDyYoseizo* pthis = (BgDyYoseizo*)pthisx; - this->fountainType = globalCtx->curSpawn; + pthis->fountainType = globalCtx->curSpawn; - if (this->fountainType < 0) { - this->fountainType = 0; + if (pthis->fountainType < 0) { + pthis->fountainType = 0; } - this->vanishHeight = this->actor.world.pos.y; - this->grownHeight = this->vanishHeight + 40.0f; - this->actor.focus.pos = this->actor.world.pos; + pthis->vanishHeight = pthis->actor.world.pos.y; + pthis->grownHeight = pthis->vanishHeight + 40.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { // "Great Fairy Fountain" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 大妖精の泉 ☆☆☆☆☆ %d\n" VT_RST, globalCtx->curSpawn); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGreatFairySkel, &gGreatFairySittingTransitionAnim, - this->jointTable, this->morphTable, 28); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGreatFairySkel, &gGreatFairySittingTransitionAnim, + pthis->jointTable, pthis->morphTable, 28); } else { // "Stone/Jewel Fairy Fountain" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 石妖精の泉 ☆☆☆☆☆ %d\n" VT_RST, globalCtx->curSpawn); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGreatFairySkel, &gGreatFairyLayingDownTransitionAnim, - this->jointTable, this->morphTable, 28); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGreatFairySkel, &gGreatFairyLayingDownTransitionAnim, + pthis->jointTable, pthis->morphTable, 28); } - this->actionFunc = BgDyYoseizo_CheckMagicAcquired; + pthis->actionFunc = BgDyYoseizo_CheckMagicAcquired; } -void BgDyYoseizo_Destroy(Actor* this, GlobalContext* globalCtx) { +void BgDyYoseizo_Destroy(Actor* pthis, GlobalContext* globalCtx) { } static Color_RGB8 sParticlePrimColors[] = { @@ -120,7 +120,7 @@ static Color_RGB8 sParticleEnvColors[] = { { 255, 255, 100 }, { 100, 255, 100 }, { 255, 100, 100 }, { 100, 255, 255 }, }; -void BgDyYoseizo_SpawnParticles(BgDyYoseizo* this, GlobalContext* globalCtx, s16 type) { +void BgDyYoseizo_SpawnParticles(BgDyYoseizo* pthis, GlobalContext* globalCtx, s16 type) { Vec3f particleInitVelocity = { 0.0f, 0.0f, 0.0f }; Vec3f particleAccel; Vec3f particleInitPos; @@ -132,8 +132,8 @@ void BgDyYoseizo_SpawnParticles(BgDyYoseizo* this, GlobalContext* globalCtx, s16 s32 i; s16 particleLife; - if (!(this->scale < 0.01f)) { - spawnPosVariation = this->scale * 3500.0f; + if (!(pthis->scale < 0.01f)) { + spawnPosVariation = pthis->scale * 3500.0f; particleAccel.x = Rand_ZeroOne() - 0.5f; particleAccel.y = Rand_ZeroOne() - 0.5f; particleAccel.z = Rand_ZeroOne() - 0.5f; @@ -142,24 +142,24 @@ void BgDyYoseizo_SpawnParticles(BgDyYoseizo* this, GlobalContext* globalCtx, s16 particleType = 0; particleScale = 0.4f; particleLife = 90; - particleInitPos.x = this->actor.world.pos.x; - particleInitPos.y = this->actor.world.pos.y + spawnPosVariation + + particleInitPos.x = pthis->actor.world.pos.x; + particleInitPos.y = pthis->actor.world.pos.y + spawnPosVariation + ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.5f)); - particleInitPos.z = this->actor.world.pos.z + 30.0f; + particleInitPos.z = pthis->actor.world.pos.z + 30.0f; } else { particleLife = 50; particleType = type; particleScale = 0.2f; - particleInitPos.x = this->actor.world.pos.x + Rand_CenteredFloat(10.0f); + particleInitPos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(10.0f); if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - particleInitPos.y = this->actor.world.pos.y + spawnPosVariation + 50.0f + + particleInitPos.y = pthis->actor.world.pos.y + spawnPosVariation + 50.0f + ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.1f)); - particleInitPos.z = this->actor.world.pos.z + 30.0f; + particleInitPos.z = pthis->actor.world.pos.z + 30.0f; } else { - particleInitPos.y = this->actor.world.pos.y + spawnPosVariation - 30.0f + + particleInitPos.y = pthis->actor.world.pos.y + spawnPosVariation - 30.0f + ((Rand_ZeroOne() - 0.5f) * (spawnPosVariation * 0.1f)); - particleInitPos.z = this->actor.world.pos.z + 60.0f; + particleInitPos.z = pthis->actor.world.pos.z + 60.0f; } if (LINK_IS_ADULT) { @@ -173,53 +173,53 @@ void BgDyYoseizo_SpawnParticles(BgDyYoseizo* this, GlobalContext* globalCtx, s16 particleEnvColor.r = sParticleEnvColors[particleType].r; particleEnvColor.g = sParticleEnvColors[particleType].g; particleEnvColor.b = sParticleEnvColors[particleType].b; - BgDyYoseizo_ParticleInit(this, &particleInitPos, &particleInitVelocity, &particleAccel, &particlePrimColor, + BgDyYoseizo_ParticleInit(pthis, &particleInitPos, &particleInitVelocity, &particleAccel, &particlePrimColor, &particleEnvColor, particleScale, particleLife, particleType); } } } -void BgDyYoseizo_Bob(BgDyYoseizo* this, GlobalContext* globalCtx) { - this->targetHeight = this->grownHeight + this->bobOffset; - Math_ApproachF(&this->actor.world.pos.y, this->targetHeight, 0.1f, 10.0f); - Math_ApproachF(&this->bobOffset, 10.0f, 0.1f, 0.5f); +void BgDyYoseizo_Bob(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + pthis->targetHeight = pthis->grownHeight + pthis->bobOffset; + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetHeight, 0.1f, 10.0f); + Math_ApproachF(&pthis->bobOffset, 10.0f, 0.1f, 0.5f); if (globalCtx->csCtx.state == CS_STATE_IDLE) { - this->actor.velocity.y = Math_SinS(this->bobTimer); + pthis->actor.velocity.y = Math_SinS(pthis->bobTimer); } else { - this->actor.velocity.y = Math_SinS(this->bobTimer) * 0.4f; + pthis->actor.velocity.y = Math_SinS(pthis->bobTimer) * 0.4f; } } -void BgDyYoseizo_CheckMagicAcquired(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_CheckMagicAcquired(BgDyYoseizo* pthis, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, 0x38)) { globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - if (!gSaveContext.magicAcquired && (this->fountainType != FAIRY_UPGRADE_MAGIC)) { - Actor_Kill(&this->actor); + if (!gSaveContext.magicAcquired && (pthis->fountainType != FAIRY_UPGRADE_MAGIC)) { + Actor_Kill(&pthis->actor); return; } } else { if (!gSaveContext.magicAcquired) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } } - func_8002DF54(globalCtx, &this->actor, 1); - this->actionFunc = BgDyYoseizo_ChooseType; + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->actionFunc = BgDyYoseizo_ChooseType; } } -void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_ChooseType(BgDyYoseizo* pthis, GlobalContext* globalCtx) { s32 givingReward; - func_8002DF54(globalCtx, &this->actor, 1); + func_8002DF54(globalCtx, &pthis->actor, 1); // "Mode" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ もうど ☆☆☆☆☆ %d\n" VT_RST, globalCtx->msgCtx.ocarinaMode); givingReward = false; if (globalCtx->sceneNum != SCENE_DAIYOUSEI_IZUMI) { - switch (this->fountainType) { + switch (pthis->fountainType) { case FAIRY_SPELL_FARORES_WIND: if (!(gSaveContext.itemGetInf[1] & 0x100)) { givingReward = true; @@ -237,12 +237,12 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { break; } } else { - switch (this->fountainType) { + switch (pthis->fountainType) { case FAIRY_UPGRADE_MAGIC: if (!gSaveContext.magicAcquired || BREG(2)) { // "Spin Attack speed UP" osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 回転切り速度UP ☆☆☆☆☆ \n" VT_RST); - this->givingSpell = true; + pthis->givingSpell = true; givingReward = true; } break; @@ -250,7 +250,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { if (!gSaveContext.doubleMagic) { // "Magic Meter doubled" osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 魔法ゲージメーター倍増 ☆☆☆☆☆ \n" VT_RST); - this->givingSpell = true; + pthis->givingSpell = true; givingReward = true; } break; @@ -258,7 +258,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { if (!gSaveContext.doubleDefense) { // "Damage halved" osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ ダメージ半減 ☆☆☆☆☆ \n" VT_RST); - this->givingSpell = true; + pthis->givingSpell = true; givingReward = true; } break; @@ -268,7 +268,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { if (givingReward) { if (gSaveContext.sceneSetupIndex < 4) { if (globalCtx->sceneNum != SCENE_DAIYOUSEI_IZUMI) { - switch (this->fountainType) { + switch (pthis->fountainType) { case FAIRY_SPELL_FARORES_WIND: globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGreatFairyFaroresWindCs); gSaveContext.cutsceneTrigger = 1; @@ -283,7 +283,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { break; } } else { - switch (this->fountainType) { + switch (pthis->fountainType) { case FAIRY_UPGRADE_MAGIC: globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGreatFairyMagicCs); gSaveContext.cutsceneTrigger = 1; @@ -299,7 +299,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { } } } - this->actionFunc = BgDyYoseizo_SetupSpinGrow_Reward; + pthis->actionFunc = BgDyYoseizo_SetupSpinGrow_Reward; return; } @@ -311,258 +311,258 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, GlobalContext* globalCtx) { OnePointCutscene_Init(globalCtx, 8604, -99, NULL, MAIN_CAM); }; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GREAT_FAIRY_APPEAR); - this->actor.draw = BgDyYoseizo_Draw; - this->actionFunc = BgDyYoseizo_SetupSpinGrow_NoReward; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GREAT_FAIRY_APPEAR); + pthis->actor.draw = BgDyYoseizo_Draw; + pthis->actionFunc = BgDyYoseizo_SetupSpinGrow_NoReward; } // Sets animations for spingrow -void BgDyYoseizo_SetupSpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_SetupSpinGrow_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairySittingTransitionAnim); - Animation_Change(&this->skelAnime, &gGreatFairySittingTransitionAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairySittingTransitionAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairySittingTransitionAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyLayingDownTransitionAnim); - Animation_Change(&this->skelAnime, &gGreatFairyLayingDownTransitionAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyLayingDownTransitionAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyLayingDownTransitionAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } - Audio_PlayActorSound2(&this->actor, NA_SE_VO_FR_LAUGH_0); - func_8002DF54(globalCtx, &this->actor, 1); - this->actionFunc = BgDyYoseizo_SpinGrow_NoReward; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_FR_LAUGH_0); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->actionFunc = BgDyYoseizo_SpinGrow_NoReward; } -void BgDyYoseizo_SpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { - func_8002DF54(globalCtx, &this->actor, 1); - Math_ApproachF(&this->actor.world.pos.y, this->grownHeight, this->heightFraction, 100.0f); - Math_ApproachF(&this->scale, 0.035f, this->scaleFraction, 0.005f); - Math_ApproachF(&this->heightFraction, 0.8f, 0.1f, 0.02f); - Math_ApproachF(&this->scaleFraction, 0.2f, 0.03f, 0.05f); +void BgDyYoseizo_SpinGrow_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + func_8002DF54(globalCtx, &pthis->actor, 1); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->grownHeight, pthis->heightFraction, 100.0f); + Math_ApproachF(&pthis->scale, 0.035f, pthis->scaleFraction, 0.005f); + Math_ApproachF(&pthis->heightFraction, 0.8f, 0.1f, 0.02f); + Math_ApproachF(&pthis->scaleFraction, 0.2f, 0.03f, 0.05f); // Finished growing - if (this->scale >= 0.034f) { - if ((this->actor.shape.rot.y > -8000) && (this->actor.shape.rot.y < 1000)) { - SkelAnime_Update(&this->skelAnime); + if (pthis->scale >= 0.034f) { + if ((pthis->actor.shape.rot.y > -8000) && (pthis->actor.shape.rot.y < 1000)) { + SkelAnime_Update(&pthis->skelAnime); // Turn to front - Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 5, 1000, 0); - if (fabsf(this->actor.shape.rot.y) < 50.0f) { - this->actionFunc = BgDyYoseizo_CompleteSpinGrow_NoReward; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, 0, 5, 1000, 0); + if (fabsf(pthis->actor.shape.rot.y) < 50.0f) { + pthis->actionFunc = BgDyYoseizo_CompleteSpinGrow_NoReward; } } else { - this->actor.shape.rot.y += 3000; + pthis->actor.shape.rot.y += 3000; } } else { - this->actor.shape.rot.y += 3000; + pthis->actor.shape.rot.y += 3000; } - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); } -void BgDyYoseizo_CompleteSpinGrow_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { - f32 curFrame = this->skelAnime.curFrame; +void BgDyYoseizo_CompleteSpinGrow_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + f32 curFrame = pthis->skelAnime.curFrame; - func_8002DF54(globalCtx, &this->actor, 1); + func_8002DF54(globalCtx, &pthis->actor, 1); - if ((this->frameCount * 1273.0f) <= this->bobTimer) { - this->bobTimer = 0.0f; + if ((pthis->frameCount * 1273.0f) <= pthis->bobTimer) { + pthis->bobTimer = 0.0f; } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if ((this->frameCount <= curFrame) && !this->animationChanged) { - this->actionFunc = BgDyYoseizo_SetupGreetPlayer_NoReward; + if ((pthis->frameCount <= curFrame) && !pthis->animationChanged) { + pthis->actionFunc = BgDyYoseizo_SetupGreetPlayer_NoReward; } } -void BgDyYoseizo_SetupGreetPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { - func_8002DF54(globalCtx, &this->actor, 1); +void BgDyYoseizo_SetupGreetPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + func_8002DF54(globalCtx, &pthis->actor, 1); if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairySittingAnim); - Animation_Change(&this->skelAnime, &gGreatFairySittingAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairySittingAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairySittingAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyLayingSidewaysAnim); - Animation_Change(&this->skelAnime, &gGreatFairyLayingSidewaysAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyLayingSidewaysAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyLayingSidewaysAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } - this->actor.textId = 0xDB; - this->dialogState = TEXT_STATE_EVENT; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); - this->actionFunc = BgDyYoseizo_GreetPlayer_NoReward; + pthis->actor.textId = 0xDB; + pthis->dialogState = TEXT_STATE_EVENT; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); + pthis->actionFunc = BgDyYoseizo_GreetPlayer_NoReward; } -void BgDyYoseizo_GreetPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { - func_8002DF54(globalCtx, &this->actor, 1); - this->bobTimer = this->skelAnime.curFrame * 1273.0f; +void BgDyYoseizo_GreetPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->bobTimer = pthis->skelAnime.curFrame * 1273.0f; - if ((this->frameCount * 1273.0f) <= this->bobTimer) { - this->bobTimer = 0.0f; + if ((pthis->frameCount * 1273.0f) <= pthis->bobTimer) { + pthis->bobTimer = 0.0f; } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if ((this->dialogState == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if ((pthis->dialogState == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { Message_CloseTextbox(globalCtx); Interface_ChangeAlpha(5); - this->actionFunc = BgDyYoseizo_SetupHealPlayer_NoReward; + pthis->actionFunc = BgDyYoseizo_SetupHealPlayer_NoReward; } - BgDyYoseizo_Bob(this, globalCtx); - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_Bob(pthis, globalCtx); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); } -void BgDyYoseizo_SetupHealPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_SetupHealPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairyGivingUpgradeAnim); - Animation_Change(&this->skelAnime, &gGreatFairyGivingUpgradeAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_ONCE, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyGivingUpgradeAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyGivingUpgradeAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyAnim_005810); - Animation_Change(&this->skelAnime, &gGreatFairyAnim_005810, 1.0f, 0.0f, this->frameCount, ANIMMODE_ONCE, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyAnim_005810); + Animation_Change(&pthis->skelAnime, &gGreatFairyAnim_005810, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } - Audio_PlayActorSound2(&this->actor, NA_SE_VO_FR_SMILE_0); - this->mouthState = 1; - this->actionFunc = BgDyYoseizo_HealPlayer_NoReward; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_FR_SMILE_0); + pthis->mouthState = 1; + pthis->actionFunc = BgDyYoseizo_HealPlayer_NoReward; } -void BgDyYoseizo_HealPlayer_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_HealPlayer_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - f32 curFrame = this->skelAnime.curFrame; + f32 curFrame = pthis->skelAnime.curFrame; Vec3f beamPos; s16 beamParams; - if (this->animationChanged) { - this->bobTimer = this->skelAnime.curFrame * 1300.0f; - if ((this->frameCount * 1300.0f) <= this->bobTimer) { - this->bobTimer = 0.0f; + if (pthis->animationChanged) { + pthis->bobTimer = pthis->skelAnime.curFrame * 1300.0f; + if ((pthis->frameCount * 1300.0f) <= pthis->bobTimer) { + pthis->bobTimer = 0.0f; } } - SkelAnime_Update(&this->skelAnime); - if ((this->frameCount <= curFrame) && !(this->animationChanged)) { + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->frameCount <= curFrame) && !(pthis->animationChanged)) { if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairyAfterUpgradeAnim); - Animation_Change(&this->skelAnime, &gGreatFairyAfterUpgradeAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyAfterUpgradeAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyAfterUpgradeAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyAfterSpellAnim); - Animation_Change(&this->skelAnime, &gGreatFairyAfterSpellAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyAfterSpellAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyAfterSpellAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } - this->healingTimer = 150; - this->animationChanged = true; - if (!this->givingSpell) { + pthis->healingTimer = 150; + pthis->animationChanged = true; + if (!pthis->givingSpell) { beamPos.x = player->actor.world.pos.x; beamPos.y = player->actor.world.pos.y + 200.0f; beamPos.z = player->actor.world.pos.z; beamParams = ((globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) ? 0 : 1); - this->beam = - (EnDyExtra*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_DY_EXTRA, + pthis->beam = + (EnDyExtra*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_DY_EXTRA, beamPos.x, beamPos.y, beamPos.z, 0, 0, 0, beamParams); } } - if (this->refillTimer > 1) { - this->refillTimer--; + if (pthis->refillTimer > 1) { + pthis->refillTimer--; } - if (this->healingTimer >= 110) { - this->healingTimer--; + if (pthis->healingTimer >= 110) { + pthis->healingTimer--; } - if (this->healingTimer == 110) { + if (pthis->healingTimer == 110) { gSaveContext.healthAccumulator = 0x140; Magic_Fill(globalCtx); - this->refillTimer = 200; + pthis->refillTimer = 200; } if (((gSaveContext.healthCapacity == gSaveContext.health) && (gSaveContext.magic == gSaveContext.unk_13F4)) || - (this->refillTimer == 1)) { - this->healingTimer--; - if (this->healingTimer == 90) { - if (!this->givingSpell) { - this->beam->trigger = 1; + (pthis->refillTimer == 1)) { + pthis->healingTimer--; + if (pthis->healingTimer == 90) { + if (!pthis->givingSpell) { + pthis->beam->trigger = 1; } - this->givingSpell = false; + pthis->givingSpell = false; } } - if (this->healingTimer == 1) { - this->actor.textId = 0xDA; - this->dialogState = TEXT_STATE_EVENT; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->actionFunc = BgDyYoseizo_SayFarewell_NoReward; + if (pthis->healingTimer == 1) { + pthis->actor.textId = 0xDA; + pthis->dialogState = TEXT_STATE_EVENT; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->actionFunc = BgDyYoseizo_SayFarewell_NoReward; return; } - BgDyYoseizo_Bob(this, globalCtx); + BgDyYoseizo_Bob(pthis, globalCtx); } -void BgDyYoseizo_SayFarewell_NoReward(BgDyYoseizo* this, GlobalContext* globalCtx) { - this->bobTimer = this->skelAnime.curFrame * 1400.0f; +void BgDyYoseizo_SayFarewell_NoReward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + pthis->bobTimer = pthis->skelAnime.curFrame * 1400.0f; - if (this->bobTimer >= (this->frameCount * 1400.0f)) { - this->bobTimer = 0.0f; + if (pthis->bobTimer >= (pthis->frameCount * 1400.0f)) { + pthis->bobTimer = 0.0f; } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if ((this->dialogState == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if ((pthis->dialogState == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { Message_CloseTextbox(globalCtx); - this->mouthState = 0; - this->actionFunc = BgDyYoseizo_SetupSpinShrink; + pthis->mouthState = 0; + pthis->actionFunc = BgDyYoseizo_SetupSpinShrink; func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); } - BgDyYoseizo_Bob(this, globalCtx); - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_Bob(pthis, globalCtx); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); } -void BgDyYoseizo_SetupSpinShrink(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_SetupSpinShrink(BgDyYoseizo* pthis, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairyJewelFountainSpinShrinkAnim); - Animation_Change(&this->skelAnime, &gGreatFairyJewelFountainSpinShrinkAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyJewelFountainSpinShrinkAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyJewelFountainSpinShrinkAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairySpellFountainSpinShrinkAnim); - Animation_Change(&this->skelAnime, &gGreatFairySpellFountainSpinShrinkAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairySpellFountainSpinShrinkAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairySpellFountainSpinShrinkAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } - this->vanishTimer = 5; - this->scaleFraction = 0.0f; - this->heightFraction = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_FR_LAUGH_0); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GREAT_FAIRY_VANISH); - this->actionFunc = BgDyYoseizo_SpinShrink; + pthis->vanishTimer = 5; + pthis->scaleFraction = 0.0f; + pthis->heightFraction = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_FR_LAUGH_0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GREAT_FAIRY_VANISH); + pthis->actionFunc = BgDyYoseizo_SpinShrink; } -void BgDyYoseizo_SpinShrink(BgDyYoseizo* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->vanishTimer == 0) { - if (this->scale < 0.003f) { - this->vanishTimer = 30; - this->actionFunc = BgDyYoseizo_Vanish; +void BgDyYoseizo_SpinShrink(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->vanishTimer == 0) { + if (pthis->scale < 0.003f) { + pthis->vanishTimer = 30; + pthis->actionFunc = BgDyYoseizo_Vanish; } else { - Math_ApproachF(&this->actor.world.pos.y, this->vanishHeight, this->heightFraction, 100.0f); - Math_ApproachZeroF(&this->scale, this->scaleFraction, 0.005f); - Math_ApproachF(&this->heightFraction, 0.8f, 0.1f, 0.02f); - Math_ApproachF(&this->scaleFraction, 0.2f, 0.03f, 0.05f); - this->actor.shape.rot.y += 3000; - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->vanishHeight, pthis->heightFraction, 100.0f); + Math_ApproachZeroF(&pthis->scale, pthis->scaleFraction, 0.005f); + Math_ApproachF(&pthis->heightFraction, 0.8f, 0.1f, 0.02f); + Math_ApproachF(&pthis->scaleFraction, 0.2f, 0.03f, 0.05f); + pthis->actor.shape.rot.y += 3000; + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); } } } -void BgDyYoseizo_Vanish(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_Vanish(BgDyYoseizo* pthis, GlobalContext* globalCtx) { Actor* findOcarinaSpot; - if (this->vanishTimer == 0) { - func_8002DF54(globalCtx, &this->actor, 7); + if (pthis->vanishTimer == 0) { + func_8002DF54(globalCtx, &pthis->actor, 7); globalCtx->envCtx.unk_BF = 0; findOcarinaSpot = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; @@ -576,89 +576,89 @@ void BgDyYoseizo_Vanish(BgDyYoseizo* this, GlobalContext* globalCtx) { } Flags_UnsetSwitch(globalCtx, 0x38); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void BgDyYoseizo_SetupSpinGrow_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_SetupSpinGrow_Reward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != CS_STATE_IDLE) { if ((globalCtx->csCtx.npcActions[0] != NULL) && (globalCtx->csCtx.npcActions[0]->action == 2)) { - this->actor.draw = BgDyYoseizo_Draw; - func_8002DF54(globalCtx, &this->actor, 1); - this->finishedSpinGrow = false; + pthis->actor.draw = BgDyYoseizo_Draw; + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->finishedSpinGrow = false; if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairySittingTransitionAnim); - Animation_Change(&this->skelAnime, &gGreatFairySittingTransitionAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairySittingTransitionAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairySittingTransitionAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyLayingDownTransitionAnim); - Animation_Change(&this->skelAnime, &gGreatFairyLayingDownTransitionAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyLayingDownTransitionAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyLayingDownTransitionAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GREAT_FAIRY_APPEAR); - this->actionFunc = BgDyYoseizo_SpinGrowSetupGive_Reward; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GREAT_FAIRY_APPEAR); + pthis->actionFunc = BgDyYoseizo_SpinGrowSetupGive_Reward; } } } -void BgDyYoseizo_SpinGrowSetupGive_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { - f32 curFrame = this->skelAnime.curFrame; +void BgDyYoseizo_SpinGrowSetupGive_Reward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + f32 curFrame = pthis->skelAnime.curFrame; - if (!this->finishedSpinGrow) { - Math_ApproachF(&this->actor.world.pos.y, this->grownHeight, this->heightFraction, 100.0f); - Math_ApproachF(&this->scale, 0.035f, this->scaleFraction, 0.005f); - Math_ApproachF(&this->heightFraction, 0.8f, 0.1f, 0.02f); - Math_ApproachF(&this->scaleFraction, 0.2f, 0.03f, 0.05f); + if (!pthis->finishedSpinGrow) { + Math_ApproachF(&pthis->actor.world.pos.y, pthis->grownHeight, pthis->heightFraction, 100.0f); + Math_ApproachF(&pthis->scale, 0.035f, pthis->scaleFraction, 0.005f); + Math_ApproachF(&pthis->heightFraction, 0.8f, 0.1f, 0.02f); + Math_ApproachF(&pthis->scaleFraction, 0.2f, 0.03f, 0.05f); // Finished growing - if (this->scale >= 0.034f) { - if ((this->actor.shape.rot.y > -8000) && (this->actor.shape.rot.y < 1000)) { - SkelAnime_Update(&this->skelAnime); + if (pthis->scale >= 0.034f) { + if ((pthis->actor.shape.rot.y > -8000) && (pthis->actor.shape.rot.y < 1000)) { + SkelAnime_Update(&pthis->skelAnime); // Spin until facing front - Math_ApproachS(&this->actor.shape.rot.y, 0, 5, 1000); - if (fabsf(this->actor.shape.rot.y) < 50.0f) { - this->finishedSpinGrow = true; + Math_ApproachS(&pthis->actor.shape.rot.y, 0, 5, 1000); + if (fabsf(pthis->actor.shape.rot.y) < 50.0f) { + pthis->finishedSpinGrow = true; } } else { - this->actor.shape.rot.y += 3000; + pthis->actor.shape.rot.y += 3000; } } else { - this->actor.shape.rot.y += 3000; + pthis->actor.shape.rot.y += 3000; } } else { - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if ((this->frameCount <= curFrame) && !this->animationChanged) { + if ((pthis->frameCount <= curFrame) && !pthis->animationChanged) { if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairySittingAnim); - Animation_Change(&this->skelAnime, &gGreatFairySittingAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairySittingAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairySittingAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyLayingSidewaysAnim); - Animation_Change(&this->skelAnime, &gGreatFairyLayingSidewaysAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyLayingSidewaysAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyLayingSidewaysAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } - this->animationChanged = true; + pthis->animationChanged = true; } if ((globalCtx->csCtx.state != CS_STATE_IDLE) && ((globalCtx->csCtx.npcActions[0] != NULL) && (globalCtx->csCtx.npcActions[0]->action == 3))) { - this->finishedSpinGrow = this->animationChanged = false; + pthis->finishedSpinGrow = pthis->animationChanged = false; if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairyGivingUpgradeAnim); - Animation_Change(&this->skelAnime, &gGreatFairyGivingUpgradeAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyGivingUpgradeAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyGivingUpgradeAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyAnim_005810); - Animation_Change(&this->skelAnime, &gGreatFairyAnim_005810, 1.0f, 0.0f, this->frameCount, ANIMMODE_ONCE, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyAnim_005810); + Animation_Change(&pthis->skelAnime, &gGreatFairyAnim_005810, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); } - this->mouthState = 1; - this->actionFunc = BgDyYoseizo_Give_Reward; + pthis->mouthState = 1; + pthis->actionFunc = BgDyYoseizo_Give_Reward; } } - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); } static s16 sDemoEffectLightColors[] = { DEMO_EFFECT_LIGHT_GREEN, DEMO_EFFECT_LIGHT_RED, DEMO_EFFECT_LIGHT_BLUE }; @@ -669,36 +669,36 @@ static s16 sItemGetFlags[] = { 0x100, 0x200, 0x400 }; static u8 sItemIds[] = { ITEM_FARORES_WIND, ITEM_DINS_FIRE, ITEM_NAYRUS_LOVE }; -void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { - f32 curFrame = this->skelAnime.curFrame; +void BgDyYoseizo_Give_Reward(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + f32 curFrame = pthis->skelAnime.curFrame; Player* player = GET_PLAYER(globalCtx); s16 actionIndex; s16 demoEffectParams; Vec3f itemPos; - if (this->animationChanged) { - this->bobTimer = this->skelAnime.curFrame * 1400.0f; - if ((this->frameCount * 1400.0f) <= this->bobTimer) { - this->bobTimer = 0.0f; + if (pthis->animationChanged) { + pthis->bobTimer = pthis->skelAnime.curFrame * 1400.0f; + if ((pthis->frameCount * 1400.0f) <= pthis->bobTimer) { + pthis->bobTimer = 0.0f; } } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if ((this->frameCount <= curFrame) && !this->animationChanged) { + if ((pthis->frameCount <= curFrame) && !pthis->animationChanged) { if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { - this->frameCount = Animation_GetLastFrame(&gGreatFairyAfterUpgradeAnim); - Animation_Change(&this->skelAnime, &gGreatFairyAfterUpgradeAnim, 1.0f, 0.0f, this->frameCount, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyAfterUpgradeAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyAfterUpgradeAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } else { - this->frameCount = Animation_GetLastFrame(&gGreatFairyAfterSpellAnim); - Animation_Change(&this->skelAnime, &gGreatFairyAfterSpellAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, + pthis->frameCount = Animation_GetLastFrame(&gGreatFairyAfterSpellAnim); + Animation_Change(&pthis->skelAnime, &gGreatFairyAfterSpellAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); } - this->animationChanged = true; + pthis->animationChanged = true; } if (globalCtx->csCtx.npcActions[0]->action == 13) { - this->actionFunc = BgDyYoseizo_SetupSpinShrink; + pthis->actionFunc = BgDyYoseizo_SetupSpinShrink; return; } @@ -706,16 +706,16 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { actionIndex = globalCtx->csCtx.npcActions[0]->action - 4; if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) { actionIndex++; - BgDyYoseizo_SpawnParticles(this, globalCtx, actionIndex); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, actionIndex); - } else if (!this->lightBallSpawned) { + } else if (!pthis->lightBallSpawned) { demoEffectParams = ((s16)(sDemoEffectLightColors[actionIndex] << 0xC) | DEMO_EFFECT_LIGHT); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, (s32)demoEffectParams); - this->lightBallSpawned = true; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, (s32)demoEffectParams); + pthis->lightBallSpawned = true; } } else { - BgDyYoseizo_SpawnParticles(this, globalCtx, 0); + BgDyYoseizo_SpawnParticles(pthis, globalCtx, 0); } if ((globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) && (globalCtx->csCtx.npcActions[0]->action >= 10) && @@ -743,9 +743,9 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { break; } - if (!this->healing) { + if (!pthis->healing) { gSaveContext.healthAccumulator = 0x140; - this->healing = true; + pthis->healing = true; if (actionIndex == 2) { Magic_Fill(globalCtx); } @@ -756,81 +756,81 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, GlobalContext* globalCtx) { (globalCtx->csCtx.npcActions[0]->action < 17)) { actionIndex = globalCtx->csCtx.npcActions[0]->action - 14; - if (!this->itemSpawned) { + if (!pthis->itemSpawned) { itemPos.x = player->actor.world.pos.x; itemPos.y = (LINK_IS_ADULT ? player->actor.world.pos.y + 73.0f : player->actor.world.pos.y + 53.0f); itemPos.z = player->actor.world.pos.z; - this->item = - (EnExItem*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_ITEM, + pthis->item = + (EnExItem*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_ITEM, itemPos.x, itemPos.y, itemPos.z, 0, 0, 0, sExItemTypes[actionIndex]); - if (this->item != NULL) { + if (pthis->item != NULL) { if (gSaveContext.magicAcquired == 0) { gSaveContext.magicAcquired = 1; } else { Magic_Fill(globalCtx); } - this->itemSpawned = true; + pthis->itemSpawned = true; gSaveContext.healthAccumulator = 0x140; Interface_ChangeAlpha(9); gSaveContext.itemGetInf[1] |= sItemGetFlags[actionIndex]; Item_Give(globalCtx, sItemIds[actionIndex]); } } else { - this->item->actor.world.pos.x = player->actor.world.pos.x; - this->item->actor.world.pos.y = + pthis->item->actor.world.pos.x = player->actor.world.pos.x; + pthis->item->actor.world.pos.y = (LINK_IS_ADULT ? player->actor.world.pos.y + 73.0f : player->actor.world.pos.y + 53.0f); - this->item->actor.world.pos.z = player->actor.world.pos.z; - this->item->scale = 0.3f; + pthis->item->actor.world.pos.z = player->actor.world.pos.z; + pthis->item->scale = 0.3f; } } if ((globalCtx->sceneNum != SCENE_DAIYOUSEI_IZUMI) && (globalCtx->csCtx.npcActions[0]->action == 17) && - (this->item != NULL)) { - Actor_Kill(&this->item->actor); - this->item = NULL; + (pthis->item != NULL)) { + Actor_Kill(&pthis->item->actor); + pthis->item = NULL; } if ((globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI) && (globalCtx->csCtx.npcActions[0]->action == 18)) { - this->giveDefenseHearts = true; + pthis->giveDefenseHearts = true; } - if (this->giveDefenseHearts) { + if (pthis->giveDefenseHearts) { if (gSaveContext.inventory.defenseHearts < 20) { gSaveContext.inventory.defenseHearts++; } } if ((globalCtx->csCtx.npcActions[0]->action >= 19) && (globalCtx->csCtx.npcActions[0]->action < 22) && - !this->warpEffectSpawned) { + !pthis->warpEffectSpawned) { actionIndex = globalCtx->csCtx.npcActions[0]->action - 11; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, actionIndex); - this->warpEffectSpawned = true; + pthis->warpEffectSpawned = true; } - BgDyYoseizo_Bob(this, globalCtx); + BgDyYoseizo_Bob(pthis, globalCtx); } -void BgDyYoseizo_Update(Actor* thisx, GlobalContext* globalCtx2) { +void BgDyYoseizo_Update(Actor* pthisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgDyYoseizo* this = (BgDyYoseizo*)thisx; + BgDyYoseizo* pthis = (BgDyYoseizo*)pthisx; s32 phi_v1; - this->absoluteTimer++; + pthis->absoluteTimer++; - if (this->vanishTimer != 0) { - this->vanishTimer--; + if (pthis->vanishTimer != 0) { + pthis->vanishTimer--; } - if (this->blinkTimer != 0) { - this->blinkTimer--; + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; } - if (this->unusedTimer != 0) { - this->unusedTimer--; + if (pthis->unusedTimer != 0) { + pthis->unusedTimer--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); if (globalCtx->csCtx.state != CS_STATE_IDLE) { phi_v1 = 0; @@ -853,41 +853,41 @@ void BgDyYoseizo_Update(Actor* thisx, GlobalContext* globalCtx2) { } if (phi_v1 == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_FR_SMILE_0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_FR_SMILE_0); } if (phi_v1 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_FR_LAUGH_0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_FR_LAUGH_0); } } - if ((this->blinkTimer == 0) && (this->actionFunc != BgDyYoseizo_HealPlayer_NoReward)) { - this->eyeState++; - this->eyeState2++; - if (this->eyeState >= 3) { - this->eyeState = this->eyeState2 = 0; - this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + if ((pthis->blinkTimer == 0) && (pthis->actionFunc != BgDyYoseizo_HealPlayer_NoReward)) { + pthis->eyeState++; + pthis->eyeState2++; + if (pthis->eyeState >= 3) { + pthis->eyeState = pthis->eyeState2 = 0; + pthis->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; } } - Actor_MoveForward(&this->actor); - this->heightOffset = this->scale * 7500.0f; - Actor_SetFocus(&this->actor, this->heightOffset); - this->actor.focus.pos.y = this->heightOffset; - func_80038290(globalCtx, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); - BgDyYoseizo_ParticleUpdate(this, globalCtx); - Actor_SetScale(&this->actor, this->scale); + Actor_MoveForward(&pthis->actor); + pthis->heightOffset = pthis->scale * 7500.0f; + Actor_SetFocus(&pthis->actor, pthis->heightOffset); + pthis->actor.focus.pos.y = pthis->heightOffset; + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->torsoRot, pthis->actor.focus.pos); + BgDyYoseizo_ParticleUpdate(pthis, globalCtx); + Actor_SetScale(&pthis->actor, pthis->scale); } s32 BgDyYoseizo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BgDyYoseizo* this = (BgDyYoseizo*)thisx; + void* pthisx) { + BgDyYoseizo* pthis = (BgDyYoseizo*)pthisx; if (limbIndex == 8) { // Torso - rot->x += this->torsoRot.y; + rot->x += pthis->torsoRot.y; } if (limbIndex == 15) { // Head - rot->x += this->headRot.y; - rot->z += this->headRot.z; + rot->x += pthis->headRot.y; + rot->z += pthis->headRot.z; } return 0; } @@ -903,34 +903,34 @@ static void* sMouthTextures[] = { gGreatFairyMouthOpenTex, // Open }; -void BgDyYoseizo_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgDyYoseizo* this = (BgDyYoseizo*)thisx; +void BgDyYoseizo_Draw(Actor* pthisx, GlobalContext* globalCtx) { + BgDyYoseizo* pthis = (BgDyYoseizo*)pthisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_dy_yoseizo.c", 1609); - if (this->actionFunc != BgDyYoseizo_Vanish) { + if (pthis->actionFunc != BgDyYoseizo_Vanish) { func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeState])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeState])); - // This was probably intended to allow this actor to wink, but segment 09 is not used in the dList for the head, + // This was probably intended to allow pthis actor to wink, but segment 09 is not used in the dList for the head, // so it can only blink - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeState2])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeState2])); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthState])); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sMouthTextures[pthis->mouthState])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BgDyYoseizo_OverrideLimbDraw, NULL, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BgDyYoseizo_OverrideLimbDraw, NULL, pthis); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_dy_yoseizo.c", 1629); - BgDyYoseizo_ParticleDraw(this, globalCtx); + BgDyYoseizo_ParticleDraw(pthis, globalCtx); } -void BgDyYoseizo_ParticleInit(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, +void BgDyYoseizo_ParticleInit(BgDyYoseizo* pthis, Vec3f* initPos, Vec3f* initVelocity, Vec3f* accel, Color_RGB8* primColor, Color_RGB8* envColor, f32 scale, s16 life, s16 type) { BgDyYoseizoParticle* particle; s16 i; - particle = this->particles; + particle = pthis->particles; for (i = 0; i < 200; i++, particle++) { if (particle->alive == 0) { @@ -952,8 +952,8 @@ void BgDyYoseizo_ParticleInit(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelo } } -void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx) { - BgDyYoseizoParticle* particle = this->particles; +void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* pthis, GlobalContext* globalCtx) { + BgDyYoseizoParticle* particle = pthis->particles; Player* player = GET_PLAYER(globalCtx); Vec3f sp94; Vec3f sp88; @@ -973,7 +973,7 @@ void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx) { particle->velocity.y += particle->accel.y; particle->velocity.z += particle->accel.z; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HEALING - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HEALING - SFX_FLAG); sp94 = player->actor.world.pos; sp94.y = player->actor.world.pos.y - 150.0f; @@ -1016,10 +1016,10 @@ void BgDyYoseizo_ParticleUpdate(BgDyYoseizo* this, GlobalContext* globalCtx) { } } -void BgDyYoseizo_ParticleDraw(BgDyYoseizo* this, GlobalContext* globalCtx) { +void BgDyYoseizo_ParticleDraw(BgDyYoseizo* pthis, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; u8 phi_s3 = 0; - BgDyYoseizoParticle* particle = this->particles; + BgDyYoseizoParticle* particle = pthis->particles; s16 i; OPEN_DISPS(gfxCtx, "../z_bg_dy_yoseizo.c", 1767); diff --git a/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c b/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.cpp similarity index 63% rename from src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c rename to src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.cpp index 5d1d31c61..948d5f3fd 100644 --- a/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c +++ b/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.cpp @@ -28,16 +28,16 @@ typedef enum { /* 0x02 */ FLASH_SHRINK } FlashState; -void BgGanonOtyuka_Init(Actor* thisx, GlobalContext* globalCtx); -void BgGanonOtyuka_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgGanonOtyuka_Update(Actor* thisx, GlobalContext* globalCtx); -void BgGanonOtyuka_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgGanonOtyuka_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgGanonOtyuka_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgGanonOtyuka_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgGanonOtyuka_Draw(Actor* pthisx, GlobalContext* globalCtx); -void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, GlobalContext* globalCtx); -void BgGanonOtyuka_Fall(BgGanonOtyuka* this, GlobalContext* globalCtx); -void BgGanonOtyuka_DoNothing(Actor* thisx, GlobalContext* globalCtx); +void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* pthis, GlobalContext* globalCtx); +void BgGanonOtyuka_Fall(BgGanonOtyuka* pthis, GlobalContext* globalCtx); +void BgGanonOtyuka_DoNothing(Actor* pthisx, GlobalContext* globalCtx); -const ActorInit Bg_Ganon_Otyuka_InitVars = { +ActorInit Bg_Ganon_Otyuka_InitVars = { ACTOR_BG_GANON_OTYUKA, ACTORCAT_PROP, FLAGS, @@ -75,39 +75,39 @@ static Vec3f sSideCenters[] = { static f32 sSideAngles[] = { M_PI / 2, -M_PI / 2, 0.0f, M_PI }; -#include "overlays/ovl_Bg_Ganon_Otyuka/ovl_Bg_Ganon_Otyuka.c" +#include "overlays/ovl_Bg_Ganon_Otyuka/ovl_Bg_Ganon_Otyuka.cpp" -void BgGanonOtyuka_Init(Actor* thisx, GlobalContext* globalCtx2) { - BgGanonOtyuka* this = (BgGanonOtyuka*)thisx; +void BgGanonOtyuka_Init(Actor* pthisx, GlobalContext* globalCtx2) { + BgGanonOtyuka* pthis = (BgGanonOtyuka*)pthisx; GlobalContext* globalCtx = globalCtx2; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(pthisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&sCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, pthisx, colHeader); - if (thisx->params != 0x23) { - thisx->draw = NULL; - this->actionFunc = BgGanonOtyuka_WaitToFall; + if (pthisx->params != 0x23) { + pthisx->draw = NULL; + pthis->actionFunc = BgGanonOtyuka_WaitToFall; } else { - thisx->update = BgGanonOtyuka_DoNothing; + pthisx->update = BgGanonOtyuka_DoNothing; } } -void BgGanonOtyuka_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - BgGanonOtyuka* this = (BgGanonOtyuka*)thisx; +void BgGanonOtyuka_Destroy(Actor* pthisx, GlobalContext* globalCtx2) { + BgGanonOtyuka* pthis = (BgGanonOtyuka*)pthisx; GlobalContext* globalCtx = globalCtx2; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("WHY !!!!!!!!!!!!!!!!\n"); osSyncPrintf(VT_RST); } -void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* pthis, GlobalContext* globalCtx) { + Actor* pthisx = &pthis->dyna.actor; Actor* prop; BgGanonOtyuka* platform; f32 dx; @@ -116,22 +116,22 @@ void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, GlobalContext* globalCtx) { Vec3f center; s16 i; - if (this->isFalling || ((globalCtx->actorCtx.unk_02 != 0) && (this->dyna.actor.xyzDistToPlayerSq < 4900.0f))) { + if (pthis->isFalling || ((globalCtx->actorCtx.unk_02 != 0) && (pthis->dyna.actor.xyzDistToPlayerSq < 4900.0f))) { osSyncPrintf("OTC O 1\n"); for (i = 0; i < ARRAY_COUNT(D_80876A68); i++) { prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; while (prop != NULL) { - if ((prop == thisx) || (prop->id != ACTOR_BG_GANON_OTYUKA)) { + if ((prop == pthisx) || (prop->id != ACTOR_BG_GANON_OTYUKA)) { prop = prop->next; continue; } platform = (BgGanonOtyuka*)prop; - dx = platform->dyna.actor.world.pos.x - this->dyna.actor.world.pos.x + D_80876A68[i].x; - dy = platform->dyna.actor.world.pos.y - this->dyna.actor.world.pos.y; - dz = platform->dyna.actor.world.pos.z - this->dyna.actor.world.pos.z + D_80876A68[i].z; + dx = platform->dyna.actor.world.pos.x - pthis->dyna.actor.world.pos.x + D_80876A68[i].x; + dy = platform->dyna.actor.world.pos.y - pthis->dyna.actor.world.pos.y; + dz = platform->dyna.actor.world.pos.z - pthis->dyna.actor.world.pos.z + D_80876A68[i].z; if ((fabsf(dx) < 10.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 10.0f)) { platform->visibleSides |= sSides[i]; @@ -145,31 +145,31 @@ void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, GlobalContext* globalCtx) { osSyncPrintf("OTC O 2\n"); for (i = 0; i < ARRAY_COUNT(D_80876A68); i++) { - center.x = this->dyna.actor.world.pos.x + D_80876A68[i].x; - center.y = this->dyna.actor.world.pos.y; - center.z = this->dyna.actor.world.pos.z + D_80876A68[i].z; + center.x = pthis->dyna.actor.world.pos.x + D_80876A68[i].x; + center.y = pthis->dyna.actor.world.pos.y; + center.z = pthis->dyna.actor.world.pos.z + D_80876A68[i].z; if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, ¢er, 50.0f)) { - this->unwalledSides |= sSides[i]; + pthis->unwalledSides |= sSides[i]; } } osSyncPrintf("OTC O 3\n"); - this->actionFunc = BgGanonOtyuka_Fall; - this->isFalling = true; - this->dropTimer = 20; - this->flashState = FLASH_GROW; - this->flashTimer = 0; - this->flashPrimColorR = 255.0f; - this->flashPrimColorG = 255.0f; - this->flashPrimColorB = 255.0f; - this->flashEnvColorR = 255.0f; - this->flashEnvColorG = 255.0f; - this->flashEnvColorB = 0.0f; + pthis->actionFunc = BgGanonOtyuka_Fall; + pthis->isFalling = true; + pthis->dropTimer = 20; + pthis->flashState = FLASH_GROW; + pthis->flashTimer = 0; + pthis->flashPrimColorR = 255.0f; + pthis->flashPrimColorG = 255.0f; + pthis->flashPrimColorB = 255.0f; + pthis->flashEnvColorR = 255.0f; + pthis->flashEnvColorG = 255.0f; + pthis->flashEnvColorB = 0.0f; } } -void BgGanonOtyuka_Fall(BgGanonOtyuka* this, GlobalContext* globalCtx) { +void BgGanonOtyuka_Fall(BgGanonOtyuka* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 i; Vec3f pos; @@ -177,86 +177,86 @@ void BgGanonOtyuka_Fall(BgGanonOtyuka* this, GlobalContext* globalCtx) { Vec3f accel; osSyncPrintf("MODE DOWN\n"); - if (this->flashState == FLASH_GROW) { - Math_ApproachF(&this->flashPrimColorB, 170.0f, 1.0f, 8.5f); - Math_ApproachF(&this->flashEnvColorR, 120.0f, 1.0f, 13.5f); - Math_ApproachF(&this->flashYScale, 2.5f, 1.0f, 0.25f); - if (this->flashYScale == 2.5f) { - this->flashState = FLASH_SHRINK; + if (pthis->flashState == FLASH_GROW) { + Math_ApproachF(&pthis->flashPrimColorB, 170.0f, 1.0f, 8.5f); + Math_ApproachF(&pthis->flashEnvColorR, 120.0f, 1.0f, 13.5f); + Math_ApproachF(&pthis->flashYScale, 2.5f, 1.0f, 0.25f); + if (pthis->flashYScale == 2.5f) { + pthis->flashState = FLASH_SHRINK; } - } else if (this->flashState == FLASH_SHRINK) { - Math_ApproachF(&this->flashPrimColorG, 0.0f, 1.0f, 25.5f); - Math_ApproachF(&this->flashEnvColorR, 0.0f, 1.0f, 12.0f); - Math_ApproachF(&this->flashEnvColorG, 0.0f, 1.0f, 25.5f); - Math_ApproachZeroF(&this->flashYScale, 1.0f, 0.25f); - if (this->flashYScale == 0.0f) { - this->flashState = FLASH_NONE; + } else if (pthis->flashState == FLASH_SHRINK) { + Math_ApproachF(&pthis->flashPrimColorG, 0.0f, 1.0f, 25.5f); + Math_ApproachF(&pthis->flashEnvColorR, 0.0f, 1.0f, 12.0f); + Math_ApproachF(&pthis->flashEnvColorG, 0.0f, 1.0f, 25.5f); + Math_ApproachZeroF(&pthis->flashYScale, 1.0f, 0.25f); + if (pthis->flashYScale == 0.0f) { + pthis->flashState = FLASH_NONE; } } - if (this->dropTimer == 0) { - this->flashYScale = 0.0f; - Math_ApproachF(&this->dyna.actor.world.pos.y, -1000.0f, 1.0f, this->dyna.actor.speedXZ); - Math_ApproachF(&this->dyna.actor.speedXZ, 100.0f, 1.0f, 2.0f); - if (!(this->unwalledSides & OTYUKA_SIDE_EAST)) { - this->dyna.actor.shape.rot.z -= (s16)(this->dyna.actor.speedXZ * 30.0f); + if (pthis->dropTimer == 0) { + pthis->flashYScale = 0.0f; + Math_ApproachF(&pthis->dyna.actor.world.pos.y, -1000.0f, 1.0f, pthis->dyna.actor.speedXZ); + Math_ApproachF(&pthis->dyna.actor.speedXZ, 100.0f, 1.0f, 2.0f); + if (!(pthis->unwalledSides & OTYUKA_SIDE_EAST)) { + pthis->dyna.actor.shape.rot.z -= (s16)(pthis->dyna.actor.speedXZ * 30.0f); } - if (!(this->unwalledSides & OTYUKA_SIDE_WEST)) { - this->dyna.actor.shape.rot.z += (s16)(this->dyna.actor.speedXZ * 30.0f); + if (!(pthis->unwalledSides & OTYUKA_SIDE_WEST)) { + pthis->dyna.actor.shape.rot.z += (s16)(pthis->dyna.actor.speedXZ * 30.0f); } - if (!(this->unwalledSides & OTYUKA_SIDE_SOUTH)) { - this->dyna.actor.shape.rot.x += (s16)(this->dyna.actor.speedXZ * 30.0f); + if (!(pthis->unwalledSides & OTYUKA_SIDE_SOUTH)) { + pthis->dyna.actor.shape.rot.x += (s16)(pthis->dyna.actor.speedXZ * 30.0f); } - if (!(this->unwalledSides & OTYUKA_SIDE_NORTH)) { - this->dyna.actor.shape.rot.x -= (s16)(this->dyna.actor.speedXZ * 30.0f); + if (!(pthis->unwalledSides & OTYUKA_SIDE_NORTH)) { + pthis->dyna.actor.shape.rot.x -= (s16)(pthis->dyna.actor.speedXZ * 30.0f); } - if (this->dyna.actor.world.pos.y < -750.0f) { + if (pthis->dyna.actor.world.pos.y < -750.0f) { if (player->actor.world.pos.y < -400.0f) { accel.x = accel.z = 0.0f; accel.y = 0.1f; velocity.x = velocity.y = velocity.z = 0.0f; for (i = 0; i < 30; i++) { - pos.x = Rand_CenteredFloat(150.0f) + this->dyna.actor.world.pos.x; + pos.x = Rand_CenteredFloat(150.0f) + pthis->dyna.actor.world.pos.x; pos.y = Rand_ZeroFloat(60.0f) + -750.0f; - pos.z = Rand_CenteredFloat(150.0f) + this->dyna.actor.world.pos.z; + pos.z = Rand_CenteredFloat(150.0f) + pthis->dyna.actor.world.pos.z; func_8002836C(globalCtx, &pos, &velocity, &accel, &sDustPrimColor, &sDustEnvColor, (s16)Rand_ZeroFloat(100.0f) + 250, 5, (s16)Rand_ZeroFloat(5.0f) + 15); } func_80033DB8(globalCtx, 10, 15); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 0x28, NA_SE_EV_BOX_BREAK); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 0x28, NA_SE_EV_BOX_BREAK); } - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } else { - if (this->dropTimer == 1) { - Audio_PlaySoundGeneral(NA_SE_EV_STONEDOOR_STOP, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, + if (pthis->dropTimer == 1) { + Audio_PlaySoundGeneral(NA_SE_EV_STONEDOOR_STOP, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - Audio_PlaySoundGeneral(NA_SE_EV_BLOCKSINK - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EV_BLOCKSINK - SFX_FLAG, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Math_ApproachF(&this->dyna.actor.world.pos.y, -1000.0f, 1.0f, this->dyna.actor.speedXZ); - Math_ApproachF(&this->dyna.actor.speedXZ, 100.0f, 1.0f, 0.1f); + Math_ApproachF(&pthis->dyna.actor.world.pos.y, -1000.0f, 1.0f, pthis->dyna.actor.speedXZ); + Math_ApproachF(&pthis->dyna.actor.speedXZ, 100.0f, 1.0f, 0.1f); } osSyncPrintf("MODE DOWN END\n"); } -void BgGanonOtyuka_DoNothing(Actor* thisx, GlobalContext* globalCtx) { +void BgGanonOtyuka_DoNothing(Actor* pthisx, GlobalContext* globalCtx) { } -void BgGanonOtyuka_Update(Actor* thisx, GlobalContext* globalCtx) { - BgGanonOtyuka* this = (BgGanonOtyuka*)thisx; +void BgGanonOtyuka_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgGanonOtyuka* pthis = (BgGanonOtyuka*)pthisx; - this->actionFunc(this, globalCtx); - this->flashTimer++; - if (this->dropTimer != 0) { - this->dropTimer--; + pthis->actionFunc(pthis, globalCtx); + pthis->flashTimer++; + if (pthis->dropTimer != 0) { + pthis->dropTimer--; } } -void BgGanonOtyuka_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgGanonOtyuka* this = (BgGanonOtyuka*)thisx; +void BgGanonOtyuka_Draw(Actor* pthisx, GlobalContext* globalCtx) { + BgGanonOtyuka* pthis = (BgGanonOtyuka*)pthisx; s16 i; Gfx* phi_s2; Gfx* phi_s1; diff --git a/src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.c b/src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.c deleted file mode 100644 index c6d231338..000000000 --- a/src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.c +++ /dev/null @@ -1,144 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_GATE_SHUTTER_Z_BG_GATE_SHUTTER_C -#include "actor_common.h" -/* - * File: z_bg_gate_shutter.c - * Overlay: Bg_Gate_Shutter - * Description: Death Mountain Trail Gate - */ - -#include "z_bg_gate_shutter.h" -#include "objects/object_spot01_matoyab/object_spot01_matoyab.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void BgGateShutter_Init(Actor* thisx, GlobalContext* globalCtx); -void BgGateShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgGateShutter_Update(Actor* thisx, GlobalContext* globalCtx); -void BgGateShutter_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8087828C(BgGateShutter* this, GlobalContext* globalCtx); -void func_80878300(BgGateShutter* this, GlobalContext* globalCtx); -void func_808783AC(BgGateShutter* this, GlobalContext* globalCtx); -void func_808783D4(BgGateShutter* this, GlobalContext* globalCtx); - -const ActorInit Bg_Gate_Shutter_InitVars = { - ACTOR_BG_GATE_SHUTTER, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_SPOT01_MATOYAB, - sizeof(BgGateShutter), - (ActorFunc)BgGateShutter_Init, - (ActorFunc)BgGateShutter_Destroy, - (ActorFunc)BgGateShutter_Update, - (ActorFunc)BgGateShutter_Draw, -}; - -void BgGateShutter_Init(Actor* thisx, GlobalContext* globalCtx) { - BgGateShutter* this = (BgGateShutter*)thisx; - s32 pad[2]; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gKakarikoGuardGateCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - this->somePos.x = thisx->world.pos.x; - this->somePos.y = thisx->world.pos.y; - this->somePos.z = thisx->world.pos.z; - if (((gSaveContext.infTable[7] & 0x40) || (gSaveContext.eventChkInf[4] & 0x20)) && - (globalCtx->sceneNum == SCENE_SPOT01)) { - thisx->world.pos.x = -89.0f; - thisx->world.pos.z = -1375.0f; - } - thisx->scale.x = 1.0f; - thisx->scale.y = 1.0f; - thisx->scale.z = 1.0f; - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 柵でたなぁ ☆☆☆☆☆ \n" VT_RST); - this->actionFunc = func_8087828C; -} - -void BgGateShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgGateShutter* this = (BgGateShutter*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_8087828C(BgGateShutter* this, GlobalContext* globalCtx) { - if (this->openingState == 1 && !(gSaveContext.infTable[7] & 0x40)) { - this->unk_178 = 2; - this->actionFunc = func_80878300; - } else if (this->openingState == 2) { - this->unk_178 = 2; - this->actionFunc = func_80878300; - } else if (this->openingState < 0) { - this->unk_178 = 2; - this->actionFunc = func_808783D4; - } -} - -void func_80878300(BgGateShutter* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - - if (this->unk_178 == 0) { - Audio_PlayActorSound2(thisx, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); - thisx->world.pos.x -= 2.0f; - Math_ApproachF(&thisx->world.pos.z, -1375.0f, 0.8f, 0.3f); - if (thisx->world.pos.x < -89.0f) { - Audio_PlayActorSound2(thisx, NA_SE_EV_BRIDGE_OPEN_STOP); - this->unk_178 = 0x1E; - this->actionFunc = func_808783AC; - } - } -} - -void func_808783AC(BgGateShutter* this, GlobalContext* globalCtx) { - if (this->unk_178 == 0) { - this->openingState = 0; - this->actionFunc = func_8087828C; - } -} - -void func_808783D4(BgGateShutter* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - - if (this->unk_178 == 0) { - Audio_PlayActorSound2(thisx, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); - thisx->world.pos.x += 2.0f; - Math_ApproachF(&thisx->world.pos.z, -1350.0f, 0.8f, 0.3f); - if (thisx->world.pos.x > 90.0f) { - thisx->world.pos.x = 91.0f; - Audio_PlayActorSound2(thisx, NA_SE_EV_BRIDGE_OPEN_STOP); - this->unk_178 = 30; - this->actionFunc = func_808783AC; - } - } -} - -void BgGateShutter_Update(Actor* thisx, GlobalContext* globalCtx) { - BgGateShutter* this = (BgGateShutter*)thisx; - - if (this->unk_178 != 0) { - this->unk_178 -= 1; - } - this->actionFunc(this, globalCtx); -} - -void BgGateShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gate_shutter.c", 323); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_gate_shutter.c", 328), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gKakarikoGuardGateDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gate_shutter.c", 333); -} diff --git a/src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.cpp b/src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.cpp new file mode 100644 index 000000000..009b58c8a --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.cpp @@ -0,0 +1,144 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_GATE_SHUTTER_Z_BG_GATE_SHUTTER_C +#include "actor_common.h" +/* + * File: z_bg_gate_shutter.c + * Overlay: Bg_Gate_Shutter + * Description: Death Mountain Trail Gate + */ + +#include "z_bg_gate_shutter.h" +#include "objects/object_spot01_matoyab/object_spot01_matoyab.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void BgGateShutter_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgGateShutter_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgGateShutter_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgGateShutter_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void func_8087828C(BgGateShutter* pthis, GlobalContext* globalCtx); +void func_80878300(BgGateShutter* pthis, GlobalContext* globalCtx); +void func_808783AC(BgGateShutter* pthis, GlobalContext* globalCtx); +void func_808783D4(BgGateShutter* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Gate_Shutter_InitVars = { + ACTOR_BG_GATE_SHUTTER, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_SPOT01_MATOYAB, + sizeof(BgGateShutter), + (ActorFunc)BgGateShutter_Init, + (ActorFunc)BgGateShutter_Destroy, + (ActorFunc)BgGateShutter_Update, + (ActorFunc)BgGateShutter_Draw, +}; + +void BgGateShutter_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgGateShutter* pthis = (BgGateShutter*)pthisx; + s32 pad[2]; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gKakarikoGuardGateCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, pthisx, colHeader); + pthis->somePos.x = pthisx->world.pos.x; + pthis->somePos.y = pthisx->world.pos.y; + pthis->somePos.z = pthisx->world.pos.z; + if (((gSaveContext.infTable[7] & 0x40) || (gSaveContext.eventChkInf[4] & 0x20)) && + (globalCtx->sceneNum == SCENE_SPOT01)) { + pthisx->world.pos.x = -89.0f; + pthisx->world.pos.z = -1375.0f; + } + pthisx->scale.x = 1.0f; + pthisx->scale.y = 1.0f; + pthisx->scale.z = 1.0f; + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 柵でたなぁ ☆☆☆☆☆ \n" VT_RST); + pthis->actionFunc = func_8087828C; +} + +void BgGateShutter_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgGateShutter* pthis = (BgGateShutter*)pthisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_8087828C(BgGateShutter* pthis, GlobalContext* globalCtx) { + if (pthis->openingState == 1 && !(gSaveContext.infTable[7] & 0x40)) { + pthis->unk_178 = 2; + pthis->actionFunc = func_80878300; + } else if (pthis->openingState == 2) { + pthis->unk_178 = 2; + pthis->actionFunc = func_80878300; + } else if (pthis->openingState < 0) { + pthis->unk_178 = 2; + pthis->actionFunc = func_808783D4; + } +} + +void func_80878300(BgGateShutter* pthis, GlobalContext* globalCtx) { + Actor* pthisx = &pthis->dyna.actor; + + if (pthis->unk_178 == 0) { + Audio_PlayActorSound2(pthisx, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + pthisx->world.pos.x -= 2.0f; + Math_ApproachF(&pthisx->world.pos.z, -1375.0f, 0.8f, 0.3f); + if (pthisx->world.pos.x < -89.0f) { + Audio_PlayActorSound2(pthisx, NA_SE_EV_BRIDGE_OPEN_STOP); + pthis->unk_178 = 0x1E; + pthis->actionFunc = func_808783AC; + } + } +} + +void func_808783AC(BgGateShutter* pthis, GlobalContext* globalCtx) { + if (pthis->unk_178 == 0) { + pthis->openingState = 0; + pthis->actionFunc = func_8087828C; + } +} + +void func_808783D4(BgGateShutter* pthis, GlobalContext* globalCtx) { + Actor* pthisx = &pthis->dyna.actor; + + if (pthis->unk_178 == 0) { + Audio_PlayActorSound2(pthisx, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + pthisx->world.pos.x += 2.0f; + Math_ApproachF(&pthisx->world.pos.z, -1350.0f, 0.8f, 0.3f); + if (pthisx->world.pos.x > 90.0f) { + pthisx->world.pos.x = 91.0f; + Audio_PlayActorSound2(pthisx, NA_SE_EV_BRIDGE_OPEN_STOP); + pthis->unk_178 = 30; + pthis->actionFunc = func_808783AC; + } + } +} + +void BgGateShutter_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgGateShutter* pthis = (BgGateShutter*)pthisx; + + if (pthis->unk_178 != 0) { + pthis->unk_178 -= 1; + } + pthis->actionFunc(pthis, globalCtx); +} + +void BgGateShutter_Draw(Actor* pthisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gate_shutter.c", 323); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_gate_shutter.c", 328), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gKakarikoGuardGateDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gate_shutter.c", 333); +} diff --git a/src/overlays/actors/ovl_Bg_Gjyo_Bridge/z_bg_gjyo_bridge.c b/src/overlays/actors/ovl_Bg_Gjyo_Bridge/z_bg_gjyo_bridge.cpp similarity index 59% rename from src/overlays/actors/ovl_Bg_Gjyo_Bridge/z_bg_gjyo_bridge.c rename to src/overlays/actors/ovl_Bg_Gjyo_Bridge/z_bg_gjyo_bridge.cpp index 5857a6722..0b197ce1e 100644 --- a/src/overlays/actors/ovl_Bg_Gjyo_Bridge/z_bg_gjyo_bridge.c +++ b/src/overlays/actors/ovl_Bg_Gjyo_Bridge/z_bg_gjyo_bridge.cpp @@ -19,16 +19,16 @@ #define FLAGS 0 -void BgGjyoBridge_Init(Actor* thisx, GlobalContext* globalCtx); -void BgGjyoBridge_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgGjyoBridge_Update(Actor* thisx, GlobalContext* globalCtx); -void BgGjyoBridge_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgGjyoBridge_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgGjyoBridge_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgGjyoBridge_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgGjyoBridge_Draw(Actor* pthisx, GlobalContext* globalCtx); -void func_808787A4(BgGjyoBridge* this, GlobalContext* globalCtx); -void BgGjyoBridge_TriggerCutscene(BgGjyoBridge* this, GlobalContext* globalCtx); -void BgGjyoBridge_SpawnBridge(BgGjyoBridge* this, GlobalContext* globalCtx); +void func_808787A4(BgGjyoBridge* pthis, GlobalContext* globalCtx); +void BgGjyoBridge_TriggerCutscene(BgGjyoBridge* pthis, GlobalContext* globalCtx); +void BgGjyoBridge_SpawnBridge(BgGjyoBridge* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Gjyo_Bridge_InitVars = { +ActorInit Bg_Gjyo_Bridge_InitVars = { ACTOR_BG_GJYO_BRIDGE, ACTORCAT_PROP, FLAGS, @@ -45,38 +45,38 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgGjyoBridge_Init(Actor* thisx, GlobalContext* globalCtx) { - BgGjyoBridge* this = (BgGjyoBridge*)thisx; +void BgGjyoBridge_Init(Actor* pthisx, GlobalContext* globalCtx) { + BgGjyoBridge* pthis = (BgGjyoBridge*)pthisx; s32 pad; CollisionHeader* colHeader; colHeader = NULL; - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(pthisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gRainbowBridgeCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, pthisx, colHeader); if (gSaveContext.eventChkInf[4] & 0x2000) { - this->actionFunc = func_808787A4; + pthis->actionFunc = func_808787A4; } else { - this->dyna.actor.draw = NULL; - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgGjyoBridge_TriggerCutscene; + pthis->dyna.actor.draw = NULL; + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->actionFunc = BgGjyoBridge_TriggerCutscene; } } -void BgGjyoBridge_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgGjyoBridge* this = (BgGjyoBridge*)thisx; +void BgGjyoBridge_Destroy(Actor* pthisx, GlobalContext* globalCtx) { + BgGjyoBridge* pthis = (BgGjyoBridge*)pthisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808787A4(BgGjyoBridge* this, GlobalContext* globalCtx) { +void func_808787A4(BgGjyoBridge* pthis, GlobalContext* globalCtx) { } -void BgGjyoBridge_TriggerCutscene(BgGjyoBridge* this, GlobalContext* globalCtx) { +void BgGjyoBridge_TriggerCutscene(BgGjyoBridge* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT) && CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW) && @@ -86,27 +86,27 @@ void BgGjyoBridge_TriggerCutscene(BgGjyoBridge* this, GlobalContext* globalCtx) !Gameplay_InCsMode(globalCtx)) { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gRainbowBridgeCs); gSaveContext.cutsceneTrigger = 1; - this->actionFunc = BgGjyoBridge_SpawnBridge; + pthis->actionFunc = BgGjyoBridge_SpawnBridge; } } -void BgGjyoBridge_SpawnBridge(BgGjyoBridge* this, GlobalContext* globalCtx) { +void BgGjyoBridge_SpawnBridge(BgGjyoBridge* pthis, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[2] != NULL) && (globalCtx->csCtx.npcActions[2]->action == 2)) { - this->dyna.actor.draw = BgGjyoBridge_Draw; - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + pthis->dyna.actor.draw = BgGjyoBridge_Draw; + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); gSaveContext.eventChkInf[4] |= 0x2000; } } -void BgGjyoBridge_Update(Actor* thisx, GlobalContext* globalCtx) { - BgGjyoBridge* this = (BgGjyoBridge*)thisx; +void BgGjyoBridge_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgGjyoBridge* pthis = (BgGjyoBridge*)pthisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } -void BgGjyoBridge_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgGjyoBridge* this = (BgGjyoBridge*)thisx; +void BgGjyoBridge_Draw(Actor* pthisx, GlobalContext* globalCtx) { + BgGjyoBridge* pthis = (BgGjyoBridge*)pthisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gjyo_bridge.c", 260); diff --git a/src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c b/src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c deleted file mode 100644 index 2676569fe..000000000 --- a/src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c +++ /dev/null @@ -1,221 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_GND_DARKMEIRO_Z_BG_GND_DARKMEIRO_C -#include "actor_common.h" -/* - * File: z_bg_gnd_darkmeiro.c - * Overlay: ovl_Bg_Gnd_Darkmeiro - * Description: Shadow trial actors (invisible path, clear block, and timer) - */ - -#include "z_bg_gnd_darkmeiro.h" -#include "objects/object_demo_kekkai/object_demo_kekkai.h" -#include "def/code_800F7260.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgGndDarkmeiro_Init(Actor* thisx, GlobalContext* globalCtx); -void BgGndDarkmeiro_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgGndDarkmeiro_Update(Actor* thisx, GlobalContext* globalCtx); -void BgGndDarkmeiro_DrawInvisiblePath(Actor* thisx, GlobalContext* globalCtx); -void BgGndDarkmeiro_DrawSwitchBlock(Actor* thisx, GlobalContext* globalCtx); -void BgGndDarkmeiro_DrawStaticBlock(Actor* thisx, GlobalContext* globalCtx); - -void BgGndDarkmeiro_Noop(BgGndDarkmeiro* this, GlobalContext* globalCtx); -void BgGndDarkmeiro_UpdateBlockTimer(BgGndDarkmeiro* this, GlobalContext* globalCtx); -void BgGndDarkmeiro_UpdateStaticBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx); -void BgGndDarkmeiro_UpdateSwitchBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx); - -const ActorInit Bg_Gnd_Darkmeiro_InitVars = { - ACTOR_BG_GND_DARKMEIRO, - ACTORCAT_PROP, - FLAGS, - OBJECT_DEMO_KEKKAI, - sizeof(BgGndDarkmeiro), - (ActorFunc)BgGndDarkmeiro_Init, - (ActorFunc)BgGndDarkmeiro_Destroy, - (ActorFunc)BgGndDarkmeiro_Update, - NULL, -}; - -void BgGndDarkmeiro_ToggleBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx) { - if (this->actionFlags & 2) { - if (this->timer1 == 0) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->actionFlags &= ~2; - } - } else if (this->timer1 != 0) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->actionFlags |= 2; - } -} - -void BgGndDarkmeiro_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - CollisionHeader* colHeader = NULL; - BgGndDarkmeiro* this = (BgGndDarkmeiro*)thisx; - - this->updateFunc = BgGndDarkmeiro_Noop; - Actor_SetScale(&this->dyna.actor, 0.1f); - switch (this->dyna.actor.params & 0xFF) { - case DARKMEIRO_INVISIBLE_PATH: - this->dyna.actor.draw = BgGndDarkmeiro_DrawInvisiblePath; - this->dyna.actor.flags |= ACTOR_FLAG_7; - break; - case DARKMEIRO_CLEAR_BLOCK: - CollisionHeader_GetVirtual(&gClearBlockCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (((this->dyna.actor.params >> 8) & 0x3F) == 0x3F) { - this->updateFunc = BgGndDarkmeiro_UpdateStaticBlock; - this->dyna.actor.draw = BgGndDarkmeiro_DrawStaticBlock; - } else { - this->actionFlags = this->timer1 = this->timer2 = 0; - thisx->draw = BgGndDarkmeiro_DrawSwitchBlock; - this->updateFunc = BgGndDarkmeiro_UpdateSwitchBlock; - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } else { - this->timer1 = 64; - this->actionFlags |= 2; - } - } - break; - case DARKMEIRO_BLOCK_TIMER: - this->actionFlags = this->timer1 = this->timer2 = 0; - this->updateFunc = BgGndDarkmeiro_UpdateBlockTimer; - thisx->draw = NULL; - if (Flags_GetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 1)) { - this->timer1 = 64; - this->actionFlags |= 4; - } - if (Flags_GetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 2)) { - this->timer2 = 64; - this->actionFlags |= 8; - } - if ((this->timer1 != 0) || (this->timer2 != 0)) { - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - } else { - Flags_UnsetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - } - break; - } -} - -void BgGndDarkmeiro_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BgGndDarkmeiro* this = (BgGndDarkmeiro*)thisx; - - if ((this->dyna.actor.params & 0xFF) == 1) { - if (1) {} - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } -} - -void BgGndDarkmeiro_Noop(BgGndDarkmeiro* this, GlobalContext* globalCtx) { -} - -void BgGndDarkmeiro_UpdateBlockTimer(BgGndDarkmeiro* this, GlobalContext* globalCtx) { - s16 timeLeft; - - if (Flags_GetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 1)) { - if (this->actionFlags & 4) { - if (this->timer1 > 0) { - this->timer1--; - } else { - Flags_UnsetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 1); - this->actionFlags &= ~4; - } - } else { - this->actionFlags |= 4; - this->timer1 = 304; - Audio_PlaySoundGeneral(NA_SE_EV_RED_EYE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - - if (Flags_GetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 2)) { - if (this->actionFlags & 8) { - if (this->timer2 > 0) { - this->timer2--; - } else { - Flags_UnsetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 2); - this->actionFlags &= ~8; - } - } else { - this->actionFlags |= 8; - this->timer2 = 304; - Audio_PlaySoundGeneral(NA_SE_EV_RED_EYE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - - timeLeft = CLAMP_MIN(this->timer1, this->timer2); - if (timeLeft > 0) { - func_8002F994(&this->dyna.actor, timeLeft); - } - if ((this->timer1 >= 64) || (this->timer2 >= 64)) { - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - } else { - Flags_UnsetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - } -} - -void BgGndDarkmeiro_UpdateStaticBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx) { -} - -void BgGndDarkmeiro_UpdateSwitchBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx) { - if (this->timer1 > 0) { - this->timer1--; - } - - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - this->timer1 = 64; - } - - BgGndDarkmeiro_ToggleBlock(this, globalCtx); -} - -void BgGndDarkmeiro_Update(Actor* thisx, GlobalContext* globalCtx2) { - BgGndDarkmeiro* this = (BgGndDarkmeiro*)thisx; - GlobalContext* globalCtx = globalCtx2; - - this->updateFunc(this, globalCtx2); -} - -void BgGndDarkmeiro_DrawInvisiblePath(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, gShadowTrialPathDL); -} - -void BgGndDarkmeiro_DrawSwitchBlock(Actor* thisx, GlobalContext* globalCtx) { - BgGndDarkmeiro* this = (BgGndDarkmeiro*)thisx; - s16 vanishTimer; - - vanishTimer = this->timer1; - if (vanishTimer != 0) { - if (vanishTimer > 64) { - this->timer2 = (this->timer2 < 120) ? this->timer2 + 8 : 127; - } else if (vanishTimer > 16) { - this->timer2 = (Math_CosS((u16)this->timer1 * 0x1000) * 64.0f) + 127.0f; - if (this->timer2 > 127) { - this->timer2 = 127; - } - } else { - this->timer2 = vanishTimer * 8; - } - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 378); - //! @bug Due to a bug in the display list, the transparency data is not used. - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 198, 202, 208, this->timer2); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 380); - - Gfx_DrawDListXlu(globalCtx, gClearBlockDL); - } -} - -void BgGndDarkmeiro_DrawStaticBlock(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 391); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 198, 202, 208, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 393); - - Gfx_DrawDListXlu(globalCtx, gClearBlockDL); -} diff --git a/src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.cpp b/src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.cpp new file mode 100644 index 000000000..69c1afc4a --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.cpp @@ -0,0 +1,221 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_GND_DARKMEIRO_Z_BG_GND_DARKMEIRO_C +#include "actor_common.h" +/* + * File: z_bg_gnd_darkmeiro.c + * Overlay: ovl_Bg_Gnd_Darkmeiro + * Description: Shadow trial actors (invisible path, clear block, and timer) + */ + +#include "z_bg_gnd_darkmeiro.h" +#include "objects/object_demo_kekkai/object_demo_kekkai.h" +#include "def/code_800F7260.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgGndDarkmeiro_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgGndDarkmeiro_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgGndDarkmeiro_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgGndDarkmeiro_DrawInvisiblePath(Actor* pthisx, GlobalContext* globalCtx); +void BgGndDarkmeiro_DrawSwitchBlock(Actor* pthisx, GlobalContext* globalCtx); +void BgGndDarkmeiro_DrawStaticBlock(Actor* pthisx, GlobalContext* globalCtx); + +void BgGndDarkmeiro_Noop(BgGndDarkmeiro* pthis, GlobalContext* globalCtx); +void BgGndDarkmeiro_UpdateBlockTimer(BgGndDarkmeiro* pthis, GlobalContext* globalCtx); +void BgGndDarkmeiro_UpdateStaticBlock(BgGndDarkmeiro* pthis, GlobalContext* globalCtx); +void BgGndDarkmeiro_UpdateSwitchBlock(BgGndDarkmeiro* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Gnd_Darkmeiro_InitVars = { + ACTOR_BG_GND_DARKMEIRO, + ACTORCAT_PROP, + FLAGS, + OBJECT_DEMO_KEKKAI, + sizeof(BgGndDarkmeiro), + (ActorFunc)BgGndDarkmeiro_Init, + (ActorFunc)BgGndDarkmeiro_Destroy, + (ActorFunc)BgGndDarkmeiro_Update, + NULL, +}; + +void BgGndDarkmeiro_ToggleBlock(BgGndDarkmeiro* pthis, GlobalContext* globalCtx) { + if (pthis->actionFlags & 2) { + if (pthis->timer1 == 0) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->actionFlags &= ~2; + } + } else if (pthis->timer1 != 0) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->actionFlags |= 2; + } +} + +void BgGndDarkmeiro_Init(Actor* pthisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + CollisionHeader* colHeader = NULL; + BgGndDarkmeiro* pthis = (BgGndDarkmeiro*)pthisx; + + pthis->updateFunc = BgGndDarkmeiro_Noop; + Actor_SetScale(&pthis->dyna.actor, 0.1f); + switch (pthis->dyna.actor.params & 0xFF) { + case DARKMEIRO_INVISIBLE_PATH: + pthis->dyna.actor.draw = BgGndDarkmeiro_DrawInvisiblePath; + pthis->dyna.actor.flags |= ACTOR_FLAG_7; + break; + case DARKMEIRO_CLEAR_BLOCK: + CollisionHeader_GetVirtual(&gClearBlockCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (((pthis->dyna.actor.params >> 8) & 0x3F) == 0x3F) { + pthis->updateFunc = BgGndDarkmeiro_UpdateStaticBlock; + pthis->dyna.actor.draw = BgGndDarkmeiro_DrawStaticBlock; + } else { + pthis->actionFlags = pthis->timer1 = pthis->timer2 = 0; + pthisx->draw = BgGndDarkmeiro_DrawSwitchBlock; + pthis->updateFunc = BgGndDarkmeiro_UpdateSwitchBlock; + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } else { + pthis->timer1 = 64; + pthis->actionFlags |= 2; + } + } + break; + case DARKMEIRO_BLOCK_TIMER: + pthis->actionFlags = pthis->timer1 = pthis->timer2 = 0; + pthis->updateFunc = BgGndDarkmeiro_UpdateBlockTimer; + pthisx->draw = NULL; + if (Flags_GetSwitch(globalCtx, ((pthis->dyna.actor.params >> 8) & 0x3F) + 1)) { + pthis->timer1 = 64; + pthis->actionFlags |= 4; + } + if (Flags_GetSwitch(globalCtx, ((pthis->dyna.actor.params >> 8) & 0x3F) + 2)) { + pthis->timer2 = 64; + pthis->actionFlags |= 8; + } + if ((pthis->timer1 != 0) || (pthis->timer2 != 0)) { + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + } else { + Flags_UnsetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + } + break; + } +} + +void BgGndDarkmeiro_Destroy(Actor* pthisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgGndDarkmeiro* pthis = (BgGndDarkmeiro*)pthisx; + + if ((pthis->dyna.actor.params & 0xFF) == 1) { + if (1) {} + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } +} + +void BgGndDarkmeiro_Noop(BgGndDarkmeiro* pthis, GlobalContext* globalCtx) { +} + +void BgGndDarkmeiro_UpdateBlockTimer(BgGndDarkmeiro* pthis, GlobalContext* globalCtx) { + s16 timeLeft; + + if (Flags_GetSwitch(globalCtx, ((pthis->dyna.actor.params >> 8) & 0x3F) + 1)) { + if (pthis->actionFlags & 4) { + if (pthis->timer1 > 0) { + pthis->timer1--; + } else { + Flags_UnsetSwitch(globalCtx, ((pthis->dyna.actor.params >> 8) & 0x3F) + 1); + pthis->actionFlags &= ~4; + } + } else { + pthis->actionFlags |= 4; + pthis->timer1 = 304; + Audio_PlaySoundGeneral(NA_SE_EV_RED_EYE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + if (Flags_GetSwitch(globalCtx, ((pthis->dyna.actor.params >> 8) & 0x3F) + 2)) { + if (pthis->actionFlags & 8) { + if (pthis->timer2 > 0) { + pthis->timer2--; + } else { + Flags_UnsetSwitch(globalCtx, ((pthis->dyna.actor.params >> 8) & 0x3F) + 2); + pthis->actionFlags &= ~8; + } + } else { + pthis->actionFlags |= 8; + pthis->timer2 = 304; + Audio_PlaySoundGeneral(NA_SE_EV_RED_EYE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + timeLeft = CLAMP_MIN(pthis->timer1, pthis->timer2); + if (timeLeft > 0) { + func_8002F994(&pthis->dyna.actor, timeLeft); + } + if ((pthis->timer1 >= 64) || (pthis->timer2 >= 64)) { + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + } else { + Flags_UnsetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + } +} + +void BgGndDarkmeiro_UpdateStaticBlock(BgGndDarkmeiro* pthis, GlobalContext* globalCtx) { +} + +void BgGndDarkmeiro_UpdateSwitchBlock(BgGndDarkmeiro* pthis, GlobalContext* globalCtx) { + if (pthis->timer1 > 0) { + pthis->timer1--; + } + + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + pthis->timer1 = 64; + } + + BgGndDarkmeiro_ToggleBlock(pthis, globalCtx); +} + +void BgGndDarkmeiro_Update(Actor* pthisx, GlobalContext* globalCtx2) { + BgGndDarkmeiro* pthis = (BgGndDarkmeiro*)pthisx; + GlobalContext* globalCtx = globalCtx2; + + pthis->updateFunc(pthis, globalCtx2); +} + +void BgGndDarkmeiro_DrawInvisiblePath(Actor* pthisx, GlobalContext* globalCtx) { + Gfx_DrawDListXlu(globalCtx, gShadowTrialPathDL); +} + +void BgGndDarkmeiro_DrawSwitchBlock(Actor* pthisx, GlobalContext* globalCtx) { + BgGndDarkmeiro* pthis = (BgGndDarkmeiro*)pthisx; + s16 vanishTimer; + + vanishTimer = pthis->timer1; + if (vanishTimer != 0) { + if (vanishTimer > 64) { + pthis->timer2 = (pthis->timer2 < 120) ? pthis->timer2 + 8 : 127; + } else if (vanishTimer > 16) { + pthis->timer2 = (Math_CosS((u16)pthis->timer1 * 0x1000) * 64.0f) + 127.0f; + if (pthis->timer2 > 127) { + pthis->timer2 = 127; + } + } else { + pthis->timer2 = vanishTimer * 8; + } + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 378); + //! @bug Due to a bug in the display list, the transparency data is not used. + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 198, 202, 208, pthis->timer2); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 380); + + Gfx_DrawDListXlu(globalCtx, gClearBlockDL); + } +} + +void BgGndDarkmeiro_DrawStaticBlock(Actor* pthisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 391); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 198, 202, 208, 255); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 393); + + Gfx_DrawDListXlu(globalCtx, gClearBlockDL); +} diff --git a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c deleted file mode 100644 index 260411421..000000000 --- a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c +++ /dev/null @@ -1,158 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_GND_FIREMEIRO_Z_BG_GND_FIREMEIRO_C -#include "actor_common.h" -/* - * File: z_bg_gnd_firemeiro.c - * Overlay: ovl_Bg_Gnd_Firemeiro - * Description: Sinking lava platform (Ganon's Castle) - */ - -#include "z_bg_gnd_firemeiro.h" -#include "objects/object_demo_kekkai/object_demo_kekkai.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgGndFiremeiro_Init(Actor* thisx, GlobalContext* globalCtx); -void BgGndFiremeiro_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgGndFiremeiro_Update(Actor* thisx, GlobalContext* globalCtx); -void BgGndFiremeiro_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgGndFiremeiro_Sink(BgGndFiremeiro* this, GlobalContext* globalCtx); -void BgGndFiremeiro_Shake(BgGndFiremeiro* this, GlobalContext* globalCtx); -void BgGndFiremeiro_Rise(BgGndFiremeiro* this, GlobalContext* globalCtx); - -const ActorInit Bg_Gnd_Firemeiro_InitVars = { - ACTOR_BG_GND_FIREMEIRO, - ACTORCAT_PROP, - FLAGS, - OBJECT_DEMO_KEKKAI, - sizeof(BgGndFiremeiro), - (ActorFunc)BgGndFiremeiro_Init, - (ActorFunc)BgGndFiremeiro_Destroy, - (ActorFunc)BgGndFiremeiro_Update, - (ActorFunc)BgGndFiremeiro_Draw, -}; - -void BgGndFiremeiro_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgGndFiremeiro* this = (BgGndFiremeiro*)thisx; - CollisionHeader* colHeader = NULL; - - ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); - Actor_SetScale(&this->dyna.actor, 0.1f); - this->initPos = this->dyna.actor.world.pos; - - if (this->dyna.actor.params == 0) { - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gFireTrialPlatformCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->actionFunc = BgGndFiremeiro_Rise; - } -} - -void BgGndFiremeiro_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BgGndFiremeiro* this = (BgGndFiremeiro*)thisx; - - if (this->dyna.actor.params == 0) { - if (1) {} - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } -} - -void BgGndFiremeiro_Sink(BgGndFiremeiro* this, GlobalContext* globalCtx) { - f32 sunkHeight = this->initPos.y - 150.0f; - - if (func_8004356C(&this->dyna)) { - this->timer = 10; - } - - if (sunkHeight < this->dyna.actor.world.pos.y) { - this->dyna.actor.world.pos.y -= 0.5f; - - if (this->dyna.actor.world.pos.y < sunkHeight) { - this->dyna.actor.world.pos.y = sunkHeight; - } - - func_8002F948(&this->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); - } - - if (this->timer > 0) { - this->timer--; - } else { - this->actionFunc = BgGndFiremeiro_Rise; - } -} - -void BgGndFiremeiro_Shake(BgGndFiremeiro* this, GlobalContext* globalCtx) { - s32 pad; - f32 randSign; - - if (func_8004356C(&this->dyna)) { // Player standing on it - if (this->timer > 0) { - this->timer--; - - randSign = ((this->timer & 1) ? 2.0f : -2.0f); - - this->dyna.actor.world.pos = this->initPos; - this->dyna.actor.world.pos.x += randSign * Math_SinS(this->timer * 0x2FFF); - this->dyna.actor.world.pos.z += randSign * Math_CosS(this->timer * 0x2FFF); - this->dyna.actor.world.pos.y += Math_CosS(this->timer * 0x7FFF); - - if (!(this->timer % 4)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE); - } - } else { - this->timer = 10; - this->dyna.actor.world.pos = this->initPos; - this->actionFunc = BgGndFiremeiro_Sink; - } - } else { - this->dyna.actor.world.pos = this->initPos; - this->actionFunc = BgGndFiremeiro_Rise; - } -} - -void BgGndFiremeiro_Rise(BgGndFiremeiro* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Actor* thisx = &this->dyna.actor; - - if ((player->currentBoots != PLAYER_BOOTS_HOVER) && func_8004356C(&this->dyna)) { // Player standing on it - if (thisx->world.pos.y < this->initPos.y) { - this->actionFunc = BgGndFiremeiro_Sink; - this->timer = 20; - } else { - this->actionFunc = BgGndFiremeiro_Shake; - this->timer = 20; - } - } else { - if (thisx->world.pos.y < this->initPos.y) { - thisx->world.pos.y += 2.0f; - if (this->initPos.y < thisx->world.pos.y) { - thisx->world.pos.y = this->initPos.y; - } - } - } -} - -void BgGndFiremeiro_Update(Actor* thisx, GlobalContext* globalCtx) { - BgGndFiremeiro* this = (BgGndFiremeiro*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgGndFiremeiro_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 280); - func_800943C8(globalCtx->state.gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 282), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gFireTrialPlatformDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 285); -} diff --git a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.cpp b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.cpp new file mode 100644 index 000000000..5a7e7386f --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.cpp @@ -0,0 +1,158 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_GND_FIREMEIRO_Z_BG_GND_FIREMEIRO_C +#include "actor_common.h" +/* + * File: z_bg_gnd_firemeiro.c + * Overlay: ovl_Bg_Gnd_Firemeiro + * Description: Sinking lava platform (Ganon's Castle) + */ + +#include "z_bg_gnd_firemeiro.h" +#include "objects/object_demo_kekkai/object_demo_kekkai.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgGndFiremeiro_Init(Actor* pthisx, GlobalContext* globalCtx); +void BgGndFiremeiro_Destroy(Actor* pthisx, GlobalContext* globalCtx); +void BgGndFiremeiro_Update(Actor* pthisx, GlobalContext* globalCtx); +void BgGndFiremeiro_Draw(Actor* pthisx, GlobalContext* globalCtx); + +void BgGndFiremeiro_Sink(BgGndFiremeiro* pthis, GlobalContext* globalCtx); +void BgGndFiremeiro_Shake(BgGndFiremeiro* pthis, GlobalContext* globalCtx); +void BgGndFiremeiro_Rise(BgGndFiremeiro* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Gnd_Firemeiro_InitVars = { + ACTOR_BG_GND_FIREMEIRO, + ACTORCAT_PROP, + FLAGS, + OBJECT_DEMO_KEKKAI, + sizeof(BgGndFiremeiro), + (ActorFunc)BgGndFiremeiro_Init, + (ActorFunc)BgGndFiremeiro_Destroy, + (ActorFunc)BgGndFiremeiro_Update, + (ActorFunc)BgGndFiremeiro_Draw, +}; + +void BgGndFiremeiro_Init(Actor* pthisx, GlobalContext* globalCtx) { + s32 pad; + BgGndFiremeiro* pthis = (BgGndFiremeiro*)pthisx; + CollisionHeader* colHeader = NULL; + + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&pthis->dyna.actor, 0.1f); + pthis->initPos = pthis->dyna.actor.world.pos; + + if (pthis->dyna.actor.params == 0) { + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gFireTrialPlatformCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->actionFunc = BgGndFiremeiro_Rise; + } +} + +void BgGndFiremeiro_Destroy(Actor* pthisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgGndFiremeiro* pthis = (BgGndFiremeiro*)pthisx; + + if (pthis->dyna.actor.params == 0) { + if (1) {} + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } +} + +void BgGndFiremeiro_Sink(BgGndFiremeiro* pthis, GlobalContext* globalCtx) { + f32 sunkHeight = pthis->initPos.y - 150.0f; + + if (func_8004356C(&pthis->dyna)) { + pthis->timer = 10; + } + + if (sunkHeight < pthis->dyna.actor.world.pos.y) { + pthis->dyna.actor.world.pos.y -= 0.5f; + + if (pthis->dyna.actor.world.pos.y < sunkHeight) { + pthis->dyna.actor.world.pos.y = sunkHeight; + } + + func_8002F948(&pthis->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); + } + + if (pthis->timer > 0) { + pthis->timer--; + } else { + pthis->actionFunc = BgGndFiremeiro_Rise; + } +} + +void BgGndFiremeiro_Shake(BgGndFiremeiro* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 randSign; + + if (func_8004356C(&pthis->dyna)) { // Player standing on it + if (pthis->timer > 0) { + pthis->timer--; + + randSign = ((pthis->timer & 1) ? 2.0f : -2.0f); + + pthis->dyna.actor.world.pos = pthis->initPos; + pthis->dyna.actor.world.pos.x += randSign * Math_SinS(pthis->timer * 0x2FFF); + pthis->dyna.actor.world.pos.z += randSign * Math_CosS(pthis->timer * 0x2FFF); + pthis->dyna.actor.world.pos.y += Math_CosS(pthis->timer * 0x7FFF); + + if (!(pthis->timer % 4)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_SHAKE); + } + } else { + pthis->timer = 10; + pthis->dyna.actor.world.pos = pthis->initPos; + pthis->actionFunc = BgGndFiremeiro_Sink; + } + } else { + pthis->dyna.actor.world.pos = pthis->initPos; + pthis->actionFunc = BgGndFiremeiro_Rise; + } +} + +void BgGndFiremeiro_Rise(BgGndFiremeiro* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* pthisx = &pthis->dyna.actor; + + if ((player->currentBoots != PLAYER_BOOTS_HOVER) && func_8004356C(&pthis->dyna)) { // Player standing on it + if (pthisx->world.pos.y < pthis->initPos.y) { + pthis->actionFunc = BgGndFiremeiro_Sink; + pthis->timer = 20; + } else { + pthis->actionFunc = BgGndFiremeiro_Shake; + pthis->timer = 20; + } + } else { + if (pthisx->world.pos.y < pthis->initPos.y) { + pthisx->world.pos.y += 2.0f; + if (pthis->initPos.y < pthisx->world.pos.y) { + pthisx->world.pos.y = pthis->initPos.y; + } + } + } +} + +void BgGndFiremeiro_Update(Actor* pthisx, GlobalContext* globalCtx) { + BgGndFiremeiro* pthis = (BgGndFiremeiro*)pthisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgGndFiremeiro_Draw(Actor* pthisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 280); + func_800943C8(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 282), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFireTrialPlatformDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 285); +} diff --git a/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c b/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.cpp similarity index 55% rename from src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c rename to src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.cpp index c667070d7..1473b4c03 100644 --- a/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c +++ b/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.cpp @@ -30,10 +30,10 @@ void BgGndIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgGndIceblock_Update(Actor* thisx, GlobalContext* globalCtx); void BgGndIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgGndIceblock_Idle(BgGndIceblock* this, GlobalContext* globalCtx); -void BgGndIceblock_Slide(BgGndIceblock* this, GlobalContext* globalCtx); +void BgGndIceblock_Idle(BgGndIceblock* pthis, GlobalContext* globalCtx); +void BgGndIceblock_Slide(BgGndIceblock* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Gnd_Iceblock_InitVars = { +ActorInit Bg_Gnd_Iceblock_InitVars = { ACTOR_BG_GND_ICEBLOCK, ACTORCAT_PROP, FLAGS, @@ -56,32 +56,32 @@ static u8 sBlockPositions[2]; void BgGndIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgGndIceblock* this = (BgGndIceblock*)thisx; + BgGndIceblock* pthis = (BgGndIceblock*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gWaterTrialIceBlockCol, &colHeader); - this->targetPos = this->dyna.actor.home.pos; - this->actionFunc = BgGndIceblock_Idle; - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.actor.world.pos.x == 2792.0f) { - this->dyna.actor.params = 0; + pthis->targetPos = pthis->dyna.actor.home.pos; + pthis->actionFunc = BgGndIceblock_Idle; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.actor.world.pos.x == 2792.0f) { + pthis->dyna.actor.params = 0; sBlockPositions[0] = 7; - } else if (this->dyna.actor.world.pos.x == 3032.0f) { - this->dyna.actor.params = 1; + } else if (pthis->dyna.actor.world.pos.x == 3032.0f) { + pthis->dyna.actor.params = 1; sBlockPositions[1] = 14; } else { - LOG_FLOAT("thisx->world.position.x", this->dyna.actor.world.pos.x, "../z_bg_gnd_iceblock.c", 138); + LOG_FLOAT("thisx->world.position.x", pthis->dyna.actor.world.pos.x, "../z_bg_gnd_iceblock.c", 138); ASSERT(0, "0", "../z_bg_gnd_iceblock.c", 139); } } void BgGndIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgGndIceblock* this = (BgGndIceblock*)thisx; + BgGndIceblock* pthis = (BgGndIceblock*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } /* @@ -101,8 +101,8 @@ void BgGndIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { * Block 0 starts at 7 and block 1 starts at 14 */ -void BgGndIceblock_SetPosition(BgGndIceblock* this, s32 blockPosition) { - Actor* thisx = &this->dyna.actor; +void BgGndIceblock_SetPosition(BgGndIceblock* pthis, s32 blockPosition) { + Actor* thisx = &pthis->dyna.actor; u8 xPosIdx[22] = { 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 6, 6, 6, 6, 6, 6, }; @@ -111,8 +111,8 @@ void BgGndIceblock_SetPosition(BgGndIceblock* this, s32 blockPosition) { }; sBlockPositions[thisx->params] = blockPosition; - this->targetPos.x = 2552.0f + (xPosIdx[blockPosition] * 120.0f); - this->targetPos.z = -540.0f - (zPosIdx[blockPosition] * 120.0f); + pthis->targetPos.x = 2552.0f + (xPosIdx[blockPosition] * 120.0f); + pthis->targetPos.z = -540.0f - (zPosIdx[blockPosition] * 120.0f); } s32 BgGndIceblock_CheckForBlock(s32 blockPosition) { @@ -126,8 +126,8 @@ s32 BgGndIceblock_CheckForBlock(s32 blockPosition) { return false; } -s32 BgGndIceblock_NextAction(BgGndIceblock* this) { - switch (sBlockPositions[this->dyna.actor.params]) { +s32 BgGndIceblock_NextAction(BgGndIceblock* pthis) { + switch (sBlockPositions[pthis->dyna.actor.params]) { case 0: case 1: case 5: @@ -143,132 +143,132 @@ s32 BgGndIceblock_NextAction(BgGndIceblock* this) { } } -void BgGndIceblock_SetNextPosition(BgGndIceblock* this) { - if (this->dyna.unk_158 == 0) { - switch (sBlockPositions[this->dyna.actor.params]) { +void BgGndIceblock_SetNextPosition(BgGndIceblock* pthis) { + if (pthis->dyna.unk_158 == 0) { + switch (sBlockPositions[pthis->dyna.actor.params]) { case 3: case 4: - BgGndIceblock_SetPosition(this, 5); + BgGndIceblock_SetPosition(pthis, 5); break; case 7: if (BgGndIceblock_CheckForBlock(8)) { - BgGndIceblock_SetPosition(this, 9); + BgGndIceblock_SetPosition(pthis, 9); } else { - BgGndIceblock_SetPosition(this, 8); + BgGndIceblock_SetPosition(pthis, 8); } break; case 11: - BgGndIceblock_SetPosition(this, 12); + BgGndIceblock_SetPosition(pthis, 12); break; case 14: - BgGndIceblock_SetPosition(this, 15); + BgGndIceblock_SetPosition(pthis, 15); break; case 18: case 19: - BgGndIceblock_SetPosition(this, 20); + BgGndIceblock_SetPosition(pthis, 20); break; } - } else if (this->dyna.unk_158 == -0x8000) { - switch (sBlockPositions[this->dyna.actor.params]) { + } else if (pthis->dyna.unk_158 == -0x8000) { + switch (sBlockPositions[pthis->dyna.actor.params]) { case 2: case 3: - BgGndIceblock_SetPosition(this, 1); + BgGndIceblock_SetPosition(pthis, 1); break; case 7: case 9: - BgGndIceblock_SetPosition(this, 6); + BgGndIceblock_SetPosition(pthis, 6); break; case 11: - BgGndIceblock_SetPosition(this, 10); + BgGndIceblock_SetPosition(pthis, 10); break; case 14: case 15: - BgGndIceblock_SetPosition(this, 13); + BgGndIceblock_SetPosition(pthis, 13); break; case 17: - BgGndIceblock_SetPosition(this, 16); + BgGndIceblock_SetPosition(pthis, 16); break; case 18: if (!BgGndIceblock_CheckForBlock(17)) { - BgGndIceblock_SetPosition(this, 16); + BgGndIceblock_SetPosition(pthis, 16); } break; } - } else if (this->dyna.unk_158 == 0x4000) { - switch (sBlockPositions[this->dyna.actor.params]) { + } else if (pthis->dyna.unk_158 == 0x4000) { + switch (sBlockPositions[pthis->dyna.actor.params]) { case 6: - BgGndIceblock_SetPosition(this, 13); + BgGndIceblock_SetPosition(pthis, 13); break; case 7: - BgGndIceblock_SetPosition(this, 17); + BgGndIceblock_SetPosition(pthis, 17); break; case 9: - BgGndIceblock_SetPosition(this, 11); + BgGndIceblock_SetPosition(pthis, 11); break; case 12: - BgGndIceblock_SetPosition(this, 21); + BgGndIceblock_SetPosition(pthis, 21); break; case 14: - BgGndIceblock_SetPosition(this, 18); + BgGndIceblock_SetPosition(pthis, 18); break; case 15: - BgGndIceblock_SetPosition(this, 19); + BgGndIceblock_SetPosition(pthis, 19); break; } - } else if (this->dyna.unk_158 == -0x4000) { - switch (sBlockPositions[this->dyna.actor.params]) { + } else if (pthis->dyna.unk_158 == -0x4000) { + switch (sBlockPositions[pthis->dyna.actor.params]) { case 6: - BgGndIceblock_SetPosition(this, 0); + BgGndIceblock_SetPosition(pthis, 0); break; case 7: - BgGndIceblock_SetPosition(this, 1); + BgGndIceblock_SetPosition(pthis, 1); break; case 9: case 11: - BgGndIceblock_SetPosition(this, 4); + BgGndIceblock_SetPosition(pthis, 4); break; case 14: - BgGndIceblock_SetPosition(this, 2); + BgGndIceblock_SetPosition(pthis, 2); break; case 15: if (BgGndIceblock_CheckForBlock(8)) { - BgGndIceblock_SetPosition(this, 3); + BgGndIceblock_SetPosition(pthis, 3); } else { - BgGndIceblock_SetPosition(this, 8); + BgGndIceblock_SetPosition(pthis, 8); } break; } } } -void BgGndIceblock_Idle(BgGndIceblock* this, GlobalContext* globalCtx) { +void BgGndIceblock_Idle(BgGndIceblock* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { player->stateFlags2 &= ~0x10; - if (this->dyna.unk_150 > 0.0f) { - BgGndIceblock_SetNextPosition(this); - if (Actor_WorldDistXZToPoint(&this->dyna.actor, &this->targetPos) > 1.0f) { - func_8002DF54(globalCtx, &this->dyna.actor, 8); - this->actionFunc = BgGndIceblock_Slide; + if (pthis->dyna.unk_150 > 0.0f) { + BgGndIceblock_SetNextPosition(pthis); + if (Actor_WorldDistXZToPoint(&pthis->dyna.actor, &pthis->targetPos) > 1.0f) { + func_8002DF54(globalCtx, &pthis->dyna.actor, 8); + pthis->actionFunc = BgGndIceblock_Slide; } } - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } } -void BgGndIceblock_Reset(BgGndIceblock* this, GlobalContext* globalCtx) { +void BgGndIceblock_Reset(BgGndIceblock* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y, 1.0f)) { - this->targetPos = thisx->home.pos; + pthis->targetPos = thisx->home.pos; thisx->speedXZ = 0.0f; - this->actionFunc = BgGndIceblock_Idle; + pthis->actionFunc = BgGndIceblock_Idle; switch (thisx->params) { case 0: sBlockPositions[0] = 7; @@ -280,8 +280,8 @@ void BgGndIceblock_Reset(BgGndIceblock* this, GlobalContext* globalCtx) { } } -void BgGndIceblock_Fall(BgGndIceblock* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void BgGndIceblock_Fall(BgGndIceblock* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; thisx->velocity.y += 1.0f; if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 300.0f, thisx->velocity.y)) { @@ -292,12 +292,12 @@ void BgGndIceblock_Fall(BgGndIceblock* this, GlobalContext* globalCtx) { if (Player_InCsMode(globalCtx)) { func_8002DF54(globalCtx, thisx, 7); } - this->actionFunc = BgGndIceblock_Reset; + pthis->actionFunc = BgGndIceblock_Reset; } } -void BgGndIceblock_Hole(BgGndIceblock* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void BgGndIceblock_Hole(BgGndIceblock* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; thisx->velocity.y += 1.0f; if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 100.0f, thisx->velocity.y)) { @@ -305,49 +305,49 @@ void BgGndIceblock_Hole(BgGndIceblock* this, GlobalContext* globalCtx) { if (Player_InCsMode(globalCtx)) { func_8002DF54(globalCtx, thisx, 7); } - this->actionFunc = BgGndIceblock_Idle; + pthis->actionFunc = BgGndIceblock_Idle; } } -void BgGndIceblock_Slide(BgGndIceblock* this, GlobalContext* globalCtx) { +void BgGndIceblock_Slide(BgGndIceblock* pthis, GlobalContext* globalCtx) { s32 atTarget; Vec3f pos; Vec3f velocity; f32 spread; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; Math_StepToF(&thisx->speedXZ, 10.0f, 0.5f); - atTarget = Math_StepToF(&thisx->world.pos.x, this->targetPos.x, thisx->speedXZ); - atTarget &= Math_StepToF(&thisx->world.pos.z, this->targetPos.z, thisx->speedXZ); + atTarget = Math_StepToF(&thisx->world.pos.x, pthis->targetPos.x, thisx->speedXZ); + atTarget &= Math_StepToF(&thisx->world.pos.z, pthis->targetPos.z, thisx->speedXZ); if (atTarget) { thisx->speedXZ = 0.0f; - this->targetPos.x = thisx->world.pos.x; - this->targetPos.z = thisx->world.pos.z; + pthis->targetPos.x = thisx->world.pos.x; + pthis->targetPos.z = thisx->world.pos.z; Audio_PlayActorSound2(thisx, NA_SE_EV_BLOCK_BOUND); - switch (BgGndIceblock_NextAction(this)) { + switch (BgGndIceblock_NextAction(pthis)) { case GNDICE_IDLE: - this->actionFunc = BgGndIceblock_Idle; + pthis->actionFunc = BgGndIceblock_Idle; func_8002DF54(globalCtx, thisx, 7); break; case GNDICE_FALL: - this->actionFunc = BgGndIceblock_Fall; + pthis->actionFunc = BgGndIceblock_Fall; break; case GNDICE_HOLE: - this->actionFunc = BgGndIceblock_Hole; + pthis->actionFunc = BgGndIceblock_Hole; break; } } else if (thisx->speedXZ > 6.0f) { spread = Rand_CenteredFloat(120.0f); - velocity.x = -(1.5f + Rand_ZeroOne()) * Math_SinS(this->dyna.unk_158); + velocity.x = -(1.5f + Rand_ZeroOne()) * Math_SinS(pthis->dyna.unk_158); velocity.y = Rand_ZeroOne() + 1.0f; - velocity.z = -(1.5f + Rand_ZeroOne()) * Math_CosS(this->dyna.unk_158); - pos.x = thisx->world.pos.x - (60.0f * Math_SinS(this->dyna.unk_158)) - (Math_CosS(this->dyna.unk_158) * spread); - pos.z = thisx->world.pos.z - (60.0f * Math_CosS(this->dyna.unk_158)) + (Math_SinS(this->dyna.unk_158) * spread); + velocity.z = -(1.5f + Rand_ZeroOne()) * Math_CosS(pthis->dyna.unk_158); + pos.x = thisx->world.pos.x - (60.0f * Math_SinS(pthis->dyna.unk_158)) - (Math_CosS(pthis->dyna.unk_158) * spread); + pos.z = thisx->world.pos.z - (60.0f * Math_CosS(pthis->dyna.unk_158)) + (Math_SinS(pthis->dyna.unk_158) * spread); pos.y = thisx->world.pos.y; func_8002829C(globalCtx, &pos, &velocity, &sZeroVec, &sWhite, &sGray, 250, Rand_S16Offset(40, 15)); spread = Rand_CenteredFloat(120.0f); - pos.x = thisx->world.pos.x - (60.0f * Math_SinS(this->dyna.unk_158)) + (Math_CosS(this->dyna.unk_158) * spread); - pos.z = thisx->world.pos.z - (60.0f * Math_CosS(this->dyna.unk_158)) - (Math_SinS(this->dyna.unk_158) * spread); + pos.x = thisx->world.pos.x - (60.0f * Math_SinS(pthis->dyna.unk_158)) + (Math_CosS(pthis->dyna.unk_158) * spread); + pos.z = thisx->world.pos.z - (60.0f * Math_CosS(pthis->dyna.unk_158)) - (Math_SinS(pthis->dyna.unk_158) * spread); func_8002829C(globalCtx, &pos, &velocity, &sZeroVec, &sWhite, &sGray, 250, Rand_S16Offset(40, 15)); func_8002F974(thisx, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } @@ -355,14 +355,14 @@ void BgGndIceblock_Slide(BgGndIceblock* this, GlobalContext* globalCtx) { void BgGndIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgGndIceblock* this = (BgGndIceblock*)thisx; + BgGndIceblock* pthis = (BgGndIceblock*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgGndIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgGndIceblock* this = (BgGndIceblock*)thisx; + BgGndIceblock* pthis = (BgGndIceblock*)thisx; Gfx_DrawDListOpa(globalCtx, gWaterTrialIceBlockDL); } diff --git a/src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.c b/src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.cpp similarity index 76% rename from src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.c rename to src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.cpp index ed3e47763..295bdc0dc 100644 --- a/src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.c +++ b/src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.cpp @@ -18,7 +18,7 @@ void BgGndNisekabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgGndNisekabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgGndNisekabe_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Gnd_Nisekabe_InitVars = { +ActorInit Bg_Gnd_Nisekabe_InitVars = { ACTOR_BG_GND_NISEKABE, ACTORCAT_PROP, FLAGS, @@ -31,22 +31,22 @@ const ActorInit Bg_Gnd_Nisekabe_InitVars = { }; void BgGndNisekabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgGndNisekabe* this = (BgGndNisekabe*)thisx; + BgGndNisekabe* pthis = (BgGndNisekabe*)thisx; - Actor_SetScale(&this->actor, 0.1); - this->actor.uncullZoneForward = 3000.0; + Actor_SetScale(&pthis->actor, 0.1); + pthis->actor.uncullZoneForward = 3000.0; } void BgGndNisekabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void BgGndNisekabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgGndNisekabe* this = (BgGndNisekabe*)thisx; + BgGndNisekabe* pthis = (BgGndNisekabe*)thisx; if (globalCtx->actorCtx.unk_03 != 0) { - this->actor.flags |= ACTOR_FLAG_7; + pthis->actor.flags |= ACTOR_FLAG_7; } else { - this->actor.flags &= ~ACTOR_FLAG_7; + pthis->actor.flags &= ~ACTOR_FLAG_7; } } @@ -56,10 +56,10 @@ void BgGndNisekabe_Draw(Actor* thisx, GlobalContext* globalCtx) { gGanonsCastleUnusedFakeWallDL, gGanonsCastleScrubsFakeWallDL, }; - BgGndNisekabe* this = (BgGndNisekabe*)thisx; - u32 index = this->actor.params & 0xFF; + BgGndNisekabe* pthis = (BgGndNisekabe*)thisx; + u32 index = pthis->actor.params & 0xFF; - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { Gfx_DrawDListXlu(globalCtx, dLists[index]); } else { Gfx_DrawDListOpa(globalCtx, dLists[index]); diff --git a/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c b/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.cpp similarity index 67% rename from src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c rename to src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.cpp index 8c4364bbd..3ea376346 100644 --- a/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c +++ b/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.cpp @@ -26,11 +26,11 @@ void BgGndSoulmeiro_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgGndSoulmeiro_Update(Actor* thisx, GlobalContext* globalCtx); void BgGndSoulmeiro_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8087AF38(BgGndSoulmeiro* this, GlobalContext* globalCtx); -void func_8087B284(BgGndSoulmeiro* this, GlobalContext* globalCtx); -void func_8087B350(BgGndSoulmeiro* this, GlobalContext* globalCtx); +void func_8087AF38(BgGndSoulmeiro* pthis, GlobalContext* globalCtx); +void func_8087B284(BgGndSoulmeiro* pthis, GlobalContext* globalCtx); +void func_8087B350(BgGndSoulmeiro* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Gnd_Soulmeiro_InitVars = { +ActorInit Bg_Gnd_Soulmeiro_InitVars = { ACTOR_BG_GND_SOULMEIRO, ACTORCAT_PROP, FLAGS, @@ -71,69 +71,69 @@ static InitChainEntry sInitChain[] = { void BgGndSoulmeiro_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgGndSoulmeiro* this = (BgGndSoulmeiro*)thisx; + BgGndSoulmeiro* pthis = (BgGndSoulmeiro*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actionFunc = NULL; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actionFunc = NULL; - switch (this->actor.params & 0xFF) { + switch (pthis->actor.params & 0xFF) { case 0: - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actionFunc = func_8087B284; - if (Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actionFunc = func_8087B284; + if (Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 9); - this->actor.draw = NULL; - Actor_Kill(&this->actor); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 9); + pthis->actor.draw = NULL; + Actor_Kill(&pthis->actor); return; } else { - this->actor.draw = BgGndSoulmeiro_Draw; + pthis->actor.draw = BgGndSoulmeiro_Draw; } break; case 1: case 2: - if (Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { - this->actor.draw = BgGndSoulmeiro_Draw; + if (Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { + pthis->actor.draw = BgGndSoulmeiro_Draw; } else { - this->actor.draw = NULL; + pthis->actor.draw = NULL; } - this->actionFunc = func_8087B350; + pthis->actionFunc = func_8087B350; break; } } void BgGndSoulmeiro_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgGndSoulmeiro* this = (BgGndSoulmeiro*)thisx; + BgGndSoulmeiro* pthis = (BgGndSoulmeiro*)thisx; - if ((this->actor.params & 0xFF) == 0) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if ((pthis->actor.params & 0xFF) == 0) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } -void func_8087AF38(BgGndSoulmeiro* this, GlobalContext* globalCtx) { +void func_8087AF38(BgGndSoulmeiro* pthis, GlobalContext* globalCtx) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f vecA; Vec3f vecB; - Actor* thisx = &this->actor; + Actor* thisx = &pthis->actor; - if (this->unk_198 != 0) { - this->unk_198--; + if (pthis->unk_198 != 0) { + pthis->unk_198--; } - if (this->unk_198 == 20) { + if (pthis->unk_198 == 20) { Flags_SetSwitch(globalCtx, (thisx->params >> 8) & 0x3F); thisx->draw = NULL; } - // This should be this->unk_198 == 0, this is required to match - if (!this->unk_198) { + // This should be pthis->unk_198 == 0, pthis is required to match + if (!pthis->unk_198) { Flags_SetSwitch(globalCtx, (thisx->params >> 8) & 0x3F); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, 9); - } else if ((this->unk_198 % 6) == 0) { + } else if ((pthis->unk_198 % 6) == 0) { s32 i; s16 temp_2 = Rand_ZeroOne() * (10922.0f); // This should be: 0x10000 / 6.0f @@ -167,35 +167,35 @@ void func_8087AF38(BgGndSoulmeiro* this, GlobalContext* globalCtx) { } } -void func_8087B284(BgGndSoulmeiro* this, GlobalContext* globalCtx) { +void func_8087B284(BgGndSoulmeiro* pthis, GlobalContext* globalCtx) { s32 pad; - if (!Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { - this->actor.draw = BgGndSoulmeiro_Draw; - if (this->collider.base.acFlags & AC_HIT) { + if (!Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { + pthis->actor.draw = BgGndSoulmeiro_Draw; + if (pthis->collider.base.acFlags & AC_HIT) { Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_198 = 40; - this->actionFunc = func_8087AF38; + pthis->unk_198 = 40; + pthis->actionFunc = func_8087AF38; } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } } -void func_8087B350(BgGndSoulmeiro* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { - this->actor.draw = BgGndSoulmeiro_Draw; +void func_8087B350(BgGndSoulmeiro* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { + pthis->actor.draw = BgGndSoulmeiro_Draw; } else { - this->actor.draw = NULL; + pthis->actor.draw = NULL; } } void BgGndSoulmeiro_Update(Actor* thisx, GlobalContext* globalCtx) { - BgGndSoulmeiro* this = (BgGndSoulmeiro*)thisx; + BgGndSoulmeiro* pthis = (BgGndSoulmeiro*)thisx; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c b/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.cpp similarity index 54% rename from src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c rename to src/overlays/actors/ovl_Bg_Haka/z_bg_haka.cpp index 55b9ac13a..a0f4ad5d3 100644 --- a/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c +++ b/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.cpp @@ -25,13 +25,13 @@ void BgHaka_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHaka_Update(Actor* thisx, GlobalContext* globalCtx); void BgHaka_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8087B758(BgHaka* this, Player* player); -void func_8087B7E8(BgHaka* this, GlobalContext* globalCtx); -void func_8087B938(BgHaka* this, GlobalContext* globalCtx); -void func_8087BAAC(BgHaka* this, GlobalContext* globalCtx); -void func_8087BAE4(BgHaka* this, GlobalContext* globalCtx); +void func_8087B758(BgHaka* pthis, Player* player); +void func_8087B7E8(BgHaka* pthis, GlobalContext* globalCtx); +void func_8087B938(BgHaka* pthis, GlobalContext* globalCtx); +void func_8087BAAC(BgHaka* pthis, GlobalContext* globalCtx); +void func_8087BAE4(BgHaka* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Haka_InitVars = { +ActorInit Bg_Haka_InitVars = { ACTOR_BG_HAKA, ACTORCAT_BG, FLAGS, @@ -49,112 +49,112 @@ static InitChainEntry sInitChain[] = { }; void BgHaka_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHaka* this = (BgHaka*)thisx; + BgHaka* pthis = (BgHaka*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gGravestoneCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->actionFunc = func_8087B7E8; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->actionFunc = func_8087B7E8; } void BgHaka_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHaka* this = (BgHaka*)thisx; + BgHaka* pthis = (BgHaka*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_8087B758(BgHaka* this, Player* player) { +void func_8087B758(BgHaka* pthis, Player* player) { Vec3f sp1C; - func_8002DBD0(&this->dyna.actor, &sp1C, &player->actor.world.pos); + func_8002DBD0(&pthis->dyna.actor, &sp1C, &player->actor.world.pos); if (fabsf(sp1C.x) < 34.6f && sp1C.z > -112.8f && sp1C.z < -36.0f) { player->stateFlags2 |= 0x200; } } -void func_8087B7E8(BgHaka* this, GlobalContext* globalCtx) { +void func_8087B7E8(BgHaka* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { if (globalCtx->sceneNum == SCENE_SPOT02 && !LINK_IS_ADULT && !gSaveContext.nightFlag) { - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; if (!Gameplay_InCsMode(globalCtx)) { Message_StartTextbox(globalCtx, 0x5073, NULL); - this->dyna.actor.params = 100; - this->actionFunc = func_8087BAE4; + pthis->dyna.actor.params = 100; + pthis->actionFunc = func_8087BAE4; } - } else if (0.0f < this->dyna.unk_150 || + } else if (0.0f < pthis->dyna.unk_150 || (globalCtx->sceneNum == SCENE_SPOT06 && !LINK_IS_ADULT && !Flags_GetSwitch(globalCtx, 0x23))) { - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; } else { - this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x8000; - this->actionFunc = func_8087B938; + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.shape.rot.y + 0x8000; + pthis->actionFunc = func_8087B938; } } - func_8087B758(this, player); + func_8087B758(pthis, player); } -void func_8087B938(BgHaka* this, GlobalContext* globalCtx) { +void func_8087B938(BgHaka* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp38; - this->dyna.actor.speedXZ += 0.05f; - this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 1.5f); - sp38 = Math_StepToF(&this->dyna.actor.minVelocityY, 60.0f, this->dyna.actor.speedXZ); - this->dyna.actor.world.pos.x = - Math_SinS(this->dyna.actor.world.rot.y) * this->dyna.actor.minVelocityY + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = - Math_CosS(this->dyna.actor.world.rot.y) * this->dyna.actor.minVelocityY + this->dyna.actor.home.pos.z; + pthis->dyna.actor.speedXZ += 0.05f; + pthis->dyna.actor.speedXZ = CLAMP_MAX(pthis->dyna.actor.speedXZ, 1.5f); + sp38 = Math_StepToF(&pthis->dyna.actor.minVelocityY, 60.0f, pthis->dyna.actor.speedXZ); + pthis->dyna.actor.world.pos.x = + Math_SinS(pthis->dyna.actor.world.rot.y) * pthis->dyna.actor.minVelocityY + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = + Math_CosS(pthis->dyna.actor.world.rot.y) * pthis->dyna.actor.minVelocityY + pthis->dyna.actor.home.pos.z; if (sp38 != 0) { - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; - if (this->dyna.actor.params == 1) { + if (pthis->dyna.actor.params == 1) { func_80078884(NA_SE_SY_CORRECT_CHIME); } else if (!IS_DAY && globalCtx->sceneNum == SCENE_SPOT02) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, this->dyna.actor.home.pos.x, - this->dyna.actor.home.pos.y, this->dyna.actor.home.pos.z, 0, this->dyna.actor.shape.rot.y, 0, + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, pthis->dyna.actor.home.pos.x, + pthis->dyna.actor.home.pos.y, pthis->dyna.actor.home.pos.z, 0, pthis->dyna.actor.shape.rot.y, 0, 1); } - this->actionFunc = func_8087BAAC; + pthis->actionFunc = func_8087BAAC; } - func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } -void func_8087BAAC(BgHaka* this, GlobalContext* globalCtx) { +void func_8087BAAC(BgHaka* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 != 0.0f) { - this->dyna.unk_150 = 0.0f; + if (pthis->dyna.unk_150 != 0.0f) { + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; } } -void func_8087BAE4(BgHaka* this, GlobalContext* globalCtx) { +void func_8087BAE4(BgHaka* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; - if (this->dyna.actor.params != 0) { - this->dyna.actor.params -= 1; + if (pthis->dyna.actor.params != 0) { + pthis->dyna.actor.params -= 1; } - if (this->dyna.unk_150 != 0.0f) { - this->dyna.unk_150 = 0.0f; + if (pthis->dyna.unk_150 != 0.0f) { + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; } - if (this->dyna.actor.params == 0) { - this->actionFunc = func_8087B7E8; + if (pthis->dyna.actor.params == 0) { + pthis->actionFunc = func_8087B7E8; } - func_8087B758(this, player); + func_8087B758(pthis, player); } void BgHaka_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHaka* this = (BgHaka*)thisx; + BgHaka* pthis = (BgHaka*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgHaka_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c b/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.cpp similarity index 51% rename from src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c rename to src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.cpp index 061209a08..dbd9a75d1 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c +++ b/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.cpp @@ -45,18 +45,18 @@ void BgHakaGate_Init(Actor* thisx, GlobalContext* globalCtx); void BgHakaGate_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaGate_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaGate_Draw(Actor* this, GlobalContext* globalCtx); +void BgHakaGate_Draw(Actor* pthis, GlobalContext* globalCtx); -void BgHakaGate_DoNothing(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_StatueInactive(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_StatueIdle(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_StatueTurn(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_FloorClosed(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_FloorOpen(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_GateWait(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_GateOpen(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_SkullOfTruth(BgHakaGate* this, GlobalContext* globalCtx); -void BgHakaGate_FalseSkull(BgHakaGate* this, GlobalContext* globalCtx); +void BgHakaGate_DoNothing(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_StatueInactive(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_StatueIdle(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_StatueTurn(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_FloorClosed(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_FloorOpen(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_GateWait(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_GateOpen(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_SkullOfTruth(BgHakaGate* pthis, GlobalContext* globalCtx); +void BgHakaGate_FalseSkull(BgHakaGate* pthis, GlobalContext* globalCtx); static s16 sSkullOfTruthRotY = 0x100; static u8 sPuzzleState = 1; @@ -64,7 +64,7 @@ static f32 sStatueDistToPlayer = 0; static s16 sStatueRotY; -const ActorInit Bg_Haka_Gate_InitVars = { +ActorInit Bg_Haka_Gate_InitVars = { ACTOR_BG_HAKA_GATE, ACTORCAT_PROP, FLAGS, @@ -82,163 +82,163 @@ static InitChainEntry sInitChain[] = { void BgHakaGate_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgHakaGate* this = (BgHakaGate*)thisx; + BgHakaGate* pthis = (BgHakaGate*)thisx; CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(thisx, sInitChain); - this->switchFlag = (thisx->params >> 8) & 0xFF; + pthis->switchFlag = (thisx->params >> 8) & 0xFF; thisx->params &= 0xFF; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); if (thisx->params == BGHAKAGATE_SKULL) { if (sSkullOfTruthRotY != 0x100) { - this->actionFunc = BgHakaGate_FalseSkull; + pthis->actionFunc = BgHakaGate_FalseSkull; } else if (ABS(thisx->shape.rot.y) < 0x4000) { if ((Rand_ZeroOne() * 3.0f) < sPuzzleState) { - this->vIsSkullOfTruth = true; + pthis->vIsSkullOfTruth = true; sSkullOfTruthRotY = thisx->shape.rot.y + 0x8000; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actionFunc = BgHakaGate_DoNothing; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actionFunc = BgHakaGate_DoNothing; } else { - this->actionFunc = BgHakaGate_SkullOfTruth; + pthis->actionFunc = BgHakaGate_SkullOfTruth; } } else { sPuzzleState++; - this->actionFunc = BgHakaGate_FalseSkull; + pthis->actionFunc = BgHakaGate_FalseSkull; } } else { - this->actionFunc = BgHakaGate_FalseSkull; + pthis->actionFunc = BgHakaGate_FalseSkull; } - this->vScrollTimer = Rand_ZeroOne() * 20.0f; + pthis->vScrollTimer = Rand_ZeroOne() * 20.0f; thisx->flags |= ACTOR_FLAG_4; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->vFlameScale = 350; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->vFlameScale = 350; } } else { if (thisx->params == BGHAKAGATE_STATUE) { CollisionHeader_GetVirtual(&object_haka_objects_Col_0131C4, &colHeader); - this->vTimer = 0; + pthis->vTimer = 0; sStatueDistToPlayer = 0.0f; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actionFunc = BgHakaGate_StatueInactive; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actionFunc = BgHakaGate_StatueInactive; } else { - this->actionFunc = BgHakaGate_StatueIdle; + pthis->actionFunc = BgHakaGate_StatueIdle; } } else if (thisx->params == BGHAKAGATE_FLOOR) { CollisionHeader_GetVirtual(&object_haka_objects_Col_010E10, &colHeader); - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actionFunc = BgHakaGate_DoNothing; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actionFunc = BgHakaGate_DoNothing; } else { - this->actionFunc = BgHakaGate_FloorClosed; + pthis->actionFunc = BgHakaGate_FloorClosed; } } else { // BGHAKAGATE_GATE CollisionHeader_GetVirtual(&object_haka_objects_Col_00A938, &colHeader); - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actionFunc = BgHakaGate_DoNothing; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actionFunc = BgHakaGate_DoNothing; thisx->world.pos.y += 80.0f; } else { thisx->flags |= ACTOR_FLAG_4; Actor_SetFocus(thisx, 30.0f); - this->actionFunc = BgHakaGate_GateWait; + pthis->actionFunc = BgHakaGate_GateWait; } } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); } } void BgHakaGate_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgHakaGate* this = (BgHakaGate*)thisx; + BgHakaGate* pthis = (BgHakaGate*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if (this->dyna.actor.params == BGHAKAGATE_STATUE) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if (pthis->dyna.actor.params == BGHAKAGATE_STATUE) { sSkullOfTruthRotY = 0x100; sPuzzleState = 1; } } -void BgHakaGate_DoNothing(BgHakaGate* this, GlobalContext* globalCtx) { +void BgHakaGate_DoNothing(BgHakaGate* pthis, GlobalContext* globalCtx) { } -void BgHakaGate_StatueInactive(BgHakaGate* this, GlobalContext* globalCtx) { +void BgHakaGate_StatueInactive(BgHakaGate* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } } -void BgHakaGate_StatueIdle(BgHakaGate* this, GlobalContext* globalCtx) { +void BgHakaGate_StatueIdle(BgHakaGate* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 linkDirection; f32 forceDirection; - if (this->dyna.unk_150 != 0.0f) { - if (this->vTimer == 0) { - this->vInitTurnAngle = this->dyna.actor.shape.rot.y - this->dyna.actor.yawTowardsPlayer; - sStatueDistToPlayer = this->dyna.actor.xzDistToPlayer; - forceDirection = (this->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; - linkDirection = ((s16)(this->dyna.actor.yawTowardsPlayer - player->actor.shape.rot.y) > 0) ? -1 : 1; - this->vTurnDirection = linkDirection * forceDirection; - this->actionFunc = BgHakaGate_StatueTurn; + if (pthis->dyna.unk_150 != 0.0f) { + if (pthis->vTimer == 0) { + pthis->vInitTurnAngle = pthis->dyna.actor.shape.rot.y - pthis->dyna.actor.yawTowardsPlayer; + sStatueDistToPlayer = pthis->dyna.actor.xzDistToPlayer; + forceDirection = (pthis->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; + linkDirection = ((s16)(pthis->dyna.actor.yawTowardsPlayer - player->actor.shape.rot.y) > 0) ? -1 : 1; + pthis->vTurnDirection = linkDirection * forceDirection; + pthis->actionFunc = BgHakaGate_StatueTurn; } else { player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - if (this->vTimer != 0) { - this->vTimer--; + pthis->dyna.unk_150 = 0.0f; + if (pthis->vTimer != 0) { + pthis->vTimer--; } } } else { if (sPuzzleState == SKULL_OF_TRUTH_FOUND) { - this->actionFunc = BgHakaGate_StatueInactive; + pthis->actionFunc = BgHakaGate_StatueInactive; } else { - this->vTimer = 0; + pthis->vTimer = 0; } } } -void BgHakaGate_StatueTurn(BgHakaGate* this, GlobalContext* globalCtx) { +void BgHakaGate_StatueTurn(BgHakaGate* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 turnFinished; s16 turnAngle; - this->vTurnRateDeg10++; - this->vTurnRateDeg10 = CLAMP_MAX(this->vTurnRateDeg10, 5); - turnFinished = Math_StepToS(&this->vTurnAngleDeg10, 600, this->vTurnRateDeg10); - turnAngle = this->vTurnAngleDeg10 * this->vTurnDirection; - this->dyna.actor.shape.rot.y = (this->vRotYDeg10 + turnAngle) * 0.1f * (0x10000 / 360.0f); + pthis->vTurnRateDeg10++; + pthis->vTurnRateDeg10 = CLAMP_MAX(pthis->vTurnRateDeg10, 5); + turnFinished = Math_StepToS(&pthis->vTurnAngleDeg10, 600, pthis->vTurnRateDeg10); + turnAngle = pthis->vTurnAngleDeg10 * pthis->vTurnDirection; + pthis->dyna.actor.shape.rot.y = (pthis->vRotYDeg10 + turnAngle) * 0.1f * (0x10000 / 360.0f); if ((player->stateFlags2 & 0x10) && (sStatueDistToPlayer > 0.0f)) { player->actor.world.pos.x = - this->dyna.actor.home.pos.x + - (Math_SinS(this->dyna.actor.shape.rot.y - this->vInitTurnAngle) * sStatueDistToPlayer); + pthis->dyna.actor.home.pos.x + + (Math_SinS(pthis->dyna.actor.shape.rot.y - pthis->vInitTurnAngle) * sStatueDistToPlayer); player->actor.world.pos.z = - this->dyna.actor.home.pos.z + - (Math_CosS(this->dyna.actor.shape.rot.y - this->vInitTurnAngle) * sStatueDistToPlayer); + pthis->dyna.actor.home.pos.z + + (Math_CosS(pthis->dyna.actor.shape.rot.y - pthis->vInitTurnAngle) * sStatueDistToPlayer); } else { sStatueDistToPlayer = 0.0f; } - sStatueRotY = this->dyna.actor.shape.rot.y; + sStatueRotY = pthis->dyna.actor.shape.rot.y; if (turnFinished) { player->stateFlags2 &= ~0x10; - this->vRotYDeg10 = (this->vRotYDeg10 + turnAngle) % 3600; - this->vTurnRateDeg10 = 0; - this->vTurnAngleDeg10 = 0; - this->vTimer = 5; - this->actionFunc = BgHakaGate_StatueIdle; - this->dyna.unk_150 = 0.0f; + pthis->vRotYDeg10 = (pthis->vRotYDeg10 + turnAngle) % 3600; + pthis->vTurnRateDeg10 = 0; + pthis->vTurnAngleDeg10 = 0; + pthis->vTimer = 5; + pthis->actionFunc = BgHakaGate_StatueIdle; + pthis->dyna.unk_150 = 0.0f; } - func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } -void BgHakaGate_FloorClosed(BgHakaGate* this, GlobalContext* globalCtx) { +void BgHakaGate_FloorClosed(BgHakaGate* pthis, GlobalContext* globalCtx) { if ((sStatueDistToPlayer > 1.0f) && (sStatueRotY != 0)) { Player* player = GET_PLAYER(globalCtx); f32 radialDist; f32 angDist; f32 cos = Math_CosS(sStatueRotY); f32 sin = Math_SinS(sStatueRotY); - f32 dx = player->actor.world.pos.x - this->dyna.actor.world.pos.x; - f32 dz = player->actor.world.pos.z - this->dyna.actor.world.pos.z; + f32 dx = player->actor.world.pos.x - pthis->dyna.actor.world.pos.x; + f32 dz = player->actor.world.pos.z - pthis->dyna.actor.world.pos.z; radialDist = dx * cos - dz * sin; angDist = dx * sin + dz * cos; @@ -248,83 +248,83 @@ void BgHakaGate_FloorClosed(BgHakaGate* this, GlobalContext* globalCtx) { sStatueDistToPlayer = 0.0f; if (ABS(yawDiff) < 0x80) { - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, pthis->switchFlag); sPuzzleState = SKULL_OF_TRUTH_FOUND; - this->actionFunc = BgHakaGate_DoNothing; + pthis->actionFunc = BgHakaGate_DoNothing; } else { func_80078884(NA_SE_SY_ERROR); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_GROUND_GATE_OPEN); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->vTimer = 60; - this->actionFunc = BgHakaGate_FloorOpen; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_GROUND_GATE_OPEN); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->vTimer = 60; + pthis->actionFunc = BgHakaGate_FloorOpen; } } } } -void BgHakaGate_FloorOpen(BgHakaGate* this, GlobalContext* globalCtx) { - if (this->vTimer != 0) { - this->vTimer--; +void BgHakaGate_FloorOpen(BgHakaGate* pthis, GlobalContext* globalCtx) { + if (pthis->vTimer != 0) { + pthis->vTimer--; } - if (this->vTimer == 0) { - if (Math_ScaledStepToS(&this->vOpenAngle, 0, 0x800)) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgHakaGate_FloorClosed; + if (pthis->vTimer == 0) { + if (Math_ScaledStepToS(&pthis->vOpenAngle, 0, 0x800)) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->actionFunc = BgHakaGate_FloorClosed; } } else { - Math_ScaledStepToS(&this->vOpenAngle, 0x3000, 0x800); + Math_ScaledStepToS(&pthis->vOpenAngle, 0x3000, 0x800); } } -void BgHakaGate_GateWait(BgHakaGate* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->actionFunc = BgHakaGate_GateOpen; +void BgHakaGate_GateWait(BgHakaGate* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->actionFunc = BgHakaGate_GateOpen; } } -void BgHakaGate_GateOpen(BgHakaGate* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 80.0f, 1.0f)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); - this->dyna.actor.flags &= ~ACTOR_FLAG_4; - this->actionFunc = BgHakaGate_DoNothing; +void BgHakaGate_GateOpen(BgHakaGate* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 80.0f, 1.0f)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_STOP); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; + pthis->actionFunc = BgHakaGate_DoNothing; } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); } } -void BgHakaGate_SkullOfTruth(BgHakaGate* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag) && Math_StepToS(&this->vFlameScale, 350, 20)) { - this->actionFunc = BgHakaGate_DoNothing; +void BgHakaGate_SkullOfTruth(BgHakaGate* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag) && Math_StepToS(&pthis->vFlameScale, 350, 20)) { + pthis->actionFunc = BgHakaGate_DoNothing; } } -void BgHakaGate_FalseSkull(BgHakaGate* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - Math_StepToS(&this->vFlameScale, 350, 20); +void BgHakaGate_FalseSkull(BgHakaGate* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + Math_StepToS(&pthis->vFlameScale, 350, 20); } if (globalCtx->actorCtx.unk_03) { - this->dyna.actor.flags |= ACTOR_FLAG_7; + pthis->dyna.actor.flags |= ACTOR_FLAG_7; } else { - this->dyna.actor.flags &= ~ACTOR_FLAG_7; + pthis->dyna.actor.flags &= ~ACTOR_FLAG_7; } } void BgHakaGate_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgHakaGate* this = (BgHakaGate*)thisx; + BgHakaGate* pthis = (BgHakaGate*)thisx; - this->actionFunc(this, globalCtx); - if (this->dyna.actor.params == BGHAKAGATE_SKULL) { - this->vScrollTimer++; + pthis->actionFunc(pthis, globalCtx); + if (pthis->dyna.actor.params == BGHAKAGATE_SKULL) { + pthis->vScrollTimer++; } } -void BgHakaGate_DrawFlame(BgHakaGate* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void BgHakaGate_DrawFlame(BgHakaGate* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; f32 scale; - if (this->vFlameScale > 0) { + if (pthis->vFlameScale > 0) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_gate.c", 716); if (1) {} @@ -332,13 +332,13 @@ void BgHakaGate_DrawFlame(BgHakaGate* this, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (this->vScrollTimer * -20) & 0x1FF, 0x20, 0x80)); + (pthis->vScrollTimer * -20) & 0x1FF, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y + 15.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) * (M_PI / 0x8000), MTXMODE_APPLY); - scale = this->vFlameScale * 0.00001f; + scale = pthis->vFlameScale * 0.00001f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_gate.c", 744), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -354,7 +354,7 @@ void BgHakaGate_Draw(Actor* thisx, GlobalContext* globalCtx) { object_haka_objects_DL_00A860, object_haka_objects_DL_00F1B0, }; - BgHakaGate* this = (BgHakaGate*)thisx; + BgHakaGate* pthis = (BgHakaGate*)thisx; MtxF currentMtxF; if (CHECK_FLAG_ALL(thisx->flags, ACTOR_FLAG_7)) { @@ -365,14 +365,14 @@ void BgHakaGate_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_gate.c", 781); Matrix_Get(¤tMtxF); Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); - Matrix_RotateX(this->vOpenAngle * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->vOpenAngle * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 2000.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_gate.c", 788), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_010A10); Matrix_Put(¤tMtxF); Matrix_Translate(0.0f, 0.0f, 2000.0f, MTXMODE_APPLY); - Matrix_RotateX(-this->vOpenAngle * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(-pthis->vOpenAngle * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_gate.c", 796), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -383,6 +383,6 @@ void BgHakaGate_Draw(Actor* thisx, GlobalContext* globalCtx) { } } if (thisx->params == BGHAKAGATE_SKULL) { - BgHakaGate_DrawFlame(this, globalCtx); + BgHakaGate_DrawFlame(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c deleted file mode 100644 index 00cba09e6..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c +++ /dev/null @@ -1,229 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_HUTA_Z_BG_HAKA_HUTA_C -#include "actor_common.h" -/* - * File: z_bg_haka_huta.c - * Overlay: ovl_Bg_Haka_Huta - * Description: Coffin Lid - */ - -#include "z_bg_haka_huta.h" -#include "objects/object_hakach_objects/object_hakach_objects.h" -#include "def/code_80043480.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_quake.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgHakaHuta_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaHuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaHuta_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaHuta_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgHakaHuta_SpawnDust(BgHakaHuta* this, GlobalContext* globalCtx); -void BgHakaHuta_PlaySound(BgHakaHuta* this, GlobalContext* globalCtx, u16 sfx); -void BgHakaHuta_SpawnEnemies(BgHakaHuta* this, GlobalContext* globalCtx); -void BgHakaHuta_Open(BgHakaHuta* this, GlobalContext* globalCtx); -void BgHakaHuta_SlideOpen(BgHakaHuta* this, GlobalContext* globalCtx); -void func_8087D720(BgHakaHuta* this, GlobalContext* globalCtx); -void BgHakaHuta_DoNothing(BgHakaHuta* this, GlobalContext* globalCtx); - -const ActorInit Bg_Haka_Huta_InitVars = { - ACTOR_BG_HAKA_HUTA, - ACTORCAT_BG, - FLAGS, - OBJECT_HAKACH_OBJECTS, - sizeof(BgHakaHuta), - (ActorFunc)BgHakaHuta_Init, - (ActorFunc)BgHakaHuta_Destroy, - (ActorFunc)BgHakaHuta_Update, - (ActorFunc)BgHakaHuta_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgHakaHuta_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHakaHuta* this = (BgHakaHuta*)thisx; - s16 pad; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(&gBotwCoffinLidCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - this->unk_16A = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - if (Flags_GetSwitch(globalCtx, thisx->params)) { - this->counter = -1; - this->actionFunc = func_8087D720; - } else { - this->actionFunc = BgHakaHuta_SpawnEnemies; - } -} - -void BgHakaHuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaHuta* this = (BgHakaHuta*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgHakaHuta_SpawnDust(BgHakaHuta* this, GlobalContext* globalCtx) { - static Vec3f sEffectAccel[] = { 0.0f, 0.0f, 0.0f }; - static Color_RGBA8 primColor = { 30, 20, 50, 255 }; - static Color_RGBA8 envColor = { 0, 0, 0, 255 }; - f32 scale; - f32 phi_f20; - Vec3f effectPos; - Vec3f effectVel; - s32 i; - f32 new_Xpos; - f32 xPosOffset; - - phi_f20 = (this->dyna.actor.world.rot.y == 0) ? 1.0f : -1.0f; - effectVel.y = 0.0f; - effectVel.z = 0.0f; - effectVel.x = -0.5f * phi_f20; - effectPos.y = this->dyna.actor.world.pos.y; - effectPos.z = this->dyna.actor.world.pos.z; - new_Xpos = 50 - ((this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x) * phi_f20); - xPosOffset = new_Xpos * phi_f20; - - for (i = 0; i < 4; i++) { - if (i == 2) { - effectPos.z += 120.0f * phi_f20; - } - effectPos.x = this->dyna.actor.home.pos.x - (Rand_ZeroOne() * xPosOffset); - scale = ((Rand_ZeroOne() * 10.0f) + 50.0f); - func_8002829C(globalCtx, &effectPos, &effectVel, sEffectAccel, &primColor, &envColor, scale, 0xA); - } -} - -void BgHakaHuta_PlaySound(BgHakaHuta* this, GlobalContext* globalCtx, u16 sfx) { - Vec3f pos; - - pos.z = (this->dyna.actor.shape.rot.y == 0) ? this->dyna.actor.world.pos.z + 120.0f - : this->dyna.actor.world.pos.z - 120.0f; - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y; - Audio_PlaySoundAtPosition(globalCtx, &pos, 30, sfx); -} - -void BgHakaHuta_SpawnEnemies(BgHakaHuta* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params) && !Player_InCsMode(globalCtx)) { - this->counter = 25; - this->actionFunc = BgHakaHuta_Open; - OnePointCutscene_Init(globalCtx, 6001, 999, &this->dyna.actor, MAIN_CAM); - if (this->unk_16A == 2) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FIREFLY, - (this->dyna.actor.world.pos.x + (-25.0f) * Math_CosS(this->dyna.actor.shape.rot.y) + - 40.0f * Math_SinS(this->dyna.actor.shape.rot.y)), - this->dyna.actor.world.pos.y - 10.0f, - (this->dyna.actor.world.pos.z - (-25.0f) * Math_SinS(this->dyna.actor.shape.rot.y) + - Math_CosS(this->dyna.actor.shape.rot.y) * 40.0f), - 0, this->dyna.actor.shape.rot.y + 0x8000, 0, 2); - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FIREFLY, - (this->dyna.actor.world.pos.x + (-25.0f) * (Math_CosS(this->dyna.actor.shape.rot.y)) + - Math_SinS(this->dyna.actor.shape.rot.y) * 80.0f), - this->dyna.actor.world.pos.y - 10.0f, - (this->dyna.actor.world.pos.z - (-25.0f) * (Math_SinS(this->dyna.actor.shape.rot.y)) + - Math_CosS(this->dyna.actor.shape.rot.y) * 80.0f), - 0, this->dyna.actor.shape.rot.y, 0, 2); - - } else if (this->unk_16A == 1) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_RD, - (this->dyna.actor.home.pos.x + (-25.0f) * (Math_CosS(this->dyna.actor.shape.rot.y)) + - Math_SinS(this->dyna.actor.shape.rot.y) * 100.0f), - this->dyna.actor.home.pos.y - 40.0f, - (this->dyna.actor.home.pos.z - (-25.0f) * (Math_SinS(this->dyna.actor.shape.rot.y)) + - Math_CosS(this->dyna.actor.shape.rot.y) * 100.0f), - 0, this->dyna.actor.shape.rot.y, 0, 0xFD); - } - } -} - -void BgHakaHuta_Open(BgHakaHuta* this, GlobalContext* globalCtx) { - f32 posOffset; - - if (this->counter != 0) { - this->counter--; - } - posOffset = (this->dyna.actor.world.rot.y == 0) ? 4.0f : -4.0f; - Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + posOffset, 2.0f); - if (this->counter == 0) { - this->counter = 37; - BgHakaHuta_PlaySound(this, globalCtx, NA_SE_EV_COFFIN_CAP_OPEN); - this->actionFunc = BgHakaHuta_SlideOpen; - } -} - -void BgHakaHuta_SlideOpen(BgHakaHuta* this, GlobalContext* globalCtx) { - f32 posOffset; - - if (this->counter != 0) { - this->counter--; - } - posOffset = (this->dyna.actor.world.rot.y == 0) ? 24.0f : -24.0f; - if (!Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + posOffset, 0.5f)) { - BgHakaHuta_SpawnDust(this, globalCtx); - } - if (this->counter == 0) { - BgHakaHuta_PlaySound(this, globalCtx, NA_SE_EV_COFFIN_CAP_BOUND); - this->actionFunc = func_8087D720; - } -} - -void func_8087D720(BgHakaHuta* this, GlobalContext* globalCtx) { - static Vec3f D_8087D958 = { 30.0f, 0.0f, 0.0f }; - static Vec3f D_8087D964 = { 0.03258f, 0.3258f, -0.9449f }; - MtxF mtx; - Vec3f vec; - s32 quakeIndex; - - this->counter++; - if (this->counter == 6) { - this->actionFunc = BgHakaHuta_DoNothing; - quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quakeIndex, 0x7530); - Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 2); - } else if (this->counter == 0) { - this->counter = 6; - this->actionFunc = BgHakaHuta_DoNothing; - } - - D_8087D958.x = this->counter + 24.0f; - if (D_8087D958.x > 30.0f) { - D_8087D958.x = 30.0f; - } - Matrix_RotateY(this->dyna.actor.world.rot.y * (M_PI / 0x8000), MTXMODE_NEW); - Matrix_RotateAxis(this->counter * (191 * M_PI / 3750), &D_8087D964, MTXMODE_APPLY); - Matrix_MultVec3f(&D_8087D958, &vec); - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + vec.x; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + vec.y; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + vec.z; - Matrix_Get(&mtx); - Matrix_MtxFToYXZRotS(&mtx, &this->dyna.actor.shape.rot, 0); -} - -void BgHakaHuta_DoNothing(BgHakaHuta* this, GlobalContext* globalCtx) { -} - -void BgHakaHuta_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaHuta* this = (BgHakaHuta*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgHakaHuta_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gBotwCoffinLidDL); -} diff --git a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.cpp b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.cpp new file mode 100644 index 000000000..a7c5b1460 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.cpp @@ -0,0 +1,229 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_HUTA_Z_BG_HAKA_HUTA_C +#include "actor_common.h" +/* + * File: z_bg_haka_huta.c + * Overlay: ovl_Bg_Haka_Huta + * Description: Coffin Lid + */ + +#include "z_bg_haka_huta.h" +#include "objects/object_hakach_objects/object_hakach_objects.h" +#include "def/code_80043480.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_quake.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgHakaHuta_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHakaHuta_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHakaHuta_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakaHuta_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgHakaHuta_SpawnDust(BgHakaHuta* pthis, GlobalContext* globalCtx); +void BgHakaHuta_PlaySound(BgHakaHuta* pthis, GlobalContext* globalCtx, u16 sfx); +void BgHakaHuta_SpawnEnemies(BgHakaHuta* pthis, GlobalContext* globalCtx); +void BgHakaHuta_Open(BgHakaHuta* pthis, GlobalContext* globalCtx); +void BgHakaHuta_SlideOpen(BgHakaHuta* pthis, GlobalContext* globalCtx); +void func_8087D720(BgHakaHuta* pthis, GlobalContext* globalCtx); +void BgHakaHuta_DoNothing(BgHakaHuta* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Haka_Huta_InitVars = { + ACTOR_BG_HAKA_HUTA, + ACTORCAT_BG, + FLAGS, + OBJECT_HAKACH_OBJECTS, + sizeof(BgHakaHuta), + (ActorFunc)BgHakaHuta_Init, + (ActorFunc)BgHakaHuta_Destroy, + (ActorFunc)BgHakaHuta_Update, + (ActorFunc)BgHakaHuta_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgHakaHuta_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHakaHuta* pthis = (BgHakaHuta*)thisx; + s16 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(&gBotwCoffinLidCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->unk_16A = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + if (Flags_GetSwitch(globalCtx, thisx->params)) { + pthis->counter = -1; + pthis->actionFunc = func_8087D720; + } else { + pthis->actionFunc = BgHakaHuta_SpawnEnemies; + } +} + +void BgHakaHuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaHuta* pthis = (BgHakaHuta*)thisx; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgHakaHuta_SpawnDust(BgHakaHuta* pthis, GlobalContext* globalCtx) { + static Vec3f sEffectAccel[] = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 primColor = { 30, 20, 50, 255 }; + static Color_RGBA8 envColor = { 0, 0, 0, 255 }; + f32 scale; + f32 phi_f20; + Vec3f effectPos; + Vec3f effectVel; + s32 i; + f32 new_Xpos; + f32 xPosOffset; + + phi_f20 = (pthis->dyna.actor.world.rot.y == 0) ? 1.0f : -1.0f; + effectVel.y = 0.0f; + effectVel.z = 0.0f; + effectVel.x = -0.5f * phi_f20; + effectPos.y = pthis->dyna.actor.world.pos.y; + effectPos.z = pthis->dyna.actor.world.pos.z; + new_Xpos = 50 - ((pthis->dyna.actor.world.pos.x - pthis->dyna.actor.home.pos.x) * phi_f20); + xPosOffset = new_Xpos * phi_f20; + + for (i = 0; i < 4; i++) { + if (i == 2) { + effectPos.z += 120.0f * phi_f20; + } + effectPos.x = pthis->dyna.actor.home.pos.x - (Rand_ZeroOne() * xPosOffset); + scale = ((Rand_ZeroOne() * 10.0f) + 50.0f); + func_8002829C(globalCtx, &effectPos, &effectVel, sEffectAccel, &primColor, &envColor, scale, 0xA); + } +} + +void BgHakaHuta_PlaySound(BgHakaHuta* pthis, GlobalContext* globalCtx, u16 sfx) { + Vec3f pos; + + pos.z = (pthis->dyna.actor.shape.rot.y == 0) ? pthis->dyna.actor.world.pos.z + 120.0f + : pthis->dyna.actor.world.pos.z - 120.0f; + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y; + Audio_PlaySoundAtPosition(globalCtx, &pos, 30, sfx); +} + +void BgHakaHuta_SpawnEnemies(BgHakaHuta* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params) && !Player_InCsMode(globalCtx)) { + pthis->counter = 25; + pthis->actionFunc = BgHakaHuta_Open; + OnePointCutscene_Init(globalCtx, 6001, 999, &pthis->dyna.actor, MAIN_CAM); + if (pthis->unk_16A == 2) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FIREFLY, + (pthis->dyna.actor.world.pos.x + (-25.0f) * Math_CosS(pthis->dyna.actor.shape.rot.y) + + 40.0f * Math_SinS(pthis->dyna.actor.shape.rot.y)), + pthis->dyna.actor.world.pos.y - 10.0f, + (pthis->dyna.actor.world.pos.z - (-25.0f) * Math_SinS(pthis->dyna.actor.shape.rot.y) + + Math_CosS(pthis->dyna.actor.shape.rot.y) * 40.0f), + 0, pthis->dyna.actor.shape.rot.y + 0x8000, 0, 2); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FIREFLY, + (pthis->dyna.actor.world.pos.x + (-25.0f) * (Math_CosS(pthis->dyna.actor.shape.rot.y)) + + Math_SinS(pthis->dyna.actor.shape.rot.y) * 80.0f), + pthis->dyna.actor.world.pos.y - 10.0f, + (pthis->dyna.actor.world.pos.z - (-25.0f) * (Math_SinS(pthis->dyna.actor.shape.rot.y)) + + Math_CosS(pthis->dyna.actor.shape.rot.y) * 80.0f), + 0, pthis->dyna.actor.shape.rot.y, 0, 2); + + } else if (pthis->unk_16A == 1) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_RD, + (pthis->dyna.actor.home.pos.x + (-25.0f) * (Math_CosS(pthis->dyna.actor.shape.rot.y)) + + Math_SinS(pthis->dyna.actor.shape.rot.y) * 100.0f), + pthis->dyna.actor.home.pos.y - 40.0f, + (pthis->dyna.actor.home.pos.z - (-25.0f) * (Math_SinS(pthis->dyna.actor.shape.rot.y)) + + Math_CosS(pthis->dyna.actor.shape.rot.y) * 100.0f), + 0, pthis->dyna.actor.shape.rot.y, 0, 0xFD); + } + } +} + +void BgHakaHuta_Open(BgHakaHuta* pthis, GlobalContext* globalCtx) { + f32 posOffset; + + if (pthis->counter != 0) { + pthis->counter--; + } + posOffset = (pthis->dyna.actor.world.rot.y == 0) ? 4.0f : -4.0f; + Math_StepToF(&pthis->dyna.actor.world.pos.x, pthis->dyna.actor.home.pos.x + posOffset, 2.0f); + if (pthis->counter == 0) { + pthis->counter = 37; + BgHakaHuta_PlaySound(pthis, globalCtx, NA_SE_EV_COFFIN_CAP_OPEN); + pthis->actionFunc = BgHakaHuta_SlideOpen; + } +} + +void BgHakaHuta_SlideOpen(BgHakaHuta* pthis, GlobalContext* globalCtx) { + f32 posOffset; + + if (pthis->counter != 0) { + pthis->counter--; + } + posOffset = (pthis->dyna.actor.world.rot.y == 0) ? 24.0f : -24.0f; + if (!Math_StepToF(&pthis->dyna.actor.world.pos.x, pthis->dyna.actor.home.pos.x + posOffset, 0.5f)) { + BgHakaHuta_SpawnDust(pthis, globalCtx); + } + if (pthis->counter == 0) { + BgHakaHuta_PlaySound(pthis, globalCtx, NA_SE_EV_COFFIN_CAP_BOUND); + pthis->actionFunc = func_8087D720; + } +} + +void func_8087D720(BgHakaHuta* pthis, GlobalContext* globalCtx) { + static Vec3f D_8087D958 = { 30.0f, 0.0f, 0.0f }; + static Vec3f D_8087D964 = { 0.03258f, 0.3258f, -0.9449f }; + MtxF mtx; + Vec3f vec; + s32 quakeIndex; + + pthis->counter++; + if (pthis->counter == 6) { + pthis->actionFunc = BgHakaHuta_DoNothing; + quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(quakeIndex, 0x7530); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 2); + } else if (pthis->counter == 0) { + pthis->counter = 6; + pthis->actionFunc = BgHakaHuta_DoNothing; + } + + D_8087D958.x = pthis->counter + 24.0f; + if (D_8087D958.x > 30.0f) { + D_8087D958.x = 30.0f; + } + Matrix_RotateY(pthis->dyna.actor.world.rot.y * (M_PI / 0x8000), MTXMODE_NEW); + Matrix_RotateAxis(pthis->counter * (191 * M_PI / 3750), &D_8087D964, MTXMODE_APPLY); + Matrix_MultVec3f(&D_8087D958, &vec); + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x + vec.x; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + vec.y; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z + vec.z; + Matrix_Get(&mtx); + Matrix_MtxFToYXZRotS(&mtx, &pthis->dyna.actor.shape.rot, 0); +} + +void BgHakaHuta_DoNothing(BgHakaHuta* pthis, GlobalContext* globalCtx) { +} + +void BgHakaHuta_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaHuta* pthis = (BgHakaHuta*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgHakaHuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gBotwCoffinLidDL); +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.cpp similarity index 63% rename from src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c rename to src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.cpp index 2538c78c1..a834ff665 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c +++ b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.cpp @@ -23,11 +23,11 @@ void BgHakaMegane_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaMegane_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakaMegane_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8087DB24(BgHakaMegane* this, GlobalContext* globalCtx); -void func_8087DBF0(BgHakaMegane* this, GlobalContext* globalCtx); -void BgHakaMegane_DoNothing(BgHakaMegane* this, GlobalContext* globalCtx); +void func_8087DB24(BgHakaMegane* pthis, GlobalContext* globalCtx); +void func_8087DBF0(BgHakaMegane* pthis, GlobalContext* globalCtx); +void BgHakaMegane_DoNothing(BgHakaMegane* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Haka_Megane_InitVars = { +ActorInit Bg_Haka_Megane_InitVars = { ACTOR_BG_HAKA_MEGANE, ACTORCAT_PROP, FLAGS, @@ -68,74 +68,74 @@ static Gfx* sDLists[] = { }; void BgHakaMegane_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMegane* this = (BgHakaMegane*)thisx; + BgHakaMegane* pthis = (BgHakaMegane*)thisx; Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); if (thisx->params < 3) { - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKACH_OBJECTS); + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKACH_OBJECTS); } else { - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); } - if (this->objBankIndex < 0) { + if (pthis->objBankIndex < 0) { Actor_Kill(thisx); } else { - this->actionFunc = func_8087DB24; + pthis->actionFunc = func_8087DB24; } } void BgHakaMegane_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMegane* this = (BgHakaMegane*)thisx; + BgHakaMegane* pthis = (BgHakaMegane*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_8087DB24(BgHakaMegane* this, GlobalContext* globalCtx) { +void func_8087DB24(BgHakaMegane* pthis, GlobalContext* globalCtx) { CollisionHeader* colHeader; CollisionHeader* collision; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->dyna.actor.objBankIndex = this->objBankIndex; - this->dyna.actor.draw = BgHakaMegane_Draw; - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->dyna.actor.objBankIndex = pthis->objBankIndex; + pthis->dyna.actor.draw = BgHakaMegane_Draw; + Actor_SetObjectDependency(globalCtx, &pthis->dyna.actor); if (globalCtx->roomCtx.curRoom.showInvisActors) { - this->actionFunc = func_8087DBF0; - collision = sCollisionHeaders[this->dyna.actor.params]; + pthis->actionFunc = func_8087DBF0; + collision = sCollisionHeaders[pthis->dyna.actor.params]; if (collision != NULL) { CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } } else { - this->actionFunc = BgHakaMegane_DoNothing; + pthis->actionFunc = BgHakaMegane_DoNothing; } } } -void func_8087DBF0(BgHakaMegane* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void func_8087DBF0(BgHakaMegane* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; if (globalCtx->actorCtx.unk_03 != 0) { thisx->flags |= ACTOR_FLAG_7; - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } else { thisx->flags &= ~ACTOR_FLAG_7; - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } -void BgHakaMegane_DoNothing(BgHakaMegane* this, GlobalContext* globalCtx) { +void BgHakaMegane_DoNothing(BgHakaMegane* pthis, GlobalContext* globalCtx) { } void BgHakaMegane_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMegane* this = (BgHakaMegane*)thisx; + BgHakaMegane* pthis = (BgHakaMegane*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgHakaMegane_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMegane* this = (BgHakaMegane*)thisx; + BgHakaMegane* pthis = (BgHakaMegane*)thisx; if (CHECK_FLAG_ALL(thisx->flags, ACTOR_FLAG_7)) { Gfx_DrawDListXlu(globalCtx, sDLists[thisx->params]); diff --git a/src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.c b/src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.c deleted file mode 100644 index ef0459ca3..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.c +++ /dev/null @@ -1,229 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_MEGANEBG_Z_BG_HAKA_MEGANEBG_C -#include "actor_common.h" -/* - * File: z_bg_haka_meganebg.c - * Overlay: ovl_Bg_Haka_MeganeBG - * Description: - */ - -#include "z_bg_haka_meganebg.h" -#include "objects/object_haka_objects/object_haka_objects.h" -#include "def/code_80043480.h" -#include "def/sinf.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS 0 - -void BgHakaMeganeBG_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaMeganeBG_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaMeganeBG_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaMeganeBG_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8087DFF8(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E040(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E10C(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E1E0(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E258(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E288(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E2D8(BgHakaMeganeBG* this, GlobalContext* globalCtx); -void func_8087E34C(BgHakaMeganeBG* this, GlobalContext* globalCtx); - -const ActorInit Bg_Haka_MeganeBG_InitVars = { - ACTOR_BG_HAKA_MEGANEBG, - ACTORCAT_BG, - FLAGS, - OBJECT_HAKA_OBJECTS, - sizeof(BgHakaMeganeBG), - (ActorFunc)BgHakaMeganeBG_Init, - (ActorFunc)BgHakaMeganeBG_Destroy, - (ActorFunc)BgHakaMeganeBG_Update, - (ActorFunc)BgHakaMeganeBG_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -// Unused -static u32 D_8087E3FC[] = { - 0x00000000, 0x00000000, 0x00000000, 0xC8C800FF, 0xFF0000FF, -}; - -static Gfx* D_8087E410[] = { - object_haka_objects_DL_008EB0, - object_haka_objects_DL_00A1A0, - object_haka_objects_DL_005000, - object_haka_objects_DL_000040, -}; - -void BgHakaMeganeBG_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHakaMeganeBG* this = (BgHakaMeganeBG*)thisx; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->unk_168 = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - - if (thisx->params == 2) { - DynaPolyActor_Init(&this->dyna, DPM_UNK3); - thisx->flags |= ACTOR_FLAG_4; - CollisionHeader_GetVirtual(&object_haka_objects_Col_005334, &colHeader); - this->actionFunc = func_8087E258; - } else { - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - - if (thisx->params == 0) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_009168, &colHeader); - thisx->flags |= ACTOR_FLAG_7; - this->unk_16A = 20; - this->actionFunc = func_8087DFF8; - } else if (thisx->params == 3) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_000118, &colHeader); - thisx->home.pos.y += 100.0f; - - if (Flags_GetSwitch(globalCtx, this->unk_168)) { - this->actionFunc = func_8087E34C; - thisx->world.pos.y = thisx->home.pos.y; - } else { - thisx->flags |= ACTOR_FLAG_4; - this->actionFunc = func_8087E288; - } - } else { - CollisionHeader_GetVirtual(&object_haka_objects_Col_00A7F4, &colHeader); - this->unk_16A = 80; - this->actionFunc = func_8087E10C; - thisx->uncullZoneScale = 3000.0f; - thisx->uncullZoneDownward = 3000.0f; - } - } - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); -} - -void BgHakaMeganeBG_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMeganeBG* this = (BgHakaMeganeBG*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_8087DFF8(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - if (this->unk_16A != 0) { - this->unk_16A--; - } - - if (this->unk_16A == 0) { - this->unk_16A = 40; - this->dyna.actor.world.rot.y += 0x8000; - this->actionFunc = func_8087E040; - } -} - -void func_8087E040(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - f32 xSub; - - if (this->unk_16A != 0) { - this->unk_16A--; - } - - xSub = (sinf(((this->unk_16A * 0.025f) + 0.5f) * M_PI) + 1.0f) * 160.0f; - - if (this->dyna.actor.world.rot.y != this->dyna.actor.shape.rot.y) { - xSub = 320.0f - xSub; - } - - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - xSub; - - if (this->unk_16A == 0) { - this->unk_16A = 20; - this->actionFunc = func_8087DFF8; - } -} - -void func_8087E10C(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - this->dyna.actor.velocity.y += 1.0f; - - if (this->dyna.actor.velocity.y > 20.0f) { - this->dyna.actor.velocity.y = 20.0f; - } else { - this->dyna.actor.velocity.y = this->dyna.actor.velocity.y; - } - - if (this->unk_16A != 0) { - this->unk_16A--; - } - - if (!Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 640.0f, - this->dyna.actor.velocity.y)) { - func_8002F974(&this->dyna.actor, NA_SE_EV_CHINETRAP_DOWN - SFX_FLAG); - } - - if (this->unk_16A == 0) { - this->unk_16A = 120; - this->actionFunc = func_8087E1E0; - this->dyna.actor.velocity.y = 0.0f; - } -} - -void func_8087E1E0(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 16.0f / 3.0f); - func_8002F974(&this->dyna.actor, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); - - if (this->unk_16A != 0) { - this->unk_16A--; - } - - if (this->unk_16A == 0) { - this->unk_16A = 80; - this->actionFunc = func_8087E10C; - } -} - -void func_8087E258(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - this->dyna.actor.shape.rot.y += 0x180; - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); -} - -void func_8087E288(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->unk_168)) { - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->actionFunc = func_8087E2D8; - } -} - -void func_8087E2D8(BgHakaMeganeBG* this, GlobalContext* globalCtx) { - Math_StepToF(&this->dyna.actor.speedXZ, 30.0f, 2.0f); - - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.speedXZ)) { - Actor_SetFocus(&this->dyna.actor, 50.0f); - this->actionFunc = func_8087E34C; - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); - } -} - -void func_8087E34C(BgHakaMeganeBG* this, GlobalContext* globalCtx) { -} - -void BgHakaMeganeBG_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMeganeBG* this = (BgHakaMeganeBG*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgHakaMeganeBG_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHakaMeganeBG* this = (BgHakaMeganeBG*)thisx; - s16 params = this->dyna.actor.params; - - if (params == 0) { - Gfx_DrawDListXlu(globalCtx, object_haka_objects_DL_008EB0); - } else { - Gfx_DrawDListOpa(globalCtx, D_8087E410[params]); - } -} diff --git a/src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.cpp b/src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.cpp new file mode 100644 index 000000000..86a79c152 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Haka_MeganeBG/z_bg_haka_meganebg.cpp @@ -0,0 +1,228 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_MEGANEBG_Z_BG_HAKA_MEGANEBG_C +#include "actor_common.h" +/* + * File: z_bg_haka_meganebg.c + * Overlay: ovl_Bg_Haka_MeganeBG + * Description: + */ + +#include "z_bg_haka_meganebg.h" +#include "objects/object_haka_objects/object_haka_objects.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS 0 + +void BgHakaMeganeBG_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHakaMeganeBG_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHakaMeganeBG_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakaMeganeBG_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8087DFF8(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E040(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E10C(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E1E0(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E258(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E288(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E2D8(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); +void func_8087E34C(BgHakaMeganeBG* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Haka_MeganeBG_InitVars = { + ACTOR_BG_HAKA_MEGANEBG, + ACTORCAT_BG, + FLAGS, + OBJECT_HAKA_OBJECTS, + sizeof(BgHakaMeganeBG), + (ActorFunc)BgHakaMeganeBG_Init, + (ActorFunc)BgHakaMeganeBG_Destroy, + (ActorFunc)BgHakaMeganeBG_Update, + (ActorFunc)BgHakaMeganeBG_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +// Unused +static u32 D_8087E3FC[] = { + 0x00000000, 0x00000000, 0x00000000, 0xC8C800FF, 0xFF0000FF, +}; + +static Gfx* D_8087E410[] = { + object_haka_objects_DL_008EB0, + object_haka_objects_DL_00A1A0, + object_haka_objects_DL_005000, + object_haka_objects_DL_000040, +}; + +void BgHakaMeganeBG_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakaMeganeBG* pthis = (BgHakaMeganeBG*)thisx; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->unk_168 = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + + if (thisx->params == 2) { + DynaPolyActor_Init(&pthis->dyna, DPM_UNK3); + thisx->flags |= ACTOR_FLAG_4; + CollisionHeader_GetVirtual(&object_haka_objects_Col_005334, &colHeader); + pthis->actionFunc = func_8087E258; + } else { + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + + if (thisx->params == 0) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_009168, &colHeader); + thisx->flags |= ACTOR_FLAG_7; + pthis->unk_16A = 20; + pthis->actionFunc = func_8087DFF8; + } else if (thisx->params == 3) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_000118, &colHeader); + thisx->home.pos.y += 100.0f; + + if (Flags_GetSwitch(globalCtx, pthis->unk_168)) { + pthis->actionFunc = func_8087E34C; + thisx->world.pos.y = thisx->home.pos.y; + } else { + thisx->flags |= ACTOR_FLAG_4; + pthis->actionFunc = func_8087E288; + } + } else { + CollisionHeader_GetVirtual(&object_haka_objects_Col_00A7F4, &colHeader); + pthis->unk_16A = 80; + pthis->actionFunc = func_8087E10C; + thisx->uncullZoneScale = 3000.0f; + thisx->uncullZoneDownward = 3000.0f; + } + } + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); +} + +void BgHakaMeganeBG_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaMeganeBG* pthis = (BgHakaMeganeBG*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_8087DFF8(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + if (pthis->unk_16A != 0) { + pthis->unk_16A--; + } + + if (pthis->unk_16A == 0) { + pthis->unk_16A = 40; + pthis->dyna.actor.world.rot.y += 0x8000; + pthis->actionFunc = func_8087E040; + } +} + +void func_8087E040(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + f32 xSub; + + if (pthis->unk_16A != 0) { + pthis->unk_16A--; + } + + xSub = (sinf(((pthis->unk_16A * 0.025f) + 0.5f) * M_PI) + 1.0f) * 160.0f; + + if (pthis->dyna.actor.world.rot.y != pthis->dyna.actor.shape.rot.y) { + xSub = 320.0f - xSub; + } + + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x - xSub; + + if (pthis->unk_16A == 0) { + pthis->unk_16A = 20; + pthis->actionFunc = func_8087DFF8; + } +} + +void func_8087E10C(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.velocity.y += 1.0f; + + if (pthis->dyna.actor.velocity.y > 20.0f) { + pthis->dyna.actor.velocity.y = 20.0f; + } else { + pthis->dyna.actor.velocity.y = pthis->dyna.actor.velocity.y; + } + + if (pthis->unk_16A != 0) { + pthis->unk_16A--; + } + + if (!Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 640.0f, + pthis->dyna.actor.velocity.y)) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_CHINETRAP_DOWN - SFX_FLAG); + } + + if (pthis->unk_16A == 0) { + pthis->unk_16A = 120; + pthis->actionFunc = func_8087E1E0; + pthis->dyna.actor.velocity.y = 0.0f; + } +} + +void func_8087E1E0(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 16.0f / 3.0f); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); + + if (pthis->unk_16A != 0) { + pthis->unk_16A--; + } + + if (pthis->unk_16A == 0) { + pthis->unk_16A = 80; + pthis->actionFunc = func_8087E10C; + } +} + +void func_8087E258(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.shape.rot.y += 0x180; + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); +} + +void func_8087E288(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->unk_168)) { + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->actionFunc = func_8087E2D8; + } +} + +void func_8087E2D8(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->dyna.actor.speedXZ, 30.0f, 2.0f); + + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.speedXZ)) { + Actor_SetFocus(&pthis->dyna.actor, 50.0f); + pthis->actionFunc = func_8087E34C; + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_OPEN); + } +} + +void func_8087E34C(BgHakaMeganeBG* pthis, GlobalContext* globalCtx) { +} + +void BgHakaMeganeBG_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaMeganeBG* pthis = (BgHakaMeganeBG*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgHakaMeganeBG_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHakaMeganeBG* pthis = (BgHakaMeganeBG*)thisx; + s16 params = pthis->dyna.actor.params; + + if (params == 0) { + Gfx_DrawDListXlu(globalCtx, object_haka_objects_DL_008EB0); + } else { + Gfx_DrawDListOpa(globalCtx, D_8087E410[params]); + } +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c b/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.cpp similarity index 53% rename from src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c rename to src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.cpp index c7a68690d..d092b5bb2 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c +++ b/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.cpp @@ -9,7 +9,6 @@ #include "z_bg_haka_sgami.h" #include "objects/object_haka_objects/object_haka_objects.h" #include "objects/object_ice_objects/object_ice_objects.h" -#include "def/sinf.h" #include "def/z_actor.h" #include "def/z_cheap_proc.h" #include "def/z_collision_check.h" @@ -33,10 +32,10 @@ void BgHakaSgami_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaSgami_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakaSgami_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgHakaSgami_SetupSpin(BgHakaSgami* this, GlobalContext* globalCtx); -void BgHakaSgami_Spin(BgHakaSgami* this, GlobalContext* globalCtx); +void BgHakaSgami_SetupSpin(BgHakaSgami* pthis, GlobalContext* globalCtx); +void BgHakaSgami_Spin(BgHakaSgami* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Haka_Sgami_InitVars = { +ActorInit Bg_Haka_Sgami_InitVars = { ACTOR_BG_HAKA_SGAMI, ACTORCAT_PROP, FLAGS, @@ -141,28 +140,28 @@ void BgHakaSgami_Init(Actor* thisx, GlobalContext* globalCtx) { static u8 sP2StartColor[] = { 200, 200, 200, 130 }; static u8 sP1EndColor[] = { 200, 200, 200, 60 }; static u8 sP2EndColor[] = { 150, 150, 150, 20 }; - BgHakaSgami* this = (BgHakaSgami*)thisx; + BgHakaSgami* pthis = (BgHakaSgami*)thisx; EffectBlureInit1 blureInit; s32 i; - ColliderTris* colliderScythe = &this->colliderScythe; + ColliderTris* colliderScythe = &pthis->colliderScythe; Actor_ProcessInitChain(thisx, sInitChain); - this->unk_151 = thisx->params & 0xFF; + pthis->unk_151 = thisx->params & 0xFF; thisx->params = (thisx->params >> 8) & 0xFF; - if (this->unk_151 != 0) { + if (pthis->unk_151 != 0) { thisx->flags |= ACTOR_FLAG_7; } Collider_InitTris(globalCtx, colliderScythe); - Collider_SetTris(globalCtx, colliderScythe, thisx, &sTrisInit, this->colliderScytheItems); - Collider_InitCylinder(globalCtx, &this->colliderScytheCenter); - Collider_SetCylinder(globalCtx, &this->colliderScytheCenter, thisx, &sCylinderInit); + Collider_SetTris(globalCtx, colliderScythe, thisx, &sTrisInit, pthis->colliderScytheItems); + Collider_InitCylinder(globalCtx, &pthis->colliderScytheCenter); + Collider_SetCylinder(globalCtx, &pthis->colliderScytheCenter, thisx, &sCylinderInit); - this->colliderScytheCenter.dim.pos.x = thisx->world.pos.x; - this->colliderScytheCenter.dim.pos.y = thisx->world.pos.y; - this->colliderScytheCenter.dim.pos.z = thisx->world.pos.z; + pthis->colliderScytheCenter.dim.pos.x = thisx->world.pos.x; + pthis->colliderScytheCenter.dim.pos.y = thisx->world.pos.y; + pthis->colliderScytheCenter.dim.pos.z = thisx->world.pos.z; CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); @@ -175,47 +174,47 @@ void BgHakaSgami_Init(Actor* thisx, GlobalContext* globalCtx) { blureInit.elemDuration = 10; blureInit.unkFlag = false; blureInit.calcMode = 2; - Effect_Add(globalCtx, &this->blureEffectIndex[0], EFFECT_BLURE1, 0, 0, &blureInit); - Effect_Add(globalCtx, &this->blureEffectIndex[1], EFFECT_BLURE1, 0, 0, &blureInit); + Effect_Add(globalCtx, &pthis->blureEffectIndex[0], EFFECT_BLURE1, 0, 0, &blureInit); + Effect_Add(globalCtx, &pthis->blureEffectIndex[1], EFFECT_BLURE1, 0, 0, &blureInit); if (thisx->params == SCYTHE_TRAP_SHADOW_TEMPLE) { - this->requiredObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); + pthis->requiredObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); thisx->flags &= ~ACTOR_FLAG_0; } else { - this->requiredObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_OBJECTS); - this->colliderScytheCenter.dim.radius = 30; - this->colliderScytheCenter.dim.height = 70; + pthis->requiredObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_OBJECTS); + pthis->colliderScytheCenter.dim.radius = 30; + pthis->colliderScytheCenter.dim.height = 70; Actor_SetFocus(thisx, 40.0f); } - if (this->requiredObjBankIndex < 0) { + if (pthis->requiredObjBankIndex < 0) { Actor_Kill(thisx); return; } - this->actionFunc = BgHakaSgami_SetupSpin; + pthis->actionFunc = BgHakaSgami_SetupSpin; } void BgHakaSgami_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaSgami* this = (BgHakaSgami*)thisx; + BgHakaSgami* pthis = (BgHakaSgami*)thisx; - Effect_Delete(globalCtx, this->blureEffectIndex[0]); - Effect_Delete(globalCtx, this->blureEffectIndex[1]); - Collider_DestroyTris(globalCtx, &this->colliderScythe); - Collider_DestroyCylinder(globalCtx, &this->colliderScytheCenter); + Effect_Delete(globalCtx, pthis->blureEffectIndex[0]); + Effect_Delete(globalCtx, pthis->blureEffectIndex[1]); + Collider_DestroyTris(globalCtx, &pthis->colliderScythe); + Collider_DestroyCylinder(globalCtx, &pthis->colliderScytheCenter); } -void BgHakaSgami_SetupSpin(BgHakaSgami* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { - this->actor.objBankIndex = this->requiredObjBankIndex; - this->actor.draw = BgHakaSgami_Draw; - this->timer = SCYTHE_SPIN_TIME; - this->actor.flags &= ~ACTOR_FLAG_4; - this->actionFunc = BgHakaSgami_Spin; +void BgHakaSgami_SetupSpin(BgHakaSgami* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->requiredObjBankIndex)) { + pthis->actor.objBankIndex = pthis->requiredObjBankIndex; + pthis->actor.draw = BgHakaSgami_Draw; + pthis->timer = SCYTHE_SPIN_TIME; + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actionFunc = BgHakaSgami_Spin; } } -void BgHakaSgami_Spin(BgHakaSgami* this, GlobalContext* globalCtx) { +void BgHakaSgami_Spin(BgHakaSgami* pthis, GlobalContext* globalCtx) { static Vec3f blureEffectVertices2[] = { { -20.0f, 50.0f, 130.0f }, { -50.0f, 33.0f, 20.0f }, @@ -232,84 +231,84 @@ void BgHakaSgami_Spin(BgHakaSgami* this, GlobalContext* globalCtx) { s32 iterateCount; ColliderTrisElementInit* elementInit; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - this->actor.shape.rot.y += ((s16)(512.0f * sinf(this->timer * (M_PI / 16.0f))) + 0x400) >> 1; + pthis->actor.shape.rot.y += ((s16)(512.0f * sinf(pthis->timer * (M_PI / 16.0f))) + 0x400) >> 1; - if (this->timer == 0) { - this->timer = SCYTHE_SPIN_TIME; + if (pthis->timer == 0) { + pthis->timer = SCYTHE_SPIN_TIME; } - actorRotYSin = Math_SinS(this->actor.shape.rot.y); - actorRotYCos = Math_CosS(this->actor.shape.rot.y); + actorRotYSin = Math_SinS(pthis->actor.shape.rot.y); + actorRotYCos = Math_CosS(pthis->actor.shape.rot.y); - iterateCount = (this->actor.params != 0) ? 4 : 2; + iterateCount = (pthis->actor.params != 0) ? 4 : 2; for (i = iterateCount - 2; i < iterateCount; i++) { elementInit = &sTrisInit.elements[i]; for (j = 0; j < 3; j++) { - scytheVertices[j].x = this->actor.world.pos.x + elementInit->dim.vtx[j].z * actorRotYSin + + scytheVertices[j].x = pthis->actor.world.pos.x + elementInit->dim.vtx[j].z * actorRotYSin + elementInit->dim.vtx[j].x * actorRotYCos; - scytheVertices[j].y = this->actor.world.pos.y + elementInit->dim.vtx[j].y; - scytheVertices[j].z = this->actor.world.pos.z + elementInit->dim.vtx[j].z * actorRotYCos - + scytheVertices[j].y = pthis->actor.world.pos.y + elementInit->dim.vtx[j].y; + scytheVertices[j].z = pthis->actor.world.pos.z + elementInit->dim.vtx[j].z * actorRotYCos - elementInit->dim.vtx[j].x * actorRotYSin; } - Collider_SetTrisVertices(&this->colliderScythe, i, &scytheVertices[0], &scytheVertices[1], &scytheVertices[2]); + Collider_SetTrisVertices(&pthis->colliderScythe, i, &scytheVertices[0], &scytheVertices[1], &scytheVertices[2]); for (j = 0; j < 3; j++) { - scytheVertices[j].x = (2 * this->actor.world.pos.x) - scytheVertices[j].x; - scytheVertices[j].z = (2 * this->actor.world.pos.z) - scytheVertices[j].z; + scytheVertices[j].x = (2 * pthis->actor.world.pos.x) - scytheVertices[j].x; + scytheVertices[j].z = (2 * pthis->actor.world.pos.z) - scytheVertices[j].z; } - Collider_SetTrisVertices(&this->colliderScythe, (i + 2) % 4, &scytheVertices[0], &scytheVertices[1], + Collider_SetTrisVertices(&pthis->colliderScythe, (i + 2) % 4, &scytheVertices[0], &scytheVertices[1], &scytheVertices[2]); } - if ((this->unk_151 == 0) || (globalCtx->actorCtx.unk_03 != 0)) { - scytheVertices[0].x = this->actor.world.pos.x + blureEffectVertices1[this->actor.params].z * actorRotYSin + - blureEffectVertices1[this->actor.params].x * actorRotYCos; - scytheVertices[0].y = this->actor.world.pos.y + blureEffectVertices1[this->actor.params].y; - scytheVertices[0].z = this->actor.world.pos.z + blureEffectVertices1[this->actor.params].z * actorRotYCos - - blureEffectVertices1[this->actor.params].x * actorRotYSin; - scytheVertices[1].x = this->actor.world.pos.x + blureEffectVertices2[this->actor.params].z * actorRotYSin + - blureEffectVertices2[this->actor.params].x * actorRotYCos; - scytheVertices[1].y = this->actor.world.pos.y + blureEffectVertices2[this->actor.params].y; - scytheVertices[1].z = this->actor.world.pos.z + blureEffectVertices2[this->actor.params].z * actorRotYCos - - blureEffectVertices2[this->actor.params].x * actorRotYSin; - EffectBlure_AddVertex(Effect_GetByIndex(this->blureEffectIndex[0]), &scytheVertices[0], &scytheVertices[1]); + if ((pthis->unk_151 == 0) || (globalCtx->actorCtx.unk_03 != 0)) { + scytheVertices[0].x = pthis->actor.world.pos.x + blureEffectVertices1[pthis->actor.params].z * actorRotYSin + + blureEffectVertices1[pthis->actor.params].x * actorRotYCos; + scytheVertices[0].y = pthis->actor.world.pos.y + blureEffectVertices1[pthis->actor.params].y; + scytheVertices[0].z = pthis->actor.world.pos.z + blureEffectVertices1[pthis->actor.params].z * actorRotYCos - + blureEffectVertices1[pthis->actor.params].x * actorRotYSin; + scytheVertices[1].x = pthis->actor.world.pos.x + blureEffectVertices2[pthis->actor.params].z * actorRotYSin + + blureEffectVertices2[pthis->actor.params].x * actorRotYCos; + scytheVertices[1].y = pthis->actor.world.pos.y + blureEffectVertices2[pthis->actor.params].y; + scytheVertices[1].z = pthis->actor.world.pos.z + blureEffectVertices2[pthis->actor.params].z * actorRotYCos - + blureEffectVertices2[pthis->actor.params].x * actorRotYSin; + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureEffectIndex[0]), &scytheVertices[0], &scytheVertices[1]); for (j = 0; j < 2; j++) { - scytheVertices[j].x = (2 * this->actor.world.pos.x) - scytheVertices[j].x; - scytheVertices[j].z = (2 * this->actor.world.pos.z) - scytheVertices[j].z; + scytheVertices[j].x = (2 * pthis->actor.world.pos.x) - scytheVertices[j].x; + scytheVertices[j].z = (2 * pthis->actor.world.pos.z) - scytheVertices[j].z; } - EffectBlure_AddVertex(Effect_GetByIndex(this->blureEffectIndex[1]), &scytheVertices[0], &scytheVertices[1]); + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureEffectIndex[1]), &scytheVertices[0], &scytheVertices[1]); } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderScythe.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderScytheCenter.base); - func_8002F974(&this->actor, NA_SE_EV_ROLLCUTTER_MOTOR - SFX_FLAG); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderScythe.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderScytheCenter.base); + func_8002F974(&pthis->actor, NA_SE_EV_ROLLCUTTER_MOTOR - SFX_FLAG); } void BgHakaSgami_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaSgami* this = (BgHakaSgami*)thisx; + BgHakaSgami* pthis = (BgHakaSgami*)thisx; Player* player = GET_PLAYER(globalCtx); - if (!(player->stateFlags1 & 0x300000C0) || (this->actionFunc == BgHakaSgami_SetupSpin)) { - this->actionFunc(this, globalCtx); + if (!(player->stateFlags1 & 0x300000C0) || (pthis->actionFunc == BgHakaSgami_SetupSpin)) { + pthis->actionFunc(pthis, globalCtx); } } void BgHakaSgami_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHakaSgami* this = (BgHakaSgami*)thisx; + BgHakaSgami* pthis = (BgHakaSgami*)thisx; - if (this->unk_151 != 0) { + if (pthis->unk_151 != 0) { Gfx_DrawDListXlu(globalCtx, object_haka_objects_DL_00BF20); - } else if (this->actor.params == SCYTHE_TRAP_SHADOW_TEMPLE) { + } else if (pthis->actor.params == SCYTHE_TRAP_SHADOW_TEMPLE) { Gfx_DrawDListOpa(globalCtx, object_haka_objects_DL_00BF20); } else { Gfx_DrawDListOpa(globalCtx, object_ice_objects_DL_0021F0); diff --git a/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c b/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c deleted file mode 100644 index 3921f8e66..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c +++ /dev/null @@ -1,248 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_SHIP_Z_BG_HAKA_SHIP_C -#include "actor_common.h" -/* - * File: z_bg_haka_ship.c - * Overlay: ovl_Bg_Haka_Ship - * Description: Shadow Temple Ship - */ - -#include "z_bg_haka_ship.h" -#include "objects/object_haka_objects/object_haka_objects.h" -#include "def/code_80043480.h" -#include "def/code_800F7260.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgHakaShip_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaShip_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaShip_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaShip_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgHakaShip_ChildUpdatePosition(BgHakaShip* this, GlobalContext* globalCtx); -void BgHakaShip_WaitForSong(BgHakaShip* this, GlobalContext* globalCtx); -void BgHakaShip_CutsceneStationary(BgHakaShip* this, GlobalContext* globalCtx); -void BgHakaShip_Move(BgHakaShip* this, GlobalContext* globalCtx); -void BgHakaShip_SetupCrash(BgHakaShip* this, GlobalContext* globalCtx); -void BgHakaShip_CrashShake(BgHakaShip* this, GlobalContext* globalCtx); -void BgHakaShip_CrashFall(BgHakaShip* this, GlobalContext* globalCtx); - -const ActorInit Bg_Haka_Ship_InitVars = { - ACTOR_BG_HAKA_SHIP, - ACTORCAT_BG, - FLAGS, - OBJECT_HAKA_OBJECTS, - sizeof(BgHakaShip), - (ActorFunc)BgHakaShip_Init, - (ActorFunc)BgHakaShip_Destroy, - (ActorFunc)BgHakaShip_Update, - (ActorFunc)BgHakaShip_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgHakaShip_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHakaShip* this = (BgHakaShip*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); - this->switchFlag = (thisx->params >> 8) & 0xFF; - this->dyna.actor.params &= 0xFF; - - if (this->dyna.actor.params == 0) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_00E408, &colHeader); - this->counter = 8; - this->actionFunc = BgHakaShip_WaitForSong; - } else { - CollisionHeader_GetVirtual(&object_haka_objects_Col_00ED7C, &colHeader); - this->actionFunc = BgHakaShip_ChildUpdatePosition; - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000; - this->yOffset = 0; - if (this->dyna.actor.params == 0 && - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_HAKA_SHIP, - this->dyna.actor.world.pos.x + -10.0f, this->dyna.actor.world.pos.y + 82.0f, - this->dyna.actor.world.pos.z, 0, 0, 0, 1) == NULL) { - Actor_Kill(&this->dyna.actor); - } -} - -void BgHakaShip_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaShip* this = (BgHakaShip*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Audio_StopSfxByPos(&this->bellSoundPos); -} - -void BgHakaShip_ChildUpdatePosition(BgHakaShip* this, GlobalContext* globalCtx) { - Actor* parent = this->dyna.actor.parent; - - if (parent != NULL && parent->update != NULL) { - this->dyna.actor.world.pos.x = parent->world.pos.x + -10.0f; - this->dyna.actor.world.pos.y = parent->world.pos.y + 82.0f; - this->dyna.actor.world.pos.z = parent->world.pos.z; - } else { - this->dyna.actor.parent = NULL; - } -} - -void BgHakaShip_WaitForSong(BgHakaShip* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - if (this->counter) { - this->counter--; - } - if (this->counter == 0) { - this->counter = 130; - this->actionFunc = BgHakaShip_CutsceneStationary; - osSyncPrintf("シーン 外輪船 ... アァクション!!\n"); - OnePointCutscene_Init(globalCtx, 3390, 999, &this->dyna.actor, MAIN_CAM); - } - } -} - -void BgHakaShip_CutsceneStationary(BgHakaShip* this, GlobalContext* globalCtx) { - if (this->counter) { - this->counter--; - } - this->yOffset = sinf(this->counter * (M_PI / 25)) * 6144.0f; - if (this->counter == 0) { - this->counter = 50; - this->actionFunc = BgHakaShip_Move; - } -} - -void BgHakaShip_Move(BgHakaShip* this, GlobalContext* globalCtx) { - f32 distanceFromHome; - Actor* child; - - if (this->counter) { - this->counter--; - } - if (this->counter == 0) { - this->counter = 50; - } - this->dyna.actor.world.pos.y = (sinf(this->counter * (M_PI / 25)) * 50.0f) + this->dyna.actor.home.pos.y; - - distanceFromHome = this->dyna.actor.home.pos.x - this->dyna.actor.world.pos.x; - if (distanceFromHome > 7650.0f) { - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - 7650.0f; - this->dyna.actor.speedXZ = 0.0f; - } - if (distanceFromHome > 7600.0f && !Gameplay_InCsMode(globalCtx)) { - this->counter = 40; - this->dyna.actor.speedXZ = 0.0f; - Message_StartTextbox(globalCtx, 0x5071, NULL); - this->actionFunc = BgHakaShip_SetupCrash; - } else { - Math_StepToF(&this->dyna.actor.speedXZ, 4.0f, 0.2f); - } - child = this->dyna.actor.child; - if (child != NULL && child->update != NULL) { - child->shape.rot.z += ((655.0f / 13.0f) * this->dyna.actor.speedXZ); - } else { - this->dyna.actor.child = NULL; - } - this->yOffset = sinf(this->counter * (M_PI / 25)) * 6144.0f; -} - -void BgHakaShip_SetupCrash(BgHakaShip* this, GlobalContext* globalCtx) { - if (this->counter) { - this->counter--; - } - if (this->counter == 0) { - this->counter = 40; - this->actionFunc = BgHakaShip_CrashShake; - } - Math_ScaledStepToS(&this->yOffset, 0, 128); -} - -void BgHakaShip_CrashShake(BgHakaShip* this, GlobalContext* globalCtx) { - if (this->counter != 0) { - this->counter--; - } - this->dyna.actor.world.pos.y = this->counter % 4 * 3 - 6 + this->dyna.actor.home.pos.y; - if (!this->counter) { - this->dyna.actor.gravity = -1.0f; - this->actionFunc = BgHakaShip_CrashFall; - } - func_8002F974(&this->dyna.actor, NA_SE_EV_BLOCKSINK - SFX_FLAG); -} - -void BgHakaShip_CrashFall(BgHakaShip* this, GlobalContext* globalCtx) { - Actor* child; - - if (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y > 2000.0f) { - Actor_Kill(&this->dyna.actor); - child = this->dyna.actor.child; - if (child != NULL && child->update != NULL) { - Actor_Kill(child); - } - } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCKSINK - SFX_FLAG); - if ((this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y > 500.0f) && func_8004356C(&this->dyna)) { - Gameplay_TriggerVoidOut(globalCtx); - } - } -} - -void BgHakaShip_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaShip* this = (BgHakaShip*)thisx; - - this->actionFunc(this, globalCtx); - if (this->dyna.actor.params == 0) { - Actor_MoveForward(&this->dyna.actor); - } -} - -void BgHakaShip_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHakaShip* this = (BgHakaShip*)thisx; - f32 angleTemp; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 528); - func_80093D18(globalCtx->state.gfxCtx); - if (this->dyna.actor.params == 0) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 534), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00D330); - angleTemp = this->yOffset * (M_PI / 0x8000); - Matrix_Translate(-3670.0f, 620.0f, 1150.0f, MTXMODE_APPLY); - Matrix_RotateZ(angleTemp, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 547), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_005A70); - Matrix_Translate(0.0f, 0.0f, -2300.0f, MTXMODE_APPLY); - Matrix_RotateZ(-(2.0f * angleTemp), MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 556), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_005A70); - } else { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 562), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00E910); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 568); - if (this->actionFunc == BgHakaShip_CutsceneStationary || this->actionFunc == BgHakaShip_Move) { - s32 pad; - Vec3f sp2C; - - sp2C.x = this->dyna.actor.world.pos.x + -367.0f; - sp2C.y = this->dyna.actor.world.pos.y + 62.0f; - sp2C.z = this->dyna.actor.world.pos.z; - - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp2C, &this->bellSoundPos); - func_80078914(&this->bellSoundPos, NA_SE_EV_SHIP_BELL - SFX_FLAG); - } -} diff --git a/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.cpp b/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.cpp new file mode 100644 index 000000000..251956ddc --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.cpp @@ -0,0 +1,248 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_SHIP_Z_BG_HAKA_SHIP_C +#include "actor_common.h" +/* + * File: z_bg_haka_ship.c + * Overlay: ovl_Bg_Haka_Ship + * Description: Shadow Temple Ship + */ + +#include "z_bg_haka_ship.h" +#include "objects/object_haka_objects/object_haka_objects.h" +#include "def/code_80043480.h" +#include "def/code_800F7260.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgHakaShip_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHakaShip_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHakaShip_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakaShip_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakaShip_ChildUpdatePosition(BgHakaShip* pthis, GlobalContext* globalCtx); +void BgHakaShip_WaitForSong(BgHakaShip* pthis, GlobalContext* globalCtx); +void BgHakaShip_CutsceneStationary(BgHakaShip* pthis, GlobalContext* globalCtx); +void BgHakaShip_Move(BgHakaShip* pthis, GlobalContext* globalCtx); +void BgHakaShip_SetupCrash(BgHakaShip* pthis, GlobalContext* globalCtx); +void BgHakaShip_CrashShake(BgHakaShip* pthis, GlobalContext* globalCtx); +void BgHakaShip_CrashFall(BgHakaShip* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Haka_Ship_InitVars = { + ACTOR_BG_HAKA_SHIP, + ACTORCAT_BG, + FLAGS, + OBJECT_HAKA_OBJECTS, + sizeof(BgHakaShip), + (ActorFunc)BgHakaShip_Init, + (ActorFunc)BgHakaShip_Destroy, + (ActorFunc)BgHakaShip_Update, + (ActorFunc)BgHakaShip_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgHakaShip_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHakaShip* pthis = (BgHakaShip*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, 1); + pthis->switchFlag = (thisx->params >> 8) & 0xFF; + pthis->dyna.actor.params &= 0xFF; + + if (pthis->dyna.actor.params == 0) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_00E408, &colHeader); + pthis->counter = 8; + pthis->actionFunc = BgHakaShip_WaitForSong; + } else { + CollisionHeader_GetVirtual(&object_haka_objects_Col_00ED7C, &colHeader); + pthis->actionFunc = BgHakaShip_ChildUpdatePosition; + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.shape.rot.y - 0x4000; + pthis->yOffset = 0; + if (pthis->dyna.actor.params == 0 && + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_HAKA_SHIP, + pthis->dyna.actor.world.pos.x + -10.0f, pthis->dyna.actor.world.pos.y + 82.0f, + pthis->dyna.actor.world.pos.z, 0, 0, 0, 1) == NULL) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgHakaShip_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaShip* pthis = (BgHakaShip*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Audio_StopSfxByPos(&pthis->bellSoundPos); +} + +void BgHakaShip_ChildUpdatePosition(BgHakaShip* pthis, GlobalContext* globalCtx) { + Actor* parent = pthis->dyna.actor.parent; + + if (parent != NULL && parent->update != NULL) { + pthis->dyna.actor.world.pos.x = parent->world.pos.x + -10.0f; + pthis->dyna.actor.world.pos.y = parent->world.pos.y + 82.0f; + pthis->dyna.actor.world.pos.z = parent->world.pos.z; + } else { + pthis->dyna.actor.parent = NULL; + } +} + +void BgHakaShip_WaitForSong(BgHakaShip* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if (pthis->counter) { + pthis->counter--; + } + if (pthis->counter == 0) { + pthis->counter = 130; + pthis->actionFunc = BgHakaShip_CutsceneStationary; + osSyncPrintf("シーン 外輪船 ... アァクション!!\n"); + OnePointCutscene_Init(globalCtx, 3390, 999, &pthis->dyna.actor, MAIN_CAM); + } + } +} + +void BgHakaShip_CutsceneStationary(BgHakaShip* pthis, GlobalContext* globalCtx) { + if (pthis->counter) { + pthis->counter--; + } + pthis->yOffset = sinf(pthis->counter * (M_PI / 25)) * 6144.0f; + if (pthis->counter == 0) { + pthis->counter = 50; + pthis->actionFunc = BgHakaShip_Move; + } +} + +void BgHakaShip_Move(BgHakaShip* pthis, GlobalContext* globalCtx) { + f32 distanceFromHome; + Actor* child; + + if (pthis->counter) { + pthis->counter--; + } + if (pthis->counter == 0) { + pthis->counter = 50; + } + pthis->dyna.actor.world.pos.y = (sinf(pthis->counter * (M_PI / 25)) * 50.0f) + pthis->dyna.actor.home.pos.y; + + distanceFromHome = pthis->dyna.actor.home.pos.x - pthis->dyna.actor.world.pos.x; + if (distanceFromHome > 7650.0f) { + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x - 7650.0f; + pthis->dyna.actor.speedXZ = 0.0f; + } + if (distanceFromHome > 7600.0f && !Gameplay_InCsMode(globalCtx)) { + pthis->counter = 40; + pthis->dyna.actor.speedXZ = 0.0f; + Message_StartTextbox(globalCtx, 0x5071, NULL); + pthis->actionFunc = BgHakaShip_SetupCrash; + } else { + Math_StepToF(&pthis->dyna.actor.speedXZ, 4.0f, 0.2f); + } + child = pthis->dyna.actor.child; + if (child != NULL && child->update != NULL) { + child->shape.rot.z += ((655.0f / 13.0f) * pthis->dyna.actor.speedXZ); + } else { + pthis->dyna.actor.child = NULL; + } + pthis->yOffset = sinf(pthis->counter * (M_PI / 25)) * 6144.0f; +} + +void BgHakaShip_SetupCrash(BgHakaShip* pthis, GlobalContext* globalCtx) { + if (pthis->counter) { + pthis->counter--; + } + if (pthis->counter == 0) { + pthis->counter = 40; + pthis->actionFunc = BgHakaShip_CrashShake; + } + Math_ScaledStepToS(&pthis->yOffset, 0, 128); +} + +void BgHakaShip_CrashShake(BgHakaShip* pthis, GlobalContext* globalCtx) { + if (pthis->counter != 0) { + pthis->counter--; + } + pthis->dyna.actor.world.pos.y = pthis->counter % 4 * 3 - 6 + pthis->dyna.actor.home.pos.y; + if (!pthis->counter) { + pthis->dyna.actor.gravity = -1.0f; + pthis->actionFunc = BgHakaShip_CrashFall; + } + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BLOCKSINK - SFX_FLAG); +} + +void BgHakaShip_CrashFall(BgHakaShip* pthis, GlobalContext* globalCtx) { + Actor* child; + + if (pthis->dyna.actor.home.pos.y - pthis->dyna.actor.world.pos.y > 2000.0f) { + Actor_Kill(&pthis->dyna.actor); + child = pthis->dyna.actor.child; + if (child != NULL && child->update != NULL) { + Actor_Kill(child); + } + } else { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCKSINK - SFX_FLAG); + if ((pthis->dyna.actor.home.pos.y - pthis->dyna.actor.world.pos.y > 500.0f) && func_8004356C(&pthis->dyna)) { + Gameplay_TriggerVoidOut(globalCtx); + } + } +} + +void BgHakaShip_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaShip* pthis = (BgHakaShip*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (pthis->dyna.actor.params == 0) { + Actor_MoveForward(&pthis->dyna.actor); + } +} + +void BgHakaShip_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHakaShip* pthis = (BgHakaShip*)thisx; + f32 angleTemp; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 528); + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->dyna.actor.params == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 534), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00D330); + angleTemp = pthis->yOffset * (M_PI / 0x8000); + Matrix_Translate(-3670.0f, 620.0f, 1150.0f, MTXMODE_APPLY); + Matrix_RotateZ(angleTemp, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 547), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_005A70); + Matrix_Translate(0.0f, 0.0f, -2300.0f, MTXMODE_APPLY); + Matrix_RotateZ(-(2.0f * angleTemp), MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 556), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_005A70); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 562), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00E910); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 568); + if (pthis->actionFunc == BgHakaShip_CutsceneStationary || pthis->actionFunc == BgHakaShip_Move) { + s32 pad; + Vec3f sp2C; + + sp2C.x = pthis->dyna.actor.world.pos.x + -367.0f; + sp2C.y = pthis->dyna.actor.world.pos.y + 62.0f; + sp2C.z = pthis->dyna.actor.world.pos.z; + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp2C, &pthis->bellSoundPos); + func_80078914(&pthis->bellSoundPos, NA_SE_EV_SHIP_BELL - SFX_FLAG); + } +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c deleted file mode 100644 index 039603442..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c +++ /dev/null @@ -1,564 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_TRAP_Z_BG_HAKA_TRAP_C -#include "actor_common.h" -/* - * File: z_bg_haka_trap.c - * Overlay: ovl_Bg_Haka_Trap - * Description: Shadow Temple Objects - */ - -#include "z_bg_haka_trap.h" -#include "objects/object_haka_objects/object_haka_objects.h" -#include "def/code_80043480.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_eff_ss_dead.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_skin_matrix.h" - -#define FLAGS 0 - -void BgHakaTrap_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTrap_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTrap_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8087FFC0(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808801B8(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808802D8(BgHakaTrap* this, GlobalContext* globalCtx); -void func_80880484(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808805C0(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808806BC(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808808F4(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808809B0(BgHakaTrap* this, GlobalContext* globalCtx); -void func_808809E4(BgHakaTrap* this, GlobalContext* globalCtx, s16 arg2); -void func_80880AE8(BgHakaTrap* this, GlobalContext* globalCtx); -void func_80880C0C(BgHakaTrap* this, GlobalContext* globalCtx); -void func_80880D68(BgHakaTrap* this); - -static UNK_TYPE D_80880F30 = 0; - -const ActorInit Bg_Haka_Trap_InitVars = { - ACTOR_BG_HAKA_TRAP, - ACTORCAT_BG, - FLAGS, - OBJECT_HAKA_OBJECTS, - sizeof(BgHakaTrap), - (ActorFunc)BgHakaTrap_Init, - (ActorFunc)BgHakaTrap_Destroy, - (ActorFunc)BgHakaTrap_Update, - (ActorFunc)BgHakaTrap_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_METAL, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 30, 90, 0, { 0, 0, 0 } }, -}; - -static ColliderTrisElementInit sTrisElementsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00020000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 1800.0f, 1200.0f, 0.0f }, { -1800.0f, 1200.0f, 0.0f }, { -1800.0f, 0.0f, 0.0f } } }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00020000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 1800.0f, 1200.0f, 0.0f }, { -1800.0f, 0.0f, 0.0f }, { 1800.0f, 0.0f, 0.0f } } }, - }, -}; - -static ColliderTrisInit sTrisInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_TRIS, - }, - 2, - sTrisElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0, 80, 100, MASS_IMMOVABLE }; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgHakaTrap_Init(Actor* thisx, GlobalContext* globalCtx) { - static UNK_TYPE D_80881014 = 0; - BgHakaTrap* this = (BgHakaTrap*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(thisx, sInitChain); - thisx->params &= 0xFF; - - if (thisx->params != HAKA_TRAP_PROPELLER) { - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, thisx, &sCylinderInit); - - if ((thisx->params == HAKA_TRAP_GUILLOTINE_SLOW) || (thisx->params == HAKA_TRAP_GUILLOTINE_FAST)) { - this->timer = 20; - this->colliderCylinder.dim.yShift = 10; - thisx->velocity.y = 0.1f; - - if (thisx->params == HAKA_TRAP_GUILLOTINE_FAST) { - thisx->params = HAKA_TRAP_GUILLOTINE_SLOW; - this->unk_16A = 1; - } - - this->actionFunc = func_80880484; - } else { - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - thisx->flags |= ACTOR_FLAG_4; - - if (thisx->params == HAKA_TRAP_SPIKED_BOX) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_009CD0, &colHeader); - this->timer = 30; - - if (D_80881014 != 0) { - this->actionFunc = func_808808F4; - D_80881014 = 0; - } else { - D_80881014 = 1; - this->actionFunc = func_808806BC; - thisx->velocity.y = 0.5f; - } - - thisx->floorHeight = thisx->home.pos.y - 225.0f; - this->unk_16A = (thisx->floorHeight + 50.0f) - 25.0f; - - this->colliderCylinder.dim.radius = 10; - this->colliderCylinder.dim.height = 40; - } else { - if (thisx->params == HAKA_TRAP_SPIKED_WALL) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_0081D0, &colHeader); - thisx->home.pos.x -= 200.0f; - } else { - thisx->home.pos.x += 200.0f; - CollisionHeader_GetVirtual(&object_haka_objects_Col_008D10, &colHeader); - } - - Collider_InitTris(globalCtx, &this->colliderSpikes); - Collider_SetTris(globalCtx, &this->colliderSpikes, thisx, &sTrisInit, this->colliderSpikesItem); - - this->colliderCylinder.dim.radius = 18; - this->colliderCylinder.dim.height = 115; - - this->colliderCylinder.info.toucherFlags = this->colliderCylinder.info.toucherFlags; - this->colliderCylinder.info.toucherFlags |= TOUCH_SFX_WOOD; - - this->actionFunc = func_808801B8; - } - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - } - } else { - this->timer = 40; - this->actionFunc = func_808809B0; - thisx->uncullZoneScale = 500.0f; - } - - CollisionCheck_SetInfo(&thisx->colChkInfo, 0, &sColChkInfoInit); -} - -void BgHakaTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaTrap* this = (BgHakaTrap*)thisx; - - if (this->dyna.actor.params != HAKA_TRAP_PROPELLER) { - if (this->dyna.actor.params != HAKA_TRAP_GUILLOTINE_SLOW) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if ((this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL) || - (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_2)) { - Collider_DestroyTris(globalCtx, &this->colliderSpikes); - } - } - - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - } - - Audio_StopSfxByPos(&this->unk_16C); -} - -void func_8087FFC0(BgHakaTrap* this, GlobalContext* globalCtx) { - f32 cosine; - Vec3f sp28; - f32 sine; - f32 zNonNegative; - Player* player = GET_PLAYER(globalCtx); - - func_8002DBD0(&this->dyna.actor, &sp28, &player->actor.world.pos); - - sine = Math_SinS(this->dyna.actor.shape.rot.y); - cosine = Math_CosS(this->dyna.actor.shape.rot.y); - if (this->dyna.actor.params == HAKA_TRAP_GUILLOTINE_SLOW) { - sp28.x = CLAMP(sp28.x, -50.0f, 50.0f); - zNonNegative = (sp28.z >= 0.0f) ? 1.0f : -1.0f; - sp28.z = zNonNegative * -15.0f; - } else { - sp28.x = -CLAMP(sp28.x, -162.0f, 162.0f); - zNonNegative = (sp28.z >= 0.0f) ? 1.0f : -1.0f; - sp28.z = zNonNegative * 15.0f; - } - - this->colliderCylinder.dim.pos.x = this->dyna.actor.world.pos.x + sp28.x * cosine + sp28.z * sine; - this->colliderCylinder.dim.pos.z = this->dyna.actor.world.pos.z + sp28.x * sine + sp28.z * cosine; -} - -void func_808801B8(BgHakaTrap* this, GlobalContext* globalCtx) { - static UNK_TYPE D_80881018 = 0; - Player* player = GET_PLAYER(globalCtx); - - if ((D_80880F30 == 0) && (!Player_InCsMode(globalCtx))) { - if (!Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x, 0.5f)) { - func_8002F974(&this->dyna.actor, NA_SE_EV_TRAP_OBJ_SLIDE - SFX_FLAG); - } else if (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL) { - D_80881018 |= 1; - } else if (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_2) { - D_80881018 |= 2; - } - } - - func_8087FFC0(this, globalCtx); - - if (this->colliderSpikes.base.acFlags & AC_HIT) { - this->timer = 20; - D_80880F30 = 1; - this->actionFunc = func_808802D8; - } else if (D_80881018 == 3) { - D_80881018 = 4; - player->actor.bgCheckFlags |= 0x100; - } -} - -void func_808802D8(BgHakaTrap* this, GlobalContext* globalCtx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f vector; - f32 xScale; - s32 i; - - if (this->timer != 0) { - this->timer--; - } - - func_8002F974(&this->dyna.actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - - for (i = 0; i < 2; i++) { - f32 rand = Rand_ZeroOne(); - - xScale = (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL) ? -30.0f : 30.0f; - - vector.x = xScale * rand + this->dyna.actor.world.pos.x; - vector.y = Rand_ZeroOne() * 10.0f + this->dyna.actor.world.pos.y + 30.0f; - vector.z = Rand_CenteredFloat(320.0f) + this->dyna.actor.world.pos.z; - - EffectSsDeadDb_Spawn(globalCtx, &vector, &zeroVec, &zeroVec, 130, 20, 255, 255, 150, 170, 255, 0, 0, 1, 9, - false); - } - - if (this->timer == 0) { - D_80880F30 = 0; - Actor_Kill(&this->dyna.actor); - } -} - -void func_80880484(BgHakaTrap* this, GlobalContext* globalCtx) { - s32 sp24; - s32 timer; - - if (this->unk_16A) { - this->dyna.actor.velocity.y *= 3.0f; - } else { - this->dyna.actor.velocity.y *= 2.0f; - } - - if (this->timer != 0) { - this->timer -= 1; - } - - sp24 = - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 185.0f, this->dyna.actor.velocity.y); - timer = this->timer; - - if ((timer == 10 && !this->unk_16A) || (timer == 13 && this->unk_16A)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_GUILLOTINE_BOUND); - } - - if (this->timer == 0) { - this->dyna.actor.velocity.y = 0.0f; - this->timer = (this->unk_16A) ? 10 : 40; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_GUILLOTINE_UP); - this->actionFunc = func_808805C0; - } - - func_8087FFC0(this, globalCtx); - - if (sp24 == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - } -} - -void func_808805C0(BgHakaTrap* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->unk_16A) { - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 27.0f); - } else { - if (this->timer > 20) { - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 90.0f, 9.0f); - } else { - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.5f); - } - - if (this->timer == 20) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_GUILLOTINE_UP); - } - } - - if (this->timer == 0) { - this->timer = 20; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - this->dyna.actor.velocity.y = 0.1f; - this->actionFunc = func_80880484; - } - - func_8087FFC0(this, globalCtx); -} - -void func_808806BC(BgHakaTrap* this, GlobalContext* globalCtx) { - Vec3f vector; - f32 tempf20; - f32 temp; - s32 i; - s32 sp64; - - this->dyna.actor.velocity.y *= 1.6f; - - if (this->timer != 0) { - this->timer--; - } - - vector.x = this->dyna.actor.world.pos.x + 90.0f; - vector.y = (this->dyna.actor.world.pos.y + 1.0f) + 25.0f; - vector.z = this->dyna.actor.world.pos.z; - - tempf20 = this->dyna.actor.floorHeight; - - for (i = 0; i < 3; i++) { - temp = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp64, &this->dyna.actor, - &vector) - - 25.0f; - if (tempf20 < temp) { - tempf20 = temp; - } - - vector.x -= 90.0f; - } - - if (Math_StepToF(&this->dyna.actor.world.pos.y, tempf20, this->dyna.actor.velocity.y)) { - if (this->dyna.actor.velocity.y > 0.01f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_TRAP_BOUND); - } - this->dyna.actor.velocity.y = 0.0f; - } - - if (this->dyna.actor.velocity.y >= 0.01f) { - func_8002F974(&this->dyna.actor, NA_SE_EV_CHINETRAP_DOWN - SFX_FLAG); - } - - if (this->timer == 0) { - this->dyna.actor.velocity.y = 0.0f; - this->timer = 30; - this->unk_16A = (s16)this->dyna.actor.world.pos.y + 50.0f; - this->unk_16A = CLAMP_MAX(this->unk_16A, this->dyna.actor.home.pos.y); - - this->actionFunc = func_808808F4; - } -} - -void func_808808F4(BgHakaTrap* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer > 20) { - this->unk_169 = Math_StepToF(&this->dyna.actor.world.pos.y, this->unk_16A, 15.0f); - } else { - this->unk_169 = Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 20.0f); - } - - if (this->timer == 0) { - this->timer = 30; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - this->dyna.actor.velocity.y = 0.5f; - this->actionFunc = func_808806BC; - } -} - -void func_808809B0(BgHakaTrap* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer -= 1; - } - - if (this->timer == 0) { - this->actionFunc = func_80880AE8; - } -} - -void func_808809E4(BgHakaTrap* this, GlobalContext* globalCtx, s16 arg2) { - Player* player = GET_PLAYER(globalCtx); - Vec3f sp18; - - func_8002DBD0(&this->dyna.actor, &sp18, &player->actor.world.pos); - - if ((fabsf(sp18.x) < 70.0f) && (fabsf(sp18.y) < 100.0f) && (sp18.z < 500.0f) && - (GET_PLAYER(globalCtx)->currentBoots != PLAYER_BOOTS_IRON)) { - player->windSpeed = ((500.0f - sp18.z) * 0.06f + 5.0f) * arg2 * (1.0f / 0x3A00) * (2.0f / 3.0f); - player->windDirection = this->dyna.actor.shape.rot.y; - } -} - -void func_80880AE8(BgHakaTrap* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - if (Math_ScaledStepToS(&this->dyna.actor.world.rot.z, 0, this->dyna.actor.world.rot.z * 0.03f + 5.0f)) { - this->timer = 40; - this->actionFunc = func_808809B0; - } - } else { - if (Math_ScaledStepToS(&this->dyna.actor.world.rot.z, 0x3A00, this->dyna.actor.world.rot.z * 0.03f + 5.0f)) { - this->timer = 100; - this->actionFunc = func_80880C0C; - } - } - - this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z; - if (this->dyna.actor.world.rot.z >= 0x1801) { - func_8002F974(&this->dyna.actor, NA_SE_EV_WIND_TRAP - SFX_FLAG); - } - - func_808809E4(this, globalCtx, this->dyna.actor.world.rot.z); -} - -void func_80880C0C(BgHakaTrap* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - func_8002F974(&this->dyna.actor, NA_SE_EV_WIND_TRAP - SFX_FLAG); - - if (this->timer == 0) { - this->timer = 1; - this->actionFunc = func_80880AE8; - } - - this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z; - func_808809E4(this, globalCtx, this->dyna.actor.world.rot.z); -} - -void BgHakaTrap_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaTrap* this = (BgHakaTrap*)thisx; - Vec3f* actorPos = &this->dyna.actor.world.pos; - - this->actionFunc(this, globalCtx); - - if ((this->dyna.actor.params != HAKA_TRAP_PROPELLER) && (thisx->params != HAKA_TRAP_SPIKED_BOX)) { - this->colliderCylinder.dim.pos.y = actorPos->y; - - if ((thisx->params == HAKA_TRAP_GUILLOTINE_SLOW) || (thisx->params == HAKA_TRAP_GUILLOTINE_FAST)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - } else { - if (this->actionFunc == func_808801B8) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSpikes.base); - } - - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - } - } -} - -void func_80880D68(BgHakaTrap* this) { - Vec3f vec3; - Vec3f vec2; - Vec3f vec1; - - Matrix_MultVec3f(&sTrisElementsInit[0].dim.vtx[0], &vec1); - Matrix_MultVec3f(&sTrisElementsInit[0].dim.vtx[1], &vec2); - Matrix_MultVec3f(&sTrisElementsInit[0].dim.vtx[2], &vec3); - Collider_SetTrisVertices(&this->colliderSpikes, 0, &vec1, &vec2, &vec3); - - Matrix_MultVec3f(&sTrisElementsInit[1].dim.vtx[2], &vec2); - Collider_SetTrisVertices(&this->colliderSpikes, 1, &vec1, &vec3, &vec2); -} - -void BgHakaTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Gfx* sDLists[5] = { - object_haka_objects_DL_007610, object_haka_objects_DL_009860, object_haka_objects_DL_007EF0, - object_haka_objects_DL_008A20, object_haka_objects_DL_0072C0, - }; - static Color_RGBA8 D_8088103C = { 0, 0, 0, 0 }; - BgHakaTrap* this = (BgHakaTrap*)thisx; - s32 pad; - Vec3f sp2C; - - if (this->actionFunc == func_808802D8) { - func_80026230(globalCtx, &D_8088103C, this->timer + 20, 0x28); - } - - Gfx_DrawDListOpa(globalCtx, sDLists[this->dyna.actor.params]); - - if (this->actionFunc == func_808801B8) { - func_80880D68(this); - } - - if (this->actionFunc == func_808802D8) { - func_80026608(globalCtx); - } - - if ((this->actionFunc == func_808808F4) && !this->unk_169) { - sp2C.x = this->dyna.actor.world.pos.x; - sp2C.z = this->dyna.actor.world.pos.z; - sp2C.y = this->dyna.actor.world.pos.y + 110.0f; - - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp2C, &this->unk_16C); - func_80078914(&this->unk_16C, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); - } -} diff --git a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.cpp b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.cpp new file mode 100644 index 000000000..82b2eece6 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.cpp @@ -0,0 +1,564 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_TRAP_Z_BG_HAKA_TRAP_C +#include "actor_common.h" +/* + * File: z_bg_haka_trap.c + * Overlay: ovl_Bg_Haka_Trap + * Description: Shadow Temple Objects + */ + +#include "z_bg_haka_trap.h" +#include "objects/object_haka_objects/object_haka_objects.h" +#include "def/code_80043480.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_eff_ss_dead.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_skin_matrix.h" + +#define FLAGS 0 + +void BgHakaTrap_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHakaTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHakaTrap_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakaTrap_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8087FFC0(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808801B8(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808802D8(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_80880484(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808805C0(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808806BC(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808808F4(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808809B0(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_808809E4(BgHakaTrap* pthis, GlobalContext* globalCtx, s16 arg2); +void func_80880AE8(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_80880C0C(BgHakaTrap* pthis, GlobalContext* globalCtx); +void func_80880D68(BgHakaTrap* pthis); + +static UNK_TYPE D_80880F30 = 0; + +ActorInit Bg_Haka_Trap_InitVars = { + ACTOR_BG_HAKA_TRAP, + ACTORCAT_BG, + FLAGS, + OBJECT_HAKA_OBJECTS, + sizeof(BgHakaTrap), + (ActorFunc)BgHakaTrap_Init, + (ActorFunc)BgHakaTrap_Destroy, + (ActorFunc)BgHakaTrap_Update, + (ActorFunc)BgHakaTrap_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 30, 90, 0, { 0, 0, 0 } }, +}; + +static ColliderTrisElementInit sTrisElementsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00020000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 1800.0f, 1200.0f, 0.0f }, { -1800.0f, 1200.0f, 0.0f }, { -1800.0f, 0.0f, 0.0f } } }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00020000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 1800.0f, 1200.0f, 0.0f }, { -1800.0f, 0.0f, 0.0f }, { 1800.0f, 0.0f, 0.0f } } }, + }, +}; + +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 80, 100, MASS_IMMOVABLE }; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgHakaTrap_Init(Actor* thisx, GlobalContext* globalCtx) { + static UNK_TYPE D_80881014 = 0; + BgHakaTrap* pthis = (BgHakaTrap*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(thisx, sInitChain); + thisx->params &= 0xFF; + + if (thisx->params != HAKA_TRAP_PROPELLER) { + Collider_InitCylinder(globalCtx, &pthis->colliderCylinder); + Collider_SetCylinder(globalCtx, &pthis->colliderCylinder, thisx, &sCylinderInit); + + if ((thisx->params == HAKA_TRAP_GUILLOTINE_SLOW) || (thisx->params == HAKA_TRAP_GUILLOTINE_FAST)) { + pthis->timer = 20; + pthis->colliderCylinder.dim.yShift = 10; + thisx->velocity.y = 0.1f; + + if (thisx->params == HAKA_TRAP_GUILLOTINE_FAST) { + thisx->params = HAKA_TRAP_GUILLOTINE_SLOW; + pthis->unk_16A = 1; + } + + pthis->actionFunc = func_80880484; + } else { + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + thisx->flags |= ACTOR_FLAG_4; + + if (thisx->params == HAKA_TRAP_SPIKED_BOX) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_009CD0, &colHeader); + pthis->timer = 30; + + if (D_80881014 != 0) { + pthis->actionFunc = func_808808F4; + D_80881014 = 0; + } else { + D_80881014 = 1; + pthis->actionFunc = func_808806BC; + thisx->velocity.y = 0.5f; + } + + thisx->floorHeight = thisx->home.pos.y - 225.0f; + pthis->unk_16A = (thisx->floorHeight + 50.0f) - 25.0f; + + pthis->colliderCylinder.dim.radius = 10; + pthis->colliderCylinder.dim.height = 40; + } else { + if (thisx->params == HAKA_TRAP_SPIKED_WALL) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_0081D0, &colHeader); + thisx->home.pos.x -= 200.0f; + } else { + thisx->home.pos.x += 200.0f; + CollisionHeader_GetVirtual(&object_haka_objects_Col_008D10, &colHeader); + } + + Collider_InitTris(globalCtx, &pthis->colliderSpikes); + Collider_SetTris(globalCtx, &pthis->colliderSpikes, thisx, &sTrisInit, pthis->colliderSpikesItem); + + pthis->colliderCylinder.dim.radius = 18; + pthis->colliderCylinder.dim.height = 115; + + pthis->colliderCylinder.info.toucherFlags = pthis->colliderCylinder.info.toucherFlags; + pthis->colliderCylinder.info.toucherFlags |= TOUCH_SFX_WOOD; + + pthis->actionFunc = func_808801B8; + } + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + } + } else { + pthis->timer = 40; + pthis->actionFunc = func_808809B0; + thisx->uncullZoneScale = 500.0f; + } + + CollisionCheck_SetInfo(&thisx->colChkInfo, 0, &sColChkInfoInit); +} + +void BgHakaTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaTrap* pthis = (BgHakaTrap*)thisx; + + if (pthis->dyna.actor.params != HAKA_TRAP_PROPELLER) { + if (pthis->dyna.actor.params != HAKA_TRAP_GUILLOTINE_SLOW) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if ((pthis->dyna.actor.params == HAKA_TRAP_SPIKED_WALL) || + (pthis->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_2)) { + Collider_DestroyTris(globalCtx, &pthis->colliderSpikes); + } + } + + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinder); + } + + Audio_StopSfxByPos(&pthis->unk_16C); +} + +void func_8087FFC0(BgHakaTrap* pthis, GlobalContext* globalCtx) { + f32 cosine; + Vec3f sp28; + f32 sine; + f32 zNonNegative; + Player* player = GET_PLAYER(globalCtx); + + func_8002DBD0(&pthis->dyna.actor, &sp28, &player->actor.world.pos); + + sine = Math_SinS(pthis->dyna.actor.shape.rot.y); + cosine = Math_CosS(pthis->dyna.actor.shape.rot.y); + if (pthis->dyna.actor.params == HAKA_TRAP_GUILLOTINE_SLOW) { + sp28.x = CLAMP(sp28.x, -50.0f, 50.0f); + zNonNegative = (sp28.z >= 0.0f) ? 1.0f : -1.0f; + sp28.z = zNonNegative * -15.0f; + } else { + sp28.x = -CLAMP(sp28.x, -162.0f, 162.0f); + zNonNegative = (sp28.z >= 0.0f) ? 1.0f : -1.0f; + sp28.z = zNonNegative * 15.0f; + } + + pthis->colliderCylinder.dim.pos.x = pthis->dyna.actor.world.pos.x + sp28.x * cosine + sp28.z * sine; + pthis->colliderCylinder.dim.pos.z = pthis->dyna.actor.world.pos.z + sp28.x * sine + sp28.z * cosine; +} + +void func_808801B8(BgHakaTrap* pthis, GlobalContext* globalCtx) { + static UNK_TYPE D_80881018 = 0; + Player* player = GET_PLAYER(globalCtx); + + if ((D_80880F30 == 0) && (!Player_InCsMode(globalCtx))) { + if (!Math_StepToF(&pthis->dyna.actor.world.pos.x, pthis->dyna.actor.home.pos.x, 0.5f)) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_TRAP_OBJ_SLIDE - SFX_FLAG); + } else if (pthis->dyna.actor.params == HAKA_TRAP_SPIKED_WALL) { + D_80881018 |= 1; + } else if (pthis->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_2) { + D_80881018 |= 2; + } + } + + func_8087FFC0(pthis, globalCtx); + + if (pthis->colliderSpikes.base.acFlags & AC_HIT) { + pthis->timer = 20; + D_80880F30 = 1; + pthis->actionFunc = func_808802D8; + } else if (D_80881018 == 3) { + D_80881018 = 4; + player->actor.bgCheckFlags |= 0x100; + } +} + +void func_808802D8(BgHakaTrap* pthis, GlobalContext* globalCtx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f vector; + f32 xScale; + s32 i; + + if (pthis->timer != 0) { + pthis->timer--; + } + + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + + for (i = 0; i < 2; i++) { + f32 rand = Rand_ZeroOne(); + + xScale = (pthis->dyna.actor.params == HAKA_TRAP_SPIKED_WALL) ? -30.0f : 30.0f; + + vector.x = xScale * rand + pthis->dyna.actor.world.pos.x; + vector.y = Rand_ZeroOne() * 10.0f + pthis->dyna.actor.world.pos.y + 30.0f; + vector.z = Rand_CenteredFloat(320.0f) + pthis->dyna.actor.world.pos.z; + + EffectSsDeadDb_Spawn(globalCtx, &vector, &zeroVec, &zeroVec, 130, 20, 255, 255, 150, 170, 255, 0, 0, 1, 9, + false); + } + + if (pthis->timer == 0) { + D_80880F30 = 0; + Actor_Kill(&pthis->dyna.actor); + } +} + +void func_80880484(BgHakaTrap* pthis, GlobalContext* globalCtx) { + s32 sp24; + s32 timer; + + if (pthis->unk_16A) { + pthis->dyna.actor.velocity.y *= 3.0f; + } else { + pthis->dyna.actor.velocity.y *= 2.0f; + } + + if (pthis->timer != 0) { + pthis->timer -= 1; + } + + sp24 = + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 185.0f, pthis->dyna.actor.velocity.y); + timer = pthis->timer; + + if ((timer == 10 && !pthis->unk_16A) || (timer == 13 && pthis->unk_16A)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_GUILLOTINE_BOUND); + } + + if (pthis->timer == 0) { + pthis->dyna.actor.velocity.y = 0.0f; + pthis->timer = (pthis->unk_16A) ? 10 : 40; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_GUILLOTINE_UP); + pthis->actionFunc = func_808805C0; + } + + func_8087FFC0(pthis, globalCtx); + + if (sp24 == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); + } +} + +void func_808805C0(BgHakaTrap* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->unk_16A) { + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 27.0f); + } else { + if (pthis->timer > 20) { + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 90.0f, 9.0f); + } else { + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 4.5f); + } + + if (pthis->timer == 20) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_GUILLOTINE_UP); + } + } + + if (pthis->timer == 0) { + pthis->timer = 20; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + pthis->dyna.actor.velocity.y = 0.1f; + pthis->actionFunc = func_80880484; + } + + func_8087FFC0(pthis, globalCtx); +} + +void func_808806BC(BgHakaTrap* pthis, GlobalContext* globalCtx) { + Vec3f vector; + f32 tempf20; + f32 temp; + s32 i; + s32 sp64; + + pthis->dyna.actor.velocity.y *= 1.6f; + + if (pthis->timer != 0) { + pthis->timer--; + } + + vector.x = pthis->dyna.actor.world.pos.x + 90.0f; + vector.y = (pthis->dyna.actor.world.pos.y + 1.0f) + 25.0f; + vector.z = pthis->dyna.actor.world.pos.z; + + tempf20 = pthis->dyna.actor.floorHeight; + + for (i = 0; i < 3; i++) { + temp = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, &sp64, &pthis->dyna.actor, + &vector) - + 25.0f; + if (tempf20 < temp) { + tempf20 = temp; + } + + vector.x -= 90.0f; + } + + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, tempf20, pthis->dyna.actor.velocity.y)) { + if (pthis->dyna.actor.velocity.y > 0.01f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_TRAP_BOUND); + } + pthis->dyna.actor.velocity.y = 0.0f; + } + + if (pthis->dyna.actor.velocity.y >= 0.01f) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_CHINETRAP_DOWN - SFX_FLAG); + } + + if (pthis->timer == 0) { + pthis->dyna.actor.velocity.y = 0.0f; + pthis->timer = 30; + pthis->unk_16A = (s16)pthis->dyna.actor.world.pos.y + 50.0f; + pthis->unk_16A = CLAMP_MAX(pthis->unk_16A, pthis->dyna.actor.home.pos.y); + + pthis->actionFunc = func_808808F4; + } +} + +void func_808808F4(BgHakaTrap* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer > 20) { + pthis->unk_169 = Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->unk_16A, 15.0f); + } else { + pthis->unk_169 = Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 20.0f); + } + + if (pthis->timer == 0) { + pthis->timer = 30; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + pthis->dyna.actor.velocity.y = 0.5f; + pthis->actionFunc = func_808806BC; + } +} + +void func_808809B0(BgHakaTrap* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer -= 1; + } + + if (pthis->timer == 0) { + pthis->actionFunc = func_80880AE8; + } +} + +void func_808809E4(BgHakaTrap* pthis, GlobalContext* globalCtx, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp18; + + func_8002DBD0(&pthis->dyna.actor, &sp18, &player->actor.world.pos); + + if ((fabsf(sp18.x) < 70.0f) && (fabsf(sp18.y) < 100.0f) && (sp18.z < 500.0f) && + (GET_PLAYER(globalCtx)->currentBoots != PLAYER_BOOTS_IRON)) { + player->windSpeed = ((500.0f - sp18.z) * 0.06f + 5.0f) * arg2 * (1.0f / 0x3A00) * (2.0f / 3.0f); + player->windDirection = pthis->dyna.actor.shape.rot.y; + } +} + +void func_80880AE8(BgHakaTrap* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + if (Math_ScaledStepToS(&pthis->dyna.actor.world.rot.z, 0, pthis->dyna.actor.world.rot.z * 0.03f + 5.0f)) { + pthis->timer = 40; + pthis->actionFunc = func_808809B0; + } + } else { + if (Math_ScaledStepToS(&pthis->dyna.actor.world.rot.z, 0x3A00, pthis->dyna.actor.world.rot.z * 0.03f + 5.0f)) { + pthis->timer = 100; + pthis->actionFunc = func_80880C0C; + } + } + + pthis->dyna.actor.shape.rot.z += pthis->dyna.actor.world.rot.z; + if (pthis->dyna.actor.world.rot.z >= 0x1801) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_WIND_TRAP - SFX_FLAG); + } + + func_808809E4(pthis, globalCtx, pthis->dyna.actor.world.rot.z); +} + +void func_80880C0C(BgHakaTrap* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + func_8002F974(&pthis->dyna.actor, NA_SE_EV_WIND_TRAP - SFX_FLAG); + + if (pthis->timer == 0) { + pthis->timer = 1; + pthis->actionFunc = func_80880AE8; + } + + pthis->dyna.actor.shape.rot.z += pthis->dyna.actor.world.rot.z; + func_808809E4(pthis, globalCtx, pthis->dyna.actor.world.rot.z); +} + +void BgHakaTrap_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaTrap* pthis = (BgHakaTrap*)thisx; + Vec3f* actorPos = &pthis->dyna.actor.world.pos; + + pthis->actionFunc(pthis, globalCtx); + + if ((pthis->dyna.actor.params != HAKA_TRAP_PROPELLER) && (thisx->params != HAKA_TRAP_SPIKED_BOX)) { + pthis->colliderCylinder.dim.pos.y = actorPos->y; + + if ((thisx->params == HAKA_TRAP_GUILLOTINE_SLOW) || (thisx->params == HAKA_TRAP_GUILLOTINE_FAST)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); + } else { + if (pthis->actionFunc == func_808801B8) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSpikes.base); + } + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); + } + } +} + +void func_80880D68(BgHakaTrap* pthis) { + Vec3f vec3; + Vec3f vec2; + Vec3f vec1; + + Matrix_MultVec3f(&sTrisElementsInit[0].dim.vtx[0], &vec1); + Matrix_MultVec3f(&sTrisElementsInit[0].dim.vtx[1], &vec2); + Matrix_MultVec3f(&sTrisElementsInit[0].dim.vtx[2], &vec3); + Collider_SetTrisVertices(&pthis->colliderSpikes, 0, &vec1, &vec2, &vec3); + + Matrix_MultVec3f(&sTrisElementsInit[1].dim.vtx[2], &vec2); + Collider_SetTrisVertices(&pthis->colliderSpikes, 1, &vec1, &vec3, &vec2); +} + +void BgHakaTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* sDLists[5] = { + object_haka_objects_DL_007610, object_haka_objects_DL_009860, object_haka_objects_DL_007EF0, + object_haka_objects_DL_008A20, object_haka_objects_DL_0072C0, + }; + static Color_RGBA8 D_8088103C = { 0, 0, 0, 0 }; + BgHakaTrap* pthis = (BgHakaTrap*)thisx; + s32 pad; + Vec3f sp2C; + + if (pthis->actionFunc == func_808802D8) { + func_80026230(globalCtx, &D_8088103C, pthis->timer + 20, 0x28); + } + + Gfx_DrawDListOpa(globalCtx, sDLists[pthis->dyna.actor.params]); + + if (pthis->actionFunc == func_808801B8) { + func_80880D68(pthis); + } + + if (pthis->actionFunc == func_808802D8) { + func_80026608(globalCtx); + } + + if ((pthis->actionFunc == func_808808F4) && !pthis->unk_169) { + sp2C.x = pthis->dyna.actor.world.pos.x; + sp2C.z = pthis->dyna.actor.world.pos.z; + sp2C.y = pthis->dyna.actor.world.pos.y + 110.0f; + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp2C, &pthis->unk_16C); + func_80078914(&pthis->unk_16C, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); + } +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c b/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.cpp similarity index 57% rename from src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c rename to src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.cpp index 2070df8c7..af3695319 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.cpp @@ -29,10 +29,10 @@ void BgHakaTubo_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaTubo_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakaTubo_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTubo_Idle(BgHakaTubo* this, GlobalContext* globalCtx); -void BgHakaTubo_DropCollectible(BgHakaTubo* this, GlobalContext* globalCtx); +void BgHakaTubo_Idle(BgHakaTubo* pthis, GlobalContext* globalCtx); +void BgHakaTubo_DropCollectible(BgHakaTubo* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Haka_Tubo_InitVars = { +ActorInit Bg_Haka_Tubo_InitVars = { ACTOR_BG_HAKA_TUBO, ACTORCAT_BG, FLAGS, @@ -91,86 +91,86 @@ static InitChainEntry sInitChain[] = { }; void BgHakaTubo_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHakaTubo* this = (BgHakaTubo*)thisx; + BgHakaTubo* pthis = (BgHakaTubo*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK3); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK3); CollisionHeader_GetVirtual(&object_haka_objects_Col_0108B8, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Collider_InitCylinder(globalCtx, &this->potCollider); - Collider_SetCylinder(globalCtx, &this->potCollider, &this->dyna.actor, &sPotColliderInit); - Collider_InitCylinder(globalCtx, &this->flamesCollider); - Collider_SetCylinder(globalCtx, &this->flamesCollider, &this->dyna.actor, &sFlamesColliderInit); - this->fireScroll = Rand_ZeroOne() * 15.0f; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Collider_InitCylinder(globalCtx, &pthis->potCollider); + Collider_SetCylinder(globalCtx, &pthis->potCollider, &pthis->dyna.actor, &sPotColliderInit); + Collider_InitCylinder(globalCtx, &pthis->flamesCollider); + Collider_SetCylinder(globalCtx, &pthis->flamesCollider, &pthis->dyna.actor, &sFlamesColliderInit); + pthis->fireScroll = Rand_ZeroOne() * 15.0f; sPotsDestroyed = 0; - this->actionFunc = BgHakaTubo_Idle; + pthis->actionFunc = BgHakaTubo_Idle; } void BgHakaTubo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaTubo* this = (BgHakaTubo*)thisx; + BgHakaTubo* pthis = (BgHakaTubo*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->potCollider); - Collider_DestroyCylinder(globalCtx, &this->flamesCollider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->potCollider); + Collider_DestroyCylinder(globalCtx, &pthis->flamesCollider); } -void BgHakaTubo_Idle(BgHakaTubo* this, GlobalContext* globalCtx) { +void BgHakaTubo_Idle(BgHakaTubo* pthis, GlobalContext* globalCtx) { static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; Vec3f pos; - if (this->dyna.actor.room == 12) { // 3 spinning pots room in Shadow Temple - this->dyna.actor.shape.rot.y += 0x180; - this->dyna.actor.world.pos.x = Math_SinS(this->dyna.actor.shape.rot.y - 0x4000) * 145.0f + -5559.0f; - this->dyna.actor.world.pos.z = Math_CosS(this->dyna.actor.shape.rot.y - 0x4000) * 145.0f + -1587.0f; + if (pthis->dyna.actor.room == 12) { // 3 spinning pots room in Shadow Temple + pthis->dyna.actor.shape.rot.y += 0x180; + pthis->dyna.actor.world.pos.x = Math_SinS(pthis->dyna.actor.shape.rot.y - 0x4000) * 145.0f + -5559.0f; + pthis->dyna.actor.world.pos.z = Math_CosS(pthis->dyna.actor.shape.rot.y - 0x4000) * 145.0f + -1587.0f; } // Colliding with flame circle - if (this->flamesCollider.base.atFlags & AT_HIT) { - this->flamesCollider.base.atFlags &= ~AT_HIT; - func_8002F71C(globalCtx, &this->dyna.actor, 5.0f, this->dyna.actor.yawTowardsPlayer, 5.0f); + if (pthis->flamesCollider.base.atFlags & AT_HIT) { + pthis->flamesCollider.base.atFlags &= ~AT_HIT; + func_8002F71C(globalCtx, &pthis->dyna.actor, 5.0f, pthis->dyna.actor.yawTowardsPlayer, 5.0f); } // Colliding with hitbox inside the pot - if (this->potCollider.base.acFlags & AC_HIT) { - this->potCollider.base.acFlags &= ~AC_HIT; + if (pthis->potCollider.base.acFlags & AC_HIT) { + pthis->potCollider.base.acFlags &= ~AC_HIT; // If the colliding actor is within a 50 unit radius and 50 unit height cylinder centered // on the actor's position, break the pot - if (Actor_WorldDistXZToPoint(&this->dyna.actor, &this->potCollider.base.ac->world.pos) < 50.0f && - (this->potCollider.base.ac->world.pos.y - this->dyna.actor.world.pos.y) < 50.0f) { - pos.x = this->dyna.actor.world.pos.x; - pos.z = this->dyna.actor.world.pos.z; - pos.y = this->dyna.actor.world.pos.y + 80.0f; + if (Actor_WorldDistXZToPoint(&pthis->dyna.actor, &pthis->potCollider.base.ac->world.pos) < 50.0f && + (pthis->potCollider.base.ac->world.pos.y - pthis->dyna.actor.world.pos.y) < 50.0f) { + pos.x = pthis->dyna.actor.world.pos.x; + pos.z = pthis->dyna.actor.world.pos.z; + pos.y = pthis->dyna.actor.world.pos.y + 80.0f; EffectSsBomb2_SpawnLayered(globalCtx, &pos, &sZeroVector, &sZeroVector, 100, 45); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 50, NA_SE_EV_BOX_BREAK); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 50, NA_SE_EV_BOX_BREAK); EffectSsHahen_SpawnBurst(globalCtx, &pos, 20.0f, 0, 350, 100, 50, OBJECT_HAKA_OBJECTS, 40, gEffFragments2DL); - this->dropTimer = 5; - this->dyna.actor.draw = NULL; - Actor_SetScale(&this->dyna.actor, 0.0f); - this->actionFunc = BgHakaTubo_DropCollectible; + pthis->dropTimer = 5; + pthis->dyna.actor.draw = NULL; + Actor_SetScale(&pthis->dyna.actor, 0.0f); + pthis->actionFunc = BgHakaTubo_DropCollectible; } } else { - Collider_UpdateCylinder(&this->dyna.actor, &this->flamesCollider); - Collider_UpdateCylinder(&this->dyna.actor, &this->potCollider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->potCollider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->flamesCollider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->flamesCollider.base); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->flamesCollider); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->potCollider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->potCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->flamesCollider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->flamesCollider.base); } } -void BgHakaTubo_DropCollectible(BgHakaTubo* this, GlobalContext* globalCtx) { +void BgHakaTubo_DropCollectible(BgHakaTubo* pthis, GlobalContext* globalCtx) { EnItem00* collectible; f32 rnd; Vec3f spawnPos; s32 i; s32 collectibleParams; - this->dropTimer--; - if (this->dropTimer == 0) { // Creates a delay between destroying the pot and dropping the collectible - spawnPos.x = this->dyna.actor.world.pos.x; - spawnPos.y = this->dyna.actor.world.pos.y + 200.0f; - spawnPos.z = this->dyna.actor.world.pos.z; - if (this->dyna.actor.room == 12) { // 3 spinning pots room in Shadow Temple + pthis->dropTimer--; + if (pthis->dropTimer == 0) { // Creates a delay between destroying the pot and dropping the collectible + spawnPos.x = pthis->dyna.actor.world.pos.x; + spawnPos.y = pthis->dyna.actor.world.pos.y + 200.0f; + spawnPos.z = pthis->dyna.actor.world.pos.z; + if (pthis->dyna.actor.room == 12) { // 3 spinning pots room in Shadow Temple rnd = Rand_ZeroOne(); sPotsDestroyed++; if (sPotsDestroyed == 3) { @@ -182,15 +182,15 @@ void BgHakaTubo_DropCollectible(BgHakaTubo* this, GlobalContext* globalCtx) { collectible = Item_DropCollectible(globalCtx, &spawnPos, i % 3); if (collectible != NULL) { collectible->actor.velocity.y = 15.0f; - collectible->actor.world.rot.y = this->dyna.actor.shape.rot.y + (i * 0x1C71); + collectible->actor.world.rot.y = pthis->dyna.actor.shape.rot.y + (i * 0x1C71); } } } else if (rnd < 0.2f) { // Unlucky, no reward and spawn keese collectibleParams = -1; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FIREFLY, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + 80.0f, this->dyna.actor.world.pos.z, 0, - this->dyna.actor.shape.rot.y, 0, 2); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FIREFLY, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y + 80.0f, pthis->dyna.actor.world.pos.z, 0, + pthis->dyna.actor.shape.rot.y, 0, 2); func_80078884(NA_SE_SY_ERROR); } else { // Random rewards @@ -205,49 +205,49 @@ void BgHakaTubo_DropCollectible(BgHakaTubo* this, GlobalContext* globalCtx) { } func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } - } else if (Flags_GetCollectible(globalCtx, this->dyna.actor.params) != 0) { + } else if (Flags_GetCollectible(globalCtx, pthis->dyna.actor.params) != 0) { // If small key already collected, drop recovery heart instead collectibleParams = ITEM00_HEART; func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } else { // Drops a small key and sets a collect flag - collectibleParams = ((this->dyna.actor.params & 0x3F) << 8) | ITEM00_SMALL_KEY; + collectibleParams = ((pthis->dyna.actor.params & 0x3F) << 8) | ITEM00_SMALL_KEY; func_80078884(NA_SE_SY_CORRECT_CHIME); } if (collectibleParams != -1) { collectible = Item_DropCollectible(globalCtx, &spawnPos, collectibleParams); if (collectible != NULL) { collectible->actor.velocity.y = 15.0f; - collectible->actor.world.rot.y = this->dyna.actor.shape.rot.y; + collectible->actor.world.rot.y = pthis->dyna.actor.shape.rot.y; } } - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } void BgHakaTubo_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaTubo* this = (BgHakaTubo*)thisx; + BgHakaTubo* pthis = (BgHakaTubo*)thisx; - this->actionFunc(this, globalCtx); - this->fireScroll++; + pthis->actionFunc(pthis, globalCtx); + pthis->fireScroll++; } -void BgHakaTubo_DrawFlameCircle(BgHakaTubo* this, GlobalContext* globalCtx) { +void BgHakaTubo_DrawFlameCircle(BgHakaTubo* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_tubo.c", 476); func_80093D84(globalCtx->state.gfxCtx); - Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 235.0f, this->dyna.actor.world.pos.z, + Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y + 235.0f, pthis->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Scale(0.07f, 0.04f, 0.07f, MTXMODE_APPLY); if (1) {} gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 0, 170, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 255); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->fireScroll & 127, 0, 32, 64, 1, 0, - (this->fireScroll * -15) & 0xFF, 32, 64)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->fireScroll & 127, 0, 32, 64, 1, 0, + (pthis->fireScroll * -15) & 0xFF, 32, 64)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_tubo.c", 497), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFireCircleDL); @@ -256,8 +256,8 @@ void BgHakaTubo_DrawFlameCircle(BgHakaTubo* this, GlobalContext* globalCtx) { } void BgHakaTubo_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHakaTubo* this = (BgHakaTubo*)thisx; + BgHakaTubo* pthis = (BgHakaTubo*)thisx; Gfx_DrawDListOpa(globalCtx, object_haka_objects_DL_00FE40); - BgHakaTubo_DrawFlameCircle(this, globalCtx); + BgHakaTubo_DrawFlameCircle(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Water/z_bg_haka_water.c b/src/overlays/actors/ovl_Bg_Haka_Water/z_bg_haka_water.cpp similarity index 53% rename from src/overlays/actors/ovl_Bg_Haka_Water/z_bg_haka_water.c rename to src/overlays/actors/ovl_Bg_Haka_Water/z_bg_haka_water.cpp index a4133b7bd..3dcaa2566 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Water/z_bg_haka_water.c +++ b/src/overlays/actors/ovl_Bg_Haka_Water/z_bg_haka_water.cpp @@ -20,11 +20,11 @@ void BgHakaWater_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaWater_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakaWater_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgHakaWater_LowerWater(BgHakaWater* this, GlobalContext* globalCtx); -void BgHakaWater_Wait(BgHakaWater* this, GlobalContext* globalCtx); -void BgHakaWater_ChangeWaterLevel(BgHakaWater* this, GlobalContext* globalCtx); +void BgHakaWater_LowerWater(BgHakaWater* pthis, GlobalContext* globalCtx); +void BgHakaWater_Wait(BgHakaWater* pthis, GlobalContext* globalCtx); +void BgHakaWater_ChangeWaterLevel(BgHakaWater* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Haka_Water_InitVars = { +ActorInit Bg_Haka_Water_InitVars = { ACTOR_BG_HAKA_WATER, ACTORCAT_PROP, FLAGS, @@ -41,78 +41,78 @@ static InitChainEntry sInitChain[] = { }; void BgHakaWater_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHakaWater* this = (BgHakaWater*)thisx; + BgHakaWater* pthis = (BgHakaWater*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - this->isLowered = true; - this->actor.home.pos.y -= 200.0f; - this->actor.world.pos.y = this->actor.home.pos.y; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + pthis->isLowered = true; + pthis->actor.home.pos.y -= 200.0f; + pthis->actor.world.pos.y = pthis->actor.home.pos.y; } else { - this->isLowered = false; + pthis->isLowered = false; } - BgHakaWater_LowerWater(this, globalCtx); - this->actionFunc = BgHakaWater_Wait; + BgHakaWater_LowerWater(pthis, globalCtx); + pthis->actionFunc = BgHakaWater_Wait; } void BgHakaWater_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void BgHakaWater_LowerWater(BgHakaWater* this, GlobalContext* globalCtx) { +void BgHakaWater_LowerWater(BgHakaWater* pthis, GlobalContext* globalCtx) { s32 i; for (i = 0; i < 9; i++) { - globalCtx->colCtx.colHeader->waterBoxes[i].ySurface = (s16)this->actor.world.pos.y - 8; + globalCtx->colCtx.colHeader->waterBoxes[i].ySurface = (s16)pthis->actor.world.pos.y - 8; } } -void BgHakaWater_Wait(BgHakaWater* this, GlobalContext* globalCtx) { - if ((!this->isLowered && Flags_GetSwitch(globalCtx, this->actor.params)) || - (this->isLowered && !Flags_GetSwitch(globalCtx, this->actor.params))) { - if (this->isLowered) { - this->isLowered = false; - this->actor.draw = BgHakaWater_Draw; - this->actor.home.pos.y += 200.0f; +void BgHakaWater_Wait(BgHakaWater* pthis, GlobalContext* globalCtx) { + if ((!pthis->isLowered && Flags_GetSwitch(globalCtx, pthis->actor.params)) || + (pthis->isLowered && !Flags_GetSwitch(globalCtx, pthis->actor.params))) { + if (pthis->isLowered) { + pthis->isLowered = false; + pthis->actor.draw = BgHakaWater_Draw; + pthis->actor.home.pos.y += 200.0f; } else { - this->isLowered = true; - this->actor.home.pos.y -= 200.0f; + pthis->isLowered = true; + pthis->actor.home.pos.y -= 200.0f; } - this->actionFunc = BgHakaWater_ChangeWaterLevel; + pthis->actionFunc = BgHakaWater_ChangeWaterLevel; } } -void BgHakaWater_ChangeWaterLevel(BgHakaWater* this, GlobalContext* globalCtx) { - if (!this->isLowered && Flags_GetSwitch(globalCtx, this->actor.params)) { - this->isLowered = true; - this->actor.home.pos.y -= 200.0f; - } else if (this->isLowered && !Flags_GetSwitch(globalCtx, this->actor.params)) { - this->isLowered = false; - this->actor.home.pos.y += 200.0f; +void BgHakaWater_ChangeWaterLevel(BgHakaWater* pthis, GlobalContext* globalCtx) { + if (!pthis->isLowered && Flags_GetSwitch(globalCtx, pthis->actor.params)) { + pthis->isLowered = true; + pthis->actor.home.pos.y -= 200.0f; + } else if (pthis->isLowered && !Flags_GetSwitch(globalCtx, pthis->actor.params)) { + pthis->isLowered = false; + pthis->actor.home.pos.y += 200.0f; } - if (this->actor.home.pos.y < this->actor.world.pos.y) { - func_8002F948(&this->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + if (pthis->actor.home.pos.y < pthis->actor.world.pos.y) { + func_8002F948(&pthis->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); } else { - func_8002F948(&this->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); } - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f) != 0) { - this->actionFunc = BgHakaWater_Wait; - if (this->isLowered) { - this->actor.draw = NULL; + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f) != 0) { + pthis->actionFunc = BgHakaWater_Wait; + if (pthis->isLowered) { + pthis->actor.draw = NULL; } } - BgHakaWater_LowerWater(this, globalCtx); + BgHakaWater_LowerWater(pthis, globalCtx); } void BgHakaWater_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaWater* this = (BgHakaWater*)thisx; + BgHakaWater* pthis = (BgHakaWater*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgHakaWater_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHakaWater* this = (BgHakaWater*)thisx; + BgHakaWater* pthis = (BgHakaWater*)thisx; s32 pad; f32 temp; s32 pad2; @@ -120,10 +120,10 @@ void BgHakaWater_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_water.c", 287); func_80093D84(globalCtx->state.gfxCtx); - if (this->isLowered) { - temp = this->actor.world.pos.y - this->actor.home.pos.y; + if (pthis->isLowered) { + temp = pthis->actor.world.pos.y - pthis->actor.home.pos.y; } else { - temp = this->actor.world.pos.y - (this->actor.home.pos.y - 200.0f); + temp = pthis->actor.world.pos.y - (pthis->actor.home.pos.y - 200.0f); } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(0.765f * temp)); diff --git a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c deleted file mode 100644 index 39e9f8d5b..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c +++ /dev/null @@ -1,423 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_ZOU_Z_BG_HAKA_ZOU_C -#include "actor_common.h" -/* - * File: z_bg_haka_zou.c - * Overlay: ovl_Bg_Haka_Zou - * Description: Statue and Wall (Shadow Temple) - */ - -#include "z_bg_haka_zou.h" -#include "objects/object_hakach_objects/object_hakach_objects.h" -#include "objects/object_haka_objects/object_haka_objects.h" -#include "def/code_80043480.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_scene.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef enum { - /* 0x0 */ STA_GIANT_BIRD_STATUE, - /* 0x1 */ STA_BOMBABLE_SKULL_WALL, - /* 0x2 */ STA_BOMBABLE_RUBBLE, - /* 0x3 */ STA_UNKNOWN -} ShadowTempleAssetsType; - -void BgHakaZou_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaZou_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaZou_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaZou_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgHakaZou_Wait(BgHakaZou* this, GlobalContext* globalCtx); -void func_80882BDC(BgHakaZou* this, GlobalContext* globalCtx); -void func_80883000(BgHakaZou* this, GlobalContext* globalCtx); -void func_80883104(BgHakaZou* this, GlobalContext* globalCtx); -void func_80883144(BgHakaZou* this, GlobalContext* globalCtx); -void func_80883254(BgHakaZou* this, GlobalContext* globalCtx); -void func_80883328(BgHakaZou* this, GlobalContext* globalCtx); -void func_808834D8(BgHakaZou* this, GlobalContext* globalCtx); -void BgHakaZou_DoNothing(BgHakaZou* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 5, 60, 0, { 0, 0, 0 } }, -}; - -static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; - -const ActorInit Bg_Haka_Zou_InitVars = { - ACTOR_BG_HAKA_ZOU, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(BgHakaZou), - (ActorFunc)BgHakaZou_Init, - (ActorFunc)BgHakaZou_Destroy, - (ActorFunc)BgHakaZou_Update, - NULL, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgHakaZou_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHakaZou* this = (BgHakaZou*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - - this->switchFlag = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - - if (thisx->params == STA_UNKNOWN) { - Actor_SetScale(thisx, (Rand_ZeroOne() * 0.005f) + 0.025f); - - thisx->speedXZ = Rand_ZeroOne(); - thisx->world.rot.y = thisx->shape.rot.y * ((Rand_ZeroOne() < 0.5f) ? -1 : 1) + Rand_CenteredFloat(0x1000); - this->timer = 20; - thisx->world.rot.x = Rand_S16Offset(0x100, 0x300) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); - thisx->world.rot.z = Rand_S16Offset(0x400, 0x800) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); - } else { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - Collider_UpdateCylinder(thisx, &this->collider); - - DynaPolyActor_Init(&this->dyna, 0); - - if (thisx->params == STA_GIANT_BIRD_STATUE) { - thisx->uncullZoneForward = 2000.0f; - thisx->uncullZoneScale = 3000.0f; - thisx->uncullZoneDownward = 3000.0f; - } - } - - this->requiredObjBankIndex = (thisx->params == STA_BOMBABLE_RUBBLE) - ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKACH_OBJECTS) - : Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); - - if (this->requiredObjBankIndex < 0) { - Actor_Kill(thisx); - } else if ((thisx->params != STA_UNKNOWN) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - if (thisx->params != STA_GIANT_BIRD_STATUE) { - Actor_Kill(thisx); - } else { - thisx->shape.rot.x = -0x4000; - thisx->world.pos.z -= 80.0f; - thisx->world.pos.y -= 54.0f; - } - } - - this->actionFunc = BgHakaZou_Wait; -} - -void BgHakaZou_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHakaZou* this = (BgHakaZou*)thisx; - - if (this->dyna.actor.params != STA_UNKNOWN) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void func_808828F4(BgHakaZou* this, GlobalContext* globalCtx) { - Vec3f effectPos; - Vec3f effectVelocity; - f32 rand; - s32 i; - - effectVelocity.x = 0.0f; - effectVelocity.y = 1.0f; - effectVelocity.z = 2.0f; - - for (i = 0; i < 2; i++) { - if (i == 0) { - effectPos.x = this->dyna.actor.world.pos.x - (Rand_CenteredFloat(10.0f) + 112.0f); - } else { - effectPos.x = Rand_CenteredFloat(10.0f) + this->dyna.actor.world.pos.x; - } - - rand = Rand_ZeroOne(); - effectPos.y = this->dyna.actor.world.pos.y + (60.0f * rand); - effectPos.z = this->dyna.actor.world.pos.z + (112.0f * rand); - - func_800286CC(globalCtx, &effectPos, &effectVelocity, &sZeroVec, (Rand_ZeroOne() * 200.0f) + 1000.0f, 100); - } -} - -void BgHakaZou_Wait(BgHakaZou* this, GlobalContext* globalCtx) { - CollisionHeader* colHeader; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { - this->dyna.actor.objBankIndex = this->requiredObjBankIndex; - this->dyna.actor.draw = BgHakaZou_Draw; - - if (this->dyna.actor.params == STA_UNKNOWN) { - this->actionFunc = func_80882BDC; - } else { - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); - - colHeader = NULL; - - if (this->dyna.actor.params == STA_GIANT_BIRD_STATUE) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_006F70, &colHeader); - this->collider.dim.radius = 80; - this->collider.dim.height = 100; - this->collider.dim.yShift = -30; - this->collider.dim.pos.x -= 56; - this->collider.dim.pos.z += 56; - this->dyna.actor.uncullZoneScale = 1500.0f; - } else if (this->dyna.actor.params == STA_BOMBABLE_SKULL_WALL) { - CollisionHeader_GetVirtual(&object_haka_objects_Col_005E30, &colHeader); - this->collider.dim.yShift = -50; - } else { - CollisionHeader_GetVirtual(&gBotwBombSpotCol, &colHeader); - this->collider.dim.radius = 55; - this->collider.dim.height = 20; - } - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if ((this->dyna.actor.params == STA_GIANT_BIRD_STATUE) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actionFunc = BgHakaZou_DoNothing; - } else { - this->actionFunc = func_80883000; - } - } - } -} -void func_80882BDC(BgHakaZou* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - this->dyna.actor.shape.rot.x += this->dyna.actor.world.rot.x; - this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z; - - if (this->dyna.actor.bgCheckFlags & 2) { - if (this->dyna.actor.velocity.y < -8.0f) { - this->dyna.actor.velocity.y *= -0.6f; - this->dyna.actor.velocity.y = CLAMP_MAX(this->dyna.actor.velocity.y, 10.0f); - this->dyna.actor.bgCheckFlags &= ~3; - this->dyna.actor.speedXZ = 2.0f; - } else { - Actor_Kill(&this->dyna.actor); - } - } - - if (this->timer == 0) { - Actor_Kill(&this->dyna.actor); - } -} - -void func_80882CC4(BgHakaZou* this, GlobalContext* globalCtx) { - s32 i; - s32 j; - Vec3f actorSpawnPos; - f32 sin; - f32 cos; - s32 pad; - - sin = Math_SinS(this->dyna.actor.shape.rot.y - 0x4000) * 40.0f; - cos = Math_CosS(this->dyna.actor.shape.rot.y - 0x4000) * 40.0f; - - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - actorSpawnPos.x = this->dyna.actor.world.pos.x + (j - 1) * sin; - actorSpawnPos.z = this->dyna.actor.world.pos.z + (j - 1) * cos; - actorSpawnPos.y = this->dyna.actor.world.pos.y + (i - 1) * 55; - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_HAKA_ZOU, actorSpawnPos.x, actorSpawnPos.y, - actorSpawnPos.z, 0, this->dyna.actor.shape.rot.y, 0, this->dyna.actor.params + 2); - func_800286CC(globalCtx, &actorSpawnPos, &sZeroVec, &sZeroVec, 1000, 50); - } - } -} - -void func_80882E54(BgHakaZou* this, GlobalContext* globalCtx) { - Vec3f fragmentPos; - s32 i; - s32 j; - s32 num = 25; - - fragmentPos.x = this->collider.dim.pos.x; - fragmentPos.y = this->collider.dim.pos.y; - fragmentPos.z = this->collider.dim.pos.z; - - EffectSsHahen_SpawnBurst(globalCtx, &fragmentPos, 10.0f, 0, 10, 10, 4, 141, 40, gBotwBombSpotDL); - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - fragmentPos.x = this->collider.dim.pos.x + (((j * 2) - 1) * num); - fragmentPos.z = this->collider.dim.pos.z + (((i * 2) - 1) * num); - EffectSsHahen_SpawnBurst(globalCtx, &fragmentPos, 10.0f, 0, 10, 10, 4, 141, 40, gBotwBombSpotDL); - func_800286CC(globalCtx, &fragmentPos, &sZeroVec, &sZeroVec, 1000, 50); - } - } -} - -void func_80883000(BgHakaZou* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - Flags_SetSwitch(globalCtx, this->switchFlag); - - if (this->dyna.actor.params == STA_GIANT_BIRD_STATUE) { - this->timer = 20; - this->actionFunc = func_80883144; - OnePointCutscene_Init(globalCtx, 3400, 999, &this->dyna.actor, MAIN_CAM); - } else if (this->dyna.actor.params == 2) { - func_80882E54(this, globalCtx); - this->dyna.actor.draw = NULL; - this->timer = 1; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_EXPLOSION); - this->actionFunc = func_80883104; - } else { - func_80882CC4(this, globalCtx); - this->timer = 1; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); - this->actionFunc = func_80883104; - } - } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void func_80883104(BgHakaZou* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - Actor_Kill(&this->dyna.actor); - } -} - -void func_80883144(BgHakaZou* this, GlobalContext* globalCtx) { - Vec3f explosionPos; - - if (this->timer != 0) { - this->timer--; - } - - if (!(this->timer % 4)) { - explosionPos.x = Rand_CenteredFloat(200.0f) + (this->dyna.actor.world.pos.x - 56.0f); - explosionPos.y = (Rand_ZeroOne() * 80.0f) + this->dyna.actor.world.pos.y; - explosionPos.z = Rand_CenteredFloat(200.0f) + (this->dyna.actor.world.pos.z + 56.0f); - - EffectSsBomb2_SpawnLayered(globalCtx, &explosionPos, &sZeroVec, &sZeroVec, 150, 70); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); - } - - if (this->timer == 0) { - this->timer = 20; - this->actionFunc = func_80883254; - } -} - -void func_80883254(BgHakaZou* this, GlobalContext* globalCtx) { - f32 moveDist = (Rand_ZeroOne() * 0.5f) + 0.5f; - - Math_StepToF(&this->dyna.actor.world.pos.z, this->dyna.actor.home.pos.z - 80.0f, 2.0f * moveDist); - - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 40.0f, moveDist)) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - this->timer = 60; - this->dyna.actor.world.rot.x = 8; - this->actionFunc = func_80883328; - } - } else { - func_808828F4(this, globalCtx); - } -} - -void func_80883328(BgHakaZou* this, GlobalContext* globalCtx) { - Vec3f effectPos; - s32 i; - s32 j; - - this->dyna.actor.world.rot.x += this->dyna.actor.world.rot.x / 8.0f; - - if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, -0x4000, this->dyna.actor.world.rot.x)) { - effectPos.x = this->dyna.actor.world.pos.x; - effectPos.y = this->dyna.actor.world.pos.y; - - for (j = 0; j < 2; j++) { - effectPos.z = this->dyna.actor.world.pos.z; - - for (i = 0; i < 4; i++) { - effectPos.z -= (i == 2) ? 550.0f : 50.0f; - func_800286CC(globalCtx, &effectPos, &sZeroVec, &sZeroVec, (Rand_ZeroOne() * 200.0f) + 1000.0f, 200); - } - - effectPos.x -= 112.0f; - } - - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - this->timer = 25; - this->actionFunc = func_808834D8; - } -} - -void func_808834D8(BgHakaZou* this, GlobalContext* globalCtx) { - f32 moveDist; - - if (this->timer != 0) { - this->timer--; - } - - moveDist = (this->timer % 2) ? 15.0f : -15.0f; - this->dyna.actor.world.pos.y += ((this->timer & 0xFE) * 0.04f * moveDist); - - if (this->timer == 0) { - this->actionFunc = BgHakaZou_DoNothing; - } -} - -void BgHakaZou_DoNothing(BgHakaZou* this, GlobalContext* globalCtx) { -} - -void BgHakaZou_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHakaZou* this = (BgHakaZou*)thisx; - - this->actionFunc(this, globalCtx); - - if (this->dyna.actor.params == 3) { - Actor_MoveForward(&this->dyna.actor); - } -} - -void BgHakaZou_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Gfx* dLists[] = { - object_haka_objects_DL_0064E0, - object_haka_objects_DL_005CE0, - gBotwBombSpotDL, - object_haka_objects_DL_005CE0, - }; - - Gfx_DrawDListOpa(globalCtx, dLists[thisx->params]); -} diff --git a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.cpp b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.cpp new file mode 100644 index 000000000..3a3e68e6c --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.cpp @@ -0,0 +1,423 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HAKA_ZOU_Z_BG_HAKA_ZOU_C +#include "actor_common.h" +/* + * File: z_bg_haka_zou.c + * Overlay: ovl_Bg_Haka_Zou + * Description: Statue and Wall (Shadow Temple) + */ + +#include "z_bg_haka_zou.h" +#include "objects/object_hakach_objects/object_hakach_objects.h" +#include "objects/object_haka_objects/object_haka_objects.h" +#include "def/code_80043480.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_scene.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef enum { + /* 0x0 */ STA_GIANT_BIRD_STATUE, + /* 0x1 */ STA_BOMBABLE_SKULL_WALL, + /* 0x2 */ STA_BOMBABLE_RUBBLE, + /* 0x3 */ STA_UNKNOWN +} ShadowTempleAssetsType; + +void BgHakaZou_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHakaZou_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHakaZou_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakaZou_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgHakaZou_Wait(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_80882BDC(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_80883000(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_80883104(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_80883144(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_80883254(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_80883328(BgHakaZou* pthis, GlobalContext* globalCtx); +void func_808834D8(BgHakaZou* pthis, GlobalContext* globalCtx); +void BgHakaZou_DoNothing(BgHakaZou* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 5, 60, 0, { 0, 0, 0 } }, +}; + +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +ActorInit Bg_Haka_Zou_InitVars = { + ACTOR_BG_HAKA_ZOU, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(BgHakaZou), + (ActorFunc)BgHakaZou_Init, + (ActorFunc)BgHakaZou_Destroy, + (ActorFunc)BgHakaZou_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgHakaZou_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakaZou* pthis = (BgHakaZou*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + + pthis->switchFlag = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + + if (thisx->params == STA_UNKNOWN) { + Actor_SetScale(thisx, (Rand_ZeroOne() * 0.005f) + 0.025f); + + thisx->speedXZ = Rand_ZeroOne(); + thisx->world.rot.y = thisx->shape.rot.y * ((Rand_ZeroOne() < 0.5f) ? -1 : 1) + Rand_CenteredFloat(0x1000); + pthis->timer = 20; + thisx->world.rot.x = Rand_S16Offset(0x100, 0x300) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + thisx->world.rot.z = Rand_S16Offset(0x400, 0x800) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + } else { + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &pthis->collider); + + DynaPolyActor_Init(&pthis->dyna, 0); + + if (thisx->params == STA_GIANT_BIRD_STATUE) { + thisx->uncullZoneForward = 2000.0f; + thisx->uncullZoneScale = 3000.0f; + thisx->uncullZoneDownward = 3000.0f; + } + } + + pthis->requiredObjBankIndex = (thisx->params == STA_BOMBABLE_RUBBLE) + ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKACH_OBJECTS) + : Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); + + if (pthis->requiredObjBankIndex < 0) { + Actor_Kill(thisx); + } else if ((thisx->params != STA_UNKNOWN) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if (thisx->params != STA_GIANT_BIRD_STATUE) { + Actor_Kill(thisx); + } else { + thisx->shape.rot.x = -0x4000; + thisx->world.pos.z -= 80.0f; + thisx->world.pos.y -= 54.0f; + } + } + + pthis->actionFunc = BgHakaZou_Wait; +} + +void BgHakaZou_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaZou* pthis = (BgHakaZou*)thisx; + + if (pthis->dyna.actor.params != STA_UNKNOWN) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void func_808828F4(BgHakaZou* pthis, GlobalContext* globalCtx) { + Vec3f effectPos; + Vec3f effectVelocity; + f32 rand; + s32 i; + + effectVelocity.x = 0.0f; + effectVelocity.y = 1.0f; + effectVelocity.z = 2.0f; + + for (i = 0; i < 2; i++) { + if (i == 0) { + effectPos.x = pthis->dyna.actor.world.pos.x - (Rand_CenteredFloat(10.0f) + 112.0f); + } else { + effectPos.x = Rand_CenteredFloat(10.0f) + pthis->dyna.actor.world.pos.x; + } + + rand = Rand_ZeroOne(); + effectPos.y = pthis->dyna.actor.world.pos.y + (60.0f * rand); + effectPos.z = pthis->dyna.actor.world.pos.z + (112.0f * rand); + + func_800286CC(globalCtx, &effectPos, &effectVelocity, &sZeroVec, (Rand_ZeroOne() * 200.0f) + 1000.0f, 100); + } +} + +void BgHakaZou_Wait(BgHakaZou* pthis, GlobalContext* globalCtx) { + CollisionHeader* colHeader; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->requiredObjBankIndex)) { + pthis->dyna.actor.objBankIndex = pthis->requiredObjBankIndex; + pthis->dyna.actor.draw = BgHakaZou_Draw; + + if (pthis->dyna.actor.params == STA_UNKNOWN) { + pthis->actionFunc = func_80882BDC; + } else { + Actor_SetObjectDependency(globalCtx, &pthis->dyna.actor); + + colHeader = NULL; + + if (pthis->dyna.actor.params == STA_GIANT_BIRD_STATUE) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_006F70, &colHeader); + pthis->collider.dim.radius = 80; + pthis->collider.dim.height = 100; + pthis->collider.dim.yShift = -30; + pthis->collider.dim.pos.x -= 56; + pthis->collider.dim.pos.z += 56; + pthis->dyna.actor.uncullZoneScale = 1500.0f; + } else if (pthis->dyna.actor.params == STA_BOMBABLE_SKULL_WALL) { + CollisionHeader_GetVirtual(&object_haka_objects_Col_005E30, &colHeader); + pthis->collider.dim.yShift = -50; + } else { + CollisionHeader_GetVirtual(&gBotwBombSpotCol, &colHeader); + pthis->collider.dim.radius = 55; + pthis->collider.dim.height = 20; + } + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if ((pthis->dyna.actor.params == STA_GIANT_BIRD_STATUE) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actionFunc = BgHakaZou_DoNothing; + } else { + pthis->actionFunc = func_80883000; + } + } + } +} +void func_80882BDC(BgHakaZou* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->dyna.actor.shape.rot.x += pthis->dyna.actor.world.rot.x; + pthis->dyna.actor.shape.rot.z += pthis->dyna.actor.world.rot.z; + + if (pthis->dyna.actor.bgCheckFlags & 2) { + if (pthis->dyna.actor.velocity.y < -8.0f) { + pthis->dyna.actor.velocity.y *= -0.6f; + pthis->dyna.actor.velocity.y = CLAMP_MAX(pthis->dyna.actor.velocity.y, 10.0f); + pthis->dyna.actor.bgCheckFlags &= ~3; + pthis->dyna.actor.speedXZ = 2.0f; + } else { + Actor_Kill(&pthis->dyna.actor); + } + } + + if (pthis->timer == 0) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void func_80882CC4(BgHakaZou* pthis, GlobalContext* globalCtx) { + s32 i; + s32 j; + Vec3f actorSpawnPos; + f32 sin; + f32 cos; + s32 pad; + + sin = Math_SinS(pthis->dyna.actor.shape.rot.y - 0x4000) * 40.0f; + cos = Math_CosS(pthis->dyna.actor.shape.rot.y - 0x4000) * 40.0f; + + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + actorSpawnPos.x = pthis->dyna.actor.world.pos.x + (j - 1) * sin; + actorSpawnPos.z = pthis->dyna.actor.world.pos.z + (j - 1) * cos; + actorSpawnPos.y = pthis->dyna.actor.world.pos.y + (i - 1) * 55; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_HAKA_ZOU, actorSpawnPos.x, actorSpawnPos.y, + actorSpawnPos.z, 0, pthis->dyna.actor.shape.rot.y, 0, pthis->dyna.actor.params + 2); + func_800286CC(globalCtx, &actorSpawnPos, &sZeroVec, &sZeroVec, 1000, 50); + } + } +} + +void func_80882E54(BgHakaZou* pthis, GlobalContext* globalCtx) { + Vec3f fragmentPos; + s32 i; + s32 j; + s32 num = 25; + + fragmentPos.x = pthis->collider.dim.pos.x; + fragmentPos.y = pthis->collider.dim.pos.y; + fragmentPos.z = pthis->collider.dim.pos.z; + + EffectSsHahen_SpawnBurst(globalCtx, &fragmentPos, 10.0f, 0, 10, 10, 4, 141, 40, gBotwBombSpotDL); + + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + fragmentPos.x = pthis->collider.dim.pos.x + (((j * 2) - 1) * num); + fragmentPos.z = pthis->collider.dim.pos.z + (((i * 2) - 1) * num); + EffectSsHahen_SpawnBurst(globalCtx, &fragmentPos, 10.0f, 0, 10, 10, 4, 141, 40, gBotwBombSpotDL); + func_800286CC(globalCtx, &fragmentPos, &sZeroVec, &sZeroVec, 1000, 50); + } + } +} + +void func_80883000(BgHakaZou* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + + if (pthis->dyna.actor.params == STA_GIANT_BIRD_STATUE) { + pthis->timer = 20; + pthis->actionFunc = func_80883144; + OnePointCutscene_Init(globalCtx, 3400, 999, &pthis->dyna.actor, MAIN_CAM); + } else if (pthis->dyna.actor.params == 2) { + func_80882E54(pthis, globalCtx); + pthis->dyna.actor.draw = NULL; + pthis->timer = 1; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_EXPLOSION); + pthis->actionFunc = func_80883104; + } else { + func_80882CC4(pthis, globalCtx); + pthis->timer = 1; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WALL_BROKEN); + pthis->actionFunc = func_80883104; + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void func_80883104(BgHakaZou* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void func_80883144(BgHakaZou* pthis, GlobalContext* globalCtx) { + Vec3f explosionPos; + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (!(pthis->timer % 4)) { + explosionPos.x = Rand_CenteredFloat(200.0f) + (pthis->dyna.actor.world.pos.x - 56.0f); + explosionPos.y = (Rand_ZeroOne() * 80.0f) + pthis->dyna.actor.world.pos.y; + explosionPos.z = Rand_CenteredFloat(200.0f) + (pthis->dyna.actor.world.pos.z + 56.0f); + + EffectSsBomb2_SpawnLayered(globalCtx, &explosionPos, &sZeroVec, &sZeroVec, 150, 70); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + } + + if (pthis->timer == 0) { + pthis->timer = 20; + pthis->actionFunc = func_80883254; + } +} + +void func_80883254(BgHakaZou* pthis, GlobalContext* globalCtx) { + f32 moveDist = (Rand_ZeroOne() * 0.5f) + 0.5f; + + Math_StepToF(&pthis->dyna.actor.world.pos.z, pthis->dyna.actor.home.pos.z - 80.0f, 2.0f * moveDist); + + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 40.0f, moveDist)) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + pthis->timer = 60; + pthis->dyna.actor.world.rot.x = 8; + pthis->actionFunc = func_80883328; + } + } else { + func_808828F4(pthis, globalCtx); + } +} + +void func_80883328(BgHakaZou* pthis, GlobalContext* globalCtx) { + Vec3f effectPos; + s32 i; + s32 j; + + pthis->dyna.actor.world.rot.x += pthis->dyna.actor.world.rot.x / 8.0f; + + if (Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.x, -0x4000, pthis->dyna.actor.world.rot.x)) { + effectPos.x = pthis->dyna.actor.world.pos.x; + effectPos.y = pthis->dyna.actor.world.pos.y; + + for (j = 0; j < 2; j++) { + effectPos.z = pthis->dyna.actor.world.pos.z; + + for (i = 0; i < 4; i++) { + effectPos.z -= (i == 2) ? 550.0f : 50.0f; + func_800286CC(globalCtx, &effectPos, &sZeroVec, &sZeroVec, (Rand_ZeroOne() * 200.0f) + 1000.0f, 200); + } + + effectPos.x -= 112.0f; + } + + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); + pthis->timer = 25; + pthis->actionFunc = func_808834D8; + } +} + +void func_808834D8(BgHakaZou* pthis, GlobalContext* globalCtx) { + f32 moveDist; + + if (pthis->timer != 0) { + pthis->timer--; + } + + moveDist = (pthis->timer % 2) ? 15.0f : -15.0f; + pthis->dyna.actor.world.pos.y += ((pthis->timer & 0xFE) * 0.04f * moveDist); + + if (pthis->timer == 0) { + pthis->actionFunc = BgHakaZou_DoNothing; + } +} + +void BgHakaZou_DoNothing(BgHakaZou* pthis, GlobalContext* globalCtx) { +} + +void BgHakaZou_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaZou* pthis = (BgHakaZou*)thisx; + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->dyna.actor.params == 3) { + Actor_MoveForward(&pthis->dyna.actor); + } +} + +void BgHakaZou_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* dLists[] = { + object_haka_objects_DL_0064E0, + object_haka_objects_DL_005CE0, + gBotwBombSpotDL, + object_haka_objects_DL_005CE0, + }; + + Gfx_DrawDListOpa(globalCtx, dLists[thisx->params]); +} diff --git a/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c b/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.cpp similarity index 62% rename from src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c rename to src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.cpp index 70111d874..1e96eceba 100644 --- a/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c +++ b/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.cpp @@ -34,14 +34,14 @@ void BgHeavyBlock_Draw(Actor* thisx, GlobalContext* globalCtx); void BgHeavyBlock_DrawPiece(Actor* thisx, GlobalContext* globalCtx); -void BgHeavyBlock_MovePiece(BgHeavyBlock* this, GlobalContext* globalCtx); -void BgHeavyBlock_Wait(BgHeavyBlock* this, GlobalContext* globalCtx); -void BgHeavyBlock_LiftedUp(BgHeavyBlock* this, GlobalContext* globalCtx); -void BgHeavyBlock_Fly(BgHeavyBlock* this, GlobalContext* globalCtx); -void BgHeavyBlock_Land(BgHeavyBlock* this, GlobalContext* globalCtx); -void BgHeavyBlock_DoNothing(BgHeavyBlock* this, GlobalContext* globalCtx); +void BgHeavyBlock_MovePiece(BgHeavyBlock* pthis, GlobalContext* globalCtx); +void BgHeavyBlock_Wait(BgHeavyBlock* pthis, GlobalContext* globalCtx); +void BgHeavyBlock_LiftedUp(BgHeavyBlock* pthis, GlobalContext* globalCtx); +void BgHeavyBlock_Fly(BgHeavyBlock* pthis, GlobalContext* globalCtx); +void BgHeavyBlock_Land(BgHeavyBlock* pthis, GlobalContext* globalCtx); +void BgHeavyBlock_DoNothing(BgHeavyBlock* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Heavy_Block_InitVars = { +ActorInit Bg_Heavy_Block_InitVars = { ACTOR_BG_HEAVY_BLOCK, ACTORCAT_BG, FLAGS, @@ -60,48 +60,48 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; -void BgHeavyBlock_SetPieceRandRot(BgHeavyBlock* this, f32 scale) { - this->dyna.actor.world.rot.x = Rand_CenteredFloat(1024.0f) * scale; - this->dyna.actor.world.rot.y = Rand_CenteredFloat(1024.0f) * scale; - this->dyna.actor.world.rot.z = Rand_CenteredFloat(1024.0f) * scale; +void BgHeavyBlock_SetPieceRandRot(BgHeavyBlock* pthis, f32 scale) { + pthis->dyna.actor.world.rot.x = Rand_CenteredFloat(1024.0f) * scale; + pthis->dyna.actor.world.rot.y = Rand_CenteredFloat(1024.0f) * scale; + pthis->dyna.actor.world.rot.z = Rand_CenteredFloat(1024.0f) * scale; } -void BgHeavyBlock_InitPiece(BgHeavyBlock* this, f32 scale) { +void BgHeavyBlock_InitPiece(BgHeavyBlock* pthis, f32 scale) { f32 rand; f32 yawSinCos; f32 randChoice; - this->dyna.actor.gravity = -0.6f; - this->dyna.actor.minVelocityY = -12.0f; + pthis->dyna.actor.gravity = -0.6f; + pthis->dyna.actor.minVelocityY = -12.0f; randChoice = Rand_CenteredFloat(12.0f * scale); rand = (randChoice < 0.0f) ? randChoice - 2.0f : randChoice + 2.0f; - this->dyna.actor.velocity.y = (Rand_ZeroFloat(8.0f) + 4.0f) * scale; - this->dyna.actor.velocity.z = Rand_ZeroFloat(-8.0f * scale); - yawSinCos = Math_CosS(this->dyna.actor.world.rot.y); - this->dyna.actor.velocity.x = - (Math_SinS(this->dyna.actor.world.rot.y) * this->dyna.actor.velocity.z + (yawSinCos * rand)); - yawSinCos = Math_SinS(this->dyna.actor.world.rot.y); - this->dyna.actor.velocity.z = - (Math_CosS(this->dyna.actor.world.rot.y) * this->dyna.actor.velocity.z) + (-yawSinCos * rand); - BgHeavyBlock_SetPieceRandRot(this, scale); - Actor_SetScale(&this->dyna.actor, Rand_CenteredFloat(0.2f) + 1.0f); + pthis->dyna.actor.velocity.y = (Rand_ZeroFloat(8.0f) + 4.0f) * scale; + pthis->dyna.actor.velocity.z = Rand_ZeroFloat(-8.0f * scale); + yawSinCos = Math_CosS(pthis->dyna.actor.world.rot.y); + pthis->dyna.actor.velocity.x = + (Math_SinS(pthis->dyna.actor.world.rot.y) * pthis->dyna.actor.velocity.z + (yawSinCos * rand)); + yawSinCos = Math_SinS(pthis->dyna.actor.world.rot.y); + pthis->dyna.actor.velocity.z = + (Math_CosS(pthis->dyna.actor.world.rot.y) * pthis->dyna.actor.velocity.z) + (-yawSinCos * rand); + BgHeavyBlock_SetPieceRandRot(pthis, scale); + Actor_SetScale(&pthis->dyna.actor, Rand_CenteredFloat(0.2f) + 1.0f); } -void BgHeavyBlock_SetupDynapoly(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_SetupDynapoly(BgHeavyBlock* pthis, GlobalContext* globalCtx) { s32 pad[2]; CollisionHeader* colHeader = NULL; - this->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_17; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + pthis->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_17; + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gHeavyBlockCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } void BgHeavyBlock_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHeavyBlock* this = (BgHeavyBlock*)thisx; + BgHeavyBlock* pthis = (BgHeavyBlock*)thisx; Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - this->pieceFlags = 0; + pthis->pieceFlags = 0; if (globalCtx->sceneNum == SCENE_GANON_TOU) { thisx->params &= 0xFF00; @@ -111,35 +111,35 @@ void BgHeavyBlock_Init(Actor* thisx, GlobalContext* globalCtx) { switch (thisx->params & 0xFF) { case HEAVYBLOCK_BIG_PIECE: thisx->draw = BgHeavyBlock_DrawPiece; - this->actionFunc = BgHeavyBlock_MovePiece; - BgHeavyBlock_InitPiece(this, 1.0f); - this->timer = 120; + pthis->actionFunc = BgHeavyBlock_MovePiece; + BgHeavyBlock_InitPiece(pthis, 1.0f); + pthis->timer = 120; thisx->flags |= ACTOR_FLAG_4; - this->unk_164.y = -50.0f; + pthis->unk_164.y = -50.0f; break; case HEAVYBLOCK_SMALL_PIECE: thisx->draw = BgHeavyBlock_DrawPiece; - this->actionFunc = BgHeavyBlock_MovePiece; - BgHeavyBlock_InitPiece(this, 2.0f); - this->timer = 120; + pthis->actionFunc = BgHeavyBlock_MovePiece; + BgHeavyBlock_InitPiece(pthis, 2.0f); + pthis->timer = 120; thisx->flags |= ACTOR_FLAG_4; - this->unk_164.y = -20.0f; + pthis->unk_164.y = -20.0f; break; case HEAVYBLOCK_BREAKABLE: - BgHeavyBlock_SetupDynapoly(this, globalCtx); + BgHeavyBlock_SetupDynapoly(pthis, globalCtx); if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0x3F)) { Actor_Kill(thisx); return; } - this->actionFunc = BgHeavyBlock_Wait; + pthis->actionFunc = BgHeavyBlock_Wait; break; case HEAVYBLOCK_UNBREAKABLE_OUTSIDE_CASTLE: - BgHeavyBlock_SetupDynapoly(this, globalCtx); + BgHeavyBlock_SetupDynapoly(pthis, globalCtx); if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0x3F)) { - this->actionFunc = BgHeavyBlock_DoNothing; + pthis->actionFunc = BgHeavyBlock_DoNothing; thisx->shape.rot.x = thisx->world.rot.x = 0x8AD0; thisx->shape.rot.y = thisx->world.rot.y = 0xC000; thisx->shape.rot.z = thisx->world.rot.z = 0x0; @@ -148,15 +148,15 @@ void BgHeavyBlock_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->world.pos.z = 516.0f; } - this->actionFunc = BgHeavyBlock_Wait; + pthis->actionFunc = BgHeavyBlock_Wait; break; case HEAVYBLOCK_UNBREAKABLE: - BgHeavyBlock_SetupDynapoly(this, globalCtx); - this->actionFunc = BgHeavyBlock_Wait; + BgHeavyBlock_SetupDynapoly(pthis, globalCtx); + pthis->actionFunc = BgHeavyBlock_Wait; break; default: - BgHeavyBlock_SetupDynapoly(this, globalCtx); - this->actionFunc = BgHeavyBlock_Wait; + BgHeavyBlock_SetupDynapoly(pthis, globalCtx); + pthis->actionFunc = BgHeavyBlock_Wait; break; } // "Largest Block Save Bit %x" @@ -164,19 +164,19 @@ void BgHeavyBlock_Init(Actor* thisx, GlobalContext* globalCtx) { } void BgHeavyBlock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHeavyBlock* this = (BgHeavyBlock*)thisx; - switch (this->dyna.actor.params & 0xFF) { + BgHeavyBlock* pthis = (BgHeavyBlock*)thisx; + switch (pthis->dyna.actor.params & 0xFF) { case HEAVYBLOCK_BIG_PIECE: break; case HEAVYBLOCK_SMALL_PIECE: break; default: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } -void BgHeavyBlock_MovePiece(BgHeavyBlock* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void BgHeavyBlock_MovePiece(BgHeavyBlock* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; thisx->velocity.y += thisx->gravity; @@ -191,25 +191,25 @@ void BgHeavyBlock_MovePiece(BgHeavyBlock* this, GlobalContext* globalCtx) { thisx->shape.rot.y += thisx->world.rot.y; thisx->shape.rot.z += thisx->world.rot.z; - if (!(this->pieceFlags & PIECE_FLAG_HIT_FLOOR)) { - thisx->world.pos.y += this->unk_164.y; - thisx->prevPos.y += this->unk_164.y; + if (!(pthis->pieceFlags & PIECE_FLAG_HIT_FLOOR)) { + thisx->world.pos.y += pthis->unk_164.y; + thisx->prevPos.y += pthis->unk_164.y; Actor_UpdateBgCheckInfo(globalCtx, thisx, 50.0f, 50.0f, 0.0f, 5); - thisx->world.pos.y -= this->unk_164.y; - thisx->prevPos.y -= this->unk_164.y; + thisx->world.pos.y -= pthis->unk_164.y; + thisx->prevPos.y -= pthis->unk_164.y; if (thisx->bgCheckFlags & 1) { - this->pieceFlags |= PIECE_FLAG_HIT_FLOOR; + pthis->pieceFlags |= PIECE_FLAG_HIT_FLOOR; thisx->velocity.y = Rand_ZeroFloat(4.0f) + 2.0f; thisx->velocity.x = Rand_CenteredFloat(8.0f); thisx->velocity.z = Rand_CenteredFloat(8.0f); - BgHeavyBlock_SetPieceRandRot(this, 1.0f); + BgHeavyBlock_SetPieceRandRot(pthis, 1.0f); Audio_PlayActorSound2(thisx, NA_SE_EV_ROCK_BROKEN); func_800AA000(thisx->xzDistToPlayer, 0x96, 0xA, 8); } } - if (this->timer > 0) { - this->timer--; + if (pthis->timer > 0) { + pthis->timer--; } else { Actor_Kill(thisx); } @@ -293,7 +293,7 @@ void BgHeavyBlock_SpawnDust(GlobalContext* globalCtx, f32 posX, f32 posY, f32 po (s32)Rand_ZeroFloat(10.0f) + 20); } -void BgHeavyBlock_SpawnPieces(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_SpawnPieces(BgHeavyBlock* pthis, GlobalContext* globalCtx) { s32 i; Vec3f spA4[] = { { 0.0f, 300.0f, -20.0f }, { 50.0f, 200.0f, -20.0f }, { -50.0f, 200.0f, -20.0f }, @@ -306,43 +306,43 @@ void BgHeavyBlock_SpawnPieces(BgHeavyBlock* this, GlobalContext* globalCtx) { f32 sinYaw; f32 cosYaw; - sinPitch = Math_SinS(this->dyna.actor.world.rot.x); - cosPitch = Math_CosS(this->dyna.actor.world.rot.x); - sinYaw = Math_SinS(this->dyna.actor.world.rot.y); - cosYaw = Math_CosS(this->dyna.actor.world.rot.y); + sinPitch = Math_SinS(pthis->dyna.actor.world.rot.x); + cosPitch = Math_CosS(pthis->dyna.actor.world.rot.x); + sinYaw = Math_SinS(pthis->dyna.actor.world.rot.y); + cosYaw = Math_CosS(pthis->dyna.actor.world.rot.y); for (i = 0; i < ARRAY_COUNT(spA4); i++) { pos.z = (spA4[i].y * sinPitch) + (spA4[i].z * cosPitch); - pos.x = this->dyna.actor.world.pos.x + (spA4[i].x * cosYaw) + (sinYaw * pos.z); - pos.y = this->dyna.actor.world.pos.y + (spA4[i].y * cosPitch) + (-spA4[i].z * sinPitch); - pos.z = this->dyna.actor.world.pos.z + (spA4[i].x * -sinYaw) + (cosYaw * pos.z); + pos.x = pthis->dyna.actor.world.pos.x + (spA4[i].x * cosYaw) + (sinYaw * pos.z); + pos.y = pthis->dyna.actor.world.pos.y + (spA4[i].y * cosPitch) + (-spA4[i].z * sinPitch); + pos.z = pthis->dyna.actor.world.pos.z + (spA4[i].x * -sinYaw) + (cosYaw * pos.z); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_HEAVY_BLOCK, pos.x, pos.y, pos.z, - this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, 0, 2); + pthis->dyna.actor.shape.rot.x, pthis->dyna.actor.shape.rot.y, 0, 2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_HEAVY_BLOCK, pos.x, pos.y, pos.z, - this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, 0, 3); + pthis->dyna.actor.shape.rot.x, pthis->dyna.actor.shape.rot.y, 0, 3); BgHeavyBlock_SpawnDust(globalCtx, pos.x, pos.y, pos.z, 0.0f, 0.0f, 0.0f, 0); } } -void BgHeavyBlock_Wait(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_Wait(BgHeavyBlock* pthis, GlobalContext* globalCtx) { s32 quakeIndex; // if block has a parent link has lifted it, start one point cutscene and quake - if (Actor_HasParent(&this->dyna.actor, globalCtx)) { - this->timer = 0; + if (Actor_HasParent(&pthis->dyna.actor, globalCtx)) { + pthis->timer = 0; - switch (this->dyna.actor.params & 0xFF) { + switch (pthis->dyna.actor.params & 0xFF) { case HEAVYBLOCK_BREAKABLE: - OnePointCutscene_Init(globalCtx, 4020, 270, &this->dyna.actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 4020, 270, &pthis->dyna.actor, MAIN_CAM); break; case HEAVYBLOCK_UNBREAKABLE: - OnePointCutscene_Init(globalCtx, 4021, 220, &this->dyna.actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 4021, 220, &pthis->dyna.actor, MAIN_CAM); break; case HEAVYBLOCK_UNBREAKABLE_OUTSIDE_CASTLE: - OnePointCutscene_Init(globalCtx, 4022, 210, &this->dyna.actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 4022, 210, &pthis->dyna.actor, MAIN_CAM); break; } @@ -350,11 +350,11 @@ void BgHeavyBlock_Wait(BgHeavyBlock* this, GlobalContext* globalCtx) { Quake_SetSpeed(quakeIndex, 25000); Quake_SetQuakeValues(quakeIndex, 1, 1, 5, 0); Quake_SetCountdown(quakeIndex, 10); - this->actionFunc = BgHeavyBlock_LiftedUp; + pthis->actionFunc = BgHeavyBlock_LiftedUp; } } -void BgHeavyBlock_LiftedUp(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_LiftedUp(BgHeavyBlock* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; f32 cosYaw; @@ -362,56 +362,56 @@ void BgHeavyBlock_LiftedUp(BgHeavyBlock* this, GlobalContext* globalCtx) { f32 sinYaw; f32 xOffset; - if (this->timer == 11) { + if (pthis->timer == 11) { func_800AA000(0.0f, 0xFF, 0x14, 0x14); func_8002F7DC(&player->actor, NA_SE_PL_PULL_UP_BIGROCK); LOG_STRING("NA_SE_PL_PULL_UP_BIGROCK", "../z_bg_heavy_block.c", 691); } - if (this->timer < 40) { + if (pthis->timer < 40) { xOffset = Rand_CenteredFloat(110.0f); - sinYaw = Math_SinS(this->dyna.actor.shape.rot.y); + sinYaw = Math_SinS(pthis->dyna.actor.shape.rot.y); zOffset = Rand_CenteredFloat(110.0f); - cosYaw = Math_CosS(this->dyna.actor.shape.rot.y); + cosYaw = Math_CosS(pthis->dyna.actor.shape.rot.y); - BgHeavyBlock_SpawnDust(globalCtx, (sinYaw * -70.0f) + (this->dyna.actor.world.pos.x + xOffset), - this->dyna.actor.world.pos.y + 10.0f, - (cosYaw * -70.0f) + (this->dyna.actor.world.pos.z + zOffset), 0.0f, -1.0f, 0.0f, 0xC); + BgHeavyBlock_SpawnDust(globalCtx, (sinYaw * -70.0f) + (pthis->dyna.actor.world.pos.x + xOffset), + pthis->dyna.actor.world.pos.y + 10.0f, + (cosYaw * -70.0f) + (pthis->dyna.actor.world.pos.z + zOffset), 0.0f, -1.0f, 0.0f, 0xC); } - this->timer++; + pthis->timer++; func_8002DF54(globalCtx, &player->actor, 8); // if parent is NULL, link threw it - if (Actor_HasNoParent(&this->dyna.actor, globalCtx)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_HEAVY_THROW); - this->actionFunc = BgHeavyBlock_Fly; + if (Actor_HasNoParent(&pthis->dyna.actor, globalCtx)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_HEAVY_THROW); + pthis->actionFunc = BgHeavyBlock_Fly; } } -void BgHeavyBlock_Fly(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_Fly(BgHeavyBlock* pthis, GlobalContext* globalCtx) { s32 bgId; s32 quakeIndex; Vec3f pos; f32 raycastResult; - Actor_MoveForward(&this->dyna.actor); - pos.x = this->dyna.actor.home.pos.x; - pos.y = this->dyna.actor.home.pos.y + 1000.0f; - pos.z = this->dyna.actor.home.pos.z; + Actor_MoveForward(&pthis->dyna.actor); + pos.x = pthis->dyna.actor.home.pos.x; + pos.y = pthis->dyna.actor.home.pos.y + 1000.0f; + pos.z = pthis->dyna.actor.home.pos.z; raycastResult = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &pos); - this->dyna.actor.floorHeight = raycastResult; + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, &bgId, &pthis->dyna.actor, &pos); + pthis->dyna.actor.floorHeight = raycastResult; - if (this->dyna.actor.home.pos.y <= raycastResult) { + if (pthis->dyna.actor.home.pos.y <= raycastResult) { func_800AA000(0.0f, 0xFF, 0x3C, 4); - switch (this->dyna.actor.params & 0xFF) { + switch (pthis->dyna.actor.params & 0xFF) { case HEAVYBLOCK_BREAKABLE: - BgHeavyBlock_SpawnPieces(this, globalCtx); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - Actor_Kill(&this->dyna.actor); + BgHeavyBlock_SpawnPieces(pthis, globalCtx); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + Actor_Kill(&pthis->dyna.actor); quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quakeIndex, 28000); @@ -423,28 +423,28 @@ void BgHeavyBlock_Fly(BgHeavyBlock* this, GlobalContext* globalCtx) { Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0); Quake_SetCountdown(quakeIndex, 999); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_ELECTRIC_EXPLOSION); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 30, NA_SE_EV_ELECTRIC_EXPLOSION); return; case HEAVYBLOCK_UNBREAKABLE_OUTSIDE_CASTLE: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quakeIndex, 28000); Quake_SetQuakeValues(quakeIndex, 16, 2, 120, 0); Quake_SetCountdown(quakeIndex, 40); - this->actionFunc = BgHeavyBlock_Land; - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); + pthis->actionFunc = BgHeavyBlock_Land; + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); break; case HEAVYBLOCK_UNBREAKABLE: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quakeIndex, 28000); Quake_SetQuakeValues(quakeIndex, 14, 2, 100, 0); Quake_SetCountdown(quakeIndex, 40); - this->actionFunc = BgHeavyBlock_Land; + pthis->actionFunc = BgHeavyBlock_Land; break; default: quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); @@ -452,26 +452,26 @@ void BgHeavyBlock_Fly(BgHeavyBlock* this, GlobalContext* globalCtx) { Quake_SetQuakeValues(quakeIndex, 14, 2, 100, 0); Quake_SetCountdown(quakeIndex, 40); - this->actionFunc = BgHeavyBlock_Land; + pthis->actionFunc = BgHeavyBlock_Land; } } - this->dyna.actor.shape.rot.x = Math_Atan2S(this->dyna.actor.velocity.y, this->dyna.actor.speedXZ); + pthis->dyna.actor.shape.rot.x = Math_Atan2S(pthis->dyna.actor.velocity.y, pthis->dyna.actor.speedXZ); } -void BgHeavyBlock_DoNothing(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_DoNothing(BgHeavyBlock* pthis, GlobalContext* globalCtx) { } -void BgHeavyBlock_Land(BgHeavyBlock* this, GlobalContext* globalCtx) { +void BgHeavyBlock_Land(BgHeavyBlock* pthis, GlobalContext* globalCtx) { s32 pad; - if (Math_SmoothStepToS(&this->dyna.actor.shape.rot.x, 0x8AD0, 6, 2000, 100) != 0) { - Math_StepToF(&this->dyna.actor.speedXZ, 0.0f, 20.0f); - Math_StepToF(&this->dyna.actor.velocity.y, 0.0f, 3.0f); - this->dyna.actor.gravity = 0.0f; - this->dyna.actor.world.pos = this->dyna.actor.home.pos; - Actor_MoveForward(&this->dyna.actor); - this->dyna.actor.home.pos = this->dyna.actor.world.pos; - switch (this->dyna.actor.params & 0xFF) { + if (Math_SmoothStepToS(&pthis->dyna.actor.shape.rot.x, 0x8AD0, 6, 2000, 100) != 0) { + Math_StepToF(&pthis->dyna.actor.speedXZ, 0.0f, 20.0f); + Math_StepToF(&pthis->dyna.actor.velocity.y, 0.0f, 3.0f); + pthis->dyna.actor.gravity = 0.0f; + pthis->dyna.actor.world.pos = pthis->dyna.actor.home.pos; + Actor_MoveForward(&pthis->dyna.actor); + pthis->dyna.actor.home.pos = pthis->dyna.actor.world.pos; + switch (pthis->dyna.actor.params & 0xFF) { case HEAVYBLOCK_UNBREAKABLE_OUTSIDE_CASTLE: BgHeavyBlock_SpawnDust(globalCtx, Rand_CenteredFloat(30.0f) + 1678.0f, Rand_ZeroFloat(100.0f) + 1286.0f, Rand_CenteredFloat(30.0f) + 552.0f, 0.0f, 0.0f, 0.0f, 0); @@ -484,30 +484,30 @@ void BgHeavyBlock_Land(BgHeavyBlock* this, GlobalContext* globalCtx) { break; } } else { - this->dyna.actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_5); - this->actionFunc = BgHeavyBlock_DoNothing; + pthis->dyna.actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_5); + pthis->actionFunc = BgHeavyBlock_DoNothing; } } void BgHeavyBlock_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHeavyBlock* this = (BgHeavyBlock*)thisx; + BgHeavyBlock* pthis = (BgHeavyBlock*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgHeavyBlock_Draw(Actor* thisx, GlobalContext* globalCtx) { static Vec3f D_80884EC8 = { 0.0f, 0.0f, 0.0f }; static Vec3f D_80884ED4 = { 0.0f, 400.0f, 0.0f }; - BgHeavyBlock* this = (BgHeavyBlock*)thisx; + BgHeavyBlock* pthis = (BgHeavyBlock*)thisx; s32 pad; Player* player = GET_PLAYER(globalCtx); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_heavy_block.c", 904); - if (BgHeavyBlock_LiftedUp == this->actionFunc) { + if (BgHeavyBlock_LiftedUp == pthis->actionFunc) { func_800D1694(player->leftHandPos.x, player->leftHandPos.y, player->leftHandPos.z, &thisx->shape.rot); - Matrix_Translate(-this->unk_164.x, -this->unk_164.y, -this->unk_164.z, MTXMODE_APPLY); - } else if ((thisx->gravity == 0.0f) && (BgHeavyBlock_Land == this->actionFunc)) { + Matrix_Translate(-pthis->unk_164.x, -pthis->unk_164.y, -pthis->unk_164.z, MTXMODE_APPLY); + } else if ((thisx->gravity == 0.0f) && (BgHeavyBlock_Land == pthis->actionFunc)) { func_800D1694(thisx->home.pos.x, thisx->home.pos.y, thisx->home.pos.z, &thisx->shape.rot); Matrix_Translate(-D_80884ED4.x, -D_80884ED4.y, -D_80884ED4.z, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c b/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c deleted file mode 100644 index 37a5af719..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c +++ /dev/null @@ -1,271 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_CURTAIN_Z_BG_HIDAN_CURTAIN_C -#include "actor_common.h" -/* - * File: z_bg_hidan_curtain.c - * Overlay: ovl_Bg_Hidan_Curtain - * Description: Flame circle - */ - -#include "z_bg_hidan_curtain.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgHidanCurtain_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanCurtain_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanCurtain_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgHidanCurtain_WaitForSwitchOn(BgHidanCurtain* this, GlobalContext* globalCtx); -void BgHidanCurtain_WaitForCutscene(BgHidanCurtain* this, GlobalContext* globalCtx); -void BgHidanCurtain_WaitForClear(BgHidanCurtain* this, GlobalContext* globalCtx); -void BgHidanCurtain_TurnOn(BgHidanCurtain* this, GlobalContext* globalCtx); -void BgHidanCurtain_TurnOff(BgHidanCurtain* this, GlobalContext* globalCtx); -void BgHidanCurtain_WaitForTimer(BgHidanCurtain* this, GlobalContext* globalCtx); - -typedef struct { - /* 0x00 */ s16 radius; - /* 0x02 */ s16 height; - /* 0x04 */ f32 scale; - /* 0x08 */ f32 riseDist; - /* 0x0C */ f32 riseSpeed; -} BgHidanCurtainParams; // size = 0x10 - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 81, 144, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sCcInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; - -static BgHidanCurtainParams sHCParams[] = { { 81, 144, 0.090f, 144.0f, 5.0f }, { 46, 88, 0.055f, 88.0f, 3.0f } }; - -const ActorInit Bg_Hidan_Curtain_InitVars = { - ACTOR_BG_HIDAN_CURTAIN, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(BgHidanCurtain), - (ActorFunc)BgHidanCurtain_Init, - (ActorFunc)BgHidanCurtain_Destroy, - (ActorFunc)BgHidanCurtain_Update, - (ActorFunc)BgHidanCurtain_Draw, -}; - -void BgHidanCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHidanCurtain* this = (BgHidanCurtain*)thisx; - BgHidanCurtainParams* hcParams; - - osSyncPrintf("Curtain (arg_data 0x%04x)\n", this->actor.params); - Actor_SetFocus(&this->actor, 20.0f); - this->type = (thisx->params >> 0xC) & 0xF; - if (this->type > 6) { - // "Type is not set" - osSyncPrintf("Error : object のタイプが設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_hidan_curtain.c", - 352, this->actor.params); - Actor_Kill(&this->actor); - return; - } - - this->size = ((this->type == 2) || (this->type == 4)) ? 1 : 0; - hcParams = &sHCParams[this->size]; - this->treasureFlag = (thisx->params >> 6) & 0x3F; - thisx->params &= 0x3F; - - if ((this->actor.params < 0) || (this->actor.params > 0x3F)) { - // "Save bit is not set" - osSyncPrintf("Warning : object のセーブビットが設定されていない(%s %d)(arg_data 0x%04x)\n", - "../z_bg_hidan_curtain.c", 373, this->actor.params); - } - Actor_SetScale(&this->actor, hcParams->scale); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->collider.dim.pos.x = this->actor.world.pos.x; - this->collider.dim.pos.y = this->actor.world.pos.y; - this->collider.dim.pos.z = this->actor.world.pos.z; - this->collider.dim.radius = hcParams->radius; - this->collider.dim.height = hcParams->height; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sCcInfoInit); - if (this->type == 0) { - this->actionFunc = BgHidanCurtain_WaitForClear; - } else { - this->actionFunc = BgHidanCurtain_WaitForSwitchOn; - if ((this->type == 4) || (this->type == 5)) { - this->actor.world.pos.y = this->actor.home.pos.y - hcParams->riseDist; - } - } - if (((this->type == 1) && Flags_GetTreasure(globalCtx, this->treasureFlag)) || - (((this->type == 0) || (this->type == 6)) && Flags_GetClear(globalCtx, this->actor.room))) { - Actor_Kill(&this->actor); - } - this->texScroll = Rand_ZeroOne() * 15.0f; -} - -void BgHidanCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHidanCurtain* this = (BgHidanCurtain*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void BgHidanCurtain_WaitForSwitchOn(BgHidanCurtain* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - if (this->type == 1) { - this->actionFunc = BgHidanCurtain_WaitForCutscene; - OnePointCutscene_Init(globalCtx, 3350, -99, &this->actor, MAIN_CAM); - this->timer = 50; - } else if (this->type == 3) { - this->actionFunc = BgHidanCurtain_WaitForCutscene; - OnePointCutscene_Init(globalCtx, 3360, 60, &this->actor, MAIN_CAM); - this->timer = 30; - } else { - this->actionFunc = BgHidanCurtain_TurnOff; - } - } -} - -void BgHidanCurtain_WaitForCutscene(BgHidanCurtain* this, GlobalContext* globalCtx) { - if (this->timer-- == 0) { - this->actionFunc = BgHidanCurtain_TurnOff; - } -} - -void BgHidanCurtain_WaitForClear(BgHidanCurtain* this, GlobalContext* globalCtx) { - if (Flags_GetClear(globalCtx, this->actor.room)) { - this->actionFunc = BgHidanCurtain_TurnOff; - } -} - -void BgHidanCurtain_WaitForSwitchOff(BgHidanCurtain* this, GlobalContext* globalCtx) { - if (!Flags_GetSwitch(globalCtx, this->actor.params)) { - this->actionFunc = BgHidanCurtain_TurnOn; - } -} - -void BgHidanCurtain_TurnOn(BgHidanCurtain* this, GlobalContext* globalCtx) { - f32 riseSpeed = sHCParams[this->size].riseSpeed; - - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, riseSpeed)) { - Flags_UnsetSwitch(globalCtx, this->actor.params); - this->actionFunc = BgHidanCurtain_WaitForSwitchOn; - } -} - -void BgHidanCurtain_TurnOff(BgHidanCurtain* this, GlobalContext* globalCtx) { - BgHidanCurtainParams* hcParams = &sHCParams[this->size]; - - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - hcParams->riseDist, hcParams->riseSpeed)) { - if ((this->type == 0) || (this->type == 6)) { - Actor_Kill(&this->actor); - } else if (this->type == 5) { - this->actionFunc = BgHidanCurtain_WaitForSwitchOff; - } else { - if (this->type == 2) { - this->timer = 400; - } else if (this->type == 4) { - this->timer = 200; - } else if (this->type == 3) { - this->timer = 160; - } else { // this->type == 1 - this->timer = 300; - } - this->actionFunc = BgHidanCurtain_WaitForTimer; - } - } -} - -void BgHidanCurtain_WaitForTimer(BgHidanCurtain* this, GlobalContext* globalCtx) { - DECR(this->timer); - if (this->timer == 0) { - this->actionFunc = BgHidanCurtain_TurnOn; - } - if ((this->type == 1) || (this->type == 3)) { - func_8002F994(&this->actor, this->timer); - } -} - -void BgHidanCurtain_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BgHidanCurtain* this = (BgHidanCurtain*)thisx; - BgHidanCurtainParams* hcParams = &sHCParams[this->size]; - f32 riseProgress; - - if ((globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_SLOW_CHEST_CS) || - (globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_TURN_AROUND)) { - this->collider.base.atFlags &= ~AT_HIT; - } else { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - func_8002F71C(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 1.0f); - } - if ((this->type == 4) || (this->type == 5)) { - this->actor.world.pos.y = (2.0f * this->actor.home.pos.y) - hcParams->riseDist - this->actor.world.pos.y; - } - - this->actionFunc(this, globalCtx); - - if ((this->type == 4) || (this->type == 5)) { - this->actor.world.pos.y = (2.0f * this->actor.home.pos.y) - hcParams->riseDist - this->actor.world.pos.y; - } - riseProgress = (hcParams->riseDist - (this->actor.home.pos.y - this->actor.world.pos.y)) / hcParams->riseDist; - this->alpha = 255.0f * riseProgress; - if (this->alpha > 50) { - this->collider.dim.height = hcParams->height * riseProgress; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (gSaveContext.sceneSetupIndex <= 3) { - func_8002F974(&this->actor, NA_SE_EV_FIRE_PILLAR_S - SFX_FLAG); - } - } else if ((this->type == 1) && Flags_GetTreasure(globalCtx, this->treasureFlag)) { - Actor_Kill(&this->actor); - } - this->texScroll++; - } -} - -void BgHidanCurtain_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanCurtain* this = (BgHidanCurtain*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_curtain.c", 685); - func_80093D84(globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, this->alpha); - - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->texScroll & 0x7F, 0, 0x20, 0x40, 1, 0, - (this->texScroll * -0xF) & 0xFF, 0x20, 0x40)); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_curtain.c", 698), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_XLU_DISP++, gEffFireCircleDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_curtain.c", 702); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.cpp b/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.cpp new file mode 100644 index 000000000..be1bc1442 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.cpp @@ -0,0 +1,271 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_CURTAIN_Z_BG_HIDAN_CURTAIN_C +#include "actor_common.h" +/* + * File: z_bg_hidan_curtain.c + * Overlay: ovl_Bg_Hidan_Curtain + * Description: Flame circle + */ + +#include "z_bg_hidan_curtain.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgHidanCurtain_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanCurtain_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanCurtain_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgHidanCurtain_WaitForSwitchOn(BgHidanCurtain* pthis, GlobalContext* globalCtx); +void BgHidanCurtain_WaitForCutscene(BgHidanCurtain* pthis, GlobalContext* globalCtx); +void BgHidanCurtain_WaitForClear(BgHidanCurtain* pthis, GlobalContext* globalCtx); +void BgHidanCurtain_TurnOn(BgHidanCurtain* pthis, GlobalContext* globalCtx); +void BgHidanCurtain_TurnOff(BgHidanCurtain* pthis, GlobalContext* globalCtx); +void BgHidanCurtain_WaitForTimer(BgHidanCurtain* pthis, GlobalContext* globalCtx); + +typedef struct { + /* 0x00 */ s16 radius; + /* 0x02 */ s16 height; + /* 0x04 */ f32 scale; + /* 0x08 */ f32 riseDist; + /* 0x0C */ f32 riseSpeed; +} BgHidanCurtainParams; // size = 0x10 + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 81, 144, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sCcInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; + +static BgHidanCurtainParams sHCParams[] = { { 81, 144, 0.090f, 144.0f, 5.0f }, { 46, 88, 0.055f, 88.0f, 3.0f } }; + +ActorInit Bg_Hidan_Curtain_InitVars = { + ACTOR_BG_HIDAN_CURTAIN, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(BgHidanCurtain), + (ActorFunc)BgHidanCurtain_Init, + (ActorFunc)BgHidanCurtain_Destroy, + (ActorFunc)BgHidanCurtain_Update, + (ActorFunc)BgHidanCurtain_Draw, +}; + +void BgHidanCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHidanCurtain* pthis = (BgHidanCurtain*)thisx; + BgHidanCurtainParams* hcParams; + + osSyncPrintf("Curtain (arg_data 0x%04x)\n", pthis->actor.params); + Actor_SetFocus(&pthis->actor, 20.0f); + pthis->type = (thisx->params >> 0xC) & 0xF; + if (pthis->type > 6) { + // "Type is not set" + osSyncPrintf("Error : object のタイプが設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_hidan_curtain.c", + 352, pthis->actor.params); + Actor_Kill(&pthis->actor); + return; + } + + pthis->size = ((pthis->type == 2) || (pthis->type == 4)) ? 1 : 0; + hcParams = &sHCParams[pthis->size]; + pthis->treasureFlag = (thisx->params >> 6) & 0x3F; + thisx->params &= 0x3F; + + if ((pthis->actor.params < 0) || (pthis->actor.params > 0x3F)) { + // "Save bit is not set" + osSyncPrintf("Warning : object のセーブビットが設定されていない(%s %d)(arg_data 0x%04x)\n", + "../z_bg_hidan_curtain.c", 373, pthis->actor.params); + } + Actor_SetScale(&pthis->actor, hcParams->scale); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->collider.dim.pos.x = pthis->actor.world.pos.x; + pthis->collider.dim.pos.y = pthis->actor.world.pos.y; + pthis->collider.dim.pos.z = pthis->actor.world.pos.z; + pthis->collider.dim.radius = hcParams->radius; + pthis->collider.dim.height = hcParams->height; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sCcInfoInit); + if (pthis->type == 0) { + pthis->actionFunc = BgHidanCurtain_WaitForClear; + } else { + pthis->actionFunc = BgHidanCurtain_WaitForSwitchOn; + if ((pthis->type == 4) || (pthis->type == 5)) { + pthis->actor.world.pos.y = pthis->actor.home.pos.y - hcParams->riseDist; + } + } + if (((pthis->type == 1) && Flags_GetTreasure(globalCtx, pthis->treasureFlag)) || + (((pthis->type == 0) || (pthis->type == 6)) && Flags_GetClear(globalCtx, pthis->actor.room))) { + Actor_Kill(&pthis->actor); + } + pthis->texScroll = Rand_ZeroOne() * 15.0f; +} + +void BgHidanCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHidanCurtain* pthis = (BgHidanCurtain*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void BgHidanCurtain_WaitForSwitchOn(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + if (pthis->type == 1) { + pthis->actionFunc = BgHidanCurtain_WaitForCutscene; + OnePointCutscene_Init(globalCtx, 3350, -99, &pthis->actor, MAIN_CAM); + pthis->timer = 50; + } else if (pthis->type == 3) { + pthis->actionFunc = BgHidanCurtain_WaitForCutscene; + OnePointCutscene_Init(globalCtx, 3360, 60, &pthis->actor, MAIN_CAM); + pthis->timer = 30; + } else { + pthis->actionFunc = BgHidanCurtain_TurnOff; + } + } +} + +void BgHidanCurtain_WaitForCutscene(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + if (pthis->timer-- == 0) { + pthis->actionFunc = BgHidanCurtain_TurnOff; + } +} + +void BgHidanCurtain_WaitForClear(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + if (Flags_GetClear(globalCtx, pthis->actor.room)) { + pthis->actionFunc = BgHidanCurtain_TurnOff; + } +} + +void BgHidanCurtain_WaitForSwitchOff(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, pthis->actor.params)) { + pthis->actionFunc = BgHidanCurtain_TurnOn; + } +} + +void BgHidanCurtain_TurnOn(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + f32 riseSpeed = sHCParams[pthis->size].riseSpeed; + + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, riseSpeed)) { + Flags_UnsetSwitch(globalCtx, pthis->actor.params); + pthis->actionFunc = BgHidanCurtain_WaitForSwitchOn; + } +} + +void BgHidanCurtain_TurnOff(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + BgHidanCurtainParams* hcParams = &sHCParams[pthis->size]; + + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - hcParams->riseDist, hcParams->riseSpeed)) { + if ((pthis->type == 0) || (pthis->type == 6)) { + Actor_Kill(&pthis->actor); + } else if (pthis->type == 5) { + pthis->actionFunc = BgHidanCurtain_WaitForSwitchOff; + } else { + if (pthis->type == 2) { + pthis->timer = 400; + } else if (pthis->type == 4) { + pthis->timer = 200; + } else if (pthis->type == 3) { + pthis->timer = 160; + } else { // pthis->type == 1 + pthis->timer = 300; + } + pthis->actionFunc = BgHidanCurtain_WaitForTimer; + } + } +} + +void BgHidanCurtain_WaitForTimer(BgHidanCurtain* pthis, GlobalContext* globalCtx) { + DECR(pthis->timer); + if (pthis->timer == 0) { + pthis->actionFunc = BgHidanCurtain_TurnOn; + } + if ((pthis->type == 1) || (pthis->type == 3)) { + func_8002F994(&pthis->actor, pthis->timer); + } +} + +void BgHidanCurtain_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgHidanCurtain* pthis = (BgHidanCurtain*)thisx; + BgHidanCurtainParams* hcParams = &sHCParams[pthis->size]; + f32 riseProgress; + + if ((globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_SLOW_CHEST_CS) || + (globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_TURN_AROUND)) { + pthis->collider.base.atFlags &= ~AT_HIT; + } else { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + func_8002F71C(globalCtx, &pthis->actor, 5.0f, pthis->actor.yawTowardsPlayer, 1.0f); + } + if ((pthis->type == 4) || (pthis->type == 5)) { + pthis->actor.world.pos.y = (2.0f * pthis->actor.home.pos.y) - hcParams->riseDist - pthis->actor.world.pos.y; + } + + pthis->actionFunc(pthis, globalCtx); + + if ((pthis->type == 4) || (pthis->type == 5)) { + pthis->actor.world.pos.y = (2.0f * pthis->actor.home.pos.y) - hcParams->riseDist - pthis->actor.world.pos.y; + } + riseProgress = (hcParams->riseDist - (pthis->actor.home.pos.y - pthis->actor.world.pos.y)) / hcParams->riseDist; + pthis->alpha = 255.0f * riseProgress; + if (pthis->alpha > 50) { + pthis->collider.dim.height = hcParams->height * riseProgress; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (gSaveContext.sceneSetupIndex <= 3) { + func_8002F974(&pthis->actor, NA_SE_EV_FIRE_PILLAR_S - SFX_FLAG); + } + } else if ((pthis->type == 1) && Flags_GetTreasure(globalCtx, pthis->treasureFlag)) { + Actor_Kill(&pthis->actor); + } + pthis->texScroll++; + } +} + +void BgHidanCurtain_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHidanCurtain* pthis = (BgHidanCurtain*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_curtain.c", 685); + func_80093D84(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, pthis->alpha); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->texScroll & 0x7F, 0, 0x20, 0x40, 1, 0, + (pthis->texScroll * -0xF) & 0xFF, 0x20, 0x40)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_curtain.c", 698), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gEffFireCircleDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_curtain.c", 702); +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.c b/src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.cpp similarity index 59% rename from src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.c rename to src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.cpp index 85c40760e..60a81d902 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.cpp @@ -26,10 +26,10 @@ void BgHidanDalm_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHidanDalm_Update(Actor* thisx, GlobalContext* globalCtx); void BgHidanDalm_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgHidanDalm_Wait(BgHidanDalm* this, GlobalContext* globalCtx); -void BgHidanDalm_Shrink(BgHidanDalm* this, GlobalContext* globalCtx); +void BgHidanDalm_Wait(BgHidanDalm* pthis, GlobalContext* globalCtx); +void BgHidanDalm_Shrink(BgHidanDalm* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Hidan_Dalm_InitVars = { +ActorInit Bg_Hidan_Dalm_InitVars = { ACTOR_BG_HIDAN_DALM, ACTORCAT_BG, FLAGS, @@ -107,99 +107,99 @@ static InitChainEntry sInitChain[] = { }; void BgHidanDalm_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanDalm* this = (BgHidanDalm*)thisx; + BgHidanDalm* pthis = (BgHidanDalm*)thisx; s32 pad; CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gFireTempleHammerableTotemCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, thisx, &sTrisInit, this->colliderItems); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + Collider_InitTris(globalCtx, &pthis->collider); + Collider_SetTris(globalCtx, &pthis->collider, thisx, &sTrisInit, pthis->colliderItems); - this->switchFlag = (thisx->params >> 8) & 0xFF; + pthis->switchFlag = (thisx->params >> 8) & 0xFF; thisx->params &= 0xFF; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { Actor_Kill(thisx); } else { - this->actionFunc = BgHidanDalm_Wait; + pthis->actionFunc = BgHidanDalm_Wait; } } void BgHidanDalm_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanDalm* this = (BgHidanDalm*)thisx; + BgHidanDalm* pthis = (BgHidanDalm*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyTris(globalCtx, &pthis->collider); } -void BgHidanDalm_Wait(BgHidanDalm* this, GlobalContext* globalCtx) { +void BgHidanDalm_Wait(BgHidanDalm* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->collider.base.acFlags & AC_HIT) && !Player_InCsMode(globalCtx) && + if ((pthis->collider.base.acFlags & AC_HIT) && !Player_InCsMode(globalCtx) && (player->swordAnimation == 22 || player->swordAnimation == 23)) { - this->collider.base.acFlags &= ~AC_HIT; - if ((this->collider.elements[0].info.bumperFlags & BUMP_HIT) || - (this->collider.elements[1].info.bumperFlags & BUMP_HIT)) { - this->dyna.actor.world.rot.y -= 0x4000; + pthis->collider.base.acFlags &= ~AC_HIT; + if ((pthis->collider.elements[0].info.bumperFlags & BUMP_HIT) || + (pthis->collider.elements[1].info.bumperFlags & BUMP_HIT)) { + pthis->dyna.actor.world.rot.y -= 0x4000; } else { - this->dyna.actor.world.rot.y += 0x4000; + pthis->dyna.actor.world.rot.y += 0x4000; } - this->dyna.actor.world.pos.x += 32.5f * Math_SinS(this->dyna.actor.world.rot.y); - this->dyna.actor.world.pos.z += 32.5f * Math_CosS(this->dyna.actor.world.rot.y); + pthis->dyna.actor.world.pos.x += 32.5f * Math_SinS(pthis->dyna.actor.world.rot.y); + pthis->dyna.actor.world.pos.z += 32.5f * Math_CosS(pthis->dyna.actor.world.rot.y); - func_8002DF54(globalCtx, &this->dyna.actor, 8); - this->dyna.actor.flags |= ACTOR_FLAG_4; - this->actionFunc = BgHidanDalm_Shrink; - this->dyna.actor.bgCheckFlags &= ~2; - this->dyna.actor.bgCheckFlags &= ~8; - this->dyna.actor.speedXZ = 10.0f; - Flags_SetSwitch(globalCtx, this->switchFlag); + func_8002DF54(globalCtx, &pthis->dyna.actor, 8); + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + pthis->actionFunc = BgHidanDalm_Shrink; + pthis->dyna.actor.bgCheckFlags &= ~2; + pthis->dyna.actor.bgCheckFlags &= ~8; + pthis->dyna.actor.speedXZ = 10.0f; + Flags_SetSwitch(globalCtx, pthis->switchFlag); func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_IT_HAMMER_HIT); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_DARUMA_VANISH); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_DARUMA_VANISH); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void BgHidanDalm_Shrink(BgHidanDalm* this, GlobalContext* globalCtx) { +void BgHidanDalm_Shrink(BgHidanDalm* pthis, GlobalContext* globalCtx) { static Vec3f accel = { 0, 0, 0 }; s32 i; Vec3f velocity; Vec3f pos; - if (Math_StepToF(&this->dyna.actor.scale.x, 0.0f, 0.004f)) { - func_8002DF54(globalCtx, &this->dyna.actor, 7); - Actor_Kill(&this->dyna.actor); + if (Math_StepToF(&pthis->dyna.actor.scale.x, 0.0f, 0.004f)) { + func_8002DF54(globalCtx, &pthis->dyna.actor, 7); + Actor_Kill(&pthis->dyna.actor); } - this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->dyna.actor.scale.x; + pthis->dyna.actor.scale.y = pthis->dyna.actor.scale.z = pthis->dyna.actor.scale.x; - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + this->dyna.actor.scale.x * 160.0f; - pos.z = this->dyna.actor.world.pos.z; + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + pthis->dyna.actor.scale.x * 160.0f; + pos.z = pthis->dyna.actor.world.pos.z; for (i = 0; i < 4; i++) { - velocity.x = 5.0f * Math_SinS(this->dyna.actor.world.rot.y + 0x8000) + (Rand_ZeroOne() - 0.5f) * 5.0f; - velocity.z = 5.0f * Math_CosS(this->dyna.actor.world.rot.y + 0x8000) + (Rand_ZeroOne() - 0.5f) * 5.0f; + velocity.x = 5.0f * Math_SinS(pthis->dyna.actor.world.rot.y + 0x8000) + (Rand_ZeroOne() - 0.5f) * 5.0f; + velocity.z = 5.0f * Math_CosS(pthis->dyna.actor.world.rot.y + 0x8000) + (Rand_ZeroOne() - 0.5f) * 5.0f; velocity.y = (Rand_ZeroOne() - 0.5f) * 1.5f; EffectSsKiraKira_SpawnSmallYellow(globalCtx, &pos, &velocity, &accel); } } void BgHidanDalm_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanDalm* this = (BgHidanDalm*)thisx; + BgHidanDalm* pthis = (BgHidanDalm*)thisx; - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->dyna.actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 10.0f, 15.0f, 32.0f, 5); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 10.0f, 15.0f, 32.0f, 5); } /** * Update vertices of collider tris based on the current matrix */ -void BgHidanDalm_UpdateCollider(BgHidanDalm* this) { +void BgHidanDalm_UpdateCollider(BgHidanDalm* pthis) { Vec3f pos2; Vec3f pos1; Vec3f pos0; @@ -207,28 +207,28 @@ void BgHidanDalm_UpdateCollider(BgHidanDalm* this) { Matrix_MultVec3f(&sTrisElementInit[0].dim.vtx[0], &pos0); Matrix_MultVec3f(&sTrisElementInit[0].dim.vtx[1], &pos1); Matrix_MultVec3f(&sTrisElementInit[0].dim.vtx[2], &pos2); - Collider_SetTrisVertices(&this->collider, 0, &pos0, &pos1, &pos2); + Collider_SetTrisVertices(&pthis->collider, 0, &pos0, &pos1, &pos2); Matrix_MultVec3f(&sTrisElementInit[1].dim.vtx[2], &pos1); - Collider_SetTrisVertices(&this->collider, 1, &pos0, &pos2, &pos1); + Collider_SetTrisVertices(&pthis->collider, 1, &pos0, &pos2, &pos1); Matrix_MultVec3f(&sTrisElementInit[2].dim.vtx[0], &pos0); Matrix_MultVec3f(&sTrisElementInit[2].dim.vtx[1], &pos1); Matrix_MultVec3f(&sTrisElementInit[2].dim.vtx[2], &pos2); - Collider_SetTrisVertices(&this->collider, 2, &pos0, &pos1, &pos2); + Collider_SetTrisVertices(&pthis->collider, 2, &pos0, &pos1, &pos2); Matrix_MultVec3f(&sTrisElementInit[3].dim.vtx[1], &pos2); - Collider_SetTrisVertices(&this->collider, 3, &pos0, &pos2, &pos1); + Collider_SetTrisVertices(&pthis->collider, 3, &pos0, &pos2, &pos1); } void BgHidanDalm_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanDalm* this = (BgHidanDalm*)thisx; + BgHidanDalm* pthis = (BgHidanDalm*)thisx; - if (this->dyna.actor.params == 0) { + if (pthis->dyna.actor.params == 0) { Gfx_DrawDListOpa(globalCtx, gFireTempleHammerableTotemBodyDL); } else { Gfx_DrawDListOpa(globalCtx, gFireTempleHammerableTotemHeadDL); } - if (this->actionFunc == BgHidanDalm_Wait) { - BgHidanDalm_UpdateCollider(this); + if (pthis->actionFunc == BgHidanDalm_Wait) { + BgHidanDalm_UpdateCollider(pthis); } } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c b/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c deleted file mode 100644 index 081a1170b..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c +++ /dev/null @@ -1,223 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_FIREWALL_Z_BG_HIDAN_FIREWALL_C -#include "actor_common.h" -/* - * File: z_bg_hidan_firewall.c - * Overlay: ovl_Bg_Hidan_Firewall - * Description: Proximity Triggered Flame Wall - */ - -#include "z_bg_hidan_firewall.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void BgHidanFirewall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFirewall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFirewall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFirewall_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, GlobalContext* globalCtx); -void BgHidanFirewall_Wait(BgHidanFirewall* this, GlobalContext* globalCtx); -void BgHidanFirewall_Countdown(BgHidanFirewall* this, GlobalContext* globalCtx); -void BgHidanFirewall_Erupt(BgHidanFirewall* this, GlobalContext* globalCtx); -void BgHidanFirewall_Collide(BgHidanFirewall* this, GlobalContext* globalCtx); -void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, GlobalContext* globalCtx); - -const ActorInit Bg_Hidan_Firewall_InitVars = { - ACTOR_BG_HIDAN_FIREWALL, - ACTORCAT_BG, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanFirewall), - (ActorFunc)BgHidanFirewall_Init, - (ActorFunc)BgHidanFirewall_Destroy, - (ActorFunc)BgHidanFirewall_Update, - NULL, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 30, 83, 0, { 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; - -void BgHidanFirewall_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanFirewall* this = (BgHidanFirewall*)thisx; - - this->actor.scale.x = 0.12f; - this->actor.scale.z = 0.12f; - this->actor.scale.y = 0.01f; - - this->unk_150 = 0; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - - this->collider.dim.pos.y = this->actor.world.pos.y; - - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - - this->actionFunc = BgHidanFirewall_Wait; -} - -void BgHidanFirewall_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanFirewall* this = (BgHidanFirewall*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, GlobalContext* globalCtx) { - Player* player; - Vec3f distance; - - player = GET_PLAYER(globalCtx); - func_8002DBD0(&this->actor, &distance, &player->actor.world.pos); - - if (fabsf(distance.x) < 100.0f && fabsf(distance.z) < 120.0f) { - return 1; - } - return 0; -} - -void BgHidanFirewall_Wait(BgHidanFirewall* this, GlobalContext* globalCtx) { - if (BgHidanFirewall_CheckProximity(this, globalCtx) != 0) { - this->actor.draw = BgHidanFirewall_Draw; - this->actor.params = 5; - this->actionFunc = BgHidanFirewall_Countdown; - } -} - -void BgHidanFirewall_Countdown(BgHidanFirewall* this, GlobalContext* globalCtx) { - - if (this->actor.params != 0) { - this->actor.params--; - } - if (this->actor.params == 0) { - this->actionFunc = BgHidanFirewall_Erupt; - } -} - -void BgHidanFirewall_Erupt(BgHidanFirewall* this, GlobalContext* globalCtx) { - if (BgHidanFirewall_CheckProximity(this, globalCtx) != 0) { - Math_StepToF(&this->actor.scale.y, 0.1f, 0.01f / 0.4f); - } else { - if (Math_StepToF(&this->actor.scale.y, 0.01f, 0.01f) != 0) { - this->actor.draw = NULL; - this->actionFunc = BgHidanFirewall_Wait; - } else { - this->actor.params = 0; - } - } -} - -void BgHidanFirewall_Collide(BgHidanFirewall* this, GlobalContext* globalCtx) { - s16 phi_a3; - - if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { - phi_a3 = this->actor.shape.rot.y; - } else { - phi_a3 = this->actor.shape.rot.y + 0x8000; - } - - func_8002F71C(globalCtx, &this->actor, 5.0f, phi_a3, 1.0f); -} - -void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, GlobalContext* globalCtx) { - Player* player; - Vec3f sp30; - f32 temp_ret; - f32 sp28; - f32 phi_f0; - - player = GET_PLAYER(globalCtx); - - func_8002DBD0(&this->actor, &sp30, &player->actor.world.pos); - if (sp30.x < -70.0f) { - sp30.x = -70.0f; - } else { - if (70.0f < sp30.x) { - phi_f0 = 70.0f; - } else { - phi_f0 = sp30.x; - } - sp30.x = phi_f0; - } - if (this->actor.params == 0) { - if (0.0f < sp30.z) { - sp30.z = -25.0f; - this->actor.params = -1; - } else { - sp30.z = 25.0f; - this->actor.params = 1; - } - } else { - sp30.z = this->actor.params * 25.0f; - } - sp28 = Math_SinS(this->actor.shape.rot.y); - temp_ret = Math_CosS(this->actor.shape.rot.y); - this->collider.dim.pos.x = this->actor.world.pos.x + sp30.x * temp_ret + sp30.z * sp28; - this->collider.dim.pos.z = this->actor.world.pos.z - sp30.x * sp28 + sp30.z * temp_ret; -} - -void BgHidanFirewall_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanFirewall* this = (BgHidanFirewall*)thisx; - s32 pad; - - this->unk_150 = (this->unk_150 + 1) % 8; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - BgHidanFirewall_Collide(this, globalCtx); - } - - this->actionFunc(this, globalCtx); - if (this->actionFunc == BgHidanFirewall_Erupt) { - BgHidanFirewall_ColliderFollowPlayer(this, globalCtx); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_8002F974(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); - } -} - -static void* sFireballTexs[] = { - gFireTempleFireball0Tex, gFireTempleFireball1Tex, gFireTempleFireball2Tex, gFireTempleFireball3Tex, - gFireTempleFireball4Tex, gFireTempleFireball5Tex, gFireTempleFireball6Tex, gFireTempleFireball7Tex, -}; - -void BgHidanFirewall_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanFirewall* this = (BgHidanFirewall*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 448); - - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFireballTexs[this->unk_150])); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 458), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gFireTempleFireballUpperHalfDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 463); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.cpp b/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.cpp new file mode 100644 index 000000000..0a3dae997 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.cpp @@ -0,0 +1,223 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_FIREWALL_Z_BG_HIDAN_FIREWALL_C +#include "actor_common.h" +/* + * File: z_bg_hidan_firewall.c + * Overlay: ovl_Bg_Hidan_Firewall + * Description: Proximity Triggered Flame Wall + */ + +#include "z_bg_hidan_firewall.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void BgHidanFirewall_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFirewall_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFirewall_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFirewall_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* pthis, GlobalContext* globalCtx); +void BgHidanFirewall_Wait(BgHidanFirewall* pthis, GlobalContext* globalCtx); +void BgHidanFirewall_Countdown(BgHidanFirewall* pthis, GlobalContext* globalCtx); +void BgHidanFirewall_Erupt(BgHidanFirewall* pthis, GlobalContext* globalCtx); +void BgHidanFirewall_Collide(BgHidanFirewall* pthis, GlobalContext* globalCtx); +void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Hidan_Firewall_InitVars = { + ACTOR_BG_HIDAN_FIREWALL, + ACTORCAT_BG, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanFirewall), + (ActorFunc)BgHidanFirewall_Init, + (ActorFunc)BgHidanFirewall_Destroy, + (ActorFunc)BgHidanFirewall_Update, + NULL, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 30, 83, 0, { 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; + +void BgHidanFirewall_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHidanFirewall* pthis = (BgHidanFirewall*)thisx; + + pthis->actor.scale.x = 0.12f; + pthis->actor.scale.z = 0.12f; + pthis->actor.scale.y = 0.01f; + + pthis->unk_150 = 0; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + + pthis->collider.dim.pos.y = pthis->actor.world.pos.y; + + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + + pthis->actionFunc = BgHidanFirewall_Wait; +} + +void BgHidanFirewall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanFirewall* pthis = (BgHidanFirewall*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* pthis, GlobalContext* globalCtx) { + Player* player; + Vec3f distance; + + player = GET_PLAYER(globalCtx); + func_8002DBD0(&pthis->actor, &distance, &player->actor.world.pos); + + if (fabsf(distance.x) < 100.0f && fabsf(distance.z) < 120.0f) { + return 1; + } + return 0; +} + +void BgHidanFirewall_Wait(BgHidanFirewall* pthis, GlobalContext* globalCtx) { + if (BgHidanFirewall_CheckProximity(pthis, globalCtx) != 0) { + pthis->actor.draw = BgHidanFirewall_Draw; + pthis->actor.params = 5; + pthis->actionFunc = BgHidanFirewall_Countdown; + } +} + +void BgHidanFirewall_Countdown(BgHidanFirewall* pthis, GlobalContext* globalCtx) { + + if (pthis->actor.params != 0) { + pthis->actor.params--; + } + if (pthis->actor.params == 0) { + pthis->actionFunc = BgHidanFirewall_Erupt; + } +} + +void BgHidanFirewall_Erupt(BgHidanFirewall* pthis, GlobalContext* globalCtx) { + if (BgHidanFirewall_CheckProximity(pthis, globalCtx) != 0) { + Math_StepToF(&pthis->actor.scale.y, 0.1f, 0.01f / 0.4f); + } else { + if (Math_StepToF(&pthis->actor.scale.y, 0.01f, 0.01f) != 0) { + pthis->actor.draw = NULL; + pthis->actionFunc = BgHidanFirewall_Wait; + } else { + pthis->actor.params = 0; + } + } +} + +void BgHidanFirewall_Collide(BgHidanFirewall* pthis, GlobalContext* globalCtx) { + s16 phi_a3; + + if (Actor_IsFacingPlayer(&pthis->actor, 0x4000)) { + phi_a3 = pthis->actor.shape.rot.y; + } else { + phi_a3 = pthis->actor.shape.rot.y + 0x8000; + } + + func_8002F71C(globalCtx, &pthis->actor, 5.0f, phi_a3, 1.0f); +} + +void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* pthis, GlobalContext* globalCtx) { + Player* player; + Vec3f sp30; + f32 temp_ret; + f32 sp28; + f32 phi_f0; + + player = GET_PLAYER(globalCtx); + + func_8002DBD0(&pthis->actor, &sp30, &player->actor.world.pos); + if (sp30.x < -70.0f) { + sp30.x = -70.0f; + } else { + if (70.0f < sp30.x) { + phi_f0 = 70.0f; + } else { + phi_f0 = sp30.x; + } + sp30.x = phi_f0; + } + if (pthis->actor.params == 0) { + if (0.0f < sp30.z) { + sp30.z = -25.0f; + pthis->actor.params = -1; + } else { + sp30.z = 25.0f; + pthis->actor.params = 1; + } + } else { + sp30.z = pthis->actor.params * 25.0f; + } + sp28 = Math_SinS(pthis->actor.shape.rot.y); + temp_ret = Math_CosS(pthis->actor.shape.rot.y); + pthis->collider.dim.pos.x = pthis->actor.world.pos.x + sp30.x * temp_ret + sp30.z * sp28; + pthis->collider.dim.pos.z = pthis->actor.world.pos.z - sp30.x * sp28 + sp30.z * temp_ret; +} + +void BgHidanFirewall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHidanFirewall* pthis = (BgHidanFirewall*)thisx; + s32 pad; + + pthis->unk_150 = (pthis->unk_150 + 1) % 8; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + BgHidanFirewall_Collide(pthis, globalCtx); + } + + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc == BgHidanFirewall_Erupt) { + BgHidanFirewall_ColliderFollowPlayer(pthis, globalCtx); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + func_8002F974(&pthis->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); + } +} + +static void* sFireballTexs[] = { + gFireTempleFireball0Tex, gFireTempleFireball1Tex, gFireTempleFireball2Tex, gFireTempleFireball3Tex, + gFireTempleFireball4Tex, gFireTempleFireball5Tex, gFireTempleFireball6Tex, gFireTempleFireball7Tex, +}; + +void BgHidanFirewall_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHidanFirewall* pthis = (BgHidanFirewall*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 448); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFireballTexs[pthis->unk_150])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 458), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFireTempleFireballUpperHalfDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 463); +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c deleted file mode 100644 index 06541e1f0..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c +++ /dev/null @@ -1,151 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_FSLIFT_Z_BG_HIDAN_FSLIFT_C -#include "actor_common.h" -/* - * File: z_bg_hidan_fslift.c - * Overlay: ovl_Bg_Hidan_Fslift - * Description: Hookshot Elevator - */ - -#include "z_bg_hidan_fslift.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgHidanFslift_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFslift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFslift_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFslift_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80886FCC(BgHidanFslift* this, GlobalContext* globalCtx); -void func_8088706C(BgHidanFslift* this, GlobalContext* globalCtx); -void func_808870D8(BgHidanFslift* this, GlobalContext* globalCtx); - -const ActorInit Bg_Hidan_Fslift_InitVars = { - ACTOR_BG_HIDAN_FSLIFT, - ACTORCAT_BG, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanFslift), - (ActorFunc)BgHidanFslift_Init, - (ActorFunc)BgHidanFslift_Destroy, - (ActorFunc)BgHidanFslift_Update, - (ActorFunc)BgHidanFslift_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), -}; - -void BgHidanFslift_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad1; - BgHidanFslift* this = (BgHidanFslift*)thisx; - CollisionHeader* colHeader = NULL; - s32 pad2; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(&gFireTempleHookshotElevatorCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_HSBLOCK, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 40.0f, - this->dyna.actor.world.pos.z + -28.0f, 0, 0, 0, 2) == NULL) { - Actor_Kill(&this->dyna.actor); - return; - } - this->actionFunc = func_80886FCC; -} - -void func_80886F24(BgHidanFslift* this) { - if (this->dyna.actor.child != NULL && this->dyna.actor.child->update != NULL) { - this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; - this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y + 40.0f; - this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z + -28.0f; - } else { - this->dyna.actor.child = NULL; - } -} - -void BgHidanFslift_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanFslift* this = (BgHidanFslift*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80886FB4(BgHidanFslift* this) { - this->timer = 40; - this->actionFunc = func_80886FCC; -} - -void func_80886FCC(BgHidanFslift* this, GlobalContext* globalCtx) { - s32 heightBool; - - if (this->timer) { - this->timer--; - } - - if (this->timer == 0) { - heightBool = false; - if ((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) < 0.5f) { - heightBool = true; - } - if (func_80043590(&this->dyna) && (heightBool)) { - this->actionFunc = func_808870D8; - } else if (!heightBool) { - this->actionFunc = func_8088706C; - } - } -} - -void func_8088706C(BgHidanFslift* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.0f)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - func_80886FB4(this); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); - } - func_80886F24(this); -} - -void func_808870D8(BgHidanFslift* this, GlobalContext* globalCtx) { - if (func_80043590(&this->dyna)) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 790.0f, 4.0f)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - func_80886FB4(this); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); - } - } else { - func_80886FB4(this); - } - func_80886F24(this); -} - -void BgHidanFslift_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanFslift* this = (BgHidanFslift*)thisx; - - this->actionFunc(this, globalCtx); - if (func_8004356C(&this->dyna)) { - if (this->unk_16A == 0) { - this->unk_16A = 3; - } - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); - } else if (!func_8004356C(&this->dyna)) { - if (this->unk_16A != 0) { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); - } - this->unk_16A = 0; - } -} - -void BgHidanFslift_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gFireTempleHookshotElevatorDL); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.cpp b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.cpp new file mode 100644 index 000000000..0c4480416 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.cpp @@ -0,0 +1,151 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_FSLIFT_Z_BG_HIDAN_FSLIFT_C +#include "actor_common.h" +/* + * File: z_bg_hidan_fslift.c + * Overlay: ovl_Bg_Hidan_Fslift + * Description: Hookshot Elevator + */ + +#include "z_bg_hidan_fslift.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgHidanFslift_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFslift_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFslift_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFslift_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80886FCC(BgHidanFslift* pthis, GlobalContext* globalCtx); +void func_8088706C(BgHidanFslift* pthis, GlobalContext* globalCtx); +void func_808870D8(BgHidanFslift* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Hidan_Fslift_InitVars = { + ACTOR_BG_HIDAN_FSLIFT, + ACTORCAT_BG, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanFslift), + (ActorFunc)BgHidanFslift_Init, + (ActorFunc)BgHidanFslift_Destroy, + (ActorFunc)BgHidanFslift_Update, + (ActorFunc)BgHidanFslift_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), +}; + +void BgHidanFslift_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad1; + BgHidanFslift* pthis = (BgHidanFslift*)thisx; + CollisionHeader* colHeader = NULL; + s32 pad2; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(&gFireTempleHookshotElevatorCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_OBJ_HSBLOCK, + pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y + 40.0f, + pthis->dyna.actor.world.pos.z + -28.0f, 0, 0, 0, 2) == NULL) { + Actor_Kill(&pthis->dyna.actor); + return; + } + pthis->actionFunc = func_80886FCC; +} + +void func_80886F24(BgHidanFslift* pthis) { + if (pthis->dyna.actor.child != NULL && pthis->dyna.actor.child->update != NULL) { + pthis->dyna.actor.child->world.pos.x = pthis->dyna.actor.world.pos.x; + pthis->dyna.actor.child->world.pos.y = pthis->dyna.actor.world.pos.y + 40.0f; + pthis->dyna.actor.child->world.pos.z = pthis->dyna.actor.world.pos.z + -28.0f; + } else { + pthis->dyna.actor.child = NULL; + } +} + +void BgHidanFslift_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanFslift* pthis = (BgHidanFslift*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80886FB4(BgHidanFslift* pthis) { + pthis->timer = 40; + pthis->actionFunc = func_80886FCC; +} + +void func_80886FCC(BgHidanFslift* pthis, GlobalContext* globalCtx) { + s32 heightBool; + + if (pthis->timer) { + pthis->timer--; + } + + if (pthis->timer == 0) { + heightBool = false; + if ((pthis->dyna.actor.world.pos.y - pthis->dyna.actor.home.pos.y) < 0.5f) { + heightBool = true; + } + if (func_80043590(&pthis->dyna) && (heightBool)) { + pthis->actionFunc = func_808870D8; + } else if (!heightBool) { + pthis->actionFunc = func_8088706C; + } + } +} + +void func_8088706C(BgHidanFslift* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 4.0f)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80886FB4(pthis); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + } + func_80886F24(pthis); +} + +void func_808870D8(BgHidanFslift* pthis, GlobalContext* globalCtx) { + if (func_80043590(&pthis->dyna)) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 790.0f, 4.0f)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80886FB4(pthis); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + } + } else { + func_80886FB4(pthis); + } + func_80886F24(pthis); +} + +void BgHidanFslift_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHidanFslift* pthis = (BgHidanFslift*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (func_8004356C(&pthis->dyna)) { + if (pthis->unk_16A == 0) { + pthis->unk_16A = 3; + } + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); + } else if (!func_8004356C(&pthis->dyna)) { + if (pthis->unk_16A != 0) { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); + } + pthis->unk_16A = 0; + } +} + +void BgHidanFslift_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gFireTempleHookshotElevatorDL); +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.c b/src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.c deleted file mode 100644 index bf4b4ea71..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.c +++ /dev/null @@ -1,287 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_FWBIG_Z_BG_HIDAN_FWBIG_C -#include "actor_common.h" -/* - * File: z_bg_hidan_fwbig.c - * Overlay: ovl_Bg_Hidan_Fwbig - * Description: Large fire walls at Fire Temple (flame wall before bombable door and the one that chases the player in - * the lava room) - */ - -#include "z_bg_hidan_fwbig.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef enum { - /* 0 */ FWBIG_MOVE, - /* 1 */ FWBIG_RESET, - /* 2 */ FWBIG_KILL -} HidanFwbigMoveState; - -void BgHidanFwbig_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFwbig_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFwbig_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanFwbig_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgHidanFwbig_UpdatePosition(BgHidanFwbig* this); - -void BgHidanFwbig_WaitForSwitch(BgHidanFwbig* this, GlobalContext* globalCtx); -void BgHidanFwbig_WaitForCs(BgHidanFwbig* this, GlobalContext* globalCtx); -void BgHidanFwbig_Lower(BgHidanFwbig* this, GlobalContext* globalCtx); -void BgHidanFwbig_WaitForTimer(BgHidanFwbig* this, GlobalContext* globalCtx); -void BgHidanFwbig_WaitForPlayer(BgHidanFwbig* this, GlobalContext* globalCtx); -void BgHidanFwbig_Move(BgHidanFwbig* this, GlobalContext* globalCtx); - -const ActorInit Bg_Hidan_Fwbig_InitVars = { - ACTOR_BG_HIDAN_FWBIG, - ACTORCAT_PROP, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanFwbig), - (ActorFunc)BgHidanFwbig_Init, - (ActorFunc)BgHidanFwbig_Destroy, - (ActorFunc)BgHidanFwbig_Update, - (ActorFunc)BgHidanFwbig_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 30, 130, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_STOP), -}; - -void BgHidanFwbig_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BgHidanFwbig* this = (BgHidanFwbig*)thisx; - Player* player = GET_PLAYER(globalCtx); - - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->direction = (u16)(thisx->params >> 8); - thisx->params &= 0xFF; - if (this->direction != 0) { - this->actor.home.pos.x = 1560.0f; - this->actor.home.pos.z = 0.0f; - if (player->actor.world.pos.z > 300.0f) { - this->direction = -1; - this->actor.home.rot.y = this->actor.shape.rot.y = -0x4E38; - } else if (player->actor.world.pos.z < -300.0f) { - this->direction = 1; - this->actor.home.rot.y = this->actor.shape.rot.y = -0x31C8; - } else { - Actor_Kill(&this->actor); - return; - } - BgHidanFwbig_UpdatePosition(this); - Actor_SetScale(&this->actor, 0.15f); - this->collider.dim.height = 230; - this->actor.flags |= ACTOR_FLAG_4; - this->moveState = FWBIG_MOVE; - this->actionFunc = BgHidanFwbig_WaitForPlayer; - this->actor.world.pos.y = this->actor.home.pos.y - (2400.0f * this->actor.scale.y); - } else { - Actor_SetScale(&this->actor, 0.1f); - this->actionFunc = BgHidanFwbig_WaitForSwitch; - } -} - -void BgHidanFwbig_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHidanFwbig* this = (BgHidanFwbig*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void BgHidanFwbig_UpdatePosition(BgHidanFwbig* this) { - s16 startAngle = this->actor.shape.rot.y + this->direction * -0x4000; - - this->actor.world.pos.x = (Math_SinS(startAngle) * 885.4f) + this->actor.home.pos.x; - this->actor.world.pos.z = (Math_CosS(startAngle) * 885.4f) + this->actor.home.pos.z; -} - -void BgHidanFwbig_WaitForSwitch(BgHidanFwbig* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - this->actionFunc = BgHidanFwbig_WaitForCs; - OnePointCutscene_Init(globalCtx, 3340, -99, &this->actor, MAIN_CAM); - this->timer = 35; - } -} - -void BgHidanFwbig_WaitForCs(BgHidanFwbig* this, GlobalContext* globalCtx) { - if (this->timer-- == 0) { - this->actionFunc = BgHidanFwbig_Lower; - } -} - -void BgHidanFwbig_Rise(BgHidanFwbig* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 10.0f)) { - if (this->direction == 0) { - Flags_UnsetSwitch(globalCtx, this->actor.params); - this->actionFunc = BgHidanFwbig_WaitForSwitch; - } else { - this->actionFunc = BgHidanFwbig_Move; - } - } -} - -void BgHidanFwbig_Lower(BgHidanFwbig* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - (2400.0f * this->actor.scale.y), 10.0f)) { - if (this->direction == 0) { - this->actionFunc = BgHidanFwbig_WaitForTimer; - this->timer = 150; - } else if (this->moveState == FWBIG_KILL) { - Actor_Kill(&this->actor); - } else { - if (this->moveState == FWBIG_MOVE) { - this->actor.shape.rot.y -= (this->direction * 0x1800); - } else { - this->moveState = FWBIG_MOVE; - this->actor.shape.rot.y = this->actor.home.rot.y; - } - BgHidanFwbig_UpdatePosition(this); - this->actionFunc = BgHidanFwbig_Rise; - } - } -} - -void BgHidanFwbig_WaitForTimer(BgHidanFwbig* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->actionFunc = BgHidanFwbig_Rise; - } - func_8002F994(&this->actor, this->timer); -} - -void BgHidanFwbig_WaitForPlayer(BgHidanFwbig* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (player->actor.world.pos.x < 1150.0f) { - this->actionFunc = BgHidanFwbig_Rise; - OnePointCutscene_Init(globalCtx, 3290, -99, &this->actor, MAIN_CAM); - } -} - -void BgHidanFwbig_Move(BgHidanFwbig* this, GlobalContext* globalCtx) { - if (!Player_InCsMode(globalCtx)) { - if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y + (this->direction * 0x6390), 0x20)) { - this->moveState = FWBIG_RESET; - this->actionFunc = BgHidanFwbig_Lower; - } else { - BgHidanFwbig_UpdatePosition(this); - } - } -} - -void BgHidanFwbig_MoveCollider(BgHidanFwbig* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f projPos; - f32 cs; - f32 sn; - - func_8002DBD0(&this->actor, &projPos, &player->actor.world.pos); - projPos.z = ((projPos.z >= 0.0f) ? 1.0f : -1.0f) * 25.0f * -1.0f; - if (this->direction == 0) { - projPos.x = CLAMP(projPos.x, -360.0f, 360.0f); - } else { - projPos.x = CLAMP(projPos.x, -500.0f, 500.0f); - } - - sn = Math_SinS(this->actor.shape.rot.y); - cs = Math_CosS(this->actor.shape.rot.y); - this->collider.dim.pos.x = this->actor.world.pos.x + (projPos.x * cs) + (projPos.z * sn); - this->collider.dim.pos.z = this->actor.world.pos.z - (projPos.x * sn) + (projPos.z * cs); - this->collider.dim.pos.y = this->actor.world.pos.y; - - this->actor.world.rot.y = (projPos.z < 0.0f) ? this->actor.shape.rot.y : this->actor.shape.rot.y + 0x8000; -} - -void BgHidanFwbig_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHidanFwbig* this = (BgHidanFwbig*)thisx; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - func_8002F71C(globalCtx, &this->actor, 5.0f, this->actor.world.rot.y, 1.0f); - if (this->direction != 0) { - this->actionFunc = BgHidanFwbig_Lower; - } - } - if ((this->direction != 0) && (globalCtx->roomCtx.prevRoom.num == this->actor.room)) { - this->moveState = FWBIG_KILL; - this->actionFunc = BgHidanFwbig_Lower; - } - - this->actionFunc(this, globalCtx); - - if ((this->actor.home.pos.y - 200.0f) < this->actor.world.pos.y) { - if (gSaveContext.sceneSetupIndex < 4) { - func_8002F974(&this->actor, NA_SE_EV_BURNING - SFX_FLAG); - } else if ((s16)this->actor.world.pos.x == -513) { - func_8002F974(&this->actor, NA_SE_EV_FLAME_OF_FIRE - SFX_FLAG); - } - BgHidanFwbig_MoveCollider(this, globalCtx); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void BgHidanFwbig_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - f32 height; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_fwbig.c", 630); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gEffUnknown4Tex)); - - gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gEffUnknown5Tex)); - - height = thisx->scale.y * 2400.0f; - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, - ((height - (thisx->home.pos.y - thisx->world.pos.y)) * 255.0f) / height); - - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 0x80, 0, 0x20, 0x40, 1, 0, - (u8)(globalCtx->gameplayFrames * -15), 0x20, 0x40)); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_fwbig.c", 660), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_XLU_DISP++, gFireTempleBigFireWallDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_fwbig.c", 664); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.cpp b/src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.cpp new file mode 100644 index 000000000..f4921b4f9 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.cpp @@ -0,0 +1,287 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_FWBIG_Z_BG_HIDAN_FWBIG_C +#include "actor_common.h" +/* + * File: z_bg_hidan_fwbig.c + * Overlay: ovl_Bg_Hidan_Fwbig + * Description: Large fire walls at Fire Temple (flame wall before bombable door and the one that chases the player in + * the lava room) + */ + +#include "z_bg_hidan_fwbig.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef enum { + /* 0 */ FWBIG_MOVE, + /* 1 */ FWBIG_RESET, + /* 2 */ FWBIG_KILL +} HidanFwbigMoveState; + +void BgHidanFwbig_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFwbig_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFwbig_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanFwbig_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgHidanFwbig_UpdatePosition(BgHidanFwbig* pthis); + +void BgHidanFwbig_WaitForSwitch(BgHidanFwbig* pthis, GlobalContext* globalCtx); +void BgHidanFwbig_WaitForCs(BgHidanFwbig* pthis, GlobalContext* globalCtx); +void BgHidanFwbig_Lower(BgHidanFwbig* pthis, GlobalContext* globalCtx); +void BgHidanFwbig_WaitForTimer(BgHidanFwbig* pthis, GlobalContext* globalCtx); +void BgHidanFwbig_WaitForPlayer(BgHidanFwbig* pthis, GlobalContext* globalCtx); +void BgHidanFwbig_Move(BgHidanFwbig* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Hidan_Fwbig_InitVars = { + ACTOR_BG_HIDAN_FWBIG, + ACTORCAT_PROP, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanFwbig), + (ActorFunc)BgHidanFwbig_Init, + (ActorFunc)BgHidanFwbig_Destroy, + (ActorFunc)BgHidanFwbig_Update, + (ActorFunc)BgHidanFwbig_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 30, 130, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_STOP), +}; + +void BgHidanFwbig_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgHidanFwbig* pthis = (BgHidanFwbig*)thisx; + Player* player = GET_PLAYER(globalCtx); + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->direction = (u16)(thisx->params >> 8); + thisx->params &= 0xFF; + if (pthis->direction != 0) { + pthis->actor.home.pos.x = 1560.0f; + pthis->actor.home.pos.z = 0.0f; + if (player->actor.world.pos.z > 300.0f) { + pthis->direction = -1; + pthis->actor.home.rot.y = pthis->actor.shape.rot.y = -0x4E38; + } else if (player->actor.world.pos.z < -300.0f) { + pthis->direction = 1; + pthis->actor.home.rot.y = pthis->actor.shape.rot.y = -0x31C8; + } else { + Actor_Kill(&pthis->actor); + return; + } + BgHidanFwbig_UpdatePosition(pthis); + Actor_SetScale(&pthis->actor, 0.15f); + pthis->collider.dim.height = 230; + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->moveState = FWBIG_MOVE; + pthis->actionFunc = BgHidanFwbig_WaitForPlayer; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - (2400.0f * pthis->actor.scale.y); + } else { + Actor_SetScale(&pthis->actor, 0.1f); + pthis->actionFunc = BgHidanFwbig_WaitForSwitch; + } +} + +void BgHidanFwbig_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHidanFwbig* pthis = (BgHidanFwbig*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void BgHidanFwbig_UpdatePosition(BgHidanFwbig* pthis) { + s16 startAngle = pthis->actor.shape.rot.y + pthis->direction * -0x4000; + + pthis->actor.world.pos.x = (Math_SinS(startAngle) * 885.4f) + pthis->actor.home.pos.x; + pthis->actor.world.pos.z = (Math_CosS(startAngle) * 885.4f) + pthis->actor.home.pos.z; +} + +void BgHidanFwbig_WaitForSwitch(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + pthis->actionFunc = BgHidanFwbig_WaitForCs; + OnePointCutscene_Init(globalCtx, 3340, -99, &pthis->actor, MAIN_CAM); + pthis->timer = 35; + } +} + +void BgHidanFwbig_WaitForCs(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + if (pthis->timer-- == 0) { + pthis->actionFunc = BgHidanFwbig_Lower; + } +} + +void BgHidanFwbig_Rise(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 10.0f)) { + if (pthis->direction == 0) { + Flags_UnsetSwitch(globalCtx, pthis->actor.params); + pthis->actionFunc = BgHidanFwbig_WaitForSwitch; + } else { + pthis->actionFunc = BgHidanFwbig_Move; + } + } +} + +void BgHidanFwbig_Lower(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - (2400.0f * pthis->actor.scale.y), 10.0f)) { + if (pthis->direction == 0) { + pthis->actionFunc = BgHidanFwbig_WaitForTimer; + pthis->timer = 150; + } else if (pthis->moveState == FWBIG_KILL) { + Actor_Kill(&pthis->actor); + } else { + if (pthis->moveState == FWBIG_MOVE) { + pthis->actor.shape.rot.y -= (pthis->direction * 0x1800); + } else { + pthis->moveState = FWBIG_MOVE; + pthis->actor.shape.rot.y = pthis->actor.home.rot.y; + } + BgHidanFwbig_UpdatePosition(pthis); + pthis->actionFunc = BgHidanFwbig_Rise; + } + } +} + +void BgHidanFwbig_WaitForTimer(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + pthis->actionFunc = BgHidanFwbig_Rise; + } + func_8002F994(&pthis->actor, pthis->timer); +} + +void BgHidanFwbig_WaitForPlayer(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.x < 1150.0f) { + pthis->actionFunc = BgHidanFwbig_Rise; + OnePointCutscene_Init(globalCtx, 3290, -99, &pthis->actor, MAIN_CAM); + } +} + +void BgHidanFwbig_Move(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + if (!Player_InCsMode(globalCtx)) { + if (Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y + (pthis->direction * 0x6390), 0x20)) { + pthis->moveState = FWBIG_RESET; + pthis->actionFunc = BgHidanFwbig_Lower; + } else { + BgHidanFwbig_UpdatePosition(pthis); + } + } +} + +void BgHidanFwbig_MoveCollider(BgHidanFwbig* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f projPos; + f32 cs; + f32 sn; + + func_8002DBD0(&pthis->actor, &projPos, &player->actor.world.pos); + projPos.z = ((projPos.z >= 0.0f) ? 1.0f : -1.0f) * 25.0f * -1.0f; + if (pthis->direction == 0) { + projPos.x = CLAMP(projPos.x, -360.0f, 360.0f); + } else { + projPos.x = CLAMP(projPos.x, -500.0f, 500.0f); + } + + sn = Math_SinS(pthis->actor.shape.rot.y); + cs = Math_CosS(pthis->actor.shape.rot.y); + pthis->collider.dim.pos.x = pthis->actor.world.pos.x + (projPos.x * cs) + (projPos.z * sn); + pthis->collider.dim.pos.z = pthis->actor.world.pos.z - (projPos.x * sn) + (projPos.z * cs); + pthis->collider.dim.pos.y = pthis->actor.world.pos.y; + + pthis->actor.world.rot.y = (projPos.z < 0.0f) ? pthis->actor.shape.rot.y : pthis->actor.shape.rot.y + 0x8000; +} + +void BgHidanFwbig_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHidanFwbig* pthis = (BgHidanFwbig*)thisx; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + func_8002F71C(globalCtx, &pthis->actor, 5.0f, pthis->actor.world.rot.y, 1.0f); + if (pthis->direction != 0) { + pthis->actionFunc = BgHidanFwbig_Lower; + } + } + if ((pthis->direction != 0) && (globalCtx->roomCtx.prevRoom.num == pthis->actor.room)) { + pthis->moveState = FWBIG_KILL; + pthis->actionFunc = BgHidanFwbig_Lower; + } + + pthis->actionFunc(pthis, globalCtx); + + if ((pthis->actor.home.pos.y - 200.0f) < pthis->actor.world.pos.y) { + if (gSaveContext.sceneSetupIndex < 4) { + func_8002F974(&pthis->actor, NA_SE_EV_BURNING - SFX_FLAG); + } else if ((s16)pthis->actor.world.pos.x == -513) { + func_8002F974(&pthis->actor, NA_SE_EV_FLAME_OF_FIRE - SFX_FLAG); + } + BgHidanFwbig_MoveCollider(pthis, globalCtx); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void BgHidanFwbig_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + f32 height; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_fwbig.c", 630); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gEffUnknown4Tex)); + + gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gEffUnknown5Tex)); + + height = thisx->scale.y * 2400.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, + ((height - (thisx->home.pos.y - thisx->world.pos.y)) * 255.0f) / height); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 0x80, 0, 0x20, 0x40, 1, 0, + (u8)(globalCtx->gameplayFrames * -15), 0x20, 0x40)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_fwbig.c", 660), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFireTempleBigFireWallDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_fwbig.c", 664); +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c b/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.cpp similarity index 51% rename from src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c rename to src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.cpp index 325340b65..17e325e12 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Hamstep/z_bg_hidan_hamstep.cpp @@ -26,11 +26,11 @@ void BgHidanHamstep_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHidanHamstep_Update(Actor* thisx, GlobalContext* globalCtx); void BgHidanHamstep_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808887C4(BgHidanHamstep* this, GlobalContext* globalCtx); -void func_80888860(BgHidanHamstep* this, GlobalContext* globalCtx); -void func_808889B8(BgHidanHamstep* this, GlobalContext* globalCtx); -void func_80888A58(BgHidanHamstep* this, GlobalContext* globalCtx); -void BgHidanHamstep_DoNothing(BgHidanHamstep* this, GlobalContext* globalCtx); +void func_808887C4(BgHidanHamstep* pthis, GlobalContext* globalCtx); +void func_80888860(BgHidanHamstep* pthis, GlobalContext* globalCtx); +void func_808889B8(BgHidanHamstep* pthis, GlobalContext* globalCtx); +void func_80888A58(BgHidanHamstep* pthis, GlobalContext* globalCtx); +void BgHidanHamstep_DoNothing(BgHidanHamstep* pthis, GlobalContext* globalCtx); static f32 sYPosOffsets[] = { -20.0f, -120.0f, -220.0f, -320.0f, -420.0f, @@ -74,7 +74,7 @@ static ColliderTrisInit sTrisInit = { sTrisElementsInit, }; -const ActorInit Bg_Hidan_Hamstep_InitVars = { +ActorInit Bg_Hidan_Hamstep_InitVars = { ACTOR_BG_HIDAN_HAMSTEP, ACTORCAT_BG, FLAGS, @@ -100,13 +100,13 @@ static f32 sEffectPositions[][2] = { { 0.0f, -80.0f }, { 50.0f, -80.0f }, { 100.0f, -80.0f }, }; -void BgHidanHamstep_SetupAction(BgHidanHamstep* this, s32 action) { - this->action = action; - this->actionFunc = sActionFuncs[action]; +void BgHidanHamstep_SetupAction(BgHidanHamstep* pthis, s32 action) { + pthis->action = action; + pthis->actionFunc = sActionFuncs[action]; } -s32 BgHidanHamstep_SpawnChildren(BgHidanHamstep* this, GlobalContext* globalCtx2) { - BgHidanHamstep* step = this; +s32 BgHidanHamstep_SpawnChildren(BgHidanHamstep* pthis, GlobalContext* globalCtx2) { + BgHidanHamstep* step = pthis; s32 i; Vec3f pos; f32 sin; @@ -114,20 +114,20 @@ s32 BgHidanHamstep_SpawnChildren(BgHidanHamstep* this, GlobalContext* globalCtx2 s16 params; GlobalContext* globalCtx = globalCtx2; - pos.y = this->dyna.actor.home.pos.y - 100.0f; - sin = Math_SinS(this->dyna.actor.shape.rot.y + 0x8000); - cos = Math_CosS(this->dyna.actor.shape.rot.y + 0x8000); + pos.y = pthis->dyna.actor.home.pos.y - 100.0f; + sin = Math_SinS(pthis->dyna.actor.shape.rot.y + 0x8000); + cos = Math_CosS(pthis->dyna.actor.shape.rot.y + 0x8000); for (i = 0; i < 5; i++) { - pos.x = (((i * 160.0f) + 60.0f) * sin) + this->dyna.actor.home.pos.x; - pos.z = (((i * 160.0f) + 60.0f) * cos) + this->dyna.actor.home.pos.z; + pos.x = (((i * 160.0f) + 60.0f) * sin) + pthis->dyna.actor.home.pos.x; + pos.z = (((i * 160.0f) + 60.0f) * cos) + pthis->dyna.actor.home.pos.z; params = (i + 1) & 0xFF; - params |= (this->dyna.actor.params & 0xFF00); + params |= (pthis->dyna.actor.params & 0xFF00); step = (BgHidanHamstep*)Actor_SpawnAsChild( &globalCtx->actorCtx, &step->dyna.actor, globalCtx, ACTOR_BG_HIDAN_HAMSTEP, pos.x, pos.y, pos.z, - this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, params); + pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, params); if (step == NULL) { return 0; @@ -137,7 +137,7 @@ s32 BgHidanHamstep_SpawnChildren(BgHidanHamstep* this, GlobalContext* globalCtx2 } void BgHidanHamstep_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanHamstep* this = (BgHidanHamstep*)thisx; + BgHidanHamstep* pthis = (BgHidanHamstep*)thisx; s32 pad; CollisionHeader* colHeader = NULL; Vec3f sp48[3]; @@ -145,54 +145,54 @@ void BgHidanHamstep_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i2; BgHidanHamstep* step; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); - if ((this->dyna.actor.params & 0xFF) == 0) { - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderItems); + if ((pthis->dyna.actor.params & 0xFF) == 0) { + Collider_InitTris(globalCtx, &pthis->collider); + Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInit, pthis->colliderItems); for (i = 0; i < 2; i++) { for (i2 = 0; i2 < 3; i2++) { - sp48[i2].x = sTrisInit.elements[i].dim.vtx[i2].x + this->dyna.actor.home.pos.x; - sp48[i2].y = sTrisInit.elements[i].dim.vtx[i2].y + this->dyna.actor.home.pos.y; - sp48[i2].z = sTrisInit.elements[i].dim.vtx[i2].z + this->dyna.actor.home.pos.z; + sp48[i2].x = sTrisInit.elements[i].dim.vtx[i2].x + pthis->dyna.actor.home.pos.x; + sp48[i2].y = sTrisInit.elements[i].dim.vtx[i2].y + pthis->dyna.actor.home.pos.y; + sp48[i2].z = sTrisInit.elements[i].dim.vtx[i2].z + pthis->dyna.actor.home.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &sp48[0], &sp48[1], &sp48[2]); + Collider_SetTrisVertices(&pthis->collider, i, &sp48[0], &sp48[1], &sp48[2]); } } - if ((this->dyna.actor.params & 0xFF) == 0) { + if ((pthis->dyna.actor.params & 0xFF) == 0) { CollisionHeader_GetVirtual(&gFireTempleStoneStep1Col, &colHeader); } else { CollisionHeader_GetVirtual(&gFireTempleStoneStep2Col, &colHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0xFF)) { - if ((this->dyna.actor.params & 0xFF) == 0) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + (-20.0f); - BgHidanHamstep_SetupAction(this, 4); + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0xFF)) { + if ((pthis->dyna.actor.params & 0xFF) == 0) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + (-20.0f); + BgHidanHamstep_SetupAction(pthis, 4); } else { - this->dyna.actor.world.pos.y = - sYPosOffsets[(this->dyna.actor.params & 0xFF) - 1] + this->dyna.actor.home.pos.y; - BgHidanHamstep_SetupAction(this, 4); + pthis->dyna.actor.world.pos.y = + sYPosOffsets[(pthis->dyna.actor.params & 0xFF) - 1] + pthis->dyna.actor.home.pos.y; + BgHidanHamstep_SetupAction(pthis, 4); } - } else if ((this->dyna.actor.params & 0xFF) == 0) { - BgHidanHamstep_SetupAction(this, 0); + } else if ((pthis->dyna.actor.params & 0xFF) == 0) { + BgHidanHamstep_SetupAction(pthis, 0); } else { - BgHidanHamstep_SetupAction(this, 2); + BgHidanHamstep_SetupAction(pthis, 2); } - this->dyna.actor.gravity = -1.2f; - this->dyna.actor.minVelocityY = -12.0f; + pthis->dyna.actor.gravity = -1.2f; + pthis->dyna.actor.minVelocityY = -12.0f; - if ((this->dyna.actor.params & 0xFF) == 0) { + if ((pthis->dyna.actor.params & 0xFF) == 0) { // "Fire Temple Object [Hammer Step] appears" osSyncPrintf("◯◯◯炎の神殿オブジェクト【ハンマーステップ】出現\n"); - if (BgHidanHamstep_SpawnChildren(this, globalCtx) == 0) { - step = this; + if (BgHidanHamstep_SpawnChildren(pthis, globalCtx) == 0) { + step = pthis; // "[Hammer Step] I can't create a step!" osSyncPrintf("【ハンマーステップ】 足場産れない!!\n"); @@ -207,12 +207,12 @@ void BgHidanHamstep_Init(Actor* thisx, GlobalContext* globalCtx) { } void BgHidanHamstep_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanHamstep* this = (BgHidanHamstep*)thisx; + BgHidanHamstep* pthis = (BgHidanHamstep*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); - if ((this->dyna.actor.params & 0xFF) == 0) { - Collider_DestroyTris(globalCtx, &this->collider); + if ((pthis->dyna.actor.params & 0xFF) == 0) { + Collider_DestroyTris(globalCtx, &pthis->collider); } } @@ -238,8 +238,8 @@ void func_808884C8(BgHidanHamstep* step, GlobalContext* globalCtx) { } } -void func_80888638(BgHidanHamstep* this, GlobalContext* globalCtx) { - BgHidanHamstep* child = (BgHidanHamstep*)this->dyna.actor.child; +void func_80888638(BgHidanHamstep* pthis, GlobalContext* globalCtx) { + BgHidanHamstep* child = (BgHidanHamstep*)pthis->dyna.actor.child; while (child != NULL) { if ((child->dyna.actor.params & 0xFF) != 0) { @@ -249,161 +249,161 @@ void func_80888638(BgHidanHamstep* this, GlobalContext* globalCtx) { } } -void func_80888694(BgHidanHamstep* this, BgHidanHamstep* parent) { +void func_80888694(BgHidanHamstep* pthis, BgHidanHamstep* parent) { BgHidanHamstep* child; - if ((this->dyna.actor.params & 0xFF) >= 2) { - if (parent->dyna.actor.world.pos.y < this->dyna.actor.world.pos.y) { - this->dyna.actor.world.pos.y = parent->dyna.actor.world.pos.y; - } else if ((this->dyna.actor.world.pos.y - parent->dyna.actor.world.pos.y) < -100.0f) { - this->dyna.actor.world.pos.y = parent->dyna.actor.world.pos.y - 100.0f; + if ((pthis->dyna.actor.params & 0xFF) >= 2) { + if (parent->dyna.actor.world.pos.y < pthis->dyna.actor.world.pos.y) { + pthis->dyna.actor.world.pos.y = parent->dyna.actor.world.pos.y; + } else if ((pthis->dyna.actor.world.pos.y - parent->dyna.actor.world.pos.y) < -100.0f) { + pthis->dyna.actor.world.pos.y = parent->dyna.actor.world.pos.y - 100.0f; } } - child = (BgHidanHamstep*)this->dyna.actor.child; + child = (BgHidanHamstep*)pthis->dyna.actor.child; while (child != NULL) { - if (this->dyna.actor.world.pos.y < child->dyna.actor.world.pos.y) { - child->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y; + if (pthis->dyna.actor.world.pos.y < child->dyna.actor.world.pos.y) { + child->dyna.actor.world.pos.y = pthis->dyna.actor.world.pos.y; } child = (BgHidanHamstep*)child->dyna.actor.child; } } -void func_80888734(BgHidanHamstep* this) { - BgHidanHamstep* parent = (BgHidanHamstep*)this->dyna.actor.parent; +void func_80888734(BgHidanHamstep* pthis) { + BgHidanHamstep* parent = (BgHidanHamstep*)pthis->dyna.actor.parent; f32 frameDivisor = R_UPDATE_RATE * 0.5f; if (parent != NULL) { - this->dyna.actor.velocity.y = parent->dyna.actor.velocity.y; + pthis->dyna.actor.velocity.y = parent->dyna.actor.velocity.y; - if ((this->dyna.actor.params & 0xFF) == 1) { - this->dyna.actor.world.pos.y = parent->dyna.actor.world.pos.y - 100.0f; + if ((pthis->dyna.actor.params & 0xFF) == 1) { + pthis->dyna.actor.world.pos.y = parent->dyna.actor.world.pos.y - 100.0f; } else { - this->dyna.actor.world.pos.y += (this->dyna.actor.velocity.y * frameDivisor); + pthis->dyna.actor.world.pos.y += (pthis->dyna.actor.velocity.y * frameDivisor); } - func_80888694(this, parent); + func_80888694(pthis, parent); } } -void func_808887C4(BgHidanHamstep* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - OnePointCutscene_Init(globalCtx, 3310, 100, &this->dyna.actor, MAIN_CAM); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_HAMMER_SWITCH); - this->collider.base.acFlags = AC_NONE; - BgHidanHamstep_SetupAction(this, 1); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0xFF); +void func_808887C4(BgHidanHamstep* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + OnePointCutscene_Init(globalCtx, 3310, 100, &pthis->dyna.actor, MAIN_CAM); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_HAMMER_SWITCH); + pthis->collider.base.acFlags = AC_NONE; + BgHidanHamstep_SetupAction(pthis, 1); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0xFF); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void func_80888860(BgHidanHamstep* this, GlobalContext* globalCtx) { +void func_80888860(BgHidanHamstep* pthis, GlobalContext* globalCtx) { s32 pad; s32 pad2; s32 quakeIndex; - Actor_MoveForward(&this->dyna.actor); + Actor_MoveForward(&pthis->dyna.actor); - if (((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) < (-20.0f - this->dyna.actor.minVelocityY)) && - (this->dyna.actor.velocity.y <= 0.0f)) { - this->unk_244++; + if (((pthis->dyna.actor.world.pos.y - pthis->dyna.actor.home.pos.y) < (-20.0f - pthis->dyna.actor.minVelocityY)) && + (pthis->dyna.actor.velocity.y <= 0.0f)) { + pthis->unk_244++; - if (this->unk_244 >= 7) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + -20.0f; - BgHidanHamstep_SetupAction(this, 4); + if (pthis->unk_244 >= 7) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + -20.0f; + BgHidanHamstep_SetupAction(pthis, 4); } else { - this->dyna.actor.velocity.y *= -0.24f; + pthis->dyna.actor.velocity.y *= -0.24f; if (1) {} - if (this->unk_244 == 1) { + if (pthis->unk_244 == 1) { quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quakeIndex, -15536); Quake_SetQuakeValues(quakeIndex, 0, 0, 500, 0); Quake_SetCountdown(quakeIndex, 20); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 255, 20, 150); - func_80888638(this, globalCtx); - osSyncPrintf("A(%d)\n", this->dyna.actor.params); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 255, 20, 150); + func_80888638(pthis, globalCtx); + osSyncPrintf("A(%d)\n", pthis->dyna.actor.params); } } } } -void func_808889B8(BgHidanHamstep* this, GlobalContext* globalCtx) { +void func_808889B8(BgHidanHamstep* pthis, GlobalContext* globalCtx) { s32 pad; - BgHidanHamstep* parent = (BgHidanHamstep*)this->dyna.actor.parent; + BgHidanHamstep* parent = (BgHidanHamstep*)pthis->dyna.actor.parent; - func_80888734(this); + func_80888734(pthis); if ((parent->action == 4) || ((parent->action == 3) && (parent->unk_244 >= 5))) { - if ((this->dyna.actor.params & 0xFF) == 1) { - this->dyna.actor.world.pos.y = - sYPosOffsets[(this->dyna.actor.params & 0xFF) - 1] + this->dyna.actor.home.pos.y; - BgHidanHamstep_SetupAction(this, 4); + if ((pthis->dyna.actor.params & 0xFF) == 1) { + pthis->dyna.actor.world.pos.y = + sYPosOffsets[(pthis->dyna.actor.params & 0xFF) - 1] + pthis->dyna.actor.home.pos.y; + BgHidanHamstep_SetupAction(pthis, 4); } else { - BgHidanHamstep_SetupAction(this, 3); + BgHidanHamstep_SetupAction(pthis, 3); } } } -void func_80888A58(BgHidanHamstep* this, GlobalContext* globalCtx) { +void func_80888A58(BgHidanHamstep* pthis, GlobalContext* globalCtx) { s32 pad; s32 pad2; s32 quakeIndex; - Actor_MoveForward(&this->dyna.actor); - func_80888694(this, (BgHidanHamstep*)this->dyna.actor.parent); + Actor_MoveForward(&pthis->dyna.actor); + func_80888694(pthis, (BgHidanHamstep*)pthis->dyna.actor.parent); - if (((this->dyna.actor.params & 0xFF) <= 0) || ((this->dyna.actor.params & 0xFF) >= 6)) { + if (((pthis->dyna.actor.params & 0xFF) <= 0) || ((pthis->dyna.actor.params & 0xFF) >= 6)) { // "[Hammer Step] arg_data strange (arg_data = %d)" - osSyncPrintf("【ハンマーステップ】 arg_data おかしい (arg_data = %d)", this->dyna.actor.params); + osSyncPrintf("【ハンマーステップ】 arg_data おかしい (arg_data = %d)", pthis->dyna.actor.params); osSyncPrintf("%s %d\n", "../z_bg_hidan_hamstep.c", 696); } - if (((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) <= - sYPosOffsets[(this->dyna.actor.params & 0xFF) - 1]) && - (this->dyna.actor.velocity.y <= 0.0f)) { - this->unk_244++; + if (((pthis->dyna.actor.world.pos.y - pthis->dyna.actor.home.pos.y) <= + sYPosOffsets[(pthis->dyna.actor.params & 0xFF) - 1]) && + (pthis->dyna.actor.velocity.y <= 0.0f)) { + pthis->unk_244++; - if (this->unk_244 >= 7) { - this->dyna.actor.world.pos.y = - sYPosOffsets[(this->dyna.actor.params & 0xFF) - 1] + this->dyna.actor.home.pos.y; - BgHidanHamstep_SetupAction(this, 3); + if (pthis->unk_244 >= 7) { + pthis->dyna.actor.world.pos.y = + sYPosOffsets[(pthis->dyna.actor.params & 0xFF) - 1] + pthis->dyna.actor.home.pos.y; + BgHidanHamstep_SetupAction(pthis, 3); } else { - this->dyna.actor.velocity.y *= -0.24f; + pthis->dyna.actor.velocity.y *= -0.24f; if (1) {} - if (this->unk_244 == 1) { + if (pthis->unk_244 == 1) { quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quakeIndex, -15536); Quake_SetQuakeValues(quakeIndex, 20, 1, 0, 0); Quake_SetCountdown(quakeIndex, 7); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); func_800AA000(10000.0f, 255, 20, 150); - func_808884C8(this, globalCtx); + func_808884C8(pthis, globalCtx); - if ((this->dyna.actor.params & 0xFF) == 5) { + if ((pthis->dyna.actor.params & 0xFF) == 5) { func_80078884(NA_SE_SY_CORRECT_CHIME); } - osSyncPrintf("B(%d)\n", this->dyna.actor.params); + osSyncPrintf("B(%d)\n", pthis->dyna.actor.params); } } } } -void BgHidanHamstep_DoNothing(BgHidanHamstep* this, GlobalContext* globalCtx) { +void BgHidanHamstep_DoNothing(BgHidanHamstep* pthis, GlobalContext* globalCtx) { } void BgHidanHamstep_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanHamstep* this = (BgHidanHamstep*)thisx; + BgHidanHamstep* pthis = (BgHidanHamstep*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgHidanHamstep_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Hidan_Hrock/z_bg_hidan_hrock.c b/src/overlays/actors/ovl_Bg_Hidan_Hrock/z_bg_hidan_hrock.cpp similarity index 57% rename from src/overlays/actors/ovl_Bg_Hidan_Hrock/z_bg_hidan_hrock.c rename to src/overlays/actors/ovl_Bg_Hidan_Hrock/z_bg_hidan_hrock.cpp index 39b7104fe..50decd67a 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Hrock/z_bg_hidan_hrock.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Hrock/z_bg_hidan_hrock.cpp @@ -23,11 +23,11 @@ void BgHidanHrock_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHidanHrock_Update(Actor* thisx, GlobalContext* globalCtx); void BgHidanHrock_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8088960C(BgHidanHrock* this, GlobalContext* globalCtx); -void func_808896B8(BgHidanHrock* this, GlobalContext* globalCtx); -void func_808894A4(BgHidanHrock* this, GlobalContext* globalCtx); +void func_8088960C(BgHidanHrock* pthis, GlobalContext* globalCtx); +void func_808896B8(BgHidanHrock* pthis, GlobalContext* globalCtx); +void func_808894A4(BgHidanHrock* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Hidan_Hrock_InitVars = { +ActorInit Bg_Hidan_Hrock_InitVars = { ACTOR_BG_HIDAN_HROCK, ACTORCAT_BG, FLAGS, @@ -83,7 +83,7 @@ static InitChainEntry sInitChain[] = { }; void BgHidanHrock_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanHrock* this = (BgHidanHrock*)thisx; + BgHidanHrock* pthis = (BgHidanHrock*)thisx; ColliderTrisElementInit* colliderElementInit; Vec3f vertices[3]; f32 cosRotY; @@ -93,11 +93,11 @@ void BgHidanHrock_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionHeader* collisionHeader = NULL; Actor_ProcessInitChain(thisx, sInitChain); - this->unk_16A = thisx->params & 0x3F; + pthis->unk_16A = thisx->params & 0x3F; thisx->params = (thisx->params >> 8) & 0xFF; - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, thisx, &sTrisInit, this->colliderItems); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Collider_InitTris(globalCtx, &pthis->collider); + Collider_SetTris(globalCtx, &pthis->collider, thisx, &sTrisInit, pthis->colliderItems); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); sinRotY = Math_SinS(thisx->shape.rot.y); cosRotY = Math_CosS(thisx->shape.rot.y); @@ -119,11 +119,11 @@ void BgHidanHrock_Init(Actor* thisx, GlobalContext* globalCtx) { vertices[j].z = vtx->z * cosRotY + (thisx->home.pos.z - vtx->x * sinRotY); } } - Collider_SetTrisVertices(&this->collider, i, &vertices[0], &vertices[1], &vertices[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vertices[0], &vertices[1], &vertices[2]); } - if (Flags_GetSwitch(globalCtx, this->unk_16A)) { - this->actionFunc = func_808894A4; + if (Flags_GetSwitch(globalCtx, pthis->unk_16A)) { + pthis->actionFunc = func_808894A4; if (thisx->params == 0) { thisx->world.pos.y -= 2800.0f; thisx->uncullZoneForward = 3000.0f; @@ -137,7 +137,7 @@ void BgHidanHrock_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; thisx->uncullZoneForward = 3000.0f; } - this->actionFunc = func_808896B8; + pthis->actionFunc = func_808896B8; } if (thisx->params == 0) { @@ -146,95 +146,95 @@ void BgHidanHrock_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionHeader_GetVirtual(&gFireTemplePillarInsertedInGroundCol, &collisionHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, collisionHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, collisionHeader); } void BgHidanHrock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanHrock* this = (BgHidanHrock*)thisx; + BgHidanHrock* pthis = (BgHidanHrock*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyTris(globalCtx, &pthis->collider); } -void func_808894A4(BgHidanHrock* this, GlobalContext* globalCtx) { +void func_808894A4(BgHidanHrock* pthis, GlobalContext* globalCtx) { } -void func_808894B0(BgHidanHrock* this, GlobalContext* globalCtx) { - if (this->unk_168 != 0) { - this->unk_168--; +void func_808894B0(BgHidanHrock* pthis, GlobalContext* globalCtx) { + if (pthis->unk_168 != 0) { + pthis->unk_168--; } - this->dyna.actor.world.pos.x = - (Math_SinS(this->dyna.actor.world.rot.y + (this->unk_168 << 0xE)) * 5.0f) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = - (Math_CosS(this->dyna.actor.world.rot.y + (this->unk_168 << 0xE)) * 5.0f) + this->dyna.actor.home.pos.z; + pthis->dyna.actor.world.pos.x = + (Math_SinS(pthis->dyna.actor.world.rot.y + (pthis->unk_168 << 0xE)) * 5.0f) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = + (Math_CosS(pthis->dyna.actor.world.rot.y + (pthis->unk_168 << 0xE)) * 5.0f) + pthis->dyna.actor.home.pos.z; - if (!(this->unk_168 % 4)) { - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 180, 10, 100); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE); + if (!(pthis->unk_168 % 4)) { + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 180, 10, 100); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_SHAKE); } - if (this->unk_168 == 0) { - if (this->dyna.actor.params == 0) { - this->dyna.actor.home.pos.y -= 2800.0f; - } else if (this->dyna.actor.params == 1) { - this->dyna.actor.home.pos.y -= 800.0f; + if (pthis->unk_168 == 0) { + if (pthis->dyna.actor.params == 0) { + pthis->dyna.actor.home.pos.y -= 2800.0f; + } else if (pthis->dyna.actor.params == 1) { + pthis->dyna.actor.home.pos.y -= 800.0f; } else { - this->dyna.actor.home.pos.y -= 240.0f; + pthis->dyna.actor.home.pos.y -= 240.0f; } - this->actionFunc = func_8088960C; - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; + pthis->actionFunc = func_8088960C; + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z; } } -void func_8088960C(BgHidanHrock* this, GlobalContext* globalCtx) { - this->dyna.actor.velocity.y++; +void func_8088960C(BgHidanHrock* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.velocity.y++; - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { - this->dyna.actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_5); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.velocity.y)) { + pthis->dyna.actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_5); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); - if (this->dyna.actor.params == 0) { + if (pthis->dyna.actor.params == 0) { if (globalCtx->roomCtx.curRoom.num == 10) { - this->dyna.actor.room = 10; + pthis->dyna.actor.room = 10; } else { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } - this->actionFunc = func_808894A4; + pthis->actionFunc = func_808894A4; } } -void func_808896B8(BgHidanHrock* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & 2) { - this->collider.base.acFlags &= ~2; - this->actionFunc = func_808894B0; - this->dyna.actor.flags |= ACTOR_FLAG_4; +void func_808896B8(BgHidanHrock* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & 2) { + pthis->collider.base.acFlags &= ~2; + pthis->actionFunc = func_808894B0; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; - if (this->dyna.actor.params == 0) { - this->dyna.actor.room = -1; + if (pthis->dyna.actor.params == 0) { + pthis->dyna.actor.room = -1; } - this->unk_168 = 20; - Flags_SetSwitch(globalCtx, this->unk_16A); + pthis->unk_168 = 20; + Flags_SetSwitch(globalCtx, pthis->unk_16A); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - if (func_8004356C(&this->dyna)) { - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 5.0f, 1.0f); + if (func_8004356C(&pthis->dyna)) { + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 5.0f, 1.0f); } else { - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f); + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 1.0f); } } void BgHidanHrock_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanHrock* this = (BgHidanHrock*)thisx; + BgHidanHrock* pthis = (BgHidanHrock*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgHidanHrock_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c deleted file mode 100644 index 533cc6b13..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c +++ /dev/null @@ -1,172 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_KOUSI_Z_BG_HIDAN_KOUSI_C -#include "actor_common.h" -/* - * File: z_bg_hidan_kousi.c - * Overlay: ovl_Bg_Hidan_Kousi - * Description: - */ - -#include "z_bg_hidan_kousi.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgHidanKousi_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanKousi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanKousi_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanKousi_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80889ACC(BgHidanKousi* this); -void func_80889B5C(BgHidanKousi* this, GlobalContext* globalCtx); -void func_80889BC0(BgHidanKousi* this, GlobalContext* globalCtx); -void func_80889C18(BgHidanKousi* this, GlobalContext* globalCtx); -void func_80889C90(BgHidanKousi* this, GlobalContext* globalCtx); -void func_80889D28(BgHidanKousi* this, GlobalContext* globalCtx); - -static f32 D_80889E40[] = { 120.0f, 150.0f, 150.0f }; - -const ActorInit Bg_Hidan_Kousi_InitVars = { - ACTOR_BG_HIDAN_KOUSI, - ACTORCAT_PROP, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanKousi), - (ActorFunc)BgHidanKousi_Init, - (ActorFunc)BgHidanKousi_Destroy, - (ActorFunc)BgHidanKousi_Update, - (ActorFunc)BgHidanKousi_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -static CollisionHeader* sMetalFencesCollisions[] = { - &gFireTempleMetalFenceWithSlantCol, - &gFireTempleMetalFenceCol, - &gFireTempleMetalFence2Col, -}; - -static s16 D_80889E7C[] = { - 0x4000, - 0xC000, - 0xC000, - 0x0000, -}; - -static Gfx* sMetalFencesDLs[] = { - gFireTempleMetalFenceWithSlantDL, - gFireTempleMetalFenceDL, - gFireTempleMetalFence2DL, -}; - -void BgHidanKousi_SetupAction(BgHidanKousi* this, BgHidanKousiActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void BgHidanKousi_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKousi* this = (BgHidanKousi*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - Actor_SetFocus(thisx, 50.0f); - osSyncPrintf("◯◯◯炎の神殿オブジェクト【格子(arg_data : %0x)】出現 (%d %d)\n", thisx->params, thisx->params & 0xFF, - ((s32)thisx->params >> 8) & 0xFF); - - Actor_ProcessInitChain(thisx, sInitChain); - if (((thisx->params & 0xFF) < 0) || ((thisx->params & 0xFF) >= 3)) { - osSyncPrintf("arg_data おかしい 【格子】\n"); - } - - CollisionHeader_GetVirtual(sMetalFencesCollisions[thisx->params & 0xFF], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - thisx->world.rot.y = D_80889E7C[this->dyna.actor.params & 0xFF] + thisx->shape.rot.y; - if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0xFF)) { - func_80889ACC(this); - BgHidanKousi_SetupAction(this, func_80889D28); - } else { - BgHidanKousi_SetupAction(this, func_80889B5C); - } -} - -void BgHidanKousi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKousi* this = (BgHidanKousi*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80889ACC(BgHidanKousi* this) { - s32 pad[2]; - Vec3s* rot = &this->dyna.actor.world.rot; - f32 temp1 = D_80889E40[this->dyna.actor.params & 0xFF] * Math_SinS(rot->y); - f32 temp2 = D_80889E40[this->dyna.actor.params & 0xFF] * Math_CosS(rot->y); - - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + temp1; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp2; -} - -void func_80889B5C(BgHidanKousi* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0xFF)) { - BgHidanKousi_SetupAction(this, func_80889BC0); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->unk_168 = 0xC8; - } -} - -void func_80889BC0(BgHidanKousi* this, GlobalContext* globalCtx) { - this->unk_168 -= 1; - if (this->dyna.actor.category == func_8005B198() || (this->unk_168 <= 0)) { - BgHidanKousi_SetupAction(this, func_80889C18); - } -} - -void func_80889C18(BgHidanKousi* this, GlobalContext* globalCtx) { - this->dyna.actor.speedXZ += 0.2f; - if (this->dyna.actor.speedXZ > 2.0f) { - this->dyna.actor.speedXZ = 2.0f; - BgHidanKousi_SetupAction(this, func_80889C90); - } - Actor_MoveForward(&this->dyna.actor); - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); -} - -void func_80889C90(BgHidanKousi* this, GlobalContext* globalCtx) { - func_8002D7EC(&this->dyna.actor); - if (D_80889E40[this->dyna.actor.params & 0xFF] < - Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &this->dyna.actor.world.pos)) { - func_80889ACC(this); - BgHidanKousi_SetupAction(this, func_80889D28); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); - } -} - -void func_80889D28(BgHidanKousi* this, GlobalContext* globalCtx) { -} - -void BgHidanKousi_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKousi* this = (BgHidanKousi*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgHidanKousi_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_kousi.c", 350); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_kousi.c", 354), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sMetalFencesDLs[thisx->params & 0xFF]); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_kousi.c", 359); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp new file mode 100644 index 000000000..7f41f6515 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp @@ -0,0 +1,172 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_KOUSI_Z_BG_HIDAN_KOUSI_C +#include "actor_common.h" +/* + * File: z_bg_hidan_kousi.c + * Overlay: ovl_Bg_Hidan_Kousi + * Description: + */ + +#include "z_bg_hidan_kousi.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgHidanKousi_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanKousi_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanKousi_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanKousi_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80889ACC(BgHidanKousi* pthis); +void func_80889B5C(BgHidanKousi* pthis, GlobalContext* globalCtx); +void func_80889BC0(BgHidanKousi* pthis, GlobalContext* globalCtx); +void func_80889C18(BgHidanKousi* pthis, GlobalContext* globalCtx); +void func_80889C90(BgHidanKousi* pthis, GlobalContext* globalCtx); +void func_80889D28(BgHidanKousi* pthis, GlobalContext* globalCtx); + +static f32 D_80889E40[] = { 120.0f, 150.0f, 150.0f }; + +ActorInit Bg_Hidan_Kousi_InitVars = { + ACTOR_BG_HIDAN_KOUSI, + ACTORCAT_PROP, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanKousi), + (ActorFunc)BgHidanKousi_Init, + (ActorFunc)BgHidanKousi_Destroy, + (ActorFunc)BgHidanKousi_Update, + (ActorFunc)BgHidanKousi_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +static CollisionHeader* sMetalFencesCollisions[] = { + &gFireTempleMetalFenceWithSlantCol, + &gFireTempleMetalFenceCol, + &gFireTempleMetalFence2Col, +}; + +static s16 D_80889E7C[] = { + 0x4000, + 0xC000, + 0xC000, + 0x0000, +}; + +static Gfx* sMetalFencesDLs[] = { + gFireTempleMetalFenceWithSlantDL, + gFireTempleMetalFenceDL, + gFireTempleMetalFence2DL, +}; + +void BgHidanKousi_SetupAction(BgHidanKousi* pthis, BgHidanKousiActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void BgHidanKousi_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHidanKousi* pthis = (BgHidanKousi*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + Actor_SetFocus(thisx, 50.0f); + osSyncPrintf("◯◯◯炎の神殿オブジェクト【格子(arg_data : %0x)】出現 (%d %d)\n", thisx->params, thisx->params & 0xFF, + ((s32)thisx->params >> 8) & 0xFF); + + Actor_ProcessInitChain(thisx, sInitChain); + if (((thisx->params & 0xFF) < 0) || ((thisx->params & 0xFF) >= 3)) { + osSyncPrintf("arg_data おかしい 【格子】\n"); + } + + CollisionHeader_GetVirtual(sMetalFencesCollisions[thisx->params & 0xFF], &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + thisx->world.rot.y = D_80889E7C[pthis->dyna.actor.params & 0xFF] + thisx->shape.rot.y; + if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0xFF)) { + func_80889ACC(pthis); + BgHidanKousi_SetupAction(pthis, func_80889D28); + } else { + BgHidanKousi_SetupAction(pthis, func_80889B5C); + } +} + +void BgHidanKousi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanKousi* pthis = (BgHidanKousi*)thisx; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80889ACC(BgHidanKousi* pthis) { + s32 pad[2]; + Vec3s* rot = &pthis->dyna.actor.world.rot; + f32 temp1 = D_80889E40[pthis->dyna.actor.params & 0xFF] * Math_SinS(rot->y); + f32 temp2 = D_80889E40[pthis->dyna.actor.params & 0xFF] * Math_CosS(rot->y); + + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x + temp1; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z + temp2; +} + +void func_80889B5C(BgHidanKousi* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0xFF)) { + BgHidanKousi_SetupAction(pthis, func_80889BC0); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->unk_168 = 0xC8; + } +} + +void func_80889BC0(BgHidanKousi* pthis, GlobalContext* globalCtx) { + pthis->unk_168 -= 1; + if (pthis->dyna.actor.category == func_8005B198() || (pthis->unk_168 <= 0)) { + BgHidanKousi_SetupAction(pthis, func_80889C18); + } +} + +void func_80889C18(BgHidanKousi* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.speedXZ += 0.2f; + if (pthis->dyna.actor.speedXZ > 2.0f) { + pthis->dyna.actor.speedXZ = 2.0f; + BgHidanKousi_SetupAction(pthis, func_80889C90); + } + Actor_MoveForward(&pthis->dyna.actor); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); +} + +void func_80889C90(BgHidanKousi* pthis, GlobalContext* globalCtx) { + func_8002D7EC(&pthis->dyna.actor); + if (D_80889E40[pthis->dyna.actor.params & 0xFF] < + Math_Vec3f_DistXYZ(&pthis->dyna.actor.home.pos, &pthis->dyna.actor.world.pos)) { + func_80889ACC(pthis); + BgHidanKousi_SetupAction(pthis, func_80889D28); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_STOP); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); + } +} + +void func_80889D28(BgHidanKousi* pthis, GlobalContext* globalCtx) { +} + +void BgHidanKousi_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHidanKousi* pthis = (BgHidanKousi*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgHidanKousi_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_kousi.c", 350); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_kousi.c", 354), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sMetalFencesDLs[thisx->params & 0xFF]); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_kousi.c", 359); +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/z_bg_hidan_kowarerukabe.c b/src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/z_bg_hidan_kowarerukabe.cpp similarity index 66% rename from src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/z_bg_hidan_kowarerukabe.c rename to src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/z_bg_hidan_kowarerukabe.cpp index 7bee5cf98..04b368c47 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/z_bg_hidan_kowarerukabe.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Kowarerukabe/z_bg_hidan_kowarerukabe.cpp @@ -34,7 +34,7 @@ void BgHidanKowarerukabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHidanKowarerukabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgHidanKowarerukabe_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Hidan_Kowarerukabe_InitVars = { +ActorInit Bg_Hidan_Kowarerukabe_InitVars = { ACTOR_BG_HIDAN_KOWARERUKABE, ACTORCAT_BG, FLAGS, @@ -79,7 +79,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -void BgHidanKowarerukabe_InitDynaPoly(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { +void BgHidanKowarerukabe_InitDynaPoly(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { static CollisionHeader* collisionHeaders[] = { &gFireTempleCrackedStoneFloorCol, &gFireTempleBombableWallCol, @@ -89,31 +89,31 @@ void BgHidanKowarerukabe_InitDynaPoly(BgHidanKowarerukabe* this, GlobalContext* CollisionHeader* colHeader = NULL; s32 pad2; - if (collisionHeaders[this->dyna.actor.params & 0xFF] != NULL) { - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(collisionHeaders[this->dyna.actor.params & 0xFF], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + if (collisionHeaders[pthis->dyna.actor.params & 0xFF] != NULL) { + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(collisionHeaders[pthis->dyna.actor.params & 0xFF], &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } else { - this->dyna.bgId = BGACTOR_NEG_ONE; + pthis->dyna.bgId = BGACTOR_NEG_ONE; } } -void BgHidanKowarerukabe_InitColliderSphere(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { +void BgHidanKowarerukabe_InitColliderSphere(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { static s16 sphereRadii[] = { 80, 45, 80 }; static s16 sphereYPositions[] = { 0, 500, 500 }; s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderItems); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->colliderItems); - this->collider.elements[0].dim.modelSphere.radius = sphereRadii[this->dyna.actor.params & 0xFF]; - this->collider.elements[0].dim.modelSphere.center.y = sphereYPositions[this->dyna.actor.params & 0xFF]; + pthis->collider.elements[0].dim.modelSphere.radius = sphereRadii[pthis->dyna.actor.params & 0xFF]; + pthis->collider.elements[0].dim.modelSphere.center.y = sphereYPositions[pthis->dyna.actor.params & 0xFF]; } -void BgHidanKowarerukabe_OffsetActorYPos(BgHidanKowarerukabe* this) { +void BgHidanKowarerukabe_OffsetActorYPos(BgHidanKowarerukabe* pthis) { static f32 actorYPosOffsets[] = { 0.7f, 0.0f, 0.0f }; - this->dyna.actor.world.pos.y = actorYPosOffsets[this->dyna.actor.params & 0xFF] + this->dyna.actor.home.pos.y; + pthis->dyna.actor.world.pos.y = actorYPosOffsets[pthis->dyna.actor.params & 0xFF] + pthis->dyna.actor.home.pos.y; } static InitChainEntry sInitChain[] = { @@ -123,62 +123,62 @@ static InitChainEntry sInitChain[] = { }; void BgHidanKowarerukabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKowarerukabe* this = (BgHidanKowarerukabe*)thisx; + BgHidanKowarerukabe* pthis = (BgHidanKowarerukabe*)thisx; - BgHidanKowarerukabe_InitDynaPoly(this, globalCtx); + BgHidanKowarerukabe_InitDynaPoly(pthis, globalCtx); - if (((this->dyna.actor.params & 0xFF) < CRACKED_STONE_FLOOR) || - ((this->dyna.actor.params & 0xFF) > LARGE_BOMBABLE_WALL)) { + if (((pthis->dyna.actor.params & 0xFF) < CRACKED_STONE_FLOOR) || + ((pthis->dyna.actor.params & 0xFF) > LARGE_BOMBABLE_WALL)) { // "Error: Fire Temple Breakable Walls. arg_data I can't determine the (%s %d)(arg_data 0x%04x)" osSyncPrintf("Error : 炎の神殿 壊れる壁 の arg_data が判別出来ない(%s %d)(arg_data 0x%04x)\n", - "../z_bg_hidan_kowarerukabe.c", 254, this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); + "../z_bg_hidan_kowarerukabe.c", 254, pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); return; } - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - Actor_Kill(&this->dyna.actor); + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + Actor_Kill(&pthis->dyna.actor); return; } - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Actor_SetScale(&this->dyna.actor, 0.1f); - BgHidanKowarerukabe_InitColliderSphere(this, globalCtx); - BgHidanKowarerukabe_OffsetActorYPos(this); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + Actor_SetScale(&pthis->dyna.actor, 0.1f); + BgHidanKowarerukabe_InitColliderSphere(pthis, globalCtx); + BgHidanKowarerukabe_OffsetActorYPos(pthis); // "(fire walls, floors, destroyed by bombs)(arg_data 0x%04x)" - osSyncPrintf("(hidan 爆弾で壊れる 壁 床)(arg_data 0x%04x)\n", this->dyna.actor.params); + osSyncPrintf("(hidan 爆弾で壊れる 壁 床)(arg_data 0x%04x)\n", pthis->dyna.actor.params); } void BgHidanKowarerukabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKowarerukabe* this = (BgHidanKowarerukabe*)thisx; + BgHidanKowarerukabe* pthis = (BgHidanKowarerukabe*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void BgHidanKowarerukabe_SpawnDust(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { +void BgHidanKowarerukabe_SpawnDust(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { s32 pad; Vec3f pos; - pos = this->dyna.actor.world.pos; + pos = pthis->dyna.actor.world.pos; pos.y += 10.0f; func_80033480(globalCtx, &pos, 0.0f, 0, 600, 300, 1); - pos.x = ((Rand_ZeroOne() - 0.5f) * 80.0f) + this->dyna.actor.world.pos.x; - pos.y = (Rand_ZeroOne() * 100.0f) + this->dyna.actor.world.pos.y; - pos.z = ((Rand_ZeroOne() - 0.5f) * 80.0f) + this->dyna.actor.world.pos.z; + pos.x = ((Rand_ZeroOne() - 0.5f) * 80.0f) + pthis->dyna.actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 100.0f) + pthis->dyna.actor.world.pos.y; + pos.z = ((Rand_ZeroOne() - 0.5f) * 80.0f) + pthis->dyna.actor.world.pos.z; func_80033480(globalCtx, &pos, 100.0f, 4, 200, 250, 1); } -void BgHidanKowarerukabe_FloorBreak(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { +void BgHidanKowarerukabe_FloorBreak(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { s32 i; s32 j; Vec3f velocity; Vec3f pos; s16 arg5; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; f32 sin = Math_SinS(thisx->shape.rot.y); f32 cos = Math_CosS(thisx->shape.rot.y); f32 tmp1; @@ -212,13 +212,13 @@ void BgHidanKowarerukabe_FloorBreak(BgHidanKowarerukabe* this, GlobalContext* gl } } -void func_8088A67C(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { +void func_8088A67C(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { s32 i; s32 j; Vec3f velocity; Vec3f pos; s16 arg5; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; f32 sin = Math_SinS(thisx->shape.rot.y); f32 cos = Math_CosS(thisx->shape.rot.y); f32 tmp1; @@ -253,13 +253,13 @@ void func_8088A67C(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { } } -void BgHidanKowarerukabe_LargeWallBreak(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { +void BgHidanKowarerukabe_LargeWallBreak(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { s32 i; s32 j; Vec3f velocity; Vec3f pos; s16 arg5; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; f32 sin = Math_SinS(thisx->shape.rot.y); f32 cos = Math_CosS(thisx->shape.rot.y); f32 tmp1; @@ -294,46 +294,46 @@ void BgHidanKowarerukabe_LargeWallBreak(BgHidanKowarerukabe* this, GlobalContext } } -void BgHidanKowarerukabe_Break(BgHidanKowarerukabe* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xFF) { +void BgHidanKowarerukabe_Break(BgHidanKowarerukabe* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xFF) { case CRACKED_STONE_FLOOR: - BgHidanKowarerukabe_FloorBreak(this, globalCtx); + BgHidanKowarerukabe_FloorBreak(pthis, globalCtx); break; case BOMBABLE_WALL: - func_8088A67C(this, globalCtx); + func_8088A67C(pthis, globalCtx); break; case LARGE_BOMBABLE_WALL: - BgHidanKowarerukabe_LargeWallBreak(this, globalCtx); + BgHidanKowarerukabe_LargeWallBreak(pthis, globalCtx); break; } - BgHidanKowarerukabe_SpawnDust(this, globalCtx); + BgHidanKowarerukabe_SpawnDust(pthis, globalCtx); } void BgHidanKowarerukabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKowarerukabe* this = (BgHidanKowarerukabe*)thisx; + BgHidanKowarerukabe* pthis = (BgHidanKowarerukabe*)thisx; s32 pad; - if (Actor_GetCollidedExplosive(globalCtx, &this->collider.base) != NULL) { - BgHidanKowarerukabe_Break(this, globalCtx); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); + if (Actor_GetCollidedExplosive(globalCtx, &pthis->collider.base) != NULL) { + BgHidanKowarerukabe_Break(pthis, globalCtx); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); - if ((this->dyna.actor.params & 0xFF) == 0) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 40, NA_SE_EV_EXPLOSION); + if ((pthis->dyna.actor.params & 0xFF) == 0) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 40, NA_SE_EV_EXPLOSION); } else { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); } func_80078884(NA_SE_SY_CORRECT_CHIME); - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } void BgHidanKowarerukabe_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanKowarerukabe* this = (BgHidanKowarerukabe*)thisx; + BgHidanKowarerukabe* pthis = (BgHidanKowarerukabe*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_kowarerukabe.c", 565); @@ -341,9 +341,9 @@ void BgHidanKowarerukabe_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_kowarerukabe.c", 568), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sBreakableWallDLists[this->dyna.actor.params & 0xFF]); + gSPDisplayList(POLY_OPA_DISP++, sBreakableWallDLists[pthis->dyna.actor.params & 0xFF]); - Collider_UpdateSpheres(0, &this->collider); + Collider_UpdateSpheres(0, &pthis->collider); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_kowarerukabe.c", 573); } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c deleted file mode 100644 index fcbc6de18..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c +++ /dev/null @@ -1,414 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_ROCK_Z_BG_HIDAN_ROCK_C -#include "actor_common.h" -/* - * File: z_bg_hidan_rock.c - * Overlay: ovl_Bg_Hidan_Rock - * Description: Stone blocks (Fire Temple) - */ - -#include "z_bg_hidan_rock.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define FLAGS 0 - -void BgHidanRock_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanRock_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8088B24C(BgHidanRock* this); - -void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B5F4(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B634(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B69C(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B79C(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B90C(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B954(BgHidanRock* this, GlobalContext* globalCtx); -void func_8088B990(BgHidanRock* this, GlobalContext* globalCtx); - -void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* this); - -static Vec3f D_8088BF60 = { 3310.0f, 120.0f, 0.0f }; - -const ActorInit Bg_Hidan_Rock_InitVars = { - ACTOR_BG_HIDAN_ROCK, - ACTORCAT_BG, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanRock), - (ActorFunc)BgHidanRock_Init, - (ActorFunc)BgHidanRock_Destroy, - (ActorFunc)BgHidanRock_Update, - (ActorFunc)BgHidanRock_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 45, 77, -40, { 3310, 120, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_STOP), -}; - -void BgHidanRock_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRock* this = (BgHidanRock*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - - this->type = thisx->params & 0xFF; - this->unk_169 = 0; - - thisx->params = ((thisx->params) >> 8) & 0xFF; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - - if (this->type == 0) { - if (Flags_GetSwitch(globalCtx, thisx->params)) { - Math_Vec3f_Copy(&thisx->home.pos, &D_8088BF60); - Math_Vec3f_Copy(&thisx->world.pos, &D_8088BF60); - this->timer = 60; - this->actionFunc = func_8088B5F4; - } else { - this->actionFunc = func_8088B268; - } - thisx->flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - CollisionHeader_GetVirtual(&gFireTempleStoneBlock1Col, &colHeader); - } else { - CollisionHeader_GetVirtual(&gFireTempleStoneBlock2Col, &colHeader); - this->collider.dim.pos.x = thisx->home.pos.x; - this->collider.dim.pos.y = thisx->home.pos.y; - this->collider.dim.pos.z = thisx->home.pos.z; - this->actionFunc = func_8088B634; - } - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - this->timer = 0; -} - -void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRock* this = (BgHidanRock*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); - Audio_StopSfxByPos(&this->unk_170); -} - -void func_8088B24C(BgHidanRock* this) { - this->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - this->actionFunc = func_8088B990; -} - -void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx) { - static f32 D_8088BFC0 = 0.0f; - f32 sp2C; - s32 temp_v1; - s32 frame; - Player* player = GET_PLAYER(globalCtx); - - if (this->dyna.unk_150 != 0.0f) { - if (this->timer == 0) { - if (D_8088BFC0 == 0.0f) { - if (this->dyna.unk_150 > 0.0f) { - D_8088BFC0 += 0.01f; - } else { - D_8088BFC0 -= 0.01f; - } - } - - this->dyna.actor.speedXZ += 0.05f; - this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 2.0f); - - if (D_8088BFC0 > 0.0f) { - temp_v1 = Math_StepToF(&D_8088BFC0, 20.0f, this->dyna.actor.speedXZ); - } else { - temp_v1 = Math_StepToF(&D_8088BFC0, -20.0f, this->dyna.actor.speedXZ); - } - - this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.unk_158) * D_8088BFC0) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.unk_158) * D_8088BFC0) + this->dyna.actor.home.pos.z; - - if (temp_v1) { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; - this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; - D_8088BFC0 = 0.0f; - this->dyna.actor.speedXZ = 0.0f; - this->timer = 5; - } - - func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - if (this->timer != 0) { - this->timer--; - } - } - } else { - this->timer = 0; - } - - sp2C = this->dyna.actor.world.pos.z - D_8088BF60.z; - if (sp2C < 0.5f) { - Flags_SetSwitch(globalCtx, this->dyna.actor.params); - Math_Vec3f_Copy(&this->dyna.actor.home.pos, &D_8088BF60); - this->dyna.actor.world.pos.x = D_8088BF60.x; - this->dyna.actor.world.pos.z = D_8088BF60.z; - this->dyna.actor.speedXZ = 0.0f; - D_8088BFC0 = 0.0f; - player->stateFlags2 &= ~0x10; - this->actionFunc = func_8088B79C; - } - - frame = globalCtx->gameplayFrames & 0xFF; - if (globalCtx->gameplayFrames & 0x100) { - this->unk_16C = 0.0f; - } else if (frame < 128) { - this->unk_16C = sinf(frame * (4 * 0.001f * M_PI)) * 19.625f; - } else if (frame < 230) { - this->unk_16C = 19.625f; - } else { - this->unk_16C -= 1.0f; - this->unk_16C = CLAMP_MIN(this->unk_16C, 0.0f); - } - - if (sp2C < 100.0f) { - this->unk_16C = CLAMP_MAX(this->unk_16C, 6.125f); - } -} - -void func_8088B5F4(BgHidanRock* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - func_8088B24C(this); - } -} - -void func_8088B634(BgHidanRock* this, GlobalContext* globalCtx) { - if (func_8004356C(&this->dyna)) { - this->timer = 20; - this->dyna.actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4000; - this->actionFunc = func_8088B69C; - } -} - -void func_8088B69C(BgHidanRock* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer != 0) { - this->dyna.actor.world.pos.x = - this->dyna.actor.home.pos.x + 5.0f * Math_SinS(this->dyna.actor.world.rot.y + this->timer * 0x4000); - this->dyna.actor.world.pos.z = - this->dyna.actor.home.pos.z + 5.0f * Math_CosS(this->dyna.actor.world.rot.y + this->timer * 0x4000); - } else { - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; - func_8088B24C(this); - } - - if (!(this->timer % 4)) { - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0xB4, 0x0A, 0x64); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE); - } -} - -void func_8088B79C(BgHidanRock* this, GlobalContext* globalCtx) { - this->timer--; - if (this->dyna.actor.bgCheckFlags & 2) { - if (this->type == 0) { - this->timer = 60; - this->actionFunc = func_8088B5F4; - } else { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 15.0f; - this->actionFunc = func_8088B90C; - this->dyna.actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_5); - } - - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Audio_PlayActorSound2( - &this->dyna.actor, - SurfaceType_GetSfx(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + 0x800); - } - - this->unk_16C -= 0.5f; - this->unk_16C = CLAMP_MIN(this->unk_16C, 0.0f); - - if (this->type == 0) { - if (func_8004356C(&this->dyna)) { - if (this->unk_169 == 0) { - this->unk_169 = 3; - } - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); - } else if (!func_8004356C(&this->dyna)) { - if (this->unk_169 != 0) { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); - } - this->unk_169 = 0; - } - } -} - -void func_8088B90C(BgHidanRock* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { - this->actionFunc = func_8088B634; - } -} - -void func_8088B954(BgHidanRock* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - this->actionFunc = func_8088B79C; - this->dyna.actor.velocity.y = 0.0f; - } -} - -void func_8088B990(BgHidanRock* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->timer++; - if (this->dyna.unk_150 != 0.0f) { - this->dyna.actor.speedXZ = 0.0f; - player->stateFlags2 &= ~0x10; - } - - if ((this->type == 0 && (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 1820.0f, - 0.25f, 20.0f, 0.5f) < 0.1f)) || - ((this->type != 0) && (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 480.0, - 0.25f, 20.0f, 0.5f) < 0.1f))) { - if (this->type == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - } - this->timer = 20; - this->actionFunc = func_8088B954; - } - - this->unk_16C = (this->dyna.actor.world.pos.y + 50.0f - this->dyna.actor.home.pos.y + 40.0f) / 80.0f; - if (this->type == 0) { - if (func_8004356C(&this->dyna)) { - if (this->unk_169 == 0) { - this->unk_169 = 3; - } - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); - } else if (!func_8004356C(&this->dyna)) { - if (this->unk_169 != 0) { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); - } - this->unk_169 = 0; - } - } -} - -void BgHidanRock_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRock* this = (BgHidanRock*)thisx; - - this->actionFunc(this, globalCtx); - if (this->actionFunc == func_8088B79C) { - Actor_MoveForward(&this->dyna.actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); - } - - if (this->unk_16C > 0.0f) { - this->collider.dim.height = sCylinderInit.dim.height * this->unk_16C; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -static void* sVerticalFlamesTexs[] = { - gFireTempleBigVerticalFlame0Tex, gFireTempleBigVerticalFlame1Tex, gFireTempleBigVerticalFlame2Tex, - gFireTempleBigVerticalFlame3Tex, gFireTempleBigVerticalFlame4Tex, gFireTempleBigVerticalFlame5Tex, - gFireTempleBigVerticalFlame6Tex, gFireTempleBigVerticalFlame7Tex, -}; - -void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* this) { - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 808); - - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); - - if (this->type == 0) { - Matrix_Translate(D_8088BF60.x, D_8088BF60.y - 40.0f, D_8088BF60.z, MTXMODE_NEW); - } else { - Matrix_Translate(this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y - 40.0f, this->dyna.actor.home.pos.z, - MTXMODE_NEW); - } - - Matrix_RotateZYX(0, Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000, 0, MTXMODE_APPLY); - Matrix_Translate(-10.5f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(6.0f, this->unk_16C, 6.0f, MTXMODE_APPLY); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sVerticalFlamesTexs[globalCtx->gameplayFrames & 7])); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 853), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gFireTempleBigVerticalFlameDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 857); -} - -void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRock* this = (BgHidanRock*)thisx; - s32 pad; - - if (this->type == 0) { - Gfx_DrawDListOpa(globalCtx, gFireTempleStoneBlock1DL); - } else { - Gfx_DrawDListOpa(globalCtx, gFireTempleStoneBlock2DL); - } - - if (this->unk_16C > 0.0f) { - if (this->type == 0) { - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &D_8088BF60, &this->unk_170); - } else { - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &this->dyna.actor.home.pos, &this->unk_170); - } - - func_80078914(&this->unk_170, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); - func_8088BC40(globalCtx, this); - } -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.cpp b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.cpp new file mode 100644 index 000000000..e4a8e2aed --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.cpp @@ -0,0 +1,414 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_ROCK_Z_BG_HIDAN_ROCK_C +#include "actor_common.h" +/* + * File: z_bg_hidan_rock.c + * Overlay: ovl_Bg_Hidan_Rock + * Description: Stone blocks (Fire Temple) + */ + +#include "z_bg_hidan_rock.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define FLAGS 0 + +void BgHidanRock_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanRock_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8088B24C(BgHidanRock* pthis); + +void func_8088B268(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B5F4(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B634(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B69C(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B79C(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B90C(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B954(BgHidanRock* pthis, GlobalContext* globalCtx); +void func_8088B990(BgHidanRock* pthis, GlobalContext* globalCtx); + +void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* pthis); + +static Vec3f D_8088BF60 = { 3310.0f, 120.0f, 0.0f }; + +ActorInit Bg_Hidan_Rock_InitVars = { + ACTOR_BG_HIDAN_ROCK, + ACTORCAT_BG, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanRock), + (ActorFunc)BgHidanRock_Init, + (ActorFunc)BgHidanRock_Destroy, + (ActorFunc)BgHidanRock_Update, + (ActorFunc)BgHidanRock_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 45, 77, -40, { 3310, 120, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_STOP), +}; + +void BgHidanRock_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* pthis = (BgHidanRock*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + + pthis->type = thisx->params & 0xFF; + pthis->unk_169 = 0; + + thisx->params = ((thisx->params) >> 8) & 0xFF; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + + if (pthis->type == 0) { + if (Flags_GetSwitch(globalCtx, thisx->params)) { + Math_Vec3f_Copy(&thisx->home.pos, &D_8088BF60); + Math_Vec3f_Copy(&thisx->world.pos, &D_8088BF60); + pthis->timer = 60; + pthis->actionFunc = func_8088B5F4; + } else { + pthis->actionFunc = func_8088B268; + } + thisx->flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + CollisionHeader_GetVirtual(&gFireTempleStoneBlock1Col, &colHeader); + } else { + CollisionHeader_GetVirtual(&gFireTempleStoneBlock2Col, &colHeader); + pthis->collider.dim.pos.x = thisx->home.pos.x; + pthis->collider.dim.pos.y = thisx->home.pos.y; + pthis->collider.dim.pos.z = thisx->home.pos.z; + pthis->actionFunc = func_8088B634; + } + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->timer = 0; +} + +void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* pthis = (BgHidanRock*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + Audio_StopSfxByPos(&pthis->unk_170); +} + +void func_8088B24C(BgHidanRock* pthis) { + pthis->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + pthis->actionFunc = func_8088B990; +} + +void func_8088B268(BgHidanRock* pthis, GlobalContext* globalCtx) { + static f32 D_8088BFC0 = 0.0f; + f32 sp2C; + s32 temp_v1; + s32 frame; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->dyna.unk_150 != 0.0f) { + if (pthis->timer == 0) { + if (D_8088BFC0 == 0.0f) { + if (pthis->dyna.unk_150 > 0.0f) { + D_8088BFC0 += 0.01f; + } else { + D_8088BFC0 -= 0.01f; + } + } + + pthis->dyna.actor.speedXZ += 0.05f; + pthis->dyna.actor.speedXZ = CLAMP_MAX(pthis->dyna.actor.speedXZ, 2.0f); + + if (D_8088BFC0 > 0.0f) { + temp_v1 = Math_StepToF(&D_8088BFC0, 20.0f, pthis->dyna.actor.speedXZ); + } else { + temp_v1 = Math_StepToF(&D_8088BFC0, -20.0f, pthis->dyna.actor.speedXZ); + } + + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->dyna.unk_158) * D_8088BFC0) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->dyna.unk_158) * D_8088BFC0) + pthis->dyna.actor.home.pos.z; + + if (temp_v1) { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + pthis->dyna.actor.home.pos.x = pthis->dyna.actor.world.pos.x; + pthis->dyna.actor.home.pos.z = pthis->dyna.actor.world.pos.z; + D_8088BFC0 = 0.0f; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->timer = 5; + } + + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + if (pthis->timer != 0) { + pthis->timer--; + } + } + } else { + pthis->timer = 0; + } + + sp2C = pthis->dyna.actor.world.pos.z - D_8088BF60.z; + if (sp2C < 0.5f) { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params); + Math_Vec3f_Copy(&pthis->dyna.actor.home.pos, &D_8088BF60); + pthis->dyna.actor.world.pos.x = D_8088BF60.x; + pthis->dyna.actor.world.pos.z = D_8088BF60.z; + pthis->dyna.actor.speedXZ = 0.0f; + D_8088BFC0 = 0.0f; + player->stateFlags2 &= ~0x10; + pthis->actionFunc = func_8088B79C; + } + + frame = globalCtx->gameplayFrames & 0xFF; + if (globalCtx->gameplayFrames & 0x100) { + pthis->unk_16C = 0.0f; + } else if (frame < 128) { + pthis->unk_16C = sinf(frame * (4 * 0.001f * M_PI)) * 19.625f; + } else if (frame < 230) { + pthis->unk_16C = 19.625f; + } else { + pthis->unk_16C -= 1.0f; + pthis->unk_16C = CLAMP_MIN(pthis->unk_16C, 0.0f); + } + + if (sp2C < 100.0f) { + pthis->unk_16C = CLAMP_MAX(pthis->unk_16C, 6.125f); + } +} + +void func_8088B5F4(BgHidanRock* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + func_8088B24C(pthis); + } +} + +void func_8088B634(BgHidanRock* pthis, GlobalContext* globalCtx) { + if (func_8004356C(&pthis->dyna)) { + pthis->timer = 20; + pthis->dyna.actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4000; + pthis->actionFunc = func_8088B69C; + } +} + +void func_8088B69C(BgHidanRock* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer != 0) { + pthis->dyna.actor.world.pos.x = + pthis->dyna.actor.home.pos.x + 5.0f * Math_SinS(pthis->dyna.actor.world.rot.y + pthis->timer * 0x4000); + pthis->dyna.actor.world.pos.z = + pthis->dyna.actor.home.pos.z + 5.0f * Math_CosS(pthis->dyna.actor.world.rot.y + pthis->timer * 0x4000); + } else { + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z; + func_8088B24C(pthis); + } + + if (!(pthis->timer % 4)) { + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 0xB4, 0x0A, 0x64); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_SHAKE); + } +} + +void func_8088B79C(BgHidanRock* pthis, GlobalContext* globalCtx) { + pthis->timer--; + if (pthis->dyna.actor.bgCheckFlags & 2) { + if (pthis->type == 0) { + pthis->timer = 60; + pthis->actionFunc = func_8088B5F4; + } else { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - 15.0f; + pthis->actionFunc = func_8088B90C; + pthis->dyna.actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_5); + } + + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Audio_PlayActorSound2( + &pthis->dyna.actor, + SurfaceType_GetSfx(&globalCtx->colCtx, pthis->dyna.actor.floorPoly, pthis->dyna.actor.floorBgId) + 0x800); + } + + pthis->unk_16C -= 0.5f; + pthis->unk_16C = CLAMP_MIN(pthis->unk_16C, 0.0f); + + if (pthis->type == 0) { + if (func_8004356C(&pthis->dyna)) { + if (pthis->unk_169 == 0) { + pthis->unk_169 = 3; + } + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); + } else if (!func_8004356C(&pthis->dyna)) { + if (pthis->unk_169 != 0) { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); + } + pthis->unk_169 = 0; + } + } +} + +void func_8088B90C(BgHidanRock* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 1.0f)) { + pthis->actionFunc = func_8088B634; + } +} + +void func_8088B954(BgHidanRock* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + pthis->actionFunc = func_8088B79C; + pthis->dyna.actor.velocity.y = 0.0f; + } +} + +void func_8088B990(BgHidanRock* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->timer++; + if (pthis->dyna.unk_150 != 0.0f) { + pthis->dyna.actor.speedXZ = 0.0f; + player->stateFlags2 &= ~0x10; + } + + if ((pthis->type == 0 && (Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 1820.0f, + 0.25f, 20.0f, 0.5f) < 0.1f)) || + ((pthis->type != 0) && (Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 480.0, + 0.25f, 20.0f, 0.5f) < 0.1f))) { + if (pthis->type == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + pthis->timer = 20; + pthis->actionFunc = func_8088B954; + } + + pthis->unk_16C = (pthis->dyna.actor.world.pos.y + 50.0f - pthis->dyna.actor.home.pos.y + 40.0f) / 80.0f; + if (pthis->type == 0) { + if (func_8004356C(&pthis->dyna)) { + if (pthis->unk_169 == 0) { + pthis->unk_169 = 3; + } + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); + } else if (!func_8004356C(&pthis->dyna)) { + if (pthis->unk_169 != 0) { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); + } + pthis->unk_169 = 0; + } + } +} + +void BgHidanRock_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* pthis = (BgHidanRock*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc == func_8088B79C) { + Actor_MoveForward(&pthis->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + } + + if (pthis->unk_16C > 0.0f) { + pthis->collider.dim.height = sCylinderInit.dim.height * pthis->unk_16C; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +static void* sVerticalFlamesTexs[] = { + gFireTempleBigVerticalFlame0Tex, gFireTempleBigVerticalFlame1Tex, gFireTempleBigVerticalFlame2Tex, + gFireTempleBigVerticalFlame3Tex, gFireTempleBigVerticalFlame4Tex, gFireTempleBigVerticalFlame5Tex, + gFireTempleBigVerticalFlame6Tex, gFireTempleBigVerticalFlame7Tex, +}; + +void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* pthis) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 808); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); + + if (pthis->type == 0) { + Matrix_Translate(D_8088BF60.x, D_8088BF60.y - 40.0f, D_8088BF60.z, MTXMODE_NEW); + } else { + Matrix_Translate(pthis->dyna.actor.home.pos.x, pthis->dyna.actor.home.pos.y - 40.0f, pthis->dyna.actor.home.pos.z, + MTXMODE_NEW); + } + + Matrix_RotateZYX(0, Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000, 0, MTXMODE_APPLY); + Matrix_Translate(-10.5f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(6.0f, pthis->unk_16C, 6.0f, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sVerticalFlamesTexs[globalCtx->gameplayFrames & 7])); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 853), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFireTempleBigVerticalFlameDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 857); +} + +void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* pthis = (BgHidanRock*)thisx; + s32 pad; + + if (pthis->type == 0) { + Gfx_DrawDListOpa(globalCtx, gFireTempleStoneBlock1DL); + } else { + Gfx_DrawDListOpa(globalCtx, gFireTempleStoneBlock2DL); + } + + if (pthis->unk_16C > 0.0f) { + if (pthis->type == 0) { + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &D_8088BF60, &pthis->unk_170); + } else { + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &pthis->dyna.actor.home.pos, &pthis->unk_170); + } + + func_80078914(&pthis->unk_170, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + func_8088BC40(globalCtx, pthis); + } +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c b/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.cpp similarity index 66% rename from src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c rename to src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.cpp index 06bc1da5e..a2ef6ee78 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.cpp @@ -25,7 +25,7 @@ void BgHidanRsekizou_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHidanRsekizou_Update(Actor* thisx, GlobalContext* globalCtx); void BgHidanRsekizou_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Hidan_Rsekizou_InitVars = { +ActorInit Bg_Hidan_Rsekizou_InitVars = { ACTOR_BG_HIDAN_RSEKIZOU, ACTORCAT_BG, FLAGS, @@ -131,68 +131,68 @@ static void* sFireballsTexs[] = { }; void BgHidanRsekizou_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; + BgHidanRsekizou* pthis = (BgHidanRsekizou*)thisx; s32 i; s32 pad; CollisionHeader* colHeader; colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gFireTempleSpinningFlamethrowerCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderItems); - for (i = 0; i < ARRAY_COUNT(this->colliderItems); i++) { - this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->colliderItems); + for (i = 0; i < ARRAY_COUNT(pthis->colliderItems); i++) { + pthis->collider.elements[i].dim.worldSphere.radius = pthis->collider.elements[i].dim.modelSphere.radius; } - this->burnFrame = 0; - this->bendFrame = 0; + pthis->burnFrame = 0; + pthis->bendFrame = 0; } void BgHidanRsekizou_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; + BgHidanRsekizou* pthis = (BgHidanRsekizou*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } void BgHidanRsekizou_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; + BgHidanRsekizou* pthis = (BgHidanRsekizou*)thisx; s32 i; ColliderJntSphElement* sphere; s32 pad; f32 yawSine; f32 yawCosine; - this->burnFrame = (this->burnFrame + 1) % 8; + pthis->burnFrame = (pthis->burnFrame + 1) % 8; - if (this->bendFrame != 0) { - this->bendFrame--; + if (pthis->bendFrame != 0) { + pthis->bendFrame--; } - if (this->bendFrame == 0) { - this->bendFrame = 3; + if (pthis->bendFrame == 0) { + pthis->bendFrame = 3; } - this->dyna.actor.shape.rot.y += 0x180; // Approximately 2 Degrees per Frame - yawSine = Math_SinS(this->dyna.actor.shape.rot.y); - yawCosine = Math_CosS(this->dyna.actor.shape.rot.y); + pthis->dyna.actor.shape.rot.y += 0x180; // Approximately 2 Degrees per Frame + yawSine = Math_SinS(pthis->dyna.actor.shape.rot.y); + yawCosine = Math_CosS(pthis->dyna.actor.shape.rot.y); - for (i = 0; i < ARRAY_COUNT(this->colliderItems); i++) { - sphere = &this->collider.elements[i]; - sphere->dim.worldSphere.center.x = this->dyna.actor.home.pos.x + yawCosine * sphere->dim.modelSphere.center.x + + for (i = 0; i < ARRAY_COUNT(pthis->colliderItems); i++) { + sphere = &pthis->collider.elements[i]; + sphere->dim.worldSphere.center.x = pthis->dyna.actor.home.pos.x + yawCosine * sphere->dim.modelSphere.center.x + yawSine * sphere->dim.modelSphere.center.z; - sphere->dim.worldSphere.center.y = (s16)this->dyna.actor.home.pos.y + sphere->dim.modelSphere.center.y; - sphere->dim.worldSphere.center.z = (this->dyna.actor.home.pos.z - yawSine * sphere->dim.modelSphere.center.x) + + sphere->dim.worldSphere.center.y = (s16)pthis->dyna.actor.home.pos.y + sphere->dim.modelSphere.center.y; + sphere->dim.worldSphere.center.z = (pthis->dyna.actor.home.pos.z - yawSine * sphere->dim.modelSphere.center.x) + yawCosine * sphere->dim.modelSphere.center.z; } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_8002F974(&this->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); } -Gfx* BgHidanRsekizou_DrawFireball(GlobalContext* globalCtx, BgHidanRsekizou* this, s16 frame, MtxF* mf, s32 a, +Gfx* BgHidanRsekizou_DrawFireball(GlobalContext* globalCtx, BgHidanRsekizou* pthis, s16 frame, MtxF* mf, s32 a, Gfx* displayList) { f32 coss; f32 sins; @@ -200,41 +200,38 @@ Gfx* BgHidanRsekizou_DrawFireball(GlobalContext* globalCtx, BgHidanRsekizou* thi f32 fVar6; f32 tmpf7; - temp = (((this->burnFrame + frame) % 8) * 7) * (1.0f / 7.0f); + temp = (((pthis->burnFrame + frame) % 8) * 7) * (1.0f / 7.0f); gSPSegment(displayList++, 0x09, SEGMENTED_TO_VIRTUAL(sFireballsTexs[temp])); frame++; - fVar6 = (frame != 4) ? frame + ((3 - this->bendFrame) * (1.0f / 3.0f)) : frame; + fVar6 = (frame != 4) ? frame + ((3 - pthis->bendFrame) * (1.0f / 3.0f)) : frame; gDPSetPrimColor(displayList++, 0, 1, 255, 255, 0, 150); gDPSetEnvColor(displayList++, 255, 0, 0, 255); if (a == 0) { - sins = -Math_SinS(this->dyna.actor.shape.rot.y - (frame * 1500)); - coss = -Math_CosS(this->dyna.actor.shape.rot.y - (frame * 1500)); + sins = -Math_SinS(pthis->dyna.actor.shape.rot.y - (frame * 1500)); + coss = -Math_CosS(pthis->dyna.actor.shape.rot.y - (frame * 1500)); } else { - sins = Math_SinS(this->dyna.actor.shape.rot.y - (frame * 1500)); - coss = Math_CosS(this->dyna.actor.shape.rot.y - (frame * 1500)); + sins = Math_SinS(pthis->dyna.actor.shape.rot.y - (frame * 1500)); + coss = Math_CosS(pthis->dyna.actor.shape.rot.y - (frame * 1500)); } mf->xx = mf->yy = mf->zz = (0.7f * fVar6) + 0.5f; tmpf7 = (((((0.7f * fVar6) + 0.5f) * 10.0f) * fVar6) + 20.0f); - mf->xw = (tmpf7 * sins) + this->dyna.actor.world.pos.x; - mf->yw = (this->dyna.actor.world.pos.y + 30.0f) + ((7.0f / 10.0f) * fVar6); - mf->zw = (tmpf7 * coss) + this->dyna.actor.world.pos.z; + mf->xw = (tmpf7 * sins) + pthis->dyna.actor.world.pos.x; + mf->yw = (pthis->dyna.actor.world.pos.y + 30.0f) + ((7.0f / 10.0f) * fVar6); + mf->zw = (tmpf7 * coss) + pthis->dyna.actor.world.pos.z; - gSPMatrix(displayList++, - Matrix_MtxFToMtx(Matrix_CheckFloats(mf, "../z_bg_hidan_rsekizou.c", 543), - Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(displayList++, Matrix_MtxFToMtx(mf, (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(displayList++, gFireTempleFireballDL); return displayList; } void BgHidanRsekizou_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; + BgHidanRsekizou* pthis = (BgHidanRsekizou*)thisx; s32 i; s32 pad; MtxF mf; @@ -250,21 +247,21 @@ void BgHidanRsekizou_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); - if ((s16)((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->dyna.actor.shape.rot.y) - 0x2E6C) >= 0) { + if ((s16)((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->dyna.actor.shape.rot.y) - 0x2E6C) >= 0) { for (i = 3; i >= 0; i--) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, this, i, &mf, 0, POLY_XLU_DISP); + POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, pthis, i, &mf, 0, POLY_XLU_DISP); } for (i = 0; i < 4; i++) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, this, i, &mf, 1, POLY_XLU_DISP); + POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, pthis, i, &mf, 1, POLY_XLU_DISP); } } else { for (i = 3; i >= 0; i--) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, this, i, &mf, 1, POLY_XLU_DISP); + POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, pthis, i, &mf, 1, POLY_XLU_DISP); } for (i = 0; i < 4; i++) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, this, i, &mf, 0, POLY_XLU_DISP); + POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(globalCtx, pthis, i, &mf, 0, POLY_XLU_DISP); } } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Sekizou/z_bg_hidan_sekizou.c b/src/overlays/actors/ovl_Bg_Hidan_Sekizou/z_bg_hidan_sekizou.cpp similarity index 60% rename from src/overlays/actors/ovl_Bg_Hidan_Sekizou/z_bg_hidan_sekizou.c rename to src/overlays/actors/ovl_Bg_Hidan_Sekizou/z_bg_hidan_sekizou.cpp index af89ba7e8..298d34918 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Sekizou/z_bg_hidan_sekizou.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Sekizou/z_bg_hidan_sekizou.cpp @@ -25,10 +25,10 @@ void BgHidanSekizou_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHidanSekizou_Update(Actor* thisx, GlobalContext* globalCtx); void BgHidanSekizou_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8088D434(BgHidanSekizou* this, GlobalContext* globalCtx); -void func_8088D720(BgHidanSekizou* this, GlobalContext* globalCtx); +void func_8088D434(BgHidanSekizou* pthis, GlobalContext* globalCtx); +void func_8088D720(BgHidanSekizou* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Hidan_Sekizou_InitVars = { +ActorInit Bg_Hidan_Sekizou_InitVars = { ACTOR_BG_HIDAN_SEKIZOU, ACTORCAT_BG, FLAGS, @@ -135,7 +135,7 @@ static void* sFireballsTexs[] = { gFireTempleFireball4Tex, gFireTempleFireball5Tex, gFireTempleFireball6Tex, gFireTempleFireball7Tex, }; -void func_8088CEC0(BgHidanSekizou* this, s32 arg1, s16 arg2) { +void func_8088CEC0(BgHidanSekizou* pthis, s32 arg1, s16 arg2) { s32 i; s32 start = arg1 * 3; s32 end = start + 3; @@ -143,12 +143,12 @@ void func_8088CEC0(BgHidanSekizou* this, s32 arg1, s16 arg2) { f32 sp2C = Math_CosS(arg2); for (i = start; i < end; i++) { - ColliderJntSphElement* element = &this->collider.elements[i]; + ColliderJntSphElement* element = &pthis->collider.elements[i]; - element->dim.worldSphere.center.x = this->dyna.actor.home.pos.x + (sp2C * element->dim.modelSphere.center.x) + + element->dim.worldSphere.center.x = pthis->dyna.actor.home.pos.x + (sp2C * element->dim.modelSphere.center.x) + (sp30 * element->dim.modelSphere.center.z); - element->dim.worldSphere.center.y = (s16)this->dyna.actor.home.pos.y + element->dim.modelSphere.center.y; - element->dim.worldSphere.center.z = this->dyna.actor.home.pos.z - (sp30 * element->dim.modelSphere.center.x) + + element->dim.worldSphere.center.y = (s16)pthis->dyna.actor.home.pos.y + element->dim.modelSphere.center.y; + element->dim.worldSphere.center.z = pthis->dyna.actor.home.pos.z - (sp30 * element->dim.modelSphere.center.x) + (sp2C * element->dim.modelSphere.center.z); element->info.toucherFlags |= TOUCH_ON; element->info.ocElemFlags |= OCELEM_ON; @@ -157,100 +157,100 @@ void func_8088CEC0(BgHidanSekizou* this, s32 arg1, s16 arg2) { void BgHidanSekizou_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgHidanSekizou* this = (BgHidanSekizou*)thisx; + BgHidanSekizou* pthis = (BgHidanSekizou*)thisx; s32 i; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->elements); - for (i = 0; i < ARRAY_COUNT(this->elements); i++) { - this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->elements); + for (i = 0; i < ARRAY_COUNT(pthis->elements); i++) { + pthis->collider.elements[i].dim.worldSphere.radius = pthis->collider.elements[i].dim.modelSphere.radius; } - if (this->dyna.actor.params == 0) { - this->unk_168[0] = 36; + if (pthis->dyna.actor.params == 0) { + pthis->unk_168[0] = 36; for (i = 0; i < 2; i++) { - func_8088CEC0(this, i, this->dyna.actor.shape.rot.y + ((i == 0) ? 0x2000 : -0x2000)); + func_8088CEC0(pthis, i, pthis->dyna.actor.shape.rot.y + ((i == 0) ? 0x2000 : -0x2000)); } CollisionHeader_GetVirtual(&gFireTempleStationaryFlamethrowerShortCol, &colHeader); - this->updateFunc = func_8088D720; + pthis->updateFunc = func_8088D720; } else { - this->unk_168[0] = this->unk_168[1] = this->unk_168[2] = this->unk_168[3] = 0; + pthis->unk_168[0] = pthis->unk_168[1] = pthis->unk_168[2] = pthis->unk_168[3] = 0; CollisionHeader_GetVirtual(&gFireTempleStationaryFlamethrowerTallCol, &colHeader); - this->updateFunc = func_8088D434; + pthis->updateFunc = func_8088D434; } - this->unk_170 = 0; - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - CollisionCheck_SetInfo(&this->dyna.actor.colChkInfo, NULL, &sColChkInfoInit); + pthis->unk_170 = 0; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + CollisionCheck_SetInfo(&pthis->dyna.actor.colChkInfo, NULL, &sColChkInfoInit); } void BgHidanSekizou_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgHidanSekizou* this = (BgHidanSekizou*)thisx; + BgHidanSekizou* pthis = (BgHidanSekizou*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void func_8088D434(BgHidanSekizou* this, GlobalContext* globalCtx) { +void func_8088D434(BgHidanSekizou* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; s32 isAligned[2]; s32 isClose; s32 phi_s4; - isClose = this->dyna.actor.xzDistToPlayer < 300.0f; - isAligned[0] = fabsf(this->dyna.actor.world.pos.x - player->actor.world.pos.x) < 80.0f; - isAligned[1] = fabsf(this->dyna.actor.world.pos.z - player->actor.world.pos.z) < 80.0f; + isClose = pthis->dyna.actor.xzDistToPlayer < 300.0f; + isAligned[0] = fabsf(pthis->dyna.actor.world.pos.x - player->actor.world.pos.x) < 80.0f; + isAligned[1] = fabsf(pthis->dyna.actor.world.pos.z - player->actor.world.pos.z) < 80.0f; phi_s4 = 0; for (i = 0; i < 4; i++) { s16 diff; - s16* temp = &this->unk_168[i]; + s16* temp = &pthis->unk_168[i]; DECR(*temp); - diff = this->dyna.actor.yawTowardsPlayer - i * 0x4000; + diff = pthis->dyna.actor.yawTowardsPlayer - i * 0x4000; if (isAligned[i % 2] && isClose) { if (ABS(diff) <= 0x4000) { if (*temp < 4) { *temp = 35 - *temp; } - func_8088CEC0(this, (phi_s4 > 1) ? 1 : phi_s4, this->dyna.actor.shape.rot.y + i * 0x4000); + func_8088CEC0(pthis, (phi_s4 > 1) ? 1 : phi_s4, pthis->dyna.actor.shape.rot.y + i * 0x4000); phi_s4++; } } } - for (i = 3 * phi_s4; i < ARRAY_COUNT(this->elements); i++) { - this->collider.elements[i].info.toucherFlags &= ~TOUCH_ON; - this->collider.elements[i].info.ocElemFlags &= ~OCELEM_ON; + for (i = 3 * phi_s4; i < ARRAY_COUNT(pthis->elements); i++) { + pthis->collider.elements[i].info.toucherFlags &= ~TOUCH_ON; + pthis->collider.elements[i].info.ocElemFlags &= ~OCELEM_ON; } } -void func_8088D720(BgHidanSekizou* this, GlobalContext* globalCtx) { - this->unk_168[0]--; - if (this->unk_168[0] <= -36) { - this->unk_168[0] = 36; +void func_8088D720(BgHidanSekizou* pthis, GlobalContext* globalCtx) { + pthis->unk_168[0]--; + if (pthis->unk_168[0] <= -36) { + pthis->unk_168[0] = 36; } } -void func_8088D750(BgHidanSekizou* this, GlobalContext* globalCtx) { +void func_8088D750(BgHidanSekizou* pthis, GlobalContext* globalCtx) { s16 phi_a3; - if (this->dyna.actor.xzDistToPlayer > 200.0f) { - phi_a3 = this->dyna.actor.yawTowardsPlayer; - } else if (this->dyna.actor.params == 0) { - phi_a3 = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; + if (pthis->dyna.actor.xzDistToPlayer > 200.0f) { + phi_a3 = pthis->dyna.actor.yawTowardsPlayer; + } else if (pthis->dyna.actor.params == 0) { + phi_a3 = pthis->dyna.actor.yawTowardsPlayer - pthis->dyna.actor.shape.rot.y; if (phi_a3 > 0x2000) { - phi_a3 = this->dyna.actor.shape.rot.y + 0x6000; + phi_a3 = pthis->dyna.actor.shape.rot.y + 0x6000; } else if (phi_a3 < -0x2000) { - phi_a3 = this->dyna.actor.shape.rot.y - 0x6000; + phi_a3 = pthis->dyna.actor.shape.rot.y - 0x6000; } else if (phi_a3 > 0) { - phi_a3 = this->dyna.actor.shape.rot.y - 0x2000; + phi_a3 = pthis->dyna.actor.shape.rot.y - 0x2000; } else { - phi_a3 = this->dyna.actor.shape.rot.y + 0x2000; + phi_a3 = pthis->dyna.actor.shape.rot.y + 0x2000; } } else { - phi_a3 = this->dyna.actor.yawTowardsPlayer; + phi_a3 = pthis->dyna.actor.yawTowardsPlayer; if (phi_a3 > 0x6000) { phi_a3 = 0x4000; } else if (phi_a3 > 0x4000) { @@ -269,43 +269,43 @@ void func_8088D750(BgHidanSekizou* this, GlobalContext* globalCtx) { phi_a3 = -0x4000; } } - func_8002F71C(globalCtx, &this->dyna.actor, 5.0f, phi_a3, 1.0f); + func_8002F71C(globalCtx, &pthis->dyna.actor, 5.0f, phi_a3, 1.0f); } void BgHidanSekizou_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgHidanSekizou* this = (BgHidanSekizou*)thisx; + BgHidanSekizou* pthis = (BgHidanSekizou*)thisx; - if (this->unk_170 != 0) { - this->unk_170--; + if (pthis->unk_170 != 0) { + pthis->unk_170--; } - if (this->unk_170 == 0) { - this->unk_170 = 4; + if (pthis->unk_170 == 0) { + pthis->unk_170 = 4; } - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - func_8088D750(this, globalCtx); + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + func_8088D750(pthis, globalCtx); } - this->updateFunc(this, globalCtx); + pthis->updateFunc(pthis, globalCtx); - if (this->dyna.actor.params == 0) { - if (this->unk_168[0] > 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_8002F974(&this->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + if (pthis->dyna.actor.params == 0) { + if (pthis->unk_168[0] > 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); } } else { - if ((this->unk_168[0] > 0) || (this->unk_168[1] > 0) || (this->unk_168[2] > 0) || (this->unk_168[3] > 0)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_8002F974(&this->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + if ((pthis->unk_168[0] > 0) || (pthis->unk_168[1] > 0) || (pthis->unk_168[2] > 0) || (pthis->unk_168[3] > 0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); } } } -Gfx* func_8088D9F4(GlobalContext* globalCtx, BgHidanSekizou* this, s16 arg2, MtxF* arg3, f32 arg4, f32 arg5, s16 arg6, +Gfx* func_8088D9F4(GlobalContext* globalCtx, BgHidanSekizou* pthis, s16 arg2, MtxF* arg3, f32 arg4, f32 arg5, s16 arg6, Gfx* arg7) { f32 temp_f0; f32 temp_f2; @@ -315,7 +315,7 @@ Gfx* func_8088D9F4(GlobalContext* globalCtx, BgHidanSekizou* this, s16 arg2, Mtx arg2++; gSPSegment(arg7++, 9, SEGMENTED_TO_VIRTUAL(sFireballsTexs[arg6])); if (arg2 != 4) { - phi_f12 = arg2 + ((4 - this->unk_170) / 4.0f); + phi_f12 = arg2 + ((4 - pthis->unk_170) / 4.0f); } else { phi_f12 = arg2; } @@ -325,12 +325,12 @@ Gfx* func_8088D9F4(GlobalContext* globalCtx, BgHidanSekizou* this, s16 arg2, Mtx arg3->xx = arg3->yy = arg3->zz = (0.7f * phi_f12) + 0.5f; temp_f2 = (arg3->xx * 10.0f * phi_f12) + 20.0f; - arg3->xw = (temp_f2 * arg4) + this->dyna.actor.world.pos.x; - arg3->yw = this->dyna.actor.world.pos.y + 30.0f + (.7f * phi_f12); - arg3->zw = (temp_f2 * arg5) + this->dyna.actor.world.pos.z; + arg3->xw = (temp_f2 * arg4) + pthis->dyna.actor.world.pos.x; + arg3->yw = pthis->dyna.actor.world.pos.y + 30.0f + (.7f * phi_f12); + arg3->zw = (temp_f2 * arg5) + pthis->dyna.actor.world.pos.z; gSPMatrix(arg7++, - Matrix_MtxFToMtx(Matrix_CheckFloats(arg3, "../z_bg_hidan_sekizou.c", 711), - Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), + Matrix_MtxFToMtx(arg3, + (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(arg7++, gFireTempleFireballDL); @@ -338,7 +338,7 @@ Gfx* func_8088D9F4(GlobalContext* globalCtx, BgHidanSekizou* this, s16 arg2, Mtx return arg7; } -Gfx* func_8088DC50(GlobalContext* globalCtx, BgHidanSekizou* this, s16 arg2, s16 arg3, Gfx* arg4) { +Gfx* func_8088DC50(GlobalContext* globalCtx, BgHidanSekizou* pthis, s16 arg2, s16 arg3, Gfx* arg4) { s32 pad; s16 temp_v1; s32 phi_s1; @@ -363,11 +363,11 @@ Gfx* func_8088DC50(GlobalContext* globalCtx, BgHidanSekizou* this, s16 arg2, s16 if (ABS(temp_v1) < 0x4000) { for (i = phi_s2 - 1; i >= phi_s1; i--) { - arg4 = func_8088D9F4(globalCtx, this, i, &sp68, temp_f20, temp_f22, arg3, arg4); + arg4 = func_8088D9F4(globalCtx, pthis, i, &sp68, temp_f20, temp_f22, arg3, arg4); } } else { for (i = phi_s1; i < phi_s2; i++) { - arg4 = func_8088D9F4(globalCtx, this, i, &sp68, temp_f20, temp_f22, arg3, arg4); + arg4 = func_8088D9F4(globalCtx, pthis, i, &sp68, temp_f20, temp_f22, arg3, arg4); } } return arg4; @@ -401,7 +401,7 @@ void func_8088DE08(s16 arg0, s16 arg1, s32 arg2[]) { void BgHidanSekizou_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgHidanSekizou* this = (BgHidanSekizou*)thisx; + BgHidanSekizou* pthis = (BgHidanSekizou*)thisx; s32 i; s32 sp6C[4]; @@ -409,34 +409,34 @@ void BgHidanSekizou_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_80093D18(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_sekizou.c", 831), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->dyna.actor.params == 0) { + if (pthis->dyna.actor.params == 0) { gSPDisplayList(POLY_OPA_DISP++, gFireTempleStationaryFlamethrowerShortDL); } else { gSPDisplayList(POLY_OPA_DISP++, gFireTempleStationaryFlamethrowerTallDL); } POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); - if (this->dyna.actor.params == 0) { - if (this->unk_168[0] > 0) { - if ((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->dyna.actor.shape.rot.y) >= 0) { - POLY_XLU_DISP = func_8088DC50(globalCtx, this, this->dyna.actor.shape.rot.y + 0x2000, this->unk_168[0], + if (pthis->dyna.actor.params == 0) { + if (pthis->unk_168[0] > 0) { + if ((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->dyna.actor.shape.rot.y) >= 0) { + POLY_XLU_DISP = func_8088DC50(globalCtx, pthis, pthis->dyna.actor.shape.rot.y + 0x2000, pthis->unk_168[0], POLY_XLU_DISP); - POLY_XLU_DISP = func_8088DC50(globalCtx, this, this->dyna.actor.shape.rot.y - 0x2000, this->unk_168[0], + POLY_XLU_DISP = func_8088DC50(globalCtx, pthis, pthis->dyna.actor.shape.rot.y - 0x2000, pthis->unk_168[0], POLY_XLU_DISP); } else { - POLY_XLU_DISP = func_8088DC50(globalCtx, this, this->dyna.actor.shape.rot.y - 0x2000, this->unk_168[0], + POLY_XLU_DISP = func_8088DC50(globalCtx, pthis, pthis->dyna.actor.shape.rot.y - 0x2000, pthis->unk_168[0], POLY_XLU_DISP); - POLY_XLU_DISP = func_8088DC50(globalCtx, this, this->dyna.actor.shape.rot.y + 0x2000, this->unk_168[0], + POLY_XLU_DISP = func_8088DC50(globalCtx, pthis, pthis->dyna.actor.shape.rot.y + 0x2000, pthis->unk_168[0], POLY_XLU_DISP); } } } else { - func_8088DE08(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), this->dyna.actor.shape.rot.y, sp6C); + func_8088DE08(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), pthis->dyna.actor.shape.rot.y, sp6C); for (i = 0; i < 4; i++) { s32 index = sp6C[i]; - if (this->unk_168[index] > 0) { - POLY_XLU_DISP = func_8088DC50(globalCtx, this, this->dyna.actor.shape.rot.y + index * 0x4000, - this->unk_168[index], POLY_XLU_DISP); + if (pthis->unk_168[index] > 0) { + POLY_XLU_DISP = func_8088DC50(globalCtx, pthis, pthis->dyna.actor.shape.rot.y + index * 0x4000, + pthis->unk_168[index], POLY_XLU_DISP); } } } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c b/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c deleted file mode 100644 index 8cbeab661..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c +++ /dev/null @@ -1,311 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_SIMA_Z_BG_HIDAN_SIMA_C -#include "actor_common.h" -/* - * File: z_bg_hidan_sima.c - * Overlay: ovl_Bg_Hidan_Sima - * Description: Stone platform (Fire Temple) - */ - -#include "z_bg_hidan_sima.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/cosf.h" -#include "def/graph.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void BgHidanSima_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanSima_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanSima_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanSima_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8088E518(BgHidanSima* this, GlobalContext* globalCtx); -void func_8088E5D0(BgHidanSima* this, GlobalContext* globalCtx); -void func_8088E6D0(BgHidanSima* this, GlobalContext* globalCtx); -void func_8088E760(BgHidanSima* this, GlobalContext* globalCtx); -void func_8088E7A8(BgHidanSima* this, GlobalContext* globalCtx); -void func_8088E90C(BgHidanSima* this); - -const ActorInit Bg_Hidan_Sima_InitVars = { - ACTOR_BG_HIDAN_SIMA, - ACTORCAT_BG, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanSima), - (ActorFunc)BgHidanSima_Init, - (ActorFunc)BgHidanSima_Destroy, - (ActorFunc)BgHidanSima_Update, - (ActorFunc)BgHidanSima_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 1, { { 0, 40, 100 }, 22 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 1, { { 0, 40, 145 }, 30 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphElementsInit), - sJntSphElementsInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -static void* sFireballsTexs[] = { - gFireTempleFireball0Tex, gFireTempleFireball1Tex, gFireTempleFireball2Tex, gFireTempleFireball3Tex, - gFireTempleFireball4Tex, gFireTempleFireball5Tex, gFireTempleFireball6Tex, gFireTempleFireball7Tex, -}; - -void BgHidanSima_Init(Actor* thisx, GlobalContext* globalCtx) { - BgHidanSima* this = (BgHidanSima*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - s32 i; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - if (this->dyna.actor.params == 0) { - CollisionHeader_GetVirtual(&gFireTempleStonePlatform1Col, &colHeader); - } else { - CollisionHeader_GetVirtual(&gFireTempleStonePlatform2Col, &colHeader); - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->elements); - for (i = 0; i < ARRAY_COUNT(sJntSphElementsInit); i++) { - this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; - } - if (this->dyna.actor.params == 0) { - this->actionFunc = func_8088E518; - } else { - this->actionFunc = func_8088E760; - } -} - -void BgHidanSima_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanSima* this = (BgHidanSima*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void func_8088E518(BgHidanSima* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 3.4f); - if (func_8004356C(&this->dyna) && !(player->stateFlags1 & 0x6000)) { - this->timer = 20; - this->dyna.actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4000; - if (this->dyna.actor.home.pos.y <= this->dyna.actor.world.pos.y) { - this->actionFunc = func_8088E5D0; - } else { - this->actionFunc = func_8088E6D0; - } - } -} - -void func_8088E5D0(BgHidanSima* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer != 0) { - this->dyna.actor.world.pos.x = - Math_SinS(this->dyna.actor.world.rot.y + (this->timer * 0x4000)) * 5.0f + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = - Math_CosS(this->dyna.actor.world.rot.y + (this->timer * 0x4000)) * 5.0f + this->dyna.actor.home.pos.z; - } else { - this->actionFunc = func_8088E6D0; - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; - } - if (!(this->timer % 4)) { - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 180, 10, 100); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE); - } -} - -void func_8088E6D0(BgHidanSima* this, GlobalContext* globalCtx) { - if (func_8004356C(&this->dyna)) { - this->timer = 20; - } else if (this->timer != 0) { - this->timer--; - } - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 100.0f, 1.7f); - if (this->timer == 0) { - this->actionFunc = func_8088E518; - } -} - -void func_8088E760(BgHidanSima* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->dyna.actor.world.rot.y += 0x8000; - this->timer = 60; - this->actionFunc = func_8088E7A8; - } -} - -void func_8088E7A8(BgHidanSima* this, GlobalContext* globalCtx) { - f32 temp; - - if (this->timer != 0) { - this->timer--; - } - if (this->dyna.actor.world.rot.y != this->dyna.actor.home.rot.y) { - temp = (sinf(((60 - this->timer) * 0.01667 - 0.5) * M_PI) + 1) * 200; - } else { - temp = (sinf((this->timer * 0.01667 - 0.5) * M_PI) + 1) * -200; - } - this->dyna.actor.world.pos.x = Math_SinS(this->dyna.actor.world.rot.y) * temp + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = Math_CosS(this->dyna.actor.world.rot.y) * temp + this->dyna.actor.home.pos.z; - if (this->timer == 0) { - this->timer = 20; - this->actionFunc = func_8088E760; - } - func_8002F974(&this->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); -} - -void func_8088E90C(BgHidanSima* this) { - ColliderJntSphElement* elem; - s32 i; - f32 cos = Math_CosS(this->dyna.actor.world.rot.y + 0x8000); - f32 sin = Math_SinS(this->dyna.actor.world.rot.y + 0x8000); - - for (i = 0; i < 2; i++) { - elem = &this->collider.elements[i]; - elem->dim.worldSphere.center.x = this->dyna.actor.world.pos.x + sin * elem->dim.modelSphere.center.z; - elem->dim.worldSphere.center.y = (s16)this->dyna.actor.world.pos.y + elem->dim.modelSphere.center.y; - elem->dim.worldSphere.center.z = this->dyna.actor.world.pos.z + cos * elem->dim.modelSphere.center.z; - } -} - -void BgHidanSima_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanSima* this = (BgHidanSima*)thisx; - s32 pad; - - this->actionFunc(this, globalCtx); - if (this->dyna.actor.params != 0) { - s32 temp = (this->dyna.actor.world.rot.y == this->dyna.actor.shape.rot.y) ? this->timer : (this->timer + 80); - - if (this->actionFunc == func_8088E7A8) { - temp += 20; - } - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - ((1.0f - cosf(temp * (M_PI / 20))) * 5.0f); - if (this->actionFunc == func_8088E7A8) { - func_8088E90C(this); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -Gfx* func_8088EB54(GlobalContext* globalCtx, BgHidanSima* this, Gfx* gfx) { - MtxF mtxF; - s32 phi_s5; - s32 s3; - s32 v0; - f32 cos; - f32 sin; - s32 pad[2]; - - Matrix_MtxFCopy(&mtxF, &gMtxFClear); - cos = Math_CosS(this->dyna.actor.world.rot.y + 0x8000); - sin = Math_SinS(this->dyna.actor.world.rot.y + 0x8000); - - phi_s5 = (60 - this->timer) >> 1; - phi_s5 = CLAMP_MAX(phi_s5, 3); - - v0 = 3 - (this->timer >> 1); - v0 = CLAMP_MIN(v0, 0); - - mtxF.xw = this->dyna.actor.world.pos.x + ((79 - ((this->timer % 6) * 4)) + v0 * 25) * sin; - mtxF.zw = this->dyna.actor.world.pos.z + ((79 - ((this->timer % 6) * 4)) + v0 * 25) * cos; - mtxF.yw = this->dyna.actor.world.pos.y + 40.0f; - mtxF.zz = v0 * 0.4f + 1.0f; - mtxF.yy = v0 * 0.4f + 1.0f; - mtxF.xx = v0 * 0.4f + 1.0f; - - for (s3 = v0; s3 < phi_s5; s3++) { - mtxF.xw += 25.0f * sin; - mtxF.zw += 25.0f * cos; - mtxF.xx += 0.4f; - mtxF.yy += 0.4f; - mtxF.zz += 0.4f; - - gSPSegment(gfx++, 0x09, SEGMENTED_TO_VIRTUAL(sFireballsTexs[(this->timer + s3) % 7])); - gSPMatrix(gfx++, - Matrix_MtxFToMtx(Matrix_CheckFloats(&mtxF, "../z_bg_hidan_sima.c", 611), - Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, gFireTempleFireballDL); - } - mtxF.xw = this->dyna.actor.world.pos.x + (phi_s5 * 25 + 80) * sin; - mtxF.zw = this->dyna.actor.world.pos.z + (phi_s5 * 25 + 80) * cos; - gSPSegment(gfx++, 0x09, SEGMENTED_TO_VIRTUAL(sFireballsTexs[(this->timer + s3) % 7])); - gSPMatrix(gfx++, - Matrix_MtxFToMtx(Matrix_CheckFloats(&mtxF, "../z_bg_hidan_sima.c", 624), - Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, gFireTempleFireballDL); - return gfx; -} - -void BgHidanSima_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgHidanSima* this = (BgHidanSima*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_sima.c", 641); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_sima.c", 645), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->dyna.actor.params == 0) { - gSPDisplayList(POLY_OPA_DISP++, gFireTempleStonePlatform1DL); - } else { - gSPDisplayList(POLY_OPA_DISP++, gFireTempleStonePlatform2DL); - if (this->actionFunc == func_8088E7A8) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 1, 255, 255, 0, 150); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); - POLY_XLU_DISP = func_8088EB54(globalCtx, this, POLY_XLU_DISP); - } - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_sima.c", 668); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.cpp b/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.cpp new file mode 100644 index 000000000..30f4d0358 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.cpp @@ -0,0 +1,311 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_SIMA_Z_BG_HIDAN_SIMA_C +#include "actor_common.h" +/* + * File: z_bg_hidan_sima.c + * Overlay: ovl_Bg_Hidan_Sima + * Description: Stone platform (Fire Temple) + */ + +#include "z_bg_hidan_sima.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/cosf.h" +#include "def/graph.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void BgHidanSima_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanSima_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanSima_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanSima_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8088E518(BgHidanSima* pthis, GlobalContext* globalCtx); +void func_8088E5D0(BgHidanSima* pthis, GlobalContext* globalCtx); +void func_8088E6D0(BgHidanSima* pthis, GlobalContext* globalCtx); +void func_8088E760(BgHidanSima* pthis, GlobalContext* globalCtx); +void func_8088E7A8(BgHidanSima* pthis, GlobalContext* globalCtx); +void func_8088E90C(BgHidanSima* pthis); + +ActorInit Bg_Hidan_Sima_InitVars = { + ACTOR_BG_HIDAN_SIMA, + ACTORCAT_BG, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanSima), + (ActorFunc)BgHidanSima_Init, + (ActorFunc)BgHidanSima_Destroy, + (ActorFunc)BgHidanSima_Update, + (ActorFunc)BgHidanSima_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 1, { { 0, 40, 100 }, 22 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 1, { { 0, 40, 145 }, 30 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +static void* sFireballsTexs[] = { + gFireTempleFireball0Tex, gFireTempleFireball1Tex, gFireTempleFireball2Tex, gFireTempleFireball3Tex, + gFireTempleFireball4Tex, gFireTempleFireball5Tex, gFireTempleFireball6Tex, gFireTempleFireball7Tex, +}; + +void BgHidanSima_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHidanSima* pthis = (BgHidanSima*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + s32 i; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + if (pthis->dyna.actor.params == 0) { + CollisionHeader_GetVirtual(&gFireTempleStonePlatform1Col, &colHeader); + } else { + CollisionHeader_GetVirtual(&gFireTempleStonePlatform2Col, &colHeader); + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->elements); + for (i = 0; i < ARRAY_COUNT(sJntSphElementsInit); i++) { + pthis->collider.elements[i].dim.worldSphere.radius = pthis->collider.elements[i].dim.modelSphere.radius; + } + if (pthis->dyna.actor.params == 0) { + pthis->actionFunc = func_8088E518; + } else { + pthis->actionFunc = func_8088E760; + } +} + +void BgHidanSima_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanSima* pthis = (BgHidanSima*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void func_8088E518(BgHidanSima* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 3.4f); + if (func_8004356C(&pthis->dyna) && !(player->stateFlags1 & 0x6000)) { + pthis->timer = 20; + pthis->dyna.actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4000; + if (pthis->dyna.actor.home.pos.y <= pthis->dyna.actor.world.pos.y) { + pthis->actionFunc = func_8088E5D0; + } else { + pthis->actionFunc = func_8088E6D0; + } + } +} + +void func_8088E5D0(BgHidanSima* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer != 0) { + pthis->dyna.actor.world.pos.x = + Math_SinS(pthis->dyna.actor.world.rot.y + (pthis->timer * 0x4000)) * 5.0f + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = + Math_CosS(pthis->dyna.actor.world.rot.y + (pthis->timer * 0x4000)) * 5.0f + pthis->dyna.actor.home.pos.z; + } else { + pthis->actionFunc = func_8088E6D0; + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z; + } + if (!(pthis->timer % 4)) { + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 180, 10, 100); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_SHAKE); + } +} + +void func_8088E6D0(BgHidanSima* pthis, GlobalContext* globalCtx) { + if (func_8004356C(&pthis->dyna)) { + pthis->timer = 20; + } else if (pthis->timer != 0) { + pthis->timer--; + } + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 100.0f, 1.7f); + if (pthis->timer == 0) { + pthis->actionFunc = func_8088E518; + } +} + +void func_8088E760(BgHidanSima* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + pthis->dyna.actor.world.rot.y += 0x8000; + pthis->timer = 60; + pthis->actionFunc = func_8088E7A8; + } +} + +void func_8088E7A8(BgHidanSima* pthis, GlobalContext* globalCtx) { + f32 temp; + + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->dyna.actor.world.rot.y != pthis->dyna.actor.home.rot.y) { + temp = (sinf(((60 - pthis->timer) * 0.01667 - 0.5) * M_PI) + 1) * 200; + } else { + temp = (sinf((pthis->timer * 0.01667 - 0.5) * M_PI) + 1) * -200; + } + pthis->dyna.actor.world.pos.x = Math_SinS(pthis->dyna.actor.world.rot.y) * temp + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = Math_CosS(pthis->dyna.actor.world.rot.y) * temp + pthis->dyna.actor.home.pos.z; + if (pthis->timer == 0) { + pthis->timer = 20; + pthis->actionFunc = func_8088E760; + } + func_8002F974(&pthis->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); +} + +void func_8088E90C(BgHidanSima* pthis) { + ColliderJntSphElement* elem; + s32 i; + f32 cos = Math_CosS(pthis->dyna.actor.world.rot.y + 0x8000); + f32 sin = Math_SinS(pthis->dyna.actor.world.rot.y + 0x8000); + + for (i = 0; i < 2; i++) { + elem = &pthis->collider.elements[i]; + elem->dim.worldSphere.center.x = pthis->dyna.actor.world.pos.x + sin * elem->dim.modelSphere.center.z; + elem->dim.worldSphere.center.y = (s16)pthis->dyna.actor.world.pos.y + elem->dim.modelSphere.center.y; + elem->dim.worldSphere.center.z = pthis->dyna.actor.world.pos.z + cos * elem->dim.modelSphere.center.z; + } +} + +void BgHidanSima_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHidanSima* pthis = (BgHidanSima*)thisx; + s32 pad; + + pthis->actionFunc(pthis, globalCtx); + if (pthis->dyna.actor.params != 0) { + s32 temp = (pthis->dyna.actor.world.rot.y == pthis->dyna.actor.shape.rot.y) ? pthis->timer : (pthis->timer + 80); + + if (pthis->actionFunc == func_8088E7A8) { + temp += 20; + } + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - ((1.0f - cosf(temp * (M_PI / 20))) * 5.0f); + if (pthis->actionFunc == func_8088E7A8) { + func_8088E90C(pthis); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +Gfx* func_8088EB54(GlobalContext* globalCtx, BgHidanSima* pthis, Gfx* gfx) { + MtxF mtxF; + s32 phi_s5; + s32 s3; + s32 v0; + f32 cos; + f32 sin; + s32 pad[2]; + + Matrix_MtxFCopy(&mtxF, &gMtxFClear); + cos = Math_CosS(pthis->dyna.actor.world.rot.y + 0x8000); + sin = Math_SinS(pthis->dyna.actor.world.rot.y + 0x8000); + + phi_s5 = (60 - pthis->timer) >> 1; + phi_s5 = CLAMP_MAX(phi_s5, 3); + + v0 = 3 - (pthis->timer >> 1); + v0 = CLAMP_MIN(v0, 0); + + mtxF.xw = pthis->dyna.actor.world.pos.x + ((79 - ((pthis->timer % 6) * 4)) + v0 * 25) * sin; + mtxF.zw = pthis->dyna.actor.world.pos.z + ((79 - ((pthis->timer % 6) * 4)) + v0 * 25) * cos; + mtxF.yw = pthis->dyna.actor.world.pos.y + 40.0f; + mtxF.zz = v0 * 0.4f + 1.0f; + mtxF.yy = v0 * 0.4f + 1.0f; + mtxF.xx = v0 * 0.4f + 1.0f; + + for (s3 = v0; s3 < phi_s5; s3++) { + mtxF.xw += 25.0f * sin; + mtxF.zw += 25.0f * cos; + mtxF.xx += 0.4f; + mtxF.yy += 0.4f; + mtxF.zz += 0.4f; + + gSPSegment(gfx++, 0x09, SEGMENTED_TO_VIRTUAL(sFireballsTexs[(pthis->timer + s3) % 7])); + gSPMatrix(gfx++, + Matrix_MtxFToMtx(&mtxF, + (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gFireTempleFireballDL); + } + mtxF.xw = pthis->dyna.actor.world.pos.x + (phi_s5 * 25 + 80) * sin; + mtxF.zw = pthis->dyna.actor.world.pos.z + (phi_s5 * 25 + 80) * cos; + gSPSegment(gfx++, 0x09, SEGMENTED_TO_VIRTUAL(sFireballsTexs[(pthis->timer + s3) % 7])); + gSPMatrix(gfx++, + Matrix_MtxFToMtx(&mtxF, + (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx))), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gFireTempleFireballDL); + return gfx; +} + +void BgHidanSima_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHidanSima* pthis = (BgHidanSima*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_sima.c", 641); + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_sima.c", 645), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (pthis->dyna.actor.params == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFireTempleStonePlatform1DL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gFireTempleStonePlatform2DL); + if (pthis->actionFunc == func_8088E7A8) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 1, 255, 255, 0, 150); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); + POLY_XLU_DISP = func_8088EB54(globalCtx, pthis, POLY_XLU_DISP); + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_sima.c", 668); +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c deleted file mode 100644 index d101dcb36..000000000 --- a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c +++ /dev/null @@ -1,135 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_SYOKU_Z_BG_HIDAN_SYOKU_C -#include "actor_common.h" -/* - * File: z_bg_hidan_syoku.c - * Overlay: ovl_Bg_Hidan_Syoku - * Description: Stone Elevator in the Fire Temple - */ - -#include "z_bg_hidan_syoku.h" -#include "objects/object_hidan_objects/object_hidan_objects.h" -#include "def/code_80043480.h" -#include "def/cosf.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgHidanSyoku_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHidanSyoku_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHidanSyoku_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHidanSyoku_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8088F4B8(BgHidanSyoku* this, GlobalContext* globalCtx); -void func_8088F514(BgHidanSyoku* this, GlobalContext* globalCtx); -void func_8088F62C(BgHidanSyoku* this, GlobalContext* globalCtx); - -const ActorInit Bg_Hidan_Syoku_InitVars = { - ACTOR_BG_HIDAN_SYOKU, - ACTORCAT_BG, - FLAGS, - OBJECT_HIDAN_OBJECTS, - sizeof(BgHidanSyoku), - (ActorFunc)BgHidanSyoku_Init, - (ActorFunc)BgHidanSyoku_Destroy, - (ActorFunc)BgHidanSyoku_Update, - (ActorFunc)BgHidanSyoku_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgHidanSyoku_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgHidanSyoku* this = (BgHidanSyoku*)thisx; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(&gFireTempleFlareDancerPlatformCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->actionFunc = func_8088F4B8; - this->dyna.actor.home.pos.y += 540.0f; -} - -void BgHidanSyoku_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgHidanSyoku* this = (BgHidanSyoku*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_8088F47C(BgHidanSyoku* this) { - this->timer = 60; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - this->actionFunc = func_8088F62C; -} - -void func_8088F4B8(BgHidanSyoku* this, GlobalContext* globalCtx) { - if (Flags_GetClear(globalCtx, this->dyna.actor.room) && func_8004356C(&this->dyna)) { - this->timer = 140; - this->actionFunc = func_8088F514; - } -} - -void func_8088F514(BgHidanSyoku* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - this->dyna.actor.world.pos.y = (cosf(this->timer * (M_PI / 140)) * 540.0f) + this->dyna.actor.home.pos.y; - if (this->timer == 0) { - func_8088F47C(this); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); - } -} - -void func_8088F5A0(BgHidanSyoku* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - (cosf(this->timer * (M_PI / 140)) * 540.0f); - if (this->timer == 0) { - func_8088F47C(this); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); - } -} - -void func_8088F62C(BgHidanSyoku* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->timer = 140; - if (this->dyna.actor.world.pos.y < this->dyna.actor.home.pos.y) { - this->actionFunc = func_8088F514; - } else { - this->actionFunc = func_8088F5A0; - } - } -} - -void BgHidanSyoku_Update(Actor* thisx, GlobalContext* globalCtx) { - BgHidanSyoku* this = (BgHidanSyoku*)thisx; - - this->actionFunc(this, globalCtx); - if (func_8004356C(&this->dyna)) { - if (this->unk_168 == 0) { - this->unk_168 = 3; - } - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); - } else if (!func_8004356C(&this->dyna)) { - if (this->unk_168 != 0) { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); - } - this->unk_168 = 0; - } -} - -void BgHidanSyoku_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gFireTempleFlareDancerPlatformDL); -} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.cpp b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.cpp new file mode 100644 index 000000000..bdef785e2 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.cpp @@ -0,0 +1,135 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_HIDAN_SYOKU_Z_BG_HIDAN_SYOKU_C +#include "actor_common.h" +/* + * File: z_bg_hidan_syoku.c + * Overlay: ovl_Bg_Hidan_Syoku + * Description: Stone Elevator in the Fire Temple + */ + +#include "z_bg_hidan_syoku.h" +#include "objects/object_hidan_objects/object_hidan_objects.h" +#include "def/code_80043480.h" +#include "def/cosf.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgHidanSyoku_Init(Actor* thisx, GlobalContext* globalCtx); +void BgHidanSyoku_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgHidanSyoku_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHidanSyoku_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8088F4B8(BgHidanSyoku* pthis, GlobalContext* globalCtx); +void func_8088F514(BgHidanSyoku* pthis, GlobalContext* globalCtx); +void func_8088F62C(BgHidanSyoku* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Hidan_Syoku_InitVars = { + ACTOR_BG_HIDAN_SYOKU, + ACTORCAT_BG, + FLAGS, + OBJECT_HIDAN_OBJECTS, + sizeof(BgHidanSyoku), + (ActorFunc)BgHidanSyoku_Init, + (ActorFunc)BgHidanSyoku_Destroy, + (ActorFunc)BgHidanSyoku_Update, + (ActorFunc)BgHidanSyoku_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgHidanSyoku_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHidanSyoku* pthis = (BgHidanSyoku*)thisx; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(&gFireTempleFlareDancerPlatformCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->actionFunc = func_8088F4B8; + pthis->dyna.actor.home.pos.y += 540.0f; +} + +void BgHidanSyoku_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanSyoku* pthis = (BgHidanSyoku*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_8088F47C(BgHidanSyoku* pthis) { + pthis->timer = 60; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + pthis->actionFunc = func_8088F62C; +} + +void func_8088F4B8(BgHidanSyoku* pthis, GlobalContext* globalCtx) { + if (Flags_GetClear(globalCtx, pthis->dyna.actor.room) && func_8004356C(&pthis->dyna)) { + pthis->timer = 140; + pthis->actionFunc = func_8088F514; + } +} + +void func_8088F514(BgHidanSyoku* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + pthis->dyna.actor.world.pos.y = (cosf(pthis->timer * (M_PI / 140)) * 540.0f) + pthis->dyna.actor.home.pos.y; + if (pthis->timer == 0) { + func_8088F47C(pthis); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + } +} + +void func_8088F5A0(BgHidanSyoku* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - (cosf(pthis->timer * (M_PI / 140)) * 540.0f); + if (pthis->timer == 0) { + func_8088F47C(pthis); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + } +} + +void func_8088F62C(BgHidanSyoku* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + pthis->timer = 140; + if (pthis->dyna.actor.world.pos.y < pthis->dyna.actor.home.pos.y) { + pthis->actionFunc = func_8088F514; + } else { + pthis->actionFunc = func_8088F5A0; + } + } +} + +void BgHidanSyoku_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHidanSyoku* pthis = (BgHidanSyoku*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (func_8004356C(&pthis->dyna)) { + if (pthis->unk_168 == 0) { + pthis->unk_168 = 3; + } + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); + } else if (!func_8004356C(&pthis->dyna)) { + if (pthis->unk_168 != 0) { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); + } + pthis->unk_168 = 0; + } +} + +void BgHidanSyoku_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gFireTempleFlareDancerPlatformDL); +} diff --git a/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c b/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.cpp similarity index 57% rename from src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c rename to src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.cpp index 9ccb6eb4f..57fb431a5 100644 --- a/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c +++ b/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.cpp @@ -24,16 +24,16 @@ void BgIceObjects_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIceObjects_Update(Actor* thisx, GlobalContext* globalCtx); void BgIceObjects_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgIceObjects_Idle(BgIceObjects* this, GlobalContext* globalCtx); -void BgIceObjects_Slide(BgIceObjects* this, GlobalContext* globalCtx); -void BgIceObjects_Reset(BgIceObjects* this, GlobalContext* globalCtx); -void BgIceObjects_Stuck(BgIceObjects* this, GlobalContext* globalCtx); +void BgIceObjects_Idle(BgIceObjects* pthis, GlobalContext* globalCtx); +void BgIceObjects_Slide(BgIceObjects* pthis, GlobalContext* globalCtx); +void BgIceObjects_Reset(BgIceObjects* pthis, GlobalContext* globalCtx); +void BgIceObjects_Stuck(BgIceObjects* pthis, GlobalContext* globalCtx); static Color_RGBA8 sWhite = { 250, 250, 250, 255 }; static Color_RGBA8 sGray = { 180, 180, 180, 255 }; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -const ActorInit Bg_Ice_Objects_InitVars = { +ActorInit Bg_Ice_Objects_InitVars = { ACTOR_BG_ICE_OBJECTS, ACTORCAT_PROP, FLAGS, @@ -51,23 +51,23 @@ static InitChainEntry sInitChain[] = { void BgIceObjects_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgIceObjects* this = (BgIceObjects*)thisx; + BgIceObjects* pthis = (BgIceObjects*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&object_ice_objects_Col_0003F0, &colHeader); - Math_Vec3f_Copy(&this->targetPos, &this->dyna.actor.home.pos); - this->actionFunc = BgIceObjects_Idle; - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->dyna.actor.params = 0; + Math_Vec3f_Copy(&pthis->targetPos, &pthis->dyna.actor.home.pos); + pthis->actionFunc = BgIceObjects_Idle; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->dyna.actor.params = 0; } void BgIceObjects_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgIceObjects* this = (BgIceObjects*)thisx; + BgIceObjects* pthis = (BgIceObjects*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } static s16 sXStarts[] = { @@ -89,39 +89,39 @@ static s16 sXStops[7][2] = { * defaulting to the maximum x wall or minimum z wall. Each x and z position * has only one possible wall or pit on each side of it. */ -void BgIceObjects_SetNextTarget(BgIceObjects* this, GlobalContext* globalCtx) { +void BgIceObjects_SetNextTarget(BgIceObjects* pthis, GlobalContext* globalCtx) { s16 x16; s16 z16 = 0; // needed to match s32 i; - if ((this->dyna.unk_158 == 0) || (this->dyna.unk_158 == -0x8000)) { - x16 = this->dyna.actor.world.pos.x; + if ((pthis->dyna.unk_158 == 0) || (pthis->dyna.unk_158 == -0x8000)) { + x16 = pthis->dyna.actor.world.pos.x; for (i = 0; i < 7; i++) { if (x16 == sXStarts[i]) { - z16 = (this->dyna.unk_158 == 0) ? sZStops[i][0] : sZStops[i][1]; - this->targetPos.z = z16; + z16 = (pthis->dyna.unk_158 == 0) ? sZStops[i][0] : sZStops[i][1]; + pthis->targetPos.z = z16; return; } } - this->targetPos.z = (this->dyna.unk_158 == 0) ? -340 : -1260; + pthis->targetPos.z = (pthis->dyna.unk_158 == 0) ? -340 : -1260; } else { - z16 = this->dyna.actor.world.pos.z; + z16 = pthis->dyna.actor.world.pos.z; for (i = 0; i < 7; i++) { if (z16 == sZStarts[i]) { - x16 = (this->dyna.unk_158 == 0x4000) ? sXStops[i][0] : sXStops[i][1]; - this->targetPos.x = x16; + x16 = (pthis->dyna.unk_158 == 0x4000) ? sXStops[i][0] : sXStops[i][1]; + pthis->targetPos.x = x16; return; } } - this->targetPos.x = (this->dyna.unk_158 == 0x4000) ? -860 : -1780; + pthis->targetPos.x = (pthis->dyna.unk_158 == 0x4000) ? -860 : -1780; } } /* * Checks if the block has fallen into any of the pits. */ -void BgIceObjects_CheckPits(BgIceObjects* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void BgIceObjects_CheckPits(BgIceObjects* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; if ((thisx->velocity.y > 0.0f) || ((thisx->world.pos.x <= -1660.0f) && (thisx->world.pos.z <= -1060.0f)) || ((thisx->world.pos.x <= -1580.0f) && (thisx->world.pos.z >= -420.0f)) || @@ -137,47 +137,47 @@ void BgIceObjects_CheckPits(BgIceObjects* this, GlobalContext* globalCtx) { if (thisx->params != 0) { func_8002DF54(globalCtx, thisx, 7); } - this->actionFunc = BgIceObjects_Reset; + pthis->actionFunc = BgIceObjects_Reset; } } } -void BgIceObjects_Idle(BgIceObjects* this, GlobalContext* globalCtx) { +void BgIceObjects_Idle(BgIceObjects* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { player->stateFlags2 &= ~0x10; - if ((this->dyna.unk_150 > 0.0f) && !Player_InCsMode(globalCtx)) { - BgIceObjects_SetNextTarget(this, globalCtx); - if (Actor_WorldDistXZToPoint(thisx, &this->targetPos) > 1.0f) { + if ((pthis->dyna.unk_150 > 0.0f) && !Player_InCsMode(globalCtx)) { + BgIceObjects_SetNextTarget(pthis, globalCtx); + if (Actor_WorldDistXZToPoint(thisx, &pthis->targetPos) > 1.0f) { thisx->flags |= ACTOR_FLAG_4; func_8002DF54(globalCtx, thisx, 8); thisx->params = 1; - this->actionFunc = BgIceObjects_Slide; + pthis->actionFunc = BgIceObjects_Slide; } } - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } if (thisx->velocity.y > 0.0f) { - BgIceObjects_CheckPits(this, globalCtx); + BgIceObjects_CheckPits(pthis, globalCtx); } } -void BgIceObjects_Slide(BgIceObjects* this, GlobalContext* globalCtx) { +void BgIceObjects_Slide(BgIceObjects* pthis, GlobalContext* globalCtx) { s32 atTarget; Vec3f pos; Vec3f velocity; f32 spread; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; Math_StepToF(&thisx->speedXZ, 10.0f, 0.5f); - atTarget = Math_StepToF(&thisx->world.pos.x, this->targetPos.x, thisx->speedXZ); - atTarget &= Math_StepToF(&thisx->world.pos.z, this->targetPos.z, thisx->speedXZ); + atTarget = Math_StepToF(&thisx->world.pos.x, pthis->targetPos.x, thisx->speedXZ); + atTarget &= Math_StepToF(&thisx->world.pos.z, pthis->targetPos.z, thisx->speedXZ); if (atTarget) { thisx->speedXZ = 0.0f; - this->targetPos.x = thisx->world.pos.x; - this->targetPos.z = thisx->world.pos.z; + pthis->targetPos.x = thisx->world.pos.x; + pthis->targetPos.z = thisx->world.pos.z; if (thisx->velocity.y <= 0.0f) { thisx->flags &= ~ACTOR_FLAG_4; } @@ -185,63 +185,63 @@ void BgIceObjects_Slide(BgIceObjects* this, GlobalContext* globalCtx) { func_8002DF54(globalCtx, thisx, 7); Audio_PlayActorSound2(thisx, NA_SE_EV_BLOCK_BOUND); if ((fabsf(thisx->world.pos.x + 1387.0f) < 1.0f) && (fabsf(thisx->world.pos.z + 260.0f) < 1.0f)) { - this->actionFunc = BgIceObjects_Stuck; + pthis->actionFunc = BgIceObjects_Stuck; } else { - this->actionFunc = BgIceObjects_Idle; + pthis->actionFunc = BgIceObjects_Idle; } } else if ((thisx->speedXZ > 6.0f) && (thisx->world.pos.y >= 0.0f)) { spread = Rand_CenteredFloat(120.0f); - velocity.x = -(1.5f + Rand_ZeroOne()) * Math_SinS(this->dyna.unk_158); + velocity.x = -(1.5f + Rand_ZeroOne()) * Math_SinS(pthis->dyna.unk_158); velocity.y = Rand_ZeroOne() + 1.0f; - velocity.z = -(1.5f + Rand_ZeroOne()) * Math_CosS(this->dyna.unk_158); - pos.x = thisx->world.pos.x - (60.0f * Math_SinS(this->dyna.unk_158)) - (Math_CosS(this->dyna.unk_158) * spread); - pos.z = thisx->world.pos.z - (60.0f * Math_CosS(this->dyna.unk_158)) + (Math_SinS(this->dyna.unk_158) * spread); + velocity.z = -(1.5f + Rand_ZeroOne()) * Math_CosS(pthis->dyna.unk_158); + pos.x = thisx->world.pos.x - (60.0f * Math_SinS(pthis->dyna.unk_158)) - (Math_CosS(pthis->dyna.unk_158) * spread); + pos.z = thisx->world.pos.z - (60.0f * Math_CosS(pthis->dyna.unk_158)) + (Math_SinS(pthis->dyna.unk_158) * spread); pos.y = thisx->world.pos.y; func_8002829C(globalCtx, &pos, &velocity, &sZeroVec, &sWhite, &sGray, 250, Rand_S16Offset(40, 15)); spread = Rand_CenteredFloat(120.0f); - pos.x = thisx->world.pos.x - (60.0f * Math_SinS(this->dyna.unk_158)) + (Math_CosS(this->dyna.unk_158) * spread); - pos.z = thisx->world.pos.z - (60.0f * Math_CosS(this->dyna.unk_158)) - (Math_SinS(this->dyna.unk_158) * spread); + pos.x = thisx->world.pos.x - (60.0f * Math_SinS(pthis->dyna.unk_158)) + (Math_CosS(pthis->dyna.unk_158) * spread); + pos.z = thisx->world.pos.z - (60.0f * Math_CosS(pthis->dyna.unk_158)) - (Math_SinS(pthis->dyna.unk_158) * spread); func_8002829C(globalCtx, &pos, &velocity, &sZeroVec, &sWhite, &sGray, 250, Rand_S16Offset(40, 15)); func_8002F974(thisx, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } - BgIceObjects_CheckPits(this, globalCtx); + BgIceObjects_CheckPits(pthis, globalCtx); } -void BgIceObjects_Reset(BgIceObjects* this, GlobalContext* globalCtx) { +void BgIceObjects_Reset(BgIceObjects* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y, 1.0f)) { thisx->flags &= ~ACTOR_FLAG_4; - Math_Vec3f_Copy(&this->targetPos, &thisx->home.pos); - this->actionFunc = BgIceObjects_Idle; + Math_Vec3f_Copy(&pthis->targetPos, &thisx->home.pos); + pthis->actionFunc = BgIceObjects_Idle; thisx->speedXZ = 0.0f; } } -void BgIceObjects_Stuck(BgIceObjects* this, GlobalContext* globalCtx) { +void BgIceObjects_Stuck(BgIceObjects* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 != 0.0f) { + if (pthis->dyna.unk_150 != 0.0f) { player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } } void BgIceObjects_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgIceObjects* this = (BgIceObjects*)thisx; + BgIceObjects* pthis = (BgIceObjects*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgIceObjects_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgIceObjects* this = (BgIceObjects*)thisx; + BgIceObjects* pthis = (BgIceObjects*)thisx; Gfx_DrawDListOpa(globalCtx, object_ice_objects_DL_000190); } diff --git a/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c b/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.cpp similarity index 62% rename from src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c rename to src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.cpp index ec82b0e67..164c576a2 100644 --- a/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c +++ b/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.cpp @@ -19,13 +19,13 @@ void BgIceShelter_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIceShelter_Update(Actor* thisx, GlobalContext* globalCtx); void BgIceShelter_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80891064(BgIceShelter* this); -void func_808911BC(BgIceShelter* this); +void func_80891064(BgIceShelter* pthis); +void func_808911BC(BgIceShelter* pthis); -void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx); -void func_808911D4(BgIceShelter* this, GlobalContext* globalCtx); +void func_8089107C(BgIceShelter* pthis, GlobalContext* globalCtx); +void func_808911D4(BgIceShelter* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Ice_Shelter_InitVars = { +ActorInit Bg_Ice_Shelter_InitVars = { ACTOR_BG_ICE_SHELTER, ACTORCAT_BG, FLAGS, @@ -82,46 +82,46 @@ static ColliderCylinderInit D_80891738 = { { 0, 0, 0, { 0, 0, 0 } }, }; -void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) { +void func_80890740(BgIceShelter* pthis, GlobalContext* globalCtx) { static s16 cylinderRadii[] = { 47, 33, 44, 41, 100 }; static s16 cylinderHeights[] = { 80, 54, 90, 60, 200 }; s32 pad; - s32 type = (this->dyna.actor.params >> 8) & 7; + s32 type = (pthis->dyna.actor.params >> 8) & 7; - Collider_InitCylinder(globalCtx, &this->cylinder1); - Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &D_8089170C); - Collider_UpdateCylinder(&this->dyna.actor, &this->cylinder1); + Collider_InitCylinder(globalCtx, &pthis->cylinder1); + Collider_SetCylinder(globalCtx, &pthis->cylinder1, &pthis->dyna.actor, &D_8089170C); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->cylinder1); - this->cylinder1.dim.radius = cylinderRadii[type]; - this->cylinder1.dim.height = cylinderHeights[type]; + pthis->cylinder1.dim.radius = cylinderRadii[type]; + pthis->cylinder1.dim.height = cylinderHeights[type]; if (type == 0 || type == 1 || type == 4) { - Collider_InitCylinder(globalCtx, &this->cylinder2); - Collider_SetCylinder(globalCtx, &this->cylinder2, &this->dyna.actor, &D_80891738); - Collider_UpdateCylinder(&this->dyna.actor, &this->cylinder2); - this->cylinder2.dim.radius = cylinderRadii[type]; - this->cylinder2.dim.height = cylinderHeights[type]; + Collider_InitCylinder(globalCtx, &pthis->cylinder2); + Collider_SetCylinder(globalCtx, &pthis->cylinder2, &pthis->dyna.actor, &D_80891738); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->cylinder2); + pthis->cylinder2.dim.radius = cylinderRadii[type]; + pthis->cylinder2.dim.height = cylinderHeights[type]; } if (type == 4) { - this->cylinder1.dim.pos.z += 30; - this->cylinder2.dim.pos.z += 30; + pthis->cylinder1.dim.pos.z += 30; + pthis->cylinder2.dim.pos.z += 30; } } -void func_80890874(BgIceShelter* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { +void func_80890874(BgIceShelter* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2; - DynaPolyActor_Init(&this->dyna, moveFlag); + DynaPolyActor_Init(&pthis->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + if (pthis->dyna.bgId == BG_ACTOR_MAX) { // "Warning : move BG registration failed" osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_ice_shelter.c", 362, - this->dyna.actor.id, this->dyna.actor.params); + pthis->dyna.actor.id, pthis->dyna.actor.params); } } @@ -142,70 +142,70 @@ static InitChainEntry sInitChain[] = { void BgIceShelter_Init(Actor* thisx, GlobalContext* globalCtx) { static Vec3f kzIceScale = { 0.18f, 0.27f, 0.24f }; - BgIceShelter* this = (BgIceShelter*)thisx; - s16 type = (this->dyna.actor.params >> 8) & 7; + BgIceShelter* pthis = (BgIceShelter*)thisx; + s16 type = (pthis->dyna.actor.params >> 8) & 7; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); if (type == 4) { - this->dyna.actor.world.rot.x += 0xBB8; - this->dyna.actor.world.pos.y -= 45.0f; - this->dyna.actor.shape.rot.x = this->dyna.actor.world.rot.x; - this->dyna.actor.world.pos.z -= 38.0f; + pthis->dyna.actor.world.rot.x += 0xBB8; + pthis->dyna.actor.world.pos.y -= 45.0f; + pthis->dyna.actor.shape.rot.x = pthis->dyna.actor.world.rot.x; + pthis->dyna.actor.world.pos.z -= 38.0f; } if (type == 4) { - Math_Vec3f_Copy(&this->dyna.actor.scale, &kzIceScale); + Math_Vec3f_Copy(&pthis->dyna.actor.scale, &kzIceScale); } else { - Actor_SetScale(&this->dyna.actor, sScales[type]); + Actor_SetScale(&pthis->dyna.actor, sScales[type]); } switch (type) { case 2: - func_80890874(this, globalCtx, &object_ice_objects_Col_001C1C, 0); + func_80890874(pthis, globalCtx, &object_ice_objects_Col_001C1C, 0); break; case 3: - func_80890874(this, globalCtx, &object_ice_objects_Col_002920, 0); + func_80890874(pthis, globalCtx, &object_ice_objects_Col_002920, 0); break; } - func_80890740(this, globalCtx); + func_80890740(pthis, globalCtx); - this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - if (!((this->dyna.actor.params >> 6) & 1) && (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F))) { - Actor_Kill(&this->dyna.actor); + if (!((pthis->dyna.actor.params >> 6) & 1) && (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F))) { + Actor_Kill(&pthis->dyna.actor); return; } - func_80891064(this); + func_80891064(pthis); - osSyncPrintf("(ice shelter)(arg_data 0x%04x)\n", this->dyna.actor.params); + osSyncPrintf("(ice shelter)(arg_data 0x%04x)\n", pthis->dyna.actor.params); } void BgIceShelter_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgIceShelter* this = (BgIceShelter*)thisx; + BgIceShelter* pthis = (BgIceShelter*)thisx; - switch ((this->dyna.actor.params >> 8) & 7) { + switch ((pthis->dyna.actor.params >> 8) & 7) { case 2: case 3: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); break; case 0: case 1: case 4: - Collider_DestroyCylinder(globalCtx, &this->cylinder2); + Collider_DestroyCylinder(globalCtx, &pthis->cylinder2); break; } - Collider_DestroyCylinder(globalCtx, &this->cylinder1); + Collider_DestroyCylinder(globalCtx, &pthis->cylinder1); } static s16 D_80891794[] = { 0x0000, 0x4000, 0x2000, 0x6000, 0x1000, 0x5000, 0x3000, 0x7000 }; static s16 D_808917A4[] = { 0x0000, 0x003C, 0x0018, 0x0054, 0x0030, 0x000C, 0x0048, 0x0024 }; -void func_80890B8C(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 scale) { +void func_80890B8C(BgIceShelter* pthis, GlobalContext* globalCtx, f32 chance, f32 scale) { f32 cos; f32 sin; f32 xzOffset; @@ -226,7 +226,7 @@ void func_80890B8C(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 } xzOffset = 42.0f * scale; - icePos = &this->dyna.actor.world.pos; + icePos = &pthis->dyna.actor.world.pos; angle = D_80891794[frames] + (i * 0x8000); sin = Math_SinS(angle); cos = Math_CosS(angle); @@ -248,7 +248,7 @@ void func_80890B8C(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 } } -void func_80890E00(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 arg3) { +void func_80890E00(BgIceShelter* pthis, GlobalContext* globalCtx, f32 chance, f32 arg3) { static f32 D_808917B4[] = { -1.0f, 1.0f }; Vec3f* icePos; s16 frames; @@ -262,7 +262,7 @@ void func_80890E00(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 frames = (s16)globalCtx->state.frames & 7; for (i = 0; i < 2; i++) { - icePos = &this->dyna.actor.world.pos; + icePos = &pthis->dyna.actor.world.pos; if (chance < Rand_ZeroOne()) { continue; @@ -272,7 +272,7 @@ void func_80890E00(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 posOffset.y = 15.0f; posOffset.z = ((84.0f - posOffset.x) * 0.2f) + (Rand_ZeroOne() * 20.0f); - func_808908FC(&dustPos, &posOffset, this->dyna.actor.world.rot.y); + func_808908FC(&dustPos, &posOffset, pthis->dyna.actor.world.rot.y); Math_Vec3f_Sum(&dustPos, icePos, &dustPos); dustVel.x = (Rand_ZeroOne() * 3.0f) - 1.5f; @@ -288,33 +288,33 @@ void func_80890E00(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 } } -void func_80891064(BgIceShelter* this) { - this->actionFunc = func_8089107C; - this->alpha = 255; +void func_80891064(BgIceShelter* pthis) { + pthis->actionFunc = func_8089107C; + pthis->alpha = 255; } -void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) { +void func_8089107C(BgIceShelter* pthis, GlobalContext* globalCtx) { s32 pad; - s16 type = (this->dyna.actor.params >> 8) & 7; + s16 type = (pthis->dyna.actor.params >> 8) & 7; if (type == 4) { - if (this->dyna.actor.parent != NULL) { - this->dyna.actor.parent->freezeTimer = 10000; + if (pthis->dyna.actor.parent != NULL) { + pthis->dyna.actor.parent->freezeTimer = 10000; } } - if (this->cylinder1.base.acFlags & AC_HIT) { - this->cylinder1.base.acFlags &= ~AC_HIT; + if (pthis->cylinder1.base.acFlags & AC_HIT) { + pthis->cylinder1.base.acFlags &= ~AC_HIT; - if ((this->cylinder1.base.ac != NULL) && (this->cylinder1.base.ac->id == ACTOR_EN_ICE_HONO)) { + if ((pthis->cylinder1.base.ac != NULL) && (pthis->cylinder1.base.ac->id == ACTOR_EN_ICE_HONO)) { if (type == 4) { - if (this->dyna.actor.parent != NULL) { - this->dyna.actor.parent->freezeTimer = 50; + if (pthis->dyna.actor.parent != NULL) { + pthis->dyna.actor.parent->freezeTimer = 50; } } - func_808911BC(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ICE_MELT); + func_808911BC(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ICE_MELT); } } @@ -322,81 +322,81 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) { case 0: case 1: case 4: - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cylinder1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder2.base); break; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder1.base); } -void func_808911BC(BgIceShelter* this) { - this->actionFunc = func_808911D4; - this->alpha = 255; +void func_808911BC(BgIceShelter* pthis) { + pthis->actionFunc = func_808911D4; + pthis->alpha = 255; } static f32 D_808917BC[] = { -0.0015f, -0.0009f, -0.0016f, -0.0016f, -0.00375f }; static f32 D_808917D0[] = { 1.0f, 0.6f, 1.2f, 1.0f, 1.8f }; -static void (*sEffSpawnFuncs[])(BgIceShelter* this, GlobalContext* globalCtx, f32 chance, f32 scale) = { +static void (*sEffSpawnFuncs[])(BgIceShelter* pthis, GlobalContext* globalCtx, f32 chance, f32 scale) = { func_80890B8C, func_80890B8C, func_80890B8C, func_80890E00, func_80890B8C, }; -void func_808911D4(BgIceShelter* this, GlobalContext* globalCtx) { +void func_808911D4(BgIceShelter* pthis, GlobalContext* globalCtx) { s32 pad; - s32 type = (this->dyna.actor.params >> 8) & 7; + s32 type = (pthis->dyna.actor.params >> 8) & 7; f32 phi_f0; - this->alpha -= 5; - this->alpha = CLAMP(this->alpha, 0, 255); + pthis->alpha -= 5; + pthis->alpha = CLAMP(pthis->alpha, 0, 255); - this->dyna.actor.scale.y += D_808917BC[type]; - this->dyna.actor.scale.y = CLAMP_MIN(this->dyna.actor.scale.y, 0.0001f); + pthis->dyna.actor.scale.y += D_808917BC[type]; + pthis->dyna.actor.scale.y = CLAMP_MIN(pthis->dyna.actor.scale.y, 0.0001f); - if (this->alpha > 80) { + if (pthis->alpha > 80) { switch (type) { case 0: case 1: case 4: - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cylinder1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder2.base); break; } } - if (this->alpha > 180) { + if (pthis->alpha > 180) { phi_f0 = 1.0f; - } else if (this->alpha > 60) { + } else if (pthis->alpha > 60) { phi_f0 = 0.5f; } else { phi_f0 = 0.0f; } - sEffSpawnFuncs[type](this, globalCtx, phi_f0, D_808917D0[type]); + sEffSpawnFuncs[type](pthis, globalCtx, phi_f0, D_808917D0[type]); - if (this->alpha <= 0) { - if (!((this->dyna.actor.params >> 6) & 1)) { - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); + if (pthis->alpha <= 0) { + if (!((pthis->dyna.actor.params >> 6) & 1)) { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); } if (type == 4) { func_80078884(NA_SE_SY_CORRECT_CHIME); } - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } void BgIceShelter_Update(Actor* thisx, GlobalContext* globalCtx) { - BgIceShelter* this = (BgIceShelter*)thisx; + BgIceShelter* pthis = (BgIceShelter*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgIceShelter_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgIceShelter* this = (BgIceShelter*)thisx; + BgIceShelter* pthis = (BgIceShelter*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_ice_shelter.c", 748); @@ -405,18 +405,18 @@ void BgIceShelter_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ice_shelter.c", 751), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - switch ((this->dyna.actor.params >> 8) & 7) { + switch ((pthis->dyna.actor.params >> 8) & 7) { case 0: case 1: case 2: case 4: - func_8002ED80(&this->dyna.actor, globalCtx, 0); + func_8002ED80(&pthis->dyna.actor, globalCtx, 0); break; } - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, pthis->alpha); - switch ((this->dyna.actor.params >> 8) & 7) { + switch ((pthis->dyna.actor.params >> 8) & 7) { case 0: case 1: case 4: diff --git a/src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.c b/src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.c deleted file mode 100644 index 37c0f645f..000000000 --- a/src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.c +++ /dev/null @@ -1,143 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_ICE_SHUTTER_Z_BG_ICE_SHUTTER_C -#include "actor_common.h" -/* - * File: z_bg_ice_shutter.c - * Overlay: ovl_Bg_Ice_Shutter - * Description: Vertical Ice Bars (Doors) in Ice Cavern - */ - -#include "z_bg_ice_shutter.h" -#include "objects/object_ice_objects/object_ice_objects.h" -#include "def/code_80043480.h" -#include "def/code_8006BA00.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgIceShutter_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIceShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIceShutter_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIceShutter_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80891CF4(BgIceShutter* thisx, GlobalContext* globalCtx); -void func_80891D6C(BgIceShutter* thisx, GlobalContext* globalCtx); -void func_80891DD4(BgIceShutter* thisx, GlobalContext* globalCtx); - -const ActorInit Bg_Ice_Shutter_InitVars = { - ACTOR_BG_ICE_SHUTTER, - ACTORCAT_PROP, - FLAGS, - OBJECT_ICE_OBJECTS, - sizeof(BgIceShutter), - (ActorFunc)BgIceShutter_Init, - (ActorFunc)BgIceShutter_Destroy, - (ActorFunc)BgIceShutter_Update, - (ActorFunc)BgIceShutter_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void func_80891AC0(BgIceShutter* this) { - f32 sp24; - - sp24 = Math_SinS(this->dyna.actor.shape.rot.x) * this->dyna.actor.velocity.y; - this->dyna.actor.world.pos.y = - (Math_CosS(this->dyna.actor.shape.rot.x) * this->dyna.actor.velocity.y) + this->dyna.actor.home.pos.y; - this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.actor.shape.rot.y) * sp24) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.actor.shape.rot.y) * sp24) + this->dyna.actor.home.pos.z; -} - -void BgIceShutter_Init(Actor* thisx, GlobalContext* globalCtx) { - BgIceShutter* this = (BgIceShutter*)thisx; - f32 sp24; - CollisionHeader* colHeader; - s32 sp28; - f32 temp_f6; - - colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - sp28 = this->dyna.actor.params & 0xFF; - this->dyna.actor.params = (this->dyna.actor.params >> 8) & 0xFF; - CollisionHeader_GetVirtual(&object_ice_objects_Col_002854, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (sp28 == 2) { - this->dyna.actor.shape.rot.x = -0x4000; - } - - if (sp28 != 1) { - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { - Actor_Kill(&this->dyna.actor); - } else { - this->actionFunc = func_80891CF4; - } - - } else { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { - Actor_Kill(&this->dyna.actor); - } else { - this->actionFunc = func_80891D6C; - } - } - - if (sp28 == 2) { - temp_f6 = Math_SinS(this->dyna.actor.shape.rot.x) * 50.0f; - this->dyna.actor.focus.pos.x = - (Math_SinS(this->dyna.actor.shape.rot.y) * temp_f6) + this->dyna.actor.home.pos.x; - this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y; - this->dyna.actor.focus.pos.z = - this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.shape.rot.y) * temp_f6); - } else { - Actor_SetFocus(&this->dyna.actor, 50.0f); - } -} - -void BgIceShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgIceShutter* this = (BgIceShutter*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80891CF4(BgIceShutter* this, GlobalContext* globalCtx) { - if (Flags_GetTempClear(globalCtx, this->dyna.actor.room)) { - Flags_SetClear(globalCtx, this->dyna.actor.room); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_SLIDE_DOOR_OPEN); - this->actionFunc = func_80891DD4; - if (this->dyna.actor.shape.rot.x == 0) { - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - } - } -} - -void func_80891D6C(BgIceShutter* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_SLIDE_DOOR_OPEN); - this->actionFunc = func_80891DD4; - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - } -} - -void func_80891DD4(BgIceShutter* this, GlobalContext* globalCtx) { - Math_StepToF(&this->dyna.actor.speedXZ, 30.0f, 2.0f); - if (Math_StepToF(&this->dyna.actor.velocity.y, 210.0f, this->dyna.actor.speedXZ)) { - Actor_Kill(&this->dyna.actor); - return; - } - - func_80891AC0(this); -} - -void BgIceShutter_Update(Actor* thisx, GlobalContext* globalCtx) { - BgIceShutter* this = (BgIceShutter*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgIceShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_ice_objects_DL_002740); -} diff --git a/src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.cpp b/src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.cpp new file mode 100644 index 000000000..45ba9d43e --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ice_Shutter/z_bg_ice_shutter.cpp @@ -0,0 +1,143 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_ICE_SHUTTER_Z_BG_ICE_SHUTTER_C +#include "actor_common.h" +/* + * File: z_bg_ice_shutter.c + * Overlay: ovl_Bg_Ice_Shutter + * Description: Vertical Ice Bars (Doors) in Ice Cavern + */ + +#include "z_bg_ice_shutter.h" +#include "objects/object_ice_objects/object_ice_objects.h" +#include "def/code_80043480.h" +#include "def/code_8006BA00.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgIceShutter_Init(Actor* thisx, GlobalContext* globalCtx); +void BgIceShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgIceShutter_Update(Actor* thisx, GlobalContext* globalCtx); +void BgIceShutter_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80891CF4(BgIceShutter* thisx, GlobalContext* globalCtx); +void func_80891D6C(BgIceShutter* thisx, GlobalContext* globalCtx); +void func_80891DD4(BgIceShutter* thisx, GlobalContext* globalCtx); + +ActorInit Bg_Ice_Shutter_InitVars = { + ACTOR_BG_ICE_SHUTTER, + ACTORCAT_PROP, + FLAGS, + OBJECT_ICE_OBJECTS, + sizeof(BgIceShutter), + (ActorFunc)BgIceShutter_Init, + (ActorFunc)BgIceShutter_Destroy, + (ActorFunc)BgIceShutter_Update, + (ActorFunc)BgIceShutter_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void func_80891AC0(BgIceShutter* pthis) { + f32 sp24; + + sp24 = Math_SinS(pthis->dyna.actor.shape.rot.x) * pthis->dyna.actor.velocity.y; + pthis->dyna.actor.world.pos.y = + (Math_CosS(pthis->dyna.actor.shape.rot.x) * pthis->dyna.actor.velocity.y) + pthis->dyna.actor.home.pos.y; + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->dyna.actor.shape.rot.y) * sp24) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->dyna.actor.shape.rot.y) * sp24) + pthis->dyna.actor.home.pos.z; +} + +void BgIceShutter_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIceShutter* pthis = (BgIceShutter*)thisx; + f32 sp24; + CollisionHeader* colHeader; + s32 sp28; + f32 temp_f6; + + colHeader = NULL; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + sp28 = pthis->dyna.actor.params & 0xFF; + pthis->dyna.actor.params = (pthis->dyna.actor.params >> 8) & 0xFF; + CollisionHeader_GetVirtual(&object_ice_objects_Col_002854, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (sp28 == 2) { + pthis->dyna.actor.shape.rot.x = -0x4000; + } + + if (sp28 != 1) { + if (Flags_GetClear(globalCtx, pthis->dyna.actor.room)) { + Actor_Kill(&pthis->dyna.actor); + } else { + pthis->actionFunc = func_80891CF4; + } + + } else { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params)) { + Actor_Kill(&pthis->dyna.actor); + } else { + pthis->actionFunc = func_80891D6C; + } + } + + if (sp28 == 2) { + temp_f6 = Math_SinS(pthis->dyna.actor.shape.rot.x) * 50.0f; + pthis->dyna.actor.focus.pos.x = + (Math_SinS(pthis->dyna.actor.shape.rot.y) * temp_f6) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.focus.pos.y = pthis->dyna.actor.home.pos.y; + pthis->dyna.actor.focus.pos.z = + pthis->dyna.actor.home.pos.z + (Math_CosS(pthis->dyna.actor.shape.rot.y) * temp_f6); + } else { + Actor_SetFocus(&pthis->dyna.actor, 50.0f); + } +} + +void BgIceShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIceShutter* pthis = (BgIceShutter*)thisx; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80891CF4(BgIceShutter* pthis, GlobalContext* globalCtx) { + if (Flags_GetTempClear(globalCtx, pthis->dyna.actor.room)) { + Flags_SetClear(globalCtx, pthis->dyna.actor.room); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 30, NA_SE_EV_SLIDE_DOOR_OPEN); + pthis->actionFunc = func_80891DD4; + if (pthis->dyna.actor.shape.rot.x == 0) { + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + } + } +} + +void func_80891D6C(BgIceShutter* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params)) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 30, NA_SE_EV_SLIDE_DOOR_OPEN); + pthis->actionFunc = func_80891DD4; + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + } +} + +void func_80891DD4(BgIceShutter* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->dyna.actor.speedXZ, 30.0f, 2.0f); + if (Math_StepToF(&pthis->dyna.actor.velocity.y, 210.0f, pthis->dyna.actor.speedXZ)) { + Actor_Kill(&pthis->dyna.actor); + return; + } + + func_80891AC0(pthis); +} + +void BgIceShutter_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIceShutter* pthis = (BgIceShutter*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgIceShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_ice_objects_DL_002740); +} diff --git a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c deleted file mode 100644 index f123d26eb..000000000 --- a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c +++ /dev/null @@ -1,212 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_ICE_TURARA_Z_BG_ICE_TURARA_C -#include "actor_common.h" -/* - * File: z_bg_ice_turara.c - * Overlay: ovl_Bg_Ice_Turara - * Description: Icicles - */ - -#include "z_bg_ice_turara.h" -#include "objects/object_ice_objects/object_ice_objects.h" -#include "def/code_80043480.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void BgIceTurara_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIceTurara_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIceTurara_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIceTurara_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgIceTurara_Stalagmite(BgIceTurara* this, GlobalContext* globalCtx); -void BgIceTurara_Wait(BgIceTurara* this, GlobalContext* globalCtx); -void BgIceTurara_Shiver(BgIceTurara* this, GlobalContext* globalCtx); -void BgIceTurara_Fall(BgIceTurara* this, GlobalContext* globalCtx); -void BgIceTurara_Regrow(BgIceTurara* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x4FC007CA, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 13, 120, 0, { 0, 0, 0 } }, -}; - -const ActorInit Bg_Ice_Turara_InitVars = { - ACTOR_BG_ICE_TURARA, - ACTORCAT_PROP, - FLAGS, - OBJECT_ICE_OBJECTS, - sizeof(BgIceTurara), - (ActorFunc)BgIceTurara_Init, - (ActorFunc)BgIceTurara_Destroy, - (ActorFunc)BgIceTurara_Update, - (ActorFunc)BgIceTurara_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 600, ICHAIN_CONTINUE), - ICHAIN_F32(gravity, -3, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -30, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgIceTurara_Init(Actor* thisx, GlobalContext* globalCtx) { - BgIceTurara* this = (BgIceTurara*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&object_ice_objects_Col_002594, &colHeader); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.actor.params == TURARA_STALAGMITE) { - this->actionFunc = BgIceTurara_Stalagmite; - } else { - this->dyna.actor.shape.rot.x = -0x8000; - this->dyna.actor.shape.yOffset = 1200.0f; - this->actionFunc = BgIceTurara_Wait; - } -} - -void BgIceTurara_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgIceTurara* this = (BgIceTurara*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void BgIceTurara_Break(BgIceTurara* this, GlobalContext* globalCtx, f32 arg2) { - static Vec3f accel = { 0.0f, -1.0f, 0.0f }; - static Color_RGBA8 primColor = { 170, 255, 255, 255 }; - static Color_RGBA8 envColor = { 0, 50, 100, 255 }; - Vec3f vel; - Vec3f pos; - s32 j; - s32 i; - - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); - for (i = 0; i < 2; i++) { - for (j = 0; j < 10; j++) { - pos.x = this->dyna.actor.world.pos.x + Rand_CenteredFloat(8.0f); - pos.y = this->dyna.actor.world.pos.y + (Rand_ZeroOne() * arg2) + (i * arg2); - pos.z = this->dyna.actor.world.pos.z + Rand_CenteredFloat(8.0f); - - vel.x = Rand_CenteredFloat(7.0f); - vel.z = Rand_CenteredFloat(7.0f); - vel.y = (Rand_ZeroOne() * 4.0f) + 8.0f; - - EffectSsEnIce_Spawn(globalCtx, &pos, (Rand_ZeroOne() * 0.2f) + 0.1f, &vel, &accel, &primColor, &envColor, - 30); - } - } -} - -void BgIceTurara_Stalagmite(BgIceTurara* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - BgIceTurara_Break(this, globalCtx, 50.0f); - Actor_Kill(&this->dyna.actor); - return; - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void BgIceTurara_Wait(BgIceTurara* this, GlobalContext* globalCtx) { - if (this->dyna.actor.xzDistToPlayer < 60.0f) { - this->shiverTimer = 10; - this->actionFunc = BgIceTurara_Shiver; - } -} - -void BgIceTurara_Shiver(BgIceTurara* this, GlobalContext* globalCtx) { - s16 phi_v0_3; - s16 phi_v0_2; - f32 sp28; - - if (this->shiverTimer != 0) { - this->shiverTimer--; - } - if (!(this->shiverTimer % 4)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ICE_SWING); - } - if (this->shiverTimer == 0) { - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgIceTurara_Fall; - } else { - sp28 = Rand_ZeroOne(); - phi_v0_2 = (Rand_ZeroOne() < 0.5f ? -1 : 1); - this->dyna.actor.world.pos.x = (phi_v0_2 * ((0.5f * sp28) + 0.5f)) + this->dyna.actor.home.pos.x; - sp28 = Rand_ZeroOne(); - phi_v0_3 = (Rand_ZeroOne() < 0.5f ? -1 : 1); - this->dyna.actor.world.pos.z = (phi_v0_3 * ((0.5f * sp28) + 0.5f)) + this->dyna.actor.home.pos.z; - } -} - -void BgIceTurara_Fall(BgIceTurara* this, GlobalContext* globalCtx) { - if ((this->collider.base.atFlags & AT_HIT) || (this->dyna.actor.bgCheckFlags & 1)) { - this->collider.base.atFlags &= ~AT_HIT; - this->dyna.actor.bgCheckFlags &= ~1; - if (this->dyna.actor.world.pos.y < this->dyna.actor.floorHeight) { - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - } - BgIceTurara_Break(this, globalCtx, 40.0f); - if (this->dyna.actor.params == TURARA_STALACTITE_REGROW) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgIceTurara_Regrow; - } else { - Actor_Kill(&this->dyna.actor); - return; - } - } else { - Actor_MoveForward(&this->dyna.actor); - this->dyna.actor.world.pos.y += 40.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); - this->dyna.actor.world.pos.y -= 40.0f; - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void BgIceTurara_Regrow(BgIceTurara* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { - this->actionFunc = BgIceTurara_Wait; - this->dyna.actor.velocity.y = 0.0f; - } -} - -void BgIceTurara_Update(Actor* thisx, GlobalContext* globalCtx) { - BgIceTurara* this = (BgIceTurara*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgIceTurara_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_ice_objects_DL_0023D0); -} diff --git a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.cpp b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.cpp new file mode 100644 index 000000000..fedbf2630 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.cpp @@ -0,0 +1,212 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_ICE_TURARA_Z_BG_ICE_TURARA_C +#include "actor_common.h" +/* + * File: z_bg_ice_turara.c + * Overlay: ovl_Bg_Ice_Turara + * Description: Icicles + */ + +#include "z_bg_ice_turara.h" +#include "objects/object_ice_objects/object_ice_objects.h" +#include "def/code_80043480.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void BgIceTurara_Init(Actor* thisx, GlobalContext* globalCtx); +void BgIceTurara_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgIceTurara_Update(Actor* thisx, GlobalContext* globalCtx); +void BgIceTurara_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgIceTurara_Stalagmite(BgIceTurara* pthis, GlobalContext* globalCtx); +void BgIceTurara_Wait(BgIceTurara* pthis, GlobalContext* globalCtx); +void BgIceTurara_Shiver(BgIceTurara* pthis, GlobalContext* globalCtx); +void BgIceTurara_Fall(BgIceTurara* pthis, GlobalContext* globalCtx); +void BgIceTurara_Regrow(BgIceTurara* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x4FC007CA, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 13, 120, 0, { 0, 0, 0 } }, +}; + +ActorInit Bg_Ice_Turara_InitVars = { + ACTOR_BG_ICE_TURARA, + ACTORCAT_PROP, + FLAGS, + OBJECT_ICE_OBJECTS, + sizeof(BgIceTurara), + (ActorFunc)BgIceTurara_Init, + (ActorFunc)BgIceTurara_Destroy, + (ActorFunc)BgIceTurara_Update, + (ActorFunc)BgIceTurara_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 600, ICHAIN_CONTINUE), + ICHAIN_F32(gravity, -3, ICHAIN_CONTINUE), + ICHAIN_F32(minVelocityY, -30, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgIceTurara_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIceTurara* pthis = (BgIceTurara*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&object_ice_objects_Col_002594, &colHeader); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.actor.params == TURARA_STALAGMITE) { + pthis->actionFunc = BgIceTurara_Stalagmite; + } else { + pthis->dyna.actor.shape.rot.x = -0x8000; + pthis->dyna.actor.shape.yOffset = 1200.0f; + pthis->actionFunc = BgIceTurara_Wait; + } +} + +void BgIceTurara_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIceTurara* pthis = (BgIceTurara*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void BgIceTurara_Break(BgIceTurara* pthis, GlobalContext* globalCtx, f32 arg2) { + static Vec3f accel = { 0.0f, -1.0f, 0.0f }; + static Color_RGBA8 primColor = { 170, 255, 255, 255 }; + static Color_RGBA8 envColor = { 0, 50, 100, 255 }; + Vec3f vel; + Vec3f pos; + s32 j; + s32 i; + + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + for (i = 0; i < 2; i++) { + for (j = 0; j < 10; j++) { + pos.x = pthis->dyna.actor.world.pos.x + Rand_CenteredFloat(8.0f); + pos.y = pthis->dyna.actor.world.pos.y + (Rand_ZeroOne() * arg2) + (i * arg2); + pos.z = pthis->dyna.actor.world.pos.z + Rand_CenteredFloat(8.0f); + + vel.x = Rand_CenteredFloat(7.0f); + vel.z = Rand_CenteredFloat(7.0f); + vel.y = (Rand_ZeroOne() * 4.0f) + 8.0f; + + EffectSsEnIce_Spawn(globalCtx, &pos, (Rand_ZeroOne() * 0.2f) + 0.1f, &vel, &accel, &primColor, &envColor, + 30); + } + } +} + +void BgIceTurara_Stalagmite(BgIceTurara* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + BgIceTurara_Break(pthis, globalCtx, 50.0f); + Actor_Kill(&pthis->dyna.actor); + return; + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void BgIceTurara_Wait(BgIceTurara* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.xzDistToPlayer < 60.0f) { + pthis->shiverTimer = 10; + pthis->actionFunc = BgIceTurara_Shiver; + } +} + +void BgIceTurara_Shiver(BgIceTurara* pthis, GlobalContext* globalCtx) { + s16 phi_v0_3; + s16 phi_v0_2; + f32 sp28; + + if (pthis->shiverTimer != 0) { + pthis->shiverTimer--; + } + if (!(pthis->shiverTimer % 4)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ICE_SWING); + } + if (pthis->shiverTimer == 0) { + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z; + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->actionFunc = BgIceTurara_Fall; + } else { + sp28 = Rand_ZeroOne(); + phi_v0_2 = (Rand_ZeroOne() < 0.5f ? -1 : 1); + pthis->dyna.actor.world.pos.x = (phi_v0_2 * ((0.5f * sp28) + 0.5f)) + pthis->dyna.actor.home.pos.x; + sp28 = Rand_ZeroOne(); + phi_v0_3 = (Rand_ZeroOne() < 0.5f ? -1 : 1); + pthis->dyna.actor.world.pos.z = (phi_v0_3 * ((0.5f * sp28) + 0.5f)) + pthis->dyna.actor.home.pos.z; + } +} + +void BgIceTurara_Fall(BgIceTurara* pthis, GlobalContext* globalCtx) { + if ((pthis->collider.base.atFlags & AT_HIT) || (pthis->dyna.actor.bgCheckFlags & 1)) { + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->dyna.actor.bgCheckFlags &= ~1; + if (pthis->dyna.actor.world.pos.y < pthis->dyna.actor.floorHeight) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + } + BgIceTurara_Break(pthis, globalCtx, 40.0f); + if (pthis->dyna.actor.params == TURARA_STALACTITE_REGROW) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + 120.0f; + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->actionFunc = BgIceTurara_Regrow; + } else { + Actor_Kill(&pthis->dyna.actor); + return; + } + } else { + Actor_MoveForward(&pthis->dyna.actor); + pthis->dyna.actor.world.pos.y += 40.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + pthis->dyna.actor.world.pos.y -= 40.0f; + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void BgIceTurara_Regrow(BgIceTurara* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 1.0f)) { + pthis->actionFunc = BgIceTurara_Wait; + pthis->dyna.actor.velocity.y = 0.0f; + } +} + +void BgIceTurara_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIceTurara* pthis = (BgIceTurara*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgIceTurara_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_ice_objects_DL_0023D0); +} diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.cpp similarity index 63% rename from src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c rename to src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.cpp index 185e276f7..a3414cb0f 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.cpp @@ -23,10 +23,10 @@ void BgInGate_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgInGate_Update(Actor* thisx, GlobalContext* globalCtx); void BgInGate_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80892890(BgInGate* this, GlobalContext* globalCtx); -void BgInGate_DoNothing(BgInGate* this, GlobalContext* globalCtx); +void func_80892890(BgInGate* pthis, GlobalContext* globalCtx); +void BgInGate_DoNothing(BgInGate* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Ingate_InitVars = { +ActorInit Bg_Ingate_InitVars = { ACTOR_BG_INGATE, ACTORCAT_PROP, FLAGS, @@ -38,54 +38,54 @@ const ActorInit Bg_Ingate_InitVars = { (ActorFunc)BgInGate_Draw, }; -void BgInGate_SetupAction(BgInGate* this, BgInGateActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgInGate_SetupAction(BgInGate* pthis, BgInGateActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgInGate_Init(Actor* thisx, GlobalContext* globalCtx) { - BgInGate* this = (BgInGate*)thisx; + BgInGate* pthis = (BgInGate*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gIngoGateCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); if ((globalCtx->sceneNum != SCENE_SPOT20 || !LINK_IS_ADULT) || (((gSaveContext.eventChkInf[1] & 0x100)) && (gSaveContext.cutsceneIndex != 0xFFF0))) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } - Actor_SetScale(&this->dyna.actor, 0.1f); - if (((this->dyna.actor.params & 1) != 0) && ((gSaveContext.eventInf[0] & 0xF) == 6)) { + Actor_SetScale(&pthis->dyna.actor, 0.1f); + if (((pthis->dyna.actor.params & 1) != 0) && ((gSaveContext.eventInf[0] & 0xF) == 6)) { globalCtx->csCtx.frames = 0; - BgInGate_SetupAction(this, func_80892890); + BgInGate_SetupAction(pthis, func_80892890); } else { - BgInGate_SetupAction(this, BgInGate_DoNothing); + BgInGate_SetupAction(pthis, BgInGate_DoNothing); } } void BgInGate_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgInGate* this = (BgInGate*)thisx; + BgInGate* pthis = (BgInGate*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_80892890(BgInGate* this, GlobalContext* globalCtx) { +void func_80892890(BgInGate* pthis, GlobalContext* globalCtx) { s32 phi0; s16 phi1; s16 csFrames; if (globalCtx->csCtx.frames >= 50) { phi0 = 0x4000; - if ((this->dyna.actor.params & 2) == 0) { + if ((pthis->dyna.actor.params & 2) == 0) { phi0 = -0x4000; } - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y + phi0; - BgInGate_SetupAction(this, BgInGate_DoNothing); + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y + phi0; + BgInGate_SetupAction(pthis, BgInGate_DoNothing); } else if (globalCtx->csCtx.frames >= 10) { csFrames = globalCtx->csCtx.frames - 10; csFrames *= 400; @@ -95,20 +95,20 @@ void func_80892890(BgInGate* this, GlobalContext* globalCtx) { } csFrames = (Math_SinS(csFrames) * 16384.0f); phi1 = csFrames; - if ((this->dyna.actor.params & 2) == 0) { + if ((pthis->dyna.actor.params & 2) == 0) { phi1 = -phi1; } - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y + phi1; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y + phi1; } } -void BgInGate_DoNothing(BgInGate* this, GlobalContext* globalCtx) { +void BgInGate_DoNothing(BgInGate* pthis, GlobalContext* globalCtx) { } void BgInGate_Update(Actor* thisx, GlobalContext* globalCtx) { - BgInGate* this = (BgInGate*)thisx; + BgInGate* pthis = (BgInGate*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgInGate_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.cpp similarity index 50% rename from src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c rename to src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.cpp index 7bb2d08ff..ef148d030 100644 --- a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c +++ b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.cpp @@ -23,18 +23,18 @@ void BgJya1flift_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJya1flift_Update(Actor* thisx, GlobalContext* globalCtx); void BgJya1flift_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgJya1flift_SetupWaitForSwitch(BgJya1flift* this); -void BgJya1flift_WaitForSwitch(BgJya1flift* this, GlobalContext* globalCtx); -void BgJya1flift_DoNothing(BgJya1flift* this, GlobalContext* globalCtx); -void BgJya1flift_ChangeDirection(BgJya1flift* this); -void BgJya1flift_Move(BgJya1flift* this, GlobalContext* globalCtx); -void BgJya1flift_SetupDoNothing(BgJya1flift* this); -void BgJya1flift_ResetMoveDelay(BgJya1flift* this); -void BgJya1flift_DelayMove(BgJya1flift* this, GlobalContext* globalCtx); +void BgJya1flift_SetupWaitForSwitch(BgJya1flift* pthis); +void BgJya1flift_WaitForSwitch(BgJya1flift* pthis, GlobalContext* globalCtx); +void BgJya1flift_DoNothing(BgJya1flift* pthis, GlobalContext* globalCtx); +void BgJya1flift_ChangeDirection(BgJya1flift* pthis); +void BgJya1flift_Move(BgJya1flift* pthis, GlobalContext* globalCtx); +void BgJya1flift_SetupDoNothing(BgJya1flift* pthis); +void BgJya1flift_ResetMoveDelay(BgJya1flift* pthis); +void BgJya1flift_DelayMove(BgJya1flift* pthis, GlobalContext* globalCtx); static u8 sIsSpawned = false; -const ActorInit Bg_Jya_1flift_InitVars = { +ActorInit Bg_Jya_1flift_InitVars = { ACTOR_BG_JYA_1FLIFT, ACTORCAT_BG, FLAGS, @@ -75,137 +75,137 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), }; -void BgJya1flift_InitDynapoly(BgJya1flift* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { +void BgJya1flift_InitDynapoly(BgJya1flift* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2; - DynaPolyActor_Init(&this->dyna, moveFlag); + DynaPolyActor_Init(&pthis->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + if (pthis->dyna.bgId == BG_ACTOR_MAX) { // "Warning : move BG login failed" osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_1flift.c", 179, - this->dyna.actor.id, this->dyna.actor.params); + pthis->dyna.actor.id, pthis->dyna.actor.params); } } void BgJya1flift_InitCollision(Actor* thisx, GlobalContext* globalCtx) { - BgJya1flift* this = (BgJya1flift*)thisx; + BgJya1flift* pthis = (BgJya1flift*)thisx; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + pthis->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; } void BgJya1flift_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJya1flift* this = (BgJya1flift*)thisx; + BgJya1flift* pthis = (BgJya1flift*)thisx; // "1 F lift" osSyncPrintf("(1Fリフト)(flag %d)(room %d)\n", sIsSpawned, globalCtx->roomCtx.curRoom.num); - this->hasInitialized = false; + pthis->hasInitialized = false; if (sIsSpawned) { Actor_Kill(thisx); return; } - BgJya1flift_InitDynapoly(this, globalCtx, &g1fliftCol, 0); + BgJya1flift_InitDynapoly(pthis, globalCtx, &g1fliftCol, 0); Actor_ProcessInitChain(thisx, sInitChain); BgJya1flift_InitCollision(thisx, globalCtx); if (Flags_GetSwitch(globalCtx, (thisx->params & 0x3F))) { - LINK_AGE_IN_YEARS == YEARS_ADULT ? BgJya1flift_ChangeDirection(this) : BgJya1flift_SetupDoNothing(this); + LINK_AGE_IN_YEARS == YEARS_ADULT ? BgJya1flift_ChangeDirection(pthis) : BgJya1flift_SetupDoNothing(pthis); } else { - BgJya1flift_SetupWaitForSwitch(this); + BgJya1flift_SetupWaitForSwitch(pthis); } thisx->room = -1; sIsSpawned = true; - this->hasInitialized = true; + pthis->hasInitialized = true; } void BgJya1flift_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJya1flift* this = (BgJya1flift*)thisx; + BgJya1flift* pthis = (BgJya1flift*)thisx; - if (this->hasInitialized) { + if (pthis->hasInitialized) { sIsSpawned = false; - Collider_DestroyCylinder(globalCtx, &this->collider); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } -void BgJya1flift_SetupWaitForSwitch(BgJya1flift* this) { - this->actionFunc = BgJya1flift_WaitForSwitch; - this->dyna.actor.world.pos.y = sFinalPositions[0]; +void BgJya1flift_SetupWaitForSwitch(BgJya1flift* pthis) { + pthis->actionFunc = BgJya1flift_WaitForSwitch; + pthis->dyna.actor.world.pos.y = sFinalPositions[0]; } -void BgJya1flift_WaitForSwitch(BgJya1flift* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) { - BgJya1flift_ChangeDirection(this); +void BgJya1flift_WaitForSwitch(BgJya1flift* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F))) { + BgJya1flift_ChangeDirection(pthis); } } -void BgJya1flift_SetupDoNothing(BgJya1flift* this) { - this->actionFunc = BgJya1flift_DoNothing; - this->dyna.actor.world.pos.y = sFinalPositions[0]; +void BgJya1flift_SetupDoNothing(BgJya1flift* pthis) { + pthis->actionFunc = BgJya1flift_DoNothing; + pthis->dyna.actor.world.pos.y = sFinalPositions[0]; } -void BgJya1flift_DoNothing(BgJya1flift* this, GlobalContext* globalCtx) { +void BgJya1flift_DoNothing(BgJya1flift* pthis, GlobalContext* globalCtx) { } -void BgJya1flift_ChangeDirection(BgJya1flift* this) { - this->actionFunc = BgJya1flift_Move; - this->isMovingDown ^= true; - this->dyna.actor.velocity.y = 0.0f; +void BgJya1flift_ChangeDirection(BgJya1flift* pthis) { + pthis->actionFunc = BgJya1flift_Move; + pthis->isMovingDown ^= true; + pthis->dyna.actor.velocity.y = 0.0f; } -void BgJya1flift_Move(BgJya1flift* this, GlobalContext* globalCtx) { +void BgJya1flift_Move(BgJya1flift* pthis, GlobalContext* globalCtx) { f32 tempVelocity; - Math_StepToF(&this->dyna.actor.velocity.y, 6.0f, 0.4f); - if (this->dyna.actor.velocity.y < 1.0f) { + Math_StepToF(&pthis->dyna.actor.velocity.y, 6.0f, 0.4f); + if (pthis->dyna.actor.velocity.y < 1.0f) { tempVelocity = 1.0f; } else { - tempVelocity = this->dyna.actor.velocity.y; + tempVelocity = pthis->dyna.actor.velocity.y; } - if (fabsf(Math_SmoothStepToF(&this->dyna.actor.world.pos.y, (sFinalPositions[this->isMovingDown]), 0.5f, + if (fabsf(Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, (sFinalPositions[pthis->isMovingDown]), 0.5f, tempVelocity, 1.0f)) < 0.001f) { - this->dyna.actor.world.pos.y = sFinalPositions[this->isMovingDown]; - BgJya1flift_ResetMoveDelay(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + pthis->dyna.actor.world.pos.y = sFinalPositions[pthis->isMovingDown]; + BgJya1flift_ResetMoveDelay(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); } } -void BgJya1flift_ResetMoveDelay(BgJya1flift* this) { - this->actionFunc = BgJya1flift_DelayMove; - this->moveDelay = 0; +void BgJya1flift_ResetMoveDelay(BgJya1flift* pthis) { + pthis->actionFunc = BgJya1flift_DelayMove; + pthis->moveDelay = 0; } -void BgJya1flift_DelayMove(BgJya1flift* this, GlobalContext* globalCtx) { - this->moveDelay++; - if (this->moveDelay >= 21) { - BgJya1flift_ChangeDirection(this); +void BgJya1flift_DelayMove(BgJya1flift* pthis, GlobalContext* globalCtx) { + pthis->moveDelay++; + if (pthis->moveDelay >= 21) { + BgJya1flift_ChangeDirection(pthis); } } void BgJya1flift_Update(Actor* thisx, GlobalContext* globalCtx2) { - BgJya1flift* this = (BgJya1flift*)thisx; + BgJya1flift* pthis = (BgJya1flift*)thisx; GlobalContext* globalCtx = globalCtx2; s32 tempIsRiding; // Room 0 is the first room and 6 is the room that the lift starts on if (globalCtx->roomCtx.curRoom.num == 6 || globalCtx->roomCtx.curRoom.num == 0) { - this->actionFunc(this, globalCtx); - tempIsRiding = func_8004356C(&this->dyna) ? true : false; - if ((this->actionFunc == BgJya1flift_Move) || (this->actionFunc == BgJya1flift_DelayMove)) { + pthis->actionFunc(pthis, globalCtx); + tempIsRiding = func_8004356C(&pthis->dyna) ? true : false; + if ((pthis->actionFunc == BgJya1flift_Move) || (pthis->actionFunc == BgJya1flift_DelayMove)) { if (tempIsRiding) { Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FIRE_PLATFORM); - } else if (!tempIsRiding && this->isLinkRiding) { + } else if (!tempIsRiding && pthis->isLinkRiding) { Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); } } - this->isLinkRiding = tempIsRiding; - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->isLinkRiding = tempIsRiding; + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } else { Actor_Kill(thisx); } diff --git a/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c b/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c deleted file mode 100644 index 1b944cd13..000000000 --- a/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c +++ /dev/null @@ -1,135 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_JYA_AMISHUTTER_Z_BG_JYA_AMISHUTTER_C -#include "actor_common.h" -/* - * File: z_bg_jya_amishutter.c - * Overlay: Bg_Jya_Amishutter - * Description: Circular metal grate. Lifts up when you get close to it. - */ - -#include "z_bg_jya_amishutter.h" -#include "objects/object_jya_obj/object_jya_obj.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void BgJyaAmishutter_Init(Actor* thisx, GlobalContext* globalCtx); -void BgJyaAmishutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgJyaAmishutter_Update(Actor* thisx, GlobalContext* globalCtx); -void BgJyaAmishutter_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgJyaAmishutter_SetupWaitForPlayer(BgJyaAmishutter* this); -void BgJyaAmishutter_WaitForPlayer(BgJyaAmishutter* this); -void func_80893428(BgJyaAmishutter* this); -void func_80893438(BgJyaAmishutter* this); -void func_808934B0(BgJyaAmishutter* this); -void func_808934C0(BgJyaAmishutter* this); -void func_808934FC(BgJyaAmishutter* this); -void func_8089350C(BgJyaAmishutter* this); - -const ActorInit Bg_Jya_Amishutter_InitVars = { - ACTOR_BG_JYA_AMISHUTTER, - ACTORCAT_BG, - FLAGS, - OBJECT_JYA_OBJ, - sizeof(BgJyaAmishutter), - (ActorFunc)BgJyaAmishutter_Init, - (ActorFunc)BgJyaAmishutter_Destroy, - (ActorFunc)BgJyaAmishutter_Update, - (ActorFunc)BgJyaAmishutter_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void BgJyaAmishutter_InitDynaPoly(BgJyaAmishutter* this, GlobalContext* globalCtx, CollisionHeader* collision, - s32 flag) { - s32 pad1; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, flag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_amishutter.c", 129, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgJyaAmishutter_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaAmishutter* this = (BgJyaAmishutter*)thisx; - - BgJyaAmishutter_InitDynaPoly(this, globalCtx, &gAmishutterCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BgJyaAmishutter_SetupWaitForPlayer(this); -} - -void BgJyaAmishutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaAmishutter* this = (BgJyaAmishutter*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgJyaAmishutter_SetupWaitForPlayer(BgJyaAmishutter* this) { - this->actionFunc = BgJyaAmishutter_WaitForPlayer; -} - -void BgJyaAmishutter_WaitForPlayer(BgJyaAmishutter* this) { - if ((this->dyna.actor.xzDistToPlayer < 60.0f) && (fabsf(this->dyna.actor.yDistToPlayer) < 30.0f)) { - func_80893428(this); - } -} - -void func_80893428(BgJyaAmishutter* this) { - this->actionFunc = func_80893438; -} - -void func_80893438(BgJyaAmishutter* this) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 100.0f, 3.0f)) { - func_808934B0(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); - } -} - -void func_808934B0(BgJyaAmishutter* this) { - this->actionFunc = func_808934C0; -} - -void func_808934C0(BgJyaAmishutter* this) { - if (this->dyna.actor.xzDistToPlayer > 300.0f) { - func_808934FC(this); - } -} - -void func_808934FC(BgJyaAmishutter* this) { - this->actionFunc = func_8089350C; -} - -void func_8089350C(BgJyaAmishutter* this) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 3.0f)) { - BgJyaAmishutter_SetupWaitForPlayer(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); - } -} - -void BgJyaAmishutter_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaAmishutter* this = (BgJyaAmishutter*)thisx; - - this->actionFunc(this); -} - -void BgJyaAmishutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gAmishutterDL); -} diff --git a/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.cpp b/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.cpp new file mode 100644 index 000000000..562dcf4e7 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.cpp @@ -0,0 +1,135 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_JYA_AMISHUTTER_Z_BG_JYA_AMISHUTTER_C +#include "actor_common.h" +/* + * File: z_bg_jya_amishutter.c + * Overlay: Bg_Jya_Amishutter + * Description: Circular metal grate. Lifts up when you get close to it. + */ + +#include "z_bg_jya_amishutter.h" +#include "objects/object_jya_obj/object_jya_obj.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void BgJyaAmishutter_Init(Actor* thisx, GlobalContext* globalCtx); +void BgJyaAmishutter_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgJyaAmishutter_Update(Actor* thisx, GlobalContext* globalCtx); +void BgJyaAmishutter_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgJyaAmishutter_SetupWaitForPlayer(BgJyaAmishutter* pthis); +void BgJyaAmishutter_WaitForPlayer(BgJyaAmishutter* pthis); +void func_80893428(BgJyaAmishutter* pthis); +void func_80893438(BgJyaAmishutter* pthis); +void func_808934B0(BgJyaAmishutter* pthis); +void func_808934C0(BgJyaAmishutter* pthis); +void func_808934FC(BgJyaAmishutter* pthis); +void func_8089350C(BgJyaAmishutter* pthis); + +ActorInit Bg_Jya_Amishutter_InitVars = { + ACTOR_BG_JYA_AMISHUTTER, + ACTORCAT_BG, + FLAGS, + OBJECT_JYA_OBJ, + sizeof(BgJyaAmishutter), + (ActorFunc)BgJyaAmishutter_Init, + (ActorFunc)BgJyaAmishutter_Destroy, + (ActorFunc)BgJyaAmishutter_Update, + (ActorFunc)BgJyaAmishutter_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void BgJyaAmishutter_InitDynaPoly(BgJyaAmishutter* pthis, GlobalContext* globalCtx, CollisionHeader* collision, + s32 flag) { + s32 pad1; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_amishutter.c", 129, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgJyaAmishutter_Init(Actor* thisx, GlobalContext* globalCtx) { + BgJyaAmishutter* pthis = (BgJyaAmishutter*)thisx; + + BgJyaAmishutter_InitDynaPoly(pthis, globalCtx, &gAmishutterCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + BgJyaAmishutter_SetupWaitForPlayer(pthis); +} + +void BgJyaAmishutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgJyaAmishutter* pthis = (BgJyaAmishutter*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgJyaAmishutter_SetupWaitForPlayer(BgJyaAmishutter* pthis) { + pthis->actionFunc = BgJyaAmishutter_WaitForPlayer; +} + +void BgJyaAmishutter_WaitForPlayer(BgJyaAmishutter* pthis) { + if ((pthis->dyna.actor.xzDistToPlayer < 60.0f) && (fabsf(pthis->dyna.actor.yDistToPlayer) < 30.0f)) { + func_80893428(pthis); + } +} + +void func_80893428(BgJyaAmishutter* pthis) { + pthis->actionFunc = func_80893438; +} + +void func_80893438(BgJyaAmishutter* pthis) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 100.0f, 3.0f)) { + func_808934B0(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_STOP); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); + } +} + +void func_808934B0(BgJyaAmishutter* pthis) { + pthis->actionFunc = func_808934C0; +} + +void func_808934C0(BgJyaAmishutter* pthis) { + if (pthis->dyna.actor.xzDistToPlayer > 300.0f) { + func_808934FC(pthis); + } +} + +void func_808934FC(BgJyaAmishutter* pthis) { + pthis->actionFunc = func_8089350C; +} + +void func_8089350C(BgJyaAmishutter* pthis) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 3.0f)) { + BgJyaAmishutter_SetupWaitForPlayer(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_STOP); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); + } +} + +void BgJyaAmishutter_Update(Actor* thisx, GlobalContext* globalCtx) { + BgJyaAmishutter* pthis = (BgJyaAmishutter*)thisx; + + pthis->actionFunc(pthis); +} + +void BgJyaAmishutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gAmishutterDL); +} diff --git a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.cpp similarity index 67% rename from src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c rename to src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.cpp index c798000fa..795f5944a 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.cpp @@ -23,7 +23,7 @@ void BgJyaBigmirror_Draw(Actor* thisx, GlobalContext* globalCtx); static u8 sIsSpawned = false; -const ActorInit Bg_Jya_Bigmirror_InitVars = { +ActorInit Bg_Jya_Bigmirror_InitVars = { ACTOR_BG_JYA_BIGMIRROR, ACTORCAT_BG, FLAGS, @@ -48,37 +48,37 @@ static BigMirrorDataEntry sCobraSpawnData[] = { }; void BgJyaBigmirror_SetRoomFlag(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; - this->puzzleFlags &= + pthis->puzzleFlags &= ~(BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM); if (globalCtx->roomCtx.curRoom.num == 5) { - this->puzzleFlags |= BIGMIR_PUZZLE_IN_STATUE_ROOM; + pthis->puzzleFlags |= BIGMIR_PUZZLE_IN_STATUE_ROOM; } else if (globalCtx->roomCtx.curRoom.num == 0x19) { - this->puzzleFlags |= BIGMIR_PUZZLE_IN_1ST_TOP_ROOM; + pthis->puzzleFlags |= BIGMIR_PUZZLE_IN_1ST_TOP_ROOM; } else if (globalCtx->roomCtx.curRoom.num == 0x1A) { - this->puzzleFlags |= BIGMIR_PUZZLE_IN_2ND_TOP_ROOM; + pthis->puzzleFlags |= BIGMIR_PUZZLE_IN_2ND_TOP_ROOM; } } void BgJyaBigmirror_HandleCobra(Actor* thisx, GlobalContext* globalCtx) { static u8 cobraPuzzleFlags[] = { BIGMIR_PUZZLE_COBRA1_SOLVED, BIGMIR_PUZZLE_COBRA2_SOLVED }; - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; BigMirrorDataEntry* curSpawnData; BigmirrorCobra* curCobraInfo; s32 i; - if (this->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM)) { + if (pthis->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM)) { for (i = 0; i < 2; i++) { curSpawnData = &sCobraSpawnData[i]; - curCobraInfo = &this->cobraInfo[i]; + curCobraInfo = &pthis->cobraInfo[i]; if (curCobraInfo->cobra != NULL) { curCobraInfo->rotY = curCobraInfo->cobra->dyna.actor.shape.rot.y; if (curCobraInfo->rotY == curSpawnData->solvedRotY) { - this->puzzleFlags |= cobraPuzzleFlags[i]; + pthis->puzzleFlags |= cobraPuzzleFlags[i]; } else { - this->puzzleFlags &= ~cobraPuzzleFlags[i]; + pthis->puzzleFlags &= ~cobraPuzzleFlags[i]; } if (curCobraInfo->cobra->dyna.actor.update == NULL) { @@ -87,9 +87,9 @@ void BgJyaBigmirror_HandleCobra(Actor* thisx, GlobalContext* globalCtx) { } } else { curCobraInfo->cobra = (BgJyaCobra*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BG_JYA_COBRA, curSpawnData->pos.x, + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BG_JYA_COBRA, curSpawnData->pos.x, curSpawnData->pos.y, curSpawnData->pos.z, 0, curCobraInfo->rotY, 0, curSpawnData->params); - this->actor.child = NULL; + pthis->actor.child = NULL; if (&curCobraInfo->cobra->dyna.actor == NULL) { // "Cobra generation failed" @@ -100,7 +100,7 @@ void BgJyaBigmirror_HandleCobra(Actor* thisx, GlobalContext* globalCtx) { } else { for (i = 0; i < 2; i++) { - curCobraInfo = &this->cobraInfo[i]; + curCobraInfo = &pthis->cobraInfo[i]; if (curCobraInfo->cobra != NULL) { if (curCobraInfo->cobra->dyna.actor.child != NULL) { Actor_Kill(curCobraInfo->cobra->dyna.actor.child); @@ -114,12 +114,12 @@ void BgJyaBigmirror_HandleCobra(Actor* thisx, GlobalContext* globalCtx) { } void BgJyaBigmirror_SetBombiwaFlag(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; if (Flags_GetSwitch(globalCtx, 0x29)) { - this->puzzleFlags |= BIGMIR_PUZZLE_BOMBIWA_DESTROYED; + pthis->puzzleFlags |= BIGMIR_PUZZLE_BOMBIWA_DESTROYED; } else { - this->puzzleFlags &= ~(BIGMIR_PUZZLE_BOMBIWA_DESTROYED); + pthis->puzzleFlags &= ~(BIGMIR_PUZZLE_BOMBIWA_DESTROYED); } } @@ -130,7 +130,7 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, GlobalContext* globalCtx) { { -560.0f, 1800.0f, -310.0f }, { 60.0f, 1800.0f, -310.0f }, }; - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; s32 puzzleSolved; s32 lightBeamToggles[3]; s32 i; @@ -138,71 +138,71 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, GlobalContext* globalCtx) { objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MIR_RAY); - if ((objBankIndex < 0) || (objBankIndex != this->mirRayObjIndex)) { - this->lightBeams[2] = NULL; - this->lightBeams[1] = NULL; - this->lightBeams[0] = NULL; + if ((objBankIndex < 0) || (objBankIndex != pthis->mirRayObjIndex)) { + pthis->lightBeams[2] = NULL; + pthis->lightBeams[1] = NULL; + pthis->lightBeams[0] = NULL; } else { - puzzleSolved = !!(this->puzzleFlags & (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM)); + puzzleSolved = !!(pthis->puzzleFlags & (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM)); if (puzzleSolved) { - puzzleSolved = !!(this->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED); + puzzleSolved = !!(pthis->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED); if (puzzleSolved) { - puzzleSolved = !!(this->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED); + puzzleSolved = !!(pthis->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED); } } lightBeamToggles[0] = puzzleSolved; // Only spawn if puzzle solved if (1) {} lightBeamToggles[1] = lightBeamToggles[2] = - this->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM); + pthis->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM); for (i = 0; i < 3; i++) { if (lightBeamToggles[i]) { - if ((this->lightBeams[i] == NULL) && Object_IsLoaded(&globalCtx->objectCtx, objBankIndex)) { - this->lightBeams[i] = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, sMirRayPoss[i].x, + if ((pthis->lightBeams[i] == NULL) && Object_IsLoaded(&globalCtx->objectCtx, objBankIndex)) { + pthis->lightBeams[i] = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, sMirRayPoss[i].x, sMirRayPoss[i].y, sMirRayPoss[i].z, 0, 0, 0, sMirRayParamss[i]); - if (this->lightBeams[i] == NULL) { + if (pthis->lightBeams[i] == NULL) { // "Mir Ray generation failed" osSyncPrintf("Error : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_bigmirror.c", 310); } } } else { - if (this->lightBeams[i] != NULL) { - Actor_Kill(this->lightBeams[i]); - this->lightBeams[i] = NULL; + if (pthis->lightBeams[i] != NULL) { + Actor_Kill(pthis->lightBeams[i]); + pthis->lightBeams[i] = NULL; } } } } - this->mirRayObjIndex = objBankIndex; + pthis->mirRayObjIndex = objBankIndex; } void BgJyaBigmirror_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; if (sIsSpawned) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - Actor_SetScale(&this->actor, 0.1f); - this->cobraInfo[0].rotY = sCobraSpawnData[0].initRotY; - this->cobraInfo[1].rotY = sCobraSpawnData[1].initRotY; - this->actor.room = -1; + Actor_SetScale(&pthis->actor, 0.1f); + pthis->cobraInfo[0].rotY = sCobraSpawnData[0].initRotY; + pthis->cobraInfo[1].rotY = sCobraSpawnData[1].initRotY; + pthis->actor.room = -1; sIsSpawned = true; - this->spawned = true; - this->mirRayObjIndex = -1; + pthis->spawned = true; + pthis->mirRayObjIndex = -1; // "jya Bigmirror" - osSyncPrintf("(jya 大鏡)(arg_data 0x%04x)\n", this->actor.params); + osSyncPrintf("(jya 大鏡)(arg_data 0x%04x)\n", pthis->actor.params); } void BgJyaBigmirror_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; - if (this->spawned) { + if (pthis->spawned) { sIsSpawned = false; } } @@ -216,18 +216,18 @@ void BgJyaBigmirror_Update(Actor* thisx, GlobalContext* globalCtx) { void BgJyaBigmirror_DrawLightBeam(Actor* thisx, GlobalContext* globalCtx) { static Vec3s D_80893F4C = { 0, 0, 0 }; - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; Actor* lift; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_bigmirror.c", 435); func_80093D84(globalCtx->state.gfxCtx); lift = Actor_Find(&globalCtx->actorCtx, ACTOR_BG_JYA_LIFT, ACTORCAT_BG); if (lift != NULL) { - this->liftHeight = lift->world.pos.y; + pthis->liftHeight = lift->world.pos.y; } - func_800D1694(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_Scale(0.1f, (this->liftHeight * -(1.0f / 1280.0f)) + (1779.4f / 1280.0f), 0.1f, MTXMODE_APPLY); + func_800D1694(pthis->actor.world.pos.x, pthis->actor.world.pos.y + 40.0f, pthis->actor.world.pos.z, + &pthis->actor.shape.rot); + Matrix_Scale(0.1f, (pthis->liftHeight * -(1.0f / 1280.0f)) + (1779.4f / 1280.0f), 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_jya_bigmirror.c", 457), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gBigMirror1DL); @@ -245,16 +245,16 @@ void BgJyaBigmirror_DrawLightBeam(Actor* thisx, GlobalContext* globalCtx) { } void BgJyaBigmirror_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + BgJyaBigmirror* pthis = (BgJyaBigmirror*)thisx; - if (this->puzzleFlags & BIGMIR_PUZZLE_IN_1ST_TOP_ROOM) { + if (pthis->puzzleFlags & BIGMIR_PUZZLE_IN_1ST_TOP_ROOM) { Gfx_DrawDListOpa(globalCtx, gBigMirror3DL); Gfx_DrawDListXlu(globalCtx, gBigMirror4DL); } - if ((this->puzzleFlags & + if ((pthis->puzzleFlags & (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM)) && - (this->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED) && (this->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED)) { - BgJyaBigmirror_DrawLightBeam(&this->actor, globalCtx); + (pthis->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED) && (pthis->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED)) { + BgJyaBigmirror_DrawLightBeam(&pthis->actor, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c b/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.cpp similarity index 81% rename from src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c rename to src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.cpp index ebd3cc121..3c7f10604 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c +++ b/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.cpp @@ -22,7 +22,7 @@ void BgJyaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaBlock_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaBlock_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Jya_Block_InitVars = { +ActorInit Bg_Jya_Block_InitVars = { ACTOR_BG_JYA_BLOCK, ACTORCAT_PROP, FLAGS, @@ -43,31 +43,31 @@ static InitChainEntry sInitChain[] = { void BgJyaBlock_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgJyaBlock* this = (BgJyaBlock*)thisx; + BgJyaBlock* pthis = (BgJyaBlock*)thisx; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_Init(&pthis->dyna, 0); CollisionHeader_GetVirtual(&gPushBlockCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); if ((LINK_AGE_IN_YEARS != YEARS_CHILD) || !Flags_GetSwitch(globalCtx, thisx->params & 0x3F)) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } void BgJyaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBlock* this = (BgJyaBlock*)thisx; + BgJyaBlock* pthis = (BgJyaBlock*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgJyaBlock_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBlock* this = (BgJyaBlock*)thisx; + BgJyaBlock* pthis = (BgJyaBlock*)thisx; Player* player = GET_PLAYER(globalCtx); player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_150 = 0.0f; } void BgJyaBlock_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c b/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.cpp similarity index 56% rename from src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c rename to src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.cpp index bc11db7f7..b3a650299 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.cpp @@ -20,13 +20,13 @@ void BgJyaBombchuiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaBombchuiwa_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaBombchuiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgJyaBombchuiwa_WaitForExplosion(BgJyaBombchuiwa* this, GlobalContext* globalCtx); -void BgJyaBombchuiwa_SetupWaitForExplosion(BgJyaBombchuiwa* this, GlobalContext* globalCtx); -void func_808949B8(BgJyaBombchuiwa* this, GlobalContext* globalCtx); -void BgJyaBombchuiwa_CleanUpAfterExplosion(BgJyaBombchuiwa* this, GlobalContext* globalCtx); -void BgJyaBombchuiwa_SpawnLightRay(BgJyaBombchuiwa* this, GlobalContext* globalCtx); +void BgJyaBombchuiwa_WaitForExplosion(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx); +void BgJyaBombchuiwa_SetupWaitForExplosion(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx); +void func_808949B8(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx); +void BgJyaBombchuiwa_CleanUpAfterExplosion(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx); +void BgJyaBombchuiwa_SpawnLightRay(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Jya_Bombchuiwa_InitVars = { +ActorInit Bg_Jya_Bombchuiwa_InitVars = { ACTOR_BG_JYA_BOMBCHUIWA, ACTORCAT_BG, FLAGS, @@ -73,39 +73,39 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void BgJyaBombchuiwa_SetupCollider(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { +void BgJyaBombchuiwa_SetupCollider(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderItems); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, &pthis->colliderItems); } -void BgJyaBombchuiwa_SetDrawFlags(BgJyaBombchuiwa* this, u8 drawFlags) { - this->drawFlags &= ~7; - this->drawFlags |= drawFlags; +void BgJyaBombchuiwa_SetDrawFlags(BgJyaBombchuiwa* pthis, u8 drawFlags) { + pthis->drawFlags &= ~7; + pthis->drawFlags |= drawFlags; } void BgJyaBombchuiwa_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombchuiwa* this = (BgJyaBombchuiwa*)thisx; + BgJyaBombchuiwa* pthis = (BgJyaBombchuiwa*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - BgJyaBombchuiwa_SetupCollider(this, globalCtx); - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x3F)) { - BgJyaBombchuiwa_SpawnLightRay(this, globalCtx); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + BgJyaBombchuiwa_SetupCollider(pthis, globalCtx); + if (Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F)) { + BgJyaBombchuiwa_SpawnLightRay(pthis, globalCtx); } else { - BgJyaBombchuiwa_SetupWaitForExplosion(this, globalCtx); + BgJyaBombchuiwa_SetupWaitForExplosion(pthis, globalCtx); } - Actor_SetFocus(&this->actor, 0.0f); + Actor_SetFocus(&pthis->actor, 0.0f); } void BgJyaBombchuiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgJyaBombchuiwa* this = (BgJyaBombchuiwa*)thisx; + BgJyaBombchuiwa* pthis = (BgJyaBombchuiwa*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void BgJyaBombchuiwa_Break(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { +void BgJyaBombchuiwa_Break(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { Vec3f pos; Vec3f velocity; s16 scale; @@ -115,9 +115,9 @@ void BgJyaBombchuiwa_Break(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { s32 i; for (i = 0; i < 20; i++) { - pos.x = Rand_ZeroOne() * 10.0f + this->actor.world.pos.x - 10.0f; - pos.y = Rand_ZeroOne() * 40.0f + this->actor.world.pos.y - 20.0f; - pos.z = Rand_ZeroOne() * 50.0f + this->actor.world.pos.z - 25.0f; + pos.x = Rand_ZeroOne() * 10.0f + pthis->actor.world.pos.x - 10.0f; + pos.y = Rand_ZeroOne() * 40.0f + pthis->actor.world.pos.y - 20.0f; + pos.z = Rand_ZeroOne() * 50.0f + pthis->actor.world.pos.z - 25.0f; velocity.x = Rand_ZeroOne() * 3.0f - 0.3f; velocity.y = Rand_ZeroOne() * 18.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 15.0f; @@ -143,67 +143,67 @@ void BgJyaBombchuiwa_Break(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -300, arg5, arg6, arg7, 0, scale, 1, 15, 80, KAKERA_COLOR_NONE, OBJECT_JYA_OBJ, gBombiwaEffectDL); } - func_80033480(globalCtx, &this->actor.world.pos, 100.0f, 8, 100, 160, 0); + func_80033480(globalCtx, &pthis->actor.world.pos, 100.0f, 8, 100, 160, 0); } -void BgJyaBombchuiwa_SetupWaitForExplosion(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { - this->actionFunc = BgJyaBombchuiwa_WaitForExplosion; - BgJyaBombchuiwa_SetDrawFlags(this, 3); - this->timer = 0; +void BgJyaBombchuiwa_SetupWaitForExplosion(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BgJyaBombchuiwa_WaitForExplosion; + BgJyaBombchuiwa_SetDrawFlags(pthis, 3); + pthis->timer = 0; } -void BgJyaBombchuiwa_WaitForExplosion(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { - if ((this->collider.base.acFlags & AC_HIT) || (this->timer > 0)) { - if (this->timer == 0) { - OnePointCutscene_Init(globalCtx, 3410, -99, &this->actor, MAIN_CAM); +void BgJyaBombchuiwa_WaitForExplosion(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { + if ((pthis->collider.base.acFlags & AC_HIT) || (pthis->timer > 0)) { + if (pthis->timer == 0) { + OnePointCutscene_Init(globalCtx, 3410, -99, &pthis->actor, MAIN_CAM); } - this->timer++; - if (this->timer > 10) { - BgJyaBombchuiwa_Break(this, globalCtx); - BgJyaBombchuiwa_CleanUpAfterExplosion(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + pthis->timer++; + if (pthis->timer > 10) { + BgJyaBombchuiwa_Break(pthis, globalCtx); + BgJyaBombchuiwa_CleanUpAfterExplosion(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); } } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void BgJyaBombchuiwa_CleanUpAfterExplosion(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { - this->actionFunc = func_808949B8; - BgJyaBombchuiwa_SetDrawFlags(this, 4); - this->lightRayIntensity = 0.3f; - this->timer = 0; - this->actor.flags &= ~ACTOR_FLAG_0; +void BgJyaBombchuiwa_CleanUpAfterExplosion(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = func_808949B8; + BgJyaBombchuiwa_SetDrawFlags(pthis, 4); + pthis->lightRayIntensity = 0.3f; + pthis->timer = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } -void func_808949B8(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { - this->timer++; - if (this->timer & 4) { - func_80033480(globalCtx, &this->actor.world.pos, 60.0f, 3, 100, 100, 0); +void func_808949B8(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { + pthis->timer++; + if (pthis->timer & 4) { + func_80033480(globalCtx, &pthis->actor.world.pos, 60.0f, 3, 100, 100, 0); } - if (Math_StepToF(&this->lightRayIntensity, 1.0f, 0.028)) { - BgJyaBombchuiwa_SpawnLightRay(this, globalCtx); + if (Math_StepToF(&pthis->lightRayIntensity, 1.0f, 0.028)) { + BgJyaBombchuiwa_SpawnLightRay(pthis, globalCtx); } } -void BgJyaBombchuiwa_SpawnLightRay(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { - this->actionFunc = NULL; - this->lightRayIntensity = 153.0f; - BgJyaBombchuiwa_SetDrawFlags(this, 4); - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0) == NULL) { +void BgJyaBombchuiwa_SpawnLightRay(BgJyaBombchuiwa* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = NULL; + pthis->lightRayIntensity = 153.0f; + BgJyaBombchuiwa_SetDrawFlags(pthis, 4); + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_MIR_RAY, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0) == NULL) { // "Occurrence failure" osSyncPrintf("Error : Mir_Ray 発生失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_jya_bombchuiwa.c", 410, - this->actor.params); + pthis->actor.params); } } void BgJyaBombchuiwa_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombchuiwa* this = (BgJyaBombchuiwa*)thisx; + BgJyaBombchuiwa* pthis = (BgJyaBombchuiwa*)thisx; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } } @@ -217,16 +217,16 @@ void BgJyaBombchuiwa_DrawRock(GlobalContext* globalCtx) { } void BgJyaBombchuiwa_DrawLight(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombchuiwa* this = (BgJyaBombchuiwa*)thisx; + BgJyaBombchuiwa* pthis = (BgJyaBombchuiwa*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_bombchuiwa.c", 453); func_80093D84(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_jya_bombchuiwa.c", 457), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, CLAMP_MAX((u32)(this->lightRayIntensity * 153.0f), 153)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, CLAMP_MAX((u32)(pthis->lightRayIntensity * 153.0f), 153)); gSPDisplayList(POLY_XLU_DISP++, gBombchuiwaLight1DL); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, CLAMP_MAX((u32)(this->lightRayIntensity * 255.0f), 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, CLAMP_MAX((u32)(pthis->lightRayIntensity * 255.0f), 255)); gSPDisplayList(POLY_XLU_DISP++, gBombchuiwaLight2DL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_bombchuiwa.c", 472); } @@ -234,20 +234,20 @@ void BgJyaBombchuiwa_DrawLight(Actor* thisx, GlobalContext* globalCtx) { void BgJyaBombchuiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { static Vec3f D_80894F88 = { -920.0f, 480.0f, -889.0f }; static Vec3s D_80894F94 = { 0, 0, 0 }; - BgJyaBombchuiwa* this = (BgJyaBombchuiwa*)thisx; + BgJyaBombchuiwa* pthis = (BgJyaBombchuiwa*)thisx; - if (this->drawFlags & 1) { + if (pthis->drawFlags & 1) { Gfx_DrawDListOpa(globalCtx, gBombchuiwaDL); - Collider_UpdateSpheres(0, &this->collider); + Collider_UpdateSpheres(0, &pthis->collider); } - if (this->drawFlags & 2) { + if (pthis->drawFlags & 2) { BgJyaBombchuiwa_DrawRock(globalCtx); } - if (this->drawFlags & 4) { + if (pthis->drawFlags & 4) { func_800D1694(D_80894F88.x, D_80894F88.y, D_80894F88.z, &D_80894F94); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (this->drawFlags & 4) { + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + if (pthis->drawFlags & 4) { BgJyaBombchuiwa_DrawLight(thisx, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.cpp similarity index 64% rename from src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c rename to src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.cpp index 6f44a7c49..41ed18666 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.cpp @@ -27,7 +27,7 @@ void BgJyaBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaBombiwa_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaBombiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Jya_Bombiwa_InitVars = { +ActorInit Bg_Jya_Bombiwa_InitVars = { ACTOR_BG_JYA_BOMBIWA, ACTORCAT_BG, FLAGS, @@ -73,60 +73,60 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void BgJyaBombiwa_SetupDynaPoly(BgJyaBombiwa* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { +void BgJyaBombiwa_SetupDynaPoly(BgJyaBombiwa* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { s16 pad1; CollisionHeader* colHeader = NULL; s16 pad2; - DynaPolyActor_Init(&this->dyna, flag); + DynaPolyActor_Init(&pthis->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { // "Warning: move BG registration failed" osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_bombiwa.c", 174, - this->dyna.actor.id, this->dyna.actor.params); + pthis->dyna.actor.id, pthis->dyna.actor.params); } } -void BgJyaBombiwa_InitCollider(BgJyaBombiwa* this, GlobalContext* globalCtx) { +void BgJyaBombiwa_InitCollider(BgJyaBombiwa* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderItems); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->colliderItems); } void BgJyaBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombiwa* this = (BgJyaBombiwa*)thisx; + BgJyaBombiwa* pthis = (BgJyaBombiwa*)thisx; - if ((this->dyna.actor.params & 0x3F) != 0x29) { + if ((pthis->dyna.actor.params & 0x3F) != 0x29) { osSyncPrintf(VT_COL(YELLOW, BLACK)); // "Warning: Switch Number changed (%s %d)(SW %d)" osSyncPrintf("Warning : Switch Number が変更された(%s %d)(SW %d)\n", "../z_bg_jya_bombiwa.c", 218, - this->dyna.actor.params & 0x3F); + pthis->dyna.actor.params & 0x3F); osSyncPrintf(VT_RST); } - BgJyaBombiwa_SetupDynaPoly(this, globalCtx, &gBombiwaCol, DPM_UNK); - BgJyaBombiwa_InitCollider(this, globalCtx); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - Actor_Kill(&this->dyna.actor); + BgJyaBombiwa_SetupDynaPoly(pthis, globalCtx, &gBombiwaCol, DPM_UNK); + BgJyaBombiwa_InitCollider(pthis, globalCtx); + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + Actor_Kill(&pthis->dyna.actor); } else { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); // "Rock destroyed by jya bomb" - osSyncPrintf("(jya 爆弾で破壊岩)(arg_data 0x%04x)\n", this->dyna.actor.params); + osSyncPrintf("(jya 爆弾で破壊岩)(arg_data 0x%04x)\n", pthis->dyna.actor.params); } } void BgJyaBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombiwa* this = (BgJyaBombiwa*)thisx; + BgJyaBombiwa* pthis = (BgJyaBombiwa*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void BgJyaBombiwa_Break(BgJyaBombiwa* this, GlobalContext* globalCtx) { +void BgJyaBombiwa_Break(BgJyaBombiwa* pthis, GlobalContext* globalCtx) { Vec3f pos; Vec3f velocity; s16 arg5; @@ -136,9 +136,9 @@ void BgJyaBombiwa_Break(BgJyaBombiwa* this, GlobalContext* globalCtx) { s16 scale; for (i = 0; i < 16; i++) { - pos.x = ((Rand_ZeroOne() * 80.0f) + this->dyna.actor.world.pos.x) - 40.0f; - pos.y = (Rand_ZeroOne() * 140.0f) + this->dyna.actor.world.pos.y; - pos.z = ((Rand_ZeroOne() * 80.0f) + this->dyna.actor.world.pos.z) - 40.0f; + pos.x = ((Rand_ZeroOne() * 80.0f) + pthis->dyna.actor.world.pos.x) - 40.0f; + pos.y = (Rand_ZeroOne() * 140.0f) + pthis->dyna.actor.world.pos.y; + pos.z = ((Rand_ZeroOne() * 80.0f) + pthis->dyna.actor.world.pos.z) - 40.0f; velocity.x = (Rand_ZeroOne() - 0.5f) * 10.0f; velocity.y = Rand_ZeroOne() * 12.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 10.0f; @@ -164,28 +164,28 @@ void BgJyaBombiwa_Break(BgJyaBombiwa* this, GlobalContext* globalCtx) { EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -400, arg5, arg6, arg7, 0, scale, 1, 20, 80, KAKERA_COLOR_NONE, OBJECT_JYA_OBJ, gBombiwaEffectDL); } - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + 70.0f; - pos.z = this->dyna.actor.world.pos.z; + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + 70.0f; + pos.z = pthis->dyna.actor.world.pos.z; func_80033480(globalCtx, &pos, 100.0f, 0xA, 0x64, 0xA0, 1); } void BgJyaBombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombiwa* this = (BgJyaBombiwa*)thisx; + BgJyaBombiwa* pthis = (BgJyaBombiwa*)thisx; - if (this->collider.base.acFlags & AC_HIT) { - BgJyaBombiwa_Break(this, globalCtx); - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); - Actor_Kill(&this->dyna.actor); + if (pthis->collider.base.acFlags & AC_HIT) { + BgJyaBombiwa_Break(pthis, globalCtx); + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Actor_Kill(&pthis->dyna.actor); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } void BgJyaBombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgJyaBombiwa* this = (BgJyaBombiwa*)thisx; + BgJyaBombiwa* pthis = (BgJyaBombiwa*)thisx; Gfx_DrawDListOpa(globalCtx, gBombiwaDL); - Collider_UpdateSpheres(0, &this->collider); + Collider_UpdateSpheres(0, &pthis->collider); } diff --git a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.cpp similarity index 60% rename from src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c rename to src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.cpp index 7561020ad..04f9c06ce 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c +++ b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.cpp @@ -13,12 +13,12 @@ void BgJyaCobra_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaCobra_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaCobra_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80896918(BgJyaCobra* this, GlobalContext* globalCtx); -void func_80896950(BgJyaCobra* this, GlobalContext* globalCtx); -void func_808969F8(BgJyaCobra* this, GlobalContext* globalCtx); -void func_80896ABC(BgJyaCobra* this, GlobalContext* globalCtx); +void func_80896918(BgJyaCobra* pthis, GlobalContext* globalCtx); +void func_80896950(BgJyaCobra* pthis, GlobalContext* globalCtx); +void func_808969F8(BgJyaCobra* pthis, GlobalContext* globalCtx); +void func_80896ABC(BgJyaCobra* pthis, GlobalContext* globalCtx); -#include "overlays/ovl_Bg_Jya_Cobra/ovl_Bg_Jya_Cobra.c" +#include "overlays/ovl_Bg_Jya_Cobra/ovl_Bg_Jya_Cobra.cpp" #include "def/code_80043480.h" #include "def/sys_matrix.h" #include "def/z_actor.h" @@ -27,7 +27,7 @@ void func_80896ABC(BgJyaCobra* this, GlobalContext* globalCtx); #include "def/z_lib.h" #include "def/z_rcp.h" -const ActorInit Bg_Jya_Cobra_InitVars = { +ActorInit Bg_Jya_Cobra_InitVars = { ACTOR_BG_JYA_COBRA, ACTORCAT_PROP, FLAGS, @@ -124,25 +124,25 @@ void func_808958F0(Vec3f* dest, Vec3f* src, f32 arg2, f32 arg3) { dest->z = (src->z * arg3) - (src->x * arg2); } -void BgJyaCobra_InitDynapoly(BgJyaCobra* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { +void BgJyaCobra_InitDynapoly(BgJyaCobra* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2; - DynaPolyActor_Init(&this->dyna, flags); + DynaPolyActor_Init(&pthis->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { // "Warning : move BG Registration Failure" osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_cobra.c", 247, - this->dyna.actor.id, this->dyna.actor.params); + pthis->dyna.actor.id, pthis->dyna.actor.params); } } -void BgJyaCobra_SpawnRay(BgJyaCobra* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_MIR_RAY, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + 57.0f, this->dyna.actor.world.pos.z, 0, 0, 0, 6); - if (this->dyna.actor.child == NULL) { +void BgJyaCobra_SpawnRay(BgJyaCobra* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_MIR_RAY, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y + 57.0f, pthis->dyna.actor.world.pos.z, 0, 0, 0, 6); + if (pthis->dyna.actor.child == NULL) { osSyncPrintf(VT_FGCOL(RED)); // "Error : Mir Ray occurrence failure" osSyncPrintf("Error : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_cobra.c", 270); @@ -150,19 +150,19 @@ void BgJyaCobra_SpawnRay(BgJyaCobra* this, GlobalContext* globalCtx) { } } -void func_80895A70(BgJyaCobra* this) { +void func_80895A70(BgJyaCobra* pthis) { s32 pad; - BgJyaBigmirror* mirror = (BgJyaBigmirror*)this->dyna.actor.parent; + BgJyaBigmirror* mirror = (BgJyaBigmirror*)pthis->dyna.actor.parent; MirRay* mirRay = NULL; - switch (this->dyna.actor.params & 3) { + switch (pthis->dyna.actor.params & 3) { case 0: - mirRay = (MirRay*)this->dyna.actor.child; + mirRay = (MirRay*)pthis->dyna.actor.child; if (mirRay == NULL) { return; } - if (this->dyna.actor.child->update == NULL) { - this->dyna.actor.child = NULL; + if (pthis->dyna.actor.child->update == NULL) { + pthis->dyna.actor.child = NULL; return; } break; @@ -180,96 +180,96 @@ void func_80895A70(BgJyaCobra* this) { break; } - if (this->unk_18C <= 0.0f) { + if (pthis->unk_18C <= 0.0f) { mirRay->unLit = 1; } else { Vec3f sp28; mirRay->unLit = 0; - Math_Vec3f_Copy(&mirRay->sourcePt, &this->unk_180); - Matrix_RotateY(this->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_NEW); - Matrix_RotateX(D_80897308[this->dyna.actor.params & 3] * (M_PI / 0x8000), MTXMODE_APPLY); + Math_Vec3f_Copy(&mirRay->sourcePt, &pthis->unk_180); + Matrix_RotateY(pthis->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_NEW); + Matrix_RotateX(D_80897308[pthis->dyna.actor.params & 3] * (M_PI / 0x8000), MTXMODE_APPLY); sp28.x = 0.0f; sp28.y = 0.0; - sp28.z = this->unk_190 * 2800.0f; + sp28.z = pthis->unk_190 * 2800.0f; Matrix_MultVec3f(&sp28, &mirRay->poolPt); Math_Vec3f_Sum(&mirRay->sourcePt, &mirRay->poolPt, &mirRay->poolPt); } } -void func_80895BEC(BgJyaCobra* this, GlobalContext* globalCtx) { +void func_80895BEC(BgJyaCobra* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp2C; - func_808958F0(&sp2C, &this->unk_174, Math_SinS(this->unk_170), Math_CosS(this->unk_170)); - player->actor.world.pos.x = this->dyna.actor.world.pos.x + sp2C.x; - player->actor.world.pos.y = this->dyna.actor.world.pos.y + sp2C.y; - player->actor.world.pos.z = this->dyna.actor.world.pos.z + sp2C.z; + func_808958F0(&sp2C, &pthis->unk_174, Math_SinS(pthis->unk_170), Math_CosS(pthis->unk_170)); + player->actor.world.pos.x = pthis->dyna.actor.world.pos.x + sp2C.x; + player->actor.world.pos.y = pthis->dyna.actor.world.pos.y + sp2C.y; + player->actor.world.pos.z = pthis->dyna.actor.world.pos.z + sp2C.z; } -void func_80895C74(BgJyaCobra* this, GlobalContext* globalCtx) { +void func_80895C74(BgJyaCobra* pthis, GlobalContext* globalCtx) { s16 phi_v0; - s16 params = this->dyna.actor.params; - BgJyaBigmirror* mirror = (BgJyaBigmirror*)this->dyna.actor.parent; + s16 params = pthis->dyna.actor.params; + BgJyaBigmirror* mirror = (BgJyaBigmirror*)pthis->dyna.actor.parent; f32 phi_f0; if ((params & 3) == 2 && mirror != NULL && (!(mirror->puzzleFlags & BIGMIR_PUZZLE_BOMBIWA_DESTROYED) || !(mirror->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED))) { - Math_StepToF(&this->unk_18C, 0.0f, 0.05f); + Math_StepToF(&pthis->unk_18C, 0.0f, 0.05f); } else { - this->unk_18C = 1.0f; + pthis->unk_18C = 1.0f; if (D_80897310[params & 3]) { - phi_v0 = this->dyna.actor.shape.rot.y - D_80897314[params & 3]; + phi_v0 = pthis->dyna.actor.shape.rot.y - D_80897314[params & 3]; phi_v0 = ABS(phi_v0); if (phi_v0 < 0x2000 && phi_v0 != -0x8000) { - this->unk_18C += (phi_v0 - 0x2000) * (3.0f / 0x4000); - if (this->unk_18C < 0.0f) { - this->unk_18C = 0.0f; + pthis->unk_18C += (phi_v0 - 0x2000) * (3.0f / 0x4000); + if (pthis->unk_18C < 0.0f) { + pthis->unk_18C = 0.0f; } } } } - this->unk_180.x = this->dyna.actor.world.pos.x; - this->unk_180.y = this->dyna.actor.world.pos.y + 57.0f; - this->unk_180.z = this->dyna.actor.world.pos.z; + pthis->unk_180.x = pthis->dyna.actor.world.pos.x; + pthis->unk_180.y = pthis->dyna.actor.world.pos.y + 57.0f; + pthis->unk_180.z = pthis->dyna.actor.world.pos.z; if ((params & 3) == 0) { - this->unk_190 = 0.1f; + pthis->unk_190 = 0.1f; } else if ((params & 3) == 1) { phi_f0 = 0.1f; - phi_v0 = this->dyna.actor.shape.rot.y - 0x8000; + phi_v0 = pthis->dyna.actor.shape.rot.y - 0x8000; if (phi_v0 < 0x500 && phi_v0 > -0x500) { phi_f0 = 0.34f; } else { - phi_v0 = this->dyna.actor.shape.rot.y - 0x4000; + phi_v0 = pthis->dyna.actor.shape.rot.y - 0x4000; if (phi_v0 < 0x500 && phi_v0 > -0x500 && mirror != NULL && (mirror->puzzleFlags & BIGMIR_PUZZLE_BOMBIWA_DESTROYED)) { phi_f0 = 0.34f; } } - Math_StepToF(&this->unk_190, phi_f0, 0.04f); + Math_StepToF(&pthis->unk_190, phi_f0, 0.04f); } else if ((params & 3) == 2) { phi_f0 = 0.1f; - phi_v0 = this->dyna.actor.shape.rot.y - 0x8000; + phi_v0 = pthis->dyna.actor.shape.rot.y - 0x8000; if (phi_v0 < 0x500 && phi_v0 > -0x500) { phi_f0 = 0.34f; } else { - phi_v0 = this->dyna.actor.shape.rot.y + 0xFFFF4000; + phi_v0 = pthis->dyna.actor.shape.rot.y + 0xFFFF4000; if (phi_v0 < 0x500 && phi_v0 > -0x500) { phi_f0 = 0.34f; } } - Math_StepToF(&this->unk_190, phi_f0, 0.04f); + Math_StepToF(&pthis->unk_190, phi_f0, 0.04f); } } /* * Updates the shadow with light coming from the side of the mirror */ -void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { +void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* pthis) { Vec3f spD4; Vec3f spC8; Vec3f spBC; @@ -284,12 +284,12 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { s32 l; s16 rotY; - temp_s2 = ALIGN16((s32)(&this->shadowTexture)); + temp_s2 = (u8*)ALIGN16((s32)(&pthis->shadowTexture)); Lib_MemSet(temp_s2, 0x1000, 0); Matrix_RotateX((M_PI / 4), MTXMODE_NEW); - rotY = !(this->dyna.actor.params & 3) ? (this->dyna.actor.shape.rot.y + 0x4000) - : (this->dyna.actor.shape.rot.y - 0x4000); + rotY = !(pthis->dyna.actor.params & 3) ? (pthis->dyna.actor.shape.rot.y + 0x4000) + : (pthis->dyna.actor.shape.rot.y - 0x4000); Matrix_RotateY(rotY * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Scale(0.9f, 0.9f, 0.9f, MTXMODE_APPLY); @@ -363,7 +363,7 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { /* * Updates the shadow with light coming from above the mirror */ -void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { +void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* pthis) { f32 sp58[0x40]; s32 i; s32 j; @@ -376,7 +376,7 @@ void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { sp58[i] = SQ(i - 31.5f); } - sp40 = temp_s0 = (u8*)ALIGN16((uintptr_t)(&this->shadowTexture)); + sp40 = temp_s0 = (u8*)ALIGN16((uintptr_t)(&pthis->shadowTexture)); Lib_MemSet(temp_s0, 0x1000, 0); for (i = 0; i != 0x40; i++) { @@ -404,132 +404,132 @@ void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { } void BgJyaCobra_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaCobra* this = (BgJyaCobra*)thisx; + BgJyaCobra* pthis = (BgJyaCobra*)thisx; - BgJyaCobra_InitDynapoly(this, globalCtx, &gCobraCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (!(this->dyna.actor.params & 3) && Flags_GetSwitch(globalCtx, ((s32)this->dyna.actor.params >> 8) & 0x3F)) { - this->dyna.actor.world.rot.y = this->dyna.actor.home.rot.y = this->dyna.actor.shape.rot.y = 0; + BgJyaCobra_InitDynapoly(pthis, globalCtx, &gCobraCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + if (!(pthis->dyna.actor.params & 3) && Flags_GetSwitch(globalCtx, ((s32)pthis->dyna.actor.params >> 8) & 0x3F)) { + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.home.rot.y = pthis->dyna.actor.shape.rot.y = 0; } - if (!(this->dyna.actor.params & 3)) { - BgJyaCobra_SpawnRay(this, globalCtx); + if (!(pthis->dyna.actor.params & 3)) { + BgJyaCobra_SpawnRay(pthis, globalCtx); } - func_80896918(this, globalCtx); + func_80896918(pthis, globalCtx); - if ((this->dyna.actor.params & 3) == 1 || (this->dyna.actor.params & 3) == 2) { - this->dyna.actor.room = -1; + if ((pthis->dyna.actor.params & 3) == 1 || (pthis->dyna.actor.params & 3) == 2) { + pthis->dyna.actor.room = -1; } - if ((this->dyna.actor.params & 3) == 1) { - BgJyaCobra_UpdateShadowFromTop(this); + if ((pthis->dyna.actor.params & 3) == 1) { + BgJyaCobra_UpdateShadowFromTop(pthis); } // "(jya cobra)" - osSyncPrintf("(jya コブラ)(arg_data 0x%04x)(act %x)(txt %x)(txt16 %x)\n", this->dyna.actor.params, this, - &this->shadowTexture, ALIGN16((s32)(&this->shadowTexture))); + osSyncPrintf("(jya コブラ)(arg_data 0x%04x)(act %x)(txt %x)(txt16 %x)\n", pthis->dyna.actor.params, pthis, + &pthis->shadowTexture, ALIGN16((s32)(&pthis->shadowTexture))); } void BgJyaCobra_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaCobra* this = (BgJyaCobra*)thisx; + BgJyaCobra* pthis = (BgJyaCobra*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_80896918(BgJyaCobra* this, GlobalContext* globalCtx) { - this->actionFunc = func_80896950; - this->unk_168 = 0; - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y = - (this->unk_16C * 0x2000) + this->dyna.actor.home.rot.y; +void func_80896918(BgJyaCobra* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = func_80896950; + pthis->unk_168 = 0; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y = + (pthis->unk_16C * 0x2000) + pthis->dyna.actor.home.rot.y; } -void func_80896950(BgJyaCobra* this, GlobalContext* globalCtx) { +void func_80896950(BgJyaCobra* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 > 0.001f) { - this->unk_168++; - if (this->unk_168 >= 15) { - func_808969F8(this, globalCtx); + if (pthis->dyna.unk_150 > 0.001f) { + pthis->unk_168++; + if (pthis->unk_168 >= 15) { + func_808969F8(pthis, globalCtx); } } else { - this->unk_168 = 0; + pthis->unk_168 = 0; } - if (fabsf(this->dyna.unk_150) > 0.001f) { - this->dyna.unk_150 = 0.0f; + if (fabsf(pthis->dyna.unk_150) > 0.001f) { + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; } } -void func_808969F8(BgJyaCobra* this, GlobalContext* globalCtx) { +void func_808969F8(BgJyaCobra* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 phi_a3; s16 temp2; - this->actionFunc = func_80896ABC; + pthis->actionFunc = func_80896ABC; - temp2 = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; - phi_a3 = (s16)(this->dyna.actor.shape.rot.y - this->dyna.unk_158); + temp2 = pthis->dyna.actor.yawTowardsPlayer - pthis->dyna.actor.shape.rot.y; + phi_a3 = (s16)(pthis->dyna.actor.shape.rot.y - pthis->dyna.unk_158); phi_a3 = ABS(phi_a3); if (temp2 > 0) { - this->unk_16A = (phi_a3 > 0x4000) ? 1 : -1; + pthis->unk_16A = (phi_a3 > 0x4000) ? 1 : -1; } else { - this->unk_16A = (phi_a3 > 0x4000) ? -1 : 1; + pthis->unk_16A = (phi_a3 > 0x4000) ? -1 : 1; } - this->unk_174.x = player->actor.world.pos.x - this->dyna.actor.world.pos.x; - this->unk_174.y = player->actor.world.pos.y - this->dyna.actor.world.pos.y; - this->unk_174.z = player->actor.world.pos.z - this->dyna.actor.world.pos.z; - this->unk_170 = this->unk_16E = 0; - this->unk_172 = true; + pthis->unk_174.x = player->actor.world.pos.x - pthis->dyna.actor.world.pos.x; + pthis->unk_174.y = player->actor.world.pos.y - pthis->dyna.actor.world.pos.y; + pthis->unk_174.z = player->actor.world.pos.z - pthis->dyna.actor.world.pos.z; + pthis->unk_170 = pthis->unk_16E = 0; + pthis->unk_172 = true; } -void func_80896ABC(BgJyaCobra* this, GlobalContext* globalCtx) { +void func_80896ABC(BgJyaCobra* pthis, GlobalContext* globalCtx) { s16 temp_v0; Player* player = GET_PLAYER(globalCtx); - temp_v0 = (s16)((this->unk_16C * 0x2000) + this->dyna.actor.home.rot.y) - this->dyna.actor.world.rot.y; + temp_v0 = (s16)((pthis->unk_16C * 0x2000) + pthis->dyna.actor.home.rot.y) - pthis->dyna.actor.world.rot.y; if (ABS(temp_v0) < 7424) { - Math_StepToS(&this->unk_16E, 106, 4); + Math_StepToS(&pthis->unk_16E, 106, 4); } else { - Math_StepToS(&this->unk_16E, 21, 10); + Math_StepToS(&pthis->unk_16E, 21, 10); } - if (Math_ScaledStepToS(&this->unk_170, this->unk_16A * 0x2000, this->unk_16E)) { - this->unk_16C = (this->unk_16C + this->unk_16A) & 7; + if (Math_ScaledStepToS(&pthis->unk_170, pthis->unk_16A * 0x2000, pthis->unk_16E)) { + pthis->unk_16C = (pthis->unk_16C + pthis->unk_16A) & 7; player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - func_80896918(this, globalCtx); + pthis->dyna.unk_150 = 0.0f; + func_80896918(pthis, globalCtx); } else { - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y = - (this->unk_16C * 0x2000) + this->dyna.actor.home.rot.y + this->unk_170; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y = + (pthis->unk_16C * 0x2000) + pthis->dyna.actor.home.rot.y + pthis->unk_170; } if (player->stateFlags2 & 0x10) { - if (this->unk_172) { - func_80895BEC(this, globalCtx); + if (pthis->unk_172) { + func_80895BEC(pthis, globalCtx); } - } else if (fabsf(this->dyna.unk_150) < 0.001f) { - this->unk_172 = false; + } else if (fabsf(pthis->dyna.unk_150) < 0.001f) { + pthis->unk_172 = false; } - this->dyna.unk_150 = 0.0f; - func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + pthis->dyna.unk_150 = 0.0f; + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } void BgJyaCobra_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgJyaCobra* this = (BgJyaCobra*)thisx; + BgJyaCobra* pthis = (BgJyaCobra*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - func_80895C74(this, globalCtx); - func_80895A70(this); + func_80895C74(pthis, globalCtx); + func_80895A70(pthis); - if ((this->dyna.actor.params & 3) == 0 || (this->dyna.actor.params & 3) == 2) { - BgJyaCobra_UpdateShadowFromSide(this); + if ((pthis->dyna.actor.params & 3) == 0 || (pthis->dyna.actor.params & 3) == 2) { + BgJyaCobra_UpdateShadowFromSide(pthis); } } @@ -544,30 +544,30 @@ void func_80896CB4(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_cobra.c", 872); } -void func_80896D78(BgJyaCobra* this, GlobalContext* globalCtx) { +void func_80896D78(BgJyaCobra* pthis, GlobalContext* globalCtx) { s32 pad; Vec3s sp44; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_cobra.c", 924); func_80093D84(globalCtx->state.gfxCtx); - sp44.x = D_80897308[this->dyna.actor.params & 3] + this->dyna.actor.shape.rot.x; - sp44.y = this->dyna.actor.shape.rot.y; - sp44.z = this->dyna.actor.shape.rot.z; - func_800D1694(this->unk_180.x, this->unk_180.y, this->unk_180.z, &sp44); + sp44.x = D_80897308[pthis->dyna.actor.params & 3] + pthis->dyna.actor.shape.rot.x; + sp44.y = pthis->dyna.actor.shape.rot.y; + sp44.z = pthis->dyna.actor.shape.rot.z; + func_800D1694(pthis->unk_180.x, pthis->unk_180.y, pthis->unk_180.z, &sp44); - Matrix_Scale(0.1f, 0.1f, this->unk_190, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, pthis->unk_190, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_jya_cobra.c", 939), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)(this->unk_18C * 140.0f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)(pthis->unk_18C * 140.0f)); gSPDisplayList(POLY_XLU_DISP++, gCobra3DL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_cobra.c", 947); } -void BgJyaCobra_DrawShadow(BgJyaCobra* this, GlobalContext* globalCtx) { +void BgJyaCobra_DrawShadow(BgJyaCobra* pthis, GlobalContext* globalCtx) { s32 pad; - s16 params = this->dyna.actor.params & 3; + s16 params = pthis->dyna.actor.params & 3; Vec3f sp64; Vec3s* phi_a3; @@ -576,18 +576,18 @@ void BgJyaCobra_DrawShadow(BgJyaCobra* this, GlobalContext* globalCtx) { func_80094044(globalCtx->state.gfxCtx); if (params == 0) { - sp64.x = this->dyna.actor.world.pos.x - 50.0f; - sp64.y = this->dyna.actor.world.pos.y; - sp64.z = this->dyna.actor.world.pos.z; + sp64.x = pthis->dyna.actor.world.pos.x - 50.0f; + sp64.y = pthis->dyna.actor.world.pos.y; + sp64.z = pthis->dyna.actor.world.pos.z; phi_a3 = &D_80897538; } else if (params == 2) { - sp64.x = this->dyna.actor.world.pos.x + 70.0f; - sp64.y = this->dyna.actor.world.pos.y; - sp64.z = this->dyna.actor.world.pos.z; + sp64.x = pthis->dyna.actor.world.pos.x + 70.0f; + sp64.y = pthis->dyna.actor.world.pos.y; + sp64.z = pthis->dyna.actor.world.pos.z; phi_a3 = &D_80897540; } else { // params == 1 - phi_a3 = &this->dyna.actor.shape.rot; - Math_Vec3f_Copy(&sp64, &this->dyna.actor.world.pos); + phi_a3 = &pthis->dyna.actor.shape.rot; + Math_Vec3f_Copy(&sp64, &pthis->dyna.actor.world.pos); } func_800D1694(sp64.x, sp64.y, sp64.z, phi_a3); @@ -599,7 +599,7 @@ void BgJyaCobra_DrawShadow(BgJyaCobra* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_jya_cobra.c", 994), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPLoadTextureBlock(POLY_XLU_DISP++, ALIGN16((s32)(&this->shadowTexture)), G_IM_FMT_I, G_IM_SIZ_8b, 0x40, 0x40, 0, + gDPLoadTextureBlock(POLY_XLU_DISP++, ALIGN16((s32)(&pthis->shadowTexture)), G_IM_FMT_I, G_IM_SIZ_8b, 0x40, 0x40, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -609,23 +609,23 @@ void BgJyaCobra_DrawShadow(BgJyaCobra* this, GlobalContext* globalCtx) { } void BgJyaCobra_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgJyaCobra* this = (BgJyaCobra*)thisx; + BgJyaCobra* pthis = (BgJyaCobra*)thisx; func_80896CB4(globalCtx); Gfx_DrawDListOpa(globalCtx, gCobra1DL); - if (this->unk_18C > 0.0f) { - func_80896D78(this, globalCtx); + if (pthis->unk_18C > 0.0f) { + func_80896D78(pthis, globalCtx); } - if ((this->dyna.actor.params & 3) == 2) { - BgJyaBigmirror* mirror = (BgJyaBigmirror*)this->dyna.actor.parent; + if ((pthis->dyna.actor.params & 3) == 2) { + BgJyaBigmirror* mirror = (BgJyaBigmirror*)pthis->dyna.actor.parent; if (mirror != NULL && (mirror->puzzleFlags & BIGMIR_PUZZLE_BOMBIWA_DESTROYED) && (mirror->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED)) { - BgJyaCobra_DrawShadow(this, globalCtx); + BgJyaCobra_DrawShadow(pthis, globalCtx); } } else { - BgJyaCobra_DrawShadow(this, globalCtx); + BgJyaCobra_DrawShadow(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c b/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.cpp similarity index 53% rename from src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c rename to src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.cpp index 1382bd3a2..979e240c5 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.cpp @@ -22,15 +22,15 @@ void BgJyaGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgJyaGoroiwa_Wait(BgJyaGoroiwa* this, GlobalContext* globalCtx); -void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, GlobalContext* globalCtx); +void BgJyaGoroiwa_Wait(BgJyaGoroiwa* pthis, GlobalContext* globalCtx); +void BgJyaGoroiwa_Move(BgJyaGoroiwa* pthis, GlobalContext* globalCtx); -void BgJyaGoroiwa_SetupWait(BgJyaGoroiwa* this); -void BgJyaGoroiwa_SetupMove(BgJyaGoroiwa* this); -void BgJyaGoroiwa_UpdateRotation(BgJyaGoroiwa* this); -void BgJyaGoroiwa_UpdateCollider(BgJyaGoroiwa* this); +void BgJyaGoroiwa_SetupWait(BgJyaGoroiwa* pthis); +void BgJyaGoroiwa_SetupMove(BgJyaGoroiwa* pthis); +void BgJyaGoroiwa_UpdateRotation(BgJyaGoroiwa* pthis); +void BgJyaGoroiwa_UpdateCollider(BgJyaGoroiwa* pthis); -const ActorInit Bg_Jya_Goroiwa_InitVars = { +ActorInit Bg_Jya_Goroiwa_InitVars = { ACTOR_BG_JYA_GOROIWA, ACTORCAT_PROP, FLAGS, @@ -78,56 +78,56 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void BgJyaGoroiwa_UpdateCollider(BgJyaGoroiwa* this) { - Sphere16* worldSphere = &this->collider.elements[0].dim.worldSphere; +void BgJyaGoroiwa_UpdateCollider(BgJyaGoroiwa* pthis) { + Sphere16* worldSphere = &pthis->collider.elements[0].dim.worldSphere; - worldSphere->center.x = this->actor.world.pos.x; - worldSphere->center.y = this->actor.world.pos.y + 59.5f; - worldSphere->center.z = this->actor.world.pos.z; + worldSphere->center.x = pthis->actor.world.pos.x; + worldSphere->center.y = pthis->actor.world.pos.y + 59.5f; + worldSphere->center.z = pthis->actor.world.pos.z; } -void BgJyaGoroiwa_InitCollider(BgJyaGoroiwa* this, GlobalContext* globalCtx) { +void BgJyaGoroiwa_InitCollider(BgJyaGoroiwa* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderItem); - BgJyaGoroiwa_UpdateCollider(this); - this->collider.elements[0].dim.worldSphere.radius = 58; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, &pthis->colliderItem); + BgJyaGoroiwa_UpdateCollider(pthis); + pthis->collider.elements[0].dim.worldSphere.radius = 58; } -void BgJyaGoroiwa_UpdateRotation(BgJyaGoroiwa* this) { - f32 xDiff = this->actor.world.pos.x - this->actor.prevPos.x; +void BgJyaGoroiwa_UpdateRotation(BgJyaGoroiwa* pthis) { + f32 xDiff = pthis->actor.world.pos.x - pthis->actor.prevPos.x; - this->actor.shape.rot.z -= 0x10000 / (119 * M_PI) * xDiff; + pthis->actor.shape.rot.z -= 0x10000 / (119 * M_PI) * xDiff; } void BgJyaGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaGoroiwa* this = (BgJyaGoroiwa*)thisx; + BgJyaGoroiwa* pthis = (BgJyaGoroiwa*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - BgJyaGoroiwa_InitCollider(this, globalCtx); - this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 595.0f, ActorShadow_DrawCircle, 9.0f); - this->actor.shape.shadowAlpha = 128; - BgJyaGoroiwa_SetupMove(this); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + BgJyaGoroiwa_InitCollider(pthis, globalCtx); + pthis->actor.shape.rot.x = pthis->actor.shape.rot.y = pthis->actor.shape.rot.z = 0; + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 595.0f, ActorShadow_DrawCircle, 9.0f); + pthis->actor.shape.shadowAlpha = 128; + BgJyaGoroiwa_SetupMove(pthis); } void BgJyaGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaGoroiwa* this = (BgJyaGoroiwa*)thisx; + BgJyaGoroiwa* pthis = (BgJyaGoroiwa*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void BgJyaGoroiwa_SetupMove(BgJyaGoroiwa* this) { - this->actionFunc = BgJyaGoroiwa_Move; - this->collider.base.atFlags |= AT_ON; - this->hasHit = false; - this->speedFactor = 1.0f; +void BgJyaGoroiwa_SetupMove(BgJyaGoroiwa* pthis) { + pthis->actionFunc = BgJyaGoroiwa_Move; + pthis->collider.base.atFlags |= AT_ON; + pthis->hasHit = false; + pthis->speedFactor = 1.0f; } -void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, GlobalContext* globalCtx) { - Actor* thisx = &this->actor; +void BgJyaGoroiwa_Move(BgJyaGoroiwa* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->actor; s16 relYawTowardsPlayer; f32 speedXZsqBase = (-100.0f - thisx->world.pos.y) * 2.5f; f32 posYfac; @@ -136,7 +136,7 @@ void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, GlobalContext* globalCtx) { speedXZsqBase = 0.01f; } - thisx->speedXZ = sqrtf(speedXZsqBase) * this->speedFactor; + thisx->speedXZ = sqrtf(speedXZsqBase) * pthis->speedFactor; thisx->velocity.x = Math_SinS(thisx->world.rot.y) * thisx->speedXZ; thisx->velocity.z = Math_CosS(thisx->world.rot.y) * thisx->speedXZ; @@ -151,8 +151,8 @@ void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, GlobalContext* globalCtx) { thisx->world.pos.y = ((35.0f / 92.0f) * posYfac) - 129.5f; } - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT & ~AT_ON; + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT & ~AT_ON; relYawTowardsPlayer = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((relYawTowardsPlayer > -0x4000) && (relYawTowardsPlayer < 0x4000)) { @@ -162,20 +162,20 @@ void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, GlobalContext* globalCtx) { func_8002F6D4(globalCtx, thisx, 2.0f, thisx->yawTowardsPlayer, 0.0f, 0); func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - this->yOffsetSpeed = 10.0f; - this->speedFactor = 0.5f; - this->hasHit = true; + pthis->yOffsetSpeed = 10.0f; + pthis->speedFactor = 0.5f; + pthis->hasHit = true; } - if (this->hasHit) { - this->yOffsetSpeed -= 1.5f; - thisx->shape.yOffset += this->yOffsetSpeed * 10.0f; + if (pthis->hasHit) { + pthis->yOffsetSpeed -= 1.5f; + thisx->shape.yOffset += pthis->yOffsetSpeed * 10.0f; if (thisx->shape.yOffset < 595.0f) { thisx->shape.yOffset = 595.0f; - BgJyaGoroiwa_SetupWait(this); + BgJyaGoroiwa_SetupWait(pthis); } } else { - Math_StepToF(&this->speedFactor, 1.0f, 0.04f); + Math_StepToF(&pthis->speedFactor, 1.0f, 0.04f); } if (thisx->world.pos.x > 1745.0f) { @@ -187,39 +187,39 @@ void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(thisx, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); } -void BgJyaGoroiwa_SetupWait(BgJyaGoroiwa* this) { - this->actionFunc = BgJyaGoroiwa_Wait; - this->waitTimer = 0; +void BgJyaGoroiwa_SetupWait(BgJyaGoroiwa* pthis) { + pthis->actionFunc = BgJyaGoroiwa_Wait; + pthis->waitTimer = 0; } -void BgJyaGoroiwa_Wait(BgJyaGoroiwa* this, GlobalContext* globalCtx) { - this->waitTimer++; - if (this->waitTimer > 60) { - BgJyaGoroiwa_SetupMove(this); - this->speedFactor = 0.1f; +void BgJyaGoroiwa_Wait(BgJyaGoroiwa* pthis, GlobalContext* globalCtx) { + pthis->waitTimer++; + if (pthis->waitTimer > 60) { + BgJyaGoroiwa_SetupMove(pthis); + pthis->speedFactor = 0.1f; } } void BgJyaGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgJyaGoroiwa* this = (BgJyaGoroiwa*)thisx; + BgJyaGoroiwa* pthis = (BgJyaGoroiwa*)thisx; Player* player = GET_PLAYER(globalCtx); s32 bgId; Vec3f pos; if (!(player->stateFlags1 & 0x300000C0)) { - this->actionFunc(this, globalCtx); - BgJyaGoroiwa_UpdateRotation(this); - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 59.5f; - pos.z = this->actor.world.pos.z; - this->actor.floorHeight = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); - BgJyaGoroiwa_UpdateCollider(this); - if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->actionFunc(pthis, globalCtx); + BgJyaGoroiwa_UpdateRotation(pthis); + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 59.5f; + pos.z = pthis->actor.world.pos.z; + pthis->actor.floorHeight = + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, &pthis->actor, &pos); + BgJyaGoroiwa_UpdateCollider(pthis); + if (pthis->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c b/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.cpp similarity index 52% rename from src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c rename to src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.cpp index 637df85ae..b12d35f2b 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c +++ b/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.cpp @@ -24,14 +24,14 @@ void BgJyaHaheniron_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaHaheniron_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaHaheniron_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgJyaHaheniron_SetupChairCrumble(BgJyaHaheniron* this); -void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* this, GlobalContext* globalCtx); -void BgJyaHaheniron_SetupPillarCrumble(BgJyaHaheniron* this); -void BgJyaHaheniron_PillarCrumble(BgJyaHaheniron* this, GlobalContext* globalCtx); -void BgJyaHaheniron_SetupRubbleCollide(BgJyaHaheniron* this); -void BgJyaHaheniron_RubbleCollide(BgJyaHaheniron* this, GlobalContext* globalCtx); +void BgJyaHaheniron_SetupChairCrumble(BgJyaHaheniron* pthis); +void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* pthis, GlobalContext* globalCtx); +void BgJyaHaheniron_SetupPillarCrumble(BgJyaHaheniron* pthis); +void BgJyaHaheniron_PillarCrumble(BgJyaHaheniron* pthis, GlobalContext* globalCtx); +void BgJyaHaheniron_SetupRubbleCollide(BgJyaHaheniron* pthis); +void BgJyaHaheniron_RubbleCollide(BgJyaHaheniron* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Jya_Haheniron_InitVars = { +ActorInit Bg_Jya_Haheniron_InitVars = { ACTOR_BG_JYA_HAHENIRON, ACTORCAT_PROP, FLAGS, @@ -84,11 +84,11 @@ static Vec3f D_808987A0[] = { 0.0f, 14.0f, 0.0f }; static Vec3f D_808987AC[] = { 0.0f, 8.0f, 0.0f }; -void BgJyaHaheniron_ColliderInit(BgJyaHaheniron* this, GlobalContext* globalCtx) { +void BgJyaHaheniron_ColliderInit(BgJyaHaheniron* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); } void BgJyaHaheniron_SpawnFragments(GlobalContext* globalCtx, Vec3f* vec1, Vec3f* vec2) { @@ -126,88 +126,88 @@ void BgJyaHaheniron_SpawnFragments(GlobalContext* globalCtx, Vec3f* vec1, Vec3f* void BgJyaHaheniron_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; + BgJyaHaheniron* pthis = (BgJyaHaheniron*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, D_80898794[this->actor.params]); - if (this->actor.params == 0) { - BgJyaHaheniron_ColliderInit(this, globalCtx); - this->actor.shape.rot.z = (Rand_ZeroOne() * 65535.0f); - BgJyaHaheniron_SetupChairCrumble(this); - } else if (this->actor.params == 1) { - BgJyaHaheniron_SetupPillarCrumble(this); - } else if (this->actor.params == 2) { - BgJyaHaheniron_SetupRubbleCollide(this); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, D_80898794[pthis->actor.params]); + if (pthis->actor.params == 0) { + BgJyaHaheniron_ColliderInit(pthis, globalCtx); + pthis->actor.shape.rot.z = (Rand_ZeroOne() * 65535.0f); + BgJyaHaheniron_SetupChairCrumble(pthis); + } else if (pthis->actor.params == 1) { + BgJyaHaheniron_SetupPillarCrumble(pthis); + } else if (pthis->actor.params == 2) { + BgJyaHaheniron_SetupRubbleCollide(pthis); } } void BgJyaHaheniron_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; + BgJyaHaheniron* pthis = (BgJyaHaheniron*)thisx; - if (this->actor.params == 0) { - Collider_DestroyJntSph(globalCtx, &this->collider); + if (pthis->actor.params == 0) { + Collider_DestroyJntSph(globalCtx, &pthis->collider); } } -void BgJyaHaheniron_SetupChairCrumble(BgJyaHaheniron* this) { - this->actionFunc = BgJyaHaheniron_ChairCrumble; +void BgJyaHaheniron_SetupChairCrumble(BgJyaHaheniron* pthis) { + pthis->actionFunc = BgJyaHaheniron_ChairCrumble; } -void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* this, GlobalContext* globalCtx) { +void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* pthis, GlobalContext* globalCtx) { Vec3f vec; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 8.0f, 0.0f, 0x85); - if ((this->actor.bgCheckFlags & 9) || ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.at != NULL) && - (this->collider.base.at->category == ACTORCAT_PLAYER))) { - vec.x = -Rand_ZeroOne() * this->actor.velocity.x; - vec.y = -Rand_ZeroOne() * this->actor.velocity.y; - vec.z = -Rand_ZeroOne() * this->actor.velocity.z; - BgJyaHaheniron_SpawnFragments(globalCtx, &this->actor.world.pos, &vec); - Actor_Kill(&this->actor); - } else if (this->timer > 60) { - Actor_Kill(&this->actor); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 8.0f, 0.0f, 0x85); + if ((pthis->actor.bgCheckFlags & 9) || ((pthis->collider.base.atFlags & AT_HIT) && (pthis->collider.base.at != NULL) && + (pthis->collider.base.at->category == ACTORCAT_PLAYER))) { + vec.x = -Rand_ZeroOne() * pthis->actor.velocity.x; + vec.y = -Rand_ZeroOne() * pthis->actor.velocity.y; + vec.z = -Rand_ZeroOne() * pthis->actor.velocity.z; + BgJyaHaheniron_SpawnFragments(globalCtx, &pthis->actor.world.pos, &vec); + Actor_Kill(&pthis->actor); + } else if (pthis->timer > 60) { + Actor_Kill(&pthis->actor); } else { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - this->actor.shape.rot.y += 0x4B0; - this->actor.shape.rot.x += 0xFA0; + pthis->actor.shape.rot.y += 0x4B0; + pthis->actor.shape.rot.x += 0xFA0; } -void BgJyaHaheniron_SetupPillarCrumble(BgJyaHaheniron* this) { - this->actionFunc = BgJyaHaheniron_PillarCrumble; +void BgJyaHaheniron_SetupPillarCrumble(BgJyaHaheniron* pthis) { + pthis->actionFunc = BgJyaHaheniron_PillarCrumble; } -void BgJyaHaheniron_PillarCrumble(BgJyaHaheniron* this, GlobalContext* globalCtx) { - if (this->timer >= 8) { - Actor_MoveForward(&this->actor); - } else if (this->timer >= 17) { - BgJyaHaheniron_SpawnFragments(globalCtx, &this->actor.world.pos, D_808987A0); - Actor_Kill(&this->actor); +void BgJyaHaheniron_PillarCrumble(BgJyaHaheniron* pthis, GlobalContext* globalCtx) { + if (pthis->timer >= 8) { + Actor_MoveForward(&pthis->actor); + } else if (pthis->timer >= 17) { + BgJyaHaheniron_SpawnFragments(globalCtx, &pthis->actor.world.pos, D_808987A0); + Actor_Kill(&pthis->actor); } - this->actor.shape.rot.y += 0x258; - this->actor.shape.rot.x += 0x3E8; + pthis->actor.shape.rot.y += 0x258; + pthis->actor.shape.rot.x += 0x3E8; } -void BgJyaHaheniron_SetupRubbleCollide(BgJyaHaheniron* this) { - this->actionFunc = BgJyaHaheniron_RubbleCollide; +void BgJyaHaheniron_SetupRubbleCollide(BgJyaHaheniron* pthis) { + pthis->actionFunc = BgJyaHaheniron_RubbleCollide; } -void BgJyaHaheniron_RubbleCollide(BgJyaHaheniron* this, GlobalContext* globalCtx) { - if (this->timer >= 17) { - BgJyaHaheniron_SpawnFragments(globalCtx, &this->actor.world.pos, D_808987AC); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 80, NA_SE_EN_IRONNACK_BREAK_PILLAR2); - Actor_Kill(&this->actor); +void BgJyaHaheniron_RubbleCollide(BgJyaHaheniron* pthis, GlobalContext* globalCtx) { + if (pthis->timer >= 17) { + BgJyaHaheniron_SpawnFragments(globalCtx, &pthis->actor.world.pos, D_808987AC); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 80, NA_SE_EN_IRONNACK_BREAK_PILLAR2); + Actor_Kill(&pthis->actor); } } void BgJyaHaheniron_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; + BgJyaHaheniron* pthis = (BgJyaHaheniron*)thisx; - this->timer++; - this->actionFunc(this, globalCtx); + pthis->timer++; + pthis->actionFunc(pthis, globalCtx); } void BgJyaHaheniron_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -217,10 +217,10 @@ void BgJyaHaheniron_Draw(Actor* thisx, GlobalContext* globalCtx) { gObjectJyaIronDL_000600, }; s32 pad; - BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; + BgJyaHaheniron* pthis = (BgJyaHaheniron*)thisx; - if (this->actor.params == 0) { - Collider_UpdateSpheres(0, &this->collider); + if (pthis->actor.params == 0) { + Collider_UpdateSpheres(0, &pthis->collider); } - Gfx_DrawDListOpa(globalCtx, dLists[this->actor.params]); + Gfx_DrawDListOpa(globalCtx, dLists[pthis->actor.params]); } diff --git a/src/overlays/actors/ovl_Bg_Jya_Ironobj/z_bg_jya_ironobj.c b/src/overlays/actors/ovl_Bg_Jya_Ironobj/z_bg_jya_ironobj.cpp similarity index 67% rename from src/overlays/actors/ovl_Bg_Jya_Ironobj/z_bg_jya_ironobj.c rename to src/overlays/actors/ovl_Bg_Jya_Ironobj/z_bg_jya_ironobj.cpp index 474e2bcce..4d2c9404a 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Ironobj/z_bg_jya_ironobj.c +++ b/src/overlays/actors/ovl_Bg_Jya_Ironobj/z_bg_jya_ironobj.cpp @@ -28,15 +28,15 @@ void BgJyaIronobj_Init(Actor* thisx, GlobalContext* globalCtx); void BgJyaIronobj_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaIronobj_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaIronobj_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808992D8(BgJyaIronobj* this); -void func_808992E8(BgJyaIronobj* this, GlobalContext* globalCtx); +void func_808992D8(BgJyaIronobj* pthis); +void func_808992E8(BgJyaIronobj* pthis, GlobalContext* globalCtx); -void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* this, GlobalContext* globalCtx, EnIk* enIk); -void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* this, GlobalContext* arg1, EnIk* enIk); +void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* pthis, GlobalContext* globalCtx, EnIk* enIk); +void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* pthis, GlobalContext* arg1, EnIk* enIk); static int sUnused = 0; -const ActorInit Bg_Jya_Ironobj_InitVars = { +ActorInit Bg_Jya_Ironobj_InitVars = { ACTOR_BG_JYA_IRONOBJ, ACTORCAT_PROP, FLAGS, @@ -91,22 +91,22 @@ static InitChainEntry sInitChain[] = { static CollisionHeader* sCollisionHeaders[] = { &gPillarCol, &gThroneCol }; -void BgJyaIronobj_InitCylinder(BgJyaIronobj* this, GlobalContext* globalCtx) { - ColliderCylinder* colCylinder = &this->colCylinder; +void BgJyaIronobj_InitCylinder(BgJyaIronobj* pthis, GlobalContext* globalCtx) { + ColliderCylinder* colCylinder = &pthis->colCylinder; Collider_InitCylinder(globalCtx, colCylinder); - Collider_SetCylinder(globalCtx, colCylinder, &this->dyna.actor, &sCylinderInit); - if ((this->dyna.actor.params & 1) == 1) { - this->colCylinder.dim.radius = 40; - this->colCylinder.dim.height = 100; + Collider_SetCylinder(globalCtx, colCylinder, &pthis->dyna.actor, &sCylinderInit); + if ((pthis->dyna.actor.params & 1) == 1) { + pthis->colCylinder.dim.radius = 40; + pthis->colCylinder.dim.height = 100; } - Collider_UpdateCylinder(&this->dyna.actor, colCylinder); + Collider_UpdateCylinder(&pthis->dyna.actor, colCylinder); } /* * Spawns particles for the destroyed pillar */ -void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* this, GlobalContext* globalCtx, EnIk* enIk) { +void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* pthis, GlobalContext* globalCtx, EnIk* enIk) { s32 i; s32 j; s16 unkArg5; @@ -123,22 +123,22 @@ void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* this, GlobalContext* global return; } osSyncPrintf("¢ attack_type(%d)\n", enIk->unk_2FF); - rotY = Actor_WorldYawTowardActor(&this->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1]; + rotY = Actor_WorldYawTowardActor(&pthis->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1]; for (i = 0; i < 8; i++) { Actor* actor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_JYA_HAHENIRON, this->dyna.actor.world.pos.x, - Rand_ZeroOne() * 80.0f + this->dyna.actor.world.pos.y + 20.0f, this->dyna.actor.world.pos.z, 0, + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_JYA_HAHENIRON, pthis->dyna.actor.world.pos.x, + Rand_ZeroOne() * 80.0f + pthis->dyna.actor.world.pos.y + 20.0f, pthis->dyna.actor.world.pos.z, 0, (s16)(Rand_ZeroOne() * 0x4000) + rotY - 0x2000, 0, 0); if (actor != NULL) { actor->speedXZ = Rand_ZeroOne() * 8.0f + 9.0f; actor->velocity.y = Rand_ZeroOne() * 10.0f + 6.0f; } } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_JYA_HAHENIRON, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + 150.0f, this->dyna.actor.world.pos.z, 0, 0, 0, 1); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_JYA_HAHENIRON, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, 2); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_JYA_HAHENIRON, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y + 150.0f, pthis->dyna.actor.world.pos.z, 0, 0, 0, 1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_JYA_HAHENIRON, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, 0, 0, 2); sins = Math_SinS(rotY); coss = Math_CosS(rotY); for (j = 0; j < 32; j++) { @@ -151,9 +151,9 @@ void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* this, GlobalContext* global } else { unkArg5 = 0x20; } - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + ((4.375f * j) + 10.0f); - pos.z = this->dyna.actor.world.pos.z; + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + ((4.375f * j) + 10.0f); + pos.z = pthis->dyna.actor.world.pos.z; temp_f22 = fabsf(j - 15.5f) * (1.0f / 31) + 0.5f; vel.x = 2.0f * ((Rand_ZeroOne() * 6.0f) - 3.0f) + (Rand_ZeroOne() * sins * 8.0f * temp_f22); vel.y = (Rand_ZeroOne() * 8.0f) - 3.0f; @@ -169,7 +169,7 @@ void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* this, GlobalContext* global /* * Spawns particles for the destroyed throne */ -void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* this, GlobalContext* arg1, EnIk* enIk) { +void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* pthis, GlobalContext* arg1, EnIk* enIk) { s32 i; s32 j; s16 unkArg5; @@ -186,11 +186,11 @@ void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* this, GlobalContext* arg1, E return; } osSyncPrintf("¢ attack_type(%d)\n", enIk->unk_2FF); - rotY = Actor_WorldYawTowardActor(&this->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1]; + rotY = Actor_WorldYawTowardActor(&pthis->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1]; for (i = 0; i < 8; i++) { Actor* actor = - Actor_Spawn(&arg1->actorCtx, arg1, ACTOR_BG_JYA_HAHENIRON, this->dyna.actor.world.pos.x, - (Rand_ZeroOne() * 80.0f) + this->dyna.actor.world.pos.y + 10.0f, this->dyna.actor.world.pos.z, + Actor_Spawn(&arg1->actorCtx, arg1, ACTOR_BG_JYA_HAHENIRON, pthis->dyna.actor.world.pos.x, + (Rand_ZeroOne() * 80.0f) + pthis->dyna.actor.world.pos.y + 10.0f, pthis->dyna.actor.world.pos.z, 0, ((s16)(s32)(Rand_ZeroOne() * 0x4000) + rotY) - 0x2000, 0, 0); if (actor != NULL) { actor->speedXZ = Rand_ZeroOne() * 8.0f + 9.0f; @@ -210,9 +210,9 @@ void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* this, GlobalContext* arg1, E } else { unkArg5 = 0x20; } - pos.x = this->dyna.actor.world.pos.x + (Rand_ZeroOne() * 40 - 20); - pos.y = this->dyna.actor.world.pos.y + (3.75f * j); - pos.z = this->dyna.actor.world.pos.z + (Rand_ZeroOne() * 40 - 20); + pos.x = pthis->dyna.actor.world.pos.x + (Rand_ZeroOne() * 40 - 20); + pos.y = pthis->dyna.actor.world.pos.y + (3.75f * j); + pos.z = pthis->dyna.actor.world.pos.z + (Rand_ZeroOne() * 40 - 20); temp_f22 = fabsf(j - 15.5f) * (1.0f / 31) + 0.5f; vel.x = 2.0f * (Rand_ZeroOne() * 6.0f - 3.0f) + (Rand_ZeroOne() * sins * 8.0f * temp_f22); vel.y = Rand_ZeroOne() * 8.0f - 3.0f; @@ -226,60 +226,60 @@ void BgJyaIronobj_SpawnThoneParticles(BgJyaIronobj* this, GlobalContext* arg1, E } void BgJyaIronobj_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaIronobj* this = (BgJyaIronobj*)thisx; + BgJyaIronobj* pthis = (BgJyaIronobj*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, 0); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BgJyaIronobj_InitCylinder(this, globalCtx); + DynaPolyActor_Init(&pthis->dyna, 0); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + BgJyaIronobj_InitCylinder(pthis, globalCtx); CollisionHeader_GetVirtual(sCollisionHeaders[thisx->params & 1], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - func_808992D8(this); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + func_808992D8(pthis); } void BgJyaIronobj_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaIronobj* this = (BgJyaIronobj*)thisx; + BgJyaIronobj* pthis = (BgJyaIronobj*)thisx; - Collider_DestroyCylinder(globalCtx, &this->colCylinder); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->colCylinder); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808992D8(BgJyaIronobj* this) { - this->actionFunc = func_808992E8; +void func_808992D8(BgJyaIronobj* pthis) { + pthis->actionFunc = func_808992E8; } -void func_808992E8(BgJyaIronobj* this, GlobalContext* globalCtx) { +void func_808992E8(BgJyaIronobj* pthis, GlobalContext* globalCtx) { static BgJyaIronobjIkFunc particleFunc[] = { BgJyaIronobj_SpawnPillarParticles, BgJyaIronobj_SpawnThoneParticles }; Actor* actor; Vec3f dropPos; s32 i; - if (this->colCylinder.base.acFlags & AC_HIT) { - actor = this->colCylinder.base.ac; - this->colCylinder.base.acFlags &= ~AC_HIT; + if (pthis->colCylinder.base.acFlags & AC_HIT) { + actor = pthis->colCylinder.base.ac; + pthis->colCylinder.base.acFlags &= ~AC_HIT; if (actor != NULL && actor->id == ACTOR_EN_IK) { - particleFunc[this->dyna.actor.params & 1](this, globalCtx, (EnIk*)actor); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 80, NA_SE_EN_IRONNACK_BREAK_PILLAR); - dropPos.x = this->dyna.actor.world.pos.x; - dropPos.y = this->dyna.actor.world.pos.y + 20.0f; - dropPos.z = this->dyna.actor.world.pos.z; + particleFunc[pthis->dyna.actor.params & 1](pthis, globalCtx, (EnIk*)actor); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 80, NA_SE_EN_IRONNACK_BREAK_PILLAR); + dropPos.x = pthis->dyna.actor.world.pos.x; + dropPos.y = pthis->dyna.actor.world.pos.y + 20.0f; + dropPos.z = pthis->dyna.actor.world.pos.z; for (i = 0; i < 3; i++) { Item_DropCollectible(globalCtx, &dropPos, ITEM00_HEART); dropPos.y += 18.0f; } - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder.base); } } void BgJyaIronobj_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaIronobj* this = (BgJyaIronobj*)thisx; + BgJyaIronobj* pthis = (BgJyaIronobj*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgJyaIronobj_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c deleted file mode 100644 index 659370a02..000000000 --- a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c +++ /dev/null @@ -1,137 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_JYA_KANAAMI_Z_BG_JYA_KANAAMI_C -#include "actor_common.h" -/* - * File: z_bg_jya_kanaami.c - * Overlay: ovl_Bg_Jya_Kanaami - * Description: Climbable grating/bridge (Spirit Temple) - */ - -#include "z_bg_jya_kanaami.h" -#include "objects/object_jya_obj/object_jya_obj.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_quake.h" - -#define FLAGS 0 - -void BgJyaKanaami_Init(Actor* thisx, GlobalContext* globalCtx); -void BgJyaKanaami_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgJyaKanaami_Update(Actor* thisx, GlobalContext* globalCtx); -void BgJyaKanaami_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80899880(BgJyaKanaami* this); -void func_80899894(BgJyaKanaami* this, GlobalContext* globalCtx); -void func_8089993C(BgJyaKanaami* this); -void func_80899950(BgJyaKanaami* this, GlobalContext* globalCtx); -void func_80899A08(BgJyaKanaami* this); - -const ActorInit Bg_Jya_Kanaami_InitVars = { - ACTOR_BG_JYA_KANAAMI, - ACTORCAT_BG, - FLAGS, - OBJECT_JYA_OBJ, - sizeof(BgJyaKanaami), - (ActorFunc)BgJyaKanaami_Init, - (ActorFunc)BgJyaKanaami_Destroy, - (ActorFunc)BgJyaKanaami_Update, - (ActorFunc)BgJyaKanaami_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 700, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void BgJyaKanaami_InitDynaPoly(BgJyaKanaami* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, flag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_kanaami.c", 145, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgJyaKanaami_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaKanaami* this = (BgJyaKanaami*)thisx; - - BgJyaKanaami_InitDynaPoly(this, globalCtx, &gKanaamiCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - func_80899A08(this); - } else { - func_80899880(this); - } - osSyncPrintf("(jya 金網)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void BgJyaKanaami_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaKanaami* this = (BgJyaKanaami*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80899880(BgJyaKanaami* this) { - this->actionFunc = func_80899894; - this->unk_16A = 0; -} - -void func_80899894(BgJyaKanaami* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) || this->unk_16A > 0) { - if (this->dyna.actor.world.pos.x > -1000.0f && this->unk_16A == 0) { - OnePointCutscene_Init(globalCtx, 3450, -99, &this->dyna.actor, MAIN_CAM); - } - this->unk_16A += 1; - if (this->unk_16A >= 0xA) { - func_8089993C(this); - } - } -} - -void func_8089993C(BgJyaKanaami* this) { - this->actionFunc = func_80899950; - this->unk_168 = 0; -} - -void func_80899950(BgJyaKanaami* this, GlobalContext* globalCtx) { - s32 pad[2]; - s32 quakeId; - - this->unk_168 += 0x20; - if (Math_ScaledStepToS(&this->dyna.actor.world.rot.x, 0x4000, this->unk_168)) { - func_80899A08(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_TRAP_BOUND); - quakeId = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quakeId, 25000); - Quake_SetQuakeValues(quakeId, 2, 0, 0, 0); - Quake_SetCountdown(quakeId, 16); - } -} - -void func_80899A08(BgJyaKanaami* this) { - this->actionFunc = 0; - this->dyna.actor.world.rot.x = 0x4000; -} - -void BgJyaKanaami_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaKanaami* this = (BgJyaKanaami*)thisx; - - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } - this->dyna.actor.shape.rot.x = this->dyna.actor.world.rot.x; -} - -void BgJyaKanaami_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gKanaamiDL); -} diff --git a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.cpp b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.cpp new file mode 100644 index 000000000..9293f4978 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.cpp @@ -0,0 +1,137 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_JYA_KANAAMI_Z_BG_JYA_KANAAMI_C +#include "actor_common.h" +/* + * File: z_bg_jya_kanaami.c + * Overlay: ovl_Bg_Jya_Kanaami + * Description: Climbable grating/bridge (Spirit Temple) + */ + +#include "z_bg_jya_kanaami.h" +#include "objects/object_jya_obj/object_jya_obj.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_quake.h" + +#define FLAGS 0 + +void BgJyaKanaami_Init(Actor* thisx, GlobalContext* globalCtx); +void BgJyaKanaami_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgJyaKanaami_Update(Actor* thisx, GlobalContext* globalCtx); +void BgJyaKanaami_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80899880(BgJyaKanaami* pthis); +void func_80899894(BgJyaKanaami* pthis, GlobalContext* globalCtx); +void func_8089993C(BgJyaKanaami* pthis); +void func_80899950(BgJyaKanaami* pthis, GlobalContext* globalCtx); +void func_80899A08(BgJyaKanaami* pthis); + +ActorInit Bg_Jya_Kanaami_InitVars = { + ACTOR_BG_JYA_KANAAMI, + ACTORCAT_BG, + FLAGS, + OBJECT_JYA_OBJ, + sizeof(BgJyaKanaami), + (ActorFunc)BgJyaKanaami_Init, + (ActorFunc)BgJyaKanaami_Destroy, + (ActorFunc)BgJyaKanaami_Update, + (ActorFunc)BgJyaKanaami_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 700, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void BgJyaKanaami_InitDynaPoly(BgJyaKanaami* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_kanaami.c", 145, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgJyaKanaami_Init(Actor* thisx, GlobalContext* globalCtx) { + BgJyaKanaami* pthis = (BgJyaKanaami*)thisx; + + BgJyaKanaami_InitDynaPoly(pthis, globalCtx, &gKanaamiCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + func_80899A08(pthis); + } else { + func_80899880(pthis); + } + osSyncPrintf("(jya 金網)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void BgJyaKanaami_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgJyaKanaami* pthis = (BgJyaKanaami*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80899880(BgJyaKanaami* pthis) { + pthis->actionFunc = func_80899894; + pthis->unk_16A = 0; +} + +void func_80899894(BgJyaKanaami* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F) || pthis->unk_16A > 0) { + if (pthis->dyna.actor.world.pos.x > -1000.0f && pthis->unk_16A == 0) { + OnePointCutscene_Init(globalCtx, 3450, -99, &pthis->dyna.actor, MAIN_CAM); + } + pthis->unk_16A += 1; + if (pthis->unk_16A >= 0xA) { + func_8089993C(pthis); + } + } +} + +void func_8089993C(BgJyaKanaami* pthis) { + pthis->actionFunc = func_80899950; + pthis->unk_168 = 0; +} + +void func_80899950(BgJyaKanaami* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s32 quakeId; + + pthis->unk_168 += 0x20; + if (Math_ScaledStepToS(&pthis->dyna.actor.world.rot.x, 0x4000, pthis->unk_168)) { + func_80899A08(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_TRAP_BOUND); + quakeId = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(quakeId, 25000); + Quake_SetQuakeValues(quakeId, 2, 0, 0, 0); + Quake_SetCountdown(quakeId, 16); + } +} + +void func_80899A08(BgJyaKanaami* pthis) { + pthis->actionFunc = 0; + pthis->dyna.actor.world.rot.x = 0x4000; +} + +void BgJyaKanaami_Update(Actor* thisx, GlobalContext* globalCtx) { + BgJyaKanaami* pthis = (BgJyaKanaami*)thisx; + + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } + pthis->dyna.actor.shape.rot.x = pthis->dyna.actor.world.rot.x; +} + +void BgJyaKanaami_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gKanaamiDL); +} diff --git a/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c b/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.cpp similarity index 52% rename from src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c rename to src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.cpp index bf6d1fa6b..b73209dab 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c +++ b/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.cpp @@ -23,15 +23,15 @@ void BgJyaLift_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaLift_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaLift_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgJyaLift_SetFinalPosY(BgJyaLift* this); -void BgJyaLift_SetInitPosY(BgJyaLift* this); -void BgJyaLift_DelayMove(BgJyaLift* this, GlobalContext* globalCtx); -void BgJyaLift_SetupMove(BgJyaLift* this); -void BgJyaLift_Move(BgJyaLift* this, GlobalContext* globalCtx); +void BgJyaLift_SetFinalPosY(BgJyaLift* pthis); +void BgJyaLift_SetInitPosY(BgJyaLift* pthis); +void BgJyaLift_DelayMove(BgJyaLift* pthis, GlobalContext* globalCtx); +void BgJyaLift_SetupMove(BgJyaLift* pthis); +void BgJyaLift_Move(BgJyaLift* pthis, GlobalContext* globalCtx); static s16 sIsSpawned = false; -const ActorInit Bg_Jya_Lift_InitVars = { +ActorInit Bg_Jya_Lift_InitVars = { ACTOR_BG_JYA_LIFT, ACTORCAT_BG, FLAGS, @@ -50,19 +50,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 2500, ICHAIN_STOP), }; -void BgJyaLift_InitDynapoly(BgJyaLift* this, GlobalContext* globalCtx, CollisionHeader* collisionHeader, s32 moveFlag) { +void BgJyaLift_InitDynapoly(BgJyaLift* pthis, GlobalContext* globalCtx, CollisionHeader* collisionHeader, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, moveFlag); + DynaPolyActor_Init(&pthis->dyna, moveFlag); CollisionHeader_GetVirtual(collisionHeader, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } void BgJyaLift_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaLift* this = (BgJyaLift*)thisx; + BgJyaLift* pthis = (BgJyaLift*)thisx; - this->isSpawned = false; + pthis->isSpawned = false; if (sIsSpawned) { Actor_Kill(thisx); return; @@ -70,87 +70,87 @@ void BgJyaLift_Init(Actor* thisx, GlobalContext* globalCtx) { // "Goddess lift CT" osSyncPrintf("女神リフト CT\n"); - BgJyaLift_InitDynapoly(this, globalCtx, &gLiftCol, DPM_UNK); + BgJyaLift_InitDynapoly(pthis, globalCtx, &gLiftCol, DPM_UNK); Actor_ProcessInitChain(thisx, sInitChain); if (Flags_GetSwitch(globalCtx, (thisx->params & 0x3F))) { - BgJyaLift_SetFinalPosY(this); + BgJyaLift_SetFinalPosY(pthis); } else { - BgJyaLift_SetInitPosY(this); + BgJyaLift_SetInitPosY(pthis); } thisx->room = -1; sIsSpawned = true; - this->isSpawned = true; + pthis->isSpawned = true; } void BgJyaLift_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaLift* this = (BgJyaLift*)thisx; + BgJyaLift* pthis = (BgJyaLift*)thisx; - if (this->isSpawned) { + if (pthis->isSpawned) { // "Goddess Lift DT" osSyncPrintf("女神リフト DT\n"); sIsSpawned = false; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } -void BgJyaLift_SetInitPosY(BgJyaLift* this) { - this->actionFunc = BgJyaLift_DelayMove; - this->dyna.actor.world.pos.y = 1613.0f; - this->moveDelay = 0; +void BgJyaLift_SetInitPosY(BgJyaLift* pthis) { + pthis->actionFunc = BgJyaLift_DelayMove; + pthis->dyna.actor.world.pos.y = 1613.0f; + pthis->moveDelay = 0; } -void BgJyaLift_DelayMove(BgJyaLift* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) || (this->moveDelay > 0)) { - this->moveDelay++; - if (this->moveDelay >= 20) { - OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM); - BgJyaLift_SetupMove(this); +void BgJyaLift_DelayMove(BgJyaLift* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F) || (pthis->moveDelay > 0)) { + pthis->moveDelay++; + if (pthis->moveDelay >= 20) { + OnePointCutscene_Init(globalCtx, 3430, -99, &pthis->dyna.actor, MAIN_CAM); + BgJyaLift_SetupMove(pthis); } } } -void BgJyaLift_SetupMove(BgJyaLift* this) { - this->actionFunc = BgJyaLift_Move; +void BgJyaLift_SetupMove(BgJyaLift* pthis) { + pthis->actionFunc = BgJyaLift_Move; } -void BgJyaLift_Move(BgJyaLift* this, GlobalContext* globalCtx) { +void BgJyaLift_Move(BgJyaLift* pthis, GlobalContext* globalCtx) { f32 distFromBottom; f32 tempVelocity; - Math_SmoothStepToF(&this->dyna.actor.velocity.y, 4.0f, 0.1f, 1.0f, 0.0f); - tempVelocity = (this->dyna.actor.velocity.y < 0.2f) ? 0.2f : this->dyna.actor.velocity.y; - distFromBottom = Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 973.0f, 0.1f, tempVelocity, 0.2f); - if ((this->dyna.actor.world.pos.y < 1440.0f) && (1440.0f <= this->dyna.actor.prevPos.y)) { + Math_SmoothStepToF(&pthis->dyna.actor.velocity.y, 4.0f, 0.1f, 1.0f, 0.0f); + tempVelocity = (pthis->dyna.actor.velocity.y < 0.2f) ? 0.2f : pthis->dyna.actor.velocity.y; + distFromBottom = Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, 973.0f, 0.1f, tempVelocity, 0.2f); + if ((pthis->dyna.actor.world.pos.y < 1440.0f) && (1440.0f <= pthis->dyna.actor.prevPos.y)) { func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); } if (fabsf(distFromBottom) < 0.001f) { - BgJyaLift_SetFinalPosY(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ELEVATOR_STOP); + BgJyaLift_SetFinalPosY(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_STOP); } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BRIDGE_OPEN - SFX_FLAG); } } -void BgJyaLift_SetFinalPosY(BgJyaLift* this) { - this->actionFunc = NULL; - this->dyna.actor.world.pos.y = 973.0f; +void BgJyaLift_SetFinalPosY(BgJyaLift* pthis) { + pthis->actionFunc = NULL; + pthis->dyna.actor.world.pos.y = 973.0f; } void BgJyaLift_Update(Actor* thisx, GlobalContext* globalCtx2) { - BgJyaLift* this = (BgJyaLift*)thisx; + BgJyaLift* pthis = (BgJyaLift*)thisx; GlobalContext* globalCtx = globalCtx2; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } - if ((this->dyna.unk_160 & 4) && ((this->unk_16B & 4) == 0)) { + if ((pthis->dyna.unk_160 & 4) && ((pthis->unk_16B & 4) == 0)) { Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DIRECTED_YAW); - } else if (((this->dyna.unk_160) & 4) == 0 && ((this->unk_16B & 4)) && + } else if (((pthis->dyna.unk_160) & 4) == 0 && ((pthis->unk_16B & 4)) && (globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_DIRECTED_YAW)) { Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); } - this->unk_16B = this->dyna.unk_160; + pthis->unk_16B = pthis->dyna.unk_160; // Spirit Temple room 5 is the main room with the statue room 25 is directly above room 5 if ((globalCtx->roomCtx.curRoom.num != 5) && (globalCtx->roomCtx.curRoom.num != 25)) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c b/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.cpp similarity index 62% rename from src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c rename to src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.cpp index ecdaab0fa..a192567f4 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c +++ b/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.cpp @@ -22,12 +22,12 @@ void BgJyaMegami_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaMegami_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaMegami_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgJyaMegami_SetupDetectLight(BgJyaMegami* this); -void BgJyaMegami_DetectLight(BgJyaMegami* this, GlobalContext* globalCtx); -void BgJyaMegami_SetupExplode(BgJyaMegami* this); -void BgJyaMegami_Explode(BgJyaMegami* this, GlobalContext* globalCtx); +void BgJyaMegami_SetupDetectLight(BgJyaMegami* pthis); +void BgJyaMegami_DetectLight(BgJyaMegami* pthis, GlobalContext* globalCtx); +void BgJyaMegami_SetupExplode(BgJyaMegami* pthis); +void BgJyaMegami_Explode(BgJyaMegami* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Jya_Megami_InitVars = { +ActorInit Bg_Jya_Megami_InitVars = { ACTOR_BG_JYA_MEGAMI, ACTORCAT_BG, FLAGS, @@ -117,20 +117,20 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), }; -void BgJyaMegami_InitDynaPoly(BgJyaMegami* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { +void BgJyaMegami_InitDynaPoly(BgJyaMegami* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, flag); + DynaPolyActor_Init(&pthis->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } -void BgJyaMegami_InitCollider(BgJyaMegami* this, GlobalContext* globalCtx) { +void BgJyaMegami_InitCollider(BgJyaMegami* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colliderItem); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, &pthis->colliderItem); } void BgJyaMegami_SpawnEffect(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, s32 num, s32 arg4) { @@ -150,13 +150,13 @@ void BgJyaMegami_SpawnEffect(GlobalContext* globalCtx, Vec3f* pos, Vec3f* veloci } } -void BgJyaMegami_SetupSpawnEffect(BgJyaMegami* this, GlobalContext* globalCtx, f32 arg2) { +void BgJyaMegami_SetupSpawnEffect(BgJyaMegami* pthis, GlobalContext* globalCtx, f32 arg2) { s32 i; Vec3f pos; - for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->pieces); i++) { if (Rand_ZeroOne() < arg2) { - Math_Vec3f_Sum(&this->dyna.actor.world.pos, &sPiecesInit[i].unk_00, &pos); + Math_Vec3f_Sum(&pthis->dyna.actor.world.pos, &sPiecesInit[i].unk_00, &pos); pos.z += 15.0f; BgJyaMegami_SpawnEffect(globalCtx, &pos, &sVelocity, 1, 0); } @@ -164,76 +164,76 @@ void BgJyaMegami_SetupSpawnEffect(BgJyaMegami* this, GlobalContext* globalCtx, f } void BgJyaMegami_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaMegami* this = (BgJyaMegami*)thisx; + BgJyaMegami* pthis = (BgJyaMegami*)thisx; - BgJyaMegami_InitDynaPoly(this, globalCtx, &GMegamiCol, DPM_UNK); - BgJyaMegami_InitCollider(this, globalCtx); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - Actor_Kill(&this->dyna.actor); + BgJyaMegami_InitDynaPoly(pthis, globalCtx, &GMegamiCol, DPM_UNK); + BgJyaMegami_InitCollider(pthis, globalCtx); + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + Actor_Kill(&pthis->dyna.actor); } else { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Actor_SetFocus(&this->dyna.actor, -50.0f); - BgJyaMegami_SetupDetectLight(this); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + Actor_SetFocus(&pthis->dyna.actor, -50.0f); + BgJyaMegami_SetupDetectLight(pthis); } } void BgJyaMegami_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaMegami* this = (BgJyaMegami*)thisx; + BgJyaMegami* pthis = (BgJyaMegami*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void BgJyaMegami_SetupDetectLight(BgJyaMegami* this) { - this->actionFunc = BgJyaMegami_DetectLight; - this->lightTimer = 0; - this->crumbleIndex = 0; +void BgJyaMegami_SetupDetectLight(BgJyaMegami* pthis) { + pthis->actionFunc = BgJyaMegami_DetectLight; + pthis->lightTimer = 0; + pthis->crumbleIndex = 0; } -void BgJyaMegami_DetectLight(BgJyaMegami* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->lightTimer++; - this->collider.base.acFlags &= ~AC_HIT; +void BgJyaMegami_DetectLight(BgJyaMegami* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->lightTimer++; + pthis->collider.base.acFlags &= ~AC_HIT; if (globalCtx->gameplayFrames % 4 == 0) { - BgJyaMegami_SetupSpawnEffect(this, globalCtx, (this->crumbleIndex * 0.04f) + 0.05f); + BgJyaMegami_SetupSpawnEffect(pthis, globalCtx, (pthis->crumbleIndex * 0.04f) + 0.05f); } - func_8002F974(&this->dyna.actor, NA_SE_EV_FACE_CRUMBLE_SLOW - SFX_FLAG); - } else if (this->lightTimer > 0) { - this->lightTimer--; + func_8002F974(&pthis->dyna.actor, NA_SE_EV_FACE_CRUMBLE_SLOW - SFX_FLAG); + } else if (pthis->lightTimer > 0) { + pthis->lightTimer--; } - if (this->lightTimer > 40) { - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - BgJyaMegami_SetupExplode(this); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 100, NA_SE_EV_FACE_EXPLOSION); - OnePointCutscene_Init(globalCtx, 3440, -99, &this->dyna.actor, MAIN_CAM); + if (pthis->lightTimer > 40) { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + BgJyaMegami_SetupExplode(pthis); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 100, NA_SE_EV_FACE_EXPLOSION); + OnePointCutscene_Init(globalCtx, 3440, -99, &pthis->dyna.actor, MAIN_CAM); } else { - if (this->lightTimer < 8) { - this->crumbleIndex = 0; - } else if (this->lightTimer < 16) { - this->crumbleIndex = 1; - } else if (this->lightTimer < 24) { - this->crumbleIndex = 2; - } else if (this->lightTimer < 32) { - this->crumbleIndex = 3; + if (pthis->lightTimer < 8) { + pthis->crumbleIndex = 0; + } else if (pthis->lightTimer < 16) { + pthis->crumbleIndex = 1; + } else if (pthis->lightTimer < 24) { + pthis->crumbleIndex = 2; + } else if (pthis->lightTimer < 32) { + pthis->crumbleIndex = 3; } else { - this->crumbleIndex = 4; + pthis->crumbleIndex = 4; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void BgJyaMegami_SetupExplode(BgJyaMegami* this) { +void BgJyaMegami_SetupExplode(BgJyaMegami* pthis) { u32 i; - this->actionFunc = BgJyaMegami_Explode; - for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { - Math_Vec3f_Copy(&this->pieces[i].pos, &this->dyna.actor.world.pos); - this->pieces[i].vel.x = sPiecesInit[i].velX; + pthis->actionFunc = BgJyaMegami_Explode; + for (i = 0; i < ARRAY_COUNT(pthis->pieces); i++) { + Math_Vec3f_Copy(&pthis->pieces[i].pos, &pthis->dyna.actor.world.pos); + pthis->pieces[i].vel.x = sPiecesInit[i].velX; } - this->explosionTimer = 0; + pthis->explosionTimer = 0; } -void BgJyaMegami_Explode(BgJyaMegami* this, GlobalContext* globalCtx) { +void BgJyaMegami_Explode(BgJyaMegami* pthis, GlobalContext* globalCtx) { static Vec3f sVec = { 0.0f, 0.0f, 0.0f }; BgJyaMegamiPiece* temp; u32 i; @@ -241,15 +241,15 @@ void BgJyaMegami_Explode(BgJyaMegami* this, GlobalContext* globalCtx) { BgJyaMegamiPieceInit* temp2; s32 pad; - this->explosionTimer++; - if (this->explosionTimer == 30) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 100, NA_SE_EV_FACE_BREAKDOWN); + pthis->explosionTimer++; + if (pthis->explosionTimer == 30) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 100, NA_SE_EV_FACE_BREAKDOWN); } - for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { - temp = &this->pieces[i]; + for (i = 0; i < ARRAY_COUNT(pthis->pieces); i++) { + temp = &pthis->pieces[i]; temp2 = &sPiecesInit[i]; - if (this->explosionTimer > temp2->delay) { + if (pthis->explosionTimer > temp2->delay) { temp->vel.y -= 0.6f; if (temp->vel.y < -18.0f) { temp->vel.y = -18.0f; @@ -264,38 +264,38 @@ void BgJyaMegami_Explode(BgJyaMegami* this, GlobalContext* globalCtx) { sp8C.z += 10.0f; BgJyaMegami_SpawnEffect(globalCtx, &sp8C, &temp->vel, 3, 2); } - } else if (this->explosionTimer == temp2->delay) { + } else if (pthis->explosionTimer == temp2->delay) { Math_Vec3f_Sum(&temp->pos, &temp2->unk_00, &sp8C); sp8C.z += 10.0f; BgJyaMegami_SpawnEffect(globalCtx, &sp8C, &temp->vel, 4, 2); } } - if ((this->explosionTimer % 4 == 0) && (this->explosionTimer > 30) && (this->explosionTimer < 80) && - (this->explosionTimer > 40)) { - sp8C.x = ((Rand_ZeroOne() - 0.5f) * 90.0f) + this->dyna.actor.world.pos.x; - sp8C.y = (this->dyna.actor.world.pos.y - (Rand_ZeroOne() * 80.0f)) - 20.0f; - sp8C.z = this->dyna.actor.world.pos.z - (Rand_ZeroOne() - 0.5f) * 50.0f; + if ((pthis->explosionTimer % 4 == 0) && (pthis->explosionTimer > 30) && (pthis->explosionTimer < 80) && + (pthis->explosionTimer > 40)) { + sp8C.x = ((Rand_ZeroOne() - 0.5f) * 90.0f) + pthis->dyna.actor.world.pos.x; + sp8C.y = (pthis->dyna.actor.world.pos.y - (Rand_ZeroOne() * 80.0f)) - 20.0f; + sp8C.z = pthis->dyna.actor.world.pos.z - (Rand_ZeroOne() - 0.5f) * 50.0f; BgJyaMegami_SpawnEffect(globalCtx, &sp8C, &sVec, 1, 0); } - if (this->explosionTimer < ARRAY_COUNT(this->pieces)) { - sp8C.x = this->dyna.actor.world.pos.x; - sp8C.y = this->dyna.actor.world.pos.y - 60.0f; - sp8C.z = this->dyna.actor.world.pos.z; + if (pthis->explosionTimer < ARRAY_COUNT(pthis->pieces)) { + sp8C.x = pthis->dyna.actor.world.pos.x; + sp8C.y = pthis->dyna.actor.world.pos.y - 60.0f; + sp8C.z = pthis->dyna.actor.world.pos.z; func_80033480(globalCtx, &sp8C, 100.0f, 1, 150, 100, 1); } - if (this->explosionTimer == 60) { + if (pthis->explosionTimer == 60) { func_80078884(NA_SE_SY_CORRECT_CHIME); } - if (this->explosionTimer >= 100) { - Actor_Kill(&this->dyna.actor); + if (pthis->explosionTimer >= 100) { + Actor_Kill(&pthis->dyna.actor); } } void BgJyaMegami_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaMegami* this = (BgJyaMegami*)thisx; + BgJyaMegami* pthis = (BgJyaMegami*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } static void* sRightSideCrumbles[] = { @@ -308,12 +308,12 @@ static void* sLeftSideCrumbles[] = { gMegamiLeftCrumble4Tex, gMegamiLeftCrumble5Tex, }; -void BgJyaMegami_DrawFace(BgJyaMegami* this, GlobalContext* globalCtx) { +void BgJyaMegami_DrawFace(BgJyaMegami* pthis, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_jya_megami.c", 706); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sRightSideCrumbles[this->crumbleIndex])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sLeftSideCrumbles[this->crumbleIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sRightSideCrumbles[pthis->crumbleIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sLeftSideCrumbles[pthis->crumbleIndex])); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_jya_megami.c", 716), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gMegami1DL); @@ -327,7 +327,7 @@ static Gfx* sDLists[] = { gMegamiPiece11DL, gMegamiPiece12DL, gMegamiPiece13DL, }; -void BgJyaMegami_DrawExplode(BgJyaMegami* this, GlobalContext* globalCtx) { +void BgJyaMegami_DrawExplode(BgJyaMegami* pthis, GlobalContext* globalCtx) { s32 pad; BgJyaMegamiPiece* piece; u32 i; @@ -336,8 +336,8 @@ void BgJyaMegami_DrawExplode(BgJyaMegami* this, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { - piece = &this->pieces[i]; + for (i = 0; i < ARRAY_COUNT(pthis->pieces); i++) { + piece = &pthis->pieces[i]; Matrix_Translate(piece->pos.x + sPiecesInit[i].unk_00.x, piece->pos.y + sPiecesInit[i].unk_00.y, piece->pos.z + sPiecesInit[i].unk_00.z, MTXMODE_NEW); Matrix_RotateY(piece->rotVelY * (M_PI / 0x8000), MTXMODE_APPLY); @@ -355,12 +355,12 @@ void BgJyaMegami_DrawExplode(BgJyaMegami* this, GlobalContext* globalCtx) { } void BgJyaMegami_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgJyaMegami* this = (BgJyaMegami*)thisx; + BgJyaMegami* pthis = (BgJyaMegami*)thisx; - Collider_UpdateSpheres(0, &this->collider); - if (this->actionFunc == BgJyaMegami_Explode) { - BgJyaMegami_DrawExplode(this, globalCtx); + Collider_UpdateSpheres(0, &pthis->collider); + if (pthis->actionFunc == BgJyaMegami_Explode) { + BgJyaMegami_DrawExplode(pthis, globalCtx); } else { - BgJyaMegami_DrawFace(this, globalCtx); + BgJyaMegami_DrawFace(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c b/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.cpp similarity index 56% rename from src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c rename to src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.cpp index 7b2cea7ec..9adeef4a2 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c +++ b/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.cpp @@ -22,15 +22,15 @@ void BgJyaZurerukabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaZurerukabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaZurerukabe_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8089B4C8(BgJyaZurerukabe* this, GlobalContext* globalCtx); -void func_8089B7B4(BgJyaZurerukabe* this); -void func_8089B7C4(BgJyaZurerukabe* this, GlobalContext* globalCtx); -void func_8089B80C(BgJyaZurerukabe* this); -void func_8089B870(BgJyaZurerukabe* this, GlobalContext* globalCtx); +void func_8089B4C8(BgJyaZurerukabe* pthis, GlobalContext* globalCtx); +void func_8089B7B4(BgJyaZurerukabe* pthis); +void func_8089B7C4(BgJyaZurerukabe* pthis, GlobalContext* globalCtx); +void func_8089B80C(BgJyaZurerukabe* pthis); +void func_8089B870(BgJyaZurerukabe* pthis, GlobalContext* globalCtx); static f32 D_8089B9C0[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; -const ActorInit Bg_Jya_Zurerukabe_InitVars = { +ActorInit Bg_Jya_Zurerukabe_InitVars = { ACTOR_BG_JYA_ZURERUKABE, ACTORCAT_BG, FLAGS, @@ -66,22 +66,22 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void BgJyaZurerukabe_InitDynaPoly(BgJyaZurerukabe* this, GlobalContext* globalCtx, CollisionHeader* collision, +void BgJyaZurerukabe_InitDynaPoly(BgJyaZurerukabe* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2; - DynaPolyActor_Init(&this->dyna, flag); + DynaPolyActor_Init(&pthis->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_zurerukabe.c", 194, - this->dyna.actor.id, this->dyna.actor.params); + pthis->dyna.actor.id, pthis->dyna.actor.params); } } -void func_8089B4C8(BgJyaZurerukabe* this, GlobalContext* globalCtx) { +void func_8089B4C8(BgJyaZurerukabe* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 == 0x200000) && (player->actor.wallPoly != NULL)) { @@ -101,13 +101,13 @@ void func_8089B4C8(BgJyaZurerukabe* this, GlobalContext* globalCtx) { case 3: case 5: if (fabsf(D_8089B9C0[D_8089BA30[i]]) > 1.0f) { - func_8002F6D4(globalCtx, &this->dyna.actor, 1.5f, this->dyna.actor.shape.rot.y, 0.0f, 0); + func_8002F6D4(globalCtx, &pthis->dyna.actor, 1.5f, pthis->dyna.actor.shape.rot.y, 0.0f, 0); } break; case 1: case 4: if (fabsf(D_8089B9C0[D_8089BA30[i]] - D_8089B9C0[D_8089BA30[i + 1]]) > 1.0f) { - func_8002F6D4(globalCtx, &this->dyna.actor, 1.5f, this->dyna.actor.shape.rot.y, 0.0f, 0); + func_8002F6D4(globalCtx, &pthis->dyna.actor, 1.5f, pthis->dyna.actor.shape.rot.y, 0.0f, 0); } break; } @@ -115,15 +115,15 @@ void func_8089B4C8(BgJyaZurerukabe* this, GlobalContext* globalCtx) { } void BgJyaZurerukabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgJyaZurerukabe* this = (BgJyaZurerukabe*)thisx; + BgJyaZurerukabe* pthis = (BgJyaZurerukabe*)thisx; s32 i; - BgJyaZurerukabe_InitDynaPoly(this, globalCtx, &gZurerukabeCol, DPM_UNK); + BgJyaZurerukabe_InitDynaPoly(pthis, globalCtx, &gZurerukabeCol, DPM_UNK); Actor_ProcessInitChain(thisx, sInitChain); for (i = 0; i < ARRAY_COUNT(D_8089B9F0); i++) { - if (fabsf(D_8089B9F0[i] - this->dyna.actor.home.pos.y) < 1.0f) { - this->unk_168 = i; + if (fabsf(D_8089B9F0[i] - pthis->dyna.actor.home.pos.y) < 1.0f) { + pthis->unk_168 = i; break; } } @@ -131,63 +131,63 @@ void BgJyaZurerukabe_Init(Actor* thisx, GlobalContext* globalCtx) { if (i == ARRAY_COUNT(D_8089B9F0)) { osSyncPrintf(VT_COL(RED, WHITE)); osSyncPrintf("home pos が変更されたみたい(%s %d)(arg_data 0x%04x)\n", "../z_bg_jya_zurerukabe.c", 299, - this->dyna.actor.params); + pthis->dyna.actor.params); osSyncPrintf(VT_RST); } - this->unk_16E = D_8089B9F8[this->unk_168]; - func_8089B7B4(this); - osSyncPrintf("(jya ずれる壁)(arg_data 0x%04x)\n", this->dyna.actor.params); + pthis->unk_16E = D_8089B9F8[pthis->unk_168]; + func_8089B7B4(pthis); + osSyncPrintf("(jya ずれる壁)(arg_data 0x%04x)\n", pthis->dyna.actor.params); } void BgJyaZurerukabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgJyaZurerukabe* this = (BgJyaZurerukabe*)thisx; + BgJyaZurerukabe* pthis = (BgJyaZurerukabe*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - D_8089B9C0[this->unk_168] = 0.0f; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + D_8089B9C0[pthis->unk_168] = 0.0f; } -void func_8089B7B4(BgJyaZurerukabe* this) { - this->actionFunc = func_8089B7C4; +void func_8089B7B4(BgJyaZurerukabe* pthis) { + pthis->actionFunc = func_8089B7C4; } -void func_8089B7C4(BgJyaZurerukabe* this, GlobalContext* globalCtx) { - if (this->unk_16A <= 0) { - func_8089B80C(this); +void func_8089B7C4(BgJyaZurerukabe* pthis, GlobalContext* globalCtx) { + if (pthis->unk_16A <= 0) { + func_8089B80C(pthis); } - D_8089B9C0[this->unk_168] = 0.0f; + D_8089B9C0[pthis->unk_168] = 0.0f; } -void func_8089B80C(BgJyaZurerukabe* this) { - this->actionFunc = func_8089B870; - this->unk_16A = D_8089BA00[this->unk_168]; - if (ABS(this->unk_16C) == 4) { - this->unk_16E = -this->unk_16E; +void func_8089B80C(BgJyaZurerukabe* pthis) { + pthis->actionFunc = func_8089B870; + pthis->unk_16A = D_8089BA00[pthis->unk_168]; + if (ABS(pthis->unk_16C) == 4) { + pthis->unk_16E = -pthis->unk_16E; } - this->unk_16C += this->unk_16E; + pthis->unk_16C += pthis->unk_16E; } -void func_8089B870(BgJyaZurerukabe* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + (this->unk_16C * 75), - D_8089BA08[this->unk_168])) { - func_8089B7B4(this); +void func_8089B870(BgJyaZurerukabe* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.x, pthis->dyna.actor.home.pos.x + (pthis->unk_16C * 75), + D_8089BA08[pthis->unk_168])) { + func_8089B7B4(pthis); } - D_8089B9C0[this->unk_168] = D_8089BA08[this->unk_168] * this->unk_16E; - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + D_8089B9C0[pthis->unk_168] = D_8089BA08[pthis->unk_168] * pthis->unk_16E; + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); } void BgJyaZurerukabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgJyaZurerukabe* this = (BgJyaZurerukabe*)thisx; + BgJyaZurerukabe* pthis = (BgJyaZurerukabe*)thisx; - if (this->unk_16A > 0) { - this->unk_16A--; + if (pthis->unk_16A > 0) { + pthis->unk_16A--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->unk_168 == 0) { - func_8089B4C8(this, globalCtx); + if (pthis->unk_168 == 0) { + func_8089B4C8(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c b/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.cpp similarity index 58% rename from src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c rename to src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.cpp index b7ebc2d84..1ae871f24 100644 --- a/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c +++ b/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.cpp @@ -21,7 +21,7 @@ void BgMenkuriEye_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMenkuriEye_Update(Actor* thisx, GlobalContext* globalCtx); void BgMenkuriEye_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Menkuri_Eye_InitVars = { +ActorInit Bg_Menkuri_Eye_InitVars = { ACTOR_BG_MENKURI_EYE, ACTORCAT_BG, FLAGS, @@ -67,79 +67,79 @@ static InitChainEntry sInitChain[] = { }; void BgMenkuriEye_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriEye* this = (BgMenkuriEye*)thisx; + BgMenkuriEye* pthis = (BgMenkuriEye*)thisx; ColliderJntSphElement* colliderList; - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; - this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - colliderList = this->collider.elements; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + pthis->collider.elements[0].dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->collider.elements[0].dim.worldSphere.center.y = pthis->actor.world.pos.y; + pthis->collider.elements[0].dim.worldSphere.center.z = pthis->actor.world.pos.z; + colliderList = pthis->collider.elements; colliderList->dim.worldSphere.radius = colliderList->dim.modelSphere.radius; - if (!Flags_GetSwitch(globalCtx, this->actor.params)) { + if (!Flags_GetSwitch(globalCtx, pthis->actor.params)) { D_8089C1A0 = 0; } - this->framesUntilDisable = -1; + pthis->framesUntilDisable = -1; } void BgMenkuriEye_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriEye* this = (BgMenkuriEye*)thisx; + BgMenkuriEye* pthis = (BgMenkuriEye*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } void BgMenkuriEye_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriEye* this = (BgMenkuriEye*)thisx; + BgMenkuriEye* pthis = (BgMenkuriEye*)thisx; - if (!Flags_GetSwitch(globalCtx, this->actor.params)) { - if (this->framesUntilDisable != -1) { - if (this->framesUntilDisable != 0) { - this->framesUntilDisable -= 1; + if (!Flags_GetSwitch(globalCtx, pthis->actor.params)) { + if (pthis->framesUntilDisable != -1) { + if (pthis->framesUntilDisable != 0) { + pthis->framesUntilDisable -= 1; } - if (this->framesUntilDisable == 0) { - this->framesUntilDisable = -1; + if (pthis->framesUntilDisable == 0) { + pthis->framesUntilDisable = -1; D_8089C1A0 -= 1; } } } - if ((this->collider.base.acFlags & AC_HIT) && - (ABS((s16)(this->collider.base.ac->world.rot.y - this->actor.shape.rot.y)) > 0x5000)) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->framesUntilDisable == -1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AMOS_DAMAGE); + if ((pthis->collider.base.acFlags & AC_HIT) && + (ABS((s16)(pthis->collider.base.ac->world.rot.y - pthis->actor.shape.rot.y)) > 0x5000)) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (pthis->framesUntilDisable == -1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_AMOS_DAMAGE); D_8089C1A0 += 1; D_8089C1A0 = CLAMP_MAX(D_8089C1A0, 4); } - this->framesUntilDisable = 416; + pthis->framesUntilDisable = 416; if (D_8089C1A0 == 4) { - Flags_SetSwitch(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, pthis->actor.params); func_80078884(NA_SE_SY_CORRECT_CHIME); } } - if (this->framesUntilDisable == -1) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (pthis->framesUntilDisable == -1) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - Actor_SetFocus(&this->actor, 0.0f); + Actor_SetFocus(&pthis->actor, 0.0f); } void BgMenkuriEye_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriEye* this = (BgMenkuriEye*)thisx; + BgMenkuriEye* pthis = (BgMenkuriEye*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_menkuri_eye.c", 292); func_80093D84(globalCtx->state.gfxCtx); - if (Flags_GetSwitch(globalCtx, this->actor.params)) { + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { gDPSetEnvColor(POLY_XLU_DISP++, 200, 0, 0, 255); - } else if (this->framesUntilDisable == -1) { + } else if (pthis->framesUntilDisable == -1) { gDPSetEnvColor(POLY_XLU_DISP++, 200, 0, 0, 0); } else { gDPSetEnvColor(POLY_XLU_DISP++, 200, 0, 0, 255); } - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, pthis->actor.world.rot.z, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_menkuri_eye.c", 331), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Menkuri_Kaiten/z_bg_menkuri_kaiten.c b/src/overlays/actors/ovl_Bg_Menkuri_Kaiten/z_bg_menkuri_kaiten.cpp similarity index 69% rename from src/overlays/actors/ovl_Bg_Menkuri_Kaiten/z_bg_menkuri_kaiten.c rename to src/overlays/actors/ovl_Bg_Menkuri_Kaiten/z_bg_menkuri_kaiten.cpp index 143dfa81d..ae2e44676 100644 --- a/src/overlays/actors/ovl_Bg_Menkuri_Kaiten/z_bg_menkuri_kaiten.c +++ b/src/overlays/actors/ovl_Bg_Menkuri_Kaiten/z_bg_menkuri_kaiten.cpp @@ -21,7 +21,7 @@ void BgMenkuriKaiten_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMenkuriKaiten_Update(Actor* thisx, GlobalContext* globalCtx); void BgMenkuriKaiten_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Menkuri_Kaiten_InitVars = { +ActorInit Bg_Menkuri_Kaiten_InitVars = { ACTOR_BG_MENKURI_KAITEN, ACTORCAT_BG, FLAGS, @@ -38,28 +38,28 @@ static InitChainEntry sInitChain[] = { }; void BgMenkuriKaiten_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriKaiten* this = (BgMenkuriKaiten*)thisx; + BgMenkuriKaiten* pthis = (BgMenkuriKaiten*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK3); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK3); CollisionHeader_GetVirtual(&gGTGRotatingRingPlatformCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } void BgMenkuriKaiten_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriKaiten* this = (BgMenkuriKaiten*)thisx; + BgMenkuriKaiten* pthis = (BgMenkuriKaiten*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgMenkuriKaiten_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriKaiten* this = (BgMenkuriKaiten*)thisx; + BgMenkuriKaiten* pthis = (BgMenkuriKaiten*)thisx; - if (!Flags_GetSwitch(globalCtx, this->dyna.actor.params) && func_80043590(&this->dyna)) { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); - this->dyna.actor.shape.rot.y += 0x80; + if (!Flags_GetSwitch(globalCtx, pthis->dyna.actor.params) && func_80043590(&pthis->dyna)) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + pthis->dyna.actor.shape.rot.y += 0x80; } } diff --git a/src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/z_bg_menkuri_nisekabe.c b/src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/z_bg_menkuri_nisekabe.cpp similarity index 77% rename from src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/z_bg_menkuri_nisekabe.c rename to src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/z_bg_menkuri_nisekabe.cpp index b461c6982..ba8328cdc 100644 --- a/src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/z_bg_menkuri_nisekabe.c +++ b/src/overlays/actors/ovl_Bg_Menkuri_Nisekabe/z_bg_menkuri_nisekabe.cpp @@ -18,7 +18,7 @@ void BgMenkuriNisekabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMenkuriNisekabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgMenkuriNisekabe_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Menkuri_Nisekabe_InitVars = { +ActorInit Bg_Menkuri_Nisekabe_InitVars = { ACTOR_BG_MENKURI_NISEKABE, ACTORCAT_PROP, FLAGS, @@ -33,29 +33,29 @@ const ActorInit Bg_Menkuri_Nisekabe_InitVars = { static Gfx* sDLists[] = { gGTGFakeWallDL, gGTGFakeCeilingDL }; void BgMenkuriNisekabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriNisekabe* this = (BgMenkuriNisekabe*)thisx; + BgMenkuriNisekabe* pthis = (BgMenkuriNisekabe*)thisx; - Actor_SetScale(&this->actor, 0.1f); + Actor_SetScale(&pthis->actor, 0.1f); } void BgMenkuriNisekabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void BgMenkuriNisekabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriNisekabe* this = (BgMenkuriNisekabe*)thisx; + BgMenkuriNisekabe* pthis = (BgMenkuriNisekabe*)thisx; if (globalCtx->actorCtx.unk_03 != 0) { - this->actor.flags |= ACTOR_FLAG_7; + pthis->actor.flags |= ACTOR_FLAG_7; } else { - this->actor.flags &= ~ACTOR_FLAG_7; + pthis->actor.flags &= ~ACTOR_FLAG_7; } } void BgMenkuriNisekabe_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgMenkuriNisekabe* this = (BgMenkuriNisekabe*)thisx; - u32 index = this->actor.params & 0xFF; + BgMenkuriNisekabe* pthis = (BgMenkuriNisekabe*)thisx; + u32 index = pthis->actor.params & 0xFF; - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { Gfx_DrawDListXlu(globalCtx, sDLists[index]); } else { Gfx_DrawDListOpa(globalCtx, sDLists[index]); diff --git a/src/overlays/actors/ovl_Bg_Mizu_Bwall/z_bg_mizu_bwall.c b/src/overlays/actors/ovl_Bg_Mizu_Bwall/z_bg_mizu_bwall.cpp similarity index 62% rename from src/overlays/actors/ovl_Bg_Mizu_Bwall/z_bg_mizu_bwall.c rename to src/overlays/actors/ovl_Bg_Mizu_Bwall/z_bg_mizu_bwall.cpp index 18e67856e..c032c4f02 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Bwall/z_bg_mizu_bwall.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Bwall/z_bg_mizu_bwall.cpp @@ -26,11 +26,11 @@ void BgMizuBwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMizuBwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgMizuBwall_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgMizuBwall_Idle(BgMizuBwall* this, GlobalContext* globalCtx); -void BgMizuBwall_Break(BgMizuBwall* this, GlobalContext* globalCtx); -void BgMizuBwall_DoNothing(BgMizuBwall* this, GlobalContext* globalCtx); +void BgMizuBwall_Idle(BgMizuBwall* pthis, GlobalContext* globalCtx); +void BgMizuBwall_Break(BgMizuBwall* pthis, GlobalContext* globalCtx); +void BgMizuBwall_DoNothing(BgMizuBwall* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Mizu_Bwall_InitVars = { +ActorInit Bg_Mizu_Bwall_InitVars = { ACTOR_BG_MIZU_BWALL, ACTORCAT_BG, FLAGS, @@ -182,31 +182,31 @@ void BgMizuBwall_RotateVec3f(Vec3f* out, Vec3f* in, f32 sin, f32 cos) { void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMizuBwall* this = (BgMizuBwall*)thisx; + BgMizuBwall* pthis = (BgMizuBwall*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, D_8089D854); - this->yRot = this->dyna.actor.world.pos.y; - this->dList = sDLists[(u16)this->dyna.actor.params & 0xF]; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(sColHeaders[(u16)this->dyna.actor.params & 0xF], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Actor_ProcessInitChain(&pthis->dyna.actor, D_8089D854); + pthis->yRot = pthis->dyna.actor.world.pos.y; + pthis->dList = sDLists[(u16)pthis->dyna.actor.params & 0xF]; + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(sColHeaders[(u16)pthis->dyna.actor.params & 0xF], &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - switch ((u16)this->dyna.actor.params & 0xF) { + switch ((u16)pthis->dyna.actor.params & 0xF) { case MIZUBWALL_FLOOR: - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dList = NULL; - this->actionFunc = BgMizuBwall_DoNothing; + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dList = NULL; + pthis->actionFunc = BgMizuBwall_DoNothing; } else { - Collider_InitTris(globalCtx, &this->collider); - if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInitFloor, this->elements)) { + Collider_InitTris(globalCtx, &pthis->collider); + if (!Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInitFloor, pthis->elements)) { osSyncPrintf("Error : コリジョンデータセット失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mizu_bwall.c", - 484, this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); + 484, pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); } else { - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); s32 i; s32 j; Vec3f offset; @@ -218,31 +218,31 @@ void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { offset.y = sTrisInitFloor.elements[i].dim.vtx[j].y; offset.z = sTrisInitFloor.elements[i].dim.vtx[j].z + 2.0f; BgMizuBwall_RotateVec3f(&vtx[j], &offset, sin, cos); - vtx[j].x += this->dyna.actor.world.pos.x; - vtx[j].y += this->dyna.actor.world.pos.y; - vtx[j].z += this->dyna.actor.world.pos.z; + vtx[j].x += pthis->dyna.actor.world.pos.x; + vtx[j].y += pthis->dyna.actor.world.pos.y; + vtx[j].z += pthis->dyna.actor.world.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &vtx[0], &vtx[1], &vtx[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vtx[0], &vtx[1], &vtx[2]); } - this->actionFunc = BgMizuBwall_Idle; + pthis->actionFunc = BgMizuBwall_Idle; } } break; case MIZUBWALL_RUTO_ROOM: - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dList = NULL; - this->actionFunc = BgMizuBwall_DoNothing; + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dList = NULL; + pthis->actionFunc = BgMizuBwall_DoNothing; } else { - Collider_InitTris(globalCtx, &this->collider); - if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInitRutoWall, - this->elements)) { + Collider_InitTris(globalCtx, &pthis->collider); + if (!Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInitRutoWall, + pthis->elements)) { osSyncPrintf("Error : コリジョンデータセット失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mizu_bwall.c", - 558, this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); + 558, pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); } else { - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); s32 i; s32 j; Vec3f offset; @@ -254,31 +254,31 @@ void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { offset.y = sTrisInitRutoWall.elements[i].dim.vtx[j].y; offset.z = sTrisInitRutoWall.elements[i].dim.vtx[j].z + 2.0f; BgMizuBwall_RotateVec3f(&vtx[j], &offset, sin, cos); - vtx[j].x += this->dyna.actor.world.pos.x; - vtx[j].y += this->dyna.actor.world.pos.y; - vtx[j].z += this->dyna.actor.world.pos.z; + vtx[j].x += pthis->dyna.actor.world.pos.x; + vtx[j].y += pthis->dyna.actor.world.pos.y; + vtx[j].z += pthis->dyna.actor.world.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &vtx[0], &vtx[1], &vtx[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vtx[0], &vtx[1], &vtx[2]); } - this->actionFunc = BgMizuBwall_Idle; + pthis->actionFunc = BgMizuBwall_Idle; } } break; case MIZUBWALL_UNUSED: - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dList = NULL; - this->actionFunc = BgMizuBwall_DoNothing; + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dList = NULL; + pthis->actionFunc = BgMizuBwall_DoNothing; } else { - Collider_InitTris(globalCtx, &this->collider); - if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInitUnusedWall, - this->elements)) { + Collider_InitTris(globalCtx, &pthis->collider); + if (!Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInitUnusedWall, + pthis->elements)) { osSyncPrintf("Error : コリジョンデータセット失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mizu_bwall.c", - 638, this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); + 638, pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); } else { - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); s32 i; s32 j; Vec3f offset; @@ -292,31 +292,31 @@ void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { offset.y = sTrisInitFloor.elements[i].dim.vtx[j].y; offset.z = sTrisInitFloor.elements[i].dim.vtx[j].z; BgMizuBwall_RotateVec3f(&vtx[j], &offset, sin, cos); - vtx[j].x += this->dyna.actor.world.pos.x; - vtx[j].y += this->dyna.actor.world.pos.y; - vtx[j].z += this->dyna.actor.world.pos.z; + vtx[j].x += pthis->dyna.actor.world.pos.x; + vtx[j].y += pthis->dyna.actor.world.pos.y; + vtx[j].z += pthis->dyna.actor.world.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &vtx[0], &vtx[1], &vtx[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vtx[0], &vtx[1], &vtx[2]); } - this->actionFunc = BgMizuBwall_Idle; + pthis->actionFunc = BgMizuBwall_Idle; } } break; case MIZUBWALL_STINGER_ROOM_1: - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dList = NULL; - this->actionFunc = BgMizuBwall_DoNothing; + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dList = NULL; + pthis->actionFunc = BgMizuBwall_DoNothing; } else { - Collider_InitTris(globalCtx, &this->collider); - if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInitStingerWall, - this->elements)) { + Collider_InitTris(globalCtx, &pthis->collider); + if (!Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInitStingerWall, + pthis->elements)) { osSyncPrintf("Error : コリジョンデータセット失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mizu_bwall.c", - 724, this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); + 724, pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); } else { - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); s32 i; s32 j; Vec3f offset; @@ -330,31 +330,31 @@ void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { offset.y = sTrisInitFloor.elements[i].dim.vtx[j].y; offset.z = sTrisInitFloor.elements[i].dim.vtx[j].z + 2.0f; BgMizuBwall_RotateVec3f(&vtx[j], &offset, sin, cos); - vtx[j].x += this->dyna.actor.world.pos.x; - vtx[j].y += this->dyna.actor.world.pos.y; - vtx[j].z += this->dyna.actor.world.pos.z; + vtx[j].x += pthis->dyna.actor.world.pos.x; + vtx[j].y += pthis->dyna.actor.world.pos.y; + vtx[j].z += pthis->dyna.actor.world.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &vtx[0], &vtx[1], &vtx[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vtx[0], &vtx[1], &vtx[2]); } - this->actionFunc = BgMizuBwall_Idle; + pthis->actionFunc = BgMizuBwall_Idle; } } break; case MIZUBWALL_STINGER_ROOM_2: - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dList = NULL; - this->actionFunc = BgMizuBwall_DoNothing; + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 8) & 0x3F)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dList = NULL; + pthis->actionFunc = BgMizuBwall_DoNothing; } else { - Collider_InitTris(globalCtx, &this->collider); - if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInitStingerWall, - this->elements)) { + Collider_InitTris(globalCtx, &pthis->collider); + if (!Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInitStingerWall, + pthis->elements)) { osSyncPrintf("Error : コリジョンデータセット失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mizu_bwall.c", - 798, this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); + 798, pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); } else { - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); s32 i; s32 j; Vec3f offset; @@ -368,13 +368,13 @@ void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { offset.y = sTrisInitFloor.elements[i].dim.vtx[j].y; offset.z = sTrisInitFloor.elements[i].dim.vtx[j].z + 2.0f; BgMizuBwall_RotateVec3f(&vtx[j], &offset, sin, cos); - vtx[j].x += this->dyna.actor.world.pos.x; - vtx[j].y += this->dyna.actor.world.pos.y; - vtx[j].z += this->dyna.actor.world.pos.z; + vtx[j].x += pthis->dyna.actor.world.pos.x; + vtx[j].y += pthis->dyna.actor.world.pos.y; + vtx[j].z += pthis->dyna.actor.world.pos.z; } - Collider_SetTrisVertices(&this->collider, i, &vtx[0], &vtx[1], &vtx[2]); + Collider_SetTrisVertices(&pthis->collider, i, &vtx[0], &vtx[1], &vtx[2]); } - this->actionFunc = BgMizuBwall_Idle; + pthis->actionFunc = BgMizuBwall_Idle; } } break; @@ -383,62 +383,62 @@ void BgMizuBwall_Init(Actor* thisx, GlobalContext* globalCtx) { void BgMizuBwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMizuBwall* this = (BgMizuBwall*)thisx; + BgMizuBwall* pthis = (BgMizuBwall*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyTris(globalCtx, &pthis->collider); } -void BgMizuBwall_SetAlpha(BgMizuBwall* this, GlobalContext* globalCtx) { +void BgMizuBwall_SetAlpha(BgMizuBwall* pthis, GlobalContext* globalCtx) { f32 waterLevel = globalCtx->colCtx.colHeader->waterBoxes[2].ySurface; if (globalCtx->colCtx.colHeader->waterBoxes) {} if (waterLevel < WATER_TEMPLE_WATER_F1_Y) { - this->scrollAlpha1 = 255; + pthis->scrollAlpha1 = 255; } else if (waterLevel < WATER_TEMPLE_WATER_F2_Y) { - this->scrollAlpha1 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F1_Y) / + pthis->scrollAlpha1 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F1_Y) / (WATER_TEMPLE_WATER_F2_Y - WATER_TEMPLE_WATER_F1_Y) * (255 - 160)); } else { - this->scrollAlpha1 = 160; + pthis->scrollAlpha1 = 160; } if (waterLevel < WATER_TEMPLE_WATER_F2_Y) { - this->scrollAlpha2 = 255; + pthis->scrollAlpha2 = 255; } else if (waterLevel < WATER_TEMPLE_WATER_F3_Y) { - this->scrollAlpha2 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F2_Y) / + pthis->scrollAlpha2 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F2_Y) / (WATER_TEMPLE_WATER_F3_Y - WATER_TEMPLE_WATER_F2_Y) * (255 - 160)); } else { - this->scrollAlpha2 = 160; + pthis->scrollAlpha2 = 160; } if (waterLevel < WATER_TEMPLE_WATER_B1_Y) { - this->scrollAlpha3 = 255; + pthis->scrollAlpha3 = 255; } else if (waterLevel < WATER_TEMPLE_WATER_F1_Y) { - this->scrollAlpha3 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_B1_Y) / + pthis->scrollAlpha3 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_B1_Y) / (WATER_TEMPLE_WATER_F1_Y - WATER_TEMPLE_WATER_B1_Y) * (255 - 160)); } else { - this->scrollAlpha3 = 160; + pthis->scrollAlpha3 = 160; } - this->scrollAlpha4 = this->scrollAlpha3; + pthis->scrollAlpha4 = pthis->scrollAlpha3; } -void BgMizuBwall_SpawnDebris(BgMizuBwall* this, GlobalContext* globalCtx) { +void BgMizuBwall_SpawnDebris(BgMizuBwall* pthis, GlobalContext* globalCtx) { s32 i; s32 pad; s16 rand1; s16 rand2; - Vec3f* thisPos = &this->dyna.actor.world.pos; + Vec3f* thisPos = &pthis->dyna.actor.world.pos; Vec3f debrisPos; f32 tempx; f32 tempz; - f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); - f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); + f32 sin = Math_SinS(pthis->dyna.actor.shape.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.shape.rot.y); Vec3f debrisOffsets[15]; for (i = 0; i < ARRAY_COUNT(debrisOffsets); i++) { - switch ((u16)this->dyna.actor.params & 0xF) { + switch ((u16)pthis->dyna.actor.params & 0xF) { case MIZUBWALL_FLOOR: debrisOffsets[i].x = (Rand_ZeroOne() * 80.0f) - 40.0f; debrisOffsets[i].y = Rand_ZeroOne() * 0; @@ -475,43 +475,43 @@ void BgMizuBwall_SpawnDebris(BgMizuBwall* this, GlobalContext* globalCtx) { } } -void BgMizuBwall_Idle(BgMizuBwall* this, GlobalContext* globalCtx) { - BgMizuBwall_SetAlpha(this, globalCtx); - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Flags_SetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 8) & 0x3F); - this->breakTimer = 1; - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dList = NULL; - BgMizuBwall_SpawnDebris(this, globalCtx); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); +void BgMizuBwall_Idle(BgMizuBwall* pthis, GlobalContext* globalCtx) { + BgMizuBwall_SetAlpha(pthis, globalCtx); + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Flags_SetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 8) & 0x3F); + pthis->breakTimer = 1; + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dList = NULL; + BgMizuBwall_SpawnDebris(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WALL_BROKEN); Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->actionFunc = BgMizuBwall_Break; - } else if (this->dyna.actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->actionFunc = BgMizuBwall_Break; + } else if (pthis->dyna.actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void BgMizuBwall_Break(BgMizuBwall* this, GlobalContext* globalCtx) { - if (this->breakTimer > 0) { - this->breakTimer--; +void BgMizuBwall_Break(BgMizuBwall* pthis, GlobalContext* globalCtx) { + if (pthis->breakTimer > 0) { + pthis->breakTimer--; } else { - this->actionFunc = BgMizuBwall_DoNothing; + pthis->actionFunc = BgMizuBwall_DoNothing; } } -void BgMizuBwall_DoNothing(BgMizuBwall* this, GlobalContext* globalCtx) { +void BgMizuBwall_DoNothing(BgMizuBwall* pthis, GlobalContext* globalCtx) { } void BgMizuBwall_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMizuBwall* this = (BgMizuBwall*)thisx; + BgMizuBwall* pthis = (BgMizuBwall*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgMizuBwall_Draw(Actor* thisx, GlobalContext* globalCtx2) { - BgMizuBwall* this = (BgMizuBwall*)thisx; + BgMizuBwall* pthis = (BgMizuBwall*)thisx; GlobalContext* globalCtx = globalCtx2; u32 frames; @@ -522,20 +522,20 @@ void BgMizuBwall_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_80093D18(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, 1 * frames, 0, 0x20, 0x20, 1, 0, 0, 0x20, 0x20, 0, - 0, 0, this->scrollAlpha1)); + 0, 0, pthis->scrollAlpha1)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, 1 * frames, 0, 0x20, 0x20, 1, 0, 0, 0x20, 0x20, 0, - 0, 0, this->scrollAlpha2)); + 0, 0, pthis->scrollAlpha2)); gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, 1 * frames, 0, 0x20, 0x20, 1, 0, 0, 0x20, 0x20, 0, - 0, 0, this->scrollAlpha3)); + 0, 0, pthis->scrollAlpha3)); gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, 3 * frames, 0, 0x20, 0x20, 1, 0, 0, 0x20, 0x20, 0, - 0, 0, this->scrollAlpha4)); + 0, 0, pthis->scrollAlpha4)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mizu_bwall.c", 1129), 2); - if (this->dList != NULL) { - gSPDisplayList(POLY_OPA_DISP++, this->dList); + if (pthis->dList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, pthis->dList); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_bwall.c", 1136); } diff --git a/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c b/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.cpp similarity index 68% rename from src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c rename to src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.cpp index cc9099a54..9beadb0bd 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.cpp @@ -29,11 +29,11 @@ void BgMizuMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMizuMovebg_Update(Actor* thisx, GlobalContext* globalCtx); void BgMizuMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8089E318(BgMizuMovebg* this, GlobalContext* globalCtx); -void func_8089E650(BgMizuMovebg* this, GlobalContext* globalCtx); +void func_8089E318(BgMizuMovebg* pthis, GlobalContext* globalCtx); +void func_8089E650(BgMizuMovebg* pthis, GlobalContext* globalCtx); s32 func_8089E108(Path* pathList, Vec3f* pos, s32 pathId, s32 pointId); -const ActorInit Bg_Mizu_Movebg_InitVars = { +ActorInit Bg_Mizu_Movebg_InitVars = { ACTOR_BG_MIZU_MOVEBG, ACTORCAT_BG, FLAGS, @@ -176,20 +176,20 @@ void BgMizuMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { } void BgMizuMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMizuMovebg* this = (BgMizuMovebg*)thisx; + BgMizuMovebg* pthis = (BgMizuMovebg*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); switch (MOVEBG_TYPE(thisx->params)) { case 3: case 4: case 5: case 6: - if (this->sfxFlags & 2) { + if (pthis->sfxFlags & 2) { D_8089EE40 &= ~2; } break; case 7: - if (this->sfxFlags & 1) { + if (pthis->sfxFlags & 1) { D_8089EE40 &= ~1; } break; @@ -210,78 +210,78 @@ s32 func_8089E108(Path* pathList, Vec3f* pos, s32 pathId, s32 pointId) { return 0; } -void func_8089E198(BgMizuMovebg* this, GlobalContext* globalCtx) { +void func_8089E198(BgMizuMovebg* pthis, GlobalContext* globalCtx) { f32 waterLevel = globalCtx->colCtx.colHeader->waterBoxes[2].ySurface; if (waterLevel < WATER_TEMPLE_WATER_F1_Y) { - this->scrollAlpha1 = 255; + pthis->scrollAlpha1 = 255; } else if (waterLevel < WATER_TEMPLE_WATER_F2_Y) { - this->scrollAlpha1 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F1_Y) / + pthis->scrollAlpha1 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F1_Y) / (WATER_TEMPLE_WATER_F2_Y - WATER_TEMPLE_WATER_F1_Y) * (255 - 160)); } else { - this->scrollAlpha1 = 160; + pthis->scrollAlpha1 = 160; } if (waterLevel < WATER_TEMPLE_WATER_F2_Y) { - this->scrollAlpha2 = 255; + pthis->scrollAlpha2 = 255; } else if (waterLevel < WATER_TEMPLE_WATER_F3_Y) { - this->scrollAlpha2 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F2_Y) / + pthis->scrollAlpha2 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_F2_Y) / (WATER_TEMPLE_WATER_F3_Y - WATER_TEMPLE_WATER_F2_Y) * (255 - 160)); } else { - this->scrollAlpha2 = 160; + pthis->scrollAlpha2 = 160; } if (waterLevel < WATER_TEMPLE_WATER_B1_Y) { - this->scrollAlpha3 = 255; + pthis->scrollAlpha3 = 255; } else if (waterLevel < WATER_TEMPLE_WATER_F1_Y) { - this->scrollAlpha3 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_B1_Y) / + pthis->scrollAlpha3 = 255 - (s32)((waterLevel - WATER_TEMPLE_WATER_B1_Y) / (WATER_TEMPLE_WATER_F1_Y - WATER_TEMPLE_WATER_B1_Y) * (255 - 160)); } else { - this->scrollAlpha3 = 160; + pthis->scrollAlpha3 = 160; } - this->scrollAlpha4 = this->scrollAlpha3; + pthis->scrollAlpha4 = pthis->scrollAlpha3; } -void func_8089E318(BgMizuMovebg* this, GlobalContext* globalCtx) { +void func_8089E318(BgMizuMovebg* pthis, GlobalContext* globalCtx) { WaterBox* waterBoxes = globalCtx->colCtx.colHeader->waterBoxes; f32 phi_f0; s32 type; Vec3f sp28; - func_8089E198(this, globalCtx); + func_8089E198(pthis, globalCtx); - type = MOVEBG_TYPE(this->dyna.actor.params); + type = MOVEBG_TYPE(pthis->dyna.actor.params); switch (type) { case 0: case 2: phi_f0 = waterBoxes[2].ySurface + 15.0f; - if (phi_f0 < this->homeY - 700.0f) { - this->dyna.actor.world.pos.y = this->homeY - 700.0f; + if (phi_f0 < pthis->homeY - 700.0f) { + pthis->dyna.actor.world.pos.y = pthis->homeY - 700.0f; } else { - this->dyna.actor.world.pos.y = phi_f0; + pthis->dyna.actor.world.pos.y = phi_f0; } break; case 1: phi_f0 = waterBoxes[2].ySurface + 15.0f; - if (phi_f0 < this->homeY - 710.0f) { - this->dyna.actor.world.pos.y = this->homeY - 710.0f; + if (phi_f0 < pthis->homeY - 710.0f) { + pthis->dyna.actor.world.pos.y = pthis->homeY - 710.0f; } else { - this->dyna.actor.world.pos.y = phi_f0; + pthis->dyna.actor.world.pos.y = phi_f0; } break; case 3: - phi_f0 = this->homeY + D_8089EB40[func_8089DC30(globalCtx)]; - if (!Math_StepToF(&this->dyna.actor.world.pos.y, phi_f0, 1.0f)) { - if (!(D_8089EE40 & 2) && MOVEBG_SPEED(this->dyna.actor.params) != 0) { + phi_f0 = pthis->homeY + D_8089EB40[func_8089DC30(globalCtx)]; + if (!Math_StepToF(&pthis->dyna.actor.world.pos.y, phi_f0, 1.0f)) { + if (!(D_8089EE40 & 2) && MOVEBG_SPEED(pthis->dyna.actor.params) != 0) { D_8089EE40 |= 2; - this->sfxFlags |= 2; + pthis->sfxFlags |= 2; } - if (this->sfxFlags & 2) { - if (this->dyna.actor.room == 0) { - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + if (pthis->sfxFlags & 2) { + if (pthis->dyna.actor.room == 0) { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); } else { - func_8002F948(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + func_8002F948(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); } } } @@ -289,84 +289,84 @@ void func_8089E318(BgMizuMovebg* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (Flags_GetSwitch(globalCtx, MOVEBG_FLAGS(this->dyna.actor.params))) { - phi_f0 = this->homeY + 115.200005f; + if (Flags_GetSwitch(globalCtx, MOVEBG_FLAGS(pthis->dyna.actor.params))) { + phi_f0 = pthis->homeY + 115.200005f; } else { - phi_f0 = this->homeY; + phi_f0 = pthis->homeY; } - if (!Math_StepToF(&this->dyna.actor.world.pos.y, phi_f0, 1.0f)) { - if (!(D_8089EE40 & 2) && MOVEBG_SPEED(this->dyna.actor.params) != 0) { + if (!Math_StepToF(&pthis->dyna.actor.world.pos.y, phi_f0, 1.0f)) { + if (!(D_8089EE40 & 2) && MOVEBG_SPEED(pthis->dyna.actor.params) != 0) { D_8089EE40 |= 2; - this->sfxFlags |= 2; + pthis->sfxFlags |= 2; } - if (this->sfxFlags & 2) { - func_8002F948(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + if (pthis->sfxFlags & 2) { + func_8002F948(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); } } break; } - type = MOVEBG_TYPE(this->dyna.actor.params); + type = MOVEBG_TYPE(pthis->dyna.actor.params); switch (type) { case 3: case 4: case 5: case 6: - if (globalCtx->roomCtx.curRoom.num == this->dyna.actor.room) { - Matrix_RotateY(this->dyna.actor.world.rot.y * (M_PI / 32768), MTXMODE_NEW); + if (globalCtx->roomCtx.curRoom.num == pthis->dyna.actor.room) { + Matrix_RotateY(pthis->dyna.actor.world.rot.y * (M_PI / 32768), MTXMODE_NEW); Matrix_MultVec3f(&D_8089EBAC, &sp28); - this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x + sp28.x; - this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y + sp28.y; - this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z + sp28.z; - this->dyna.actor.child->flags &= ~ACTOR_FLAG_0; + pthis->dyna.actor.child->world.pos.x = pthis->dyna.actor.world.pos.x + sp28.x; + pthis->dyna.actor.child->world.pos.y = pthis->dyna.actor.world.pos.y + sp28.y; + pthis->dyna.actor.child->world.pos.z = pthis->dyna.actor.world.pos.z + sp28.z; + pthis->dyna.actor.child->flags &= ~ACTOR_FLAG_0; } break; } } -void func_8089E650(BgMizuMovebg* this, GlobalContext* globalCtx) { +void func_8089E650(BgMizuMovebg* pthis, GlobalContext* globalCtx) { Vec3f waypoint; f32 dist; f32 dx; f32 dy; f32 dz; - this->dyna.actor.speedXZ = MOVEBG_SPEED(this->dyna.actor.params) * 0.1f; - func_8089E108(globalCtx->setupPathList, &waypoint, MOVEBG_PATH_ID(this->dyna.actor.params), this->waypointId); - dist = Actor_WorldDistXYZToPoint(&this->dyna.actor, &waypoint); - if (dist < this->dyna.actor.speedXZ) { - this->dyna.actor.speedXZ = dist; + pthis->dyna.actor.speedXZ = MOVEBG_SPEED(pthis->dyna.actor.params) * 0.1f; + func_8089E108(globalCtx->setupPathList, &waypoint, MOVEBG_PATH_ID(pthis->dyna.actor.params), pthis->waypointId); + dist = Actor_WorldDistXYZToPoint(&pthis->dyna.actor, &waypoint); + if (dist < pthis->dyna.actor.speedXZ) { + pthis->dyna.actor.speedXZ = dist; } - func_80035844(&this->dyna.actor.world.pos, &waypoint, &this->dyna.actor.world.rot, 1); - func_8002D97C(&this->dyna.actor); - dx = waypoint.x - this->dyna.actor.world.pos.x; - dy = waypoint.y - this->dyna.actor.world.pos.y; - dz = waypoint.z - this->dyna.actor.world.pos.z; + func_80035844(&pthis->dyna.actor.world.pos, &waypoint, &pthis->dyna.actor.world.rot, 1); + func_8002D97C(&pthis->dyna.actor); + dx = waypoint.x - pthis->dyna.actor.world.pos.x; + dy = waypoint.y - pthis->dyna.actor.world.pos.y; + dz = waypoint.z - pthis->dyna.actor.world.pos.z; if (fabsf(dx) < 2.0f && fabsf(dy) < 2.0f && fabsf(dz) < 2.0f) { - this->waypointId++; - if (this->waypointId >= globalCtx->setupPathList[MOVEBG_PATH_ID(this->dyna.actor.params)].count) { - this->waypointId = 0; - func_8089E108(globalCtx->setupPathList, &this->dyna.actor.world.pos, - MOVEBG_PATH_ID(this->dyna.actor.params), 0); + pthis->waypointId++; + if (pthis->waypointId >= globalCtx->setupPathList[MOVEBG_PATH_ID(pthis->dyna.actor.params)].count) { + pthis->waypointId = 0; + func_8089E108(globalCtx->setupPathList, &pthis->dyna.actor.world.pos, + MOVEBG_PATH_ID(pthis->dyna.actor.params), 0); } } - if (!(D_8089EE40 & 1) && MOVEBG_SPEED(this->dyna.actor.params) != 0) { + if (!(D_8089EE40 & 1) && MOVEBG_SPEED(pthis->dyna.actor.params) != 0) { D_8089EE40 |= 1; - this->sfxFlags |= 1; + pthis->sfxFlags |= 1; } - if (this->sfxFlags & 1) { - func_8002F948(&this->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); + if (pthis->sfxFlags & 1) { + func_8002F948(&pthis->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); } } void BgMizuMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMizuMovebg* this = (BgMizuMovebg*)thisx; + BgMizuMovebg* pthis = (BgMizuMovebg*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgMizuMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { - BgMizuMovebg* this = (BgMizuMovebg*)thisx; + BgMizuMovebg* pthis = (BgMizuMovebg*)thisx; GlobalContext* globalCtx = globalCtx2; u32 frames; @@ -379,25 +379,25 @@ void BgMizuMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, frames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, - this->scrollAlpha1)); + pthis->scrollAlpha1)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, frames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, - this->scrollAlpha2)); + pthis->scrollAlpha2)); gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, frames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, - this->scrollAlpha3)); + pthis->scrollAlpha3)); gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, frames * 3, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, - this->scrollAlpha4)); + pthis->scrollAlpha4)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mizu_movebg.c", 788), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->dlist != NULL) { - gSPDisplayList(POLY_OPA_DISP++, this->dlist); + if (pthis->dlist != NULL) { + gSPDisplayList(POLY_OPA_DISP++, pthis->dlist); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_movebg.c", 795); diff --git a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c deleted file mode 100644 index 2a3e831ec..000000000 --- a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c +++ /dev/null @@ -1,179 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MIZU_SHUTTER_Z_BG_MIZU_SHUTTER_C -#include "actor_common.h" -#include "z_bg_mizu_shutter.h" -#include "objects/object_mizu_objects/object_mizu_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -#define SIZE_PARAM (((u16)this->dyna.actor.params >> 0xC) & 0xF) -#define TIMER_PARAM (((u16)this->dyna.actor.params >> 6) & 0x3F) - -void BgMizuShutter_Init(BgMizuShutter* this, GlobalContext* globalCtx); -void BgMizuShutter_Destroy(BgMizuShutter* this, GlobalContext* globalCtx); -void BgMizuShutter_Update(BgMizuShutter* this, GlobalContext* globalCtx); -void BgMizuShutter_Draw(BgMizuShutter* this, GlobalContext* globalCtx); - -void BgMizuShutter_WaitForTimer(BgMizuShutter* this, GlobalContext* globalCtx); -void BgMizuShutter_WaitForSwitch(BgMizuShutter* this, GlobalContext* globalCtx); -void BgMizuShutter_Move(BgMizuShutter* this, GlobalContext* globalCtx); -void BgMizuShutter_WaitForCutscene(BgMizuShutter* this, GlobalContext* globalCtx); - -const ActorInit Bg_Mizu_Shutter_InitVars = { - ACTOR_BG_MIZU_SHUTTER, - ACTORCAT_PROP, - FLAGS, - OBJECT_MIZU_OBJECTS, - sizeof(BgMizuShutter), - (ActorFunc)BgMizuShutter_Init, - (ActorFunc)BgMizuShutter_Destroy, - (ActorFunc)BgMizuShutter_Update, - (ActorFunc)BgMizuShutter_Draw, -}; - -static Gfx* sDisplayLists[] = { gObjectMizuObjectsShutterDL_007130, gObjectMizuObjectsShutterDL_0072D0 }; - -static CollisionHeader* sCollisionHeaders[] = { - &gObjectMizuObjectsShutterCol_007250, - &gObjectMizuObjectsShutterCol_0073F0, -}; - -static Vec3f sDisplacements[] = { - { 0.0f, 100.0f, 0.0f }, - { 0.0f, 140.0f, 0.0f }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgMizuShutter_Init(BgMizuShutter* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMizuShutter* this = (BgMizuShutter*)thisx; - s32 pad2; - CollisionHeader* sp30 = NULL; - s32 pad3; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->displayList = sDisplayLists[SIZE_PARAM]; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(sCollisionHeaders[SIZE_PARAM], &sp30); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp30); - if ((SIZE_PARAM == BGMIZUSHUTTER_SMALL) || (SIZE_PARAM == BGMIZUSHUTTER_LARGE)) { - this->closedPos = this->dyna.actor.world.pos; - this->timer = 0; - this->timerMax = TIMER_PARAM * 20; - Matrix_RotateY(this->dyna.actor.world.rot.y * (M_PI / 0x8000), MTXMODE_NEW); - Matrix_RotateX(this->dyna.actor.world.rot.x * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(this->dyna.actor.world.rot.z * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultVec3f(&sDisplacements[SIZE_PARAM], &this->openPos); - this->openPos.x += this->dyna.actor.world.pos.x; - this->openPos.y += this->dyna.actor.world.pos.y; - this->openPos.z += this->dyna.actor.world.pos.z; - if (this->timerMax != 0x3F * 20) { - Flags_UnsetSwitch(globalCtx, (u16)this->dyna.actor.params & 0x3F); - this->dyna.actor.world.pos = this->closedPos; - } - if (Flags_GetSwitch(globalCtx, (u16)this->dyna.actor.params & 0x3F)) { - this->dyna.actor.world.pos = this->openPos; - this->actionFunc = BgMizuShutter_WaitForTimer; - } else { - this->actionFunc = BgMizuShutter_WaitForSwitch; - } - } -} - -void BgMizuShutter_Destroy(BgMizuShutter* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMizuShutter* this = (BgMizuShutter*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgMizuShutter_WaitForSwitch(BgMizuShutter* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (u16)this->dyna.actor.params & 0x3F)) { - if (ABS(this->dyna.actor.world.rot.x) > 0x2C60) { - OnePointCutscene_Init(globalCtx, 4510, -99, &this->dyna.actor, MAIN_CAM); - } else { - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - } - this->actionFunc = BgMizuShutter_WaitForCutscene; - this->timer = 30; - } -} - -void BgMizuShutter_WaitForCutscene(BgMizuShutter* this, GlobalContext* globalCtx) { - if (this->timer-- == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); - this->actionFunc = BgMizuShutter_Move; - } -} - -void BgMizuShutter_Move(BgMizuShutter* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (u16)this->dyna.actor.params & 0x3F)) { - Math_SmoothStepToF(&this->dyna.actor.world.pos.x, this->openPos.x, 1.0f, 4.0f, 0.1f); - Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->openPos.y, 1.0f, 4.0f, 0.1f); - Math_SmoothStepToF(&this->dyna.actor.world.pos.z, this->openPos.z, 1.0f, 4.0f, 0.1f); - if ((this->dyna.actor.world.pos.x == this->openPos.x) && (this->dyna.actor.world.pos.y == this->openPos.y) && - (this->dyna.actor.world.pos.z == this->openPos.z)) { - this->timer = this->timerMax; - this->actionFunc = BgMizuShutter_WaitForTimer; - } - } else { - Math_SmoothStepToF(&this->maxSpeed, 20.0f, 1.0f, 3.0f, 0.1f); - Math_SmoothStepToF(&this->dyna.actor.world.pos.x, this->closedPos.x, 1.0f, this->maxSpeed, 0.1f); - Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->closedPos.y, 1.0f, this->maxSpeed, 0.1f); - Math_SmoothStepToF(&this->dyna.actor.world.pos.z, this->closedPos.z, 1.0f, this->maxSpeed, 0.1f); - if ((this->dyna.actor.world.pos.x == this->closedPos.x) && - (this->dyna.actor.world.pos.y == this->closedPos.y) && - (this->dyna.actor.world.pos.z == this->closedPos.z)) { - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - this->actionFunc = BgMizuShutter_WaitForSwitch; - } - } -} - -void BgMizuShutter_WaitForTimer(BgMizuShutter* this, GlobalContext* globalCtx) { - if (this->timerMax != 0x3F * 20) { - this->timer--; - func_8002F994(&this->dyna.actor, this->timer); - if (this->timer == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); - Flags_UnsetSwitch(globalCtx, (u16)this->dyna.actor.params & 0x3F); - this->actionFunc = BgMizuShutter_Move; - } - } -} - -void BgMizuShutter_Update(BgMizuShutter* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMizuShutter* this = (BgMizuShutter*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgMizuShutter_Draw(BgMizuShutter* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMizuShutter* this = (BgMizuShutter*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_shutter.c", 410); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mizu_shutter.c", 415), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (this->displayList != NULL) { - gSPDisplayList(POLY_OPA_DISP++, this->displayList); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_shutter.c", 422); -} diff --git a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp new file mode 100644 index 000000000..388f0013a --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp @@ -0,0 +1,179 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MIZU_SHUTTER_Z_BG_MIZU_SHUTTER_C +#include "actor_common.h" +#include "z_bg_mizu_shutter.h" +#include "objects/object_mizu_objects/object_mizu_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +#define SIZE_PARAM (((u16)pthis->dyna.actor.params >> 0xC) & 0xF) +#define TIMER_PARAM (((u16)pthis->dyna.actor.params >> 6) & 0x3F) + +void BgMizuShutter_Init(BgMizuShutter* pthis, GlobalContext* globalCtx); +void BgMizuShutter_Destroy(BgMizuShutter* pthis, GlobalContext* globalCtx); +void BgMizuShutter_Update(BgMizuShutter* pthis, GlobalContext* globalCtx); +void BgMizuShutter_Draw(BgMizuShutter* pthis, GlobalContext* globalCtx); + +void BgMizuShutter_WaitForTimer(BgMizuShutter* pthis, GlobalContext* globalCtx); +void BgMizuShutter_WaitForSwitch(BgMizuShutter* pthis, GlobalContext* globalCtx); +void BgMizuShutter_Move(BgMizuShutter* pthis, GlobalContext* globalCtx); +void BgMizuShutter_WaitForCutscene(BgMizuShutter* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Mizu_Shutter_InitVars = { + ACTOR_BG_MIZU_SHUTTER, + ACTORCAT_PROP, + FLAGS, + OBJECT_MIZU_OBJECTS, + sizeof(BgMizuShutter), + (ActorFunc)BgMizuShutter_Init, + (ActorFunc)BgMizuShutter_Destroy, + (ActorFunc)BgMizuShutter_Update, + (ActorFunc)BgMizuShutter_Draw, +}; + +static Gfx* sDisplayLists[] = { gObjectMizuObjectsShutterDL_007130, gObjectMizuObjectsShutterDL_0072D0 }; + +static CollisionHeader* sCollisionHeaders[] = { + &gObjectMizuObjectsShutterCol_007250, + &gObjectMizuObjectsShutterCol_0073F0, +}; + +static Vec3f sDisplacements[] = { + { 0.0f, 100.0f, 0.0f }, + { 0.0f, 140.0f, 0.0f }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgMizuShutter_Init(BgMizuShutter* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMizuShutter* pthis = (BgMizuShutter*)thisx; + s32 pad2; + CollisionHeader* sp30 = NULL; + s32 pad3; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->displayList = sDisplayLists[SIZE_PARAM]; + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(sCollisionHeaders[SIZE_PARAM], &sp30); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, sp30); + if ((SIZE_PARAM == BGMIZUSHUTTER_SMALL) || (SIZE_PARAM == BGMIZUSHUTTER_LARGE)) { + pthis->closedPos = pthis->dyna.actor.world.pos; + pthis->timer = 0; + pthis->timerMax = TIMER_PARAM * 20; + Matrix_RotateY(pthis->dyna.actor.world.rot.y * (M_PI / 0x8000), MTXMODE_NEW); + Matrix_RotateX(pthis->dyna.actor.world.rot.x * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->dyna.actor.world.rot.z * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&sDisplacements[SIZE_PARAM], &pthis->openPos); + pthis->openPos.x += pthis->dyna.actor.world.pos.x; + pthis->openPos.y += pthis->dyna.actor.world.pos.y; + pthis->openPos.z += pthis->dyna.actor.world.pos.z; + if (pthis->timerMax != 0x3F * 20) { + Flags_UnsetSwitch(globalCtx, (u16)pthis->dyna.actor.params & 0x3F); + pthis->dyna.actor.world.pos = pthis->closedPos; + } + if (Flags_GetSwitch(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { + pthis->dyna.actor.world.pos = pthis->openPos; + pthis->actionFunc = BgMizuShutter_WaitForTimer; + } else { + pthis->actionFunc = BgMizuShutter_WaitForSwitch; + } + } +} + +void BgMizuShutter_Destroy(BgMizuShutter* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMizuShutter* pthis = (BgMizuShutter*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgMizuShutter_WaitForSwitch(BgMizuShutter* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { + if (ABS(pthis->dyna.actor.world.rot.x) > 0x2C60) { + OnePointCutscene_Init(globalCtx, 4510, -99, &pthis->dyna.actor, MAIN_CAM); + } else { + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + } + pthis->actionFunc = BgMizuShutter_WaitForCutscene; + pthis->timer = 30; + } +} + +void BgMizuShutter_WaitForCutscene(BgMizuShutter* pthis, GlobalContext* globalCtx) { + if (pthis->timer-- == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_OPEN); + pthis->actionFunc = BgMizuShutter_Move; + } +} + +void BgMizuShutter_Move(BgMizuShutter* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.x, pthis->openPos.x, 1.0f, 4.0f, 0.1f); + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->openPos.y, 1.0f, 4.0f, 0.1f); + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.z, pthis->openPos.z, 1.0f, 4.0f, 0.1f); + if ((pthis->dyna.actor.world.pos.x == pthis->openPos.x) && (pthis->dyna.actor.world.pos.y == pthis->openPos.y) && + (pthis->dyna.actor.world.pos.z == pthis->openPos.z)) { + pthis->timer = pthis->timerMax; + pthis->actionFunc = BgMizuShutter_WaitForTimer; + } + } else { + Math_SmoothStepToF(&pthis->maxSpeed, 20.0f, 1.0f, 3.0f, 0.1f); + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.x, pthis->closedPos.x, 1.0f, pthis->maxSpeed, 0.1f); + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->closedPos.y, 1.0f, pthis->maxSpeed, 0.1f); + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.z, pthis->closedPos.z, 1.0f, pthis->maxSpeed, 0.1f); + if ((pthis->dyna.actor.world.pos.x == pthis->closedPos.x) && + (pthis->dyna.actor.world.pos.y == pthis->closedPos.y) && + (pthis->dyna.actor.world.pos.z == pthis->closedPos.z)) { + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); + pthis->actionFunc = BgMizuShutter_WaitForSwitch; + } + } +} + +void BgMizuShutter_WaitForTimer(BgMizuShutter* pthis, GlobalContext* globalCtx) { + if (pthis->timerMax != 0x3F * 20) { + pthis->timer--; + func_8002F994(&pthis->dyna.actor, pthis->timer); + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); + Flags_UnsetSwitch(globalCtx, (u16)pthis->dyna.actor.params & 0x3F); + pthis->actionFunc = BgMizuShutter_Move; + } + } +} + +void BgMizuShutter_Update(BgMizuShutter* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMizuShutter* pthis = (BgMizuShutter*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgMizuShutter_Draw(BgMizuShutter* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMizuShutter* pthis = (BgMizuShutter*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_shutter.c", 410); + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mizu_shutter.c", 415), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (pthis->displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, pthis->displayList); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_shutter.c", 422); +} diff --git a/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c b/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.cpp similarity index 66% rename from src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c rename to src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.cpp index 2acb39dac..1c5a36b40 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.cpp @@ -20,9 +20,9 @@ void BgMizuUzu_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMizuUzu_Update(Actor* thisx, GlobalContext* globalCtx); void BgMizuUzu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8089F788(BgMizuUzu* this, GlobalContext* globalCtx); +void func_8089F788(BgMizuUzu* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Mizu_Uzu_InitVars = { +ActorInit Bg_Mizu_Uzu_InitVars = { ACTOR_BG_MIZU_UZU, ACTORCAT_PROP, FLAGS, @@ -42,39 +42,39 @@ static InitChainEntry sInitChain[] = { void BgMizuUzu_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMizuUzu* this = (BgMizuUzu*)thisx; + BgMizuUzu* pthis = (BgMizuUzu*)thisx; CollisionHeader* colHeader = NULL; s32 pad2; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gObjectMizuObjectsUzuCol_0074EC, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->actionFunc = func_8089F788; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->actionFunc = func_8089F788; } void BgMizuUzu_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMizuUzu* this = (BgMizuUzu*)thisx; + BgMizuUzu* pthis = (BgMizuUzu*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_8089F788(BgMizuUzu* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void func_8089F788(BgMizuUzu* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; if (GET_PLAYER(globalCtx)->currentBoots == PLAYER_BOOTS_IRON) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } else { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } Audio_PlayActorSound2(thisx, NA_SE_EV_WATER_CONVECTION - SFX_FLAG); thisx->shape.rot.y += 0x1C0; } void BgMizuUzu_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMizuUzu* this = (BgMizuUzu*)thisx; + BgMizuUzu* pthis = (BgMizuUzu*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgMizuUzu_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.cpp similarity index 62% rename from src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c rename to src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.cpp index fec2e59e8..e16b71305 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.cpp @@ -23,8 +23,8 @@ void BgMizuWater_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMizuWater_Update(Actor* thisx, GlobalContext* globalCtx); void BgMizuWater_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgMizuWater_WaitForAction(BgMizuWater* this, GlobalContext* globalCtx); -void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, GlobalContext* globalCtx); +void BgMizuWater_WaitForAction(BgMizuWater* pthis, GlobalContext* globalCtx); +void BgMizuWater_ChangeWaterLevel(BgMizuWater* pthis, GlobalContext* globalCtx); typedef struct { s32 switchFlag; @@ -38,7 +38,7 @@ static WaterLevel sWaterLevels[] = { { WATER_TEMPLE_WATER_F1_FLAG, WATER_TEMPLE_WATER_F1_Y - WATER_TEMPLE_WATER_F3_Y }, }; -const ActorInit Bg_Mizu_Water_InitVars = { +ActorInit Bg_Mizu_Water_InitVars = { ACTOR_BG_MIZU_WATER, ACTORCAT_BG, FLAGS, @@ -98,20 +98,20 @@ void BgMizuWater_SetWaterBoxesHeight(WaterBox* waterBoxes, s16 height) { } void BgMizuWater_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMizuWater* this = (BgMizuWater*)thisx; + BgMizuWater* pthis = (BgMizuWater*)thisx; f32 initialActorY; WaterBox* waterBoxes; s32 waterLevelActionIndex; waterBoxes = globalCtx->colCtx.colHeader->waterBoxes; - this->type = this->actor.params & 0xFF; - this->switchFlag = (this->actor.params >> 8) & 0xFF; - Actor_ProcessInitChain(&this->actor, sInitChain); - initialActorY = this->actor.world.pos.y; - this->baseY = initialActorY; - this->targetY = initialActorY; + pthis->type = pthis->actor.params & 0xFF; + pthis->switchFlag = (pthis->actor.params >> 8) & 0xFF; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + initialActorY = pthis->actor.world.pos.y; + pthis->baseY = initialActorY; + pthis->targetY = initialActorY; - switch (this->type) { + switch (pthis->type) { case 0: if (bREG(15) == 0) { osSyncPrintf("<コンストラクト>%x %x %x\n", Flags_GetSwitch(globalCtx, WATER_TEMPLE_WATER_F1_FLAG), @@ -119,14 +119,14 @@ void BgMizuWater_Init(Actor* thisx, GlobalContext* globalCtx) { Flags_GetSwitch(globalCtx, WATER_TEMPLE_WATER_F3_FLAG)); } waterLevelActionIndex = BgMizuWater_GetWaterLevelActionIndex(-1, globalCtx); - this->actor.world.pos.y = sWaterLevels[waterLevelActionIndex].yDiff + this->baseY; - BgMizuWater_SetWaterBoxesHeight(waterBoxes, this->actor.world.pos.y); - this->actor.params = sWaterLevels[waterLevelActionIndex].switchFlag; + pthis->actor.world.pos.y = sWaterLevels[waterLevelActionIndex].yDiff + pthis->baseY; + BgMizuWater_SetWaterBoxesHeight(waterBoxes, pthis->actor.world.pos.y); + pthis->actor.params = sWaterLevels[waterLevelActionIndex].switchFlag; Flags_UnsetSwitch(globalCtx, WATER_TEMPLE_WATER_F1_FLAG); Flags_UnsetSwitch(globalCtx, WATER_TEMPLE_WATER_F2_FLAG); Flags_UnsetSwitch(globalCtx, WATER_TEMPLE_WATER_F3_FLAG); - switch (this->actor.params) { + switch (pthis->actor.params) { case 0x1E: Flags_SetSwitch(globalCtx, WATER_TEMPLE_WATER_F3_FLAG); break; @@ -138,169 +138,169 @@ void BgMizuWater_Init(Actor* thisx, GlobalContext* globalCtx) { Flags_SetSwitch(globalCtx, WATER_TEMPLE_WATER_F1_FLAG); break; } - this->targetY = this->actor.world.pos.y; + pthis->targetY = pthis->actor.world.pos.y; break; case 1: break; case 2: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actor.world.pos.y = this->baseY + 85.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actor.world.pos.y = pthis->baseY + 85.0f; } - waterBoxes[6].ySurface = this->actor.world.pos.y; + waterBoxes[6].ySurface = pthis->actor.world.pos.y; break; case 3: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actor.world.pos.y = this->baseY + 110.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actor.world.pos.y = pthis->baseY + 110.0f; if (1) {} - this->targetY = this->actor.world.pos.y; + pthis->targetY = pthis->actor.world.pos.y; } - waterBoxes[8].ySurface = this->actor.world.pos.y; + waterBoxes[8].ySurface = pthis->actor.world.pos.y; break; case 4: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actor.world.pos.y = this->baseY + 160.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actor.world.pos.y = pthis->baseY + 160.0f; if (1) {} - this->targetY = this->actor.world.pos.y; + pthis->targetY = pthis->actor.world.pos.y; } - waterBoxes[16].ySurface = this->actor.world.pos.y; + waterBoxes[16].ySurface = pthis->actor.world.pos.y; break; } - this->actionFunc = BgMizuWater_WaitForAction; + pthis->actionFunc = BgMizuWater_WaitForAction; } void BgMizuWater_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void BgMizuWater_WaitForAction(BgMizuWater* this, GlobalContext* globalCtx) { +void BgMizuWater_WaitForAction(BgMizuWater* pthis, GlobalContext* globalCtx) { s32 pad; s32 waterLevelActionIndex; s16 prevSwitchFlag; - switch (this->type) { + switch (pthis->type) { case 0: - prevSwitchFlag = this->actor.params; - waterLevelActionIndex = BgMizuWater_GetWaterLevelActionIndex(this->actor.params, globalCtx); + prevSwitchFlag = pthis->actor.params; + waterLevelActionIndex = BgMizuWater_GetWaterLevelActionIndex(pthis->actor.params, globalCtx); if (waterLevelActionIndex != 0) { if (prevSwitchFlag != sWaterLevels[waterLevelActionIndex].switchFlag) { OnePointCutscene_Init(globalCtx, 3120, -100 - waterLevelActionIndex, NULL, MAIN_CAM); - this->actor.params = sWaterLevels[waterLevelActionIndex].switchFlag; - this->targetY = sWaterLevels[waterLevelActionIndex].yDiff + this->baseY; + pthis->actor.params = sWaterLevels[waterLevelActionIndex].switchFlag; + pthis->targetY = sWaterLevels[waterLevelActionIndex].yDiff + pthis->baseY; } } - if ((prevSwitchFlag != this->actor.params) && (prevSwitchFlag != 0)) { + if ((prevSwitchFlag != pthis->actor.params) && (prevSwitchFlag != 0)) { Flags_UnsetSwitch(globalCtx, prevSwitchFlag); } break; case 1: break; case 2: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->targetY = this->baseY + 85.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->targetY = pthis->baseY + 85.0f; } else { - this->targetY = this->baseY; + pthis->targetY = pthis->baseY; } break; case 3: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->targetY = this->baseY + 110.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->targetY = pthis->baseY + 110.0f; } else { - this->targetY = this->baseY; + pthis->targetY = pthis->baseY; } break; case 4: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->targetY = this->baseY + 160.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->targetY = pthis->baseY + 160.0f; } else { - this->targetY = this->baseY; + pthis->targetY = pthis->baseY; } } - if (this->targetY != this->actor.world.pos.y) { - this->actionFunc = BgMizuWater_ChangeWaterLevel; + if (pthis->targetY != pthis->actor.world.pos.y) { + pthis->actionFunc = BgMizuWater_ChangeWaterLevel; } } -void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, GlobalContext* globalCtx) { +void BgMizuWater_ChangeWaterLevel(BgMizuWater* pthis, GlobalContext* globalCtx) { s32 pad; s16 prevSwitchFlag; s32 waterLevelActionIndex; WaterBox* waterBoxes; waterBoxes = globalCtx->colCtx.colHeader->waterBoxes; - switch (this->type) { + switch (pthis->type) { case 0: - prevSwitchFlag = this->actor.params; - waterLevelActionIndex = BgMizuWater_GetWaterLevelActionIndex(this->actor.params, globalCtx); + prevSwitchFlag = pthis->actor.params; + waterLevelActionIndex = BgMizuWater_GetWaterLevelActionIndex(pthis->actor.params, globalCtx); if (waterLevelActionIndex != 0) { if (prevSwitchFlag != sWaterLevels[waterLevelActionIndex].switchFlag) { - this->actor.params = sWaterLevels[waterLevelActionIndex].switchFlag; - this->targetY = sWaterLevels[waterLevelActionIndex].yDiff + this->baseY; + pthis->actor.params = sWaterLevels[waterLevelActionIndex].switchFlag; + pthis->targetY = sWaterLevels[waterLevelActionIndex].yDiff + pthis->baseY; } } - if ((prevSwitchFlag != this->actor.params) && (prevSwitchFlag != 0)) { + if ((prevSwitchFlag != pthis->actor.params) && (prevSwitchFlag != 0)) { Flags_UnsetSwitch(globalCtx, prevSwitchFlag); } - if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 5.0f)) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->targetY, 5.0f)) { globalCtx->roomCtx.unk_74[0] = 0; - this->actionFunc = BgMizuWater_WaitForAction; + pthis->actionFunc = BgMizuWater_WaitForAction; Message_CloseTextbox(globalCtx); } - BgMizuWater_SetWaterBoxesHeight(globalCtx->colCtx.colHeader->waterBoxes, this->actor.world.pos.y); + BgMizuWater_SetWaterBoxesHeight(globalCtx->colCtx.colHeader->waterBoxes, pthis->actor.world.pos.y); break; case 1: break; case 2: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->targetY = this->baseY + 85.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->targetY = pthis->baseY + 85.0f; } else { - this->targetY = this->baseY; + pthis->targetY = pthis->baseY; } - if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->targetY, 1.0f)) { globalCtx->roomCtx.unk_74[0] = 0; - this->actionFunc = BgMizuWater_WaitForAction; + pthis->actionFunc = BgMizuWater_WaitForAction; } - waterBoxes[6].ySurface = this->actor.world.pos.y; + waterBoxes[6].ySurface = pthis->actor.world.pos.y; break; case 3: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->targetY = this->baseY + 110.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->targetY = pthis->baseY + 110.0f; } else { - this->targetY = this->baseY; + pthis->targetY = pthis->baseY; } - if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->targetY, 1.0f)) { globalCtx->roomCtx.unk_74[0] = 0; - this->actionFunc = BgMizuWater_WaitForAction; + pthis->actionFunc = BgMizuWater_WaitForAction; } - waterBoxes[8].ySurface = this->actor.world.pos.y; + waterBoxes[8].ySurface = pthis->actor.world.pos.y; break; case 4: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->targetY = this->baseY + 160.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->targetY = pthis->baseY + 160.0f; } else { - this->targetY = this->baseY; + pthis->targetY = pthis->baseY; } - if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->targetY, 1.0f)) { globalCtx->roomCtx.unk_74[0] = 0; - this->actionFunc = BgMizuWater_WaitForAction; + pthis->actionFunc = BgMizuWater_WaitForAction; } - waterBoxes[16].ySurface = this->actor.world.pos.y; + waterBoxes[16].ySurface = pthis->actor.world.pos.y; break; } - if (this->targetY < this->actor.world.pos.y) { + if (pthis->targetY < pthis->actor.world.pos.y) { func_800AA000(0.0f, 0x78, 0x14, 0xA); - func_8002F948(&this->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); - } else if (this->targetY > this->actor.world.pos.y) { + func_8002F948(&pthis->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + } else if (pthis->targetY > pthis->actor.world.pos.y) { func_800AA000(0.0f, 0x78, 0x14, 0xA); - func_8002F948(&this->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); } } void BgMizuWater_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMizuWater* this = (BgMizuWater*)thisx; + BgMizuWater* pthis = (BgMizuWater*)thisx; s32 posY; s32 unk0; s32 unk1; @@ -311,8 +311,8 @@ void BgMizuWater_Update(Actor* thisx, GlobalContext* globalCtx) { Flags_GetSwitch(globalCtx, WATER_TEMPLE_WATER_F2_FLAG), Flags_GetSwitch(globalCtx, WATER_TEMPLE_WATER_F3_FLAG)); } - if (this->type == 0) { - posY = this->actor.world.pos.y; + if (pthis->type == 0) { + posY = pthis->actor.world.pos.y; unk0 = 0; unk1 = 0; if (posY < WATER_TEMPLE_WATER_F1_Y) { @@ -330,11 +330,11 @@ void BgMizuWater_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->roomCtx.unk_74[1] = ((u8)unk0 << 8) | (unk1 & 0xFF); } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgMizuWater_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgMizuWater* this = (BgMizuWater*)thisx; + BgMizuWater* pthis = (BgMizuWater*)thisx; s32 gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_water.c", 738); diff --git a/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c b/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.cpp similarity index 68% rename from src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c rename to src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.cpp index cc9f61973..29b580d01 100644 --- a/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.c +++ b/src/overlays/actors/ovl_Bg_Mjin/z_bg_mjin.cpp @@ -30,10 +30,10 @@ void BgMjin_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMjin_Update(Actor* thisx, GlobalContext* globalCtx); void BgMjin_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808A0850(BgMjin* this, GlobalContext* globalCtx); -void BgMjin_DoNothing(BgMjin* this, GlobalContext* globalCtx); +void func_808A0850(BgMjin* pthis, GlobalContext* globalCtx); +void BgMjin_DoNothing(BgMjin* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Mjin_InitVars = { +ActorInit Bg_Mjin_InitVars = { ACTOR_BG_MJIN, ACTORCAT_BG, FLAGS, @@ -57,59 +57,59 @@ static InitChainEntry sInitChain[] = { static s16 sObjectIDs[] = { OBJECT_MJIN_FLASH, OBJECT_MJIN_DARK, OBJECT_MJIN_FLAME, OBJECT_MJIN_ICE, OBJECT_MJIN_SOUL, OBJECT_MJIN_WIND }; -void BgMjin_SetupAction(BgMjin* this, BgMjinActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgMjin_SetupAction(BgMjin* pthis, BgMjinActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgMjin_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMjin* this = (BgMjin*)thisx; + BgMjin* pthis = (BgMjin*)thisx; s32 objBankIndex; Actor_ProcessInitChain(thisx, sInitChain); objBankIndex = Object_GetIndex(&globalCtx->objectCtx, (thisx->params != 0 ? OBJECT_MJIN : OBJECT_MJIN_OKA)); - this->objBankIndex = objBankIndex; + pthis->objBankIndex = objBankIndex; if (objBankIndex < 0) { Actor_Kill(thisx); } else { - BgMjin_SetupAction(this, func_808A0850); + BgMjin_SetupAction(pthis, func_808A0850); } } void BgMjin_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMjin* this = (BgMjin*)thisx; + BgMjin* pthis = (BgMjin*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808A0850(BgMjin* this, GlobalContext* globalCtx) { +void func_808A0850(BgMjin* pthis, GlobalContext* globalCtx) { CollisionHeader* colHeader; CollisionHeader* collision; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { colHeader = NULL; - this->dyna.actor.flags &= ~ACTOR_FLAG_4; - this->dyna.actor.objBankIndex = this->objBankIndex; - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); - DynaPolyActor_Init(&this->dyna, 0); - collision = this->dyna.actor.params != 0 ? &gWarpPadCol : &gOcarinaWarpPadCol; + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; + pthis->dyna.actor.objBankIndex = pthis->objBankIndex; + Actor_SetObjectDependency(globalCtx, &pthis->dyna.actor); + DynaPolyActor_Init(&pthis->dyna, 0); + collision = pthis->dyna.actor.params != 0 ? &gWarpPadCol : &gOcarinaWarpPadCol; CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - BgMjin_SetupAction(this, BgMjin_DoNothing); - this->dyna.actor.draw = BgMjin_Draw; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + BgMjin_SetupAction(pthis, BgMjin_DoNothing); + pthis->dyna.actor.draw = BgMjin_Draw; } } -void BgMjin_DoNothing(BgMjin* this, GlobalContext* globalCtx) { +void BgMjin_DoNothing(BgMjin* pthis, GlobalContext* globalCtx) { } void BgMjin_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMjin* this = (BgMjin*)thisx; + BgMjin* pthis = (BgMjin*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgMjin_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgMjin* this = (BgMjin*)thisx; + BgMjin* pthis = (BgMjin*)thisx; Gfx* dlist; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mjin.c", 250); @@ -118,10 +118,10 @@ void BgMjin_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIDs[thisx->params - 1]); if (objBankIndex >= 0) { - gSegments[6] = gObjectTable[objBankIndex].vromStart; + gSegments[6] = gObjectTable[objBankIndex].vromStart.get(); } - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[objBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[objBankIndex].vromStart.get()); dlist = gWarpPadBaseDL; } else { dlist = gOcarinaWarpPadDL; diff --git a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c deleted file mode 100644 index d223a215f..000000000 --- a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c +++ /dev/null @@ -1,269 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_BIGST_Z_BG_MORI_BIGST_C -#include "actor_common.h" -/* - * File: z_bg_mori_bigst.c - * Overlay: ovl_Bg_Mori_Bigst - * Description: Forest Temple falling platform and Stalfos fight - */ - -#include "z_bg_mori_bigst.h" -#include "objects/object_mori_objects/object_mori_objects.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_quake.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgMoriBigst_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMoriBigst_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMoriBigst_Update(Actor* thisx, GlobalContext* globalCtx); -void BgMoriBigst_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgMoriBigst_SetupWaitForMoriTex(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_WaitForMoriTex(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_SetupNoop(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_SetupStalfosFight(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_StalfosFight(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_SetupFall(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_Fall(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_SetupLanding(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_Landing(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_SetupStalfosPairFight(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_StalfosPairFight(BgMoriBigst* this, GlobalContext* globalCtx); -void BgMoriBigst_SetupDone(BgMoriBigst* this, GlobalContext* globalCtx); - -const ActorInit Bg_Mori_Bigst_InitVars = { - ACTOR_BG_MORI_BIGST, - ACTORCAT_BG, - FLAGS, - OBJECT_MORI_OBJECTS, - sizeof(BgMoriBigst), - (ActorFunc)BgMoriBigst_Init, - (ActorFunc)BgMoriBigst_Destroy, - (ActorFunc)BgMoriBigst_Update, - NULL, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -12000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -void BgMoriBigst_SetupAction(BgMoriBigst* this, BgMoriBigstActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void BgMoriBigst_InitDynapoly(BgMoriBigst* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, moveFlag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - // "Warning : move BG login failed" - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_bigst.c", 190, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgMoriBigst_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriBigst* this = (BgMoriBigst*)thisx; - - // "mori (bigST.keyceiling)" - osSyncPrintf("mori (bigST.鍵型天井)(arg : %04x)(sw %d)(noE %d)(roomC %d)(playerPosY %f)\n", this->dyna.actor.params, - Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F), - Flags_GetTempClear(globalCtx, this->dyna.actor.room), Flags_GetClear(globalCtx, this->dyna.actor.room), - GET_PLAYER(globalCtx)->actor.world.pos.y); - BgMoriBigst_InitDynapoly(this, globalCtx, &gMoriBigstCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - // "【Big Stalfos key ceiling】 bank danger!" - osSyncPrintf("【ビッグスタルフォス鍵型天井】 バンク危険!\n"); - osSyncPrintf("%s %d\n", "../z_bg_mori_bigst.c", 234); - Actor_Kill(&this->dyna.actor); - return; - } - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - } else { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 270.0f; - } - Actor_SetFocus(&this->dyna.actor, 50.0f); - BgMoriBigst_SetupWaitForMoriTex(this, globalCtx); -} - -void BgMoriBigst_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriBigst* this = (BgMoriBigst*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgMoriBigst_SetupWaitForMoriTex(BgMoriBigst* this, GlobalContext* globalCtx) { - BgMoriBigst_SetupAction(this, BgMoriBigst_WaitForMoriTex); -} - -void BgMoriBigst_WaitForMoriTex(BgMoriBigst* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - thisx->draw = BgMoriBigst_Draw; - if (Flags_GetClear(globalCtx, thisx->room) && (GET_PLAYER(globalCtx)->actor.world.pos.y > 700.0f)) { - if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0x3F)) { - BgMoriBigst_SetupDone(this, globalCtx); - } else { - BgMoriBigst_SetupStalfosFight(this, globalCtx); - } - } else { - BgMoriBigst_SetupNoop(this, globalCtx); - } - } -} - -void BgMoriBigst_SetupNoop(BgMoriBigst* this, GlobalContext* globalCtx) { - BgMoriBigst_SetupAction(this, NULL); -} - -void BgMoriBigst_SetupStalfosFight(BgMoriBigst* this, GlobalContext* globalCtx) { - Actor* stalfos; - - BgMoriBigst_SetupAction(this, BgMoriBigst_StalfosFight); - Flags_UnsetClear(globalCtx, this->dyna.actor.room); - stalfos = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_TEST, 209.0f, 827.0f, - -3320.0f, 0, 0, 0, 1); - if (stalfos != NULL) { - this->dyna.actor.child = NULL; - this->dyna.actor.home.rot.z++; - } else { - // "Second Stalfos failure" - osSyncPrintf("Warning : 第2スタルフォス発生失敗\n"); - } - Flags_SetClear(globalCtx, this->dyna.actor.room); -} - -void BgMoriBigst_StalfosFight(BgMoriBigst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((this->dyna.actor.home.rot.z == 0) && - ((this->dyna.actor.home.pos.y - 5.0f) <= GET_PLAYER(globalCtx)->actor.world.pos.y)) { - BgMoriBigst_SetupFall(this, globalCtx); - OnePointCutscene_Init(globalCtx, 3220, 72, &this->dyna.actor, MAIN_CAM); - } -} - -void BgMoriBigst_SetupFall(BgMoriBigst* this, GlobalContext* globalCtx) { - BgMoriBigst_SetupAction(this, BgMoriBigst_Fall); -} - -void BgMoriBigst_Fall(BgMoriBigst* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - BgMoriBigst_SetupLanding(this, globalCtx); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - OnePointCutscene_Init(globalCtx, 1020, 8, &this->dyna.actor, MAIN_CAM); - func_8002DF38(globalCtx, NULL, 0x3C); - } -} - -void BgMoriBigst_SetupLanding(BgMoriBigst* this, GlobalContext* globalCtx) { - s32 pad; - s32 quake; - - BgMoriBigst_SetupAction(this, BgMoriBigst_Landing); - this->waitTimer = 18; - quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quake, 25000); - Quake_SetQuakeValues(quake, 5, 0, 0, 0); - Quake_SetCountdown(quake, 16); -} - -void BgMoriBigst_Landing(BgMoriBigst* this, GlobalContext* globalCtx) { - if (this->waitTimer <= 0) { - BgMoriBigst_SetupStalfosPairFight(this, globalCtx); - } -} - -void BgMoriBigst_SetupStalfosPairFight(BgMoriBigst* this, GlobalContext* globalCtx) { - Actor* stalfos1; - Actor* stalfos2; - - BgMoriBigst_SetupAction(this, BgMoriBigst_StalfosPairFight); - Flags_UnsetClear(globalCtx, this->dyna.actor.room); - stalfos1 = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_TEST, 70.0f, 827.0f, - -3383.0f, 0, 0, 0, 5); - if (stalfos1 != NULL) { - this->dyna.actor.child = NULL; - this->dyna.actor.home.rot.z++; - } else { - // "Warning: 3-1 Stalfos failure" - osSyncPrintf("Warning : 第3-1スタルフォス発生失敗\n"); - } - stalfos2 = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_TEST, 170.0f, 827.0f, - -3260.0f, 0, 0, 0, 5); - if (stalfos2 != NULL) { - this->dyna.actor.child = NULL; - this->dyna.actor.home.rot.z++; - } else { - // "Warning: 3-2 Stalfos failure" - osSyncPrintf("Warning : 第3-2スタルフォス発生失敗\n"); - } - Flags_SetClear(globalCtx, this->dyna.actor.room); -} - -void BgMoriBigst_StalfosPairFight(BgMoriBigst* this, GlobalContext* globalCtx) { - if ((this->dyna.actor.home.rot.z == 0) && !Player_InCsMode(globalCtx)) { - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - BgMoriBigst_SetupDone(this, globalCtx); - } -} - -void BgMoriBigst_SetupDone(BgMoriBigst* this, GlobalContext* globalCtx) { - BgMoriBigst_SetupAction(this, NULL); -} - -void BgMoriBigst_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriBigst* this = (BgMoriBigst*)thisx; - - Actor_SetFocus(&this->dyna.actor, 50.0f); - if (this->waitTimer > 0) { - this->waitTimer--; - } - if (func_80043590(&this->dyna)) { - func_80074CE8(globalCtx, 6); - } - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } -} - -void BgMoriBigst_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriBigst* this = (BgMoriBigst*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_bigst.c", 541); - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_bigst.c", 548), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_OPA_DISP++, gMoriBigstDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_bigst.c", 553); -} diff --git a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.cpp b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.cpp new file mode 100644 index 000000000..b54ab0e13 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.cpp @@ -0,0 +1,269 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_BIGST_Z_BG_MORI_BIGST_C +#include "actor_common.h" +/* + * File: z_bg_mori_bigst.c + * Overlay: ovl_Bg_Mori_Bigst + * Description: Forest Temple falling platform and Stalfos fight + */ + +#include "z_bg_mori_bigst.h" +#include "objects/object_mori_objects/object_mori_objects.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_quake.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgMoriBigst_Init(Actor* thisx, GlobalContext* globalCtx); +void BgMoriBigst_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgMoriBigst_Update(Actor* thisx, GlobalContext* globalCtx); +void BgMoriBigst_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgMoriBigst_SetupWaitForMoriTex(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_WaitForMoriTex(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_SetupNoop(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_SetupStalfosFight(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_StalfosFight(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_SetupFall(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_Fall(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_SetupLanding(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_Landing(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_SetupStalfosPairFight(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_StalfosPairFight(BgMoriBigst* pthis, GlobalContext* globalCtx); +void BgMoriBigst_SetupDone(BgMoriBigst* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Mori_Bigst_InitVars = { + ACTOR_BG_MORI_BIGST, + ACTORCAT_BG, + FLAGS, + OBJECT_MORI_OBJECTS, + sizeof(BgMoriBigst), + (ActorFunc)BgMoriBigst_Init, + (ActorFunc)BgMoriBigst_Destroy, + (ActorFunc)BgMoriBigst_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(minVelocityY, -12000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +void BgMoriBigst_SetupAction(BgMoriBigst* pthis, BgMoriBigstActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void BgMoriBigst_InitDynapoly(BgMoriBigst* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, moveFlag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + // "Warning : move BG login failed" + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_bigst.c", 190, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgMoriBigst_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriBigst* pthis = (BgMoriBigst*)thisx; + + // "mori (bigST.keyceiling)" + osSyncPrintf("mori (bigST.鍵型天井)(arg : %04x)(sw %d)(noE %d)(roomC %d)(playerPosY %f)\n", pthis->dyna.actor.params, + Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F), + Flags_GetTempClear(globalCtx, pthis->dyna.actor.room), Flags_GetClear(globalCtx, pthis->dyna.actor.room), + GET_PLAYER(globalCtx)->actor.world.pos.y); + BgMoriBigst_InitDynapoly(pthis, globalCtx, &gMoriBigstCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + // "【Big Stalfos key ceiling】 bank danger!" + osSyncPrintf("【ビッグスタルフォス鍵型天井】 バンク危険!\n"); + osSyncPrintf("%s %d\n", "../z_bg_mori_bigst.c", 234); + Actor_Kill(&pthis->dyna.actor); + return; + } + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + } else { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + 270.0f; + } + Actor_SetFocus(&pthis->dyna.actor, 50.0f); + BgMoriBigst_SetupWaitForMoriTex(pthis, globalCtx); +} + +void BgMoriBigst_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriBigst* pthis = (BgMoriBigst*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgMoriBigst_SetupWaitForMoriTex(BgMoriBigst* pthis, GlobalContext* globalCtx) { + BgMoriBigst_SetupAction(pthis, BgMoriBigst_WaitForMoriTex); +} + +void BgMoriBigst_WaitForMoriTex(BgMoriBigst* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + thisx->draw = BgMoriBigst_Draw; + if (Flags_GetClear(globalCtx, thisx->room) && (GET_PLAYER(globalCtx)->actor.world.pos.y > 700.0f)) { + if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0x3F)) { + BgMoriBigst_SetupDone(pthis, globalCtx); + } else { + BgMoriBigst_SetupStalfosFight(pthis, globalCtx); + } + } else { + BgMoriBigst_SetupNoop(pthis, globalCtx); + } + } +} + +void BgMoriBigst_SetupNoop(BgMoriBigst* pthis, GlobalContext* globalCtx) { + BgMoriBigst_SetupAction(pthis, NULL); +} + +void BgMoriBigst_SetupStalfosFight(BgMoriBigst* pthis, GlobalContext* globalCtx) { + Actor* stalfos; + + BgMoriBigst_SetupAction(pthis, BgMoriBigst_StalfosFight); + Flags_UnsetClear(globalCtx, pthis->dyna.actor.room); + stalfos = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_TEST, 209.0f, 827.0f, + -3320.0f, 0, 0, 0, 1); + if (stalfos != NULL) { + pthis->dyna.actor.child = NULL; + pthis->dyna.actor.home.rot.z++; + } else { + // "Second Stalfos failure" + osSyncPrintf("Warning : 第2スタルフォス発生失敗\n"); + } + Flags_SetClear(globalCtx, pthis->dyna.actor.room); +} + +void BgMoriBigst_StalfosFight(BgMoriBigst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->dyna.actor.home.rot.z == 0) && + ((pthis->dyna.actor.home.pos.y - 5.0f) <= GET_PLAYER(globalCtx)->actor.world.pos.y)) { + BgMoriBigst_SetupFall(pthis, globalCtx); + OnePointCutscene_Init(globalCtx, 3220, 72, &pthis->dyna.actor, MAIN_CAM); + } +} + +void BgMoriBigst_SetupFall(BgMoriBigst* pthis, GlobalContext* globalCtx) { + BgMoriBigst_SetupAction(pthis, BgMoriBigst_Fall); +} + +void BgMoriBigst_Fall(BgMoriBigst* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + if (pthis->dyna.actor.world.pos.y <= pthis->dyna.actor.home.pos.y) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + BgMoriBigst_SetupLanding(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); + OnePointCutscene_Init(globalCtx, 1020, 8, &pthis->dyna.actor, MAIN_CAM); + func_8002DF38(globalCtx, NULL, 0x3C); + } +} + +void BgMoriBigst_SetupLanding(BgMoriBigst* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 quake; + + BgMoriBigst_SetupAction(pthis, BgMoriBigst_Landing); + pthis->waitTimer = 18; + quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(quake, 25000); + Quake_SetQuakeValues(quake, 5, 0, 0, 0); + Quake_SetCountdown(quake, 16); +} + +void BgMoriBigst_Landing(BgMoriBigst* pthis, GlobalContext* globalCtx) { + if (pthis->waitTimer <= 0) { + BgMoriBigst_SetupStalfosPairFight(pthis, globalCtx); + } +} + +void BgMoriBigst_SetupStalfosPairFight(BgMoriBigst* pthis, GlobalContext* globalCtx) { + Actor* stalfos1; + Actor* stalfos2; + + BgMoriBigst_SetupAction(pthis, BgMoriBigst_StalfosPairFight); + Flags_UnsetClear(globalCtx, pthis->dyna.actor.room); + stalfos1 = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_TEST, 70.0f, 827.0f, + -3383.0f, 0, 0, 0, 5); + if (stalfos1 != NULL) { + pthis->dyna.actor.child = NULL; + pthis->dyna.actor.home.rot.z++; + } else { + // "Warning: 3-1 Stalfos failure" + osSyncPrintf("Warning : 第3-1スタルフォス発生失敗\n"); + } + stalfos2 = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_TEST, 170.0f, 827.0f, + -3260.0f, 0, 0, 0, 5); + if (stalfos2 != NULL) { + pthis->dyna.actor.child = NULL; + pthis->dyna.actor.home.rot.z++; + } else { + // "Warning: 3-2 Stalfos failure" + osSyncPrintf("Warning : 第3-2スタルフォス発生失敗\n"); + } + Flags_SetClear(globalCtx, pthis->dyna.actor.room); +} + +void BgMoriBigst_StalfosPairFight(BgMoriBigst* pthis, GlobalContext* globalCtx) { + if ((pthis->dyna.actor.home.rot.z == 0) && !Player_InCsMode(globalCtx)) { + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + BgMoriBigst_SetupDone(pthis, globalCtx); + } +} + +void BgMoriBigst_SetupDone(BgMoriBigst* pthis, GlobalContext* globalCtx) { + BgMoriBigst_SetupAction(pthis, NULL); +} + +void BgMoriBigst_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriBigst* pthis = (BgMoriBigst*)thisx; + + Actor_SetFocus(&pthis->dyna.actor, 50.0f); + if (pthis->waitTimer > 0) { + pthis->waitTimer--; + } + if (func_80043590(&pthis->dyna)) { + func_80074CE8(globalCtx, 6); + } + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } +} + +void BgMoriBigst_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriBigst* pthis = (BgMoriBigst*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_bigst.c", 541); + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_bigst.c", 548), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gMoriBigstDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_bigst.c", 553); +} diff --git a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c deleted file mode 100644 index 7a2dba5a4..000000000 --- a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c +++ /dev/null @@ -1,274 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_ELEVATOR_Z_BG_MORI_ELEVATOR_C -#include "actor_common.h" -#include "z_bg_mori_elevator.h" -#include "objects/object_mori_objects/object_mori_objects.h" -#include "def/code_80043480.h" -#include "def/code_800EC960.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgMoriElevator_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMoriElevator_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMoriElevator_Update(Actor* thisx, GlobalContext* globalCtx); - -void BgMoriElevator_SetupWaitAfterInit(BgMoriElevator* this); -void BgMoriElevator_WaitAfterInit(BgMoriElevator* this, GlobalContext* globalCtx); -void BgMoriElevator_SetupSetPosition(BgMoriElevator* this); -void BgMoriElevator_SetPosition(BgMoriElevator* this, GlobalContext* globalCtx); -void BgMoriElevator_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgMoriElevator_StopMovement(BgMoriElevator* this); -void func_808A2008(BgMoriElevator* this, GlobalContext* globalCtx); -void BgMoriElevator_MoveIntoGround(BgMoriElevator* this, GlobalContext* globalCtx); -void BgMoriElevator_MoveAboveGround(BgMoriElevator* this, GlobalContext* globalCtx); - -static s16 sIsSpawned = false; - -const ActorInit Bg_Mori_Elevator_InitVars = { - ACTOR_BG_MORI_ELEVATOR, - ACTORCAT_BG, - FLAGS, - OBJECT_MORI_OBJECTS, - sizeof(BgMoriElevator), - (ActorFunc)BgMoriElevator_Init, - (ActorFunc)BgMoriElevator_Destroy, - (ActorFunc)BgMoriElevator_Update, - NULL, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 3000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -f32 func_808A1800(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) { - f32 var = (target - *pValue) * scale; - - if (*pValue < target) { - if (maxStep < var) { - var = maxStep; - } else { - if (var < minStep) { - var = minStep; - } - } - *pValue = (*pValue + var); - - if (target < *pValue) { - *pValue = target; - } - } else { - if (target < *pValue) { - if (var < (-maxStep)) { - var = (-maxStep); - } else { - if ((-minStep) < var) { - var = (-minStep); - } - } - *pValue = (*pValue + var); - if (*pValue < target) { - *pValue = target; - } - } else { - var = 0.0f; - } - } - return var; -} - -void func_808A18FC(BgMoriElevator* this, f32 distTo) { - f32 temp; - - temp = fabsf(distTo) * 0.09f; - func_800F436C(&this->dyna.actor.projectedPos, NA_SE_EV_ELEVATOR_MOVE2 - SFX_FLAG, CLAMP(temp, 0.0f, 1.0f)); -} - -void BgMoriElevator_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMoriElevator* this = (BgMoriElevator*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - this->unk_172 = sIsSpawned; - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - Actor_Kill(thisx); - // "Forest Temple obj elevator Bank Danger!" - osSyncPrintf("Error : 森の神殿 obj elevator バンク危険!(%s %d)\n", "../z_bg_mori_elevator.c", 277); - } else { - switch (sIsSpawned) { - case false: - // "Forest Temple elevator CT" - osSyncPrintf("森の神殿 elevator CT\n"); - sIsSpawned = true; - this->dyna.actor.room = -1; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(&gMoriElevatorCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - BgMoriElevator_SetupWaitAfterInit(this); - break; - case true: - Actor_Kill(thisx); - break; - } - } -} - -void BgMoriElevator_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMoriElevator* this = (BgMoriElevator*)thisx; - - if (this->unk_172 == 0) { - // "Forest Temple elevator DT" - osSyncPrintf("森の神殿 elevator DT\n"); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - sIsSpawned = false; - } -} - -s32 BgMoriElevator_IsPlayerRiding(BgMoriElevator* this, GlobalContext* globalCtx) { - return ((this->dyna.unk_160 & 2) && !(this->unk_170 & 2) && - ((GET_PLAYER(globalCtx)->actor.world.pos.y - this->dyna.actor.world.pos.y) < 80.0f)); -} - -void BgMoriElevator_SetupWaitAfterInit(BgMoriElevator* this) { - this->actionFunc = BgMoriElevator_WaitAfterInit; -} - -void BgMoriElevator_WaitAfterInit(BgMoriElevator* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - if (globalCtx->roomCtx.curRoom.num == 2) { - this->dyna.actor.world.pos.y = 73.0f; - BgMoriElevator_SetupSetPosition(this); - } else { - // "Error: Forest Temple obj elevator Room setting is dangerous" - osSyncPrintf("Error : 森の神殿 obj elevator 部屋設定が危険(%s %d)\n", "../z_bg_mori_elevator.c", 371); - } - } else { - BgMoriElevator_SetupSetPosition(this); - } - this->dyna.actor.draw = BgMoriElevator_Draw; - } -} - -void func_808A1C30(BgMoriElevator* this) { - this->actionFunc = BgMoriElevator_MoveIntoGround; -} - -void BgMoriElevator_MoveIntoGround(BgMoriElevator* this, GlobalContext* globalCtx) { - f32 distToTarget; - - func_808A1800(&this->dyna.actor.velocity.y, 2.0f, 0.05f, 1.0f, 0.0f); - distToTarget = func_808A1800(&this->dyna.actor.world.pos.y, 73.0f, 0.08f, this->dyna.actor.velocity.y, 1.5f); - if (fabsf(distToTarget) < 0.001f) { - BgMoriElevator_SetupSetPosition(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ELEVATOR_STOP); - } else { - func_808A18FC(this, distToTarget); - } -} - -void func_808A1CF4(BgMoriElevator* this, GlobalContext* globalCtx) { - this->actionFunc = BgMoriElevator_MoveAboveGround; - OnePointCutscene_Init(globalCtx, 3230, 70, &this->dyna.actor, MAIN_CAM); - OnePointCutscene_Init(globalCtx, 1020, 15, &this->dyna.actor, MAIN_CAM); -} - -void BgMoriElevator_MoveAboveGround(BgMoriElevator* this, GlobalContext* globalCtx) { - f32 distToTarget; - - func_808A1800(&this->dyna.actor.velocity.y, 2.0f, 0.05f, 1.0f, 0.0f); - distToTarget = func_808A1800(&this->dyna.actor.world.pos.y, 233.0f, 0.08f, this->dyna.actor.velocity.y, 1.5f); - if (fabsf(distToTarget) < 0.001f) { - BgMoriElevator_SetupSetPosition(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ELEVATOR_STOP); - } else { - func_808A18FC(this, distToTarget); - } -} - -void BgMoriElevator_SetupSetPosition(BgMoriElevator* this) { - this->actionFunc = BgMoriElevator_SetPosition; -} - -void BgMoriElevator_SetPosition(BgMoriElevator* this, GlobalContext* globalCtx) { - s32 pad; - - if (BgMoriElevator_IsPlayerRiding(this, globalCtx)) { - if (globalCtx->roomCtx.curRoom.num == 2) { - this->targetY = -779.0f; - BgMoriElevator_StopMovement(this); - } else if (globalCtx->roomCtx.curRoom.num == 17) { - this->targetY = 233.0f; - BgMoriElevator_StopMovement(this); - } else { - // "Error:Forest Temple obj elevator Room setting is dangerous(%s %d)" - osSyncPrintf("Error : 森の神殿 obj elevator 部屋設定が危険(%s %d)\n", "../z_bg_mori_elevator.c", 479); - } - } else if ((globalCtx->roomCtx.curRoom.num == 2) && (this->dyna.actor.world.pos.y < -275.0f)) { - this->targetY = 233.0f; - BgMoriElevator_StopMovement(this); - } else if ((globalCtx->roomCtx.curRoom.num == 17) && (-275.0f < this->dyna.actor.world.pos.y)) { - this->targetY = -779.0f; - BgMoriElevator_StopMovement(this); - } else if ((globalCtx->roomCtx.curRoom.num == 2) && Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) && - (this->unk_16C == 0)) { - this->targetY = 73.0f; - func_808A1C30(this); - } else if ((globalCtx->roomCtx.curRoom.num == 2) && !Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) && - (this->unk_16C != 0)) { - this->targetY = 233.0f; - func_808A1CF4(this, globalCtx); - } -} - -void BgMoriElevator_StopMovement(BgMoriElevator* this) { - this->actionFunc = func_808A2008; - this->dyna.actor.velocity.y = 0.0f; -} - -void func_808A2008(BgMoriElevator* this, GlobalContext* globalCtx) { - f32 distTo; - - func_808A1800(&this->dyna.actor.velocity.y, 12.0f, 0.1f, 1.0f, 0.0f); - distTo = func_808A1800(&this->dyna.actor.world.pos.y, this->targetY, 0.1f, this->dyna.actor.velocity.y, 0.3f); - if (fabsf(distTo) < 0.001f) { - BgMoriElevator_SetupSetPosition(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ELEVATOR_STOP); - - } else { - func_808A18FC(this, distTo); - } -} - -void BgMoriElevator_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMoriElevator* this = (BgMoriElevator*)thisx; - - this->actionFunc(this, globalCtx); - this->unk_170 = this->dyna.unk_160; - this->unk_16C = Flags_GetSwitch(globalCtx, (thisx->params & 0x3F)); -} - -void BgMoriElevator_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriElevator* this = (BgMoriElevator*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_elevator.c", 575); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_elevator.c", 580), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gMoriElevatorDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_elevator.c", 584); -} diff --git a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.cpp b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.cpp new file mode 100644 index 000000000..1a6ff5fd2 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.cpp @@ -0,0 +1,274 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_ELEVATOR_Z_BG_MORI_ELEVATOR_C +#include "actor_common.h" +#include "z_bg_mori_elevator.h" +#include "objects/object_mori_objects/object_mori_objects.h" +#include "def/code_80043480.h" +#include "def/code_800EC960.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgMoriElevator_Init(Actor* thisx, GlobalContext* globalCtx); +void BgMoriElevator_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgMoriElevator_Update(Actor* thisx, GlobalContext* globalCtx); + +void BgMoriElevator_SetupWaitAfterInit(BgMoriElevator* pthis); +void BgMoriElevator_WaitAfterInit(BgMoriElevator* pthis, GlobalContext* globalCtx); +void BgMoriElevator_SetupSetPosition(BgMoriElevator* pthis); +void BgMoriElevator_SetPosition(BgMoriElevator* pthis, GlobalContext* globalCtx); +void BgMoriElevator_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgMoriElevator_StopMovement(BgMoriElevator* pthis); +void func_808A2008(BgMoriElevator* pthis, GlobalContext* globalCtx); +void BgMoriElevator_MoveIntoGround(BgMoriElevator* pthis, GlobalContext* globalCtx); +void BgMoriElevator_MoveAboveGround(BgMoriElevator* pthis, GlobalContext* globalCtx); + +static s16 sIsSpawned = false; + +ActorInit Bg_Mori_Elevator_InitVars = { + ACTOR_BG_MORI_ELEVATOR, + ACTORCAT_BG, + FLAGS, + OBJECT_MORI_OBJECTS, + sizeof(BgMoriElevator), + (ActorFunc)BgMoriElevator_Init, + (ActorFunc)BgMoriElevator_Destroy, + (ActorFunc)BgMoriElevator_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 3000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +f32 func_808A1800(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) { + f32 var = (target - *pValue) * scale; + + if (*pValue < target) { + if (maxStep < var) { + var = maxStep; + } else { + if (var < minStep) { + var = minStep; + } + } + *pValue = (*pValue + var); + + if (target < *pValue) { + *pValue = target; + } + } else { + if (target < *pValue) { + if (var < (-maxStep)) { + var = (-maxStep); + } else { + if ((-minStep) < var) { + var = (-minStep); + } + } + *pValue = (*pValue + var); + if (*pValue < target) { + *pValue = target; + } + } else { + var = 0.0f; + } + } + return var; +} + +void func_808A18FC(BgMoriElevator* pthis, f32 distTo) { + f32 temp; + + temp = fabsf(distTo) * 0.09f; + func_800F436C(&pthis->dyna.actor.projectedPos, NA_SE_EV_ELEVATOR_MOVE2 - SFX_FLAG, CLAMP(temp, 0.0f, 1.0f)); +} + +void BgMoriElevator_Init(Actor* thisx, GlobalContext* globalCtx) { + BgMoriElevator* pthis = (BgMoriElevator*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + pthis->unk_172 = sIsSpawned; + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + Actor_Kill(thisx); + // "Forest Temple obj elevator Bank Danger!" + osSyncPrintf("Error : 森の神殿 obj elevator バンク危険!(%s %d)\n", "../z_bg_mori_elevator.c", 277); + } else { + switch (sIsSpawned) { + case false: + // "Forest Temple elevator CT" + osSyncPrintf("森の神殿 elevator CT\n"); + sIsSpawned = true; + pthis->dyna.actor.room = -1; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(&gMoriElevatorCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + BgMoriElevator_SetupWaitAfterInit(pthis); + break; + case true: + Actor_Kill(thisx); + break; + } + } +} + +void BgMoriElevator_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgMoriElevator* pthis = (BgMoriElevator*)thisx; + + if (pthis->unk_172 == 0) { + // "Forest Temple elevator DT" + osSyncPrintf("森の神殿 elevator DT\n"); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + sIsSpawned = false; + } +} + +s32 BgMoriElevator_IsPlayerRiding(BgMoriElevator* pthis, GlobalContext* globalCtx) { + return ((pthis->dyna.unk_160 & 2) && !(pthis->unk_170 & 2) && + ((GET_PLAYER(globalCtx)->actor.world.pos.y - pthis->dyna.actor.world.pos.y) < 80.0f)); +} + +void BgMoriElevator_SetupWaitAfterInit(BgMoriElevator* pthis) { + pthis->actionFunc = BgMoriElevator_WaitAfterInit; +} + +void BgMoriElevator_WaitAfterInit(BgMoriElevator* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + if (globalCtx->roomCtx.curRoom.num == 2) { + pthis->dyna.actor.world.pos.y = 73.0f; + BgMoriElevator_SetupSetPosition(pthis); + } else { + // "Error: Forest Temple obj elevator Room setting is dangerous" + osSyncPrintf("Error : 森の神殿 obj elevator 部屋設定が危険(%s %d)\n", "../z_bg_mori_elevator.c", 371); + } + } else { + BgMoriElevator_SetupSetPosition(pthis); + } + pthis->dyna.actor.draw = BgMoriElevator_Draw; + } +} + +void func_808A1C30(BgMoriElevator* pthis) { + pthis->actionFunc = BgMoriElevator_MoveIntoGround; +} + +void BgMoriElevator_MoveIntoGround(BgMoriElevator* pthis, GlobalContext* globalCtx) { + f32 distToTarget; + + func_808A1800(&pthis->dyna.actor.velocity.y, 2.0f, 0.05f, 1.0f, 0.0f); + distToTarget = func_808A1800(&pthis->dyna.actor.world.pos.y, 73.0f, 0.08f, pthis->dyna.actor.velocity.y, 1.5f); + if (fabsf(distToTarget) < 0.001f) { + BgMoriElevator_SetupSetPosition(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_STOP); + } else { + func_808A18FC(pthis, distToTarget); + } +} + +void func_808A1CF4(BgMoriElevator* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BgMoriElevator_MoveAboveGround; + OnePointCutscene_Init(globalCtx, 3230, 70, &pthis->dyna.actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 1020, 15, &pthis->dyna.actor, MAIN_CAM); +} + +void BgMoriElevator_MoveAboveGround(BgMoriElevator* pthis, GlobalContext* globalCtx) { + f32 distToTarget; + + func_808A1800(&pthis->dyna.actor.velocity.y, 2.0f, 0.05f, 1.0f, 0.0f); + distToTarget = func_808A1800(&pthis->dyna.actor.world.pos.y, 233.0f, 0.08f, pthis->dyna.actor.velocity.y, 1.5f); + if (fabsf(distToTarget) < 0.001f) { + BgMoriElevator_SetupSetPosition(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_STOP); + } else { + func_808A18FC(pthis, distToTarget); + } +} + +void BgMoriElevator_SetupSetPosition(BgMoriElevator* pthis) { + pthis->actionFunc = BgMoriElevator_SetPosition; +} + +void BgMoriElevator_SetPosition(BgMoriElevator* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (BgMoriElevator_IsPlayerRiding(pthis, globalCtx)) { + if (globalCtx->roomCtx.curRoom.num == 2) { + pthis->targetY = -779.0f; + BgMoriElevator_StopMovement(pthis); + } else if (globalCtx->roomCtx.curRoom.num == 17) { + pthis->targetY = 233.0f; + BgMoriElevator_StopMovement(pthis); + } else { + // "Error:Forest Temple obj elevator Room setting is dangerous(%s %d)" + osSyncPrintf("Error : 森の神殿 obj elevator 部屋設定が危険(%s %d)\n", "../z_bg_mori_elevator.c", 479); + } + } else if ((globalCtx->roomCtx.curRoom.num == 2) && (pthis->dyna.actor.world.pos.y < -275.0f)) { + pthis->targetY = 233.0f; + BgMoriElevator_StopMovement(pthis); + } else if ((globalCtx->roomCtx.curRoom.num == 17) && (-275.0f < pthis->dyna.actor.world.pos.y)) { + pthis->targetY = -779.0f; + BgMoriElevator_StopMovement(pthis); + } else if ((globalCtx->roomCtx.curRoom.num == 2) && Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F) && + (pthis->unk_16C == 0)) { + pthis->targetY = 73.0f; + func_808A1C30(pthis); + } else if ((globalCtx->roomCtx.curRoom.num == 2) && !Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F) && + (pthis->unk_16C != 0)) { + pthis->targetY = 233.0f; + func_808A1CF4(pthis, globalCtx); + } +} + +void BgMoriElevator_StopMovement(BgMoriElevator* pthis) { + pthis->actionFunc = func_808A2008; + pthis->dyna.actor.velocity.y = 0.0f; +} + +void func_808A2008(BgMoriElevator* pthis, GlobalContext* globalCtx) { + f32 distTo; + + func_808A1800(&pthis->dyna.actor.velocity.y, 12.0f, 0.1f, 1.0f, 0.0f); + distTo = func_808A1800(&pthis->dyna.actor.world.pos.y, pthis->targetY, 0.1f, pthis->dyna.actor.velocity.y, 0.3f); + if (fabsf(distTo) < 0.001f) { + BgMoriElevator_SetupSetPosition(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_STOP); + + } else { + func_808A18FC(pthis, distTo); + } +} + +void BgMoriElevator_Update(Actor* thisx, GlobalContext* globalCtx) { + BgMoriElevator* pthis = (BgMoriElevator*)thisx; + + pthis->actionFunc(pthis, globalCtx); + pthis->unk_170 = pthis->dyna.unk_160; + pthis->unk_16C = Flags_GetSwitch(globalCtx, (thisx->params & 0x3F)); +} + +void BgMoriElevator_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriElevator* pthis = (BgMoriElevator*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_elevator.c", 575); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_elevator.c", 580), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gMoriElevatorDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_elevator.c", 584); +} diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c deleted file mode 100644 index 2973c6fb8..000000000 --- a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c +++ /dev/null @@ -1,311 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_HASHIGO_Z_BG_MORI_HASHIGO_C -#include "actor_common.h" -/* - * File: z_bg_mori_hashigo.c - * Overlay: ovl_Bg_Mori_Hashigo - * Description: Falling ladder and clasp that holds it. Unused. - */ - -#include "z_bg_mori_hashigo.h" -#include "objects/object_mori_objects/object_mori_objects.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS 0 - -void BgMoriHashigo_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHashigo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHashigo_Update(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHashigo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgMoriHashigo_SetupWaitForMoriTex(BgMoriHashigo* this); -void BgMoriHashigo_WaitForMoriTex(BgMoriHashigo* this, GlobalContext* globalCtx); -void BgMoriHashigo_SetupClasp(BgMoriHashigo* this); -void BgMoriHashigo_Clasp(BgMoriHashigo* this, GlobalContext* globalCtx); -void BgMoriHashigo_SetupLadderWait(BgMoriHashigo* this); -void BgMoriHashigo_LadderWait(BgMoriHashigo* this, GlobalContext* globalCtx); -void BgMoriHashigo_SetupLadderFall(BgMoriHashigo* this); -void BgMoriHashigo_LadderFall(BgMoriHashigo* this, GlobalContext* globalCtx); -void BgMoriHashigo_SetupLadderRest(BgMoriHashigo* this); - -const ActorInit Bg_Mori_Hashigo_InitVars = { - ACTOR_BG_MORI_HASHIGO, - ACTORCAT_BG, - FLAGS, - OBJECT_MORI_OBJECTS, - sizeof(BgMoriHashigo), - (ActorFunc)BgMoriHashigo_Init, - (ActorFunc)BgMoriHashigo_Destroy, - (ActorFunc)BgMoriHashigo_Update, - NULL, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK4, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F820, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 0, { { 0, 0, 0 }, 25 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static InitChainEntry sInitChainClasp[] = { - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 3, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 40, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainLadder[] = { - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -void BgMoriHashigo_InitDynapoly(BgMoriHashigo* this, GlobalContext* globalCtx, CollisionHeader* collision, - s32 moveFlag) { - s32 pad; - CollisionHeader* colHeader; - s32 pad2; - - colHeader = NULL; - DynaPolyActor_Init(&this->dyna, moveFlag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - // "Warning : move BG login failed" - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashigo.c", 164, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgMoriHashigo_InitCollider(BgMoriHashigo* this, GlobalContext* globalCtx) { - s32 pad; - - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderItems); - - this->collider.elements[0].dim.worldSphere.center.x = (s16)this->dyna.actor.world.pos.x; - this->collider.elements[0].dim.worldSphere.center.y = (s16)this->dyna.actor.world.pos.y + 21; - this->collider.elements[0].dim.worldSphere.center.z = (s16)this->dyna.actor.world.pos.z; - this->collider.elements[0].dim.worldSphere.radius = 19; -} - -s32 BgMoriHashigo_SpawnLadder(BgMoriHashigo* this, GlobalContext* globalCtx) { - f32 sn; - f32 cs; - Vec3f pos; - Actor* ladder; - - cs = Math_CosS(this->dyna.actor.shape.rot.y); - sn = Math_SinS(this->dyna.actor.shape.rot.y); - - pos.x = 6.0f * sn + this->dyna.actor.world.pos.x; - pos.y = -210.0f + this->dyna.actor.world.pos.y; - pos.z = 6.0f * cs + this->dyna.actor.world.pos.z; - - ladder = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_MORI_HASHIGO, pos.x, pos.y, - pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, - this->dyna.actor.world.rot.z, 0); - if (ladder != NULL) { - return true; - } else { - // "Ladder failure" - osSyncPrintf("Error : 梯子の発生失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashigo.c", 220, - this->dyna.actor.params); - return false; - } -} - -s32 BgMoriHashigo_InitClasp(BgMoriHashigo* this, GlobalContext* globalCtx) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChainClasp); - this->dyna.actor.flags |= ACTOR_FLAG_0; - Actor_SetFocus(&this->dyna.actor, 55.0f); - BgMoriHashigo_InitCollider(this, globalCtx); - if ((this->dyna.actor.params == HASHIGO_CLASP) && !BgMoriHashigo_SpawnLadder(this, globalCtx)) { - return false; - } else { - return true; - } -} - -s32 BgMoriHashigo_InitLadder(BgMoriHashigo* this, GlobalContext* globalCtx) { - BgMoriHashigo_InitDynapoly(this, globalCtx, &gMoriHashigoCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChainLadder); - return true; -} - -void BgMoriHashigo_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashigo* this = (BgMoriHashigo*)thisx; - - if (this->dyna.actor.params == HASHIGO_CLASP) { - if (!BgMoriHashigo_InitClasp(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - return; - } - } else if (this->dyna.actor.params == HASHIGO_LADDER) { - if (!BgMoriHashigo_InitLadder(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - return; - } - } - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - // "Bank danger!" - osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->dyna.actor.params, - "../z_bg_mori_hashigo.c", 312); - Actor_Kill(&this->dyna.actor); - } else { - BgMoriHashigo_SetupWaitForMoriTex(this); - // "(Forest Temple Ladder and its clasp)" - osSyncPrintf("(森の神殿 梯子とその留め金)(arg_data 0x%04x)\n", this->dyna.actor.params); - } -} - -void BgMoriHashigo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashigo* this = (BgMoriHashigo*)thisx; - - if (this->dyna.actor.params == HASHIGO_LADDER) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } - if (this->dyna.actor.params == HASHIGO_CLASP) { - Collider_DestroyJntSph(globalCtx, &this->collider); - } -} - -void BgMoriHashigo_SetupWaitForMoriTex(BgMoriHashigo* this) { - this->actionFunc = BgMoriHashigo_WaitForMoriTex; -} - -void BgMoriHashigo_WaitForMoriTex(BgMoriHashigo* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - if (this->dyna.actor.params == HASHIGO_CLASP) { - BgMoriHashigo_SetupClasp(this); - } else if (this->dyna.actor.params == HASHIGO_LADDER) { - BgMoriHashigo_SetupLadderWait(this); - } - this->dyna.actor.draw = BgMoriHashigo_Draw; - } -} - -void BgMoriHashigo_SetupClasp(BgMoriHashigo* this) { - this->actionFunc = BgMoriHashigo_Clasp; -} - -void BgMoriHashigo_Clasp(BgMoriHashigo* this, GlobalContext* globalCtx) { - if (this->hitTimer <= 0) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - this->hitTimer = 10; - } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -void BgMoriHashigo_SetupLadderWait(BgMoriHashigo* this) { - this->actionFunc = BgMoriHashigo_LadderWait; -} - -void BgMoriHashigo_LadderWait(BgMoriHashigo* this, GlobalContext* globalCtx) { - BgMoriHashigo* clasp = (BgMoriHashigo*)this->dyna.actor.parent; - - if (clasp->hitTimer > 0) { - BgMoriHashigo_SetupLadderFall(this); - } -} - -void BgMoriHashigo_SetupLadderFall(BgMoriHashigo* this) { - this->bounceCounter = 0; - this->actionFunc = BgMoriHashigo_LadderFall; - this->dyna.actor.gravity = -1.0f; - this->dyna.actor.minVelocityY = -10.0f; - this->dyna.actor.velocity.y = 2.0f; -} - -void BgMoriHashigo_LadderFall(BgMoriHashigo* this, GlobalContext* globalCtx) { - static f32 bounceSpeed[3] = { 4.0f, 2.7f, 1.7f }; - Actor* thisx = &this->dyna.actor; - - Actor_MoveForward(thisx); - if ((thisx->bgCheckFlags & 1) && (thisx->velocity.y < 0.0f)) { - if (this->bounceCounter >= ARRAY_COUNT(bounceSpeed)) { - BgMoriHashigo_SetupLadderRest(this); - } else { - Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 0x1C); - thisx->velocity.y = bounceSpeed[this->bounceCounter]; - this->bounceCounter++; - } - } else { - Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 0x1C); - } -} - -void BgMoriHashigo_SetupLadderRest(BgMoriHashigo* this) { - this->actionFunc = NULL; - this->dyna.actor.gravity = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; -} - -void BgMoriHashigo_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashigo* this = (BgMoriHashigo*)thisx; - - if (this->hitTimer > 0) { - this->hitTimer--; - } - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } -} - -void BgMoriHashigo_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashigo* this = (BgMoriHashigo*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashigo.c", 516); - func_80093D18(globalCtx->state.gfxCtx); - if (1) {} - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hashigo.c", 521), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - switch (this->dyna.actor.params) { - case HASHIGO_CLASP: - gSPDisplayList(POLY_OPA_DISP++, gMoriHashigoClaspDL); - break; - case HASHIGO_LADDER: - gSPDisplayList(POLY_OPA_DISP++, gMoriHashigoLadderDL); - break; - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashigo.c", 531); -} diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.cpp b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.cpp new file mode 100644 index 000000000..d63172b8d --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.cpp @@ -0,0 +1,311 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_HASHIGO_Z_BG_MORI_HASHIGO_C +#include "actor_common.h" +/* + * File: z_bg_mori_hashigo.c + * Overlay: ovl_Bg_Mori_Hashigo + * Description: Falling ladder and clasp that holds it. Unused. + */ + +#include "z_bg_mori_hashigo.h" +#include "objects/object_mori_objects/object_mori_objects.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS 0 + +void BgMoriHashigo_Init(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHashigo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHashigo_Update(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHashigo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgMoriHashigo_SetupWaitForMoriTex(BgMoriHashigo* pthis); +void BgMoriHashigo_WaitForMoriTex(BgMoriHashigo* pthis, GlobalContext* globalCtx); +void BgMoriHashigo_SetupClasp(BgMoriHashigo* pthis); +void BgMoriHashigo_Clasp(BgMoriHashigo* pthis, GlobalContext* globalCtx); +void BgMoriHashigo_SetupLadderWait(BgMoriHashigo* pthis); +void BgMoriHashigo_LadderWait(BgMoriHashigo* pthis, GlobalContext* globalCtx); +void BgMoriHashigo_SetupLadderFall(BgMoriHashigo* pthis); +void BgMoriHashigo_LadderFall(BgMoriHashigo* pthis, GlobalContext* globalCtx); +void BgMoriHashigo_SetupLadderRest(BgMoriHashigo* pthis); + +ActorInit Bg_Mori_Hashigo_InitVars = { + ACTOR_BG_MORI_HASHIGO, + ACTORCAT_BG, + FLAGS, + OBJECT_MORI_OBJECTS, + sizeof(BgMoriHashigo), + (ActorFunc)BgMoriHashigo_Init, + (ActorFunc)BgMoriHashigo_Destroy, + (ActorFunc)BgMoriHashigo_Update, + NULL, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F820, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 0, { { 0, 0, 0 }, 25 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static InitChainEntry sInitChainClasp[] = { + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 3, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 40, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +static InitChainEntry sInitChainLadder[] = { + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +void BgMoriHashigo_InitDynapoly(BgMoriHashigo* pthis, GlobalContext* globalCtx, CollisionHeader* collision, + s32 moveFlag) { + s32 pad; + CollisionHeader* colHeader; + s32 pad2; + + colHeader = NULL; + DynaPolyActor_Init(&pthis->dyna, moveFlag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + // "Warning : move BG login failed" + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashigo.c", 164, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgMoriHashigo_InitCollider(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + s32 pad; + + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->colliderItems); + + pthis->collider.elements[0].dim.worldSphere.center.x = (s16)pthis->dyna.actor.world.pos.x; + pthis->collider.elements[0].dim.worldSphere.center.y = (s16)pthis->dyna.actor.world.pos.y + 21; + pthis->collider.elements[0].dim.worldSphere.center.z = (s16)pthis->dyna.actor.world.pos.z; + pthis->collider.elements[0].dim.worldSphere.radius = 19; +} + +s32 BgMoriHashigo_SpawnLadder(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + f32 sn; + f32 cs; + Vec3f pos; + Actor* ladder; + + cs = Math_CosS(pthis->dyna.actor.shape.rot.y); + sn = Math_SinS(pthis->dyna.actor.shape.rot.y); + + pos.x = 6.0f * sn + pthis->dyna.actor.world.pos.x; + pos.y = -210.0f + pthis->dyna.actor.world.pos.y; + pos.z = 6.0f * cs + pthis->dyna.actor.world.pos.z; + + ladder = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_MORI_HASHIGO, pos.x, pos.y, + pos.z, pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, + pthis->dyna.actor.world.rot.z, 0); + if (ladder != NULL) { + return true; + } else { + // "Ladder failure" + osSyncPrintf("Error : 梯子の発生失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashigo.c", 220, + pthis->dyna.actor.params); + return false; + } +} + +s32 BgMoriHashigo_InitClasp(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChainClasp); + pthis->dyna.actor.flags |= ACTOR_FLAG_0; + Actor_SetFocus(&pthis->dyna.actor, 55.0f); + BgMoriHashigo_InitCollider(pthis, globalCtx); + if ((pthis->dyna.actor.params == HASHIGO_CLASP) && !BgMoriHashigo_SpawnLadder(pthis, globalCtx)) { + return false; + } else { + return true; + } +} + +s32 BgMoriHashigo_InitLadder(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + BgMoriHashigo_InitDynapoly(pthis, globalCtx, &gMoriHashigoCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChainLadder); + return true; +} + +void BgMoriHashigo_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashigo* pthis = (BgMoriHashigo*)thisx; + + if (pthis->dyna.actor.params == HASHIGO_CLASP) { + if (!BgMoriHashigo_InitClasp(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + return; + } + } else if (pthis->dyna.actor.params == HASHIGO_LADDER) { + if (!BgMoriHashigo_InitLadder(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + return; + } + } + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + // "Bank danger!" + osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", pthis->dyna.actor.params, + "../z_bg_mori_hashigo.c", 312); + Actor_Kill(&pthis->dyna.actor); + } else { + BgMoriHashigo_SetupWaitForMoriTex(pthis); + // "(Forest Temple Ladder and its clasp)" + osSyncPrintf("(森の神殿 梯子とその留め金)(arg_data 0x%04x)\n", pthis->dyna.actor.params); + } +} + +void BgMoriHashigo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashigo* pthis = (BgMoriHashigo*)thisx; + + if (pthis->dyna.actor.params == HASHIGO_LADDER) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } + if (pthis->dyna.actor.params == HASHIGO_CLASP) { + Collider_DestroyJntSph(globalCtx, &pthis->collider); + } +} + +void BgMoriHashigo_SetupWaitForMoriTex(BgMoriHashigo* pthis) { + pthis->actionFunc = BgMoriHashigo_WaitForMoriTex; +} + +void BgMoriHashigo_WaitForMoriTex(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + if (pthis->dyna.actor.params == HASHIGO_CLASP) { + BgMoriHashigo_SetupClasp(pthis); + } else if (pthis->dyna.actor.params == HASHIGO_LADDER) { + BgMoriHashigo_SetupLadderWait(pthis); + } + pthis->dyna.actor.draw = BgMoriHashigo_Draw; + } +} + +void BgMoriHashigo_SetupClasp(BgMoriHashigo* pthis) { + pthis->actionFunc = BgMoriHashigo_Clasp; +} + +void BgMoriHashigo_Clasp(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + if (pthis->hitTimer <= 0) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->hitTimer = 10; + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +void BgMoriHashigo_SetupLadderWait(BgMoriHashigo* pthis) { + pthis->actionFunc = BgMoriHashigo_LadderWait; +} + +void BgMoriHashigo_LadderWait(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + BgMoriHashigo* clasp = (BgMoriHashigo*)pthis->dyna.actor.parent; + + if (clasp->hitTimer > 0) { + BgMoriHashigo_SetupLadderFall(pthis); + } +} + +void BgMoriHashigo_SetupLadderFall(BgMoriHashigo* pthis) { + pthis->bounceCounter = 0; + pthis->actionFunc = BgMoriHashigo_LadderFall; + pthis->dyna.actor.gravity = -1.0f; + pthis->dyna.actor.minVelocityY = -10.0f; + pthis->dyna.actor.velocity.y = 2.0f; +} + +void BgMoriHashigo_LadderFall(BgMoriHashigo* pthis, GlobalContext* globalCtx) { + static f32 bounceSpeed[3] = { 4.0f, 2.7f, 1.7f }; + Actor* thisx = &pthis->dyna.actor; + + Actor_MoveForward(thisx); + if ((thisx->bgCheckFlags & 1) && (thisx->velocity.y < 0.0f)) { + if (pthis->bounceCounter >= ARRAY_COUNT(bounceSpeed)) { + BgMoriHashigo_SetupLadderRest(pthis); + } else { + Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 0x1C); + thisx->velocity.y = bounceSpeed[pthis->bounceCounter]; + pthis->bounceCounter++; + } + } else { + Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 0x1C); + } +} + +void BgMoriHashigo_SetupLadderRest(BgMoriHashigo* pthis) { + pthis->actionFunc = NULL; + pthis->dyna.actor.gravity = 0.0f; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; +} + +void BgMoriHashigo_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashigo* pthis = (BgMoriHashigo*)thisx; + + if (pthis->hitTimer > 0) { + pthis->hitTimer--; + } + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } +} + +void BgMoriHashigo_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashigo* pthis = (BgMoriHashigo*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashigo.c", 516); + func_80093D18(globalCtx->state.gfxCtx); + if (1) {} + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hashigo.c", 521), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + switch (pthis->dyna.actor.params) { + case HASHIGO_CLASP: + gSPDisplayList(POLY_OPA_DISP++, gMoriHashigoClaspDL); + break; + case HASHIGO_LADDER: + gSPDisplayList(POLY_OPA_DISP++, gMoriHashigoLadderDL); + break; + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashigo.c", 531); +} diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c deleted file mode 100644 index 8f92d3943..000000000 --- a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c +++ /dev/null @@ -1,184 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_HASHIRA4_Z_BG_MORI_HASHIRA4_C -#include "actor_common.h" -/* - * File: z_bg_mori_hashira4 - * Overlay: ovl_Bg_Mori_Hashira4 - * Description: Forest Temple gates and rotating pillars - */ - -#include "z_bg_mori_hashira4.h" -#include "objects/object_mori_objects/object_mori_objects.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgMoriHashira4_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHashira4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHashira4_Update(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHashira4_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgMoriHashira4_SetupWaitForMoriTex(BgMoriHashira4* this); -void BgMoriHashira4_WaitForMoriTex(BgMoriHashira4* this, GlobalContext* globalCtx); -void BgMoriHashira4_SetupPillarsRotate(BgMoriHashira4* this); -void BgMoriHashira4_PillarsRotate(BgMoriHashira4* this, GlobalContext* globalCtx); -void BgMoriHashira4_GateWait(BgMoriHashira4* this, GlobalContext* globalCtx); -void BgMoriHashira4_GateOpen(BgMoriHashira4* this, GlobalContext* globalCtx); - -const ActorInit Bg_Mori_Hashira4_InitVars = { - ACTOR_BG_MORI_HASHIRA4, - ACTORCAT_BG, - FLAGS, - OBJECT_MORI_OBJECTS, - sizeof(BgMoriHashira4), - (ActorFunc)BgMoriHashira4_Init, - (ActorFunc)BgMoriHashira4_Destroy, - (ActorFunc)BgMoriHashira4_Update, - NULL, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 700, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -static Gfx* sDisplayLists[] = { gMoriHashiraPlatformsDL, gMoriHashiraGateDL }; - -static s16 sUnkTimer; // seems to be unused - -void BgMoriHashira4_SetupAction(BgMoriHashira4* this, BgMoriHashira4ActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void BgMoriHashira4_InitDynaPoly(BgMoriHashira4* this, GlobalContext* globalCtx, CollisionHeader* collision, - s32 moveFlag) { - s32 pad; - CollisionHeader* colHeader; - s32 pad2; - - colHeader = NULL; - DynaPolyActor_Init(&this->dyna, moveFlag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - // "Warning : move BG login failed" - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashira4.c", 155, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgMoriHashira4_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashira4* this = (BgMoriHashira4*)thisx; - - this->switchFlag = (this->dyna.actor.params >> 8) & 0x3F; - this->dyna.actor.params &= 0xFF; - - if (this->dyna.actor.params == 0) { - BgMoriHashira4_InitDynaPoly(this, globalCtx, &gMoriHashira1Col, DPM_UNK3); - } else { - BgMoriHashira4_InitDynaPoly(this, globalCtx, &gMoriHashira2Col, DPM_UNK); - } - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - Actor_Kill(&this->dyna.actor); - // "Bank danger!" - osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->dyna.actor.params, - "../z_bg_mori_hashira4.c", 196); - return; - } - if ((this->dyna.actor.params != 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - Actor_Kill(&this->dyna.actor); - return; - } - Actor_SetFocus(&this->dyna.actor, 50.0f); - BgMoriHashira4_SetupWaitForMoriTex(this); - // "(4 pillars of the Forest Temple) Bank danger" - osSyncPrintf("(森の神殿 4本柱)(arg_data 0x%04x)\n", this->dyna.actor.params); - sUnkTimer = 0; -} - -void BgMoriHashira4_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashira4* this = (BgMoriHashira4*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgMoriHashira4_SetupWaitForMoriTex(BgMoriHashira4* this) { - BgMoriHashira4_SetupAction(this, BgMoriHashira4_WaitForMoriTex); -} - -void BgMoriHashira4_WaitForMoriTex(BgMoriHashira4* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - this->gateTimer = 0; - if (this->dyna.actor.params == 0) { - BgMoriHashira4_SetupPillarsRotate(this); - } else { - BgMoriHashira4_SetupAction(this, BgMoriHashira4_GateWait); - } - this->dyna.actor.draw = BgMoriHashira4_Draw; - } -} - -void BgMoriHashira4_SetupPillarsRotate(BgMoriHashira4* this) { - BgMoriHashira4_SetupAction(this, BgMoriHashira4_PillarsRotate); -} - -void BgMoriHashira4_PillarsRotate(BgMoriHashira4* this, GlobalContext* globalCtx) { - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y += 0x96; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); -} - -void BgMoriHashira4_GateWait(BgMoriHashira4* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag) || (this->gateTimer != 0)) { - this->gateTimer++; - if (this->gateTimer > 30) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); - BgMoriHashira4_SetupAction(this, BgMoriHashira4_GateOpen); - OnePointCutscene_Init(globalCtx, 6010, 20, &this->dyna.actor, MAIN_CAM); - sUnkTimer++; - } - } -} - -void BgMoriHashira4_GateOpen(BgMoriHashira4* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, 10.0f)) { - Actor_Kill(&this->dyna.actor); - } -} - -void BgMoriHashira4_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashira4* this = (BgMoriHashira4*)thisx; - - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } -} - -void BgMoriHashira4_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriHashira4* this = (BgMoriHashira4*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashira4.c", 339); - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hashira4.c", 344), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[this->dyna.actor.params]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashira4.c", 348); -} diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.cpp b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.cpp new file mode 100644 index 000000000..b99759b0f --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.cpp @@ -0,0 +1,184 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_HASHIRA4_Z_BG_MORI_HASHIRA4_C +#include "actor_common.h" +/* + * File: z_bg_mori_hashira4 + * Overlay: ovl_Bg_Mori_Hashira4 + * Description: Forest Temple gates and rotating pillars + */ + +#include "z_bg_mori_hashira4.h" +#include "objects/object_mori_objects/object_mori_objects.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgMoriHashira4_Init(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHashira4_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHashira4_Update(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHashira4_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgMoriHashira4_SetupWaitForMoriTex(BgMoriHashira4* pthis); +void BgMoriHashira4_WaitForMoriTex(BgMoriHashira4* pthis, GlobalContext* globalCtx); +void BgMoriHashira4_SetupPillarsRotate(BgMoriHashira4* pthis); +void BgMoriHashira4_PillarsRotate(BgMoriHashira4* pthis, GlobalContext* globalCtx); +void BgMoriHashira4_GateWait(BgMoriHashira4* pthis, GlobalContext* globalCtx); +void BgMoriHashira4_GateOpen(BgMoriHashira4* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Mori_Hashira4_InitVars = { + ACTOR_BG_MORI_HASHIRA4, + ACTORCAT_BG, + FLAGS, + OBJECT_MORI_OBJECTS, + sizeof(BgMoriHashira4), + (ActorFunc)BgMoriHashira4_Init, + (ActorFunc)BgMoriHashira4_Destroy, + (ActorFunc)BgMoriHashira4_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 700, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +static Gfx* sDisplayLists[] = { gMoriHashiraPlatformsDL, gMoriHashiraGateDL }; + +static s16 sUnkTimer; // seems to be unused + +void BgMoriHashira4_SetupAction(BgMoriHashira4* pthis, BgMoriHashira4ActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void BgMoriHashira4_InitDynaPoly(BgMoriHashira4* pthis, GlobalContext* globalCtx, CollisionHeader* collision, + s32 moveFlag) { + s32 pad; + CollisionHeader* colHeader; + s32 pad2; + + colHeader = NULL; + DynaPolyActor_Init(&pthis->dyna, moveFlag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + // "Warning : move BG login failed" + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashira4.c", 155, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgMoriHashira4_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashira4* pthis = (BgMoriHashira4*)thisx; + + pthis->switchFlag = (pthis->dyna.actor.params >> 8) & 0x3F; + pthis->dyna.actor.params &= 0xFF; + + if (pthis->dyna.actor.params == 0) { + BgMoriHashira4_InitDynaPoly(pthis, globalCtx, &gMoriHashira1Col, DPM_UNK3); + } else { + BgMoriHashira4_InitDynaPoly(pthis, globalCtx, &gMoriHashira2Col, DPM_UNK); + } + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + Actor_Kill(&pthis->dyna.actor); + // "Bank danger!" + osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", pthis->dyna.actor.params, + "../z_bg_mori_hashira4.c", 196); + return; + } + if ((pthis->dyna.actor.params != 0) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + Actor_Kill(&pthis->dyna.actor); + return; + } + Actor_SetFocus(&pthis->dyna.actor, 50.0f); + BgMoriHashira4_SetupWaitForMoriTex(pthis); + // "(4 pillars of the Forest Temple) Bank danger" + osSyncPrintf("(森の神殿 4本柱)(arg_data 0x%04x)\n", pthis->dyna.actor.params); + sUnkTimer = 0; +} + +void BgMoriHashira4_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashira4* pthis = (BgMoriHashira4*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgMoriHashira4_SetupWaitForMoriTex(BgMoriHashira4* pthis) { + BgMoriHashira4_SetupAction(pthis, BgMoriHashira4_WaitForMoriTex); +} + +void BgMoriHashira4_WaitForMoriTex(BgMoriHashira4* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + pthis->gateTimer = 0; + if (pthis->dyna.actor.params == 0) { + BgMoriHashira4_SetupPillarsRotate(pthis); + } else { + BgMoriHashira4_SetupAction(pthis, BgMoriHashira4_GateWait); + } + pthis->dyna.actor.draw = BgMoriHashira4_Draw; + } +} + +void BgMoriHashira4_SetupPillarsRotate(BgMoriHashira4* pthis) { + BgMoriHashira4_SetupAction(pthis, BgMoriHashira4_PillarsRotate); +} + +void BgMoriHashira4_PillarsRotate(BgMoriHashira4* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y += 0x96; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); +} + +void BgMoriHashira4_GateWait(BgMoriHashira4* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag) || (pthis->gateTimer != 0)) { + pthis->gateTimer++; + if (pthis->gateTimer > 30) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_OPEN); + BgMoriHashira4_SetupAction(pthis, BgMoriHashira4_GateOpen); + OnePointCutscene_Init(globalCtx, 6010, 20, &pthis->dyna.actor, MAIN_CAM); + sUnkTimer++; + } + } +} + +void BgMoriHashira4_GateOpen(BgMoriHashira4* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 120.0f, 10.0f)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgMoriHashira4_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashira4* pthis = (BgMoriHashira4*)thisx; + + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } +} + +void BgMoriHashira4_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriHashira4* pthis = (BgMoriHashira4*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashira4.c", 339); + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hashira4.c", 344), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[pthis->dyna.actor.params]); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hashira4.c", 348); +} diff --git a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c deleted file mode 100644 index da2b0d103..000000000 --- a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c +++ /dev/null @@ -1,292 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_HINERI_Z_BG_MORI_HINERI_C -#include "actor_common.h" -/* - * File: z_bg_mori_hineri.c - * Overlay: ovl_Bg_Mori_Hineri - * Description: Twisting hallway in Forest Temple - */ - -#include "z_bg_mori_hineri.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_box/object_box.h" -#include "objects/object_mori_hineri1/object_mori_hineri1.h" -#include "objects/object_mori_hineri1a/object_mori_hineri1a.h" -#include "objects/object_mori_hineri2/object_mori_hineri2.h" -#include "objects/object_mori_hineri2a/object_mori_hineri2a.h" -#include "objects/object_mori_tex/object_mori_tex.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgMoriHineri_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHineri_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHineri_Update(Actor* thisx, GlobalContext* globalCtx); -void BgMoriHineri_DrawHallAndRoom(Actor* thisx, GlobalContext* globalCtx); - -void func_808A39FC(BgMoriHineri* this, GlobalContext* globalCtx); -void func_808A3E54(BgMoriHineri* this, GlobalContext* globalCtx); -void func_808A3C8C(BgMoriHineri* this, GlobalContext* globalCtx); -void BgMoriHineri_SpawnBossKeyChest(BgMoriHineri* this, GlobalContext* globalCtx); -void BgMoriHineri_DoNothing(BgMoriHineri* this, GlobalContext* globalCtx); -void func_808A3D58(BgMoriHineri* this, GlobalContext* globalCtx); - -static s16 sNextCamIdx = SUBCAM_NONE; - -const ActorInit Bg_Mori_Hineri_InitVars = { - ACTOR_BG_MORI_HINERI, - ACTORCAT_BG, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(BgMoriHineri), - (ActorFunc)BgMoriHineri_Init, - (ActorFunc)BgMoriHineri_Destroy, - (ActorFunc)BgMoriHineri_Update, - NULL, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -static Gfx* sDLists[] = { - object_mori_hineri1_DL_0024E0, - object_mori_hineri1a_DL_001980, - object_mori_hineri2_DL_0020F0, - object_mori_hineri2a_DL_002B70, -}; - -void BgMoriHineri_Init(Actor* thisx, GlobalContext* globalCtx) { - BgMoriHineri* this = (BgMoriHineri*)thisx; - s8 moriHineriObjIdx; - u32 switchFlagParam; - s32 t6; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - - switchFlagParam = this->dyna.actor.params & 0x3F; - t6 = this->dyna.actor.params & 0x4000; - - if (t6 != 0) { - this->switchFlag = switchFlagParam; - } else { - this->switchFlag = ((this->dyna.actor.params >> 8) & 0x3F); - this->switchFlag = (Flags_GetSwitch(globalCtx, this->switchFlag)) ? 1 : 0; - } - this->dyna.actor.params = ((this->dyna.actor.params & 0x8000) >> 0xE); - if (Flags_GetSwitch(globalCtx, switchFlagParam)) { - if (this->dyna.actor.params == 0) { - this->dyna.actor.params = 1; - } else if (this->dyna.actor.params == 2) { - this->dyna.actor.params = 3; - } - } - this->boxObjIdx = -1; - if (this->dyna.actor.params == 0) { - this->moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1); - if (t6 == 0) { - this->boxObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_BOX); - } - } else { - if (this->dyna.actor.params == 1) { - moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1A); - } else { - moriHineriObjIdx = (this->dyna.actor.params == 2) - ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2) - : Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2A); - } - this->moriHineriObjIdx = moriHineriObjIdx; - } - this->moriTexObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (t6 != 0) { - this->dyna.actor.params += 4; - } - if ((this->moriHineriObjIdx < 0) || (this->moriTexObjIdx < 0)) { - Actor_Kill(&this->dyna.actor); - } else { - this->actionFunc = func_808A39FC; - } -} - -void BgMoriHineri_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgMoriHineri* this = (BgMoriHineri*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_808A39FC(BgMoriHineri* this, GlobalContext* globalCtx) { - CollisionHeader* colHeader; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriHineriObjIdx) && - Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIdx) && - ((this->boxObjIdx < 0) || Object_IsLoaded(&globalCtx->objectCtx, this->boxObjIdx))) { - this->dyna.actor.objBankIndex = this->moriHineriObjIdx; - if (this->dyna.actor.params >= 4) { - this->dyna.actor.params -= 4; - if (this->dyna.actor.params == 0) { - this->moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1A); - } else if (this->dyna.actor.params == 1) { - this->moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1); - } else { - this->moriHineriObjIdx = (this->dyna.actor.params == 2) - ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2A) - : Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2); - } - if (this->moriHineriObjIdx < 0) { - Actor_Kill(&this->dyna.actor); - } else { - this->actionFunc = func_808A3D58; - } - } else { - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); - colHeader = NULL; - this->dyna.actor.draw = BgMoriHineri_DrawHallAndRoom; - if (this->dyna.actor.params == 0) { - this->actionFunc = func_808A3C8C; - CollisionHeader_GetVirtual(&object_mori_hineri1_Col_0054B8, &colHeader); - } else if (this->dyna.actor.params == 1) { - this->actionFunc = BgMoriHineri_SpawnBossKeyChest; - CollisionHeader_GetVirtual(&object_mori_hineri1a_Col_003490, &colHeader); - } else if (this->dyna.actor.params == 2) { - this->actionFunc = BgMoriHineri_DoNothing; - CollisionHeader_GetVirtual(&object_mori_hineri2_Col_0043D0, &colHeader); - } else { - this->actionFunc = func_808A3C8C; - CollisionHeader_GetVirtual(&object_mori_hineri2a_Col_006078, &colHeader); - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - } - } -} - -void BgMoriHineri_DoNothing(BgMoriHineri* this, GlobalContext* globalCtx) { -} - -void BgMoriHineri_SpawnBossKeyChest(BgMoriHineri* this, GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->dyna.actor.world.pos.x + 147.0f, - this->dyna.actor.world.pos.y + -245.0f, this->dyna.actor.world.pos.z + -453.0f, 0, 0x4000, 0, 0x27EE); - this->actionFunc = BgMoriHineri_DoNothing; -} - -void func_808A3C8C(BgMoriHineri* this, GlobalContext* globalCtx) { - f32 f0; - Player* player = GET_PLAYER(globalCtx); - - f0 = 1100.0f - (player->actor.world.pos.z - this->dyna.actor.world.pos.z); - this->dyna.actor.shape.rot.z = CLAMP(f0, 0.0f, 1000.0f) * 16.384f; - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON1); - if (this->dyna.actor.params != 0) { - this->dyna.actor.shape.rot.z = -this->dyna.actor.shape.rot.z; - } -} - -void func_808A3D58(BgMoriHineri* this, GlobalContext* globalCtx) { - s16 mainCamChildIdx; - - if ((Flags_GetSwitch(globalCtx, this->switchFlag) && - (this->dyna.actor.params == 0 || this->dyna.actor.params == 2)) || - (!Flags_GetSwitch(globalCtx, this->switchFlag) && - (this->dyna.actor.params == 1 || this->dyna.actor.params == 3))) { - this->dyna.actor.draw = BgMoriHineri_DrawHallAndRoom; - this->actionFunc = func_808A3E54; - - mainCamChildIdx = globalCtx->cameraPtrs[MAIN_CAM]->childCamIdx; - if ((mainCamChildIdx != SUBCAM_FREE) && - (globalCtx->cameraPtrs[mainCamChildIdx]->setting == CAM_SET_CS_TWISTED_HALLWAY)) { - OnePointCutscene_EndCutscene(globalCtx, mainCamChildIdx); - } - OnePointCutscene_Init(globalCtx, 3260, 40, &this->dyna.actor, MAIN_CAM); - sNextCamIdx = OnePointCutscene_Init(globalCtx, 3261, 40, &this->dyna.actor, MAIN_CAM); - } -} - -void func_808A3E54(BgMoriHineri* this, GlobalContext* globalCtx) { - s32 objBankIndex; - - if (globalCtx->activeCamera == sNextCamIdx) { - if (sNextCamIdx != MAIN_CAM) { - objBankIndex = this->dyna.actor.objBankIndex; - this->dyna.actor.objBankIndex = this->moriHineriObjIdx; - this->moriHineriObjIdx = objBankIndex; - this->dyna.actor.params ^= 1; - sNextCamIdx = MAIN_CAM; - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } else { - this->dyna.actor.draw = NULL; - this->actionFunc = func_808A3D58; - sNextCamIdx = SUBCAM_NONE; - } - } - if ((sNextCamIdx >= SUBCAM_FIRST) && - ((GET_ACTIVE_CAM(globalCtx)->eye.z - this->dyna.actor.world.pos.z) < 1100.0f)) { - func_8002F948(&this->dyna.actor, NA_SE_EV_FLOOR_ROLLING - SFX_FLAG); - } -} - -void BgMoriHineri_Update(Actor* thisx, GlobalContext* globalCtx) { - BgMoriHineri* this = (BgMoriHineri*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgMoriHineri_DrawHallAndRoom(Actor* thisx, GlobalContext* globalCtx) { - BgMoriHineri* this = (BgMoriHineri*)thisx; - s8 objIndex; - MtxF mtx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 611); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIdx].vromStart); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 618), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sDLists[this->dyna.actor.params]); - if (this->boxObjIdx > 0) { - Matrix_Get(&mtx); - } - if ((this->actionFunc == func_808A3C8C) && (this->dyna.actor.shape.rot.z != 0)) { - func_80093D18(globalCtx->state.gfxCtx); - if (this->dyna.actor.params == 0) { - Matrix_Translate(-1761.0f, 1278.0f, -1821.0f, MTXMODE_NEW); - } else { - Matrix_Translate(1999.0f, 1278.0f, -1821.0f, MTXMODE_NEW); - } - Matrix_RotateZYX(0, -0x8000, this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_Translate(0.0f, -50.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 652), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDungeonDoorDL); - } - if ((this->boxObjIdx > 0) && ((this->boxObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_BOX)) > 0) && - (Object_IsLoaded(&globalCtx->objectCtx, this->boxObjIdx))) { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->boxObjIdx].vromStart); - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - Matrix_Put(&mtx); - Matrix_Translate(147.0f, -245.0f, -453.0f, MTXMODE_APPLY); - Matrix_RotateY(M_PI / 2, MTXMODE_APPLY); - Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 689), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gTreasureChestBossKeyChestFrontDL); - Matrix_Put(&mtx); - Matrix_Translate(167.0f, -218.0f, -453.0f, MTXMODE_APPLY); - if (Flags_GetTreasure(globalCtx, 0xE)) { - Matrix_RotateZ(0x3500 * (M_PI / 0x8000), MTXMODE_APPLY); - } else { - Matrix_RotateZ(M_PI, MTXMODE_APPLY); - } - Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 703), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gTreasureChestBossKeyChestSideAndTopDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 709); -} diff --git a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.cpp b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.cpp new file mode 100644 index 000000000..cb218cc19 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.cpp @@ -0,0 +1,292 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_HINERI_Z_BG_MORI_HINERI_C +#include "actor_common.h" +/* + * File: z_bg_mori_hineri.c + * Overlay: ovl_Bg_Mori_Hineri + * Description: Twisting hallway in Forest Temple + */ + +#include "z_bg_mori_hineri.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_box/object_box.h" +#include "objects/object_mori_hineri1/object_mori_hineri1.h" +#include "objects/object_mori_hineri1a/object_mori_hineri1a.h" +#include "objects/object_mori_hineri2/object_mori_hineri2.h" +#include "objects/object_mori_hineri2a/object_mori_hineri2a.h" +#include "objects/object_mori_tex/object_mori_tex.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgMoriHineri_Init(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHineri_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHineri_Update(Actor* thisx, GlobalContext* globalCtx); +void BgMoriHineri_DrawHallAndRoom(Actor* thisx, GlobalContext* globalCtx); + +void func_808A39FC(BgMoriHineri* pthis, GlobalContext* globalCtx); +void func_808A3E54(BgMoriHineri* pthis, GlobalContext* globalCtx); +void func_808A3C8C(BgMoriHineri* pthis, GlobalContext* globalCtx); +void BgMoriHineri_SpawnBossKeyChest(BgMoriHineri* pthis, GlobalContext* globalCtx); +void BgMoriHineri_DoNothing(BgMoriHineri* pthis, GlobalContext* globalCtx); +void func_808A3D58(BgMoriHineri* pthis, GlobalContext* globalCtx); + +static s16 sNextCamIdx = SUBCAM_NONE; + +ActorInit Bg_Mori_Hineri_InitVars = { + ACTOR_BG_MORI_HINERI, + ACTORCAT_BG, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(BgMoriHineri), + (ActorFunc)BgMoriHineri_Init, + (ActorFunc)BgMoriHineri_Destroy, + (ActorFunc)BgMoriHineri_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +static Gfx* sDLists[] = { + object_mori_hineri1_DL_0024E0, + object_mori_hineri1a_DL_001980, + object_mori_hineri2_DL_0020F0, + object_mori_hineri2a_DL_002B70, +}; + +void BgMoriHineri_Init(Actor* thisx, GlobalContext* globalCtx) { + BgMoriHineri* pthis = (BgMoriHineri*)thisx; + s8 moriHineriObjIdx; + u32 switchFlagParam; + s32 t6; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + + switchFlagParam = pthis->dyna.actor.params & 0x3F; + t6 = pthis->dyna.actor.params & 0x4000; + + if (t6 != 0) { + pthis->switchFlag = switchFlagParam; + } else { + pthis->switchFlag = ((pthis->dyna.actor.params >> 8) & 0x3F); + pthis->switchFlag = (Flags_GetSwitch(globalCtx, pthis->switchFlag)) ? 1 : 0; + } + pthis->dyna.actor.params = ((pthis->dyna.actor.params & 0x8000) >> 0xE); + if (Flags_GetSwitch(globalCtx, switchFlagParam)) { + if (pthis->dyna.actor.params == 0) { + pthis->dyna.actor.params = 1; + } else if (pthis->dyna.actor.params == 2) { + pthis->dyna.actor.params = 3; + } + } + pthis->boxObjIdx = -1; + if (pthis->dyna.actor.params == 0) { + pthis->moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1); + if (t6 == 0) { + pthis->boxObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_BOX); + } + } else { + if (pthis->dyna.actor.params == 1) { + moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1A); + } else { + moriHineriObjIdx = (pthis->dyna.actor.params == 2) + ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2) + : Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2A); + } + pthis->moriHineriObjIdx = moriHineriObjIdx; + } + pthis->moriTexObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (t6 != 0) { + pthis->dyna.actor.params += 4; + } + if ((pthis->moriHineriObjIdx < 0) || (pthis->moriTexObjIdx < 0)) { + Actor_Kill(&pthis->dyna.actor); + } else { + pthis->actionFunc = func_808A39FC; + } +} + +void BgMoriHineri_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgMoriHineri* pthis = (BgMoriHineri*)thisx; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_808A39FC(BgMoriHineri* pthis, GlobalContext* globalCtx) { + CollisionHeader* colHeader; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriHineriObjIdx) && + Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIdx) && + ((pthis->boxObjIdx < 0) || Object_IsLoaded(&globalCtx->objectCtx, pthis->boxObjIdx))) { + pthis->dyna.actor.objBankIndex = pthis->moriHineriObjIdx; + if (pthis->dyna.actor.params >= 4) { + pthis->dyna.actor.params -= 4; + if (pthis->dyna.actor.params == 0) { + pthis->moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1A); + } else if (pthis->dyna.actor.params == 1) { + pthis->moriHineriObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI1); + } else { + pthis->moriHineriObjIdx = (pthis->dyna.actor.params == 2) + ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2A) + : Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_HINERI2); + } + if (pthis->moriHineriObjIdx < 0) { + Actor_Kill(&pthis->dyna.actor); + } else { + pthis->actionFunc = func_808A3D58; + } + } else { + Actor_SetObjectDependency(globalCtx, &pthis->dyna.actor); + colHeader = NULL; + pthis->dyna.actor.draw = BgMoriHineri_DrawHallAndRoom; + if (pthis->dyna.actor.params == 0) { + pthis->actionFunc = func_808A3C8C; + CollisionHeader_GetVirtual(&object_mori_hineri1_Col_0054B8, &colHeader); + } else if (pthis->dyna.actor.params == 1) { + pthis->actionFunc = BgMoriHineri_SpawnBossKeyChest; + CollisionHeader_GetVirtual(&object_mori_hineri1a_Col_003490, &colHeader); + } else if (pthis->dyna.actor.params == 2) { + pthis->actionFunc = BgMoriHineri_DoNothing; + CollisionHeader_GetVirtual(&object_mori_hineri2_Col_0043D0, &colHeader); + } else { + pthis->actionFunc = func_808A3C8C; + CollisionHeader_GetVirtual(&object_mori_hineri2a_Col_006078, &colHeader); + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + } + } +} + +void BgMoriHineri_DoNothing(BgMoriHineri* pthis, GlobalContext* globalCtx) { +} + +void BgMoriHineri_SpawnBossKeyChest(BgMoriHineri* pthis, GlobalContext* globalCtx) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, pthis->dyna.actor.world.pos.x + 147.0f, + pthis->dyna.actor.world.pos.y + -245.0f, pthis->dyna.actor.world.pos.z + -453.0f, 0, 0x4000, 0, 0x27EE); + pthis->actionFunc = BgMoriHineri_DoNothing; +} + +void func_808A3C8C(BgMoriHineri* pthis, GlobalContext* globalCtx) { + f32 f0; + Player* player = GET_PLAYER(globalCtx); + + f0 = 1100.0f - (player->actor.world.pos.z - pthis->dyna.actor.world.pos.z); + pthis->dyna.actor.shape.rot.z = CLAMP(f0, 0.0f, 1000.0f) * 16.384f; + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON1); + if (pthis->dyna.actor.params != 0) { + pthis->dyna.actor.shape.rot.z = -pthis->dyna.actor.shape.rot.z; + } +} + +void func_808A3D58(BgMoriHineri* pthis, GlobalContext* globalCtx) { + s16 mainCamChildIdx; + + if ((Flags_GetSwitch(globalCtx, pthis->switchFlag) && + (pthis->dyna.actor.params == 0 || pthis->dyna.actor.params == 2)) || + (!Flags_GetSwitch(globalCtx, pthis->switchFlag) && + (pthis->dyna.actor.params == 1 || pthis->dyna.actor.params == 3))) { + pthis->dyna.actor.draw = BgMoriHineri_DrawHallAndRoom; + pthis->actionFunc = func_808A3E54; + + mainCamChildIdx = globalCtx->cameraPtrs[MAIN_CAM]->childCamIdx; + if ((mainCamChildIdx != SUBCAM_FREE) && + (globalCtx->cameraPtrs[mainCamChildIdx]->setting == CAM_SET_CS_TWISTED_HALLWAY)) { + OnePointCutscene_EndCutscene(globalCtx, mainCamChildIdx); + } + OnePointCutscene_Init(globalCtx, 3260, 40, &pthis->dyna.actor, MAIN_CAM); + sNextCamIdx = OnePointCutscene_Init(globalCtx, 3261, 40, &pthis->dyna.actor, MAIN_CAM); + } +} + +void func_808A3E54(BgMoriHineri* pthis, GlobalContext* globalCtx) { + s32 objBankIndex; + + if (globalCtx->activeCamera == sNextCamIdx) { + if (sNextCamIdx != MAIN_CAM) { + objBankIndex = pthis->dyna.actor.objBankIndex; + pthis->dyna.actor.objBankIndex = pthis->moriHineriObjIdx; + pthis->moriHineriObjIdx = objBankIndex; + pthis->dyna.actor.params ^= 1; + sNextCamIdx = MAIN_CAM; + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } else { + pthis->dyna.actor.draw = NULL; + pthis->actionFunc = func_808A3D58; + sNextCamIdx = SUBCAM_NONE; + } + } + if ((sNextCamIdx >= SUBCAM_FIRST) && + ((GET_ACTIVE_CAM(globalCtx)->eye.z - pthis->dyna.actor.world.pos.z) < 1100.0f)) { + func_8002F948(&pthis->dyna.actor, NA_SE_EV_FLOOR_ROLLING - SFX_FLAG); + } +} + +void BgMoriHineri_Update(Actor* thisx, GlobalContext* globalCtx) { + BgMoriHineri* pthis = (BgMoriHineri*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgMoriHineri_DrawHallAndRoom(Actor* thisx, GlobalContext* globalCtx) { + BgMoriHineri* pthis = (BgMoriHineri*)thisx; + s8 objIndex; + MtxF mtx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 611); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIdx].vromStart.get()); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 618), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDLists[pthis->dyna.actor.params]); + if (pthis->boxObjIdx > 0) { + Matrix_Get(&mtx); + } + if ((pthis->actionFunc == func_808A3C8C) && (pthis->dyna.actor.shape.rot.z != 0)) { + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->dyna.actor.params == 0) { + Matrix_Translate(-1761.0f, 1278.0f, -1821.0f, MTXMODE_NEW); + } else { + Matrix_Translate(1999.0f, 1278.0f, -1821.0f, MTXMODE_NEW); + } + Matrix_RotateZYX(0, -0x8000, pthis->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -50.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 652), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDungeonDoorDL); + } + if ((pthis->boxObjIdx > 0) && ((pthis->boxObjIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_BOX)) > 0) && + (Object_IsLoaded(&globalCtx->objectCtx, pthis->boxObjIdx))) { + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->boxObjIdx].vromStart.get()); + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + Matrix_Put(&mtx); + Matrix_Translate(147.0f, -245.0f, -453.0f, MTXMODE_APPLY); + Matrix_RotateY(M_PI / 2, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 689), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gTreasureChestBossKeyChestFrontDL); + Matrix_Put(&mtx); + Matrix_Translate(167.0f, -218.0f, -453.0f, MTXMODE_APPLY); + if (Flags_GetTreasure(globalCtx, 0xE)) { + Matrix_RotateZ(0x3500 * (M_PI / 0x8000), MTXMODE_APPLY); + } else { + Matrix_RotateZ(M_PI, MTXMODE_APPLY); + } + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 703), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gTreasureChestBossKeyChestSideAndTopDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_hineri.c", 709); +} diff --git a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.cpp similarity index 58% rename from src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c rename to src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.cpp index b163c7a8a..7fc5d3ba9 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c +++ b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.cpp @@ -22,14 +22,14 @@ void BgMoriIdomizu_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMoriIdomizu_Update(Actor* thisx, GlobalContext* globalCtx); void BgMoriIdomizu_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* this); -void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, GlobalContext* globalCtx); -void BgMoriIdomizu_SetupMain(BgMoriIdomizu* this); -void BgMoriIdomizu_Main(BgMoriIdomizu* this, GlobalContext* globalCtx); +void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* pthis); +void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* pthis, GlobalContext* globalCtx); +void BgMoriIdomizu_SetupMain(BgMoriIdomizu* pthis); +void BgMoriIdomizu_Main(BgMoriIdomizu* pthis, GlobalContext* globalCtx); static s16 sIsSpawned = false; -const ActorInit Bg_Mori_Idomizu_InitVars = { +ActorInit Bg_Mori_Idomizu_InitVars = { ACTOR_BG_MORI_IDOMIZU, ACTORCAT_BG, FLAGS, @@ -41,8 +41,8 @@ const ActorInit Bg_Mori_Idomizu_InitVars = { NULL, }; -void BgMoriIdomizu_SetupAction(BgMoriIdomizu* this, BgMoriIdomizuActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgMoriIdomizu_SetupAction(BgMoriIdomizu* pthis, BgMoriIdomizuActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgMoriIdomizu_SetWaterLevel(GlobalContext* globalCtx, s16 waterLevel) { @@ -55,91 +55,91 @@ void BgMoriIdomizu_SetWaterLevel(GlobalContext* globalCtx, s16 waterLevel) { void BgMoriIdomizu_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; + BgMoriIdomizu* pthis = (BgMoriIdomizu*)thisx; if (sIsSpawned) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->actor.scale.x = 1.1f; - this->actor.scale.y = 1.0f; - this->actor.scale.z = 1.0f; - this->actor.world.pos.x = 119.0f; - this->actor.world.pos.z = -1820.0f; - this->prevSwitchFlagSet = Flags_GetSwitch(globalCtx, this->actor.params & 0x3F); - if (this->prevSwitchFlagSet != 0) { - this->actor.world.pos.y = -282.0f; + pthis->actor.scale.x = 1.1f; + pthis->actor.scale.y = 1.0f; + pthis->actor.scale.z = 1.0f; + pthis->actor.world.pos.x = 119.0f; + pthis->actor.world.pos.z = -1820.0f; + pthis->prevSwitchFlagSet = Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F); + if (pthis->prevSwitchFlagSet != 0) { + pthis->actor.world.pos.y = -282.0f; BgMoriIdomizu_SetWaterLevel(globalCtx, -282); } else { - this->actor.world.pos.y = 184.0f; + pthis->actor.world.pos.y = 184.0f; BgMoriIdomizu_SetWaterLevel(globalCtx, 184); } - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - Actor_Kill(&this->actor); + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + Actor_Kill(&pthis->actor); // "Bank danger!" - osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->actor.params, "../z_bg_mori_idomizu.c", + osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", pthis->actor.params, "../z_bg_mori_idomizu.c", 202); return; } - BgMoriIdomizu_SetupWaitForMoriTex(this); + BgMoriIdomizu_SetupWaitForMoriTex(pthis); sIsSpawned = true; - this->isLoaded = true; - this->actor.room = -1; + pthis->isLoaded = true; + pthis->actor.room = -1; // "Forest Temple well water" - osSyncPrintf("(森の神殿 井戸水)(arg_data 0x%04x)\n", this->actor.params); + osSyncPrintf("(森の神殿 井戸水)(arg_data 0x%04x)\n", pthis->actor.params); } void BgMoriIdomizu_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; + BgMoriIdomizu* pthis = (BgMoriIdomizu*)thisx; - if (this->isLoaded) { + if (pthis->isLoaded) { sIsSpawned = false; } } -void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* this) { - BgMoriIdomizu_SetupAction(this, BgMoriIdomizu_WaitForMoriTex); +void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* pthis) { + BgMoriIdomizu_SetupAction(pthis, BgMoriIdomizu_WaitForMoriTex); } -void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - BgMoriIdomizu_SetupMain(this); - this->actor.draw = BgMoriIdomizu_Draw; +void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + BgMoriIdomizu_SetupMain(pthis); + pthis->actor.draw = BgMoriIdomizu_Draw; } } -void BgMoriIdomizu_SetupMain(BgMoriIdomizu* this) { - BgMoriIdomizu_SetupAction(this, BgMoriIdomizu_Main); +void BgMoriIdomizu_SetupMain(BgMoriIdomizu* pthis) { + BgMoriIdomizu_SetupAction(pthis, BgMoriIdomizu_Main); } -void BgMoriIdomizu_Main(BgMoriIdomizu* this, GlobalContext* globalCtx) { +void BgMoriIdomizu_Main(BgMoriIdomizu* pthis, GlobalContext* globalCtx) { s8 roomNum; - Actor* thisx = &this->actor; + Actor* thisx = &pthis->actor; s32 switchFlagSet; roomNum = globalCtx->roomCtx.curRoom.num; switchFlagSet = Flags_GetSwitch(globalCtx, thisx->params & 0x3F); if (switchFlagSet) { - this->targetWaterLevel = -282.0f; + pthis->targetWaterLevel = -282.0f; } else { - this->targetWaterLevel = 184.0f; + pthis->targetWaterLevel = 184.0f; } - if (switchFlagSet && !this->prevSwitchFlagSet) { + if (switchFlagSet && !pthis->prevSwitchFlagSet) { OnePointCutscene_Init(globalCtx, 3240, 70, thisx, MAIN_CAM); - this->drainTimer = 90; - } else if (!switchFlagSet && this->prevSwitchFlagSet) { + pthis->drainTimer = 90; + } else if (!switchFlagSet && pthis->prevSwitchFlagSet) { OnePointCutscene_Init(globalCtx, 3240, 70, thisx, MAIN_CAM); - this->drainTimer = 90; + pthis->drainTimer = 90; thisx->world.pos.y = 0.0f; } - this->drainTimer--; + pthis->drainTimer--; if ((roomNum == 7) || (roomNum == 8) || (roomNum == 9)) { - if (this->drainTimer < 70) { - Math_StepToF(&thisx->world.pos.y, this->targetWaterLevel, 3.5f); + if (pthis->drainTimer < 70) { + Math_StepToF(&thisx->world.pos.y, pthis->targetWaterLevel, 3.5f); BgMoriIdomizu_SetWaterLevel(globalCtx, thisx->world.pos.y); - if (this->drainTimer > 0) { + if (pthis->drainTimer > 0) { if (switchFlagSet) { func_800788CC(NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); } else { @@ -148,26 +148,26 @@ void BgMoriIdomizu_Main(BgMoriIdomizu* this, GlobalContext* globalCtx) { } } } else { - thisx->world.pos.y = this->targetWaterLevel; + thisx->world.pos.y = pthis->targetWaterLevel; BgMoriIdomizu_SetWaterLevel(globalCtx, thisx->world.pos.y); Actor_Kill(thisx); return; } - this->prevSwitchFlagSet = switchFlagSet; + pthis->prevSwitchFlagSet = switchFlagSet; } void BgMoriIdomizu_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; + BgMoriIdomizu* pthis = (BgMoriIdomizu*)thisx; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } } void BgMoriIdomizu_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; + BgMoriIdomizu* pthis = (BgMoriIdomizu*)thisx; u32 gameplayFrames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_idomizu.c", 356); @@ -177,7 +177,7 @@ void BgMoriIdomizu_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_idomizu.c", 360), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); + gSPSegment(POLY_XLU_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 128); diff --git a/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c b/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.cpp similarity index 52% rename from src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c rename to src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.cpp index 695c3b4fc..dde303ea9 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c +++ b/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.cpp @@ -24,13 +24,13 @@ void BgMoriKaitenkabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgMoriKaitenkabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgMoriKaitenkabe_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgMoriKaitenkabe_WaitForMoriTex(BgMoriKaitenkabe* this, GlobalContext* globalCtx); -void BgMoriKaitenkabe_SetupWait(BgMoriKaitenkabe* this); -void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* this, GlobalContext* globalCtx); -void BgMoriKaitenkabe_SetupRotate(BgMoriKaitenkabe* this); -void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* this, GlobalContext* globalCtx); +void BgMoriKaitenkabe_WaitForMoriTex(BgMoriKaitenkabe* pthis, GlobalContext* globalCtx); +void BgMoriKaitenkabe_SetupWait(BgMoriKaitenkabe* pthis); +void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* pthis, GlobalContext* globalCtx); +void BgMoriKaitenkabe_SetupRotate(BgMoriKaitenkabe* pthis); +void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Mori_Kaitenkabe_InitVars = { +ActorInit Bg_Mori_Kaitenkabe_InitVars = { ACTOR_BG_MORI_KAITENKABE, ACTORCAT_BG, FLAGS, @@ -57,90 +57,90 @@ void BgMoriKaitenkabe_CrossProduct(Vec3f* dest, Vec3f* v1, Vec3f* v2) { void BgMoriKaitenkabe_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriKaitenkabe* this = (BgMoriKaitenkabe*)thisx; + BgMoriKaitenkabe* pthis = (BgMoriKaitenkabe*)thisx; CollisionHeader* colHeader = NULL; // "Forest Temple object 【Rotating Wall (arg_data: 0x% 04x)】 appears" - osSyncPrintf("◯◯◯森の神殿オブジェクト【回転壁(arg_data : 0x%04x)】出現 \n", this->dyna.actor.params); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + osSyncPrintf("◯◯◯森の神殿オブジェクト【回転壁(arg_data : 0x%04x)】出現 \n", pthis->dyna.actor.params); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gMoriKaitenkabeCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - Actor_Kill(&this->dyna.actor); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + Actor_Kill(&pthis->dyna.actor); // "【Rotating wall】 Bank danger!" osSyncPrintf("【回転壁】 バンク危険!(%s %d)\n", "../z_bg_mori_kaitenkabe.c", 176); } else { - this->actionFunc = BgMoriKaitenkabe_WaitForMoriTex; + pthis->actionFunc = BgMoriKaitenkabe_WaitForMoriTex; } } void BgMoriKaitenkabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriKaitenkabe* this = (BgMoriKaitenkabe*)thisx; + BgMoriKaitenkabe* pthis = (BgMoriKaitenkabe*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void BgMoriKaitenkabe_WaitForMoriTex(BgMoriKaitenkabe* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - BgMoriKaitenkabe_SetupWait(this); - this->dyna.actor.draw = BgMoriKaitenkabe_Draw; +void BgMoriKaitenkabe_WaitForMoriTex(BgMoriKaitenkabe* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + BgMoriKaitenkabe_SetupWait(pthis); + pthis->dyna.actor.draw = BgMoriKaitenkabe_Draw; } } -void BgMoriKaitenkabe_SetupWait(BgMoriKaitenkabe* this) { - this->actionFunc = BgMoriKaitenkabe_Wait; - this->timer = 0; +void BgMoriKaitenkabe_SetupWait(BgMoriKaitenkabe* pthis) { + pthis->actionFunc = BgMoriKaitenkabe_Wait; + pthis->timer = 0; } -void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* this, GlobalContext* globalCtx) { +void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* pthis, GlobalContext* globalCtx) { Vec3f push; Vec3f leverArm; Vec3f torque; Player* player = GET_PLAYER(globalCtx); - if (this->dyna.unk_150 > 0.001f) { - this->timer++; - if ((this->timer > 28) && !Player_InCsMode(globalCtx)) { - BgMoriKaitenkabe_SetupRotate(this); - func_8002DF54(globalCtx, &this->dyna.actor, 8); - Math_Vec3f_Copy(&this->lockedPlayerPos, &player->actor.world.pos); - push.x = Math_SinS(this->dyna.unk_158); + if (pthis->dyna.unk_150 > 0.001f) { + pthis->timer++; + if ((pthis->timer > 28) && !Player_InCsMode(globalCtx)) { + BgMoriKaitenkabe_SetupRotate(pthis); + func_8002DF54(globalCtx, &pthis->dyna.actor, 8); + Math_Vec3f_Copy(&pthis->lockedPlayerPos, &player->actor.world.pos); + push.x = Math_SinS(pthis->dyna.unk_158); push.y = 0.0f; - push.z = Math_CosS(this->dyna.unk_158); - leverArm.x = this->dyna.actor.world.pos.x - player->actor.world.pos.x; + push.z = Math_CosS(pthis->dyna.unk_158); + leverArm.x = pthis->dyna.actor.world.pos.x - player->actor.world.pos.x; leverArm.y = 0.0f; - leverArm.z = this->dyna.actor.world.pos.z - player->actor.world.pos.z; + leverArm.z = pthis->dyna.actor.world.pos.z - player->actor.world.pos.z; BgMoriKaitenkabe_CrossProduct(&torque, &push, &leverArm); - this->rotDirection = (torque.y > 0.0f) ? 1.0f : -1.0f; + pthis->rotDirection = (torque.y > 0.0f) ? 1.0f : -1.0f; } } else { - this->timer = 0; + pthis->timer = 0; } - if (fabsf(this->dyna.unk_150) > 0.001f) { - this->dyna.unk_150 = 0.0f; + if (fabsf(pthis->dyna.unk_150) > 0.001f) { + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; } } -void BgMoriKaitenkabe_SetupRotate(BgMoriKaitenkabe* this) { - this->actionFunc = BgMoriKaitenkabe_Rotate; - this->rotSpeed = 0.0f; - this->rotYdeg = 0.0f; +void BgMoriKaitenkabe_SetupRotate(BgMoriKaitenkabe* pthis) { + pthis->actionFunc = BgMoriKaitenkabe_Rotate; + pthis->rotSpeed = 0.0f; + pthis->rotYdeg = 0.0f; } -void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* this, GlobalContext* globalCtx) { +void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; s16 rotY; - Math_StepToF(&this->rotSpeed, 0.6f, 0.02f); - if (Math_StepToF(&this->rotYdeg, this->rotDirection * 45.0f, this->rotSpeed)) { - BgMoriKaitenkabe_SetupWait(this); + Math_StepToF(&pthis->rotSpeed, 0.6f, 0.02f); + if (Math_StepToF(&pthis->rotYdeg, pthis->rotDirection * 45.0f, pthis->rotSpeed)) { + BgMoriKaitenkabe_SetupWait(pthis); func_8002DF54(globalCtx, thisx, 7); - if (this->rotDirection > 0.0f) { + if (pthis->rotDirection > 0.0f) { thisx->home.rot.y += 0x2000; } else { thisx->home.rot.y -= 0x2000; @@ -148,32 +148,32 @@ void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* this, GlobalContext* globalCtx) { thisx->world.rot.y = thisx->shape.rot.y = thisx->home.rot.y; func_800788CC(NA_SE_EV_STONEDOOR_STOP); } else { - rotY = this->rotYdeg * (0x10000 / 360.0f); + rotY = pthis->rotYdeg * (0x10000 / 360.0f); thisx->world.rot.y = thisx->shape.rot.y = thisx->home.rot.y + rotY; func_800788CC(NA_SE_EV_WALL_SLIDE - SFX_FLAG); } - if (fabsf(this->dyna.unk_150) > 0.001f) { - this->dyna.unk_150 = 0.0f; + if (fabsf(pthis->dyna.unk_150) > 0.001f) { + pthis->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~0x10; } - Math_Vec3f_Copy(&player->actor.world.pos, &this->lockedPlayerPos); + Math_Vec3f_Copy(&player->actor.world.pos, &pthis->lockedPlayerPos); } void BgMoriKaitenkabe_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriKaitenkabe* this = (BgMoriKaitenkabe*)thisx; + BgMoriKaitenkabe* pthis = (BgMoriKaitenkabe*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgMoriKaitenkabe_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgMoriKaitenkabe* this = (BgMoriKaitenkabe*)thisx; + BgMoriKaitenkabe* pthis = (BgMoriKaitenkabe*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_kaitenkabe.c", 347); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_kaitenkabe.c", 352), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c deleted file mode 100644 index 8d6e84ac2..000000000 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c +++ /dev/null @@ -1,247 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_RAKKATENJO_Z_BG_MORI_RAKKATENJO_C -#include "actor_common.h" -/* - * File: z_bg_mori_rakkatenjo.c - * Overlay: ovl_Bg_Mori_Rakkatenjo - * Description: Falling ceiling in Forest Temple - */ - -#include "z_bg_mori_rakkatenjo.h" -#include "objects/object_mori_objects/object_mori_objects.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_lib.h" -#include "def/z_quake.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgMoriRakkatenjo_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMoriRakkatenjo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMoriRakkatenjo_Update(Actor* thisx, GlobalContext* globalCtx); -void BgMoriRakkatenjo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgMoriRakkatenjo_SetupWaitForMoriTex(BgMoriRakkatenjo* this); -void BgMoriRakkatenjo_WaitForMoriTex(BgMoriRakkatenjo* this, GlobalContext* globalCtx); -void BgMoriRakkatenjo_SetupWait(BgMoriRakkatenjo* this); -void BgMoriRakkatenjo_Wait(BgMoriRakkatenjo* this, GlobalContext* globalCtx); -void BgMoriRakkatenjo_SetupFall(BgMoriRakkatenjo* this); -void BgMoriRakkatenjo_Fall(BgMoriRakkatenjo* this, GlobalContext* globalCtx); -void BgMoriRakkatenjo_SetupRest(BgMoriRakkatenjo* this); -void BgMoriRakkatenjo_Rest(BgMoriRakkatenjo* this, GlobalContext* globalCtx); -void BgMoriRakkatenjo_SetupRise(BgMoriRakkatenjo* this); -void BgMoriRakkatenjo_Rise(BgMoriRakkatenjo* this, GlobalContext* globalCtx); - -static s16 sCamSetting = 0; - -const ActorInit Bg_Mori_Rakkatenjo_InitVars = { - ACTOR_BG_MORI_RAKKATENJO, - ACTORCAT_BG, - FLAGS, - OBJECT_MORI_OBJECTS, - sizeof(BgMoriRakkatenjo), - (ActorFunc)BgMoriRakkatenjo_Init, - (ActorFunc)BgMoriRakkatenjo_Destroy, - (ActorFunc)BgMoriRakkatenjo_Update, - NULL, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -11, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -void BgMoriRakkatenjo_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriRakkatenjo* this = (BgMoriRakkatenjo*)thisx; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - // "Forest Temple obj. Falling Ceiling" - osSyncPrintf("森の神殿 obj. 落下天井 (home posY %f)\n", this->dyna.actor.home.pos.y); - if ((fabsf(1991.0f - this->dyna.actor.home.pos.x) > 0.001f) || - (fabsf(683.0f - this->dyna.actor.home.pos.y) > 0.001f) || - (fabsf(-2520.0f - this->dyna.actor.home.pos.z) > 0.001f)) { - // "The set position has been changed. Let's fix the program." - osSyncPrintf("Warning : セット位置が変更されています。プログラムを修正しましょう。\n"); - } - if (this->dyna.actor.home.rot.y != 0x8000) { - // "The set Angle has changed. Let's fix the program." - osSyncPrintf("Warning : セット Angle が変更されています。プログラムを修正しましょう。\n"); - } - this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); - if (this->moriTexObjIndex < 0) { - // "Forest Temple obj Falling Ceiling Bank Danger!" - osSyncPrintf("Error : 森の神殿 obj 落下天井 バンク危険!(%s %d)\n", "../z_bg_mori_rakkatenjo.c", 205); - Actor_Kill(&this->dyna.actor); - return; - } - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - CollisionHeader_GetVirtual(&gMoriRakkatenjoCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - BgMoriRakkatenjo_SetupWaitForMoriTex(this); - sCamSetting = 0; -} - -void BgMoriRakkatenjo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriRakkatenjo* this = (BgMoriRakkatenjo*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -s32 BgMoriRakkatenjo_IsLinkUnder(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - Vec3f* pos = &GET_PLAYER(globalCtx)->actor.world.pos; - - return (-3300.0f < pos->z) && (pos->z < -1840.0f) && (1791.0f < pos->x) && (pos->x < 2191.0f); -} - -s32 BgMoriRakkatenjo_IsLinkClose(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - Vec3f* pos = &GET_PLAYER(globalCtx)->actor.world.pos; - - return (-3360.0f < pos->z) && (pos->z < -1840.0f) && (1791.0f < pos->x) && (pos->x < 2191.0f); -} - -void BgMoriRakkatenjo_SetupWaitForMoriTex(BgMoriRakkatenjo* this) { - this->actionFunc = BgMoriRakkatenjo_WaitForMoriTex; -} - -void BgMoriRakkatenjo_WaitForMoriTex(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) { - BgMoriRakkatenjo_SetupWait(this); - this->dyna.actor.draw = BgMoriRakkatenjo_Draw; - } -} - -void BgMoriRakkatenjo_SetupWait(BgMoriRakkatenjo* this) { - this->timer = (this->fallCount > 0) ? 100 : 21; - this->dyna.actor.world.pos.y = 683.0f; - this->actionFunc = BgMoriRakkatenjo_Wait; -} - -void BgMoriRakkatenjo_Wait(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - if (this->fallCount == 0) { - if (BgMoriRakkatenjo_IsLinkClose(this, globalCtx) || (this->timer < 20)) { - if (this->timer <= 0) { - BgMoriRakkatenjo_SetupFall(this); - } - } else { - this->timer = 21; - } - } else { - if (BgMoriRakkatenjo_IsLinkUnder(this, globalCtx) || (this->timer < 20)) { - if (this->timer <= 0) { - BgMoriRakkatenjo_SetupFall(this); - } - } else { - this->timer = 100; - } - } - if (this->timer < 20) { - func_800788CC(NA_SE_EV_BLOCKSINK - SFX_FLAG); - } -} - -void BgMoriRakkatenjo_SetupFall(BgMoriRakkatenjo* this) { - this->actionFunc = BgMoriRakkatenjo_Fall; - this->bounceCount = 0; - this->dyna.actor.velocity.y = 0.0f; -} - -void BgMoriRakkatenjo_Fall(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - static f32 bounceVel[] = { 4.0f, 1.5f, 0.4f, 0.1f }; - s32 pad; - Actor* thisx = &this->dyna.actor; - s32 quake; - - Actor_MoveForward(thisx); - if ((thisx->velocity.y < 0.0f) && (thisx->world.pos.y <= 403.0f)) { - if (this->bounceCount >= ARRAY_COUNT(bounceVel)) { - BgMoriRakkatenjo_SetupRest(this); - } else { - if (this->bounceCount == 0) { - this->fallCount++; - func_800788CC(NA_SE_EV_STONE_BOUND); - func_800AA000(SQ(thisx->yDistToPlayer), 0xFF, 0x14, 0x96); - } - thisx->world.pos.y = - 403.0f - (thisx->world.pos.y - 403.0f) * bounceVel[this->bounceCount] / fabsf(thisx->velocity.y); - thisx->velocity.y = bounceVel[this->bounceCount]; - this->bounceCount++; - quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quake, 50000); - Quake_SetQuakeValues(quake, 5, 0, 0, 0); - Quake_SetCountdown(quake, 5); - } - } -} - -void BgMoriRakkatenjo_SetupRest(BgMoriRakkatenjo* this) { - this->actionFunc = BgMoriRakkatenjo_Rest; - this->dyna.actor.world.pos.y = 403.0f; - this->timer = 20; -} - -void BgMoriRakkatenjo_Rest(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - if (this->timer <= 0) { - BgMoriRakkatenjo_SetupRise(this); - } -} - -void BgMoriRakkatenjo_SetupRise(BgMoriRakkatenjo* this) { - this->actionFunc = BgMoriRakkatenjo_Rise; - this->dyna.actor.velocity.y = -0.1f; -} - -void BgMoriRakkatenjo_Rise(BgMoriRakkatenjo* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->dyna.actor.velocity.y, 5.0f, 0.06f, 0.1f, 0.0f); - this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; - if (this->dyna.actor.world.pos.y >= 683.0f) { - BgMoriRakkatenjo_SetupWait(this); - } -} - -void BgMoriRakkatenjo_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriRakkatenjo* this = (BgMoriRakkatenjo*)thisx; - - if (this->timer > 0) { - this->timer--; - } - this->actionFunc(this, globalCtx); - if (BgMoriRakkatenjo_IsLinkUnder(this, globalCtx)) { - if (sCamSetting == CAM_SET_NONE) { - osSyncPrintf("camera changed (mori rakka tenjyo) ... \n"); - sCamSetting = globalCtx->cameraPtrs[MAIN_CAM]->setting; - Camera_SetCameraData(globalCtx->cameraPtrs[MAIN_CAM], 1, &this->dyna.actor, NULL, 0, 0, 0); - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FOREST_BIRDS_EYE); - } - } else if (sCamSetting != CAM_SET_NONE) { - osSyncPrintf("camera changed (previous) ... \n"); - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON1); - sCamSetting = 0; - } -} - -void BgMoriRakkatenjo_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgMoriRakkatenjo* this = (BgMoriRakkatenjo*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 497); - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[this->moriTexObjIndex].vromStart); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 502), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_OPA_DISP++, gMoriRakkatenjoDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 506); -} diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.cpp b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.cpp new file mode 100644 index 000000000..57f2d6ce8 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.cpp @@ -0,0 +1,247 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_MORI_RAKKATENJO_Z_BG_MORI_RAKKATENJO_C +#include "actor_common.h" +/* + * File: z_bg_mori_rakkatenjo.c + * Overlay: ovl_Bg_Mori_Rakkatenjo + * Description: Falling ceiling in Forest Temple + */ + +#include "z_bg_mori_rakkatenjo.h" +#include "objects/object_mori_objects/object_mori_objects.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_lib.h" +#include "def/z_quake.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgMoriRakkatenjo_Init(Actor* thisx, GlobalContext* globalCtx); +void BgMoriRakkatenjo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgMoriRakkatenjo_Update(Actor* thisx, GlobalContext* globalCtx); +void BgMoriRakkatenjo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgMoriRakkatenjo_SetupWaitForMoriTex(BgMoriRakkatenjo* pthis); +void BgMoriRakkatenjo_WaitForMoriTex(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx); +void BgMoriRakkatenjo_SetupWait(BgMoriRakkatenjo* pthis); +void BgMoriRakkatenjo_Wait(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx); +void BgMoriRakkatenjo_SetupFall(BgMoriRakkatenjo* pthis); +void BgMoriRakkatenjo_Fall(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx); +void BgMoriRakkatenjo_SetupRest(BgMoriRakkatenjo* pthis); +void BgMoriRakkatenjo_Rest(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx); +void BgMoriRakkatenjo_SetupRise(BgMoriRakkatenjo* pthis); +void BgMoriRakkatenjo_Rise(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx); + +static s16 sCamSetting = 0; + +ActorInit Bg_Mori_Rakkatenjo_InitVars = { + ACTOR_BG_MORI_RAKKATENJO, + ACTORCAT_BG, + FLAGS, + OBJECT_MORI_OBJECTS, + sizeof(BgMoriRakkatenjo), + (ActorFunc)BgMoriRakkatenjo_Init, + (ActorFunc)BgMoriRakkatenjo_Destroy, + (ActorFunc)BgMoriRakkatenjo_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), + ICHAIN_F32(minVelocityY, -11, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +void BgMoriRakkatenjo_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriRakkatenjo* pthis = (BgMoriRakkatenjo*)thisx; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + // "Forest Temple obj. Falling Ceiling" + osSyncPrintf("森の神殿 obj. 落下天井 (home posY %f)\n", pthis->dyna.actor.home.pos.y); + if ((fabsf(1991.0f - pthis->dyna.actor.home.pos.x) > 0.001f) || + (fabsf(683.0f - pthis->dyna.actor.home.pos.y) > 0.001f) || + (fabsf(-2520.0f - pthis->dyna.actor.home.pos.z) > 0.001f)) { + // "The set position has been changed. Let's fix the program." + osSyncPrintf("Warning : セット位置が変更されています。プログラムを修正しましょう。\n"); + } + if (pthis->dyna.actor.home.rot.y != 0x8000) { + // "The set Angle has changed. Let's fix the program." + osSyncPrintf("Warning : セット Angle が変更されています。プログラムを修正しましょう。\n"); + } + pthis->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); + if (pthis->moriTexObjIndex < 0) { + // "Forest Temple obj Falling Ceiling Bank Danger!" + osSyncPrintf("Error : 森の神殿 obj 落下天井 バンク危険!(%s %d)\n", "../z_bg_mori_rakkatenjo.c", 205); + Actor_Kill(&pthis->dyna.actor); + return; + } + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + CollisionHeader_GetVirtual(&gMoriRakkatenjoCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + BgMoriRakkatenjo_SetupWaitForMoriTex(pthis); + sCamSetting = 0; +} + +void BgMoriRakkatenjo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriRakkatenjo* pthis = (BgMoriRakkatenjo*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +s32 BgMoriRakkatenjo_IsLinkUnder(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + Vec3f* pos = &GET_PLAYER(globalCtx)->actor.world.pos; + + return (-3300.0f < pos->z) && (pos->z < -1840.0f) && (1791.0f < pos->x) && (pos->x < 2191.0f); +} + +s32 BgMoriRakkatenjo_IsLinkClose(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + Vec3f* pos = &GET_PLAYER(globalCtx)->actor.world.pos; + + return (-3360.0f < pos->z) && (pos->z < -1840.0f) && (1791.0f < pos->x) && (pos->x < 2191.0f); +} + +void BgMoriRakkatenjo_SetupWaitForMoriTex(BgMoriRakkatenjo* pthis) { + pthis->actionFunc = BgMoriRakkatenjo_WaitForMoriTex; +} + +void BgMoriRakkatenjo_WaitForMoriTex(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->moriTexObjIndex)) { + BgMoriRakkatenjo_SetupWait(pthis); + pthis->dyna.actor.draw = BgMoriRakkatenjo_Draw; + } +} + +void BgMoriRakkatenjo_SetupWait(BgMoriRakkatenjo* pthis) { + pthis->timer = (pthis->fallCount > 0) ? 100 : 21; + pthis->dyna.actor.world.pos.y = 683.0f; + pthis->actionFunc = BgMoriRakkatenjo_Wait; +} + +void BgMoriRakkatenjo_Wait(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + if (pthis->fallCount == 0) { + if (BgMoriRakkatenjo_IsLinkClose(pthis, globalCtx) || (pthis->timer < 20)) { + if (pthis->timer <= 0) { + BgMoriRakkatenjo_SetupFall(pthis); + } + } else { + pthis->timer = 21; + } + } else { + if (BgMoriRakkatenjo_IsLinkUnder(pthis, globalCtx) || (pthis->timer < 20)) { + if (pthis->timer <= 0) { + BgMoriRakkatenjo_SetupFall(pthis); + } + } else { + pthis->timer = 100; + } + } + if (pthis->timer < 20) { + func_800788CC(NA_SE_EV_BLOCKSINK - SFX_FLAG); + } +} + +void BgMoriRakkatenjo_SetupFall(BgMoriRakkatenjo* pthis) { + pthis->actionFunc = BgMoriRakkatenjo_Fall; + pthis->bounceCount = 0; + pthis->dyna.actor.velocity.y = 0.0f; +} + +void BgMoriRakkatenjo_Fall(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + static f32 bounceVel[] = { 4.0f, 1.5f, 0.4f, 0.1f }; + s32 pad; + Actor* thisx = &pthis->dyna.actor; + s32 quake; + + Actor_MoveForward(thisx); + if ((thisx->velocity.y < 0.0f) && (thisx->world.pos.y <= 403.0f)) { + if (pthis->bounceCount >= ARRAY_COUNT(bounceVel)) { + BgMoriRakkatenjo_SetupRest(pthis); + } else { + if (pthis->bounceCount == 0) { + pthis->fallCount++; + func_800788CC(NA_SE_EV_STONE_BOUND); + func_800AA000(SQ(thisx->yDistToPlayer), 0xFF, 0x14, 0x96); + } + thisx->world.pos.y = + 403.0f - (thisx->world.pos.y - 403.0f) * bounceVel[pthis->bounceCount] / fabsf(thisx->velocity.y); + thisx->velocity.y = bounceVel[pthis->bounceCount]; + pthis->bounceCount++; + quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(quake, 50000); + Quake_SetQuakeValues(quake, 5, 0, 0, 0); + Quake_SetCountdown(quake, 5); + } + } +} + +void BgMoriRakkatenjo_SetupRest(BgMoriRakkatenjo* pthis) { + pthis->actionFunc = BgMoriRakkatenjo_Rest; + pthis->dyna.actor.world.pos.y = 403.0f; + pthis->timer = 20; +} + +void BgMoriRakkatenjo_Rest(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + if (pthis->timer <= 0) { + BgMoriRakkatenjo_SetupRise(pthis); + } +} + +void BgMoriRakkatenjo_SetupRise(BgMoriRakkatenjo* pthis) { + pthis->actionFunc = BgMoriRakkatenjo_Rise; + pthis->dyna.actor.velocity.y = -0.1f; +} + +void BgMoriRakkatenjo_Rise(BgMoriRakkatenjo* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->dyna.actor.velocity.y, 5.0f, 0.06f, 0.1f, 0.0f); + pthis->dyna.actor.world.pos.y += pthis->dyna.actor.velocity.y; + if (pthis->dyna.actor.world.pos.y >= 683.0f) { + BgMoriRakkatenjo_SetupWait(pthis); + } +} + +void BgMoriRakkatenjo_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriRakkatenjo* pthis = (BgMoriRakkatenjo*)thisx; + + if (pthis->timer > 0) { + pthis->timer--; + } + pthis->actionFunc(pthis, globalCtx); + if (BgMoriRakkatenjo_IsLinkUnder(pthis, globalCtx)) { + if (sCamSetting == CAM_SET_NONE) { + osSyncPrintf("camera changed (mori rakka tenjyo) ... \n"); + sCamSetting = globalCtx->cameraPtrs[MAIN_CAM]->setting; + Camera_SetCameraData(globalCtx->cameraPtrs[MAIN_CAM], 1, &pthis->dyna.actor, NULL, 0, 0, 0); + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_FOREST_BIRDS_EYE); + } + } else if (sCamSetting != CAM_SET_NONE) { + osSyncPrintf("camera changed (previous) ... \n"); + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON1); + sCamSetting = 0; + } +} + +void BgMoriRakkatenjo_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgMoriRakkatenjo* pthis = (BgMoriRakkatenjo*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 497); + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, gObjectTable[pthis->moriTexObjIndex].vromStart.get()); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 502), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gMoriRakkatenjoDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_rakkatenjo.c", 506); +} diff --git a/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c b/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c deleted file mode 100644 index dfca7fd0f..000000000 --- a/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c +++ /dev/null @@ -1,649 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_PO_EVENT_Z_BG_PO_EVENT_C -#include "actor_common.h" -/* - * File: z_bg_po_event.c - * Overlay: ovl_Bg_Po_Event - * Description: Poe sisters' paintings and puzzle blocks - */ - -#include "z_bg_po_event.h" -#include "objects/object_po_sisters/object_po_sisters.h" -#include "def/code_80043480.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void BgPoEvent_Init(Actor* thisx, GlobalContext* globalCtx); -void BgPoEvent_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgPoEvent_Update(Actor* thisx, GlobalContext* globalCtx); -void BgPoEvent_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgPoEvent_BlockWait(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_BlockShake(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_BlockFall(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_BlockIdle(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_BlockPush(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_BlockReset(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_BlockSolved(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_AmyWait(BgPoEvent* this, GlobalContext* globalCtx); // Amy is the green Poe -void BgPoEvent_AmyPuzzle(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_PaintingEmpty(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_PaintingAppear(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_PaintingPresent(BgPoEvent* this, GlobalContext* globalCtx); -void BgPoEvent_PaintingBurn(BgPoEvent* this, GlobalContext* globalCtx); - -const ActorInit Bg_Po_Event_InitVars = { - ACTOR_BG_PO_EVENT, - ACTORCAT_BG, - FLAGS, - OBJECT_PO_SISTERS, - sizeof(BgPoEvent), - (ActorFunc)BgPoEvent_Init, - (ActorFunc)BgPoEvent_Destroy, - (ActorFunc)BgPoEvent_Update, - (ActorFunc)BgPoEvent_Draw, -}; - -static ColliderTrisElementInit sTrisElementsInit[2] = { - { - { - ELEMTYPE_UNK4, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F820, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 25.0f, 33.0f, 0.0f }, { -25.0f, 33.0f, 0.0f }, { -25.0f, -33.0f, 0.0f } } }, - }, - { - { - ELEMTYPE_UNK4, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F820, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 25.0f, 33.0f, 0.0f }, { -25.0f, -33.0f, 0.0f }, { 25.0f, -33.0f, 0.0f } } }, - }, -}; - -static ColliderTrisInit sTrisInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_TRIS, - }, - 2, - sTrisElementsInit, -}; - -static u8 sBlocksAtRest = 0; - -static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; - -static u8 sPuzzleState; - -void BgPoEvent_InitPaintings(BgPoEvent* this, GlobalContext* globalCtx) { - static s16 paintingPosX[] = { -1302, -866, 1421, 985 }; - static s16 paintingPosY[] = { 1107, 1091 }; - static s16 paintingPosZ[] = { -3384, -3252 }; - ColliderTrisElementInit* item; - Vec3f* vtxVec; - s32 i1; - s32 i2; - Vec3f sp9C[3]; - f32 coss; - f32 sins; - f32 scaleY; - s32 phi_t2; - Actor* newPainting; - - sins = Math_SinS(this->dyna.actor.shape.rot.y); - coss = Math_CosS(this->dyna.actor.shape.rot.y); - if (this->type == 4) { - sins *= 2.4f; - scaleY = 1.818f; - coss *= 2.4f; - } else { - scaleY = 1.0f; - } - for (i1 = 0; i1 < sTrisInit.count; i1++) { - item = &sTrisInit.elements[i1]; - if (1) {} // This section looks like a macro of some sort. - for (i2 = 0; i2 < 3; i2++) { - vtxVec = &item->dim.vtx[i2]; - sp9C[i2].x = (vtxVec->x * coss) + (this->dyna.actor.home.pos.x + (sins * vtxVec->z)); - sp9C[i2].y = (vtxVec->y * scaleY) + this->dyna.actor.home.pos.y; - sp9C[i2].z = this->dyna.actor.home.pos.z + (coss * vtxVec->z) - (vtxVec->x * sins); - } - Collider_SetTrisVertices(&this->collider, i1, &sp9C[0], &sp9C[1], &sp9C[2]); - } - if ((this->type != 4) && (this->index != 2)) { - phi_t2 = (this->type == 2) ? this->index : this->index + 2; - newPainting = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_PO_EVENT, - paintingPosX[phi_t2], paintingPosY[this->index], paintingPosZ[this->index], 0, - this->dyna.actor.shape.rot.y + 0x8000, 0, - ((this->index + 1) << 0xC) + (this->type << 8) + this->dyna.actor.params); - if (newPainting == NULL) { - Actor_Kill(&this->dyna.actor); - return; - } - if (this->index == 0) { - if (this->dyna.actor.child->child == NULL) { - Actor_Kill(&this->dyna.actor); - return; - } - this->dyna.actor.parent = this->dyna.actor.child->child; - this->dyna.actor.child->child->child = &this->dyna.actor; - } - } - this->timer = 0; - if (this->type == 4) { - sPuzzleState = 0; - this->actionFunc = BgPoEvent_AmyWait; - } else { - sPuzzleState = (s32)(Rand_ZeroOne() * 3.0f) % 3; - this->actionFunc = BgPoEvent_PaintingEmpty; - } -} - -void BgPoEvent_InitBlocks(BgPoEvent* this, GlobalContext* globalCtx) { - static s16 blockPosX[] = { 2149, 1969, 1909 }; - static s16 blockPosZ[] = { -1410, -1350, -1530 }; - Actor* newBlock; - CollisionHeader* colHeader = NULL; - s32 bgId; - - this->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - CollisionHeader_GetVirtual(&gPoSistersAmyBlockCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if ((this->type == 0) && (this->index != 3)) { - newBlock = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_PO_EVENT, - blockPosX[this->index], this->dyna.actor.world.pos.y, blockPosZ[this->index], 0, - this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z - 0x4000, - ((this->index + 1) << 0xC) + (this->type << 8) + this->dyna.actor.params); - if (newBlock == NULL) { - Actor_Kill(&this->dyna.actor); - return; - } - if (this->index == 0) { - if (this->dyna.actor.child->child == NULL) { - Actor_Kill(&this->dyna.actor); - return; - } - if (this->dyna.actor.child->child->child == NULL) { - Actor_Kill(&this->dyna.actor); - Actor_Kill(this->dyna.actor.child); - return; - } - this->dyna.actor.parent = this->dyna.actor.child->child->child; - this->dyna.actor.child->child->child->child = &this->dyna.actor; - } - } - this->dyna.actor.world.pos.y = 833.0f; - this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &bgId, - &this->dyna.actor, &this->dyna.actor.world.pos); - this->actionFunc = BgPoEvent_BlockWait; -} - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -void BgPoEvent_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgPoEvent* this = (BgPoEvent*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - this->type = (thisx->params >> 8) & 0xF; - this->index = (thisx->params >> 0xC) & 0xF; - thisx->params &= 0x3F; - - if (this->type >= 2) { - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, thisx, &sTrisInit, this->colliderItems); - if (Flags_GetSwitch(globalCtx, thisx->params)) { - Actor_Kill(thisx); - } else { - BgPoEvent_InitPaintings(this, globalCtx); - } - } else { - DynaPolyActor_Init(&this->dyna, DPM_UNK); - if (Flags_GetSwitch(globalCtx, thisx->params)) { - Actor_Kill(thisx); - } else { - BgPoEvent_InitBlocks(this, globalCtx); - } - } -} - -void BgPoEvent_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgPoEvent* this = (BgPoEvent*)thisx; - - if (this->type >= 2) { - Collider_DestroyTris(globalCtx, &this->collider); - } else { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if ((this->type == 1) && (gSaveContext.timer1Value > 0)) { - gSaveContext.timer1State = 0xA; - } - } -} - -void BgPoEvent_BlockWait(BgPoEvent* this, GlobalContext* globalCtx) { - this->dyna.actor.world.pos.y = 833.0f; - if (sPuzzleState == 0x3F) { - if (this->type == 1) { - OnePointCutscene_Init(globalCtx, 3150, 65, NULL, MAIN_CAM); - } - this->timer = 45; - this->actionFunc = BgPoEvent_BlockShake; - } else if (this->dyna.actor.xzDistToPlayer > 50.0f) { - if (this->type != 1) { - sPuzzleState |= (1 << this->index); - } else { - sPuzzleState |= 0x10; - } - } else if (this->type != 1) { - sPuzzleState &= ~(1 << this->index); - } else { - sPuzzleState &= ~0x10; - } -} - -void BgPoEvent_BlockShake(BgPoEvent* this, GlobalContext* globalCtx) { - DECR(this->timer); - if (this->timer < 15) { - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + 2.0f * ((this->timer % 3) - 1); - if (!(this->timer % 4)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE); - } - } - if (this->timer == 0) { - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - sPuzzleState = 0; - this->timer = 60; - this->actionFunc = BgPoEvent_BlockFall; - } -} - -void BgPoEvent_CheckBlock(BgPoEvent* this) { - s32 phi_v1; - s32 phi_a1; - s32 phi_t0; - s32 phi_a3; - - if ((this->index == 3) || (this->index == 1)) { - phi_v1 = this->dyna.actor.world.pos.z; - phi_a1 = this->dyna.actor.child->world.pos.z; - if (this->index == 3) { - phi_a3 = this->dyna.actor.world.pos.x; - phi_t0 = this->dyna.actor.child->world.pos.x; - } else { // this->index == 1 - phi_a3 = this->dyna.actor.child->world.pos.x; - phi_t0 = this->dyna.actor.world.pos.x; - } - } else { - phi_v1 = this->dyna.actor.world.pos.x; - phi_a1 = this->dyna.actor.child->world.pos.x; - if (this->index == 0) { - phi_a3 = this->dyna.actor.world.pos.z; - phi_t0 = this->dyna.actor.child->world.pos.z; - } else { // this->index == 2 - phi_a3 = this->dyna.actor.child->world.pos.z; - phi_t0 = this->dyna.actor.world.pos.z; - } - } - if ((phi_v1 == phi_a1) && ((phi_t0 - phi_a3) == 60)) { - sPuzzleState |= (1 << this->index); - } else { - sPuzzleState &= ~(1 << this->index); - } -} - -void BgPoEvent_BlockFall(BgPoEvent* this, GlobalContext* globalCtx) { - static s32 firstFall = 0; - - this->dyna.actor.velocity.y++; - if (Math_StepToF(&this->dyna.actor.world.pos.y, 433.0f, this->dyna.actor.velocity.y)) { - this->dyna.actor.flags &= ~ACTOR_FLAG_5; - this->dyna.actor.velocity.y = 0.0f; - sBlocksAtRest++; - if (this->type != 1) { - BgPoEvent_CheckBlock(this); - } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - func_80033E88(&this->dyna.actor, globalCtx, 5, 5); - func_80088B34(this->timer); - if (firstFall == 0) { - firstFall = 1; - } else { - func_8002DF54(globalCtx, &GET_PLAYER(globalCtx)->actor, 7); - } - } - this->direction = 0; - this->actionFunc = BgPoEvent_BlockIdle; - } -} - -void BgPoEvent_BlockIdle(BgPoEvent* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Actor* amy; - - if (sPuzzleState == 0xF) { - this->actionFunc = BgPoEvent_BlockSolved; - if ((this->type == 0) && (this->index == 0)) { - amy = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, this->dyna.actor.world.pos.x + 30.0f, - this->dyna.actor.world.pos.y - 30.0f, this->dyna.actor.world.pos.z + 30.0f, 0, - this->dyna.actor.shape.rot.y, 0, this->dyna.actor.params + 0x300); - if (amy != NULL) { - OnePointCutscene_Init(globalCtx, 3170, 30, amy, MAIN_CAM); - } - func_80078884(NA_SE_SY_CORRECT_CHIME); - gSaveContext.timer1State = 0xA; - } - } else { - if ((gSaveContext.timer1Value == 0) && (sBlocksAtRest == 5)) { - player->stateFlags2 &= ~0x10; - sPuzzleState = 0x10; - sBlocksAtRest = 0; - } - if ((sPuzzleState == 0x40) || ((sPuzzleState == 0x10) && !Player_InCsMode(globalCtx))) { - this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z; - this->actionFunc = BgPoEvent_BlockReset; - if (sPuzzleState == 0x10) { - sPuzzleState = 0x40; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_RISING); - func_8002DF54(globalCtx, &player->actor, 8); - } - } else if (this->dyna.unk_150 != 0.0f) { - if (this->direction == 0) { - if (func_800435D8(globalCtx, &this->dyna, 0x1E, 0x32, -0x14) != 0) { - sBlocksAtRest--; - this->direction = (this->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; - this->actionFunc = BgPoEvent_BlockPush; - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - DECR(this->direction); - } - } else { - this->direction = 0; - } - } -} - -void BgPoEvent_BlockPush(BgPoEvent* this, GlobalContext* globalCtx) { - static f32 blockPushDist = 0.0f; - f32 displacement; - s32 blockStop; - Player* player = GET_PLAYER(globalCtx); - - this->dyna.actor.speedXZ += 0.1f; - this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 2.0f); - blockStop = Math_StepToF(&blockPushDist, 20.0f, this->dyna.actor.speedXZ); - displacement = this->direction * blockPushDist; - this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.unk_158) * displacement) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.unk_158) * displacement) + this->dyna.actor.home.pos.z; - if (blockStop) { - player->stateFlags2 &= ~0x10; - if ((this->dyna.unk_150 > 0.0f) && (func_800435D8(globalCtx, &this->dyna, 0x1E, 0x32, -0x14) == 0)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - } - this->dyna.unk_150 = 0.0f; - this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; - this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; - blockPushDist = 0.0f; - this->dyna.actor.speedXZ = 0.0f; - this->direction = 5; - sBlocksAtRest++; - this->actionFunc = BgPoEvent_BlockIdle; - if (this->type == 1) { - return; - } - BgPoEvent_CheckBlock(this); - BgPoEvent_CheckBlock((BgPoEvent*)this->dyna.actor.parent); - } - func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); -} - -void BgPoEvent_BlockReset(BgPoEvent* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } - if (Math_StepToF(&this->dyna.actor.world.pos.y, 493.0f, 1.0f) && - Math_ScaledStepToS(&this->dyna.actor.shape.rot.z, this->dyna.actor.world.rot.z - 0x4000, 0x400)) { - - this->index = (this->index + 1) % 4; - this->actionFunc = BgPoEvent_BlockFall; - sPuzzleState = 0; - if (this->type == 1) { - this->timer += 10; - this->timer = CLAMP_MAX(this->timer, 120); - } - } -} - -void BgPoEvent_BlockSolved(BgPoEvent* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; - } - if (Math_StepToF(&this->dyna.actor.world.pos.y, 369.0f, 2.0f)) { - sPuzzleState = 0x20; - Actor_Kill(&this->dyna.actor); - } -} - -void BgPoEvent_AmyWait(BgPoEvent* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - sPuzzleState |= 0x20; - this->timer = 5; - Actor_SetColorFilter(&this->dyna.actor, 0x4000, 0xFF, 0, 5); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_PO_LAUGH2); - this->actionFunc = BgPoEvent_AmyPuzzle; - } -} - -void BgPoEvent_AmyPuzzle(BgPoEvent* this, GlobalContext* globalCtx) { - Vec3f pos; - - if (sPuzzleState == 0xF) { - pos.x = this->dyna.actor.world.pos.x - 5.0f; - pos.y = Rand_CenteredFloat(120.0f) + this->dyna.actor.world.pos.y; - pos.z = Rand_CenteredFloat(120.0f) + this->dyna.actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &pos, &sZeroVec, &sZeroVec, 170, 0, 200, 255, 100, 170, 0, 255, 0, 1, 9, true); - } else if (sPuzzleState == 0x20) { - Actor_Kill(&this->dyna.actor); - } else { - DECR(this->timer); - } -} - -s32 BgPoEvent_NextPainting(BgPoEvent* this) { - if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.child != NULL)) { - if (Rand_ZeroOne() < 0.5f) { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.parent)->index; - } else { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.child)->index; - } - } else if (this->dyna.actor.parent != NULL) { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.parent)->index; - } else if (this->dyna.actor.child != NULL) { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.child)->index; - } else { - return false; - } - return true; -} - -void BgPoEvent_PaintingEmpty(BgPoEvent* this, GlobalContext* globalCtx) { - if (sPuzzleState == this->index) { - this->timer = 255; - this->actionFunc = BgPoEvent_PaintingAppear; - } -} - -void BgPoEvent_PaintingAppear(BgPoEvent* this, GlobalContext* globalCtx) { - this->timer -= 20; - if (this->timer <= 0) { - this->timer = 1000; - this->actionFunc = BgPoEvent_PaintingPresent; - } -} - -void BgPoEvent_PaintingVanish(BgPoEvent* this, GlobalContext* globalCtx) { - this->timer += 20; - if (this->timer >= 255) { - BgPoEvent_NextPainting(this); - this->actionFunc = BgPoEvent_PaintingEmpty; - } -} - -void BgPoEvent_PaintingPresent(BgPoEvent* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - Player* player = GET_PLAYER(globalCtx); - - DECR(this->timer); - - if (((this->timer == 0) || ((thisx->xzDistToPlayer < 150.0f) && (thisx->yDistToPlayer < 50.0f)) || - (func_8002DD78(player) && (thisx->xzDistToPlayer < 320.0f) && - ((this->index != 2) ? (thisx->yDistToPlayer < 100.0f) : (thisx->yDistToPlayer < 0.0f)) && - Player_IsFacingActor(thisx, 0x2000, globalCtx))) && - ((thisx->parent != NULL) || (thisx->child != NULL))) { - /*The third condition in the || is checking if - 1) Link is holding a ranged weapon - 2) Link is too close in the xz plane - 3) Link is too close in the y direction. The painting - under the balcony allows him to be closer. - 4) Link is within 45 degrees of facing the painting. */ - this->timer = 0; - Audio_PlayActorSound2(thisx, NA_SE_EN_PO_LAUGH); - this->actionFunc = BgPoEvent_PaintingVanish; - } else if (this->collider.base.acFlags & AC_HIT) { - if (!BgPoEvent_NextPainting(this)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, thisx->world.pos.x, - thisx->world.pos.y - 40.0f, thisx->world.pos.z, 0, thisx->shape.rot.y, 0, - thisx->params + ((this->type - 1) << 8)); - OnePointCutscene_Init(globalCtx, 3160, 80, thisx, MAIN_CAM); - func_80078884(NA_SE_SY_CORRECT_CHIME); - - } else { - Audio_PlayActorSound2(thisx, NA_SE_EN_PO_LAUGH2); - OnePointCutscene_Init(globalCtx, 3160, 35, thisx, MAIN_CAM); - } - if (thisx->parent != NULL) { - thisx->parent->child = NULL; - thisx->parent = NULL; - } - if (thisx->child != NULL) { - thisx->child->parent = NULL; - thisx->child = NULL; - } - this->timer = 20; - this->actionFunc = BgPoEvent_PaintingBurn; - } -} - -void BgPoEvent_PaintingBurn(BgPoEvent* this, GlobalContext* globalCtx) { - Vec3f sp54; - - this->timer--; - sp54.x = (Math_SinS(this->dyna.actor.shape.rot.y) * 5.0f) + this->dyna.actor.world.pos.x; - sp54.y = Rand_CenteredFloat(66.0f) + this->dyna.actor.world.pos.y; - sp54.z = Rand_CenteredFloat(50.0f) + this->dyna.actor.world.pos.z; - if (this->timer >= 0) { - if (this->type == 2) { - EffectSsDeadDb_Spawn(globalCtx, &sp54, &sZeroVec, &sZeroVec, 100, 0, 255, 255, 150, 170, 255, 0, 0, 1, 9, - true); - } else { - EffectSsDeadDb_Spawn(globalCtx, &sp54, &sZeroVec, &sZeroVec, 100, 0, 200, 255, 255, 170, 50, 100, 255, 1, 9, - true); - } - } - if (this->timer == 0) { - this->dyna.actor.draw = NULL; - } - if (this->timer < -60) { - Actor_Kill(&this->dyna.actor); - } -} - -void BgPoEvent_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgPoEvent* this = (BgPoEvent*)thisx; - - this->actionFunc(this, globalCtx); - if ((this->actionFunc == BgPoEvent_AmyWait) || (this->actionFunc == BgPoEvent_PaintingPresent)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void BgPoEvent_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Gfx* displayLists[] = { - gPoSistersAmyBlockDL, gPoSistersAmyBethBlockDL, gPoSistersJoellePaintingDL, - gPoSistersBethPaintingDL, gPoSistersAmyPaintingDL, - }; - s32 pad; - BgPoEvent* this = (BgPoEvent*)thisx; - u8 alpha; - Vec3f sp58; - Vec3f sp4C; - f32 sp48; - s32 pad2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_po_event.c", 1481); - func_80093D18(globalCtx->state.gfxCtx); - if ((this->type == 3) || (this->type == 2)) { - if (this->actionFunc == BgPoEvent_PaintingEmpty) { - alpha = 255; - } else if (this->actionFunc == BgPoEvent_PaintingPresent) { - alpha = 0; - } else { - alpha = this->timer; - } - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, alpha); - } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_po_event.c", 1501), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, displayLists[this->type]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_po_event.c", 1508); - - if ((this->type == 0) || (this->type == 1)) { - sp48 = (833.0f - this->dyna.actor.world.pos.y) * 0.0025f; - if (!(sp48 > 1.0f)) { - sp58.x = this->dyna.actor.world.pos.x; - sp58.y = this->dyna.actor.world.pos.y - 30.0f; - sp58.z = this->dyna.actor.world.pos.z; - sp4C.y = 1.0f; - sp4C.x = sp4C.z = (sp48 * 0.3f) + 0.4f; - func_80033C30(&sp58, &sp4C, (u8)(155.0f + sp48 * 100.0f), globalCtx); - } - } -} diff --git a/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.cpp b/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.cpp new file mode 100644 index 000000000..913858895 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.cpp @@ -0,0 +1,649 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_PO_EVENT_Z_BG_PO_EVENT_C +#include "actor_common.h" +/* + * File: z_bg_po_event.c + * Overlay: ovl_Bg_Po_Event + * Description: Poe sisters' paintings and puzzle blocks + */ + +#include "z_bg_po_event.h" +#include "objects/object_po_sisters/object_po_sisters.h" +#include "def/code_80043480.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void BgPoEvent_Init(Actor* thisx, GlobalContext* globalCtx); +void BgPoEvent_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgPoEvent_Update(Actor* thisx, GlobalContext* globalCtx); +void BgPoEvent_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgPoEvent_BlockWait(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_BlockShake(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_BlockFall(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_BlockIdle(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_BlockPush(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_BlockReset(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_BlockSolved(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_AmyWait(BgPoEvent* pthis, GlobalContext* globalCtx); // Amy is the green Poe +void BgPoEvent_AmyPuzzle(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_PaintingEmpty(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_PaintingAppear(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_PaintingPresent(BgPoEvent* pthis, GlobalContext* globalCtx); +void BgPoEvent_PaintingBurn(BgPoEvent* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Po_Event_InitVars = { + ACTOR_BG_PO_EVENT, + ACTORCAT_BG, + FLAGS, + OBJECT_PO_SISTERS, + sizeof(BgPoEvent), + (ActorFunc)BgPoEvent_Init, + (ActorFunc)BgPoEvent_Destroy, + (ActorFunc)BgPoEvent_Update, + (ActorFunc)BgPoEvent_Draw, +}; + +static ColliderTrisElementInit sTrisElementsInit[2] = { + { + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F820, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 25.0f, 33.0f, 0.0f }, { -25.0f, 33.0f, 0.0f }, { -25.0f, -33.0f, 0.0f } } }, + }, + { + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F820, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 25.0f, 33.0f, 0.0f }, { -25.0f, -33.0f, 0.0f }, { 25.0f, -33.0f, 0.0f } } }, + }, +}; + +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, +}; + +static u8 sBlocksAtRest = 0; + +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +static u8 sPuzzleState; + +void BgPoEvent_InitPaintings(BgPoEvent* pthis, GlobalContext* globalCtx) { + static s16 paintingPosX[] = { -1302, -866, 1421, 985 }; + static s16 paintingPosY[] = { 1107, 1091 }; + static s16 paintingPosZ[] = { -3384, -3252 }; + ColliderTrisElementInit* item; + Vec3f* vtxVec; + s32 i1; + s32 i2; + Vec3f sp9C[3]; + f32 coss; + f32 sins; + f32 scaleY; + s32 phi_t2; + Actor* newPainting; + + sins = Math_SinS(pthis->dyna.actor.shape.rot.y); + coss = Math_CosS(pthis->dyna.actor.shape.rot.y); + if (pthis->type == 4) { + sins *= 2.4f; + scaleY = 1.818f; + coss *= 2.4f; + } else { + scaleY = 1.0f; + } + for (i1 = 0; i1 < sTrisInit.count; i1++) { + item = &sTrisInit.elements[i1]; + if (1) {} // This section looks like a macro of some sort. + for (i2 = 0; i2 < 3; i2++) { + vtxVec = &item->dim.vtx[i2]; + sp9C[i2].x = (vtxVec->x * coss) + (pthis->dyna.actor.home.pos.x + (sins * vtxVec->z)); + sp9C[i2].y = (vtxVec->y * scaleY) + pthis->dyna.actor.home.pos.y; + sp9C[i2].z = pthis->dyna.actor.home.pos.z + (coss * vtxVec->z) - (vtxVec->x * sins); + } + Collider_SetTrisVertices(&pthis->collider, i1, &sp9C[0], &sp9C[1], &sp9C[2]); + } + if ((pthis->type != 4) && (pthis->index != 2)) { + phi_t2 = (pthis->type == 2) ? pthis->index : pthis->index + 2; + newPainting = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_PO_EVENT, + paintingPosX[phi_t2], paintingPosY[pthis->index], paintingPosZ[pthis->index], 0, + pthis->dyna.actor.shape.rot.y + 0x8000, 0, + ((pthis->index + 1) << 0xC) + (pthis->type << 8) + pthis->dyna.actor.params); + if (newPainting == NULL) { + Actor_Kill(&pthis->dyna.actor); + return; + } + if (pthis->index == 0) { + if (pthis->dyna.actor.child->child == NULL) { + Actor_Kill(&pthis->dyna.actor); + return; + } + pthis->dyna.actor.parent = pthis->dyna.actor.child->child; + pthis->dyna.actor.child->child->child = &pthis->dyna.actor; + } + } + pthis->timer = 0; + if (pthis->type == 4) { + sPuzzleState = 0; + pthis->actionFunc = BgPoEvent_AmyWait; + } else { + sPuzzleState = (s32)(Rand_ZeroOne() * 3.0f) % 3; + pthis->actionFunc = BgPoEvent_PaintingEmpty; + } +} + +void BgPoEvent_InitBlocks(BgPoEvent* pthis, GlobalContext* globalCtx) { + static s16 blockPosX[] = { 2149, 1969, 1909 }; + static s16 blockPosZ[] = { -1410, -1350, -1530 }; + Actor* newBlock; + CollisionHeader* colHeader = NULL; + s32 bgId; + + pthis->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + CollisionHeader_GetVirtual(&gPoSistersAmyBlockCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if ((pthis->type == 0) && (pthis->index != 3)) { + newBlock = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_PO_EVENT, + blockPosX[pthis->index], pthis->dyna.actor.world.pos.y, blockPosZ[pthis->index], 0, + pthis->dyna.actor.shape.rot.y, pthis->dyna.actor.shape.rot.z - 0x4000, + ((pthis->index + 1) << 0xC) + (pthis->type << 8) + pthis->dyna.actor.params); + if (newBlock == NULL) { + Actor_Kill(&pthis->dyna.actor); + return; + } + if (pthis->index == 0) { + if (pthis->dyna.actor.child->child == NULL) { + Actor_Kill(&pthis->dyna.actor); + return; + } + if (pthis->dyna.actor.child->child->child == NULL) { + Actor_Kill(&pthis->dyna.actor); + Actor_Kill(pthis->dyna.actor.child); + return; + } + pthis->dyna.actor.parent = pthis->dyna.actor.child->child->child; + pthis->dyna.actor.child->child->child->child = &pthis->dyna.actor; + } + } + pthis->dyna.actor.world.pos.y = 833.0f; + pthis->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, &bgId, + &pthis->dyna.actor, &pthis->dyna.actor.world.pos); + pthis->actionFunc = BgPoEvent_BlockWait; +} + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +void BgPoEvent_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgPoEvent* pthis = (BgPoEvent*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + pthis->type = (thisx->params >> 8) & 0xF; + pthis->index = (thisx->params >> 0xC) & 0xF; + thisx->params &= 0x3F; + + if (pthis->type >= 2) { + Collider_InitTris(globalCtx, &pthis->collider); + Collider_SetTris(globalCtx, &pthis->collider, thisx, &sTrisInit, pthis->colliderItems); + if (Flags_GetSwitch(globalCtx, thisx->params)) { + Actor_Kill(thisx); + } else { + BgPoEvent_InitPaintings(pthis, globalCtx); + } + } else { + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + if (Flags_GetSwitch(globalCtx, thisx->params)) { + Actor_Kill(thisx); + } else { + BgPoEvent_InitBlocks(pthis, globalCtx); + } + } +} + +void BgPoEvent_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgPoEvent* pthis = (BgPoEvent*)thisx; + + if (pthis->type >= 2) { + Collider_DestroyTris(globalCtx, &pthis->collider); + } else { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if ((pthis->type == 1) && (gSaveContext.timer1Value > 0)) { + gSaveContext.timer1State = 0xA; + } + } +} + +void BgPoEvent_BlockWait(BgPoEvent* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.world.pos.y = 833.0f; + if (sPuzzleState == 0x3F) { + if (pthis->type == 1) { + OnePointCutscene_Init(globalCtx, 3150, 65, NULL, MAIN_CAM); + } + pthis->timer = 45; + pthis->actionFunc = BgPoEvent_BlockShake; + } else if (pthis->dyna.actor.xzDistToPlayer > 50.0f) { + if (pthis->type != 1) { + sPuzzleState |= (1 << pthis->index); + } else { + sPuzzleState |= 0x10; + } + } else if (pthis->type != 1) { + sPuzzleState &= ~(1 << pthis->index); + } else { + sPuzzleState &= ~0x10; + } +} + +void BgPoEvent_BlockShake(BgPoEvent* pthis, GlobalContext* globalCtx) { + DECR(pthis->timer); + if (pthis->timer < 15) { + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x + 2.0f * ((pthis->timer % 3) - 1); + if (!(pthis->timer % 4)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_SHAKE); + } + } + if (pthis->timer == 0) { + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x; + sPuzzleState = 0; + pthis->timer = 60; + pthis->actionFunc = BgPoEvent_BlockFall; + } +} + +void BgPoEvent_CheckBlock(BgPoEvent* pthis) { + s32 phi_v1; + s32 phi_a1; + s32 phi_t0; + s32 phi_a3; + + if ((pthis->index == 3) || (pthis->index == 1)) { + phi_v1 = pthis->dyna.actor.world.pos.z; + phi_a1 = pthis->dyna.actor.child->world.pos.z; + if (pthis->index == 3) { + phi_a3 = pthis->dyna.actor.world.pos.x; + phi_t0 = pthis->dyna.actor.child->world.pos.x; + } else { // pthis->index == 1 + phi_a3 = pthis->dyna.actor.child->world.pos.x; + phi_t0 = pthis->dyna.actor.world.pos.x; + } + } else { + phi_v1 = pthis->dyna.actor.world.pos.x; + phi_a1 = pthis->dyna.actor.child->world.pos.x; + if (pthis->index == 0) { + phi_a3 = pthis->dyna.actor.world.pos.z; + phi_t0 = pthis->dyna.actor.child->world.pos.z; + } else { // pthis->index == 2 + phi_a3 = pthis->dyna.actor.child->world.pos.z; + phi_t0 = pthis->dyna.actor.world.pos.z; + } + } + if ((phi_v1 == phi_a1) && ((phi_t0 - phi_a3) == 60)) { + sPuzzleState |= (1 << pthis->index); + } else { + sPuzzleState &= ~(1 << pthis->index); + } +} + +void BgPoEvent_BlockFall(BgPoEvent* pthis, GlobalContext* globalCtx) { + static s32 firstFall = 0; + + pthis->dyna.actor.velocity.y++; + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, 433.0f, pthis->dyna.actor.velocity.y)) { + pthis->dyna.actor.flags &= ~ACTOR_FLAG_5; + pthis->dyna.actor.velocity.y = 0.0f; + sBlocksAtRest++; + if (pthis->type != 1) { + BgPoEvent_CheckBlock(pthis); + } else { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); + func_80033E88(&pthis->dyna.actor, globalCtx, 5, 5); + func_80088B34(pthis->timer); + if (firstFall == 0) { + firstFall = 1; + } else { + func_8002DF54(globalCtx, &GET_PLAYER(globalCtx)->actor, 7); + } + } + pthis->direction = 0; + pthis->actionFunc = BgPoEvent_BlockIdle; + } +} + +void BgPoEvent_BlockIdle(BgPoEvent* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* amy; + + if (sPuzzleState == 0xF) { + pthis->actionFunc = BgPoEvent_BlockSolved; + if ((pthis->type == 0) && (pthis->index == 0)) { + amy = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, pthis->dyna.actor.world.pos.x + 30.0f, + pthis->dyna.actor.world.pos.y - 30.0f, pthis->dyna.actor.world.pos.z + 30.0f, 0, + pthis->dyna.actor.shape.rot.y, 0, pthis->dyna.actor.params + 0x300); + if (amy != NULL) { + OnePointCutscene_Init(globalCtx, 3170, 30, amy, MAIN_CAM); + } + func_80078884(NA_SE_SY_CORRECT_CHIME); + gSaveContext.timer1State = 0xA; + } + } else { + if ((gSaveContext.timer1Value == 0) && (sBlocksAtRest == 5)) { + player->stateFlags2 &= ~0x10; + sPuzzleState = 0x10; + sBlocksAtRest = 0; + } + if ((sPuzzleState == 0x40) || ((sPuzzleState == 0x10) && !Player_InCsMode(globalCtx))) { + pthis->dyna.actor.world.rot.z = pthis->dyna.actor.shape.rot.z; + pthis->actionFunc = BgPoEvent_BlockReset; + if (sPuzzleState == 0x10) { + sPuzzleState = 0x40; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_RISING); + func_8002DF54(globalCtx, &player->actor, 8); + } + } else if (pthis->dyna.unk_150 != 0.0f) { + if (pthis->direction == 0) { + if (func_800435D8(globalCtx, &pthis->dyna, 0x1E, 0x32, -0x14) != 0) { + sBlocksAtRest--; + pthis->direction = (pthis->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; + pthis->actionFunc = BgPoEvent_BlockPush; + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + DECR(pthis->direction); + } + } else { + pthis->direction = 0; + } + } +} + +void BgPoEvent_BlockPush(BgPoEvent* pthis, GlobalContext* globalCtx) { + static f32 blockPushDist = 0.0f; + f32 displacement; + s32 blockStop; + Player* player = GET_PLAYER(globalCtx); + + pthis->dyna.actor.speedXZ += 0.1f; + pthis->dyna.actor.speedXZ = CLAMP_MAX(pthis->dyna.actor.speedXZ, 2.0f); + blockStop = Math_StepToF(&blockPushDist, 20.0f, pthis->dyna.actor.speedXZ); + displacement = pthis->direction * blockPushDist; + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->dyna.unk_158) * displacement) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->dyna.unk_158) * displacement) + pthis->dyna.actor.home.pos.z; + if (blockStop) { + player->stateFlags2 &= ~0x10; + if ((pthis->dyna.unk_150 > 0.0f) && (func_800435D8(globalCtx, &pthis->dyna, 0x1E, 0x32, -0x14) == 0)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + pthis->dyna.unk_150 = 0.0f; + pthis->dyna.actor.home.pos.x = pthis->dyna.actor.world.pos.x; + pthis->dyna.actor.home.pos.z = pthis->dyna.actor.world.pos.z; + blockPushDist = 0.0f; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->direction = 5; + sBlocksAtRest++; + pthis->actionFunc = BgPoEvent_BlockIdle; + if (pthis->type == 1) { + return; + } + BgPoEvent_CheckBlock(pthis); + BgPoEvent_CheckBlock((BgPoEvent*)pthis->dyna.actor.parent); + } + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); +} + +void BgPoEvent_BlockReset(BgPoEvent* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->dyna.unk_150 != 0.0f) { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, 493.0f, 1.0f) && + Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.z, pthis->dyna.actor.world.rot.z - 0x4000, 0x400)) { + + pthis->index = (pthis->index + 1) % 4; + pthis->actionFunc = BgPoEvent_BlockFall; + sPuzzleState = 0; + if (pthis->type == 1) { + pthis->timer += 10; + pthis->timer = CLAMP_MAX(pthis->timer, 120); + } + } +} + +void BgPoEvent_BlockSolved(BgPoEvent* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->dyna.unk_150 != 0.0f) { + player->stateFlags2 &= ~0x10; + } + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, 369.0f, 2.0f)) { + sPuzzleState = 0x20; + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgPoEvent_AmyWait(BgPoEvent* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + sPuzzleState |= 0x20; + pthis->timer = 5; + Actor_SetColorFilter(&pthis->dyna.actor, 0x4000, 0xFF, 0, 5); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_PO_LAUGH2); + pthis->actionFunc = BgPoEvent_AmyPuzzle; + } +} + +void BgPoEvent_AmyPuzzle(BgPoEvent* pthis, GlobalContext* globalCtx) { + Vec3f pos; + + if (sPuzzleState == 0xF) { + pos.x = pthis->dyna.actor.world.pos.x - 5.0f; + pos.y = Rand_CenteredFloat(120.0f) + pthis->dyna.actor.world.pos.y; + pos.z = Rand_CenteredFloat(120.0f) + pthis->dyna.actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &pos, &sZeroVec, &sZeroVec, 170, 0, 200, 255, 100, 170, 0, 255, 0, 1, 9, true); + } else if (sPuzzleState == 0x20) { + Actor_Kill(&pthis->dyna.actor); + } else { + DECR(pthis->timer); + } +} + +s32 BgPoEvent_NextPainting(BgPoEvent* pthis) { + if ((pthis->dyna.actor.parent != NULL) && (pthis->dyna.actor.child != NULL)) { + if (Rand_ZeroOne() < 0.5f) { + sPuzzleState = ((BgPoEvent*)pthis->dyna.actor.parent)->index; + } else { + sPuzzleState = ((BgPoEvent*)pthis->dyna.actor.child)->index; + } + } else if (pthis->dyna.actor.parent != NULL) { + sPuzzleState = ((BgPoEvent*)pthis->dyna.actor.parent)->index; + } else if (pthis->dyna.actor.child != NULL) { + sPuzzleState = ((BgPoEvent*)pthis->dyna.actor.child)->index; + } else { + return false; + } + return true; +} + +void BgPoEvent_PaintingEmpty(BgPoEvent* pthis, GlobalContext* globalCtx) { + if (sPuzzleState == pthis->index) { + pthis->timer = 255; + pthis->actionFunc = BgPoEvent_PaintingAppear; + } +} + +void BgPoEvent_PaintingAppear(BgPoEvent* pthis, GlobalContext* globalCtx) { + pthis->timer -= 20; + if (pthis->timer <= 0) { + pthis->timer = 1000; + pthis->actionFunc = BgPoEvent_PaintingPresent; + } +} + +void BgPoEvent_PaintingVanish(BgPoEvent* pthis, GlobalContext* globalCtx) { + pthis->timer += 20; + if (pthis->timer >= 255) { + BgPoEvent_NextPainting(pthis); + pthis->actionFunc = BgPoEvent_PaintingEmpty; + } +} + +void BgPoEvent_PaintingPresent(BgPoEvent* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + Player* player = GET_PLAYER(globalCtx); + + DECR(pthis->timer); + + if (((pthis->timer == 0) || ((thisx->xzDistToPlayer < 150.0f) && (thisx->yDistToPlayer < 50.0f)) || + (func_8002DD78(player) && (thisx->xzDistToPlayer < 320.0f) && + ((pthis->index != 2) ? (thisx->yDistToPlayer < 100.0f) : (thisx->yDistToPlayer < 0.0f)) && + Player_IsFacingActor(thisx, 0x2000, globalCtx))) && + ((thisx->parent != NULL) || (thisx->child != NULL))) { + /*The third condition in the || is checking if + 1) Link is holding a ranged weapon + 2) Link is too close in the xz plane + 3) Link is too close in the y direction. The painting + under the balcony allows him to be closer. + 4) Link is within 45 degrees of facing the painting. */ + pthis->timer = 0; + Audio_PlayActorSound2(thisx, NA_SE_EN_PO_LAUGH); + pthis->actionFunc = BgPoEvent_PaintingVanish; + } else if (pthis->collider.base.acFlags & AC_HIT) { + if (!BgPoEvent_NextPainting(pthis)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, thisx->world.pos.x, + thisx->world.pos.y - 40.0f, thisx->world.pos.z, 0, thisx->shape.rot.y, 0, + thisx->params + ((pthis->type - 1) << 8)); + OnePointCutscene_Init(globalCtx, 3160, 80, thisx, MAIN_CAM); + func_80078884(NA_SE_SY_CORRECT_CHIME); + + } else { + Audio_PlayActorSound2(thisx, NA_SE_EN_PO_LAUGH2); + OnePointCutscene_Init(globalCtx, 3160, 35, thisx, MAIN_CAM); + } + if (thisx->parent != NULL) { + thisx->parent->child = NULL; + thisx->parent = NULL; + } + if (thisx->child != NULL) { + thisx->child->parent = NULL; + thisx->child = NULL; + } + pthis->timer = 20; + pthis->actionFunc = BgPoEvent_PaintingBurn; + } +} + +void BgPoEvent_PaintingBurn(BgPoEvent* pthis, GlobalContext* globalCtx) { + Vec3f sp54; + + pthis->timer--; + sp54.x = (Math_SinS(pthis->dyna.actor.shape.rot.y) * 5.0f) + pthis->dyna.actor.world.pos.x; + sp54.y = Rand_CenteredFloat(66.0f) + pthis->dyna.actor.world.pos.y; + sp54.z = Rand_CenteredFloat(50.0f) + pthis->dyna.actor.world.pos.z; + if (pthis->timer >= 0) { + if (pthis->type == 2) { + EffectSsDeadDb_Spawn(globalCtx, &sp54, &sZeroVec, &sZeroVec, 100, 0, 255, 255, 150, 170, 255, 0, 0, 1, 9, + true); + } else { + EffectSsDeadDb_Spawn(globalCtx, &sp54, &sZeroVec, &sZeroVec, 100, 0, 200, 255, 255, 170, 50, 100, 255, 1, 9, + true); + } + } + if (pthis->timer == 0) { + pthis->dyna.actor.draw = NULL; + } + if (pthis->timer < -60) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgPoEvent_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgPoEvent* pthis = (BgPoEvent*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if ((pthis->actionFunc == BgPoEvent_AmyWait) || (pthis->actionFunc == BgPoEvent_PaintingPresent)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void BgPoEvent_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* displayLists[] = { + gPoSistersAmyBlockDL, gPoSistersAmyBethBlockDL, gPoSistersJoellePaintingDL, + gPoSistersBethPaintingDL, gPoSistersAmyPaintingDL, + }; + s32 pad; + BgPoEvent* pthis = (BgPoEvent*)thisx; + u8 alpha; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + s32 pad2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_po_event.c", 1481); + func_80093D18(globalCtx->state.gfxCtx); + if ((pthis->type == 3) || (pthis->type == 2)) { + if (pthis->actionFunc == BgPoEvent_PaintingEmpty) { + alpha = 255; + } else if (pthis->actionFunc == BgPoEvent_PaintingPresent) { + alpha = 0; + } else { + alpha = pthis->timer; + } + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, alpha); + } + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_po_event.c", 1501), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, displayLists[pthis->type]); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_po_event.c", 1508); + + if ((pthis->type == 0) || (pthis->type == 1)) { + sp48 = (833.0f - pthis->dyna.actor.world.pos.y) * 0.0025f; + if (!(sp48 > 1.0f)) { + sp58.x = pthis->dyna.actor.world.pos.x; + sp58.y = pthis->dyna.actor.world.pos.y - 30.0f; + sp58.z = pthis->dyna.actor.world.pos.z; + sp4C.y = 1.0f; + sp4C.x = sp4C.z = (sp48 * 0.3f) + 0.4f; + func_80033C30(&sp58, &sp4C, (u8)(155.0f + sp48 * 100.0f), globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.cpp similarity index 72% rename from src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c rename to src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.cpp index 843c66d34..c65a64d01 100644 --- a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c +++ b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.cpp @@ -68,7 +68,7 @@ static Color_RGBA8 sEnvColors[] = { { 0, 150, 0, 255 }, }; -const ActorInit Bg_Po_Syokudai_InitVars = { +ActorInit Bg_Po_Syokudai_InitVars = { ACTOR_BG_PO_SYOKUDAI, ACTORCAT_PROP, FLAGS, @@ -85,28 +85,28 @@ static InitChainEntry sInitChain[] = { }; void BgPoSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { - BgPoSyokudai* this = (BgPoSyokudai*)thisx; + BgPoSyokudai* pthis = (BgPoSyokudai*)thisx; s32 pad; Actor_ProcessInitChain(thisx, sInitChain); - this->flameColor = (thisx->params >> 8) & 0xFF; + pthis->flameColor = (thisx->params >> 8) & 0xFF; thisx->params &= 0x3F; thisx->colChkInfo.mass = MASS_IMMOVABLE; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, thisx->world.pos.x, (s16)thisx->world.pos.y + 65, thisx->world.pos.z, 0, + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointGlowSetInfo(&pthis->lightInfo, thisx->world.pos.x, (s16)thisx->world.pos.y + 65, thisx->world.pos.z, 0, 0, 0, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); - this->collider.dim.pos.x = thisx->world.pos.x; - this->collider.dim.pos.y = thisx->world.pos.y; - this->collider.dim.pos.z = thisx->world.pos.z; + pthis->collider.dim.pos.x = thisx->world.pos.x; + pthis->collider.dim.pos.y = thisx->world.pos.y; + pthis->collider.dim.pos.z = thisx->world.pos.z; - if (this->flameColor == POE_FLAME_PURPLE && Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_GREEN) && + if (pthis->flameColor == POE_FLAME_PURPLE && Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_GREEN) && Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_BLUE) && Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_RED) && !Flags_GetSwitch(globalCtx, thisx->params)) { @@ -118,7 +118,7 @@ void BgPoSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, thisx->world.pos.x, thisx->world.pos.y + 52.0f, thisx->world.pos.z, 0, 0, 0, - (this->flameColor << 8) + thisx->params + 0x1000); + (pthis->flameColor << 8) + thisx->params + 0x1000); } else if (!Flags_GetSwitch(globalCtx, thisx->params)) { if (globalCtx->envCtx.unk_BF == 0xFF) { @@ -126,14 +126,14 @@ void BgPoSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->flameTextureScroll = (s16)(Rand_ZeroOne() * 20.0f); + pthis->flameTextureScroll = (s16)(Rand_ZeroOne() * 20.0f); } void BgPoSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgPoSyokudai* this = (BgPoSyokudai*)thisx; + BgPoSyokudai* pthis = (BgPoSyokudai*)thisx; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyCylinder(globalCtx, &this->collider); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + Collider_DestroyCylinder(globalCtx, &pthis->collider); if (globalCtx->envCtx.unk_BF != 0xFF) { globalCtx->envCtx.unk_BF = 0xFF; @@ -141,19 +141,19 @@ void BgPoSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void BgPoSyokudai_Update(Actor* thisx, GlobalContext* globalCtx) { - BgPoSyokudai* this = (BgPoSyokudai*)thisx; + BgPoSyokudai* pthis = (BgPoSyokudai*)thisx; s32 pad; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - func_8002F974(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + func_8002F974(&pthis->actor, NA_SE_EV_TORCH - SFX_FLAG); } - this->flameTextureScroll++; + pthis->flameTextureScroll++; } void BgPoSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgPoSyokudai* this = (BgPoSyokudai*)thisx; + BgPoSyokudai* pthis = (BgPoSyokudai*)thisx; f32 lightBrightness; u8 red; u8 green; @@ -166,9 +166,9 @@ void BgPoSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gGoldenTorchDL); - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - Color_RGBA8* primColor = &sPrimColors[this->flameColor]; - Color_RGBA8* envColor = &sEnvColors[this->flameColor]; + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + Color_RGBA8* primColor = &sPrimColors[pthis->flameColor]; + Color_RGBA8* envColor = &sEnvColors[pthis->flameColor]; lightBrightness = (0.3f * Rand_ZeroOne()) + 0.7f; @@ -176,18 +176,18 @@ void BgPoSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { green = (u8)(primColor->g * lightBrightness); blue = (u8)(primColor->b * lightBrightness); - Lights_PointSetColorAndRadius(&this->lightInfo, red, green, blue, 200); + Lights_PointSetColorAndRadius(&pthis->lightInfo, red, green, blue, 200); func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - (this->flameTextureScroll * -20) & 0x1FF, 32, 128)); + (pthis->flameTextureScroll * -20) & 0x1FF, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, primColor->r, primColor->g, primColor->b, 255); gDPSetEnvColor(POLY_XLU_DISP++, envColor->r, envColor->g, envColor->b, 255); Matrix_Translate(0.0f, 52.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y + 0x8000) * + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Scale(0.0027f, 0.0027f, 0.0027f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c b/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.cpp similarity index 56% rename from src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c rename to src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.cpp index b217b2325..6e01256fa 100644 --- a/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c +++ b/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.cpp @@ -22,13 +22,13 @@ void BgPushbox_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgPushbox_Update(Actor* thisx, GlobalContext* globalCtx); void BgPushbox_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgPushbox_UpdateImpl(BgPushbox* this, GlobalContext* globalCtx); +void BgPushbox_UpdateImpl(BgPushbox* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Pushbox_InitVars = { +ActorInit Bg_Pushbox_InitVars = { ACTOR_BG_PUSHBOX, ACTORCAT_BG, FLAGS, - //! @bug fixing this actor would involve using OBJECT_PU_BOX + //! @bug fixing pthis actor would involve using OBJECT_PU_BOX OBJECT_GAMEPLAY_DANGEON_KEEP, sizeof(BgPushbox), (ActorFunc)BgPushbox_Init, @@ -41,46 +41,46 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -void BgPushbox_SetupAction(BgPushbox* this, BgPushboxActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgPushbox_SetupAction(BgPushbox* pthis, BgPushboxActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgPushbox_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgPushbox* this = (BgPushbox*)thisx; + BgPushbox* pthis = (BgPushbox*)thisx; CollisionHeader* colHeader = NULL; s32 pad2; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gBlockSmallCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); - BgPushbox_SetupAction(this, BgPushbox_UpdateImpl); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, NULL, 0.0f); + BgPushbox_SetupAction(pthis, BgPushbox_UpdateImpl); } void BgPushbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgPushbox* this = (BgPushbox*)thisx; + BgPushbox* pthis = (BgPushbox*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void BgPushbox_UpdateImpl(BgPushbox* this, GlobalContext* globalCtx) { - this->dyna.actor.speedXZ += this->dyna.unk_150 * 0.2f; - this->dyna.actor.speedXZ = (this->dyna.actor.speedXZ < -1.0f) +void BgPushbox_UpdateImpl(BgPushbox* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.speedXZ += pthis->dyna.unk_150 * 0.2f; + pthis->dyna.actor.speedXZ = (pthis->dyna.actor.speedXZ < -1.0f) ? -1.0f - : ((this->dyna.actor.speedXZ > 1.0f) ? 1.0f : this->dyna.actor.speedXZ); - Math_StepToF(&this->dyna.actor.speedXZ, 0.0f, 0.2f); - this->dyna.actor.world.rot.y = this->dyna.unk_158; - Actor_MoveForward(&this->dyna.actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 40.0f, 40.0f, 0x1D); + : ((pthis->dyna.actor.speedXZ > 1.0f) ? 1.0f : pthis->dyna.actor.speedXZ); + Math_StepToF(&pthis->dyna.actor.speedXZ, 0.0f, 0.2f); + pthis->dyna.actor.world.rot.y = pthis->dyna.unk_158; + Actor_MoveForward(&pthis->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 20.0f, 40.0f, 40.0f, 0x1D); } void BgPushbox_Update(Actor* thisx, GlobalContext* globalCtx) { - BgPushbox* this = (BgPushbox*)thisx; + BgPushbox* pthis = (BgPushbox*)thisx; - this->actionFunc(this, globalCtx); - func_8002DF90(&this->dyna); + pthis->actionFunc(pthis, globalCtx); + func_8002DF90(&pthis->dyna); } void BgPushbox_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c b/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c deleted file mode 100644 index 5c3fb567e..000000000 --- a/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c +++ /dev/null @@ -1,222 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_RELAY_OBJECTS_Z_BG_RELAY_OBJECTS_C -#include "actor_common.h" -/* - * File: z_bg_relay_objects.c - * Overlay: ovl_Bg_Relay_Objects - * Description: Windmill Setpieces - */ - -#include "z_bg_relay_objects.h" -#include "objects/object_relay_objects/object_relay_objects.h" -#include "def/code_80043480.h" -#include "def/code_8006C3A0.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef enum { - /* 0 */ WINDMILL_ROTATING_GEAR, - /* 1 */ WINDMILL_DAMPE_STONE_DOOR -} WindmillSetpiecesMode; - -void BgRelayObjects_Init(Actor* thisx, GlobalContext* globalCtx); -void BgRelayObjects_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgRelayObjects_Update(Actor* thisx, GlobalContext* globalCtx); -void BgRelayObjects_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808A90F4(BgRelayObjects* this, GlobalContext* globalCtx); -void func_808A91AC(BgRelayObjects* this, GlobalContext* globalCtx); -void func_808A9234(BgRelayObjects* this, GlobalContext* globalCtx); -void BgRelayObjects_DoNothing(BgRelayObjects* this, GlobalContext* globalCtx); -void func_808A932C(BgRelayObjects* this, GlobalContext* globalCtx); -void func_808A939C(BgRelayObjects* this, GlobalContext* globalCtx); - -const ActorInit Bg_Relay_Objects_InitVars = { - ACTOR_BG_RELAY_OBJECTS, - ACTORCAT_BG, - FLAGS, - OBJECT_RELAY_OBJECTS, - sizeof(BgRelayObjects), - (ActorFunc)BgRelayObjects_Init, - (ActorFunc)BgRelayObjects_Destroy, - (ActorFunc)BgRelayObjects_Update, - (ActorFunc)BgRelayObjects_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(gravity, 5, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgRelayObjects_Init(Actor* thisx, GlobalContext* globalCtx) { - static u32 D_808A9508 = 0; - BgRelayObjects* this = (BgRelayObjects*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(thisx, sInitChain); - this->switchFlag = thisx->params & 0x3F; - thisx->params = (thisx->params >> 8) & 0xFF; - DynaPolyActor_Init(&this->dyna, 3); - if (thisx->params == WINDMILL_ROTATING_GEAR) { - CollisionHeader_GetVirtual(&gWindmillRotatingPlatformCol, &colHeader); - if (gSaveContext.eventChkInf[6] & 0x20) { - thisx->world.rot.y = 0x400; - } else { - thisx->world.rot.y = 0x80; - } - func_800F5718(); - thisx->room = -1; - thisx->flags |= ACTOR_FLAG_5; - if (D_808A9508 & 2) { - thisx->params = 0xFF; - Actor_Kill(thisx); - } else { - D_808A9508 |= 2; - this->actionFunc = func_808A939C; - } - } else { - CollisionHeader_GetVirtual(&gDampeRaceDoorCol, &colHeader); - if (thisx->room == 0) { - this->unk_169 = this->switchFlag - 0x33; - } else { - this->unk_169 = thisx->room + 1; - } - thisx->room = -1; - this->timer = 1; - if (this->unk_169 >= 6) { - if (D_808A9508 & 1) { - Actor_Kill(thisx); - } else { - D_808A9508 |= 1; - this->actionFunc = BgRelayObjects_DoNothing; - } - } else if (this->unk_169 != 5) { - Flags_UnsetSwitch(globalCtx, this->switchFlag); - if (D_808A9508 & (1 << this->unk_169)) { - Actor_Kill(thisx); - } else { - D_808A9508 |= (1 << this->unk_169); - this->actionFunc = func_808A90F4; - } - } else { - Flags_SetSwitch(globalCtx, this->switchFlag); - this->actionFunc = func_808A91AC; - thisx->world.pos.y += 120.0f; - D_808A9508 |= 1; - } - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); -} - -void BgRelayObjects_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgRelayObjects* this = (BgRelayObjects*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if ((this->dyna.actor.params == WINDMILL_ROTATING_GEAR) && (gSaveContext.cutsceneIndex < 0xFFF0)) { - gSaveContext.eventChkInf[6] &= ~0x20; - } -} - -void func_808A90F4(BgRelayObjects* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - if (this->timer != 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); - if (INV_CONTENT(ITEM_HOOKSHOT) != ITEM_NONE) { - this->timer = 120; - } else { - this->timer = 160; - } - } - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, 12.0f)) { - this->actionFunc = func_808A91AC; - } - } -} - -void func_808A91AC(BgRelayObjects* this, GlobalContext* globalCtx) { - if (this->unk_169 != 5) { - if (this->timer != 0) { - this->timer--; - } - func_8002F994(&this->dyna.actor, this->timer); - } - if ((this->timer == 0) || (this->unk_169 == globalCtx->roomCtx.curRoom.num)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); - this->actionFunc = func_808A9234; - } -} - -void func_808A9234(BgRelayObjects* this, GlobalContext* globalCtx) { - this->dyna.actor.velocity.y += this->dyna.actor.gravity; - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); - if (this->unk_169 != globalCtx->roomCtx.curRoom.num) { - func_800788CC(NA_SE_EN_PO_LAUGH); - this->timer = 5; - this->actionFunc = func_808A932C; - return; - } - Flags_UnsetSwitch(globalCtx, this->switchFlag); - this->dyna.actor.flags &= ~ACTOR_FLAG_4; - if (globalCtx->roomCtx.curRoom.num == 4) { - gSaveContext.timer1State = 0xF; - } - this->actionFunc = BgRelayObjects_DoNothing; - } -} - -void BgRelayObjects_DoNothing(BgRelayObjects* this, GlobalContext* globalCtx) { -} - -void func_808A932C(BgRelayObjects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - if (!Player_InCsMode(globalCtx)) { - func_80078884(NA_SE_OC_ABYSS); - Gameplay_TriggerRespawn(globalCtx); - this->actionFunc = BgRelayObjects_DoNothing; - } - } -} - -void func_808A939C(BgRelayObjects* this, GlobalContext* globalCtx) { - if (Flags_GetEnv(globalCtx, 5)) { - gSaveContext.eventChkInf[6] |= 0x20; - } - if (gSaveContext.eventChkInf[6] & 0x20) { - Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0x400, 8); - } else { - Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0x80, 8); - } - this->dyna.actor.shape.rot.y += this->dyna.actor.world.rot.y; - func_800F436C(&this->dyna.actor.projectedPos, NA_SE_EV_WOOD_GEAR - SFX_FLAG, - ((this->dyna.actor.world.rot.y - 0x80) * (1.0f / 0x380)) + 1.0f); -} - -void BgRelayObjects_Update(Actor* thisx, GlobalContext* globalCtx) { - BgRelayObjects* this = (BgRelayObjects*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgRelayObjects_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgRelayObjects* this = (BgRelayObjects*)thisx; - - if (this->dyna.actor.params == WINDMILL_ROTATING_GEAR) { - Gfx_DrawDListOpa(globalCtx, gWindmillRotatingPlatformDL); - } else { - Gfx_DrawDListOpa(globalCtx, gDampeRaceDoorDL); - } -} diff --git a/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.cpp b/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.cpp new file mode 100644 index 000000000..1d7562712 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.cpp @@ -0,0 +1,222 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_RELAY_OBJECTS_Z_BG_RELAY_OBJECTS_C +#include "actor_common.h" +/* + * File: z_bg_relay_objects.c + * Overlay: ovl_Bg_Relay_Objects + * Description: Windmill Setpieces + */ + +#include "z_bg_relay_objects.h" +#include "objects/object_relay_objects/object_relay_objects.h" +#include "def/code_80043480.h" +#include "def/code_8006C3A0.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef enum { + /* 0 */ WINDMILL_ROTATING_GEAR, + /* 1 */ WINDMILL_DAMPE_STONE_DOOR +} WindmillSetpiecesMode; + +void BgRelayObjects_Init(Actor* thisx, GlobalContext* globalCtx); +void BgRelayObjects_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgRelayObjects_Update(Actor* thisx, GlobalContext* globalCtx); +void BgRelayObjects_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808A90F4(BgRelayObjects* pthis, GlobalContext* globalCtx); +void func_808A91AC(BgRelayObjects* pthis, GlobalContext* globalCtx); +void func_808A9234(BgRelayObjects* pthis, GlobalContext* globalCtx); +void BgRelayObjects_DoNothing(BgRelayObjects* pthis, GlobalContext* globalCtx); +void func_808A932C(BgRelayObjects* pthis, GlobalContext* globalCtx); +void func_808A939C(BgRelayObjects* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Relay_Objects_InitVars = { + ACTOR_BG_RELAY_OBJECTS, + ACTORCAT_BG, + FLAGS, + OBJECT_RELAY_OBJECTS, + sizeof(BgRelayObjects), + (ActorFunc)BgRelayObjects_Init, + (ActorFunc)BgRelayObjects_Destroy, + (ActorFunc)BgRelayObjects_Update, + (ActorFunc)BgRelayObjects_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(gravity, 5, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgRelayObjects_Init(Actor* thisx, GlobalContext* globalCtx) { + static u32 D_808A9508 = 0; + BgRelayObjects* pthis = (BgRelayObjects*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(thisx, sInitChain); + pthis->switchFlag = thisx->params & 0x3F; + thisx->params = (thisx->params >> 8) & 0xFF; + DynaPolyActor_Init(&pthis->dyna, 3); + if (thisx->params == WINDMILL_ROTATING_GEAR) { + CollisionHeader_GetVirtual(&gWindmillRotatingPlatformCol, &colHeader); + if (gSaveContext.eventChkInf[6] & 0x20) { + thisx->world.rot.y = 0x400; + } else { + thisx->world.rot.y = 0x80; + } + func_800F5718(); + thisx->room = -1; + thisx->flags |= ACTOR_FLAG_5; + if (D_808A9508 & 2) { + thisx->params = 0xFF; + Actor_Kill(thisx); + } else { + D_808A9508 |= 2; + pthis->actionFunc = func_808A939C; + } + } else { + CollisionHeader_GetVirtual(&gDampeRaceDoorCol, &colHeader); + if (thisx->room == 0) { + pthis->unk_169 = pthis->switchFlag - 0x33; + } else { + pthis->unk_169 = thisx->room + 1; + } + thisx->room = -1; + pthis->timer = 1; + if (pthis->unk_169 >= 6) { + if (D_808A9508 & 1) { + Actor_Kill(thisx); + } else { + D_808A9508 |= 1; + pthis->actionFunc = BgRelayObjects_DoNothing; + } + } else if (pthis->unk_169 != 5) { + Flags_UnsetSwitch(globalCtx, pthis->switchFlag); + if (D_808A9508 & (1 << pthis->unk_169)) { + Actor_Kill(thisx); + } else { + D_808A9508 |= (1 << pthis->unk_169); + pthis->actionFunc = func_808A90F4; + } + } else { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + pthis->actionFunc = func_808A91AC; + thisx->world.pos.y += 120.0f; + D_808A9508 |= 1; + } + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); +} + +void BgRelayObjects_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgRelayObjects* pthis = (BgRelayObjects*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if ((pthis->dyna.actor.params == WINDMILL_ROTATING_GEAR) && (gSaveContext.cutsceneIndex < 0xFFF0)) { + gSaveContext.eventChkInf[6] &= ~0x20; + } +} + +void func_808A90F4(BgRelayObjects* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if (pthis->timer != 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + if (INV_CONTENT(ITEM_HOOKSHOT) != ITEM_NONE) { + pthis->timer = 120; + } else { + pthis->timer = 160; + } + } + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 120.0f, 12.0f)) { + pthis->actionFunc = func_808A91AC; + } + } +} + +void func_808A91AC(BgRelayObjects* pthis, GlobalContext* globalCtx) { + if (pthis->unk_169 != 5) { + if (pthis->timer != 0) { + pthis->timer--; + } + func_8002F994(&pthis->dyna.actor, pthis->timer); + } + if ((pthis->timer == 0) || (pthis->unk_169 == globalCtx->roomCtx.curRoom.num)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + pthis->actionFunc = func_808A9234; + } +} + +void func_808A9234(BgRelayObjects* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.velocity.y += pthis->dyna.actor.gravity; + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.velocity.y)) { + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); + if (pthis->unk_169 != globalCtx->roomCtx.curRoom.num) { + func_800788CC(NA_SE_EN_PO_LAUGH); + pthis->timer = 5; + pthis->actionFunc = func_808A932C; + return; + } + Flags_UnsetSwitch(globalCtx, pthis->switchFlag); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; + if (globalCtx->roomCtx.curRoom.num == 4) { + gSaveContext.timer1State = 0xF; + } + pthis->actionFunc = BgRelayObjects_DoNothing; + } +} + +void BgRelayObjects_DoNothing(BgRelayObjects* pthis, GlobalContext* globalCtx) { +} + +void func_808A932C(BgRelayObjects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + if (!Player_InCsMode(globalCtx)) { + func_80078884(NA_SE_OC_ABYSS); + Gameplay_TriggerRespawn(globalCtx); + pthis->actionFunc = BgRelayObjects_DoNothing; + } + } +} + +void func_808A939C(BgRelayObjects* pthis, GlobalContext* globalCtx) { + if (Flags_GetEnv(globalCtx, 5)) { + gSaveContext.eventChkInf[6] |= 0x20; + } + if (gSaveContext.eventChkInf[6] & 0x20) { + Math_ScaledStepToS(&pthis->dyna.actor.world.rot.y, 0x400, 8); + } else { + Math_ScaledStepToS(&pthis->dyna.actor.world.rot.y, 0x80, 8); + } + pthis->dyna.actor.shape.rot.y += pthis->dyna.actor.world.rot.y; + func_800F436C(&pthis->dyna.actor.projectedPos, NA_SE_EV_WOOD_GEAR - SFX_FLAG, + ((pthis->dyna.actor.world.rot.y - 0x80) * (1.0f / 0x380)) + 1.0f); +} + +void BgRelayObjects_Update(Actor* thisx, GlobalContext* globalCtx) { + BgRelayObjects* pthis = (BgRelayObjects*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgRelayObjects_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgRelayObjects* pthis = (BgRelayObjects*)thisx; + + if (pthis->dyna.actor.params == WINDMILL_ROTATING_GEAR) { + Gfx_DrawDListOpa(globalCtx, gWindmillRotatingPlatformDL); + } else { + Gfx_DrawDListOpa(globalCtx, gDampeRaceDoorDL); + } +} diff --git a/src/overlays/actors/ovl_Bg_Spot00_Break/z_bg_spot00_break.c b/src/overlays/actors/ovl_Bg_Spot00_Break/z_bg_spot00_break.cpp similarity index 75% rename from src/overlays/actors/ovl_Bg_Spot00_Break/z_bg_spot00_break.c rename to src/overlays/actors/ovl_Bg_Spot00_Break/z_bg_spot00_break.cpp index d5b08293f..d9c36c571 100644 --- a/src/overlays/actors/ovl_Bg_Spot00_Break/z_bg_spot00_break.c +++ b/src/overlays/actors/ovl_Bg_Spot00_Break/z_bg_spot00_break.cpp @@ -21,7 +21,7 @@ void BgSpot00Break_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot00Break_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot00Break_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot00_Break_InitVars = { +ActorInit Bg_Spot00_Break_InitVars = { ACTOR_BG_SPOT00_BREAK, ACTORCAT_PROP, FLAGS, @@ -41,39 +41,39 @@ static InitChainEntry sInitChain[] = { }; void BgSpot00Break_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot00Break* this = (BgSpot00Break*)thisx; + BgSpot00Break* pthis = (BgSpot00Break*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); - if (this->dyna.actor.params == 1) { + if (pthis->dyna.actor.params == 1) { CollisionHeader_GetVirtual(&gBarbedWireFenceCol, &colHeader); } else { CollisionHeader_GetVirtual(&gBrokenDrawbridgeCol, &colHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); if (!LINK_IS_ADULT) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } void BgSpot00Break_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot00Break* this = (BgSpot00Break*)thisx; + BgSpot00Break* pthis = (BgSpot00Break*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgSpot00Break_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgSpot00Break_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot00Break* this = (BgSpot00Break*)thisx; + BgSpot00Break* pthis = (BgSpot00Break*)thisx; - if (this->dyna.actor.params == 1) { + if (pthis->dyna.actor.params == 1) { Gfx_DrawDListOpa(globalCtx, gBarbedWireFenceDL); } else { Gfx_DrawDListOpa(globalCtx, gBrokenDrawbridgeDL); diff --git a/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c b/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.cpp similarity index 62% rename from src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c rename to src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.cpp index 48471a491..34a54b279 100644 --- a/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c +++ b/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.cpp @@ -37,11 +37,11 @@ void BgSpot00Hanebasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot00Hanebasi_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot00Hanebasi_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* this, GlobalContext* globalCtx); -void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* this, GlobalContext* globalCtx); -void BgSpot00Hanebasi_SetTorchLightInfo(BgSpot00Hanebasi* this, GlobalContext* globalCtx); +void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx); +void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx); +void BgSpot00Hanebasi_SetTorchLightInfo(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot00_Hanebasi_InitVars = { +ActorInit Bg_Spot00_Hanebasi_InitVars = { ACTOR_BG_SPOT00_HANEBASI, ACTORCAT_BG, FLAGS, @@ -63,169 +63,169 @@ static InitChainEntry sInitChain[] = { }; void BgSpot00Hanebasi_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot00Hanebasi* this = (BgSpot00Hanebasi*)thisx; + BgSpot00Hanebasi* pthis = (BgSpot00Hanebasi*)thisx; s32 pad; Vec3f chainPos; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, 1); - if (this->dyna.actor.params == DT_DRAWBRIDGE) { + if (pthis->dyna.actor.params == DT_DRAWBRIDGE) { CollisionHeader_GetVirtual(&gHyruleFieldCastleDrawbridgeCol, &colHeader); } else { CollisionHeader_GetVirtual(&gHyruleFieldCastleDrawbridgeChainsCol, &colHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - if (this->dyna.actor.params == DT_DRAWBRIDGE) { + if (pthis->dyna.actor.params == DT_DRAWBRIDGE) { if (LINK_IS_ADULT && (gSaveContext.sceneSetupIndex < 4)) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } if ((gSaveContext.sceneSetupIndex != 6) && ((gSaveContext.sceneSetupIndex == 4) || (gSaveContext.sceneSetupIndex == 5) || (!LINK_IS_ADULT && !IS_DAY))) { - this->dyna.actor.shape.rot.x = -0x4000; + pthis->dyna.actor.shape.rot.x = -0x4000; } else { - this->dyna.actor.shape.rot.x = 0; + pthis->dyna.actor.shape.rot.x = 0; } if (gSaveContext.sceneSetupIndex != 6) { if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY) && CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE) && !(gSaveContext.eventChkInf[8] & 1)) { - this->dyna.actor.shape.rot.x = -0x4000; + pthis->dyna.actor.shape.rot.x = -0x4000; } } chainPos.y = - (10.0f * Math_CosS(this->dyna.actor.shape.rot.x)) - (Math_SinS(this->dyna.actor.shape.rot.x) * 400.0f); + (10.0f * Math_CosS(pthis->dyna.actor.shape.rot.x)) - (Math_SinS(pthis->dyna.actor.shape.rot.x) * 400.0f); chainPos.z = - (10.0f * Math_SinS(this->dyna.actor.shape.rot.x)) - (Math_CosS(this->dyna.actor.shape.rot.x) * 400.0f); + (10.0f * Math_SinS(pthis->dyna.actor.shape.rot.x)) - (Math_CosS(pthis->dyna.actor.shape.rot.x) * 400.0f); chainPos.x = - (158.0f * Math_CosS(this->dyna.actor.shape.rot.y)) + (Math_SinS(this->dyna.actor.shape.rot.y) * chainPos.z); - chainPos.z = (-158.0f * Math_SinS(this->dyna.actor.shape.rot.y)) + - (Math_CosS(this->dyna.actor.shape.rot.y) * chainPos.z); + (158.0f * Math_CosS(pthis->dyna.actor.shape.rot.y)) + (Math_SinS(pthis->dyna.actor.shape.rot.y) * chainPos.z); + chainPos.z = (-158.0f * Math_SinS(pthis->dyna.actor.shape.rot.y)) + + (Math_CosS(pthis->dyna.actor.shape.rot.y) * chainPos.z); - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_SPOT00_HANEBASI, - this->dyna.actor.world.pos.x + chainPos.x, this->dyna.actor.world.pos.y + chainPos.y, - this->dyna.actor.world.pos.z + chainPos.z, - ((this->dyna.actor.shape.rot.x == 0) ? 0 : 0xF020), this->dyna.actor.shape.rot.y, 0, + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_SPOT00_HANEBASI, + pthis->dyna.actor.world.pos.x + chainPos.x, pthis->dyna.actor.world.pos.y + chainPos.y, + pthis->dyna.actor.world.pos.z + chainPos.z, + ((pthis->dyna.actor.shape.rot.x == 0) ? 0 : 0xF020), pthis->dyna.actor.shape.rot.y, 0, DT_CHAIN_1) == NULL) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } - this->actionFunc = BgSpot00Hanebasi_DrawbridgeWait; - this->destAngle = 40; - } else if (this->dyna.actor.params == DT_CHAIN_1) { - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_SPOT00_HANEBASI, - this->dyna.actor.world.pos.x - (Math_CosS(this->dyna.actor.shape.rot.y) * 316.0f), - this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z + (Math_SinS(this->dyna.actor.shape.rot.y) * 316.0f), - this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, 0, DT_CHAIN_2) == NULL) { - Actor_Kill(&this->dyna.actor); - Actor_Kill(this->dyna.actor.parent); + pthis->actionFunc = BgSpot00Hanebasi_DrawbridgeWait; + pthis->destAngle = 40; + } else if (pthis->dyna.actor.params == DT_CHAIN_1) { + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_SPOT00_HANEBASI, + pthis->dyna.actor.world.pos.x - (Math_CosS(pthis->dyna.actor.shape.rot.y) * 316.0f), + pthis->dyna.actor.world.pos.y, + pthis->dyna.actor.world.pos.z + (Math_SinS(pthis->dyna.actor.shape.rot.y) * 316.0f), + pthis->dyna.actor.shape.rot.x, pthis->dyna.actor.shape.rot.y, 0, DT_CHAIN_2) == NULL) { + Actor_Kill(&pthis->dyna.actor); + Actor_Kill(pthis->dyna.actor.parent); } - this->actionFunc = BgSpot00Hanebasi_SetTorchLightInfo; + pthis->actionFunc = BgSpot00Hanebasi_SetTorchLightInfo; } else { - this->actionFunc = BgSpot00Hanebasi_SetTorchLightInfo; + pthis->actionFunc = BgSpot00Hanebasi_SetTorchLightInfo; } - if (this->dyna.actor.params >= DT_CHAIN_1) { - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, ((this->dyna.actor.params == DT_CHAIN_1) ? 260.0f : -260.0f), 168, + if (pthis->dyna.actor.params >= DT_CHAIN_1) { + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointGlowSetInfo(&pthis->lightInfo, ((pthis->dyna.actor.params == DT_CHAIN_1) ? 260.0f : -260.0f), 168, 690, 255, 255, 0, 0); } } void BgSpot00Hanebasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot00Hanebasi* this = (BgSpot00Hanebasi*)thisx; + BgSpot00Hanebasi* pthis = (BgSpot00Hanebasi*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); - if (this->dyna.actor.params >= DT_CHAIN_1) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + if (pthis->dyna.actor.params >= DT_CHAIN_1) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); } } -void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* this, GlobalContext* globalCtx) { - BgSpot00Hanebasi* child = (BgSpot00Hanebasi*)this->dyna.actor.child; +void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx) { + BgSpot00Hanebasi* child = (BgSpot00Hanebasi*)pthis->dyna.actor.child; if ((gSaveContext.sceneSetupIndex >= 4) || !CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) || !CHECK_QUEST_ITEM(QUEST_GORON_RUBY) || !CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE) || (gSaveContext.eventChkInf[8] & 1)) { - if (this->dyna.actor.shape.rot.x != 0) { + if (pthis->dyna.actor.shape.rot.x != 0) { if (Flags_GetEnv(globalCtx, 0) || ((gSaveContext.sceneSetupIndex < 4) && (gSaveContext.nightFlag == 0))) { - this->actionFunc = BgSpot00Hanebasi_DrawbridgeRiseAndFall; - this->destAngle = 0; + pthis->actionFunc = BgSpot00Hanebasi_DrawbridgeRiseAndFall; + pthis->destAngle = 0; child->destAngle = 0; return; } - if (this) {} // required to match + if (pthis) {} // required to match } - if ((this->dyna.actor.shape.rot.x == 0) && (gSaveContext.sceneSetupIndex < 4) && !LINK_IS_ADULT && + if ((pthis->dyna.actor.shape.rot.x == 0) && (gSaveContext.sceneSetupIndex < 4) && !LINK_IS_ADULT && (gSaveContext.nightFlag != 0)) { - this->actionFunc = BgSpot00Hanebasi_DrawbridgeRiseAndFall; - this->destAngle = -0x4000; + pthis->actionFunc = BgSpot00Hanebasi_DrawbridgeRiseAndFall; + pthis->destAngle = -0x4000; child->destAngle = -0xFE0; } } } -void BgSpot00Hanebasi_DoNothing(BgSpot00Hanebasi* this, GlobalContext* globalCtx) { +void BgSpot00Hanebasi_DoNothing(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx) { } -void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* this, GlobalContext* globalCtx) { +void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx) { BgSpot00Hanebasi* child; Actor* childsChild; s16 angle = 80; - if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, this->destAngle, 80)) { - this->actionFunc = BgSpot00Hanebasi_DrawbridgeWait; + if (Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.x, pthis->destAngle, 80)) { + pthis->actionFunc = BgSpot00Hanebasi_DrawbridgeWait; } - if (this->dyna.actor.shape.rot.x >= -0x27D8) { - child = (BgSpot00Hanebasi*)this->dyna.actor.child; + if (pthis->dyna.actor.shape.rot.x >= -0x27D8) { + child = (BgSpot00Hanebasi*)pthis->dyna.actor.child; angle *= 0.4f; Math_ScaledStepToS(&child->dyna.actor.shape.rot.x, child->destAngle, angle); childsChild = child->dyna.actor.child; Math_ScaledStepToS(&childsChild->shape.rot.x, child->destAngle, angle); } - if (this->destAngle < 0) { - if (this->actionFunc == BgSpot00Hanebasi_DrawbridgeWait) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BRIDGE_CLOSE_STOP); + if (pthis->destAngle < 0) { + if (pthis->actionFunc == BgSpot00Hanebasi_DrawbridgeWait) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BRIDGE_CLOSE_STOP); } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); } } else { - if (this->actionFunc == BgSpot00Hanebasi_DrawbridgeWait) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + if (pthis->actionFunc == BgSpot00Hanebasi_DrawbridgeWait) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_BRIDGE_OPEN - SFX_FLAG); } } } -void BgSpot00Hanebasi_SetTorchLightInfo(BgSpot00Hanebasi* this, GlobalContext* globalCtx) { +void BgSpot00Hanebasi_SetTorchLightInfo(BgSpot00Hanebasi* pthis, GlobalContext* globalCtx) { u8 lightColor = (u8)(Rand_ZeroOne() * 127.0f) + 128; // intensity of the red and green channels - Lights_PointGlowSetInfo(&this->lightInfo, (this->dyna.actor.params == DT_CHAIN_1) ? 260.0f : -260.0f, + Lights_PointGlowSetInfo(&pthis->lightInfo, (pthis->dyna.actor.params == DT_CHAIN_1) ? 260.0f : -260.0f, (5000.0f * sTorchFlameScale) + 128.0f, 690, lightColor, lightColor, 0, sTorchFlameScale * 37500.0f); } void BgSpot00Hanebasi_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot00Hanebasi* this = (BgSpot00Hanebasi*)thisx; + BgSpot00Hanebasi* pthis = (BgSpot00Hanebasi*)thisx; s32 pad; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->dyna.actor.params == DT_DRAWBRIDGE) { + if (pthis->dyna.actor.params == DT_DRAWBRIDGE) { if (globalCtx->sceneNum == SCENE_SPOT00) { if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY) && CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE) && !(gSaveContext.eventChkInf[8] & 1) && LINK_IS_CHILD) { @@ -236,13 +236,13 @@ void BgSpot00Hanebasi_Update(Actor* thisx, GlobalContext* globalCtx) { (!(Gameplay_InCsMode(globalCtx)))) { gSaveContext.eventChkInf[8] |= 1; Flags_SetEventChkInf(0x82); - this->actionFunc = BgSpot00Hanebasi_DoNothing; + pthis->actionFunc = BgSpot00Hanebasi_DoNothing; func_8002DF54(globalCtx, &player->actor, 8); globalCtx->nextEntranceIndex = 0x00CD; gSaveContext.nextCutsceneIndex = 0xFFF1; globalCtx->sceneLoadFlag = 0x14; globalCtx->fadeTransition = 4; - } else if (Actor_IsFacingAndNearPlayer(&this->dyna.actor, 3000.0f, 0x7530)) { + } else if (Actor_IsFacingAndNearPlayer(&pthis->dyna.actor, 3000.0f, 0x7530)) { globalCtx->envCtx.gloomySkyMode = 1; } } diff --git a/src/overlays/actors/ovl_Bg_Spot01_Fusya/z_bg_spot01_fusya.c b/src/overlays/actors/ovl_Bg_Spot01_Fusya/z_bg_spot01_fusya.cpp similarity index 71% rename from src/overlays/actors/ovl_Bg_Spot01_Fusya/z_bg_spot01_fusya.c rename to src/overlays/actors/ovl_Bg_Spot01_Fusya/z_bg_spot01_fusya.cpp index 19b2adad9..280e76406 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Fusya/z_bg_spot01_fusya.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Fusya/z_bg_spot01_fusya.cpp @@ -21,9 +21,9 @@ void BgSpot01Fusya_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Fusya_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Fusya_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808AAA50(BgSpot01Fusya* this, GlobalContext* globalCtx); +void func_808AAA50(BgSpot01Fusya* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot01_Fusya_InitVars = { +ActorInit Bg_Spot01_Fusya_InitVars = { ACTOR_BG_SPOT01_FUSYA, ACTORCAT_BG, FLAGS, @@ -42,43 +42,43 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1300, ICHAIN_STOP), }; -void BgSpot01Fusya_SetupAction(BgSpot01Fusya* this, BgSpot01FusyaActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgSpot01Fusya_SetupAction(BgSpot01Fusya* pthis, BgSpot01FusyaActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgSpot01Fusya_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Fusya* this = (BgSpot01Fusya*)thisx; + BgSpot01Fusya* pthis = (BgSpot01Fusya*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_154 = 100.0f; - this->unk_158 = 100.0f; - this->unk_15C = 0.5f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->unk_154 = 100.0f; + pthis->unk_158 = 100.0f; + pthis->unk_15C = 0.5f; if (gSaveContext.sceneSetupIndex < 4) { gSaveContext.eventChkInf[6] &= 0xFFDF; } - BgSpot01Fusya_SetupAction(this, func_808AAA50); + BgSpot01Fusya_SetupAction(pthis, func_808AAA50); } void BgSpot01Fusya_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_808AAA50(BgSpot01Fusya* this, GlobalContext* globalCtx) { +void func_808AAA50(BgSpot01Fusya* pthis, GlobalContext* globalCtx) { f32 temp; - Actor* thisx = &this->actor; + Actor* thisx = &pthis->actor; if (gSaveContext.eventChkInf[6] & 0x20) { - this->unk_158 = 1800.0f; + pthis->unk_158 = 1800.0f; } - thisx->shape.rot.z += this->unk_154; - temp = ((this->unk_154 - 100.0f) / 1700.0f) + 1.0f; + thisx->shape.rot.z += pthis->unk_154; + temp = ((pthis->unk_154 - 100.0f) / 1700.0f) + 1.0f; func_800F436C(&thisx->projectedPos, 0x2085, temp); - Math_ApproachF(&this->unk_154, this->unk_158, this->unk_15C, 100.0f); + Math_ApproachF(&pthis->unk_154, pthis->unk_158, pthis->unk_15C, 100.0f); } void BgSpot01Fusya_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Fusya* this = (BgSpot01Fusya*)thisx; + BgSpot01Fusya* pthis = (BgSpot01Fusya*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot01Fusya_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot01_Idohashira/z_bg_spot01_idohashira.c b/src/overlays/actors/ovl_Bg_Spot01_Idohashira/z_bg_spot01_idohashira.cpp similarity index 66% rename from src/overlays/actors/ovl_Bg_Spot01_Idohashira/z_bg_spot01_idohashira.c rename to src/overlays/actors/ovl_Bg_Spot01_Idohashira/z_bg_spot01_idohashira.cpp index 49718c0c9..113caae4a 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Idohashira/z_bg_spot01_idohashira.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Idohashira/z_bg_spot01_idohashira.cpp @@ -27,11 +27,11 @@ void BgSpot01Idohashira_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Idohashira_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Idohashira_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808AB504(BgSpot01Idohashira* this, GlobalContext* globalCtx); -void func_808AB510(BgSpot01Idohashira* this, GlobalContext* globalCtx); -void func_808AB530(BgSpot01Idohashira* this, GlobalContext* globalCtx); -void func_808AB570(BgSpot01Idohashira* this, GlobalContext* globalCtx); -void func_808AB700(BgSpot01Idohashira* this, GlobalContext* globalCtx); +void func_808AB504(BgSpot01Idohashira* pthis, GlobalContext* globalCtx); +void func_808AB510(BgSpot01Idohashira* pthis, GlobalContext* globalCtx); +void func_808AB530(BgSpot01Idohashira* pthis, GlobalContext* globalCtx); +void func_808AB570(BgSpot01Idohashira* pthis, GlobalContext* globalCtx); +void func_808AB700(BgSpot01Idohashira* pthis, GlobalContext* globalCtx); static BgSpot01IdohashiraActionFunc sActionFuncs[] = { func_808AB504, @@ -48,7 +48,7 @@ static BgSpot01IdohashiraDrawFunc sDrawFuncs[] = { func_808AB700, }; -const ActorInit Bg_Spot01_Idohashira_InitVars = { +ActorInit Bg_Spot01_Idohashira_InitVars = { ACTOR_BG_SPOT01_IDOHASHIRA, ACTORCAT_PROP, FLAGS, @@ -60,12 +60,12 @@ const ActorInit Bg_Spot01_Idohashira_InitVars = { (ActorFunc)BgSpot01Idohashira_Draw, }; -void BgSpot01Idohashira_PlayBreakSfx1(BgSpot01Idohashira* this) { - func_80078914(&this->dyna.actor.projectedPos, NA_SE_EV_BOX_BREAK); +void BgSpot01Idohashira_PlayBreakSfx1(BgSpot01Idohashira* pthis) { + func_80078914(&pthis->dyna.actor.projectedPos, NA_SE_EV_BOX_BREAK); } -void BgSpot01Idohashira_PlayBreakSfx2(BgSpot01Idohashira* this, GlobalContext* globalCtx) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WOODBOX_BREAK); +void BgSpot01Idohashira_PlayBreakSfx2(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 60, NA_SE_EV_WOODBOX_BREAK); } void func_808AAD3C(GlobalContext* globalCtx, Vec3f* vec, u32 arg2) { @@ -117,22 +117,22 @@ void func_808AAD3C(GlobalContext* globalCtx, Vec3f* vec, u32 arg2) { Effect_Add(globalCtx, &sp24, EFFECT_SPARK, 0, 1, &effect); } -void func_808AAE6C(BgSpot01Idohashira* this, GlobalContext* globalCtx) { +void func_808AAE6C(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { s32 pad; - Vec3f sp30 = this->dyna.actor.world.pos; + Vec3f sp30 = pthis->dyna.actor.world.pos; sp30.y += kREG(15); func_80033480(globalCtx, &sp30, kREG(11) + 350.0f, kREG(12) + 5, kREG(13) + 0x7D0, kREG(14) + 0x320, 0); func_808AAD3C(globalCtx, &sp30, 5); - BgSpot01Idohashira_PlayBreakSfx2(this, globalCtx); + BgSpot01Idohashira_PlayBreakSfx2(pthis, globalCtx); } -void func_808AAF34(BgSpot01Idohashira* this, GlobalContext* globalCtx) { +void func_808AAF34(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { s32 pad[2]; Vec3f dest; Vec3f src; - if (this->unk_170 != 0) { + if (pthis->unk_170 != 0) { src.x = kREG(20) + 1300.0f; src.y = kREG(21) + 200.0f; src.z = 0.0f; @@ -145,15 +145,15 @@ void func_808AAF34(BgSpot01Idohashira* this, GlobalContext* globalCtx) { Matrix_MultVec3f(&src, &dest); func_80033480(globalCtx, &dest, kREG(16) + 80.0f, kREG(17) + 10, kREG(18) + 1000, kREG(19), 0); func_808AAD3C(globalCtx, &dest, 3); - this->unk_170 = 0; - BgSpot01Idohashira_PlayBreakSfx1(this); + pthis->unk_170 = 0; + BgSpot01Idohashira_PlayBreakSfx1(pthis); } } void BgSpot01Idohashira_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idohashira* this = (BgSpot01Idohashira*)thisx; + BgSpot01Idohashira* pthis = (BgSpot01Idohashira*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } s32 BgSpot01Idohashira_NotInCsMode(GlobalContext* globalCtx) { @@ -173,10 +173,10 @@ CsCmdActorAction* BgSpot01Idohashira_GetNpcAction(GlobalContext* globalCtx, s32 return npcAction; } -void func_808AB18C(BgSpot01Idohashira* this) { - this->dyna.actor.shape.rot.x += kREG(6); - this->dyna.actor.shape.rot.y += (s16)(kREG(7) + 0x3E8); - this->dyna.actor.shape.rot.z += (s16)(kREG(8) + 0x7D0); +void func_808AB18C(BgSpot01Idohashira* pthis) { + pthis->dyna.actor.shape.rot.x += kREG(6); + pthis->dyna.actor.shape.rot.y += (s16)(kREG(7) + 0x3E8); + pthis->dyna.actor.shape.rot.z += (s16)(kREG(8) + 0x7D0); } f32 func_808AB1DC(f32 arg0, f32 arg1, u16 arg2, u16 arg3, u16 arg4) { @@ -196,7 +196,7 @@ f32 func_808AB1DC(f32 arg0, f32 arg1, u16 arg2, u16 arg3, u16 arg4) { return 0.0f; } -s32 func_808AB29C(BgSpot01Idohashira* this, GlobalContext* globalCtx) { +s32 func_808AB29C(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { CsCmdActorAction* npcAction; Vec3f* thisPos; f32 endX; @@ -210,11 +210,11 @@ s32 func_808AB29C(BgSpot01Idohashira* this, GlobalContext* globalCtx) { npcAction = BgSpot01Idohashira_GetNpcAction(globalCtx, 2); if (npcAction != NULL) { temp_f0 = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); - initPos = this->dyna.actor.home.pos; + initPos = pthis->dyna.actor.home.pos; endX = npcAction->endPos.x; tempY = ((kREG(10) + 1100.0f) / 10.0f) + npcAction->endPos.y; endZ = npcAction->endPos.z; - thisPos = &this->dyna.actor.world.pos; + thisPos = &pthis->dyna.actor.world.pos; thisPos->x = ((endX - initPos.x) * temp_f0) + initPos.x; thisPos->y = func_808AB1DC(initPos.y, tempY, npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames) + @@ -230,106 +230,106 @@ s32 func_808AB29C(BgSpot01Idohashira* this, GlobalContext* globalCtx) { return false; } -void func_808AB3E8(BgSpot01Idohashira* this) { - this->action = 1; - this->drawConfig = 0; +void func_808AB3E8(BgSpot01Idohashira* pthis) { + pthis->action = 1; + pthis->drawConfig = 0; } -void func_808AB3F8(BgSpot01Idohashira* this, GlobalContext* globalCtx) { - this->action = 2; - this->drawConfig = 0; - this->unk_170 = 1; +void func_808AB3F8(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { + pthis->action = 2; + pthis->drawConfig = 0; + pthis->unk_170 = 1; } -void func_808AB414(BgSpot01Idohashira* this, GlobalContext* globalCtx) { - func_808AAE6C(this, globalCtx); - this->action = 3; - this->drawConfig = 0; +void func_808AB414(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { + func_808AAE6C(pthis, globalCtx); + pthis->action = 3; + pthis->drawConfig = 0; } -void func_808AB444(BgSpot01Idohashira* this, GlobalContext* globalCtx) { +void func_808AB444(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { CsCmdActorAction* npcAction = BgSpot01Idohashira_GetNpcAction(globalCtx, 2); u32 action; u32 currentNpcAction; if (npcAction != NULL) { action = npcAction->action; - currentNpcAction = this->npcAction; + currentNpcAction = pthis->npcAction; if (action != currentNpcAction) { switch (action) { case 1: - func_808AB3E8(this); + func_808AB3E8(pthis); break; case 2: - func_808AB3F8(this, globalCtx); + func_808AB3F8(pthis, globalCtx); break; case 3: - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); break; default: osSyncPrintf("Bg_Spot01_Idohashira_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); } - this->npcAction = action; + pthis->npcAction = action; } } } -void func_808AB504(BgSpot01Idohashira* this, GlobalContext* globalCtx) { +void func_808AB504(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { } -void func_808AB510(BgSpot01Idohashira* this, GlobalContext* globalCtx) { - func_808AB444(this, globalCtx); +void func_808AB510(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { + func_808AB444(pthis, globalCtx); } -void func_808AB530(BgSpot01Idohashira* this, GlobalContext* globalCtx) { - func_808AB18C(this); - if (func_808AB29C(this, globalCtx)) { - func_808AB414(this, globalCtx); +void func_808AB530(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { + func_808AB18C(pthis); + if (func_808AB29C(pthis, globalCtx)) { + func_808AB414(pthis, globalCtx); } } -void func_808AB570(BgSpot01Idohashira* this, GlobalContext* globalCtx) { - func_808AB444(this, globalCtx); +void func_808AB570(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { + func_808AB444(pthis, globalCtx); } void BgSpot01Idohashira_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idohashira* this = (BgSpot01Idohashira*)thisx; + BgSpot01Idohashira* pthis = (BgSpot01Idohashira*)thisx; - if (this->action < 0 || this->action >= 4 || sActionFuncs[this->action] == NULL) { + if (pthis->action < 0 || pthis->action >= 4 || sActionFuncs[pthis->action] == NULL) { osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - sActionFuncs[this->action](this, globalCtx); + sActionFuncs[pthis->action](pthis, globalCtx); } void BgSpot01Idohashira_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; - BgSpot01Idohashira* this = (BgSpot01Idohashira*)thisx; + BgSpot01Idohashira* pthis = (BgSpot01Idohashira*)thisx; CollisionHeader* colHeader; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); colHeader = NULL; CollisionHeader_GetVirtual(&gKakarikoWellArchCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); if (gSaveContext.sceneSetupIndex < 4) { if ((gSaveContext.eventChkInf[5] & 0x10) && LINK_IS_ADULT) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } else { - this->action = 0; + pthis->action = 0; } } else if (gSaveContext.sceneSetupIndex == 4) { - this->action = 1; - this->dyna.actor.shape.yOffset = -(kREG(10) + 1100.0f); + pthis->action = 1; + pthis->dyna.actor.shape.yOffset = -(kREG(10) + 1100.0f); } else if (gSaveContext.sceneSetupIndex == 6) { - this->action = 0; + pthis->action = 0; } else { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } -void func_808AB700(BgSpot01Idohashira* this, GlobalContext* globalCtx) { +void func_808AB700(BgSpot01Idohashira* pthis, GlobalContext* globalCtx) { GraphicsContext* localGfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(localGfxCtx, "../z_bg_spot01_idohashira.c", 689); @@ -338,18 +338,18 @@ void func_808AB700(BgSpot01Idohashira* this, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(localGfxCtx, "../z_bg_spot01_idohashira.c", 699), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_808AAF34(this, globalCtx); + func_808AAF34(pthis, globalCtx); gSPDisplayList(POLY_OPA_DISP++, gKakarikoWellArchDL); CLOSE_DISPS(localGfxCtx, "../z_bg_spot01_idohashira.c", 708); } void BgSpot01Idohashira_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idohashira* this = (BgSpot01Idohashira*)thisx; + BgSpot01Idohashira* pthis = (BgSpot01Idohashira*)thisx; - if (this->drawConfig < 0 || this->drawConfig > 0 || sDrawFuncs[this->drawConfig] == NULL) { + if (pthis->drawConfig < 0 || pthis->drawConfig > 0 || sDrawFuncs[pthis->drawConfig] == NULL) { osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - sDrawFuncs[this->drawConfig](this, globalCtx); + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_Bg_Spot01_Idomizu/z_bg_spot01_idomizu.c b/src/overlays/actors/ovl_Bg_Spot01_Idomizu/z_bg_spot01_idomizu.cpp similarity index 75% rename from src/overlays/actors/ovl_Bg_Spot01_Idomizu/z_bg_spot01_idomizu.c rename to src/overlays/actors/ovl_Bg_Spot01_Idomizu/z_bg_spot01_idomizu.cpp index c027cc7a1..7b1b36e14 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Idomizu/z_bg_spot01_idomizu.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Idomizu/z_bg_spot01_idomizu.cpp @@ -21,9 +21,9 @@ void BgSpot01Idomizu_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Idomizu_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Idomizu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808ABB84(BgSpot01Idomizu* this, GlobalContext* globalCtx); +void func_808ABB84(BgSpot01Idomizu* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot01_Idomizu_InitVars = { +ActorInit Bg_Spot01_Idomizu_InitVars = { ACTOR_BG_SPOT01_IDOMIZU, ACTORCAT_BG, FLAGS, @@ -40,37 +40,37 @@ static InitChainEntry sInitChain[] = { }; void BgSpot01Idomizu_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idomizu* this = (BgSpot01Idomizu*)thisx; + BgSpot01Idomizu* pthis = (BgSpot01Idomizu*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(&pthis->actor, sInitChain); if (gSaveContext.eventChkInf[6] & 0x80 || LINK_AGE_IN_YEARS == YEARS_ADULT) { - this->waterHeight = -550.0f; + pthis->waterHeight = -550.0f; } else { - this->waterHeight = 52.0f; + pthis->waterHeight = 52.0f; } - this->actionFunc = func_808ABB84; - this->actor.world.pos.y = this->waterHeight; + pthis->actionFunc = func_808ABB84; + pthis->actor.world.pos.y = pthis->waterHeight; } void BgSpot01Idomizu_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_808ABB84(BgSpot01Idomizu* this, GlobalContext* globalCtx) { +void func_808ABB84(BgSpot01Idomizu* pthis, GlobalContext* globalCtx) { if (gSaveContext.eventChkInf[6] & 0x80) { - this->waterHeight = -550.0f; + pthis->waterHeight = -550.0f; } - globalCtx->colCtx.colHeader->waterBoxes[0].ySurface = this->actor.world.pos.y; - if (this->waterHeight < this->actor.world.pos.y) { + globalCtx->colCtx.colHeader->waterBoxes[0].ySurface = pthis->actor.world.pos.y; + if (pthis->waterHeight < pthis->actor.world.pos.y) { Audio_PlaySoundGeneral(NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Math_ApproachF(&this->actor.world.pos.y, this->waterHeight, 1.0f, 2.0f); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->waterHeight, 1.0f, 2.0f); } void BgSpot01Idomizu_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idomizu* this = (BgSpot01Idomizu*)thisx; + BgSpot01Idomizu* pthis = (BgSpot01Idomizu*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot01Idomizu_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c b/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.cpp similarity index 69% rename from src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c rename to src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.cpp index a4ed7e1da..d3cfeb237 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.cpp @@ -22,9 +22,9 @@ void BgSpot01Idosoko_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Idosoko_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Idosoko_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808ABF54(BgSpot01Idosoko* this, GlobalContext* globalCtx); +void func_808ABF54(BgSpot01Idosoko* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot01_Idosoko_InitVars = { +ActorInit Bg_Spot01_Idosoko_InitVars = { ACTOR_BG_SPOT01_IDOSOKO, ACTORCAT_BG, FLAGS, @@ -40,40 +40,40 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgSpot01Idosoko_SetupAction(BgSpot01Idosoko* this, BgSpot01IdosokoActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgSpot01Idosoko_SetupAction(BgSpot01Idosoko* pthis, BgSpot01IdosokoActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgSpot01Idosoko_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgSpot01Idosoko* this = (BgSpot01Idosoko*)thisx; + BgSpot01Idosoko* pthis = (BgSpot01Idosoko*)thisx; CollisionHeader* colHeader = NULL; s32 pad2; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); CollisionHeader_GetVirtual(&gKakarikoBOTWStoneCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); if (!LINK_IS_ADULT) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } else { - BgSpot01Idosoko_SetupAction(this, func_808ABF54); + BgSpot01Idosoko_SetupAction(pthis, func_808ABF54); } } void BgSpot01Idosoko_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idosoko* this = (BgSpot01Idosoko*)thisx; + BgSpot01Idosoko* pthis = (BgSpot01Idosoko*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808ABF54(BgSpot01Idosoko* this, GlobalContext* globalCtx) { +void func_808ABF54(BgSpot01Idosoko* pthis, GlobalContext* globalCtx) { } void BgSpot01Idosoko_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Idosoko* this = (BgSpot01Idosoko*)thisx; + BgSpot01Idosoko* pthis = (BgSpot01Idosoko*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot01Idosoko_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.cpp similarity index 68% rename from src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c rename to src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.cpp index 335b50ad2..ef5d0d95f 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.cpp @@ -22,11 +22,11 @@ void BgSpot01Objects2_Init(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Objects2_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot01Objects2_Update(Actor* thisx, GlobalContext* globalCtx); -void func_808AC2BC(BgSpot01Objects2* this, GlobalContext* globalCtx); -void func_808AC474(BgSpot01Objects2* this, GlobalContext* globalCtx); +void func_808AC2BC(BgSpot01Objects2* pthis, GlobalContext* globalCtx); +void func_808AC474(BgSpot01Objects2* pthis, GlobalContext* globalCtx); void func_808AC4A4(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot01_Objects2_InitVars = { +ActorInit Bg_Spot01_Objects2_InitVars = { ACTOR_BG_SPOT01_OBJECTS2, ACTORCAT_BG, FLAGS, @@ -51,34 +51,34 @@ static Gfx* D_808AC510[] = { }; void BgSpot01Objects2_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Objects2* this = (BgSpot01Objects2*)thisx; + BgSpot01Objects2* pthis = (BgSpot01Objects2*)thisx; - switch (this->dyna.actor.params & 7) { + switch (pthis->dyna.actor.params & 7) { case 0: case 1: case 2: - this->objectId = OBJECT_SPOT01_MATOYA; + pthis->objectId = OBJECT_SPOT01_MATOYA; break; case 3: - this->objectId = OBJECT_SPOT01_MATOYAB; + pthis->objectId = OBJECT_SPOT01_MATOYAB; break; case 4: - this->objectId = OBJECT_SPOT01_MATOYA; + pthis->objectId = OBJECT_SPOT01_MATOYA; } - if (this->objectId >= 0) { - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, this->objectId); - if (this->objBankIndex < 0) { + if (pthis->objectId >= 0) { + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, pthis->objectId); + if (pthis->objBankIndex < 0) { // "There was no bank setting." osSyncPrintf("-----------------------------バンク設定ありませんでした."); - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } } else { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } - this->actionFunc = func_808AC2BC; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + pthis->actionFunc = func_808AC2BC; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); } void BgSpot01Objects2_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -93,28 +93,28 @@ s32 func_808AC22C(Path* pathList, Vec3f* pos, s32 path, s32 waypoint) { return 0; } -void func_808AC2BC(BgSpot01Objects2* this, GlobalContext* globalCtx) { +void func_808AC2BC(BgSpot01Objects2* pthis, GlobalContext* globalCtx) { CollisionHeader* colHeader = NULL; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; s32 pad; Vec3f position; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { // "---- Successful bank switching!!" osSyncPrintf("-----バンク切り換え成功!!\n"); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndex].vromStart); + gSegments[6] = gObjectTable[pthis->objBankIndex].vromStart.get(); - this->dyna.actor.objBankIndex = this->objBankIndex; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); + pthis->dyna.actor.objBankIndex = pthis->objBankIndex; + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); - switch (this->dyna.actor.params & 7) { + switch (pthis->dyna.actor.params & 7) { case 4: // Shooting gallery CollisionHeader_GetVirtual(&gKakarikoShootingGalleryCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); break; case 3: // Shooting Gallery, spawns Carpenter Sabooro during the day CollisionHeader_GetVirtual(&object_spot01_matoyab_col, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); if (IS_DAY) { func_808AC22C(globalCtx->setupPathList, &position, ((s32)thisx->params >> 8) & 0xFF, 0); Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_DAIKU_KAKARIKO, position.x, @@ -128,18 +128,18 @@ void func_808AC2BC(BgSpot01Objects2* this, GlobalContext* globalCtx) { break; } - this->dyna.actor.draw = func_808AC4A4; - this->actionFunc = func_808AC474; + pthis->dyna.actor.draw = func_808AC4A4; + pthis->actionFunc = func_808AC474; } } -void func_808AC474(BgSpot01Objects2* this, GlobalContext* globalCtx) { +void func_808AC474(BgSpot01Objects2* pthis, GlobalContext* globalCtx) { } void BgSpot01Objects2_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot01Objects2* this = (BgSpot01Objects2*)thisx; + BgSpot01Objects2* pthis = (BgSpot01Objects2*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void func_808AC4A4(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c b/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.cpp similarity index 67% rename from src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c rename to src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.cpp index cd28f4cda..8b5de3692 100644 --- a/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c +++ b/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.cpp @@ -29,13 +29,13 @@ void BgSpot02Objects_Draw(Actor* thisx, GlobalContext* globalCtx); void func_808ACCB8(Actor* thisx, GlobalContext* globalCtx); void func_808AD450(Actor* thisx, GlobalContext* globalCtx); -void func_808AC8FC(BgSpot02Objects* this, GlobalContext* globalCtx); -void func_808AC908(BgSpot02Objects* this, GlobalContext* globalCtx); -void func_808ACA08(BgSpot02Objects* this, GlobalContext* globalCtx); -void func_808ACAFC(BgSpot02Objects* this, GlobalContext* globalCtx); -void func_808ACB58(BgSpot02Objects* this, GlobalContext* globalCtx); -void func_808ACC34(BgSpot02Objects* this, GlobalContext* globalCtx); -void func_808AD3D4(BgSpot02Objects* this, GlobalContext* globalCtx); +void func_808AC8FC(BgSpot02Objects* pthis, GlobalContext* globalCtx); +void func_808AC908(BgSpot02Objects* pthis, GlobalContext* globalCtx); +void func_808ACA08(BgSpot02Objects* pthis, GlobalContext* globalCtx); +void func_808ACAFC(BgSpot02Objects* pthis, GlobalContext* globalCtx); +void func_808ACB58(BgSpot02Objects* pthis, GlobalContext* globalCtx); +void func_808ACC34(BgSpot02Objects* pthis, GlobalContext* globalCtx); +void func_808AD3D4(BgSpot02Objects* pthis, GlobalContext* globalCtx); static void* D_808AD850[] = { object_spot02_objects_Tex_0096B0, object_spot02_objects_Tex_00A2B0, object_spot02_objects_Tex_00AEB0, @@ -44,7 +44,7 @@ static void* D_808AD850[] = { object_spot02_objects_Tex_0102B0, object_spot02_objects_Tex_010EB0, object_spot02_objects_Tex_011AB0, }; -const ActorInit Bg_Spot02_Objects_InitVars = { +ActorInit Bg_Spot02_Objects_InitVars = { ACTOR_BG_SPOT02_OBJECTS, ACTORCAT_BG, FLAGS, @@ -62,11 +62,11 @@ static InitChainEntry sInitChain[] = { void BgSpot02Objects_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgSpot02Objects* this = (BgSpot02Objects*)thisx; + BgSpot02Objects* pthis = (BgSpot02Objects*)thisx; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, 0); - this->unk_16B = (u16)(thisx->params >> 8); + DynaPolyActor_Init(&pthis->dyna, 0); + pthis->unk_16B = (u16)(thisx->params >> 8); thisx->params = (u16)(thisx->params & 0xFF); switch (thisx->params) { @@ -76,29 +76,29 @@ void BgSpot02Objects_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(thisx, sInitChain); if (thisx->params == 0) { - if (Flags_GetSwitch(globalCtx, this->unk_16B)) { - this->actionFunc = func_808AC8FC; + if (Flags_GetSwitch(globalCtx, pthis->unk_16B)) { + pthis->actionFunc = func_808AC8FC; thisx->world.pos.y += 255.0f; } else { - this->actionFunc = func_808ACAFC; + pthis->actionFunc = func_808ACAFC; } CollisionHeader_GetVirtual(&object_spot02_objects_Col_012BA4, &colHeader); } else if (thisx->params == 1) { - this->actionFunc = func_808AC8FC; + pthis->actionFunc = func_808AC8FC; CollisionHeader_GetVirtual(&object_spot02_objects_Col_0128D8, &colHeader); thisx->flags |= ACTOR_FLAG_22; } else { if (globalCtx->sceneNum == SCENE_SPOT02) { - this->actionFunc = func_808AC908; + pthis->actionFunc = func_808AC908; } else { - this->actionFunc = func_808AC8FC; + pthis->actionFunc = func_808AC8FC; } CollisionHeader_GetVirtual(&object_spot02_objects_Col_0133EC, &colHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); if (((gSaveContext.eventChkInf[1] & 0x2000) && (globalCtx->sceneNum == SCENE_SPOT02) && (thisx->params == 2)) || @@ -108,9 +108,9 @@ void BgSpot02Objects_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 3: - this->unk_16A = 0; + pthis->unk_16A = 0; Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_ITEMACTION); - this->actionFunc = func_808ACC34; + pthis->actionFunc = func_808ACC34; thisx->draw = func_808ACCB8; if (gSaveContext.eventChkInf[1] & 0x2000) { @@ -119,55 +119,55 @@ void BgSpot02Objects_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 4: - this->timer = -12; - this->unk_170 = 0xFFFF; + pthis->timer = -12; + pthis->unk_170 = 0xFFFF; Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_ITEMACTION); - this->actionFunc = func_808AD3D4; + pthis->actionFunc = func_808AD3D4; thisx->draw = func_808AD450; break; } } void BgSpot02Objects_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot02Objects* this = (BgSpot02Objects*)thisx; + BgSpot02Objects* pthis = (BgSpot02Objects*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808AC8FC(BgSpot02Objects* this, GlobalContext* globalCtx) { +void func_808AC8FC(BgSpot02Objects* pthis, GlobalContext* globalCtx) { } -void func_808AC908(BgSpot02Objects* this, GlobalContext* globalCtx) { +void func_808AC908(BgSpot02Objects* pthis, GlobalContext* globalCtx) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f pos; if (globalCtx->csCtx.state != 0) { if (globalCtx->csCtx.npcActions[3] != NULL && globalCtx->csCtx.npcActions[3]->action == 2) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_GRAVE_EXPLOSION); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_GRAVE_EXPLOSION); gSaveContext.eventChkInf[1] |= 0x2000; - this->timer = 25; - pos.x = (Math_SinS(this->dyna.actor.shape.rot.y) * 50.0f) + this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + 30.0f; - pos.z = (Math_CosS(this->dyna.actor.shape.rot.y) * 50.0f) + this->dyna.actor.world.pos.z; + pthis->timer = 25; + pos.x = (Math_SinS(pthis->dyna.actor.shape.rot.y) * 50.0f) + pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + 30.0f; + pos.z = (Math_CosS(pthis->dyna.actor.shape.rot.y) * 50.0f) + pthis->dyna.actor.world.pos.z; EffectSsBomb2_SpawnLayered(globalCtx, &pos, &zeroVec, &zeroVec, 70, 30); - this->actionFunc = func_808ACA08; + pthis->actionFunc = func_808ACA08; } } } -void func_808ACA08(BgSpot02Objects* this, GlobalContext* globalCtx) { +void func_808ACA08(BgSpot02Objects* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - if (this->timer == 20) { - this->dyna.actor.draw = NULL; - EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 30.0f, 0, 25, 5, 40, OBJECT_SPOT02_OBJECTS, 20, + if (pthis->timer == 20) { + pthis->dyna.actor.draw = NULL; + EffectSsHahen_SpawnBurst(globalCtx, &pthis->dyna.actor.world.pos, 30.0f, 0, 25, 5, 40, OBJECT_SPOT02_OBJECTS, 20, object_spot02_objects_DL_012D30); - } else if (this->timer == 0) { - Actor_Kill(&this->dyna.actor); + } else if (pthis->timer == 0) { + Actor_Kill(&pthis->dyna.actor); } if (globalCtx->csCtx.frames == 402) { @@ -179,27 +179,27 @@ void func_808ACA08(BgSpot02Objects* this, GlobalContext* globalCtx) { } } -void func_808ACAFC(BgSpot02Objects* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->unk_16B)) { - Actor_SetFocus(&this->dyna.actor, 60.0f); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->actionFunc = func_808ACB58; +void func_808ACAFC(BgSpot02Objects* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->unk_16B)) { + Actor_SetFocus(&pthis->dyna.actor, 60.0f); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->actionFunc = func_808ACB58; } } -void func_808ACB58(BgSpot02Objects* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 255.0f, 1.0f)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - this->actionFunc = func_808AC8FC; +void func_808ACB58(BgSpot02Objects* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 255.0f, 1.0f)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + pthis->actionFunc = func_808AC8FC; } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_WALL_MOVE_SP - SFX_FLAG); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_WALL_MOVE_SP - SFX_FLAG); } } void BgSpot02Objects_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot02Objects* this = (BgSpot02Objects*)thisx; + BgSpot02Objects* pthis = (BgSpot02Objects*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot02Objects_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -212,13 +212,13 @@ void BgSpot02Objects_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, dLists[thisx->params]); } -void func_808ACC34(BgSpot02Objects* this, GlobalContext* globalCtx) { +void func_808ACC34(BgSpot02Objects* pthis, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0 && globalCtx->csCtx.npcActions[0] != NULL && globalCtx->csCtx.npcActions[0]->action == 2) { - this->unk_16A++; + pthis->unk_16A++; - if (this->unk_16A >= 12) { - Actor_Kill(&this->dyna.actor); + if (pthis->unk_16A >= 12) { + Actor_Kill(&pthis->dyna.actor); } } @@ -228,7 +228,7 @@ void func_808ACC34(BgSpot02Objects* this, GlobalContext* globalCtx) { } void func_808ACCB8(Actor* thisx, GlobalContext* globalCtx) { - BgSpot02Objects* this = (BgSpot02Objects*)thisx; + BgSpot02Objects* pthis = (BgSpot02Objects*)thisx; f32 rate; s32 pad; u8 redPrim; @@ -242,14 +242,14 @@ void func_808ACCB8(Actor* thisx, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0 && globalCtx->csCtx.npcActions[0] != NULL && globalCtx->csCtx.npcActions[0]->action == 2) { - if (this->unk_16A < 5) { - rate = (this->unk_16A / 5.0f); + if (pthis->unk_16A < 5) { + rate = (pthis->unk_16A / 5.0f); redPrim = greenPrim = bluePrim = 255; redEnv = 100.0f + 155.0f * rate; greenEnv = 255; blueEnv = 255.0f - 155.0f * rate; } else { - rate = ((this->unk_16A - 5) / 7.0f); + rate = ((pthis->unk_16A - 5) / 7.0f); redPrim = 255.0f - (255.0f * rate); greenPrim = 255.0f - (55.0f * rate); bluePrim = 255.0f - (255.0f * rate); @@ -271,7 +271,7 @@ void func_808ACCB8(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, redEnv, greenEnv, blueEnv, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot02_objects.c", 679), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_808AD850[this->unk_16A])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_808AD850[pthis->unk_16A])); gDPPipeSync(POLY_XLU_DISP++); gSPDisplayList(POLY_XLU_DISP++, object_spot02_objects_DL_0126F0); gDPPipeSync(POLY_XLU_DISP++); @@ -280,23 +280,23 @@ void func_808ACCB8(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot02_objects.c", 692); } -void func_808AD3D4(BgSpot02Objects* this, GlobalContext* globalCtx) { +void func_808AD3D4(BgSpot02Objects* pthis, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0 && globalCtx->csCtx.npcActions[2] != NULL && globalCtx->csCtx.npcActions[2]->action == 2) { - if (this->timer == 2) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_IT_EXPLOSION_ICE); + if (pthis->timer == 2) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_IT_EXPLOSION_ICE); } - if (this->timer < 32) { - this->timer++; + if (pthis->timer < 32) { + pthis->timer++; } else { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } } void func_808AD450(Actor* thisx, GlobalContext* globalCtx) { - BgSpot02Objects* this = (BgSpot02Objects*)thisx; + BgSpot02Objects* pthis = (BgSpot02Objects*)thisx; s32 pad; f32 lerp; @@ -305,13 +305,13 @@ void func_808AD450(Actor* thisx, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0 && globalCtx->csCtx.npcActions[2] != NULL) { u16 temp_v1 = globalCtx->csCtx.npcActions[2]->urot.z * 0.00549325f; - if (this->unk_170 != temp_v1) { - if (this->unk_170 == 0xFFFF) { - this->unk_170 = temp_v1; - this->unk_172 = temp_v1; + if (pthis->unk_170 != temp_v1) { + if (pthis->unk_170 == 0xFFFF) { + pthis->unk_170 = temp_v1; + pthis->unk_172 = temp_v1; } else { - this->unk_172 = this->unk_170; - this->unk_170 = temp_v1; + pthis->unk_172 = pthis->unk_170; + pthis->unk_170 = temp_v1; } } @@ -324,7 +324,7 @@ void func_808AD450(Actor* thisx, GlobalContext* globalCtx) { globalCtx->csCtx.npcActions[2]->startPos.z, MTXMODE_NEW); Matrix_RotateX(globalCtx->csCtx.npcActions[2]->urot.x * (M_PI / (f32)0x8000), MTXMODE_APPLY); Matrix_RotateY(globalCtx->csCtx.npcActions[2]->urot.y * (M_PI / (f32)0x8000), MTXMODE_APPLY); - Matrix_Scale(0.9f, 0.9f, (((this->unk_170 - this->unk_172) * lerp) + this->unk_172) * 0.1f, MTXMODE_APPLY); + Matrix_Scale(0.9f, 0.9f, (((pthis->unk_170 - pthis->unk_172) * lerp) + pthis->unk_172) * 0.1f, MTXMODE_APPLY); func_80093D84(globalCtx->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); @@ -333,8 +333,8 @@ void func_808AD450(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot02_objects.c", 795), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 2 * this->timer, -3 * this->timer, 32, 64, 1, - 4 * this->timer, -6 * this->timer, 32, 64)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 2 * pthis->timer, -3 * pthis->timer, 32, 64, 1, + 4 * pthis->timer, -6 * pthis->timer, 32, 64)); gDPPipeSync(POLY_XLU_DISP++); gSPDisplayList(POLY_XLU_DISP++, object_spot02_objects_DL_0013F0); gDPPipeSync(POLY_XLU_DISP++); diff --git a/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.c b/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.cpp similarity index 52% rename from src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.c rename to src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.cpp index e2c1f5c73..e44fdc489 100644 --- a/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.c +++ b/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.cpp @@ -24,9 +24,9 @@ void BgSpot03Taki_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot03Taki_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot03Taki_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808ADEF0(BgSpot03Taki* this, GlobalContext* globalCtx); +void func_808ADEF0(BgSpot03Taki* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot03_Taki_InitVars = { +ActorInit Bg_Spot03_Taki_InitVars = { ACTOR_BG_SPOT03_TAKI, ACTORCAT_BG, FLAGS, @@ -42,89 +42,88 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgSpot03Taki_ApplyOpeningAlpha(BgSpot03Taki* this, s32 bufferIndex) { +void BgSpot03Taki_ApplyOpeningAlpha(BgSpot03Taki* pthis, s32 bufferIndex) { s32 i; - Vtx* vtx = (bufferIndex == 0) ? SEGMENTED_TO_VIRTUAL(object_spot03_object_Vtx_000800) - : SEGMENTED_TO_VIRTUAL(object_spot03_object_Vtx_000990); + Vtx* vtx = (bufferIndex == 0) ? object_spot03_object_Vtx_000800 : object_spot03_object_Vtx_000990; for (i = 0; i < 5; i++) { - vtx[i + 10].v.cn[3] = this->openingAlpha; + vtx[i + 10].v.cn[3] = pthis->openingAlpha; } } void BgSpot03Taki_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot03Taki* this = (BgSpot03Taki*)thisx; + BgSpot03Taki* pthis = (BgSpot03Taki*)thisx; s16 pad; CollisionHeader* colHeader = NULL; - this->switchFlag = (this->dyna.actor.params & 0x3F); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + pthis->switchFlag = (pthis->dyna.actor.params & 0x3F); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&object_spot03_object_Col_000C98, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->bufferIndex = 0; - this->openingAlpha = 255.0f; - BgSpot03Taki_ApplyOpeningAlpha(this, 0); - BgSpot03Taki_ApplyOpeningAlpha(this, 1); - this->actionFunc = func_808ADEF0; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->bufferIndex = 0; + pthis->openingAlpha = 255.0f; + BgSpot03Taki_ApplyOpeningAlpha(pthis, 0); + BgSpot03Taki_ApplyOpeningAlpha(pthis, 1); + pthis->actionFunc = func_808ADEF0; } void BgSpot03Taki_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot03Taki* this = (BgSpot03Taki*)thisx; + BgSpot03Taki* pthis = (BgSpot03Taki*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808ADEF0(BgSpot03Taki* this, GlobalContext* globalCtx) { - if (this->state == WATERFALL_CLOSED) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->state = WATERFALL_OPENING_ANIMATED; - this->timer = 40; +void func_808ADEF0(BgSpot03Taki* pthis, GlobalContext* globalCtx) { + if (pthis->state == WATERFALL_CLOSED) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->state = WATERFALL_OPENING_ANIMATED; + pthis->timer = 40; OnePointCutscene_Init(globalCtx, 4100, -99, NULL, MAIN_CAM); } - } else if (this->state == WATERFALL_OPENING_IDLE) { - this->timer--; - if (this->timer < 0) { - this->state = WATERFALL_OPENING_ANIMATED; + } else if (pthis->state == WATERFALL_OPENING_IDLE) { + pthis->timer--; + if (pthis->timer < 0) { + pthis->state = WATERFALL_OPENING_ANIMATED; } - } else if (this->state == WATERFALL_OPENING_ANIMATED) { - if (this->openingAlpha > 0) { - this->openingAlpha -= 5; - if (this->openingAlpha <= 0.0f) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->timer = 400; - this->state = WATERFALL_OPENED; - this->openingAlpha = 0; + } else if (pthis->state == WATERFALL_OPENING_ANIMATED) { + if (pthis->openingAlpha > 0) { + pthis->openingAlpha -= 5; + if (pthis->openingAlpha <= 0.0f) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->timer = 400; + pthis->state = WATERFALL_OPENED; + pthis->openingAlpha = 0; } } - } else if (this->state == WATERFALL_OPENED) { - this->timer--; - if (this->timer < 0) { - this->state = WATERFALL_CLOSING; + } else if (pthis->state == WATERFALL_OPENED) { + pthis->timer--; + if (pthis->timer < 0) { + pthis->state = WATERFALL_CLOSING; } - } else if (this->state == WATERFALL_CLOSING) { - if (this->openingAlpha < 255.0f) { - this->openingAlpha += 5.0f; - if (this->openingAlpha >= 255.0f) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->state = WATERFALL_CLOSED; - this->openingAlpha = 255.0f; - Flags_UnsetSwitch(globalCtx, this->switchFlag); + } else if (pthis->state == WATERFALL_CLOSING) { + if (pthis->openingAlpha < 255.0f) { + pthis->openingAlpha += 5.0f; + if (pthis->openingAlpha >= 255.0f) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->state = WATERFALL_CLOSED; + pthis->openingAlpha = 255.0f; + Flags_UnsetSwitch(globalCtx, pthis->switchFlag); } } } - BgSpot03Taki_ApplyOpeningAlpha(this, this->bufferIndex); + BgSpot03Taki_ApplyOpeningAlpha(pthis, pthis->bufferIndex); } void BgSpot03Taki_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot03Taki* this = (BgSpot03Taki*)thisx; + BgSpot03Taki* pthis = (BgSpot03Taki*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot03Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot03Taki* this = (BgSpot03Taki*)thisx; + BgSpot03Taki* pthis = (BgSpot03Taki*)thisx; s32 pad; u32 gameplayFrames; @@ -143,7 +142,7 @@ void BgSpot03Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, object_spot03_object_DL_000B20); - if (this->bufferIndex == 0) { + if (pthis->bufferIndex == 0) { gSPVertex(POLY_XLU_DISP++, object_spot03_object_Vtx_000800, 25, 0); } else { gSPVertex(POLY_XLU_DISP++, object_spot03_object_Vtx_000990, 25, 0); @@ -159,11 +158,11 @@ void BgSpot03Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot03_taki.c", 358); - this->bufferIndex = this->bufferIndex == 0; + pthis->bufferIndex = pthis->bufferIndex == 0; - if (this->state >= WATERFALL_OPENING_IDLE && this->state <= WATERFALL_OPENED) { - Audio_PlaySoundWaterfall(&this->dyna.actor.projectedPos, 0.5f); + if (pthis->state >= WATERFALL_OPENING_IDLE && pthis->state <= WATERFALL_OPENED) { + Audio_PlaySoundWaterfall(&pthis->dyna.actor.projectedPos, 0.5f); } else { - Audio_PlaySoundWaterfall(&this->dyna.actor.projectedPos, 1.0f); + Audio_PlaySoundWaterfall(&pthis->dyna.actor.projectedPos, 1.0f); } } diff --git a/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c b/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.cpp similarity index 56% rename from src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c rename to src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.cpp index 5beda27d7..91761216d 100644 --- a/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c +++ b/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.cpp @@ -22,11 +22,11 @@ void BgSpot05Soko_Init(Actor* thisx, GlobalContext* globalCtx); void BgSpot05Soko_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot05Soko_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot05Soko_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808AE5A8(BgSpot05Soko* this, GlobalContext* globalCtx); -void func_808AE5B4(BgSpot05Soko* this, GlobalContext* globalCtx); -void func_808AE630(BgSpot05Soko* this, GlobalContext* globalCtx); +void func_808AE5A8(BgSpot05Soko* pthis, GlobalContext* globalCtx); +void func_808AE5B4(BgSpot05Soko* pthis, GlobalContext* globalCtx); +void func_808AE630(BgSpot05Soko* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot05_Soko_InitVars = { +ActorInit Bg_Spot05_Soko_InitVars = { ACTOR_BG_SPOT05_SOKO, ACTORCAT_PROP, FLAGS, @@ -49,64 +49,64 @@ static Gfx* sDLists[] = { void BgSpot05Soko_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad1; - BgSpot05Soko* this = (BgSpot05Soko*)thisx; + BgSpot05Soko* pthis = (BgSpot05Soko*)thisx; CollisionHeader* colHeader = NULL; s32 pad2; Actor_ProcessInitChain(thisx, sInitChain); - this->switchFlag = (thisx->params >> 8) & 0xFF; + pthis->switchFlag = (thisx->params >> 8) & 0xFF; thisx->params &= 0xFF; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); if (thisx->params == 0) { CollisionHeader_GetVirtual(&object_spot05_objects_Col_000918, &colHeader); if (LINK_IS_ADULT) { Actor_Kill(thisx); } else { - this->actionFunc = func_808AE5A8; + pthis->actionFunc = func_808AE5A8; } } else { CollisionHeader_GetVirtual(&object_spot05_objects_Col_0012C0, &colHeader); - if (Flags_GetSwitch(globalCtx, this->switchFlag) != 0) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag) != 0) { Actor_Kill(thisx); } else { - this->actionFunc = func_808AE5B4; + pthis->actionFunc = func_808AE5B4; thisx->flags |= ACTOR_FLAG_4; } } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); } void BgSpot05Soko_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot05Soko* this = (BgSpot05Soko*)thisx; + BgSpot05Soko* pthis = (BgSpot05Soko*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808AE5A8(BgSpot05Soko* this, GlobalContext* globalCtx) { +void func_808AE5A8(BgSpot05Soko* pthis, GlobalContext* globalCtx) { } -void func_808AE5B4(BgSpot05Soko* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_METALDOOR_CLOSE); - Actor_SetFocus(&this->dyna.actor, 50.0f); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->actionFunc = func_808AE630; - this->dyna.actor.speedXZ = 0.5f; +void func_808AE5B4(BgSpot05Soko* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 30, NA_SE_EV_METALDOOR_CLOSE); + Actor_SetFocus(&pthis->dyna.actor, 50.0f); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->actionFunc = func_808AE630; + pthis->dyna.actor.speedXZ = 0.5f; } } -void func_808AE630(BgSpot05Soko* this, GlobalContext* globalCtx) { - this->dyna.actor.speedXZ *= 1.5f; - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 120.0f, this->dyna.actor.speedXZ) != +void func_808AE630(BgSpot05Soko* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.speedXZ *= 1.5f; + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 120.0f, pthis->dyna.actor.speedXZ) != 0) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } void BgSpot05Soko_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot05Soko* this = (BgSpot05Soko*)thisx; + BgSpot05Soko* pthis = (BgSpot05Soko*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot05Soko_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c b/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c deleted file mode 100644 index 0c784b61c..000000000 --- a/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c +++ /dev/null @@ -1,525 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT06_OBJECTS_Z_BG_SPOT06_OBJECTS_C -#include "actor_common.h" -/* - * File: z_bg_spot06_objects.c - * Overlay: ovl_Bg_Spot06_Objects - * Description: Lake Hylia Objects - */ - -#include "z_bg_spot06_objects.h" -#include "objects/object_spot06_objects/object_spot06_objects.h" -#include "def/code_80043480.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_9 - -typedef enum { - /* 0x0 */ LHO_WATER_TEMPLE_ENTRACE_GATE, - /* 0x1 */ LHO_WATER_TEMPLE_ENTRANCE_LOCK, - /* 0x2 */ LHO_WATER_PLANE, - /* 0x3 */ LHO_ICE_BLOCK -} LakeHyliaObjectsType; - -typedef enum { - /* 0x0 */ LHWB_GERUDO_VALLEY_RIVER_UPPER, // entrance from Gerudo Valley - /* 0x1 */ LHWB_GERUDO_VALLEY_RIVER_LOWER, // river flowing from Gerudo Valley - /* 0x2 */ LHWB_MAIN_1, // main water box - /* 0x3 */ LHWB_MAIN_2 // extension of main water box -} LakeHyliaWaterBoxIndices; - -// Lake Hylia water plane levels -#define WATER_LEVEL_RAISED (-1313) -#define WATER_LEVEL_RIVER_RAISED (WATER_LEVEL_RAISED + 200) -#define WATER_LEVEL_LOWERED (WATER_LEVEL_RAISED - 680) -#define WATER_LEVEL_RIVER_LOWERED (WATER_LEVEL_RIVER_RAISED - 80) - -void BgSpot06Objects_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot06Objects_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot06Objects_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot06Objects_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgSpot06Objects_GateWaitForSwitch(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_GateWaitToOpen(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_GateOpen(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_DoNothing(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_LockWait(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_LockPullOutward(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_LockSwimToSurface(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_LockFloat(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_WaterPlaneCutsceneWait(BgSpot06Objects* this, GlobalContext* globalCtx); -void BgSpot06Objects_WaterPlaneCutsceneRise(BgSpot06Objects* this, GlobalContext* globalCtx); - -const ActorInit Bg_Spot06_Objects_InitVars = { - ACTOR_BG_SPOT06_OBJECTS, - ACTORCAT_PROP, - FLAGS, - OBJECT_SPOT06_OBJECTS, - sizeof(BgSpot06Objects), - (ActorFunc)BgSpot06Objects_Init, - (ActorFunc)BgSpot06Objects_Destroy, - (ActorFunc)BgSpot06Objects_Update, - (ActorFunc)BgSpot06Objects_Draw, -}; - -static ColliderJntSphElementInit sJntSphItemsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000080, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 1, { { 0, 0, -160 }, 18 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphItemsInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainWaterPlane[] = { - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -void BgSpot06Objects_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot06Objects* this = (BgSpot06Objects*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - this->switchFlag = thisx->params & 0xFF; - thisx->params = (thisx->params >> 8) & 0xFF; - - osSyncPrintf("spot06 obj nthisx->arg_data=[%d]", thisx->params); - - switch (thisx->params) { - case LHO_WATER_TEMPLE_ENTRACE_GATE: - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gLakeHyliaWaterTempleGateCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - - if (LINK_IS_ADULT && Flags_GetSwitch(globalCtx, this->switchFlag)) { - thisx->world.pos.y = thisx->home.pos.y + 120.0f; - this->actionFunc = BgSpot06Objects_DoNothing; - - } else { - this->actionFunc = BgSpot06Objects_GateWaitForSwitch; - } - - break; - case LHO_WATER_TEMPLE_ENTRANCE_LOCK: - Actor_ProcessInitChain(thisx, sInitChain); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, thisx, &sJntSphInit, this->colliderItem); - - if (LINK_IS_ADULT && Flags_GetSwitch(globalCtx, this->switchFlag)) { - if (!(gSaveContext.eventChkInf[6] & 0x200)) { - thisx->home.pos.y = thisx->world.pos.y = WATER_LEVEL_LOWERED; - } else { - thisx->home.pos.y = thisx->world.pos.y = WATER_LEVEL_RAISED; - } - - this->actionFunc = BgSpot06Objects_LockFloat; - thisx->world.pos.z -= 100.0f; - thisx->home.pos.z = thisx->world.pos.z + 16.0f; - this->collider.elements[0].dim.worldSphere.radius = - this->collider.elements[0].dim.modelSphere.radius * 2; - this->collider.elements[0].dim.worldSphere.center.z = thisx->world.pos.z + 16.0f; - } else { - this->actionFunc = BgSpot06Objects_LockWait; - this->collider.elements[0].dim.worldSphere.radius = this->collider.elements[0].dim.modelSphere.radius; - this->collider.elements[0].dim.worldSphere.center.z = thisx->world.pos.z; - } - - this->collider.elements[0].dim.worldSphere.center.x = thisx->world.pos.x; - this->collider.elements[0].dim.worldSphere.center.y = thisx->world.pos.y; - thisx->colChkInfo.mass = MASS_IMMOVABLE; - break; - case LHO_WATER_PLANE: - Actor_ProcessInitChain(thisx, sInitChainWaterPlane); - thisx->flags = ACTOR_FLAG_4 | ACTOR_FLAG_5; - - if (LINK_IS_ADULT && !(gSaveContext.eventChkInf[6] & 0x200)) { - if (gSaveContext.sceneSetupIndex < 4) { - this->lakeHyliaWaterLevel = -681.0f; - globalCtx->colCtx.colHeader->waterBoxes[LHWB_GERUDO_VALLEY_RIVER_LOWER].ySurface = - WATER_LEVEL_RIVER_LOWERED; - globalCtx->colCtx.colHeader->waterBoxes[LHWB_GERUDO_VALLEY_RIVER_LOWER].zMin -= 50; - globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_1].ySurface = WATER_LEVEL_LOWERED; - globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_2].ySurface = WATER_LEVEL_LOWERED; - this->actionFunc = BgSpot06Objects_DoNothing; - } else { - thisx->world.pos.y = this->lakeHyliaWaterLevel = -681.0f; - thisx->world.pos.y += WATER_LEVEL_RAISED; - this->actionFunc = BgSpot06Objects_WaterPlaneCutsceneWait; - } - } else { - this->lakeHyliaWaterLevel = 0.0f; - this->actionFunc = BgSpot06Objects_DoNothing; - } - break; - case LHO_ICE_BLOCK: - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gLakeHyliaZoraShortcutIceblockCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - this->actionFunc = BgSpot06Objects_DoNothing; - - if (!LINK_IS_ADULT) { - Actor_Kill(thisx); - } - break; - } -} - -void BgSpot06Objects_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot06Objects* this = (BgSpot06Objects*)thisx; - - switch (this->dyna.actor.params) { - case LHO_WATER_TEMPLE_ENTRACE_GATE: - case LHO_ICE_BLOCK: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - break; - case LHO_WATER_TEMPLE_ENTRANCE_LOCK: - Collider_DestroyJntSph(globalCtx, &this->collider); - break; - case LHO_WATER_PLANE: - break; - } -} - -/** - * Water Temple entrance gate effect functions - */ -void BgSpot06Objects_GateSpawnBubbles(BgSpot06Objects* this, GlobalContext* globalCtx) { - Vec3f sp34; - f32 tmp; - - if ((globalCtx->gameplayFrames % 3) == 0) { - tmp = Rand_CenteredFloat(160.0f); - sp34.x = (Math_SinS(this->dyna.actor.shape.rot.y + 0x4000) * tmp) + this->dyna.actor.world.pos.x; - sp34.y = this->dyna.actor.world.pos.y; - sp34.z = (Math_CosS(this->dyna.actor.shape.rot.y + 0x4000) * tmp) + this->dyna.actor.world.pos.z; - EffectSsBubble_Spawn(globalCtx, &sp34, 50.0f, 70.0f, 10.0f, (Rand_ZeroOne() * 0.05f) + 0.175f); - } -} - -/** - * This is where the gate waits for the switch to be set by the fish shaped lock. - */ -void BgSpot06Objects_GateWaitForSwitch(BgSpot06Objects* this, GlobalContext* globalCtx) { - s32 i; - - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->timer = 100; - this->dyna.actor.world.pos.y += 3.0f; - this->actionFunc = BgSpot06Objects_GateWaitToOpen; - - for (i = 0; i < 15; i++) { - BgSpot06Objects_GateSpawnBubbles(this, globalCtx); - } - } -} - -/** - * This is where the gate waits a few frames before rising after the switch is set. - */ -void BgSpot06Objects_GateWaitToOpen(BgSpot06Objects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - this->actionFunc = BgSpot06Objects_GateOpen; - } -} - -/** - * This is where the gate finally rises upward. - */ -void BgSpot06Objects_GateOpen(BgSpot06Objects* this, GlobalContext* globalCtx) { - BgSpot06Objects_GateSpawnBubbles(this, globalCtx); - - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, 0.6f)) { - this->actionFunc = BgSpot06Objects_DoNothing; - this->timer = 0; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); - } -} - -void BgSpot06Objects_DoNothing(BgSpot06Objects* this, GlobalContext* globalCtx) { -} - -/** - * Fish shaped lock effect functions - */ -void BgSpot06Objects_LockSpawnWaterRipples(BgSpot06Objects* this, GlobalContext* globalCtx, s32 flag) { - if (flag || !(globalCtx->gameplayFrames % 7)) { - EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.home.pos, 300, 700, 0); - } -} - -void BgSpot06Objects_LockSpawnBubbles(BgSpot06Objects* this, GlobalContext* globalCtx, s32 flag) { - if (!(globalCtx->gameplayFrames % 7) || flag) { - EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 0.0f, 40.0f, 30.0f, - (Rand_ZeroOne() * 0.05f) + 0.175f); - } -} - -/** - * This is where the fish shaped lock waits to be pulled out by the hookshot. Once it does it will spawn bubbles. - */ -void BgSpot06Objects_LockWait(BgSpot06Objects* this, GlobalContext* globalCtx) { - s32 pad; - s32 i; - s32 pad2; - Vec3f effectPos; - f32 sin; - f32 cos; - - if (this->collider.base.acFlags & 2) { - this->timer = 130; - this->dyna.actor.flags |= ACTOR_FLAG_4; - sin = Math_SinS(this->dyna.actor.world.rot.y); - cos = Math_CosS(this->dyna.actor.world.rot.y); - this->dyna.actor.world.pos.x += (3.0f * sin); - this->dyna.actor.world.pos.z += (3.0f * cos); - - for (i = 0; i < 20; i++) { - BgSpot06Objects_LockSpawnBubbles(this, globalCtx, 1); - } - - effectPos.x = this->dyna.actor.world.pos.x + (5.0f * sin); - effectPos.y = this->dyna.actor.world.pos.y; - effectPos.z = this->dyna.actor.world.pos.z + (5.0f * cos); - - for (i = 0; i < 3; i++) { - EffectSsBubble_Spawn(globalCtx, &effectPos, 0.0f, 20.0f, 20.0f, (Rand_ZeroOne() * 0.1f) + 0.7f); - } - - EffectSsGSplash_Spawn(globalCtx, &this->dyna.actor.world.pos, NULL, NULL, 1, 700); - this->collider.elements->dim.worldSphere.radius = 45; - this->actionFunc = BgSpot06Objects_LockPullOutward; - Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Flags_SetSwitch(globalCtx, this->switchFlag); - OnePointCutscene_Init(globalCtx, 4120, 170, &this->dyna.actor, MAIN_CAM); - } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -/** - * Once the fish shaped lock is pulled out from the Hookshot it will move outward. - */ -void BgSpot06Objects_LockPullOutward(BgSpot06Objects* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - this->dyna.actor.world.pos.x += (0.3f * Math_SinS(this->dyna.actor.world.rot.y)); - this->dyna.actor.world.pos.z += (0.3f * Math_CosS(this->dyna.actor.world.rot.y)); - BgSpot06Objects_LockSpawnBubbles(this, globalCtx, 0); - - if (this->timer == 0) { - this->dyna.actor.velocity.y = 0.5f; - this->dyna.actor.flags &= ~ACTOR_FLAG_13; - - this->actionFunc = BgSpot06Objects_LockSwimToSurface; - } -} - -/** - * After being pulled all the way out the fish shaped lock will rise to the surface, creating bubbles in the water as it - * does so. - */ -void BgSpot06Objects_LockSwimToSurface(BgSpot06Objects* this, GlobalContext* globalCtx) { - f32 cos; - f32 pad; - - this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; - - if (this->dyna.actor.velocity.y <= 0.0f) { - cos = Math_CosS(this->dyna.actor.shape.rot.x) * 4.3f; - this->dyna.actor.world.pos.x += (cos * Math_SinS(this->dyna.actor.shape.rot.y)); - this->dyna.actor.world.pos.z += (cos * Math_CosS(this->dyna.actor.shape.rot.y)); - this->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y - 1.3f; - BgSpot06Objects_LockSpawnWaterRipples(this, globalCtx, 0); - - if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, 0, 0x260) != 0) { - this->dyna.actor.home.pos.x = - this->dyna.actor.world.pos.x - (Math_SinS(this->dyna.actor.shape.rot.y) * 16.0f); - this->dyna.actor.home.pos.z = - this->dyna.actor.world.pos.z - (Math_CosS(this->dyna.actor.shape.rot.y) * 16.0f); - this->dyna.actor.world.pos.y = -1993.0f; - this->timer = 32; - this->dyna.actor.flags &= ~ACTOR_FLAG_4; - this->collider.elements[0].dim.worldSphere.radius = this->collider.elements[0].dim.modelSphere.radius * 2; - this->actionFunc = BgSpot06Objects_LockFloat; - } - } else { - if (this->dyna.actor.world.pos.y >= -1973.0f) { - this->dyna.actor.velocity.y = 0.0f; - BgSpot06Objects_LockSpawnWaterRipples(this, globalCtx, 1); - EffectSsGSplash_Spawn(globalCtx, &this->dyna.actor.home.pos, NULL, NULL, 1, 700); - } else if (this->dyna.actor.shape.rot.x == -0x4000) { - this->dyna.actor.velocity.y += 0.02f; - this->dyna.actor.world.pos.x = Rand_CenteredFloat(1.0f) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = Rand_CenteredFloat(1.0f) + this->dyna.actor.home.pos.z; - this->dyna.actor.velocity.y = - (this->dyna.actor.velocity.y > 10.0f) ? (10.0f) : (this->dyna.actor.velocity.y); - BgSpot06Objects_LockSpawnBubbles(this, globalCtx, 0); - } else { - BgSpot06Objects_LockSpawnBubbles(this, globalCtx, 0); - - if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, -0x4000, 0x30)) { - this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; - this->dyna.actor.home.pos.y = -1993.0f; - this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; - } - } - } -} - -/** - * Once the fish shaped lock finishes rising to the surface it will float and create ripples in the water every few - * frames. - */ -void BgSpot06Objects_LockFloat(BgSpot06Objects* this, GlobalContext* globalCtx) { - BgSpot06Objects_LockSpawnWaterRipples(this, globalCtx, 0); - - if (this->timer != 0) { - this->timer--; - } - - this->dyna.actor.world.pos.y = (2.0f * sinf(this->timer * (M_PI / 16.0f))) + this->dyna.actor.home.pos.y; - - if (this->timer == 0) { - this->timer = 32; - } -} - -void BgSpot06Objects_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot06Objects* this = (BgSpot06Objects*)thisx; - - this->actionFunc(this, globalCtx); - - if (thisx->params == LHO_WATER_TEMPLE_ENTRANCE_LOCK) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -/** - * Draw the Lake Hylia water plane, and scroll its texture - */ -void BgSpot06Objects_DrawLakeHyliaWater(BgSpot06Objects* this, GlobalContext* globalCtx) { - s32 pad; - s32 gameplayFrames; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot06_objects.c", 844); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot06_objects.c", 850), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gameplayFrames = globalCtx->state.frames; - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -gameplayFrames, gameplayFrames, 32, 32, 1, gameplayFrames, - gameplayFrames, 32, 32)); - gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -gameplayFrames, gameplayFrames * 6, 32, 32, 1, - gameplayFrames, gameplayFrames * 6, 32, 32)); - - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); - - if ((this->lakeHyliaWaterLevel < -680.0f) && (gSaveContext.sceneSetupIndex < 4)) { - gSPDisplayList(POLY_XLU_DISP++, gLakeHyliaLowWaterDL); - } else { - gSPDisplayList(POLY_XLU_DISP++, gLakeHyliaHighWaterDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot06_objects.c", 879); -} - -void BgSpot06Objects_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot06Objects* this = (BgSpot06Objects*)thisx; - - switch (this->dyna.actor.params) { - case LHO_WATER_TEMPLE_ENTRACE_GATE: - Gfx_DrawDListOpa(globalCtx, gLakeHyliaWaterTempleGateDL); - break; - case LHO_WATER_TEMPLE_ENTRANCE_LOCK: - Gfx_DrawDListOpa(globalCtx, gLakeHyliaWaterTempleKeyDL); - - if (this->actionFunc == BgSpot06Objects_LockSwimToSurface) { - Collider_UpdateSpheres(1, &this->collider); - } - break; - case LHO_WATER_PLANE: - BgSpot06Objects_DrawLakeHyliaWater(this, globalCtx); - break; - case LHO_ICE_BLOCK: - Gfx_DrawDListOpa(globalCtx, gLakeHyliaZoraShortcutIceblockDL); - break; - } -} - -/** - * This is where the Lake Hylia water plane waits for the cutscene to set the water risen flag after the Water Temple is - * cleared. - */ -void BgSpot06Objects_WaterPlaneCutsceneWait(BgSpot06Objects* this, GlobalContext* globalCtx) { - if (gSaveContext.eventChkInf[6] & 0x200) { - this->actionFunc = BgSpot06Objects_WaterPlaneCutsceneRise; - } -} - -/** - * This is where the Lake Hylia water plane rises in the cutscene after the Water Temple is cleared. - */ -void BgSpot06Objects_WaterPlaneCutsceneRise(BgSpot06Objects* this, GlobalContext* globalCtx) { - s32 pad; - - this->dyna.actor.world.pos.y = this->lakeHyliaWaterLevel + WATER_LEVEL_RAISED; - - if (this->lakeHyliaWaterLevel >= 0.0001f) { - this->dyna.actor.world.pos.y = WATER_LEVEL_RAISED; - this->actionFunc = BgSpot06Objects_DoNothing; - } else { - Math_SmoothStepToF(&this->lakeHyliaWaterLevel, 1.0f, 0.1f, 1.0f, 0.001f); - globalCtx->colCtx.colHeader->waterBoxes[LHWB_GERUDO_VALLEY_RIVER_LOWER].ySurface = WATER_LEVEL_RIVER_LOWERED; - globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_1].ySurface = this->dyna.actor.world.pos.y; - globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_2].ySurface = this->dyna.actor.world.pos.y; - } - - func_8002F948(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); -} diff --git a/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.cpp b/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.cpp new file mode 100644 index 000000000..b2a27b984 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.cpp @@ -0,0 +1,525 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT06_OBJECTS_Z_BG_SPOT06_OBJECTS_C +#include "actor_common.h" +/* + * File: z_bg_spot06_objects.c + * Overlay: ovl_Bg_Spot06_Objects + * Description: Lake Hylia Objects + */ + +#include "z_bg_spot06_objects.h" +#include "objects/object_spot06_objects/object_spot06_objects.h" +#include "def/code_80043480.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_9 + +typedef enum { + /* 0x0 */ LHO_WATER_TEMPLE_ENTRACE_GATE, + /* 0x1 */ LHO_WATER_TEMPLE_ENTRANCE_LOCK, + /* 0x2 */ LHO_WATER_PLANE, + /* 0x3 */ LHO_ICE_BLOCK +} LakeHyliaObjectsType; + +typedef enum { + /* 0x0 */ LHWB_GERUDO_VALLEY_RIVER_UPPER, // entrance from Gerudo Valley + /* 0x1 */ LHWB_GERUDO_VALLEY_RIVER_LOWER, // river flowing from Gerudo Valley + /* 0x2 */ LHWB_MAIN_1, // main water box + /* 0x3 */ LHWB_MAIN_2 // extension of main water box +} LakeHyliaWaterBoxIndices; + +// Lake Hylia water plane levels +#define WATER_LEVEL_RAISED (-1313) +#define WATER_LEVEL_RIVER_RAISED (WATER_LEVEL_RAISED + 200) +#define WATER_LEVEL_LOWERED (WATER_LEVEL_RAISED - 680) +#define WATER_LEVEL_RIVER_LOWERED (WATER_LEVEL_RIVER_RAISED - 80) + +void BgSpot06Objects_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot06Objects_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot06Objects_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot06Objects_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgSpot06Objects_GateWaitForSwitch(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_GateWaitToOpen(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_GateOpen(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_DoNothing(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_LockWait(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_LockPullOutward(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_LockSwimToSurface(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_LockFloat(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_WaterPlaneCutsceneWait(BgSpot06Objects* pthis, GlobalContext* globalCtx); +void BgSpot06Objects_WaterPlaneCutsceneRise(BgSpot06Objects* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Spot06_Objects_InitVars = { + ACTOR_BG_SPOT06_OBJECTS, + ACTORCAT_PROP, + FLAGS, + OBJECT_SPOT06_OBJECTS, + sizeof(BgSpot06Objects), + (ActorFunc)BgSpot06Objects_Init, + (ActorFunc)BgSpot06Objects_Destroy, + (ActorFunc)BgSpot06Objects_Update, + (ActorFunc)BgSpot06Objects_Draw, +}; + +static ColliderJntSphElementInit sJntSphItemsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000080, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 1, { { 0, 0, -160 }, 18 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphItemsInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +static InitChainEntry sInitChainWaterPlane[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; + +void BgSpot06Objects_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpot06Objects* pthis = (BgSpot06Objects*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + pthis->switchFlag = thisx->params & 0xFF; + thisx->params = (thisx->params >> 8) & 0xFF; + + osSyncPrintf("spot06 obj nthisx->arg_data=[%d]", thisx->params); + + switch (thisx->params) { + case LHO_WATER_TEMPLE_ENTRACE_GATE: + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gLakeHyliaWaterTempleGateCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + + if (LINK_IS_ADULT && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + thisx->world.pos.y = thisx->home.pos.y + 120.0f; + pthis->actionFunc = BgSpot06Objects_DoNothing; + + } else { + pthis->actionFunc = BgSpot06Objects_GateWaitForSwitch; + } + + break; + case LHO_WATER_TEMPLE_ENTRANCE_LOCK: + Actor_ProcessInitChain(thisx, sInitChain); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, thisx, &sJntSphInit, pthis->colliderItem); + + if (LINK_IS_ADULT && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if (!(gSaveContext.eventChkInf[6] & 0x200)) { + thisx->home.pos.y = thisx->world.pos.y = WATER_LEVEL_LOWERED; + } else { + thisx->home.pos.y = thisx->world.pos.y = WATER_LEVEL_RAISED; + } + + pthis->actionFunc = BgSpot06Objects_LockFloat; + thisx->world.pos.z -= 100.0f; + thisx->home.pos.z = thisx->world.pos.z + 16.0f; + pthis->collider.elements[0].dim.worldSphere.radius = + pthis->collider.elements[0].dim.modelSphere.radius * 2; + pthis->collider.elements[0].dim.worldSphere.center.z = thisx->world.pos.z + 16.0f; + } else { + pthis->actionFunc = BgSpot06Objects_LockWait; + pthis->collider.elements[0].dim.worldSphere.radius = pthis->collider.elements[0].dim.modelSphere.radius; + pthis->collider.elements[0].dim.worldSphere.center.z = thisx->world.pos.z; + } + + pthis->collider.elements[0].dim.worldSphere.center.x = thisx->world.pos.x; + pthis->collider.elements[0].dim.worldSphere.center.y = thisx->world.pos.y; + thisx->colChkInfo.mass = MASS_IMMOVABLE; + break; + case LHO_WATER_PLANE: + Actor_ProcessInitChain(thisx, sInitChainWaterPlane); + thisx->flags = ACTOR_FLAG_4 | ACTOR_FLAG_5; + + if (LINK_IS_ADULT && !(gSaveContext.eventChkInf[6] & 0x200)) { + if (gSaveContext.sceneSetupIndex < 4) { + pthis->lakeHyliaWaterLevel = -681.0f; + globalCtx->colCtx.colHeader->waterBoxes[LHWB_GERUDO_VALLEY_RIVER_LOWER].ySurface = + WATER_LEVEL_RIVER_LOWERED; + globalCtx->colCtx.colHeader->waterBoxes[LHWB_GERUDO_VALLEY_RIVER_LOWER].zMin -= 50; + globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_1].ySurface = WATER_LEVEL_LOWERED; + globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_2].ySurface = WATER_LEVEL_LOWERED; + pthis->actionFunc = BgSpot06Objects_DoNothing; + } else { + thisx->world.pos.y = pthis->lakeHyliaWaterLevel = -681.0f; + thisx->world.pos.y += WATER_LEVEL_RAISED; + pthis->actionFunc = BgSpot06Objects_WaterPlaneCutsceneWait; + } + } else { + pthis->lakeHyliaWaterLevel = 0.0f; + pthis->actionFunc = BgSpot06Objects_DoNothing; + } + break; + case LHO_ICE_BLOCK: + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gLakeHyliaZoraShortcutIceblockCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->actionFunc = BgSpot06Objects_DoNothing; + + if (!LINK_IS_ADULT) { + Actor_Kill(thisx); + } + break; + } +} + +void BgSpot06Objects_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot06Objects* pthis = (BgSpot06Objects*)thisx; + + switch (pthis->dyna.actor.params) { + case LHO_WATER_TEMPLE_ENTRACE_GATE: + case LHO_ICE_BLOCK: + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + break; + case LHO_WATER_TEMPLE_ENTRANCE_LOCK: + Collider_DestroyJntSph(globalCtx, &pthis->collider); + break; + case LHO_WATER_PLANE: + break; + } +} + +/** + * Water Temple entrance gate effect functions + */ +void BgSpot06Objects_GateSpawnBubbles(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + Vec3f sp34; + f32 tmp; + + if ((globalCtx->gameplayFrames % 3) == 0) { + tmp = Rand_CenteredFloat(160.0f); + sp34.x = (Math_SinS(pthis->dyna.actor.shape.rot.y + 0x4000) * tmp) + pthis->dyna.actor.world.pos.x; + sp34.y = pthis->dyna.actor.world.pos.y; + sp34.z = (Math_CosS(pthis->dyna.actor.shape.rot.y + 0x4000) * tmp) + pthis->dyna.actor.world.pos.z; + EffectSsBubble_Spawn(globalCtx, &sp34, 50.0f, 70.0f, 10.0f, (Rand_ZeroOne() * 0.05f) + 0.175f); + } +} + +/** + * This is where the gate waits for the switch to be set by the fish shaped lock. + */ +void BgSpot06Objects_GateWaitForSwitch(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + s32 i; + + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->timer = 100; + pthis->dyna.actor.world.pos.y += 3.0f; + pthis->actionFunc = BgSpot06Objects_GateWaitToOpen; + + for (i = 0; i < 15; i++) { + BgSpot06Objects_GateSpawnBubbles(pthis, globalCtx); + } + } +} + +/** + * This is where the gate waits a few frames before rising after the switch is set. + */ +void BgSpot06Objects_GateWaitToOpen(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + pthis->actionFunc = BgSpot06Objects_GateOpen; + } +} + +/** + * This is where the gate finally rises upward. + */ +void BgSpot06Objects_GateOpen(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + BgSpot06Objects_GateSpawnBubbles(pthis, globalCtx); + + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 120.0f, 0.6f)) { + pthis->actionFunc = BgSpot06Objects_DoNothing; + pthis->timer = 0; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_STOP); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); + } +} + +void BgSpot06Objects_DoNothing(BgSpot06Objects* pthis, GlobalContext* globalCtx) { +} + +/** + * Fish shaped lock effect functions + */ +void BgSpot06Objects_LockSpawnWaterRipples(BgSpot06Objects* pthis, GlobalContext* globalCtx, s32 flag) { + if (flag || !(globalCtx->gameplayFrames % 7)) { + EffectSsGRipple_Spawn(globalCtx, &pthis->dyna.actor.home.pos, 300, 700, 0); + } +} + +void BgSpot06Objects_LockSpawnBubbles(BgSpot06Objects* pthis, GlobalContext* globalCtx, s32 flag) { + if (!(globalCtx->gameplayFrames % 7) || flag) { + EffectSsBubble_Spawn(globalCtx, &pthis->dyna.actor.world.pos, 0.0f, 40.0f, 30.0f, + (Rand_ZeroOne() * 0.05f) + 0.175f); + } +} + +/** + * This is where the fish shaped lock waits to be pulled out by the hookshot. Once it does it will spawn bubbles. + */ +void BgSpot06Objects_LockWait(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 i; + s32 pad2; + Vec3f effectPos; + f32 sin; + f32 cos; + + if (pthis->collider.base.acFlags & 2) { + pthis->timer = 130; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + sin = Math_SinS(pthis->dyna.actor.world.rot.y); + cos = Math_CosS(pthis->dyna.actor.world.rot.y); + pthis->dyna.actor.world.pos.x += (3.0f * sin); + pthis->dyna.actor.world.pos.z += (3.0f * cos); + + for (i = 0; i < 20; i++) { + BgSpot06Objects_LockSpawnBubbles(pthis, globalCtx, 1); + } + + effectPos.x = pthis->dyna.actor.world.pos.x + (5.0f * sin); + effectPos.y = pthis->dyna.actor.world.pos.y; + effectPos.z = pthis->dyna.actor.world.pos.z + (5.0f * cos); + + for (i = 0; i < 3; i++) { + EffectSsBubble_Spawn(globalCtx, &effectPos, 0.0f, 20.0f, 20.0f, (Rand_ZeroOne() * 0.1f) + 0.7f); + } + + EffectSsGSplash_Spawn(globalCtx, &pthis->dyna.actor.world.pos, NULL, NULL, 1, 700); + pthis->collider.elements->dim.worldSphere.radius = 45; + pthis->actionFunc = BgSpot06Objects_LockPullOutward; + Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Flags_SetSwitch(globalCtx, pthis->switchFlag); + OnePointCutscene_Init(globalCtx, 4120, 170, &pthis->dyna.actor, MAIN_CAM); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +/** + * Once the fish shaped lock is pulled out from the Hookshot it will move outward. + */ +void BgSpot06Objects_LockPullOutward(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->dyna.actor.world.pos.x += (0.3f * Math_SinS(pthis->dyna.actor.world.rot.y)); + pthis->dyna.actor.world.pos.z += (0.3f * Math_CosS(pthis->dyna.actor.world.rot.y)); + BgSpot06Objects_LockSpawnBubbles(pthis, globalCtx, 0); + + if (pthis->timer == 0) { + pthis->dyna.actor.velocity.y = 0.5f; + pthis->dyna.actor.flags &= ~ACTOR_FLAG_13; + + pthis->actionFunc = BgSpot06Objects_LockSwimToSurface; + } +} + +/** + * After being pulled all the way out the fish shaped lock will rise to the surface, creating bubbles in the water as it + * does so. + */ +void BgSpot06Objects_LockSwimToSurface(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + f32 cos; + f32 pad; + + pthis->dyna.actor.world.pos.y += pthis->dyna.actor.velocity.y; + + if (pthis->dyna.actor.velocity.y <= 0.0f) { + cos = Math_CosS(pthis->dyna.actor.shape.rot.x) * 4.3f; + pthis->dyna.actor.world.pos.x += (cos * Math_SinS(pthis->dyna.actor.shape.rot.y)); + pthis->dyna.actor.world.pos.z += (cos * Math_CosS(pthis->dyna.actor.shape.rot.y)); + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.world.pos.y - 1.3f; + BgSpot06Objects_LockSpawnWaterRipples(pthis, globalCtx, 0); + + if (Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.x, 0, 0x260) != 0) { + pthis->dyna.actor.home.pos.x = + pthis->dyna.actor.world.pos.x - (Math_SinS(pthis->dyna.actor.shape.rot.y) * 16.0f); + pthis->dyna.actor.home.pos.z = + pthis->dyna.actor.world.pos.z - (Math_CosS(pthis->dyna.actor.shape.rot.y) * 16.0f); + pthis->dyna.actor.world.pos.y = -1993.0f; + pthis->timer = 32; + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; + pthis->collider.elements[0].dim.worldSphere.radius = pthis->collider.elements[0].dim.modelSphere.radius * 2; + pthis->actionFunc = BgSpot06Objects_LockFloat; + } + } else { + if (pthis->dyna.actor.world.pos.y >= -1973.0f) { + pthis->dyna.actor.velocity.y = 0.0f; + BgSpot06Objects_LockSpawnWaterRipples(pthis, globalCtx, 1); + EffectSsGSplash_Spawn(globalCtx, &pthis->dyna.actor.home.pos, NULL, NULL, 1, 700); + } else if (pthis->dyna.actor.shape.rot.x == -0x4000) { + pthis->dyna.actor.velocity.y += 0.02f; + pthis->dyna.actor.world.pos.x = Rand_CenteredFloat(1.0f) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = Rand_CenteredFloat(1.0f) + pthis->dyna.actor.home.pos.z; + pthis->dyna.actor.velocity.y = + (pthis->dyna.actor.velocity.y > 10.0f) ? (10.0f) : (pthis->dyna.actor.velocity.y); + BgSpot06Objects_LockSpawnBubbles(pthis, globalCtx, 0); + } else { + BgSpot06Objects_LockSpawnBubbles(pthis, globalCtx, 0); + + if (Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.x, -0x4000, 0x30)) { + pthis->dyna.actor.home.pos.x = pthis->dyna.actor.world.pos.x; + pthis->dyna.actor.home.pos.y = -1993.0f; + pthis->dyna.actor.home.pos.z = pthis->dyna.actor.world.pos.z; + } + } + } +} + +/** + * Once the fish shaped lock finishes rising to the surface it will float and create ripples in the water every few + * frames. + */ +void BgSpot06Objects_LockFloat(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + BgSpot06Objects_LockSpawnWaterRipples(pthis, globalCtx, 0); + + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->dyna.actor.world.pos.y = (2.0f * sinf(pthis->timer * (M_PI / 16.0f))) + pthis->dyna.actor.home.pos.y; + + if (pthis->timer == 0) { + pthis->timer = 32; + } +} + +void BgSpot06Objects_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot06Objects* pthis = (BgSpot06Objects*)thisx; + + pthis->actionFunc(pthis, globalCtx); + + if (thisx->params == LHO_WATER_TEMPLE_ENTRANCE_LOCK) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +/** + * Draw the Lake Hylia water plane, and scroll its texture + */ +void BgSpot06Objects_DrawLakeHyliaWater(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 gameplayFrames; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot06_objects.c", 844); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot06_objects.c", 850), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gameplayFrames = globalCtx->state.frames; + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -gameplayFrames, gameplayFrames, 32, 32, 1, gameplayFrames, + gameplayFrames, 32, 32)); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -gameplayFrames, gameplayFrames * 6, 32, 32, 1, + gameplayFrames, gameplayFrames * 6, 32, 32)); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); + + if ((pthis->lakeHyliaWaterLevel < -680.0f) && (gSaveContext.sceneSetupIndex < 4)) { + gSPDisplayList(POLY_XLU_DISP++, gLakeHyliaLowWaterDL); + } else { + gSPDisplayList(POLY_XLU_DISP++, gLakeHyliaHighWaterDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot06_objects.c", 879); +} + +void BgSpot06Objects_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgSpot06Objects* pthis = (BgSpot06Objects*)thisx; + + switch (pthis->dyna.actor.params) { + case LHO_WATER_TEMPLE_ENTRACE_GATE: + Gfx_DrawDListOpa(globalCtx, gLakeHyliaWaterTempleGateDL); + break; + case LHO_WATER_TEMPLE_ENTRANCE_LOCK: + Gfx_DrawDListOpa(globalCtx, gLakeHyliaWaterTempleKeyDL); + + if (pthis->actionFunc == BgSpot06Objects_LockSwimToSurface) { + Collider_UpdateSpheres(1, &pthis->collider); + } + break; + case LHO_WATER_PLANE: + BgSpot06Objects_DrawLakeHyliaWater(pthis, globalCtx); + break; + case LHO_ICE_BLOCK: + Gfx_DrawDListOpa(globalCtx, gLakeHyliaZoraShortcutIceblockDL); + break; + } +} + +/** + * This is where the Lake Hylia water plane waits for the cutscene to set the water risen flag after the Water Temple is + * cleared. + */ +void BgSpot06Objects_WaterPlaneCutsceneWait(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + if (gSaveContext.eventChkInf[6] & 0x200) { + pthis->actionFunc = BgSpot06Objects_WaterPlaneCutsceneRise; + } +} + +/** + * This is where the Lake Hylia water plane rises in the cutscene after the Water Temple is cleared. + */ +void BgSpot06Objects_WaterPlaneCutsceneRise(BgSpot06Objects* pthis, GlobalContext* globalCtx) { + s32 pad; + + pthis->dyna.actor.world.pos.y = pthis->lakeHyliaWaterLevel + WATER_LEVEL_RAISED; + + if (pthis->lakeHyliaWaterLevel >= 0.0001f) { + pthis->dyna.actor.world.pos.y = WATER_LEVEL_RAISED; + pthis->actionFunc = BgSpot06Objects_DoNothing; + } else { + Math_SmoothStepToF(&pthis->lakeHyliaWaterLevel, 1.0f, 0.1f, 1.0f, 0.001f); + globalCtx->colCtx.colHeader->waterBoxes[LHWB_GERUDO_VALLEY_RIVER_LOWER].ySurface = WATER_LEVEL_RIVER_LOWERED; + globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_1].ySurface = pthis->dyna.actor.world.pos.y; + globalCtx->colCtx.colHeader->waterBoxes[LHWB_MAIN_2].ySurface = pthis->dyna.actor.world.pos.y; + } + + func_8002F948(&pthis->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); +} diff --git a/src/overlays/actors/ovl_Bg_Spot07_Taki/z_bg_spot07_taki.c b/src/overlays/actors/ovl_Bg_Spot07_Taki/z_bg_spot07_taki.cpp similarity index 81% rename from src/overlays/actors/ovl_Bg_Spot07_Taki/z_bg_spot07_taki.c rename to src/overlays/actors/ovl_Bg_Spot07_Taki/z_bg_spot07_taki.cpp index f931b9912..5adbfff14 100644 --- a/src/overlays/actors/ovl_Bg_Spot07_Taki/z_bg_spot07_taki.c +++ b/src/overlays/actors/ovl_Bg_Spot07_Taki/z_bg_spot07_taki.cpp @@ -21,9 +21,9 @@ void BgSpot07Taki_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot07Taki_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot07Taki_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgSpot07Taki_DoNothing(BgSpot07Taki* this, GlobalContext* globalCtx); +void BgSpot07Taki_DoNothing(BgSpot07Taki* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot07_Taki_InitVars = { +ActorInit Bg_Spot07_Taki_InitVars = { ACTOR_BG_SPOT07_TAKI, ACTORCAT_BG, FLAGS, @@ -40,40 +40,40 @@ static InitChainEntry sInitChain[] = { }; void BgSpot07Taki_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot07Taki* this = (BgSpot07Taki*)thisx; + BgSpot07Taki* pthis = (BgSpot07Taki*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); if (LINK_IS_ADULT) { - if (this->dyna.actor.params == 0) { + if (pthis->dyna.actor.params == 0) { CollisionHeader_GetVirtual(&object_spot07_object_Col_002590, &colHeader); } else { CollisionHeader_GetVirtual(&object_spot07_object_Col_0038FC, &colHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } - this->actionFunc = BgSpot07Taki_DoNothing; + pthis->actionFunc = BgSpot07Taki_DoNothing; } void BgSpot07Taki_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot07Taki* this = (BgSpot07Taki*)thisx; + BgSpot07Taki* pthis = (BgSpot07Taki*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void BgSpot07Taki_DoNothing(BgSpot07Taki* this, GlobalContext* globalCtx) { +void BgSpot07Taki_DoNothing(BgSpot07Taki* pthis, GlobalContext* globalCtx) { } void BgSpot07Taki_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot07Taki* this = (BgSpot07Taki*)thisx; + BgSpot07Taki* pthis = (BgSpot07Taki*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot07Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot07Taki* this = (BgSpot07Taki*)thisx; + BgSpot07Taki* pthis = (BgSpot07Taki*)thisx; u32 frames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot07_taki.c", 169); @@ -82,7 +82,7 @@ void BgSpot07Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot07_taki.c", 177), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->dyna.actor.params == 0) { + if (pthis->dyna.actor.params == 0) { gSPDisplayList(POLY_OPA_DISP++, object_spot07_object_DL_001CF0); } else { gSPDisplayList(POLY_OPA_DISP++, object_spot07_object_DL_003210); @@ -99,7 +99,7 @@ void BgSpot07Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!LINK_IS_ADULT) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); - if (this->dyna.actor.params == 0) { + if (pthis->dyna.actor.params == 0) { gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, ((frames * -1) & 0x7F), ((frames * -3) & 0xFF), 64, 64, 1, ((frames * 1) & 0x7F), ((frames * -3) & 0xFF), 64, 64)); @@ -116,7 +116,7 @@ void BgSpot07Taki_Draw(Actor* thisx, GlobalContext* globalCtx) { frames * 0, ((frames * 3) & 0x1FF), 32, 128)); gSPDisplayList(POLY_XLU_DISP++, object_spot07_object_DL_000BE0); } - } else if (this->dyna.actor.params == 0) { + } else if (pthis->dyna.actor.params == 0) { gSPDisplayList(POLY_XLU_DISP++, object_spot07_object_DL_001F68); } else { gSPDisplayList(POLY_XLU_DISP++, object_spot07_object_DL_0032D8); diff --git a/src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/z_bg_spot08_bakudankabe.c b/src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/z_bg_spot08_bakudankabe.cpp similarity index 65% rename from src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/z_bg_spot08_bakudankabe.c rename to src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/z_bg_spot08_bakudankabe.cpp index cb8f426a3..4541d3a1e 100644 --- a/src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/z_bg_spot08_bakudankabe.c +++ b/src/overlays/actors/ovl_Bg_Spot08_Bakudankabe/z_bg_spot08_bakudankabe.cpp @@ -27,10 +27,10 @@ void BgSpot08Bakudankabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot08Bakudankabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot08Bakudankabe_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B02D0(BgSpot08Bakudankabe* this, GlobalContext* globalCtx); -void func_808B0324(BgSpot08Bakudankabe* this, GlobalContext* globalCtx); +void func_808B02D0(BgSpot08Bakudankabe* pthis, GlobalContext* globalCtx); +void func_808B0324(BgSpot08Bakudankabe* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot08_Bakudankabe_InitVars = { +ActorInit Bg_Spot08_Bakudankabe_InitVars = { ACTOR_BG_SPOT08_BAKUDANKABE, ACTORCAT_BG, FLAGS, @@ -104,14 +104,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void func_808B02D0(BgSpot08Bakudankabe* this, GlobalContext* globalCtx) { +void func_808B02D0(BgSpot08Bakudankabe* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderItems); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->dyna.actor, &sJntSphInit, pthis->colliderItems); } -void func_808B0324(BgSpot08Bakudankabe* this, GlobalContext* globalCtx) { +void func_808B0324(BgSpot08Bakudankabe* pthis, GlobalContext* globalCtx) { s32 pad[2]; s32 i; Vec3f burstDepthY; @@ -119,8 +119,8 @@ void func_808B0324(BgSpot08Bakudankabe* this, GlobalContext* globalCtx) { f32 sinY; f32 cosY; - sinY = Math_SinS(this->dyna.actor.shape.rot.y); - cosY = Math_CosS(this->dyna.actor.shape.rot.y); + sinY = Math_SinS(pthis->dyna.actor.shape.rot.y); + cosY = Math_CosS(pthis->dyna.actor.shape.rot.y); burstDepthX.z = 0.0f; burstDepthX.x = 0.0f; @@ -134,9 +134,9 @@ void func_808B0324(BgSpot08Bakudankabe* this, GlobalContext* globalCtx) { temp1 = (Rand_ZeroOne() - 0.5f) * 440.0f; temp2 = (Rand_ZeroOne() - 0.5f) * 20.0f; - burstDepthY.x = this->dyna.actor.world.pos.x + temp2 * sinY + (temp1 * cosY); - burstDepthY.y = (this->dyna.actor.world.pos.y + 20.0f) + (i * (65.0f / 12.0f)); - burstDepthY.z = this->dyna.actor.world.pos.z + temp2 * cosY - (temp1 * sinY); + burstDepthY.x = pthis->dyna.actor.world.pos.x + temp2 * sinY + (temp1 * cosY); + burstDepthY.y = (pthis->dyna.actor.world.pos.y + 20.0f) + (i * (65.0f / 12.0f)); + burstDepthY.z = pthis->dyna.actor.world.pos.z + temp2 * cosY - (temp1 * sinY); burstDepthX.y = (Rand_ZeroOne() - 0.2f) * 12.0f; scale = Rand_ZeroOne() * 75.0f + 10.0f; @@ -160,55 +160,55 @@ void func_808B0324(BgSpot08Bakudankabe* this, GlobalContext* globalCtx) { } for (i = 0; i < ARRAY_COUNT(D_808B08AC); i++) { - burstDepthY.x = this->dyna.actor.world.pos.x + D_808B08AC[i].z * sinY + D_808B08AC[i].x * cosY; - burstDepthY.y = this->dyna.actor.world.pos.y + D_808B08AC[i].y; - burstDepthY.z = this->dyna.actor.world.pos.z + D_808B08AC[i].z * cosY - (D_808B08AC[i].x * sinY); + burstDepthY.x = pthis->dyna.actor.world.pos.x + D_808B08AC[i].z * sinY + D_808B08AC[i].x * cosY; + burstDepthY.y = pthis->dyna.actor.world.pos.y + D_808B08AC[i].y; + burstDepthY.z = pthis->dyna.actor.world.pos.z + D_808B08AC[i].z * cosY - (D_808B08AC[i].x * sinY); func_80033480(globalCtx, &burstDepthY, 120.0f, 4, 0x78, 0xA0, 1); } } void BgSpot08Bakudankabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Bakudankabe* this = (BgSpot08Bakudankabe*)thisx; + BgSpot08Bakudankabe* pthis = (BgSpot08Bakudankabe*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) { - Actor_Kill(&this->dyna.actor); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F))) { + Actor_Kill(&pthis->dyna.actor); return; } - func_808B02D0(this, globalCtx); + func_808B02D0(pthis, globalCtx); CollisionHeader_GetVirtual(&gZorasFountainBombableWallCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); } void BgSpot08Bakudankabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Bakudankabe* this = (BgSpot08Bakudankabe*)thisx; + BgSpot08Bakudankabe* pthis = (BgSpot08Bakudankabe*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } void BgSpot08Bakudankabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Bakudankabe* this = (BgSpot08Bakudankabe*)thisx; + BgSpot08Bakudankabe* pthis = (BgSpot08Bakudankabe*)thisx; - if (this->collider.base.acFlags & AC_HIT) { - func_808B0324(this, globalCtx); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params & 0x3F)); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + if (pthis->collider.base.acFlags & AC_HIT) { + func_808B0324(pthis, globalCtx); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F)); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); func_80078884(NA_SE_SY_CORRECT_CHIME); - Actor_Kill(&this->dyna.actor); - } else if (this->dyna.actor.xzDistToPlayer < 800.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_Kill(&pthis->dyna.actor); + } else if (pthis->dyna.actor.xzDistToPlayer < 800.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } void BgSpot08Bakudankabe_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Bakudankabe* this = (BgSpot08Bakudankabe*)thisx; + BgSpot08Bakudankabe* pthis = (BgSpot08Bakudankabe*)thisx; - Collider_UpdateSpheres(0, &this->collider); - Collider_UpdateSpheres(1, &this->collider); - Collider_UpdateSpheres(2, &this->collider); + Collider_UpdateSpheres(0, &pthis->collider); + Collider_UpdateSpheres(1, &pthis->collider); + Collider_UpdateSpheres(2, &pthis->collider); Gfx_DrawDListOpa(globalCtx, gZorasFountainBombableWallDL); } diff --git a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c deleted file mode 100644 index dd59d9ad4..000000000 --- a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c +++ /dev/null @@ -1,457 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT08_ICEBLOCK_Z_BG_SPOT08_ICEBLOCK_C -#include "actor_common.h" -/* - * File: z_bg_spot08_iceblock.c - * Overlay: ovl_Bg_Spot08_Iceblock - * Description: Floating ice platforms - */ - -#include "z_bg_spot08_iceblock.h" -#include "objects/object_spot08_obj/object_spot08_obj.h" -#include "def/code_80043480.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void BgSpot08Iceblock_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot08Iceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot08Iceblock_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot08Iceblock_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgSpot08Iceblock_SetupFloatNonrotating(BgSpot08Iceblock* this); -void BgSpot08Iceblock_FloatNonrotating(BgSpot08Iceblock* this, GlobalContext* globalCtx); -void BgSpot08Iceblock_SetupFloatRotating(BgSpot08Iceblock* this); -void BgSpot08Iceblock_FloatRotating(BgSpot08Iceblock* this, GlobalContext* globalCtx); -void BgSpot08Iceblock_SetupFloatOrbitingTwins(BgSpot08Iceblock* this); -void BgSpot08Iceblock_FloatOrbitingTwins(BgSpot08Iceblock* this, GlobalContext* globalCtx); -void BgSpot08Iceblock_SetupNoAction(BgSpot08Iceblock* this); - -const ActorInit Bg_Spot08_Iceblock_InitVars = { - ACTOR_BG_SPOT08_ICEBLOCK, - ACTORCAT_BG, - FLAGS, - OBJECT_SPOT08_OBJ, - sizeof(BgSpot08Iceblock), - (ActorFunc)BgSpot08Iceblock_Init, - (ActorFunc)BgSpot08Iceblock_Destroy, - (ActorFunc)BgSpot08Iceblock_Update, - (ActorFunc)BgSpot08Iceblock_Draw, -}; - -void BgSpot08Iceblock_SetupAction(BgSpot08Iceblock* this, BgSpot08IceblockActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void BgSpot08Iceblock_InitDynaPoly(BgSpot08Iceblock* this, GlobalContext* globalCtx, CollisionHeader* collision, - s32 flags) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, flags); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - // "Warning: move BG registration failed" - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 0xD9, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -// Sets params to 0x10 (medium, nonrotating) if not in the cases listed. -void BgSpot08Iceblock_CheckParams(BgSpot08Iceblock* this) { - switch (this->dyna.actor.params & 0xFF) { - case 0xFF: - this->dyna.actor.params = 0x10; - break; - default: - // "Error: arg_data setting error" - osSyncPrintf("Error : arg_data 設定ミスです。(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 0xF6, - this->dyna.actor.params); - this->dyna.actor.params = 0x10; - break; - case 1: - case 4: - case 0x10: - case 0x11: - case 0x12: - case 0x14: - case 0x20: - case 0x23: - case 0x24: - break; - } -} - -void BgSpot08Iceblock_Bobbing(BgSpot08Iceblock* this) { - this->bobOffset = (Math_SinS(this->bobPhaseSlow) * 4.0f) + (Math_SinS(this->bobPhaseFast) * 3.0f); -} - -void BgSpot08Iceblock_SinkUnderPlayer(BgSpot08Iceblock* this) { - f32 target; - f32 step; - - switch (this->dyna.actor.params & 0xF0) { - case 0: - step = 0.15f; - break; - case 0x10: - step = 0.2f; - break; - case 0x20: - step = 0.4f; - break; - } - - // Sink under Player's weight if standing on it - target = (func_80043548(&this->dyna) ? -4.0f : 0.0f); - - Math_StepToF(&this->sinkOffset, target, step); -} - -void BgSpot08Iceblock_SetWaterline(BgSpot08Iceblock* this) { - this->dyna.actor.world.pos.y = this->sinkOffset + this->bobOffset + this->dyna.actor.home.pos.y; -} - -void BgSpot08Iceblock_MultVectorScalar(Vec3f* dest, Vec3f* v, f32 scale) { - dest->x = v->x * scale; - dest->y = v->y * scale; - dest->z = v->z * scale; -} - -void BgSpot08Iceblock_CrossProduct(Vec3f* dest, Vec3f* v1, Vec3f* v2) { - dest->x = (v1->y * v2->z) - (v1->z * v2->y); - dest->y = (v1->z * v2->x) - (v1->x * v2->z); - dest->z = (v1->x * v2->y) - (v1->y * v2->x); -} - -s32 BgSpot08Iceblock_NormalizeVector(Vec3f* dest, Vec3f* v) { - f32 magnitude; - - magnitude = Math3D_Vec3fMagnitude(v); - if (magnitude < 0.001f) { - dest->x = dest->y = 0.0f; - dest->z = 1.0f; - return false; - } else { - dest->x = v->x * (1.0f / magnitude); - dest->y = v->y * (1.0f / magnitude); - dest->z = v->z * (1.0f / magnitude); - return true; - } -} - -static Vec3f sVerticalVector = { 0.0f, 1.0f, 0.0f }; -static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; -static f32 sInertias[] = { 1.0f / 70000000, 1.0f / 175000000, 1.0f / 700000000 }; -static f32 sDampingFactors[] = { 0.96f, 0.96f, 0.98f }; - -static f32 sRollSins[] = { - 0.22495104f, // sin(13 degrees) - 0.22495104f, // sin(13 degrees) - 0.03489947f, // sin(2 degrees) -}; - -static f32 sRollCoss[] = { - 0.97437006f, // cos(13 degrees) - 0.97437006f, // cos(13 degrees) - 0.99939084f, // cos(2 degrees) -}; - -/** - * Handles all the factors that influence rolling: inertia, random oscillations, and most significantly, player weight, - * and combines them to produce a matrix that rotates the actor to match the surface normal - */ -void BgSpot08Iceblock_Roll(BgSpot08Iceblock* this, GlobalContext* globalCtx) { - f32 deviationFromVertSq; - f32 stabilityCorrection; - Vec3f surfaceNormalHorizontal; - Vec3f playerCentroidDiff; - Vec3f playerMoment; - Vec3f surfaceNormalHorizontalScaled; - Vec3f randomNutation; - Vec3f tempVec; // reused with different meanings - Vec3f torqueDirection; - f32 playerCentroidDist; - s32 rollDataIndex; - MtxF mtx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - switch (this->dyna.actor.params & 0xFF) { - case 0x11: // Medium nonrotating - rollDataIndex = 0; - break; - case 1: - rollDataIndex = 1; // Large nonrotating - break; - default: - rollDataIndex = 2; - break; - } - - Math_Vec3f_Diff(&player->actor.world.pos, &this->dyna.actor.world.pos, &playerCentroidDiff); - playerCentroidDiff.y -= (150.0f * this->dyna.actor.scale.y); - playerCentroidDist = Math3D_Vec3fMagnitude(&playerCentroidDiff); - - randomNutation.x = (Rand_ZeroOne() - 0.5f) * (1.0f / 625); - randomNutation.y = 0.0f; - randomNutation.z = (Rand_ZeroOne() - 0.5f) * (1.0f / 625); - - surfaceNormalHorizontal.x = this->surfaceNormal.x; - surfaceNormalHorizontal.y = 0.0f; - surfaceNormalHorizontal.z = this->surfaceNormal.z; - - // If player is standing on it or holding the edge - if (func_8004356C(&this->dyna) && (playerCentroidDist > 3.0f)) { - Math_Vec3f_Diff(&playerCentroidDiff, &surfaceNormalHorizontal, &playerMoment); - BgSpot08Iceblock_MultVectorScalar(&playerMoment, &playerMoment, - (sInertias[rollDataIndex] * playerCentroidDist) / this->dyna.actor.scale.x); - } else { - playerMoment = sZeroVector; - } - - BgSpot08Iceblock_MultVectorScalar(&surfaceNormalHorizontalScaled, &surfaceNormalHorizontal, -0.01f); - - // Add all three deviations - Math_Vec3f_Sum(&this->normalDelta, &playerMoment, &this->normalDelta); - Math_Vec3f_Sum(&this->normalDelta, &surfaceNormalHorizontalScaled, &this->normalDelta); - Math_Vec3f_Sum(&this->normalDelta, &randomNutation, &this->normalDelta); - - this->normalDelta.y = 0.0f; - - Math_Vec3f_Sum(&this->surfaceNormal, &this->normalDelta, &tempVec); - - tempVec.x *= sDampingFactors[rollDataIndex]; - tempVec.z *= sDampingFactors[rollDataIndex]; - - // Set up roll axis and final new angle - if (BgSpot08Iceblock_NormalizeVector(&this->surfaceNormal, &tempVec)) { - deviationFromVertSq = Math3D_Dist1DSq(this->surfaceNormal.z, this->surfaceNormal.x); - - // Prevent overrolling - if (sRollSins[rollDataIndex] < deviationFromVertSq) { - stabilityCorrection = sRollSins[rollDataIndex] / deviationFromVertSq; - - this->surfaceNormal.x *= stabilityCorrection; - this->surfaceNormal.y = sRollCoss[rollDataIndex]; - this->surfaceNormal.z *= stabilityCorrection; - } - - BgSpot08Iceblock_CrossProduct(&tempVec, &sVerticalVector, &this->surfaceNormal); - - if (BgSpot08Iceblock_NormalizeVector(&torqueDirection, &tempVec)) { - this->rotationAxis = torqueDirection; - } - } else { - this->surfaceNormal = sVerticalVector; - } - - // Rotation by the angle between surfaceNormal and the vertical about rotationAxis - Matrix_RotateAxis(Math_FAcosF(Math3D_Cos(&sVerticalVector, &this->surfaceNormal)), &this->rotationAxis, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_Get(&mtx); - Matrix_MtxFToYXZRotS(&mtx, &this->dyna.actor.shape.rot, 0); -} - -void BgSpot08Iceblock_SpawnTwinFloe(BgSpot08Iceblock* this, GlobalContext* globalCtx) { - s32 pad[2]; - f32 sin; - f32 cos; - - sin = Math_SinS(this->dyna.actor.home.rot.y) * 100.0f; - cos = Math_CosS(this->dyna.actor.home.rot.y) * 100.0f; - - if (!(this->dyna.actor.params & 0x100)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_SPOT08_ICEBLOCK, - this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, this->dyna.actor.home.pos.z, - this->dyna.actor.home.rot.x, this->dyna.actor.home.rot.y, this->dyna.actor.home.rot.z, - 0x123); - - this->dyna.actor.world.pos.x += sin; - this->dyna.actor.world.pos.z += cos; - } else { - this->dyna.actor.world.pos.x -= sin; - this->dyna.actor.world.pos.z -= cos; - } - BgSpot08Iceblock_SetupFloatOrbitingTwins(this); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 2200, ICHAIN_STOP), -}; - -void BgSpot08Iceblock_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; - CollisionHeader* colHeader = NULL; - - // "spot08 ice floe" - osSyncPrintf("(spot08 流氷)(arg_data 0x%04x)\n", this->dyna.actor.params); - BgSpot08Iceblock_CheckParams(this); - - switch (this->dyna.actor.params & 0x200) { - case 0: - colHeader = &gZorasFountainIcebergCol; - break; - case 0x200: - colHeader = &gZorasFountainIceRampCol; - break; - } - - switch (this->dyna.actor.params & 0xF) { - case 2: - case 3: - BgSpot08Iceblock_InitDynaPoly(this, globalCtx, colHeader, DPM_UNK3); - break; - default: - BgSpot08Iceblock_InitDynaPoly(this, globalCtx, colHeader, DPM_UNK); - break; - } - - if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - Actor_Kill(&this->dyna.actor); - return; - } - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - - switch (this->dyna.actor.params & 0xF0) { - case 0: - Actor_SetScale(&this->dyna.actor, 0.2f); - break; - case 0x10: - Actor_SetScale(&this->dyna.actor, 0.1f); - break; - case 0x20: - Actor_SetScale(&this->dyna.actor, 0.05f); - break; - } - - this->bobPhaseSlow = (s32)(Rand_ZeroOne() * (0xFFFF + 0.5f)); - this->bobPhaseFast = (s32)(Rand_ZeroOne() * (0xFFFF + 0.5f)); - this->surfaceNormal.y = 1.0f; - this->rotationAxis.x = 1.0f; - - switch (this->dyna.actor.params & 0xF) { - case 0: - case 1: - BgSpot08Iceblock_SetupFloatNonrotating(this); - break; - case 2: - BgSpot08Iceblock_SetupFloatRotating(this); - break; - case 3: - BgSpot08Iceblock_SpawnTwinFloe(this, globalCtx); - break; - case 4: - BgSpot08Iceblock_SetupNoAction(this); - break; - } -} - -void BgSpot08Iceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgSpot08Iceblock_SetupFloatNonrotating(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_FloatNonrotating); -} - -void BgSpot08Iceblock_FloatNonrotating(BgSpot08Iceblock* this, GlobalContext* globalCtx) { - BgSpot08Iceblock_Bobbing(this); - BgSpot08Iceblock_SinkUnderPlayer(this); - BgSpot08Iceblock_SetWaterline(this); - this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; - BgSpot08Iceblock_Roll(this, globalCtx); -} - -void BgSpot08Iceblock_SetupFloatRotating(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_FloatRotating); -} - -void BgSpot08Iceblock_FloatRotating(BgSpot08Iceblock* this, GlobalContext* globalCtx) { - BgSpot08Iceblock_Bobbing(this); - BgSpot08Iceblock_SinkUnderPlayer(this); - BgSpot08Iceblock_SetWaterline(this); - this->dyna.actor.world.rot.y = this->dyna.actor.world.rot.y + 0x190; - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; - BgSpot08Iceblock_Roll(this, globalCtx); -} - -void BgSpot08Iceblock_SetupFloatOrbitingTwins(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_FloatOrbitingTwins); -} - -void BgSpot08Iceblock_FloatOrbitingTwins(BgSpot08Iceblock* this, GlobalContext* globalCtx) { - f32 cos; - f32 sin; - - BgSpot08Iceblock_Bobbing(this); - BgSpot08Iceblock_SinkUnderPlayer(this); - BgSpot08Iceblock_SetWaterline(this); - - // parent handles rotations of both - if (!(this->dyna.actor.params & 0x100)) { - this->dyna.actor.world.rot.y += 0x190; - sin = Math_SinS(this->dyna.actor.world.rot.y) * 100.0f; - cos = Math_CosS(this->dyna.actor.world.rot.y) * 100.0f; - - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sin; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + cos; - - if (this->dyna.actor.child != NULL) { - this->dyna.actor.child->world.pos.x = this->dyna.actor.home.pos.x - sin; - this->dyna.actor.child->world.pos.z = this->dyna.actor.home.pos.z - cos; - } - } - - this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; - BgSpot08Iceblock_Roll(this, globalCtx); -} - -void BgSpot08Iceblock_SetupNoAction(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, NULL); -} - -void BgSpot08Iceblock_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; - - if (Rand_ZeroOne() < 0.05f) { - this->bobIncrSlow = Rand_S16Offset(300, 100); - this->bobIncrFast = Rand_S16Offset(800, 400); - } - - this->bobPhaseSlow += this->bobIncrSlow; - this->bobPhaseFast += this->bobIncrFast; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } -} - -void BgSpot08Iceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx* dList = NULL; - BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; - - switch (this->dyna.actor.params & 0x200) { - case 0: - dList = gZorasFountainIcebergDL; - break; - case 0x200: - dList = gZorasFountainIceRampDL; - break; - } - - Gfx_DrawDListOpa(globalCtx, dList); -} diff --git a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.cpp b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.cpp new file mode 100644 index 000000000..a16b19dd2 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.cpp @@ -0,0 +1,457 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT08_ICEBLOCK_Z_BG_SPOT08_ICEBLOCK_C +#include "actor_common.h" +/* + * File: z_bg_spot08_iceblock.c + * Overlay: ovl_Bg_Spot08_Iceblock + * Description: Floating ice platforms + */ + +#include "z_bg_spot08_iceblock.h" +#include "objects/object_spot08_obj/object_spot08_obj.h" +#include "def/code_80043480.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void BgSpot08Iceblock_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot08Iceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot08Iceblock_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot08Iceblock_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgSpot08Iceblock_SetupFloatNonrotating(BgSpot08Iceblock* pthis); +void BgSpot08Iceblock_FloatNonrotating(BgSpot08Iceblock* pthis, GlobalContext* globalCtx); +void BgSpot08Iceblock_SetupFloatRotating(BgSpot08Iceblock* pthis); +void BgSpot08Iceblock_FloatRotating(BgSpot08Iceblock* pthis, GlobalContext* globalCtx); +void BgSpot08Iceblock_SetupFloatOrbitingTwins(BgSpot08Iceblock* pthis); +void BgSpot08Iceblock_FloatOrbitingTwins(BgSpot08Iceblock* pthis, GlobalContext* globalCtx); +void BgSpot08Iceblock_SetupNoAction(BgSpot08Iceblock* pthis); + +ActorInit Bg_Spot08_Iceblock_InitVars = { + ACTOR_BG_SPOT08_ICEBLOCK, + ACTORCAT_BG, + FLAGS, + OBJECT_SPOT08_OBJ, + sizeof(BgSpot08Iceblock), + (ActorFunc)BgSpot08Iceblock_Init, + (ActorFunc)BgSpot08Iceblock_Destroy, + (ActorFunc)BgSpot08Iceblock_Update, + (ActorFunc)BgSpot08Iceblock_Draw, +}; + +void BgSpot08Iceblock_SetupAction(BgSpot08Iceblock* pthis, BgSpot08IceblockActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void BgSpot08Iceblock_InitDynaPoly(BgSpot08Iceblock* pthis, GlobalContext* globalCtx, CollisionHeader* collision, + s32 flags) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flags); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + // "Warning: move BG registration failed" + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 0xD9, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +// Sets params to 0x10 (medium, nonrotating) if not in the cases listed. +void BgSpot08Iceblock_CheckParams(BgSpot08Iceblock* pthis) { + switch (pthis->dyna.actor.params & 0xFF) { + case 0xFF: + pthis->dyna.actor.params = 0x10; + break; + default: + // "Error: arg_data setting error" + osSyncPrintf("Error : arg_data 設定ミスです。(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 0xF6, + pthis->dyna.actor.params); + pthis->dyna.actor.params = 0x10; + break; + case 1: + case 4: + case 0x10: + case 0x11: + case 0x12: + case 0x14: + case 0x20: + case 0x23: + case 0x24: + break; + } +} + +void BgSpot08Iceblock_Bobbing(BgSpot08Iceblock* pthis) { + pthis->bobOffset = (Math_SinS(pthis->bobPhaseSlow) * 4.0f) + (Math_SinS(pthis->bobPhaseFast) * 3.0f); +} + +void BgSpot08Iceblock_SinkUnderPlayer(BgSpot08Iceblock* pthis) { + f32 target; + f32 step; + + switch (pthis->dyna.actor.params & 0xF0) { + case 0: + step = 0.15f; + break; + case 0x10: + step = 0.2f; + break; + case 0x20: + step = 0.4f; + break; + } + + // Sink under Player's weight if standing on it + target = (func_80043548(&pthis->dyna) ? -4.0f : 0.0f); + + Math_StepToF(&pthis->sinkOffset, target, step); +} + +void BgSpot08Iceblock_SetWaterline(BgSpot08Iceblock* pthis) { + pthis->dyna.actor.world.pos.y = pthis->sinkOffset + pthis->bobOffset + pthis->dyna.actor.home.pos.y; +} + +void BgSpot08Iceblock_MultVectorScalar(Vec3f* dest, Vec3f* v, f32 scale) { + dest->x = v->x * scale; + dest->y = v->y * scale; + dest->z = v->z * scale; +} + +void BgSpot08Iceblock_CrossProduct(Vec3f* dest, Vec3f* v1, Vec3f* v2) { + dest->x = (v1->y * v2->z) - (v1->z * v2->y); + dest->y = (v1->z * v2->x) - (v1->x * v2->z); + dest->z = (v1->x * v2->y) - (v1->y * v2->x); +} + +s32 BgSpot08Iceblock_NormalizeVector(Vec3f* dest, Vec3f* v) { + f32 magnitude; + + magnitude = Math3D_Vec3fMagnitude(v); + if (magnitude < 0.001f) { + dest->x = dest->y = 0.0f; + dest->z = 1.0f; + return false; + } else { + dest->x = v->x * (1.0f / magnitude); + dest->y = v->y * (1.0f / magnitude); + dest->z = v->z * (1.0f / magnitude); + return true; + } +} + +static Vec3f sVerticalVector = { 0.0f, 1.0f, 0.0f }; +static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; +static f32 sInertias[] = { 1.0f / 70000000, 1.0f / 175000000, 1.0f / 700000000 }; +static f32 sDampingFactors[] = { 0.96f, 0.96f, 0.98f }; + +static f32 sRollSins[] = { + 0.22495104f, // sin(13 degrees) + 0.22495104f, // sin(13 degrees) + 0.03489947f, // sin(2 degrees) +}; + +static f32 sRollCoss[] = { + 0.97437006f, // cos(13 degrees) + 0.97437006f, // cos(13 degrees) + 0.99939084f, // cos(2 degrees) +}; + +/** + * Handles all the factors that influence rolling: inertia, random oscillations, and most significantly, player weight, + * and combines them to produce a matrix that rotates the actor to match the surface normal + */ +void BgSpot08Iceblock_Roll(BgSpot08Iceblock* pthis, GlobalContext* globalCtx) { + f32 deviationFromVertSq; + f32 stabilityCorrection; + Vec3f surfaceNormalHorizontal; + Vec3f playerCentroidDiff; + Vec3f playerMoment; + Vec3f surfaceNormalHorizontalScaled; + Vec3f randomNutation; + Vec3f tempVec; // reused with different meanings + Vec3f torqueDirection; + f32 playerCentroidDist; + s32 rollDataIndex; + MtxF mtx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + switch (pthis->dyna.actor.params & 0xFF) { + case 0x11: // Medium nonrotating + rollDataIndex = 0; + break; + case 1: + rollDataIndex = 1; // Large nonrotating + break; + default: + rollDataIndex = 2; + break; + } + + Math_Vec3f_Diff(&player->actor.world.pos, &pthis->dyna.actor.world.pos, &playerCentroidDiff); + playerCentroidDiff.y -= (150.0f * pthis->dyna.actor.scale.y); + playerCentroidDist = Math3D_Vec3fMagnitude(&playerCentroidDiff); + + randomNutation.x = (Rand_ZeroOne() - 0.5f) * (1.0f / 625); + randomNutation.y = 0.0f; + randomNutation.z = (Rand_ZeroOne() - 0.5f) * (1.0f / 625); + + surfaceNormalHorizontal.x = pthis->surfaceNormal.x; + surfaceNormalHorizontal.y = 0.0f; + surfaceNormalHorizontal.z = pthis->surfaceNormal.z; + + // If player is standing on it or holding the edge + if (func_8004356C(&pthis->dyna) && (playerCentroidDist > 3.0f)) { + Math_Vec3f_Diff(&playerCentroidDiff, &surfaceNormalHorizontal, &playerMoment); + BgSpot08Iceblock_MultVectorScalar(&playerMoment, &playerMoment, + (sInertias[rollDataIndex] * playerCentroidDist) / pthis->dyna.actor.scale.x); + } else { + playerMoment = sZeroVector; + } + + BgSpot08Iceblock_MultVectorScalar(&surfaceNormalHorizontalScaled, &surfaceNormalHorizontal, -0.01f); + + // Add all three deviations + Math_Vec3f_Sum(&pthis->normalDelta, &playerMoment, &pthis->normalDelta); + Math_Vec3f_Sum(&pthis->normalDelta, &surfaceNormalHorizontalScaled, &pthis->normalDelta); + Math_Vec3f_Sum(&pthis->normalDelta, &randomNutation, &pthis->normalDelta); + + pthis->normalDelta.y = 0.0f; + + Math_Vec3f_Sum(&pthis->surfaceNormal, &pthis->normalDelta, &tempVec); + + tempVec.x *= sDampingFactors[rollDataIndex]; + tempVec.z *= sDampingFactors[rollDataIndex]; + + // Set up roll axis and final new angle + if (BgSpot08Iceblock_NormalizeVector(&pthis->surfaceNormal, &tempVec)) { + deviationFromVertSq = Math3D_Dist1DSq(pthis->surfaceNormal.z, pthis->surfaceNormal.x); + + // Prevent overrolling + if (sRollSins[rollDataIndex] < deviationFromVertSq) { + stabilityCorrection = sRollSins[rollDataIndex] / deviationFromVertSq; + + pthis->surfaceNormal.x *= stabilityCorrection; + pthis->surfaceNormal.y = sRollCoss[rollDataIndex]; + pthis->surfaceNormal.z *= stabilityCorrection; + } + + BgSpot08Iceblock_CrossProduct(&tempVec, &sVerticalVector, &pthis->surfaceNormal); + + if (BgSpot08Iceblock_NormalizeVector(&torqueDirection, &tempVec)) { + pthis->rotationAxis = torqueDirection; + } + } else { + pthis->surfaceNormal = sVerticalVector; + } + + // Rotation by the angle between surfaceNormal and the vertical about rotationAxis + Matrix_RotateAxis(Math_FAcosF(Math3D_Cos(&sVerticalVector, &pthis->surfaceNormal)), &pthis->rotationAxis, + MTXMODE_NEW); + Matrix_RotateY(pthis->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Get(&mtx); + Matrix_MtxFToYXZRotS(&mtx, &pthis->dyna.actor.shape.rot, 0); +} + +void BgSpot08Iceblock_SpawnTwinFloe(BgSpot08Iceblock* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + f32 sin; + f32 cos; + + sin = Math_SinS(pthis->dyna.actor.home.rot.y) * 100.0f; + cos = Math_CosS(pthis->dyna.actor.home.rot.y) * 100.0f; + + if (!(pthis->dyna.actor.params & 0x100)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_SPOT08_ICEBLOCK, + pthis->dyna.actor.home.pos.x, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.home.pos.z, + pthis->dyna.actor.home.rot.x, pthis->dyna.actor.home.rot.y, pthis->dyna.actor.home.rot.z, + 0x123); + + pthis->dyna.actor.world.pos.x += sin; + pthis->dyna.actor.world.pos.z += cos; + } else { + pthis->dyna.actor.world.pos.x -= sin; + pthis->dyna.actor.world.pos.z -= cos; + } + BgSpot08Iceblock_SetupFloatOrbitingTwins(pthis); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 2200, ICHAIN_STOP), +}; + +void BgSpot08Iceblock_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpot08Iceblock* pthis = (BgSpot08Iceblock*)thisx; + CollisionHeader* colHeader = NULL; + + // "spot08 ice floe" + osSyncPrintf("(spot08 流氷)(arg_data 0x%04x)\n", pthis->dyna.actor.params); + BgSpot08Iceblock_CheckParams(pthis); + + switch (pthis->dyna.actor.params & 0x200) { + case 0: + colHeader = &gZorasFountainIcebergCol; + break; + case 0x200: + colHeader = &gZorasFountainIceRampCol; + break; + } + + switch (pthis->dyna.actor.params & 0xF) { + case 2: + case 3: + BgSpot08Iceblock_InitDynaPoly(pthis, globalCtx, colHeader, DPM_UNK3); + break; + default: + BgSpot08Iceblock_InitDynaPoly(pthis, globalCtx, colHeader, DPM_UNK); + break; + } + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + Actor_Kill(&pthis->dyna.actor); + return; + } + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + + switch (pthis->dyna.actor.params & 0xF0) { + case 0: + Actor_SetScale(&pthis->dyna.actor, 0.2f); + break; + case 0x10: + Actor_SetScale(&pthis->dyna.actor, 0.1f); + break; + case 0x20: + Actor_SetScale(&pthis->dyna.actor, 0.05f); + break; + } + + pthis->bobPhaseSlow = (s32)(Rand_ZeroOne() * (0xFFFF + 0.5f)); + pthis->bobPhaseFast = (s32)(Rand_ZeroOne() * (0xFFFF + 0.5f)); + pthis->surfaceNormal.y = 1.0f; + pthis->rotationAxis.x = 1.0f; + + switch (pthis->dyna.actor.params & 0xF) { + case 0: + case 1: + BgSpot08Iceblock_SetupFloatNonrotating(pthis); + break; + case 2: + BgSpot08Iceblock_SetupFloatRotating(pthis); + break; + case 3: + BgSpot08Iceblock_SpawnTwinFloe(pthis, globalCtx); + break; + case 4: + BgSpot08Iceblock_SetupNoAction(pthis); + break; + } +} + +void BgSpot08Iceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot08Iceblock* pthis = (BgSpot08Iceblock*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgSpot08Iceblock_SetupFloatNonrotating(BgSpot08Iceblock* pthis) { + BgSpot08Iceblock_SetupAction(pthis, BgSpot08Iceblock_FloatNonrotating); +} + +void BgSpot08Iceblock_FloatNonrotating(BgSpot08Iceblock* pthis, GlobalContext* globalCtx) { + BgSpot08Iceblock_Bobbing(pthis); + BgSpot08Iceblock_SinkUnderPlayer(pthis); + BgSpot08Iceblock_SetWaterline(pthis); + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.home.rot.y; + BgSpot08Iceblock_Roll(pthis, globalCtx); +} + +void BgSpot08Iceblock_SetupFloatRotating(BgSpot08Iceblock* pthis) { + BgSpot08Iceblock_SetupAction(pthis, BgSpot08Iceblock_FloatRotating); +} + +void BgSpot08Iceblock_FloatRotating(BgSpot08Iceblock* pthis, GlobalContext* globalCtx) { + BgSpot08Iceblock_Bobbing(pthis); + BgSpot08Iceblock_SinkUnderPlayer(pthis); + BgSpot08Iceblock_SetWaterline(pthis); + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.world.rot.y + 0x190; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y; + BgSpot08Iceblock_Roll(pthis, globalCtx); +} + +void BgSpot08Iceblock_SetupFloatOrbitingTwins(BgSpot08Iceblock* pthis) { + BgSpot08Iceblock_SetupAction(pthis, BgSpot08Iceblock_FloatOrbitingTwins); +} + +void BgSpot08Iceblock_FloatOrbitingTwins(BgSpot08Iceblock* pthis, GlobalContext* globalCtx) { + f32 cos; + f32 sin; + + BgSpot08Iceblock_Bobbing(pthis); + BgSpot08Iceblock_SinkUnderPlayer(pthis); + BgSpot08Iceblock_SetWaterline(pthis); + + // parent handles rotations of both + if (!(pthis->dyna.actor.params & 0x100)) { + pthis->dyna.actor.world.rot.y += 0x190; + sin = Math_SinS(pthis->dyna.actor.world.rot.y) * 100.0f; + cos = Math_CosS(pthis->dyna.actor.world.rot.y) * 100.0f; + + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x + sin; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z + cos; + + if (pthis->dyna.actor.child != NULL) { + pthis->dyna.actor.child->world.pos.x = pthis->dyna.actor.home.pos.x - sin; + pthis->dyna.actor.child->world.pos.z = pthis->dyna.actor.home.pos.z - cos; + } + } + + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.home.rot.y; + BgSpot08Iceblock_Roll(pthis, globalCtx); +} + +void BgSpot08Iceblock_SetupNoAction(BgSpot08Iceblock* pthis) { + BgSpot08Iceblock_SetupAction(pthis, NULL); +} + +void BgSpot08Iceblock_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot08Iceblock* pthis = (BgSpot08Iceblock*)thisx; + + if (Rand_ZeroOne() < 0.05f) { + pthis->bobIncrSlow = Rand_S16Offset(300, 100); + pthis->bobIncrFast = Rand_S16Offset(800, 400); + } + + pthis->bobPhaseSlow += pthis->bobIncrSlow; + pthis->bobPhaseFast += pthis->bobIncrFast; + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } +} + +void BgSpot08Iceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* dList = NULL; + BgSpot08Iceblock* pthis = (BgSpot08Iceblock*)thisx; + + switch (pthis->dyna.actor.params & 0x200) { + case 0: + dList = gZorasFountainIcebergDL; + break; + case 0x200: + dList = gZorasFountainIceRampDL; + break; + } + + Gfx_DrawDListOpa(globalCtx, dList); +} diff --git a/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c b/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.cpp similarity index 61% rename from src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c rename to src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.cpp index 031625476..52ea481ba 100644 --- a/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c +++ b/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.cpp @@ -24,11 +24,11 @@ void BgSpot09Obj_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot09Obj_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot09Obj_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 func_808B1AE0(BgSpot09Obj* this, GlobalContext* globalCtx); -s32 func_808B1BA0(BgSpot09Obj* this, GlobalContext* globalCtx); -s32 func_808B1BEC(BgSpot09Obj* this, GlobalContext* globalCtx); +s32 func_808B1AE0(BgSpot09Obj* pthis, GlobalContext* globalCtx); +s32 func_808B1BA0(BgSpot09Obj* pthis, GlobalContext* globalCtx); +s32 func_808B1BEC(BgSpot09Obj* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot09_Obj_InitVars = { +ActorInit Bg_Spot09_Obj_InitVars = { ACTOR_BG_SPOT09_OBJ, ACTORCAT_BG, FLAGS, @@ -44,7 +44,7 @@ static CollisionHeader* D_808B1F90[] = { NULL, &gValleyObjects1Col, &gValleyObjects2Col, &gValleyObjects3Col, &gValleyObjects4Col, }; -static s32 (*D_808B1FA4[])(BgSpot09Obj* this, GlobalContext* globalCtx) = { +static s32 (*D_808B1FA4[])(BgSpot09Obj* pthis, GlobalContext* globalCtx) = { func_808B1BEC, func_808B1AE0, func_808B1BA0, @@ -66,17 +66,17 @@ static Gfx* sDLists[] = { gValleyBridgeSidesDL, gValleyBrokenBridgeDL, gValleyBridgeChildDL, gCarpentersTentDL, gValleyRepairedBridgeDL, }; -s32 func_808B1AE0(BgSpot09Obj* this, GlobalContext* globalCtx) { +s32 func_808B1AE0(BgSpot09Obj* pthis, GlobalContext* globalCtx) { s32 carpentersRescued; if (gSaveContext.sceneSetupIndex >= 4) { - return this->dyna.actor.params == 0; + return pthis->dyna.actor.params == 0; } carpentersRescued = (gSaveContext.eventChkInf[9] & 0xF) == 0xF; if (LINK_AGE_IN_YEARS == YEARS_ADULT) { - switch (this->dyna.actor.params) { + switch (pthis->dyna.actor.params) { case 0: return 0; case 1: @@ -87,87 +87,87 @@ s32 func_808B1AE0(BgSpot09Obj* this, GlobalContext* globalCtx) { return 1; } } else { - return this->dyna.actor.params == 2; + return pthis->dyna.actor.params == 2; } return 0; } -s32 func_808B1BA0(BgSpot09Obj* this, GlobalContext* globalCtx) { - if (this->dyna.actor.params == 3) { - Actor_SetScale(&this->dyna.actor, 0.1f); +s32 func_808B1BA0(BgSpot09Obj* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.params == 3) { + Actor_SetScale(&pthis->dyna.actor, 0.1f); } else { - Actor_SetScale(&this->dyna.actor, 1.0f); + Actor_SetScale(&pthis->dyna.actor, 1.0f); } return 1; } -s32 func_808B1BEC(BgSpot09Obj* this, GlobalContext* globalCtx) { +s32 func_808B1BEC(BgSpot09Obj* pthis, GlobalContext* globalCtx) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2[2]; - if (D_808B1F90[this->dyna.actor.params] != NULL) { - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(D_808B1F90[this->dyna.actor.params], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + if (D_808B1F90[pthis->dyna.actor.params] != NULL) { + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(D_808B1F90[pthis->dyna.actor.params], &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } return true; } -s32 func_808B1C70(BgSpot09Obj* this, GlobalContext* globalCtx) { +s32 func_808B1C70(BgSpot09Obj* pthis, GlobalContext* globalCtx) { s32 i; for (i = 0; i < ARRAY_COUNT(D_808B1FA4); i++) { - if (!D_808B1FA4[i](this, globalCtx)) { + if (!D_808B1FA4[i](pthis, globalCtx)) { return false; } } return true; } -s32 func_808B1CEC(BgSpot09Obj* this, GlobalContext* globalCtx) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain1); +s32 func_808B1CEC(BgSpot09Obj* pthis, GlobalContext* globalCtx) { + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain1); return true; } -s32 func_808B1D18(BgSpot09Obj* this, GlobalContext* globalCtx) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); +s32 func_808B1D18(BgSpot09Obj* pthis, GlobalContext* globalCtx) { + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain2); return true; } -s32 func_808B1D44(BgSpot09Obj* this, GlobalContext* globalCtx) { - if (this->dyna.actor.params == 3) { - return func_808B1D18(this, globalCtx); +s32 func_808B1D44(BgSpot09Obj* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.params == 3) { + return func_808B1D18(pthis, globalCtx); } else { - return func_808B1CEC(this, globalCtx); + return func_808B1CEC(pthis, globalCtx); } } void BgSpot09Obj_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot09Obj* this = (BgSpot09Obj*)thisx; + BgSpot09Obj* pthis = (BgSpot09Obj*)thisx; - osSyncPrintf("Spot09 Object [arg_data : 0x%04x](大工救出フラグ 0x%x)\n", this->dyna.actor.params, + osSyncPrintf("Spot09 Object [arg_data : 0x%04x](大工救出フラグ 0x%x)\n", pthis->dyna.actor.params, gSaveContext.eventChkInf[9] & 0xF); - this->dyna.actor.params &= 0xFF; - if ((this->dyna.actor.params < 0) || (this->dyna.actor.params >= 5)) { + pthis->dyna.actor.params &= 0xFF; + if ((pthis->dyna.actor.params < 0) || (pthis->dyna.actor.params >= 5)) { osSyncPrintf("Error : Spot 09 object の arg_data が判別出来ない(%s %d)(arg_data 0x%04x)\n", - "../z_bg_spot09_obj.c", 322, this->dyna.actor.params); + "../z_bg_spot09_obj.c", 322, pthis->dyna.actor.params); } - if (!func_808B1C70(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } else if (!func_808B1D44(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); + if (!func_808B1C70(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } else if (!func_808B1D44(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); } } void BgSpot09Obj_Destroy(Actor* thisx, GlobalContext* globalCtx) { DynaCollisionContext* dynaColCtx = &globalCtx->colCtx.dyna; - BgSpot09Obj* this = (BgSpot09Obj*)thisx; + BgSpot09Obj* pthis = (BgSpot09Obj*)thisx; - if (this->dyna.actor.params != 0) { - DynaPoly_DeleteBgActor(globalCtx, dynaColCtx, this->dyna.bgId); + if (pthis->dyna.actor.params != 0) { + DynaPoly_DeleteBgActor(globalCtx, dynaColCtx, pthis->dyna.bgId); } } diff --git a/src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/z_bg_spot11_bakudankabe.c b/src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/z_bg_spot11_bakudankabe.cpp similarity index 70% rename from src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/z_bg_spot11_bakudankabe.c rename to src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/z_bg_spot11_bakudankabe.cpp index 55e8aaa77..52967c226 100644 --- a/src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/z_bg_spot11_bakudankabe.c +++ b/src/overlays/actors/ovl_Bg_Spot11_Bakudankabe/z_bg_spot11_bakudankabe.cpp @@ -27,7 +27,7 @@ void BgSpot11Bakudankabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot11Bakudankabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot11Bakudankabe_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot11_Bakudankabe_InitVars = { +ActorInit Bg_Spot11_Bakudankabe_InitVars = { ACTOR_BG_SPOT11_BAKUDANKABE, ACTORCAT_BG, FLAGS, @@ -62,18 +62,18 @@ static ColliderCylinderInit sCylinderInit = { static Vec3f D_808B272C = { 2259.0f, 108.0f, -1550.0f }; static Vec3f D_808B2738 = { 2259.0f, 108.0f, -1550.0f }; -void func_808B2180(BgSpot11Bakudankabe* this, GlobalContext* globalCtx) { +void func_808B2180(BgSpot11Bakudankabe* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - this->collider.dim.pos.x += (s16)this->dyna.actor.world.pos.x; - this->collider.dim.pos.y += (s16)this->dyna.actor.world.pos.y; - this->collider.dim.pos.z += (s16)this->dyna.actor.world.pos.z; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + pthis->collider.dim.pos.x += (s16)pthis->dyna.actor.world.pos.x; + pthis->collider.dim.pos.y += (s16)pthis->dyna.actor.world.pos.y; + pthis->collider.dim.pos.z += (s16)pthis->dyna.actor.world.pos.z; } -void func_808B2218(BgSpot11Bakudankabe* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void func_808B2218(BgSpot11Bakudankabe* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; Vec3f burstDepthY; Vec3f burstDepthX; s32 i; @@ -119,45 +119,45 @@ void func_808B2218(BgSpot11Bakudankabe* this, GlobalContext* globalCtx) { } void BgSpot11Bakudankabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot11Bakudankabe* this = (BgSpot11Bakudankabe*)thisx; + BgSpot11Bakudankabe* pthis = (BgSpot11Bakudankabe*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) { - Actor_Kill(&this->dyna.actor); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F))) { + Actor_Kill(&pthis->dyna.actor); return; } - func_808B2180(this, globalCtx); + func_808B2180(pthis, globalCtx); CollisionHeader_GetVirtual(&gDesertColossusBombableWallCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_SetScale(&this->dyna.actor, 1.0f); - osSyncPrintf("(spot11 爆弾壁)(arg_data 0x%04x)\n", this->dyna.actor.params); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_SetScale(&pthis->dyna.actor, 1.0f); + osSyncPrintf("(spot11 爆弾壁)(arg_data 0x%04x)\n", pthis->dyna.actor.params); } void BgSpot11Bakudankabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot11Bakudankabe* this = (BgSpot11Bakudankabe*)thisx; + BgSpot11Bakudankabe* pthis = (BgSpot11Bakudankabe*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void BgSpot11Bakudankabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot11Bakudankabe* this = (BgSpot11Bakudankabe*)thisx; + BgSpot11Bakudankabe* pthis = (BgSpot11Bakudankabe*)thisx; - if (this->collider.base.acFlags & AC_HIT) { - func_808B2218(this, globalCtx); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params & 0x3F)); + if (pthis->collider.base.acFlags & AC_HIT) { + func_808B2218(pthis, globalCtx); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F)); Audio_PlaySoundAtPosition(globalCtx, &D_808B2738, 40, NA_SE_EV_WALL_BROKEN); func_80078884(NA_SE_SY_CORRECT_CHIME); - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } void BgSpot11Bakudankabe_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot11Bakudankabe* this = (BgSpot11Bakudankabe*)thisx; + BgSpot11Bakudankabe* pthis = (BgSpot11Bakudankabe*)thisx; Gfx_DrawDListOpa(globalCtx, gDesertColossusBombableWallDL); } diff --git a/src/overlays/actors/ovl_Bg_Spot11_Oasis/z_bg_spot11_oasis.c b/src/overlays/actors/ovl_Bg_Spot11_Oasis/z_bg_spot11_oasis.cpp similarity index 67% rename from src/overlays/actors/ovl_Bg_Spot11_Oasis/z_bg_spot11_oasis.c rename to src/overlays/actors/ovl_Bg_Spot11_Oasis/z_bg_spot11_oasis.cpp index af6e96c4b..d6b2f14c7 100644 --- a/src/overlays/actors/ovl_Bg_Spot11_Oasis/z_bg_spot11_oasis.c +++ b/src/overlays/actors/ovl_Bg_Spot11_Oasis/z_bg_spot11_oasis.cpp @@ -24,14 +24,14 @@ void BgSpot11Oasis_Init(Actor* thisx, GlobalContext* globalCtx); void BgSpot11Oasis_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot11Oasis_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B2970(BgSpot11Oasis* this); -void func_808B2980(BgSpot11Oasis* this, GlobalContext* globalCtx); -void func_808B29E0(BgSpot11Oasis* this); -void func_808B29F0(BgSpot11Oasis* this, GlobalContext* globalCtx); -void func_808B2AA8(BgSpot11Oasis* this); -void func_808B2AB8(BgSpot11Oasis* this, GlobalContext* globalCtx); +void func_808B2970(BgSpot11Oasis* pthis); +void func_808B2980(BgSpot11Oasis* pthis, GlobalContext* globalCtx); +void func_808B29E0(BgSpot11Oasis* pthis); +void func_808B29F0(BgSpot11Oasis* pthis, GlobalContext* globalCtx); +void func_808B2AA8(BgSpot11Oasis* pthis); +void func_808B2AB8(BgSpot11Oasis* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot11_Oasis_InitVars = { +ActorInit Bg_Spot11_Oasis_InitVars = { ACTOR_BG_SPOT11_OASIS, ACTORCAT_BG, FLAGS, @@ -92,69 +92,69 @@ s32 func_808B280C(GlobalContext* globalCtx) { } void BgSpot11Oasis_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot11Oasis* this = (BgSpot11Oasis*)thisx; + BgSpot11Oasis* pthis = (BgSpot11Oasis*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - func_808B2970(this); - this->actor.world.pos.y = -100.0f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + func_808B2970(pthis); + pthis->actor.world.pos.y = -100.0f; func_808B27F0(globalCtx, -100); } -void func_808B2970(BgSpot11Oasis* this) { - this->actionFunc = func_808B2980; +void func_808B2970(BgSpot11Oasis* pthis) { + pthis->actionFunc = func_808B2980; } -void func_808B2980(BgSpot11Oasis* this, GlobalContext* globalCtx) { +void func_808B2980(BgSpot11Oasis* pthis, GlobalContext* globalCtx) { if (Flags_GetEnv(globalCtx, 5) && func_808B280C(globalCtx)) { - OnePointCutscene_Init(globalCtx, 4150, -99, &this->actor, MAIN_CAM); - func_808B29E0(this); + OnePointCutscene_Init(globalCtx, 4150, -99, &pthis->actor, MAIN_CAM); + func_808B29E0(pthis); } } -void func_808B29E0(BgSpot11Oasis* this) { - this->actionFunc = func_808B29F0; +void func_808B29E0(BgSpot11Oasis* pthis) { + pthis->actionFunc = func_808B29F0; } -void func_808B29F0(BgSpot11Oasis* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->actor.world.pos.y, 0.0f, 0.7f)) { - func_808B2AA8(this); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, FAIRY_SPAWNER); +void func_808B29F0(BgSpot11Oasis* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->actor.world.pos.y, 0.0f, 0.7f)) { + func_808B2AA8(pthis); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 40.0f, pthis->actor.world.pos.z, 0, 0, 0, FAIRY_SPAWNER); func_80078884(NA_SE_SY_CORRECT_CHIME); } - func_808B27F0(globalCtx, this->actor.world.pos.y); + func_808B27F0(globalCtx, pthis->actor.world.pos.y); } -void func_808B2AA8(BgSpot11Oasis* this) { - this->actionFunc = func_808B2AB8; +void func_808B2AA8(BgSpot11Oasis* pthis) { + pthis->actionFunc = func_808B2AB8; } -void func_808B2AB8(BgSpot11Oasis* this, GlobalContext* globalCtx) { +void func_808B2AB8(BgSpot11Oasis* pthis, GlobalContext* globalCtx) { } void BgSpot11Oasis_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot11Oasis* this = (BgSpot11Oasis*)thisx; + BgSpot11Oasis* pthis = (BgSpot11Oasis*)thisx; s32 pad; u32 gameplayFrames; Vec3f sp30; - this->actionFunc(this, globalCtx); - if (this->actionFunc == func_808B2980) { - this->actor.draw = NULL; + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc == func_808B2980) { + pthis->actor.draw = NULL; return; } - this->actor.draw = BgSpot11Oasis_Draw; - if (this->unk_150 && (this->actor.projectedPos.z < 400.0f) && (this->actor.projectedPos.z > -40.0f)) { + pthis->actor.draw = BgSpot11Oasis_Draw; + if (pthis->unk_150 && (pthis->actor.projectedPos.z < 400.0f) && (pthis->actor.projectedPos.z > -40.0f)) { gameplayFrames = globalCtx->gameplayFrames; if (gameplayFrames & 4) { - Math_Vec3f_Sum(&this->actor.world.pos, &D_808B2E34[this->unk_151], &sp30); + Math_Vec3f_Sum(&pthis->actor.world.pos, &D_808B2E34[pthis->unk_151], &sp30); EffectSsBubble_Spawn(globalCtx, &sp30, 0.0f, 15.0f, 50.0f, (Rand_ZeroOne() * 0.12f) + 0.02f); if (Rand_ZeroOne() < 0.3f) { - this->unk_151 = Rand_ZeroOne() * 4.9f; + pthis->unk_151 = Rand_ZeroOne() * 4.9f; } } } else { - this->unk_150 = 1; + pthis->unk_150 = 1; } } diff --git a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c deleted file mode 100644 index 384adc827..000000000 --- a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c +++ /dev/null @@ -1,151 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT12_GATE_Z_BG_SPOT12_GATE_C -#include "actor_common.h" -/* - * File: z_bg_spot12_gate.c - * Overlay: ovl_Bg_Spot12_Gate - * Description: Haunted Wasteland Gate - */ - -#include "z_bg_spot12_gate.h" -#include "objects/object_spot12_obj/object_spot12_obj.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_quake.h" - -#define FLAGS 0 - -void BgSpot12Gate_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot12Gate_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot12Gate_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot12Gate_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808B30C0(BgSpot12Gate* this); -void func_808B30D8(BgSpot12Gate* this, GlobalContext* globalCtx); -void func_808B3134(BgSpot12Gate* this); -void func_808B314C(BgSpot12Gate* this, GlobalContext* globalCtx); -void func_808B317C(BgSpot12Gate* this); -void func_808B318C(BgSpot12Gate* this, GlobalContext* globalCtx); -void func_808B3274(BgSpot12Gate* this); -void func_808B3298(BgSpot12Gate* this, GlobalContext* globalCtx); - -const ActorInit Bg_Spot12_Gate_InitVars = { - ACTOR_BG_SPOT12_GATE, - ACTORCAT_BG, - FLAGS, - OBJECT_SPOT12_OBJ, - sizeof(BgSpot12Gate), - (ActorFunc)BgSpot12Gate_Init, - (ActorFunc)BgSpot12Gate_Destroy, - (ActorFunc)BgSpot12Gate_Update, - (ActorFunc)BgSpot12Gate_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), -}; - -void BgSpot12Gate_InitDynaPoly(BgSpot12Gate* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, flags); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_gate.c", 145, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgSpot12Gate_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot12Gate* this = (BgSpot12Gate*)thisx; - - BgSpot12Gate_InitDynaPoly(this, globalCtx, &gGerudoFortressWastelandGateCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - func_808B3274(this); - } else { - func_808B30C0(this); - } -} - -void BgSpot12Gate_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot12Gate* this = (BgSpot12Gate*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_808B30C0(BgSpot12Gate* this) { - this->actionFunc = func_808B30D8; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; -} - -void func_808B30D8(BgSpot12Gate* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - func_808B3134(this); - OnePointCutscene_Init(globalCtx, 4160, -99, &this->dyna.actor, MAIN_CAM); - } -} - -void func_808B3134(BgSpot12Gate* this) { - this->actionFunc = func_808B314C; - this->unk_168 = 40; -} - -void func_808B314C(BgSpot12Gate* this, GlobalContext* globalCtx) { - if (this->unk_168 <= 0) { - func_808B317C(this); - } -} - -void func_808B317C(BgSpot12Gate* this) { - this->actionFunc = func_808B318C; -} - -void func_808B318C(BgSpot12Gate* this, GlobalContext* globalCtx) { - s32 pad; - s32 var; - - Math_StepToF(&this->dyna.actor.velocity.y, 1.6f, 0.03f); - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, - this->dyna.actor.velocity.y)) { - func_808B3274(this); - var = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(var, -0x3CB0); - Quake_SetQuakeValues(var, 3, 0, 0, 0); - Quake_SetCountdown(var, 0xC); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); - } -} - -void func_808B3274(BgSpot12Gate* this) { - this->actionFunc = func_808B3298; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 200.0f; -} - -void func_808B3298(BgSpot12Gate* this, GlobalContext* globalCtx) { -} - -void BgSpot12Gate_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot12Gate* this = (BgSpot12Gate*)thisx; - - if (this->unk_168 > 0) { - this->unk_168--; - } - this->actionFunc(this, globalCtx); -} - -void BgSpot12Gate_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gGerudoFortressWastelandGateDL); -} diff --git a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.cpp b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.cpp new file mode 100644 index 000000000..e52b5ebd1 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.cpp @@ -0,0 +1,151 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT12_GATE_Z_BG_SPOT12_GATE_C +#include "actor_common.h" +/* + * File: z_bg_spot12_gate.c + * Overlay: ovl_Bg_Spot12_Gate + * Description: Haunted Wasteland Gate + */ + +#include "z_bg_spot12_gate.h" +#include "objects/object_spot12_obj/object_spot12_obj.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_quake.h" + +#define FLAGS 0 + +void BgSpot12Gate_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot12Gate_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot12Gate_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot12Gate_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808B30C0(BgSpot12Gate* pthis); +void func_808B30D8(BgSpot12Gate* pthis, GlobalContext* globalCtx); +void func_808B3134(BgSpot12Gate* pthis); +void func_808B314C(BgSpot12Gate* pthis, GlobalContext* globalCtx); +void func_808B317C(BgSpot12Gate* pthis); +void func_808B318C(BgSpot12Gate* pthis, GlobalContext* globalCtx); +void func_808B3274(BgSpot12Gate* pthis); +void func_808B3298(BgSpot12Gate* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Spot12_Gate_InitVars = { + ACTOR_BG_SPOT12_GATE, + ACTORCAT_BG, + FLAGS, + OBJECT_SPOT12_OBJ, + sizeof(BgSpot12Gate), + (ActorFunc)BgSpot12Gate_Init, + (ActorFunc)BgSpot12Gate_Destroy, + (ActorFunc)BgSpot12Gate_Update, + (ActorFunc)BgSpot12Gate_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), +}; + +void BgSpot12Gate_InitDynaPoly(BgSpot12Gate* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flags); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_gate.c", 145, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgSpot12Gate_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpot12Gate* pthis = (BgSpot12Gate*)thisx; + + BgSpot12Gate_InitDynaPoly(pthis, globalCtx, &gGerudoFortressWastelandGateCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + func_808B3274(pthis); + } else { + func_808B30C0(pthis); + } +} + +void BgSpot12Gate_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot12Gate* pthis = (BgSpot12Gate*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_808B30C0(BgSpot12Gate* pthis) { + pthis->actionFunc = func_808B30D8; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; +} + +void func_808B30D8(BgSpot12Gate* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + func_808B3134(pthis); + OnePointCutscene_Init(globalCtx, 4160, -99, &pthis->dyna.actor, MAIN_CAM); + } +} + +void func_808B3134(BgSpot12Gate* pthis) { + pthis->actionFunc = func_808B314C; + pthis->unk_168 = 40; +} + +void func_808B314C(BgSpot12Gate* pthis, GlobalContext* globalCtx) { + if (pthis->unk_168 <= 0) { + func_808B317C(pthis); + } +} + +void func_808B317C(BgSpot12Gate* pthis) { + pthis->actionFunc = func_808B318C; +} + +void func_808B318C(BgSpot12Gate* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 var; + + Math_StepToF(&pthis->dyna.actor.velocity.y, 1.6f, 0.03f); + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 200.0f, + pthis->dyna.actor.velocity.y)) { + func_808B3274(pthis); + var = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(var, -0x3CB0); + Quake_SetQuakeValues(var, 3, 0, 0, 0); + Quake_SetCountdown(var, 0xC); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + } +} + +void func_808B3274(BgSpot12Gate* pthis) { + pthis->actionFunc = func_808B3298; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + 200.0f; +} + +void func_808B3298(BgSpot12Gate* pthis, GlobalContext* globalCtx) { +} + +void BgSpot12Gate_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot12Gate* pthis = (BgSpot12Gate*)thisx; + + if (pthis->unk_168 > 0) { + pthis->unk_168--; + } + pthis->actionFunc(pthis, globalCtx); +} + +void BgSpot12Gate_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gGerudoFortressWastelandGateDL); +} diff --git a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c deleted file mode 100644 index c361a69a2..000000000 --- a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c +++ /dev/null @@ -1,143 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT12_SAKU_Z_BG_SPOT12_SAKU_C -#include "actor_common.h" -/* - * File: z_bg_spot12_saku.c - * Overlay: ovl_Bg_Spot12_Saku - * Description: - */ - -#include "z_bg_spot12_saku.h" -#include "objects/object_spot12_obj/object_spot12_obj.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS 0 - -void BgSpot12Saku_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot12Saku_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot12Saku_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot12Saku_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808B3550(BgSpot12Saku* this); -void func_808B357C(BgSpot12Saku* this, GlobalContext* globalCtx); -void func_808B35E4(BgSpot12Saku* this); -void func_808B3604(BgSpot12Saku* this, GlobalContext* globalCtx); -void func_808B3714(BgSpot12Saku* this); -void func_808B37AC(BgSpot12Saku* this, GlobalContext* globalCtx); - -const ActorInit Bg_Spot12_Saku_InitVars = { - ACTOR_BG_SPOT12_SAKU, - ACTORCAT_BG, - FLAGS, - OBJECT_SPOT12_OBJ, - sizeof(BgSpot12Saku), - (ActorFunc)BgSpot12Saku_Init, - (ActorFunc)BgSpot12Saku_Destroy, - (ActorFunc)BgSpot12Saku_Update, - (ActorFunc)BgSpot12Saku_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void func_808B3420(BgSpot12Saku* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, flags); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_saku.c", 140, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void BgSpot12Saku_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot12Saku* this = (BgSpot12Saku*)thisx; - - func_808B3420(this, globalCtx, &gGerudoFortressGTGShutterCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - func_808B3714(this); - } else { - func_808B3550(this); - } -} - -void BgSpot12Saku_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot12Saku* this = (BgSpot12Saku*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_808B3550(BgSpot12Saku* this) { - this->actionFunc = func_808B357C; - this->dyna.actor.scale.x = 0.1f; - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; -} - -void func_808B357C(BgSpot12Saku* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - func_808B35E4(this); - this->timer = 20; - OnePointCutscene_Init(globalCtx, 4170, -99, &this->dyna.actor, MAIN_CAM); - } -} - -void func_808B35E4(BgSpot12Saku* this) { - if (this->timer == 0) { - this->actionFunc = func_808B3604; - } -} - -void func_808B3604(BgSpot12Saku* this, GlobalContext* globalCtx) { - f32 temp_ret = Math_SmoothStepToF(&this->dyna.actor.scale.x, 0.001f / 0.14f, 0.16f, 0.0022f, 0.001f); - f32 temp_f18 = ((0.1f - this->dyna.actor.scale.x) * 840.0f); - - this->dyna.actor.world.pos.x = - this->dyna.actor.home.pos.x - (Math_SinS(this->dyna.actor.shape.rot.y + 0x4000) * temp_f18); - this->dyna.actor.world.pos.z = - this->dyna.actor.home.pos.z - (Math_CosS(this->dyna.actor.shape.rot.y + 0x4000) * temp_f18); - if (fabsf(temp_ret) < 0.0001f) { - func_808B3714(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); - } -} - -void func_808B3714(BgSpot12Saku* this) { - this->actionFunc = func_808B37AC; - this->dyna.actor.scale.x = 0.001f / 0.14f; - this->dyna.actor.world.pos.x = - this->dyna.actor.home.pos.x - (Math_SinS(this->dyna.actor.shape.rot.y + 0x4000) * 78.0f); - this->dyna.actor.world.pos.z = - this->dyna.actor.home.pos.z - (Math_CosS(this->dyna.actor.shape.rot.y + 0x4000) * 78.0f); -} - -void func_808B37AC(BgSpot12Saku* this, GlobalContext* globalCtx) { -} - -void BgSpot12Saku_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot12Saku* this = (BgSpot12Saku*)thisx; - - if (this->timer > 0) { - this->timer--; - } - this->actionFunc(this, globalCtx); -} - -void BgSpot12Saku_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gGerudoFortressGTGShutterDL); -} diff --git a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.cpp b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.cpp new file mode 100644 index 000000000..8017ec9e5 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.cpp @@ -0,0 +1,143 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT12_SAKU_Z_BG_SPOT12_SAKU_C +#include "actor_common.h" +/* + * File: z_bg_spot12_saku.c + * Overlay: ovl_Bg_Spot12_Saku + * Description: + */ + +#include "z_bg_spot12_saku.h" +#include "objects/object_spot12_obj/object_spot12_obj.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS 0 + +void BgSpot12Saku_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot12Saku_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot12Saku_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot12Saku_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808B3550(BgSpot12Saku* pthis); +void func_808B357C(BgSpot12Saku* pthis, GlobalContext* globalCtx); +void func_808B35E4(BgSpot12Saku* pthis); +void func_808B3604(BgSpot12Saku* pthis, GlobalContext* globalCtx); +void func_808B3714(BgSpot12Saku* pthis); +void func_808B37AC(BgSpot12Saku* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Spot12_Saku_InitVars = { + ACTOR_BG_SPOT12_SAKU, + ACTORCAT_BG, + FLAGS, + OBJECT_SPOT12_OBJ, + sizeof(BgSpot12Saku), + (ActorFunc)BgSpot12Saku_Init, + (ActorFunc)BgSpot12Saku_Destroy, + (ActorFunc)BgSpot12Saku_Update, + (ActorFunc)BgSpot12Saku_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void func_808B3420(BgSpot12Saku* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flags); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_saku.c", 140, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void BgSpot12Saku_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpot12Saku* pthis = (BgSpot12Saku*)thisx; + + func_808B3420(pthis, globalCtx, &gGerudoFortressGTGShutterCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + func_808B3714(pthis); + } else { + func_808B3550(pthis); + } +} + +void BgSpot12Saku_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot12Saku* pthis = (BgSpot12Saku*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_808B3550(BgSpot12Saku* pthis) { + pthis->actionFunc = func_808B357C; + pthis->dyna.actor.scale.x = 0.1f; + pthis->dyna.actor.world.pos.x = pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = pthis->dyna.actor.home.pos.z; +} + +void func_808B357C(BgSpot12Saku* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + func_808B35E4(pthis); + pthis->timer = 20; + OnePointCutscene_Init(globalCtx, 4170, -99, &pthis->dyna.actor, MAIN_CAM); + } +} + +void func_808B35E4(BgSpot12Saku* pthis) { + if (pthis->timer == 0) { + pthis->actionFunc = func_808B3604; + } +} + +void func_808B3604(BgSpot12Saku* pthis, GlobalContext* globalCtx) { + f32 temp_ret = Math_SmoothStepToF(&pthis->dyna.actor.scale.x, 0.001f / 0.14f, 0.16f, 0.0022f, 0.001f); + f32 temp_f18 = ((0.1f - pthis->dyna.actor.scale.x) * 840.0f); + + pthis->dyna.actor.world.pos.x = + pthis->dyna.actor.home.pos.x - (Math_SinS(pthis->dyna.actor.shape.rot.y + 0x4000) * temp_f18); + pthis->dyna.actor.world.pos.z = + pthis->dyna.actor.home.pos.z - (Math_CosS(pthis->dyna.actor.shape.rot.y + 0x4000) * temp_f18); + if (fabsf(temp_ret) < 0.0001f) { + func_808B3714(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + } +} + +void func_808B3714(BgSpot12Saku* pthis) { + pthis->actionFunc = func_808B37AC; + pthis->dyna.actor.scale.x = 0.001f / 0.14f; + pthis->dyna.actor.world.pos.x = + pthis->dyna.actor.home.pos.x - (Math_SinS(pthis->dyna.actor.shape.rot.y + 0x4000) * 78.0f); + pthis->dyna.actor.world.pos.z = + pthis->dyna.actor.home.pos.z - (Math_CosS(pthis->dyna.actor.shape.rot.y + 0x4000) * 78.0f); +} + +void func_808B37AC(BgSpot12Saku* pthis, GlobalContext* globalCtx) { +} + +void BgSpot12Saku_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot12Saku* pthis = (BgSpot12Saku*)thisx; + + if (pthis->timer > 0) { + pthis->timer--; + } + pthis->actionFunc(pthis, globalCtx); +} + +void BgSpot12Saku_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gGerudoFortressGTGShutterDL); +} diff --git a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c deleted file mode 100644 index 1ab082822..000000000 --- a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c +++ /dev/null @@ -1,376 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT15_RRBOX_Z_BG_SPOT15_RRBOX_C -#include "actor_common.h" -/* - * File: z_bg_spot15_rrbox.c - * Overlay: ovl_Bg_Spot15_Rrbox - * Description: Milk Crate - */ - -#include "z_bg_spot15_rrbox.h" -#include "objects/object_spot15_obj/object_spot15_obj.h" -#include "def/code_80043480.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void BgSpot15Rrbox_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot15Rrbox_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot15Rrbox_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot15Rrbox_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808B4084(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B40AC(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B4194(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B4380(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B43D0(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B44B8(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B4178(BgSpot15Rrbox* this, GlobalContext* globalCtx); -void func_808B44CC(BgSpot15Rrbox* this, GlobalContext* globalCtx); - -static s16 D_808B4590 = 0; - -const ActorInit Bg_Spot15_Rrbox_InitVars = { - ACTOR_BG_SPOT15_RRBOX, - ACTORCAT_BG, - FLAGS, - OBJECT_SPOT15_OBJ, - sizeof(BgSpot15Rrbox), - (ActorFunc)BgSpot15Rrbox_Init, - (ActorFunc)BgSpot15Rrbox_Destroy, - (ActorFunc)BgSpot15Rrbox_Update, - (ActorFunc)BgSpot15Rrbox_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -static Vec3f D_808B45C4[] = { - { 770.0f, 1490.0f, -299.0f }, - { 770.0f, 1550.0f, -299.0f }, -}; - -static Vec3f D_808B45DC[] = { - { 29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, 29.99f }, - { 29.99f, 0.01f, 29.99f }, { 0.0f, 0.01f, 0.0f }, -}; - -void func_808B3960(BgSpot15Rrbox* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { - s32 pad; - CollisionHeader* colHeader = NULL; - u32 pad2; - - DynaPolyActor_Init(&this->dyna, flags); - CollisionHeader_GetVirtual(collision, &colHeader); - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 171, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void func_808B39E8(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3) { - arg0->x = (arg1->z * arg2) + (arg1->x * arg3); - arg0->y = arg1->y; - arg0->z = (arg1->z * arg3) - (arg1->x * arg2); -} - -void func_808B3A34(BgSpot15Rrbox* this) { - this->bgId = BG_ACTOR_MAX; -} - -s32 func_808B3A40(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->bgId); - - if ((dynaPolyActor != NULL) && - Math3D_Dist2DSq(dynaPolyActor->actor.world.pos.x, dynaPolyActor->actor.world.pos.z, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z) < 0.01f) { - return true; - } - return false; -} - -s32 func_808B3AAC(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - s16 rotY; - Actor* actor = &this->dyna.actor; - - if (globalCtx->sceneNum == SCENE_SOUKO) { - return true; - } else if (func_808B3A40(this, globalCtx)) { - return false; - } - - if (actor->world.pos.x <= 930.0f && actor->world.pos.z >= -360.0f) { - if (this->dyna.unk_150 >= 0.0f) { - rotY = actor->world.rot.y; - } else { - rotY = actor->world.rot.y + 0x8000; - } - - if (rotY < 0x2000 && rotY > -0x6000) { - return gSaveContext.eventChkInf[1] & 0x10; - } - return true; - } - - return true; -} - -void BgSpot15Rrbox_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot15Rrbox* this = (BgSpot15Rrbox*)thisx; - - func_808B3960(this, globalCtx, &gLonLonMilkCrateCol, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - func_808B3A34(this); - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) { - func_808B44B8(this, globalCtx); - this->dyna.actor.world.pos = D_808B45C4[D_808B4590]; - D_808B4590++; - } else { - func_808B4084(this, globalCtx); - } - osSyncPrintf("(spot15 ロンロン木箱)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void BgSpot15Rrbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot15Rrbox* this = (BgSpot15Rrbox*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - D_808B4590 = 0; -} - -s32 func_808B3CA0(BgSpot15Rrbox* this, GlobalContext* globalCtx, s32 arg2) { - f32 chkDist = 0.0f; - Vec3f actorPosition; - Vec3f actorScale; - - func_808B3A34(this); - - actorScale.x = D_808B45DC[arg2].x * (this->dyna.actor.scale.x * 10.0f); - actorScale.y = D_808B45DC[arg2].y * (this->dyna.actor.scale.y * 10.0f); - actorScale.z = D_808B45DC[arg2].z * (this->dyna.actor.scale.z * 10.0f); - - func_808B39E8(&actorPosition, &actorScale, this->unk_16C, this->unk_170); - - actorPosition.x += this->dyna.actor.world.pos.x; - actorPosition.y += this->dyna.actor.prevPos.y; - actorPosition.z += this->dyna.actor.world.pos.z; - - this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &this->dyna.actor.floorPoly, - &this->bgId, &this->dyna.actor, &actorPosition, chkDist); - - if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= -0.001f) { - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - return true; - } - return false; -} - -f32 func_808B3DDC(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - s32 i; - Vec3f position; - Vec3f scale; - Actor* actor = &this->dyna.actor; - f32 yIntersect; - f32 returnValue = BGCHECK_Y_MIN; - s32 bgId; - - func_808B3A34(this); - for (i = 0; i < ARRAY_COUNT(D_808B45DC); i++) { - scale.x = D_808B45DC[i].x * (actor->scale.x * 10.0f); - scale.y = D_808B45DC[i].y * (actor->scale.y * 10.0f); - scale.z = D_808B45DC[i].z * (actor->scale.z * 10.0f); - - func_808B39E8(&position, &scale, this->unk_16C, this->unk_170); - - position.x += actor->world.pos.x; - position.y += actor->prevPos.y; - position.z += actor->world.pos.z; - - yIntersect = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &actor->floorPoly, &bgId, actor, &position, 0); - - if (returnValue < yIntersect) { - returnValue = yIntersect; - this->bgId = bgId; - } - } - return returnValue; -} - -s32 func_808B3F58(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - if (func_808B3CA0(this, globalCtx, 0)) { - return true; - } - if (func_808B3CA0(this, globalCtx, 1)) { - return true; - } - if (func_808B3CA0(this, globalCtx, 2)) { - return true; - } - if (func_808B3CA0(this, globalCtx, 3)) { - return true; - } - if (func_808B3CA0(this, globalCtx, 4)) { - return true; - } - return false; -} - -s32 func_808B4010(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - return !func_800435D8(globalCtx, &this->dyna, this->dyna.actor.scale.x * 290.0f, - this->dyna.actor.scale.x * 290.0f + 20.0f, 1.0f); -} - -void func_808B4084(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - this->actionFunc = func_808B40AC; - this->dyna.actor.gravity = 0.0f; - this->dyna.actor.velocity.x = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.velocity.z = 0.0f; -} - -void func_808B40AC(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->unk_168 <= 0 && fabsf(this->dyna.unk_150) > 0.001f) { - if (func_808B3AAC(this, globalCtx) && !func_808B4010(this, globalCtx)) { - this->unk_17C = this->dyna.unk_150; - func_808B4178(this, globalCtx); - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } -} - -void func_808B4178(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - this->actionFunc = func_808B4194; - this->dyna.actor.gravity = 0.0f; -} - -void func_808B4194(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - f32 sign; - Player* player = GET_PLAYER(globalCtx); - f32 tempUnk178; - s32 approxFResult; - Actor* actor = &this->dyna.actor; - - this->unk_174 += 0.5f; - - this->unk_174 = CLAMP_MAX(this->unk_174, 2.0f); - - approxFResult = Math_StepToF(&this->unk_178, 20.0f, this->unk_174); - - sign = this->unk_17C >= 0.0f ? 1.0f : -1.0f; - - tempUnk178 = (f32)sign * this->unk_178; - actor->world.pos.x = actor->home.pos.x + (tempUnk178 * this->unk_16C); - actor->world.pos.z = actor->home.pos.z + (tempUnk178 * this->unk_170); - - if (!func_808B3F58(this, globalCtx)) { - actor->home.pos.x = actor->world.pos.x; - actor->home.pos.z = actor->world.pos.z; - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - this->unk_178 = 0.0f; - this->unk_174 = 0.0f; - func_808B4380(this, globalCtx); - } else if (approxFResult) { - player = GET_PLAYER(globalCtx); - if (func_808B4010(this, globalCtx)) { - Audio_PlayActorSound2(actor, NA_SE_EV_WOOD_BOUND); - } - if (func_808B3A40(this, globalCtx)) { - func_80078884(NA_SE_SY_CORRECT_CHIME); - } - actor->home.pos.x = actor->world.pos.x; - actor->home.pos.z = actor->world.pos.z; - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - this->unk_178 = 0.0f; - this->unk_174 = 0.0f; - this->unk_168 = 10; - func_808B4084(this, globalCtx); - } - Audio_PlayActorSound2(actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); -} - -void func_808B4380(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - this->dyna.actor.velocity.x = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.velocity.z = 0.0f; - this->dyna.actor.gravity = -1.0f; - this->dyna.actor.floorHeight = func_808B3DDC(this, globalCtx); - this->actionFunc = func_808B43D0; -} - -void func_808B43D0(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - f32 floorHeight; - Player* player = GET_PLAYER(globalCtx); - Actor* actor = &this->dyna.actor; - - if (fabsf(this->dyna.unk_150) > 0.001f) { - this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; - } - - Actor_MoveForward(actor); - - if (actor->world.pos.y <= BGCHECK_Y_MIN + 10.0f) { - // "Lon Lon wooden crate fell too much" - osSyncPrintf("Warning : ロンロン木箱落ちすぎた(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 599, - actor->params); - - Actor_Kill(actor); - - return; - } - - floorHeight = actor->floorHeight; - - if ((floorHeight - actor->world.pos.y) >= -0.001f) { - actor->world.pos.y = floorHeight; - func_808B4084(this, globalCtx); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WOOD_BOUND); - } -} - -void func_808B44B8(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - this->actionFunc = func_808B44CC; -} - -void func_808B44CC(BgSpot15Rrbox* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; -} - -void BgSpot15Rrbox_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot15Rrbox* this = (BgSpot15Rrbox*)thisx; - - if (this->unk_168 > 0) { - this->unk_168--; - } - this->dyna.actor.world.rot.y = this->dyna.unk_158; - this->unk_16C = Math_SinS(this->dyna.actor.world.rot.y); - this->unk_170 = Math_CosS(this->dyna.actor.world.rot.y); - this->actionFunc(this, globalCtx); -} - -void BgSpot15Rrbox_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gLonLonMilkCrateDL); -} diff --git a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.cpp b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.cpp new file mode 100644 index 000000000..0d1f7a260 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.cpp @@ -0,0 +1,376 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT15_RRBOX_Z_BG_SPOT15_RRBOX_C +#include "actor_common.h" +/* + * File: z_bg_spot15_rrbox.c + * Overlay: ovl_Bg_Spot15_Rrbox + * Description: Milk Crate + */ + +#include "z_bg_spot15_rrbox.h" +#include "objects/object_spot15_obj/object_spot15_obj.h" +#include "def/code_80043480.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void BgSpot15Rrbox_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot15Rrbox_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot15Rrbox_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot15Rrbox_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808B4084(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B40AC(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B4194(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B4380(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B43D0(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B44B8(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B4178(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); +void func_808B44CC(BgSpot15Rrbox* pthis, GlobalContext* globalCtx); + +static s16 D_808B4590 = 0; + +ActorInit Bg_Spot15_Rrbox_InitVars = { + ACTOR_BG_SPOT15_RRBOX, + ACTORCAT_BG, + FLAGS, + OBJECT_SPOT15_OBJ, + sizeof(BgSpot15Rrbox), + (ActorFunc)BgSpot15Rrbox_Init, + (ActorFunc)BgSpot15Rrbox_Destroy, + (ActorFunc)BgSpot15Rrbox_Update, + (ActorFunc)BgSpot15Rrbox_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +static Vec3f D_808B45C4[] = { + { 770.0f, 1490.0f, -299.0f }, + { 770.0f, 1550.0f, -299.0f }, +}; + +static Vec3f D_808B45DC[] = { + { 29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, 29.99f }, + { 29.99f, 0.01f, 29.99f }, { 0.0f, 0.01f, 0.0f }, +}; + +void func_808B3960(BgSpot15Rrbox* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { + s32 pad; + CollisionHeader* colHeader = NULL; + u32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flags); + CollisionHeader_GetVirtual(collision, &colHeader); + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 171, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void func_808B39E8(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3) { + arg0->x = (arg1->z * arg2) + (arg1->x * arg3); + arg0->y = arg1->y; + arg0->z = (arg1->z * arg3) - (arg1->x * arg2); +} + +void func_808B3A34(BgSpot15Rrbox* pthis) { + pthis->bgId = BG_ACTOR_MAX; +} + +s32 func_808B3A40(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->bgId); + + if ((dynaPolyActor != NULL) && + Math3D_Dist2DSq(dynaPolyActor->actor.world.pos.x, dynaPolyActor->actor.world.pos.z, + pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.z) < 0.01f) { + return true; + } + return false; +} + +s32 func_808B3AAC(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + s16 rotY; + Actor* actor = &pthis->dyna.actor; + + if (globalCtx->sceneNum == SCENE_SOUKO) { + return true; + } else if (func_808B3A40(pthis, globalCtx)) { + return false; + } + + if (actor->world.pos.x <= 930.0f && actor->world.pos.z >= -360.0f) { + if (pthis->dyna.unk_150 >= 0.0f) { + rotY = actor->world.rot.y; + } else { + rotY = actor->world.rot.y + 0x8000; + } + + if (rotY < 0x2000 && rotY > -0x6000) { + return gSaveContext.eventChkInf[1] & 0x10; + } + return true; + } + + return true; +} + +void BgSpot15Rrbox_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpot15Rrbox* pthis = (BgSpot15Rrbox*)thisx; + + func_808B3960(pthis, globalCtx, &gLonLonMilkCrateCol, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + func_808B3A34(pthis); + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F))) { + func_808B44B8(pthis, globalCtx); + pthis->dyna.actor.world.pos = D_808B45C4[D_808B4590]; + D_808B4590++; + } else { + func_808B4084(pthis, globalCtx); + } + osSyncPrintf("(spot15 ロンロン木箱)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void BgSpot15Rrbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot15Rrbox* pthis = (BgSpot15Rrbox*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + D_808B4590 = 0; +} + +s32 func_808B3CA0(BgSpot15Rrbox* pthis, GlobalContext* globalCtx, s32 arg2) { + f32 chkDist = 0.0f; + Vec3f actorPosition; + Vec3f actorScale; + + func_808B3A34(pthis); + + actorScale.x = D_808B45DC[arg2].x * (pthis->dyna.actor.scale.x * 10.0f); + actorScale.y = D_808B45DC[arg2].y * (pthis->dyna.actor.scale.y * 10.0f); + actorScale.z = D_808B45DC[arg2].z * (pthis->dyna.actor.scale.z * 10.0f); + + func_808B39E8(&actorPosition, &actorScale, pthis->unk_16C, pthis->unk_170); + + actorPosition.x += pthis->dyna.actor.world.pos.x; + actorPosition.y += pthis->dyna.actor.prevPos.y; + actorPosition.z += pthis->dyna.actor.world.pos.z; + + pthis->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, + &pthis->bgId, &pthis->dyna.actor, &actorPosition, chkDist); + + if ((pthis->dyna.actor.floorHeight - pthis->dyna.actor.world.pos.y) >= -0.001f) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + return true; + } + return false; +} + +f32 func_808B3DDC(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f position; + Vec3f scale; + Actor* actor = &pthis->dyna.actor; + f32 yIntersect; + f32 returnValue = BGCHECK_Y_MIN; + s32 bgId; + + func_808B3A34(pthis); + for (i = 0; i < ARRAY_COUNT(D_808B45DC); i++) { + scale.x = D_808B45DC[i].x * (actor->scale.x * 10.0f); + scale.y = D_808B45DC[i].y * (actor->scale.y * 10.0f); + scale.z = D_808B45DC[i].z * (actor->scale.z * 10.0f); + + func_808B39E8(&position, &scale, pthis->unk_16C, pthis->unk_170); + + position.x += actor->world.pos.x; + position.y += actor->prevPos.y; + position.z += actor->world.pos.z; + + yIntersect = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &actor->floorPoly, &bgId, actor, &position, 0); + + if (returnValue < yIntersect) { + returnValue = yIntersect; + pthis->bgId = bgId; + } + } + return returnValue; +} + +s32 func_808B3F58(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + if (func_808B3CA0(pthis, globalCtx, 0)) { + return true; + } + if (func_808B3CA0(pthis, globalCtx, 1)) { + return true; + } + if (func_808B3CA0(pthis, globalCtx, 2)) { + return true; + } + if (func_808B3CA0(pthis, globalCtx, 3)) { + return true; + } + if (func_808B3CA0(pthis, globalCtx, 4)) { + return true; + } + return false; +} + +s32 func_808B4010(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + return !func_800435D8(globalCtx, &pthis->dyna, pthis->dyna.actor.scale.x * 290.0f, + pthis->dyna.actor.scale.x * 290.0f + 20.0f, 1.0f); +} + +void func_808B4084(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = func_808B40AC; + pthis->dyna.actor.gravity = 0.0f; + pthis->dyna.actor.velocity.x = 0.0f; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.velocity.z = 0.0f; +} + +void func_808B40AC(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->unk_168 <= 0 && fabsf(pthis->dyna.unk_150) > 0.001f) { + if (func_808B3AAC(pthis, globalCtx) && !func_808B4010(pthis, globalCtx)) { + pthis->unk_17C = pthis->dyna.unk_150; + func_808B4178(pthis, globalCtx); + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } +} + +void func_808B4178(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = func_808B4194; + pthis->dyna.actor.gravity = 0.0f; +} + +void func_808B4194(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + f32 sign; + Player* player = GET_PLAYER(globalCtx); + f32 tempUnk178; + s32 approxFResult; + Actor* actor = &pthis->dyna.actor; + + pthis->unk_174 += 0.5f; + + pthis->unk_174 = CLAMP_MAX(pthis->unk_174, 2.0f); + + approxFResult = Math_StepToF(&pthis->unk_178, 20.0f, pthis->unk_174); + + sign = pthis->unk_17C >= 0.0f ? 1.0f : -1.0f; + + tempUnk178 = (f32)sign * pthis->unk_178; + actor->world.pos.x = actor->home.pos.x + (tempUnk178 * pthis->unk_16C); + actor->world.pos.z = actor->home.pos.z + (tempUnk178 * pthis->unk_170); + + if (!func_808B3F58(pthis, globalCtx)) { + actor->home.pos.x = actor->world.pos.x; + actor->home.pos.z = actor->world.pos.z; + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + pthis->unk_178 = 0.0f; + pthis->unk_174 = 0.0f; + func_808B4380(pthis, globalCtx); + } else if (approxFResult) { + player = GET_PLAYER(globalCtx); + if (func_808B4010(pthis, globalCtx)) { + Audio_PlayActorSound2(actor, NA_SE_EV_WOOD_BOUND); + } + if (func_808B3A40(pthis, globalCtx)) { + func_80078884(NA_SE_SY_CORRECT_CHIME); + } + actor->home.pos.x = actor->world.pos.x; + actor->home.pos.z = actor->world.pos.z; + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + pthis->unk_178 = 0.0f; + pthis->unk_174 = 0.0f; + pthis->unk_168 = 10; + func_808B4084(pthis, globalCtx); + } + Audio_PlayActorSound2(actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); +} + +void func_808B4380(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.velocity.x = 0.0f; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.velocity.z = 0.0f; + pthis->dyna.actor.gravity = -1.0f; + pthis->dyna.actor.floorHeight = func_808B3DDC(pthis, globalCtx); + pthis->actionFunc = func_808B43D0; +} + +void func_808B43D0(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + f32 floorHeight; + Player* player = GET_PLAYER(globalCtx); + Actor* actor = &pthis->dyna.actor; + + if (fabsf(pthis->dyna.unk_150) > 0.001f) { + pthis->dyna.unk_150 = 0.0f; + player->stateFlags2 &= ~0x10; + } + + Actor_MoveForward(actor); + + if (actor->world.pos.y <= BGCHECK_Y_MIN + 10.0f) { + // "Lon Lon wooden crate fell too much" + osSyncPrintf("Warning : ロンロン木箱落ちすぎた(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 599, + actor->params); + + Actor_Kill(actor); + + return; + } + + floorHeight = actor->floorHeight; + + if ((floorHeight - actor->world.pos.y) >= -0.001f) { + actor->world.pos.y = floorHeight; + func_808B4084(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WOOD_BOUND); + } +} + +void func_808B44B8(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = func_808B44CC; +} + +void func_808B44CC(BgSpot15Rrbox* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; +} + +void BgSpot15Rrbox_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot15Rrbox* pthis = (BgSpot15Rrbox*)thisx; + + if (pthis->unk_168 > 0) { + pthis->unk_168--; + } + pthis->dyna.actor.world.rot.y = pthis->dyna.unk_158; + pthis->unk_16C = Math_SinS(pthis->dyna.actor.world.rot.y); + pthis->unk_170 = Math_CosS(pthis->dyna.actor.world.rot.y); + pthis->actionFunc(pthis, globalCtx); +} + +void BgSpot15Rrbox_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gLonLonMilkCrateDL); +} diff --git a/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c b/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.cpp similarity index 50% rename from src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c rename to src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.cpp index 2710c8d2c..a77e7b972 100644 --- a/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c +++ b/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.cpp @@ -22,11 +22,11 @@ void BgSpot15Saku_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot15Saku_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot15Saku_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B4930(BgSpot15Saku* this, GlobalContext* globalCtx); -void func_808B4978(BgSpot15Saku* this, GlobalContext* globalCtx); -void func_808B4A04(BgSpot15Saku* this, GlobalContext* globalCtx); +void func_808B4930(BgSpot15Saku* pthis, GlobalContext* globalCtx); +void func_808B4978(BgSpot15Saku* pthis, GlobalContext* globalCtx); +void func_808B4A04(BgSpot15Saku* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Spot15_Saku_InitVars = { +ActorInit Bg_Spot15_Saku_InitVars = { ACTOR_BG_SPOT15_SAKU, ACTORCAT_ITEMACTION, FLAGS, @@ -40,65 +40,65 @@ const ActorInit Bg_Spot15_Saku_InitVars = { void BgSpot15Saku_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgSpot15Saku* this = (BgSpot15Saku*)thisx; + BgSpot15Saku* pthis = (BgSpot15Saku*)thisx; s32 pad2; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gLonLonCorralFenceCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->dyna.actor.scale.x = 0.1f; - this->dyna.actor.scale.y = 0.1f; - this->dyna.actor.scale.z = 0.1f; - this->unk_170.x = this->dyna.actor.world.pos.x; - this->unk_170.y = this->dyna.actor.world.pos.y; - this->unk_170.z = this->dyna.actor.world.pos.z; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->dyna.actor.scale.x = 0.1f; + pthis->dyna.actor.scale.y = 0.1f; + pthis->dyna.actor.scale.z = 0.1f; + pthis->unk_170.x = pthis->dyna.actor.world.pos.x; + pthis->unk_170.y = pthis->dyna.actor.world.pos.y; + pthis->unk_170.z = pthis->dyna.actor.world.pos.z; if (gSaveContext.infTable[7] & 2) { - this->dyna.actor.world.pos.z = 2659.0f; + pthis->dyna.actor.world.pos.z = 2659.0f; } - this->actionFunc = func_808B4930; + pthis->actionFunc = func_808B4930; } void BgSpot15Saku_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot15Saku* this = (BgSpot15Saku*)thisx; + BgSpot15Saku* pthis = (BgSpot15Saku*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808B4930(BgSpot15Saku* this, GlobalContext* globalCtx) { - if (this->unk_168 && !(gSaveContext.infTable[7] & 2)) { - this->timer = 2; - this->actionFunc = func_808B4978; +void func_808B4930(BgSpot15Saku* pthis, GlobalContext* globalCtx) { + if (pthis->unk_168 && !(gSaveContext.infTable[7] & 2)) { + pthis->timer = 2; + pthis->actionFunc = func_808B4978; } } -void func_808B4978(BgSpot15Saku* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); - this->dyna.actor.world.pos.z -= 2.0f; - if (this->dyna.actor.world.pos.z < 2660.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); - this->timer = 30; - this->actionFunc = func_808B4A04; +void func_808B4978(BgSpot15Saku* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + pthis->dyna.actor.world.pos.z -= 2.0f; + if (pthis->dyna.actor.world.pos.z < 2660.0f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + pthis->timer = 30; + pthis->actionFunc = func_808B4A04; } } } -void func_808B4A04(BgSpot15Saku* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - this->unk_168 = 0; - this->actionFunc = func_808B4930; +void func_808B4A04(BgSpot15Saku* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + pthis->unk_168 = 0; + pthis->actionFunc = func_808B4930; } } void BgSpot15Saku_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot15Saku* this = (BgSpot15Saku*)thisx; + BgSpot15Saku* pthis = (BgSpot15Saku*)thisx; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgSpot15Saku_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.cpp similarity index 59% rename from src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c rename to src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.cpp index 449599436..ae70d00f7 100644 --- a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c +++ b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.cpp @@ -25,14 +25,14 @@ void BgSpot16Bombstone_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot16Bombstone_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot16Bombstone_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B5A94(BgSpot16Bombstone* this, GlobalContext* globalCtx); -void func_808B5B04(BgSpot16Bombstone* this, GlobalContext* globalCtx); -void func_808B5B6C(BgSpot16Bombstone* this, GlobalContext* globalCtx); -void func_808B5B58(BgSpot16Bombstone* this); -void func_808B5950(BgSpot16Bombstone* this, GlobalContext* globalCtx); -void func_808B5934(BgSpot16Bombstone* this); -void func_808B5AF0(BgSpot16Bombstone* this); -void func_808B5A78(BgSpot16Bombstone* this); +void func_808B5A94(BgSpot16Bombstone* pthis, GlobalContext* globalCtx); +void func_808B5B04(BgSpot16Bombstone* pthis, GlobalContext* globalCtx); +void func_808B5B6C(BgSpot16Bombstone* pthis, GlobalContext* globalCtx); +void func_808B5B58(BgSpot16Bombstone* pthis); +void func_808B5950(BgSpot16Bombstone* pthis, GlobalContext* globalCtx); +void func_808B5934(BgSpot16Bombstone* pthis); +void func_808B5AF0(BgSpot16Bombstone* pthis); +void func_808B5A78(BgSpot16Bombstone* pthis); static EnBombf* sPlayerBomb = NULL; @@ -123,7 +123,7 @@ static s16 D_808B5EB0[][7] = { { 0x0014, 0x0050, 0x0032, 0x0000, 0x0096, 0x00C8, 0x0008 }, }; -const ActorInit Bg_Spot16_Bombstone_InitVars = { +ActorInit Bg_Spot16_Bombstone_InitVars = { ACTOR_BG_SPOT16_BOMBSTONE, ACTORCAT_PROP, FLAGS, @@ -157,52 +157,52 @@ static f32 D_808B6074[] = { 66.0f, 51.0f, 48.0f, 36.0f, 21.0f }; static s16 D_808B6088[] = { 0, 1, 2, 3, 4 }; -void func_808B4C30(BgSpot16Bombstone* this) { - this->switchFlag = (this->actor.params >> 8) & 0x3F; - this->actor.params = this->actor.params & 0xFF; +void func_808B4C30(BgSpot16Bombstone* pthis) { + pthis->switchFlag = (pthis->actor.params >> 8) & 0x3F; + pthis->actor.params = pthis->actor.params & 0xFF; } -void func_808B4C4C(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B4C4C(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitJntSph(globalCtx, &this->colliderJntSph); - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderElements); - this->colliderJntSph.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; - this->colliderJntSph.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + 50.0f; - this->colliderJntSph.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - this->colliderJntSph.elements[0].dim.worldSphere.radius = 120; + Collider_InitJntSph(globalCtx, &pthis->colliderJntSph); + Collider_SetJntSph(globalCtx, &pthis->colliderJntSph, &pthis->actor, &sJntSphInit, pthis->colliderElements); + pthis->colliderJntSph.elements[0].dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->colliderJntSph.elements[0].dim.worldSphere.center.y = pthis->actor.world.pos.y + 50.0f; + pthis->colliderJntSph.elements[0].dim.worldSphere.center.z = pthis->actor.world.pos.z; + pthis->colliderJntSph.elements[0].dim.worldSphere.radius = 120; } -void func_808B4D04(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B4D04(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { s32 pad; - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - this->colliderCylinder.dim.pos.x += (s16)this->actor.world.pos.x; - this->colliderCylinder.dim.pos.y += (s16)this->actor.world.pos.y; - this->colliderCylinder.dim.pos.z += (s16)this->actor.world.pos.z; + Collider_InitCylinder(globalCtx, &pthis->colliderCylinder); + Collider_SetCylinder(globalCtx, &pthis->colliderCylinder, &pthis->actor, &sCylinderInit); + pthis->colliderCylinder.dim.pos.x += (s16)pthis->actor.world.pos.x; + pthis->colliderCylinder.dim.pos.y += (s16)pthis->actor.world.pos.y; + pthis->colliderCylinder.dim.pos.z += (s16)pthis->actor.world.pos.z; } -s32 func_808B4D9C(BgSpot16Bombstone* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { +s32 func_808B4D9C(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { osSyncPrintf("Spot16 obj 爆弾石 破壊済み\n"); return false; } - Actor_ProcessInitChain(&this->actor, sInitChainBoulder); - Actor_SetScale(&this->actor, 0.4f); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - func_808B4C4C(this, globalCtx); - func_808B4D04(this, globalCtx); - this->sinRotation = Math_SinS(this->actor.shape.rot.y); - this->cosRotation = Math_CosS(this->actor.shape.rot.y); - this->dList = gDodongosCavernRock3DL; + Actor_ProcessInitChain(&pthis->actor, sInitChainBoulder); + Actor_SetScale(&pthis->actor, 0.4f); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + func_808B4C4C(pthis, globalCtx); + func_808B4D04(pthis, globalCtx); + pthis->sinRotation = Math_SinS(pthis->actor.shape.rot.y); + pthis->cosRotation = Math_CosS(pthis->actor.shape.rot.y); + pthis->dList = gDodongosCavernRock3DL; - func_808B5934(this); + func_808B5934(pthis); return true; } -s32 func_808B4E58(BgSpot16Bombstone* this, GlobalContext* globalctx) { - Actor* actor = &this->actor; +s32 func_808B4E58(BgSpot16Bombstone* pthis, GlobalContext* globalctx) { + Actor* actor = &pthis->actor; f32 scaleFactor = 1.0f / 600.0f; f32 sinCosPosFactor = 50.0f; f32 sinValue; @@ -215,13 +215,13 @@ s32 func_808B4E58(BgSpot16Bombstone* this, GlobalContext* globalctx) { Actor_SetScale(actor, D_808B5DD8[actor->params][2] * scaleFactor); - this->unk_210 = (f32)D_808B5DD8[actor->params][3]; - this->unk_212 = (f32)D_808B5DD8[actor->params][4]; + pthis->unk_210 = (f32)D_808B5DD8[actor->params][3]; + pthis->unk_212 = (f32)D_808B5DD8[actor->params][4]; actor->world.rot.y = D_808B5DD8[actor->params][5]; - sinValue = Math_SinS(this->actor.world.rot.y); - cosValue = Math_CosS(this->actor.world.rot.y); + sinValue = Math_SinS(pthis->actor.world.rot.y); + cosValue = Math_CosS(pthis->actor.world.rot.y); actor->world.pos.x = (sinValue * sinCosPosFactor) + actor->home.pos.x; actor->world.pos.y = D_808B5DD8[actor->params][6] + actor->home.pos.y; @@ -231,29 +231,29 @@ s32 func_808B4E58(BgSpot16Bombstone* this, GlobalContext* globalctx) { actor->shape.rot.y = D_808B5DD8[actor->params][8]; actor->shape.rot.z = D_808B5DD8[actor->params][9]; - this->dList = object_bombiwa_DL_0009E0; - this->bombiwaBankIndex = Object_GetIndex(&globalctx->objectCtx, OBJECT_BOMBIWA); + pthis->dList = object_bombiwa_DL_0009E0; + pthis->bombiwaBankIndex = Object_GetIndex(&globalctx->objectCtx, OBJECT_BOMBIWA); - if (this->bombiwaBankIndex < 0) { + if (pthis->bombiwaBankIndex < 0) { osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", actor->params, "../z_bg_spot16_bombstone.c", 589); return false; } - func_808B5AF0(this); + func_808B5AF0(pthis); return true; } void BgSpot16Bombstone_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Bombstone* this = (BgSpot16Bombstone*)thisx; + BgSpot16Bombstone* pthis = (BgSpot16Bombstone*)thisx; s16 shouldLive; - func_808B4C30(this); + func_808B4C30(pthis); - switch (this->actor.params) { + switch (pthis->actor.params) { case 0xFF: // The boulder is intact - shouldLive = func_808B4D9C(this, globalCtx); + shouldLive = func_808B4D9C(pthis, globalCtx); break; case 0: case 1: @@ -262,84 +262,84 @@ void BgSpot16Bombstone_Init(Actor* thisx, GlobalContext* globalCtx) { case 4: case 5: // The boulder is debris - shouldLive = func_808B4E58(this, globalCtx); + shouldLive = func_808B4E58(pthis, globalCtx); break; default: osSyncPrintf("Error : arg_data おかしいな(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot16_bombstone.c", 668, - this->actor.params); + pthis->actor.params); shouldLive = false; break; } if (!shouldLive) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - osSyncPrintf("Spot16 obj 爆弾石 (scaleX %f)(arg_data 0x%04x)\n", this->actor.scale.x, this->actor.params); + osSyncPrintf("Spot16 obj 爆弾石 (scaleX %f)(arg_data 0x%04x)\n", pthis->actor.scale.x, pthis->actor.params); } void BgSpot16Bombstone_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Bombstone* this = (BgSpot16Bombstone*)thisx; + BgSpot16Bombstone* pthis = (BgSpot16Bombstone*)thisx; - if (this->actor.params == 0xFF) { + if (pthis->actor.params == 0xFF) { // Boulder is intact so remove its collider - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &pthis->colliderJntSph); + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinder); } } -void BgSpot16Bombstone_SpawnDust(BgSpot16Bombstone* this, GlobalContext* globalCtx) { - f32 scaleX1 = this->actor.scale.x * 150; - s16 scaleX2 = this->actor.scale.x * 250; +void BgSpot16Bombstone_SpawnDust(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { + f32 scaleX1 = pthis->actor.scale.x * 150; + s16 scaleX2 = pthis->actor.scale.x * 250; Vec3f world; - world.x = this->actor.world.pos.x; - world.y = this->actor.world.pos.y + 50.0f; - world.z = this->actor.world.pos.z; + world.x = pthis->actor.world.pos.x; + world.y = pthis->actor.world.pos.y + 50.0f; + world.z = pthis->actor.world.pos.z; func_80033480(globalCtx, &world, scaleX1, 2, scaleX2, 0xA0, 1); } -void func_808B5240(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B5240(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { f32 tempUnk6; f32 tempUnk2; s16 index; Vec3f position; - Vec3f* actorPosition = &this->actor.world.pos; + Vec3f* actorPosition = &pthis->actor.world.pos; if (1) {} while (true) { - if ((u32)this->unk_158 >= ARRAY_COUNTU(D_808B5EB0) || this->unk_154 < D_808B5EB0[this->unk_158][0]) { + if ((u32)pthis->unk_158 >= ARRAY_COUNTU(D_808B5EB0) || pthis->unk_154 < D_808B5EB0[pthis->unk_158][0]) { break; } - index = this->unk_158; + index = pthis->unk_158; tempUnk2 = D_808B5EB0[index][1]; tempUnk6 = D_808B5EB0[index][3]; - position.x = ((this->sinRotation * tempUnk6) + (tempUnk2 * this->cosRotation)) + actorPosition->x; + position.x = ((pthis->sinRotation * tempUnk6) + (tempUnk2 * pthis->cosRotation)) + actorPosition->x; position.y = D_808B5EB0[index][2] + actorPosition->y; - position.z = ((this->cosRotation * tempUnk6) - (tempUnk2 * this->sinRotation)) + actorPosition->z; + position.z = ((pthis->cosRotation * tempUnk6) - (tempUnk2 * pthis->sinRotation)) + actorPosition->z; func_800287AC(globalCtx, &position, &sVelocity, &sAcceleration, D_808B5EB0[index][4], D_808B5EB0[index][5], D_808B5EB0[index][6]); - this->unk_158 += 1; + pthis->unk_158 += 1; } } -void BgSpot16Bombstone_SpawnFragments(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void BgSpot16Bombstone_SpawnFragments(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { f32 velocityYMultiplier = 1.3f; Vec3f pos; Vec3f velocity; s32 index; s16 scale; - if (this->actor.params == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_SPOT16_BOMBSTONE, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 5); + if (pthis->actor.params == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_SPOT16_BOMBSTONE, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 5); index = 3; } else { index = 0; @@ -347,28 +347,28 @@ void BgSpot16Bombstone_SpawnFragments(BgSpot16Bombstone* this, GlobalContext* gl if (index < ARRAY_COUNT(D_808B6074)) { do { - pos.x = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.x; - pos.y = ((Rand_ZeroOne() * 5.0f) + this->actor.world.pos.y) + 8.0f; - pos.z = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.z; + pos.x = ((Rand_ZeroOne() - 0.5f) * 8.0f) + pthis->actor.world.pos.x; + pos.y = ((Rand_ZeroOne() * 5.0f) + pthis->actor.world.pos.y) + 8.0f; + pos.z = ((Rand_ZeroOne() - 0.5f) * 8.0f) + pthis->actor.world.pos.z; velocity.x = (Rand_ZeroOne() - 0.5f) * 16.0f; - velocity.y = (Rand_ZeroOne() * 14.0) + (fabsf(this->actor.velocity.y) * velocityYMultiplier); + velocity.y = (Rand_ZeroOne() * 14.0) + (fabsf(pthis->actor.velocity.y) * velocityYMultiplier); velocity.z = (Rand_ZeroOne() - 0.5f) * 16.0f; - scale = D_808B6074[index] * this->actor.scale.x * 3; + scale = D_808B6074[index] * pthis->actor.scale.x * 3; - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &this->actor.world.pos, -420, 0x31, 0xF, 0xF, 0, scale, 2, + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pthis->actor.world.pos, -420, 0x31, 0xF, 0xF, 0, scale, 2, 0x40, 160, KAKERA_COLOR_NONE, OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); index += 1; } while (index != ARRAY_COUNT(D_808B6074)); } } -void func_808B561C(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B561C(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { s32 index; PosRot* world; - world = &this->actor.world; + world = &pthis->actor.world; for (index = 0; index < ARRAY_COUNT(D_808B6088); index++) { if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_SPOT16_BOMBSTONE, world->pos.x, world->pos.y, world->pos.z, 0, 0, 0, D_808B6088[index]) == NULL) { @@ -377,35 +377,35 @@ void func_808B561C(BgSpot16Bombstone* this, GlobalContext* globalCtx) { } } -void func_808B56BC(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B56BC(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 sinValue; s16 adjustedYawDiff; s32 yawDiff; s32 absYawDiff; - if (this->actor.xzDistToPlayer < 130.0f && this->actor.yDistToPlayer < 160.0f && - this->actor.yDistToPlayer >= -10.0f) { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (pthis->actor.xzDistToPlayer < 130.0f && pthis->actor.yDistToPlayer < 160.0f && + pthis->actor.yDistToPlayer >= -10.0f) { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; absYawDiff = ABS(yawDiff); adjustedYawDiff = absYawDiff - 0x3FFF; if (adjustedYawDiff > 0) { - sinValue = Math_SinS(adjustedYawDiff) * this->actor.xzDistToPlayer; + sinValue = Math_SinS(adjustedYawDiff) * pthis->actor.xzDistToPlayer; if (sinValue >= 0.0f) { - player->actor.world.pos.x += sinValue * this->sinRotation; - player->actor.world.pos.z += sinValue * this->cosRotation; + player->actor.world.pos.x += sinValue * pthis->sinRotation; + player->actor.world.pos.z += sinValue * pthis->cosRotation; } else { osSyncPrintf("Error 補正出来ない(%s %d)(arg_data 0x%04x)(hosei_angY %x)\n", - "../z_bg_spot16_bombstone.c", 935, this->actor.params, adjustedYawDiff); + "../z_bg_spot16_bombstone.c", 935, pthis->actor.params, adjustedYawDiff); } } } } -void func_808B57E0(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B57E0(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { Actor* playerHeldActor; Player* player = GET_PLAYER(globalCtx); EnBombf* currentBomb; @@ -436,96 +436,96 @@ void func_808B57E0(BgSpot16Bombstone* this, GlobalContext* globalCtx) { } } -void func_808B5934(BgSpot16Bombstone* this) { - this->actor.draw = BgSpot16Bombstone_Draw; - this->actionFunc = func_808B5950; +void func_808B5934(BgSpot16Bombstone* pthis) { + pthis->actor.draw = BgSpot16Bombstone_Draw; + pthis->actionFunc = func_808B5950; } -void func_808B5950(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B5950(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { s32 pad; - func_808B56BC(this, globalCtx); - func_808B57E0(this, globalCtx); + func_808B56BC(pthis, globalCtx); + func_808B57E0(pthis, globalCtx); if (globalCtx) {} - if (this->colliderCylinder.base.acFlags & AC_HIT) { - this->colliderCylinder.base.acFlags &= ~AC_HIT; + if (pthis->colliderCylinder.base.acFlags & AC_HIT) { + pthis->colliderCylinder.base.acFlags &= ~AC_HIT; - func_808B561C(this, globalCtx); + func_808B561C(pthis, globalCtx); OnePointCutscene_Init(globalCtx, 4180, 50, NULL, MAIN_CAM); - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, pthis->switchFlag); gSaveContext.eventChkInf[2] |= 8; - func_808B5A78(this); + func_808B5A78(pthis); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); } if (mREG(64) == 1) { - func_808B561C(this, globalCtx); + func_808B561C(pthis, globalCtx); mREG(64) = -10; } else if (mREG(64) < 0) { mREG(64)++; } } -void func_808B5A78(BgSpot16Bombstone* this) { - this->unk_154 = 0; - this->unk_158 = 0; - this->actor.draw = NULL; - this->actionFunc = func_808B5A94; +void func_808B5A78(BgSpot16Bombstone* pthis) { + pthis->unk_154 = 0; + pthis->unk_158 = 0; + pthis->actor.draw = NULL; + pthis->actionFunc = func_808B5A94; } -void func_808B5A94(BgSpot16Bombstone* this, GlobalContext* globalCtx) { +void func_808B5A94(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { - func_808B5240(this, globalCtx); + func_808B5240(pthis, globalCtx); - if (this->unk_154 == 56) { + if (pthis->unk_154 == 56) { func_80078884(NA_SE_SY_CORRECT_CHIME); } - if (this->unk_154 > 60) { - Actor_Kill(&this->actor); + if (pthis->unk_154 > 60) { + Actor_Kill(&pthis->actor); } } -void func_808B5AF0(BgSpot16Bombstone* this) { - this->actionFunc = func_808B5B04; - this->actor.draw = NULL; +void func_808B5AF0(BgSpot16Bombstone* pthis) { + pthis->actionFunc = func_808B5B04; + pthis->actor.draw = NULL; } -void func_808B5B04(BgSpot16Bombstone* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->bombiwaBankIndex)) { - func_808B5B58(this); - this->actor.draw = BgSpot16Bombstone_Draw; +void func_808B5B04(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->bombiwaBankIndex)) { + func_808B5B58(pthis); + pthis->actor.draw = BgSpot16Bombstone_Draw; } } -void func_808B5B58(BgSpot16Bombstone* this) { - this->unk_154 = 0; - this->actionFunc = func_808B5B6C; +void func_808B5B58(BgSpot16Bombstone* pthis) { + pthis->unk_154 = 0; + pthis->actionFunc = func_808B5B6C; } -void func_808B5B6C(BgSpot16Bombstone* this, GlobalContext* globalCtx) { - Actor* actor = &this->actor; +void func_808B5B6C(BgSpot16Bombstone* pthis, GlobalContext* globalCtx) { + Actor* actor = &pthis->actor; Actor_MoveForward(actor); - actor->shape.rot.x += this->unk_210; - actor->shape.rot.z += this->unk_212; + actor->shape.rot.x += pthis->unk_210; + actor->shape.rot.z += pthis->unk_212; - if (this->unk_154 > 60) { + if (pthis->unk_154 > 60) { Actor_Kill(actor); return; } if (actor->bgCheckFlags & 8 || (actor->bgCheckFlags & 1 && actor->velocity.y < 0.0f)) { - BgSpot16Bombstone_SpawnFragments(this, globalCtx); - BgSpot16Bombstone_SpawnDust(this, globalCtx); + BgSpot16Bombstone_SpawnFragments(pthis, globalCtx); + BgSpot16Bombstone_SpawnDust(pthis, globalCtx); Audio_PlaySoundAtPosition(globalCtx, &actor->world.pos, 20, NA_SE_EV_ROCK_BROKEN); Actor_Kill(actor); return; @@ -535,16 +535,16 @@ void func_808B5B6C(BgSpot16Bombstone* this, GlobalContext* globalCtx) { } void BgSpot16Bombstone_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Bombstone* this = (BgSpot16Bombstone*)thisx; + BgSpot16Bombstone* pthis = (BgSpot16Bombstone*)thisx; - this->unk_154++; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + pthis->unk_154++; + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } } void BgSpot16Bombstone_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Bombstone* this = (BgSpot16Bombstone*)thisx; + BgSpot16Bombstone* pthis = (BgSpot16Bombstone*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot16_bombstone.c", 1253); @@ -554,13 +554,13 @@ void BgSpot16Bombstone_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot16_bombstone.c", 1257), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->actor.params == 0xFF) { + if (pthis->actor.params == 0xFF) { // The boulder is intact - gSPDisplayList(POLY_OPA_DISP++, this->dList); + gSPDisplayList(POLY_OPA_DISP++, pthis->dList); } else { // The boulder is debris - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->bombiwaBankIndex].vromStart); - gSPDisplayList(POLY_OPA_DISP++, this->dList); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->bombiwaBankIndex].vromStart.get()); + gSPDisplayList(POLY_OPA_DISP++, pthis->dList); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot16_bombstone.c", 1274); diff --git a/src/overlays/actors/ovl_Bg_Spot16_Doughnut/z_bg_spot16_doughnut.c b/src/overlays/actors/ovl_Bg_Spot16_Doughnut/z_bg_spot16_doughnut.cpp similarity index 68% rename from src/overlays/actors/ovl_Bg_Spot16_Doughnut/z_bg_spot16_doughnut.c rename to src/overlays/actors/ovl_Bg_Spot16_Doughnut/z_bg_spot16_doughnut.cpp index 5f0b2417b..5bb0bd024 100644 --- a/src/overlays/actors/ovl_Bg_Spot16_Doughnut/z_bg_spot16_doughnut.c +++ b/src/overlays/actors/ovl_Bg_Spot16_Doughnut/z_bg_spot16_doughnut.cpp @@ -25,7 +25,7 @@ void BgSpot16Doughnut_Draw(Actor* thisx, GlobalContext* globalCtx); void BgSpot16Doughnut_UpdateExpanding(Actor* thisx, GlobalContext* globalCtx); void BgSpot16Doughnut_DrawExpanding(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot16_Doughnut_InitVars = { +ActorInit Bg_Spot16_Doughnut_InitVars = { ACTOR_BG_SPOT16_DOUGHNUT, ACTORCAT_PROP, FLAGS, @@ -48,41 +48,41 @@ static s16 sScales[] = { }; void BgSpot16Doughnut_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Doughnut* this = (BgSpot16Doughnut*)thisx; + BgSpot16Doughnut* pthis = (BgSpot16Doughnut*)thisx; s32 params; - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.1f); - this->fireFlag = 0; - this->envColorAlpha = 255; - params = this->actor.params; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.1f); + pthis->fireFlag = 0; + pthis->envColorAlpha = 255; + params = pthis->actor.params; if (params == 1 || params == 2 || params == 3 || params == 4) { - Actor_SetScale(&this->actor, sScales[this->actor.params] * 1.0e-4f); - this->actor.draw = BgSpot16Doughnut_DrawExpanding; - this->actor.update = BgSpot16Doughnut_UpdateExpanding; + Actor_SetScale(&pthis->actor, sScales[pthis->actor.params] * 1.0e-4f); + pthis->actor.draw = BgSpot16Doughnut_DrawExpanding; + pthis->actor.update = BgSpot16Doughnut_UpdateExpanding; } else { - // Scales this actor for scenes where it is featured in the background, + // Scales pthis actor for scenes where it is featured in the background, // Death Mountain itself falls into the default case. switch (globalCtx->sceneNum) { case SCENE_SPOT01: - Actor_SetScale(&this->actor, 0.04f); + Actor_SetScale(&pthis->actor, 0.04f); break; case SCENE_SHRINE: case SCENE_SHRINE_N: case SCENE_SHRINE_R: - Actor_SetScale(&this->actor, 0.018f); + Actor_SetScale(&pthis->actor, 0.018f); break; default: - Actor_SetScale(&this->actor, 0.1f); + Actor_SetScale(&pthis->actor, 0.1f); break; } - osSyncPrintf(VT_FGCOL(CYAN) "%f" VT_RST "\n", this->actor.scale.x); + osSyncPrintf(VT_FGCOL(CYAN) "%f" VT_RST "\n", pthis->actor.scale.x); if (!LINK_IS_ADULT || gSaveContext.eventChkInf[2] & 0x8000) { - this->fireFlag &= ~1; + pthis->fireFlag &= ~1; } else { - this->fireFlag |= 1; + pthis->fireFlag |= 1; } - osSyncPrintf("(spot16 ドーナツ雲)(arg_data 0x%04x)\n", this->actor.params); + osSyncPrintf("(spot16 ドーナツ雲)(arg_data 0x%04x)\n", pthis->actor.params); } } @@ -90,41 +90,41 @@ void BgSpot16Doughnut_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void BgSpot16Doughnut_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Doughnut* this = (BgSpot16Doughnut*)thisx; + BgSpot16Doughnut* pthis = (BgSpot16Doughnut*)thisx; - if (!(this->fireFlag & 1)) { - this->actor.shape.rot.y -= 0x20; - if (this->envColorAlpha < 255) { - this->envColorAlpha += 5; + if (!(pthis->fireFlag & 1)) { + pthis->actor.shape.rot.y -= 0x20; + if (pthis->envColorAlpha < 255) { + pthis->envColorAlpha += 5; } else { - this->envColorAlpha = 255; + pthis->envColorAlpha = 255; } } else if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[2] != NULL && globalCtx->csCtx.npcActions[2]->action == 2) { - if (this->envColorAlpha >= 6) { - this->envColorAlpha -= 5; + if (pthis->envColorAlpha >= 6) { + pthis->envColorAlpha -= 5; } else { - this->envColorAlpha = 0; - this->fireFlag &= ~1; + pthis->envColorAlpha = 0; + pthis->fireFlag &= ~1; } } } // Update function for outwardly expanding and dissipating void BgSpot16Doughnut_UpdateExpanding(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Doughnut* this = (BgSpot16Doughnut*)thisx; + BgSpot16Doughnut* pthis = (BgSpot16Doughnut*)thisx; - if (this->envColorAlpha >= 6) { - this->envColorAlpha -= 5; + if (pthis->envColorAlpha >= 6) { + pthis->envColorAlpha -= 5; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - this->actor.shape.rot.y -= 0x20; - Actor_SetScale(&this->actor, this->actor.scale.x + 0.0019999998f); + pthis->actor.shape.rot.y -= 0x20; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x + 0.0019999998f); } void BgSpot16Doughnut_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Doughnut* this = (BgSpot16Doughnut*)thisx; + BgSpot16Doughnut* pthis = (BgSpot16Doughnut*)thisx; u32 scroll = globalCtx->gameplayFrames & 0xFFFF; s32 pad; @@ -136,14 +136,14 @@ void BgSpot16Doughnut_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot16_doughnut.c", 213), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->fireFlag & 1) { + if (pthis->fireFlag & 1) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, scroll * (-1), 0, 16, 32, 1, scroll, scroll * (-2), 16, 32)); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, this->envColorAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, pthis->envColorAlpha); gSPDisplayList(POLY_XLU_DISP++, gDeathMountainCloudCircleFieryDL); } else { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->envColorAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, pthis->envColorAlpha); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gSPDisplayList(POLY_XLU_DISP++, gDeathMountainCloudCircleNormalDL); } @@ -153,7 +153,7 @@ void BgSpot16Doughnut_Draw(Actor* thisx, GlobalContext* globalCtx) { // Draw function for outwardly expanding and dissipating void BgSpot16Doughnut_DrawExpanding(Actor* thisx, GlobalContext* globalCtx) { - BgSpot16Doughnut* this = (BgSpot16Doughnut*)thisx; + BgSpot16Doughnut* pthis = (BgSpot16Doughnut*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot16_doughnut.c", 245); @@ -161,7 +161,7 @@ void BgSpot16Doughnut_DrawExpanding(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot16_doughnut.c", 248), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->envColorAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, pthis->envColorAlpha); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gSPDisplayList(POLY_XLU_DISP++, gDeathMountainCloudCircleNormalDL); diff --git a/src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/z_bg_spot17_bakudankabe.c b/src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/z_bg_spot17_bakudankabe.cpp similarity index 75% rename from src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/z_bg_spot17_bakudankabe.c rename to src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/z_bg_spot17_bakudankabe.cpp index 57ff20bbe..9c9229171 100644 --- a/src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/z_bg_spot17_bakudankabe.c +++ b/src/overlays/actors/ovl_Bg_Spot17_Bakudankabe/z_bg_spot17_bakudankabe.cpp @@ -28,7 +28,7 @@ void BgSpot17Bakudankabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot17Bakudankabe_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot17Bakudankabe_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot17_Bakudankabe_InitVars = { +ActorInit Bg_Spot17_Bakudankabe_InitVars = { ACTOR_BG_SPOT17_BAKUDANKABE, ACTORCAT_BG, FLAGS, @@ -47,7 +47,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void func_808B6BC0(BgSpot17Bakudankabe* this, GlobalContext* globalCtx) { +void func_808B6BC0(BgSpot17Bakudankabe* pthis, GlobalContext* globalCtx) { s32 pad[2]; s32 i; Vec3f burstDepthY; @@ -55,8 +55,8 @@ void func_808B6BC0(BgSpot17Bakudankabe* this, GlobalContext* globalCtx) { f32 sinY; f32 cosY; - sinY = Math_SinS(this->dyna.actor.shape.rot.y); - cosY = Math_CosS(this->dyna.actor.shape.rot.y); + sinY = Math_SinS(pthis->dyna.actor.shape.rot.y); + cosY = Math_CosS(pthis->dyna.actor.shape.rot.y); burstDepthX.z = 0.0f; burstDepthX.x = 0.0f; @@ -71,9 +71,9 @@ void func_808B6BC0(BgSpot17Bakudankabe* this, GlobalContext* globalCtx) { temp1 = (Rand_ZeroOne() - 0.5f) * 140.0f; temp2 = (Rand_ZeroOne() - 0.5f) * 20.0f; - burstDepthY.x = this->dyna.actor.world.pos.x + temp2 * sinY + (temp1 * cosY); - burstDepthY.y = this->dyna.actor.world.pos.y + 30.0f + (i * 6.5f); - burstDepthY.z = this->dyna.actor.world.pos.z + temp2 * cosY - (temp1 * sinY); + burstDepthY.x = pthis->dyna.actor.world.pos.x + temp2 * sinY + (temp1 * cosY); + burstDepthY.y = pthis->dyna.actor.world.pos.y + 30.0f + (i * 6.5f); + burstDepthY.z = pthis->dyna.actor.world.pos.z + temp2 * cosY - (temp1 * sinY); burstDepthX.y = (Rand_ZeroOne() - 0.2f) * 12.0f; scale = Rand_ZeroOne() * 55.0f + 8.0f; @@ -94,7 +94,7 @@ void func_808B6BC0(BgSpot17Bakudankabe* this, GlobalContext* globalCtx) { EffectSsKakera_Spawn(globalCtx, &burstDepthY, &burstDepthX, &burstDepthY, gravityInfluence, rotationSpeed, 0x1E, 4, 0, scale, 1, 3, 80, KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_FIELD_KEEP, gFieldKakeraDL); } - Math_Vec3f_Copy(&burstDepthY, &this->dyna.actor.world.pos); + Math_Vec3f_Copy(&burstDepthY, &pthis->dyna.actor.world.pos); func_80033480(globalCtx, &burstDepthY, 60.0f, 4, 110, 160, 1); burstDepthY.y += 40.0f; func_80033480(globalCtx, &burstDepthY, 60.0f, 4, 120, 160, 1); @@ -103,34 +103,34 @@ void func_808B6BC0(BgSpot17Bakudankabe* this, GlobalContext* globalCtx) { } void BgSpot17Bakudankabe_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot17Bakudankabe* this = (BgSpot17Bakudankabe*)thisx; + BgSpot17Bakudankabe* pthis = (BgSpot17Bakudankabe*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) { - Actor_Kill(&this->dyna.actor); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F))) { + Actor_Kill(&pthis->dyna.actor); return; } CollisionHeader_GetVirtual(&gCraterBombableWallCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); } void BgSpot17Bakudankabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot17Bakudankabe* this = (BgSpot17Bakudankabe*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + BgSpot17Bakudankabe* pthis = (BgSpot17Bakudankabe*)thisx; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgSpot17Bakudankabe_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot17Bakudankabe* this = (BgSpot17Bakudankabe*)thisx; - if (this->dyna.actor.xzDistToPlayer < 650.0f && func_80033684(globalCtx, &this->dyna.actor) != NULL) { - func_808B6BC0(this, globalCtx); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params & 0x3F)); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + BgSpot17Bakudankabe* pthis = (BgSpot17Bakudankabe*)thisx; + if (pthis->dyna.actor.xzDistToPlayer < 650.0f && func_80033684(globalCtx, &pthis->dyna.actor) != NULL) { + func_808B6BC0(pthis, globalCtx); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params & 0x3F)); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); func_80078884(NA_SE_SY_CORRECT_CHIME); - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } diff --git a/src/overlays/actors/ovl_Bg_Spot17_Funen/z_bg_spot17_funen.c b/src/overlays/actors/ovl_Bg_Spot17_Funen/z_bg_spot17_funen.cpp similarity index 86% rename from src/overlays/actors/ovl_Bg_Spot17_Funen/z_bg_spot17_funen.c rename to src/overlays/actors/ovl_Bg_Spot17_Funen/z_bg_spot17_funen.cpp index e5542146e..afa28313d 100644 --- a/src/overlays/actors/ovl_Bg_Spot17_Funen/z_bg_spot17_funen.c +++ b/src/overlays/actors/ovl_Bg_Spot17_Funen/z_bg_spot17_funen.cpp @@ -21,7 +21,7 @@ void BgSpot17Funen_Update(Actor* thisx, GlobalContext* globalCtx); void func_808B746C(Actor* thisx, GlobalContext* globalCtx); void func_808B7478(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot17_Funen_InitVars = { +ActorInit Bg_Spot17_Funen_InitVars = { ACTOR_BG_SPOT17_FUNEN, ACTORCAT_SWITCH, FLAGS, @@ -38,20 +38,20 @@ static InitChainEntry sInitChain[] = { }; void BgSpot17Funen_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot17Funen* this = (BgSpot17Funen*)thisx; + BgSpot17Funen* pthis = (BgSpot17Funen*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - osSyncPrintf("spot17 obj. 噴煙 (arg_data 0x%04x)\n", this->actor.params); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + osSyncPrintf("spot17 obj. 噴煙 (arg_data 0x%04x)\n", pthis->actor.params); } void BgSpot17Funen_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void BgSpot17Funen_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot17Funen* this = (BgSpot17Funen*)thisx; + BgSpot17Funen* pthis = (BgSpot17Funen*)thisx; - this->actor.draw = func_808B7478; - this->actor.update = func_808B746C; + pthis->actor.draw = func_808B7478; + pthis->actor.update = func_808B746C; } void func_808B746C(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c b/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c deleted file mode 100644 index 6e9343d69..000000000 --- a/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c +++ /dev/null @@ -1,466 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT18_BASKET_Z_BG_SPOT18_BASKET_C -#include "actor_common.h" -#include "z_bg_spot18_basket.h" -#include "objects/object_spot18_obj/object_spot18_obj.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS ACTOR_FLAG_4 - -void BgSpot18Basket_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Basket_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Basket_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Basket_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808B7BCC(BgSpot18Basket* this, GlobalContext* globalCtx); -void func_808B7AEC(BgSpot18Basket* this); -void func_808B7B58(BgSpot18Basket* this); -void func_808B7BB0(BgSpot18Basket* this); -void func_808B7D38(BgSpot18Basket* this); -void func_808B7F74(BgSpot18Basket* this); -void func_808B818C(BgSpot18Basket* this); -void func_808B7AFC(BgSpot18Basket* this, GlobalContext* globalCtx); -void func_808B7B6C(BgSpot18Basket* this, GlobalContext* globalCtx); -void func_808B7D50(BgSpot18Basket* this, GlobalContext* globalCtx); -void func_808B7FC0(BgSpot18Basket* this, GlobalContext* globalCtx); -void func_808B81A0(BgSpot18Basket* this, GlobalContext* globalCtx); - -const ActorInit Bg_Spot18_Basket_InitVars = { - ACTOR_BG_SPOT18_BASKET, - ACTORCAT_PROP, - FLAGS, - OBJECT_SPOT18_OBJ, - sizeof(BgSpot18Basket), - (ActorFunc)BgSpot18Basket_Init, - (ActorFunc)BgSpot18Basket_Destroy, - (ActorFunc)BgSpot18Basket_Update, - (ActorFunc)BgSpot18Basket_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 0, { { 0, 2040, 0 }, 54 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 1, { { 0, 1400, 0 }, 13 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - 2, - sJntSphElementsInit, -}; - -static s16 D_808B85C8[] = { 0x8000, 0x2AAA, 0xD555, 0x0000 }; - -void func_808B7710(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Basket* this = (BgSpot18Basket*)thisx; - - Collider_InitJntSph(globalCtx, &this->colliderJntSph); - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, &sJntSphInit, this->ColliderJntSphElements); - this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; -} - -void func_808B7770(BgSpot18Basket* this, GlobalContext* globalCtx, f32 arg2) { - static s16 D_808B85D0 = 0; - Vec3f acceleration; - Vec3f velocity; - Vec3f position; - f32 cosValue; - s32 i; - f32 randomValue; - f32 sinValue; - s32 count; - - for (i = 0, count = 2; i != count; i++) { - if (globalCtx) {} - if (!(arg2 < Rand_ZeroOne())) { - D_808B85D0 += 0x7530; - - sinValue = Math_SinS(D_808B85D0); - cosValue = Math_CosS(D_808B85D0); - - randomValue = (Rand_ZeroOne() * 35.0f) + 35.0f; - - position.x = (randomValue * sinValue) + this->dyna.actor.world.pos.x; - position.y = this->dyna.actor.world.pos.y + 10.0f; - position.z = (randomValue * cosValue) + this->dyna.actor.world.pos.z; - - velocity.x = sinValue; - velocity.y = 0.0f; - velocity.z = cosValue; - - acceleration.x = 0.0f; - acceleration.y = 0.5f; - acceleration.z = 0.0f; - - func_800286CC(globalCtx, &position, &velocity, &acceleration, ((Rand_ZeroOne() * 16) + 80), - ((Rand_ZeroOne() * 30) + 80)); - } - } -} - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void BgSpot18Basket_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgSpot18Basket* this = (BgSpot18Basket*)thisx; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK3); - func_808B7710(&this->dyna.actor, globalCtx); - CollisionHeader_GetVirtual(&gGoronCityVaseCol, &colHeader); - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); - this->dyna.actor.home.pos.y += 0.01f; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - func_808B7BB0(this); - return; - } - - func_808B7AEC(this); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_SPOT18_FUTA, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y + 0x1555, - this->dyna.actor.shape.rot.z, -1); - - if (this->dyna.actor.child == NULL) { - osSyncPrintf(VT_FGCOL(RED)); - osSyncPrintf("Error : 変化壷蓋発生失敗(%s %d)\n", "../z_bg_spot18_basket.c", 351); - osSyncPrintf(VT_RST); - Actor_Kill(&this->dyna.actor); - } -} - -void BgSpot18Basket_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Basket* this = (BgSpot18Basket*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); -} - -void func_808B7AEC(BgSpot18Basket* this) { - this->actionFunc = func_808B7AFC; -} - -void func_808B7AFC(BgSpot18Basket* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - OnePointCutscene_Init(globalCtx, 4220, 80, &this->dyna.actor, MAIN_CAM); - func_808B7B58(this); - } -} - -void func_808B7B58(BgSpot18Basket* this) { - this->actionFunc = func_808B7B6C; - this->unk_216 = 0; -} - -void func_808B7B6C(BgSpot18Basket* this, GlobalContext* globalCtx) { - if (this->unk_216 > 20) { - func_808B7BB0(this); - this->dyna.actor.child->parent = NULL; - this->dyna.actor.child = NULL; - } -} - -void func_808B7BB0(BgSpot18Basket* this) { - this->actionFunc = func_808B7BCC; - this->unk_210 = this->unk_20C = 0; -} - -void func_808B7BCC(BgSpot18Basket* this, GlobalContext* globalCtx) { - f32 positionDiff; - Actor* colliderBaseAc; - - Math_StepToS(&this->unk_210, 0x1F4, 0x1E); - - this->dyna.actor.shape.rot.y += this->unk_210; - - Math_StepToF(&this->unk_208, 50.0f, 1.5f); - Math_StepToS(&this->unk_20C, 400, 15); - - this->unk_20E += this->unk_20C; - - this->dyna.actor.world.pos.x = (Math_SinS(this->unk_20E) * this->unk_208) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->unk_20E) * this->unk_208) + this->dyna.actor.home.pos.z; - - if (this->colliderJntSph.base.acFlags & AC_HIT) { - colliderBaseAc = this->colliderJntSph.base.ac; - - if (colliderBaseAc != NULL) { - positionDiff = colliderBaseAc->world.pos.y - this->dyna.actor.world.pos.y; - - if (positionDiff > 120.0f && positionDiff < 200.0f) { - if (Math3D_Dist2DSq(colliderBaseAc->world.pos.z, this->colliderJntSph.base.ac->world.pos.x, - this->dyna.actor.world.pos.z, this->dyna.actor.world.pos.x) < SQ(32.0f)) { - OnePointCutscene_Init(globalCtx, 4210, 240, &this->dyna.actor, MAIN_CAM); - func_808B7D38(this); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } - } - } - } - func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); -} - -void func_808B7D38(BgSpot18Basket* this) { - this->actionFunc = func_808B7D50; - this->unk_216 = 0; - this->unk_214 = 0; -} - -void func_808B7D50(BgSpot18Basket* this, GlobalContext* globalCtx) { - f32 tempValue2; - f32 tempValue; - - if (this->unk_216 > 120) { - Math_StepToS(&this->unk_210, 0x3E8, 0x32); - } else { - Math_StepToS(&this->unk_210, 0xBB8, 0x64); - } - - this->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y + this->unk_210; - - if (this->unk_216 < 70) { - Math_StepToF(&this->unk_208, 100.0f, 2.0f); - } else { - Math_StepToF(&this->unk_208, 0.0f, 2.0f); - } - - Math_StepToS(&this->unk_20C, 1000, 20); - - this->unk_20E += this->unk_20C; - - this->dyna.actor.world.pos.x = (Math_SinS(this->unk_20E) * this->unk_208) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->unk_20E) * this->unk_208) + this->dyna.actor.home.pos.z; - - this->unk_212 += 0xBB8; - - Math_StepToS(&this->unk_214, 0x5DC, 0x1E); - - this->dyna.actor.shape.rot.x = Math_CosS(this->unk_212) * this->unk_214; - this->dyna.actor.shape.rot.z = -Math_SinS(this->unk_212) * this->unk_214; - - if (this->unk_216 > 140) { - func_808B7F74(this); - } - - if (this->unk_216 < 80) { - func_808B7770(this, globalCtx, 1.0f); - } else { - func_808B7770(this, globalCtx, 0.8f); - } - - tempValue2 = (this->unk_210 - 500) * 0.0006f; - - tempValue = CLAMP(tempValue2, 0.0f, 1.5f); - - func_800F436C(&this->dyna.actor.projectedPos, NA_SE_EV_WALL_MOVE_SP - SFX_FLAG, tempValue); -} - -void func_808B7F74(BgSpot18Basket* this) { - s16 shapeRotY; - - shapeRotY = this->dyna.actor.shape.rot.y; - this->actionFunc = func_808B7FC0; - - if ((shapeRotY < -0x2E93) || (shapeRotY >= 0x7C19)) { - this->unk_218 = 2; - } else if (shapeRotY < 0x26C2) { - this->unk_218 = 1; - } else { - this->unk_218 = 0; - } - - this->unk_216 = 0; -} - -void func_808B7FC0(BgSpot18Basket* this, GlobalContext* globalCtx) { - s32 pad; - s32 tempUnk214; - f32 tempUnk210; - s16 arrayValue; - f32 clampedTempUnk210; - - this->unk_212 += 0xBB8; - - if (this->unk_216 >= 13) { - tempUnk214 = Math_StepToS(&this->unk_214, 0, 55); - } else { - tempUnk214 = 0; - } - - this->dyna.actor.shape.rot.x = Math_CosS(this->unk_212) * this->unk_214; - this->dyna.actor.shape.rot.z = -Math_SinS(this->unk_212) * this->unk_214; - - Math_StepToS(&this->unk_210, 0x1F4, 0xA); - this->dyna.actor.shape.rot.y += this->unk_210; - - if (tempUnk214 != 0) { - arrayValue = D_808B85C8[this->unk_218]; - - if ((s16)(this->dyna.actor.shape.rot.y - arrayValue) >= 0) { - this->dyna.actor.shape.rot.y = arrayValue; - - func_808B818C(this); - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } - } - - if (this->unk_216 < 30) { - func_808B7770(this, globalCtx, 0.5f); - } else { - func_808B7770(this, globalCtx, 0.3f); - } - - tempUnk210 = (this->unk_210 - 500) * 0.0006f; - - clampedTempUnk210 = CLAMP(tempUnk210, 0.0f, 1.5f); - - func_800F436C(&this->dyna.actor.projectedPos, NA_SE_EV_WALL_MOVE_SP - SFX_FLAG, clampedTempUnk210); -} - -void func_808B818C(BgSpot18Basket* this) { - this->actionFunc = func_808B81A0; - this->unk_216 = 0; -} - -static s16 D_808B85E4[] = { -0x0FA0, 0x0320, 0x0FA0 }; - -void func_808B81A0(BgSpot18Basket* this, GlobalContext* globalCtx) { - s32 i; - Actor* actor = &this->dyna.actor; - Vec3f tempVector; - EnItem00* collectible; - - if (this->unk_216 == 1) { - tempVector.x = actor->world.pos.x; - tempVector.y = actor->world.pos.y + 170.0f; - tempVector.z = actor->world.pos.z; - - if (this->unk_218 == 0) { - for (i = 0; i < ARRAY_COUNT(D_808B85E4); i++) { - collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_BOMBS_A); - if (collectible != NULL) { - collectible->actor.velocity.y = 11.0f; - collectible->actor.world.rot.y = D_808B85E4[i]; - } - } - } else if (this->unk_218 == 1) { - for (i = 0; i < ARRAY_COUNT(D_808B85E4); i++) { - collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_GREEN); - if (collectible != NULL) { - collectible->actor.velocity.y = 11.0f; - collectible->actor.world.rot.y = D_808B85E4[i]; - } - } - } else if (this->unk_218 == 2) { - if ((this->unk_21A != 0) || Flags_GetCollectible(globalCtx, (actor->params & 0x3F))) { - collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_PURPLE); - if (collectible != NULL) { - collectible->actor.velocity.y = 11.0f; - collectible->actor.world.rot.y = D_808B85E4[1]; - } - } else { - collectible = - Item_DropCollectible(globalCtx, &tempVector, ((actor->params & 0x3F) << 8) | ITEM00_HEART_PIECE); - if (collectible != NULL) { - collectible->actor.velocity.y = 11.0f; - collectible->actor.world.rot.y = D_808B85E4[1]; - this->unk_21A = 1; - } - } - - collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_RED); - if (collectible != NULL) { - collectible->actor.velocity.y = 11.0f; - collectible->actor.world.rot.y = D_808B85E4[0]; - } - - collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_BLUE); - if (collectible != NULL) { - collectible->actor.velocity.y = 11.0f; - collectible->actor.world.rot.y = D_808B85E4[2]; - } - } - } else if (this->unk_216 == 2) { - if (this->unk_218 == 2) { - func_80078884(NA_SE_SY_CORRECT_CHIME); - } else { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - } else if (this->unk_216 == 200) { - func_808B7BB0(this); - } -} - -void BgSpot18Basket_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgSpot18Basket* this = (BgSpot18Basket*)thisx; - s32 bgId; - - this->unk_216++; - this->actionFunc(this, globalCtx); - this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &bgId, - &this->dyna.actor, &this->dyna.actor.world.pos); - if (this->actionFunc != func_808B7AFC) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - if (this->actionFunc != func_808B7B6C) { - this->colliderJntSph.base.acFlags &= ~AC_HIT; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - } -} - -void BgSpot18Basket_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Basket* this = (BgSpot18Basket*)thisx; - - Collider_UpdateSpheres(0, &this->colliderJntSph); - Collider_UpdateSpheres(1, &this->colliderJntSph); - Gfx_DrawDListOpa(globalCtx, gGoronCityVaseDL); -} diff --git a/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.cpp b/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.cpp new file mode 100644 index 000000000..c45cc3f56 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.cpp @@ -0,0 +1,466 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT18_BASKET_Z_BG_SPOT18_BASKET_C +#include "actor_common.h" +#include "z_bg_spot18_basket.h" +#include "objects/object_spot18_obj/object_spot18_obj.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS ACTOR_FLAG_4 + +void BgSpot18Basket_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Basket_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Basket_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Basket_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808B7BCC(BgSpot18Basket* pthis, GlobalContext* globalCtx); +void func_808B7AEC(BgSpot18Basket* pthis); +void func_808B7B58(BgSpot18Basket* pthis); +void func_808B7BB0(BgSpot18Basket* pthis); +void func_808B7D38(BgSpot18Basket* pthis); +void func_808B7F74(BgSpot18Basket* pthis); +void func_808B818C(BgSpot18Basket* pthis); +void func_808B7AFC(BgSpot18Basket* pthis, GlobalContext* globalCtx); +void func_808B7B6C(BgSpot18Basket* pthis, GlobalContext* globalCtx); +void func_808B7D50(BgSpot18Basket* pthis, GlobalContext* globalCtx); +void func_808B7FC0(BgSpot18Basket* pthis, GlobalContext* globalCtx); +void func_808B81A0(BgSpot18Basket* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Spot18_Basket_InitVars = { + ACTOR_BG_SPOT18_BASKET, + ACTORCAT_PROP, + FLAGS, + OBJECT_SPOT18_OBJ, + sizeof(BgSpot18Basket), + (ActorFunc)BgSpot18Basket_Init, + (ActorFunc)BgSpot18Basket_Destroy, + (ActorFunc)BgSpot18Basket_Update, + (ActorFunc)BgSpot18Basket_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 0, { { 0, 2040, 0 }, 54 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 1, { { 0, 1400, 0 }, 13 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, +}; + +static s16 D_808B85C8[] = { 0x8000, 0x2AAA, 0xD555, 0x0000 }; + +void func_808B7710(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Basket* pthis = (BgSpot18Basket*)thisx; + + Collider_InitJntSph(globalCtx, &pthis->colliderJntSph); + Collider_SetJntSph(globalCtx, &pthis->colliderJntSph, &pthis->dyna.actor, &sJntSphInit, pthis->ColliderJntSphElements); + pthis->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; +} + +void func_808B7770(BgSpot18Basket* pthis, GlobalContext* globalCtx, f32 arg2) { + static s16 D_808B85D0 = 0; + Vec3f acceleration; + Vec3f velocity; + Vec3f position; + f32 cosValue; + s32 i; + f32 randomValue; + f32 sinValue; + s32 count; + + for (i = 0, count = 2; i != count; i++) { + if (globalCtx) {} + if (!(arg2 < Rand_ZeroOne())) { + D_808B85D0 += 0x7530; + + sinValue = Math_SinS(D_808B85D0); + cosValue = Math_CosS(D_808B85D0); + + randomValue = (Rand_ZeroOne() * 35.0f) + 35.0f; + + position.x = (randomValue * sinValue) + pthis->dyna.actor.world.pos.x; + position.y = pthis->dyna.actor.world.pos.y + 10.0f; + position.z = (randomValue * cosValue) + pthis->dyna.actor.world.pos.z; + + velocity.x = sinValue; + velocity.y = 0.0f; + velocity.z = cosValue; + + acceleration.x = 0.0f; + acceleration.y = 0.5f; + acceleration.z = 0.0f; + + func_800286CC(globalCtx, &position, &velocity, &acceleration, ((Rand_ZeroOne() * 16) + 80), + ((Rand_ZeroOne() * 30) + 80)); + } + } +} + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void BgSpot18Basket_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgSpot18Basket* pthis = (BgSpot18Basket*)thisx; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK3); + func_808B7710(&pthis->dyna.actor, globalCtx); + CollisionHeader_GetVirtual(&gGoronCityVaseCol, &colHeader); + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); + pthis->dyna.actor.home.pos.y += 0.01f; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + func_808B7BB0(pthis); + return; + } + + func_808B7AEC(pthis); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_BG_SPOT18_FUTA, + pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, + pthis->dyna.actor.shape.rot.x, pthis->dyna.actor.shape.rot.y + 0x1555, + pthis->dyna.actor.shape.rot.z, -1); + + if (pthis->dyna.actor.child == NULL) { + osSyncPrintf(VT_FGCOL(RED)); + osSyncPrintf("Error : 変化壷蓋発生失敗(%s %d)\n", "../z_bg_spot18_basket.c", 351); + osSyncPrintf(VT_RST); + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgSpot18Basket_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Basket* pthis = (BgSpot18Basket*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &pthis->colliderJntSph); +} + +void func_808B7AEC(BgSpot18Basket* pthis) { + pthis->actionFunc = func_808B7AFC; +} + +void func_808B7AFC(BgSpot18Basket* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + OnePointCutscene_Init(globalCtx, 4220, 80, &pthis->dyna.actor, MAIN_CAM); + func_808B7B58(pthis); + } +} + +void func_808B7B58(BgSpot18Basket* pthis) { + pthis->actionFunc = func_808B7B6C; + pthis->unk_216 = 0; +} + +void func_808B7B6C(BgSpot18Basket* pthis, GlobalContext* globalCtx) { + if (pthis->unk_216 > 20) { + func_808B7BB0(pthis); + pthis->dyna.actor.child->parent = NULL; + pthis->dyna.actor.child = NULL; + } +} + +void func_808B7BB0(BgSpot18Basket* pthis) { + pthis->actionFunc = func_808B7BCC; + pthis->unk_210 = pthis->unk_20C = 0; +} + +void func_808B7BCC(BgSpot18Basket* pthis, GlobalContext* globalCtx) { + f32 positionDiff; + Actor* colliderBaseAc; + + Math_StepToS(&pthis->unk_210, 0x1F4, 0x1E); + + pthis->dyna.actor.shape.rot.y += pthis->unk_210; + + Math_StepToF(&pthis->unk_208, 50.0f, 1.5f); + Math_StepToS(&pthis->unk_20C, 400, 15); + + pthis->unk_20E += pthis->unk_20C; + + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->unk_20E) * pthis->unk_208) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->unk_20E) * pthis->unk_208) + pthis->dyna.actor.home.pos.z; + + if (pthis->colliderJntSph.base.acFlags & AC_HIT) { + colliderBaseAc = pthis->colliderJntSph.base.ac; + + if (colliderBaseAc != NULL) { + positionDiff = colliderBaseAc->world.pos.y - pthis->dyna.actor.world.pos.y; + + if (positionDiff > 120.0f && positionDiff < 200.0f) { + if (Math3D_Dist2DSq(colliderBaseAc->world.pos.z, pthis->colliderJntSph.base.ac->world.pos.x, + pthis->dyna.actor.world.pos.z, pthis->dyna.actor.world.pos.x) < SQ(32.0f)) { + OnePointCutscene_Init(globalCtx, 4210, 240, &pthis->dyna.actor, MAIN_CAM); + func_808B7D38(pthis); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } + } + } + } + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); +} + +void func_808B7D38(BgSpot18Basket* pthis) { + pthis->actionFunc = func_808B7D50; + pthis->unk_216 = 0; + pthis->unk_214 = 0; +} + +void func_808B7D50(BgSpot18Basket* pthis, GlobalContext* globalCtx) { + f32 tempValue2; + f32 tempValue; + + if (pthis->unk_216 > 120) { + Math_StepToS(&pthis->unk_210, 0x3E8, 0x32); + } else { + Math_StepToS(&pthis->unk_210, 0xBB8, 0x64); + } + + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.shape.rot.y + pthis->unk_210; + + if (pthis->unk_216 < 70) { + Math_StepToF(&pthis->unk_208, 100.0f, 2.0f); + } else { + Math_StepToF(&pthis->unk_208, 0.0f, 2.0f); + } + + Math_StepToS(&pthis->unk_20C, 1000, 20); + + pthis->unk_20E += pthis->unk_20C; + + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->unk_20E) * pthis->unk_208) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->unk_20E) * pthis->unk_208) + pthis->dyna.actor.home.pos.z; + + pthis->unk_212 += 0xBB8; + + Math_StepToS(&pthis->unk_214, 0x5DC, 0x1E); + + pthis->dyna.actor.shape.rot.x = Math_CosS(pthis->unk_212) * pthis->unk_214; + pthis->dyna.actor.shape.rot.z = -Math_SinS(pthis->unk_212) * pthis->unk_214; + + if (pthis->unk_216 > 140) { + func_808B7F74(pthis); + } + + if (pthis->unk_216 < 80) { + func_808B7770(pthis, globalCtx, 1.0f); + } else { + func_808B7770(pthis, globalCtx, 0.8f); + } + + tempValue2 = (pthis->unk_210 - 500) * 0.0006f; + + tempValue = CLAMP(tempValue2, 0.0f, 1.5f); + + func_800F436C(&pthis->dyna.actor.projectedPos, NA_SE_EV_WALL_MOVE_SP - SFX_FLAG, tempValue); +} + +void func_808B7F74(BgSpot18Basket* pthis) { + s16 shapeRotY; + + shapeRotY = pthis->dyna.actor.shape.rot.y; + pthis->actionFunc = func_808B7FC0; + + if ((shapeRotY < -0x2E93) || (shapeRotY >= 0x7C19)) { + pthis->unk_218 = 2; + } else if (shapeRotY < 0x26C2) { + pthis->unk_218 = 1; + } else { + pthis->unk_218 = 0; + } + + pthis->unk_216 = 0; +} + +void func_808B7FC0(BgSpot18Basket* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 tempUnk214; + f32 tempUnk210; + s16 arrayValue; + f32 clampedTempUnk210; + + pthis->unk_212 += 0xBB8; + + if (pthis->unk_216 >= 13) { + tempUnk214 = Math_StepToS(&pthis->unk_214, 0, 55); + } else { + tempUnk214 = 0; + } + + pthis->dyna.actor.shape.rot.x = Math_CosS(pthis->unk_212) * pthis->unk_214; + pthis->dyna.actor.shape.rot.z = -Math_SinS(pthis->unk_212) * pthis->unk_214; + + Math_StepToS(&pthis->unk_210, 0x1F4, 0xA); + pthis->dyna.actor.shape.rot.y += pthis->unk_210; + + if (tempUnk214 != 0) { + arrayValue = D_808B85C8[pthis->unk_218]; + + if ((s16)(pthis->dyna.actor.shape.rot.y - arrayValue) >= 0) { + pthis->dyna.actor.shape.rot.y = arrayValue; + + func_808B818C(pthis); + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } + } + + if (pthis->unk_216 < 30) { + func_808B7770(pthis, globalCtx, 0.5f); + } else { + func_808B7770(pthis, globalCtx, 0.3f); + } + + tempUnk210 = (pthis->unk_210 - 500) * 0.0006f; + + clampedTempUnk210 = CLAMP(tempUnk210, 0.0f, 1.5f); + + func_800F436C(&pthis->dyna.actor.projectedPos, NA_SE_EV_WALL_MOVE_SP - SFX_FLAG, clampedTempUnk210); +} + +void func_808B818C(BgSpot18Basket* pthis) { + pthis->actionFunc = func_808B81A0; + pthis->unk_216 = 0; +} + +static s16 D_808B85E4[] = { -0x0FA0, 0x0320, 0x0FA0 }; + +void func_808B81A0(BgSpot18Basket* pthis, GlobalContext* globalCtx) { + s32 i; + Actor* actor = &pthis->dyna.actor; + Vec3f tempVector; + EnItem00* collectible; + + if (pthis->unk_216 == 1) { + tempVector.x = actor->world.pos.x; + tempVector.y = actor->world.pos.y + 170.0f; + tempVector.z = actor->world.pos.z; + + if (pthis->unk_218 == 0) { + for (i = 0; i < ARRAY_COUNT(D_808B85E4); i++) { + collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_BOMBS_A); + if (collectible != NULL) { + collectible->actor.velocity.y = 11.0f; + collectible->actor.world.rot.y = D_808B85E4[i]; + } + } + } else if (pthis->unk_218 == 1) { + for (i = 0; i < ARRAY_COUNT(D_808B85E4); i++) { + collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_GREEN); + if (collectible != NULL) { + collectible->actor.velocity.y = 11.0f; + collectible->actor.world.rot.y = D_808B85E4[i]; + } + } + } else if (pthis->unk_218 == 2) { + if ((pthis->unk_21A != 0) || Flags_GetCollectible(globalCtx, (actor->params & 0x3F))) { + collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_PURPLE); + if (collectible != NULL) { + collectible->actor.velocity.y = 11.0f; + collectible->actor.world.rot.y = D_808B85E4[1]; + } + } else { + collectible = + Item_DropCollectible(globalCtx, &tempVector, ((actor->params & 0x3F) << 8) | ITEM00_HEART_PIECE); + if (collectible != NULL) { + collectible->actor.velocity.y = 11.0f; + collectible->actor.world.rot.y = D_808B85E4[1]; + pthis->unk_21A = 1; + } + } + + collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_RED); + if (collectible != NULL) { + collectible->actor.velocity.y = 11.0f; + collectible->actor.world.rot.y = D_808B85E4[0]; + } + + collectible = Item_DropCollectible(globalCtx, &tempVector, ITEM00_RUPEE_BLUE); + if (collectible != NULL) { + collectible->actor.velocity.y = 11.0f; + collectible->actor.world.rot.y = D_808B85E4[2]; + } + } + } else if (pthis->unk_216 == 2) { + if (pthis->unk_218 == 2) { + func_80078884(NA_SE_SY_CORRECT_CHIME); + } else { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (pthis->unk_216 == 200) { + func_808B7BB0(pthis); + } +} + +void BgSpot18Basket_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgSpot18Basket* pthis = (BgSpot18Basket*)thisx; + s32 bgId; + + pthis->unk_216++; + pthis->actionFunc(pthis, globalCtx); + pthis->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, &bgId, + &pthis->dyna.actor, &pthis->dyna.actor.world.pos); + if (pthis->actionFunc != func_808B7AFC) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + if (pthis->actionFunc != func_808B7B6C) { + pthis->colliderJntSph.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + } +} + +void BgSpot18Basket_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Basket* pthis = (BgSpot18Basket*)thisx; + + Collider_UpdateSpheres(0, &pthis->colliderJntSph); + Collider_UpdateSpheres(1, &pthis->colliderJntSph); + Gfx_DrawDListOpa(globalCtx, gGoronCityVaseDL); +} diff --git a/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.c b/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.cpp similarity index 69% rename from src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.c rename to src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.cpp index a5fe329a6..4b5951958 100644 --- a/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.c +++ b/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.cpp @@ -21,7 +21,7 @@ void BgSpot18Futa_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpot18Futa_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpot18Futa_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Spot18_Futa_InitVars = { +ActorInit Bg_Spot18_Futa_InitVars = { ACTOR_BG_SPOT18_FUTA, ACTORCAT_PROP, FLAGS, @@ -41,34 +41,34 @@ static InitChainEntry sInitChain[] = { }; void BgSpot18Futa_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Futa* this = (BgSpot18Futa*)thisx; + BgSpot18Futa* pthis = (BgSpot18Futa*)thisx; s32 pad; CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gGoronCityVaseLidCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); } void BgSpot18Futa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Futa* this = (BgSpot18Futa*)thisx; + BgSpot18Futa* pthis = (BgSpot18Futa*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgSpot18Futa_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Futa* this = (BgSpot18Futa*)thisx; + BgSpot18Futa* pthis = (BgSpot18Futa*)thisx; s32 iVar1; - if (this->dyna.actor.parent == NULL) { - iVar1 = Math_StepToF(&this->dyna.actor.scale.x, 0, 0.005); + if (pthis->dyna.actor.parent == NULL) { + iVar1 = Math_StepToF(&pthis->dyna.actor.scale.x, 0, 0.005); if (iVar1 != 0) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } else { - this->dyna.actor.scale.z = this->dyna.actor.scale.x; - this->dyna.actor.scale.y = this->dyna.actor.scale.x; + pthis->dyna.actor.scale.z = pthis->dyna.actor.scale.x; + pthis->dyna.actor.scale.y = pthis->dyna.actor.scale.x; } } } diff --git a/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c b/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c deleted file mode 100644 index f162d0fb5..000000000 --- a/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c +++ /dev/null @@ -1,294 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT18_OBJ_Z_BG_SPOT18_OBJ_C -#include "actor_common.h" - -/* - * File: z_bg_spot18_obj.c - * Overlay: ovl_Bg_Spot18_Obj - * Description: - */ - -#include "z_bg_spot18_obj.h" -#include "objects/object_spot18_obj/object_spot18_obj.h" -#include "def/code_80043480.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void BgSpot18Obj_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Obj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Obj_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Obj_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 func_808B8910(BgSpot18Obj* this, GlobalContext* globalCtx); -s32 func_808B8A5C(BgSpot18Obj* this, GlobalContext* globalCtx); -s32 func_808B8A98(BgSpot18Obj* this, GlobalContext* globalCtx); -s32 func_808B8B08(BgSpot18Obj* this, GlobalContext* globalCtx); -s32 func_808B8BB4(BgSpot18Obj* this, GlobalContext* globalCtx); -s32 func_808B8C90(BgSpot18Obj* this, GlobalContext* globalCtx); -void func_808B8DC0(BgSpot18Obj* this); -void func_808B8DD0(BgSpot18Obj* this, GlobalContext* globalCtx); -void func_808B8E64(BgSpot18Obj* this); -void func_808B8E7C(BgSpot18Obj* this, GlobalContext* globalCtx); -void func_808B8EE0(BgSpot18Obj* this); -void func_808B8F08(BgSpot18Obj* this, GlobalContext* globalCtx); -void func_808B9030(BgSpot18Obj* this); -void func_808B9040(BgSpot18Obj* this, GlobalContext* globalCtx); - -const ActorInit Bg_Spot18_Obj_InitVars = { - ACTOR_BG_SPOT18_OBJ, - ACTORCAT_BG, - FLAGS, - OBJECT_SPOT18_OBJ, - sizeof(BgSpot18Obj), - (ActorFunc)BgSpot18Obj_Init, - (ActorFunc)BgSpot18Obj_Destroy, - (ActorFunc)BgSpot18Obj_Update, - (ActorFunc)BgSpot18Obj_Draw, -}; - -static u8 D_808B90F0[2][2] = { { 0x01, 0x01 }, { 0x01, 0x00 } }; - -static f32 D_808B90F4[] = { - 0.1f, - 0.1f, -}; - -static CollisionHeader* D_808B90FC[] = { - &gGoronCityStatueCol, - &gGoronCityStatueSpearCol, -}; - -static u32 D_808B9104[] = { - 0, - 0, -}; - -static BgSpot18ObjInitFunc D_808B910C[] = { - func_808B8A98, - func_808B8910, - func_808B8A5C, - func_808B8B08, -}; - -static InitChainEntry sInitChain1[] = { - ICHAIN_F32(minVelocityY, -10, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -4, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), -}; - -static InitChainEntry sInitChain2[] = { - ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 700, ICHAIN_STOP), -}; - -static BgSpot18ObjInitFunc D_808B913C[] = { - func_808B8BB4, - func_808B8C90, -}; - -static Gfx(*sDlists[]) = { - gGoronCityStatueDL, - gGoronCityStatueSpearDL, -}; - -s32 func_808B8910(BgSpot18Obj* this, GlobalContext* globalCtx) { - s32 age; - - if (LINK_AGE_IN_YEARS == YEARS_ADULT) { - age = 1; - } else if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - age = 0; - } else { - osSyncPrintf("Error : リンク年齢不詳 (%s %d)(arg_data 0x%04x)\n", "../z_bg_spot18_obj.c", 182, - this->dyna.actor.params); - return 0; - } - - switch (D_808B90F0[this->dyna.actor.params & 0xF][age]) { - case 0: - case 1: - if (D_808B90F0[this->dyna.actor.params & 0xF][age] == 0) { - osSyncPrintf("出現しない Object (0x%04x)\n", this->dyna.actor.params); - } - return D_808B90F0[this->dyna.actor.params & 0xF][age]; - case 2: - osSyncPrintf("Error : Obj出現判定が設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot18_obj.c", 202, - this->dyna.actor.params); - break; - default: - osSyncPrintf("Error : Obj出現判定失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot18_obj.c", 210, - this->dyna.actor.params); - } - return 0; -} - -s32 func_808B8A5C(BgSpot18Obj* this, GlobalContext* globalCtx) { - Actor_SetScale(&this->dyna.actor, D_808B90F4[this->dyna.actor.params & 0xF]); - return 1; -} - -s32 func_808B8A98(BgSpot18Obj* this, GlobalContext* globalCtx) { - s32 pad[2]; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(D_808B90FC[this->dyna.actor.params & 0xF], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - return 1; -} - -s32 func_808B8B08(BgSpot18Obj* this, GlobalContext* globalCtx) { - this->dyna.actor.flags |= D_808B9104[this->dyna.actor.params & 0xF]; - return 1; -} - -s32 func_808B8B38(BgSpot18Obj* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < ARRAY_COUNT(D_808B910C); i++) { - if (D_808B910C[i](this, globalCtx) == 0) { - return 0; - } - } - return 1; -} - -s32 func_808B8BB4(BgSpot18Obj* this, GlobalContext* globalCtx) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain1); - - if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - func_808B9030(this); - } else if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - func_808B9030(this); - this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.z; - } else { - func_808B8E64(this); - } - return 1; -} - -s32 func_808B8C90(BgSpot18Obj* this, GlobalContext* globalCtx) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); - func_808B8DC0(this); - return 1; -} - -s32 func_808B8CC8(BgSpot18Obj* this, GlobalContext* globalCtx) { - if ((D_808B913C[this->dyna.actor.params & 0xF] != NULL) && - (!D_808B913C[this->dyna.actor.params & 0xF](this, globalCtx))) { - return 0; - } - return 1; -} - -void BgSpot18Obj_Init(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Obj* this = (BgSpot18Obj*)thisx; - - osSyncPrintf("Spot18 Object [arg_data : 0x%04x]\n", this->dyna.actor.params); - if (!func_808B8B38(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } else if (!func_808B8CC8(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -void BgSpot18Obj_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Obj* this = (BgSpot18Obj*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_808B8DC0(BgSpot18Obj* this) { - this->actionFunc = func_808B8DD0; -} - -void func_808B8DD0(BgSpot18Obj* this, GlobalContext* globalCtx) { -} - -void func_808B8DDC(BgSpot18Obj* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 46.0f, 0.0f, 28); -} - -void func_808B8E20(BgSpot18Obj* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (fabsf(this->dyna.unk_150) > 0.001f) { - this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; - } -} - -void func_808B8E64(BgSpot18Obj* this) { - this->unk_168 = 20; - this->actionFunc = func_808B8E7C; -} - -void func_808B8E7C(BgSpot18Obj* this, GlobalContext* globalCtx) { - if (this->dyna.unk_150 < -0.001f) { - if (this->unk_168 <= 0) { - func_808B8EE0(this); - } - } else { - this->unk_168 = 20; - } - func_808B8E20(this, globalCtx); -} - -void func_808B8EE0(BgSpot18Obj* this) { - this->actionFunc = func_808B8F08; - this->dyna.actor.world.rot.y = 0; - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.velocity.z = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.velocity.x = 0.0f; -} - -void func_808B8F08(BgSpot18Obj* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - Math_StepToF(&this->dyna.actor.speedXZ, 1.2f, 0.1f); - Actor_MoveForward(&this->dyna.actor); - func_808B8DDC(this, globalCtx); - - if (Math3D_Dist2DSq(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, this->dyna.actor.home.pos.x, - this->dyna.actor.home.pos.z) >= 6400.0f) { - func_808B9030(this); - this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.z; - this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F); - func_80078884(NA_SE_SY_CORRECT_CHIME); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); - } -} - -void func_808B9030(BgSpot18Obj* this) { - this->actionFunc = func_808B9040; -} - -void func_808B9040(BgSpot18Obj* this, GlobalContext* globalCtx) { - func_808B8E20(this, globalCtx); -} - -void BgSpot18Obj_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Obj* this = (BgSpot18Obj*)thisx; - - if (this->unk_168 > 0) { - this->unk_168 -= 1; - } - this->actionFunc(this, globalCtx); -} - -void BgSpot18Obj_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, sDlists[thisx->params & 0xF]); -} diff --git a/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.cpp b/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.cpp new file mode 100644 index 000000000..bd23a85ed --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.cpp @@ -0,0 +1,294 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT18_OBJ_Z_BG_SPOT18_OBJ_C +#include "actor_common.h" + +/* + * File: z_bg_spot18_obj.c + * Overlay: ovl_Bg_Spot18_Obj + * Description: + */ + +#include "z_bg_spot18_obj.h" +#include "objects/object_spot18_obj/object_spot18_obj.h" +#include "def/code_80043480.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void BgSpot18Obj_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Obj_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Obj_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Obj_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 func_808B8910(BgSpot18Obj* pthis, GlobalContext* globalCtx); +s32 func_808B8A5C(BgSpot18Obj* pthis, GlobalContext* globalCtx); +s32 func_808B8A98(BgSpot18Obj* pthis, GlobalContext* globalCtx); +s32 func_808B8B08(BgSpot18Obj* pthis, GlobalContext* globalCtx); +s32 func_808B8BB4(BgSpot18Obj* pthis, GlobalContext* globalCtx); +s32 func_808B8C90(BgSpot18Obj* pthis, GlobalContext* globalCtx); +void func_808B8DC0(BgSpot18Obj* pthis); +void func_808B8DD0(BgSpot18Obj* pthis, GlobalContext* globalCtx); +void func_808B8E64(BgSpot18Obj* pthis); +void func_808B8E7C(BgSpot18Obj* pthis, GlobalContext* globalCtx); +void func_808B8EE0(BgSpot18Obj* pthis); +void func_808B8F08(BgSpot18Obj* pthis, GlobalContext* globalCtx); +void func_808B9030(BgSpot18Obj* pthis); +void func_808B9040(BgSpot18Obj* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Spot18_Obj_InitVars = { + ACTOR_BG_SPOT18_OBJ, + ACTORCAT_BG, + FLAGS, + OBJECT_SPOT18_OBJ, + sizeof(BgSpot18Obj), + (ActorFunc)BgSpot18Obj_Init, + (ActorFunc)BgSpot18Obj_Destroy, + (ActorFunc)BgSpot18Obj_Update, + (ActorFunc)BgSpot18Obj_Draw, +}; + +static u8 D_808B90F0[2][2] = { { 0x01, 0x01 }, { 0x01, 0x00 } }; + +static f32 D_808B90F4[] = { + 0.1f, + 0.1f, +}; + +static CollisionHeader* D_808B90FC[] = { + &gGoronCityStatueCol, + &gGoronCityStatueSpearCol, +}; + +static u32 D_808B9104[] = { + 0, + 0, +}; + +static BgSpot18ObjInitFunc D_808B910C[] = { + func_808B8A98, + func_808B8910, + func_808B8A5C, + func_808B8B08, +}; + +static InitChainEntry sInitChain1[] = { + ICHAIN_F32(minVelocityY, -10, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -4, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), +}; + +static InitChainEntry sInitChain2[] = { + ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 700, ICHAIN_STOP), +}; + +static BgSpot18ObjInitFunc D_808B913C[] = { + func_808B8BB4, + func_808B8C90, +}; + +static Gfx(*sDlists[]) = { + gGoronCityStatueDL, + gGoronCityStatueSpearDL, +}; + +s32 func_808B8910(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + s32 age; + + if (LINK_AGE_IN_YEARS == YEARS_ADULT) { + age = 1; + } else if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + age = 0; + } else { + osSyncPrintf("Error : リンク年齢不詳 (%s %d)(arg_data 0x%04x)\n", "../z_bg_spot18_obj.c", 182, + pthis->dyna.actor.params); + return 0; + } + + switch (D_808B90F0[pthis->dyna.actor.params & 0xF][age]) { + case 0: + case 1: + if (D_808B90F0[pthis->dyna.actor.params & 0xF][age] == 0) { + osSyncPrintf("出現しない Object (0x%04x)\n", pthis->dyna.actor.params); + } + return D_808B90F0[pthis->dyna.actor.params & 0xF][age]; + case 2: + osSyncPrintf("Error : Obj出現判定が設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot18_obj.c", 202, + pthis->dyna.actor.params); + break; + default: + osSyncPrintf("Error : Obj出現判定失敗(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot18_obj.c", 210, + pthis->dyna.actor.params); + } + return 0; +} + +s32 func_808B8A5C(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + Actor_SetScale(&pthis->dyna.actor, D_808B90F4[pthis->dyna.actor.params & 0xF]); + return 1; +} + +s32 func_808B8A98(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(D_808B90FC[pthis->dyna.actor.params & 0xF], &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + return 1; +} + +s32 func_808B8B08(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.flags |= D_808B9104[pthis->dyna.actor.params & 0xF]; + return 1; +} + +s32 func_808B8B38(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_808B910C); i++) { + if (D_808B910C[i](pthis, globalCtx) == 0) { + return 0; + } + } + return 1; +} + +s32 func_808B8BB4(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain1); + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + func_808B9030(pthis); + } else if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + func_808B9030(pthis); + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->dyna.actor.world.rot.y) * 80.0f) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->dyna.actor.world.rot.y) * 80.0f) + pthis->dyna.actor.home.pos.z; + } else { + func_808B8E64(pthis); + } + return 1; +} + +s32 func_808B8C90(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain2); + func_808B8DC0(pthis); + return 1; +} + +s32 func_808B8CC8(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + if ((D_808B913C[pthis->dyna.actor.params & 0xF] != NULL) && + (!D_808B913C[pthis->dyna.actor.params & 0xF](pthis, globalCtx))) { + return 0; + } + return 1; +} + +void BgSpot18Obj_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Obj* pthis = (BgSpot18Obj*)thisx; + + osSyncPrintf("Spot18 Object [arg_data : 0x%04x]\n", pthis->dyna.actor.params); + if (!func_808B8B38(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } else if (!func_808B8CC8(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgSpot18Obj_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Obj* pthis = (BgSpot18Obj*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_808B8DC0(BgSpot18Obj* pthis) { + pthis->actionFunc = func_808B8DD0; +} + +void func_808B8DD0(BgSpot18Obj* pthis, GlobalContext* globalCtx) { +} + +void func_808B8DDC(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 20.0f, 46.0f, 0.0f, 28); +} + +void func_808B8E20(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (fabsf(pthis->dyna.unk_150) > 0.001f) { + pthis->dyna.unk_150 = 0.0f; + player->stateFlags2 &= ~0x10; + } +} + +void func_808B8E64(BgSpot18Obj* pthis) { + pthis->unk_168 = 20; + pthis->actionFunc = func_808B8E7C; +} + +void func_808B8E7C(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.unk_150 < -0.001f) { + if (pthis->unk_168 <= 0) { + func_808B8EE0(pthis); + } + } else { + pthis->unk_168 = 20; + } + func_808B8E20(pthis, globalCtx); +} + +void func_808B8EE0(BgSpot18Obj* pthis) { + pthis->actionFunc = func_808B8F08; + pthis->dyna.actor.world.rot.y = 0; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.velocity.z = 0.0f; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.velocity.x = 0.0f; +} + +void func_808B8F08(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + Math_StepToF(&pthis->dyna.actor.speedXZ, 1.2f, 0.1f); + Actor_MoveForward(&pthis->dyna.actor); + func_808B8DDC(pthis, globalCtx); + + if (Math3D_Dist2DSq(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.z, pthis->dyna.actor.home.pos.x, + pthis->dyna.actor.home.pos.z) >= 6400.0f) { + func_808B9030(pthis); + pthis->dyna.actor.world.pos.x = (Math_SinS(pthis->dyna.actor.world.rot.y) * 80.0f) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_CosS(pthis->dyna.actor.world.rot.y) * 80.0f) + pthis->dyna.actor.home.pos.z; + pthis->dyna.unk_150 = 0.0f; + player->stateFlags2 &= ~0x10; + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F); + func_80078884(NA_SE_SY_CORRECT_CHIME); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_808B9030(BgSpot18Obj* pthis) { + pthis->actionFunc = func_808B9040; +} + +void func_808B9040(BgSpot18Obj* pthis, GlobalContext* globalCtx) { + func_808B8E20(pthis, globalCtx); +} + +void BgSpot18Obj_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Obj* pthis = (BgSpot18Obj*)thisx; + + if (pthis->unk_168 > 0) { + pthis->unk_168 -= 1; + } + pthis->actionFunc(pthis, globalCtx); +} + +void BgSpot18Obj_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, sDlists[thisx->params & 0xF]); +} diff --git a/src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.c b/src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.c deleted file mode 100644 index 51a7bf7ec..000000000 --- a/src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.c +++ /dev/null @@ -1,149 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT18_SHUTTER_Z_BG_SPOT18_SHUTTER_C -#include "actor_common.h" -/* - * File: z_bg_spot18_shutter.c - * Overlay: Bg_Spot18_Shutter - * Description: - */ - -#include "z_bg_spot18_shutter.h" -#include "objects/object_spot18_obj/object_spot18_obj.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgSpot18Shutter_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Shutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Shutter_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpot18Shutter_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808B95AC(BgSpot18Shutter* this, GlobalContext* globalCtx); -void func_808B95B8(BgSpot18Shutter* this, GlobalContext* globalCtx); -void func_808B9618(BgSpot18Shutter* this, GlobalContext* globalCtx); -void func_808B9698(BgSpot18Shutter* this, GlobalContext* globalCtx); -void func_808B971C(BgSpot18Shutter* this, GlobalContext* globalCtx); - -const ActorInit Bg_Spot18_Shutter_InitVars = { - ACTOR_BG_SPOT18_SHUTTER, - ACTORCAT_PROP, - FLAGS, - OBJECT_SPOT18_OBJ, - sizeof(BgSpot18Shutter), - (ActorFunc)BgSpot18Shutter_Init, - (ActorFunc)BgSpot18Shutter_Destroy, - (ActorFunc)BgSpot18Shutter_Update, - (ActorFunc)BgSpot18Shutter_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgSpot18Shutter_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgSpot18Shutter* this = (BgSpot18Shutter*)thisx; - s32 param = (this->dyna.actor.params >> 8) & 1; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - - if (param == 0) { - if (LINK_AGE_IN_YEARS == YEARS_ADULT) { - if (gSaveContext.infTable[16] & 0x200) { - this->actionFunc = func_808B95AC; - this->dyna.actor.world.pos.y += 180.0f; - } else { - this->actionFunc = func_808B9618; - } - } else { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - this->actionFunc = func_808B95AC; - this->dyna.actor.world.pos.y += 180.0f; - } else { - this->actionFunc = func_808B95B8; - } - } - } else { - if (gSaveContext.infTable[16] & 0x200) { - this->dyna.actor.world.pos.x += 125.0f * Math_CosS(this->dyna.actor.world.rot.y); - this->dyna.actor.world.pos.z -= 125.0f * Math_SinS(this->dyna.actor.world.rot.y); - this->actionFunc = func_808B95AC; - } else { - this->actionFunc = func_808B9618; - } - } - - CollisionHeader_GetVirtual(&gGoronCityDoorCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); -} - -void BgSpot18Shutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Shutter* this = (BgSpot18Shutter*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_808B95AC(BgSpot18Shutter* this, GlobalContext* globalCtx) { -} - -void func_808B95B8(BgSpot18Shutter* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - Actor_SetFocus(&this->dyna.actor, 70.0f); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->actionFunc = func_808B9698; - } -} - -void func_808B9618(BgSpot18Shutter* this, GlobalContext* globalCtx) { - if (gSaveContext.infTable[16] & 0x200) { - Actor_SetFocus(&this->dyna.actor, 70.0f); - if (((this->dyna.actor.params >> 8) & 1) == 0) { - this->actionFunc = func_808B9698; - } else { - this->actionFunc = func_808B971C; - OnePointCutscene_Init(globalCtx, 4221, 140, &this->dyna.actor, MAIN_CAM); - } - } -} - -void func_808B9698(BgSpot18Shutter* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 180.0f, 1.44f)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - this->actionFunc = func_808B95AC; - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); - } -} - -void func_808B971C(BgSpot18Shutter* this, GlobalContext* globalCtx) { - f32 sin = Math_SinS(this->dyna.actor.world.rot.y); - f32 cos = Math_CosS(this->dyna.actor.world.rot.y); - s32 flag = true; - - flag &= Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + (125.0f * cos), fabsf(cos)); - flag &= Math_StepToF(&this->dyna.actor.world.pos.z, this->dyna.actor.home.pos.z - (125.0f * sin), fabsf(sin)); - - if (flag) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - this->actionFunc = func_808B95AC; - } else { - func_8002F974(&this->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); - } -} - -void BgSpot18Shutter_Update(Actor* thisx, GlobalContext* globalCtx) { - BgSpot18Shutter* this = (BgSpot18Shutter*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgSpot18Shutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gGoronCityDoorDL); -} diff --git a/src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.cpp b/src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.cpp new file mode 100644 index 000000000..5e7d3c3d8 --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Spot18_Shutter/z_bg_spot18_shutter.cpp @@ -0,0 +1,149 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_SPOT18_SHUTTER_Z_BG_SPOT18_SHUTTER_C +#include "actor_common.h" +/* + * File: z_bg_spot18_shutter.c + * Overlay: Bg_Spot18_Shutter + * Description: + */ + +#include "z_bg_spot18_shutter.h" +#include "objects/object_spot18_obj/object_spot18_obj.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgSpot18Shutter_Init(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Shutter_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Shutter_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpot18Shutter_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808B95AC(BgSpot18Shutter* pthis, GlobalContext* globalCtx); +void func_808B95B8(BgSpot18Shutter* pthis, GlobalContext* globalCtx); +void func_808B9618(BgSpot18Shutter* pthis, GlobalContext* globalCtx); +void func_808B9698(BgSpot18Shutter* pthis, GlobalContext* globalCtx); +void func_808B971C(BgSpot18Shutter* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Spot18_Shutter_InitVars = { + ACTOR_BG_SPOT18_SHUTTER, + ACTORCAT_PROP, + FLAGS, + OBJECT_SPOT18_OBJ, + sizeof(BgSpot18Shutter), + (ActorFunc)BgSpot18Shutter_Init, + (ActorFunc)BgSpot18Shutter_Destroy, + (ActorFunc)BgSpot18Shutter_Update, + (ActorFunc)BgSpot18Shutter_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgSpot18Shutter_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgSpot18Shutter* pthis = (BgSpot18Shutter*)thisx; + s32 param = (pthis->dyna.actor.params >> 8) & 1; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + + if (param == 0) { + if (LINK_AGE_IN_YEARS == YEARS_ADULT) { + if (gSaveContext.infTable[16] & 0x200) { + pthis->actionFunc = func_808B95AC; + pthis->dyna.actor.world.pos.y += 180.0f; + } else { + pthis->actionFunc = func_808B9618; + } + } else { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + pthis->actionFunc = func_808B95AC; + pthis->dyna.actor.world.pos.y += 180.0f; + } else { + pthis->actionFunc = func_808B95B8; + } + } + } else { + if (gSaveContext.infTable[16] & 0x200) { + pthis->dyna.actor.world.pos.x += 125.0f * Math_CosS(pthis->dyna.actor.world.rot.y); + pthis->dyna.actor.world.pos.z -= 125.0f * Math_SinS(pthis->dyna.actor.world.rot.y); + pthis->actionFunc = func_808B95AC; + } else { + pthis->actionFunc = func_808B9618; + } + } + + CollisionHeader_GetVirtual(&gGoronCityDoorCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); +} + +void BgSpot18Shutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Shutter* pthis = (BgSpot18Shutter*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_808B95AC(BgSpot18Shutter* pthis, GlobalContext* globalCtx) { +} + +void func_808B95B8(BgSpot18Shutter* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + Actor_SetFocus(&pthis->dyna.actor, 70.0f); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->actionFunc = func_808B9698; + } +} + +void func_808B9618(BgSpot18Shutter* pthis, GlobalContext* globalCtx) { + if (gSaveContext.infTable[16] & 0x200) { + Actor_SetFocus(&pthis->dyna.actor, 70.0f); + if (((pthis->dyna.actor.params >> 8) & 1) == 0) { + pthis->actionFunc = func_808B9698; + } else { + pthis->actionFunc = func_808B971C; + OnePointCutscene_Init(globalCtx, 4221, 140, &pthis->dyna.actor, MAIN_CAM); + } + } +} + +void func_808B9698(BgSpot18Shutter* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 180.0f, 1.44f)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + pthis->actionFunc = func_808B95AC; + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); + } +} + +void func_808B971C(BgSpot18Shutter* pthis, GlobalContext* globalCtx) { + f32 sin = Math_SinS(pthis->dyna.actor.world.rot.y); + f32 cos = Math_CosS(pthis->dyna.actor.world.rot.y); + s32 flag = true; + + flag &= Math_StepToF(&pthis->dyna.actor.world.pos.x, pthis->dyna.actor.home.pos.x + (125.0f * cos), fabsf(cos)); + flag &= Math_StepToF(&pthis->dyna.actor.world.pos.z, pthis->dyna.actor.home.pos.z - (125.0f * sin), fabsf(sin)); + + if (flag) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + pthis->actionFunc = func_808B95AC; + } else { + func_8002F974(&pthis->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); + } +} + +void BgSpot18Shutter_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpot18Shutter* pthis = (BgSpot18Shutter*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgSpot18Shutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gGoronCityDoorDL); +} diff --git a/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c b/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.cpp similarity index 63% rename from src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c rename to src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.cpp index 5f163550d..4810f902c 100644 --- a/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c +++ b/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.cpp @@ -19,14 +19,14 @@ #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) -void BgSstFloor_Init(BgSstFloor* this, GlobalContext* globalCtx); -void BgSstFloor_Destroy(BgSstFloor* this, GlobalContext* globalCtx); -void BgSstFloor_Update(BgSstFloor* this, GlobalContext* globalCtx); -void BgSstFloor_Draw(BgSstFloor* this, GlobalContext* globalCtx); +void BgSstFloor_Init(BgSstFloor* pthis, GlobalContext* globalCtx); +void BgSstFloor_Destroy(BgSstFloor* pthis, GlobalContext* globalCtx); +void BgSstFloor_Update(BgSstFloor* pthis, GlobalContext* globalCtx); +void BgSstFloor_Draw(BgSstFloor* pthis, GlobalContext* globalCtx); static s32 sUnkValues[] = { 0, 0, 0 }; // Unused, probably a zero vector -const ActorInit Bg_Sst_Floor_InitVars = { +ActorInit Bg_Sst_Floor_InitVars = { ACTOR_BG_SST_FLOOR, ACTORCAT_BG, FLAGS, @@ -44,54 +44,54 @@ static InitChainEntry sInitChain[] = { void BgSstFloor_Init(BgSstFloor* thisx, GlobalContext* globalCtx) { s32 pad; - BgSstFloor* this = (BgSstFloor*)thisx; + BgSstFloor* pthis = (BgSstFloor*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); CollisionHeader_GetVirtual(&gBongoDrumCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } void BgSstFloor_Destroy(BgSstFloor* thisx, GlobalContext* globalCtx) { s32 pad; - BgSstFloor* this = (BgSstFloor*)thisx; + BgSstFloor* pthis = (BgSstFloor*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgSstFloor_Update(BgSstFloor* thisx, GlobalContext* globalCtx) { s32 pad; - BgSstFloor* this = (BgSstFloor*)thisx; + BgSstFloor* pthis = (BgSstFloor*)thisx; Player* player = GET_PLAYER(globalCtx); - CollisionHeader* colHeader = SEGMENTED_TO_VIRTUAL(&gBongoDrumCol); + CollisionHeader* colHeader = &gBongoDrumCol; - colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); + colHeader->vtxList = colHeader->vtxList; if (1) {} - if (func_80043590(&this->dyna) && (this->dyna.actor.yDistToPlayer < 1000.0f)) { + if (func_80043590(&pthis->dyna) && (pthis->dyna.actor.yDistToPlayer < 1000.0f)) { Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BOSS_BONGO); } else { Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); } - if (func_8004356C(&this->dyna) && (player->fallDistance > 1000.0f)) { - this->dyna.actor.params = 1; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_SHADEST_TAIKO_HIGH); + if (func_8004356C(&pthis->dyna) && (player->fallDistance > 1000.0f)) { + pthis->dyna.actor.params = 1; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_SHADEST_TAIKO_HIGH); } - if (this->dyna.actor.params == BONGOFLOOR_HIT) { + if (pthis->dyna.actor.params == BONGOFLOOR_HIT) { Actor* item00 = globalCtx->actorCtx.actorLists[ACTORCAT_MISC].head; f32 distFromRim; f32 xzDist; - this->drumAmp = 80; - this->dyna.actor.params = BONGOFLOOR_REST; - this->drumPhase = 28; + pthis->drumAmp = 80; + pthis->dyna.actor.params = BONGOFLOOR_REST; + pthis->drumPhase = 28; - if (func_8004356C(&this->dyna) && !(player->stateFlags1 & 0x6000)) { - distFromRim = 600.0f - this->dyna.actor.xzDistToPlayer; + if (func_8004356C(&pthis->dyna) && !(player->stateFlags1 & 0x6000)) { + distFromRim = 600.0f - pthis->dyna.actor.xzDistToPlayer; if (distFromRim > 0.0f) { if (distFromRim > 350.0f) { distFromRim = 350.0f; @@ -103,7 +103,7 @@ void BgSstFloor_Update(BgSstFloor* thisx, GlobalContext* globalCtx) { while (item00 != NULL) { if ((item00->id == ACTOR_EN_ITEM00) && (item00->world.pos.y == 0.0f)) { - xzDist = Actor_WorldDistXZToActor(&this->dyna.actor, item00); + xzDist = Actor_WorldDistXZToActor(&pthis->dyna.actor, item00); distFromRim = 600.0f - xzDist; if (xzDist < 600.0f) { if (distFromRim > 350.0f) { @@ -116,26 +116,26 @@ void BgSstFloor_Update(BgSstFloor* thisx, GlobalContext* globalCtx) { item00 = item00->next; } } - this->drumHeight = sinf(this->drumPhase * (M_PI / 2)) * (-this->drumAmp); - Math_StepToS(&this->drumAmp, 0, 5); + pthis->drumHeight = sinf(pthis->drumPhase * (M_PI / 2)) * (-pthis->drumAmp); + Math_StepToS(&pthis->drumAmp, 0, 5); colHeader->vtxList[1].y = colHeader->vtxList[0].y = colHeader->vtxList[2].y = colHeader->vtxList[3].y = colHeader->vtxList[4].y = colHeader->vtxList[7].y = colHeader->vtxList[9].y = colHeader->vtxList[11].y = - colHeader->vtxList[13].y = this->dyna.actor.home.pos.y + this->drumHeight; + colHeader->vtxList[13].y = pthis->dyna.actor.home.pos.y + pthis->drumHeight; - if (this->drumPhase != 0) { - this->drumPhase--; + if (pthis->drumPhase != 0) { + pthis->drumPhase--; } if (1) {} func_8003EE6C(globalCtx, &globalCtx->colCtx.dyna); } void BgSstFloor_Draw(BgSstFloor* thisx, GlobalContext* globalCtx) { - BgSstFloor* this = (BgSstFloor*)thisx; + BgSstFloor* pthis = (BgSstFloor*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_sst_floor.c", 277); func_80093D18(globalCtx->state.gfxCtx); - Matrix_Scale(1.0f, this->drumHeight * -0.0025f, 1.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, pthis->drumHeight * -0.0025f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_sst_floor.c", 283), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.cpp similarity index 61% rename from src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c rename to src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.cpp index dcf2e44ed..b47d709e8 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c +++ b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.cpp @@ -21,14 +21,14 @@ void BgTokiHikari_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgTokiHikari_Update(Actor* thisx, GlobalContext* globalCtx); void BgTokiHikari_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgTokiHikari_DoNothing(BgTokiHikari* this, GlobalContext* globalCtx); -void func_808BA018(BgTokiHikari* this, GlobalContext* globalCtx); -void func_808BA204(BgTokiHikari* this, GlobalContext* globalCtx); -void func_808BA22C(BgTokiHikari* this, GlobalContext* globalCtx); -void func_808BA274(BgTokiHikari* this, GlobalContext* globalCtx); -void func_808BA2CC(BgTokiHikari* this, GlobalContext* globalCtx); +void BgTokiHikari_DoNothing(BgTokiHikari* pthis, GlobalContext* globalCtx); +void func_808BA018(BgTokiHikari* pthis, GlobalContext* globalCtx); +void func_808BA204(BgTokiHikari* pthis, GlobalContext* globalCtx); +void func_808BA22C(BgTokiHikari* pthis, GlobalContext* globalCtx); +void func_808BA274(BgTokiHikari* pthis, GlobalContext* globalCtx); +void func_808BA2CC(BgTokiHikari* pthis, GlobalContext* globalCtx); -const ActorInit Bg_Toki_Hikari_InitVars = { +ActorInit Bg_Toki_Hikari_InitVars = { ACTOR_BG_TOKI_HIKARI, ACTORCAT_BG, FLAGS, @@ -45,19 +45,19 @@ static InitChainEntry sInitChain[] = { }; void BgTokiHikari_Init(Actor* thisx, GlobalContext* globalCtx) { - BgTokiHikari* this = (BgTokiHikari*)thisx; + BgTokiHikari* pthis = (BgTokiHikari*)thisx; - switch (this->actor.params) { + switch (pthis->actor.params) { case 0: - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actionFunc = BgTokiHikari_DoNothing; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actionFunc = BgTokiHikari_DoNothing; break; case 1: if (!(gSaveContext.eventChkInf[4] & 0x800)) { - this->actionFunc = func_808BA204; - this->unk_14C = 0.0f; + pthis->actionFunc = func_808BA204; + pthis->unk_14C = 0.0f; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; } @@ -66,29 +66,29 @@ void BgTokiHikari_Init(Actor* thisx, GlobalContext* globalCtx) { void BgTokiHikari_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void BgTokiHikari_DoNothing(BgTokiHikari* this, GlobalContext* globalCtx) { +void BgTokiHikari_DoNothing(BgTokiHikari* pthis, GlobalContext* globalCtx) { } void BgTokiHikari_Update(Actor* thisx, GlobalContext* globalCtx) { - BgTokiHikari* this = (BgTokiHikari*)thisx; + BgTokiHikari* pthis = (BgTokiHikari*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void BgTokiHikari_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgTokiHikari* this = (BgTokiHikari*)thisx; + BgTokiHikari* pthis = (BgTokiHikari*)thisx; - switch (this->actor.params) { + switch (pthis->actor.params) { case 0: - func_808BA018(this, globalCtx); + func_808BA018(pthis, globalCtx); break; case 1: - func_808BA2CC(this, globalCtx); + func_808BA2CC(pthis, globalCtx); break; } } -void func_808BA018(BgTokiHikari* this, GlobalContext* globalCtx) { +void func_808BA018(BgTokiHikari* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_toki_hikari.c", 246); @@ -115,44 +115,44 @@ void func_808BA018(BgTokiHikari* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_toki_hikari.c", 284); } -void func_808BA204(BgTokiHikari* this, GlobalContext* globalCtx) { +void func_808BA204(BgTokiHikari* pthis, GlobalContext* globalCtx) { if (globalCtx->roomCtx.unk_74[1] != 0) { - this->actionFunc = func_808BA22C; + pthis->actionFunc = func_808BA22C; } } -void func_808BA22C(BgTokiHikari* this, GlobalContext* globalCtx) { - if (this->unk_14C < 1.0f) { - this->unk_14C += 0.05f; +void func_808BA22C(BgTokiHikari* pthis, GlobalContext* globalCtx) { + if (pthis->unk_14C < 1.0f) { + pthis->unk_14C += 0.05f; } else { - this->unk_14C = 1.0f; - this->actionFunc = func_808BA274; + pthis->unk_14C = 1.0f; + pthis->actionFunc = func_808BA274; } } -void func_808BA274(BgTokiHikari* this, GlobalContext* globalCtx) { - if (this->unk_14C > 0.2f) { - this->unk_14C -= 0.025f; +void func_808BA274(BgTokiHikari* pthis, GlobalContext* globalCtx) { + if (pthis->unk_14C > 0.2f) { + pthis->unk_14C -= 0.025f; } else { - this->unk_14C = 0.0f; - Actor_Kill(&this->actor); + pthis->unk_14C = 0.0f; + Actor_Kill(&pthis->actor); } } -void func_808BA2CC(BgTokiHikari* this, GlobalContext* globalCtx) { +void func_808BA2CC(BgTokiHikari* pthis, GlobalContext* globalCtx) { s32 pad[2]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_toki_hikari.c", 350); Matrix_Translate(0.0f, 276.0f, 1122.0f, MTXMODE_NEW); - Matrix_Scale(0.32f, 0.32f, this->unk_14C * 7.0f, MTXMODE_APPLY); + Matrix_Scale(0.32f, 0.32f, pthis->unk_14C * 7.0f, MTXMODE_APPLY); Matrix_RotateZ(M_PI, MTXMODE_APPLY); func_80093D18(globalCtx->state.gfxCtx); Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->unk_14C * 255.0f, (u8)(155.0f * this->unk_14C) + 100, - this->unk_14C * 255.0f, this->unk_14C * 255.0f); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, pthis->unk_14C * 255.0f, (u8)(155.0f * pthis->unk_14C) + 100, + pthis->unk_14C * 255.0f, pthis->unk_14C * 255.0f); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->unk_14C * 155.0f) + 100, (u8)(255.0f * this->unk_14C), 0, 128); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(pthis->unk_14C * 155.0f) + 100, (u8)(255.0f * pthis->unk_14C), 0, 128); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_toki_hikari.c", 382), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -165,10 +165,10 @@ void func_808BA2CC(BgTokiHikari* this, GlobalContext* globalCtx) { Matrix_Pop(); Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(this->unk_14C * 200.0f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(pthis->unk_14C * 200.0f)); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->unk_14C * 255.0f), (u8)(this->unk_14C * 255.0f), - (u8)(this->unk_14C * 255.0f), (u8)(200.0f * this->unk_14C)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(pthis->unk_14C * 255.0f), (u8)(pthis->unk_14C * 255.0f), + (u8)(pthis->unk_14C * 255.0f), (u8)(200.0f * pthis->unk_14C)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_toki_hikari.c", 415), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -177,10 +177,10 @@ void func_808BA2CC(BgTokiHikari* this, GlobalContext* globalCtx) { Matrix_Pop(); Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(this->unk_14C * 200.0f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(pthis->unk_14C * 200.0f)); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->unk_14C * 255.0f), (u8)(this->unk_14C * 255.0f), - (u8)(this->unk_14C * 255.0f), (u8)(200.0f * this->unk_14C)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(pthis->unk_14C * 255.0f), (u8)(pthis->unk_14C * 255.0f), + (u8)(pthis->unk_14C * 255.0f), (u8)(200.0f * pthis->unk_14C)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_toki_hikari.c", 437), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.cpp similarity index 65% rename from src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c rename to src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.cpp index 6caa8c995..b5c0378d7 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.cpp @@ -26,15 +26,15 @@ void BgTokiSwd_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgTokiSwd_Update(Actor* thisx, GlobalContext* globalCtx); void BgTokiSwd_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808BAF40(BgTokiSwd* this, GlobalContext* globalCtx); -void func_808BB0AC(BgTokiSwd* this, GlobalContext* globalCtx); -void func_808BB128(BgTokiSwd* this, GlobalContext* globalCtx); +void func_808BAF40(BgTokiSwd* pthis, GlobalContext* globalCtx); +void func_808BB0AC(BgTokiSwd* pthis, GlobalContext* globalCtx); +void func_808BB128(BgTokiSwd* pthis, GlobalContext* globalCtx); extern CutsceneData D_808BB2F0[]; extern CutsceneData D_808BB7A0[]; extern CutsceneData D_808BBD90[]; -const ActorInit Bg_Toki_Swd_InitVars = { +ActorInit Bg_Toki_Swd_InitVars = { ACTOR_BG_TOKI_SWD, ACTORCAT_PROP, FLAGS, @@ -72,47 +72,47 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), }; -void BgTokiSwd_SetupAction(BgTokiSwd* this, BgTokiSwdActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgTokiSwd_SetupAction(BgTokiSwd* pthis, BgTokiSwdActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgTokiSwd_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgTokiSwd* this = (BgTokiSwd*)thisx; + BgTokiSwd* pthis = (BgTokiSwd*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.shape.yOffset = 800.0f; - BgTokiSwd_SetupAction(this, func_808BAF40); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.shape.yOffset = 800.0f; + BgTokiSwd_SetupAction(pthis, func_808BAF40); if (LINK_IS_ADULT) { - this->actor.draw = NULL; + pthis->actor.draw = NULL; } if (gSaveContext.sceneSetupIndex == 5) { globalCtx->roomCtx.unk_74[0] = 0xFF; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); } void BgTokiSwd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgTokiSwd* this = (BgTokiSwd*)thisx; + BgTokiSwd* pthis = (BgTokiSwd*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_808BAF40(BgTokiSwd* this, GlobalContext* globalCtx) { +void func_808BAF40(BgTokiSwd* pthis, GlobalContext* globalCtx) { if (((gSaveContext.eventChkInf[4] & 0x8000) == 0) && (gSaveContext.sceneSetupIndex < 4) && - Actor_IsFacingAndNearPlayer(&this->actor, 800.0f, 0x7530) && !Gameplay_InCsMode(globalCtx)) { + Actor_IsFacingAndNearPlayer(&pthis->actor, 800.0f, 0x7530) && !Gameplay_InCsMode(globalCtx)) { gSaveContext.eventChkInf[4] |= 0x8000; globalCtx->csCtx.segment = D_808BBD90; gSaveContext.cutsceneTrigger = 1; } if (!LINK_IS_ADULT || ((gSaveContext.eventChkInf[5] & 0x20))) { - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { if (!LINK_IS_ADULT) { Item_Give(globalCtx, ITEM_SWORD_MASTER); globalCtx->csCtx.segment = D_808BB2F0; @@ -122,11 +122,11 @@ void func_808BAF40(BgTokiSwd* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_MASTER_SWORD); gSaveContext.cutsceneTrigger = 1; - this->actor.parent = NULL; - BgTokiSwd_SetupAction(this, func_808BB0AC); + pthis->actor.parent = NULL; + BgTokiSwd_SetupAction(pthis, func_808BB0AC); } else { - if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_8002F580(&this->actor, globalCtx); + if (Actor_IsFacingPlayer(&pthis->actor, 0x2000)) { + func_8002F580(&pthis->actor, globalCtx); } } } @@ -139,47 +139,47 @@ void func_808BAF40(BgTokiSwd* this, GlobalContext* globalCtx) { } } -void func_808BB0AC(BgTokiSwd* this, GlobalContext* globalCtx) { +void func_808BB0AC(BgTokiSwd* pthis, GlobalContext* globalCtx) { Player* player; // if sword has a parent it has been pulled/placed from the pedestal - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { if (!LINK_IS_ADULT) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SWORD_PUTAWAY_STN); - this->actor.draw = NULL; // sword has been pulled, dont draw sword + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SWORD_PUTAWAY_STN); + pthis->actor.draw = NULL; // sword has been pulled, dont draw sword } else { - this->actor.draw = BgTokiSwd_Draw; // sword has been placed, draw the master sword + pthis->actor.draw = BgTokiSwd_Draw; // sword has been placed, draw the master sword } - BgTokiSwd_SetupAction(this, func_808BB128); + BgTokiSwd_SetupAction(pthis, func_808BB128); } else { player = GET_PLAYER(globalCtx); - player->interactRangeActor = &this->actor; + player->interactRangeActor = &pthis->actor; } } -void func_808BB128(BgTokiSwd* this, GlobalContext* globalCtx) { +void func_808BB128(BgTokiSwd* pthis, GlobalContext* globalCtx) { if (Flags_GetEnv(globalCtx, 1) && (globalCtx->roomCtx.unk_74[0] < 0xFF)) { globalCtx->roomCtx.unk_74[0] += 5; } } void BgTokiSwd_Update(Actor* thisx, GlobalContext* globalCtx) { - BgTokiSwd* this = (BgTokiSwd*)thisx; + BgTokiSwd* pthis = (BgTokiSwd*)thisx; - this->actionFunc(this, globalCtx); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->actionFunc(pthis, globalCtx); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } void BgTokiSwd_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BgTokiSwd* this = (BgTokiSwd*)thisx; + BgTokiSwd* pthis = (BgTokiSwd*)thisx; s32 pad[3]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_toki_swd.c", 727); func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, -(globalCtx->gameplayFrames % 0x80), 32, 32)); diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_1.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_1.cpp similarity index 100% rename from src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_1.c rename to src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_1.cpp diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_2.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_2.cpp similarity index 100% rename from src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_2.c rename to src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_2.cpp diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_3.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_3.cpp similarity index 100% rename from src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_3.c rename to src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd_cutscene_data_3.cpp diff --git a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.cpp similarity index 65% rename from src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c rename to src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.cpp index c54a6b3a6..99520961a 100644 --- a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c +++ b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.cpp @@ -33,21 +33,21 @@ void BgTreemouth_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgTreemouth_Update(Actor* thisx, GlobalContext* globalCtx); void BgTreemouth_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808BC65C(BgTreemouth* this, GlobalContext* globalCtx); -void func_808BC6F8(BgTreemouth* this, GlobalContext* globalCtx); -void func_808BC80C(BgTreemouth* this, GlobalContext* globalCtx); -void func_808BC864(BgTreemouth* this, GlobalContext* globalCtx); -void BgTreemouth_DoNothing(BgTreemouth* this, GlobalContext* globalCtx); -void func_808BC8B8(BgTreemouth* this, GlobalContext* globalCtx); -void func_808BC9EC(BgTreemouth* this, GlobalContext* globalCtx); -void func_808BCAF0(BgTreemouth* this, GlobalContext* globalCtx); +void func_808BC65C(BgTreemouth* pthis, GlobalContext* globalCtx); +void func_808BC6F8(BgTreemouth* pthis, GlobalContext* globalCtx); +void func_808BC80C(BgTreemouth* pthis, GlobalContext* globalCtx); +void func_808BC864(BgTreemouth* pthis, GlobalContext* globalCtx); +void BgTreemouth_DoNothing(BgTreemouth* pthis, GlobalContext* globalCtx); +void func_808BC8B8(BgTreemouth* pthis, GlobalContext* globalCtx); +void func_808BC9EC(BgTreemouth* pthis, GlobalContext* globalCtx); +void func_808BCAF0(BgTreemouth* pthis, GlobalContext* globalCtx); extern CutsceneData D_808BCE20[]; extern CutsceneData D_808BD2A0[]; extern CutsceneData D_808BD520[]; extern CutsceneData D_808BD790[]; -const ActorInit Bg_Treemouth_InitVars = { +ActorInit Bg_Treemouth_InitVars = { ACTOR_BG_TREEMOUTH, ACTORCAT_BG, FLAGS, @@ -72,64 +72,64 @@ static f32 D_808BD9C4[] = { -2746.0f, 545.0f, 4694.0f, -2654.0f, 146.0f, 4534.0f, }; -void BgTreemouth_SetupAction(BgTreemouth* this, BgTreemouthActionFunc actionFunc) { - this->actionFunc = actionFunc; +void BgTreemouth_SetupAction(BgTreemouth* pthis, BgTreemouthActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void BgTreemouth_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgTreemouth* this = (BgTreemouth*)thisx; + BgTreemouth* pthis = (BgTreemouth*)thisx; CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gDekuTreeMouthCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); Actor_SetFocus(thisx, 50.0f); if ((gSaveContext.sceneSetupIndex < 4) && !LINK_IS_ADULT) { - BgTreemouth_SetupAction(this, func_808BC8B8); + BgTreemouth_SetupAction(pthis, func_808BC8B8); } else if (LINK_IS_ADULT || (gSaveContext.sceneSetupIndex == 7)) { - this->unk_168 = 0.0f; - BgTreemouth_SetupAction(this, BgTreemouth_DoNothing); + pthis->unk_168 = 0.0f; + BgTreemouth_SetupAction(pthis, BgTreemouth_DoNothing); } else { - this->unk_168 = 1.0f; - BgTreemouth_SetupAction(this, func_808BC6F8); + pthis->unk_168 = 1.0f; + BgTreemouth_SetupAction(pthis, func_808BC6F8); } thisx->textId = 0x905; } void BgTreemouth_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgTreemouth* this = (BgTreemouth*)thisx; + BgTreemouth* pthis = (BgTreemouth*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808BC65C(BgTreemouth* this, GlobalContext* globalCtx) { +void func_808BC65C(BgTreemouth* pthis, GlobalContext* globalCtx) { CsCmdActorAction* npcAction; if ((globalCtx->csCtx.state != CS_STATE_IDLE)) { npcAction = globalCtx->csCtx.npcActions[0]; if (npcAction != NULL) { if (npcAction->action == 2) { - BgTreemouth_SetupAction(this, func_808BC80C); + BgTreemouth_SetupAction(pthis, func_808BC80C); } else if (npcAction->action == 3) { Audio_PlaySoundGeneral(NA_SE_EV_WOODDOOR_OPEN, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - BgTreemouth_SetupAction(this, func_808BC6F8); + BgTreemouth_SetupAction(pthis, func_808BC6F8); } } } } -void func_808BC6F8(BgTreemouth* this, GlobalContext* globalCtx) { +void func_808BC6F8(BgTreemouth* pthis, GlobalContext* globalCtx) { Vec3f sp34; - if (this->unk_168 < 1.0f) { - this->unk_168 += 0.01f; + if (pthis->unk_168 < 1.0f) { + pthis->unk_168 += 0.01f; } else { - this->unk_168 = 1.0f; + pthis->unk_168 = 1.0f; } if ((gSaveContext.sceneSetupIndex == 6) && (globalCtx->csCtx.frames >= 0x2BD) && @@ -141,50 +141,50 @@ void func_808BC6F8(BgTreemouth* this, GlobalContext* globalCtx) { } } -void func_808BC80C(BgTreemouth* this, GlobalContext* globalCtx) { - this->unk_168 += 0.05f; - if (this->unk_168 >= 0.8f) { - BgTreemouth_SetupAction(this, func_808BC864); +void func_808BC80C(BgTreemouth* pthis, GlobalContext* globalCtx) { + pthis->unk_168 += 0.05f; + if (pthis->unk_168 >= 0.8f) { + BgTreemouth_SetupAction(pthis, func_808BC864); } } -void func_808BC864(BgTreemouth* this, GlobalContext* globalCtx) { - this->unk_168 -= 0.03f; - if (this->unk_168 <= 0.0f) { - BgTreemouth_SetupAction(this, func_808BC65C); +void func_808BC864(BgTreemouth* pthis, GlobalContext* globalCtx) { + pthis->unk_168 -= 0.03f; + if (pthis->unk_168 <= 0.0f) { + BgTreemouth_SetupAction(pthis, func_808BC65C); } } -void func_808BC8B8(BgTreemouth* this, GlobalContext* globalCtx) { +void func_808BC8B8(BgTreemouth* pthis, GlobalContext* globalCtx) { if ((!(Flags_GetEventChkInf(5))) || LINK_IS_ADULT) { if (!LINK_IS_ADULT) { if (Flags_GetEventChkInf(0xC)) { - if (Actor_IsFacingAndNearPlayer(&this->dyna.actor, 1658.0f, 0x7530)) { - this->dyna.actor.flags |= ACTOR_FLAG_0; - if (this->dyna.actor.isTargeted) { - this->dyna.actor.flags &= ~ACTOR_FLAG_0; + if (Actor_IsFacingAndNearPlayer(&pthis->dyna.actor, 1658.0f, 0x7530)) { + pthis->dyna.actor.flags |= ACTOR_FLAG_0; + if (pthis->dyna.actor.isTargeted) { + pthis->dyna.actor.flags &= ~ACTOR_FLAG_0; globalCtx->csCtx.segment = D_808BD2A0; gSaveContext.cutsceneTrigger = 1; - BgTreemouth_SetupAction(this, func_808BC9EC); + BgTreemouth_SetupAction(pthis, func_808BC9EC); } } - } else if (Actor_IsFacingAndNearPlayer(&this->dyna.actor, 1658.0f, 0x4E20)) { + } else if (Actor_IsFacingAndNearPlayer(&pthis->dyna.actor, 1658.0f, 0x4E20)) { Flags_SetEventChkInf(0xC); globalCtx->csCtx.segment = D_808BCE20; gSaveContext.cutsceneTrigger = 1; - BgTreemouth_SetupAction(this, func_808BC9EC); + BgTreemouth_SetupAction(pthis, func_808BC9EC); } } } else { - this->unk_168 = 1.0f; + pthis->unk_168 = 1.0f; } } -void func_808BC9EC(BgTreemouth* this, GlobalContext* globalCtx) { +void func_808BC9EC(BgTreemouth* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->csCtx.state == CS_STATE_UNSKIPPABLE_INIT) { - if (Actor_IsFacingAndNearPlayer(&this->dyna.actor, 350.0f, 0x7530)) { + if (Actor_IsFacingAndNearPlayer(&pthis->dyna.actor, 350.0f, 0x7530)) { player->actor.world.pos.x = 3827.0f; player->actor.world.pos.y = -161.0f; player->actor.world.pos.z = -1142.0f; @@ -202,40 +202,40 @@ void func_808BC9EC(BgTreemouth* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.choiceIndex == 0) { globalCtx->csCtx.segment = D_808BD520; Flags_SetEventChkInf(5); - BgTreemouth_SetupAction(this, func_808BCAF0); + BgTreemouth_SetupAction(pthis, func_808BCAF0); } else { globalCtx->csCtx.segment = D_808BD790; globalCtx->csCtx.frames = 0; - BgTreemouth_SetupAction(this, func_808BC8B8); + BgTreemouth_SetupAction(pthis, func_808BC8B8); } } } -void func_808BCAF0(BgTreemouth* this, GlobalContext* globalCtx) { +void func_808BCAF0(BgTreemouth* pthis, GlobalContext* globalCtx) { CsCmdActorAction* npcAction; if (globalCtx->csCtx.state != CS_STATE_IDLE) { npcAction = globalCtx->csCtx.npcActions[0]; if (npcAction != NULL) { if (npcAction->action == 2) { - BgTreemouth_SetupAction(this, func_808BC80C); + BgTreemouth_SetupAction(pthis, func_808BC80C); } else if (npcAction->action == 3) { Audio_PlaySoundGeneral(NA_SE_EV_WOODDOOR_OPEN, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - BgTreemouth_SetupAction(this, func_808BC6F8); + BgTreemouth_SetupAction(pthis, func_808BC6F8); } } } } -void BgTreemouth_DoNothing(BgTreemouth* this, GlobalContext* globalCtx) { +void BgTreemouth_DoNothing(BgTreemouth* pthis, GlobalContext* globalCtx) { } void BgTreemouth_Update(Actor* thisx, GlobalContext* globalCtx) { - BgTreemouth* this = (BgTreemouth*)thisx; + BgTreemouth* pthis = (BgTreemouth*)thisx; f32 unk_168; - this->actionFunc(this, globalCtx); - unk_168 = this->unk_168; + pthis->actionFunc(pthis, globalCtx); + unk_168 = pthis->unk_168; thisx->world.pos.x = (unk_168 * -160.0f) + 4029.0f; thisx->world.pos.y = (unk_168 * -399.0f) + 136.0f; thisx->world.pos.z = (unk_168 * 92.0f) + -1255.0f; diff --git a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth_cutscene_data.c b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth_cutscene_data.c rename to src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.cpp similarity index 73% rename from src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c rename to src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.cpp index 0b802754c..bfb34698a 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.cpp @@ -21,7 +21,7 @@ void BgUmaJump_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgUmaJump_Update(Actor* thisx, GlobalContext* globalCtx); void BgUmaJump_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Umajump_InitVars = { +ActorInit Bg_Umajump_InitVars = { ACTOR_BG_UMAJUMP, ACTORCAT_PROP, FLAGS, @@ -39,27 +39,27 @@ static InitChainEntry sInitChain[] = { void BgUmaJump_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgUmaJump* this = (BgUmaJump*)thisx; + BgUmaJump* pthis = (BgUmaJump*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gJumpableHorseFenceCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); - if (this->dyna.actor.params == 1) { + if (pthis->dyna.actor.params == 1) { if (!Flags_GetEventChkInf(0x18) && (DREG(1) == 0)) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return; } - this->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + pthis->dyna.actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; } } void BgUmaJump_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgUmaJump* this = (BgUmaJump*)thisx; + BgUmaJump* pthis = (BgUmaJump*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgUmaJump_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.c b/src/overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.cpp similarity index 81% rename from src/overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.c rename to src/overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.cpp index 7401881b5..662084702 100644 --- a/src/overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.c +++ b/src/overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.cpp @@ -26,7 +26,7 @@ void BgVbSima_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgVbSima_Update(Actor* thisx, GlobalContext* globalCtx); void BgVbSima_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Bg_Vb_Sima_InitVars = { +ActorInit Bg_Vb_Sima_InitVars = { ACTOR_BG_VB_SIMA, ACTORCAT_BG, FLAGS, @@ -44,20 +44,20 @@ static InitChainEntry sInitChain[] = { void BgVbSima_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgVbSima* this = (BgVbSima*)thisx; + BgVbSima* pthis = (BgVbSima*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); CollisionHeader_GetVirtual(&gVolvagiaPlatformCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } void BgVbSima_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BgVbSima* this = (BgVbSima*)thisx; + BgVbSima* pthis = (BgVbSima*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void BgVbSima_SpawnEmber(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { @@ -81,23 +81,23 @@ void BgVbSima_Update(Actor* thisx, GlobalContext* globalCtx) { static Color_RGBA8 colorYellow = { 255, 255, 0, 255 }; static Color_RGBA8 colorRed = { 255, 10, 0, 255 }; s32 pad; - BgVbSima* this = (BgVbSima*)thisx; - BossFd* bossFd = (BossFd*)this->dyna.actor.parent; + BgVbSima* pthis = (BgVbSima*)thisx; + BossFd* bossFd = (BossFd*)pthis->dyna.actor.parent; f32 minus1 = -1.0f; - this->shakeTimer++; + pthis->shakeTimer++; if (!Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { s32 signal = bossFd->platformSignal; if (signal == VBSIMA_COLLAPSE) { - Math_SmoothStepToF(&this->dyna.actor.world.pos.y, -1000.0f, 1.0f, 1.5f, 0.0f); - this->dyna.actor.world.pos.z += 2.0f * Math_CosS(this->shakeTimer * 0x8000); - this->dyna.actor.shape.rot.x = (s16)Math_SinS(this->shakeTimer * 0x7000) * 0x37; - this->dyna.actor.shape.rot.z = (s16)Math_SinS(this->shakeTimer * 0x5000) * 0x37; - Audio_PlaySoundGeneral(NA_SE_EV_BLOCKSINK - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &D_801333E0, + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, -1000.0f, 1.0f, 1.5f, 0.0f); + pthis->dyna.actor.world.pos.z += 2.0f * Math_CosS(pthis->shakeTimer * 0x8000); + pthis->dyna.actor.shape.rot.x = (s16)Math_SinS(pthis->shakeTimer * 0x7000) * 0x37; + pthis->dyna.actor.shape.rot.z = (s16)Math_SinS(pthis->shakeTimer * 0x5000) * 0x37; + Audio_PlaySoundGeneral(NA_SE_EV_BLOCKSINK - SFX_FLAG, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else if (signal == VBSIMA_KILL) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } if (bossFd->platformSignal != VBSIMA_STAND) { s16 i2; @@ -131,9 +131,9 @@ void BgVbSima_Update(Actor* thisx, GlobalContext* globalCtx) { splashAcc.x = splashVel.x; splashAcc.z = splashVel.z; - splashPos.x = this->dyna.actor.world.pos.x + edgeX; + splashPos.x = pthis->dyna.actor.world.pos.x + edgeX; splashPos.y = -80.0f; - splashPos.z = this->dyna.actor.world.pos.z + edgeZ; + splashPos.z = pthis->dyna.actor.world.pos.z + edgeZ; func_8002836C(globalCtx, &splashPos, &splashVel, &splashAcc, &colorYellow, &colorRed, (s16)Rand_ZeroFloat(100.0f) + 500, 10, 20); diff --git a/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c b/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c deleted file mode 100644 index 4644dbc03..000000000 --- a/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c +++ /dev/null @@ -1,203 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_YDAN_HASI_Z_BG_YDAN_HASI_C -#include "actor_common.h" -/* - * File: z_bg_ydan_hasi.c - * Overlay: ovl_Bg_Ydan_Hasi - * Description: Deku Tree Puzzle elements. Water plane and floating block in B1, and 3 blocks on 2F - */ - -#include "z_bg_ydan_hasi.h" -#include "objects/object_ydan_objects/object_ydan_objects.h" -#include "def/code_80043480.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BgYdanHasi_Init(Actor* thisx, GlobalContext* globalCtx); -void BgYdanHasi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgYdanHasi_Update(Actor* thisx, GlobalContext* globalCtx); -void BgYdanHasi_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgYdanHasi_InitWater(BgYdanHasi* this, GlobalContext* globalCtx); -void BgYdanHasi_UpdateFloatingBlock(BgYdanHasi* this, GlobalContext* globalCtx); -void BgYdanHasi_SetupThreeBlocks(BgYdanHasi* this, GlobalContext* globalCtx); -void BgYdanHasi_MoveWater(BgYdanHasi* this, GlobalContext* globalCtx); -void BgYdanHasi_DecWaterTimer(BgYdanHasi* this, GlobalContext* globalCtx); -void BgYdanHasi_UpdateThreeBlocks(BgYdanHasi* this, GlobalContext* globalCtx); - -const ActorInit Bg_Ydan_Hasi_InitVars = { - ACTOR_BG_YDAN_HASI, - ACTORCAT_BG, - FLAGS, - OBJECT_YDAN_OBJECTS, - sizeof(BgYdanHasi), - (ActorFunc)BgYdanHasi_Init, - (ActorFunc)BgYdanHasi_Destroy, - (ActorFunc)BgYdanHasi_Update, - (ActorFunc)BgYdanHasi_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgYdanHasi_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgYdanHasi* this = (BgYdanHasi*)thisx; - CollisionHeader* colHeader = NULL; - WaterBox* waterBox; - - Actor_ProcessInitChain(thisx, sInitChain); - this->type = ((thisx->params >> 8) & 0x3F); - thisx->params = thisx->params & 0xFF; - waterBox = &globalCtx->colCtx.colHeader->waterBoxes[1]; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - if (thisx->params == HASI_WATER) { - // Water the moving platform floats on in B1. Never runs in Master Quest - waterBox->ySurface = thisx->world.pos.y = thisx->home.pos.y += -5.0f; - this->actionFunc = BgYdanHasi_InitWater; - } else { - if (thisx->params == HASI_WATER_BLOCK) { - // Moving platform on the water in B1 - CollisionHeader_GetVirtual(&gDTSlidingPlatformCol, &colHeader); - thisx->scale.z = 0.15f; - thisx->scale.x = 0.15f; - thisx->world.pos.y = (waterBox->ySurface + 20.0f); - this->actionFunc = BgYdanHasi_UpdateFloatingBlock; - } else { - // 3 platforms on 2F - CollisionHeader_GetVirtual(&gDTRisingPlatformsCol, &colHeader); - thisx->draw = NULL; - this->actionFunc = BgYdanHasi_SetupThreeBlocks; - Actor_SetFocus(&this->dyna.actor, 40.0f); - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - } - this->timer = 0; -} - -void BgYdanHasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgYdanHasi* this = (BgYdanHasi*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void BgYdanHasi_UpdateFloatingBlock(BgYdanHasi* this, GlobalContext* globalCtx) { - WaterBox* waterBox; - f32 framesAfterMath; - - framesAfterMath = sinf((globalCtx->gameplayFrames & 0xFF) * (M_PI / 128)) * 165.0f; - this->dyna.actor.world.pos.x = - ((Math_SinS(this->dyna.actor.world.rot.y) * framesAfterMath) + this->dyna.actor.home.pos.x); - this->dyna.actor.world.pos.z = - ((Math_CosS(this->dyna.actor.world.rot.y) * framesAfterMath) + this->dyna.actor.home.pos.z); - waterBox = &globalCtx->colCtx.colHeader->waterBoxes[1]; - this->dyna.actor.world.pos.y = waterBox->ySurface + 20.0f; - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->timer = 50; - } - this->dyna.actor.world.pos.y += 2.0f * sinf(this->timer * (M_PI / 25)); -} - -void BgYdanHasi_InitWater(BgYdanHasi* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->type)) { - this->timer = 600; - this->actionFunc = BgYdanHasi_MoveWater; - } -} - -void BgYdanHasi_MoveWater(BgYdanHasi* this, GlobalContext* globalCtx) { - WaterBox* waterBox; - - if (this->timer == 0) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f) != 0) { - Flags_UnsetSwitch(globalCtx, this->type); - this->actionFunc = BgYdanHasi_InitWater; - } - func_8002F948(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); - } else { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 47.0f, 0.5f)) { - this->actionFunc = BgYdanHasi_DecWaterTimer; - } - func_8002F948(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); - } - waterBox = &globalCtx->colCtx.colHeader->waterBoxes[1]; - waterBox->ySurface = this->dyna.actor.world.pos.y; -} - -void BgYdanHasi_DecWaterTimer(BgYdanHasi* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - func_8002F994(&this->dyna.actor, this->timer); - if (this->timer == 0) { - this->actionFunc = BgYdanHasi_MoveWater; - } -} - -void BgYdanHasi_SetupThreeBlocks(BgYdanHasi* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->type)) { - this->timer = 260; - this->dyna.actor.draw = BgYdanHasi_Draw; - this->actionFunc = BgYdanHasi_UpdateThreeBlocks; - OnePointCutscene_Init(globalCtx, 3040, 30, &this->dyna.actor, MAIN_CAM); - } -} - -void BgYdanHasi_UpdateThreeBlocks(BgYdanHasi* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 3.0f) != 0) { - Flags_UnsetSwitch(globalCtx, this->type); - this->dyna.actor.draw = NULL; - this->actionFunc = BgYdanHasi_SetupThreeBlocks; - } else { - func_8002F948(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); - } - } else if (!Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, 3.0f)) { - func_8002F948(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); - - } else { - func_8002F994(&this->dyna.actor, this->timer); - } -} - -void BgYdanHasi_Update(Actor* thisx, GlobalContext* globalCtx) { - BgYdanHasi* this = (BgYdanHasi*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgYdanHasi_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Gfx* dLists[] = { gDTSlidingPlatformDL, gDTWaterPlaneDL, gDTRisingPlatformsDL }; - BgYdanHasi* this = (BgYdanHasi*)thisx; - - if (this->dyna.actor.params == HASI_WATER_BLOCK || this->dyna.actor.params == HASI_THREE_BLOCKS) { - Gfx_DrawDListOpa(globalCtx, dLists[this->dyna.actor.params]); - } else { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_hasi.c", 577); - - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->gameplayFrames % 128, - globalCtx->gameplayFrames % 128, 0x20, 0x20, 1, globalCtx->gameplayFrames % 128, - globalCtx->gameplayFrames % 128, 0x20, 0x20)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_hasi.c", 592), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDTWaterPlaneDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_hasi.c", 597); - } -} diff --git a/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.cpp b/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.cpp new file mode 100644 index 000000000..9268ee60a --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.cpp @@ -0,0 +1,203 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_YDAN_HASI_Z_BG_YDAN_HASI_C +#include "actor_common.h" +/* + * File: z_bg_ydan_hasi.c + * Overlay: ovl_Bg_Ydan_Hasi + * Description: Deku Tree Puzzle elements. Water plane and floating block in B1, and 3 blocks on 2F + */ + +#include "z_bg_ydan_hasi.h" +#include "objects/object_ydan_objects/object_ydan_objects.h" +#include "def/code_80043480.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BgYdanHasi_Init(Actor* thisx, GlobalContext* globalCtx); +void BgYdanHasi_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgYdanHasi_Update(Actor* thisx, GlobalContext* globalCtx); +void BgYdanHasi_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgYdanHasi_InitWater(BgYdanHasi* pthis, GlobalContext* globalCtx); +void BgYdanHasi_UpdateFloatingBlock(BgYdanHasi* pthis, GlobalContext* globalCtx); +void BgYdanHasi_SetupThreeBlocks(BgYdanHasi* pthis, GlobalContext* globalCtx); +void BgYdanHasi_MoveWater(BgYdanHasi* pthis, GlobalContext* globalCtx); +void BgYdanHasi_DecWaterTimer(BgYdanHasi* pthis, GlobalContext* globalCtx); +void BgYdanHasi_UpdateThreeBlocks(BgYdanHasi* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Ydan_Hasi_InitVars = { + ACTOR_BG_YDAN_HASI, + ACTORCAT_BG, + FLAGS, + OBJECT_YDAN_OBJECTS, + sizeof(BgYdanHasi), + (ActorFunc)BgYdanHasi_Init, + (ActorFunc)BgYdanHasi_Destroy, + (ActorFunc)BgYdanHasi_Update, + (ActorFunc)BgYdanHasi_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgYdanHasi_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgYdanHasi* pthis = (BgYdanHasi*)thisx; + CollisionHeader* colHeader = NULL; + WaterBox* waterBox; + + Actor_ProcessInitChain(thisx, sInitChain); + pthis->type = ((thisx->params >> 8) & 0x3F); + thisx->params = thisx->params & 0xFF; + waterBox = &globalCtx->colCtx.colHeader->waterBoxes[1]; + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + if (thisx->params == HASI_WATER) { + // Water the moving platform floats on in B1. Never runs in Master Quest + waterBox->ySurface = thisx->world.pos.y = thisx->home.pos.y += -5.0f; + pthis->actionFunc = BgYdanHasi_InitWater; + } else { + if (thisx->params == HASI_WATER_BLOCK) { + // Moving platform on the water in B1 + CollisionHeader_GetVirtual(&gDTSlidingPlatformCol, &colHeader); + thisx->scale.z = 0.15f; + thisx->scale.x = 0.15f; + thisx->world.pos.y = (waterBox->ySurface + 20.0f); + pthis->actionFunc = BgYdanHasi_UpdateFloatingBlock; + } else { + // 3 platforms on 2F + CollisionHeader_GetVirtual(&gDTRisingPlatformsCol, &colHeader); + thisx->draw = NULL; + pthis->actionFunc = BgYdanHasi_SetupThreeBlocks; + Actor_SetFocus(&pthis->dyna.actor, 40.0f); + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + } + pthis->timer = 0; +} + +void BgYdanHasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgYdanHasi* pthis = (BgYdanHasi*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void BgYdanHasi_UpdateFloatingBlock(BgYdanHasi* pthis, GlobalContext* globalCtx) { + WaterBox* waterBox; + f32 framesAfterMath; + + framesAfterMath = sinf((globalCtx->gameplayFrames & 0xFF) * (M_PI / 128)) * 165.0f; + pthis->dyna.actor.world.pos.x = + ((Math_SinS(pthis->dyna.actor.world.rot.y) * framesAfterMath) + pthis->dyna.actor.home.pos.x); + pthis->dyna.actor.world.pos.z = + ((Math_CosS(pthis->dyna.actor.world.rot.y) * framesAfterMath) + pthis->dyna.actor.home.pos.z); + waterBox = &globalCtx->colCtx.colHeader->waterBoxes[1]; + pthis->dyna.actor.world.pos.y = waterBox->ySurface + 20.0f; + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + pthis->timer = 50; + } + pthis->dyna.actor.world.pos.y += 2.0f * sinf(pthis->timer * (M_PI / 25)); +} + +void BgYdanHasi_InitWater(BgYdanHasi* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->type)) { + pthis->timer = 600; + pthis->actionFunc = BgYdanHasi_MoveWater; + } +} + +void BgYdanHasi_MoveWater(BgYdanHasi* pthis, GlobalContext* globalCtx) { + WaterBox* waterBox; + + if (pthis->timer == 0) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 1.0f) != 0) { + Flags_UnsetSwitch(globalCtx, pthis->type); + pthis->actionFunc = BgYdanHasi_InitWater; + } + func_8002F948(&pthis->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + } else { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y - 47.0f, 0.5f)) { + pthis->actionFunc = BgYdanHasi_DecWaterTimer; + } + func_8002F948(&pthis->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + } + waterBox = &globalCtx->colCtx.colHeader->waterBoxes[1]; + waterBox->ySurface = pthis->dyna.actor.world.pos.y; +} + +void BgYdanHasi_DecWaterTimer(BgYdanHasi* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + func_8002F994(&pthis->dyna.actor, pthis->timer); + if (pthis->timer == 0) { + pthis->actionFunc = BgYdanHasi_MoveWater; + } +} + +void BgYdanHasi_SetupThreeBlocks(BgYdanHasi* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->type)) { + pthis->timer = 260; + pthis->dyna.actor.draw = BgYdanHasi_Draw; + pthis->actionFunc = BgYdanHasi_UpdateThreeBlocks; + OnePointCutscene_Init(globalCtx, 3040, 30, &pthis->dyna.actor, MAIN_CAM); + } +} + +void BgYdanHasi_UpdateThreeBlocks(BgYdanHasi* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 3.0f) != 0) { + Flags_UnsetSwitch(globalCtx, pthis->type); + pthis->dyna.actor.draw = NULL; + pthis->actionFunc = BgYdanHasi_SetupThreeBlocks; + } else { + func_8002F948(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + } + } else if (!Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 120.0f, 3.0f)) { + func_8002F948(&pthis->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + + } else { + func_8002F994(&pthis->dyna.actor, pthis->timer); + } +} + +void BgYdanHasi_Update(Actor* thisx, GlobalContext* globalCtx) { + BgYdanHasi* pthis = (BgYdanHasi*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgYdanHasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* dLists[] = { gDTSlidingPlatformDL, gDTWaterPlaneDL, gDTRisingPlatformsDL }; + BgYdanHasi* pthis = (BgYdanHasi*)thisx; + + if (pthis->dyna.actor.params == HASI_WATER_BLOCK || pthis->dyna.actor.params == HASI_THREE_BLOCKS) { + Gfx_DrawDListOpa(globalCtx, dLists[pthis->dyna.actor.params]); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_hasi.c", 577); + + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->gameplayFrames % 128, + globalCtx->gameplayFrames % 128, 0x20, 0x20, 1, globalCtx->gameplayFrames % 128, + globalCtx->gameplayFrames % 128, 0x20, 0x20)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_hasi.c", 592), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDTWaterPlaneDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_hasi.c", 597); + } +} diff --git a/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c b/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c deleted file mode 100644 index 2f4d62b8b..000000000 --- a/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c +++ /dev/null @@ -1,218 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_YDAN_MARUTA_Z_BG_YDAN_MARUTA_C -#include "actor_common.h" -/* - * File: z_bg_ydan_maruta.c - * Overlay: ovl_Bg_Ydan_Maruta - * Description: Rotating spike log and falling ladder in Deku Tree - */ - -#include "z_bg_ydan_maruta.h" -#include "objects/object_ydan_objects/object_ydan_objects.h" -#include "def/code_80043480.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS 0 - -void BgYdanMaruta_Init(Actor* thisx, GlobalContext* globalCtx); -void BgYdanMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgYdanMaruta_Update(Actor* thisx, GlobalContext* globalCtx); -void BgYdanMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808BEFF4(BgYdanMaruta* this, GlobalContext* globalCtx); -void BgYdanMaruta_DoNothing(BgYdanMaruta* this, GlobalContext* globalCtx); -void func_808BF078(BgYdanMaruta* this, GlobalContext* globalCtx); -void func_808BF108(BgYdanMaruta* this, GlobalContext* globalCtx); -void func_808BF1EC(BgYdanMaruta* this, GlobalContext* globalCtx); - -const ActorInit Bg_Ydan_Maruta_InitVars = { - ACTOR_BG_YDAN_MARUTA, - ACTORCAT_PROP, - FLAGS, - OBJECT_YDAN_OBJECTS, - sizeof(BgYdanMaruta), - (ActorFunc)BgYdanMaruta_Init, - (ActorFunc)BgYdanMaruta_Destroy, - (ActorFunc)BgYdanMaruta_Update, - (ActorFunc)BgYdanMaruta_Draw, -}; - -static ColliderTrisElementInit sTrisElementsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0x20000000, 0x00, 0x04 }, - { 0x00000004, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_WOOD, - BUMP_ON, - OCELEM_NONE, - }, - { { { 220.0f, -10.0f, 0.0f }, { 220.0f, 10.0f, 0.0f }, { -220.0f, 10.0f, 0.0f } } }, - }, - { - { - ELEMTYPE_UNK0, - { 0x20000000, 0x00, 0x04 }, - { 0x00000004, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_WOOD, - BUMP_ON, - OCELEM_NONE, - }, - { { { 16.0f, 0.0f, 0.0f }, { 16.0f, 135.0f, 0.0f }, { -16.0f, 135.0f, 0.0f } } }, - }, -}; - -static ColliderTrisInit sTrisInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_TRIS, - }, - 2, - sTrisElementsInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgYdanMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BgYdanMaruta* this = (BgYdanMaruta*)thisx; - Vec3f sp4C[3]; - s32 i; - f32 sinRotY; - f32 cosRotY; - CollisionHeader* colHeader = NULL; - ColliderTrisElementInit* triInit; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->elements); - - this->switchFlag = this->dyna.actor.params & 0xFFFF; - thisx->params = (thisx->params >> 8) & 0xFF; // thisx is required to match here - - if (this->dyna.actor.params == 0) { - triInit = &sTrisElementsInit[0]; - this->actionFunc = func_808BEFF4; - } else { - triInit = &sTrisElementsInit[1]; - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gDTFallingLadderCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - thisx->home.pos.y += -280.0f; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - thisx->world.pos.y = thisx->home.pos.y; - this->actionFunc = BgYdanMaruta_DoNothing; - } else { - this->actionFunc = func_808BF078; - } - } - - sinRotY = Math_SinS(this->dyna.actor.shape.rot.y); - cosRotY = Math_CosS(this->dyna.actor.shape.rot.y); - - for (i = 0; i < 3; i++) { - sp4C[i].x = (triInit->dim.vtx[i].x * cosRotY) + this->dyna.actor.world.pos.x; - sp4C[i].y = triInit->dim.vtx[i].y + this->dyna.actor.world.pos.y; - sp4C[i].z = this->dyna.actor.world.pos.z - (triInit->dim.vtx[i].x * sinRotY); - } - - Collider_SetTrisVertices(&this->collider, 0, &sp4C[0], &sp4C[1], &sp4C[2]); - - sp4C[1].x = (triInit->dim.vtx[2].x * cosRotY) + this->dyna.actor.world.pos.x; - sp4C[1].y = triInit->dim.vtx[0].y + this->dyna.actor.world.pos.y; - sp4C[1].z = this->dyna.actor.world.pos.z - (triInit->dim.vtx[2].x * sinRotY); - - Collider_SetTrisVertices(&this->collider, 1, &sp4C[0], &sp4C[2], &sp4C[1]); -} - -void BgYdanMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgYdanMaruta* this = (BgYdanMaruta*)thisx; - - Collider_DestroyTris(globalCtx, &this->collider); - if (this->dyna.actor.params == 1) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } -} - -void func_808BEFF4(BgYdanMaruta* this, GlobalContext* globalCtx) { - if (this->collider.base.atFlags & AT_HIT) { - func_8002F71C(globalCtx, &this->dyna.actor, 7.0f, this->dyna.actor.shape.rot.y, 6.0f); - } - this->dyna.actor.shape.rot.x += 0x360; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_8002F974(&this->dyna.actor, NA_SE_EV_TOGE_STICK_ROLLING - SFX_FLAG); -} - -void func_808BF078(BgYdanMaruta* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->unk_16A = 20; - Flags_SetSwitch(globalCtx, this->switchFlag); - func_80078884(NA_SE_SY_CORRECT_CHIME); - this->actionFunc = func_808BF108; - OnePointCutscene_Init(globalCtx, 3010, 50, &this->dyna.actor, MAIN_CAM); - } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void func_808BF108(BgYdanMaruta* this, GlobalContext* globalCtx) { - s16 temp; - - if (this->unk_16A != 0) { - this->unk_16A--; - } - if (this->unk_16A == 0) { - this->actionFunc = func_808BF1EC; - } - - if (1) {} - - temp = (this->unk_16A % 4) - 2; - if (temp == -2) { - temp = 0; - } else { - temp *= 2; - } - - this->dyna.actor.world.pos.x = (Math_CosS(this->dyna.actor.shape.rot.y) * temp) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = (Math_SinS(this->dyna.actor.shape.rot.y) * temp) + this->dyna.actor.home.pos.z; - - func_8002F974(&this->dyna.actor, NA_SE_EV_TRAP_OBJ_SLIDE - SFX_FLAG); -} - -void func_808BF1EC(BgYdanMaruta* this, GlobalContext* globalCtx) { - this->dyna.actor.velocity.y += 1.0f; - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_LADDER_DOUND); - this->actionFunc = BgYdanMaruta_DoNothing; - } -} - -void BgYdanMaruta_DoNothing(BgYdanMaruta* this, GlobalContext* globalCtx) { -} - -void BgYdanMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { - BgYdanMaruta* this = (BgYdanMaruta*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgYdanMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgYdanMaruta* this = (BgYdanMaruta*)thisx; - - if (this->dyna.actor.params == 0) { - Gfx_DrawDListOpa(globalCtx, gDTRollingSpikeTrapDL); - } else { - Gfx_DrawDListOpa(globalCtx, gDTFallingLadderDL); - } -} diff --git a/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.cpp b/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.cpp new file mode 100644 index 000000000..c3f01c1fb --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.cpp @@ -0,0 +1,218 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_YDAN_MARUTA_Z_BG_YDAN_MARUTA_C +#include "actor_common.h" +/* + * File: z_bg_ydan_maruta.c + * Overlay: ovl_Bg_Ydan_Maruta + * Description: Rotating spike log and falling ladder in Deku Tree + */ + +#include "z_bg_ydan_maruta.h" +#include "objects/object_ydan_objects/object_ydan_objects.h" +#include "def/code_80043480.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS 0 + +void BgYdanMaruta_Init(Actor* thisx, GlobalContext* globalCtx); +void BgYdanMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgYdanMaruta_Update(Actor* thisx, GlobalContext* globalCtx); +void BgYdanMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808BEFF4(BgYdanMaruta* pthis, GlobalContext* globalCtx); +void BgYdanMaruta_DoNothing(BgYdanMaruta* pthis, GlobalContext* globalCtx); +void func_808BF078(BgYdanMaruta* pthis, GlobalContext* globalCtx); +void func_808BF108(BgYdanMaruta* pthis, GlobalContext* globalCtx); +void func_808BF1EC(BgYdanMaruta* pthis, GlobalContext* globalCtx); + +ActorInit Bg_Ydan_Maruta_InitVars = { + ACTOR_BG_YDAN_MARUTA, + ACTORCAT_PROP, + FLAGS, + OBJECT_YDAN_OBJECTS, + sizeof(BgYdanMaruta), + (ActorFunc)BgYdanMaruta_Init, + (ActorFunc)BgYdanMaruta_Destroy, + (ActorFunc)BgYdanMaruta_Update, + (ActorFunc)BgYdanMaruta_Draw, +}; + +static ColliderTrisElementInit sTrisElementsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x00000004, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_WOOD, + BUMP_ON, + OCELEM_NONE, + }, + { { { 220.0f, -10.0f, 0.0f }, { 220.0f, 10.0f, 0.0f }, { -220.0f, 10.0f, 0.0f } } }, + }, + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x00000004, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_WOOD, + BUMP_ON, + OCELEM_NONE, + }, + { { { 16.0f, 0.0f, 0.0f }, { 16.0f, 135.0f, 0.0f }, { -16.0f, 135.0f, 0.0f } } }, + }, +}; + +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgYdanMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgYdanMaruta* pthis = (BgYdanMaruta*)thisx; + Vec3f sp4C[3]; + s32 i; + f32 sinRotY; + f32 cosRotY; + CollisionHeader* colHeader = NULL; + ColliderTrisElementInit* triInit; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + Collider_InitTris(globalCtx, &pthis->collider); + Collider_SetTris(globalCtx, &pthis->collider, &pthis->dyna.actor, &sTrisInit, pthis->elements); + + pthis->switchFlag = pthis->dyna.actor.params & 0xFFFF; + thisx->params = (thisx->params >> 8) & 0xFF; // thisx is required to match here + + if (pthis->dyna.actor.params == 0) { + triInit = &sTrisElementsInit[0]; + pthis->actionFunc = func_808BEFF4; + } else { + triInit = &sTrisElementsInit[1]; + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gDTFallingLadderCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + thisx->home.pos.y += -280.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + thisx->world.pos.y = thisx->home.pos.y; + pthis->actionFunc = BgYdanMaruta_DoNothing; + } else { + pthis->actionFunc = func_808BF078; + } + } + + sinRotY = Math_SinS(pthis->dyna.actor.shape.rot.y); + cosRotY = Math_CosS(pthis->dyna.actor.shape.rot.y); + + for (i = 0; i < 3; i++) { + sp4C[i].x = (triInit->dim.vtx[i].x * cosRotY) + pthis->dyna.actor.world.pos.x; + sp4C[i].y = triInit->dim.vtx[i].y + pthis->dyna.actor.world.pos.y; + sp4C[i].z = pthis->dyna.actor.world.pos.z - (triInit->dim.vtx[i].x * sinRotY); + } + + Collider_SetTrisVertices(&pthis->collider, 0, &sp4C[0], &sp4C[1], &sp4C[2]); + + sp4C[1].x = (triInit->dim.vtx[2].x * cosRotY) + pthis->dyna.actor.world.pos.x; + sp4C[1].y = triInit->dim.vtx[0].y + pthis->dyna.actor.world.pos.y; + sp4C[1].z = pthis->dyna.actor.world.pos.z - (triInit->dim.vtx[2].x * sinRotY); + + Collider_SetTrisVertices(&pthis->collider, 1, &sp4C[0], &sp4C[2], &sp4C[1]); +} + +void BgYdanMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgYdanMaruta* pthis = (BgYdanMaruta*)thisx; + + Collider_DestroyTris(globalCtx, &pthis->collider); + if (pthis->dyna.actor.params == 1) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } +} + +void func_808BEFF4(BgYdanMaruta* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.atFlags & AT_HIT) { + func_8002F71C(globalCtx, &pthis->dyna.actor, 7.0f, pthis->dyna.actor.shape.rot.y, 6.0f); + } + pthis->dyna.actor.shape.rot.x += 0x360; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + func_8002F974(&pthis->dyna.actor, NA_SE_EV_TOGE_STICK_ROLLING - SFX_FLAG); +} + +void func_808BF078(BgYdanMaruta* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->unk_16A = 20; + Flags_SetSwitch(globalCtx, pthis->switchFlag); + func_80078884(NA_SE_SY_CORRECT_CHIME); + pthis->actionFunc = func_808BF108; + OnePointCutscene_Init(globalCtx, 3010, 50, &pthis->dyna.actor, MAIN_CAM); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void func_808BF108(BgYdanMaruta* pthis, GlobalContext* globalCtx) { + s16 temp; + + if (pthis->unk_16A != 0) { + pthis->unk_16A--; + } + if (pthis->unk_16A == 0) { + pthis->actionFunc = func_808BF1EC; + } + + if (1) {} + + temp = (pthis->unk_16A % 4) - 2; + if (temp == -2) { + temp = 0; + } else { + temp *= 2; + } + + pthis->dyna.actor.world.pos.x = (Math_CosS(pthis->dyna.actor.shape.rot.y) * temp) + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = (Math_SinS(pthis->dyna.actor.shape.rot.y) * temp) + pthis->dyna.actor.home.pos.z; + + func_8002F974(&pthis->dyna.actor, NA_SE_EV_TRAP_OBJ_SLIDE - SFX_FLAG); +} + +void func_808BF1EC(BgYdanMaruta* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.velocity.y += 1.0f; + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.velocity.y)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_LADDER_DOUND); + pthis->actionFunc = BgYdanMaruta_DoNothing; + } +} + +void BgYdanMaruta_DoNothing(BgYdanMaruta* pthis, GlobalContext* globalCtx) { +} + +void BgYdanMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { + BgYdanMaruta* pthis = (BgYdanMaruta*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgYdanMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgYdanMaruta* pthis = (BgYdanMaruta*)thisx; + + if (pthis->dyna.actor.params == 0) { + Gfx_DrawDListOpa(globalCtx, gDTRollingSpikeTrapDL); + } else { + Gfx_DrawDListOpa(globalCtx, gDTFallingLadderDL); + } +} diff --git a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c deleted file mode 100644 index 47d894882..000000000 --- a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c +++ /dev/null @@ -1,472 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_YDAN_SP_Z_BG_YDAN_SP_C -#include "actor_common.h" -/* - * File: z_bg_ydan_sp.c - * Overlay: ovl_Bg_Ydan_Sp - * Description: Webs - */ - -#include "z_bg_ydan_sp.h" -#include "objects/object_ydan_objects/object_ydan_objects.h" -#include "def/code_80043480.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void BgYdanSp_Init(Actor* thisx, GlobalContext* globalCtx); -void BgYdanSp_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgYdanSp_Update(Actor* thisx, GlobalContext* globalCtx); -void BgYdanSp_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BgYdanSp_BurnFloorWeb(BgYdanSp* this, GlobalContext* globalCtx); -void BgYdanSp_FloorWebIdle(BgYdanSp* this, GlobalContext* globalCtx); -void BgYdanSp_BurnWallWeb(BgYdanSp* this, GlobalContext* globalCtx); -void BgYdanSp_WallWebIdle(BgYdanSp* this, GlobalContext* globalCtx); - -typedef enum { - /* 0 */ WEB_FLOOR, - /* 1 */ WEB_WALL -} BgYdanSpType; - -const ActorInit Bg_Ydan_Sp_InitVars = { - ACTOR_BG_YDAN_SP, - ACTORCAT_BG, - FLAGS, - OBJECT_YDAN_OBJECTS, - sizeof(BgYdanSp), - (ActorFunc)BgYdanSp_Init, - (ActorFunc)BgYdanSp_Destroy, - (ActorFunc)BgYdanSp_Update, - (ActorFunc)BgYdanSp_Draw, -}; - -static ColliderTrisElementInit sTrisItemsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0x00020800, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, -75.0f } } }, - }, - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0x00020800, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 140.0f, 288.8f, 0.0f }, { -140.0f, 288.0f, 0.0f }, { -140.0f, 0.0f, 0.0f } } }, - }, -}; - -static ColliderTrisInit sTrisInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_TRIS, - }, - 2, - sTrisItemsInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void BgYdanSp_Init(Actor* thisx, GlobalContext* globalCtx) { - BgYdanSp* this = (BgYdanSp*)thisx; - ColliderTrisElementInit* ti0 = &sTrisItemsInit[0]; - Vec3f tri[3]; - s32 i; - CollisionHeader* colHeader = NULL; - ColliderTrisElementInit* ti1 = &sTrisItemsInit[1]; - f32 cossY; - f32 sinsY; - f32 cossX; - f32 nSinsX; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->isDestroyedSwitchFlag = thisx->params & 0x3F; - this->burnSwitchFlag = (thisx->params >> 6) & 0x3F; - this->dyna.actor.params = (thisx->params >> 0xC) & 0xF; - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - Collider_InitTris(globalCtx, &this->trisCollider); - Collider_SetTris(globalCtx, &this->trisCollider, &this->dyna.actor, &sTrisInit, this->trisColliderItems); - if (this->dyna.actor.params == WEB_FLOOR) { - CollisionHeader_GetVirtual(&gDTWebFloorCol, &colHeader); - this->actionFunc = BgYdanSp_FloorWebIdle; - - for (i = 0; i < 3; i++) { - tri[i].x = ti0->dim.vtx[i].x + this->dyna.actor.world.pos.x; - tri[i].y = ti0->dim.vtx[i].y + this->dyna.actor.world.pos.y; - tri[i].z = ti0->dim.vtx[i].z + this->dyna.actor.world.pos.z; - } - - Collider_SetTrisVertices(&this->trisCollider, 0, &tri[0], &tri[1], &tri[2]); - tri[1].x = tri[0].x; - tri[1].z = tri[2].z; - Collider_SetTrisVertices(&this->trisCollider, 1, &tri[0], &tri[2], &tri[1]); - this->unk16C = 0.0f; - } else { - CollisionHeader_GetVirtual(&gDTWebWallCol, &colHeader); - this->actionFunc = BgYdanSp_WallWebIdle; - Actor_SetFocus(&this->dyna.actor, 30.0f); - sinsY = Math_SinS(this->dyna.actor.shape.rot.y); - cossY = Math_CosS(this->dyna.actor.shape.rot.y); - nSinsX = -Math_SinS(this->dyna.actor.shape.rot.x); - cossX = Math_CosS(this->dyna.actor.shape.rot.x); - - for (i = 0; i < 3; i++) { - tri[i].x = - this->dyna.actor.world.pos.x + (cossY * ti1->dim.vtx[i].x) - (sinsY * ti1->dim.vtx[i].y * nSinsX); - tri[i].y = this->dyna.actor.world.pos.y + (ti1->dim.vtx[i].y * cossX); - tri[i].z = - this->dyna.actor.world.pos.z - (sinsY * ti1->dim.vtx[i].x) + (ti1->dim.vtx[i].y * cossY * nSinsX); - } - - Collider_SetTrisVertices(&this->trisCollider, 0, &tri[0], &tri[1], &tri[2]); - - tri[1].x = this->dyna.actor.world.pos.x + (cossY * ti1->dim.vtx[0].x) - (ti1->dim.vtx[2].y * sinsY * nSinsX); - tri[1].y = this->dyna.actor.world.pos.y + (ti1->dim.vtx[2].y * cossX); - tri[1].z = this->dyna.actor.world.pos.z - (sinsY * ti1->dim.vtx[0].x) + (ti1->dim.vtx[2].y * cossY * nSinsX); - Collider_SetTrisVertices(&this->trisCollider, 1, &tri[0], &tri[2], &tri[1]); - } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->timer = 0; - if (Flags_GetSwitch(globalCtx, this->isDestroyedSwitchFlag)) { - Actor_Kill(&this->dyna.actor); - } -} - -void BgYdanSp_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgYdanSp* this = (BgYdanSp*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->trisCollider); -} - -void BgYdanSp_UpdateFloorWebCollision(BgYdanSp* this) { - s16 newY; - CollisionHeader* colHeader; - - colHeader = SEGMENTED_TO_VIRTUAL(&gDTWebFloorCol); - colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); - newY = (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y) * 10; - colHeader->vtxList[14].y = newY; - colHeader->vtxList[12].y = newY; - colHeader->vtxList[10].y = newY; - colHeader->vtxList[9].y = newY; - colHeader->vtxList[6].y = newY; - colHeader->vtxList[5].y = newY; - colHeader->vtxList[1].y = newY; - colHeader->vtxList[0].y = newY; -} - -void BgYdanSp_BurnWeb(BgYdanSp* this, GlobalContext* globalCtx) { - this->timer = 30; - this = this; - func_80078884(NA_SE_SY_CORRECT_CHIME); - Flags_SetSwitch(globalCtx, this->isDestroyedSwitchFlag); - if (this->dyna.actor.params == WEB_FLOOR) { - this->actionFunc = BgYdanSp_BurnFloorWeb; - } else { - this->actionFunc = BgYdanSp_BurnWallWeb; - } -} - -void BgYdanSp_BurnFloorWeb(BgYdanSp* this, GlobalContext* globalCtx) { - static Vec3f accel = { 0 }; - Vec3f velocity; - Vec3f pos2; - f32 distXZ; - f32 sins; - f32 coss; - s16 rot; - s16 rot2; - s32 i; - - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - Actor_Kill(&this->dyna.actor); - return; - } - if ((this->timer % 3) == 0) { - rot2 = Rand_ZeroOne() * 0x2AAA; - velocity.y = 0.0f; - pos2.y = this->dyna.actor.world.pos.y; - - for (i = 0; i < 6; i++) { - rot = Rand_CenteredFloat(0x2800) + rot2; - sins = Math_SinS(rot); - coss = Math_CosS(rot); - pos2.x = this->dyna.actor.world.pos.x + (120.0f * sins); - pos2.z = this->dyna.actor.world.pos.z + (120.0f * coss); - distXZ = Math_Vec3f_DistXZ(&this->dyna.actor.home.pos, &pos2) * (1.0f / 120.0f); - if (distXZ < 0.7f) { - sins = Math_SinS(rot + 0x8000); - coss = Math_CosS(rot + 0x8000); - pos2.x = this->dyna.actor.world.pos.x + (120.0f * sins); - pos2.z = this->dyna.actor.world.pos.z + (120.0f * coss); - distXZ = Math_Vec3f_DistXZ(&this->dyna.actor.home.pos, &pos2) * (1.0f / 120.0f); - } - velocity.x = (7.0f * sins) * distXZ; - velocity.y = 0.0f; - velocity.z = (7.0f * coss) * distXZ; - EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &velocity, &accel, 60, 6, 255, 255, 150, 170, - 255, 0, 0, 1, 0xE, 1); - rot2 += 0x2AAA; - } - } -} - -void BgYdanSp_FloorWebBroken(BgYdanSp* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - Actor_Kill(&this->dyna.actor); - } -} - -void BgYdanSp_FloorWebBreaking(BgYdanSp* this, GlobalContext* globalCtx) { - static Color_RGBA8 primColor = { 250, 250, 250, 255 }; - static Color_RGBA8 envColor = { 180, 180, 180, 255 }; - static Vec3f zeroVec = { 0 }; - s32 i; - Vec3f pos; - s16 rot; - - if (this->timer != 0) { - this->timer--; - } - - this->dyna.actor.world.pos.y = (sinf((f32)this->timer * (M_PI / 20)) * this->unk16C) + this->dyna.actor.home.pos.y; - if (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y > 190.0f) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->timer = 40; - func_80078884(NA_SE_SY_CORRECT_CHIME); - Flags_SetSwitch(globalCtx, this->isDestroyedSwitchFlag); - this->actionFunc = BgYdanSp_FloorWebBroken; - pos.y = this->dyna.actor.world.pos.y - 60.0f; - rot = 0; - for (i = 0; i < 6; i++) { - pos.x = Math_SinS(rot) * 60.0f + this->dyna.actor.world.pos.x; - pos.z = Math_CosS(rot) * 60.0f + this->dyna.actor.world.pos.z; - func_8002829C(globalCtx, &pos, &zeroVec, &zeroVec, &primColor, &envColor, 1000, 10); - - rot += 0x2AAA; - } - } - BgYdanSp_UpdateFloorWebCollision(this); -} - -void BgYdanSp_FloorWebIdle(BgYdanSp* this, GlobalContext* globalCtx) { - Player* player; - Vec3f webPos; - f32 sqrtFallDistance; - f32 unk; - - player = GET_PLAYER(globalCtx); - webPos.x = this->dyna.actor.world.pos.x; - webPos.y = this->dyna.actor.world.pos.y - 50.0f; - webPos.z = this->dyna.actor.world.pos.z; - if (Player_IsBurningStickInRange(globalCtx, &webPos, 70.0f, 50.0f) != 0) { - this->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; - this->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; - BgYdanSp_BurnWeb(this, globalCtx); - return; - } - if ((this->trisCollider.base.acFlags & 2) != 0) { - BgYdanSp_BurnWeb(this, globalCtx); - return; - } - if (func_8004356C(&this->dyna)) { - sqrtFallDistance = sqrtf(CLAMP_MIN(player->fallDistance, 0.0f)); - if (player->fallDistance > 750.0f) { - if (this->dyna.actor.xzDistToPlayer < 80.0f) { - this->unk16C = 200.0f; - this->dyna.actor.room = -1; - this->dyna.actor.flags |= ACTOR_FLAG_4; - this->timer = 40; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WEB_BROKEN); - this->actionFunc = BgYdanSp_FloorWebBreaking; - return; - } - } - unk = sqrtFallDistance + sqrtFallDistance; - if (this->unk16C < unk) { - if (unk > 2.0f) { - this->unk16C = unk; - this->timer = 14; - } - } - if (player->actor.speedXZ != 0.0f) { - if (this->unk16C < 0.1f) { - this->timer = 14; - } - if (this->unk16C < 2.0f) { - this->unk16C = 2.0f; - } else { - this->unk16C = this->unk16C; - } - } - } - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->timer = 14; - } - this->dyna.actor.world.pos.y = sinf((f32)this->timer * (M_PI / 7)) * this->unk16C + this->dyna.actor.home.pos.y; - Math_ApproachZeroF(&this->unk16C, 1.0f, 0.8f); - if (this->timer == 13) { - if (this->unk16C > 3.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); - } else { - Audio_StopSfxById(NA_SE_EV_WEB_VIBRATION); - } - } - BgYdanSp_UpdateFloorWebCollision(this); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->trisCollider.base); -} - -void BgYdanSp_BurnWallWeb(BgYdanSp* this, GlobalContext* globalCtx) { - static Vec3f accel = { 0 }; - Vec3f velocity; - Vec3f spC8; - f32 distXYZ; - f32 sins; - f32 coss; - f32 coss2; - s16 rot; - s16 rot2; - s32 i; - - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - Actor_Kill(&this->dyna.actor); - return; - } - if ((this->timer % 3) == 0) { - rot2 = Rand_ZeroOne() * 0x2AAA; - - for (i = 0; i < 6; i++) { - rot = Rand_CenteredFloat(0x2800) + rot2; - sins = Math_SinS(rot); - coss = Math_CosS(rot); - coss2 = Math_CosS(this->dyna.actor.shape.rot.y) * sins; - sins *= Math_SinS(this->dyna.actor.shape.rot.y); - - spC8.x = this->dyna.actor.world.pos.x + (140.0f * coss2); - spC8.y = this->dyna.actor.world.pos.y + (140.0f * (1.0f + coss)); - spC8.z = this->dyna.actor.world.pos.z - (140.0f * sins); - distXYZ = Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &spC8) * (1.0f / 140.0f); - if (distXYZ < 0.65f) { - sins = Math_SinS(rot + 0x8000); - coss = Math_CosS(rot + 0x8000); - coss2 = Math_CosS(this->dyna.actor.shape.rot.y) * sins; - sins *= Math_SinS(this->dyna.actor.shape.rot.y); - spC8.x = this->dyna.actor.world.pos.x + (140.0f * coss2); - spC8.y = this->dyna.actor.world.pos.y + (140.0f * (1.0f + coss)); - spC8.z = this->dyna.actor.world.pos.z - (140.0f * sins); - distXYZ = Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &spC8) * (1.0f / 140.0f); - } - velocity.x = 6.5f * coss2 * distXYZ; - velocity.y = 6.5f * coss * distXYZ; - velocity.z = -6.5f * sins * distXYZ; - EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &velocity, &accel, 80, 6, 255, 255, 150, 170, - 255, 0, 0, 1, 0xE, 1); - rot2 += 0x2AAA; - } - } -} - -void BgYdanSp_WallWebIdle(BgYdanSp* this, GlobalContext* globalCtx) { - Player* player; - Vec3f sp30; - - player = GET_PLAYER(globalCtx); - if (Flags_GetSwitch(globalCtx, this->burnSwitchFlag) || (this->trisCollider.base.acFlags & 2)) { - this->dyna.actor.home.pos.y = this->dyna.actor.world.pos.y + 80.0f; - BgYdanSp_BurnWeb(this, globalCtx); - } else if (player->heldItemActionParam == PLAYER_AP_STICK && player->unk_860 != 0) { - func_8002DBD0(&this->dyna.actor, &sp30, &player->swordInfo[0].tip); - if (fabsf(sp30.x) < 100.0f && sp30.z < 1.0f && sp30.y < 200.0f) { - OnePointCutscene_Init(globalCtx, 3020, 40, &this->dyna.actor, MAIN_CAM); - Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); - BgYdanSp_BurnWeb(this, globalCtx); - } - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->trisCollider.base); -} - -void BgYdanSp_Update(Actor* thisx, GlobalContext* globalCtx) { - BgYdanSp* this = (BgYdanSp*)thisx; - - this->actionFunc(this, globalCtx); -} - -void BgYdanSp_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgYdanSp* this = (BgYdanSp*)thisx; - s32 i; - MtxF mtxF; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 781); - func_80093D84(globalCtx->state.gfxCtx); - if (thisx->params == WEB_WALL) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 787), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDTWebWallDL); - } else if (this->actionFunc == BgYdanSp_FloorWebBroken) { - Matrix_Get(&mtxF); - if (this->timer == 40) { - Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 808), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDTWebFloorDL); - } - for (i = 0; i < 8; i++) { - Matrix_Put(&mtxF); - Matrix_RotateZYX(-0x5A0, i * 0x2000, 0, MTXMODE_APPLY); - Matrix_Translate(0.0f, 700.0f, -900.0f, MTXMODE_APPLY); - Matrix_Scale(3.5f, 5.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 830), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDTUnknownWebDL); - } - } else { - Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 849), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDTWebFloorDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 856); -} diff --git a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.cpp b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.cpp new file mode 100644 index 000000000..1b4ced10f --- /dev/null +++ b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.cpp @@ -0,0 +1,472 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BG_YDAN_SP_Z_BG_YDAN_SP_C +#include "actor_common.h" +/* + * File: z_bg_ydan_sp.c + * Overlay: ovl_Bg_Ydan_Sp + * Description: Webs + */ + +#include "z_bg_ydan_sp.h" +#include "objects/object_ydan_objects/object_ydan_objects.h" +#include "def/code_80043480.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void BgYdanSp_Init(Actor* thisx, GlobalContext* globalCtx); +void BgYdanSp_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BgYdanSp_Update(Actor* thisx, GlobalContext* globalCtx); +void BgYdanSp_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BgYdanSp_BurnFloorWeb(BgYdanSp* pthis, GlobalContext* globalCtx); +void BgYdanSp_FloorWebIdle(BgYdanSp* pthis, GlobalContext* globalCtx); +void BgYdanSp_BurnWallWeb(BgYdanSp* pthis, GlobalContext* globalCtx); +void BgYdanSp_WallWebIdle(BgYdanSp* pthis, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ WEB_FLOOR, + /* 1 */ WEB_WALL +} BgYdanSpType; + +ActorInit Bg_Ydan_Sp_InitVars = { + ACTOR_BG_YDAN_SP, + ACTORCAT_BG, + FLAGS, + OBJECT_YDAN_OBJECTS, + sizeof(BgYdanSp), + (ActorFunc)BgYdanSp_Init, + (ActorFunc)BgYdanSp_Destroy, + (ActorFunc)BgYdanSp_Update, + (ActorFunc)BgYdanSp_Draw, +}; + +static ColliderTrisElementInit sTrisItemsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0x00020800, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, -75.0f } } }, + }, + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0x00020800, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 140.0f, 288.8f, 0.0f }, { -140.0f, 288.0f, 0.0f }, { -140.0f, 0.0f, 0.0f } } }, + }, +}; + +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisItemsInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void BgYdanSp_Init(Actor* thisx, GlobalContext* globalCtx) { + BgYdanSp* pthis = (BgYdanSp*)thisx; + ColliderTrisElementInit* ti0 = &sTrisItemsInit[0]; + Vec3f tri[3]; + s32 i; + CollisionHeader* colHeader = NULL; + ColliderTrisElementInit* ti1 = &sTrisItemsInit[1]; + f32 cossY; + f32 sinsY; + f32 cossX; + f32 nSinsX; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->isDestroyedSwitchFlag = thisx->params & 0x3F; + pthis->burnSwitchFlag = (thisx->params >> 6) & 0x3F; + pthis->dyna.actor.params = (thisx->params >> 0xC) & 0xF; + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + Collider_InitTris(globalCtx, &pthis->trisCollider); + Collider_SetTris(globalCtx, &pthis->trisCollider, &pthis->dyna.actor, &sTrisInit, pthis->trisColliderItems); + if (pthis->dyna.actor.params == WEB_FLOOR) { + CollisionHeader_GetVirtual(&gDTWebFloorCol, &colHeader); + pthis->actionFunc = BgYdanSp_FloorWebIdle; + + for (i = 0; i < 3; i++) { + tri[i].x = ti0->dim.vtx[i].x + pthis->dyna.actor.world.pos.x; + tri[i].y = ti0->dim.vtx[i].y + pthis->dyna.actor.world.pos.y; + tri[i].z = ti0->dim.vtx[i].z + pthis->dyna.actor.world.pos.z; + } + + Collider_SetTrisVertices(&pthis->trisCollider, 0, &tri[0], &tri[1], &tri[2]); + tri[1].x = tri[0].x; + tri[1].z = tri[2].z; + Collider_SetTrisVertices(&pthis->trisCollider, 1, &tri[0], &tri[2], &tri[1]); + pthis->unk16C = 0.0f; + } else { + CollisionHeader_GetVirtual(&gDTWebWallCol, &colHeader); + pthis->actionFunc = BgYdanSp_WallWebIdle; + Actor_SetFocus(&pthis->dyna.actor, 30.0f); + sinsY = Math_SinS(pthis->dyna.actor.shape.rot.y); + cossY = Math_CosS(pthis->dyna.actor.shape.rot.y); + nSinsX = -Math_SinS(pthis->dyna.actor.shape.rot.x); + cossX = Math_CosS(pthis->dyna.actor.shape.rot.x); + + for (i = 0; i < 3; i++) { + tri[i].x = + pthis->dyna.actor.world.pos.x + (cossY * ti1->dim.vtx[i].x) - (sinsY * ti1->dim.vtx[i].y * nSinsX); + tri[i].y = pthis->dyna.actor.world.pos.y + (ti1->dim.vtx[i].y * cossX); + tri[i].z = + pthis->dyna.actor.world.pos.z - (sinsY * ti1->dim.vtx[i].x) + (ti1->dim.vtx[i].y * cossY * nSinsX); + } + + Collider_SetTrisVertices(&pthis->trisCollider, 0, &tri[0], &tri[1], &tri[2]); + + tri[1].x = pthis->dyna.actor.world.pos.x + (cossY * ti1->dim.vtx[0].x) - (ti1->dim.vtx[2].y * sinsY * nSinsX); + tri[1].y = pthis->dyna.actor.world.pos.y + (ti1->dim.vtx[2].y * cossX); + tri[1].z = pthis->dyna.actor.world.pos.z - (sinsY * ti1->dim.vtx[0].x) + (ti1->dim.vtx[2].y * cossY * nSinsX); + Collider_SetTrisVertices(&pthis->trisCollider, 1, &tri[0], &tri[2], &tri[1]); + } + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->timer = 0; + if (Flags_GetSwitch(globalCtx, pthis->isDestroyedSwitchFlag)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgYdanSp_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgYdanSp* pthis = (BgYdanSp*)thisx; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyTris(globalCtx, &pthis->trisCollider); +} + +void BgYdanSp_UpdateFloorWebCollision(BgYdanSp* pthis) { + s16 newY; + CollisionHeader* colHeader; + + colHeader = SEGMENTED_TO_VIRTUAL(&gDTWebFloorCol); + colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); + newY = (pthis->dyna.actor.home.pos.y - pthis->dyna.actor.world.pos.y) * 10; + colHeader->vtxList[14].y = newY; + colHeader->vtxList[12].y = newY; + colHeader->vtxList[10].y = newY; + colHeader->vtxList[9].y = newY; + colHeader->vtxList[6].y = newY; + colHeader->vtxList[5].y = newY; + colHeader->vtxList[1].y = newY; + colHeader->vtxList[0].y = newY; +} + +void BgYdanSp_BurnWeb(BgYdanSp* pthis, GlobalContext* globalCtx) { + pthis->timer = 30; + pthis = pthis; + func_80078884(NA_SE_SY_CORRECT_CHIME); + Flags_SetSwitch(globalCtx, pthis->isDestroyedSwitchFlag); + if (pthis->dyna.actor.params == WEB_FLOOR) { + pthis->actionFunc = BgYdanSp_BurnFloorWeb; + } else { + pthis->actionFunc = BgYdanSp_BurnWallWeb; + } +} + +void BgYdanSp_BurnFloorWeb(BgYdanSp* pthis, GlobalContext* globalCtx) { + static Vec3f accel = { 0 }; + Vec3f velocity; + Vec3f pos2; + f32 distXZ; + f32 sins; + f32 coss; + s16 rot; + s16 rot2; + s32 i; + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + Actor_Kill(&pthis->dyna.actor); + return; + } + if ((pthis->timer % 3) == 0) { + rot2 = Rand_ZeroOne() * 0x2AAA; + velocity.y = 0.0f; + pos2.y = pthis->dyna.actor.world.pos.y; + + for (i = 0; i < 6; i++) { + rot = Rand_CenteredFloat(0x2800) + rot2; + sins = Math_SinS(rot); + coss = Math_CosS(rot); + pos2.x = pthis->dyna.actor.world.pos.x + (120.0f * sins); + pos2.z = pthis->dyna.actor.world.pos.z + (120.0f * coss); + distXZ = Math_Vec3f_DistXZ(&pthis->dyna.actor.home.pos, &pos2) * (1.0f / 120.0f); + if (distXZ < 0.7f) { + sins = Math_SinS(rot + 0x8000); + coss = Math_CosS(rot + 0x8000); + pos2.x = pthis->dyna.actor.world.pos.x + (120.0f * sins); + pos2.z = pthis->dyna.actor.world.pos.z + (120.0f * coss); + distXZ = Math_Vec3f_DistXZ(&pthis->dyna.actor.home.pos, &pos2) * (1.0f / 120.0f); + } + velocity.x = (7.0f * sins) * distXZ; + velocity.y = 0.0f; + velocity.z = (7.0f * coss) * distXZ; + EffectSsDeadDb_Spawn(globalCtx, &pthis->dyna.actor.home.pos, &velocity, &accel, 60, 6, 255, 255, 150, 170, + 255, 0, 0, 1, 0xE, 1); + rot2 += 0x2AAA; + } + } +} + +void BgYdanSp_FloorWebBroken(BgYdanSp* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + Actor_Kill(&pthis->dyna.actor); + } +} + +void BgYdanSp_FloorWebBreaking(BgYdanSp* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 primColor = { 250, 250, 250, 255 }; + static Color_RGBA8 envColor = { 180, 180, 180, 255 }; + static Vec3f zeroVec = { 0 }; + s32 i; + Vec3f pos; + s16 rot; + + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->dyna.actor.world.pos.y = (sinf((f32)pthis->timer * (M_PI / 20)) * pthis->unk16C) + pthis->dyna.actor.home.pos.y; + if (pthis->dyna.actor.home.pos.y - pthis->dyna.actor.world.pos.y > 190.0f) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->timer = 40; + func_80078884(NA_SE_SY_CORRECT_CHIME); + Flags_SetSwitch(globalCtx, pthis->isDestroyedSwitchFlag); + pthis->actionFunc = BgYdanSp_FloorWebBroken; + pos.y = pthis->dyna.actor.world.pos.y - 60.0f; + rot = 0; + for (i = 0; i < 6; i++) { + pos.x = Math_SinS(rot) * 60.0f + pthis->dyna.actor.world.pos.x; + pos.z = Math_CosS(rot) * 60.0f + pthis->dyna.actor.world.pos.z; + func_8002829C(globalCtx, &pos, &zeroVec, &zeroVec, &primColor, &envColor, 1000, 10); + + rot += 0x2AAA; + } + } + BgYdanSp_UpdateFloorWebCollision(pthis); +} + +void BgYdanSp_FloorWebIdle(BgYdanSp* pthis, GlobalContext* globalCtx) { + Player* player; + Vec3f webPos; + f32 sqrtFallDistance; + f32 unk; + + player = GET_PLAYER(globalCtx); + webPos.x = pthis->dyna.actor.world.pos.x; + webPos.y = pthis->dyna.actor.world.pos.y - 50.0f; + webPos.z = pthis->dyna.actor.world.pos.z; + if (Player_IsBurningStickInRange(globalCtx, &webPos, 70.0f, 50.0f) != 0) { + pthis->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; + pthis->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; + BgYdanSp_BurnWeb(pthis, globalCtx); + return; + } + if ((pthis->trisCollider.base.acFlags & 2) != 0) { + BgYdanSp_BurnWeb(pthis, globalCtx); + return; + } + if (func_8004356C(&pthis->dyna)) { + sqrtFallDistance = sqrtf(CLAMP_MIN(player->fallDistance, 0.0f)); + if (player->fallDistance > 750.0f) { + if (pthis->dyna.actor.xzDistToPlayer < 80.0f) { + pthis->unk16C = 200.0f; + pthis->dyna.actor.room = -1; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + pthis->timer = 40; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WEB_BROKEN); + pthis->actionFunc = BgYdanSp_FloorWebBreaking; + return; + } + } + unk = sqrtFallDistance + sqrtFallDistance; + if (pthis->unk16C < unk) { + if (unk > 2.0f) { + pthis->unk16C = unk; + pthis->timer = 14; + } + } + if (player->actor.speedXZ != 0.0f) { + if (pthis->unk16C < 0.1f) { + pthis->timer = 14; + } + if (pthis->unk16C < 2.0f) { + pthis->unk16C = 2.0f; + } else { + pthis->unk16C = pthis->unk16C; + } + } + } + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + pthis->timer = 14; + } + pthis->dyna.actor.world.pos.y = sinf((f32)pthis->timer * (M_PI / 7)) * pthis->unk16C + pthis->dyna.actor.home.pos.y; + Math_ApproachZeroF(&pthis->unk16C, 1.0f, 0.8f); + if (pthis->timer == 13) { + if (pthis->unk16C > 3.0f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WEB_VIBRATION); + } else { + Audio_StopSfxById(NA_SE_EV_WEB_VIBRATION); + } + } + BgYdanSp_UpdateFloorWebCollision(pthis); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->trisCollider.base); +} + +void BgYdanSp_BurnWallWeb(BgYdanSp* pthis, GlobalContext* globalCtx) { + static Vec3f accel = { 0 }; + Vec3f velocity; + Vec3f spC8; + f32 distXYZ; + f32 sins; + f32 coss; + f32 coss2; + s16 rot; + s16 rot2; + s32 i; + + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + Actor_Kill(&pthis->dyna.actor); + return; + } + if ((pthis->timer % 3) == 0) { + rot2 = Rand_ZeroOne() * 0x2AAA; + + for (i = 0; i < 6; i++) { + rot = Rand_CenteredFloat(0x2800) + rot2; + sins = Math_SinS(rot); + coss = Math_CosS(rot); + coss2 = Math_CosS(pthis->dyna.actor.shape.rot.y) * sins; + sins *= Math_SinS(pthis->dyna.actor.shape.rot.y); + + spC8.x = pthis->dyna.actor.world.pos.x + (140.0f * coss2); + spC8.y = pthis->dyna.actor.world.pos.y + (140.0f * (1.0f + coss)); + spC8.z = pthis->dyna.actor.world.pos.z - (140.0f * sins); + distXYZ = Math_Vec3f_DistXYZ(&pthis->dyna.actor.home.pos, &spC8) * (1.0f / 140.0f); + if (distXYZ < 0.65f) { + sins = Math_SinS(rot + 0x8000); + coss = Math_CosS(rot + 0x8000); + coss2 = Math_CosS(pthis->dyna.actor.shape.rot.y) * sins; + sins *= Math_SinS(pthis->dyna.actor.shape.rot.y); + spC8.x = pthis->dyna.actor.world.pos.x + (140.0f * coss2); + spC8.y = pthis->dyna.actor.world.pos.y + (140.0f * (1.0f + coss)); + spC8.z = pthis->dyna.actor.world.pos.z - (140.0f * sins); + distXYZ = Math_Vec3f_DistXYZ(&pthis->dyna.actor.home.pos, &spC8) * (1.0f / 140.0f); + } + velocity.x = 6.5f * coss2 * distXYZ; + velocity.y = 6.5f * coss * distXYZ; + velocity.z = -6.5f * sins * distXYZ; + EffectSsDeadDb_Spawn(globalCtx, &pthis->dyna.actor.home.pos, &velocity, &accel, 80, 6, 255, 255, 150, 170, + 255, 0, 0, 1, 0xE, 1); + rot2 += 0x2AAA; + } + } +} + +void BgYdanSp_WallWebIdle(BgYdanSp* pthis, GlobalContext* globalCtx) { + Player* player; + Vec3f sp30; + + player = GET_PLAYER(globalCtx); + if (Flags_GetSwitch(globalCtx, pthis->burnSwitchFlag) || (pthis->trisCollider.base.acFlags & 2)) { + pthis->dyna.actor.home.pos.y = pthis->dyna.actor.world.pos.y + 80.0f; + BgYdanSp_BurnWeb(pthis, globalCtx); + } else if (player->heldItemActionParam == PLAYER_AP_STICK && player->unk_860 != 0) { + func_8002DBD0(&pthis->dyna.actor, &sp30, &player->swordInfo[0].tip); + if (fabsf(sp30.x) < 100.0f && sp30.z < 1.0f && sp30.y < 200.0f) { + OnePointCutscene_Init(globalCtx, 3020, 40, &pthis->dyna.actor, MAIN_CAM); + Math_Vec3f_Copy(&pthis->dyna.actor.home.pos, &player->swordInfo[0].tip); + BgYdanSp_BurnWeb(pthis, globalCtx); + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->trisCollider.base); +} + +void BgYdanSp_Update(Actor* thisx, GlobalContext* globalCtx) { + BgYdanSp* pthis = (BgYdanSp*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void BgYdanSp_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgYdanSp* pthis = (BgYdanSp*)thisx; + s32 i; + MtxF mtxF; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 781); + func_80093D84(globalCtx->state.gfxCtx); + if (thisx->params == WEB_WALL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 787), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDTWebWallDL); + } else if (pthis->actionFunc == BgYdanSp_FloorWebBroken) { + Matrix_Get(&mtxF); + if (pthis->timer == 40) { + Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 808), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDTWebFloorDL); + } + for (i = 0; i < 8; i++) { + Matrix_Put(&mtxF); + Matrix_RotateZYX(-0x5A0, i * 0x2000, 0, MTXMODE_APPLY); + Matrix_Translate(0.0f, 700.0f, -900.0f, MTXMODE_APPLY); + Matrix_Scale(3.5f, 5.0f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 830), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDTUnknownWebDL); + } + } else { + Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 849), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDTWebFloorDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_ydan_sp.c", 856); +} diff --git a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.cpp similarity index 54% rename from src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c rename to src/overlays/actors/ovl_Bg_Zg/z_bg_zg.cpp index eb7a312ba..900c609f8 100644 --- a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c +++ b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.cpp @@ -24,12 +24,12 @@ void BgZg_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgZg_Update(Actor* thisx, GlobalContext* globalCtx); void BgZg_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808C0C50(BgZg* this); -s32 func_808C0C98(BgZg* this, GlobalContext* globalCtx); -s32 func_808C0CC8(BgZg* this); -void func_808C0CD4(BgZg* this, GlobalContext* globalCtx); -void func_808C0D08(BgZg* this, GlobalContext* globalCtx); -void func_808C0EEC(BgZg* this, GlobalContext* globalCtx); +void func_808C0C50(BgZg* pthis); +s32 func_808C0C98(BgZg* pthis, GlobalContext* globalCtx); +s32 func_808C0CC8(BgZg* pthis); +void func_808C0CD4(BgZg* pthis, GlobalContext* globalCtx); +void func_808C0D08(BgZg* pthis, GlobalContext* globalCtx); +void func_808C0EEC(BgZg* pthis, GlobalContext* globalCtx); static BgZgActionFunc sActionFuncs[] = { func_808C0CD4, @@ -44,7 +44,7 @@ static BgZgDrawFunc sDrawFuncs[] = { func_808C0EEC, }; -const ActorInit Bg_Zg_InitVars = { +ActorInit Bg_Zg_InitVars = { ACTOR_BG_ZG, ACTORCAT_NPC, FLAGS, @@ -57,78 +57,78 @@ const ActorInit Bg_Zg_InitVars = { }; void BgZg_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgZg* this = (BgZg*)thisx; + BgZg* pthis = (BgZg*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_808C0C50(BgZg* this) { - Audio_PlaySoundGeneral(NA_SE_EV_METALDOOR_OPEN, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, +void func_808C0C50(BgZg* pthis) { + Audio_PlaySoundGeneral(NA_SE_EV_METALDOOR_OPEN, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } -s32 func_808C0C98(BgZg* this, GlobalContext* globalCtx) { - s32 flag = (this->dyna.actor.params >> 8) & 0xFF; +s32 func_808C0C98(BgZg* pthis, GlobalContext* globalCtx) { + s32 flag = (pthis->dyna.actor.params >> 8) & 0xFF; return Flags_GetSwitch(globalCtx, flag); } -s32 func_808C0CC8(BgZg* this) { - s32 flag = this->dyna.actor.params & 0xFF; +s32 func_808C0CC8(BgZg* pthis) { + s32 flag = pthis->dyna.actor.params & 0xFF; return flag; } -void func_808C0CD4(BgZg* this, GlobalContext* globalCtx) { - if (func_808C0C98(this, globalCtx) != 0) { - this->action = 1; - func_808C0C50(this); +void func_808C0CD4(BgZg* pthis, GlobalContext* globalCtx) { + if (func_808C0C98(pthis, globalCtx) != 0) { + pthis->action = 1; + func_808C0C50(pthis); } } -void func_808C0D08(BgZg* this, GlobalContext* globalCtx) { - this->dyna.actor.world.pos.y += (kREG(16) + 20.0f) * 1.2f; - if ((((kREG(17) + 200.0f) * 1.2f) + this->dyna.actor.home.pos.y) <= this->dyna.actor.world.pos.y) { - Actor_Kill(&this->dyna.actor); +void func_808C0D08(BgZg* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.world.pos.y += (kREG(16) + 20.0f) * 1.2f; + if ((((kREG(17) + 200.0f) * 1.2f) + pthis->dyna.actor.home.pos.y) <= pthis->dyna.actor.world.pos.y) { + Actor_Kill(&pthis->dyna.actor); } } void BgZg_Update(Actor* thisx, GlobalContext* globalCtx) { - BgZg* this = (BgZg*)thisx; - s32 action = this->action; + BgZg* pthis = (BgZg*)thisx; + s32 action = pthis->action; if (((action < 0) || (1 < action)) || (sActionFuncs[action] == NULL)) { // "Main Mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!" osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); } else { - sActionFuncs[action](this, globalCtx); + sActionFuncs[action](pthis, globalCtx); } } void BgZg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; - BgZg* this = (BgZg*)thisx; + BgZg* pthis = (BgZg*)thisx; CollisionHeader* colHeader; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); colHeader = NULL; CollisionHeader_GetVirtual(&gTowerCollapseBarsCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if ((func_808C0CC8(this) == 8) || (func_808C0CC8(this) == 9)) { - this->dyna.actor.scale.x = this->dyna.actor.scale.x * 1.3f; - this->dyna.actor.scale.z = this->dyna.actor.scale.z * 1.3f; - this->dyna.actor.scale.y = this->dyna.actor.scale.y * 1.2f; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if ((func_808C0CC8(pthis) == 8) || (func_808C0CC8(pthis) == 9)) { + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.x * 1.3f; + pthis->dyna.actor.scale.z = pthis->dyna.actor.scale.z * 1.3f; + pthis->dyna.actor.scale.y = pthis->dyna.actor.scale.y * 1.2f; } - this->action = 0; - this->drawConfig = 0; - if (func_808C0C98(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); + pthis->action = 0; + pthis->drawConfig = 0; + if (func_808C0C98(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); } } -void func_808C0EEC(BgZg* this, GlobalContext* globalCtx) { +void func_808C0EEC(BgZg* pthis, GlobalContext* globalCtx) { GraphicsContext* localGfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(localGfxCtx, "../z_bg_zg.c", 311); @@ -142,13 +142,13 @@ void func_808C0EEC(BgZg* this, GlobalContext* globalCtx) { } void BgZg_Draw(Actor* thisx, GlobalContext* globalCtx) { - BgZg* this = (BgZg*)thisx; - s32 drawConfig = this->drawConfig; + BgZg* pthis = (BgZg*)thisx; + s32 drawConfig = pthis->drawConfig; if (((drawConfig < 0) || (drawConfig > 0)) || sDrawFuncs[drawConfig] == NULL) { // "Drawing mode is wrong !!!!!!!!!!!!!!!!!!!!!!!!!" osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); } else { - sDrawFuncs[drawConfig](this, globalCtx); + sDrawFuncs[drawConfig](pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c deleted file mode 100644 index fd24c2302..000000000 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ /dev/null @@ -1,1725 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_DODONGO_Z_BOSS_DODONGO_C -#include "actor_common.h" -#include "z_boss_dodongo.h" -#include "objects/object_kingdodongo/object_kingdodongo.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "scenes/dungeons/ddan_boss/ddan_boss_room_1.h" -#include "def/code_800A9F30.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BossDodongo_Init(Actor* thisx, GlobalContext* globalCtx); -void BossDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossDodongo_Update(Actor* thisx, GlobalContext* globalCtx); -void BossDodongo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BossDodongo_SetupIntroCutscene(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_IntroCutscene(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_Walk(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_Inhale(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_BlowFire(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_Roll(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_SpawnFire(BossDodongo* this, GlobalContext* globalCtx, s16 arg2); -void BossDodongo_Explode(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_LayDown(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_Vulnerable(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_GetUp(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_SetupWalk(BossDodongo* this); -void BossDodongo_DeathCutscene(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_SetupDeathCutscene(BossDodongo* this); -void BossDodongo_Damaged(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_UpdateDamage(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_PlayerPosCheck(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_PlayerYawCheck(BossDodongo* this, GlobalContext* globalCtx); -f32 func_808C4F6C(BossDodongo* this, GlobalContext* globalCtx); -f32 func_808C50A8(BossDodongo* this, GlobalContext* globalCtx); -void BossDodongo_DrawEffects(GlobalContext* globalCtx); -void BossDodongo_UpdateEffects(GlobalContext* globalCtx); - -const ActorInit Boss_Dodongo_InitVars = { - ACTOR_EN_DODONGO, - ACTORCAT_BOSS, - FLAGS, - OBJECT_KINGDODONGO, - sizeof(BossDodongo), - (ActorFunc)BossDodongo_Init, - (ActorFunc)BossDodongo_Destroy, - (ActorFunc)BossDodongo_Update, - (ActorFunc)BossDodongo_Draw, -}; - -#include "z_boss_dodongo_data.c" - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x0C, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -3000.0f, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 8200.0f, ICHAIN_STOP), -}; - -void func_808C1190(s16* arg0, u8* arg1, s16 arg2) { - if (arg2[arg1] != 0) { - arg0[arg2 / 2] = 0; - } -} - -void func_808C11D0(s16* arg0, u8* arg1, s16 arg2) { - if (arg1[arg2] != 0) { - arg0[arg2] = 0; - } -} - -void func_808C1200(s16* arg0, u8* arg1, s16 arg2) { - if (arg1[arg2] != 0) { - arg0[arg2] = 0; - } -} - -void func_808C1230(s16* arg0, u8* arg1, s16 arg2) { - s16 index; - - if (arg1[arg2] != 0) { - index = ((arg2 & 0xF) + ((arg2 & 0xF0) * 2)); - arg0[index + 16] = 0; - arg0[index] = 0; - } -} - -void func_808C1278(s16* arg0, u8* arg1, s16 arg2) { - s16 index; - - if (arg1[arg2] != 0) { - index = ((arg2 & 0xF) * 2) + ((arg2 & 0xF0) * 2); - arg0[index + 1] = 0; - arg0[index] = 0; - } -} - -void func_808C12C4(u8* arg1, s16 arg2) { - func_808C1190(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015890), arg1, arg2); - func_808C1200(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_017210), arg1, arg2); - func_808C11D0(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015D90), arg1, arg2); - func_808C11D0(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016390), arg1, arg2); - func_808C11D0(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016590), arg1, arg2); - func_808C11D0(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016790), arg1, arg2); - func_808C1230(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015990), arg1, arg2); - func_808C1230(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015F90), arg1, arg2); - func_808C1278(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016990), arg1, arg2); - func_808C1278(SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016E10), arg1, arg2); -} - -void func_808C1554(void* arg0, void* floorTex, s32 arg2, f32 arg3) { - u16* temp_s3 = SEGMENTED_TO_VIRTUAL(arg0); - u16* temp_s1 = SEGMENTED_TO_VIRTUAL(floorTex); - s16 i; - s16 i2; - u16 sp54[2048]; - s16 temp; - s16 temp2; - - for (i = 0; i < 2048; i += 32) { - temp = sinf((((i / 32) + (s16)((arg2 * 50.0f) / 100.0f)) & 0x1F) * (M_PI / 16)) * arg3; - for (i2 = 0; i2 < 32; i2++) { - sp54[i + ((temp + i2) & 0x1F)] = temp_s1[i + i2]; - } - } - for (i = 0; i < 32; i++) { - temp = sinf(((i + (s16)((arg2 * 80.0f) / 100.0f)) & 0x1F) * (M_PI / 16)) * arg3; - temp *= 32; - for (i2 = 0; i2 < 2048; i2 += 32) { - temp2 = (temp + i2) & 0x7FF; - temp_s3[i + temp2] = sp54[i + i2]; - } - } -} - -void func_808C17C8(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5) { - s16 i; - BossDodongoEffect* eff = (BossDodongoEffect*)globalCtx->specialEffects; - - for (i = 0; i < arg5; i++, eff++) { - if (eff->unk_24 == 0) { - eff->unk_24 = 1; - eff->unk_00 = *arg1; - eff->unk_0C = *arg2; - eff->unk_18 = *arg3; - eff->unk_2C = arg4 / 1000.0f; - eff->alpha = 255; - eff->unk_25 = (s16)Rand_ZeroFloat(10.0f); - break; - } - } -} - -s32 BossDodongo_AteExplosive(BossDodongo* this, GlobalContext* globalCtx) { - f32 dx; - f32 dy; - f32 dz; - Actor* currentExplosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; - Actor* thisx = &this->actor; - - while (currentExplosive != NULL) { - if (currentExplosive == thisx) { - currentExplosive = currentExplosive->next; - continue; - } - - dx = currentExplosive->world.pos.x - this->mouthPos.x; - dy = currentExplosive->world.pos.y - this->mouthPos.y; - dz = currentExplosive->world.pos.z - this->mouthPos.z; - - if ((fabsf(dx) < 40.0f) && (fabsf(dy) < 40.0f) && (fabsf(dz) < 40.0f)) { - Actor_Kill(currentExplosive); - return true; - } - - currentExplosive = currentExplosive->next; - } - - return false; -} - -void BossDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { - BossDodongo* this = (BossDodongo*)thisx; - s16 i; - u16* temp_s1_3; - u16* temp_s2; - u32 temp_v0; - - globalCtx->specialEffects = &this->effects; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 9200.0f, ActorShadow_DrawCircle, 250.0f); - Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_kingdodongo_Skel_01B310, &object_kingdodongo_Anim_00F0D8, NULL, - NULL, 0); - Animation_PlayLoop(&this->skelAnime, &object_kingdodongo_Anim_00F0D8); - this->unk_1F8 = 1.0f; - BossDodongo_SetupIntroCutscene(this, globalCtx); - this->health = 12; - this->colorFilterMin = 995.0f; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->colorFilterMax = 1000.0f; - this->unk_224 = 2.0f; - this->unk_228 = 9200.0f; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->items); - - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { // KD is dead - temp_s1_3 = SEGMENTED_TO_VIRTUAL(gDodongosCavernBossLavaFloorTex); - temp_s2 = SEGMENTED_TO_VIRTUAL(sLavaFloorRockTex); - - Actor_Kill(&this->actor); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, -890.0f, -1523.76f, - -3304.0f, 0, 0, 0, WARP_DUNGEON_CHILD); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_BREAKWALL, -890.0f, -1523.76f, -3304.0f, 0, 0, 0, 0x6000); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -690.0f, -1523.76f, -3304.0f, 0, 0, 0, 0); - - for (i = 0; i < 2048; i++) { - temp_v0 = i; - temp_s1_3[temp_v0] = temp_s2[temp_v0]; - } - } - - this->actor.flags &= ~ACTOR_FLAG_0; -} - -void BossDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BossDodongo* this = (BossDodongo*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void BossDodongo_SetupIntroCutscene(BossDodongo* this, GlobalContext* globalCtx) { - s16 frames = Animation_GetLastFrame(&object_kingdodongo_Anim_00F0D8); - - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_00F0D8, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); - this->actionFunc = BossDodongo_IntroCutscene; - this->csState = 0; - this->unk_1BC = 1; -} - -void BossDodongo_IntroCutscene(BossDodongo* this, GlobalContext* globalCtx) { - f32 phi_f0; - Camera* camera; - Player* player; - Vec3f sp60; - Vec3f sp54; - Vec3f sp48; - - player = GET_PLAYER(globalCtx); - camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); - - if (this->unk_196 != 0) { - this->unk_196--; - } - - if (this->unk_198 != 0) { - this->unk_198--; - } - - if (this->unk_19A != 0) { - this->unk_19A--; - } - - switch (this->csState) { - case 0: - if (player->actor.world.pos.y < -1223.76f) { - this->csState = 1; - this->actor.world.pos.x = -1390.0f; - this->actor.world.pos.z = -3374.0f; - this->unk_1A0 = 1; - } - break; - case 1: - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 1); - Gameplay_ClearAllSubCameras(globalCtx); - this->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, 0, 1); - Gameplay_ChangeCameraStatus(globalCtx, this->cutsceneCamera, 7); - this->csState = 2; - this->unk_196 = 0x3C; - this->unk_198 = 160; - player->actor.world.pos.y = -1023.76f; - this->cameraEye.y = player->actor.world.pos.y - 480.0f + 50.0f; - case 2: - if (this->unk_198 >= 131) { - player->actor.world.pos.x = -890.0f; - player->actor.world.pos.z = -2804.0f; - - player->actor.speedXZ = 0.0f; - player->actor.shape.rot.y = player->actor.world.rot.y = 0x3FFF; - - this->cameraEye.x = -890.0f; - this->cameraEye.z = player->actor.world.pos.z - 100.0f; - - this->cameraAt.x = player->actor.world.pos.x; - this->cameraAt.y = player->actor.world.pos.y + 20.0f; - this->cameraAt.z = player->actor.world.pos.z; - } - - if (this->unk_198 == 110) { - func_8002DF54(globalCtx, &this->actor, 9); - } - - if (this->unk_198 == 5) { - func_8002DF54(globalCtx, &this->actor, 12); - } - - if (this->unk_198 < 6) { - player->actor.shape.rot.y = -0x4001; - } else { - player->actor.shape.rot.y = 0x3FFF; - } - - if (this->unk_198 < 60) { - this->unk_1BC = 1; - } else { - this->unk_1BC = 2; - } - - BossDodongo_Walk(this, globalCtx); - - if (this->unk_196 == 1) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - } - - if (this->unk_196 == 0) { - Math_SmoothStepToF(&this->cameraEye.x, this->vec.x + 30.0f, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.y, this->vec.y, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.z, this->vec.z + 10.0f, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); - } else { - this->cameraAt.x = player->actor.world.pos.x; - this->cameraAt.y = player->actor.world.pos.y + 20.0f; - this->cameraAt.z = player->actor.world.pos.z; - } - - if (gSaveContext.eventChkInf[7] & 2) { - if (this->unk_198 == 100) { - this->actor.world.pos.x = -1114.0f; - this->actor.world.pos.z = -2804.0f; - this->actor.world.rot.y = 0x3FFF; - this->unk_1A2 = 0; - this->unk_1A0 = 2; - this->csState = 4; - this->unk_196 = 30; - this->unk_198 = 150; - this->unk_204 = 0.0f; - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_008EEC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_008EEC), ANIMMODE_ONCE, 0.0f); - SkelAnime_Update(&this->skelAnime); - } - } else if (this->unk_198 == 0) { - this->csState = 3; - this->unk_19E = 0x14; - this->unk_204 = 0.0f; - } - break; - case 3: - BossDodongo_Walk(this, globalCtx); - Math_SmoothStepToF(&this->unk_20C, sinf(this->unk_19E * 0.05f) * 0.1f, 1.0f, 0.01f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.x, this->vec.x + 90.0f, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.y, this->vec.y + 50.0f, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.z, this->vec.z, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.y, this->vec.y - 10.0f, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); - if (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < 200.0f) { - this->csState = 4; - this->unk_196 = 0x1E; - this->unk_198 = 0x96; - this->unk_204 = 0.0f; - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_008EEC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_008EEC), ANIMMODE_ONCE, -5.0f); - } - break; - case 4: - Math_SmoothStepToF(&this->unk_20C, 0.0f, 1.0f, 0.01f, 0.0f); - - if (gSaveContext.eventChkInf[7] & 2) { - phi_f0 = -50.0f; - } else { - phi_f0 = 0.0f; - } - - Math_SmoothStepToF(&this->cameraEye.x, player->actor.world.pos.x + phi_f0 + 70.0f, 0.2f, - this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.y, player->actor.world.pos.y + 10.0f, 0.2f, this->unk_204 * 20.0f, - 0.0f); - Math_SmoothStepToF(&this->cameraEye.z, player->actor.world.pos.z - 60.0f, 0.2f, this->unk_204 * 20.0f, - 0.0f); - - Math_SmoothStepToF(&this->cameraAt.x, this->vec.x, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.y, this->vec.y, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.z, this->vec.z, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); - - if (this->unk_196 == 0) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); - } - - if (this->unk_198 == 0x64) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_OTAKEBI); - } - - if (this->unk_198 == 0x5A) { - if (!(gSaveContext.eventChkInf[7] & 2)) { - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(&object_kingdodongo_Blob_017410), 0xA0, 0xB4, 0x80, - 0x28); - } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); - } - - if (this->unk_198 == 0) { - camera->eye = this->cameraEye; - camera->eyeNext = this->cameraEye; - camera->at = this->cameraAt; - func_800C08AC(globalCtx, this->cutsceneCamera, 0); - this->cutsceneCamera = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - BossDodongo_SetupWalk(this); - this->unk_1DA = 50; - this->unk_1BC = 0; - player->actor.shape.rot.y = -0x4002; - gSaveContext.eventChkInf[7] |= 2; - } - break; - } - - if (this->cutsceneCamera != 0) { - if (this->unk_1B6 != 0) { - this->unk_1B6--; - } - - sp60.x = this->cameraEye.x; - phi_f0 = sinf((this->unk_1B6 * 3.1415f * 90.0f) / 180.0f); - sp60.y = (this->unk_1B6 * phi_f0 * 0.7f) + this->cameraEye.y; - sp60.z = this->cameraEye.z; - - sp54.x = this->cameraAt.x; - phi_f0 = sinf((this->unk_1B6 * 3.1415f * 90.0f) / 180.0f); - sp54.y = (this->unk_1B6 * phi_f0 * 0.7f) + this->cameraAt.y; - sp54.z = this->cameraAt.z; - - sp48.x = this->unk_20C; - sp48.y = 1.0f; - sp48.z = this->unk_20C; - - Gameplay_CameraSetAtEyeUp(globalCtx, this->cutsceneCamera, &sp54, &sp60, &sp48); - } -} - -void BossDodongo_SetupDamaged(BossDodongo* this) { - if (this->actionFunc != BossDodongo_Damaged) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_001074, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_001074), ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_Damaged; - } - - this->unk_1DA = 100; -} - -void BossDodongo_SetupExplode(BossDodongo* this) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_00E848, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_00E848), ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_Explode; - this->unk_1B0 = 10; - this->unk_1C0 = 2; - this->unk_1DA = 35; - this->unk_1FC = 50.0f; - this->unk_200 = 300.0f; -} - -void BossDodongo_SetupWalk(BossDodongo* this) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_01D934, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_01D934), ANIMMODE_ONCE, -10.0f); - this->unk_1AA = 0; - this->actionFunc = BossDodongo_Walk; - this->unk_1DA = 0; - this->actor.flags |= ACTOR_FLAG_0; - this->unk_1E4 = 0.0f; -} - -void BossDodongo_SetupRoll(BossDodongo* this) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_00DF38, 1.0f, 0.0f, 59.0f, ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_Roll; - this->numWallCollisions = 0; - this->unk_1DA = 27; -} - -void BossDodongo_SetupBlowFire(BossDodongo* this) { - this->actor.speedXZ = 0.0f; - this->unk_1E4 = 0.0f; - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_0061D4, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_0061D4), ANIMMODE_ONCE, 0.0f); - this->actionFunc = BossDodongo_BlowFire; - this->unk_1DA = 50; - this->unk_1AE = 0; -} - -void BossDodongo_SetupInhale(BossDodongo* this) { - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_008EEC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_008EEC), ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_Inhale; - this->unk_1DA = 100; - this->unk_1AC = 0; - this->unk_1E2 = 1; -} - -void BossDodongo_Damaged(BossDodongo* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->unk_1F8, 1.0f, 0.5f, 0.02f, 0.001f); - Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); - - if (Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_001074))) { - BossDodongo_SetupRoll(this); - } -} - -void BossDodongo_Explode(BossDodongo* this, GlobalContext* globalCtx) { - static Color_RGBA8 dustPrimColor = { 255, 255, 0, 255 }; - static Color_RGBA8 dustEnvColor = { 255, 10, 0, 255 }; - s16 pad; - Vec3f dustVel; - Vec3f dustAcell; - Vec3f dustPos; - s16 i; - - Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->unk_1DA == 0) { - for (i = 0; i < 30; i++) { - dustVel.x = Rand_CenteredFloat(20.0f); - dustVel.y = Rand_CenteredFloat(20.0f); - dustVel.z = Rand_CenteredFloat(20.0f); - - dustAcell.x = dustVel.x * -0.1f; - dustAcell.y = dustVel.y * -0.1f; - dustAcell.z = dustVel.z * -0.1f; - - dustPos.x = this->actor.world.pos.x + (dustVel.x * 3.0f); - dustPos.y = this->actor.world.pos.y + 90.0f + (dustVel.y * 3.0f); - dustPos.z = this->actor.world.pos.z + (dustVel.z * 3.0f); - - func_8002836C(globalCtx, &dustPos, &dustVel, &dustAcell, &dustPrimColor, &dustEnvColor, 500, 10, 10); - } - - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_004E0C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_004E0C), ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_LayDown; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_DAMAGE); - func_80033E88(&this->actor, globalCtx, 4, 10); - this->health -= 2; - - // make sure not to die from the bomb explosion - if (this->health <= 0) { - this->health = 1; - } - } -} - -void BossDodongo_LayDown(BossDodongo* this, GlobalContext* globalCtx) { - this->unk_1BE = 10; - Math_SmoothStepToF(&this->unk_1F8, 1.3f, 1.0f, 0.1f, 0.001f); - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_004E0C))) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_0042A8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_0042A8), ANIMMODE_LOOP, -5.0f); - this->actionFunc = BossDodongo_Vulnerable; - this->unk_1DA = 100; - } -} - -void BossDodongo_Vulnerable(BossDodongo* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_DOWN - SFX_FLAG); - this->unk_1BE = 10; - Math_SmoothStepToF(&this->unk_1F8, 1.0f, 0.5f, 0.02f, 0.001f); - Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->unk_1DA == 0) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_009D10, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_009D10), ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_GetUp; - } -} - -void BossDodongo_GetUp(BossDodongo* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_009D10))) { - BossDodongo_SetupRoll(this); - } -} - -void BossDodongo_BlowFire(BossDodongo* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f unusedZeroVec1 = { 0.0f, 0.0f, 0.0f }; - Vec3f unusedZeroVec2 = { 0.0f, 0.0f, 0.0f }; - - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_CRY); - } - - if (Animation_OnFrame(&this->skelAnime, 17.0f)) { - this->unk_1C8 = 28; - } - - if ((this->skelAnime.curFrame > 17.0f) && (this->skelAnime.curFrame < 35.0f)) { - BossDodongo_SpawnFire(this, globalCtx, this->unk_1AE); - this->unk_1AE++; - Math_SmoothStepToF(&this->unk_244, 0.0f, 1.0f, 8.0f, 0.0f); - } - - if (this->unk_1DA == 0) { - BossDodongo_SetupRoll(this); - } -} - -void BossDodongo_Inhale(BossDodongo* this, GlobalContext* GlobalContext) { - this->unk_1E2 = 1; - - if (this->unk_1AC > 20) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_BREATH - SFX_FLAG); - } - - Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->unk_1DA == 0) { - BossDodongo_SetupBlowFire(this); - } else { - this->unk_1AC++; - - if ((this->unk_1AC > 20) && (this->unk_1AC < 82) && BossDodongo_AteExplosive(this, GlobalContext)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_DRINK); - BossDodongo_SetupExplode(this); - } - } -} - -static Vec3f sCornerPositions[] = { - { -1390.0f, 0.0f, -3804.0f }, - { -1390.0f, 0.0f, -2804.0f }, - { -390.0f, 0.0f, -2804.0f }, - { -390.0f, 0.0f, -3804.0f }, -}; - -void BossDodongo_Walk(BossDodongo* this, GlobalContext* globalCtx) { - Vec3f* sp4C; - f32 sp48; - f32 sp44; - - if (this->unk_1AA == 0) { - if (Animation_OnFrame(&this->skelAnime, 14.0f)) { - Animation_PlayLoop(&this->skelAnime, &object_kingdodongo_Anim_01CAE0); - this->unk_1AA = 1; - } - } else if (this->unk_1BC != 2) { - if (((s32)this->skelAnime.curFrame == 1) || ((s32)this->skelAnime.curFrame == 31)) { - if ((s32)this->skelAnime.curFrame == 1) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->unk_410, 25.0f, 0xA, 8.0f, 0x1F4, 0xA, 0); - } else { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->unk_404, 25.0f, 0xA, 8.0f, 0x1F4, 0xA, 0); - } - - if (this->unk_1BC != 0) { - func_80078884(NA_SE_EN_DODO_K_WALK); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_WALK); - } - - if (this->cutsceneCamera == 0) { - func_80033E88(&this->actor, globalCtx, 4, 10); - } else { - this->unk_1B6 = 10; - func_800A9F6C(0.0f, 180, 20, 100); - } - } - } - - SkelAnime_Update(&this->skelAnime); - sp4C = &sCornerPositions[this->unk_1A0]; - this->unk_1EC = 0.7f; - Math_SmoothStepToF(&this->unk_1E4, this->unk_1EC * 4.0f, 1.0f, this->unk_1EC * 0.25f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.x, sp4C->x, 0.3f, this->unk_1E4, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, sp4C->z, 0.3f, this->unk_1E4, 0.0f); - sp48 = sp4C->x - this->actor.world.pos.x; - sp44 = sp4C->z - this->actor.world.pos.z; - Math_SmoothStepToF(&this->unk_1E8, 2000.0f, 1.0f, this->unk_1EC * 80.0f, 0.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(sp48, sp44) * (0x8000 / M_PI), 5, - (this->unk_1EC * this->unk_1E8), 5); - Math_SmoothStepToS(&this->unk_1C4, 0, 2, 2000, 0); - - if ((fabsf(sp48) <= 5.0f) && (fabsf(sp44) <= 5.0f)) { - this->unk_1E8 = 0.0f; - this->unk_1E4 = 0.0f; - if (this->unk_1A2 == 0) { - this->unk_1A0++; - if (this->unk_1A0 >= 4) { - this->unk_1A0 = 0; - } - } else { - this->unk_1A0--; - if (this->unk_1A0 < 0) { - this->unk_1A0 = 3; - } - } - } - - if ((this->unk_1DA == 0) && (this->unk_1BC == 0)) { - if ((this->actor.xzDistToPlayer < 500.0f) && (this->unk_1A4 != 0) && !this->playerPosInRange) { - BossDodongo_SetupInhale(this); - BossDodongo_SpawnFire(this, globalCtx, -1); - } - - if (!this->playerPosInRange && !this->playerYawInRange) { - BossDodongo_SetupRoll(this); - } - } -} - -void BossDodongo_Roll(BossDodongo* this, GlobalContext* globalCtx) { - Vec3f* sp5C; - Vec3f sp50; - f32 sp4C; - f32 sp48; - - this->actor.flags |= ACTOR_FLAG_24; - SkelAnime_Update(&this->skelAnime); - - if (this->unk_1DA == 10) { - this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_CRY); - } - - if (this->unk_1DA == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_COLI2); - } - - sp5C = &sCornerPositions[this->unk_1A0]; - this->unk_1EC = 3.0f; - - if (this->unk_1DA == 0) { - Math_SmoothStepToF(&this->unk_1E4, this->unk_1EC * 5.0f, 1.0f, this->unk_1EC * 0.25f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.x, sp5C->x, 1.0f, this->unk_1E4, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, sp5C->z, 1.0f, this->unk_1E4, 0.0f); - this->unk_1C4 += 2000; - - if (this->actor.bgCheckFlags & 1) { - this->unk_228 = 7700.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); - - if ((this->unk_19E & 7) == 0) { - Camera_AddQuake(&globalCtx->mainCamera, 2, 1, 8); - } - - if (!(this->unk_19E & 1)) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 40.0f, 3, 8.0f, 0x1F4, 0xA, - 0); - } - } - } - - sp4C = sp5C->x - this->actor.world.pos.x; - sp48 = sp5C->z - this->actor.world.pos.z; - Math_SmoothStepToF(&this->unk_1E8, 2000.0f, 1.0f, this->unk_1EC * 100.0f, 0.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(sp4C, sp48) * (0x8000 / M_PI), 5, - this->unk_1EC * this->unk_1E8, 0); - - if (fabsf(sp4C) <= 15.0f && fabsf(sp48) <= 15.0f) { - this->numWallCollisions++; - - if (this->numWallCollisions >= 2) { - if (this->unk_1A6 != 0) { - this->unk_1A2 = 1 - this->unk_1A2; - } - - this->unk_1E8 = 0.0f; - this->unk_1E4 = 0.0f; - BossDodongo_SetupWalk(this); - this->unk_228 = 9200.0f; - this->actor.velocity.y = 20.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_COLI); - Camera_AddQuake(&globalCtx->mainCamera, 2, 6, 8); - sp50.x = this->actor.world.pos.x; - sp50.y = this->actor.world.pos.y + 60.0f; - sp50.z = this->actor.world.pos.z; - func_80033480(globalCtx, &sp50, 250.0f, 40, 800, 10, 0); - func_80033E88(&this->actor, globalCtx, 6, 15); - } else { - this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_COLI2); - } - - if (this->unk_1A2 == 0) { - this->unk_1A0++; - if (this->unk_1A0 >= 4) { - this->unk_1A0 = 0; - } - } else { - this->unk_1A0--; - if (this->unk_1A0 < 0) { - this->unk_1A0 = 3; - } - } - } -} - -void BossDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BossDodongo* this = (BossDodongo*)thisx; - f32 temp_f0; - s16 i; - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); - s32 pad; - - this->unk_1E2 = 0; - this->unk_19E++; - - if (this->unk_1DA != 0) { - this->unk_1DA--; - } - - if (this->unk_1DC != 0) { - this->unk_1DC--; - } - - if (this->unk_1DE != 0) { - this->unk_1DE--; - } - - if (this->unk_1C0 != 0) { - this->unk_1C0--; - } - - if (this->unk_1C8 != 0) { - this->unk_1C8--; - } - - temp_f0 = func_808C4F6C(this, globalCtx); - - if (temp_f0 > 0.0f) { - this->unk_1A4 = temp_f0; - } else { - this->unk_1A4 = 0; - } - - temp_f0 = func_808C50A8(this, globalCtx); - - if (temp_f0 > 0.0f) { - this->unk_1A6 = temp_f0; - } else { - this->unk_1A6 = 0; - } - - BossDodongo_PlayerYawCheck(this, globalCtx); - BossDodongo_PlayerPosCheck(this, globalCtx); - - this->actionFunc(this, globalCtx); - - thisx->shape.rot.y = thisx->world.rot.y; - - Math_SmoothStepToF(&thisx->shape.yOffset, this->unk_228, 1.0f, 100.0f, 0.0f); - Actor_MoveForward(thisx); - BossDodongo_UpdateDamage(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 10.0f, 10.0f, 20.0f, 4); - Math_SmoothStepToF(&this->unk_208, 0, 1, 0.001f, 0.0); - Math_SmoothStepToF(&this->unk_20C, 0, 1, 0.001f, 0.0); - - if ((this->unk_19E % 128) == 0) { - for (i = 0; i < 50; i++) { - this->unk_324[i] = (Rand_ZeroOne() * 0.25f) + 0.5f; - } - } - - for (i = 0; i < 50; i++) { - this->unk_25C[i] += this->unk_324[i]; - } - - if (this->unk_1C8 != 0) { - if (this->unk_1C8 >= 11) { - Math_SmoothStepToF(&this->unk_240, (this->unk_1C8 & 1) ? (40.0f) : (60.0f), 1.0f, 50.0f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_240, 0.0f, 1, 10.0f, 0.0); - } - - if ((globalCtx->envCtx.adjLight1Color[2] == 0) && (globalCtx->envCtx.adjAmbientColor[2] == 0)) { - globalCtx->envCtx.adjLight1Color[0] = (u8)this->unk_240; - globalCtx->envCtx.adjLight1Color[1] = (u8)(this->unk_240 * 0.1f); - globalCtx->envCtx.adjAmbientColor[0] = (u8)this->unk_240; - globalCtx->envCtx.adjAmbientColor[1] = (u8)(this->unk_240 * 0.1f); - } - } - - if (this->unk_1BE != 0) { - if (this->unk_1BE >= 1000) { - Math_SmoothStepToF(&this->colorFilterR, 30.0f, 1, 20.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterG, 10.0f, 1, 20.0f, 0.0); - } else { - this->unk_1BE--; - Math_SmoothStepToF(&this->colorFilterR, 255.0f, 1, 20.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterG, 0.0f, 1, 20.0f, 0.0); - } - - Math_SmoothStepToF(&this->colorFilterB, 0.0f, 1, 20.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterMin, 900.0f, 1, 10.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterMax, 1099.0f, 1, 10.0f, 0.0); - } else { - Math_SmoothStepToF(&this->colorFilterR, globalCtx->lightCtx.fogColor[0], 1, 5.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterG, globalCtx->lightCtx.fogColor[1], 1.0f, 5.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterB, globalCtx->lightCtx.fogColor[2], 1.0f, 5.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterMin, globalCtx->lightCtx.fogNear, 1.0, 5.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterMax, 1000.0f, 1, 5.0f, 0.0); - } - - if (player->actor.world.pos.y < -1000.0f) { - s16 phi_s0_3; - s16 sp90; - s16 magma2DrawMode; - s16 magmaScale = 0; - - if (this->unk_224 > 1.9f) { - phi_s0_3 = 1; - magma2DrawMode = 0; - sp90 = 0; - } else if (this->unk_224 > 1.7f) { - phi_s0_3 = 3; - sp90 = 1; - if (globalCtx) {} - magma2DrawMode = 0; - } else if (this->unk_224 > 1.4f) { - phi_s0_3 = 7; - sp90 = 3; - magma2DrawMode = Rand_ZeroOne() * 1.9f; - } else if (this->unk_224 > 1.1f) { - phi_s0_3 = 7; - sp90 = 4095; - magma2DrawMode = Rand_ZeroOne() * 1.9f; - } else { - phi_s0_3 = 1; - sp90 = -1; - magma2DrawMode = 1; - magmaScale = ((s16)(Rand_ZeroOne() * 50)) - 50; - } - - if (player2->csMode >= 10) { - phi_s0_3 = -1; - } - - if ((this->unk_19E & phi_s0_3) == 0) { - static Color_RGBA8 magmaPrimColor[] = { { 255, 255, 0, 255 }, { 0, 0, 0, 150 } }; - static Color_RGBA8 magmaEnvColor[] = { { 255, 0, 0, 255 }, { 0, 0, 0, 0 } }; - Vec3f sp84; - f32 temp_f12; - f32 temp_f10; - - temp_f12 = Rand_ZeroOne() * 330.0f; - temp_f10 = Rand_ZeroOne() * 6.28f; - sp84.x = (sinf(temp_f10) * temp_f12) + (-890.0f); - sp84.y = -1523.76f; - sp84.z = (cosf(temp_f10) * temp_f12) + (-3304.0f); - EffectSsGMagma2_Spawn(globalCtx, &sp84, &magmaPrimColor[magma2DrawMode], &magmaEnvColor[magma2DrawMode], - 10 - (magma2DrawMode * 5), magma2DrawMode, magmaScale + 100); - } - - if ((this->unk_19E & sp90) == 0) { - Vec3f sp6C = { 0.0f, 0.0f, 0.0f }; - Vec3f sp60 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp54; - f32 sp50 = Rand_ZeroOne() * 330.0f; - f32 sp4C = Rand_ZeroOne() * 6.28f; - - sp54.x = sinf(sp4C) * sp50 + (-890.0f); - sp54.y = -1523.76f; - sp54.z = cosf(sp4C) * sp50 + (-3304.0f); - EffectSsGMagma_Spawn(globalCtx, &sp54); - for (i = 0; i < 4; i++) { - sp60.y = 0.4f; - sp60.x = Rand_CenteredFloat(0.5f); - sp60.z = Rand_CenteredFloat(0.5f); - sp50 = Rand_ZeroOne() * 330.0f; - sp4C = Rand_ZeroOne() * 6.28f; - sp54.x = sinf(sp4C) * sp50 + (-890.0f); - sp54.y = -1513.76f; - sp54.z = cosf(sp4C) * sp50 + (-3304.0f); - func_808C17C8(globalCtx, &sp54, &sp6C, &sp60, ((s16)Rand_ZeroFloat(2.0f)) + 6, 0x50); - } - } - - func_808C1554(gDodongosCavernBossLavaFloorTex, sLavaFloorLavaTex, this->unk_19E, this->unk_224); - } - - if (this->unk_1C6 != 0) { - u16* ptr1 = SEGMENTED_TO_VIRTUAL(sLavaFloorLavaTex); - u16* ptr2 = SEGMENTED_TO_VIRTUAL(sLavaFloorRockTex); - s16 i2; - - for (i2 = 0; i2 < 20; i2++) { - s16 new_var = this->unk_1C2 & 0x7FF; - - ptr1[new_var] = ptr2[new_var]; - this->unk_1C2 += 37; - } - Math_SmoothStepToF(&this->unk_224, 0.0f, 1.0f, 0.01f, 0.0f); - } - - if (this->unk_1BC == 0) { - if (this->actionFunc != BossDodongo_DeathCutscene) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->actionFunc == BossDodongo_Roll) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - this->collider.elements[0].dim.scale = (this->actionFunc == BossDodongo_Inhale) ? 0.0f : 1.0f; - - for (i = 6; i < 19; i++) { - if (i != 12) { - this->collider.elements[i].dim.scale = (this->actionFunc == BossDodongo_Roll) ? 0.0f : 1.0f; - } - } - - if (this->unk_244 != 0) { - MREG(64) = 1; - MREG(65) = 255; - MREG(66) = 80; - MREG(67) = 0; - MREG(68) = (u8)this->unk_244; - } else { - MREG(64) = 0; - } - - Math_SmoothStepToF(&this->unk_244, 0.0f, 1.0f, 2.0f, 0.0f); - BossDodongo_UpdateEffects(globalCtx); -} - -s32 BossDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - f32 mtxScaleY; - f32 mtxScaleZ; - BossDodongo* this = (BossDodongo*)thisx; - - // required for matching - if ((limbIndex == 6) || (limbIndex == 7)) { - if (this->unk_25C) {} - goto block_1; - } -block_1: - Matrix_TranslateRotateZYX(pos, rot); - - if (*dList != NULL) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3787); - - mtxScaleZ = 1.0f; - mtxScaleY = 1.0f; - - if ((limbIndex == 33) || (limbIndex == 48)) { - mtxScaleY = mtxScaleZ = this->unk_1F8; - } - - Matrix_Push(); - Matrix_Scale(1.0f, mtxScaleY, mtxScaleZ, MTXMODE_APPLY); - - if ((limbIndex != 6) && (limbIndex != 7)) { - Matrix_RotateX(this->unk_25C[limbIndex] * 0.115f, MTXMODE_APPLY); - Matrix_RotateY(this->unk_25C[limbIndex] * 0.13f, MTXMODE_APPLY); - Matrix_RotateZ(this->unk_25C[limbIndex] * 0.1f, MTXMODE_APPLY); - Matrix_Scale(1.0f - this->unk_208, this->unk_208 + 1.0f, 1.0f - this->unk_208, MTXMODE_APPLY); - Matrix_RotateZ(-(this->unk_25C[limbIndex] * 0.1f), MTXMODE_APPLY); - Matrix_RotateY(-(this->unk_25C[limbIndex] * 0.13f), MTXMODE_APPLY); - Matrix_RotateX(-(this->unk_25C[limbIndex] * 0.115f), MTXMODE_APPLY); - } - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3822), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3826); - } - { s32 pad; } // Required to match - return 1; -} - -void BossDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_808CA450 = { 5000.0f, -2500.0f, 0.0f }; - static Vec3f D_808CA45C = { 0.0f, 0.0f, 0.0f }; - static Vec3f D_808CA468 = { 11500.0f, -3000.0f, 0.0f }; - static Vec3f D_808CA474 = { 5000.0f, -2000.0f, 0.0f }; - static Vec3f D_808CA480 = { 8000.0f, 0.0f, 0.0f }; - static Vec3f D_808CA48C = { 8000.0f, 0.0f, 0.0f }; - BossDodongo* this = (BossDodongo*)thisx; - - if (limbIndex == 6) { - Matrix_MultVec3f(&D_808CA45C, &this->vec); - Matrix_MultVec3f(&D_808CA450, &this->actor.focus.pos); - Matrix_MultVec3f(&D_808CA468, &this->firePos); - Matrix_MultVec3f(&D_808CA474, &this->mouthPos); - } else if (limbIndex == 39) { - Matrix_MultVec3f(&D_808CA480, &this->unk_410); - } else if (limbIndex == 46) { - Matrix_MultVec3f(&D_808CA48C, &this->unk_404); - } - Collider_UpdateSpheres(limbIndex, &this->collider); -} - -void BossDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { - BossDodongo* this = (BossDodongo*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3922); - func_80093D18(globalCtx->state.gfxCtx); - - if ((this->unk_1C0 >= 2) && (this->unk_1C0 & 1)) { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 255, 255, 0, 900, 1099); - } else { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, (u32)this->colorFilterR, (u32)this->colorFilterG, - (u32)this->colorFilterB, 0, this->colorFilterMin, this->colorFilterMax); - } - - Matrix_RotateZ(this->unk_23C, MTXMODE_APPLY); - Matrix_RotateX((this->unk_1C4 / 32768.0f) * 3.14159f, MTXMODE_APPLY); - - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, BossDodongo_OverrideLimbDraw, - BossDodongo_PostLimbDraw, this); - - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3981); - - BossDodongo_DrawEffects(globalCtx); -} - -f32 func_808C4F6C(BossDodongo* this, GlobalContext* globalCtx) { - f32 xDiff; - f32 zDiff; - f32 sp2C; - s32 pad; - f32 temp_f2; - f32 rotation; - Player* player = GET_PLAYER(globalCtx); - - xDiff = player->actor.world.pos.x - this->actor.world.pos.x; - zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - - rotation = Math_CosS(-this->actor.world.rot.y); - sp2C = (Math_SinS(-this->actor.world.rot.y) * zDiff) + (rotation * xDiff); - rotation = Math_SinS(-this->actor.world.rot.y); - temp_f2 = (Math_CosS(-this->actor.world.rot.y) * zDiff) + (-rotation * xDiff); - - if ((fabsf(sp2C) < 150.0f) && (temp_f2 >= 100.0f) && (temp_f2 <= 2000.0f)) { - return temp_f2; - } - return -1.0f; -} - -f32 func_808C50A8(BossDodongo* this, GlobalContext* globalCtx) { - f32 xDiff; - f32 zDiff; - f32 sp2C; - s32 pad; - f32 temp_f2; - f32 rotation; - Player* player = GET_PLAYER(globalCtx); - - xDiff = player->actor.world.pos.x - this->actor.world.pos.x; - zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - - rotation = Math_CosS(-0x8000 - this->actor.world.rot.y); - sp2C = (Math_SinS(-0x8000 - this->actor.world.rot.y) * zDiff) + (rotation * xDiff); - rotation = Math_SinS(-0x8000 - this->actor.world.rot.y); - temp_f2 = (Math_CosS(-0x8000 - this->actor.world.rot.y) * zDiff) + (-rotation * xDiff); - - if ((fabsf(sp2C) < 150.0f) && (100.0f <= temp_f2) && (temp_f2 <= 2000.0f)) { - return temp_f2; - } - - return -1.0f; -} - -void BossDodongo_PlayerYawCheck(BossDodongo* this, GlobalContext* globalCtx) { - s16 yawDiff = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; - - if ((yawDiff < 0x38E3) && (-0x38E3 < yawDiff)) { - this->playerYawInRange = true; - } else { - this->playerYawInRange = false; - } -} - -void BossDodongo_PlayerPosCheck(BossDodongo* this, GlobalContext* globalCtx) { - Vec3f* temp_v1; - s16 i; - - this->playerPosInRange = false; - - for (i = 0; i < 4; i++) { - temp_v1 = &sCornerPositions[i]; - - if ((fabsf(this->actor.world.pos.x - temp_v1->x) < 200.0f) && - (fabsf(this->actor.world.pos.z - temp_v1->z) < 200.0f)) { - this->playerPosInRange = true; - break; - } - } -} - -void BossDodongo_SpawnFire(BossDodongo* this, GlobalContext* globalCtx, s16 params) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BDFIRE, this->vec.x, this->vec.y - 20.0f, - this->vec.z, 0, this->actor.shape.rot.y, 0, params); -} - -void BossDodongo_UpdateDamage(BossDodongo* this, GlobalContext* globalCtx) { - s32 pad; - ColliderInfo* item1; - u8 swordDamage; - s32 damage; - ColliderInfo* item2; - s16 i; - - if ((this->health <= 0) && (this->actionFunc != BossDodongo_DeathCutscene)) { - BossDodongo_SetupDeathCutscene(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - return; - } - - if (this->unk_1C0 == 0) { - if (this->actionFunc == BossDodongo_Inhale) { - for (i = 0; i < 19; i++) { - if (this->collider.elements[i].info.bumperFlags & 2) { - item1 = this->collider.elements[i].info.acHitInfo; - item2 = item1; - - if ((item2->toucher.dmgFlags & 0x10) || (item2->toucher.dmgFlags & 4)) { - this->collider.elements[i].info.bumperFlags &= ~2; - this->unk_1C0 = 2; - BossDodongo_SetupWalk(this); - this->unk_1DA = 0x32; - return; - } - } - } - } - - if (this->collider.elements->info.bumperFlags & 2) { - this->collider.elements->info.bumperFlags &= ~2; - item1 = this->collider.elements[0].info.acHitInfo; - if ((this->actionFunc == BossDodongo_Vulnerable) || (this->actionFunc == BossDodongo_LayDown)) { - swordDamage = damage = CollisionCheck_GetSwordDamage(item1->toucher.dmgFlags); - - if (damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_DAMAGE); - BossDodongo_SetupDamaged(this); - this->unk_1C0 = 5; - this->health -= swordDamage; - } - } - } - } -} - -void BossDodongo_SetupDeathCutscene(BossDodongo* this) { - this->actor.speedXZ = 0.0f; - this->unk_1E4 = 0.0f; - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_002D0C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_002D0C), ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossDodongo_DeathCutscene; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_DEAD); - this->unk_1DA = 0; - this->csState = 0; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->unk_1BC = 1; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); -} - -void BossDodongo_DeathCutscene(BossDodongo* this, GlobalContext* globalCtx) { - Vec3f* cornerPos; - Vec3f sp198; - Vec3f sp184; - f32 tempSin; - f32 tempCos; - f32 sp178; - s16 i; - Vec3f effectPos; - Camera* camera; - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - - switch (this->csState) { - case 0: - this->csState = 5; - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 1); - this->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_UNK3); - Gameplay_ChangeCameraStatus(globalCtx, this->cutsceneCamera, CAM_STAT_ACTIVE); - camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); - this->cameraEye.x = camera->eye.x; - this->cameraEye.y = camera->eye.y; - this->cameraEye.z = camera->eye.z; - this->cameraAt.x = camera->at.x; - this->cameraAt.y = camera->at.y; - this->cameraAt.z = camera->at.z; - break; - case 5: - tempSin = Math_SinS(this->actor.shape.rot.y - 0x1388) * 150.0f; - tempCos = Math_CosS(this->actor.shape.rot.y - 0x1388) * 150.0f; - Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x + tempSin, 0.5f, 5.0f, 0.0f); - Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z + tempCos, 0.5f, 5.0f, 0.0f); - Math_SmoothStepToF(&this->unk_208, 0.07f, 1.0f, 0.005f, 0.0f); - tempSin = Math_SinS(this->actor.world.rot.y) * 230.0f; - tempCos = Math_CosS(this->actor.world.rot.y) * 230.0f; - Math_SmoothStepToF(&this->cameraEye.x, this->actor.world.pos.x + tempSin, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->cameraEye.y, this->actor.world.pos.y + 20.0f, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->cameraEye.z, this->actor.world.pos.z + tempCos, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->cameraAt.x, this->actor.world.pos.x, 0.2f, 30.0f, 0.1f); - Math_SmoothStepToF(&this->cameraAt.y, this->actor.focus.pos.y - 70.0f, 0.2f, 30.0f, 0.1f); - Math_SmoothStepToF(&this->cameraAt.z, this->actor.world.pos.z, 0.2f, 30.0f, 0.1f); - if (Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_002D0C))) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_003CF8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_kingdodongo_Anim_003CF8), ANIMMODE_ONCE, -1.0f); - this->csState = 6; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_BREAKWALL, -890.0f, -1523.76f, -3304.0f, 0, 0, 0, - 0x6000); - } - break; - case 6: - Math_SmoothStepToF(&this->cameraAt.x, this->actor.world.pos.x, 0.2f, 30.0f, 0.1f); - Math_SmoothStepToF(&this->cameraAt.y, (this->actor.world.pos.y - 70.0f) + 130.0f, 0.2f, 20.0f, 0.1f); - Math_SmoothStepToF(&this->cameraAt.z, this->actor.world.pos.z, 0.2f, 30.0f, 0.1f); - - if (Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_003CF8))) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_00DF38, 1.0f, 30.0f, 59.0f, ANIMMODE_ONCE, - -1.0f); - this->csState = 7; - this->unk_228 = 7700.0f; - this->unk_204 = 0.0f; - this->unk_1E4 = 0.0f; - this->numWallCollisions = 0; - this->unk_19E = 0; - } - break; - case 7: - this->unk_1C4 += 0x7D0; - Math_SmoothStepToF(&this->cameraAt.x, this->actor.world.pos.x, 0.2f, 30.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.y, (this->actor.world.pos.y - 70.0f) + 130.0f, 0.2f, 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.z, this->actor.world.pos.z, 0.2f, 30.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.x, -890.0f, 0.1f, this->unk_204 * 5.0f, 0.1f); - Math_SmoothStepToF(&this->cameraEye.z, -3304.0f, 0.1f, this->unk_204 * 5.0f, 0.1f); - Math_SmoothStepToF(&this->unk_204, 1.0f, 1.0f, 0.1f, 0.0f); - if (this->unk_1DA == 1) { - this->csState = 8; - this->actor.speedXZ = this->unk_1E4 / 1.5f; - if (this->unk_1A2 == 0) { - this->unk_238 = 250.0f; - } else { - this->unk_238 = -250.0f; - } - this->unk_1DA = 1000; - this->unk_234 = 2000.0f; - } else { - cornerPos = &sCornerPositions[this->unk_1A0]; - this->unk_1EC = 3.0f; - Math_SmoothStepToF(&this->unk_1E4, this->unk_1EC * 5.0f, 1.0f, this->unk_1EC * 0.25f, 0.0f); - tempSin = cornerPos->x - this->actor.world.pos.x; - tempCos = cornerPos->z - this->actor.world.pos.z; - sp178 = sqrtf(SQ(tempSin) + SQ(tempCos)) - 200.0f; - if ((sqrtf(SQ(tempSin) + SQ(tempCos)) < 200.0f) || (this->unk_1DA != 0)) { - sp178 = 0.0f; - } - sp178 = CLAMP_MAX(sp178, 70.0f); - this->unk_23C = (Math_SinS(this->unk_19E * 1000) * -50.0f) / 100.0f; - - sp198.x = Math_SinS(this->unk_19E * 1000) * sp178; - sp198.y = sp198.z = 0.0f; - - Matrix_RotateY(this->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_NEW); - Matrix_MultVec3f(&sp198, &sp184); - - Math_SmoothStepToF(&this->actor.world.pos.x, cornerPos->x + sp184.x, 1.0f, this->unk_1E4, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, cornerPos->z + sp184.z, 1.0f, this->unk_1E4, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); - if ((this->unk_19E & 7) == 0) { - Camera_AddQuake(&globalCtx->mainCamera, 2, 1, 8); - } - if (!(this->unk_19E & 1)) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 40.0f, 3, 8.0f, 0x1F4, - 0xA, 0); - } - tempSin = cornerPos->x - this->actor.world.pos.x; - tempCos = cornerPos->z - this->actor.world.pos.z; - Math_SmoothStepToF(&this->unk_1E8, 1500.0f, 1.0f, this->unk_1EC * 100.0f, 0.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, (Math_FAtan2F(tempSin, tempCos) * (0x8000 / M_PI)), 5, - (this->unk_1EC * this->unk_1E8), 0); - - if ((fabsf(tempSin) <= 15.0f) && (fabsf(tempCos) <= 15.0f)) { - Vec3f dustPos; - - this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_COLI2); - if (this->unk_1A2 == 0) { - this->unk_1A0 = this->unk_1A0 + 1; - if (this->unk_1A0 >= 4) { - this->unk_1A0 = 0; - } - } else { - this->unk_1A0--; - if (this->unk_1A0 < 0) { - this->unk_1A0 = 3; - } - } - this->unk_1DA = 0xA; - dustPos.x = this->actor.world.pos.x; - dustPos.y = this->actor.world.pos.y + 60.0f; - dustPos.z = this->actor.world.pos.z; - func_80033480(globalCtx, &dustPos, 250.0f, 0x28, 0x320, 0xA, 0); - } - } - break; - case 8: - case 9: - if (this->unk_1DA == 884) { - Animation_Change(&this->skelAnime, &object_kingdodongo_Anim_0042A8, 1.0f, 0.0f, - (f32)Animation_GetLastFrame(&object_kingdodongo_Anim_0042A8), ANIMMODE_LOOP, -20.0f); - tempSin = this->cameraEye.x - this->actor.world.pos.x; - tempCos = this->cameraEye.z - this->actor.world.pos.z; - this->unk_22C = sqrtf(SQ(tempSin) + SQ(tempCos)); - this->unk_230 = Math_FAtan2F(tempSin, tempCos); - this->unk_1DC = 350; - this->csState = 9; - } - if (this->unk_1DA < 854) { - for (i = 0; i < 2; i++) { - func_808C12C4(D_808C7000, this->unk_1CC); - if (this->unk_1CC < 256) { - this->unk_1CC++; - } - } - } - if (this->unk_1DA < 984) { - Math_SmoothStepToS(&this->unk_1C4, -0x4000, 0xA, 0x12C, 0); - } - if (this->unk_1DA == 904) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_END); - } - if (this->unk_1DA < 854) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_LAST - SFX_FLAG); - } - if (this->unk_1DA == 960) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_LAVA); - } - if (this->unk_1DA < 960) { - Math_SmoothStepToF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 10.0f, 0.0f); - if (this->unk_1DA >= 710) { - - if (this->unk_1DA == 710) { - Vec3f sp124[] = { - { -440.0f, 0.0f, -3304.0f }, - { -890.0f, 0.0f, -3754.0f }, - { -1340.0f, 0.0f, -3304.0f }, - { -890.0f, 0.0f, -2854.0f }, - }; - Vec3f spF4[] = { - { -890.0f, 0.0f, -2854.0f }, - { -440.0f, 0.0f, -3304.0f }, - { -890.0f, 0.0f, -3754.0f }, - { -1340.0f, 0.0f, -3304.0f }, - }; - Vec3f* phi_v0_2; - - this->unk_1C6 = 1; - if (this->unk_1A2 == 0) { - phi_v0_2 = &sp124[this->unk_1A0]; - } else { - phi_v0_2 = &spF4[this->unk_1A0]; - } - player->actor.world.pos.x = phi_v0_2->x; - player->actor.world.pos.z = phi_v0_2->z; - this->unk_204 = 0.0f; - } - if (this->unk_1DA >= 885) { - Math_SmoothStepToF(&this->unk_228, 200.0, 0.2f, 100.0f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_228, -6600.0f, 0.2f, 30.0f, 0.0f); - } - { - static Vec3f dustVel = { 0.0f, 0.0f, 0.0f }; - static Vec3f dustAcell = { 0.0f, 1.0f, 0.0f }; - static Color_RGBA8 dustPrimColor = { 255, 255, 100, 255 }; - static Color_RGBA8 dustEnvColor = { 255, 100, 0, 255 }; - s16 colorIndex; - Color_RGBA8 magmaPrimColor2[] = { { 255, 255, 0, 255 }, { 0, 0, 0, 100 } }; - Color_RGBA8 magmaEnvColor2[] = { { 255, 0, 0, 255 }, { 0, 0, 0, 0 } }; - - effectPos.x = Rand_CenteredFloat(120.0f) + this->actor.focus.pos.x; - effectPos.y = Rand_ZeroFloat(50.0f) + this->actor.world.pos.y; - effectPos.z = Rand_CenteredFloat(120.0f) + this->actor.focus.pos.z; - func_8002836C(globalCtx, &effectPos, &dustVel, &dustAcell, &dustPrimColor, &dustEnvColor, 0x1F4, - 0xA, 0xA); - effectPos.x = Rand_CenteredFloat(120.0f) + this->actor.focus.pos.x; - effectPos.y = -1498.76f; - effectPos.z = Rand_CenteredFloat(120.0f) + this->actor.focus.pos.z; - colorIndex = (Rand_ZeroOne() * 1.9f); - EffectSsGMagma2_Spawn(globalCtx, &effectPos, &magmaPrimColor2[colorIndex], - &magmaEnvColor2[colorIndex], 10 - (colorIndex * 5), colorIndex, - (s16)(Rand_ZeroOne() * 100.0f) + 100); - } - } - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); - if (!(this->unk_19E & 1)) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 40.0f, 3, 8.0f, 0x1F4, - 0xA, 0); - } - } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.2f, 0.1f, 0.0f); - this->actor.world.rot.y += (s16)this->unk_238; - this->unk_1C4 += (s16)this->unk_234; - if (this->unk_1DA >= 0x367) { - if (this->unk_1A2 == 0) { - if (this->unk_238 < 450.0f) { - this->unk_238 += 10.0f; - } - } else if (-450.0f < this->unk_238) { - this->unk_238 -= 10.0f; - } - } else { - Math_SmoothStepToF(&this->unk_238, 0.0f, 0.05f, 40.0f, 0.0f); - } - Math_SmoothStepToF(&this->unk_234, 0.0f, 0.2f, 17.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.x, this->actor.world.pos.x, 0.2f, 30.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.y, (this->actor.world.pos.y - 70.0f) + 130.0f, 0.2f, 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraAt.z, this->actor.world.pos.z, 0.2f, 30.0f, 0.0f); - if (this->csState == 9) { - if (this->unk_1DA < 0x2C6) { - Vec3f spAC[] = { { -390.0f, 0.0f, -3304.0f }, - { -890.0f, 0.0f, -3804.0f }, - { -1390.0f, 0.0f, -3304.0f }, - { -890.0f, 0.0f, -2804.0f } }; - - Vec3f sp7C[] = { { -890.0f, 0.0f, -2804.0f }, - { -390.0f, 0.0f, -3304.0f }, - { -890.0f, 0.0f, -3804.0f }, - { -1390.0f, 0.0f, -3304.0f } }; - Vec3f* sp78; - s32 pad74; - - if (this->unk_1A2 == 0) { - sp78 = &spAC[this->unk_1A0]; - } else { - sp78 = &sp7C[this->unk_1A0]; - } - - Math_SmoothStepToF(&this->cameraEye.x, sp78->x, 0.2f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.y, player->actor.world.pos.y + 30.0f, 0.1f, - this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.z, sp78->z, 0.1f, this->unk_204 * 20.0f, 0.0f); - Math_SmoothStepToF(&this->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); - } else { - if (this->unk_1A2 == 0) { - this->unk_230 += 0.01f; - } else { - this->unk_230 -= 0.01f; - } - Math_SmoothStepToF(&this->unk_22C, 220.0f, 0.1f, 5.0f, 0.1f); - tempSin = sinf(this->unk_230) * (*this).unk_22C; - tempCos = cosf(this->unk_230) * (*this).unk_22C; - Math_SmoothStepToF(&this->cameraEye.x, this->actor.world.pos.x + tempSin, 0.2f, 50.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.y, this->actor.world.pos.y + 20.0f, 0.2f, 50.0f, 0.0f); - Math_SmoothStepToF(&this->cameraEye.z, this->actor.world.pos.z + tempCos, 0.2f, 50.0f, 0.0f); - Math_SmoothStepToF(&this->unk_23C, 0.0f, 0.2f, 0.01f, 0.0f); - } - } else { - - if (this->unk_1A2 == 0) { - Math_SmoothStepToF(&this->unk_23C, -0.5f, 0.2f, 0.05f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_23C, 0.5f, 0.2f, 0.05f, 0.0f); - } - - Math_SmoothStepToF(&this->cameraEye.x, -890.0f, 0.1f, this->unk_204 * 5.0f, 0.1f); - Math_SmoothStepToF(&this->cameraEye.z, -3304.0f, 0.1f, this->unk_204 * 5.0f, 0.1f); - Math_SmoothStepToF(&this->unk_204, 1.0f, 1.0f, 0.05f, 0.0f); - } - - if (this->unk_1DA == 820) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, - Math_SinS(this->actor.shape.rot.y) * -50.0f + this->actor.world.pos.x, - this->actor.world.pos.y, - Math_CosS(this->actor.shape.rot.y) * -50.0f + this->actor.world.pos.z, 0, 0, 0, 0); - } - if (this->unk_1DA == 600) { - camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); - camera->eye = this->cameraEye; - camera->eyeNext = this->cameraEye; - camera->at = this->cameraAt; - func_800C08AC(globalCtx, this->cutsceneCamera, 0); - this->unk_1BC = 0; - this->cutsceneCamera = MAIN_CAM; - this->csState = 100; - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, -890.0f, -1523.76f, - -3304.0f, 0, 0, 0, WARP_DUNGEON_CHILD); - this->skelAnime.playSpeed = 0.0f; - Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); - } - case 100: - if ((this->unk_1DA < 0x2C6) && (Rand_ZeroOne() < 0.5f)) { - Vec3f sp68; - Color_RGBA8 D_808CA568 = { 0, 0, 0, 100 }; - Color_RGBA8 D_808CA56C = { 0, 0, 0, 0 }; - - sp68.x = Rand_CenteredFloat(60.0f) + this->actor.focus.pos.x; - sp68.y = (Rand_ZeroOne() * 50.0f) + -1498.76f; - sp68.z = Rand_CenteredFloat(60.0f) + this->actor.focus.pos.z; - EffectSsGMagma2_Spawn(globalCtx, &sp68, &D_808CA568, &D_808CA56C, 5, 1, - (s16)(Rand_ZeroOne() * 50.0f) + 50); - } - break; - } - if (this->cutsceneCamera != MAIN_CAM) { - Gameplay_CameraSetAtEye(globalCtx, this->cutsceneCamera, &this->cameraAt, &this->cameraEye); - } -} - -void BossDodongo_UpdateEffects(GlobalContext* globalCtx) { - BossDodongoEffect* eff = (BossDodongoEffect*)globalCtx->specialEffects; - Color_RGB8 effectColors[] = { { 255, 128, 0 }, { 255, 0, 0 }, { 255, 255, 0 }, { 255, 0, 0 } }; - s16 colorIndex; - s16 i; - - for (i = 0; i < 80; i++, eff++) { - if (eff->unk_24 != 0) { - eff->unk_00.x += eff->unk_0C.x; - eff->unk_00.y += eff->unk_0C.y; - eff->unk_00.z += eff->unk_0C.z; - eff->unk_25++; - eff->unk_0C.x += eff->unk_18.x; - eff->unk_0C.y += eff->unk_18.y; - eff->unk_0C.z += eff->unk_18.z; - if (eff->unk_24 == 1) { - colorIndex = eff->unk_25 % 4; - eff->color.r = effectColors[colorIndex].r; - eff->color.g = effectColors[colorIndex].g; - eff->color.b = effectColors[colorIndex].b; - eff->alpha -= 20; - if (eff->alpha <= 0) { - eff->alpha = 0; - eff->unk_24 = 0; - } - } - } - } -} - -void BossDodongo_DrawEffects(GlobalContext* globalCtx) { - MtxF* unkMtx; - s16 i; - u8 phi_s3 = 0; - BossDodongoEffect* eff; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - eff = (BossDodongoEffect*)globalCtx->specialEffects; - - OPEN_DISPS(gfxCtx, "../z_boss_dodongo.c", 5228); - - func_80093D84(globalCtx->state.gfxCtx); - unkMtx = &globalCtx->billboardMtxF; - - for (i = 0; i < 80; i++, eff++) { - if (eff->unk_24 == 1) { - gDPPipeSync(POLY_XLU_DISP++); - - if (phi_s3 == 0) { - gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_009D50); - phi_s3++; - } - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, eff->alpha); - Matrix_Translate(eff->unk_00.x, eff->unk_00.y, eff->unk_00.z, MTXMODE_NEW); - func_800D1FD4(unkMtx); - Matrix_Scale(eff->unk_2C, eff->unk_2C, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_dodongo.c", 5253), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_009DD0); - } - } - - CLOSE_DISPS(gfxCtx, "../z_boss_dodongo.c", 5258); -} diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.cpp b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.cpp new file mode 100644 index 000000000..b8a3f791d --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.cpp @@ -0,0 +1,1725 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_DODONGO_Z_BOSS_DODONGO_C +#include "actor_common.h" +#include "z_boss_dodongo.h" +#include "objects/object_kingdodongo/object_kingdodongo.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "scenes/dungeons/ddan_boss/ddan_boss_room_1.h" +#include "def/code_800A9F30.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BossDodongo_Init(Actor* thisx, GlobalContext* globalCtx); +void BossDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossDodongo_Update(Actor* thisx, GlobalContext* globalCtx); +void BossDodongo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BossDodongo_SetupIntroCutscene(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_IntroCutscene(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_Walk(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_Inhale(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_BlowFire(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_Roll(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_SpawnFire(BossDodongo* pthis, GlobalContext* globalCtx, s16 arg2); +void BossDodongo_Explode(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_LayDown(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_Vulnerable(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_GetUp(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_SetupWalk(BossDodongo* pthis); +void BossDodongo_DeathCutscene(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_SetupDeathCutscene(BossDodongo* pthis); +void BossDodongo_Damaged(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_UpdateDamage(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_PlayerPosCheck(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_PlayerYawCheck(BossDodongo* pthis, GlobalContext* globalCtx); +f32 func_808C4F6C(BossDodongo* pthis, GlobalContext* globalCtx); +f32 func_808C50A8(BossDodongo* pthis, GlobalContext* globalCtx); +void BossDodongo_DrawEffects(GlobalContext* globalCtx); +void BossDodongo_UpdateEffects(GlobalContext* globalCtx); + +ActorInit Boss_Dodongo_InitVars = { + ACTOR_EN_DODONGO, + ACTORCAT_BOSS, + FLAGS, + OBJECT_KINGDODONGO, + sizeof(BossDodongo), + (ActorFunc)BossDodongo_Init, + (ActorFunc)BossDodongo_Destroy, + (ActorFunc)BossDodongo_Update, + (ActorFunc)BossDodongo_Draw, +}; + +#include "z_boss_dodongo_data.cpp" + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x0C, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -3000.0f, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 8200.0f, ICHAIN_STOP), +}; + +void func_808C1190(s16* arg0, u8* arg1, s16 arg2) { + if (arg2[arg1] != 0) { + arg0[arg2 / 2] = 0; + } +} + +void func_808C11D0(s16* arg0, u8* arg1, s16 arg2) { + if (arg1[arg2] != 0) { + arg0[arg2] = 0; + } +} + +void func_808C1200(s16* arg0, u8* arg1, s16 arg2) { + if (arg1[arg2] != 0) { + arg0[arg2] = 0; + } +} + +void func_808C1230(s16* arg0, u8* arg1, s16 arg2) { + s16 index; + + if (arg1[arg2] != 0) { + index = ((arg2 & 0xF) + ((arg2 & 0xF0) * 2)); + arg0[index + 16] = 0; + arg0[index] = 0; + } +} + +void func_808C1278(s16* arg0, u8* arg1, s16 arg2) { + s16 index; + + if (arg1[arg2] != 0) { + index = ((arg2 & 0xF) * 2) + ((arg2 & 0xF0) * 2); + arg0[index + 1] = 0; + arg0[index] = 0; + } +} + +void func_808C12C4(u8* arg1, s16 arg2) { + func_808C1190((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015890), arg1, arg2); + func_808C1200((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_017210), arg1, arg2); + func_808C11D0((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015D90), arg1, arg2); + func_808C11D0((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016390), arg1, arg2); + func_808C11D0((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016590), arg1, arg2); + func_808C11D0((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016790), arg1, arg2); + func_808C1230((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015990), arg1, arg2); + func_808C1230((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_015F90), arg1, arg2); + func_808C1278((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016990), arg1, arg2); + func_808C1278((s16*)SEGMENTED_TO_VIRTUAL(object_kingdodongo_Tex_016E10), arg1, arg2); +} + +void func_808C1554(void* arg0, void* floorTex, s32 arg2, f32 arg3) { + u16* temp_s3 = (u16*)SEGMENTED_TO_VIRTUAL(arg0); + u16* temp_s1 = (u16*)SEGMENTED_TO_VIRTUAL(floorTex); + s16 i; + s16 i2; + u16 sp54[2048]; + s16 temp; + s16 temp2; + + for (i = 0; i < 2048; i += 32) { + temp = sinf((((i / 32) + (s16)((arg2 * 50.0f) / 100.0f)) & 0x1F) * (M_PI / 16)) * arg3; + for (i2 = 0; i2 < 32; i2++) { + sp54[i + ((temp + i2) & 0x1F)] = temp_s1[i + i2]; + } + } + for (i = 0; i < 32; i++) { + temp = sinf(((i + (s16)((arg2 * 80.0f) / 100.0f)) & 0x1F) * (M_PI / 16)) * arg3; + temp *= 32; + for (i2 = 0; i2 < 2048; i2 += 32) { + temp2 = (temp + i2) & 0x7FF; + temp_s3[i + temp2] = sp54[i + i2]; + } + } +} + +void func_808C17C8(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5) { + s16 i; + BossDodongoEffect* eff = (BossDodongoEffect*)globalCtx->specialEffects; + + for (i = 0; i < arg5; i++, eff++) { + if (eff->unk_24 == 0) { + eff->unk_24 = 1; + eff->unk_00 = *arg1; + eff->unk_0C = *arg2; + eff->unk_18 = *arg3; + eff->unk_2C = arg4 / 1000.0f; + eff->alpha = 255; + eff->unk_25 = (s16)Rand_ZeroFloat(10.0f); + break; + } + } +} + +s32 BossDodongo_AteExplosive(BossDodongo* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dy; + f32 dz; + Actor* currentExplosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; + Actor* thisx = &pthis->actor; + + while (currentExplosive != NULL) { + if (currentExplosive == thisx) { + currentExplosive = currentExplosive->next; + continue; + } + + dx = currentExplosive->world.pos.x - pthis->mouthPos.x; + dy = currentExplosive->world.pos.y - pthis->mouthPos.y; + dz = currentExplosive->world.pos.z - pthis->mouthPos.z; + + if ((fabsf(dx) < 40.0f) && (fabsf(dy) < 40.0f) && (fabsf(dz) < 40.0f)) { + Actor_Kill(currentExplosive); + return true; + } + + currentExplosive = currentExplosive->next; + } + + return false; +} + +void BossDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { + BossDodongo* pthis = (BossDodongo*)thisx; + s16 i; + u16* temp_s1_3; + u16* temp_s2; + u32 temp_v0; + + globalCtx->specialEffects = &pthis->effects; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 9200.0f, ActorShadow_DrawCircle, 250.0f); + Actor_SetScale(&pthis->actor, 0.01f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_kingdodongo_Skel_01B310, &object_kingdodongo_Anim_00F0D8, NULL, + NULL, 0); + Animation_PlayLoop(&pthis->skelAnime, &object_kingdodongo_Anim_00F0D8); + pthis->unk_1F8 = 1.0f; + BossDodongo_SetupIntroCutscene(pthis, globalCtx); + pthis->health = 12; + pthis->colorFilterMin = 995.0f; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->colorFilterMax = 1000.0f; + pthis->unk_224 = 2.0f; + pthis->unk_228 = 9200.0f; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->items); + + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { // KD is dead + temp_s1_3 = (u16*)SEGMENTED_TO_VIRTUAL(gDodongosCavernBossLavaFloorTex); + temp_s2 = (u16*)SEGMENTED_TO_VIRTUAL(sLavaFloorRockTex); + + Actor_Kill(&pthis->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, -890.0f, -1523.76f, + -3304.0f, 0, 0, 0, WARP_DUNGEON_CHILD); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_BREAKWALL, -890.0f, -1523.76f, -3304.0f, 0, 0, 0, 0x6000); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -690.0f, -1523.76f, -3304.0f, 0, 0, 0, 0); + + for (i = 0; i < 2048; i++) { + temp_v0 = i; + temp_s1_3[temp_v0] = temp_s2[temp_v0]; + } + } + + pthis->actor.flags &= ~ACTOR_FLAG_0; +} + +void BossDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BossDodongo* pthis = (BossDodongo*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void BossDodongo_SetupIntroCutscene(BossDodongo* pthis, GlobalContext* globalCtx) { + s16 frames = Animation_GetLastFrame(&object_kingdodongo_Anim_00F0D8); + + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_00F0D8, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = BossDodongo_IntroCutscene; + pthis->csState = 0; + pthis->unk_1BC = 1; +} + +void BossDodongo_IntroCutscene(BossDodongo* pthis, GlobalContext* globalCtx) { + f32 phi_f0; + Camera* camera; + Player* player; + Vec3f sp60; + Vec3f sp54; + Vec3f sp48; + + player = GET_PLAYER(globalCtx); + camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); + + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + + if (pthis->unk_19A != 0) { + pthis->unk_19A--; + } + + switch (pthis->csState) { + case 0: + if (player->actor.world.pos.y < -1223.76f) { + pthis->csState = 1; + pthis->actor.world.pos.x = -1390.0f; + pthis->actor.world.pos.z = -3374.0f; + pthis->unk_1A0 = 1; + } + break; + case 1: + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + Gameplay_ClearAllSubCameras(globalCtx); + pthis->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, 0, 1); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cutsceneCamera, 7); + pthis->csState = 2; + pthis->unk_196 = 0x3C; + pthis->unk_198 = 160; + player->actor.world.pos.y = -1023.76f; + pthis->cameraEye.y = player->actor.world.pos.y - 480.0f + 50.0f; + case 2: + if (pthis->unk_198 >= 131) { + player->actor.world.pos.x = -890.0f; + player->actor.world.pos.z = -2804.0f; + + player->actor.speedXZ = 0.0f; + player->actor.shape.rot.y = player->actor.world.rot.y = 0x3FFF; + + pthis->cameraEye.x = -890.0f; + pthis->cameraEye.z = player->actor.world.pos.z - 100.0f; + + pthis->cameraAt.x = player->actor.world.pos.x; + pthis->cameraAt.y = player->actor.world.pos.y + 20.0f; + pthis->cameraAt.z = player->actor.world.pos.z; + } + + if (pthis->unk_198 == 110) { + func_8002DF54(globalCtx, &pthis->actor, 9); + } + + if (pthis->unk_198 == 5) { + func_8002DF54(globalCtx, &pthis->actor, 12); + } + + if (pthis->unk_198 < 6) { + player->actor.shape.rot.y = -0x4001; + } else { + player->actor.shape.rot.y = 0x3FFF; + } + + if (pthis->unk_198 < 60) { + pthis->unk_1BC = 1; + } else { + pthis->unk_1BC = 2; + } + + BossDodongo_Walk(pthis, globalCtx); + + if (pthis->unk_196 == 1) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + } + + if (pthis->unk_196 == 0) { + Math_SmoothStepToF(&pthis->cameraEye.x, pthis->vec.x + 30.0f, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.y, pthis->vec.y, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.z, pthis->vec.z + 10.0f, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); + } else { + pthis->cameraAt.x = player->actor.world.pos.x; + pthis->cameraAt.y = player->actor.world.pos.y + 20.0f; + pthis->cameraAt.z = player->actor.world.pos.z; + } + + if (gSaveContext.eventChkInf[7] & 2) { + if (pthis->unk_198 == 100) { + pthis->actor.world.pos.x = -1114.0f; + pthis->actor.world.pos.z = -2804.0f; + pthis->actor.world.rot.y = 0x3FFF; + pthis->unk_1A2 = 0; + pthis->unk_1A0 = 2; + pthis->csState = 4; + pthis->unk_196 = 30; + pthis->unk_198 = 150; + pthis->unk_204 = 0.0f; + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_008EEC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_008EEC), ANIMMODE_ONCE, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + } + } else if (pthis->unk_198 == 0) { + pthis->csState = 3; + pthis->unk_19E = 0x14; + pthis->unk_204 = 0.0f; + } + break; + case 3: + BossDodongo_Walk(pthis, globalCtx); + Math_SmoothStepToF(&pthis->unk_20C, sinf(pthis->unk_19E * 0.05f) * 0.1f, 1.0f, 0.01f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.x, pthis->vec.x + 90.0f, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.y, pthis->vec.y + 50.0f, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.z, pthis->vec.z, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.y, pthis->vec.y - 10.0f, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); + if (fabsf(player->actor.world.pos.x - pthis->actor.world.pos.x) < 200.0f) { + pthis->csState = 4; + pthis->unk_196 = 0x1E; + pthis->unk_198 = 0x96; + pthis->unk_204 = 0.0f; + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_008EEC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_008EEC), ANIMMODE_ONCE, -5.0f); + } + break; + case 4: + Math_SmoothStepToF(&pthis->unk_20C, 0.0f, 1.0f, 0.01f, 0.0f); + + if (gSaveContext.eventChkInf[7] & 2) { + phi_f0 = -50.0f; + } else { + phi_f0 = 0.0f; + } + + Math_SmoothStepToF(&pthis->cameraEye.x, player->actor.world.pos.x + phi_f0 + 70.0f, 0.2f, + pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.y, player->actor.world.pos.y + 10.0f, 0.2f, pthis->unk_204 * 20.0f, + 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.z, player->actor.world.pos.z - 60.0f, 0.2f, pthis->unk_204 * 20.0f, + 0.0f); + + Math_SmoothStepToF(&pthis->cameraAt.x, pthis->vec.x, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.y, pthis->vec.y, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.z, pthis->vec.z, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); + + if (pthis->unk_196 == 0) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToF(&pthis->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); + } + + if (pthis->unk_198 == 0x64) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_OTAKEBI); + } + + if (pthis->unk_198 == 0x5A) { + if (!(gSaveContext.eventChkInf[7] & 2)) { + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(&object_kingdodongo_Blob_017410), 0xA0, 0xB4, 0x80, + 0x28); + } + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); + } + + if (pthis->unk_198 == 0) { + camera->eye = pthis->cameraEye; + camera->eyeNext = pthis->cameraEye; + camera->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->cutsceneCamera, 0); + pthis->cutsceneCamera = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + BossDodongo_SetupWalk(pthis); + pthis->unk_1DA = 50; + pthis->unk_1BC = 0; + player->actor.shape.rot.y = -0x4002; + gSaveContext.eventChkInf[7] |= 2; + } + break; + } + + if (pthis->cutsceneCamera != 0) { + if (pthis->unk_1B6 != 0) { + pthis->unk_1B6--; + } + + sp60.x = pthis->cameraEye.x; + phi_f0 = sinf((pthis->unk_1B6 * 3.1415f * 90.0f) / 180.0f); + sp60.y = (pthis->unk_1B6 * phi_f0 * 0.7f) + pthis->cameraEye.y; + sp60.z = pthis->cameraEye.z; + + sp54.x = pthis->cameraAt.x; + phi_f0 = sinf((pthis->unk_1B6 * 3.1415f * 90.0f) / 180.0f); + sp54.y = (pthis->unk_1B6 * phi_f0 * 0.7f) + pthis->cameraAt.y; + sp54.z = pthis->cameraAt.z; + + sp48.x = pthis->unk_20C; + sp48.y = 1.0f; + sp48.z = pthis->unk_20C; + + Gameplay_CameraSetAtEyeUp(globalCtx, pthis->cutsceneCamera, &sp54, &sp60, &sp48); + } +} + +void BossDodongo_SetupDamaged(BossDodongo* pthis) { + if (pthis->actionFunc != BossDodongo_Damaged) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_001074, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_001074), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_Damaged; + } + + pthis->unk_1DA = 100; +} + +void BossDodongo_SetupExplode(BossDodongo* pthis) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_00E848, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_00E848), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_Explode; + pthis->unk_1B0 = 10; + pthis->unk_1C0 = 2; + pthis->unk_1DA = 35; + pthis->unk_1FC = 50.0f; + pthis->unk_200 = 300.0f; +} + +void BossDodongo_SetupWalk(BossDodongo* pthis) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_01D934, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_01D934), ANIMMODE_ONCE, -10.0f); + pthis->unk_1AA = 0; + pthis->actionFunc = BossDodongo_Walk; + pthis->unk_1DA = 0; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->unk_1E4 = 0.0f; +} + +void BossDodongo_SetupRoll(BossDodongo* pthis) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_00DF38, 1.0f, 0.0f, 59.0f, ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_Roll; + pthis->numWallCollisions = 0; + pthis->unk_1DA = 27; +} + +void BossDodongo_SetupBlowFire(BossDodongo* pthis) { + pthis->actor.speedXZ = 0.0f; + pthis->unk_1E4 = 0.0f; + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_0061D4, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_0061D4), ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = BossDodongo_BlowFire; + pthis->unk_1DA = 50; + pthis->unk_1AE = 0; +} + +void BossDodongo_SetupInhale(BossDodongo* pthis) { + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_008EEC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_008EEC), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_Inhale; + pthis->unk_1DA = 100; + pthis->unk_1AC = 0; + pthis->unk_1E2 = 1; +} + +void BossDodongo_Damaged(BossDodongo* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToF(&pthis->unk_1F8, 1.0f, 0.5f, 0.02f, 0.001f); + Math_SmoothStepToF(&pthis->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); + + if (Animation_OnFrame(&pthis->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_001074))) { + BossDodongo_SetupRoll(pthis); + } +} + +void BossDodongo_Explode(BossDodongo* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 dustPrimColor = { 255, 255, 0, 255 }; + static Color_RGBA8 dustEnvColor = { 255, 10, 0, 255 }; + s16 pad; + Vec3f dustVel; + Vec3f dustAcell; + Vec3f dustPos; + s16 i; + + Math_SmoothStepToF(&pthis->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_1DA == 0) { + for (i = 0; i < 30; i++) { + dustVel.x = Rand_CenteredFloat(20.0f); + dustVel.y = Rand_CenteredFloat(20.0f); + dustVel.z = Rand_CenteredFloat(20.0f); + + dustAcell.x = dustVel.x * -0.1f; + dustAcell.y = dustVel.y * -0.1f; + dustAcell.z = dustVel.z * -0.1f; + + dustPos.x = pthis->actor.world.pos.x + (dustVel.x * 3.0f); + dustPos.y = pthis->actor.world.pos.y + 90.0f + (dustVel.y * 3.0f); + dustPos.z = pthis->actor.world.pos.z + (dustVel.z * 3.0f); + + func_8002836C(globalCtx, &dustPos, &dustVel, &dustAcell, &dustPrimColor, &dustEnvColor, 500, 10, 10); + } + + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_004E0C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_004E0C), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_LayDown; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_BOMB_EXPLOSION); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_DAMAGE); + func_80033E88(&pthis->actor, globalCtx, 4, 10); + pthis->health -= 2; + + // make sure not to die from the bomb explosion + if (pthis->health <= 0) { + pthis->health = 1; + } + } +} + +void BossDodongo_LayDown(BossDodongo* pthis, GlobalContext* globalCtx) { + pthis->unk_1BE = 10; + Math_SmoothStepToF(&pthis->unk_1F8, 1.3f, 1.0f, 0.1f, 0.001f); + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_004E0C))) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_0042A8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_0042A8), ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = BossDodongo_Vulnerable; + pthis->unk_1DA = 100; + } +} + +void BossDodongo_Vulnerable(BossDodongo* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_DOWN - SFX_FLAG); + pthis->unk_1BE = 10; + Math_SmoothStepToF(&pthis->unk_1F8, 1.0f, 0.5f, 0.02f, 0.001f); + Math_SmoothStepToF(&pthis->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_1DA == 0) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_009D10, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_009D10), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_GetUp; + } +} + +void BossDodongo_GetUp(BossDodongo* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_009D10))) { + BossDodongo_SetupRoll(pthis); + } +} + +void BossDodongo_BlowFire(BossDodongo* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f unusedZeroVec1 = { 0.0f, 0.0f, 0.0f }; + Vec3f unusedZeroVec2 = { 0.0f, 0.0f, 0.0f }; + + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_CRY); + } + + if (Animation_OnFrame(&pthis->skelAnime, 17.0f)) { + pthis->unk_1C8 = 28; + } + + if ((pthis->skelAnime.curFrame > 17.0f) && (pthis->skelAnime.curFrame < 35.0f)) { + BossDodongo_SpawnFire(pthis, globalCtx, pthis->unk_1AE); + pthis->unk_1AE++; + Math_SmoothStepToF(&pthis->unk_244, 0.0f, 1.0f, 8.0f, 0.0f); + } + + if (pthis->unk_1DA == 0) { + BossDodongo_SetupRoll(pthis); + } +} + +void BossDodongo_Inhale(BossDodongo* pthis, GlobalContext* GlobalContext) { + pthis->unk_1E2 = 1; + + if (pthis->unk_1AC > 20) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_BREATH - SFX_FLAG); + } + + Math_SmoothStepToF(&pthis->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_1DA == 0) { + BossDodongo_SetupBlowFire(pthis); + } else { + pthis->unk_1AC++; + + if ((pthis->unk_1AC > 20) && (pthis->unk_1AC < 82) && BossDodongo_AteExplosive(pthis, GlobalContext)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_DRINK); + BossDodongo_SetupExplode(pthis); + } + } +} + +static Vec3f sCornerPositions[] = { + { -1390.0f, 0.0f, -3804.0f }, + { -1390.0f, 0.0f, -2804.0f }, + { -390.0f, 0.0f, -2804.0f }, + { -390.0f, 0.0f, -3804.0f }, +}; + +void BossDodongo_Walk(BossDodongo* pthis, GlobalContext* globalCtx) { + Vec3f* sp4C; + f32 sp48; + f32 sp44; + + if (pthis->unk_1AA == 0) { + if (Animation_OnFrame(&pthis->skelAnime, 14.0f)) { + Animation_PlayLoop(&pthis->skelAnime, &object_kingdodongo_Anim_01CAE0); + pthis->unk_1AA = 1; + } + } else if (pthis->unk_1BC != 2) { + if (((s32)pthis->skelAnime.curFrame == 1) || ((s32)pthis->skelAnime.curFrame == 31)) { + if ((s32)pthis->skelAnime.curFrame == 1) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->unk_410, 25.0f, 0xA, 8.0f, 0x1F4, 0xA, 0); + } else { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->unk_404, 25.0f, 0xA, 8.0f, 0x1F4, 0xA, 0); + } + + if (pthis->unk_1BC != 0) { + func_80078884(NA_SE_EN_DODO_K_WALK); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_WALK); + } + + if (pthis->cutsceneCamera == 0) { + func_80033E88(&pthis->actor, globalCtx, 4, 10); + } else { + pthis->unk_1B6 = 10; + func_800A9F6C(0.0f, 180, 20, 100); + } + } + } + + SkelAnime_Update(&pthis->skelAnime); + sp4C = &sCornerPositions[pthis->unk_1A0]; + pthis->unk_1EC = 0.7f; + Math_SmoothStepToF(&pthis->unk_1E4, pthis->unk_1EC * 4.0f, 1.0f, pthis->unk_1EC * 0.25f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.x, sp4C->x, 0.3f, pthis->unk_1E4, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, sp4C->z, 0.3f, pthis->unk_1E4, 0.0f); + sp48 = sp4C->x - pthis->actor.world.pos.x; + sp44 = sp4C->z - pthis->actor.world.pos.z; + Math_SmoothStepToF(&pthis->unk_1E8, 2000.0f, 1.0f, pthis->unk_1EC * 80.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_FAtan2F(sp48, sp44) * (0x8000 / M_PI), 5, + (pthis->unk_1EC * pthis->unk_1E8), 5); + Math_SmoothStepToS(&pthis->unk_1C4, 0, 2, 2000, 0); + + if ((fabsf(sp48) <= 5.0f) && (fabsf(sp44) <= 5.0f)) { + pthis->unk_1E8 = 0.0f; + pthis->unk_1E4 = 0.0f; + if (pthis->unk_1A2 == 0) { + pthis->unk_1A0++; + if (pthis->unk_1A0 >= 4) { + pthis->unk_1A0 = 0; + } + } else { + pthis->unk_1A0--; + if (pthis->unk_1A0 < 0) { + pthis->unk_1A0 = 3; + } + } + } + + if ((pthis->unk_1DA == 0) && (pthis->unk_1BC == 0)) { + if ((pthis->actor.xzDistToPlayer < 500.0f) && (pthis->unk_1A4 != 0) && !pthis->playerPosInRange) { + BossDodongo_SetupInhale(pthis); + BossDodongo_SpawnFire(pthis, globalCtx, -1); + } + + if (!pthis->playerPosInRange && !pthis->playerYawInRange) { + BossDodongo_SetupRoll(pthis); + } + } +} + +void BossDodongo_Roll(BossDodongo* pthis, GlobalContext* globalCtx) { + Vec3f* sp5C; + Vec3f sp50; + f32 sp4C; + f32 sp48; + + pthis->actor.flags |= ACTOR_FLAG_24; + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_1DA == 10) { + pthis->actor.velocity.y = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_CRY); + } + + if (pthis->unk_1DA == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_COLI2); + } + + sp5C = &sCornerPositions[pthis->unk_1A0]; + pthis->unk_1EC = 3.0f; + + if (pthis->unk_1DA == 0) { + Math_SmoothStepToF(&pthis->unk_1E4, pthis->unk_1EC * 5.0f, 1.0f, pthis->unk_1EC * 0.25f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.x, sp5C->x, 1.0f, pthis->unk_1E4, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, sp5C->z, 1.0f, pthis->unk_1E4, 0.0f); + pthis->unk_1C4 += 2000; + + if (pthis->actor.bgCheckFlags & 1) { + pthis->unk_228 = 7700.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); + + if ((pthis->unk_19E & 7) == 0) { + Camera_AddQuake(&globalCtx->mainCamera, 2, 1, 8); + } + + if (!(pthis->unk_19E & 1)) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40.0f, 3, 8.0f, 0x1F4, 0xA, + 0); + } + } + } + + sp4C = sp5C->x - pthis->actor.world.pos.x; + sp48 = sp5C->z - pthis->actor.world.pos.z; + Math_SmoothStepToF(&pthis->unk_1E8, 2000.0f, 1.0f, pthis->unk_1EC * 100.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_FAtan2F(sp4C, sp48) * (0x8000 / M_PI), 5, + pthis->unk_1EC * pthis->unk_1E8, 0); + + if (fabsf(sp4C) <= 15.0f && fabsf(sp48) <= 15.0f) { + pthis->numWallCollisions++; + + if (pthis->numWallCollisions >= 2) { + if (pthis->unk_1A6 != 0) { + pthis->unk_1A2 = 1 - pthis->unk_1A2; + } + + pthis->unk_1E8 = 0.0f; + pthis->unk_1E4 = 0.0f; + BossDodongo_SetupWalk(pthis); + pthis->unk_228 = 9200.0f; + pthis->actor.velocity.y = 20.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_COLI); + Camera_AddQuake(&globalCtx->mainCamera, 2, 6, 8); + sp50.x = pthis->actor.world.pos.x; + sp50.y = pthis->actor.world.pos.y + 60.0f; + sp50.z = pthis->actor.world.pos.z; + func_80033480(globalCtx, &sp50, 250.0f, 40, 800, 10, 0); + func_80033E88(&pthis->actor, globalCtx, 6, 15); + } else { + pthis->actor.velocity.y = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_COLI2); + } + + if (pthis->unk_1A2 == 0) { + pthis->unk_1A0++; + if (pthis->unk_1A0 >= 4) { + pthis->unk_1A0 = 0; + } + } else { + pthis->unk_1A0--; + if (pthis->unk_1A0 < 0) { + pthis->unk_1A0 = 3; + } + } + } +} + +void BossDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BossDodongo* pthis = (BossDodongo*)thisx; + f32 temp_f0; + s16 i; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + s32 pad; + + pthis->unk_1E2 = 0; + pthis->unk_19E++; + + if (pthis->unk_1DA != 0) { + pthis->unk_1DA--; + } + + if (pthis->unk_1DC != 0) { + pthis->unk_1DC--; + } + + if (pthis->unk_1DE != 0) { + pthis->unk_1DE--; + } + + if (pthis->unk_1C0 != 0) { + pthis->unk_1C0--; + } + + if (pthis->unk_1C8 != 0) { + pthis->unk_1C8--; + } + + temp_f0 = func_808C4F6C(pthis, globalCtx); + + if (temp_f0 > 0.0f) { + pthis->unk_1A4 = temp_f0; + } else { + pthis->unk_1A4 = 0; + } + + temp_f0 = func_808C50A8(pthis, globalCtx); + + if (temp_f0 > 0.0f) { + pthis->unk_1A6 = temp_f0; + } else { + pthis->unk_1A6 = 0; + } + + BossDodongo_PlayerYawCheck(pthis, globalCtx); + BossDodongo_PlayerPosCheck(pthis, globalCtx); + + pthis->actionFunc(pthis, globalCtx); + + thisx->shape.rot.y = thisx->world.rot.y; + + Math_SmoothStepToF(&thisx->shape.yOffset, pthis->unk_228, 1.0f, 100.0f, 0.0f); + Actor_MoveForward(thisx); + BossDodongo_UpdateDamage(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 10.0f, 10.0f, 20.0f, 4); + Math_SmoothStepToF(&pthis->unk_208, 0, 1, 0.001f, 0.0); + Math_SmoothStepToF(&pthis->unk_20C, 0, 1, 0.001f, 0.0); + + if ((pthis->unk_19E % 128) == 0) { + for (i = 0; i < 50; i++) { + pthis->unk_324[i] = (Rand_ZeroOne() * 0.25f) + 0.5f; + } + } + + for (i = 0; i < 50; i++) { + pthis->unk_25C[i] += pthis->unk_324[i]; + } + + if (pthis->unk_1C8 != 0) { + if (pthis->unk_1C8 >= 11) { + Math_SmoothStepToF(&pthis->unk_240, (pthis->unk_1C8 & 1) ? (40.0f) : (60.0f), 1.0f, 50.0f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_240, 0.0f, 1, 10.0f, 0.0); + } + + if ((globalCtx->envCtx.adjLight1Color[2] == 0) && (globalCtx->envCtx.adjAmbientColor[2] == 0)) { + globalCtx->envCtx.adjLight1Color[0] = (u8)pthis->unk_240; + globalCtx->envCtx.adjLight1Color[1] = (u8)(pthis->unk_240 * 0.1f); + globalCtx->envCtx.adjAmbientColor[0] = (u8)pthis->unk_240; + globalCtx->envCtx.adjAmbientColor[1] = (u8)(pthis->unk_240 * 0.1f); + } + } + + if (pthis->unk_1BE != 0) { + if (pthis->unk_1BE >= 1000) { + Math_SmoothStepToF(&pthis->colorFilterR, 30.0f, 1, 20.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterG, 10.0f, 1, 20.0f, 0.0); + } else { + pthis->unk_1BE--; + Math_SmoothStepToF(&pthis->colorFilterR, 255.0f, 1, 20.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterG, 0.0f, 1, 20.0f, 0.0); + } + + Math_SmoothStepToF(&pthis->colorFilterB, 0.0f, 1, 20.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterMin, 900.0f, 1, 10.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterMax, 1099.0f, 1, 10.0f, 0.0); + } else { + Math_SmoothStepToF(&pthis->colorFilterR, globalCtx->lightCtx.fogColor[0], 1, 5.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterG, globalCtx->lightCtx.fogColor[1], 1.0f, 5.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterB, globalCtx->lightCtx.fogColor[2], 1.0f, 5.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterMin, globalCtx->lightCtx.fogNear, 1.0, 5.0f, 0.0); + Math_SmoothStepToF(&pthis->colorFilterMax, 1000.0f, 1, 5.0f, 0.0); + } + + if (player->actor.world.pos.y < -1000.0f) { + s16 phi_s0_3; + s16 sp90; + s16 magma2DrawMode; + s16 magmaScale = 0; + + if (pthis->unk_224 > 1.9f) { + phi_s0_3 = 1; + magma2DrawMode = 0; + sp90 = 0; + } else if (pthis->unk_224 > 1.7f) { + phi_s0_3 = 3; + sp90 = 1; + if (globalCtx) {} + magma2DrawMode = 0; + } else if (pthis->unk_224 > 1.4f) { + phi_s0_3 = 7; + sp90 = 3; + magma2DrawMode = Rand_ZeroOne() * 1.9f; + } else if (pthis->unk_224 > 1.1f) { + phi_s0_3 = 7; + sp90 = 4095; + magma2DrawMode = Rand_ZeroOne() * 1.9f; + } else { + phi_s0_3 = 1; + sp90 = -1; + magma2DrawMode = 1; + magmaScale = ((s16)(Rand_ZeroOne() * 50)) - 50; + } + + if (player2->csMode >= 10) { + phi_s0_3 = -1; + } + + if ((pthis->unk_19E & phi_s0_3) == 0) { + static Color_RGBA8 magmaPrimColor[] = { { 255, 255, 0, 255 }, { 0, 0, 0, 150 } }; + static Color_RGBA8 magmaEnvColor[] = { { 255, 0, 0, 255 }, { 0, 0, 0, 0 } }; + Vec3f sp84; + f32 temp_f12; + f32 temp_f10; + + temp_f12 = Rand_ZeroOne() * 330.0f; + temp_f10 = Rand_ZeroOne() * 6.28f; + sp84.x = (sinf(temp_f10) * temp_f12) + (-890.0f); + sp84.y = -1523.76f; + sp84.z = (cosf(temp_f10) * temp_f12) + (-3304.0f); + EffectSsGMagma2_Spawn(globalCtx, &sp84, &magmaPrimColor[magma2DrawMode], &magmaEnvColor[magma2DrawMode], + 10 - (magma2DrawMode * 5), magma2DrawMode, magmaScale + 100); + } + + if ((pthis->unk_19E & sp90) == 0) { + Vec3f sp6C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp60 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp54; + f32 sp50 = Rand_ZeroOne() * 330.0f; + f32 sp4C = Rand_ZeroOne() * 6.28f; + + sp54.x = sinf(sp4C) * sp50 + (-890.0f); + sp54.y = -1523.76f; + sp54.z = cosf(sp4C) * sp50 + (-3304.0f); + EffectSsGMagma_Spawn(globalCtx, &sp54); + for (i = 0; i < 4; i++) { + sp60.y = 0.4f; + sp60.x = Rand_CenteredFloat(0.5f); + sp60.z = Rand_CenteredFloat(0.5f); + sp50 = Rand_ZeroOne() * 330.0f; + sp4C = Rand_ZeroOne() * 6.28f; + sp54.x = sinf(sp4C) * sp50 + (-890.0f); + sp54.y = -1513.76f; + sp54.z = cosf(sp4C) * sp50 + (-3304.0f); + func_808C17C8(globalCtx, &sp54, &sp6C, &sp60, ((s16)Rand_ZeroFloat(2.0f)) + 6, 0x50); + } + } + + func_808C1554(gDodongosCavernBossLavaFloorTex, sLavaFloorLavaTex, pthis->unk_19E, pthis->unk_224); + } + + if (pthis->unk_1C6 != 0) { + u16* ptr1 = (u16*)SEGMENTED_TO_VIRTUAL(sLavaFloorLavaTex); + u16* ptr2 = (u16*)SEGMENTED_TO_VIRTUAL(sLavaFloorRockTex); + s16 i2; + + for (i2 = 0; i2 < 20; i2++) { + s16 new_var = pthis->unk_1C2 & 0x7FF; + + ptr1[new_var] = ptr2[new_var]; + pthis->unk_1C2 += 37; + } + Math_SmoothStepToF(&pthis->unk_224, 0.0f, 1.0f, 0.01f, 0.0f); + } + + if (pthis->unk_1BC == 0) { + if (pthis->actionFunc != BossDodongo_DeathCutscene) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->actionFunc == BossDodongo_Roll) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + pthis->collider.elements[0].dim.scale = (pthis->actionFunc == BossDodongo_Inhale) ? 0.0f : 1.0f; + + for (i = 6; i < 19; i++) { + if (i != 12) { + pthis->collider.elements[i].dim.scale = (pthis->actionFunc == BossDodongo_Roll) ? 0.0f : 1.0f; + } + } + + if (pthis->unk_244 != 0) { + MREG(64) = 1; + MREG(65) = 255; + MREG(66) = 80; + MREG(67) = 0; + MREG(68) = (u8)pthis->unk_244; + } else { + MREG(64) = 0; + } + + Math_SmoothStepToF(&pthis->unk_244, 0.0f, 1.0f, 2.0f, 0.0f); + BossDodongo_UpdateEffects(globalCtx); +} + +s32 BossDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + f32 mtxScaleY; + f32 mtxScaleZ; + BossDodongo* pthis = (BossDodongo*)thisx; + + // required for matching + if ((limbIndex == 6) || (limbIndex == 7)) { + if (pthis->unk_25C) {} + goto block_1; + } +block_1: + Matrix_TranslateRotateZYX(pos, rot); + + if (*dList != NULL) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3787); + + mtxScaleZ = 1.0f; + mtxScaleY = 1.0f; + + if ((limbIndex == 33) || (limbIndex == 48)) { + mtxScaleY = mtxScaleZ = pthis->unk_1F8; + } + + Matrix_Push(); + Matrix_Scale(1.0f, mtxScaleY, mtxScaleZ, MTXMODE_APPLY); + + if ((limbIndex != 6) && (limbIndex != 7)) { + Matrix_RotateX(pthis->unk_25C[limbIndex] * 0.115f, MTXMODE_APPLY); + Matrix_RotateY(pthis->unk_25C[limbIndex] * 0.13f, MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_25C[limbIndex] * 0.1f, MTXMODE_APPLY); + Matrix_Scale(1.0f - pthis->unk_208, pthis->unk_208 + 1.0f, 1.0f - pthis->unk_208, MTXMODE_APPLY); + Matrix_RotateZ(-(pthis->unk_25C[limbIndex] * 0.1f), MTXMODE_APPLY); + Matrix_RotateY(-(pthis->unk_25C[limbIndex] * 0.13f), MTXMODE_APPLY); + Matrix_RotateX(-(pthis->unk_25C[limbIndex] * 0.115f), MTXMODE_APPLY); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3822), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3826); + } + { s32 pad; } // Required to match + return 1; +} + +void BossDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_808CA450 = { 5000.0f, -2500.0f, 0.0f }; + static Vec3f D_808CA45C = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_808CA468 = { 11500.0f, -3000.0f, 0.0f }; + static Vec3f D_808CA474 = { 5000.0f, -2000.0f, 0.0f }; + static Vec3f D_808CA480 = { 8000.0f, 0.0f, 0.0f }; + static Vec3f D_808CA48C = { 8000.0f, 0.0f, 0.0f }; + BossDodongo* pthis = (BossDodongo*)thisx; + + if (limbIndex == 6) { + Matrix_MultVec3f(&D_808CA45C, &pthis->vec); + Matrix_MultVec3f(&D_808CA450, &pthis->actor.focus.pos); + Matrix_MultVec3f(&D_808CA468, &pthis->firePos); + Matrix_MultVec3f(&D_808CA474, &pthis->mouthPos); + } else if (limbIndex == 39) { + Matrix_MultVec3f(&D_808CA480, &pthis->unk_410); + } else if (limbIndex == 46) { + Matrix_MultVec3f(&D_808CA48C, &pthis->unk_404); + } + Collider_UpdateSpheres(limbIndex, &pthis->collider); +} + +void BossDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { + BossDodongo* pthis = (BossDodongo*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3922); + func_80093D18(globalCtx->state.gfxCtx); + + if ((pthis->unk_1C0 >= 2) && (pthis->unk_1C0 & 1)) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 255, 255, 0, 900, 1099); + } else { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, (u32)pthis->colorFilterR, (u32)pthis->colorFilterG, + (u32)pthis->colorFilterB, 0, pthis->colorFilterMin, pthis->colorFilterMax); + } + + Matrix_RotateZ(pthis->unk_23C, MTXMODE_APPLY); + Matrix_RotateX((pthis->unk_1C4 / 32768.0f) * 3.14159f, MTXMODE_APPLY); + + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, BossDodongo_OverrideLimbDraw, + BossDodongo_PostLimbDraw, pthis); + + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_dodongo.c", 3981); + + BossDodongo_DrawEffects(globalCtx); +} + +f32 func_808C4F6C(BossDodongo* pthis, GlobalContext* globalCtx) { + f32 xDiff; + f32 zDiff; + f32 sp2C; + s32 pad; + f32 temp_f2; + f32 rotation; + Player* player = GET_PLAYER(globalCtx); + + xDiff = player->actor.world.pos.x - pthis->actor.world.pos.x; + zDiff = player->actor.world.pos.z - pthis->actor.world.pos.z; + + rotation = Math_CosS(-pthis->actor.world.rot.y); + sp2C = (Math_SinS(-pthis->actor.world.rot.y) * zDiff) + (rotation * xDiff); + rotation = Math_SinS(-pthis->actor.world.rot.y); + temp_f2 = (Math_CosS(-pthis->actor.world.rot.y) * zDiff) + (-rotation * xDiff); + + if ((fabsf(sp2C) < 150.0f) && (temp_f2 >= 100.0f) && (temp_f2 <= 2000.0f)) { + return temp_f2; + } + return -1.0f; +} + +f32 func_808C50A8(BossDodongo* pthis, GlobalContext* globalCtx) { + f32 xDiff; + f32 zDiff; + f32 sp2C; + s32 pad; + f32 temp_f2; + f32 rotation; + Player* player = GET_PLAYER(globalCtx); + + xDiff = player->actor.world.pos.x - pthis->actor.world.pos.x; + zDiff = player->actor.world.pos.z - pthis->actor.world.pos.z; + + rotation = Math_CosS(-0x8000 - pthis->actor.world.rot.y); + sp2C = (Math_SinS(-0x8000 - pthis->actor.world.rot.y) * zDiff) + (rotation * xDiff); + rotation = Math_SinS(-0x8000 - pthis->actor.world.rot.y); + temp_f2 = (Math_CosS(-0x8000 - pthis->actor.world.rot.y) * zDiff) + (-rotation * xDiff); + + if ((fabsf(sp2C) < 150.0f) && (100.0f <= temp_f2) && (temp_f2 <= 2000.0f)) { + return temp_f2; + } + + return -1.0f; +} + +void BossDodongo_PlayerYawCheck(BossDodongo* pthis, GlobalContext* globalCtx) { + s16 yawDiff = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.world.rot.y; + + if ((yawDiff < 0x38E3) && (-0x38E3 < yawDiff)) { + pthis->playerYawInRange = true; + } else { + pthis->playerYawInRange = false; + } +} + +void BossDodongo_PlayerPosCheck(BossDodongo* pthis, GlobalContext* globalCtx) { + Vec3f* temp_v1; + s16 i; + + pthis->playerPosInRange = false; + + for (i = 0; i < 4; i++) { + temp_v1 = &sCornerPositions[i]; + + if ((fabsf(pthis->actor.world.pos.x - temp_v1->x) < 200.0f) && + (fabsf(pthis->actor.world.pos.z - temp_v1->z) < 200.0f)) { + pthis->playerPosInRange = true; + break; + } + } +} + +void BossDodongo_SpawnFire(BossDodongo* pthis, GlobalContext* globalCtx, s16 params) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_BDFIRE, pthis->vec.x, pthis->vec.y - 20.0f, + pthis->vec.z, 0, pthis->actor.shape.rot.y, 0, params); +} + +void BossDodongo_UpdateDamage(BossDodongo* pthis, GlobalContext* globalCtx) { + s32 pad; + ColliderInfo* item1; + u8 swordDamage; + s32 damage; + ColliderInfo* item2; + s16 i; + + if ((pthis->health <= 0) && (pthis->actionFunc != BossDodongo_DeathCutscene)) { + BossDodongo_SetupDeathCutscene(pthis); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + return; + } + + if (pthis->unk_1C0 == 0) { + if (pthis->actionFunc == BossDodongo_Inhale) { + for (i = 0; i < 19; i++) { + if (pthis->collider.elements[i].info.bumperFlags & 2) { + item1 = pthis->collider.elements[i].info.acHitInfo; + item2 = item1; + + if ((item2->toucher.dmgFlags & 0x10) || (item2->toucher.dmgFlags & 4)) { + pthis->collider.elements[i].info.bumperFlags &= ~2; + pthis->unk_1C0 = 2; + BossDodongo_SetupWalk(pthis); + pthis->unk_1DA = 0x32; + return; + } + } + } + } + + if (pthis->collider.elements->info.bumperFlags & 2) { + pthis->collider.elements->info.bumperFlags &= ~2; + item1 = pthis->collider.elements[0].info.acHitInfo; + if ((pthis->actionFunc == BossDodongo_Vulnerable) || (pthis->actionFunc == BossDodongo_LayDown)) { + swordDamage = damage = CollisionCheck_GetSwordDamage(item1->toucher.dmgFlags); + + if (damage != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_DAMAGE); + BossDodongo_SetupDamaged(pthis); + pthis->unk_1C0 = 5; + pthis->health -= swordDamage; + } + } + } + } +} + +void BossDodongo_SetupDeathCutscene(BossDodongo* pthis) { + pthis->actor.speedXZ = 0.0f; + pthis->unk_1E4 = 0.0f; + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_002D0C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_002D0C), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossDodongo_DeathCutscene; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_DEAD); + pthis->unk_1DA = 0; + pthis->csState = 0; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->unk_1BC = 1; + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); +} + +void BossDodongo_DeathCutscene(BossDodongo* pthis, GlobalContext* globalCtx) { + Vec3f* cornerPos; + Vec3f sp198; + Vec3f sp184; + f32 tempSin; + f32 tempCos; + f32 sp178; + s16 i; + Vec3f effectPos; + Camera* camera; + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + + switch (pthis->csState) { + case 0: + pthis->csState = 5; + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_UNK3); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cutsceneCamera, CAM_STAT_ACTIVE); + camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); + pthis->cameraEye.x = camera->eye.x; + pthis->cameraEye.y = camera->eye.y; + pthis->cameraEye.z = camera->eye.z; + pthis->cameraAt.x = camera->at.x; + pthis->cameraAt.y = camera->at.y; + pthis->cameraAt.z = camera->at.z; + break; + case 5: + tempSin = Math_SinS(pthis->actor.shape.rot.y - 0x1388) * 150.0f; + tempCos = Math_CosS(pthis->actor.shape.rot.y - 0x1388) * 150.0f; + Math_SmoothStepToF(&player->actor.world.pos.x, pthis->actor.world.pos.x + tempSin, 0.5f, 5.0f, 0.0f); + Math_SmoothStepToF(&player->actor.world.pos.z, pthis->actor.world.pos.z + tempCos, 0.5f, 5.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_208, 0.07f, 1.0f, 0.005f, 0.0f); + tempSin = Math_SinS(pthis->actor.world.rot.y) * 230.0f; + tempCos = Math_CosS(pthis->actor.world.rot.y) * 230.0f; + Math_SmoothStepToF(&pthis->cameraEye.x, pthis->actor.world.pos.x + tempSin, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraEye.y, pthis->actor.world.pos.y + 20.0f, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraEye.z, pthis->actor.world.pos.z + tempCos, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraAt.x, pthis->actor.world.pos.x, 0.2f, 30.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraAt.y, pthis->actor.focus.pos.y - 70.0f, 0.2f, 30.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraAt.z, pthis->actor.world.pos.z, 0.2f, 30.0f, 0.1f); + if (Animation_OnFrame(&pthis->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_002D0C))) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_003CF8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_kingdodongo_Anim_003CF8), ANIMMODE_ONCE, -1.0f); + pthis->csState = 6; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_BREAKWALL, -890.0f, -1523.76f, -3304.0f, 0, 0, 0, + 0x6000); + } + break; + case 6: + Math_SmoothStepToF(&pthis->cameraAt.x, pthis->actor.world.pos.x, 0.2f, 30.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraAt.y, (pthis->actor.world.pos.y - 70.0f) + 130.0f, 0.2f, 20.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraAt.z, pthis->actor.world.pos.z, 0.2f, 30.0f, 0.1f); + + if (Animation_OnFrame(&pthis->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_003CF8))) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_00DF38, 1.0f, 30.0f, 59.0f, ANIMMODE_ONCE, + -1.0f); + pthis->csState = 7; + pthis->unk_228 = 7700.0f; + pthis->unk_204 = 0.0f; + pthis->unk_1E4 = 0.0f; + pthis->numWallCollisions = 0; + pthis->unk_19E = 0; + } + break; + case 7: + pthis->unk_1C4 += 0x7D0; + Math_SmoothStepToF(&pthis->cameraAt.x, pthis->actor.world.pos.x, 0.2f, 30.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.y, (pthis->actor.world.pos.y - 70.0f) + 130.0f, 0.2f, 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.z, pthis->actor.world.pos.z, 0.2f, 30.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.x, -890.0f, 0.1f, pthis->unk_204 * 5.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraEye.z, -3304.0f, 0.1f, pthis->unk_204 * 5.0f, 0.1f); + Math_SmoothStepToF(&pthis->unk_204, 1.0f, 1.0f, 0.1f, 0.0f); + if (pthis->unk_1DA == 1) { + pthis->csState = 8; + pthis->actor.speedXZ = pthis->unk_1E4 / 1.5f; + if (pthis->unk_1A2 == 0) { + pthis->unk_238 = 250.0f; + } else { + pthis->unk_238 = -250.0f; + } + pthis->unk_1DA = 1000; + pthis->unk_234 = 2000.0f; + } else { + cornerPos = &sCornerPositions[pthis->unk_1A0]; + pthis->unk_1EC = 3.0f; + Math_SmoothStepToF(&pthis->unk_1E4, pthis->unk_1EC * 5.0f, 1.0f, pthis->unk_1EC * 0.25f, 0.0f); + tempSin = cornerPos->x - pthis->actor.world.pos.x; + tempCos = cornerPos->z - pthis->actor.world.pos.z; + sp178 = sqrtf(SQ(tempSin) + SQ(tempCos)) - 200.0f; + if ((sqrtf(SQ(tempSin) + SQ(tempCos)) < 200.0f) || (pthis->unk_1DA != 0)) { + sp178 = 0.0f; + } + sp178 = CLAMP_MAX(sp178, 70.0f); + pthis->unk_23C = (Math_SinS(pthis->unk_19E * 1000) * -50.0f) / 100.0f; + + sp198.x = Math_SinS(pthis->unk_19E * 1000) * sp178; + sp198.y = sp198.z = 0.0f; + + Matrix_RotateY(pthis->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_NEW); + Matrix_MultVec3f(&sp198, &sp184); + + Math_SmoothStepToF(&pthis->actor.world.pos.x, cornerPos->x + sp184.x, 1.0f, pthis->unk_1E4, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, cornerPos->z + sp184.z, 1.0f, pthis->unk_1E4, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); + if ((pthis->unk_19E & 7) == 0) { + Camera_AddQuake(&globalCtx->mainCamera, 2, 1, 8); + } + if (!(pthis->unk_19E & 1)) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40.0f, 3, 8.0f, 0x1F4, + 0xA, 0); + } + tempSin = cornerPos->x - pthis->actor.world.pos.x; + tempCos = cornerPos->z - pthis->actor.world.pos.z; + Math_SmoothStepToF(&pthis->unk_1E8, 1500.0f, 1.0f, pthis->unk_1EC * 100.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.world.rot.y, (Math_FAtan2F(tempSin, tempCos) * (0x8000 / M_PI)), 5, + (pthis->unk_1EC * pthis->unk_1E8), 0); + + if ((fabsf(tempSin) <= 15.0f) && (fabsf(tempCos) <= 15.0f)) { + Vec3f dustPos; + + pthis->actor.velocity.y = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_COLI2); + if (pthis->unk_1A2 == 0) { + pthis->unk_1A0 = pthis->unk_1A0 + 1; + if (pthis->unk_1A0 >= 4) { + pthis->unk_1A0 = 0; + } + } else { + pthis->unk_1A0--; + if (pthis->unk_1A0 < 0) { + pthis->unk_1A0 = 3; + } + } + pthis->unk_1DA = 0xA; + dustPos.x = pthis->actor.world.pos.x; + dustPos.y = pthis->actor.world.pos.y + 60.0f; + dustPos.z = pthis->actor.world.pos.z; + func_80033480(globalCtx, &dustPos, 250.0f, 0x28, 0x320, 0xA, 0); + } + } + break; + case 8: + case 9: + if (pthis->unk_1DA == 884) { + Animation_Change(&pthis->skelAnime, &object_kingdodongo_Anim_0042A8, 1.0f, 0.0f, + (f32)Animation_GetLastFrame(&object_kingdodongo_Anim_0042A8), ANIMMODE_LOOP, -20.0f); + tempSin = pthis->cameraEye.x - pthis->actor.world.pos.x; + tempCos = pthis->cameraEye.z - pthis->actor.world.pos.z; + pthis->unk_22C = sqrtf(SQ(tempSin) + SQ(tempCos)); + pthis->unk_230 = Math_FAtan2F(tempSin, tempCos); + pthis->unk_1DC = 350; + pthis->csState = 9; + } + if (pthis->unk_1DA < 854) { + for (i = 0; i < 2; i++) { + func_808C12C4(D_808C7000, pthis->unk_1CC); + if (pthis->unk_1CC < 256) { + pthis->unk_1CC++; + } + } + } + if (pthis->unk_1DA < 984) { + Math_SmoothStepToS(&pthis->unk_1C4, -0x4000, 0xA, 0x12C, 0); + } + if (pthis->unk_1DA == 904) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_END); + } + if (pthis->unk_1DA < 854) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_LAST - SFX_FLAG); + } + if (pthis->unk_1DA == 960) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_LAVA); + } + if (pthis->unk_1DA < 960) { + Math_SmoothStepToF(&pthis->actor.shape.shadowScale, 0.0f, 1.0f, 10.0f, 0.0f); + if (pthis->unk_1DA >= 710) { + + if (pthis->unk_1DA == 710) { + Vec3f sp124[] = { + { -440.0f, 0.0f, -3304.0f }, + { -890.0f, 0.0f, -3754.0f }, + { -1340.0f, 0.0f, -3304.0f }, + { -890.0f, 0.0f, -2854.0f }, + }; + Vec3f spF4[] = { + { -890.0f, 0.0f, -2854.0f }, + { -440.0f, 0.0f, -3304.0f }, + { -890.0f, 0.0f, -3754.0f }, + { -1340.0f, 0.0f, -3304.0f }, + }; + Vec3f* phi_v0_2; + + pthis->unk_1C6 = 1; + if (pthis->unk_1A2 == 0) { + phi_v0_2 = &sp124[pthis->unk_1A0]; + } else { + phi_v0_2 = &spF4[pthis->unk_1A0]; + } + player->actor.world.pos.x = phi_v0_2->x; + player->actor.world.pos.z = phi_v0_2->z; + pthis->unk_204 = 0.0f; + } + if (pthis->unk_1DA >= 885) { + Math_SmoothStepToF(&pthis->unk_228, 200.0, 0.2f, 100.0f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_228, -6600.0f, 0.2f, 30.0f, 0.0f); + } + { + static Vec3f dustVel = { 0.0f, 0.0f, 0.0f }; + static Vec3f dustAcell = { 0.0f, 1.0f, 0.0f }; + static Color_RGBA8 dustPrimColor = { 255, 255, 100, 255 }; + static Color_RGBA8 dustEnvColor = { 255, 100, 0, 255 }; + s16 colorIndex; + Color_RGBA8 magmaPrimColor2[] = { { 255, 255, 0, 255 }, { 0, 0, 0, 100 } }; + Color_RGBA8 magmaEnvColor2[] = { { 255, 0, 0, 255 }, { 0, 0, 0, 0 } }; + + effectPos.x = Rand_CenteredFloat(120.0f) + pthis->actor.focus.pos.x; + effectPos.y = Rand_ZeroFloat(50.0f) + pthis->actor.world.pos.y; + effectPos.z = Rand_CenteredFloat(120.0f) + pthis->actor.focus.pos.z; + func_8002836C(globalCtx, &effectPos, &dustVel, &dustAcell, &dustPrimColor, &dustEnvColor, 0x1F4, + 0xA, 0xA); + effectPos.x = Rand_CenteredFloat(120.0f) + pthis->actor.focus.pos.x; + effectPos.y = -1498.76f; + effectPos.z = Rand_CenteredFloat(120.0f) + pthis->actor.focus.pos.z; + colorIndex = (Rand_ZeroOne() * 1.9f); + EffectSsGMagma2_Spawn(globalCtx, &effectPos, &magmaPrimColor2[colorIndex], + &magmaEnvColor2[colorIndex], 10 - (colorIndex * 5), colorIndex, + (s16)(Rand_ZeroOne() * 100.0f) + 100); + } + } + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_ROLL - SFX_FLAG); + if (!(pthis->unk_19E & 1)) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40.0f, 3, 8.0f, 0x1F4, + 0xA, 0); + } + } + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.2f, 0.1f, 0.0f); + pthis->actor.world.rot.y += (s16)pthis->unk_238; + pthis->unk_1C4 += (s16)pthis->unk_234; + if (pthis->unk_1DA >= 0x367) { + if (pthis->unk_1A2 == 0) { + if (pthis->unk_238 < 450.0f) { + pthis->unk_238 += 10.0f; + } + } else if (-450.0f < pthis->unk_238) { + pthis->unk_238 -= 10.0f; + } + } else { + Math_SmoothStepToF(&pthis->unk_238, 0.0f, 0.05f, 40.0f, 0.0f); + } + Math_SmoothStepToF(&pthis->unk_234, 0.0f, 0.2f, 17.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.x, pthis->actor.world.pos.x, 0.2f, 30.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.y, (pthis->actor.world.pos.y - 70.0f) + 130.0f, 0.2f, 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraAt.z, pthis->actor.world.pos.z, 0.2f, 30.0f, 0.0f); + if (pthis->csState == 9) { + if (pthis->unk_1DA < 0x2C6) { + Vec3f spAC[] = { { -390.0f, 0.0f, -3304.0f }, + { -890.0f, 0.0f, -3804.0f }, + { -1390.0f, 0.0f, -3304.0f }, + { -890.0f, 0.0f, -2804.0f } }; + + Vec3f sp7C[] = { { -890.0f, 0.0f, -2804.0f }, + { -390.0f, 0.0f, -3304.0f }, + { -890.0f, 0.0f, -3804.0f }, + { -1390.0f, 0.0f, -3304.0f } }; + Vec3f* sp78; + s32 pad74; + + if (pthis->unk_1A2 == 0) { + sp78 = &spAC[pthis->unk_1A0]; + } else { + sp78 = &sp7C[pthis->unk_1A0]; + } + + Math_SmoothStepToF(&pthis->cameraEye.x, sp78->x, 0.2f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.y, player->actor.world.pos.y + 30.0f, 0.1f, + pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.z, sp78->z, 0.1f, pthis->unk_204 * 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_204, 1.0f, 1.0f, 0.02f, 0.0f); + } else { + if (pthis->unk_1A2 == 0) { + pthis->unk_230 += 0.01f; + } else { + pthis->unk_230 -= 0.01f; + } + Math_SmoothStepToF(&pthis->unk_22C, 220.0f, 0.1f, 5.0f, 0.1f); + tempSin = sinf(pthis->unk_230) * (*pthis).unk_22C; + tempCos = cosf(pthis->unk_230) * (*pthis).unk_22C; + Math_SmoothStepToF(&pthis->cameraEye.x, pthis->actor.world.pos.x + tempSin, 0.2f, 50.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.y, pthis->actor.world.pos.y + 20.0f, 0.2f, 50.0f, 0.0f); + Math_SmoothStepToF(&pthis->cameraEye.z, pthis->actor.world.pos.z + tempCos, 0.2f, 50.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_23C, 0.0f, 0.2f, 0.01f, 0.0f); + } + } else { + + if (pthis->unk_1A2 == 0) { + Math_SmoothStepToF(&pthis->unk_23C, -0.5f, 0.2f, 0.05f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_23C, 0.5f, 0.2f, 0.05f, 0.0f); + } + + Math_SmoothStepToF(&pthis->cameraEye.x, -890.0f, 0.1f, pthis->unk_204 * 5.0f, 0.1f); + Math_SmoothStepToF(&pthis->cameraEye.z, -3304.0f, 0.1f, pthis->unk_204 * 5.0f, 0.1f); + Math_SmoothStepToF(&pthis->unk_204, 1.0f, 1.0f, 0.05f, 0.0f); + } + + if (pthis->unk_1DA == 820) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, + Math_SinS(pthis->actor.shape.rot.y) * -50.0f + pthis->actor.world.pos.x, + pthis->actor.world.pos.y, + Math_CosS(pthis->actor.shape.rot.y) * -50.0f + pthis->actor.world.pos.z, 0, 0, 0, 0); + } + if (pthis->unk_1DA == 600) { + camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); + camera->eye = pthis->cameraEye; + camera->eyeNext = pthis->cameraEye; + camera->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->cutsceneCamera, 0); + pthis->unk_1BC = 0; + pthis->cutsceneCamera = MAIN_CAM; + pthis->csState = 100; + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, -890.0f, -1523.76f, + -3304.0f, 0, 0, 0, WARP_DUNGEON_CHILD); + pthis->skelAnime.playSpeed = 0.0f; + Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); + } + case 100: + if ((pthis->unk_1DA < 0x2C6) && (Rand_ZeroOne() < 0.5f)) { + Vec3f sp68; + Color_RGBA8 D_808CA568 = { 0, 0, 0, 100 }; + Color_RGBA8 D_808CA56C = { 0, 0, 0, 0 }; + + sp68.x = Rand_CenteredFloat(60.0f) + pthis->actor.focus.pos.x; + sp68.y = (Rand_ZeroOne() * 50.0f) + -1498.76f; + sp68.z = Rand_CenteredFloat(60.0f) + pthis->actor.focus.pos.z; + EffectSsGMagma2_Spawn(globalCtx, &sp68, &D_808CA568, &D_808CA56C, 5, 1, + (s16)(Rand_ZeroOne() * 50.0f) + 50); + } + break; + } + if (pthis->cutsceneCamera != MAIN_CAM) { + Gameplay_CameraSetAtEye(globalCtx, pthis->cutsceneCamera, &pthis->cameraAt, &pthis->cameraEye); + } +} + +void BossDodongo_UpdateEffects(GlobalContext* globalCtx) { + BossDodongoEffect* eff = (BossDodongoEffect*)globalCtx->specialEffects; + Color_RGB8 effectColors[] = { { 255, 128, 0 }, { 255, 0, 0 }, { 255, 255, 0 }, { 255, 0, 0 } }; + s16 colorIndex; + s16 i; + + for (i = 0; i < 80; i++, eff++) { + if (eff->unk_24 != 0) { + eff->unk_00.x += eff->unk_0C.x; + eff->unk_00.y += eff->unk_0C.y; + eff->unk_00.z += eff->unk_0C.z; + eff->unk_25++; + eff->unk_0C.x += eff->unk_18.x; + eff->unk_0C.y += eff->unk_18.y; + eff->unk_0C.z += eff->unk_18.z; + if (eff->unk_24 == 1) { + colorIndex = eff->unk_25 % 4; + eff->color.r = effectColors[colorIndex].r; + eff->color.g = effectColors[colorIndex].g; + eff->color.b = effectColors[colorIndex].b; + eff->alpha -= 20; + if (eff->alpha <= 0) { + eff->alpha = 0; + eff->unk_24 = 0; + } + } + } + } +} + +void BossDodongo_DrawEffects(GlobalContext* globalCtx) { + MtxF* unkMtx; + s16 i; + u8 phi_s3 = 0; + BossDodongoEffect* eff; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + eff = (BossDodongoEffect*)globalCtx->specialEffects; + + OPEN_DISPS(gfxCtx, "../z_boss_dodongo.c", 5228); + + func_80093D84(globalCtx->state.gfxCtx); + unkMtx = &globalCtx->billboardMtxF; + + for (i = 0; i < 80; i++, eff++) { + if (eff->unk_24 == 1) { + gDPPipeSync(POLY_XLU_DISP++); + + if (phi_s3 == 0) { + gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_009D50); + phi_s3++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, eff->alpha); + Matrix_Translate(eff->unk_00.x, eff->unk_00.y, eff->unk_00.z, MTXMODE_NEW); + func_800D1FD4(unkMtx); + Matrix_Scale(eff->unk_2C, eff->unk_2C, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_dodongo.c", 5253), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_009DD0); + } + } + + CLOSE_DISPS(gfxCtx, "../z_boss_dodongo.c", 5258); +} diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo_data.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo_data.cpp similarity index 99% rename from src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo_data.c rename to src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo_data.cpp index 59e8fa4aa..5e2284cfd 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo_data.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo_data.cpp @@ -238,4 +238,4 @@ static ColliderJntSphInit sJntSphInit = { static Vec3f sUnkZeroVec = { 0.0f, 0.0f, 0.0f }; -#include "overlays/ovl_Boss_Dodongo/ovl_Boss_Dodongo.c" +#include "overlays/ovl_Boss_Dodongo/ovl_Boss_Dodongo.cpp" diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c deleted file mode 100644 index b3085d52d..000000000 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ /dev/null @@ -1,1997 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_FD_Z_BOSS_FD_C -#include "actor_common.h" -/* - * File: z_boss_fd.c - * Overlay: ovl_Boss_Fd - * Description: Volvagia, flying form - */ - -#include "z_boss_fd.h" -#include "objects/object_fd/object_fd.h" -#include "overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.h" -#include "overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.h" -#include "overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -typedef enum { - /* 0 */ INTRO_FLY_EMERGE, - /* 1 */ INTRO_FLY_HOLE, - /* 2 */ INTRO_FLY_CAMERA, - /* 3 */ INTRO_FLY_RETRAT -} BossFdIntroFlyState; - -typedef enum { - /* 0 */ MANE_CENTER, - /* 1 */ MANE_RIGHT, - /* 2 */ MANE_LEFT -} BossFdManeIndex; - -typedef enum { - /* 0 */ EYE_OPEN, - /* 1 */ EYE_HALF, - /* 2 */ EYE_CLOSED -} BossFdEyeState; - -void BossFd_Init(Actor* thisx, GlobalContext* globalCtx); -void BossFd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossFd_Update(Actor* thisx, GlobalContext* globalCtx); -void BossFd_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BossFd_SetupFly(BossFd* this, GlobalContext* globalCtx); -void BossFd_Fly(BossFd* this, GlobalContext* globalCtx); -void BossFd_Wait(BossFd* this, GlobalContext* globalCtx); -void BossFd_UpdateEffects(BossFd* this, GlobalContext* globalCtx); -void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* this); - -const ActorInit Boss_Fd_InitVars = { - ACTOR_BOSS_FD, - ACTORCAT_BOSS, - FLAGS, - OBJECT_FD, - sizeof(BossFd), - (ActorFunc)BossFd_Init, - (ActorFunc)BossFd_Destroy, - (ActorFunc)BossFd_Update, - (ActorFunc)BossFd_Draw, -}; - -#include "z_boss_fd_colchk.c" - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x21, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void BossFd_SpawnEmber(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 150; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_EMBER; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->scale = scale / 1000.0f; - effect->alpha = 255; - effect->timer1 = (s16)Rand_ZeroFloat(10.0f); - break; - } - } -} - -void BossFd_SpawnDebris(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 150; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_DEBRIS; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->scale = scale / 1000.0f; - effect->vFdFxRotX = Rand_ZeroFloat(100.0f); - effect->vFdFxRotY = Rand_ZeroFloat(100.0f); - break; - } - } -} - -void BossFd_SpawnDust(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 150; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_DUST; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->timer2 = 0; - effect->scale = scale / 400.0f; - break; - } - } -} - -void BossFd_SpawnFireBreath(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 alpha, s16 kbAngle) { - s16 i; - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_FIRE_BREATH; - effect->timer1 = 0; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->pos.x -= effect->velocity.x; - effect->pos.y -= effect->velocity.y; - effect->pos.z -= effect->velocity.z; - effect->vFdFxScaleMod = 0.0f; - effect->alpha = alpha; - effect->vFdFxYStop = Rand_ZeroFloat(10.0f); - effect->timer2 = 0; - effect->scale = scale / 400.0f; - effect->kbAngle = kbAngle; - break; - } - } -} - -void BossFd_SetCameraSpeed(BossFd* this, f32 speedMod) { - this->camData.eyeVel.x = fabsf(this->camData.eye.x - this->camData.nextEye.x) * speedMod; - this->camData.eyeVel.y = fabsf(this->camData.eye.y - this->camData.nextEye.y) * speedMod; - this->camData.eyeVel.z = fabsf(this->camData.eye.z - this->camData.nextEye.z) * speedMod; - this->camData.atVel.x = fabsf(this->camData.at.x - this->camData.nextAt.x) * speedMod; - this->camData.atVel.y = fabsf(this->camData.at.y - this->camData.nextAt.y) * speedMod; - this->camData.atVel.z = fabsf(this->camData.at.z - this->camData.nextAt.z) * speedMod; -} - -void BossFd_UpdateCamera(BossFd* this, GlobalContext* globalCtx) { - if (this->introCamera != SUBCAM_FREE) { - Math_ApproachF(&this->camData.eye.x, this->camData.nextEye.x, this->camData.eyeMaxVel.x, - this->camData.eyeVel.x * this->camData.speedMod); - Math_ApproachF(&this->camData.eye.y, this->camData.nextEye.y, this->camData.eyeMaxVel.y, - this->camData.eyeVel.y * this->camData.speedMod); - Math_ApproachF(&this->camData.eye.z, this->camData.nextEye.z, this->camData.eyeMaxVel.z, - this->camData.eyeVel.z * this->camData.speedMod); - Math_ApproachF(&this->camData.at.x, this->camData.nextAt.x, this->camData.atMaxVel.x, - this->camData.atVel.x * this->camData.speedMod); - Math_ApproachF(&this->camData.at.y, this->camData.nextAt.y, this->camData.atMaxVel.y, - this->camData.atVel.y * this->camData.speedMod); - Math_ApproachF(&this->camData.at.z, this->camData.nextAt.z, this->camData.atMaxVel.z, - this->camData.atVel.z * this->camData.speedMod); - Math_ApproachF(&this->camData.speedMod, 1.0f, 1.0f, this->camData.accel); - this->camData.at.y += this->camData.yMod; - Gameplay_CameraSetAtEye(globalCtx, this->introCamera, &this->camData.at, &this->camData.eye); - Math_ApproachZeroF(&this->camData.yMod, 1.0f, 0.1f); - } -} - -void BossFd_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossFd* this = (BossFd*)thisx; - s16 i; - - Flags_SetSwitch(globalCtx, 0x14); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BG_VB_SIMA, 680.0f, -100.0f, 0.0f, 0, 0, 0, - 100); - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - Actor_SetScale(&this->actor, 0.05f); - SkelAnime_Init(globalCtx, &this->skelAnimeHead, &gVolvagiaHeadSkel, &gVolvagiaHeadEmergeAnim, NULL, NULL, 0); - SkelAnime_Init(globalCtx, &this->skelAnimeRightArm, &gVolvagiaRightArmSkel, &gVolvagiaRightArmEmergeAnim, NULL, - NULL, 0); - SkelAnime_Init(globalCtx, &this->skelAnimeLeftArm, &gVolvagiaLeftArmSkel, &gVolvagiaLeftArmEmergeAnim, NULL, NULL, - 0); - this->introState = BFD_CS_WAIT; - if (this->introState == BFD_CS_NONE) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); - } - - this->actor.world.pos.x = this->actor.world.pos.z = 0.0f; - this->actor.world.pos.y = -200.0f; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->elements); - - for (i = 0; i < 100; i++) { - this->bodySegsPos[i].x = this->actor.world.pos.x; - this->bodySegsPos[i].y = this->actor.world.pos.y; - this->bodySegsPos[i].z = this->actor.world.pos.z; - if (i < 30) { - this->centerMane.pos[i].x = this->actor.world.pos.x; - this->centerMane.pos[i].y = this->actor.world.pos.y; - this->centerMane.pos[i].z = this->actor.world.pos.z; - } - } - - this->actor.colChkInfo.health = 24; - this->skinSegments = 18; - if (this->introState == BFD_CS_NONE) { - this->actionFunc = BossFd_Wait; - } else { - BossFd_SetupFly(this, globalCtx); - } - - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { - Actor_Kill(&this->actor); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 100.0f, 0.0f, 0, 0, 0, - WARP_DUNGEON_ADULT); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 100.0f, 200.0f, 0, 0, 0, 0); - } else { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_FD2, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, this->introState); - } -} - -void BossFd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossFd* this = (BossFd*)thisx; - - SkelAnime_Free(&this->skelAnimeHead, globalCtx); - SkelAnime_Free(&this->skelAnimeRightArm, globalCtx); - SkelAnime_Free(&this->skelAnimeLeftArm, globalCtx); - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -s32 BossFd_IsFacingLink(BossFd* this) { - return ABS((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)) < 0x2000; -} - -void BossFd_SetupFly(BossFd* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnimeHead, &gVolvagiaHeadEmergeAnim); - Animation_PlayOnce(&this->skelAnimeRightArm, &gVolvagiaRightArmEmergeAnim); - Animation_PlayOnce(&this->skelAnimeLeftArm, &gVolvagiaLeftArmEmergeAnim); - this->actionFunc = BossFd_Fly; - this->fwork[BFD_TURN_RATE_MAX] = 1000.0f; -} - -static Vec3f sHoleLocations[] = { - { 0.0f, 90.0f, -243.0f }, { 0.0f, 90.0f, 0.0f }, { 0.0f, 90.0f, 243.0f }, - { -243.0f, 90.0f, -243.0f }, { -243.0f, 90.0f, 0.0f }, { -243.0f, 90.0f, 243.0f }, - { 243.0f, 90.0f, -243.0f }, { 243.0f, 90.0f, 0.0f }, { 243.0f, 90.0f, 243.0f }, -}; - -static Vec3f sCeilingTargets[] = { - { 0.0f, 900.0f, -243.0f }, { 243.0, 900.0f, -100.0f }, { 243.0f, 900.0f, 100.0f }, - { 0.0f, 900.0f, 243.0f }, { -243.0f, 900.0f, 100.0f }, { -243.0, 900.0f, -100.0f }, -}; - -void BossFd_Fly(BossFd* this, GlobalContext* globalCtx) { - u8 sp1CF = false; - u8 temp_rand; - s16 i1; - s16 i2; - s16 i3; - f32 dx; - f32 dy; - f32 dz; - Player* player = GET_PLAYER(globalCtx); - f32 angleToTarget; - f32 pitchToTarget; - Vec3f* holePosition1; - f32 temp_y; - f32 temp_x; - f32 temp_z; - f32 temp; - - SkelAnime_Update(&this->skelAnimeHead); - SkelAnime_Update(&this->skelAnimeRightArm); - SkelAnime_Update(&this->skelAnimeLeftArm); - dx = this->targetPosition.x - this->actor.world.pos.x; - dy = this->targetPosition.y - this->actor.world.pos.y; - dz = this->targetPosition.z - this->actor.world.pos.z; - dx += Math_SinS((2096.0f + this->fwork[BFD_FLY_WOBBLE_RATE]) * this->work[BFD_MOVE_TIMER]) * - this->fwork[BFD_FLY_WOBBLE_AMP]; - dy += Math_SinS((1096.0f + this->fwork[BFD_FLY_WOBBLE_RATE]) * this->work[BFD_MOVE_TIMER]) * - this->fwork[BFD_FLY_WOBBLE_AMP]; - dz += Math_SinS((1796.0f + this->fwork[BFD_FLY_WOBBLE_RATE]) * this->work[BFD_MOVE_TIMER]) * - this->fwork[BFD_FLY_WOBBLE_AMP]; - angleToTarget = (s16)(Math_FAtan2F(dx, dz) * (0x8000 / M_PI)); - pitchToTarget = (s16)(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))) * (0x8000 / M_PI)); - - osSyncPrintf("MODE %d\n", this->work[BFD_ACTION_STATE]); - - Math_ApproachF(&this->fwork[BFD_BODY_PULSE], 0.1f, 1.0f, 0.02); - - // Boss Intro Cutscene - - if (this->introState != BFD_CS_NONE) { - Player* player2 = GET_PLAYER(globalCtx); - Camera* mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - - switch (this->introState) { - case BFD_CS_WAIT: - this->fogMode = 3; - this->targetPosition.x = 0.0f; - this->targetPosition.y = -110.0f; - this->targetPosition.z = 0.0; - this->fwork[BFD_TURN_RATE_MAX] = 10000.0f; - this->work[BFD_ACTION_STATE] = BOSSFD_WAIT_INTRO; - if ((fabsf(player2->actor.world.pos.z) < 80.0f) && - (fabsf(player2->actor.world.pos.x - 340.0f) < 60.0f)) { - - this->introState = BFD_CS_START; - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->introCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->introCamera, CAM_STAT_ACTIVE); - player2->actor.world.pos.x = 380.0f; - player2->actor.world.pos.y = 100.0f; - player2->actor.world.pos.z = 0.0f; - player2->actor.shape.rot.y = player2->actor.world.rot.y = -0x4000; - player2->actor.speedXZ = 0.0f; - this->camData.eye.x = player2->actor.world.pos.x - 70.0f; - this->camData.eye.y = player2->actor.world.pos.y + 40.0f; - this->camData.eye.z = player2->actor.world.pos.z + 70.0f; - this->camData.at.x = player2->actor.world.pos.x; - this->camData.at.y = player2->actor.world.pos.y + 30.0f; - this->camData.at.z = player2->actor.world.pos.z; - this->camData.nextEye.x = player2->actor.world.pos.x - 50.0f + 18.0f; - this->camData.nextEye.y = player2->actor.world.pos.y + 40; - this->camData.nextEye.z = player2->actor.world.pos.z + 50.0f - 18.0f; - this->camData.nextAt.x = player2->actor.world.pos.x; - this->camData.nextAt.y = player2->actor.world.pos.y + 50.0f; - this->camData.nextAt.z = player2->actor.world.pos.z; - BossFd_SetCameraSpeed(this, 1.0f); - this->camData.atMaxVel.x = this->camData.atMaxVel.y = this->camData.atMaxVel.z = 0.05f; - this->camData.eyeMaxVel.x = this->camData.eyeMaxVel.y = this->camData.eyeMaxVel.z = 0.05f; - this->timers[0] = 0; - this->camData.speedMod = 0.0f; - this->camData.accel = 0.0f; - if (gSaveContext.eventChkInf[7] & 8) { - this->introState = BFD_CS_EMERGE; - this->camData.nextEye.x = player2->actor.world.pos.x + 100.0f + 300.0f - 600.0f; - this->camData.nextEye.y = player2->actor.world.pos.y + 100.0f - 50.0f; - this->camData.nextEye.z = player2->actor.world.pos.z + 200.0f - 150.0f; - this->camData.nextAt.x = 0.0f; - this->camData.nextAt.y = 120.0f; - this->camData.nextAt.z = 0.0f; - BossFd_SetCameraSpeed(this, 0.5f); - this->camData.eyeMaxVel.x = this->camData.eyeMaxVel.y = this->camData.eyeMaxVel.z = 0.1f; - this->camData.atMaxVel.x = this->camData.atMaxVel.y = this->camData.atMaxVel.z = 0.1f; - this->camData.accel = 0.005f; - this->timers[0] = 0; - this->holeIndex = 1; - this->targetPosition.x = sHoleLocations[this->holeIndex].x; - this->targetPosition.y = sHoleLocations[this->holeIndex].y - 200.0f; - this->targetPosition.z = sHoleLocations[this->holeIndex].z; - this->timers[0] = 50; - this->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; - this->actor.world.rot.x = 0x4000; - this->work[BFD_MOVE_TIMER] = 0; - this->timers[3] = 250; - this->timers[2] = 470; - this->fwork[BFD_FLY_SPEED] = 5.0f; - } - } - break; - case BFD_CS_START: - if (this->timers[0] == 0) { - this->camData.accel = 0.0010000002f; - this->timers[0] = 100; - this->introState = BFD_CS_LOOK_LINK; - } - case BFD_CS_LOOK_LINK: - player2->actor.world.pos.x = 380.0f; - player2->actor.world.pos.y = 100.0f; - player2->actor.world.pos.z = 0.0f; - player2->actor.speedXZ = 0.0f; - player2->actor.shape.rot.y = player2->actor.world.rot.y = -0x4000; - if (this->timers[0] == 50) { - this->fogMode = 1; - } - if (this->timers[0] < 50) { - Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - this->camData.yMod = Math_CosS(this->work[BFD_MOVE_TIMER] * 0x8000) * this->camData.shake; - Math_ApproachF(&this->camData.shake, 2.0f, 1.0f, 0.8 * 0.01f); - } - if (this->timers[0] == 40) { - func_8002DF54(globalCtx, &this->actor, 0x13); - } - if (this->timers[0] == 0) { - this->introState = BFD_CS_LOOK_GROUND; - this->camData.nextAt.y = player2->actor.world.pos.y + 10.0f; - this->camData.atMaxVel.y = 0.2f; - this->camData.speedMod = 0.0f; - this->camData.accel = 0.02f; - this->timers[0] = 70; - this->work[BFD_MOVE_TIMER] = 0; - } - break; - case BFD_CS_LOOK_GROUND: - this->camData.yMod = Math_CosS(this->work[BFD_MOVE_TIMER] * 0x8000) * this->camData.shake; - Math_ApproachF(&this->camData.shake, 2.0f, 1.0f, 0.8 * 0.01f); - Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - if (this->timers[0] == 0) { - this->introState = BFD_CS_COLLAPSE; - this->camData.nextEye.x = player2->actor.world.pos.x + 100.0f + 300.0f; - this->camData.nextEye.y = player2->actor.world.pos.y + 100.0f; - this->camData.nextEye.z = player2->actor.world.pos.z + 200.0f; - this->camData.nextAt.x = player2->actor.world.pos.x; - this->camData.nextAt.y = player2->actor.world.pos.y - 150.0f; - this->camData.nextAt.z = player2->actor.world.pos.z - 50.0f; - BossFd_SetCameraSpeed(this, 0.1f); - this->timers[0] = 170; - this->camData.speedMod = 0.0f; - this->camData.accel = 0.0f; - func_8002DF54(globalCtx, &this->actor, 0x14); - } - break; - case BFD_CS_COLLAPSE: - this->camData.accel = 0.005f; - this->camData.yMod = Math_CosS(this->work[BFD_MOVE_TIMER] * 0x8000) * this->camData.shake; - Math_ApproachF(&this->camData.shake, 2.0f, 1.0f, 0.8 * 0.01f); - Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - if (this->timers[0] == 100) { - this->platformSignal = VBSIMA_COLLAPSE; - } - if (this->timers[0] == 0) { - this->introState = BFD_CS_EMERGE; - this->camData.speedMod = 0.0f; - this->camData.nextEye.x = player2->actor.world.pos.x + 100.0f + 300.0f - 600.0f; - this->camData.nextEye.y = player2->actor.world.pos.y + 100.0f - 50.0f; - this->camData.nextEye.z = player2->actor.world.pos.z + 200.0f - 150.0f; - this->camData.nextAt.x = 0.0f; - this->camData.nextAt.y = 120.0f; - this->camData.nextAt.z = 0.0f; - BossFd_SetCameraSpeed(this, 0.5f); - this->camData.atMaxVel.x = this->camData.atMaxVel.y = this->camData.atMaxVel.z = 0.1f; - this->camData.eyeMaxVel.x = this->camData.eyeMaxVel.y = this->camData.eyeMaxVel.z = 0.1f; - this->camData.accel = 0.005f; - this->timers[0] = 0; - this->holeIndex = 1; - this->targetPosition.x = sHoleLocations[this->holeIndex].x; - this->targetPosition.y = sHoleLocations[this->holeIndex].y - 200.0f; - this->targetPosition.z = sHoleLocations[this->holeIndex].z; - this->timers[0] = 50; - this->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; - this->actor.world.rot.x = 0x4000; - this->work[BFD_MOVE_TIMER] = 0; - this->timers[3] = 250; - this->timers[2] = 470; - this->fwork[BFD_FLY_SPEED] = 5.0f; - } - break; - case BFD_CS_EMERGE: - osSyncPrintf("WAY_SPD X = %f\n", this->camData.atVel.x); - osSyncPrintf("WAY_SPD Y = %f\n", this->camData.atVel.y); - osSyncPrintf("WAY_SPD Z = %f\n", this->camData.atVel.z); - if ((this->timers[3] > 190) && !(gSaveContext.eventChkInf[7] & 8)) { - Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - } - if (this->timers[3] == 190) { - this->camData.atMaxVel.x = this->camData.atMaxVel.y = this->camData.atMaxVel.z = 0.05f; - this->platformSignal = VBSIMA_KILL; - func_8002DF54(globalCtx, &this->actor, 1); - } - if (this->actor.world.pos.y > 120.0f) { - this->camData.nextAt = this->actor.world.pos; - this->camData.atVel.x = 190.0f; - this->camData.atVel.y = 85.56f; - this->camData.atVel.z = 25.0f; - } else { - // the following `temp` stuff is probably fake but is required to match - // it's optimized to 1.0f because sp1CF is false at this point, but the 0.1f ends up in rodata - temp = 0.1f; - if (!sp1CF) { - temp = 1.0f; - } - Math_ApproachF(&this->camData.shake, 2.0f, temp, 0.1 * 0.08f); - this->camData.yMod = Math_CosS(this->work[BFD_MOVE_TIMER] * 0x8000) * this->camData.shake; - } - if (this->timers[3] == 160) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); - } - if ((this->timers[3] == 130) && !(gSaveContext.eventChkInf[7] & 8)) { - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gVolvagiaBossTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); - } - if (this->timers[3] <= 100) { - this->camData.eyeVel.x = this->camData.eyeVel.y = this->camData.eyeVel.z = 2.0f; - this->camData.nextEye.x = player2->actor.world.pos.x + 50.0f; - this->camData.nextEye.y = player2->actor.world.pos.y + 50.0f; - this->camData.nextEye.z = player2->actor.world.pos.z + 50.0f; - } - if (this->work[BFD_ACTION_STATE] == BOSSFD_FLY_HOLE) { - switch (this->introFlyState) { - case INTRO_FLY_EMERGE: - this->timers[5] = 100; - this->introFlyState = INTRO_FLY_HOLE; - case INTRO_FLY_HOLE: - if (this->timers[5] == 0) { - this->introFlyState = INTRO_FLY_CAMERA; - this->timers[5] = 75; - } - break; - case INTRO_FLY_CAMERA: - this->targetPosition = this->camData.eye; - if (this->timers[5] == 0) { - this->timers[0] = 0; - this->holeIndex = 7; - this->targetPosition.x = sHoleLocations[this->holeIndex].x; - this->targetPosition.y = sHoleLocations[this->holeIndex].y + 200.0f + 50.0f; - this->targetPosition.z = sHoleLocations[this->holeIndex].z; - this->introFlyState = INTRO_FLY_RETRAT; - } - if (this->timers[5] == 30) { - this->work[BFD_ROAR_TIMER] = 40; - this->fireBreathTimer = 20; - } - case INTRO_FLY_RETRAT: - break; - } - } - osSyncPrintf("this->timer[2] = %d\n", this->timers[2]); - osSyncPrintf("this->timer[5] = %d\n", this->timers[5]); - if (this->timers[2] == 0) { - mainCam->eye = this->camData.eye; - mainCam->eyeNext = this->camData.eye; - mainCam->at = this->camData.at; - func_800C08AC(globalCtx, this->introCamera, 0); - this->introState = this->introFlyState = this->introCamera = BFD_CS_NONE; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->actionFunc = BossFd_Wait; - this->handoffSignal = FD2_SIGNAL_GROUND; - gSaveContext.eventChkInf[7] |= 8; - } - break; - } - BossFd_UpdateCamera(this, globalCtx); - } else { - this->fwork[BFD_FLY_SPEED] = 5.0f; - } - - // Attacks and Death Cutscene - - switch (this->work[BFD_ACTION_STATE]) { - case BOSSFD_FLY_MAIN: - sp1CF = true; - if (this->timers[0] == 0) { - if (this->actor.colChkInfo.health == 0) { - this->work[BFD_ACTION_STATE] = BOSSFD_DEATH_START; - this->timers[0] = 0; - this->timers[1] = 100; - } else { - if (this->introState != BFD_CS_NONE) { - this->holeIndex = 6; - } else { - do { - temp_rand = Rand_ZeroFloat(8.9f); - } while (temp_rand == this->holeIndex); - this->holeIndex = temp_rand; - } - this->targetPosition.x = sHoleLocations[this->holeIndex].x; - this->targetPosition.y = sHoleLocations[this->holeIndex].y + 200.0f + 50.0f; - this->targetPosition.z = sHoleLocations[this->holeIndex].z; - this->fwork[BFD_TURN_RATE] = 0.0f; - this->fwork[BFD_TURN_RATE_MAX] = 1000.0f; - if (this->introState != BFD_CS_NONE) { - this->timers[0] = 10050; - } else { - this->timers[0] = 20; - } - this->fwork[BFD_FLY_WOBBLE_AMP] = 100.0f; - this->work[BFD_ACTION_STATE] = BOSSFD_FLY_HOLE; - - if (this->work[BFD_START_ATTACK]) { - this->work[BFD_START_ATTACK] = false; - this->work[BFD_FLY_COUNT]++; - if (this->work[BFD_FLY_COUNT] & 1) { - this->work[BFD_ACTION_STATE] = BOSSFD_FLY_CHASE; - this->timers[0] = 300; - this->fwork[BFD_TURN_RATE_MAX] = 900.0f; - this->fwork[BFD_TARGET_Y_OFFSET] = 300.0f; - this->work[BFD_UNK_234] = this->work[BFD_UNK_236] = 0; - } else { - this->work[BFD_ACTION_STATE] = BOSSFD_FLY_CEILING; - } - } - } - } - break; - case BOSSFD_FLY_HOLE: - if ((this->timers[0] == 0) && (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 100.0f)) { - this->work[BFD_ACTION_STATE] = BOSSFD_BURROW; - this->targetPosition.y = sHoleLocations[this->holeIndex].y - 70.0f; - this->fwork[BFD_TURN_RATE_MAX] = 10000.0f; - this->fwork[BFD_FLY_WOBBLE_AMP] = 0.0f; - this->timers[0] = 150; - this->work[BFD_ROAR_TIMER] = 40; - this->holePosition.x = this->targetPosition.x; - this->holePosition.z = this->targetPosition.z; - } - break; - case BOSSFD_BURROW: - sp1CF = true; - if (this->timers[0] == 0) { - this->actionFunc = BossFd_Wait; - this->handoffSignal = FD2_SIGNAL_GROUND; - } - break; - case BOSSFD_EMERGE: - if ((this->timers[0] == 0) && (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 100.0f)) { - this->actor.world.pos = this->targetPosition; - this->work[BFD_ACTION_STATE] = BOSSFD_FLY_MAIN; - this->actor.world.rot.x = 0x4000; - this->targetPosition.y = sHoleLocations[this->holeIndex].y + 200.0f; - this->timers[4] = 80; - this->fwork[BFD_TURN_RATE_MAX] = 1000.0f; - this->fwork[BFD_FLY_WOBBLE_AMP] = 0.0f; - this->holePosition.x = this->targetPosition.x; - this->holePosition.z = this->targetPosition.z; - - func_80033E1C(globalCtx, 1, 0x50, 0x5000); - if (this->introState != BFD_CS_NONE) { - this->timers[0] = 50; - } else { - this->timers[0] = 50; - } - } - break; - case BOSSFD_FLY_CEILING: - this->fwork[BFD_FLY_SPEED] = 8; - this->targetPosition.x = 0.0f; - this->targetPosition.y = 700.0f; - this->targetPosition.z = -300.0f; - this->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; - this->fwork[BFD_TURN_RATE_MAX] = 3000.0f; - if (this->actor.world.pos.y > 700.0f) { - this->work[BFD_ACTION_STATE] = BOSSFD_DROP_ROCKS; - this->timers[0] = 25; - this->timers[2] = 150; - this->work[BFD_CEILING_TARGET] = 0; - } - break; - case BOSSFD_DROP_ROCKS: - this->fwork[BFD_FLY_SPEED] = 8; - this->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; - this->fwork[BFD_TURN_RATE_MAX] = 10000.0f; - this->targetPosition.x = sCeilingTargets[this->work[BFD_CEILING_TARGET]].x; - this->targetPosition.y = sCeilingTargets[this->work[BFD_CEILING_TARGET]].y + 900.0f; - this->targetPosition.z = sCeilingTargets[this->work[BFD_CEILING_TARGET]].z; - if (this->timers[0] == 0) { - this->timers[0] = 25; - this->work[BFD_CEILING_TARGET]++; - if (this->work[BFD_CEILING_TARGET] >= 6) { - this->work[BFD_CEILING_TARGET] = 0; - } - } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 2); - if (this->timers[1] == 0) { - osSyncPrintf("BGCHECKKKKKKKKKKKKKKKKKKKKKKK\n"); - if (this->actor.bgCheckFlags & 0x10) { - this->fwork[BFD_CEILING_BOUNCE] = -18384.0f; - this->timers[1] = 10; - Audio_PlaySoundGeneral(NA_SE_EV_EXPLOSION, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_80033E1C(globalCtx, 3, 0xA, 0x7530); - this->work[BFD_ROCK_TIMER] = 300; - } - } else { - pitchToTarget = this->fwork[BFD_CEILING_BOUNCE]; - Math_ApproachZeroF(&this->fwork[BFD_CEILING_BOUNCE], 1.0f, 1000.0f); - } - if (this->timers[2] == 0) { - this->work[BFD_ACTION_STATE] = BOSSFD_FLY_MAIN; - this->timers[0] = 0; - this->work[BFD_START_ATTACK] = false; - } - break; - case BOSSFD_FLY_CHASE: - this->actor.flags |= ACTOR_FLAG_24; - temp_y = Math_SinS(this->work[BFD_MOVE_TIMER] * 2396.0f) * 30.0f + this->fwork[BFD_TARGET_Y_OFFSET]; - this->targetPosition.x = player->actor.world.pos.x; - this->targetPosition.y = player->actor.world.pos.y + temp_y + 30.0f; - this->targetPosition.z = player->actor.world.pos.z; - this->fwork[BFD_FLY_WOBBLE_AMP] = 0.0f; - if (((this->timers[0] % 64) == 0) && (this->timers[0] < 450)) { - this->work[BFD_ROAR_TIMER] = 40; - if (BossFd_IsFacingLink(this)) { - this->fireBreathTimer = 20; - } - } - if ((this->work[BFD_DAMAGE_FLASH_TIMER] != 0) || (this->timers[0] == 0) || - (player->actor.world.pos.y < 70.0f)) { - this->work[BFD_ACTION_STATE] = BOSSFD_FLY_MAIN; - this->timers[0] = 0; - this->work[BFD_START_ATTACK] = false; - } else { - Math_ApproachF(&this->fwork[BFD_TARGET_Y_OFFSET], 50.0, 1.0f, 2.0f); - } - break; - case BOSSFD_DEATH_START: - if (sqrtf(SQ(dx) + SQ(dz)) < 50.0f) { - this->timers[0] = 0; - } - if (this->timers[0] == 0) { - this->timers[0] = (s16)Rand_ZeroFloat(10.0f) + 10; - do { - this->targetPosition.x = Rand_CenteredFloat(200.0f); - this->targetPosition.y = 390.0f; - this->targetPosition.z = Rand_CenteredFloat(200.0f); - temp_x = this->targetPosition.x - this->actor.world.pos.x; - temp_z = this->targetPosition.z - this->actor.world.pos.z; - } while (!(sqrtf(SQ(temp_x) + SQ(temp_z)) > 100.0f)); - } - this->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; - this->fwork[BFD_FLY_WOBBLE_RATE] = 1000.0f; - this->fwork[BFD_TURN_RATE_MAX] = 10000.0f; - Math_ApproachF(&this->fwork[BFD_BODY_PULSE], 0.3f, 1.0f, 0.05f); - if (this->timers[1] == 0) { - this->work[BFD_ACTION_STATE] = BOSSFD_SKIN_BURN; - this->timers[0] = 30; - } - break; - case BOSSFD_SKIN_BURN: - this->targetPosition.x = 0.0f; - this->targetPosition.y = 390.0f; - this->targetPosition.z = 0.0f; - this->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; - this->fwork[BFD_FLY_WOBBLE_RATE] = 1000.0f; - this->fwork[BFD_TURN_RATE_MAX] = 2000.0f; - Math_ApproachF(&this->fwork[BFD_BODY_PULSE], 0.3f, 1.0f, 0.05f); - if ((this->timers[0] == 0) && ((this->work[BFD_MOVE_TIMER] % 4) == 0)) { - if (this->skinSegments != 0) { - this->skinSegments--; - if (this->skinSegments == 0) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - } - } else { - this->work[BFD_ACTION_STATE] = BOSSFD_BONES_FALL; - this->timers[0] = 30; - } - } - if ((this->work[BFD_MOVE_TIMER] % 32) == 0) { - this->work[BFD_ROAR_TIMER] = 40; - } - - if (this->skinSegments != 0) { - Vec3f sp188; - Vec3f sp17C = { 0.0f, 0.0f, 0.0f }; - Vec3f sp170; - Vec3f sp164 = { 0.0f, 0.03f, 0.0f }; - Vec3f sp158; - f32 pad154; - s16 temp_rand2; - s16 sp150; - - if (this->fogMode == 0) { - globalCtx->envCtx.unk_D8 = 0; - } - this->fogMode = 0xA; - - sp150 = 1; - if (this->work[BFD_MOVE_TIMER] & 0x1C) { - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_BURN - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - } - for (i1 = 0; i1 < sp150; i1++) { - if (sp150) { // Needed for matching - temp_rand2 = Rand_ZeroFloat(99.9f); - - sp188.x = this->bodySegsPos[temp_rand2].x; - sp188.y = this->bodySegsPos[temp_rand2].y - 10.0f; - sp188.z = this->bodySegsPos[temp_rand2].z; - - sp164.y = 0.03f; - - EffectSsKFire_Spawn(globalCtx, &sp188, &sp17C, &sp164, (s16)Rand_ZeroFloat(20.0f) + 40, 0x64); - - for (i2 = 0; i2 < 15; i2++) { - sp170.x = Rand_CenteredFloat(20.0f); - sp170.y = Rand_CenteredFloat(20.0f); - sp170.z = Rand_CenteredFloat(20.0f); - - sp158.y = 0.4f; - sp158.x = Rand_CenteredFloat(0.5f); - sp158.z = Rand_CenteredFloat(0.5f); - - BossFd_SpawnEmber(this->effects, &sp188, &sp170, &sp158, (s16)Rand_ZeroFloat(3.0f) + 8); - } - } - } - } - break; - case BOSSFD_BONES_FALL: - this->work[BFD_STOP_FLAG] = true; - this->fogMode = 3; - if (this->timers[0] < 18) { - this->bodyFallApart[this->timers[0]] = 1; - } - if (this->timers[0] == 0) { - this->work[BFD_ACTION_STATE] = BOSSFD_SKULL_PAUSE; - this->timers[0] = 15; - this->work[BFD_CEILING_TARGET] = 0; - player->actor.world.pos.y = 90.0f; - player->actor.world.pos.x = 40.0f; - player->actor.world.pos.z = 150.0f; - } - break; - case BOSSFD_SKULL_PAUSE: - if (this->timers[0] == 0) { - this->work[BFD_ACTION_STATE] = BOSSFD_SKULL_FALL; - this->timers[0] = 20; - this->work[BFD_STOP_FLAG] = false; - } - break; - case BOSSFD_SKULL_FALL: - this->fwork[BFD_TURN_RATE] = this->fwork[BFD_TURN_RATE_MAX] = this->actor.speedXZ = - this->fwork[BFD_FLY_SPEED] = 0; - - if (this->timers[0] == 1) { - this->actor.world.pos.x = 0; - this->actor.world.pos.y = 900.0f; - this->actor.world.pos.z = 150.0f; - this->actor.world.rot.x = this->actor.world.rot.y = 0; - this->actor.shape.rot.z = 0x1200; - this->actor.velocity.x = 0; - this->actor.velocity.z = 0; - } - if (this->timers[0] == 0) { - if (this->actor.world.pos.y <= 110.0f) { - this->actor.world.pos.y = 110.0f; - this->actor.velocity.y = 0; - if (this->work[BFD_CEILING_TARGET] == 0) { - this->work[BFD_CEILING_TARGET]++; - this->timers[1] = 60; - this->work[BFD_CAM_SHAKE_TIMER] = 20; - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_LAND2, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - func_8002DF54(globalCtx, &this->actor, 5); - for (i1 = 0; i1 < 15; i1++) { - Vec3f sp144 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp138 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp12C; - - sp144.x = Rand_CenteredFloat(8.0f); - sp144.y = Rand_ZeroFloat(1.0f); - sp144.z = Rand_CenteredFloat(8.0f); - - sp138.y = 0.3f; - - sp12C.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; - sp12C.y = Rand_CenteredFloat(10.0f) + this->actor.world.pos.y; - sp12C.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; - BossFd_SpawnDust(this->effects, &sp12C, &sp144, &sp138, Rand_ZeroFloat(100.0f) + 300); - } - } - } else { - this->actor.velocity.y -= 1.0f; - } - } else { - this->actor.velocity.y = 0; - } - if (this->timers[1] == 1) { - this->work[BFD_ACTION_STATE] = BOSSFD_SKULL_BURN; - this->timers[0] = 70; - } - break; - case BOSSFD_SKULL_BURN: - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = 110.0f; - this->fwork[BFD_TURN_RATE] = this->fwork[BFD_TURN_RATE_MAX] = this->actor.speedXZ = - this->fwork[BFD_FLY_SPEED] = 0.0f; - - if ((50 > this->timers[0]) && (this->timers[0] > 0)) { - Vec3f sp120; - Vec3f sp114 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp108 = { 0.0f, 0.03f, 0.0f }; - - Audio_PlaySoundGeneral(NA_SE_EN_GOMA_LAST - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - - sp120.x = Rand_CenteredFloat(40.0f) + this->actor.world.pos.x; - sp120.y = (Rand_CenteredFloat(10.0f) + this->actor.world.pos.y) - 10.0f; - sp120.z = (Rand_CenteredFloat(40.0f) + this->actor.world.pos.z) + 5.0f; - - sp108.y = 0.03f; - - EffectSsKFire_Spawn(globalCtx, &sp120, &sp114, &sp108, (s16)Rand_ZeroFloat(15.0f) + 30, 0); - } - if (this->timers[0] < 20) { - Math_ApproachZeroF(&this->actor.scale.x, 1.0f, 0.0025f); - Actor_SetScale(&this->actor, this->actor.scale.x); - } - if (this->timers[0] == 0) { - this->actionFunc = BossFd_Wait; - this->actor.world.pos.y -= 1000.0f; - } - if (this->timers[0] == 7) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - } - break; - case BOSSFD_WAIT_INTRO: - break; - } - - // Update body segments and mane - - if (!this->work[BFD_STOP_FLAG]) { - s16 i4; - Vec3f spE0[3]; - Vec3f spBC[3]; - f32 phi_f20; - f32 padB4; - f32 padB0; - f32 padAC; - - Math_ApproachS(&this->actor.world.rot.y, angleToTarget, 0xA, this->fwork[BFD_TURN_RATE]); - - if (((this->work[BFD_ACTION_STATE] == BOSSFD_FLY_CHASE) || - (this->work[BFD_ACTION_STATE] == BOSSFD_FLY_UNUSED)) && - (this->actor.world.pos.y < 110.0f) && (pitchToTarget < 0)) { - pitchToTarget = 0; - Math_ApproachF(&this->actor.world.pos.y, 110.0f, 1.0f, 5.0f); - } - - Math_ApproachS(&this->actor.world.rot.x, pitchToTarget, 0xA, this->fwork[BFD_TURN_RATE]); - Math_ApproachF(&this->fwork[BFD_TURN_RATE], this->fwork[BFD_TURN_RATE_MAX], 1.0f, 20000.0f); - Math_ApproachF(&this->actor.speedXZ, this->fwork[BFD_FLY_SPEED], 1.0f, 0.1f); - if (this->work[BFD_ACTION_STATE] < BOSSFD_SKULL_FALL) { - func_8002D908(&this->actor); - } - func_8002D7EC(&this->actor); - - this->work[BFD_LEAD_BODY_SEG]++; - if (this->work[BFD_LEAD_BODY_SEG] >= 100) { - this->work[BFD_LEAD_BODY_SEG] = 0; - } - i4 = this->work[BFD_LEAD_BODY_SEG]; - this->bodySegsPos[i4].x = this->actor.world.pos.x; - this->bodySegsPos[i4].y = this->actor.world.pos.y; - this->bodySegsPos[i4].z = this->actor.world.pos.z; - this->bodySegsRot[i4].x = (this->actor.world.rot.x / (f32)0x8000) * M_PI; - this->bodySegsRot[i4].y = (this->actor.world.rot.y / (f32)0x8000) * M_PI; - this->bodySegsRot[i4].z = (this->actor.world.rot.z / (f32)0x8000) * M_PI; - - this->work[BFD_LEAD_MANE_SEG]++; - if (this->work[BFD_LEAD_MANE_SEG] >= 30) { - this->work[BFD_LEAD_MANE_SEG] = 0; - } - i4 = this->work[BFD_LEAD_MANE_SEG]; - this->centerMane.scale[i4] = (Math_SinS(this->work[BFD_MOVE_TIMER] * 5596.0f) * 0.3f) + 1.0f; - this->rightMane.scale[i4] = (Math_SinS(this->work[BFD_MOVE_TIMER] * 5496.0f) * 0.3f) + 1.0f; - this->leftMane.scale[i4] = (Math_CosS(this->work[BFD_MOVE_TIMER] * 5696.0f) * 0.3f) + 1.0f; - this->centerMane.pos[i4] = this->centerMane.head; - this->fireManeRot[i4].x = (this->actor.world.rot.x / (f32)0x8000) * M_PI; - this->fireManeRot[i4].y = (this->actor.world.rot.y / (f32)0x8000) * M_PI; - this->fireManeRot[i4].z = (this->actor.world.rot.z / (f32)0x8000) * M_PI; - this->rightMane.pos[i4] = this->rightMane.head; - this->leftMane.pos[i4] = this->leftMane.head; - - if ((0x3000 > this->actor.world.rot.x) && (this->actor.world.rot.x > -0x3000)) { - Math_ApproachF(&this->flattenMane, 1.0f, 1.0f, 0.05f); - } else { - Math_ApproachF(&this->flattenMane, 0.5f, 1.0f, 0.05f); - } - - if (this->work[BFD_ACTION_STATE] < BOSSFD_SKULL_FALL) { - if ((this->actor.prevPos.y < 90.0f) && (90.0f <= this->actor.world.pos.y)) { - this->timers[4] = 80; - func_80033E1C(globalCtx, 1, 80, 0x5000); - this->work[BFD_ROAR_TIMER] = 40; - this->work[BFD_MANE_EMBERS_TIMER] = 30; - this->work[BFD_SPLASH_TIMER] = 10; - } - if ((this->actor.prevPos.y > 90.0f) && (90.0f >= this->actor.world.pos.y)) { - this->timers[4] = 80; - func_80033E1C(globalCtx, 1, 80, 0x5000); - this->work[BFD_MANE_EMBERS_TIMER] = 30; - this->work[BFD_SPLASH_TIMER] = 10; - } - } - - if (!sp1CF) { - spE0[0].x = spE0[0].y = Math_SinS(this->work[BFD_MOVE_TIMER] * 1500.0f) * 3000.0f; - spE0[1].x = Math_SinS(this->work[BFD_MOVE_TIMER] * 2000.0f) * 4000.0f; - spE0[1].y = Math_SinS(this->work[BFD_MOVE_TIMER] * 2200.0f) * 4000.0f; - spE0[2].x = Math_SinS(this->work[BFD_MOVE_TIMER] * 1700.0f) * 2000.0f; - spE0[2].y = Math_SinS(this->work[BFD_MOVE_TIMER] * 1900.0f) * 2000.0f; - spBC[0].x = spBC[0].y = Math_SinS(this->work[BFD_MOVE_TIMER] * 1500.0f) * -3000.0f; - spBC[1].x = Math_SinS(this->work[BFD_MOVE_TIMER] * 2200.0f) * -4000.0f; - spBC[1].y = Math_SinS(this->work[BFD_MOVE_TIMER] * 2000.0f) * -4000.0f; - spBC[2].x = Math_SinS(this->work[BFD_MOVE_TIMER] * 1900.0f) * -2000.0f; - spBC[2].y = Math_SinS(this->work[BFD_MOVE_TIMER] * 1700.0f) * -2000.0f; - - for (i3 = 0; i3 < 3; i3++) { - Math_ApproachF(&this->rightArmRot[i3].x, spE0[i3].x, 1.0f, 1000.0f); - Math_ApproachF(&this->rightArmRot[i3].y, spE0[i3].y, 1.0f, 1000.0f); - Math_ApproachF(&this->leftArmRot[i3].x, spBC[i3].x, 1.0f, 1000.0f); - Math_ApproachF(&this->leftArmRot[i3].y, spBC[i3].y, 1.0f, 1000.0f); - } - } else { - for (i2 = 0; i2 < 3; i2++) { - phi_f20 = 0.0f; - Math_ApproachZeroF(&this->rightArmRot[i2].y, 0.1f, 100.0f); - Math_ApproachZeroF(&this->leftArmRot[i2].y, 0.1f, 100.0f); - if (i2 == 0) { - phi_f20 = -3000.0f; - } - Math_ApproachF(&this->rightArmRot[i2].x, phi_f20, 0.1f, 100.0f); - Math_ApproachF(&this->leftArmRot[i2].x, -phi_f20, 0.1f, 100.0f); - } - } - } -} - -void BossFd_Wait(BossFd* this, GlobalContext* globalCtx) { - if (this->handoffSignal == FD2_SIGNAL_FLY) { // Set by BossFd2 - u8 temp_rand; - - this->handoffSignal = FD2_SIGNAL_NONE; - BossFd_SetupFly(this, globalCtx); - do { - temp_rand = Rand_ZeroFloat(8.9f); - } while (temp_rand == this->holeIndex); - this->holeIndex = temp_rand; - if (1) {} // Needed for matching - this->targetPosition.x = sHoleLocations[this->holeIndex].x; - this->targetPosition.y = sHoleLocations[this->holeIndex].y - 200.0f; - this->targetPosition.z = sHoleLocations[this->holeIndex].z; - this->actor.world.pos = this->targetPosition; - - this->timers[0] = 10; - this->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; - this->work[BFD_START_ATTACK] = true; - } - if (this->handoffSignal == FD2_SIGNAL_DEATH) { - this->handoffSignal = FD2_SIGNAL_NONE; - BossFd_SetupFly(this, globalCtx); - this->holeIndex = 1; - this->targetPosition.x = sHoleLocations[1].x; - this->targetPosition.y = sHoleLocations[1].y - 200.0f; - this->targetPosition.z = sHoleLocations[1].z; - this->actor.world.pos = this->targetPosition; - this->timers[0] = 10; - this->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; - } -} - -static Vec3f sFireAudioVec = { 0.0f, 0.0f, 50.0f }; - -void BossFd_Effects(BossFd* this, GlobalContext* globalCtx) { - static Color_RGBA8 colorYellow = { 255, 255, 0, 255 }; - static Color_RGBA8 colorRed = { 255, 10, 0, 255 }; - s16 breathOpacity = 0; - f32 jawAngle; - f32 jawSpeed; - f32 emberRate; - f32 emberSpeed; - s16 eyeStates[] = { EYE_OPEN, EYE_HALF, EYE_CLOSED, EYE_CLOSED, EYE_HALF }; - f32 temp_x; - f32 temp_z; - s16 i; - - if (1) {} // Needed for match - - if (this->fogMode == 0) { - globalCtx->envCtx.unk_BF = 0; - globalCtx->envCtx.unk_D8 = 0.5f + 0.5f * Math_SinS(this->work[BFD_VAR_TIMER] * 0x500); - globalCtx->envCtx.unk_DC = 2; - globalCtx->envCtx.unk_BD = 1; - globalCtx->envCtx.unk_BE = 0; - } else if (this->fogMode == 3) { - globalCtx->envCtx.unk_BF = 0; - globalCtx->envCtx.unk_DC = 2; - globalCtx->envCtx.unk_BD = 2; - globalCtx->envCtx.unk_BE = 0; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); - } else if (this->fogMode == 2) { - this->fogMode--; - globalCtx->envCtx.unk_BF = 0; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.55f + 0.05f * Math_SinS(this->work[BFD_VAR_TIMER] * 0x3E00), 1.0f, - 0.15f); - globalCtx->envCtx.unk_DC = 2; - globalCtx->envCtx.unk_BD = 3; - globalCtx->envCtx.unk_BE = 0; - } else if (this->fogMode == 10) { - this->fogMode = 1; - globalCtx->envCtx.unk_BF = 0; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.21f + 0.07f * Math_SinS(this->work[BFD_VAR_TIMER] * 0xC00), 1.0f, - 0.05f); - globalCtx->envCtx.unk_DC = 2; - globalCtx->envCtx.unk_BD = 3; - globalCtx->envCtx.unk_BE = 0; - } else if (this->fogMode == 1) { - Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.0f, 1.0f, 0.03f); - if (globalCtx->envCtx.unk_D8 <= 0.01f) { - this->fogMode = 0; - } - } - - if (this->work[BFD_MANE_EMBERS_TIMER] != 0) { - this->work[BFD_MANE_EMBERS_TIMER]--; - emberSpeed = emberRate = 20.0f; - } else { - emberRate = 3.0f; - emberSpeed = 5.0f; - } - Math_ApproachF(&this->fwork[BFD_MANE_EMBER_RATE], emberRate, 1.0f, 0.1f); - Math_ApproachF(&this->fwork[BFD_MANE_EMBER_SPEED], emberSpeed, 1.0f, 0.5f); - - if (((this->work[BFD_VAR_TIMER] % 8) == 0) && (Rand_ZeroOne() < 0.3f)) { - this->work[BFD_BLINK_TIMER] = 4; - } - this->eyeState = eyeStates[this->work[BFD_BLINK_TIMER]]; - - if (this->work[BFD_BLINK_TIMER] != 0) { - this->work[BFD_BLINK_TIMER]--; - } - - if (this->work[BFD_ROAR_TIMER] != 0) { - if (this->work[BFD_ROAR_TIMER] == 37) { - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_ROAR, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - jawAngle = 6000.0f; - jawSpeed = 1300.0f; - } else { - jawAngle = (this->work[BFD_VAR_TIMER] & 0x10) ? 0.0f : 1000.0f; - jawSpeed = 500.0f; - } - Math_ApproachF(&this->jawOpening, jawAngle, 0.3f, jawSpeed); - - if (this->work[BFD_ROAR_TIMER] != 0) { - this->work[BFD_ROAR_TIMER]--; - } - - if (this->timers[4] != 0) { - Vec3f spawnVel1; - Vec3f spawnAccel1; - Vec3f spawnPos1; - s32 pad; - - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_APPEAR - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - if (this->work[BFD_SPLASH_TIMER] != 0) { - this->work[BFD_SPLASH_TIMER]--; - if ((this->actor.colChkInfo.health == 0) || - ((this->introState == BFD_CS_EMERGE) && (this->actor.world.rot.x > 0x3000))) { - if ((u8)this->fogMode == 0) { - globalCtx->envCtx.unk_D8 = 0.0f; - } - this->fogMode = 2; - } - for (i = 0; i < 5; i++) { - spawnVel1.x = Rand_CenteredFloat(20.0f); - spawnVel1.y = Rand_ZeroFloat(5.0f) + 4.0f; - spawnVel1.z = Rand_CenteredFloat(20.0f); - - spawnAccel1.x = spawnAccel1.z = 0.0f; - spawnAccel1.y = -0.3f; - - temp_x = (spawnVel1.x * 20) / 10.0f; - temp_z = (spawnVel1.z * 20) / 10.0f; - spawnPos1.x = temp_x + this->holePosition.x; - spawnPos1.y = 100.0f; - spawnPos1.z = temp_z + this->holePosition.z; - - func_8002836C(globalCtx, &spawnPos1, &spawnVel1, &spawnAccel1, &colorYellow, &colorRed, - (s16)Rand_ZeroFloat(150.0f) + 800, 10, (s16)Rand_ZeroFloat(5.0f) + 17); - } - } else { - for (i = 0; i < 2; i++) { - spawnVel1.x = Rand_CenteredFloat(10.0f); - spawnVel1.y = Rand_ZeroFloat(3.0f) + 3.0f; - spawnVel1.z = Rand_CenteredFloat(10.0f); - - spawnAccel1.x = spawnAccel1.z = 0.0f; - spawnAccel1.y = -0.3f; - temp_x = (spawnVel1.x * 50) / 10.0f; - temp_z = (spawnVel1.z * 50) / 10.0f; - - spawnPos1.x = temp_x + this->holePosition.x; - spawnPos1.y = 100.0f; - spawnPos1.z = temp_z + this->holePosition.z; - - func_8002836C(globalCtx, &spawnPos1, &spawnVel1, &spawnAccel1, &colorYellow, &colorRed, 500, 10, 20); - } - } - - for (i = 0; i < 8; i++) { - spawnVel1.x = Rand_CenteredFloat(20.0f); - spawnVel1.y = Rand_ZeroFloat(10.0f); - spawnVel1.z = Rand_CenteredFloat(20.0f); - - spawnAccel1.y = 0.4f; - spawnAccel1.x = Rand_CenteredFloat(0.5f); - spawnAccel1.z = Rand_CenteredFloat(0.5f); - - spawnPos1.x = Rand_CenteredFloat(60.0) + this->holePosition.x; - spawnPos1.y = Rand_ZeroFloat(40.0f) + 100.0f; - spawnPos1.z = Rand_CenteredFloat(60.0) + this->holePosition.z; - - BossFd_SpawnEmber(this->effects, &spawnPos1, &spawnVel1, &spawnAccel1, (s16)Rand_ZeroFloat(1.5f) + 6); - } - } - - if ((this->fireBreathTimer != 0) && (this->fireBreathTimer < 17)) { - breathOpacity = (this->fireBreathTimer >= 6) ? 255 : this->fireBreathTimer * 50; - } - if (breathOpacity != 0) { - f32 spawnAngleX; - f32 spawnAngleY; - Vec3f spawnSpeed2 = { 0.0f, 0.0f, 0.0f }; - Vec3f spawnVel2; - Vec3f spawnAccel2 = { 0.0f, 0.0f, 0.0f }; - Vec3f spawnPos2; - - this->fogMode = 2; - spawnSpeed2.z = 30.0f; - - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_FIRE - SFX_FLAG, &sFireAudioVec, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - spawnPos2 = this->headPos; - - spawnAngleY = (this->actor.world.rot.y / (f32)0x8000) * M_PI; - spawnAngleX = (((-this->actor.world.rot.x) / (f32)0x8000) * M_PI) + 0.3f; - Matrix_RotateY(spawnAngleY, MTXMODE_NEW); - Matrix_RotateX(spawnAngleX, MTXMODE_APPLY); - Matrix_MultVec3f(&spawnSpeed2, &spawnVel2); - - BossFd_SpawnFireBreath(this->effects, &spawnPos2, &spawnVel2, &spawnAccel2, - 50.0f * Math_SinS(this->work[BFD_VAR_TIMER] * 0x2000) + 300.0f, breathOpacity, - this->actor.world.rot.y); - - spawnPos2.x += spawnVel2.x * 0.5f; - spawnPos2.y += spawnVel2.y * 0.5f; - spawnPos2.z += spawnVel2.z * 0.5f; - - BossFd_SpawnFireBreath(this->effects, &spawnPos2, &spawnVel2, &spawnAccel2, - 50.0f * Math_SinS(this->work[BFD_VAR_TIMER] * 0x2000) + 300.0f, breathOpacity, - this->actor.world.rot.y); - spawnSpeed2.x = 0.0f; - spawnSpeed2.y = 17.0f; - spawnSpeed2.z = 0.0f; - - for (i = 0; i < 6; i++) { - spawnAngleY = Rand_ZeroFloat(2.0f * M_PI); - spawnAngleX = Rand_ZeroFloat(2.0f * M_PI); - Matrix_RotateY(spawnAngleY, MTXMODE_NEW); - Matrix_RotateX(spawnAngleX, MTXMODE_APPLY); - Matrix_MultVec3f(&spawnSpeed2, &spawnVel2); - - spawnAccel2.x = (spawnVel2.x * -10) / 100; - spawnAccel2.y = (spawnVel2.y * -10) / 100; - spawnAccel2.z = (spawnVel2.z * -10) / 100; - - BossFd_SpawnEmber(this->effects, &this->headPos, &spawnVel2, &spawnAccel2, (s16)Rand_ZeroFloat(2.0f) + 8); - } - } - - if ((this->actor.world.pos.y < 90.0f) || (700.0f < this->actor.world.pos.y) || (this->actionFunc == BossFd_Wait)) { - this->actor.flags &= ~ACTOR_FLAG_0; - } else { - this->actor.flags |= ACTOR_FLAG_0; - } -} - -void BossFd_CollisionCheck(BossFd* this, GlobalContext* globalCtx) { - ColliderJntSphElement* headCollider = &this->collider.elements[0]; - ColliderInfo* hurtbox; - - if (headCollider->info.bumperFlags & BUMP_HIT) { - headCollider->info.bumperFlags &= ~BUMP_HIT; - hurtbox = headCollider->info.acHitInfo; - this->actor.colChkInfo.health -= 2; - if (hurtbox->toucher.dmgFlags & 0x1000) { - this->actor.colChkInfo.health -= 2; - } - if ((s8)this->actor.colChkInfo.health <= 2) { - this->actor.colChkInfo.health = 2; - } - this->work[BFD_DAMAGE_FLASH_TIMER] = 10; - this->work[BFD_INVINC_TIMER] = 20; - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_DAMAGE1, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void BossFd_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossFd* this = (BossFd*)thisx; - f32 headGlow; - f32 rManeGlow; - f32 lManeGlow; - s16 i; - - osSyncPrintf("FD MOVE START \n"); - this->work[BFD_VAR_TIMER]++; - this->work[BFD_MOVE_TIMER]++; - this->actionFunc(this, globalCtx); - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - if (this->fireBreathTimer != 0) { - this->fireBreathTimer--; - } - if (this->work[BFD_DAMAGE_FLASH_TIMER] != 0) { - this->work[BFD_DAMAGE_FLASH_TIMER]--; - } - if (this->work[BFD_INVINC_TIMER] != 0) { - this->work[BFD_INVINC_TIMER]--; - } - if (this->work[BFD_ACTION_STATE] < BOSSFD_DEATH_START) { - if (this->work[BFD_INVINC_TIMER] == 0) { - BossFd_CollisionCheck(this, globalCtx); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - BossFd_Effects(this, globalCtx); - this->fwork[BFD_TEX1_SCROLL_X] += 4.0f; - this->fwork[BFD_TEX1_SCROLL_Y] = 120.0f; - this->fwork[BFD_TEX2_SCROLL_X] += 3.0f; - this->fwork[BFD_TEX2_SCROLL_Y] -= 2.0f; - - Math_ApproachF(&this->fwork[BFD_BODY_TEX2_ALPHA], (this->work[BFD_VAR_TIMER] & 0x10) ? 30.0f : 158.0f, 1.0f, 8.0f); - if (this->skinSegments == 0) { - this->fwork[BFD_HEAD_TEX2_ALPHA] = this->fwork[BFD_BODY_TEX2_ALPHA]; - } else { - headGlow = (this->work[BFD_VAR_TIMER] & 4) ? 0.0f : 255.0f; - Math_ApproachF(&this->fwork[BFD_HEAD_TEX2_ALPHA], headGlow, 1.0f, 64.0f); - } - - headGlow = (this->work[BFD_VAR_TIMER] & 8) ? 128.0f : 255.0f; - rManeGlow = ((this->work[BFD_VAR_TIMER] + 3) & 8) ? 128.0f : 255.0f; - lManeGlow = ((this->work[BFD_VAR_TIMER] + 6) & 8) ? 128.0f : 255.0f; - - Math_ApproachF(&this->fwork[BFD_MANE_COLOR_CENTER], headGlow, 1.0f, 16.0f); - Math_ApproachF(&this->fwork[BFD_MANE_COLOR_RIGHT], rManeGlow, 1.0f, 16.0f); - Math_ApproachF(&this->fwork[BFD_MANE_COLOR_LEFT], lManeGlow, 1.0f, 16.0f); - - if (this->work[BFD_ROCK_TIMER] != 0) { - this->work[BFD_ROCK_TIMER]--; - if ((this->work[BFD_ROCK_TIMER] % 16) == 0) { - EnVbBall* bossFdRock = (EnVbBall*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_VB_BALL, this->actor.world.pos.x, 1000.0f, - this->actor.world.pos.z, 0, 0, (s16)Rand_ZeroFloat(50.0f) + 130, 100); - - if (bossFdRock != NULL) { - for (i = 0; i < 10; i++) { - Vec3f debrisVel = { 0.0f, 0.0f, 0.0f }; - Vec3f debrisAccel = { 0.0f, -1.0f, 0.0f }; - Vec3f debrisPos; - - debrisPos.x = Rand_CenteredFloat(300.0f) + bossFdRock->actor.world.pos.x; - debrisPos.y = Rand_CenteredFloat(300.0f) + bossFdRock->actor.world.pos.y; - debrisPos.z = Rand_CenteredFloat(300.0f) + bossFdRock->actor.world.pos.z; - - BossFd_SpawnDebris(this->effects, &debrisPos, &debrisVel, &debrisAccel, - (s16)Rand_ZeroFloat(15.0f) + 20); - } - } - } - } - - if (1) { // Needed for matching, and also to define new variables - Vec3f emberVel = { 0.0f, 0.0f, 0.0f }; - Vec3f emberAccel = { 0.0f, 0.0f, 0.0f }; - Vec3f emberPos; - s16 temp_rand; - - for (i = 0; i < 6; i++) { - emberAccel.y = 0.4f; - emberAccel.x = Rand_CenteredFloat(0.5f); - emberAccel.z = Rand_CenteredFloat(0.5f); - - temp_rand = Rand_ZeroFloat(8.9f); - - emberPos.x = sHoleLocations[temp_rand].x + Rand_CenteredFloat(60.0f); - emberPos.y = (sHoleLocations[temp_rand].y + 10.0f) + Rand_ZeroFloat(40.0f); - emberPos.z = sHoleLocations[temp_rand].z + Rand_CenteredFloat(60.0f); - - BossFd_SpawnEmber(this->effects, &emberPos, &emberVel, &emberAccel, (s16)Rand_ZeroFloat(2.0f) + 6); - } - - if (this->skinSegments != 0) { - for (i = 0; i < (s16)this->fwork[BFD_MANE_EMBER_RATE]; i++) { - temp_rand = Rand_ZeroFloat(29.9f); - emberPos.y = this->centerMane.pos[temp_rand].y + Rand_CenteredFloat(20.0f); - - if (emberPos.y >= 90.0f) { - emberPos.x = this->centerMane.pos[temp_rand].x + Rand_CenteredFloat(20.0f); - emberPos.z = this->centerMane.pos[temp_rand].z + Rand_CenteredFloat(20.0f); - - emberVel.x = Rand_CenteredFloat(this->fwork[BFD_MANE_EMBER_SPEED]); - emberVel.y = Rand_CenteredFloat(this->fwork[BFD_MANE_EMBER_SPEED]); - emberVel.z = Rand_CenteredFloat(this->fwork[BFD_MANE_EMBER_SPEED]); - - emberAccel.y = 0.4f; - emberAccel.x = Rand_CenteredFloat(0.5f); - emberAccel.z = Rand_CenteredFloat(0.5f); - - BossFd_SpawnEmber(this->effects, &emberPos, &emberVel, &emberAccel, (s16)Rand_ZeroFloat(2.0f) + 8); - } - } - } - } - osSyncPrintf("FD MOVE END 1\n"); - BossFd_UpdateEffects(this, globalCtx); - osSyncPrintf("FD MOVE END 2\n"); -} - -void BossFd_UpdateEffects(BossFd* this, GlobalContext* globalCtx) { - BossFdEffect* effect = this->effects; - Player* player = GET_PLAYER(globalCtx); - Color_RGB8 colors[4] = { { 255, 128, 0 }, { 255, 0, 0 }, { 255, 255, 0 }, { 255, 0, 0 } }; - Vec3f diff; - s16 i1; - s16 i2; - - for (i1 = 0; i1 < 180; i1++, effect++) { - if (effect->type != BFD_FX_NONE) { - effect->timer1++; - - effect->pos.x += effect->velocity.x; - effect->pos.y += effect->velocity.y; - effect->pos.z += effect->velocity.z; - - effect->velocity.x += effect->accel.x; - effect->velocity.y += effect->accel.y; - effect->velocity.z += effect->accel.z; - if (effect->type == BFD_FX_EMBER) { - s16 cInd = effect->timer1 % 4; - - effect->color.r = colors[cInd].r; - effect->color.g = colors[cInd].g; - effect->color.b = colors[cInd].b; - effect->alpha -= 20; - if (effect->alpha <= 0) { - effect->alpha = 0; - effect->type = 0; - } - } else if ((effect->type == BFD_FX_DEBRIS) || (effect->type == BFD_FX_SKULL_PIECE)) { - effect->vFdFxRotX += 0.55f; - effect->vFdFxRotY += 0.1f; - if (effect->pos.y <= 100.0f) { - effect->type = 0; - } - } else if (effect->type == BFD_FX_DUST) { - if (effect->timer2 >= 8) { - effect->timer2 = 8; - effect->type = 0; - } else if (((effect->timer1 % 2) != 0) || (Rand_ZeroOne() < 0.3f)) { - effect->timer2++; - } - } else if (effect->type == BFD_FX_FIRE_BREATH) { - diff.x = player->actor.world.pos.x - effect->pos.x; - diff.y = player->actor.world.pos.y + 30.0f - effect->pos.y; - diff.z = player->actor.world.pos.z - effect->pos.z; - if ((this->timers[3] == 0) && (sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)) < 20.0f)) { - this->timers[3] = 50; - func_8002F6D4(globalCtx, NULL, 5.0f, effect->kbAngle, 0.0f, 0x30); - if (player->isBurning == false) { - for (i2 = 0; i2 < ARRAY_COUNT(player->flameTimers); i2++) { - player->flameTimers[i2] = Rand_S16Offset(0, 200); - } - player->isBurning = true; - } - } - if (effect->timer2 == 0) { - if (effect->scale < 2.5f) { - effect->scale += effect->vFdFxScaleMod; - effect->vFdFxScaleMod += 0.08f; - } - if ((effect->pos.y <= (effect->vFdFxYStop + 130.0f)) || (effect->timer1 >= 10)) { - effect->accel.y = 5.0f; - effect->timer2++; - effect->velocity.y = 0.0f; - effect->accel.x = (effect->velocity.x * -25.0f) / 100.0f; - effect->accel.z = (effect->velocity.z * -25.0f) / 100.0f; - } - } else { - if (effect->scale < 2.5f) { - Math_ApproachF(&effect->scale, 2.5f, 0.5f, 0.5f); - } - effect->timer2++; - if (effect->timer2 >= 9) { - effect->type = 0; - } - } - } - } - } -} - -void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { - static void* dustTex[] = { - gDust1Tex, gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, - }; - u8 flag = false; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s16 i; - BossFdEffect* firstEffect = effect; - - OPEN_DISPS(gfxCtx, "../z_boss_fd.c", 4023); - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_EMBER) { - if (!flag) { - func_80093D84(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaEmberMaterialDL); - flag++; - } - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, effect->color.r, effect->color.g, effect->color.b, effect->alpha); - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4046), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaEmberModelDL); - } - } - - effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_DEBRIS) { - if (!flag) { - func_80093D18(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, gVolvagiaDebrisMaterialDL); - flag++; - } - - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateY(effect->vFdFxRotY, MTXMODE_APPLY); - Matrix_RotateX(effect->vFdFxRotX, MTXMODE_APPLY); - Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4068), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gVolvagiaDebrisModelDL); - } - } - - effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_DUST) { - if (!flag) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustMaterialDL); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 90, 30, 0, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 90, 30, 0, 0); - flag++; - } - - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - func_800D1FD4(&globalCtx->billboardMtxF); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4104), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTex[effect->timer2])); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustModelDL); - } - } - - effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_FIRE_BREATH) { - if (!flag) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustMaterialDL); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 255); - flag++; - } - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, effect->alpha); - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - func_800D1FD4(&globalCtx->billboardMtxF); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4154), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTex[effect->timer2])); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustModelDL); - } - } - - effect = firstEffect; - flag = false; - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_SKULL_PIECE) { - if (!flag) { - func_80093D84(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaSkullPieceMaterialDL); - flag++; - } - - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateY(effect->vFdFxRotY, MTXMODE_APPLY); - Matrix_RotateX(effect->vFdFxRotX, MTXMODE_APPLY); - Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4192), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaSkullPieceModelDL); - } - } - - CLOSE_DISPS(gfxCtx, "../z_boss_fd.c", 4198); -} - -void BossFd_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossFd* this = (BossFd*)thisx; - - osSyncPrintf("FD DRAW START\n"); - if (this->actionFunc != BossFd_Wait) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4217); - func_80093D18(globalCtx->state.gfxCtx); - if (this->work[BFD_DAMAGE_FLASH_TIMER] & 2) { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 255, 255, 0, 900, 1099); - } - - BossFd_DrawBody(globalCtx, this); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4243); - } - - osSyncPrintf("FD DRAW END\n"); - BossFd_DrawEffects(this->effects, globalCtx); - osSyncPrintf("FD DRAW END2\n"); -} - -s32 BossFd_OverrideRightArmDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossFd* this = (BossFd*)thisx; - - switch (limbIndex) { - case 1: - rot->y += 4000.0f + this->rightArmRot[0].x; - break; - case 2: - rot->y += this->rightArmRot[1].x; - rot->z += this->rightArmRot[1].y; - break; - case 3: - rot->y += this->rightArmRot[2].x; - rot->z += this->rightArmRot[2].y; - break; - } - if (this->skinSegments < limbIndex) { - *dList = NULL; - } - return false; -} - -s32 BossFd_OverrideLeftArmDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossFd* this = (BossFd*)thisx; - - switch (limbIndex) { - case 1: - rot->y += -4000.0f + this->leftArmRot[0].x; - break; - case 2: - rot->y += this->leftArmRot[1].x; - rot->z += this->leftArmRot[1].y; - break; - case 3: - rot->y += this->leftArmRot[2].x; - rot->z += this->leftArmRot[2].y; - break; - } - if (this->skinSegments < limbIndex) { - *dList = NULL; - } - return false; -} - -static s16 sBodyIndex[] = { 0, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5 }; -static s16 sManeIndex[] = { 0, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10 }; // Unused - -void BossFd_DrawMane(GlobalContext* globalCtx, BossFd* this, Vec3f* manePos, Vec3f* maneRot, f32* maneScale, u8 mode) { - f32 sp140[] = { 0.0f, 10.0f, 17.0f, 20.0f, 19.5f, 18.0f, 17.0f, 15.0f, 15.0f, 15.0f }; - f32 sp118[] = { 0.0f, 10.0f, 17.0f, 20.0f, 21.0f, 21.0f, 21.0f, 21.0f, 21.0f, 21.0f }; - f32 spF0[] = { 0.4636457f, 0.3366129f, 0.14879614f, 0.04995025f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - // arctan of {0.5, 0.35, 0.15, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} - f32 spC8[] = { -0.4636457f, -0.3366129f, -0.14879614f, 0.024927188f, 0.07478157f, - 0.04995025f, 0.09961288f, 0.0f, 0.0f, 0.0f }; - // arctan of {-0.5, -0.35, -0.15, 0.025, 0.075, 0.05, 0.1, 0.0, 0.0} - s16 maneIndex; - s16 i; - s16 maneLength; - Vec3f spB4; - Vec3f spA8; - f32 phi_f20; - f32 phi_f22; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4419); - - maneLength = this->skinSegments; - maneLength = CLAMP_MAX(maneLength, 10); - - for (i = 0; i < maneLength; i++) { - maneIndex = (this->work[BFD_LEAD_MANE_SEG] - (i * 2) + 30) % 30; - - if (mode == 0) { - spB4.x = spB4.z = 0.0f; - spB4.y = ((sp140[i] * 0.1f) * 10.0f) * this->flattenMane; - phi_f20 = 0.0f; - phi_f22 = spC8[i] * this->flattenMane; - } else if (mode == 1) { - phi_f22 = (spC8[i] * this->flattenMane) * 0.7f; - phi_f20 = spF0[i] * this->flattenMane; - - spB4.y = (sp140[i] * this->flattenMane) * 0.7f; - spB4.x = -sp118[i] * this->flattenMane; - spB4.z = 0.0f; - } else { - phi_f22 = (spC8[i] * this->flattenMane) * 0.7f; - phi_f20 = -spF0[i] * this->flattenMane; - - spB4.y = (sp140[i] * this->flattenMane) * 0.7f; - spB4.x = sp118[i] * this->flattenMane; - spB4.z = 0.0f; - } - - Matrix_RotateY((maneRot + maneIndex)->y, MTXMODE_NEW); - Matrix_RotateX(-(maneRot + maneIndex)->x, MTXMODE_APPLY); - - Matrix_MultVec3f(&spB4, &spA8); - - Matrix_Translate((manePos + maneIndex)->x + spA8.x, (manePos + maneIndex)->y + spA8.y, - (manePos + maneIndex)->z + spA8.z, MTXMODE_NEW); - Matrix_RotateY((maneRot + maneIndex)->y + phi_f20, MTXMODE_APPLY); - Matrix_RotateX(-((maneRot + maneIndex)->x + phi_f22), MTXMODE_APPLY); - Matrix_Scale(maneScale[maneIndex] * (0.01f - (i * 0.0008f)), maneScale[maneIndex] * (0.01f - (i * 0.0008f)), - 0.01f, MTXMODE_APPLY); - Matrix_RotateX(-M_PI / 2.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4480), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaManeModelDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4483); -} - -s32 BossFd_OverrideHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossFd* this = (BossFd*)thisx; - - switch (limbIndex) { - case 5: - case 6: - rot->z -= this->jawOpening * 0.1f; - break; - case 2: - rot->z += this->jawOpening; - break; - } - if ((this->faceExposed == true) && (limbIndex == 5)) { - *dList = gVolvagiaBrokenFaceDL; - } - if (this->skinSegments == 0) { - if (limbIndex == 6) { - *dList = gVolvagiaSkullDL; - } else if (limbIndex == 2) { - *dList = gVolvagiaJawboneDL; - } else { - *dList = NULL; - } - } - return false; -} - -void BossFd_PostHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f targetMod = { 4500.0f, 0.0f, 0.0f }; - static Vec3f headMod = { 4000.0f, 0.0f, 0.0f }; - BossFd* this = (BossFd*)thisx; - - if (limbIndex == 5) { - Matrix_MultVec3f(&targetMod, &this->actor.focus.pos); - Matrix_MultVec3f(&headMod, &this->headPos); - } -} - -static void* sEyeTextures[] = { - gVolvagiaEyeOpenTex, - gVolvagiaEyeHalfTex, - gVolvagiaEyeClosedTex, -}; - -static Gfx* sBodyDLists[] = { - gVolvagiaBodySeg1DL, gVolvagiaBodySeg2DL, gVolvagiaBodySeg3DL, gVolvagiaBodySeg4DL, gVolvagiaBodySeg5DL, - gVolvagiaBodySeg6DL, gVolvagiaBodySeg7DL, gVolvagiaBodySeg8DL, gVolvagiaBodySeg9DL, gVolvagiaBodySeg10DL, - gVolvagiaBodySeg11DL, gVolvagiaBodySeg12DL, gVolvagiaBodySeg13DL, gVolvagiaBodySeg14DL, gVolvagiaBodySeg15DL, - gVolvagiaBodySeg16DL, gVolvagiaBodySeg17DL, gVolvagiaBodySeg18DL, -}; - -void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* this) { - s16 segIndex; - s16 i; - f32 temp_float; - Mtx* tempMat = Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Mtx)); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4589); - if (this->skinSegments != 0) { - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeState])); - } - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)this->fwork[BFD_TEX1_SCROLL_X], - (s16)this->fwork[BFD_TEX1_SCROLL_Y], 0x20, 0x20, 1, (s16)this->fwork[BFD_TEX2_SCROLL_X], - (s16)this->fwork[BFD_TEX2_SCROLL_Y], 0x20, 0x20)); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)this->fwork[BFD_BODY_TEX2_ALPHA]); - - osSyncPrintf("LH\n"); - Matrix_Push(); - segIndex = (this->work[BFD_LEAD_BODY_SEG] + sBodyIndex[2]) % 100; - Matrix_Translate(this->bodySegsPos[segIndex].x, this->bodySegsPos[segIndex].y, this->bodySegsPos[segIndex].z, - MTXMODE_NEW); - Matrix_RotateY(this->bodySegsRot[segIndex].y, MTXMODE_APPLY); - Matrix_RotateX(-this->bodySegsRot[segIndex].x, MTXMODE_APPLY); - Matrix_Translate(-13.0f, -5.0f, 13.0f, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x * 0.1f, this->actor.scale.y * 0.1f, this->actor.scale.z * 0.1f, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnimeRightArm.skeleton, this->skelAnimeRightArm.jointTable, - BossFd_OverrideRightArmDraw, NULL, this); - Matrix_Pop(); - osSyncPrintf("RH\n"); - Matrix_Push(); - segIndex = (this->work[BFD_LEAD_BODY_SEG] + sBodyIndex[2]) % 100; - Matrix_Translate(this->bodySegsPos[segIndex].x, this->bodySegsPos[segIndex].y, this->bodySegsPos[segIndex].z, - MTXMODE_NEW); - Matrix_RotateY(this->bodySegsRot[segIndex].y, MTXMODE_APPLY); - Matrix_RotateX(-this->bodySegsRot[segIndex].x, MTXMODE_APPLY); - Matrix_Translate(13.0f, -5.0f, 13.0f, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x * 0.1f, this->actor.scale.y * 0.1f, this->actor.scale.z * 0.1f, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnimeLeftArm.skeleton, this->skelAnimeLeftArm.jointTable, - BossFd_OverrideLeftArmDraw, NULL, this); - Matrix_Pop(); - osSyncPrintf("BD\n"); - gSPSegment(POLY_OPA_DISP++, 0x0D, tempMat); - - Matrix_Push(); - for (i = 0; i < 18; i++, tempMat++) { - segIndex = (this->work[BFD_LEAD_BODY_SEG] + sBodyIndex[i + 1]) % 100; - Matrix_Translate(this->bodySegsPos[segIndex].x, this->bodySegsPos[segIndex].y, this->bodySegsPos[segIndex].z, - MTXMODE_NEW); - Matrix_RotateY(this->bodySegsRot[segIndex].y, MTXMODE_APPLY); - Matrix_RotateX(-this->bodySegsRot[segIndex].x, MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, 35.0f, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (i < this->skinSegments) { - Matrix_Scale(1.0f + (Math_SinS((this->work[BFD_LEAD_BODY_SEG] * 5000.0f) + (i * 7000.0f)) * - this->fwork[BFD_BODY_PULSE]), - 1.0f + (Math_SinS((this->work[BFD_LEAD_BODY_SEG] * 5000.0f) + (i * 7000.0f)) * - this->fwork[BFD_BODY_PULSE]), - 1.0f, MTXMODE_APPLY); - Matrix_RotateY(M_PI / 2.0f, MTXMODE_APPLY); - Matrix_ToMtx(tempMat, "../z_boss_fd.c", 4719); - gSPMatrix(POLY_OPA_DISP++, tempMat, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sBodyDLists[i]); - } else { - MtxF spFC; - Vec3f spF0 = { 0.0f, 0.0f, 0.0f }; - Vec3f spE4; - Vec3s spDC; - f32 padD8; - - if (this->bodyFallApart[i] < 2) { - f32 spD4 = 0.1f; - - temp_float = 0.1f; - Matrix_Translate(0.0f, 0.0f, -1100.0f, MTXMODE_APPLY); - Matrix_RotateY(-M_PI, MTXMODE_APPLY); - if (i >= 14) { - f32 sp84 = 1.0f - ((i - 14) * 0.2f); - - Matrix_Scale(sp84, sp84, 1.0f, MTXMODE_APPLY); - spD4 = 0.1f * sp84; - temp_float = 0.1f * sp84; - } - Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4768), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gVolvagiaRibsDL); - - if (this->bodyFallApart[i] == 1) { - EnVbBall* bones; - - this->bodyFallApart[i] = 2; - Matrix_MultVec3f(&spF0, &spE4); - Matrix_Get(&spFC); - Matrix_MtxFToYXZRotS(&spFC, &spDC, 0); - bones = - (EnVbBall*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_VB_BALL, - spE4.x, spE4.y, spE4.z, spDC.x, spDC.y, spDC.z, i + 200); - - bones->actor.scale.x = this->actor.scale.x * temp_float; - bones->actor.scale.y = this->actor.scale.y * spD4; - bones->actor.scale.z = this->actor.scale.z * 0.1f; - } - } - } - if (i > 0) { - Collider_UpdateSpheres(i + 1, &this->collider); - } - } - Matrix_Pop(); - osSyncPrintf("BH\n"); - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)this->fwork[BFD_HEAD_TEX2_ALPHA]); - Matrix_Push(); - temp_float = - (this->work[BFD_ACTION_STATE] >= BOSSFD_SKULL_FALL) ? -20.0f : -10.0f - ((this->actor.speedXZ - 5.0f) * 10.0f); - segIndex = (this->work[BFD_LEAD_BODY_SEG] + sBodyIndex[0]) % 100; - Matrix_Translate(this->bodySegsPos[segIndex].x, this->bodySegsPos[segIndex].y, this->bodySegsPos[segIndex].z, - MTXMODE_NEW); - Matrix_RotateY(this->bodySegsRot[segIndex].y, MTXMODE_APPLY); - Matrix_RotateX(-this->bodySegsRot[segIndex].x, MTXMODE_APPLY); - Matrix_RotateZ((this->actor.shape.rot.z / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, temp_float, MTXMODE_APPLY); - Matrix_Push(); - Matrix_Translate(0.0f, 0.0f, 25.0f, MTXMODE_APPLY); - osSyncPrintf("BHC\n"); - Collider_UpdateSpheres(0, &this->collider); - Matrix_Pop(); - osSyncPrintf("BHCE\n"); - Matrix_Scale(this->actor.scale.x * 0.1f, this->actor.scale.y * 0.1f, this->actor.scale.z * 0.1f, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnimeHead.skeleton, this->skelAnimeHead.jointTable, BossFd_OverrideHeadDraw, - BossFd_PostHeadDraw, &this->actor); - osSyncPrintf("SK\n"); - { - Vec3f spB0 = { 0.0f, 1700.0f, 7000.0f }; - Vec3f spA4 = { -1000.0f, 700.0f, 7000.0f }; - - func_80093D84(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_XLU_DISP++, gVolvagiaManeMaterialDL); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, this->fwork[BFD_MANE_COLOR_CENTER], 0, 255); - Matrix_Push(); - Matrix_MultVec3f(&spB0, &this->centerMane.head); - BossFd_DrawMane(globalCtx, this, this->centerMane.pos, this->fireManeRot, this->centerMane.scale, MANE_CENTER); - Matrix_Pop(); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, this->fwork[BFD_MANE_COLOR_RIGHT], 0, 255); - Matrix_Push(); - Matrix_MultVec3f(&spA4, &this->rightMane.head); - BossFd_DrawMane(globalCtx, this, this->rightMane.pos, this->fireManeRot, this->rightMane.scale, MANE_RIGHT); - Matrix_Pop(); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, this->fwork[BFD_MANE_COLOR_LEFT], 0, 255); - Matrix_Push(); - spA4.x *= -1.0f; - Matrix_MultVec3f(&spA4, &this->leftMane.head); - BossFd_DrawMane(globalCtx, this, this->leftMane.pos, this->fireManeRot, this->leftMane.scale, MANE_LEFT); - Matrix_Pop(); - } - - Matrix_Pop(); - osSyncPrintf("END\n"); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4987); -} diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.cpp b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.cpp new file mode 100644 index 000000000..c2d6d16e7 --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.cpp @@ -0,0 +1,1997 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_FD_Z_BOSS_FD_C +#include "actor_common.h" +/* + * File: z_boss_fd.c + * Overlay: ovl_Boss_Fd + * Description: Volvagia, flying form + */ + +#include "z_boss_fd.h" +#include "objects/object_fd/object_fd.h" +#include "overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.h" +#include "overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.h" +#include "overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +typedef enum { + /* 0 */ INTRO_FLY_EMERGE, + /* 1 */ INTRO_FLY_HOLE, + /* 2 */ INTRO_FLY_CAMERA, + /* 3 */ INTRO_FLY_RETRAT +} BossFdIntroFlyState; + +typedef enum { + /* 0 */ MANE_CENTER, + /* 1 */ MANE_RIGHT, + /* 2 */ MANE_LEFT +} BossFdManeIndex; + +typedef enum { + /* 0 */ EYE_OPEN, + /* 1 */ EYE_HALF, + /* 2 */ EYE_CLOSED +} BossFdEyeState; + +void BossFd_Init(Actor* thisx, GlobalContext* globalCtx); +void BossFd_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossFd_Update(Actor* thisx, GlobalContext* globalCtx); +void BossFd_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BossFd_SetupFly(BossFd* pthis, GlobalContext* globalCtx); +void BossFd_Fly(BossFd* pthis, GlobalContext* globalCtx); +void BossFd_Wait(BossFd* pthis, GlobalContext* globalCtx); +void BossFd_UpdateEffects(BossFd* pthis, GlobalContext* globalCtx); +void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* pthis); + +ActorInit Boss_Fd_InitVars = { + ACTOR_BOSS_FD, + ACTORCAT_BOSS, + FLAGS, + OBJECT_FD, + sizeof(BossFd), + (ActorFunc)BossFd_Init, + (ActorFunc)BossFd_Destroy, + (ActorFunc)BossFd_Update, + (ActorFunc)BossFd_Draw, +}; + +#include "z_boss_fd_colchk.cpp" + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x21, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void BossFd_SpawnEmber(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_EMBER; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->scale = scale / 1000.0f; + effect->alpha = 255; + effect->timer1 = (s16)Rand_ZeroFloat(10.0f); + break; + } + } +} + +void BossFd_SpawnDebris(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_DEBRIS; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->scale = scale / 1000.0f; + effect->vFdFxRotX = Rand_ZeroFloat(100.0f); + effect->vFdFxRotY = Rand_ZeroFloat(100.0f); + break; + } + } +} + +void BossFd_SpawnDust(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_DUST; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->timer2 = 0; + effect->scale = scale / 400.0f; + break; + } + } +} + +void BossFd_SpawnFireBreath(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, + s16 alpha, s16 kbAngle) { + s16 i; + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_FIRE_BREATH; + effect->timer1 = 0; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->pos.x -= effect->velocity.x; + effect->pos.y -= effect->velocity.y; + effect->pos.z -= effect->velocity.z; + effect->vFdFxScaleMod = 0.0f; + effect->alpha = alpha; + effect->vFdFxYStop = Rand_ZeroFloat(10.0f); + effect->timer2 = 0; + effect->scale = scale / 400.0f; + effect->kbAngle = kbAngle; + break; + } + } +} + +void BossFd_SetCameraSpeed(BossFd* pthis, f32 speedMod) { + pthis->camData.eyeVel.x = fabsf(pthis->camData.eye.x - pthis->camData.nextEye.x) * speedMod; + pthis->camData.eyeVel.y = fabsf(pthis->camData.eye.y - pthis->camData.nextEye.y) * speedMod; + pthis->camData.eyeVel.z = fabsf(pthis->camData.eye.z - pthis->camData.nextEye.z) * speedMod; + pthis->camData.atVel.x = fabsf(pthis->camData.at.x - pthis->camData.nextAt.x) * speedMod; + pthis->camData.atVel.y = fabsf(pthis->camData.at.y - pthis->camData.nextAt.y) * speedMod; + pthis->camData.atVel.z = fabsf(pthis->camData.at.z - pthis->camData.nextAt.z) * speedMod; +} + +void BossFd_UpdateCamera(BossFd* pthis, GlobalContext* globalCtx) { + if (pthis->introCamera != SUBCAM_FREE) { + Math_ApproachF(&pthis->camData.eye.x, pthis->camData.nextEye.x, pthis->camData.eyeMaxVel.x, + pthis->camData.eyeVel.x * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.eye.y, pthis->camData.nextEye.y, pthis->camData.eyeMaxVel.y, + pthis->camData.eyeVel.y * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.eye.z, pthis->camData.nextEye.z, pthis->camData.eyeMaxVel.z, + pthis->camData.eyeVel.z * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.at.x, pthis->camData.nextAt.x, pthis->camData.atMaxVel.x, + pthis->camData.atVel.x * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.at.y, pthis->camData.nextAt.y, pthis->camData.atMaxVel.y, + pthis->camData.atVel.y * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.at.z, pthis->camData.nextAt.z, pthis->camData.atMaxVel.z, + pthis->camData.atVel.z * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.speedMod, 1.0f, 1.0f, pthis->camData.accel); + pthis->camData.at.y += pthis->camData.yMod; + Gameplay_CameraSetAtEye(globalCtx, pthis->introCamera, &pthis->camData.at, &pthis->camData.eye); + Math_ApproachZeroF(&pthis->camData.yMod, 1.0f, 0.1f); + } +} + +void BossFd_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossFd* pthis = (BossFd*)thisx; + s16 i; + + Flags_SetSwitch(globalCtx, 0x14); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BG_VB_SIMA, 680.0f, -100.0f, 0.0f, 0, 0, 0, + 100); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&pthis->actor, 0.05f); + SkelAnime_Init(globalCtx, &pthis->skelAnimeHead, &gVolvagiaHeadSkel, &gVolvagiaHeadEmergeAnim, NULL, NULL, 0); + SkelAnime_Init(globalCtx, &pthis->skelAnimeRightArm, &gVolvagiaRightArmSkel, &gVolvagiaRightArmEmergeAnim, NULL, + NULL, 0); + SkelAnime_Init(globalCtx, &pthis->skelAnimeLeftArm, &gVolvagiaLeftArmSkel, &gVolvagiaLeftArmEmergeAnim, NULL, NULL, + 0); + pthis->introState = BFD_CS_WAIT; + if (pthis->introState == BFD_CS_NONE) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); + } + + pthis->actor.world.pos.x = pthis->actor.world.pos.z = 0.0f; + pthis->actor.world.pos.y = -200.0f; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->elements); + + for (i = 0; i < 100; i++) { + pthis->bodySegsPos[i].x = pthis->actor.world.pos.x; + pthis->bodySegsPos[i].y = pthis->actor.world.pos.y; + pthis->bodySegsPos[i].z = pthis->actor.world.pos.z; + if (i < 30) { + pthis->centerMane.pos[i].x = pthis->actor.world.pos.x; + pthis->centerMane.pos[i].y = pthis->actor.world.pos.y; + pthis->centerMane.pos[i].z = pthis->actor.world.pos.z; + } + } + + pthis->actor.colChkInfo.health = 24; + pthis->skinSegments = 18; + if (pthis->introState == BFD_CS_NONE) { + pthis->actionFunc = BossFd_Wait; + } else { + BossFd_SetupFly(pthis, globalCtx); + } + + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { + Actor_Kill(&pthis->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 100.0f, 0.0f, 0, 0, 0, + WARP_DUNGEON_ADULT); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 100.0f, 200.0f, 0, 0, 0, 0); + } else { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_FD2, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, pthis->introState); + } +} + +void BossFd_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossFd* pthis = (BossFd*)thisx; + + SkelAnime_Free(&pthis->skelAnimeHead, globalCtx); + SkelAnime_Free(&pthis->skelAnimeRightArm, globalCtx); + SkelAnime_Free(&pthis->skelAnimeLeftArm, globalCtx); + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +s32 BossFd_IsFacingLink(BossFd* pthis) { + return ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y)) < 0x2000; +} + +void BossFd_SetupFly(BossFd* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnimeHead, &gVolvagiaHeadEmergeAnim); + Animation_PlayOnce(&pthis->skelAnimeRightArm, &gVolvagiaRightArmEmergeAnim); + Animation_PlayOnce(&pthis->skelAnimeLeftArm, &gVolvagiaLeftArmEmergeAnim); + pthis->actionFunc = BossFd_Fly; + pthis->fwork[BFD_TURN_RATE_MAX] = 1000.0f; +} + +static Vec3f sHoleLocations[] = { + { 0.0f, 90.0f, -243.0f }, { 0.0f, 90.0f, 0.0f }, { 0.0f, 90.0f, 243.0f }, + { -243.0f, 90.0f, -243.0f }, { -243.0f, 90.0f, 0.0f }, { -243.0f, 90.0f, 243.0f }, + { 243.0f, 90.0f, -243.0f }, { 243.0f, 90.0f, 0.0f }, { 243.0f, 90.0f, 243.0f }, +}; + +static Vec3f sCeilingTargets[] = { + { 0.0f, 900.0f, -243.0f }, { 243.0, 900.0f, -100.0f }, { 243.0f, 900.0f, 100.0f }, + { 0.0f, 900.0f, 243.0f }, { -243.0f, 900.0f, 100.0f }, { -243.0, 900.0f, -100.0f }, +}; + +void BossFd_Fly(BossFd* pthis, GlobalContext* globalCtx) { + u8 sp1CF = false; + u8 temp_rand; + s16 i1; + s16 i2; + s16 i3; + f32 dx; + f32 dy; + f32 dz; + Player* player = GET_PLAYER(globalCtx); + f32 angleToTarget; + f32 pitchToTarget; + Vec3f* holePosition1; + f32 temp_y; + f32 temp_x; + f32 temp_z; + f32 temp; + + SkelAnime_Update(&pthis->skelAnimeHead); + SkelAnime_Update(&pthis->skelAnimeRightArm); + SkelAnime_Update(&pthis->skelAnimeLeftArm); + dx = pthis->targetPosition.x - pthis->actor.world.pos.x; + dy = pthis->targetPosition.y - pthis->actor.world.pos.y; + dz = pthis->targetPosition.z - pthis->actor.world.pos.z; + dx += Math_SinS((2096.0f + pthis->fwork[BFD_FLY_WOBBLE_RATE]) * pthis->work[BFD_MOVE_TIMER]) * + pthis->fwork[BFD_FLY_WOBBLE_AMP]; + dy += Math_SinS((1096.0f + pthis->fwork[BFD_FLY_WOBBLE_RATE]) * pthis->work[BFD_MOVE_TIMER]) * + pthis->fwork[BFD_FLY_WOBBLE_AMP]; + dz += Math_SinS((1796.0f + pthis->fwork[BFD_FLY_WOBBLE_RATE]) * pthis->work[BFD_MOVE_TIMER]) * + pthis->fwork[BFD_FLY_WOBBLE_AMP]; + angleToTarget = (s16)(Math_FAtan2F(dx, dz) * (0x8000 / M_PI)); + pitchToTarget = (s16)(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))) * (0x8000 / M_PI)); + + osSyncPrintf("MODE %d\n", pthis->work[BFD_ACTION_STATE]); + + Math_ApproachF(&pthis->fwork[BFD_BODY_PULSE], 0.1f, 1.0f, 0.02); + + // Boss Intro Cutscene + + if (pthis->introState != BFD_CS_NONE) { + Player* player2 = GET_PLAYER(globalCtx); + Camera* mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); + + switch (pthis->introState) { + case BFD_CS_WAIT: + pthis->fogMode = 3; + pthis->targetPosition.x = 0.0f; + pthis->targetPosition.y = -110.0f; + pthis->targetPosition.z = 0.0; + pthis->fwork[BFD_TURN_RATE_MAX] = 10000.0f; + pthis->work[BFD_ACTION_STATE] = BOSSFD_WAIT_INTRO; + if ((fabsf(player2->actor.world.pos.z) < 80.0f) && + (fabsf(player2->actor.world.pos.x - 340.0f) < 60.0f)) { + + pthis->introState = BFD_CS_START; + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->introCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->introCamera, CAM_STAT_ACTIVE); + player2->actor.world.pos.x = 380.0f; + player2->actor.world.pos.y = 100.0f; + player2->actor.world.pos.z = 0.0f; + player2->actor.shape.rot.y = player2->actor.world.rot.y = -0x4000; + player2->actor.speedXZ = 0.0f; + pthis->camData.eye.x = player2->actor.world.pos.x - 70.0f; + pthis->camData.eye.y = player2->actor.world.pos.y + 40.0f; + pthis->camData.eye.z = player2->actor.world.pos.z + 70.0f; + pthis->camData.at.x = player2->actor.world.pos.x; + pthis->camData.at.y = player2->actor.world.pos.y + 30.0f; + pthis->camData.at.z = player2->actor.world.pos.z; + pthis->camData.nextEye.x = player2->actor.world.pos.x - 50.0f + 18.0f; + pthis->camData.nextEye.y = player2->actor.world.pos.y + 40; + pthis->camData.nextEye.z = player2->actor.world.pos.z + 50.0f - 18.0f; + pthis->camData.nextAt.x = player2->actor.world.pos.x; + pthis->camData.nextAt.y = player2->actor.world.pos.y + 50.0f; + pthis->camData.nextAt.z = player2->actor.world.pos.z; + BossFd_SetCameraSpeed(pthis, 1.0f); + pthis->camData.atMaxVel.x = pthis->camData.atMaxVel.y = pthis->camData.atMaxVel.z = 0.05f; + pthis->camData.eyeMaxVel.x = pthis->camData.eyeMaxVel.y = pthis->camData.eyeMaxVel.z = 0.05f; + pthis->timers[0] = 0; + pthis->camData.speedMod = 0.0f; + pthis->camData.accel = 0.0f; + if (gSaveContext.eventChkInf[7] & 8) { + pthis->introState = BFD_CS_EMERGE; + pthis->camData.nextEye.x = player2->actor.world.pos.x + 100.0f + 300.0f - 600.0f; + pthis->camData.nextEye.y = player2->actor.world.pos.y + 100.0f - 50.0f; + pthis->camData.nextEye.z = player2->actor.world.pos.z + 200.0f - 150.0f; + pthis->camData.nextAt.x = 0.0f; + pthis->camData.nextAt.y = 120.0f; + pthis->camData.nextAt.z = 0.0f; + BossFd_SetCameraSpeed(pthis, 0.5f); + pthis->camData.eyeMaxVel.x = pthis->camData.eyeMaxVel.y = pthis->camData.eyeMaxVel.z = 0.1f; + pthis->camData.atMaxVel.x = pthis->camData.atMaxVel.y = pthis->camData.atMaxVel.z = 0.1f; + pthis->camData.accel = 0.005f; + pthis->timers[0] = 0; + pthis->holeIndex = 1; + pthis->targetPosition.x = sHoleLocations[pthis->holeIndex].x; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y - 200.0f; + pthis->targetPosition.z = sHoleLocations[pthis->holeIndex].z; + pthis->timers[0] = 50; + pthis->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; + pthis->actor.world.rot.x = 0x4000; + pthis->work[BFD_MOVE_TIMER] = 0; + pthis->timers[3] = 250; + pthis->timers[2] = 470; + pthis->fwork[BFD_FLY_SPEED] = 5.0f; + } + } + break; + case BFD_CS_START: + if (pthis->timers[0] == 0) { + pthis->camData.accel = 0.0010000002f; + pthis->timers[0] = 100; + pthis->introState = BFD_CS_LOOK_LINK; + } + case BFD_CS_LOOK_LINK: + player2->actor.world.pos.x = 380.0f; + player2->actor.world.pos.y = 100.0f; + player2->actor.world.pos.z = 0.0f; + player2->actor.speedXZ = 0.0f; + player2->actor.shape.rot.y = player2->actor.world.rot.y = -0x4000; + if (pthis->timers[0] == 50) { + pthis->fogMode = 1; + } + if (pthis->timers[0] < 50) { + Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + pthis->camData.yMod = Math_CosS(pthis->work[BFD_MOVE_TIMER] * 0x8000) * pthis->camData.shake; + Math_ApproachF(&pthis->camData.shake, 2.0f, 1.0f, 0.8 * 0.01f); + } + if (pthis->timers[0] == 40) { + func_8002DF54(globalCtx, &pthis->actor, 0x13); + } + if (pthis->timers[0] == 0) { + pthis->introState = BFD_CS_LOOK_GROUND; + pthis->camData.nextAt.y = player2->actor.world.pos.y + 10.0f; + pthis->camData.atMaxVel.y = 0.2f; + pthis->camData.speedMod = 0.0f; + pthis->camData.accel = 0.02f; + pthis->timers[0] = 70; + pthis->work[BFD_MOVE_TIMER] = 0; + } + break; + case BFD_CS_LOOK_GROUND: + pthis->camData.yMod = Math_CosS(pthis->work[BFD_MOVE_TIMER] * 0x8000) * pthis->camData.shake; + Math_ApproachF(&pthis->camData.shake, 2.0f, 1.0f, 0.8 * 0.01f); + Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + if (pthis->timers[0] == 0) { + pthis->introState = BFD_CS_COLLAPSE; + pthis->camData.nextEye.x = player2->actor.world.pos.x + 100.0f + 300.0f; + pthis->camData.nextEye.y = player2->actor.world.pos.y + 100.0f; + pthis->camData.nextEye.z = player2->actor.world.pos.z + 200.0f; + pthis->camData.nextAt.x = player2->actor.world.pos.x; + pthis->camData.nextAt.y = player2->actor.world.pos.y - 150.0f; + pthis->camData.nextAt.z = player2->actor.world.pos.z - 50.0f; + BossFd_SetCameraSpeed(pthis, 0.1f); + pthis->timers[0] = 170; + pthis->camData.speedMod = 0.0f; + pthis->camData.accel = 0.0f; + func_8002DF54(globalCtx, &pthis->actor, 0x14); + } + break; + case BFD_CS_COLLAPSE: + pthis->camData.accel = 0.005f; + pthis->camData.yMod = Math_CosS(pthis->work[BFD_MOVE_TIMER] * 0x8000) * pthis->camData.shake; + Math_ApproachF(&pthis->camData.shake, 2.0f, 1.0f, 0.8 * 0.01f); + Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + if (pthis->timers[0] == 100) { + pthis->platformSignal = VBSIMA_COLLAPSE; + } + if (pthis->timers[0] == 0) { + pthis->introState = BFD_CS_EMERGE; + pthis->camData.speedMod = 0.0f; + pthis->camData.nextEye.x = player2->actor.world.pos.x + 100.0f + 300.0f - 600.0f; + pthis->camData.nextEye.y = player2->actor.world.pos.y + 100.0f - 50.0f; + pthis->camData.nextEye.z = player2->actor.world.pos.z + 200.0f - 150.0f; + pthis->camData.nextAt.x = 0.0f; + pthis->camData.nextAt.y = 120.0f; + pthis->camData.nextAt.z = 0.0f; + BossFd_SetCameraSpeed(pthis, 0.5f); + pthis->camData.atMaxVel.x = pthis->camData.atMaxVel.y = pthis->camData.atMaxVel.z = 0.1f; + pthis->camData.eyeMaxVel.x = pthis->camData.eyeMaxVel.y = pthis->camData.eyeMaxVel.z = 0.1f; + pthis->camData.accel = 0.005f; + pthis->timers[0] = 0; + pthis->holeIndex = 1; + pthis->targetPosition.x = sHoleLocations[pthis->holeIndex].x; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y - 200.0f; + pthis->targetPosition.z = sHoleLocations[pthis->holeIndex].z; + pthis->timers[0] = 50; + pthis->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; + pthis->actor.world.rot.x = 0x4000; + pthis->work[BFD_MOVE_TIMER] = 0; + pthis->timers[3] = 250; + pthis->timers[2] = 470; + pthis->fwork[BFD_FLY_SPEED] = 5.0f; + } + break; + case BFD_CS_EMERGE: + osSyncPrintf("WAY_SPD X = %f\n", pthis->camData.atVel.x); + osSyncPrintf("WAY_SPD Y = %f\n", pthis->camData.atVel.y); + osSyncPrintf("WAY_SPD Z = %f\n", pthis->camData.atVel.z); + if ((pthis->timers[3] > 190) && !(gSaveContext.eventChkInf[7] & 8)) { + Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_ROLL - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + } + if (pthis->timers[3] == 190) { + pthis->camData.atMaxVel.x = pthis->camData.atMaxVel.y = pthis->camData.atMaxVel.z = 0.05f; + pthis->platformSignal = VBSIMA_KILL; + func_8002DF54(globalCtx, &pthis->actor, 1); + } + if (pthis->actor.world.pos.y > 120.0f) { + pthis->camData.nextAt = pthis->actor.world.pos; + pthis->camData.atVel.x = 190.0f; + pthis->camData.atVel.y = 85.56f; + pthis->camData.atVel.z = 25.0f; + } else { + // the following `temp` stuff is probably fake but is required to match + // it's optimized to 1.0f because sp1CF is false at pthis point, but the 0.1f ends up in rodata + temp = 0.1f; + if (!sp1CF) { + temp = 1.0f; + } + Math_ApproachF(&pthis->camData.shake, 2.0f, temp, 0.1 * 0.08f); + pthis->camData.yMod = Math_CosS(pthis->work[BFD_MOVE_TIMER] * 0x8000) * pthis->camData.shake; + } + if (pthis->timers[3] == 160) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); + } + if ((pthis->timers[3] == 130) && !(gSaveContext.eventChkInf[7] & 8)) { + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(gVolvagiaBossTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + } + if (pthis->timers[3] <= 100) { + pthis->camData.eyeVel.x = pthis->camData.eyeVel.y = pthis->camData.eyeVel.z = 2.0f; + pthis->camData.nextEye.x = player2->actor.world.pos.x + 50.0f; + pthis->camData.nextEye.y = player2->actor.world.pos.y + 50.0f; + pthis->camData.nextEye.z = player2->actor.world.pos.z + 50.0f; + } + if (pthis->work[BFD_ACTION_STATE] == BOSSFD_FLY_HOLE) { + switch (pthis->introFlyState) { + case INTRO_FLY_EMERGE: + pthis->timers[5] = 100; + pthis->introFlyState = INTRO_FLY_HOLE; + case INTRO_FLY_HOLE: + if (pthis->timers[5] == 0) { + pthis->introFlyState = INTRO_FLY_CAMERA; + pthis->timers[5] = 75; + } + break; + case INTRO_FLY_CAMERA: + pthis->targetPosition = pthis->camData.eye; + if (pthis->timers[5] == 0) { + pthis->timers[0] = 0; + pthis->holeIndex = 7; + pthis->targetPosition.x = sHoleLocations[pthis->holeIndex].x; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y + 200.0f + 50.0f; + pthis->targetPosition.z = sHoleLocations[pthis->holeIndex].z; + pthis->introFlyState = INTRO_FLY_RETRAT; + } + if (pthis->timers[5] == 30) { + pthis->work[BFD_ROAR_TIMER] = 40; + pthis->fireBreathTimer = 20; + } + case INTRO_FLY_RETRAT: + break; + } + } + osSyncPrintf("pthis->timer[2] = %d\n", pthis->timers[2]); + osSyncPrintf("pthis->timer[5] = %d\n", pthis->timers[5]); + if (pthis->timers[2] == 0) { + mainCam->eye = pthis->camData.eye; + mainCam->eyeNext = pthis->camData.eye; + mainCam->at = pthis->camData.at; + func_800C08AC(globalCtx, pthis->introCamera, 0); + pthis->introState = pthis->introFlyState = pthis->introCamera = BFD_CS_NONE; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->actionFunc = BossFd_Wait; + pthis->handoffSignal = FD2_SIGNAL_GROUND; + gSaveContext.eventChkInf[7] |= 8; + } + break; + } + BossFd_UpdateCamera(pthis, globalCtx); + } else { + pthis->fwork[BFD_FLY_SPEED] = 5.0f; + } + + // Attacks and Death Cutscene + + switch (pthis->work[BFD_ACTION_STATE]) { + case BOSSFD_FLY_MAIN: + sp1CF = true; + if (pthis->timers[0] == 0) { + if (pthis->actor.colChkInfo.health == 0) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_DEATH_START; + pthis->timers[0] = 0; + pthis->timers[1] = 100; + } else { + if (pthis->introState != BFD_CS_NONE) { + pthis->holeIndex = 6; + } else { + do { + temp_rand = Rand_ZeroFloat(8.9f); + } while (temp_rand == pthis->holeIndex); + pthis->holeIndex = temp_rand; + } + pthis->targetPosition.x = sHoleLocations[pthis->holeIndex].x; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y + 200.0f + 50.0f; + pthis->targetPosition.z = sHoleLocations[pthis->holeIndex].z; + pthis->fwork[BFD_TURN_RATE] = 0.0f; + pthis->fwork[BFD_TURN_RATE_MAX] = 1000.0f; + if (pthis->introState != BFD_CS_NONE) { + pthis->timers[0] = 10050; + } else { + pthis->timers[0] = 20; + } + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 100.0f; + pthis->work[BFD_ACTION_STATE] = BOSSFD_FLY_HOLE; + + if (pthis->work[BFD_START_ATTACK]) { + pthis->work[BFD_START_ATTACK] = false; + pthis->work[BFD_FLY_COUNT]++; + if (pthis->work[BFD_FLY_COUNT] & 1) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_FLY_CHASE; + pthis->timers[0] = 300; + pthis->fwork[BFD_TURN_RATE_MAX] = 900.0f; + pthis->fwork[BFD_TARGET_Y_OFFSET] = 300.0f; + pthis->work[BFD_UNK_234] = pthis->work[BFD_UNK_236] = 0; + } else { + pthis->work[BFD_ACTION_STATE] = BOSSFD_FLY_CEILING; + } + } + } + } + break; + case BOSSFD_FLY_HOLE: + if ((pthis->timers[0] == 0) && (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 100.0f)) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_BURROW; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y - 70.0f; + pthis->fwork[BFD_TURN_RATE_MAX] = 10000.0f; + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 0.0f; + pthis->timers[0] = 150; + pthis->work[BFD_ROAR_TIMER] = 40; + pthis->holePosition.x = pthis->targetPosition.x; + pthis->holePosition.z = pthis->targetPosition.z; + } + break; + case BOSSFD_BURROW: + sp1CF = true; + if (pthis->timers[0] == 0) { + pthis->actionFunc = BossFd_Wait; + pthis->handoffSignal = FD2_SIGNAL_GROUND; + } + break; + case BOSSFD_EMERGE: + if ((pthis->timers[0] == 0) && (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 100.0f)) { + pthis->actor.world.pos = pthis->targetPosition; + pthis->work[BFD_ACTION_STATE] = BOSSFD_FLY_MAIN; + pthis->actor.world.rot.x = 0x4000; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y + 200.0f; + pthis->timers[4] = 80; + pthis->fwork[BFD_TURN_RATE_MAX] = 1000.0f; + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 0.0f; + pthis->holePosition.x = pthis->targetPosition.x; + pthis->holePosition.z = pthis->targetPosition.z; + + func_80033E1C(globalCtx, 1, 0x50, 0x5000); + if (pthis->introState != BFD_CS_NONE) { + pthis->timers[0] = 50; + } else { + pthis->timers[0] = 50; + } + } + break; + case BOSSFD_FLY_CEILING: + pthis->fwork[BFD_FLY_SPEED] = 8; + pthis->targetPosition.x = 0.0f; + pthis->targetPosition.y = 700.0f; + pthis->targetPosition.z = -300.0f; + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; + pthis->fwork[BFD_TURN_RATE_MAX] = 3000.0f; + if (pthis->actor.world.pos.y > 700.0f) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_DROP_ROCKS; + pthis->timers[0] = 25; + pthis->timers[2] = 150; + pthis->work[BFD_CEILING_TARGET] = 0; + } + break; + case BOSSFD_DROP_ROCKS: + pthis->fwork[BFD_FLY_SPEED] = 8; + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; + pthis->fwork[BFD_TURN_RATE_MAX] = 10000.0f; + pthis->targetPosition.x = sCeilingTargets[pthis->work[BFD_CEILING_TARGET]].x; + pthis->targetPosition.y = sCeilingTargets[pthis->work[BFD_CEILING_TARGET]].y + 900.0f; + pthis->targetPosition.z = sCeilingTargets[pthis->work[BFD_CEILING_TARGET]].z; + if (pthis->timers[0] == 0) { + pthis->timers[0] = 25; + pthis->work[BFD_CEILING_TARGET]++; + if (pthis->work[BFD_CEILING_TARGET] >= 6) { + pthis->work[BFD_CEILING_TARGET] = 0; + } + } + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 2); + if (pthis->timers[1] == 0) { + osSyncPrintf("BGCHECKKKKKKKKKKKKKKKKKKKKKKK\n"); + if (pthis->actor.bgCheckFlags & 0x10) { + pthis->fwork[BFD_CEILING_BOUNCE] = -18384.0f; + pthis->timers[1] = 10; + Audio_PlaySoundGeneral(NA_SE_EV_EXPLOSION, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_80033E1C(globalCtx, 3, 0xA, 0x7530); + pthis->work[BFD_ROCK_TIMER] = 300; + } + } else { + pitchToTarget = pthis->fwork[BFD_CEILING_BOUNCE]; + Math_ApproachZeroF(&pthis->fwork[BFD_CEILING_BOUNCE], 1.0f, 1000.0f); + } + if (pthis->timers[2] == 0) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_FLY_MAIN; + pthis->timers[0] = 0; + pthis->work[BFD_START_ATTACK] = false; + } + break; + case BOSSFD_FLY_CHASE: + pthis->actor.flags |= ACTOR_FLAG_24; + temp_y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 2396.0f) * 30.0f + pthis->fwork[BFD_TARGET_Y_OFFSET]; + pthis->targetPosition.x = player->actor.world.pos.x; + pthis->targetPosition.y = player->actor.world.pos.y + temp_y + 30.0f; + pthis->targetPosition.z = player->actor.world.pos.z; + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 0.0f; + if (((pthis->timers[0] % 64) == 0) && (pthis->timers[0] < 450)) { + pthis->work[BFD_ROAR_TIMER] = 40; + if (BossFd_IsFacingLink(pthis)) { + pthis->fireBreathTimer = 20; + } + } + if ((pthis->work[BFD_DAMAGE_FLASH_TIMER] != 0) || (pthis->timers[0] == 0) || + (player->actor.world.pos.y < 70.0f)) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_FLY_MAIN; + pthis->timers[0] = 0; + pthis->work[BFD_START_ATTACK] = false; + } else { + Math_ApproachF(&pthis->fwork[BFD_TARGET_Y_OFFSET], 50.0, 1.0f, 2.0f); + } + break; + case BOSSFD_DEATH_START: + if (sqrtf(SQ(dx) + SQ(dz)) < 50.0f) { + pthis->timers[0] = 0; + } + if (pthis->timers[0] == 0) { + pthis->timers[0] = (s16)Rand_ZeroFloat(10.0f) + 10; + do { + pthis->targetPosition.x = Rand_CenteredFloat(200.0f); + pthis->targetPosition.y = 390.0f; + pthis->targetPosition.z = Rand_CenteredFloat(200.0f); + temp_x = pthis->targetPosition.x - pthis->actor.world.pos.x; + temp_z = pthis->targetPosition.z - pthis->actor.world.pos.z; + } while (!(sqrtf(SQ(temp_x) + SQ(temp_z)) > 100.0f)); + } + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; + pthis->fwork[BFD_FLY_WOBBLE_RATE] = 1000.0f; + pthis->fwork[BFD_TURN_RATE_MAX] = 10000.0f; + Math_ApproachF(&pthis->fwork[BFD_BODY_PULSE], 0.3f, 1.0f, 0.05f); + if (pthis->timers[1] == 0) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_SKIN_BURN; + pthis->timers[0] = 30; + } + break; + case BOSSFD_SKIN_BURN: + pthis->targetPosition.x = 0.0f; + pthis->targetPosition.y = 390.0f; + pthis->targetPosition.z = 0.0f; + pthis->fwork[BFD_FLY_WOBBLE_AMP] = 200.0f; + pthis->fwork[BFD_FLY_WOBBLE_RATE] = 1000.0f; + pthis->fwork[BFD_TURN_RATE_MAX] = 2000.0f; + Math_ApproachF(&pthis->fwork[BFD_BODY_PULSE], 0.3f, 1.0f, 0.05f); + if ((pthis->timers[0] == 0) && ((pthis->work[BFD_MOVE_TIMER] % 4) == 0)) { + if (pthis->skinSegments != 0) { + pthis->skinSegments--; + if (pthis->skinSegments == 0) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + } + } else { + pthis->work[BFD_ACTION_STATE] = BOSSFD_BONES_FALL; + pthis->timers[0] = 30; + } + } + if ((pthis->work[BFD_MOVE_TIMER] % 32) == 0) { + pthis->work[BFD_ROAR_TIMER] = 40; + } + + if (pthis->skinSegments != 0) { + Vec3f sp188; + Vec3f sp17C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp170; + Vec3f sp164 = { 0.0f, 0.03f, 0.0f }; + Vec3f sp158; + f32 pad154; + s16 temp_rand2; + s16 sp150; + + if (pthis->fogMode == 0) { + globalCtx->envCtx.unk_D8 = 0; + } + pthis->fogMode = 0xA; + + sp150 = 1; + if (pthis->work[BFD_MOVE_TIMER] & 0x1C) { + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_BURN - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + } + for (i1 = 0; i1 < sp150; i1++) { + if (sp150) { // Needed for matching + temp_rand2 = Rand_ZeroFloat(99.9f); + + sp188.x = pthis->bodySegsPos[temp_rand2].x; + sp188.y = pthis->bodySegsPos[temp_rand2].y - 10.0f; + sp188.z = pthis->bodySegsPos[temp_rand2].z; + + sp164.y = 0.03f; + + EffectSsKFire_Spawn(globalCtx, &sp188, &sp17C, &sp164, (s16)Rand_ZeroFloat(20.0f) + 40, 0x64); + + for (i2 = 0; i2 < 15; i2++) { + sp170.x = Rand_CenteredFloat(20.0f); + sp170.y = Rand_CenteredFloat(20.0f); + sp170.z = Rand_CenteredFloat(20.0f); + + sp158.y = 0.4f; + sp158.x = Rand_CenteredFloat(0.5f); + sp158.z = Rand_CenteredFloat(0.5f); + + BossFd_SpawnEmber(pthis->effects, &sp188, &sp170, &sp158, (s16)Rand_ZeroFloat(3.0f) + 8); + } + } + } + } + break; + case BOSSFD_BONES_FALL: + pthis->work[BFD_STOP_FLAG] = true; + pthis->fogMode = 3; + if (pthis->timers[0] < 18) { + pthis->bodyFallApart[pthis->timers[0]] = 1; + } + if (pthis->timers[0] == 0) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_SKULL_PAUSE; + pthis->timers[0] = 15; + pthis->work[BFD_CEILING_TARGET] = 0; + player->actor.world.pos.y = 90.0f; + player->actor.world.pos.x = 40.0f; + player->actor.world.pos.z = 150.0f; + } + break; + case BOSSFD_SKULL_PAUSE: + if (pthis->timers[0] == 0) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_SKULL_FALL; + pthis->timers[0] = 20; + pthis->work[BFD_STOP_FLAG] = false; + } + break; + case BOSSFD_SKULL_FALL: + pthis->fwork[BFD_TURN_RATE] = pthis->fwork[BFD_TURN_RATE_MAX] = pthis->actor.speedXZ = + pthis->fwork[BFD_FLY_SPEED] = 0; + + if (pthis->timers[0] == 1) { + pthis->actor.world.pos.x = 0; + pthis->actor.world.pos.y = 900.0f; + pthis->actor.world.pos.z = 150.0f; + pthis->actor.world.rot.x = pthis->actor.world.rot.y = 0; + pthis->actor.shape.rot.z = 0x1200; + pthis->actor.velocity.x = 0; + pthis->actor.velocity.z = 0; + } + if (pthis->timers[0] == 0) { + if (pthis->actor.world.pos.y <= 110.0f) { + pthis->actor.world.pos.y = 110.0f; + pthis->actor.velocity.y = 0; + if (pthis->work[BFD_CEILING_TARGET] == 0) { + pthis->work[BFD_CEILING_TARGET]++; + pthis->timers[1] = 60; + pthis->work[BFD_CAM_SHAKE_TIMER] = 20; + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + func_8002DF54(globalCtx, &pthis->actor, 5); + for (i1 = 0; i1 < 15; i1++) { + Vec3f sp144 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp138 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp12C; + + sp144.x = Rand_CenteredFloat(8.0f); + sp144.y = Rand_ZeroFloat(1.0f); + sp144.z = Rand_CenteredFloat(8.0f); + + sp138.y = 0.3f; + + sp12C.x = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.x; + sp12C.y = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y; + sp12C.z = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.z; + BossFd_SpawnDust(pthis->effects, &sp12C, &sp144, &sp138, Rand_ZeroFloat(100.0f) + 300); + } + } + } else { + pthis->actor.velocity.y -= 1.0f; + } + } else { + pthis->actor.velocity.y = 0; + } + if (pthis->timers[1] == 1) { + pthis->work[BFD_ACTION_STATE] = BOSSFD_SKULL_BURN; + pthis->timers[0] = 70; + } + break; + case BOSSFD_SKULL_BURN: + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = 110.0f; + pthis->fwork[BFD_TURN_RATE] = pthis->fwork[BFD_TURN_RATE_MAX] = pthis->actor.speedXZ = + pthis->fwork[BFD_FLY_SPEED] = 0.0f; + + if ((50 > pthis->timers[0]) && (pthis->timers[0] > 0)) { + Vec3f sp120; + Vec3f sp114 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp108 = { 0.0f, 0.03f, 0.0f }; + + Audio_PlaySoundGeneral(NA_SE_EN_GOMA_LAST - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + + sp120.x = Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.x; + sp120.y = (Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y) - 10.0f; + sp120.z = (Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.z) + 5.0f; + + sp108.y = 0.03f; + + EffectSsKFire_Spawn(globalCtx, &sp120, &sp114, &sp108, (s16)Rand_ZeroFloat(15.0f) + 30, 0); + } + if (pthis->timers[0] < 20) { + Math_ApproachZeroF(&pthis->actor.scale.x, 1.0f, 0.0025f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + } + if (pthis->timers[0] == 0) { + pthis->actionFunc = BossFd_Wait; + pthis->actor.world.pos.y -= 1000.0f; + } + if (pthis->timers[0] == 7) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); + } + break; + case BOSSFD_WAIT_INTRO: + break; + } + + // Update body segments and mane + + if (!pthis->work[BFD_STOP_FLAG]) { + s16 i4; + Vec3f spE0[3]; + Vec3f spBC[3]; + f32 phi_f20; + f32 padB4; + f32 padB0; + f32 padAC; + + Math_ApproachS(&pthis->actor.world.rot.y, angleToTarget, 0xA, pthis->fwork[BFD_TURN_RATE]); + + if (((pthis->work[BFD_ACTION_STATE] == BOSSFD_FLY_CHASE) || + (pthis->work[BFD_ACTION_STATE] == BOSSFD_FLY_UNUSED)) && + (pthis->actor.world.pos.y < 110.0f) && (pitchToTarget < 0)) { + pitchToTarget = 0; + Math_ApproachF(&pthis->actor.world.pos.y, 110.0f, 1.0f, 5.0f); + } + + Math_ApproachS(&pthis->actor.world.rot.x, pitchToTarget, 0xA, pthis->fwork[BFD_TURN_RATE]); + Math_ApproachF(&pthis->fwork[BFD_TURN_RATE], pthis->fwork[BFD_TURN_RATE_MAX], 1.0f, 20000.0f); + Math_ApproachF(&pthis->actor.speedXZ, pthis->fwork[BFD_FLY_SPEED], 1.0f, 0.1f); + if (pthis->work[BFD_ACTION_STATE] < BOSSFD_SKULL_FALL) { + func_8002D908(&pthis->actor); + } + func_8002D7EC(&pthis->actor); + + pthis->work[BFD_LEAD_BODY_SEG]++; + if (pthis->work[BFD_LEAD_BODY_SEG] >= 100) { + pthis->work[BFD_LEAD_BODY_SEG] = 0; + } + i4 = pthis->work[BFD_LEAD_BODY_SEG]; + pthis->bodySegsPos[i4].x = pthis->actor.world.pos.x; + pthis->bodySegsPos[i4].y = pthis->actor.world.pos.y; + pthis->bodySegsPos[i4].z = pthis->actor.world.pos.z; + pthis->bodySegsRot[i4].x = (pthis->actor.world.rot.x / (f32)0x8000) * M_PI; + pthis->bodySegsRot[i4].y = (pthis->actor.world.rot.y / (f32)0x8000) * M_PI; + pthis->bodySegsRot[i4].z = (pthis->actor.world.rot.z / (f32)0x8000) * M_PI; + + pthis->work[BFD_LEAD_MANE_SEG]++; + if (pthis->work[BFD_LEAD_MANE_SEG] >= 30) { + pthis->work[BFD_LEAD_MANE_SEG] = 0; + } + i4 = pthis->work[BFD_LEAD_MANE_SEG]; + pthis->centerMane.scale[i4] = (Math_SinS(pthis->work[BFD_MOVE_TIMER] * 5596.0f) * 0.3f) + 1.0f; + pthis->rightMane.scale[i4] = (Math_SinS(pthis->work[BFD_MOVE_TIMER] * 5496.0f) * 0.3f) + 1.0f; + pthis->leftMane.scale[i4] = (Math_CosS(pthis->work[BFD_MOVE_TIMER] * 5696.0f) * 0.3f) + 1.0f; + pthis->centerMane.pos[i4] = pthis->centerMane.head; + pthis->fireManeRot[i4].x = (pthis->actor.world.rot.x / (f32)0x8000) * M_PI; + pthis->fireManeRot[i4].y = (pthis->actor.world.rot.y / (f32)0x8000) * M_PI; + pthis->fireManeRot[i4].z = (pthis->actor.world.rot.z / (f32)0x8000) * M_PI; + pthis->rightMane.pos[i4] = pthis->rightMane.head; + pthis->leftMane.pos[i4] = pthis->leftMane.head; + + if ((0x3000 > pthis->actor.world.rot.x) && (pthis->actor.world.rot.x > -0x3000)) { + Math_ApproachF(&pthis->flattenMane, 1.0f, 1.0f, 0.05f); + } else { + Math_ApproachF(&pthis->flattenMane, 0.5f, 1.0f, 0.05f); + } + + if (pthis->work[BFD_ACTION_STATE] < BOSSFD_SKULL_FALL) { + if ((pthis->actor.prevPos.y < 90.0f) && (90.0f <= pthis->actor.world.pos.y)) { + pthis->timers[4] = 80; + func_80033E1C(globalCtx, 1, 80, 0x5000); + pthis->work[BFD_ROAR_TIMER] = 40; + pthis->work[BFD_MANE_EMBERS_TIMER] = 30; + pthis->work[BFD_SPLASH_TIMER] = 10; + } + if ((pthis->actor.prevPos.y > 90.0f) && (90.0f >= pthis->actor.world.pos.y)) { + pthis->timers[4] = 80; + func_80033E1C(globalCtx, 1, 80, 0x5000); + pthis->work[BFD_MANE_EMBERS_TIMER] = 30; + pthis->work[BFD_SPLASH_TIMER] = 10; + } + } + + if (!sp1CF) { + spE0[0].x = spE0[0].y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 1500.0f) * 3000.0f; + spE0[1].x = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 2000.0f) * 4000.0f; + spE0[1].y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 2200.0f) * 4000.0f; + spE0[2].x = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 1700.0f) * 2000.0f; + spE0[2].y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 1900.0f) * 2000.0f; + spBC[0].x = spBC[0].y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 1500.0f) * -3000.0f; + spBC[1].x = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 2200.0f) * -4000.0f; + spBC[1].y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 2000.0f) * -4000.0f; + spBC[2].x = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 1900.0f) * -2000.0f; + spBC[2].y = Math_SinS(pthis->work[BFD_MOVE_TIMER] * 1700.0f) * -2000.0f; + + for (i3 = 0; i3 < 3; i3++) { + Math_ApproachF(&pthis->rightArmRot[i3].x, spE0[i3].x, 1.0f, 1000.0f); + Math_ApproachF(&pthis->rightArmRot[i3].y, spE0[i3].y, 1.0f, 1000.0f); + Math_ApproachF(&pthis->leftArmRot[i3].x, spBC[i3].x, 1.0f, 1000.0f); + Math_ApproachF(&pthis->leftArmRot[i3].y, spBC[i3].y, 1.0f, 1000.0f); + } + } else { + for (i2 = 0; i2 < 3; i2++) { + phi_f20 = 0.0f; + Math_ApproachZeroF(&pthis->rightArmRot[i2].y, 0.1f, 100.0f); + Math_ApproachZeroF(&pthis->leftArmRot[i2].y, 0.1f, 100.0f); + if (i2 == 0) { + phi_f20 = -3000.0f; + } + Math_ApproachF(&pthis->rightArmRot[i2].x, phi_f20, 0.1f, 100.0f); + Math_ApproachF(&pthis->leftArmRot[i2].x, -phi_f20, 0.1f, 100.0f); + } + } + } +} + +void BossFd_Wait(BossFd* pthis, GlobalContext* globalCtx) { + if (pthis->handoffSignal == FD2_SIGNAL_FLY) { // Set by BossFd2 + u8 temp_rand; + + pthis->handoffSignal = FD2_SIGNAL_NONE; + BossFd_SetupFly(pthis, globalCtx); + do { + temp_rand = Rand_ZeroFloat(8.9f); + } while (temp_rand == pthis->holeIndex); + pthis->holeIndex = temp_rand; + if (1) {} // Needed for matching + pthis->targetPosition.x = sHoleLocations[pthis->holeIndex].x; + pthis->targetPosition.y = sHoleLocations[pthis->holeIndex].y - 200.0f; + pthis->targetPosition.z = sHoleLocations[pthis->holeIndex].z; + pthis->actor.world.pos = pthis->targetPosition; + + pthis->timers[0] = 10; + pthis->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; + pthis->work[BFD_START_ATTACK] = true; + } + if (pthis->handoffSignal == FD2_SIGNAL_DEATH) { + pthis->handoffSignal = FD2_SIGNAL_NONE; + BossFd_SetupFly(pthis, globalCtx); + pthis->holeIndex = 1; + pthis->targetPosition.x = sHoleLocations[1].x; + pthis->targetPosition.y = sHoleLocations[1].y - 200.0f; + pthis->targetPosition.z = sHoleLocations[1].z; + pthis->actor.world.pos = pthis->targetPosition; + pthis->timers[0] = 10; + pthis->work[BFD_ACTION_STATE] = BOSSFD_EMERGE; + } +} + +static Vec3f sFireAudioVec = { 0.0f, 0.0f, 50.0f }; + +void BossFd_Effects(BossFd* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 colorYellow = { 255, 255, 0, 255 }; + static Color_RGBA8 colorRed = { 255, 10, 0, 255 }; + s16 breathOpacity = 0; + f32 jawAngle; + f32 jawSpeed; + f32 emberRate; + f32 emberSpeed; + s16 eyeStates[] = { EYE_OPEN, EYE_HALF, EYE_CLOSED, EYE_CLOSED, EYE_HALF }; + f32 temp_x; + f32 temp_z; + s16 i; + + if (1) {} // Needed for match + + if (pthis->fogMode == 0) { + globalCtx->envCtx.unk_BF = 0; + globalCtx->envCtx.unk_D8 = 0.5f + 0.5f * Math_SinS(pthis->work[BFD_VAR_TIMER] * 0x500); + globalCtx->envCtx.unk_DC = 2; + globalCtx->envCtx.unk_BD = 1; + globalCtx->envCtx.unk_BE = 0; + } else if (pthis->fogMode == 3) { + globalCtx->envCtx.unk_BF = 0; + globalCtx->envCtx.unk_DC = 2; + globalCtx->envCtx.unk_BD = 2; + globalCtx->envCtx.unk_BE = 0; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); + } else if (pthis->fogMode == 2) { + pthis->fogMode--; + globalCtx->envCtx.unk_BF = 0; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.55f + 0.05f * Math_SinS(pthis->work[BFD_VAR_TIMER] * 0x3E00), 1.0f, + 0.15f); + globalCtx->envCtx.unk_DC = 2; + globalCtx->envCtx.unk_BD = 3; + globalCtx->envCtx.unk_BE = 0; + } else if (pthis->fogMode == 10) { + pthis->fogMode = 1; + globalCtx->envCtx.unk_BF = 0; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.21f + 0.07f * Math_SinS(pthis->work[BFD_VAR_TIMER] * 0xC00), 1.0f, + 0.05f); + globalCtx->envCtx.unk_DC = 2; + globalCtx->envCtx.unk_BD = 3; + globalCtx->envCtx.unk_BE = 0; + } else if (pthis->fogMode == 1) { + Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.0f, 1.0f, 0.03f); + if (globalCtx->envCtx.unk_D8 <= 0.01f) { + pthis->fogMode = 0; + } + } + + if (pthis->work[BFD_MANE_EMBERS_TIMER] != 0) { + pthis->work[BFD_MANE_EMBERS_TIMER]--; + emberSpeed = emberRate = 20.0f; + } else { + emberRate = 3.0f; + emberSpeed = 5.0f; + } + Math_ApproachF(&pthis->fwork[BFD_MANE_EMBER_RATE], emberRate, 1.0f, 0.1f); + Math_ApproachF(&pthis->fwork[BFD_MANE_EMBER_SPEED], emberSpeed, 1.0f, 0.5f); + + if (((pthis->work[BFD_VAR_TIMER] % 8) == 0) && (Rand_ZeroOne() < 0.3f)) { + pthis->work[BFD_BLINK_TIMER] = 4; + } + pthis->eyeState = eyeStates[pthis->work[BFD_BLINK_TIMER]]; + + if (pthis->work[BFD_BLINK_TIMER] != 0) { + pthis->work[BFD_BLINK_TIMER]--; + } + + if (pthis->work[BFD_ROAR_TIMER] != 0) { + if (pthis->work[BFD_ROAR_TIMER] == 37) { + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_ROAR, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + jawAngle = 6000.0f; + jawSpeed = 1300.0f; + } else { + jawAngle = (pthis->work[BFD_VAR_TIMER] & 0x10) ? 0.0f : 1000.0f; + jawSpeed = 500.0f; + } + Math_ApproachF(&pthis->jawOpening, jawAngle, 0.3f, jawSpeed); + + if (pthis->work[BFD_ROAR_TIMER] != 0) { + pthis->work[BFD_ROAR_TIMER]--; + } + + if (pthis->timers[4] != 0) { + Vec3f spawnVel1; + Vec3f spawnAccel1; + Vec3f spawnPos1; + s32 pad; + + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_APPEAR - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + if (pthis->work[BFD_SPLASH_TIMER] != 0) { + pthis->work[BFD_SPLASH_TIMER]--; + if ((pthis->actor.colChkInfo.health == 0) || + ((pthis->introState == BFD_CS_EMERGE) && (pthis->actor.world.rot.x > 0x3000))) { + if ((u8)pthis->fogMode == 0) { + globalCtx->envCtx.unk_D8 = 0.0f; + } + pthis->fogMode = 2; + } + for (i = 0; i < 5; i++) { + spawnVel1.x = Rand_CenteredFloat(20.0f); + spawnVel1.y = Rand_ZeroFloat(5.0f) + 4.0f; + spawnVel1.z = Rand_CenteredFloat(20.0f); + + spawnAccel1.x = spawnAccel1.z = 0.0f; + spawnAccel1.y = -0.3f; + + temp_x = (spawnVel1.x * 20) / 10.0f; + temp_z = (spawnVel1.z * 20) / 10.0f; + spawnPos1.x = temp_x + pthis->holePosition.x; + spawnPos1.y = 100.0f; + spawnPos1.z = temp_z + pthis->holePosition.z; + + func_8002836C(globalCtx, &spawnPos1, &spawnVel1, &spawnAccel1, &colorYellow, &colorRed, + (s16)Rand_ZeroFloat(150.0f) + 800, 10, (s16)Rand_ZeroFloat(5.0f) + 17); + } + } else { + for (i = 0; i < 2; i++) { + spawnVel1.x = Rand_CenteredFloat(10.0f); + spawnVel1.y = Rand_ZeroFloat(3.0f) + 3.0f; + spawnVel1.z = Rand_CenteredFloat(10.0f); + + spawnAccel1.x = spawnAccel1.z = 0.0f; + spawnAccel1.y = -0.3f; + temp_x = (spawnVel1.x * 50) / 10.0f; + temp_z = (spawnVel1.z * 50) / 10.0f; + + spawnPos1.x = temp_x + pthis->holePosition.x; + spawnPos1.y = 100.0f; + spawnPos1.z = temp_z + pthis->holePosition.z; + + func_8002836C(globalCtx, &spawnPos1, &spawnVel1, &spawnAccel1, &colorYellow, &colorRed, 500, 10, 20); + } + } + + for (i = 0; i < 8; i++) { + spawnVel1.x = Rand_CenteredFloat(20.0f); + spawnVel1.y = Rand_ZeroFloat(10.0f); + spawnVel1.z = Rand_CenteredFloat(20.0f); + + spawnAccel1.y = 0.4f; + spawnAccel1.x = Rand_CenteredFloat(0.5f); + spawnAccel1.z = Rand_CenteredFloat(0.5f); + + spawnPos1.x = Rand_CenteredFloat(60.0) + pthis->holePosition.x; + spawnPos1.y = Rand_ZeroFloat(40.0f) + 100.0f; + spawnPos1.z = Rand_CenteredFloat(60.0) + pthis->holePosition.z; + + BossFd_SpawnEmber(pthis->effects, &spawnPos1, &spawnVel1, &spawnAccel1, (s16)Rand_ZeroFloat(1.5f) + 6); + } + } + + if ((pthis->fireBreathTimer != 0) && (pthis->fireBreathTimer < 17)) { + breathOpacity = (pthis->fireBreathTimer >= 6) ? 255 : pthis->fireBreathTimer * 50; + } + if (breathOpacity != 0) { + f32 spawnAngleX; + f32 spawnAngleY; + Vec3f spawnSpeed2 = { 0.0f, 0.0f, 0.0f }; + Vec3f spawnVel2; + Vec3f spawnAccel2 = { 0.0f, 0.0f, 0.0f }; + Vec3f spawnPos2; + + pthis->fogMode = 2; + spawnSpeed2.z = 30.0f; + + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_FIRE - SFX_FLAG, &sFireAudioVec, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + spawnPos2 = pthis->headPos; + + spawnAngleY = (pthis->actor.world.rot.y / (f32)0x8000) * M_PI; + spawnAngleX = (((-pthis->actor.world.rot.x) / (f32)0x8000) * M_PI) + 0.3f; + Matrix_RotateY(spawnAngleY, MTXMODE_NEW); + Matrix_RotateX(spawnAngleX, MTXMODE_APPLY); + Matrix_MultVec3f(&spawnSpeed2, &spawnVel2); + + BossFd_SpawnFireBreath(pthis->effects, &spawnPos2, &spawnVel2, &spawnAccel2, + 50.0f * Math_SinS(pthis->work[BFD_VAR_TIMER] * 0x2000) + 300.0f, breathOpacity, + pthis->actor.world.rot.y); + + spawnPos2.x += spawnVel2.x * 0.5f; + spawnPos2.y += spawnVel2.y * 0.5f; + spawnPos2.z += spawnVel2.z * 0.5f; + + BossFd_SpawnFireBreath(pthis->effects, &spawnPos2, &spawnVel2, &spawnAccel2, + 50.0f * Math_SinS(pthis->work[BFD_VAR_TIMER] * 0x2000) + 300.0f, breathOpacity, + pthis->actor.world.rot.y); + spawnSpeed2.x = 0.0f; + spawnSpeed2.y = 17.0f; + spawnSpeed2.z = 0.0f; + + for (i = 0; i < 6; i++) { + spawnAngleY = Rand_ZeroFloat(2.0f * M_PI); + spawnAngleX = Rand_ZeroFloat(2.0f * M_PI); + Matrix_RotateY(spawnAngleY, MTXMODE_NEW); + Matrix_RotateX(spawnAngleX, MTXMODE_APPLY); + Matrix_MultVec3f(&spawnSpeed2, &spawnVel2); + + spawnAccel2.x = (spawnVel2.x * -10) / 100; + spawnAccel2.y = (spawnVel2.y * -10) / 100; + spawnAccel2.z = (spawnVel2.z * -10) / 100; + + BossFd_SpawnEmber(pthis->effects, &pthis->headPos, &spawnVel2, &spawnAccel2, (s16)Rand_ZeroFloat(2.0f) + 8); + } + } + + if ((pthis->actor.world.pos.y < 90.0f) || (700.0f < pthis->actor.world.pos.y) || (pthis->actionFunc == BossFd_Wait)) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else { + pthis->actor.flags |= ACTOR_FLAG_0; + } +} + +void BossFd_CollisionCheck(BossFd* pthis, GlobalContext* globalCtx) { + ColliderJntSphElement* headCollider = &pthis->collider.elements[0]; + ColliderInfo* hurtbox; + + if (headCollider->info.bumperFlags & BUMP_HIT) { + headCollider->info.bumperFlags &= ~BUMP_HIT; + hurtbox = headCollider->info.acHitInfo; + pthis->actor.colChkInfo.health -= 2; + if (hurtbox->toucher.dmgFlags & 0x1000) { + pthis->actor.colChkInfo.health -= 2; + } + if ((s8)pthis->actor.colChkInfo.health <= 2) { + pthis->actor.colChkInfo.health = 2; + } + pthis->work[BFD_DAMAGE_FLASH_TIMER] = 10; + pthis->work[BFD_INVINC_TIMER] = 20; + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_DAMAGE1, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void BossFd_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossFd* pthis = (BossFd*)thisx; + f32 headGlow; + f32 rManeGlow; + f32 lManeGlow; + s16 i; + + osSyncPrintf("FD MOVE START \n"); + pthis->work[BFD_VAR_TIMER]++; + pthis->work[BFD_MOVE_TIMER]++; + pthis->actionFunc(pthis, globalCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + if (pthis->fireBreathTimer != 0) { + pthis->fireBreathTimer--; + } + if (pthis->work[BFD_DAMAGE_FLASH_TIMER] != 0) { + pthis->work[BFD_DAMAGE_FLASH_TIMER]--; + } + if (pthis->work[BFD_INVINC_TIMER] != 0) { + pthis->work[BFD_INVINC_TIMER]--; + } + if (pthis->work[BFD_ACTION_STATE] < BOSSFD_DEATH_START) { + if (pthis->work[BFD_INVINC_TIMER] == 0) { + BossFd_CollisionCheck(pthis, globalCtx); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + BossFd_Effects(pthis, globalCtx); + pthis->fwork[BFD_TEX1_SCROLL_X] += 4.0f; + pthis->fwork[BFD_TEX1_SCROLL_Y] = 120.0f; + pthis->fwork[BFD_TEX2_SCROLL_X] += 3.0f; + pthis->fwork[BFD_TEX2_SCROLL_Y] -= 2.0f; + + Math_ApproachF(&pthis->fwork[BFD_BODY_TEX2_ALPHA], (pthis->work[BFD_VAR_TIMER] & 0x10) ? 30.0f : 158.0f, 1.0f, 8.0f); + if (pthis->skinSegments == 0) { + pthis->fwork[BFD_HEAD_TEX2_ALPHA] = pthis->fwork[BFD_BODY_TEX2_ALPHA]; + } else { + headGlow = (pthis->work[BFD_VAR_TIMER] & 4) ? 0.0f : 255.0f; + Math_ApproachF(&pthis->fwork[BFD_HEAD_TEX2_ALPHA], headGlow, 1.0f, 64.0f); + } + + headGlow = (pthis->work[BFD_VAR_TIMER] & 8) ? 128.0f : 255.0f; + rManeGlow = ((pthis->work[BFD_VAR_TIMER] + 3) & 8) ? 128.0f : 255.0f; + lManeGlow = ((pthis->work[BFD_VAR_TIMER] + 6) & 8) ? 128.0f : 255.0f; + + Math_ApproachF(&pthis->fwork[BFD_MANE_COLOR_CENTER], headGlow, 1.0f, 16.0f); + Math_ApproachF(&pthis->fwork[BFD_MANE_COLOR_RIGHT], rManeGlow, 1.0f, 16.0f); + Math_ApproachF(&pthis->fwork[BFD_MANE_COLOR_LEFT], lManeGlow, 1.0f, 16.0f); + + if (pthis->work[BFD_ROCK_TIMER] != 0) { + pthis->work[BFD_ROCK_TIMER]--; + if ((pthis->work[BFD_ROCK_TIMER] % 16) == 0) { + EnVbBall* bossFdRock = (EnVbBall*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_VB_BALL, pthis->actor.world.pos.x, 1000.0f, + pthis->actor.world.pos.z, 0, 0, (s16)Rand_ZeroFloat(50.0f) + 130, 100); + + if (bossFdRock != NULL) { + for (i = 0; i < 10; i++) { + Vec3f debrisVel = { 0.0f, 0.0f, 0.0f }; + Vec3f debrisAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f debrisPos; + + debrisPos.x = Rand_CenteredFloat(300.0f) + bossFdRock->actor.world.pos.x; + debrisPos.y = Rand_CenteredFloat(300.0f) + bossFdRock->actor.world.pos.y; + debrisPos.z = Rand_CenteredFloat(300.0f) + bossFdRock->actor.world.pos.z; + + BossFd_SpawnDebris(pthis->effects, &debrisPos, &debrisVel, &debrisAccel, + (s16)Rand_ZeroFloat(15.0f) + 20); + } + } + } + } + + if (1) { // Needed for matching, and also to define new variables + Vec3f emberVel = { 0.0f, 0.0f, 0.0f }; + Vec3f emberAccel = { 0.0f, 0.0f, 0.0f }; + Vec3f emberPos; + s16 temp_rand; + + for (i = 0; i < 6; i++) { + emberAccel.y = 0.4f; + emberAccel.x = Rand_CenteredFloat(0.5f); + emberAccel.z = Rand_CenteredFloat(0.5f); + + temp_rand = Rand_ZeroFloat(8.9f); + + emberPos.x = sHoleLocations[temp_rand].x + Rand_CenteredFloat(60.0f); + emberPos.y = (sHoleLocations[temp_rand].y + 10.0f) + Rand_ZeroFloat(40.0f); + emberPos.z = sHoleLocations[temp_rand].z + Rand_CenteredFloat(60.0f); + + BossFd_SpawnEmber(pthis->effects, &emberPos, &emberVel, &emberAccel, (s16)Rand_ZeroFloat(2.0f) + 6); + } + + if (pthis->skinSegments != 0) { + for (i = 0; i < (s16)pthis->fwork[BFD_MANE_EMBER_RATE]; i++) { + temp_rand = Rand_ZeroFloat(29.9f); + emberPos.y = pthis->centerMane.pos[temp_rand].y + Rand_CenteredFloat(20.0f); + + if (emberPos.y >= 90.0f) { + emberPos.x = pthis->centerMane.pos[temp_rand].x + Rand_CenteredFloat(20.0f); + emberPos.z = pthis->centerMane.pos[temp_rand].z + Rand_CenteredFloat(20.0f); + + emberVel.x = Rand_CenteredFloat(pthis->fwork[BFD_MANE_EMBER_SPEED]); + emberVel.y = Rand_CenteredFloat(pthis->fwork[BFD_MANE_EMBER_SPEED]); + emberVel.z = Rand_CenteredFloat(pthis->fwork[BFD_MANE_EMBER_SPEED]); + + emberAccel.y = 0.4f; + emberAccel.x = Rand_CenteredFloat(0.5f); + emberAccel.z = Rand_CenteredFloat(0.5f); + + BossFd_SpawnEmber(pthis->effects, &emberPos, &emberVel, &emberAccel, (s16)Rand_ZeroFloat(2.0f) + 8); + } + } + } + } + osSyncPrintf("FD MOVE END 1\n"); + BossFd_UpdateEffects(pthis, globalCtx); + osSyncPrintf("FD MOVE END 2\n"); +} + +void BossFd_UpdateEffects(BossFd* pthis, GlobalContext* globalCtx) { + BossFdEffect* effect = pthis->effects; + Player* player = GET_PLAYER(globalCtx); + Color_RGB8 colors[4] = { { 255, 128, 0 }, { 255, 0, 0 }, { 255, 255, 0 }, { 255, 0, 0 } }; + Vec3f diff; + s16 i1; + s16 i2; + + for (i1 = 0; i1 < 180; i1++, effect++) { + if (effect->type != BFD_FX_NONE) { + effect->timer1++; + + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; + if (effect->type == BFD_FX_EMBER) { + s16 cInd = effect->timer1 % 4; + + effect->color.r = colors[cInd].r; + effect->color.g = colors[cInd].g; + effect->color.b = colors[cInd].b; + effect->alpha -= 20; + if (effect->alpha <= 0) { + effect->alpha = 0; + effect->type = 0; + } + } else if ((effect->type == BFD_FX_DEBRIS) || (effect->type == BFD_FX_SKULL_PIECE)) { + effect->vFdFxRotX += 0.55f; + effect->vFdFxRotY += 0.1f; + if (effect->pos.y <= 100.0f) { + effect->type = 0; + } + } else if (effect->type == BFD_FX_DUST) { + if (effect->timer2 >= 8) { + effect->timer2 = 8; + effect->type = 0; + } else if (((effect->timer1 % 2) != 0) || (Rand_ZeroOne() < 0.3f)) { + effect->timer2++; + } + } else if (effect->type == BFD_FX_FIRE_BREATH) { + diff.x = player->actor.world.pos.x - effect->pos.x; + diff.y = player->actor.world.pos.y + 30.0f - effect->pos.y; + diff.z = player->actor.world.pos.z - effect->pos.z; + if ((pthis->timers[3] == 0) && (sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)) < 20.0f)) { + pthis->timers[3] = 50; + func_8002F6D4(globalCtx, NULL, 5.0f, effect->kbAngle, 0.0f, 0x30); + if (player->isBurning == false) { + for (i2 = 0; i2 < ARRAY_COUNT(player->flameTimers); i2++) { + player->flameTimers[i2] = Rand_S16Offset(0, 200); + } + player->isBurning = true; + } + } + if (effect->timer2 == 0) { + if (effect->scale < 2.5f) { + effect->scale += effect->vFdFxScaleMod; + effect->vFdFxScaleMod += 0.08f; + } + if ((effect->pos.y <= (effect->vFdFxYStop + 130.0f)) || (effect->timer1 >= 10)) { + effect->accel.y = 5.0f; + effect->timer2++; + effect->velocity.y = 0.0f; + effect->accel.x = (effect->velocity.x * -25.0f) / 100.0f; + effect->accel.z = (effect->velocity.z * -25.0f) / 100.0f; + } + } else { + if (effect->scale < 2.5f) { + Math_ApproachF(&effect->scale, 2.5f, 0.5f, 0.5f); + } + effect->timer2++; + if (effect->timer2 >= 9) { + effect->type = 0; + } + } + } + } + } +} + +void BossFd_DrawEffects(BossFdEffect* effect, GlobalContext* globalCtx) { + static void* dustTex[] = { + gDust1Tex, gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, + }; + u8 flag = false; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 i; + BossFdEffect* firstEffect = effect; + + OPEN_DISPS(gfxCtx, "../z_boss_fd.c", 4023); + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_EMBER) { + if (!flag) { + func_80093D84(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaEmberMaterialDL); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, effect->color.r, effect->color.g, effect->color.b, effect->alpha); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4046), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaEmberModelDL); + } + } + + effect = firstEffect; + flag = false; + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_DEBRIS) { + if (!flag) { + func_80093D18(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, gVolvagiaDebrisMaterialDL); + flag++; + } + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateY(effect->vFdFxRotY, MTXMODE_APPLY); + Matrix_RotateX(effect->vFdFxRotX, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4068), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gVolvagiaDebrisModelDL); + } + } + + effect = firstEffect; + flag = false; + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_DUST) { + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustMaterialDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 90, 30, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 90, 30, 0, 0); + flag++; + } + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + func_800D1FD4(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4104), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTex[effect->timer2])); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustModelDL); + } + } + + effect = firstEffect; + flag = false; + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_FIRE_BREATH) { + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustMaterialDL); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 255); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, effect->alpha); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + func_800D1FD4(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4154), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTex[effect->timer2])); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaDustModelDL); + } + } + + effect = firstEffect; + flag = false; + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_SKULL_PIECE) { + if (!flag) { + func_80093D84(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaSkullPieceMaterialDL); + flag++; + } + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateY(effect->vFdFxRotY, MTXMODE_APPLY); + Matrix_RotateX(effect->vFdFxRotX, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_fd.c", 4192), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaSkullPieceModelDL); + } + } + + CLOSE_DISPS(gfxCtx, "../z_boss_fd.c", 4198); +} + +void BossFd_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossFd* pthis = (BossFd*)thisx; + + osSyncPrintf("FD DRAW START\n"); + if (pthis->actionFunc != BossFd_Wait) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4217); + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->work[BFD_DAMAGE_FLASH_TIMER] & 2) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 255, 255, 0, 900, 1099); + } + + BossFd_DrawBody(globalCtx, pthis); + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4243); + } + + osSyncPrintf("FD DRAW END\n"); + BossFd_DrawEffects(pthis->effects, globalCtx); + osSyncPrintf("FD DRAW END2\n"); +} + +s32 BossFd_OverrideRightArmDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossFd* pthis = (BossFd*)thisx; + + switch (limbIndex) { + case 1: + rot->y += 4000.0f + pthis->rightArmRot[0].x; + break; + case 2: + rot->y += pthis->rightArmRot[1].x; + rot->z += pthis->rightArmRot[1].y; + break; + case 3: + rot->y += pthis->rightArmRot[2].x; + rot->z += pthis->rightArmRot[2].y; + break; + } + if (pthis->skinSegments < limbIndex) { + *dList = NULL; + } + return false; +} + +s32 BossFd_OverrideLeftArmDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossFd* pthis = (BossFd*)thisx; + + switch (limbIndex) { + case 1: + rot->y += -4000.0f + pthis->leftArmRot[0].x; + break; + case 2: + rot->y += pthis->leftArmRot[1].x; + rot->z += pthis->leftArmRot[1].y; + break; + case 3: + rot->y += pthis->leftArmRot[2].x; + rot->z += pthis->leftArmRot[2].y; + break; + } + if (pthis->skinSegments < limbIndex) { + *dList = NULL; + } + return false; +} + +static s16 sBodyIndex[] = { 0, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5 }; +static s16 sManeIndex[] = { 0, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10 }; // Unused + +void BossFd_DrawMane(GlobalContext* globalCtx, BossFd* pthis, Vec3f* manePos, Vec3f* maneRot, f32* maneScale, u8 mode) { + f32 sp140[] = { 0.0f, 10.0f, 17.0f, 20.0f, 19.5f, 18.0f, 17.0f, 15.0f, 15.0f, 15.0f }; + f32 sp118[] = { 0.0f, 10.0f, 17.0f, 20.0f, 21.0f, 21.0f, 21.0f, 21.0f, 21.0f, 21.0f }; + f32 spF0[] = { 0.4636457f, 0.3366129f, 0.14879614f, 0.04995025f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + // arctan of {0.5, 0.35, 0.15, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} + f32 spC8[] = { -0.4636457f, -0.3366129f, -0.14879614f, 0.024927188f, 0.07478157f, + 0.04995025f, 0.09961288f, 0.0f, 0.0f, 0.0f }; + // arctan of {-0.5, -0.35, -0.15, 0.025, 0.075, 0.05, 0.1, 0.0, 0.0} + s16 maneIndex; + s16 i; + s16 maneLength; + Vec3f spB4; + Vec3f spA8; + f32 phi_f20; + f32 phi_f22; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4419); + + maneLength = pthis->skinSegments; + maneLength = CLAMP_MAX(maneLength, 10); + + for (i = 0; i < maneLength; i++) { + maneIndex = (pthis->work[BFD_LEAD_MANE_SEG] - (i * 2) + 30) % 30; + + if (mode == 0) { + spB4.x = spB4.z = 0.0f; + spB4.y = ((sp140[i] * 0.1f) * 10.0f) * pthis->flattenMane; + phi_f20 = 0.0f; + phi_f22 = spC8[i] * pthis->flattenMane; + } else if (mode == 1) { + phi_f22 = (spC8[i] * pthis->flattenMane) * 0.7f; + phi_f20 = spF0[i] * pthis->flattenMane; + + spB4.y = (sp140[i] * pthis->flattenMane) * 0.7f; + spB4.x = -sp118[i] * pthis->flattenMane; + spB4.z = 0.0f; + } else { + phi_f22 = (spC8[i] * pthis->flattenMane) * 0.7f; + phi_f20 = -spF0[i] * pthis->flattenMane; + + spB4.y = (sp140[i] * pthis->flattenMane) * 0.7f; + spB4.x = sp118[i] * pthis->flattenMane; + spB4.z = 0.0f; + } + + Matrix_RotateY((maneRot + maneIndex)->y, MTXMODE_NEW); + Matrix_RotateX(-(maneRot + maneIndex)->x, MTXMODE_APPLY); + + Matrix_MultVec3f(&spB4, &spA8); + + Matrix_Translate((manePos + maneIndex)->x + spA8.x, (manePos + maneIndex)->y + spA8.y, + (manePos + maneIndex)->z + spA8.z, MTXMODE_NEW); + Matrix_RotateY((maneRot + maneIndex)->y + phi_f20, MTXMODE_APPLY); + Matrix_RotateX(-((maneRot + maneIndex)->x + phi_f22), MTXMODE_APPLY); + Matrix_Scale(maneScale[maneIndex] * (0.01f - (i * 0.0008f)), maneScale[maneIndex] * (0.01f - (i * 0.0008f)), + 0.01f, MTXMODE_APPLY); + Matrix_RotateX(-M_PI / 2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4480), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaManeModelDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4483); +} + +s32 BossFd_OverrideHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + BossFd* pthis = (BossFd*)thisx; + + switch (limbIndex) { + case 5: + case 6: + rot->z -= pthis->jawOpening * 0.1f; + break; + case 2: + rot->z += pthis->jawOpening; + break; + } + if ((pthis->faceExposed == true) && (limbIndex == 5)) { + *dList = gVolvagiaBrokenFaceDL; + } + if (pthis->skinSegments == 0) { + if (limbIndex == 6) { + *dList = gVolvagiaSkullDL; + } else if (limbIndex == 2) { + *dList = gVolvagiaJawboneDL; + } else { + *dList = NULL; + } + } + return false; +} + +void BossFd_PostHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f targetMod = { 4500.0f, 0.0f, 0.0f }; + static Vec3f headMod = { 4000.0f, 0.0f, 0.0f }; + BossFd* pthis = (BossFd*)thisx; + + if (limbIndex == 5) { + Matrix_MultVec3f(&targetMod, &pthis->actor.focus.pos); + Matrix_MultVec3f(&headMod, &pthis->headPos); + } +} + +static void* sEyeTextures[] = { + gVolvagiaEyeOpenTex, + gVolvagiaEyeHalfTex, + gVolvagiaEyeClosedTex, +}; + +static Gfx* sBodyDLists[] = { + gVolvagiaBodySeg1DL, gVolvagiaBodySeg2DL, gVolvagiaBodySeg3DL, gVolvagiaBodySeg4DL, gVolvagiaBodySeg5DL, + gVolvagiaBodySeg6DL, gVolvagiaBodySeg7DL, gVolvagiaBodySeg8DL, gVolvagiaBodySeg9DL, gVolvagiaBodySeg10DL, + gVolvagiaBodySeg11DL, gVolvagiaBodySeg12DL, gVolvagiaBodySeg13DL, gVolvagiaBodySeg14DL, gVolvagiaBodySeg15DL, + gVolvagiaBodySeg16DL, gVolvagiaBodySeg17DL, gVolvagiaBodySeg18DL, +}; + +void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* pthis) { + s16 segIndex; + s16 i; + f32 temp_float; + Mtx* tempMat = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Mtx)); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4589); + if (pthis->skinSegments != 0) { + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeState])); + } + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)pthis->fwork[BFD_TEX1_SCROLL_X], + (s16)pthis->fwork[BFD_TEX1_SCROLL_Y], 0x20, 0x20, 1, (s16)pthis->fwork[BFD_TEX2_SCROLL_X], + (s16)pthis->fwork[BFD_TEX2_SCROLL_Y], 0x20, 0x20)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)pthis->fwork[BFD_BODY_TEX2_ALPHA]); + + osSyncPrintf("LH\n"); + Matrix_Push(); + segIndex = (pthis->work[BFD_LEAD_BODY_SEG] + sBodyIndex[2]) % 100; + Matrix_Translate(pthis->bodySegsPos[segIndex].x, pthis->bodySegsPos[segIndex].y, pthis->bodySegsPos[segIndex].z, + MTXMODE_NEW); + Matrix_RotateY(pthis->bodySegsRot[segIndex].y, MTXMODE_APPLY); + Matrix_RotateX(-pthis->bodySegsRot[segIndex].x, MTXMODE_APPLY); + Matrix_Translate(-13.0f, -5.0f, 13.0f, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * 0.1f, pthis->actor.scale.y * 0.1f, pthis->actor.scale.z * 0.1f, MTXMODE_APPLY); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnimeRightArm.skeleton, pthis->skelAnimeRightArm.jointTable, + BossFd_OverrideRightArmDraw, NULL, pthis); + Matrix_Pop(); + osSyncPrintf("RH\n"); + Matrix_Push(); + segIndex = (pthis->work[BFD_LEAD_BODY_SEG] + sBodyIndex[2]) % 100; + Matrix_Translate(pthis->bodySegsPos[segIndex].x, pthis->bodySegsPos[segIndex].y, pthis->bodySegsPos[segIndex].z, + MTXMODE_NEW); + Matrix_RotateY(pthis->bodySegsRot[segIndex].y, MTXMODE_APPLY); + Matrix_RotateX(-pthis->bodySegsRot[segIndex].x, MTXMODE_APPLY); + Matrix_Translate(13.0f, -5.0f, 13.0f, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * 0.1f, pthis->actor.scale.y * 0.1f, pthis->actor.scale.z * 0.1f, MTXMODE_APPLY); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnimeLeftArm.skeleton, pthis->skelAnimeLeftArm.jointTable, + BossFd_OverrideLeftArmDraw, NULL, pthis); + Matrix_Pop(); + osSyncPrintf("BD\n"); + gSPSegment(POLY_OPA_DISP++, 0x0D, tempMat); + + Matrix_Push(); + for (i = 0; i < 18; i++, tempMat++) { + segIndex = (pthis->work[BFD_LEAD_BODY_SEG] + sBodyIndex[i + 1]) % 100; + Matrix_Translate(pthis->bodySegsPos[segIndex].x, pthis->bodySegsPos[segIndex].y, pthis->bodySegsPos[segIndex].z, + MTXMODE_NEW); + Matrix_RotateY(pthis->bodySegsRot[segIndex].y, MTXMODE_APPLY); + Matrix_RotateX(-pthis->bodySegsRot[segIndex].x, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 35.0f, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + if (i < pthis->skinSegments) { + Matrix_Scale(1.0f + (Math_SinS((pthis->work[BFD_LEAD_BODY_SEG] * 5000.0f) + (i * 7000.0f)) * + pthis->fwork[BFD_BODY_PULSE]), + 1.0f + (Math_SinS((pthis->work[BFD_LEAD_BODY_SEG] * 5000.0f) + (i * 7000.0f)) * + pthis->fwork[BFD_BODY_PULSE]), + 1.0f, MTXMODE_APPLY); + Matrix_RotateY(M_PI / 2.0f, MTXMODE_APPLY); + Matrix_ToMtx(tempMat, "../z_boss_fd.c", 4719); + gSPMatrix(POLY_OPA_DISP++, tempMat, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sBodyDLists[i]); + } else { + MtxF spFC; + Vec3f spF0 = { 0.0f, 0.0f, 0.0f }; + Vec3f spE4; + Vec3s spDC; + f32 padD8; + + if (pthis->bodyFallApart[i] < 2) { + f32 spD4 = 0.1f; + + temp_float = 0.1f; + Matrix_Translate(0.0f, 0.0f, -1100.0f, MTXMODE_APPLY); + Matrix_RotateY(-M_PI, MTXMODE_APPLY); + if (i >= 14) { + f32 sp84 = 1.0f - ((i - 14) * 0.2f); + + Matrix_Scale(sp84, sp84, 1.0f, MTXMODE_APPLY); + spD4 = 0.1f * sp84; + temp_float = 0.1f * sp84; + } + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4768), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gVolvagiaRibsDL); + + if (pthis->bodyFallApart[i] == 1) { + EnVbBall* bones; + + pthis->bodyFallApart[i] = 2; + Matrix_MultVec3f(&spF0, &spE4); + Matrix_Get(&spFC); + Matrix_MtxFToYXZRotS(&spFC, &spDC, 0); + bones = + (EnVbBall*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_VB_BALL, + spE4.x, spE4.y, spE4.z, spDC.x, spDC.y, spDC.z, i + 200); + + bones->actor.scale.x = pthis->actor.scale.x * temp_float; + bones->actor.scale.y = pthis->actor.scale.y * spD4; + bones->actor.scale.z = pthis->actor.scale.z * 0.1f; + } + } + } + if (i > 0) { + Collider_UpdateSpheres(i + 1, &pthis->collider); + } + } + Matrix_Pop(); + osSyncPrintf("BH\n"); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)pthis->fwork[BFD_HEAD_TEX2_ALPHA]); + Matrix_Push(); + temp_float = + (pthis->work[BFD_ACTION_STATE] >= BOSSFD_SKULL_FALL) ? -20.0f : -10.0f - ((pthis->actor.speedXZ - 5.0f) * 10.0f); + segIndex = (pthis->work[BFD_LEAD_BODY_SEG] + sBodyIndex[0]) % 100; + Matrix_Translate(pthis->bodySegsPos[segIndex].x, pthis->bodySegsPos[segIndex].y, pthis->bodySegsPos[segIndex].z, + MTXMODE_NEW); + Matrix_RotateY(pthis->bodySegsRot[segIndex].y, MTXMODE_APPLY); + Matrix_RotateX(-pthis->bodySegsRot[segIndex].x, MTXMODE_APPLY); + Matrix_RotateZ((pthis->actor.shape.rot.z / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, temp_float, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(0.0f, 0.0f, 25.0f, MTXMODE_APPLY); + osSyncPrintf("BHC\n"); + Collider_UpdateSpheres(0, &pthis->collider); + Matrix_Pop(); + osSyncPrintf("BHCE\n"); + Matrix_Scale(pthis->actor.scale.x * 0.1f, pthis->actor.scale.y * 0.1f, pthis->actor.scale.z * 0.1f, MTXMODE_APPLY); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnimeHead.skeleton, pthis->skelAnimeHead.jointTable, BossFd_OverrideHeadDraw, + BossFd_PostHeadDraw, &pthis->actor); + osSyncPrintf("SK\n"); + { + Vec3f spB0 = { 0.0f, 1700.0f, 7000.0f }; + Vec3f spA4 = { -1000.0f, 700.0f, 7000.0f }; + + func_80093D84(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, gVolvagiaManeMaterialDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, pthis->fwork[BFD_MANE_COLOR_CENTER], 0, 255); + Matrix_Push(); + Matrix_MultVec3f(&spB0, &pthis->centerMane.head); + BossFd_DrawMane(globalCtx, pthis, pthis->centerMane.pos, pthis->fireManeRot, pthis->centerMane.scale, MANE_CENTER); + Matrix_Pop(); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, pthis->fwork[BFD_MANE_COLOR_RIGHT], 0, 255); + Matrix_Push(); + Matrix_MultVec3f(&spA4, &pthis->rightMane.head); + BossFd_DrawMane(globalCtx, pthis, pthis->rightMane.pos, pthis->fireManeRot, pthis->rightMane.scale, MANE_RIGHT); + Matrix_Pop(); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, pthis->fwork[BFD_MANE_COLOR_LEFT], 0, 255); + Matrix_Push(); + spA4.x *= -1.0f; + Matrix_MultVec3f(&spA4, &pthis->leftMane.head); + BossFd_DrawMane(globalCtx, pthis, pthis->leftMane.pos, pthis->fireManeRot, pthis->leftMane.scale, MANE_LEFT); + Matrix_Pop(); + } + + Matrix_Pop(); + osSyncPrintf("END\n"); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd.c", 4987); +} diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd_colchk.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd_colchk.cpp similarity index 100% rename from src/overlays/actors/ovl_Boss_Fd/z_boss_fd_colchk.c rename to src/overlays/actors/ovl_Boss_Fd/z_boss_fd_colchk.cpp diff --git a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c deleted file mode 100644 index 5f26e8e67..000000000 --- a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c +++ /dev/null @@ -1,1231 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_FD2_Z_BOSS_FD2_C -#include "actor_common.h" -/* - * File: z_boss_fd2.c - * Overlay: ovl_Boss_Fd2 - * Description: Volvagia, hole form - */ - -#include "z_boss_fd2.h" -#include "objects/object_fd2/object_fd2.h" -#include "overlays/actors/ovl_Boss_Fd/z_boss_fd.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "vt.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_demo.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -typedef enum { - /* 0 */ DEATH_START, - /* 1 */ DEATH_RETREAT, - /* 2 */ DEATH_HANDOFF, - /* 3 */ DEATH_FD_BODY, - /* 4 */ DEATH_FD_SKULL, - /* 5 */ DEATH_FINISH -} BossFd2CutsceneState; - -typedef enum { - /* 0 */ EYE_OPEN, - /* 1 */ EYE_HALF, - /* 2 */ EYE_CLOSED -} BossFd2EyeState; - -void BossFd2_Init(Actor* thisx, GlobalContext* globalCtx); -void BossFd2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossFd2_Update(Actor* thisx, GlobalContext* globalCtx); -void BossFd2_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BossFd2_SetupEmerge(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Emerge(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_SetupIdle(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Idle(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Burrow(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_SetupBreatheFire(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_BreatheFire(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_SetupClawSwipe(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_ClawSwipe(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Vulnerable(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Damaged(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Death(BossFd2* this, GlobalContext* globalCtx); -void BossFd2_Wait(BossFd2* this, GlobalContext* globalCtx); - -const ActorInit Boss_Fd2_InitVars = { - ACTOR_BOSS_FD2, - ACTORCAT_BOSS, - FLAGS, - OBJECT_FD2, - sizeof(BossFd2), - (ActorFunc)BossFd2_Init, - (ActorFunc)BossFd2_Destroy, - (ActorFunc)BossFd2_Update, - (ActorFunc)BossFd2_Draw, -}; - -#include "z_boss_fd2_colchk.c" - -static Vec3f sHoleLocations[] = { - { 0.0f, 90.0f, -243.0f }, { 0.0f, 90.0f, 0.0f }, { 0.0f, 90.0f, 243.0f }, - { -243.0f, 90.0f, -243.0f }, { -243.0f, 90.0f, 0.0f }, { -243.0f, 90.0f, 243.0f }, - { 243.0f, 90.0f, -243.0f }, { 243.0f, 90.0f, 0.0f }, { 243.0f, 90.0f, 243.0f }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x21, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void BossFd2_SpawnDebris(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, - Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_DEBRIS; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->scale = scale / 1000.0f; - effect->vFdFxRotX = Rand_ZeroFloat(100.0f); - effect->vFdFxRotY = Rand_ZeroFloat(100.0f); - break; - } - } -} - -void BossFd2_SpawnFireBreath(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, - Vec3f* acceleration, f32 scale, s16 alpha, s16 kbAngle) { - s16 i; - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_FIRE_BREATH; - effect->timer1 = 0; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->pos.x -= effect->velocity.x; - effect->pos.y -= effect->velocity.y; - effect->pos.z -= effect->velocity.z; - effect->vFdFxScaleMod = 0.0f; - effect->alpha = alpha; - effect->vFdFxYStop = Rand_ZeroFloat(10.0f); - effect->timer2 = 0; - effect->scale = scale / 400.0f; - effect->kbAngle = kbAngle; - break; - } - } -} - -void BossFd2_SpawnEmber(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, - Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == 0) { - effect->type = BFD_FX_EMBER; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->scale = scale / 1000.0f; - effect->alpha = 255; - effect->timer1 = (s16)Rand_ZeroFloat(10.0f); - break; - } - } -} - -void BossFd2_SpawnSkullPiece(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, - Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_SKULL_PIECE; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->scale = scale / 1000.0f; - effect->vFdFxRotX = Rand_ZeroFloat(100.0f); - effect->vFdFxRotY = Rand_ZeroFloat(100.0f); - break; - } - } -} - -void BossFd2_SpawnDust(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { - s16 i; - - for (i = 0; i < 180; i++, effect++) { - if (effect->type == BFD_FX_NONE) { - effect->type = BFD_FX_DUST; - effect->pos = *position; - effect->velocity = *velocity; - effect->accel = *acceleration; - effect->timer2 = 0; - effect->scale = scale / 400.0f; - break; - } - } -} - -void BossFd2_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossFd2* this = (BossFd2*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.0069999993f); - this->actor.world.pos.y = -850.0f; - ActorShape_Init(&this->actor.shape, -580.0f / this->actor.scale.y, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gHoleVolvagiaSkel, &gHoleVolvagiaIdleAnim, NULL, NULL, 0); - if (this->actor.params == BFD_CS_NONE) { - BossFd2_SetupEmerge(this, globalCtx); - } else { - this->actionFunc = BossFd2_Wait; - } - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->elements); -} - -void BossFd2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossFd2* this = (BossFd2*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void BossFd2_SetupEmerge(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - s16 temp_rand; - s8 health; - - osSyncPrintf("UP INIT 1\n"); - Animation_PlayOnce(&this->skelAnime, &gHoleVolvagiaEmergeAnim); - this->actionFunc = BossFd2_Emerge; - this->skelAnime.playSpeed = 0.0f; - temp_rand = Rand_ZeroFloat(8.9f); - this->actor.world.pos.x = sHoleLocations[temp_rand].x; - this->actor.world.pos.z = sHoleLocations[temp_rand].z; - this->work[FD2_ACTION_STATE] = 0; - osSyncPrintf("UP INIT 2\n"); - this->timers[0] = 10; - if (bossFd != NULL) { - health = bossFd->actor.colChkInfo.health; - if (health >= 18) { - this->work[FD2_FAKEOUT_COUNT] = 0; - } else if (health >= 12) { - this->work[FD2_FAKEOUT_COUNT] = 1; - } else if (health >= 6) { - this->work[FD2_FAKEOUT_COUNT] = 2; - } else { - this->work[FD2_FAKEOUT_COUNT] = 3; - } - } -} - -void BossFd2_Emerge(BossFd2* this, GlobalContext* globalCtx) { - s8 health; - BossFd* bossFd = (BossFd*)this->actor.parent; - Player* player = GET_PLAYER(globalCtx); - s16 i; - s16 holeTime; - - osSyncPrintf("UP 1 mode %d\n", this->work[FD2_ACTION_STATE]); - SkelAnime_Update(&this->skelAnime); - osSyncPrintf("UP 1.5 \n"); - switch (this->work[FD2_ACTION_STATE]) { - case 0: - osSyncPrintf("UP time %d \n", this->timers[0]); - osSyncPrintf("PL time %x \n", player); - osSyncPrintf("MT time %x \n", bossFd); - if ((this->timers[0] == 0) && (player->actor.world.pos.y > 70.0f)) { - osSyncPrintf("UP 1.6 \n"); - bossFd->faceExposed = 0; - bossFd->holePosition.x = this->actor.world.pos.x; - bossFd->holePosition.z = this->actor.world.pos.z; - func_80033E1C(globalCtx, 1, 0x32, 0x5000); - this->work[FD2_ACTION_STATE] = 1; - this->work[FD2_HOLE_COUNTER]++; - this->actor.world.pos.y = -200.0f; - health = bossFd->actor.colChkInfo.health; - if (health == 24) { - holeTime = 30; - } else if (health >= 18) { - holeTime = 25; - } else if (health >= 12) { - holeTime = 20; - } else if (health >= 6) { - holeTime = 10; - } else { - holeTime = 5; - } - this->timers[0] = holeTime; - bossFd->timers[4] = this->timers[0] + 10; - osSyncPrintf("UP 1.7 \n"); - } - break; - case 1: - if (this->timers[0] == 0) { - if (this->work[FD2_FAKEOUT_COUNT] != 0) { - this->work[FD2_FAKEOUT_COUNT]--; - i = Rand_ZeroFloat(8.9f); - this->actor.world.pos.x = sHoleLocations[i].x; - this->actor.world.pos.z = sHoleLocations[i].z; - this->work[FD2_ACTION_STATE] = 0; - this->timers[0] = 10; - } else { - this->skelAnime.playSpeed = 1.0f; - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaEmergeAnim); - this->work[FD2_ACTION_STATE] = 2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_ROAR); - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->timers[0] = 15; - this->actor.world.pos.y = 150.0f; - for (i = 0; i < 10; i++) { - this->rightMane.pos[i].x += Rand_CenteredFloat(100.0f); - this->rightMane.pos[i].z += Rand_CenteredFloat(100.0f); - this->leftMane.pos[i].x += Rand_CenteredFloat(100.0f); - this->leftMane.pos[i].z += Rand_CenteredFloat(100.0f); - } - bossFd->work[BFD_SPLASH_TIMER] = 5; - } - } - break; - case 2: - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0); - if ((this->timers[0] == 1) && (this->actor.xzDistToPlayer < 120.0f)) { - func_8002F6D4(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 2.0f, 0x20); - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - BossFd2_SetupIdle(this, globalCtx); - } - break; - } - osSyncPrintf("UP 2\n"); -} - -void BossFd2_SetupIdle(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - s8 health; - s16 idleTime; - - osSyncPrintf("UP INIT 1\n"); - Animation_PlayLoop(&this->skelAnime, &gHoleVolvagiaTurnAnim); - this->actionFunc = BossFd2_Idle; - health = bossFd->actor.colChkInfo.health; - if (health == 24) { - idleTime = 50; - } else if (health >= 18) { - idleTime = 40; - } else if (health >= 12) { - idleTime = 40; - } else if (health >= 6) { - idleTime = 30; - } else { - idleTime = 20; - } - this->timers[0] = idleTime; -} - -void BossFd2_Idle(BossFd2* this, GlobalContext* globalCtx) { - s16 prevToLink; - - SkelAnime_Update(&this->skelAnime); - prevToLink = this->work[FD2_TURN_TO_LINK]; - this->work[FD2_TURN_TO_LINK] = - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0, 0); - osSyncPrintf("SW1 = %d\n", prevToLink); - osSyncPrintf("SW2 = %d\n", this->work[FD2_TURN_TO_LINK]); - if ((fabsf(prevToLink) <= 1000.0f) && (1000.0f < fabsf(this->work[FD2_TURN_TO_LINK]))) { - Animation_MorphToLoop(&this->skelAnime, &gHoleVolvagiaTurnAnim, -5.0f); - } - if ((1000.0f < fabsf(prevToLink)) && (fabsf(this->work[FD2_TURN_TO_LINK]) <= 1000.0f)) { - Animation_MorphToLoop(&this->skelAnime, &gHoleVolvagiaIdleAnim, -5.0f); - } - if (this->timers[0] == 0) { - if (this->actor.xzDistToPlayer < 200.0f) { - BossFd2_SetupClawSwipe(this, globalCtx); - } else { - BossFd2_SetupBreatheFire(this, globalCtx); - } - } -} - -void BossFd2_SetupBurrow(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - - Animation_MorphToPlayOnce(&this->skelAnime, &gHoleVolvagiaBurrowAnim, -5.0f); - this->actionFunc = BossFd2_Burrow; - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaBurrowAnim); - bossFd->timers[4] = 30; - this->work[FD2_ACTION_STATE] = 0; -} - -void BossFd2_Burrow(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - - if (this->work[FD2_ACTION_STATE] == 0) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - this->work[FD2_ACTION_STATE] = 1; - this->timers[0] = 25; - } - } else { - Math_ApproachF(&this->actor.world.pos.y, -100.0f, 1.0f, 10.0f); - if (this->timers[0] == 0) { - if ((this->work[FD2_HOLE_COUNTER] >= 3) && ((s8)bossFd->actor.colChkInfo.health < 24)) { - this->work[FD2_HOLE_COUNTER] = 0; - this->actionFunc = BossFd2_Wait; - bossFd->handoffSignal = FD2_SIGNAL_FLY; - } else { - BossFd2_SetupEmerge(this, globalCtx); - } - } - } -} - -void BossFd2_SetupBreatheFire(BossFd2* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &gHoleVolvagiaBreatheFireAnim, -5.0f); - this->actionFunc = BossFd2_BreatheFire; - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaBreatheFireAnim); - this->work[FD2_ACTION_STATE] = 0; -} - -static Vec3f sUnkVec = { 0.0f, 0.0f, 50.0f }; // Unused? BossFd uses a similar array for its fire breath sfx. - -void BossFd2_BreatheFire(BossFd2* this, GlobalContext* globalCtx) { - s16 i; - Vec3f toLink; - s16 angleX; - s16 angleY; - s16 breathOpacity = 0; - BossFd* bossFd = (BossFd*)this->actor.parent; - Player* player = GET_PLAYER(globalCtx); - f32 tempX; - f32 tempY; - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - BossFd2_SetupBurrow(this, globalCtx); - } - if ((25.0f <= this->skelAnime.curFrame) && (this->skelAnime.curFrame < 70.0f)) { - if (this->skelAnime.curFrame == 25.0f) { - globalCtx->envCtx.unk_D8 = 0.0f; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_FIRE - SFX_FLAG); - if (this->skelAnime.curFrame > 50) { - breathOpacity = (70.0f - this->skelAnime.curFrame) * 12.0f; - } else { - breathOpacity = 255; - } - toLink.x = player->actor.world.pos.x - this->headPos.x; - toLink.y = player->actor.world.pos.y - this->headPos.y; - toLink.z = player->actor.world.pos.z - this->headPos.z; - angleY = Math_Atan2S(toLink.z, toLink.x); - angleX = -Math_Atan2S(sqrtf(SQ(toLink.x) + SQ(toLink.z)), toLink.y); - angleY -= this->actor.shape.rot.y; - if (angleY > 0x1F40) { - angleY = 0x1F40; - } - if (angleY < -0x1F40) { - angleY = -0x1F40; - } - angleX += (-0x1B58); - if (angleX > 0x3E8) { - angleX = 0x3E8; - } - if (angleX < -0xFA0) { - angleX = -0xFA0; - } - Math_ApproachS(&this->headRot.y, angleY, 5, 0x7D0); - Math_ApproachS(&this->headRot.x, angleX, 5, 0x7D0); - } else { - Math_ApproachS(&this->headRot.y, 0, 5, 0x7D0); - Math_ApproachS(&this->headRot.x, 0, 5, 0x7D0); - } - if (breathOpacity != 0) { - f32 breathScale; - Vec3f spawnSpeed = { 0.0f, 0.0f, 0.0f }; - Vec3f spawnVel; - Vec3f spawnAccel = { 0.0f, 0.0f, 0.0f }; - Vec3f spawnPos; - - bossFd->fogMode = 2; - spawnSpeed.z = 30.0f; - spawnPos = this->headPos; - - tempY = ((this->actor.shape.rot.y + this->headRot.y) / (f32)0x8000) * M_PI; - tempX = ((this->headRot.x / (f32)0x8000) * M_PI) + 1.0f / 2; - Matrix_RotateY(tempY, MTXMODE_NEW); - Matrix_RotateX(tempX, MTXMODE_APPLY); - Matrix_MultVec3f(&spawnSpeed, &spawnVel); - - breathScale = 300.0f + 50.0f * Math_SinS(this->work[FD2_VAR_TIMER] * 0x2000); - BossFd2_SpawnFireBreath(globalCtx, bossFd->effects, &spawnPos, &spawnVel, &spawnAccel, breathScale, - breathOpacity, this->actor.shape.rot.y + this->headRot.y); - - spawnPos.x += spawnVel.x * 0.5f; - spawnPos.y += spawnVel.y * 0.5f; - spawnPos.z += spawnVel.z * 0.5f; - - breathScale = 300.0f + 50.0f * Math_SinS(this->work[FD2_VAR_TIMER] * 0x2000); - BossFd2_SpawnFireBreath(globalCtx, bossFd->effects, &spawnPos, &spawnVel, &spawnAccel, breathScale, - breathOpacity, this->actor.shape.rot.y + this->headRot.y); - - spawnSpeed.x = 0.0f; - spawnSpeed.y = 17.0f; - spawnSpeed.z = 0.0f; - - for (i = 0; i < 6; i++) { - tempY = Rand_ZeroFloat(2.0f * M_PI); - tempX = Rand_ZeroFloat(2.0f * M_PI); - Matrix_RotateY(tempY, MTXMODE_NEW); - Matrix_RotateX(tempX, MTXMODE_APPLY); - Matrix_MultVec3f(&spawnSpeed, &spawnVel); - - spawnAccel.x = (spawnVel.x * -10.0f) / 100.0f; - spawnAccel.y = (spawnVel.y * -10.0f) / 100.0f; - spawnAccel.z = (spawnVel.z * -10.0f) / 100.0f; - - BossFd2_SpawnEmber(globalCtx, bossFd->effects, &this->headPos, &spawnVel, &spawnAccel, - (s16)Rand_ZeroFloat(2.0f) + 8); - } - } -} - -void BossFd2_SetupClawSwipe(BossFd2* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &gHoleVolvagiaClawSwipeAnim, -5.0f); - this->actionFunc = BossFd2_ClawSwipe; - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaClawSwipeAnim); -} - -void BossFd2_ClawSwipe(BossFd2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_ROAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_SW_NAIL); - } - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - BossFd2_SetupBurrow(this, globalCtx); - } -} - -void BossFd2_SetupVulnerable(BossFd2* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gHoleVolvagiaKnockoutAnim); - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaKnockoutAnim); - this->actionFunc = BossFd2_Vulnerable; - this->work[FD2_ACTION_STATE] = 0; -} - -void BossFd2_Vulnerable(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - s16 i; - - this->disableAT = true; - this->actor.flags |= ACTOR_FLAG_10; - SkelAnime_Update(&this->skelAnime); - switch (this->work[FD2_ACTION_STATE]) { - case 0: - if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_MAHI2); - } - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME] - 3.0f)) { - for (i = 0; i < 25; i++) { - Vec3f spawnVel; - Vec3f spawnAccel = { 0.0f, 0.0f, 0.0f }; - Vec3f spawnPos; - - spawnVel.x = Rand_CenteredFloat(8.0f); - spawnVel.y = Rand_ZeroFloat(1.0f); - spawnVel.z = Rand_CenteredFloat(8.0f); - - spawnAccel.y = 0.5f; - - spawnPos.x = Rand_CenteredFloat(10.0f) + this->actor.focus.pos.x; - spawnPos.y = Rand_CenteredFloat(10.0f) + this->actor.focus.pos.y; - spawnPos.z = Rand_CenteredFloat(10.0f) + this->actor.focus.pos.z; - - BossFd2_SpawnDust(bossFd->effects, &spawnPos, &spawnVel, &spawnAccel, - Rand_ZeroFloat(100.0f) + 300.0f); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_LAND); - } - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - Animation_MorphToLoop(&this->skelAnime, &gHoleVolvagiaVulnerableAnim, -5.0f); - this->work[FD2_ACTION_STATE] = 1; - this->timers[0] = 60; - } - break; - case 1: - if ((this->work[FD2_VAR_TIMER] & 0xF) == 0xF) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_KNOCKOUT); - } - if (this->timers[0] == 0) { - BossFd2_SetupBurrow(this, globalCtx); - } - break; - } -} - -void BossFd2_SetupDamaged(BossFd2* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gHoleVolvagiaHitAnim); - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaHitAnim); - this->actionFunc = BossFd2_Damaged; - this->work[FD2_ACTION_STATE] = 0; -} - -void BossFd2_Damaged(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - - SkelAnime_Update(&this->skelAnime); - this->disableAT = true; - if (this->work[FD2_ACTION_STATE] == 0) { - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - Animation_PlayOnce(&this->skelAnime, &gHoleVolvagiaDamagedAnim); - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaDamagedAnim); - this->work[FD2_ACTION_STATE] = 1; - } - } else if (this->work[FD2_ACTION_STATE] == 1) { - if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_DAMAGE2); - } - if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - bossFd->timers[4] = 30; - } - if (Animation_OnFrame(&this->skelAnime, this->fwork[FD2_END_FRAME])) { - this->work[FD2_ACTION_STATE] = 2; - this->timers[0] = 25; - } - } else { - Math_ApproachF(&this->actor.world.pos.y, -100.0f, 1.0f, 10.0f); - if (this->timers[0] == 0) { - this->actionFunc = BossFd2_Wait; - bossFd->handoffSignal = FD2_SIGNAL_FLY; - } - } -} - -void BossFd2_SetupDeath(BossFd2* this, GlobalContext* globalCtx) { - this->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaDamagedAnim); - Animation_Change(&this->skelAnime, &gHoleVolvagiaDamagedAnim, 1.0f, 0.0f, this->fwork[FD2_END_FRAME], - ANIMMODE_ONCE_INTERP, -3.0f); - this->actionFunc = BossFd2_Death; - this->actor.flags &= ~ACTOR_FLAG_0; - this->deathState = DEATH_START; -} - -void BossFd2_UpdateCamera(BossFd2* this, GlobalContext* globalCtx) { - if (this->deathCamera != SUBCAM_FREE) { - Math_ApproachF(&this->camData.eye.x, this->camData.nextEye.x, this->camData.eyeMaxVel.x, - this->camData.eyeVel.x * this->camData.speedMod); - Math_ApproachF(&this->camData.eye.y, this->camData.nextEye.y, this->camData.eyeMaxVel.y, - this->camData.eyeVel.y * this->camData.speedMod); - Math_ApproachF(&this->camData.eye.z, this->camData.nextEye.z, this->camData.eyeMaxVel.z, - this->camData.eyeVel.z * this->camData.speedMod); - Math_ApproachF(&this->camData.at.x, this->camData.nextAt.x, this->camData.atMaxVel.x, - this->camData.atVel.x * this->camData.speedMod); - Math_ApproachF(&this->camData.at.y, this->camData.nextAt.y, this->camData.atMaxVel.y, - this->camData.atVel.y * this->camData.speedMod); - Math_ApproachF(&this->camData.at.z, this->camData.nextAt.z, this->camData.atMaxVel.z, - this->camData.atVel.z * this->camData.speedMod); - Math_ApproachF(&this->camData.speedMod, 1.0f, 1.0f, this->camData.accel); - this->camData.at.y += this->camData.yMod; - Gameplay_CameraSetAtEye(globalCtx, this->deathCamera, &this->camData.at, &this->camData.eye); - Math_ApproachF(&this->camData.yMod, 0.0f, 1.0f, 0.1f); - } -} - -void BossFd2_Death(BossFd2* this, GlobalContext* globalCtx) { - f32 retreatSpeed; - Vec3f sp70; - Vec3f sp64; - BossFd* bossFd = (BossFd*)this->actor.parent; - Camera* mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - f32 pad3; - f32 pad2; - f32 pad1; - f32 cameraShake; - SkelAnime* skelAnime = &this->skelAnime; - - SkelAnime_Update(skelAnime); - switch (this->deathState) { - case DEATH_START: - this->deathState = DEATH_RETREAT; - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 1); - this->deathCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->deathCamera, CAM_STAT_ACTIVE); - this->camData.eye = mainCam->eye; - this->camData.at = mainCam->at; - this->camData.eyeVel.x = 100.0f; - this->camData.eyeVel.y = 100.0f; - this->camData.eyeVel.z = 100.0f; - this->camData.atVel.x = 100.0f; - this->camData.atVel.y = 100.0f; - this->camData.atVel.z = 100.0f; - this->camData.accel = 0.02f; - this->timers[0] = 0; - this->work[FD2_HOLE_COUNTER] = 0; - this->camData.eyeMaxVel.x = 0.1f; - this->camData.eyeMaxVel.y = 0.1f; - this->camData.eyeMaxVel.z = 0.1f; - this->camData.atMaxVel.x = 0.1f; - this->camData.atMaxVel.y = 0.1f; - this->camData.atMaxVel.z = 0.1f; - case DEATH_RETREAT: - this->work[FD2_HOLE_COUNTER]++; - if (this->work[FD2_HOLE_COUNTER] < 15) { - retreatSpeed = 1.0f; - } else if (this->work[FD2_HOLE_COUNTER] < 20) { - retreatSpeed = 0.5f; - } else { - retreatSpeed = 0.25f; - } - if ((this->work[FD2_HOLE_COUNTER] == 1) || (this->work[FD2_HOLE_COUNTER] == 40)) { - this->work[FD2_SCREAM_TIMER] = 20; - if (this->work[FD2_HOLE_COUNTER] == 40) { - Audio_StopSfxById(NA_SE_EN_VALVAISA_DEAD); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_DAMAGE2); - } - Math_ApproachF(&this->skelAnime.playSpeed, retreatSpeed, 1.0f, 1.0f); - Matrix_RotateY(((this->actor.yawTowardsPlayer / (f32)0x8000) * M_PI) + 0.2f, MTXMODE_NEW); - sp70.x = 0.0f; - sp70.y = 0.0f; - sp70.z = 250.0f; - Matrix_MultVec3f(&sp70, &sp64); - this->camData.nextEye.x = this->actor.world.pos.x + sp64.x; - this->camData.nextEye.y = 140.0f; - this->camData.nextEye.z = this->actor.world.pos.z + sp64.z; - if (this->actor.focus.pos.y >= 90.0f) { - this->camData.nextAt.y = this->actor.focus.pos.y; - this->camData.nextAt.x = this->actor.focus.pos.x; - this->camData.nextAt.z = this->actor.focus.pos.z; - } - if (this->timers[0] == 0) { - if (Animation_OnFrame(skelAnime, 20.0f)) { - bossFd->timers[4] = 60; - } - if (this->work[FD2_HOLE_COUNTER] >= 100) { - this->deathState = DEATH_HANDOFF; - this->timers[0] = 50; - } - } else if (Animation_OnFrame(skelAnime, 15.0f)) { - Animation_MorphToPlayOnce(skelAnime, &gHoleVolvagiaDamagedAnim, -10.0f); - } - break; - case DEATH_HANDOFF: - if (this->timers[0] == 0) { - this->actor.draw = NULL; - this->deathState = DEATH_FD_BODY; - bossFd->handoffSignal = FD2_SIGNAL_DEATH; - this->work[FD2_ACTION_STATE] = 0; - this->camData.speedMod = 0.0f; - } else { - Math_ApproachF(&this->actor.world.pos.y, -100.0f, 1.0f, 5.0f); - } - break; - case DEATH_FD_BODY: - if (bossFd->actor.world.pos.y < 80.0f) { - if (bossFd->actor.world.rot.x > 0x3000) { - this->camData.nextAt = bossFd->actor.world.pos; - this->camData.nextAt.y = 80.0f; - this->camData.nextEye.x = bossFd->actor.world.pos.x; - this->camData.nextEye.y = 150.0f; - this->camData.nextEye.z = bossFd->actor.world.pos.z + 300.0f; - } - } else { - this->camData.nextAt = bossFd->actor.world.pos; - this->camData.nextEye.x = this->actor.world.pos.x; - Math_ApproachF(&this->camData.nextEye.y, 200.0f, 1.0f, 2.0f); - Math_ApproachF(&this->camData.nextEye.z, bossFd->actor.world.pos.z + 200.0f, 1.0f, 3.0f); - if (this->work[FD2_ACTION_STATE] == 0) { - this->work[FD2_ACTION_STATE]++; - this->camData.speedMod = 0.0f; - this->camData.accel = 0.02f; - func_8002DF54(globalCtx, &bossFd->actor, 1); - } - } - if ((bossFd->work[BFD_ACTION_STATE] == BOSSFD_BONES_FALL) && (bossFd->timers[0] == 5)) { - this->deathState = DEATH_FD_SKULL; - this->camData.speedMod = 0.0f; - this->camData.accel = 0.02f; - this->camData.nextEye.y = 150.0f; - this->camData.nextEye.z = bossFd->actor.world.pos.z + 300.0f; - } - break; - case DEATH_FD_SKULL: - Math_ApproachF(&this->camData.nextAt.y, 100.0, 1.0f, 100.0f); - this->camData.nextAt.x = 0.0f; - this->camData.nextAt.z = 0.0f; - this->camData.nextEye.x = 0.0f; - this->camData.nextEye.y = 140.0f; - Math_ApproachF(&this->camData.nextEye.z, 220.0f, 0.5f, 1.15f); - if (bossFd->work[BFD_CAM_SHAKE_TIMER] != 0) { - bossFd->work[BFD_CAM_SHAKE_TIMER]--; - cameraShake = bossFd->work[BFD_CAM_SHAKE_TIMER] / 0.5f; - if (cameraShake >= 20.0f) { - cameraShake = 20.0f; - } - this->camData.yMod = (bossFd->work[BFD_CAM_SHAKE_TIMER] & 1) ? cameraShake : -cameraShake; - } - if (bossFd->work[BFD_ACTION_STATE] == BOSSFD_SKULL_BURN) { - this->deathState = DEATH_FINISH; - mainCam->eye = this->camData.eye; - mainCam->eyeNext = this->camData.eye; - mainCam->at = this->camData.at; - func_800C08AC(globalCtx, this->deathCamera, 0); - this->deathCamera = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 100.0f, 0.0f, - 0, 0, 0, WARP_DUNGEON_ADULT); - Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); - } - break; - case DEATH_FINISH: - break; - } - BossFd2_UpdateCamera(this, globalCtx); -} - -void BossFd2_Wait(BossFd2* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; - - if (bossFd->handoffSignal == FD2_SIGNAL_GROUND) { - bossFd->handoffSignal = FD2_SIGNAL_NONE; - BossFd2_SetupEmerge(this, globalCtx); - this->timers[0] = 20; - this->work[FD2_HOLE_COUNTER] = 0; - } -} - -void BossFd2_CollisionCheck(BossFd2* this, GlobalContext* globalCtx) { - s16 i; - ColliderInfo* hurtbox; - BossFd* bossFd = (BossFd*)this->actor.parent; - - if (this->actionFunc == BossFd2_ClawSwipe) { - Player* player = GET_PLAYER(globalCtx); - - for (i = 0; i < ARRAY_COUNT(this->elements); i++) { - if (this->collider.elements[i].info.toucherFlags & TOUCH_HIT) { - this->collider.elements[i].info.toucherFlags &= ~TOUCH_HIT; - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - } - } - if (!bossFd->faceExposed) { - this->collider.elements[0].info.elemType = ELEMTYPE_UNK2; - this->collider.base.colType = COLTYPE_METAL; - } else { - this->collider.elements[0].info.elemType = ELEMTYPE_UNK3; - this->collider.base.colType = COLTYPE_HIT3; - } - - if (this->collider.elements[0].info.bumperFlags & BUMP_HIT) { - this->collider.elements[0].info.bumperFlags &= ~BUMP_HIT; - - hurtbox = this->collider.elements[0].info.acHitInfo; - if (!bossFd->faceExposed) { - if (hurtbox->toucher.dmgFlags & 0x40000040) { - bossFd->actor.colChkInfo.health -= 2; - if ((s8)bossFd->actor.colChkInfo.health <= 2) { - bossFd->actor.colChkInfo.health = 1; - } - bossFd->faceExposed = true; - BossFd2_SetupVulnerable(this, globalCtx); - this->work[FD2_INVINC_TIMER] = 30; - this->work[FD2_DAMAGE_FLASH_TIMER] = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_MAHI1); - for (i = 0; i < 30; i++) { - Vec3f debrisVel = { 0.0f, 0.0f, 0.0f }; - Vec3f debrisAccel = { 0.0f, -1.0f, 0.0f }; - Vec3f debrisPos; - - debrisVel.x = Rand_CenteredFloat(10.0f); - debrisVel.y = Rand_ZeroFloat(5.0f) + 8.0f; - debrisVel.z = Rand_CenteredFloat(10.0f); - - debrisPos.x = this->actor.focus.pos.x; - debrisPos.y = this->actor.focus.pos.y; - debrisPos.z = this->actor.focus.pos.z; - - BossFd2_SpawnDebris(globalCtx, bossFd->effects, &debrisPos, &debrisVel, &debrisAccel, - (s16)Rand_ZeroFloat(10.0) + 10); - } - } - } else { - u8 canKill = false; - u8 damage; - - if ((damage = CollisionCheck_GetSwordDamage(hurtbox->toucher.dmgFlags)) == 0) { - damage = (hurtbox->toucher.dmgFlags & 0x00001000) ? 4 : 2; - } else { - canKill = true; - } - if (hurtbox->toucher.dmgFlags & 0x80) { - damage = 0; - } - if (((s8)bossFd->actor.colChkInfo.health > 2) || canKill) { - bossFd->actor.colChkInfo.health -= damage; - osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("damage %d\n", damage); - } - osSyncPrintf(VT_RST); - osSyncPrintf("hp %d\n", bossFd->actor.colChkInfo.health); - - if ((s8)bossFd->actor.colChkInfo.health <= 0) { - bossFd->actor.colChkInfo.health = 0; - BossFd2_SetupDeath(this, globalCtx); - this->work[FD2_DAMAGE_FLASH_TIMER] = 10; - this->work[FD2_INVINC_TIMER] = 30000; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else if (damage) { - BossFd2_SetupDamaged(this, globalCtx); - this->work[FD2_DAMAGE_FLASH_TIMER] = 10; - this->work[FD2_INVINC_TIMER] = 100; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_DAMAGE1); - } - if (damage) { - for (i = 0; i < 30; i++) { - Vec3f pieceVel = { 0.0f, 0.0f, 0.0f }; - Vec3f pieceAccel = { 0.0f, -1.0f, 0.0f }; - Vec3f piecePos; - - pieceVel.x = Rand_CenteredFloat(6.0f); - pieceVel.y = Rand_ZeroFloat(4.0f) + 6.0f; - pieceVel.z = Rand_CenteredFloat(6.0f); - - piecePos.x = this->actor.focus.pos.x; - piecePos.y = this->actor.focus.pos.y; - piecePos.z = this->actor.focus.pos.z; - - BossFd2_SpawnSkullPiece(globalCtx, bossFd->effects, &piecePos, &pieceVel, &pieceAccel, - (s16)Rand_ZeroFloat(6.0f) + 10); - } - } - } - } -} - -void BossFd2_UpdateFace(BossFd2* this, GlobalContext* globalCtx) { - f32 maxOpen; - f32 openRate; - s16 eyeStates[5] = { EYE_OPEN, EYE_HALF, EYE_CLOSED, EYE_CLOSED, EYE_HALF }; - - if (((this->work[FD2_VAR_TIMER] % 8) == 0) && (Rand_ZeroOne() < 0.3f)) { - this->work[FD2_BLINK_TIMER] = 4; - } - if ((this->actionFunc == BossFd2_Vulnerable) || (this->actionFunc == BossFd2_Damaged)) { - if (this->work[FD2_VAR_TIMER] & 0x10) { - this->eyeState = EYE_HALF; - } else { - this->eyeState = EYE_CLOSED; - } - } else { - this->eyeState = eyeStates[this->work[FD2_BLINK_TIMER]]; - } - - if (this->work[FD2_BLINK_TIMER] != 0) { - this->work[FD2_BLINK_TIMER]--; - } - - if (this->work[FD2_SCREAM_TIMER] != 0) { - maxOpen = 6000.0f; - openRate = 1300.0f; - } else { - maxOpen = (this->work[FD2_VAR_TIMER] & 0x10) ? 1000.0f : 0.0f; - openRate = 700.0f; - } - Math_ApproachF(&this->jawOpening, maxOpen, 0.3f, openRate); - - if (this->work[FD2_SCREAM_TIMER] != 0) { - this->work[FD2_SCREAM_TIMER]--; - } -} - -void BossFd2_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BossFd2* this = (BossFd2*)thisx; - s16 i; - - osSyncPrintf("FD2 move start \n"); - this->disableAT = false; - this->actor.flags &= ~ACTOR_FLAG_10; - this->work[FD2_VAR_TIMER]++; - this->work[FD2_UNK_TIMER]++; - - this->actionFunc(this, globalCtx); - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - if (this->work[FD2_DAMAGE_FLASH_TIMER] != 0) { - this->work[FD2_DAMAGE_FLASH_TIMER]--; - } - if (this->work[FD2_INVINC_TIMER] != 0) { - this->work[FD2_INVINC_TIMER]--; - } - - if (this->deathState == DEATH_START) { - if (this->work[FD2_INVINC_TIMER] == 0) { - BossFd2_CollisionCheck(this, globalCtx); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (!this->disableAT) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - BossFd2_UpdateFace(this, globalCtx); - this->fwork[FD2_TEX1_SCROLL_X] += 4.0f; - this->fwork[FD2_TEX1_SCROLL_Y] = 120.0f; - this->fwork[FD2_TEX2_SCROLL_X] += 3.0f; - this->fwork[FD2_TEX2_SCROLL_Y] -= 2.0f; - if (this->actor.focus.pos.y < 90.0f) { - this->actor.flags &= ~ACTOR_FLAG_0; - } else { - this->actor.flags |= ACTOR_FLAG_0; - } -} - -s32 BossFd2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossFd2* this = (BossFd2*)thisx; - BossFd* bossFd = (BossFd*)this->actor.parent; - - if (limbIndex == 31) { - rot->y -= (f32)this->headRot.y; - rot->z += (f32)this->headRot.x; - } - switch (limbIndex) { - case 35: - case 36: - rot->z -= this->jawOpening * 0.1f; - break; - case 32: - rot->z += this->jawOpening; - break; - } - if ((bossFd->faceExposed == 1) && (limbIndex == 35)) { - *dList = gHoleVolvagiaBrokenFaceDL; - } - - if ((limbIndex == 32) || (limbIndex == 35) || (limbIndex == 36)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2165); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)bossFd->fwork[BFD_HEAD_TEX2_ALPHA]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2172); - } else { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2174); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)bossFd->fwork[BFD_BODY_TEX2_ALPHA]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2181); - } - if ((0 < limbIndex) && (limbIndex < 16)) { - *dList = NULL; - } - return false; -} - -void BossFd2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f targetMod = { 4500.0f, 0.0f, 0.0f }; - static Vec3f headMod = { 4000.0f, 0.0f, 0.0f }; - static Vec3f centerManeMod = { 4000.0f, -2900.0, 2000.0f }; - static Vec3f rightManeMod = { 4000.0f, -1600.0, 0.0f }; - static Vec3f leftManeMod = { 4000.0f, -1600.0, -2000.0f }; - BossFd2* this = (BossFd2*)thisx; - - if (limbIndex == 35) { - Matrix_MultVec3f(&targetMod, &this->actor.focus.pos); - Matrix_MultVec3f(&headMod, &this->headPos); - Matrix_MultVec3f(¢erManeMod, &this->centerMane.head); - Matrix_MultVec3f(&rightManeMod, &this->rightMane.head); - Matrix_MultVec3f(&leftManeMod, &this->leftMane.head); - } - Collider_UpdateSpheres(limbIndex, &this->collider); -} - -void BossFd2_UpdateMane(BossFd2* this, GlobalContext* globalCtx, Vec3f* head, Vec3f* pos, Vec3f* rot, Vec3f* pull, - f32* scale) { - f32 sp138[10] = { 0.0f, 100.0f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - f32 sp110[10] = { 0.0f, 5.0f, -10.0f, 500.0f, 500.0f, 500.0f, 500.0f, 500.0f, 500.0f, 500.0f }; - f32 spE8[10] = { 0.4f, 0.6f, 0.8f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - s16 i; - Vec3f temp_vec; - f32 temp_f2; - f32 phi_f0; - f32 temp_angleX; - f32 temp_angleY; - Vec3f spBC; - Vec3f spB0; - f32 xyScale; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2389); - Matrix_Push(); - gDPPipeSync(POLY_OPA_DISP++); - - for (i = 0; i < 10; i++) { - if (i == 0) { - (pos + i)->x = head->x; - (pos + i)->y = head->y; - (pos + i)->z = head->z; - } else { - Math_ApproachF(&(pull + i)->x, 0.0f, 1.0f, 1.0f); - Math_ApproachF(&(pull + i)->y, 0.0f, 1.0f, 1.0f); - Math_ApproachF(&(pull + i)->z, 0.0f, 1.0f, 1.0f); - } - } - - for (i = 1; i < 10; i++) { - temp_vec.x = (pos + i)->x + (pull + i)->x - (pos + i - 1)->x; - - phi_f0 = (pos + i)->y + (pull + i)->y - 2.0f + sp138[i]; - temp_f2 = (pos + i - 1)->y + sp110[i]; - if (phi_f0 > temp_f2) { - phi_f0 = temp_f2; - } - if ((head->y >= -910.0f) && (phi_f0 < 110.0f)) { - phi_f0 = 110.0f; - } - temp_vec.y = phi_f0 - (pos + i - 1)->y; - - temp_vec.z = (pos + i)->z + (pull + i)->z - (pos + i - 1)->z; - temp_angleY = Math_Atan2F(temp_vec.z, temp_vec.x); - temp_angleX = -Math_Atan2F(sqrtf(SQ(temp_vec.x) + SQ(temp_vec.z)), temp_vec.y); - (rot + i - 1)->y = temp_angleY; - (rot + i - 1)->x = temp_angleX; - spBC.x = 0.0f; - spBC.y = 0.0f; - spBC.z = spE8[i] * 25.0f; - Matrix_RotateY(temp_angleY, MTXMODE_NEW); - Matrix_RotateX(temp_angleX, MTXMODE_APPLY); - Matrix_MultVec3f(&spBC, &spB0); - temp_vec.x = (pos + i)->x; - temp_vec.y = (pos + i)->y; - temp_vec.z = (pos + i)->z; - (pos + i)->x = (pos + i - 1)->x + spB0.x; - (pos + i)->y = (pos + i - 1)->y + spB0.y; - (pos + i)->z = (pos + i - 1)->z + spB0.z; - (pull + i)->x = (((pos + i)->x - temp_vec.x) * 88.0f) / 100.0f; - (pull + i)->y = (((pos + i)->y - temp_vec.y) * 88.0f) / 100.0f; - (pull + i)->z = (((pos + i)->z - temp_vec.z) * 88.0f) / 100.0f; - if ((pull + i)->x > 30.0f) { - (pull + i)->x = 30.0f; - } - if ((pull + i)->x < -30.0f) { - (pull + i)->x = -30.0f; - } - if ((pull + i)->y > 30.0f) { - (pull + i)->y = 30.0f; - } - if ((pull + i)->y < -30.0f) { - (pull + i)->y = -30.0f; - } - if ((pull + i)->z > 30.0f) { - (pull + i)->z = 30.0f; - } - if ((pull + i)->z < -30.0f) { - (pull + i)->z = -30.0f; - } - } - - for (i = 0; i < 9; i++) { - Matrix_Translate((pos + i)->x, (pos + i)->y, (pos + i)->z, MTXMODE_NEW); - Matrix_RotateY((rot + i)->y, MTXMODE_APPLY); - Matrix_RotateX((rot + i)->x, MTXMODE_APPLY); - xyScale = (0.01f - (i * 0.0009f)) * spE8[i] * scale[i]; - Matrix_Scale(xyScale, xyScale, 0.01f * spE8[i], MTXMODE_APPLY); - Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2498), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gHoleVolvagiaManeModelDL); - } - Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2503); -} - -void BossFd2_DrawMane(BossFd2* this, GlobalContext* globalCtx) { - s32 pad; - BossFd* bossFd = (BossFd*)this->actor.parent; - s16 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2515); - if (1) {} - for (i = 0; i < 10; i++) { - this->centerMane.scale[i] = 1.5f + 0.3f * Math_SinS(5596.0f * this->work[FD2_VAR_TIMER] + i * 0x3200); - this->rightMane.scale[i] = 1.5f + 0.3f * Math_SinS(5496.0f * this->work[FD2_VAR_TIMER] + i * 0x3200); - this->leftMane.scale[i] = 1.5f + 0.3f * Math_CosS(5696.0f * this->work[FD2_VAR_TIMER] + i * 0x3200); - } - - func_80093D84(globalCtx->state.gfxCtx); - - gSPDisplayList(POLY_XLU_DISP++, gHoleVolvagiaManeMaterialDL); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, bossFd->fwork[BFD_MANE_COLOR_CENTER], 0, 255); - BossFd2_UpdateMane(this, globalCtx, &this->centerMane.head, this->centerMane.pos, this->centerMane.rot, - this->centerMane.pull, this->centerMane.scale); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, bossFd->fwork[BFD_MANE_COLOR_RIGHT], 0, 255); - BossFd2_UpdateMane(this, globalCtx, &this->rightMane.head, this->rightMane.pos, this->rightMane.rot, - this->rightMane.pull, this->rightMane.scale); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, bossFd->fwork[BFD_MANE_COLOR_LEFT], 0, 255); - BossFd2_UpdateMane(this, globalCtx, &this->leftMane.head, this->leftMane.pos, this->leftMane.rot, - this->leftMane.pull, this->leftMane.scale); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2601); -} - -void BossFd2_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gHoleVolvagiaEyeOpenTex, gHoleVolvagiaEyeHalfTex, gHoleVolvagiaEyeClosedTex }; - s32 pad; - BossFd2* this = (BossFd2*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2617); - osSyncPrintf("FD2 draw start \n"); - if (this->actionFunc != BossFd2_Wait) { - func_80093D18(globalCtx->state.gfxCtx); - if (this->work[FD2_DAMAGE_FLASH_TIMER] & 2) { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 255, 255, 0, 900, 1099); - } - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeState])); - - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)this->fwork[FD2_TEX1_SCROLL_X], - (s16)this->fwork[FD2_TEX1_SCROLL_Y], 0x20, 0x20, 1, - (s16)this->fwork[FD2_TEX2_SCROLL_X], (s16)this->fwork[FD2_TEX2_SCROLL_Y], 0x20, - 0x20)); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 128); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossFd2_OverrideLimbDraw, BossFd2_PostLimbDraw, &this->actor); - BossFd2_DrawMane(this, globalCtx); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2688); -} diff --git a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.cpp b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.cpp new file mode 100644 index 000000000..39fce134d --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.cpp @@ -0,0 +1,1231 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_FD2_Z_BOSS_FD2_C +#include "actor_common.h" +/* + * File: z_boss_fd2.c + * Overlay: ovl_Boss_Fd2 + * Description: Volvagia, hole form + */ + +#include "z_boss_fd2.h" +#include "objects/object_fd2/object_fd2.h" +#include "overlays/actors/ovl_Boss_Fd/z_boss_fd.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "vt.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_demo.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +typedef enum { + /* 0 */ DEATH_START, + /* 1 */ DEATH_RETREAT, + /* 2 */ DEATH_HANDOFF, + /* 3 */ DEATH_FD_BODY, + /* 4 */ DEATH_FD_SKULL, + /* 5 */ DEATH_FINISH +} BossFd2CutsceneState; + +typedef enum { + /* 0 */ EYE_OPEN, + /* 1 */ EYE_HALF, + /* 2 */ EYE_CLOSED +} BossFd2EyeState; + +void BossFd2_Init(Actor* thisx, GlobalContext* globalCtx); +void BossFd2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossFd2_Update(Actor* thisx, GlobalContext* globalCtx); +void BossFd2_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BossFd2_SetupEmerge(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Emerge(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_SetupIdle(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Idle(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Burrow(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_SetupBreatheFire(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_BreatheFire(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_SetupClawSwipe(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_ClawSwipe(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Vulnerable(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Damaged(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Death(BossFd2* pthis, GlobalContext* globalCtx); +void BossFd2_Wait(BossFd2* pthis, GlobalContext* globalCtx); + +ActorInit Boss_Fd2_InitVars = { + ACTOR_BOSS_FD2, + ACTORCAT_BOSS, + FLAGS, + OBJECT_FD2, + sizeof(BossFd2), + (ActorFunc)BossFd2_Init, + (ActorFunc)BossFd2_Destroy, + (ActorFunc)BossFd2_Update, + (ActorFunc)BossFd2_Draw, +}; + +#include "z_boss_fd2_colchk.cpp" + +static Vec3f sHoleLocations[] = { + { 0.0f, 90.0f, -243.0f }, { 0.0f, 90.0f, 0.0f }, { 0.0f, 90.0f, 243.0f }, + { -243.0f, 90.0f, -243.0f }, { -243.0f, 90.0f, 0.0f }, { -243.0f, 90.0f, 243.0f }, + { 243.0f, 90.0f, -243.0f }, { 243.0f, 90.0f, 0.0f }, { 243.0f, 90.0f, 243.0f }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x21, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void BossFd2_SpawnDebris(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, + Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_DEBRIS; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->scale = scale / 1000.0f; + effect->vFdFxRotX = Rand_ZeroFloat(100.0f); + effect->vFdFxRotY = Rand_ZeroFloat(100.0f); + break; + } + } +} + +void BossFd2_SpawnFireBreath(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, + Vec3f* acceleration, f32 scale, s16 alpha, s16 kbAngle) { + s16 i; + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_FIRE_BREATH; + effect->timer1 = 0; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->pos.x -= effect->velocity.x; + effect->pos.y -= effect->velocity.y; + effect->pos.z -= effect->velocity.z; + effect->vFdFxScaleMod = 0.0f; + effect->alpha = alpha; + effect->vFdFxYStop = Rand_ZeroFloat(10.0f); + effect->timer2 = 0; + effect->scale = scale / 400.0f; + effect->kbAngle = kbAngle; + break; + } + } +} + +void BossFd2_SpawnEmber(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, + Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == 0) { + effect->type = BFD_FX_EMBER; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->scale = scale / 1000.0f; + effect->alpha = 255; + effect->timer1 = (s16)Rand_ZeroFloat(10.0f); + break; + } + } +} + +void BossFd2_SpawnSkullPiece(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* position, Vec3f* velocity, + Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_SKULL_PIECE; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->scale = scale / 1000.0f; + effect->vFdFxRotX = Rand_ZeroFloat(100.0f); + effect->vFdFxRotY = Rand_ZeroFloat(100.0f); + break; + } + } +} + +void BossFd2_SpawnDust(BossFdEffect* effect, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale) { + s16 i; + + for (i = 0; i < 180; i++, effect++) { + if (effect->type == BFD_FX_NONE) { + effect->type = BFD_FX_DUST; + effect->pos = *position; + effect->velocity = *velocity; + effect->accel = *acceleration; + effect->timer2 = 0; + effect->scale = scale / 400.0f; + break; + } + } +} + +void BossFd2_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossFd2* pthis = (BossFd2*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.0069999993f); + pthis->actor.world.pos.y = -850.0f; + ActorShape_Init(&pthis->actor.shape, -580.0f / pthis->actor.scale.y, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gHoleVolvagiaSkel, &gHoleVolvagiaIdleAnim, NULL, NULL, 0); + if (pthis->actor.params == BFD_CS_NONE) { + BossFd2_SetupEmerge(pthis, globalCtx); + } else { + pthis->actionFunc = BossFd2_Wait; + } + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->elements); +} + +void BossFd2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossFd2* pthis = (BossFd2*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void BossFd2_SetupEmerge(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + s16 temp_rand; + s8 health; + + osSyncPrintf("UP INIT 1\n"); + Animation_PlayOnce(&pthis->skelAnime, &gHoleVolvagiaEmergeAnim); + pthis->actionFunc = BossFd2_Emerge; + pthis->skelAnime.playSpeed = 0.0f; + temp_rand = Rand_ZeroFloat(8.9f); + pthis->actor.world.pos.x = sHoleLocations[temp_rand].x; + pthis->actor.world.pos.z = sHoleLocations[temp_rand].z; + pthis->work[FD2_ACTION_STATE] = 0; + osSyncPrintf("UP INIT 2\n"); + pthis->timers[0] = 10; + if (bossFd != NULL) { + health = bossFd->actor.colChkInfo.health; + if (health >= 18) { + pthis->work[FD2_FAKEOUT_COUNT] = 0; + } else if (health >= 12) { + pthis->work[FD2_FAKEOUT_COUNT] = 1; + } else if (health >= 6) { + pthis->work[FD2_FAKEOUT_COUNT] = 2; + } else { + pthis->work[FD2_FAKEOUT_COUNT] = 3; + } + } +} + +void BossFd2_Emerge(BossFd2* pthis, GlobalContext* globalCtx) { + s8 health; + BossFd* bossFd = (BossFd*)pthis->actor.parent; + Player* player = GET_PLAYER(globalCtx); + s16 i; + s16 holeTime; + + osSyncPrintf("UP 1 mode %d\n", pthis->work[FD2_ACTION_STATE]); + SkelAnime_Update(&pthis->skelAnime); + osSyncPrintf("UP 1.5 \n"); + switch (pthis->work[FD2_ACTION_STATE]) { + case 0: + osSyncPrintf("UP time %d \n", pthis->timers[0]); + osSyncPrintf("PL time %x \n", player); + osSyncPrintf("MT time %x \n", bossFd); + if ((pthis->timers[0] == 0) && (player->actor.world.pos.y > 70.0f)) { + osSyncPrintf("UP 1.6 \n"); + bossFd->faceExposed = 0; + bossFd->holePosition.x = pthis->actor.world.pos.x; + bossFd->holePosition.z = pthis->actor.world.pos.z; + func_80033E1C(globalCtx, 1, 0x32, 0x5000); + pthis->work[FD2_ACTION_STATE] = 1; + pthis->work[FD2_HOLE_COUNTER]++; + pthis->actor.world.pos.y = -200.0f; + health = bossFd->actor.colChkInfo.health; + if (health == 24) { + holeTime = 30; + } else if (health >= 18) { + holeTime = 25; + } else if (health >= 12) { + holeTime = 20; + } else if (health >= 6) { + holeTime = 10; + } else { + holeTime = 5; + } + pthis->timers[0] = holeTime; + bossFd->timers[4] = pthis->timers[0] + 10; + osSyncPrintf("UP 1.7 \n"); + } + break; + case 1: + if (pthis->timers[0] == 0) { + if (pthis->work[FD2_FAKEOUT_COUNT] != 0) { + pthis->work[FD2_FAKEOUT_COUNT]--; + i = Rand_ZeroFloat(8.9f); + pthis->actor.world.pos.x = sHoleLocations[i].x; + pthis->actor.world.pos.z = sHoleLocations[i].z; + pthis->work[FD2_ACTION_STATE] = 0; + pthis->timers[0] = 10; + } else { + pthis->skelAnime.playSpeed = 1.0f; + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaEmergeAnim); + pthis->work[FD2_ACTION_STATE] = 2; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_ROAR); + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->timers[0] = 15; + pthis->actor.world.pos.y = 150.0f; + for (i = 0; i < 10; i++) { + pthis->rightMane.pos[i].x += Rand_CenteredFloat(100.0f); + pthis->rightMane.pos[i].z += Rand_CenteredFloat(100.0f); + pthis->leftMane.pos[i].x += Rand_CenteredFloat(100.0f); + pthis->leftMane.pos[i].z += Rand_CenteredFloat(100.0f); + } + bossFd->work[BFD_SPLASH_TIMER] = 5; + } + } + break; + case 2: + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x7D0); + if ((pthis->timers[0] == 1) && (pthis->actor.xzDistToPlayer < 120.0f)) { + func_8002F6D4(globalCtx, &pthis->actor, 3.0f, pthis->actor.yawTowardsPlayer, 2.0f, 0x20); + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + BossFd2_SetupIdle(pthis, globalCtx); + } + break; + } + osSyncPrintf("UP 2\n"); +} + +void BossFd2_SetupIdle(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + s8 health; + s16 idleTime; + + osSyncPrintf("UP INIT 1\n"); + Animation_PlayLoop(&pthis->skelAnime, &gHoleVolvagiaTurnAnim); + pthis->actionFunc = BossFd2_Idle; + health = bossFd->actor.colChkInfo.health; + if (health == 24) { + idleTime = 50; + } else if (health >= 18) { + idleTime = 40; + } else if (health >= 12) { + idleTime = 40; + } else if (health >= 6) { + idleTime = 30; + } else { + idleTime = 20; + } + pthis->timers[0] = idleTime; +} + +void BossFd2_Idle(BossFd2* pthis, GlobalContext* globalCtx) { + s16 prevToLink; + + SkelAnime_Update(&pthis->skelAnime); + prevToLink = pthis->work[FD2_TURN_TO_LINK]; + pthis->work[FD2_TURN_TO_LINK] = + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x7D0, 0); + osSyncPrintf("SW1 = %d\n", prevToLink); + osSyncPrintf("SW2 = %d\n", pthis->work[FD2_TURN_TO_LINK]); + if ((fabsf(prevToLink) <= 1000.0f) && (1000.0f < fabsf(pthis->work[FD2_TURN_TO_LINK]))) { + Animation_MorphToLoop(&pthis->skelAnime, &gHoleVolvagiaTurnAnim, -5.0f); + } + if ((1000.0f < fabsf(prevToLink)) && (fabsf(pthis->work[FD2_TURN_TO_LINK]) <= 1000.0f)) { + Animation_MorphToLoop(&pthis->skelAnime, &gHoleVolvagiaIdleAnim, -5.0f); + } + if (pthis->timers[0] == 0) { + if (pthis->actor.xzDistToPlayer < 200.0f) { + BossFd2_SetupClawSwipe(pthis, globalCtx); + } else { + BossFd2_SetupBreatheFire(pthis, globalCtx); + } + } +} + +void BossFd2_SetupBurrow(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + + Animation_MorphToPlayOnce(&pthis->skelAnime, &gHoleVolvagiaBurrowAnim, -5.0f); + pthis->actionFunc = BossFd2_Burrow; + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaBurrowAnim); + bossFd->timers[4] = 30; + pthis->work[FD2_ACTION_STATE] = 0; +} + +void BossFd2_Burrow(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + + if (pthis->work[FD2_ACTION_STATE] == 0) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + pthis->work[FD2_ACTION_STATE] = 1; + pthis->timers[0] = 25; + } + } else { + Math_ApproachF(&pthis->actor.world.pos.y, -100.0f, 1.0f, 10.0f); + if (pthis->timers[0] == 0) { + if ((pthis->work[FD2_HOLE_COUNTER] >= 3) && ((s8)bossFd->actor.colChkInfo.health < 24)) { + pthis->work[FD2_HOLE_COUNTER] = 0; + pthis->actionFunc = BossFd2_Wait; + bossFd->handoffSignal = FD2_SIGNAL_FLY; + } else { + BossFd2_SetupEmerge(pthis, globalCtx); + } + } + } +} + +void BossFd2_SetupBreatheFire(BossFd2* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gHoleVolvagiaBreatheFireAnim, -5.0f); + pthis->actionFunc = BossFd2_BreatheFire; + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaBreatheFireAnim); + pthis->work[FD2_ACTION_STATE] = 0; +} + +static Vec3f sUnkVec = { 0.0f, 0.0f, 50.0f }; // Unused? BossFd uses a similar array for its fire breath sfx. + +void BossFd2_BreatheFire(BossFd2* pthis, GlobalContext* globalCtx) { + s16 i; + Vec3f toLink; + s16 angleX; + s16 angleY; + s16 breathOpacity = 0; + BossFd* bossFd = (BossFd*)pthis->actor.parent; + Player* player = GET_PLAYER(globalCtx); + f32 tempX; + f32 tempY; + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + BossFd2_SetupBurrow(pthis, globalCtx); + } + if ((25.0f <= pthis->skelAnime.curFrame) && (pthis->skelAnime.curFrame < 70.0f)) { + if (pthis->skelAnime.curFrame == 25.0f) { + globalCtx->envCtx.unk_D8 = 0.0f; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_FIRE - SFX_FLAG); + if (pthis->skelAnime.curFrame > 50) { + breathOpacity = (70.0f - pthis->skelAnime.curFrame) * 12.0f; + } else { + breathOpacity = 255; + } + toLink.x = player->actor.world.pos.x - pthis->headPos.x; + toLink.y = player->actor.world.pos.y - pthis->headPos.y; + toLink.z = player->actor.world.pos.z - pthis->headPos.z; + angleY = Math_Atan2S(toLink.z, toLink.x); + angleX = -Math_Atan2S(sqrtf(SQ(toLink.x) + SQ(toLink.z)), toLink.y); + angleY -= pthis->actor.shape.rot.y; + if (angleY > 0x1F40) { + angleY = 0x1F40; + } + if (angleY < -0x1F40) { + angleY = -0x1F40; + } + angleX += (-0x1B58); + if (angleX > 0x3E8) { + angleX = 0x3E8; + } + if (angleX < -0xFA0) { + angleX = -0xFA0; + } + Math_ApproachS(&pthis->headRot.y, angleY, 5, 0x7D0); + Math_ApproachS(&pthis->headRot.x, angleX, 5, 0x7D0); + } else { + Math_ApproachS(&pthis->headRot.y, 0, 5, 0x7D0); + Math_ApproachS(&pthis->headRot.x, 0, 5, 0x7D0); + } + if (breathOpacity != 0) { + f32 breathScale; + Vec3f spawnSpeed = { 0.0f, 0.0f, 0.0f }; + Vec3f spawnVel; + Vec3f spawnAccel = { 0.0f, 0.0f, 0.0f }; + Vec3f spawnPos; + + bossFd->fogMode = 2; + spawnSpeed.z = 30.0f; + spawnPos = pthis->headPos; + + tempY = ((pthis->actor.shape.rot.y + pthis->headRot.y) / (f32)0x8000) * M_PI; + tempX = ((pthis->headRot.x / (f32)0x8000) * M_PI) + 1.0f / 2; + Matrix_RotateY(tempY, MTXMODE_NEW); + Matrix_RotateX(tempX, MTXMODE_APPLY); + Matrix_MultVec3f(&spawnSpeed, &spawnVel); + + breathScale = 300.0f + 50.0f * Math_SinS(pthis->work[FD2_VAR_TIMER] * 0x2000); + BossFd2_SpawnFireBreath(globalCtx, bossFd->effects, &spawnPos, &spawnVel, &spawnAccel, breathScale, + breathOpacity, pthis->actor.shape.rot.y + pthis->headRot.y); + + spawnPos.x += spawnVel.x * 0.5f; + spawnPos.y += spawnVel.y * 0.5f; + spawnPos.z += spawnVel.z * 0.5f; + + breathScale = 300.0f + 50.0f * Math_SinS(pthis->work[FD2_VAR_TIMER] * 0x2000); + BossFd2_SpawnFireBreath(globalCtx, bossFd->effects, &spawnPos, &spawnVel, &spawnAccel, breathScale, + breathOpacity, pthis->actor.shape.rot.y + pthis->headRot.y); + + spawnSpeed.x = 0.0f; + spawnSpeed.y = 17.0f; + spawnSpeed.z = 0.0f; + + for (i = 0; i < 6; i++) { + tempY = Rand_ZeroFloat(2.0f * M_PI); + tempX = Rand_ZeroFloat(2.0f * M_PI); + Matrix_RotateY(tempY, MTXMODE_NEW); + Matrix_RotateX(tempX, MTXMODE_APPLY); + Matrix_MultVec3f(&spawnSpeed, &spawnVel); + + spawnAccel.x = (spawnVel.x * -10.0f) / 100.0f; + spawnAccel.y = (spawnVel.y * -10.0f) / 100.0f; + spawnAccel.z = (spawnVel.z * -10.0f) / 100.0f; + + BossFd2_SpawnEmber(globalCtx, bossFd->effects, &pthis->headPos, &spawnVel, &spawnAccel, + (s16)Rand_ZeroFloat(2.0f) + 8); + } + } +} + +void BossFd2_SetupClawSwipe(BossFd2* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gHoleVolvagiaClawSwipeAnim, -5.0f); + pthis->actionFunc = BossFd2_ClawSwipe; + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaClawSwipeAnim); +} + +void BossFd2_ClawSwipe(BossFd2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_ROAR); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_SW_NAIL); + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + BossFd2_SetupBurrow(pthis, globalCtx); + } +} + +void BossFd2_SetupVulnerable(BossFd2* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gHoleVolvagiaKnockoutAnim); + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaKnockoutAnim); + pthis->actionFunc = BossFd2_Vulnerable; + pthis->work[FD2_ACTION_STATE] = 0; +} + +void BossFd2_Vulnerable(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + s16 i; + + pthis->disableAT = true; + pthis->actor.flags |= ACTOR_FLAG_10; + SkelAnime_Update(&pthis->skelAnime); + switch (pthis->work[FD2_ACTION_STATE]) { + case 0: + if (Animation_OnFrame(&pthis->skelAnime, 13.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_MAHI2); + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME] - 3.0f)) { + for (i = 0; i < 25; i++) { + Vec3f spawnVel; + Vec3f spawnAccel = { 0.0f, 0.0f, 0.0f }; + Vec3f spawnPos; + + spawnVel.x = Rand_CenteredFloat(8.0f); + spawnVel.y = Rand_ZeroFloat(1.0f); + spawnVel.z = Rand_CenteredFloat(8.0f); + + spawnAccel.y = 0.5f; + + spawnPos.x = Rand_CenteredFloat(10.0f) + pthis->actor.focus.pos.x; + spawnPos.y = Rand_CenteredFloat(10.0f) + pthis->actor.focus.pos.y; + spawnPos.z = Rand_CenteredFloat(10.0f) + pthis->actor.focus.pos.z; + + BossFd2_SpawnDust(bossFd->effects, &spawnPos, &spawnVel, &spawnAccel, + Rand_ZeroFloat(100.0f) + 300.0f); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_LAND); + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + Animation_MorphToLoop(&pthis->skelAnime, &gHoleVolvagiaVulnerableAnim, -5.0f); + pthis->work[FD2_ACTION_STATE] = 1; + pthis->timers[0] = 60; + } + break; + case 1: + if ((pthis->work[FD2_VAR_TIMER] & 0xF) == 0xF) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_KNOCKOUT); + } + if (pthis->timers[0] == 0) { + BossFd2_SetupBurrow(pthis, globalCtx); + } + break; + } +} + +void BossFd2_SetupDamaged(BossFd2* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gHoleVolvagiaHitAnim); + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaHitAnim); + pthis->actionFunc = BossFd2_Damaged; + pthis->work[FD2_ACTION_STATE] = 0; +} + +void BossFd2_Damaged(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + + SkelAnime_Update(&pthis->skelAnime); + pthis->disableAT = true; + if (pthis->work[FD2_ACTION_STATE] == 0) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + Animation_PlayOnce(&pthis->skelAnime, &gHoleVolvagiaDamagedAnim); + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaDamagedAnim); + pthis->work[FD2_ACTION_STATE] = 1; + } + } else if (pthis->work[FD2_ACTION_STATE] == 1) { + if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_DAMAGE2); + } + if (Animation_OnFrame(&pthis->skelAnime, 20.0f)) { + bossFd->timers[4] = 30; + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[FD2_END_FRAME])) { + pthis->work[FD2_ACTION_STATE] = 2; + pthis->timers[0] = 25; + } + } else { + Math_ApproachF(&pthis->actor.world.pos.y, -100.0f, 1.0f, 10.0f); + if (pthis->timers[0] == 0) { + pthis->actionFunc = BossFd2_Wait; + bossFd->handoffSignal = FD2_SIGNAL_FLY; + } + } +} + +void BossFd2_SetupDeath(BossFd2* pthis, GlobalContext* globalCtx) { + pthis->fwork[FD2_END_FRAME] = Animation_GetLastFrame(&gHoleVolvagiaDamagedAnim); + Animation_Change(&pthis->skelAnime, &gHoleVolvagiaDamagedAnim, 1.0f, 0.0f, pthis->fwork[FD2_END_FRAME], + ANIMMODE_ONCE_INTERP, -3.0f); + pthis->actionFunc = BossFd2_Death; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->deathState = DEATH_START; +} + +void BossFd2_UpdateCamera(BossFd2* pthis, GlobalContext* globalCtx) { + if (pthis->deathCamera != SUBCAM_FREE) { + Math_ApproachF(&pthis->camData.eye.x, pthis->camData.nextEye.x, pthis->camData.eyeMaxVel.x, + pthis->camData.eyeVel.x * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.eye.y, pthis->camData.nextEye.y, pthis->camData.eyeMaxVel.y, + pthis->camData.eyeVel.y * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.eye.z, pthis->camData.nextEye.z, pthis->camData.eyeMaxVel.z, + pthis->camData.eyeVel.z * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.at.x, pthis->camData.nextAt.x, pthis->camData.atMaxVel.x, + pthis->camData.atVel.x * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.at.y, pthis->camData.nextAt.y, pthis->camData.atMaxVel.y, + pthis->camData.atVel.y * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.at.z, pthis->camData.nextAt.z, pthis->camData.atMaxVel.z, + pthis->camData.atVel.z * pthis->camData.speedMod); + Math_ApproachF(&pthis->camData.speedMod, 1.0f, 1.0f, pthis->camData.accel); + pthis->camData.at.y += pthis->camData.yMod; + Gameplay_CameraSetAtEye(globalCtx, pthis->deathCamera, &pthis->camData.at, &pthis->camData.eye); + Math_ApproachF(&pthis->camData.yMod, 0.0f, 1.0f, 0.1f); + } +} + +void BossFd2_Death(BossFd2* pthis, GlobalContext* globalCtx) { + f32 retreatSpeed; + Vec3f sp70; + Vec3f sp64; + BossFd* bossFd = (BossFd*)pthis->actor.parent; + Camera* mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); + f32 pad3; + f32 pad2; + f32 pad1; + f32 cameraShake; + SkelAnime* skelAnime = &pthis->skelAnime; + + SkelAnime_Update(skelAnime); + switch (pthis->deathState) { + case DEATH_START: + pthis->deathState = DEATH_RETREAT; + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->deathCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->deathCamera, CAM_STAT_ACTIVE); + pthis->camData.eye = mainCam->eye; + pthis->camData.at = mainCam->at; + pthis->camData.eyeVel.x = 100.0f; + pthis->camData.eyeVel.y = 100.0f; + pthis->camData.eyeVel.z = 100.0f; + pthis->camData.atVel.x = 100.0f; + pthis->camData.atVel.y = 100.0f; + pthis->camData.atVel.z = 100.0f; + pthis->camData.accel = 0.02f; + pthis->timers[0] = 0; + pthis->work[FD2_HOLE_COUNTER] = 0; + pthis->camData.eyeMaxVel.x = 0.1f; + pthis->camData.eyeMaxVel.y = 0.1f; + pthis->camData.eyeMaxVel.z = 0.1f; + pthis->camData.atMaxVel.x = 0.1f; + pthis->camData.atMaxVel.y = 0.1f; + pthis->camData.atMaxVel.z = 0.1f; + case DEATH_RETREAT: + pthis->work[FD2_HOLE_COUNTER]++; + if (pthis->work[FD2_HOLE_COUNTER] < 15) { + retreatSpeed = 1.0f; + } else if (pthis->work[FD2_HOLE_COUNTER] < 20) { + retreatSpeed = 0.5f; + } else { + retreatSpeed = 0.25f; + } + if ((pthis->work[FD2_HOLE_COUNTER] == 1) || (pthis->work[FD2_HOLE_COUNTER] == 40)) { + pthis->work[FD2_SCREAM_TIMER] = 20; + if (pthis->work[FD2_HOLE_COUNTER] == 40) { + Audio_StopSfxById(NA_SE_EN_VALVAISA_DEAD); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_DAMAGE2); + } + Math_ApproachF(&pthis->skelAnime.playSpeed, retreatSpeed, 1.0f, 1.0f); + Matrix_RotateY(((pthis->actor.yawTowardsPlayer / (f32)0x8000) * M_PI) + 0.2f, MTXMODE_NEW); + sp70.x = 0.0f; + sp70.y = 0.0f; + sp70.z = 250.0f; + Matrix_MultVec3f(&sp70, &sp64); + pthis->camData.nextEye.x = pthis->actor.world.pos.x + sp64.x; + pthis->camData.nextEye.y = 140.0f; + pthis->camData.nextEye.z = pthis->actor.world.pos.z + sp64.z; + if (pthis->actor.focus.pos.y >= 90.0f) { + pthis->camData.nextAt.y = pthis->actor.focus.pos.y; + pthis->camData.nextAt.x = pthis->actor.focus.pos.x; + pthis->camData.nextAt.z = pthis->actor.focus.pos.z; + } + if (pthis->timers[0] == 0) { + if (Animation_OnFrame(skelAnime, 20.0f)) { + bossFd->timers[4] = 60; + } + if (pthis->work[FD2_HOLE_COUNTER] >= 100) { + pthis->deathState = DEATH_HANDOFF; + pthis->timers[0] = 50; + } + } else if (Animation_OnFrame(skelAnime, 15.0f)) { + Animation_MorphToPlayOnce(skelAnime, &gHoleVolvagiaDamagedAnim, -10.0f); + } + break; + case DEATH_HANDOFF: + if (pthis->timers[0] == 0) { + pthis->actor.draw = NULL; + pthis->deathState = DEATH_FD_BODY; + bossFd->handoffSignal = FD2_SIGNAL_DEATH; + pthis->work[FD2_ACTION_STATE] = 0; + pthis->camData.speedMod = 0.0f; + } else { + Math_ApproachF(&pthis->actor.world.pos.y, -100.0f, 1.0f, 5.0f); + } + break; + case DEATH_FD_BODY: + if (bossFd->actor.world.pos.y < 80.0f) { + if (bossFd->actor.world.rot.x > 0x3000) { + pthis->camData.nextAt = bossFd->actor.world.pos; + pthis->camData.nextAt.y = 80.0f; + pthis->camData.nextEye.x = bossFd->actor.world.pos.x; + pthis->camData.nextEye.y = 150.0f; + pthis->camData.nextEye.z = bossFd->actor.world.pos.z + 300.0f; + } + } else { + pthis->camData.nextAt = bossFd->actor.world.pos; + pthis->camData.nextEye.x = pthis->actor.world.pos.x; + Math_ApproachF(&pthis->camData.nextEye.y, 200.0f, 1.0f, 2.0f); + Math_ApproachF(&pthis->camData.nextEye.z, bossFd->actor.world.pos.z + 200.0f, 1.0f, 3.0f); + if (pthis->work[FD2_ACTION_STATE] == 0) { + pthis->work[FD2_ACTION_STATE]++; + pthis->camData.speedMod = 0.0f; + pthis->camData.accel = 0.02f; + func_8002DF54(globalCtx, &bossFd->actor, 1); + } + } + if ((bossFd->work[BFD_ACTION_STATE] == BOSSFD_BONES_FALL) && (bossFd->timers[0] == 5)) { + pthis->deathState = DEATH_FD_SKULL; + pthis->camData.speedMod = 0.0f; + pthis->camData.accel = 0.02f; + pthis->camData.nextEye.y = 150.0f; + pthis->camData.nextEye.z = bossFd->actor.world.pos.z + 300.0f; + } + break; + case DEATH_FD_SKULL: + Math_ApproachF(&pthis->camData.nextAt.y, 100.0, 1.0f, 100.0f); + pthis->camData.nextAt.x = 0.0f; + pthis->camData.nextAt.z = 0.0f; + pthis->camData.nextEye.x = 0.0f; + pthis->camData.nextEye.y = 140.0f; + Math_ApproachF(&pthis->camData.nextEye.z, 220.0f, 0.5f, 1.15f); + if (bossFd->work[BFD_CAM_SHAKE_TIMER] != 0) { + bossFd->work[BFD_CAM_SHAKE_TIMER]--; + cameraShake = bossFd->work[BFD_CAM_SHAKE_TIMER] / 0.5f; + if (cameraShake >= 20.0f) { + cameraShake = 20.0f; + } + pthis->camData.yMod = (bossFd->work[BFD_CAM_SHAKE_TIMER] & 1) ? cameraShake : -cameraShake; + } + if (bossFd->work[BFD_ACTION_STATE] == BOSSFD_SKULL_BURN) { + pthis->deathState = DEATH_FINISH; + mainCam->eye = pthis->camData.eye; + mainCam->eyeNext = pthis->camData.eye; + mainCam->at = pthis->camData.at; + func_800C08AC(globalCtx, pthis->deathCamera, 0); + pthis->deathCamera = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 100.0f, 0.0f, + 0, 0, 0, WARP_DUNGEON_ADULT); + Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); + } + break; + case DEATH_FINISH: + break; + } + BossFd2_UpdateCamera(pthis, globalCtx); +} + +void BossFd2_Wait(BossFd2* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; + + if (bossFd->handoffSignal == FD2_SIGNAL_GROUND) { + bossFd->handoffSignal = FD2_SIGNAL_NONE; + BossFd2_SetupEmerge(pthis, globalCtx); + pthis->timers[0] = 20; + pthis->work[FD2_HOLE_COUNTER] = 0; + } +} + +void BossFd2_CollisionCheck(BossFd2* pthis, GlobalContext* globalCtx) { + s16 i; + ColliderInfo* hurtbox; + BossFd* bossFd = (BossFd*)pthis->actor.parent; + + if (pthis->actionFunc == BossFd2_ClawSwipe) { + Player* player = GET_PLAYER(globalCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->elements); i++) { + if (pthis->collider.elements[i].info.toucherFlags & TOUCH_HIT) { + pthis->collider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + } + } + if (!bossFd->faceExposed) { + pthis->collider.elements[0].info.elemType = ELEMTYPE_UNK2; + pthis->collider.base.colType = COLTYPE_METAL; + } else { + pthis->collider.elements[0].info.elemType = ELEMTYPE_UNK3; + pthis->collider.base.colType = COLTYPE_HIT3; + } + + if (pthis->collider.elements[0].info.bumperFlags & BUMP_HIT) { + pthis->collider.elements[0].info.bumperFlags &= ~BUMP_HIT; + + hurtbox = pthis->collider.elements[0].info.acHitInfo; + if (!bossFd->faceExposed) { + if (hurtbox->toucher.dmgFlags & 0x40000040) { + bossFd->actor.colChkInfo.health -= 2; + if ((s8)bossFd->actor.colChkInfo.health <= 2) { + bossFd->actor.colChkInfo.health = 1; + } + bossFd->faceExposed = true; + BossFd2_SetupVulnerable(pthis, globalCtx); + pthis->work[FD2_INVINC_TIMER] = 30; + pthis->work[FD2_DAMAGE_FLASH_TIMER] = 5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_MAHI1); + for (i = 0; i < 30; i++) { + Vec3f debrisVel = { 0.0f, 0.0f, 0.0f }; + Vec3f debrisAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f debrisPos; + + debrisVel.x = Rand_CenteredFloat(10.0f); + debrisVel.y = Rand_ZeroFloat(5.0f) + 8.0f; + debrisVel.z = Rand_CenteredFloat(10.0f); + + debrisPos.x = pthis->actor.focus.pos.x; + debrisPos.y = pthis->actor.focus.pos.y; + debrisPos.z = pthis->actor.focus.pos.z; + + BossFd2_SpawnDebris(globalCtx, bossFd->effects, &debrisPos, &debrisVel, &debrisAccel, + (s16)Rand_ZeroFloat(10.0) + 10); + } + } + } else { + u8 canKill = false; + u8 damage; + + if ((damage = CollisionCheck_GetSwordDamage(hurtbox->toucher.dmgFlags)) == 0) { + damage = (hurtbox->toucher.dmgFlags & 0x00001000) ? 4 : 2; + } else { + canKill = true; + } + if (hurtbox->toucher.dmgFlags & 0x80) { + damage = 0; + } + if (((s8)bossFd->actor.colChkInfo.health > 2) || canKill) { + bossFd->actor.colChkInfo.health -= damage; + osSyncPrintf(VT_FGCOL(GREEN)); + osSyncPrintf("damage %d\n", damage); + } + osSyncPrintf(VT_RST); + osSyncPrintf("hp %d\n", bossFd->actor.colChkInfo.health); + + if ((s8)bossFd->actor.colChkInfo.health <= 0) { + bossFd->actor.colChkInfo.health = 0; + BossFd2_SetupDeath(pthis, globalCtx); + pthis->work[FD2_DAMAGE_FLASH_TIMER] = 10; + pthis->work[FD2_INVINC_TIMER] = 30000; + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_DEAD); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else if (damage) { + BossFd2_SetupDamaged(pthis, globalCtx); + pthis->work[FD2_DAMAGE_FLASH_TIMER] = 10; + pthis->work[FD2_INVINC_TIMER] = 100; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_DAMAGE1); + } + if (damage) { + for (i = 0; i < 30; i++) { + Vec3f pieceVel = { 0.0f, 0.0f, 0.0f }; + Vec3f pieceAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f piecePos; + + pieceVel.x = Rand_CenteredFloat(6.0f); + pieceVel.y = Rand_ZeroFloat(4.0f) + 6.0f; + pieceVel.z = Rand_CenteredFloat(6.0f); + + piecePos.x = pthis->actor.focus.pos.x; + piecePos.y = pthis->actor.focus.pos.y; + piecePos.z = pthis->actor.focus.pos.z; + + BossFd2_SpawnSkullPiece(globalCtx, bossFd->effects, &piecePos, &pieceVel, &pieceAccel, + (s16)Rand_ZeroFloat(6.0f) + 10); + } + } + } + } +} + +void BossFd2_UpdateFace(BossFd2* pthis, GlobalContext* globalCtx) { + f32 maxOpen; + f32 openRate; + s16 eyeStates[5] = { EYE_OPEN, EYE_HALF, EYE_CLOSED, EYE_CLOSED, EYE_HALF }; + + if (((pthis->work[FD2_VAR_TIMER] % 8) == 0) && (Rand_ZeroOne() < 0.3f)) { + pthis->work[FD2_BLINK_TIMER] = 4; + } + if ((pthis->actionFunc == BossFd2_Vulnerable) || (pthis->actionFunc == BossFd2_Damaged)) { + if (pthis->work[FD2_VAR_TIMER] & 0x10) { + pthis->eyeState = EYE_HALF; + } else { + pthis->eyeState = EYE_CLOSED; + } + } else { + pthis->eyeState = eyeStates[pthis->work[FD2_BLINK_TIMER]]; + } + + if (pthis->work[FD2_BLINK_TIMER] != 0) { + pthis->work[FD2_BLINK_TIMER]--; + } + + if (pthis->work[FD2_SCREAM_TIMER] != 0) { + maxOpen = 6000.0f; + openRate = 1300.0f; + } else { + maxOpen = (pthis->work[FD2_VAR_TIMER] & 0x10) ? 1000.0f : 0.0f; + openRate = 700.0f; + } + Math_ApproachF(&pthis->jawOpening, maxOpen, 0.3f, openRate); + + if (pthis->work[FD2_SCREAM_TIMER] != 0) { + pthis->work[FD2_SCREAM_TIMER]--; + } +} + +void BossFd2_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BossFd2* pthis = (BossFd2*)thisx; + s16 i; + + osSyncPrintf("FD2 move start \n"); + pthis->disableAT = false; + pthis->actor.flags &= ~ACTOR_FLAG_10; + pthis->work[FD2_VAR_TIMER]++; + pthis->work[FD2_UNK_TIMER]++; + + pthis->actionFunc(pthis, globalCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + if (pthis->work[FD2_DAMAGE_FLASH_TIMER] != 0) { + pthis->work[FD2_DAMAGE_FLASH_TIMER]--; + } + if (pthis->work[FD2_INVINC_TIMER] != 0) { + pthis->work[FD2_INVINC_TIMER]--; + } + + if (pthis->deathState == DEATH_START) { + if (pthis->work[FD2_INVINC_TIMER] == 0) { + BossFd2_CollisionCheck(pthis, globalCtx); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (!pthis->disableAT) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + BossFd2_UpdateFace(pthis, globalCtx); + pthis->fwork[FD2_TEX1_SCROLL_X] += 4.0f; + pthis->fwork[FD2_TEX1_SCROLL_Y] = 120.0f; + pthis->fwork[FD2_TEX2_SCROLL_X] += 3.0f; + pthis->fwork[FD2_TEX2_SCROLL_Y] -= 2.0f; + if (pthis->actor.focus.pos.y < 90.0f) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else { + pthis->actor.flags |= ACTOR_FLAG_0; + } +} + +s32 BossFd2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossFd2* pthis = (BossFd2*)thisx; + BossFd* bossFd = (BossFd*)pthis->actor.parent; + + if (limbIndex == 31) { + rot->y -= (f32)pthis->headRot.y; + rot->z += (f32)pthis->headRot.x; + } + switch (limbIndex) { + case 35: + case 36: + rot->z -= pthis->jawOpening * 0.1f; + break; + case 32: + rot->z += pthis->jawOpening; + break; + } + if ((bossFd->faceExposed == 1) && (limbIndex == 35)) { + *dList = gHoleVolvagiaBrokenFaceDL; + } + + if ((limbIndex == 32) || (limbIndex == 35) || (limbIndex == 36)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2165); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)bossFd->fwork[BFD_HEAD_TEX2_ALPHA]); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2172); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2174); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, (s8)bossFd->fwork[BFD_BODY_TEX2_ALPHA]); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2181); + } + if ((0 < limbIndex) && (limbIndex < 16)) { + *dList = NULL; + } + return false; +} + +void BossFd2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f targetMod = { 4500.0f, 0.0f, 0.0f }; + static Vec3f headMod = { 4000.0f, 0.0f, 0.0f }; + static Vec3f centerManeMod = { 4000.0f, -2900.0, 2000.0f }; + static Vec3f rightManeMod = { 4000.0f, -1600.0, 0.0f }; + static Vec3f leftManeMod = { 4000.0f, -1600.0, -2000.0f }; + BossFd2* pthis = (BossFd2*)thisx; + + if (limbIndex == 35) { + Matrix_MultVec3f(&targetMod, &pthis->actor.focus.pos); + Matrix_MultVec3f(&headMod, &pthis->headPos); + Matrix_MultVec3f(¢erManeMod, &pthis->centerMane.head); + Matrix_MultVec3f(&rightManeMod, &pthis->rightMane.head); + Matrix_MultVec3f(&leftManeMod, &pthis->leftMane.head); + } + Collider_UpdateSpheres(limbIndex, &pthis->collider); +} + +void BossFd2_UpdateMane(BossFd2* pthis, GlobalContext* globalCtx, Vec3f* head, Vec3f* pos, Vec3f* rot, Vec3f* pull, + f32* scale) { + f32 sp138[10] = { 0.0f, 100.0f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + f32 sp110[10] = { 0.0f, 5.0f, -10.0f, 500.0f, 500.0f, 500.0f, 500.0f, 500.0f, 500.0f, 500.0f }; + f32 spE8[10] = { 0.4f, 0.6f, 0.8f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; + s16 i; + Vec3f temp_vec; + f32 temp_f2; + f32 phi_f0; + f32 temp_angleX; + f32 temp_angleY; + Vec3f spBC; + Vec3f spB0; + f32 xyScale; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2389); + Matrix_Push(); + gDPPipeSync(POLY_OPA_DISP++); + + for (i = 0; i < 10; i++) { + if (i == 0) { + (pos + i)->x = head->x; + (pos + i)->y = head->y; + (pos + i)->z = head->z; + } else { + Math_ApproachF(&(pull + i)->x, 0.0f, 1.0f, 1.0f); + Math_ApproachF(&(pull + i)->y, 0.0f, 1.0f, 1.0f); + Math_ApproachF(&(pull + i)->z, 0.0f, 1.0f, 1.0f); + } + } + + for (i = 1; i < 10; i++) { + temp_vec.x = (pos + i)->x + (pull + i)->x - (pos + i - 1)->x; + + phi_f0 = (pos + i)->y + (pull + i)->y - 2.0f + sp138[i]; + temp_f2 = (pos + i - 1)->y + sp110[i]; + if (phi_f0 > temp_f2) { + phi_f0 = temp_f2; + } + if ((head->y >= -910.0f) && (phi_f0 < 110.0f)) { + phi_f0 = 110.0f; + } + temp_vec.y = phi_f0 - (pos + i - 1)->y; + + temp_vec.z = (pos + i)->z + (pull + i)->z - (pos + i - 1)->z; + temp_angleY = Math_Atan2F(temp_vec.z, temp_vec.x); + temp_angleX = -Math_Atan2F(sqrtf(SQ(temp_vec.x) + SQ(temp_vec.z)), temp_vec.y); + (rot + i - 1)->y = temp_angleY; + (rot + i - 1)->x = temp_angleX; + spBC.x = 0.0f; + spBC.y = 0.0f; + spBC.z = spE8[i] * 25.0f; + Matrix_RotateY(temp_angleY, MTXMODE_NEW); + Matrix_RotateX(temp_angleX, MTXMODE_APPLY); + Matrix_MultVec3f(&spBC, &spB0); + temp_vec.x = (pos + i)->x; + temp_vec.y = (pos + i)->y; + temp_vec.z = (pos + i)->z; + (pos + i)->x = (pos + i - 1)->x + spB0.x; + (pos + i)->y = (pos + i - 1)->y + spB0.y; + (pos + i)->z = (pos + i - 1)->z + spB0.z; + (pull + i)->x = (((pos + i)->x - temp_vec.x) * 88.0f) / 100.0f; + (pull + i)->y = (((pos + i)->y - temp_vec.y) * 88.0f) / 100.0f; + (pull + i)->z = (((pos + i)->z - temp_vec.z) * 88.0f) / 100.0f; + if ((pull + i)->x > 30.0f) { + (pull + i)->x = 30.0f; + } + if ((pull + i)->x < -30.0f) { + (pull + i)->x = -30.0f; + } + if ((pull + i)->y > 30.0f) { + (pull + i)->y = 30.0f; + } + if ((pull + i)->y < -30.0f) { + (pull + i)->y = -30.0f; + } + if ((pull + i)->z > 30.0f) { + (pull + i)->z = 30.0f; + } + if ((pull + i)->z < -30.0f) { + (pull + i)->z = -30.0f; + } + } + + for (i = 0; i < 9; i++) { + Matrix_Translate((pos + i)->x, (pos + i)->y, (pos + i)->z, MTXMODE_NEW); + Matrix_RotateY((rot + i)->y, MTXMODE_APPLY); + Matrix_RotateX((rot + i)->x, MTXMODE_APPLY); + xyScale = (0.01f - (i * 0.0009f)) * spE8[i] * scale[i]; + Matrix_Scale(xyScale, xyScale, 0.01f * spE8[i], MTXMODE_APPLY); + Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2498), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gHoleVolvagiaManeModelDL); + } + Matrix_Pop(); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2503); +} + +void BossFd2_DrawMane(BossFd2* pthis, GlobalContext* globalCtx) { + s32 pad; + BossFd* bossFd = (BossFd*)pthis->actor.parent; + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2515); + if (1) {} + for (i = 0; i < 10; i++) { + pthis->centerMane.scale[i] = 1.5f + 0.3f * Math_SinS(5596.0f * pthis->work[FD2_VAR_TIMER] + i * 0x3200); + pthis->rightMane.scale[i] = 1.5f + 0.3f * Math_SinS(5496.0f * pthis->work[FD2_VAR_TIMER] + i * 0x3200); + pthis->leftMane.scale[i] = 1.5f + 0.3f * Math_CosS(5696.0f * pthis->work[FD2_VAR_TIMER] + i * 0x3200); + } + + func_80093D84(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gHoleVolvagiaManeMaterialDL); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, bossFd->fwork[BFD_MANE_COLOR_CENTER], 0, 255); + BossFd2_UpdateMane(pthis, globalCtx, &pthis->centerMane.head, pthis->centerMane.pos, pthis->centerMane.rot, + pthis->centerMane.pull, pthis->centerMane.scale); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, bossFd->fwork[BFD_MANE_COLOR_RIGHT], 0, 255); + BossFd2_UpdateMane(pthis, globalCtx, &pthis->rightMane.head, pthis->rightMane.pos, pthis->rightMane.rot, + pthis->rightMane.pull, pthis->rightMane.scale); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, bossFd->fwork[BFD_MANE_COLOR_LEFT], 0, 255); + BossFd2_UpdateMane(pthis, globalCtx, &pthis->leftMane.head, pthis->leftMane.pos, pthis->leftMane.rot, + pthis->leftMane.pull, pthis->leftMane.scale); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2601); +} + +void BossFd2_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gHoleVolvagiaEyeOpenTex, gHoleVolvagiaEyeHalfTex, gHoleVolvagiaEyeClosedTex }; + s32 pad; + BossFd2* pthis = (BossFd2*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2617); + osSyncPrintf("FD2 draw start \n"); + if (pthis->actionFunc != BossFd2_Wait) { + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->work[FD2_DAMAGE_FLASH_TIMER] & 2) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 255, 255, 0, 900, 1099); + } + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeState])); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)pthis->fwork[FD2_TEX1_SCROLL_X], + (s16)pthis->fwork[FD2_TEX1_SCROLL_Y], 0x20, 0x20, 1, + (s16)pthis->fwork[FD2_TEX2_SCROLL_X], (s16)pthis->fwork[FD2_TEX2_SCROLL_Y], 0x20, + 0x20)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 128); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossFd2_OverrideLimbDraw, BossFd2_PostLimbDraw, &pthis->actor); + BossFd2_DrawMane(pthis, globalCtx); + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_fd2.c", 2688); +} diff --git a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2_colchk.c b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2_colchk.cpp similarity index 100% rename from src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2_colchk.c rename to src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2_colchk.cpp diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c deleted file mode 100644 index 7c900841a..000000000 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ /dev/null @@ -1,5040 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GANON_Z_BOSS_GANON_C -#include "actor_common.h" -#include "z_kankyo.h" -#include "z_boss_ganon.h" -#include "overlays/ovl_Boss_Ganon/ovl_Boss_Ganon.h" -#include "overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.h" -#include "overlays/actors/ovl_En_Zl3/z_en_zl3.h" -#include "overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "assets/objects/object_ganon/object_ganon.h" -#include "assets/objects/object_ganon_anime1/object_ganon_anime1.h" -#include "assets/objects/object_ganon_anime2/object_ganon_anime2.h" -#include "assets/scenes/dungeons/ganon_boss/ganon_boss_scene.h" -#include "def/code_8006BA00.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/graph.h" -#include "def/sinf.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx); -void BossGanon_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossGanon_Update(Actor* thisx, GlobalContext* globalCtx); -void BossGanon_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808E1EB4(Actor* thisx, GlobalContext* globalCtx); // update -void func_808E2544(Actor* thisx, GlobalContext* globalCtx); // update -void BossGanon_LightBall_Update(Actor* thisx, GlobalContext* globalCtx); -void func_808E229C(Actor* thisx, GlobalContext* globalCtx); // draw -void func_808E324C(Actor* thisx, GlobalContext* globalCtx); // draw -void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BossGanon_SetupIntroCutscene(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_SetupTowerCutscene(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_Wait(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_ChargeLightBall(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_PlayTennis(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_PoundFloor(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_ChargeBigMagic(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_Block(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_HitByLightBall(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_Vulnerable(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_Damaged(BossGanon* this, GlobalContext* globalCtx); - -void BossGanon_SetupWait(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_SetupChargeLightBall(BossGanon* this, GlobalContext* globalCtx); -void BossGanon_SetupPlayTennis(BossGanon* this, GlobalContext* globalCtx); - -void BossGanon_DrawEffects(GlobalContext* globalCtx); -void BossGanon_UpdateEffects(GlobalContext* globalCtx); - -s32 BossGanon_CheckFallingPlatforms(BossGanon* this, GlobalContext* globalCtx, Vec3f* checkPos); - -const ActorInit Boss_Ganon_InitVars = { - ACTOR_BOSS_GANON, - ACTORCAT_BOSS, - FLAGS, - OBJECT_GANON, - sizeof(BossGanon), - (ActorFunc)BossGanon_Init, - (ActorFunc)BossGanon_Destroy, - (ActorFunc)BossGanon_Update, - (ActorFunc)BossGanon_Draw, -}; - -static ColliderCylinderInit sDorfCylinderInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x10 }, - { 0xFFCFFFFE, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 20, 80, -50, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sLightBallCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK6, - { 0x00100700, 0x00, 0x08 }, - { 0x0D900740, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 20, 30, -15, { 0, 0, 0 } }, -}; - -static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 }; -static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; - -static EnGanonMant* sCape; - -static s32 sSeed1; -static s32 sSeed2; -static s32 sSeed3; - -static BossGanon* sGanondorf; - -static EnZl3* sZelda; - -typedef struct { - /* 0x00 */ u8 type; - /* 0x01 */ u8 timer; - /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ Color_RGB8 color; - /* 0x2C */ s16 alpha; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ s16 unk_30; - /* 0x34 */ f32 scale; - /* 0x38 */ f32 unk_38; // scale target mostly, but used for other things - /* 0x3C */ f32 unk_3C; // mostly z rot - /* 0x40 */ f32 unk_40; - /* 0x44 */ f32 unk_44; // mostly x rot - /* 0x48 */ f32 unk_48; // mostly y rot -} GanondorfEffect; // size = 0x4C - -GanondorfEffect sEffectBuf[200]; - -void BossGanonEff_SpawnWindowShard(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, f32 scale) { - static Color_RGB8 shardColors[] = { { 255, 175, 85 }, { 155, 205, 155 }, { 155, 125, 55 } }; - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - Color_RGB8* color; - - for (i = 0; i < 200; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_WINDOW_SHARD; - eff->pos = *pos; - eff->velocity = *velocity; - eff->accel = sZeroVec; - eff->scale = scale; - eff->accel.y = -1.5f; - eff->unk_44 = Rand_ZeroFloat(6.28f); - eff->unk_48 = Rand_ZeroFloat(6.28f); - color = &shardColors[(s16)Rand_ZeroFloat(2.99f)]; - eff->color.r = color->r; - eff->color.g = color->g; - eff->color.b = color->b; - eff->timer = (s16)Rand_ZeroFloat(20.0f); - break; - } - } -} - -void BossGanonEff_SpawnSparkle(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, - s16 arg6) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_SPARKLE; - eff->pos = *pos; - eff->velocity = *velocity; - eff->accel = *accel; - eff->scale = scale / 1000.0f; - eff->unk_2E = (s16)Rand_ZeroFloat(100.0f) + 0xC8; - eff->unk_30 = arg6; - eff->timer = (s16)Rand_ZeroFloat(10.0f); - break; - } - } -} - -void BossGanonEff_SpawnLightRay(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, - f32 arg5, s16 arg6) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_LIGHT_RAY; - eff->pos = *pos; - eff->velocity = *velocity; - eff->accel = *accel; - eff->scale = scale / 1000.0f; - eff->unk_38 = 1.0f; - eff->unk_40 = arg5; - eff->unk_2E = (s16)Rand_ZeroFloat(100.0f) + 0xC8; - eff->unk_30 = arg6; - eff->timer = (s16)Rand_ZeroFloat(10.0f); - eff->unk_48 = Math_Atan2F(eff->velocity.z, eff->velocity.x); - eff->unk_44 = -Math_Atan2F(sqrtf(SQXZ(eff->velocity)), eff->velocity.y); - break; - } - } -} - -void BossGanonEff_SpawnShock(GlobalContext* globalCtx, f32 scale, s16 shockType) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 75; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_SHOCK; - eff->pos = sZeroVec; - eff->pos.y = -2000.0f; - eff->velocity = sZeroVec; - eff->accel = sZeroVec; - eff->scale = scale / 1000.0f; - eff->unk_2E = shockType; - eff->timer = 0; - break; - } - } -} - -void BossGanonEff_SpawnLightning(GlobalContext* globalCtx, f32 scale, f32 arg2, f32 arg3) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_LIGHTNING; - eff->velocity = sZeroVec; - eff->accel = sZeroVec; - eff->unk_2E = 0; - eff->scale = scale; - eff->unk_48 = arg2; - eff->unk_3C = arg3; - eff->timer = 0; - break; - } - } -} - -void BossGanonEff_SpawnDustDark(GlobalContext* globalCtx, Vec3f* pos, f32 scale, f32 arg3) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_IMPACT_DUST_DARK; - eff->pos = *pos; - eff->velocity = sZeroVec; - eff->accel = sZeroVec; - eff->scale = scale; - eff->unk_40 = 1.0f; - eff->unk_38 = arg3; - eff->unk_30 = (s16)Rand_ZeroFloat(100.0f); - eff->unk_2E = eff->timer = eff->alpha = 0; - break; - } - } -} - -void BossGanonEff_SpawnDustLight(GlobalContext* globalCtx, Vec3f* pos, f32 scale, f32 arg3, s16 bufIndex) { - GanondorfEffect* effArr = globalCtx->specialEffects; - - effArr[bufIndex].type = GDF_EFF_IMPACT_DUST_LIGHT; - effArr[bufIndex].pos = *pos; - effArr[bufIndex].velocity = sZeroVec; - effArr[bufIndex].accel = sZeroVec; - effArr[bufIndex].unk_40 = 1.0f; - effArr[bufIndex].scale = scale; - effArr[bufIndex].unk_38 = arg3; - effArr[bufIndex].unk_30 = Rand_ZeroFloat(100.0f); - effArr[bufIndex].unk_2E = effArr[bufIndex].timer = effArr[bufIndex].alpha = 0; -} - -void BossGanonEff_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, f32 scale, f32 arg3) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_SHOCKWAVE; - eff->pos = *pos; - eff->velocity = sZeroVec; - eff->accel = sZeroVec; - eff->alpha = 255; - eff->unk_40 = 0.6f; - eff->scale = scale; - eff->unk_38 = arg3; - eff->unk_30 = (s16)Rand_ZeroFloat(100.0f); - eff->unk_2E = eff->timer = 0; - break; - } - } -} - -void BossGanonEff_SpawnBlackDot(GlobalContext* globalCtx, Vec3f* pos, f32 scale) { - s16 i; - GanondorfEffect* eff = globalCtx->specialEffects; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_NONE) { - eff->type = GDF_EFF_BLACK_DOT; - eff->pos = *pos; - eff->velocity = sZeroVec; - eff->accel = sZeroVec; - eff->unk_38 = 0.0f; - eff->scale = scale / 1000.0f; - eff->timer = 0; - eff->alpha = 0; - eff->unk_2E = 0; - break; - } - } -} - -void BossGanon_SetColliderPos(Vec3f* pos, ColliderCylinder* collider) { - collider->dim.pos.x = pos->x; - collider->dim.pos.y = pos->y; - collider->dim.pos.z = pos->z; -} - -void BossGanon_SetAnimationObject(BossGanon* this, GlobalContext* globalCtx, s32 objectId) { - this->animBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animBankIndex].vromStart); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x3D, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx2) { - s16 i; - GlobalContext* globalCtx = globalCtx2; - BossGanon* this = (BossGanon*)thisx; - s32 cond; - f32 xDistFromPlayer; - f32 yDistFromPlayer; - f32 zDistFromPlayer; - Player* player = GET_PLAYER(globalCtx); - - if (thisx->params < 0x64) { - Flags_SetSwitch(globalCtx, 0x14); - globalCtx->specialEffects = sEffectBuf; - - for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++) { - sEffectBuf[i].type = GDF_EFF_NONE; - } - - sGanondorf = this; - thisx->colChkInfo.health = 40; - Actor_ProcessInitChain(thisx, sInitChain); - ActorShape_Init(&thisx->shape, 0, NULL, 0); - Actor_SetScale(thisx, 0.01f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDorfSkel, NULL, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sDorfCylinderInit); - - if (thisx->params != 1) { - BossGanon_SetupIntroCutscene(this, globalCtx); - this->organAlpha = 255; - } else { - cond = Flags_GetSwitch(globalCtx, 0x37) && - ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); - - if (!cond) { - BossGanon_SetupTowerCutscene(this, globalCtx); - } else { - Actor_Kill(thisx); - return; - } - - BossGanon_SetupTowerCutscene(this, globalCtx); - } - - sCape = (EnGanonMant*)Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_GANON_MANT, 0.0f, - 0.0f, 0.0f, 0, 0, 0, 1); - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BOSS); - } else { - thisx->flags &= ~ACTOR_FLAG_0; - this->fwork[GDF_FWORK_1] = 255.0f; - - if (thisx->params >= 0xC8) { - if (thisx->params == 0x12C) { - thisx->update = BossGanon_LightBall_Update; - thisx->draw = BossGanon_LightBall_Draw; - this->unk_1A8 = 2; - } else if (thisx->params == 0x190) { - thisx->update = BossGanon_LightBall_Update; - thisx->draw = BossGanon_LightBall_Draw; - this->unk_1A8 = 1; - } else if (thisx->params >= 0x104) { - // big magic light ball thrown - thisx->update = func_808E2544; - thisx->draw = func_808E324C; - this->unk_1C2 = 10; - this->unk_1A2 = 520 + (-thisx->params * 2); - - for (i = 0; i < 15; i++) { - this->unk_2EC[i] = thisx->world.pos; - } - - this->timers[1] = 3; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sLightBallCylinderInit); - } else if (thisx->params >= 0xFA) { - // big magic light ball charge - thisx->update = func_808E2544; - thisx->draw = func_808E324C; - this->unk_1A2 = Rand_ZeroFloat(10000.0f); - - for (i = 0; i < 15; i++) { - this->unk_2EC[i] = thisx->world.pos; - } - - this->fwork[GDF_FWORK_1] = 0; - } else { - thisx->update = func_808E1EB4; - thisx->draw = func_808E229C; - if (1) {} - thisx->speedXZ = 11.0f; - - if (thisx->params == 0xC8) { - this->timers[0] = 7; - } else { - this->timers[0] = (s16)Rand_ZeroFloat(3.0f) + 3; - } - - for (i = 0; i < 15; i++) { - this->unk_2EC[i].y = 5000.0f; - } - } - } else { - // light ball (anything from 0x64 - 0xC7) - thisx->update = BossGanon_LightBall_Update; - thisx->draw = BossGanon_LightBall_Draw; - thisx->speedXZ = 12.0f; - - xDistFromPlayer = player->actor.world.pos.x - thisx->world.pos.x; - yDistFromPlayer = (player->actor.world.pos.y + 30.0f) - thisx->world.pos.y; - zDistFromPlayer = player->actor.world.pos.z - thisx->world.pos.z; - - thisx->world.rot.y = Math_Atan2S(zDistFromPlayer, xDistFromPlayer); - thisx->world.rot.x = Math_Atan2S(sqrtf(SQ(xDistFromPlayer) + SQ(zDistFromPlayer)), yDistFromPlayer); - - if (Rand_ZeroOne() < 0) { - thisx->world.rot.y += (s16)Rand_CenteredFloat(5000.0f); - thisx->world.rot.x += (s16)Rand_CenteredFloat(5000.0f); - } - - this->timers[1] = 3; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sLightBallCylinderInit); - } - } -} - -void BossGanon_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BossGanon* this = (BossGanon*)thisx; - - if ((this->actor.params < 0xC8) || (this->actor.params >= 0x104)) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } - - if (this->actor.params < 0x64) { - SkelAnime_Free(&this->skelAnime, globalCtx); - } -} - -void BossGanon_SetupIntroCutscene(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - s32 animBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME2); - - if (animBankIndex < 0) { - Actor_Kill(&this->actor); - return; - } - - if (Object_IsLoaded(&globalCtx->objectCtx, animBankIndex)) { - this->actionFunc = BossGanon_IntroCutscene; - this->unk_198 = 1; - this->animBankIndex = animBankIndex; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[animBankIndex].vromStart); - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_005FFC, 0.0f); - } else { - this->actionFunc = BossGanon_SetupIntroCutscene; - } -} - -typedef struct { - /* 0x00 */ Vec3s eye; - /* 0x06 */ Vec3s at; -} CutsceneCameraPosition; // size = 0x12 - -static CutsceneCameraPosition sIntroCsCameraPositions[] = { - { { 0, 40, 0 }, { 0, 50, 430 } }, - { { -20, 30, 400 }, { 10, 55, 440 } }, - { { 0, 60, 300 }, { 0, 273, -150 } }, - { { 0, 180, -260 }, { 0, 155, -300 } }, - { { -30, 60, 440 }, { 20, 25, 390 } }, - { { -50, 140, -360 }, { 50, 92, -390 } }, - { { -10, 264, -121 }, { 5, 266, -160 } }, - { { -13, 200, -310 }, { 0, 125, -410 } }, - { { 0, 40, -50 }, { 0, 35, 230 } }, - { { 0, 140, -250 }, { 0, 115, -570 } }, - { { -410, 150, -130 }, { 50, 155, -170 } }, - { { 0, 130, -230 }, { 0, 125, -2000 } }, - { { -2, 147, -293 }, { -200, 345, -2000 } }, -}; - -void BossGanon_SetIntroCsCamera(BossGanon* this, u8 camPosIndex) { - CutsceneCameraPosition* camPos = &sIntroCsCameraPositions[camPosIndex]; - - this->csCamEye.x = camPos->eye.x; - this->csCamEye.y = camPos->eye.y; - this->csCamEye.z = camPos->eye.z; - - this->csCamAt.x = camPos->at.x; - this->csCamAt.y = camPos->at.y; - this->csCamAt.z = camPos->at.z; -} - -void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { - u8 moveCam = false; - Player* player = GET_PLAYER(globalCtx); - s32 pad; - f32 sin; - f32 cos; - Camera* mainCam; - - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animBankIndex].vromStart); - - sCape->backPush = -2.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -1.0f; - sCape->minDist = 0.0f; - - this->csTimer++; - - SkelAnime_Update(&this->skelAnime); - - switch (this->csState) { - case 0: - player->actor.world.pos.x = 0.0f; - player->actor.world.pos.y = 0.0f; - player->actor.world.pos.z = 430.0f; - - this->actor.world.pos.x = 0.0f; - this->actor.world.pos.y = 112.0f; - this->actor.world.pos.z = -333.0f; - - this->actor.shape.yOffset = -7000.0f; - this->actor.shape.rot.y = 0; - - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->csCamIndex = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->csCamIndex, CAM_STAT_ACTIVE); - this->csCamFov = 60.0f; - - if (gSaveContext.eventChkInf[7] & 0x100) { - // watched cutscene already, skip most of it - this->csState = 17; - this->csTimer = 0; - player->actor.world.pos.z = 20.0f; - this->useOpenHand = false; - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_0089F8, -5.0f); - this->fwork[GDF_FWORK_1] = 1000.0f; - BossGanon_SetIntroCsCamera(this, 11); - this->unk_198 = 2; - this->timers[2] = 110; - gSaveContext.healthAccumulator = 0x140; - Audio_QueueSeqCmd(NA_BGM_STOP); - } else { - this->useOpenHand = true; - BossGanon_SetIntroCsCamera(this, 0); - this->csState = 1; - sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, - 220.0f, -150.0f, 0, 0, 0, 0x2000); - } - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_GANON_ORGAN, 0.0f, 0.0f, 0.0f, 0, - 0, 0, 1); - sCape->minY = 57.0f; - // fallthrough - case 1: - this->envLightMode = 3; - if (this->csTimer == 70) { - this->csState = 2; - this->csTimer = 0; - } - break; - - case 2: - BossGanon_SetIntroCsCamera(this, 1); - - if (this->csTimer == 10) { - func_8002DF54(globalCtx, &this->actor, 5); - } - - if (this->csTimer == 13) { - func_8002F7DC(&player->actor, player->ageProperties->unk_92 + NA_SE_VO_LI_SURPRISE); - } - - if (this->csTimer != 35) { - break; - } - - this->csState = 3; - this->csTimer = 0; - - this->csCamEye.x = 0.0f; - this->csCamEye.y = 60.0f; - this->csCamEye.z = 300.0f; - - this->csCamAt.x = 0.0f; - this->unk_704 = 1.2566371f; - // fallthrough - case 3: - this->envLightMode = 0; - globalCtx->envCtx.unk_D8 = 0.0f; - this->csCamAt.y = (sinf(this->unk_704) * 300.0f) + this->csCamEye.y; - this->csCamAt.z = (cosf(this->unk_704) * -300.0f) + this->csCamEye.z; - Math_ApproachF(&this->unk_704, 0.25f, 0.05f, this->csCamAtMaxStep.y); - Math_ApproachF(&this->csCamAtMaxStep.y, 0.01f, 1.0f, 0.0001f); - - if (this->csTimer != 200) { - break; - } - - func_8002DF54(globalCtx, &this->actor, 8); - this->csState = 4; - BossGanon_SetIntroCsCamera(this, 2); - this->csTimer = 0; - // fallthrough - case 4: - if ((this->csTimer == 0) || (this->csTimer == 10) || (this->csTimer == 20)) { - this->csCamEye.y += 68.0f; - this->csCamEye.z -= 142.0f; - } - - if (this->csTimer >= 20) { - this->envLightMode = 4; - } else { - this->envLightMode = 35; - } - - if (this->csTimer == 60) { - BossGanon_SetIntroCsCamera(this, 1); - this->csState = 5; - this->csTimer = 0; - } - break; - - case 5: - this->envLightMode = 5; - - if (this->csTimer < 50) { - globalCtx->envCtx.unk_D8 = 1.0f; - } - - if (this->csTimer == 10) { - func_8002DF54(globalCtx, &this->actor, 0x4B); - } - - if (this->csTimer == 70) { - BossGanon_SetIntroCsCamera(this, 3); - this->csState = 6; - this->csTimer = 0; - this->envLightMode = 3; - } - break; - - case 6: - this->envLightMode = 3; - - if (this->csTimer != 30) { - break; - } - - this->csState = 7; - this->csTimer = 0; - BossGanon_SetIntroCsCamera(this, 4); - this->triforceType = GDF_TRIFORCE_PLAYER; - this->fwork[GDF_TRIFORCE_SCALE] = 10.0f; - this->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; - this->fwork[GDF_TRIFORCE_PRIM_B] = 255.0f; - this->fwork[GDF_TRIFORCE_ENV_G] = 100.0f; - func_80078884(NA_SE_EV_TRIFORCE_MARK); - globalCtx->envCtx.unk_D8 = 0.0f; - // fallthrough - case 7: - this->envLightMode = 6; - // fade in links triforce - Math_ApproachF(&this->fwork[GDF_TRIFORCE_PRIM_A], 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_SCALE], 0.4f, 1.0f, 0.3f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_PRIM_B], 170.0f, 1.0f, 2.55f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); - - if (this->csTimer >= 30) { - this->envLightMode = 65; - } - - if (this->csTimer == 30) { - globalCtx->envCtx.unk_D8 = 1.0f; - } - - BossGanon_SetIntroCsCamera(this, 4); - this->csCamEye.x += 5.0f; - this->csCamEye.z += -10.0f; - this->csCamAt.x += 18.0f; - - if (this->csTimer == 60) { - this->csState = 8; - this->csTimer = 0; - } - break; - - case 8: - this->envLightMode = 3; - BossGanon_SetIntroCsCamera(this, 5); - - if (this->csTimer != 30) { - break; - } - - this->csState = 9; - this->csTimer = 0; - func_8002DF54(globalCtx, &this->actor, 8); - sZelda->unk_3C8 = 0; - this->triforceType = GDF_TRIFORCE_ZELDA; - this->fwork[GDF_TRIFORCE_SCALE] = 10.0f; - this->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; - this->fwork[GDF_TRIFORCE_PRIM_B] = 255.0f; - this->fwork[GDF_TRIFORCE_ENV_G] = 100.0f; - func_80078884(NA_SE_EV_TRIFORCE_MARK); - globalCtx->envCtx.unk_D8 = 0.0f; - // fallthrough - case 9: - this->envLightMode = 7; - BossGanon_SetIntroCsCamera(this, 6); - // fade in zeldas triforce - Math_ApproachF(&this->fwork[GDF_TRIFORCE_PRIM_A], 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_SCALE], 0.4f, 1.0f, 0.3f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_PRIM_B], 170.0f, 1.0f, 2.55f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); - - if (this->csTimer == 30) { - sZelda->unk_3C8 = 1; - } - - if (this->csTimer >= 32) { - this->envLightMode = 75; - } - - if (this->csTimer == 32) { - globalCtx->envCtx.unk_D8 = 1.0f; - } - - if (this->csTimer == 50) { - this->csState = 10; - this->csTimer = 0; - } - break; - - case 10: // top view of playing the organ - this->envLightMode = 3; - BossGanon_SetIntroCsCamera(this, 7); - - if (this->csTimer == 40) { - this->csState = 11; - this->csTimer = 0; - this->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; - } - break; - - case 11: // link is healed - this->envLightMode = 3; - BossGanon_SetIntroCsCamera(this, 8); - player->actor.world.pos.z = 20.0f; - - if (this->csTimer == 20) { - func_8002DF54(globalCtx, &this->actor, 0x17); - Interface_ChangeAlpha(11); // show hearts only - } - - if (this->csTimer == 25) { - gSaveContext.healthAccumulator = 0x140; - } - - if (this->csTimer == 100) { - Interface_ChangeAlpha(1); - } - - if (this->csTimer == 120) { - this->csState = 12; - this->csTimer = 0; - } - break; - - case 12: // first dialogue, ganondorf facing away from link - this->envLightMode = 3; - BossGanon_SetIntroCsCamera(this, 9); - - if (this->csTimer == 30) { - Audio_QueueSeqCmd(0x100100FF); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_004F64); - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_004F64, -5.0f); - } - - if ((this->csTimer > 30) && Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_006AF4, 0.0f); - this->fwork[GDF_FWORK_1] = 1000.0f; - } - - if (this->csTimer == 80) { - Message_StartTextbox(globalCtx, 0x70C8, NULL); - } - - if ((this->csTimer > 180) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 15; - this->csTimer = 0; - this->useOpenHand = false; - } - break; - - case 15: // side view of all 3 of them - this->envLightMode = 0; - globalCtx->envCtx.unk_D8 = 0.0f; - BossGanon_SetIntroCsCamera(this, 10); - - if (this->csTimer == 30) { - Message_StartTextbox(globalCtx, 0x70C9, NULL); - } - - if ((this->csTimer > 100) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 16; - this->csTimer = 0; - BossGanon_SetIntroCsCamera(this, 11); - this->unk_198 = 2; - sZelda->unk_3C8 = 2; - this->timers[2] = 110; - this->envLightMode = 3; - } - break; - - case 16: - this->envLightMode = 3; - - if (this->csTimer <= 20) { - if (this->csTimer == 20) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_004304, -5.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_004304); - } - } else if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - Message_StartTextbox(globalCtx, 0x70CA, NULL); - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_0089F8, -5.0f); - this->fwork[GDF_FWORK_1] = 1000.0f; - } - - if ((this->csTimer > 100) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 17; - this->csTimer = 0; - } - break; - - case 17: // turns around - this->envLightMode = 3; - - if (this->csTimer == 20) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_001F58, -5.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_001F58); - } - - if (this->csTimer > 10) { - if (this->csTimer == 62) { - sCape->attachRightArmTimer = 20.0f; - } - - if (this->csTimer == 57) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - } - - Math_ApproachF(&this->csCamFov, 110.0f, 0.1f, this->csCamMaxStepScale * 2.0f); - Math_ApproachF(&this->csCamEye.z, -290.0f, 0.1f, this->csCamMaxStepScale * 2.4f); - Math_ApproachF(&this->csCamMaxStepScale, 0.75f, 1.0f, 0.05f); - - if (this->csTimer == 70) { - this->csState = 18; - this->csTimer = 0; - this->csCamFov = 60.0f; - BossGanon_SetIntroCsCamera(this, 12); - Message_StartTextbox(globalCtx, 0x70CB, NULL); - } - } - break; - - case 18: // last dialog before triforce - this->envLightMode = 3; - BossGanon_SetIntroCsCamera(this, 12); - this->csCamEye.y += -6.0f; - this->csCamEye.z += 6.0f; - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1] - 5.0f)) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_003018, -5.0f); - this->fwork[GDF_FWORK_1] = 1000.0f; - } - - if ((this->csTimer <= 50) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { - break; - } - - this->csState = 19; - this->csTimer = 0; - Message_StartTextbox(globalCtx, 0x70CC, NULL); - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_007268, -5.0f); - this->triforceType = GDF_TRIFORCE_DORF; - this->fwork[GDF_TRIFORCE_SCALE] = 10.0f; - this->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; - this->fwork[GDF_TRIFORCE_PRIM_B] = 255.0f; - this->fwork[GDF_TRIFORCE_ENV_G] = 100.0f; - globalCtx->envCtx.unk_D8 = 0.0f; - // fallthrough - case 19: // show triforce - this->envLightMode = 8; - - if (this->csTimer >= 60) { - this->envLightMode = 9; - - if (this->csTimer == 60) { - globalCtx->envCtx.unk_D8 = 1.0f; - } - } - - BossGanon_SetIntroCsCamera(this, 12); - this->csCamEye.y += -6.0f; - this->csCamEye.z += 6.0f; - - if (this->csTimer >= 30) { - if (this->csTimer == 30) { - func_80078884(NA_SE_EV_TRIFORCE_MARK); - } - - // fade in ganondorf's triforce - Math_ApproachF(&this->fwork[GDF_TRIFORCE_PRIM_A], 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_SCALE], 0.6f, 1.0f, 0.3f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_PRIM_B], 170.0f, 1.0f, 2.55f); - Math_ApproachF(&this->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); - } - - if (this->csTimer == 17) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_007A64, -5.0f); - } - - if ((this->csTimer > 80) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 20; - this->csTimer = 0; - - this->csCamTargetEye.x = this->csCamEye.x - 50.0f; - this->csCamTargetEye.y = this->csCamEye.y - 100.0f; - this->csCamTargetEye.z = this->csCamEye.z + 400.0f; - - this->csCamEyeMaxStep.x = 50.0f; - this->csCamEyeMaxStep.y = 100.0f; - this->csCamEyeMaxStep.z = 400.0f; - - this->csCamAtMaxStep.x = 400.0f; - this->csCamMaxStepScale = 0.0f; - - this->csCamTargetAt.x = this->csCamAt.x + 400.0f; - this->csCamTargetAt.y = this->csCamAt.y; - this->csCamTargetAt.z = this->csCamAt.z; - - this->csCamMovementScale = 0.2f; - - this->fwork[GDF_VORTEX_ALPHA] = 0.0f; - this->fwork[GDF_VORTEX_SCALE] = 0.1f; - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DARKWAVE); - } - break; - - case 20: // zoom cam out - this->envLightMode = 10; - moveCam = true; - Math_ApproachF(&this->csCamMaxStepScale, 0.15f, 1.0f, 0.015f); - - if (this->csTimer <= 40) { - Math_ApproachF(&this->fwork[GDF_VORTEX_ALPHA], 255.0f, 1.0f, 6.5f); - Math_ApproachF(&this->fwork[GDF_VORTEX_SCALE], 0.2f, 1.0f, 0.025f); - } - - if (this->csTimer > 20) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DARKWAVE_M - SFX_FLAG); - } - - if (this->csTimer > 20) { - BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); - BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); - } - - if (this->csTimer == 30) { - func_8002DF54(globalCtx, &this->actor, 0x4A); - } - - if (this->csTimer <= 50) { - break; - } - - this->csState = 21; - this->csTimer = 0; - this->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; - this->fwork[GDF_VORTEX_SCALE] = 0.16f; - goto skip_sound_and_fx; - - case 21: // purple vortex - this->envLightMode = 11; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DARKWAVE_M - SFX_FLAG); - BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); - BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); - - skip_sound_and_fx: - this->csCamEye.x = -30.0f; - this->csCamEye.y = 37.0f; - this->csCamEye.z = -30.0f; - - this->csCamAt.x = -10.0f; - this->csCamAt.y = 45.0f; - this->csCamAt.z = 0.0f; - - if (this->csTimer == 13) { - Message_StartTextbox(globalCtx, 0x70CD, NULL); - } - - if ((this->csTimer <= 120) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { - break; - } - - this->csState = 22; - this->csTimer = 0; - this->timers[2] = 30; - this->organAlpha = 254; - this->csCamAt.x = this->unk_1FC.x - 10.0f; - this->csCamAt.y = this->unk_1FC.y + 30.0f; - this->csCamAt.z = this->unk_1FC.z; - this->fwork[GDF_VORTEX_ALPHA] = 255.0f; - this->fwork[GDF_VORTEX_SCALE] = 0.2f; - // fallthrough - case 22: // start floating, show title card, start fight - if (this->csTimer > 30) { - this->envLightMode = 0; - } else { - this->envLightMode = 12; - } - - Math_ApproachZeroF(&this->fwork[GDF_VORTEX_ALPHA], 1.0f, 10.0f); - - this->csCamEye.x = -30.0f; - this->csCamEye.y = 137.0f; - this->csCamEye.z = -110.0f; - - Math_ApproachF(&this->csCamAt.y, this->unk_1FC.y + 30.0f, 0.1f, 20.0f); - Math_ApproachF(&this->csCamAt.x, this->unk_1FC.x - 10.0f, 0.1f, 5.0f); - - if (this->csTimer == 20) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); - SkelAnime_Update(&this->skelAnime); - this->actor.shape.yOffset = 0.0f; - sCape->attachShouldersTimer = 18.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - this->unk_198 = 0; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANONDORF_BOSS); - } - - if (this->csTimer == 50) { - gSegments[6] = VIRTUAL_TO_PHYSICAL( - gObjectTable[Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON)].vromStart); - - if (!(gSaveContext.eventChkInf[7] & 0x100)) { - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gDorfTitleCardTex), 160, 180, 128, 40); - } - - gSaveContext.eventChkInf[7] |= 0x100; - } - - if (this->csTimer >= 20) { - this->legSwayEnabled = true; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_FLOAT - SFX_FLAG); - - Math_ApproachF(&this->actor.world.pos.y, 228.0f, 0.05f, 2.0f); - Math_ApproachF(&this->actor.world.pos.z, -230.0f, 0.05f, 4.0f); - - sCape->backPush = -3.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -3.0f; - - sin = Math_SinS(this->csTimer * 1500); - this->actor.velocity.y = this->fwork[GDF_FWORK_0] * sin * 0.04f; - this->actor.world.pos.y += this->actor.velocity.y; - - cos = Math_CosS(this->csTimer * 1800); - this->actor.world.pos.x = this->fwork[GDF_FWORK_0] * cos * 0.5f; - this->actor.velocity.x = this->actor.world.pos.x - this->actor.prevPos.x; - - Math_ApproachF(&this->fwork[GDF_FWORK_0], 50.0f, 1.0f, 1.0f); - } - - if (this->csTimer > 30) { - this->organAlpha -= 5; - - if (this->organAlpha < 0) { - this->organAlpha = 0; - } - } - - if (this->csTimer == 120) { - mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - mainCam->eye = this->csCamEye; - mainCam->eyeNext = this->csCamEye; - mainCam->at = this->csCamAt; - func_800C08AC(globalCtx, this->csCamIndex, 0); - this->csState = this->csCamIndex = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - BossGanon_SetupWait(this, globalCtx); - } - - if (sZelda != NULL) { - sZelda->actor.world.pos.x = 0.0f; - sZelda->actor.world.pos.y = 350.0f; - sZelda->actor.world.pos.z = 0.0f; - } - } - - if (this->csCamIndex != 0) { - if (moveCam) { - Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, this->csCamMovementScale, - this->csCamEyeMaxStep.x * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, this->csCamMovementScale, - this->csCamEyeMaxStep.y * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, this->csCamMovementScale, - this->csCamEyeMaxStep.z * this->csCamMaxStepScale); - - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, this->csCamMovementScale, - this->csCamAtMaxStep.x * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, this->csCamMovementScale, - this->csCamAtMaxStep.y * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, this->csCamMovementScale, - this->csCamAtMaxStep.z * this->csCamMaxStepScale); - } - - Gameplay_CameraSetAtEye(globalCtx, this->csCamIndex, &this->csCamAt, &this->csCamEye); - Gameplay_CameraSetFov(globalCtx, this->csCamIndex, this->csCamFov); - } -} - -void BossGanon_SetupDeathCutscene(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - s32 animBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME2); - - if (Object_IsLoaded(&globalCtx->objectCtx, animBankIndex)) { - this->actionFunc = BossGanon_DeathAndTowerCutscene; - this->csTimer = this->csState = 0; - this->unk_198 = 1; - this->animBankIndex = animBankIndex; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[animBankIndex].vromStart); - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_00EA00, 0.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); - this->unk_508 = 0.0f; - } -} - -void BossGanon_SetupTowerCutscene(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - s32 animBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME2); - - if (Object_IsLoaded(&globalCtx->objectCtx, animBankIndex)) { - this->animBankIndex = animBankIndex; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[animBankIndex].vromStart); - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_00EA00, 0.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); - this->actionFunc = BossGanon_DeathAndTowerCutscene; - this->csTimer = 0; - this->csState = 100; - this->unk_198 = 1; - gSaveContext.magic = gSaveContext.unk_13F4; - gSaveContext.health = gSaveContext.healthCapacity; - } else { - this->actionFunc = BossGanon_SetupTowerCutscene; - } -} - -void BossGanon_ShatterWindows(u8 windowShatterState) { - s16 i; - u8* tex1 = SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_006C18); - u8* tex2 = SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_007418); - - for (i = 0; i < 2048; i++) { - if ((tex1[i] != 0) && (Rand_ZeroOne() < 0.03f)) { - if ((((u8*)gDorfWindowShatterTemplateTex)[i] == 0) || (windowShatterState == GDF_WINDOW_SHATTER_FULL)) { - tex1[i] = tex2[i] = 1; - } - } - } -} - -void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) { - static Color_RGBA8 bloodPrimColor = { 0, 120, 0, 255 }; - static Color_RGBA8 bloodEnvColor = { 0, 120, 0, 255 }; - s16 i; - u8 moveCam = false; - Player* player = GET_PLAYER(globalCtx); - s16 pad; - Vec3f sp98; - Vec3f sp8C; - Vec3f sp80; - Vec3f sp74; - Camera* mainCam; - Vec3f sp64; - - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animBankIndex].vromStart); - - this->csTimer++; - SkelAnime_Update(&this->skelAnime); - - switch (this->csState) { - case 0: - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->csCamIndex = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->csCamIndex, CAM_STAT_ACTIVE); - - this->actor.world.pos.x = 0.0f; - this->actor.world.pos.y = 70.0f; - this->actor.world.pos.z = -80.0f; - - this->actor.shape.yOffset = -7000.0f; - - this->actor.shape.rot.y = 0; - this->csState = 1; - this->csTimer = 0; - this->useOpenHand = true; - // fallthrough - case 1: - player->actor.shape.rot.y = -0x8000; - - player->actor.world.pos.x = -10.0f; - player->actor.world.pos.y = 0.0f; - player->actor.world.pos.z = 115.0f; - - this->envLightMode = 13; - - if (this->csTimer < 30) { - globalCtx->envCtx.unk_D8 = 0.0f; - } - - if (this->csTimer >= 2) { - globalCtx->envCtx.fillScreen = false; - } - - this->csCamEye.x = -50.0f; - this->csCamEye.z = -50.0f; - this->csCamEye.y = 50.0f; - - this->csCamAt.x = this->unk_1FC.x; - this->csCamAt.y = this->unk_1FC.y + 30.0f; - this->csCamAt.z = this->unk_1FC.z; - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_00F19C, 0.0f); - this->csState = 2; - this->csTimer = 0; - } - break; - - case 2: - this->csCamEye.x = -100.0f; - this->csCamEye.y = 20.0f; - this->csCamEye.z = -130.0f; - - this->envLightMode = 13; - - this->csCamAt.x = this->unk_1FC.x; - this->csCamAt.y = this->unk_1FC.y; - this->csCamAt.z = this->unk_1FC.z + 40.0f; - - if (this->csTimer >= 30) { - this->csState = 3; - this->csTimer = 0; - Message_StartTextbox(globalCtx, 0x70CE, NULL); - this->fwork[GDF_FWORK_1] = 1000.0f; - } - - if ((this->unk_1A2 % 32) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BREATH); - } - break; - - case 3: - this->envLightMode = 14; - - if ((this->fwork[GDF_FWORK_1] > 100.0f) && ((this->unk_1A2 % 32) == 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BREATH); - } - - this->csCamEye.x = 7.0f; - this->csCamEye.y = 52.0f; - this->csCamEye.z = -15.0f; - - this->csCamAt.x = this->unk_1FC.x - 5.0f; - this->csCamAt.y = this->unk_1FC.y + 30.0f - 10.0f; - this->csCamAt.z = this->unk_1FC.z; - - if ((this->fwork[GDF_FWORK_1] > 100.0f) && (this->csTimer > 100) && - (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_00B668, 0.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00B668); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_TOKETU); - } else { - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1] - 16.0f)) { - for (i = 0; i < 40; i++) { - sp98.x = Rand_CenteredFloat(5.0f); - sp98.y = Rand_CenteredFloat(1.5f) + 1.0f; - sp98.z = Rand_ZeroFloat(5.0f) + 2.0f; - - sp8C.x = 0.0f; - sp8C.y = -1.0f; - sp8C.z = 0.0f; - - sp80.x = this->unk_208.x; - sp80.y = this->unk_208.y - 10.0f; - sp80.z = this->unk_208.z; - - func_8002836C(globalCtx, &sp80, &sp98, &sp8C, &bloodPrimColor, &bloodEnvColor, - (s16)Rand_ZeroFloat(50.0f) + 50, 0, 17); - } - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_00BE38, 0.0f); - this->csState = 4; - this->csTimer = 0; - } - } - break; - - case 4: - this->envLightMode = 14; - - if (this->csTimer == 30) { - Message_StartTextbox(globalCtx, 0x70CF, NULL); - this->csState = 5; - this->csTimer = 0; - } - break; - - case 5: - this->envLightMode = 14; - - if ((this->csTimer > 70) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 6; - this->csTimer = 0; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_010298, 0.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_010298); - - this->csCamMovementScale = 0.05f; - this->csCamMaxStepScale = 0.0f; - - this->csCamTargetEye.x = 7.0f; - this->csCamTargetEye.y = 12.0f; - this->csCamTargetEye.z = 70.0f; - - this->csCamTargetAt.x = this->unk_1FC.x - 5.0f; - this->csCamTargetAt.y = (this->unk_1FC.y + 30.0f) - 10.0f; - this->csCamTargetAt.z = this->unk_1FC.z; - - this->csCamEyeMaxStep.x = fabsf(this->csCamEye.x - this->csCamTargetEye.x); - this->csCamEyeMaxStep.y = fabsf(this->csCamEye.y - this->csCamTargetEye.y); - this->csCamEyeMaxStep.z = fabsf(this->csCamEye.z - this->csCamTargetEye.z); - - this->csCamAtMaxStep.x = fabsf(this->csCamAt.x - this->csCamTargetAt.x); - this->csCamAtMaxStep.y = fabsf(this->csCamAt.y - this->csCamTargetAt.y); - this->csCamAtMaxStep.z = fabsf(this->csCamAt.z - this->csCamTargetAt.z); - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_CASBREAK); - } - break; - - case 6: - this->envLightMode = 14; - moveCam = true; - Math_ApproachF(&this->csCamMaxStepScale, 0.2f, 1.0f, 0.01f); - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime2_Anim_010514, 0.0f); - this->csState = 7; - this->csTimer = 0; - this->unk_2E8 = 0; - this->envLightMode = 15; - this->unk_508 = 0.0f; - this->fwork[GDF_FWORK_1] = 1000.0f; - globalCtx->envCtx.unk_D8 = 0.0f; - } - break; - - case 7: - if (this->csTimer < 10) { - globalCtx->envCtx.unk_D8 = 0.0f; - } - - if (this->csTimer == 30) { - this->csState = 8; - this->csTimer = 0; - this->unk_70C = 0.0f; - } - goto skip_cam_and_quake; - - case 8: - this->csCamEye.x = -60.0f; - this->csCamEye.y = 80.0f; - this->csCamEye.z = -130.0f; - - this->csCamAt.x = 0.0f; - this->csCamAt.y = 0.0f; - this->csCamAt.z = 70.0f; - - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.2f; - - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - skip_cam_and_quake: - this->envLightMode = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BODY_SPARK - SFX_FLAG); - - for (i = 1; i < 15; i++) { - this->unk_4E4[i] = 0xA; - } - - this->unk_2E6 = 20000; - Math_ApproachF(&this->unk_508, 5.0f, 0.05f, 0.1f); - - if (this->csTimer == 30) { - this->csState = 9; - this->csTimer = 0; - - this->csCamEye.x = -30.0f; - this->csCamEye.y = 40.0f; - this->csCamEye.z = 60.0f; - - this->csCamAt.x = 492.0f; - this->csCamAt.y = 43.0f; - this->csCamAt.z = 580.0f; - - this->csCamMaxStepScale = 0.0f; - this->unk_710 = 10.0f; - } - break; - - case 9: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BODY_SPARK - SFX_FLAG); - - if (this->csTimer == 2) { - func_8002DF54(globalCtx, &this->actor, 0x39); - } - - if (this->csTimer > 50) { - Math_ApproachZeroF(&this->unk_710, 1.0f, 0.2f); - Math_ApproachF(&this->csCamEye.x, 270.0f, 0.05f, this->csCamMaxStepScale * 30.0f); - Math_ApproachF(&this->csCamEye.z, 260.0f, 0.05f, this->csCamMaxStepScale * 20.0f); - Math_ApproachF(&this->csCamAt.y, 103.0f, 0.05f, this->csCamMaxStepScale * 6.0f); - Math_ApproachF(&this->csCamAt.z, 280.0f, 0.05f, this->csCamMaxStepScale * 20.0f); - Math_ApproachF(&this->csCamMaxStepScale, 1.0f, 1.0f, 0.01f); - } - - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * this->unk_710; - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - if (this->csTimer < 100) { - this->windowShatterState = GDF_WINDOW_SHATTER_PARTIAL; - this->envLightMode = 15; - } else { - this->envLightMode = 16; - this->windowShatterState = GDF_WINDOW_SHATTER_FULL; - } - - if (this->csTimer >= 130) { - Math_ApproachF(&this->whiteFillAlpha, 255.0f, 1.0f, 5.0f); - } - - if (this->csTimer == 180) { - globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = 0x43F; - globalCtx->fadeTransition = 5; - } - break; - - case 100: - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->csCamIndex = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->csCamIndex, CAM_STAT_ACTIVE); - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime2_Anim_00ADDC, 0.0f); - this->fwork[1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); - this->csState = 101; - this->skelAnime.playSpeed = 0.0f; - sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, - 6000.0f, 0.0f, 0, 0, 0, 0x2000); - - player->actor.world.pos.x = -472.0f; - player->actor.world.pos.y = 4102.0f; - player->actor.world.pos.z = -130.0f; - - player->actor.shape.rot.y = -0x8000; - - this->actor.world.pos.x = -472.0f; - this->actor.world.pos.y = 4172.0f; - this->actor.world.pos.z = -400.0f; - - this->actor.shape.yOffset = -7000.0f; - this->actor.shape.rot.y = 0; - - this->csCamEye.x = this->csCamAt.x = -472.0f; - this->csCamEye.y = this->csCamAt.y = 4152.0f; - this->csCamEye.z = -160.0f; - - this->csCamAt.z = -100.0f; - - sCape->backPush = -2.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -1.0f; - sCape->minDist = 0.0f; - sCape->minY = 4104.0f; - sCape->tearTimer = 20; - - this->whiteFillAlpha = 255.0f; - globalCtx->envCtx.unk_D8 = 1.0f; - // fallthrough - case 101: - player->actor.world.pos.y = 4102.0f; - Math_ApproachZeroF(&this->whiteFillAlpha, 1.0f, 5.0f); - - if (this->csTimer > 40) { - Math_ApproachF(&this->csCamEye.z, -520.0f, 0.1f, this->csCamMaxStepScale); - Math_ApproachF(&this->csCamMaxStepScale, 5.0f, 1.0f, 0.1f); - - if (this->csTimer == 150) { - this->skelAnime.playSpeed = 1.0f; - } - - if (this->csTimer == 160) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_BOUND_NOWEAPON); - } - - if (this->csTimer == 187) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_BODY_HIT); - } - - if (this->csTimer == 180) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - } - - if (this->csTimer == 190) { - sp74 = this->actor.world.pos; - sp74.y = 4102.0f; - BossGanonEff_SpawnDustDark(globalCtx, &sp74, 0.2f, 0.7f); - } - - if (this->csTimer == 230) { - this->csState = 102; - this->csTimer = 0; - } - } - break; - - case 102: - player->actor.world.pos.y = 4102.0f; - - this->csCamEye.x = -442.0f; - this->csCamEye.y = 4152.0f; - this->csCamEye.z = -135.0f; - - this->csCamAt.x = -472.0f; - this->csCamAt.y = 4152.0f; - this->csCamAt.z = -135.0f; - - if (this->csTimer == 5) { - func_8002DF54(globalCtx, &this->actor, 0x4C); - } - - if (this->csTimer == 70) { - func_8002DF54(globalCtx, &this->actor, 0x4D); - } - - if (this->csTimer == 90) { - this->csState = 103; - this->csTimer = 0; - sZelda->actor.world.pos.x = -472.0f; - sZelda->actor.world.pos.y = 4352.0f; - sZelda->actor.world.pos.z = -200.0f; - sZelda->unk_3C8 = 3; - } - break; - - case 103: - Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_DOWN_TO_GROUND - SFX_FLAG); - Math_ApproachF(&sZelda->actor.world.pos.y, 4102.0f, 0.05f, 1.5f); - - this->csCamEye.x = -242.0f; - this->csCamEye.y = 4122.0f; - this->csCamEye.z = -190.0f; - - this->csCamAt.x = sZelda->actor.world.pos.x; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z; - - if (this->csTimer == 200) { - sZelda->actor.world.pos.y = 4102.0f; - this->csState = 104; - this->csTimer = 0; - } else { - break; - } - // fallthrough - case 104: - this->csCamEye.x = -432.0f; - this->csCamEye.y = 4147.0f; - this->csCamEye.z = -200.0f; - - this->csCamAt.x = sZelda->actor.world.pos.x; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z; - - if (this->csTimer >= 10) { - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - } - - if (this->csTimer == 10) { - sZelda->unk_3C8 = 8; - } - - if (this->csTimer == 50) { - sZelda->unk_3C8 = 4; - } - - if (this->csTimer == 100) { - this->csState = 105; - this->csTimer = 0; - } - break; - - case 105: - this->csCamEye.x = -450.0f; - this->csCamEye.y = 4154.0f; - this->csCamEye.z = -182.0f; - - this->csCamAt.x = sZelda->actor.world.pos.x - 5.0f; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z - 25.0f; - - if (this->csTimer == 10) { - Message_StartTextbox(globalCtx, 0x70D0, NULL); - } - - if ((this->csTimer > 100) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 1055; - this->csTimer = 0; - } - break; - - case 1055: - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.3f; - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - if (this->csTimer == 20) { - sZelda->unk_3C8 = 5; - func_8002DF54(globalCtx, &this->actor, 0x39); - } - - if (this->csTimer == 40) { - this->csState = 1056; - this->csTimer = 0; - } - break; - - case 1056: - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.3f; - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - this->csCamEye.x = -503.0f; - this->csCamEye.y = 4128.0f; - this->csCamEye.z = -162.0f; - - this->csCamAt.x = -416.0f; - this->csCamAt.y = 4181.0f; - this->csCamAt.z = -75.0f; - - if (this->csTimer > 40) { - this->csState = 1057; - this->csTimer = 0; - } - break; - - case 1057: - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * (50.0f * this->csCamMovementScale); - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - Math_ApproachF(&this->csCamEye.x, -1200.0f, 0.1f, this->csCamMovementScale * 697.0f); - Math_ApproachF(&this->csCamEye.y, 4241.0f, 0.1f, this->csCamMovementScale * 113.0f); - Math_ApproachF(&this->csCamEye.z, -1048.0f, 0.1f, this->csCamMovementScale * 886.0f); - - Math_ApproachF(&this->csCamMovementScale, 0.05f, 1.0f, 0.001f); - - if (this->csTimer > 80) { - this->csState = 106; - this->csTimer = 60; - } - break; - - case 106: - this->csCamEye.x = -450.0f; - this->csCamEye.y = 4154.0f; - this->csCamEye.z = -182.0f; - - this->csCamAt.x = sZelda->actor.world.pos.x - 5.0f; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z - 25.0f; - - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.3f; - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - if (this->csTimer == 70) { - sZelda->unk_3C8 = 6; - } - - if (this->csTimer == 90) { - Message_StartTextbox(globalCtx, 0x70D1, NULL); - } - - if ((this->csTimer > 150) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->csState = 107; - this->csTimer = 0; - Message_StartTextbox(globalCtx, 0x70D2, NULL); - func_8002DF54(globalCtx, &this->actor, 0x39); - } - break; - - case 107: - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.8f; - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - this->csCamEye.x = -380.0f; - this->csCamEye.y = 4154.0f; - this->csCamEye.z = -242.0f; - - this->csCamAt.x = (sZelda->actor.world.pos.x - 5.0f) - 30.0f; - this->csCamAt.y = (sZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; - this->csCamAt.z = (sZelda->actor.world.pos.z - 25.0f) + 80.0f; - - if ((this->csTimer > 50) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - sZelda->unk_3C8 = 7; - this->csState = 108; - this->csTimer = 0; - } - break; - - case 108: - this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.8f; - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - - this->csCamAt.x = (sZelda->actor.world.pos.x - 5.0f) - 30.0f; - this->csCamAt.y = (sZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; - this->csCamAt.z = (sZelda->actor.world.pos.z - 25.0f) + 80.0f; - - if (this->csTimer > 50) { - mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - - mainCam->eye = this->csCamEye; - mainCam->eyeNext = this->csCamEye; - mainCam->at = this->csCamAt; - - func_800C08AC(globalCtx, this->csCamIndex, 0); - this->csState = 109; - this->csCamIndex = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - Flags_SetSwitch(globalCtx, 0x37); - } - break; - - case 109: - func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - break; - } - - if (this->csState >= 100) { - this->envLightMode = 20; - } - - if (this->csCamIndex != 0) { - if (moveCam) { - Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, this->csCamMovementScale, - this->csCamEyeMaxStep.x * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, this->csCamMovementScale, - this->csCamEyeMaxStep.y * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, this->csCamMovementScale, - this->csCamEyeMaxStep.z * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, this->csCamMovementScale, - this->csCamAtMaxStep.x * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, this->csCamMovementScale, - this->csCamAtMaxStep.y * this->csCamMaxStepScale); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, this->csCamMovementScale, - this->csCamAtMaxStep.z * this->csCamMaxStepScale); - } - - sp64 = this->csCamAt; - sp64.y += this->unk_70C; - Gameplay_CameraSetAtEye(globalCtx, this->csCamIndex, &sp64, &this->csCamEye); - } -} - -void BossGanon_SetupPoundFloor(BossGanon* this, GlobalContext* globalCtx) { - this->unk_1C2 = 0; - this->timers[0] = 40; - this->actionFunc = BossGanon_PoundFloor; - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->fwork[GDF_CENTER_POS] = 100.0f; -} - -void BossGanon_PoundFloor(BossGanon* this, GlobalContext* globalCtx) { - s16 i; - f32 heightTarget; - f32 targetPosX; - f32 targetPosZ; - Vec3f sp6C; - Vec3f sp60; - Vec3f sp54; - Vec3f sp48; - - SkelAnime_Update(&this->skelAnime); - - switch (this->unk_1C2) { - case 0: - targetPosX = Math_SinS(this->unk_1A2 * 1280); - targetPosX = targetPosX * this->fwork[GDF_CENTER_POS]; - targetPosZ = Math_CosS(this->unk_1A2 * 1792); - targetPosZ = targetPosZ * this->fwork[GDF_CENTER_POS]; - - Math_ApproachF(&this->actor.world.pos.x, targetPosX, 0.05f, this->fwork[GDF_FWORK_0]); - Math_ApproachF(&this->actor.world.pos.z, targetPosZ, 0.05f, this->fwork[GDF_FWORK_0]); - Math_ApproachF(&this->fwork[GDF_CENTER_POS], 0.0f, 1, 1.5f); - - if (this->timers[0] == 5) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_HIT_GND); - } - - if (this->timers[0] < 14) { - heightTarget = 250.0f; - this->unk_258 += (Rand_ZeroFloat(M_PI / 2) + (M_PI / 2)); - Math_ApproachF(&this->handLightBallScale, 7.0f, 0.5f, 1.0f); - this->envLightMode = 1; - } else { - heightTarget = 200.0f; - } - - Math_ApproachF(&this->actor.world.pos.y, heightTarget, 0.1f, this->actor.velocity.y); - Math_ApproachF(&this->actor.velocity.y, 20.0f, 1.0f, 1.0f); - - if (this->timers[0] == 14) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfPoundAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfPoundAnim, 0.0f); - this->actor.velocity.y = 0.0f; - } - - if (this->timers[0] == 0) { - this->unk_1C2 = 1; - this->actor.velocity.y = 0.0f; - } - break; - - case 1: - sCape->gravity = -1.0f; - this->envLightMode = 1; - Math_ApproachF(&this->actor.velocity.y, -50.0f, 1.0f, 10.0f); - this->actor.world.pos.y += this->actor.velocity.y; - - if (this->actor.world.pos.y < 60.0f) { - this->actor.world.pos.y = 60.0f; - this->unk_1C2 = 2; - this->timers[0] = 10; - func_80033E88(&this->actor, globalCtx, 0xA, 0x14); // rumble - this->unk_19C = 35; - this->unk_19E = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_HIT_GND_IMP); - this->handLightBallScale = 0.0f; - sp60 = this->unk_260; - sp60.y = 0.0f; - - for (i = 0; i < 80; i++) { - sp6C.x = Rand_CenteredFloat(25.0f); - sp6C.y = Rand_ZeroFloat(17.0f); - sp6C.z = Rand_CenteredFloat(25.0f); - BossGanonEff_SpawnLightRay(globalCtx, &sp60, &sp6C, &sZeroVec, Rand_ZeroFloat(300.0f) + 500.0f, - 13.0f, 0x1E); - } - } - break; - - case 2: - this->envLightMode = 1; - - if (this->timers[0] == 0) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfPoundEndAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfPoundEndAnim, 0.0f); - this->unk_1C2 = 3; - this->unk_19F = 1; - this->actor.velocity.y = 0.0f; - } - break; - - case 3: - Math_ApproachF(&this->actor.world.pos.y, 150.0f, 0.1f, this->actor.velocity.y); - Math_ApproachF(&this->actor.velocity.y, 20.0f, 1.0f, 1.0f); - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); - SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 18.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - this->unk_1C2 = 4; - } - break; - - case 4: - Math_ApproachF(&this->actor.world.pos.y, 150.0f, 0.1f, this->actor.velocity.y); - Math_ApproachF(&this->actor.velocity.y, 20.0f, 1.0f, 1.0f); - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - BossGanon_SetupWait(this, globalCtx); - } - break; - } - - if ((this->unk_19C == 35) || (this->unk_19C == 30) || (this->unk_19C == 25)) { - sp54 = this->actor.world.pos; - sp54.y = 0.0f; - BossGanonEff_SpawnDustLight(globalCtx, &sp54, 0, 3.0f, this->unk_19C - 25); - } - - if (this->unk_19C == 35) { - sp48 = this->actor.world.pos; - sp48.y = 0.0f; - BossGanonEff_SpawnShockwave(globalCtx, &sp48, 0, 3.0f); - } -} - -void BossGanon_SetupChargeBigMagic(BossGanon* this, GlobalContext* globalCtx) { - this->unk_1C2 = 0; - this->timers[0] = 30; - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->fwork[GDF_CENTER_POS] = 100.0f; - this->unk_1AA = Rand_ZeroFloat(20000.0f); - this->unk_1AC = 0; - this->actionFunc = BossGanon_ChargeBigMagic; -} - -void BossGanon_ChargeBigMagic(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - f32 targetPosX; - f32 targetPosZ; - Vec3f sp80; - Vec3f sp74; - Vec3f sp68; - s16 i; - - SkelAnime_Update(&this->skelAnime); - - targetPosX = Math_SinS(this->unk_1A2 * 1280); - targetPosX = targetPosX * this->fwork[GDF_CENTER_POS]; - - targetPosZ = Math_CosS(this->unk_1A2 * 1792); - targetPosZ = targetPosZ * this->fwork[GDF_CENTER_POS]; - - Math_ApproachF(&this->actor.world.pos.x, targetPosX, 0.05f, this->fwork[GDF_FWORK_0]); - Math_ApproachF(&this->actor.world.pos.z, targetPosZ, 0.05, this->fwork[GDF_FWORK_0]); - - Math_ApproachF(&this->fwork[GDF_CENTER_POS], 0.0f, 1.0f, 1.5f); - Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, this->actor.velocity.y); - Math_ApproachF(&this->actor.velocity.y, 20.0f, 1.0f, 1.0f); - - switch (this->unk_1C2) { - case 0: - if (this->timers[0] == 0) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicChargeStartAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBigMagicChargeStartAnim, 0.0f); - this->unk_1C2 = 1; - } - break; - - case 1: - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicChargeHoldAnim); - Animation_MorphToLoop(&this->skelAnime, &gDorfBigMagicChargeHoldAnim, 0.0f); - this->unk_1C2 = 2; - this->timers[0] = 100; - } - break; - - case 2: - this->envLightMode = 2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_CHARGE_MASIC - SFX_FLAG); - this->unk_278.x = this->unk_2EC[0].x; - this->unk_278.y = this->unk_2EC[0].y + 50.0f + 30.0f; - this->unk_278.z = this->unk_2EC[0].z; - - Math_ApproachF(&this->unk_284, 0.25f, 0.1f, 0.006f); - Math_ApproachF(&this->unk_288, 255.0f, 1.0f, 255.0f); - Math_ApproachF(&this->unk_28C, 0.25f, 0.1f, 0.006f); - - if ((this->timers[0] > 20) && (this->timers[0] < 60)) { - Math_ApproachF(&this->unk_290, 255.0f, 1.0f, 15.0f); - } - - if (this->timers[0] == 0) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicWindupAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBigMagicWindupAnim, 0.0f); - this->unk_1C2 = 3; - this->timers[0] = 6; - this->timers[1] = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DARKWAVE); - break; - } - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3E8); - - if (this->timers[0] < -4) { - for (i = 0; i < ARRAY_COUNT(this->unk_294); i++) { - Math_ApproachF(&this->unk_294[i], 0.0f, 1.0f, 40.0f); - } - } else if ((this->timers[0] >= 7) && (this->timers[0] < 26)) { - if (this->unk_1AC < ARRAY_COUNT(this->unk_294)) { - this->unk_1AC++; - } - - for (i = 0; i < this->unk_1AC; i++) { - Math_ApproachF(&this->unk_294[i], 200.0f, 1.0f, 40.0f); - } - } - - if (this->timers[0] <= 30) { - Math_ApproachF(&this->unk_284, 0.4f, 0.5f, 0.017f); - this->unk_28C = this->unk_284; - } - - if (this->timers[0] <= 30) { - Math_ApproachF(&this->unk_2D0, 45.0f, 0.1f, 10.0f); - this->lensFlareTimer = 1; - this->lensFlareMode = 2; - gCustomLensFlarePos = this->unk_278; - } - - if (this->timers[0] == 47) { - this->unk_274 = 1; - } - - if (this->timers[0] == 46) { - this->unk_274 = 2; - } - - if (this->timers[0] == 45) { - this->unk_274 = 3; - } - - if (this->timers[0] == 44) { - this->unk_274 = 4; - } - - if (this->timers[0] == 43) { - this->unk_274 = 5; - } - - if (this->timers[0] == 42) { - this->unk_274 = 6; - } - - if (this->timers[0] > 30) { - sp74.x = 0.0f; - sp74.y = Rand_ZeroFloat(10.0f) + 150.0f; - sp74.z = 0.0f; - - Matrix_RotateY(BINANG_TO_RAD(this->actor.yawTowardsPlayer), MTXMODE_NEW); - Matrix_RotateZ(Rand_ZeroFloat(65536.0f), MTXMODE_APPLY); - Matrix_MultVec3f(&sp74, &sp68); - - sp80.x = this->unk_278.x + sp68.x; - sp80.y = this->unk_278.y + sp68.y; - sp80.z = this->unk_278.z + sp68.z; - - BossGanonEff_SpawnBlackDot(globalCtx, &sp80, 20.0f); - } - break; - - case 3: - this->envLightMode = 2; - - for (i = 0; i < ARRAY_COUNT(this->unk_294); i++) { - Math_ApproachF(&this->unk_294[i], 0.0f, 1.0f, 40.0f); - } - - if (this->timers[0] == 1) { - sCape->attachLeftArmTimer = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - } - - if (this->timers[0] == 0) { - Math_ApproachZeroF(&this->unk_284, 1.0f, 0.08f); - this->unk_28C = this->unk_284; - Math_ApproachZeroF(&this->unk_2D0, 1.0f, 10.0f); - Math_ApproachF(&this->unk_278.x, this->unk_1FC.x, 0.5f, 30.0f); - Math_ApproachF(&this->unk_278.y, this->unk_1FC.y, 0.5f, 30.0f); - Math_ApproachF(&this->unk_278.z, this->unk_1FC.z, 0.5f, 30.0f); - } - - if (this->timers[1] == 0) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicThrowAnim); - Animation_MorphToLoop(&this->skelAnime, &gDorfBigMagicThrowAnim, 0.0f); - this->unk_1C2 = 4; - this->unk_288 = 0.0f; - this->unk_290 = 0.0f; - this->unk_284 = 0.0f; - this->unk_28C = 0.0f; - } - break; - - case 4: - this->envLightMode = 2; - - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - for (i = 0; i < 5; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_GANON, this->unk_1FC.x, - this->unk_1FC.y, this->unk_1FC.z, 0, this->actor.yawTowardsPlayer, 0, 0x104 + i); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BIGMASIC); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_THROW_BIG); - } - - if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - sCape->attachShouldersTimer = 26.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicThrowEndAnim); - Animation_MorphToLoop(&this->skelAnime, &gDorfBigMagicThrowEndAnim, 0.0f); - this->unk_1C2 = 5; - } - break; - - case 5: - this->envLightMode = 2; - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - BossGanon_SetupWait(this, globalCtx); - } - break; - } -} - -void BossGanon_SetupWait(BossGanon* this, GlobalContext* globalCtx) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - Animation_MorphToLoop(&this->skelAnime, &gDorfFloatAnim, -10.0f); - this->actionFunc = BossGanon_Wait; - this->fwork[GDF_FWORK_0] = 0.0f; - this->timers[0] = (s16)Rand_ZeroFloat(64.0f) + 30; - this->unk_1C2 = 0; - sCape->minY = 2.0f; -} - -void BossGanon_Wait(BossGanon* this, GlobalContext* globalCtx) { - f32 sin; - s32 pad; - f32 cos; - Player* player = GET_PLAYER(globalCtx); - - this->legSwayEnabled = true; - - sCape->backPush = -3.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -3.0f; - sCape->minDist = 20.0f; - - SkelAnime_Update(&this->skelAnime); - - if ((this->unk_1C2 == 0) && !(player->actor.world.pos.y < 0.0f)) { - if (!(player->stateFlags1 & 0x2000) && (fabsf(player->actor.world.pos.x) < 110.0f) && - (fabsf(player->actor.world.pos.z) < 110.0f)) { - BossGanon_SetupPoundFloor(this, globalCtx); - } else if ((this->timers[0] == 0) && !(player->stateFlags1 & 0x2000)) { - this->timers[0] = (s16)Rand_ZeroFloat(30.0f) + 30; - - if ((s8)this->actor.colChkInfo.health >= 20) { - BossGanon_SetupChargeLightBall(this, globalCtx); - } else if (Rand_ZeroOne() >= 0.5f) { - if ((Rand_ZeroOne() >= 0.5f) || (this->actor.xzDistToPlayer > 350.0f)) { - BossGanon_SetupChargeBigMagic(this, globalCtx); - } else { - BossGanon_SetupPoundFloor(this, globalCtx); - } - } else { - BossGanon_SetupChargeLightBall(this, globalCtx); - } - } - } - - sin = Math_SinS(this->unk_1A2 * 1280) * 100.0f; - cos = Math_CosS(this->unk_1A2 * 1792) * 100.0f; - - Math_ApproachF(&this->actor.world.pos.x, sin, 0.05f, this->fwork[GDF_FWORK_0]); - Math_ApproachF(&this->actor.world.pos.y, 150.0f, 0.05f, this->fwork[GDF_FWORK_0] * 0.2f); - Math_ApproachF(&this->actor.world.pos.z, cos, 0.05f, this->fwork[GDF_FWORK_0]); - Math_ApproachF(&this->fwork[GDF_FWORK_0], 50.0f, 1.0f, 0.5f); - - this->actor.velocity.x = this->actor.world.pos.x - this->actor.prevPos.x; - this->actor.velocity.z = this->actor.world.pos.z - this->actor.prevPos.z; - - sin = Math_SinS(this->unk_1A2 * 1500); - this->actor.velocity.y = this->fwork[GDF_FWORK_0] * sin * 0.04f; - this->actor.world.pos.y += this->actor.velocity.y; - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0xBB8); - func_80078914(&this->actor.projectedPos, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); -} - -void BossGanon_SetupChargeLightBall(BossGanon* this, GlobalContext* globalCtx) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfChargeLightBallAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfChargeLightBallAnim, -3.0f); - this->actionFunc = BossGanon_ChargeLightBall; - this->timers[0] = 25; -} - -void BossGanon_ChargeLightBall(BossGanon* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - sCape->backPush = -3.0f; - sCape->backSwayMagnitude = 1.25f; - sCape->sideSwayMagnitude = -2.0f; - sCape->minDist = 10.0f; - - if (this->timers[0] < 17) { - this->envLightMode = 1; - } - - if (this->timers[0] == 17) { - this->unk_26C = 10; - this->unk_270 = Rand_ZeroFloat(M_PI); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_SPARK); - } - - if (this->timers[0] < 10) { - this->unk_258 += (Rand_ZeroFloat(M_PI / 2) + (M_PI / 2)); - Math_ApproachF(&this->handLightBallScale, 10.0f, 0.5f, 1.25f); - - if (this->timers[0] == 0) { - BossGanon_SetupPlayTennis(this, globalCtx); - } - } - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x7D0); - - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; - - Math_ApproachZeroF(&this->actor.velocity.x, 1.0f, 0.5f); - Math_ApproachZeroF(&this->actor.velocity.z, 1.0f, 0.5f); - - this->actor.velocity.y = Math_SinS(this->unk_1A2 * 1500) * 2.0f; - this->actor.world.pos.y += this->actor.velocity.y; -} - -void BossGanon_SetupPlayTennis(BossGanon* this, GlobalContext* globalCtx) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfThrowAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfThrowAnim, 0.0f); - this->actionFunc = BossGanon_PlayTennis; -} - -void BossGanon_PlayTennis(BossGanon* this, GlobalContext* globalCtx) { - static AnimationHeader* volleyAnims[] = { &gDorfVolleyLeftAnim, &gDorfVolleyRightAnim }; - static s16 capeRightArmDurations[] = { 26, 20 }; - s16 rand; - - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->handLightBallScale, 1.0f, 0.2f); - - switch (this->unk_1C2) { - case 0: - this->envLightMode = 1; - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->unk_1C2 = 1; - Animation_MorphToLoop(&this->skelAnime, &gDorfFloatAnim, 0.0f); - } - - if (this->skelAnime.curFrame <= 12.0f) { - this->lensFlareTimer = 2; - this->lensFlareMode = 2; - gCustomLensFlarePos = this->unk_260; - } - - if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - this->handLightBallScale = 0.0f; - } - - if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - this->unk_25C = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_THROW); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_THROW_MASIC); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_GANON, this->unk_260.x, - this->unk_260.y, this->unk_260.z, 0, 0, 0, 0x64); - } - break; - - case 1: - if (this->startVolley) { - rand = Rand_ZeroOne() * 1.99f; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(volleyAnims[rand]); - Animation_MorphToPlayOnce(&this->skelAnime, volleyAnims[rand], 0.0f); - sCape->attachRightArmTimer = capeRightArmDurations[rand]; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - this->startVolley = false; - } - break; - } - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x7D0); - - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; - - Math_SmoothStepToF(&this->actor.velocity.x, 0.0f, 1.0f, 0.5f, 0.0f); - Math_SmoothStepToF(&this->actor.velocity.z, 0.0f, 1.0f, 0.5f, 0.0f); - - this->actor.velocity.y = Math_SinS(this->unk_1A2 * 1500) * 2.0f; - this->actor.world.pos.y += this->actor.velocity.y; -} - -void BossGanon_SetupBlock(BossGanon* this, GlobalContext* globalCtx) { - if ((this->actionFunc != BossGanon_Block) || (this->unk_1C2 != 0)) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBlockAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBlockAnim, 0.0f); - this->actionFunc = BossGanon_Block; - } - - this->unk_1C2 = 0; - sCape->attachLeftArmTimer = this->timers[0] = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - this->handLightBallScale = 0.0f; -} - -void BossGanon_Block(BossGanon* this, GlobalContext* globalCtx) { - this->collider.base.colType = 9; - SkelAnime_Update(&this->skelAnime); - sCape->backPush = -9.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -2.0f; - sCape->minDist = 13.0f; - - if (this->unk_1C2 == 0) { - if (this->timers[0] == 0) { - this->unk_1C2 = 1; - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBlockReleaseAnim, 0.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBlockReleaseAnim); - SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - } - } else { - sCape->sideSwayMagnitude = -13.0f; - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - BossGanon_SetupWait(this, globalCtx); - } - } - - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.world.pos.z += this->actor.velocity.z; - - Math_ApproachZeroF(&this->actor.velocity.x, 1.0f, 0.5f); - Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 0.5f); - Math_ApproachZeroF(&this->actor.velocity.z, 1.0f, 0.5f); -} - -void BossGanon_SetupHitByLightBall(BossGanon* this, GlobalContext* globalCtx) { - s16 i; - - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicHitAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBigMagicHitAnim, 0); - this->timers[0] = 70; - sCape->attachRightArmTimer = sCape->attachLeftArmTimer = 0; - - for (i = 1; i < 15; i++) { - this->unk_4E4[i] = D_808E4C58[i]; - } - - this->unk_2E6 = 80; - this->unk_2E8 = 0; - this->actionFunc = BossGanon_HitByLightBall; - this->actor.velocity.x = this->actor.velocity.z = 0.0f; - this->unk_1C2 = 0; - this->unk_1A6 = 15; - this->unk_508 = 6.0f; -} - -void BossGanon_HitByLightBall(BossGanon* this, GlobalContext* globalCtx) { - s16 i; - Vec3f sp50; - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_1C2 == 0) { - BossGanonEff_SpawnShock(globalCtx, 1500.0f, GDF_SHOCK_DORF_YELLOW); - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightArrowWaitAnim); - Animation_MorphToLoop(&this->skelAnime, &gDorfLightArrowWaitAnim, 0.0f); - this->unk_1C2 = 1; - } - } else if (this->unk_1C2 == 1) { - BossGanonEff_SpawnShock(globalCtx, 1000.0f, GDF_SHOCK_DORF_YELLOW); - - if (this->timers[0] == 0) { - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); - this->unk_1C2 = 2; - SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 18.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_RESTORE); - this->timers[2] = 130; - } - } else { - if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - for (i = 0; i < 100; i++) { - sp50.x = Rand_CenteredFloat(25.0f); - sp50.y = Rand_CenteredFloat(25.0f); - sp50.z = Rand_CenteredFloat(25.0f); - - BossGanonEff_SpawnSparkle(globalCtx, &this->unk_1FC, &sp50, &sZeroVec, Rand_ZeroFloat(200.0f) + 500.0f, - 0x14); - } - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER2); - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - BossGanon_SetupWait(this, globalCtx); - } - } - - this->actor.velocity.y = Math_SinS(this->unk_1A2 * 1500) * 2.0f; - this->actor.world.pos.y += this->actor.velocity.y; -} - -void BossGanon_SetupVulnerable(BossGanon* this, GlobalContext* globalCtx) { - s16 i; - - if (this->actionFunc != BossGanon_Vulnerable) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightArrowHitAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfLightArrowHitAnim, 0.0f); - sCape->attachRightArmTimer = sCape->attachLeftArmTimer = 0; - this->actionFunc = BossGanon_Vulnerable; - - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; - - this->unk_1C2 = 0; - sCape->backPush = -4.0f; - sCape->backSwayMagnitude = 0.75f; - sCape->sideSwayMagnitude = -3.0f; - sCape->minDist = 20.0f; - - for (i = 0; i < 10; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_GANON, this->unk_1FC.x, - this->unk_1FC.y, this->unk_1FC.z, Rand_CenteredFloat(0x8000), - (s16)Rand_CenteredFloat(0x8000) + this->actor.yawTowardsPlayer, 0, 0xC8 + i); - } - - this->unk_1A4 = 0; - this->unk_288 = 0.0f; - this->unk_290 = 0.0f; - this->unk_284 = 0.0f; - this->unk_28C = 0.0f; - } -} - -void BossGanon_Vulnerable(BossGanon* this, GlobalContext* globalCtx) { - s16 i; - Vec3f sp40; - - if (this->timers[3] == 0) { - this->actor.flags |= ACTOR_FLAG_0; - } - - SkelAnime_Update(&this->skelAnime); - - this->envLightMode = 1; - this->actor.world.pos.y += this->actor.velocity.y; - - if (this->unk_1A4 < 0x28) { - Math_ApproachF(&this->unk_508, 4.0f, 0.1f, 0.1f); - } - - if ((this->unk_1A4 >= 0x28) && (this->unk_1A4 < 0x37)) { - Math_ApproachF(&this->unk_508, 0.0f, 1.0f, 0.5f); - } - - if (this->unk_1A4 >= 0x37) { - Math_ApproachF(&this->unk_508, 5.0f, 0.1f, 0.15f); - this->shockGlow = true; - } - - switch (this->unk_1C2) { - case 0: - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->unk_1C2 = 1; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightEnergyHitAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfLightEnergyHitAnim, 0.0f); - } - break; - - case 1: - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->unk_1C2 = 2; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfKneelVulnerableAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfKneelVulnerableAnim, 0.0f); - } - break; - - case 2: - sCape->minDist = 0.0f; - this->actor.velocity.y = this->actor.velocity.y - 0.5f; - - if (this->actor.world.pos.y < 40.0f) { - this->actor.world.pos.y = 40.0f; - this->actor.velocity.y = 0.0f; - this->unk_1C2 = 3; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLandAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfLandAnim, 0.0f); - this->timers[0] = 70; - this->actor.flags |= ACTOR_FLAG_10; - } - break; - - case 3: - if (this->timers[0] == 68) { - this->unk_19F = 1; - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->unk_1C2 = 4; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfVulnerableAnim); - Animation_MorphToLoop(&this->skelAnime, &gDorfVulnerableAnim, 0.0f); - } - break; - - case 4: - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DOWN); - } - - if (this->timers[0] == 0) { - this->unk_1C2 = 5; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp1Anim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp1Anim, 0.0f); - this->unk_2D4 = 80; - - for (i = 1; i < 15; i++) { - this->unk_4E4[i] = Rand_ZeroFloat(10.0f); - } - - this->unk_2E6 = 80; - this->unk_2E8 = 0; - this->actor.flags &= ~ACTOR_FLAG_10; - } - break; - - case 5: - BossGanonEff_SpawnShock(globalCtx, 1000.0f, GDF_SHOCK_DORF_YELLOW); - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->unk_1C2 = 6; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp2Anim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp2Anim, 0.0f); - sCape->minDist = 20.0f; - this->unk_19F = 1; - } - break; - - case 6: - this->envLightMode = 0; - Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.1f, 1000.0f); - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->unk_1C2 = 7; - } - break; - - case 7: - this->envLightMode = 0; - Math_ApproachF(&this->actor.world.pos.y, 150.0f, 0.05f, 30.0f); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); - this->unk_1C2 = 8; - SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 18.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_RESTORE); - break; - - case 8: - this->envLightMode = 0; - - if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - for (i = 0; i < 100; i++) { - sp40.x = Rand_CenteredFloat(25.0f); - sp40.y = Rand_CenteredFloat(25.0f); - sp40.z = Rand_CenteredFloat(25.0f); - BossGanonEff_SpawnSparkle(globalCtx, &this->unk_1FC, &sp40, &sZeroVec, - Rand_ZeroFloat(200.0f) + 500.0f, 0x14); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER2); - this->timers[3] = 50; - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - BossGanon_SetupWait(this, globalCtx); - } - break; - } -} - -void BossGanon_SetupDamaged(BossGanon* this, GlobalContext* globalCtx) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfDamageAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gDorfDamageAnim, 0.0f); - this->actionFunc = BossGanon_Damaged; -} - -void BossGanon_Damaged(BossGanon* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_0; - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_1A4 >= 0x37) { - Math_ApproachF(&this->unk_508, 5.0f, 0.1f, 0.15f); - this->shockGlow = true; - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { - this->actionFunc = BossGanon_Vulnerable; - this->unk_1C2 = 4; - this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfVulnerableAnim); - Animation_MorphToLoop(&this->skelAnime, &gDorfVulnerableAnim, 0.0f); - } -} - -void BossGanon_UpdateDamage(BossGanon* this, GlobalContext* globalCtx) { - s16 i; - s16 j; - ColliderInfo* acHitInfo; - - if (this->collider.base.acFlags & 2) { - this->unk_2D4 = 2; - this->collider.base.acFlags &= ~2; - acHitInfo = this->collider.info.acHitInfo; - - if ((this->actionFunc == BossGanon_HitByLightBall) || (this->actionFunc == BossGanon_ChargeBigMagic)) { - if (acHitInfo->toucher.dmgFlags & 0x2000) { - BossGanon_SetupVulnerable(this, globalCtx); - this->timers[2] = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DAMAGE1); - this->unk_1A6 = 15; - } - } else if ((this->actionFunc == BossGanon_Vulnerable) && (this->unk_1C2 >= 3)) { - if (!(acHitInfo->toucher.dmgFlags & 0x80)) { - u8 hitWithSword = false; - u8 damage; - Vec3f sp50; - u32 flags; - - for (i = 0; i < 30; i++) { - sp50.x = Rand_CenteredFloat(20.0f); - sp50.y = Rand_CenteredFloat(20.0f); - sp50.z = Rand_CenteredFloat(20.0f); - BossGanonEff_SpawnSparkle(globalCtx, &this->unk_1FC, &sp50, &sZeroVec, - Rand_ZeroFloat(200.0f) + 500.0f, 0x1E); - } - - damage = flags = CollisionCheck_GetSwordDamage(acHitInfo->toucher.dmgFlags); - - if (flags == 0) { - damage = 2; - } else { - hitWithSword = true; - } - - if (((s8)this->actor.colChkInfo.health >= 3) || hitWithSword) { - this->actor.colChkInfo.health -= damage; - } - - for (i = 0; i < ARRAY_COUNT(sCape->strands); i++) { - for (j = 1; j < 12; j++) { - sCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); - sCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); - } - } - - if ((s8)this->actor.colChkInfo.health <= 0) { - BossGanon_SetupDeathCutscene(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DEAD); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DD_THUNDER); - func_80078914(&sZeroVec, NA_SE_EN_LAST_DAMAGE); - Audio_QueueSeqCmd(0x100100FF); - this->screenFlashTimer = 4; - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_DAMAGE2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_CUTBODY); - BossGanon_SetupDamaged(this, globalCtx); - this->unk_1A6 = 15; - sCape->tearTimer = 1; - } - } - } else if (acHitInfo->toucher.dmgFlags & 0x1F8A4) { - Audio_PlayActorSound2(&this->actor, 0); - - for (i = 0; i < ARRAY_COUNT(sCape->strands); i++) { - for (j = 1; j < 12; j++) { - sCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); - sCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); - } - } - } - } -} - -static f32 D_808E4D44[] = { - 1.0f, 3.0f, 0.0f, 7.0f, 13.0f, 4.0f, 6.0f, 11.0f, 5.0f, 2.0f, 8.0f, 14.0f, 10.0f, 12.0f, 9.0f, -}; - -void BossGanon_Update(Actor* thisx, GlobalContext* globalCtx2) { - BossGanon* this = (BossGanon*)thisx; - GlobalContext* globalCtx = globalCtx2; - f32 legRotX; - f32 legRotY; - f32 legRotZ; - Player* player = GET_PLAYER(globalCtx); - s16 i; - f32 sin; - f32 cos; - Vec3f shardPos; - Vec3f shardVel; - Vec3f spE8; - s16 i2; - s16 j; - Vec3f spD8; - Vec3f platformCheckPos; - Actor* explosive; - Vec3f spBC; - Vec3f spB0; - Vec3f platCheckPosBomb; - Actor* prop; - BgGanonOtyuka* platform; - f32 targetLensFlareScale; - f32 xOffset; - f32 zOffset; - - if ((this->actionFunc != BossGanon_IntroCutscene) && (this->actionFunc != BossGanon_DeathAndTowerCutscene)) { - BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); - } else { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animBankIndex].vromStart); - } - - if (this->windowShatterState != GDF_WINDOW_SHATTER_OFF) { - BossGanon_ShatterWindows(this->windowShatterState); - shardVel.y = 0.0f; - - for (i = 0; i < 10; i++) { - shardPos.y = Rand_ZeroFloat(240.0f) + 20.0f; - - if (Rand_ZeroOne() < 0.5f) { - shardPos.x = 463; - shardPos.z = Rand_ZeroFloat(463.0f); - - shardVel.x = Rand_ZeroFloat(2.0f); - shardVel.z = Rand_ZeroFloat(1.0f); - } else { - shardPos.z = 463; - shardPos.x = Rand_ZeroFloat(463.0f); - - shardVel.z = Rand_ZeroFloat(2.0f); - shardVel.x = Rand_ZeroFloat(1.0f); - } - - BossGanonEff_SpawnWindowShard(globalCtx, &shardPos, &shardVel, Rand_ZeroFloat(0.075f) + 0.08f); - } - } - - this->collider.base.colType = 3; - sCape->gravity = -3.0f; - this->shockGlow = false; - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_1A2++; - this->unk_1A4++; - - // block players attack if hes shooting something - if ((this->actionFunc == BossGanon_Wait) || (this->actionFunc == BossGanon_Block)) { - if (player->unk_A73 != 0) { - BossGanon_SetupBlock(this, globalCtx); - } - } - - this->actionFunc(this, globalCtx); - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - - if (this->unk_1A6 != 0) { - this->unk_1A6--; - } - - if (this->unk_2D4 != 0) { - this->unk_2D4--; - } - - if (this->unk_2E8 != 0) { - this->unk_2E8--; - } - - if (this->unk_2E6 != 0) { - this->unk_2E6--; - } - - if (this->unk_19C != 0) { - this->unk_19C--; - } - - if (this->csState == 0) { - BossGanon_UpdateDamage(this, globalCtx); - BossGanon_SetColliderPos(&this->unk_1FC, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->unk_2D4 == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if ((this->actionFunc != BossGanon_HitByLightBall) && (this->actionFunc != BossGanon_Vulnerable) && - (this->actionFunc != BossGanon_Damaged)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - } - - if (this->legSwayEnabled) { - sin = Math_SinS(-this->actor.shape.rot.y); - cos = Math_CosS(-this->actor.shape.rot.y); - - legRotX = ((this->actor.velocity.z * sin) + (cos * this->actor.velocity.x)) * 300.0f; - legRotY = ((-sin * this->actor.velocity.x) + (cos * this->actor.velocity.z)) * 300.0f; - legRotZ = (Math_SinS(this->unk_1A2 * 2268) * -500.0f) - 500.0f; - } else { - legRotY = legRotX = legRotZ = 0.0f; - } - - this->legSwayEnabled = false; - - Math_SmoothStepToF(&this->legRot.x, legRotX, 1.0f, 600.0f, 0.0f); - Math_SmoothStepToF(&this->legRot.y, legRotY, 1.0f, 600.0f, 0.0f); - Math_SmoothStepToF(&this->legRot.z, legRotZ, 1.0f, 100.0f, 0.0f); - - if (this->timers[2] == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_LAUGH); - } - - if (this->timers[2] == 100) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_ST_LAUGH); - this->timers[2] = 0; - } - - if ((this->unk_2E6 != 0) || (this->unk_2E8 != 0)) { - for (i = 1; i < ARRAY_COUNT(this->unk_49C); i++) { - if (this->unk_4E4[i] != 0) { - this->unk_4E4[i]--; - Math_ApproachF(&this->unk_49C[i], this->unk_508, 1.0f, 2.0f); - } else { - Math_ApproachZeroF(&this->unk_49C[i], 1.0f, 0.2f); - } - } - - // player hit, spawn shock and play sound - if (this->unk_2E8 != 0) { - func_80078914(&player->actor.projectedPos, NA_SE_PL_SPARK - SFX_FLAG); - BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_YELLOW); - } - } - - if (this->unk_19F != 0) { - this->unk_19F = 0; - spE8 = this->actor.world.pos; - spE8.y = 0.0f; - BossGanonEff_SpawnDustDark(globalCtx, &spE8, 0.2, 0.7f); - BossGanonEff_SpawnDustDark(globalCtx, &spE8, 0.3f, 0.8f); - } - - if (this->unk_26C != 0) { - this->unk_26C--; - - if (this->unk_26C == 0) { - BossGanonEff_SpawnLightning(globalCtx, 1.0f, 0.0f, 0.0f); - } - - BossGanonEff_SpawnLightning(globalCtx, 1.0f, D_808E4D44[this->unk_26C] * (M_PI / 5) + this->unk_270, - Rand_CenteredFloat(M_PI / 5) + (M_PI / 2)); - } - - // see if light ball hit and should knock platform down? - if ((this->unk_19C != 0) && (this->unk_19E < 4)) { - if ((this->unk_19A == 0) && (this->unk_19C == 20)) { - this->unk_19A = 1; - platformCheckPos.x = -180.0f; - platformCheckPos.y = 0.0f; - - for (i2 = 0; i2 < 4; i2++) { - for (j = 0, platformCheckPos.z = -180.0f; j < 4; j++) { - BossGanon_CheckFallingPlatforms(this, globalCtx, &platformCheckPos); - platformCheckPos.z += 120.0f; - } - - platformCheckPos.x += 120.0f; - } - } else if (this->unk_19C < 30) { - spD8.x = 0.0f; - spD8.y = 0.0f; - spD8.z = 15.0f * (30.0f - this->unk_19C); - - Matrix_RotateY(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); - Matrix_MultVec3f(&spD8, &platformCheckPos); - - this->unk_19E += BossGanon_CheckFallingPlatforms(this, globalCtx, &platformCheckPos); - } - } - - // see if a bomb exploded near a group of platforms and if they should fall - explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; - - while (explosive != NULL) { - if (explosive->params != BOMB_EXPLOSION) { - explosive = explosive->next; - } else { - for (i = 0; i < 8; i++) { - spBC.x = 0.0f; - spBC.y = 0.0f; - spBC.z = 60.0f; - - Matrix_RotateY(i * (M_PI / 4), MTXMODE_NEW); - Matrix_MultVec3f(&spBC, &spB0); - - platCheckPosBomb.x = explosive->world.pos.x + spB0.x; - platCheckPosBomb.y = explosive->world.pos.y; - platCheckPosBomb.z = explosive->world.pos.z + spB0.z; - - BossGanon_CheckFallingPlatforms(this, globalCtx, &platCheckPosBomb); - } - - explosive = explosive->next; - } - } - - BossGanon_UpdateEffects(globalCtx); - - prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - - // if a platform is lit up, change the room lighting - while (prop != NULL) { - if (prop->id != ACTOR_BG_GANON_OTYUKA) { - prop = prop->next; - } else { - platform = (BgGanonOtyuka*)prop; - - if (platform->flashState != 0) { - this->envLightMode = 1; - break; - } - - prop = prop->next; - } - } - - globalCtx->envCtx.unk_BF = 0; - globalCtx->envCtx.unk_BE = 0; - globalCtx->envCtx.unk_DC = 2; - - switch (this->envLightMode) { - case -1: - break; - case 0: - Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.0f, 1.0f, 0.02f); - break; - case 1: - globalCtx->envCtx.unk_BD = 1; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.1f); - break; - case 2: - globalCtx->envCtx.unk_BD = 1; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.02f); - break; - case 3: - globalCtx->envCtx.unk_BD = 3; - globalCtx->envCtx.unk_D8 = 1.0f; - break; - case 35: - globalCtx->envCtx.unk_BD = 0; - globalCtx->envCtx.unk_D8 = 1.0f; - break; - case 4: - globalCtx->envCtx.unk_BD = 4; - globalCtx->envCtx.unk_D8 = 1.0f; - break; - case 5: - globalCtx->envCtx.unk_BE = 5; - globalCtx->envCtx.unk_BD = 3; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.075f); - break; - case 6: - globalCtx->envCtx.unk_BE = 5; - globalCtx->envCtx.unk_D8 = 0.0f; - break; - case 65: - globalCtx->envCtx.unk_BE = 3; - globalCtx->envCtx.unk_BD = 6; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - break; - case 7: - globalCtx->envCtx.unk_BE = 7; - globalCtx->envCtx.unk_D8 = 0.0f; - break; - case 75: - globalCtx->envCtx.unk_BE = 4; - globalCtx->envCtx.unk_BD = 8; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - break; - case 8: - globalCtx->envCtx.unk_BE = 3; - globalCtx->envCtx.unk_BD = 9; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); - break; - case 9: - globalCtx->envCtx.unk_BE = 3; - globalCtx->envCtx.unk_BD = 0xA; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - break; - case 10: - globalCtx->envCtx.unk_BE = 3; - globalCtx->envCtx.unk_BD = 0xB; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); - this->unk_1A4 = 0; - break; - case 11: - globalCtx->envCtx.unk_BE = 0xC; - globalCtx->envCtx.unk_BD = 0xB; - Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_CosS(this->unk_1A4 * 0x1800) * 0.5f) + 0.5f, 1.0f, 1.0f); - break; - case 12: - globalCtx->envCtx.unk_BE = 0xC; - globalCtx->envCtx.unk_BD = 3; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); - break; - case 13: - globalCtx->envCtx.unk_BD = 0xD; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.025f); - break; - case 14: - globalCtx->envCtx.unk_BD = 0xE; - globalCtx->envCtx.unk_D8 = 1.0f; - break; - case 15: - globalCtx->envCtx.unk_BE = 0xE; - globalCtx->envCtx.unk_BD = 0xF; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.01f); - break; - case 16: - globalCtx->envCtx.unk_BE = 0x10; - globalCtx->envCtx.unk_BD = 0xF; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - break; - case 20: - globalCtx->envCtx.unk_BE = 2; - globalCtx->envCtx.unk_BD = 1; - break; - default: - break; - } - - this->envLightMode = 0; - - if (this->whiteFillAlpha != 0) { - globalCtx->envCtx.screenFillColor[3] = (s8)(u8)this->whiteFillAlpha; - globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = - globalCtx->envCtx.screenFillColor[2] = 255; - globalCtx->envCtx.fillScreen = true; - } else if (this->screenFlashTimer != 0) { - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = - globalCtx->envCtx.screenFillColor[2] = 255; - - globalCtx->envCtx.screenFillColor[3] = ((this->screenFlashTimer % 2) != 0) ? 100 : 0; - - this->screenFlashTimer--; - } else { - globalCtx->envCtx.fillScreen = globalCtx->envCtx.screenFillColor[3] = 0; - } - - if (this->lensFlareTimer != 0) { - this->lensFlareTimer--; - - if (this->lensFlareMode == 1) { - targetLensFlareScale = 40.0f; - } else if (this->lensFlareMode == 4) { - targetLensFlareScale = 25.0f; - } else { - targetLensFlareScale = 10.0f; - } - - Math_ApproachF(&this->lensFlareScale, targetLensFlareScale, 0.3f, 10.0f); - } else { - Math_ApproachZeroF(&this->lensFlareScale, 1.0f, 5.0f); - - if (this->lensFlareScale == 0.0f) { - this->lensFlareMode = 0; - } - } - - if (this->lensFlareMode != 0) { - gCustomLensFlareOn = true; - - if (this->lensFlareMode == 1) { - gCustomLensFlarePos = this->actor.world.pos; - } - - gLensFlareScale = this->lensFlareScale; - gLensFlareColorIntensity = 10.0f; - gLensFlareScreenFillAlpha = 0; - } else { - gCustomLensFlareOn = false; - } - - if (this->unk_274 != 0) { - i = this->unk_274 - 1; - - this->unk_278.x = this->unk_2EC[0].x; - this->unk_278.y = this->unk_2EC[0].y + 50.0f + 30.0f; - this->unk_278.z = this->unk_2EC[0].z; - - xOffset = (sinf(i * 1.2566371f) * 600.0f); - zOffset = (cosf(i * 1.2566371f) * 600.0f); - - // 5 or 6 light balls that go into the charge. not the same as the ones that he throws - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_GANON, this->unk_1FC.x + xOffset, - this->unk_1FC.y, this->unk_1FC.z + zOffset, 0, (s16)(i * 13107.2f) + 0x6000, 0, 0xFA + i); - this->unk_274 = 0; - } -} - -s32 BossGanon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossGanon* this = (BossGanon*)thisx; - - switch (limbIndex) { - case 10: - if (this->useOpenHand) { - *dList = gDorfOpenHandDL; - } - break; - - case 20: - rot->y += this->legRot.x + this->legRot.z; - rot->z += this->legRot.y; - break; - - case 21: - if (this->legRot.y > 0.0f) { - rot->z += this->legRot.y; - } - break; - - case 22: - rot->y += this->legRot.x + this->legRot.z; - rot->z += this->legRot.y; - break; - - case 23: - rot->y += this->legRot.x - this->legRot.z; - rot->z += this->legRot.y; - break; - - case 24: - if (this->legRot.y > 0.0f) { - rot->z += this->legRot.y; - } - break; - - case 25: - rot->y += this->legRot.x - this->legRot.z; - rot->z += this->legRot.y; - break; - - default: - break; - } - - return 0; -} - -void BossGanon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static s8 bodyPartLimbMap[] = { - -1, -1, 1, -1, 3, 4, 5, -1, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, 2, 12, 13, 14, 9, 10, 11, -1, -1, -1, -1, - }; - static Vec3f D_808E4DA0 = { -500.0f, 200.0f, -300.0f }; - static Vec3f D_808E4DAC = { -500.0f, 200.0f, 300.0f }; - static Vec3f D_808E4DB8 = { 0.0f, 0.0f, 0.0f }; - static Vec3f D_808E4DC4 = { 0.0f, 0.0f, 0.0f }; - static Vec3f D_808E4DD0 = { 0.0f, 0.0f, 0.0f }; - static Vec3f D_808E4DDC = { 1300.0f, 0.0f, 0.0f }; - static Vec3f D_808E4DE8 = { 600.0f, 420.0f, 100.0f }; - s8 bodyPart; - BossGanon* this = (BossGanon*)thisx; - - bodyPart = bodyPartLimbMap[limbIndex]; - if (bodyPart >= 0) { - Matrix_MultVec3f(&D_808E4DB8, &this->unk_2EC[bodyPart]); - } - - if (limbIndex == 2) { - Matrix_MultVec3f(&D_808E4DB8, &this->unk_1FC); - } else if (limbIndex == 19) { - Matrix_MultVec3f(&D_808E4DB8, &this->actor.focus.pos); - } else if (limbIndex == 11) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7191); - - Matrix_MultVec3f(&D_808E4DB8, &this->unk_208); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7196), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_ganon_DL_00BE90)); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7198); - } else if (limbIndex == 6) { - Matrix_MultVec3f(&D_808E4DC4, &this->unk_238); - } else if (limbIndex == 10) { - Matrix_MultVec3f(&D_808E4DD0, &this->unk_22C); - - if (this->unk_25C == 0) { - Matrix_MultVec3f(&D_808E4DDC, &this->unk_260); - } - - this->unk_25C = 0; - - if (this->triforceType == GDF_TRIFORCE_DORF) { - Matrix_MultVec3f(&D_808E4DE8, &this->triforcePos); - } - } else if (limbIndex == 4) { - Vec3f sp28 = D_808E4DA0; - - if (this->unk_198 == 1) { - sp28.x += -300.0f; - sp28.y += -300.0f; - sp28.z += 700.0f; - } else if (this->unk_198 == 2) { - sp28.x += -300.0f; - sp28.z += 700.0f; - } - - Matrix_MultVec3f(&sp28, &this->unk_220); - } else if (limbIndex == 8) { - Vec3f sp1C = D_808E4DAC; - - if (this->unk_198 == 1) { - sp1C.x += -300.0f; - sp1C.y += -300.0f; - sp1C.z += -700.0f; - } else if (this->unk_198 == 2) { - sp1C.x += -300.0f; - sp1C.y += 100.0f; - sp1C.z += -700.0f; - } - - Matrix_MultVec3f(&sp1C, &this->unk_214); - } -} - -void BossGanon_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { - sSeed1 = seedInit0; - sSeed2 = seedInit1; - sSeed3 = seedInit2; -} - -f32 BossGanon_RandZeroOne(void) { - // Wichmann-Hill algorithm - f32 randFloat; - - sSeed1 = (sSeed1 * 171) % 30269; - sSeed2 = (sSeed2 * 172) % 30307; - sSeed3 = (sSeed3 * 170) % 30323; - - randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); - - while (randFloat >= 1.0f) { - randFloat -= 1.0f; - } - - return fabsf(randFloat); -} - -void BossGanon_DrawShock(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s16 i; - - OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 7350); - - if ((this->unk_2E8 != 0) || (this->unk_2E6 != 0)) { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - - if (this->unk_2E8 != 0) { - Player* player = GET_PLAYER(globalCtx); - - for (i = 0; i < ARRAY_COUNT(player->bodyPartsPos); i++) { - Matrix_Translate(player->bodyPartsPos[i].x, player->bodyPartsPos[i].y, player->bodyPartsPos[i].z, - MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_49C[i], this->unk_49C[i], this->unk_49C[i], MTXMODE_APPLY); - Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7384), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - } - } else { - for (i = 1; i < 15; i++) { - Matrix_Translate(this->unk_2EC[i].x, this->unk_2EC[i].y, this->unk_2EC[i].z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_49C[i], this->unk_49C[i], this->unk_49C[i], MTXMODE_APPLY); - - if (!this->shockGlow) { - Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); - } - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7401), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (this->shockGlow) { - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - (this->unk_1A2 + i) * -15, 32, 64)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 255, 170, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); - gSPDisplayList(POLY_XLU_DISP++, gDorfShockGlowDL); - } else { - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - } - } - } - } - - CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 7465); -} - -void BossGanon_DrawHandLightBall(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 alpha; - - OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 7476); - - if (this->handLightBallScale > 0.0f) { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - - if ((this->unk_1A2 % 2) != 0) { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 100, 255, 0, 0); - } - - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - - Matrix_Translate(this->unk_260.x, this->unk_260.y, this->unk_260.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->handLightBallScale, this->handLightBallScale, this->handLightBallScale, MTXMODE_APPLY); - Matrix_RotateZ(this->unk_258, 1); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7510), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - - alpha = ((this->unk_1A2 % 2) != 0) ? 100 : 80; - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, alpha); - Matrix_Translate(this->unk_260.x, 0.0f, this->unk_260.z, MTXMODE_NEW); - Matrix_Scale(this->handLightBallScale * 0.75f, 1.0f, this->handLightBallScale * 0.75f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7531), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightCoreDL); - - CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 7534); - } -} - -void BossGanon_DrawBigMagicCharge(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - f32 yRot; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s16 i; - - OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 7548); - - if (this->unk_284 > 0.0f) { - func_80093D84(globalCtx->state.gfxCtx); - - // light flecks - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s8)this->unk_290); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 128); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_1A2 * -2, 0, 0x40, 0x40, 1, 0, - this->unk_1A2 * 0xA, 0x40, 0x40)); - Matrix_Translate(this->unk_278.x, this->unk_278.y, this->unk_278.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_28C, this->unk_28C, this->unk_28C, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7588), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightFlecksDL); - - // background circle texture - Matrix_Translate(this->unk_278.x, this->unk_278.y, this->unk_278.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_284, this->unk_284, this->unk_284, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7601), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 100, (s8)this->unk_288); - gSPSegment( - POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, 0, this->unk_1A2 * -4, 0x20, 0x20)); - gSPDisplayList(POLY_XLU_DISP++, gDorfBigMagicBGCircleDL); - - // yellow background dot - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 170, 0, (s8)this->unk_288); - gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_1A2 * 2, - this->unk_1A2 * -0x14, 0x40, 0x40)); - gSPDisplayList(POLY_XLU_DISP++, gDorfDotDL); - - // light ball material - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 0); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - - // light ball geometry - Matrix_Translate(this->unk_278.x, this->unk_278.y, this->unk_278.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_2D0, this->unk_2D0, this->unk_2D0, MTXMODE_APPLY); - Matrix_RotateZ((this->unk_1A2 * 10.0f) / 1000.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7673), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - - BossGanon_InitRand(this->unk_1AA + 1, 0x71AC, 0x263A); - Matrix_Translate(this->unk_278.x, this->unk_278.y, this->unk_278.z, MTXMODE_NEW); - Matrix_RotateY((this->unk_1A2 * 10.0f) / 1000.0f, MTXMODE_APPLY); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); - - yRot = BINANG_TO_RAD(this->actor.yawTowardsPlayer); - - for (i = 0; i < this->unk_1AC; i++) { - f32 xzRot = (BossGanon_RandZeroOne() - 0.5f) * M_PI * 1.5f; - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_294[i]); - Matrix_Push(); - Matrix_RotateY(xzRot + yRot, MTXMODE_APPLY); - Matrix_RotateX((BossGanon_RandZeroOne() - 0.5f) * M_PI, MTXMODE_APPLY); - Matrix_RotateZ(xzRot, MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, 50.0f, MTXMODE_APPLY); - Matrix_Scale(4.0f, 4.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7713), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightRayTriDL); - - Matrix_Pop(); - } - - CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 7721); - } -} - -void BossGanon_DrawTriforce(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - - if (this->fwork[GDF_TRIFORCE_PRIM_A] > 0.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7732); - - Matrix_Push(); - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)this->fwork[GDF_TRIFORCE_PRIM_B], - (s8)this->fwork[GDF_TRIFORCE_PRIM_A]); - gDPSetEnvColor(POLY_XLU_DISP++, 255, (u8)this->fwork[GDF_TRIFORCE_ENV_G], 0, 128); - - if (this->triforceType == GDF_TRIFORCE_PLAYER) { - Player* player = GET_PLAYER(globalCtx); - - this->triforcePos = player->bodyPartsPos[12]; - - this->triforcePos.x += -0.6f; - this->triforcePos.y += 3.0f; - this->triforcePos.z += -2.0f; - } else if (this->triforceType == GDF_TRIFORCE_ZELDA) { - this->triforcePos = sZelda->unk_31C; - - this->triforcePos.y += 1.8f; - this->triforcePos.z += 4.0f; - } - - Matrix_Translate(this->triforcePos.x, this->triforcePos.y, this->triforcePos.z, MTXMODE_NEW); - - if (this->triforceType == GDF_TRIFORCE_PLAYER) { - Matrix_RotateX(-1.4f, MTXMODE_APPLY); - Matrix_RotateZ(4.0f, MTXMODE_APPLY); - } else if (this->triforceType == GDF_TRIFORCE_ZELDA) { - Matrix_RotateY(1.5f, 1); - Matrix_RotateX(1.1f, 1); - Matrix_RotateZ(-0.99999994f, MTXMODE_APPLY); - } else { - func_800D1FD4(&globalCtx->billboardMtxF); - } - - Matrix_Scale(this->fwork[GDF_TRIFORCE_SCALE], this->fwork[GDF_TRIFORCE_SCALE], 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7779), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gDorfTriforceDL)); - - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7782); - } -} - -void BossGanon_DrawDarkVortex(BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - - if (this->fwork[GDF_VORTEX_ALPHA] > 0.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7792); - - Matrix_Push(); - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_1A2 * -8, 0, 0x20, 0x40, 1, - this->unk_1A2 * -4, this->unk_1A2 * -8, 0x20, 0x20)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 0, 200, (s8)this->fwork[GDF_VORTEX_ALPHA]); - gDPSetEnvColor(POLY_XLU_DISP++, 130, 0, 0, 128); - - if (this->csState != 21) { - Matrix_Translate(0.0f, 105.0f, -400.0f, MTXMODE_NEW); - Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); - } else { - Matrix_Translate(-50.0f, 50.0f, -150.0f, MTXMODE_NEW); - Matrix_RotateY(M_PI / 10, MTXMODE_APPLY); - Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); - } - - Matrix_Scale(this->fwork[GDF_VORTEX_SCALE], this->fwork[GDF_VORTEX_SCALE], this->fwork[GDF_VORTEX_SCALE], - MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7841), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gDorfVortexDL)); - - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7844); - } -} - -void func_808E0254(BossGanon* this, u8* tex, f32 arg2) { - static s16 D_808E4DF4[] = { 1, 2, 3, 3, 2, 1 }; - static s16 D_808E4E00[] = { 2, 3, 4, 4, 4, 3, 2 }; - static s16 D_808E4E10[] = { 2, 3, 4, 4, 4, 4, 3, 2 }; - static s16 D_808E4E20[] = { 2, 4, 5, 5, 6, 6, 6, 6, 5, 5, 4, 2 }; - static s16 D_808E4E38[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 10, 2, 12, 13 }; - static u8 D_808E4E58[] = { 3, 2, 2, 1, 3, 3, 1, 3, 3, 1, 0, 3, 1, 0, 3 }; - s16 baseX; - s16 index; - s16 i; - s16 baseY; - s16 x; - s16 addY; - f32 lerpX; - s16 y; - f32 lerpY; - f32 lerpZ; - Vec3f sp68; - Vec3f sp5C; - - for (i = 0; i < 15; i++) { - if (arg2 == 0.0f || (y = D_808E4E38[i]) >= 0) { - if (arg2 > 0.0f) { - lerpX = this->unk_2EC[i].x + (this->unk_2EC[y].x - this->unk_2EC[i].x) * arg2; - lerpY = this->unk_2EC[i].y + (this->unk_2EC[y].y - this->unk_2EC[i].y) * arg2; - lerpZ = this->unk_2EC[i].z + (this->unk_2EC[y].z - this->unk_2EC[i].z) * arg2; - - sp68.x = lerpX - this->actor.world.pos.x; - sp68.y = lerpY - this->actor.world.pos.y + 76 + 30 + 30; - sp68.z = lerpZ - this->actor.world.pos.z; - } else { - - sp68.x = this->unk_2EC[i].x - this->actor.world.pos.x; - sp68.y = this->unk_2EC[i].y - this->actor.world.pos.y + 76 + 30 + 30; - sp68.z = this->unk_2EC[i].z - this->actor.world.pos.z; - } - Matrix_MultVec3f(&sp68, &sp5C); - - sp5C.x *= 0.4f; - sp5C.y *= 0.4f; - - baseX = (s16)(sp5C.x + 32.0f); - baseY = (s16)sp5C.y * 64; - - if (D_808E4E58[i] == 2) { - for (y = 0, addY = -0x180; y < 12; y++, addY += 0x40) { - for (x = -D_808E4E20[y]; x < D_808E4E20[y]; x++) { - index = baseX + x + baseY + addY; - if ((index >= 0) && (index < 0x1000)) { - tex[index] = 255; - } - } - } - } else if (D_808E4E58[i] == 1) { - for (y = 0, addY = -0x100; y < 8; y++, addY += 0x40) { - for (x = -D_808E4E10[y]; x < D_808E4E10[y]; x++) { - index = baseX + x + baseY + addY; - if ((index >= 0) && (index < 0x1000)) { - tex[index] = 255; - } - } - } - } else if (D_808E4E58[i] == 0) { - for (y = 0, addY = -0xC0; y < 7; y++, addY += 0x40) { - for (x = -D_808E4E00[y]; x < D_808E4E00[y] - 1; x++) { - index = baseX + x + baseY + addY; - if ((index >= 0) && (index < 0x1000)) { - tex[index] = 255; - } - } - } - } else { - for (y = 0, addY = -0x80; y < 6; y++, addY += 0x40) { - for (x = -D_808E4DF4[y]; x < D_808E4DF4[y] - 1; x++) { - index = baseX + x + baseY + addY; - if ((index >= 0) && (index < 0x1000)) { - tex[index] = 255; - } - } - } - } - } - } -} - -void BossGanon_GenShadowTexture(u8* tex, BossGanon* this, GlobalContext* globalCtx) { - s16 addY; - s16 baseX; - s16 baseY; - s16 i; - s16 j; - s16 y; - s16 x; - s16 index; - Vec3f sp7C; - Vec3f sp70; - s32* ptr = (s32*)tex; - - for (i = 0; i < 64 * 64 / 4; i++, ptr++) { - *ptr = 0; - } - - Matrix_RotateX(1.0f, MTXMODE_NEW); - - for (i = 0; i <= 5; i++) { - func_808E0254(this, tex, i / 5.0f); - } - - for (i = 0; i < 12; i++) { - for (j = 0; j < 12; j++) { - sp7C.x = sCape->strands[i].joints[j].x - this->actor.world.pos.x; - sp7C.y = sCape->strands[i].joints[j].y - this->actor.world.pos.y + 76.0f + 100.0f + 30.0f; - sp7C.z = sCape->strands[i].joints[j].z - this->actor.world.pos.z; - - Matrix_MultVec3f(&sp7C, &sp70); - - sp70.x = sp70.x * 0.28f; - sp70.y = sp70.y * 0.28f; - - baseX = (s32)(sp70.x + 32.0f); - baseY = (s16)sp70.y * 0x40; - - if (!sCape->strands[i].torn[j]) { - for (y = -1, addY = -0x40; y <= 1; y++, addY += 0x40) { - for (x = -3; x <= 3; x++) { - index = baseX + x + baseY + addY; - if (0 <= index && index < 0x1000) { - tex[index] = 255; - } - } - } - } else { - for (y = -1, addY = -0x40; y <= 1; y++, addY += 0x40) { - for (x = -1; x <= 1; x++) { - index = baseX + x + baseY + addY; - if (0 <= index && index < 0x1000) { - tex[index] = 255; - } - } - } - } - } - } -} - -void BossGanon_DrawShadowTexture(void* tex, BossGanon* this, GlobalContext* globalCtx) { - s32 pad; - f32 zOffset; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 8372); - - func_80093D18(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 50); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - if (this->csState < 100) { - zOffset = (((((this->actor.world.pos.y - 10) + 70.0f) * -5.0f) / 10.0f) + 10.0f); - Matrix_Translate(this->actor.world.pos.x, 0.0f, this->actor.world.pos.z + zOffset, MTXMODE_NEW); - } else { - Matrix_Translate(this->actor.world.pos.x, 4102.0f, this->actor.world.pos.z - 20.0f, MTXMODE_NEW); - } - - Matrix_Scale(0.95000005f, 1.0f, 0.95000005f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 8396), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDorfShadowSetupDL); - gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); - gSPDisplayList(POLY_OPA_DISP++, gDorfShadowModelDL); - - CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 8426); -} - -void BossGanon_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 i; - BossGanon* this = (BossGanon*)thisx; - void* shadowTex; - - shadowTex = Graph_Alloc(globalCtx->state.gfxCtx, 64 * 64); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9138); - - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - - if ((this->unk_1A6 & 2) != 0) { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099); - } - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDorfEyeTex)); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - BossGanon_OverrideLimbDraw, BossGanon_PostLimbDraw, &this->actor); - - this->unk_2EC[0].x = this->unk_2EC[1].x; - this->unk_2EC[0].y = this->unk_2EC[1].y + 30.0f; - this->unk_2EC[0].z = this->unk_2EC[1].z; - - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - - BossGanon_DrawEffects(globalCtx); - - sCape->actor.world.pos = this->actor.world.pos; - - sCape->rightForearmPos = this->unk_214; - sCape->leftForearmPos = this->unk_220; - - sCape->rightShoulderPos = this->unk_22C; - sCape->leftShoulderPos = this->unk_238; - - BossGanon_DrawShock(this, globalCtx); - BossGanon_DrawHandLightBall(this, globalCtx); - BossGanon_DrawBigMagicCharge(this, globalCtx); - BossGanon_DrawTriforce(this, globalCtx); - BossGanon_DrawDarkVortex(this, globalCtx); - - BossGanon_GenShadowTexture(shadowTex, this, globalCtx); - BossGanon_DrawShadowTexture(shadowTex, this, globalCtx); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9393); -} - -s32 BossGanon_CheckFallingPlatforms(BossGanon* this, GlobalContext* globalCtx, Vec3f* checkPos) { - Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - - while (prop != NULL) { - if (((BossGanon*)prop == this) || (prop->id != ACTOR_BG_GANON_OTYUKA)) { - prop = prop->next; - } else { - BgGanonOtyuka* platform = (BgGanonOtyuka*)prop; - f32 xDiff = platform->dyna.actor.world.pos.x - checkPos->x; - f32 yDiff = platform->dyna.actor.world.pos.y - checkPos->y; - f32 zDiff = platform->dyna.actor.world.pos.z - checkPos->z; - - if ((fabsf(xDiff) < 60.0f) && (yDiff < 20.0f) && (yDiff > -20.0f) && (fabsf(zDiff) < 60.0f)) { - platform->isFalling = true; - platform->visibleSides = OTYUKA_SIDE_ALL; - - return 1; - } else { - prop = prop->next; - } - } - } - - return 0; -} - -void BossGanon_LightBall_Update(Actor* thisx, GlobalContext* globalCtx2) { - u8 hitWithBottle; - s16 i; - s16 spBA = 0; - Vec3f spAC; - Vec3f spA0; - Vec3f sp94; - BossGanon* this = (BossGanon*)thisx; - GlobalContext* globalCtx = globalCtx2; - f32 xDistFromLink; - f32 yDistFromLink; - f32 zDistFromLink; - f32 minReflectDist; - f32 xDistFromGanondorf; - f32 yDistFromGanondorf; - f32 zDistFromGanondorf; - Player* player = GET_PLAYER(globalCtx); - s32 pad; - BossGanon* ganondorf = (BossGanon*)this->actor.parent; - s32 pad1; - - this->unk_1A2++; - ganondorf->envLightMode = 1; - - if (this->unk_1A8 != 0) { - if (this->unk_1A8 == 2) { - Math_ApproachZeroF(&this->fwork[GDF_FWORK_1], 1.0f, 10.0f); - Math_ApproachF(&this->actor.scale.x, 30.0f, 0.5f, 100.0f); - } else { - this->actor.shape.rot.y += 0x1000; - ganondorf->lensFlareTimer = 1; - gCustomLensFlarePos = this->actor.world.pos; - Math_ApproachZeroF(&this->fwork[GDF_FWORK_1], 1.0f, 30.0f); - Math_ApproachF(&this->actor.scale.x, 20.0f, 0.5f, 100.0f); - this->fwork[GDF_FWORK_0] += ((M_PI / 2) + Rand_ZeroFloat(M_PI / 4)); - } - - Actor_SetScale(&this->actor, this->actor.scale.x); - - if (this->fwork[GDF_FWORK_1] == 0.0f) { - Actor_Kill(&this->actor); - } - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_FIRE - SFX_FLAG); - - if ((this->unk_1A2 % 2) != 0) { - Actor_SetScale(&this->actor, 6.0f); - } else { - Actor_SetScale(&this->actor, 5.25f); - } - - this->actor.shape.rot.z += (s16)(Rand_ZeroOne() * 20000.0f) + 0x4000; - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - - xDistFromGanondorf = ganondorf->unk_1FC.x - this->actor.world.pos.x; - yDistFromGanondorf = ganondorf->unk_1FC.y - this->actor.world.pos.y; - zDistFromGanondorf = ganondorf->unk_1FC.z - this->actor.world.pos.z; - - xDistFromLink = player->actor.world.pos.x - this->actor.world.pos.x; - yDistFromLink = (player->actor.world.pos.y + 40.0f) - this->actor.world.pos.y; - zDistFromLink = player->actor.world.pos.z - this->actor.world.pos.z; - - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - - switch (this->unk_1C2) { - case 0: - if ((player->stateFlags1 & 2) && - (ABS((s16)(player->actor.shape.rot.y - (s16)(ganondorf->actor.yawTowardsPlayer + 0x8000))) < - 0x2000) && - (sqrtf(SQ(xDistFromLink) + SQ(yDistFromLink) + SQ(zDistFromLink)) <= 25.0f)) { - hitWithBottle = true; - } else { - hitWithBottle = false; - } - - if ((this->collider.base.acFlags & 2) || hitWithBottle) { - ColliderInfo* acHitInfo = this->collider.info.acHitInfo; - - this->collider.base.acFlags &= ~2; - - if ((hitWithBottle == false) && (acHitInfo->toucher.dmgFlags & 0x100000)) { - spBA = 2; - Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - func_800AA000(this->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); - } else { - spBA = 1; - this->actor.world.rot.y = Math_Atan2S(zDistFromGanondorf, xDistFromGanondorf); - this->actor.world.rot.x = - Math_Atan2S(sqrtf(SQ(xDistFromGanondorf) + SQ(zDistFromGanondorf)), yDistFromGanondorf); - this->unk_1A4++; - this->timers[1] = 2; - Audio_PlaySoundGeneral(NA_SE_IT_SWORD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - func_800AA000(this->actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); - - if (hitWithBottle == false) { - // if ganondorf is 250 units away from link, at least 3 volleys are required - if ((ganondorf->actor.xyzDistToPlayerSq > 62500.0f) && (this->unk_1A4 < 3)) { - this->unk_1C2 = 1; - } else if (Rand_ZeroOne() < 0.7f) { - this->unk_1C2 = 1; - } else { - this->unk_1C2 = 3; - } - - // if a spin attack is used - if (player->swordAnimation >= 0x18) { - this->actor.speedXZ = 20.0f; - } - break; - } else { - if (Rand_ZeroOne() < 0.9f) { - this->unk_1C2 = 1; - } else { - this->unk_1C2 = 3; - } - } - } - } else { - if (sqrtf(SQ(xDistFromLink) + SQ(yDistFromLink) + SQ(zDistFromLink)) <= 25.0f) { - spBA = 5; - func_8002F6D4(globalCtx, &this->actor, 3.0f, this->actor.world.rot.y, 0.0f, 0x30); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_GANON_HIT_THUNDER); - ganondorf->timers[2] = 20; - - for (i = 0; i < ARRAY_COUNT(ganondorf->unk_4E4); i++) { - ganondorf->unk_4E4[i] = D_808E4C58[i]; - } - - ganondorf->unk_2E6 = 0; - ganondorf->unk_2E8 = 60; - ganondorf->unk_508 = 4.0f; - } - } - break; - - case 1: - if ((ganondorf->actionFunc == BossGanon_PlayTennis) && (ganondorf->unk_1C2 == 1)) { - minReflectDist = (this->actor.speedXZ >= 19.0f) ? 250.0f : 170.0f; - - if (sqrtf(SQ(xDistFromGanondorf) + SQ(yDistFromGanondorf) + SQ(zDistFromGanondorf)) < - minReflectDist) { - ganondorf->startVolley = true; - this->timers[0] = 8; - this->unk_1C2 = 2; - } - } - break; - - case 2: - if (this->timers[0] == 1) { - spBA = 1; - this->actor.world.rot.y = Math_Atan2S(zDistFromLink, xDistFromLink); - this->actor.world.rot.x = Math_Atan2S(sqrtf(SQ(xDistFromLink) + SQ(zDistFromLink)), yDistFromLink); - this->timers[1] = 2; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SWORD_REFLECT_MG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_AT_RETURN); - this->unk_1C2 = 0; - break; - } - // fallthrough - case 4: - if (sqrtf(SQ(xDistFromGanondorf) + SQ(yDistFromGanondorf) + SQ(zDistFromGanondorf)) < 30.0f) { - spBA = 3; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_GANON_DAMAGE1); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_GANON_HIT_THUNDER); - } - break; - - case 3: - if (sqrtf(SQ(xDistFromGanondorf) + SQ(yDistFromGanondorf) + SQ(zDistFromGanondorf)) < 100.0f) { - ganondorf->startVolley = true; - this->unk_1C2 = 4; - } - break; - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (this->timers[1] == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - for (i = 0; i < 2; i++) { - spA0.x = spA0.z = 0.0f; - spA0.y = 0.2f; - - spAC.x = spAC.y = spAC.z = 0.0f; - - sp94.x = Rand_CenteredFloat(30.0f) + this->actor.world.pos.x; - sp94.y = Rand_CenteredFloat(30.0f) + this->actor.world.pos.y; - sp94.z = Rand_CenteredFloat(30.0f) + this->actor.world.pos.z; - - BossGanonEff_SpawnSparkle(globalCtx, &sp94, &spAC, &spA0, Rand_ZeroFloat(500.0f) + 700.0f, 0x1E); - } - - if (this->actor.world.pos.y < 10.0f) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 20.0f, 4); - } - - if ((fabsf(this->actor.world.pos.x) > 465.0f) || (this->actor.world.pos.y > 500.0f) || - (fabsf(this->actor.world.pos.z) > 465.0f)) { - spBA = 4; - } - - if ((spBA != 0) || (this->actor.bgCheckFlags & 1)) { - f32 sp58; - f32 sp54; - f32 phi_f20; - s16 sp4E; - - if (spBA == 1) { - sp58 = Rand_ZeroFloat(100.0f) + 300.0f; - sp54 = 10.0f; - phi_f20 = 25.0f; - sp4E = 40; - } else { - sp58 = Rand_ZeroFloat(200.0f) + 500.0f; - sp54 = 15.0f; - phi_f20 = 30.0f; - sp4E = 70; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 80, NA_SE_EN_GANON_HIT_THUNDER); - } - - for (i = 0; i < sp4E; i++) { - if (spBA != 0) { - spAC.x = Rand_CenteredFloat(phi_f20); - spAC.y = Rand_CenteredFloat(phi_f20); - spAC.z = Rand_CenteredFloat(phi_f20); - } else { - spAC.x = Rand_CenteredFloat(phi_f20); - spAC.y = Rand_ZeroFloat(25.0f); - spAC.z = Rand_CenteredFloat(phi_f20); - } - - BossGanonEff_SpawnLightRay(globalCtx, &this->actor.world.pos, &spAC, &sZeroVec, sp58, sp54, 0x1E); - } - - if (spBA != 1) { - this->unk_1A8 = 1; - - if (spBA == 0) { - BossGanon_CheckFallingPlatforms(this, globalCtx, &this->actor.world.pos); - } - - if (spBA == 3) { - BossGanon_SetupHitByLightBall(ganondorf, globalCtx); - } else if (ganondorf->actionFunc == BossGanon_PlayTennis) { - BossGanon_SetupWait(ganondorf, globalCtx); - - if (spBA == 5) { - ganondorf->timers[0] = 125; - } - } - } - } - } -} - -void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx) { - BossGanon* this = (BossGanon*)thisx; - s16 i; - f32 alpha; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9849); - - func_80093D84(globalCtx->state.gfxCtx); - - alpha = ((this->unk_1A2 % 2) != 0) ? this->fwork[GDF_FWORK_1] * 0.4f : this->fwork[GDF_FWORK_1] * 0.35f; - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, (s8)alpha); - Matrix_Push(); - Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x * 0.75f, 1.0f, this->actor.scale.z * 0.75f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9875), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightCoreDL); - - Matrix_Pop(); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->fwork[GDF_FWORK_1]); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - - if (this->unk_1A8 == 1) { - for (i = 0; i < 8; i++) { - Matrix_Push(); - Matrix_RotateY(i * (M_PI / 8), MTXMODE_APPLY); - Matrix_RotateZ(this->fwork[GDF_FWORK_0], MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9899), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - Matrix_Pop(); - } - } else if (this->unk_1A8 == 0) { - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_RotateZ((this->actor.shape.rot.z / 32768.0f) * 3.1416f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9907), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9911); -} - -void func_808E1EB4(Actor* thisx, GlobalContext* globalCtx2) { - s16 i; - BossGanon* this = (BossGanon*)thisx; - GlobalContext* globalCtx = globalCtx2; - BossGanon* dorf = (BossGanon*)this->actor.parent; - f32 xDiff; - f32 yDiff; - f32 zDiff; - f32 xzDist; - s16 xRotTarget; - s16 yRotTarget; - Vec3f vel; - Vec3f accel; - - this->unk_1A2++; - dorf->envLightMode = 1; - Actor_SetScale(&this->actor, 6.0f); - this->actor.shape.rot.z += ((s16)(Rand_ZeroOne() * 20000.0f) + 0x4000); - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - - this->unk_1A6++; - - if (this->unk_1A6 >= 15) { - this->unk_1A6 = 0; - } - - this->unk_2EC[this->unk_1A6] = this->actor.world.pos; - - if (this->unk_1C2 == 0) { - if (1) {} - if (this->timers[0] == 0) { - this->unk_1C2 = 1; - } - } else if (this->unk_1C2 == 1) { - xDiff = dorf->unk_1FC.x - this->actor.world.pos.x; - yDiff = dorf->unk_1FC.y - this->actor.world.pos.y; - zDiff = dorf->unk_1FC.z - this->actor.world.pos.z; - - yRotTarget = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); - xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - xRotTarget = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); - - Math_ApproachS(&this->actor.world.rot.x, xRotTarget, 1, 0x1000); - Math_ApproachS(&this->actor.world.rot.y, yRotTarget, 1, 0x1000); - - if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 40.0f) { - this->unk_1C2 = 2; - this->timers[0] = 30; - this->actor.speedXZ = 0.0f; - - if (this->actor.params == 0xC8) { - func_80078884(NA_SE_EN_GANON_DAMAGE2); - func_80078884(NA_SE_EN_GANON_DD_THUNDER); - - for (i = 0; i < 150; i++) { - - vel.x = Rand_CenteredFloat(25.0f); - vel.y = Rand_CenteredFloat(25.0f); - vel.z = Rand_CenteredFloat(25.0f); - - accel.x = vel.x * -0.03f; - accel.y = vel.y * -0.03f; - accel.z = vel.z * -0.03f; - - BossGanonEff_SpawnLightRay(globalCtx, &dorf->unk_1FC, &vel, &accel, - Rand_ZeroFloat(500.0f) + 1000.0f, 15.0f, 0x14); - } - - for (i = 1; i < 15; i++) { - dorf->unk_4E4[i] = 1000; - } - - dorf->unk_2E6 = 1000; - dorf->unk_2E8 = 0; - dorf->screenFlashTimer = 4; - dorf->lensFlareTimer = 10; - dorf->lensFlareMode = 1; - dorf->unk_508 = 10.0f; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &dorf->actor, globalCtx, ACTOR_BOSS_GANON, dorf->unk_1FC.x, - dorf->unk_1FC.y, dorf->unk_1FC.z, 0, 0, 0, 0x12C); - } - - this->actor.world.pos.y = 5000.0f; - } - } else if (this->timers[0] == 0) { - Actor_Kill(&this->actor); - } -} - -void func_808E229C(Actor* thisx, GlobalContext* globalCtx2) { - BossGanon* this = (BossGanon*)thisx; - GlobalContext* globalCtx = globalCtx2; - s16 i; - s32 temp; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10081); - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - - for (i = 9; i >= 0; i--) { - temp = (s16)(((this->unk_1A6 - i) + 0xF) % 15); - Matrix_Translate(this->unk_2EC[temp].x, this->unk_2EC[temp].y, this->unk_2EC[temp].z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x * (1.0f - (i * 0.07000001f)), this->actor.scale.y * (1.0f - (i * 0.07000001f)), - this->actor.scale.z * (1.0f - (i * 0.07000001f)), MTXMODE_APPLY); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_RotateZ(((2.0f * (i * M_PI)) / 10.0f) + BINANG_TO_RAD(this->actor.shape.rot.z), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10109), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10113); -} - -void func_808E2544(Actor* thisx, GlobalContext* globalCtx) { - u8 numEffects = 0; - s16 xRot; - f32 xDiff; - f32 yDiff; - f32 zDiff; - f32 xzDist; - f32 new_var; - f32 sp84; - s16 i; - s16 sp80; - BossGanon* this = (BossGanon*)thisx; - BossGanon* dorf = (BossGanon*)this->actor.parent; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - ColliderInfo* acHitInfo; - Vec3f sp60; - - this->unk_1A2++; - Actor_SetScale(&this->actor, 0.01f); - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - - this->unk_1A6++; - - if (this->unk_1A6 >= 15) { - this->unk_1A6 = 0; - } - - this->unk_2EC[this->unk_1A6] = this->actor.world.pos; - this->unk_3C4[this->unk_1A6].x = BINANG_TO_RAD(this->actor.world.rot.x); - this->unk_3C4[this->unk_1A6].y = BINANG_TO_RAD(this->actor.world.rot.y); - - switch (this->unk_1C2) { - if (1) {} - case 0: - this->actor.speedXZ = 40.0f; - Math_ApproachF(&this->fwork[1], 255.0f, 1.0f, 40.0f); - xDiff = dorf->unk_278.x - this->actor.world.pos.x; - yDiff = dorf->unk_278.y - this->actor.world.pos.y; - zDiff = dorf->unk_278.z - this->actor.world.pos.z; - sp80 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); - xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - - xRot = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); - sp84 = (xzDist * 700.0f) / 10.0f; - if (sp84 > 6144.0f) { - sp84 = 6144.0f; - } - - xRot += (Math_CosS(this->unk_1A2 * 0x2200) * sp84); - this->actor.world.rot.x = xRot; - Math_ApproachS(&this->actor.shape.rot.y, sp80, 1, this->csCamMaxStepScale); - Math_ApproachF(&this->csCamMaxStepScale, 4096.0f, 1.0f, 256.0f); - this->actor.world.rot.y = (Math_SinS(this->unk_1A2 * 0x1A00) * sp84) + this->actor.shape.rot.y; - - if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 45.0f) { - this->unk_1C2 = 1; - this->actor.speedXZ = 0.0f; - } - break; - - case 1: - Math_ApproachZeroF(&this->fwork[1], 1.0f, 40.0f); - - if (this->fwork[1] == 0.0f) { - Actor_Kill(&this->actor); - } - break; - - case 10: - this->unk_1C2 = 0xB; - this->timers[0] = 14; - - this->collider.dim.radius = 15; - this->collider.dim.height = 20; - this->collider.dim.yShift = -10; - - this->actor.speedXZ = 20.0f; - this->fwork[1] = 255.0f; - this->unk_1F0 = player->actor.world.pos; - new_var = this->unk_1F0.x - this->actor.world.pos.x; - this->actor.shape.rot.y = RADF_TO_BINANG(Math_FAtan2F(new_var, this->unk_1F0.z - this->actor.world.pos.z)) + - (this->actor.params << 0xD) - 0x20C000; - // fallthrough - case 11: - if (this->timers[0] != 0) { - this->unk_1F0 = player->actor.world.pos; - xDiff = this->unk_1F0.x - this->actor.world.pos.x; - yDiff = (this->unk_1F0.y + 30.0f) - this->actor.world.pos.y; - zDiff = this->unk_1F0.z - this->actor.world.pos.z; - - sp80 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); - this->actor.shape.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff)))); - Math_ApproachS(&this->actor.shape.rot.y, sp80, 1, this->csCamMaxStepScale); - Math_ApproachF(&this->csCamMaxStepScale, 4096.0f, 1.0f, 256.0f); - } - - sp84 = (sqrtf(this->actor.xyzDistToPlayerSq) * 200.0f) / 10.0f; - if (sp84 > 13824.0f) { - sp84 = 13824.0f; - } - - this->actor.world.rot.x = (Math_CosS(this->unk_1A2 * 0x3400) * sp84 * 0.1f) + this->actor.shape.rot.x; - this->actor.world.rot.y = (Math_SinS(this->unk_1A2 * 0x1A00) * sp84) + this->actor.shape.rot.y; - - if ((player->swordState != 0) && (player->swordAnimation >= 0x18) && (this->actor.xzDistToPlayer < 80.0f)) { - this->unk_1C2 = 0xC; - this->actor.speedXZ = -30.0f; - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - this->unk_1F0 = dorf->unk_1FC; - numEffects = 10; - break; - } - - if (this->collider.base.acFlags & 2) { - acHitInfo = this->collider.info.acHitInfo; - - this->collider.base.acFlags &= ~2; - - if (!(acHitInfo->toucher.dmgFlags & 0x100000) || Player_HasMirrorShieldEquipped(globalCtx)) { - func_800AA000(this->actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); - this->unk_1C2 = 0xC; - this->actor.speedXZ = -30.0f; - - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - - this->unk_1F0.x = Rand_CenteredFloat(700.0f) + dorf->unk_1FC.x; - this->unk_1F0.y = Rand_CenteredFloat(200.0f) + dorf->unk_1FC.y; - this->unk_1F0.z = Rand_CenteredFloat(700.0f) + dorf->unk_1FC.z; - - this->unk_1F0.x = this->unk_1F0.x + ((this->unk_1F0.x - this->actor.world.pos.x) * 100.0f); - this->unk_1F0.y = this->unk_1F0.y + ((this->unk_1F0.y - this->actor.world.pos.y) * 100.0f); - this->unk_1F0.z = this->unk_1F0.z + ((this->unk_1F0.z - this->actor.world.pos.z) * 100.0f); - - numEffects = 10; - break; - } - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (this->timers[1] == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - xDiff = player->actor.world.pos.x - this->actor.world.pos.x; - yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y; - zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - - if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 30.0f) { - this->unk_1C2 = 1; - this->actor.speedXZ = 0.0f; - - if (dorf->timers[2] == 0) { - func_8002F6D4(globalCtx, &this->actor, 3.0f, this->actor.world.rot.y, 0.0f, 0x50); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_GANON_HIT_THUNDER); - dorf->timers[2] = 20; - - for (i = 0; i < ARRAY_COUNT(this->unk_4E4); i++) { - dorf->unk_4E4[i] = D_808E4C58[i]; - } - - dorf->unk_2E6 = 0; - dorf->unk_2E8 = 60; - dorf->unk_508 = 4.0f; - numEffects = 40; - } - } - break; - - case 12: - this->actor.speedXZ = 20.0f; - - xDiff = this->unk_1F0.x - this->actor.world.pos.x; - yDiff = this->unk_1F0.y - this->actor.world.pos.y; - zDiff = this->unk_1F0.z - this->actor.world.pos.z; - - sp80 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); - xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - xRot = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); - sp84 = (xzDist * 700.0f) / 10.0f; - - if (sp84 > 6144.0f) { - sp84 = 6144.0f; - } - - sp80 += Math_SinS(this->unk_1A2 * 0x2200) * sp84; - - xRot += Math_CosS(this->unk_1A2 * 0x1800) * sp84; - - this->actor.world.rot.x = xRot; - this->actor.world.rot.y = sp80; - - xDiff = dorf->unk_1FC.x - this->actor.world.pos.x; - yDiff = dorf->unk_1FC.y - this->actor.world.pos.y; - zDiff = dorf->unk_1FC.z - this->actor.world.pos.z; - - if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 45.0f) { - BossGanon_SetupHitByLightBall(dorf, globalCtx); - this->timers[0] = 150; - numEffects = 40; - this->unk_1C2 = 1; - this->actor.speedXZ = 0.0f; - } - break; - } - - if (this->unk_1C2 >= 0xB) { - xzDist = (this->unk_1C2 == 0xC) ? -65.0f : 0.0f; - - if ((fabsf(this->actor.world.pos.x) > (465.0f + xzDist)) || - (fabsf(this->actor.world.pos.z) > (465.0f + xzDist)) || ((this->actor.world.pos.y < 0.0f)) || - (this->actor.world.pos.y > 450.0f)) { - this->unk_1C2 = 1; - this->actor.speedXZ = 0.0f; - numEffects = 10; - BossGanon_CheckFallingPlatforms(this, globalCtx, &this->actor.world.pos); - Actor_SpawnAsChild(&globalCtx->actorCtx, &dorf->actor, globalCtx, ACTOR_BOSS_GANON, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x190); - } - } - - if (numEffects) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 80, NA_SE_EN_FANTOM_THUNDER); - - for (i = 0; i < numEffects; i++) { - sp60.x = Rand_CenteredFloat(30.0f); - sp60.y = Rand_CenteredFloat(30.0f); - sp60.z = Rand_CenteredFloat(30.0); - - BossGanonEff_SpawnLightRay(globalCtx, &this->actor.world.pos, &sp60, &sZeroVec, - Rand_ZeroFloat(200.0f) + 500.0f, 15.0f, 0x1E); - } - } -} - -static Gfx* sBigMagicLightStreakDLists[] = { - gDorfLightStreak12DL, gDorfLightStreak11DL, gDorfLightStreak10DL, gDorfLightStreak9DL, - gDorfLightStreak8DL, gDorfLightStreak7DL, gDorfLightStreak6DL, gDorfLightStreak5DL, - gDorfLightStreak4DL, gDorfLightStreak3DL, gDorfLightStreak2DL, gDorfLightStreak1DL, -}; - -void func_808E324C(Actor* thisx, GlobalContext* globalCtx) { - BossGanon* this = (BossGanon*)thisx; - Mtx* mtx; - s16 i; - s32 temp; - - mtx = Graph_Alloc(globalCtx->state.gfxCtx, 12 * sizeof(Mtx)); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10489); - - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (s8)this->fwork[GDF_FWORK_1]); - gDPSetEnvColor(POLY_XLU_DISP++, 150, 255, 0, 128); - gSPSegment(POLY_XLU_DISP++, 0x0D, mtx); - - for (i = 0; i < 12; i++) { - temp = (s16)(((this->unk_1A6 - i) + 0xF) % 15); - Matrix_Translate(this->unk_2EC[temp].x, this->unk_2EC[temp].y, this->unk_2EC[temp].z, MTXMODE_NEW); - Matrix_RotateY(this->unk_3C4[temp].y, MTXMODE_APPLY); - Matrix_RotateX(-this->unk_3C4[temp].x, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(M_PI / 2, MTXMODE_APPLY); - Matrix_ToMtx(mtx, "../z_boss_ganon.c", 10520); - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, sBigMagicLightStreakDLists[i]); - mtx++; - }; - - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(10.0f, 10.0f, 10.0f, MTXMODE_APPLY); - Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10534), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10541); -} - -void BossGanon_UpdateEffects(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - GanondorfEffect* eff = globalCtx->specialEffects; - s16 i; - s32 pad; - f32 xDiff; - f32 yDiff; - f32 zDiff; - f32 yRot; - f32 xRot; - Vec3f spA0; - s16 bodyPart; - f32 distToPlayer; - s32 pad2; - s32 pad3; - - spA0.x = 0.0f; - spA0.y = 0.0f; - - for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++, eff++) { - if (eff->type != GDF_EFF_NONE) { - eff->pos.x += eff->velocity.x; - eff->pos.y += eff->velocity.y; - eff->pos.z += eff->velocity.z; - - eff->timer++; - - eff->velocity.x += eff->accel.x; - eff->velocity.y += eff->accel.y; - eff->velocity.z += eff->accel.z; - - if (eff->type == GDF_EFF_WINDOW_SHARD) { - eff->unk_44 += 0.3f; - eff->unk_48 += 0.5f; - - if (eff->pos.y < 0.0f) { - eff->type = GDF_EFF_NONE; - } - } else if (eff->type == GDF_EFF_SPARKLE) { - eff->unk_3C += Rand_ZeroFloat(M_PI / 2) + M_PI / 2; - eff->unk_2E -= eff->unk_30; - - if (eff->unk_2E <= 0) { - eff->unk_2E = 0; - eff->type = GDF_EFF_NONE; - } - - eff->alpha = eff->unk_2E; - - if (eff->alpha > 255) { - eff->alpha = 255; - } - } else if (eff->type == GDF_EFF_BLACK_DOT) { - xDiff = sGanondorf->unk_278.x - eff->pos.x; - yDiff = sGanondorf->unk_278.y - eff->pos.y; - zDiff = sGanondorf->unk_278.z - eff->pos.z; - - yRot = Math_FAtan2F(xDiff, zDiff); - - xRot = -Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))); - spA0.z = eff->unk_38; - Matrix_RotateY(yRot, MTXMODE_NEW); - Matrix_RotateX(xRot, MTXMODE_APPLY); - Matrix_MultVec3f(&spA0, &eff->velocity); - Math_ApproachF(&eff->unk_38, 10.0f, 1.0f, 0.5f); - - eff->alpha += 10; - - if (eff->alpha > 255) { - eff->alpha = 255; - } - - if ((sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)) < 20.0f) || (eff->timer > 70)) { - eff->type = GDF_EFF_NONE; - } - } else if (eff->type == GDF_EFF_LIGHT_RAY) { - eff->unk_3C += Rand_ZeroFloat(M_PI / 2) + M_PI / 2; - eff->unk_2E -= eff->unk_30; - - if (eff->unk_2E <= 0) { - eff->unk_2E = 0; - eff->type = GDF_EFF_NONE; - } - - eff->alpha = eff->unk_2E; - - if (eff->alpha > 255) { - eff->alpha = 255; - } - - Math_ApproachF(&eff->unk_38, eff->unk_40, 1.0f, (eff->unk_40 / 15.0f) * 4.0f); - } else if (eff->type == GDF_EFF_SHOCK) { - if (eff->unk_2E == GDF_SHOCK_DORF_YELLOW) { - bodyPart = (s16)Rand_ZeroFloat(13.9f) + 1; - - eff->pos.x = sGanondorf->unk_2EC[bodyPart].x + Rand_CenteredFloat(20.0f); - eff->pos.y = sGanondorf->unk_2EC[bodyPart].y + Rand_CenteredFloat(20.0f); - eff->pos.z = sGanondorf->unk_2EC[bodyPart].z + Rand_CenteredFloat(20.0f); - } else { - bodyPart = (s16)Rand_ZeroFloat(17.9f); - - eff->pos.x = player->bodyPartsPos[bodyPart].x + Rand_CenteredFloat(10.0f); - eff->pos.y = player->bodyPartsPos[bodyPart].y + Rand_CenteredFloat(15.0f); - eff->pos.z = player->bodyPartsPos[bodyPart].z + Rand_CenteredFloat(10.0f); - } - - eff->unk_3C += (Rand_ZeroFloat(M_PI / 2) + M_PI / 2); - - if (eff->timer > 20) { - eff->type = GDF_EFF_NONE; - } - } else if (eff->type == GDF_EFF_LIGHTNING) { - if (eff->unk_3C == 0.0f) { - eff->unk_44 = BINANG_TO_RAD(Camera_GetInputDirYaw(Gameplay_GetCamera(globalCtx, MAIN_CAM))); - } else { - eff->unk_44 = M_PI / 2; - } - - if (eff->timer > 12) { - eff->type = GDF_EFF_NONE; - } - } else if (eff->type == GDF_EFF_IMPACT_DUST_DARK) { - eff->unk_30++; // unused - - if (eff->unk_2E == 0) { - eff->alpha += 26; - - if (eff->alpha > 255) { - eff->alpha = 255; - eff->unk_2E = 1; - } - } else if (eff->unk_2E == 1) { - eff->unk_2E = 2; - } else if (eff->unk_2E == 2) { - eff->alpha -= 26; - - if (eff->alpha < 0) { - eff->alpha = 0; - eff->type = GDF_EFF_NONE; - } - } - - Math_ApproachF(&eff->scale, eff->unk_38, 1.0f, 0.01f); - Math_ApproachF(&eff->unk_40, 4.0f, 1.0f, 0.15f); - } else if (eff->type == GDF_EFF_IMPACT_DUST_LIGHT) { - if (i == 0) { - func_80078884(NA_SE_EN_GANON_WAVE_GND - SFX_FLAG); - } - - eff->unk_30++; // unused - - if (eff->unk_2E == 0) { - eff->alpha += 100; - - if (eff->alpha > 255) { - eff->alpha = 255; - eff->unk_2E = 1; - } - } else if (eff->unk_2E == 1) { - if (eff->timer >= 20) { - eff->unk_2E = 2; - } - } else if (eff->unk_2E == 2) { - eff->alpha -= 30; - - if (eff->alpha < 0) { - eff->alpha = 0; - eff->type = GDF_EFF_NONE; - } - } - - Math_ApproachF(&eff->scale, eff->unk_38, 1.0f, 0.1f); - Math_ApproachF(&eff->unk_40, 1.0f, 1.0f, 0.15f); - } else if (eff->type == GDF_EFF_SHOCKWAVE) { - eff->unk_30++; // unused - eff->alpha -= 30; - - if (eff->alpha < 0) { - eff->alpha = 0; - eff->type = GDF_EFF_NONE; - } - - Math_ApproachF(&eff->scale, eff->unk_38, 1.0f, 0.13f); - - if ((eff->timer < 150) && (fabsf(player->actor.world.pos.y) < 5.0f)) { - distToPlayer = - sqrtf(SQ(eff->pos.x - player->actor.world.pos.x) + SQ(eff->pos.z - player->actor.world.pos.z)); - - if (((eff->scale * 150.0f) < distToPlayer) && (distToPlayer < (eff->scale * 300.0f))) { - eff->timer = 150; - func_8002F6D4(globalCtx, &sGanondorf->actor, 7.0f, sGanondorf->actor.yawTowardsPlayer, 0.0f, - 0x20); - } - } - } - } - } -} - -static void* sLightningTextures[] = { - gDorfLightning1Tex, gDorfLightning1Tex, gDorfLightning2Tex, gDorfLightning3Tex, gDorfLightning4Tex, - gDorfLightning5Tex, gDorfLightning6Tex, gDorfLightning7Tex, gDorfLightning8Tex, gDorfLightning9Tex, - gDorfLightning10Tex, gDorfLightning11Tex, gDorfLightning12Tex, -}; - -static u8 sLightningPrimColors[] = { - 0, 0, 0, 255, 255, 255, 231, 250, 231, 208, 245, 208, 185, 240, 185, 162, 235, 162, 139, 230, - 139, 115, 225, 115, 92, 220, 92, 69, 215, 69, 46, 210, 46, 23, 205, 23, 0, 200, 0, -}; - -static u8 sLightningEnvColors[] = { - 0, 0, 0, 255, 255, 0, 240, 231, 23, 226, 208, 46, 212, 185, 69, 198, 162, 92, - 184, 139, 115, 170, 115, 139, 156, 92, 162, 142, 69, 185, 128, 46, 208, 114, 23, 231, - 100, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -void BossGanon_DrawEffects(GlobalContext* globalCtx) { - u8 flag = 0; - s16 i; - s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - GanondorfEffect* eff = globalCtx->specialEffects; - GanondorfEffect* effFirst = eff; - - OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 10865); - func_80093D84(globalCtx->state.gfxCtx); - - for (i = 0; i < 200; i++, eff++) { - if (eff->type == GDF_EFF_WINDOW_SHARD) { - gDPPipeSync(POLY_OPA_DISP++); - if (flag == 0) { - gSPDisplayList(POLY_OPA_DISP++, gDorfWindowShardMaterialDL); - flag++; - } - if ((eff->timer & 7) != 0) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, 255); - } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - } - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - Matrix_Scale(eff->scale, eff->scale, eff->scale, MTXMODE_APPLY); - Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); - Matrix_RotateX(eff->unk_44, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 10898), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDorfWindowShardModelDL); - } - } - - eff = effFirst; - flag = 0; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_SPARKLE) { - gDPPipeSync(POLY_XLU_DISP++); - if (flag == 0) { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - flag++; - } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 10932), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - } - } - - eff = effFirst; - flag = 0; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_LIGHT_RAY) { - gDPPipeSync(POLY_XLU_DISP++); - if (flag == 0) { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); - flag++; - } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); - Matrix_RotateX(eff->unk_44, MTXMODE_APPLY); - Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); - Matrix_Scale(eff->scale, eff->scale, eff->unk_38 * eff->scale, MTXMODE_APPLY); - Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 10971), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); - } - } - - eff = effFirst; - flag = 0; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_SHOCK) { - if (flag == 0) { - gDPPipeSync(POLY_XLU_DISP++); - if (eff->unk_2E == GDF_SHOCK_PLAYER_PURPLE) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 0, 200, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 130, 0, 0, 0); - } else { // GDF_SHOCK_DORF_YELLOW or GDF_SHOCK_PLAYER_YELLOW - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); - } - flag++; - } - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); - Matrix_RotateX(eff->unk_3C * 1.3f, MTXMODE_APPLY); - Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11023), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfShockDL); - } - } - - eff = effFirst; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_LIGHTNING) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, sLightningPrimColors[(eff->timer * 3) + 0], - sLightningPrimColors[(eff->timer * 3) + 1], sLightningPrimColors[(eff->timer * 3) + 2], - 255); - gDPSetEnvColor(POLY_XLU_DISP++, sLightningEnvColors[(eff->timer * 3) + 0], - sLightningEnvColors[(eff->timer * 3) + 1], sLightningEnvColors[(eff->timer * 3) + 2], 0); - Matrix_Translate(sGanondorf->unk_260.x, sGanondorf->unk_260.y, sGanondorf->unk_260.z, MTXMODE_NEW); - Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); - Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); - Matrix_Scale(eff->scale, eff->scale, eff->scale, MTXMODE_APPLY); - Matrix_RotateY(eff->unk_44, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11074), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLightningTextures[eff->timer])); - gSPDisplayList(POLY_XLU_DISP++, gDorfLightningDL); - } - } - - eff = effFirst; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_IMPACT_DUST_DARK) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, eff->alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 100, 70, 0, 128); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, eff->timer * 4, 0, 32, 64, 1, eff->timer * 2, - eff->timer * -20, 32, 32)); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - Matrix_Scale(eff->scale, eff->unk_40 * eff->scale, eff->scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11121), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfImpactDarkDL); - } - } - - eff = effFirst; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_IMPACT_DUST_LIGHT) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 100, 0, 128); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, eff->timer * 4, 0, 32, 64, 1, eff->timer * 2, - eff->timer * -20, 32, 32)); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - Matrix_Scale(eff->scale, eff->unk_40 * eff->scale, eff->scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11165), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfImpactLightDL); - } - } - - eff = effFirst; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_SHOCKWAVE) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, eff->alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 150, 255, 0, 128); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (eff->timer * 100), 0, 64, 32, 1, - (eff->timer * 100), 0, 64, 32)); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - Matrix_Scale((eff->scale * 200.0f) / 1500.0f, (eff->unk_40 * 200.0f) / 1500.0f, - (eff->scale * 200.0f) / 1500.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11209), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfShockwaveDL); - } - } - - eff = effFirst; - - for (i = 0; i < 150; i++, eff++) { - if (eff->type == GDF_EFF_BLACK_DOT) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 170, 0, eff->alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); - gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, eff->timer * 2, eff->timer * -20, - 64, 64)); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11250), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gDorfDotDL); - } - } - - CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 11255); -} - -#include "overlays/ovl_Boss_Ganon/ovl_Boss_Ganon.c" diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.cpp b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.cpp new file mode 100644 index 000000000..1053627dc --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.cpp @@ -0,0 +1,5039 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GANON_Z_BOSS_GANON_C +#include "actor_common.h" +#include "z_kankyo.h" +#include "z_boss_ganon.h" +#include "overlays/ovl_Boss_Ganon/ovl_Boss_Ganon.h" +#include "overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.h" +#include "overlays/actors/ovl_En_Zl3/z_en_zl3.h" +#include "overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "assets/objects/object_ganon/object_ganon.h" +#include "assets/objects/object_ganon_anime1/object_ganon_anime1.h" +#include "assets/objects/object_ganon_anime2/object_ganon_anime2.h" +#include "assets/scenes/dungeons/ganon_boss/ganon_boss_scene.h" +#include "def/code_8006BA00.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/graph.h" +#include "def/sinf.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx); +void BossGanon_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossGanon_Update(Actor* thisx, GlobalContext* globalCtx); +void BossGanon_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_808E1EB4(Actor* thisx, GlobalContext* globalCtx); // update +void func_808E2544(Actor* thisx, GlobalContext* globalCtx); // update +void BossGanon_LightBall_Update(Actor* thisx, GlobalContext* globalCtx); +void func_808E229C(Actor* thisx, GlobalContext* globalCtx); // draw +void func_808E324C(Actor* thisx, GlobalContext* globalCtx); // draw +void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BossGanon_SetupIntroCutscene(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_SetupTowerCutscene(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_IntroCutscene(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_DeathAndTowerCutscene(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_Wait(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_ChargeLightBall(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_PlayTennis(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_PoundFloor(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_ChargeBigMagic(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_Block(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_HitByLightBall(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_Vulnerable(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_Damaged(BossGanon* pthis, GlobalContext* globalCtx); + +void BossGanon_SetupWait(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_SetupChargeLightBall(BossGanon* pthis, GlobalContext* globalCtx); +void BossGanon_SetupPlayTennis(BossGanon* pthis, GlobalContext* globalCtx); + +void BossGanon_DrawEffects(GlobalContext* globalCtx); +void BossGanon_UpdateEffects(GlobalContext* globalCtx); + +s32 BossGanon_CheckFallingPlatforms(BossGanon* pthis, GlobalContext* globalCtx, Vec3f* checkPos); + +ActorInit Boss_Ganon_InitVars = { + ACTOR_BOSS_GANON, + ACTORCAT_BOSS, + FLAGS, + OBJECT_GANON, + sizeof(BossGanon), + (ActorFunc)BossGanon_Init, + (ActorFunc)BossGanon_Destroy, + (ActorFunc)BossGanon_Update, + (ActorFunc)BossGanon_Draw, +}; + +static ColliderCylinderInit sDorfCylinderInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x10 }, + { 0xFFCFFFFE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 20, 80, -50, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sLightBallCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK6, + { 0x00100700, 0x00, 0x08 }, + { 0x0D900740, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 20, 30, -15, { 0, 0, 0 } }, +}; + +static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 }; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +static EnGanonMant* sCape; + +static s32 sSeed1; +static s32 sSeed2; +static s32 sSeed3; + +static BossGanon* sGanondorf; + +static EnZl3* sZelda; + +typedef struct { + /* 0x00 */ u8 type; + /* 0x01 */ u8 timer; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ Color_RGB8 color; + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ s16 unk_30; + /* 0x34 */ f32 scale; + /* 0x38 */ f32 unk_38; // scale target mostly, but used for other things + /* 0x3C */ f32 unk_3C; // mostly z rot + /* 0x40 */ f32 unk_40; + /* 0x44 */ f32 unk_44; // mostly x rot + /* 0x48 */ f32 unk_48; // mostly y rot +} GanondorfEffect; // size = 0x4C + +GanondorfEffect sEffectBuf[200]; + +void BossGanonEff_SpawnWindowShard(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, f32 scale) { + static Color_RGB8 shardColors[] = { { 255, 175, 85 }, { 155, 205, 155 }, { 155, 125, 55 } }; + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + Color_RGB8* color; + + for (i = 0; i < 200; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_WINDOW_SHARD; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = sZeroVec; + eff->scale = scale; + eff->accel.y = -1.5f; + eff->unk_44 = Rand_ZeroFloat(6.28f); + eff->unk_48 = Rand_ZeroFloat(6.28f); + color = &shardColors[(s16)Rand_ZeroFloat(2.99f)]; + eff->color.r = color->r; + eff->color.g = color->g; + eff->color.b = color->b; + eff->timer = (s16)Rand_ZeroFloat(20.0f); + break; + } + } +} + +void BossGanonEff_SpawnSparkle(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, + s16 arg6) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_SPARKLE; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = *accel; + eff->scale = scale / 1000.0f; + eff->unk_2E = (s16)Rand_ZeroFloat(100.0f) + 0xC8; + eff->unk_30 = arg6; + eff->timer = (s16)Rand_ZeroFloat(10.0f); + break; + } + } +} + +void BossGanonEff_SpawnLightRay(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, + f32 arg5, s16 arg6) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_LIGHT_RAY; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = *accel; + eff->scale = scale / 1000.0f; + eff->unk_38 = 1.0f; + eff->unk_40 = arg5; + eff->unk_2E = (s16)Rand_ZeroFloat(100.0f) + 0xC8; + eff->unk_30 = arg6; + eff->timer = (s16)Rand_ZeroFloat(10.0f); + eff->unk_48 = Math_Atan2F(eff->velocity.z, eff->velocity.x); + eff->unk_44 = -Math_Atan2F(sqrtf(SQXZ(eff->velocity)), eff->velocity.y); + break; + } + } +} + +void BossGanonEff_SpawnShock(GlobalContext* globalCtx, f32 scale, s16 shockType) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 75; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_SHOCK; + eff->pos = sZeroVec; + eff->pos.y = -2000.0f; + eff->velocity = sZeroVec; + eff->accel = sZeroVec; + eff->scale = scale / 1000.0f; + eff->unk_2E = shockType; + eff->timer = 0; + break; + } + } +} + +void BossGanonEff_SpawnLightning(GlobalContext* globalCtx, f32 scale, f32 arg2, f32 arg3) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_LIGHTNING; + eff->velocity = sZeroVec; + eff->accel = sZeroVec; + eff->unk_2E = 0; + eff->scale = scale; + eff->unk_48 = arg2; + eff->unk_3C = arg3; + eff->timer = 0; + break; + } + } +} + +void BossGanonEff_SpawnDustDark(GlobalContext* globalCtx, Vec3f* pos, f32 scale, f32 arg3) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_IMPACT_DUST_DARK; + eff->pos = *pos; + eff->velocity = sZeroVec; + eff->accel = sZeroVec; + eff->scale = scale; + eff->unk_40 = 1.0f; + eff->unk_38 = arg3; + eff->unk_30 = (s16)Rand_ZeroFloat(100.0f); + eff->unk_2E = eff->timer = eff->alpha = 0; + break; + } + } +} + +void BossGanonEff_SpawnDustLight(GlobalContext* globalCtx, Vec3f* pos, f32 scale, f32 arg3, s16 bufIndex) { + GanondorfEffect* effArr = (GanondorfEffect*)globalCtx->specialEffects; + + effArr[bufIndex].type = GDF_EFF_IMPACT_DUST_LIGHT; + effArr[bufIndex].pos = *pos; + effArr[bufIndex].velocity = sZeroVec; + effArr[bufIndex].accel = sZeroVec; + effArr[bufIndex].unk_40 = 1.0f; + effArr[bufIndex].scale = scale; + effArr[bufIndex].unk_38 = arg3; + effArr[bufIndex].unk_30 = Rand_ZeroFloat(100.0f); + effArr[bufIndex].unk_2E = effArr[bufIndex].timer = effArr[bufIndex].alpha = 0; +} + +void BossGanonEff_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, f32 scale, f32 arg3) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_SHOCKWAVE; + eff->pos = *pos; + eff->velocity = sZeroVec; + eff->accel = sZeroVec; + eff->alpha = 255; + eff->unk_40 = 0.6f; + eff->scale = scale; + eff->unk_38 = arg3; + eff->unk_30 = (s16)Rand_ZeroFloat(100.0f); + eff->unk_2E = eff->timer = 0; + break; + } + } +} + +void BossGanonEff_SpawnBlackDot(GlobalContext* globalCtx, Vec3f* pos, f32 scale) { + s16 i; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_NONE) { + eff->type = GDF_EFF_BLACK_DOT; + eff->pos = *pos; + eff->velocity = sZeroVec; + eff->accel = sZeroVec; + eff->unk_38 = 0.0f; + eff->scale = scale / 1000.0f; + eff->timer = 0; + eff->alpha = 0; + eff->unk_2E = 0; + break; + } + } +} + +void BossGanon_SetColliderPos(Vec3f* pos, ColliderCylinder* collider) { + collider->dim.pos.x = pos->x; + collider->dim.pos.y = pos->y; + collider->dim.pos.z = pos->z; +} + +void BossGanon_SetAnimationObject(BossGanon* pthis, GlobalContext* globalCtx, s32 objectId) { + pthis->animBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animBankIndex].vromStart.get()); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x3D, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx2) { + s16 i; + GlobalContext* globalCtx = globalCtx2; + BossGanon* pthis = (BossGanon*)thisx; + s32 cond; + f32 xDistFromPlayer; + f32 yDistFromPlayer; + f32 zDistFromPlayer; + Player* player = GET_PLAYER(globalCtx); + + if (thisx->params < 0x64) { + Flags_SetSwitch(globalCtx, 0x14); + globalCtx->specialEffects = sEffectBuf; + + for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++) { + sEffectBuf[i].type = GDF_EFF_NONE; + } + + sGanondorf = pthis; + thisx->colChkInfo.health = 40; + Actor_ProcessInitChain(thisx, sInitChain); + ActorShape_Init(&thisx->shape, 0, NULL, 0); + Actor_SetScale(thisx, 0.01f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDorfSkel, NULL, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sDorfCylinderInit); + + if (thisx->params != 1) { + BossGanon_SetupIntroCutscene(pthis, globalCtx); + pthis->organAlpha = 255; + } else { + cond = Flags_GetSwitch(globalCtx, 0x37) && + ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || + (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); + + if (!cond) { + BossGanon_SetupTowerCutscene(pthis, globalCtx); + } else { + Actor_Kill(thisx); + return; + } + + BossGanon_SetupTowerCutscene(pthis, globalCtx); + } + + sCape = (EnGanonMant*)Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_GANON_MANT, 0.0f, + 0.0f, 0.0f, 0, 0, 0, 1); + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BOSS); + } else { + thisx->flags &= ~ACTOR_FLAG_0; + pthis->fwork[GDF_FWORK_1] = 255.0f; + + if (thisx->params >= 0xC8) { + if (thisx->params == 0x12C) { + thisx->update = BossGanon_LightBall_Update; + thisx->draw = BossGanon_LightBall_Draw; + pthis->unk_1A8 = 2; + } else if (thisx->params == 0x190) { + thisx->update = BossGanon_LightBall_Update; + thisx->draw = BossGanon_LightBall_Draw; + pthis->unk_1A8 = 1; + } else if (thisx->params >= 0x104) { + // big magic light ball thrown + thisx->update = func_808E2544; + thisx->draw = func_808E324C; + pthis->unk_1C2 = 10; + pthis->unk_1A2 = 520 + (-thisx->params * 2); + + for (i = 0; i < 15; i++) { + pthis->unk_2EC[i] = thisx->world.pos; + } + + pthis->timers[1] = 3; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sLightBallCylinderInit); + } else if (thisx->params >= 0xFA) { + // big magic light ball charge + thisx->update = func_808E2544; + thisx->draw = func_808E324C; + pthis->unk_1A2 = Rand_ZeroFloat(10000.0f); + + for (i = 0; i < 15; i++) { + pthis->unk_2EC[i] = thisx->world.pos; + } + + pthis->fwork[GDF_FWORK_1] = 0; + } else { + thisx->update = func_808E1EB4; + thisx->draw = func_808E229C; + if (1) {} + thisx->speedXZ = 11.0f; + + if (thisx->params == 0xC8) { + pthis->timers[0] = 7; + } else { + pthis->timers[0] = (s16)Rand_ZeroFloat(3.0f) + 3; + } + + for (i = 0; i < 15; i++) { + pthis->unk_2EC[i].y = 5000.0f; + } + } + } else { + // light ball (anything from 0x64 - 0xC7) + thisx->update = BossGanon_LightBall_Update; + thisx->draw = BossGanon_LightBall_Draw; + thisx->speedXZ = 12.0f; + + xDistFromPlayer = player->actor.world.pos.x - thisx->world.pos.x; + yDistFromPlayer = (player->actor.world.pos.y + 30.0f) - thisx->world.pos.y; + zDistFromPlayer = player->actor.world.pos.z - thisx->world.pos.z; + + thisx->world.rot.y = Math_Atan2S(zDistFromPlayer, xDistFromPlayer); + thisx->world.rot.x = Math_Atan2S(sqrtf(SQ(xDistFromPlayer) + SQ(zDistFromPlayer)), yDistFromPlayer); + + if (Rand_ZeroOne() < 0) { + thisx->world.rot.y += (s16)Rand_CenteredFloat(5000.0f); + thisx->world.rot.x += (s16)Rand_CenteredFloat(5000.0f); + } + + pthis->timers[1] = 3; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sLightBallCylinderInit); + } + } +} + +void BossGanon_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BossGanon* pthis = (BossGanon*)thisx; + + if ((pthis->actor.params < 0xC8) || (pthis->actor.params >= 0x104)) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } + + if (pthis->actor.params < 0x64) { + SkelAnime_Free(&pthis->skelAnime, globalCtx); + } +} + +void BossGanon_SetupIntroCutscene(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 animBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME2); + + if (animBankIndex < 0) { + Actor_Kill(&pthis->actor); + return; + } + + if (Object_IsLoaded(&globalCtx->objectCtx, animBankIndex)) { + pthis->actionFunc = BossGanon_IntroCutscene; + pthis->unk_198 = 1; + pthis->animBankIndex = animBankIndex; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[animBankIndex].vromStart.get()); + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_005FFC, 0.0f); + } else { + pthis->actionFunc = BossGanon_SetupIntroCutscene; + } +} + +typedef struct { + /* 0x00 */ Vec3s eye; + /* 0x06 */ Vec3s at; +} CutsceneCameraPosition; // size = 0x12 + +static CutsceneCameraPosition sIntroCsCameraPositions[] = { + { { 0, 40, 0 }, { 0, 50, 430 } }, + { { -20, 30, 400 }, { 10, 55, 440 } }, + { { 0, 60, 300 }, { 0, 273, -150 } }, + { { 0, 180, -260 }, { 0, 155, -300 } }, + { { -30, 60, 440 }, { 20, 25, 390 } }, + { { -50, 140, -360 }, { 50, 92, -390 } }, + { { -10, 264, -121 }, { 5, 266, -160 } }, + { { -13, 200, -310 }, { 0, 125, -410 } }, + { { 0, 40, -50 }, { 0, 35, 230 } }, + { { 0, 140, -250 }, { 0, 115, -570 } }, + { { -410, 150, -130 }, { 50, 155, -170 } }, + { { 0, 130, -230 }, { 0, 125, -2000 } }, + { { -2, 147, -293 }, { -200, 345, -2000 } }, +}; + +void BossGanon_SetIntroCsCamera(BossGanon* pthis, u8 camPosIndex) { + CutsceneCameraPosition* camPos = &sIntroCsCameraPositions[camPosIndex]; + + pthis->csCamEye.x = camPos->eye.x; + pthis->csCamEye.y = camPos->eye.y; + pthis->csCamEye.z = camPos->eye.z; + + pthis->csCamAt.x = camPos->at.x; + pthis->csCamAt.y = camPos->at.y; + pthis->csCamAt.z = camPos->at.z; +} + +void BossGanon_IntroCutscene(BossGanon* pthis, GlobalContext* globalCtx) { + u8 moveCam = false; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + f32 sin; + f32 cos; + Camera* mainCam; + + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animBankIndex].vromStart.get()); + + sCape->backPush = -2.0f; + sCape->backSwayMagnitude = 0.25f; + sCape->sideSwayMagnitude = -1.0f; + sCape->minDist = 0.0f; + + pthis->csTimer++; + + SkelAnime_Update(&pthis->skelAnime); + + switch (pthis->csState) { + case 0: + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 430.0f; + + pthis->actor.world.pos.x = 0.0f; + pthis->actor.world.pos.y = 112.0f; + pthis->actor.world.pos.z = -333.0f; + + pthis->actor.shape.yOffset = -7000.0f; + pthis->actor.shape.rot.y = 0; + + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->csCamIndex = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->csCamIndex, CAM_STAT_ACTIVE); + pthis->csCamFov = 60.0f; + + if (gSaveContext.eventChkInf[7] & 0x100) { + // watched cutscene already, skip most of it + pthis->csState = 17; + pthis->csTimer = 0; + player->actor.world.pos.z = 20.0f; + pthis->useOpenHand = false; + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_0089F8, -5.0f); + pthis->fwork[GDF_FWORK_1] = 1000.0f; + BossGanon_SetIntroCsCamera(pthis, 11); + pthis->unk_198 = 2; + pthis->timers[2] = 110; + gSaveContext.healthAccumulator = 0x140; + Audio_QueueSeqCmd(NA_BGM_STOP); + } else { + pthis->useOpenHand = true; + BossGanon_SetIntroCsCamera(pthis, 0); + pthis->csState = 1; + sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, + 220.0f, -150.0f, 0, 0, 0, 0x2000); + } + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_GANON_ORGAN, 0.0f, 0.0f, 0.0f, 0, + 0, 0, 1); + sCape->minY = 57.0f; + // fallthrough + case 1: + pthis->envLightMode = 3; + if (pthis->csTimer == 70) { + pthis->csState = 2; + pthis->csTimer = 0; + } + break; + + case 2: + BossGanon_SetIntroCsCamera(pthis, 1); + + if (pthis->csTimer == 10) { + func_8002DF54(globalCtx, &pthis->actor, 5); + } + + if (pthis->csTimer == 13) { + func_8002F7DC(&player->actor, player->ageProperties->unk_92 + NA_SE_VO_LI_SURPRISE); + } + + if (pthis->csTimer != 35) { + break; + } + + pthis->csState = 3; + pthis->csTimer = 0; + + pthis->csCamEye.x = 0.0f; + pthis->csCamEye.y = 60.0f; + pthis->csCamEye.z = 300.0f; + + pthis->csCamAt.x = 0.0f; + pthis->unk_704 = 1.2566371f; + // fallthrough + case 3: + pthis->envLightMode = 0; + globalCtx->envCtx.unk_D8 = 0.0f; + pthis->csCamAt.y = (sinf(pthis->unk_704) * 300.0f) + pthis->csCamEye.y; + pthis->csCamAt.z = (cosf(pthis->unk_704) * -300.0f) + pthis->csCamEye.z; + Math_ApproachF(&pthis->unk_704, 0.25f, 0.05f, pthis->csCamAtMaxStep.y); + Math_ApproachF(&pthis->csCamAtMaxStep.y, 0.01f, 1.0f, 0.0001f); + + if (pthis->csTimer != 200) { + break; + } + + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->csState = 4; + BossGanon_SetIntroCsCamera(pthis, 2); + pthis->csTimer = 0; + // fallthrough + case 4: + if ((pthis->csTimer == 0) || (pthis->csTimer == 10) || (pthis->csTimer == 20)) { + pthis->csCamEye.y += 68.0f; + pthis->csCamEye.z -= 142.0f; + } + + if (pthis->csTimer >= 20) { + pthis->envLightMode = 4; + } else { + pthis->envLightMode = 35; + } + + if (pthis->csTimer == 60) { + BossGanon_SetIntroCsCamera(pthis, 1); + pthis->csState = 5; + pthis->csTimer = 0; + } + break; + + case 5: + pthis->envLightMode = 5; + + if (pthis->csTimer < 50) { + globalCtx->envCtx.unk_D8 = 1.0f; + } + + if (pthis->csTimer == 10) { + func_8002DF54(globalCtx, &pthis->actor, 0x4B); + } + + if (pthis->csTimer == 70) { + BossGanon_SetIntroCsCamera(pthis, 3); + pthis->csState = 6; + pthis->csTimer = 0; + pthis->envLightMode = 3; + } + break; + + case 6: + pthis->envLightMode = 3; + + if (pthis->csTimer != 30) { + break; + } + + pthis->csState = 7; + pthis->csTimer = 0; + BossGanon_SetIntroCsCamera(pthis, 4); + pthis->triforceType = GDF_TRIFORCE_PLAYER; + pthis->fwork[GDF_TRIFORCE_SCALE] = 10.0f; + pthis->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; + pthis->fwork[GDF_TRIFORCE_PRIM_B] = 255.0f; + pthis->fwork[GDF_TRIFORCE_ENV_G] = 100.0f; + func_80078884(NA_SE_EV_TRIFORCE_MARK); + globalCtx->envCtx.unk_D8 = 0.0f; + // fallthrough + case 7: + pthis->envLightMode = 6; + // fade in links triforce + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_PRIM_A], 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_SCALE], 0.4f, 1.0f, 0.3f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_PRIM_B], 170.0f, 1.0f, 2.55f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); + + if (pthis->csTimer >= 30) { + pthis->envLightMode = 65; + } + + if (pthis->csTimer == 30) { + globalCtx->envCtx.unk_D8 = 1.0f; + } + + BossGanon_SetIntroCsCamera(pthis, 4); + pthis->csCamEye.x += 5.0f; + pthis->csCamEye.z += -10.0f; + pthis->csCamAt.x += 18.0f; + + if (pthis->csTimer == 60) { + pthis->csState = 8; + pthis->csTimer = 0; + } + break; + + case 8: + pthis->envLightMode = 3; + BossGanon_SetIntroCsCamera(pthis, 5); + + if (pthis->csTimer != 30) { + break; + } + + pthis->csState = 9; + pthis->csTimer = 0; + func_8002DF54(globalCtx, &pthis->actor, 8); + sZelda->unk_3C8 = 0; + pthis->triforceType = GDF_TRIFORCE_ZELDA; + pthis->fwork[GDF_TRIFORCE_SCALE] = 10.0f; + pthis->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; + pthis->fwork[GDF_TRIFORCE_PRIM_B] = 255.0f; + pthis->fwork[GDF_TRIFORCE_ENV_G] = 100.0f; + func_80078884(NA_SE_EV_TRIFORCE_MARK); + globalCtx->envCtx.unk_D8 = 0.0f; + // fallthrough + case 9: + pthis->envLightMode = 7; + BossGanon_SetIntroCsCamera(pthis, 6); + // fade in zeldas triforce + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_PRIM_A], 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_SCALE], 0.4f, 1.0f, 0.3f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_PRIM_B], 170.0f, 1.0f, 2.55f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); + + if (pthis->csTimer == 30) { + sZelda->unk_3C8 = 1; + } + + if (pthis->csTimer >= 32) { + pthis->envLightMode = 75; + } + + if (pthis->csTimer == 32) { + globalCtx->envCtx.unk_D8 = 1.0f; + } + + if (pthis->csTimer == 50) { + pthis->csState = 10; + pthis->csTimer = 0; + } + break; + + case 10: // top view of playing the organ + pthis->envLightMode = 3; + BossGanon_SetIntroCsCamera(pthis, 7); + + if (pthis->csTimer == 40) { + pthis->csState = 11; + pthis->csTimer = 0; + pthis->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; + } + break; + + case 11: // link is healed + pthis->envLightMode = 3; + BossGanon_SetIntroCsCamera(pthis, 8); + player->actor.world.pos.z = 20.0f; + + if (pthis->csTimer == 20) { + func_8002DF54(globalCtx, &pthis->actor, 0x17); + Interface_ChangeAlpha(11); // show hearts only + } + + if (pthis->csTimer == 25) { + gSaveContext.healthAccumulator = 0x140; + } + + if (pthis->csTimer == 100) { + Interface_ChangeAlpha(1); + } + + if (pthis->csTimer == 120) { + pthis->csState = 12; + pthis->csTimer = 0; + } + break; + + case 12: // first dialogue, ganondorf facing away from link + pthis->envLightMode = 3; + BossGanon_SetIntroCsCamera(pthis, 9); + + if (pthis->csTimer == 30) { + Audio_QueueSeqCmd(0x100100FF); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_004F64); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_004F64, -5.0f); + } + + if ((pthis->csTimer > 30) && Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_006AF4, 0.0f); + pthis->fwork[GDF_FWORK_1] = 1000.0f; + } + + if (pthis->csTimer == 80) { + Message_StartTextbox(globalCtx, 0x70C8, NULL); + } + + if ((pthis->csTimer > 180) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 15; + pthis->csTimer = 0; + pthis->useOpenHand = false; + } + break; + + case 15: // side view of all 3 of them + pthis->envLightMode = 0; + globalCtx->envCtx.unk_D8 = 0.0f; + BossGanon_SetIntroCsCamera(pthis, 10); + + if (pthis->csTimer == 30) { + Message_StartTextbox(globalCtx, 0x70C9, NULL); + } + + if ((pthis->csTimer > 100) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 16; + pthis->csTimer = 0; + BossGanon_SetIntroCsCamera(pthis, 11); + pthis->unk_198 = 2; + sZelda->unk_3C8 = 2; + pthis->timers[2] = 110; + pthis->envLightMode = 3; + } + break; + + case 16: + pthis->envLightMode = 3; + + if (pthis->csTimer <= 20) { + if (pthis->csTimer == 20) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_004304, -5.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_004304); + } + } else if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + Message_StartTextbox(globalCtx, 0x70CA, NULL); + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_0089F8, -5.0f); + pthis->fwork[GDF_FWORK_1] = 1000.0f; + } + + if ((pthis->csTimer > 100) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 17; + pthis->csTimer = 0; + } + break; + + case 17: // turns around + pthis->envLightMode = 3; + + if (pthis->csTimer == 20) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_001F58, -5.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_001F58); + } + + if (pthis->csTimer > 10) { + if (pthis->csTimer == 62) { + sCape->attachRightArmTimer = 20.0f; + } + + if (pthis->csTimer == 57) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + } + + Math_ApproachF(&pthis->csCamFov, 110.0f, 0.1f, pthis->csCamMaxStepScale * 2.0f); + Math_ApproachF(&pthis->csCamEye.z, -290.0f, 0.1f, pthis->csCamMaxStepScale * 2.4f); + Math_ApproachF(&pthis->csCamMaxStepScale, 0.75f, 1.0f, 0.05f); + + if (pthis->csTimer == 70) { + pthis->csState = 18; + pthis->csTimer = 0; + pthis->csCamFov = 60.0f; + BossGanon_SetIntroCsCamera(pthis, 12); + Message_StartTextbox(globalCtx, 0x70CB, NULL); + } + } + break; + + case 18: // last dialog before triforce + pthis->envLightMode = 3; + BossGanon_SetIntroCsCamera(pthis, 12); + pthis->csCamEye.y += -6.0f; + pthis->csCamEye.z += 6.0f; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1] - 5.0f)) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_003018, -5.0f); + pthis->fwork[GDF_FWORK_1] = 1000.0f; + } + + if ((pthis->csTimer <= 50) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { + break; + } + + pthis->csState = 19; + pthis->csTimer = 0; + Message_StartTextbox(globalCtx, 0x70CC, NULL); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_007268, -5.0f); + pthis->triforceType = GDF_TRIFORCE_DORF; + pthis->fwork[GDF_TRIFORCE_SCALE] = 10.0f; + pthis->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; + pthis->fwork[GDF_TRIFORCE_PRIM_B] = 255.0f; + pthis->fwork[GDF_TRIFORCE_ENV_G] = 100.0f; + globalCtx->envCtx.unk_D8 = 0.0f; + // fallthrough + case 19: // show triforce + pthis->envLightMode = 8; + + if (pthis->csTimer >= 60) { + pthis->envLightMode = 9; + + if (pthis->csTimer == 60) { + globalCtx->envCtx.unk_D8 = 1.0f; + } + } + + BossGanon_SetIntroCsCamera(pthis, 12); + pthis->csCamEye.y += -6.0f; + pthis->csCamEye.z += 6.0f; + + if (pthis->csTimer >= 30) { + if (pthis->csTimer == 30) { + func_80078884(NA_SE_EV_TRIFORCE_MARK); + } + + // fade in ganondorf's triforce + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_PRIM_A], 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_SCALE], 0.6f, 1.0f, 0.3f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_PRIM_B], 170.0f, 1.0f, 2.55f); + Math_ApproachF(&pthis->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); + } + + if (pthis->csTimer == 17) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_007A64, -5.0f); + } + + if ((pthis->csTimer > 80) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 20; + pthis->csTimer = 0; + + pthis->csCamTargetEye.x = pthis->csCamEye.x - 50.0f; + pthis->csCamTargetEye.y = pthis->csCamEye.y - 100.0f; + pthis->csCamTargetEye.z = pthis->csCamEye.z + 400.0f; + + pthis->csCamEyeMaxStep.x = 50.0f; + pthis->csCamEyeMaxStep.y = 100.0f; + pthis->csCamEyeMaxStep.z = 400.0f; + + pthis->csCamAtMaxStep.x = 400.0f; + pthis->csCamMaxStepScale = 0.0f; + + pthis->csCamTargetAt.x = pthis->csCamAt.x + 400.0f; + pthis->csCamTargetAt.y = pthis->csCamAt.y; + pthis->csCamTargetAt.z = pthis->csCamAt.z; + + pthis->csCamMovementScale = 0.2f; + + pthis->fwork[GDF_VORTEX_ALPHA] = 0.0f; + pthis->fwork[GDF_VORTEX_SCALE] = 0.1f; + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DARKWAVE); + } + break; + + case 20: // zoom cam out + pthis->envLightMode = 10; + moveCam = true; + Math_ApproachF(&pthis->csCamMaxStepScale, 0.15f, 1.0f, 0.015f); + + if (pthis->csTimer <= 40) { + Math_ApproachF(&pthis->fwork[GDF_VORTEX_ALPHA], 255.0f, 1.0f, 6.5f); + Math_ApproachF(&pthis->fwork[GDF_VORTEX_SCALE], 0.2f, 1.0f, 0.025f); + } + + if (pthis->csTimer > 20) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DARKWAVE_M - SFX_FLAG); + } + + if (pthis->csTimer > 20) { + BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); + BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); + } + + if (pthis->csTimer == 30) { + func_8002DF54(globalCtx, &pthis->actor, 0x4A); + } + + if (pthis->csTimer <= 50) { + break; + } + + pthis->csState = 21; + pthis->csTimer = 0; + pthis->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; + pthis->fwork[GDF_VORTEX_SCALE] = 0.16f; + goto skip_sound_and_fx; + + case 21: // purple vortex + pthis->envLightMode = 11; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DARKWAVE_M - SFX_FLAG); + BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); + BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_PURPLE); + + skip_sound_and_fx: + pthis->csCamEye.x = -30.0f; + pthis->csCamEye.y = 37.0f; + pthis->csCamEye.z = -30.0f; + + pthis->csCamAt.x = -10.0f; + pthis->csCamAt.y = 45.0f; + pthis->csCamAt.z = 0.0f; + + if (pthis->csTimer == 13) { + Message_StartTextbox(globalCtx, 0x70CD, NULL); + } + + if ((pthis->csTimer <= 120) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { + break; + } + + pthis->csState = 22; + pthis->csTimer = 0; + pthis->timers[2] = 30; + pthis->organAlpha = 254; + pthis->csCamAt.x = pthis->unk_1FC.x - 10.0f; + pthis->csCamAt.y = pthis->unk_1FC.y + 30.0f; + pthis->csCamAt.z = pthis->unk_1FC.z; + pthis->fwork[GDF_VORTEX_ALPHA] = 255.0f; + pthis->fwork[GDF_VORTEX_SCALE] = 0.2f; + // fallthrough + case 22: // start floating, show title card, start fight + if (pthis->csTimer > 30) { + pthis->envLightMode = 0; + } else { + pthis->envLightMode = 12; + } + + Math_ApproachZeroF(&pthis->fwork[GDF_VORTEX_ALPHA], 1.0f, 10.0f); + + pthis->csCamEye.x = -30.0f; + pthis->csCamEye.y = 137.0f; + pthis->csCamEye.z = -110.0f; + + Math_ApproachF(&pthis->csCamAt.y, pthis->unk_1FC.y + 30.0f, 0.1f, 20.0f); + Math_ApproachF(&pthis->csCamAt.x, pthis->unk_1FC.x - 10.0f, 0.1f, 5.0f); + + if (pthis->csTimer == 20) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfGetUp3Anim, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.shape.yOffset = 0.0f; + sCape->attachShouldersTimer = 18.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + pthis->unk_198 = 0; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANONDORF_BOSS); + } + + if (pthis->csTimer == 50) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON)].vromStart.get()); + + if (!(gSaveContext.eventChkInf[7] & 0x100)) { + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(gDorfTitleCardTex), 160, 180, 128, 40); + } + + gSaveContext.eventChkInf[7] |= 0x100; + } + + if (pthis->csTimer >= 20) { + pthis->legSwayEnabled = true; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_FLOAT - SFX_FLAG); + + Math_ApproachF(&pthis->actor.world.pos.y, 228.0f, 0.05f, 2.0f); + Math_ApproachF(&pthis->actor.world.pos.z, -230.0f, 0.05f, 4.0f); + + sCape->backPush = -3.0f; + sCape->backSwayMagnitude = 0.25f; + sCape->sideSwayMagnitude = -3.0f; + + sin = Math_SinS(pthis->csTimer * 1500); + pthis->actor.velocity.y = pthis->fwork[GDF_FWORK_0] * sin * 0.04f; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + + cos = Math_CosS(pthis->csTimer * 1800); + pthis->actor.world.pos.x = pthis->fwork[GDF_FWORK_0] * cos * 0.5f; + pthis->actor.velocity.x = pthis->actor.world.pos.x - pthis->actor.prevPos.x; + + Math_ApproachF(&pthis->fwork[GDF_FWORK_0], 50.0f, 1.0f, 1.0f); + } + + if (pthis->csTimer > 30) { + pthis->organAlpha -= 5; + + if (pthis->organAlpha < 0) { + pthis->organAlpha = 0; + } + } + + if (pthis->csTimer == 120) { + mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); + mainCam->eye = pthis->csCamEye; + mainCam->eyeNext = pthis->csCamEye; + mainCam->at = pthis->csCamAt; + func_800C08AC(globalCtx, pthis->csCamIndex, 0); + pthis->csState = pthis->csCamIndex = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + BossGanon_SetupWait(pthis, globalCtx); + } + + if (sZelda != NULL) { + sZelda->actor.world.pos.x = 0.0f; + sZelda->actor.world.pos.y = 350.0f; + sZelda->actor.world.pos.z = 0.0f; + } + } + + if (pthis->csCamIndex != 0) { + if (moveCam) { + Math_ApproachF(&pthis->csCamEye.x, pthis->csCamTargetEye.x, pthis->csCamMovementScale, + pthis->csCamEyeMaxStep.x * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamEye.y, pthis->csCamTargetEye.y, pthis->csCamMovementScale, + pthis->csCamEyeMaxStep.y * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamEye.z, pthis->csCamTargetEye.z, pthis->csCamMovementScale, + pthis->csCamEyeMaxStep.z * pthis->csCamMaxStepScale); + + Math_ApproachF(&pthis->csCamAt.x, pthis->csCamTargetAt.x, pthis->csCamMovementScale, + pthis->csCamAtMaxStep.x * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamAt.y, pthis->csCamTargetAt.y, pthis->csCamMovementScale, + pthis->csCamAtMaxStep.y * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamAt.z, pthis->csCamTargetAt.z, pthis->csCamMovementScale, + pthis->csCamAtMaxStep.z * pthis->csCamMaxStepScale); + } + + Gameplay_CameraSetAtEye(globalCtx, pthis->csCamIndex, &pthis->csCamAt, &pthis->csCamEye); + Gameplay_CameraSetFov(globalCtx, pthis->csCamIndex, pthis->csCamFov); + } +} + +void BossGanon_SetupDeathCutscene(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 animBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME2); + + if (Object_IsLoaded(&globalCtx->objectCtx, animBankIndex)) { + pthis->actionFunc = BossGanon_DeathAndTowerCutscene; + pthis->csTimer = pthis->csState = 0; + pthis->unk_198 = 1; + pthis->animBankIndex = animBankIndex; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[animBankIndex].vromStart.get()); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_00EA00, 0.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); + pthis->unk_508 = 0.0f; + } +} + +void BossGanon_SetupTowerCutscene(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 animBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME2); + + if (Object_IsLoaded(&globalCtx->objectCtx, animBankIndex)) { + pthis->animBankIndex = animBankIndex; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[animBankIndex].vromStart.get()); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_00EA00, 0.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); + pthis->actionFunc = BossGanon_DeathAndTowerCutscene; + pthis->csTimer = 0; + pthis->csState = 100; + pthis->unk_198 = 1; + gSaveContext.magic = gSaveContext.unk_13F4; + gSaveContext.health = gSaveContext.healthCapacity; + } else { + pthis->actionFunc = BossGanon_SetupTowerCutscene; + } +} + +void BossGanon_ShatterWindows(u8 windowShatterState) { + s16 i; + u8* tex1 = SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_006C18); + u8* tex2 = SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_007418); + + for (i = 0; i < 2048; i++) { + if ((tex1[i] != 0) && (Rand_ZeroOne() < 0.03f)) { + if ((((u8*)gDorfWindowShatterTemplateTex)[i] == 0) || (windowShatterState == GDF_WINDOW_SHATTER_FULL)) { + tex1[i] = tex2[i] = 1; + } + } + } +} + +void BossGanon_DeathAndTowerCutscene(BossGanon* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 bloodPrimColor = { 0, 120, 0, 255 }; + static Color_RGBA8 bloodEnvColor = { 0, 120, 0, 255 }; + s16 i; + u8 moveCam = false; + Player* player = GET_PLAYER(globalCtx); + s16 pad; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + Vec3f sp74; + Camera* mainCam; + Vec3f sp64; + + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animBankIndex].vromStart.get()); + + pthis->csTimer++; + SkelAnime_Update(&pthis->skelAnime); + + switch (pthis->csState) { + case 0: + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->csCamIndex = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->csCamIndex, CAM_STAT_ACTIVE); + + pthis->actor.world.pos.x = 0.0f; + pthis->actor.world.pos.y = 70.0f; + pthis->actor.world.pos.z = -80.0f; + + pthis->actor.shape.yOffset = -7000.0f; + + pthis->actor.shape.rot.y = 0; + pthis->csState = 1; + pthis->csTimer = 0; + pthis->useOpenHand = true; + // fallthrough + case 1: + player->actor.shape.rot.y = -0x8000; + + player->actor.world.pos.x = -10.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 115.0f; + + pthis->envLightMode = 13; + + if (pthis->csTimer < 30) { + globalCtx->envCtx.unk_D8 = 0.0f; + } + + if (pthis->csTimer >= 2) { + globalCtx->envCtx.fillScreen = false; + } + + pthis->csCamEye.x = -50.0f; + pthis->csCamEye.z = -50.0f; + pthis->csCamEye.y = 50.0f; + + pthis->csCamAt.x = pthis->unk_1FC.x; + pthis->csCamAt.y = pthis->unk_1FC.y + 30.0f; + pthis->csCamAt.z = pthis->unk_1FC.z; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_00F19C, 0.0f); + pthis->csState = 2; + pthis->csTimer = 0; + } + break; + + case 2: + pthis->csCamEye.x = -100.0f; + pthis->csCamEye.y = 20.0f; + pthis->csCamEye.z = -130.0f; + + pthis->envLightMode = 13; + + pthis->csCamAt.x = pthis->unk_1FC.x; + pthis->csCamAt.y = pthis->unk_1FC.y; + pthis->csCamAt.z = pthis->unk_1FC.z + 40.0f; + + if (pthis->csTimer >= 30) { + pthis->csState = 3; + pthis->csTimer = 0; + Message_StartTextbox(globalCtx, 0x70CE, NULL); + pthis->fwork[GDF_FWORK_1] = 1000.0f; + } + + if ((pthis->unk_1A2 % 32) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BREATH); + } + break; + + case 3: + pthis->envLightMode = 14; + + if ((pthis->fwork[GDF_FWORK_1] > 100.0f) && ((pthis->unk_1A2 % 32) == 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BREATH); + } + + pthis->csCamEye.x = 7.0f; + pthis->csCamEye.y = 52.0f; + pthis->csCamEye.z = -15.0f; + + pthis->csCamAt.x = pthis->unk_1FC.x - 5.0f; + pthis->csCamAt.y = pthis->unk_1FC.y + 30.0f - 10.0f; + pthis->csCamAt.z = pthis->unk_1FC.z; + + if ((pthis->fwork[GDF_FWORK_1] > 100.0f) && (pthis->csTimer > 100) && + (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_00B668, 0.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00B668); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_TOKETU); + } else { + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1] - 16.0f)) { + for (i = 0; i < 40; i++) { + sp98.x = Rand_CenteredFloat(5.0f); + sp98.y = Rand_CenteredFloat(1.5f) + 1.0f; + sp98.z = Rand_ZeroFloat(5.0f) + 2.0f; + + sp8C.x = 0.0f; + sp8C.y = -1.0f; + sp8C.z = 0.0f; + + sp80.x = pthis->unk_208.x; + sp80.y = pthis->unk_208.y - 10.0f; + sp80.z = pthis->unk_208.z; + + func_8002836C(globalCtx, &sp80, &sp98, &sp8C, &bloodPrimColor, &bloodEnvColor, + (s16)Rand_ZeroFloat(50.0f) + 50, 0, 17); + } + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_00BE38, 0.0f); + pthis->csState = 4; + pthis->csTimer = 0; + } + } + break; + + case 4: + pthis->envLightMode = 14; + + if (pthis->csTimer == 30) { + Message_StartTextbox(globalCtx, 0x70CF, NULL); + pthis->csState = 5; + pthis->csTimer = 0; + } + break; + + case 5: + pthis->envLightMode = 14; + + if ((pthis->csTimer > 70) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 6; + pthis->csTimer = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_010298, 0.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_010298); + + pthis->csCamMovementScale = 0.05f; + pthis->csCamMaxStepScale = 0.0f; + + pthis->csCamTargetEye.x = 7.0f; + pthis->csCamTargetEye.y = 12.0f; + pthis->csCamTargetEye.z = 70.0f; + + pthis->csCamTargetAt.x = pthis->unk_1FC.x - 5.0f; + pthis->csCamTargetAt.y = (pthis->unk_1FC.y + 30.0f) - 10.0f; + pthis->csCamTargetAt.z = pthis->unk_1FC.z; + + pthis->csCamEyeMaxStep.x = fabsf(pthis->csCamEye.x - pthis->csCamTargetEye.x); + pthis->csCamEyeMaxStep.y = fabsf(pthis->csCamEye.y - pthis->csCamTargetEye.y); + pthis->csCamEyeMaxStep.z = fabsf(pthis->csCamEye.z - pthis->csCamTargetEye.z); + + pthis->csCamAtMaxStep.x = fabsf(pthis->csCamAt.x - pthis->csCamTargetAt.x); + pthis->csCamAtMaxStep.y = fabsf(pthis->csCamAt.y - pthis->csCamTargetAt.y); + pthis->csCamAtMaxStep.z = fabsf(pthis->csCamAt.z - pthis->csCamTargetAt.z); + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_CASBREAK); + } + break; + + case 6: + pthis->envLightMode = 14; + moveCam = true; + Math_ApproachF(&pthis->csCamMaxStepScale, 0.2f, 1.0f, 0.01f); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime2_Anim_010514, 0.0f); + pthis->csState = 7; + pthis->csTimer = 0; + pthis->unk_2E8 = 0; + pthis->envLightMode = 15; + pthis->unk_508 = 0.0f; + pthis->fwork[GDF_FWORK_1] = 1000.0f; + globalCtx->envCtx.unk_D8 = 0.0f; + } + break; + + case 7: + if (pthis->csTimer < 10) { + globalCtx->envCtx.unk_D8 = 0.0f; + } + + if (pthis->csTimer == 30) { + pthis->csState = 8; + pthis->csTimer = 0; + pthis->unk_70C = 0.0f; + } + goto skip_cam_and_quake; + + case 8: + pthis->csCamEye.x = -60.0f; + pthis->csCamEye.y = 80.0f; + pthis->csCamEye.z = -130.0f; + + pthis->csCamAt.x = 0.0f; + pthis->csCamAt.y = 0.0f; + pthis->csCamAt.z = 70.0f; + + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * 0.2f; + + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + skip_cam_and_quake: + pthis->envLightMode = 15; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BODY_SPARK - SFX_FLAG); + + for (i = 1; i < 15; i++) { + pthis->unk_4E4[i] = 0xA; + } + + pthis->unk_2E6 = 20000; + Math_ApproachF(&pthis->unk_508, 5.0f, 0.05f, 0.1f); + + if (pthis->csTimer == 30) { + pthis->csState = 9; + pthis->csTimer = 0; + + pthis->csCamEye.x = -30.0f; + pthis->csCamEye.y = 40.0f; + pthis->csCamEye.z = 60.0f; + + pthis->csCamAt.x = 492.0f; + pthis->csCamAt.y = 43.0f; + pthis->csCamAt.z = 580.0f; + + pthis->csCamMaxStepScale = 0.0f; + pthis->unk_710 = 10.0f; + } + break; + + case 9: + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BODY_SPARK - SFX_FLAG); + + if (pthis->csTimer == 2) { + func_8002DF54(globalCtx, &pthis->actor, 0x39); + } + + if (pthis->csTimer > 50) { + Math_ApproachZeroF(&pthis->unk_710, 1.0f, 0.2f); + Math_ApproachF(&pthis->csCamEye.x, 270.0f, 0.05f, pthis->csCamMaxStepScale * 30.0f); + Math_ApproachF(&pthis->csCamEye.z, 260.0f, 0.05f, pthis->csCamMaxStepScale * 20.0f); + Math_ApproachF(&pthis->csCamAt.y, 103.0f, 0.05f, pthis->csCamMaxStepScale * 6.0f); + Math_ApproachF(&pthis->csCamAt.z, 280.0f, 0.05f, pthis->csCamMaxStepScale * 20.0f); + Math_ApproachF(&pthis->csCamMaxStepScale, 1.0f, 1.0f, 0.01f); + } + + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * pthis->unk_710; + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + if (pthis->csTimer < 100) { + pthis->windowShatterState = GDF_WINDOW_SHATTER_PARTIAL; + pthis->envLightMode = 15; + } else { + pthis->envLightMode = 16; + pthis->windowShatterState = GDF_WINDOW_SHATTER_FULL; + } + + if (pthis->csTimer >= 130) { + Math_ApproachF(&pthis->whiteFillAlpha, 255.0f, 1.0f, 5.0f); + } + + if (pthis->csTimer == 180) { + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = 0x43F; + globalCtx->fadeTransition = 5; + } + break; + + case 100: + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->csCamIndex = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->csCamIndex, CAM_STAT_ACTIVE); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime2_Anim_00ADDC, 0.0f); + pthis->fwork[1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); + pthis->csState = 101; + pthis->skelAnime.playSpeed = 0.0f; + sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, + 6000.0f, 0.0f, 0, 0, 0, 0x2000); + + player->actor.world.pos.x = -472.0f; + player->actor.world.pos.y = 4102.0f; + player->actor.world.pos.z = -130.0f; + + player->actor.shape.rot.y = -0x8000; + + pthis->actor.world.pos.x = -472.0f; + pthis->actor.world.pos.y = 4172.0f; + pthis->actor.world.pos.z = -400.0f; + + pthis->actor.shape.yOffset = -7000.0f; + pthis->actor.shape.rot.y = 0; + + pthis->csCamEye.x = pthis->csCamAt.x = -472.0f; + pthis->csCamEye.y = pthis->csCamAt.y = 4152.0f; + pthis->csCamEye.z = -160.0f; + + pthis->csCamAt.z = -100.0f; + + sCape->backPush = -2.0f; + sCape->backSwayMagnitude = 0.25f; + sCape->sideSwayMagnitude = -1.0f; + sCape->minDist = 0.0f; + sCape->minY = 4104.0f; + sCape->tearTimer = 20; + + pthis->whiteFillAlpha = 255.0f; + globalCtx->envCtx.unk_D8 = 1.0f; + // fallthrough + case 101: + player->actor.world.pos.y = 4102.0f; + Math_ApproachZeroF(&pthis->whiteFillAlpha, 1.0f, 5.0f); + + if (pthis->csTimer > 40) { + Math_ApproachF(&pthis->csCamEye.z, -520.0f, 0.1f, pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamMaxStepScale, 5.0f, 1.0f, 0.1f); + + if (pthis->csTimer == 150) { + pthis->skelAnime.playSpeed = 1.0f; + } + + if (pthis->csTimer == 160) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_BOUND_NOWEAPON); + } + + if (pthis->csTimer == 187) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_BODY_HIT); + } + + if (pthis->csTimer == 180) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + } + + if (pthis->csTimer == 190) { + sp74 = pthis->actor.world.pos; + sp74.y = 4102.0f; + BossGanonEff_SpawnDustDark(globalCtx, &sp74, 0.2f, 0.7f); + } + + if (pthis->csTimer == 230) { + pthis->csState = 102; + pthis->csTimer = 0; + } + } + break; + + case 102: + player->actor.world.pos.y = 4102.0f; + + pthis->csCamEye.x = -442.0f; + pthis->csCamEye.y = 4152.0f; + pthis->csCamEye.z = -135.0f; + + pthis->csCamAt.x = -472.0f; + pthis->csCamAt.y = 4152.0f; + pthis->csCamAt.z = -135.0f; + + if (pthis->csTimer == 5) { + func_8002DF54(globalCtx, &pthis->actor, 0x4C); + } + + if (pthis->csTimer == 70) { + func_8002DF54(globalCtx, &pthis->actor, 0x4D); + } + + if (pthis->csTimer == 90) { + pthis->csState = 103; + pthis->csTimer = 0; + sZelda->actor.world.pos.x = -472.0f; + sZelda->actor.world.pos.y = 4352.0f; + sZelda->actor.world.pos.z = -200.0f; + sZelda->unk_3C8 = 3; + } + break; + + case 103: + Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_DOWN_TO_GROUND - SFX_FLAG); + Math_ApproachF(&sZelda->actor.world.pos.y, 4102.0f, 0.05f, 1.5f); + + pthis->csCamEye.x = -242.0f; + pthis->csCamEye.y = 4122.0f; + pthis->csCamEye.z = -190.0f; + + pthis->csCamAt.x = sZelda->actor.world.pos.x; + pthis->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; + pthis->csCamAt.z = sZelda->actor.world.pos.z; + + if (pthis->csTimer == 200) { + sZelda->actor.world.pos.y = 4102.0f; + pthis->csState = 104; + pthis->csTimer = 0; + } else { + break; + } + // fallthrough + case 104: + pthis->csCamEye.x = -432.0f; + pthis->csCamEye.y = 4147.0f; + pthis->csCamEye.z = -200.0f; + + pthis->csCamAt.x = sZelda->actor.world.pos.x; + pthis->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; + pthis->csCamAt.z = sZelda->actor.world.pos.z; + + if (pthis->csTimer >= 10) { + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + } + + if (pthis->csTimer == 10) { + sZelda->unk_3C8 = 8; + } + + if (pthis->csTimer == 50) { + sZelda->unk_3C8 = 4; + } + + if (pthis->csTimer == 100) { + pthis->csState = 105; + pthis->csTimer = 0; + } + break; + + case 105: + pthis->csCamEye.x = -450.0f; + pthis->csCamEye.y = 4154.0f; + pthis->csCamEye.z = -182.0f; + + pthis->csCamAt.x = sZelda->actor.world.pos.x - 5.0f; + pthis->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; + pthis->csCamAt.z = sZelda->actor.world.pos.z - 25.0f; + + if (pthis->csTimer == 10) { + Message_StartTextbox(globalCtx, 0x70D0, NULL); + } + + if ((pthis->csTimer > 100) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 1055; + pthis->csTimer = 0; + } + break; + + case 1055: + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * 0.3f; + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + if (pthis->csTimer == 20) { + sZelda->unk_3C8 = 5; + func_8002DF54(globalCtx, &pthis->actor, 0x39); + } + + if (pthis->csTimer == 40) { + pthis->csState = 1056; + pthis->csTimer = 0; + } + break; + + case 1056: + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * 0.3f; + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + pthis->csCamEye.x = -503.0f; + pthis->csCamEye.y = 4128.0f; + pthis->csCamEye.z = -162.0f; + + pthis->csCamAt.x = -416.0f; + pthis->csCamAt.y = 4181.0f; + pthis->csCamAt.z = -75.0f; + + if (pthis->csTimer > 40) { + pthis->csState = 1057; + pthis->csTimer = 0; + } + break; + + case 1057: + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * (50.0f * pthis->csCamMovementScale); + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + Math_ApproachF(&pthis->csCamEye.x, -1200.0f, 0.1f, pthis->csCamMovementScale * 697.0f); + Math_ApproachF(&pthis->csCamEye.y, 4241.0f, 0.1f, pthis->csCamMovementScale * 113.0f); + Math_ApproachF(&pthis->csCamEye.z, -1048.0f, 0.1f, pthis->csCamMovementScale * 886.0f); + + Math_ApproachF(&pthis->csCamMovementScale, 0.05f, 1.0f, 0.001f); + + if (pthis->csTimer > 80) { + pthis->csState = 106; + pthis->csTimer = 60; + } + break; + + case 106: + pthis->csCamEye.x = -450.0f; + pthis->csCamEye.y = 4154.0f; + pthis->csCamEye.z = -182.0f; + + pthis->csCamAt.x = sZelda->actor.world.pos.x - 5.0f; + pthis->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; + pthis->csCamAt.z = sZelda->actor.world.pos.z - 25.0f; + + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * 0.3f; + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + if (pthis->csTimer == 70) { + sZelda->unk_3C8 = 6; + } + + if (pthis->csTimer == 90) { + Message_StartTextbox(globalCtx, 0x70D1, NULL); + } + + if ((pthis->csTimer > 150) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->csState = 107; + pthis->csTimer = 0; + Message_StartTextbox(globalCtx, 0x70D2, NULL); + func_8002DF54(globalCtx, &pthis->actor, 0x39); + } + break; + + case 107: + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * 0.8f; + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + pthis->csCamEye.x = -380.0f; + pthis->csCamEye.y = 4154.0f; + pthis->csCamEye.z = -242.0f; + + pthis->csCamAt.x = (sZelda->actor.world.pos.x - 5.0f) - 30.0f; + pthis->csCamAt.y = (sZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; + pthis->csCamAt.z = (sZelda->actor.world.pos.z - 25.0f) + 80.0f; + + if ((pthis->csTimer > 50) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + sZelda->unk_3C8 = 7; + pthis->csState = 108; + pthis->csTimer = 0; + } + break; + + case 108: + pthis->unk_70C = Math_SinS(pthis->csTimer * 0x6300) * 0.8f; + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + pthis->csCamAt.x = (sZelda->actor.world.pos.x - 5.0f) - 30.0f; + pthis->csCamAt.y = (sZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; + pthis->csCamAt.z = (sZelda->actor.world.pos.z - 25.0f) + 80.0f; + + if (pthis->csTimer > 50) { + mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); + + mainCam->eye = pthis->csCamEye; + mainCam->eyeNext = pthis->csCamEye; + mainCam->at = pthis->csCamAt; + + func_800C08AC(globalCtx, pthis->csCamIndex, 0); + pthis->csState = 109; + pthis->csCamIndex = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + Flags_SetSwitch(globalCtx, 0x37); + } + break; + + case 109: + func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + break; + } + + if (pthis->csState >= 100) { + pthis->envLightMode = 20; + } + + if (pthis->csCamIndex != 0) { + if (moveCam) { + Math_ApproachF(&pthis->csCamEye.x, pthis->csCamTargetEye.x, pthis->csCamMovementScale, + pthis->csCamEyeMaxStep.x * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamEye.y, pthis->csCamTargetEye.y, pthis->csCamMovementScale, + pthis->csCamEyeMaxStep.y * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamEye.z, pthis->csCamTargetEye.z, pthis->csCamMovementScale, + pthis->csCamEyeMaxStep.z * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamAt.x, pthis->csCamTargetAt.x, pthis->csCamMovementScale, + pthis->csCamAtMaxStep.x * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamAt.y, pthis->csCamTargetAt.y, pthis->csCamMovementScale, + pthis->csCamAtMaxStep.y * pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamAt.z, pthis->csCamTargetAt.z, pthis->csCamMovementScale, + pthis->csCamAtMaxStep.z * pthis->csCamMaxStepScale); + } + + sp64 = pthis->csCamAt; + sp64.y += pthis->unk_70C; + Gameplay_CameraSetAtEye(globalCtx, pthis->csCamIndex, &sp64, &pthis->csCamEye); + } +} + +void BossGanon_SetupPoundFloor(BossGanon* pthis, GlobalContext* globalCtx) { + pthis->unk_1C2 = 0; + pthis->timers[0] = 40; + pthis->actionFunc = BossGanon_PoundFloor; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->fwork[GDF_CENTER_POS] = 100.0f; +} + +void BossGanon_PoundFloor(BossGanon* pthis, GlobalContext* globalCtx) { + s16 i; + f32 heightTarget; + f32 targetPosX; + f32 targetPosZ; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + Vec3f sp48; + + SkelAnime_Update(&pthis->skelAnime); + + switch (pthis->unk_1C2) { + case 0: + targetPosX = Math_SinS(pthis->unk_1A2 * 1280); + targetPosX = targetPosX * pthis->fwork[GDF_CENTER_POS]; + targetPosZ = Math_CosS(pthis->unk_1A2 * 1792); + targetPosZ = targetPosZ * pthis->fwork[GDF_CENTER_POS]; + + Math_ApproachF(&pthis->actor.world.pos.x, targetPosX, 0.05f, pthis->fwork[GDF_FWORK_0]); + Math_ApproachF(&pthis->actor.world.pos.z, targetPosZ, 0.05f, pthis->fwork[GDF_FWORK_0]); + Math_ApproachF(&pthis->fwork[GDF_CENTER_POS], 0.0f, 1, 1.5f); + + if (pthis->timers[0] == 5) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_HIT_GND); + } + + if (pthis->timers[0] < 14) { + heightTarget = 250.0f; + pthis->unk_258 += (Rand_ZeroFloat(M_PI / 2) + (M_PI / 2)); + Math_ApproachF(&pthis->handLightBallScale, 7.0f, 0.5f, 1.0f); + pthis->envLightMode = 1; + } else { + heightTarget = 200.0f; + } + + Math_ApproachF(&pthis->actor.world.pos.y, heightTarget, 0.1f, pthis->actor.velocity.y); + Math_ApproachF(&pthis->actor.velocity.y, 20.0f, 1.0f, 1.0f); + + if (pthis->timers[0] == 14) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfPoundAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfPoundAnim, 0.0f); + pthis->actor.velocity.y = 0.0f; + } + + if (pthis->timers[0] == 0) { + pthis->unk_1C2 = 1; + pthis->actor.velocity.y = 0.0f; + } + break; + + case 1: + sCape->gravity = -1.0f; + pthis->envLightMode = 1; + Math_ApproachF(&pthis->actor.velocity.y, -50.0f, 1.0f, 10.0f); + pthis->actor.world.pos.y += pthis->actor.velocity.y; + + if (pthis->actor.world.pos.y < 60.0f) { + pthis->actor.world.pos.y = 60.0f; + pthis->unk_1C2 = 2; + pthis->timers[0] = 10; + func_80033E88(&pthis->actor, globalCtx, 0xA, 0x14); // rumble + pthis->unk_19C = 35; + pthis->unk_19E = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_HIT_GND_IMP); + pthis->handLightBallScale = 0.0f; + sp60 = pthis->unk_260; + sp60.y = 0.0f; + + for (i = 0; i < 80; i++) { + sp6C.x = Rand_CenteredFloat(25.0f); + sp6C.y = Rand_ZeroFloat(17.0f); + sp6C.z = Rand_CenteredFloat(25.0f); + BossGanonEff_SpawnLightRay(globalCtx, &sp60, &sp6C, &sZeroVec, Rand_ZeroFloat(300.0f) + 500.0f, + 13.0f, 0x1E); + } + } + break; + + case 2: + pthis->envLightMode = 1; + + if (pthis->timers[0] == 0) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfPoundEndAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfPoundEndAnim, 0.0f); + pthis->unk_1C2 = 3; + pthis->unk_19F = 1; + pthis->actor.velocity.y = 0.0f; + } + break; + + case 3: + Math_ApproachF(&pthis->actor.world.pos.y, 150.0f, 0.1f, pthis->actor.velocity.y); + Math_ApproachF(&pthis->actor.velocity.y, 20.0f, 1.0f, 1.0f); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfGetUp3Anim, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + sCape->attachShouldersTimer = 18.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + pthis->unk_1C2 = 4; + } + break; + + case 4: + Math_ApproachF(&pthis->actor.world.pos.y, 150.0f, 0.1f, pthis->actor.velocity.y); + Math_ApproachF(&pthis->actor.velocity.y, 20.0f, 1.0f, 1.0f); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + BossGanon_SetupWait(pthis, globalCtx); + } + break; + } + + if ((pthis->unk_19C == 35) || (pthis->unk_19C == 30) || (pthis->unk_19C == 25)) { + sp54 = pthis->actor.world.pos; + sp54.y = 0.0f; + BossGanonEff_SpawnDustLight(globalCtx, &sp54, 0, 3.0f, pthis->unk_19C - 25); + } + + if (pthis->unk_19C == 35) { + sp48 = pthis->actor.world.pos; + sp48.y = 0.0f; + BossGanonEff_SpawnShockwave(globalCtx, &sp48, 0, 3.0f); + } +} + +void BossGanon_SetupChargeBigMagic(BossGanon* pthis, GlobalContext* globalCtx) { + pthis->unk_1C2 = 0; + pthis->timers[0] = 30; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->fwork[GDF_CENTER_POS] = 100.0f; + pthis->unk_1AA = Rand_ZeroFloat(20000.0f); + pthis->unk_1AC = 0; + pthis->actionFunc = BossGanon_ChargeBigMagic; +} + +void BossGanon_ChargeBigMagic(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 targetPosX; + f32 targetPosZ; + Vec3f sp80; + Vec3f sp74; + Vec3f sp68; + s16 i; + + SkelAnime_Update(&pthis->skelAnime); + + targetPosX = Math_SinS(pthis->unk_1A2 * 1280); + targetPosX = targetPosX * pthis->fwork[GDF_CENTER_POS]; + + targetPosZ = Math_CosS(pthis->unk_1A2 * 1792); + targetPosZ = targetPosZ * pthis->fwork[GDF_CENTER_POS]; + + Math_ApproachF(&pthis->actor.world.pos.x, targetPosX, 0.05f, pthis->fwork[GDF_FWORK_0]); + Math_ApproachF(&pthis->actor.world.pos.z, targetPosZ, 0.05, pthis->fwork[GDF_FWORK_0]); + + Math_ApproachF(&pthis->fwork[GDF_CENTER_POS], 0.0f, 1.0f, 1.5f); + Math_ApproachF(&pthis->actor.world.pos.y, 200.0f, 0.05f, pthis->actor.velocity.y); + Math_ApproachF(&pthis->actor.velocity.y, 20.0f, 1.0f, 1.0f); + + switch (pthis->unk_1C2) { + case 0: + if (pthis->timers[0] == 0) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicChargeStartAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfBigMagicChargeStartAnim, 0.0f); + pthis->unk_1C2 = 1; + } + break; + + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicChargeHoldAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfBigMagicChargeHoldAnim, 0.0f); + pthis->unk_1C2 = 2; + pthis->timers[0] = 100; + } + break; + + case 2: + pthis->envLightMode = 2; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_CHARGE_MASIC - SFX_FLAG); + pthis->unk_278.x = pthis->unk_2EC[0].x; + pthis->unk_278.y = pthis->unk_2EC[0].y + 50.0f + 30.0f; + pthis->unk_278.z = pthis->unk_2EC[0].z; + + Math_ApproachF(&pthis->unk_284, 0.25f, 0.1f, 0.006f); + Math_ApproachF(&pthis->unk_288, 255.0f, 1.0f, 255.0f); + Math_ApproachF(&pthis->unk_28C, 0.25f, 0.1f, 0.006f); + + if ((pthis->timers[0] > 20) && (pthis->timers[0] < 60)) { + Math_ApproachF(&pthis->unk_290, 255.0f, 1.0f, 15.0f); + } + + if (pthis->timers[0] == 0) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicWindupAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfBigMagicWindupAnim, 0.0f); + pthis->unk_1C2 = 3; + pthis->timers[0] = 6; + pthis->timers[1] = 15; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DARKWAVE); + break; + } + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x3E8); + + if (pthis->timers[0] < -4) { + for (i = 0; i < ARRAY_COUNT(pthis->unk_294); i++) { + Math_ApproachF(&pthis->unk_294[i], 0.0f, 1.0f, 40.0f); + } + } else if ((pthis->timers[0] >= 7) && (pthis->timers[0] < 26)) { + if (pthis->unk_1AC < ARRAY_COUNT(pthis->unk_294)) { + pthis->unk_1AC++; + } + + for (i = 0; i < pthis->unk_1AC; i++) { + Math_ApproachF(&pthis->unk_294[i], 200.0f, 1.0f, 40.0f); + } + } + + if (pthis->timers[0] <= 30) { + Math_ApproachF(&pthis->unk_284, 0.4f, 0.5f, 0.017f); + pthis->unk_28C = pthis->unk_284; + } + + if (pthis->timers[0] <= 30) { + Math_ApproachF(&pthis->unk_2D0, 45.0f, 0.1f, 10.0f); + pthis->lensFlareTimer = 1; + pthis->lensFlareMode = 2; + gCustomLensFlarePos = pthis->unk_278; + } + + if (pthis->timers[0] == 47) { + pthis->unk_274 = 1; + } + + if (pthis->timers[0] == 46) { + pthis->unk_274 = 2; + } + + if (pthis->timers[0] == 45) { + pthis->unk_274 = 3; + } + + if (pthis->timers[0] == 44) { + pthis->unk_274 = 4; + } + + if (pthis->timers[0] == 43) { + pthis->unk_274 = 5; + } + + if (pthis->timers[0] == 42) { + pthis->unk_274 = 6; + } + + if (pthis->timers[0] > 30) { + sp74.x = 0.0f; + sp74.y = Rand_ZeroFloat(10.0f) + 150.0f; + sp74.z = 0.0f; + + Matrix_RotateY(BINANG_TO_RAD(pthis->actor.yawTowardsPlayer), MTXMODE_NEW); + Matrix_RotateZ(Rand_ZeroFloat(65536.0f), MTXMODE_APPLY); + Matrix_MultVec3f(&sp74, &sp68); + + sp80.x = pthis->unk_278.x + sp68.x; + sp80.y = pthis->unk_278.y + sp68.y; + sp80.z = pthis->unk_278.z + sp68.z; + + BossGanonEff_SpawnBlackDot(globalCtx, &sp80, 20.0f); + } + break; + + case 3: + pthis->envLightMode = 2; + + for (i = 0; i < ARRAY_COUNT(pthis->unk_294); i++) { + Math_ApproachF(&pthis->unk_294[i], 0.0f, 1.0f, 40.0f); + } + + if (pthis->timers[0] == 1) { + sCape->attachLeftArmTimer = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + } + + if (pthis->timers[0] == 0) { + Math_ApproachZeroF(&pthis->unk_284, 1.0f, 0.08f); + pthis->unk_28C = pthis->unk_284; + Math_ApproachZeroF(&pthis->unk_2D0, 1.0f, 10.0f); + Math_ApproachF(&pthis->unk_278.x, pthis->unk_1FC.x, 0.5f, 30.0f); + Math_ApproachF(&pthis->unk_278.y, pthis->unk_1FC.y, 0.5f, 30.0f); + Math_ApproachF(&pthis->unk_278.z, pthis->unk_1FC.z, 0.5f, 30.0f); + } + + if (pthis->timers[1] == 0) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicThrowAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfBigMagicThrowAnim, 0.0f); + pthis->unk_1C2 = 4; + pthis->unk_288 = 0.0f; + pthis->unk_290 = 0.0f; + pthis->unk_284 = 0.0f; + pthis->unk_28C = 0.0f; + } + break; + + case 4: + pthis->envLightMode = 2; + + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + for (i = 0; i < 5; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_GANON, pthis->unk_1FC.x, + pthis->unk_1FC.y, pthis->unk_1FC.z, 0, pthis->actor.yawTowardsPlayer, 0, 0x104 + i); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BIGMASIC); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_THROW_BIG); + } + + if (Animation_OnFrame(&pthis->skelAnime, 3.0f)) { + sCape->attachShouldersTimer = 26.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicThrowEndAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfBigMagicThrowEndAnim, 0.0f); + pthis->unk_1C2 = 5; + } + break; + + case 5: + pthis->envLightMode = 2; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + BossGanon_SetupWait(pthis, globalCtx); + } + break; + } +} + +void BossGanon_SetupWait(BossGanon* pthis, GlobalContext* globalCtx) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfFloatAnim, -10.0f); + pthis->actionFunc = BossGanon_Wait; + pthis->fwork[GDF_FWORK_0] = 0.0f; + pthis->timers[0] = (s16)Rand_ZeroFloat(64.0f) + 30; + pthis->unk_1C2 = 0; + sCape->minY = 2.0f; +} + +void BossGanon_Wait(BossGanon* pthis, GlobalContext* globalCtx) { + f32 sin; + s32 pad; + f32 cos; + Player* player = GET_PLAYER(globalCtx); + + pthis->legSwayEnabled = true; + + sCape->backPush = -3.0f; + sCape->backSwayMagnitude = 0.25f; + sCape->sideSwayMagnitude = -3.0f; + sCape->minDist = 20.0f; + + SkelAnime_Update(&pthis->skelAnime); + + if ((pthis->unk_1C2 == 0) && !(player->actor.world.pos.y < 0.0f)) { + if (!(player->stateFlags1 & 0x2000) && (fabsf(player->actor.world.pos.x) < 110.0f) && + (fabsf(player->actor.world.pos.z) < 110.0f)) { + BossGanon_SetupPoundFloor(pthis, globalCtx); + } else if ((pthis->timers[0] == 0) && !(player->stateFlags1 & 0x2000)) { + pthis->timers[0] = (s16)Rand_ZeroFloat(30.0f) + 30; + + if ((s8)pthis->actor.colChkInfo.health >= 20) { + BossGanon_SetupChargeLightBall(pthis, globalCtx); + } else if (Rand_ZeroOne() >= 0.5f) { + if ((Rand_ZeroOne() >= 0.5f) || (pthis->actor.xzDistToPlayer > 350.0f)) { + BossGanon_SetupChargeBigMagic(pthis, globalCtx); + } else { + BossGanon_SetupPoundFloor(pthis, globalCtx); + } + } else { + BossGanon_SetupChargeLightBall(pthis, globalCtx); + } + } + } + + sin = Math_SinS(pthis->unk_1A2 * 1280) * 100.0f; + cos = Math_CosS(pthis->unk_1A2 * 1792) * 100.0f; + + Math_ApproachF(&pthis->actor.world.pos.x, sin, 0.05f, pthis->fwork[GDF_FWORK_0]); + Math_ApproachF(&pthis->actor.world.pos.y, 150.0f, 0.05f, pthis->fwork[GDF_FWORK_0] * 0.2f); + Math_ApproachF(&pthis->actor.world.pos.z, cos, 0.05f, pthis->fwork[GDF_FWORK_0]); + Math_ApproachF(&pthis->fwork[GDF_FWORK_0], 50.0f, 1.0f, 0.5f); + + pthis->actor.velocity.x = pthis->actor.world.pos.x - pthis->actor.prevPos.x; + pthis->actor.velocity.z = pthis->actor.world.pos.z - pthis->actor.prevPos.z; + + sin = Math_SinS(pthis->unk_1A2 * 1500); + pthis->actor.velocity.y = pthis->fwork[GDF_FWORK_0] * sin * 0.04f; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0xBB8); + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); +} + +void BossGanon_SetupChargeLightBall(BossGanon* pthis, GlobalContext* globalCtx) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfChargeLightBallAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfChargeLightBallAnim, -3.0f); + pthis->actionFunc = BossGanon_ChargeLightBall; + pthis->timers[0] = 25; +} + +void BossGanon_ChargeLightBall(BossGanon* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + sCape->backPush = -3.0f; + sCape->backSwayMagnitude = 1.25f; + sCape->sideSwayMagnitude = -2.0f; + sCape->minDist = 10.0f; + + if (pthis->timers[0] < 17) { + pthis->envLightMode = 1; + } + + if (pthis->timers[0] == 17) { + pthis->unk_26C = 10; + pthis->unk_270 = Rand_ZeroFloat(M_PI); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_SPARK); + } + + if (pthis->timers[0] < 10) { + pthis->unk_258 += (Rand_ZeroFloat(M_PI / 2) + (M_PI / 2)); + Math_ApproachF(&pthis->handLightBallScale, 10.0f, 0.5f, 1.25f); + + if (pthis->timers[0] == 0) { + BossGanon_SetupPlayTennis(pthis, globalCtx); + } + } + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x7D0); + + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + + Math_ApproachZeroF(&pthis->actor.velocity.x, 1.0f, 0.5f); + Math_ApproachZeroF(&pthis->actor.velocity.z, 1.0f, 0.5f); + + pthis->actor.velocity.y = Math_SinS(pthis->unk_1A2 * 1500) * 2.0f; + pthis->actor.world.pos.y += pthis->actor.velocity.y; +} + +void BossGanon_SetupPlayTennis(BossGanon* pthis, GlobalContext* globalCtx) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfThrowAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfThrowAnim, 0.0f); + pthis->actionFunc = BossGanon_PlayTennis; +} + +void BossGanon_PlayTennis(BossGanon* pthis, GlobalContext* globalCtx) { + static AnimationHeader* volleyAnims[] = { &gDorfVolleyLeftAnim, &gDorfVolleyRightAnim }; + static s16 capeRightArmDurations[] = { 26, 20 }; + s16 rand; + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->handLightBallScale, 1.0f, 0.2f); + + switch (pthis->unk_1C2) { + case 0: + pthis->envLightMode = 1; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->unk_1C2 = 1; + Animation_MorphToLoop(&pthis->skelAnime, &gDorfFloatAnim, 0.0f); + } + + if (pthis->skelAnime.curFrame <= 12.0f) { + pthis->lensFlareTimer = 2; + pthis->lensFlareMode = 2; + gCustomLensFlarePos = pthis->unk_260; + } + + if (Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + pthis->handLightBallScale = 0.0f; + } + + if (Animation_OnFrame(&pthis->skelAnime, 11.0f)) { + pthis->unk_25C = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_THROW); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_THROW_MASIC); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_GANON, pthis->unk_260.x, + pthis->unk_260.y, pthis->unk_260.z, 0, 0, 0, 0x64); + } + break; + + case 1: + if (pthis->startVolley) { + rand = Rand_ZeroOne() * 1.99f; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(volleyAnims[rand]); + Animation_MorphToPlayOnce(&pthis->skelAnime, volleyAnims[rand], 0.0f); + sCape->attachRightArmTimer = capeRightArmDurations[rand]; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + pthis->startVolley = false; + } + break; + } + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x7D0); + + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + + Math_SmoothStepToF(&pthis->actor.velocity.x, 0.0f, 1.0f, 0.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.velocity.z, 0.0f, 1.0f, 0.5f, 0.0f); + + pthis->actor.velocity.y = Math_SinS(pthis->unk_1A2 * 1500) * 2.0f; + pthis->actor.world.pos.y += pthis->actor.velocity.y; +} + +void BossGanon_SetupBlock(BossGanon* pthis, GlobalContext* globalCtx) { + if ((pthis->actionFunc != BossGanon_Block) || (pthis->unk_1C2 != 0)) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBlockAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfBlockAnim, 0.0f); + pthis->actionFunc = BossGanon_Block; + } + + pthis->unk_1C2 = 0; + sCape->attachLeftArmTimer = pthis->timers[0] = 10; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + pthis->handLightBallScale = 0.0f; +} + +void BossGanon_Block(BossGanon* pthis, GlobalContext* globalCtx) { + pthis->collider.base.colType = 9; + SkelAnime_Update(&pthis->skelAnime); + sCape->backPush = -9.0f; + sCape->backSwayMagnitude = 0.25f; + sCape->sideSwayMagnitude = -2.0f; + sCape->minDist = 13.0f; + + if (pthis->unk_1C2 == 0) { + if (pthis->timers[0] == 0) { + pthis->unk_1C2 = 1; + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfBlockReleaseAnim, 0.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBlockReleaseAnim); + SkelAnime_Update(&pthis->skelAnime); + sCape->attachShouldersTimer = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + } + } else { + sCape->sideSwayMagnitude = -13.0f; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + BossGanon_SetupWait(pthis, globalCtx); + } + } + + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + + Math_ApproachZeroF(&pthis->actor.velocity.x, 1.0f, 0.5f); + Math_ApproachZeroF(&pthis->actor.velocity.y, 1.0f, 0.5f); + Math_ApproachZeroF(&pthis->actor.velocity.z, 1.0f, 0.5f); +} + +void BossGanon_SetupHitByLightBall(BossGanon* pthis, GlobalContext* globalCtx) { + s16 i; + + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicHitAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfBigMagicHitAnim, 0); + pthis->timers[0] = 70; + sCape->attachRightArmTimer = sCape->attachLeftArmTimer = 0; + + for (i = 1; i < 15; i++) { + pthis->unk_4E4[i] = D_808E4C58[i]; + } + + pthis->unk_2E6 = 80; + pthis->unk_2E8 = 0; + pthis->actionFunc = BossGanon_HitByLightBall; + pthis->actor.velocity.x = pthis->actor.velocity.z = 0.0f; + pthis->unk_1C2 = 0; + pthis->unk_1A6 = 15; + pthis->unk_508 = 6.0f; +} + +void BossGanon_HitByLightBall(BossGanon* pthis, GlobalContext* globalCtx) { + s16 i; + Vec3f sp50; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_1C2 == 0) { + BossGanonEff_SpawnShock(globalCtx, 1500.0f, GDF_SHOCK_DORF_YELLOW); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightArrowWaitAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfLightArrowWaitAnim, 0.0f); + pthis->unk_1C2 = 1; + } + } else if (pthis->unk_1C2 == 1) { + BossGanonEff_SpawnShock(globalCtx, 1000.0f, GDF_SHOCK_DORF_YELLOW); + + if (pthis->timers[0] == 0) { + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfGetUp3Anim, 0.0f); + pthis->unk_1C2 = 2; + SkelAnime_Update(&pthis->skelAnime); + sCape->attachShouldersTimer = 18.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_RESTORE); + pthis->timers[2] = 130; + } + } else { + if (Animation_OnFrame(&pthis->skelAnime, 7.0f)) { + for (i = 0; i < 100; i++) { + sp50.x = Rand_CenteredFloat(25.0f); + sp50.y = Rand_CenteredFloat(25.0f); + sp50.z = Rand_CenteredFloat(25.0f); + + BossGanonEff_SpawnSparkle(globalCtx, &pthis->unk_1FC, &sp50, &sZeroVec, Rand_ZeroFloat(200.0f) + 500.0f, + 0x14); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_WALK_WATER2); + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + BossGanon_SetupWait(pthis, globalCtx); + } + } + + pthis->actor.velocity.y = Math_SinS(pthis->unk_1A2 * 1500) * 2.0f; + pthis->actor.world.pos.y += pthis->actor.velocity.y; +} + +void BossGanon_SetupVulnerable(BossGanon* pthis, GlobalContext* globalCtx) { + s16 i; + + if (pthis->actionFunc != BossGanon_Vulnerable) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightArrowHitAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfLightArrowHitAnim, 0.0f); + sCape->attachRightArmTimer = sCape->attachLeftArmTimer = 0; + pthis->actionFunc = BossGanon_Vulnerable; + + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.velocity.z = 0.0f; + + pthis->unk_1C2 = 0; + sCape->backPush = -4.0f; + sCape->backSwayMagnitude = 0.75f; + sCape->sideSwayMagnitude = -3.0f; + sCape->minDist = 20.0f; + + for (i = 0; i < 10; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_GANON, pthis->unk_1FC.x, + pthis->unk_1FC.y, pthis->unk_1FC.z, Rand_CenteredFloat(0x8000), + (s16)Rand_CenteredFloat(0x8000) + pthis->actor.yawTowardsPlayer, 0, 0xC8 + i); + } + + pthis->unk_1A4 = 0; + pthis->unk_288 = 0.0f; + pthis->unk_290 = 0.0f; + pthis->unk_284 = 0.0f; + pthis->unk_28C = 0.0f; + } +} + +void BossGanon_Vulnerable(BossGanon* pthis, GlobalContext* globalCtx) { + s16 i; + Vec3f sp40; + + if (pthis->timers[3] == 0) { + pthis->actor.flags |= ACTOR_FLAG_0; + } + + SkelAnime_Update(&pthis->skelAnime); + + pthis->envLightMode = 1; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + + if (pthis->unk_1A4 < 0x28) { + Math_ApproachF(&pthis->unk_508, 4.0f, 0.1f, 0.1f); + } + + if ((pthis->unk_1A4 >= 0x28) && (pthis->unk_1A4 < 0x37)) { + Math_ApproachF(&pthis->unk_508, 0.0f, 1.0f, 0.5f); + } + + if (pthis->unk_1A4 >= 0x37) { + Math_ApproachF(&pthis->unk_508, 5.0f, 0.1f, 0.15f); + pthis->shockGlow = true; + } + + switch (pthis->unk_1C2) { + case 0: + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->unk_1C2 = 1; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightEnergyHitAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfLightEnergyHitAnim, 0.0f); + } + break; + + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->unk_1C2 = 2; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfKneelVulnerableAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfKneelVulnerableAnim, 0.0f); + } + break; + + case 2: + sCape->minDist = 0.0f; + pthis->actor.velocity.y = pthis->actor.velocity.y - 0.5f; + + if (pthis->actor.world.pos.y < 40.0f) { + pthis->actor.world.pos.y = 40.0f; + pthis->actor.velocity.y = 0.0f; + pthis->unk_1C2 = 3; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLandAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfLandAnim, 0.0f); + pthis->timers[0] = 70; + pthis->actor.flags |= ACTOR_FLAG_10; + } + break; + + case 3: + if (pthis->timers[0] == 68) { + pthis->unk_19F = 1; + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->unk_1C2 = 4; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfVulnerableAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfVulnerableAnim, 0.0f); + } + break; + + case 4: + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DOWN); + } + + if (pthis->timers[0] == 0) { + pthis->unk_1C2 = 5; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp1Anim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfGetUp1Anim, 0.0f); + pthis->unk_2D4 = 80; + + for (i = 1; i < 15; i++) { + pthis->unk_4E4[i] = Rand_ZeroFloat(10.0f); + } + + pthis->unk_2E6 = 80; + pthis->unk_2E8 = 0; + pthis->actor.flags &= ~ACTOR_FLAG_10; + } + break; + + case 5: + BossGanonEff_SpawnShock(globalCtx, 1000.0f, GDF_SHOCK_DORF_YELLOW); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->unk_1C2 = 6; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp2Anim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfGetUp2Anim, 0.0f); + sCape->minDist = 20.0f; + pthis->unk_19F = 1; + } + break; + + case 6: + pthis->envLightMode = 0; + Math_ApproachF(&pthis->actor.world.pos.y, 200.0f, 0.1f, 1000.0f); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->unk_1C2 = 7; + } + break; + + case 7: + pthis->envLightMode = 0; + Math_ApproachF(&pthis->actor.world.pos.y, 150.0f, 0.05f, 30.0f); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfGetUp3Anim, 0.0f); + pthis->unk_1C2 = 8; + SkelAnime_Update(&pthis->skelAnime); + sCape->attachShouldersTimer = 18.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_MANTLE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_RESTORE); + break; + + case 8: + pthis->envLightMode = 0; + + if (Animation_OnFrame(&pthis->skelAnime, 7.0f)) { + for (i = 0; i < 100; i++) { + sp40.x = Rand_CenteredFloat(25.0f); + sp40.y = Rand_CenteredFloat(25.0f); + sp40.z = Rand_CenteredFloat(25.0f); + BossGanonEff_SpawnSparkle(globalCtx, &pthis->unk_1FC, &sp40, &sZeroVec, + Rand_ZeroFloat(200.0f) + 500.0f, 0x14); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_WALK_WATER2); + pthis->timers[3] = 50; + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + BossGanon_SetupWait(pthis, globalCtx); + } + break; + } +} + +void BossGanon_SetupDamaged(BossGanon* pthis, GlobalContext* globalCtx) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfDamageAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDorfDamageAnim, 0.0f); + pthis->actionFunc = BossGanon_Damaged; +} + +void BossGanon_Damaged(BossGanon* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_0; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_1A4 >= 0x37) { + Math_ApproachF(&pthis->unk_508, 5.0f, 0.1f, 0.15f); + pthis->shockGlow = true; + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GDF_FWORK_1])) { + pthis->actionFunc = BossGanon_Vulnerable; + pthis->unk_1C2 = 4; + pthis->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfVulnerableAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gDorfVulnerableAnim, 0.0f); + } +} + +void BossGanon_UpdateDamage(BossGanon* pthis, GlobalContext* globalCtx) { + s16 i; + s16 j; + ColliderInfo* acHitInfo; + + if (pthis->collider.base.acFlags & 2) { + pthis->unk_2D4 = 2; + pthis->collider.base.acFlags &= ~2; + acHitInfo = pthis->collider.info.acHitInfo; + + if ((pthis->actionFunc == BossGanon_HitByLightBall) || (pthis->actionFunc == BossGanon_ChargeBigMagic)) { + if (acHitInfo->toucher.dmgFlags & 0x2000) { + BossGanon_SetupVulnerable(pthis, globalCtx); + pthis->timers[2] = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DAMAGE1); + pthis->unk_1A6 = 15; + } + } else if ((pthis->actionFunc == BossGanon_Vulnerable) && (pthis->unk_1C2 >= 3)) { + if (!(acHitInfo->toucher.dmgFlags & 0x80)) { + u8 hitWithSword = false; + u8 damage; + Vec3f sp50; + u32 flags; + + for (i = 0; i < 30; i++) { + sp50.x = Rand_CenteredFloat(20.0f); + sp50.y = Rand_CenteredFloat(20.0f); + sp50.z = Rand_CenteredFloat(20.0f); + BossGanonEff_SpawnSparkle(globalCtx, &pthis->unk_1FC, &sp50, &sZeroVec, + Rand_ZeroFloat(200.0f) + 500.0f, 0x1E); + } + + damage = flags = CollisionCheck_GetSwordDamage(acHitInfo->toucher.dmgFlags); + + if (flags == 0) { + damage = 2; + } else { + hitWithSword = true; + } + + if (((s8)pthis->actor.colChkInfo.health >= 3) || hitWithSword) { + pthis->actor.colChkInfo.health -= damage; + } + + for (i = 0; i < ARRAY_COUNT(sCape->strands); i++) { + for (j = 1; j < 12; j++) { + sCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); + sCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); + } + } + + if ((s8)pthis->actor.colChkInfo.health <= 0) { + BossGanon_SetupDeathCutscene(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DEAD); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DD_THUNDER); + func_80078914(&sZeroVec, NA_SE_EN_LAST_DAMAGE); + Audio_QueueSeqCmd(0x100100FF); + pthis->screenFlashTimer = 4; + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_DAMAGE2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_CUTBODY); + BossGanon_SetupDamaged(pthis, globalCtx); + pthis->unk_1A6 = 15; + sCape->tearTimer = 1; + } + } + } else if (acHitInfo->toucher.dmgFlags & 0x1F8A4) { + Audio_PlayActorSound2(&pthis->actor, 0); + + for (i = 0; i < ARRAY_COUNT(sCape->strands); i++) { + for (j = 1; j < 12; j++) { + sCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); + sCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); + } + } + } + } +} + +static f32 D_808E4D44[] = { + 1.0f, 3.0f, 0.0f, 7.0f, 13.0f, 4.0f, 6.0f, 11.0f, 5.0f, 2.0f, 8.0f, 14.0f, 10.0f, 12.0f, 9.0f, +}; + +void BossGanon_Update(Actor* thisx, GlobalContext* globalCtx2) { + BossGanon* pthis = (BossGanon*)thisx; + GlobalContext* globalCtx = globalCtx2; + f32 legRotX; + f32 legRotY; + f32 legRotZ; + Player* player = GET_PLAYER(globalCtx); + s16 i; + f32 sin; + f32 cos; + Vec3f shardPos; + Vec3f shardVel; + Vec3f spE8; + s16 i2; + s16 j; + Vec3f spD8; + Vec3f platformCheckPos; + Actor* explosive; + Vec3f spBC; + Vec3f spB0; + Vec3f platCheckPosBomb; + Actor* prop; + BgGanonOtyuka* platform; + f32 targetLensFlareScale; + f32 xOffset; + f32 zOffset; + + if ((pthis->actionFunc != BossGanon_IntroCutscene) && (pthis->actionFunc != BossGanon_DeathAndTowerCutscene)) { + BossGanon_SetAnimationObject(pthis, globalCtx, OBJECT_GANON_ANIME1); + } else { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animBankIndex].vromStart.get()); + } + + if (pthis->windowShatterState != GDF_WINDOW_SHATTER_OFF) { + BossGanon_ShatterWindows(pthis->windowShatterState); + shardVel.y = 0.0f; + + for (i = 0; i < 10; i++) { + shardPos.y = Rand_ZeroFloat(240.0f) + 20.0f; + + if (Rand_ZeroOne() < 0.5f) { + shardPos.x = 463; + shardPos.z = Rand_ZeroFloat(463.0f); + + shardVel.x = Rand_ZeroFloat(2.0f); + shardVel.z = Rand_ZeroFloat(1.0f); + } else { + shardPos.z = 463; + shardPos.x = Rand_ZeroFloat(463.0f); + + shardVel.z = Rand_ZeroFloat(2.0f); + shardVel.x = Rand_ZeroFloat(1.0f); + } + + BossGanonEff_SpawnWindowShard(globalCtx, &shardPos, &shardVel, Rand_ZeroFloat(0.075f) + 0.08f); + } + } + + pthis->collider.base.colType = 3; + sCape->gravity = -3.0f; + pthis->shockGlow = false; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_1A2++; + pthis->unk_1A4++; + + // block players attack if hes shooting something + if ((pthis->actionFunc == BossGanon_Wait) || (pthis->actionFunc == BossGanon_Block)) { + if (player->unk_A73 != 0) { + BossGanon_SetupBlock(pthis, globalCtx); + } + } + + pthis->actionFunc(pthis, globalCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + + if (pthis->unk_1A6 != 0) { + pthis->unk_1A6--; + } + + if (pthis->unk_2D4 != 0) { + pthis->unk_2D4--; + } + + if (pthis->unk_2E8 != 0) { + pthis->unk_2E8--; + } + + if (pthis->unk_2E6 != 0) { + pthis->unk_2E6--; + } + + if (pthis->unk_19C != 0) { + pthis->unk_19C--; + } + + if (pthis->csState == 0) { + BossGanon_UpdateDamage(pthis, globalCtx); + BossGanon_SetColliderPos(&pthis->unk_1FC, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->unk_2D4 == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if ((pthis->actionFunc != BossGanon_HitByLightBall) && (pthis->actionFunc != BossGanon_Vulnerable) && + (pthis->actionFunc != BossGanon_Damaged)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + } + + if (pthis->legSwayEnabled) { + sin = Math_SinS(-pthis->actor.shape.rot.y); + cos = Math_CosS(-pthis->actor.shape.rot.y); + + legRotX = ((pthis->actor.velocity.z * sin) + (cos * pthis->actor.velocity.x)) * 300.0f; + legRotY = ((-sin * pthis->actor.velocity.x) + (cos * pthis->actor.velocity.z)) * 300.0f; + legRotZ = (Math_SinS(pthis->unk_1A2 * 2268) * -500.0f) - 500.0f; + } else { + legRotY = legRotX = legRotZ = 0.0f; + } + + pthis->legSwayEnabled = false; + + Math_SmoothStepToF(&pthis->legRot.x, legRotX, 1.0f, 600.0f, 0.0f); + Math_SmoothStepToF(&pthis->legRot.y, legRotY, 1.0f, 600.0f, 0.0f); + Math_SmoothStepToF(&pthis->legRot.z, legRotZ, 1.0f, 100.0f, 0.0f); + + if (pthis->timers[2] == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_LAUGH); + } + + if (pthis->timers[2] == 100) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_ST_LAUGH); + pthis->timers[2] = 0; + } + + if ((pthis->unk_2E6 != 0) || (pthis->unk_2E8 != 0)) { + for (i = 1; i < ARRAY_COUNT(pthis->unk_49C); i++) { + if (pthis->unk_4E4[i] != 0) { + pthis->unk_4E4[i]--; + Math_ApproachF(&pthis->unk_49C[i], pthis->unk_508, 1.0f, 2.0f); + } else { + Math_ApproachZeroF(&pthis->unk_49C[i], 1.0f, 0.2f); + } + } + + // player hit, spawn shock and play sound + if (pthis->unk_2E8 != 0) { + func_80078914(&player->actor.projectedPos, NA_SE_PL_SPARK - SFX_FLAG); + BossGanonEff_SpawnShock(globalCtx, 700.0f, GDF_SHOCK_PLAYER_YELLOW); + } + } + + if (pthis->unk_19F != 0) { + pthis->unk_19F = 0; + spE8 = pthis->actor.world.pos; + spE8.y = 0.0f; + BossGanonEff_SpawnDustDark(globalCtx, &spE8, 0.2, 0.7f); + BossGanonEff_SpawnDustDark(globalCtx, &spE8, 0.3f, 0.8f); + } + + if (pthis->unk_26C != 0) { + pthis->unk_26C--; + + if (pthis->unk_26C == 0) { + BossGanonEff_SpawnLightning(globalCtx, 1.0f, 0.0f, 0.0f); + } + + BossGanonEff_SpawnLightning(globalCtx, 1.0f, D_808E4D44[pthis->unk_26C] * (M_PI / 5) + pthis->unk_270, + Rand_CenteredFloat(M_PI / 5) + (M_PI / 2)); + } + + // see if light ball hit and should knock platform down? + if ((pthis->unk_19C != 0) && (pthis->unk_19E < 4)) { + if ((pthis->unk_19A == 0) && (pthis->unk_19C == 20)) { + pthis->unk_19A = 1; + platformCheckPos.x = -180.0f; + platformCheckPos.y = 0.0f; + + for (i2 = 0; i2 < 4; i2++) { + for (j = 0, platformCheckPos.z = -180.0f; j < 4; j++) { + BossGanon_CheckFallingPlatforms(pthis, globalCtx, &platformCheckPos); + platformCheckPos.z += 120.0f; + } + + platformCheckPos.x += 120.0f; + } + } else if (pthis->unk_19C < 30) { + spD8.x = 0.0f; + spD8.y = 0.0f; + spD8.z = 15.0f * (30.0f - pthis->unk_19C); + + Matrix_RotateY(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); + Matrix_MultVec3f(&spD8, &platformCheckPos); + + pthis->unk_19E += BossGanon_CheckFallingPlatforms(pthis, globalCtx, &platformCheckPos); + } + } + + // see if a bomb exploded near a group of platforms and if they should fall + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; + + while (explosive != NULL) { + if (explosive->params != BOMB_EXPLOSION) { + explosive = explosive->next; + } else { + for (i = 0; i < 8; i++) { + spBC.x = 0.0f; + spBC.y = 0.0f; + spBC.z = 60.0f; + + Matrix_RotateY(i * (M_PI / 4), MTXMODE_NEW); + Matrix_MultVec3f(&spBC, &spB0); + + platCheckPosBomb.x = explosive->world.pos.x + spB0.x; + platCheckPosBomb.y = explosive->world.pos.y; + platCheckPosBomb.z = explosive->world.pos.z + spB0.z; + + BossGanon_CheckFallingPlatforms(pthis, globalCtx, &platCheckPosBomb); + } + + explosive = explosive->next; + } + } + + BossGanon_UpdateEffects(globalCtx); + + prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + + // if a platform is lit up, change the room lighting + while (prop != NULL) { + if (prop->id != ACTOR_BG_GANON_OTYUKA) { + prop = prop->next; + } else { + platform = (BgGanonOtyuka*)prop; + + if (platform->flashState != 0) { + pthis->envLightMode = 1; + break; + } + + prop = prop->next; + } + } + + globalCtx->envCtx.unk_BF = 0; + globalCtx->envCtx.unk_BE = 0; + globalCtx->envCtx.unk_DC = 2; + + switch (pthis->envLightMode) { + case -1: + break; + case 0: + Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.0f, 1.0f, 0.02f); + break; + case 1: + globalCtx->envCtx.unk_BD = 1; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.1f); + break; + case 2: + globalCtx->envCtx.unk_BD = 1; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.02f); + break; + case 3: + globalCtx->envCtx.unk_BD = 3; + globalCtx->envCtx.unk_D8 = 1.0f; + break; + case 35: + globalCtx->envCtx.unk_BD = 0; + globalCtx->envCtx.unk_D8 = 1.0f; + break; + case 4: + globalCtx->envCtx.unk_BD = 4; + globalCtx->envCtx.unk_D8 = 1.0f; + break; + case 5: + globalCtx->envCtx.unk_BE = 5; + globalCtx->envCtx.unk_BD = 3; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.075f); + break; + case 6: + globalCtx->envCtx.unk_BE = 5; + globalCtx->envCtx.unk_D8 = 0.0f; + break; + case 65: + globalCtx->envCtx.unk_BE = 3; + globalCtx->envCtx.unk_BD = 6; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + break; + case 7: + globalCtx->envCtx.unk_BE = 7; + globalCtx->envCtx.unk_D8 = 0.0f; + break; + case 75: + globalCtx->envCtx.unk_BE = 4; + globalCtx->envCtx.unk_BD = 8; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + break; + case 8: + globalCtx->envCtx.unk_BE = 3; + globalCtx->envCtx.unk_BD = 9; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); + break; + case 9: + globalCtx->envCtx.unk_BE = 3; + globalCtx->envCtx.unk_BD = 0xA; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + break; + case 10: + globalCtx->envCtx.unk_BE = 3; + globalCtx->envCtx.unk_BD = 0xB; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); + pthis->unk_1A4 = 0; + break; + case 11: + globalCtx->envCtx.unk_BE = 0xC; + globalCtx->envCtx.unk_BD = 0xB; + Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_CosS(pthis->unk_1A4 * 0x1800) * 0.5f) + 0.5f, 1.0f, 1.0f); + break; + case 12: + globalCtx->envCtx.unk_BE = 0xC; + globalCtx->envCtx.unk_BD = 3; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.05f); + break; + case 13: + globalCtx->envCtx.unk_BD = 0xD; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.025f); + break; + case 14: + globalCtx->envCtx.unk_BD = 0xE; + globalCtx->envCtx.unk_D8 = 1.0f; + break; + case 15: + globalCtx->envCtx.unk_BE = 0xE; + globalCtx->envCtx.unk_BD = 0xF; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.01f); + break; + case 16: + globalCtx->envCtx.unk_BE = 0x10; + globalCtx->envCtx.unk_BD = 0xF; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + break; + case 20: + globalCtx->envCtx.unk_BE = 2; + globalCtx->envCtx.unk_BD = 1; + break; + default: + break; + } + + pthis->envLightMode = 0; + + if (pthis->whiteFillAlpha != 0) { + globalCtx->envCtx.screenFillColor[3] = (s8)(u8)pthis->whiteFillAlpha; + globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = + globalCtx->envCtx.screenFillColor[2] = 255; + globalCtx->envCtx.fillScreen = true; + } else if (pthis->screenFlashTimer != 0) { + globalCtx->envCtx.fillScreen = true; + globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = + globalCtx->envCtx.screenFillColor[2] = 255; + + globalCtx->envCtx.screenFillColor[3] = ((pthis->screenFlashTimer % 2) != 0) ? 100 : 0; + + pthis->screenFlashTimer--; + } else { + globalCtx->envCtx.fillScreen = globalCtx->envCtx.screenFillColor[3] = 0; + } + + if (pthis->lensFlareTimer != 0) { + pthis->lensFlareTimer--; + + if (pthis->lensFlareMode == 1) { + targetLensFlareScale = 40.0f; + } else if (pthis->lensFlareMode == 4) { + targetLensFlareScale = 25.0f; + } else { + targetLensFlareScale = 10.0f; + } + + Math_ApproachF(&pthis->lensFlareScale, targetLensFlareScale, 0.3f, 10.0f); + } else { + Math_ApproachZeroF(&pthis->lensFlareScale, 1.0f, 5.0f); + + if (pthis->lensFlareScale == 0.0f) { + pthis->lensFlareMode = 0; + } + } + + if (pthis->lensFlareMode != 0) { + gCustomLensFlareOn = true; + + if (pthis->lensFlareMode == 1) { + gCustomLensFlarePos = pthis->actor.world.pos; + } + + gLensFlareScale = pthis->lensFlareScale; + gLensFlareColorIntensity = 10.0f; + gLensFlareScreenFillAlpha = 0; + } else { + gCustomLensFlareOn = false; + } + + if (pthis->unk_274 != 0) { + i = pthis->unk_274 - 1; + + pthis->unk_278.x = pthis->unk_2EC[0].x; + pthis->unk_278.y = pthis->unk_2EC[0].y + 50.0f + 30.0f; + pthis->unk_278.z = pthis->unk_2EC[0].z; + + xOffset = (sinf(i * 1.2566371f) * 600.0f); + zOffset = (cosf(i * 1.2566371f) * 600.0f); + + // 5 or 6 light balls that go into the charge. not the same as the ones that he throws + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_GANON, pthis->unk_1FC.x + xOffset, + pthis->unk_1FC.y, pthis->unk_1FC.z + zOffset, 0, (s16)(i * 13107.2f) + 0x6000, 0, 0xFA + i); + pthis->unk_274 = 0; + } +} + +s32 BossGanon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossGanon* pthis = (BossGanon*)thisx; + + switch (limbIndex) { + case 10: + if (pthis->useOpenHand) { + *dList = gDorfOpenHandDL; + } + break; + + case 20: + rot->y += pthis->legRot.x + pthis->legRot.z; + rot->z += pthis->legRot.y; + break; + + case 21: + if (pthis->legRot.y > 0.0f) { + rot->z += pthis->legRot.y; + } + break; + + case 22: + rot->y += pthis->legRot.x + pthis->legRot.z; + rot->z += pthis->legRot.y; + break; + + case 23: + rot->y += pthis->legRot.x - pthis->legRot.z; + rot->z += pthis->legRot.y; + break; + + case 24: + if (pthis->legRot.y > 0.0f) { + rot->z += pthis->legRot.y; + } + break; + + case 25: + rot->y += pthis->legRot.x - pthis->legRot.z; + rot->z += pthis->legRot.y; + break; + + default: + break; + } + + return 0; +} + +void BossGanon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static s8 bodyPartLimbMap[] = { + -1, -1, 1, -1, 3, 4, 5, -1, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, 2, 12, 13, 14, 9, 10, 11, -1, -1, -1, -1, + }; + static Vec3f D_808E4DA0 = { -500.0f, 200.0f, -300.0f }; + static Vec3f D_808E4DAC = { -500.0f, 200.0f, 300.0f }; + static Vec3f D_808E4DB8 = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_808E4DC4 = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_808E4DD0 = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_808E4DDC = { 1300.0f, 0.0f, 0.0f }; + static Vec3f D_808E4DE8 = { 600.0f, 420.0f, 100.0f }; + s8 bodyPart; + BossGanon* pthis = (BossGanon*)thisx; + + bodyPart = bodyPartLimbMap[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultVec3f(&D_808E4DB8, &pthis->unk_2EC[bodyPart]); + } + + if (limbIndex == 2) { + Matrix_MultVec3f(&D_808E4DB8, &pthis->unk_1FC); + } else if (limbIndex == 19) { + Matrix_MultVec3f(&D_808E4DB8, &pthis->actor.focus.pos); + } else if (limbIndex == 11) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7191); + + Matrix_MultVec3f(&D_808E4DB8, &pthis->unk_208); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7196), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_ganon_DL_00BE90)); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7198); + } else if (limbIndex == 6) { + Matrix_MultVec3f(&D_808E4DC4, &pthis->unk_238); + } else if (limbIndex == 10) { + Matrix_MultVec3f(&D_808E4DD0, &pthis->unk_22C); + + if (pthis->unk_25C == 0) { + Matrix_MultVec3f(&D_808E4DDC, &pthis->unk_260); + } + + pthis->unk_25C = 0; + + if (pthis->triforceType == GDF_TRIFORCE_DORF) { + Matrix_MultVec3f(&D_808E4DE8, &pthis->triforcePos); + } + } else if (limbIndex == 4) { + Vec3f sp28 = D_808E4DA0; + + if (pthis->unk_198 == 1) { + sp28.x += -300.0f; + sp28.y += -300.0f; + sp28.z += 700.0f; + } else if (pthis->unk_198 == 2) { + sp28.x += -300.0f; + sp28.z += 700.0f; + } + + Matrix_MultVec3f(&sp28, &pthis->unk_220); + } else if (limbIndex == 8) { + Vec3f sp1C = D_808E4DAC; + + if (pthis->unk_198 == 1) { + sp1C.x += -300.0f; + sp1C.y += -300.0f; + sp1C.z += -700.0f; + } else if (pthis->unk_198 == 2) { + sp1C.x += -300.0f; + sp1C.y += 100.0f; + sp1C.z += -700.0f; + } + + Matrix_MultVec3f(&sp1C, &pthis->unk_214); + } +} + +void BossGanon_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { + sSeed1 = seedInit0; + sSeed2 = seedInit1; + sSeed3 = seedInit2; +} + +f32 BossGanon_RandZeroOne(void) { + // Wichmann-Hill algorithm + f32 randFloat; + + sSeed1 = (sSeed1 * 171) % 30269; + sSeed2 = (sSeed2 * 172) % 30307; + sSeed3 = (sSeed3 * 170) % 30323; + + randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); + + while (randFloat >= 1.0f) { + randFloat -= 1.0f; + } + + return fabsf(randFloat); +} + +void BossGanon_DrawShock(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 i; + + OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 7350); + + if ((pthis->unk_2E8 != 0) || (pthis->unk_2E6 != 0)) { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + + if (pthis->unk_2E8 != 0) { + Player* player = GET_PLAYER(globalCtx); + + for (i = 0; i < ARRAY_COUNT(player->bodyPartsPos); i++) { + Matrix_Translate(player->bodyPartsPos[i].x, player->bodyPartsPos[i].y, player->bodyPartsPos[i].z, + MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_49C[i], pthis->unk_49C[i], pthis->unk_49C[i], MTXMODE_APPLY); + Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7384), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + } + } else { + for (i = 1; i < 15; i++) { + Matrix_Translate(pthis->unk_2EC[i].x, pthis->unk_2EC[i].y, pthis->unk_2EC[i].z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_49C[i], pthis->unk_49C[i], pthis->unk_49C[i], MTXMODE_APPLY); + + if (!pthis->shockGlow) { + Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7401), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (pthis->shockGlow) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (pthis->unk_1A2 + i) * -15, 32, 64)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); + gSPDisplayList(POLY_XLU_DISP++, gDorfShockGlowDL); + } else { + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + } + } + } + } + + CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 7465); +} + +void BossGanon_DrawHandLightBall(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 alpha; + + OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 7476); + + if (pthis->handLightBallScale > 0.0f) { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + + if ((pthis->unk_1A2 % 2) != 0) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 100, 255, 0, 0); + } + + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + + Matrix_Translate(pthis->unk_260.x, pthis->unk_260.y, pthis->unk_260.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->handLightBallScale, pthis->handLightBallScale, pthis->handLightBallScale, MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_258, 1); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7510), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + + alpha = ((pthis->unk_1A2 % 2) != 0) ? 100 : 80; + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, alpha); + Matrix_Translate(pthis->unk_260.x, 0.0f, pthis->unk_260.z, MTXMODE_NEW); + Matrix_Scale(pthis->handLightBallScale * 0.75f, 1.0f, pthis->handLightBallScale * 0.75f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7531), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightCoreDL); + + CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 7534); + } +} + +void BossGanon_DrawBigMagicCharge(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 yRot; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 i; + + OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 7548); + + if (pthis->unk_284 > 0.0f) { + func_80093D84(globalCtx->state.gfxCtx); + + // light flecks + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s8)pthis->unk_290); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 128); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->unk_1A2 * -2, 0, 0x40, 0x40, 1, 0, + pthis->unk_1A2 * 0xA, 0x40, 0x40)); + Matrix_Translate(pthis->unk_278.x, pthis->unk_278.y, pthis->unk_278.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_28C, pthis->unk_28C, pthis->unk_28C, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7588), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightFlecksDL); + + // background circle texture + Matrix_Translate(pthis->unk_278.x, pthis->unk_278.y, pthis->unk_278.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_284, pthis->unk_284, pthis->unk_284, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7601), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 100, (s8)pthis->unk_288); + gSPSegment( + POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, 0, pthis->unk_1A2 * -4, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gDorfBigMagicBGCircleDL); + + // yellow background dot + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 170, 0, (s8)pthis->unk_288); + gSPSegment(POLY_XLU_DISP++, 0x0A, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, pthis->unk_1A2 * 2, + pthis->unk_1A2 * -0x14, 0x40, 0x40)); + gSPDisplayList(POLY_XLU_DISP++, gDorfDotDL); + + // light ball material + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 0); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + + // light ball geometry + Matrix_Translate(pthis->unk_278.x, pthis->unk_278.y, pthis->unk_278.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_2D0, pthis->unk_2D0, pthis->unk_2D0, MTXMODE_APPLY); + Matrix_RotateZ((pthis->unk_1A2 * 10.0f) / 1000.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7673), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + + BossGanon_InitRand(pthis->unk_1AA + 1, 0x71AC, 0x263A); + Matrix_Translate(pthis->unk_278.x, pthis->unk_278.y, pthis->unk_278.z, MTXMODE_NEW); + Matrix_RotateY((pthis->unk_1A2 * 10.0f) / 1000.0f, MTXMODE_APPLY); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); + + yRot = BINANG_TO_RAD(pthis->actor.yawTowardsPlayer); + + for (i = 0; i < pthis->unk_1AC; i++) { + f32 xzRot = (BossGanon_RandZeroOne() - 0.5f) * M_PI * 1.5f; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)pthis->unk_294[i]); + Matrix_Push(); + Matrix_RotateY(xzRot + yRot, MTXMODE_APPLY); + Matrix_RotateX((BossGanon_RandZeroOne() - 0.5f) * M_PI, MTXMODE_APPLY); + Matrix_RotateZ(xzRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 50.0f, MTXMODE_APPLY); + Matrix_Scale(4.0f, 4.0f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 7713), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightRayTriDL); + + Matrix_Pop(); + } + + CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 7721); + } +} + +void BossGanon_DrawTriforce(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (pthis->fwork[GDF_TRIFORCE_PRIM_A] > 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7732); + + Matrix_Push(); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)pthis->fwork[GDF_TRIFORCE_PRIM_B], + (s8)pthis->fwork[GDF_TRIFORCE_PRIM_A]); + gDPSetEnvColor(POLY_XLU_DISP++, 255, (u8)pthis->fwork[GDF_TRIFORCE_ENV_G], 0, 128); + + if (pthis->triforceType == GDF_TRIFORCE_PLAYER) { + Player* player = GET_PLAYER(globalCtx); + + pthis->triforcePos = player->bodyPartsPos[12]; + + pthis->triforcePos.x += -0.6f; + pthis->triforcePos.y += 3.0f; + pthis->triforcePos.z += -2.0f; + } else if (pthis->triforceType == GDF_TRIFORCE_ZELDA) { + pthis->triforcePos = sZelda->unk_31C; + + pthis->triforcePos.y += 1.8f; + pthis->triforcePos.z += 4.0f; + } + + Matrix_Translate(pthis->triforcePos.x, pthis->triforcePos.y, pthis->triforcePos.z, MTXMODE_NEW); + + if (pthis->triforceType == GDF_TRIFORCE_PLAYER) { + Matrix_RotateX(-1.4f, MTXMODE_APPLY); + Matrix_RotateZ(4.0f, MTXMODE_APPLY); + } else if (pthis->triforceType == GDF_TRIFORCE_ZELDA) { + Matrix_RotateY(1.5f, 1); + Matrix_RotateX(1.1f, 1); + Matrix_RotateZ(-0.99999994f, MTXMODE_APPLY); + } else { + func_800D1FD4(&globalCtx->billboardMtxF); + } + + Matrix_Scale(pthis->fwork[GDF_TRIFORCE_SCALE], pthis->fwork[GDF_TRIFORCE_SCALE], 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7779), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gDorfTriforceDL)); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7782); + } +} + +void BossGanon_DrawDarkVortex(BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (pthis->fwork[GDF_VORTEX_ALPHA] > 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7792); + + Matrix_Push(); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->unk_1A2 * -8, 0, 0x20, 0x40, 1, + pthis->unk_1A2 * -4, pthis->unk_1A2 * -8, 0x20, 0x20)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 0, 200, (s8)pthis->fwork[GDF_VORTEX_ALPHA]); + gDPSetEnvColor(POLY_XLU_DISP++, 130, 0, 0, 128); + + if (pthis->csState != 21) { + Matrix_Translate(0.0f, 105.0f, -400.0f, MTXMODE_NEW); + Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); + } else { + Matrix_Translate(-50.0f, 50.0f, -150.0f, MTXMODE_NEW); + Matrix_RotateY(M_PI / 10, MTXMODE_APPLY); + Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); + } + + Matrix_Scale(pthis->fwork[GDF_VORTEX_SCALE], pthis->fwork[GDF_VORTEX_SCALE], pthis->fwork[GDF_VORTEX_SCALE], + MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7841), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gDorfVortexDL)); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 7844); + } +} + +void func_808E0254(BossGanon* pthis, u8* tex, f32 arg2) { + static s16 D_808E4DF4[] = { 1, 2, 3, 3, 2, 1 }; + static s16 D_808E4E00[] = { 2, 3, 4, 4, 4, 3, 2 }; + static s16 D_808E4E10[] = { 2, 3, 4, 4, 4, 4, 3, 2 }; + static s16 D_808E4E20[] = { 2, 4, 5, 5, 6, 6, 6, 6, 5, 5, 4, 2 }; + static s16 D_808E4E38[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 10, 2, 12, 13 }; + static u8 D_808E4E58[] = { 3, 2, 2, 1, 3, 3, 1, 3, 3, 1, 0, 3, 1, 0, 3 }; + s16 baseX; + s16 index; + s16 i; + s16 baseY; + s16 x; + s16 addY; + f32 lerpX; + s16 y; + f32 lerpY; + f32 lerpZ; + Vec3f sp68; + Vec3f sp5C; + + for (i = 0; i < 15; i++) { + if (arg2 == 0.0f || (y = D_808E4E38[i]) >= 0) { + if (arg2 > 0.0f) { + lerpX = pthis->unk_2EC[i].x + (pthis->unk_2EC[y].x - pthis->unk_2EC[i].x) * arg2; + lerpY = pthis->unk_2EC[i].y + (pthis->unk_2EC[y].y - pthis->unk_2EC[i].y) * arg2; + lerpZ = pthis->unk_2EC[i].z + (pthis->unk_2EC[y].z - pthis->unk_2EC[i].z) * arg2; + + sp68.x = lerpX - pthis->actor.world.pos.x; + sp68.y = lerpY - pthis->actor.world.pos.y + 76 + 30 + 30; + sp68.z = lerpZ - pthis->actor.world.pos.z; + } else { + + sp68.x = pthis->unk_2EC[i].x - pthis->actor.world.pos.x; + sp68.y = pthis->unk_2EC[i].y - pthis->actor.world.pos.y + 76 + 30 + 30; + sp68.z = pthis->unk_2EC[i].z - pthis->actor.world.pos.z; + } + Matrix_MultVec3f(&sp68, &sp5C); + + sp5C.x *= 0.4f; + sp5C.y *= 0.4f; + + baseX = (s16)(sp5C.x + 32.0f); + baseY = (s16)sp5C.y * 64; + + if (D_808E4E58[i] == 2) { + for (y = 0, addY = -0x180; y < 12; y++, addY += 0x40) { + for (x = -D_808E4E20[y]; x < D_808E4E20[y]; x++) { + index = baseX + x + baseY + addY; + if ((index >= 0) && (index < 0x1000)) { + tex[index] = 255; + } + } + } + } else if (D_808E4E58[i] == 1) { + for (y = 0, addY = -0x100; y < 8; y++, addY += 0x40) { + for (x = -D_808E4E10[y]; x < D_808E4E10[y]; x++) { + index = baseX + x + baseY + addY; + if ((index >= 0) && (index < 0x1000)) { + tex[index] = 255; + } + } + } + } else if (D_808E4E58[i] == 0) { + for (y = 0, addY = -0xC0; y < 7; y++, addY += 0x40) { + for (x = -D_808E4E00[y]; x < D_808E4E00[y] - 1; x++) { + index = baseX + x + baseY + addY; + if ((index >= 0) && (index < 0x1000)) { + tex[index] = 255; + } + } + } + } else { + for (y = 0, addY = -0x80; y < 6; y++, addY += 0x40) { + for (x = -D_808E4DF4[y]; x < D_808E4DF4[y] - 1; x++) { + index = baseX + x + baseY + addY; + if ((index >= 0) && (index < 0x1000)) { + tex[index] = 255; + } + } + } + } + } + } +} + +void BossGanon_GenShadowTexture(u8* tex, BossGanon* pthis, GlobalContext* globalCtx) { + s16 addY; + s16 baseX; + s16 baseY; + s16 i; + s16 j; + s16 y; + s16 x; + s16 index; + Vec3f sp7C; + Vec3f sp70; + s32* ptr = (s32*)tex; + + for (i = 0; i < 64 * 64 / 4; i++, ptr++) { + *ptr = 0; + } + + Matrix_RotateX(1.0f, MTXMODE_NEW); + + for (i = 0; i <= 5; i++) { + func_808E0254(pthis, tex, i / 5.0f); + } + + for (i = 0; i < 12; i++) { + for (j = 0; j < 12; j++) { + sp7C.x = sCape->strands[i].joints[j].x - pthis->actor.world.pos.x; + sp7C.y = sCape->strands[i].joints[j].y - pthis->actor.world.pos.y + 76.0f + 100.0f + 30.0f; + sp7C.z = sCape->strands[i].joints[j].z - pthis->actor.world.pos.z; + + Matrix_MultVec3f(&sp7C, &sp70); + + sp70.x = sp70.x * 0.28f; + sp70.y = sp70.y * 0.28f; + + baseX = (s32)(sp70.x + 32.0f); + baseY = (s16)sp70.y * 0x40; + + if (!sCape->strands[i].torn[j]) { + for (y = -1, addY = -0x40; y <= 1; y++, addY += 0x40) { + for (x = -3; x <= 3; x++) { + index = baseX + x + baseY + addY; + if (0 <= index && index < 0x1000) { + tex[index] = 255; + } + } + } + } else { + for (y = -1, addY = -0x40; y <= 1; y++, addY += 0x40) { + for (x = -1; x <= 1; x++) { + index = baseX + x + baseY + addY; + if (0 <= index && index < 0x1000) { + tex[index] = 255; + } + } + } + } + } + } +} + +void BossGanon_DrawShadowTexture(void* tex, BossGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 zOffset; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 8372); + + func_80093D18(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 50); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + if (pthis->csState < 100) { + zOffset = (((((pthis->actor.world.pos.y - 10) + 70.0f) * -5.0f) / 10.0f) + 10.0f); + Matrix_Translate(pthis->actor.world.pos.x, 0.0f, pthis->actor.world.pos.z + zOffset, MTXMODE_NEW); + } else { + Matrix_Translate(pthis->actor.world.pos.x, 4102.0f, pthis->actor.world.pos.z - 20.0f, MTXMODE_NEW); + } + + Matrix_Scale(0.95000005f, 1.0f, 0.95000005f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 8396), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDorfShadowSetupDL); + gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_OPA_DISP++, gDorfShadowModelDL); + + CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 8426); +} + +void BossGanon_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 i; + BossGanon* pthis = (BossGanon*)thisx; + void* shadowTex; + + shadowTex = Graph_Alloc(globalCtx->state.gfxCtx, 64 * 64); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9138); + + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + + if ((pthis->unk_1A6 & 2) != 0) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099); + } + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDorfEyeTex)); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + BossGanon_OverrideLimbDraw, BossGanon_PostLimbDraw, &pthis->actor); + + pthis->unk_2EC[0].x = pthis->unk_2EC[1].x; + pthis->unk_2EC[0].y = pthis->unk_2EC[1].y + 30.0f; + pthis->unk_2EC[0].z = pthis->unk_2EC[1].z; + + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + + BossGanon_DrawEffects(globalCtx); + + sCape->actor.world.pos = pthis->actor.world.pos; + + sCape->rightForearmPos = pthis->unk_214; + sCape->leftForearmPos = pthis->unk_220; + + sCape->rightShoulderPos = pthis->unk_22C; + sCape->leftShoulderPos = pthis->unk_238; + + BossGanon_DrawShock(pthis, globalCtx); + BossGanon_DrawHandLightBall(pthis, globalCtx); + BossGanon_DrawBigMagicCharge(pthis, globalCtx); + BossGanon_DrawTriforce(pthis, globalCtx); + BossGanon_DrawDarkVortex(pthis, globalCtx); + + BossGanon_GenShadowTexture((u8*)shadowTex, pthis, globalCtx); + BossGanon_DrawShadowTexture(shadowTex, pthis, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9393); +} + +s32 BossGanon_CheckFallingPlatforms(BossGanon* pthis, GlobalContext* globalCtx, Vec3f* checkPos) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + + while (prop != NULL) { + if (((BossGanon*)prop == pthis) || (prop->id != ACTOR_BG_GANON_OTYUKA)) { + prop = prop->next; + } else { + BgGanonOtyuka* platform = (BgGanonOtyuka*)prop; + f32 xDiff = platform->dyna.actor.world.pos.x - checkPos->x; + f32 yDiff = platform->dyna.actor.world.pos.y - checkPos->y; + f32 zDiff = platform->dyna.actor.world.pos.z - checkPos->z; + + if ((fabsf(xDiff) < 60.0f) && (yDiff < 20.0f) && (yDiff > -20.0f) && (fabsf(zDiff) < 60.0f)) { + platform->isFalling = true; + platform->visibleSides = OTYUKA_SIDE_ALL; + + return 1; + } else { + prop = prop->next; + } + } + } + + return 0; +} + +void BossGanon_LightBall_Update(Actor* thisx, GlobalContext* globalCtx2) { + u8 hitWithBottle; + s16 i; + s16 spBA = 0; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + BossGanon* pthis = (BossGanon*)thisx; + GlobalContext* globalCtx = globalCtx2; + f32 xDistFromLink; + f32 yDistFromLink; + f32 zDistFromLink; + f32 minReflectDist; + f32 xDistFromGanondorf; + f32 yDistFromGanondorf; + f32 zDistFromGanondorf; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + BossGanon* ganondorf = (BossGanon*)pthis->actor.parent; + s32 pad1; + + pthis->unk_1A2++; + ganondorf->envLightMode = 1; + + if (pthis->unk_1A8 != 0) { + if (pthis->unk_1A8 == 2) { + Math_ApproachZeroF(&pthis->fwork[GDF_FWORK_1], 1.0f, 10.0f); + Math_ApproachF(&pthis->actor.scale.x, 30.0f, 0.5f, 100.0f); + } else { + pthis->actor.shape.rot.y += 0x1000; + ganondorf->lensFlareTimer = 1; + gCustomLensFlarePos = pthis->actor.world.pos; + Math_ApproachZeroF(&pthis->fwork[GDF_FWORK_1], 1.0f, 30.0f); + Math_ApproachF(&pthis->actor.scale.x, 20.0f, 0.5f, 100.0f); + pthis->fwork[GDF_FWORK_0] += ((M_PI / 2) + Rand_ZeroFloat(M_PI / 4)); + } + + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + + if (pthis->fwork[GDF_FWORK_1] == 0.0f) { + Actor_Kill(&pthis->actor); + } + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_FIRE - SFX_FLAG); + + if ((pthis->unk_1A2 % 2) != 0) { + Actor_SetScale(&pthis->actor, 6.0f); + } else { + Actor_SetScale(&pthis->actor, 5.25f); + } + + pthis->actor.shape.rot.z += (s16)(Rand_ZeroOne() * 20000.0f) + 0x4000; + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + + xDistFromGanondorf = ganondorf->unk_1FC.x - pthis->actor.world.pos.x; + yDistFromGanondorf = ganondorf->unk_1FC.y - pthis->actor.world.pos.y; + zDistFromGanondorf = ganondorf->unk_1FC.z - pthis->actor.world.pos.z; + + xDistFromLink = player->actor.world.pos.x - pthis->actor.world.pos.x; + yDistFromLink = (player->actor.world.pos.y + 40.0f) - pthis->actor.world.pos.y; + zDistFromLink = player->actor.world.pos.z - pthis->actor.world.pos.z; + + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + + switch (pthis->unk_1C2) { + case 0: + if ((player->stateFlags1 & 2) && + (ABS((s16)(player->actor.shape.rot.y - (s16)(ganondorf->actor.yawTowardsPlayer + 0x8000))) < + 0x2000) && + (sqrtf(SQ(xDistFromLink) + SQ(yDistFromLink) + SQ(zDistFromLink)) <= 25.0f)) { + hitWithBottle = true; + } else { + hitWithBottle = false; + } + + if ((pthis->collider.base.acFlags & 2) || hitWithBottle) { + ColliderInfo* acHitInfo = pthis->collider.info.acHitInfo; + + pthis->collider.base.acFlags &= ~2; + + if ((hitWithBottle == false) && (acHitInfo->toucher.dmgFlags & 0x100000)) { + spBA = 2; + Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); + } else { + spBA = 1; + pthis->actor.world.rot.y = Math_Atan2S(zDistFromGanondorf, xDistFromGanondorf); + pthis->actor.world.rot.x = + Math_Atan2S(sqrtf(SQ(xDistFromGanondorf) + SQ(zDistFromGanondorf)), yDistFromGanondorf); + pthis->unk_1A4++; + pthis->timers[1] = 2; + Audio_PlaySoundGeneral(NA_SE_IT_SWORD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); + + if (hitWithBottle == false) { + // if ganondorf is 250 units away from link, at least 3 volleys are required + if ((ganondorf->actor.xyzDistToPlayerSq > 62500.0f) && (pthis->unk_1A4 < 3)) { + pthis->unk_1C2 = 1; + } else if (Rand_ZeroOne() < 0.7f) { + pthis->unk_1C2 = 1; + } else { + pthis->unk_1C2 = 3; + } + + // if a spin attack is used + if (player->swordAnimation >= 0x18) { + pthis->actor.speedXZ = 20.0f; + } + break; + } else { + if (Rand_ZeroOne() < 0.9f) { + pthis->unk_1C2 = 1; + } else { + pthis->unk_1C2 = 3; + } + } + } + } else { + if (sqrtf(SQ(xDistFromLink) + SQ(yDistFromLink) + SQ(zDistFromLink)) <= 25.0f) { + spBA = 5; + func_8002F6D4(globalCtx, &pthis->actor, 3.0f, pthis->actor.world.rot.y, 0.0f, 0x30); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_GANON_HIT_THUNDER); + ganondorf->timers[2] = 20; + + for (i = 0; i < ARRAY_COUNT(ganondorf->unk_4E4); i++) { + ganondorf->unk_4E4[i] = D_808E4C58[i]; + } + + ganondorf->unk_2E6 = 0; + ganondorf->unk_2E8 = 60; + ganondorf->unk_508 = 4.0f; + } + } + break; + + case 1: + if ((ganondorf->actionFunc == BossGanon_PlayTennis) && (ganondorf->unk_1C2 == 1)) { + minReflectDist = (pthis->actor.speedXZ >= 19.0f) ? 250.0f : 170.0f; + + if (sqrtf(SQ(xDistFromGanondorf) + SQ(yDistFromGanondorf) + SQ(zDistFromGanondorf)) < + minReflectDist) { + ganondorf->startVolley = true; + pthis->timers[0] = 8; + pthis->unk_1C2 = 2; + } + } + break; + + case 2: + if (pthis->timers[0] == 1) { + spBA = 1; + pthis->actor.world.rot.y = Math_Atan2S(zDistFromLink, xDistFromLink); + pthis->actor.world.rot.x = Math_Atan2S(sqrtf(SQ(xDistFromLink) + SQ(zDistFromLink)), yDistFromLink); + pthis->timers[1] = 2; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SWORD_REFLECT_MG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_AT_RETURN); + pthis->unk_1C2 = 0; + break; + } + // fallthrough + case 4: + if (sqrtf(SQ(xDistFromGanondorf) + SQ(yDistFromGanondorf) + SQ(zDistFromGanondorf)) < 30.0f) { + spBA = 3; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_GANON_DAMAGE1); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_GANON_HIT_THUNDER); + } + break; + + case 3: + if (sqrtf(SQ(xDistFromGanondorf) + SQ(yDistFromGanondorf) + SQ(zDistFromGanondorf)) < 100.0f) { + ganondorf->startVolley = true; + pthis->unk_1C2 = 4; + } + break; + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (pthis->timers[1] == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + for (i = 0; i < 2; i++) { + spA0.x = spA0.z = 0.0f; + spA0.y = 0.2f; + + spAC.x = spAC.y = spAC.z = 0.0f; + + sp94.x = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.x; + sp94.y = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.y; + sp94.z = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.z; + + BossGanonEff_SpawnSparkle(globalCtx, &sp94, &spAC, &spA0, Rand_ZeroFloat(500.0f) + 700.0f, 0x1E); + } + + if (pthis->actor.world.pos.y < 10.0f) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 20.0f, 20.0f, 4); + } + + if ((fabsf(pthis->actor.world.pos.x) > 465.0f) || (pthis->actor.world.pos.y > 500.0f) || + (fabsf(pthis->actor.world.pos.z) > 465.0f)) { + spBA = 4; + } + + if ((spBA != 0) || (pthis->actor.bgCheckFlags & 1)) { + f32 sp58; + f32 sp54; + f32 phi_f20; + s16 sp4E; + + if (spBA == 1) { + sp58 = Rand_ZeroFloat(100.0f) + 300.0f; + sp54 = 10.0f; + phi_f20 = 25.0f; + sp4E = 40; + } else { + sp58 = Rand_ZeroFloat(200.0f) + 500.0f; + sp54 = 15.0f; + phi_f20 = 30.0f; + sp4E = 70; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 80, NA_SE_EN_GANON_HIT_THUNDER); + } + + for (i = 0; i < sp4E; i++) { + if (spBA != 0) { + spAC.x = Rand_CenteredFloat(phi_f20); + spAC.y = Rand_CenteredFloat(phi_f20); + spAC.z = Rand_CenteredFloat(phi_f20); + } else { + spAC.x = Rand_CenteredFloat(phi_f20); + spAC.y = Rand_ZeroFloat(25.0f); + spAC.z = Rand_CenteredFloat(phi_f20); + } + + BossGanonEff_SpawnLightRay(globalCtx, &pthis->actor.world.pos, &spAC, &sZeroVec, sp58, sp54, 0x1E); + } + + if (spBA != 1) { + pthis->unk_1A8 = 1; + + if (spBA == 0) { + BossGanon_CheckFallingPlatforms(pthis, globalCtx, &pthis->actor.world.pos); + } + + if (spBA == 3) { + BossGanon_SetupHitByLightBall(ganondorf, globalCtx); + } else if (ganondorf->actionFunc == BossGanon_PlayTennis) { + BossGanon_SetupWait(ganondorf, globalCtx); + + if (spBA == 5) { + ganondorf->timers[0] = 125; + } + } + } + } + } +} + +void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx) { + BossGanon* pthis = (BossGanon*)thisx; + s16 i; + f32 alpha; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9849); + + func_80093D84(globalCtx->state.gfxCtx); + + alpha = ((pthis->unk_1A2 % 2) != 0) ? pthis->fwork[GDF_FWORK_1] * 0.4f : pthis->fwork[GDF_FWORK_1] * 0.35f; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, (s8)alpha); + Matrix_Push(); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.floorHeight, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(pthis->actor.scale.x * 0.75f, 1.0f, pthis->actor.scale.z * 0.75f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9875), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightCoreDL); + + Matrix_Pop(); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)pthis->fwork[GDF_FWORK_1]); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + + if (pthis->unk_1A8 == 1) { + for (i = 0; i < 8; i++) { + Matrix_Push(); + Matrix_RotateY(i * (M_PI / 8), MTXMODE_APPLY); + Matrix_RotateZ(pthis->fwork[GDF_FWORK_0], MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9899), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + Matrix_Pop(); + } + } else if (pthis->unk_1A8 == 0) { + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_RotateZ((pthis->actor.shape.rot.z / 32768.0f) * 3.1416f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9907), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 9911); +} + +void func_808E1EB4(Actor* thisx, GlobalContext* globalCtx2) { + s16 i; + BossGanon* pthis = (BossGanon*)thisx; + GlobalContext* globalCtx = globalCtx2; + BossGanon* dorf = (BossGanon*)pthis->actor.parent; + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 xzDist; + s16 xRotTarget; + s16 yRotTarget; + Vec3f vel; + Vec3f accel; + + pthis->unk_1A2++; + dorf->envLightMode = 1; + Actor_SetScale(&pthis->actor, 6.0f); + pthis->actor.shape.rot.z += ((s16)(Rand_ZeroOne() * 20000.0f) + 0x4000); + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + + pthis->unk_1A6++; + + if (pthis->unk_1A6 >= 15) { + pthis->unk_1A6 = 0; + } + + pthis->unk_2EC[pthis->unk_1A6] = pthis->actor.world.pos; + + if (pthis->unk_1C2 == 0) { + if (1) {} + if (pthis->timers[0] == 0) { + pthis->unk_1C2 = 1; + } + } else if (pthis->unk_1C2 == 1) { + xDiff = dorf->unk_1FC.x - pthis->actor.world.pos.x; + yDiff = dorf->unk_1FC.y - pthis->actor.world.pos.y; + zDiff = dorf->unk_1FC.z - pthis->actor.world.pos.z; + + yRotTarget = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); + xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); + xRotTarget = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); + + Math_ApproachS(&pthis->actor.world.rot.x, xRotTarget, 1, 0x1000); + Math_ApproachS(&pthis->actor.world.rot.y, yRotTarget, 1, 0x1000); + + if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 40.0f) { + pthis->unk_1C2 = 2; + pthis->timers[0] = 30; + pthis->actor.speedXZ = 0.0f; + + if (pthis->actor.params == 0xC8) { + func_80078884(NA_SE_EN_GANON_DAMAGE2); + func_80078884(NA_SE_EN_GANON_DD_THUNDER); + + for (i = 0; i < 150; i++) { + + vel.x = Rand_CenteredFloat(25.0f); + vel.y = Rand_CenteredFloat(25.0f); + vel.z = Rand_CenteredFloat(25.0f); + + accel.x = vel.x * -0.03f; + accel.y = vel.y * -0.03f; + accel.z = vel.z * -0.03f; + + BossGanonEff_SpawnLightRay(globalCtx, &dorf->unk_1FC, &vel, &accel, + Rand_ZeroFloat(500.0f) + 1000.0f, 15.0f, 0x14); + } + + for (i = 1; i < 15; i++) { + dorf->unk_4E4[i] = 1000; + } + + dorf->unk_2E6 = 1000; + dorf->unk_2E8 = 0; + dorf->screenFlashTimer = 4; + dorf->lensFlareTimer = 10; + dorf->lensFlareMode = 1; + dorf->unk_508 = 10.0f; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &dorf->actor, globalCtx, ACTOR_BOSS_GANON, dorf->unk_1FC.x, + dorf->unk_1FC.y, dorf->unk_1FC.z, 0, 0, 0, 0x12C); + } + + pthis->actor.world.pos.y = 5000.0f; + } + } else if (pthis->timers[0] == 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_808E229C(Actor* thisx, GlobalContext* globalCtx2) { + BossGanon* pthis = (BossGanon*)thisx; + GlobalContext* globalCtx = globalCtx2; + s16 i; + s32 temp; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10081); + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + + for (i = 9; i >= 0; i--) { + temp = (s16)(((pthis->unk_1A6 - i) + 0xF) % 15); + Matrix_Translate(pthis->unk_2EC[temp].x, pthis->unk_2EC[temp].y, pthis->unk_2EC[temp].z, MTXMODE_NEW); + Matrix_Scale(pthis->actor.scale.x * (1.0f - (i * 0.07000001f)), pthis->actor.scale.y * (1.0f - (i * 0.07000001f)), + pthis->actor.scale.z * (1.0f - (i * 0.07000001f)), MTXMODE_APPLY); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_RotateZ(((2.0f * (i * M_PI)) / 10.0f) + BINANG_TO_RAD(pthis->actor.shape.rot.z), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10109), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10113); +} + +void func_808E2544(Actor* thisx, GlobalContext* globalCtx) { + u8 numEffects = 0; + s16 xRot; + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 xzDist; + f32 new_var; + f32 sp84; + s16 i; + s16 sp80; + BossGanon* pthis = (BossGanon*)thisx; + BossGanon* dorf = (BossGanon*)pthis->actor.parent; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + ColliderInfo* acHitInfo; + Vec3f sp60; + + pthis->unk_1A2++; + Actor_SetScale(&pthis->actor, 0.01f); + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + + pthis->unk_1A6++; + + if (pthis->unk_1A6 >= 15) { + pthis->unk_1A6 = 0; + } + + pthis->unk_2EC[pthis->unk_1A6] = pthis->actor.world.pos; + pthis->unk_3C4[pthis->unk_1A6].x = BINANG_TO_RAD(pthis->actor.world.rot.x); + pthis->unk_3C4[pthis->unk_1A6].y = BINANG_TO_RAD(pthis->actor.world.rot.y); + + switch (pthis->unk_1C2) { + if (1) {} + case 0: + pthis->actor.speedXZ = 40.0f; + Math_ApproachF(&pthis->fwork[1], 255.0f, 1.0f, 40.0f); + xDiff = dorf->unk_278.x - pthis->actor.world.pos.x; + yDiff = dorf->unk_278.y - pthis->actor.world.pos.y; + zDiff = dorf->unk_278.z - pthis->actor.world.pos.z; + sp80 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); + xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); + + xRot = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); + sp84 = (xzDist * 700.0f) / 10.0f; + if (sp84 > 6144.0f) { + sp84 = 6144.0f; + } + + xRot += (Math_CosS(pthis->unk_1A2 * 0x2200) * sp84); + pthis->actor.world.rot.x = xRot; + Math_ApproachS(&pthis->actor.shape.rot.y, sp80, 1, pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamMaxStepScale, 4096.0f, 1.0f, 256.0f); + pthis->actor.world.rot.y = (Math_SinS(pthis->unk_1A2 * 0x1A00) * sp84) + pthis->actor.shape.rot.y; + + if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 45.0f) { + pthis->unk_1C2 = 1; + pthis->actor.speedXZ = 0.0f; + } + break; + + case 1: + Math_ApproachZeroF(&pthis->fwork[1], 1.0f, 40.0f); + + if (pthis->fwork[1] == 0.0f) { + Actor_Kill(&pthis->actor); + } + break; + + case 10: + pthis->unk_1C2 = 0xB; + pthis->timers[0] = 14; + + pthis->collider.dim.radius = 15; + pthis->collider.dim.height = 20; + pthis->collider.dim.yShift = -10; + + pthis->actor.speedXZ = 20.0f; + pthis->fwork[1] = 255.0f; + pthis->unk_1F0 = player->actor.world.pos; + new_var = pthis->unk_1F0.x - pthis->actor.world.pos.x; + pthis->actor.shape.rot.y = RADF_TO_BINANG(Math_FAtan2F(new_var, pthis->unk_1F0.z - pthis->actor.world.pos.z)) + + (pthis->actor.params << 0xD) - 0x20C000; + // fallthrough + case 11: + if (pthis->timers[0] != 0) { + pthis->unk_1F0 = player->actor.world.pos; + xDiff = pthis->unk_1F0.x - pthis->actor.world.pos.x; + yDiff = (pthis->unk_1F0.y + 30.0f) - pthis->actor.world.pos.y; + zDiff = pthis->unk_1F0.z - pthis->actor.world.pos.z; + + sp80 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); + pthis->actor.shape.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff)))); + Math_ApproachS(&pthis->actor.shape.rot.y, sp80, 1, pthis->csCamMaxStepScale); + Math_ApproachF(&pthis->csCamMaxStepScale, 4096.0f, 1.0f, 256.0f); + } + + sp84 = (sqrtf(pthis->actor.xyzDistToPlayerSq) * 200.0f) / 10.0f; + if (sp84 > 13824.0f) { + sp84 = 13824.0f; + } + + pthis->actor.world.rot.x = (Math_CosS(pthis->unk_1A2 * 0x3400) * sp84 * 0.1f) + pthis->actor.shape.rot.x; + pthis->actor.world.rot.y = (Math_SinS(pthis->unk_1A2 * 0x1A00) * sp84) + pthis->actor.shape.rot.y; + + if ((player->swordState != 0) && (player->swordAnimation >= 0x18) && (pthis->actor.xzDistToPlayer < 80.0f)) { + pthis->unk_1C2 = 0xC; + pthis->actor.speedXZ = -30.0f; + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + pthis->unk_1F0 = dorf->unk_1FC; + numEffects = 10; + break; + } + + if (pthis->collider.base.acFlags & 2) { + acHitInfo = pthis->collider.info.acHitInfo; + + pthis->collider.base.acFlags &= ~2; + + if (!(acHitInfo->toucher.dmgFlags & 0x100000) || Player_HasMirrorShieldEquipped(globalCtx)) { + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); + pthis->unk_1C2 = 0xC; + pthis->actor.speedXZ = -30.0f; + + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + + pthis->unk_1F0.x = Rand_CenteredFloat(700.0f) + dorf->unk_1FC.x; + pthis->unk_1F0.y = Rand_CenteredFloat(200.0f) + dorf->unk_1FC.y; + pthis->unk_1F0.z = Rand_CenteredFloat(700.0f) + dorf->unk_1FC.z; + + pthis->unk_1F0.x = pthis->unk_1F0.x + ((pthis->unk_1F0.x - pthis->actor.world.pos.x) * 100.0f); + pthis->unk_1F0.y = pthis->unk_1F0.y + ((pthis->unk_1F0.y - pthis->actor.world.pos.y) * 100.0f); + pthis->unk_1F0.z = pthis->unk_1F0.z + ((pthis->unk_1F0.z - pthis->actor.world.pos.z) * 100.0f); + + numEffects = 10; + break; + } + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (pthis->timers[1] == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + xDiff = player->actor.world.pos.x - pthis->actor.world.pos.x; + yDiff = (player->actor.world.pos.y + 30.0f) - pthis->actor.world.pos.y; + zDiff = player->actor.world.pos.z - pthis->actor.world.pos.z; + + if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 30.0f) { + pthis->unk_1C2 = 1; + pthis->actor.speedXZ = 0.0f; + + if (dorf->timers[2] == 0) { + func_8002F6D4(globalCtx, &pthis->actor, 3.0f, pthis->actor.world.rot.y, 0.0f, 0x50); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_GANON_HIT_THUNDER); + dorf->timers[2] = 20; + + for (i = 0; i < ARRAY_COUNT(pthis->unk_4E4); i++) { + dorf->unk_4E4[i] = D_808E4C58[i]; + } + + dorf->unk_2E6 = 0; + dorf->unk_2E8 = 60; + dorf->unk_508 = 4.0f; + numEffects = 40; + } + } + break; + + case 12: + pthis->actor.speedXZ = 20.0f; + + xDiff = pthis->unk_1F0.x - pthis->actor.world.pos.x; + yDiff = pthis->unk_1F0.y - pthis->actor.world.pos.y; + zDiff = pthis->unk_1F0.z - pthis->actor.world.pos.z; + + sp80 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); + xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); + xRot = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); + sp84 = (xzDist * 700.0f) / 10.0f; + + if (sp84 > 6144.0f) { + sp84 = 6144.0f; + } + + sp80 += Math_SinS(pthis->unk_1A2 * 0x2200) * sp84; + + xRot += Math_CosS(pthis->unk_1A2 * 0x1800) * sp84; + + pthis->actor.world.rot.x = xRot; + pthis->actor.world.rot.y = sp80; + + xDiff = dorf->unk_1FC.x - pthis->actor.world.pos.x; + yDiff = dorf->unk_1FC.y - pthis->actor.world.pos.y; + zDiff = dorf->unk_1FC.z - pthis->actor.world.pos.z; + + if (sqrtf(SQ(xDiff) + SQ(zDiff) + SQ(yDiff)) < 45.0f) { + BossGanon_SetupHitByLightBall(dorf, globalCtx); + pthis->timers[0] = 150; + numEffects = 40; + pthis->unk_1C2 = 1; + pthis->actor.speedXZ = 0.0f; + } + break; + } + + if (pthis->unk_1C2 >= 0xB) { + xzDist = (pthis->unk_1C2 == 0xC) ? -65.0f : 0.0f; + + if ((fabsf(pthis->actor.world.pos.x) > (465.0f + xzDist)) || + (fabsf(pthis->actor.world.pos.z) > (465.0f + xzDist)) || ((pthis->actor.world.pos.y < 0.0f)) || + (pthis->actor.world.pos.y > 450.0f)) { + pthis->unk_1C2 = 1; + pthis->actor.speedXZ = 0.0f; + numEffects = 10; + BossGanon_CheckFallingPlatforms(pthis, globalCtx, &pthis->actor.world.pos); + Actor_SpawnAsChild(&globalCtx->actorCtx, &dorf->actor, globalCtx, ACTOR_BOSS_GANON, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0x190); + } + } + + if (numEffects) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 80, NA_SE_EN_FANTOM_THUNDER); + + for (i = 0; i < numEffects; i++) { + sp60.x = Rand_CenteredFloat(30.0f); + sp60.y = Rand_CenteredFloat(30.0f); + sp60.z = Rand_CenteredFloat(30.0); + + BossGanonEff_SpawnLightRay(globalCtx, &pthis->actor.world.pos, &sp60, &sZeroVec, + Rand_ZeroFloat(200.0f) + 500.0f, 15.0f, 0x1E); + } + } +} + +static Gfx* sBigMagicLightStreakDLists[] = { + gDorfLightStreak12DL, gDorfLightStreak11DL, gDorfLightStreak10DL, gDorfLightStreak9DL, + gDorfLightStreak8DL, gDorfLightStreak7DL, gDorfLightStreak6DL, gDorfLightStreak5DL, + gDorfLightStreak4DL, gDorfLightStreak3DL, gDorfLightStreak2DL, gDorfLightStreak1DL, +}; + +void func_808E324C(Actor* thisx, GlobalContext* globalCtx) { + BossGanon* pthis = (BossGanon*)thisx; + Mtx* mtx; + s16 i; + s32 temp; + + mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, 12 * sizeof(Mtx)); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10489); + + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (s8)pthis->fwork[GDF_FWORK_1]); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 255, 0, 128); + gSPSegment(POLY_XLU_DISP++, 0x0D, mtx); + + for (i = 0; i < 12; i++) { + temp = (s16)(((pthis->unk_1A6 - i) + 0xF) % 15); + Matrix_Translate(pthis->unk_2EC[temp].x, pthis->unk_2EC[temp].y, pthis->unk_2EC[temp].z, MTXMODE_NEW); + Matrix_RotateY(pthis->unk_3C4[temp].y, MTXMODE_APPLY); + Matrix_RotateX(-pthis->unk_3C4[temp].x, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(M_PI / 2, MTXMODE_APPLY); + Matrix_ToMtx(mtx, "../z_boss_ganon.c", 10520); + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sBigMagicLightStreakDLists[i]); + mtx++; + }; + + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(10.0f, 10.0f, 10.0f, MTXMODE_APPLY); + Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10534), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon.c", 10541); +} + +void BossGanon_UpdateEffects(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + s16 i; + s32 pad; + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 yRot; + f32 xRot; + Vec3f spA0; + s16 bodyPart; + f32 distToPlayer; + s32 pad2; + s32 pad3; + + spA0.x = 0.0f; + spA0.y = 0.0f; + + for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++, eff++) { + if (eff->type != GDF_EFF_NONE) { + eff->pos.x += eff->velocity.x; + eff->pos.y += eff->velocity.y; + eff->pos.z += eff->velocity.z; + + eff->timer++; + + eff->velocity.x += eff->accel.x; + eff->velocity.y += eff->accel.y; + eff->velocity.z += eff->accel.z; + + if (eff->type == GDF_EFF_WINDOW_SHARD) { + eff->unk_44 += 0.3f; + eff->unk_48 += 0.5f; + + if (eff->pos.y < 0.0f) { + eff->type = GDF_EFF_NONE; + } + } else if (eff->type == GDF_EFF_SPARKLE) { + eff->unk_3C += Rand_ZeroFloat(M_PI / 2) + M_PI / 2; + eff->unk_2E -= eff->unk_30; + + if (eff->unk_2E <= 0) { + eff->unk_2E = 0; + eff->type = GDF_EFF_NONE; + } + + eff->alpha = eff->unk_2E; + + if (eff->alpha > 255) { + eff->alpha = 255; + } + } else if (eff->type == GDF_EFF_BLACK_DOT) { + xDiff = sGanondorf->unk_278.x - eff->pos.x; + yDiff = sGanondorf->unk_278.y - eff->pos.y; + zDiff = sGanondorf->unk_278.z - eff->pos.z; + + yRot = Math_FAtan2F(xDiff, zDiff); + + xRot = -Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))); + spA0.z = eff->unk_38; + Matrix_RotateY(yRot, MTXMODE_NEW); + Matrix_RotateX(xRot, MTXMODE_APPLY); + Matrix_MultVec3f(&spA0, &eff->velocity); + Math_ApproachF(&eff->unk_38, 10.0f, 1.0f, 0.5f); + + eff->alpha += 10; + + if (eff->alpha > 255) { + eff->alpha = 255; + } + + if ((sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)) < 20.0f) || (eff->timer > 70)) { + eff->type = GDF_EFF_NONE; + } + } else if (eff->type == GDF_EFF_LIGHT_RAY) { + eff->unk_3C += Rand_ZeroFloat(M_PI / 2) + M_PI / 2; + eff->unk_2E -= eff->unk_30; + + if (eff->unk_2E <= 0) { + eff->unk_2E = 0; + eff->type = GDF_EFF_NONE; + } + + eff->alpha = eff->unk_2E; + + if (eff->alpha > 255) { + eff->alpha = 255; + } + + Math_ApproachF(&eff->unk_38, eff->unk_40, 1.0f, (eff->unk_40 / 15.0f) * 4.0f); + } else if (eff->type == GDF_EFF_SHOCK) { + if (eff->unk_2E == GDF_SHOCK_DORF_YELLOW) { + bodyPart = (s16)Rand_ZeroFloat(13.9f) + 1; + + eff->pos.x = sGanondorf->unk_2EC[bodyPart].x + Rand_CenteredFloat(20.0f); + eff->pos.y = sGanondorf->unk_2EC[bodyPart].y + Rand_CenteredFloat(20.0f); + eff->pos.z = sGanondorf->unk_2EC[bodyPart].z + Rand_CenteredFloat(20.0f); + } else { + bodyPart = (s16)Rand_ZeroFloat(17.9f); + + eff->pos.x = player->bodyPartsPos[bodyPart].x + Rand_CenteredFloat(10.0f); + eff->pos.y = player->bodyPartsPos[bodyPart].y + Rand_CenteredFloat(15.0f); + eff->pos.z = player->bodyPartsPos[bodyPart].z + Rand_CenteredFloat(10.0f); + } + + eff->unk_3C += (Rand_ZeroFloat(M_PI / 2) + M_PI / 2); + + if (eff->timer > 20) { + eff->type = GDF_EFF_NONE; + } + } else if (eff->type == GDF_EFF_LIGHTNING) { + if (eff->unk_3C == 0.0f) { + eff->unk_44 = BINANG_TO_RAD(Camera_GetInputDirYaw(Gameplay_GetCamera(globalCtx, MAIN_CAM))); + } else { + eff->unk_44 = M_PI / 2; + } + + if (eff->timer > 12) { + eff->type = GDF_EFF_NONE; + } + } else if (eff->type == GDF_EFF_IMPACT_DUST_DARK) { + eff->unk_30++; // unused + + if (eff->unk_2E == 0) { + eff->alpha += 26; + + if (eff->alpha > 255) { + eff->alpha = 255; + eff->unk_2E = 1; + } + } else if (eff->unk_2E == 1) { + eff->unk_2E = 2; + } else if (eff->unk_2E == 2) { + eff->alpha -= 26; + + if (eff->alpha < 0) { + eff->alpha = 0; + eff->type = GDF_EFF_NONE; + } + } + + Math_ApproachF(&eff->scale, eff->unk_38, 1.0f, 0.01f); + Math_ApproachF(&eff->unk_40, 4.0f, 1.0f, 0.15f); + } else if (eff->type == GDF_EFF_IMPACT_DUST_LIGHT) { + if (i == 0) { + func_80078884(NA_SE_EN_GANON_WAVE_GND - SFX_FLAG); + } + + eff->unk_30++; // unused + + if (eff->unk_2E == 0) { + eff->alpha += 100; + + if (eff->alpha > 255) { + eff->alpha = 255; + eff->unk_2E = 1; + } + } else if (eff->unk_2E == 1) { + if (eff->timer >= 20) { + eff->unk_2E = 2; + } + } else if (eff->unk_2E == 2) { + eff->alpha -= 30; + + if (eff->alpha < 0) { + eff->alpha = 0; + eff->type = GDF_EFF_NONE; + } + } + + Math_ApproachF(&eff->scale, eff->unk_38, 1.0f, 0.1f); + Math_ApproachF(&eff->unk_40, 1.0f, 1.0f, 0.15f); + } else if (eff->type == GDF_EFF_SHOCKWAVE) { + eff->unk_30++; // unused + eff->alpha -= 30; + + if (eff->alpha < 0) { + eff->alpha = 0; + eff->type = GDF_EFF_NONE; + } + + Math_ApproachF(&eff->scale, eff->unk_38, 1.0f, 0.13f); + + if ((eff->timer < 150) && (fabsf(player->actor.world.pos.y) < 5.0f)) { + distToPlayer = + sqrtf(SQ(eff->pos.x - player->actor.world.pos.x) + SQ(eff->pos.z - player->actor.world.pos.z)); + + if (((eff->scale * 150.0f) < distToPlayer) && (distToPlayer < (eff->scale * 300.0f))) { + eff->timer = 150; + func_8002F6D4(globalCtx, &sGanondorf->actor, 7.0f, sGanondorf->actor.yawTowardsPlayer, 0.0f, + 0x20); + } + } + } + } + } +} + +static void* sLightningTextures[] = { + gDorfLightning1Tex, gDorfLightning1Tex, gDorfLightning2Tex, gDorfLightning3Tex, gDorfLightning4Tex, + gDorfLightning5Tex, gDorfLightning6Tex, gDorfLightning7Tex, gDorfLightning8Tex, gDorfLightning9Tex, + gDorfLightning10Tex, gDorfLightning11Tex, gDorfLightning12Tex, +}; + +static u8 sLightningPrimColors[] = { + 0, 0, 0, 255, 255, 255, 231, 250, 231, 208, 245, 208, 185, 240, 185, 162, 235, 162, 139, 230, + 139, 115, 225, 115, 92, 220, 92, 69, 215, 69, 46, 210, 46, 23, 205, 23, 0, 200, 0, +}; + +static u8 sLightningEnvColors[] = { + 0, 0, 0, 255, 255, 0, 240, 231, 23, 226, 208, 46, 212, 185, 69, 198, 162, 92, + 184, 139, 115, 170, 115, 139, 156, 92, 162, 142, 69, 185, 128, 46, 208, 114, 23, 231, + 100, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +void BossGanon_DrawEffects(GlobalContext* globalCtx) { + u8 flag = 0; + s16 i; + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GanondorfEffect* eff = (GanondorfEffect*)globalCtx->specialEffects; + GanondorfEffect* effFirst = eff; + + OPEN_DISPS(gfxCtx, "../z_boss_ganon.c", 10865); + func_80093D84(globalCtx->state.gfxCtx); + + for (i = 0; i < 200; i++, eff++) { + if (eff->type == GDF_EFF_WINDOW_SHARD) { + gDPPipeSync(POLY_OPA_DISP++); + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gDorfWindowShardMaterialDL); + flag++; + } + if ((eff->timer & 7) != 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, 255); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + } + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->scale, eff->scale, eff->scale, MTXMODE_APPLY); + Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); + Matrix_RotateX(eff->unk_44, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 10898), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDorfWindowShardModelDL); + } + } + + eff = effFirst; + flag = 0; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_SPARKLE) { + gDPPipeSync(POLY_XLU_DISP++); + if (flag == 0) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + flag++; + } + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 10932), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + } + } + + eff = effFirst; + flag = 0; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_LIGHT_RAY) { + gDPPipeSync(POLY_XLU_DISP++); + if (flag == 0) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightBallMaterialDL); + flag++; + } + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); + Matrix_RotateX(eff->unk_44, MTXMODE_APPLY); + Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); + Matrix_Scale(eff->scale, eff->scale, eff->unk_38 * eff->scale, MTXMODE_APPLY); + Matrix_RotateX(M_PI / 2, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 10971), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + } + } + + eff = effFirst; + flag = 0; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_SHOCK) { + if (flag == 0) { + gDPPipeSync(POLY_XLU_DISP++); + if (eff->unk_2E == GDF_SHOCK_PLAYER_PURPLE) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 0, 200, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 130, 0, 0, 0); + } else { // GDF_SHOCK_DORF_YELLOW or GDF_SHOCK_PLAYER_YELLOW + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 0); + } + flag++; + } + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); + Matrix_RotateX(eff->unk_3C * 1.3f, MTXMODE_APPLY); + Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11023), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfShockDL); + } + } + + eff = effFirst; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_LIGHTNING) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, sLightningPrimColors[(eff->timer * 3) + 0], + sLightningPrimColors[(eff->timer * 3) + 1], sLightningPrimColors[(eff->timer * 3) + 2], + 255); + gDPSetEnvColor(POLY_XLU_DISP++, sLightningEnvColors[(eff->timer * 3) + 0], + sLightningEnvColors[(eff->timer * 3) + 1], sLightningEnvColors[(eff->timer * 3) + 2], 0); + Matrix_Translate(sGanondorf->unk_260.x, sGanondorf->unk_260.y, sGanondorf->unk_260.z, MTXMODE_NEW); + Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); + Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); + Matrix_Scale(eff->scale, eff->scale, eff->scale, MTXMODE_APPLY); + Matrix_RotateY(eff->unk_44, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11074), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLightningTextures[eff->timer])); + gSPDisplayList(POLY_XLU_DISP++, gDorfLightningDL); + } + } + + eff = effFirst; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_IMPACT_DUST_DARK) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, eff->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 70, 0, 128); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, eff->timer * 4, 0, 32, 64, 1, eff->timer * 2, + eff->timer * -20, 32, 32)); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->scale, eff->unk_40 * eff->scale, eff->scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11121), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfImpactDarkDL); + } + } + + eff = effFirst; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_IMPACT_DUST_LIGHT) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, eff->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 100, 0, 128); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, eff->timer * 4, 0, 32, 64, 1, eff->timer * 2, + eff->timer * -20, 32, 32)); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->scale, eff->unk_40 * eff->scale, eff->scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11165), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfImpactLightDL); + } + } + + eff = effFirst; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_SHOCKWAVE) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, eff->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 255, 0, 128); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (eff->timer * 100), 0, 64, 32, 1, + (eff->timer * 100), 0, 64, 32)); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale((eff->scale * 200.0f) / 1500.0f, (eff->unk_40 * 200.0f) / 1500.0f, + (eff->scale * 200.0f) / 1500.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11209), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfShockwaveDL); + } + } + + eff = effFirst; + + for (i = 0; i < 150; i++, eff++) { + if (eff->type == GDF_EFF_BLACK_DOT) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 170, 0, eff->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); + gSPSegment(POLY_XLU_DISP++, 0x0A, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, eff->timer * 2, eff->timer * -20, + 64, 64)); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_ganon.c", 11250), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gDorfDotDL); + } + } + + CLOSE_DISPS(gfxCtx, "../z_boss_ganon.c", 11255); +} + +#include "overlays/ovl_Boss_Ganon/ovl_Boss_Ganon.cpp" diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c deleted file mode 100644 index 29701c44d..000000000 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ /dev/null @@ -1,3093 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GANON2_Z_BOSS_GANON2_C -#include "actor_common.h" -#include "z_boss_ganon2.h" -#include "overlays/actors/ovl_Demo_Gj/z_demo_gj.h" -#include "overlays/actors/ovl_En_Zl3/z_en_zl3.h" -#include "objects/object_ganon/object_ganon.h" -#include "objects/object_ganon2/object_ganon2.h" -#include "objects/object_ganon_anime3/object_ganon_anime3.h" -#include "objects/object_geff/object_geff.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/graph.h" -#include "def/sinf.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void BossGanon2_Init(Actor* thisx, GlobalContext* globalCtx); -void BossGanon2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx); -void BossGanon2_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808FD5C4(BossGanon2* this, GlobalContext* globalCtx); -void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx); -void func_808FFDB0(BossGanon2* this, GlobalContext* globalCtx); -void func_808FFEBC(BossGanon2* this, GlobalContext* globalCtx); -void func_808FFFE0(BossGanon2* this, GlobalContext* globalCtx); -void func_80900104(BossGanon2* this, GlobalContext* globalCtx); -void func_8090026C(BossGanon2* this, GlobalContext* globalCtx); -void func_809002CC(BossGanon2* this, GlobalContext* globalCtx); -void func_80900344(BossGanon2* this, GlobalContext* globalCtx); -void func_80900580(BossGanon2* this, GlobalContext* globalCtx); -void func_80900650(BossGanon2* this, GlobalContext* globalCtx); -void func_80900890(BossGanon2* this, GlobalContext* globalCtx); -void func_8090120C(BossGanon2* this, GlobalContext* globalCtx); -void func_80905DA8(BossGanon2* this, GlobalContext* globalCtx); -void func_809060E8(GlobalContext* globalCtx); -void BossGanon2_GenShadowTexture(void* shadowTexture, BossGanon2* this, GlobalContext* globalCtx); -void BossGanon2_DrawShadowTexture(void* shadowTexture, BossGanon2* this, GlobalContext* globalCtx); - -const ActorInit Boss_Ganon2_InitVars = { - ACTOR_BOSS_GANON2, - ACTORCAT_BOSS, - FLAGS, - OBJECT_GANON2, - sizeof(BossGanon2), - (ActorFunc)BossGanon2_Init, - (ActorFunc)BossGanon2_Destroy, - (ActorFunc)BossGanon2_Update, - (ActorFunc)BossGanon2_Draw, -}; - -#include "z_boss_ganon2_data.c" - -void BossGanon2_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { - sSeed1 = seedInit0; - sSeed2 = seedInit1; - sSeed3 = seedInit2; -} - -f32 BossGanon2_RandZeroOne(void) { - // Wichmann-Hill algorithm - f32 randFloat; - - sSeed1 = (sSeed1 * 171) % 30269; - sSeed2 = (sSeed2 * 172) % 30307; - sSeed3 = (sSeed3 * 170) % 30323; - - randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); - while (randFloat >= 1.0f) { - randFloat -= 1.0f; - } - return fabsf(randFloat); -} - -void func_808FD080(s32 idx, ColliderJntSph* collider, Vec3f* arg2) { - collider->elements[idx].dim.worldSphere.center.x = arg2->x; - collider->elements[idx].dim.worldSphere.center.y = arg2->y; - collider->elements[idx].dim.worldSphere.center.z = arg2->z; - - collider->elements[idx].dim.worldSphere.radius = - collider->elements[idx].dim.modelSphere.radius * collider->elements[idx].dim.scale; -} - -void BossGanon2_SetObjectSegment(BossGanon2* this, GlobalContext* globalCtx, s32 objectId, u8 setRSPSegment) { - s32 pad; - s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, objectId); - - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[objectIdx].vromStart); - - if (setRSPSegment) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 790); - - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[objectIdx].vromStart); - gSPSegment(POLY_XLU_DISP++, 0x06, gObjectTable[objectIdx].vromStart); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 799); - } -} - -void func_808FD210(GlobalContext* globalCtx, Vec3f* arg1) { - BossGanon2Effect* effect = globalCtx->specialEffects; - - effect->type = 1; - effect->position = *arg1; - effect->unk_2E = 0; - effect->unk_01 = 0; - effect->velocity.x = 25.0f; - effect->velocity.y = 15.0f; - effect->velocity.z = 0.0f; - effect->accel.x = 0.0f; - effect->accel.y = -1.0f; - effect->accel.z = 0.0f; -} - -void func_808FD27C(GlobalContext* globalCtx, Vec3f* position, Vec3f* velocity, f32 scale) { - BossGanon2Effect* effect = globalCtx->specialEffects; - s16 i; - - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { - if (effect->type == 0) { - effect->type = 2; - effect->position = *position; - effect->velocity = *velocity; - effect->accel.x = 0.0; - effect->accel.y = -1.0f; - effect->accel.z = 0.0; - effect->unk_38.z = Rand_ZeroFloat(2 * M_PI); - effect->unk_38.y = Rand_ZeroFloat(2 * M_PI); - effect->unk_38.x = Rand_ZeroFloat(2 * M_PI); - effect->scale = scale; - break; - } - } -} - -void BossGanon2_Init(Actor* thisx, GlobalContext* globalCtx) { - BossGanon2* this = (BossGanon2*)thisx; - s32 pad; - s16 i; - - globalCtx->specialEffects = sParticles; - - for (i = 0; i < ARRAY_COUNT(sParticles); i++) { - sParticles[i].type = 0; - } - - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.colChkInfo.health = 30; - Collider_InitJntSph(globalCtx, &this->unk_424); - Collider_SetJntSph(globalCtx, &this->unk_424, &this->actor, &sJntSphInit1, this->unk_464); - Collider_InitJntSph(globalCtx, &this->unk_444); - Collider_SetJntSph(globalCtx, &this->unk_444, &this->actor, &sJntSphInit2, this->unk_864); - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON, false); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDorfSkel, NULL, NULL, NULL, 0); - func_808FD5C4(this, globalCtx); - this->actor.naviEnemyId = 0x3E; - this->actor.gravity = 0.0f; -} - -void BossGanon2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BossGanon2* this = (BossGanon2*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyJntSph(globalCtx, &this->unk_424); - Collider_DestroyJntSph(globalCtx, &this->unk_444); -} - -void func_808FD4D4(BossGanon2* this, GlobalContext* globalCtx, s16 arg2, s16 arg3) { - if ((arg2 == 0) || (arg2 == 1)) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->unk_1D0, 25.0f, arg3, 8.0f, 0x1F4, 0xA, 1); - } - - if ((arg2 == 0) || (arg2 == 2)) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->unk_1DC, 25.0f, arg3, 8.0f, 0x1F4, 0xA, 1); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_WALK); - func_80033E88(&this->actor, globalCtx, 2, 0xA); -} - -void func_808FD5C4(BossGanon2* this, GlobalContext* globalCtx) { - this->actionFunc = func_808FD5F4; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.world.pos.y = -3000.0f; -} - -void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { - s16 pad; - u8 sp8D; - Player* player; - s32 objectIdx; - s32 zero = 0; - s32 pad2; - - sp8D = false; - player = GET_PLAYER(globalCtx); - this->unk_398++; - - switch (this->unk_39C) { - case 0: - objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME3); - if (Object_IsLoaded(&globalCtx->objectCtx, objectIdx)) { - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->unk_39E = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); - this->unk_39C = 1; - sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 970.0f, - 1086.0f, -200.0f, 0, 0, 0, 1); - sZelda->unk_3C8 = 0; - sZelda->actor.world.pos.x = 970.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -214.0f; - sZelda->actor.shape.rot.y = -0x7000; - this->unk_3BC.x = 0.0f; - this->unk_3BC.y = 1.0f; - this->unk_3BC.z = 0.0f; - this->unk_398 = 0; - this->unk_3A4.x = 0.0f; - this->unk_3A4.y = 1400.0f; - this->unk_3A4.z = 1600.0f; - player->actor.world.pos.x = 970.0f; - player->actor.world.pos.y = 1086.0f; - player->actor.world.pos.z = -186.0f; - player->actor.shape.rot.y = -0x5000; - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime3_Anim_002168, 0.0f); - globalCtx->envCtx.unk_D8 = 0.0f; - // fake, tricks the compiler into allocating more stack - if (zero) { - this->unk_3A4.x *= 2.0; - } - } else { - break; - } - case 1: - if (this->unk_398 < 70) { - globalCtx->envCtx.unk_D8 = 0.0f; - } - this->unk_339 = 3; - Math_ApproachF(&this->unk_3A4.x, 1500.0f, 0.1f, this->unk_410.x * 1500.0f); - Math_ApproachF(&this->unk_3A4.z, -160.0f, 0.1f, this->unk_410.x * 1760.0f); - Math_ApproachF(&this->unk_410.x, 0.0075f, 1.0f, 0.0001f); - this->unk_3B0.x = -200.0f; - this->unk_3B0.y = 1086.0f; - this->unk_3B0.z = -200.0f; - if (this->unk_398 == 150) { - Message_StartTextbox(globalCtx, 0x70D3, NULL); - } - if (this->unk_398 > 250 && Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { - this->unk_39C = 2; - this->unk_398 = 0; - this->unk_410.x = 0.0f; - globalCtx->envCtx.unk_D8 = 1.0f; - } else { - break; - } - case 2: - this->unk_339 = 4; - player->actor.world.pos.x = 970.0f; - player->actor.world.pos.y = 1086.0f; - player->actor.world.pos.z = -166.0f; - sZelda->actor.world.pos.x = 974.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; - player->actor.shape.rot.y = -0x5000; - sZelda->actor.shape.rot.y = -0x5000; - if (this->unk_398 == 60) { - Message_StartTextbox(globalCtx, 0x70D4, NULL); - } - if (this->unk_398 == 40) { - sZelda->unk_3C8 = 1; - func_8002DF54(globalCtx, &this->actor, 0x4E); - } - if (this->unk_398 == 85) { - sZelda->unk_3C8 = 2; - func_8002DF54(globalCtx, &this->actor, 0x4F); - } - this->unk_3A4.x = 930.0f; - this->unk_3A4.y = 1129.0f; - this->unk_3A4.z = -181.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.z = (player->actor.world.pos.z - 15.0f) + 5.0f; - if (this->unk_398 > 104) { - Math_ApproachF(&this->unk_3B0.y, player->actor.world.pos.y + 47.0f + 7.0f + 15.0f, 0.1f, - this->unk_410.x); - Math_ApproachF(&this->unk_410.x, 2.0f, 1.0f, 0.1f); - } else { - this->unk_3B0.y = player->actor.world.pos.y + 47.0f + 7.0f; - } - if ((this->unk_398 > 170) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->unk_39C = 3; - this->unk_398 = 0; - this->unk_410.x = 0.0f; - } - break; - case 3: - Math_ApproachF(&this->unk_3B0.y, player->actor.world.pos.y + 47.0f + 7.0f, 0.1f, 2.0f); - this->unk_339 = 4; - if (this->unk_398 == 10) { - func_80078914(&D_80906D6C, NA_SE_EV_STONE_BOUND); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); - } - if (this->unk_398 == 20) { - sZelda->unk_3C8 = 3; - func_8002DF54(globalCtx, &this->actor, 0x50); - } - if (this->unk_398 == 55) { - this->unk_39C = 4; - this->unk_398 = 0; - this->unk_410.x = 0.0f; - sZelda->unk_3C8 = 4; - func_8002DF54(globalCtx, &this->actor, 0x50); - } - break; - case 4: - this->unk_339 = 4; - Math_ApproachF(&this->unk_3A4.x, -360.0f, 0.1f, this->unk_410.x * 1290.0f); - Math_ApproachF(&this->unk_3A4.z, -20.0f, 0.1f, this->unk_410.x * 170.0f); - Math_ApproachF(&this->unk_410.x, 0.04f, 1.0f, 0.0005f); - if (this->unk_398 == 100) { - Camera* camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); - - camera->eye = this->unk_3A4; - camera->eyeNext = this->unk_3A4; - camera->at = this->unk_3B0; - func_800C08AC(globalCtx, this->unk_39E, 0); - this->unk_39E = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->unk_39C = 5; - this->unk_398 = 0; - } - break; - case 5: - this->unk_339 = 4; - if (this->actor.xzDistToPlayer < 500.0f) { - Message_CloseTextbox(globalCtx); - this->unk_39C = 10; - this->unk_398 = 0; - func_80064520(globalCtx, &globalCtx->csCtx); - this->unk_39E = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); - } else { - break; - } - case 10: - player->actor.world.pos.x = 490.0f; - player->actor.world.pos.y = 1086.0f; - player->actor.world.pos.z = -166.0f; - sZelda->actor.world.pos.x = 724.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; - player->actor.shape.rot.y = -0x4000; - sZelda->actor.shape.rot.y = -0x5000; - this->unk_3A4.x = 410.0f; - this->unk_3A4.y = 1096.0f; - this->unk_3A4.z = -110.0f; - this->unk_3B0.x = player->actor.world.pos.x + 10.0f; - this->unk_3B0.y = (player->actor.world.pos.y + 200.0f) - 160.0f; - this->unk_3B0.z = player->actor.world.pos.z; - if (this->unk_398 >= 20) { - func_80078884(NA_SE_EN_GOMA_LAST - SFX_FLAG); - Math_ApproachF(&this->unk_324, 255.0f, 1.0f, 10.0f); - this->unk_339 = 5; - if (this->unk_398 == 20) { - this->unk_33C = 0.0f; - globalCtx->envCtx.unk_D8 = 0.0f; - } - } else { - this->unk_339 = 4; - } - if (this->unk_398 == 30) { - sZelda->unk_3C8 = 5; - func_8002DF54(globalCtx, &this->actor, 0x51); - } - if (this->unk_398 == 50) { - this->unk_398 = 0; - this->unk_39C = 11; - } - break; - case 11: - this->unk_339 = 5; - func_80078884(NA_SE_EN_GOMA_LAST - SFX_FLAG); - player->actor.world.pos.x = 490.0f; - player->actor.world.pos.y = 1086.0f; - player->actor.world.pos.z = -166.0f; - sZelda->actor.world.pos.x = 724.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; - player->actor.shape.rot.y = -0x4000; - sZelda->actor.shape.rot.y = -0x5000; - this->unk_3A4.x = 450.0f; - this->unk_3A4.y = 1121.0f; - this->unk_3A4.z = -158.0f; - this->unk_3B0.x = (player->actor.world.pos.x - 20.0f) + 2.0f; - this->unk_3B0.y = ((player->actor.world.pos.y + 200.0f) - 151.0f) - 2.0f; - this->unk_3B0.z = player->actor.world.pos.z + 2.0f; - if (this->unk_398 == 10) { - func_80078914(&D_80906D6C, NA_SE_EV_STONE_BOUND); - } - if (this->unk_398 == 20) { - func_80078884(NA_SE_EV_STONE_BOUND); - } - if (this->unk_398 == 30) { - func_8002DF54(globalCtx, &this->actor, 0x52); - } - if (this->unk_398 == 50) { - this->unk_398 = 0; - this->unk_39C = 12; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_002168, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_002168); - this->actor.world.pos.x = this->actor.world.pos.z = -200.0f; - this->actor.world.pos.y = 1009.0f; - this->actor.shape.yOffset = 7000.0f; - this->actor.world.rot.y = 0x5000; - this->unk_3A4.x = -60.0f; - this->unk_3A4.y = 1106.0f; - this->unk_3A4.z = -200.0f; - this->unk_3B0.x = this->unk_3B0.z = -200.0f; - this->unk_3B0.y = this->actor.world.pos.y + 70.0f; - globalCtx->envCtx.unk_D8 = 0.0f; - globalCtx->envCtx.unk_BE = globalCtx->envCtx.unk_BD = 0; - this->unk_339 = 0; - } else { - break; - } - case 12: - case 13: - SkelAnime_Update(&this->skelAnime); - if (this->unk_398 == 30) { - D_80906D78 = 1; - this->unk_314 = 1; - func_800A9F6C(0.0f, 0xC8, 0x14, 0x14); - } - if (this->unk_398 == 30) { - func_80078884(NA_SE_EV_GRAVE_EXPLOSION); - } - if (this->unk_398 >= 30) { - Math_ApproachF(&this->actor.world.pos.y, 1289.0f, 0.1f, 10.0f); - this->unk_3B0.y = this->actor.world.pos.y + 70.0f; - } - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime3_Anim_002E6C, 0.0f); - this->unk_39C = 14; - this->unk_398 = 0; - this->actor.world.pos.x = -200.0f; - this->actor.world.pos.y = this->actor.world.pos.y - 30.0f; - this->actor.world.pos.z = -200.0f; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_OPENING_GANON); - } else { - break; - } - case 14: - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.world.pos.y, 1289.0f, 0.05f, 1.0f); - player->actor.world.pos.x = 250.0f; - player->actor.world.pos.y = 1086.0f; - player->actor.world.pos.z = -266.0f; - player->actor.shape.rot.y = -0x4000; - sZelda->actor.world.pos.x = 724.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; - this->unk_3A4.x = this->actor.world.pos.x + -10.0f; - this->unk_3A4.y = this->actor.world.pos.y + 80.0f; - this->unk_3A4.z = this->actor.world.pos.z + 50.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = player->actor.world.pos.y; - this->unk_3B0.z = player->actor.world.pos.z - 200.0f; - if (this->unk_398 == 20) { - func_8002DF54(globalCtx, &this->actor, 0x1E); - } - if (this->unk_398 == 60) { - this->unk_3A4.x = (this->actor.world.pos.x + 200.0f) - 154.0f; - this->unk_3A4.y = this->actor.world.pos.y + 60.0f; - this->unk_3A4.z = this->actor.world.pos.z - 15.0f; - this->unk_39C = 15; - this->unk_398 = 0; - this->unk_3B0.y = this->actor.world.pos.y + 77.0f + 100.0f; - this->unk_314 = 2; - this->unk_3B0.z = this->actor.world.pos.z + 5.0f; - this->unk_3B0.x = this->actor.world.pos.x; - } - if ((globalCtx->gameplayFrames % 32) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BREATH); - } - break; - case 15: - if (((globalCtx->gameplayFrames % 32) == 0) && (this->unk_398 < 100)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BREATH); - } - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->unk_3B0.y, this->actor.world.pos.y + 77.0f, 0.05f, 5.0f); - if (this->unk_398 >= 50) { - if (this->unk_398 == 50) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_000BFC, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_000BFC); - this->unk_314 = 3; - } - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon_anime3_Anim_003F38, 0.0f); - this->unk_194 = 1000.0f; - } - } - if (this->unk_398 > 70) { - Math_ApproachF(&this->unk_1B4, 255.0f, 1.0f, 10.0f); - } - if (this->unk_398 == 140) { - this->unk_39C = 16; - this->unk_398 = 0; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_003754, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_003754); - this->unk_339 = 55; - globalCtx->envCtx.unk_D8 = 1.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_CASBREAK); - } else { - break; - } - case 16: - if (this->unk_398 < 25) { - this->unk_339 = 55; - } else { - this->unk_339 = 6; - if (this->unk_194 > 100.0f) { - Math_ApproachF(&this->unk_30C, 15.0f, 1.0f, 2.0f); - } else { - Math_ApproachF(&this->unk_30C, 7.0f, 1.0f, 0.2f); - } - } - this->unk_1B4 = 0.0f; - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_0028A8, 0.0f); - this->unk_194 = 1000.0f; - } - Math_ApproachF(&this->unk_3A4.x, (this->actor.world.pos.x + 200.0f) - 90.0f, 0.1f, 6.3999996f); - Math_ApproachF(&this->unk_3A4.y, ((this->actor.world.pos.y + 60.0f) - 60.0f) - 70.0f, 0.1f, 13.0f); - Math_ApproachF(&this->unk_3B0.y, this->actor.world.pos.y + 40.0f, 0.1f, 3.6999998f); - if (this->unk_398 == 30) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BIGMASIC); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_THROW_BIG); - } - if (this->unk_398 <= 50) { - sp8D = true; - } - if (this->unk_398 >= 60) { - Camera* camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); - - camera->eye = this->unk_3A4; - camera->eyeNext = this->unk_3A4; - camera->at = this->unk_3B0; - this->unk_39C = 17; - this->unk_398 = 0; - this->unk_337 = 2; - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON2, false); - SkelAnime_Free(&this->skelAnime, globalCtx); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ganon2_Skel_025970, NULL, NULL, NULL, 0); - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON_ANIME3, false); - func_8002DF54(globalCtx, &this->actor, 0x54); - this->unk_314 = 3; - } - // fake, tricks the compiler into using stack the way we need it to - if (zero) { - Math_ApproachF(&this->unk_3B0.y, 0.0f, 0.0f, 0.0f); - } - break; - case 17: - this->unk_339 = 6; - SkelAnime_Update(&this->skelAnime); - this->unk_3A4.x = player->actor.world.pos.x - 40.0f; - this->unk_3A4.y = player->actor.world.pos.y + 40.0f; - this->unk_3A4.z = player->actor.world.pos.z + 20.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = (player->actor.world.pos.y + 10.0f + 60.0f) - 30.0f; - this->unk_3B0.z = player->actor.world.pos.z; - if (this->unk_398 == 25) { - this->unk_39C = 18; - this->unk_398 = 0; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_010380, 0.0f); - this->skelAnime.playSpeed = 0.0f; - this->unk_3A4.x = ((this->actor.world.pos.x + 500.0f) - 350.0f) - 50.0f; - this->unk_3A4.y = this->actor.world.pos.y; - this->unk_3A4.z = this->actor.world.pos.z; - this->unk_3B0.x = this->actor.world.pos.x + 50.0f; - this->unk_3B0.y = this->actor.world.pos.y + 60.0f; - this->unk_3B0.z = this->actor.world.pos.z; - this->actor.world.rot.y = 0x4000; - } - break; - case 18: - this->unk_339 = 6; - if (this->unk_398 == 30) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANON_BOSS); - } - Math_ApproachF(&this->unk_30C, 7.0f, 1.0f, 0.1f); - Math_ApproachF(&this->unk_3A4.x, (this->actor.world.pos.x + 500.0f) - 350.0f, 0.1f, 1.0f); - Math_ApproachF(&this->unk_3B0.x, this->actor.world.pos.x, 0.1f, 1.0f); - Math_ApproachF(&this->unk_228, 1.0f, 0.1f, 0.02f); - if (this->unk_398 == 65) { - this->unk_39C = 19; - this->unk_398 = 0; - } - break; - case 19: - this->unk_394 += 0.5f; - this->unk_339 = 6; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.velocity.y -= 1.0f; - if (this->unk_398 == 10) { - this->unk_39C = 20; - this->unk_398 = 0; - this->actor.world.pos.x += 250; - this->actor.world.pos.y = 1886.0f; - this->unk_394 = 0.0f; - func_8002DF54(globalCtx, &this->actor, 0x53); - this->unk_30C = 5.0f; - this->unk_228 = 1.0f; - } - break; - case 20: - this->unk_339 = 6; - SkelAnime_Update(&this->skelAnime); - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.velocity.y -= 1.0f; - player->actor.world.pos.x = 250.0f; - player->actor.world.pos.y = 1086.0f; - player->actor.world.pos.z = -266.0f; - player->actor.shape.rot.y = -0x4000; - this->unk_3A4.x = (player->actor.world.pos.x - 40.0f) - 200.0f; - this->unk_3A4.y = (player->actor.world.pos.y + 40.0f) - 30.0f; - this->unk_3A4.z = (player->actor.world.pos.z - 20.0f) + 100.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) + 30.0f; - this->unk_3B0.z = player->actor.world.pos.z; - this->unk_3BC.x = 0.8f; - if (this->actor.world.pos.y <= 1099.0f) { - this->actor.world.pos.y = 1099.0f; - this->unk_39C = 21; - this->unk_398 = 0; - this->unk_420 = 10.0f; - this->actor.velocity.y = 0.0f; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_010380, 0.0f); - func_808FD4D4(this, globalCtx, 0, 3); - func_800A9F6C(0.0f, 0xC8, 0x14, 0x14); - } - break; - case 21: - this->unk_339 = 6; - SkelAnime_Update(&this->skelAnime); - this->unk_41C = Math_CosS(globalCtx->gameplayFrames * 0x8000) * this->unk_420; - Math_ApproachZeroF(&this->unk_420, 1.0f, 0.75f); - if (this->unk_398 == 30) { - this->unk_39C = 22; - this->unk_30C = 10.0f; - } else { - break; - } - case 22: - if (this->unk_398 < 60) { - this->unk_339 = 7; - } - this->unk_3BC.x = 0.0f; - this->actor.world.pos.y = 1099.0f; - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->unk_30C, 1.0f, 0.1f); - if (this->unk_398 > 50) { - Math_ApproachF(&this->unk_224, 1.0f, 1.0f, 0.025f); - } - if (this->unk_398 == 60) { - this->unk_336 = 2; - } - if (this->unk_398 == 80) { - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON2, false); - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(object_ganon2_Tex_021A90), 160, 180, 128, 40); - } - this->unk_3A4.x = ((this->actor.world.pos.x + 500.0f) - 350.0f) + 100.0f; - this->unk_3A4.y = this->actor.world.pos.y; - this->unk_3A4.z = this->actor.world.pos.z; - this->unk_3B0.x = this->actor.world.pos.x; - this->unk_3B0.z = this->actor.world.pos.z; - this->unk_3B0.y = (this->unk_1B8.y + 60.0f) - 40.0f; - if (this->unk_398 > 166 && this->unk_398 < 173) { - this->unk_312 = 2; - } - if (this->unk_398 > 186 && this->unk_398 < 196) { - this->unk_312 = 1; - } - if (this->unk_398 > 202 && this->unk_398 < 210) { - this->unk_312 = 2; - } - if ((this->unk_398 == 166) || (this->unk_398 == 185) || (this->unk_398 == 200)) { - func_80078884(NA_SE_EN_MGANON_SWORD); - func_80078884(NA_SE_EN_MGANON_ROAR); - } - if (this->unk_398 == 215) { - this->unk_39C = 23; - this->unk_224 = 0.0f; - func_8002DF54(globalCtx, &this->actor, 0x55); - } - break; - case 23: - SkelAnime_Update(&this->skelAnime); - if (this->unk_398 > 222 && this->unk_398 < 232) { - this->unk_312 = 2; - } - if (this->unk_398 == 222) { - func_80078884(NA_SE_EN_MGANON_SWORD); - func_80078884(NA_SE_EN_MGANON_ROAR); - } - this->unk_3A4.x = (player->actor.world.pos.x - 40.0f) + 6.0f; - this->unk_3A4.y = player->actor.world.pos.y + 40.0f; - this->unk_3A4.z = (player->actor.world.pos.z + 20.0f) - 7.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) - 2.0f; - this->unk_3B0.z = player->actor.world.pos.z; - if (this->unk_398 == 228) { - func_80078884(NA_SE_IT_SHIELD_REFLECT_SW); - func_8002DF54(globalCtx, &this->actor, 0x56); - func_800A9F6C(0.0f, 0xFF, 0xA, 0x32); - } - if (this->unk_398 >= 229) { - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = - globalCtx->envCtx.screenFillColor[2] = 255; - globalCtx->envCtx.screenFillColor[3] = 100; - if (this->unk_398 == 234) { - Vec3f sp68; - - globalCtx->envCtx.fillScreen = false; - this->unk_39C = 24; - this->unk_398 = 0; - sp68 = player->actor.world.pos; - sp68.y += 60.0f; - func_808FD210(globalCtx, &sp68); - globalCtx->envCtx.unk_D8 = 0.0f; - globalCtx->envCtx.unk_BE = 0; - this->unk_339 = 0; - } - } - break; - case 24: - SkelAnime_Update(&this->skelAnime); - if (1) { - BossGanon2Effect* effect = globalCtx->specialEffects; - - this->unk_3B0 = effect->position; - this->unk_3A4.x = effect->position.x + 70.0f; - this->unk_3A4.y = effect->position.y - 30.0f; - this->unk_3A4.z = effect->position.z + 70.0f; - } - if ((this->unk_398 & 3) == 0) { - func_80078884(NA_SE_IT_SWORD_SWING); - } - if (this->unk_398 == 25) { - func_8002DF54(globalCtx, &this->actor, 0x57); - this->unk_39C = 25; - this->unk_398 = 0; - } - break; - case 25: - SkelAnime_Update(&this->skelAnime); - this->unk_3A4.x = (player->actor.world.pos.x - 40.0f) + 80.0f; - this->unk_3A4.y = player->actor.world.pos.y + 40.0f + 10.0f; - this->unk_3A4.z = player->actor.world.pos.z + 20.0f + 10.0f; - this->unk_3B0.x = player->actor.world.pos.x - 20.0f; - this->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) - 3.0f; - this->unk_3B0.z = (player->actor.world.pos.z - 40.0f) - 10.0f; - if (this->unk_398 == 10) { - BossGanon2Effect* effect = globalCtx->specialEffects; - - effect->unk_2E = 1; - effect->position.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; - effect->position.y = sZelda->actor.world.pos.y + 350.0f; - effect->position.z = sZelda->actor.world.pos.z - 25.0f; - effect->velocity.x = 0.0f; - effect->velocity.z = 0.0f; - effect->velocity.y = -30.0f; - this->unk_39C = 26; - this->unk_398 = 0; - } else { - break; - } - case 26: - this->unk_3A4.x = sZelda->actor.world.pos.x + 100.0f + 30.0f; - this->unk_3A4.y = sZelda->actor.world.pos.y + 10.0f; - this->unk_3A4.z = sZelda->actor.world.pos.z + 5.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 30.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z - 20.0f; - this->unk_3BC.z = -0.5f; - if (this->unk_398 == 13) { - sZelda->unk_3C8 = 6; - } - if (this->unk_398 == 50) { - this->unk_39C = 27; - this->unk_398 = 0; - } - break; - case 27: - this->unk_3BC.z = 0.0f; - if (this->unk_398 == 4) { - func_8002DF54(globalCtx, &this->actor, 0x58); - } - this->unk_3A4.x = player->actor.world.pos.x - 20.0f; - this->unk_3A4.y = player->actor.world.pos.y + 50.0f; - this->unk_3A4.z = player->actor.world.pos.z; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = player->actor.world.pos.y + 50.0f; - this->unk_3B0.z = player->actor.world.pos.z; - if (this->unk_398 == 26) { - D_8090EB30 = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; - while (D_8090EB30 != NULL) { - if (D_8090EB30->id == ACTOR_EN_ELF) { - this->unk_3A4.x = D_8090EB30->world.pos.x - 30.0f; - this->unk_3A4.y = D_8090EB30->world.pos.y; - this->unk_3A4.z = D_8090EB30->world.pos.z; - this->unk_3B0.x = D_8090EB30->world.pos.x; - this->unk_3B0.y = D_8090EB30->world.pos.y; - this->unk_3B0.z = D_8090EB30->world.pos.z; - break; - } - D_8090EB30 = D_8090EB30->next; - } - this->unk_39C = 28; - this->unk_398 = 0; - } - break; - case 28: - if (this->unk_398 == 5) { - Message_StartTextbox(globalCtx, 0x70D6, NULL); - } - if (D_8090EB30 != NULL) { - this->unk_3A4.x = D_8090EB30->world.pos.x - 20.0f; - this->unk_3A4.y = D_8090EB30->world.pos.y; - this->unk_3A4.z = D_8090EB30->world.pos.z; - Math_ApproachF(&this->unk_3B0.x, D_8090EB30->world.pos.x, 0.2f, 50.0f); - Math_ApproachF(&this->unk_3B0.y, D_8090EB30->world.pos.y, 0.2f, 50.0f); - Math_ApproachF(&this->unk_3B0.z, D_8090EB30->world.pos.z, 0.2f, 50.0f); - if ((this->unk_398 > 40) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->unk_39C = 29; - this->unk_398 = 0; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon_anime3_Anim_0147E0, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_0147E0); - this->actor.shape.yOffset = 0.0f; - this->actor.world.pos.y = 1086.0f; - this->actor.gravity = -1.0f; - this->unk_335 = 1; - this->unk_224 = 1.0f; - } - } - break; - case 29: - SkelAnime_Update(&this->skelAnime); - this->unk_3A4.x = (((this->actor.world.pos.x + 500.0f) - 350.0f) + 100.0f) - 60.0f; - this->unk_3B0.x = this->actor.world.pos.x; - this->unk_3B0.z = this->actor.world.pos.z; - this->unk_3A4.y = this->actor.world.pos.y; - this->unk_3A4.z = this->actor.world.pos.z + 10.0f; - this->unk_3B0.y = (this->unk_1B8.y + 60.0f) - 40.0f; - player->actor.shape.rot.y = -0x4000; - player->actor.world.pos.x = 140.0f; - player->actor.world.pos.z = -196.0f; - if (this->unk_398 == 50) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_ROAR); - } - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Camera* camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); - - camera->eye = this->unk_3A4; - camera->eyeNext = this->unk_3A4; - camera->at = this->unk_3B0; - func_800C08AC(globalCtx, this->unk_39E, 0); - this->unk_39E = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->unk_39C = 0; - this->unk_337 = 1; - func_808FFDB0(this, globalCtx); - this->unk_1A2[1] = 50; - this->actor.flags |= ACTOR_FLAG_0; - sZelda->unk_3C8 = 7; - } - break; - } - - if ((this->unk_30C > 4.0f) && !sp8D) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_BODY_SPARK - SFX_FLAG); - } - - if (this->unk_39E != 0) { - // fake, tricks the compiler into putting some pointers on the stack - if (zero) { - osSyncPrintf(NULL, 0, 0); - } - this->unk_3B0.y += this->unk_41C; - Gameplay_CameraSetAtEyeUp(globalCtx, this->unk_39E, &this->unk_3B0, &this->unk_3A4, &this->unk_3BC); - } -} - -void func_808FF898(BossGanon2* this, GlobalContext* globalCtx) { - if ((this->unk_312 != 0) && (this->unk_39E == 0)) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - while (actor != NULL) { - if (actor->id == ACTOR_DEMO_GJ) { - DemoGj* gj = (DemoGj*)actor; - - if (((actor->params & 0xFF) == 0x10) || ((actor->params & 0xFF) == 0x11) || - ((actor->params & 0xFF) == 0x16)) { - if (SQ(this->unk_218.x - gj->dyna.actor.world.pos.x) + - SQ(this->unk_218.z - gj->dyna.actor.world.pos.z) < - SQ(100.0f)) { - s32 pad; - Vec3f sp28; - - Matrix_RotateY(((this->actor.shape.rot.y / (f32)0x8000) * M_PI) + 0.5f, MTXMODE_NEW); - sp28.x = 0.0f; - sp28.y = 0.0f; - sp28.z = 1.0f; - Matrix_MultVec3f(&sp28, &gj->unk_26C); - gj->killFlag = true; - func_800A9F6C(0.0f, 0x96, 0x14, 0x32); - this->unk_392 = 6; - return; - } - } - } - - actor = actor->next; - } - - if (this->unk_392 == 4) { - func_80078884(NA_SE_EV_GRAVE_EXPLOSION); - } - - if (this->unk_392 == 3) { - func_80078884(NA_SE_EN_MGANON_SWDIMP); - } - } -} - -s32 func_808FFA24(BossGanon2* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - - while (actor != NULL) { - if (actor->id == ACTOR_DEMO_GJ) { - DemoGj* gj = (DemoGj*)actor; - - if (((actor->params & 0xFF) == 0x10) || ((actor->params & 0xFF) == 0x11) || - ((actor->params & 0xFF) == 0x16)) { - if (SQ(this->actor.world.pos.x - gj->dyna.actor.world.pos.x) + - SQ(this->actor.world.pos.z - gj->dyna.actor.world.pos.z) < - SQ(200.0f)) { - return true; - } - } - } - - actor = actor->next; - } - - return false; -} - -void func_808FFAC8(BossGanon2* this, GlobalContext* globalCtx, u8 arg2) { - s16 temp_v1; - s16 phi_a1; - - if (this->unk_313 || (arg2 != 0)) { - phi_a1 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - - if (phi_a1 > 0x3000) { - phi_a1 = 0x3000; - } else if (phi_a1 < -0x3000) { - phi_a1 = -0x3000; - } - } else if (this->unk_19C & 0x20) { - phi_a1 = 0x3000; - } else { - phi_a1 = -0x3000; - } - - Math_ApproachS(&this->unk_31A, phi_a1, 5, 0x7D0); - - temp_v1 = Math_Atan2S(this->actor.xzDistToPlayer, 150.0f) - 0xBB8; - temp_v1 = CLAMP_MAX(temp_v1, 0x1B58); - temp_v1 = CLAMP_MIN(temp_v1, -0x1B58); - - Math_ApproachS(&this->unk_31C, temp_v1, 5, 0x7D0); -} - -void func_808FFBBC(BossGanon2* this, GlobalContext* globalCtx, u8 arg2) { - if (arg2 != 0 || this->unk_313) { - f32 phi_f0; - f32 phi_f2; - - Math_ApproachS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, this->unk_320); - - if (this->unk_334 != 0) { - phi_f0 = 5000.0f; - phi_f2 = 200.0f; - } else { - phi_f0 = 3000.0f; - phi_f2 = 30.0f; - } - - Math_ApproachF(&this->unk_320, phi_f0, 1.0f, phi_f2); - } else { - this->unk_320 = 0.0f; - } -} - -void func_808FFC84(BossGanon2* this) { - if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x2800) { - this->unk_313 = true; - this->actor.focus.pos = this->unk_1B8; - } else { - this->unk_313 = false; - this->actor.focus.pos = this->unk_1C4; - } -} - -void func_808FFCFC(BossGanon2* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < 150.0f && - ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x2800) { - this->unk_311 = false; - func_80900580(this, globalCtx); - Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); - } else if ((this->actor.bgCheckFlags & 8) && func_808FFA24(this, globalCtx)) { - this->unk_311 = false; - func_80900580(this, globalCtx); - Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); - } -} - -void func_808FFDB0(BossGanon2* this, GlobalContext* globalCtx) { - s32 sp28; - s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON2); - - if (Object_IsLoaded(&globalCtx->objectCtx, objectIdx)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[objectIdx].vromStart); - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_00FFE4, -10.0f); - this->actionFunc = func_808FFEBC; - - if (this->unk_334 != 0) { - this->unk_1A2[0] = Rand_ZeroFloat(30.0f); - } else { - this->unk_1A2[0] = 40; - } - - this->unk_336 = 1; - this->actor.flags |= ACTOR_FLAG_0; - this->unk_228 = 1.0f; - this->unk_224 = 1.0f; - } else { - this->actionFunc = func_808FFDB0; - } -} - -void func_808FFEBC(BossGanon2* this, GlobalContext* globalCtx) { - if (this->unk_390 == 0) { - this->unk_390 = (s16)Rand_ZeroFloat(50.0f) + 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_UNARI); - } - - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); - - if (this->unk_1A2[0] == 0) { - func_809002CC(this, globalCtx); - } else if (this->unk_1A2[1] == 0) { - func_808FFCFC(this, globalCtx); - } - - func_808FFAC8(this, globalCtx, 0); - func_808FFBBC(this, globalCtx, 0); -} - -void func_808FFF90(BossGanon2* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_00FFE4, -10.0f); - this->actionFunc = func_808FFFE0; - this->unk_1A2[0] = 40; -} - -void func_808FFFE0(BossGanon2* this, GlobalContext* globalCtx) { - s16 target; - - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); - - if (this->unk_1A2[0] == 0) { - func_809002CC(this, globalCtx); - } - - if (this->unk_1A2[0] < 30 && this->unk_1A2[0] >= 10) { - target = Math_SinS(this->unk_1A2[0] * 0x3000) * (f32)0x2000; - } else { - target = 0; - } - - Math_ApproachS(&this->unk_31A, target, 2, 0x4000); -} - -void func_809000A0(BossGanon2* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_026510, -2.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_026510); - this->unk_1AC = 0; - this->actionFunc = func_80900104; -} - -void func_80900104(BossGanon2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); - - switch (this->unk_1AC) { - case 0: - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - this->unk_1AC = 1; - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_026AF4, 0.0f); - this->unk_1A2[0] = 80; - } - break; - case 1: - if (this->unk_1A2[0] == 0) { - this->unk_1AC = 2; - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_027824, -5.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_027824); - } - break; - case 2: - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - func_809002CC(this, globalCtx); - } - break; - } -} - -void func_80900210(BossGanon2* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_00DFF0, -3.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_00DFF0); - this->actionFunc = func_8090026C; -} - -void func_8090026C(BossGanon2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - func_809002CC(this, globalCtx); - } -} - -void func_809002CC(BossGanon2* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_00E8EC, -10.0f); - this->actionFunc = func_80900344; - this->unk_338 = 0; - this->unk_1A2[0] = 100; - this->unk_390 = (s16)Rand_ZeroFloat(50.0f) + 50; -} - -void func_80900344(BossGanon2* this, GlobalContext* globalCtx) { - f32 phi_f0; - - if (this->unk_390 == 0) { - this->unk_390 = (s16)Rand_ZeroFloat(50.0f) + 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_UNARI); - } - - Math_ApproachF(&this->unk_324, 255.0f, 1.0f, 10.0f); - - if (this->unk_338 != 0) { - if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - func_808FD4D4(this, globalCtx, 1, 3); - } else if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - func_808FD4D4(this, globalCtx, 2, 3); - } - if (this->actor.xzDistToPlayer < 200.0f) { - this->unk_338 = 0; - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_00E8EC, -10.0f); - } else { - this->skelAnime.playSpeed = ((this->actor.xzDistToPlayer - 300.0f) * 0.005f) + 1.0f; - if (this->skelAnime.playSpeed > 2.0f) { - this->skelAnime.playSpeed = 2.0f; - } - if (this->unk_334 != 0) { - this->skelAnime.playSpeed *= 1.5f; - } - } - phi_f0 = this->skelAnime.playSpeed * 3.0f; - } else { - phi_f0 = 2.0f; - if (this->actor.xzDistToPlayer >= 200.0f) { - this->unk_338 = 1; - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_0353C0, -10.0f); - } - } - - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.speedXZ, phi_f0, 0.5f, 1.0f); - - if (this->unk_1A2[0] == 0) { - func_808FFDB0(this, globalCtx); - } else { - func_808FFCFC(this, globalCtx); - } - - func_808FFAC8(this, globalCtx, 1); - func_808FFBBC(this, globalCtx, 1); -} - -void func_80900580(BossGanon2* this, GlobalContext* globalCtx) { - if (this->unk_311 == 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_00ADD0, -5.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_00ADD0); - this->unk_198 = (this->unk_194 - 15.0f) - 5.0f; - } else { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_00CAF8, -5.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_00CAF8); - this->unk_198 = (this->unk_194 - 15.0f) - 5.0f; - } - - this->actionFunc = func_80900650; -} - -void func_80900650(BossGanon2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, this->unk_198)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_SWORD); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_ROAR); - } - - if (this->unk_311 == 0) { - if (((this->unk_198 - 4.0f) < this->skelAnime.curFrame) && - (this->skelAnime.curFrame < (this->unk_198 + 6.0f))) { - this->unk_312 = 1; - } - } else if ((((this->unk_198 - 4.0f) + 4.0f) < this->skelAnime.curFrame) && - (this->skelAnime.curFrame < (this->unk_198 + 6.0f))) { - this->unk_312 = 2; - } - - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); - - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - this->unk_311 = 1 - this->unk_311; - - if ((this->unk_311 == 1) && (this->actor.xzDistToPlayer < 250.0f) && this->unk_313) { - func_80900580(this, globalCtx); - } else { - func_808FFDB0(this, globalCtx); - } - } - - func_808FFAC8(this, globalCtx, 0); - - if ((this->unk_334 == 0) && (this->unk_311 == 0)) { - this->unk_320 = 0.0f; - } else { - func_808FFBBC(this, globalCtx, 0); - } -} - -void func_80900818(BossGanon2* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_02A848, -5.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_02A848); - this->actionFunc = func_80900890; - this->unk_1AC = 0; - this->unk_39C = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DEAD1); - this->unk_336 = 0; -} - -void func_80900890(BossGanon2* this, GlobalContext* globalCtx) { - Vec3f sp5C; - Vec3f sp50; - Camera* sp4C; - Player* player; - Camera* temp_v0; - Camera* temp_v0_2; - s32 pad; - f32 temp_f12; - f32 temp_f2; - - sp4C = Gameplay_GetCamera(globalCtx, MAIN_CAM); - player = GET_PLAYER(globalCtx); - SkelAnime_Update(&this->skelAnime); - this->unk_398++; - this->unk_339 = 20; - - switch (this->unk_39C) { - case 0: - func_80064520(globalCtx, &globalCtx->csCtx); - this->unk_39E = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); - func_8002DF54(globalCtx, &this->actor, 8); - this->unk_39C = 1; - this->unk_3A4 = sp4C->eye; - this->unk_3B0 = sp4C->at; - this->unk_1A2[0] = 300; - this->unk_1A2[1] = 100; - globalCtx->envCtx.unk_D8 = 0.0f; - case 1: - if (this->unk_1A2[1] == 50) { - func_80078884(NA_SE_EN_MGANON_WALK); - } - Matrix_RotateY(((this->actor.shape.rot.y / (f32)0x8000) * M_PI) + 0.3f, MTXMODE_NEW); - sp5C.x = 0.0f; - sp5C.y = 0.0f; - sp5C.z = 250.0f; - Matrix_MultVec3f(&sp5C, &sp50); - Math_ApproachF(&this->unk_3A4.x, this->actor.world.pos.x + sp50.x, 0.2f, 100.0f); - Math_ApproachF(&this->unk_3A4.y, 1136.0f, 0.2f, 100.0f); - Math_ApproachF(&this->unk_3A4.z, this->actor.world.pos.z + sp50.z, 0.2f, 100.0f); - Math_ApproachF(&this->unk_3B0.x, this->unk_1B8.x, 0.2f, 100.0f); - Math_ApproachF(&this->unk_3B0.y, this->unk_1B8.y, 0.2f, 100.0f); - Math_ApproachF(&this->unk_3B0.z, this->unk_1B8.z, 0.2f, 100.0f); - if (this->unk_1A2[1] == 0) { - this->unk_39C = 2; - this->unk_1A2[1] = 90; - } - break; - case 2: - this->unk_1A2[0] = 300; - this->unk_3A4.x = sZelda->actor.world.pos.x - 100.0f; - this->unk_3A4.y = sZelda->actor.world.pos.y + 30.0f; - this->unk_3A4.z = (sZelda->actor.world.pos.z + 30.0f) - 60.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 30.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z - 10.0f; - Math_ApproachZeroF(&this->unk_324, 1.0f, 5.0f); - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 1.0f / 51); - if (this->unk_1A2[1] == 80) { - Message_StartTextbox(globalCtx, 0x70D7, NULL); - } - if ((this->unk_1A2[1] < 30) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - temp_v0 = Gameplay_GetCamera(globalCtx, MAIN_CAM); - temp_v0->eye = this->unk_3A4; - temp_v0->eyeNext = this->unk_3A4; - temp_v0->at = this->unk_3B0; - func_800C08AC(globalCtx, this->unk_39E, 0); - this->unk_39E = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->unk_39C = 3; - } - break; - case 10: - func_80064520(globalCtx, &globalCtx->csCtx); - this->unk_39E = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); - this->unk_39C = 11; - this->unk_334 = 1; - func_8002DF54(globalCtx, &this->actor, 0x60); - this->unk_398 = 0; - case 11: - player->actor.world.pos.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; - player->actor.world.pos.z = sZelda->actor.world.pos.z - 25.0f; - player->actor.shape.rot.y = -0x8000; - this->unk_3A4.x = (player->actor.world.pos.x + 100.0f) - 80.0f; - this->unk_3A4.y = (player->actor.world.pos.y + 60.0f) - 40.0f; - this->unk_3A4.z = player->actor.world.pos.z - 110.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = (player->actor.world.pos.y + 60.0f) - 25.0f; - this->unk_3B0.z = player->actor.world.pos.z; - if (this->unk_398 == 80) { - temp_v0_2 = Gameplay_GetCamera(globalCtx, MAIN_CAM); - temp_v0_2->eye = this->unk_3A4; - temp_v0_2->eyeNext = this->unk_3A4; - temp_v0_2->at = this->unk_3B0; - this->unk_39C = 3; - func_800C08AC(globalCtx, this->unk_39E, 0); - this->unk_39E = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - } - break; - } - - if (this->unk_39E != 0) { - Gameplay_CameraSetAtEye(globalCtx, this->unk_39E, &this->unk_3B0, &this->unk_3A4); - } - - switch (this->unk_1AC) { - case 0: - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_034278, 0.0f); - this->unk_1AC = 1; - } - break; - case 1: - if ((globalCtx->gameplayFrames % 32) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_BREATH); - } - - if ((this->unk_1A2[0] == 0) || (this->unk_334 != 0)) { - temp_f2 = -200.0f - player->actor.world.pos.x; - temp_f12 = -200.0f - player->actor.world.pos.z; - - if (sqrtf(SQ(temp_f2) + SQ(temp_f12)) <= 784.0f) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_0334F8, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_0334F8); - this->unk_1AC = 2; - this->unk_1A2[0] = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_ROAR); - } - } - break; - case 2: - Math_ApproachF(&this->unk_324, 255.0f, 1.0f, 10.0f); - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 2.0f / 51.0f); - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - func_808FFDB0(this, globalCtx); - if (this->unk_334 == 0) { - this->actor.colChkInfo.health = 25; - } - this->unk_336 = 1; - } - break; - } - - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); -} - -void func_80901020(BossGanon2* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_02A848, -5.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_02A848); - this->actionFunc = func_8090120C; - this->unk_1AC = 0; - this->unk_39C = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DEAD1); - this->unk_314 = 4; -} - -void func_8090109C(BossGanon2* this, GlobalContext* globalCtx) { - u8 i; - - for (i = 0; i < 70; i++) { - Vec3f velocity; - Vec3f accel; - Vec3f pos; - - velocity.x = Rand_CenteredFloat(50.0f); - velocity.y = Rand_CenteredFloat(10.0f) + 5.0f; - velocity.z = Rand_CenteredFloat(50.0f); - accel.x = 0.0f; - accel.y = -1.0f; - accel.z = 0.0f; - pos.x = this->unk_1B8.x; - pos.y = this->unk_1B8.y; - pos.z = this->unk_1B8.z; - func_8002836C(globalCtx, &pos, &velocity, &accel, &sPrimColor, &sEnvColor, (s16)Rand_ZeroFloat(50.0f) + 50, 0, - 17); - } -} - -void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { - Player* player; - f32 temp_f14; - f32 temp_f12; - Camera* temp_v0_2; - s16 temp_a0_2; - f32 phi_f0; - s32 phi_a1; - - player = GET_PLAYER(globalCtx); - this->unk_398++; - SkelAnime_Update(&this->skelAnime); - - this->unk_3BC.x = 0.0f; - this->unk_3BC.y = 1.0f; - this->unk_3BC.z = 0.0f; - - switch (this->unk_39C) { - case 0: - func_80064520(globalCtx, &globalCtx->csCtx); - this->unk_39E = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); - func_8002DF54(globalCtx, &this->actor, 8); - this->unk_39C = 1; - this->unk_398 = 0; - sZelda->unk_3C8 = 9; - this->unk_31C = 0; - this->unk_1A2[2] = 0; - this->unk_336 = 0; - this->unk_324 = 0.0f; - this->actor.speedXZ = 0.0f; - this->unk_31A = this->unk_31C; - globalCtx->envCtx.unk_D8 = 0.0f; - case 1: - if (this->unk_398 < 90) { - this->unk_339 = 20; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.1f); - } else if (this->unk_398 >= 90) { - this->unk_339 = 21; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.08f); - } - if (this->unk_398 == 50) { - func_80078884(NA_SE_EN_MGANON_WALK); - } - if (this->unk_398 > 90) { - Math_ApproachF(&this->unk_380, 0.25f, 1.0f, 0.0125f); - this->unk_37C = 200.0f; - func_80078884(NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); - } - if (this->unk_398 >= 110) { - if (this->unk_398 == 110) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_HIT_THUNDER); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DAMAGE); - } - Math_ApproachF(&this->unk_30C, 10.0f, 0.2f, 5.0f); - this->skelAnime.playSpeed = 3.0f; - } - if (this->unk_398 == 120) { - func_8002DF54(globalCtx, &this->actor, 0x63); - } - this->actor.world.rot.y = 0x4000; - this->actor.world.pos.x = this->actor.world.pos.z = 0.0f; - player->actor.shape.rot.y = -0x4000; - player->actor.world.pos.x = 200.0f; - player->actor.world.pos.z = 30.0f; - sZelda->actor.world.pos.x = 340.0f; - sZelda->actor.world.pos.z = -250.0f; - sZelda->actor.world.rot.y = sZelda->actor.shape.rot.y = -0x2000; - this->unk_3A4.x = 250; - this->unk_3A4.y = 1150.0f; - this->unk_3A4.z = 0.0f; - this->unk_3B0.x = this->unk_1B8.x; - this->unk_3B0.y = this->unk_1B8.y; - this->unk_3B0.z = this->unk_1B8.z; - if (this->unk_398 > 135) { - this->unk_39C = 2; - this->unk_398 = 0; - } - break; - case 2: - this->unk_339 = 22; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.1f); - func_80078884(NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); - this->unk_3A4.x = 250; - this->unk_3A4.y = 1150.0f; - this->unk_3A4.z = 0.0f; - Math_ApproachF(&this->unk_3B0.x, sZelda->actor.world.pos.x, 0.2f, 20.0f); - Math_ApproachF(&this->unk_3B0.y, sZelda->actor.world.pos.y + 50.0f, 0.2f, 10.0f); - Math_ApproachF(&this->unk_3B0.z, sZelda->actor.world.pos.z, 0.2f, 20.0f); - if (this->unk_398 == 50) { - this->unk_39C = 3; - this->unk_398 = 0; - } - break; - case 3: - this->unk_339 = 22; - func_80078884(NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); - this->unk_3A4.x = 330.0f; - this->unk_3A4.y = 1120.0f; - this->unk_3A4.z = -150.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 40.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z; - if (this->unk_398 == 10) { - Message_StartTextbox(globalCtx, 0x70D8, NULL); - } - if ((this->unk_398 > 80) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - this->unk_39C = 4; - this->unk_398 = 0; - } - break; - case 4: - if (this->unk_398 > 10) { - Math_ApproachZeroF(&this->unk_37C, 1.0f, 10.0f); - if (this->unk_398 == 30) { - sZelda->unk_3C8 = 10; - } - this->unk_339 = 23; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - } else { - this->unk_339 = 22; - } - if (this->unk_398 == 100) { - this->unk_39C = 5; - this->unk_398 = 40; - this->skelAnime.playSpeed = 1.0f; - func_8002DF54(globalCtx, &this->actor, 0x64); - } - break; - case 5: - this->unk_339 = 23; - if ((this->unk_398 >= 60) && (this->unk_398 <= 90)) { - if (this->unk_398 == 62) { - func_80078884(NA_SE_EV_TRIFORCE_FLASH); - } - Math_ApproachF(&this->unk_38C, 200.0f, 1.0f, 8.0f); - } else { - Math_ApproachZeroF(&this->unk_38C, 1.0f, 8.0f); - } - if (this->unk_398 == 70) { - func_8002DF54(globalCtx, &this->actor, 0x65); - } - if (this->unk_398 == 150) { - func_8002DF54(globalCtx, &this->actor, 0x66); - } - this->unk_30C = 10.0f; - player->actor.world.pos.x = 250.0f; - player->actor.world.pos.z = 30.0f; - this->unk_3A4.x = player->actor.world.pos.x - 50.0f; - this->unk_3A4.y = player->actor.world.pos.y + 50.0f; - this->unk_3A4.z = player->actor.world.pos.z + 40.0f; - this->unk_3B0.x = player->actor.world.pos.x; - this->unk_3B0.y = player->actor.world.pos.y + 40.0f; - this->unk_3B0.z = player->actor.world.pos.z; - if (this->unk_398 == 166) { - temp_v0_2 = Gameplay_GetCamera(globalCtx, MAIN_CAM); - temp_v0_2->eye = this->unk_3A4; - temp_v0_2->eyeNext = this->unk_3A4; - temp_v0_2->at = this->unk_3B0; - func_800C08AC(globalCtx, this->unk_39E, 0); - this->unk_39E = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->unk_39C = 6; - } - break; - case 6: - this->unk_339 = 23; - temp_f14 = this->unk_1B8.x - player->actor.world.pos.x; - temp_f12 = this->unk_1B8.z - player->actor.world.pos.z; - temp_a0_2 = Math_Atan2S(temp_f12, temp_f14) - player->actor.shape.rot.y; - if ((ABS(temp_a0_2) < 0x2000) && (sqrtf(SQ(temp_f14) + SQ(temp_f12)) < 70.0f) && - (player->swordState != 0) && (player->heldItemActionParam == PLAYER_AP_SWORD_MASTER)) { - func_80064520(globalCtx, &globalCtx->csCtx); - this->unk_39E = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); - this->unk_39C = 7; - this->unk_398 = 0; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_003B1C, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_003B1C); - globalCtx->startPlayerCutscene(globalCtx, &this->actor, 0x61); - } else { - break; - } - case 7: - this->unk_339 = 23; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.2f); - player->actor.world.pos.x = 250.0f; - player->actor.shape.rot.y = -0x4000; - player->actor.world.pos.z = 30.0f; - if ((this->unk_398 == 20) || (this->unk_398 == 30) || (this->unk_398 == 65) || (this->unk_398 == 40)) { - func_80078884(NA_SE_VO_LI_SWORD_N); - func_80078884(NA_SE_IT_SWORD_SWING_HARD); - } - if ((this->unk_398 == 22) || (this->unk_398 == 35) || (this->unk_398 == 72) || (this->unk_398 == 45)) { - func_80078884(NA_SE_EN_MGANON_DAMAGE); - func_80078884(NA_SE_IT_SHIELD_BOUND); - globalCtx->envCtx.unk_D8 = 1.0f; - } - if ((this->unk_398 == 22) || (this->unk_398 == 35) || (this->unk_398 == 72) || (this->unk_398 == 45)) { - func_8090109C(this, globalCtx); - } - if ((this->unk_398 >= 34) && (this->unk_398 < 40)) { - this->unk_3A4.x = 269.0f; - this->unk_3A4.y = 1112.0f; - this->unk_3A4.z = -28.0f; - this->unk_3B0.x = 234.0f; - this->unk_3B0.y = 1117.0f; - this->unk_3B0.z = -11.0f; - } else { - if (this->unk_398 < 30) { - phi_a1 = 0; - } else if (this->unk_398 < 43) { - phi_a1 = 1; - } else { - this->unk_3BC.z = -0.8f; - player->actor.world.pos.x = 200.0f; - player->actor.world.pos.z = 10.0f; - phi_a1 = 2; - } - this->unk_3A4.x = D_8090702C[phi_a1].x + (player->actor.world.pos.x - 50.0f); - this->unk_3A4.y = D_8090702C[phi_a1].y + (player->actor.world.pos.y + 50.0f); - this->unk_3A4.z = D_8090702C[phi_a1].z + (player->actor.world.pos.z + 40.0f); - this->unk_3B0.x = D_80907050[phi_a1].x + player->actor.world.pos.x; - this->unk_3B0.y = D_80907050[phi_a1].y + (player->actor.world.pos.y + 40.0f); - this->unk_3B0.z = D_80907050[phi_a1].z + player->actor.world.pos.z; - } - if (this->unk_398 > 80) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - this->unk_39C = 75; - this->unk_398 = 0; - this->unk_3A4.x = 112.0f; - this->unk_3A4.y = 1146.0f; - this->unk_3A4.z = 202.0f; - this->unk_3B0.x = 110.0f; - this->unk_3B0.y = 1144.0f; - this->unk_3B0.z = 177.0f; - player->actor.world.pos.x = 200.0f; - this->unk_3BC.z = 0.0f; - } - break; - case 75: - this->unk_339 = 23; - if (this->unk_398 == 55) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_007288, 0.0f); - this->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_007288); - func_8002DF54(globalCtx, &this->actor, 0x62); - this->unk_39C = 8; - this->unk_398 = 1000; - } - break; - case 8: - if (this->unk_398 == 1025) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_STAND); - } - if (this->unk_398 >= 1000) { - if (this->unk_398 < 1040) { - this->unk_339 = 23; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.2f); - } - } - if (this->unk_398 == 1040) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DEAD2); - this->unk_336 = 2; - this->unk_339 = 0; - globalCtx->envCtx.unk_BE = 0; - globalCtx->envCtx.unk_D8 = 0.0f; - } - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_ganon2_Anim_008EB8, 0.0f); - this->unk_398 = 0; - this->unk_194 = 1000.0f; - } - this->unk_3A4.x = 250; - this->unk_3A4.y = 1150.0f; - this->unk_3A4.z = 0.0f; - this->unk_3B0.x = this->unk_1B8.x; - this->unk_3B0.y = this->unk_1B8.y; - this->unk_3B0.z = this->unk_1B8.z; - if ((this->unk_398 < 1000) && ((this->unk_398 % 16) == 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_SWORD); - } - if (this->unk_398 == 40) { - this->unk_39C = 9; - this->unk_398 = 0; - sZelda->unk_3C8 = 11; - Message_StartTextbox(globalCtx, 0x70D9, NULL); - this->unk_336 = 0; - globalCtx->envCtx.unk_D8 = 0.0f; - } - break; - case 9: - this->unk_339 = 24; - this->unk_3A4.x = 330.0f; - this->unk_3A4.y = 1120.0f; - this->unk_3A4.z = -150.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 40.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z; - if (this->unk_398 > 60) { - this->unk_39C = 10; - this->unk_398 = 0; - this->unk_410.x = 0.0f; - } - break; - case 10: - this->unk_339 = 24; - Math_ApproachF(&this->unk_3A4.x, 290.0f, 0.05f, this->unk_410.x); - Math_ApproachF(&this->unk_3A4.y, 1130.0f, 0.05f, this->unk_410.x * 0.25f); - Math_ApproachF(&this->unk_3A4.z, -260.0f, 0.05f, this->unk_410.x * 1.25f); - if ((this->unk_398 >= 40) && (this->unk_398 <= 110)) { - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.02f); - Math_ApproachF(&this->unk_384, 10.0f, 0.1f, 0.2f); - Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); - } else { - Math_ApproachZeroF(&this->unk_384, 1.0f, 0.2f); - } - if (this->unk_398 > 130) { - Math_ApproachF(&this->unk_3B0.y, (sZelda->actor.world.pos.y + 40.0f + 10.0f) - 20.0f, 0.1f, - this->unk_410.x); - } else { - Math_ApproachF(&this->unk_3B0.y, sZelda->actor.world.pos.y + 40.0f + 10.0f, 0.05f, - this->unk_410.x * 0.25f); - } - Math_ApproachF(&this->unk_410.x, 1.0f, 1.0f, 0.01f); - if (this->unk_398 == 10) { - sZelda->unk_3C8 = 12; - } - if (this->unk_398 == 110) { - sZelda->unk_3C8 = 13; - } - if (this->unk_398 == 140) { - Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_HUMAN_BOUND); - } - if (this->unk_398 < 160) { - break; - } - case 20: - globalCtx->nextEntranceIndex = 0x6B; - gSaveContext.nextCutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; - globalCtx->linkAgeOnLoad = 1; - break; - } - - if (this->unk_39E != 0) { - Gameplay_CameraSetAtEyeUp(globalCtx, this->unk_39E, &this->unk_3B0, &this->unk_3A4, &this->unk_3BC); - } - - switch (this->unk_1AC) { - case 0: - if (Animation_OnFrame(&this->skelAnime, this->unk_194)) { - Animation_MorphToLoop(&this->skelAnime, &object_ganon2_Anim_034278, 0.0f); - this->unk_1AC = 1; - } - break; - case 1: - if ((this->unk_39C < 7) && ((globalCtx->gameplayFrames % 32) == 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_BREATH); - } - break; - } -} - -void func_80902348(BossGanon2* this, GlobalContext* globalCtx) { - Player* player; - f32 temp_f2; - f32 temp_f12; - s16 i; - s16 j; - s16 phi_v0_2; - - if (this->unk_316 == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_864); i++) { - if (this->unk_444.elements[i].info.bumperFlags & 2) { - this->unk_444.elements[i].info.bumperFlags &= ~2; - } else if (this->unk_444.elements[i].info.toucherFlags & 2) { - this->unk_444.elements[i].info.toucherFlags &= ~2; - - if (this->unk_312 == 1) { - phi_v0_2 = 0x1800; - } else { - phi_v0_2 = 0; - } - - func_8002F6D4(globalCtx, &this->actor, 15.0f, this->actor.yawTowardsPlayer + phi_v0_2, 2.0f, 0); - sZelda->unk_3C8 = 8; - this->unk_316 = 10; - break; - } - } - } - - if (this->unk_324 > 0.0f) { - player = GET_PLAYER(globalCtx); - temp_f2 = -200.0f - player->actor.world.pos.x; - temp_f12 = -200.0f - player->actor.world.pos.z; - - if (sqrtf(SQ(temp_f2) + SQ(temp_f12)) > 784.0f) { - for (j = 0; j < ARRAY_COUNT(player->flameTimers); j++) { - player->flameTimers[j] = Rand_S16Offset(0, 200); - } - - player->isBurning = true; - func_8002F6D4(globalCtx, &this->actor, 10.0f, Math_Atan2S(temp_f12, temp_f2), 0.0f, 0x10); - sZelda->unk_3C8 = 8; - } - } -} - -void func_80902524(BossGanon2* this, GlobalContext* globalCtx) { - s8 temp_v0_4; - ColliderInfo* acHitInfo; - s16 i; - u8 phi_v1_2; - - osSyncPrintf("this->no_hit_time %d\n", this->unk_316); - if (this->unk_316 != 0 || ((this->unk_334 == 0) && (this->actionFunc == func_80900890))) { - for (i = 0; i < ARRAY_COUNT(this->unk_464); i++) { - this->unk_424.elements[i].info.bumperFlags &= ~2; - } - } - - osSyncPrintf("this->look_on %d\n", this->unk_313); - if (this->unk_313) { - if (this->actionFunc != func_808FFFE0) { - if (this->unk_424.elements[0].info.bumperFlags & 2) { - this->unk_424.elements[0].info.bumperFlags &= ~2; - acHitInfo = this->unk_424.elements[0].info.acHitInfo; - if ((acHitInfo->toucher.dmgFlags & 0x2000) && (this->actionFunc != func_80900890)) { - func_809000A0(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_HIT_THUNDER); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DAMAGE); - Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); - } else if ((this->actionFunc == func_80900890) && (acHitInfo->toucher.dmgFlags & 0x9000200)) { - this->unk_316 = 60; - this->unk_342 = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DAMAGE); - Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); - this->actor.colChkInfo.health -= 2; - temp_v0_4 = this->actor.colChkInfo.health; - if (temp_v0_4 < 0x15 && this->unk_334 == 0) { - func_80900818(this, globalCtx); - } else { - if (temp_v0_4 <= 0) { - func_80901020(this, globalCtx); - } else { - func_80900210(this, globalCtx); - } - } - } else if (this->actionFunc != func_80900890) { - func_808FFF90(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_HOOKSHOT_REFLECT); - } - } - } - } else { - if (this->unk_424.elements[15].info.bumperFlags & 2) { - this->unk_424.elements[15].info.bumperFlags &= ~2; - acHitInfo = this->unk_424.elements[15].info.acHitInfo; - this->unk_316 = 60; - this->unk_344 = 0x32; - this->unk_342 = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MGANON_DAMAGE); - Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); - phi_v1_2 = 1; - if (acHitInfo->toucher.dmgFlags & 0x9000200) { - if (acHitInfo->toucher.dmgFlags & 0x8000000) { - phi_v1_2 = 4; - } else { - phi_v1_2 = 2; - } - } - this->actor.colChkInfo.health -= phi_v1_2; - temp_v0_4 = this->actor.colChkInfo.health; - if ((temp_v0_4 < 0x15) && (this->unk_334 == 0)) { - func_80900818(this, globalCtx); - } else if ((temp_v0_4 <= 0) && (phi_v1_2 >= 2)) { - func_80901020(this, globalCtx); - } else { - if (temp_v0_4 <= 0) { - this->actor.colChkInfo.health = 1; - } - func_80900210(this, globalCtx); - } - } - } -} - -void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx) { - BossGanon2* this = (BossGanon2*)thisx; - s32 pad; - s16 i; - f32 phi_f2; - u16 i2; - Vec3f sp58; - Vec3f sp4C; - f32 angle; - f32 sp44; - - if ((this->unk_337 == 0) || (this->unk_337 == 2)) { - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON_ANIME3, false); - } else { - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON2, false); - Math_ApproachZeroF(&this->unk_30C, 1.0f, 0.5f); - } - func_808FFC84(this); - this->unk_312 = 0; - this->unk_19C++; - Actor_SetScale(&this->actor, 0.01f); - this->actionFunc(this, globalCtx); - for (i = 0; i < ARRAY_COUNT(this->unk_1A2); i++) { - if (this->unk_1A2[i] != 0) { - this->unk_1A2[i]--; - } - } - if (this->unk_316 != 0) { - this->unk_316--; - } - if (this->unk_342 != 0) { - this->unk_342--; - } - if (this->unk_390 != 0) { - this->unk_390--; - } - if (this->unk_392 != 0) { - this->unk_392--; - } - Actor_MoveForward(&this->actor); - this->actor.shape.rot = this->actor.world.rot; - if (this->unk_335 != 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 60.0f, 60.0f, 100.0f, 5); - if (this->actor.bgCheckFlags & 1) { - if (this->actor.velocity.y < -5.0f) { - func_80033E88(&this->actor, globalCtx, 5, 20); - func_80078884(NA_SE_IT_BOMB_EXPLOSION); - } - this->actor.velocity.y = 0.0f; - } - } - if (((this->unk_19C & 0x1F) == 0) && (Rand_ZeroOne() < 0.3f)) { - this->unk_318 = 4; - } - this->unk_310 = D_80907074[this->unk_318]; - if (this->unk_318 != 0) { - this->unk_318--; - } - this->unk_1B0 = (Math_SinS(this->unk_19C * 0x2AAA) * 64.0f) + 191.0f; - if (this->unk_344 != 0) { - this->unk_344--; - Math_ApproachF(&this->unk_360.x, 5000.0f, 0.5f, 3000.0f); - Math_ApproachF(&this->unk_370.x, 5500.0f, 0.5f, 3000.0f); - Math_ApproachF(&this->unk_360.z, 8000.0f, 0.1f, 4000.0f); - Math_ApproachF(&this->unk_370.z, 8000.0f, 0.1f, 4000.0f); - Math_ApproachS(&this->unk_346, 0xFA0, 0xA, 0x7D0); - } else { - this->unk_360.y = 14000.0f; - Math_ApproachF(&this->unk_360.x, 2000.0f, 0.1f, 100.0f); - this->unk_370.y = 12000.0f; - Math_ApproachF(&this->unk_370.x, 1500.0f, 0.1f, 100.0f); - if ((this->actionFunc == func_808FFEBC) || (this->actionFunc == func_808FFFE0) || - (this->actionFunc == func_80900104)) { - Math_ApproachF(&this->unk_360.z, 1000.0f, 0.1f, 100.0f); - Math_ApproachF(&this->unk_370.z, 1000.0f, 0.1f, 100.0f); - Math_ApproachS(&this->unk_346, -0xFA0, 0xA, 0x64); - } else { - Math_ApproachF(&this->unk_360.z, 5000.0f, 0.1f, 200.0f); - Math_ApproachF(&this->unk_370.z, 5000.0f, 0.1f, 200.0f); - Math_ApproachS(&this->unk_346, 0, 0xA, 0x64); - } - } - if (this->unk_39C != 75) { - this->unk_35C += this->unk_360.x; - this->unk_36C += this->unk_370.x; - } - if (this->unk_337 == 2) { - this->unk_370.z = 0.0f; - this->unk_360.z = 0.0f; - } - - for (i = 0; i < ARRAY_COUNT(this->unk_348); i++) { - if (i == 0) { - phi_f2 = 0.2f; - } else if (i == 1) { - phi_f2 = 0.5f; - } else { - phi_f2 = 1.0f; - } - - this->unk_348[i] = Math_SinS(((s16)this->unk_35C + (i * (s16)this->unk_360.y))) * phi_f2 * this->unk_360.z; - this->unk_352[i] = Math_SinS(((s16)this->unk_36C + (i * (s16)this->unk_370.y))) * phi_f2 * this->unk_370.z; - } - - func_808FF898(this, globalCtx); - func_80902348(this, globalCtx); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->unk_424.base); - if (this->actionFunc != func_8090120C) { - func_80902524(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_424.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->unk_444.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_444.base); - if (this->unk_39E == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->unk_444.base); - } - } - if ((this->unk_332 == 0) && (this->unk_336 != 0)) { - if (this->unk_336 == 2) { - this->unk_332 = (s16)Rand_ZeroFloat(30.0f) + 8; - } else { - this->unk_332 = (s16)Rand_ZeroFloat(60.0f) + 0xA; - } - this->unk_339 = 0; - globalCtx->envCtx.unk_BE = 0; - globalCtx->envCtx.unk_BD = (s8)Rand_ZeroFloat(1.9f) + 1; - globalCtx->envCtx.unk_D8 = 1.0f; - D_8090EB20.y = 0.0f; - D_8090EB20.x = D_8090EB20.y; - D_8090EB20.z = D_8090EB20.x; - if (Rand_ZeroOne() < 0.5f) { - D_8090EB20.z = Rand_ZeroFloat(1000.0f); - } - func_80078914(&D_8090EB20, NA_SE_EV_LIGHTNING); - this->unk_328 = 0xFF; - this->unk_330 = 5; - this->unk_32C = 0.0f; - this->unk_340 = (s16)Rand_ZeroFloat(10000.0f); - } else if (this->unk_332 != 0) { - this->unk_332--; - } - if ((globalCtx->envCtx.unk_D8 > 0.0f) && (this->unk_336 != 0)) { - globalCtx->envCtx.customSkyboxFilter = 1; - globalCtx->envCtx.skyboxFilterColor[0] = 255; - globalCtx->envCtx.skyboxFilterColor[1] = 255; - globalCtx->envCtx.skyboxFilterColor[2] = 255; - globalCtx->envCtx.skyboxFilterColor[3] = (s16)(globalCtx->envCtx.unk_D8 * 200.0f); - } else { - globalCtx->envCtx.customSkyboxFilter = 0; - } - globalCtx->envCtx.unk_BF = 0; - globalCtx->envCtx.unk_DC = 2; - - switch (this->unk_339) { - case 0: - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.1f); - break; - case 3: - globalCtx->envCtx.unk_BE = 3; - globalCtx->envCtx.unk_BD = 4; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.0125f); - break; - case 4: - globalCtx->envCtx.unk_BE = 5; - globalCtx->envCtx.unk_BD = 6; - Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.0125f); - break; - case 5: - globalCtx->envCtx.unk_BE = 6; - globalCtx->envCtx.unk_BD = 7; - Math_ApproachF(&this->unk_33C, 0.69f, 1.0f, 0.05f); - globalCtx->envCtx.unk_D8 = - (Math_SinS(globalCtx->gameplayFrames * 0x5000) * 0.15f) + (0.15f + this->unk_33C); - break; - case 55: - globalCtx->envCtx.unk_BE = 2; - globalCtx->envCtx.unk_BD = 0; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); - break; - case 6: - globalCtx->envCtx.unk_BE = 2; - globalCtx->envCtx.unk_BD = 8; - Math_ApproachF(&this->unk_33C, 0.69f, 1.0f, 0.05f); - globalCtx->envCtx.unk_D8 = - (Math_SinS(globalCtx->gameplayFrames * 0x7000) * 0.15f) + (0.15f + this->unk_33C); - break; - case 7: - globalCtx->envCtx.unk_BE = 0; - globalCtx->envCtx.unk_BD = 8; - Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.02f); - break; - case 20: - globalCtx->envCtx.unk_BE = 0; - globalCtx->envCtx.unk_BD = 9; - break; - case 21: - globalCtx->envCtx.unk_BE = 0xA; - globalCtx->envCtx.unk_BD = 9; - break; - case 22: - globalCtx->envCtx.unk_BE = 0xA; - globalCtx->envCtx.unk_BD = 0xB; - break; - case 23: - globalCtx->envCtx.unk_BE = 9; - globalCtx->envCtx.unk_BD = 0xB; - break; - case 24: - globalCtx->envCtx.unk_BE = 0; - globalCtx->envCtx.unk_BD = 0xC; - break; - case -1: - break; - } - - if (this->unk_339 >= 0) { - this->unk_339 = 0; - } - if (D_80906D78 != 0) { - D_80906D78 = 0; - - for (i2 = 0; i2 < ARRAY_COUNT(sParticles); i2++) { - angle = Rand_ZeroFloat(2 * M_PI); - sp44 = Rand_ZeroFloat(40.0f) + 10.0f; - sp58 = this->actor.world.pos; - sp58.y = 1200.0f; - sp4C.x = cosf(angle) * sp44; - sp4C.z = sinf(angle) * sp44; - sp4C.y = Rand_ZeroFloat(15.0f) + 15.0f; - sp58.x += sp4C.x * 10.0f * 0.1f; - sp58.z += sp4C.z * 10.0f * 0.1f; - func_808FD27C(globalCtx, &sp58, &sp4C, Rand_ZeroFloat(0.3f) + 0.2f); - } - } - this->unk_388 += 0.15f; - func_80905DA8(this, globalCtx); -} - -void func_809034E4(Vec3f* arg0, Vec3f* arg1) { - Vtx* vtx; - Vec3f sp2D0; - s16 temp_s1; - s16 temp_a1; - s16 sp2CA; - s16 sp2C8; - s16 i; - u8 phi_s2; - u8 temp_s4; - u8 temp_s4_2; - f32 temp_f12; - Vec3f temp_f20; - Vec3f temp_f2; - Vec3f temp_f22; - f32 sp294; - f32 phi_f30; - f32 temp_f28; - f32 temp_f26; - s32 pad[3]; - Vec3f sp18C[20]; - Vec3f sp9C[20]; - - for (i = 0; i < 20; i++) { - sp18C[i] = *arg0; - sp9C[i] = *arg1; - } - - temp_s4 = 0; - - D_809105D8[3] = D_809105D8[2]; - D_809105D8[2] = D_809105D8[1]; - D_809105D8[1] = D_809105D8[0]; - D_809105D8[0] = *arg0; - - sp2D0 = D_809105D8[0]; - - temp_f20.x = D_809105D8[1].x - sp2D0.x; - temp_f20.y = D_809105D8[1].y - sp2D0.y; - temp_f20.z = D_809105D8[1].z - sp2D0.z; - - sp2CA = Math_Atan2S(temp_f20.z, temp_f20.x); - sp2C8 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); - - temp_f2.x = D_809105D8[2].x - D_809105D8[1].x; - temp_f2.y = D_809105D8[2].y - D_809105D8[1].y; - temp_f2.z = D_809105D8[2].z - D_809105D8[1].z; - - temp_f22.x = D_809105D8[3].x - D_809105D8[2].x; - temp_f22.y = D_809105D8[3].y - D_809105D8[2].y; - temp_f22.z = D_809105D8[3].z - D_809105D8[2].z; - - temp_f12 = sqrtf(SQXYZ(temp_f20)) + sqrtf(SQXYZ(temp_f2)) + sqrtf(SQXYZ(temp_f22)); - if (temp_f12 <= 1.0f) { - temp_f12 = 1.0f; - } - - temp_f28 = temp_f12 * 0.083f; - phi_f30 = sqrtf(SQXYZ(temp_f20)) / 2.0f; - sp294 = sqrtf(SQXYZ(temp_f2)) / 2.0f; - - phi_s2 = 1; - - while (true) { - temp_f20.x = D_809105D8[phi_s2].x - sp2D0.x; - temp_f20.y = D_809105D8[phi_s2].y - sp2D0.y; - temp_f20.z = D_809105D8[phi_s2].z - sp2D0.z; - - temp_s1 = Math_Atan2S(temp_f20.z, temp_f20.x); - temp_a1 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); - - Math_ApproachS(&sp2C8, temp_a1, 1, 0x1000); - Math_ApproachS(&sp2CA, temp_s1, 1, 0x1000); - - temp_f26 = temp_f28 * Math_CosS(sp2C8); - - sp18C[temp_s4] = sp2D0; - - sp2D0.x += temp_f26 * Math_SinS(sp2CA); - sp2D0.y += temp_f28 * Math_SinS(sp2C8); - sp2D0.z += temp_f26 * Math_CosS(sp2CA); - - temp_f20.x = D_809105D8[phi_s2].x - sp2D0.x; - temp_f20.y = D_809105D8[phi_s2].y - sp2D0.y; - temp_f20.z = D_809105D8[phi_s2].z - sp2D0.z; - - if (phi_s2 < 3) { - if (sqrtf(SQXYZ(temp_f20)) <= phi_f30) { - phi_f30 = sp294; - phi_s2++; - } - } else { - if (sqrtf(SQXYZ(temp_f20)) <= (temp_f28 + 1.0f)) { - phi_s2++; - } - } - - temp_s4++; - - if ((temp_s4 >= 20) || (phi_s2 >= 4)) { - break; - } - } - - temp_s4_2 = 0; - - D_80910608[3] = D_80910608[2]; - D_80910608[2] = D_80910608[1]; - D_80910608[1] = D_80910608[0]; - D_80910608[0] = *arg1; - - sp2D0 = D_80910608[0]; - - temp_f20.x = D_80910608[1].x - sp2D0.x; - temp_f20.y = D_80910608[1].y - sp2D0.y; - temp_f20.z = D_80910608[1].z - sp2D0.z; - - sp2CA = Math_Atan2S(temp_f20.z, temp_f20.x); - sp2C8 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); - - temp_f2.x = D_80910608[2].x - D_80910608[1].x; - temp_f2.y = D_80910608[2].y - D_80910608[1].y; - temp_f2.z = D_80910608[2].z - D_80910608[1].z; - - temp_f22.x = D_80910608[3].x - D_80910608[2].x; - temp_f22.y = D_80910608[3].y - D_80910608[2].y; - temp_f22.z = D_80910608[3].z - D_80910608[2].z; - - temp_f12 = sqrtf(SQXYZ(temp_f20)) + sqrtf(SQXYZ(temp_f2)) + sqrtf(SQXYZ(temp_f22)); - if (temp_f12 <= 1.0f) { - temp_f12 = 1.0f; - } - - temp_f28 = temp_f12 * 0.083f; - phi_f30 = sqrtf(SQXYZ(temp_f20)) / 2.0f; - sp294 = sqrtf(SQXYZ(temp_f2)) / 2.0f; - - phi_s2 = 1; - - while (true) { - temp_f20.x = D_80910608[phi_s2].x - sp2D0.x; - temp_f20.y = D_80910608[phi_s2].y - sp2D0.y; - temp_f20.z = D_80910608[phi_s2].z - sp2D0.z; - - temp_s1 = Math_Atan2S(temp_f20.z, temp_f20.x); - temp_a1 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); - - Math_ApproachS(&sp2C8, temp_a1, 1, 0x1000); - Math_ApproachS(&sp2CA, temp_s1, 1, 0x1000); - - temp_f26 = temp_f28 * Math_CosS(sp2C8); - - sp9C[temp_s4_2] = sp2D0; - - sp2D0.x += temp_f26 * Math_SinS(sp2CA); - sp2D0.y += temp_f28 * Math_SinS(sp2C8); - sp2D0.z += temp_f26 * Math_CosS(sp2CA); - - temp_f20.x = D_80910608[phi_s2].x - sp2D0.x; - temp_f20.y = D_80910608[phi_s2].y - sp2D0.y; - temp_f20.z = D_80910608[phi_s2].z - sp2D0.z; - - if (phi_s2 < 3) { - if (sqrtf(SQXYZ(temp_f20)) <= phi_f30) { - phi_f30 = sp294; - phi_s2++; - } - } else { - if (sqrtf(SQXYZ(temp_f20)) <= (temp_f28 + 1.0f)) { - phi_s2++; - } - } - - temp_s4_2++; - - if ((temp_s4_2 >= 20) || (phi_s2 >= 4)) { - break; - } - } - - vtx = SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_Vtx_00BA20); - for (i = 0; i < 11; i++) { - if ((temp_s4 - i) > 0) { - vtx[D_80907084[i]].n.ob[0] = sp18C[temp_s4 - i - 1].x; - vtx[D_80907084[i]].n.ob[1] = sp18C[temp_s4 - i - 1].y; - vtx[D_80907084[i]].n.ob[2] = sp18C[temp_s4 - i - 1].z; - } - if ((temp_s4_2 - i) > 0) { - vtx[D_80907090[i]].n.ob[0] = sp9C[temp_s4_2 - i - 1].x; - vtx[D_80907090[i]].n.ob[1] = sp9C[temp_s4_2 - i - 1].y; - vtx[D_80907090[i]].n.ob[2] = sp9C[temp_s4_2 - i - 1].z; - } - } -} - -void func_80903F38(BossGanon2* this, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5083); - - if (this->unk_312 != 0) { - func_809034E4(&this->unk_200, &this->unk_20C); - D_80907080 = 0xFF; - } - - if (D_80910638 >= 4) { - gSPSegment( - POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, globalCtx->gameplayFrames * 18, 0, 32, 32)); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, D_80907080); - Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_NEW); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5117), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00BB80); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5122); -} - -void func_80904108(BossGanon2* this, GlobalContext* globalCtx) { - s32 pad; - - if (this->unk_324 > 0.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5131); - - Matrix_Push(); - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s32)globalCtx->gameplayFrames, 0, 32, 64, 1, - -globalCtx->gameplayFrames * 2, -globalCtx->gameplayFrames * 8, 32, 32)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 200, 0, (s8)this->unk_324); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); - Matrix_Translate(-200.0f, 1086.0f, -200.0f, MTXMODE_NEW); - Matrix_Scale(0.098000005f, 0.1f, 0.098000005f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5183), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00E1C0)); - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5186); - } -} - -void func_80904340(BossGanon2* this, GlobalContext* globalCtx) { - s16 i; - f32 rand; - f32 angle; - f32 sin; - f32 cos; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5196); - Matrix_Push(); - - if ((this->unk_330 != 0) || (this->unk_328 != 0)) { - if (this->unk_330 != 0) { - this->unk_330--; - } else { - this->unk_328 -= 70; - - if (this->unk_328 < 0) { - this->unk_328 = 0; - } - } - - Math_ApproachF(&this->unk_32C, 0.13f, 1.0f, 0.065f); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->unk_328); - BossGanon2_InitRand(this->unk_340 + 1, 0x71AC - this->unk_340, 0x263A); - rand = BossGanon2_RandZeroOne(); - if (1) {} - - for (i = 0; i < 5; i++) { - angle = (i * (2 * M_PI / 5)) + (rand * M_PI); - sin = 5000.0f * sinf(angle); - cos = 5000.0f * cosf(angle); - Matrix_Translate(-200.0f + sin, 4786.0f, -200.0f + cos, MTXMODE_NEW); - Matrix_Scale(this->unk_32C, this->unk_32C, this->unk_32C, MTXMODE_APPLY); - Matrix_RotateY(angle, MTXMODE_APPLY); - Matrix_RotateZ((BossGanon2_RandZeroOne() - 0.5f) * 100.0f * 0.01f, MTXMODE_APPLY); - - if (BossGanon2_RandZeroOne() < 0.5f) { - Matrix_RotateY(M_PI, MTXMODE_APPLY); - } - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5250), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00D798)); - } - } - - Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5255); -} - -void func_8090464C(BossGanon2* this, GlobalContext* globalCtx) { - s32 pad; - - if (this->unk_1B4 > 0.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5264); - - Matrix_Push(); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s16)this->unk_1B4); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 128); - Matrix_Translate(this->unk_1B8.x, this->unk_1B8.y, this->unk_1B8.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_RotateZ(-0.2f, MTXMODE_APPLY); - Matrix_Scale(0.6f, 0.6f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5290), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00CCD8)); - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5293); - } -} - -s32 BossGanon2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - s32 pad; - BossGanon2* this = (BossGanon2*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5355); - - if (limbIndex == 15) { - rot->y += this->unk_31A; - rot->z += this->unk_31C; - } - - if (limbIndex >= 42) { - rot->x += this->unk_2F4[limbIndex] + this->unk_346; - rot->y += this->unk_2FE[limbIndex]; - - if (this->unk_342 & 1) { - gDPSetEnvColor(POLY_OPA_DISP++, 255, 0, 0, 255); - } else { - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->unk_1B0, (s16)this->unk_1B0, (s16)(*this).unk_1B0, 255); - } - } - - if ((limbIndex == 7) || (limbIndex == 13) || (limbIndex == 33) || (limbIndex == 34)) { - *dList = NULL; - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5431); - return 0; -} - -void BossGanon2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - s8 pad; - s8 temp_v0; - BossGanon2* this = (BossGanon2*)thisx; - Vec3f sp4C; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5459); - - D_80907120.z = 17000.0f; - D_8090712C.z = 3000.0f; - - if (D_809070CC[limbIndex] >= 0) { - Matrix_MultVec3f(&D_80906D60, &this->unk_234[D_809070CC[limbIndex]]); - } - - if (limbIndex == 15) { - Matrix_MultVec3f(&D_80906D60, &this->unk_1B8); - } else if (limbIndex == 3) { - Matrix_MultVec3f(&D_80907108, &this->unk_1F4); - } else if (limbIndex == 9) { - Matrix_MultVec3f(&D_80907114, &this->unk_1E8); - } else if (limbIndex == 38) { - Matrix_MultVec3f(&D_80906D60, &this->unk_1DC); - } else if (limbIndex == 41) { - Matrix_MultVec3f(&D_80906D60, &this->unk_1D0); - } else if (limbIndex == 45) { - Matrix_MultVec3f(&D_80907138, &this->unk_1C4); - } - - temp_v0 = D_8090709C[limbIndex]; - if (temp_v0 >= 0) { - Matrix_MultVec3f(&D_80906D60, &sp4C); - func_808FD080(temp_v0, &this->unk_424, &sp4C); - } - - if ((limbIndex == 7) || (limbIndex == 13)) { - Matrix_Push(); - Matrix_Scale(this->unk_224, this->unk_224, this->unk_224, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5522), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - } else if ((limbIndex == 33) || (limbIndex == 34)) { - Matrix_Push(); - Matrix_Scale(this->unk_228, this->unk_228, this->unk_228, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5533), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - } - - if (*dList != NULL) { - if ((limbIndex == 7) && (this->unk_312 == 1)) { - Matrix_MultVec3f(&D_809070FC, &this->unk_218); - func_808FD080(0, &this->unk_444, &this->unk_218); - Matrix_MultVec3f(&D_80907120, &this->unk_200); - Matrix_MultVec3f(&D_8090712C, &this->unk_20C); - } else if ((limbIndex == 13) && (this->unk_312 == 2)) { - Matrix_MultVec3f(&D_809070FC, &this->unk_218); - func_808FD080(1, &this->unk_444, &this->unk_218); - Matrix_MultVec3f(&D_80907120, &this->unk_200); - Matrix_MultVec3f(&D_8090712C, &this->unk_20C); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5566); -} - -void func_80904D88(BossGanon2* this, GlobalContext* globalCtx) { - s32 pad; - s16 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5575); - - if (this->unk_30C > 0.0f) { - func_80093D84(globalCtx->state.gfxCtx); - if (this->unk_380 > 0.0f) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 0); - } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 100, 255, 255, 0); - } - gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); - - for (i = 0; i < 15; i++) { - Matrix_Translate(this->unk_234[i].x, this->unk_234[i].y, this->unk_234[i].z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_30C, this->unk_30C, this->unk_30C, MTXMODE_APPLY); - Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5618), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B378); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5622); -} - -void func_80904FC8(BossGanon2* this, GlobalContext* globalCtx) { - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5632); - - if (this->unk_384 > 0.0f) { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); - Matrix_Translate(sZelda->actor.world.pos.x, sZelda->actor.world.pos.y + 80.0f, sZelda->actor.world.pos.z, - MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(this->unk_384, this->unk_384, this->unk_384, MTXMODE_APPLY); - Matrix_RotateZ(this->unk_388, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5661), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); - Matrix_RotateZ(this->unk_388 * -2.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5664), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5667); -} - -void func_8090523C(BossGanon2* this, GlobalContext* globalCtx) { - Player* player; - f32 phi_f20; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5675); - - if (this->unk_38C > 0.0f) { - s8 i; - - player = GET_PLAYER(globalCtx); - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)this->unk_38C); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); - gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); - - for (i = 0; i < 11; i++) { - Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); - Matrix_Translate((i * 250.0f) + 900.0f, 350.0f, 0.0f, MTXMODE_APPLY); - - if (i < 7) { - phi_f20 = 1.0f; - } else { - phi_f20 = 1.0f - ((i - 7) * 0.2333333f); // 7 / 30 - } - - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(200.0f * phi_f20, 200.0f * phi_f20, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(Rand_ZeroFloat(2.0f * M_PI), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5721), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5725); -} - -void BossGanon2_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - s8 temp_v1 = D_80907144[limbIndex]; - BossGanon2* this = (BossGanon2*)thisx; - - if (temp_v1 >= 0) { - Matrix_MultVec3f(&D_80906D60, &this->unk_234[temp_v1]); - } - if (limbIndex == 11) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5749); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5752), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_ganon_DL_00BE90)); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5754); - } else if (limbIndex == 10) { - Matrix_MultVec3f(&D_80907164, &this->unk_1B8); - } -} - -void func_80905674(BossGanon2* this, GlobalContext* globalCtx) { - s32 pad; - - if (this->unk_380 > 0.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5772); - - Matrix_Push(); - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_19C * -8, 0, 32, 64, 1, this->unk_19C * -4, - this->unk_19C * -8, 32, 32)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s16)this->unk_37C); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 128); - Matrix_Translate(sZelda->actor.world.pos.x + 100.0f, sZelda->actor.world.pos.y + 35.0f + 7.0f, - sZelda->actor.world.pos.z - 100.0f, MTXMODE_NEW); - Matrix_RotateY(-M_PI / 4.0f, MTXMODE_APPLY); - Matrix_Scale(0.040000003f, 0.040000003f, this->unk_380, MTXMODE_APPLY); - Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5814), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00EC40)); - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5817); - } -} - -void BossGanon2_Draw(Actor* thisx, GlobalContext* globalCtx) { - void* shadowTexture = Graph_Alloc(globalCtx->state.gfxCtx, 4096); - BossGanon2* this = (BossGanon2*)thisx; - s16 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5840); - - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - - switch (this->unk_337) { - case 0: - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON, true); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_ganon_Tex_00A8E0)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_ganon_Tex_00A8E0)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, BossGanon2_PostLimbDraw2, this); - break; - case 1: - case 2: - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON2, true); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->unk_310])); - func_808FD080(0, &this->unk_444, &D_8090717C); - func_808FD080(1, &this->unk_444, &D_8090717C); - this->unk_218 = D_8090717C; - if (this->unk_342 & 1) { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0xFF, 0, 0, 0xFF, 0x384, 0x44B); - } - Matrix_Translate(0.0f, -4000.0f, 4000.0f, MTXMODE_APPLY); - Matrix_RotateX(this->unk_394, MTXMODE_APPLY); - Matrix_Translate(0.0f, 4000.0f, -4000.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5910), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossGanon2_OverrideLimbDraw, BossGanon2_PostLimbDraw, - this); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - BossGanon2_GenShadowTexture(shadowTexture, this, globalCtx); - BossGanon2_DrawShadowTexture(shadowTexture, this, globalCtx); - break; - } - - BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON2, true); - func_80904340(this, globalCtx); - func_80904108(this, globalCtx); - func_80904D88(this, globalCtx); - func_8090464C(this, globalCtx); - func_80905674(this, globalCtx); - func_80904FC8(this, globalCtx); - func_8090523C(this, globalCtx); - - if ((this->unk_312 != 0) || (D_80907080 != 0)) { - func_80903F38(this, globalCtx); - if (this->unk_312 == 0) { - s32 pad; - - D_80907080 -= 40; - if (D_80907080 <= 0) { - D_80907080 = 0; - } - } - - D_80910638++; - } else { - for (i = 0; i < 3; i++) { - D_809105D8[i] = this->unk_200; - D_80910608[i] = this->unk_20C; - } - - D_80910638 = 0; - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5983); - - func_809060E8(globalCtx); -} - -void func_80905DA8(BossGanon2* this, GlobalContext* globalCtx) { - s32 pad[5]; - Player* player = GET_PLAYER(globalCtx); - BossGanon2Effect* effect = globalCtx->specialEffects; - Vec3f sp78; - s16 i; - - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { - if (effect->type != 0) { - effect->position.x += effect->velocity.x; - effect->position.y += effect->velocity.y; - effect->position.z += effect->velocity.z; - effect->unk_01++; - effect->velocity.x += effect->accel.x; - effect->velocity.y += effect->accel.y; - effect->velocity.z += effect->accel.z; - if (effect->type == 1) { - if (effect->unk_2E == 0) { - effect->unk_38.z += 1.0f; - effect->unk_38.y = (2.0f * M_PI) / 5.0f; - } else { - effect->unk_38.z = M_PI / 2.0f; - effect->unk_38.y = 0.0f; - if (effect->position.y <= 1098.0f) { - effect->position.y = 1098.0f; - if (effect->velocity.y < -10.0f) { - sp78 = effect->position; - sp78.y = 1086.0f; - func_80078884(NA_SE_IT_SHIELD_REFLECT_SW); - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp78); - } - effect->velocity.y = 0.0f; - } - if ((SQ(player->actor.world.pos.x - effect->position.x) + - SQ(player->actor.world.pos.z - effect->position.z)) < SQ(25.0f)) { - effect->type = 0; - this->unk_39C = 10; - } - } - } else if (effect->type == 2) { - effect->unk_38.x += 0.1f; - effect->unk_38.y += 0.4f; - if ((sqrtf(SQ(-200.0f - effect->position.x) + SQ(-200.0f - effect->position.z)) < 1000.0f)) { - if (effect->position.y < 1186.0f) { - if (effect->unk_2E == 0) { - effect->unk_2E++; - effect->position.y = 1186.0f; - effect->velocity.x *= 0.75f; - effect->velocity.z *= 0.75f; - effect->velocity.y *= -0.2f; - } else { - effect->type = 0; - } - } - } else if ((effect->position.y < 0.0f)) { - effect->type = 0; - } - } - } - } -} - -void func_809060E8(GlobalContext* globalCtx) { - s16 alpha; - u8 usingObjectGEff = false; - BossGanon2Effect* effect; - s16 i; - BossGanon2Effect* effects; - - effects = effect = globalCtx->specialEffects; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6086); - - func_80093D18(globalCtx->state.gfxCtx); - - for (i = 0; i < 1; i++) { - if (effect->type == 1) { - Vec3f spA0; - f32 temp_f0; - f32 angle; - - func_80093D84(globalCtx->state.gfxCtx); - spA0.x = globalCtx->envCtx.dirLight1.params.dir.x; - spA0.y = globalCtx->envCtx.dirLight1.params.dir.y; - spA0.z = globalCtx->envCtx.dirLight1.params.dir.z; - func_8002EABC(&effect->position, &globalCtx->view.eye, &spA0, globalCtx->state.gfxCtx); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); - Matrix_RotateY(effect->unk_38.z, MTXMODE_APPLY); - Matrix_RotateX(effect->unk_38.y, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6116), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, 0 - (globalCtx->gameplayFrames & 0x7F), 32, 32)); - gSPDisplayList(POLY_OPA_DISP++, ovl_Boss_Ganon2_DL_0103A8); - if ((globalCtx->envCtx.unk_BD == 1) || (globalCtx->envCtx.unk_BD == 2)) { - alpha = (s16)(globalCtx->envCtx.unk_D8 * 150.0f) + 50; - angle = M_PI / 5.0f; - } else { - alpha = 100; - angle = M_PI / 2.0f; - } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); - temp_f0 = effect->position.y - 1098.0f; - Matrix_Translate(effect->position.x + temp_f0, 1086.0f, (effect->position.z - 1.0f) + temp_f0, MTXMODE_NEW); - Matrix_RotateY(angle, MTXMODE_APPLY); - Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6155), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00F188); - } - } - - effect = effects; - - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { - if (effect->type == 2) { - if (!usingObjectGEff) { - BossGanon2_SetObjectSegment(NULL, globalCtx, OBJECT_GEFF, true); - usingObjectGEff++; - } - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - Matrix_RotateY(effect->unk_38.z, MTXMODE_APPLY); - Matrix_RotateX(effect->unk_38.y, MTXMODE_APPLY); - Matrix_RotateZ(effect->unk_38.x, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6179), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gGanonRubbleDL); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6185); -} - -void func_80906538(BossGanon2* this, u8* shadowTexture, f32 arg2) { - s16 temp_t0; - s16 temp_v0; - s16 temp_a3; - s16 phi_v1; - s16 phi_a1; - s16 i; - f32 lerpx; - s16 j; - f32 lerpy; - f32 lerpz; - Vec3f sp70; - Vec3f sp64; - - for (i = 0; i < 15; i++) { - if ((arg2 == 0.0f) || ((j = D_809071CC[i]) >= 0)) { - if (arg2 > 0.0f) { - lerpx = this->unk_234[i].x + (this->unk_234[j].x - this->unk_234[i].x) * arg2; - lerpy = this->unk_234[i].y + (this->unk_234[j].y - this->unk_234[i].y) * arg2; - lerpz = this->unk_234[i].z + (this->unk_234[j].z - this->unk_234[i].z) * arg2; - - sp70.x = lerpx - this->actor.world.pos.x; - sp70.y = lerpy - this->actor.world.pos.y + 76.0f + 30.0f + 30.0f + 100.0f; - sp70.z = lerpz - this->actor.world.pos.z; - } else { - sp70.x = this->unk_234[i].x - this->actor.world.pos.x; - sp70.y = this->unk_234[i].y - this->actor.world.pos.y + 76.0f + 30.0f + 30.0f + 100.0f; - sp70.z = this->unk_234[i].z - this->actor.world.pos.z; - } - - Matrix_MultVec3f(&sp70, &sp64); - sp64.x *= 0.2f; - sp64.y *= 0.2f; - temp_a3 = sp64.x + 32.0f; - temp_t0 = (s16)sp64.y * 64; - - if (D_809071EC[i] == 2) { - for (j = 0, phi_a1 = -0x180; j < 12; j++, phi_a1 += 0x40) { - for (phi_v1 = -D_809071B4[j]; phi_v1 < D_809071B4[j]; phi_v1++) { - temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; - if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { - shadowTexture[temp_v0] = 0xFF; - } - } - } - } else if (D_809071EC[i] == 1) { - for (j = 0, phi_a1 = -0x100; j < 8; j++, phi_a1 += 0x40) { - for (phi_v1 = -D_809071A4[j]; phi_v1 < D_809071A4[j]; phi_v1++) { - temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; - if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { - shadowTexture[temp_v0] = 0xFF; - } - } - } - } else if (D_809071EC[i] == 0) { - for (j = 0, phi_a1 = -0xC0; j < 7; j++, phi_a1 += 0x40) { - for (phi_v1 = -D_80907194[j]; phi_v1 < D_80907194[j] - 1; phi_v1++) { - temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; - if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { - shadowTexture[temp_v0] = 0xFF; - } - } - } - } else { - for (j = 0, phi_a1 = -0x80; j < 6; j++, phi_a1 += 0x40) { - for (phi_v1 = -D_80907188[j]; phi_v1 < D_80907188[j] - 1; phi_v1++) { - temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; - if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { - shadowTexture[temp_v0] = 0xFF; - } - } - } - } - } - } -} - -void BossGanon2_GenShadowTexture(void* shadowTexture, BossGanon2* this, GlobalContext* globalCtx) { - s16 i; - u32* p = shadowTexture; - - for (i = 0; i < 1024; i++, p++) { - *p = 0; - } - - Matrix_RotateX(1.0f, MTXMODE_NEW); - - for (i = 0; i < 6; i++) { - func_80906538(this, shadowTexture, i / 5.0f); - } -} - -void BossGanon2_DrawShadowTexture(void* shadowTexture, BossGanon2* this, GlobalContext* globalCtx) { - s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s16 alpha; - - OPEN_DISPS(gfxCtx, "../z_boss_ganon2.c", 6430); - - func_80093D18(globalCtx->state.gfxCtx); - - if ((globalCtx->envCtx.unk_BD == 1) || (globalCtx->envCtx.unk_BD == 2)) { - alpha = (s16)(globalCtx->envCtx.unk_D8 * 180.0f) + 30; - } else { - alpha = 120; - } - - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z - 20.0f, MTXMODE_NEW); - Matrix_Scale(1.65f, 1.0f, 1.65f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6457), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, ovl_Boss_Ganon2_DL_00B3D0); - gDPLoadTextureBlock(POLY_OPA_DISP++, shadowTexture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); - gSPDisplayList(POLY_OPA_DISP++, ovl_Boss_Ganon2_DL_00B3F0); - - CLOSE_DISPS(gfxCtx, "../z_boss_ganon2.c", 6479); -} diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.cpp b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.cpp new file mode 100644 index 000000000..e89bc26c9 --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.cpp @@ -0,0 +1,3093 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GANON2_Z_BOSS_GANON2_C +#include "actor_common.h" +#include "z_boss_ganon2.h" +#include "overlays/actors/ovl_Demo_Gj/z_demo_gj.h" +#include "overlays/actors/ovl_En_Zl3/z_en_zl3.h" +#include "objects/object_ganon/object_ganon.h" +#include "objects/object_ganon2/object_ganon2.h" +#include "objects/object_ganon_anime3/object_ganon_anime3.h" +#include "objects/object_geff/object_geff.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/graph.h" +#include "def/sinf.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void BossGanon2_Init(Actor* thisx, GlobalContext* globalCtx); +void BossGanon2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx); +void BossGanon2_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_808FD5C4(BossGanon2* pthis, GlobalContext* globalCtx); +void func_808FD5F4(BossGanon2* pthis, GlobalContext* globalCtx); +void func_808FFDB0(BossGanon2* pthis, GlobalContext* globalCtx); +void func_808FFEBC(BossGanon2* pthis, GlobalContext* globalCtx); +void func_808FFFE0(BossGanon2* pthis, GlobalContext* globalCtx); +void func_80900104(BossGanon2* pthis, GlobalContext* globalCtx); +void func_8090026C(BossGanon2* pthis, GlobalContext* globalCtx); +void func_809002CC(BossGanon2* pthis, GlobalContext* globalCtx); +void func_80900344(BossGanon2* pthis, GlobalContext* globalCtx); +void func_80900580(BossGanon2* pthis, GlobalContext* globalCtx); +void func_80900650(BossGanon2* pthis, GlobalContext* globalCtx); +void func_80900890(BossGanon2* pthis, GlobalContext* globalCtx); +void func_8090120C(BossGanon2* pthis, GlobalContext* globalCtx); +void func_80905DA8(BossGanon2* pthis, GlobalContext* globalCtx); +void func_809060E8(GlobalContext* globalCtx); +void BossGanon2_GenShadowTexture(void* shadowTexture, BossGanon2* pthis, GlobalContext* globalCtx); +void BossGanon2_DrawShadowTexture(void* shadowTexture, BossGanon2* pthis, GlobalContext* globalCtx); + +ActorInit Boss_Ganon2_InitVars = { + ACTOR_BOSS_GANON2, + ACTORCAT_BOSS, + FLAGS, + OBJECT_GANON2, + sizeof(BossGanon2), + (ActorFunc)BossGanon2_Init, + (ActorFunc)BossGanon2_Destroy, + (ActorFunc)BossGanon2_Update, + (ActorFunc)BossGanon2_Draw, +}; + +#include "z_boss_ganon2_data.cpp" + +void BossGanon2_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { + sSeed1 = seedInit0; + sSeed2 = seedInit1; + sSeed3 = seedInit2; +} + +f32 BossGanon2_RandZeroOne(void) { + // Wichmann-Hill algorithm + f32 randFloat; + + sSeed1 = (sSeed1 * 171) % 30269; + sSeed2 = (sSeed2 * 172) % 30307; + sSeed3 = (sSeed3 * 170) % 30323; + + randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); + while (randFloat >= 1.0f) { + randFloat -= 1.0f; + } + return fabsf(randFloat); +} + +void func_808FD080(s32 idx, ColliderJntSph* collider, Vec3f* arg2) { + collider->elements[idx].dim.worldSphere.center.x = arg2->x; + collider->elements[idx].dim.worldSphere.center.y = arg2->y; + collider->elements[idx].dim.worldSphere.center.z = arg2->z; + + collider->elements[idx].dim.worldSphere.radius = + collider->elements[idx].dim.modelSphere.radius * collider->elements[idx].dim.scale; +} + +void BossGanon2_SetObjectSegment(BossGanon2* pthis, GlobalContext* globalCtx, s32 objectId, u8 setRSPSegment) { + s32 pad; + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, objectId); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[objectIdx].vromStart.get()); + + if (setRSPSegment) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 790); + + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[objectIdx].vromStart.get()); + gSPSegment(POLY_XLU_DISP++, 0x06, gObjectTable[objectIdx].vromStart.get()); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 799); + } +} + +void func_808FD210(GlobalContext* globalCtx, Vec3f* arg1) { + BossGanon2Effect* effect = (BossGanon2Effect*)globalCtx->specialEffects; + + effect->type = 1; + effect->position = *arg1; + effect->unk_2E = 0; + effect->unk_01 = 0; + effect->velocity.x = 25.0f; + effect->velocity.y = 15.0f; + effect->velocity.z = 0.0f; + effect->accel.x = 0.0f; + effect->accel.y = -1.0f; + effect->accel.z = 0.0f; +} + +void func_808FD27C(GlobalContext* globalCtx, Vec3f* position, Vec3f* velocity, f32 scale) { + BossGanon2Effect* effect = (BossGanon2Effect*)globalCtx->specialEffects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + if (effect->type == 0) { + effect->type = 2; + effect->position = *position; + effect->velocity = *velocity; + effect->accel.x = 0.0; + effect->accel.y = -1.0f; + effect->accel.z = 0.0; + effect->unk_38.z = Rand_ZeroFloat(2 * M_PI); + effect->unk_38.y = Rand_ZeroFloat(2 * M_PI); + effect->unk_38.x = Rand_ZeroFloat(2 * M_PI); + effect->scale = scale; + break; + } + } +} + +void BossGanon2_Init(Actor* thisx, GlobalContext* globalCtx) { + BossGanon2* pthis = (BossGanon2*)thisx; + s32 pad; + s16 i; + + globalCtx->specialEffects = sParticles; + + for (i = 0; i < ARRAY_COUNT(sParticles); i++) { + sParticles[i].type = 0; + } + + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.colChkInfo.health = 30; + Collider_InitJntSph(globalCtx, &pthis->unk_424); + Collider_SetJntSph(globalCtx, &pthis->unk_424, &pthis->actor, &sJntSphInit1, pthis->unk_464); + Collider_InitJntSph(globalCtx, &pthis->unk_444); + Collider_SetJntSph(globalCtx, &pthis->unk_444, &pthis->actor, &sJntSphInit2, pthis->unk_864); + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON, false); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDorfSkel, NULL, NULL, NULL, 0); + func_808FD5C4(pthis, globalCtx); + pthis->actor.naviEnemyId = 0x3E; + pthis->actor.gravity = 0.0f; +} + +void BossGanon2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BossGanon2* pthis = (BossGanon2*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyJntSph(globalCtx, &pthis->unk_424); + Collider_DestroyJntSph(globalCtx, &pthis->unk_444); +} + +void func_808FD4D4(BossGanon2* pthis, GlobalContext* globalCtx, s16 arg2, s16 arg3) { + if ((arg2 == 0) || (arg2 == 1)) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->unk_1D0, 25.0f, arg3, 8.0f, 0x1F4, 0xA, 1); + } + + if ((arg2 == 0) || (arg2 == 2)) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->unk_1DC, 25.0f, arg3, 8.0f, 0x1F4, 0xA, 1); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_WALK); + func_80033E88(&pthis->actor, globalCtx, 2, 0xA); +} + +void func_808FD5C4(BossGanon2* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = func_808FD5F4; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.world.pos.y = -3000.0f; +} + +void func_808FD5F4(BossGanon2* pthis, GlobalContext* globalCtx) { + s16 pad; + u8 sp8D; + Player* player; + s32 objectIdx; + s32 zero = 0; + s32 pad2; + + sp8D = false; + player = GET_PLAYER(globalCtx); + pthis->unk_398++; + + switch (pthis->unk_39C) { + case 0: + objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON_ANIME3); + if (Object_IsLoaded(&globalCtx->objectCtx, objectIdx)) { + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->unk_39E = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_39E, CAM_STAT_ACTIVE); + pthis->unk_39C = 1; + sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ZL3, 970.0f, + 1086.0f, -200.0f, 0, 0, 0, 1); + sZelda->unk_3C8 = 0; + sZelda->actor.world.pos.x = 970.0f; + sZelda->actor.world.pos.y = 1086.0f; + sZelda->actor.world.pos.z = -214.0f; + sZelda->actor.shape.rot.y = -0x7000; + pthis->unk_3BC.x = 0.0f; + pthis->unk_3BC.y = 1.0f; + pthis->unk_3BC.z = 0.0f; + pthis->unk_398 = 0; + pthis->unk_3A4.x = 0.0f; + pthis->unk_3A4.y = 1400.0f; + pthis->unk_3A4.z = 1600.0f; + player->actor.world.pos.x = 970.0f; + player->actor.world.pos.y = 1086.0f; + player->actor.world.pos.z = -186.0f; + player->actor.shape.rot.y = -0x5000; + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime3_Anim_002168, 0.0f); + globalCtx->envCtx.unk_D8 = 0.0f; + // fake, tricks the compiler into allocating more stack + if (zero) { + pthis->unk_3A4.x *= 2.0; + } + } else { + break; + } + case 1: + if (pthis->unk_398 < 70) { + globalCtx->envCtx.unk_D8 = 0.0f; + } + pthis->unk_339 = 3; + Math_ApproachF(&pthis->unk_3A4.x, 1500.0f, 0.1f, pthis->unk_410.x * 1500.0f); + Math_ApproachF(&pthis->unk_3A4.z, -160.0f, 0.1f, pthis->unk_410.x * 1760.0f); + Math_ApproachF(&pthis->unk_410.x, 0.0075f, 1.0f, 0.0001f); + pthis->unk_3B0.x = -200.0f; + pthis->unk_3B0.y = 1086.0f; + pthis->unk_3B0.z = -200.0f; + if (pthis->unk_398 == 150) { + Message_StartTextbox(globalCtx, 0x70D3, NULL); + } + if (pthis->unk_398 > 250 && Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { + pthis->unk_39C = 2; + pthis->unk_398 = 0; + pthis->unk_410.x = 0.0f; + globalCtx->envCtx.unk_D8 = 1.0f; + } else { + break; + } + case 2: + pthis->unk_339 = 4; + player->actor.world.pos.x = 970.0f; + player->actor.world.pos.y = 1086.0f; + player->actor.world.pos.z = -166.0f; + sZelda->actor.world.pos.x = 974.0f; + sZelda->actor.world.pos.y = 1086.0f; + sZelda->actor.world.pos.z = -186.0f; + player->actor.shape.rot.y = -0x5000; + sZelda->actor.shape.rot.y = -0x5000; + if (pthis->unk_398 == 60) { + Message_StartTextbox(globalCtx, 0x70D4, NULL); + } + if (pthis->unk_398 == 40) { + sZelda->unk_3C8 = 1; + func_8002DF54(globalCtx, &pthis->actor, 0x4E); + } + if (pthis->unk_398 == 85) { + sZelda->unk_3C8 = 2; + func_8002DF54(globalCtx, &pthis->actor, 0x4F); + } + pthis->unk_3A4.x = 930.0f; + pthis->unk_3A4.y = 1129.0f; + pthis->unk_3A4.z = -181.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.z = (player->actor.world.pos.z - 15.0f) + 5.0f; + if (pthis->unk_398 > 104) { + Math_ApproachF(&pthis->unk_3B0.y, player->actor.world.pos.y + 47.0f + 7.0f + 15.0f, 0.1f, + pthis->unk_410.x); + Math_ApproachF(&pthis->unk_410.x, 2.0f, 1.0f, 0.1f); + } else { + pthis->unk_3B0.y = player->actor.world.pos.y + 47.0f + 7.0f; + } + if ((pthis->unk_398 > 170) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->unk_39C = 3; + pthis->unk_398 = 0; + pthis->unk_410.x = 0.0f; + } + break; + case 3: + Math_ApproachF(&pthis->unk_3B0.y, player->actor.world.pos.y + 47.0f + 7.0f, 0.1f, 2.0f); + pthis->unk_339 = 4; + if (pthis->unk_398 == 10) { + func_80078914(&D_80906D6C, NA_SE_EV_STONE_BOUND); + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + } + if (pthis->unk_398 == 20) { + sZelda->unk_3C8 = 3; + func_8002DF54(globalCtx, &pthis->actor, 0x50); + } + if (pthis->unk_398 == 55) { + pthis->unk_39C = 4; + pthis->unk_398 = 0; + pthis->unk_410.x = 0.0f; + sZelda->unk_3C8 = 4; + func_8002DF54(globalCtx, &pthis->actor, 0x50); + } + break; + case 4: + pthis->unk_339 = 4; + Math_ApproachF(&pthis->unk_3A4.x, -360.0f, 0.1f, pthis->unk_410.x * 1290.0f); + Math_ApproachF(&pthis->unk_3A4.z, -20.0f, 0.1f, pthis->unk_410.x * 170.0f); + Math_ApproachF(&pthis->unk_410.x, 0.04f, 1.0f, 0.0005f); + if (pthis->unk_398 == 100) { + Camera* camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = pthis->unk_3A4; + camera->eyeNext = pthis->unk_3A4; + camera->at = pthis->unk_3B0; + func_800C08AC(globalCtx, pthis->unk_39E, 0); + pthis->unk_39E = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->unk_39C = 5; + pthis->unk_398 = 0; + } + break; + case 5: + pthis->unk_339 = 4; + if (pthis->actor.xzDistToPlayer < 500.0f) { + Message_CloseTextbox(globalCtx); + pthis->unk_39C = 10; + pthis->unk_398 = 0; + func_80064520(globalCtx, &globalCtx->csCtx); + pthis->unk_39E = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_39E, CAM_STAT_ACTIVE); + } else { + break; + } + case 10: + player->actor.world.pos.x = 490.0f; + player->actor.world.pos.y = 1086.0f; + player->actor.world.pos.z = -166.0f; + sZelda->actor.world.pos.x = 724.0f; + sZelda->actor.world.pos.y = 1086.0f; + sZelda->actor.world.pos.z = -186.0f; + player->actor.shape.rot.y = -0x4000; + sZelda->actor.shape.rot.y = -0x5000; + pthis->unk_3A4.x = 410.0f; + pthis->unk_3A4.y = 1096.0f; + pthis->unk_3A4.z = -110.0f; + pthis->unk_3B0.x = player->actor.world.pos.x + 10.0f; + pthis->unk_3B0.y = (player->actor.world.pos.y + 200.0f) - 160.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + if (pthis->unk_398 >= 20) { + func_80078884(NA_SE_EN_GOMA_LAST - SFX_FLAG); + Math_ApproachF(&pthis->unk_324, 255.0f, 1.0f, 10.0f); + pthis->unk_339 = 5; + if (pthis->unk_398 == 20) { + pthis->unk_33C = 0.0f; + globalCtx->envCtx.unk_D8 = 0.0f; + } + } else { + pthis->unk_339 = 4; + } + if (pthis->unk_398 == 30) { + sZelda->unk_3C8 = 5; + func_8002DF54(globalCtx, &pthis->actor, 0x51); + } + if (pthis->unk_398 == 50) { + pthis->unk_398 = 0; + pthis->unk_39C = 11; + } + break; + case 11: + pthis->unk_339 = 5; + func_80078884(NA_SE_EN_GOMA_LAST - SFX_FLAG); + player->actor.world.pos.x = 490.0f; + player->actor.world.pos.y = 1086.0f; + player->actor.world.pos.z = -166.0f; + sZelda->actor.world.pos.x = 724.0f; + sZelda->actor.world.pos.y = 1086.0f; + sZelda->actor.world.pos.z = -186.0f; + player->actor.shape.rot.y = -0x4000; + sZelda->actor.shape.rot.y = -0x5000; + pthis->unk_3A4.x = 450.0f; + pthis->unk_3A4.y = 1121.0f; + pthis->unk_3A4.z = -158.0f; + pthis->unk_3B0.x = (player->actor.world.pos.x - 20.0f) + 2.0f; + pthis->unk_3B0.y = ((player->actor.world.pos.y + 200.0f) - 151.0f) - 2.0f; + pthis->unk_3B0.z = player->actor.world.pos.z + 2.0f; + if (pthis->unk_398 == 10) { + func_80078914(&D_80906D6C, NA_SE_EV_STONE_BOUND); + } + if (pthis->unk_398 == 20) { + func_80078884(NA_SE_EV_STONE_BOUND); + } + if (pthis->unk_398 == 30) { + func_8002DF54(globalCtx, &pthis->actor, 0x52); + } + if (pthis->unk_398 == 50) { + pthis->unk_398 = 0; + pthis->unk_39C = 12; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_002168, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_002168); + pthis->actor.world.pos.x = pthis->actor.world.pos.z = -200.0f; + pthis->actor.world.pos.y = 1009.0f; + pthis->actor.shape.yOffset = 7000.0f; + pthis->actor.world.rot.y = 0x5000; + pthis->unk_3A4.x = -60.0f; + pthis->unk_3A4.y = 1106.0f; + pthis->unk_3A4.z = -200.0f; + pthis->unk_3B0.x = pthis->unk_3B0.z = -200.0f; + pthis->unk_3B0.y = pthis->actor.world.pos.y + 70.0f; + globalCtx->envCtx.unk_D8 = 0.0f; + globalCtx->envCtx.unk_BE = globalCtx->envCtx.unk_BD = 0; + pthis->unk_339 = 0; + } else { + break; + } + case 12: + case 13: + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_398 == 30) { + D_80906D78 = 1; + pthis->unk_314 = 1; + func_800A9F6C(0.0f, 0xC8, 0x14, 0x14); + } + if (pthis->unk_398 == 30) { + func_80078884(NA_SE_EV_GRAVE_EXPLOSION); + } + if (pthis->unk_398 >= 30) { + Math_ApproachF(&pthis->actor.world.pos.y, 1289.0f, 0.1f, 10.0f); + pthis->unk_3B0.y = pthis->actor.world.pos.y + 70.0f; + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime3_Anim_002E6C, 0.0f); + pthis->unk_39C = 14; + pthis->unk_398 = 0; + pthis->actor.world.pos.x = -200.0f; + pthis->actor.world.pos.y = pthis->actor.world.pos.y - 30.0f; + pthis->actor.world.pos.z = -200.0f; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_OPENING_GANON); + } else { + break; + } + case 14: + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.world.pos.y, 1289.0f, 0.05f, 1.0f); + player->actor.world.pos.x = 250.0f; + player->actor.world.pos.y = 1086.0f; + player->actor.world.pos.z = -266.0f; + player->actor.shape.rot.y = -0x4000; + sZelda->actor.world.pos.x = 724.0f; + sZelda->actor.world.pos.y = 1086.0f; + sZelda->actor.world.pos.z = -186.0f; + pthis->unk_3A4.x = pthis->actor.world.pos.x + -10.0f; + pthis->unk_3A4.y = pthis->actor.world.pos.y + 80.0f; + pthis->unk_3A4.z = pthis->actor.world.pos.z + 50.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = player->actor.world.pos.y; + pthis->unk_3B0.z = player->actor.world.pos.z - 200.0f; + if (pthis->unk_398 == 20) { + func_8002DF54(globalCtx, &pthis->actor, 0x1E); + } + if (pthis->unk_398 == 60) { + pthis->unk_3A4.x = (pthis->actor.world.pos.x + 200.0f) - 154.0f; + pthis->unk_3A4.y = pthis->actor.world.pos.y + 60.0f; + pthis->unk_3A4.z = pthis->actor.world.pos.z - 15.0f; + pthis->unk_39C = 15; + pthis->unk_398 = 0; + pthis->unk_3B0.y = pthis->actor.world.pos.y + 77.0f + 100.0f; + pthis->unk_314 = 2; + pthis->unk_3B0.z = pthis->actor.world.pos.z + 5.0f; + pthis->unk_3B0.x = pthis->actor.world.pos.x; + } + if ((globalCtx->gameplayFrames % 32) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BREATH); + } + break; + case 15: + if (((globalCtx->gameplayFrames % 32) == 0) && (pthis->unk_398 < 100)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BREATH); + } + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->unk_3B0.y, pthis->actor.world.pos.y + 77.0f, 0.05f, 5.0f); + if (pthis->unk_398 >= 50) { + if (pthis->unk_398 == 50) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_000BFC, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_000BFC); + pthis->unk_314 = 3; + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon_anime3_Anim_003F38, 0.0f); + pthis->unk_194 = 1000.0f; + } + } + if (pthis->unk_398 > 70) { + Math_ApproachF(&pthis->unk_1B4, 255.0f, 1.0f, 10.0f); + } + if (pthis->unk_398 == 140) { + pthis->unk_39C = 16; + pthis->unk_398 = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_003754, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_003754); + pthis->unk_339 = 55; + globalCtx->envCtx.unk_D8 = 1.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_CASBREAK); + } else { + break; + } + case 16: + if (pthis->unk_398 < 25) { + pthis->unk_339 = 55; + } else { + pthis->unk_339 = 6; + if (pthis->unk_194 > 100.0f) { + Math_ApproachF(&pthis->unk_30C, 15.0f, 1.0f, 2.0f); + } else { + Math_ApproachF(&pthis->unk_30C, 7.0f, 1.0f, 0.2f); + } + } + pthis->unk_1B4 = 0.0f; + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_0028A8, 0.0f); + pthis->unk_194 = 1000.0f; + } + Math_ApproachF(&pthis->unk_3A4.x, (pthis->actor.world.pos.x + 200.0f) - 90.0f, 0.1f, 6.3999996f); + Math_ApproachF(&pthis->unk_3A4.y, ((pthis->actor.world.pos.y + 60.0f) - 60.0f) - 70.0f, 0.1f, 13.0f); + Math_ApproachF(&pthis->unk_3B0.y, pthis->actor.world.pos.y + 40.0f, 0.1f, 3.6999998f); + if (pthis->unk_398 == 30) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BIGMASIC); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_THROW_BIG); + } + if (pthis->unk_398 <= 50) { + sp8D = true; + } + if (pthis->unk_398 >= 60) { + Camera* camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = pthis->unk_3A4; + camera->eyeNext = pthis->unk_3A4; + camera->at = pthis->unk_3B0; + pthis->unk_39C = 17; + pthis->unk_398 = 0; + pthis->unk_337 = 2; + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON2, false); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ganon2_Skel_025970, NULL, NULL, NULL, 0); + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON_ANIME3, false); + func_8002DF54(globalCtx, &pthis->actor, 0x54); + pthis->unk_314 = 3; + } + // fake, tricks the compiler into using stack the way we need it to + if (zero) { + Math_ApproachF(&pthis->unk_3B0.y, 0.0f, 0.0f, 0.0f); + } + break; + case 17: + pthis->unk_339 = 6; + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_3A4.x = player->actor.world.pos.x - 40.0f; + pthis->unk_3A4.y = player->actor.world.pos.y + 40.0f; + pthis->unk_3A4.z = player->actor.world.pos.z + 20.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = (player->actor.world.pos.y + 10.0f + 60.0f) - 30.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + if (pthis->unk_398 == 25) { + pthis->unk_39C = 18; + pthis->unk_398 = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_010380, 0.0f); + pthis->skelAnime.playSpeed = 0.0f; + pthis->unk_3A4.x = ((pthis->actor.world.pos.x + 500.0f) - 350.0f) - 50.0f; + pthis->unk_3A4.y = pthis->actor.world.pos.y; + pthis->unk_3A4.z = pthis->actor.world.pos.z; + pthis->unk_3B0.x = pthis->actor.world.pos.x + 50.0f; + pthis->unk_3B0.y = pthis->actor.world.pos.y + 60.0f; + pthis->unk_3B0.z = pthis->actor.world.pos.z; + pthis->actor.world.rot.y = 0x4000; + } + break; + case 18: + pthis->unk_339 = 6; + if (pthis->unk_398 == 30) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANON_BOSS); + } + Math_ApproachF(&pthis->unk_30C, 7.0f, 1.0f, 0.1f); + Math_ApproachF(&pthis->unk_3A4.x, (pthis->actor.world.pos.x + 500.0f) - 350.0f, 0.1f, 1.0f); + Math_ApproachF(&pthis->unk_3B0.x, pthis->actor.world.pos.x, 0.1f, 1.0f); + Math_ApproachF(&pthis->unk_228, 1.0f, 0.1f, 0.02f); + if (pthis->unk_398 == 65) { + pthis->unk_39C = 19; + pthis->unk_398 = 0; + } + break; + case 19: + pthis->unk_394 += 0.5f; + pthis->unk_339 = 6; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.velocity.y -= 1.0f; + if (pthis->unk_398 == 10) { + pthis->unk_39C = 20; + pthis->unk_398 = 0; + pthis->actor.world.pos.x += 250; + pthis->actor.world.pos.y = 1886.0f; + pthis->unk_394 = 0.0f; + func_8002DF54(globalCtx, &pthis->actor, 0x53); + pthis->unk_30C = 5.0f; + pthis->unk_228 = 1.0f; + } + break; + case 20: + pthis->unk_339 = 6; + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.velocity.y -= 1.0f; + player->actor.world.pos.x = 250.0f; + player->actor.world.pos.y = 1086.0f; + player->actor.world.pos.z = -266.0f; + player->actor.shape.rot.y = -0x4000; + pthis->unk_3A4.x = (player->actor.world.pos.x - 40.0f) - 200.0f; + pthis->unk_3A4.y = (player->actor.world.pos.y + 40.0f) - 30.0f; + pthis->unk_3A4.z = (player->actor.world.pos.z - 20.0f) + 100.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) + 30.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + pthis->unk_3BC.x = 0.8f; + if (pthis->actor.world.pos.y <= 1099.0f) { + pthis->actor.world.pos.y = 1099.0f; + pthis->unk_39C = 21; + pthis->unk_398 = 0; + pthis->unk_420 = 10.0f; + pthis->actor.velocity.y = 0.0f; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_010380, 0.0f); + func_808FD4D4(pthis, globalCtx, 0, 3); + func_800A9F6C(0.0f, 0xC8, 0x14, 0x14); + } + break; + case 21: + pthis->unk_339 = 6; + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_41C = Math_CosS(globalCtx->gameplayFrames * 0x8000) * pthis->unk_420; + Math_ApproachZeroF(&pthis->unk_420, 1.0f, 0.75f); + if (pthis->unk_398 == 30) { + pthis->unk_39C = 22; + pthis->unk_30C = 10.0f; + } else { + break; + } + case 22: + if (pthis->unk_398 < 60) { + pthis->unk_339 = 7; + } + pthis->unk_3BC.x = 0.0f; + pthis->actor.world.pos.y = 1099.0f; + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->unk_30C, 1.0f, 0.1f); + if (pthis->unk_398 > 50) { + Math_ApproachF(&pthis->unk_224, 1.0f, 1.0f, 0.025f); + } + if (pthis->unk_398 == 60) { + pthis->unk_336 = 2; + } + if (pthis->unk_398 == 80) { + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON2, false); + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(object_ganon2_Tex_021A90), 160, 180, 128, 40); + } + pthis->unk_3A4.x = ((pthis->actor.world.pos.x + 500.0f) - 350.0f) + 100.0f; + pthis->unk_3A4.y = pthis->actor.world.pos.y; + pthis->unk_3A4.z = pthis->actor.world.pos.z; + pthis->unk_3B0.x = pthis->actor.world.pos.x; + pthis->unk_3B0.z = pthis->actor.world.pos.z; + pthis->unk_3B0.y = (pthis->unk_1B8.y + 60.0f) - 40.0f; + if (pthis->unk_398 > 166 && pthis->unk_398 < 173) { + pthis->unk_312 = 2; + } + if (pthis->unk_398 > 186 && pthis->unk_398 < 196) { + pthis->unk_312 = 1; + } + if (pthis->unk_398 > 202 && pthis->unk_398 < 210) { + pthis->unk_312 = 2; + } + if ((pthis->unk_398 == 166) || (pthis->unk_398 == 185) || (pthis->unk_398 == 200)) { + func_80078884(NA_SE_EN_MGANON_SWORD); + func_80078884(NA_SE_EN_MGANON_ROAR); + } + if (pthis->unk_398 == 215) { + pthis->unk_39C = 23; + pthis->unk_224 = 0.0f; + func_8002DF54(globalCtx, &pthis->actor, 0x55); + } + break; + case 23: + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_398 > 222 && pthis->unk_398 < 232) { + pthis->unk_312 = 2; + } + if (pthis->unk_398 == 222) { + func_80078884(NA_SE_EN_MGANON_SWORD); + func_80078884(NA_SE_EN_MGANON_ROAR); + } + pthis->unk_3A4.x = (player->actor.world.pos.x - 40.0f) + 6.0f; + pthis->unk_3A4.y = player->actor.world.pos.y + 40.0f; + pthis->unk_3A4.z = (player->actor.world.pos.z + 20.0f) - 7.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) - 2.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + if (pthis->unk_398 == 228) { + func_80078884(NA_SE_IT_SHIELD_REFLECT_SW); + func_8002DF54(globalCtx, &pthis->actor, 0x56); + func_800A9F6C(0.0f, 0xFF, 0xA, 0x32); + } + if (pthis->unk_398 >= 229) { + globalCtx->envCtx.fillScreen = true; + globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = + globalCtx->envCtx.screenFillColor[2] = 255; + globalCtx->envCtx.screenFillColor[3] = 100; + if (pthis->unk_398 == 234) { + Vec3f sp68; + + globalCtx->envCtx.fillScreen = false; + pthis->unk_39C = 24; + pthis->unk_398 = 0; + sp68 = player->actor.world.pos; + sp68.y += 60.0f; + func_808FD210(globalCtx, &sp68); + globalCtx->envCtx.unk_D8 = 0.0f; + globalCtx->envCtx.unk_BE = 0; + pthis->unk_339 = 0; + } + } + break; + case 24: + SkelAnime_Update(&pthis->skelAnime); + if (1) { + BossGanon2Effect* effect = (BossGanon2Effect*)globalCtx->specialEffects; + + pthis->unk_3B0 = effect->position; + pthis->unk_3A4.x = effect->position.x + 70.0f; + pthis->unk_3A4.y = effect->position.y - 30.0f; + pthis->unk_3A4.z = effect->position.z + 70.0f; + } + if ((pthis->unk_398 & 3) == 0) { + func_80078884(NA_SE_IT_SWORD_SWING); + } + if (pthis->unk_398 == 25) { + func_8002DF54(globalCtx, &pthis->actor, 0x57); + pthis->unk_39C = 25; + pthis->unk_398 = 0; + } + break; + case 25: + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_3A4.x = (player->actor.world.pos.x - 40.0f) + 80.0f; + pthis->unk_3A4.y = player->actor.world.pos.y + 40.0f + 10.0f; + pthis->unk_3A4.z = player->actor.world.pos.z + 20.0f + 10.0f; + pthis->unk_3B0.x = player->actor.world.pos.x - 20.0f; + pthis->unk_3B0.y = ((player->actor.world.pos.y + 10.0f + 60.0f) - 20.0f) - 3.0f; + pthis->unk_3B0.z = (player->actor.world.pos.z - 40.0f) - 10.0f; + if (pthis->unk_398 == 10) { + BossGanon2Effect* effect = (BossGanon2Effect*)globalCtx->specialEffects; + + effect->unk_2E = 1; + effect->position.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; + effect->position.y = sZelda->actor.world.pos.y + 350.0f; + effect->position.z = sZelda->actor.world.pos.z - 25.0f; + effect->velocity.x = 0.0f; + effect->velocity.z = 0.0f; + effect->velocity.y = -30.0f; + pthis->unk_39C = 26; + pthis->unk_398 = 0; + } else { + break; + } + case 26: + pthis->unk_3A4.x = sZelda->actor.world.pos.x + 100.0f + 30.0f; + pthis->unk_3A4.y = sZelda->actor.world.pos.y + 10.0f; + pthis->unk_3A4.z = sZelda->actor.world.pos.z + 5.0f; + pthis->unk_3B0.x = sZelda->actor.world.pos.x; + pthis->unk_3B0.y = sZelda->actor.world.pos.y + 30.0f; + pthis->unk_3B0.z = sZelda->actor.world.pos.z - 20.0f; + pthis->unk_3BC.z = -0.5f; + if (pthis->unk_398 == 13) { + sZelda->unk_3C8 = 6; + } + if (pthis->unk_398 == 50) { + pthis->unk_39C = 27; + pthis->unk_398 = 0; + } + break; + case 27: + pthis->unk_3BC.z = 0.0f; + if (pthis->unk_398 == 4) { + func_8002DF54(globalCtx, &pthis->actor, 0x58); + } + pthis->unk_3A4.x = player->actor.world.pos.x - 20.0f; + pthis->unk_3A4.y = player->actor.world.pos.y + 50.0f; + pthis->unk_3A4.z = player->actor.world.pos.z; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = player->actor.world.pos.y + 50.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + if (pthis->unk_398 == 26) { + D_8090EB30 = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + while (D_8090EB30 != NULL) { + if (D_8090EB30->id == ACTOR_EN_ELF) { + pthis->unk_3A4.x = D_8090EB30->world.pos.x - 30.0f; + pthis->unk_3A4.y = D_8090EB30->world.pos.y; + pthis->unk_3A4.z = D_8090EB30->world.pos.z; + pthis->unk_3B0.x = D_8090EB30->world.pos.x; + pthis->unk_3B0.y = D_8090EB30->world.pos.y; + pthis->unk_3B0.z = D_8090EB30->world.pos.z; + break; + } + D_8090EB30 = D_8090EB30->next; + } + pthis->unk_39C = 28; + pthis->unk_398 = 0; + } + break; + case 28: + if (pthis->unk_398 == 5) { + Message_StartTextbox(globalCtx, 0x70D6, NULL); + } + if (D_8090EB30 != NULL) { + pthis->unk_3A4.x = D_8090EB30->world.pos.x - 20.0f; + pthis->unk_3A4.y = D_8090EB30->world.pos.y; + pthis->unk_3A4.z = D_8090EB30->world.pos.z; + Math_ApproachF(&pthis->unk_3B0.x, D_8090EB30->world.pos.x, 0.2f, 50.0f); + Math_ApproachF(&pthis->unk_3B0.y, D_8090EB30->world.pos.y, 0.2f, 50.0f); + Math_ApproachF(&pthis->unk_3B0.z, D_8090EB30->world.pos.z, 0.2f, 50.0f); + if ((pthis->unk_398 > 40) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->unk_39C = 29; + pthis->unk_398 = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon_anime3_Anim_0147E0, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon_anime3_Anim_0147E0); + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.world.pos.y = 1086.0f; + pthis->actor.gravity = -1.0f; + pthis->unk_335 = 1; + pthis->unk_224 = 1.0f; + } + } + break; + case 29: + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_3A4.x = (((pthis->actor.world.pos.x + 500.0f) - 350.0f) + 100.0f) - 60.0f; + pthis->unk_3B0.x = pthis->actor.world.pos.x; + pthis->unk_3B0.z = pthis->actor.world.pos.z; + pthis->unk_3A4.y = pthis->actor.world.pos.y; + pthis->unk_3A4.z = pthis->actor.world.pos.z + 10.0f; + pthis->unk_3B0.y = (pthis->unk_1B8.y + 60.0f) - 40.0f; + player->actor.shape.rot.y = -0x4000; + player->actor.world.pos.x = 140.0f; + player->actor.world.pos.z = -196.0f; + if (pthis->unk_398 == 50) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_ROAR); + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Camera* camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = pthis->unk_3A4; + camera->eyeNext = pthis->unk_3A4; + camera->at = pthis->unk_3B0; + func_800C08AC(globalCtx, pthis->unk_39E, 0); + pthis->unk_39E = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->unk_39C = 0; + pthis->unk_337 = 1; + func_808FFDB0(pthis, globalCtx); + pthis->unk_1A2[1] = 50; + pthis->actor.flags |= ACTOR_FLAG_0; + sZelda->unk_3C8 = 7; + } + break; + } + + if ((pthis->unk_30C > 4.0f) && !sp8D) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_BODY_SPARK - SFX_FLAG); + } + + if (pthis->unk_39E != 0) { + // fake, tricks the compiler into putting some pointers on the stack + if (zero) { + osSyncPrintf(NULL, 0, 0); + } + pthis->unk_3B0.y += pthis->unk_41C; + Gameplay_CameraSetAtEyeUp(globalCtx, pthis->unk_39E, &pthis->unk_3B0, &pthis->unk_3A4, &pthis->unk_3BC); + } +} + +void func_808FF898(BossGanon2* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_312 != 0) && (pthis->unk_39E == 0)) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + while (actor != NULL) { + if (actor->id == ACTOR_DEMO_GJ) { + DemoGj* gj = (DemoGj*)actor; + + if (((actor->params & 0xFF) == 0x10) || ((actor->params & 0xFF) == 0x11) || + ((actor->params & 0xFF) == 0x16)) { + if (SQ(pthis->unk_218.x - gj->dyna.actor.world.pos.x) + + SQ(pthis->unk_218.z - gj->dyna.actor.world.pos.z) < + SQ(100.0f)) { + s32 pad; + Vec3f sp28; + + Matrix_RotateY(((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI) + 0.5f, MTXMODE_NEW); + sp28.x = 0.0f; + sp28.y = 0.0f; + sp28.z = 1.0f; + Matrix_MultVec3f(&sp28, &gj->unk_26C); + gj->killFlag = true; + func_800A9F6C(0.0f, 0x96, 0x14, 0x32); + pthis->unk_392 = 6; + return; + } + } + } + + actor = actor->next; + } + + if (pthis->unk_392 == 4) { + func_80078884(NA_SE_EV_GRAVE_EXPLOSION); + } + + if (pthis->unk_392 == 3) { + func_80078884(NA_SE_EN_MGANON_SWDIMP); + } + } +} + +s32 func_808FFA24(BossGanon2* pthis, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + + while (actor != NULL) { + if (actor->id == ACTOR_DEMO_GJ) { + DemoGj* gj = (DemoGj*)actor; + + if (((actor->params & 0xFF) == 0x10) || ((actor->params & 0xFF) == 0x11) || + ((actor->params & 0xFF) == 0x16)) { + if (SQ(pthis->actor.world.pos.x - gj->dyna.actor.world.pos.x) + + SQ(pthis->actor.world.pos.z - gj->dyna.actor.world.pos.z) < + SQ(200.0f)) { + return true; + } + } + } + + actor = actor->next; + } + + return false; +} + +void func_808FFAC8(BossGanon2* pthis, GlobalContext* globalCtx, u8 arg2) { + s16 temp_v1; + s16 phi_a1; + + if (pthis->unk_313 || (arg2 != 0)) { + phi_a1 = pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer; + + if (phi_a1 > 0x3000) { + phi_a1 = 0x3000; + } else if (phi_a1 < -0x3000) { + phi_a1 = -0x3000; + } + } else if (pthis->unk_19C & 0x20) { + phi_a1 = 0x3000; + } else { + phi_a1 = -0x3000; + } + + Math_ApproachS(&pthis->unk_31A, phi_a1, 5, 0x7D0); + + temp_v1 = Math_Atan2S(pthis->actor.xzDistToPlayer, 150.0f) - 0xBB8; + temp_v1 = CLAMP_MAX(temp_v1, 0x1B58); + temp_v1 = CLAMP_MIN(temp_v1, -0x1B58); + + Math_ApproachS(&pthis->unk_31C, temp_v1, 5, 0x7D0); +} + +void func_808FFBBC(BossGanon2* pthis, GlobalContext* globalCtx, u8 arg2) { + if (arg2 != 0 || pthis->unk_313) { + f32 phi_f0; + f32 phi_f2; + + Math_ApproachS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 5, pthis->unk_320); + + if (pthis->unk_334 != 0) { + phi_f0 = 5000.0f; + phi_f2 = 200.0f; + } else { + phi_f0 = 3000.0f; + phi_f2 = 30.0f; + } + + Math_ApproachF(&pthis->unk_320, phi_f0, 1.0f, phi_f2); + } else { + pthis->unk_320 = 0.0f; + } +} + +void func_808FFC84(BossGanon2* pthis) { + if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) < 0x2800) { + pthis->unk_313 = true; + pthis->actor.focus.pos = pthis->unk_1B8; + } else { + pthis->unk_313 = false; + pthis->actor.focus.pos = pthis->unk_1C4; + } +} + +void func_808FFCFC(BossGanon2* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer < 150.0f && + ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) < 0x2800) { + pthis->unk_311 = false; + func_80900580(pthis, globalCtx); + Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); + } else if ((pthis->actor.bgCheckFlags & 8) && func_808FFA24(pthis, globalCtx)) { + pthis->unk_311 = false; + func_80900580(pthis, globalCtx); + Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); + } +} + +void func_808FFDB0(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 sp28; + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GANON2); + + if (Object_IsLoaded(&globalCtx->objectCtx, objectIdx)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[objectIdx].vromStart.get()); + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_00FFE4, -10.0f); + pthis->actionFunc = func_808FFEBC; + + if (pthis->unk_334 != 0) { + pthis->unk_1A2[0] = Rand_ZeroFloat(30.0f); + } else { + pthis->unk_1A2[0] = 40; + } + + pthis->unk_336 = 1; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->unk_228 = 1.0f; + pthis->unk_224 = 1.0f; + } else { + pthis->actionFunc = func_808FFDB0; + } +} + +void func_808FFEBC(BossGanon2* pthis, GlobalContext* globalCtx) { + if (pthis->unk_390 == 0) { + pthis->unk_390 = (s16)Rand_ZeroFloat(50.0f) + 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_UNARI); + } + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 1.0f); + + if (pthis->unk_1A2[0] == 0) { + func_809002CC(pthis, globalCtx); + } else if (pthis->unk_1A2[1] == 0) { + func_808FFCFC(pthis, globalCtx); + } + + func_808FFAC8(pthis, globalCtx, 0); + func_808FFBBC(pthis, globalCtx, 0); +} + +void func_808FFF90(BossGanon2* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_00FFE4, -10.0f); + pthis->actionFunc = func_808FFFE0; + pthis->unk_1A2[0] = 40; +} + +void func_808FFFE0(BossGanon2* pthis, GlobalContext* globalCtx) { + s16 target; + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 1.0f); + + if (pthis->unk_1A2[0] == 0) { + func_809002CC(pthis, globalCtx); + } + + if (pthis->unk_1A2[0] < 30 && pthis->unk_1A2[0] >= 10) { + target = Math_SinS(pthis->unk_1A2[0] * 0x3000) * (f32)0x2000; + } else { + target = 0; + } + + Math_ApproachS(&pthis->unk_31A, target, 2, 0x4000); +} + +void func_809000A0(BossGanon2* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_026510, -2.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_026510); + pthis->unk_1AC = 0; + pthis->actionFunc = func_80900104; +} + +void func_80900104(BossGanon2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 1.0f); + + switch (pthis->unk_1AC) { + case 0: + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + pthis->unk_1AC = 1; + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_026AF4, 0.0f); + pthis->unk_1A2[0] = 80; + } + break; + case 1: + if (pthis->unk_1A2[0] == 0) { + pthis->unk_1AC = 2; + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_027824, -5.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_027824); + } + break; + case 2: + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + func_809002CC(pthis, globalCtx); + } + break; + } +} + +void func_80900210(BossGanon2* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_00DFF0, -3.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_00DFF0); + pthis->actionFunc = func_8090026C; +} + +void func_8090026C(BossGanon2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + func_809002CC(pthis, globalCtx); + } +} + +void func_809002CC(BossGanon2* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_00E8EC, -10.0f); + pthis->actionFunc = func_80900344; + pthis->unk_338 = 0; + pthis->unk_1A2[0] = 100; + pthis->unk_390 = (s16)Rand_ZeroFloat(50.0f) + 50; +} + +void func_80900344(BossGanon2* pthis, GlobalContext* globalCtx) { + f32 phi_f0; + + if (pthis->unk_390 == 0) { + pthis->unk_390 = (s16)Rand_ZeroFloat(50.0f) + 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_UNARI); + } + + Math_ApproachF(&pthis->unk_324, 255.0f, 1.0f, 10.0f); + + if (pthis->unk_338 != 0) { + if (Animation_OnFrame(&pthis->skelAnime, 13.0f)) { + func_808FD4D4(pthis, globalCtx, 1, 3); + } else if (Animation_OnFrame(&pthis->skelAnime, 28.0f)) { + func_808FD4D4(pthis, globalCtx, 2, 3); + } + if (pthis->actor.xzDistToPlayer < 200.0f) { + pthis->unk_338 = 0; + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_00E8EC, -10.0f); + } else { + pthis->skelAnime.playSpeed = ((pthis->actor.xzDistToPlayer - 300.0f) * 0.005f) + 1.0f; + if (pthis->skelAnime.playSpeed > 2.0f) { + pthis->skelAnime.playSpeed = 2.0f; + } + if (pthis->unk_334 != 0) { + pthis->skelAnime.playSpeed *= 1.5f; + } + } + phi_f0 = pthis->skelAnime.playSpeed * 3.0f; + } else { + phi_f0 = 2.0f; + if (pthis->actor.xzDistToPlayer >= 200.0f) { + pthis->unk_338 = 1; + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_0353C0, -10.0f); + } + } + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.speedXZ, phi_f0, 0.5f, 1.0f); + + if (pthis->unk_1A2[0] == 0) { + func_808FFDB0(pthis, globalCtx); + } else { + func_808FFCFC(pthis, globalCtx); + } + + func_808FFAC8(pthis, globalCtx, 1); + func_808FFBBC(pthis, globalCtx, 1); +} + +void func_80900580(BossGanon2* pthis, GlobalContext* globalCtx) { + if (pthis->unk_311 == 0) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_00ADD0, -5.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_00ADD0); + pthis->unk_198 = (pthis->unk_194 - 15.0f) - 5.0f; + } else { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_00CAF8, -5.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_00CAF8); + pthis->unk_198 = (pthis->unk_194 - 15.0f) - 5.0f; + } + + pthis->actionFunc = func_80900650; +} + +void func_80900650(BossGanon2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_198)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_SWORD); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_ROAR); + } + + if (pthis->unk_311 == 0) { + if (((pthis->unk_198 - 4.0f) < pthis->skelAnime.curFrame) && + (pthis->skelAnime.curFrame < (pthis->unk_198 + 6.0f))) { + pthis->unk_312 = 1; + } + } else if ((((pthis->unk_198 - 4.0f) + 4.0f) < pthis->skelAnime.curFrame) && + (pthis->skelAnime.curFrame < (pthis->unk_198 + 6.0f))) { + pthis->unk_312 = 2; + } + + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 1.0f); + + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + pthis->unk_311 = 1 - pthis->unk_311; + + if ((pthis->unk_311 == 1) && (pthis->actor.xzDistToPlayer < 250.0f) && pthis->unk_313) { + func_80900580(pthis, globalCtx); + } else { + func_808FFDB0(pthis, globalCtx); + } + } + + func_808FFAC8(pthis, globalCtx, 0); + + if ((pthis->unk_334 == 0) && (pthis->unk_311 == 0)) { + pthis->unk_320 = 0.0f; + } else { + func_808FFBBC(pthis, globalCtx, 0); + } +} + +void func_80900818(BossGanon2* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_02A848, -5.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_02A848); + pthis->actionFunc = func_80900890; + pthis->unk_1AC = 0; + pthis->unk_39C = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DEAD1); + pthis->unk_336 = 0; +} + +void func_80900890(BossGanon2* pthis, GlobalContext* globalCtx) { + Vec3f sp5C; + Vec3f sp50; + Camera* sp4C; + Player* player; + Camera* temp_v0; + Camera* temp_v0_2; + s32 pad; + f32 temp_f12; + f32 temp_f2; + + sp4C = Gameplay_GetCamera(globalCtx, MAIN_CAM); + player = GET_PLAYER(globalCtx); + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_398++; + pthis->unk_339 = 20; + + switch (pthis->unk_39C) { + case 0: + func_80064520(globalCtx, &globalCtx->csCtx); + pthis->unk_39E = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_39E, CAM_STAT_ACTIVE); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->unk_39C = 1; + pthis->unk_3A4 = sp4C->eye; + pthis->unk_3B0 = sp4C->at; + pthis->unk_1A2[0] = 300; + pthis->unk_1A2[1] = 100; + globalCtx->envCtx.unk_D8 = 0.0f; + case 1: + if (pthis->unk_1A2[1] == 50) { + func_80078884(NA_SE_EN_MGANON_WALK); + } + Matrix_RotateY(((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI) + 0.3f, MTXMODE_NEW); + sp5C.x = 0.0f; + sp5C.y = 0.0f; + sp5C.z = 250.0f; + Matrix_MultVec3f(&sp5C, &sp50); + Math_ApproachF(&pthis->unk_3A4.x, pthis->actor.world.pos.x + sp50.x, 0.2f, 100.0f); + Math_ApproachF(&pthis->unk_3A4.y, 1136.0f, 0.2f, 100.0f); + Math_ApproachF(&pthis->unk_3A4.z, pthis->actor.world.pos.z + sp50.z, 0.2f, 100.0f); + Math_ApproachF(&pthis->unk_3B0.x, pthis->unk_1B8.x, 0.2f, 100.0f); + Math_ApproachF(&pthis->unk_3B0.y, pthis->unk_1B8.y, 0.2f, 100.0f); + Math_ApproachF(&pthis->unk_3B0.z, pthis->unk_1B8.z, 0.2f, 100.0f); + if (pthis->unk_1A2[1] == 0) { + pthis->unk_39C = 2; + pthis->unk_1A2[1] = 90; + } + break; + case 2: + pthis->unk_1A2[0] = 300; + pthis->unk_3A4.x = sZelda->actor.world.pos.x - 100.0f; + pthis->unk_3A4.y = sZelda->actor.world.pos.y + 30.0f; + pthis->unk_3A4.z = (sZelda->actor.world.pos.z + 30.0f) - 60.0f; + pthis->unk_3B0.x = sZelda->actor.world.pos.x; + pthis->unk_3B0.y = sZelda->actor.world.pos.y + 30.0f; + pthis->unk_3B0.z = sZelda->actor.world.pos.z - 10.0f; + Math_ApproachZeroF(&pthis->unk_324, 1.0f, 5.0f); + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 1.0f / 51); + if (pthis->unk_1A2[1] == 80) { + Message_StartTextbox(globalCtx, 0x70D7, NULL); + } + if ((pthis->unk_1A2[1] < 30) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + temp_v0 = Gameplay_GetCamera(globalCtx, MAIN_CAM); + temp_v0->eye = pthis->unk_3A4; + temp_v0->eyeNext = pthis->unk_3A4; + temp_v0->at = pthis->unk_3B0; + func_800C08AC(globalCtx, pthis->unk_39E, 0); + pthis->unk_39E = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->unk_39C = 3; + } + break; + case 10: + func_80064520(globalCtx, &globalCtx->csCtx); + pthis->unk_39E = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_39E, CAM_STAT_ACTIVE); + pthis->unk_39C = 11; + pthis->unk_334 = 1; + func_8002DF54(globalCtx, &pthis->actor, 0x60); + pthis->unk_398 = 0; + case 11: + player->actor.world.pos.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; + player->actor.world.pos.z = sZelda->actor.world.pos.z - 25.0f; + player->actor.shape.rot.y = -0x8000; + pthis->unk_3A4.x = (player->actor.world.pos.x + 100.0f) - 80.0f; + pthis->unk_3A4.y = (player->actor.world.pos.y + 60.0f) - 40.0f; + pthis->unk_3A4.z = player->actor.world.pos.z - 110.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = (player->actor.world.pos.y + 60.0f) - 25.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + if (pthis->unk_398 == 80) { + temp_v0_2 = Gameplay_GetCamera(globalCtx, MAIN_CAM); + temp_v0_2->eye = pthis->unk_3A4; + temp_v0_2->eyeNext = pthis->unk_3A4; + temp_v0_2->at = pthis->unk_3B0; + pthis->unk_39C = 3; + func_800C08AC(globalCtx, pthis->unk_39E, 0); + pthis->unk_39E = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + } + break; + } + + if (pthis->unk_39E != 0) { + Gameplay_CameraSetAtEye(globalCtx, pthis->unk_39E, &pthis->unk_3B0, &pthis->unk_3A4); + } + + switch (pthis->unk_1AC) { + case 0: + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_034278, 0.0f); + pthis->unk_1AC = 1; + } + break; + case 1: + if ((globalCtx->gameplayFrames % 32) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_BREATH); + } + + if ((pthis->unk_1A2[0] == 0) || (pthis->unk_334 != 0)) { + temp_f2 = -200.0f - player->actor.world.pos.x; + temp_f12 = -200.0f - player->actor.world.pos.z; + + if (sqrtf(SQ(temp_f2) + SQ(temp_f12)) <= 784.0f) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_0334F8, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_0334F8); + pthis->unk_1AC = 2; + pthis->unk_1A2[0] = 40; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_ROAR); + } + } + break; + case 2: + Math_ApproachF(&pthis->unk_324, 255.0f, 1.0f, 10.0f); + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 2.0f / 51.0f); + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + func_808FFDB0(pthis, globalCtx); + if (pthis->unk_334 == 0) { + pthis->actor.colChkInfo.health = 25; + } + pthis->unk_336 = 1; + } + break; + } + + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 1.0f); +} + +void func_80901020(BossGanon2* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_02A848, -5.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_02A848); + pthis->actionFunc = func_8090120C; + pthis->unk_1AC = 0; + pthis->unk_39C = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DEAD1); + pthis->unk_314 = 4; +} + +void func_8090109C(BossGanon2* pthis, GlobalContext* globalCtx) { + u8 i; + + for (i = 0; i < 70; i++) { + Vec3f velocity; + Vec3f accel; + Vec3f pos; + + velocity.x = Rand_CenteredFloat(50.0f); + velocity.y = Rand_CenteredFloat(10.0f) + 5.0f; + velocity.z = Rand_CenteredFloat(50.0f); + accel.x = 0.0f; + accel.y = -1.0f; + accel.z = 0.0f; + pos.x = pthis->unk_1B8.x; + pos.y = pthis->unk_1B8.y; + pos.z = pthis->unk_1B8.z; + func_8002836C(globalCtx, &pos, &velocity, &accel, &sPrimColor, &sEnvColor, (s16)Rand_ZeroFloat(50.0f) + 50, 0, + 17); + } +} + +void func_8090120C(BossGanon2* pthis, GlobalContext* globalCtx) { + Player* player; + f32 temp_f14; + f32 temp_f12; + Camera* temp_v0_2; + s16 temp_a0_2; + f32 phi_f0; + s32 phi_a1; + + player = GET_PLAYER(globalCtx); + pthis->unk_398++; + SkelAnime_Update(&pthis->skelAnime); + + pthis->unk_3BC.x = 0.0f; + pthis->unk_3BC.y = 1.0f; + pthis->unk_3BC.z = 0.0f; + + switch (pthis->unk_39C) { + case 0: + func_80064520(globalCtx, &globalCtx->csCtx); + pthis->unk_39E = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_39E, CAM_STAT_ACTIVE); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->unk_39C = 1; + pthis->unk_398 = 0; + sZelda->unk_3C8 = 9; + pthis->unk_31C = 0; + pthis->unk_1A2[2] = 0; + pthis->unk_336 = 0; + pthis->unk_324 = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->unk_31A = pthis->unk_31C; + globalCtx->envCtx.unk_D8 = 0.0f; + case 1: + if (pthis->unk_398 < 90) { + pthis->unk_339 = 20; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.1f); + } else if (pthis->unk_398 >= 90) { + pthis->unk_339 = 21; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.08f); + } + if (pthis->unk_398 == 50) { + func_80078884(NA_SE_EN_MGANON_WALK); + } + if (pthis->unk_398 > 90) { + Math_ApproachF(&pthis->unk_380, 0.25f, 1.0f, 0.0125f); + pthis->unk_37C = 200.0f; + func_80078884(NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + } + if (pthis->unk_398 >= 110) { + if (pthis->unk_398 == 110) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_HIT_THUNDER); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DAMAGE); + } + Math_ApproachF(&pthis->unk_30C, 10.0f, 0.2f, 5.0f); + pthis->skelAnime.playSpeed = 3.0f; + } + if (pthis->unk_398 == 120) { + func_8002DF54(globalCtx, &pthis->actor, 0x63); + } + pthis->actor.world.rot.y = 0x4000; + pthis->actor.world.pos.x = pthis->actor.world.pos.z = 0.0f; + player->actor.shape.rot.y = -0x4000; + player->actor.world.pos.x = 200.0f; + player->actor.world.pos.z = 30.0f; + sZelda->actor.world.pos.x = 340.0f; + sZelda->actor.world.pos.z = -250.0f; + sZelda->actor.world.rot.y = sZelda->actor.shape.rot.y = -0x2000; + pthis->unk_3A4.x = 250; + pthis->unk_3A4.y = 1150.0f; + pthis->unk_3A4.z = 0.0f; + pthis->unk_3B0.x = pthis->unk_1B8.x; + pthis->unk_3B0.y = pthis->unk_1B8.y; + pthis->unk_3B0.z = pthis->unk_1B8.z; + if (pthis->unk_398 > 135) { + pthis->unk_39C = 2; + pthis->unk_398 = 0; + } + break; + case 2: + pthis->unk_339 = 22; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.1f); + func_80078884(NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + pthis->unk_3A4.x = 250; + pthis->unk_3A4.y = 1150.0f; + pthis->unk_3A4.z = 0.0f; + Math_ApproachF(&pthis->unk_3B0.x, sZelda->actor.world.pos.x, 0.2f, 20.0f); + Math_ApproachF(&pthis->unk_3B0.y, sZelda->actor.world.pos.y + 50.0f, 0.2f, 10.0f); + Math_ApproachF(&pthis->unk_3B0.z, sZelda->actor.world.pos.z, 0.2f, 20.0f); + if (pthis->unk_398 == 50) { + pthis->unk_39C = 3; + pthis->unk_398 = 0; + } + break; + case 3: + pthis->unk_339 = 22; + func_80078884(NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + pthis->unk_3A4.x = 330.0f; + pthis->unk_3A4.y = 1120.0f; + pthis->unk_3A4.z = -150.0f; + pthis->unk_3B0.x = sZelda->actor.world.pos.x; + pthis->unk_3B0.y = sZelda->actor.world.pos.y + 40.0f; + pthis->unk_3B0.z = sZelda->actor.world.pos.z; + if (pthis->unk_398 == 10) { + Message_StartTextbox(globalCtx, 0x70D8, NULL); + } + if ((pthis->unk_398 > 80) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { + pthis->unk_39C = 4; + pthis->unk_398 = 0; + } + break; + case 4: + if (pthis->unk_398 > 10) { + Math_ApproachZeroF(&pthis->unk_37C, 1.0f, 10.0f); + if (pthis->unk_398 == 30) { + sZelda->unk_3C8 = 10; + } + pthis->unk_339 = 23; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + } else { + pthis->unk_339 = 22; + } + if (pthis->unk_398 == 100) { + pthis->unk_39C = 5; + pthis->unk_398 = 40; + pthis->skelAnime.playSpeed = 1.0f; + func_8002DF54(globalCtx, &pthis->actor, 0x64); + } + break; + case 5: + pthis->unk_339 = 23; + if ((pthis->unk_398 >= 60) && (pthis->unk_398 <= 90)) { + if (pthis->unk_398 == 62) { + func_80078884(NA_SE_EV_TRIFORCE_FLASH); + } + Math_ApproachF(&pthis->unk_38C, 200.0f, 1.0f, 8.0f); + } else { + Math_ApproachZeroF(&pthis->unk_38C, 1.0f, 8.0f); + } + if (pthis->unk_398 == 70) { + func_8002DF54(globalCtx, &pthis->actor, 0x65); + } + if (pthis->unk_398 == 150) { + func_8002DF54(globalCtx, &pthis->actor, 0x66); + } + pthis->unk_30C = 10.0f; + player->actor.world.pos.x = 250.0f; + player->actor.world.pos.z = 30.0f; + pthis->unk_3A4.x = player->actor.world.pos.x - 50.0f; + pthis->unk_3A4.y = player->actor.world.pos.y + 50.0f; + pthis->unk_3A4.z = player->actor.world.pos.z + 40.0f; + pthis->unk_3B0.x = player->actor.world.pos.x; + pthis->unk_3B0.y = player->actor.world.pos.y + 40.0f; + pthis->unk_3B0.z = player->actor.world.pos.z; + if (pthis->unk_398 == 166) { + temp_v0_2 = Gameplay_GetCamera(globalCtx, MAIN_CAM); + temp_v0_2->eye = pthis->unk_3A4; + temp_v0_2->eyeNext = pthis->unk_3A4; + temp_v0_2->at = pthis->unk_3B0; + func_800C08AC(globalCtx, pthis->unk_39E, 0); + pthis->unk_39E = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->unk_39C = 6; + } + break; + case 6: + pthis->unk_339 = 23; + temp_f14 = pthis->unk_1B8.x - player->actor.world.pos.x; + temp_f12 = pthis->unk_1B8.z - player->actor.world.pos.z; + temp_a0_2 = Math_Atan2S(temp_f12, temp_f14) - player->actor.shape.rot.y; + if ((ABS(temp_a0_2) < 0x2000) && (sqrtf(SQ(temp_f14) + SQ(temp_f12)) < 70.0f) && + (player->swordState != 0) && (player->heldItemActionParam == PLAYER_AP_SWORD_MASTER)) { + func_80064520(globalCtx, &globalCtx->csCtx); + pthis->unk_39E = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_39E, CAM_STAT_ACTIVE); + pthis->unk_39C = 7; + pthis->unk_398 = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_003B1C, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_003B1C); + globalCtx->startPlayerCutscene(globalCtx, &pthis->actor, 0x61); + } else { + break; + } + case 7: + pthis->unk_339 = 23; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.2f); + player->actor.world.pos.x = 250.0f; + player->actor.shape.rot.y = -0x4000; + player->actor.world.pos.z = 30.0f; + if ((pthis->unk_398 == 20) || (pthis->unk_398 == 30) || (pthis->unk_398 == 65) || (pthis->unk_398 == 40)) { + func_80078884(NA_SE_VO_LI_SWORD_N); + func_80078884(NA_SE_IT_SWORD_SWING_HARD); + } + if ((pthis->unk_398 == 22) || (pthis->unk_398 == 35) || (pthis->unk_398 == 72) || (pthis->unk_398 == 45)) { + func_80078884(NA_SE_EN_MGANON_DAMAGE); + func_80078884(NA_SE_IT_SHIELD_BOUND); + globalCtx->envCtx.unk_D8 = 1.0f; + } + if ((pthis->unk_398 == 22) || (pthis->unk_398 == 35) || (pthis->unk_398 == 72) || (pthis->unk_398 == 45)) { + func_8090109C(pthis, globalCtx); + } + if ((pthis->unk_398 >= 34) && (pthis->unk_398 < 40)) { + pthis->unk_3A4.x = 269.0f; + pthis->unk_3A4.y = 1112.0f; + pthis->unk_3A4.z = -28.0f; + pthis->unk_3B0.x = 234.0f; + pthis->unk_3B0.y = 1117.0f; + pthis->unk_3B0.z = -11.0f; + } else { + if (pthis->unk_398 < 30) { + phi_a1 = 0; + } else if (pthis->unk_398 < 43) { + phi_a1 = 1; + } else { + pthis->unk_3BC.z = -0.8f; + player->actor.world.pos.x = 200.0f; + player->actor.world.pos.z = 10.0f; + phi_a1 = 2; + } + pthis->unk_3A4.x = D_8090702C[phi_a1].x + (player->actor.world.pos.x - 50.0f); + pthis->unk_3A4.y = D_8090702C[phi_a1].y + (player->actor.world.pos.y + 50.0f); + pthis->unk_3A4.z = D_8090702C[phi_a1].z + (player->actor.world.pos.z + 40.0f); + pthis->unk_3B0.x = D_80907050[phi_a1].x + player->actor.world.pos.x; + pthis->unk_3B0.y = D_80907050[phi_a1].y + (player->actor.world.pos.y + 40.0f); + pthis->unk_3B0.z = D_80907050[phi_a1].z + player->actor.world.pos.z; + } + if (pthis->unk_398 > 80) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + pthis->unk_39C = 75; + pthis->unk_398 = 0; + pthis->unk_3A4.x = 112.0f; + pthis->unk_3A4.y = 1146.0f; + pthis->unk_3A4.z = 202.0f; + pthis->unk_3B0.x = 110.0f; + pthis->unk_3B0.y = 1144.0f; + pthis->unk_3B0.z = 177.0f; + player->actor.world.pos.x = 200.0f; + pthis->unk_3BC.z = 0.0f; + } + break; + case 75: + pthis->unk_339 = 23; + if (pthis->unk_398 == 55) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_007288, 0.0f); + pthis->unk_194 = Animation_GetLastFrame(&object_ganon2_Anim_007288); + func_8002DF54(globalCtx, &pthis->actor, 0x62); + pthis->unk_39C = 8; + pthis->unk_398 = 1000; + } + break; + case 8: + if (pthis->unk_398 == 1025) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_STAND); + } + if (pthis->unk_398 >= 1000) { + if (pthis->unk_398 < 1040) { + pthis->unk_339 = 23; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.2f); + } + } + if (pthis->unk_398 == 1040) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DEAD2); + pthis->unk_336 = 2; + pthis->unk_339 = 0; + globalCtx->envCtx.unk_BE = 0; + globalCtx->envCtx.unk_D8 = 0.0f; + } + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_ganon2_Anim_008EB8, 0.0f); + pthis->unk_398 = 0; + pthis->unk_194 = 1000.0f; + } + pthis->unk_3A4.x = 250; + pthis->unk_3A4.y = 1150.0f; + pthis->unk_3A4.z = 0.0f; + pthis->unk_3B0.x = pthis->unk_1B8.x; + pthis->unk_3B0.y = pthis->unk_1B8.y; + pthis->unk_3B0.z = pthis->unk_1B8.z; + if ((pthis->unk_398 < 1000) && ((pthis->unk_398 % 16) == 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_SWORD); + } + if (pthis->unk_398 == 40) { + pthis->unk_39C = 9; + pthis->unk_398 = 0; + sZelda->unk_3C8 = 11; + Message_StartTextbox(globalCtx, 0x70D9, NULL); + pthis->unk_336 = 0; + globalCtx->envCtx.unk_D8 = 0.0f; + } + break; + case 9: + pthis->unk_339 = 24; + pthis->unk_3A4.x = 330.0f; + pthis->unk_3A4.y = 1120.0f; + pthis->unk_3A4.z = -150.0f; + pthis->unk_3B0.x = sZelda->actor.world.pos.x; + pthis->unk_3B0.y = sZelda->actor.world.pos.y + 40.0f; + pthis->unk_3B0.z = sZelda->actor.world.pos.z; + if (pthis->unk_398 > 60) { + pthis->unk_39C = 10; + pthis->unk_398 = 0; + pthis->unk_410.x = 0.0f; + } + break; + case 10: + pthis->unk_339 = 24; + Math_ApproachF(&pthis->unk_3A4.x, 290.0f, 0.05f, pthis->unk_410.x); + Math_ApproachF(&pthis->unk_3A4.y, 1130.0f, 0.05f, pthis->unk_410.x * 0.25f); + Math_ApproachF(&pthis->unk_3A4.z, -260.0f, 0.05f, pthis->unk_410.x * 1.25f); + if ((pthis->unk_398 >= 40) && (pthis->unk_398 <= 110)) { + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.02f); + Math_ApproachF(&pthis->unk_384, 10.0f, 0.1f, 0.2f); + Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); + } else { + Math_ApproachZeroF(&pthis->unk_384, 1.0f, 0.2f); + } + if (pthis->unk_398 > 130) { + Math_ApproachF(&pthis->unk_3B0.y, (sZelda->actor.world.pos.y + 40.0f + 10.0f) - 20.0f, 0.1f, + pthis->unk_410.x); + } else { + Math_ApproachF(&pthis->unk_3B0.y, sZelda->actor.world.pos.y + 40.0f + 10.0f, 0.05f, + pthis->unk_410.x * 0.25f); + } + Math_ApproachF(&pthis->unk_410.x, 1.0f, 1.0f, 0.01f); + if (pthis->unk_398 == 10) { + sZelda->unk_3C8 = 12; + } + if (pthis->unk_398 == 110) { + sZelda->unk_3C8 = 13; + } + if (pthis->unk_398 == 140) { + Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_HUMAN_BOUND); + } + if (pthis->unk_398 < 160) { + break; + } + case 20: + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0xFFF2; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 3; + globalCtx->linkAgeOnLoad = 1; + break; + } + + if (pthis->unk_39E != 0) { + Gameplay_CameraSetAtEyeUp(globalCtx, pthis->unk_39E, &pthis->unk_3B0, &pthis->unk_3A4, &pthis->unk_3BC); + } + + switch (pthis->unk_1AC) { + case 0: + if (Animation_OnFrame(&pthis->skelAnime, pthis->unk_194)) { + Animation_MorphToLoop(&pthis->skelAnime, &object_ganon2_Anim_034278, 0.0f); + pthis->unk_1AC = 1; + } + break; + case 1: + if ((pthis->unk_39C < 7) && ((globalCtx->gameplayFrames % 32) == 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_BREATH); + } + break; + } +} + +void func_80902348(BossGanon2* pthis, GlobalContext* globalCtx) { + Player* player; + f32 temp_f2; + f32 temp_f12; + s16 i; + s16 j; + s16 phi_v0_2; + + if (pthis->unk_316 == 0) { + for (i = 0; i < ARRAY_COUNT(pthis->unk_864); i++) { + if (pthis->unk_444.elements[i].info.bumperFlags & 2) { + pthis->unk_444.elements[i].info.bumperFlags &= ~2; + } else if (pthis->unk_444.elements[i].info.toucherFlags & 2) { + pthis->unk_444.elements[i].info.toucherFlags &= ~2; + + if (pthis->unk_312 == 1) { + phi_v0_2 = 0x1800; + } else { + phi_v0_2 = 0; + } + + func_8002F6D4(globalCtx, &pthis->actor, 15.0f, pthis->actor.yawTowardsPlayer + phi_v0_2, 2.0f, 0); + sZelda->unk_3C8 = 8; + pthis->unk_316 = 10; + break; + } + } + } + + if (pthis->unk_324 > 0.0f) { + player = GET_PLAYER(globalCtx); + temp_f2 = -200.0f - player->actor.world.pos.x; + temp_f12 = -200.0f - player->actor.world.pos.z; + + if (sqrtf(SQ(temp_f2) + SQ(temp_f12)) > 784.0f) { + for (j = 0; j < ARRAY_COUNT(player->flameTimers); j++) { + player->flameTimers[j] = Rand_S16Offset(0, 200); + } + + player->isBurning = true; + func_8002F6D4(globalCtx, &pthis->actor, 10.0f, Math_Atan2S(temp_f12, temp_f2), 0.0f, 0x10); + sZelda->unk_3C8 = 8; + } + } +} + +void func_80902524(BossGanon2* pthis, GlobalContext* globalCtx) { + s8 temp_v0_4; + ColliderInfo* acHitInfo; + s16 i; + u8 phi_v1_2; + + osSyncPrintf("pthis->no_hit_time %d\n", pthis->unk_316); + if (pthis->unk_316 != 0 || ((pthis->unk_334 == 0) && (pthis->actionFunc == func_80900890))) { + for (i = 0; i < ARRAY_COUNT(pthis->unk_464); i++) { + pthis->unk_424.elements[i].info.bumperFlags &= ~2; + } + } + + osSyncPrintf("pthis->look_on %d\n", pthis->unk_313); + if (pthis->unk_313) { + if (pthis->actionFunc != func_808FFFE0) { + if (pthis->unk_424.elements[0].info.bumperFlags & 2) { + pthis->unk_424.elements[0].info.bumperFlags &= ~2; + acHitInfo = pthis->unk_424.elements[0].info.acHitInfo; + if ((acHitInfo->toucher.dmgFlags & 0x2000) && (pthis->actionFunc != func_80900890)) { + func_809000A0(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_HIT_THUNDER); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DAMAGE); + Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); + } else if ((pthis->actionFunc == func_80900890) && (acHitInfo->toucher.dmgFlags & 0x9000200)) { + pthis->unk_316 = 60; + pthis->unk_342 = 5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DAMAGE); + Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); + pthis->actor.colChkInfo.health -= 2; + temp_v0_4 = pthis->actor.colChkInfo.health; + if (temp_v0_4 < 0x15 && pthis->unk_334 == 0) { + func_80900818(pthis, globalCtx); + } else { + if (temp_v0_4 <= 0) { + func_80901020(pthis, globalCtx); + } else { + func_80900210(pthis, globalCtx); + } + } + } else if (pthis->actionFunc != func_80900890) { + func_808FFF90(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_HOOKSHOT_REFLECT); + } + } + } + } else { + if (pthis->unk_424.elements[15].info.bumperFlags & 2) { + pthis->unk_424.elements[15].info.bumperFlags &= ~2; + acHitInfo = pthis->unk_424.elements[15].info.acHitInfo; + pthis->unk_316 = 60; + pthis->unk_344 = 0x32; + pthis->unk_342 = 5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MGANON_DAMAGE); + Audio_StopSfxById(NA_SE_EN_MGANON_UNARI); + phi_v1_2 = 1; + if (acHitInfo->toucher.dmgFlags & 0x9000200) { + if (acHitInfo->toucher.dmgFlags & 0x8000000) { + phi_v1_2 = 4; + } else { + phi_v1_2 = 2; + } + } + pthis->actor.colChkInfo.health -= phi_v1_2; + temp_v0_4 = pthis->actor.colChkInfo.health; + if ((temp_v0_4 < 0x15) && (pthis->unk_334 == 0)) { + func_80900818(pthis, globalCtx); + } else if ((temp_v0_4 <= 0) && (phi_v1_2 >= 2)) { + func_80901020(pthis, globalCtx); + } else { + if (temp_v0_4 <= 0) { + pthis->actor.colChkInfo.health = 1; + } + func_80900210(pthis, globalCtx); + } + } + } +} + +void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx) { + BossGanon2* pthis = (BossGanon2*)thisx; + s32 pad; + s16 i; + f32 phi_f2; + u16 i2; + Vec3f sp58; + Vec3f sp4C; + f32 angle; + f32 sp44; + + if ((pthis->unk_337 == 0) || (pthis->unk_337 == 2)) { + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON_ANIME3, false); + } else { + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON2, false); + Math_ApproachZeroF(&pthis->unk_30C, 1.0f, 0.5f); + } + func_808FFC84(pthis); + pthis->unk_312 = 0; + pthis->unk_19C++; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actionFunc(pthis, globalCtx); + for (i = 0; i < ARRAY_COUNT(pthis->unk_1A2); i++) { + if (pthis->unk_1A2[i] != 0) { + pthis->unk_1A2[i]--; + } + } + if (pthis->unk_316 != 0) { + pthis->unk_316--; + } + if (pthis->unk_342 != 0) { + pthis->unk_342--; + } + if (pthis->unk_390 != 0) { + pthis->unk_390--; + } + if (pthis->unk_392 != 0) { + pthis->unk_392--; + } + Actor_MoveForward(&pthis->actor); + pthis->actor.shape.rot = pthis->actor.world.rot; + if (pthis->unk_335 != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 60.0f, 60.0f, 100.0f, 5); + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.velocity.y < -5.0f) { + func_80033E88(&pthis->actor, globalCtx, 5, 20); + func_80078884(NA_SE_IT_BOMB_EXPLOSION); + } + pthis->actor.velocity.y = 0.0f; + } + } + if (((pthis->unk_19C & 0x1F) == 0) && (Rand_ZeroOne() < 0.3f)) { + pthis->unk_318 = 4; + } + pthis->unk_310 = D_80907074[pthis->unk_318]; + if (pthis->unk_318 != 0) { + pthis->unk_318--; + } + pthis->unk_1B0 = (Math_SinS(pthis->unk_19C * 0x2AAA) * 64.0f) + 191.0f; + if (pthis->unk_344 != 0) { + pthis->unk_344--; + Math_ApproachF(&pthis->unk_360.x, 5000.0f, 0.5f, 3000.0f); + Math_ApproachF(&pthis->unk_370.x, 5500.0f, 0.5f, 3000.0f); + Math_ApproachF(&pthis->unk_360.z, 8000.0f, 0.1f, 4000.0f); + Math_ApproachF(&pthis->unk_370.z, 8000.0f, 0.1f, 4000.0f); + Math_ApproachS(&pthis->unk_346, 0xFA0, 0xA, 0x7D0); + } else { + pthis->unk_360.y = 14000.0f; + Math_ApproachF(&pthis->unk_360.x, 2000.0f, 0.1f, 100.0f); + pthis->unk_370.y = 12000.0f; + Math_ApproachF(&pthis->unk_370.x, 1500.0f, 0.1f, 100.0f); + if ((pthis->actionFunc == func_808FFEBC) || (pthis->actionFunc == func_808FFFE0) || + (pthis->actionFunc == func_80900104)) { + Math_ApproachF(&pthis->unk_360.z, 1000.0f, 0.1f, 100.0f); + Math_ApproachF(&pthis->unk_370.z, 1000.0f, 0.1f, 100.0f); + Math_ApproachS(&pthis->unk_346, -0xFA0, 0xA, 0x64); + } else { + Math_ApproachF(&pthis->unk_360.z, 5000.0f, 0.1f, 200.0f); + Math_ApproachF(&pthis->unk_370.z, 5000.0f, 0.1f, 200.0f); + Math_ApproachS(&pthis->unk_346, 0, 0xA, 0x64); + } + } + if (pthis->unk_39C != 75) { + pthis->unk_35C += pthis->unk_360.x; + pthis->unk_36C += pthis->unk_370.x; + } + if (pthis->unk_337 == 2) { + pthis->unk_370.z = 0.0f; + pthis->unk_360.z = 0.0f; + } + + for (i = 0; i < ARRAY_COUNT(pthis->unk_348); i++) { + if (i == 0) { + phi_f2 = 0.2f; + } else if (i == 1) { + phi_f2 = 0.5f; + } else { + phi_f2 = 1.0f; + } + + pthis->unk_348[i] = Math_SinS(((s16)pthis->unk_35C + (i * (s16)pthis->unk_360.y))) * phi_f2 * pthis->unk_360.z; + pthis->unk_352[i] = Math_SinS(((s16)pthis->unk_36C + (i * (s16)pthis->unk_370.y))) * phi_f2 * pthis->unk_370.z; + } + + func_808FF898(pthis, globalCtx); + func_80902348(pthis, globalCtx); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->unk_424.base); + if (pthis->actionFunc != func_8090120C) { + func_80902524(pthis, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->unk_424.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->unk_444.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->unk_444.base); + if (pthis->unk_39E == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->unk_444.base); + } + } + if ((pthis->unk_332 == 0) && (pthis->unk_336 != 0)) { + if (pthis->unk_336 == 2) { + pthis->unk_332 = (s16)Rand_ZeroFloat(30.0f) + 8; + } else { + pthis->unk_332 = (s16)Rand_ZeroFloat(60.0f) + 0xA; + } + pthis->unk_339 = 0; + globalCtx->envCtx.unk_BE = 0; + globalCtx->envCtx.unk_BD = (s8)Rand_ZeroFloat(1.9f) + 1; + globalCtx->envCtx.unk_D8 = 1.0f; + D_8090EB20.y = 0.0f; + D_8090EB20.x = D_8090EB20.y; + D_8090EB20.z = D_8090EB20.x; + if (Rand_ZeroOne() < 0.5f) { + D_8090EB20.z = Rand_ZeroFloat(1000.0f); + } + func_80078914(&D_8090EB20, NA_SE_EV_LIGHTNING); + pthis->unk_328 = 0xFF; + pthis->unk_330 = 5; + pthis->unk_32C = 0.0f; + pthis->unk_340 = (s16)Rand_ZeroFloat(10000.0f); + } else if (pthis->unk_332 != 0) { + pthis->unk_332--; + } + if ((globalCtx->envCtx.unk_D8 > 0.0f) && (pthis->unk_336 != 0)) { + globalCtx->envCtx.customSkyboxFilter = 1; + globalCtx->envCtx.skyboxFilterColor[0] = 255; + globalCtx->envCtx.skyboxFilterColor[1] = 255; + globalCtx->envCtx.skyboxFilterColor[2] = 255; + globalCtx->envCtx.skyboxFilterColor[3] = (s16)(globalCtx->envCtx.unk_D8 * 200.0f); + } else { + globalCtx->envCtx.customSkyboxFilter = 0; + } + globalCtx->envCtx.unk_BF = 0; + globalCtx->envCtx.unk_DC = 2; + + switch (pthis->unk_339) { + case 0: + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.1f); + break; + case 3: + globalCtx->envCtx.unk_BE = 3; + globalCtx->envCtx.unk_BD = 4; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.0125f); + break; + case 4: + globalCtx->envCtx.unk_BE = 5; + globalCtx->envCtx.unk_BD = 6; + Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.0125f); + break; + case 5: + globalCtx->envCtx.unk_BE = 6; + globalCtx->envCtx.unk_BD = 7; + Math_ApproachF(&pthis->unk_33C, 0.69f, 1.0f, 0.05f); + globalCtx->envCtx.unk_D8 = + (Math_SinS(globalCtx->gameplayFrames * 0x5000) * 0.15f) + (0.15f + pthis->unk_33C); + break; + case 55: + globalCtx->envCtx.unk_BE = 2; + globalCtx->envCtx.unk_BD = 0; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); + break; + case 6: + globalCtx->envCtx.unk_BE = 2; + globalCtx->envCtx.unk_BD = 8; + Math_ApproachF(&pthis->unk_33C, 0.69f, 1.0f, 0.05f); + globalCtx->envCtx.unk_D8 = + (Math_SinS(globalCtx->gameplayFrames * 0x7000) * 0.15f) + (0.15f + pthis->unk_33C); + break; + case 7: + globalCtx->envCtx.unk_BE = 0; + globalCtx->envCtx.unk_BD = 8; + Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.02f); + break; + case 20: + globalCtx->envCtx.unk_BE = 0; + globalCtx->envCtx.unk_BD = 9; + break; + case 21: + globalCtx->envCtx.unk_BE = 0xA; + globalCtx->envCtx.unk_BD = 9; + break; + case 22: + globalCtx->envCtx.unk_BE = 0xA; + globalCtx->envCtx.unk_BD = 0xB; + break; + case 23: + globalCtx->envCtx.unk_BE = 9; + globalCtx->envCtx.unk_BD = 0xB; + break; + case 24: + globalCtx->envCtx.unk_BE = 0; + globalCtx->envCtx.unk_BD = 0xC; + break; + case -1: + break; + } + + if (pthis->unk_339 >= 0) { + pthis->unk_339 = 0; + } + if (D_80906D78 != 0) { + D_80906D78 = 0; + + for (i2 = 0; i2 < ARRAY_COUNT(sParticles); i2++) { + angle = Rand_ZeroFloat(2 * M_PI); + sp44 = Rand_ZeroFloat(40.0f) + 10.0f; + sp58 = pthis->actor.world.pos; + sp58.y = 1200.0f; + sp4C.x = cosf(angle) * sp44; + sp4C.z = sinf(angle) * sp44; + sp4C.y = Rand_ZeroFloat(15.0f) + 15.0f; + sp58.x += sp4C.x * 10.0f * 0.1f; + sp58.z += sp4C.z * 10.0f * 0.1f; + func_808FD27C(globalCtx, &sp58, &sp4C, Rand_ZeroFloat(0.3f) + 0.2f); + } + } + pthis->unk_388 += 0.15f; + func_80905DA8(pthis, globalCtx); +} + +void func_809034E4(Vec3f* arg0, Vec3f* arg1) { + Vtx* vtx; + Vec3f sp2D0; + s16 temp_s1; + s16 temp_a1; + s16 sp2CA; + s16 sp2C8; + s16 i; + u8 phi_s2; + u8 temp_s4; + u8 temp_s4_2; + f32 temp_f12; + Vec3f temp_f20; + Vec3f temp_f2; + Vec3f temp_f22; + f32 sp294; + f32 phi_f30; + f32 temp_f28; + f32 temp_f26; + s32 pad[3]; + Vec3f sp18C[20]; + Vec3f sp9C[20]; + + for (i = 0; i < 20; i++) { + sp18C[i] = *arg0; + sp9C[i] = *arg1; + } + + temp_s4 = 0; + + D_809105D8[3] = D_809105D8[2]; + D_809105D8[2] = D_809105D8[1]; + D_809105D8[1] = D_809105D8[0]; + D_809105D8[0] = *arg0; + + sp2D0 = D_809105D8[0]; + + temp_f20.x = D_809105D8[1].x - sp2D0.x; + temp_f20.y = D_809105D8[1].y - sp2D0.y; + temp_f20.z = D_809105D8[1].z - sp2D0.z; + + sp2CA = Math_Atan2S(temp_f20.z, temp_f20.x); + sp2C8 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); + + temp_f2.x = D_809105D8[2].x - D_809105D8[1].x; + temp_f2.y = D_809105D8[2].y - D_809105D8[1].y; + temp_f2.z = D_809105D8[2].z - D_809105D8[1].z; + + temp_f22.x = D_809105D8[3].x - D_809105D8[2].x; + temp_f22.y = D_809105D8[3].y - D_809105D8[2].y; + temp_f22.z = D_809105D8[3].z - D_809105D8[2].z; + + temp_f12 = sqrtf(SQXYZ(temp_f20)) + sqrtf(SQXYZ(temp_f2)) + sqrtf(SQXYZ(temp_f22)); + if (temp_f12 <= 1.0f) { + temp_f12 = 1.0f; + } + + temp_f28 = temp_f12 * 0.083f; + phi_f30 = sqrtf(SQXYZ(temp_f20)) / 2.0f; + sp294 = sqrtf(SQXYZ(temp_f2)) / 2.0f; + + phi_s2 = 1; + + while (true) { + temp_f20.x = D_809105D8[phi_s2].x - sp2D0.x; + temp_f20.y = D_809105D8[phi_s2].y - sp2D0.y; + temp_f20.z = D_809105D8[phi_s2].z - sp2D0.z; + + temp_s1 = Math_Atan2S(temp_f20.z, temp_f20.x); + temp_a1 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); + + Math_ApproachS(&sp2C8, temp_a1, 1, 0x1000); + Math_ApproachS(&sp2CA, temp_s1, 1, 0x1000); + + temp_f26 = temp_f28 * Math_CosS(sp2C8); + + sp18C[temp_s4] = sp2D0; + + sp2D0.x += temp_f26 * Math_SinS(sp2CA); + sp2D0.y += temp_f28 * Math_SinS(sp2C8); + sp2D0.z += temp_f26 * Math_CosS(sp2CA); + + temp_f20.x = D_809105D8[phi_s2].x - sp2D0.x; + temp_f20.y = D_809105D8[phi_s2].y - sp2D0.y; + temp_f20.z = D_809105D8[phi_s2].z - sp2D0.z; + + if (phi_s2 < 3) { + if (sqrtf(SQXYZ(temp_f20)) <= phi_f30) { + phi_f30 = sp294; + phi_s2++; + } + } else { + if (sqrtf(SQXYZ(temp_f20)) <= (temp_f28 + 1.0f)) { + phi_s2++; + } + } + + temp_s4++; + + if ((temp_s4 >= 20) || (phi_s2 >= 4)) { + break; + } + } + + temp_s4_2 = 0; + + D_80910608[3] = D_80910608[2]; + D_80910608[2] = D_80910608[1]; + D_80910608[1] = D_80910608[0]; + D_80910608[0] = *arg1; + + sp2D0 = D_80910608[0]; + + temp_f20.x = D_80910608[1].x - sp2D0.x; + temp_f20.y = D_80910608[1].y - sp2D0.y; + temp_f20.z = D_80910608[1].z - sp2D0.z; + + sp2CA = Math_Atan2S(temp_f20.z, temp_f20.x); + sp2C8 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); + + temp_f2.x = D_80910608[2].x - D_80910608[1].x; + temp_f2.y = D_80910608[2].y - D_80910608[1].y; + temp_f2.z = D_80910608[2].z - D_80910608[1].z; + + temp_f22.x = D_80910608[3].x - D_80910608[2].x; + temp_f22.y = D_80910608[3].y - D_80910608[2].y; + temp_f22.z = D_80910608[3].z - D_80910608[2].z; + + temp_f12 = sqrtf(SQXYZ(temp_f20)) + sqrtf(SQXYZ(temp_f2)) + sqrtf(SQXYZ(temp_f22)); + if (temp_f12 <= 1.0f) { + temp_f12 = 1.0f; + } + + temp_f28 = temp_f12 * 0.083f; + phi_f30 = sqrtf(SQXYZ(temp_f20)) / 2.0f; + sp294 = sqrtf(SQXYZ(temp_f2)) / 2.0f; + + phi_s2 = 1; + + while (true) { + temp_f20.x = D_80910608[phi_s2].x - sp2D0.x; + temp_f20.y = D_80910608[phi_s2].y - sp2D0.y; + temp_f20.z = D_80910608[phi_s2].z - sp2D0.z; + + temp_s1 = Math_Atan2S(temp_f20.z, temp_f20.x); + temp_a1 = Math_Atan2S(sqrtf(SQXZ(temp_f20)), temp_f20.y); + + Math_ApproachS(&sp2C8, temp_a1, 1, 0x1000); + Math_ApproachS(&sp2CA, temp_s1, 1, 0x1000); + + temp_f26 = temp_f28 * Math_CosS(sp2C8); + + sp9C[temp_s4_2] = sp2D0; + + sp2D0.x += temp_f26 * Math_SinS(sp2CA); + sp2D0.y += temp_f28 * Math_SinS(sp2C8); + sp2D0.z += temp_f26 * Math_CosS(sp2CA); + + temp_f20.x = D_80910608[phi_s2].x - sp2D0.x; + temp_f20.y = D_80910608[phi_s2].y - sp2D0.y; + temp_f20.z = D_80910608[phi_s2].z - sp2D0.z; + + if (phi_s2 < 3) { + if (sqrtf(SQXYZ(temp_f20)) <= phi_f30) { + phi_f30 = sp294; + phi_s2++; + } + } else { + if (sqrtf(SQXYZ(temp_f20)) <= (temp_f28 + 1.0f)) { + phi_s2++; + } + } + + temp_s4_2++; + + if ((temp_s4_2 >= 20) || (phi_s2 >= 4)) { + break; + } + } + + vtx = SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_Vtx_00BA20); + for (i = 0; i < 11; i++) { + if ((temp_s4 - i) > 0) { + vtx[D_80907084[i]].n.ob[0] = sp18C[temp_s4 - i - 1].x; + vtx[D_80907084[i]].n.ob[1] = sp18C[temp_s4 - i - 1].y; + vtx[D_80907084[i]].n.ob[2] = sp18C[temp_s4 - i - 1].z; + } + if ((temp_s4_2 - i) > 0) { + vtx[D_80907090[i]].n.ob[0] = sp9C[temp_s4_2 - i - 1].x; + vtx[D_80907090[i]].n.ob[1] = sp9C[temp_s4_2 - i - 1].y; + vtx[D_80907090[i]].n.ob[2] = sp9C[temp_s4_2 - i - 1].z; + } + } +} + +void func_80903F38(BossGanon2* pthis, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5083); + + if (pthis->unk_312 != 0) { + func_809034E4(&pthis->unk_200, &pthis->unk_20C); + D_80907080 = 0xFF; + } + + if (D_80910638 >= 4) { + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, globalCtx->gameplayFrames * 18, 0, 32, 32)); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, D_80907080); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_NEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5117), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00BB80); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5122); +} + +void func_80904108(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (pthis->unk_324 > 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5131); + + Matrix_Push(); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s32)globalCtx->gameplayFrames, 0, 32, 64, 1, + -globalCtx->gameplayFrames * 2, -globalCtx->gameplayFrames * 8, 32, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 200, 0, (s8)pthis->unk_324); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + Matrix_Translate(-200.0f, 1086.0f, -200.0f, MTXMODE_NEW); + Matrix_Scale(0.098000005f, 0.1f, 0.098000005f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5183), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00E1C0)); + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5186); + } +} + +void func_80904340(BossGanon2* pthis, GlobalContext* globalCtx) { + s16 i; + f32 rand; + f32 angle; + f32 sin; + f32 cos; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5196); + Matrix_Push(); + + if ((pthis->unk_330 != 0) || (pthis->unk_328 != 0)) { + if (pthis->unk_330 != 0) { + pthis->unk_330--; + } else { + pthis->unk_328 -= 70; + + if (pthis->unk_328 < 0) { + pthis->unk_328 = 0; + } + } + + Math_ApproachF(&pthis->unk_32C, 0.13f, 1.0f, 0.065f); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, pthis->unk_328); + BossGanon2_InitRand(pthis->unk_340 + 1, 0x71AC - pthis->unk_340, 0x263A); + rand = BossGanon2_RandZeroOne(); + if (1) {} + + for (i = 0; i < 5; i++) { + angle = (i * (2 * M_PI / 5)) + (rand * M_PI); + sin = 5000.0f * sinf(angle); + cos = 5000.0f * cosf(angle); + Matrix_Translate(-200.0f + sin, 4786.0f, -200.0f + cos, MTXMODE_NEW); + Matrix_Scale(pthis->unk_32C, pthis->unk_32C, pthis->unk_32C, MTXMODE_APPLY); + Matrix_RotateY(angle, MTXMODE_APPLY); + Matrix_RotateZ((BossGanon2_RandZeroOne() - 0.5f) * 100.0f * 0.01f, MTXMODE_APPLY); + + if (BossGanon2_RandZeroOne() < 0.5f) { + Matrix_RotateY(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5250), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00D798)); + } + } + + Matrix_Pop(); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5255); +} + +void func_8090464C(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (pthis->unk_1B4 > 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5264); + + Matrix_Push(); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s16)pthis->unk_1B4); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 128); + Matrix_Translate(pthis->unk_1B8.x, pthis->unk_1B8.y, pthis->unk_1B8.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_RotateZ(-0.2f, MTXMODE_APPLY); + Matrix_Scale(0.6f, 0.6f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5290), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00CCD8)); + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5293); + } +} + +s32 BossGanon2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + s32 pad; + BossGanon2* pthis = (BossGanon2*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5355); + + if (limbIndex == 15) { + rot->y += pthis->unk_31A; + rot->z += pthis->unk_31C; + } + + if (limbIndex >= 42) { + rot->x += pthis->unk_2F4[limbIndex] + pthis->unk_346; + rot->y += pthis->unk_2FE[limbIndex]; + + if (pthis->unk_342 & 1) { + gDPSetEnvColor(POLY_OPA_DISP++, 255, 0, 0, 255); + } else { + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->unk_1B0, (s16)pthis->unk_1B0, (s16)(*pthis).unk_1B0, 255); + } + } + + if ((limbIndex == 7) || (limbIndex == 13) || (limbIndex == 33) || (limbIndex == 34)) { + *dList = NULL; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5431); + return 0; +} + +void BossGanon2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + s8 pad; + s8 temp_v0; + BossGanon2* pthis = (BossGanon2*)thisx; + Vec3f sp4C; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5459); + + D_80907120.z = 17000.0f; + D_8090712C.z = 3000.0f; + + if (D_809070CC[limbIndex] >= 0) { + Matrix_MultVec3f(&D_80906D60, &pthis->unk_234[D_809070CC[limbIndex]]); + } + + if (limbIndex == 15) { + Matrix_MultVec3f(&D_80906D60, &pthis->unk_1B8); + } else if (limbIndex == 3) { + Matrix_MultVec3f(&D_80907108, &pthis->unk_1F4); + } else if (limbIndex == 9) { + Matrix_MultVec3f(&D_80907114, &pthis->unk_1E8); + } else if (limbIndex == 38) { + Matrix_MultVec3f(&D_80906D60, &pthis->unk_1DC); + } else if (limbIndex == 41) { + Matrix_MultVec3f(&D_80906D60, &pthis->unk_1D0); + } else if (limbIndex == 45) { + Matrix_MultVec3f(&D_80907138, &pthis->unk_1C4); + } + + temp_v0 = D_8090709C[limbIndex]; + if (temp_v0 >= 0) { + Matrix_MultVec3f(&D_80906D60, &sp4C); + func_808FD080(temp_v0, &pthis->unk_424, &sp4C); + } + + if ((limbIndex == 7) || (limbIndex == 13)) { + Matrix_Push(); + Matrix_Scale(pthis->unk_224, pthis->unk_224, pthis->unk_224, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5522), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + } else if ((limbIndex == 33) || (limbIndex == 34)) { + Matrix_Push(); + Matrix_Scale(pthis->unk_228, pthis->unk_228, pthis->unk_228, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5533), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + } + + if (*dList != NULL) { + if ((limbIndex == 7) && (pthis->unk_312 == 1)) { + Matrix_MultVec3f(&D_809070FC, &pthis->unk_218); + func_808FD080(0, &pthis->unk_444, &pthis->unk_218); + Matrix_MultVec3f(&D_80907120, &pthis->unk_200); + Matrix_MultVec3f(&D_8090712C, &pthis->unk_20C); + } else if ((limbIndex == 13) && (pthis->unk_312 == 2)) { + Matrix_MultVec3f(&D_809070FC, &pthis->unk_218); + func_808FD080(1, &pthis->unk_444, &pthis->unk_218); + Matrix_MultVec3f(&D_80907120, &pthis->unk_200); + Matrix_MultVec3f(&D_8090712C, &pthis->unk_20C); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5566); +} + +void func_80904D88(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5575); + + if (pthis->unk_30C > 0.0f) { + func_80093D84(globalCtx->state.gfxCtx); + if (pthis->unk_380 > 0.0f) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 0); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 255, 255, 0); + } + gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); + + for (i = 0; i < 15; i++) { + Matrix_Translate(pthis->unk_234[i].x, pthis->unk_234[i].y, pthis->unk_234[i].z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_30C, pthis->unk_30C, pthis->unk_30C, MTXMODE_APPLY); + Matrix_RotateZ(Rand_CenteredFloat(M_PI), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5618), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B378); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5622); +} + +void func_80904FC8(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5632); + + if (pthis->unk_384 > 0.0f) { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 0); + gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); + Matrix_Translate(sZelda->actor.world.pos.x, sZelda->actor.world.pos.y + 80.0f, sZelda->actor.world.pos.z, + MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(pthis->unk_384, pthis->unk_384, pthis->unk_384, MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_388, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5661), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); + Matrix_RotateZ(pthis->unk_388 * -2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5664), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5667); +} + +void func_8090523C(BossGanon2* pthis, GlobalContext* globalCtx) { + Player* player; + f32 phi_f20; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5675); + + if (pthis->unk_38C > 0.0f) { + s8 i; + + player = GET_PLAYER(globalCtx); + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)pthis->unk_38C); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); + + for (i = 0; i < 11; i++) { + Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); + Matrix_Translate((i * 250.0f) + 900.0f, 350.0f, 0.0f, MTXMODE_APPLY); + + if (i < 7) { + phi_f20 = 1.0f; + } else { + phi_f20 = 1.0f - ((i - 7) * 0.2333333f); // 7 / 30 + } + + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(200.0f * phi_f20, 200.0f * phi_f20, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(Rand_ZeroFloat(2.0f * M_PI), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5721), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5725); +} + +void BossGanon2_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + s8 temp_v1 = D_80907144[limbIndex]; + BossGanon2* pthis = (BossGanon2*)thisx; + + if (temp_v1 >= 0) { + Matrix_MultVec3f(&D_80906D60, &pthis->unk_234[temp_v1]); + } + if (limbIndex == 11) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5749); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5752), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_ganon_DL_00BE90)); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5754); + } else if (limbIndex == 10) { + Matrix_MultVec3f(&D_80907164, &pthis->unk_1B8); + } +} + +void func_80905674(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (pthis->unk_380 > 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5772); + + Matrix_Push(); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->unk_19C * -8, 0, 32, 64, 1, pthis->unk_19C * -4, + pthis->unk_19C * -8, 32, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s16)pthis->unk_37C); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 128); + Matrix_Translate(sZelda->actor.world.pos.x + 100.0f, sZelda->actor.world.pos.y + 35.0f + 7.0f, + sZelda->actor.world.pos.z - 100.0f, MTXMODE_NEW); + Matrix_RotateY(-M_PI / 4.0f, MTXMODE_APPLY); + Matrix_Scale(0.040000003f, 0.040000003f, pthis->unk_380, MTXMODE_APPLY); + Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5814), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00EC40)); + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5817); + } +} + +void BossGanon2_Draw(Actor* thisx, GlobalContext* globalCtx) { + void* shadowTexture = Graph_Alloc(globalCtx->state.gfxCtx, 4096); + BossGanon2* pthis = (BossGanon2*)thisx; + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5840); + + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + + switch (pthis->unk_337) { + case 0: + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON, true); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_ganon_Tex_00A8E0)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_ganon_Tex_00A8E0)); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, NULL, BossGanon2_PostLimbDraw2, pthis); + break; + case 1: + case 2: + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON2, true); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->unk_310])); + func_808FD080(0, &pthis->unk_444, &D_8090717C); + func_808FD080(1, &pthis->unk_444, &D_8090717C); + pthis->unk_218 = D_8090717C; + if (pthis->unk_342 & 1) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0xFF, 0, 0, 0xFF, 0x384, 0x44B); + } + Matrix_Translate(0.0f, -4000.0f, 4000.0f, MTXMODE_APPLY); + Matrix_RotateX(pthis->unk_394, MTXMODE_APPLY); + Matrix_Translate(0.0f, 4000.0f, -4000.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5910), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossGanon2_OverrideLimbDraw, BossGanon2_PostLimbDraw, + pthis); + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + BossGanon2_GenShadowTexture(shadowTexture, pthis, globalCtx); + BossGanon2_DrawShadowTexture(shadowTexture, pthis, globalCtx); + break; + } + + BossGanon2_SetObjectSegment(pthis, globalCtx, OBJECT_GANON2, true); + func_80904340(pthis, globalCtx); + func_80904108(pthis, globalCtx); + func_80904D88(pthis, globalCtx); + func_8090464C(pthis, globalCtx); + func_80905674(pthis, globalCtx); + func_80904FC8(pthis, globalCtx); + func_8090523C(pthis, globalCtx); + + if ((pthis->unk_312 != 0) || (D_80907080 != 0)) { + func_80903F38(pthis, globalCtx); + if (pthis->unk_312 == 0) { + s32 pad; + + D_80907080 -= 40; + if (D_80907080 <= 0) { + D_80907080 = 0; + } + } + + D_80910638++; + } else { + for (i = 0; i < 3; i++) { + D_809105D8[i] = pthis->unk_200; + D_80910608[i] = pthis->unk_20C; + } + + D_80910638 = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 5983); + + func_809060E8(globalCtx); +} + +void func_80905DA8(BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad[5]; + Player* player = GET_PLAYER(globalCtx); + BossGanon2Effect* effect = (BossGanon2Effect*)globalCtx->specialEffects; + Vec3f sp78; + s16 i; + + for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + if (effect->type != 0) { + effect->position.x += effect->velocity.x; + effect->position.y += effect->velocity.y; + effect->position.z += effect->velocity.z; + effect->unk_01++; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; + if (effect->type == 1) { + if (effect->unk_2E == 0) { + effect->unk_38.z += 1.0f; + effect->unk_38.y = (2.0f * M_PI) / 5.0f; + } else { + effect->unk_38.z = M_PI / 2.0f; + effect->unk_38.y = 0.0f; + if (effect->position.y <= 1098.0f) { + effect->position.y = 1098.0f; + if (effect->velocity.y < -10.0f) { + sp78 = effect->position; + sp78.y = 1086.0f; + func_80078884(NA_SE_IT_SHIELD_REFLECT_SW); + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp78); + } + effect->velocity.y = 0.0f; + } + if ((SQ(player->actor.world.pos.x - effect->position.x) + + SQ(player->actor.world.pos.z - effect->position.z)) < SQ(25.0f)) { + effect->type = 0; + pthis->unk_39C = 10; + } + } + } else if (effect->type == 2) { + effect->unk_38.x += 0.1f; + effect->unk_38.y += 0.4f; + if ((sqrtf(SQ(-200.0f - effect->position.x) + SQ(-200.0f - effect->position.z)) < 1000.0f)) { + if (effect->position.y < 1186.0f) { + if (effect->unk_2E == 0) { + effect->unk_2E++; + effect->position.y = 1186.0f; + effect->velocity.x *= 0.75f; + effect->velocity.z *= 0.75f; + effect->velocity.y *= -0.2f; + } else { + effect->type = 0; + } + } + } else if ((effect->position.y < 0.0f)) { + effect->type = 0; + } + } + } + } +} + +void func_809060E8(GlobalContext* globalCtx) { + s16 alpha; + u8 usingObjectGEff = false; + BossGanon2Effect* effect; + s16 i; + BossGanon2Effect* effects; + + effects = effect = (BossGanon2Effect*)globalCtx->specialEffects; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6086); + + func_80093D18(globalCtx->state.gfxCtx); + + for (i = 0; i < 1; i++) { + if (effect->type == 1) { + Vec3f spA0; + f32 temp_f0; + f32 angle; + + func_80093D84(globalCtx->state.gfxCtx); + spA0.x = globalCtx->envCtx.dirLight1.params.dir.x; + spA0.y = globalCtx->envCtx.dirLight1.params.dir.y; + spA0.z = globalCtx->envCtx.dirLight1.params.dir.z; + func_8002EABC(&effect->position, &globalCtx->view.eye, &spA0, globalCtx->state.gfxCtx); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); + Matrix_RotateY(effect->unk_38.z, MTXMODE_APPLY); + Matrix_RotateX(effect->unk_38.y, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6116), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TexScroll(globalCtx->state.gfxCtx, 0, 0 - (globalCtx->gameplayFrames & 0x7F), 32, 32)); + gSPDisplayList(POLY_OPA_DISP++, ovl_Boss_Ganon2_DL_0103A8); + if ((globalCtx->envCtx.unk_BD == 1) || (globalCtx->envCtx.unk_BD == 2)) { + alpha = (s16)(globalCtx->envCtx.unk_D8 * 150.0f) + 50; + angle = M_PI / 5.0f; + } else { + alpha = 100; + angle = M_PI / 2.0f; + } + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); + temp_f0 = effect->position.y - 1098.0f; + Matrix_Translate(effect->position.x + temp_f0, 1086.0f, (effect->position.z - 1.0f) + temp_f0, MTXMODE_NEW); + Matrix_RotateY(angle, MTXMODE_APPLY); + Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6155), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00F188); + } + } + + effect = effects; + + for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + if (effect->type == 2) { + if (!usingObjectGEff) { + BossGanon2_SetObjectSegment(NULL, globalCtx, OBJECT_GEFF, true); + usingObjectGEff++; + } + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + Matrix_RotateY(effect->unk_38.z, MTXMODE_APPLY); + Matrix_RotateX(effect->unk_38.y, MTXMODE_APPLY); + Matrix_RotateZ(effect->unk_38.x, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6179), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGanonRubbleDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6185); +} + +void func_80906538(BossGanon2* pthis, u8* shadowTexture, f32 arg2) { + s16 temp_t0; + s16 temp_v0; + s16 temp_a3; + s16 phi_v1; + s16 phi_a1; + s16 i; + f32 lerpx; + s16 j; + f32 lerpy; + f32 lerpz; + Vec3f sp70; + Vec3f sp64; + + for (i = 0; i < 15; i++) { + if ((arg2 == 0.0f) || ((j = D_809071CC[i]) >= 0)) { + if (arg2 > 0.0f) { + lerpx = pthis->unk_234[i].x + (pthis->unk_234[j].x - pthis->unk_234[i].x) * arg2; + lerpy = pthis->unk_234[i].y + (pthis->unk_234[j].y - pthis->unk_234[i].y) * arg2; + lerpz = pthis->unk_234[i].z + (pthis->unk_234[j].z - pthis->unk_234[i].z) * arg2; + + sp70.x = lerpx - pthis->actor.world.pos.x; + sp70.y = lerpy - pthis->actor.world.pos.y + 76.0f + 30.0f + 30.0f + 100.0f; + sp70.z = lerpz - pthis->actor.world.pos.z; + } else { + sp70.x = pthis->unk_234[i].x - pthis->actor.world.pos.x; + sp70.y = pthis->unk_234[i].y - pthis->actor.world.pos.y + 76.0f + 30.0f + 30.0f + 100.0f; + sp70.z = pthis->unk_234[i].z - pthis->actor.world.pos.z; + } + + Matrix_MultVec3f(&sp70, &sp64); + sp64.x *= 0.2f; + sp64.y *= 0.2f; + temp_a3 = sp64.x + 32.0f; + temp_t0 = (s16)sp64.y * 64; + + if (D_809071EC[i] == 2) { + for (j = 0, phi_a1 = -0x180; j < 12; j++, phi_a1 += 0x40) { + for (phi_v1 = -D_809071B4[j]; phi_v1 < D_809071B4[j]; phi_v1++) { + temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v0] = 0xFF; + } + } + } + } else if (D_809071EC[i] == 1) { + for (j = 0, phi_a1 = -0x100; j < 8; j++, phi_a1 += 0x40) { + for (phi_v1 = -D_809071A4[j]; phi_v1 < D_809071A4[j]; phi_v1++) { + temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v0] = 0xFF; + } + } + } + } else if (D_809071EC[i] == 0) { + for (j = 0, phi_a1 = -0xC0; j < 7; j++, phi_a1 += 0x40) { + for (phi_v1 = -D_80907194[j]; phi_v1 < D_80907194[j] - 1; phi_v1++) { + temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v0] = 0xFF; + } + } + } + } else { + for (j = 0, phi_a1 = -0x80; j < 6; j++, phi_a1 += 0x40) { + for (phi_v1 = -D_80907188[j]; phi_v1 < D_80907188[j] - 1; phi_v1++) { + temp_v0 = temp_a3 + phi_v1 + temp_t0 + phi_a1; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v0] = 0xFF; + } + } + } + } + } + } +} + +void BossGanon2_GenShadowTexture(void* shadowTexture, BossGanon2* pthis, GlobalContext* globalCtx) { + s16 i; + u32* p = (u32*)shadowTexture; + + for (i = 0; i < 1024; i++, p++) { + *p = 0; + } + + Matrix_RotateX(1.0f, MTXMODE_NEW); + + for (i = 0; i < 6; i++) { + func_80906538(pthis, (u8*)shadowTexture, i / 5.0f); + } +} + +void BossGanon2_DrawShadowTexture(void* shadowTexture, BossGanon2* pthis, GlobalContext* globalCtx) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 alpha; + + OPEN_DISPS(gfxCtx, "../z_boss_ganon2.c", 6430); + + func_80093D18(globalCtx->state.gfxCtx); + + if ((globalCtx->envCtx.unk_BD == 1) || (globalCtx->envCtx.unk_BD == 2)) { + alpha = (s16)(globalCtx->envCtx.unk_D8 * 180.0f) + 30; + } else { + alpha = 120; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.floorHeight, pthis->actor.world.pos.z - 20.0f, MTXMODE_NEW); + Matrix_Scale(1.65f, 1.0f, 1.65f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_ganon2.c", 6457), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_Boss_Ganon2_DL_00B3D0); + gDPLoadTextureBlock(POLY_OPA_DISP++, shadowTexture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_OPA_DISP++, ovl_Boss_Ganon2_DL_00B3F0); + + CLOSE_DISPS(gfxCtx, "../z_boss_ganon2.c", 6479); +} diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.cpp similarity index 99% rename from src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c rename to src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.cpp index 7f314eb3c..d6a1444aa 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.cpp @@ -330,7 +330,7 @@ static u8 D_809071EC[] = { 3, 2, 2, 1, 3, 3, 1, 3, 3, 1, 0, 3, 1, 0, 3 }; // padding static u32 D_809071FC[2] = { 0 }; -#include "overlays/ovl_Boss_Ganon2/ovl_Boss_Ganon2.c" +#include "overlays/ovl_Boss_Ganon2/ovl_Boss_Ganon2.cpp" static Vec3f D_8090EB20; diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c deleted file mode 100644 index 4ea9d0036..000000000 --- a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c +++ /dev/null @@ -1,1540 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GANONDROF_Z_BOSS_GANONDROF_C -#include "actor_common.h" -/* - * File: z_boss_ganondrof.c - * Overlay: ovl_Boss_Ganondrof - * Description: Phantom Ganon - */ - -#include "z_boss_ganondrof.h" -#include "objects/object_gnd/object_gnd.h" -#include "overlays/actors/ovl_En_fHG/z_en_fhg.h" -#include "overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.h" -#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -typedef enum { - /* 0 */ NOT_DEAD, - /* 1 */ DEATH_START, - /* 2 */ DEATH_THROES, - /* 3 */ DEATH_WARP, - /* 4 */ DEATH_SCREAM, - /* 5 */ DEATH_DISINTEGRATE, - /* 6 */ DEATH_FINISH -} BossGanondrofDeathState; - -typedef enum { - /* 0 */ THROW_NORMAL, - /* 1 */ THROW_SLOW -} BossGanondrofThrowAction; - -typedef enum { - /* 0 */ STUNNED_FALL, - /* 1 */ STUNNED_GROUND -} BossGanondrofStunnedAction; - -typedef enum { - /* 0 */ CHARGE_WINDUP, - /* 1 */ CHARGE_START, - /* 2 */ CHARGE_ATTACK, - /* 3 */ CHARGE_FINISH -} BossGanondrofChargeAction; - -typedef enum { - /* 0 */ DEATH_SPASM, - /* 1 */ DEATH_LIMP, - /* 2 */ DEATH_HUNCHED -} BossGanondrofDeathAction; - -void BossGanondrof_Init(Actor* thisx, GlobalContext* globalCtx); -void BossGanondrof_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossGanondrof_Update(Actor* thisx, GlobalContext* globalCtx); -void BossGanondrof_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BossGanondrof_SetupIntro(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Intro(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_SetupPaintings(BossGanondrof* this); -void BossGanondrof_Paintings(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_SetupNeutral(BossGanondrof* this, f32 arg1); -void BossGanondrof_Neutral(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_SetupThrow(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Throw(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_SetupBlock(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Block(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_SetupReturn(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Return(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_SetupCharge(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Charge(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Stunned(BossGanondrof* this, GlobalContext* globalCtx); -void BossGanondrof_Death(BossGanondrof* this, GlobalContext* globalCtx); - -const ActorInit Boss_Ganondrof_InitVars = { - ACTOR_BOSS_GANONDROF, - ACTORCAT_BOSS, - FLAGS, - OBJECT_GND, - sizeof(BossGanondrof), - (ActorFunc)BossGanondrof_Init, - (ActorFunc)BossGanondrof_Destroy, - (ActorFunc)BossGanondrof_Update, - (ActorFunc)BossGanondrof_Draw, -}; - -static ColliderCylinderInit sCylinderInitBody = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x10 }, - { 0xFFCFFFFE, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 30, 90, -50, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInitSpear = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x30 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 20, 30, -20, { 0, 0, 0 } }, -}; - -// clang-format off -static u8 sDecayMaskHigh[16 * 16] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1, - 1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1, - 1,0,1,1,1,0,0,0,0,1,1,1,1,1,0,1, - 1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,1, - 1,0,0,1,1,1,1,1,0,0,0,1,1,0,0,1, - 1,0,1,1,1,1,0,0,0,0,0,1,0,0,0,1, - 1,1,1,1,1,1,1,1,0,0,0,0,1,1,0,1, - 1,0,1,1,1,1,1,0,0,0,0,1,1,1,0,1, - 1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,1, - 1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1, - 1,0,0,0,1,1,0,0,0,1,1,1,1,1,1,1, - 1,0,0,1,1,1,1,0,1,1,1,1,1,1,1,1, - 1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,1, - 1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, -}; - -static u8 sDecayMaskLow[16 * 16] = { - 1,1,1,0,1,0,0,1,0,0,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0, - 1,0,1,1,0,0,0,0,0,1,1,0,0,1,0,0, - 1,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0, - 0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,1, - 0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1, - 1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0, - 1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, - 1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1, - 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1, - 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1, - 1,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0, - 1,0,0,0,0,1,0,0,0,0,1,0,1,1,0,0, - 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, - 1,0,0,0,1,0,1,0,0,0,1,1,0,0,0,1, - 1,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1, -}; - -static u8 sDecayMaskTotal[16 * 16] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, -}; -// clang-format on - -// These are Phantom Ganon's body textures, but I don't know which is which. -static void* sLimbTex_rgba16_8x8[] = { - gPhantomGanonLimbTex_00A800, gPhantomGanonLimbTex_00AE80, gPhantomGanonLimbTex_00AF00, - gPhantomGanonLimbTex_00C180, gPhantomGanonLimbTex_00C400, -}; -static void* sLimbTex_rgba16_16x8[] = { - gPhantomGanonLimbTex_00B980, gPhantomGanonLimbTex_00C480, gPhantomGanonLimbTex_00BC80, - gPhantomGanonLimbTex_00BD80, gPhantomGanonLimbTex_00C080, -}; -static void* sLimbTex_rgba16_16x16[] = { - gPhantomGanonLimbTex_00C200, gPhantomGanonLimbTex_00A000, gPhantomGanonLimbTex_00A200, - gPhantomGanonLimbTex_00A400, gPhantomGanonLimbTex_00A600, gPhantomGanonLimbTex_00A880, - gPhantomGanonLimbTex_00B780, gPhantomGanonLimbTex_00BA80, gPhantomGanonLimbTex_00BE80, -}; -static void* sLimbTex_rgba16_16x32[] = { gPhantomGanonLimbTex_00AA80, gPhantomGanonLimbTex_00AF80 }; - -static void* sMouthTex_ci8_16x16[] = { gPhantomGanonMouthTex, gPhantomGanonSmileTex }; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x2B, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -static Vec3f sAudioVec = { 0.0f, 0.0f, 50.0f }; - -void BossGanondrof_ClearPixels8x8(s16* texture, u8* mask, s16 index) { - if (mask[index]) { - texture[index / 4] = 0; - } -} - -void BossGanondrof_ClearPixels16x8(s16* texture, u8* mask, s16 index) { - if (mask[index]) { - texture[index / 2] = 0; - } -} - -void BossGanondrof_ClearPixels16x16(s16* texture, u8* mask, s16 index) { - if (mask[index]) { - texture[index] = 0; - } -} - -void BossGanondrof_ClearPixels32x16(s16* texture, u8* mask, s16 index) { - if (mask[index]) { - s16 i = (index & 0xF) + ((index & 0xF0) << 1); - - texture[i + 0x10] = 0; - texture[i] = 0; - } -} - -void BossGanondrof_ClearPixels16x32(s16* texture, u8* mask, s16 index) { - if (mask[index]) { - s16 i = ((index & 0xF) * 2) + ((index & 0xF0) * 2); - - texture[i + 1] = 0; - texture[i] = 0; - } -} - -void BossGanondrof_ClearPixels(u8* mask, s16 index) { - s16 i; - - for (i = 0; i < 5; i++) { - // ARRAY_COUNT can't be used here because the arrays aren't guaranteed to be the same size. - BossGanondrof_ClearPixels8x8(SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_8x8[i]), mask, index); - BossGanondrof_ClearPixels16x8(SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_16x8[i]), mask, index); - } - - for (i = 0; i < ARRAY_COUNT(sLimbTex_rgba16_16x16); i++) { - BossGanondrof_ClearPixels16x16(SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_16x16[i]), mask, index); - } - - for (i = 0; i < ARRAY_COUNT(sLimbTex_rgba16_16x32); i++) { - BossGanondrof_ClearPixels16x32(SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_16x32[i]), mask, index); - } - - BossGanondrof_ClearPixels32x16(SEGMENTED_TO_VIRTUAL(gPhantomGanonLimbTex_00B380), mask, index); - BossGanondrof_ClearPixels16x32(SEGMENTED_TO_VIRTUAL(gPhantomGanonEyeTex), mask, index); - for (i = 0; i < ARRAY_COUNT(sMouthTex_ci8_16x16); i++) { - BossGanondrof_ClearPixels16x16(SEGMENTED_TO_VIRTUAL(sMouthTex_ci8_16x16[i]), mask, index); - } -} - -void BossGanondrof_SetColliderPos(Vec3f* pos, ColliderCylinder* collider) { - collider->dim.pos.x = pos->x; - collider->dim.pos.y = pos->y; - collider->dim.pos.z = pos->z; -} - -void BossGanondrof_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossGanondrof* this = (BossGanondrof*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gPhantomGanonSkel, &gPhantomGanonRideAnim, NULL, NULL, 0); - if (this->actor.params < GND_FAKE_BOSS) { - this->actor.params = GND_REAL_BOSS; - this->actor.colChkInfo.health = 30; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, 255); - BossGanondrof_SetupIntro(this, globalCtx); - } else { - BossGanondrof_SetupPaintings(this); - } - - Collider_InitCylinder(globalCtx, &this->colliderBody); - Collider_InitCylinder(globalCtx, &this->colliderSpear); - Collider_SetCylinder(globalCtx, &this->colliderBody, &this->actor, &sCylinderInitBody); - Collider_SetCylinder(globalCtx, &this->colliderSpear, &this->actor, &sCylinderInitSpear); - this->actor.flags &= ~ACTOR_FLAG_0; - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { - Actor_Kill(&this->actor); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y, - GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 200.0f + GND_BOSSROOM_CENTER_X, - GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, 0); - } else { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, this->actor.params); - } -} - -void BossGanondrof_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossGanondrof* this = (BossGanondrof*)thisx; - - osSyncPrintf("DT1\n"); - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->colliderBody); - Collider_DestroyCylinder(globalCtx, &this->colliderSpear); - if (this->actor.params == GND_REAL_BOSS) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - } - - osSyncPrintf("DT2\n"); -} - -void BossGanondrof_SetupIntro(BossGanondrof* this, GlobalContext* globalCtx) { - Animation_PlayLoop(&this->skelAnime, &gPhantomGanonRidePoseAnim); - this->actionFunc = BossGanondrof_Intro; - this->work[GND_MASK_OFF] = true; -} - -void BossGanondrof_Intro(BossGanondrof* this, GlobalContext* globalCtx) { - s16 i; - s32 pad; - EnfHG* horse = (EnfHG*)this->actor.child; - - SkelAnime_Update(&this->skelAnime); - this->actor.world.pos = horse->actor.world.pos; - this->actor.shape.rot.y = this->actor.world.rot.y = horse->actor.world.rot.y; - - osSyncPrintf("SW %d------------------------------------------------\n", horse->bossGndSignal); - - if ((this->timers[1] != 0) && (this->timers[1] < 25)) { - Vec3f pos; - Vec3f vel = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - - pos.x = this->bodyPartsPos[14].x + Rand_CenteredFloat(10.0f); - pos.y = this->bodyPartsPos[14].y + Rand_ZeroFloat(-5.0f); - pos.z = this->bodyPartsPos[14].z + Rand_CenteredFloat(10.0f) + 5.0f; - accel.y = 0.03f; - EffectSsKFire_Spawn(globalCtx, &pos, &vel, &accel, (s16)Rand_ZeroFloat(10.0f) + 5, 0); - } - - if (this->timers[1] == 20) { - this->work[GND_MASK_OFF] = false; - } - - if (this->timers[1] == 30) { - func_80078914(&sAudioVec, NA_SE_EN_FANTOM_TRANSFORM); - } - - if (horse->bossGndSignal == FHG_LIGHTNING) { - Animation_Change(&this->skelAnime, &gPhantomGanonMaskOnAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gPhantomGanonMaskOnAnim), ANIMMODE_ONCE_INTERP, 0.0f); - this->timers[1] = 40; - } - - if (horse->bossGndSignal == FHG_REAR) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonHorseRearingAnim, -3.0f); - } - - if (horse->bossGndSignal == FHG_RIDE) { - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonRidePoseAnim, -13.0f); - } - - if (horse->bossGndSignal == FHG_SPUR) { - EnfHG* horseTemp; - - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonRideSpearRaiseAnim, -7.0f); - horseTemp = (EnfHG*)this->actor.child; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, this->spearTip.x, - this->spearTip.y, this->spearTip.z, 50, FHGFIRE_LIGHT_GREEN, 0, FHGFIRE_SPEAR_LIGHT); - this->actor.child = &horseTemp->actor; - } - - if (horse->bossGndSignal == FHG_FINISH) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonRideSpearResetAnim, -5.0f); - } - - switch (this->work[GND_EYE_STATE]) { - case GND_EYESTATE_FADE: - this->fwork[GND_EYE_ALPHA] += 40.0f; - if (this->fwork[GND_EYE_ALPHA] >= 255.0f) { - this->fwork[GND_EYE_ALPHA] = 255.0f; - } - break; - - case GND_EYESTATE_BRIGHTEN: - this->fwork[GND_EYE_BRIGHTNESS] += 20.0f; - if (this->fwork[GND_EYE_BRIGHTNESS] > 255.0f) { - this->fwork[GND_EYE_BRIGHTNESS] = 255.0f; - } - break; - } - - this->armRotY = Math_SinS(this->work[GND_VARIANCE_TIMER] * 0x6E8) * 0; - this->armRotZ = Math_CosS(this->work[GND_VARIANCE_TIMER] * 0x8DC) * 300.0f; - for (i = 0; i < 30; i++) { - this->rideRotY[i] = Math_SinS(this->work[GND_VARIANCE_TIMER] * ((i * 50) + 0x7B0)) * 100.0f; - this->rideRotZ[i] = Math_CosS(this->work[GND_VARIANCE_TIMER] * ((i * 50) + 0x8DC)) * 100.0f; - } - - if (horse->bossGndSignal == FHG_START_FIGHT) { - BossGanondrof_SetupPaintings(this); - for (i = 0; i < 30; i++) { - this->rideRotY[i] = this->rideRotZ[i] = 0.0f; - } - } - - horse->bossGndSignal = FHG_NO_SIGNAL; -} - -void BossGanondrof_SetupPaintings(BossGanondrof* this) { - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonRideAnim, -5.0f); - this->actionFunc = BossGanondrof_Paintings; -} - -void BossGanondrof_Paintings(BossGanondrof* this, GlobalContext* globalCtx) { - EnfHG* horse = (EnfHG*)this->actor.child; - - osSyncPrintf("RUN 1\n"); - SkelAnime_Update(&this->skelAnime); - osSyncPrintf("RUN 2\n"); - - if (horse->bossGndSignal == FHG_RAISE_SPEAR) { - EnfHG* horseTemp; - - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonRideSpearRaiseAnim, -2.0f); - this->actor.flags |= ACTOR_FLAG_0; - horseTemp = (EnfHG*)this->actor.child; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, this->spearTip.x, - this->spearTip.y, this->spearTip.z, 30, FHGFIRE_LIGHT_GREEN, 0, FHGFIRE_SPEAR_LIGHT); - this->actor.child = &horseTemp->actor; - } else if (horse->bossGndSignal == FHG_LIGHTNING) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonRideSpearStrikeAnim, -2.0f); - } else if (horse->bossGndSignal == FHG_RESET) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonRideSpearResetAnim, -2.0f); - } else if (horse->bossGndSignal == FHG_RIDE) { - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonRideAnim, -2.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - } - - osSyncPrintf("RUN 3\n"); - this->actor.world.pos = horse->actor.world.pos; - this->actor.world.pos.y = horse->actor.world.pos.y; - this->actor.shape.rot.y = this->actor.world.rot.y = horse->actor.world.rot.y; - if (this->flyMode != GND_FLY_PAINTING) { - BossGanondrof_SetupNeutral(this, -20.0f); - this->timers[0] = 100; - this->colliderBody.dim.radius = 20; - this->colliderBody.dim.height = 60; - this->colliderBody.dim.yShift = -33; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_LAUGH); - this->actor.naviEnemyId = 0x1A; - } else { - horse->bossGndSignal = FHG_NO_SIGNAL; - this->actor.scale.x = horse->actor.scale.x / 1.15f; - this->actor.scale.y = horse->actor.scale.y / 1.15f; - this->actor.scale.z = horse->actor.scale.z / 1.15f; - osSyncPrintf("RUN 4\n"); - } -} - -void BossGanondrof_SetupNeutral(BossGanondrof* this, f32 arg1) { - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonNeutralAnim, arg1); - this->actionFunc = BossGanondrof_Neutral; - this->actor.flags |= ACTOR_FLAG_0; - this->fwork[GND_FLOAT_SPEED] = 0.0f; - this->timers[0] = (s16)(Rand_ZeroOne() * 64.0f) + 30; -} - -void BossGanondrof_Neutral(BossGanondrof* this, GlobalContext* globalCtx) { - f32 targetX; - f32 targetY; - f32 targetZ; - Player* player = GET_PLAYER(globalCtx); - Actor* playerx = &player->actor; - Actor* thisx = &this->actor; - f32 rand01; - s16 i; - - SkelAnime_Update(&this->skelAnime); - switch (this->flyMode) { - case GND_FLY_NEUTRAL: - if (this->timers[0] == 0) { - this->timers[0] = (s16)(Rand_ZeroOne() * 64.0f) + 30; - rand01 = Rand_ZeroOne(); - if (thisx->colChkInfo.health < 5) { - if (rand01 < 0.25f) { - BossGanondrof_SetupThrow(this, globalCtx); - } else if (rand01 >= 0.8f) { - this->flyMode = GND_FLY_CHARGE; - this->timers[0] = 60; - this->fwork[GND_FLOAT_SPEED] = 0.0f; - Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_LAUGH); - } else { - this->flyMode = GND_FLY_VOLLEY; - this->timers[0] = 60; - this->fwork[GND_FLOAT_SPEED] = 0.0f; - Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_LAUGH); - } - } else if ((rand01 < 0.5f) || (this->work[GND_THROW_COUNT] < 5)) { - BossGanondrof_SetupThrow(this, globalCtx); - } else { - this->flyMode = GND_FLY_VOLLEY; - this->timers[0] = 60; - this->fwork[GND_FLOAT_SPEED] = 0.0f; - Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_LAUGH); - } - } - - if (this->timers[1] != 0) { - targetX = GND_BOSSROOM_CENTER_X; - targetZ = GND_BOSSROOM_CENTER_Z; - } else { - targetX = playerx->world.pos.x + (180.0f * Math_SinS(playerx->shape.rot.y)); - targetZ = playerx->world.pos.z + (180.0f * Math_CosS(playerx->shape.rot.y)); - if (sqrtf(SQ(targetX - GND_BOSSROOM_CENTER_X) + SQ(targetZ - GND_BOSSROOM_CENTER_Z)) > 280.0f) { - this->timers[1] = 50; - this->fwork[GND_FLOAT_SPEED] = 0.0f; - } - } - - targetY = playerx->world.pos.y + 100.0f + 0.0f; - targetX += Math_SinS(this->work[GND_VARIANCE_TIMER] * 0x500) * 100.0f; - targetZ += Math_CosS(this->work[GND_VARIANCE_TIMER] * 0x700) * 100.0f; - break; - case GND_FLY_VOLLEY: - targetX = GND_BOSSROOM_CENTER_X - 14.0f; - targetZ = GND_BOSSROOM_CENTER_Z + 265.0f; - - targetY = playerx->world.pos.y + 100.0f + 100.0f; - targetX += Math_SinS(this->work[GND_VARIANCE_TIMER] * 0x500) * 100.0f; - targetZ += Math_CosS(this->work[GND_VARIANCE_TIMER] * 0x700) * 100.0f; - if (this->timers[0] == 0) { - this->flyMode = GND_FLY_RETURN; - this->returnSuccess = false; - BossGanondrof_SetupThrow(this, globalCtx); - this->timers[0] = 80; - } - break; - case GND_FLY_RETURN: - targetX = GND_BOSSROOM_CENTER_X - 14.0f; - targetZ = GND_BOSSROOM_CENTER_Z + 265.0f; - - targetY = playerx->world.pos.y + 100.0f + 100.0f; - targetX += Math_SinS(this->work[GND_VARIANCE_TIMER] * 0x500) * 50.0f; - targetZ += Math_CosS(this->work[GND_VARIANCE_TIMER] * 0x700) * 50.0f; - if (this->returnSuccess) { - this->returnSuccess = false; - BossGanondrof_SetupReturn(this, globalCtx); - this->timers[0] = 80; - } - - if (this->timers[0] == 0) { - this->flyMode = GND_FLY_NEUTRAL; - } - break; - case GND_FLY_CHARGE: - targetX = GND_BOSSROOM_CENTER_X - 14.0f; - targetZ = GND_BOSSROOM_CENTER_Z + 215.0f; - - targetY = playerx->world.pos.y + 100.0f + 50.0f; - targetX += Math_SinS(this->work[GND_VARIANCE_TIMER] * 0x500) * 100.0f; - targetZ += Math_CosS(this->work[GND_VARIANCE_TIMER] * 0x700) * 100.0f; - if (this->timers[0] == 0) { - BossGanondrof_SetupCharge(this, globalCtx); - } - break; - } - - Math_ApproachF(&thisx->world.pos.x, targetX, 0.05f, this->fwork[GND_FLOAT_SPEED]); - if (this->timers[2] != 0) { - Math_ApproachF(&thisx->world.pos.y, targetY + 100.0f, 0.1f, 50.0f); - } else { - Math_ApproachF(&thisx->world.pos.y, targetY, 0.05f, 10.0f); - } - - Math_ApproachF(&thisx->world.pos.z, targetZ, 0.05f, this->fwork[GND_FLOAT_SPEED]); - Math_ApproachF(&this->fwork[GND_FLOAT_SPEED], 50.0f, 1.0f, 0.5f); - thisx->velocity.x = thisx->world.pos.x - thisx->prevPos.x; - thisx->velocity.z = thisx->world.pos.z - thisx->prevPos.z; - thisx->world.pos.y += 2.0f * Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); - Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0xBB8); - if ((this->work[GND_VARIANCE_TIMER] & 1) == 0) { - Vec3f pos; - Vec3f vel = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - - for (i = 0; i < 3; i++) { - pos.x = Rand_CenteredFloat(20.0f) + this->spearTip.x; - pos.y = Rand_CenteredFloat(20.0f) + this->spearTip.y; - pos.z = Rand_CenteredFloat(20.0f) + this->spearTip.z; - accel.y = -0.08f; - EffectSsFhgFlash_SpawnLightBall(globalCtx, &pos, &vel, &accel, (s16)(Rand_ZeroOne() * 80.0f) + 150, - FHGFLASH_LIGHTBALL_GREEN); - } - } - - if (player->unk_A73 != 0) { - BossGanondrof_SetupBlock(this, globalCtx); - } - - Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); -} - -void BossGanondrof_SetupThrow(BossGanondrof* this, GlobalContext* globalCtx) { - EnfHG* horseTemp; - s16 lightTime; - - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonThrowAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonThrowAnim, -5.0f); - this->actionFunc = BossGanondrof_Throw; - if ((Rand_ZeroOne() <= 0.1f) && (this->work[GND_THROW_COUNT] >= 10) && (this->flyMode == GND_FLY_NEUTRAL)) { - this->work[GND_ACTION_STATE] = THROW_SLOW; - this->work[GND_THROW_FRAME] = 1000; - lightTime = 32; - } else { - this->work[GND_ACTION_STATE] = THROW_NORMAL; - this->work[GND_THROW_FRAME] = 25; - lightTime = 25; - } - - horseTemp = (EnfHG*)this->actor.child; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, this->spearTip.x, - this->spearTip.y, this->spearTip.z, lightTime, FHGFIRE_LIGHT_GREEN, 0, FHGFIRE_SPEAR_LIGHT); - this->actor.child = &horseTemp->actor; - this->work[GND_THROW_COUNT]++; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_STICK); -} - -void BossGanondrof_Throw(BossGanondrof* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - osSyncPrintf("this->fwork[GND_END_FRAME] = %d\n", (s16)this->fwork[GND_END_FRAME]); - osSyncPrintf("this->work[GND_SHOT_FRAME] = %d\n", this->work[GND_THROW_FRAME]); - if (Animation_OnFrame(&this->skelAnime, this->fwork[GND_END_FRAME])) { - BossGanondrof_SetupNeutral(this, -6.0f); - } - - if ((this->work[GND_ACTION_STATE] != THROW_NORMAL) && Animation_OnFrame(&this->skelAnime, 21.0f)) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonThrowEndAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonThrowEndAnim, 0.0f); - this->work[GND_THROW_FRAME] = 10; - } - - if (Animation_OnFrame(&this->skelAnime, this->work[GND_THROW_FRAME])) { - if (this->flyMode <= GND_FLY_NEUTRAL) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_MASIC2); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_MASIC1); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_VOICE); - } - - if (Animation_OnFrame(&this->skelAnime, this->work[GND_THROW_FRAME])) { - EnfHG* horseTemp = (EnfHG*)this->actor.child; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, this->spearTip.x, - this->spearTip.y, this->spearTip.z, this->work[GND_ACTION_STATE], 0, 0, FHGFIRE_ENERGY_BALL); - this->actor.child = &horseTemp->actor; - } - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x7D0); - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; - Math_ApproachZeroF(&this->actor.velocity.x, 1.0f, 0.5f); - Math_ApproachZeroF(&this->actor.velocity.z, 1.0f, 0.5f); - this->actor.world.pos.y += 2.0f * Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); -} - -void BossGanondrof_SetupReturn(BossGanondrof* this, GlobalContext* globalCtx) { - static AnimationHeader* returnAnim[] = { &gPhantomGanonReturn1Anim, &gPhantomGanonReturn2Anim }; - s16 rand = Rand_ZeroOne() * 1.99f; - - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(returnAnim[rand]); - Animation_MorphToPlayOnce(&this->skelAnime, returnAnim[rand], 0.0f); - this->actionFunc = BossGanondrof_Return; -} - -void BossGanondrof_Return(BossGanondrof* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_VOICE); - osSyncPrintf("VOISE 2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - osSyncPrintf("VOISE 2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - } - - if (Animation_OnFrame(&this->skelAnime, this->fwork[GND_END_FRAME])) { - BossGanondrof_SetupNeutral(this, 0.0f); - } - - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; - Math_ApproachZeroF(&this->actor.velocity.x, 1.0f, 0.5f); - Math_ApproachZeroF(&this->actor.velocity.z, 1.0f, 0.5f); - this->actor.world.pos.y += 2.0f * Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); - if (this->returnSuccess) { - this->returnSuccess = false; - BossGanondrof_SetupReturn(this, globalCtx); - this->timers[0] = 80; - } -} - -void BossGanondrof_SetupStunned(BossGanondrof* this, GlobalContext* globalCtx) { - if (this->actionFunc != BossGanondrof_Stunned) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonAirDamageAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonAirDamageAnim, 0.0f); - this->timers[0] = 50; - this->shockTimer = 60; - } else { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonGroundDamageAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonGroundDamageAnim, 0.0f); - } - - this->actionFunc = BossGanondrof_Stunned; - this->work[GND_ACTION_STATE] = STUNNED_FALL; - this->actor.velocity.x = 0.0f; - this->actor.velocity.z = 0.0f; -} - -void BossGanondrof_Stunned(BossGanondrof* this, GlobalContext* globalCtx) { - osSyncPrintf("DAMAGE .................................\n"); - SkelAnime_Update(&this->skelAnime); - this->actor.gravity = -0.2f; - if (this->actor.world.pos.y <= 5.0f) { - if (this->work[GND_ACTION_STATE] == STUNNED_FALL) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonStunnedAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonStunnedAnim, -10.0f); - this->work[GND_ACTION_STATE] = STUNNED_GROUND; - } - - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - if (Animation_OnFrame(&this->skelAnime, this->fwork[GND_END_FRAME])) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_DAMAGE2); - } - - this->actor.flags |= ACTOR_FLAG_10; - } - - osSyncPrintf("TIME0 %d ********************************************\n", this->timers[0]); - if (this->timers[0] == 0) { - BossGanondrof_SetupNeutral(this, -5.0f); - this->timers[0] = 30; - this->timers[2] = 30; - this->flyMode = GND_FLY_NEUTRAL; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - } - - Actor_MoveForward(&this->actor); -} - -void BossGanondrof_SetupBlock(BossGanondrof* this, GlobalContext* globalCtx) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonBlockAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonBlockAnim, -3.0f); - this->actionFunc = BossGanondrof_Block; - this->timers[0] = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_STICK); -} - -void BossGanondrof_Block(BossGanondrof* this, GlobalContext* globalCtx) { - this->colliderBody.base.colType = COLTYPE_METAL; - SkelAnime_Update(&this->skelAnime); - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; - Math_ApproachZeroF(&this->actor.velocity.x, 1.0f, 0.5f); - Math_ApproachZeroF(&this->actor.velocity.z, 1.0f, 0.5f); - this->actor.world.pos.y += 2.0f * Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); - if (this->timers[0] == 0) { - BossGanondrof_SetupNeutral(this, -5.0f); - this->timers[0] = 10; - this->flyMode = GND_FLY_NEUTRAL; - } -} - -void BossGanondrof_SetupCharge(BossGanondrof* this, GlobalContext* globalCtx) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonChargeWindupAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonChargeWindupAnim, -3.0f); - this->actionFunc = BossGanondrof_Charge; - this->timers[0] = 20; - this->work[GND_ACTION_STATE] = CHARGE_WINDUP; -} - -void BossGanondrof_Charge(BossGanondrof* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Actor* playerx = &player->actor; - Actor* thisx = &this->actor; - f32 dxCenter = thisx->world.pos.x - GND_BOSSROOM_CENTER_X; - f32 dzCenter = thisx->world.pos.z - GND_BOSSROOM_CENTER_Z; - - this->colliderBody.base.colType = COLTYPE_METAL; - SkelAnime_Update(&this->skelAnime); - switch (this->work[GND_ACTION_STATE]) { - case CHARGE_WINDUP: - if (this->timers[0] == 218) { - Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_STICK); - } - - if (this->timers[0] == 19) { - Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_ATTACK); - } - - thisx->world.pos.x += thisx->velocity.x; - thisx->world.pos.z += thisx->velocity.z; - Math_ApproachZeroF(&thisx->velocity.x, 1.0f, 0.5f); - Math_ApproachZeroF(&thisx->velocity.z, 1.0f, 0.5f); - if (this->timers[0] == 0) { - this->work[GND_ACTION_STATE] = CHARGE_START; - this->timers[0] = 10; - thisx->speedXZ = 0.0f; - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonChargeStartAnim); - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonChargeStartAnim, 0.0f); - } - - Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0x7D0); - break; - case CHARGE_START: - if (Animation_OnFrame(&this->skelAnime, this->fwork[GND_END_FRAME])) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonChargeAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonChargeAnim, 0.0f); - this->work[GND_ACTION_STATE] = CHARGE_ATTACK; - } - case CHARGE_ATTACK: - if (this->timers[0] != 0) { - Vec3f vecToLink; - - Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0x7D0); - vecToLink.x = playerx->world.pos.x - thisx->world.pos.x; - vecToLink.y = playerx->world.pos.y + 40.0f - thisx->world.pos.y; - vecToLink.z = playerx->world.pos.z - thisx->world.pos.z; - thisx->world.rot.y = thisx->shape.rot.y; - thisx->world.rot.x = - Math_FAtan2F(vecToLink.y, sqrtf(SQ(vecToLink.x) + SQ(vecToLink.z))) * (0x8000 / M_PI); - } - - func_8002D908(thisx); - func_8002D7EC(thisx); - Math_ApproachF(&thisx->speedXZ, 10.0f, 1.0f, 0.5f); - if ((sqrtf(SQ(dxCenter) + SQ(dzCenter)) > 280.0f) || (thisx->xyzDistToPlayerSq < SQ(100.0f))) { - this->work[GND_ACTION_STATE] = CHARGE_FINISH; - this->timers[0] = 20; - } - break; - case CHARGE_FINISH: - thisx->gravity = 0.2f; - Actor_MoveForward(thisx); - osSyncPrintf("YP %f @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n", thisx->world.pos.y); - if (thisx->world.pos.y < 5.0f) { - thisx->world.pos.y = 5.0f; - thisx->velocity.y = 0.0f; - } - - if (sqrtf(SQ(dxCenter) + SQ(dzCenter)) > 280.0f) { - Math_ApproachZeroF(&thisx->speedXZ, 1.0f, 2.0f); - this->timers[0] = 0; - } - - if (this->timers[0] == 0) { - Math_ApproachZeroF(&thisx->speedXZ, 1.0f, 2.0f); - Math_ApproachZeroF(&thisx->velocity.y, 1.0f, 2.0f); - Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0x7D0); - if ((thisx->speedXZ <= 0.5f) && (fabsf(thisx->velocity.y) <= 0.1f)) { - BossGanondrof_SetupNeutral(this, -10.0f); - this->timers[0] = 30; - this->flyMode = GND_FLY_NEUTRAL; - } - } - break; - } - - if (thisx->world.pos.y > (GND_BOSSROOM_CENTER_Y + 83.0f)) { - thisx->world.pos.y += 2.0f * Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); - } - { - s16 i; - Vec3f pos; - Vec3f vel = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f baseOffset = { 0.0f, 50.0f, 0.0f }; - Vec3f offset; - - baseOffset.y = 10.0f; - for (i = 0; i < 10; i++) { - Matrix_Push(); - Matrix_RotateY((thisx->shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); - Matrix_RotateX((thisx->shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateZ((this->work[GND_PARTICLE_ANGLE] / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_MultVec3f(&baseOffset, &offset); - Matrix_Pop(); - pos.x = this->spearTip.x + offset.x; - pos.y = this->spearTip.y + offset.y; - pos.z = this->spearTip.z + offset.z; - vel.x = (offset.x * 500.0f) / 1000.0f; - vel.y = (offset.y * 500.0f) / 1000.0f; - vel.z = (offset.z * 500.0f) / 1000.0f; - accel.x = (offset.x * -50.0f) / 1000.0f; - accel.y = (offset.y * -50.0f) / 1000.0f; - accel.z = (offset.z * -50.0f) / 1000.0f; - EffectSsFhgFlash_SpawnLightBall(globalCtx, &pos, &vel, &accel, 150, i % 7); - this->work[GND_PARTICLE_ANGLE] += 0x1A5C; - } - } - - if (!(this->work[GND_VARIANCE_TIMER] & 7)) { - EnfHG* horse = (EnfHG*)thisx->child; - - Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_FHG_FIRE, this->spearTip.x, - this->spearTip.y, this->spearTip.z, 8, FHGFIRE_LIGHT_BLUE, 0, FHGFIRE_SPEAR_LIGHT); - thisx->child = &horse->actor; - } -} - -void BossGanondrof_SetupDeath(BossGanondrof* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gPhantomGanonDeathBlowAnim); - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonDeathBlowAnim); - this->actionFunc = BossGanondrof_Death; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_DEAD); - this->deathState = DEATH_START; - this->actor.flags &= ~ACTOR_FLAG_0; - this->work[GND_VARIANCE_TIMER] = 0; - this->shockTimer = 50; -} - -void BossGanondrof_Death(BossGanondrof* this, GlobalContext* globalCtx) { - u8 holdCamera = false; - u8 bodyDecayLevel = 0; - f32 camX; - f32 camZ; - f32 pad; - Player* player = GET_PLAYER(globalCtx); - Camera* camera = Gameplay_GetCamera(globalCtx, 0); - - osSyncPrintf("PYP %f\n", player->actor.floorHeight); - SkelAnime_Update(&this->skelAnime); - this->work[GND_DEATH_SFX_TIMER]++; - if (((60 < this->work[GND_DEATH_SFX_TIMER]) && (this->work[GND_DEATH_SFX_TIMER] < 500)) || - ((501 < this->work[GND_DEATH_SFX_TIMER]) && (this->work[GND_DEATH_SFX_TIMER] < 620))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_LAST - SFX_FLAG); - } - - switch (this->deathState) { - case DEATH_START: - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 1); - this->deathCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - osSyncPrintf("7\n"); - Gameplay_ChangeCameraStatus(globalCtx, this->deathCamera, CAM_STAT_ACTIVE); - osSyncPrintf("8\n"); - this->deathState = DEATH_THROES; - player->actor.speedXZ = 0.0f; - this->timers[0] = 50; - this->cameraEye = camera->eye; - this->cameraAt = camera->at; - this->cameraNextEye.x = this->targetPos.x; - this->cameraNextEye.y = GND_BOSSROOM_CENTER_Y + 83.0f; - this->cameraNextEye.z = (this->targetPos.z + 100.0f) + 50; - this->cameraNextAt.x = this->targetPos.x; - this->cameraNextAt.y = this->targetPos.y - 10.0f; - this->cameraNextAt.z = this->targetPos.z; - this->cameraEyeVel.x = fabsf(camera->eye.x - this->cameraNextEye.x); - this->cameraEyeVel.y = fabsf(camera->eye.y - this->cameraNextEye.y); - this->cameraEyeVel.z = fabsf(camera->eye.z - this->cameraNextEye.z); - this->cameraAtVel.x = fabsf(camera->at.x - this->cameraNextAt.x); - this->cameraAtVel.y = fabsf(camera->at.y - this->cameraNextAt.y); - this->cameraAtVel.z = fabsf(camera->at.z - this->cameraNextAt.z); - this->cameraAccel = 0.02f; - this->cameraEyeMaxVel.x = this->cameraEyeMaxVel.y = this->cameraEyeMaxVel.z = 0.05f; - this->work[GND_ACTION_STATE] = DEATH_SPASM; - this->timers[0] = 150; - this->cameraAtMaxVel.x = 0.2f; - this->cameraAtMaxVel.y = 0.2f; - this->cameraAtMaxVel.z = 0.2f; - case DEATH_THROES: - switch (this->work[GND_ACTION_STATE]) { - case DEATH_SPASM: - if (Animation_OnFrame(&this->skelAnime, this->fwork[GND_END_FRAME])) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonAirDamageAnim); - Animation_Change(&this->skelAnime, &gPhantomGanonAirDamageAnim, 0.5f, 0.0f, - this->fwork[GND_END_FRAME], ANIMMODE_ONCE_INTERP, 0.0f); - this->work[GND_ACTION_STATE] = DEATH_LIMP; - } - break; - case DEATH_LIMP: - if (Animation_OnFrame(&this->skelAnime, this->fwork[GND_END_FRAME])) { - this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonLimpAnim); - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonLimpAnim, -20.0f); - this->work[GND_ACTION_STATE] = DEATH_HUNCHED; - } - case DEATH_HUNCHED: - bodyDecayLevel = 1; - break; - } - Math_ApproachS(&this->actor.shape.rot.y, this->work[GND_VARIANCE_TIMER] * -100, 5, 0xBB8); - Math_ApproachF(&this->cameraNextEye.z, this->targetPos.z + 60.0f, 0.02f, 0.5f); - Math_ApproachF(&this->actor.world.pos.y, GND_BOSSROOM_CENTER_Y + 133.0f, 0.05f, 100.0f); - this->actor.world.pos.y += Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); - this->cameraNextAt.x = this->targetPos.x; - this->cameraNextAt.y = this->targetPos.y - 10.0f; - this->cameraNextAt.z = this->targetPos.z; - if (this->timers[0] == 0) { - this->deathState = DEATH_WARP; - this->timers[0] = 350; - this->timers[1] = 50; - this->fwork[GND_CAMERA_ZOOM] = 300.0f; - this->cameraNextEye.y = GND_BOSSROOM_CENTER_Y + 233.0f; - player->actor.world.pos.x = GND_BOSSROOM_CENTER_X - 200.0f; - player->actor.world.pos.z = GND_BOSSROOM_CENTER_Z; - holdCamera = true; - bodyDecayLevel = 1; - } - break; - case DEATH_WARP: - if (this->timers[1] == 1) { - EnfHG* horseTemp = (EnfHG*)this->actor.child; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y + 3.0f, GND_BOSSROOM_CENTER_Z, 0x4000, - 0, 0, FHGFIRE_WARP_DEATH); - this->actor.child = &horseTemp->actor; - Message_StartTextbox(globalCtx, 0x108E, NULL); - } - - this->actor.shape.rot.y -= 0xC8; - this->actor.world.pos.y += Math_SinS(this->work[GND_VARIANCE_TIMER] * 1500); - this->fwork[GND_CAMERA_ANGLE] += 0x78; - camX = Math_SinS(this->fwork[GND_CAMERA_ANGLE]) * this->fwork[GND_CAMERA_ZOOM]; - camZ = Math_CosS(this->fwork[GND_CAMERA_ANGLE]) * this->fwork[GND_CAMERA_ZOOM]; - this->cameraEye.x = GND_BOSSROOM_CENTER_X + camX; - this->cameraEye.y = this->cameraNextEye.y; - this->cameraEye.z = GND_BOSSROOM_CENTER_Z + camZ; - this->cameraAt.x = GND_BOSSROOM_CENTER_X; - this->cameraAt.y = GND_BOSSROOM_CENTER_Y + 23.0f; - this->cameraAt.z = GND_BOSSROOM_CENTER_Z; - Math_ApproachF(&this->cameraNextEye.y, GND_BOSSROOM_CENTER_Y + 33.0f, 0.05f, 0.5f); - Math_ApproachF(&this->fwork[GND_CAMERA_ZOOM], 170.0f, 0.05f, 1.0f); - Math_ApproachF(&this->actor.world.pos.x, GND_BOSSROOM_CENTER_X, 0.05f, 1.5f); - Math_ApproachF(&this->actor.world.pos.y, GND_BOSSROOM_CENTER_Y + 83.0f, 0.05f, 1.0f); - Math_ApproachF(&this->actor.world.pos.z, GND_BOSSROOM_CENTER_Z, 0.05f, 1.5f); - if (this->timers[0] == 0) { - this->deathState = DEATH_SCREAM; - this->timers[0] = 50; - Animation_MorphToLoop(&this->skelAnime, &gPhantomGanonScreamAnim, -10.0f); - this->actor.world.pos.x = GND_BOSSROOM_CENTER_X; - this->actor.world.pos.y = GND_BOSSROOM_CENTER_Y + 83.0f; - this->actor.world.pos.z = GND_BOSSROOM_CENTER_Z; - this->actor.shape.rot.y = 0; - this->work[GND_BODY_DECAY_INDEX] = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_LAST); - } - - holdCamera = true; - bodyDecayLevel = 1; - break; - case DEATH_SCREAM: - holdCamera = true; - bodyDecayLevel = 2; - this->actor.world.pos.y = GND_BOSSROOM_CENTER_Y + 83.0f; - this->cameraEye.x = GND_BOSSROOM_CENTER_X; - this->cameraEye.y = GND_BOSSROOM_CENTER_Y + 83.0f; - this->cameraEye.z = GND_BOSSROOM_CENTER_Z + 50.0f; - this->cameraAt.x = GND_BOSSROOM_CENTER_X; - this->cameraAt.y = GND_BOSSROOM_CENTER_Y + 103.0f; - this->cameraAt.z = GND_BOSSROOM_CENTER_Z; - if (this->timers[0] == 0) { - this->deathState = DEATH_DISINTEGRATE; - Animation_MorphToPlayOnce(&this->skelAnime, &gPhantomGanonLastPoseAnim, -10.0f); - this->work[GND_BODY_DECAY_INDEX] = 0; - this->timers[0] = 40; - } - break; - case DEATH_DISINTEGRATE: - holdCamera = true; - bodyDecayLevel = 3; - Math_ApproachZeroF(&this->cameraEye.y, 0.05f, 1.0f); // approaches GND_BOSSROOM_CENTER_Y + 33.0f - Math_ApproachF(&this->cameraEye.z, GND_BOSSROOM_CENTER_Z + 170.0f, 0.05f, 2.0f); - Math_ApproachF(&this->cameraAt.y, GND_BOSSROOM_CENTER_Y + 53.0f, 0.05f, 1.0f); - if (this->timers[0] == 0) { - this->timers[0] = 250; - this->deathState = DEATH_FINISH; - } - break; - case DEATH_FINISH: - holdCamera = true; - bodyDecayLevel = 10; - if (this->timers[0] == 150) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, - GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); - } - - Math_ApproachZeroF(&this->cameraEye.y, 0.05f, 1.0f); // GND_BOSSROOM_CENTER_Y + 33.0f - Math_ApproachF(&this->cameraEye.z, GND_BOSSROOM_CENTER_Z + 170.0f, 0.05f, 2.0f); - Math_ApproachF(&this->cameraAt.y, GND_BOSSROOM_CENTER_Y + 53.0f, 0.05f, 1.0f); - if (this->timers[0] == 0) { - EnfHG* horse = (EnfHG*)this->actor.child; - - camera->eye = this->cameraEye; - camera->eyeNext = this->cameraEye; - camera->at = this->cameraAt; - func_800C08AC(globalCtx, this->deathCamera, 0); - this->deathCamera = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, GND_BOSSROOM_CENTER_X, - GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z + 200.0f, 0, 0, 0, 0); - this->actor.child = &horse->actor; - this->killActor = true; - horse->killActor = true; - Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); - Flags_SetSwitch(globalCtx, 0x22); - } - break; - } - - if (bodyDecayLevel) { - Vec3f pos; - Vec3f vel = { 0.0f, 0.0f, 0.0f }; - Vec3f accelKFire = { 0.0f, 0.0f, 0.0f }; - Vec3f accelHahen = { 0.0f, -0.5f, 0.0f }; - s16 limbDecayIndex; - s16 i; - - vel.x = this->actor.world.pos.x - this->actor.prevPos.x; - vel.z = this->actor.world.pos.z - this->actor.prevPos.z; - if (bodyDecayLevel < 10) { - if (this->work[GND_DEATH_ENV_TIMER] == 0) { - if (globalCtx->envCtx.unk_BF == 0) { - globalCtx->envCtx.unk_BF = 3; - this->work[GND_DEATH_ENV_TIMER] = (s16)Rand_ZeroFloat(5.0f) + 4.0f; - globalCtx->envCtx.unk_D6 = 0x28; - } else { - globalCtx->envCtx.unk_BF = 0; - this->work[GND_DEATH_ENV_TIMER] = (s16)Rand_ZeroFloat(2.0f) + 2.0f; - globalCtx->envCtx.unk_D6 = 0x14; - } - } else { - this->work[GND_DEATH_ENV_TIMER]--; - } - - for (i = 0; i <= 0; i++) { - limbDecayIndex = this->work[GND_LIMB_DECAY_INDEX]; - this->work[GND_LIMB_DECAY_INDEX]++; - this->work[GND_LIMB_DECAY_INDEX] %= 25; - pos.x = this->bodyPartsPos[limbDecayIndex].x + Rand_CenteredFloat(5.0f); - pos.y = this->bodyPartsPos[limbDecayIndex].y + Rand_CenteredFloat(5.0f); - pos.z = this->bodyPartsPos[limbDecayIndex].z + Rand_CenteredFloat(5.0f); - accelKFire.y = 0.0f; - - if (bodyDecayLevel == 3) { - accelKFire.y = -0.2f; - accelKFire.x = (GND_BOSSROOM_CENTER_X - pos.x) * 0.002f; - accelKFire.z = (GND_BOSSROOM_CENTER_Z - pos.z) * 0.002f; - accelHahen.x = (GND_BOSSROOM_CENTER_X - pos.x) * 0.001f; - accelHahen.y = -1.0f; - accelHahen.z = (GND_BOSSROOM_CENTER_Z - pos.z) * 0.001f; - } - - EffectSsKFire_Spawn(globalCtx, &pos, &vel, &accelKFire, (s16)Rand_ZeroFloat(20.0f) + 15, - bodyDecayLevel); - if ((Rand_ZeroOne() < 0.5f) || (bodyDecayLevel == 3)) { - EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accelHahen, 0, (s16)Rand_ZeroFloat(4.0f) + 7, - HAHEN_OBJECT_DEFAULT, 10, NULL); - } - } - } else { - globalCtx->envCtx.unk_BF = 0; - globalCtx->envCtx.unk_D6 = 0x14; - } - - this->work[GND_BODY_DECAY_FLAG] = true; - for (i = 0; i < 5; i++) { - if (bodyDecayLevel == 1) { - BossGanondrof_ClearPixels(sDecayMaskLow, this->work[GND_BODY_DECAY_INDEX]); - } else if (bodyDecayLevel == 2) { - BossGanondrof_ClearPixels(sDecayMaskHigh, this->work[GND_BODY_DECAY_INDEX]); - } else { - BossGanondrof_ClearPixels(sDecayMaskTotal, this->work[GND_BODY_DECAY_INDEX]); - } - - if (this->work[GND_BODY_DECAY_INDEX] < 0x100) { - this->work[GND_BODY_DECAY_INDEX]++; - } - } - } - - if (this->deathCamera != 0) { - if (!holdCamera) { - Math_ApproachF(&this->cameraEye.x, this->cameraNextEye.x, this->cameraEyeMaxVel.x, - this->cameraEyeVel.x * this->cameraSpeedMod); - Math_ApproachF(&this->cameraEye.y, this->cameraNextEye.y, this->cameraEyeMaxVel.y, - this->cameraEyeVel.y * this->cameraSpeedMod); - Math_ApproachF(&this->cameraEye.z, this->cameraNextEye.z, this->cameraEyeMaxVel.z, - this->cameraEyeVel.z * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.x, this->cameraNextAt.x, this->cameraAtMaxVel.x, - this->cameraAtVel.x * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.y, this->cameraNextAt.y, this->cameraAtMaxVel.y, - this->cameraAtVel.y * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.z, this->cameraNextAt.z, this->cameraAtMaxVel.z, - this->cameraAtVel.z * this->cameraSpeedMod); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, this->cameraAccel); - } - - Gameplay_CameraSetAtEye(globalCtx, this->deathCamera, &this->cameraAt, &this->cameraEye); - } -} - -void BossGanondrof_CollisionCheck(BossGanondrof* this, GlobalContext* globalCtx) { - s32 acHit; - EnfHG* horse = (EnfHG*)this->actor.child; - ColliderInfo* hurtbox = NULL; - - if (this->work[GND_INVINC_TIMER] != 0) { - this->work[GND_INVINC_TIMER]--; - this->returnCount = 0; - this->colliderBody.base.acFlags &= ~AC_HIT; - } else { - acHit = this->colliderBody.base.acFlags & AC_HIT; - if ((acHit && ((s8)this->actor.colChkInfo.health > 0)) || (this->returnCount != 0)) { - if (acHit) { - this->colliderBody.base.acFlags &= ~AC_HIT; - hurtbox = this->colliderBody.info.acHitInfo; - } - if (this->flyMode != GND_FLY_PAINTING) { - if (acHit && (this->actionFunc != BossGanondrof_Stunned) && (hurtbox->toucher.dmgFlags & 0x0001F8A4)) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_GROUND - SFX_FLAG); - osSyncPrintf("hit != 0 \n"); - } else if (this->actionFunc != BossGanondrof_Charge) { - if (this->returnCount == 0) { - u8 dmg; - u8 canKill = false; - s32 dmgFlags = hurtbox->toucher.dmgFlags; - - if (dmgFlags & 0x80) { - return; - } - dmg = CollisionCheck_GetSwordDamage(dmgFlags); - (dmg == 0) ? (dmg = 2) : (canKill = true); - if (((s8)this->actor.colChkInfo.health > 2) || canKill) { - this->actor.colChkInfo.health -= dmg; - } - - if ((s8)this->actor.colChkInfo.health <= 0) { - BossGanondrof_SetupDeath(this, globalCtx); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - return; - } - } - BossGanondrof_SetupStunned(this, globalCtx); - if (this->returnCount >= 2) { - this->timers[0] = 120; - } - this->work[GND_INVINC_TIMER] = 10; - horse->hitTimer = 20; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_DAMAGE); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_GROUND - SFX_FLAG); - } - } else if (acHit && (hurtbox->toucher.dmgFlags & 0x0001F8A4)) { - this->work[GND_INVINC_TIMER] = 10; - this->actor.colChkInfo.health -= 2; - horse->hitTimer = 20; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_DAMAGE); - } - this->returnCount = 0; - } - } -} - -void BossGanondrof_Update(Actor* thisx, GlobalContext* globalCtx) { - f32 cs; - f32 sn; - f32 legRotTargetY; - f32 legRotTargetZ; - f32 legSplitTarget; - s32 pad2; - s16 i; - s32 pad; - BossGanondrof* this = (BossGanondrof*)thisx; - EnfHG* horse; - - osSyncPrintf("MOVE START %d\n", this->actor.params); - this->actor.flags &= ~ACTOR_FLAG_10; - this->colliderBody.base.colType = COLTYPE_HIT3; - if (this->killActor) { - Actor_Kill(&this->actor); - return; - } - this->work[GND_VARIANCE_TIMER]++; - horse = (EnfHG*)this->actor.child; - osSyncPrintf("MOVE START EEEEEEEEEEEEEEEEEEEEEE%d\n", this->actor.params); - - this->actionFunc(this, globalCtx); - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i]) { - this->timers[i]--; - } - } - if (this->work[GND_UNKTIMER_1]) { - this->work[GND_UNKTIMER_1]--; - } - if (this->work[GND_UNKTIMER_2]) { - this->work[GND_UNKTIMER_2]--; - } - - if (this->actionFunc != BossGanondrof_Death) { - BossGanondrof_CollisionCheck(this, globalCtx); - } - - osSyncPrintf("MOVE END\n"); - BossGanondrof_SetColliderPos(&this->targetPos, &this->colliderBody); - BossGanondrof_SetColliderPos(&this->spearTip, &this->colliderSpear); - if ((this->flyMode == GND_FLY_PAINTING) && !horse->bossGndInPainting) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - } - if ((this->actionFunc == BossGanondrof_Stunned) && (this->timers[0] > 1)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - } else if (this->actionFunc == BossGanondrof_Block) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - } else if (this->actionFunc == BossGanondrof_Charge) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSpear.base); - } - - this->actor.focus.pos = this->targetPos; - - sn = Math_SinS(-this->actor.shape.rot.y); - cs = Math_CosS(-this->actor.shape.rot.y); - legRotTargetY = ((sn * this->actor.velocity.z) + (cs * this->actor.velocity.x)) * 300.0f; - legRotTargetZ = ((-sn * this->actor.velocity.x) + (cs * this->actor.velocity.z)) * 300.0f; - Math_ApproachF(&this->legRotY, legRotTargetY, 1.0f, 600.0f); - Math_ApproachF(&this->legRotZ, legRotTargetZ, 1.0f, 600.0f); - if ((this->flyMode != GND_FLY_PAINTING) && (this->actionFunc != BossGanondrof_Stunned) && - (this->deathState == NOT_DEAD)) { - legSplitTarget = (Math_SinS(this->work[GND_VARIANCE_TIMER] * 0x8DC) * -500.0f) - 500.0f; - } else { - legSplitTarget = 0.0f; - } - - Math_ApproachF(&this->legSplitY, legSplitTarget, 1.0f, 100.0f); - if (this->shockTimer != 0) { - s16 j; - - this->shockTimer--; - osSyncPrintf("F 1\n"); - for (j = 0; j < 7; j++) { - osSyncPrintf("F 15\n"); - EffectSsFhgFlash_SpawnShock(globalCtx, &this->actor, &this->actor.world.pos, 45, FHGFLASH_SHOCK_PG); - } - osSyncPrintf("F 2\n"); - } - - if (this->actor.params == GND_REAL_BOSS) { - Lights_PointNoGlowSetInfo(&this->lightInfo, this->spearTip.x, this->spearTip.y, this->spearTip.z, 255, 255, 255, - 200); - } -} - -s32 BossGanondrof_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossGanondrof* this = (BossGanondrof*)thisx; - - switch (limbIndex) { - case 15: - if ((this->actionFunc == BossGanondrof_Intro) && this->work[GND_MASK_OFF]) { - *dList = gPhantomGanonFaceDL; - } - rot->y += this->rideRotY[limbIndex]; - rot->z += this->rideRotZ[limbIndex]; - break; - - case 19: - rot->y += this->legRotY + this->legSplitY; - rot->z += this->legRotZ; - break; - - case 20: - rot->y += this->legRotY + this->legSplitY; - rot->z += this->legRotZ; - break; - - case 21: - rot->y += this->legRotY + this->legSplitY; - rot->z += this->legRotZ; - break; - - case 23: - rot->y += this->legRotY - this->legSplitY; - rot->z += this->legRotZ; - break; - - case 24: - rot->y += this->legRotY - this->legSplitY; - rot->z += this->legRotZ; - break; - - case 25: - rot->y += this->legRotY - this->legSplitY; - rot->z += this->legRotZ; - break; - - case 5: - case 6: - case 7: - rot->y += this->armRotY; - rot->z += this->armRotZ; - break; - - case 8: - case 9: - case 10: - rot->y += this->armRotY; - rot->z += this->armRotZ; - break; - - case 13: - if (this->deathState != NOT_DEAD) { - *dList = NULL; - } - default: - rot->y += this->rideRotY[limbIndex]; - rot->z += this->rideRotZ[limbIndex]; - break; - } - - return 0; -} - -void BossGanondrof_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - static Vec3f spearVec = { 0.0f, 0.0f, 6000.0f }; - - BossGanondrof* this = (BossGanondrof*)thisx; - - if (limbIndex == 14) { - Matrix_MultVec3f(&zeroVec, &this->targetPos); - } else if (limbIndex == 13) { - Matrix_MultVec3f(&spearVec, &this->spearTip); - } - - if (((this->flyMode != GND_FLY_PAINTING) || (this->actionFunc == BossGanondrof_Intro)) && (limbIndex <= 25)) { - Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[limbIndex - 1]); - } -} - -Gfx* BossGanondrof_GetClearPixelDList(GraphicsContext* gfxCtx) { - Gfx* dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 4); - Gfx* dListHead = dList; - - gDPPipeSync(dListHead++); - gDPSetRenderMode(dListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); - gSPClearGeometryMode(dListHead++, G_CULL_BACK); - gSPEndDisplayList(dListHead++); - - return dList; -} - -Gfx* BossGanondrof_GetNullDList(GraphicsContext* gfxCtx) { - Gfx* dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 1); - Gfx* dListHead = dList; - - gSPEndDisplayList(dListHead++); - return dList; -} - -void BossGanondrof_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossGanondrof* this = (BossGanondrof*)thisx; - EnfHG* horse; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganondrof.c", 3716); - osSyncPrintf("MOVE P = %x\n", this->actor.update); - osSyncPrintf("STOP TIMER = %d ==============\n", this->actor.freezeTimer); - horse = (EnfHG*)this->actor.child; - if (this->flyMode == GND_FLY_PAINTING) { - Matrix_RotateY((horse->turnRot * 3.1416f) / (f32)0x8000, MTXMODE_APPLY); - } - - osSyncPrintf("YP %f\n", this->actor.world.pos.y); - func_80093D18(globalCtx->state.gfxCtx); - if (this->work[GND_INVINC_TIMER] & 4) { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099); - } else { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, (u32)horse->warpColorFilterR, (u32)horse->warpColorFilterG, - (u32)horse->warpColorFilterB, 0, (s32)horse->warpColorFilterUnk1 + 995, - (s32)horse->warpColorFilterUnk2 + 1000); - } - - osSyncPrintf("DRAW 11\n"); - osSyncPrintf("EYE_COL %d\n", (s16)this->fwork[GND_EYE_BRIGHTNESS]); - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->fwork[GND_EYE_BRIGHTNESS], (s16)this->fwork[GND_EYE_BRIGHTNESS], - (s16)this->fwork[GND_EYE_BRIGHTNESS], (s16)this->fwork[GND_EYE_ALPHA]); - if (this->work[GND_BODY_DECAY_FLAG]) { - gSPSegment(POLY_OPA_DISP++, 0x08, BossGanondrof_GetClearPixelDList(globalCtx->state.gfxCtx)); - } else { - gSPSegment(POLY_OPA_DISP++, 0x08, BossGanondrof_GetNullDList(globalCtx->state.gfxCtx)); - } - - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, BossGanondrof_OverrideLimbDraw, - BossGanondrof_PostLimbDraw, this); - osSyncPrintf("DRAW 22\n"); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganondrof.c", 3814); - osSyncPrintf("DRAW END %d\n", this->actor.params); -} diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.cpp b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.cpp new file mode 100644 index 000000000..85f74cfaa --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.cpp @@ -0,0 +1,1540 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GANONDROF_Z_BOSS_GANONDROF_C +#include "actor_common.h" +/* + * File: z_boss_ganondrof.c + * Overlay: ovl_Boss_Ganondrof + * Description: Phantom Ganon + */ + +#include "z_boss_ganondrof.h" +#include "objects/object_gnd/object_gnd.h" +#include "overlays/actors/ovl_En_fHG/z_en_fhg.h" +#include "overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.h" +#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +typedef enum { + /* 0 */ NOT_DEAD, + /* 1 */ DEATH_START, + /* 2 */ DEATH_THROES, + /* 3 */ DEATH_WARP, + /* 4 */ DEATH_SCREAM, + /* 5 */ DEATH_DISINTEGRATE, + /* 6 */ DEATH_FINISH +} BossGanondrofDeathState; + +typedef enum { + /* 0 */ THROW_NORMAL, + /* 1 */ THROW_SLOW +} BossGanondrofThrowAction; + +typedef enum { + /* 0 */ STUNNED_FALL, + /* 1 */ STUNNED_GROUND +} BossGanondrofStunnedAction; + +typedef enum { + /* 0 */ CHARGE_WINDUP, + /* 1 */ CHARGE_START, + /* 2 */ CHARGE_ATTACK, + /* 3 */ CHARGE_FINISH +} BossGanondrofChargeAction; + +typedef enum { + /* 0 */ DEATH_SPASM, + /* 1 */ DEATH_LIMP, + /* 2 */ DEATH_HUNCHED +} BossGanondrofDeathAction; + +void BossGanondrof_Init(Actor* thisx, GlobalContext* globalCtx); +void BossGanondrof_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossGanondrof_Update(Actor* thisx, GlobalContext* globalCtx); +void BossGanondrof_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BossGanondrof_SetupIntro(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Intro(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_SetupPaintings(BossGanondrof* pthis); +void BossGanondrof_Paintings(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_SetupNeutral(BossGanondrof* pthis, f32 arg1); +void BossGanondrof_Neutral(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_SetupThrow(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Throw(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_SetupBlock(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Block(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_SetupReturn(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Return(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_SetupCharge(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Charge(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Stunned(BossGanondrof* pthis, GlobalContext* globalCtx); +void BossGanondrof_Death(BossGanondrof* pthis, GlobalContext* globalCtx); + +ActorInit Boss_Ganondrof_InitVars = { + ACTOR_BOSS_GANONDROF, + ACTORCAT_BOSS, + FLAGS, + OBJECT_GND, + sizeof(BossGanondrof), + (ActorFunc)BossGanondrof_Init, + (ActorFunc)BossGanondrof_Destroy, + (ActorFunc)BossGanondrof_Update, + (ActorFunc)BossGanondrof_Draw, +}; + +static ColliderCylinderInit sCylinderInitBody = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x10 }, + { 0xFFCFFFFE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 30, 90, -50, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInitSpear = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x30 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 20, 30, -20, { 0, 0, 0 } }, +}; + +// clang-format off +static u8 sDecayMaskHigh[16 * 16] = { + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1, + 1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1, + 1,0,1,1,1,0,0,0,0,1,1,1,1,1,0,1, + 1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,1, + 1,0,0,1,1,1,1,1,0,0,0,1,1,0,0,1, + 1,0,1,1,1,1,0,0,0,0,0,1,0,0,0,1, + 1,1,1,1,1,1,1,1,0,0,0,0,1,1,0,1, + 1,0,1,1,1,1,1,0,0,0,0,1,1,1,0,1, + 1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,1, + 1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1, + 1,0,0,0,1,1,0,0,0,1,1,1,1,1,1,1, + 1,0,0,1,1,1,1,0,1,1,1,1,1,1,1,1, + 1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,1, + 1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +}; + +static u8 sDecayMaskLow[16 * 16] = { + 1,1,1,0,1,0,0,1,0,0,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0, + 1,0,1,1,0,0,0,0,0,1,1,0,0,1,0,0, + 1,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0, + 0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,1, + 0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1, + 1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0, + 1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, + 1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1, + 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1, + 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1, + 1,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0, + 1,0,0,0,0,1,0,0,0,0,1,0,1,1,0,0, + 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, + 1,0,0,0,1,0,1,0,0,0,1,1,0,0,0,1, + 1,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1, +}; + +static u8 sDecayMaskTotal[16 * 16] = { + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +}; +// clang-format on + +// These are Phantom Ganon's body textures, but I don't know which is which. +static void* sLimbTex_rgba16_8x8[] = { + gPhantomGanonLimbTex_00A800, gPhantomGanonLimbTex_00AE80, gPhantomGanonLimbTex_00AF00, + gPhantomGanonLimbTex_00C180, gPhantomGanonLimbTex_00C400, +}; +static void* sLimbTex_rgba16_16x8[] = { + gPhantomGanonLimbTex_00B980, gPhantomGanonLimbTex_00C480, gPhantomGanonLimbTex_00BC80, + gPhantomGanonLimbTex_00BD80, gPhantomGanonLimbTex_00C080, +}; +static void* sLimbTex_rgba16_16x16[] = { + gPhantomGanonLimbTex_00C200, gPhantomGanonLimbTex_00A000, gPhantomGanonLimbTex_00A200, + gPhantomGanonLimbTex_00A400, gPhantomGanonLimbTex_00A600, gPhantomGanonLimbTex_00A880, + gPhantomGanonLimbTex_00B780, gPhantomGanonLimbTex_00BA80, gPhantomGanonLimbTex_00BE80, +}; +static void* sLimbTex_rgba16_16x32[] = { gPhantomGanonLimbTex_00AA80, gPhantomGanonLimbTex_00AF80 }; + +static void* sMouthTex_ci8_16x16[] = { gPhantomGanonMouthTex, gPhantomGanonSmileTex }; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x2B, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +static Vec3f sAudioVec = { 0.0f, 0.0f, 50.0f }; + +void BossGanondrof_ClearPixels8x8(s16* texture, u8* mask, s16 index) { + if (mask[index]) { + texture[index / 4] = 0; + } +} + +void BossGanondrof_ClearPixels16x8(s16* texture, u8* mask, s16 index) { + if (mask[index]) { + texture[index / 2] = 0; + } +} + +void BossGanondrof_ClearPixels16x16(s16* texture, u8* mask, s16 index) { + if (mask[index]) { + texture[index] = 0; + } +} + +void BossGanondrof_ClearPixels32x16(s16* texture, u8* mask, s16 index) { + if (mask[index]) { + s16 i = (index & 0xF) + ((index & 0xF0) << 1); + + texture[i + 0x10] = 0; + texture[i] = 0; + } +} + +void BossGanondrof_ClearPixels16x32(s16* texture, u8* mask, s16 index) { + if (mask[index]) { + s16 i = ((index & 0xF) * 2) + ((index & 0xF0) * 2); + + texture[i + 1] = 0; + texture[i] = 0; + } +} + +void BossGanondrof_ClearPixels(u8* mask, s16 index) { + s16 i; + + for (i = 0; i < 5; i++) { + // ARRAY_COUNT can't be used here because the arrays aren't guaranteed to be the same size. + BossGanondrof_ClearPixels8x8((s16*)SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_8x8[i]), mask, index); + BossGanondrof_ClearPixels16x8((s16*)SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_16x8[i]), mask, index); + } + + for (i = 0; i < ARRAY_COUNT(sLimbTex_rgba16_16x16); i++) { + BossGanondrof_ClearPixels16x16((s16*)SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_16x16[i]), mask, index); + } + + for (i = 0; i < ARRAY_COUNT(sLimbTex_rgba16_16x32); i++) { + BossGanondrof_ClearPixels16x32((s16*)SEGMENTED_TO_VIRTUAL(sLimbTex_rgba16_16x32[i]), mask, index); + } + + BossGanondrof_ClearPixels32x16((s16*)SEGMENTED_TO_VIRTUAL(gPhantomGanonLimbTex_00B380), mask, index); + BossGanondrof_ClearPixels16x32((s16*)SEGMENTED_TO_VIRTUAL(gPhantomGanonEyeTex), mask, index); + for (i = 0; i < ARRAY_COUNT(sMouthTex_ci8_16x16); i++) { + BossGanondrof_ClearPixels16x16((s16*)SEGMENTED_TO_VIRTUAL(sMouthTex_ci8_16x16[i]), mask, index); + } +} + +void BossGanondrof_SetColliderPos(Vec3f* pos, ColliderCylinder* collider) { + collider->dim.pos.x = pos->x; + collider->dim.pos.y = pos->y; + collider->dim.pos.z = pos->z; +} + +void BossGanondrof_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossGanondrof* pthis = (BossGanondrof*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&pthis->actor, 0.01f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gPhantomGanonSkel, &gPhantomGanonRideAnim, NULL, NULL, 0); + if (pthis->actor.params < GND_FAKE_BOSS) { + pthis->actor.params = GND_REAL_BOSS; + pthis->actor.colChkInfo.health = 30; + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, 255); + BossGanondrof_SetupIntro(pthis, globalCtx); + } else { + BossGanondrof_SetupPaintings(pthis); + } + + Collider_InitCylinder(globalCtx, &pthis->colliderBody); + Collider_InitCylinder(globalCtx, &pthis->colliderSpear); + Collider_SetCylinder(globalCtx, &pthis->colliderBody, &pthis->actor, &sCylinderInitBody); + Collider_SetCylinder(globalCtx, &pthis->colliderSpear, &pthis->actor, &sCylinderInitSpear); + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { + Actor_Kill(&pthis->actor); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y, + GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 200.0f + GND_BOSSROOM_CENTER_X, + GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, 0); + } else { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, pthis->actor.params); + } +} + +void BossGanondrof_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossGanondrof* pthis = (BossGanondrof*)thisx; + + osSyncPrintf("DT1\n"); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->colliderBody); + Collider_DestroyCylinder(globalCtx, &pthis->colliderSpear); + if (pthis->actor.params == GND_REAL_BOSS) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + } + + osSyncPrintf("DT2\n"); +} + +void BossGanondrof_SetupIntro(BossGanondrof* pthis, GlobalContext* globalCtx) { + Animation_PlayLoop(&pthis->skelAnime, &gPhantomGanonRidePoseAnim); + pthis->actionFunc = BossGanondrof_Intro; + pthis->work[GND_MASK_OFF] = true; +} + +void BossGanondrof_Intro(BossGanondrof* pthis, GlobalContext* globalCtx) { + s16 i; + s32 pad; + EnfHG* horse = (EnfHG*)pthis->actor.child; + + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.world.pos = horse->actor.world.pos; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = horse->actor.world.rot.y; + + osSyncPrintf("SW %d------------------------------------------------\n", horse->bossGndSignal); + + if ((pthis->timers[1] != 0) && (pthis->timers[1] < 25)) { + Vec3f pos; + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + + pos.x = pthis->bodyPartsPos[14].x + Rand_CenteredFloat(10.0f); + pos.y = pthis->bodyPartsPos[14].y + Rand_ZeroFloat(-5.0f); + pos.z = pthis->bodyPartsPos[14].z + Rand_CenteredFloat(10.0f) + 5.0f; + accel.y = 0.03f; + EffectSsKFire_Spawn(globalCtx, &pos, &vel, &accel, (s16)Rand_ZeroFloat(10.0f) + 5, 0); + } + + if (pthis->timers[1] == 20) { + pthis->work[GND_MASK_OFF] = false; + } + + if (pthis->timers[1] == 30) { + func_80078914(&sAudioVec, NA_SE_EN_FANTOM_TRANSFORM); + } + + if (horse->bossGndSignal == FHG_LIGHTNING) { + Animation_Change(&pthis->skelAnime, &gPhantomGanonMaskOnAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gPhantomGanonMaskOnAnim), ANIMMODE_ONCE_INTERP, 0.0f); + pthis->timers[1] = 40; + } + + if (horse->bossGndSignal == FHG_REAR) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonHorseRearingAnim, -3.0f); + } + + if (horse->bossGndSignal == FHG_RIDE) { + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonRidePoseAnim, -13.0f); + } + + if (horse->bossGndSignal == FHG_SPUR) { + EnfHG* horseTemp; + + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonRideSpearRaiseAnim, -7.0f); + horseTemp = (EnfHG*)pthis->actor.child; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, pthis->spearTip.x, + pthis->spearTip.y, pthis->spearTip.z, 50, FHGFIRE_LIGHT_GREEN, 0, FHGFIRE_SPEAR_LIGHT); + pthis->actor.child = &horseTemp->actor; + } + + if (horse->bossGndSignal == FHG_FINISH) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonRideSpearResetAnim, -5.0f); + } + + switch (pthis->work[GND_EYE_STATE]) { + case GND_EYESTATE_FADE: + pthis->fwork[GND_EYE_ALPHA] += 40.0f; + if (pthis->fwork[GND_EYE_ALPHA] >= 255.0f) { + pthis->fwork[GND_EYE_ALPHA] = 255.0f; + } + break; + + case GND_EYESTATE_BRIGHTEN: + pthis->fwork[GND_EYE_BRIGHTNESS] += 20.0f; + if (pthis->fwork[GND_EYE_BRIGHTNESS] > 255.0f) { + pthis->fwork[GND_EYE_BRIGHTNESS] = 255.0f; + } + break; + } + + pthis->armRotY = Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 0x6E8) * 0; + pthis->armRotZ = Math_CosS(pthis->work[GND_VARIANCE_TIMER] * 0x8DC) * 300.0f; + for (i = 0; i < 30; i++) { + pthis->rideRotY[i] = Math_SinS(pthis->work[GND_VARIANCE_TIMER] * ((i * 50) + 0x7B0)) * 100.0f; + pthis->rideRotZ[i] = Math_CosS(pthis->work[GND_VARIANCE_TIMER] * ((i * 50) + 0x8DC)) * 100.0f; + } + + if (horse->bossGndSignal == FHG_START_FIGHT) { + BossGanondrof_SetupPaintings(pthis); + for (i = 0; i < 30; i++) { + pthis->rideRotY[i] = pthis->rideRotZ[i] = 0.0f; + } + } + + horse->bossGndSignal = FHG_NO_SIGNAL; +} + +void BossGanondrof_SetupPaintings(BossGanondrof* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonRideAnim, -5.0f); + pthis->actionFunc = BossGanondrof_Paintings; +} + +void BossGanondrof_Paintings(BossGanondrof* pthis, GlobalContext* globalCtx) { + EnfHG* horse = (EnfHG*)pthis->actor.child; + + osSyncPrintf("RUN 1\n"); + SkelAnime_Update(&pthis->skelAnime); + osSyncPrintf("RUN 2\n"); + + if (horse->bossGndSignal == FHG_RAISE_SPEAR) { + EnfHG* horseTemp; + + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonRideSpearRaiseAnim, -2.0f); + pthis->actor.flags |= ACTOR_FLAG_0; + horseTemp = (EnfHG*)pthis->actor.child; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, pthis->spearTip.x, + pthis->spearTip.y, pthis->spearTip.z, 30, FHGFIRE_LIGHT_GREEN, 0, FHGFIRE_SPEAR_LIGHT); + pthis->actor.child = &horseTemp->actor; + } else if (horse->bossGndSignal == FHG_LIGHTNING) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonRideSpearStrikeAnim, -2.0f); + } else if (horse->bossGndSignal == FHG_RESET) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonRideSpearResetAnim, -2.0f); + } else if (horse->bossGndSignal == FHG_RIDE) { + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonRideAnim, -2.0f); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + + osSyncPrintf("RUN 3\n"); + pthis->actor.world.pos = horse->actor.world.pos; + pthis->actor.world.pos.y = horse->actor.world.pos.y; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = horse->actor.world.rot.y; + if (pthis->flyMode != GND_FLY_PAINTING) { + BossGanondrof_SetupNeutral(pthis, -20.0f); + pthis->timers[0] = 100; + pthis->colliderBody.dim.radius = 20; + pthis->colliderBody.dim.height = 60; + pthis->colliderBody.dim.yShift = -33; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_LAUGH); + pthis->actor.naviEnemyId = 0x1A; + } else { + horse->bossGndSignal = FHG_NO_SIGNAL; + pthis->actor.scale.x = horse->actor.scale.x / 1.15f; + pthis->actor.scale.y = horse->actor.scale.y / 1.15f; + pthis->actor.scale.z = horse->actor.scale.z / 1.15f; + osSyncPrintf("RUN 4\n"); + } +} + +void BossGanondrof_SetupNeutral(BossGanondrof* pthis, f32 arg1) { + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonNeutralAnim, arg1); + pthis->actionFunc = BossGanondrof_Neutral; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->fwork[GND_FLOAT_SPEED] = 0.0f; + pthis->timers[0] = (s16)(Rand_ZeroOne() * 64.0f) + 30; +} + +void BossGanondrof_Neutral(BossGanondrof* pthis, GlobalContext* globalCtx) { + f32 targetX; + f32 targetY; + f32 targetZ; + Player* player = GET_PLAYER(globalCtx); + Actor* playerx = &player->actor; + Actor* thisx = &pthis->actor; + f32 rand01; + s16 i; + + SkelAnime_Update(&pthis->skelAnime); + switch (pthis->flyMode) { + case GND_FLY_NEUTRAL: + if (pthis->timers[0] == 0) { + pthis->timers[0] = (s16)(Rand_ZeroOne() * 64.0f) + 30; + rand01 = Rand_ZeroOne(); + if (thisx->colChkInfo.health < 5) { + if (rand01 < 0.25f) { + BossGanondrof_SetupThrow(pthis, globalCtx); + } else if (rand01 >= 0.8f) { + pthis->flyMode = GND_FLY_CHARGE; + pthis->timers[0] = 60; + pthis->fwork[GND_FLOAT_SPEED] = 0.0f; + Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_LAUGH); + } else { + pthis->flyMode = GND_FLY_VOLLEY; + pthis->timers[0] = 60; + pthis->fwork[GND_FLOAT_SPEED] = 0.0f; + Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_LAUGH); + } + } else if ((rand01 < 0.5f) || (pthis->work[GND_THROW_COUNT] < 5)) { + BossGanondrof_SetupThrow(pthis, globalCtx); + } else { + pthis->flyMode = GND_FLY_VOLLEY; + pthis->timers[0] = 60; + pthis->fwork[GND_FLOAT_SPEED] = 0.0f; + Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_LAUGH); + } + } + + if (pthis->timers[1] != 0) { + targetX = GND_BOSSROOM_CENTER_X; + targetZ = GND_BOSSROOM_CENTER_Z; + } else { + targetX = playerx->world.pos.x + (180.0f * Math_SinS(playerx->shape.rot.y)); + targetZ = playerx->world.pos.z + (180.0f * Math_CosS(playerx->shape.rot.y)); + if (sqrtf(SQ(targetX - GND_BOSSROOM_CENTER_X) + SQ(targetZ - GND_BOSSROOM_CENTER_Z)) > 280.0f) { + pthis->timers[1] = 50; + pthis->fwork[GND_FLOAT_SPEED] = 0.0f; + } + } + + targetY = playerx->world.pos.y + 100.0f + 0.0f; + targetX += Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 0x500) * 100.0f; + targetZ += Math_CosS(pthis->work[GND_VARIANCE_TIMER] * 0x700) * 100.0f; + break; + case GND_FLY_VOLLEY: + targetX = GND_BOSSROOM_CENTER_X - 14.0f; + targetZ = GND_BOSSROOM_CENTER_Z + 265.0f; + + targetY = playerx->world.pos.y + 100.0f + 100.0f; + targetX += Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 0x500) * 100.0f; + targetZ += Math_CosS(pthis->work[GND_VARIANCE_TIMER] * 0x700) * 100.0f; + if (pthis->timers[0] == 0) { + pthis->flyMode = GND_FLY_RETURN; + pthis->returnSuccess = false; + BossGanondrof_SetupThrow(pthis, globalCtx); + pthis->timers[0] = 80; + } + break; + case GND_FLY_RETURN: + targetX = GND_BOSSROOM_CENTER_X - 14.0f; + targetZ = GND_BOSSROOM_CENTER_Z + 265.0f; + + targetY = playerx->world.pos.y + 100.0f + 100.0f; + targetX += Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 0x500) * 50.0f; + targetZ += Math_CosS(pthis->work[GND_VARIANCE_TIMER] * 0x700) * 50.0f; + if (pthis->returnSuccess) { + pthis->returnSuccess = false; + BossGanondrof_SetupReturn(pthis, globalCtx); + pthis->timers[0] = 80; + } + + if (pthis->timers[0] == 0) { + pthis->flyMode = GND_FLY_NEUTRAL; + } + break; + case GND_FLY_CHARGE: + targetX = GND_BOSSROOM_CENTER_X - 14.0f; + targetZ = GND_BOSSROOM_CENTER_Z + 215.0f; + + targetY = playerx->world.pos.y + 100.0f + 50.0f; + targetX += Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 0x500) * 100.0f; + targetZ += Math_CosS(pthis->work[GND_VARIANCE_TIMER] * 0x700) * 100.0f; + if (pthis->timers[0] == 0) { + BossGanondrof_SetupCharge(pthis, globalCtx); + } + break; + } + + Math_ApproachF(&thisx->world.pos.x, targetX, 0.05f, pthis->fwork[GND_FLOAT_SPEED]); + if (pthis->timers[2] != 0) { + Math_ApproachF(&thisx->world.pos.y, targetY + 100.0f, 0.1f, 50.0f); + } else { + Math_ApproachF(&thisx->world.pos.y, targetY, 0.05f, 10.0f); + } + + Math_ApproachF(&thisx->world.pos.z, targetZ, 0.05f, pthis->fwork[GND_FLOAT_SPEED]); + Math_ApproachF(&pthis->fwork[GND_FLOAT_SPEED], 50.0f, 1.0f, 0.5f); + thisx->velocity.x = thisx->world.pos.x - thisx->prevPos.x; + thisx->velocity.z = thisx->world.pos.z - thisx->prevPos.z; + thisx->world.pos.y += 2.0f * Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); + Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0xBB8); + if ((pthis->work[GND_VARIANCE_TIMER] & 1) == 0) { + Vec3f pos; + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + + for (i = 0; i < 3; i++) { + pos.x = Rand_CenteredFloat(20.0f) + pthis->spearTip.x; + pos.y = Rand_CenteredFloat(20.0f) + pthis->spearTip.y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->spearTip.z; + accel.y = -0.08f; + EffectSsFhgFlash_SpawnLightBall(globalCtx, &pos, &vel, &accel, (s16)(Rand_ZeroOne() * 80.0f) + 150, + FHGFLASH_LIGHTBALL_GREEN); + } + } + + if (player->unk_A73 != 0) { + BossGanondrof_SetupBlock(pthis, globalCtx); + } + + Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_FLOAT - SFX_FLAG); +} + +void BossGanondrof_SetupThrow(BossGanondrof* pthis, GlobalContext* globalCtx) { + EnfHG* horseTemp; + s16 lightTime; + + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonThrowAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonThrowAnim, -5.0f); + pthis->actionFunc = BossGanondrof_Throw; + if ((Rand_ZeroOne() <= 0.1f) && (pthis->work[GND_THROW_COUNT] >= 10) && (pthis->flyMode == GND_FLY_NEUTRAL)) { + pthis->work[GND_ACTION_STATE] = THROW_SLOW; + pthis->work[GND_THROW_FRAME] = 1000; + lightTime = 32; + } else { + pthis->work[GND_ACTION_STATE] = THROW_NORMAL; + pthis->work[GND_THROW_FRAME] = 25; + lightTime = 25; + } + + horseTemp = (EnfHG*)pthis->actor.child; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, pthis->spearTip.x, + pthis->spearTip.y, pthis->spearTip.z, lightTime, FHGFIRE_LIGHT_GREEN, 0, FHGFIRE_SPEAR_LIGHT); + pthis->actor.child = &horseTemp->actor; + pthis->work[GND_THROW_COUNT]++; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_STICK); +} + +void BossGanondrof_Throw(BossGanondrof* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + osSyncPrintf("pthis->fwork[GND_END_FRAME] = %d\n", (s16)pthis->fwork[GND_END_FRAME]); + osSyncPrintf("pthis->work[GND_SHOT_FRAME] = %d\n", pthis->work[GND_THROW_FRAME]); + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GND_END_FRAME])) { + BossGanondrof_SetupNeutral(pthis, -6.0f); + } + + if ((pthis->work[GND_ACTION_STATE] != THROW_NORMAL) && Animation_OnFrame(&pthis->skelAnime, 21.0f)) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonThrowEndAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonThrowEndAnim, 0.0f); + pthis->work[GND_THROW_FRAME] = 10; + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->work[GND_THROW_FRAME])) { + if (pthis->flyMode <= GND_FLY_NEUTRAL) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_MASIC2); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_MASIC1); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_VOICE); + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->work[GND_THROW_FRAME])) { + EnfHG* horseTemp = (EnfHG*)pthis->actor.child; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, pthis->spearTip.x, + pthis->spearTip.y, pthis->spearTip.z, pthis->work[GND_ACTION_STATE], 0, 0, FHGFIRE_ENERGY_BALL); + pthis->actor.child = &horseTemp->actor; + } + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x7D0); + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + Math_ApproachZeroF(&pthis->actor.velocity.x, 1.0f, 0.5f); + Math_ApproachZeroF(&pthis->actor.velocity.z, 1.0f, 0.5f); + pthis->actor.world.pos.y += 2.0f * Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); +} + +void BossGanondrof_SetupReturn(BossGanondrof* pthis, GlobalContext* globalCtx) { + static AnimationHeader* returnAnim[] = { &gPhantomGanonReturn1Anim, &gPhantomGanonReturn2Anim }; + s16 rand = Rand_ZeroOne() * 1.99f; + + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(returnAnim[rand]); + Animation_MorphToPlayOnce(&pthis->skelAnime, returnAnim[rand], 0.0f); + pthis->actionFunc = BossGanondrof_Return; +} + +void BossGanondrof_Return(BossGanondrof* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_VOICE); + osSyncPrintf("VOISE 2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + osSyncPrintf("VOISE 2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + } + + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GND_END_FRAME])) { + BossGanondrof_SetupNeutral(pthis, 0.0f); + } + + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + Math_ApproachZeroF(&pthis->actor.velocity.x, 1.0f, 0.5f); + Math_ApproachZeroF(&pthis->actor.velocity.z, 1.0f, 0.5f); + pthis->actor.world.pos.y += 2.0f * Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); + if (pthis->returnSuccess) { + pthis->returnSuccess = false; + BossGanondrof_SetupReturn(pthis, globalCtx); + pthis->timers[0] = 80; + } +} + +void BossGanondrof_SetupStunned(BossGanondrof* pthis, GlobalContext* globalCtx) { + if (pthis->actionFunc != BossGanondrof_Stunned) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonAirDamageAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonAirDamageAnim, 0.0f); + pthis->timers[0] = 50; + pthis->shockTimer = 60; + } else { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonGroundDamageAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonGroundDamageAnim, 0.0f); + } + + pthis->actionFunc = BossGanondrof_Stunned; + pthis->work[GND_ACTION_STATE] = STUNNED_FALL; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.z = 0.0f; +} + +void BossGanondrof_Stunned(BossGanondrof* pthis, GlobalContext* globalCtx) { + osSyncPrintf("DAMAGE .................................\n"); + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.gravity = -0.2f; + if (pthis->actor.world.pos.y <= 5.0f) { + if (pthis->work[GND_ACTION_STATE] == STUNNED_FALL) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonStunnedAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonStunnedAnim, -10.0f); + pthis->work[GND_ACTION_STATE] = STUNNED_GROUND; + } + + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GND_END_FRAME])) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_DAMAGE2); + } + + pthis->actor.flags |= ACTOR_FLAG_10; + } + + osSyncPrintf("TIME0 %d ********************************************\n", pthis->timers[0]); + if (pthis->timers[0] == 0) { + BossGanondrof_SetupNeutral(pthis, -5.0f); + pthis->timers[0] = 30; + pthis->timers[2] = 30; + pthis->flyMode = GND_FLY_NEUTRAL; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + } + + Actor_MoveForward(&pthis->actor); +} + +void BossGanondrof_SetupBlock(BossGanondrof* pthis, GlobalContext* globalCtx) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonBlockAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonBlockAnim, -3.0f); + pthis->actionFunc = BossGanondrof_Block; + pthis->timers[0] = 10; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_STICK); +} + +void BossGanondrof_Block(BossGanondrof* pthis, GlobalContext* globalCtx) { + pthis->colliderBody.base.colType = COLTYPE_METAL; + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + Math_ApproachZeroF(&pthis->actor.velocity.x, 1.0f, 0.5f); + Math_ApproachZeroF(&pthis->actor.velocity.z, 1.0f, 0.5f); + pthis->actor.world.pos.y += 2.0f * Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); + if (pthis->timers[0] == 0) { + BossGanondrof_SetupNeutral(pthis, -5.0f); + pthis->timers[0] = 10; + pthis->flyMode = GND_FLY_NEUTRAL; + } +} + +void BossGanondrof_SetupCharge(BossGanondrof* pthis, GlobalContext* globalCtx) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonChargeWindupAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonChargeWindupAnim, -3.0f); + pthis->actionFunc = BossGanondrof_Charge; + pthis->timers[0] = 20; + pthis->work[GND_ACTION_STATE] = CHARGE_WINDUP; +} + +void BossGanondrof_Charge(BossGanondrof* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* playerx = &player->actor; + Actor* thisx = &pthis->actor; + f32 dxCenter = thisx->world.pos.x - GND_BOSSROOM_CENTER_X; + f32 dzCenter = thisx->world.pos.z - GND_BOSSROOM_CENTER_Z; + + pthis->colliderBody.base.colType = COLTYPE_METAL; + SkelAnime_Update(&pthis->skelAnime); + switch (pthis->work[GND_ACTION_STATE]) { + case CHARGE_WINDUP: + if (pthis->timers[0] == 218) { + Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_STICK); + } + + if (pthis->timers[0] == 19) { + Audio_PlayActorSound2(thisx, NA_SE_EN_FANTOM_ATTACK); + } + + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.z += thisx->velocity.z; + Math_ApproachZeroF(&thisx->velocity.x, 1.0f, 0.5f); + Math_ApproachZeroF(&thisx->velocity.z, 1.0f, 0.5f); + if (pthis->timers[0] == 0) { + pthis->work[GND_ACTION_STATE] = CHARGE_START; + pthis->timers[0] = 10; + thisx->speedXZ = 0.0f; + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonChargeStartAnim); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonChargeStartAnim, 0.0f); + } + + Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0x7D0); + break; + case CHARGE_START: + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GND_END_FRAME])) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonChargeAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonChargeAnim, 0.0f); + pthis->work[GND_ACTION_STATE] = CHARGE_ATTACK; + } + case CHARGE_ATTACK: + if (pthis->timers[0] != 0) { + Vec3f vecToLink; + + Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0x7D0); + vecToLink.x = playerx->world.pos.x - thisx->world.pos.x; + vecToLink.y = playerx->world.pos.y + 40.0f - thisx->world.pos.y; + vecToLink.z = playerx->world.pos.z - thisx->world.pos.z; + thisx->world.rot.y = thisx->shape.rot.y; + thisx->world.rot.x = + Math_FAtan2F(vecToLink.y, sqrtf(SQ(vecToLink.x) + SQ(vecToLink.z))) * (0x8000 / M_PI); + } + + func_8002D908(thisx); + func_8002D7EC(thisx); + Math_ApproachF(&thisx->speedXZ, 10.0f, 1.0f, 0.5f); + if ((sqrtf(SQ(dxCenter) + SQ(dzCenter)) > 280.0f) || (thisx->xyzDistToPlayerSq < SQ(100.0f))) { + pthis->work[GND_ACTION_STATE] = CHARGE_FINISH; + pthis->timers[0] = 20; + } + break; + case CHARGE_FINISH: + thisx->gravity = 0.2f; + Actor_MoveForward(thisx); + osSyncPrintf("YP %f @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n", thisx->world.pos.y); + if (thisx->world.pos.y < 5.0f) { + thisx->world.pos.y = 5.0f; + thisx->velocity.y = 0.0f; + } + + if (sqrtf(SQ(dxCenter) + SQ(dzCenter)) > 280.0f) { + Math_ApproachZeroF(&thisx->speedXZ, 1.0f, 2.0f); + pthis->timers[0] = 0; + } + + if (pthis->timers[0] == 0) { + Math_ApproachZeroF(&thisx->speedXZ, 1.0f, 2.0f); + Math_ApproachZeroF(&thisx->velocity.y, 1.0f, 2.0f); + Math_ApproachS(&thisx->shape.rot.y, thisx->yawTowardsPlayer, 5, 0x7D0); + if ((thisx->speedXZ <= 0.5f) && (fabsf(thisx->velocity.y) <= 0.1f)) { + BossGanondrof_SetupNeutral(pthis, -10.0f); + pthis->timers[0] = 30; + pthis->flyMode = GND_FLY_NEUTRAL; + } + } + break; + } + + if (thisx->world.pos.y > (GND_BOSSROOM_CENTER_Y + 83.0f)) { + thisx->world.pos.y += 2.0f * Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); + } + { + s16 i; + Vec3f pos; + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f baseOffset = { 0.0f, 50.0f, 0.0f }; + Vec3f offset; + + baseOffset.y = 10.0f; + for (i = 0; i < 10; i++) { + Matrix_Push(); + Matrix_RotateY((thisx->shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); + Matrix_RotateX((thisx->shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateZ((pthis->work[GND_PARTICLE_ANGLE] / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_MultVec3f(&baseOffset, &offset); + Matrix_Pop(); + pos.x = pthis->spearTip.x + offset.x; + pos.y = pthis->spearTip.y + offset.y; + pos.z = pthis->spearTip.z + offset.z; + vel.x = (offset.x * 500.0f) / 1000.0f; + vel.y = (offset.y * 500.0f) / 1000.0f; + vel.z = (offset.z * 500.0f) / 1000.0f; + accel.x = (offset.x * -50.0f) / 1000.0f; + accel.y = (offset.y * -50.0f) / 1000.0f; + accel.z = (offset.z * -50.0f) / 1000.0f; + EffectSsFhgFlash_SpawnLightBall(globalCtx, &pos, &vel, &accel, 150, i % 7); + pthis->work[GND_PARTICLE_ANGLE] += 0x1A5C; + } + } + + if (!(pthis->work[GND_VARIANCE_TIMER] & 7)) { + EnfHG* horse = (EnfHG*)thisx->child; + + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_FHG_FIRE, pthis->spearTip.x, + pthis->spearTip.y, pthis->spearTip.z, 8, FHGFIRE_LIGHT_BLUE, 0, FHGFIRE_SPEAR_LIGHT); + thisx->child = &horse->actor; + } +} + +void BossGanondrof_SetupDeath(BossGanondrof* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gPhantomGanonDeathBlowAnim); + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonDeathBlowAnim); + pthis->actionFunc = BossGanondrof_Death; + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_DEAD); + pthis->deathState = DEATH_START; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->work[GND_VARIANCE_TIMER] = 0; + pthis->shockTimer = 50; +} + +void BossGanondrof_Death(BossGanondrof* pthis, GlobalContext* globalCtx) { + u8 holdCamera = false; + u8 bodyDecayLevel = 0; + f32 camX; + f32 camZ; + f32 pad; + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Gameplay_GetCamera(globalCtx, 0); + + osSyncPrintf("PYP %f\n", player->actor.floorHeight); + SkelAnime_Update(&pthis->skelAnime); + pthis->work[GND_DEATH_SFX_TIMER]++; + if (((60 < pthis->work[GND_DEATH_SFX_TIMER]) && (pthis->work[GND_DEATH_SFX_TIMER] < 500)) || + ((501 < pthis->work[GND_DEATH_SFX_TIMER]) && (pthis->work[GND_DEATH_SFX_TIMER] < 620))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_LAST - SFX_FLAG); + } + + switch (pthis->deathState) { + case DEATH_START: + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->deathCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + osSyncPrintf("7\n"); + Gameplay_ChangeCameraStatus(globalCtx, pthis->deathCamera, CAM_STAT_ACTIVE); + osSyncPrintf("8\n"); + pthis->deathState = DEATH_THROES; + player->actor.speedXZ = 0.0f; + pthis->timers[0] = 50; + pthis->cameraEye = camera->eye; + pthis->cameraAt = camera->at; + pthis->cameraNextEye.x = pthis->targetPos.x; + pthis->cameraNextEye.y = GND_BOSSROOM_CENTER_Y + 83.0f; + pthis->cameraNextEye.z = (pthis->targetPos.z + 100.0f) + 50; + pthis->cameraNextAt.x = pthis->targetPos.x; + pthis->cameraNextAt.y = pthis->targetPos.y - 10.0f; + pthis->cameraNextAt.z = pthis->targetPos.z; + pthis->cameraEyeVel.x = fabsf(camera->eye.x - pthis->cameraNextEye.x); + pthis->cameraEyeVel.y = fabsf(camera->eye.y - pthis->cameraNextEye.y); + pthis->cameraEyeVel.z = fabsf(camera->eye.z - pthis->cameraNextEye.z); + pthis->cameraAtVel.x = fabsf(camera->at.x - pthis->cameraNextAt.x); + pthis->cameraAtVel.y = fabsf(camera->at.y - pthis->cameraNextAt.y); + pthis->cameraAtVel.z = fabsf(camera->at.z - pthis->cameraNextAt.z); + pthis->cameraAccel = 0.02f; + pthis->cameraEyeMaxVel.x = pthis->cameraEyeMaxVel.y = pthis->cameraEyeMaxVel.z = 0.05f; + pthis->work[GND_ACTION_STATE] = DEATH_SPASM; + pthis->timers[0] = 150; + pthis->cameraAtMaxVel.x = 0.2f; + pthis->cameraAtMaxVel.y = 0.2f; + pthis->cameraAtMaxVel.z = 0.2f; + case DEATH_THROES: + switch (pthis->work[GND_ACTION_STATE]) { + case DEATH_SPASM: + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GND_END_FRAME])) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonAirDamageAnim); + Animation_Change(&pthis->skelAnime, &gPhantomGanonAirDamageAnim, 0.5f, 0.0f, + pthis->fwork[GND_END_FRAME], ANIMMODE_ONCE_INTERP, 0.0f); + pthis->work[GND_ACTION_STATE] = DEATH_LIMP; + } + break; + case DEATH_LIMP: + if (Animation_OnFrame(&pthis->skelAnime, pthis->fwork[GND_END_FRAME])) { + pthis->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonLimpAnim); + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonLimpAnim, -20.0f); + pthis->work[GND_ACTION_STATE] = DEATH_HUNCHED; + } + case DEATH_HUNCHED: + bodyDecayLevel = 1; + break; + } + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->work[GND_VARIANCE_TIMER] * -100, 5, 0xBB8); + Math_ApproachF(&pthis->cameraNextEye.z, pthis->targetPos.z + 60.0f, 0.02f, 0.5f); + Math_ApproachF(&pthis->actor.world.pos.y, GND_BOSSROOM_CENTER_Y + 133.0f, 0.05f, 100.0f); + pthis->actor.world.pos.y += Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); + pthis->cameraNextAt.x = pthis->targetPos.x; + pthis->cameraNextAt.y = pthis->targetPos.y - 10.0f; + pthis->cameraNextAt.z = pthis->targetPos.z; + if (pthis->timers[0] == 0) { + pthis->deathState = DEATH_WARP; + pthis->timers[0] = 350; + pthis->timers[1] = 50; + pthis->fwork[GND_CAMERA_ZOOM] = 300.0f; + pthis->cameraNextEye.y = GND_BOSSROOM_CENTER_Y + 233.0f; + player->actor.world.pos.x = GND_BOSSROOM_CENTER_X - 200.0f; + player->actor.world.pos.z = GND_BOSSROOM_CENTER_Z; + holdCamera = true; + bodyDecayLevel = 1; + } + break; + case DEATH_WARP: + if (pthis->timers[1] == 1) { + EnfHG* horseTemp = (EnfHG*)pthis->actor.child; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y + 3.0f, GND_BOSSROOM_CENTER_Z, 0x4000, + 0, 0, FHGFIRE_WARP_DEATH); + pthis->actor.child = &horseTemp->actor; + Message_StartTextbox(globalCtx, 0x108E, NULL); + } + + pthis->actor.shape.rot.y -= 0xC8; + pthis->actor.world.pos.y += Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 1500); + pthis->fwork[GND_CAMERA_ANGLE] += 0x78; + camX = Math_SinS(pthis->fwork[GND_CAMERA_ANGLE]) * pthis->fwork[GND_CAMERA_ZOOM]; + camZ = Math_CosS(pthis->fwork[GND_CAMERA_ANGLE]) * pthis->fwork[GND_CAMERA_ZOOM]; + pthis->cameraEye.x = GND_BOSSROOM_CENTER_X + camX; + pthis->cameraEye.y = pthis->cameraNextEye.y; + pthis->cameraEye.z = GND_BOSSROOM_CENTER_Z + camZ; + pthis->cameraAt.x = GND_BOSSROOM_CENTER_X; + pthis->cameraAt.y = GND_BOSSROOM_CENTER_Y + 23.0f; + pthis->cameraAt.z = GND_BOSSROOM_CENTER_Z; + Math_ApproachF(&pthis->cameraNextEye.y, GND_BOSSROOM_CENTER_Y + 33.0f, 0.05f, 0.5f); + Math_ApproachF(&pthis->fwork[GND_CAMERA_ZOOM], 170.0f, 0.05f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.x, GND_BOSSROOM_CENTER_X, 0.05f, 1.5f); + Math_ApproachF(&pthis->actor.world.pos.y, GND_BOSSROOM_CENTER_Y + 83.0f, 0.05f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.z, GND_BOSSROOM_CENTER_Z, 0.05f, 1.5f); + if (pthis->timers[0] == 0) { + pthis->deathState = DEATH_SCREAM; + pthis->timers[0] = 50; + Animation_MorphToLoop(&pthis->skelAnime, &gPhantomGanonScreamAnim, -10.0f); + pthis->actor.world.pos.x = GND_BOSSROOM_CENTER_X; + pthis->actor.world.pos.y = GND_BOSSROOM_CENTER_Y + 83.0f; + pthis->actor.world.pos.z = GND_BOSSROOM_CENTER_Z; + pthis->actor.shape.rot.y = 0; + pthis->work[GND_BODY_DECAY_INDEX] = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_LAST); + } + + holdCamera = true; + bodyDecayLevel = 1; + break; + case DEATH_SCREAM: + holdCamera = true; + bodyDecayLevel = 2; + pthis->actor.world.pos.y = GND_BOSSROOM_CENTER_Y + 83.0f; + pthis->cameraEye.x = GND_BOSSROOM_CENTER_X; + pthis->cameraEye.y = GND_BOSSROOM_CENTER_Y + 83.0f; + pthis->cameraEye.z = GND_BOSSROOM_CENTER_Z + 50.0f; + pthis->cameraAt.x = GND_BOSSROOM_CENTER_X; + pthis->cameraAt.y = GND_BOSSROOM_CENTER_Y + 103.0f; + pthis->cameraAt.z = GND_BOSSROOM_CENTER_Z; + if (pthis->timers[0] == 0) { + pthis->deathState = DEATH_DISINTEGRATE; + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPhantomGanonLastPoseAnim, -10.0f); + pthis->work[GND_BODY_DECAY_INDEX] = 0; + pthis->timers[0] = 40; + } + break; + case DEATH_DISINTEGRATE: + holdCamera = true; + bodyDecayLevel = 3; + Math_ApproachZeroF(&pthis->cameraEye.y, 0.05f, 1.0f); // approaches GND_BOSSROOM_CENTER_Y + 33.0f + Math_ApproachF(&pthis->cameraEye.z, GND_BOSSROOM_CENTER_Z + 170.0f, 0.05f, 2.0f); + Math_ApproachF(&pthis->cameraAt.y, GND_BOSSROOM_CENTER_Y + 53.0f, 0.05f, 1.0f); + if (pthis->timers[0] == 0) { + pthis->timers[0] = 250; + pthis->deathState = DEATH_FINISH; + } + break; + case DEATH_FINISH: + holdCamera = true; + bodyDecayLevel = 10; + if (pthis->timers[0] == 150) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, + GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); + } + + Math_ApproachZeroF(&pthis->cameraEye.y, 0.05f, 1.0f); // GND_BOSSROOM_CENTER_Y + 33.0f + Math_ApproachF(&pthis->cameraEye.z, GND_BOSSROOM_CENTER_Z + 170.0f, 0.05f, 2.0f); + Math_ApproachF(&pthis->cameraAt.y, GND_BOSSROOM_CENTER_Y + 53.0f, 0.05f, 1.0f); + if (pthis->timers[0] == 0) { + EnfHG* horse = (EnfHG*)pthis->actor.child; + + camera->eye = pthis->cameraEye; + camera->eyeNext = pthis->cameraEye; + camera->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->deathCamera, 0); + pthis->deathCamera = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, GND_BOSSROOM_CENTER_X, + GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z + 200.0f, 0, 0, 0, 0); + pthis->actor.child = &horse->actor; + pthis->killActor = true; + horse->killActor = true; + Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); + Flags_SetSwitch(globalCtx, 0x22); + } + break; + } + + if (bodyDecayLevel) { + Vec3f pos; + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f accelKFire = { 0.0f, 0.0f, 0.0f }; + Vec3f accelHahen = { 0.0f, -0.5f, 0.0f }; + s16 limbDecayIndex; + s16 i; + + vel.x = pthis->actor.world.pos.x - pthis->actor.prevPos.x; + vel.z = pthis->actor.world.pos.z - pthis->actor.prevPos.z; + if (bodyDecayLevel < 10) { + if (pthis->work[GND_DEATH_ENV_TIMER] == 0) { + if (globalCtx->envCtx.unk_BF == 0) { + globalCtx->envCtx.unk_BF = 3; + pthis->work[GND_DEATH_ENV_TIMER] = (s16)Rand_ZeroFloat(5.0f) + 4.0f; + globalCtx->envCtx.unk_D6 = 0x28; + } else { + globalCtx->envCtx.unk_BF = 0; + pthis->work[GND_DEATH_ENV_TIMER] = (s16)Rand_ZeroFloat(2.0f) + 2.0f; + globalCtx->envCtx.unk_D6 = 0x14; + } + } else { + pthis->work[GND_DEATH_ENV_TIMER]--; + } + + for (i = 0; i <= 0; i++) { + limbDecayIndex = pthis->work[GND_LIMB_DECAY_INDEX]; + pthis->work[GND_LIMB_DECAY_INDEX]++; + pthis->work[GND_LIMB_DECAY_INDEX] %= 25; + pos.x = pthis->bodyPartsPos[limbDecayIndex].x + Rand_CenteredFloat(5.0f); + pos.y = pthis->bodyPartsPos[limbDecayIndex].y + Rand_CenteredFloat(5.0f); + pos.z = pthis->bodyPartsPos[limbDecayIndex].z + Rand_CenteredFloat(5.0f); + accelKFire.y = 0.0f; + + if (bodyDecayLevel == 3) { + accelKFire.y = -0.2f; + accelKFire.x = (GND_BOSSROOM_CENTER_X - pos.x) * 0.002f; + accelKFire.z = (GND_BOSSROOM_CENTER_Z - pos.z) * 0.002f; + accelHahen.x = (GND_BOSSROOM_CENTER_X - pos.x) * 0.001f; + accelHahen.y = -1.0f; + accelHahen.z = (GND_BOSSROOM_CENTER_Z - pos.z) * 0.001f; + } + + EffectSsKFire_Spawn(globalCtx, &pos, &vel, &accelKFire, (s16)Rand_ZeroFloat(20.0f) + 15, + bodyDecayLevel); + if ((Rand_ZeroOne() < 0.5f) || (bodyDecayLevel == 3)) { + EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accelHahen, 0, (s16)Rand_ZeroFloat(4.0f) + 7, + HAHEN_OBJECT_DEFAULT, 10, NULL); + } + } + } else { + globalCtx->envCtx.unk_BF = 0; + globalCtx->envCtx.unk_D6 = 0x14; + } + + pthis->work[GND_BODY_DECAY_FLAG] = true; + for (i = 0; i < 5; i++) { + if (bodyDecayLevel == 1) { + BossGanondrof_ClearPixels(sDecayMaskLow, pthis->work[GND_BODY_DECAY_INDEX]); + } else if (bodyDecayLevel == 2) { + BossGanondrof_ClearPixels(sDecayMaskHigh, pthis->work[GND_BODY_DECAY_INDEX]); + } else { + BossGanondrof_ClearPixels(sDecayMaskTotal, pthis->work[GND_BODY_DECAY_INDEX]); + } + + if (pthis->work[GND_BODY_DECAY_INDEX] < 0x100) { + pthis->work[GND_BODY_DECAY_INDEX]++; + } + } + } + + if (pthis->deathCamera != 0) { + if (!holdCamera) { + Math_ApproachF(&pthis->cameraEye.x, pthis->cameraNextEye.x, pthis->cameraEyeMaxVel.x, + pthis->cameraEyeVel.x * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraEye.y, pthis->cameraNextEye.y, pthis->cameraEyeMaxVel.y, + pthis->cameraEyeVel.y * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraEye.z, pthis->cameraNextEye.z, pthis->cameraEyeMaxVel.z, + pthis->cameraEyeVel.z * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.x, pthis->cameraNextAt.x, pthis->cameraAtMaxVel.x, + pthis->cameraAtVel.x * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.y, pthis->cameraNextAt.y, pthis->cameraAtMaxVel.y, + pthis->cameraAtVel.y * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.z, pthis->cameraNextAt.z, pthis->cameraAtMaxVel.z, + pthis->cameraAtVel.z * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, pthis->cameraAccel); + } + + Gameplay_CameraSetAtEye(globalCtx, pthis->deathCamera, &pthis->cameraAt, &pthis->cameraEye); + } +} + +void BossGanondrof_CollisionCheck(BossGanondrof* pthis, GlobalContext* globalCtx) { + s32 acHit; + EnfHG* horse = (EnfHG*)pthis->actor.child; + ColliderInfo* hurtbox = NULL; + + if (pthis->work[GND_INVINC_TIMER] != 0) { + pthis->work[GND_INVINC_TIMER]--; + pthis->returnCount = 0; + pthis->colliderBody.base.acFlags &= ~AC_HIT; + } else { + acHit = pthis->colliderBody.base.acFlags & AC_HIT; + if ((acHit && ((s8)pthis->actor.colChkInfo.health > 0)) || (pthis->returnCount != 0)) { + if (acHit) { + pthis->colliderBody.base.acFlags &= ~AC_HIT; + hurtbox = pthis->colliderBody.info.acHitInfo; + } + if (pthis->flyMode != GND_FLY_PAINTING) { + if (acHit && (pthis->actionFunc != BossGanondrof_Stunned) && (hurtbox->toucher.dmgFlags & 0x0001F8A4)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_WALK_GROUND - SFX_FLAG); + osSyncPrintf("hit != 0 \n"); + } else if (pthis->actionFunc != BossGanondrof_Charge) { + if (pthis->returnCount == 0) { + u8 dmg; + u8 canKill = false; + s32 dmgFlags = hurtbox->toucher.dmgFlags; + + if (dmgFlags & 0x80) { + return; + } + dmg = CollisionCheck_GetSwordDamage(dmgFlags); + (dmg == 0) ? (dmg = 2) : (canKill = true); + if (((s8)pthis->actor.colChkInfo.health > 2) || canKill) { + pthis->actor.colChkInfo.health -= dmg; + } + + if ((s8)pthis->actor.colChkInfo.health <= 0) { + BossGanondrof_SetupDeath(pthis, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + return; + } + } + BossGanondrof_SetupStunned(pthis, globalCtx); + if (pthis->returnCount >= 2) { + pthis->timers[0] = 120; + } + pthis->work[GND_INVINC_TIMER] = 10; + horse->hitTimer = 20; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_DAMAGE); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_WALK_GROUND - SFX_FLAG); + } + } else if (acHit && (hurtbox->toucher.dmgFlags & 0x0001F8A4)) { + pthis->work[GND_INVINC_TIMER] = 10; + pthis->actor.colChkInfo.health -= 2; + horse->hitTimer = 20; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_DAMAGE); + } + pthis->returnCount = 0; + } + } +} + +void BossGanondrof_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 cs; + f32 sn; + f32 legRotTargetY; + f32 legRotTargetZ; + f32 legSplitTarget; + s32 pad2; + s16 i; + s32 pad; + BossGanondrof* pthis = (BossGanondrof*)thisx; + EnfHG* horse; + + osSyncPrintf("MOVE START %d\n", pthis->actor.params); + pthis->actor.flags &= ~ACTOR_FLAG_10; + pthis->colliderBody.base.colType = COLTYPE_HIT3; + if (pthis->killActor) { + Actor_Kill(&pthis->actor); + return; + } + pthis->work[GND_VARIANCE_TIMER]++; + horse = (EnfHG*)pthis->actor.child; + osSyncPrintf("MOVE START EEEEEEEEEEEEEEEEEEEEEE%d\n", pthis->actor.params); + + pthis->actionFunc(pthis, globalCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i]) { + pthis->timers[i]--; + } + } + if (pthis->work[GND_UNKTIMER_1]) { + pthis->work[GND_UNKTIMER_1]--; + } + if (pthis->work[GND_UNKTIMER_2]) { + pthis->work[GND_UNKTIMER_2]--; + } + + if (pthis->actionFunc != BossGanondrof_Death) { + BossGanondrof_CollisionCheck(pthis, globalCtx); + } + + osSyncPrintf("MOVE END\n"); + BossGanondrof_SetColliderPos(&pthis->targetPos, &pthis->colliderBody); + BossGanondrof_SetColliderPos(&pthis->spearTip, &pthis->colliderSpear); + if ((pthis->flyMode == GND_FLY_PAINTING) && !horse->bossGndInPainting) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + } + if ((pthis->actionFunc == BossGanondrof_Stunned) && (pthis->timers[0] > 1)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + } else if (pthis->actionFunc == BossGanondrof_Block) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + } else if (pthis->actionFunc == BossGanondrof_Charge) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSpear.base); + } + + pthis->actor.focus.pos = pthis->targetPos; + + sn = Math_SinS(-pthis->actor.shape.rot.y); + cs = Math_CosS(-pthis->actor.shape.rot.y); + legRotTargetY = ((sn * pthis->actor.velocity.z) + (cs * pthis->actor.velocity.x)) * 300.0f; + legRotTargetZ = ((-sn * pthis->actor.velocity.x) + (cs * pthis->actor.velocity.z)) * 300.0f; + Math_ApproachF(&pthis->legRotY, legRotTargetY, 1.0f, 600.0f); + Math_ApproachF(&pthis->legRotZ, legRotTargetZ, 1.0f, 600.0f); + if ((pthis->flyMode != GND_FLY_PAINTING) && (pthis->actionFunc != BossGanondrof_Stunned) && + (pthis->deathState == NOT_DEAD)) { + legSplitTarget = (Math_SinS(pthis->work[GND_VARIANCE_TIMER] * 0x8DC) * -500.0f) - 500.0f; + } else { + legSplitTarget = 0.0f; + } + + Math_ApproachF(&pthis->legSplitY, legSplitTarget, 1.0f, 100.0f); + if (pthis->shockTimer != 0) { + s16 j; + + pthis->shockTimer--; + osSyncPrintf("F 1\n"); + for (j = 0; j < 7; j++) { + osSyncPrintf("F 15\n"); + EffectSsFhgFlash_SpawnShock(globalCtx, &pthis->actor, &pthis->actor.world.pos, 45, FHGFLASH_SHOCK_PG); + } + osSyncPrintf("F 2\n"); + } + + if (pthis->actor.params == GND_REAL_BOSS) { + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->spearTip.x, pthis->spearTip.y, pthis->spearTip.z, 255, 255, 255, + 200); + } +} + +s32 BossGanondrof_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossGanondrof* pthis = (BossGanondrof*)thisx; + + switch (limbIndex) { + case 15: + if ((pthis->actionFunc == BossGanondrof_Intro) && pthis->work[GND_MASK_OFF]) { + *dList = gPhantomGanonFaceDL; + } + rot->y += pthis->rideRotY[limbIndex]; + rot->z += pthis->rideRotZ[limbIndex]; + break; + + case 19: + rot->y += pthis->legRotY + pthis->legSplitY; + rot->z += pthis->legRotZ; + break; + + case 20: + rot->y += pthis->legRotY + pthis->legSplitY; + rot->z += pthis->legRotZ; + break; + + case 21: + rot->y += pthis->legRotY + pthis->legSplitY; + rot->z += pthis->legRotZ; + break; + + case 23: + rot->y += pthis->legRotY - pthis->legSplitY; + rot->z += pthis->legRotZ; + break; + + case 24: + rot->y += pthis->legRotY - pthis->legSplitY; + rot->z += pthis->legRotZ; + break; + + case 25: + rot->y += pthis->legRotY - pthis->legSplitY; + rot->z += pthis->legRotZ; + break; + + case 5: + case 6: + case 7: + rot->y += pthis->armRotY; + rot->z += pthis->armRotZ; + break; + + case 8: + case 9: + case 10: + rot->y += pthis->armRotY; + rot->z += pthis->armRotZ; + break; + + case 13: + if (pthis->deathState != NOT_DEAD) { + *dList = NULL; + } + default: + rot->y += pthis->rideRotY[limbIndex]; + rot->z += pthis->rideRotZ[limbIndex]; + break; + } + + return 0; +} + +void BossGanondrof_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + static Vec3f spearVec = { 0.0f, 0.0f, 6000.0f }; + + BossGanondrof* pthis = (BossGanondrof*)thisx; + + if (limbIndex == 14) { + Matrix_MultVec3f(&zeroVec, &pthis->targetPos); + } else if (limbIndex == 13) { + Matrix_MultVec3f(&spearVec, &pthis->spearTip); + } + + if (((pthis->flyMode != GND_FLY_PAINTING) || (pthis->actionFunc == BossGanondrof_Intro)) && (limbIndex <= 25)) { + Matrix_MultVec3f(&zeroVec, &pthis->bodyPartsPos[limbIndex - 1]); + } +} + +Gfx* BossGanondrof_GetClearPixelDList(GraphicsContext* gfxCtx) { + Gfx* dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 4); + Gfx* dListHead = dList; + + gDPPipeSync(dListHead++); + gDPSetRenderMode(dListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); + gSPClearGeometryMode(dListHead++, G_CULL_BACK); + gSPEndDisplayList(dListHead++); + + return dList; +} + +Gfx* BossGanondrof_GetNullDList(GraphicsContext* gfxCtx) { + Gfx* dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 1); + Gfx* dListHead = dList; + + gSPEndDisplayList(dListHead++); + return dList; +} + +void BossGanondrof_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossGanondrof* pthis = (BossGanondrof*)thisx; + EnfHG* horse; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganondrof.c", 3716); + osSyncPrintf("MOVE P = %x\n", pthis->actor.update); + osSyncPrintf("STOP TIMER = %d ==============\n", pthis->actor.freezeTimer); + horse = (EnfHG*)pthis->actor.child; + if (pthis->flyMode == GND_FLY_PAINTING) { + Matrix_RotateY((horse->turnRot * 3.1416f) / (f32)0x8000, MTXMODE_APPLY); + } + + osSyncPrintf("YP %f\n", pthis->actor.world.pos.y); + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->work[GND_INVINC_TIMER] & 4) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099); + } else { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, (u32)horse->warpColorFilterR, (u32)horse->warpColorFilterG, + (u32)horse->warpColorFilterB, 0, (s32)horse->warpColorFilterUnk1 + 995, + (s32)horse->warpColorFilterUnk2 + 1000); + } + + osSyncPrintf("DRAW 11\n"); + osSyncPrintf("EYE_COL %d\n", (s16)pthis->fwork[GND_EYE_BRIGHTNESS]); + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->fwork[GND_EYE_BRIGHTNESS], (s16)pthis->fwork[GND_EYE_BRIGHTNESS], + (s16)pthis->fwork[GND_EYE_BRIGHTNESS], (s16)pthis->fwork[GND_EYE_ALPHA]); + if (pthis->work[GND_BODY_DECAY_FLAG]) { + gSPSegment(POLY_OPA_DISP++, 0x08, BossGanondrof_GetClearPixelDList(globalCtx->state.gfxCtx)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, BossGanondrof_GetNullDList(globalCtx->state.gfxCtx)); + } + + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, BossGanondrof_OverrideLimbDraw, + BossGanondrof_PostLimbDraw, pthis); + osSyncPrintf("DRAW 22\n"); + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_ganondrof.c", 3814); + osSyncPrintf("DRAW END %d\n", pthis->actor.params); +} diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c deleted file mode 100644 index ef534e423..000000000 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ /dev/null @@ -1,2165 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GOMA_Z_BOSS_GOMA_C -#include "actor_common.h" -#include "z_boss_goma.h" -#include "objects/object_goma/object_goma.h" -#include "overlays/actors/ovl_En_Goma/z_en_goma.h" -#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/graph.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -// IRIS_FOLLOW: gohma looks towards the player (iris rotation) -// BONUS_IFRAMES: gain invincibility frames when the player does something (throwing things?), or -// randomly (see BossGoma_UpdateEye) -typedef enum { - EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES, // default, allows not drawing lens and iris when eye is closed - EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES, - EYESTATE_IRIS_FOLLOW_NO_IFRAMES -} GohmaEyeState; - -typedef enum { - VISUALSTATE_RED, // main/eye: red - VISUALSTATE_DEFAULT, // main: greenish cyan, blinks with dark gray every 16 frames; eye: white - VISUALSTATE_DEFEATED, // main/eye: dark gray - VISUALSTATE_STUNNED = 4, // main: greenish cyan, alternates with blue; eye: greenish cyan - VISUALSTATE_HIT // main: greenish cyan, alternates with red; eye: greenish cyan -} GohmaVisualState; - -void BossGoma_Init(Actor* thisx, GlobalContext* globalCtx); -void BossGoma_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossGoma_Update(Actor* thisx, GlobalContext* globalCtx); -void BossGoma_Draw(Actor* thisx, GlobalContext* globalCtx); - -void BossGoma_SetupEncounter(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_Encounter(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_Defeated(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorAttackPosture(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorPrepareAttack(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorAttack(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorDamaged(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorLandStruckDown(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorLand(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorStunned(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FallJump(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FallStruckDown(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_CeilingSpawnGohmas(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_CeilingPrepareSpawnGohmas(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorIdle(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_CeilingIdle(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_FloorMain(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_WallClimb(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_CeilingMoveToCenter(BossGoma* this, GlobalContext* globalCtx); -void BossGoma_SpawnChildGohma(BossGoma* this, GlobalContext* globalCtx, s16 i); - -const ActorInit Boss_Goma_InitVars = { - ACTOR_BOSS_GOMA, - ACTORCAT_BOSS, - FLAGS, - OBJECT_GOMA, - sizeof(BossGoma), - (ActorFunc)BossGoma_Init, - (ActorFunc)BossGoma_Destroy, - (ActorFunc)BossGoma_Update, - (ActorFunc)BossGoma_Draw, -}; - -static ColliderJntSphElementInit sColliderJntSphElementInit[13] = { - { - { - ELEMTYPE_UNK3, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_EYE, { { 0, 0, 1200 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_TAIL4, { { 0, 0, 0 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_TAIL3, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_TAIL2, { { 0, 0, 0 }, 12 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_TAIL1, { { 0, 0, 0 }, 25 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_R_FEET, { { 0, 0, 0 }, 30 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_R_SHIN, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_R_THIGH_SHELL, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_L_ANTENNA_CLAW, { { 0, 0, 0 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_R_ANTENNA_CLAW, { { 0, 0, 0 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_L_FEET, { { 0, 0, 0 }, 30 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_L_SHIN, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK2, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { BOSSGOMA_LIMB_L_THIGH_SHELL, { { 0, 0, 0 }, 15 }, 100 }, - }, -}; - -static ColliderJntSphInit sColliderJntSphInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 13, - sColliderJntSphElementInit, -}; - -static u8 sClearPixelTableFirstPass[16 * 16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 -}; - -static u8 sClearPixelTableSecondPass[16 * 16] = { - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -}; - -// indexed by limb (where the root limb is 1) -static u8 sDeadLimbLifetime[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 30, // tail end/last part - 40, // tail 2nd to last part - 0, 0, 0, 0, 0, 0, 0, 0, - 10, // back of right claw/hand - 15, // front of right claw/hand - 21, // part of right arm (inner) - 0, 0, - 25, // part of right arm (shell) - 0, 0, - 31, // part of right arm (shell on shoulder) - 35, // part of right arm (shoulder) - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 43, // end of left antenna - 48, // middle of left antenna - 53, // start of left antenna - 0, 0, 0, 0, - 42, // end of right antenna - 45, // middle of right antenna - 53, // start of right antenna - 0, 0, 0, 0, 0, 0, - 11, // back of left claw/hand - 15, // front of left claw/hand - 21, // part of left arm (inner) - 0, 0, - 25, // part of left arm (shell) - 0, 0, - 30, // part of left arm (shell on shoulder) - 35, // part of left arm (shoulder) - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -/** - * Sets the `i`th pixel of a 16x16 RGBA16 image to 0 (transparent black) - * according to the `clearPixelTable` - */ -void BossGoma_ClearPixels16x16Rgba16(s16* rgba16image, u8* clearPixelTable, s16 i) { - if (clearPixelTable[i]) { - rgba16image[i] = 0; - } -} - -/** - * Sets the `i`th 2x2 pixels block of a 32x32 RGBA16 image to 0 (transparent black) - * according to the `clearPixelTable` - */ -void BossGoma_ClearPixels32x32Rgba16(s16* rgba16image, u8* clearPixelTable, s16 i) { - s16* targetPixel; - - if (clearPixelTable[i]) { - // address of the top left pixel in a 2x2 pixels block located at - // (i & 0xF, i >> 4) in a 16x16 grid of 2x2 pixels - targetPixel = (s32)rgba16image + (s16)((i & 0xF) * 2 + (i & 0xF0) * 4) * 2; - // set the 2x2 block of pixels to 0 - targetPixel[0] = 0; - targetPixel[1] = 0; - targetPixel[32 + 0] = 0; - targetPixel[32 + 1] = 0; - } -} - -/** - * Clear pixels from Gohma's textures - */ -void BossGoma_ClearPixels(u8* clearPixelTable, s16 i) { - BossGoma_ClearPixels16x16Rgba16(SEGMENTED_TO_VIRTUAL(gGohmaBodyTex), clearPixelTable, i); - BossGoma_ClearPixels16x16Rgba16(SEGMENTED_TO_VIRTUAL(gGohmaShellUndersideTex), clearPixelTable, i); - BossGoma_ClearPixels16x16Rgba16(SEGMENTED_TO_VIRTUAL(gGohmaDarkShellTex), clearPixelTable, i); - BossGoma_ClearPixels16x16Rgba16(SEGMENTED_TO_VIRTUAL(gGohmaEyeTex), clearPixelTable, i); - - BossGoma_ClearPixels32x32Rgba16(SEGMENTED_TO_VIRTUAL(gGohmaShellTex), clearPixelTable, i); - BossGoma_ClearPixels32x32Rgba16(SEGMENTED_TO_VIRTUAL(gGohmaIrisTex), clearPixelTable, i); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x01, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), -}; - -void BossGoma_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossGoma* this = (BossGoma*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 4000.0f, ActorShadow_DrawCircle, 150.0f); - SkelAnime_Init(globalCtx, &this->skelanime, &gGohmaSkel, &gGohmaIdleCrouchedAnim, NULL, NULL, 0); - Animation_PlayLoop(&this->skelanime, &gGohmaIdleCrouchedAnim); - this->actor.shape.rot.x = -0x8000; // upside-down - this->eyeIrisScaleX = 1.0f; - this->eyeIrisScaleY = 1.0f; - this->unusedInitX = this->actor.world.pos.x; - this->unusedInitZ = this->actor.world.pos.z; - this->actor.world.pos.y = -300.0f; // ceiling - this->actor.gravity = 0.0f; - BossGoma_SetupEncounter(this, globalCtx); - this->actor.colChkInfo.health = 10; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems); - - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { - Actor_Kill(&this->actor); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, -640.0f, 0.0f, 0, 0, - 0, WARP_DUNGEON_CHILD); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 141.0f, -640.0f, -84.0f, 0, 0, 0, 0); - } -} - -void BossGoma_PlayEffectsAndSfx(BossGoma* this, GlobalContext* globalCtx, s16 arg2, s16 amountMinus1) { - if (arg2 == 0 || arg2 == 1 || arg2 == 3) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightHandBackLimbWorldPos, 25.0f, amountMinus1, 8.0f, - 500, 10, 1); - } - - if (arg2 == 0 || arg2 == 2 || arg2 == 3) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftHandBackLimbWorldPos, 25.0f, amountMinus1, 8.0f, - 500, 10, 1); - } - - if (arg2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DOWN); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_WALK); - } -} - -void BossGoma_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BossGoma* this = (BossGoma*)thisx; - - SkelAnime_Free(&this->skelanime, globalCtx); - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -/** - * When Gohma is hit and its health drops to 0 - */ -void BossGoma_SetupDefeated(BossGoma* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelanime, &gGohmaDeathAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaDeathAnim), - ANIMMODE_ONCE, -2.0f); - this->actionFunc = BossGoma_Defeated; - this->disableGameplayLogic = true; - this->decayingProgress = 0; - this->noBackfaceCulling = false; - this->framesUntilNextAction = 1200; - this->actionState = 0; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actor.speedXZ = 0.0f; - this->actor.shape.shadowScale = 0.0f; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DEAD); -} - -/** - * Initial action setup, with Gohma waiting on the ceiling for the fight to start. - */ -void BossGoma_SetupEncounter(BossGoma* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gGohmaWalkAnim); - - Animation_Change(&this->skelanime, &gGohmaWalkAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -15.0f); - this->actionFunc = BossGoma_Encounter; - this->actionState = 0; - this->disableGameplayLogic = true; - globalCtx->envCtx.unk_BF = 4; - globalCtx->envCtx.unk_D6 = 0xFF; -} - -/** - * On the floor and not doing anything for 20-30 frames, before going back to BossGoma_FloorMain - */ -void BossGoma_SetupFloorIdle(BossGoma* this) { - f32 lastFrame = Animation_GetLastFrame(&gGohmaIdleCrouchedAnim); - - this->framesUntilNextAction = Rand_S16Offset(20, 30); - Animation_Change(&this->skelanime, &gGohmaIdleCrouchedAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -5.0f); - this->actionFunc = BossGoma_FloorIdle; -} - -/** - * On the ceiling and not doing anything for 20-30 frames, leads to spawning children gohmas - */ -void BossGoma_SetupCeilingIdle(BossGoma* this) { - this->framesUntilNextAction = Rand_S16Offset(20, 30); - Animation_Change(&this->skelanime, &gGohmaHangAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaHangAnim), - ANIMMODE_LOOP, -5.0f); - this->actionFunc = BossGoma_CeilingIdle; -} - -/** - * When the player killed all children gohmas - */ -void BossGoma_SetupFallJump(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaLandAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossGoma_FallJump; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -2.0f; -} - -/** - * When the player successfully hits Gohma on the ceiling - */ -void BossGoma_SetupFallStruckDown(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaCrashAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -5.0f); - this->actionFunc = BossGoma_FallStruckDown; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -2.0f; -} - -void BossGoma_SetupCeilingSpawnGohmas(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaLayEggsAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaLayEggsAnim), - ANIMMODE_LOOP, -15.0f); - this->actionFunc = BossGoma_CeilingSpawnGohmas; - this->spawnGohmasActionTimer = 0; -} - -void BossGoma_SetupCeilingPrepareSpawnGohmas(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaPrepareEggsAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaPrepareEggsAnim), ANIMMODE_LOOP, -10.0f); - this->actionFunc = BossGoma_CeilingPrepareSpawnGohmas; - this->framesUntilNextAction = 70; -} - -void BossGoma_SetupWallClimb(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaClimbAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaClimbAnim), - ANIMMODE_LOOP, -10.0f); - this->actionFunc = BossGoma_WallClimb; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; -} - -/** - * Gohma either reached the ceiling after climbing a wall, or is waiting for the player to kill the (children) Gohmas. - */ -void BossGoma_SetupCeilingMoveToCenter(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaWalkAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaWalkAnim), - ANIMMODE_LOOP, -5.0f); - this->actionFunc = BossGoma_CeilingMoveToCenter; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - this->framesUntilNextAction = Rand_S16Offset(30, 60); -} - -/** - * Root action when on the floor, leads to attacking or climbing. - */ -void BossGoma_SetupFloorMain(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaWalkCrouchedAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaWalkCrouchedAnim), ANIMMODE_LOOP, -5.0f); - this->actionFunc = BossGoma_FloorMain; - this->framesUntilNextAction = Rand_S16Offset(70, 110); -} - -/** - * Gohma jumped to the floor on its own, after the player has killed its children Gohmas. - */ -void BossGoma_SetupFloorLand(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaLandAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaLandAnim), - ANIMMODE_ONCE, -2.0f); - this->actionFunc = BossGoma_FloorLand; - this->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaLandAnim); -} - -/** - * Gohma was shot by the player down from the ceiling. - */ -void BossGoma_SetupFloorLandStruckDown(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaCrashAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaCrashAnim), - ANIMMODE_ONCE, -2.0f); - this->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaCrashAnim); - this->actionFunc = BossGoma_FloorLandStruckDown; - this->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaCrashAnim); -} - -/** - * Gohma is vulnerable, from being struck down from the ceiling or on the ground. - */ -void BossGoma_SetupFloorStunned(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaStunnedAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaStunnedAnim), - ANIMMODE_LOOP, -2.0f); - this->actionFunc = BossGoma_FloorStunned; -} - -/** - * Take an attack posture, when the player is close enough. - */ -void BossGoma_SetupFloorAttackPosture(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaPrepareAttackAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaPrepareAttackAnim), ANIMMODE_ONCE, -10.0f); - this->actionFunc = BossGoma_FloorAttackPosture; -} - -/** - * Leads to BossGoma_FloorAttack after 1 frame - */ -void BossGoma_SetupFloorPrepareAttack(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaStandAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaStandAnim), - ANIMMODE_LOOP, -10.0f); - this->actionFunc = BossGoma_FloorPrepareAttack; - this->framesUntilNextAction = 0; -} - -void BossGoma_SetupFloorAttack(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaAttackAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaAttackAnim), - ANIMMODE_ONCE, -10.0f); - this->actionFunc = BossGoma_FloorAttack; - this->actionState = 0; - this->framesUntilNextAction = 0; -} - -/** - * Plays an animation for Gohma being hit (while stunned) - * The setup and the action preserve timers apart from the patience one, notably `framesUntilNextAction` which is used - * as the stun duration - */ -void BossGoma_SetupFloorDamaged(BossGoma* this) { - Animation_Change(&this->skelanime, &gGohmaDamageAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaDamageAnim), - ANIMMODE_ONCE, -2.0f); - this->actionFunc = BossGoma_FloorDamaged; -} - -void BossGoma_UpdateCeilingMovement(BossGoma* this, GlobalContext* globalCtx, f32 dz, f32 targetSpeedXZ, - s16 rotateTowardsCenter) { - static Vec3f velInit = { 0.0f, 0.0f, 0.0f }; - static Vec3f accelInit = { 0.0f, -0.5f, 0.0f }; - static Vec3f roomCenter = { -150.0f, 0.0f, -350.0f }; - Vec3f* basePos = NULL; - s16 i; - Vec3f vel; - Vec3f accel; - Vec3f pos; - - roomCenter.z += dz; // dz is always 0 - SkelAnime_Update(&this->skelanime); - Math_ApproachF(&this->actor.speedXZ, targetSpeedXZ, 0.5f, 2.0f); - - if (rotateTowardsCenter) { - Math_ApproachS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &roomCenter) + 0x8000, 3, - 0x3E8); - } - - if (Animation_OnFrame(&this->skelanime, 9.0f)) { - basePos = &this->rightHandBackLimbWorldPos; - } else if (Animation_OnFrame(&this->skelanime, 1.0f)) { - basePos = &this->leftHandBackLimbWorldPos; - } - - if (basePos != NULL) { - for (i = 0; i < 5; i++) { - vel = velInit; - accel = accelInit; - pos.x = Rand_CenteredFloat(70.0f) + basePos->x; - pos.y = Rand_ZeroFloat(30.0f) + basePos->y; - pos.z = Rand_CenteredFloat(70.0f) + basePos->z; - EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accel, 0, (s16)(Rand_ZeroOne() * 5.0f) + 10, -1, 10, NULL); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_HIGH); - } -} - -void BossGoma_SetupEncounterState4(BossGoma* this, GlobalContext* globalCtx) { - Player* player; - Camera* camera; - - camera = Gameplay_GetCamera(globalCtx, 0); - player = GET_PLAYER(globalCtx); - this->actionState = 4; - this->actor.flags |= ACTOR_FLAG_0; - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 1); - this->subCameraId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, 0, 3); - Gameplay_ChangeCameraStatus(globalCtx, this->subCameraId, 7); - Animation_Change(&this->skelanime, &gGohmaEyeRollAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaEyeRollAnim), - ANIMMODE_ONCE, 0.0f); - this->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaEyeRollAnim); - - // room center (todo: defines for hardcoded positions relative to room center) - this->actor.world.pos.x = -150.0f; - this->actor.world.pos.z = -350.0f; - - // room entrance, towards center - player->actor.world.pos.x = 150.0f; - player->actor.world.pos.z = 300.0f; - - player->actor.world.rot.y = player->actor.shape.rot.y = -0x705C; - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) + 0x8000; - - // room entrance, closer to room center - this->subCameraEye.x = 90.0f; - this->subCameraEye.z = 170.0f; - this->subCameraEye.y = camera->eye.y + 20.0f; - - this->framesUntilNextAction = 50; - - this->subCameraAt.x = this->actor.world.pos.x; - this->subCameraAt.y = this->actor.world.pos.y; - this->subCameraAt.z = this->actor.world.pos.z; - - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); -} - -/** - * Spawns the door once the player entered - * Wait for the player to look at Gohma on the ceiling - * Handles the "meeting Gohma" cutscene, including boss card - * - * Skips the door and look-at-Gohma puzzle if the player already reached the boss card part before - */ -void BossGoma_Encounter(BossGoma* this, GlobalContext* globalCtx) { - Camera* cam; - Player* player = GET_PLAYER(globalCtx); - s32 pad[2]; - - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - - switch (this->actionState) { - case 0: // wait for the player to enter the room - // entrance of the boss room - if (fabsf(player->actor.world.pos.x - 150.0f) < 60.0f && - fabsf(player->actor.world.pos.z - 350.0f) < 60.0f) { - if (gSaveContext.eventChkInf[7] & 1) { - BossGoma_SetupEncounterState4(this, globalCtx); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_SHUTTER, 164.72f, - -480.0f, 397.68002f, 0, -0x705C, 0, 0x180); - } else { - func_8002DF54(globalCtx, &this->actor, 8); - this->actionState = 1; - } - } - break; - - case 1: // player entered the room - func_80064520(globalCtx, &globalCtx->csCtx); - this->subCameraId = Gameplay_CreateSubCamera(globalCtx); - osSyncPrintf("MAKE CAMERA !!! 1 !!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - Gameplay_ChangeCameraStatus(globalCtx, 0, 1); - Gameplay_ChangeCameraStatus(globalCtx, this->subCameraId, 7); - this->actionState = 2; - // ceiling center - this->actor.world.pos.x = -150.0f; - this->actor.world.pos.y = -320.0f; - this->actor.world.pos.z = -350.0f; - // room entrance - player->actor.world.pos.x = 150.0f; - player->actor.world.pos.z = 300.0f; - // near ceiling center - this->subCameraEye.x = -350.0f; - this->subCameraEye.y = -310.0f; - this->subCameraEye.z = -350.0f; - // below room entrance - this->subCameraAt.x = player->actor.world.pos.x; - this->subCameraAt.y = player->actor.world.pos.y - 200.0f + 25.0f; - this->subCameraAt.z = player->actor.world.pos.z; - this->framesUntilNextAction = 50; - this->timer = 80; - this->frameCount = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - // fall-through - case 2: // zoom on player from room center - // room entrance, towards center - player->actor.shape.rot.y = -0x705C; - player->actor.world.pos.x = 150.0f; - player->actor.world.pos.z = 300.0f; - player->actor.world.rot.y = player->actor.shape.rot.y; - player->actor.speedXZ = 0.0f; - - if (this->framesUntilNextAction == 0) { - // (-20, 25, -65) is towards room center - Math_ApproachF(&this->subCameraEye.x, player->actor.world.pos.x - 20.0f, 0.049999997f, - this->subCameraFollowSpeed * 50.0f); - Math_ApproachF(&this->subCameraEye.y, player->actor.world.pos.y + 25.0f, 0.099999994f, - this->subCameraFollowSpeed * 130.0f); - Math_ApproachF(&this->subCameraEye.z, player->actor.world.pos.z - 65.0f, 0.049999997f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraFollowSpeed, 0.29999998f, 1.0f, 0.0050000004f); - if (this->timer == 0) { - Math_ApproachF(&this->subCameraAt.y, player->actor.world.pos.y + 35.0f, 0.099999994f, - this->subCameraFollowSpeed * 30.0f); - } - this->subCameraAt.x = player->actor.world.pos.x; - this->subCameraAt.z = player->actor.world.pos.z; - } - - Gameplay_CameraSetAtEye(globalCtx, 0, &this->subCameraAt, &this->subCameraEye); - - if (this->frameCount == 176) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_SHUTTER, 164.72f, -480.0f, - 397.68002f, 0, -0x705C, 0, SHUTTER_GOHMA_BLOCK << 6); - } - - if (this->frameCount == 176) { - globalCtx->envCtx.unk_BF = 3; - globalCtx->envCtx.unk_D6 = 0xFFFF; - } - - if (this->frameCount == 190) { - func_8002DF54(globalCtx, &this->actor, 2); - } - - if (this->frameCount >= 228) { - cam = Gameplay_GetCamera(globalCtx, 0); - cam->eye = this->subCameraEye; - cam->eyeNext = this->subCameraEye; - cam->at = this->subCameraAt; - func_800C08AC(globalCtx, this->subCameraId, 0); - this->subCameraId = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->actionState = 3; - } - break; - - case 3: // wait for the player to look at Gohma - if (fabsf(this->actor.projectedPos.x) < 150.0f && fabsf(this->actor.projectedPos.y) < 250.0f && - this->actor.projectedPos.z < 800.0f && this->actor.projectedPos.z > 0.0f) { - this->lookedAtFrames++; - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - Math_ApproachS(&this->actor.world.rot.y, - Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) + 0x8000, 2, - 0xBB8); - this->eyeLidBottomRotX = this->eyeLidTopRotX = this->eyeIrisRotX = this->eyeIrisRotY = 0; - } else { - this->lookedAtFrames = 0; - BossGoma_UpdateCeilingMovement(this, globalCtx, 0.0f, -5.0f, true); - } - - if (this->lookedAtFrames > 15) { - BossGoma_SetupEncounterState4(this, globalCtx); - } - break; - - case 4: // focus Gohma on the ceiling - if (Animation_OnFrame(&this->skelanime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DEMO_EYE); - } - - if (this->framesUntilNextAction <= 40) { - // (22, -25, 45) is towards room entrance - Math_ApproachF(&this->subCameraEye.x, this->actor.world.pos.x + 22.0f, 0.2f, 100.0f); - Math_ApproachF(&this->subCameraEye.y, this->actor.world.pos.y - 25.0f, 0.2f, 100.0f); - Math_ApproachF(&this->subCameraEye.z, this->actor.world.pos.z + 45.0f, 0.2f, 100.0f); - Math_ApproachF(&this->subCameraAt.x, this->actor.world.pos.x, 0.2f, 100.0f); - Math_ApproachF(&this->subCameraAt.y, this->actor.world.pos.y + 5.0f, 0.2f, 100.0f); - Math_ApproachF(&this->subCameraAt.z, this->actor.world.pos.z, 0.2f, 100.0f); - - if (this->framesUntilNextAction == 30) { - globalCtx->envCtx.unk_BF = 4; - } - - if (this->framesUntilNextAction < 20) { - SkelAnime_Update(&this->skelanime); - Math_ApproachF(&this->eyeIrisScaleX, 1.0f, 0.8f, 0.4f); - Math_ApproachF(&this->eyeIrisScaleY, 1.0f, 0.8f, 0.4f); - - if (Animation_OnFrame(&this->skelanime, 36.0f)) { - this->eyeIrisScaleX = 1.8f; - this->eyeIrisScaleY = 1.8f; - } - - if (Animation_OnFrame(&this->skelanime, this->currentAnimFrameCount)) { - this->actionState = 5; - Animation_Change(&this->skelanime, &gGohmaWalkAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gGohmaWalkAnim), ANIMMODE_LOOP, -5.0f); - this->framesUntilNextAction = 30; - this->subCameraFollowSpeed = 0.0f; - } - } - } - break; - - case 5: // running on the ceiling - // (98, 0, 85) is towards room entrance - Math_ApproachF(&this->subCameraEye.x, this->actor.world.pos.x + 8.0f + 90.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraEye.y, player->actor.world.pos.y, 0.1f, this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraEye.z, this->actor.world.pos.z + 45.0f + 40.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraFollowSpeed, 1.0f, 1.0f, 0.05f); - this->subCameraAt.x = this->actor.world.pos.x; - this->subCameraAt.y = this->actor.world.pos.y; - this->subCameraAt.z = this->actor.world.pos.z; - - if (this->framesUntilNextAction < 0) { - //! @bug ? unreachable, timer is >= 0 - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 2.0f); - } else { - BossGoma_UpdateCeilingMovement(this, globalCtx, 0.0f, -7.5f, false); - } - - if (this->framesUntilNextAction == 0) { - Animation_Change(&this->skelanime, &gGohmaHangAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaHangAnim), - ANIMMODE_LOOP, -5.0f); - } - - if (this->framesUntilNextAction == 0) { - this->actionState = 9; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -2.0f; - Animation_Change(&this->skelanime, &gGohmaInitialLandingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaInitialLandingAnim), ANIMMODE_ONCE, -5.0f); - player->actor.world.pos.x = 0.0f; - player->actor.world.pos.z = -30.0f; - } - break; - - case 9: // falling from the ceiling - Math_ApproachF(&this->subCameraEye.x, this->actor.world.pos.x + 8.0f + 90.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraEye.y, player->actor.world.pos.y + 10.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraEye.z, this->actor.world.pos.z + 45.0f + 40.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - this->subCameraAt.x = this->actor.world.pos.x; - this->subCameraAt.y = this->actor.world.pos.y; - this->subCameraAt.z = this->actor.world.pos.z; - SkelAnime_Update(&this->skelanime); - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - Math_ApproachS(&this->actor.world.rot.y, - Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor), 2, 0x7D0); - - if (this->actor.bgCheckFlags & 1) { - this->actionState = 130; - this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelanime, &gGohmaInitialLandingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaInitialLandingAnim), ANIMMODE_ONCE, -2.0f); - this->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaInitialLandingAnim); - BossGoma_PlayEffectsAndSfx(this, globalCtx, 0, 5); - this->framesUntilNextAction = 15; - func_800A9F6C(0.0f, 0xC8, 0x14, 0x14); - } - break; - - case 130: // focus Gohma on the ground - Math_ApproachF(&this->subCameraEye.x, this->actor.world.pos.x + 8.0f + 90.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraEye.y, player->actor.world.pos.y + 10.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachF(&this->subCameraEye.z, this->actor.world.pos.z + 45.0f + 40.0f, 0.1f, - this->subCameraFollowSpeed * 30.0f); - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - Math_ApproachS(&this->actor.world.rot.y, - Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor), 2, 0x7D0); - SkelAnime_Update(&this->skelanime); - this->subCameraAt.x = this->actor.world.pos.x; - this->subCameraAt.z = this->actor.world.pos.z; - - if (this->framesUntilNextAction != 0) { - f32 s = sinf(this->framesUntilNextAction * 3.1415f * 0.5f); - - this->subCameraAt.y = this->framesUntilNextAction * s * 0.7f + this->actor.world.pos.y; - } else { - Math_ApproachF(&this->subCameraAt.y, this->actor.focus.pos.y, 0.1f, 10.0f); - } - - if (Animation_OnFrame(&this->skelanime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_CRY1); - - if (!(gSaveContext.eventChkInf[7] & 1)) { - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gGohmaTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); - } - - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); - gSaveContext.eventChkInf[7] |= 1; - } - - if (Animation_OnFrame(&this->skelanime, this->currentAnimFrameCount)) { - this->actionState = 140; - Animation_Change(&this->skelanime, &gGohmaStandAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaStandAnim), ANIMMODE_LOOP, -10.0f); - this->framesUntilNextAction = 20; - } - break; - - case 140: - SkelAnime_Update(&this->skelanime); - Math_ApproachF(&this->subCameraAt.y, this->actor.focus.pos.y, 0.1f, 10.0f); - - if (this->framesUntilNextAction == 0) { - this->framesUntilNextAction = 30; - this->actionState = 150; - Gameplay_ChangeCameraStatus(globalCtx, 0, 3); - } - break; - - case 150: - SkelAnime_Update(&this->skelanime); - Math_SmoothStepToF(&this->subCameraEye.x, this->actor.world.pos.x + 150.0f, 0.2f, 100.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraEye.y, this->actor.world.pos.y + 20.0f, 0.2f, 100.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraEye.z, this->actor.world.pos.z + 220.0f, 0.2f, 100.0f, 0.1f); - - if (this->framesUntilNextAction == 0) { - cam = Gameplay_GetCamera(globalCtx, 0); - cam->eye = this->subCameraEye; - cam->eyeNext = this->subCameraEye; - cam->at = this->subCameraAt; - func_800C08AC(globalCtx, this->subCameraId, 0); - this->subCameraId = 0; - BossGoma_SetupFloorMain(this); - this->disableGameplayLogic = false; - this->patienceTimer = 200; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - } - break; - } - - if (this->subCameraId != 0) { - Gameplay_CameraSetAtEye(globalCtx, this->subCameraId, &this->subCameraAt, &this->subCameraEye); - } -} - -/** - * Handles the "Gohma defeated" cutscene and effects - * Spawns the heart container and blue warp actors - */ -void BossGoma_Defeated(BossGoma* this, GlobalContext* globalCtx) { - static Vec3f roomCenter = { -150.0f, 0.0f, -350.0f }; - f32 dx; - f32 dz; - s16 j; - Vec3f vel1 = { 0.0f, 0.0f, 0.0f }; - Vec3f accel1 = { 0.0f, 1.0f, 0.0f }; - Color_RGBA8 color1 = { 255, 255, 255, 255 }; - Color_RGBA8 color2 = { 0, 100, 255, 255 }; - Vec3f vel2 = { 0.0f, 0.0f, 0.0f }; - Vec3f accel2 = { 0.0f, -0.5f, 0.0f }; - Vec3f pos; - Camera* camera; - Player* player = GET_PLAYER(globalCtx); - Vec3f childPos; - s16 i; - - SkelAnime_Update(&this->skelanime); - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - - if (Animation_OnFrame(&this->skelanime, 107.0f)) { - BossGoma_PlayEffectsAndSfx(this, globalCtx, 0, 8); - func_800A9F6C(0.0f, 0x96, 0x14, 0x14); - } - - this->visualState = VISUALSTATE_DEFEATED; - this->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; - - if (this->framesUntilNextAction == 1001) { - for (i = 0; i < 90; i++) { - if (sDeadLimbLifetime[i] != 0) { - this->deadLimbsState[i] = 1; - } - } - } - - if (this->framesUntilNextAction < 1200 && this->framesUntilNextAction > 1100 && - this->framesUntilNextAction % 8 == 0) { - EffectSsSibuki_SpawnBurst(globalCtx, &this->actor.focus.pos); - } - - if (this->framesUntilNextAction < 1080 && this->actionState < 3) { - if (this->framesUntilNextAction < 1070) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_LAST - SFX_FLAG); - } - - for (i = 0; i < 4; i++) { - //! @bug this 0-indexes into this->defeatedLimbPositions which is initialized with - // this->defeatedLimbPositions[limb], but limb is 1-indexed in skelanime callbacks, this means effects - // should spawn at this->defeatedLimbPositions[0] too, which is uninitialized, so map origin? - j = (s16)(Rand_ZeroOne() * (BOSSGOMA_LIMB_MAX - 1)); - if (this->defeatedLimbPositions[j].y < 10000.0f) { - pos.x = Rand_CenteredFloat(20.0f) + this->defeatedLimbPositions[j].x; - pos.y = Rand_CenteredFloat(10.0f) + this->defeatedLimbPositions[j].y; - pos.z = Rand_CenteredFloat(20.0f) + this->defeatedLimbPositions[j].z; - func_8002836C(globalCtx, &pos, &vel1, &accel1, &color1, &color2, 500, 10, 10); - } - } - - for (i = 0; i < 15; i++) { - //! @bug same as above - j = (s16)(Rand_ZeroOne() * (BOSSGOMA_LIMB_MAX - 1)); - if (this->defeatedLimbPositions[j].y < 10000.0f) { - pos.x = Rand_CenteredFloat(20.0f) + this->defeatedLimbPositions[j].x; - pos.y = Rand_CenteredFloat(10.0f) + this->defeatedLimbPositions[j].y; - pos.z = Rand_CenteredFloat(20.0f) + this->defeatedLimbPositions[j].z; - EffectSsHahen_Spawn(globalCtx, &pos, &vel2, &accel2, 0, (s16)(Rand_ZeroOne() * 5.0f) + 10, -1, 10, - NULL); - } - } - } - - switch (this->actionState) { - case 0: - this->actionState = 1; - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 1); - this->subCameraId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, 0, 3); - Gameplay_ChangeCameraStatus(globalCtx, this->subCameraId, 7); - camera = Gameplay_GetCamera(globalCtx, 0); - this->subCameraEye.x = camera->eye.x; - this->subCameraEye.y = camera->eye.y; - this->subCameraEye.z = camera->eye.z; - this->subCameraAt.x = camera->at.x; - this->subCameraAt.y = camera->at.y; - this->subCameraAt.z = camera->at.z; - dx = this->subCameraEye.x - this->actor.world.pos.x; - dz = this->subCameraEye.z - this->actor.world.pos.z; - this->defeatedCameraEyeDist = sqrtf(SQ(dx) + SQ(dz)); - this->defeatedCameraEyeAngle = Math_FAtan2F(dx, dz); - this->timer = 270; - break; - - case 1: - dx = Math_SinS(this->actor.shape.rot.y) * 100.0f; - dz = Math_CosS(this->actor.shape.rot.y) * 100.0f; - Math_ApproachF(&player->actor.world.pos.x, this->actor.world.pos.x + dx, 0.5f, 5.0f); - Math_ApproachF(&player->actor.world.pos.z, this->actor.world.pos.z + dz, 0.5f, 5.0f); - - if (this->framesUntilNextAction < 1080) { - this->noBackfaceCulling = true; - - for (i = 0; i < 4; i++) { - BossGoma_ClearPixels(sClearPixelTableFirstPass, this->decayingProgress); - //! @bug this allows this->decayingProgress = 0x100 = 256 which is out of bounds when accessing - // sClearPixelTableFirstPass, though timers may prevent this from ever happening? - if (this->decayingProgress < 0x100) { - this->decayingProgress++; - } - } - } - - if (this->framesUntilNextAction < 1070 && this->frameCount % 4 == 0 && Rand_ZeroOne() < 0.5f) { - this->blinkTimer = 3; - } - - this->defeatedCameraEyeAngle += 0.022f; - Math_ApproachF(&this->defeatedCameraEyeDist, 150.0f, 0.1f, 5.0f); - dx = sinf(this->defeatedCameraEyeAngle); - dx = dx * this->defeatedCameraEyeDist; - dz = cosf(this->defeatedCameraEyeAngle); - dz = dz * this->defeatedCameraEyeDist; - Math_SmoothStepToF(&this->subCameraEye.x, this->actor.world.pos.x + dx, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraEye.y, this->actor.world.pos.y + 20.0f, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraEye.z, this->actor.world.pos.z + dz, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraAt.x, this->firstTailLimbWorldPos.x, 0.2f, 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraAt.y, this->actor.focus.pos.y, 0.5f, 100.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraAt.z, this->firstTailLimbWorldPos.z, 0.2f, 50.0f, 0.1f); - - if (this->timer == 80) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - } - - if (this->timer == 0) { - this->actionState = 2; - Gameplay_ChangeCameraStatus(globalCtx, 0, 3); - this->timer = 70; - this->decayingProgress = 0; - this->subCameraFollowSpeed = 0.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - } - break; - - case 2: - camera = Gameplay_GetCamera(globalCtx, 0); - Math_SmoothStepToF(&this->subCameraEye.x, camera->eye.x, 0.2f, this->subCameraFollowSpeed * 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraEye.y, camera->eye.y, 0.2f, this->subCameraFollowSpeed * 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraEye.z, camera->eye.z, 0.2f, this->subCameraFollowSpeed * 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraAt.x, camera->at.x, 0.2f, this->subCameraFollowSpeed * 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraAt.y, camera->at.y, 0.2f, this->subCameraFollowSpeed * 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraAt.z, camera->at.z, 0.2f, this->subCameraFollowSpeed * 50.0f, 0.1f); - Math_SmoothStepToF(&this->subCameraFollowSpeed, 1.0f, 1.0f, 0.02f, 0.0f); - - if (this->timer == 0) { - childPos = roomCenter; - this->timer = 30; - this->actionState = 3; - - for (i = 0; i < 10000; i++) { - if ((fabsf(childPos.x - player->actor.world.pos.x) < 100.0f && - fabsf(childPos.z - player->actor.world.pos.z) < 100.0f) || - (fabsf(childPos.x - this->actor.world.pos.x) < 150.0f && - fabsf(childPos.z - this->actor.world.pos.z) < 150.0f)) { - childPos.x = Rand_CenteredFloat(400.0f) + -150.0f; - childPos.z = Rand_CenteredFloat(400.0f) + -350.0f; - } else { - break; - } - } - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, childPos.x, - this->actor.world.pos.y, childPos.z, 0, 0, 0, WARP_DUNGEON_CHILD); - Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); - } - - for (i = 0; i < 4; i++) { - BossGoma_ClearPixels(sClearPixelTableSecondPass, this->decayingProgress); - //! @bug same as sClearPixelTableFirstPass - if (this->decayingProgress < 0x100) { - this->decayingProgress++; - } - } - break; - - case 3: - for (i = 0; i < 4; i++) { - BossGoma_ClearPixels(sClearPixelTableSecondPass, this->decayingProgress); - //! @bug same as sClearPixelTableFirstPass - if (this->decayingProgress < 0x100) { - this->decayingProgress++; - } - } - - if (this->timer == 0) { - if (Math_SmoothStepToF(&this->actor.scale.y, 0, 1.0f, 0.00075f, 0.0f) <= 0.001f) { - camera = Gameplay_GetCamera(globalCtx, 0); - camera->eye = this->subCameraEye; - camera->eyeNext = this->subCameraEye; - camera->at = this->subCameraAt; - func_800C08AC(globalCtx, this->subCameraId, 0); - this->subCameraId = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - Actor_Kill(&this->actor); - } - - this->actor.scale.x = this->actor.scale.z = this->actor.scale.y; - } - break; - } - - if (this->subCameraId != 0) { - Gameplay_CameraSetAtEye(globalCtx, this->subCameraId, &this->subCameraAt, &this->subCameraEye); - } - - if (this->blinkTimer != 0) { - this->blinkTimer--; - globalCtx->envCtx.adjAmbientColor[0] += 40; - globalCtx->envCtx.adjAmbientColor[1] += 40; - globalCtx->envCtx.adjAmbientColor[2] += 80; - globalCtx->envCtx.adjFogColor[0] += 10; - globalCtx->envCtx.adjFogColor[1] += 10; - globalCtx->envCtx.adjFogColor[2] += 20; - } else { - globalCtx->envCtx.adjAmbientColor[0] -= 20; - globalCtx->envCtx.adjAmbientColor[1] -= 20; - globalCtx->envCtx.adjAmbientColor[2] -= 40; - globalCtx->envCtx.adjFogColor[0] -= 5; - globalCtx->envCtx.adjFogColor[1] -= 5; - globalCtx->envCtx.adjFogColor[2] -= 10; - } - - if (globalCtx->envCtx.adjAmbientColor[0] > 200) { - globalCtx->envCtx.adjAmbientColor[0] = 200; - } - if (globalCtx->envCtx.adjAmbientColor[1] > 200) { - globalCtx->envCtx.adjAmbientColor[1] = 200; - } - if (globalCtx->envCtx.adjAmbientColor[2] > 200) { - globalCtx->envCtx.adjAmbientColor[2] = 200; - } - if (globalCtx->envCtx.adjFogColor[0] > 70) { - globalCtx->envCtx.adjFogColor[0] = 70; - } - if (globalCtx->envCtx.adjFogColor[1] > 70) { - globalCtx->envCtx.adjFogColor[1] = 70; - } - if (globalCtx->envCtx.adjFogColor[2] > 140) { - globalCtx->envCtx.adjFogColor[2] = 140; - } - - if (globalCtx->envCtx.adjAmbientColor[0] < 0) { - globalCtx->envCtx.adjAmbientColor[0] = 0; - } - if (globalCtx->envCtx.adjAmbientColor[1] < 0) { - globalCtx->envCtx.adjAmbientColor[1] = 0; - } - if (globalCtx->envCtx.adjAmbientColor[2] < 0) { - globalCtx->envCtx.adjAmbientColor[2] = 0; - } - if (globalCtx->envCtx.adjFogColor[0] < 0) { - globalCtx->envCtx.adjFogColor[0] = 0; - } - if (globalCtx->envCtx.adjFogColor[1] < 0) { - globalCtx->envCtx.adjFogColor[1] = 0; - } - if (globalCtx->envCtx.adjFogColor[2] < 0) { - globalCtx->envCtx.adjFogColor[2] = 0; - } -} - -/** - * If the player backs off, cancel the attack, or attack. - */ -void BossGoma_FloorAttackPosture(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - - if (this->skelanime.curFrame >= (19.0f + 1.0f / 3.0f) && this->skelanime.curFrame <= 30.0f) { - Math_ApproachS(&this->actor.world.rot.y, Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor), - 3, 0xBB8); - } - - if (Animation_OnFrame(&this->skelanime, Animation_GetLastFrame(&gGohmaPrepareAttackAnim))) { - if (this->actor.xzDistToPlayer < 250.0f) { - BossGoma_SetupFloorPrepareAttack(this); - } else { - BossGoma_SetupFloorMain(this); - } - } - - this->eyeState = EYESTATE_IRIS_FOLLOW_NO_IFRAMES; - this->visualState = VISUALSTATE_RED; -} - -/** - * Only lasts 1 frame. Plays a sound. - */ -void BossGoma_FloorPrepareAttack(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->framesUntilNextAction == 0) { - BossGoma_SetupFloorAttack(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_CRY1); - } - - this->eyeState = EYESTATE_IRIS_FOLLOW_NO_IFRAMES; - this->visualState = VISUALSTATE_RED; -} - -/** - * Gohma attacks, then the action eventually goes back to BossGoma_FloorMain - */ -void BossGoma_FloorAttack(BossGoma* this, GlobalContext* globalCtx) { - s16 i; - - this->actor.flags |= ACTOR_FLAG_24; - SkelAnime_Update(&this->skelanime); - - switch (this->actionState) { - case 0: - for (i = 0; i < this->collider.count; i++) { - if (this->collider.elements[i].info.toucherFlags & 2) { - this->framesUntilNextAction = 10; - break; - } - } - - if (Animation_OnFrame(&this->skelanime, 10.0f)) { - BossGoma_PlayEffectsAndSfx(this, globalCtx, 3, 5); - func_80033E88(&this->actor, globalCtx, 5, 15); - } - - if (Animation_OnFrame(&this->skelanime, Animation_GetLastFrame(&gGohmaAttackAnim))) { - this->actionState = 1; - Animation_Change(&this->skelanime, &gGohmaRestAfterAttackAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaRestAfterAttackAnim), ANIMMODE_LOOP, -1.0f); - - if (this->framesUntilNextAction == 0) { - this->timer = (s16)(Rand_ZeroOne() * 30.0f) + 30; - } - } - break; - - case 1: - if (Animation_OnFrame(&this->skelanime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_UNARI2); - } - - if (this->timer == 0) { - this->actionState = 2; - Animation_Change(&this->skelanime, &gGohmaRecoverAfterAttackAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGohmaRecoverAfterAttackAnim), ANIMMODE_ONCE, -5.0f); - } - break; - - case 2: - if (Animation_OnFrame(&this->skelanime, Animation_GetLastFrame(&gGohmaRecoverAfterAttackAnim))) { - BossGoma_SetupFloorIdle(this); - } - break; - } - - this->eyeState = EYESTATE_IRIS_FOLLOW_NO_IFRAMES; - this->visualState = VISUALSTATE_RED; -} - -/** - * Plays the animation to its end, then goes back to BossGoma_FloorStunned - */ -void BossGoma_FloorDamaged(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (Animation_OnFrame(&this->skelanime, Animation_GetLastFrame(&gGohmaDamageAnim))) { - BossGoma_SetupFloorStunned(this); - this->patienceTimer = 0; - } - - this->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; - Math_ApproachF(&this->eyeIrisScaleX, 0.4f, 0.5f, 0.2f); - this->visualState = VISUALSTATE_HIT; -} - -/** - * Gohma is back on the floor after the player struck it down from the ceiling. - * Sets patience to 0 - * Gohma is then stunned (BossGoma_FloorStunned) - */ -void BossGoma_FloorLandStruckDown(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (Animation_OnFrame(&this->skelanime, this->currentAnimFrameCount)) { - BossGoma_SetupFloorStunned(this); - this->sfxFaintTimer = 92; - this->patienceTimer = 0; - this->framesUntilNextAction = 150; - } - - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 55.0f, 4, 8.0f, 500, 10, 1); -} - -/** - * Gohma is back on the floor after the player has killed its children Gohmas. - * Plays an animation then goes to usual floor behavior, with refilled patience. - */ -void BossGoma_FloorLand(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (Animation_OnFrame(&this->skelanime, this->currentAnimFrameCount)) { - BossGoma_SetupFloorIdle(this); - this->patienceTimer = 200; - } -} - -/** - * Gohma is stunned and vulnerable. It can only be damaged during this action. - */ -void BossGoma_FloorStunned(BossGoma* this, GlobalContext* globalCtx) { - if (this->sfxFaintTimer <= 90) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_FAINT - 0x800); - } - SkelAnime_Update(&this->skelanime); - - if (this->timer == 1) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 55.0f, 4, 8.0f, 500, 10, 1); - } - - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); - - if (this->framesUntilNextAction == 0) { - BossGoma_SetupFloorMain(this); - if (this->patienceTimer == 0 && this->actor.xzDistToPlayer < 130.0f) { - this->timer = 20; - } - } - - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - this->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; - Math_ApproachF(&this->eyeIrisScaleX, 0.4f, 0.5f, 0.2f); - this->visualState = VISUALSTATE_STUNNED; -} - -/** - * Gohma goes back to the floor after the player killed the three gohmas it spawned - */ -void BossGoma_FallJump(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - Math_ApproachS(&this->actor.world.rot.y, Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor), 2, - 0x7D0); - - if (this->actor.bgCheckFlags & 1) { - BossGoma_SetupFloorLand(this); - this->actor.velocity.y = 0.0f; - BossGoma_PlayEffectsAndSfx(this, globalCtx, 0, 8); - func_80033E88(&this->actor, globalCtx, 5, 0xF); - } -} - -/** - * Gohma falls to the floor after the player hit it - */ -void BossGoma_FallStruckDown(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - Math_ApproachS(&this->actor.world.rot.y, Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor), 3, - 0x7D0); - - if (this->actor.bgCheckFlags & 1) { - BossGoma_SetupFloorLandStruckDown(this); - this->actor.velocity.y = 0.0f; - BossGoma_PlayEffectsAndSfx(this, globalCtx, 0, 8); - func_80033E88(&this->actor, globalCtx, 0xA, 0xF); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DAM1); - } -} - -/** - * Spawn three gohmas, one after the other. Cannot be interrupted - */ -void BossGoma_CeilingSpawnGohmas(BossGoma* this, GlobalContext* globalCtx) { - s16 i; - - SkelAnime_Update(&this->skelanime); - - if (this->frameCount % 16 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_UNARI); - } - - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - this->spawnGohmasActionTimer++; - - switch (this->spawnGohmasActionTimer) { - case 24: - // BOSSGOMA_LIMB_TAIL1, the tail limb closest to the body - this->tailLimbsScaleTimers[3] = 10; - break; - case 32: - // BOSSGOMA_LIMB_TAIL2 - this->tailLimbsScaleTimers[2] = 10; - break; - case 40: - // BOSSGOMA_LIMB_TAIL3 - this->tailLimbsScaleTimers[1] = 10; - break; - case 48: - // BOSSGOMA_LIMB_TAIL4, the furthest from the body - this->tailLimbsScaleTimers[0] = 10; - break; - } - - if (this->tailLimbsScaleTimers[0] == 2) { - for (i = 0; i < ARRAY_COUNT(this->childrenGohmaState); i++) { - if (this->childrenGohmaState[i] == 0) { - BossGoma_SpawnChildGohma(this, globalCtx, i); - break; - } - } - - if (this->childrenGohmaState[0] == 0 || this->childrenGohmaState[1] == 0 || this->childrenGohmaState[2] == 0) { - this->spawnGohmasActionTimer = 23; - } - } - - if (this->spawnGohmasActionTimer >= 64) { - BossGoma_SetupCeilingIdle(this); - } - - this->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; -} - -/** - * Prepare to spawn children gohmas, red eye for 70 frames - * During this time, the player can interrupt by hitting Gohma and make it fall from the ceiling - */ -void BossGoma_CeilingPrepareSpawnGohmas(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->framesUntilNextAction == 0) { - BossGoma_SetupCeilingSpawnGohmas(this); - } - - this->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; - this->visualState = VISUALSTATE_RED; -} - -/** - * On the floor, not doing anything special. - */ -void BossGoma_FloorIdle(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - Math_ApproachS(&this->actor.shape.rot.x, 0, 2, 0xBB8); - - if (this->framesUntilNextAction == 0) { - BossGoma_SetupFloorMain(this); - } -} - -/** - * On the ceiling, not doing anything special. - * Eventually spawns children gohmas, jumping down to the floor when they are killed, or staying on the ceiling as long - * as any is still alive. - */ -void BossGoma_CeilingIdle(BossGoma* this, GlobalContext* globalCtx) { - s16 i; - - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - - if (this->framesUntilNextAction == 0) { - if (this->childrenGohmaState[0] == 0 && this->childrenGohmaState[1] == 0 && this->childrenGohmaState[2] == 0) { - // if no child gohma has been spawned - BossGoma_SetupCeilingPrepareSpawnGohmas(this); - } else if (this->childrenGohmaState[0] < 0 && this->childrenGohmaState[1] < 0 && - this->childrenGohmaState[2] < 0) { - // if all children gohmas are dead - BossGoma_SetupFallJump(this); - } else { - for (i = 0; i < ARRAY_COUNT(this->childrenGohmaState); i++) { - if (this->childrenGohmaState[i] == 0) { - // if any child gohma hasn't been spawned - // this seems unreachable since BossGoma_CeilingSpawnGohmas spawns all three and can't be - // interrupted - BossGoma_SetupCeilingSpawnGohmas(this); - return; - } - } - // if all children gohmas have been spawned - BossGoma_SetupCeilingMoveToCenter(this); - } - } -} - -/** - * Gohma approaches the player as long as it has patience (see patienceTimer), then moves away from the player - * Gohma climbs any wall it collides with - * Uses the "walk cautiously" animation - */ -void BossGoma_FloorMain(BossGoma* this, GlobalContext* globalCtx) { - s16 rot; - - SkelAnime_Update(&this->skelanime); - - if (Animation_OnFrame(&this->skelanime, 1.0f)) { - this->doNotMoveThisFrame = true; - } else if (Animation_OnFrame(&this->skelanime, 30.0f)) { - this->doNotMoveThisFrame = true; - } else if (Animation_OnFrame(&this->skelanime, 15.0f)) { - this->doNotMoveThisFrame = true; - } else if (Animation_OnFrame(&this->skelanime, 16.0f)) { - this->doNotMoveThisFrame = true; - } - - if (Animation_OnFrame(&this->skelanime, 15.0f)) { - BossGoma_PlayEffectsAndSfx(this, globalCtx, 1, 3); - } else if (Animation_OnFrame(&this->skelanime, 30.0f)) { - BossGoma_PlayEffectsAndSfx(this, globalCtx, 2, 3); - } - - if (this->frameCount % 64 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_CRY2); - } - - if (!this->doNotMoveThisFrame) { - rot = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - - if (this->patienceTimer != 0) { - this->patienceTimer--; - - if (this->actor.xzDistToPlayer < 150.0f) { - BossGoma_SetupFloorAttackPosture(this); - } - - Math_ApproachF(&this->actor.speedXZ, 10.0f / 3.0f, 0.5f, 2.0f); - Math_ApproachS(&this->actor.world.rot.y, rot, 5, 0x3E8); - } else { - if (this->timer != 0) { - // move away from the player, walking backwards - Math_ApproachF(&this->actor.speedXZ, -10.0f, 0.5f, 2.0f); - this->skelanime.playSpeed = -3.0f; - if (this->timer == 1) { - this->actor.speedXZ = 0.0f; - } - } else { - // move away from the player, walking forwards - Math_ApproachF(&this->actor.speedXZ, 20.0f / 3.0f, 0.5f, 2.0f); - this->skelanime.playSpeed = 2.0f; - rot += 0x8000; - } - - Math_ApproachS(&this->actor.world.rot.y, rot, 3, 0x9C4); - } - } - - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 0.0f; - } - - if (this->actor.bgCheckFlags & 8) { - BossGoma_SetupWallClimb(this); - } - - if (this->framesUntilNextAction == 0 && this->patienceTimer != 0) { - BossGoma_SetupFloorIdle(this); - } -} - -/** - * Gohma moves up until it reaches the ceiling - */ -void BossGoma_WallClimb(BossGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->frameCount % 8 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_CLIM); - } - - Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.5f, 2.0f); - Math_ApproachS(&this->actor.shape.rot.x, -0x4000, 2, 0x7D0); - Math_ApproachS(&this->actor.world.rot.y, this->actor.wallYaw + 0x8000, 2, 0x5DC); - - // -320 is a bit below boss room ceiling - if (this->actor.world.pos.y > -320.0f) { - BossGoma_SetupCeilingMoveToCenter(this); - // allow new spawns - this->childrenGohmaState[0] = this->childrenGohmaState[1] = this->childrenGohmaState[2] = 0; - } -} - -/** - * Goes to BossGoma_CeilingIdle after enough time and after being close enough to the center of the ceiling. - */ -void BossGoma_CeilingMoveToCenter(BossGoma* this, GlobalContext* globalCtx) { - s16 angle; - s16 absDiff; - - BossGoma_UpdateCeilingMovement(this, globalCtx, 0.0f, -5.0f, true); - - if (this->frameCount % 64 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_CRY2); - } - - Math_ApproachS(&this->actor.shape.rot.x, -0x8000, 3, 0x3E8); - - // avoid walking into a wall? - if (this->actor.bgCheckFlags & 8) { - angle = this->actor.shape.rot.y + 0x8000; - - if (angle < this->actor.wallYaw) { - absDiff = this->actor.wallYaw - angle; - angle = angle + absDiff / 2; - } else { - absDiff = angle - this->actor.wallYaw; - angle = this->actor.wallYaw + absDiff / 2; - } - - this->actor.world.pos.z += Math_CosS(angle) * (5.0f + Rand_ZeroOne() * 5.0f) + Rand_CenteredFloat(2.0f); - this->actor.world.pos.x += Math_SinS(angle) * (5.0f + Rand_ZeroOne() * 5.0f) + Rand_CenteredFloat(2.0f); - } - - // timer setup to 30-60 - if (this->framesUntilNextAction == 0 && fabsf(-150.0f - this->actor.world.pos.x) < 100.0f && - fabsf(-350.0f - this->actor.world.pos.z) < 100.0f) { - BossGoma_SetupCeilingIdle(this); - } -} - -/** - * Update eye-related properties - * - open/close (eye lid rotation) - * - look at the player (iris rotation) - * - iris scale, when menacing or damaged - */ -void BossGoma_UpdateEye(BossGoma* this, GlobalContext* globalCtx) { - s16 targetEyeIrisRotX; - s16 targetEyeIrisRotY; - - if (!this->disableGameplayLogic) { - Player* player = GET_PLAYER(globalCtx); - - if (this->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES) { - // player + 0xA73 seems to be related to "throwing something" - if (player->unk_A73 != 0) { - player->unk_A73 = 0; - this->eyeClosedTimer = 12; - } - - if (this->frameCount % 16 == 0 && Rand_ZeroOne() < 0.3f) { - this->eyeClosedTimer = 7; - } - } - - if (this->childrenGohmaState[0] > 0 || this->childrenGohmaState[1] > 0 || this->childrenGohmaState[2] > 0) { - this->eyeClosedTimer = 7; - } - - if (this->eyeClosedTimer != 0) { - this->eyeClosedTimer--; - // close eye - Math_ApproachS(&this->eyeLidBottomRotX, -0xA98, 1, 0x7D0); - Math_ApproachS(&this->eyeLidTopRotX, 0x1600, 1, 0x7D0); - } else { - // open eye - Math_ApproachS(&this->eyeLidBottomRotX, 0, 1, 0x7D0); - Math_ApproachS(&this->eyeLidTopRotX, 0, 1, 0x7D0); - } - - if (this->eyeState != EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES) { - targetEyeIrisRotY = - Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.shape.rot.y; - targetEyeIrisRotX = - Actor_WorldPitchTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.shape.rot.x; - - if (this->actor.shape.rot.x > 0x4000 || this->actor.shape.rot.x < -0x4000) { - targetEyeIrisRotY = -(s16)(targetEyeIrisRotY + 0x8000); - targetEyeIrisRotX = -0xBB8; - } - - if (targetEyeIrisRotY > 0x1770) { - targetEyeIrisRotY = 0x1770; - } - - if (targetEyeIrisRotY < -0x1770) { - targetEyeIrisRotY = -0x1770; - } - - Math_ApproachS(&this->eyeIrisRotY, targetEyeIrisRotY, 3, 0x7D0); - Math_ApproachS(&this->eyeIrisRotX, targetEyeIrisRotX, 3, 0x7D0); - } else { - Math_ApproachS(&this->eyeIrisRotY, 0, 3, 0x3E8); - Math_ApproachS(&this->eyeIrisRotX, 0, 3, 0x3E8); - } - - Math_ApproachF(&this->eyeIrisScaleX, 1.0f, 0.2f, 0.07f); - Math_ApproachF(&this->eyeIrisScaleY, 1.0f, 0.2f, 0.07f); - } -} - -/** - * Part of achieving visual effects when spawning children gohmas, - * inflating each tail limb one after the other. - */ -void BossGoma_UpdateTailLimbsScale(BossGoma* this) { - s16 i; - - if (this->frameCount % 128 == 0) { - this->unusedTimer++; - if (this->unusedTimer >= 3) { - this->unusedTimer = 0; - } - } - - // See BossGoma_CeilingSpawnGohmas for `tailLimbsScaleTimers` usage - for (i = 0; i < ARRAY_COUNT(this->tailLimbsScaleTimers); i++) { - if (this->tailLimbsScaleTimers[i] != 0) { - this->tailLimbsScaleTimers[i]--; - Math_ApproachF(&this->tailLimbsScale[i], 1.5f, 0.2f, 0.1f); - } else { - Math_ApproachF(&this->tailLimbsScale[i], 1.0f, 0.2f, 0.1f); - } - } -} - -void BossGoma_UpdateHit(BossGoma* this, GlobalContext* globalCtx) { - if (this->invincibilityFrames != 0) { - this->invincibilityFrames--; - } else { - ColliderInfo* acHitInfo = this->collider.elements[0].info.acHitInfo; - s32 damage; - - if (this->eyeClosedTimer == 0 && this->actionFunc != BossGoma_CeilingSpawnGohmas && - (this->collider.elements[0].info.bumperFlags & BUMP_HIT)) { - this->collider.elements[0].info.bumperFlags &= ~BUMP_HIT; - - if (this->actionFunc == BossGoma_CeilingMoveToCenter || this->actionFunc == BossGoma_CeilingIdle || - this->actionFunc == BossGoma_CeilingPrepareSpawnGohmas) { - BossGoma_SetupFallStruckDown(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DAM2); - } else if (this->actionFunc == BossGoma_FloorStunned && - (damage = CollisionCheck_GetSwordDamage(acHitInfo->toucher.dmgFlags)) != 0) { - this->actor.colChkInfo.health -= damage; - - if ((s8)this->actor.colChkInfo.health > 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DAM1); - BossGoma_SetupFloorDamaged(this); - EffectSsSibuki_SpawnBurst(globalCtx, &this->actor.focus.pos); - } else { - BossGoma_SetupDefeated(this, globalCtx); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } - - this->invincibilityFrames = 10; - } else if (this->actionFunc != BossGoma_FloorStunned && this->patienceTimer != 0 && - (acHitInfo->toucher.dmgFlags & 0x00000005)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_DAM2); - Audio_StopSfxById(NA_SE_EN_GOMA_CRY1); - this->invincibilityFrames = 10; - BossGoma_SetupFloorStunned(this); - this->sfxFaintTimer = 100; - - if (acHitInfo->toucher.dmgFlags & 1) { - this->framesUntilNextAction = 40; - } else { - this->framesUntilNextAction = 90; - } - - this->timer = 4; - func_80033E88(&this->actor, globalCtx, 4, 0xC); - } - } - } -} - -void BossGoma_UpdateMainEnvColor(BossGoma* this) { - static f32 colors1[][3] = { - { 255.0f, 17.0f, 0.0f }, { 0.0f, 255.0f, 170.0f }, { 50.0f, 50.0f, 50.0f }, - { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, - }; - static f32 colors2[][3] = { - { 255.0f, 17.0f, 0.0f }, { 0.0f, 255.0f, 170.0f }, { 50.0f, 50.0f, 50.0f }, - { 0.0f, 255.0f, 170.0f }, { 0.0f, 0.0f, 255.0f }, { 255.0f, 17.0f, 0.0f }, - }; - - if (this->visualState == VISUALSTATE_DEFAULT && this->frameCount & 0x10) { - Math_ApproachF(&this->mainEnvColor[0], 50.0f, 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[1], 50.0f, 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[2], 50.0f, 0.5f, 20.0f); - } else if (this->invincibilityFrames != 0) { - if (this->invincibilityFrames & 2) { - this->mainEnvColor[0] = colors2[this->visualState][0]; - this->mainEnvColor[1] = colors2[this->visualState][1]; - this->mainEnvColor[2] = colors2[this->visualState][2]; - } else { - this->mainEnvColor[0] = colors1[this->visualState][0]; - this->mainEnvColor[1] = colors1[this->visualState][1]; - this->mainEnvColor[2] = colors1[this->visualState][2]; - } - } else { - Math_ApproachF(&this->mainEnvColor[0], colors1[this->visualState][0], 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[1], colors1[this->visualState][1], 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[2], colors1[this->visualState][2], 0.5f, 20.0f); - } -} - -void BossGoma_UpdateEyeEnvColor(BossGoma* this) { - static f32 targetEyeEnvColors[][3] = { - { 255.0f, 17.0f, 0.0f }, { 255.0f, 255.0f, 255.0f }, { 50.0f, 50.0f, 50.0f }, - { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, - }; - - Math_ApproachF(&this->eyeEnvColor[0], targetEyeEnvColors[this->visualState][0], 0.5f, 20.0f); - Math_ApproachF(&this->eyeEnvColor[1], targetEyeEnvColors[this->visualState][1], 0.5f, 20.0f); - Math_ApproachF(&this->eyeEnvColor[2], targetEyeEnvColors[this->visualState][2], 0.5f, 20.0f); -} - -void BossGoma_Update(Actor* thisx, GlobalContext* globalCtx) { - BossGoma* this = (BossGoma*)thisx; - s32 pad; - - this->visualState = VISUALSTATE_DEFAULT; - this->frameCount++; - - if (this->framesUntilNextAction != 0) { - this->framesUntilNextAction--; - } - - if (this->timer != 0) { - this->timer--; - } - - if (this->sfxFaintTimer != 0) { - this->sfxFaintTimer--; - } - - if (1) {} - - this->eyeState = EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES; - this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (!this->doNotMoveThisFrame) { - Actor_MoveForward(&this->actor); - } else { - this->doNotMoveThisFrame = false; - } - - if (this->actor.world.pos.y < -400.0f) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 80.0f, 5); - } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 80.0f, 1); - } - - BossGoma_UpdateEye(this, globalCtx); - BossGoma_UpdateMainEnvColor(this); - BossGoma_UpdateEyeEnvColor(this); - BossGoma_UpdateTailLimbsScale(this); - - if (!this->disableGameplayLogic) { - BossGoma_UpdateHit(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->actionFunc != BossGoma_FloorStunned && this->actionFunc != BossGoma_FloorDamaged && - (this->actionFunc != BossGoma_FloorMain || this->timer == 0)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -s32 BossGoma_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossGoma* this = (BossGoma*)thisx; - s32 doNotDrawLimb = false; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4685); - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->mainEnvColor[0], (s16)this->mainEnvColor[1], (s16)this->mainEnvColor[2], - 255); - - if (this->deadLimbsState[limbIndex] >= 2) { - *dList = NULL; - } - - switch (limbIndex) { - case BOSSGOMA_LIMB_EYE: - if (this->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES && this->eyeLidBottomRotX < -0xA8C) { - *dList = NULL; - } else if (this->invincibilityFrames != 0) { - gDPSetEnvColor(POLY_OPA_DISP++, (s16)(Rand_ZeroOne() * 255.0f), (s16)(Rand_ZeroOne() * 255.0f), - (s16)(Rand_ZeroOne() * 255.0f), 63); - } else { - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->eyeEnvColor[0], (s16)this->eyeEnvColor[1], - (s16)this->eyeEnvColor[2], 63); - } - break; - - case BOSSGOMA_LIMB_EYE_LID_BOTTOM_ROOT2: - rot->x += this->eyeLidBottomRotX; - break; - - case BOSSGOMA_LIMB_EYE_LID_TOP_ROOT2: - rot->x += this->eyeLidTopRotX; - break; - - case BOSSGOMA_LIMB_IRIS_ROOT2: - rot->x += this->eyeIrisRotX; - rot->y += this->eyeIrisRotY; - break; - - case BOSSGOMA_LIMB_IRIS: - if (this->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES && this->eyeLidBottomRotX < -0xA8C) { - *dList = NULL; - } else { - if (this->visualState == VISUALSTATE_DEFEATED) { - gDPSetEnvColor(POLY_OPA_DISP++, 50, 50, 50, 255); - } else { - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - } - - Matrix_TranslateRotateZYX(pos, rot); - - if (*dList != NULL) { - Matrix_Push(); - Matrix_Scale(this->eyeIrisScaleX, this->eyeIrisScaleY, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4815), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - } - - doNotDrawLimb = true; - } - break; - - case BOSSGOMA_LIMB_TAIL4: - case BOSSGOMA_LIMB_TAIL3: - case BOSSGOMA_LIMB_TAIL2: - case BOSSGOMA_LIMB_TAIL1: - Matrix_TranslateRotateZYX(pos, rot); - - if (*dList != NULL) { - Matrix_Push(); - Matrix_Scale(this->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], - this->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], - this->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4836), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - } - - doNotDrawLimb = true; - break; - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4858); - - return doNotDrawLimb; -} - -void BossGoma_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f tailZero = { 0.0f, 0.0f, 0.0f }; - static Vec3f clawBackLocalPos = { 0.0f, 0.0f, 0.0f }; - static Vec3f focusEyeLocalPos = { 0.0f, 300.0f, 2650.0f }; // in the center of the surface of the lens - static Vec3f zero = { 0.0f, 0.0f, 0.0f }; - Vec3f childPos; - Vec3s childRot; - EnGoma* babyGohma; - BossGoma* this = (BossGoma*)thisx; - s32 pad; - MtxF mtx; - - if (limbIndex == BOSSGOMA_LIMB_TAIL4) { // tail end/last part - Matrix_MultVec3f(&tailZero, &this->lastTailLimbWorldPos); - } else if (limbIndex == BOSSGOMA_LIMB_TAIL1) { // tail start/first part - Matrix_MultVec3f(&tailZero, &this->firstTailLimbWorldPos); - } else if (limbIndex == BOSSGOMA_LIMB_EYE) { - Matrix_MultVec3f(&focusEyeLocalPos, &this->actor.focus.pos); - } else if (limbIndex == BOSSGOMA_LIMB_R_FEET_BACK) { - Matrix_MultVec3f(&clawBackLocalPos, &this->rightHandBackLimbWorldPos); - } else if (limbIndex == BOSSGOMA_LIMB_L_FEET_BACK) { - Matrix_MultVec3f(&clawBackLocalPos, &this->leftHandBackLimbWorldPos); - } - - if (this->visualState == VISUALSTATE_DEFEATED) { - if (*dList != NULL) { - Matrix_MultVec3f(&clawBackLocalPos, &this->defeatedLimbPositions[limbIndex]); - } else { - this->defeatedLimbPositions[limbIndex].y = 10000.0f; - } - } - - if (this->deadLimbsState[limbIndex] == 1) { - this->deadLimbsState[limbIndex] = 2; - Matrix_MultVec3f(&zero, &childPos); - Matrix_Get(&mtx); - Matrix_MtxFToYXZRotS(&mtx, &childRot, 0); - // These are the pieces of Gohma as it falls apart. It appears to use the same actor as the baby gohmas. - babyGohma = (EnGoma*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_GOMA, - childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, childRot.z, - sDeadLimbLifetime[limbIndex] + 100); - if (babyGohma != NULL) { - babyGohma->bossLimbDl = *dList; - babyGohma->actor.objBankIndex = this->actor.objBankIndex; - } - } - - Collider_UpdateSpheres(limbIndex, &this->collider); -} - -Gfx* BossGoma_EmptyDlist(GraphicsContext* gfxCtx) { - Gfx* dListHead; - Gfx* dList; - - dList = dListHead = Graph_Alloc(gfxCtx, sizeof(Gfx) * 1); - - gSPEndDisplayList(dListHead++); - - return dList; -} - -Gfx* BossGoma_NoBackfaceCullingDlist(GraphicsContext* gfxCtx) { - Gfx* dListHead; - Gfx* dList; - - dList = dListHead = Graph_Alloc(gfxCtx, sizeof(Gfx) * 4); - - gDPPipeSync(dListHead++); - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2); - gSPClearGeometryMode(dListHead++, G_CULL_BACK); - gSPEndDisplayList(dListHead++); - - return dList; -} - -void BossGoma_Draw(Actor* thisx, GlobalContext* globalCtx) { - BossGoma* this = (BossGoma*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4991); - - func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); - - if (this->noBackfaceCulling) { - gSPSegment(POLY_OPA_DISP++, 0x08, BossGoma_NoBackfaceCullingDlist(globalCtx->state.gfxCtx)); - } else { - gSPSegment(POLY_OPA_DISP++, 0x08, BossGoma_EmptyDlist(globalCtx->state.gfxCtx)); - } - - SkelAnime_DrawOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, BossGoma_OverrideLimbDraw, - BossGoma_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 5012); -} - -void BossGoma_SpawnChildGohma(BossGoma* this, GlobalContext* globalCtx, s16 i) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_GOMA, this->lastTailLimbWorldPos.x, - this->lastTailLimbWorldPos.y - 50.0f, this->lastTailLimbWorldPos.z, 0, i * (0x10000 / 3), 0, i); - - this->childrenGohmaState[i] = 1; -} diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.cpp b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.cpp new file mode 100644 index 000000000..1e886e9ab --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.cpp @@ -0,0 +1,2165 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_GOMA_Z_BOSS_GOMA_C +#include "actor_common.h" +#include "z_boss_goma.h" +#include "objects/object_goma/object_goma.h" +#include "overlays/actors/ovl_En_Goma/z_en_goma.h" +#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/graph.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +// IRIS_FOLLOW: gohma looks towards the player (iris rotation) +// BONUS_IFRAMES: gain invincibility frames when the player does something (throwing things?), or +// randomly (see BossGoma_UpdateEye) +typedef enum { + EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES, // default, allows not drawing lens and iris when eye is closed + EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES, + EYESTATE_IRIS_FOLLOW_NO_IFRAMES +} GohmaEyeState; + +typedef enum { + VISUALSTATE_RED, // main/eye: red + VISUALSTATE_DEFAULT, // main: greenish cyan, blinks with dark gray every 16 frames; eye: white + VISUALSTATE_DEFEATED, // main/eye: dark gray + VISUALSTATE_STUNNED = 4, // main: greenish cyan, alternates with blue; eye: greenish cyan + VISUALSTATE_HIT // main: greenish cyan, alternates with red; eye: greenish cyan +} GohmaVisualState; + +void BossGoma_Init(Actor* thisx, GlobalContext* globalCtx); +void BossGoma_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossGoma_Update(Actor* thisx, GlobalContext* globalCtx); +void BossGoma_Draw(Actor* thisx, GlobalContext* globalCtx); + +void BossGoma_SetupEncounter(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_Encounter(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_Defeated(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorAttackPosture(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorPrepareAttack(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorAttack(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorDamaged(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorLandStruckDown(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorLand(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorStunned(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FallJump(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FallStruckDown(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_CeilingSpawnGohmas(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_CeilingPrepareSpawnGohmas(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorIdle(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_CeilingIdle(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_FloorMain(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_WallClimb(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_CeilingMoveToCenter(BossGoma* pthis, GlobalContext* globalCtx); +void BossGoma_SpawnChildGohma(BossGoma* pthis, GlobalContext* globalCtx, s16 i); + +ActorInit Boss_Goma_InitVars = { + ACTOR_BOSS_GOMA, + ACTORCAT_BOSS, + FLAGS, + OBJECT_GOMA, + sizeof(BossGoma), + (ActorFunc)BossGoma_Init, + (ActorFunc)BossGoma_Destroy, + (ActorFunc)BossGoma_Update, + (ActorFunc)BossGoma_Draw, +}; + +static ColliderJntSphElementInit sColliderJntSphElementInit[13] = { + { + { + ELEMTYPE_UNK3, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_EYE, { { 0, 0, 1200 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_TAIL4, { { 0, 0, 0 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_TAIL3, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_TAIL2, { { 0, 0, 0 }, 12 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_TAIL1, { { 0, 0, 0 }, 25 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_R_FEET, { { 0, 0, 0 }, 30 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_R_SHIN, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_R_THIGH_SHELL, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_L_ANTENNA_CLAW, { { 0, 0, 0 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_R_ANTENNA_CLAW, { { 0, 0, 0 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_L_FEET, { { 0, 0, 0 }, 30 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_L_SHIN, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { BOSSGOMA_LIMB_L_THIGH_SHELL, { { 0, 0, 0 }, 15 }, 100 }, + }, +}; + +static ColliderJntSphInit sColliderJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 13, + sColliderJntSphElementInit, +}; + +static u8 sClearPixelTableFirstPass[16 * 16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 +}; + +static u8 sClearPixelTableSecondPass[16 * 16] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +}; + +// indexed by limb (where the root limb is 1) +static u8 sDeadLimbLifetime[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 30, // tail end/last part + 40, // tail 2nd to last part + 0, 0, 0, 0, 0, 0, 0, 0, + 10, // back of right claw/hand + 15, // front of right claw/hand + 21, // part of right arm (inner) + 0, 0, + 25, // part of right arm (shell) + 0, 0, + 31, // part of right arm (shell on shoulder) + 35, // part of right arm (shoulder) + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 43, // end of left antenna + 48, // middle of left antenna + 53, // start of left antenna + 0, 0, 0, 0, + 42, // end of right antenna + 45, // middle of right antenna + 53, // start of right antenna + 0, 0, 0, 0, 0, 0, + 11, // back of left claw/hand + 15, // front of left claw/hand + 21, // part of left arm (inner) + 0, 0, + 25, // part of left arm (shell) + 0, 0, + 30, // part of left arm (shell on shoulder) + 35, // part of left arm (shoulder) + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +/** + * Sets the `i`th pixel of a 16x16 RGBA16 image to 0 (transparent black) + * according to the `clearPixelTable` + */ +void BossGoma_ClearPixels16x16Rgba16(s16* rgba16image, u8* clearPixelTable, s16 i) { + if (clearPixelTable[i]) { + rgba16image[i] = 0; + } +} + +/** + * Sets the `i`th 2x2 pixels block of a 32x32 RGBA16 image to 0 (transparent black) + * according to the `clearPixelTable` + */ +void BossGoma_ClearPixels32x32Rgba16(s16* rgba16image, u8* clearPixelTable, s16 i) { + s16* targetPixel; + + if (clearPixelTable[i]) { + // address of the top left pixel in a 2x2 pixels block located at + // (i & 0xF, i >> 4) in a 16x16 grid of 2x2 pixels + targetPixel = (s16*)((uintptr_t)rgba16image + (s16)((i & 0xF) * 2 + (i & 0xF0) * 4) * 2); + // set the 2x2 block of pixels to 0 + targetPixel[0] = 0; + targetPixel[1] = 0; + targetPixel[32 + 0] = 0; + targetPixel[32 + 1] = 0; + } +} + +/** + * Clear pixels from Gohma's textures + */ +void BossGoma_ClearPixels(u8* clearPixelTable, s16 i) { + BossGoma_ClearPixels16x16Rgba16((s16*)SEGMENTED_TO_VIRTUAL(gGohmaBodyTex), clearPixelTable, i); + BossGoma_ClearPixels16x16Rgba16((s16*)SEGMENTED_TO_VIRTUAL(gGohmaShellUndersideTex), clearPixelTable, i); + BossGoma_ClearPixels16x16Rgba16((s16*)SEGMENTED_TO_VIRTUAL(gGohmaDarkShellTex), clearPixelTable, i); + BossGoma_ClearPixels16x16Rgba16((s16*)SEGMENTED_TO_VIRTUAL(gGohmaEyeTex), clearPixelTable, i); + + BossGoma_ClearPixels32x32Rgba16((s16*)SEGMENTED_TO_VIRTUAL(gGohmaShellTex), clearPixelTable, i); + BossGoma_ClearPixels32x32Rgba16((s16*)SEGMENTED_TO_VIRTUAL(gGohmaIrisTex), clearPixelTable, i); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x01, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), +}; + +void BossGoma_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossGoma* pthis = (BossGoma*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 4000.0f, ActorShadow_DrawCircle, 150.0f); + SkelAnime_Init(globalCtx, &pthis->skelanime, &gGohmaSkel, &gGohmaIdleCrouchedAnim, NULL, NULL, 0); + Animation_PlayLoop(&pthis->skelanime, &gGohmaIdleCrouchedAnim); + pthis->actor.shape.rot.x = -0x8000; // upside-down + pthis->eyeIrisScaleX = 1.0f; + pthis->eyeIrisScaleY = 1.0f; + pthis->unusedInitX = pthis->actor.world.pos.x; + pthis->unusedInitZ = pthis->actor.world.pos.z; + pthis->actor.world.pos.y = -300.0f; // ceiling + pthis->actor.gravity = 0.0f; + BossGoma_SetupEncounter(pthis, globalCtx); + pthis->actor.colChkInfo.health = 10; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sColliderJntSphInit, pthis->colliderItems); + + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { + Actor_Kill(&pthis->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, -640.0f, 0.0f, 0, 0, + 0, WARP_DUNGEON_CHILD); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 141.0f, -640.0f, -84.0f, 0, 0, 0, 0); + } +} + +void BossGoma_PlayEffectsAndSfx(BossGoma* pthis, GlobalContext* globalCtx, s16 arg2, s16 amountMinus1) { + if (arg2 == 0 || arg2 == 1 || arg2 == 3) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightHandBackLimbWorldPos, 25.0f, amountMinus1, 8.0f, + 500, 10, 1); + } + + if (arg2 == 0 || arg2 == 2 || arg2 == 3) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftHandBackLimbWorldPos, 25.0f, amountMinus1, 8.0f, + 500, 10, 1); + } + + if (arg2 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DOWN); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_WALK); + } +} + +void BossGoma_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BossGoma* pthis = (BossGoma*)thisx; + + SkelAnime_Free(&pthis->skelanime, globalCtx); + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +/** + * When Gohma is hit and its health drops to 0 + */ +void BossGoma_SetupDefeated(BossGoma* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelanime, &gGohmaDeathAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaDeathAnim), + ANIMMODE_ONCE, -2.0f); + pthis->actionFunc = BossGoma_Defeated; + pthis->disableGameplayLogic = true; + pthis->decayingProgress = 0; + pthis->noBackfaceCulling = false; + pthis->framesUntilNextAction = 1200; + pthis->actionState = 0; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actor.speedXZ = 0.0f; + pthis->actor.shape.shadowScale = 0.0f; + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DEAD); +} + +/** + * Initial action setup, with Gohma waiting on the ceiling for the fight to start. + */ +void BossGoma_SetupEncounter(BossGoma* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gGohmaWalkAnim); + + Animation_Change(&pthis->skelanime, &gGohmaWalkAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -15.0f); + pthis->actionFunc = BossGoma_Encounter; + pthis->actionState = 0; + pthis->disableGameplayLogic = true; + globalCtx->envCtx.unk_BF = 4; + globalCtx->envCtx.unk_D6 = 0xFF; +} + +/** + * On the floor and not doing anything for 20-30 frames, before going back to BossGoma_FloorMain + */ +void BossGoma_SetupFloorIdle(BossGoma* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGohmaIdleCrouchedAnim); + + pthis->framesUntilNextAction = Rand_S16Offset(20, 30); + Animation_Change(&pthis->skelanime, &gGohmaIdleCrouchedAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = BossGoma_FloorIdle; +} + +/** + * On the ceiling and not doing anything for 20-30 frames, leads to spawning children gohmas + */ +void BossGoma_SetupCeilingIdle(BossGoma* pthis) { + pthis->framesUntilNextAction = Rand_S16Offset(20, 30); + Animation_Change(&pthis->skelanime, &gGohmaHangAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaHangAnim), + ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = BossGoma_CeilingIdle; +} + +/** + * When the player killed all children gohmas + */ +void BossGoma_SetupFallJump(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaLandAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossGoma_FallJump; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -2.0f; +} + +/** + * When the player successfully hits Gohma on the ceiling + */ +void BossGoma_SetupFallStruckDown(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaCrashAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = BossGoma_FallStruckDown; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -2.0f; +} + +void BossGoma_SetupCeilingSpawnGohmas(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaLayEggsAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaLayEggsAnim), + ANIMMODE_LOOP, -15.0f); + pthis->actionFunc = BossGoma_CeilingSpawnGohmas; + pthis->spawnGohmasActionTimer = 0; +} + +void BossGoma_SetupCeilingPrepareSpawnGohmas(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaPrepareEggsAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaPrepareEggsAnim), ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = BossGoma_CeilingPrepareSpawnGohmas; + pthis->framesUntilNextAction = 70; +} + +void BossGoma_SetupWallClimb(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaClimbAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaClimbAnim), + ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = BossGoma_WallClimb; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; +} + +/** + * Gohma either reached the ceiling after climbing a wall, or is waiting for the player to kill the (children) Gohmas. + */ +void BossGoma_SetupCeilingMoveToCenter(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaWalkAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaWalkAnim), + ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = BossGoma_CeilingMoveToCenter; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->framesUntilNextAction = Rand_S16Offset(30, 60); +} + +/** + * Root action when on the floor, leads to attacking or climbing. + */ +void BossGoma_SetupFloorMain(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaWalkCrouchedAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaWalkCrouchedAnim), ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = BossGoma_FloorMain; + pthis->framesUntilNextAction = Rand_S16Offset(70, 110); +} + +/** + * Gohma jumped to the floor on its own, after the player has killed its children Gohmas. + */ +void BossGoma_SetupFloorLand(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaLandAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaLandAnim), + ANIMMODE_ONCE, -2.0f); + pthis->actionFunc = BossGoma_FloorLand; + pthis->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaLandAnim); +} + +/** + * Gohma was shot by the player down from the ceiling. + */ +void BossGoma_SetupFloorLandStruckDown(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaCrashAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaCrashAnim), + ANIMMODE_ONCE, -2.0f); + pthis->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaCrashAnim); + pthis->actionFunc = BossGoma_FloorLandStruckDown; + pthis->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaCrashAnim); +} + +/** + * Gohma is vulnerable, from being struck down from the ceiling or on the ground. + */ +void BossGoma_SetupFloorStunned(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaStunnedAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaStunnedAnim), + ANIMMODE_LOOP, -2.0f); + pthis->actionFunc = BossGoma_FloorStunned; +} + +/** + * Take an attack posture, when the player is close enough. + */ +void BossGoma_SetupFloorAttackPosture(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaPrepareAttackAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaPrepareAttackAnim), ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = BossGoma_FloorAttackPosture; +} + +/** + * Leads to BossGoma_FloorAttack after 1 frame + */ +void BossGoma_SetupFloorPrepareAttack(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaStandAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaStandAnim), + ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = BossGoma_FloorPrepareAttack; + pthis->framesUntilNextAction = 0; +} + +void BossGoma_SetupFloorAttack(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaAttackAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaAttackAnim), + ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = BossGoma_FloorAttack; + pthis->actionState = 0; + pthis->framesUntilNextAction = 0; +} + +/** + * Plays an animation for Gohma being hit (while stunned) + * The setup and the action preserve timers apart from the patience one, notably `framesUntilNextAction` which is used + * as the stun duration + */ +void BossGoma_SetupFloorDamaged(BossGoma* pthis) { + Animation_Change(&pthis->skelanime, &gGohmaDamageAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaDamageAnim), + ANIMMODE_ONCE, -2.0f); + pthis->actionFunc = BossGoma_FloorDamaged; +} + +void BossGoma_UpdateCeilingMovement(BossGoma* pthis, GlobalContext* globalCtx, f32 dz, f32 targetSpeedXZ, + s16 rotateTowardsCenter) { + static Vec3f velInit = { 0.0f, 0.0f, 0.0f }; + static Vec3f accelInit = { 0.0f, -0.5f, 0.0f }; + static Vec3f roomCenter = { -150.0f, 0.0f, -350.0f }; + Vec3f* basePos = NULL; + s16 i; + Vec3f vel; + Vec3f accel; + Vec3f pos; + + roomCenter.z += dz; // dz is always 0 + SkelAnime_Update(&pthis->skelanime); + Math_ApproachF(&pthis->actor.speedXZ, targetSpeedXZ, 0.5f, 2.0f); + + if (rotateTowardsCenter) { + Math_ApproachS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &roomCenter) + 0x8000, 3, + 0x3E8); + } + + if (Animation_OnFrame(&pthis->skelanime, 9.0f)) { + basePos = &pthis->rightHandBackLimbWorldPos; + } else if (Animation_OnFrame(&pthis->skelanime, 1.0f)) { + basePos = &pthis->leftHandBackLimbWorldPos; + } + + if (basePos != NULL) { + for (i = 0; i < 5; i++) { + vel = velInit; + accel = accelInit; + pos.x = Rand_CenteredFloat(70.0f) + basePos->x; + pos.y = Rand_ZeroFloat(30.0f) + basePos->y; + pos.z = Rand_CenteredFloat(70.0f) + basePos->z; + EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accel, 0, (s16)(Rand_ZeroOne() * 5.0f) + 10, -1, 10, NULL); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_HIGH); + } +} + +void BossGoma_SetupEncounterState4(BossGoma* pthis, GlobalContext* globalCtx) { + Player* player; + Camera* camera; + + camera = Gameplay_GetCamera(globalCtx, 0); + player = GET_PLAYER(globalCtx); + pthis->actionState = 4; + pthis->actor.flags |= ACTOR_FLAG_0; + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->subCameraId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, 0, 3); + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCameraId, 7); + Animation_Change(&pthis->skelanime, &gGohmaEyeRollAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaEyeRollAnim), + ANIMMODE_ONCE, 0.0f); + pthis->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaEyeRollAnim); + + // room center (todo: defines for hardcoded positions relative to room center) + pthis->actor.world.pos.x = -150.0f; + pthis->actor.world.pos.z = -350.0f; + + // room entrance, towards center + player->actor.world.pos.x = 150.0f; + player->actor.world.pos.z = 300.0f; + + player->actor.world.rot.y = player->actor.shape.rot.y = -0x705C; + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) + 0x8000; + + // room entrance, closer to room center + pthis->subCameraEye.x = 90.0f; + pthis->subCameraEye.z = 170.0f; + pthis->subCameraEye.y = camera->eye.y + 20.0f; + + pthis->framesUntilNextAction = 50; + + pthis->subCameraAt.x = pthis->actor.world.pos.x; + pthis->subCameraAt.y = pthis->actor.world.pos.y; + pthis->subCameraAt.z = pthis->actor.world.pos.z; + + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); +} + +/** + * Spawns the door once the player entered + * Wait for the player to look at Gohma on the ceiling + * Handles the "meeting Gohma" cutscene, including boss card + * + * Skips the door and look-at-Gohma puzzle if the player already reached the boss card part before + */ +void BossGoma_Encounter(BossGoma* pthis, GlobalContext* globalCtx) { + Camera* cam; + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + + switch (pthis->actionState) { + case 0: // wait for the player to enter the room + // entrance of the boss room + if (fabsf(player->actor.world.pos.x - 150.0f) < 60.0f && + fabsf(player->actor.world.pos.z - 350.0f) < 60.0f) { + if (gSaveContext.eventChkInf[7] & 1) { + BossGoma_SetupEncounterState4(pthis, globalCtx); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_SHUTTER, 164.72f, + -480.0f, 397.68002f, 0, -0x705C, 0, 0x180); + } else { + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->actionState = 1; + } + } + break; + + case 1: // player entered the room + func_80064520(globalCtx, &globalCtx->csCtx); + pthis->subCameraId = Gameplay_CreateSubCamera(globalCtx); + osSyncPrintf("MAKE CAMERA !!! 1 !!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + Gameplay_ChangeCameraStatus(globalCtx, 0, 1); + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCameraId, 7); + pthis->actionState = 2; + // ceiling center + pthis->actor.world.pos.x = -150.0f; + pthis->actor.world.pos.y = -320.0f; + pthis->actor.world.pos.z = -350.0f; + // room entrance + player->actor.world.pos.x = 150.0f; + player->actor.world.pos.z = 300.0f; + // near ceiling center + pthis->subCameraEye.x = -350.0f; + pthis->subCameraEye.y = -310.0f; + pthis->subCameraEye.z = -350.0f; + // below room entrance + pthis->subCameraAt.x = player->actor.world.pos.x; + pthis->subCameraAt.y = player->actor.world.pos.y - 200.0f + 25.0f; + pthis->subCameraAt.z = player->actor.world.pos.z; + pthis->framesUntilNextAction = 50; + pthis->timer = 80; + pthis->frameCount = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + // fall-through + case 2: // zoom on player from room center + // room entrance, towards center + player->actor.shape.rot.y = -0x705C; + player->actor.world.pos.x = 150.0f; + player->actor.world.pos.z = 300.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + player->actor.speedXZ = 0.0f; + + if (pthis->framesUntilNextAction == 0) { + // (-20, 25, -65) is towards room center + Math_ApproachF(&pthis->subCameraEye.x, player->actor.world.pos.x - 20.0f, 0.049999997f, + pthis->subCameraFollowSpeed * 50.0f); + Math_ApproachF(&pthis->subCameraEye.y, player->actor.world.pos.y + 25.0f, 0.099999994f, + pthis->subCameraFollowSpeed * 130.0f); + Math_ApproachF(&pthis->subCameraEye.z, player->actor.world.pos.z - 65.0f, 0.049999997f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraFollowSpeed, 0.29999998f, 1.0f, 0.0050000004f); + if (pthis->timer == 0) { + Math_ApproachF(&pthis->subCameraAt.y, player->actor.world.pos.y + 35.0f, 0.099999994f, + pthis->subCameraFollowSpeed * 30.0f); + } + pthis->subCameraAt.x = player->actor.world.pos.x; + pthis->subCameraAt.z = player->actor.world.pos.z; + } + + Gameplay_CameraSetAtEye(globalCtx, 0, &pthis->subCameraAt, &pthis->subCameraEye); + + if (pthis->frameCount == 176) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_SHUTTER, 164.72f, -480.0f, + 397.68002f, 0, -0x705C, 0, SHUTTER_GOHMA_BLOCK << 6); + } + + if (pthis->frameCount == 176) { + globalCtx->envCtx.unk_BF = 3; + globalCtx->envCtx.unk_D6 = 0xFFFF; + } + + if (pthis->frameCount == 190) { + func_8002DF54(globalCtx, &pthis->actor, 2); + } + + if (pthis->frameCount >= 228) { + cam = Gameplay_GetCamera(globalCtx, 0); + cam->eye = pthis->subCameraEye; + cam->eyeNext = pthis->subCameraEye; + cam->at = pthis->subCameraAt; + func_800C08AC(globalCtx, pthis->subCameraId, 0); + pthis->subCameraId = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->actionState = 3; + } + break; + + case 3: // wait for the player to look at Gohma + if (fabsf(pthis->actor.projectedPos.x) < 150.0f && fabsf(pthis->actor.projectedPos.y) < 250.0f && + pthis->actor.projectedPos.z < 800.0f && pthis->actor.projectedPos.z > 0.0f) { + pthis->lookedAtFrames++; + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.world.rot.y, + Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) + 0x8000, 2, + 0xBB8); + pthis->eyeLidBottomRotX = pthis->eyeLidTopRotX = pthis->eyeIrisRotX = pthis->eyeIrisRotY = 0; + } else { + pthis->lookedAtFrames = 0; + BossGoma_UpdateCeilingMovement(pthis, globalCtx, 0.0f, -5.0f, true); + } + + if (pthis->lookedAtFrames > 15) { + BossGoma_SetupEncounterState4(pthis, globalCtx); + } + break; + + case 4: // focus Gohma on the ceiling + if (Animation_OnFrame(&pthis->skelanime, 15.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DEMO_EYE); + } + + if (pthis->framesUntilNextAction <= 40) { + // (22, -25, 45) is towards room entrance + Math_ApproachF(&pthis->subCameraEye.x, pthis->actor.world.pos.x + 22.0f, 0.2f, 100.0f); + Math_ApproachF(&pthis->subCameraEye.y, pthis->actor.world.pos.y - 25.0f, 0.2f, 100.0f); + Math_ApproachF(&pthis->subCameraEye.z, pthis->actor.world.pos.z + 45.0f, 0.2f, 100.0f); + Math_ApproachF(&pthis->subCameraAt.x, pthis->actor.world.pos.x, 0.2f, 100.0f); + Math_ApproachF(&pthis->subCameraAt.y, pthis->actor.world.pos.y + 5.0f, 0.2f, 100.0f); + Math_ApproachF(&pthis->subCameraAt.z, pthis->actor.world.pos.z, 0.2f, 100.0f); + + if (pthis->framesUntilNextAction == 30) { + globalCtx->envCtx.unk_BF = 4; + } + + if (pthis->framesUntilNextAction < 20) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachF(&pthis->eyeIrisScaleX, 1.0f, 0.8f, 0.4f); + Math_ApproachF(&pthis->eyeIrisScaleY, 1.0f, 0.8f, 0.4f); + + if (Animation_OnFrame(&pthis->skelanime, 36.0f)) { + pthis->eyeIrisScaleX = 1.8f; + pthis->eyeIrisScaleY = 1.8f; + } + + if (Animation_OnFrame(&pthis->skelanime, pthis->currentAnimFrameCount)) { + pthis->actionState = 5; + Animation_Change(&pthis->skelanime, &gGohmaWalkAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gGohmaWalkAnim), ANIMMODE_LOOP, -5.0f); + pthis->framesUntilNextAction = 30; + pthis->subCameraFollowSpeed = 0.0f; + } + } + } + break; + + case 5: // running on the ceiling + // (98, 0, 85) is towards room entrance + Math_ApproachF(&pthis->subCameraEye.x, pthis->actor.world.pos.x + 8.0f + 90.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraEye.y, player->actor.world.pos.y, 0.1f, pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraEye.z, pthis->actor.world.pos.z + 45.0f + 40.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraFollowSpeed, 1.0f, 1.0f, 0.05f); + pthis->subCameraAt.x = pthis->actor.world.pos.x; + pthis->subCameraAt.y = pthis->actor.world.pos.y; + pthis->subCameraAt.z = pthis->actor.world.pos.z; + + if (pthis->framesUntilNextAction < 0) { + //! @bug ? unreachable, timer is >= 0 + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 2.0f); + } else { + BossGoma_UpdateCeilingMovement(pthis, globalCtx, 0.0f, -7.5f, false); + } + + if (pthis->framesUntilNextAction == 0) { + Animation_Change(&pthis->skelanime, &gGohmaHangAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGohmaHangAnim), + ANIMMODE_LOOP, -5.0f); + } + + if (pthis->framesUntilNextAction == 0) { + pthis->actionState = 9; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -2.0f; + Animation_Change(&pthis->skelanime, &gGohmaInitialLandingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaInitialLandingAnim), ANIMMODE_ONCE, -5.0f); + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.z = -30.0f; + } + break; + + case 9: // falling from the ceiling + Math_ApproachF(&pthis->subCameraEye.x, pthis->actor.world.pos.x + 8.0f + 90.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraEye.y, player->actor.world.pos.y + 10.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraEye.z, pthis->actor.world.pos.z + 45.0f + 40.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + pthis->subCameraAt.x = pthis->actor.world.pos.x; + pthis->subCameraAt.y = pthis->actor.world.pos.y; + pthis->subCameraAt.z = pthis->actor.world.pos.z; + SkelAnime_Update(&pthis->skelanime); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + Math_ApproachS(&pthis->actor.world.rot.y, + Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor), 2, 0x7D0); + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actionState = 130; + pthis->actor.velocity.y = 0.0f; + Animation_Change(&pthis->skelanime, &gGohmaInitialLandingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaInitialLandingAnim), ANIMMODE_ONCE, -2.0f); + pthis->currentAnimFrameCount = Animation_GetLastFrame(&gGohmaInitialLandingAnim); + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 0, 5); + pthis->framesUntilNextAction = 15; + func_800A9F6C(0.0f, 0xC8, 0x14, 0x14); + } + break; + + case 130: // focus Gohma on the ground + Math_ApproachF(&pthis->subCameraEye.x, pthis->actor.world.pos.x + 8.0f + 90.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraEye.y, player->actor.world.pos.y + 10.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachF(&pthis->subCameraEye.z, pthis->actor.world.pos.z + 45.0f + 40.0f, 0.1f, + pthis->subCameraFollowSpeed * 30.0f); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + Math_ApproachS(&pthis->actor.world.rot.y, + Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor), 2, 0x7D0); + SkelAnime_Update(&pthis->skelanime); + pthis->subCameraAt.x = pthis->actor.world.pos.x; + pthis->subCameraAt.z = pthis->actor.world.pos.z; + + if (pthis->framesUntilNextAction != 0) { + f32 s = sinf(pthis->framesUntilNextAction * 3.1415f * 0.5f); + + pthis->subCameraAt.y = pthis->framesUntilNextAction * s * 0.7f + pthis->actor.world.pos.y; + } else { + Math_ApproachF(&pthis->subCameraAt.y, pthis->actor.focus.pos.y, 0.1f, 10.0f); + } + + if (Animation_OnFrame(&pthis->skelanime, 40.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_CRY1); + + if (!(gSaveContext.eventChkInf[7] & 1)) { + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(gGohmaTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + } + + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + gSaveContext.eventChkInf[7] |= 1; + } + + if (Animation_OnFrame(&pthis->skelanime, pthis->currentAnimFrameCount)) { + pthis->actionState = 140; + Animation_Change(&pthis->skelanime, &gGohmaStandAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaStandAnim), ANIMMODE_LOOP, -10.0f); + pthis->framesUntilNextAction = 20; + } + break; + + case 140: + SkelAnime_Update(&pthis->skelanime); + Math_ApproachF(&pthis->subCameraAt.y, pthis->actor.focus.pos.y, 0.1f, 10.0f); + + if (pthis->framesUntilNextAction == 0) { + pthis->framesUntilNextAction = 30; + pthis->actionState = 150; + Gameplay_ChangeCameraStatus(globalCtx, 0, 3); + } + break; + + case 150: + SkelAnime_Update(&pthis->skelanime); + Math_SmoothStepToF(&pthis->subCameraEye.x, pthis->actor.world.pos.x + 150.0f, 0.2f, 100.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraEye.y, pthis->actor.world.pos.y + 20.0f, 0.2f, 100.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraEye.z, pthis->actor.world.pos.z + 220.0f, 0.2f, 100.0f, 0.1f); + + if (pthis->framesUntilNextAction == 0) { + cam = Gameplay_GetCamera(globalCtx, 0); + cam->eye = pthis->subCameraEye; + cam->eyeNext = pthis->subCameraEye; + cam->at = pthis->subCameraAt; + func_800C08AC(globalCtx, pthis->subCameraId, 0); + pthis->subCameraId = 0; + BossGoma_SetupFloorMain(pthis); + pthis->disableGameplayLogic = false; + pthis->patienceTimer = 200; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + } + break; + } + + if (pthis->subCameraId != 0) { + Gameplay_CameraSetAtEye(globalCtx, pthis->subCameraId, &pthis->subCameraAt, &pthis->subCameraEye); + } +} + +/** + * Handles the "Gohma defeated" cutscene and effects + * Spawns the heart container and blue warp actors + */ +void BossGoma_Defeated(BossGoma* pthis, GlobalContext* globalCtx) { + static Vec3f roomCenter = { -150.0f, 0.0f, -350.0f }; + f32 dx; + f32 dz; + s16 j; + Vec3f vel1 = { 0.0f, 0.0f, 0.0f }; + Vec3f accel1 = { 0.0f, 1.0f, 0.0f }; + Color_RGBA8 color1 = { 255, 255, 255, 255 }; + Color_RGBA8 color2 = { 0, 100, 255, 255 }; + Vec3f vel2 = { 0.0f, 0.0f, 0.0f }; + Vec3f accel2 = { 0.0f, -0.5f, 0.0f }; + Vec3f pos; + Camera* camera; + Player* player = GET_PLAYER(globalCtx); + Vec3f childPos; + s16 i; + + SkelAnime_Update(&pthis->skelanime); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + + if (Animation_OnFrame(&pthis->skelanime, 107.0f)) { + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 0, 8); + func_800A9F6C(0.0f, 0x96, 0x14, 0x14); + } + + pthis->visualState = VISUALSTATE_DEFEATED; + pthis->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; + + if (pthis->framesUntilNextAction == 1001) { + for (i = 0; i < 90; i++) { + if (sDeadLimbLifetime[i] != 0) { + pthis->deadLimbsState[i] = 1; + } + } + } + + if (pthis->framesUntilNextAction < 1200 && pthis->framesUntilNextAction > 1100 && + pthis->framesUntilNextAction % 8 == 0) { + EffectSsSibuki_SpawnBurst(globalCtx, &pthis->actor.focus.pos); + } + + if (pthis->framesUntilNextAction < 1080 && pthis->actionState < 3) { + if (pthis->framesUntilNextAction < 1070) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_LAST - SFX_FLAG); + } + + for (i = 0; i < 4; i++) { + //! @bug pthis 0-indexes into pthis->defeatedLimbPositions which is initialized with + // pthis->defeatedLimbPositions[limb], but limb is 1-indexed in skelanime callbacks, pthis means effects + // should spawn at pthis->defeatedLimbPositions[0] too, which is uninitialized, so map origin? + j = (s16)(Rand_ZeroOne() * (BOSSGOMA_LIMB_MAX - 1)); + if (pthis->defeatedLimbPositions[j].y < 10000.0f) { + pos.x = Rand_CenteredFloat(20.0f) + pthis->defeatedLimbPositions[j].x; + pos.y = Rand_CenteredFloat(10.0f) + pthis->defeatedLimbPositions[j].y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->defeatedLimbPositions[j].z; + func_8002836C(globalCtx, &pos, &vel1, &accel1, &color1, &color2, 500, 10, 10); + } + } + + for (i = 0; i < 15; i++) { + //! @bug same as above + j = (s16)(Rand_ZeroOne() * (BOSSGOMA_LIMB_MAX - 1)); + if (pthis->defeatedLimbPositions[j].y < 10000.0f) { + pos.x = Rand_CenteredFloat(20.0f) + pthis->defeatedLimbPositions[j].x; + pos.y = Rand_CenteredFloat(10.0f) + pthis->defeatedLimbPositions[j].y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->defeatedLimbPositions[j].z; + EffectSsHahen_Spawn(globalCtx, &pos, &vel2, &accel2, 0, (s16)(Rand_ZeroOne() * 5.0f) + 10, -1, 10, + NULL); + } + } + } + + switch (pthis->actionState) { + case 0: + pthis->actionState = 1; + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->subCameraId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, 0, 3); + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCameraId, 7); + camera = Gameplay_GetCamera(globalCtx, 0); + pthis->subCameraEye.x = camera->eye.x; + pthis->subCameraEye.y = camera->eye.y; + pthis->subCameraEye.z = camera->eye.z; + pthis->subCameraAt.x = camera->at.x; + pthis->subCameraAt.y = camera->at.y; + pthis->subCameraAt.z = camera->at.z; + dx = pthis->subCameraEye.x - pthis->actor.world.pos.x; + dz = pthis->subCameraEye.z - pthis->actor.world.pos.z; + pthis->defeatedCameraEyeDist = sqrtf(SQ(dx) + SQ(dz)); + pthis->defeatedCameraEyeAngle = Math_FAtan2F(dx, dz); + pthis->timer = 270; + break; + + case 1: + dx = Math_SinS(pthis->actor.shape.rot.y) * 100.0f; + dz = Math_CosS(pthis->actor.shape.rot.y) * 100.0f; + Math_ApproachF(&player->actor.world.pos.x, pthis->actor.world.pos.x + dx, 0.5f, 5.0f); + Math_ApproachF(&player->actor.world.pos.z, pthis->actor.world.pos.z + dz, 0.5f, 5.0f); + + if (pthis->framesUntilNextAction < 1080) { + pthis->noBackfaceCulling = true; + + for (i = 0; i < 4; i++) { + BossGoma_ClearPixels(sClearPixelTableFirstPass, pthis->decayingProgress); + //! @bug pthis allows pthis->decayingProgress = 0x100 = 256 which is out of bounds when accessing + // sClearPixelTableFirstPass, though timers may prevent pthis from ever happening? + if (pthis->decayingProgress < 0x100) { + pthis->decayingProgress++; + } + } + } + + if (pthis->framesUntilNextAction < 1070 && pthis->frameCount % 4 == 0 && Rand_ZeroOne() < 0.5f) { + pthis->blinkTimer = 3; + } + + pthis->defeatedCameraEyeAngle += 0.022f; + Math_ApproachF(&pthis->defeatedCameraEyeDist, 150.0f, 0.1f, 5.0f); + dx = sinf(pthis->defeatedCameraEyeAngle); + dx = dx * pthis->defeatedCameraEyeDist; + dz = cosf(pthis->defeatedCameraEyeAngle); + dz = dz * pthis->defeatedCameraEyeDist; + Math_SmoothStepToF(&pthis->subCameraEye.x, pthis->actor.world.pos.x + dx, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraEye.y, pthis->actor.world.pos.y + 20.0f, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraEye.z, pthis->actor.world.pos.z + dz, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraAt.x, pthis->firstTailLimbWorldPos.x, 0.2f, 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraAt.y, pthis->actor.focus.pos.y, 0.5f, 100.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraAt.z, pthis->firstTailLimbWorldPos.z, 0.2f, 50.0f, 0.1f); + + if (pthis->timer == 80) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + } + + if (pthis->timer == 0) { + pthis->actionState = 2; + Gameplay_ChangeCameraStatus(globalCtx, 0, 3); + pthis->timer = 70; + pthis->decayingProgress = 0; + pthis->subCameraFollowSpeed = 0.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); + } + break; + + case 2: + camera = Gameplay_GetCamera(globalCtx, 0); + Math_SmoothStepToF(&pthis->subCameraEye.x, camera->eye.x, 0.2f, pthis->subCameraFollowSpeed * 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraEye.y, camera->eye.y, 0.2f, pthis->subCameraFollowSpeed * 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraEye.z, camera->eye.z, 0.2f, pthis->subCameraFollowSpeed * 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraAt.x, camera->at.x, 0.2f, pthis->subCameraFollowSpeed * 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraAt.y, camera->at.y, 0.2f, pthis->subCameraFollowSpeed * 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraAt.z, camera->at.z, 0.2f, pthis->subCameraFollowSpeed * 50.0f, 0.1f); + Math_SmoothStepToF(&pthis->subCameraFollowSpeed, 1.0f, 1.0f, 0.02f, 0.0f); + + if (pthis->timer == 0) { + childPos = roomCenter; + pthis->timer = 30; + pthis->actionState = 3; + + for (i = 0; i < 10000; i++) { + if ((fabsf(childPos.x - player->actor.world.pos.x) < 100.0f && + fabsf(childPos.z - player->actor.world.pos.z) < 100.0f) || + (fabsf(childPos.x - pthis->actor.world.pos.x) < 150.0f && + fabsf(childPos.z - pthis->actor.world.pos.z) < 150.0f)) { + childPos.x = Rand_CenteredFloat(400.0f) + -150.0f; + childPos.z = Rand_CenteredFloat(400.0f) + -350.0f; + } else { + break; + } + } + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, childPos.x, + pthis->actor.world.pos.y, childPos.z, 0, 0, 0, WARP_DUNGEON_CHILD); + Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); + } + + for (i = 0; i < 4; i++) { + BossGoma_ClearPixels(sClearPixelTableSecondPass, pthis->decayingProgress); + //! @bug same as sClearPixelTableFirstPass + if (pthis->decayingProgress < 0x100) { + pthis->decayingProgress++; + } + } + break; + + case 3: + for (i = 0; i < 4; i++) { + BossGoma_ClearPixels(sClearPixelTableSecondPass, pthis->decayingProgress); + //! @bug same as sClearPixelTableFirstPass + if (pthis->decayingProgress < 0x100) { + pthis->decayingProgress++; + } + } + + if (pthis->timer == 0) { + if (Math_SmoothStepToF(&pthis->actor.scale.y, 0, 1.0f, 0.00075f, 0.0f) <= 0.001f) { + camera = Gameplay_GetCamera(globalCtx, 0); + camera->eye = pthis->subCameraEye; + camera->eyeNext = pthis->subCameraEye; + camera->at = pthis->subCameraAt; + func_800C08AC(globalCtx, pthis->subCameraId, 0); + pthis->subCameraId = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + Actor_Kill(&pthis->actor); + } + + pthis->actor.scale.x = pthis->actor.scale.z = pthis->actor.scale.y; + } + break; + } + + if (pthis->subCameraId != 0) { + Gameplay_CameraSetAtEye(globalCtx, pthis->subCameraId, &pthis->subCameraAt, &pthis->subCameraEye); + } + + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + globalCtx->envCtx.adjAmbientColor[0] += 40; + globalCtx->envCtx.adjAmbientColor[1] += 40; + globalCtx->envCtx.adjAmbientColor[2] += 80; + globalCtx->envCtx.adjFogColor[0] += 10; + globalCtx->envCtx.adjFogColor[1] += 10; + globalCtx->envCtx.adjFogColor[2] += 20; + } else { + globalCtx->envCtx.adjAmbientColor[0] -= 20; + globalCtx->envCtx.adjAmbientColor[1] -= 20; + globalCtx->envCtx.adjAmbientColor[2] -= 40; + globalCtx->envCtx.adjFogColor[0] -= 5; + globalCtx->envCtx.adjFogColor[1] -= 5; + globalCtx->envCtx.adjFogColor[2] -= 10; + } + + if (globalCtx->envCtx.adjAmbientColor[0] > 200) { + globalCtx->envCtx.adjAmbientColor[0] = 200; + } + if (globalCtx->envCtx.adjAmbientColor[1] > 200) { + globalCtx->envCtx.adjAmbientColor[1] = 200; + } + if (globalCtx->envCtx.adjAmbientColor[2] > 200) { + globalCtx->envCtx.adjAmbientColor[2] = 200; + } + if (globalCtx->envCtx.adjFogColor[0] > 70) { + globalCtx->envCtx.adjFogColor[0] = 70; + } + if (globalCtx->envCtx.adjFogColor[1] > 70) { + globalCtx->envCtx.adjFogColor[1] = 70; + } + if (globalCtx->envCtx.adjFogColor[2] > 140) { + globalCtx->envCtx.adjFogColor[2] = 140; + } + + if (globalCtx->envCtx.adjAmbientColor[0] < 0) { + globalCtx->envCtx.adjAmbientColor[0] = 0; + } + if (globalCtx->envCtx.adjAmbientColor[1] < 0) { + globalCtx->envCtx.adjAmbientColor[1] = 0; + } + if (globalCtx->envCtx.adjAmbientColor[2] < 0) { + globalCtx->envCtx.adjAmbientColor[2] = 0; + } + if (globalCtx->envCtx.adjFogColor[0] < 0) { + globalCtx->envCtx.adjFogColor[0] = 0; + } + if (globalCtx->envCtx.adjFogColor[1] < 0) { + globalCtx->envCtx.adjFogColor[1] = 0; + } + if (globalCtx->envCtx.adjFogColor[2] < 0) { + globalCtx->envCtx.adjFogColor[2] = 0; + } +} + +/** + * If the player backs off, cancel the attack, or attack. + */ +void BossGoma_FloorAttackPosture(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + + if (pthis->skelanime.curFrame >= (19.0f + 1.0f / 3.0f) && pthis->skelanime.curFrame <= 30.0f) { + Math_ApproachS(&pthis->actor.world.rot.y, Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor), + 3, 0xBB8); + } + + if (Animation_OnFrame(&pthis->skelanime, Animation_GetLastFrame(&gGohmaPrepareAttackAnim))) { + if (pthis->actor.xzDistToPlayer < 250.0f) { + BossGoma_SetupFloorPrepareAttack(pthis); + } else { + BossGoma_SetupFloorMain(pthis); + } + } + + pthis->eyeState = EYESTATE_IRIS_FOLLOW_NO_IFRAMES; + pthis->visualState = VISUALSTATE_RED; +} + +/** + * Only lasts 1 frame. Plays a sound. + */ +void BossGoma_FloorPrepareAttack(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->framesUntilNextAction == 0) { + BossGoma_SetupFloorAttack(pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_CRY1); + } + + pthis->eyeState = EYESTATE_IRIS_FOLLOW_NO_IFRAMES; + pthis->visualState = VISUALSTATE_RED; +} + +/** + * Gohma attacks, then the action eventually goes back to BossGoma_FloorMain + */ +void BossGoma_FloorAttack(BossGoma* pthis, GlobalContext* globalCtx) { + s16 i; + + pthis->actor.flags |= ACTOR_FLAG_24; + SkelAnime_Update(&pthis->skelanime); + + switch (pthis->actionState) { + case 0: + for (i = 0; i < pthis->collider.count; i++) { + if (pthis->collider.elements[i].info.toucherFlags & 2) { + pthis->framesUntilNextAction = 10; + break; + } + } + + if (Animation_OnFrame(&pthis->skelanime, 10.0f)) { + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 3, 5); + func_80033E88(&pthis->actor, globalCtx, 5, 15); + } + + if (Animation_OnFrame(&pthis->skelanime, Animation_GetLastFrame(&gGohmaAttackAnim))) { + pthis->actionState = 1; + Animation_Change(&pthis->skelanime, &gGohmaRestAfterAttackAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaRestAfterAttackAnim), ANIMMODE_LOOP, -1.0f); + + if (pthis->framesUntilNextAction == 0) { + pthis->timer = (s16)(Rand_ZeroOne() * 30.0f) + 30; + } + } + break; + + case 1: + if (Animation_OnFrame(&pthis->skelanime, 3.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_UNARI2); + } + + if (pthis->timer == 0) { + pthis->actionState = 2; + Animation_Change(&pthis->skelanime, &gGohmaRecoverAfterAttackAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGohmaRecoverAfterAttackAnim), ANIMMODE_ONCE, -5.0f); + } + break; + + case 2: + if (Animation_OnFrame(&pthis->skelanime, Animation_GetLastFrame(&gGohmaRecoverAfterAttackAnim))) { + BossGoma_SetupFloorIdle(pthis); + } + break; + } + + pthis->eyeState = EYESTATE_IRIS_FOLLOW_NO_IFRAMES; + pthis->visualState = VISUALSTATE_RED; +} + +/** + * Plays the animation to its end, then goes back to BossGoma_FloorStunned + */ +void BossGoma_FloorDamaged(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (Animation_OnFrame(&pthis->skelanime, Animation_GetLastFrame(&gGohmaDamageAnim))) { + BossGoma_SetupFloorStunned(pthis); + pthis->patienceTimer = 0; + } + + pthis->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; + Math_ApproachF(&pthis->eyeIrisScaleX, 0.4f, 0.5f, 0.2f); + pthis->visualState = VISUALSTATE_HIT; +} + +/** + * Gohma is back on the floor after the player struck it down from the ceiling. + * Sets patience to 0 + * Gohma is then stunned (BossGoma_FloorStunned) + */ +void BossGoma_FloorLandStruckDown(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (Animation_OnFrame(&pthis->skelanime, pthis->currentAnimFrameCount)) { + BossGoma_SetupFloorStunned(pthis); + pthis->sfxFaintTimer = 92; + pthis->patienceTimer = 0; + pthis->framesUntilNextAction = 150; + } + + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 55.0f, 4, 8.0f, 500, 10, 1); +} + +/** + * Gohma is back on the floor after the player has killed its children Gohmas. + * Plays an animation then goes to usual floor behavior, with refilled patience. + */ +void BossGoma_FloorLand(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (Animation_OnFrame(&pthis->skelanime, pthis->currentAnimFrameCount)) { + BossGoma_SetupFloorIdle(pthis); + pthis->patienceTimer = 200; + } +} + +/** + * Gohma is stunned and vulnerable. It can only be damaged during pthis action. + */ +void BossGoma_FloorStunned(BossGoma* pthis, GlobalContext* globalCtx) { + if (pthis->sfxFaintTimer <= 90) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_FAINT - 0x800); + } + SkelAnime_Update(&pthis->skelanime); + + if (pthis->timer == 1) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 55.0f, 4, 8.0f, 500, 10, 1); + } + + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 1.0f); + + if (pthis->framesUntilNextAction == 0) { + BossGoma_SetupFloorMain(pthis); + if (pthis->patienceTimer == 0 && pthis->actor.xzDistToPlayer < 130.0f) { + pthis->timer = 20; + } + } + + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + pthis->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; + Math_ApproachF(&pthis->eyeIrisScaleX, 0.4f, 0.5f, 0.2f); + pthis->visualState = VISUALSTATE_STUNNED; +} + +/** + * Gohma goes back to the floor after the player killed the three gohmas it spawned + */ +void BossGoma_FallJump(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + Math_ApproachS(&pthis->actor.world.rot.y, Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor), 2, + 0x7D0); + + if (pthis->actor.bgCheckFlags & 1) { + BossGoma_SetupFloorLand(pthis); + pthis->actor.velocity.y = 0.0f; + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 0, 8); + func_80033E88(&pthis->actor, globalCtx, 5, 0xF); + } +} + +/** + * Gohma falls to the floor after the player hit it + */ +void BossGoma_FallStruckDown(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + Math_ApproachS(&pthis->actor.world.rot.y, Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor), 3, + 0x7D0); + + if (pthis->actor.bgCheckFlags & 1) { + BossGoma_SetupFloorLandStruckDown(pthis); + pthis->actor.velocity.y = 0.0f; + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 0, 8); + func_80033E88(&pthis->actor, globalCtx, 0xA, 0xF); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DAM1); + } +} + +/** + * Spawn three gohmas, one after the other. Cannot be interrupted + */ +void BossGoma_CeilingSpawnGohmas(BossGoma* pthis, GlobalContext* globalCtx) { + s16 i; + + SkelAnime_Update(&pthis->skelanime); + + if (pthis->frameCount % 16 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_UNARI); + } + + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + pthis->spawnGohmasActionTimer++; + + switch (pthis->spawnGohmasActionTimer) { + case 24: + // BOSSGOMA_LIMB_TAIL1, the tail limb closest to the body + pthis->tailLimbsScaleTimers[3] = 10; + break; + case 32: + // BOSSGOMA_LIMB_TAIL2 + pthis->tailLimbsScaleTimers[2] = 10; + break; + case 40: + // BOSSGOMA_LIMB_TAIL3 + pthis->tailLimbsScaleTimers[1] = 10; + break; + case 48: + // BOSSGOMA_LIMB_TAIL4, the furthest from the body + pthis->tailLimbsScaleTimers[0] = 10; + break; + } + + if (pthis->tailLimbsScaleTimers[0] == 2) { + for (i = 0; i < ARRAY_COUNT(pthis->childrenGohmaState); i++) { + if (pthis->childrenGohmaState[i] == 0) { + BossGoma_SpawnChildGohma(pthis, globalCtx, i); + break; + } + } + + if (pthis->childrenGohmaState[0] == 0 || pthis->childrenGohmaState[1] == 0 || pthis->childrenGohmaState[2] == 0) { + pthis->spawnGohmasActionTimer = 23; + } + } + + if (pthis->spawnGohmasActionTimer >= 64) { + BossGoma_SetupCeilingIdle(pthis); + } + + pthis->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; +} + +/** + * Prepare to spawn children gohmas, red eye for 70 frames + * During pthis time, the player can interrupt by hitting Gohma and make it fall from the ceiling + */ +void BossGoma_CeilingPrepareSpawnGohmas(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->framesUntilNextAction == 0) { + BossGoma_SetupCeilingSpawnGohmas(pthis); + } + + pthis->eyeState = EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES; + pthis->visualState = VISUALSTATE_RED; +} + +/** + * On the floor, not doing anything special. + */ +void BossGoma_FloorIdle(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 2, 0xBB8); + + if (pthis->framesUntilNextAction == 0) { + BossGoma_SetupFloorMain(pthis); + } +} + +/** + * On the ceiling, not doing anything special. + * Eventually spawns children gohmas, jumping down to the floor when they are killed, or staying on the ceiling as long + * as any is still alive. + */ +void BossGoma_CeilingIdle(BossGoma* pthis, GlobalContext* globalCtx) { + s16 i; + + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + + if (pthis->framesUntilNextAction == 0) { + if (pthis->childrenGohmaState[0] == 0 && pthis->childrenGohmaState[1] == 0 && pthis->childrenGohmaState[2] == 0) { + // if no child gohma has been spawned + BossGoma_SetupCeilingPrepareSpawnGohmas(pthis); + } else if (pthis->childrenGohmaState[0] < 0 && pthis->childrenGohmaState[1] < 0 && + pthis->childrenGohmaState[2] < 0) { + // if all children gohmas are dead + BossGoma_SetupFallJump(pthis); + } else { + for (i = 0; i < ARRAY_COUNT(pthis->childrenGohmaState); i++) { + if (pthis->childrenGohmaState[i] == 0) { + // if any child gohma hasn't been spawned + // pthis seems unreachable since BossGoma_CeilingSpawnGohmas spawns all three and can't be + // interrupted + BossGoma_SetupCeilingSpawnGohmas(pthis); + return; + } + } + // if all children gohmas have been spawned + BossGoma_SetupCeilingMoveToCenter(pthis); + } + } +} + +/** + * Gohma approaches the player as long as it has patience (see patienceTimer), then moves away from the player + * Gohma climbs any wall it collides with + * Uses the "walk cautiously" animation + */ +void BossGoma_FloorMain(BossGoma* pthis, GlobalContext* globalCtx) { + s16 rot; + + SkelAnime_Update(&pthis->skelanime); + + if (Animation_OnFrame(&pthis->skelanime, 1.0f)) { + pthis->doNotMoveThisFrame = true; + } else if (Animation_OnFrame(&pthis->skelanime, 30.0f)) { + pthis->doNotMoveThisFrame = true; + } else if (Animation_OnFrame(&pthis->skelanime, 15.0f)) { + pthis->doNotMoveThisFrame = true; + } else if (Animation_OnFrame(&pthis->skelanime, 16.0f)) { + pthis->doNotMoveThisFrame = true; + } + + if (Animation_OnFrame(&pthis->skelanime, 15.0f)) { + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 1, 3); + } else if (Animation_OnFrame(&pthis->skelanime, 30.0f)) { + BossGoma_PlayEffectsAndSfx(pthis, globalCtx, 2, 3); + } + + if (pthis->frameCount % 64 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_CRY2); + } + + if (!pthis->doNotMoveThisFrame) { + rot = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + + if (pthis->patienceTimer != 0) { + pthis->patienceTimer--; + + if (pthis->actor.xzDistToPlayer < 150.0f) { + BossGoma_SetupFloorAttackPosture(pthis); + } + + Math_ApproachF(&pthis->actor.speedXZ, 10.0f / 3.0f, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.world.rot.y, rot, 5, 0x3E8); + } else { + if (pthis->timer != 0) { + // move away from the player, walking backwards + Math_ApproachF(&pthis->actor.speedXZ, -10.0f, 0.5f, 2.0f); + pthis->skelanime.playSpeed = -3.0f; + if (pthis->timer == 1) { + pthis->actor.speedXZ = 0.0f; + } + } else { + // move away from the player, walking forwards + Math_ApproachF(&pthis->actor.speedXZ, 20.0f / 3.0f, 0.5f, 2.0f); + pthis->skelanime.playSpeed = 2.0f; + rot += 0x8000; + } + + Math_ApproachS(&pthis->actor.world.rot.y, rot, 3, 0x9C4); + } + } + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 8) { + BossGoma_SetupWallClimb(pthis); + } + + if (pthis->framesUntilNextAction == 0 && pthis->patienceTimer != 0) { + BossGoma_SetupFloorIdle(pthis); + } +} + +/** + * Gohma moves up until it reaches the ceiling + */ +void BossGoma_WallClimb(BossGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->frameCount % 8 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_CLIM); + } + + Math_ApproachF(&pthis->actor.velocity.y, 5.0f, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.shape.rot.x, -0x4000, 2, 0x7D0); + Math_ApproachS(&pthis->actor.world.rot.y, pthis->actor.wallYaw + 0x8000, 2, 0x5DC); + + // -320 is a bit below boss room ceiling + if (pthis->actor.world.pos.y > -320.0f) { + BossGoma_SetupCeilingMoveToCenter(pthis); + // allow new spawns + pthis->childrenGohmaState[0] = pthis->childrenGohmaState[1] = pthis->childrenGohmaState[2] = 0; + } +} + +/** + * Goes to BossGoma_CeilingIdle after enough time and after being close enough to the center of the ceiling. + */ +void BossGoma_CeilingMoveToCenter(BossGoma* pthis, GlobalContext* globalCtx) { + s16 angle; + s16 absDiff; + + BossGoma_UpdateCeilingMovement(pthis, globalCtx, 0.0f, -5.0f, true); + + if (pthis->frameCount % 64 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_CRY2); + } + + Math_ApproachS(&pthis->actor.shape.rot.x, -0x8000, 3, 0x3E8); + + // avoid walking into a wall? + if (pthis->actor.bgCheckFlags & 8) { + angle = pthis->actor.shape.rot.y + 0x8000; + + if (angle < pthis->actor.wallYaw) { + absDiff = pthis->actor.wallYaw - angle; + angle = angle + absDiff / 2; + } else { + absDiff = angle - pthis->actor.wallYaw; + angle = pthis->actor.wallYaw + absDiff / 2; + } + + pthis->actor.world.pos.z += Math_CosS(angle) * (5.0f + Rand_ZeroOne() * 5.0f) + Rand_CenteredFloat(2.0f); + pthis->actor.world.pos.x += Math_SinS(angle) * (5.0f + Rand_ZeroOne() * 5.0f) + Rand_CenteredFloat(2.0f); + } + + // timer setup to 30-60 + if (pthis->framesUntilNextAction == 0 && fabsf(-150.0f - pthis->actor.world.pos.x) < 100.0f && + fabsf(-350.0f - pthis->actor.world.pos.z) < 100.0f) { + BossGoma_SetupCeilingIdle(pthis); + } +} + +/** + * Update eye-related properties + * - open/close (eye lid rotation) + * - look at the player (iris rotation) + * - iris scale, when menacing or damaged + */ +void BossGoma_UpdateEye(BossGoma* pthis, GlobalContext* globalCtx) { + s16 targetEyeIrisRotX; + s16 targetEyeIrisRotY; + + if (!pthis->disableGameplayLogic) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES) { + // player + 0xA73 seems to be related to "throwing something" + if (player->unk_A73 != 0) { + player->unk_A73 = 0; + pthis->eyeClosedTimer = 12; + } + + if (pthis->frameCount % 16 == 0 && Rand_ZeroOne() < 0.3f) { + pthis->eyeClosedTimer = 7; + } + } + + if (pthis->childrenGohmaState[0] > 0 || pthis->childrenGohmaState[1] > 0 || pthis->childrenGohmaState[2] > 0) { + pthis->eyeClosedTimer = 7; + } + + if (pthis->eyeClosedTimer != 0) { + pthis->eyeClosedTimer--; + // close eye + Math_ApproachS(&pthis->eyeLidBottomRotX, -0xA98, 1, 0x7D0); + Math_ApproachS(&pthis->eyeLidTopRotX, 0x1600, 1, 0x7D0); + } else { + // open eye + Math_ApproachS(&pthis->eyeLidBottomRotX, 0, 1, 0x7D0); + Math_ApproachS(&pthis->eyeLidTopRotX, 0, 1, 0x7D0); + } + + if (pthis->eyeState != EYESTATE_IRIS_NO_FOLLOW_NO_IFRAMES) { + targetEyeIrisRotY = + Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.shape.rot.y; + targetEyeIrisRotX = + Actor_WorldPitchTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.shape.rot.x; + + if (pthis->actor.shape.rot.x > 0x4000 || pthis->actor.shape.rot.x < -0x4000) { + targetEyeIrisRotY = -(s16)(targetEyeIrisRotY + 0x8000); + targetEyeIrisRotX = -0xBB8; + } + + if (targetEyeIrisRotY > 0x1770) { + targetEyeIrisRotY = 0x1770; + } + + if (targetEyeIrisRotY < -0x1770) { + targetEyeIrisRotY = -0x1770; + } + + Math_ApproachS(&pthis->eyeIrisRotY, targetEyeIrisRotY, 3, 0x7D0); + Math_ApproachS(&pthis->eyeIrisRotX, targetEyeIrisRotX, 3, 0x7D0); + } else { + Math_ApproachS(&pthis->eyeIrisRotY, 0, 3, 0x3E8); + Math_ApproachS(&pthis->eyeIrisRotX, 0, 3, 0x3E8); + } + + Math_ApproachF(&pthis->eyeIrisScaleX, 1.0f, 0.2f, 0.07f); + Math_ApproachF(&pthis->eyeIrisScaleY, 1.0f, 0.2f, 0.07f); + } +} + +/** + * Part of achieving visual effects when spawning children gohmas, + * inflating each tail limb one after the other. + */ +void BossGoma_UpdateTailLimbsScale(BossGoma* pthis) { + s16 i; + + if (pthis->frameCount % 128 == 0) { + pthis->unusedTimer++; + if (pthis->unusedTimer >= 3) { + pthis->unusedTimer = 0; + } + } + + // See BossGoma_CeilingSpawnGohmas for `tailLimbsScaleTimers` usage + for (i = 0; i < ARRAY_COUNT(pthis->tailLimbsScaleTimers); i++) { + if (pthis->tailLimbsScaleTimers[i] != 0) { + pthis->tailLimbsScaleTimers[i]--; + Math_ApproachF(&pthis->tailLimbsScale[i], 1.5f, 0.2f, 0.1f); + } else { + Math_ApproachF(&pthis->tailLimbsScale[i], 1.0f, 0.2f, 0.1f); + } + } +} + +void BossGoma_UpdateHit(BossGoma* pthis, GlobalContext* globalCtx) { + if (pthis->invincibilityFrames != 0) { + pthis->invincibilityFrames--; + } else { + ColliderInfo* acHitInfo = pthis->collider.elements[0].info.acHitInfo; + s32 damage; + + if (pthis->eyeClosedTimer == 0 && pthis->actionFunc != BossGoma_CeilingSpawnGohmas && + (pthis->collider.elements[0].info.bumperFlags & BUMP_HIT)) { + pthis->collider.elements[0].info.bumperFlags &= ~BUMP_HIT; + + if (pthis->actionFunc == BossGoma_CeilingMoveToCenter || pthis->actionFunc == BossGoma_CeilingIdle || + pthis->actionFunc == BossGoma_CeilingPrepareSpawnGohmas) { + BossGoma_SetupFallStruckDown(pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DAM2); + } else if (pthis->actionFunc == BossGoma_FloorStunned && + (damage = CollisionCheck_GetSwordDamage(acHitInfo->toucher.dmgFlags)) != 0) { + pthis->actor.colChkInfo.health -= damage; + + if ((s8)pthis->actor.colChkInfo.health > 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DAM1); + BossGoma_SetupFloorDamaged(pthis); + EffectSsSibuki_SpawnBurst(globalCtx, &pthis->actor.focus.pos); + } else { + BossGoma_SetupDefeated(pthis, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } + + pthis->invincibilityFrames = 10; + } else if (pthis->actionFunc != BossGoma_FloorStunned && pthis->patienceTimer != 0 && + (acHitInfo->toucher.dmgFlags & 0x00000005)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_DAM2); + Audio_StopSfxById(NA_SE_EN_GOMA_CRY1); + pthis->invincibilityFrames = 10; + BossGoma_SetupFloorStunned(pthis); + pthis->sfxFaintTimer = 100; + + if (acHitInfo->toucher.dmgFlags & 1) { + pthis->framesUntilNextAction = 40; + } else { + pthis->framesUntilNextAction = 90; + } + + pthis->timer = 4; + func_80033E88(&pthis->actor, globalCtx, 4, 0xC); + } + } + } +} + +void BossGoma_UpdateMainEnvColor(BossGoma* pthis) { + static f32 colors1[][3] = { + { 255.0f, 17.0f, 0.0f }, { 0.0f, 255.0f, 170.0f }, { 50.0f, 50.0f, 50.0f }, + { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, + }; + static f32 colors2[][3] = { + { 255.0f, 17.0f, 0.0f }, { 0.0f, 255.0f, 170.0f }, { 50.0f, 50.0f, 50.0f }, + { 0.0f, 255.0f, 170.0f }, { 0.0f, 0.0f, 255.0f }, { 255.0f, 17.0f, 0.0f }, + }; + + if (pthis->visualState == VISUALSTATE_DEFAULT && pthis->frameCount & 0x10) { + Math_ApproachF(&pthis->mainEnvColor[0], 50.0f, 0.5f, 20.0f); + Math_ApproachF(&pthis->mainEnvColor[1], 50.0f, 0.5f, 20.0f); + Math_ApproachF(&pthis->mainEnvColor[2], 50.0f, 0.5f, 20.0f); + } else if (pthis->invincibilityFrames != 0) { + if (pthis->invincibilityFrames & 2) { + pthis->mainEnvColor[0] = colors2[pthis->visualState][0]; + pthis->mainEnvColor[1] = colors2[pthis->visualState][1]; + pthis->mainEnvColor[2] = colors2[pthis->visualState][2]; + } else { + pthis->mainEnvColor[0] = colors1[pthis->visualState][0]; + pthis->mainEnvColor[1] = colors1[pthis->visualState][1]; + pthis->mainEnvColor[2] = colors1[pthis->visualState][2]; + } + } else { + Math_ApproachF(&pthis->mainEnvColor[0], colors1[pthis->visualState][0], 0.5f, 20.0f); + Math_ApproachF(&pthis->mainEnvColor[1], colors1[pthis->visualState][1], 0.5f, 20.0f); + Math_ApproachF(&pthis->mainEnvColor[2], colors1[pthis->visualState][2], 0.5f, 20.0f); + } +} + +void BossGoma_UpdateEyeEnvColor(BossGoma* pthis) { + static f32 targetEyeEnvColors[][3] = { + { 255.0f, 17.0f, 0.0f }, { 255.0f, 255.0f, 255.0f }, { 50.0f, 50.0f, 50.0f }, + { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, { 0.0f, 255.0f, 170.0f }, + }; + + Math_ApproachF(&pthis->eyeEnvColor[0], targetEyeEnvColors[pthis->visualState][0], 0.5f, 20.0f); + Math_ApproachF(&pthis->eyeEnvColor[1], targetEyeEnvColors[pthis->visualState][1], 0.5f, 20.0f); + Math_ApproachF(&pthis->eyeEnvColor[2], targetEyeEnvColors[pthis->visualState][2], 0.5f, 20.0f); +} + +void BossGoma_Update(Actor* thisx, GlobalContext* globalCtx) { + BossGoma* pthis = (BossGoma*)thisx; + s32 pad; + + pthis->visualState = VISUALSTATE_DEFAULT; + pthis->frameCount++; + + if (pthis->framesUntilNextAction != 0) { + pthis->framesUntilNextAction--; + } + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->sfxFaintTimer != 0) { + pthis->sfxFaintTimer--; + } + + if (1) {} + + pthis->eyeState = EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES; + pthis->actionFunc(pthis, globalCtx); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (!pthis->doNotMoveThisFrame) { + Actor_MoveForward(&pthis->actor); + } else { + pthis->doNotMoveThisFrame = false; + } + + if (pthis->actor.world.pos.y < -400.0f) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 30.0f, 80.0f, 5); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 30.0f, 80.0f, 1); + } + + BossGoma_UpdateEye(pthis, globalCtx); + BossGoma_UpdateMainEnvColor(pthis); + BossGoma_UpdateEyeEnvColor(pthis); + BossGoma_UpdateTailLimbsScale(pthis); + + if (!pthis->disableGameplayLogic) { + BossGoma_UpdateHit(pthis, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->actionFunc != BossGoma_FloorStunned && pthis->actionFunc != BossGoma_FloorDamaged && + (pthis->actionFunc != BossGoma_FloorMain || pthis->timer == 0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +s32 BossGoma_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossGoma* pthis = (BossGoma*)thisx; + s32 doNotDrawLimb = false; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4685); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->mainEnvColor[0], (s16)pthis->mainEnvColor[1], (s16)pthis->mainEnvColor[2], + 255); + + if (pthis->deadLimbsState[limbIndex] >= 2) { + *dList = NULL; + } + + switch (limbIndex) { + case BOSSGOMA_LIMB_EYE: + if (pthis->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES && pthis->eyeLidBottomRotX < -0xA8C) { + *dList = NULL; + } else if (pthis->invincibilityFrames != 0) { + gDPSetEnvColor(POLY_OPA_DISP++, (s16)(Rand_ZeroOne() * 255.0f), (s16)(Rand_ZeroOne() * 255.0f), + (s16)(Rand_ZeroOne() * 255.0f), 63); + } else { + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->eyeEnvColor[0], (s16)pthis->eyeEnvColor[1], + (s16)pthis->eyeEnvColor[2], 63); + } + break; + + case BOSSGOMA_LIMB_EYE_LID_BOTTOM_ROOT2: + rot->x += pthis->eyeLidBottomRotX; + break; + + case BOSSGOMA_LIMB_EYE_LID_TOP_ROOT2: + rot->x += pthis->eyeLidTopRotX; + break; + + case BOSSGOMA_LIMB_IRIS_ROOT2: + rot->x += pthis->eyeIrisRotX; + rot->y += pthis->eyeIrisRotY; + break; + + case BOSSGOMA_LIMB_IRIS: + if (pthis->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES && pthis->eyeLidBottomRotX < -0xA8C) { + *dList = NULL; + } else { + if (pthis->visualState == VISUALSTATE_DEFEATED) { + gDPSetEnvColor(POLY_OPA_DISP++, 50, 50, 50, 255); + } else { + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + } + + Matrix_TranslateRotateZYX(pos, rot); + + if (*dList != NULL) { + Matrix_Push(); + Matrix_Scale(pthis->eyeIrisScaleX, pthis->eyeIrisScaleY, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4815), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + } + + doNotDrawLimb = true; + } + break; + + case BOSSGOMA_LIMB_TAIL4: + case BOSSGOMA_LIMB_TAIL3: + case BOSSGOMA_LIMB_TAIL2: + case BOSSGOMA_LIMB_TAIL1: + Matrix_TranslateRotateZYX(pos, rot); + + if (*dList != NULL) { + Matrix_Push(); + Matrix_Scale(pthis->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], + pthis->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], + pthis->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4836), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + } + + doNotDrawLimb = true; + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4858); + + return doNotDrawLimb; +} + +void BossGoma_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f tailZero = { 0.0f, 0.0f, 0.0f }; + static Vec3f clawBackLocalPos = { 0.0f, 0.0f, 0.0f }; + static Vec3f focusEyeLocalPos = { 0.0f, 300.0f, 2650.0f }; // in the center of the surface of the lens + static Vec3f zero = { 0.0f, 0.0f, 0.0f }; + Vec3f childPos; + Vec3s childRot; + EnGoma* babyGohma; + BossGoma* pthis = (BossGoma*)thisx; + s32 pad; + MtxF mtx; + + if (limbIndex == BOSSGOMA_LIMB_TAIL4) { // tail end/last part + Matrix_MultVec3f(&tailZero, &pthis->lastTailLimbWorldPos); + } else if (limbIndex == BOSSGOMA_LIMB_TAIL1) { // tail start/first part + Matrix_MultVec3f(&tailZero, &pthis->firstTailLimbWorldPos); + } else if (limbIndex == BOSSGOMA_LIMB_EYE) { + Matrix_MultVec3f(&focusEyeLocalPos, &pthis->actor.focus.pos); + } else if (limbIndex == BOSSGOMA_LIMB_R_FEET_BACK) { + Matrix_MultVec3f(&clawBackLocalPos, &pthis->rightHandBackLimbWorldPos); + } else if (limbIndex == BOSSGOMA_LIMB_L_FEET_BACK) { + Matrix_MultVec3f(&clawBackLocalPos, &pthis->leftHandBackLimbWorldPos); + } + + if (pthis->visualState == VISUALSTATE_DEFEATED) { + if (*dList != NULL) { + Matrix_MultVec3f(&clawBackLocalPos, &pthis->defeatedLimbPositions[limbIndex]); + } else { + pthis->defeatedLimbPositions[limbIndex].y = 10000.0f; + } + } + + if (pthis->deadLimbsState[limbIndex] == 1) { + pthis->deadLimbsState[limbIndex] = 2; + Matrix_MultVec3f(&zero, &childPos); + Matrix_Get(&mtx); + Matrix_MtxFToYXZRotS(&mtx, &childRot, 0); + // These are the pieces of Gohma as it falls apart. It appears to use the same actor as the baby gohmas. + babyGohma = (EnGoma*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_GOMA, + childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, childRot.z, + sDeadLimbLifetime[limbIndex] + 100); + if (babyGohma != NULL) { + babyGohma->bossLimbDl = *dList; + babyGohma->actor.objBankIndex = pthis->actor.objBankIndex; + } + } + + Collider_UpdateSpheres(limbIndex, &pthis->collider); +} + +Gfx* BossGoma_EmptyDlist(GraphicsContext* gfxCtx) { + Gfx* dListHead; + Gfx* dList; + + dList = dListHead = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 1); + + gSPEndDisplayList(dListHead++); + + return dList; +} + +Gfx* BossGoma_NoBackfaceCullingDlist(GraphicsContext* gfxCtx) { + Gfx* dListHead; + Gfx* dList; + + dList = dListHead = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 4); + + gDPPipeSync(dListHead++); + gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2); + gSPClearGeometryMode(dListHead++, G_CULL_BACK); + gSPEndDisplayList(dListHead++); + + return dList; +} + +void BossGoma_Draw(Actor* thisx, GlobalContext* globalCtx) { + BossGoma* pthis = (BossGoma*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 4991); + + func_80093D18(globalCtx->state.gfxCtx); + Matrix_Translate(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); + + if (pthis->noBackfaceCulling) { + gSPSegment(POLY_OPA_DISP++, 0x08, BossGoma_NoBackfaceCullingDlist(globalCtx->state.gfxCtx)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, BossGoma_EmptyDlist(globalCtx->state.gfxCtx)); + } + + SkelAnime_DrawOpa(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, BossGoma_OverrideLimbDraw, + BossGoma_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_goma.c", 5012); +} + +void BossGoma_SpawnChildGohma(BossGoma* pthis, GlobalContext* globalCtx, s16 i) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_GOMA, pthis->lastTailLimbWorldPos.x, + pthis->lastTailLimbWorldPos.y - 50.0f, pthis->lastTailLimbWorldPos.z, 0, i * (0x10000 / 3), 0, i); + + pthis->childrenGohmaState[i] = 1; +} diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.cpp similarity index 55% rename from src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c rename to src/overlays/actors/ovl_Boss_Mo/z_boss_mo.cpp index 17131779c..78da466ba 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.cpp @@ -74,11 +74,11 @@ void BossMo_UpdateTent(Actor* thisx, GlobalContext* globalCtx); void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx); void BossMo_DrawTent(Actor* thisx, GlobalContext* globalCtx); -void BossMo_UpdateEffects(BossMo* this, GlobalContext* globalCtx); +void BossMo_UpdateEffects(BossMo* pthis, GlobalContext* globalCtx); void BossMo_DrawEffects(BossMoEffect* effect, GlobalContext* globalCtx); -void BossMo_SetupTentacle(BossMo* this, GlobalContext* globalCtx); -void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx); +void BossMo_SetupTentacle(BossMo* pthis, GlobalContext* globalCtx); +void BossMo_Tentacle(BossMo* pthis, GlobalContext* globalCtx); void BossMo_Unknown(void); @@ -141,7 +141,7 @@ typedef enum { /* 150 */ MO_DEATH_MO_CORE_BURST = 150 } BossMoCsState; -const ActorInit Boss_Mo_InitVars = { +ActorInit Boss_Mo_InitVars = { ACTOR_BOSS_MO, ACTORCAT_BOSS, FLAGS, @@ -163,7 +163,7 @@ static f32 sFlatWidth[41] = { 8.6f, 8.3f, 8.2f, 8.1f, 7.2f, 6.7f, 5.9f, 4.9f, 2.7f, 0.0f, 0.0f, 0.0f, 0.0f, }; -#include "z_boss_mo_colchk.c" +#include "z_boss_mo_colchk.cpp" static BossMoEffect sEffects[300]; static s32 sSeed1; @@ -349,33 +349,33 @@ static f32 sDropletWidth[41] = { void BossMo_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BossMo* this = (BossMo*)thisx; + BossMo* pthis = (BossMo*)thisx; u16 i; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - if (this->actor.params != BOSSMO_TENTACLE) { + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + if (pthis->actor.params != BOSSMO_TENTACLE) { Flags_SetSwitch(globalCtx, 0x14); - sMorphaCore = this; - MO_WATER_LEVEL(globalCtx) = this->waterLevel = MO_WATER_LEVEL(globalCtx); + sMorphaCore = pthis; + MO_WATER_LEVEL(globalCtx) = pthis->waterLevel = MO_WATER_LEVEL(globalCtx); globalCtx->roomCtx.unk_74[0] = 0xA0; globalCtx->specialEffects = sEffects; for (i = 0; i < ARRAY_COUNT(sEffects); i++) { sEffects[i].type = MO_FX_NONE; } - this->actor.world.pos.x = 200.0f; - this->actor.world.pos.y = MO_WATER_LEVEL(globalCtx) + 50.0f; - this->fwork[MO_TENT_SWING_SIZE_X] = 5.0f; - this->drawActor = true; - this->actor.colChkInfo.health = 20; - this->actor.colChkInfo.mass = 0; - this->actor.params = 0; - Actor_SetScale(&this->actor, 0.01f); - Collider_InitCylinder(globalCtx, &this->coreCollider); - Collider_SetCylinder(globalCtx, &this->coreCollider, &this->actor, &sCylinderInit); + pthis->actor.world.pos.x = 200.0f; + pthis->actor.world.pos.y = MO_WATER_LEVEL(globalCtx) + 50.0f; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 5.0f; + pthis->drawActor = true; + pthis->actor.colChkInfo.health = 20; + pthis->actor.colChkInfo.mass = 0; + pthis->actor.params = 0; + Actor_SetScale(&pthis->actor, 0.01f); + Collider_InitCylinder(globalCtx, &pthis->coreCollider); + Collider_SetCylinder(globalCtx, &pthis->coreCollider, &pthis->actor, &sCylinderInit); if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { - Actor_Kill(&this->actor); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, -280.0f, 0.0f, 0, + Actor_Kill(&pthis->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, -280.0f, 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -200.0f, -280.0f, 0.0f, 0, 0, 0, 0); globalCtx->roomCtx.unk_74[0] = 0xFF; @@ -384,52 +384,52 @@ void BossMo_Init(Actor* thisx, GlobalContext* globalCtx2) { } if (gSaveContext.eventChkInf[7] & 0x10) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); - this->tentMaxAngle = 5.0f; - this->timers[0] = 50; + pthis->tentMaxAngle = 5.0f; + pthis->timers[0] = 50; } else { - this->csState = MO_INTRO_WAIT; - this->work[MO_TENT_ACTION_STATE] = MO_CORE_INTRO_WAIT; - this->actor.world.pos.x = 1000.0f; - this->timers[0] = 60; + pthis->csState = MO_INTRO_WAIT; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_INTRO_WAIT; + pthis->actor.world.pos.x = 1000.0f; + pthis->timers[0] = 60; } - sMorphaTent1 = (BossMo*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_MO, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, BOSSMO_TENTACLE); - this->actor.draw = BossMo_DrawCore; - this->actor.update = BossMo_UpdateCore; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_BOSS); + sMorphaTent1 = (BossMo*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_MO, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, BOSSMO_TENTACLE); + pthis->actor.draw = BossMo_DrawCore; + pthis->actor.update = BossMo_UpdateCore; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_BOSS); } else { - Actor_SetScale(&this->actor, 0.01f); - BossMo_SetupTentacle(this, globalCtx); - this->actor.colChkInfo.mass = 0xFF; + Actor_SetScale(&pthis->actor, 0.01f); + BossMo_SetupTentacle(pthis, globalCtx); + pthis->actor.colChkInfo.mass = 0xFF; MO_WATER_LEVEL(globalCtx) = -50; - this->waterTexAlpha = 90.0f; - this->actor.world.pos.y = MO_WATER_LEVEL(globalCtx); - this->actor.prevPos = this->targetPos = this->actor.world.pos; - Collider_InitJntSph(globalCtx, &this->tentCollider); - Collider_SetJntSph(globalCtx, &this->tentCollider, &this->actor, &sJntSphInit, this->tentElements); - this->tentMaxAngle = 1.0f; + pthis->waterTexAlpha = 90.0f; + pthis->actor.world.pos.y = MO_WATER_LEVEL(globalCtx); + pthis->actor.prevPos = pthis->targetPos = pthis->actor.world.pos; + Collider_InitJntSph(globalCtx, &pthis->tentCollider); + Collider_SetJntSph(globalCtx, &pthis->tentCollider, &pthis->actor, &sJntSphInit, pthis->tentElements); + pthis->tentMaxAngle = 1.0f; } } void BossMo_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BossMo* this = (BossMo*)thisx; + BossMo* pthis = (BossMo*)thisx; - if (this->actor.params >= BOSSMO_TENTACLE) { - Collider_DestroyJntSph(globalCtx, &this->tentCollider); + if (pthis->actor.params >= BOSSMO_TENTACLE) { + Collider_DestroyJntSph(globalCtx, &pthis->tentCollider); } else { - Collider_DestroyCylinder(globalCtx, &this->coreCollider); + Collider_DestroyCylinder(globalCtx, &pthis->coreCollider); } } -void BossMo_SetupTentacle(BossMo* this, GlobalContext* globalCtx) { - this->actionFunc = BossMo_Tentacle; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_WAIT; - this->timers[0] = 50 + (s16)Rand_ZeroFloat(20.0f); +void BossMo_SetupTentacle(BossMo* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossMo_Tentacle; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_WAIT; + pthis->timers[0] = 50 + (s16)Rand_ZeroFloat(20.0f); } -void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { +void BossMo_Tentacle(BossMo* pthis, GlobalContext* globalCtx) { s16 tentXrot; s16 sp1B4 = 0; s32 buttons; @@ -438,7 +438,7 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { s16 indS1; Camera* camera1; Camera* camera2; - BossMo* otherTent = (BossMo*)this->otherTent; + BossMo* otherTent = (BossMo*)pthis->otherTent; f32 maxSwingRateX; f32 maxSwingLagX; f32 maxSwingSizeX; @@ -476,14 +476,14 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { Vec3f spD4; Vec3f spC8; - if (this->work[MO_TENT_ACTION_STATE] <= MO_TENT_DEATH_3) { - this->actor.world.pos.y = MO_WATER_LEVEL(globalCtx); + if (pthis->work[MO_TENT_ACTION_STATE] <= MO_TENT_DEATH_3) { + pthis->actor.world.pos.y = MO_WATER_LEVEL(globalCtx); } - if ((this->work[MO_TENT_ACTION_STATE] == MO_TENT_READY) || - (this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_START) || - (this->work[MO_TENT_ACTION_STATE] == MO_TENT_RETREAT) || (this->work[MO_TENT_ACTION_STATE] == MO_TENT_SWING) || - (this->work[MO_TENT_ACTION_STATE] == MO_TENT_SHAKE)) { - if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_READY) { + if ((pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_READY) || + (pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_START) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_RETREAT) || (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_SWING) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_SHAKE)) { + if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_READY) { if (sMorphaCore->csState != MO_BATTLE) { maxSwingRateX = 2000.0f; maxSwingLagX = 3000.0f; @@ -503,7 +503,7 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { swingRateAccel = 20.0f; swingSizeAccel = 30.0f; } - } else if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_SWING) { + } else if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_SWING) { maxSwingRateX = 2500.0f; maxSwingLagX = -1000.0f; maxSwingSizeX = 3000.0f; @@ -512,11 +512,11 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { maxSwingSizeZ = 0.0; swingRateAccel = 30.0f; swingSizeAccel = 60.0f; - if (((this->sfxTimer % 16) == 0) && (this->timers[0] < 30)) { - Audio_PlaySoundIncreasinglyTransposed(&this->tentTipPos, NA_SE_EN_MOFER_WAVE, gMorphaTransposeTable); + if (((pthis->sfxTimer % 16) == 0) && (pthis->timers[0] < 30)) { + Audio_PlaySoundIncreasinglyTransposed(&pthis->tentTipPos, NA_SE_EN_MOFER_WAVE, gMorphaTransposeTable); } - } else if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_SHAKE) { - if (this->timers[0] > 40) { + } else if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_SHAKE) { + if (pthis->timers[0] > 40) { maxSwingRateX = 1300.0f; maxSwingLagX = -3200.0f; maxSwingSizeX = 7000.0f; @@ -525,8 +525,8 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { maxSwingSizeZ = 5000.0f; swingRateAccel = 30.0f; swingSizeAccel = 60.0f; - if ((this->sfxTimer % 32) == 0) { - Audio_PlaySoundIncreasinglyTransposed(&this->tentTipPos, NA_SE_EN_MOFER_WAVE, + if ((pthis->sfxTimer % 32) == 0) { + Audio_PlaySoundIncreasinglyTransposed(&pthis->tentTipPos, NA_SE_EN_MOFER_WAVE, gMorphaTransposeTable); func_800AA000(0, 100, 5, 2); func_8002F7DC(&player->actor, NA_SE_VO_LI_FREEZE + player->ageProperties->unk_92); @@ -540,14 +540,14 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { maxSwingSizeZ = 100.0f; swingRateAccel = 70.0f; swingSizeAccel = 70.0f; - if ((this->sfxTimer % 16) == 0) { - Audio_PlaySoundIncreasinglyTransposed(&this->tentTipPos, NA_SE_EN_MOFER_WAVE, + if ((pthis->sfxTimer % 16) == 0) { + Audio_PlaySoundIncreasinglyTransposed(&pthis->tentTipPos, NA_SE_EN_MOFER_WAVE, gMorphaTransposeTable); func_800AA000(0, 160, 5, 4); func_8002F7DC(&player->actor, NA_SE_VO_LI_FREEZE + player->ageProperties->unk_92); } } - } else if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_RETREAT) { + } else if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_RETREAT) { maxSwingRateX = 1300.0f; maxSwingLagX = 3200.0f; maxSwingSizeX = 7000.0f; @@ -556,7 +556,7 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { maxSwingSizeZ = 5000.0f; swingRateAccel = 30.0f; swingSizeAccel = 30.0f; - } else if (this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_START) { + } else if (pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_START) { maxSwingRateX = -400.0f; maxSwingLagX = -3200.0f; maxSwingSizeX = 0.0f; @@ -566,42 +566,42 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { swingRateAccel = 30.0f; swingSizeAccel = 60.0f; } - Math_ApproachF(&this->fwork[MO_TENT_SWING_RATE_X], maxSwingRateX, 1.0f, swingRateAccel); - Math_ApproachF(&this->fwork[MO_TENT_SWING_LAG_X], maxSwingLagX, 1.0f, 30.0f); - Math_ApproachF(&this->fwork[MO_TENT_SWING_SIZE_X], maxSwingSizeX, 1.0f, swingSizeAccel); - Math_ApproachF(&this->fwork[MO_TENT_SWING_RATE_Z], maxSwingRateZ, 1.0f, swingRateAccel); - Math_ApproachF(&this->fwork[MO_TENT_SWING_LAG_Z], maxSwingLagZ, 1.0f, 30.0f); - Math_ApproachF(&this->fwork[MO_TENT_SWING_SIZE_Z], maxSwingSizeZ, 1.0f, swingSizeAccel); - this->xSwing += (s16)this->fwork[MO_TENT_SWING_RATE_X]; - this->zSwing += (s16)this->fwork[MO_TENT_SWING_RATE_Z]; + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_RATE_X], maxSwingRateX, 1.0f, swingRateAccel); + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_LAG_X], maxSwingLagX, 1.0f, 30.0f); + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_SIZE_X], maxSwingSizeX, 1.0f, swingSizeAccel); + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_RATE_Z], maxSwingRateZ, 1.0f, swingRateAccel); + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_LAG_Z], maxSwingLagZ, 1.0f, 30.0f); + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_SIZE_Z], maxSwingSizeZ, 1.0f, swingSizeAccel); + pthis->xSwing += (s16)pthis->fwork[MO_TENT_SWING_RATE_X]; + pthis->zSwing += (s16)pthis->fwork[MO_TENT_SWING_RATE_Z]; } - switch (this->work[MO_TENT_ACTION_STATE]) { + switch (pthis->work[MO_TENT_ACTION_STATE]) { case MO_TENT_WAIT: - this->actor.flags &= ~ACTOR_FLAG_0; - if (this == sMorphaTent2) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_SPAWN; - this->timers[0] = 70; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis == sMorphaTent2) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_SPAWN; + pthis->timers[0] = 70; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; } break; case MO_TENT_SPAWN: - this->drawActor = true; - this->baseBubblesTimer = 20; - if (this->timers[0] < 20) { - Math_ApproachF(&this->tentRippleSize, 0.15f, 0.5f, 0.01); - Math_ApproachF(&this->baseAlpha, 150.0f, 1.0f, 5.0f); - if (this->baseAlpha >= 150.0f) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; - this->timers[0] = 60; + pthis->drawActor = true; + pthis->baseBubblesTimer = 20; + if (pthis->timers[0] < 20) { + Math_ApproachF(&pthis->tentRippleSize, 0.15f, 0.5f, 0.01); + Math_ApproachF(&pthis->baseAlpha, 150.0f, 1.0f, 5.0f); + if (pthis->baseAlpha >= 150.0f) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; + pthis->timers[0] = 60; } } - if (this->timers[0] > 50) { + if (pthis->timers[0] > 50) { rippleCount = 1; - } else if (this->timers[0] > 40) { + } else if (pthis->timers[0] > 40) { rippleCount = 3; - } else if (this->timers[0] > 30) { + } else if (pthis->timers[0] > 30) { rippleCount = 5; - } else if (this->timers[0] > 20) { + } else if (pthis->timers[0] > 20) { rippleCount = 8; } else { rippleCount = 3; @@ -609,340 +609,340 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { for (indS1 = 0; indS1 < rippleCount; indS1++) { randFloat = Rand_ZeroFloat(50.0f); randAngle = Rand_ZeroFloat(0x10000); - ripplePos = this->actor.world.pos; + ripplePos = pthis->actor.world.pos; ripplePos.x += sinf(randAngle) * randFloat; ripplePos.z += cosf(randAngle) * randFloat; ripplePos.y = MO_WATER_LEVEL(globalCtx); - BossMo_SpawnRipple(globalCtx->specialEffects, &ripplePos, 40.0f, 110.0f, 80, 290, MO_FX_SMALL_RIPPLE); + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &ripplePos, 40.0f, 110.0f, 80, 290, MO_FX_SMALL_RIPPLE); } break; case MO_TENT_READY: case MO_TENT_SWING: if (sMorphaCore->csState == MO_BATTLE) { - func_80078914(&this->tentTipPos, NA_SE_EN_MOFER_APPEAR - SFX_FLAG); + func_80078914(&pthis->tentTipPos, NA_SE_EN_MOFER_APPEAR - SFX_FLAG); } - Math_ApproachF(&this->waterLevelMod, -5.0f, 0.1f, 0.4f); + Math_ApproachF(&pthis->waterLevelMod, -5.0f, 0.1f, 0.4f); for (indS1 = 0; indS1 < 41; indS1++) { - sin = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_X] * indS1) + this->xSwing); - tempf1 = this->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); + sin = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_X] * indS1) + pthis->xSwing); + tempf1 = pthis->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); - cos = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_Z] * indS1) + this->zSwing); - tempf2 = this->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); + cos = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_Z] * indS1) + pthis->zSwing); + tempf2 = pthis->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); if (indS1 == 28) { - sp1B4 = this->tentRot[indS1].x; + sp1B4 = pthis->tentRot[indS1].x; } - Math_ApproachS(&this->tentRot[indS1].x, tempf1, 1.0f / this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].x, tempf1, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, tempf2, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } - this->targetPos = this->actor.world.pos; - Math_ApproachF(&this->actor.speedXZ, 0.75f, 1.0f, 0.04f); - if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_SWING) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->attackAngleMod, 0xA, + pthis->targetPos = pthis->actor.world.pos; + Math_ApproachF(&pthis->actor.speedXZ, 0.75f, 1.0f, 0.04f); + if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_SWING) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + pthis->attackAngleMod, 0xA, 0x1F4); } - Math_ApproachF(&this->fwork[MO_TENT_MAX_STRETCH], 1.0f, 0.5f, 0.04); + Math_ApproachF(&pthis->fwork[MO_TENT_MAX_STRETCH], 1.0f, 0.5f, 0.04); if (sMorphaCore->csState != MO_BATTLE) { - Math_ApproachF(&this->tentMaxAngle, 1.0f, 1.0f, 0.001f); - Math_ApproachF(&this->tentSpeed, 240.0f, 1.0f, 3.0); + Math_ApproachF(&pthis->tentMaxAngle, 1.0f, 1.0f, 0.001f); + Math_ApproachF(&pthis->tentSpeed, 240.0f, 1.0f, 3.0); } else { - Math_ApproachF(&this->tentMaxAngle, 1.0f, 1.0f, 0.002f); - Math_ApproachF(&this->tentSpeed, 400.0f, 1.0f, 6.0f); + Math_ApproachF(&pthis->tentMaxAngle, 1.0f, 1.0f, 0.002f); + Math_ApproachF(&pthis->tentSpeed, 400.0f, 1.0f, 6.0f); } - if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_READY) { - if ((this->timers[0] == 0) && !HAS_LINK(otherTent)) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_SWING; - this->timers[0] = 50; + if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_READY) { + if ((pthis->timers[0] == 0) && !HAS_LINK(otherTent)) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_SWING; + pthis->timers[0] = 50; Audio_ResetIncreasingTranspose(); - this->attackAngleMod = Rand_CenteredFloat(0x1000); + pthis->attackAngleMod = Rand_CenteredFloat(0x1000); } } else { - tentXrot = this->tentRot[28].x; - if ((this->timers[0] == 0) && (tentXrot >= 0) && (sp1B4 < 0)) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_ATTACK; - if (this == sMorphaTent1) { - this->timers[0] = 175; + tentXrot = pthis->tentRot[28].x; + if ((pthis->timers[0] == 0) && (tentXrot >= 0) && (sp1B4 < 0)) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_ATTACK; + if (pthis == sMorphaTent1) { + pthis->timers[0] = 175; } else { - this->timers[0] = 55; + pthis->timers[0] = 55; } } } break; case MO_TENT_ATTACK: - this->actor.flags |= ACTOR_FLAG_24; - func_80078914(&this->tentTipPos, NA_SE_EN_MOFER_ATTACK - SFX_FLAG); - Math_ApproachF(&this->waterLevelMod, -5.0f, 0.1f, 0.4f); + pthis->actor.flags |= ACTOR_FLAG_24; + func_80078914(&pthis->tentTipPos, NA_SE_EN_MOFER_ATTACK - SFX_FLAG); + Math_ApproachF(&pthis->waterLevelMod, -5.0f, 0.1f, 0.4f); for (indS1 = 0; indS1 < 41; indS1++) { - Math_ApproachF(&this->tentStretch[indS1].y, - this->fwork[MO_TENT_MAX_STRETCH] * ((((40 - indS1) * 25.0f) / 100.0f) + 5.0f), 0.5f, + Math_ApproachF(&pthis->tentStretch[indS1].y, + pthis->fwork[MO_TENT_MAX_STRETCH] * ((((40 - indS1) * 25.0f) / 100.0f) + 5.0f), 0.5f, 0.7f); - Math_ApproachS(&this->tentRot[indS1].x, sAttackRot[indS1] * 0x100, 1.0f / this->tentMaxAngle, - this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, 0, 1.0f / this->tentMaxAngle, this->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].x, sAttackRot[indS1] * 0x100, 1.0f / pthis->tentMaxAngle, + pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, 0, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } - this->targetPos = this->actor.world.pos; - Math_ApproachF(&this->tentMaxAngle, 0.5f, 1.0f, 0.01); - Math_ApproachF(&this->tentSpeed, 160.0f, 1.0f, 50.0f); - if ((this->timers[0] == 0) || (this->linkHitTimer != 0)) { - dx = this->tentPos[22].x - player->actor.world.pos.x; - dy = this->tentPos[22].y - player->actor.world.pos.y; - dz = this->tentPos[22].z - player->actor.world.pos.z; + pthis->targetPos = pthis->actor.world.pos; + Math_ApproachF(&pthis->tentMaxAngle, 0.5f, 1.0f, 0.01); + Math_ApproachF(&pthis->tentSpeed, 160.0f, 1.0f, 50.0f); + if ((pthis->timers[0] == 0) || (pthis->linkHitTimer != 0)) { + dx = pthis->tentPos[22].x - player->actor.world.pos.x; + dy = pthis->tentPos[22].y - player->actor.world.pos.y; + dz = pthis->tentPos[22].z - player->actor.world.pos.z; if ((fabsf(dy) < 50.0f) && !HAS_LINK(otherTent) && (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 120.0f)) { - this->tentMaxAngle = .001f; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_CURL; - this->timers[0] = 40; - this->tentSpeed = 0; - if ((s16)(this->actor.shape.rot.y - this->actor.yawTowardsPlayer) >= 0) { - this->linkToLeft = false; + pthis->tentMaxAngle = .001f; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_CURL; + pthis->timers[0] = 40; + pthis->tentSpeed = 0; + if ((s16)(pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer) >= 0) { + pthis->linkToLeft = false; } else { - this->linkToLeft = true; + pthis->linkToLeft = true; } } else { - this->tentMaxAngle = .001f; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; - this->tentSpeed = 0; - this->fwork[MO_TENT_SWING_RATE_X] = 0; - this->fwork[MO_TENT_SWING_RATE_Z] = 0; - this->fwork[MO_TENT_SWING_SIZE_X] = 0; - this->fwork[MO_TENT_SWING_SIZE_Z] = 0; - this->timers[0] = 30; - if ((fabsf(player->actor.world.pos.x - this->actor.world.pos.x) > 300.0f) || + pthis->tentMaxAngle = .001f; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; + pthis->tentSpeed = 0; + pthis->fwork[MO_TENT_SWING_RATE_X] = 0; + pthis->fwork[MO_TENT_SWING_RATE_Z] = 0; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 0; + pthis->fwork[MO_TENT_SWING_SIZE_Z] = 0; + pthis->timers[0] = 30; + if ((fabsf(player->actor.world.pos.x - pthis->actor.world.pos.x) > 300.0f) || (player->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) || HAS_LINK(otherTent) || - (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) > 300.0f)) { + (fabsf(player->actor.world.pos.z - pthis->actor.world.pos.z) > 300.0f)) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; - this->timers[0] = 75; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; + pthis->timers[0] = 75; } } } break; case MO_TENT_CURL: case MO_TENT_GRAB: - Math_ApproachF(&this->waterLevelMod, -5.0f, 0.1f, 0.4f); - if (this->timers[0] == 125) { - this->tentMaxAngle = .001f; - this->tentSpeed = 0; + Math_ApproachF(&pthis->waterLevelMod, -5.0f, 0.1f, 0.4f); + if (pthis->timers[0] == 125) { + pthis->tentMaxAngle = .001f; + pthis->tentSpeed = 0; } for (indS1 = 0; indS1 < 41; indS1++) { - if (this->timers[0] > 25) { - if (!this->linkToLeft) { - Math_ApproachS(&this->tentRot[indS1].z, sCurlRot[indS1] * 0x100, 1.0f / this->tentMaxAngle, - this->tentSpeed); + if (pthis->timers[0] > 25) { + if (!pthis->linkToLeft) { + Math_ApproachS(&pthis->tentRot[indS1].z, sCurlRot[indS1] * 0x100, 1.0f / pthis->tentMaxAngle, + pthis->tentSpeed); } else { - Math_ApproachS(&this->tentRot[indS1].z, sCurlRot[indS1] * -0x100, 1.0f / this->tentMaxAngle, - this->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, sCurlRot[indS1] * -0x100, 1.0f / pthis->tentMaxAngle, + pthis->tentSpeed); } } else { - if (!this->linkToLeft) { - Math_ApproachS(&this->tentRot[indS1].z, sGrabRot[indS1] * 0x100, 1.0f / this->tentMaxAngle, - this->tentSpeed); + if (!pthis->linkToLeft) { + Math_ApproachS(&pthis->tentRot[indS1].z, sGrabRot[indS1] * 0x100, 1.0f / pthis->tentMaxAngle, + pthis->tentSpeed); } else { - Math_ApproachS(&this->tentRot[indS1].z, sGrabRot[indS1] * -0x100, 1.0f / this->tentMaxAngle, - this->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, sGrabRot[indS1] * -0x100, 1.0f / pthis->tentMaxAngle, + pthis->tentSpeed); } } } - Math_ApproachF(&this->tentMaxAngle, 0.1f, 1.0f, 0.01f); - Math_ApproachF(&this->tentSpeed, 960.0f, 1.0f, 30.0f); - if (this->timers[0] >= 30) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0xC8); + Math_ApproachF(&pthis->tentMaxAngle, 0.1f, 1.0f, 0.01f); + Math_ApproachF(&pthis->tentSpeed, 960.0f, 1.0f, 30.0f); + if (pthis->timers[0] >= 30) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0xC8); } - if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_CURL) { - if ((this->timers[0] >= 5) && (this->linkHitTimer != 0) && (player->actor.parent == NULL)) { + if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_CURL) { + if ((pthis->timers[0] >= 5) && (pthis->linkHitTimer != 0) && (player->actor.parent == NULL)) { if (globalCtx->grabPlayer(globalCtx, player)) { - player->actor.parent = &this->actor; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_GRAB; - func_80078914(&this->tentTipPos, NA_SE_EN_MOFER_CATCH); + player->actor.parent = &pthis->actor; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_GRAB; + func_80078914(&pthis->tentTipPos, NA_SE_EN_MOFER_CATCH); Audio_PlaySoundGeneral(NA_SE_VO_LI_DAMAGE_S, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; - this->tentMaxAngle = .001f; - this->tentSpeed = 0; - this->fwork[MO_TENT_SWING_SIZE_Z] = 0; - this->fwork[MO_TENT_SWING_SIZE_X] = 0; - this->fwork[MO_TENT_SWING_RATE_Z] = 0; - this->fwork[MO_TENT_SWING_RATE_X] = 0; - this->timers[0] = 30; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; + pthis->tentMaxAngle = .001f; + pthis->tentSpeed = 0; + pthis->fwork[MO_TENT_SWING_SIZE_Z] = 0; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 0; + pthis->fwork[MO_TENT_SWING_RATE_Z] = 0; + pthis->fwork[MO_TENT_SWING_RATE_X] = 0; + pthis->timers[0] = 30; } } - if (this->timers[0] == 4) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; - this->tentMaxAngle = .001f; - this->tentSpeed = 0; - this->fwork[MO_TENT_SWING_SIZE_Z] = 0; - this->fwork[MO_TENT_SWING_SIZE_X] = 0; - this->fwork[MO_TENT_SWING_RATE_Z] = 0; - this->fwork[MO_TENT_SWING_RATE_X] = 0; - this->timers[0] = 30; + if (pthis->timers[0] == 4) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; + pthis->tentMaxAngle = .001f; + pthis->tentSpeed = 0; + pthis->fwork[MO_TENT_SWING_SIZE_Z] = 0; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 0; + pthis->fwork[MO_TENT_SWING_RATE_Z] = 0; + pthis->fwork[MO_TENT_SWING_RATE_X] = 0; + pthis->timers[0] = 30; } } - if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB) { + if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB) { player->unk_850 = 0xA; player->actor.speedXZ = player->actor.velocity.y = 0; - Math_ApproachF(&player->actor.world.pos.x, this->grabPosRot.pos.x, 0.5f, 20.0f); - Math_ApproachF(&player->actor.world.pos.y, this->grabPosRot.pos.y, 0.5f, 20.0f); - Math_ApproachF(&player->actor.world.pos.z, this->grabPosRot.pos.z, 0.5f, 20.0f); - Math_ApproachS(&player->actor.shape.rot.x, this->grabPosRot.rot.x, 2, 0x7D0); - Math_ApproachS(&player->actor.shape.rot.y, this->grabPosRot.rot.y, 2, 0x7D0); - Math_ApproachS(&player->actor.shape.rot.z, this->grabPosRot.rot.z, 2, 0x7D0); - if (this->timers[0] == 0) { + Math_ApproachF(&player->actor.world.pos.x, pthis->grabPosRot.pos.x, 0.5f, 20.0f); + Math_ApproachF(&player->actor.world.pos.y, pthis->grabPosRot.pos.y, 0.5f, 20.0f); + Math_ApproachF(&player->actor.world.pos.z, pthis->grabPosRot.pos.z, 0.5f, 20.0f); + Math_ApproachS(&player->actor.shape.rot.x, pthis->grabPosRot.rot.x, 2, 0x7D0); + Math_ApproachS(&player->actor.shape.rot.y, pthis->grabPosRot.rot.y, 2, 0x7D0); + Math_ApproachS(&player->actor.shape.rot.z, pthis->grabPosRot.rot.z, 2, 0x7D0); + if (pthis->timers[0] == 0) { camera1 = Gameplay_GetCamera(globalCtx, MAIN_CAM); - this->work[MO_TENT_ACTION_STATE] = MO_TENT_SHAKE; - this->tentMaxAngle = .001f; - this->fwork[MO_TENT_SWING_RATE_X] = this->fwork[MO_TENT_SWING_RATE_Z] = - this->fwork[MO_TENT_SWING_SIZE_X] = this->fwork[MO_TENT_SWING_SIZE_Z] = this->tentSpeed = 0; - this->timers[0] = 150; - this->mashCounter = 0; - this->sfxTimer = 30; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_SHAKE; + pthis->tentMaxAngle = .001f; + pthis->fwork[MO_TENT_SWING_RATE_X] = pthis->fwork[MO_TENT_SWING_RATE_Z] = + pthis->fwork[MO_TENT_SWING_SIZE_X] = pthis->fwork[MO_TENT_SWING_SIZE_Z] = pthis->tentSpeed = 0; + pthis->timers[0] = 150; + pthis->mashCounter = 0; + pthis->sfxTimer = 30; Audio_ResetIncreasingTranspose(); func_80064520(globalCtx, &globalCtx->csCtx); - this->csCamera = Gameplay_CreateSubCamera(globalCtx); + pthis->csCamera = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->csCamera, CAM_STAT_ACTIVE); - this->cameraEye = camera1->eye; - this->cameraAt = camera1->at; - this->cameraYaw = Math_FAtan2F(this->cameraEye.x - this->actor.world.pos.x, - this->cameraEye.z - this->actor.world.pos.z); - this->cameraYawRate = 0; + Gameplay_ChangeCameraStatus(globalCtx, pthis->csCamera, CAM_STAT_ACTIVE); + pthis->cameraEye = camera1->eye; + pthis->cameraAt = camera1->at; + pthis->cameraYaw = Math_FAtan2F(pthis->cameraEye.x - pthis->actor.world.pos.x, + pthis->cameraEye.z - pthis->actor.world.pos.z); + pthis->cameraYawRate = 0; goto tent_shake; } } break; tent_shake: case MO_TENT_SHAKE: - if (this->timers[0] == 138) { + if (pthis->timers[0] == 138) { ShrinkWindow_SetVal(0); Interface_ChangeAlpha(0xB); } - if ((this->timers[0] % 8) == 0) { + if ((pthis->timers[0] % 8) == 0) { globalCtx->damagePlayer(globalCtx, -1); } - Math_ApproachF(&this->waterLevelMod, -5.0f, 0.1f, 0.4f); - sp1B4 = this->tentRot[15].x; + Math_ApproachF(&pthis->waterLevelMod, -5.0f, 0.1f, 0.4f); + sp1B4 = pthis->tentRot[15].x; buttons = globalCtx->state.input[0].press.button; if (CHECK_BTN_ALL(buttons, BTN_A) || CHECK_BTN_ALL(buttons, BTN_B)) { - this->mashCounter++; + pthis->mashCounter++; } for (indS1 = 0; indS1 < 41; indS1++) { if (indS1 < 20) { - sin = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_X] * indS1) + this->xSwing); - tempf1 = this->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); - cos = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_Z] * indS1) + this->zSwing); - tempf2 = this->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); + sin = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_X] * indS1) + pthis->xSwing); + tempf1 = pthis->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); + cos = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_Z] * indS1) + pthis->zSwing); + tempf2 = pthis->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); temp = ((((40 - indS1) * 25.0f) / 100.0f) + 5.0f); - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * temp, 0.1f, 0.1f); - Math_ApproachS(&this->tentRot[indS1].x, tempf1, 1.0f / this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * temp, 0.1f, 0.1f); + Math_ApproachS(&pthis->tentRot[indS1].x, tempf1, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, tempf2, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } } player->unk_850 = 0xA; - player->actor.world.pos.x = this->grabPosRot.pos.x; - player->actor.world.pos.y = this->grabPosRot.pos.y; - player->actor.world.pos.z = this->grabPosRot.pos.z; - player->actor.world.rot.x = player->actor.shape.rot.x = this->grabPosRot.rot.x; - player->actor.world.rot.y = player->actor.shape.rot.y = this->grabPosRot.rot.y; - player->actor.world.rot.z = player->actor.shape.rot.z = this->grabPosRot.rot.z; + player->actor.world.pos.x = pthis->grabPosRot.pos.x; + player->actor.world.pos.y = pthis->grabPosRot.pos.y; + player->actor.world.pos.z = pthis->grabPosRot.pos.z; + player->actor.world.rot.x = player->actor.shape.rot.x = pthis->grabPosRot.rot.x; + player->actor.world.rot.y = player->actor.shape.rot.y = pthis->grabPosRot.rot.y; + player->actor.world.rot.z = player->actor.shape.rot.z = pthis->grabPosRot.rot.z; player->actor.velocity.y = 0; player->actor.speedXZ = 0; - Math_ApproachF(&this->fwork[MO_TENT_MAX_STRETCH], 1.0f, 0.5f, 0.01); - Math_ApproachF(&this->tentMaxAngle, 0.5f, 1.0f, 0.005f); - Math_ApproachF(&this->tentSpeed, 480.0f, 1.0f, 10.0f); - Math_ApproachF(&this->tentPulse, 0.3f, 0.5f, 0.03f); - if ((this->mashCounter >= 40) || (this->timers[0] == 0)) { - tentXrot = this->tentRot[15].x; + Math_ApproachF(&pthis->fwork[MO_TENT_MAX_STRETCH], 1.0f, 0.5f, 0.01); + Math_ApproachF(&pthis->tentMaxAngle, 0.5f, 1.0f, 0.005f); + Math_ApproachF(&pthis->tentSpeed, 480.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->tentPulse, 0.3f, 0.5f, 0.03f); + if ((pthis->mashCounter >= 40) || (pthis->timers[0] == 0)) { + tentXrot = pthis->tentRot[15].x; if ((tentXrot < 0) && (sp1B4 >= 0)) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; - this->work[MO_TENT_INVINC_TIMER] = 50; - if (&this->actor == player->actor.parent) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; + pthis->work[MO_TENT_INVINC_TIMER] = 50; + if (&pthis->actor == player->actor.parent) { player->unk_850 = 0x65; player->actor.parent = NULL; player->csMode = 0; - if (this->timers[0] == 0) { - func_8002F6D4(globalCtx, &this->actor, 20.0f, this->actor.shape.rot.y + 0x8000, 10.0f, 0); + if (pthis->timers[0] == 0) { + func_8002F6D4(globalCtx, &pthis->actor, 20.0f, pthis->actor.shape.rot.y + 0x8000, 10.0f, 0); } } - this->timers[0] = 75; + pthis->timers[0] = 75; } } - if (this->csCamera != 0) { + if (pthis->csCamera != 0) { sp138.x = 0; sp138.y = 100.0f; sp138.z = 200.0f; - this->cameraYaw -= this->cameraYawRate; - Math_ApproachF(&this->cameraYawRate, 0.01, 1.0f, 0.002f); - Matrix_RotateY(this->cameraYaw, MTXMODE_NEW); + pthis->cameraYaw -= pthis->cameraYawRate; + Math_ApproachF(&pthis->cameraYawRate, 0.01, 1.0f, 0.002f); + Matrix_RotateY(pthis->cameraYaw, MTXMODE_NEW); Matrix_MultVec3f(&sp138, &sp12C); - Math_ApproachF(&this->cameraEye.x, this->actor.world.pos.x + sp12C.x, 0.1f, 10.0f); - Math_ApproachF(&this->cameraEye.y, this->actor.world.pos.y + sp12C.y, 0.1f, 10.0f); - Math_ApproachF(&this->cameraEye.z, this->actor.world.pos.z + sp12C.z, 0.1f, 10.0f); - Math_ApproachF(&this->cameraAt.x, player->actor.world.pos.x, 0.5f, 50.0f); - Math_ApproachF(&this->cameraAt.y, player->actor.world.pos.y, 0.5f, 50.0f); - Math_ApproachF(&this->cameraAt.z, player->actor.world.pos.z, 0.5f, 50.0f); - Gameplay_CameraSetAtEye(globalCtx, this->csCamera, &this->cameraAt, &this->cameraEye); + Math_ApproachF(&pthis->cameraEye.x, pthis->actor.world.pos.x + sp12C.x, 0.1f, 10.0f); + Math_ApproachF(&pthis->cameraEye.y, pthis->actor.world.pos.y + sp12C.y, 0.1f, 10.0f); + Math_ApproachF(&pthis->cameraEye.z, pthis->actor.world.pos.z + sp12C.z, 0.1f, 10.0f); + Math_ApproachF(&pthis->cameraAt.x, player->actor.world.pos.x, 0.5f, 50.0f); + Math_ApproachF(&pthis->cameraAt.y, player->actor.world.pos.y, 0.5f, 50.0f); + Math_ApproachF(&pthis->cameraAt.z, player->actor.world.pos.z, 0.5f, 50.0f); + Gameplay_CameraSetAtEye(globalCtx, pthis->csCamera, &pthis->cameraAt, &pthis->cameraEye); } break; case MO_TENT_CUT: - func_80078914(&this->tentTipPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - if (&this->actor == player->actor.parent) { + func_80078914(&pthis->tentTipPos, NA_SE_EV_WATER_WALL - SFX_FLAG); + if (&pthis->actor == player->actor.parent) { player->unk_850 = 0x65; player->actor.parent = NULL; player->csMode = 0; } - Math_ApproachF(&this->tentRippleSize, 0.15f, 0.5f, 0.01); - if (this->meltIndex < 41) { + Math_ApproachF(&pthis->tentRippleSize, 0.15f, 0.5f, 0.01); + if (pthis->meltIndex < 41) { for (indS0 = 0; indS0 < 10; indS0++) { - sp120 = this->tentPos[this->meltIndex]; + sp120 = pthis->tentPos[pthis->meltIndex]; sp120.x += Rand_CenteredFloat(30.0f); sp120.y += Rand_CenteredFloat(30.0f); sp120.z += Rand_CenteredFloat(30.0f); - BossMo_SpawnStillDroplet(globalCtx->specialEffects, &sp120, Rand_ZeroFloat(0.1f) + .2f); + BossMo_SpawnStillDroplet((BossMoEffect*)globalCtx->specialEffects, &sp120, Rand_ZeroFloat(0.1f) + .2f); } - this->meltIndex++; + pthis->meltIndex++; } - Math_ApproachF(&this->cutScale, 0.0, 1.0f, 0.2f); - if ((this->meltIndex >= 41) || (this->timers[0] == 0)) { - this->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; - this->timers[0] = 75; - this->tentMaxAngle = 0.005f; - this->tentSpeed = 50.0f; - this->fwork[MO_TENT_SWING_SIZE_X] = 7000.0f; - this->fwork[MO_TENT_SWING_SIZE_Z] = 5000.0f; + Math_ApproachF(&pthis->cutScale, 0.0, 1.0f, 0.2f); + if ((pthis->meltIndex >= 41) || (pthis->timers[0] == 0)) { + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; + pthis->timers[0] = 75; + pthis->tentMaxAngle = 0.005f; + pthis->tentSpeed = 50.0f; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 7000.0f; + pthis->fwork[MO_TENT_SWING_SIZE_Z] = 5000.0f; } break; case MO_TENT_RETREAT: - if (this->csCamera != 0) { - Math_ApproachF(&this->cameraAt.x, player->actor.world.pos.x, 0.5f, 50.0f); - Math_ApproachF(&this->cameraAt.y, player->actor.world.pos.y, 0.5f, 50.0f); - Math_ApproachF(&this->cameraAt.z, player->actor.world.pos.z, 0.5f, 50.0f); - Gameplay_CameraSetAtEye(globalCtx, this->csCamera, &this->cameraAt, &this->cameraEye); + if (pthis->csCamera != 0) { + Math_ApproachF(&pthis->cameraAt.x, player->actor.world.pos.x, 0.5f, 50.0f); + Math_ApproachF(&pthis->cameraAt.y, player->actor.world.pos.y, 0.5f, 50.0f); + Math_ApproachF(&pthis->cameraAt.z, player->actor.world.pos.z, 0.5f, 50.0f); + Gameplay_CameraSetAtEye(globalCtx, pthis->csCamera, &pthis->cameraAt, &pthis->cameraEye); if (player->actor.world.pos.y <= 42.0f) { camera2 = Gameplay_GetCamera(globalCtx, MAIN_CAM); - camera2->eye = this->cameraEye; - camera2->eyeNext = this->cameraEye; - camera2->at = this->cameraAt; - func_800C08AC(globalCtx, this->csCamera, 0); - this->csCamera = 0; + camera2->eye = pthis->cameraEye; + camera2->eyeNext = pthis->cameraEye; + camera2->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->csCamera, 0); + pthis->csCamera = 0; func_80064534(globalCtx, &globalCtx->csCtx); } } for (indS1 = 0; indS1 < 41; indS1++) { - sin = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_X] * indS1) + this->xSwing); - tempf1 = (indS1 * 0.025f * sin * this->fwork[MO_TENT_SWING_SIZE_X]) * this->fwork[MO_TENT_MAX_STRETCH]; - cos = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_Z] * indS1) + this->zSwing); - tempf2 = (indS1 * 0.025f * cos * this->fwork[MO_TENT_SWING_SIZE_Z]) * this->fwork[MO_TENT_MAX_STRETCH]; - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.5f, 0.2f); - Math_ApproachS(&this->tentRot[indS1].x, tempf1, 1.0f / this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); + sin = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_X] * indS1) + pthis->xSwing); + tempf1 = (indS1 * 0.025f * sin * pthis->fwork[MO_TENT_SWING_SIZE_X]) * pthis->fwork[MO_TENT_MAX_STRETCH]; + cos = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_Z] * indS1) + pthis->zSwing); + tempf2 = (indS1 * 0.025f * cos * pthis->fwork[MO_TENT_SWING_SIZE_Z]) * pthis->fwork[MO_TENT_MAX_STRETCH]; + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.5f, 0.2f); + Math_ApproachS(&pthis->tentRot[indS1].x, tempf1, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, tempf2, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } - Math_ApproachF(&this->fwork[MO_TENT_MAX_STRETCH], 0, 0.5f, 0.02f); - Math_ApproachF(&this->tentMaxAngle, 0.5f, 1.0f, 0.01); - Math_ApproachF(&this->tentSpeed, 320.0f, 1.0f, 50.0f); - if (this->timers[0] == 0) { - this->actor.flags &= ~ACTOR_FLAG_0; - Math_ApproachF(&this->baseAlpha, 0.0, 1.0f, 5.0f); + Math_ApproachF(&pthis->fwork[MO_TENT_MAX_STRETCH], 0, 0.5f, 0.02f); + Math_ApproachF(&pthis->tentMaxAngle, 0.5f, 1.0f, 0.01); + Math_ApproachF(&pthis->tentSpeed, 320.0f, 1.0f, 50.0f); + if (pthis->timers[0] == 0) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + Math_ApproachF(&pthis->baseAlpha, 0.0, 1.0f, 5.0f); for (indS1 = 0; indS1 < 40; indS1++) { if (sMorphaTent2->tentSpawnPos) {} indT5 = Rand_ZeroFloat(20.9f); @@ -957,21 +957,21 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { if ((fabsf(spF0.x - sTentSpawnPos[indS0].x) <= 320) && (fabsf(spF0.z - sTentSpawnPos[indS0].y) <= 320) && ((sMorphaTent2 == NULL) || (sMorphaTent2->tentSpawnPos != indS0))) { - this->targetPos.x = sTentSpawnPos[indS0].x; - this->targetPos.z = sTentSpawnPos[indS0].y; - this->tentSpawnPos = indS0; - this->timers[0] = (s16)Rand_ZeroFloat(20.0f) + 30; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_DESPAWN; + pthis->targetPos.x = sTentSpawnPos[indS0].x; + pthis->targetPos.z = sTentSpawnPos[indS0].y; + pthis->tentSpawnPos = indS0; + pthis->timers[0] = (s16)Rand_ZeroFloat(20.0f) + 30; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_DESPAWN; break; } } } - if ((this == sMorphaTent1) && (sMorphaCore->hitCount >= 3) && (sMorphaTent2 == NULL)) { + if ((pthis == sMorphaTent1) && (sMorphaCore->hitCount >= 3) && (sMorphaTent2 == NULL)) { sMorphaTent2 = - (BossMo*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_MO, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, BOSSMO_TENTACLE); + (BossMo*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_MO, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, BOSSMO_TENTACLE); - sMorphaTent2->tentSpawnPos = this->tentSpawnPos; + sMorphaTent2->tentSpawnPos = pthis->tentSpawnPos; if (sMorphaTent2->tentSpawnPos > 10) { sMorphaTent2->tentSpawnPos--; } else { @@ -986,124 +986,124 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { } break; case MO_TENT_DESPAWN: - this->actor.flags &= ~ACTOR_FLAG_0; - Math_ApproachF(&this->baseAlpha, 0, 1.0f, 5.0f); - if ((this->baseAlpha <= 0.5f) && (this->timers[0] == 0)) { - this->meltIndex = 0; - this->actor.world.pos.x = this->targetPos.x; - this->actor.world.pos.z = this->targetPos.z; - this->actor.prevPos = this->actor.world.pos; - this->cutScale = 1.0f; - this->cutIndex = this->meltIndex; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_WAIT; - this->timers[0] = (s16)Rand_ZeroFloat(20.0f) + 10; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Math_ApproachF(&pthis->baseAlpha, 0, 1.0f, 5.0f); + if ((pthis->baseAlpha <= 0.5f) && (pthis->timers[0] == 0)) { + pthis->meltIndex = 0; + pthis->actor.world.pos.x = pthis->targetPos.x; + pthis->actor.world.pos.z = pthis->targetPos.z; + pthis->actor.prevPos = pthis->actor.world.pos; + pthis->cutScale = 1.0f; + pthis->cutIndex = pthis->meltIndex; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_WAIT; + pthis->timers[0] = (s16)Rand_ZeroFloat(20.0f) + 10; - this->tentSpeed = 0; - this->fwork[MO_TENT_SWING_RATE_X] = 0; - this->fwork[MO_TENT_SWING_RATE_Z] = 0; - this->fwork[MO_TENT_SWING_SIZE_X] = 0; - this->fwork[MO_TENT_SWING_SIZE_Z] = 0; + pthis->tentSpeed = 0; + pthis->fwork[MO_TENT_SWING_RATE_X] = 0; + pthis->fwork[MO_TENT_SWING_RATE_Z] = 0; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 0; + pthis->fwork[MO_TENT_SWING_SIZE_Z] = 0; - this->tentMaxAngle = .001f; + pthis->tentMaxAngle = .001f; } break; case MO_TENT_DEATH_START: - this->actor.shape.rot.y = 0x4000; + pthis->actor.shape.rot.y = 0x4000; break; case MO_TENT_DEATH_3: - this->baseBubblesTimer = 20; + pthis->baseBubblesTimer = 20; Math_ApproachF(&sMorphaCore->waterLevel, -300.0f, 0.1f, 0.8f); - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; for (indS1 = 0; indS1 < 41; indS1++) { - sin = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_X] * indS1) + this->xSwing); - tempf1 = this->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); - cos = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_Z] * indS1) + this->zSwing); - tempf2 = this->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); - Math_ApproachS(&this->tentRot[indS1].x, tempf1, 1.0f / this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); + sin = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_X] * indS1) + pthis->xSwing); + tempf1 = pthis->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); + cos = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_Z] * indS1) + pthis->zSwing); + tempf2 = pthis->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); + Math_ApproachS(&pthis->tentRot[indS1].x, tempf1, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, tempf2, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } - this->actor.speedXZ = 0.0; - Math_ApproachF(&this->fwork[MO_TENT_MAX_STRETCH], 4.3f, 0.5f, 0.04); - Math_ApproachF(&this->tentPulse, 1.3f, 0.5f, 0.05f); + pthis->actor.speedXZ = 0.0; + Math_ApproachF(&pthis->fwork[MO_TENT_MAX_STRETCH], 4.3f, 0.5f, 0.04); + Math_ApproachF(&pthis->tentPulse, 1.3f, 0.5f, 0.05f); break; case MO_TENT_DEATH_1: - this->baseBubblesTimer = 20; - this->actor.shape.rot.y = 0x4000; - this->actor.shape.rot.x = -0x8000; - this->actor.world.pos.y = sMorphaCore->waterLevel + 650.0f; + pthis->baseBubblesTimer = 20; + pthis->actor.shape.rot.y = 0x4000; + pthis->actor.shape.rot.x = -0x8000; + pthis->actor.world.pos.y = sMorphaCore->waterLevel + 650.0f; Math_ApproachF(&sMorphaCore->waterLevel, -300.0f, 0.1f, 1.3f); for (indS1 = 0; indS1 < 41; indS1++) { - sin = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_X] * indS1) + this->xSwing); - tempf1 = this->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); - cos = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_Z] * indS1) + this->zSwing); - tempf2 = this->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); - Math_ApproachS(&this->tentRot[indS1].x, tempf1, 1.0f / this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); + sin = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_X] * indS1) + pthis->xSwing); + tempf1 = pthis->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); + cos = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_Z] * indS1) + pthis->zSwing); + tempf2 = pthis->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); + Math_ApproachS(&pthis->tentRot[indS1].x, tempf1, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, tempf2, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } - this->actor.speedXZ = 0.0; - Math_ApproachF(&this->tentPulse, 1.3f, 0.5f, 0.05f); + pthis->actor.speedXZ = 0.0; + Math_ApproachF(&pthis->tentPulse, 1.3f, 0.5f, 0.05f); break; case MO_TENT_DEATH_2: - this->baseBubblesTimer = 20; + pthis->baseBubblesTimer = 20; Math_ApproachF(&sMorphaCore->waterLevel, -295.0f, 0.1f, 1.3f); - this->actor.world.pos.y = sMorphaCore->waterLevel + 650.0f; + pthis->actor.world.pos.y = sMorphaCore->waterLevel + 650.0f; for (indS1 = 0; indS1 < 41; indS1++) { - sin = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_X] * indS1) + this->xSwing); - tempf1 = this->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); - cos = Math_SinS(((s16)this->fwork[MO_TENT_SWING_LAG_Z] * indS1) + this->zSwing); - tempf2 = this->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); - Math_ApproachS(&this->tentRot[indS1].x, tempf1, 1.0f / this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); + sin = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_X] * indS1) + pthis->xSwing); + tempf1 = pthis->fwork[MO_TENT_SWING_SIZE_X] * (indS1 * 0.025f * sin); + cos = Math_SinS(((s16)pthis->fwork[MO_TENT_SWING_LAG_Z] * indS1) + pthis->zSwing); + tempf2 = pthis->fwork[MO_TENT_SWING_SIZE_Z] * (indS1 * 0.025f * cos); + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.1f, 0.4f); + Math_ApproachS(&pthis->tentRot[indS1].x, tempf1, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->tentRot[indS1].z, tempf2, 1.0f / pthis->tentMaxAngle, pthis->tentSpeed); } - this->actor.speedXZ = 0.0; - this->noBubbles--; - Math_ApproachF(&this->fwork[MO_TENT_MAX_STRETCH], 0.1f, 0.1f, 0.03); - Math_ApproachF(&this->tentPulse, 0.02f, 0.5f, 0.015f); - if ((this->timers[0] > 0) && (this->timers[0] < 40)) { - Math_ApproachF(&this->actor.scale.x, 0.035f, 0.05f, this->flattenRate); - if (this->timers[0] == 1) { - this->flattenRate = 0.0; + pthis->actor.speedXZ = 0.0; + pthis->noBubbles--; + Math_ApproachF(&pthis->fwork[MO_TENT_MAX_STRETCH], 0.1f, 0.1f, 0.03); + Math_ApproachF(&pthis->tentPulse, 0.02f, 0.5f, 0.015f); + if ((pthis->timers[0] > 0) && (pthis->timers[0] < 40)) { + Math_ApproachF(&pthis->actor.scale.x, 0.035f, 0.05f, pthis->flattenRate); + if (pthis->timers[0] == 1) { + pthis->flattenRate = 0.0; } - } else if (this->timers[0] == 0) { - Math_ApproachF(&this->actor.scale.x, .001f, 0.05f, this->flattenRate); + } else if (pthis->timers[0] == 0) { + Math_ApproachF(&pthis->actor.scale.x, .001f, 0.05f, pthis->flattenRate); } - Math_ApproachF(&this->flattenRate, 0.00045f, 0.1f, 0.00001f); + Math_ApproachF(&pthis->flattenRate, 0.00045f, 0.1f, 0.00001f); break; case MO_TENT_DEATH_5: for (indS1 = 0; indS1 < 41; indS1++) { - if (this->timers[0] != 0) { - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.05f, - this->tentSpeed); + if (pthis->timers[0] != 0) { + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.05f, + pthis->tentSpeed); } else { - Math_ApproachF(&this->tentStretch[indS1].y, this->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.3f, 100.0f); + Math_ApproachF(&pthis->tentStretch[indS1].y, pthis->fwork[MO_TENT_MAX_STRETCH] * 5.0f, 0.3f, 100.0f); } - this->tentRot[indS1].x = this->tentRot[indS1].z = 0; + pthis->tentRot[indS1].x = pthis->tentRot[indS1].z = 0; } - this->tentPulse = 0.0; - if (this->timers[0] != 0) { - this->actor.world.pos.y = sMorphaCore->waterLevel + 650.0f; - this->fwork[MO_TENT_MAX_STRETCH] = 0.5f; - Math_ApproachF(&this->actor.scale.x, 0.0015f, 0.05f, this->tentMaxAngle); - Math_ApproachF(&this->tentMaxAngle, 0.00035f, 1.0f, 0.0000175f); - Math_ApproachF(&this->tentSpeed, 0.1f, 1.0f, 0.005f); - this->actor.velocity.y = 0.0; + pthis->tentPulse = 0.0; + if (pthis->timers[0] != 0) { + pthis->actor.world.pos.y = sMorphaCore->waterLevel + 650.0f; + pthis->fwork[MO_TENT_MAX_STRETCH] = 0.5f; + Math_ApproachF(&pthis->actor.scale.x, 0.0015f, 0.05f, pthis->tentMaxAngle); + Math_ApproachF(&pthis->tentMaxAngle, 0.00035f, 1.0f, 0.0000175f); + Math_ApproachF(&pthis->tentSpeed, 0.1f, 1.0f, 0.005f); + pthis->actor.velocity.y = 0.0; } else { - this->fwork[MO_TENT_MAX_STRETCH] = 0.2f; - this->fwork[MO_TENT_MAX_STRETCH] += Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 0x2000) * 0.05f; - padEC = Math_CosS(this->work[MO_TENT_MOVE_TIMER] * 0x2000) * 0.0005f; - Math_ApproachF(&this->actor.scale.x, 0.002f + padEC, 0.5f, 0.0005f); - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.velocity.y -= 1.0f; - if (this->actor.world.pos.y < -250.0f) { - this->actor.world.pos.y = -250.0f; - this->actor.velocity.y = 0.0; - this->drawActor = false; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_6; - this->timers[0] = 60; - func_80078914(&this->tentTipPos, NA_SE_EN_MOFER_CORE_JUMP); + pthis->fwork[MO_TENT_MAX_STRETCH] = 0.2f; + pthis->fwork[MO_TENT_MAX_STRETCH] += Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 0x2000) * 0.05f; + padEC = Math_CosS(pthis->work[MO_TENT_MOVE_TIMER] * 0x2000) * 0.0005f; + Math_ApproachF(&pthis->actor.scale.x, 0.002f + padEC, 0.5f, 0.0005f); + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.velocity.y -= 1.0f; + if (pthis->actor.world.pos.y < -250.0f) { + pthis->actor.world.pos.y = -250.0f; + pthis->actor.velocity.y = 0.0; + pthis->drawActor = false; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_6; + pthis->timers[0] = 60; + func_80078914(&pthis->tentTipPos, NA_SE_EN_MOFER_CORE_JUMP); for (indS1 = 0; indS1 < 300; indS1++) { spC8.x = 0.0; spC8.y = 0.0; @@ -1111,7 +1111,7 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { Matrix_RotateY(indS1 * 0.23f, MTXMODE_NEW); Matrix_MultVec3f(&spC8, &spE0); spE0.y = Rand_ZeroFloat(7.0f) + 4.0f; - spD4 = this->actor.world.pos; + spD4 = pthis->actor.world.pos; spD4.x += spE0.x * 3.0f; spD4.y += (spE0.y * 3.0f) - 30.0f; if (spD4.y < -280.0f) { @@ -1121,11 +1121,11 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &spD4, &spE0, ((300 - indS1) * .0015f) + 0.13f); } - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, - this->actor.world.pos.x, -280.0f, this->actor.world.pos.z, 0, 0, 0, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, + pthis->actor.world.pos.x, -280.0f, pthis->actor.world.pos.z, 0, 0, 0, WARP_DUNGEON_ADULT); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x + 200.0f, - -280.0f, this->actor.world.pos.z, 0, 0, 0, 0); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, pthis->actor.world.pos.x + 200.0f, + -280.0f, pthis->actor.world.pos.z, 0, 0, 0, 0); Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); } @@ -1134,57 +1134,57 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { case MO_TENT_DEATH_6: break; } - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; - if (((this->work[MO_TENT_ACTION_STATE] == MO_TENT_ATTACK) || - (this->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_2) || (this->work[MO_TENT_ACTION_STATE] == MO_TENT_CURL) || - (this->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB)) && - (Rand_ZeroOne() < 0.8f) && (this->actor.scale.x > 0.001f)) { + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; + if (((pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_ATTACK) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_2) || (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_CURL) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB)) && + (Rand_ZeroOne() < 0.8f) && (pthis->actor.scale.x > 0.001f)) { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; f32 scale; f32 temp; - if (this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_2) { + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_2) { indS1 = 38; scale = Rand_ZeroFloat(0.1f) + 0.1f; - pos.y = this->tentPos[indS1].y; + pos.y = pthis->tentPos[indS1].y; } else { indS1 = (s16)Rand_ZeroFloat(20.0f) + 18; scale = Rand_ZeroFloat(0.02f) + .05f; - pos.y = this->tentPos[indS1].y - 10.0f; + pos.y = pthis->tentPos[indS1].y - 10.0f; } - temp = (this->actor.scale.x * 100.0f) * 20.0f; - pos.x = this->tentPos[indS1].x + Rand_CenteredFloat(temp); - pos.z = this->tentPos[indS1].z + Rand_CenteredFloat(temp); + temp = (pthis->actor.scale.x * 100.0f) * 20.0f; + pos.x = pthis->tentPos[indS1].x + Rand_CenteredFloat(temp); + pos.z = pthis->tentPos[indS1].z + Rand_CenteredFloat(temp); BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &pos, &velocity, scale); } } -void BossMo_TentCollisionCheck(BossMo* this, GlobalContext* globalCtx) { +void BossMo_TentCollisionCheck(BossMo* pthis, GlobalContext* globalCtx) { s16 i1; - for (i1 = 0; i1 < ARRAY_COUNT(this->tentElements); i1++) { - if (this->tentCollider.elements[i1].info.bumperFlags & BUMP_HIT) { + for (i1 = 0; i1 < ARRAY_COUNT(pthis->tentElements); i1++) { + if (pthis->tentCollider.elements[i1].info.bumperFlags & BUMP_HIT) { s16 i2; ColliderInfo* hurtbox; for (i2 = 0; i2 < 19; i2++) { - this->tentCollider.elements[i2].info.bumperFlags &= ~BUMP_HIT; - this->tentCollider.elements[i2].info.toucherFlags &= ~TOUCH_HIT; + pthis->tentCollider.elements[i2].info.bumperFlags &= ~BUMP_HIT; + pthis->tentCollider.elements[i2].info.toucherFlags &= ~TOUCH_HIT; } - hurtbox = this->tentCollider.elements[i1].info.acHitInfo; - this->work[MO_TENT_INVINC_TIMER] = 5; + hurtbox = pthis->tentCollider.elements[i1].info.acHitInfo; + pthis->work[MO_TENT_INVINC_TIMER] = 5; if (hurtbox->toucher.dmgFlags & 0x00020000) { - func_80078914(&this->tentTipPos, NA_SE_EN_MOFER_CUT); - this->cutIndex = 15; - this->meltIndex = this->cutIndex + 1; - this->work[MO_TENT_ACTION_STATE] = MO_TENT_CUT; - this->timers[0] = 40; - this->cutScale = 1.0f; + func_80078914(&pthis->tentTipPos, NA_SE_EN_MOFER_CUT); + pthis->cutIndex = 15; + pthis->meltIndex = pthis->cutIndex + 1; + pthis->work[MO_TENT_ACTION_STATE] = MO_TENT_CUT; + pthis->timers[0] = 40; + pthis->cutScale = 1.0f; } else if (hurtbox->toucher.dmgFlags & 0x0D800600) { - this->linkHitTimer = 5; + pthis->linkHitTimer = 5; } - this->tentRippleSize = 0.2f; + pthis->tentRippleSize = 0.2f; for (i2 = 0; i2 < 10; i2++) { Vec3f pos; Vec3f velocity; @@ -1192,22 +1192,22 @@ void BossMo_TentCollisionCheck(BossMo* this, GlobalContext* globalCtx) { velocity.x = Rand_CenteredFloat(8.0f); velocity.y = Rand_ZeroFloat(7.0f) + 4.0f; velocity.z = Rand_CenteredFloat(8.0f); - pos = this->tentPos[2 * i1]; + pos = pthis->tentPos[2 * i1]; pos.x += velocity.x * 3.0f; pos.z += velocity.z * 3.0f; BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &pos, &velocity, Rand_ZeroFloat(0.08f) + 0.13f); } break; - } else if (this->tentCollider.elements[i1].info.toucherFlags & TOUCH_HIT) { - this->tentCollider.elements[i1].info.toucherFlags &= ~TOUCH_HIT; - this->linkHitTimer = 5; + } else if (pthis->tentCollider.elements[i1].info.toucherFlags & TOUCH_HIT) { + pthis->tentCollider.elements[i1].info.toucherFlags &= ~TOUCH_HIT; + pthis->linkHitTimer = 5; break; } } } -void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { +void BossMo_IntroCs(BossMo* pthis, GlobalContext* globalCtx) { static Vec3f cutsceneTargets[6] = { { -360.0f, -190.0f, 0.0f }, { 250.0f, -190.0f, 0.0f }, { 300.0f, -120.0f, -278.0f }, { 180.0f, -80.0f, -340.0f }, { 180.0f, 0.0f, -340.0f }, { 180.0f, 60.0f, -230.0f }, @@ -1231,12 +1231,12 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { f32 pad4C; f32 pad48; - if (this->csState < MO_INTRO_REVEAL) { - this->cameraZoom = 80.0f; + if (pthis->csState < MO_INTRO_REVEAL) { + pthis->cameraZoom = 80.0f; } - switch (this->csState) { + switch (pthis->csState) { case MO_INTRO_WAIT: - if (this->timers[0] == 1) { + if (pthis->timers[0] == 1) { Message_StartTextbox(globalCtx, 0x403F, NULL); } if (((fabsf(player->actor.world.pos.z - 180.0f) < 40.0f) && @@ -1249,15 +1249,15 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { (fabsf(player->actor.world.pos.x - -180.0f) < 40.0f))) { // checks if Link is on one of the four platforms func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->csCamera = Gameplay_CreateSubCamera(globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->csCamera = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->csCamera, CAM_STAT_ACTIVE); - this->actor.speedXZ = 0.0f; - this->csState = MO_INTRO_START; - this->timers[2] = 50; - this->work[MO_TENT_VAR_TIMER] = this->work[MO_TENT_MOVE_TIMER] = 0; - this->actor.world.rot.y = 0x721A; + Gameplay_ChangeCameraStatus(globalCtx, pthis->csCamera, CAM_STAT_ACTIVE); + pthis->actor.speedXZ = 0.0f; + pthis->csState = MO_INTRO_START; + pthis->timers[2] = 50; + pthis->work[MO_TENT_VAR_TIMER] = pthis->work[MO_TENT_MOVE_TIMER] = 0; + pthis->actor.world.rot.y = 0x721A; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; sMorphaTent1->timers[0] = 30000; Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x3200FF); @@ -1270,71 +1270,71 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { player->actor.world.pos.z = -130.0f; player->actor.shape.rot.y = player->actor.world.rot.y = 0; player->actor.speedXZ = 0.0f; - this->cameraEye.x = -424.0f; - this->cameraEye.y = -190.0f; - this->cameraEye.z = 180.0f; - this->cameraAt.x = player->actor.world.pos.x; - this->cameraAt.y = -330.0f; - this->cameraAt.z = 0.0f; - if (this->timers[2] == 0) { - this->csState = MO_INTRO_SWIM; - this->work[MO_TENT_MOVE_TIMER] = 0; - } else if (this->timers[2] < 50) { - bubblePos.x = (this->cameraEye.x + 20.0f) + 10.0f; + pthis->cameraEye.x = -424.0f; + pthis->cameraEye.y = -190.0f; + pthis->cameraEye.z = 180.0f; + pthis->cameraAt.x = player->actor.world.pos.x; + pthis->cameraAt.y = -330.0f; + pthis->cameraAt.z = 0.0f; + if (pthis->timers[2] == 0) { + pthis->csState = MO_INTRO_SWIM; + pthis->work[MO_TENT_MOVE_TIMER] = 0; + } else if (pthis->timers[2] < 50) { + bubblePos.x = (pthis->cameraEye.x + 20.0f) + 10.0f; bubblePos.y = -250.0f; - bubblePos.z = this->cameraEye.z; + bubblePos.z = pthis->cameraEye.z; EffectSsBubble_Spawn(globalCtx, &bubblePos, 0.0f, 10.0f, 50.0f, Rand_ZeroFloat(0.05f) + 0.13f); } - if (this->timers[2] == 40) { + if (pthis->timers[2] == 40) { func_80078914(&sAudioZeroVec, NA_SE_EN_MOFER_BUBLE_DEMO); } break; case MO_INTRO_SWIM: - Math_ApproachF(&this->cameraYawShake, 0.1f, 1.0f, 0.002f); - this->targetPos = cutsceneTargets[this->targetIndex]; - if (this->targetIndex == 5) { - tempY = Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 0x500) * 20.0f; + Math_ApproachF(&pthis->cameraYawShake, 0.1f, 1.0f, 0.002f); + pthis->targetPos = cutsceneTargets[pthis->targetIndex]; + if (pthis->targetIndex == 5) { + tempY = Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 0x500) * 20.0f; } else { - tempY = Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 0x500) * 5.0f; + tempY = Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 0x500) * 5.0f; } - dx = this->targetPos.x - this->cameraEye.x; - dy = this->targetPos.y - this->cameraEye.y + tempY; - dz = this->targetPos.z - this->cameraEye.z; + dx = pthis->targetPos.x - pthis->cameraEye.x; + dy = pthis->targetPos.y - pthis->cameraEye.y + tempY; + dz = pthis->targetPos.z - pthis->cameraEye.z; tempY = Math_FAtan2F(dx, dz); tempX = Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))); - Math_ApproachS(&this->actor.world.rot.y, tempY * (0x8000 / M_PI), 5, this->cameraYawRate); - Math_ApproachS(&this->actor.world.rot.x, tempX * (0x8000 / M_PI), 5, this->cameraYawRate); - if (this->work[MO_TENT_MOVE_TIMER] == 150) { - this->cameraAtVel.x = fabsf(this->cameraAt.x - player->actor.world.pos.x); - this->cameraAtVel.y = fabsf(this->cameraAt.y - player->actor.world.pos.y); - this->cameraAtVel.z = fabsf(this->cameraAt.z - player->actor.world.pos.z); + Math_ApproachS(&pthis->actor.world.rot.y, tempY * (0x8000 / M_PI), 5, pthis->cameraYawRate); + Math_ApproachS(&pthis->actor.world.rot.x, tempX * (0x8000 / M_PI), 5, pthis->cameraYawRate); + if (pthis->work[MO_TENT_MOVE_TIMER] == 150) { + pthis->cameraAtVel.x = fabsf(pthis->cameraAt.x - player->actor.world.pos.x); + pthis->cameraAtVel.y = fabsf(pthis->cameraAt.y - player->actor.world.pos.y); + pthis->cameraAtVel.z = fabsf(pthis->cameraAt.z - player->actor.world.pos.z); } - if (this->work[MO_TENT_MOVE_TIMER] >= 150) { - Math_ApproachF(&this->cameraAt.x, player->actor.world.pos.x, 0.1f, - this->cameraAtVel.x * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.y, player->actor.world.pos.y + 50.0f, 0.1f, - this->cameraAtVel.y * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.z, player->actor.world.pos.z, 0.1f, - this->cameraAtVel.z * this->cameraSpeedMod); - Math_ApproachF(&this->cameraSpeedMod, 0.02f, 1.0f, 0.001f); + if (pthis->work[MO_TENT_MOVE_TIMER] >= 150) { + Math_ApproachF(&pthis->cameraAt.x, player->actor.world.pos.x, 0.1f, + pthis->cameraAtVel.x * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.y, player->actor.world.pos.y + 50.0f, 0.1f, + pthis->cameraAtVel.y * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.z, player->actor.world.pos.z, 0.1f, + pthis->cameraAtVel.z * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraSpeedMod, 0.02f, 1.0f, 0.001f); } - if (this->work[MO_TENT_MOVE_TIMER] == 190) { + if (pthis->work[MO_TENT_MOVE_TIMER] == 190) { func_80078914(&sAudioZeroVec, NA_SE_EN_MOFER_BUBLE_DEMO); } - if ((this->work[MO_TENT_MOVE_TIMER] > 150) && (this->work[MO_TENT_MOVE_TIMER] < 180)) { - bubblePos2.x = (this->cameraEye.x + 20.0f) + 10.0f; + if ((pthis->work[MO_TENT_MOVE_TIMER] > 150) && (pthis->work[MO_TENT_MOVE_TIMER] < 180)) { + bubblePos2.x = (pthis->cameraEye.x + 20.0f) + 10.0f; bubblePos2.y = -250.0f; - bubblePos2.z = this->cameraEye.z; + bubblePos2.z = pthis->cameraEye.z; EffectSsBubble_Spawn(globalCtx, &bubblePos2, 0.0f, 10.0f, 50.0f, Rand_ZeroFloat(0.05f) + 0.13f); } sp7C = (f32)0x1000; sp78 = 0.1f; - if ((this->work[MO_TENT_MOVE_TIMER] > 100) && (this->work[MO_TENT_MOVE_TIMER] < 220)) { + if ((pthis->work[MO_TENT_MOVE_TIMER] > 100) && (pthis->work[MO_TENT_MOVE_TIMER] < 220)) { sp80 = 0.0f; - } else if (this->work[MO_TENT_MOVE_TIMER] > 350) { + } else if (pthis->work[MO_TENT_MOVE_TIMER] > 350) { sp80 = 2.0f; sp78 = 0.4f; - } else if (this->work[MO_TENT_MOVE_TIMER] > 220) { + } else if (pthis->work[MO_TENT_MOVE_TIMER] > 220) { sp80 = 7.0f; sp78 = 0.3f; sp7C = (f32)0x2000; @@ -1342,39 +1342,39 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { sp80 = 4.0f; } - if (this->work[MO_TENT_MOVE_TIMER] > 250) { - Math_ApproachF(&this->fwork[MO_CORE_INTRO_WATER_ALPHA], 100.0f, 1.0f, 1.0f); + if (pthis->work[MO_TENT_MOVE_TIMER] > 250) { + Math_ApproachF(&pthis->fwork[MO_CORE_INTRO_WATER_ALPHA], 100.0f, 1.0f, 1.0f); } - if (this->targetIndex < 5) { + if (pthis->targetIndex < 5) { if (sqrtf(SQ(dx) + SQ(dz) + SQ(dy)) < 40.0f) { - this->targetIndex++; - this->cameraYawRate = 0.0f; + pthis->targetIndex++; + pthis->cameraYawRate = 0.0f; } } else { sp80 = 1.5f; sp7C = (f32)0x600; } - Math_ApproachF(&this->actor.speedXZ, sp80, 1.0f, sp78); - Math_ApproachF(&this->cameraYawRate, sp7C, 1.0f, 128.0f); - if (this->work[MO_TENT_MOVE_TIMER] == 525) { - func_8002DF54(globalCtx, &this->actor, 2); + Math_ApproachF(&pthis->actor.speedXZ, sp80, 1.0f, sp78); + Math_ApproachF(&pthis->cameraYawRate, sp7C, 1.0f, 128.0f); + if (pthis->work[MO_TENT_MOVE_TIMER] == 525) { + func_8002DF54(globalCtx, &pthis->actor, 2); } - if (this->work[MO_TENT_MOVE_TIMER] > 540) { - this->csState = MO_INTRO_REVEAL; - func_8002DF54(globalCtx, &this->actor, 1); + if (pthis->work[MO_TENT_MOVE_TIMER] > 540) { + pthis->csState = MO_INTRO_REVEAL; + func_8002DF54(globalCtx, &pthis->actor, 1); sMorphaTent1->drawActor = true; player->actor.world.pos.x = 180.0f; player->actor.world.pos.z = -210.0f; player->actor.world.rot.y = -0x8000; player->actor.shape.rot.y = player->actor.world.rot.y; - this->cameraYawShake = 0.0f; + pthis->cameraYawShake = 0.0f; sMorphaTent1->baseAlpha = 150.0; - this->actor.speedXZ = 0.0f; - this->timers[2] = 200; - this->cameraZoom = 60.0f; - this->actor.world.pos = sMorphaTent1->actor.world.pos; - this->work[MO_TENT_ACTION_STATE] = MO_CORE_INTRO_REVEAL; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + pthis->timers[2] = 200; + pthis->cameraZoom = 60.0f; + pthis->actor.world.pos = sMorphaTent1->actor.world.pos; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_INTRO_REVEAL; + pthis->actor.flags &= ~ACTOR_FLAG_0; sMorphaTent1->actor.flags |= ACTOR_FLAG_0; } else { sMorphaTent1->xSwing = 0xCEC; @@ -1384,66 +1384,66 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { break; } case MO_INTRO_REVEAL: - if (this->timers[2] >= 160) { - this->cameraEye.x = 150.0f; - this->cameraEye.y = 60.0f; - this->cameraEye.z = -230.0f; - this->cameraAt.x = 170.0f; - this->cameraAt.y = 40.0; - this->cameraAt.z = -280.0f; + if (pthis->timers[2] >= 160) { + pthis->cameraEye.x = 150.0f; + pthis->cameraEye.y = 60.0f; + pthis->cameraEye.z = -230.0f; + pthis->cameraAt.x = 170.0f; + pthis->cameraAt.y = 40.0; + pthis->cameraAt.z = -280.0f; sMorphaTent1->xSwing = 0xCEC; sMorphaTent1->fwork[MO_TENT_SWING_RATE_X] = 0.0f; sMorphaTent1->fwork[MO_TENT_SWING_LAG_X] = 1000.0f; sMorphaTent1->fwork[MO_TENT_SWING_SIZE_X] = 2500.0f; - if (this->timers[2] == 160) { - this->cameraNextAt.y = 65.0f; - this->cameraNextAt.z = -280.0f; - this->cameraEyeVel.x = fabsf(this->cameraEye.x - 150.0f) * 0.1f; - this->cameraEyeVel.y = fabsf(this->cameraEye.y - 60.0f) * 0.1f; - this->cameraEyeVel.z = fabsf(this->cameraEye.z - -260.0f) * 0.1f; - this->cameraNextEye.x = 150.0f; - this->cameraNextEye.y = 60.0f; - this->cameraNextEye.z = -260.0f; - this->cameraNextAt.x = 155.0f; - this->cameraAtMaxVel.x = this->cameraAtMaxVel.y = this->cameraAtMaxVel.z = 0.1f; - this->cameraAtVel.x = fabsf(this->cameraAt.x - this->cameraNextAt.x) * 0.1f; - this->cameraAtVel.y = fabsf(this->cameraAt.y - this->cameraNextAt.y) * 0.1f; - this->cameraAtVel.z = fabsf(this->cameraAt.z - this->cameraNextAt.z) * 0.1f; - this->cameraEyeMaxVel.x = this->cameraEyeMaxVel.y = this->cameraEyeMaxVel.z = 0.1f; - this->cameraSpeedMod = 0.0f; - this->cameraAccel = 0.01f; - this->tentMaxAngle = 0.001f; - this->tentSpeed = 0.0f; + if (pthis->timers[2] == 160) { + pthis->cameraNextAt.y = 65.0f; + pthis->cameraNextAt.z = -280.0f; + pthis->cameraEyeVel.x = fabsf(pthis->cameraEye.x - 150.0f) * 0.1f; + pthis->cameraEyeVel.y = fabsf(pthis->cameraEye.y - 60.0f) * 0.1f; + pthis->cameraEyeVel.z = fabsf(pthis->cameraEye.z - -260.0f) * 0.1f; + pthis->cameraNextEye.x = 150.0f; + pthis->cameraNextEye.y = 60.0f; + pthis->cameraNextEye.z = -260.0f; + pthis->cameraNextAt.x = 155.0f; + pthis->cameraAtMaxVel.x = pthis->cameraAtMaxVel.y = pthis->cameraAtMaxVel.z = 0.1f; + pthis->cameraAtVel.x = fabsf(pthis->cameraAt.x - pthis->cameraNextAt.x) * 0.1f; + pthis->cameraAtVel.y = fabsf(pthis->cameraAt.y - pthis->cameraNextAt.y) * 0.1f; + pthis->cameraAtVel.z = fabsf(pthis->cameraAt.z - pthis->cameraNextAt.z) * 0.1f; + pthis->cameraEyeMaxVel.x = pthis->cameraEyeMaxVel.y = pthis->cameraEyeMaxVel.z = 0.1f; + pthis->cameraSpeedMod = 0.0f; + pthis->cameraAccel = 0.01f; + pthis->tentMaxAngle = 0.001f; + pthis->tentSpeed = 0.0f; sp9F = 1; } } else { sp9F = 1; } - if (this->timers[2] == 50) { - this->cameraNextAt.x = 160.0f; - this->cameraNextAt.y = 58.0f; - this->cameraNextAt.z = -247.0f; - this->cameraEyeVel.x = fabsf(this->cameraEye.x - 111.0f) * 0.1f; - this->cameraEyeVel.y = fabsf(this->cameraEye.y - 133.0f) * 0.1f; - this->cameraEyeVel.z = fabsf(this->cameraEye.z - -191.0f) * 0.1f; + if (pthis->timers[2] == 50) { + pthis->cameraNextAt.x = 160.0f; + pthis->cameraNextAt.y = 58.0f; + pthis->cameraNextAt.z = -247.0f; + pthis->cameraEyeVel.x = fabsf(pthis->cameraEye.x - 111.0f) * 0.1f; + pthis->cameraEyeVel.y = fabsf(pthis->cameraEye.y - 133.0f) * 0.1f; + pthis->cameraEyeVel.z = fabsf(pthis->cameraEye.z - -191.0f) * 0.1f; if (1) {} - this->csState = MO_INTRO_FINISH; - this->timers[2] = 110; - this->cameraNextEye.x = 111.0f; - this->cameraNextEye.y = 133.0f; - this->cameraNextEye.z = -191.0f; - this->cameraAtVel.x = fabsf(this->cameraAt.x - this->cameraNextAt.x) * 0.1f; - this->cameraAtVel.y = fabsf(this->cameraAt.y - this->cameraNextAt.y) * 0.1f; - this->cameraAtVel.z = fabsf(this->cameraAt.z - this->cameraNextAt.z) * 0.1f; - this->cameraEyeMaxVel.y = 0.03f; - this->cameraAtMaxVel.y = 0.03f; - this->cameraSpeedMod = 0.0f; - this->cameraAccel = 0.01f; + pthis->csState = MO_INTRO_FINISH; + pthis->timers[2] = 110; + pthis->cameraNextEye.x = 111.0f; + pthis->cameraNextEye.y = 133.0f; + pthis->cameraNextEye.z = -191.0f; + pthis->cameraAtVel.x = fabsf(pthis->cameraAt.x - pthis->cameraNextAt.x) * 0.1f; + pthis->cameraAtVel.y = fabsf(pthis->cameraAt.y - pthis->cameraNextAt.y) * 0.1f; + pthis->cameraAtVel.z = fabsf(pthis->cameraAt.z - pthis->cameraNextAt.z) * 0.1f; + pthis->cameraEyeMaxVel.y = 0.03f; + pthis->cameraAtMaxVel.y = 0.03f; + pthis->cameraSpeedMod = 0.0f; + pthis->cameraAccel = 0.01f; } - if (this->timers[2] == 150) { + if (pthis->timers[2] == 150) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); } - if (this->timers[2] == 130) { + if (pthis->timers[2] == 130) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); gSaveContext.eventChkInf[7] |= 0x10; @@ -1451,25 +1451,25 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { break; case MO_INTRO_FINISH: sp9F = 1; - this->cameraNextEye.x = 111.0f; - this->cameraNextEye.y = 133.0f; - this->cameraNextEye.z = -191.0f; - this->cameraNextAt.x = 160.0f; - this->cameraNextAt.y = 58.0f; - this->cameraNextAt.z = -247.0f; - if (this->timers[2] == 100) { + pthis->cameraNextEye.x = 111.0f; + pthis->cameraNextEye.y = 133.0f; + pthis->cameraNextEye.z = -191.0f; + pthis->cameraNextAt.x = 160.0f; + pthis->cameraNextAt.y = 58.0f; + pthis->cameraNextAt.z = -247.0f; + if (pthis->timers[2] == 100) { sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; sMorphaTent1->timers[0] = 50; } - if (this->timers[2] == 20) { + if (pthis->timers[2] == 20) { camera2 = Gameplay_GetCamera(globalCtx, MAIN_CAM); - camera2->eye = this->cameraEye; - camera2->eyeNext = this->cameraEye; - camera2->at = this->cameraAt; - func_800C08AC(globalCtx, this->csCamera, 0); - this->csState = this->csCamera = MO_BATTLE; + camera2->eye = pthis->cameraEye; + camera2->eyeNext = pthis->cameraEye; + camera2->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->csCamera, 0); + pthis->csState = pthis->csCamera = MO_BATTLE; func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); } break; } @@ -1480,45 +1480,45 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { sMorphaTent1->actor.speedXZ = 0.0f; sMorphaTent1->actor.shape.rot.y = sMorphaTent1->actor.yawTowardsPlayer; } - if (this->csCamera != 0) { + if (pthis->csCamera != 0) { if (sp9F) { - Math_ApproachF(&this->cameraEye.x, this->cameraNextEye.x, this->cameraEyeMaxVel.x, - this->cameraEyeVel.x * this->cameraSpeedMod); - Math_ApproachF(&this->cameraEye.y, this->cameraNextEye.y, this->cameraEyeMaxVel.y, - this->cameraEyeVel.y * this->cameraSpeedMod); - Math_ApproachF(&this->cameraEye.z, this->cameraNextEye.z, this->cameraEyeMaxVel.z, - this->cameraEyeVel.z * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.x, this->cameraNextAt.x, this->cameraAtMaxVel.x, - this->cameraAtVel.x * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.y, this->cameraNextAt.y, this->cameraAtMaxVel.y, - this->cameraAtVel.y * this->cameraSpeedMod); - Math_ApproachF(&this->cameraAt.z, this->cameraNextAt.z, this->cameraAtMaxVel.z, - this->cameraAtVel.z * this->cameraSpeedMod); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, this->cameraAccel); - } else if (this->csState < MO_INTRO_REVEAL) { - func_8002D908(&this->actor); - this->cameraEye.x += this->actor.velocity.x; - this->cameraEye.y += this->actor.velocity.y; - this->cameraEye.z += this->actor.velocity.z; + Math_ApproachF(&pthis->cameraEye.x, pthis->cameraNextEye.x, pthis->cameraEyeMaxVel.x, + pthis->cameraEyeVel.x * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraEye.y, pthis->cameraNextEye.y, pthis->cameraEyeMaxVel.y, + pthis->cameraEyeVel.y * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraEye.z, pthis->cameraNextEye.z, pthis->cameraEyeMaxVel.z, + pthis->cameraEyeVel.z * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.x, pthis->cameraNextAt.x, pthis->cameraAtMaxVel.x, + pthis->cameraAtVel.x * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.y, pthis->cameraNextAt.y, pthis->cameraAtMaxVel.y, + pthis->cameraAtVel.y * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraAt.z, pthis->cameraNextAt.z, pthis->cameraAtMaxVel.z, + pthis->cameraAtVel.z * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, pthis->cameraAccel); + } else if (pthis->csState < MO_INTRO_REVEAL) { + func_8002D908(&pthis->actor); + pthis->cameraEye.x += pthis->actor.velocity.x; + pthis->cameraEye.y += pthis->actor.velocity.y; + pthis->cameraEye.z += pthis->actor.velocity.z; } - this->cameraUp.x = this->cameraUp.z = - sinf(this->work[MO_TENT_VAR_TIMER] * 0.03f) * this->cameraYawShake * (-2.0f); - this->cameraUp.y = 1.0f; - Gameplay_CameraSetAtEyeUp(globalCtx, this->csCamera, &this->cameraAt, &this->cameraEye, &this->cameraUp); - camera->eye = this->cameraEye; - camera->eyeNext = this->cameraEye; - camera->at = this->cameraAt; - Gameplay_CameraSetFov(globalCtx, this->csCamera, this->cameraZoom); + pthis->cameraUp.x = pthis->cameraUp.z = + sinf(pthis->work[MO_TENT_VAR_TIMER] * 0.03f) * pthis->cameraYawShake * (-2.0f); + pthis->cameraUp.y = 1.0f; + Gameplay_CameraSetAtEyeUp(globalCtx, pthis->csCamera, &pthis->cameraAt, &pthis->cameraEye, &pthis->cameraUp); + camera->eye = pthis->cameraEye; + camera->eyeNext = pthis->cameraEye; + camera->at = pthis->cameraAt; + Gameplay_CameraSetFov(globalCtx, pthis->csCamera, pthis->cameraZoom); } - if ((this->csState > MO_INTRO_START) && (this->work[MO_TENT_MOVE_TIMER] > 540)) { + if ((pthis->csState > MO_INTRO_START) && (pthis->work[MO_TENT_MOVE_TIMER] > 540)) { func_80078914(&sMorphaTent1->tentTipPos, NA_SE_EN_MOFER_APPEAR - SFX_FLAG); - } else if (this->csState >= MO_INTRO_START) { + } else if (pthis->csState >= MO_INTRO_START) { func_80078914(&sAudioZeroVec, NA_SE_EN_MOFER_MOVE_DEMO - SFX_FLAG); } } -void BossMo_DeathCs(BossMo* this, GlobalContext* globalCtx) { +void BossMo_DeathCs(BossMo* pthis, GlobalContext* globalCtx) { s16 i; s16 one; f32 dx; @@ -1531,82 +1531,82 @@ void BossMo_DeathCs(BossMo* this, GlobalContext* globalCtx) { Vec3f velocity; Vec3f pos; - switch (this->csState) { + switch (pthis->csState) { case MO_DEATH_START: func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->csCamera = Gameplay_CreateSubCamera(globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->csCamera = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->csCamera, CAM_STAT_ACTIVE); - this->csState = MO_DEATH_MO_CORE_BURST; - this->cameraEye = camera->eye; - this->timers[0] = 90; - dx = this->actor.world.pos.x - this->cameraEye.x; - dz = this->actor.world.pos.z - this->cameraEye.z; - this->cameraYaw = Math_FAtan2F(dx, dz); - this->cameraDist = sqrtf(SQ(dx) + SQ(dz)); - this->cameraYawRate = 0.0f; + Gameplay_ChangeCameraStatus(globalCtx, pthis->csCamera, CAM_STAT_ACTIVE); + pthis->csState = MO_DEATH_MO_CORE_BURST; + pthis->cameraEye = camera->eye; + pthis->timers[0] = 90; + dx = pthis->actor.world.pos.x - pthis->cameraEye.x; + dz = pthis->actor.world.pos.z - pthis->cameraEye.z; + pthis->cameraYaw = Math_FAtan2F(dx, dz); + pthis->cameraDist = sqrtf(SQ(dx) + SQ(dz)); + pthis->cameraYawRate = 0.0f; case MO_DEATH_MO_CORE_BURST: - this->baseAlpha = 0.0f; - if (this->timers[0] & 4) { + pthis->baseAlpha = 0.0f; + if (pthis->timers[0] & 4) { sp80 = 0.005f; sp7C = 0.015f; } else { sp80 = 0.015f; sp7C = 0.005f; } - Math_ApproachF(&this->actor.scale.x, sp80, 0.5f, 0.002f); - this->actor.scale.z = this->actor.scale.x; - Math_ApproachF(&this->actor.scale.y, sp7C, 0.5f, 0.002f); - this->cameraYaw += this->cameraYawRate; - if (this->timers[0] >= 30) { - Math_ApproachF(&this->cameraYawRate, 0.05f, 1.0f, 0.002f); + Math_ApproachF(&pthis->actor.scale.x, sp80, 0.5f, 0.002f); + pthis->actor.scale.z = pthis->actor.scale.x; + Math_ApproachF(&pthis->actor.scale.y, sp7C, 0.5f, 0.002f); + pthis->cameraYaw += pthis->cameraYawRate; + if (pthis->timers[0] >= 30) { + Math_ApproachF(&pthis->cameraYawRate, 0.05f, 1.0f, 0.002f); } else { - Math_ApproachF(&this->cameraYawRate, 0.0f, 1.0f, 0.002f); + Math_ApproachF(&pthis->cameraYawRate, 0.0f, 1.0f, 0.002f); } - Math_ApproachF(&this->actor.world.pos.y, 150.0f, 0.05f, 5.0f); - Math_ApproachF(&this->cameraEye.y, 100.0f, 0.05f, 2.0f); - this->cameraAt = this->cameraNextAt = this->actor.world.pos; - if (this->timers[0] > 20) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_DEAD - SFX_FLAG); + Math_ApproachF(&pthis->actor.world.pos.y, 150.0f, 0.05f, 5.0f); + Math_ApproachF(&pthis->cameraEye.y, 100.0f, 0.05f, 2.0f); + pthis->cameraAt = pthis->cameraNextAt = pthis->actor.world.pos; + if (pthis->timers[0] > 20) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_DEAD - SFX_FLAG); } - if (this->timers[0] == 20) { + if (pthis->timers[0] == 20) { for (i = 0; i < 300; i++) { velocity.x = Rand_CenteredFloat(10.0f); velocity.y = Rand_CenteredFloat(10.0f); velocity.z = Rand_CenteredFloat(10.0f); - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.x += 2.0f * velocity.x; pos.y += 2.0f * velocity.y; pos.z += 2.0f * velocity.z; BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &pos, &velocity, Rand_ZeroFloat(0.08f) + 0.13f); } - this->drawActor = false; - this->actor.flags &= ~ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_JUMP); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 70, NA_SE_EN_MOFER_LASTVOICE); + pthis->drawActor = false; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_JUMP); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 70, NA_SE_EN_MOFER_LASTVOICE); } - if (this->timers[0] == 0) { - this->csState = MO_DEATH_DRAIN_WATER_1; - this->cameraDist = 490.0f; - this->actor.world.pos.y = -1000.0f; - this->fwork[MO_TENT_SWING_SIZE_X] = 15.0f; - this->cameraYaw = 0.0f; - this->cameraEye.x = 490.0f; - this->cameraEye.y = 50.0f; - this->cameraEye.z = 0.0f; - this->cameraAt.x = 0; - this->cameraAt.y = -100.0f; - this->cameraAt.z = 0.0f; - this->work[MO_TENT_VAR_TIMER] = this->work[MO_TENT_MOVE_TIMER] = 0; - this->cameraAtMaxVel.y = 0.05f; - this->cameraAtVel.y = 4.0f; - this->cameraSpeedMod = 0.0f; - this->cameraAccel = 0.02f; - this->cameraNextAt.y = 320.0f; + if (pthis->timers[0] == 0) { + pthis->csState = MO_DEATH_DRAIN_WATER_1; + pthis->cameraDist = 490.0f; + pthis->actor.world.pos.y = -1000.0f; + pthis->fwork[MO_TENT_SWING_SIZE_X] = 15.0f; + pthis->cameraYaw = 0.0f; + pthis->cameraEye.x = 490.0f; + pthis->cameraEye.y = 50.0f; + pthis->cameraEye.z = 0.0f; + pthis->cameraAt.x = 0; + pthis->cameraAt.y = -100.0f; + pthis->cameraAt.z = 0.0f; + pthis->work[MO_TENT_VAR_TIMER] = pthis->work[MO_TENT_MOVE_TIMER] = 0; + pthis->cameraAtMaxVel.y = 0.05f; + pthis->cameraAtVel.y = 4.0f; + pthis->cameraSpeedMod = 0.0f; + pthis->cameraAccel = 0.02f; + pthis->cameraNextAt.y = 320.0f; if (1) {} - this->timers[0] = 100; + pthis->timers[0] = 100; sMorphaTent1->drawActor = true; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_3; sMorphaTent1->actor.shape.rot.x = 0; @@ -1636,90 +1636,90 @@ void BossMo_DeathCs(BossMo* this, GlobalContext* globalCtx) { } break; case MO_DEATH_DRAIN_WATER_1: - if (this->timers[0] == 0) { - this->csState = MO_DEATH_DRAIN_WATER_2; - this->cameraAt.y = -200.0f; - this->cameraNextAt.y = 320.0f; - this->cameraAtMaxVel.y = 0.05f; - this->cameraAtVel.y = 4.0f; - this->cameraSpeedMod = 0.0f; - this->cameraAccel = 0.0f; + if (pthis->timers[0] == 0) { + pthis->csState = MO_DEATH_DRAIN_WATER_2; + pthis->cameraAt.y = -200.0f; + pthis->cameraNextAt.y = 320.0f; + pthis->cameraAtMaxVel.y = 0.05f; + pthis->cameraAtVel.y = 4.0f; + pthis->cameraSpeedMod = 0.0f; + pthis->cameraAccel = 0.0f; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_1; - this->timers[0] = 125; + pthis->timers[0] = 125; sMorphaTent1->fwork[MO_TENT_MAX_STRETCH] = 3.7000003f; - this->cameraYaw = 0.5f; - this->cameraDist = 200.0f; + pthis->cameraYaw = 0.5f; + pthis->cameraDist = 200.0f; return; } break; case MO_DEATH_DRAIN_WATER_2: - if (this->timers[0] == 0) { - this->cameraAccel = 0.02f; + if (pthis->timers[0] == 0) { + pthis->cameraAccel = 0.02f; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_2; - this->csState = MO_DEATH_CEILING; + pthis->csState = MO_DEATH_CEILING; sMorphaTent1->timers[0] = 120; - this->timers[0] = 150; + pthis->timers[0] = 150; } case MO_DEATH_CEILING: - Math_ApproachF(&this->cameraYaw, 0.0f, 0.05f, 0.0029999996f); - Math_ApproachF(&this->cameraDist, 490.0f, 0.1f, 1.0f); - if (this->timers[0] == 0) { - this->csState = MO_DEATH_DROPLET; - this->timers[0] = 140; - this->cameraYawRate = 0.0f; - this->cameraSpeed = 0.0f; + Math_ApproachF(&pthis->cameraYaw, 0.0f, 0.05f, 0.0029999996f); + Math_ApproachF(&pthis->cameraDist, 490.0f, 0.1f, 1.0f); + if (pthis->timers[0] == 0) { + pthis->csState = MO_DEATH_DROPLET; + pthis->timers[0] = 140; + pthis->cameraYawRate = 0.0f; + pthis->cameraSpeed = 0.0f; } break; case MO_DEATH_DROPLET: - if (this->timers[0] == 30) { + if (pthis->timers[0] == 30) { sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_5; sMorphaTent1->timers[0] = 30; sMorphaTent1->tentMaxAngle = 0.0f; sMorphaTent1->tentSpeed = sMorphaTent1->tentMaxAngle; } - if (this->timers[0] == 0) { - if (-100.0f < this->cameraEye.y) { - Math_ApproachF(&this->cameraEye.y, sMorphaTent1->actor.world.pos.y - 100.0f, 0.1f, 2000.0f); + if (pthis->timers[0] == 0) { + if (-100.0f < pthis->cameraEye.y) { + Math_ApproachF(&pthis->cameraEye.y, sMorphaTent1->actor.world.pos.y - 100.0f, 0.1f, 2000.0f); } else { - Math_ApproachF(&this->cameraEye.y, -200.0f, 0.1f, 2000.0f); + Math_ApproachF(&pthis->cameraEye.y, -200.0f, 0.1f, 2000.0f); } - Math_ApproachF(&this->cameraAt.y, (sMorphaTent1->actor.world.pos.y - 50.0f) + 30.0f, 0.5f, 2000.0f); - this->cameraNextAt.y = this->cameraAt.y; + Math_ApproachF(&pthis->cameraAt.y, (sMorphaTent1->actor.world.pos.y - 50.0f) + 30.0f, 0.5f, 2000.0f); + pthis->cameraNextAt.y = pthis->cameraAt.y; } else { - Math_ApproachF(&this->cameraEye.y, 300.0f, 0.05f, this->cameraSpeed); + Math_ApproachF(&pthis->cameraEye.y, 300.0f, 0.05f, pthis->cameraSpeed); } - Math_ApproachF(&this->cameraYaw, -M_PI / 2.0f, 0.05f, this->cameraYawRate); - Math_ApproachF(&this->cameraSpeed, 3.0f, 1.0f, 0.05f); - Math_ApproachF(&this->cameraYawRate, 0.012999999f, 1.0f, 0.0005f); + Math_ApproachF(&pthis->cameraYaw, -M_PI / 2.0f, 0.05f, pthis->cameraYawRate); + Math_ApproachF(&pthis->cameraSpeed, 3.0f, 1.0f, 0.05f); + Math_ApproachF(&pthis->cameraYawRate, 0.012999999f, 1.0f, 0.0005f); if (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_6) { - Math_ApproachF(&this->cameraDist, 200.0f, 0.02f, this->cameraSpeed); + Math_ApproachF(&pthis->cameraDist, 200.0f, 0.02f, pthis->cameraSpeed); if (sMorphaTent1->timers[0] == 0) { - this->csState = MO_DEATH_FINISH; - camera->eye = this->cameraEye; - camera->eyeNext = this->cameraEye; - camera->at = this->cameraAt; - func_800C08AC(globalCtx, this->csCamera, 0); - this->csCamera = 0; + pthis->csState = MO_DEATH_FINISH; + camera->eye = pthis->cameraEye; + camera->eyeNext = pthis->cameraEye; + camera->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->csCamera, 0); + pthis->csCamera = 0; func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); sMorphaTent1->actor.world.pos.y = -1000.0f; } } else { - Math_ApproachF(&this->cameraDist, 150.0f, 0.05f, this->cameraSpeed); + Math_ApproachF(&pthis->cameraDist, 150.0f, 0.05f, pthis->cameraSpeed); } break; case MO_DEATH_FINISH: break; } - if ((this->csState > MO_DEATH_START) && (this->csState < MO_DEATH_FINISH)) { - if (this->work[MO_TENT_MOVE_TIMER] < 500) { + if ((pthis->csState > MO_DEATH_START) && (pthis->csState < MO_DEATH_FINISH)) { + if (pthis->work[MO_TENT_MOVE_TIMER] < 500) { func_80078914(&sAudioZeroVec, NA_SE_EN_MOFER_APPEAR - SFX_FLAG); } - if ((this->work[MO_TENT_MOVE_TIMER] < 490) && (this->work[MO_TENT_MOVE_TIMER] > 230)) { + if ((pthis->work[MO_TENT_MOVE_TIMER] < 490) && (pthis->work[MO_TENT_MOVE_TIMER] > 230)) { func_80078914(&sAudioZeroVec, NA_SE_EV_DROP_FALL - SFX_FLAG); } - if (this->work[MO_TENT_MOVE_TIMER] < 220) { + if (pthis->work[MO_TENT_MOVE_TIMER] < 220) { func_80078914(&sAudioZeroVec, NA_SE_EV_SCOOPUP_WATER - SFX_FLAG); } } @@ -1732,71 +1732,71 @@ void BossMo_DeathCs(BossMo* this, GlobalContext* globalCtx) { if (sMorphaCore->waterLevel < -250.0f) { Math_ApproachF(&sMorphaTent1->waterTexAlpha, 0.0f, 1.0f, 3.0f); } - Math_ApproachF(&this->fwork[MO_TENT_SWING_SIZE_X], 0.0f, 0.1f, 0.05f); + Math_ApproachF(&pthis->fwork[MO_TENT_SWING_SIZE_X], 0.0f, 0.1f, 0.05f); - sp70.x = this->cameraDist; + sp70.x = pthis->cameraDist; sp70.y = 0.0f; sp70.z = 0.0f; - Matrix_RotateY(this->cameraYaw, MTXMODE_NEW); + Matrix_RotateY(pthis->cameraYaw, MTXMODE_NEW); Matrix_MultVec3f(&sp70, &sp64); - this->cameraEye.x = sp64.x + this->cameraAt.x; - this->cameraEye.z = sp64.z + this->cameraAt.z; + pthis->cameraEye.x = sp64.x + pthis->cameraAt.x; + pthis->cameraEye.z = sp64.z + pthis->cameraAt.z; one = 1; // Super fake, but it works - if (this->csCamera != 0) { + if (pthis->csCamera != 0) { if (one) { - Math_ApproachF(&this->cameraAt.y, this->cameraNextAt.y, this->cameraAtMaxVel.y, - this->cameraAtVel.y * this->cameraSpeedMod); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, this->cameraAccel); + Math_ApproachF(&pthis->cameraAt.y, pthis->cameraNextAt.y, pthis->cameraAtMaxVel.y, + pthis->cameraAtVel.y * pthis->cameraSpeedMod); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, pthis->cameraAccel); } - Gameplay_CameraSetAtEye(globalCtx, this->csCamera, &this->cameraAt, &this->cameraEye); + Gameplay_CameraSetAtEye(globalCtx, pthis->csCamera, &pthis->cameraAt, &pthis->cameraEye); } } -void BossMo_CoreCollisionCheck(BossMo* this, GlobalContext* globalCtx) { +void BossMo_CoreCollisionCheck(BossMo* pthis, GlobalContext* globalCtx) { s16 i; Player* player = GET_PLAYER(globalCtx); osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("Core_Damage_check START\n"); - if (this->coreCollider.base.atFlags & AT_HIT) { - this->coreCollider.base.atFlags &= ~AT_HIT; - if (this->work[MO_TENT_ACTION_STATE] == MO_CORE_UNDERWATER) { - this->work[MO_CORE_WAIT_IN_WATER] = true; - this->timers[0] = 150; + if (pthis->coreCollider.base.atFlags & AT_HIT) { + pthis->coreCollider.base.atFlags &= ~AT_HIT; + if (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_UNDERWATER) { + pthis->work[MO_CORE_WAIT_IN_WATER] = true; + pthis->timers[0] = 150; } } - if (this->coreCollider.base.acFlags & AC_HIT) { - ColliderInfo* hurtbox = this->coreCollider.info.acHitInfo; + if (pthis->coreCollider.base.acFlags & AC_HIT) { + ColliderInfo* hurtbox = pthis->coreCollider.info.acHitInfo; // "hit!!" osSyncPrintf("Core_Damage_check 当り!!\n"); - this->coreCollider.base.acFlags &= ~AC_HIT; - if ((hurtbox->toucher.dmgFlags & 0x00020000) && (this->work[MO_TENT_ACTION_STATE] == MO_CORE_ATTACK)) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_RETREAT; + pthis->coreCollider.base.acFlags &= ~AC_HIT; + if ((hurtbox->toucher.dmgFlags & 0x00020000) && (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_ATTACK)) { + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_RETREAT; } // "hit 2 !!" osSyncPrintf("Core_Damage_check 当り 2 !!\n"); - if ((this->work[MO_TENT_ACTION_STATE] != MO_CORE_UNDERWATER) && (this->work[MO_TENT_INVINC_TIMER] == 0)) { + if ((pthis->work[MO_TENT_ACTION_STATE] != MO_CORE_UNDERWATER) && (pthis->work[MO_TENT_INVINC_TIMER] == 0)) { u8 damage = CollisionCheck_GetSwordDamage(hurtbox->toucher.dmgFlags); - if ((damage != 0) && (this->work[MO_TENT_ACTION_STATE] < MO_CORE_ATTACK)) { + if ((damage != 0) && (pthis->work[MO_TENT_ACTION_STATE] < MO_CORE_ATTACK)) { // "sword hit !!" osSyncPrintf("Core_Damage_check 剣 当り!!\n"); - this->work[MO_TENT_ACTION_STATE] = MO_CORE_STUNNED; - this->timers[0] = 25; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_STUNNED; + pthis->timers[0] = 25; - this->actor.speedXZ = 15.0f; + pthis->actor.speedXZ = 15.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; - this->work[MO_CORE_DMG_FLASH_TIMER] = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_DAMAGE); - this->actor.colChkInfo.health -= damage; - this->hitCount++; - if ((s8)this->actor.colChkInfo.health <= 0) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + pthis->work[MO_CORE_DMG_FLASH_TIMER] = 15; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_DAMAGE); + pthis->actor.colChkInfo.health -= damage; + pthis->hitCount++; + if ((s8)pthis->actor.colChkInfo.health <= 0) { if (((sMorphaTent1->csCamera == 0) && (sMorphaTent2 == NULL)) || ((sMorphaTent1->csCamera == 0) && (sMorphaTent2 != NULL) && (sMorphaTent2->csCamera == 0))) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - this->csState = MO_DEATH_START; + pthis->csState = MO_DEATH_START; sMorphaTent1->drawActor = false; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_START; sMorphaTent1->baseAlpha = 0.0f; @@ -1809,14 +1809,14 @@ void BossMo_CoreCollisionCheck(BossMo* this, GlobalContext* globalCtx) { player->csMode = 0; } } else { - this->actor.colChkInfo.health = 1; + pthis->actor.colChkInfo.health = 1; } } - this->work[MO_TENT_INVINC_TIMER] = 10; + pthis->work[MO_TENT_INVINC_TIMER] = 10; } else if (!(hurtbox->toucher.dmgFlags & 0x00100000) && (hurtbox->toucher.dmgFlags & 0x80)) { - if (this->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK) { + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK) { func_80078914(&sMorphaTent1->tentTipPos, NA_SE_EN_MOFER_CUT); - sMorphaTent1->cutIndex = this->work[MO_CORE_POS_IN_TENT]; + sMorphaTent1->cutIndex = pthis->work[MO_CORE_POS_IN_TENT]; sMorphaTent1->meltIndex = sMorphaTent1->cutIndex + 1; sMorphaTent1->cutScale = 1.0f; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_CUT; @@ -1828,10 +1828,10 @@ void BossMo_CoreCollisionCheck(BossMo* this, GlobalContext* globalCtx) { player->csMode = 0; } } - this->work[MO_TENT_ACTION_STATE] = MO_CORE_STUNNED; - this->timers[0] = 30; - this->work[MO_TENT_INVINC_TIMER] = 10; - this->actor.speedXZ = 0.0f; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_STUNNED; + pthis->timers[0] = 30; + pthis->work[MO_TENT_INVINC_TIMER] = 10; + pthis->actor.speedXZ = 0.0f; } for (i = 0; i < 10; i++) { Vec3f pos; @@ -1840,7 +1840,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, GlobalContext* globalCtx) { velocity.x = Rand_CenteredFloat(4.0f); velocity.y = Rand_ZeroFloat(2.0f) + 3.0f; velocity.z = Rand_CenteredFloat(4.0f); - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.x += (velocity.x * 3.0f); pos.z += (velocity.z * 3.0f); BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &pos, &velocity, @@ -1853,7 +1853,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, GlobalContext* globalCtx) { osSyncPrintf(VT_RST); } -void BossMo_Core(BossMo* this, GlobalContext* globalCtx) { +void BossMo_Core(BossMo* pthis, GlobalContext* globalCtx) { static f32 coreBulge[11] = { 0.1f, 0.15f, 0.2f, 0.3f, 0.4f, 0.43f, 0.4f, 0.3f, 0.2f, 0.15f, 0.1f, }; @@ -1886,25 +1886,25 @@ void BossMo_Core(BossMo* this, GlobalContext* globalCtx) { f32 sp5C; f32 sp58; - this->waterTex1x += -1.0f; - this->waterTex1y += -1.0f; - this->waterTex2x = this->waterTex2x; - this->waterTex2y++; + pthis->waterTex1x += -1.0f; + pthis->waterTex1y += -1.0f; + pthis->waterTex2x = pthis->waterTex2x; + pthis->waterTex2y++; - Math_ApproachF(&this->baseAlpha, 255.0f, 1.0f, 10.0f); - if ((this->csState != MO_BATTLE) && (this->csState < MO_DEATH_START)) { - BossMo_IntroCs(this, globalCtx); - if (this->work[MO_TENT_ACTION_STATE] == MO_CORE_INTRO_WAIT) { - this->actor.flags &= ~ACTOR_FLAG_0; + Math_ApproachF(&pthis->baseAlpha, 255.0f, 1.0f, 10.0f); + if ((pthis->csState != MO_BATTLE) && (pthis->csState < MO_DEATH_START)) { + BossMo_IntroCs(pthis, globalCtx); + if (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_INTRO_WAIT) { + pthis->actor.flags &= ~ACTOR_FLAG_0; return; } - } else if (this->csState >= MO_DEATH_START) { - BossMo_DeathCs(this, globalCtx); + } else if (pthis->csState >= MO_DEATH_START) { + BossMo_DeathCs(pthis, globalCtx); return; } - if ((this->work[MO_TENT_ACTION_STATE] < MO_CORE_ATTACK) && (this->work[MO_TENT_ACTION_STATE] >= MO_CORE_MOVE) && - (this->actor.world.pos.y > MO_WATER_LEVEL(globalCtx))) { - if (this->actor.velocity.y > 0.0f) { + if ((pthis->work[MO_TENT_ACTION_STATE] < MO_CORE_ATTACK) && (pthis->work[MO_TENT_ACTION_STATE] >= MO_CORE_MOVE) && + (pthis->actor.world.pos.y > MO_WATER_LEVEL(globalCtx))) { + if (pthis->actor.velocity.y > 0.0f) { xScaleTarget = 0.005f; yScaleTarget = 0.015f; } else { @@ -1914,27 +1914,27 @@ void BossMo_Core(BossMo* this, GlobalContext* globalCtx) { } else { xScaleTarget = yScaleTarget = 0.008f; } - Math_ApproachF(&this->actor.scale.x, xScaleTarget, 0.2f, 0.001f); - this->actor.scale.z = this->actor.scale.x; - Math_ApproachF(&this->actor.scale.y, yScaleTarget, 0.2f, 0.001f); - this->work[MO_CORE_DRAW_SHADOW] = BossMo_NearLand(&this->actor.world.pos, 15.0f); - nearLand = BossMo_NearLand(&this->actor.world.pos, 0.0f); + Math_ApproachF(&pthis->actor.scale.x, xScaleTarget, 0.2f, 0.001f); + pthis->actor.scale.z = pthis->actor.scale.x; + Math_ApproachF(&pthis->actor.scale.y, yScaleTarget, 0.2f, 0.001f); + pthis->work[MO_CORE_DRAW_SHADOW] = BossMo_NearLand(&pthis->actor.world.pos, 15.0f); + nearLand = BossMo_NearLand(&pthis->actor.world.pos, 0.0f); if ((player->actor.world.pos.y < (MO_WATER_LEVEL(globalCtx) - 50.0f)) && - ((this->work[MO_TENT_ACTION_STATE] == MO_CORE_MOVE) || - (this->work[MO_TENT_ACTION_STATE] == MO_CORE_MAKE_TENT))) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_UNDERWATER; - this->actor.speedXZ = 0.0f; - this->work[MO_CORE_WAIT_IN_WATER] = 0; + ((pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_MOVE) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_MAKE_TENT))) { + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_UNDERWATER; + pthis->actor.speedXZ = 0.0f; + pthis->work[MO_CORE_WAIT_IN_WATER] = 0; } - switch (this->work[MO_TENT_ACTION_STATE]) { + switch (pthis->work[MO_TENT_ACTION_STATE]) { case MO_CORE_MOVE: - this->actor.flags |= ACTOR_FLAG_0; - if ((this->timers[0] == 0) && + pthis->actor.flags |= ACTOR_FLAG_0; + if ((pthis->timers[0] == 0) && ((sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_WAIT) || (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_READY)) && - (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx))) { - this->actor.speedXZ = 0.0f; - this->work[MO_TENT_ACTION_STATE] = MO_CORE_MAKE_TENT; + (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx))) { + pthis->actor.speedXZ = 0.0f; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_MAKE_TENT; if (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_WAIT) { sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_SPAWN; sMorphaTent1->timers[0] = 70; @@ -1945,244 +1945,244 @@ void BossMo_Core(BossMo* this, GlobalContext* globalCtx) { case MO_CORE_MAKE_TENT: if ((sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_DESPAWN) || (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_WAIT)) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_MOVE; - this->timers[0] = 70; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_MOVE; + pthis->timers[0] = 70; } if (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_CUT) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_ATTACK; - this->work[MO_CORE_POS_IN_TENT] = 0; - this->timers[0] = 0; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_ATTACK; + pthis->work[MO_CORE_POS_IN_TENT] = 0; + pthis->timers[0] = 0; } if (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_ATTACK) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_ATTACK; - this->work[MO_CORE_POS_IN_TENT] = 0; - this->timers[0] = 0; - this->actor.speedXZ = 0.0f; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_ATTACK; + pthis->work[MO_CORE_POS_IN_TENT] = 0; + pthis->timers[0] = 0; + pthis->actor.speedXZ = 0.0f; } break; case MO_CORE_UNDERWATER: if (player->actor.world.pos.y >= MO_WATER_LEVEL(globalCtx)) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_MOVE; - this->actor.speedXZ = 0.0f; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_MOVE; + pthis->actor.speedXZ = 0.0f; } break; case MO_CORE_STUNNED: - this->actor.flags |= ACTOR_FLAG_0; - if (this->timers[0] == 0) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_MOVE; - this->timers[0] = 30; + pthis->actor.flags |= ACTOR_FLAG_0; + if (pthis->timers[0] == 0) { + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_MOVE; + pthis->timers[0] = 30; } - if (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_MAKE_TENT; - this->timers[0] = 50; - this->actor.speedXZ = 0.0f; + if (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_MAKE_TENT; + pthis->timers[0] = 50; + pthis->actor.speedXZ = 0.0f; } break; case MO_CORE_UNUSED: break; } - if (this->timers[0] == 0) { - switch (this->work[MO_TENT_ACTION_STATE]) { + if (pthis->timers[0] == 0) { + switch (pthis->work[MO_TENT_ACTION_STATE]) { case MO_CORE_ATTACK: - this->actor.flags |= ACTOR_FLAG_0; - this->work[MO_CORE_POS_IN_TENT]++; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->work[MO_CORE_POS_IN_TENT]++; if (sMorphaTent1->work[MO_TENT_ACTION_STATE] == MO_TENT_ATTACK) { - temp = (s16)(Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 0x300) * 10.0f) + 15; - if (this->work[MO_CORE_POS_IN_TENT] >= temp) { - this->work[MO_CORE_POS_IN_TENT] = temp; + temp = (s16)(Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 0x300) * 10.0f) + 15; + if (pthis->work[MO_CORE_POS_IN_TENT] >= temp) { + pthis->work[MO_CORE_POS_IN_TENT] = temp; } } if ((sMorphaTent1->work[MO_TENT_ACTION_STATE] != MO_TENT_ATTACK) && (sMorphaTent1->work[MO_TENT_ACTION_STATE] != MO_TENT_CUT)) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_RETREAT; - this->timers[0] = 0; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_RETREAT; + pthis->timers[0] = 0; } break; case MO_CORE_RETREAT: - this->work[MO_CORE_POS_IN_TENT]--; - if (this->work[MO_CORE_POS_IN_TENT] <= 0) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_MAKE_TENT; - this->timers[0] = 100; - this->tentSpeed = 0.0f; - this->actor.speedXZ = 0.0f; + pthis->work[MO_CORE_POS_IN_TENT]--; + if (pthis->work[MO_CORE_POS_IN_TENT] <= 0) { + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_MAKE_TENT; + pthis->timers[0] = 100; + pthis->tentSpeed = 0.0f; + pthis->actor.speedXZ = 0.0f; } - this->timers[0] = 0; + pthis->timers[0] = 0; break; case MO_CORE_INTRO_REVEAL: - this->actor.flags &= ~ACTOR_FLAG_0; - this->work[MO_CORE_POS_IN_TENT]++; - temp = (s16)(Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 0x500) * 10.0f) + 15; - if (this->work[MO_CORE_POS_IN_TENT] >= temp) { - this->work[MO_CORE_POS_IN_TENT] = temp; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->work[MO_CORE_POS_IN_TENT]++; + temp = (s16)(Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 0x500) * 10.0f) + 15; + if (pthis->work[MO_CORE_POS_IN_TENT] >= temp) { + pthis->work[MO_CORE_POS_IN_TENT] = temp; } if (sMorphaTent1->work[MO_TENT_ACTION_STATE] != MO_TENT_READY) { - this->work[MO_TENT_ACTION_STATE] = MO_CORE_RETREAT; - this->timers[0] = 0; + pthis->work[MO_TENT_ACTION_STATE] = MO_CORE_RETREAT; + pthis->timers[0] = 0; } break; } } - if (this->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK) { - if (this->work[MO_CORE_POS_IN_TENT] < 0) { - this->work[MO_CORE_POS_IN_TENT] = 0; - } else if (this->work[MO_CORE_POS_IN_TENT] >= 41) { - this->work[MO_CORE_POS_IN_TENT] = 40; + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK) { + if (pthis->work[MO_CORE_POS_IN_TENT] < 0) { + pthis->work[MO_CORE_POS_IN_TENT] = 0; + } else if (pthis->work[MO_CORE_POS_IN_TENT] >= 41) { + pthis->work[MO_CORE_POS_IN_TENT] = 40; } - index = (300 - (this->work[MO_CORE_POS_IN_TENT] * 2) + sMorphaTent1->widthIndex) % 300; - sp88 = sMorphaTent1->tentWidth[index] * sTentWidth[this->work[MO_CORE_POS_IN_TENT]]; + index = (300 - (pthis->work[MO_CORE_POS_IN_TENT] * 2) + sMorphaTent1->widthIndex) % 300; + sp88 = sMorphaTent1->tentWidth[index] * sTentWidth[pthis->work[MO_CORE_POS_IN_TENT]]; for (j = -5; j < 6; j++) { - index = (this->work[MO_CORE_POS_IN_TENT] + j) - 2; + index = (pthis->work[MO_CORE_POS_IN_TENT] + j) - 2; if ((0 <= index) && (index < 41)) { Math_ApproachF(&sMorphaTent1->tentScale[index].x, ((coreBulge[j + 5] * 300.0f) / 100.0f) + sp88, 0.75f, 5.0f); } } - this->targetPos.x = sMorphaTent1->tentPos[this->work[MO_CORE_POS_IN_TENT]].x; - this->targetPos.y = sMorphaTent1->tentPos[this->work[MO_CORE_POS_IN_TENT]].y; - this->targetPos.z = sMorphaTent1->tentPos[this->work[MO_CORE_POS_IN_TENT]].z; - if (this->work[MO_CORE_POS_IN_TENT] <= 1) { - this->targetPos.y -= 20.0f; + pthis->targetPos.x = sMorphaTent1->tentPos[pthis->work[MO_CORE_POS_IN_TENT]].x; + pthis->targetPos.y = sMorphaTent1->tentPos[pthis->work[MO_CORE_POS_IN_TENT]].y; + pthis->targetPos.z = sMorphaTent1->tentPos[pthis->work[MO_CORE_POS_IN_TENT]].z; + if (pthis->work[MO_CORE_POS_IN_TENT] <= 1) { + pthis->targetPos.y -= 20.0f; } - Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, this->actor.speedXZ); - Math_ApproachF(&this->actor.world.pos.y, this->targetPos.y, 0.5f, this->actor.speedXZ); - Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.5f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 30.0f, 1.0f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.x, pthis->targetPos.x, 0.5f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetPos.y, 0.5f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->targetPos.z, 0.5f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 30.0f, 1.0f, 1.0f); } else { - switch (this->work[MO_TENT_ACTION_STATE]) { + switch (pthis->work[MO_TENT_ACTION_STATE]) { case MO_CORE_MOVE: - sp80 = Math_SinS(this->work[MO_TENT_VAR_TIMER] * 0x800) * 100.0f; - sp7C = Math_CosS(this->work[MO_TENT_VAR_TIMER] * 0x800) * 100.0f; - Math_ApproachF(&this->actor.world.pos.x, sMorphaTent1->targetPos.x + sp80, 0.05f, this->actor.speedXZ); - Math_ApproachF(&this->actor.world.pos.z, sMorphaTent1->targetPos.z + sp7C, 0.05f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 0.5f); + sp80 = Math_SinS(pthis->work[MO_TENT_VAR_TIMER] * 0x800) * 100.0f; + sp7C = Math_CosS(pthis->work[MO_TENT_VAR_TIMER] * 0x800) * 100.0f; + Math_ApproachF(&pthis->actor.world.pos.x, sMorphaTent1->targetPos.x + sp80, 0.05f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.world.pos.z, sMorphaTent1->targetPos.z + sp7C, 0.05f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 10.0f, 1.0f, 0.5f); break; case MO_CORE_STUNNED: - this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; + pthis->actor.velocity.x = Math_SinS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.velocity.z = Math_CosS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; break; } - if ((this->work[MO_TENT_ACTION_STATE] == MO_CORE_MOVE) || - (this->work[MO_TENT_ACTION_STATE] == MO_CORE_STUNNED)) { - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.velocity.y -= 1.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 20.0f, 100.0f, 1); + if ((pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_MOVE) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_STUNNED)) { + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.velocity.y -= 1.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 20.0f, 100.0f, 1); effectVelocity.x = effectVelocity.y = effectVelocity.z = 0.0f; for (i = 0; i < 1; i++) { - effectPos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - effectPos.y = Rand_CenteredFloat(20.0f) + this->actor.world.pos.y; - effectPos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; + effectPos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + effectPos.y = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.y; + effectPos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &effectPos, &effectVelocity, Rand_ZeroFloat(0.02f) + 0.05f); }; if (nearLand) { - if (this->actor.world.pos.y <= 10) { - this->actor.world.pos.y = 10; - this->actor.velocity.y = -0.01f; - if (this->timers[1] != 0) { - if (this->timers[1] == 1) { - this->actor.velocity.y = 6.0f; + if (pthis->actor.world.pos.y <= 10) { + pthis->actor.world.pos.y = 10; + pthis->actor.velocity.y = -0.01f; + if (pthis->timers[1] != 0) { + if (pthis->timers[1] == 1) { + pthis->actor.velocity.y = 6.0f; } } else { - this->timers[1] = 2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_LAND); + pthis->timers[1] = 2; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_LAND); for (i = 0; i < 10; i++) { effectVelocity.x = Rand_CenteredFloat(4.0f); effectVelocity.y = Rand_ZeroFloat(2.0f) + 3.0f; effectVelocity.z = Rand_CenteredFloat(4.0f); - effectPos = this->actor.world.pos; + effectPos = pthis->actor.world.pos; effectPos.x += effectVelocity.x; effectPos.z += effectVelocity.z; BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &effectPos, &effectVelocity, Rand_ZeroFloat(0.08f) + 0.13f); } effectVelocity.x = effectVelocity.y = effectVelocity.z = 0.0f; - effectPos = this->actor.world.pos; + effectPos = pthis->actor.world.pos; effectPos.y = 0.0f; BossMo_SpawnDroplet(MO_FX_DROPLET, (BossMoEffect*)globalCtx->specialEffects, &effectPos, &effectVelocity, 0.4f); } } - } else if (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { - this->actor.velocity.y = BossMo_NearLand(&this->actor.world.pos, 40.0f) ? 15.0f : 6.0f; - if ((this->actor.world.pos.y + 15.0f) >= MO_WATER_LEVEL(globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_JUMP); + } else if (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { + pthis->actor.velocity.y = BossMo_NearLand(&pthis->actor.world.pos, 40.0f) ? 15.0f : 6.0f; + if ((pthis->actor.world.pos.y + 15.0f) >= MO_WATER_LEVEL(globalCtx)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_JUMP); } } - } else if (this->work[MO_TENT_ACTION_STATE] >= MO_CORE_MOVE) { - if (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { - if (this->work[MO_TENT_ACTION_STATE] == MO_CORE_MAKE_TENT) { - this->targetPos.x = sMorphaTent1->targetPos.x; - this->targetPos.y = sMorphaTent1->actor.world.pos.y - 40.0f; - this->targetPos.z = sMorphaTent1->targetPos.z; - Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 0.5f); - } else if (this->work[MO_TENT_ACTION_STATE] == MO_CORE_UNDERWATER) { - switch (this->work[MO_CORE_WAIT_IN_WATER]) { + } else if (pthis->work[MO_TENT_ACTION_STATE] >= MO_CORE_MOVE) { + if (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { + if (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_MAKE_TENT) { + pthis->targetPos.x = sMorphaTent1->targetPos.x; + pthis->targetPos.y = sMorphaTent1->actor.world.pos.y - 40.0f; + pthis->targetPos.z = sMorphaTent1->targetPos.z; + Math_ApproachF(&pthis->actor.speedXZ, 10.0f, 1.0f, 0.5f); + } else if (pthis->work[MO_TENT_ACTION_STATE] == MO_CORE_UNDERWATER) { + switch (pthis->work[MO_CORE_WAIT_IN_WATER]) { case false: - this->targetPos = player->actor.world.pos; - this->targetPos.y += 30.0f; + pthis->targetPos = player->actor.world.pos; + pthis->targetPos.y += 30.0f; sp70.x = 0.0f; sp70.y = 0.0f; sp70.z = 100.0f; Matrix_RotateY((player->actor.world.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); Matrix_MultVec3f(&sp70, &sp64); - this->targetPos.x = player->actor.world.pos.x + sp64.x; - this->targetPos.y = player->actor.world.pos.y + 30.0f; - this->targetPos.z = player->actor.world.pos.z + sp64.z; - Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 1.0f); - if (this->timers[0] == 0) { - this->work[MO_CORE_WAIT_IN_WATER] = true; - this->timers[0] = (s16)Rand_ZeroFloat(50.0f) + 50; + pthis->targetPos.x = player->actor.world.pos.x + sp64.x; + pthis->targetPos.y = player->actor.world.pos.y + 30.0f; + pthis->targetPos.z = player->actor.world.pos.z + sp64.z; + Math_ApproachF(&pthis->actor.speedXZ, 10.0f, 1.0f, 1.0f); + if (pthis->timers[0] == 0) { + pthis->work[MO_CORE_WAIT_IN_WATER] = true; + pthis->timers[0] = (s16)Rand_ZeroFloat(50.0f) + 50; } break; case true: - Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.5f); - if (this->timers[0] == 0) { - this->work[MO_CORE_WAIT_IN_WATER] = false; - this->timers[0] = (s16)Rand_ZeroFloat(20.0f) + 20; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_MOVE_WT); + Math_ApproachF(&pthis->actor.speedXZ, 1.0f, 1.0f, 0.5f); + if (pthis->timers[0] == 0) { + pthis->work[MO_CORE_WAIT_IN_WATER] = false; + pthis->timers[0] = (s16)Rand_ZeroFloat(20.0f) + 20; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_MOVE_WT); } break; } } - this->targetPos.x += Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 3096.0f) * 30.0f; - this->targetPos.y += Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 2096.0f) * 30.0f; - this->targetPos.z += Math_SinS(this->work[MO_TENT_MOVE_TIMER] * 2796.0f) * 30.0f; - this->tentMaxAngle = 5.0f; - this->tentSpeed = 4000.0f; - spDC = this->targetPos.x - this->actor.world.pos.x; - spD8 = this->targetPos.y - this->actor.world.pos.y; - spD4 = this->targetPos.z - this->actor.world.pos.z; + pthis->targetPos.x += Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 3096.0f) * 30.0f; + pthis->targetPos.y += Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 2096.0f) * 30.0f; + pthis->targetPos.z += Math_SinS(pthis->work[MO_TENT_MOVE_TIMER] * 2796.0f) * 30.0f; + pthis->tentMaxAngle = 5.0f; + pthis->tentSpeed = 4000.0f; + spDC = pthis->targetPos.x - pthis->actor.world.pos.x; + spD8 = pthis->targetPos.y - pthis->actor.world.pos.y; + spD4 = pthis->targetPos.z - pthis->actor.world.pos.z; spCC = (s16)(Math_FAtan2F(spDC, spD4) * (0x8000 / M_PI)); spD0 = (s16)(Math_FAtan2F(spD8, sqrtf(SQ(spDC) + SQ(spD4))) * (0x8000 / M_PI)); - Math_ApproachS(&this->actor.world.rot.y, spCC, this->tentMaxAngle, this->tentSpeed); - Math_ApproachS(&this->actor.world.rot.x, spD0, this->tentMaxAngle, this->tentSpeed); - func_8002D908(&this->actor); + Math_ApproachS(&pthis->actor.world.rot.y, spCC, pthis->tentMaxAngle, pthis->tentSpeed); + Math_ApproachS(&pthis->actor.world.rot.x, spD0, pthis->tentMaxAngle, pthis->tentSpeed); + func_8002D908(&pthis->actor); } else { - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.velocity.y -= 1.0f; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.velocity.y -= 1.0f; } - func_8002D7EC(&this->actor); - temp = (this->actor.world.pos.y < -200.0f) ? 5 : 1; - this->actor.world.pos.y -= 20.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 20.0f, 100.0f, temp); - this->actor.world.pos.y += 20.0f; + func_8002D7EC(&pthis->actor); + temp = (pthis->actor.world.pos.y < -200.0f) ? 5 : 1; + pthis->actor.world.pos.y -= 20.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 20.0f, 100.0f, temp); + pthis->actor.world.pos.y += 20.0f; } } - if ((this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) && (MO_WATER_LEVEL(globalCtx) <= this->actor.prevPos.y)) { - if (this->actor.velocity.y < -5.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_JUMP); + if ((pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) && (MO_WATER_LEVEL(globalCtx) <= pthis->actor.prevPos.y)) { + if (pthis->actor.velocity.y < -5.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_JUMP); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOFER_CORE_SMJUMP); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MOFER_CORE_SMJUMP); } - if ((this->timers[3] != 0) || ((sMorphaTent1->fwork[MO_TENT_MAX_STRETCH] > 0.2f) && - (fabsf(this->actor.world.pos.x - sMorphaTent1->actor.world.pos.x) < 30.0f) && - (fabsf(this->actor.world.pos.z - sMorphaTent1->actor.world.pos.z) < 30.0f))) { + if ((pthis->timers[3] != 0) || ((sMorphaTent1->fwork[MO_TENT_MAX_STRETCH] > 0.2f) && + (fabsf(pthis->actor.world.pos.x - sMorphaTent1->actor.world.pos.x) < 30.0f) && + (fabsf(pthis->actor.world.pos.z - sMorphaTent1->actor.world.pos.z) < 30.0f))) { // This space intentionally left blank. } else { - this->timers[3] = 8; + pthis->timers[3] = 8; for (i = 0; i < 10; i++) { sp5C = Rand_ZeroFloat(3.14f); sp60 = Rand_ZeroFloat(0.6f) + 1.6f; @@ -2190,83 +2190,83 @@ void BossMo_Core(BossMo* this, GlobalContext* globalCtx) { effectVelocity.z = Math_CosS(((i * (f32)0x10000) / 10.0f) + sp5C) * sp60; effectVelocity.y = Rand_ZeroFloat(0.3f) + 3.0f; - effectPos = this->actor.world.pos; + effectPos = pthis->actor.world.pos; effectPos.x += effectVelocity.x * 3.0f; effectPos.y = MO_WATER_LEVEL(globalCtx); effectPos.z += effectVelocity.z * 3.0f; BossMo_SpawnDroplet(MO_FX_SPLASH, (BossMoEffect*)globalCtx->specialEffects, &effectPos, &effectVelocity, Rand_ZeroFloat(0.075f) + 0.15f); } - effectPos = this->actor.world.pos; + effectPos = pthis->actor.world.pos; effectPos.y = MO_WATER_LEVEL(globalCtx); - BossMo_SpawnRipple(globalCtx->specialEffects, &effectPos, 100.0f, 800.0f, 100, 290, MO_FX_SMALL_RIPPLE); - BossMo_SpawnRipple(globalCtx->specialEffects, &effectPos, 50.0f, 600.0f, 70, 290, MO_FX_SMALL_RIPPLE); - BossMo_SpawnRipple(globalCtx->specialEffects, &effectPos, 0, 400.0f, 50, 290, MO_FX_SMALL_RIPPLE); + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &effectPos, 100.0f, 800.0f, 100, 290, MO_FX_SMALL_RIPPLE); + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &effectPos, 50.0f, 600.0f, 70, 290, MO_FX_SMALL_RIPPLE); + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &effectPos, 0, 400.0f, 50, 290, MO_FX_SMALL_RIPPLE); } } - if ((this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) || (this->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK)) { + if ((pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) || (pthis->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK)) { for (i = 0; i < 3; i++) { effectAccel.x = effectAccel.z = 0.0f; effectVelocity.x = effectVelocity.y = effectVelocity.z = 0.0f; - if (this->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK) { + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_CORE_ATTACK) { effectAccel.y = 0.0f; sp58 = 10.0f; } else { effectAccel.y = 0.1f; sp58 = 20.0f; } - effectPos.x = Rand_CenteredFloat(sp58) + this->actor.world.pos.x; - effectPos.y = Rand_CenteredFloat(sp58) + this->actor.world.pos.y; - effectPos.z = Rand_CenteredFloat(sp58) + this->actor.world.pos.z; - BossMo_SpawnBubble(globalCtx->specialEffects, &effectPos, &effectVelocity, &effectAccel, + effectPos.x = Rand_CenteredFloat(sp58) + pthis->actor.world.pos.x; + effectPos.y = Rand_CenteredFloat(sp58) + pthis->actor.world.pos.y; + effectPos.z = Rand_CenteredFloat(sp58) + pthis->actor.world.pos.z; + BossMo_SpawnBubble((BossMoEffect*)globalCtx->specialEffects, &effectPos, &effectVelocity, &effectAccel, Rand_ZeroFloat(0.05f) + 0.1f, NULL); } } - BossMo_CoreCollisionCheck(this, globalCtx); + BossMo_CoreCollisionCheck(pthis, globalCtx); } void BossMo_UpdateCore(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BossMo* this = (BossMo*)thisx; + BossMo* pthis = (BossMo*)thisx; s16 i; Player* player = GET_PLAYER(globalCtx); - osSyncPrintf("CORE mode = <%d>\n", this->work[MO_TENT_ACTION_STATE]); + osSyncPrintf("CORE mode = <%d>\n", pthis->work[MO_TENT_ACTION_STATE]); if (sMorphaTent2 == NULL) { - MO_WATER_LEVEL(globalCtx) = sMorphaTent1->waterLevelMod + (s16)this->waterLevel; + MO_WATER_LEVEL(globalCtx) = sMorphaTent1->waterLevelMod + (s16)pthis->waterLevel; } else { - MO_WATER_LEVEL(globalCtx) = sMorphaTent2->waterLevelMod + ((s16)this->waterLevel + sMorphaTent1->waterLevelMod); + MO_WATER_LEVEL(globalCtx) = sMorphaTent2->waterLevelMod + ((s16)pthis->waterLevel + sMorphaTent1->waterLevelMod); } - this->actor.flags |= ACTOR_FLAG_9; - this->actor.focus.pos = this->actor.world.pos; - this->work[MO_TENT_VAR_TIMER]++; + pthis->actor.flags |= ACTOR_FLAG_9; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->work[MO_TENT_VAR_TIMER]++; - if (this->work[MO_CORE_DMG_FLASH_TIMER] != 0) { - this->work[MO_CORE_DMG_FLASH_TIMER]--; + if (pthis->work[MO_CORE_DMG_FLASH_TIMER] != 0) { + pthis->work[MO_CORE_DMG_FLASH_TIMER]--; } - if (this->work[MO_TENT_INVINC_TIMER] != 0) { - this->work[MO_TENT_INVINC_TIMER]--; + if (pthis->work[MO_TENT_INVINC_TIMER] != 0) { + pthis->work[MO_TENT_INVINC_TIMER]--; } - this->work[MO_TENT_MOVE_TIMER]++; + pthis->work[MO_TENT_MOVE_TIMER]++; - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; } } - BossMo_Core(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->coreCollider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->coreCollider.base); - if ((this->work[MO_TENT_ACTION_STATE] != MO_CORE_STUNNED) || - (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx))) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->coreCollider.base); + BossMo_Core(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->coreCollider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->coreCollider.base); + if ((pthis->work[MO_TENT_ACTION_STATE] != MO_CORE_STUNNED) || + (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx))) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->coreCollider.base); } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->coreCollider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->coreCollider.base); } - BossMo_UpdateEffects(this, globalCtx); + BossMo_UpdateEffects(pthis, globalCtx); if (player->actor.parent != NULL) { - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } BossMo_Unknown(); } @@ -2275,159 +2275,159 @@ void BossMo_UpdateTent(Actor* thisx, GlobalContext* globalCtx) { s16 i; s16 index; s32 pad; - BossMo* this = (BossMo*)thisx; + BossMo* pthis = (BossMo*)thisx; Player* player = GET_PLAYER(globalCtx); f32 phi_f0; - if ((this == sMorphaTent2) && (this->tent2KillTimer != 0)) { - this->tent2KillTimer++; - this->actor.draw = NULL; - if (this->tent2KillTimer > 20) { - Actor_Kill(&this->actor); - Audio_StopSfxByPos(&this->tentTipPos); + if ((pthis == sMorphaTent2) && (pthis->tent2KillTimer != 0)) { + pthis->tent2KillTimer++; + pthis->actor.draw = NULL; + if (pthis->tent2KillTimer > 20) { + Actor_Kill(&pthis->actor); + Audio_StopSfxByPos(&pthis->tentTipPos); sMorphaTent2 = NULL; } return; } - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->tentPos[40], &this->tentTipPos, - &this->actor.projectedW); - osSyncPrintf("MO : Move mode = <%d>\n", this->work[MO_TENT_ACTION_STATE]); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->tentPos[40], &pthis->tentTipPos, + &pthis->actor.projectedW); + osSyncPrintf("MO : Move mode = <%d>\n", pthis->work[MO_TENT_ACTION_STATE]); Math_ApproachS(&player->actor.shape.rot.x, 0, 5, 0x3E8); Math_ApproachS(&player->actor.shape.rot.z, 0, 5, 0x3E8); - this->work[MO_TENT_VAR_TIMER]++; - this->sfxTimer++; - this->work[MO_TENT_MOVE_TIMER]++; - this->widthIndex++; - if (this->widthIndex >= 300) { - this->widthIndex = 0; + pthis->work[MO_TENT_VAR_TIMER]++; + pthis->sfxTimer++; + pthis->work[MO_TENT_MOVE_TIMER]++; + pthis->widthIndex++; + if (pthis->widthIndex >= 300) { + pthis->widthIndex = 0; } - this->pulsePhase -= 3000; - index = this->widthIndex; - this->tentWidth[index] = (Math_SinS(this->pulsePhase) * this->tentPulse) + (1.0f + this->tentPulse); + pthis->pulsePhase -= 3000; + index = pthis->widthIndex; + pthis->tentWidth[index] = (Math_SinS(pthis->pulsePhase) * pthis->tentPulse) + (1.0f + pthis->tentPulse); for (i = 0; i < 41; i++) { - if (this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_START) { - if (this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_1) { - if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_5) { - phi_f0 = (this->timers[0] != 0) ? sFlatWidth[i] : sDropletWidth[i]; - Math_ApproachF(&this->tentScale[i].x, phi_f0, 0.5f, 100.0f); + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_START) { + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_1) { + if (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_5) { + phi_f0 = (pthis->timers[0] != 0) ? sFlatWidth[i] : sDropletWidth[i]; + Math_ApproachF(&pthis->tentScale[i].x, phi_f0, 0.5f, 100.0f); } else { - index = ((this->widthIndex + (i * 2)) + 220) % 300; - phi_f0 = this->tentWidth[index] + SQ(sTentWidth[i]); - Math_ApproachF(&this->tentScale[i].x, phi_f0, 0.5f, 0.3f); + index = ((pthis->widthIndex + (i * 2)) + 220) % 300; + phi_f0 = pthis->tentWidth[index] + SQ(sTentWidth[i]); + Math_ApproachF(&pthis->tentScale[i].x, phi_f0, 0.5f, 0.3f); } } else { - index = ((this->widthIndex - (i * 2)) + 300) % 300; - phi_f0 = this->tentWidth[index] * sTentWidth[i]; - this->tentScale[i].x = phi_f0; + index = ((pthis->widthIndex - (i * 2)) + 300) % 300; + phi_f0 = pthis->tentWidth[index] * sTentWidth[i]; + pthis->tentScale[i].x = phi_f0; } } else { - index = ((this->widthIndex - (i * 2)) + 300) % 300; - phi_f0 = this->tentWidth[index] * sTentWidth[i]; - Math_ApproachF(&this->tentScale[i].x, phi_f0, 0.5f, 0.3f); + index = ((pthis->widthIndex - (i * 2)) + 300) % 300; + phi_f0 = pthis->tentWidth[index] * sTentWidth[i]; + Math_ApproachF(&pthis->tentScale[i].x, phi_f0, 0.5f, 0.3f); } - phi_f0 = Math_SinS((this->work[MO_TENT_VAR_TIMER] * 12000.0f) + (i * 20000.0f)); - this->tentRipple[i].x = (1.0f * phi_f0) * this->tentRippleSize; - this->tentScale[i].y = this->tentScale[i].z = this->tentScale[i].x; - this->tentRipple[i].y = this->tentRipple[i].z = this->tentRipple[i].x; + phi_f0 = Math_SinS((pthis->work[MO_TENT_VAR_TIMER] * 12000.0f) + (i * 20000.0f)); + pthis->tentRipple[i].x = (1.0f * phi_f0) * pthis->tentRippleSize; + pthis->tentScale[i].y = pthis->tentScale[i].z = pthis->tentScale[i].x; + pthis->tentRipple[i].y = pthis->tentRipple[i].z = pthis->tentRipple[i].x; } - Math_ApproachF(&this->tentRippleSize, 0.0f, 0.1f, 0.005f); - Math_ApproachF(&this->tentPulse, 0.2f, 0.5f, 0.01f); - this->actionFunc(this, globalCtx); - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; + Math_ApproachF(&pthis->tentRippleSize, 0.0f, 0.1f, 0.005f); + Math_ApproachF(&pthis->tentPulse, 0.2f, 0.5f, 0.01f); + pthis->actionFunc(pthis, globalCtx); + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; } } - Math_ApproachS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xC8); - Actor_MoveForward(&this->actor); - Math_ApproachF(&this->actor.speedXZ, 0.0, 1.0f, 0.02f); + Math_ApproachS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0xA, 0xC8); + Actor_MoveForward(&pthis->actor); + Math_ApproachF(&pthis->actor.speedXZ, 0.0, 1.0f, 0.02f); - if (BossMo_NearLand(&this->actor.world.pos, 40)) { - this->actor.world.pos = this->actor.prevPos; + if (BossMo_NearLand(&pthis->actor.world.pos, 40)) { + pthis->actor.world.pos = pthis->actor.prevPos; } - if ((this->work[MO_TENT_VAR_TIMER] % 8) == 0) { + if ((pthis->work[MO_TENT_VAR_TIMER] % 8) == 0) { f32 rippleScale; - Vec3f pos = this->actor.world.pos; + Vec3f pos = pthis->actor.world.pos; - if (this->work[MO_TENT_ACTION_STATE] < MO_TENT_DEATH_START) { + if (pthis->work[MO_TENT_ACTION_STATE] < MO_TENT_DEATH_START) { rippleScale = 400.0f; } else { rippleScale = 0.0; - if (this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_1) { - pos = this->tentPos[38]; + if (pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_1) { + pos = pthis->tentPos[38]; } } - BossMo_SpawnRipple(globalCtx->specialEffects, &pos, rippleScale, rippleScale * 3.0f, this->baseAlpha * 0.6666f, + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &pos, rippleScale, rippleScale * 3.0f, pthis->baseAlpha * 0.6666f, 300, MO_FX_BIG_RIPPLE); } - if (this->baseBubblesTimer != 0) { + if (pthis->baseBubblesTimer != 0) { Vec3f sp88; Vec3f sp7C; Vec3f bubblePos; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s32 pad; - this->baseBubblesTimer--; + pthis->baseBubblesTimer--; sp88.x = 0.0; sp88.y = 0.0; sp88.z = 100.0f; Matrix_RotateY(Rand_ZeroFloat(2.0f * M_PI), MTXMODE_NEW); Matrix_MultVec3f(&sp88, &sp7C); - if ((this->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_1) && - (this->work[MO_TENT_ACTION_STATE] != MO_TENT_DEATH_3)) { + if ((pthis->work[MO_TENT_ACTION_STATE] >= MO_TENT_DEATH_1) && + (pthis->work[MO_TENT_ACTION_STATE] != MO_TENT_DEATH_3)) { i = 38; } else { i = 0; - if (this->work[MO_TENT_ACTION_STATE] < MO_TENT_CUT) { - func_80078914(&this->tentTipPos, NA_SE_EN_MOFER_CORE_ROLL - SFX_FLAG); + if (pthis->work[MO_TENT_ACTION_STATE] < MO_TENT_CUT) { + func_80078914(&pthis->tentTipPos, NA_SE_EN_MOFER_CORE_ROLL - SFX_FLAG); } } - bubblePos.x = this->tentPos[i].x + sp7C.x; + bubblePos.x = pthis->tentPos[i].x + sp7C.x; bubblePos.y = (MO_WATER_LEVEL(globalCtx) - 40.0f) + Rand_ZeroFloat(20.0f); - bubblePos.z = this->tentPos[i].z + sp7C.z; - BossMo_SpawnBubble(globalCtx->specialEffects, &bubblePos, &zeroVec, &zeroVec, Rand_ZeroFloat(0.05f) + 0.2f, - &this->tentPos[i]); + bubblePos.z = pthis->tentPos[i].z + sp7C.z; + BossMo_SpawnBubble((BossMoEffect*)globalCtx->specialEffects, &bubblePos, &zeroVec, &zeroVec, Rand_ZeroFloat(0.05f) + 0.2f, + &pthis->tentPos[i]); } - if (this->work[MO_CORE_DMG_FLASH_TIMER] != 0) { - this->work[MO_CORE_DMG_FLASH_TIMER]--; + if (pthis->work[MO_CORE_DMG_FLASH_TIMER] != 0) { + pthis->work[MO_CORE_DMG_FLASH_TIMER]--; } - if (this->work[MO_TENT_INVINC_TIMER] != 0) { - this->work[MO_TENT_INVINC_TIMER]--; + if (pthis->work[MO_TENT_INVINC_TIMER] != 0) { + pthis->work[MO_TENT_INVINC_TIMER]--; } - if (this->linkHitTimer != 0) { - this->linkHitTimer--; + if (pthis->linkHitTimer != 0) { + pthis->linkHitTimer--; } - if (this->drawActor) { - BossMo_TentCollisionCheck(this, globalCtx); - if ((this->work[MO_TENT_INVINC_TIMER] == 0) && (this->work[MO_TENT_ACTION_STATE] != MO_TENT_GRAB) && - (this->work[MO_TENT_ACTION_STATE] != MO_TENT_SHAKE)) { - BossMo* otherTent = (BossMo*)this->otherTent; + if (pthis->drawActor) { + BossMo_TentCollisionCheck(pthis, globalCtx); + if ((pthis->work[MO_TENT_INVINC_TIMER] == 0) && (pthis->work[MO_TENT_ACTION_STATE] != MO_TENT_GRAB) && + (pthis->work[MO_TENT_ACTION_STATE] != MO_TENT_SHAKE)) { + BossMo* otherTent = (BossMo*)pthis->otherTent; - if (!HAS_LINK(otherTent) && (this->cutIndex == 0)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->tentCollider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->tentCollider.base); + if (!HAS_LINK(otherTent) && (pthis->cutIndex == 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->tentCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->tentCollider.base); } } - if (this->cutIndex == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->tentCollider.base); + if (pthis->cutIndex == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->tentCollider.base); } } - this->work[MO_TENT_BASE_TEX1_X]++; - this->work[MO_TENT_BASE_TEX1_Y]++; - this->work[MO_TENT_BASE_TEX2_X] -= 3; - this->work[MO_TENT_BASE_TEX2_Y]++; - Math_ApproachZeroF(&this->waterLevelMod, 0.1f, 0.2f); + pthis->work[MO_TENT_BASE_TEX1_X]++; + pthis->work[MO_TENT_BASE_TEX1_Y]++; + pthis->work[MO_TENT_BASE_TEX2_X] -= 3; + pthis->work[MO_TENT_BASE_TEX2_Y]++; + Math_ApproachZeroF(&pthis->waterLevelMod, 0.1f, 0.2f); } -void BossMo_UpdateTentColliders(BossMo* this, s32 item, ColliderJntSph* tentCollider, Vec3f* center) { +void BossMo_UpdateTentColliders(BossMo* pthis, s32 item, ColliderJntSph* tentCollider, Vec3f* center) { tentCollider->elements[item].dim.worldSphere.center.x = center->x; tentCollider->elements[item].dim.worldSphere.center.y = center->y; tentCollider->elements[item].dim.worldSphere.center.z = center->z; - if (this->work[MO_TENT_ACTION_STATE] <= MO_TENT_SHAKE) { + if (pthis->work[MO_TENT_ACTION_STATE] <= MO_TENT_SHAKE) { tentCollider->elements[item].dim.worldSphere.radius = tentCollider->elements[item].dim.modelSphere.radius * tentCollider->elements[item].dim.scale; } else { @@ -2449,12 +2449,12 @@ static Gfx* sTentDLists[41] = { gMorphaTentaclePart40DL, }; -void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { +void BossMo_DrawTentacle(BossMo* pthis, GlobalContext* globalCtx) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s16 i; s16 notCut; s16 index; - Mtx* matrix = Graph_Alloc(globalCtx->state.gfxCtx, 41 * sizeof(Mtx)); + Mtx* matrix = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, 41 * sizeof(Mtx)); f32 phi_f20; f32 phi_f22; Vec3f sp110; @@ -2471,9 +2471,9 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x0C, matrix); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateX((this->actor.shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateX((pthis->actor.shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); BossMo_InitRand(1, 29100, 9786); @@ -2487,25 +2487,25 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { notCut = true; } else { if (i >= 3) { - Matrix_Translate(0.0f, this->tentStretch[i - 2].y, 0.0f, MTXMODE_APPLY); - Matrix_RotateX((this->tentRot[i - 2].x / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateZ((this->tentRot[i - 2].z / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_Translate(0.0f, pthis->tentStretch[i - 2].y, 0.0f, MTXMODE_APPLY); + Matrix_RotateX((pthis->tentRot[i - 2].x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateZ((pthis->tentRot[i - 2].z / (f32)0x8000) * M_PI, MTXMODE_APPLY); } Matrix_Push(); - Matrix_Scale((this->tentScale[i - 2].x + this->tentRipple[i - 2].x) * this->actor.scale.x, - (this->tentScale[i - 2].y + this->tentRipple[i - 2].y) * this->actor.scale.y, - (this->tentScale[i - 2].z + this->tentRipple[i - 2].z) * this->actor.scale.z, MTXMODE_APPLY); + Matrix_Scale((pthis->tentScale[i - 2].x + pthis->tentRipple[i - 2].x) * pthis->actor.scale.x, + (pthis->tentScale[i - 2].y + pthis->tentRipple[i - 2].y) * pthis->actor.scale.y, + (pthis->tentScale[i - 2].z + pthis->tentRipple[i - 2].z) * pthis->actor.scale.z, MTXMODE_APPLY); notCut = true; - if ((i >= this->cutIndex) && (this->meltIndex >= i)) { - Matrix_Scale(this->cutScale, this->cutScale, this->cutScale, MTXMODE_APPLY); + if ((i >= pthis->cutIndex) && (pthis->meltIndex >= i)) { + Matrix_Scale(pthis->cutScale, pthis->cutScale, pthis->cutScale, MTXMODE_APPLY); notCut = false; } } - index = ((this->widthIndex - (i * 2)) + 300) % 300; - if (this->work[MO_TENT_ACTION_STATE] < MO_TENT_DEATH_START) { - Matrix_RotateY((((this->tentWidth[index] - 1.0f - this->tentPulse) * 1000) / 1000.0f) * - this->fwork[MO_TENT_MAX_STRETCH], + index = ((pthis->widthIndex - (i * 2)) + 300) % 300; + if (pthis->work[MO_TENT_ACTION_STATE] < MO_TENT_DEATH_START) { + Matrix_RotateY((((pthis->tentWidth[index] - 1.0f - pthis->tentPulse) * 1000) / 1000.0f) * + pthis->fwork[MO_TENT_MAX_STRETCH], MTXMODE_APPLY); } Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); @@ -2514,7 +2514,7 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (i == 0) { - func_8002EB44(&this->tentPos[i], &globalCtx->view.eye, &sp110, globalCtx->state.gfxCtx); + func_8002EB44(&pthis->tentPos[i], &globalCtx->view.eye, &sp110, globalCtx->state.gfxCtx); } if (i == 0) { @@ -2525,20 +2525,20 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { Matrix_Pop(); - if ((i >= 2) && notCut && (i < (this->noBubbles + 38))) { - if ((this->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_1) || - (this->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_2)) { - phi_f20 = this->work[MO_TENT_MOVE_TIMER] & 3; + if ((i >= 2) && notCut && (i < (pthis->noBubbles + 38))) { + if ((pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_1) || + (pthis->work[MO_TENT_ACTION_STATE] == MO_TENT_DEATH_2)) { + phi_f20 = pthis->work[MO_TENT_MOVE_TIMER] & 3; phi_f20 *= -15.0f; - phi_f22 = ((0.18f + BossMo_RandZeroOne() * 0.1f) * this->actor.scale.x) * 100.0f; + phi_f22 = ((0.18f + BossMo_RandZeroOne() * 0.1f) * pthis->actor.scale.x) * 100.0f; } else { phi_f20 = 0.0f; - phi_f22 = (((BossMo_RandZeroOne() * (0.08f)) + .08f) * this->actor.scale.x) * 100.0f; + phi_f22 = (((BossMo_RandZeroOne() * (0.08f)) + .08f) * pthis->actor.scale.x) * 100.0f; } Matrix_Push(); - Matrix_Translate(((BossMo_RandZeroOne() - 0.5f) * 10.0f) * this->tentScale[i - 2].x, + Matrix_Translate(((BossMo_RandZeroOne() - 0.5f) * 10.0f) * pthis->tentScale[i - 2].x, ((BossMo_RandZeroOne() - 0.5f) * 3.0f) + phi_f20, - ((BossMo_RandZeroOne() - 0.5f) * 10.0f) * this->tentScale[i - 2].z, MTXMODE_APPLY); + ((BossMo_RandZeroOne() - 0.5f) * 10.0f) * pthis->tentScale[i - 2].z, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); Matrix_Scale(phi_f22, phi_f22, 1.0f, MTXMODE_APPLY); @@ -2550,9 +2550,9 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { Matrix_Pop(); } - Matrix_MultVec3f(&zeroVec, &this->tentPos[i]); + Matrix_MultVec3f(&zeroVec, &pthis->tentPos[i]); if (i == 36) { - Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &pthis->actor.focus.pos); } if (i == 24) { MtxF sp98; @@ -2560,20 +2560,20 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { Vec3s sp84; Matrix_Push(); - if (this->linkToLeft) { + if (pthis->linkToLeft) { sp8C.x *= -1.0f; } - Matrix_MultVec3f(&sp8C, &this->grabPosRot.pos); + Matrix_MultVec3f(&sp8C, &pthis->grabPosRot.pos); Matrix_RotateX(-35 * M_PI / 64, MTXMODE_APPLY); Matrix_Get(&sp98); Matrix_MtxFToYXZRotS(&sp98, &sp84, 0); - this->grabPosRot.rot.x = sp84.x; - this->grabPosRot.rot.y = sp84.y; - this->grabPosRot.rot.z = sp84.z; + pthis->grabPosRot.rot.x = sp84.x; + pthis->grabPosRot.rot.y = sp84.y; + pthis->grabPosRot.rot.z = sp84.z; Matrix_Pop(); } if ((i < 38) && ((i & 1) == 1)) { - BossMo_UpdateTentColliders(this, i / 2, &this->tentCollider, &this->tentPos[i]); + BossMo_UpdateTentColliders(pthis, i / 2, &pthis->tentCollider, &pthis->tentPos[i]); } } @@ -2581,7 +2581,7 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6571); } -void BossMo_DrawWater(BossMo* this, GlobalContext* globalCtx) { +void BossMo_DrawWater(BossMo* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6582); @@ -2592,8 +2592,8 @@ void BossMo_DrawWater(BossMo* this, GlobalContext* globalCtx) { Matrix_Translate(0.0f, MO_WATER_LEVEL(globalCtx), 0.0f, MTXMODE_NEW); gSPSegment(POLY_XLU_DISP++, 0x0D, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)this->waterTex1x, (s16)this->waterTex1y, 32, 32, 1, - (s16)this->waterTex2x, (s16)this->waterTex2y, 32, 32)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)pthis->waterTex1x, (s16)pthis->waterTex1y, 32, 32, 1, + (s16)pthis->waterTex2x, (s16)pthis->waterTex2y, 32, 32)); gDPPipeSync(POLY_XLU_DISP++); @@ -2613,13 +2613,13 @@ void BossMo_DrawWater(BossMo* this, GlobalContext* globalCtx) { void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BossMo* this = (BossMo*)thisx; + BossMo* pthis = (BossMo*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6688); - if (this->actor.world.pos.y > MO_WATER_LEVEL(globalCtx)) { - BossMo_DrawWater(this, globalCtx); + if (pthis->actor.world.pos.y > MO_WATER_LEVEL(globalCtx)) { + BossMo_DrawWater(pthis, globalCtx); } - if (this->drawActor) { + if (pthis->drawActor) { func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -2631,33 +2631,33 @@ void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sMorphaTent1->work[MO_TENT_VAR_TIMER] * 5, 0, 32, 32, 1, 0, sMorphaTent1->work[MO_TENT_VAR_TIMER] * -10, 32, 32)); - Matrix_RotateX(this->work[MO_TENT_MOVE_TIMER] * 0.5f, MTXMODE_APPLY); - Matrix_RotateZ(this->work[MO_TENT_MOVE_TIMER] * 0.8f, MTXMODE_APPLY); + Matrix_RotateX(pthis->work[MO_TENT_MOVE_TIMER] * 0.5f, MTXMODE_APPLY); + Matrix_RotateZ(pthis->work[MO_TENT_MOVE_TIMER] * 0.8f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6735), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, (s8)this->baseAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, (s8)pthis->baseAlpha); - func_8002ED80(&this->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gMorphaCoreMembraneDL)); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 220, 255, 128); - if ((this->work[MO_CORE_DMG_FLASH_TIMER] % 2) != 0) { + if ((pthis->work[MO_CORE_DMG_FLASH_TIMER] % 2) != 0) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 60, 0, 255); } else { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); } gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gMorphaCoreNucleusDL)); - if ((this->work[MO_CORE_DRAW_SHADOW] && (this->actor.world.pos.y >= 0.0f)) || - (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx))) { + if ((pthis->work[MO_CORE_DRAW_SHADOW] && (pthis->actor.world.pos.y >= 0.0f)) || + (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx))) { f32 groundLevel; s16 shadowAlpha; - if (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { + if (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { groundLevel = -280.0f; shadowAlpha = 100; } else { @@ -2669,7 +2669,7 @@ void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, shadowAlpha); - Matrix_Translate(this->actor.world.pos.x, groundLevel, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->actor.world.pos.x, groundLevel, pthis->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(0.23f, 1.0f, 0.23f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6820), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2678,11 +2678,11 @@ void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { } } - if (this->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { - BossMo_DrawWater(this, globalCtx); + if (pthis->actor.world.pos.y < MO_WATER_LEVEL(globalCtx)) { + BossMo_DrawWater(pthis, globalCtx); } - if ((this->csCamera != 0) && (this->csState < MO_INTRO_REVEAL)) { + if ((pthis->csCamera != 0) && (pthis->csState < MO_INTRO_REVEAL)) { f32 sp8C; f32 sp88; f32 sp84; @@ -2694,17 +2694,17 @@ void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (s8)this->fwork[MO_CORE_INTRO_WATER_ALPHA]); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (s8)this->fwork[MO_CORE_INTRO_WATER_ALPHA]); + gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (s8)pthis->fwork[MO_CORE_INTRO_WATER_ALPHA]); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (s8)pthis->fwork[MO_CORE_INTRO_WATER_ALPHA]); gSPSegment(POLY_XLU_DISP++, 0x0D, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)sMorphaTent1->waterTex1x, (s16)sMorphaTent1->waterTex1y, 32, 32, 1, (s16)sMorphaTent1->waterTex2x, (s16)sMorphaTent1->waterTex2y, 32, 32)); - sp8C = this->cameraAt.x - this->cameraEye.x; - sp88 = this->cameraAt.y - this->cameraEye.y; - sp84 = this->cameraAt.z - this->cameraEye.z; + sp8C = pthis->cameraAt.x - pthis->cameraEye.x; + sp88 = pthis->cameraAt.y - pthis->cameraEye.y; + sp84 = pthis->cameraAt.z - pthis->cameraEye.z; temp = SQ(sp8C) + SQ(sp84); sp7C = Math_FAtan2F(sp8C, sp84); sp78 = -Math_FAtan2F(sp88, sqrtf(temp)); @@ -2716,16 +2716,16 @@ void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateY(sp7C, MTXMODE_NEW); Matrix_RotateX(sp78, MTXMODE_APPLY); Matrix_MultVec3f(&sp6C, &sp60); - sp8C = sp60.x + this->cameraEye.x; - sp88 = sp60.y + this->cameraEye.y; - sp84 = sp60.z + this->cameraEye.z; + sp8C = sp60.x + pthis->cameraEye.x; + sp88 = sp60.y + pthis->cameraEye.y; + sp84 = sp60.z + pthis->cameraEye.z; Matrix_Translate(sp8C, sp88, sp84, MTXMODE_NEW); Matrix_RotateY(sp7C, MTXMODE_APPLY); Matrix_RotateX(sp78, MTXMODE_APPLY); - Matrix_RotateZ(-(0.01f * this->work[MO_TENT_VAR_TIMER]), MTXMODE_APPLY); - Matrix_RotateZ(0.1f * this->work[MO_TENT_VAR_TIMER], MTXMODE_APPLY); + Matrix_RotateZ(-(0.01f * pthis->work[MO_TENT_VAR_TIMER]), MTXMODE_APPLY); + Matrix_RotateZ(0.1f * pthis->work[MO_TENT_VAR_TIMER], MTXMODE_APPLY); Matrix_Scale(0.825f, 1.175f, 0.825f, MTXMODE_APPLY); - Matrix_RotateZ(-(this->work[MO_TENT_VAR_TIMER] * 0.1f), MTXMODE_APPLY); + Matrix_RotateZ(-(pthis->work[MO_TENT_VAR_TIMER] * 0.1f), MTXMODE_APPLY); Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); Matrix_Scale(0.05f, 1.0f, 0.05f, MTXMODE_APPLY); @@ -2736,38 +2736,38 @@ void BossMo_DrawCore(Actor* thisx, GlobalContext* globalCtx) { } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6945); - BossMo_DrawEffects(globalCtx->specialEffects, globalCtx); + BossMo_DrawEffects((BossMoEffect*)globalCtx->specialEffects, globalCtx); } void BossMo_DrawTent(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - BossMo* this = (BossMo*)thisx; + BossMo* pthis = (BossMo*)thisx; u16 scroll; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_mo.c", 6958); if (1) {} func_80093D18(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, (s8)(this->baseAlpha * 1.5f)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, (s8)(pthis->baseAlpha * 1.5f)); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->work[MO_TENT_BASE_TEX1_X], - this->work[MO_TENT_BASE_TEX1_Y], 32, 32, 1, this->work[MO_TENT_BASE_TEX2_X], - this->work[MO_TENT_BASE_TEX2_Y], 32, 32)); - gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (s8)((this->baseAlpha * 12.0f) / 10.0f)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (s8)this->baseAlpha); - scroll = (s16)(Math_SinS(this->work[MO_TENT_VAR_TIMER] * 0xB00) * 30.0f) + 350; + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->work[MO_TENT_BASE_TEX1_X], + pthis->work[MO_TENT_BASE_TEX1_Y], 32, 32, 1, pthis->work[MO_TENT_BASE_TEX2_X], + pthis->work[MO_TENT_BASE_TEX2_Y], 32, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (s8)((pthis->baseAlpha * 12.0f) / 10.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (s8)pthis->baseAlpha); + scroll = (s16)(Math_SinS(pthis->work[MO_TENT_VAR_TIMER] * 0xB00) * 30.0f) + 350; gSPTexture(POLY_XLU_DISP++, scroll, scroll, 0, G_TX_RENDERTILE, G_ON); - if (this->drawActor) { - BossMo_DrawTentacle(this, globalCtx); + if (pthis->drawActor) { + BossMo_DrawTentacle(pthis, globalCtx); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_mo.c", 7023); } -void BossMo_UpdateEffects(BossMo* this, GlobalContext* globalCtx) { - BossMoEffect* effect = globalCtx->specialEffects; +void BossMo_UpdateEffects(BossMo* pthis, GlobalContext* globalCtx) { + BossMoEffect* effect = (BossMoEffect*)globalCtx->specialEffects; s16 i; Vec3f* targetPos; f32 dx; @@ -2789,7 +2789,7 @@ void BossMo_UpdateEffects(BossMo* this, GlobalContext* globalCtx) { effect->stopTimer--; } if (effect->type <= MO_FX_BIG_RIPPLE) { - if (this->csState >= MO_DEATH_START) { + if (pthis->csState >= MO_DEATH_START) { effect->pos.y = MO_WATER_LEVEL(globalCtx); } Math_ApproachF(&effect->scale, effect->fwork[MO_FX_MAX_SIZE], 0.2f, effect->fwork[MO_FX_SPREAD_RATE]); @@ -2904,10 +2904,10 @@ void BossMo_UpdateEffects(BossMo* this, GlobalContext* globalCtx) { pos.y = MO_WATER_LEVEL(globalCtx); if (effect->type == MO_FX_SPLASH) { - BossMo_SpawnRipple(globalCtx->specialEffects, &pos, 60.0f, 160.0f, 80, 290, + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &pos, 60.0f, 160.0f, 80, 290, MO_FX_SMALL_RIPPLE); } else { - BossMo_SpawnRipple(globalCtx->specialEffects, &pos, 40.0f, 110.0f, 80, 290, + BossMo_SpawnRipple((BossMoEffect*)globalCtx->specialEffects, &pos, 40.0f, 110.0f, 80, 290, MO_FX_SMALL_RIPPLE); } effect->type = MO_FX_NONE; diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo_colchk.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo_colchk.cpp similarity index 100% rename from src/overlays/actors/ovl_Boss_Mo/z_boss_mo_colchk.c rename to src/overlays/actors/ovl_Boss_Mo/z_boss_mo_colchk.cpp diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c deleted file mode 100644 index 377f2557b..000000000 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ /dev/null @@ -1,3244 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_SST_Z_BOSS_SST_C -#include "actor_common.h" -/* - * File: z_boss_sst.c - * Overlay: ovl_Boss_Sst - * Description: Bongo Bongo - */ - -#include "z_boss_sst.h" -#include "objects/object_sst/object_sst.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin_matrix.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_10) - -#define vParity actionVar -#define vVanish actionVar - -#define LEFT 0 -#define RIGHT 1 -#define OTHER_HAND(hand) ((BossSst*)hand->actor.child) -#define HAND_STATE(hand) sHandState[hand->actor.params] - -#define ROOM_CENTER_X -50.0f -#define ROOM_CENTER_Y 0.0f -#define ROOM_CENTER_Z 0.0f - -typedef enum { - /* 0 */ HAND_WAIT, - /* 1 */ HAND_BEAT, - /* 2 */ HAND_RETREAT, - /* 3 */ HAND_SLAM, - /* 4 */ HAND_SWEEP, - /* 5 */ HAND_PUNCH, - /* 6 */ HAND_CLAP, - /* 7 */ HAND_GRAB, - /* 8 */ HAND_DAMAGED, - /* 9 */ HAND_FROZEN, - /* 10 */ HAND_BREAK_ICE, - /* 11 */ HAND_DEATH -} BossSstHandState; - -typedef enum { - /* 0 */ BONGO_NULL, - /* 1 */ BONGO_ICE, - /* 2 */ BONGO_SHOCKWAVE, - /* 3 */ BONGO_SHADOW -} BossSstEffectMode; - -void BossSst_Init(Actor* thisx, GlobalContext* globalCtx); -void BossSst_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossSst_UpdateHand(Actor* thisx, GlobalContext* globalCtx); -void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx); -void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx); -void BossSst_DrawHead(Actor* thisx, GlobalContext* globalCtx); -void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx); -void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx); - -void BossSst_HeadSfx(BossSst* this, u16 sfxId); - -void BossSst_HeadSetupLurk(BossSst* this); -void BossSst_HeadLurk(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupIntro(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadIntro(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupNeutral(BossSst* this); -void BossSst_HeadNeutral(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadWait(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HeadSetupDamagedHand(BossSst* this, s32 bothHands); -void BossSst_HeadDamagedHand(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupReadyCharge(BossSst* this); -void BossSst_HeadReadyCharge(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupCharge(BossSst* this); -void BossSst_HeadCharge(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupEndCharge(BossSst* this); -void BossSst_HeadEndCharge(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HeadSetupFrozenHand(BossSst* this); -void BossSst_HeadFrozenHand(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupUnfreezeHand(BossSst* this); -void BossSst_HeadUnfreezeHand(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HeadStunned(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupVulnerable(BossSst* this); -void BossSst_HeadVulnerable(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadDamage(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupRecover(BossSst* this); -void BossSst_HeadRecover(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HeadDeath(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupThrash(BossSst* this); -void BossSst_HeadThrash(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupDarken(BossSst* this); -void BossSst_HeadDarken(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupFall(BossSst* this); -void BossSst_HeadFall(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupMelt(BossSst* this); -void BossSst_HeadMelt(BossSst* this, GlobalContext* globalCtx); -void BossSst_HeadSetupFinish(BossSst* this); -void BossSst_HeadFinish(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandGrabPlayer(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandReleasePlayer(BossSst* this, GlobalContext* globalCtx, s32 dropPlayer); -void BossSst_HandSelectAttack(BossSst* this); -void BossSst_HandSetDamage(BossSst* this, s32 damage); -void BossSst_HandSetInvulnerable(BossSst* this, s32 isInv); - -void BossSst_HandSetupWait(BossSst* this); -void BossSst_HandWait(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupDownbeat(BossSst* this); -void BossSst_HandDownbeat(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupOffbeat(BossSst* this); -void BossSst_HandOffbeat(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupDownbeatEnd(BossSst* this); -void BossSst_HandDownbeatEnd(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupOffbeatEnd(BossSst* this); -void BossSst_HandOffbeatEnd(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandReadySlam(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupSlam(BossSst* this); -void BossSst_HandSlam(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandEndSlam(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandReadySweep(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupSweep(BossSst* this); -void BossSst_HandSweep(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandReadyPunch(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupPunch(BossSst* this); -void BossSst_HandPunch(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandReadyClap(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupClap(BossSst* this); -void BossSst_HandClap(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupEndClap(BossSst* this); -void BossSst_HandEndClap(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandReadyGrab(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupGrab(BossSst* this); -void BossSst_HandGrab(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupCrush(BossSst* this); -void BossSst_HandCrush(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupEndCrush(BossSst* this); -void BossSst_HandEndCrush(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupSwing(BossSst* this); -void BossSst_HandSwing(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandSetupRetreat(BossSst* this); -void BossSst_HandRetreat(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandSetupReel(BossSst* this); -void BossSst_HandReel(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupReadyShake(BossSst* this); -void BossSst_HandReadyShake(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupShake(BossSst* this); -void BossSst_HandShake(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupReadyCharge(BossSst* this); -void BossSst_HandReadyCharge(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandSetupFrozen(BossSst* this); -void BossSst_HandFrozen(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupReadyBreakIce(BossSst* this); -void BossSst_HandReadyBreakIce(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupBreakIce(BossSst* this); -void BossSst_HandBreakIce(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandStunned(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandDamage(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupRecover(BossSst* this); -void BossSst_HandRecover(BossSst* this, GlobalContext* globalCtx); - -void BossSst_HandSetupThrash(BossSst* this); -void BossSst_HandThrash(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupDarken(BossSst* this); -void BossSst_HandDarken(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupFall(BossSst* this); -void BossSst_HandFall(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupMelt(BossSst* this); -void BossSst_HandMelt(BossSst* this, GlobalContext* globalCtx); -void BossSst_HandSetupFinish(BossSst* this); -void BossSst_HandFinish(BossSst* this, GlobalContext* globalCtx); - -void BossSst_SpawnHeadShadow(BossSst* this); -void BossSst_SpawnHandShadow(BossSst* this); -void BossSst_SpawnShockwave(BossSst* this); -void BossSst_SpawnIceCrystal(BossSst* this, s32 index); -void BossSst_SpawnIceShard(BossSst* this); -void BossSst_IceShatter(BossSst* this); - -#include "overlays/ovl_Boss_Sst/ovl_Boss_Sst.c" - -static BossSst* sHead; -static BossSst* sHands[2]; -static BgSstFloor* sFloor; - -static Vec3f sRoomCenter = { ROOM_CENTER_X, ROOM_CENTER_Y, ROOM_CENTER_Z }; -static Vec3f sHandOffsets[2]; -static s16 sHandYawOffsets[2]; - -static s16 sCutsceneCamera; -static Vec3f sCameraAt = { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 0.0f, ROOM_CENTER_Z + 0.0f }; -static Vec3f sCameraEye = { ROOM_CENTER_X + 150.0f, ROOM_CENTER_Y + 100.0f, ROOM_CENTER_Z + 0.0f }; -static Vec3f sCameraAtVel = { 0.0f, 0.0f, 0.0f }; -static Vec3f sCameraEyeVel = { 0.0f, 0.0f, 0.0f }; - -static Vec3f sCameraAtPoints[] = { - { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 300.0f, ROOM_CENTER_Z + 0.0f }, - { ROOM_CENTER_X + 150.0f, ROOM_CENTER_Y + 300.0f, ROOM_CENTER_Z + 100.0f }, - { ROOM_CENTER_X + 0.0f, ROOM_CENTER_Y + 600.0f, ROOM_CENTER_Z + 100.0f }, - { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 400.0f, ROOM_CENTER_Z + 200.0f }, - { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 200.0f }, - { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 0.0f, ROOM_CENTER_Z + 200.0f }, - { ROOM_CENTER_X - 150.0f, ROOM_CENTER_Y + 0.0f, ROOM_CENTER_Z + 100.0f }, - { ROOM_CENTER_X - 60.0f, ROOM_CENTER_Y + 180.0f, ROOM_CENTER_Z + 730.0f }, -}; - -static Vec3f sCameraEyePoints[] = { - { ROOM_CENTER_X + 250.0f, ROOM_CENTER_Y + 800.0f, ROOM_CENTER_Z + 800.0f }, - { ROOM_CENTER_X - 150.0f, ROOM_CENTER_Y + 700.0f, ROOM_CENTER_Z + 1400.0f }, - { ROOM_CENTER_X + 250.0f, ROOM_CENTER_Y + 100.0f, ROOM_CENTER_Z + 750.0f }, - { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 900.0f }, - { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 900.0f }, - { ROOM_CENTER_X + 350.0f, ROOM_CENTER_Y + 400.0f, ROOM_CENTER_Z + 1200.0f }, - { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 800.0f }, - { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 800.0f }, -}; - -static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static u32 sBodyStatic = false; - -// Unreferenced. Maybe two zero vectors? -static u32 sUnkValues[] = { 0, 0, 0, 0, 0, 0 }; - -static Color_RGBA8 sBodyColor = { 255, 255, 255, 255 }; -static Color_RGBA8 sStaticColor = { 0, 0, 0, 255 }; -static s32 sHandState[] = { HAND_WAIT, HAND_WAIT }; - -const ActorInit Boss_Sst_InitVars = { - ACTOR_BOSS_SST, - ACTORCAT_BOSS, - FLAGS, - OBJECT_SST, - sizeof(BossSst), - (ActorFunc)BossSst_Init, - (ActorFunc)BossSst_Destroy, - (ActorFunc)BossSst_UpdateHand, - (ActorFunc)BossSst_DrawHand, -}; - -#include "z_boss_sst_colchk.c" - -static AnimationHeader* sHandIdleAnims[] = { &gBongoLeftHandIdleAnim, &gBongoRightHandIdleAnim }; -static AnimationHeader* sHandFlatPoses[] = { &gBongoLeftHandFlatPoseAnim, &gBongoRightHandFlatPoseAnim }; -static AnimationHeader* sHandOpenPoses[] = { &gBongoLeftHandOpenPoseAnim, &gBongoRightHandOpenPoseAnim }; -static AnimationHeader* sHandFistPoses[] = { &gBongoLeftHandFistPoseAnim, &gBongoRightHandFistPoseAnim }; -static AnimationHeader* sHandClenchAnims[] = { &gBongoLeftHandClenchAnim, &gBongoRightHandClenchAnim }; -static AnimationHeader* sHandDamagePoses[] = { &gBongoLeftHandDamagePoseAnim, &gBongoRightHandDamagePoseAnim }; -static AnimationHeader* sHandPushoffPoses[] = { &gBongoLeftHandPushoffPoseAnim, &gBongoRightHandPushoffPoseAnim }; -static AnimationHeader* sHandHangPoses[] = { &gBongoLeftHandHangPoseAnim, &gBongoRightHandHangPoseAnim }; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x29, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), -}; - -void BossSst_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - BossSst* this = (BossSst*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->colliderCyl); - Collider_InitJntSph(globalCtx, &this->colliderJntSph); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Flags_SetSwitch(globalCtx, 0x14); - if (this->actor.params == BONGO_HEAD) { - sFloor = (BgSstFloor*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_SST_FLOOR, sRoomCenter.x, - sRoomCenter.y, sRoomCenter.z, 0, 0, 0, BONGOFLOOR_REST); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBongoHeadSkel, &gBongoHeadEyeOpenIdleAnim, this->jointTable, - this->morphTable, 45); - ActorShape_Init(&this->actor.shape, 70000.0f, ActorShadow_DrawCircle, 95.0f); - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInitHead, this->colliderItems); - Collider_SetCylinder(globalCtx, &this->colliderCyl, &this->actor, &sCylinderInitHead); - sHead = this; - this->actor.world.pos.x = ROOM_CENTER_X + 50.0f; - this->actor.world.pos.y = ROOM_CENTER_Y + 0.0f; - this->actor.world.pos.z = ROOM_CENTER_Z - 650.0f; - this->actor.home.pos = this->actor.world.pos; - this->actor.shape.rot.y = 0; - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, ROOM_CENTER_X, ROOM_CENTER_Y, - ROOM_CENTER_Z + 400.0f, 0, 0, 0, WARP_DUNGEON_ADULT); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, ROOM_CENTER_X, ROOM_CENTER_Y, - ROOM_CENTER_Z - 200.0f, 0, 0, 0, 0); - Actor_Kill(&this->actor); - } else { - sHands[LEFT] = - (BossSst*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_SST, this->actor.world.pos.x + 200.0f, - this->actor.world.pos.y, this->actor.world.pos.z + 400.0f, 0, - this->actor.shape.rot.y, 0, BONGO_LEFT_HAND); - sHands[RIGHT] = (BossSst*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_SST, - this->actor.world.pos.x + (-200.0f), this->actor.world.pos.y, - this->actor.world.pos.z + 400.0f, 0, this->actor.shape.rot.y, 0, - BONGO_RIGHT_HAND); - sHands[LEFT]->actor.child = &sHands[RIGHT]->actor; - sHands[RIGHT]->actor.child = &sHands[LEFT]->actor; - - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.update = BossSst_UpdateHead; - this->actor.draw = BossSst_DrawHead; - this->radius = -650.0f; - this->actor.targetArrowOffset = 4000.0f; - BossSst_HeadSetupLurk(this); - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_BOSS); - } - } else { - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInitHand, this->colliderItems); - Collider_SetCylinder(globalCtx, &this->colliderCyl, &this->actor, &sCylinderInitHand); - if (this->actor.params == BONGO_LEFT_HAND) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBongoLeftHandSkel, &gBongoLeftHandIdleAnim, - this->jointTable, this->morphTable, 27); - this->vParity = -1; - this->colliderJntSph.elements[0].dim.modelSphere.center.z *= -1; - } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBongoRightHandSkel, &gBongoRightHandIdleAnim, - this->jointTable, this->morphTable, 27); - this->vParity = 1; - } - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 95.0f); - this->handZPosMod = -3500; - this->actor.targetArrowOffset = 5000.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - BossSst_HandSetupWait(this); - } -} - -void BossSst_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossSst* this = (BossSst*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); - Collider_DestroyCylinder(globalCtx, &this->colliderCyl); - Audio_StopSfxByPos(&this->center); -} - -void BossSst_HeadSetupLurk(BossSst* this) { - this->actor.draw = NULL; - sHands[LEFT]->actor.draw = NULL; - sHands[RIGHT]->actor.draw = NULL; - this->vVanish = false; - this->actionFunc = BossSst_HeadLurk; -} - -void BossSst_HeadLurk(BossSst* this, GlobalContext* globalCtx) { - if (this->actor.yDistToPlayer < 1000.0f) { - BossSst_HeadSetupIntro(this, globalCtx); - } -} - -void BossSst_HeadSetupIntro(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->timer = 611; - this->ready = false; - player->actor.world.pos.x = sRoomCenter.x; - player->actor.world.pos.y = ROOM_CENTER_Y + 1000.0f; - player->actor.world.pos.z = sRoomCenter.z; - player->linearVelocity = player->actor.velocity.y = 0.0f; - player->actor.shape.rot.y = -0x8000; - player->targetYaw = -0x8000; - player->currentYaw = -0x8000; - player->fallStartHeight = 0; - player->stateFlags1 |= 0x20; - - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - sCutsceneCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_ACTIVE); - Math_Vec3f_Copy(&sCameraAt, &player->actor.world.pos); - if (gSaveContext.eventChkInf[7] & 0x80) { - sCameraEye.z = ROOM_CENTER_Z - 100.0f; - } - - Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &sCameraAt, &sCameraEye); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - this->actionFunc = BossSst_HeadIntro; -} - -void BossSst_HeadIntro(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 tempo; - s32 introStateTimer; - s32 revealStateTimer; - - if (this->timer != 0) { - this->timer--; - } - - if (SkelAnime_Update(&this->skelAnime)) { - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadEyeCloseIdleAnim, -3.0f); - } - - if (this->timer == 0) { - sHands[RIGHT]->actor.flags |= ACTOR_FLAG_0; - sHands[LEFT]->actor.flags |= ACTOR_FLAG_0; - player->stateFlags1 &= ~0x20; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - sCameraAt.y += 30.0f; - sCameraAt.z += 300.0f; - Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &sCameraAt, &sCameraEye); - Gameplay_CopyCamera(globalCtx, MAIN_CAM, sCutsceneCamera); - Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, sCutsceneCamera); - gSaveContext.eventChkInf[7] |= 0x80; - BossSst_HeadSetupNeutral(this); - this->colliderJntSph.base.ocFlags1 |= OC1_ON; - sHands[LEFT]->colliderJntSph.base.ocFlags1 |= OC1_ON; - sHands[RIGHT]->colliderJntSph.base.ocFlags1 |= OC1_ON; - this->timer = 112; - } else if (this->timer >= 546) { - if (player->actor.world.pos.y > 100.0f) { - player->actor.world.pos.x = sRoomCenter.x; - player->actor.world.pos.z = sRoomCenter.z; - player->linearVelocity = 0; - player->actor.shape.rot.y = -0x8000; - player->targetYaw = -0x8000; - player->currentYaw = -0x8000; - } - - Math_Vec3f_Copy(&sCameraAt, &player->actor.world.pos); - if (player->actor.bgCheckFlags & 2) { - if (!this->ready) { - sFloor->dyna.actor.params = BONGOFLOOR_HIT; - this->ready = true; - func_800AA000(this->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); - Audio_PlayActorSound2(&sFloor->dyna.actor, NA_SE_EN_SHADEST_TAIKO_HIGH); - } else if (gSaveContext.eventChkInf[7] & 0x80) { - sHands[RIGHT]->actor.draw = BossSst_DrawHand; - sHands[LEFT]->actor.draw = BossSst_DrawHand; - this->actor.draw = BossSst_DrawHead; - this->timer = 178; - sCameraAt.x = ROOM_CENTER_X - 23.0f; - sCameraAt.y = ROOM_CENTER_Y + 0.0f; - sCameraAt.z = ROOM_CENTER_Z + 0.0f; - } else { - this->timer = 546; - } - } - } else if (this->timer >= 478) { - sCameraEye.x += 10.0f; - sCameraEye.y += 10.0f; - sCameraEye.z -= 10.0f; - } else if (this->timer >= 448) { - if (this->timer == 460) { - sHands[RIGHT]->actor.draw = BossSst_DrawHand; - sHands[LEFT]->actor.draw = BossSst_DrawHand; - this->actor.draw = BossSst_DrawHead; - player->actor.world.pos.x = sRoomCenter.x; - player->actor.world.pos.z = sRoomCenter.z; - BossSst_HandSetupDownbeat(sHands[RIGHT]); - } - if (this->timer > 460) { - sCameraEye.x -= 40.0f; - sCameraEye.y -= 40.0f; - sCameraEye.z += 20.0f; - } else if (this->timer == 460) { - sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 0.0f; - sCameraAt.y = sHands[RIGHT]->actor.home.pos.y - 20.0f; - sCameraAt.z = sHands[RIGHT]->actor.home.pos.z + 10.0f; - sCameraEye.x = sHands[RIGHT]->actor.home.pos.x + 150.0f; - sCameraEye.y = sHands[RIGHT]->actor.home.pos.y + 100.0f; - sCameraEye.z = sHands[RIGHT]->actor.home.pos.z + 80.0f; - } - } else { - if (this->timer >= 372) { - introStateTimer = this->timer - 372; - tempo = 6; - if (this->timer == 447) { - sCameraAt = player->actor.world.pos; - sCameraEye.x = ROOM_CENTER_X - 200.0f; - sCameraEye.y = ROOM_CENTER_Y + 160.0f; - sCameraEye.z = ROOM_CENTER_Z - 190.0f; - } else if (introStateTimer == 11) { - sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 30.0f; - sCameraAt.y = sHands[RIGHT]->actor.home.pos.y + 0.0f; - sCameraAt.z = sHands[RIGHT]->actor.home.pos.z + 20.0f; - sCameraEye.x = sHands[RIGHT]->actor.home.pos.x + 100.0f; - sCameraEye.y = sHands[RIGHT]->actor.home.pos.y + 10.0f; - sCameraEye.z = sHands[RIGHT]->actor.home.pos.z - 210.0f; - } else if (introStateTimer == 62) { - sCameraAt.x = sHands[LEFT]->actor.home.pos.x + 0.0f; - sCameraAt.y = sHands[LEFT]->actor.home.pos.y + 50.0f; - sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 100.0f; - sCameraEye.x = sHands[LEFT]->actor.home.pos.x + 110.0f; - sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 180.0f; - sCameraEye.z = sHands[LEFT]->actor.home.pos.z - 70.0f; - } - } else if (this->timer >= 304) { - introStateTimer = this->timer - 304; - tempo = 5; - if (introStateTimer == 11) { - sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 40.0f; - sCameraAt.y = sHands[RIGHT]->actor.home.pos.y - 90.0f; - sCameraAt.z = sHands[RIGHT]->actor.home.pos.z - 40.0f; - sCameraEye.x = sHands[RIGHT]->actor.home.pos.x - 20.0f; - sCameraEye.y = sHands[RIGHT]->actor.home.pos.y + 210.0f; - sCameraEye.z = sHands[RIGHT]->actor.home.pos.z + 170.0f; - } else if (this->timer == 368) { - sCameraAt.x = sHands[LEFT]->actor.home.pos.x - 20.0f; - sCameraAt.y = sHands[LEFT]->actor.home.pos.y + 0.0f; - sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 0.0f; - sCameraEye.x = sHands[LEFT]->actor.home.pos.x - 70.0f; - sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 170.0f; - sCameraEye.z = sHands[LEFT]->actor.home.pos.z + 150.0f; - } - } else if (this->timer >= 244) { - introStateTimer = this->timer - 244; - tempo = 4; - if (introStateTimer == 11) { - sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 30.0f; - sCameraAt.y = sHands[RIGHT]->actor.home.pos.y + 70.0f; - sCameraAt.z = sHands[RIGHT]->actor.home.pos.z + 40.0f; - sCameraEye.x = sHands[RIGHT]->actor.home.pos.x + 110.0f; - sCameraEye.y = sHands[RIGHT]->actor.home.pos.y - 140.0f; - sCameraEye.z = sHands[RIGHT]->actor.home.pos.z - 10.0f; - } else if (this->timer == 300) { - sCameraAt.x = sHands[LEFT]->actor.home.pos.x - 20.0f; - sCameraAt.y = sHands[LEFT]->actor.home.pos.y - 80.0f; - sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 320.0f; - sCameraEye.x = sHands[LEFT]->actor.home.pos.x - 130.0f; - sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 130.0f; - sCameraEye.z = sHands[LEFT]->actor.home.pos.z - 150.0f; - } - } else if (this->timer >= 192) { - introStateTimer = this->timer - 192; - tempo = 3; - if (this->timer == 240) { - sCameraAt.x = sHands[LEFT]->actor.home.pos.x - 190.0f; - sCameraAt.y = sHands[LEFT]->actor.home.pos.y - 110.0f; - sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 40.0f; - sCameraEye.x = sHands[LEFT]->actor.home.pos.x + 120.0f; - sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 130.0f; - sCameraEye.z = sHands[LEFT]->actor.home.pos.z + 50.0f; - } else if (introStateTimer == 12) { - sCameraAt.x = sRoomCenter.x + 50.0f; - sCameraAt.y = sRoomCenter.y - 90.0f; - sCameraAt.z = sRoomCenter.z - 200.0f; - sCameraEye.x = sRoomCenter.x + 50.0f; - sCameraEye.y = sRoomCenter.y + 350.0f; - sCameraEye.z = sRoomCenter.z + 150.0f; - } - } else if (this->timer >= 148) { - introStateTimer = this->timer - 148; - tempo = 2; - } else if (this->timer >= 112) { - introStateTimer = this->timer - 112; - tempo = 1; - } else { - introStateTimer = this->timer % 28; - tempo = 0; - } - if (this->timer <= 198) { - revealStateTimer = 198 - this->timer; - if ((gSaveContext.eventChkInf[7] & 0x80) && (revealStateTimer <= 44)) { - sCameraAt.x += 492.0f * 0.01f; - sCameraAt.y += 200.0f * 0.01f; - sCameraEye.x -= 80.0f * 0.01f; - sCameraEye.y -= 360.0f * 0.01f; - sCameraEye.z += 1000.0f * 0.01f; - } else if (this->timer <= 20) { - sCameraAt.y -= 700.0f * 0.01f; - sCameraAt.z += 900.0f * 0.01f; - sCameraEye.x += 650.0f * 0.01f; - sCameraEye.y += 400.0f * 0.01f; - sCameraEye.z += 1550.0f * 0.01f; - this->vVanish = true; - this->actor.flags |= ACTOR_FLAG_7; - } else if (revealStateTimer < 40) { - sCameraAt.x += 125.0f * 0.01f; - sCameraAt.y += 350.0f * 0.01f; - sCameraAt.z += 500.0f * 0.01f; - sCameraEye.x += 200.0f * 0.01f; - sCameraEye.y -= 850.0f * 0.01f; - } else if (revealStateTimer >= 45) { - if (revealStateTimer < 85) { - sCameraAt.x -= 250.0f * 0.01f; - sCameraAt.y += 425.0f * 0.01f; - sCameraAt.z -= 1200.0f * 0.01f; - sCameraEye.x -= 650.0f * 0.01f; - sCameraEye.y += 125.0f * 0.01f; - sCameraEye.z -= 350.0f * 0.01f; - } else if (revealStateTimer == 85) { - if (!(gSaveContext.eventChkInf[7] & 0x80)) { - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gBongoTitleCardTex), 160, 180, 128, 40); - } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadEyeCloseAnim, -5.0f); - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_DISAPPEAR); - } - } - } - if (introStateTimer == 12) { - BossSst_HandSetupDownbeat(sHands[RIGHT]); - } - if ((introStateTimer != 5) && ((introStateTimer % ((tempo * 2) + 7)) == 5)) { - BossSst_HandSetupOffbeat(sHands[LEFT]); - } - } - - if (this->actionFunc != BossSst_HeadNeutral) { - Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &sCameraAt, &sCameraEye); - } -} - -void BossSst_HeadSetupWait(BossSst* this) { - if (this->skelAnime.animation != &gBongoHeadEyeCloseIdleAnim) { - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadEyeCloseIdleAnim, -5.0f); - } - this->actionFunc = BossSst_HeadWait; -} - -void BossSst_HeadWait(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((HAND_STATE(sHands[LEFT]) == HAND_WAIT) && (HAND_STATE(sHands[RIGHT]) == HAND_WAIT)) { - BossSst_HeadSetupNeutral(this); - } -} - -void BossSst_HeadSetupNeutral(BossSst* this) { - this->timer = 127; - this->ready = false; - this->actionFunc = BossSst_HeadNeutral; -} - -void BossSst_HeadNeutral(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (!this->ready && ((HAND_STATE(sHands[LEFT]) == HAND_BEAT) || (HAND_STATE(sHands[LEFT]) == HAND_WAIT)) && - ((HAND_STATE(sHands[RIGHT]) == HAND_BEAT) || (HAND_STATE(sHands[RIGHT]) == HAND_WAIT))) { - this->ready = true; - } - - if (this->ready) { - if (this->timer != 0) { - this->timer--; - } - } - - if (this->timer == 0) { - if ((GET_PLAYER(globalCtx)->actor.world.pos.y > -50.0f) && !(GET_PLAYER(globalCtx)->stateFlags1 & 0x6080)) { - sHands[Rand_ZeroOne() <= 0.5f]->ready = true; - BossSst_HeadSetupWait(this); - } else { - this->timer = 28; - } - } else { - Math_ApproachS(&this->actor.shape.rot.y, - Actor_WorldYawTowardPoint(&GET_PLAYER(globalCtx)->actor, &sRoomCenter) + 0x8000, 4, 0x400); - if ((this->timer == 28) || (this->timer == 84)) { - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_PRAY); - } - } -} - -void BossSst_HeadSetupDamagedHand(BossSst* this, s32 bothHands) { - if (bothHands) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadEyeOpenAnim, -5.0f); - } else { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadDamagedHandAnim, -5.0f); - } - this->actionFunc = BossSst_HeadDamagedHand; -} - -void BossSst_HeadDamagedHand(BossSst* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if ((HAND_STATE(sHands[LEFT]) == HAND_DAMAGED) && (HAND_STATE(sHands[RIGHT]) == HAND_DAMAGED)) { - BossSst_HeadSetupReadyCharge(this); - } else if ((HAND_STATE(sHands[LEFT]) == HAND_FROZEN) || (HAND_STATE(sHands[RIGHT]) == HAND_FROZEN)) { - BossSst_HeadSetupFrozenHand(this); - } else if (this->skelAnime.animation == &gBongoHeadEyeOpenAnim) { - BossSst_HeadSetupUnfreezeHand(this); - } else { - BossSst_HeadSetupWait(this); - } - } -} - -void BossSst_HeadSetupReadyCharge(BossSst* this) { - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); - this->actor.speedXZ = 0.0f; - this->colliderCyl.base.acFlags |= AC_ON; - this->actionFunc = BossSst_HeadReadyCharge; -} - -void BossSst_HeadReadyCharge(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (sHands[LEFT]->ready && (sHands[LEFT]->actionFunc == BossSst_HandReadyCharge) && sHands[RIGHT]->ready && - (sHands[RIGHT]->actionFunc == BossSst_HandReadyCharge)) { - BossSst_HeadSetupCharge(this); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x800, 0x400); - } -} - -void BossSst_HeadSetupCharge(BossSst* this) { - Animation_Change(&this->skelAnime, &gBongoHeadChargeAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gBongoHeadChargeAnim), - ANIMMODE_ONCE_INTERP, -5.0f); - BossSst_HandSetDamage(sHands[LEFT], 0x20); - BossSst_HandSetDamage(sHands[RIGHT], 0x20); - this->colliderJntSph.base.atFlags |= AT_ON; - this->actor.speedXZ = 3.0f; - this->radius = -650.0f; - this->ready = false; - this->actionFunc = BossSst_HeadCharge; -} - -void BossSst_HeadCharge(BossSst* this, GlobalContext* globalCtx) { - f32 chargeDist; - s32 animFinish = SkelAnime_Update(&this->skelAnime); - - if (!this->ready && Animation_OnFrame(&this->skelAnime, 6.0f)) { - this->ready = true; - this->actor.speedXZ = 0.25f; - this->skelAnime.playSpeed = 0.2f; - } - - this->actor.speedXZ *= 1.25f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 45.0f); - - if (this->ready) { - if (Math_SmoothStepToF(&this->radius, 650.0f, 0.4f, this->actor.speedXZ, 1.0f) < 10.0f) { - this->radius = 650.0f; - BossSst_HeadSetupEndCharge(this); - } else { - chargeDist = (650.0f - this->radius) * 3.0f; - if (chargeDist > 180.0f) { - chargeDist = 180.0f; - } - - this->actor.world.pos.y = this->actor.home.pos.y - chargeDist; - } - - if (!animFinish) { - sHandOffsets[LEFT].z += 5.0f; - sHandOffsets[RIGHT].z += 5.0f; - } - } else { - Math_ApproachF(&this->radius, -700.0f, 0.4f, this->actor.speedXZ); - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 180.0f, 20.0f); - sHandOffsets[LEFT].y += 5.0f; - sHandOffsets[RIGHT].y += 5.0f; - } - - if (this->colliderJntSph.base.atFlags & AT_HIT) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - sHands[LEFT]->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - sHands[RIGHT]->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - func_8002F71C(globalCtx, &this->actor, 10.0f, this->actor.shape.rot.y, 5.0f); - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - } -} - -void BossSst_HeadSetupEndCharge(BossSst* this) { - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadEyeCloseIdleAnim, -20.0f); - this->targetYaw = Actor_WorldYawTowardPoint(&this->actor, &sRoomCenter); - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->colliderCyl.base.acFlags &= ~AC_ON; - this->radius *= -1.0f; - this->actionFunc = BossSst_HeadEndCharge; -} - -void BossSst_HeadEndCharge(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Math_SmoothStepToS(&this->actor.shape.rot.y, this->targetYaw, 4, 0x800, 0x100) == 0) { - BossSst_HandSetupRetreat(sHands[LEFT]); - BossSst_HandSetupRetreat(sHands[RIGHT]); - BossSst_HeadSetupNeutral(this); - } -} - -void BossSst_HeadSetupFrozenHand(BossSst* this) { - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); - this->ready = false; - this->colliderCyl.base.acFlags |= AC_ON; - this->actionFunc = BossSst_HeadFrozenHand; -} - -void BossSst_HeadFrozenHand(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->ready) { - BossSst_HeadSetupUnfreezeHand(this); - } -} - -void BossSst_HeadSetupUnfreezeHand(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadEyeCloseAnim, -5.0f); - this->colliderCyl.base.acFlags &= ~AC_ON; - this->actionFunc = BossSst_HeadUnfreezeHand; -} - -void BossSst_HeadUnfreezeHand(BossSst* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - BossSst_HeadSetupWait(this); - } -} - -void BossSst_HeadSetupStunned(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadKnockoutAnim, -5.0f); - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadKnockoutAnim)); - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->colliderCyl.base.acFlags &= ~AC_ON; - this->vVanish = false; - this->actor.flags &= ~ACTOR_FLAG_7; - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_FREEZE); - this->actionFunc = BossSst_HeadStunned; -} - -void BossSst_HeadStunned(BossSst* this, GlobalContext* globalCtx) { - f32 bounce; - s32 animFinish; - f32 currentFrame; - - Math_StepToF(&sHandOffsets[LEFT].z, 600.0f, 20.0f); - Math_StepToF(&sHandOffsets[RIGHT].z, 600.0f, 20.0f); - Math_StepToF(&sHandOffsets[LEFT].x, 200.0f, 20.0f); - Math_StepToF(&sHandOffsets[RIGHT].x, -200.0f, 20.0f); - this->actor.velocity.y += this->actor.gravity; - animFinish = SkelAnime_Update(&this->skelAnime); - currentFrame = this->skelAnime.curFrame; - if (currentFrame <= 6.0f) { - bounce = (sinf((M_PI / 11) * currentFrame) * 100.0f) + (this->actor.home.pos.y - 180.0f); - if (this->actor.world.pos.y < bounce) { - this->actor.world.pos.y = bounce; - } - } else if (currentFrame <= 11.0f) { - this->actor.world.pos.y = (sinf((M_PI / 11) * currentFrame) * 170.0f) + (this->actor.home.pos.y - 250.0f); - } else { - this->actor.world.pos.y = - (sinf((currentFrame - 11.0f) * (M_PI / 5)) * 50.0f) + (this->actor.home.pos.y - 250.0f); - } - - if ((animFinish) || Animation_OnFrame(&this->skelAnime, 11.0f)) { - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_LAND); - } - - if (this->radius < -500.0f) { - Math_SmoothStepToF(&this->radius, -500.0f, 1.0f, 50.0f, 5.0f); - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.5f, 15.0f, 3.0f); - this->radius += this->actor.speedXZ; - } - - this->radius = CLAMP_MAX(this->radius, 400.0f); - - this->actor.world.pos.y += this->actor.velocity.y; - if (animFinish) { - BossSst_HeadSetupVulnerable(this); - } -} - -void BossSst_HeadSetupVulnerable(BossSst* this) { - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadStunnedAnim, -5.0f); - this->colliderCyl.base.acFlags |= AC_ON; - this->colliderCyl.info.bumper.dmgFlags = 0x0FC00702; // Sword-type damage - this->actor.speedXZ = 0.0f; - this->colliderJntSph.elements[10].info.bumperFlags |= (BUMP_ON | BUMP_HOOKABLE); - this->colliderJntSph.elements[0].info.bumperFlags &= ~BUMP_ON; - if (this->actionFunc != BossSst_HeadDamage) { - this->timer = 50; - } - - this->actionFunc = BossSst_HeadVulnerable; -} - -void BossSst_HeadVulnerable(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&sHandOffsets[LEFT].z, 600.0f, 20.0f); - Math_StepToF(&sHandOffsets[RIGHT].z, 600.0f, 20.0f); - Math_StepToF(&sHandOffsets[LEFT].x, 200.0f, 20.0f); - Math_StepToF(&sHandOffsets[RIGHT].x, -200.0f, 20.0f); - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { - this->timer += 2; - this->timer = CLAMP_MAX(this->timer, 50); - } else { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - BossSst_HandSetupRecover(sHands[LEFT]); - BossSst_HandSetupRecover(sHands[RIGHT]); - BossSst_HeadSetupRecover(this); - } - } -} - -void BossSst_HeadSetupDamage(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadDamageAnim, -3.0f); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadDamageAnim)); - Actor_SetColorFilter(&sHands[LEFT]->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadDamageAnim)); - Actor_SetColorFilter(&sHands[RIGHT]->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadDamageAnim)); - this->colliderCyl.base.acFlags &= ~AC_ON; - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_DAMAGE); - this->actionFunc = BossSst_HeadDamage; -} - -void BossSst_HeadDamage(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (SkelAnime_Update(&this->skelAnime)) { - BossSst_HeadSetupVulnerable(this); - } -} - -void BossSst_HeadSetupRecover(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadRecoverAnim, -5.0f); - this->colliderCyl.base.acFlags &= ~AC_ON; - this->colliderCyl.info.bumper.dmgFlags = 0xFFCFFFFF; - this->colliderJntSph.elements[10].info.bumperFlags &= ~(BUMP_ON | BUMP_HOOKABLE); - this->colliderJntSph.elements[0].info.bumperFlags |= BUMP_ON; - this->vVanish = true; - this->actor.speedXZ = 5.0f; - this->actionFunc = BossSst_HeadRecover; -} - -void BossSst_HeadRecover(BossSst* this, GlobalContext* globalCtx) { - s32 animFinish; - f32 currentFrame; - f32 diff; - - animFinish = SkelAnime_Update(&this->skelAnime); - currentFrame = this->skelAnime.curFrame; - if (currentFrame < 10.0f) { - this->actor.world.pos.y += 10.0f; - sHandOffsets[LEFT].y -= 10.0f; - sHandOffsets[RIGHT].y -= 10.0f; - Math_SmoothStepToF(&this->radius, -750.0f, 1.0f, this->actor.speedXZ, 2.0f); - } else { - this->actor.speedXZ *= 1.25f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 50.0f); - diff = Math_SmoothStepToF(&this->radius, -650.0f, 1.0f, this->actor.speedXZ, 2.0f); - diff += Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f, 30.0f, 3.0f); - } - if (animFinish && (diff < 10.0f)) { - this->actor.world.pos.y = this->actor.home.pos.y; - this->radius = -650.0f; - BossSst_HandSetupRetreat(sHands[LEFT]); - BossSst_HandSetupRetreat(sHands[RIGHT]); - BossSst_HeadSetupNeutral(this); - } -} - -void BossSst_SetCameraTargets(f32 cameraSpeedMod, s32 targetIndex) { - Vec3f* nextAt = &sCameraAtPoints[targetIndex]; - Vec3f* nextEye = &sCameraEyePoints[targetIndex]; - - if (targetIndex != 0) { - Math_Vec3f_Copy(&sCameraAt, &sCameraAtPoints[targetIndex - 1]); - Math_Vec3f_Copy(&sCameraEye, &sCameraEyePoints[targetIndex - 1]); - } - - sCameraAtVel.x = (nextAt->x - sCameraAt.x) * cameraSpeedMod; - sCameraAtVel.y = (nextAt->y - sCameraAt.y) * cameraSpeedMod; - sCameraAtVel.z = (nextAt->z - sCameraAt.z) * cameraSpeedMod; - - sCameraEyeVel.x = (nextEye->x - sCameraEye.x) * cameraSpeedMod; - sCameraEyeVel.y = (nextEye->y - sCameraEye.y) * cameraSpeedMod; - sCameraEyeVel.z = (nextEye->z - sCameraEye.z) * cameraSpeedMod; -} - -void BossSst_UpdateDeathCamera(BossSst* this, GlobalContext* globalCtx) { - Vec3f cameraAt; - Vec3f cameraEye; - f32 sn; - f32 cs; - - sCameraAt.x += sCameraAtVel.x; - sCameraAt.y += sCameraAtVel.y; - sCameraAt.z += sCameraAtVel.z; - sCameraEye.x += sCameraEyeVel.x; - sCameraEye.y += sCameraEyeVel.y; - sCameraEye.z += sCameraEyeVel.z; - - sn = Math_SinS(this->actor.shape.rot.y); - cs = Math_CosS(this->actor.shape.rot.y); - cameraAt.x = this->actor.world.pos.x + (sCameraAt.z * sn) + (sCameraAt.x * cs); - cameraAt.y = this->actor.home.pos.y - 140.0f + sCameraAt.y; - cameraAt.z = this->actor.world.pos.z + (sCameraAt.z * cs) - (sCameraAt.x * sn); - cameraEye.x = this->actor.world.pos.x + (sCameraEye.z * sn) + (sCameraEye.x * cs); - cameraEye.y = this->actor.home.pos.y - 140.0f + sCameraEye.y; - cameraEye.z = this->actor.world.pos.z + (sCameraEye.z * cs) - (sCameraEye.x * sn); - Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &cameraAt, &cameraEye); -} - -void BossSst_HeadSetupDeath(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Animation_MorphToLoop(&this->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_DEAD); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 60); - Actor_SetColorFilter(&sHands[LEFT]->actor, 0x4000, 0xFF, 0, 60); - Actor_SetColorFilter(&sHands[RIGHT]->actor, 0x4000, 0xFF, 0, 60); - this->timer = 60; - this->colliderCyl.base.acFlags &= ~AC_ON; - this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - sHands[LEFT]->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - sHands[RIGHT]->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - sCutsceneCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_ACTIVE); - Gameplay_CopyCamera(globalCtx, sCutsceneCamera, MAIN_CAM); - func_8002DF54(globalCtx, &player->actor, 8); - func_80064520(globalCtx, &globalCtx->csCtx); - Math_Vec3f_Copy(&sCameraEye, &GET_ACTIVE_CAM(globalCtx)->eye); - this->actionFunc = BossSst_HeadDeath; -} - -void BossSst_HeadDeath(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 140.0f, 20.0f); - if (this->timer == 0) { - BossSst_HandSetupThrash(sHands[LEFT]); - BossSst_HandSetupThrash(sHands[RIGHT]); - BossSst_HeadSetupThrash(this); - } else if (this->timer > 48) { - Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &this->actor.focus.pos, &sCameraEye); - Math_StepToF(&this->radius, -350.0f, 10.0f); - } else if (this->timer == 48) { - Player* player = GET_PLAYER(globalCtx); - - player->actor.world.pos.x = sRoomCenter.x + (400.0f * Math_SinS(this->actor.shape.rot.y)) + - (Math_CosS(this->actor.shape.rot.y) * -120.0f); - player->actor.world.pos.z = sRoomCenter.z + (400.0f * Math_CosS(this->actor.shape.rot.y)) - - (Math_SinS(this->actor.shape.rot.y) * -120.0f); - player->actor.shape.rot.y = Actor_WorldYawTowardPoint(&player->actor, &sRoomCenter); - func_8002DBD0(&this->actor, &sCameraEye, &GET_ACTIVE_CAM(globalCtx)->eye); - func_8002DBD0(&this->actor, &sCameraAt, &GET_ACTIVE_CAM(globalCtx)->at); - this->radius = -350.0f; - this->actor.world.pos.x = sRoomCenter.x - (Math_SinS(this->actor.shape.rot.y) * 350.0f); - this->actor.world.pos.z = sRoomCenter.z - (Math_CosS(this->actor.shape.rot.y) * 350.0f); - BossSst_SetCameraTargets(1.0 / 48, 0); - BossSst_UpdateDeathCamera(this, globalCtx); - } else { - BossSst_UpdateDeathCamera(this, globalCtx); - } -} - -void BossSst_HeadSetupThrash(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); - this->timer = 160; - this->targetYaw = this->actor.shape.rot.y; - BossSst_SetCameraTargets(1.0 / 80, 1); - this->actionFunc = BossSst_HeadThrash; -} - -void BossSst_HeadThrash(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - if ((this->timer == 0) && (this->actor.shape.rot.y == this->targetYaw)) { - BossSst_HeadSetupDarken(this); - } else if (this->timer >= 80) { - BossSst_UpdateDeathCamera(this, globalCtx); - } -} - -void BossSst_HeadSetupDarken(BossSst* this) { - this->timer = 160; - BossSst_SetCameraTargets(1.0 / 80, 2); - this->actionFunc = BossSst_HeadDarken; -} - -void BossSst_HeadDarken(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (1) {} - - if (this->timer >= 80) { - if (this->timer == 80) { - sBodyStatic = true; - } - BossSst_UpdateDeathCamera(this, globalCtx); - sBodyColor.r = sBodyColor.g = sBodyColor.b = (this->timer * 3) - 240; - if (this->timer == 80) { - BossSst_SetCameraTargets(1.0 / 80, 3); - } - } else { - sBodyColor.b = (80 - this->timer) / 1.0f; - sBodyColor.r = sBodyColor.g = sStaticColor.r = sStaticColor.g = sStaticColor.b = (80 - this->timer) / 8.0f; - BossSst_UpdateDeathCamera(this, globalCtx); - if (this->timer == 0) { - BossSst_HeadSetupFall(this); - } - } -} - -void BossSst_HeadSetupFall(BossSst* this) { - this->actor.speedXZ = 1.0f; - Math_Vec3f_Copy(&sCameraAt, &sCameraAtPoints[3]); - Math_Vec3f_Copy(&sCameraEye, &sCameraEyePoints[3]); - sCameraAtVel.x = 0.0f; - sCameraAtVel.z = 0.0f; - sCameraAtVel.y = -50.0f; - Math_Vec3f_Copy(&sCameraEyeVel, &sZeroVec); - this->actionFunc = BossSst_HeadFall; -} - -void BossSst_HeadFall(BossSst* this, GlobalContext* globalCtx) { - this->actor.speedXZ *= 1.5f; - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 230.0f, this->actor.speedXZ)) { - BossSst_HeadSetupMelt(this); - } - - if (sCameraAt.y > 200.0f) { - BossSst_UpdateDeathCamera(this, globalCtx); - } -} - -void BossSst_HeadSetupMelt(BossSst* this) { - BossSst_SpawnHeadShadow(this); - this->timer = 80; - BossSst_SetCameraTargets(1.0 / 60, 5); - this->actionFunc = BossSst_HeadMelt; -} - -void BossSst_HeadMelt(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - this->actor.scale.y -= 0.00025f; - this->actor.scale.x += 0.000075f; - this->actor.scale.z += 0.000075f; - this->actor.world.pos.y = this->actor.home.pos.y - 11500.0f * this->actor.scale.y; - if (this->timer == 0) { - BossSst_HeadSetupFinish(this); - } else if (this->timer >= 20.0f) { - BossSst_UpdateDeathCamera(this, globalCtx); - } -} - -void BossSst_HeadSetupFinish(BossSst* this) { - this->actor.draw = BossSst_DrawEffect; - this->timer = 40; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - BossSst_SetCameraTargets(1.0 / 40, 6); - this->actionFunc = BossSst_HeadFinish; -} - -void BossSst_HeadFinish(BossSst* this, GlobalContext* globalCtx) { - static Color_RGBA8 colorIndigo = { 80, 80, 150, 255 }; - static Color_RGBA8 colorDarkIndigo = { 40, 40, 80, 255 }; - static Color_RGBA8 colorUnused[2] = { - { 0, 0, 0, 255 }, - { 100, 100, 100, 0 }, - }; - Vec3f spawnPos; - s32 i; - - this->timer--; - if (this->effectMode == BONGO_NULL) { - if (this->timer < -170) { - BossSst_UpdateDeathCamera(this, globalCtx); - Gameplay_CopyCamera(globalCtx, MAIN_CAM, sCutsceneCamera); - Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, sCutsceneCamera); - func_8002DF54(globalCtx, &GET_PLAYER(globalCtx)->actor, 7); - func_80064534(globalCtx, &globalCtx->csCtx); - Actor_Kill(&this->actor); - Actor_Kill(&sHands[LEFT]->actor); - Actor_Kill(&sHands[RIGHT]->actor); - Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); - } - } else if (this->effects[0].alpha == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, ROOM_CENTER_X, ROOM_CENTER_Y, ROOM_CENTER_Z, 0, - 0, 0, WARP_DUNGEON_ADULT); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, - (Math_SinS(this->actor.shape.rot.y) * 200.0f) + ROOM_CENTER_X, ROOM_CENTER_Y, - Math_CosS(this->actor.shape.rot.y) * 200.0f + ROOM_CENTER_Z, 0, 0, 0, 0); - BossSst_SetCameraTargets(1.0f, 7); - this->effectMode = BONGO_NULL; - } else if (this->timer == 0) { - this->effects[0].status = 0; - this->effects[1].status = -1; - this->effects[2].status = -1; - } else if (this->timer > 0) { - this->effects[0].status += 5; - BossSst_UpdateDeathCamera(this, globalCtx); - } - - colorIndigo.a = this->effects[0].alpha; - colorDarkIndigo.a = this->effects[0].alpha; - - for (i = 0; i < 5; i++) { - spawnPos.x = sRoomCenter.x + 0.0f + Rand_CenteredFloat(800.0f); - spawnPos.y = sRoomCenter.y + (-28.0f) + (Rand_ZeroOne() * 5.0f); - spawnPos.z = sRoomCenter.z + 0.0f + Rand_CenteredFloat(800.0f); - EffectSsGSplash_Spawn(globalCtx, &spawnPos, &colorIndigo, &colorDarkIndigo, 0, 0x3E8); - } -} - -void BossSst_HandSetupWait(BossSst* this) { - HAND_STATE(this) = HAND_WAIT; - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - Animation_MorphToLoop(&this->skelAnime, sHandIdleAnims[this->actor.params], 5.0f); - this->ready = false; - this->timer = 20; - this->actionFunc = BossSst_HandWait; -} - -void BossSst_HandWait(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, 20.0f); - Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); - Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - Player* player = GET_PLAYER(globalCtx); - - if (this->timer != 0) { - this->timer--; - } - - if ((this->timer == 0) && (player->actor.world.pos.y > -50.0f) && !(player->stateFlags1 & 0x6080)) { - BossSst_HandSelectAttack(this); - } - } else if (sHead->actionFunc == BossSst_HeadNeutral) { - if ((this->actor.params == BONGO_RIGHT_HAND) && ((sHead->timer % 28) == 12)) { - BossSst_HandSetupDownbeat(this); - } else if ((this->actor.params == BONGO_LEFT_HAND) && ((sHead->timer % 7) == 5) && (sHead->timer < 112)) { - BossSst_HandSetupOffbeat(this); - } - } -} - -void BossSst_HandSetupDownbeat(BossSst* this) { - HAND_STATE(this) = HAND_BEAT; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 5.0f); - this->actor.shape.rot.x = 0; - this->timer = 12; - this->actionFunc = BossSst_HandDownbeat; -} - -void BossSst_HandDownbeat(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - BossSst_HandSetupWait(this); - } else { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer >= 3) { - this->actor.shape.rot.x -= 0x100; - Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 180.0f, 20.0f); - } else { - this->actor.shape.rot.x += 0x300; - Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 0.0f, 60.0f); - } - - if (this->timer == 0) { - sFloor->dyna.actor.params = BONGOFLOOR_HIT; - if (sHead->actionFunc == BossSst_HeadWait) { - if (this->ready) { - BossSst_HandSelectAttack(this); - } else { - BossSst_HandSetupWait(this); - } - } else { - BossSst_HandSetupDownbeatEnd(this); - } - func_800AA000(this->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_TAIKO_HIGH); - } - } -} - -void BossSst_HandSetupDownbeatEnd(BossSst* this) { - sFloor->dyna.actor.params = BONGOFLOOR_HIT; - Animation_PlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params]); - this->actionFunc = BossSst_HandDownbeatEnd; -} - -void BossSst_HandDownbeatEnd(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - BossSst_HandSetupWait(this); - } else { - Math_SmoothStepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 40.0f, 0.5f, 20.0f, 3.0f); - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x800, 0x100); - Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); - Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); - if ((sHead->actionFunc != BossSst_HeadIntro) && ((sHead->timer % 28) == 12)) { - BossSst_HandSetupDownbeat(this); - } - } -} - -void BossSst_HandSetupOffbeat(BossSst* this) { - HAND_STATE(this) = HAND_BEAT; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 5.0f); - this->actor.shape.rot.x = 0; - this->timer = 5; - this->actionFunc = BossSst_HandOffbeat; -} - -void BossSst_HandOffbeat(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - BossSst_HandSetupWait(this); - } else { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer != 0) { - this->actor.shape.rot.x -= 0x140; - Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 60.0f, 15.0f); - } else { - this->actor.shape.rot.x += 0x500; - Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 0.0f, 60.0f); - } - - if (this->timer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_TAIKO_LOW); - BossSst_HandSetupOffbeatEnd(this); - } - } -} - -void BossSst_HandSetupOffbeatEnd(BossSst* this) { - Animation_PlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params]); - this->actionFunc = BossSst_HandOffbeatEnd; -} - -void BossSst_HandOffbeatEnd(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - BossSst_HandSetupWait(this); - } else { - Math_SmoothStepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 40.0f, 0.5f, 20.0f, 3.0f); - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x400, 0xA0); - Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); - Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); - if (sHead->actionFunc == BossSst_HeadWait) { - if (this->ready) { - BossSst_HandSelectAttack(this); - } else { - BossSst_HandSetupWait(this); - } - } else if ((sHead->actionFunc != BossSst_HeadIntro) && ((sHead->timer % 7) == 5) && - ((sHead->timer % 28) != 5)) { - BossSst_HandSetupOffbeat(this); - } - } -} - -void BossSst_HandSetupEndSlam(BossSst* this) { - HAND_STATE(this) = HAND_RETREAT; - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - Animation_MorphToPlayOnce(&this->skelAnime, sHandPushoffPoses[this->actor.params], 6.0f); - this->actionFunc = BossSst_HandEndSlam; -} - -void BossSst_HandEndSlam(BossSst* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - BossSst_HandSetupRetreat(this); - } -} - -void BossSst_HandSetupRetreat(BossSst* this) { - HAND_STATE(this) = HAND_RETREAT; - Animation_MorphToPlayOnce(&this->skelAnime, sHandHangPoses[this->actor.params], 10.0f); - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->colliderJntSph.base.acFlags |= AC_ON; - this->actor.flags |= ACTOR_FLAG_0; - BossSst_HandSetInvulnerable(this, false); - this->timer = 0; - this->actionFunc = BossSst_HandRetreat; - this->actor.speedXZ = 3.0f; -} - -void BossSst_HandRetreat(BossSst* this, GlobalContext* globalCtx) { - f32 diff; - s32 inPosition; - - SkelAnime_Update(&this->skelAnime); - this->actor.speedXZ = this->actor.speedXZ * 1.2f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 50.0f); - - diff = Math_SmoothStepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, this->actor.speedXZ, 1.0f); - diff += Math_SmoothStepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, this->actor.speedXZ, 1.0f); - if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - - this->actor.world.pos.y = (sinf((this->timer * M_PI) / 16.0f) * 250.0f) + this->actor.home.pos.y; - if (this->timer == 0) { - BossSst_HandSetupWait(this); - } else if (this->timer == 4) { - Animation_MorphToLoop(&this->skelAnime, sHandIdleAnims[this->actor.params], 4.0f); - } - } else { - inPosition = Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x200); - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0x200); - inPosition &= Math_ScaledStepToS(&this->handYRotMod, 0, 0x800); - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); - if ((Math_SmoothStepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 250.0f, 0.5f, 70.0f, 5.0f) < 1.0f) && - inPosition && (diff < 10.0f)) { - this->timer = 8; - } - } -} - -void BossSst_HandSetupReadySlam(BossSst* this) { - HAND_STATE(this) = HAND_SLAM; - this->timer = 0; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 10.0f); - this->actionFunc = BossSst_HandReadySlam; -} - -void BossSst_HandReadySlam(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - BossSst_HandSetupSlam(this); - } - } else { - Player* player = GET_PLAYER(globalCtx); - - if (Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 300.0f, 30.0f) && - (this->actor.xzDistToPlayer < 140.0f)) { - this->timer = 20; - } - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x1000, 0x100); - Math_ApproachF(&this->actor.world.pos.x, player->actor.world.pos.x, 0.5f, 40.0f); - Math_ApproachF(&this->actor.world.pos.z, player->actor.world.pos.z, 0.5f, 40.0f); - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); - } -} - -void BossSst_HandSetupSlam(BossSst* this) { - HAND_STATE(this) = HAND_SLAM; - this->actor.velocity.y = 1.0f; - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 10.0f); - BossSst_HandSetDamage(this, 0x20); - this->ready = false; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_FLY_ATTACK); - this->actionFunc = BossSst_HandSlam; -} - -void BossSst_HandSlam(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToS(&this->handZPosMod, -0xDAC, 0x1F4); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x1000); - Math_ScaledStepToS(&this->handYRotMod, 0, 0x1000); - if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - if (this->colliderJntSph.base.acFlags & AC_ON) { - BossSst_HandSetupEndSlam(this); - } else { - this->colliderJntSph.base.acFlags |= AC_ON; - BossSst_HandSetupWait(this); - } - } - } else { - if (this->ready) { - this->timer = 30; - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - } else { - this->actor.velocity.y *= 1.5f; - if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, this->actor.velocity.y)) { - this->ready = true; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_TAIKO_LOW); - BossSst_SpawnShockwave(this); - this->colliderCyl.base.atFlags |= AT_ON; - Collider_UpdateCylinder(&this->actor, &this->colliderCyl); - this->colliderCyl.dim.radius = sCylinderInitHand.dim.radius; - } - } - - if (this->colliderJntSph.base.atFlags & AT_HIT) { - Player* player = GET_PLAYER(globalCtx); - - player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 100.0f) + this->actor.world.pos.x; - player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 100.0f) + this->actor.world.pos.z; - - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - func_8002F71C(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 0.0f); - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x200); - } -} - -void BossSst_HandSetupReadySweep(BossSst* this) { - HAND_STATE(this) = HAND_SWEEP; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 10.0f); - this->radius = Actor_WorldDistXZToPoint(&this->actor, &sHead->actor.world.pos); - this->actor.world.rot.y = Actor_WorldYawTowardPoint(&sHead->actor, &this->actor.world.pos); - this->targetYaw = this->actor.home.rot.y + (this->vParity * 0x2000); - this->actionFunc = BossSst_HandReadySweep; -} - -void BossSst_HandReadySweep(BossSst* this, GlobalContext* globalCtx) { - s32 inPosition; - - SkelAnime_Update(&this->skelAnime); - inPosition = Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 50.0f, 4.0f); - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200); - inPosition &= Math_ScaledStepToS(&this->actor.world.rot.y, this->targetYaw, 0x400); - inPosition &= (Math_SmoothStepToF(&this->radius, sHead->actor.xzDistToPlayer, 0.5f, 60.0f, 1.0f) < 10.0f); - - this->actor.world.pos.x = (Math_SinS(this->actor.world.rot.y) * this->radius) + sHead->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.world.rot.y) * this->radius) + sHead->actor.world.pos.z; - if (inPosition) { - BossSst_HandSetupSweep(this); - } else { - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); - } -} - -void BossSst_HandSetupSweep(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 5.0f); - BossSst_HandSetDamage(this, 0x10); - this->targetYaw = this->actor.home.rot.y - (this->vParity * 0x2000); - this->handMaxSpeed = 0x300; - this->handAngSpeed = 0; - this->ready = false; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_FLY_ATTACK); - this->actionFunc = BossSst_HandSweep; -} - -void BossSst_HandSweep(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 newTargetYaw; - - SkelAnime_Update(&this->skelAnime); - this->handAngSpeed += 0x60; - this->handAngSpeed = CLAMP_MAX(this->handAngSpeed, this->handMaxSpeed); - - if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->targetYaw, 4, this->handAngSpeed, 0x10)) { - this->colliderJntSph.base.ocFlags1 &= ~OC1_NO_PUSH; - BossSst_HandSetupRetreat(this); - } else if (this->colliderJntSph.base.atFlags & AT_HIT) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->ready = true; - func_8002F71C(globalCtx, &this->actor, 5.0f, this->actor.shape.rot.y - (this->vParity * 0x3800), 0.0f); - func_8002F7DC(&player->actor, NA_SE_PL_BODY_HIT); - newTargetYaw = this->actor.shape.rot.y - (this->vParity * 0x1400); - if (((s16)(newTargetYaw - this->targetYaw) * this->vParity) > 0) { - this->targetYaw = newTargetYaw; - } - } - - if (!this->ready && ((player->cylinder.dim.height > 40.0f) || (player->actor.world.pos.y > 1.0f))) { - this->colliderJntSph.base.atFlags |= AT_ON; - this->colliderJntSph.base.ocFlags1 &= ~OC1_NO_PUSH; - } else { - this->colliderJntSph.base.atFlags &= ~AT_ON; - this->colliderJntSph.base.ocFlags1 |= OC1_NO_PUSH; - } - - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * this->radius) + sHead->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * this->radius) + sHead->actor.world.pos.z; -} - -void BossSst_HandSetupReadyPunch(BossSst* this) { - HAND_STATE(this) = HAND_PUNCH; - Animation_MorphToPlayOnce(&this->skelAnime, sHandPushoffPoses[this->actor.params], 10.0f); - this->actionFunc = BossSst_HandReadyPunch; -} - -void BossSst_HandReadyPunch(BossSst* this, GlobalContext* globalCtx) { - s32 inPosition = Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x400); - - if (SkelAnime_Update(&this->skelAnime) && inPosition) { - BossSst_HandSetupPunch(this); - } -} - -void BossSst_HandSetupPunch(BossSst* this) { - this->actor.speedXZ = 0.5f; - Animation_MorphToPlayOnce(&this->skelAnime, sHandFistPoses[this->actor.params], 5.0f); - BossSst_HandSetInvulnerable(this, true); - this->targetRoll = this->vParity * 0x3F00; - BossSst_HandSetDamage(this, 0x10); - this->actionFunc = BossSst_HandPunch; -} - -void BossSst_HandPunch(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 80.0f, 20.0f); - if (Math_ScaledStepToS(&this->actor.shape.rot.z, this->targetRoll, 0x400)) { - this->targetRoll *= -1; - } - - this->actor.speedXZ *= 1.25f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 50.0f); - - this->actor.world.pos.x += this->actor.speedXZ * Math_SinS(this->actor.shape.rot.y); - this->actor.world.pos.z += this->actor.speedXZ * Math_CosS(this->actor.shape.rot.y); - if (this->actor.bgCheckFlags & 8) { - BossSst_HandSetupRetreat(this); - } else if (this->colliderJntSph.base.atFlags & AT_HIT) { - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - func_8002F71C(globalCtx, &this->actor, 10.0f, this->actor.shape.rot.y, 5.0f); - BossSst_HandSetupRetreat(this); - } - - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); -} - -void BossSst_HandSetupReadyClap(BossSst* this) { - HAND_STATE(this) = HAND_CLAP; - if (HAND_STATE(OTHER_HAND(this)) != HAND_CLAP) { - BossSst_HandSetupReadyClap(OTHER_HAND(this)); - } - - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 10.0f); - this->radius = Actor_WorldDistXZToPoint(&this->actor, &sHead->actor.world.pos); - this->actor.world.rot.y = Actor_WorldYawTowardPoint(&sHead->actor, &this->actor.world.pos); - this->targetYaw = this->actor.home.rot.y - (this->vParity * 0x1800); - this->targetRoll = this->vParity * 0x4000; - this->timer = 0; - this->ready = false; - OTHER_HAND(this)->ready = false; - this->actionFunc = BossSst_HandReadyClap; -} - -void BossSst_HandReadyClap(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - BossSst_HandSetupClap(this); - BossSst_HandSetupClap(OTHER_HAND(this)); - OTHER_HAND(this)->radius = this->radius; - } - } else if (!this->ready) { - this->ready = SkelAnime_Update(&this->skelAnime); - this->ready &= Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x600); - this->ready &= Math_ScaledStepToS(&this->actor.shape.rot.z, this->targetRoll, 0x600); - this->ready &= Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200); - this->ready &= Math_ScaledStepToS(&this->actor.world.rot.y, this->targetYaw, 0x400); - this->ready &= Math_SmoothStepToF(&this->radius, sHead->actor.xzDistToPlayer, 0.5f, 50.0f, 1.0f) < 10.0f; - this->ready &= Math_SmoothStepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 95.0f, 0.5f, 30.0f, 1.0f) < 1.0f; - - this->actor.world.pos.x = Math_SinS(this->actor.world.rot.y) * this->radius + sHead->actor.world.pos.x; - this->actor.world.pos.z = Math_CosS(this->actor.world.rot.y) * this->radius + sHead->actor.world.pos.z; - } else if (OTHER_HAND(this)->ready) { - this->timer = 20; - } -} - -void BossSst_HandSetupClap(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 3.0f); - this->timer = 0; - this->handMaxSpeed = 0x240; - this->handAngSpeed = 0; - this->ready = false; - BossSst_HandSetDamage(this, 0x20); - this->actionFunc = BossSst_HandClap; -} - -void BossSst_HandClap(BossSst* this, GlobalContext* globalCtx) { - static s32 dropFlag = false; - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - if (dropFlag) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, - (Rand_ZeroOne() < 0.5f) ? ITEM00_ARROWS_SMALL : ITEM00_MAGIC_SMALL); - dropFlag = false; - } - - BossSst_HandReleasePlayer(this, globalCtx, true); - BossSst_HandSetupEndClap(this); - } - } else { - if (this->colliderJntSph.base.atFlags & AT_HIT) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - OTHER_HAND(this)->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - BossSst_HandGrabPlayer(this, globalCtx); - } - - if (this->ready) { - this->timer = 30; - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - if (!(player->stateFlags2 & 0x80)) { - dropFlag = true; - } - } else { - this->handAngSpeed += 0x40; - this->handAngSpeed = CLAMP_MAX(this->handAngSpeed, this->handMaxSpeed); - - if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, this->handAngSpeed)) { - if (this->actor.params == BONGO_LEFT_HAND) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_CLAP); - } - this->ready = true; - } else { - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); - } - - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * this->radius) + sHead->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * this->radius) + sHead->actor.world.pos.z; - } - } - - if (player->actor.parent == &this->actor) { - player->unk_850 = 0; - player->actor.world.pos = this->actor.world.pos; - } -} - -void BossSst_HandSetupEndClap(BossSst* this) { - this->targetYaw = this->actor.home.rot.y - (this->vParity * 0x1000); - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 10.0f); - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->actionFunc = BossSst_HandEndClap; -} - -void BossSst_HandEndClap(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x200); - if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x100)) { - BossSst_HandSetupRetreat(this); - } - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * this->radius) + sHead->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * this->radius) + sHead->actor.world.pos.z; -} - -void BossSst_HandSetupReadyGrab(BossSst* this) { - HAND_STATE(this) = HAND_GRAB; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 10.0f); - this->targetYaw = this->vParity * -0x5000; - this->targetRoll = this->vParity * 0x4000; - this->actionFunc = BossSst_HandReadyGrab; -} - -void BossSst_HandReadyGrab(BossSst* this, GlobalContext* globalCtx) { - s32 inPosition; - - SkelAnime_Update(&this->skelAnime); - inPosition = Math_SmoothStepToS(&this->actor.shape.rot.z, this->targetRoll, 4, 0x800, 0x100) == 0; - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->targetYaw, 0xA00); - Math_ApproachF(&this->actor.world.pos.y, ROOM_CENTER_Y + 95.0f, 0.5f, 20.0f); - if (inPosition) { - BossSst_HandSetupGrab(this); - } -} - -void BossSst_HandSetupGrab(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFistPoses[this->actor.params], 5.0f); - this->actor.world.rot.y = this->actor.shape.rot.y + (this->vParity * 0x4000); - this->targetYaw = this->actor.world.rot.y; - this->timer = 30; - this->actor.speedXZ = 0.5f; - BossSst_HandSetDamage(this, 0x20); - this->actionFunc = BossSst_HandGrab; -} - -void BossSst_HandGrab(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->timer != 0) { - this->timer--; - } - - this->actor.world.rot.y = - ((1.0f - sinf(this->timer * (M_PI / 60.0f))) * (this->vParity * 0x2000)) + this->targetYaw; - this->actor.shape.rot.y = this->actor.world.rot.y - (this->vParity * 0x4000); - if (this->timer < 5) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.5f, 25.0f, 5.0f); - if (SkelAnime_Update(&this->skelAnime)) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->actor.speedXZ = 0.0f; - if (player->stateFlags2 & 0x80) { - if (Rand_ZeroOne() < 0.5f) { - BossSst_HandSetupCrush(this); - } else { - BossSst_HandSetupSwing(this); - } - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, - (Rand_ZeroOne() < 0.5f) ? ITEM00_ARROWS_SMALL : ITEM00_MAGIC_SMALL); - BossSst_HandSetupRetreat(this); - } - } - } else { - this->actor.speedXZ *= 1.26f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 70.0f); - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); - } - - if (this->colliderJntSph.base.atFlags & AT_HIT) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_CATCH); - BossSst_HandGrabPlayer(this, globalCtx); - this->timer = CLAMP_MAX(this->timer, 5); - } - - this->actor.world.pos.x += this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); - this->actor.world.pos.z += this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); - if (player->stateFlags2 & 0x80) { - player->unk_850 = 0; - player->actor.world.pos = this->actor.world.pos; - player->actor.shape.rot.y = this->actor.shape.rot.y; - } -} - -void BossSst_HandSetupCrush(BossSst* this) { - Animation_MorphToLoop(&this->skelAnime, sHandClenchAnims[this->actor.params], -10.0f); - this->timer = 20; - this->actionFunc = BossSst_HandCrush; -} - -void BossSst_HandCrush(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - if (!(player->stateFlags2 & 0x80)) { - BossSst_HandReleasePlayer(this, globalCtx, true); - BossSst_HandSetupEndCrush(this); - } else { - player->actor.world.pos = this->actor.world.pos; - if (this->timer == 0) { - this->timer = 20; - if (!LINK_IS_ADULT) { - func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S_KID); - } else { - func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S); - } - - globalCtx->damagePlayer(globalCtx, -8); - } - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_CATCH); - } - } -} - -void BossSst_HandSetupEndCrush(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 10.0f); - this->actionFunc = BossSst_HandEndCrush; -} - -void BossSst_HandEndCrush(BossSst* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - BossSst_HandSetupRetreat(this); - } -} - -void BossSst_HandSetupSwing(BossSst* this) { - this->amplitude = -0x4000; - this->timer = 1; - this->center.x = this->actor.world.pos.x - (Math_SinS(this->actor.shape.rot.y) * 200.0f); - this->center.y = this->actor.world.pos.y; - this->center.z = this->actor.world.pos.z - (Math_CosS(this->actor.shape.rot.y) * 200.0f); - this->actionFunc = BossSst_HandSwing; -} - -void BossSst_HandSwing(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 offXZ; - - if (Math_ScaledStepToS(&this->actor.shape.rot.x, this->amplitude, this->timer * 0xE4 + 0x1C8)) { - if (this->amplitude != 0) { - this->amplitude = 0; - if (this->timer == 4) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 4.0f); - } - } else { - if (this->timer == 4) { - player->actor.shape.rot.x = 0; - player->actor.shape.rot.z = 0; - BossSst_HandSetupRetreat(this); - return; - } - this->amplitude = (this->timer == 3) ? -0x6000 : -0x4000; - this->timer++; - } - } - - this->actor.world.pos.y = (Math_CosS(this->actor.shape.rot.x + 0x4000) * 200.0f) + this->center.y; - offXZ = Math_SinS(this->actor.shape.rot.x + 0x4000) * 200.0f; - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * offXZ) + this->center.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * offXZ) + this->center.z; - if (this->timer != 4) { - this->actor.shape.rot.z = (this->actor.shape.rot.x + 0x4000) * this->vParity; - } else { - Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x800); - } - - if (player->stateFlags2 & 0x80) { - player->unk_850 = 0; - Math_Vec3f_Copy(&player->actor.world.pos, &this->actor.world.pos); - player->actor.shape.rot.x = this->actor.shape.rot.x; - player->actor.shape.rot.z = (this->vParity * -0x4000) + this->actor.shape.rot.z; - } else { - Math_ScaledStepToS(&player->actor.shape.rot.x, 0, 0x600); - Math_ScaledStepToS(&player->actor.shape.rot.z, 0, 0x600); - player->actor.world.pos.x += 20.0f * Math_SinS(this->actor.shape.rot.y); - player->actor.world.pos.z += 20.0f * Math_CosS(this->actor.shape.rot.y); - } - - if ((this->timer == 4) && (this->amplitude == 0) && SkelAnime_Update(&this->skelAnime) && - (player->stateFlags2 & 0x80)) { - BossSst_HandReleasePlayer(this, globalCtx, false); - player->actor.world.pos.x += 70.0f * Math_SinS(this->actor.shape.rot.y); - player->actor.world.pos.z += 70.0f * Math_CosS(this->actor.shape.rot.y); - func_8002F71C(globalCtx, &this->actor, 15.0f, this->actor.shape.rot.y, 2.0f); - func_8002F7DC(&player->actor, NA_SE_PL_BODY_HIT); - } - - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); -} - -void BossSst_HandSetupReel(BossSst* this) { - HAND_STATE(this) = HAND_DAMAGED; - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 4.0f); - this->timer = 36; - Math_Vec3f_Copy(&this->center, &this->actor.world.pos); - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 200); - this->actionFunc = BossSst_HandReel; -} - -void BossSst_HandReel(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - if (!(this->timer % 4)) { - if (this->timer % 8) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 4.0f); - } else { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFistPoses[this->actor.params], 6.0f); - } - } - - this->actor.colorFilterTimer = 200; - this->actor.world.pos.x += Rand_CenteredFloat(20.0f); - this->actor.world.pos.y += Rand_CenteredFloat(20.0f); - this->actor.world.pos.z += Rand_CenteredFloat(20.0f); - - if (this->actor.world.pos.y < (this->actor.floorHeight + 100.0f)) { - Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 100.0f, 20.0f); - } - - if (this->timer == 0) { - BossSst_HandSetupReadyShake(this); - } -} - -void BossSst_HandSetupReadyShake(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandDamagePoses[this->actor.params], 8.0f); - this->actionFunc = BossSst_HandReadyShake; -} - -void BossSst_HandReadyShake(BossSst* this, GlobalContext* globalCtx) { - f32 diff; - s32 inPosition; - - diff = Math_SmoothStepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.5f, 25.0f, 1.0f); - diff += Math_SmoothStepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.5f, 25.0f, 1.0f); - diff += Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 200.0f, 0.2f, 30.0f, 1.0f); - inPosition = Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x400); - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x1000); - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x800); - inPosition &= Math_StepToS(&this->handZPosMod, -0x5DC, 0x1F4); - inPosition &= Math_ScaledStepToS(&this->handYRotMod, this->vParity * -0x2000, 0x800); - this->actor.colorFilterTimer = 200; - if ((diff < 30.0f) && inPosition) { - BossSst_HandSetupShake(this); - } else { - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); - } -} - -void BossSst_HandSetupShake(BossSst* this) { - this->timer = 200; - this->actionFunc = BossSst_HandShake; -} - -void BossSst_HandShake(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - this->actor.shape.rot.x = 0x4000 + (sinf(this->timer * (M_PI / 5)) * 0x2000); - this->handYRotMod = (this->vParity * -0x2000) + (sinf(this->timer * (M_PI / 4)) * 0x2800); - - if (!(this->timer % 8)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_SHAKEHAND); - } - - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - if ((OTHER_HAND(this)->actionFunc == BossSst_HandShake) || - (OTHER_HAND(this)->actionFunc == BossSst_HandReadyCharge)) { - BossSst_HandSetupReadyCharge(this); - } else if (this->timer == 0) { - this->timer = 80; - } - } else if (this->timer == 0) { - this->actor.flags |= ACTOR_FLAG_0; - BossSst_HandSetupSlam(this); - } -} - -void BossSst_HandSetupReadyCharge(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFistPoses[this->actor.params], 10.0f); - this->ready = false; - this->actionFunc = BossSst_HandReadyCharge; -} - -void BossSst_HandReadyCharge(BossSst* this, GlobalContext* globalCtx) { - if (!this->ready) { - this->ready = SkelAnime_Update(&this->skelAnime); - this->ready &= Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x800); - this->ready &= - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y + (this->vParity * 0x1000), 0x800); - this->ready &= Math_ScaledStepToS(&this->handYRotMod, 0, 0x800); - this->ready &= Math_ScaledStepToS(&this->actor.shape.rot.z, this->vParity * 0x2800, 0x800); - this->ready &= Math_StepToS(&this->handZPosMod, -0xDAC, 0x1F4); - if (this->ready) { - this->actor.colorFilterTimer = 0; - } - } else if (this->colliderJntSph.base.atFlags & AT_HIT) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - OTHER_HAND(this)->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - sHead->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - func_8002F71C(globalCtx, &this->actor, 10.0f, this->actor.shape.rot.y, 5.0f); - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - } -} - -void BossSst_HandSetupStunned(BossSst* hand) { - Animation_MorphToPlayOnce(&hand->skelAnime, sHandIdleAnims[hand->actor.params], 10.0f); - if (hand->actionFunc != BossSst_HandDamage) { - hand->ready = false; - } - - hand->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - hand->colliderJntSph.base.acFlags |= AC_ON; - BossSst_HandSetInvulnerable(hand, true); - Actor_SetColorFilter(&hand->actor, 0, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadKnockoutAnim)); - hand->actionFunc = BossSst_HandStunned; -} - -void BossSst_HandStunned(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.world.pos.z, (Math_CosS(sHead->actor.shape.rot.y) * 200.0f) + this->actor.home.pos.z, - 0.5f, 25.0f); - Math_ApproachF(&this->actor.world.pos.x, (Math_SinS(sHead->actor.shape.rot.y) * 200.0f) + this->actor.home.pos.x, - 0.5f, 25.0f); - if (!this->ready) { - Math_ScaledStepToS(&this->handYRotMod, 0, 0x800); - Math_StepToS(&this->handZPosMod, -0xDAC, 0x1F4); - Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 0x800); - Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0x800); - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x800); - if (sHead->actionFunc == BossSst_HeadVulnerable) { - this->ready = true; - Animation_MorphToPlayOnce(&this->skelAnime, sHandDamagePoses[this->actor.params], 10.0f); - } - } else { - Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, 30.0f); - } -} - -void BossSst_HandSetupDamage(BossSst* hand) { - hand->actor.shape.rot.x = 0; - Animation_MorphToPlayOnce(&hand->skelAnime, sHandOpenPoses[hand->actor.params], 3.0f); - hand->timer = 6; - hand->actionFunc = BossSst_HandDamage; -} - -void BossSst_HandDamage(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - SkelAnime_Update(&this->skelAnime); - if (this->timer >= 2) { - this->actor.shape.rot.x -= 0x200; - Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 200.0f, 50.0f); - } else { - this->actor.shape.rot.x += 0x400; - Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, 100.0f); - } - - if (this->timer == 0) { - if (this->actor.floorHeight >= 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_TAIKO_HIGH); - } - BossSst_HandSetupStunned(this); - } -} - -void BossSst_HandSetupThrash(BossSst* this) { - HAND_STATE(this) = HAND_DEATH; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 2.0f); - this->actor.shape.rot.x = 0; - this->timer = 160; - if (this->actor.params == BONGO_LEFT_HAND) { - this->amplitude = -0x800; - } else { - this->amplitude = 0; - this->actor.shape.rot.x = -0x800; - } - - this->handAngSpeed = 0x180; - this->actionFunc = BossSst_HandThrash; -} - -void BossSst_HandThrash(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.world.pos.z, (Math_CosS(sHead->actor.shape.rot.y) * 200.0f) + this->actor.home.pos.z, - 0.5f, 25.0f); - Math_ApproachF(&this->actor.world.pos.x, (Math_SinS(sHead->actor.shape.rot.y) * 200.0f) + this->actor.home.pos.x, - 0.5f, 25.0f); - if (Math_ScaledStepToS(&this->actor.shape.rot.x, this->amplitude, this->handAngSpeed)) { - if (this->amplitude != 0) { - this->amplitude = 0; - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 5.0f); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_TAIKO_HIGH); - this->amplitude = -0x800; - Animation_MorphToPlayOnce(&this->skelAnime, sHandOpenPoses[this->actor.params], 5.0f); - } - - if (this->timer < 80.0f) { - this->handAngSpeed -= 0x40; - this->handAngSpeed = CLAMP_MIN(this->handAngSpeed, 0x40); - } - } - - this->actor.world.pos.y = - (((this->handAngSpeed / 256.0f) + 0.5f) * 150.0f) * (-1.0f / 0x800) * this->actor.shape.rot.x; - if (this->timer == 0) { - BossSst_HandSetupDarken(this); - } -} - -void BossSst_HandSetupDarken(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 5.0f); - this->actionFunc = BossSst_HandDarken; -} - -void BossSst_HandDarken(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x800, this->handAngSpeed); - Math_StepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 90.0f, 5.0f); - if (sHead->actionFunc == BossSst_HeadFall) { - BossSst_HandSetupFall(this); - } -} - -void BossSst_HandSetupFall(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandFlatPoses[this->actor.params], 3.0f); - this->actionFunc = BossSst_HandFall; -} - -void BossSst_HandFall(BossSst* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x400); - this->actor.world.pos.y = sHead->actor.world.pos.y + 230.0f; - if (sHead->actionFunc == BossSst_HeadMelt) { - BossSst_HandSetupMelt(this); - } -} - -void BossSst_HandSetupMelt(BossSst* this) { - BossSst_SpawnHandShadow(this); - this->actor.shape.shadowDraw = NULL; - this->timer = 80; - this->actionFunc = BossSst_HandMelt; -} - -void BossSst_HandMelt(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - this->actor.scale.y -= 0.00025f; - this->actor.scale.x += 0.000025f; - this->actor.scale.z += 0.000025f; - this->actor.world.pos.y = ROOM_CENTER_Y + 0.0f; - if (this->timer == 0) { - BossSst_HandSetupFinish(this); - } -} - -void BossSst_HandSetupFinish(BossSst* this) { - this->actor.draw = BossSst_DrawEffect; - this->timer = 20; - this->effects[0].status = 0; - this->actionFunc = BossSst_HandFinish; -} - -void BossSst_HandFinish(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - this->effectMode = BONGO_NULL; - } -} - -void BossSst_HandSetupRecover(BossSst* this) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandPushoffPoses[this->actor.params], 10.0f); - this->ready = false; - this->actionFunc = BossSst_HandRecover; -} - -void BossSst_HandRecover(BossSst* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.world.pos.y, ROOM_CENTER_Y + 250.0f, 0.5f, 70.0f, 5.0f); - if (SkelAnime_Update(&this->skelAnime)) { - if (!this->ready) { - Animation_MorphToPlayOnce(&this->skelAnime, sHandHangPoses[this->actor.params], 10.0f); - this->ready = true; - } - } - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); -} - -void BossSst_HandSetupFrozen(BossSst* this) { - s32 i; - - HAND_STATE(this) = HAND_FROZEN; - Math_Vec3f_Copy(&this->center, &this->actor.world.pos); - BossSst_HandSetupReadyBreakIce(OTHER_HAND(this)); - this->ready = false; - this->effectMode = BONGO_ICE; - this->timer = 35; - for (i = 0; i < 18; i++) { - this->effects[i].move = false; - } - - BossSst_SpawnIceCrystal(this, 0); - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0xA); - this->handAngSpeed = 0; - this->actionFunc = BossSst_HandFrozen; -} - -void BossSst_HandFrozen(BossSst* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if ((this->timer % 2) != 0) { - BossSst_SpawnIceCrystal(this, (this->timer >> 1) + 1); - } - - if (this->ready) { - BossSst_IceShatter(this); - BossSst_HandSetupRetreat(this); - sHead->ready = true; - } else { - this->actor.colorFilterTimer = 10; - if (this->handAngSpeed != 0) { - f32 offY = Math_SinS(OTHER_HAND(this)->actor.shape.rot.x) * 5.0f; - f32 offXZ = Math_CosS(OTHER_HAND(this)->actor.shape.rot.x) * 5.0f; - - if ((this->handAngSpeed % 2) != 0) { - offY *= -1.0f; - offXZ *= -1.0f; - } - - this->actor.world.pos.x = this->center.x + (Math_CosS(OTHER_HAND(this)->actor.shape.rot.y) * offXZ); - this->actor.world.pos.y = this->center.y + offY; - this->actor.world.pos.z = this->center.z + (Math_SinS(OTHER_HAND(this)->actor.shape.rot.y) * offXZ); - this->handAngSpeed--; - } - } -} - -void BossSst_HandSetupReadyBreakIce(BossSst* this) { - HAND_STATE(this) = HAND_BREAK_ICE; - Animation_MorphToPlayOnce(&this->skelAnime, sHandFistPoses[this->actor.params], 5.0f); - this->ready = false; - this->actor.colorFilterTimer = 0; - if (this->effectMode == BONGO_ICE) { - this->effectMode = BONGO_NULL; - } - - this->radius = Actor_WorldDistXZToPoint(&this->actor, &OTHER_HAND(this)->center); - this->targetYaw = Actor_WorldYawTowardPoint(&this->actor, &OTHER_HAND(this)->center); - BossSst_HandSetInvulnerable(this, true); - this->actionFunc = BossSst_HandReadyBreakIce; -} - -void BossSst_HandReadyBreakIce(BossSst* this, GlobalContext* globalCtx) { - s32 inPosition; - - inPosition = Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x400); - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1000, 0x400); - inPosition &= Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x800); - inPosition &= Math_ScaledStepToS(&this->handYRotMod, 0, 0x400); - inPosition &= Math_StepToF(&this->actor.world.pos.y, OTHER_HAND(this)->center.y + 200.0f, 50.0f); - inPosition &= Math_StepToF(&this->radius, 400.0f, 60.0f); - this->actor.world.pos.x = OTHER_HAND(this)->center.x - (Math_SinS(this->targetYaw) * this->radius); - this->actor.world.pos.z = OTHER_HAND(this)->center.z - (Math_CosS(this->targetYaw) * this->radius); - if (SkelAnime_Update(&this->skelAnime) && inPosition) { - BossSst_HandSetupBreakIce(this); - } -} - -void BossSst_HandSetupBreakIce(BossSst* this) { - this->timer = 9; - this->actionFunc = BossSst_HandBreakIce; - this->actor.speedXZ = 0.5f; -} - -void BossSst_HandBreakIce(BossSst* this, GlobalContext* globalCtx) { - if ((this->timer % 2) != 0) { - this->actor.speedXZ *= 1.5f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 60.0f); - - if (Math_StepToF(&this->radius, 100.0f, this->actor.speedXZ)) { - BossSst_SpawnIceShard(this); - if (this->timer != 0) { - this->timer--; - } - - if (this->timer != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); - } - - OTHER_HAND(this)->handAngSpeed = 5; - } - } else { - this->actor.speedXZ *= 0.8f; - Math_StepToF(&this->radius, 500.0f, this->actor.speedXZ); - if (this->actor.speedXZ < 2.0f) { - if (this->timer != 0) { - this->timer--; - } - } - } - - this->actor.world.pos.x = OTHER_HAND(this)->center.x - (Math_SinS(this->targetYaw) * this->radius); - this->actor.world.pos.z = OTHER_HAND(this)->center.z - (Math_CosS(this->targetYaw) * this->radius); - this->actor.world.pos.y = OTHER_HAND(this)->center.y + (this->radius * 0.4f); - if (this->timer == 0) { - OTHER_HAND(this)->ready = true; - BossSst_HandSetupRetreat(this); - } - - func_8002F974(&this->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); -} - -void BossSst_HandGrabPlayer(BossSst* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (globalCtx->grabPlayer(globalCtx, player)) { - player->actor.parent = &this->actor; - if (player->actor.colChkInfo.health > 0) { - this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - if (HAND_STATE(this) == HAND_CLAP) { - OTHER_HAND(this)->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - } - } - } -} - -void BossSst_HandReleasePlayer(BossSst* this, GlobalContext* globalCtx, s32 dropPlayer) { - Player* player = GET_PLAYER(globalCtx); - - if (player->actor.parent == &this->actor) { - player->actor.parent = NULL; - player->unk_850 = 100; - this->colliderJntSph.base.ocFlags1 |= OC1_ON; - OTHER_HAND(this)->colliderJntSph.base.ocFlags1 |= OC1_ON; - if (dropPlayer) { - func_8002F71C(globalCtx, &this->actor, 0.0f, this->actor.shape.rot.y, 0.0f); - } - } -} - -void BossSst_MoveAround(BossSst* this) { - BossSst* hand; - Vec3f* vec; - f32 sn; - f32 cs; - s32 i; - - sn = Math_SinS(this->actor.shape.rot.y); - cs = Math_CosS(this->actor.shape.rot.y); - if (this->actionFunc != BossSst_HeadEndCharge) { - this->actor.world.pos.x = sRoomCenter.x + (this->radius * sn); - this->actor.world.pos.z = sRoomCenter.z + (this->radius * cs); - } - - for (i = 0; i < 2; i++) { - hand = sHands[i]; - vec = &sHandOffsets[i]; - - hand->actor.world.pos.x = this->actor.world.pos.x + (vec->z * sn) + (vec->x * cs); - hand->actor.world.pos.y = this->actor.world.pos.y + vec->y; - hand->actor.world.pos.z = this->actor.world.pos.z + (vec->z * cs) - (vec->x * sn); - - hand->actor.home.pos.x = this->actor.world.pos.x + (400.0f * sn) + (-200.0f * hand->vParity * cs); - hand->actor.home.pos.y = this->actor.world.pos.y; - hand->actor.home.pos.z = this->actor.world.pos.z + (400.0f * cs) - (-200.0f * hand->vParity * sn); - - hand->actor.home.rot.y = this->actor.shape.rot.y; - hand->actor.shape.rot.y = sHandYawOffsets[i] + this->actor.shape.rot.y; - - if (hand->actor.world.pos.y < hand->actor.floorHeight) { - hand->actor.world.pos.y = hand->actor.floorHeight; - } - } -} - -void BossSst_HandSelectAttack(BossSst* this) { - f32 rand = Rand_ZeroOne() * 6.0f; - s32 randInt; - - if (HAND_STATE(OTHER_HAND(this)) == HAND_DAMAGED) { - rand *= 5.0f / 6; - if (rand > 4.0f) { - rand = 4.0f; - } - } - - randInt = rand; - if (randInt == 0) { - BossSst_HandSetupReadySlam(this); - } else if (randInt == 1) { - BossSst_HandSetupReadySweep(this); - } else if (randInt == 2) { - BossSst_HandSetupReadyPunch(this); - } else if (randInt == 5) { - BossSst_HandSetupReadyClap(this); - } else { // randInt == 3 || randInt == 4 - BossSst_HandSetupReadyGrab(this); - } -} - -void BossSst_HandSetDamage(BossSst* this, s32 damage) { - s32 i; - - this->colliderJntSph.base.atFlags |= AT_ON; - for (i = 0; i < 11; i++) { - this->colliderJntSph.elements[i].info.toucher.damage = damage; - } -} - -void BossSst_HandSetInvulnerable(BossSst* this, s32 isInv) { - this->colliderJntSph.base.acFlags &= ~AC_HIT; - if (isInv) { - this->colliderJntSph.base.colType = COLTYPE_HARD; - this->colliderJntSph.base.acFlags |= AC_HARD; - } else { - this->colliderJntSph.base.colType = COLTYPE_HIT0; - this->colliderJntSph.base.acFlags &= ~AC_HARD; - } -} - -void BossSst_HeadSfx(BossSst* this, u16 sfxId) { - func_80078914(&this->center, sfxId); -} - -void BossSst_HandCollisionCheck(BossSst* this, GlobalContext* globalCtx) { - if ((this->colliderJntSph.base.acFlags & AC_HIT) && (this->colliderJntSph.base.colType != COLTYPE_HARD)) { - s32 bothHands = true; - - this->colliderJntSph.base.acFlags &= ~AC_HIT; - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - this->colliderJntSph.base.acFlags &= ~AC_ON; - this->colliderJntSph.base.ocFlags1 &= ~OC1_NO_PUSH; - BossSst_HandReleasePlayer(this, globalCtx, true); - if (HAND_STATE(OTHER_HAND(this)) == HAND_CLAP) { - BossSst_HandReleasePlayer(OTHER_HAND(this), globalCtx, true); - BossSst_HandSetupRetreat(OTHER_HAND(this)); - } - - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->actor.colChkInfo.damageEffect == 3) { - BossSst_HandSetupFrozen(this); - } else { - BossSst_HandSetupReel(this); - if (HAND_STATE(OTHER_HAND(this)) != HAND_DAMAGED) { - bothHands = false; - } - } - - BossSst_HeadSetupDamagedHand(sHead, bothHands); - Item_DropCollectible(globalCtx, &this->actor.world.pos, - (Rand_ZeroOne() < 0.5f) ? ITEM00_ARROWS_SMALL : ITEM00_MAGIC_SMALL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_DAMAGE_HAND); - } - } -} - -void BossSst_HeadCollisionCheck(BossSst* this, GlobalContext* globalCtx) { - if (this->colliderCyl.base.acFlags & AC_HIT) { - this->colliderCyl.base.acFlags &= ~AC_HIT; - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (this->actionFunc == BossSst_HeadVulnerable) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - BossSst_HeadSetupDeath(this, globalCtx); - } else { - BossSst_HeadSetupDamage(this); - } - - BossSst_HandSetupDamage(sHands[LEFT]); - BossSst_HandSetupDamage(sHands[RIGHT]); - } else { - BossSst_HeadSetupStunned(this); - if (HAND_STATE(sHands[RIGHT]) == HAND_FROZEN) { - BossSst_IceShatter(sHands[RIGHT]); - } else if (HAND_STATE(sHands[LEFT]) == HAND_FROZEN) { - BossSst_IceShatter(sHands[LEFT]); - } - - BossSst_HandSetupStunned(sHands[RIGHT]); - BossSst_HandSetupStunned(sHands[LEFT]); - } - } - } -} - -void BossSst_UpdateHand(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossSst* this = (BossSst*)thisx; - BossSstHandTrail* trail; - - if (this->colliderCyl.base.atFlags & AT_ON) { - if ((this->effects[0].move < 5) || - (this->actor.xzDistToPlayer < ((this->effects[2].scale * 0.01f) * sCylinderInitHand.dim.radius)) || - (this->colliderCyl.base.atFlags & AT_HIT)) { - this->colliderCyl.base.atFlags &= ~(AT_ON | AT_HIT); - } else { - this->colliderCyl.dim.radius = (this->effects[0].scale * 0.01f) * sCylinderInitHand.dim.radius; - } - } - - BossSst_HandCollisionCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 130.0f, 0.0f, 5); - Actor_SetFocus(&this->actor, 0.0f); - if (this->colliderJntSph.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - - if ((sHead->actionFunc != BossSst_HeadLurk) && (sHead->actionFunc != BossSst_HeadIntro) && - (this->colliderJntSph.base.acFlags & AC_ON)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - - if (this->colliderJntSph.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - - if (this->colliderCyl.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCyl.base); - } - - if ((HAND_STATE(this) != HAND_DEATH) && (HAND_STATE(this) != HAND_WAIT) && (HAND_STATE(this) != HAND_BEAT) && - (HAND_STATE(this) != HAND_FROZEN)) { - this->trailCount++; - this->trailCount = CLAMP_MAX(this->trailCount, 7); - } else { - this->trailCount--; - this->trailCount = CLAMP_MIN(this->trailCount, 0); - } - - trail = &this->handTrails[this->trailIndex]; - Math_Vec3f_Copy(&trail->world.pos, &this->actor.world.pos); - trail->world.rot = this->actor.shape.rot; - trail->zPosMod = this->handZPosMod; - trail->yRotMod = this->handYRotMod; - - this->trailIndex = (this->trailIndex + 1) % 7; - BossSst_UpdateEffect(&this->actor, globalCtx); -} - -void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossSst* this = (BossSst*)thisx; - - func_8002DBD0(&this->actor, &sHandOffsets[RIGHT], &sHands[RIGHT]->actor.world.pos); - func_8002DBD0(&this->actor, &sHandOffsets[LEFT], &sHands[LEFT]->actor.world.pos); - - sHandYawOffsets[LEFT] = sHands[LEFT]->actor.shape.rot.y - thisx->shape.rot.y; - sHandYawOffsets[RIGHT] = sHands[RIGHT]->actor.shape.rot.y - thisx->shape.rot.y; - - BossSst_HeadCollisionCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - if (this->vVanish) { - if ((globalCtx->actorCtx.unk_03 == 0) || (thisx->colorFilterTimer != 0)) { - this->actor.flags &= ~ACTOR_FLAG_7; - } else { - this->actor.flags |= ACTOR_FLAG_7; - } - } - - if (this->colliderJntSph.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - - if ((this->actionFunc != BossSst_HeadLurk) && (this->actionFunc != BossSst_HeadIntro)) { - if (this->colliderCyl.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCyl.base); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - - if (this->colliderJntSph.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); - } - - BossSst_MoveAround(this); - if ((!this->vVanish || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) && - ((this->actionFunc == BossSst_HeadReadyCharge) || (this->actionFunc == BossSst_HeadCharge) || - (this->actionFunc == BossSst_HeadFrozenHand) || (this->actionFunc == BossSst_HeadStunned) || - (this->actionFunc == BossSst_HeadVulnerable) || (this->actionFunc == BossSst_HeadDamage))) { - this->actor.flags |= ACTOR_FLAG_0; - } else { - this->actor.flags &= ~ACTOR_FLAG_0; - } - - if (this->actionFunc == BossSst_HeadCharge) { - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_MOVE - SFX_FLAG); - } - - BossSst_UpdateEffect(&this->actor, globalCtx); -} - -s32 BossSst_OverrideHandDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - BossSst* this = (BossSst*)thisx; - - if (limbIndex == 1) { - pos->z += this->handZPosMod; - rot->y += this->handYRotMod; - } - return false; -} - -void BossSst_PostHandDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - BossSst* this = (BossSst*)thisx; - - Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); -} - -s32 BossSst_OverrideHandTrailDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* data, Gfx** gfx) { - BossSstHandTrail* trail = (BossSstHandTrail*)data; - - if (limbIndex == 1) { - pos->z += trail->zPosMod; - rot->y += trail->yRotMod; - } - return false; -} - -void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { - BossSst* this = (BossSst*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6563); - - func_80093D18(globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x80, sBodyColor.r, sBodyColor.g, sBodyColor.b, 255); - - if (!sBodyStatic) { - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - } else { - gDPSetEnvColor(POLY_OPA_DISP++, sStaticColor.r, sStaticColor.g, sStaticColor.b, 0); - gSPSegment(POLY_OPA_DISP++, 0x08, sBodyStaticDList); - } - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - BossSst_OverrideHandDraw, BossSst_PostHandDraw, this); - if (this->trailCount >= 2) { - BossSstHandTrail* trail; - BossSstHandTrail* trail2; - s32 i; - s32 idx; - s32 end; - s32 pad; - - func_80093D84(globalCtx->state.gfxCtx); - - end = this->trailCount >> 1; - idx = (this->trailIndex + 4) % 7; - trail = &this->handTrails[idx]; - trail2 = &this->handTrails[(idx + 2) % 7]; - - for (i = 0; i < end; i++) { - if (Math3D_Vec3fDistSq(&trail2->world.pos, &trail->world.pos) > 900.0f) { - func_800D1694(trail->world.pos.x, trail->world.pos.y, trail->world.pos.z, &trail->world.rot); - Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); - - gSPSegment(POLY_XLU_DISP++, 0x08, sHandTrailDList); - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, ((3 - i) * 10) + 20, 0, ((3 - i) * 20) + 50, - ((3 - i) * 30) + 70); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossSst_OverrideHandTrailDraw, NULL, - trail, POLY_XLU_DISP); - } - idx = (idx + 5) % 7; - trail2 = trail; - trail = &this->handTrails[idx]; - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6654); - - BossSst_DrawEffect(&this->actor, globalCtx); -} - -s32 BossSst_OverrideHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - BossSst* this = (BossSst*)thisx; - s32 shakeAmp; - s32 pad; - s32 timer12; - f32 shakeMod; - - if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7) && this->vVanish) { - *dList = NULL; - } else if (this->actionFunc == BossSst_HeadThrash) { // Animation modifications for death cutscene - shakeAmp = (this->timer / 10) + 1; - if ((limbIndex == 3) || (limbIndex == 39) || (limbIndex == 42)) { - - shakeMod = sinf(this->timer * (M_PI / 5)); - rot->x += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; - - shakeMod = sinf((this->timer % 5) * (M_PI / 5)); - rot->z -= ((0x800 * Rand_ZeroOne() + 0x1000) / 0x10) * shakeAmp * shakeMod + 0x1000; - - if (limbIndex == 3) { - - shakeMod = sinf(this->timer * (M_PI / 5)); - rot->y += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; - } - } else if ((limbIndex == 5) || (limbIndex == 6)) { - - shakeMod = sinf((this->timer % 5) * (M_PI / 5)); - rot->z -= ((0x280 * Rand_ZeroOne() + 0x500) / 0x10) * shakeAmp * shakeMod + 0x500; - - if (limbIndex == 5) { - - shakeMod = sinf(this->timer * (M_PI / 5)); - rot->x += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; - - shakeMod = sinf(this->timer * (M_PI / 5)); - rot->y += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; - } - } else if (limbIndex == 2) { - shakeMod = sinf(this->timer * (M_PI / 5)); - rot->x += ((0x200 * Rand_ZeroOne() + 0x400) / 0x10) * shakeAmp * shakeMod; - - shakeMod = sinf(this->timer * (M_PI / 5)); - rot->y += ((0x200 * Rand_ZeroOne() + 0x400) / 0x10) * shakeAmp * shakeMod; - - shakeMod = sinf((this->timer % 5) * (M_PI / 5)); - rot->z -= ((0x100 * Rand_ZeroOne() + 0x200) / 0x10) * shakeAmp * shakeMod + 0x200; - } - } else if (this->actionFunc == BossSst_HeadDeath) { - if (this->timer > 48) { - timer12 = this->timer - 36; - } else { - pad = ((this->timer > 6) ? 6 : this->timer); - timer12 = pad * 2; - } - - if ((limbIndex == 3) || (limbIndex == 39) || (limbIndex == 42)) { - rot->z -= 0x2000 * sinf(timer12 * (M_PI / 24)); - } else if ((limbIndex == 5) || (limbIndex == 6)) { - rot->z -= 0xA00 * sinf(timer12 * (M_PI / 24)); - } else if (limbIndex == 2) { - rot->z -= 0x400 * sinf(timer12 * (M_PI / 24)); - } - } else if ((this->actionFunc == BossSst_HeadDarken) || (this->actionFunc == BossSst_HeadFall) || - (this->actionFunc == BossSst_HeadMelt)) { - if ((limbIndex == 3) || (limbIndex == 39) || (limbIndex == 42)) { - rot->z -= 0x1000; - } else if ((limbIndex == 5) || (limbIndex == 6)) { - rot->z -= 0x500; - } else if (limbIndex == 2) { - rot->z -= 0x200; - } - } - return false; -} - -void BossSst_PostHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - static Vec3f headVec = { 1000.0f, 0.0f, 0.0f }; - BossSst* this = (BossSst*)thisx; - Vec3f headPos; - - if (limbIndex == 8) { - Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); - Matrix_MultVec3f(&headVec, &headPos); - this->colliderCyl.dim.pos.x = headPos.x; - this->colliderCyl.dim.pos.y = headPos.y; - this->colliderCyl.dim.pos.z = headPos.z; - } - - Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); -} - -void BossSst_DrawHead(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossSst* this = (BossSst*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6810); - - if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x80, sBodyColor.r, sBodyColor.g, sBodyColor.b, 255); - if (!sBodyStatic) { - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - } else { - gDPSetEnvColor(POLY_OPA_DISP++, sStaticColor.r, sStaticColor.g, sStaticColor.b, 0); - gSPSegment(POLY_OPA_DISP++, 0x08, sBodyStaticDList); - } - } else { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, 255); - gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[2]); - } - - if (this->actionFunc == BossSst_HeadThrash) { - f32 randPitch = Rand_ZeroOne() * (2 * M_PI); - f32 randYaw = Rand_ZeroOne() * (2 * M_PI); - - Matrix_RotateY(randYaw, MTXMODE_APPLY); - Matrix_RotateX(randPitch, MTXMODE_APPLY); - Matrix_Scale((this->timer * 0.000375f) + 1.0f, 1.0f - (this->timer * 0.00075f), - (this->timer * 0.000375f) + 1.0f, MTXMODE_APPLY); - Matrix_RotateX(-randPitch, MTXMODE_APPLY); - Matrix_RotateY(-randYaw, MTXMODE_APPLY); - } - - if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossSst_OverrideHeadDraw, BossSst_PostHeadDraw, - this, POLY_OPA_DISP); - } else { - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossSst_OverrideHeadDraw, BossSst_PostHeadDraw, - this, POLY_XLU_DISP); - } - - if ((this->actionFunc == BossSst_HeadIntro) && (113 >= this->timer) && (this->timer > 20)) { - s32 yOffset; - Vec3f vanishMaskPos; - Vec3f vanishMaskOffset; - - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 18, 255); - - yOffset = 113 * 8 - this->timer * 8; - vanishMaskPos.x = ROOM_CENTER_X + 85.0f; - vanishMaskPos.y = ROOM_CENTER_Y - 250.0f + yOffset; - vanishMaskPos.z = ROOM_CENTER_Z + 190.0f; - if (vanishMaskPos.y > 450.0f) { - vanishMaskPos.y = 450.0f; - } - - Matrix_MultVec3fExt(&vanishMaskPos, &vanishMaskOffset, &globalCtx->billboardMtxF); - Matrix_Translate(this->actor.world.pos.x + vanishMaskOffset.x, this->actor.world.pos.y + vanishMaskOffset.y, - this->actor.world.pos.z + vanishMaskOffset.z, MTXMODE_NEW); - Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6934), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, sIntroVanishDList); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6941); - - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &this->actor.focus.pos, &this->center); - BossSst_DrawEffect(&this->actor, globalCtx); -} - -void BossSst_SpawnHeadShadow(BossSst* this) { - static Vec3f shadowOffset[] = { - { 0.0f, 0.0f, 340.0f }, - { -160.0f, 0.0f, 250.0f }, - { 160.0f, 0.0f, 250.0f }, - }; - s32 pad; - s32 i; - f32 sn; - f32 cs; - - this->effectMode = BONGO_SHADOW; - sn = Math_SinS(this->actor.shape.rot.y); - cs = Math_CosS(this->actor.shape.rot.y); - - for (i = 0; i < 3; i++) { - BossSstEffect* shadow = &this->effects[i]; - Vec3f* offset = &shadowOffset[i]; - - shadow->pos.x = this->actor.world.pos.x + (sn * offset->z) + (cs * offset->x); - shadow->pos.y = 0.0f; - shadow->pos.z = this->actor.world.pos.z + (cs * offset->z) - (sn * offset->x); - - shadow->scale = 1450; - shadow->alpha = 254; - shadow->status = 65; - } - - this->effects[3].status = -1; -} - -void BossSst_SpawnHandShadow(BossSst* this) { - this->effectMode = BONGO_SHADOW; - this->effects[0].pos.x = this->actor.world.pos.x + (Math_CosS(this->actor.shape.rot.y) * 30.0f * this->vParity); - this->effects[0].pos.z = this->actor.world.pos.z - (Math_SinS(this->actor.shape.rot.y) * 30.0f * this->vParity); - this->effects[0].pos.y = this->actor.world.pos.y; - this->effects[0].scale = 2300; - this->effects[0].alpha = 254; - this->effects[0].status = 5; - this->effects[1].status = -1; -} - -void BossSst_SpawnShockwave(BossSst* this) { - s32 i; - s32 scale = 120; - s32 alpha = 250; - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHADEST_HAND_WAVE); - this->effectMode = BONGO_SHOCKWAVE; - - for (i = 0; i < 3; i++) { - BossSstEffect* shockwave = &this->effects[i]; - - Math_Vec3f_Copy(&shockwave->pos, &this->actor.world.pos); - shockwave->move = (i + 9) * 2; - shockwave->scale = scale; - shockwave->alpha = alpha / shockwave->move; - scale -= 50; - alpha -= 25; - } -} - -void BossSst_SpawnIceCrystal(BossSst* this, s32 index) { - BossSstEffect* ice = &this->effects[index]; - Sphere16* sphere; - - if (index < 11) { - sphere = &this->colliderJntSph.elements[index].dim.worldSphere; - - ice->pos.x = sphere->center.x; - ice->pos.y = sphere->center.y; - ice->pos.z = sphere->center.z; - if (index == 0) { - ice->pos.x -= 25.0f; - ice->pos.y -= 25.0f; - ice->pos.z -= 25.0f; - } - } else { - sphere = &this->colliderJntSph.elements[0].dim.worldSphere; - - ice->pos.x = ((((index - 11) & 1) ? 1 : -1) * 25.0f) + sphere->center.x; - ice->pos.y = ((((index - 11) & 2) ? 1 : -1) * 25.0f) + sphere->center.y; - ice->pos.z = ((((index - 11) & 4) ? 1 : -1) * 25.0f) + sphere->center.z; - } - - ice->pos.x -= this->actor.world.pos.x; - ice->pos.y -= this->actor.world.pos.y; - ice->pos.z -= this->actor.world.pos.z; - - ice->status = 0; - - ice->rot.x = Rand_ZeroOne() * 0x10000; - ice->rot.y = Rand_ZeroOne() * 0x10000; - ice->rot.z = Rand_ZeroOne() * 0x10000; - - ice->alpha = 120; - ice->move = true; - - ice->vel.x = (Rand_ZeroOne() * 0.06f + 0.12f) * ice->pos.x; - ice->vel.y = (Rand_ZeroOne() * 15.0f + 5.0f); - ice->vel.z = (Rand_ZeroOne() * 0.06f + 0.12f) * ice->pos.z; - ice->scale = 4000; - - if ((index % 2) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_FREEZE_S); - } -} - -void BossSst_SpawnIceShard(BossSst* this) { - s32 i; - Vec3f spawnPos; - f32 offXZ; - - this->effectMode = BONGO_ICE; - offXZ = Math_CosS(this->actor.shape.rot.x) * 50.0f; - spawnPos.x = Math_CosS(this->actor.shape.rot.y) * offXZ + this->actor.world.pos.x; - spawnPos.y = Math_SinS(this->actor.shape.rot.x) * 50.0f + this->actor.world.pos.y - 10.0f; - spawnPos.z = Math_SinS(this->actor.shape.rot.y) * offXZ + this->actor.world.pos.z; - - for (i = 0; i < 18; i++) { - BossSstEffect* ice = &this->effects[i]; - - Math_Vec3f_Copy(&ice->pos, &spawnPos); - ice->status = 1; - ice->rot.x = Rand_ZeroOne() * 0x10000; - ice->rot.y = Rand_ZeroOne() * 0x10000; - ice->rot.z = Rand_ZeroOne() * 0x10000; - - ice->alpha = 120; - ice->move = true; - - ice->vel.x = Rand_CenteredFloat(20.0f); - ice->vel.y = Rand_ZeroOne() * 10.0f + 3.0f; - ice->vel.z = Rand_CenteredFloat(20.0f); - - ice->scale = Rand_ZeroOne() * 200.0f + 400.0f; - } -} - -void BossSst_IceShatter(BossSst* this) { - s32 i; - - this->effects[0].status = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_PL_ICE_BROKEN); - - for (i = 0; i < 18; i++) { - BossSstEffect* ice = &this->effects[i]; - - if (ice->move) { - ice->pos.x += this->actor.world.pos.x; - ice->pos.y += this->actor.world.pos.y; - ice->pos.z += this->actor.world.pos.z; - } - } -} - -void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx) { - BossSst* this = (BossSst*)thisx; - BossSstEffect* effect; - s32 i; - - if (this->effectMode != BONGO_NULL) { - if (this->effectMode == BONGO_ICE) { - if (this->effects[0].status) { - for (i = 0; i < 18; i++) { - effect = &this->effects[i]; - - if (effect->move) { - effect->pos.x += effect->vel.x; - effect->pos.y += effect->vel.y; - effect->pos.z += effect->vel.z; - effect->alpha -= 3; - effect->vel.y -= 1.0f; - effect->rot.x += 0xD00; - effect->rot.y += 0x1100; - effect->rot.z += 0x1500; - } - } - } - if (this->effects[0].alpha == 0) { - this->effectMode = BONGO_NULL; - } - } else if (this->effectMode == BONGO_SHOCKWAVE) { - for (i = 0; i < 3; i++) { - BossSstEffect* effect2 = &this->effects[i]; - s32 scale = effect2->move * 2; - - effect2->scale += CLAMP_MAX(scale, 20) + i; - if (effect2->move != 0) { - effect2->move--; - } - } - - if (this->effects[0].move == 0) { - this->effectMode = BONGO_NULL; - } - } else if (this->effectMode == BONGO_SHADOW) { - effect = &this->effects[0]; - - if (this->actor.params == BONGO_HEAD) { - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &this->actor.focus.pos, &this->center); - BossSst_HeadSfx(this, NA_SE_EN_SHADEST_LAST - SFX_FLAG); - } - while (effect->status != -1) { - if (effect->status == 0) { - effect->alpha -= 2; - } else { - effect->scale += effect->status; - } - - effect->scale = CLAMP_MAX(effect->scale, 10000); - effect++; - } - } - } -} - -void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - BossSst* this = (BossSst*)thisx; - s32 i; - BossSstEffect* effect; - - if (this->effectMode != BONGO_NULL) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7302); - - func_80093D84(globalCtx->state.gfxCtx); - if (this->effectMode == BONGO_ICE) { - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->gameplayFrames % 256, 0x20, 0x10, 1, - 0, (globalCtx->gameplayFrames * 2) % 256, 0x40, 0x20)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, this->effects[0].alpha); - gSPDisplayList(POLY_XLU_DISP++, gBongoIceCrystalDL); - - for (i = 0; i < 18; i++) { - effect = &this->effects[i]; - if (effect->move) { - func_8003435C(&effect->pos, globalCtx); - if (this->effects[0].status != 0) { - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - } else { - Matrix_Translate(effect->pos.x + this->actor.world.pos.x, - effect->pos.y + this->actor.world.pos.y, - effect->pos.z + this->actor.world.pos.z, MTXMODE_NEW); - } - - Matrix_RotateZYX(effect->rot.x, effect->rot.y, effect->rot.z, MTXMODE_APPLY); - Matrix_Scale(effect->scale * 0.001f, effect->scale * 0.001f, effect->scale * 0.001f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7350), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBongoIceShardDL); - } - } - } else if (this->effectMode == BONGO_SHOCKWAVE) { - f32 scaleY = 0.005f; - - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, 0, 0x20, 0x40, 1, - 0, (globalCtx->gameplayFrames * -15) % 256, 0x20, 0x40)); - - for (i = 0; i < 3; i++, scaleY -= 0.001f) { - effect = &this->effects[i]; - - if (effect->move != 0) { - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->scale * 0.001f, scaleY, effect->scale * 0.001f, MTXMODE_APPLY); - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 30, 0, 30, effect->alpha * effect->move); - gDPSetEnvColor(POLY_XLU_DISP++, 30, 0, 30, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7396), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFireCircleDL); - } - } - } else if (this->effectMode == BONGO_SHADOW) { - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 10, 10, 80, 0); - gDPSetEnvColor(POLY_XLU_DISP++, 10, 10, 10, this->effects[0].alpha); - - effect = &this->effects[0]; - while (effect->status != -1) { - Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_Scale(effect->scale * 0.001f, 1.0f, effect->scale * 0.001f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7423), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, sShadowDList); - effect++; - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7433); - } -} diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.cpp b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.cpp new file mode 100644 index 000000000..41ad50d96 --- /dev/null +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.cpp @@ -0,0 +1,3244 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_BOSS_SST_Z_BOSS_SST_C +#include "actor_common.h" +/* + * File: z_boss_sst.c + * Overlay: ovl_Boss_Sst + * Description: Bongo Bongo + */ + +#include "z_boss_sst.h" +#include "objects/object_sst/object_sst.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin_matrix.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_10) + +#define vParity actionVar +#define vVanish actionVar + +#define LEFT 0 +#define RIGHT 1 +#define OTHER_HAND(hand) ((BossSst*)hand->actor.child) +#define HAND_STATE(hand) sHandState[hand->actor.params] + +#define ROOM_CENTER_X -50.0f +#define ROOM_CENTER_Y 0.0f +#define ROOM_CENTER_Z 0.0f + +typedef enum { + /* 0 */ HAND_WAIT, + /* 1 */ HAND_BEAT, + /* 2 */ HAND_RETREAT, + /* 3 */ HAND_SLAM, + /* 4 */ HAND_SWEEP, + /* 5 */ HAND_PUNCH, + /* 6 */ HAND_CLAP, + /* 7 */ HAND_GRAB, + /* 8 */ HAND_DAMAGED, + /* 9 */ HAND_FROZEN, + /* 10 */ HAND_BREAK_ICE, + /* 11 */ HAND_DEATH +} BossSstHandState; + +typedef enum { + /* 0 */ BONGO_NULL, + /* 1 */ BONGO_ICE, + /* 2 */ BONGO_SHOCKWAVE, + /* 3 */ BONGO_SHADOW +} BossSstEffectMode; + +void BossSst_Init(Actor* thisx, GlobalContext* globalCtx); +void BossSst_Destroy(Actor* thisx, GlobalContext* globalCtx); +void BossSst_UpdateHand(Actor* thisx, GlobalContext* globalCtx); +void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx); +void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx); +void BossSst_DrawHead(Actor* thisx, GlobalContext* globalCtx); +void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx); +void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx); + +void BossSst_HeadSfx(BossSst* pthis, u16 sfxId); + +void BossSst_HeadSetupLurk(BossSst* pthis); +void BossSst_HeadLurk(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupIntro(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadIntro(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupNeutral(BossSst* pthis); +void BossSst_HeadNeutral(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadWait(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HeadSetupDamagedHand(BossSst* pthis, s32 bothHands); +void BossSst_HeadDamagedHand(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupReadyCharge(BossSst* pthis); +void BossSst_HeadReadyCharge(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupCharge(BossSst* pthis); +void BossSst_HeadCharge(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupEndCharge(BossSst* pthis); +void BossSst_HeadEndCharge(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HeadSetupFrozenHand(BossSst* pthis); +void BossSst_HeadFrozenHand(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupUnfreezeHand(BossSst* pthis); +void BossSst_HeadUnfreezeHand(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HeadStunned(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupVulnerable(BossSst* pthis); +void BossSst_HeadVulnerable(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadDamage(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupRecover(BossSst* pthis); +void BossSst_HeadRecover(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HeadDeath(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupThrash(BossSst* pthis); +void BossSst_HeadThrash(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupDarken(BossSst* pthis); +void BossSst_HeadDarken(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupFall(BossSst* pthis); +void BossSst_HeadFall(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupMelt(BossSst* pthis); +void BossSst_HeadMelt(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HeadSetupFinish(BossSst* pthis); +void BossSst_HeadFinish(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandGrabPlayer(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandReleasePlayer(BossSst* pthis, GlobalContext* globalCtx, s32 dropPlayer); +void BossSst_HandSelectAttack(BossSst* pthis); +void BossSst_HandSetDamage(BossSst* pthis, s32 damage); +void BossSst_HandSetInvulnerable(BossSst* pthis, s32 isInv); + +void BossSst_HandSetupWait(BossSst* pthis); +void BossSst_HandWait(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupDownbeat(BossSst* pthis); +void BossSst_HandDownbeat(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupOffbeat(BossSst* pthis); +void BossSst_HandOffbeat(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupDownbeatEnd(BossSst* pthis); +void BossSst_HandDownbeatEnd(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupOffbeatEnd(BossSst* pthis); +void BossSst_HandOffbeatEnd(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandReadySlam(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupSlam(BossSst* pthis); +void BossSst_HandSlam(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandEndSlam(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandReadySweep(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupSweep(BossSst* pthis); +void BossSst_HandSweep(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandReadyPunch(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupPunch(BossSst* pthis); +void BossSst_HandPunch(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandReadyClap(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupClap(BossSst* pthis); +void BossSst_HandClap(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupEndClap(BossSst* pthis); +void BossSst_HandEndClap(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandReadyGrab(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupGrab(BossSst* pthis); +void BossSst_HandGrab(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupCrush(BossSst* pthis); +void BossSst_HandCrush(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupEndCrush(BossSst* pthis); +void BossSst_HandEndCrush(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupSwing(BossSst* pthis); +void BossSst_HandSwing(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandSetupRetreat(BossSst* pthis); +void BossSst_HandRetreat(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandSetupReel(BossSst* pthis); +void BossSst_HandReel(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupReadyShake(BossSst* pthis); +void BossSst_HandReadyShake(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupShake(BossSst* pthis); +void BossSst_HandShake(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupReadyCharge(BossSst* pthis); +void BossSst_HandReadyCharge(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandSetupFrozen(BossSst* pthis); +void BossSst_HandFrozen(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupReadyBreakIce(BossSst* pthis); +void BossSst_HandReadyBreakIce(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupBreakIce(BossSst* pthis); +void BossSst_HandBreakIce(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandStunned(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandDamage(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupRecover(BossSst* pthis); +void BossSst_HandRecover(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_HandSetupThrash(BossSst* pthis); +void BossSst_HandThrash(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupDarken(BossSst* pthis); +void BossSst_HandDarken(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupFall(BossSst* pthis); +void BossSst_HandFall(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupMelt(BossSst* pthis); +void BossSst_HandMelt(BossSst* pthis, GlobalContext* globalCtx); +void BossSst_HandSetupFinish(BossSst* pthis); +void BossSst_HandFinish(BossSst* pthis, GlobalContext* globalCtx); + +void BossSst_SpawnHeadShadow(BossSst* pthis); +void BossSst_SpawnHandShadow(BossSst* pthis); +void BossSst_SpawnShockwave(BossSst* pthis); +void BossSst_SpawnIceCrystal(BossSst* pthis, s32 index); +void BossSst_SpawnIceShard(BossSst* pthis); +void BossSst_IceShatter(BossSst* pthis); + +#include "overlays/ovl_Boss_Sst/ovl_Boss_Sst.cpp" + +static BossSst* sHead; +static BossSst* sHands[2]; +static BgSstFloor* sFloor; + +static Vec3f sRoomCenter = { ROOM_CENTER_X, ROOM_CENTER_Y, ROOM_CENTER_Z }; +static Vec3f sHandOffsets[2]; +static s16 sHandYawOffsets[2]; + +static s16 sCutsceneCamera; +static Vec3f sCameraAt = { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 0.0f, ROOM_CENTER_Z + 0.0f }; +static Vec3f sCameraEye = { ROOM_CENTER_X + 150.0f, ROOM_CENTER_Y + 100.0f, ROOM_CENTER_Z + 0.0f }; +static Vec3f sCameraAtVel = { 0.0f, 0.0f, 0.0f }; +static Vec3f sCameraEyeVel = { 0.0f, 0.0f, 0.0f }; + +static Vec3f sCameraAtPoints[] = { + { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 300.0f, ROOM_CENTER_Z + 0.0f }, + { ROOM_CENTER_X + 150.0f, ROOM_CENTER_Y + 300.0f, ROOM_CENTER_Z + 100.0f }, + { ROOM_CENTER_X + 0.0f, ROOM_CENTER_Y + 600.0f, ROOM_CENTER_Z + 100.0f }, + { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 400.0f, ROOM_CENTER_Z + 200.0f }, + { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 200.0f }, + { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 0.0f, ROOM_CENTER_Z + 200.0f }, + { ROOM_CENTER_X - 150.0f, ROOM_CENTER_Y + 0.0f, ROOM_CENTER_Z + 100.0f }, + { ROOM_CENTER_X - 60.0f, ROOM_CENTER_Y + 180.0f, ROOM_CENTER_Z + 730.0f }, +}; + +static Vec3f sCameraEyePoints[] = { + { ROOM_CENTER_X + 250.0f, ROOM_CENTER_Y + 800.0f, ROOM_CENTER_Z + 800.0f }, + { ROOM_CENTER_X - 150.0f, ROOM_CENTER_Y + 700.0f, ROOM_CENTER_Z + 1400.0f }, + { ROOM_CENTER_X + 250.0f, ROOM_CENTER_Y + 100.0f, ROOM_CENTER_Z + 750.0f }, + { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 900.0f }, + { ROOM_CENTER_X + 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 900.0f }, + { ROOM_CENTER_X + 350.0f, ROOM_CENTER_Y + 400.0f, ROOM_CENTER_Z + 1200.0f }, + { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 800.0f }, + { ROOM_CENTER_X - 50.0f, ROOM_CENTER_Y + 200.0f, ROOM_CENTER_Z + 800.0f }, +}; + +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; +static u32 sBodyStatic = false; + +// Unreferenced. Maybe two zero vectors? +static u32 sUnkValues[] = { 0, 0, 0, 0, 0, 0 }; + +static Color_RGBA8 sBodyColor = { 255, 255, 255, 255 }; +static Color_RGBA8 sStaticColor = { 0, 0, 0, 255 }; +static s32 sHandState[] = { HAND_WAIT, HAND_WAIT }; + +ActorInit Boss_Sst_InitVars = { + ACTOR_BOSS_SST, + ACTORCAT_BOSS, + FLAGS, + OBJECT_SST, + sizeof(BossSst), + (ActorFunc)BossSst_Init, + (ActorFunc)BossSst_Destroy, + (ActorFunc)BossSst_UpdateHand, + (ActorFunc)BossSst_DrawHand, +}; + +#include "z_boss_sst_colchk.cpp" + +static AnimationHeader* sHandIdleAnims[] = { &gBongoLeftHandIdleAnim, &gBongoRightHandIdleAnim }; +static AnimationHeader* sHandFlatPoses[] = { &gBongoLeftHandFlatPoseAnim, &gBongoRightHandFlatPoseAnim }; +static AnimationHeader* sHandOpenPoses[] = { &gBongoLeftHandOpenPoseAnim, &gBongoRightHandOpenPoseAnim }; +static AnimationHeader* sHandFistPoses[] = { &gBongoLeftHandFistPoseAnim, &gBongoRightHandFistPoseAnim }; +static AnimationHeader* sHandClenchAnims[] = { &gBongoLeftHandClenchAnim, &gBongoRightHandClenchAnim }; +static AnimationHeader* sHandDamagePoses[] = { &gBongoLeftHandDamagePoseAnim, &gBongoRightHandDamagePoseAnim }; +static AnimationHeader* sHandPushoffPoses[] = { &gBongoLeftHandPushoffPoseAnim, &gBongoRightHandPushoffPoseAnim }; +static AnimationHeader* sHandHangPoses[] = { &gBongoLeftHandHangPoseAnim, &gBongoRightHandHangPoseAnim }; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x29, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), +}; + +void BossSst_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BossSst* pthis = (BossSst*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitCylinder(globalCtx, &pthis->colliderCyl); + Collider_InitJntSph(globalCtx, &pthis->colliderJntSph); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Flags_SetSwitch(globalCtx, 0x14); + if (pthis->actor.params == BONGO_HEAD) { + sFloor = (BgSstFloor*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_SST_FLOOR, sRoomCenter.x, + sRoomCenter.y, sRoomCenter.z, 0, 0, 0, BONGOFLOOR_REST); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBongoHeadSkel, &gBongoHeadEyeOpenIdleAnim, pthis->jointTable, + pthis->morphTable, 45); + ActorShape_Init(&pthis->actor.shape, 70000.0f, ActorShadow_DrawCircle, 95.0f); + Collider_SetJntSph(globalCtx, &pthis->colliderJntSph, &pthis->actor, &sJntSphInitHead, pthis->colliderItems); + Collider_SetCylinder(globalCtx, &pthis->colliderCyl, &pthis->actor, &sCylinderInitHead); + sHead = pthis; + pthis->actor.world.pos.x = ROOM_CENTER_X + 50.0f; + pthis->actor.world.pos.y = ROOM_CENTER_Y + 0.0f; + pthis->actor.world.pos.z = ROOM_CENTER_Z - 650.0f; + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actor.shape.rot.y = 0; + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, ROOM_CENTER_X, ROOM_CENTER_Y, + ROOM_CENTER_Z + 400.0f, 0, 0, 0, WARP_DUNGEON_ADULT); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, ROOM_CENTER_X, ROOM_CENTER_Y, + ROOM_CENTER_Z - 200.0f, 0, 0, 0, 0); + Actor_Kill(&pthis->actor); + } else { + sHands[LEFT] = + (BossSst*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_SST, pthis->actor.world.pos.x + 200.0f, + pthis->actor.world.pos.y, pthis->actor.world.pos.z + 400.0f, 0, + pthis->actor.shape.rot.y, 0, BONGO_LEFT_HAND); + sHands[RIGHT] = (BossSst*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_SST, + pthis->actor.world.pos.x + (-200.0f), pthis->actor.world.pos.y, + pthis->actor.world.pos.z + 400.0f, 0, pthis->actor.shape.rot.y, 0, + BONGO_RIGHT_HAND); + sHands[LEFT]->actor.child = &sHands[RIGHT]->actor; + sHands[RIGHT]->actor.child = &sHands[LEFT]->actor; + + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.update = BossSst_UpdateHead; + pthis->actor.draw = BossSst_DrawHead; + pthis->radius = -650.0f; + pthis->actor.targetArrowOffset = 4000.0f; + BossSst_HeadSetupLurk(pthis); + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_BOSS); + } + } else { + Collider_SetJntSph(globalCtx, &pthis->colliderJntSph, &pthis->actor, &sJntSphInitHand, pthis->colliderItems); + Collider_SetCylinder(globalCtx, &pthis->colliderCyl, &pthis->actor, &sCylinderInitHand); + if (pthis->actor.params == BONGO_LEFT_HAND) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBongoLeftHandSkel, &gBongoLeftHandIdleAnim, + pthis->jointTable, pthis->morphTable, 27); + pthis->vParity = -1; + pthis->colliderJntSph.elements[0].dim.modelSphere.center.z *= -1; + } else { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBongoRightHandSkel, &gBongoRightHandIdleAnim, + pthis->jointTable, pthis->morphTable, 27); + pthis->vParity = 1; + } + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 95.0f); + pthis->handZPosMod = -3500; + pthis->actor.targetArrowOffset = 5000.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossSst_HandSetupWait(pthis); + } +} + +void BossSst_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossSst* pthis = (BossSst*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->colliderJntSph); + Collider_DestroyCylinder(globalCtx, &pthis->colliderCyl); + Audio_StopSfxByPos(&pthis->center); +} + +void BossSst_HeadSetupLurk(BossSst* pthis) { + pthis->actor.draw = NULL; + sHands[LEFT]->actor.draw = NULL; + sHands[RIGHT]->actor.draw = NULL; + pthis->vVanish = false; + pthis->actionFunc = BossSst_HeadLurk; +} + +void BossSst_HeadLurk(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->actor.yDistToPlayer < 1000.0f) { + BossSst_HeadSetupIntro(pthis, globalCtx); + } +} + +void BossSst_HeadSetupIntro(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->timer = 611; + pthis->ready = false; + player->actor.world.pos.x = sRoomCenter.x; + player->actor.world.pos.y = ROOM_CENTER_Y + 1000.0f; + player->actor.world.pos.z = sRoomCenter.z; + player->linearVelocity = player->actor.velocity.y = 0.0f; + player->actor.shape.rot.y = -0x8000; + player->targetYaw = -0x8000; + player->currentYaw = -0x8000; + player->fallStartHeight = 0; + player->stateFlags1 |= 0x20; + + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + sCutsceneCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_ACTIVE); + Math_Vec3f_Copy(&sCameraAt, &player->actor.world.pos); + if (gSaveContext.eventChkInf[7] & 0x80) { + sCameraEye.z = ROOM_CENTER_Z - 100.0f; + } + + Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &sCameraAt, &sCameraEye); + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + pthis->actionFunc = BossSst_HeadIntro; +} + +void BossSst_HeadIntro(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 tempo; + s32 introStateTimer; + s32 revealStateTimer; + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadEyeCloseIdleAnim, -3.0f); + } + + if (pthis->timer == 0) { + sHands[RIGHT]->actor.flags |= ACTOR_FLAG_0; + sHands[LEFT]->actor.flags |= ACTOR_FLAG_0; + player->stateFlags1 &= ~0x20; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + sCameraAt.y += 30.0f; + sCameraAt.z += 300.0f; + Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &sCameraAt, &sCameraEye); + Gameplay_CopyCamera(globalCtx, MAIN_CAM, sCutsceneCamera); + Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, sCutsceneCamera); + gSaveContext.eventChkInf[7] |= 0x80; + BossSst_HeadSetupNeutral(pthis); + pthis->colliderJntSph.base.ocFlags1 |= OC1_ON; + sHands[LEFT]->colliderJntSph.base.ocFlags1 |= OC1_ON; + sHands[RIGHT]->colliderJntSph.base.ocFlags1 |= OC1_ON; + pthis->timer = 112; + } else if (pthis->timer >= 546) { + if (player->actor.world.pos.y > 100.0f) { + player->actor.world.pos.x = sRoomCenter.x; + player->actor.world.pos.z = sRoomCenter.z; + player->linearVelocity = 0; + player->actor.shape.rot.y = -0x8000; + player->targetYaw = -0x8000; + player->currentYaw = -0x8000; + } + + Math_Vec3f_Copy(&sCameraAt, &player->actor.world.pos); + if (player->actor.bgCheckFlags & 2) { + if (!pthis->ready) { + sFloor->dyna.actor.params = BONGOFLOOR_HIT; + pthis->ready = true; + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); + Audio_PlayActorSound2(&sFloor->dyna.actor, NA_SE_EN_SHADEST_TAIKO_HIGH); + } else if (gSaveContext.eventChkInf[7] & 0x80) { + sHands[RIGHT]->actor.draw = BossSst_DrawHand; + sHands[LEFT]->actor.draw = BossSst_DrawHand; + pthis->actor.draw = BossSst_DrawHead; + pthis->timer = 178; + sCameraAt.x = ROOM_CENTER_X - 23.0f; + sCameraAt.y = ROOM_CENTER_Y + 0.0f; + sCameraAt.z = ROOM_CENTER_Z + 0.0f; + } else { + pthis->timer = 546; + } + } + } else if (pthis->timer >= 478) { + sCameraEye.x += 10.0f; + sCameraEye.y += 10.0f; + sCameraEye.z -= 10.0f; + } else if (pthis->timer >= 448) { + if (pthis->timer == 460) { + sHands[RIGHT]->actor.draw = BossSst_DrawHand; + sHands[LEFT]->actor.draw = BossSst_DrawHand; + pthis->actor.draw = BossSst_DrawHead; + player->actor.world.pos.x = sRoomCenter.x; + player->actor.world.pos.z = sRoomCenter.z; + BossSst_HandSetupDownbeat(sHands[RIGHT]); + } + if (pthis->timer > 460) { + sCameraEye.x -= 40.0f; + sCameraEye.y -= 40.0f; + sCameraEye.z += 20.0f; + } else if (pthis->timer == 460) { + sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 0.0f; + sCameraAt.y = sHands[RIGHT]->actor.home.pos.y - 20.0f; + sCameraAt.z = sHands[RIGHT]->actor.home.pos.z + 10.0f; + sCameraEye.x = sHands[RIGHT]->actor.home.pos.x + 150.0f; + sCameraEye.y = sHands[RIGHT]->actor.home.pos.y + 100.0f; + sCameraEye.z = sHands[RIGHT]->actor.home.pos.z + 80.0f; + } + } else { + if (pthis->timer >= 372) { + introStateTimer = pthis->timer - 372; + tempo = 6; + if (pthis->timer == 447) { + sCameraAt = player->actor.world.pos; + sCameraEye.x = ROOM_CENTER_X - 200.0f; + sCameraEye.y = ROOM_CENTER_Y + 160.0f; + sCameraEye.z = ROOM_CENTER_Z - 190.0f; + } else if (introStateTimer == 11) { + sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 30.0f; + sCameraAt.y = sHands[RIGHT]->actor.home.pos.y + 0.0f; + sCameraAt.z = sHands[RIGHT]->actor.home.pos.z + 20.0f; + sCameraEye.x = sHands[RIGHT]->actor.home.pos.x + 100.0f; + sCameraEye.y = sHands[RIGHT]->actor.home.pos.y + 10.0f; + sCameraEye.z = sHands[RIGHT]->actor.home.pos.z - 210.0f; + } else if (introStateTimer == 62) { + sCameraAt.x = sHands[LEFT]->actor.home.pos.x + 0.0f; + sCameraAt.y = sHands[LEFT]->actor.home.pos.y + 50.0f; + sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 100.0f; + sCameraEye.x = sHands[LEFT]->actor.home.pos.x + 110.0f; + sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 180.0f; + sCameraEye.z = sHands[LEFT]->actor.home.pos.z - 70.0f; + } + } else if (pthis->timer >= 304) { + introStateTimer = pthis->timer - 304; + tempo = 5; + if (introStateTimer == 11) { + sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 40.0f; + sCameraAt.y = sHands[RIGHT]->actor.home.pos.y - 90.0f; + sCameraAt.z = sHands[RIGHT]->actor.home.pos.z - 40.0f; + sCameraEye.x = sHands[RIGHT]->actor.home.pos.x - 20.0f; + sCameraEye.y = sHands[RIGHT]->actor.home.pos.y + 210.0f; + sCameraEye.z = sHands[RIGHT]->actor.home.pos.z + 170.0f; + } else if (pthis->timer == 368) { + sCameraAt.x = sHands[LEFT]->actor.home.pos.x - 20.0f; + sCameraAt.y = sHands[LEFT]->actor.home.pos.y + 0.0f; + sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 0.0f; + sCameraEye.x = sHands[LEFT]->actor.home.pos.x - 70.0f; + sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 170.0f; + sCameraEye.z = sHands[LEFT]->actor.home.pos.z + 150.0f; + } + } else if (pthis->timer >= 244) { + introStateTimer = pthis->timer - 244; + tempo = 4; + if (introStateTimer == 11) { + sCameraAt.x = sHands[RIGHT]->actor.home.pos.x + 30.0f; + sCameraAt.y = sHands[RIGHT]->actor.home.pos.y + 70.0f; + sCameraAt.z = sHands[RIGHT]->actor.home.pos.z + 40.0f; + sCameraEye.x = sHands[RIGHT]->actor.home.pos.x + 110.0f; + sCameraEye.y = sHands[RIGHT]->actor.home.pos.y - 140.0f; + sCameraEye.z = sHands[RIGHT]->actor.home.pos.z - 10.0f; + } else if (pthis->timer == 300) { + sCameraAt.x = sHands[LEFT]->actor.home.pos.x - 20.0f; + sCameraAt.y = sHands[LEFT]->actor.home.pos.y - 80.0f; + sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 320.0f; + sCameraEye.x = sHands[LEFT]->actor.home.pos.x - 130.0f; + sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 130.0f; + sCameraEye.z = sHands[LEFT]->actor.home.pos.z - 150.0f; + } + } else if (pthis->timer >= 192) { + introStateTimer = pthis->timer - 192; + tempo = 3; + if (pthis->timer == 240) { + sCameraAt.x = sHands[LEFT]->actor.home.pos.x - 190.0f; + sCameraAt.y = sHands[LEFT]->actor.home.pos.y - 110.0f; + sCameraAt.z = sHands[LEFT]->actor.home.pos.z + 40.0f; + sCameraEye.x = sHands[LEFT]->actor.home.pos.x + 120.0f; + sCameraEye.y = sHands[LEFT]->actor.home.pos.y + 130.0f; + sCameraEye.z = sHands[LEFT]->actor.home.pos.z + 50.0f; + } else if (introStateTimer == 12) { + sCameraAt.x = sRoomCenter.x + 50.0f; + sCameraAt.y = sRoomCenter.y - 90.0f; + sCameraAt.z = sRoomCenter.z - 200.0f; + sCameraEye.x = sRoomCenter.x + 50.0f; + sCameraEye.y = sRoomCenter.y + 350.0f; + sCameraEye.z = sRoomCenter.z + 150.0f; + } + } else if (pthis->timer >= 148) { + introStateTimer = pthis->timer - 148; + tempo = 2; + } else if (pthis->timer >= 112) { + introStateTimer = pthis->timer - 112; + tempo = 1; + } else { + introStateTimer = pthis->timer % 28; + tempo = 0; + } + if (pthis->timer <= 198) { + revealStateTimer = 198 - pthis->timer; + if ((gSaveContext.eventChkInf[7] & 0x80) && (revealStateTimer <= 44)) { + sCameraAt.x += 492.0f * 0.01f; + sCameraAt.y += 200.0f * 0.01f; + sCameraEye.x -= 80.0f * 0.01f; + sCameraEye.y -= 360.0f * 0.01f; + sCameraEye.z += 1000.0f * 0.01f; + } else if (pthis->timer <= 20) { + sCameraAt.y -= 700.0f * 0.01f; + sCameraAt.z += 900.0f * 0.01f; + sCameraEye.x += 650.0f * 0.01f; + sCameraEye.y += 400.0f * 0.01f; + sCameraEye.z += 1550.0f * 0.01f; + pthis->vVanish = true; + pthis->actor.flags |= ACTOR_FLAG_7; + } else if (revealStateTimer < 40) { + sCameraAt.x += 125.0f * 0.01f; + sCameraAt.y += 350.0f * 0.01f; + sCameraAt.z += 500.0f * 0.01f; + sCameraEye.x += 200.0f * 0.01f; + sCameraEye.y -= 850.0f * 0.01f; + } else if (revealStateTimer >= 45) { + if (revealStateTimer < 85) { + sCameraAt.x -= 250.0f * 0.01f; + sCameraAt.y += 425.0f * 0.01f; + sCameraAt.z -= 1200.0f * 0.01f; + sCameraEye.x -= 650.0f * 0.01f; + sCameraEye.y += 125.0f * 0.01f; + sCameraEye.z -= 350.0f * 0.01f; + } else if (revealStateTimer == 85) { + if (!(gSaveContext.eventChkInf[7] & 0x80)) { + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(gBongoTitleCardTex), 160, 180, 128, 40); + } + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadEyeCloseAnim, -5.0f); + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_DISAPPEAR); + } + } + } + if (introStateTimer == 12) { + BossSst_HandSetupDownbeat(sHands[RIGHT]); + } + if ((introStateTimer != 5) && ((introStateTimer % ((tempo * 2) + 7)) == 5)) { + BossSst_HandSetupOffbeat(sHands[LEFT]); + } + } + + if (pthis->actionFunc != BossSst_HeadNeutral) { + Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &sCameraAt, &sCameraEye); + } +} + +void BossSst_HeadSetupWait(BossSst* pthis) { + if (pthis->skelAnime.animation != &gBongoHeadEyeCloseIdleAnim) { + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadEyeCloseIdleAnim, -5.0f); + } + pthis->actionFunc = BossSst_HeadWait; +} + +void BossSst_HeadWait(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((HAND_STATE(sHands[LEFT]) == HAND_WAIT) && (HAND_STATE(sHands[RIGHT]) == HAND_WAIT)) { + BossSst_HeadSetupNeutral(pthis); + } +} + +void BossSst_HeadSetupNeutral(BossSst* pthis) { + pthis->timer = 127; + pthis->ready = false; + pthis->actionFunc = BossSst_HeadNeutral; +} + +void BossSst_HeadNeutral(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (!pthis->ready && ((HAND_STATE(sHands[LEFT]) == HAND_BEAT) || (HAND_STATE(sHands[LEFT]) == HAND_WAIT)) && + ((HAND_STATE(sHands[RIGHT]) == HAND_BEAT) || (HAND_STATE(sHands[RIGHT]) == HAND_WAIT))) { + pthis->ready = true; + } + + if (pthis->ready) { + if (pthis->timer != 0) { + pthis->timer--; + } + } + + if (pthis->timer == 0) { + if ((GET_PLAYER(globalCtx)->actor.world.pos.y > -50.0f) && !(GET_PLAYER(globalCtx)->stateFlags1 & 0x6080)) { + sHands[Rand_ZeroOne() <= 0.5f]->ready = true; + BossSst_HeadSetupWait(pthis); + } else { + pthis->timer = 28; + } + } else { + Math_ApproachS(&pthis->actor.shape.rot.y, + Actor_WorldYawTowardPoint(&GET_PLAYER(globalCtx)->actor, &sRoomCenter) + 0x8000, 4, 0x400); + if ((pthis->timer == 28) || (pthis->timer == 84)) { + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_PRAY); + } + } +} + +void BossSst_HeadSetupDamagedHand(BossSst* pthis, s32 bothHands) { + if (bothHands) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadEyeOpenAnim, -5.0f); + } else { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadDamagedHandAnim, -5.0f); + } + pthis->actionFunc = BossSst_HeadDamagedHand; +} + +void BossSst_HeadDamagedHand(BossSst* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if ((HAND_STATE(sHands[LEFT]) == HAND_DAMAGED) && (HAND_STATE(sHands[RIGHT]) == HAND_DAMAGED)) { + BossSst_HeadSetupReadyCharge(pthis); + } else if ((HAND_STATE(sHands[LEFT]) == HAND_FROZEN) || (HAND_STATE(sHands[RIGHT]) == HAND_FROZEN)) { + BossSst_HeadSetupFrozenHand(pthis); + } else if (pthis->skelAnime.animation == &gBongoHeadEyeOpenAnim) { + BossSst_HeadSetupUnfreezeHand(pthis); + } else { + BossSst_HeadSetupWait(pthis); + } + } +} + +void BossSst_HeadSetupReadyCharge(BossSst* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); + pthis->actor.speedXZ = 0.0f; + pthis->colliderCyl.base.acFlags |= AC_ON; + pthis->actionFunc = BossSst_HeadReadyCharge; +} + +void BossSst_HeadReadyCharge(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (sHands[LEFT]->ready && (sHands[LEFT]->actionFunc == BossSst_HandReadyCharge) && sHands[RIGHT]->ready && + (sHands[RIGHT]->actionFunc == BossSst_HandReadyCharge)) { + BossSst_HeadSetupCharge(pthis); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 4, 0x800, 0x400); + } +} + +void BossSst_HeadSetupCharge(BossSst* pthis) { + Animation_Change(&pthis->skelAnime, &gBongoHeadChargeAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gBongoHeadChargeAnim), + ANIMMODE_ONCE_INTERP, -5.0f); + BossSst_HandSetDamage(sHands[LEFT], 0x20); + BossSst_HandSetDamage(sHands[RIGHT], 0x20); + pthis->colliderJntSph.base.atFlags |= AT_ON; + pthis->actor.speedXZ = 3.0f; + pthis->radius = -650.0f; + pthis->ready = false; + pthis->actionFunc = BossSst_HeadCharge; +} + +void BossSst_HeadCharge(BossSst* pthis, GlobalContext* globalCtx) { + f32 chargeDist; + s32 animFinish = SkelAnime_Update(&pthis->skelAnime); + + if (!pthis->ready && Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + pthis->ready = true; + pthis->actor.speedXZ = 0.25f; + pthis->skelAnime.playSpeed = 0.2f; + } + + pthis->actor.speedXZ *= 1.25f; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 45.0f); + + if (pthis->ready) { + if (Math_SmoothStepToF(&pthis->radius, 650.0f, 0.4f, pthis->actor.speedXZ, 1.0f) < 10.0f) { + pthis->radius = 650.0f; + BossSst_HeadSetupEndCharge(pthis); + } else { + chargeDist = (650.0f - pthis->radius) * 3.0f; + if (chargeDist > 180.0f) { + chargeDist = 180.0f; + } + + pthis->actor.world.pos.y = pthis->actor.home.pos.y - chargeDist; + } + + if (!animFinish) { + sHandOffsets[LEFT].z += 5.0f; + sHandOffsets[RIGHT].z += 5.0f; + } + } else { + Math_ApproachF(&pthis->radius, -700.0f, 0.4f, pthis->actor.speedXZ); + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - 180.0f, 20.0f); + sHandOffsets[LEFT].y += 5.0f; + sHandOffsets[RIGHT].y += 5.0f; + } + + if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + sHands[LEFT]->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + sHands[RIGHT]->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + func_8002F71C(globalCtx, &pthis->actor, 10.0f, pthis->actor.shape.rot.y, 5.0f); + func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); + } +} + +void BossSst_HeadSetupEndCharge(BossSst* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadEyeCloseIdleAnim, -20.0f); + pthis->targetYaw = Actor_WorldYawTowardPoint(&pthis->actor, &sRoomCenter); + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->colliderCyl.base.acFlags &= ~AC_ON; + pthis->radius *= -1.0f; + pthis->actionFunc = BossSst_HeadEndCharge; +} + +void BossSst_HeadEndCharge(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 4, 0x800, 0x100) == 0) { + BossSst_HandSetupRetreat(sHands[LEFT]); + BossSst_HandSetupRetreat(sHands[RIGHT]); + BossSst_HeadSetupNeutral(pthis); + } +} + +void BossSst_HeadSetupFrozenHand(BossSst* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); + pthis->ready = false; + pthis->colliderCyl.base.acFlags |= AC_ON; + pthis->actionFunc = BossSst_HeadFrozenHand; +} + +void BossSst_HeadFrozenHand(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->ready) { + BossSst_HeadSetupUnfreezeHand(pthis); + } +} + +void BossSst_HeadSetupUnfreezeHand(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadEyeCloseAnim, -5.0f); + pthis->colliderCyl.base.acFlags &= ~AC_ON; + pthis->actionFunc = BossSst_HeadUnfreezeHand; +} + +void BossSst_HeadUnfreezeHand(BossSst* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + BossSst_HeadSetupWait(pthis); + } +} + +void BossSst_HeadSetupStunned(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadKnockoutAnim, -5.0f); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadKnockoutAnim)); + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->colliderCyl.base.acFlags &= ~AC_ON; + pthis->vVanish = false; + pthis->actor.flags &= ~ACTOR_FLAG_7; + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_FREEZE); + pthis->actionFunc = BossSst_HeadStunned; +} + +void BossSst_HeadStunned(BossSst* pthis, GlobalContext* globalCtx) { + f32 bounce; + s32 animFinish; + f32 currentFrame; + + Math_StepToF(&sHandOffsets[LEFT].z, 600.0f, 20.0f); + Math_StepToF(&sHandOffsets[RIGHT].z, 600.0f, 20.0f); + Math_StepToF(&sHandOffsets[LEFT].x, 200.0f, 20.0f); + Math_StepToF(&sHandOffsets[RIGHT].x, -200.0f, 20.0f); + pthis->actor.velocity.y += pthis->actor.gravity; + animFinish = SkelAnime_Update(&pthis->skelAnime); + currentFrame = pthis->skelAnime.curFrame; + if (currentFrame <= 6.0f) { + bounce = (sinf((M_PI / 11) * currentFrame) * 100.0f) + (pthis->actor.home.pos.y - 180.0f); + if (pthis->actor.world.pos.y < bounce) { + pthis->actor.world.pos.y = bounce; + } + } else if (currentFrame <= 11.0f) { + pthis->actor.world.pos.y = (sinf((M_PI / 11) * currentFrame) * 170.0f) + (pthis->actor.home.pos.y - 250.0f); + } else { + pthis->actor.world.pos.y = + (sinf((currentFrame - 11.0f) * (M_PI / 5)) * 50.0f) + (pthis->actor.home.pos.y - 250.0f); + } + + if ((animFinish) || Animation_OnFrame(&pthis->skelAnime, 11.0f)) { + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_LAND); + } + + if (pthis->radius < -500.0f) { + Math_SmoothStepToF(&pthis->radius, -500.0f, 1.0f, 50.0f, 5.0f); + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.5f, 15.0f, 3.0f); + pthis->radius += pthis->actor.speedXZ; + } + + pthis->radius = CLAMP_MAX(pthis->radius, 400.0f); + + pthis->actor.world.pos.y += pthis->actor.velocity.y; + if (animFinish) { + BossSst_HeadSetupVulnerable(pthis); + } +} + +void BossSst_HeadSetupVulnerable(BossSst* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadStunnedAnim, -5.0f); + pthis->colliderCyl.base.acFlags |= AC_ON; + pthis->colliderCyl.info.bumper.dmgFlags = 0x0FC00702; // Sword-type damage + pthis->actor.speedXZ = 0.0f; + pthis->colliderJntSph.elements[10].info.bumperFlags |= (BUMP_ON | BUMP_HOOKABLE); + pthis->colliderJntSph.elements[0].info.bumperFlags &= ~BUMP_ON; + if (pthis->actionFunc != BossSst_HeadDamage) { + pthis->timer = 50; + } + + pthis->actionFunc = BossSst_HeadVulnerable; +} + +void BossSst_HeadVulnerable(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&sHandOffsets[LEFT].z, 600.0f, 20.0f); + Math_StepToF(&sHandOffsets[RIGHT].z, 600.0f, 20.0f); + Math_StepToF(&sHandOffsets[LEFT].x, 200.0f, 20.0f); + Math_StepToF(&sHandOffsets[RIGHT].x, -200.0f, 20.0f); + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_13)) { + pthis->timer += 2; + pthis->timer = CLAMP_MAX(pthis->timer, 50); + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + BossSst_HandSetupRecover(sHands[LEFT]); + BossSst_HandSetupRecover(sHands[RIGHT]); + BossSst_HeadSetupRecover(pthis); + } + } +} + +void BossSst_HeadSetupDamage(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadDamageAnim, -3.0f); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadDamageAnim)); + Actor_SetColorFilter(&sHands[LEFT]->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadDamageAnim)); + Actor_SetColorFilter(&sHands[RIGHT]->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadDamageAnim)); + pthis->colliderCyl.base.acFlags &= ~AC_ON; + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_DAMAGE); + pthis->actionFunc = BossSst_HeadDamage; +} + +void BossSst_HeadDamage(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + BossSst_HeadSetupVulnerable(pthis); + } +} + +void BossSst_HeadSetupRecover(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadRecoverAnim, -5.0f); + pthis->colliderCyl.base.acFlags &= ~AC_ON; + pthis->colliderCyl.info.bumper.dmgFlags = 0xFFCFFFFF; + pthis->colliderJntSph.elements[10].info.bumperFlags &= ~(BUMP_ON | BUMP_HOOKABLE); + pthis->colliderJntSph.elements[0].info.bumperFlags |= BUMP_ON; + pthis->vVanish = true; + pthis->actor.speedXZ = 5.0f; + pthis->actionFunc = BossSst_HeadRecover; +} + +void BossSst_HeadRecover(BossSst* pthis, GlobalContext* globalCtx) { + s32 animFinish; + f32 currentFrame; + f32 diff; + + animFinish = SkelAnime_Update(&pthis->skelAnime); + currentFrame = pthis->skelAnime.curFrame; + if (currentFrame < 10.0f) { + pthis->actor.world.pos.y += 10.0f; + sHandOffsets[LEFT].y -= 10.0f; + sHandOffsets[RIGHT].y -= 10.0f; + Math_SmoothStepToF(&pthis->radius, -750.0f, 1.0f, pthis->actor.speedXZ, 2.0f); + } else { + pthis->actor.speedXZ *= 1.25f; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 50.0f); + diff = Math_SmoothStepToF(&pthis->radius, -650.0f, 1.0f, pthis->actor.speedXZ, 2.0f); + diff += Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f, 30.0f, 3.0f); + } + if (animFinish && (diff < 10.0f)) { + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + pthis->radius = -650.0f; + BossSst_HandSetupRetreat(sHands[LEFT]); + BossSst_HandSetupRetreat(sHands[RIGHT]); + BossSst_HeadSetupNeutral(pthis); + } +} + +void BossSst_SetCameraTargets(f32 cameraSpeedMod, s32 targetIndex) { + Vec3f* nextAt = &sCameraAtPoints[targetIndex]; + Vec3f* nextEye = &sCameraEyePoints[targetIndex]; + + if (targetIndex != 0) { + Math_Vec3f_Copy(&sCameraAt, &sCameraAtPoints[targetIndex - 1]); + Math_Vec3f_Copy(&sCameraEye, &sCameraEyePoints[targetIndex - 1]); + } + + sCameraAtVel.x = (nextAt->x - sCameraAt.x) * cameraSpeedMod; + sCameraAtVel.y = (nextAt->y - sCameraAt.y) * cameraSpeedMod; + sCameraAtVel.z = (nextAt->z - sCameraAt.z) * cameraSpeedMod; + + sCameraEyeVel.x = (nextEye->x - sCameraEye.x) * cameraSpeedMod; + sCameraEyeVel.y = (nextEye->y - sCameraEye.y) * cameraSpeedMod; + sCameraEyeVel.z = (nextEye->z - sCameraEye.z) * cameraSpeedMod; +} + +void BossSst_UpdateDeathCamera(BossSst* pthis, GlobalContext* globalCtx) { + Vec3f cameraAt; + Vec3f cameraEye; + f32 sn; + f32 cs; + + sCameraAt.x += sCameraAtVel.x; + sCameraAt.y += sCameraAtVel.y; + sCameraAt.z += sCameraAtVel.z; + sCameraEye.x += sCameraEyeVel.x; + sCameraEye.y += sCameraEyeVel.y; + sCameraEye.z += sCameraEyeVel.z; + + sn = Math_SinS(pthis->actor.shape.rot.y); + cs = Math_CosS(pthis->actor.shape.rot.y); + cameraAt.x = pthis->actor.world.pos.x + (sCameraAt.z * sn) + (sCameraAt.x * cs); + cameraAt.y = pthis->actor.home.pos.y - 140.0f + sCameraAt.y; + cameraAt.z = pthis->actor.world.pos.z + (sCameraAt.z * cs) - (sCameraAt.x * sn); + cameraEye.x = pthis->actor.world.pos.x + (sCameraEye.z * sn) + (sCameraEye.x * cs); + cameraEye.y = pthis->actor.home.pos.y - 140.0f + sCameraEye.y; + cameraEye.z = pthis->actor.world.pos.z + (sCameraEye.z * cs) - (sCameraEye.x * sn); + Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &cameraAt, &cameraEye); +} + +void BossSst_HeadSetupDeath(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Animation_MorphToLoop(&pthis->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_DEAD); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 60); + Actor_SetColorFilter(&sHands[LEFT]->actor, 0x4000, 0xFF, 0, 60); + Actor_SetColorFilter(&sHands[RIGHT]->actor, 0x4000, 0xFF, 0, 60); + pthis->timer = 60; + pthis->colliderCyl.base.acFlags &= ~AC_ON; + pthis->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + sHands[LEFT]->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + sHands[RIGHT]->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + sCutsceneCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_ACTIVE); + Gameplay_CopyCamera(globalCtx, sCutsceneCamera, MAIN_CAM); + func_8002DF54(globalCtx, &player->actor, 8); + func_80064520(globalCtx, &globalCtx->csCtx); + Math_Vec3f_Copy(&sCameraEye, &GET_ACTIVE_CAM(globalCtx)->eye); + pthis->actionFunc = BossSst_HeadDeath; +} + +void BossSst_HeadDeath(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - 140.0f, 20.0f); + if (pthis->timer == 0) { + BossSst_HandSetupThrash(sHands[LEFT]); + BossSst_HandSetupThrash(sHands[RIGHT]); + BossSst_HeadSetupThrash(pthis); + } else if (pthis->timer > 48) { + Gameplay_CameraSetAtEye(globalCtx, sCutsceneCamera, &pthis->actor.focus.pos, &sCameraEye); + Math_StepToF(&pthis->radius, -350.0f, 10.0f); + } else if (pthis->timer == 48) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.world.pos.x = sRoomCenter.x + (400.0f * Math_SinS(pthis->actor.shape.rot.y)) + + (Math_CosS(pthis->actor.shape.rot.y) * -120.0f); + player->actor.world.pos.z = sRoomCenter.z + (400.0f * Math_CosS(pthis->actor.shape.rot.y)) - + (Math_SinS(pthis->actor.shape.rot.y) * -120.0f); + player->actor.shape.rot.y = Actor_WorldYawTowardPoint(&player->actor, &sRoomCenter); + func_8002DBD0(&pthis->actor, &sCameraEye, &GET_ACTIVE_CAM(globalCtx)->eye); + func_8002DBD0(&pthis->actor, &sCameraAt, &GET_ACTIVE_CAM(globalCtx)->at); + pthis->radius = -350.0f; + pthis->actor.world.pos.x = sRoomCenter.x - (Math_SinS(pthis->actor.shape.rot.y) * 350.0f); + pthis->actor.world.pos.z = sRoomCenter.z - (Math_CosS(pthis->actor.shape.rot.y) * 350.0f); + BossSst_SetCameraTargets(1.0 / 48, 0); + BossSst_UpdateDeathCamera(pthis, globalCtx); + } else { + BossSst_UpdateDeathCamera(pthis, globalCtx); + } +} + +void BossSst_HeadSetupThrash(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBongoHeadEyeOpenIdleAnim, -5.0f); + pthis->timer = 160; + pthis->targetYaw = pthis->actor.shape.rot.y; + BossSst_SetCameraTargets(1.0 / 80, 1); + pthis->actionFunc = BossSst_HeadThrash; +} + +void BossSst_HeadThrash(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + if ((pthis->timer == 0) && (pthis->actor.shape.rot.y == pthis->targetYaw)) { + BossSst_HeadSetupDarken(pthis); + } else if (pthis->timer >= 80) { + BossSst_UpdateDeathCamera(pthis, globalCtx); + } +} + +void BossSst_HeadSetupDarken(BossSst* pthis) { + pthis->timer = 160; + BossSst_SetCameraTargets(1.0 / 80, 2); + pthis->actionFunc = BossSst_HeadDarken; +} + +void BossSst_HeadDarken(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (1) {} + + if (pthis->timer >= 80) { + if (pthis->timer == 80) { + sBodyStatic = true; + } + BossSst_UpdateDeathCamera(pthis, globalCtx); + sBodyColor.r = sBodyColor.g = sBodyColor.b = (pthis->timer * 3) - 240; + if (pthis->timer == 80) { + BossSst_SetCameraTargets(1.0 / 80, 3); + } + } else { + sBodyColor.b = (80 - pthis->timer) / 1.0f; + sBodyColor.r = sBodyColor.g = sStaticColor.r = sStaticColor.g = sStaticColor.b = (80 - pthis->timer) / 8.0f; + BossSst_UpdateDeathCamera(pthis, globalCtx); + if (pthis->timer == 0) { + BossSst_HeadSetupFall(pthis); + } + } +} + +void BossSst_HeadSetupFall(BossSst* pthis) { + pthis->actor.speedXZ = 1.0f; + Math_Vec3f_Copy(&sCameraAt, &sCameraAtPoints[3]); + Math_Vec3f_Copy(&sCameraEye, &sCameraEyePoints[3]); + sCameraAtVel.x = 0.0f; + sCameraAtVel.z = 0.0f; + sCameraAtVel.y = -50.0f; + Math_Vec3f_Copy(&sCameraEyeVel, &sZeroVec); + pthis->actionFunc = BossSst_HeadFall; +} + +void BossSst_HeadFall(BossSst* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ *= 1.5f; + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - 230.0f, pthis->actor.speedXZ)) { + BossSst_HeadSetupMelt(pthis); + } + + if (sCameraAt.y > 200.0f) { + BossSst_UpdateDeathCamera(pthis, globalCtx); + } +} + +void BossSst_HeadSetupMelt(BossSst* pthis) { + BossSst_SpawnHeadShadow(pthis); + pthis->timer = 80; + BossSst_SetCameraTargets(1.0 / 60, 5); + pthis->actionFunc = BossSst_HeadMelt; +} + +void BossSst_HeadMelt(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.scale.y -= 0.00025f; + pthis->actor.scale.x += 0.000075f; + pthis->actor.scale.z += 0.000075f; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 11500.0f * pthis->actor.scale.y; + if (pthis->timer == 0) { + BossSst_HeadSetupFinish(pthis); + } else if (pthis->timer >= 20.0f) { + BossSst_UpdateDeathCamera(pthis, globalCtx); + } +} + +void BossSst_HeadSetupFinish(BossSst* pthis) { + pthis->actor.draw = BossSst_DrawEffect; + pthis->timer = 40; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + BossSst_SetCameraTargets(1.0 / 40, 6); + pthis->actionFunc = BossSst_HeadFinish; +} + +void BossSst_HeadFinish(BossSst* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 colorIndigo = { 80, 80, 150, 255 }; + static Color_RGBA8 colorDarkIndigo = { 40, 40, 80, 255 }; + static Color_RGBA8 colorUnused[2] = { + { 0, 0, 0, 255 }, + { 100, 100, 100, 0 }, + }; + Vec3f spawnPos; + s32 i; + + pthis->timer--; + if (pthis->effectMode == BONGO_NULL) { + if (pthis->timer < -170) { + BossSst_UpdateDeathCamera(pthis, globalCtx); + Gameplay_CopyCamera(globalCtx, MAIN_CAM, sCutsceneCamera); + Gameplay_ChangeCameraStatus(globalCtx, sCutsceneCamera, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, sCutsceneCamera); + func_8002DF54(globalCtx, &GET_PLAYER(globalCtx)->actor, 7); + func_80064534(globalCtx, &globalCtx->csCtx); + Actor_Kill(&pthis->actor); + Actor_Kill(&sHands[LEFT]->actor); + Actor_Kill(&sHands[RIGHT]->actor); + Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); + } + } else if (pthis->effects[0].alpha == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, ROOM_CENTER_X, ROOM_CENTER_Y, ROOM_CENTER_Z, 0, + 0, 0, WARP_DUNGEON_ADULT); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, + (Math_SinS(pthis->actor.shape.rot.y) * 200.0f) + ROOM_CENTER_X, ROOM_CENTER_Y, + Math_CosS(pthis->actor.shape.rot.y) * 200.0f + ROOM_CENTER_Z, 0, 0, 0, 0); + BossSst_SetCameraTargets(1.0f, 7); + pthis->effectMode = BONGO_NULL; + } else if (pthis->timer == 0) { + pthis->effects[0].status = 0; + pthis->effects[1].status = -1; + pthis->effects[2].status = -1; + } else if (pthis->timer > 0) { + pthis->effects[0].status += 5; + BossSst_UpdateDeathCamera(pthis, globalCtx); + } + + colorIndigo.a = pthis->effects[0].alpha; + colorDarkIndigo.a = pthis->effects[0].alpha; + + for (i = 0; i < 5; i++) { + spawnPos.x = sRoomCenter.x + 0.0f + Rand_CenteredFloat(800.0f); + spawnPos.y = sRoomCenter.y + (-28.0f) + (Rand_ZeroOne() * 5.0f); + spawnPos.z = sRoomCenter.z + 0.0f + Rand_CenteredFloat(800.0f); + EffectSsGSplash_Spawn(globalCtx, &spawnPos, &colorIndigo, &colorDarkIndigo, 0, 0x3E8); + } +} + +void BossSst_HandSetupWait(BossSst* pthis) { + HAND_STATE(pthis) = HAND_WAIT; + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + Animation_MorphToLoop(&pthis->skelAnime, sHandIdleAnims[pthis->actor.params], 5.0f); + pthis->ready = false; + pthis->timer = 20; + pthis->actionFunc = BossSst_HandWait; +} + +void BossSst_HandWait(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, 20.0f); + Math_StepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 1.0f); + Math_StepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 1.0f); + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->timer != 0) { + pthis->timer--; + } + + if ((pthis->timer == 0) && (player->actor.world.pos.y > -50.0f) && !(player->stateFlags1 & 0x6080)) { + BossSst_HandSelectAttack(pthis); + } + } else if (sHead->actionFunc == BossSst_HeadNeutral) { + if ((pthis->actor.params == BONGO_RIGHT_HAND) && ((sHead->timer % 28) == 12)) { + BossSst_HandSetupDownbeat(pthis); + } else if ((pthis->actor.params == BONGO_LEFT_HAND) && ((sHead->timer % 7) == 5) && (sHead->timer < 112)) { + BossSst_HandSetupOffbeat(pthis); + } + } +} + +void BossSst_HandSetupDownbeat(BossSst* pthis) { + HAND_STATE(pthis) = HAND_BEAT; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 5.0f); + pthis->actor.shape.rot.x = 0; + pthis->timer = 12; + pthis->actionFunc = BossSst_HandDownbeat; +} + +void BossSst_HandDownbeat(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + BossSst_HandSetupWait(pthis); + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer >= 3) { + pthis->actor.shape.rot.x -= 0x100; + Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 180.0f, 20.0f); + } else { + pthis->actor.shape.rot.x += 0x300; + Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 0.0f, 60.0f); + } + + if (pthis->timer == 0) { + sFloor->dyna.actor.params = BONGOFLOOR_HIT; + if (sHead->actionFunc == BossSst_HeadWait) { + if (pthis->ready) { + BossSst_HandSelectAttack(pthis); + } else { + BossSst_HandSetupWait(pthis); + } + } else { + BossSst_HandSetupDownbeatEnd(pthis); + } + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_TAIKO_HIGH); + } + } +} + +void BossSst_HandSetupDownbeatEnd(BossSst* pthis) { + sFloor->dyna.actor.params = BONGOFLOOR_HIT; + Animation_PlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params]); + pthis->actionFunc = BossSst_HandDownbeatEnd; +} + +void BossSst_HandDownbeatEnd(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + BossSst_HandSetupWait(pthis); + } else { + Math_SmoothStepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 40.0f, 0.5f, 20.0f, 3.0f); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x800, 0x100); + Math_StepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 1.0f); + Math_StepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 1.0f); + if ((sHead->actionFunc != BossSst_HeadIntro) && ((sHead->timer % 28) == 12)) { + BossSst_HandSetupDownbeat(pthis); + } + } +} + +void BossSst_HandSetupOffbeat(BossSst* pthis) { + HAND_STATE(pthis) = HAND_BEAT; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 5.0f); + pthis->actor.shape.rot.x = 0; + pthis->timer = 5; + pthis->actionFunc = BossSst_HandOffbeat; +} + +void BossSst_HandOffbeat(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + BossSst_HandSetupWait(pthis); + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer != 0) { + pthis->actor.shape.rot.x -= 0x140; + Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 60.0f, 15.0f); + } else { + pthis->actor.shape.rot.x += 0x500; + Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 0.0f, 60.0f); + } + + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_TAIKO_LOW); + BossSst_HandSetupOffbeatEnd(pthis); + } + } +} + +void BossSst_HandSetupOffbeatEnd(BossSst* pthis) { + Animation_PlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params]); + pthis->actionFunc = BossSst_HandOffbeatEnd; +} + +void BossSst_HandOffbeatEnd(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + BossSst_HandSetupWait(pthis); + } else { + Math_SmoothStepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 40.0f, 0.5f, 20.0f, 3.0f); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x400, 0xA0); + Math_StepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 1.0f); + Math_StepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 1.0f); + if (sHead->actionFunc == BossSst_HeadWait) { + if (pthis->ready) { + BossSst_HandSelectAttack(pthis); + } else { + BossSst_HandSetupWait(pthis); + } + } else if ((sHead->actionFunc != BossSst_HeadIntro) && ((sHead->timer % 7) == 5) && + ((sHead->timer % 28) != 5)) { + BossSst_HandSetupOffbeat(pthis); + } + } +} + +void BossSst_HandSetupEndSlam(BossSst* pthis) { + HAND_STATE(pthis) = HAND_RETREAT; + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandPushoffPoses[pthis->actor.params], 6.0f); + pthis->actionFunc = BossSst_HandEndSlam; +} + +void BossSst_HandEndSlam(BossSst* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + BossSst_HandSetupRetreat(pthis); + } +} + +void BossSst_HandSetupRetreat(BossSst* pthis) { + HAND_STATE(pthis) = HAND_RETREAT; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandHangPoses[pthis->actor.params], 10.0f); + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->colliderJntSph.base.acFlags |= AC_ON; + pthis->actor.flags |= ACTOR_FLAG_0; + BossSst_HandSetInvulnerable(pthis, false); + pthis->timer = 0; + pthis->actionFunc = BossSst_HandRetreat; + pthis->actor.speedXZ = 3.0f; +} + +void BossSst_HandRetreat(BossSst* pthis, GlobalContext* globalCtx) { + f32 diff; + s32 inPosition; + + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.speedXZ = pthis->actor.speedXZ * 1.2f; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 50.0f); + + diff = Math_SmoothStepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 0.3f, pthis->actor.speedXZ, 1.0f); + diff += Math_SmoothStepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 0.3f, pthis->actor.speedXZ, 1.0f); + if (pthis->timer != 0) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.world.pos.y = (sinf((pthis->timer * M_PI) / 16.0f) * 250.0f) + pthis->actor.home.pos.y; + if (pthis->timer == 0) { + BossSst_HandSetupWait(pthis); + } else if (pthis->timer == 4) { + Animation_MorphToLoop(&pthis->skelAnime, sHandIdleAnims[pthis->actor.params], 4.0f); + } + } else { + inPosition = Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, 0x200); + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->actor.home.rot.z, 0x200); + inPosition &= Math_ScaledStepToS(&pthis->handYRotMod, 0, 0x800); + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); + if ((Math_SmoothStepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 250.0f, 0.5f, 70.0f, 5.0f) < 1.0f) && + inPosition && (diff < 10.0f)) { + pthis->timer = 8; + } + } +} + +void BossSst_HandSetupReadySlam(BossSst* pthis) { + HAND_STATE(pthis) = HAND_SLAM; + pthis->timer = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 10.0f); + pthis->actionFunc = BossSst_HandReadySlam; +} + +void BossSst_HandReadySlam(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + BossSst_HandSetupSlam(pthis); + } + } else { + Player* player = GET_PLAYER(globalCtx); + + if (Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 300.0f, 30.0f) && + (pthis->actor.xzDistToPlayer < 140.0f)) { + pthis->timer = 20; + } + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x1000, 0x100); + Math_ApproachF(&pthis->actor.world.pos.x, player->actor.world.pos.x, 0.5f, 40.0f); + Math_ApproachF(&pthis->actor.world.pos.z, player->actor.world.pos.z, 0.5f, 40.0f); + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); + } +} + +void BossSst_HandSetupSlam(BossSst* pthis) { + HAND_STATE(pthis) = HAND_SLAM; + pthis->actor.velocity.y = 1.0f; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 10.0f); + BossSst_HandSetDamage(pthis, 0x20); + pthis->ready = false; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_FLY_ATTACK); + pthis->actionFunc = BossSst_HandSlam; +} + +void BossSst_HandSlam(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToS(&pthis->handZPosMod, -0xDAC, 0x1F4); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x1000); + Math_ScaledStepToS(&pthis->handYRotMod, 0, 0x1000); + if (pthis->timer != 0) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + if (pthis->colliderJntSph.base.acFlags & AC_ON) { + BossSst_HandSetupEndSlam(pthis); + } else { + pthis->colliderJntSph.base.acFlags |= AC_ON; + BossSst_HandSetupWait(pthis); + } + } + } else { + if (pthis->ready) { + pthis->timer = 30; + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + } else { + pthis->actor.velocity.y *= 1.5f; + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, pthis->actor.velocity.y)) { + pthis->ready = true; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_TAIKO_LOW); + BossSst_SpawnShockwave(pthis); + pthis->colliderCyl.base.atFlags |= AT_ON; + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderCyl); + pthis->colliderCyl.dim.radius = sCylinderInitHand.dim.radius; + } + } + + if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.world.pos.x = (Math_SinS(pthis->actor.yawTowardsPlayer) * 100.0f) + pthis->actor.world.pos.x; + player->actor.world.pos.z = (Math_CosS(pthis->actor.yawTowardsPlayer) * 100.0f) + pthis->actor.world.pos.z; + + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + func_8002F71C(globalCtx, &pthis->actor, 5.0f, pthis->actor.yawTowardsPlayer, 0.0f); + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x200); + } +} + +void BossSst_HandSetupReadySweep(BossSst* pthis) { + HAND_STATE(pthis) = HAND_SWEEP; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 10.0f); + pthis->radius = Actor_WorldDistXZToPoint(&pthis->actor, &sHead->actor.world.pos); + pthis->actor.world.rot.y = Actor_WorldYawTowardPoint(&sHead->actor, &pthis->actor.world.pos); + pthis->targetYaw = pthis->actor.home.rot.y + (pthis->vParity * 0x2000); + pthis->actionFunc = BossSst_HandReadySweep; +} + +void BossSst_HandReadySweep(BossSst* pthis, GlobalContext* globalCtx) { + s32 inPosition; + + SkelAnime_Update(&pthis->skelAnime); + inPosition = Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 50.0f, 4.0f); + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 0x200); + inPosition &= Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->targetYaw, 0x400); + inPosition &= (Math_SmoothStepToF(&pthis->radius, sHead->actor.xzDistToPlayer, 0.5f, 60.0f, 1.0f) < 10.0f); + + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.world.rot.y) * pthis->radius) + sHead->actor.world.pos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.world.rot.y) * pthis->radius) + sHead->actor.world.pos.z; + if (inPosition) { + BossSst_HandSetupSweep(pthis); + } else { + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); + } +} + +void BossSst_HandSetupSweep(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 5.0f); + BossSst_HandSetDamage(pthis, 0x10); + pthis->targetYaw = pthis->actor.home.rot.y - (pthis->vParity * 0x2000); + pthis->handMaxSpeed = 0x300; + pthis->handAngSpeed = 0; + pthis->ready = false; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_FLY_ATTACK); + pthis->actionFunc = BossSst_HandSweep; +} + +void BossSst_HandSweep(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 newTargetYaw; + + SkelAnime_Update(&pthis->skelAnime); + pthis->handAngSpeed += 0x60; + pthis->handAngSpeed = CLAMP_MAX(pthis->handAngSpeed, pthis->handMaxSpeed); + + if (!Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 4, pthis->handAngSpeed, 0x10)) { + pthis->colliderJntSph.base.ocFlags1 &= ~OC1_NO_PUSH; + BossSst_HandSetupRetreat(pthis); + } else if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->ready = true; + func_8002F71C(globalCtx, &pthis->actor, 5.0f, pthis->actor.shape.rot.y - (pthis->vParity * 0x3800), 0.0f); + func_8002F7DC(&player->actor, NA_SE_PL_BODY_HIT); + newTargetYaw = pthis->actor.shape.rot.y - (pthis->vParity * 0x1400); + if (((s16)(newTargetYaw - pthis->targetYaw) * pthis->vParity) > 0) { + pthis->targetYaw = newTargetYaw; + } + } + + if (!pthis->ready && ((player->cylinder.dim.height > 40.0f) || (player->actor.world.pos.y > 1.0f))) { + pthis->colliderJntSph.base.atFlags |= AT_ON; + pthis->colliderJntSph.base.ocFlags1 &= ~OC1_NO_PUSH; + } else { + pthis->colliderJntSph.base.atFlags &= ~AT_ON; + pthis->colliderJntSph.base.ocFlags1 |= OC1_NO_PUSH; + } + + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y) * pthis->radius) + sHead->actor.world.pos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y) * pthis->radius) + sHead->actor.world.pos.z; +} + +void BossSst_HandSetupReadyPunch(BossSst* pthis) { + HAND_STATE(pthis) = HAND_PUNCH; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandPushoffPoses[pthis->actor.params], 10.0f); + pthis->actionFunc = BossSst_HandReadyPunch; +} + +void BossSst_HandReadyPunch(BossSst* pthis, GlobalContext* globalCtx) { + s32 inPosition = Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0x400); + + if (SkelAnime_Update(&pthis->skelAnime) && inPosition) { + BossSst_HandSetupPunch(pthis); + } +} + +void BossSst_HandSetupPunch(BossSst* pthis) { + pthis->actor.speedXZ = 0.5f; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFistPoses[pthis->actor.params], 5.0f); + BossSst_HandSetInvulnerable(pthis, true); + pthis->targetRoll = pthis->vParity * 0x3F00; + BossSst_HandSetDamage(pthis, 0x10); + pthis->actionFunc = BossSst_HandPunch; +} + +void BossSst_HandPunch(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 80.0f, 20.0f); + if (Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->targetRoll, 0x400)) { + pthis->targetRoll *= -1; + } + + pthis->actor.speedXZ *= 1.25f; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 50.0f); + + pthis->actor.world.pos.x += pthis->actor.speedXZ * Math_SinS(pthis->actor.shape.rot.y); + pthis->actor.world.pos.z += pthis->actor.speedXZ * Math_CosS(pthis->actor.shape.rot.y); + if (pthis->actor.bgCheckFlags & 8) { + BossSst_HandSetupRetreat(pthis); + } else if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); + func_8002F71C(globalCtx, &pthis->actor, 10.0f, pthis->actor.shape.rot.y, 5.0f); + BossSst_HandSetupRetreat(pthis); + } + + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); +} + +void BossSst_HandSetupReadyClap(BossSst* pthis) { + HAND_STATE(pthis) = HAND_CLAP; + if (HAND_STATE(OTHER_HAND(pthis)) != HAND_CLAP) { + BossSst_HandSetupReadyClap(OTHER_HAND(pthis)); + } + + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 10.0f); + pthis->radius = Actor_WorldDistXZToPoint(&pthis->actor, &sHead->actor.world.pos); + pthis->actor.world.rot.y = Actor_WorldYawTowardPoint(&sHead->actor, &pthis->actor.world.pos); + pthis->targetYaw = pthis->actor.home.rot.y - (pthis->vParity * 0x1800); + pthis->targetRoll = pthis->vParity * 0x4000; + pthis->timer = 0; + pthis->ready = false; + OTHER_HAND(pthis)->ready = false; + pthis->actionFunc = BossSst_HandReadyClap; +} + +void BossSst_HandReadyClap(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + BossSst_HandSetupClap(pthis); + BossSst_HandSetupClap(OTHER_HAND(pthis)); + OTHER_HAND(pthis)->radius = pthis->radius; + } + } else if (!pthis->ready) { + pthis->ready = SkelAnime_Update(&pthis->skelAnime); + pthis->ready &= Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x600); + pthis->ready &= Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->targetRoll, 0x600); + pthis->ready &= Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 0x200); + pthis->ready &= Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->targetYaw, 0x400); + pthis->ready &= Math_SmoothStepToF(&pthis->radius, sHead->actor.xzDistToPlayer, 0.5f, 50.0f, 1.0f) < 10.0f; + pthis->ready &= Math_SmoothStepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 95.0f, 0.5f, 30.0f, 1.0f) < 1.0f; + + pthis->actor.world.pos.x = Math_SinS(pthis->actor.world.rot.y) * pthis->radius + sHead->actor.world.pos.x; + pthis->actor.world.pos.z = Math_CosS(pthis->actor.world.rot.y) * pthis->radius + sHead->actor.world.pos.z; + } else if (OTHER_HAND(pthis)->ready) { + pthis->timer = 20; + } +} + +void BossSst_HandSetupClap(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 3.0f); + pthis->timer = 0; + pthis->handMaxSpeed = 0x240; + pthis->handAngSpeed = 0; + pthis->ready = false; + BossSst_HandSetDamage(pthis, 0x20); + pthis->actionFunc = BossSst_HandClap; +} + +void BossSst_HandClap(BossSst* pthis, GlobalContext* globalCtx) { + static s32 dropFlag = false; + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + if (dropFlag) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, + (Rand_ZeroOne() < 0.5f) ? ITEM00_ARROWS_SMALL : ITEM00_MAGIC_SMALL); + dropFlag = false; + } + + BossSst_HandReleasePlayer(pthis, globalCtx, true); + BossSst_HandSetupEndClap(pthis); + } + } else { + if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + OTHER_HAND(pthis)->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + BossSst_HandGrabPlayer(pthis, globalCtx); + } + + if (pthis->ready) { + pthis->timer = 30; + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + if (!(player->stateFlags2 & 0x80)) { + dropFlag = true; + } + } else { + pthis->handAngSpeed += 0x40; + pthis->handAngSpeed = CLAMP_MAX(pthis->handAngSpeed, pthis->handMaxSpeed); + + if (Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, pthis->handAngSpeed)) { + if (pthis->actor.params == BONGO_LEFT_HAND) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_CLAP); + } + pthis->ready = true; + } else { + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); + } + + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y) * pthis->radius) + sHead->actor.world.pos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y) * pthis->radius) + sHead->actor.world.pos.z; + } + } + + if (player->actor.parent == &pthis->actor) { + player->unk_850 = 0; + player->actor.world.pos = pthis->actor.world.pos; + } +} + +void BossSst_HandSetupEndClap(BossSst* pthis) { + pthis->targetYaw = pthis->actor.home.rot.y - (pthis->vParity * 0x1000); + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 10.0f); + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->actionFunc = BossSst_HandEndClap; +} + +void BossSst_HandEndClap(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.z, 0, 0x200); + if (Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 0x100)) { + BossSst_HandSetupRetreat(pthis); + } + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y) * pthis->radius) + sHead->actor.world.pos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y) * pthis->radius) + sHead->actor.world.pos.z; +} + +void BossSst_HandSetupReadyGrab(BossSst* pthis) { + HAND_STATE(pthis) = HAND_GRAB; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 10.0f); + pthis->targetYaw = pthis->vParity * -0x5000; + pthis->targetRoll = pthis->vParity * 0x4000; + pthis->actionFunc = BossSst_HandReadyGrab; +} + +void BossSst_HandReadyGrab(BossSst* pthis, GlobalContext* globalCtx) { + s32 inPosition; + + SkelAnime_Update(&pthis->skelAnime); + inPosition = Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->targetRoll, 4, 0x800, 0x100) == 0; + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + pthis->targetYaw, 0xA00); + Math_ApproachF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 95.0f, 0.5f, 20.0f); + if (inPosition) { + BossSst_HandSetupGrab(pthis); + } +} + +void BossSst_HandSetupGrab(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFistPoses[pthis->actor.params], 5.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + (pthis->vParity * 0x4000); + pthis->targetYaw = pthis->actor.world.rot.y; + pthis->timer = 30; + pthis->actor.speedXZ = 0.5f; + BossSst_HandSetDamage(pthis, 0x20); + pthis->actionFunc = BossSst_HandGrab; +} + +void BossSst_HandGrab(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.world.rot.y = + ((1.0f - sinf(pthis->timer * (M_PI / 60.0f))) * (pthis->vParity * 0x2000)) + pthis->targetYaw; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y - (pthis->vParity * 0x4000); + if (pthis->timer < 5) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.5f, 25.0f, 5.0f); + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->actor.speedXZ = 0.0f; + if (player->stateFlags2 & 0x80) { + if (Rand_ZeroOne() < 0.5f) { + BossSst_HandSetupCrush(pthis); + } else { + BossSst_HandSetupSwing(pthis); + } + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, + (Rand_ZeroOne() < 0.5f) ? ITEM00_ARROWS_SMALL : ITEM00_MAGIC_SMALL); + BossSst_HandSetupRetreat(pthis); + } + } + } else { + pthis->actor.speedXZ *= 1.26f; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 70.0f); + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); + } + + if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_CATCH); + BossSst_HandGrabPlayer(pthis, globalCtx); + pthis->timer = CLAMP_MAX(pthis->timer, 5); + } + + pthis->actor.world.pos.x += pthis->actor.speedXZ * Math_SinS(pthis->actor.world.rot.y); + pthis->actor.world.pos.z += pthis->actor.speedXZ * Math_CosS(pthis->actor.world.rot.y); + if (player->stateFlags2 & 0x80) { + player->unk_850 = 0; + player->actor.world.pos = pthis->actor.world.pos; + player->actor.shape.rot.y = pthis->actor.shape.rot.y; + } +} + +void BossSst_HandSetupCrush(BossSst* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, sHandClenchAnims[pthis->actor.params], -10.0f); + pthis->timer = 20; + pthis->actionFunc = BossSst_HandCrush; +} + +void BossSst_HandCrush(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + if (!(player->stateFlags2 & 0x80)) { + BossSst_HandReleasePlayer(pthis, globalCtx, true); + BossSst_HandSetupEndCrush(pthis); + } else { + player->actor.world.pos = pthis->actor.world.pos; + if (pthis->timer == 0) { + pthis->timer = 20; + if (!LINK_IS_ADULT) { + func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S_KID); + } else { + func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S); + } + + globalCtx->damagePlayer(globalCtx, -8); + } + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_CATCH); + } + } +} + +void BossSst_HandSetupEndCrush(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 10.0f); + pthis->actionFunc = BossSst_HandEndCrush; +} + +void BossSst_HandEndCrush(BossSst* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + BossSst_HandSetupRetreat(pthis); + } +} + +void BossSst_HandSetupSwing(BossSst* pthis) { + pthis->amplitude = -0x4000; + pthis->timer = 1; + pthis->center.x = pthis->actor.world.pos.x - (Math_SinS(pthis->actor.shape.rot.y) * 200.0f); + pthis->center.y = pthis->actor.world.pos.y; + pthis->center.z = pthis->actor.world.pos.z - (Math_CosS(pthis->actor.shape.rot.y) * 200.0f); + pthis->actionFunc = BossSst_HandSwing; +} + +void BossSst_HandSwing(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 offXZ; + + if (Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->amplitude, pthis->timer * 0xE4 + 0x1C8)) { + if (pthis->amplitude != 0) { + pthis->amplitude = 0; + if (pthis->timer == 4) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 4.0f); + } + } else { + if (pthis->timer == 4) { + player->actor.shape.rot.x = 0; + player->actor.shape.rot.z = 0; + BossSst_HandSetupRetreat(pthis); + return; + } + pthis->amplitude = (pthis->timer == 3) ? -0x6000 : -0x4000; + pthis->timer++; + } + } + + pthis->actor.world.pos.y = (Math_CosS(pthis->actor.shape.rot.x + 0x4000) * 200.0f) + pthis->center.y; + offXZ = Math_SinS(pthis->actor.shape.rot.x + 0x4000) * 200.0f; + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y) * offXZ) + pthis->center.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y) * offXZ) + pthis->center.z; + if (pthis->timer != 4) { + pthis->actor.shape.rot.z = (pthis->actor.shape.rot.x + 0x4000) * pthis->vParity; + } else { + Math_ScaledStepToS(&pthis->actor.shape.rot.z, 0, 0x800); + } + + if (player->stateFlags2 & 0x80) { + player->unk_850 = 0; + Math_Vec3f_Copy(&player->actor.world.pos, &pthis->actor.world.pos); + player->actor.shape.rot.x = pthis->actor.shape.rot.x; + player->actor.shape.rot.z = (pthis->vParity * -0x4000) + pthis->actor.shape.rot.z; + } else { + Math_ScaledStepToS(&player->actor.shape.rot.x, 0, 0x600); + Math_ScaledStepToS(&player->actor.shape.rot.z, 0, 0x600); + player->actor.world.pos.x += 20.0f * Math_SinS(pthis->actor.shape.rot.y); + player->actor.world.pos.z += 20.0f * Math_CosS(pthis->actor.shape.rot.y); + } + + if ((pthis->timer == 4) && (pthis->amplitude == 0) && SkelAnime_Update(&pthis->skelAnime) && + (player->stateFlags2 & 0x80)) { + BossSst_HandReleasePlayer(pthis, globalCtx, false); + player->actor.world.pos.x += 70.0f * Math_SinS(pthis->actor.shape.rot.y); + player->actor.world.pos.z += 70.0f * Math_CosS(pthis->actor.shape.rot.y); + func_8002F71C(globalCtx, &pthis->actor, 15.0f, pthis->actor.shape.rot.y, 2.0f); + func_8002F7DC(&player->actor, NA_SE_PL_BODY_HIT); + } + + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); +} + +void BossSst_HandSetupReel(BossSst* pthis) { + HAND_STATE(pthis) = HAND_DAMAGED; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 4.0f); + pthis->timer = 36; + Math_Vec3f_Copy(&pthis->center, &pthis->actor.world.pos); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 200); + pthis->actionFunc = BossSst_HandReel; +} + +void BossSst_HandReel(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + if (!(pthis->timer % 4)) { + if (pthis->timer % 8) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 4.0f); + } else { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFistPoses[pthis->actor.params], 6.0f); + } + } + + pthis->actor.colorFilterTimer = 200; + pthis->actor.world.pos.x += Rand_CenteredFloat(20.0f); + pthis->actor.world.pos.y += Rand_CenteredFloat(20.0f); + pthis->actor.world.pos.z += Rand_CenteredFloat(20.0f); + + if (pthis->actor.world.pos.y < (pthis->actor.floorHeight + 100.0f)) { + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 100.0f, 20.0f); + } + + if (pthis->timer == 0) { + BossSst_HandSetupReadyShake(pthis); + } +} + +void BossSst_HandSetupReadyShake(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandDamagePoses[pthis->actor.params], 8.0f); + pthis->actionFunc = BossSst_HandReadyShake; +} + +void BossSst_HandReadyShake(BossSst* pthis, GlobalContext* globalCtx) { + f32 diff; + s32 inPosition; + + diff = Math_SmoothStepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 0.5f, 25.0f, 1.0f); + diff += Math_SmoothStepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 0.5f, 25.0f, 1.0f); + diff += Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 200.0f, 0.2f, 30.0f, 1.0f); + inPosition = Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x4000, 0x400); + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.z, 0, 0x1000); + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, 0x800); + inPosition &= Math_StepToS(&pthis->handZPosMod, -0x5DC, 0x1F4); + inPosition &= Math_ScaledStepToS(&pthis->handYRotMod, pthis->vParity * -0x2000, 0x800); + pthis->actor.colorFilterTimer = 200; + if ((diff < 30.0f) && inPosition) { + BossSst_HandSetupShake(pthis); + } else { + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); + } +} + +void BossSst_HandSetupShake(BossSst* pthis) { + pthis->timer = 200; + pthis->actionFunc = BossSst_HandShake; +} + +void BossSst_HandShake(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.shape.rot.x = 0x4000 + (sinf(pthis->timer * (M_PI / 5)) * 0x2000); + pthis->handYRotMod = (pthis->vParity * -0x2000) + (sinf(pthis->timer * (M_PI / 4)) * 0x2800); + + if (!(pthis->timer % 8)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_SHAKEHAND); + } + + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + if ((OTHER_HAND(pthis)->actionFunc == BossSst_HandShake) || + (OTHER_HAND(pthis)->actionFunc == BossSst_HandReadyCharge)) { + BossSst_HandSetupReadyCharge(pthis); + } else if (pthis->timer == 0) { + pthis->timer = 80; + } + } else if (pthis->timer == 0) { + pthis->actor.flags |= ACTOR_FLAG_0; + BossSst_HandSetupSlam(pthis); + } +} + +void BossSst_HandSetupReadyCharge(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFistPoses[pthis->actor.params], 10.0f); + pthis->ready = false; + pthis->actionFunc = BossSst_HandReadyCharge; +} + +void BossSst_HandReadyCharge(BossSst* pthis, GlobalContext* globalCtx) { + if (!pthis->ready) { + pthis->ready = SkelAnime_Update(&pthis->skelAnime); + pthis->ready &= Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x800); + pthis->ready &= + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y + (pthis->vParity * 0x1000), 0x800); + pthis->ready &= Math_ScaledStepToS(&pthis->handYRotMod, 0, 0x800); + pthis->ready &= Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->vParity * 0x2800, 0x800); + pthis->ready &= Math_StepToS(&pthis->handZPosMod, -0xDAC, 0x1F4); + if (pthis->ready) { + pthis->actor.colorFilterTimer = 0; + } + } else if (pthis->colliderJntSph.base.atFlags & AT_HIT) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + OTHER_HAND(pthis)->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + sHead->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + func_8002F71C(globalCtx, &pthis->actor, 10.0f, pthis->actor.shape.rot.y, 5.0f); + func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); + } +} + +void BossSst_HandSetupStunned(BossSst* hand) { + Animation_MorphToPlayOnce(&hand->skelAnime, sHandIdleAnims[hand->actor.params], 10.0f); + if (hand->actionFunc != BossSst_HandDamage) { + hand->ready = false; + } + + hand->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + hand->colliderJntSph.base.acFlags |= AC_ON; + BossSst_HandSetInvulnerable(hand, true); + Actor_SetColorFilter(&hand->actor, 0, 0xFF, 0, Animation_GetLastFrame(&gBongoHeadKnockoutAnim)); + hand->actionFunc = BossSst_HandStunned; +} + +void BossSst_HandStunned(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.world.pos.z, (Math_CosS(sHead->actor.shape.rot.y) * 200.0f) + pthis->actor.home.pos.z, + 0.5f, 25.0f); + Math_ApproachF(&pthis->actor.world.pos.x, (Math_SinS(sHead->actor.shape.rot.y) * 200.0f) + pthis->actor.home.pos.x, + 0.5f, 25.0f); + if (!pthis->ready) { + Math_ScaledStepToS(&pthis->handYRotMod, 0, 0x800); + Math_StepToS(&pthis->handZPosMod, -0xDAC, 0x1F4); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->actor.home.rot.x, 0x800); + Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->actor.home.rot.z, 0x800); + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, 0x800); + if (sHead->actionFunc == BossSst_HeadVulnerable) { + pthis->ready = true; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandDamagePoses[pthis->actor.params], 10.0f); + } + } else { + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, 30.0f); + } +} + +void BossSst_HandSetupDamage(BossSst* hand) { + hand->actor.shape.rot.x = 0; + Animation_MorphToPlayOnce(&hand->skelAnime, sHandOpenPoses[hand->actor.params], 3.0f); + hand->timer = 6; + hand->actionFunc = BossSst_HandDamage; +} + +void BossSst_HandDamage(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer >= 2) { + pthis->actor.shape.rot.x -= 0x200; + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 200.0f, 50.0f); + } else { + pthis->actor.shape.rot.x += 0x400; + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, 100.0f); + } + + if (pthis->timer == 0) { + if (pthis->actor.floorHeight >= 0.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_TAIKO_HIGH); + } + BossSst_HandSetupStunned(pthis); + } +} + +void BossSst_HandSetupThrash(BossSst* pthis) { + HAND_STATE(pthis) = HAND_DEATH; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 2.0f); + pthis->actor.shape.rot.x = 0; + pthis->timer = 160; + if (pthis->actor.params == BONGO_LEFT_HAND) { + pthis->amplitude = -0x800; + } else { + pthis->amplitude = 0; + pthis->actor.shape.rot.x = -0x800; + } + + pthis->handAngSpeed = 0x180; + pthis->actionFunc = BossSst_HandThrash; +} + +void BossSst_HandThrash(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.world.pos.z, (Math_CosS(sHead->actor.shape.rot.y) * 200.0f) + pthis->actor.home.pos.z, + 0.5f, 25.0f); + Math_ApproachF(&pthis->actor.world.pos.x, (Math_SinS(sHead->actor.shape.rot.y) * 200.0f) + pthis->actor.home.pos.x, + 0.5f, 25.0f); + if (Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->amplitude, pthis->handAngSpeed)) { + if (pthis->amplitude != 0) { + pthis->amplitude = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 5.0f); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_TAIKO_HIGH); + pthis->amplitude = -0x800; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandOpenPoses[pthis->actor.params], 5.0f); + } + + if (pthis->timer < 80.0f) { + pthis->handAngSpeed -= 0x40; + pthis->handAngSpeed = CLAMP_MIN(pthis->handAngSpeed, 0x40); + } + } + + pthis->actor.world.pos.y = + (((pthis->handAngSpeed / 256.0f) + 0.5f) * 150.0f) * (-1.0f / 0x800) * pthis->actor.shape.rot.x; + if (pthis->timer == 0) { + BossSst_HandSetupDarken(pthis); + } +} + +void BossSst_HandSetupDarken(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 5.0f); + pthis->actionFunc = BossSst_HandDarken; +} + +void BossSst_HandDarken(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x800, pthis->handAngSpeed); + Math_StepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 90.0f, 5.0f); + if (sHead->actionFunc == BossSst_HeadFall) { + BossSst_HandSetupFall(pthis); + } +} + +void BossSst_HandSetupFall(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFlatPoses[pthis->actor.params], 3.0f); + pthis->actionFunc = BossSst_HandFall; +} + +void BossSst_HandFall(BossSst* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x400); + pthis->actor.world.pos.y = sHead->actor.world.pos.y + 230.0f; + if (sHead->actionFunc == BossSst_HeadMelt) { + BossSst_HandSetupMelt(pthis); + } +} + +void BossSst_HandSetupMelt(BossSst* pthis) { + BossSst_SpawnHandShadow(pthis); + pthis->actor.shape.shadowDraw = NULL; + pthis->timer = 80; + pthis->actionFunc = BossSst_HandMelt; +} + +void BossSst_HandMelt(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.scale.y -= 0.00025f; + pthis->actor.scale.x += 0.000025f; + pthis->actor.scale.z += 0.000025f; + pthis->actor.world.pos.y = ROOM_CENTER_Y + 0.0f; + if (pthis->timer == 0) { + BossSst_HandSetupFinish(pthis); + } +} + +void BossSst_HandSetupFinish(BossSst* pthis) { + pthis->actor.draw = BossSst_DrawEffect; + pthis->timer = 20; + pthis->effects[0].status = 0; + pthis->actionFunc = BossSst_HandFinish; +} + +void BossSst_HandFinish(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + pthis->effectMode = BONGO_NULL; + } +} + +void BossSst_HandSetupRecover(BossSst* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandPushoffPoses[pthis->actor.params], 10.0f); + pthis->ready = false; + pthis->actionFunc = BossSst_HandRecover; +} + +void BossSst_HandRecover(BossSst* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, ROOM_CENTER_Y + 250.0f, 0.5f, 70.0f, 5.0f); + if (SkelAnime_Update(&pthis->skelAnime)) { + if (!pthis->ready) { + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandHangPoses[pthis->actor.params], 10.0f); + pthis->ready = true; + } + } + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); +} + +void BossSst_HandSetupFrozen(BossSst* pthis) { + s32 i; + + HAND_STATE(pthis) = HAND_FROZEN; + Math_Vec3f_Copy(&pthis->center, &pthis->actor.world.pos); + BossSst_HandSetupReadyBreakIce(OTHER_HAND(pthis)); + pthis->ready = false; + pthis->effectMode = BONGO_ICE; + pthis->timer = 35; + for (i = 0; i < 18; i++) { + pthis->effects[i].move = false; + } + + BossSst_SpawnIceCrystal(pthis, 0); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0xA); + pthis->handAngSpeed = 0; + pthis->actionFunc = BossSst_HandFrozen; +} + +void BossSst_HandFrozen(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if ((pthis->timer % 2) != 0) { + BossSst_SpawnIceCrystal(pthis, (pthis->timer >> 1) + 1); + } + + if (pthis->ready) { + BossSst_IceShatter(pthis); + BossSst_HandSetupRetreat(pthis); + sHead->ready = true; + } else { + pthis->actor.colorFilterTimer = 10; + if (pthis->handAngSpeed != 0) { + f32 offY = Math_SinS(OTHER_HAND(pthis)->actor.shape.rot.x) * 5.0f; + f32 offXZ = Math_CosS(OTHER_HAND(pthis)->actor.shape.rot.x) * 5.0f; + + if ((pthis->handAngSpeed % 2) != 0) { + offY *= -1.0f; + offXZ *= -1.0f; + } + + pthis->actor.world.pos.x = pthis->center.x + (Math_CosS(OTHER_HAND(pthis)->actor.shape.rot.y) * offXZ); + pthis->actor.world.pos.y = pthis->center.y + offY; + pthis->actor.world.pos.z = pthis->center.z + (Math_SinS(OTHER_HAND(pthis)->actor.shape.rot.y) * offXZ); + pthis->handAngSpeed--; + } + } +} + +void BossSst_HandSetupReadyBreakIce(BossSst* pthis) { + HAND_STATE(pthis) = HAND_BREAK_ICE; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHandFistPoses[pthis->actor.params], 5.0f); + pthis->ready = false; + pthis->actor.colorFilterTimer = 0; + if (pthis->effectMode == BONGO_ICE) { + pthis->effectMode = BONGO_NULL; + } + + pthis->radius = Actor_WorldDistXZToPoint(&pthis->actor, &OTHER_HAND(pthis)->center); + pthis->targetYaw = Actor_WorldYawTowardPoint(&pthis->actor, &OTHER_HAND(pthis)->center); + BossSst_HandSetInvulnerable(pthis, true); + pthis->actionFunc = BossSst_HandReadyBreakIce; +} + +void BossSst_HandReadyBreakIce(BossSst* pthis, GlobalContext* globalCtx) { + s32 inPosition; + + inPosition = Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 0x400); + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x1000, 0x400); + inPosition &= Math_ScaledStepToS(&pthis->actor.shape.rot.z, 0, 0x800); + inPosition &= Math_ScaledStepToS(&pthis->handYRotMod, 0, 0x400); + inPosition &= Math_StepToF(&pthis->actor.world.pos.y, OTHER_HAND(pthis)->center.y + 200.0f, 50.0f); + inPosition &= Math_StepToF(&pthis->radius, 400.0f, 60.0f); + pthis->actor.world.pos.x = OTHER_HAND(pthis)->center.x - (Math_SinS(pthis->targetYaw) * pthis->radius); + pthis->actor.world.pos.z = OTHER_HAND(pthis)->center.z - (Math_CosS(pthis->targetYaw) * pthis->radius); + if (SkelAnime_Update(&pthis->skelAnime) && inPosition) { + BossSst_HandSetupBreakIce(pthis); + } +} + +void BossSst_HandSetupBreakIce(BossSst* pthis) { + pthis->timer = 9; + pthis->actionFunc = BossSst_HandBreakIce; + pthis->actor.speedXZ = 0.5f; +} + +void BossSst_HandBreakIce(BossSst* pthis, GlobalContext* globalCtx) { + if ((pthis->timer % 2) != 0) { + pthis->actor.speedXZ *= 1.5f; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 60.0f); + + if (Math_StepToF(&pthis->radius, 100.0f, pthis->actor.speedXZ)) { + BossSst_SpawnIceShard(pthis); + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_ICE_BROKEN); + } + + OTHER_HAND(pthis)->handAngSpeed = 5; + } + } else { + pthis->actor.speedXZ *= 0.8f; + Math_StepToF(&pthis->radius, 500.0f, pthis->actor.speedXZ); + if (pthis->actor.speedXZ < 2.0f) { + if (pthis->timer != 0) { + pthis->timer--; + } + } + } + + pthis->actor.world.pos.x = OTHER_HAND(pthis)->center.x - (Math_SinS(pthis->targetYaw) * pthis->radius); + pthis->actor.world.pos.z = OTHER_HAND(pthis)->center.z - (Math_CosS(pthis->targetYaw) * pthis->radius); + pthis->actor.world.pos.y = OTHER_HAND(pthis)->center.y + (pthis->radius * 0.4f); + if (pthis->timer == 0) { + OTHER_HAND(pthis)->ready = true; + BossSst_HandSetupRetreat(pthis); + } + + func_8002F974(&pthis->actor, NA_SE_EN_SHADEST_HAND_FLY - SFX_FLAG); +} + +void BossSst_HandGrabPlayer(BossSst* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->grabPlayer(globalCtx, player)) { + player->actor.parent = &pthis->actor; + if (player->actor.colChkInfo.health > 0) { + pthis->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + if (HAND_STATE(pthis) == HAND_CLAP) { + OTHER_HAND(pthis)->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + } + } + } +} + +void BossSst_HandReleasePlayer(BossSst* pthis, GlobalContext* globalCtx, s32 dropPlayer) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.parent == &pthis->actor) { + player->actor.parent = NULL; + player->unk_850 = 100; + pthis->colliderJntSph.base.ocFlags1 |= OC1_ON; + OTHER_HAND(pthis)->colliderJntSph.base.ocFlags1 |= OC1_ON; + if (dropPlayer) { + func_8002F71C(globalCtx, &pthis->actor, 0.0f, pthis->actor.shape.rot.y, 0.0f); + } + } +} + +void BossSst_MoveAround(BossSst* pthis) { + BossSst* hand; + Vec3f* vec; + f32 sn; + f32 cs; + s32 i; + + sn = Math_SinS(pthis->actor.shape.rot.y); + cs = Math_CosS(pthis->actor.shape.rot.y); + if (pthis->actionFunc != BossSst_HeadEndCharge) { + pthis->actor.world.pos.x = sRoomCenter.x + (pthis->radius * sn); + pthis->actor.world.pos.z = sRoomCenter.z + (pthis->radius * cs); + } + + for (i = 0; i < 2; i++) { + hand = sHands[i]; + vec = &sHandOffsets[i]; + + hand->actor.world.pos.x = pthis->actor.world.pos.x + (vec->z * sn) + (vec->x * cs); + hand->actor.world.pos.y = pthis->actor.world.pos.y + vec->y; + hand->actor.world.pos.z = pthis->actor.world.pos.z + (vec->z * cs) - (vec->x * sn); + + hand->actor.home.pos.x = pthis->actor.world.pos.x + (400.0f * sn) + (-200.0f * hand->vParity * cs); + hand->actor.home.pos.y = pthis->actor.world.pos.y; + hand->actor.home.pos.z = pthis->actor.world.pos.z + (400.0f * cs) - (-200.0f * hand->vParity * sn); + + hand->actor.home.rot.y = pthis->actor.shape.rot.y; + hand->actor.shape.rot.y = sHandYawOffsets[i] + pthis->actor.shape.rot.y; + + if (hand->actor.world.pos.y < hand->actor.floorHeight) { + hand->actor.world.pos.y = hand->actor.floorHeight; + } + } +} + +void BossSst_HandSelectAttack(BossSst* pthis) { + f32 rand = Rand_ZeroOne() * 6.0f; + s32 randInt; + + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_DAMAGED) { + rand *= 5.0f / 6; + if (rand > 4.0f) { + rand = 4.0f; + } + } + + randInt = rand; + if (randInt == 0) { + BossSst_HandSetupReadySlam(pthis); + } else if (randInt == 1) { + BossSst_HandSetupReadySweep(pthis); + } else if (randInt == 2) { + BossSst_HandSetupReadyPunch(pthis); + } else if (randInt == 5) { + BossSst_HandSetupReadyClap(pthis); + } else { // randInt == 3 || randInt == 4 + BossSst_HandSetupReadyGrab(pthis); + } +} + +void BossSst_HandSetDamage(BossSst* pthis, s32 damage) { + s32 i; + + pthis->colliderJntSph.base.atFlags |= AT_ON; + for (i = 0; i < 11; i++) { + pthis->colliderJntSph.elements[i].info.toucher.damage = damage; + } +} + +void BossSst_HandSetInvulnerable(BossSst* pthis, s32 isInv) { + pthis->colliderJntSph.base.acFlags &= ~AC_HIT; + if (isInv) { + pthis->colliderJntSph.base.colType = COLTYPE_HARD; + pthis->colliderJntSph.base.acFlags |= AC_HARD; + } else { + pthis->colliderJntSph.base.colType = COLTYPE_HIT0; + pthis->colliderJntSph.base.acFlags &= ~AC_HARD; + } +} + +void BossSst_HeadSfx(BossSst* pthis, u16 sfxId) { + func_80078914(&pthis->center, sfxId); +} + +void BossSst_HandCollisionCheck(BossSst* pthis, GlobalContext* globalCtx) { + if ((pthis->colliderJntSph.base.acFlags & AC_HIT) && (pthis->colliderJntSph.base.colType != COLTYPE_HARD)) { + s32 bothHands = true; + + pthis->colliderJntSph.base.acFlags &= ~AC_HIT; + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + pthis->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); + pthis->colliderJntSph.base.acFlags &= ~AC_ON; + pthis->colliderJntSph.base.ocFlags1 &= ~OC1_NO_PUSH; + BossSst_HandReleasePlayer(pthis, globalCtx, true); + if (HAND_STATE(OTHER_HAND(pthis)) == HAND_CLAP) { + BossSst_HandReleasePlayer(OTHER_HAND(pthis), globalCtx, true); + BossSst_HandSetupRetreat(OTHER_HAND(pthis)); + } + + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->actor.colChkInfo.damageEffect == 3) { + BossSst_HandSetupFrozen(pthis); + } else { + BossSst_HandSetupReel(pthis); + if (HAND_STATE(OTHER_HAND(pthis)) != HAND_DAMAGED) { + bothHands = false; + } + } + + BossSst_HeadSetupDamagedHand(sHead, bothHands); + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, + (Rand_ZeroOne() < 0.5f) ? ITEM00_ARROWS_SMALL : ITEM00_MAGIC_SMALL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_DAMAGE_HAND); + } + } +} + +void BossSst_HeadCollisionCheck(BossSst* pthis, GlobalContext* globalCtx) { + if (pthis->colliderCyl.base.acFlags & AC_HIT) { + pthis->colliderCyl.base.acFlags &= ~AC_HIT; + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (pthis->actionFunc == BossSst_HeadVulnerable) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + BossSst_HeadSetupDeath(pthis, globalCtx); + } else { + BossSst_HeadSetupDamage(pthis); + } + + BossSst_HandSetupDamage(sHands[LEFT]); + BossSst_HandSetupDamage(sHands[RIGHT]); + } else { + BossSst_HeadSetupStunned(pthis); + if (HAND_STATE(sHands[RIGHT]) == HAND_FROZEN) { + BossSst_IceShatter(sHands[RIGHT]); + } else if (HAND_STATE(sHands[LEFT]) == HAND_FROZEN) { + BossSst_IceShatter(sHands[LEFT]); + } + + BossSst_HandSetupStunned(sHands[RIGHT]); + BossSst_HandSetupStunned(sHands[LEFT]); + } + } + } +} + +void BossSst_UpdateHand(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossSst* pthis = (BossSst*)thisx; + BossSstHandTrail* trail; + + if (pthis->colliderCyl.base.atFlags & AT_ON) { + if ((pthis->effects[0].move < 5) || + (pthis->actor.xzDistToPlayer < ((pthis->effects[2].scale * 0.01f) * sCylinderInitHand.dim.radius)) || + (pthis->colliderCyl.base.atFlags & AT_HIT)) { + pthis->colliderCyl.base.atFlags &= ~(AT_ON | AT_HIT); + } else { + pthis->colliderCyl.dim.radius = (pthis->effects[0].scale * 0.01f) * sCylinderInitHand.dim.radius; + } + } + + BossSst_HandCollisionCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 130.0f, 0.0f, 5); + Actor_SetFocus(&pthis->actor, 0.0f); + if (pthis->colliderJntSph.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + + if ((sHead->actionFunc != BossSst_HeadLurk) && (sHead->actionFunc != BossSst_HeadIntro) && + (pthis->colliderJntSph.base.acFlags & AC_ON)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + + if (pthis->colliderJntSph.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + + if (pthis->colliderCyl.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCyl.base); + } + + if ((HAND_STATE(pthis) != HAND_DEATH) && (HAND_STATE(pthis) != HAND_WAIT) && (HAND_STATE(pthis) != HAND_BEAT) && + (HAND_STATE(pthis) != HAND_FROZEN)) { + pthis->trailCount++; + pthis->trailCount = CLAMP_MAX(pthis->trailCount, 7); + } else { + pthis->trailCount--; + pthis->trailCount = CLAMP_MIN(pthis->trailCount, 0); + } + + trail = &pthis->handTrails[pthis->trailIndex]; + Math_Vec3f_Copy(&trail->world.pos, &pthis->actor.world.pos); + trail->world.rot = pthis->actor.shape.rot; + trail->zPosMod = pthis->handZPosMod; + trail->yRotMod = pthis->handYRotMod; + + pthis->trailIndex = (pthis->trailIndex + 1) % 7; + BossSst_UpdateEffect(&pthis->actor, globalCtx); +} + +void BossSst_UpdateHead(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossSst* pthis = (BossSst*)thisx; + + func_8002DBD0(&pthis->actor, &sHandOffsets[RIGHT], &sHands[RIGHT]->actor.world.pos); + func_8002DBD0(&pthis->actor, &sHandOffsets[LEFT], &sHands[LEFT]->actor.world.pos); + + sHandYawOffsets[LEFT] = sHands[LEFT]->actor.shape.rot.y - thisx->shape.rot.y; + sHandYawOffsets[RIGHT] = sHands[RIGHT]->actor.shape.rot.y - thisx->shape.rot.y; + + BossSst_HeadCollisionCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + if (pthis->vVanish) { + if ((globalCtx->actorCtx.unk_03 == 0) || (thisx->colorFilterTimer != 0)) { + pthis->actor.flags &= ~ACTOR_FLAG_7; + } else { + pthis->actor.flags |= ACTOR_FLAG_7; + } + } + + if (pthis->colliderJntSph.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + + if ((pthis->actionFunc != BossSst_HeadLurk) && (pthis->actionFunc != BossSst_HeadIntro)) { + if (pthis->colliderCyl.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCyl.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + + if (pthis->colliderJntSph.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); + } + + BossSst_MoveAround(pthis); + if ((!pthis->vVanish || CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) && + ((pthis->actionFunc == BossSst_HeadReadyCharge) || (pthis->actionFunc == BossSst_HeadCharge) || + (pthis->actionFunc == BossSst_HeadFrozenHand) || (pthis->actionFunc == BossSst_HeadStunned) || + (pthis->actionFunc == BossSst_HeadVulnerable) || (pthis->actionFunc == BossSst_HeadDamage))) { + pthis->actor.flags |= ACTOR_FLAG_0; + } else { + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + + if (pthis->actionFunc == BossSst_HeadCharge) { + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_MOVE - SFX_FLAG); + } + + BossSst_UpdateEffect(&pthis->actor, globalCtx); +} + +s32 BossSst_OverrideHandDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + BossSst* pthis = (BossSst*)thisx; + + if (limbIndex == 1) { + pos->z += pthis->handZPosMod; + rot->y += pthis->handYRotMod; + } + return false; +} + +void BossSst_PostHandDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + BossSst* pthis = (BossSst*)thisx; + + Collider_UpdateSpheres(limbIndex, &pthis->colliderJntSph); +} + +s32 BossSst_OverrideHandTrailDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* data, Gfx** gfx) { + BossSstHandTrail* trail = (BossSstHandTrail*)data; + + if (limbIndex == 1) { + pos->z += trail->zPosMod; + rot->y += trail->yRotMod; + } + return false; +} + +void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { + BossSst* pthis = (BossSst*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6563); + + func_80093D18(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x80, sBodyColor.r, sBodyColor.g, sBodyColor.b, 255); + + if (!sBodyStatic) { + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + } else { + gDPSetEnvColor(POLY_OPA_DISP++, sStaticColor.r, sStaticColor.g, sStaticColor.b, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, sBodyStaticDList); + } + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + BossSst_OverrideHandDraw, BossSst_PostHandDraw, pthis); + if (pthis->trailCount >= 2) { + BossSstHandTrail* trail; + BossSstHandTrail* trail2; + s32 i; + s32 idx; + s32 end; + s32 pad; + + func_80093D84(globalCtx->state.gfxCtx); + + end = pthis->trailCount >> 1; + idx = (pthis->trailIndex + 4) % 7; + trail = &pthis->handTrails[idx]; + trail2 = &pthis->handTrails[(idx + 2) % 7]; + + for (i = 0; i < end; i++) { + if (Math3D_Vec3fDistSq(&trail2->world.pos, &trail->world.pos) > 900.0f) { + func_800D1694(trail->world.pos.x, trail->world.pos.y, trail->world.pos.z, &trail->world.rot); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, sHandTrailDList); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, ((3 - i) * 10) + 20, 0, ((3 - i) * 20) + 50, + ((3 - i) * 30) + 70); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossSst_OverrideHandTrailDraw, NULL, + trail, POLY_XLU_DISP); + } + idx = (idx + 5) % 7; + trail2 = trail; + trail = &pthis->handTrails[idx]; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6654); + + BossSst_DrawEffect(&pthis->actor, globalCtx); +} + +s32 BossSst_OverrideHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + BossSst* pthis = (BossSst*)thisx; + s32 shakeAmp; + s32 pad; + s32 timer12; + f32 shakeMod; + + if (!CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7) && pthis->vVanish) { + *dList = NULL; + } else if (pthis->actionFunc == BossSst_HeadThrash) { // Animation modifications for death cutscene + shakeAmp = (pthis->timer / 10) + 1; + if ((limbIndex == 3) || (limbIndex == 39) || (limbIndex == 42)) { + + shakeMod = sinf(pthis->timer * (M_PI / 5)); + rot->x += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; + + shakeMod = sinf((pthis->timer % 5) * (M_PI / 5)); + rot->z -= ((0x800 * Rand_ZeroOne() + 0x1000) / 0x10) * shakeAmp * shakeMod + 0x1000; + + if (limbIndex == 3) { + + shakeMod = sinf(pthis->timer * (M_PI / 5)); + rot->y += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; + } + } else if ((limbIndex == 5) || (limbIndex == 6)) { + + shakeMod = sinf((pthis->timer % 5) * (M_PI / 5)); + rot->z -= ((0x280 * Rand_ZeroOne() + 0x500) / 0x10) * shakeAmp * shakeMod + 0x500; + + if (limbIndex == 5) { + + shakeMod = sinf(pthis->timer * (M_PI / 5)); + rot->x += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; + + shakeMod = sinf(pthis->timer * (M_PI / 5)); + rot->y += ((0x500 * Rand_ZeroOne() + 0xA00) / 0x10) * shakeAmp * shakeMod; + } + } else if (limbIndex == 2) { + shakeMod = sinf(pthis->timer * (M_PI / 5)); + rot->x += ((0x200 * Rand_ZeroOne() + 0x400) / 0x10) * shakeAmp * shakeMod; + + shakeMod = sinf(pthis->timer * (M_PI / 5)); + rot->y += ((0x200 * Rand_ZeroOne() + 0x400) / 0x10) * shakeAmp * shakeMod; + + shakeMod = sinf((pthis->timer % 5) * (M_PI / 5)); + rot->z -= ((0x100 * Rand_ZeroOne() + 0x200) / 0x10) * shakeAmp * shakeMod + 0x200; + } + } else if (pthis->actionFunc == BossSst_HeadDeath) { + if (pthis->timer > 48) { + timer12 = pthis->timer - 36; + } else { + pad = ((pthis->timer > 6) ? 6 : pthis->timer); + timer12 = pad * 2; + } + + if ((limbIndex == 3) || (limbIndex == 39) || (limbIndex == 42)) { + rot->z -= 0x2000 * sinf(timer12 * (M_PI / 24)); + } else if ((limbIndex == 5) || (limbIndex == 6)) { + rot->z -= 0xA00 * sinf(timer12 * (M_PI / 24)); + } else if (limbIndex == 2) { + rot->z -= 0x400 * sinf(timer12 * (M_PI / 24)); + } + } else if ((pthis->actionFunc == BossSst_HeadDarken) || (pthis->actionFunc == BossSst_HeadFall) || + (pthis->actionFunc == BossSst_HeadMelt)) { + if ((limbIndex == 3) || (limbIndex == 39) || (limbIndex == 42)) { + rot->z -= 0x1000; + } else if ((limbIndex == 5) || (limbIndex == 6)) { + rot->z -= 0x500; + } else if (limbIndex == 2) { + rot->z -= 0x200; + } + } + return false; +} + +void BossSst_PostHeadDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + static Vec3f headVec = { 1000.0f, 0.0f, 0.0f }; + BossSst* pthis = (BossSst*)thisx; + Vec3f headPos; + + if (limbIndex == 8) { + Matrix_MultVec3f(&zeroVec, &pthis->actor.focus.pos); + Matrix_MultVec3f(&headVec, &headPos); + pthis->colliderCyl.dim.pos.x = headPos.x; + pthis->colliderCyl.dim.pos.y = headPos.y; + pthis->colliderCyl.dim.pos.z = headPos.z; + } + + Collider_UpdateSpheres(limbIndex, &pthis->colliderJntSph); +} + +void BossSst_DrawHead(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossSst* pthis = (BossSst*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6810); + + if (!CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x80, sBodyColor.r, sBodyColor.g, sBodyColor.b, 255); + if (!sBodyStatic) { + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + } else { + gDPSetEnvColor(POLY_OPA_DISP++, sStaticColor.r, sStaticColor.g, sStaticColor.b, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, sBodyStaticDList); + } + } else { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, 255); + gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[2]); + } + + if (pthis->actionFunc == BossSst_HeadThrash) { + f32 randPitch = Rand_ZeroOne() * (2 * M_PI); + f32 randYaw = Rand_ZeroOne() * (2 * M_PI); + + Matrix_RotateY(randYaw, MTXMODE_APPLY); + Matrix_RotateX(randPitch, MTXMODE_APPLY); + Matrix_Scale((pthis->timer * 0.000375f) + 1.0f, 1.0f - (pthis->timer * 0.00075f), + (pthis->timer * 0.000375f) + 1.0f, MTXMODE_APPLY); + Matrix_RotateX(-randPitch, MTXMODE_APPLY); + Matrix_RotateY(-randYaw, MTXMODE_APPLY); + } + + if (!CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossSst_OverrideHeadDraw, BossSst_PostHeadDraw, + pthis, POLY_OPA_DISP); + } else { + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossSst_OverrideHeadDraw, BossSst_PostHeadDraw, + pthis, POLY_XLU_DISP); + } + + if ((pthis->actionFunc == BossSst_HeadIntro) && (113 >= pthis->timer) && (pthis->timer > 20)) { + s32 yOffset; + Vec3f vanishMaskPos; + Vec3f vanishMaskOffset; + + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 18, 255); + + yOffset = 113 * 8 - pthis->timer * 8; + vanishMaskPos.x = ROOM_CENTER_X + 85.0f; + vanishMaskPos.y = ROOM_CENTER_Y - 250.0f + yOffset; + vanishMaskPos.z = ROOM_CENTER_Z + 190.0f; + if (vanishMaskPos.y > 450.0f) { + vanishMaskPos.y = 450.0f; + } + + Matrix_MultVec3fExt(&vanishMaskPos, &vanishMaskOffset, &globalCtx->billboardMtxF); + Matrix_Translate(pthis->actor.world.pos.x + vanishMaskOffset.x, pthis->actor.world.pos.y + vanishMaskOffset.y, + pthis->actor.world.pos.z + vanishMaskOffset.z, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6934), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sIntroVanishDList); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 6941); + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &pthis->actor.focus.pos, &pthis->center); + BossSst_DrawEffect(&pthis->actor, globalCtx); +} + +void BossSst_SpawnHeadShadow(BossSst* pthis) { + static Vec3f shadowOffset[] = { + { 0.0f, 0.0f, 340.0f }, + { -160.0f, 0.0f, 250.0f }, + { 160.0f, 0.0f, 250.0f }, + }; + s32 pad; + s32 i; + f32 sn; + f32 cs; + + pthis->effectMode = BONGO_SHADOW; + sn = Math_SinS(pthis->actor.shape.rot.y); + cs = Math_CosS(pthis->actor.shape.rot.y); + + for (i = 0; i < 3; i++) { + BossSstEffect* shadow = &pthis->effects[i]; + Vec3f* offset = &shadowOffset[i]; + + shadow->pos.x = pthis->actor.world.pos.x + (sn * offset->z) + (cs * offset->x); + shadow->pos.y = 0.0f; + shadow->pos.z = pthis->actor.world.pos.z + (cs * offset->z) - (sn * offset->x); + + shadow->scale = 1450; + shadow->alpha = 254; + shadow->status = 65; + } + + pthis->effects[3].status = -1; +} + +void BossSst_SpawnHandShadow(BossSst* pthis) { + pthis->effectMode = BONGO_SHADOW; + pthis->effects[0].pos.x = pthis->actor.world.pos.x + (Math_CosS(pthis->actor.shape.rot.y) * 30.0f * pthis->vParity); + pthis->effects[0].pos.z = pthis->actor.world.pos.z - (Math_SinS(pthis->actor.shape.rot.y) * 30.0f * pthis->vParity); + pthis->effects[0].pos.y = pthis->actor.world.pos.y; + pthis->effects[0].scale = 2300; + pthis->effects[0].alpha = 254; + pthis->effects[0].status = 5; + pthis->effects[1].status = -1; +} + +void BossSst_SpawnShockwave(BossSst* pthis) { + s32 i; + s32 scale = 120; + s32 alpha = 250; + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHADEST_HAND_WAVE); + pthis->effectMode = BONGO_SHOCKWAVE; + + for (i = 0; i < 3; i++) { + BossSstEffect* shockwave = &pthis->effects[i]; + + Math_Vec3f_Copy(&shockwave->pos, &pthis->actor.world.pos); + shockwave->move = (i + 9) * 2; + shockwave->scale = scale; + shockwave->alpha = alpha / shockwave->move; + scale -= 50; + alpha -= 25; + } +} + +void BossSst_SpawnIceCrystal(BossSst* pthis, s32 index) { + BossSstEffect* ice = &pthis->effects[index]; + Sphere16* sphere; + + if (index < 11) { + sphere = &pthis->colliderJntSph.elements[index].dim.worldSphere; + + ice->pos.x = sphere->center.x; + ice->pos.y = sphere->center.y; + ice->pos.z = sphere->center.z; + if (index == 0) { + ice->pos.x -= 25.0f; + ice->pos.y -= 25.0f; + ice->pos.z -= 25.0f; + } + } else { + sphere = &pthis->colliderJntSph.elements[0].dim.worldSphere; + + ice->pos.x = ((((index - 11) & 1) ? 1 : -1) * 25.0f) + sphere->center.x; + ice->pos.y = ((((index - 11) & 2) ? 1 : -1) * 25.0f) + sphere->center.y; + ice->pos.z = ((((index - 11) & 4) ? 1 : -1) * 25.0f) + sphere->center.z; + } + + ice->pos.x -= pthis->actor.world.pos.x; + ice->pos.y -= pthis->actor.world.pos.y; + ice->pos.z -= pthis->actor.world.pos.z; + + ice->status = 0; + + ice->rot.x = Rand_ZeroOne() * 0x10000; + ice->rot.y = Rand_ZeroOne() * 0x10000; + ice->rot.z = Rand_ZeroOne() * 0x10000; + + ice->alpha = 120; + ice->move = true; + + ice->vel.x = (Rand_ZeroOne() * 0.06f + 0.12f) * ice->pos.x; + ice->vel.y = (Rand_ZeroOne() * 15.0f + 5.0f); + ice->vel.z = (Rand_ZeroOne() * 0.06f + 0.12f) * ice->pos.z; + ice->scale = 4000; + + if ((index % 2) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_FREEZE_S); + } +} + +void BossSst_SpawnIceShard(BossSst* pthis) { + s32 i; + Vec3f spawnPos; + f32 offXZ; + + pthis->effectMode = BONGO_ICE; + offXZ = Math_CosS(pthis->actor.shape.rot.x) * 50.0f; + spawnPos.x = Math_CosS(pthis->actor.shape.rot.y) * offXZ + pthis->actor.world.pos.x; + spawnPos.y = Math_SinS(pthis->actor.shape.rot.x) * 50.0f + pthis->actor.world.pos.y - 10.0f; + spawnPos.z = Math_SinS(pthis->actor.shape.rot.y) * offXZ + pthis->actor.world.pos.z; + + for (i = 0; i < 18; i++) { + BossSstEffect* ice = &pthis->effects[i]; + + Math_Vec3f_Copy(&ice->pos, &spawnPos); + ice->status = 1; + ice->rot.x = Rand_ZeroOne() * 0x10000; + ice->rot.y = Rand_ZeroOne() * 0x10000; + ice->rot.z = Rand_ZeroOne() * 0x10000; + + ice->alpha = 120; + ice->move = true; + + ice->vel.x = Rand_CenteredFloat(20.0f); + ice->vel.y = Rand_ZeroOne() * 10.0f + 3.0f; + ice->vel.z = Rand_CenteredFloat(20.0f); + + ice->scale = Rand_ZeroOne() * 200.0f + 400.0f; + } +} + +void BossSst_IceShatter(BossSst* pthis) { + s32 i; + + pthis->effects[0].status = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_ICE_BROKEN); + + for (i = 0; i < 18; i++) { + BossSstEffect* ice = &pthis->effects[i]; + + if (ice->move) { + ice->pos.x += pthis->actor.world.pos.x; + ice->pos.y += pthis->actor.world.pos.y; + ice->pos.z += pthis->actor.world.pos.z; + } + } +} + +void BossSst_UpdateEffect(Actor* thisx, GlobalContext* globalCtx) { + BossSst* pthis = (BossSst*)thisx; + BossSstEffect* effect; + s32 i; + + if (pthis->effectMode != BONGO_NULL) { + if (pthis->effectMode == BONGO_ICE) { + if (pthis->effects[0].status) { + for (i = 0; i < 18; i++) { + effect = &pthis->effects[i]; + + if (effect->move) { + effect->pos.x += effect->vel.x; + effect->pos.y += effect->vel.y; + effect->pos.z += effect->vel.z; + effect->alpha -= 3; + effect->vel.y -= 1.0f; + effect->rot.x += 0xD00; + effect->rot.y += 0x1100; + effect->rot.z += 0x1500; + } + } + } + if (pthis->effects[0].alpha == 0) { + pthis->effectMode = BONGO_NULL; + } + } else if (pthis->effectMode == BONGO_SHOCKWAVE) { + for (i = 0; i < 3; i++) { + BossSstEffect* effect2 = &pthis->effects[i]; + s32 scale = effect2->move * 2; + + effect2->scale += CLAMP_MAX(scale, 20) + i; + if (effect2->move != 0) { + effect2->move--; + } + } + + if (pthis->effects[0].move == 0) { + pthis->effectMode = BONGO_NULL; + } + } else if (pthis->effectMode == BONGO_SHADOW) { + effect = &pthis->effects[0]; + + if (pthis->actor.params == BONGO_HEAD) { + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &pthis->actor.focus.pos, &pthis->center); + BossSst_HeadSfx(pthis, NA_SE_EN_SHADEST_LAST - SFX_FLAG); + } + while (effect->status != -1) { + if (effect->status == 0) { + effect->alpha -= 2; + } else { + effect->scale += effect->status; + } + + effect->scale = CLAMP_MAX(effect->scale, 10000); + effect++; + } + } + } +} + +void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BossSst* pthis = (BossSst*)thisx; + s32 i; + BossSstEffect* effect; + + if (pthis->effectMode != BONGO_NULL) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7302); + + func_80093D84(globalCtx->state.gfxCtx); + if (pthis->effectMode == BONGO_ICE) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->gameplayFrames % 256, 0x20, 0x10, 1, + 0, (globalCtx->gameplayFrames * 2) % 256, 0x40, 0x20)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, pthis->effects[0].alpha); + gSPDisplayList(POLY_XLU_DISP++, gBongoIceCrystalDL); + + for (i = 0; i < 18; i++) { + effect = &pthis->effects[i]; + if (effect->move) { + func_8003435C(&effect->pos, globalCtx); + if (pthis->effects[0].status != 0) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + } else { + Matrix_Translate(effect->pos.x + pthis->actor.world.pos.x, + effect->pos.y + pthis->actor.world.pos.y, + effect->pos.z + pthis->actor.world.pos.z, MTXMODE_NEW); + } + + Matrix_RotateZYX(effect->rot.x, effect->rot.y, effect->rot.z, MTXMODE_APPLY); + Matrix_Scale(effect->scale * 0.001f, effect->scale * 0.001f, effect->scale * 0.001f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7350), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBongoIceShardDL); + } + } + } else if (pthis->effectMode == BONGO_SHOCKWAVE) { + f32 scaleY = 0.005f; + + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, 0, 0x20, 0x40, 1, + 0, (globalCtx->gameplayFrames * -15) % 256, 0x20, 0x40)); + + for (i = 0; i < 3; i++, scaleY -= 0.001f) { + effect = &pthis->effects[i]; + + if (effect->move != 0) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale * 0.001f, scaleY, effect->scale * 0.001f, MTXMODE_APPLY); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 30, 0, 30, effect->alpha * effect->move); + gDPSetEnvColor(POLY_XLU_DISP++, 30, 0, 30, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7396), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFireCircleDL); + } + } + } else if (pthis->effectMode == BONGO_SHADOW) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 10, 10, 80, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 10, 10, 10, pthis->effects[0].alpha); + + effect = &pthis->effects[0]; + while (effect->status != -1) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale * 0.001f, 1.0f, effect->scale * 0.001f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7423), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sShadowDList); + effect++; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_sst.c", 7433); + } +} diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst_colchk.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst_colchk.cpp similarity index 100% rename from src/overlays/actors/ovl_Boss_Sst/z_boss_sst_colchk.c rename to src/overlays/actors/ovl_Boss_Sst/z_boss_sst_colchk.cpp diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.cpp similarity index 55% rename from src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c rename to src/overlays/actors/ovl_Boss_Tw/z_boss_tw.cpp index 3a5c9ccce..419886d21 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.cpp @@ -84,58 +84,58 @@ void BossTw_Destroy(Actor* thisx, GlobalContext* globalCtx); void BossTw_Update(Actor* thisx, GlobalContext* globalCtx); void BossTw_Draw(Actor* thisx, GlobalContext* globalCtx); -void BossTw_TwinrovaDamage(BossTw* this, GlobalContext* globalCtx, u8 arg2); -void BossTw_TwinrovaSetupFly(BossTw* this, GlobalContext* globalCtx); +void BossTw_TwinrovaDamage(BossTw* pthis, GlobalContext* globalCtx, u8 arg2); +void BossTw_TwinrovaSetupFly(BossTw* pthis, GlobalContext* globalCtx); void BossTw_DrawEffects(GlobalContext* globalCtx); -void BossTw_TwinrovaLaugh(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaFly(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaGetUp(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupGetUp(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupLaugh(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaDoneBlastShoot(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupDoneBlastShoot(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupShootBlast(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupChargeBlast(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaArriveAtTarget(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_CSWait(BossTw* this, GlobalContext* globalCtx); -void BossTw_DeathCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaMergeCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupMergeCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_MergeCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_Spin(BossTw* this, GlobalContext* globalCtx); -void BossTw_Laugh(BossTw* this, GlobalContext* globalCtx); -void BossTw_SetupLaugh(BossTw* this, GlobalContext* globalCtx); -void BossTw_FinishBeamShoot(BossTw* this, GlobalContext* globalCtx); -void BossTw_SetupFinishBeamShoot(BossTw* this, GlobalContext* globalCtx); -void BossTw_SetupHitByBeam(BossTw* this, GlobalContext* globalCtx); -void BossTw_HitByBeam(BossTw* this, GlobalContext* globalCtx); -void BossTw_Wait(BossTw* this, GlobalContext* globalCtx); -void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx); -void BossTw_FlyTo(BossTw* this, GlobalContext* globalCtx); -void BossTw_SetupShootBeam(BossTw* this, GlobalContext* globalCtx); -void BossTw_TurnToPlayer(BossTw* this, GlobalContext* globalCtx); +void BossTw_TwinrovaLaugh(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaFly(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaGetUp(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupGetUp(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupLaugh(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaDoneBlastShoot(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupDoneBlastShoot(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupShootBlast(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupChargeBlast(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaArriveAtTarget(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaDeathCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaIntroCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_CSWait(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_DeathCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaMergeCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupMergeCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_MergeCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_Spin(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_Laugh(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_SetupLaugh(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_FinishBeamShoot(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_SetupFinishBeamShoot(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_SetupHitByBeam(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_HitByBeam(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_Wait(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_ShootBeam(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_FlyTo(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_SetupShootBeam(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TurnToPlayer(BossTw* pthis, GlobalContext* globalCtx); void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx); void BossTw_TwinrovaDraw(Actor* thisx, GlobalContext* globalCtx); -void BossTw_SetupWait(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupIntroCS(BossTw* this, GlobalContext* globalCtx); -void BossTw_SetupFlyTo(BossTw* this, GlobalContext* globalCtx); -void BossTw_SetupCSWait(BossTw* this, GlobalContext* globalCtx); +void BossTw_SetupWait(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupIntroCS(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_SetupFlyTo(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_SetupCSWait(BossTw* pthis, GlobalContext* globalCtx); void BossTw_BlastUpdate(Actor* thisx, GlobalContext* globalCtx); void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx); -void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx); -void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx); -void BossTw_DeathBall(BossTw* this, GlobalContext* globalCtx); +void BossTw_BlastFire(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_BlastIce(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_DeathBall(BossTw* pthis, GlobalContext* globalCtx); void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx); -void BossTw_TwinrovaStun(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSpin(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaShootBlast(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaChargeBlast(BossTw* this, GlobalContext* globalCtx); -void BossTw_TwinrovaSetupSpin(BossTw* this, GlobalContext* globalCtx); +void BossTw_TwinrovaStun(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSpin(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaShootBlast(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaChargeBlast(BossTw* pthis, GlobalContext* globalCtx); +void BossTw_TwinrovaSetupSpin(BossTw* pthis, GlobalContext* globalCtx); void BossTw_UpdateEffects(GlobalContext* globalCtx); -const ActorInit Boss_Tw_InitVars = { +ActorInit Boss_Tw_InitVars = { ACTOR_BOSS_TW, ACTORCAT_BOSS, FLAGS, @@ -257,7 +257,7 @@ void BossTw_AddDotEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec3f* init s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < countLimit; i++, eff++) { + for (i = 0, eff = (BossTwEffect*)globalCtx->specialEffects; i < countLimit; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_DOT; eff->pos = *initalPos; @@ -277,7 +277,7 @@ void BossTw_AddDmgCloud(GlobalContext* globalCtx, s16 type, Vec3f* initialPos, V s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < countLimit; i++, eff++) { + for (i = 0, eff = (BossTwEffect*)globalCtx->specialEffects; i < countLimit; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = type; eff->pos = *initialPos; @@ -297,7 +297,7 @@ void BossTw_AddRingEffect(GlobalContext* globalCtx, Vec3f* initalPos, f32 scale, s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < arg7; i++, eff++) { + for (i = 0, eff = (BossTwEffect*)globalCtx->specialEffects; i < arg7; i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_RING; eff->pos = *initalPos; @@ -319,7 +319,7 @@ void BossTw_AddPlayerFreezeEffect(GlobalContext* globalCtx, Actor* target) { BossTwEffect* eff; s16 i; - for (eff = globalCtx->specialEffects, i = 0; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (eff = (BossTwEffect*)globalCtx->specialEffects, i = 0; i < ARRAY_COUNT(sTwEffects); i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_PLYR_FRZ; eff->curSpeed = sZeroVector; @@ -344,7 +344,7 @@ void BossTw_AddFlameEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec3f* in s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (i = 0, eff = (BossTwEffect*)globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_FLAME; eff->pos = *initalPos; @@ -364,7 +364,7 @@ void BossTw_AddMergeFlameEffect(GlobalContext* globalCtx, Vec3f* initialPos, f32 s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (i = 0, eff = (BossTwEffect*)globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_MERGEFLAME; eff->pos = *initialPos; @@ -387,7 +387,7 @@ void BossTw_AddShieldBlastEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec s16 i; BossTwEffect* eff; - for (i = 0, eff = globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { + for (i = 0, eff = (BossTwEffect*)globalCtx->specialEffects; i < ARRAY_COUNT(sTwEffects); i++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_SHLD_BLST; eff->pos = *initalPos; @@ -414,7 +414,7 @@ void BossTw_AddShieldDeflectEffect(GlobalContext* globalCtx, f32 arg1, s16 arg2) sShieldHitYaw = player->actor.shape.rot.y; for (i = 0; i < 8; i++) { - for (eff = globalCtx->specialEffects, j = 0; j < ARRAY_COUNT(sTwEffects); j++, eff++) { + for (eff = (BossTwEffect*)globalCtx->specialEffects, j = 0; j < ARRAY_COUNT(sTwEffects); j++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_SHLD_DEFL; eff->pos = sShieldHitPos; @@ -444,7 +444,7 @@ void BossTw_AddShieldHitEffect(GlobalContext* globalCtx, f32 arg1, s16 arg2) { sShieldHitYaw = player->actor.shape.rot.y; for (i = 0; i < 8; i++) { - for (eff = globalCtx->specialEffects, j = 0; j < ARRAY_COUNT(sTwEffects); j++, eff++) { + for (eff = (BossTwEffect*)globalCtx->specialEffects, j = 0; j < ARRAY_COUNT(sTwEffects); j++, eff++) { if (eff->type == TWEFF_NONE) { eff->type = TWEFF_SHLD_HIT; eff->pos = sShieldHitPos; @@ -466,31 +466,31 @@ void BossTw_AddShieldHitEffect(GlobalContext* globalCtx, f32 arg1, s16 arg2) { void BossTw_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; s16 i; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); - if (this->actor.params >= TW_FIRE_BLAST) { + if (pthis->actor.params >= TW_FIRE_BLAST) { // Blasts - Actor_SetScale(&this->actor, 0.01f); - this->actor.update = BossTw_BlastUpdate; - this->actor.draw = BossTw_BlastDraw; - this->actor.flags &= ~ACTOR_FLAG_0; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.update = BossTw_BlastUpdate; + pthis->actor.draw = BossTw_BlastDraw; + pthis->actor.flags &= ~ACTOR_FLAG_0; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitBlasts); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInitBlasts); - if (this->actor.params == TW_FIRE_BLAST || this->actor.params == TW_FIRE_BLAST_GROUND) { - this->actionFunc = BossTw_BlastFire; - this->collider.info.toucher.effect = 1; - } else if (this->actor.params == TW_ICE_BLAST || this->actor.params == TW_ICE_BLAST_GROUND) { - this->actionFunc = BossTw_BlastIce; - } else if (this->actor.params >= TW_DEATHBALL_KOTAKE) { - this->actionFunc = BossTw_DeathBall; - this->actor.draw = BossTw_DrawDeathBall; - this->workf[TAIL_ALPHA] = 128.0f; + if (pthis->actor.params == TW_FIRE_BLAST || pthis->actor.params == TW_FIRE_BLAST_GROUND) { + pthis->actionFunc = BossTw_BlastFire; + pthis->collider.info.toucher.effect = 1; + } else if (pthis->actor.params == TW_ICE_BLAST || pthis->actor.params == TW_ICE_BLAST_GROUND) { + pthis->actionFunc = BossTw_BlastIce; + } else if (pthis->actor.params >= TW_DEATHBALL_KOTAKE) { + pthis->actionFunc = BossTw_DeathBall; + pthis->actor.draw = BossTw_DrawDeathBall; + pthis->workf[TAIL_ALPHA] = 128.0f; if (thisx->params == TW_DEATHBALL_KOTAKE) { thisx->world.rot.y = sTwinrovaPtr->actor.world.rot.y + 0x4000; @@ -499,14 +499,14 @@ void BossTw_Init(Actor* thisx, GlobalContext* globalCtx2) { } } - this->timers[1] = 150; + pthis->timers[1] = 150; return; } - Actor_SetScale(&this->actor, 2.5 * 0.01f); - this->actor.colChkInfo.mass = 255; - this->actor.colChkInfo.health = 0; - Collider_InitCylinder(globalCtx, &this->collider); + Actor_SetScale(&pthis->actor, 2.5 * 0.01f); + pthis->actor.colChkInfo.mass = 255; + pthis->actor.colChkInfo.health = 0; + Collider_InitCylinder(globalCtx, &pthis->collider); if (!sTwInitalized) { sTwInitalized = true; @@ -528,95 +528,95 @@ void BossTw_Init(Actor* thisx, GlobalContext* globalCtx2) { } } - if (this->actor.params == TW_KOTAKE) { - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitKoumeKotake); - this->actor.naviEnemyId = 0x33; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tw_Skel_0070E0, &object_tw_Anim_006F28, NULL, NULL, 0); + if (pthis->actor.params == TW_KOTAKE) { + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInitKoumeKotake); + pthis->actor.naviEnemyId = 0x33; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_tw_Skel_0070E0, &object_tw_Anim_006F28, NULL, NULL, 0); if (gSaveContext.eventChkInf[7] & 0x20) { // began twinrova battle - BossTw_SetupFlyTo(this, globalCtx); - this->actor.world.pos.x = -600.0f; - this->actor.world.pos.y = 400.0f; - this->actor.world.pos.z = 0.0f; + BossTw_SetupFlyTo(pthis, globalCtx); + pthis->actor.world.pos.x = -600.0f; + pthis->actor.world.pos.y = 400.0f; + pthis->actor.world.pos.z = 0.0f; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); } else { - BossTw_SetupCSWait(this, globalCtx); + BossTw_SetupCSWait(pthis, globalCtx); } - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_006F28, -3.0f); - this->visible = true; - } else if (this->actor.params == TW_KOUME) { - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitKoumeKotake); - this->actor.naviEnemyId = 0x32; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tw_Skel_01F888, &object_tw_Anim_006F28, NULL, NULL, 0); + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_006F28, -3.0f); + pthis->visible = true; + } else if (pthis->actor.params == TW_KOUME) { + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInitKoumeKotake); + pthis->actor.naviEnemyId = 0x32; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_tw_Skel_01F888, &object_tw_Anim_006F28, NULL, NULL, 0); if (gSaveContext.eventChkInf[7] & 0x20) { // began twinrova battle - BossTw_SetupFlyTo(this, globalCtx); - this->actor.world.pos.x = 600.0f; - this->actor.world.pos.y = 400.0f; - this->actor.world.pos.z = 0.0f; + BossTw_SetupFlyTo(pthis, globalCtx); + pthis->actor.world.pos.x = 600.0f; + pthis->actor.world.pos.y = 400.0f; + pthis->actor.world.pos.z = 0.0f; } else { - BossTw_SetupCSWait(this, globalCtx); + BossTw_SetupCSWait(pthis, globalCtx); } - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_006F28, -3.0f); - this->visible = true; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_006F28, -3.0f); + pthis->visible = true; } else { // Twinrova - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitTwinrova); - this->actor.naviEnemyId = 0x5B; - this->actor.colChkInfo.health = 24; - this->actor.update = BossTw_TwinrovaUpdate; - this->actor.draw = BossTw_TwinrovaDraw; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tw_Skel_032020, &object_tw_Anim_0244B4, NULL, NULL, 0); - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_0244B4, -3.0f); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInitTwinrova); + pthis->actor.naviEnemyId = 0x5B; + pthis->actor.colChkInfo.health = 24; + pthis->actor.update = BossTw_TwinrovaUpdate; + pthis->actor.draw = BossTw_TwinrovaDraw; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_tw_Skel_032020, &object_tw_Anim_0244B4, NULL, NULL, 0); + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_0244B4, -3.0f); if (gSaveContext.eventChkInf[7] & 0x20) { // began twinrova battle - BossTw_SetupWait(this, globalCtx); + BossTw_SetupWait(pthis, globalCtx); } else { - BossTw_TwinrovaSetupIntroCS(this, globalCtx); - this->actor.world.pos.x = 0.0f; - this->actor.world.pos.y = 1000.0f; - this->actor.world.pos.z = 0.0f; + BossTw_TwinrovaSetupIntroCS(pthis, globalCtx); + pthis->actor.world.pos.x = 0.0f; + pthis->actor.world.pos.y = 1000.0f; + pthis->actor.world.pos.z = 0.0f; } - this->actor.params = TW_TWINROVA; - sTwinrovaPtr = this; + pthis->actor.params = TW_TWINROVA; + sTwinrovaPtr = pthis; if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { // twinrova has been defeated. - Actor_Kill(&this->actor); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 600.0f, 230.0f, 0.0f, 0, + Actor_Kill(&pthis->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, 600.0f, 230.0f, 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -600.0f, 230.0f, 0.0f, 0, 0, 0, 0); } else { - sKotakePtr = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, TW_KOTAKE); - sKoumePtr = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, TW_KOUME); + sKotakePtr = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, TW_KOTAKE); + sKoumePtr = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, TW_KOUME); sKotakePtr->actor.parent = &sKoumePtr->actor; sKoumePtr->actor.parent = &sKotakePtr->actor; } } - this->fogR = globalCtx->lightCtx.fogColor[0]; - this->fogG = globalCtx->lightCtx.fogColor[1]; - this->fogB = globalCtx->lightCtx.fogColor[2]; - this->fogNear = globalCtx->lightCtx.fogNear; - this->fogFar = 1000.0f; + pthis->fogR = globalCtx->lightCtx.fogColor[0]; + pthis->fogG = globalCtx->lightCtx.fogColor[1]; + pthis->fogB = globalCtx->lightCtx.fogColor[2]; + pthis->fogNear = globalCtx->lightCtx.fogNear; + pthis->fogFar = 1000.0f; } void BossTw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); if (thisx->params < TW_FIRE_BLAST) { - SkelAnime_Free(&this->skelAnime, globalCtx); + SkelAnime_Free(&pthis->skelAnime, globalCtx); } if (thisx->params == TW_TWINROVA) { @@ -624,75 +624,75 @@ void BossTw_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void BossTw_SetupTurnToPlayer(BossTw* this, GlobalContext* globalCtx) { - BossTw* otherTw = (BossTw*)this->actor.parent; +void BossTw_SetupTurnToPlayer(BossTw* pthis, GlobalContext* globalCtx) { + BossTw* otherTw = (BossTw*)pthis->actor.parent; - this->actionFunc = BossTw_TurnToPlayer; + pthis->actionFunc = BossTw_TurnToPlayer; if ((otherTw != NULL) && (otherTw->actionFunc == BossTw_ShootBeam)) { - this->timers[0] = 40; + pthis->timers[0] = 40; } else { - this->timers[0] = 60; + pthis->timers[0] = 60; } - this->rotateSpeed = 0.0f; + pthis->rotateSpeed = 0.0f; } -void BossTw_TurnToPlayer(BossTw* this, GlobalContext* globalCtx) { - BossTw* otherTw = (BossTw*)this->actor.parent; +void BossTw_TurnToPlayer(BossTw* pthis, GlobalContext* globalCtx) { + BossTw* otherTw = (BossTw*)pthis->actor.parent; - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->rotateSpeed); - Math_ApproachS(&this->actor.shape.rot.x, 0, 5, this->rotateSpeed); - Math_ApproachF(&this->rotateSpeed, 4096.0f, 1.0f, 200.0f); - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - if (this->timers[0] == 0) { - if ((otherTw->actionFunc != BossTw_ShootBeam) && this->work[CAN_SHOOT]) { - this->work[CAN_SHOOT] = false; - BossTw_SetupShootBeam(this, globalCtx); - this->actor.speedXZ = 0.0f; + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.0f); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 5, pthis->rotateSpeed); + Math_ApproachF(&pthis->rotateSpeed, 4096.0f, 1.0f, 200.0f); + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + if (pthis->timers[0] == 0) { + if ((otherTw->actionFunc != BossTw_ShootBeam) && pthis->work[CAN_SHOOT]) { + pthis->work[CAN_SHOOT] = false; + BossTw_SetupShootBeam(pthis, globalCtx); + pthis->actor.speedXZ = 0.0f; } else { - BossTw_SetupFlyTo(this, globalCtx); + BossTw_SetupFlyTo(pthis, globalCtx); } } } -void BossTw_SetupFlyTo(BossTw* this, GlobalContext* globalCtx) { +void BossTw_SetupFlyTo(BossTw* pthis, GlobalContext* globalCtx) { static Vec3f sPillarPositions[] = { { 600.0f, 400.0f, 0.0f }, { 0.0f, 400.0f, 600.0f }, { -600.0f, 400.0f, 0.0f }, { 0.0f, 400.0f, -600.0f } }; - BossTw* otherTw = (BossTw*)this->actor.parent; + BossTw* otherTw = (BossTw*)pthis->actor.parent; - this->unk_5F8 = 1; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = BossTw_FlyTo; - this->rotateSpeed = 0.0f; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_006F28, -10.0f); + pthis->unk_5F8 = 1; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = BossTw_FlyTo; + pthis->rotateSpeed = 0.0f; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_006F28, -10.0f); if ((Rand_ZeroOne() < 0.5f) && (otherTw != NULL && otherTw->actionFunc == BossTw_ShootBeam)) { // Other Sister is shooting a beam, go near them. - this->targetPos.x = otherTw->actor.world.pos.x + Rand_CenteredFloat(200.0f); - this->targetPos.y = Rand_ZeroFloat(200.0f) + 340.0f; - this->targetPos.z = otherTw->actor.world.pos.z + Rand_CenteredFloat(200.0f); - this->timers[0] = (s16)Rand_ZeroFloat(50.0f) + 50; + pthis->targetPos.x = otherTw->actor.world.pos.x + Rand_CenteredFloat(200.0f); + pthis->targetPos.y = Rand_ZeroFloat(200.0f) + 340.0f; + pthis->targetPos.z = otherTw->actor.world.pos.z + Rand_CenteredFloat(200.0f); + pthis->timers[0] = (s16)Rand_ZeroFloat(50.0f) + 50; } else if (Rand_ZeroOne() < 0.5f) { // Fly to a random spot. - this->targetPos.x = Rand_CenteredFloat(800.0f); - this->targetPos.y = Rand_ZeroFloat(200.0f) + 340.0f; - this->targetPos.z = Rand_CenteredFloat(800.0f); - this->timers[0] = (s16)Rand_ZeroFloat(50.0f) + 50; + pthis->targetPos.x = Rand_CenteredFloat(800.0f); + pthis->targetPos.y = Rand_ZeroFloat(200.0f) + 340.0f; + pthis->targetPos.z = Rand_CenteredFloat(800.0f); + pthis->timers[0] = (s16)Rand_ZeroFloat(50.0f) + 50; } else { // fly to a random pillar. s16 idx = Rand_ZeroFloat(ARRAY_COUNT(sPillarPositions) - 0.01f); - this->targetPos = sPillarPositions[idx]; - this->timers[0] = 200; - this->work[CAN_SHOOT] = true; + pthis->targetPos = sPillarPositions[idx]; + pthis->timers[0] = 200; + pthis->work[CAN_SHOOT] = true; } } -void BossTw_FlyTo(BossTw* this, GlobalContext* globalCtx) { +void BossTw_FlyTo(BossTw* pthis, GlobalContext* globalCtx) { f32 xDiff; f32 yDiff; f32 zDiff; @@ -700,55 +700,55 @@ void BossTw_FlyTo(BossTw* this, GlobalContext* globalCtx) { f32 yawTarget; f32 xzDist; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); - Math_ApproachF(&this->scepterAlpha, 0.0f, 1.0f, 10.0f); - SkelAnime_Update(&this->skelAnime); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); + Math_ApproachF(&pthis->scepterAlpha, 0.0f, 1.0f, 10.0f); + SkelAnime_Update(&pthis->skelAnime); - xDiff = this->targetPos.x - this->actor.world.pos.x; - yDiff = this->targetPos.y - this->actor.world.pos.y; - zDiff = this->targetPos.z - this->actor.world.pos.z; + xDiff = pthis->targetPos.x - pthis->actor.world.pos.x; + yDiff = pthis->targetPos.y - pthis->actor.world.pos.y; + zDiff = pthis->targetPos.z - pthis->actor.world.pos.z; yawTarget = (s16)(Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI)); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); pitchTarget = (s16)(Math_FAtan2F(yDiff, xzDist) * (32768.0f / M_PI)); - Math_ApproachS(&this->actor.world.rot.x, pitchTarget, 0xA, this->rotateSpeed); - Math_ApproachS(&this->actor.world.rot.y, yawTarget, 0xA, this->rotateSpeed); - Math_ApproachS(&this->actor.shape.rot.y, yawTarget, 0xA, this->rotateSpeed); - Math_ApproachS(&this->actor.shape.rot.x, pitchTarget, 0xA, this->rotateSpeed); - Math_ApproachF(&this->rotateSpeed, 4096.0f, 1.0f, 100.0f); - Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 1.0f); - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); + Math_ApproachS(&pthis->actor.world.rot.x, pitchTarget, 0xA, pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.world.rot.y, yawTarget, 0xA, pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.shape.rot.y, yawTarget, 0xA, pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.shape.rot.x, pitchTarget, 0xA, pthis->rotateSpeed); + Math_ApproachF(&pthis->rotateSpeed, 4096.0f, 1.0f, 100.0f); + Math_ApproachF(&pthis->actor.speedXZ, 10.0f, 1.0f, 1.0f); + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); - if ((this->timers[0] == 0) || (xzDist < 70.0f)) { - BossTw_SetupTurnToPlayer(this, globalCtx); + if ((pthis->timers[0] == 0) || (xzDist < 70.0f)) { + BossTw_SetupTurnToPlayer(pthis, globalCtx); } } -void BossTw_SetupShootBeam(BossTw* this, GlobalContext* globalCtx) { +void BossTw_SetupShootBeam(BossTw* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->actionFunc = BossTw_ShootBeam; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_007688, -5.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_007688); - this->timers[1] = 70; - this->targetPos = player->actor.world.pos; - this->csState1 = 0; - this->beamDist = 0.0f; - this->beamReflectionDist = 0.0f; - this->beamShootState = -1; - this->beamScale = 0.01f; - this->beamReflectionOrigin = this->beamOrigin; - this->flameAlpha = 0.0f; - this->spawnPortalAlpha = 0.0f; - this->spawnPortalScale = 2000.0f; - this->updateRate1 = 0.0f; - this->portalRotation = 0.0f; - this->updateRate2 = 0.0f; + pthis->actionFunc = BossTw_ShootBeam; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_007688, -5.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_007688); + pthis->timers[1] = 70; + pthis->targetPos = player->actor.world.pos; + pthis->csState1 = 0; + pthis->beamDist = 0.0f; + pthis->beamReflectionDist = 0.0f; + pthis->beamShootState = -1; + pthis->beamScale = 0.01f; + pthis->beamReflectionOrigin = pthis->beamOrigin; + pthis->flameAlpha = 0.0f; + pthis->spawnPortalAlpha = 0.0f; + pthis->spawnPortalScale = 2000.0f; + pthis->updateRate1 = 0.0f; + pthis->portalRotation = 0.0f; + pthis->updateRate2 = 0.0f; } -void BossTw_SpawnGroundBlast(BossTw* this, GlobalContext* globalCtx, s16 blastType) { +void BossTw_SpawnGroundBlast(BossTw* pthis, GlobalContext* globalCtx, s16 blastType) { BossTw* groundBlast; s16 i; Vec3f pos; @@ -762,15 +762,15 @@ void BossTw_SpawnGroundBlast(BossTw* this, GlobalContext* globalCtx, s16 blastTy accel.y = 0.2f; accel.x = Rand_CenteredFloat(0.25f); accel.z = Rand_CenteredFloat(0.25f); - pos = this->groundBlastPos; + pos = pthis->groundBlastPos; BossTw_AddDotEffect(globalCtx, &pos, &velocity, &accel, (s16)Rand_ZeroFloat(2.0f) + 8, blastType, 75); } if (blastType == 1) { sGroundBlastType = 1; - groundBlast = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, - this->groundBlastPos.x, this->groundBlastPos.y, - this->groundBlastPos.z, 0, 0, 0, TW_FIRE_BLAST_GROUND); + groundBlast = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, + pthis->groundBlastPos.x, pthis->groundBlastPos.y, + pthis->groundBlastPos.z, 0, 0, 0, TW_FIRE_BLAST_GROUND); if (groundBlast != NULL) { if (sTwinrovaPtr->actionFunc == BossTw_Wait) { groundBlast->timers[0] = 100; @@ -785,9 +785,9 @@ void BossTw_SpawnGroundBlast(BossTw* this, GlobalContext* globalCtx, s16 blastTy } } else { sGroundBlastType = 2; - groundBlast = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, - this->groundBlastPos.x, this->groundBlastPos.y, - this->groundBlastPos.z, 0, 0, 0, TW_ICE_BLAST_GROUND); + groundBlast = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, + pthis->groundBlastPos.x, pthis->groundBlastPos.y, + pthis->groundBlastPos.z, 0, 0, 0, TW_ICE_BLAST_GROUND); if (groundBlast != NULL) { if (sTwinrovaPtr->actionFunc == BossTw_Wait) { groundBlast->timers[0] = 100; @@ -806,28 +806,28 @@ void BossTw_SpawnGroundBlast(BossTw* this, GlobalContext* globalCtx, s16 blastTy } } -s32 BossTw_BeamHitPlayerCheck(BossTw* this, GlobalContext* globalCtx) { +s32 BossTw_BeamHitPlayerCheck(BossTw* pthis, GlobalContext* globalCtx) { Vec3f offset; Vec3f beamDistFromPlayer; Player* player = GET_PLAYER(globalCtx); s16 i; - offset.x = player->actor.world.pos.x - this->beamOrigin.x; - offset.y = player->actor.world.pos.y - this->beamOrigin.y; - offset.z = player->actor.world.pos.z - this->beamOrigin.z; + offset.x = player->actor.world.pos.x - pthis->beamOrigin.x; + offset.y = player->actor.world.pos.y - pthis->beamOrigin.y; + offset.z = player->actor.world.pos.z - pthis->beamOrigin.z; - Matrix_RotateX(-this->beamPitch, MTXMODE_NEW); - Matrix_RotateY(-this->beamYaw, MTXMODE_APPLY); + Matrix_RotateX(-pthis->beamPitch, MTXMODE_NEW); + Matrix_RotateY(-pthis->beamYaw, MTXMODE_APPLY); Matrix_MultVec3f(&offset, &beamDistFromPlayer); if (fabsf(beamDistFromPlayer.x) < 20.0f && fabsf(beamDistFromPlayer.y) < 50.0f && beamDistFromPlayer.z > 100.0f && - beamDistFromPlayer.z <= this->beamDist) { + beamDistFromPlayer.z <= pthis->beamDist) { if (sTwinrovaPtr->timers[2] == 0) { sTwinrovaPtr->timers[2] = 150; - this->beamDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)); - func_8002F6D4(globalCtx, &this->actor, 3.0f, this->actor.shape.rot.y, 0.0f, 0x20); + pthis->beamDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)); + func_8002F6D4(globalCtx, &pthis->actor, 3.0f, pthis->actor.shape.rot.y, 0.0f, 0x20); - if (this->actor.params == 0) { + if (pthis->actor.params == 0) { if (sFreezeState == 0) { sFreezeState = 1; } @@ -847,19 +847,19 @@ s32 BossTw_BeamHitPlayerCheck(BossTw* this, GlobalContext* globalCtx) { } /** - * Checks if the beam shot by `this` will be reflected + * Checks if the beam shot by `pthis` will be reflected * returns 0 if the beam will not be reflected, * returns 1 if the beam will be reflected, * and returns 2 if the beam will be diverted backwards */ -s32 BossTw_CheckBeamReflection(BossTw* this, GlobalContext* globalCtx) { +s32 BossTw_CheckBeamReflection(BossTw* pthis, GlobalContext* globalCtx) { Vec3f offset; Vec3f vec; Player* player = GET_PLAYER(globalCtx); if (player->stateFlags1 & 0x400000 && - (s16)(player->actor.shape.rot.y - this->actor.shape.rot.y + 0x8000) < 0x2000 && - (s16)(player->actor.shape.rot.y - this->actor.shape.rot.y + 0x8000) > -0x2000) { + (s16)(player->actor.shape.rot.y - pthis->actor.shape.rot.y + 0x8000) < 0x2000 && + (s16)(player->actor.shape.rot.y - pthis->actor.shape.rot.y + 0x8000) > -0x2000) { // player is shielding and facing angles are less than 45 degrees in either direction offset.x = 0.0f; offset.y = 0.0f; @@ -872,22 +872,22 @@ s32 BossTw_CheckBeamReflection(BossTw* this, GlobalContext* globalCtx) { // calculates a vector where the origin is at the beams origin, // and the positive z axis is pointing in the direction the beam // is shooting - offset.x = player->actor.world.pos.x + vec.x - this->beamOrigin.x; - offset.y = player->actor.world.pos.y + vec.y - this->beamOrigin.y; - offset.z = player->actor.world.pos.z + vec.z - this->beamOrigin.z; + offset.x = player->actor.world.pos.x + vec.x - pthis->beamOrigin.x; + offset.y = player->actor.world.pos.y + vec.y - pthis->beamOrigin.y; + offset.z = player->actor.world.pos.z + vec.z - pthis->beamOrigin.z; - Matrix_RotateX(-this->beamPitch, MTXMODE_NEW); - Matrix_RotateY(-this->beamYaw, MTXMODE_APPLY); + Matrix_RotateX(-pthis->beamPitch, MTXMODE_NEW); + Matrix_RotateY(-pthis->beamYaw, MTXMODE_APPLY); Matrix_MultVec3f(&offset, &vec); - if (fabsf(vec.x) < 30.0f && fabsf(vec.y) < 70.0f && vec.z > 100.0f && vec.z <= this->beamDist) { + if (fabsf(vec.x) < 30.0f && fabsf(vec.y) < 70.0f && vec.z > 100.0f && vec.z <= pthis->beamDist) { // if the beam's origin is within 30 x units, 70 y units, is farther than 100 units // and the distance from the beams origin to 10 units in front of link is less than the beams // current distance (the distance of the beam is equal to or longer than the distance to 10 units // in front of link) if (Player_HasMirrorShieldEquipped(globalCtx)) { // player has mirror shield equipped - this->beamDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)); + pthis->beamDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)); return 1; } @@ -898,14 +898,14 @@ s32 BossTw_CheckBeamReflection(BossTw* this, GlobalContext* globalCtx) { if (sBeamDivertTimer == 0) { // beam hit the shield, normal shield equipped, // divert the beam backwards from link's Y rotation - BossTw_AddShieldDeflectEffect(globalCtx, 10.0f, this->actor.params); + BossTw_AddShieldDeflectEffect(globalCtx, 10.0f, pthis->actor.params); globalCtx->envCtx.unk_D8 = 1.0f; - this->timers[0] = 10; + pthis->timers[0] = 10; func_80078884(NA_SE_IT_SHIELD_REFLECT_MG2); } sBeamDivertTimer++; - this->beamDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)); + pthis->beamDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)); return 2; } } @@ -913,21 +913,21 @@ s32 BossTw_CheckBeamReflection(BossTw* this, GlobalContext* globalCtx) { return 0; } -s32 BossTw_BeamReflHitCheck(BossTw* this, Vec3f* pos) { +s32 BossTw_BeamReflHitCheck(BossTw* pthis, Vec3f* pos) { Vec3f offset; Vec3f beamDistFromTarget; - offset.x = pos->x - this->beamReflectionOrigin.x; - offset.y = pos->y - this->beamReflectionOrigin.y; - offset.z = pos->z - this->beamReflectionOrigin.z; + offset.x = pos->x - pthis->beamReflectionOrigin.x; + offset.y = pos->y - pthis->beamReflectionOrigin.y; + offset.z = pos->z - pthis->beamReflectionOrigin.z; - Matrix_RotateX(-this->beamReflectionPitch, MTXMODE_NEW); - Matrix_RotateY(-this->beamReflectionYaw, MTXMODE_APPLY); + Matrix_RotateX(-pthis->beamReflectionPitch, MTXMODE_NEW); + Matrix_RotateY(-pthis->beamReflectionYaw, MTXMODE_APPLY); Matrix_MultVec3f(&offset, &beamDistFromTarget); if (fabsf(beamDistFromTarget.x) < 50.0f && fabsf(beamDistFromTarget.y) < 50.0f && beamDistFromTarget.z > 100.0f && - beamDistFromTarget.z <= this->beamReflectionDist) { - this->beamReflectionDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)) * 1.1f; + beamDistFromTarget.z <= pthis->beamReflectionDist) { + pthis->beamReflectionDist = sqrtf(SQ(offset.x) + SQ(offset.y) + SQ(offset.z)) * 1.1f; return true; } else { return false; @@ -980,7 +980,7 @@ f32 BossTw_GetFloorY(Vec3f* pos) { return -100.0f; } -void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { +void BossTw_ShootBeam(BossTw* pthis, GlobalContext* globalCtx) { s16 i; f32 xDiff; f32 yDiff; @@ -989,57 +989,57 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { Vec3f sp130; Vec3s sp128; Player* player = GET_PLAYER(globalCtx); - BossTw* otherTw = (BossTw*)this->actor.parent; + BossTw* otherTw = (BossTw*)pthis->actor.parent; Input* input = &globalCtx->state.input[0]; - Math_ApproachF(&this->actor.world.pos.y, 400.0f, 0.05f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 0.25f); - SkelAnime_Update(&this->skelAnime); - this->beamRoll += -0.3f; + Math_ApproachF(&pthis->actor.world.pos.y, 400.0f, 0.05f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 5.0f, 1.0f, 0.25f); + SkelAnime_Update(&pthis->skelAnime); + pthis->beamRoll += -0.3f; - if (this->timers[1] != 0) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->rotateSpeed); + if (pthis->timers[1] != 0) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, pthis->rotateSpeed); if ((player->stateFlags1 & 0x400000) && - ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) < 0x2000) && - ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) > -0x2000)) { - Math_ApproachF(&this->targetPos.x, player->bodyPartsPos[15].x, 1.0f, 400.0f); - Math_ApproachF(&this->targetPos.y, player->bodyPartsPos[15].y, 1.0f, 400.0f); - Math_ApproachF(&this->targetPos.z, player->bodyPartsPos[15].z, 1.0f, 400.0f); + ((s16)((player->actor.shape.rot.y - pthis->actor.shape.rot.y) + 0x8000) < 0x2000) && + ((s16)((player->actor.shape.rot.y - pthis->actor.shape.rot.y) + 0x8000) > -0x2000)) { + Math_ApproachF(&pthis->targetPos.x, player->bodyPartsPos[15].x, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.y, player->bodyPartsPos[15].y, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.z, player->bodyPartsPos[15].z, 1.0f, 400.0f); } else { - Math_ApproachF(&this->targetPos.x, player->actor.world.pos.x, 1.0f, 400.0f); - Math_ApproachF(&this->targetPos.y, player->actor.world.pos.y + 30.0f, 1.0f, 400.0f); - Math_ApproachF(&this->targetPos.z, player->actor.world.pos.z, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.x, player->actor.world.pos.x, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.y, player->actor.world.pos.y + 30.0f, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.z, player->actor.world.pos.z, 1.0f, 400.0f); } - this->timers[0] = 70; - this->groundBlastPos.x = this->groundBlastPos.y = this->groundBlastPos.z = 0.0f; - this->portalRotation += this->updateRate2 * 0.0025f; - Math_ApproachF(&this->spawnPortalAlpha, 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->updateRate2, 50.0f, 1.0f, 2.0f); + pthis->timers[0] = 70; + pthis->groundBlastPos.x = pthis->groundBlastPos.y = pthis->groundBlastPos.z = 0.0f; + pthis->portalRotation += pthis->updateRate2 * 0.0025f; + Math_ApproachF(&pthis->spawnPortalAlpha, 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->updateRate2, 50.0f, 1.0f, 2.0f); - if (this->timers[1] < 50) { - if (this->timers[1] < 10) { - if (this->timers[1] == 9) { + if (pthis->timers[1] < 50) { + if (pthis->timers[1] < 10) { + if (pthis->timers[1] == 9) { globalCtx->envCtx.unk_D8 = 0.5f; - globalCtx->envCtx.unk_BD = 3 - this->actor.params; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_MASIC_SET); + globalCtx->envCtx.unk_BD = 3 - pthis->actor.params; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_MASIC_SET); } - if (this->timers[1] == 5) { - this->scepterAlpha = 255; + if (pthis->timers[1] == 5) { + pthis->scepterAlpha = 255; } - if (this->timers[1] > 4) { + if (pthis->timers[1] > 4) { s16 j; for (j = 0; j < 2; j++) { - for (i = 0; i < ARRAY_COUNT(this->scepterFlamePos); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->scepterFlamePos); i++) { Vec3f pos; Vec3f velocity; Vec3f accel; - pos.x = this->scepterFlamePos[i].x; - pos.y = this->scepterFlamePos[i].y; - pos.z = this->scepterFlamePos[i].z; + pos.x = pthis->scepterFlamePos[i].x; + pos.y = pthis->scepterFlamePos[i].y; + pos.z = pthis->scepterFlamePos[i].z; velocity.x = Rand_CenteredFloat(10.0f); velocity.y = Rand_CenteredFloat(10.0f); velocity.z = Rand_CenteredFloat(10.0f); @@ -1047,71 +1047,71 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { accel.y = 0.0f; accel.z = 0.0f; BossTw_AddFlameEffect(globalCtx, &pos, &velocity, &accel, Rand_ZeroFloat(10.0f) + 25.0f, - this->actor.params); + pthis->actor.params); } } } } - if (this->timers[1] < 20) { - Math_ApproachF(&this->flameAlpha, 0, 1.0f, 20.0f); - Math_ApproachF(&this->spawnPortalAlpha, 0, 1.0f, 30.0f); + if (pthis->timers[1] < 20) { + Math_ApproachF(&pthis->flameAlpha, 0, 1.0f, 20.0f); + Math_ApproachF(&pthis->spawnPortalAlpha, 0, 1.0f, 30.0f); } else { - Math_ApproachF(&this->flameAlpha, 255.0f, 1.0f, 10.0f); - if (this->actor.params == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_MS_FIRE - SFX_FLAG); + Math_ApproachF(&pthis->flameAlpha, 255.0f, 1.0f, 10.0f); + if (pthis->actor.params == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_MS_FIRE - SFX_FLAG); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_MS_FREEZE - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_MS_FREEZE - SFX_FLAG); } } - this->flameRotation += this->updateRate1 * 0.0025f; - Math_ApproachF(&this->spawnPortalScale, 0.0f, 0.1f, this->updateRate1); - Math_ApproachF(&this->updateRate1, 50.0f, 1.0f, 2.0f); + pthis->flameRotation += pthis->updateRate1 * 0.0025f; + Math_ApproachF(&pthis->spawnPortalScale, 0.0f, 0.1f, pthis->updateRate1); + Math_ApproachF(&pthis->updateRate1, 50.0f, 1.0f, 2.0f); } - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_009398, 0.0f); - this->workf[ANIM_SW_TGT] = 10000.0f; + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_009398, 0.0f); + pthis->workf[ANIM_SW_TGT] = 10000.0f; } - if (this->timers[1] == 1) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_003614, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_003614); - this->unk_4DC = 0.0f; - this->spawnPortalAlpha = 0.0f; - this->flameAlpha = 0.0f; + if (pthis->timers[1] == 1) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_003614, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_003614); + pthis->unk_4DC = 0.0f; + pthis->spawnPortalAlpha = 0.0f; + pthis->flameAlpha = 0.0f; sBeamDivertTimer = 0; } } else { - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_003E34, 0.0f); - this->workf[ANIM_SW_TGT] = 10000.0f; + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_003E34, 0.0f); + pthis->workf[ANIM_SW_TGT] = 10000.0f; } - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT] - 5.0f)) { - this->beamShootState = 0; - sEnvType = this->actor.params + 1; + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT] - 5.0f)) { + pthis->beamShootState = 0; + sEnvType = pthis->actor.params + 1; } - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT] - 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_THROW_MASIC); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_SHOOT_VOICE); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT] - 13.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_THROW_MASIC); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_SHOOT_VOICE); } - xDiff = this->targetPos.x - this->beamOrigin.x; - yDiff = this->targetPos.y - this->beamOrigin.y; - zDiff = this->targetPos.z - this->beamOrigin.z; + xDiff = pthis->targetPos.x - pthis->beamOrigin.x; + yDiff = pthis->targetPos.y - pthis->beamOrigin.y; + zDiff = pthis->targetPos.z - pthis->beamOrigin.z; - this->beamYaw = Math_FAtan2F(xDiff, zDiff); - this->beamPitch = -Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))); + pthis->beamYaw = Math_FAtan2F(xDiff, zDiff); + pthis->beamPitch = -Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))); - switch (this->beamShootState) { + switch (pthis->beamShootState) { case -1: break; case 0: - if (this->timers[0] != 0) { - s32 beamReflection = BossTw_CheckBeamReflection(this, globalCtx); + if (pthis->timers[0] != 0) { + s32 beamReflection = BossTw_CheckBeamReflection(pthis, globalCtx); if (beamReflection == 1) { Vec3f pos; @@ -1124,39 +1124,39 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { velocity.z = Rand_CenteredFloat(15.0f); pos = player->bodyPartsPos[15]; BossTw_AddDotEffect(globalCtx, &pos, &velocity, &accel, (s16)Rand_ZeroFloat(2.0f) + 5, - this->actor.params, 150); + pthis->actor.params, 150); } - this->beamShootState = 1; + pthis->beamShootState = 1; func_80078914(&player->actor.projectedPos, NA_SE_IT_SHIELD_REFLECT_MG); Matrix_MtxFToYXZRotS(&player->shieldMf, &sp128, 0); sp128.y += 0x8000; sp128.x = -sp128.x; - this->magicDir.x = sp128.x; - this->magicDir.y = sp128.y; - this->groundBlastPos.x = 0.0f; - this->groundBlastPos.y = 0.0f; - this->groundBlastPos.z = 0.0f; + pthis->magicDir.x = sp128.x; + pthis->magicDir.y = sp128.y; + pthis->groundBlastPos.x = 0.0f; + pthis->groundBlastPos.y = 0.0f; + pthis->groundBlastPos.z = 0.0f; globalCtx->envCtx.unk_D8 = 1.0f; func_800AA000(0.0f, 0x64, 5, 4); } else if (beamReflection == 0) { - BossTw_BeamHitPlayerCheck(this, globalCtx); + BossTw_BeamHitPlayerCheck(pthis, globalCtx); - if (this->csState1 == 0) { - Math_ApproachF(&this->beamDist, 2.0f * sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)), 1.0f, + if (pthis->csState1 == 0) { + Math_ApproachF(&pthis->beamDist, 2.0f * sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)), 1.0f, 40.0f); } } } - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->beamReflectionOrigin, - &this->unk_54C, &this->actor.projectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->beamReflectionOrigin, + &pthis->unk_54C, &pthis->actor.projectedW); - if (this->actor.params == 1) { - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FIRE - SFX_FLAG, &this->unk_54C, 4, &D_801333E0, + if (pthis->actor.params == 1) { + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FIRE - SFX_FLAG, &pthis->unk_54C, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG, &this->unk_54C, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG, &pthis->unk_54C, 4, &D_801333E0, &D_801333E0, &D_801333E8); } break; @@ -1165,97 +1165,97 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { Player* player = GET_PLAYER(globalCtx); - this->beamDist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); - Math_ApproachF(&this->beamReflectionDist, 2000.0f, 1.0f, 40.0f); - Math_ApproachF(&this->targetPos.x, player->bodyPartsPos[15].x, 1.0f, 400.0f); - Math_ApproachF(&this->targetPos.y, player->bodyPartsPos[15].y, 1.0f, 400.0f); - Math_ApproachF(&this->targetPos.z, player->bodyPartsPos[15].z, 1.0f, 400.0f); - if ((this->work[CS_TIMER_1] % 4) == 0) { - BossTw_AddRingEffect(globalCtx, &player->bodyPartsPos[15], 0.5f, 3.0f, 0xFF, this->actor.params, + pthis->beamDist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + Math_ApproachF(&pthis->beamReflectionDist, 2000.0f, 1.0f, 40.0f); + Math_ApproachF(&pthis->targetPos.x, player->bodyPartsPos[15].x, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.y, player->bodyPartsPos[15].y, 1.0f, 400.0f); + Math_ApproachF(&pthis->targetPos.z, player->bodyPartsPos[15].z, 1.0f, 400.0f); + if ((pthis->work[CS_TIMER_1] % 4) == 0) { + BossTw_AddRingEffect(globalCtx, &player->bodyPartsPos[15], 0.5f, 3.0f, 0xFF, pthis->actor.params, 1, 150); } } else { - this->beamShootState = 0; - this->beamReflectionDist = 0.0f; + pthis->beamShootState = 0; + pthis->beamReflectionDist = 0.0f; } - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->unk_530, &this->unk_558, - &this->actor.projectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->unk_530, &pthis->unk_558, + &pthis->actor.projectedW); - if (this->actor.params == 1) { - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FIRE - SFX_FLAG, &this->unk_558, 4U, &D_801333E0, + if (pthis->actor.params == 1) { + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FIRE - SFX_FLAG, &pthis->unk_558, 4U, &D_801333E0, &D_801333E0, &D_801333E8); - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_REFL_FIRE - SFX_FLAG, &this->unk_558, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_REFL_FIRE - SFX_FLAG, &pthis->unk_558, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG, &this->unk_558, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG, &pthis->unk_558, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_REFL_FREEZE - SFX_FLAG, &this->unk_558, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_REFL_FREEZE - SFX_FLAG, &pthis->unk_558, 4, &D_801333E0, &D_801333E0, &D_801333E8); } break; } - if (this->timers[0] == 0 && (sEnvType == 1 || sEnvType == 2)) { + if (pthis->timers[0] == 0 && (sEnvType == 1 || sEnvType == 2)) { sEnvType = 0; } - if (this->timers[0] == 0) { - Math_ApproachF(&this->beamScale, 0.0f, 1.0f, 0.0005f); + if (pthis->timers[0] == 0) { + Math_ApproachF(&pthis->beamScale, 0.0f, 1.0f, 0.0005f); - if (this->beamScale == 0.0f) { - BossTw_SetupFinishBeamShoot(this, globalCtx); - this->beamReflectionDist = 0.0f; - this->beamDist = 0.0f; + if (pthis->beamScale == 0.0f) { + BossTw_SetupFinishBeamShoot(pthis, globalCtx); + pthis->beamReflectionDist = 0.0f; + pthis->beamDist = 0.0f; } } } - Matrix_Translate(this->beamOrigin.x, this->beamOrigin.y, this->beamOrigin.z, MTXMODE_NEW); - Matrix_RotateY(this->beamYaw, MTXMODE_APPLY); - Matrix_RotateX(this->beamPitch, MTXMODE_APPLY); + Matrix_Translate(pthis->beamOrigin.x, pthis->beamOrigin.y, pthis->beamOrigin.z, MTXMODE_NEW); + Matrix_RotateY(pthis->beamYaw, MTXMODE_APPLY); + Matrix_RotateX(pthis->beamPitch, MTXMODE_APPLY); sp130.x = 0.0f; sp130.y = 0.0f; - sp130.z = this->beamDist + -5.0f; + sp130.z = pthis->beamDist + -5.0f; - Matrix_MultVec3f(&sp130, &this->beamReflectionOrigin); + Matrix_MultVec3f(&sp130, &pthis->beamReflectionOrigin); - if ((this->csState1 == 0) && (this->beamShootState == 0) && (this->timers[0] != 0)) { - this->groundBlastPos.y = BossTw_GetFloorY(&this->beamReflectionOrigin); + if ((pthis->csState1 == 0) && (pthis->beamShootState == 0) && (pthis->timers[0] != 0)) { + pthis->groundBlastPos.y = BossTw_GetFloorY(&pthis->beamReflectionOrigin); - if (this->groundBlastPos.y >= 0.0f) { - this->csState1 = 1; - this->groundBlastPos.x = this->beamReflectionOrigin.x; - this->groundBlastPos.z = this->beamReflectionOrigin.z; - BossTw_SpawnGroundBlast(this, globalCtx, this->actor.params); - this->timers[0] = 20; + if (pthis->groundBlastPos.y >= 0.0f) { + pthis->csState1 = 1; + pthis->groundBlastPos.x = pthis->beamReflectionOrigin.x; + pthis->groundBlastPos.z = pthis->beamReflectionOrigin.z; + BossTw_SpawnGroundBlast(pthis, globalCtx, pthis->actor.params); + pthis->timers[0] = 20; } } - if (this->beamShootState == 1) { - if (this->csState1 == 0) { + if (pthis->beamShootState == 1) { + if (pthis->csState1 == 0) { Matrix_MtxFToYXZRotS(&player->shieldMf, &sp128, 0); sp128.y += 0x8000; sp128.x = -sp128.x; - Math_ApproachS(&this->magicDir.x, sp128.x, 5, 0x2000); - Math_ApproachS(&this->magicDir.y, sp128.y, 5, 0x2000); - this->beamReflectionPitch = (this->magicDir.x / 32768.0f) * M_PI; - this->beamReflectionYaw = (this->magicDir.y / 32768.0f) * M_PI; + Math_ApproachS(&pthis->magicDir.x, sp128.x, 5, 0x2000); + Math_ApproachS(&pthis->magicDir.y, sp128.y, 5, 0x2000); + pthis->beamReflectionPitch = (pthis->magicDir.x / 32768.0f) * M_PI; + pthis->beamReflectionYaw = (pthis->magicDir.y / 32768.0f) * M_PI; } - Matrix_Translate(this->beamReflectionOrigin.x, this->beamReflectionOrigin.y, this->beamReflectionOrigin.z, + Matrix_Translate(pthis->beamReflectionOrigin.x, pthis->beamReflectionOrigin.y, pthis->beamReflectionOrigin.z, MTXMODE_NEW); - Matrix_RotateY(this->beamReflectionYaw, MTXMODE_APPLY); - Matrix_RotateX(this->beamReflectionPitch, MTXMODE_APPLY); + Matrix_RotateY(pthis->beamReflectionYaw, MTXMODE_APPLY); + Matrix_RotateX(pthis->beamReflectionPitch, MTXMODE_APPLY); sp130.x = 0.0f; sp130.y = 0.0f; - sp130.z = this->beamReflectionDist + -170.0f; + sp130.z = pthis->beamReflectionDist + -170.0f; - Matrix_MultVec3f(&sp130, &this->unk_530); + Matrix_MultVec3f(&sp130, &pthis->unk_530); - if (this->csState1 == 0) { + if (pthis->csState1 == 0) { sp130.z = 0.0f; for (i = 0; i < 200; i++) { @@ -1263,16 +1263,16 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { Matrix_MultVec3f(&sp130, &spBC); floorY = BossTw_GetFloorY(&spBC); - this->groundBlastPos.y = floorY; + pthis->groundBlastPos.y = floorY; if (floorY >= 0.0f) { - if ((this->groundBlastPos.y != 35.0f) && (0.0f < this->beamReflectionPitch) && - (this->timers[0] != 0)) { - this->csState1 = 1; - this->groundBlastPos.x = spBC.x; - this->groundBlastPos.z = spBC.z; - BossTw_SpawnGroundBlast(this, globalCtx, this->actor.params); - this->timers[0] = 20; + if ((pthis->groundBlastPos.y != 35.0f) && (0.0f < pthis->beamReflectionPitch) && + (pthis->timers[0] != 0)) { + pthis->csState1 = 1; + pthis->groundBlastPos.x = spBC.x; + pthis->groundBlastPos.z = spBC.z; + BossTw_SpawnGroundBlast(pthis, globalCtx, pthis->actor.params); + pthis->timers[0] = 20; } else { for (i = 0; i < 5; i++) { Vec3f velocity; @@ -1286,11 +1286,11 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { accel.y = 0.0f; accel.z = 0.0f; - BossTw_AddFlameEffect(globalCtx, &this->unk_530, &velocity, &accel, - Rand_ZeroFloat(10.0f) + 25.0f, this->actor.params); + BossTw_AddFlameEffect(globalCtx, &pthis->unk_530, &velocity, &accel, + Rand_ZeroFloat(10.0f) + 25.0f, pthis->actor.params); } - this->beamReflectionDist = sp130.z; + pthis->beamReflectionDist = sp130.z; Math_ApproachF(&globalCtx->envCtx.unk_D8, 0.8f, 1.0f, 0.2f); } break; @@ -1298,17 +1298,17 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { sp130.z += 20.0f; - if (this->beamReflectionDist < sp130.z) { + if (pthis->beamReflectionDist < sp130.z) { break; } } } - if (BossTw_BeamReflHitCheck(this, &this->actor.world.pos) && (this->work[CS_TIMER_1] % 4) == 0) { - BossTw_AddRingEffect(globalCtx, &this->unk_530, 0.5f, 3.0f, 255, this->actor.params, 1, 150); + if (BossTw_BeamReflHitCheck(pthis, &pthis->actor.world.pos) && (pthis->work[CS_TIMER_1] % 4) == 0) { + BossTw_AddRingEffect(globalCtx, &pthis->unk_530, 0.5f, 3.0f, 255, pthis->actor.params, 1, 150); } - if (BossTw_BeamReflHitCheck(this, &otherTw->actor.world.pos) && otherTw->actionFunc != BossTw_HitByBeam) { + if (BossTw_BeamReflHitCheck(pthis, &otherTw->actor.world.pos) && otherTw->actionFunc != BossTw_HitByBeam) { for (i = 0; i < 50; i++) { Vec3f pos; Vec3f velocity; @@ -1327,7 +1327,7 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { accel.z = 0.0f; BossTw_AddFlameEffect(globalCtx, &pos, &velocity, &accel, Rand_ZeroFloat(10.0f) + 25.0f, - this->actor.params); + pthis->actor.params); } BossTw_SetupHitByBeam(otherTw, globalCtx); @@ -1338,49 +1338,49 @@ void BossTw_ShootBeam(BossTw* this, GlobalContext* globalCtx) { } } -void BossTw_SetupFinishBeamShoot(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_FinishBeamShoot; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_004548, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_004548); +void BossTw_SetupFinishBeamShoot(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_FinishBeamShoot; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_004548, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_004548); } -void BossTw_FinishBeamShoot(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->scepterAlpha, 0.0f, 1.0f, 10.0f); +void BossTw_FinishBeamShoot(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->scepterAlpha, 0.0f, 1.0f, 10.0f); - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { if (sTwinrovaPtr->timers[2] == 0) { - BossTw_SetupFlyTo(this, globalCtx); + BossTw_SetupFlyTo(pthis, globalCtx); } else { - BossTw_SetupLaugh(this, globalCtx); + BossTw_SetupLaugh(pthis, globalCtx); } - this->scepterAlpha = 0.0f; + pthis->scepterAlpha = 0.0f; } } -void BossTw_SetupHitByBeam(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_HitByBeam; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_00578C, 0.0f); - this->timers[0] = 53; - this->actor.speedXZ = 0.0f; +void BossTw_SetupHitByBeam(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_HitByBeam; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_00578C, 0.0f); + pthis->timers[0] = 53; + pthis->actor.speedXZ = 0.0f; - if (this->actor.params == 0) { - this->work[FOG_TIMER] = 20; + if (pthis->actor.params == 0) { + pthis->work[FOG_TIMER] = 20; } } -void BossTw_HitByBeam(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void BossTw_HitByBeam(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - if ((this->work[CS_TIMER_1] % 4) == 0) { + if ((pthis->work[CS_TIMER_1] % 4) == 0) { Vec3f pos; Vec3f velocity; Vec3f accel; - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(80.0f); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(80.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(80.0f); + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(80.0f); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(80.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(80.0f); velocity.x = 0.0f; velocity.y = 0.0f; @@ -1390,228 +1390,228 @@ void BossTw_HitByBeam(BossTw* this, GlobalContext* globalCtx) { accel.y = 0.1f; accel.z = 0.0f; - BossTw_AddDmgCloud(globalCtx, this->actor.params + 2, &pos, &velocity, &accel, Rand_ZeroFloat(10.0f) + 15.0f, 0, + BossTw_AddDmgCloud(globalCtx, pthis->actor.params + 2, &pos, &velocity, &accel, Rand_ZeroFloat(10.0f) + 15.0f, 0, 0, 150); } - if (this->actor.params == 1) { - Math_ApproachF(&this->fogR, 255.0f, 1.0f, 30.0f); - Math_ApproachF(&this->fogG, 255.0f, 1.0f, 30.0f); - Math_ApproachF(&this->fogB, 255.0f, 1.0f, 30.0f); - Math_ApproachF(&this->fogNear, 900.0f, 1.0f, 30.0f); - Math_ApproachF(&this->fogFar, 1099.0f, 1.0f, 30.0f); + if (pthis->actor.params == 1) { + Math_ApproachF(&pthis->fogR, 255.0f, 1.0f, 30.0f); + Math_ApproachF(&pthis->fogG, 255.0f, 1.0f, 30.0f); + Math_ApproachF(&pthis->fogB, 255.0f, 1.0f, 30.0f); + Math_ApproachF(&pthis->fogNear, 900.0f, 1.0f, 30.0f); + Math_ApproachF(&pthis->fogFar, 1099.0f, 1.0f, 30.0f); } - Math_ApproachF(&this->actor.world.pos.y, ((Math_SinS(this->work[CS_TIMER_1] * 1500) * 20.0f) + 350.0f) + 50.0f, - 0.1f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.y, ((Math_SinS(pthis->work[CS_TIMER_1] * 1500) * 20.0f) + 350.0f) + 50.0f, + 0.1f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 5.0f, 1.0f, 1.0f); - this->actor.world.pos.y -= 50.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 4); - this->actor.world.pos.y += 50.0f; + pthis->actor.world.pos.y -= 50.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 4); + pthis->actor.world.pos.y += 50.0f; - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = 0.0f; } - if (this->timers[0] == 1) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_006530, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_006530); + if (pthis->timers[0] == 1) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_006530, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_006530); } - if ((this->timers[0] == 0) && Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - BossTw_SetupFlyTo(this, globalCtx); + if ((pthis->timers[0] == 0) && Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + BossTw_SetupFlyTo(pthis, globalCtx); } } -void BossTw_SetupLaugh(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_Laugh; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_0088C8, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0088C8); - this->actor.speedXZ = 0.0f; +void BossTw_SetupLaugh(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_Laugh; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_0088C8, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0088C8); + pthis->actor.speedXZ = 0.0f; } -void BossTw_Laugh(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void BossTw_Laugh(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - if (this->actor.params == TW_KOUME) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_LAUGH); + if (Animation_OnFrame(&pthis->skelAnime, 10.0f)) { + if (pthis->actor.params == TW_KOUME) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_LAUGH); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_LAUGH2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_LAUGH2); } } - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - BossTw_SetupFlyTo(this, globalCtx); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + BossTw_SetupFlyTo(pthis, globalCtx); } } -void BossTw_SetupSpin(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_Spin; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_007CA8, -3.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_007CA8); - this->actor.speedXZ = 0.0f; - SkelAnime_Update(&this->skelAnime); - this->timers[0] = 20; +void BossTw_SetupSpin(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_Spin; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_007CA8, -3.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_007CA8); + pthis->actor.speedXZ = 0.0f; + SkelAnime_Update(&pthis->skelAnime); + pthis->timers[0] = 20; } -void BossTw_Spin(BossTw* this, GlobalContext* globalCtx) { - if (this->timers[0] != 0) { - this->collider.base.colType = COLTYPE_METAL; - this->actor.shape.rot.y -= 0x3000; +void BossTw_Spin(BossTw* pthis, GlobalContext* globalCtx) { + if (pthis->timers[0] != 0) { + pthis->collider.base.colType = COLTYPE_METAL; + pthis->actor.shape.rot.y -= 0x3000; - if ((this->timers[0] % 4) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_ROLL); + if ((pthis->timers[0] % 4) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_ROLL); } } else { - SkelAnime_Update(&this->skelAnime); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2000); + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 3, 0x2000); - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - BossTw_SetupFlyTo(this, globalCtx); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + BossTw_SetupFlyTo(pthis, globalCtx); } } } -void BossTw_SetupMergeCS(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_MergeCS; - this->rotateSpeed = 0.0f; - this->actor.speedXZ = 0.0f; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_006F28, -10.0f); +void BossTw_SetupMergeCS(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_MergeCS; + pthis->rotateSpeed = 0.0f; + pthis->actor.speedXZ = 0.0f; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_006F28, -10.0f); } -void BossTw_MergeCS(BossTw* this, GlobalContext* globalCtx) { - Math_ApproachF(&this->scepterAlpha, 0.0f, 1.0f, 10.0f); - SkelAnime_Update(&this->skelAnime); +void BossTw_MergeCS(BossTw* pthis, GlobalContext* globalCtx) { + Math_ApproachF(&pthis->scepterAlpha, 0.0f, 1.0f, 10.0f); + SkelAnime_Update(&pthis->skelAnime); } -void BossTw_SetupWait(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_Wait; - this->visible = false; - this->actor.world.pos.y = -2000.0f; - this->actor.flags &= ~ACTOR_FLAG_0; +void BossTw_SetupWait(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_Wait; + pthis->visible = false; + pthis->actor.world.pos.y = -2000.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; } -void BossTw_Wait(BossTw* this, GlobalContext* globalCtx) { - if ((this->actor.params == TW_TWINROVA) && (sKoumePtr->actionFunc == BossTw_FlyTo) && +void BossTw_Wait(BossTw* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params == TW_TWINROVA) && (sKoumePtr->actionFunc == BossTw_FlyTo) && (sKotakePtr->actionFunc == BossTw_FlyTo) && ((sKoumePtr->actor.colChkInfo.health + sKotakePtr->actor.colChkInfo.health) >= 4)) { - BossTw_TwinrovaSetupMergeCS(this, globalCtx); + BossTw_TwinrovaSetupMergeCS(pthis, globalCtx); BossTw_SetupMergeCS(sKotakePtr, globalCtx); BossTw_SetupMergeCS(sKoumePtr, globalCtx); } } -void BossTw_TwinrovaSetupMergeCS(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaMergeCS; - this->csState2 = 0; - this->csState1 = 0; +void BossTw_TwinrovaSetupMergeCS(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaMergeCS; + pthis->csState2 = 0; + pthis->csState1 = 0; } -void BossTw_TwinrovaMergeCS(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaMergeCS(BossTw* pthis, GlobalContext* globalCtx) { s16 i; Vec3f spB0; Vec3f spA4; Player* player = GET_PLAYER(globalCtx); - switch (this->csState2) { + switch (pthis->csState2) { case 0: - this->csState2 = 1; + pthis->csState2 = 1; func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 0x39); - this->subCamId = Gameplay_CreateSubCamera(globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 0x39); + pthis->subCamId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->subCamId, CAM_STAT_ACTIVE); - this->subCamDist = 800.0f; - this->subCamYaw = M_PI; + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCamId, CAM_STAT_ACTIVE); + pthis->subCamDist = 800.0f; + pthis->subCamYaw = M_PI; sKoumePtr->actor.world.rot.x = 0; sKoumePtr->actor.shape.rot.x = 0; sKotakePtr->actor.world.rot.x = 0; sKotakePtr->actor.shape.rot.x = 0; - this->workf[UNK_F9] = 0.0f; - this->workf[UNK_F10] = 0.0f; - this->workf[UNK_F11] = 600.0f; + pthis->workf[UNK_F9] = 0.0f; + pthis->workf[UNK_F10] = 0.0f; + pthis->workf[UNK_F11] = 600.0f; Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xC800FF); - this->work[CS_TIMER_2] = 0; + pthis->work[CS_TIMER_2] = 0; // fallthrough case 1: - if (this->work[CS_TIMER_2] == 20) { + if (pthis->work[CS_TIMER_2] == 20) { Message_StartTextbox(globalCtx, 0x6059, NULL); } - if (this->work[CS_TIMER_2] == 80) { + if (pthis->work[CS_TIMER_2] == 80) { Message_StartTextbox(globalCtx, 0x605A, NULL); } - this->subCamAt.x = 0.0f; - this->subCamAt.y = 440.0f; - this->subCamAt.z = 0.0f; + pthis->subCamAt.x = 0.0f; + pthis->subCamAt.y = 440.0f; + pthis->subCamAt.z = 0.0f; spB0.x = 0.0f; spB0.y = 0.0f; - spB0.z = this->subCamDist; + spB0.z = pthis->subCamDist; - Matrix_RotateY(this->subCamYaw, MTXMODE_NEW); + Matrix_RotateY(pthis->subCamYaw, MTXMODE_NEW); Matrix_MultVec3f(&spB0, &spA4); - this->subCamEye.x = spA4.x; - this->subCamEye.y = 300.0f; - this->subCamEye.z = spA4.z; + pthis->subCamEye.x = spA4.x; + pthis->subCamEye.y = 300.0f; + pthis->subCamEye.z = spA4.z; - Math_ApproachF(&this->subCamYaw, 0.3f, 0.02f, 0.03f); - Math_ApproachF(&this->subCamDist, 200.0f, 0.1f, 5.0f); + Math_ApproachF(&pthis->subCamYaw, 0.3f, 0.02f, 0.03f); + Math_ApproachF(&pthis->subCamDist, 200.0f, 0.1f, 5.0f); break; case 2: spB0.x = 0.0f; spB0.y = 0.0f; - spB0.z = this->subCamDist; - Matrix_RotateY(this->subCamYaw, MTXMODE_NEW); + spB0.z = pthis->subCamDist; + Matrix_RotateY(pthis->subCamYaw, MTXMODE_NEW); Matrix_MultVec3f(&spB0, &spA4); - this->subCamEye.x = spA4.x; - this->subCamEye.z = spA4.z; - Math_ApproachF(&this->subCamEye.y, 420.0f, 0.1f, this->subCamUpdateRate * 20.0f); - Math_ApproachF(&this->subCamAt.y, 470.0f, 0.1f, this->subCamUpdateRate * 6.0f); - Math_ApproachF(&this->subCamYaw, 0.3f, 0.02f, 0.03f); - Math_ApproachF(&this->subCamDist, 60.0f, 0.1f, this->subCamUpdateRate * 32.0f); - Math_ApproachF(&this->subCamUpdateRate, 1, 1, 0.1f); + pthis->subCamEye.x = spA4.x; + pthis->subCamEye.z = spA4.z; + Math_ApproachF(&pthis->subCamEye.y, 420.0f, 0.1f, pthis->subCamUpdateRate * 20.0f); + Math_ApproachF(&pthis->subCamAt.y, 470.0f, 0.1f, pthis->subCamUpdateRate * 6.0f); + Math_ApproachF(&pthis->subCamYaw, 0.3f, 0.02f, 0.03f); + Math_ApproachF(&pthis->subCamDist, 60.0f, 0.1f, pthis->subCamUpdateRate * 32.0f); + Math_ApproachF(&pthis->subCamUpdateRate, 1, 1, 0.1f); break; } - if (this->subCamId != 0) { - if (this->unk_5F9 == 0) { - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); + if (pthis->subCamId != 0) { + if (pthis->unk_5F9 == 0) { + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->subCamAt, &pthis->subCamEye); } else { - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt2, &this->subCamEye2); + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->subCamAt2, &pthis->subCamEye2); } } - switch (this->csState1) { + switch (pthis->csState1) { case 0: Audio_PlayActorSound2(&sKotakePtr->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); - spB0.x = this->workf[UNK_F11]; + spB0.x = pthis->workf[UNK_F11]; spB0.y = 400.0f; spB0.z = 0.0f; - Matrix_RotateY(this->workf[UNK_F9], MTXMODE_NEW); + Matrix_RotateY(pthis->workf[UNK_F9], MTXMODE_NEW); Matrix_MultVec3f(&spB0, &spA4); sKoumePtr->actor.world.pos.x = spA4.x; sKoumePtr->actor.world.pos.y = spA4.y; sKoumePtr->actor.world.pos.z = spA4.z; - sKoumePtr->actor.shape.rot.y = (this->workf[UNK_F9] / M_PI) * 32768.0f; + sKoumePtr->actor.shape.rot.y = (pthis->workf[UNK_F9] / M_PI) * 32768.0f; sKotakePtr->actor.world.pos.x = -spA4.x; sKotakePtr->actor.world.pos.y = spA4.y; sKotakePtr->actor.world.pos.z = -spA4.z; - sKotakePtr->actor.shape.rot.y = ((this->workf[UNK_F9] / M_PI) * 32768.0f) + 32768.0f; - Math_ApproachF(&this->workf[UNK_F11], 0.0f, 0.1f, 7.0f); - this->workf[UNK_F9] -= this->workf[UNK_F10]; - Math_ApproachF(&this->workf[UNK_F10], 0.5f, 1, 0.0039999997f); - if (this->workf[UNK_F11] < 10.0f) { - if (!this->work[PLAYED_CHRG_SFX]) { + sKotakePtr->actor.shape.rot.y = ((pthis->workf[UNK_F9] / M_PI) * 32768.0f) + 32768.0f; + Math_ApproachF(&pthis->workf[UNK_F11], 0.0f, 0.1f, 7.0f); + pthis->workf[UNK_F9] -= pthis->workf[UNK_F10]; + Math_ApproachF(&pthis->workf[UNK_F10], 0.5f, 1, 0.0039999997f); + if (pthis->workf[UNK_F11] < 10.0f) { + if (!pthis->work[PLAYED_CHRG_SFX]) { Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_POWERUP); - this->work[PLAYED_CHRG_SFX] = true; + pthis->work[PLAYED_CHRG_SFX] = true; } Math_ApproachF(&sKoumePtr->actor.scale.x, 0.005000001f, 1, 0.0003750001f); @@ -1635,10 +1635,10 @@ void BossTw_TwinrovaMergeCS(BossTw* this, GlobalContext* globalCtx) { Vec3f velocity; Vec3f accel; - this->actor.world.pos.y = 400.0f; + pthis->actor.world.pos.y = 400.0f; for (i = 0; i < 50; i++) { - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; velocity.x = Rand_CenteredFloat(20.0f); velocity.y = Rand_CenteredFloat(20.0f); velocity.z = Rand_CenteredFloat(20.0f); @@ -1650,18 +1650,18 @@ void BossTw_TwinrovaMergeCS(BossTw* this, GlobalContext* globalCtx) { velocity.x < 0.0f); } - this->csState1 = 1; - this->visible = true; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.shape.rot.y = 0; + pthis->csState1 = 1; + pthis->visible = true; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.shape.rot.y = 0; BossTw_SetupWait(sKotakePtr, globalCtx); BossTw_SetupWait(sKoumePtr, globalCtx); - Actor_SetScale(&this->actor, 0.0f); - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_038E2C, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_038E2C); - this->timers[0] = 50; - func_8002DF54(globalCtx, &this->actor, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_TRANSFORM); + Actor_SetScale(&pthis->actor, 0.0f); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_038E2C, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_038E2C); + pthis->timers[0] = 50; + func_8002DF54(globalCtx, &pthis->actor, 2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_TRANSFORM); Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); } } @@ -1671,8 +1671,8 @@ void BossTw_TwinrovaMergeCS(BossTw* this, GlobalContext* globalCtx) { break; case 1: - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, -15.0f); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_032BF8, -15.0f); } sEnvType = -1; @@ -1680,198 +1680,198 @@ void BossTw_TwinrovaMergeCS(BossTw* this, GlobalContext* globalCtx) { Math_ApproachF(&globalCtx->envCtx.unk_D8, 1, 1, 0.1f); // fallthrough case 2: - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.scale.x, 0.0069999993f, 1, 0.0006999999f); - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.scale.x, 0.0069999993f, 1, 0.0006999999f); + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; - if (this->timers[0] == 1) { - this->csState2 = 2; - this->subCamUpdateRate = 0.0f; - this->timers[1] = 65; - this->timers[2] = 90; - this->timers[3] = 50; + if (pthis->timers[0] == 1) { + pthis->csState2 = 2; + pthis->subCamUpdateRate = 0.0f; + pthis->timers[1] = 65; + pthis->timers[2] = 90; + pthis->timers[3] = 50; player->actor.world.pos.x = 0.0f; player->actor.world.pos.y = 240.0f; player->actor.world.pos.z = 270.0f; player->actor.world.rot.y = player->actor.shape.rot.y = -0x8000; - this->subCamEye2.x = 0.0f; - this->subCamEye2.y = 290.0f; - this->subCamEye2.z = 222.0f; - this->subCamAt2.x = player->actor.world.pos.x; - this->subCamAt2.y = player->actor.world.pos.y + 54.0f; - this->subCamAt2.z = player->actor.world.pos.z; + pthis->subCamEye2.x = 0.0f; + pthis->subCamEye2.y = 290.0f; + pthis->subCamEye2.z = 222.0f; + pthis->subCamAt2.x = player->actor.world.pos.x; + pthis->subCamAt2.y = player->actor.world.pos.y + 54.0f; + pthis->subCamAt2.z = player->actor.world.pos.z; } - if (this->timers[3] == 19) { - func_8002DF54(globalCtx, &this->actor, 5); + if (pthis->timers[3] == 19) { + func_8002DF54(globalCtx, &pthis->actor, 5); } - if (this->timers[3] == 16) { + if (pthis->timers[3] == 16) { func_8002F7DC(&player->actor, player->ageProperties->unk_92 + NA_SE_VO_LI_SURPRISE); } - if ((this->timers[3] != 0) && (this->timers[3] < 20)) { - this->unk_5F9 = 1; - Math_ApproachF(&this->subCamEye2.z, 242.0f, 0.2f, 100.0f); + if ((pthis->timers[3] != 0) && (pthis->timers[3] < 20)) { + pthis->unk_5F9 = 1; + Math_ApproachF(&pthis->subCamEye2.z, 242.0f, 0.2f, 100.0f); } else { - this->unk_5F9 = 0; + pthis->unk_5F9 = 0; } - if (this->timers[1] == 8) { - this->work[TW_BLINK_IDX] = 8; + if (pthis->timers[1] == 8) { + pthis->work[TW_BLINK_IDX] = 8; func_80078884(NA_SE_EN_TWINROBA_YOUNG_WINK); } - if (this->timers[2] == 4) { + if (pthis->timers[2] == 4) { sEnvType = 0; globalCtx->envCtx.unk_BE = 5; } - if (this->timers[2] == 1) { + if (pthis->timers[2] == 1) { Camera* cam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - cam->eye = this->subCamEye; - cam->eyeNext = this->subCamEye; - cam->at = this->subCamAt; - func_800C08AC(globalCtx, this->subCamId, 0); - this->subCamId = 0; - this->csState2 = this->subCamId; + cam->eye = pthis->subCamEye; + cam->eyeNext = pthis->subCamEye; + cam->at = pthis->subCamAt; + func_800C08AC(globalCtx, pthis->subCamId, 0); + pthis->subCamId = 0; + pthis->csState2 = pthis->subCamId; func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->work[TW_PLLR_IDX] = 0; - this->targetPos = sTwinrovaPillarPos[0]; - BossTw_TwinrovaSetupFly(this, globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->work[TW_PLLR_IDX] = 0; + pthis->targetPos = sTwinrovaPillarPos[0]; + BossTw_TwinrovaSetupFly(pthis, globalCtx); } break; } } -void BossTw_SetupDeathCS(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_DeathCS; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_0004A4, -3.0f); - this->unk_5F8 = 0; - this->work[CS_TIMER_2] = Rand_ZeroFloat(20.0f); +void BossTw_SetupDeathCS(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_DeathCS; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_0004A4, -3.0f); + pthis->unk_5F8 = 0; + pthis->work[CS_TIMER_2] = Rand_ZeroFloat(20.0f); } -void BossTw_DeathCS(BossTw* this, GlobalContext* globalCtx) { - if (this->timers[0] == 0) { - SkelAnime_Update(&this->skelAnime); +void BossTw_DeathCS(BossTw* pthis, GlobalContext* globalCtx) { + if (pthis->timers[0] == 0) { + SkelAnime_Update(&pthis->skelAnime); } - Math_ApproachS(&this->actor.shape.rot.y, this->work[YAW_TGT], 5, this->rotateSpeed); - Math_ApproachF(&this->rotateSpeed, 20480.0f, 1.0f, 1000.0f); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->work[YAW_TGT], 5, pthis->rotateSpeed); + Math_ApproachF(&pthis->rotateSpeed, 20480.0f, 1.0f, 1000.0f); if (sTwinrovaPtr->work[CS_TIMER_2] > 140) { - Math_ApproachF(&this->fogR, 100.0f, 1.0f, 15.0f); - Math_ApproachF(&this->fogG, 255.0f, 1.0f, 15.0f); - Math_ApproachF(&this->fogB, 255.0f, 1.0f, 15.0f); - Math_ApproachF(&this->fogNear, 850.0f, 1.0f, 15.0f); - Math_ApproachF(&this->fogFar, 1099.0f, 1.0f, 15.0f); + Math_ApproachF(&pthis->fogR, 100.0f, 1.0f, 15.0f); + Math_ApproachF(&pthis->fogG, 255.0f, 1.0f, 15.0f); + Math_ApproachF(&pthis->fogB, 255.0f, 1.0f, 15.0f); + Math_ApproachF(&pthis->fogNear, 850.0f, 1.0f, 15.0f); + Math_ApproachF(&pthis->fogFar, 1099.0f, 1.0f, 15.0f); } } -void BossTw_SetupCSWait(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_CSWait; - this->visible = false; - this->actor.world.pos.y = -2000.0f; - this->actor.flags &= ~ACTOR_FLAG_0; +void BossTw_SetupCSWait(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_CSWait; + pthis->visible = false; + pthis->actor.world.pos.y = -2000.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; } /** * Do nothing while waiting for the inital cutscene to start */ -void BossTw_CSWait(BossTw* this, GlobalContext* globalCtx) { +void BossTw_CSWait(BossTw* pthis, GlobalContext* globalCtx) { } -void BossTw_TwinrovaSetupIntroCS(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaIntroCS; - this->visible = false; - this->actor.world.pos.y = -2000.0f; - this->actor.flags &= ~ACTOR_FLAG_0; +void BossTw_TwinrovaSetupIntroCS(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaIntroCS; + pthis->visible = false; + pthis->actor.world.pos.y = -2000.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; } -void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaIntroCS(BossTw* pthis, GlobalContext* globalCtx) { u8 updateCam = 0; s16 i; Vec3f sp90; Vec3f sp84; Player* player = GET_PLAYER(globalCtx); - if (this->csSfxTimer > 220 && this->csSfxTimer < 630) { + if (pthis->csSfxTimer > 220 && pthis->csSfxTimer < 630) { func_80078884(NA_SE_EN_TWINROBA_UNARI - SFX_FLAG); } - if (this->csSfxTimer == 180) { + if (pthis->csSfxTimer == 180) { func_80078914(&D_8094A7D0, NA_SE_EN_TWINROBA_LAUGH); func_80078914(&D_8094A7D0, NA_SE_EN_TWINROBA_LAUGH2); Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KOTAKE_KOUME); } - this->csSfxTimer++; + pthis->csSfxTimer++; - switch (this->csState2) { + switch (pthis->csState2) { case 0: - this->csSfxTimer = 0; + pthis->csSfxTimer = 0; if (SQ(player->actor.world.pos.x) + SQ(player->actor.world.pos.z) < SQ(150.0f)) { player->actor.world.pos.x = player->actor.world.pos.z = .0f; - this->csState2 = 1; + pthis->csState2 = 1; func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 0x39); - this->subCamId = Gameplay_CreateSubCamera(globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 0x39); + pthis->subCamId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->subCamId, CAM_STAT_ACTIVE); - this->subCamEye.x = 0.0f; - this->subCamEye.y = 350; - this->subCamEye.z = 200; + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCamId, CAM_STAT_ACTIVE); + pthis->subCamEye.x = 0.0f; + pthis->subCamEye.y = 350; + pthis->subCamEye.z = 200; - this->subCamEyeTarget.x = 450; - this->subCamEyeTarget.y = 900; + pthis->subCamEyeTarget.x = 450; + pthis->subCamEyeTarget.y = 900; - this->subCamAt.x = 0; - this->subCamAt.y = 270; - this->subCamAt.z = 0; + pthis->subCamAt.x = 0; + pthis->subCamAt.y = 270; + pthis->subCamAt.z = 0; - this->subCamAtTarget.x = 0; - this->subCamAtTarget.y = 240; - this->subCamAtTarget.z = 140; + pthis->subCamAtTarget.x = 0; + pthis->subCamAtTarget.y = 240; + pthis->subCamAtTarget.z = 140; - this->subCamEyeTarget.z = 530; - this->subCamEyeStep.x = fabsf(this->subCamEyeTarget.x - this->subCamEye.x); - this->subCamEyeStep.y = fabsf(this->subCamEyeTarget.y - this->subCamEye.y); - this->subCamEyeStep.z = fabsf(this->subCamEyeTarget.z - this->subCamEye.z); - this->subCamAtStep.x = fabsf(this->subCamAtTarget.x - this->subCamAt.x); - this->subCamAtStep.y = fabsf(this->subCamAtTarget.y - this->subCamAt.y); - this->subCamAtStep.z = fabsf(this->subCamAtTarget.z - this->subCamAt.z); + pthis->subCamEyeTarget.z = 530; + pthis->subCamEyeStep.x = fabsf(pthis->subCamEyeTarget.x - pthis->subCamEye.x); + pthis->subCamEyeStep.y = fabsf(pthis->subCamEyeTarget.y - pthis->subCamEye.y); + pthis->subCamEyeStep.z = fabsf(pthis->subCamEyeTarget.z - pthis->subCamEye.z); + pthis->subCamAtStep.x = fabsf(pthis->subCamAtTarget.x - pthis->subCamAt.x); + pthis->subCamAtStep.y = fabsf(pthis->subCamAtTarget.y - pthis->subCamAt.y); + pthis->subCamAtStep.z = fabsf(pthis->subCamAtTarget.z - pthis->subCamAt.z); - this->subCamDistStep = 0.05f; - this->work[CS_TIMER_1] = 0; + pthis->subCamDistStep = 0.05f; + pthis->work[CS_TIMER_1] = 0; } break; case 1: updateCam = 1; - if (this->work[CS_TIMER_1] == 30) { + if (pthis->work[CS_TIMER_1] == 30) { Message_StartTextbox(globalCtx, 0x6048, NULL); } - Math_ApproachF(&this->subCamUpdateRate, 0.01f, 1.0f, 0.0001f); + Math_ApproachF(&pthis->subCamUpdateRate, 0.01f, 1.0f, 0.0001f); - if (this->work[CS_TIMER_1] > 100) { + if (pthis->work[CS_TIMER_1] > 100) { globalCtx->envCtx.unk_BD = 0; Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.03f); } - if (this->work[CS_TIMER_1] == 180) { + if (pthis->work[CS_TIMER_1] == 180) { func_80078884(NA_SE_EN_TWINROBA_APPEAR_MS); } - if (this->work[CS_TIMER_1] > 180) { - this->spawnPortalScale = 0.05f; - Math_ApproachF(&this->spawnPortalAlpha, 255.0f, 1.0f, 5.f); + if (pthis->work[CS_TIMER_1] > 180) { + pthis->spawnPortalScale = 0.05f; + Math_ApproachF(&pthis->spawnPortalAlpha, 255.0f, 1.0f, 5.f); - if (this->work[CS_TIMER_1] >= 236) { - this->csState2 = 2; + if (pthis->work[CS_TIMER_1] >= 236) { + pthis->csState2 = 2; sKoumePtr->visible = 1; Animation_MorphToLoop(&sKoumePtr->skelAnime, &object_tw_Anim_0004A4, 0.0f); sKoumePtr->actor.world.pos.x = 0.0f; @@ -1879,15 +1879,15 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { sKoumePtr->actor.world.pos.z = 600.0f; sKoumePtr->actor.shape.rot.y = sKoumePtr->actor.world.rot.y = -0x8000; - this->subCamEye.x = -30; - this->subCamEye.y = 260; - this->subCamEye.z = 470; + pthis->subCamEye.x = -30; + pthis->subCamEye.y = 260; + pthis->subCamEye.z = 470; - this->subCamAt.x = 0.0F; - this->subCamAt.y = 270; - this->subCamAt.z = 600.0F; + pthis->subCamAt.x = 0.0F; + pthis->subCamAt.y = 270; + pthis->subCamAt.z = 600.0F; - this->work[CS_TIMER_1] = 0; + pthis->work[CS_TIMER_1] = 0; Actor_SetScale(&sKoumePtr->actor, 0.014999999f); } @@ -1897,29 +1897,29 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { case 2: SkelAnime_Update(&sKoumePtr->skelAnime); Math_ApproachF(&sKoumePtr->actor.world.pos.y, 240.0f, 0.05f, 5.0f); - this->subCamEye.x -= 0.2f; - this->subCamEye.z += 0.2f; + pthis->subCamEye.x -= 0.2f; + pthis->subCamEye.z += 0.2f; - if (this->work[CS_TIMER_1] > 50) { - this->csState2 = 3; + if (pthis->work[CS_TIMER_1] > 50) { + pthis->csState2 = 3; - this->subCamEyeTarget.x = -30; - this->subCamEyeTarget.y = 260; - this->subCamEyeTarget.z = 530; + pthis->subCamEyeTarget.x = -30; + pthis->subCamEyeTarget.y = 260; + pthis->subCamEyeTarget.z = 530; - this->subCamAtTarget.x = 0.0f; - this->subCamAtTarget.y = 265; - this->subCamAtTarget.z = 580; + pthis->subCamAtTarget.x = 0.0f; + pthis->subCamAtTarget.y = 265; + pthis->subCamAtTarget.z = 580; - this->subCamEyeStep.x = fabsf(this->subCamEyeTarget.x - this->subCamEye.x); - this->subCamEyeStep.y = fabsf(this->subCamEyeTarget.y - this->subCamEye.y); - this->subCamEyeStep.z = fabsf(this->subCamEyeTarget.z - this->subCamEye.z); - this->subCamAtStep.x = fabsf(this->subCamAtTarget.x - this->subCamAt.x); - this->subCamAtStep.y = fabsf(this->subCamAtTarget.y - this->subCamAt.y); - this->subCamAtStep.z = fabsf(this->subCamAtTarget.z - this->subCamAt.z); - this->subCamUpdateRate = 0; - this->subCamDistStep = 0.1f; - this->work[CS_TIMER_1] = 0; + pthis->subCamEyeStep.x = fabsf(pthis->subCamEyeTarget.x - pthis->subCamEye.x); + pthis->subCamEyeStep.y = fabsf(pthis->subCamEyeTarget.y - pthis->subCamEye.y); + pthis->subCamEyeStep.z = fabsf(pthis->subCamEyeTarget.z - pthis->subCamEye.z); + pthis->subCamAtStep.x = fabsf(pthis->subCamAtTarget.x - pthis->subCamAt.x); + pthis->subCamAtStep.y = fabsf(pthis->subCamAtTarget.y - pthis->subCamAt.y); + pthis->subCamAtStep.z = fabsf(pthis->subCamAtTarget.z - pthis->subCamAt.z); + pthis->subCamUpdateRate = 0; + pthis->subCamDistStep = 0.1f; + pthis->work[CS_TIMER_1] = 0; } break; @@ -1927,48 +1927,48 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { SkelAnime_Update(&sKoumePtr->skelAnime); updateCam = 1; Math_ApproachF(&sKoumePtr->actor.world.pos.y, 240.0f, 0.05f, 5.0f); - Math_ApproachF(&this->subCamUpdateRate, 1.0f, 1.0f, 0.02f); + Math_ApproachF(&pthis->subCamUpdateRate, 1.0f, 1.0f, 0.02f); - if (this->work[CS_TIMER_1] == 30) { + if (pthis->work[CS_TIMER_1] == 30) { Message_StartTextbox(globalCtx, 0x6049, NULL); } - if (this->work[CS_TIMER_1] > 80) { - this->csState2 = 4; - this->actor.speedXZ = 0; + if (pthis->work[CS_TIMER_1] > 80) { + pthis->csState2 = 4; + pthis->actor.speedXZ = 0; - this->subCamEyeTarget.x = -80.0f; - this->subCamEyeTarget.y = 260.0f; - this->subCamEyeTarget.z = 430.0f; + pthis->subCamEyeTarget.x = -80.0f; + pthis->subCamEyeTarget.y = 260.0f; + pthis->subCamEyeTarget.z = 430.0f; - this->subCamAtTarget.x = sKoumePtr->actor.world.pos.x; - this->subCamAtTarget.y = sKoumePtr->actor.world.pos.y + 20.0f; - this->subCamAtTarget.z = sKoumePtr->actor.world.pos.z; + pthis->subCamAtTarget.x = sKoumePtr->actor.world.pos.x; + pthis->subCamAtTarget.y = sKoumePtr->actor.world.pos.y + 20.0f; + pthis->subCamAtTarget.z = sKoumePtr->actor.world.pos.z; - this->subCamEyeStep.x = fabsf(this->subCamEyeTarget.x - this->subCamEye.x); - this->subCamEyeStep.y = fabsf(this->subCamEyeTarget.y - this->subCamEye.y); - this->subCamEyeStep.z = fabsf(this->subCamEyeTarget.z - this->subCamEye.z); - this->subCamAtStep.x = fabsf(this->subCamAtTarget.x - this->subCamAt.x); - this->subCamAtStep.y = fabsf(this->subCamAtTarget.y - this->subCamAt.y); - this->subCamAtStep.z = fabsf(this->subCamAtTarget.z - this->subCamAt.z); - this->subCamUpdateRate = 0.0f; - this->subCamDistStep = 0.05f; + pthis->subCamEyeStep.x = fabsf(pthis->subCamEyeTarget.x - pthis->subCamEye.x); + pthis->subCamEyeStep.y = fabsf(pthis->subCamEyeTarget.y - pthis->subCamEye.y); + pthis->subCamEyeStep.z = fabsf(pthis->subCamEyeTarget.z - pthis->subCamEye.z); + pthis->subCamAtStep.x = fabsf(pthis->subCamAtTarget.x - pthis->subCamAt.x); + pthis->subCamAtStep.y = fabsf(pthis->subCamAtTarget.y - pthis->subCamAt.y); + pthis->subCamAtStep.z = fabsf(pthis->subCamAtTarget.z - pthis->subCamAt.z); + pthis->subCamUpdateRate = 0.0f; + pthis->subCamDistStep = 0.05f; Animation_MorphToPlayOnce(&sKoumePtr->skelAnime, &object_tw_Anim_000AAC, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_000AAC); - this->work[CS_TIMER_1] = 0; + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_000AAC); + pthis->work[CS_TIMER_1] = 0; } break; case 4: updateCam = 1; SkelAnime_Update(&sKoumePtr->skelAnime); - this->subCamAtTarget.y = 20.0f + sKoumePtr->actor.world.pos.y; - Math_ApproachF(&sKoumePtr->actor.world.pos.y, 350, 0.1f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 9.0f, 1.0f, 0.9f); - Math_ApproachF(&this->subCamUpdateRate, 1.0f, 1.0f, 0.02f); + pthis->subCamAtTarget.y = 20.0f + sKoumePtr->actor.world.pos.y; + Math_ApproachF(&sKoumePtr->actor.world.pos.y, 350, 0.1f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 9.0f, 1.0f, 0.9f); + Math_ApproachF(&pthis->subCamUpdateRate, 1.0f, 1.0f, 0.02f); - if (this->work[CS_TIMER_1] >= 30) { - if (this->work[CS_TIMER_1] < 45) { + if (pthis->work[CS_TIMER_1] >= 30) { + if (pthis->work[CS_TIMER_1] < 45) { globalCtx->envCtx.unk_BE = 0; globalCtx->envCtx.unk_BD = 2; globalCtx->envCtx.unk_D8 = 1.0f; @@ -1976,7 +1976,7 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.1f); } - if (this->work[CS_TIMER_1] == 30) { + if (pthis->work[CS_TIMER_1] == 30) { for (i = 0; i < 50; i++) { Vec3f pos; Vec3f velocity; @@ -1995,24 +1995,24 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { globalCtx->envCtx.unk_D8 = 0; } - if (this->work[CS_TIMER_1] >= 35) { - if (this->work[CS_TIMER_1] < 50) { + if (pthis->work[CS_TIMER_1] >= 35) { + if (pthis->work[CS_TIMER_1] < 50) { Math_ApproachF(&sKoumePtr->actor.scale.x, - ((Math_SinS(this->work[CS_TIMER_1] * 0x4200) * 20.0f) / 10000.0f) + 0.024999999f, + ((Math_SinS(pthis->work[CS_TIMER_1] * 0x4200) * 20.0f) / 10000.0f) + 0.024999999f, 1.0f, 0.005f); } else { - if (this->work[CS_TIMER_1] == 50) { + if (pthis->work[CS_TIMER_1] == 50) { Animation_MorphToPlayOnce(&sKoumePtr->skelAnime, &object_tw_Anim_0088C8, -5); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0088C8); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0088C8); } - if (this->work[CS_TIMER_1] == 60) { + if (pthis->work[CS_TIMER_1] == 60) { Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_LAUGH); } - if (Animation_OnFrame(&sKoumePtr->skelAnime, this->workf[ANIM_SW_TGT])) { + if (Animation_OnFrame(&sKoumePtr->skelAnime, pthis->workf[ANIM_SW_TGT])) { Animation_MorphToLoop(&sKoumePtr->skelAnime, &object_tw_Anim_006F28, 0.f); - this->workf[ANIM_SW_TGT] = 1000.0f; + pthis->workf[ANIM_SW_TGT] = 1000.0f; } Math_ApproachF(&sKoumePtr->actor.scale.x, 0.024999999f, 0.1f, 0.005f); @@ -2022,41 +2022,41 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { sKoumePtr->actor.shape.rot.y = -0x8000; sKoumePtr->unk_5F8 = 1; - if (this->work[CS_TIMER_1] == 0x64) { - this->csState2 = 10; - this->work[CS_TIMER_1] = 0; - this->subCamYawStep = 0.0f; + if (pthis->work[CS_TIMER_1] == 0x64) { + pthis->csState2 = 10; + pthis->work[CS_TIMER_1] = 0; + pthis->subCamYawStep = 0.0f; sKotakePtr->visible = 1; Animation_MorphToLoop(&sKotakePtr->skelAnime, &object_tw_Anim_0004A4, 0.0f); sKotakePtr->actor.world.pos.x = 0.0f; sKotakePtr->actor.world.pos.y = 80.0f; sKotakePtr->actor.world.pos.z = -600.0f; sKotakePtr->actor.shape.rot.y = sKotakePtr->actor.world.rot.y = 0; - this->work[CS_TIMER_1] = 0; + pthis->work[CS_TIMER_1] = 0; - this->subCamEye.x = -30.0f; - this->subCamEye.y = 260.0f; - this->subCamEye.z = -470.0f; + pthis->subCamEye.x = -30.0f; + pthis->subCamEye.y = 260.0f; + pthis->subCamEye.z = -470.0f; - this->subCamAt.x = 0; - this->subCamAt.y = 270.0f; - this->subCamAt.z = -600.0f; + pthis->subCamAt.x = 0; + pthis->subCamAt.y = 270.0f; + pthis->subCamAt.z = -600.0f; Actor_SetScale(&sKotakePtr->actor, 0.014999999f); } } else { - sKoumePtr->actor.shape.rot.y = sKoumePtr->actor.shape.rot.y + (s16)this->subCamYawStep; + sKoumePtr->actor.shape.rot.y = sKoumePtr->actor.shape.rot.y + (s16)pthis->subCamYawStep; } } else { - if ((this->work[CS_TIMER_1] % 8) == 0) { + if ((pthis->work[CS_TIMER_1] % 8) == 0) { Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_ROLL); } - sKoumePtr->actor.shape.rot.y = sKoumePtr->actor.shape.rot.y + (s16)this->subCamYawStep; - Math_ApproachF(&this->subCamYawStep, 12288.0f, 1.0f, 384.0f); + sKoumePtr->actor.shape.rot.y = sKoumePtr->actor.shape.rot.y + (s16)pthis->subCamYawStep; + Math_ApproachF(&pthis->subCamYawStep, 12288.0f, 1.0f, 384.0f); - if (Animation_OnFrame(&sKoumePtr->skelAnime, this->workf[ANIM_SW_TGT])) { + if (Animation_OnFrame(&sKoumePtr->skelAnime, pthis->workf[ANIM_SW_TGT])) { Animation_MorphToLoop(&sKoumePtr->skelAnime, &object_tw_Anim_006F28, 0.0f); - this->workf[ANIM_SW_TGT] = 1000.0f; + pthis->workf[ANIM_SW_TGT] = 1000.0f; } } break; @@ -2064,26 +2064,26 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { case 10: SkelAnime_Update(&sKotakePtr->skelAnime); Math_ApproachF(&sKotakePtr->actor.world.pos.y, 240.0f, 0.05f, 5.0f); - this->subCamEye.x -= 0.2f; - this->subCamEye.z -= 0.2f; + pthis->subCamEye.x -= 0.2f; + pthis->subCamEye.z -= 0.2f; - if (this->work[CS_TIMER_1] >= 0x33) { - this->csState2 = 11; - this->subCamEyeTarget.x = -30; - this->subCamEyeTarget.y = 260; - this->subCamEyeTarget.z = -530; - this->subCamAtTarget.x = 0; - this->subCamAtTarget.y = 265; - this->subCamAtTarget.z = -580; - this->subCamEyeStep.x = fabsf(this->subCamEyeTarget.x - this->subCamEye.x); - this->subCamEyeStep.y = fabsf(this->subCamEyeTarget.y - this->subCamEye.y); - this->subCamEyeStep.z = fabsf(this->subCamEyeTarget.z - this->subCamEye.z); - this->subCamAtStep.x = fabsf(this->subCamAtTarget.x - this->subCamAt.x); - this->subCamAtStep.y = fabsf(this->subCamAtTarget.y - this->subCamAt.y); - this->subCamAtStep.z = fabsf(this->subCamAtTarget.z - this->subCamAt.z); - this->subCamUpdateRate = 0; - this->subCamDistStep = 0.1f; - this->work[CS_TIMER_1] = 0; + if (pthis->work[CS_TIMER_1] >= 0x33) { + pthis->csState2 = 11; + pthis->subCamEyeTarget.x = -30; + pthis->subCamEyeTarget.y = 260; + pthis->subCamEyeTarget.z = -530; + pthis->subCamAtTarget.x = 0; + pthis->subCamAtTarget.y = 265; + pthis->subCamAtTarget.z = -580; + pthis->subCamEyeStep.x = fabsf(pthis->subCamEyeTarget.x - pthis->subCamEye.x); + pthis->subCamEyeStep.y = fabsf(pthis->subCamEyeTarget.y - pthis->subCamEye.y); + pthis->subCamEyeStep.z = fabsf(pthis->subCamEyeTarget.z - pthis->subCamEye.z); + pthis->subCamAtStep.x = fabsf(pthis->subCamAtTarget.x - pthis->subCamAt.x); + pthis->subCamAtStep.y = fabsf(pthis->subCamAtTarget.y - pthis->subCamAt.y); + pthis->subCamAtStep.z = fabsf(pthis->subCamAtTarget.z - pthis->subCamAt.z); + pthis->subCamUpdateRate = 0; + pthis->subCamDistStep = 0.1f; + pthis->work[CS_TIMER_1] = 0; } break; @@ -2091,55 +2091,55 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { SkelAnime_Update(&sKotakePtr->skelAnime); updateCam = 1; Math_ApproachF(&sKotakePtr->actor.world.pos.y, 240.0f, 0.05f, 5.0f); - Math_ApproachF(&this->subCamUpdateRate, 1.0f, 1.0f, 0.02f); + Math_ApproachF(&pthis->subCamUpdateRate, 1.0f, 1.0f, 0.02f); - if (this->work[CS_TIMER_1] == 30) { + if (pthis->work[CS_TIMER_1] == 30) { Message_StartTextbox(globalCtx, 0x604A, NULL); } - if (this->work[CS_TIMER_1] > 80) { - this->csState2 = 12; - this->actor.speedXZ = 0; + if (pthis->work[CS_TIMER_1] > 80) { + pthis->csState2 = 12; + pthis->actor.speedXZ = 0; - this->subCamEyeTarget.y = 260.0f; - this->subCamEyeTarget.x = -80.0f; - this->subCamEyeTarget.z = -430.0f; + pthis->subCamEyeTarget.y = 260.0f; + pthis->subCamEyeTarget.x = -80.0f; + pthis->subCamEyeTarget.z = -430.0f; - this->subCamAtTarget.x = sKotakePtr->actor.world.pos.x; - this->subCamAtTarget.y = sKotakePtr->actor.world.pos.y + 20.0f; - this->subCamAtTarget.z = sKotakePtr->actor.world.pos.z; + pthis->subCamAtTarget.x = sKotakePtr->actor.world.pos.x; + pthis->subCamAtTarget.y = sKotakePtr->actor.world.pos.y + 20.0f; + pthis->subCamAtTarget.z = sKotakePtr->actor.world.pos.z; - this->subCamEyeStep.x = fabsf(this->subCamEyeTarget.x - this->subCamEye.x); - this->subCamEyeStep.y = fabsf(this->subCamEyeTarget.y - this->subCamEye.y); - this->subCamEyeStep.z = fabsf(this->subCamEyeTarget.z - this->subCamEye.z); - this->subCamAtStep.x = fabsf(this->subCamAtTarget.x - this->subCamAt.x); - this->subCamAtStep.y = fabsf(this->subCamAtTarget.y - this->subCamAt.y); - this->subCamAtStep.z = fabsf(this->subCamAtTarget.z - this->subCamAt.z); - this->subCamUpdateRate = 0; - this->subCamDistStep = 0.05f; + pthis->subCamEyeStep.x = fabsf(pthis->subCamEyeTarget.x - pthis->subCamEye.x); + pthis->subCamEyeStep.y = fabsf(pthis->subCamEyeTarget.y - pthis->subCamEye.y); + pthis->subCamEyeStep.z = fabsf(pthis->subCamEyeTarget.z - pthis->subCamEye.z); + pthis->subCamAtStep.x = fabsf(pthis->subCamAtTarget.x - pthis->subCamAt.x); + pthis->subCamAtStep.y = fabsf(pthis->subCamAtTarget.y - pthis->subCamAt.y); + pthis->subCamAtStep.z = fabsf(pthis->subCamAtTarget.z - pthis->subCamAt.z); + pthis->subCamUpdateRate = 0; + pthis->subCamDistStep = 0.05f; Animation_MorphToPlayOnce(&sKotakePtr->skelAnime, &object_tw_Anim_000AAC, 0); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_000AAC); - this->work[CS_TIMER_1] = 0; + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_000AAC); + pthis->work[CS_TIMER_1] = 0; } break; case 12: updateCam = 1; SkelAnime_Update(&sKotakePtr->skelAnime); - this->subCamAtTarget.y = sKotakePtr->actor.world.pos.y + 20.0f; - Math_ApproachF(&sKotakePtr->actor.world.pos.y, 350, 0.1f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 9.0f, 1.0f, 0.9f); - Math_ApproachF(&this->subCamUpdateRate, 1.0f, 1.0f, 0.02f); + pthis->subCamAtTarget.y = sKotakePtr->actor.world.pos.y + 20.0f; + Math_ApproachF(&sKotakePtr->actor.world.pos.y, 350, 0.1f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 9.0f, 1.0f, 0.9f); + Math_ApproachF(&pthis->subCamUpdateRate, 1.0f, 1.0f, 0.02f); - if (this->work[CS_TIMER_1] >= 30) { - if (this->work[CS_TIMER_1] < 45) { + if (pthis->work[CS_TIMER_1] >= 30) { + if (pthis->work[CS_TIMER_1] < 45) { globalCtx->envCtx.unk_BD = 3; globalCtx->envCtx.unk_D8 = 1.0f; } else { Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.1f); } - if (this->work[CS_TIMER_1] == 30) { + if (pthis->work[CS_TIMER_1] == 30) { for (i = 0; i < 50; i++) { Vec3f pos; Vec3f velocity; @@ -2157,24 +2157,24 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { globalCtx->envCtx.unk_D8 = 0.0f; } - if (this->work[CS_TIMER_1] >= 35) { - if (this->work[CS_TIMER_1] < 50) { + if (pthis->work[CS_TIMER_1] >= 35) { + if (pthis->work[CS_TIMER_1] < 50) { Math_ApproachF(&sKotakePtr->actor.scale.x, - ((Math_SinS(this->work[CS_TIMER_1] * 0x4200) * 20.0f) / 10000.0f) + 0.024999999f, + ((Math_SinS(pthis->work[CS_TIMER_1] * 0x4200) * 20.0f) / 10000.0f) + 0.024999999f, 1.0f, 0.005f); } else { - if (this->work[CS_TIMER_1] == 50) { + if (pthis->work[CS_TIMER_1] == 50) { Animation_MorphToPlayOnce(&sKotakePtr->skelAnime, &object_tw_Anim_0088C8, -5.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0088C8); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0088C8); } - if (this->work[CS_TIMER_1] == 60) { + if (pthis->work[CS_TIMER_1] == 60) { Audio_PlayActorSound2(&sKotakePtr->actor, NA_SE_EN_TWINROBA_LAUGH2); } - if (Animation_OnFrame(&sKotakePtr->skelAnime, this->workf[ANIM_SW_TGT])) { + if (Animation_OnFrame(&sKotakePtr->skelAnime, pthis->workf[ANIM_SW_TGT])) { Animation_MorphToLoop(&sKotakePtr->skelAnime, &object_tw_Anim_006F28, 0.0f); - this->workf[ANIM_SW_TGT] = 1000.0f; + pthis->workf[ANIM_SW_TGT] = 1000.0f; } Math_ApproachF(&sKotakePtr->actor.scale.x, 0.024999999f, 0.1f, 0.005f); @@ -2184,55 +2184,55 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { sKotakePtr->actor.shape.rot.y = 0; sKotakePtr->unk_5F8 = 1; - if (this->work[CS_TIMER_1] == 100) { - this->csState2 = 20; - this->work[CS_TIMER_1] = 0; + if (pthis->work[CS_TIMER_1] == 100) { + pthis->csState2 = 20; + pthis->work[CS_TIMER_1] = 0; - this->workf[UNK_F11] = 600.0f; + pthis->workf[UNK_F11] = 600.0f; - this->subCamEye.x = 800.0f; - this->subCamEye.y = 300.0f; - this->subCamEye.z = 0; + pthis->subCamEye.x = 800.0f; + pthis->subCamEye.y = 300.0f; + pthis->subCamEye.z = 0; - this->subCamAt.x = 0.0f; - this->subCamAt.y = 400.0f; - this->subCamAt.z = 0; + pthis->subCamAt.x = 0.0f; + pthis->subCamAt.y = 400.0f; + pthis->subCamAt.z = 0; - this->workf[UNK_F9] = -M_PI / 2.0f; - this->workf[UNK_F10] = 0.0f; + pthis->workf[UNK_F9] = -M_PI / 2.0f; + pthis->workf[UNK_F10] = 0.0f; - this->subCamEyeStep.x = 0.0f; - this->spawnPortalAlpha = 0.0f; + pthis->subCamEyeStep.x = 0.0f; + pthis->spawnPortalAlpha = 0.0f; } } else { - sKotakePtr->actor.shape.rot.y = sKotakePtr->actor.shape.rot.y + (s16)this->subCamYawStep; + sKotakePtr->actor.shape.rot.y = sKotakePtr->actor.shape.rot.y + (s16)pthis->subCamYawStep; } } else { - if ((this->work[CS_TIMER_1] % 8) == 0) { + if ((pthis->work[CS_TIMER_1] % 8) == 0) { Audio_PlayActorSound2(&sKotakePtr->actor, NA_SE_EN_TWINROBA_ROLL); } - sKotakePtr->actor.shape.rot.y = sKotakePtr->actor.shape.rot.y + (s16)this->subCamYawStep; - Math_ApproachF(&this->subCamYawStep, 12288.0f, 1.0f, 384.0f); + sKotakePtr->actor.shape.rot.y = sKotakePtr->actor.shape.rot.y + (s16)pthis->subCamYawStep; + Math_ApproachF(&pthis->subCamYawStep, 12288.0f, 1.0f, 384.0f); - if (Animation_OnFrame(&sKotakePtr->skelAnime, this->workf[ANIM_SW_TGT])) { + if (Animation_OnFrame(&sKotakePtr->skelAnime, pthis->workf[ANIM_SW_TGT])) { Animation_MorphToLoop(&sKotakePtr->skelAnime, &object_tw_Anim_006F28, 0.0f); - this->workf[ANIM_SW_TGT] = 1000.0f; + pthis->workf[ANIM_SW_TGT] = 1000.0f; } } break; case 20: - if (this->work[CS_TIMER_1] > 20 && this->work[CS_TIMER_1] < 120) { + if (pthis->work[CS_TIMER_1] > 20 && pthis->work[CS_TIMER_1] < 120) { globalCtx->envCtx.unk_BD = 1; Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.015f); } - if (this->work[CS_TIMER_1] == 90) { + if (pthis->work[CS_TIMER_1] == 90) { Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5A00FF); } - if (this->work[CS_TIMER_1] == 120) { + if (pthis->work[CS_TIMER_1] == 120) { sEnvType = 0; globalCtx->envCtx.unk_BE = 1; globalCtx->envCtx.unk_BD = 1; @@ -2243,41 +2243,41 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); } - if (this->work[CS_TIMER_1] >= 160) { - if (this->work[CS_TIMER_1] == 160) { - this->subCamEyeStep.x = 0.0f; + if (pthis->work[CS_TIMER_1] >= 160) { + if (pthis->work[CS_TIMER_1] == 160) { + pthis->subCamEyeStep.x = 0.0f; } - Math_ApproachF(&this->subCamEye.x, 0.0f, 0.05f, this->subCamEyeStep.x * 0.5f); - Math_ApproachF(&this->subCamEye.z, 1000.0f, 0.05f, this->subCamEyeStep.x); - Math_ApproachF(&this->subCamEyeStep.x, 40.0f, 1.0f, 1); + Math_ApproachF(&pthis->subCamEye.x, 0.0f, 0.05f, pthis->subCamEyeStep.x * 0.5f); + Math_ApproachF(&pthis->subCamEye.z, 1000.0f, 0.05f, pthis->subCamEyeStep.x); + Math_ApproachF(&pthis->subCamEyeStep.x, 40.0f, 1.0f, 1); } else { - Math_ApproachF(&this->subCamEye.x, 300.0f, 0.05f, this->subCamEyeStep.x); - Math_ApproachF(&this->subCamEyeStep.x, 5.0f, 1.0f, 0.5f); + Math_ApproachF(&pthis->subCamEye.x, 300.0f, 0.05f, pthis->subCamEyeStep.x); + Math_ApproachF(&pthis->subCamEyeStep.x, 5.0f, 1.0f, 0.5f); } - if (this->work[CS_TIMER_1] < 200) { + if (pthis->work[CS_TIMER_1] < 200) { Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); Audio_PlayActorSound2(&sKotakePtr->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); - sp90.x = this->workf[UNK_F11]; + sp90.x = pthis->workf[UNK_F11]; sp90.y = 400.0f; sp90.z = 0.0f; - Matrix_RotateY(this->workf[UNK_F9], MTXMODE_NEW); + Matrix_RotateY(pthis->workf[UNK_F9], MTXMODE_NEW); Matrix_MultVec3f(&sp90, &sp84); sKoumePtr->actor.world.pos.x = sp84.x; sKoumePtr->actor.world.pos.y = sp84.y; sKoumePtr->actor.world.pos.z = sp84.z; - sKoumePtr->actor.world.rot.y = sKoumePtr->actor.shape.rot.y = (this->workf[UNK_F9] / M_PI) * 32768.0f; + sKoumePtr->actor.world.rot.y = sKoumePtr->actor.shape.rot.y = (pthis->workf[UNK_F9] / M_PI) * 32768.0f; sKotakePtr->actor.world.pos.x = -sp84.x; sKotakePtr->actor.world.pos.y = sp84.y; sKotakePtr->actor.world.pos.z = -sp84.z; sKotakePtr->actor.shape.rot.y = sKotakePtr->actor.world.rot.y = - ((this->workf[UNK_F9] / M_PI) * 32768.0f) + 32768.0f; - Math_ApproachF(&this->workf[UNK_F11], 80.0f, 0.1f, 5.0f); - this->workf[UNK_F9] -= this->workf[UNK_F10]; - Math_ApproachF(&this->workf[UNK_F10], 0.19999999f, 1.0f, 0.0019999994f); + ((pthis->workf[UNK_F9] / M_PI) * 32768.0f) + 32768.0f; + Math_ApproachF(&pthis->workf[UNK_F11], 80.0f, 0.1f, 5.0f); + pthis->workf[UNK_F9] -= pthis->workf[UNK_F10]; + Math_ApproachF(&pthis->workf[UNK_F10], 0.19999999f, 1.0f, 0.0019999994f); } - if (this->work[CS_TIMER_1] == 200) { + if (pthis->work[CS_TIMER_1] == 200) { sKoumePtr->actionFunc = BossTw_FlyTo; sKotakePtr->actionFunc = BossTw_FlyTo; sKoumePtr->targetPos.x = 600.0f; @@ -2290,43 +2290,43 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { sKotakePtr->timers[0] = 100; } - if (this->work[CS_TIMER_1] == 260) { + if (pthis->work[CS_TIMER_1] == 260) { Camera* cam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - cam->eye = this->subCamEye; - cam->eyeNext = this->subCamEye; - cam->at = this->subCamAt; - func_800C08AC(globalCtx, this->subCamId, 0); - this->subCamId = 0; - this->csState2 = this->subCamId; + cam->eye = pthis->subCamEye; + cam->eyeNext = pthis->subCamEye; + cam->at = pthis->subCamAt; + func_800C08AC(globalCtx, pthis->subCamId, 0); + pthis->subCamId = 0; + pthis->csState2 = pthis->subCamId; func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - BossTw_SetupWait(this, globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + BossTw_SetupWait(pthis, globalCtx); } break; } - if (this->subCamId != 0) { + if (pthis->subCamId != 0) { if (updateCam) { - Math_ApproachF(&this->subCamEye.x, this->subCamEyeTarget.x, this->subCamDistStep, - this->subCamEyeStep.x * this->subCamUpdateRate); - Math_ApproachF(&this->subCamEye.y, this->subCamEyeTarget.y, this->subCamDistStep, - this->subCamEyeStep.y * this->subCamUpdateRate); - Math_ApproachF(&this->subCamEye.z, this->subCamEyeTarget.z, this->subCamDistStep, - this->subCamEyeStep.z * this->subCamUpdateRate); - Math_ApproachF(&this->subCamAt.x, this->subCamAtTarget.x, this->subCamDistStep, - this->subCamAtStep.x * this->subCamUpdateRate); - Math_ApproachF(&this->subCamAt.y, this->subCamAtTarget.y, this->subCamDistStep, - this->subCamAtStep.y * this->subCamUpdateRate); - Math_ApproachF(&this->subCamAt.z, this->subCamAtTarget.z, this->subCamDistStep, - this->subCamAtStep.z * this->subCamUpdateRate); + Math_ApproachF(&pthis->subCamEye.x, pthis->subCamEyeTarget.x, pthis->subCamDistStep, + pthis->subCamEyeStep.x * pthis->subCamUpdateRate); + Math_ApproachF(&pthis->subCamEye.y, pthis->subCamEyeTarget.y, pthis->subCamDistStep, + pthis->subCamEyeStep.y * pthis->subCamUpdateRate); + Math_ApproachF(&pthis->subCamEye.z, pthis->subCamEyeTarget.z, pthis->subCamDistStep, + pthis->subCamEyeStep.z * pthis->subCamUpdateRate); + Math_ApproachF(&pthis->subCamAt.x, pthis->subCamAtTarget.x, pthis->subCamDistStep, + pthis->subCamAtStep.x * pthis->subCamUpdateRate); + Math_ApproachF(&pthis->subCamAt.y, pthis->subCamAtTarget.y, pthis->subCamDistStep, + pthis->subCamAtStep.y * pthis->subCamUpdateRate); + Math_ApproachF(&pthis->subCamAt.z, pthis->subCamAtTarget.z, pthis->subCamDistStep, + pthis->subCamAtStep.z * pthis->subCamUpdateRate); } - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->subCamAt, &pthis->subCamEye); } } -void BossTw_DeathBall(BossTw* this, GlobalContext* globalCtx) { +void BossTw_DeathBall(BossTw* pthis, GlobalContext* globalCtx) { f32 xDiff; f32 yDiff; f32 zDiff; @@ -2334,76 +2334,76 @@ void BossTw_DeathBall(BossTw* this, GlobalContext* globalCtx) { s16 i; s16 yaw; - if ((this->work[CS_TIMER_1] % 16) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_FB_FLY); + if ((pthis->work[CS_TIMER_1] % 16) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_FB_FLY); } if (sTwinrovaPtr->csState2 < 2) { - if (this->timers[0] == 0) { - this->timers[0] = 20; - this->targetPos.x = Rand_CenteredFloat(100.0f) + sTwinrovaPtr->actor.world.pos.x; - this->targetPos.y = Rand_CenteredFloat(50.0f) + 400.0f; - this->targetPos.z = Rand_CenteredFloat(100.0f) + sTwinrovaPtr->actor.world.pos.z; + if (pthis->timers[0] == 0) { + pthis->timers[0] = 20; + pthis->targetPos.x = Rand_CenteredFloat(100.0f) + sTwinrovaPtr->actor.world.pos.x; + pthis->targetPos.y = Rand_CenteredFloat(50.0f) + 400.0f; + pthis->targetPos.z = Rand_CenteredFloat(100.0f) + sTwinrovaPtr->actor.world.pos.z; } - this->timers[1] = 10; - this->rotateSpeed = 8192.0f; - this->actor.speedXZ = 5.0f; + pthis->timers[1] = 10; + pthis->rotateSpeed = 8192.0f; + pthis->actor.speedXZ = 5.0f; } else { - if (this->timers[1] == 9) { - this->targetPos.y = 413.0f; - this->actor.world.pos.z = 0.0f; - this->actor.world.pos.x = 0.0f; - for (i = 0; i < ARRAY_COUNT(this->blastTailPos); i++) { - this->blastTailPos[i] = this->actor.world.pos; + if (pthis->timers[1] == 9) { + pthis->targetPos.y = 413.0f; + pthis->actor.world.pos.z = 0.0f; + pthis->actor.world.pos.x = 0.0f; + for (i = 0; i < ARRAY_COUNT(pthis->blastTailPos); i++) { + pthis->blastTailPos[i] = pthis->actor.world.pos; } } - if (this->actor.params == 0x69) { - this->targetPos.x = sKoumePtr->actor.world.pos.x; - this->targetPos.z = sKoumePtr->actor.world.pos.z; + if (pthis->actor.params == 0x69) { + pthis->targetPos.x = sKoumePtr->actor.world.pos.x; + pthis->targetPos.z = sKoumePtr->actor.world.pos.z; } else { - this->targetPos.x = sKotakePtr->actor.world.pos.x; - this->targetPos.z = sKotakePtr->actor.world.pos.z; + pthis->targetPos.x = sKotakePtr->actor.world.pos.x; + pthis->targetPos.z = sKotakePtr->actor.world.pos.z; } - Math_ApproachF(&this->targetPos.y, 263.0f, 1.0f, 2.0f); + Math_ApproachF(&pthis->targetPos.y, 263.0f, 1.0f, 2.0f); - if (this->targetPos.y == 263.0f) { - Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.2f); + if (pthis->targetPos.y == 263.0f) { + Math_ApproachF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.2f); if (sTwinrovaPtr->csState2 == 3) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } } - xDiff = this->targetPos.x - this->actor.world.pos.x; - yDiff = this->targetPos.y - this->actor.world.pos.y; - zDiff = this->targetPos.z - this->actor.world.pos.z; + xDiff = pthis->targetPos.x - pthis->actor.world.pos.x; + yDiff = pthis->targetPos.y - pthis->actor.world.pos.y; + zDiff = pthis->targetPos.z - pthis->actor.world.pos.z; yaw = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))) * (32768 / M_PI), 5, - this->rotateSpeed); - Math_ApproachS(&this->actor.world.rot.y, yaw, 5, this->rotateSpeed); - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); + Math_ApproachS(&pthis->actor.world.rot.x, Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))) * (32768 / M_PI), 5, + pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.world.rot.y, yaw, 5, pthis->rotateSpeed); + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); } -void BossTw_TwinrovaSetupDeathCS(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaDeathCS; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_024374, -3.0f); - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.flags &= ~ACTOR_FLAG_0; - this->csState2 = this->csState1 = 0; - this->work[CS_TIMER_1] = this->work[CS_TIMER_2] = 0; - this->work[INVINC_TIMER] = 10000; +void BossTw_TwinrovaSetupDeathCS(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaDeathCS; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_024374, -3.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->csState2 = pthis->csState1 = 0; + pthis->work[CS_TIMER_1] = pthis->work[CS_TIMER_2] = 0; + pthis->work[INVINC_TIMER] = 10000; BossTw_SetupDeathCS(sKoumePtr, globalCtx); BossTw_SetupDeathCS(sKotakePtr, globalCtx); sKotakePtr->timers[0] = 8; - this->workf[UNK_F19] = 1.0f; + pthis->workf[UNK_F19] = 1.0f; } -void BossTw_DeathCSMsgSfx(BossTw* this, GlobalContext* globalCtx) { +void BossTw_DeathCSMsgSfx(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; s32 pad2; s32 pad3; @@ -2419,20 +2419,20 @@ void BossTw_DeathCSMsgSfx(BossTw* this, GlobalContext* globalCtx) { koumeAnim = 0; sp35 = 0; - if (this->work[CS_TIMER_2] == 80) { + if (pthis->work[CS_TIMER_2] == 80) { koumeAnim = 1; } - if (this->work[CS_TIMER_2] == 80) { + if (pthis->work[CS_TIMER_2] == 80) { msgId2 = 0x604B; sp35 = 50; } - if (this->work[CS_TIMER_2] == 140) { + if (pthis->work[CS_TIMER_2] == 140) { kotakeAnim = koumeAnim = 2; } - if (this->work[CS_TIMER_2] == 170) { + if (pthis->work[CS_TIMER_2] == 170) { kotakeAnim = 3; sKotakePtr->work[YAW_TGT] = -0x4000; sKotakePtr->rotateSpeed = 0.0f; @@ -2440,113 +2440,113 @@ void BossTw_DeathCSMsgSfx(BossTw* this, GlobalContext* globalCtx) { msgId2 = 0x604C; } - if (this->work[CS_TIMER_2] == 210) { + if (pthis->work[CS_TIMER_2] == 210) { D_8094C874 = 30; } - if (this->work[CS_TIMER_2] == 270) { + if (pthis->work[CS_TIMER_2] == 270) { koumeAnim = 3; sKoumePtr->work[YAW_TGT] = 0x4000; sKoumePtr->rotateSpeed = 0.0f; Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_SENSE); } - if (this->work[CS_TIMER_2] == 290) { + if (pthis->work[CS_TIMER_2] == 290) { msgId2 = 0x604D; sp35 = 35; } - if (this->work[CS_TIMER_2] == 350) { + if (pthis->work[CS_TIMER_2] == 350) { koumeAnim = kotakeAnim = 2; sKoumePtr->work[YAW_TGT] = sKotakePtr->work[YAW_TGT] = 0; sKoumePtr->rotateSpeed = sKotakePtr->rotateSpeed = 0.0f; } - if (this->work[CS_TIMER_2] == 380) { + if (pthis->work[CS_TIMER_2] == 380) { koumeAnim = kotakeAnim = 3; } - if (this->work[CS_TIMER_2] == 400) { + if (pthis->work[CS_TIMER_2] == 400) { koumeAnim = kotakeAnim = 2; } - if (this->work[CS_TIMER_2] == 430) { + if (pthis->work[CS_TIMER_2] == 430) { koumeAnim = 4; D_8094C874 = 435; D_8094C878 = 1; } - if (this->work[CS_TIMER_2] > 440 && this->work[CS_TIMER_2] < 860) { + if (pthis->work[CS_TIMER_2] > 440 && pthis->work[CS_TIMER_2] < 860) { func_80078884(NA_SE_EN_TWINROBA_FIGHT - SFX_FLAG); } - if (this->work[CS_TIMER_2] == 430) { + if (pthis->work[CS_TIMER_2] == 430) { msgId2 = 0x604E; } - if (this->work[CS_TIMER_2] == 480) { + if (pthis->work[CS_TIMER_2] == 480) { kotakeAnim = 4; sKotakePtr->work[YAW_TGT] = -0x4000; } - if (this->work[CS_TIMER_2] == 500) { + if (pthis->work[CS_TIMER_2] == 500) { koumeAnim = 2; } - if (this->work[CS_TIMER_2] == 480) { + if (pthis->work[CS_TIMER_2] == 480) { msgId1 = 0x604F; } - if (this->work[CS_TIMER_2] == 530) { + if (pthis->work[CS_TIMER_2] == 530) { koumeAnim = 4; sKoumePtr->work[YAW_TGT] = 0x4000; D_8094C87A = 335; D_8094C87E = 1; } - if (this->work[CS_TIMER_2] == 530) { + if (pthis->work[CS_TIMER_2] == 530) { msgId2 = 0x6050; } - if (this->work[CS_TIMER_2] == 580) { + if (pthis->work[CS_TIMER_2] == 580) { msgId1 = 0x6051; } - if (this->work[CS_TIMER_2] == 620) { + if (pthis->work[CS_TIMER_2] == 620) { msgId2 = 0x6052; } - if (this->work[CS_TIMER_2] == 660) { + if (pthis->work[CS_TIMER_2] == 660) { msgId1 = 0x6053; } - if (this->work[CS_TIMER_2] == 700) { + if (pthis->work[CS_TIMER_2] == 700) { msgId2 = 0x6054; } - if (this->work[CS_TIMER_2] == 740) { + if (pthis->work[CS_TIMER_2] == 740) { msgId1 = 0x6055; } - if (this->work[CS_TIMER_2] == 780) { + if (pthis->work[CS_TIMER_2] == 780) { msgId2 = 0x6056; } - if (this->work[CS_TIMER_2] == 820) { + if (pthis->work[CS_TIMER_2] == 820) { msgId1 = 0x6057; Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5000FF); } - if (this->work[CS_TIMER_2] == 860) { + if (pthis->work[CS_TIMER_2] == 860) { koumeAnim = kotakeAnim = 3; } - if (this->work[CS_TIMER_2] == 900) { + if (pthis->work[CS_TIMER_2] == 900) { Audio_PlayActorSound2(&sKoumePtr->actor, NA_SE_EN_TWINROBA_DIE); Audio_PlayActorSound2(&sKotakePtr->actor, NA_SE_EN_TWINROBA_DIE); } - if (this->work[CS_TIMER_2] == 930) { + if (pthis->work[CS_TIMER_2] == 930) { msgId2 = 0x6058; } @@ -2594,65 +2594,65 @@ void BossTw_DeathCSMsgSfx(BossTw* this, GlobalContext* globalCtx) { break; } - if (this->work[CS_TIMER_2] >= 120 && this->work[CS_TIMER_2] < 500) { - Math_ApproachF(&this->workf[UNK_F18], 255.0f, 0.1f, 5.0f); + if (pthis->work[CS_TIMER_2] >= 120 && pthis->work[CS_TIMER_2] < 500) { + Math_ApproachF(&pthis->workf[UNK_F18], 255.0f, 0.1f, 5.0f); } - if (this->work[CS_TIMER_2] >= 150) { - Math_ApproachF(&sKoumePtr->workf[UNK_F17], (Math_SinS(this->work[CS_TIMER_1] * 2000) * 0.05f) + 0.4f, 0.1f, + if (pthis->work[CS_TIMER_2] >= 150) { + Math_ApproachF(&sKoumePtr->workf[UNK_F17], (Math_SinS(pthis->work[CS_TIMER_1] * 2000) * 0.05f) + 0.4f, 0.1f, 0.01f); - Math_ApproachF(&sKotakePtr->workf[UNK_F17], (Math_CosS(this->work[CS_TIMER_1] * 1700) * 0.05f) + 0.4f, 0.1f, + Math_ApproachF(&sKotakePtr->workf[UNK_F17], (Math_CosS(pthis->work[CS_TIMER_1] * 1700) * 0.05f) + 0.4f, 0.1f, 0.01f); - if (this->work[CS_TIMER_2] >= 880) { - Math_ApproachF(&sKotakePtr->actor.world.pos.y, 2000.0f, 1.0f, this->actor.speedXZ); - Math_ApproachF(&sKoumePtr->actor.world.pos.y, 2000.0f, 1.0f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 0.25f); + if (pthis->work[CS_TIMER_2] >= 880) { + Math_ApproachF(&sKotakePtr->actor.world.pos.y, 2000.0f, 1.0f, pthis->actor.speedXZ); + Math_ApproachF(&sKoumePtr->actor.world.pos.y, 2000.0f, 1.0f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 10.0f, 1.0f, 0.25f); - if (this->work[CS_TIMER_2] >= 930) { - Math_ApproachF(&this->workf[UNK_F19], 5.0f, 1.0f, 0.05f); - Math_ApproachF(&this->workf[UNK_F18], 0.0f, 1.0f, 3.0f); + if (pthis->work[CS_TIMER_2] >= 930) { + Math_ApproachF(&pthis->workf[UNK_F19], 5.0f, 1.0f, 0.05f); + Math_ApproachF(&pthis->workf[UNK_F18], 0.0f, 1.0f, 3.0f); } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GOTO_HEAVEN - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GOTO_HEAVEN - SFX_FLAG); } else { - f32 yTarget = Math_CosS(this->work[CS_TIMER_2] * 1700) * 4.0f; - Math_ApproachF(&sKotakePtr->actor.world.pos.y, 20.0f + (263.0f + yTarget), 0.1f, this->actor.speedXZ); - yTarget = Math_SinS(this->work[CS_TIMER_2] * 1500) * 4.0f; - Math_ApproachF(&sKoumePtr->actor.world.pos.y, 20.0f + (263.0f + yTarget), 0.1f, this->actor.speedXZ); - Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.05f); + f32 yTarget = Math_CosS(pthis->work[CS_TIMER_2] * 1700) * 4.0f; + Math_ApproachF(&sKotakePtr->actor.world.pos.y, 20.0f + (263.0f + yTarget), 0.1f, pthis->actor.speedXZ); + yTarget = Math_SinS(pthis->work[CS_TIMER_2] * 1500) * 4.0f; + Math_ApproachF(&sKoumePtr->actor.world.pos.y, 20.0f + (263.0f + yTarget), 0.1f, pthis->actor.speedXZ); + Math_ApproachF(&pthis->actor.speedXZ, 1.0f, 1.0f, 0.05f); } } } -void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaDeathCS(BossTw* pthis, GlobalContext* globalCtx) { s16 i; Vec3f spD0; Player* player = GET_PLAYER(globalCtx); Camera* mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - SkelAnime_Update(&this->skelAnime); - this->work[UNK_S8] += 20; + SkelAnime_Update(&pthis->skelAnime); + pthis->work[UNK_S8] += 20; - if (this->work[UNK_S8] > 255) { - this->work[UNK_S8] = 255; + if (pthis->work[UNK_S8] > 255) { + pthis->work[UNK_S8] = 255; } - Math_ApproachF(&this->workf[UNK_F12], 0.0f, 1.0f, 0.05f); - this->unk_5F8 = 1; + Math_ApproachF(&pthis->workf[UNK_F12], 0.0f, 1.0f, 0.05f); + pthis->unk_5F8 = 1; - switch (this->csState1) { + switch (pthis->csState1) { case 0: - if (this->work[CS_TIMER_1] == 15) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_0216DC, -3.0f); + if (pthis->work[CS_TIMER_1] == 15) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_0216DC, -3.0f); } - if (this->work[CS_TIMER_1] >= 15) { - Math_ApproachF(&this->actor.world.pos.y, 400.0f, 0.05f, 10.0f); + if (pthis->work[CS_TIMER_1] >= 15) { + Math_ApproachF(&pthis->actor.world.pos.y, 400.0f, 0.05f, 10.0f); } - if (this->work[CS_TIMER_1] >= 55) { - if (this->work[CS_TIMER_1] == 55) { + if (pthis->work[CS_TIMER_1] >= 55) { + if (pthis->work[CS_TIMER_1] == 55) { globalCtx->envCtx.unk_D8 = 0; } @@ -2660,15 +2660,15 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { globalCtx->envCtx.unk_BE = 5; globalCtx->envCtx.unk_BD = 0; Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.015f); - Math_ApproachF(&this->actor.scale.x, 0.00024999998f, 0.1f, 0.00005f); - this->actor.shape.rot.y += (s16)this->actor.speedXZ; - this->workf[UNK_F13] += this->actor.speedXZ; - if (this->workf[UNK_F13] > 65536.0f) { - this->workf[UNK_F13] -= 65536.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_ROLL); + Math_ApproachF(&pthis->actor.scale.x, 0.00024999998f, 0.1f, 0.00005f); + pthis->actor.shape.rot.y += (s16)pthis->actor.speedXZ; + pthis->workf[UNK_F13] += pthis->actor.speedXZ; + if (pthis->workf[UNK_F13] > 65536.0f) { + pthis->workf[UNK_F13] -= 65536.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_ROLL); } - Math_ApproachF(&this->actor.speedXZ, 12288.0f, 1.0f, 256.0f); - if (this->work[CS_TIMER_1] == 135) { + Math_ApproachF(&pthis->actor.speedXZ, 12288.0f, 1.0f, 256.0f); + if (pthis->work[CS_TIMER_1] == 135) { Vec3f spBC; Vec3f spB0; Vec3f spA4 = { 0.0f, 0.0f, 0.0f }; @@ -2677,61 +2677,61 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { spB0.x = Rand_CenteredFloat(5.0f); spB0.y = Rand_CenteredFloat(5.0f); spB0.z = Rand_CenteredFloat(5.0f); - spBC = this->actor.world.pos; + spBC = pthis->actor.world.pos; spBC.x += spB0.x; spBC.y += spB0.y; spBC.z += spB0.z; BossTw_AddFlameEffect(globalCtx, &spBC, &spB0, &spA4, Rand_ZeroFloat(2.0f) + 5, Rand_ZeroFloat(1.99f)); } - this->csState1 = 1; - this->visible = false; - this->actor.scale.x = 0.0f; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, + pthis->csState1 = 1; + pthis->visible = false; + pthis->actor.scale.x = 0.0f; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, TW_DEATHBALL_KOUME); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, TW_DEATHBALL_KOTAKE); - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } } - Actor_SetScale(&this->actor, this->actor.scale.x); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); break; case 1: break; } - switch (this->csState2) { + switch (pthis->csState2) { case 0: - this->csState2 = 1; + pthis->csState2 = 1; func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->subCamId = Gameplay_CreateSubCamera(globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->subCamId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->subCamId, CAM_STAT_ACTIVE); - this->subCamEye = mainCam->eye; - this->subCamAt = mainCam->at; + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCamId, CAM_STAT_ACTIVE); + pthis->subCamEye = mainCam->eye; + pthis->subCamAt = mainCam->at; Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); break; case 1: - spD0.x = Math_SinS(this->actor.world.rot.y) * 200.0f; - spD0.z = Math_CosS(this->actor.world.rot.y) * 200.0f; - Math_ApproachF(&this->subCamEye.x, spD0.x + this->actor.world.pos.x, 0.1f, 50.0f); - Math_ApproachF(&this->subCamEye.y, 300.0f, 0.1f, 50.0f); - Math_ApproachF(&this->subCamEye.z, spD0.z + this->actor.world.pos.z, 0.1f, 50.0f); - Math_ApproachF(&this->subCamAt.x, this->actor.world.pos.x, 0.1f, 50.0f); - Math_ApproachF(&this->subCamAt.y, this->actor.world.pos.y, 0.1f, 50.0f); - Math_ApproachF(&this->subCamAt.z, this->actor.world.pos.z, 0.1f, 50.0f); - if (this->work[CS_TIMER_1] == 170) { - this->csState2 = 2; - this->work[CS_TIMER_2] = 0; - this->subCamEye.z = 170.0f; - this->subCamDist = 170.0f; - this->subCamEye.x = 0.0f; - this->subCamAt.x = 0.0f; - this->subCamAt.z = 0.0f; - this->subCamEye.y = 260.0f; + spD0.x = Math_SinS(pthis->actor.world.rot.y) * 200.0f; + spD0.z = Math_CosS(pthis->actor.world.rot.y) * 200.0f; + Math_ApproachF(&pthis->subCamEye.x, spD0.x + pthis->actor.world.pos.x, 0.1f, 50.0f); + Math_ApproachF(&pthis->subCamEye.y, 300.0f, 0.1f, 50.0f); + Math_ApproachF(&pthis->subCamEye.z, spD0.z + pthis->actor.world.pos.z, 0.1f, 50.0f); + Math_ApproachF(&pthis->subCamAt.x, pthis->actor.world.pos.x, 0.1f, 50.0f); + Math_ApproachF(&pthis->subCamAt.y, pthis->actor.world.pos.y, 0.1f, 50.0f); + Math_ApproachF(&pthis->subCamAt.z, pthis->actor.world.pos.z, 0.1f, 50.0f); + if (pthis->work[CS_TIMER_1] == 170) { + pthis->csState2 = 2; + pthis->work[CS_TIMER_2] = 0; + pthis->subCamEye.z = 170.0f; + pthis->subCamDist = 170.0f; + pthis->subCamEye.x = 0.0f; + pthis->subCamAt.x = 0.0f; + pthis->subCamAt.z = 0.0f; + pthis->subCamEye.y = 260.0f; player->actor.shape.rot.y = -0x8000; player->actor.world.pos.x = -40.0f; player->actor.world.pos.y = 240.0f; @@ -2740,7 +2740,7 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { sKotakePtr->actor.world.pos.x = 37.0f; sKotakePtr->actor.world.pos.y = 263.0f; sKoumePtr->actor.world.pos.y = sKotakePtr->actor.world.pos.y; - this->subCamAt.y = sKoumePtr->actor.world.pos.y + 17.0f; + pthis->subCamAt.y = sKoumePtr->actor.world.pos.y + 17.0f; sKotakePtr->actor.world.pos.z = 0.0f; sKoumePtr->actor.world.pos.z = sKotakePtr->actor.world.pos.z; sKoumePtr->work[YAW_TGT] = sKotakePtr->work[YAW_TGT] = sKoumePtr->actor.shape.rot.x = @@ -2750,7 +2750,7 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { } break; case 2: - if (this->work[CS_TIMER_2] == 100) { + if (pthis->work[CS_TIMER_2] == 100) { Vec3f pos; Vec3f velocity; Vec3f accel = { 0.0f, 0.0f, 0.0f }; @@ -2788,61 +2788,61 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { sKotakePtr->visible = 1; func_80078884(NA_SE_EN_TWINROBA_TRANSFORM); Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KOTAKE_KOUME); - this->csState2 = 3; - this->work[CS_TIMER_2] = 0; - this->subCamYaw = this->subCamYawStep = this->actor.speedXZ = this->subCamDistStep = 0.0f; + pthis->csState2 = 3; + pthis->work[CS_TIMER_2] = 0; + pthis->subCamYaw = pthis->subCamYawStep = pthis->actor.speedXZ = pthis->subCamDistStep = 0.0f; } break; case 3: - BossTw_DeathCSMsgSfx(this, globalCtx); - if (this->work[CS_TIMER_2] < 150) { + BossTw_DeathCSMsgSfx(pthis, globalCtx); + if (pthis->work[CS_TIMER_2] < 150) { globalCtx->envCtx.unk_BE = 1; globalCtx->envCtx.unk_BD = 0; Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.1f); } else { globalCtx->envCtx.unk_BE = 1; globalCtx->envCtx.unk_BD = 6; - Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_SinS(this->work[CS_TIMER_2] * 4096) / 4.0f) + 0.75f, + Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_SinS(pthis->work[CS_TIMER_2] * 4096) / 4.0f) + 0.75f, 1.0f, 0.1f); } - Math_ApproachF(&this->subCamAt.y, sKoumePtr->actor.world.pos.y + 17.0f, 0.05f, 10.0f); + Math_ApproachF(&pthis->subCamAt.y, sKoumePtr->actor.world.pos.y + 17.0f, 0.05f, 10.0f); - if (this->work[CS_TIMER_2] >= 50) { - Math_ApproachF(&this->subCamDist, 110.0f, 0.05f, this->subCamDistStep); - Math_ApproachF(&this->subCamDistStep, 1.0f, 1.0f, 0.025f); - this->subCamEye.x = this->subCamDist * sinf(this->subCamYaw); - this->subCamEye.z = this->subCamDist * cosf(this->subCamYaw); - if (this->work[CS_TIMER_2] >= 151) { - this->subCamYaw += this->subCamYawStep; - if (this->work[CS_TIMER_2] >= 800) { - Math_ApproachF(&this->subCamYawStep, 0.0f, 1.0f, 0.0001f); + if (pthis->work[CS_TIMER_2] >= 50) { + Math_ApproachF(&pthis->subCamDist, 110.0f, 0.05f, pthis->subCamDistStep); + Math_ApproachF(&pthis->subCamDistStep, 1.0f, 1.0f, 0.025f); + pthis->subCamEye.x = pthis->subCamDist * sinf(pthis->subCamYaw); + pthis->subCamEye.z = pthis->subCamDist * cosf(pthis->subCamYaw); + if (pthis->work[CS_TIMER_2] >= 151) { + pthis->subCamYaw += pthis->subCamYawStep; + if (pthis->work[CS_TIMER_2] >= 800) { + Math_ApproachF(&pthis->subCamYawStep, 0.0f, 1.0f, 0.0001f); } else { - Math_ApproachF(&this->subCamYawStep, 0.015f, 1.0f, 0.0001f); + Math_ApproachF(&pthis->subCamYawStep, 0.015f, 1.0f, 0.0001f); } } } Math_ApproachF(&sKoumePtr->actor.scale.x, 0.009999999f, 0.1f, 0.001f); Actor_SetScale(&sKoumePtr->actor, sKoumePtr->actor.scale.x); Actor_SetScale(&sKotakePtr->actor, sKoumePtr->actor.scale.x); - if (this->work[CS_TIMER_2] >= 1020) { + if (pthis->work[CS_TIMER_2] >= 1020) { mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); - mainCam->eye = this->subCamEye; - mainCam->eyeNext = this->subCamEye; - mainCam->at = this->subCamAt; - func_800C08AC(globalCtx, this->subCamId, 0); - this->csState2 = 4; - this->subCamId = 0; + mainCam->eye = pthis->subCamEye; + mainCam->eyeNext = pthis->subCamEye; + mainCam->at = pthis->subCamAt; + func_800C08AC(globalCtx, pthis->subCamId, 0); + pthis->csState2 = 4; + pthis->subCamId = 0; func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 600.0f, 230.0f, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, 600.0f, 230.0f, 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -600.0f, 230.f, 0.0f, 0, 0, 0, 0); - this->actor.world.pos.y = -2000.0f; - this->workf[UNK_F18] = 0.0f; + pthis->actor.world.pos.y = -2000.0f; + pthis->workf[UNK_F18] = 0.0f; sKoumePtr->visible = sKotakePtr->visible = false; - if (&this->subCamEye) {} // fixes regalloc, may be fake + if (&pthis->subCamEye) {} // fixes regalloc, may be fake Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); } break; @@ -2851,9 +2851,9 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { break; } - if (this->subCamId) { + if (pthis->subCamId) { if (1) {} - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->subCamAt, &pthis->subCamEye); } } @@ -2866,103 +2866,103 @@ static s16 D_8094A90C[] = { }; void BossTw_Update(Actor* thisx, GlobalContext* globalCtx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; Player* player = GET_PLAYER(globalCtx); s16 i; s32 pad; - this->collider.base.colType = COLTYPE_HIT3; - Math_ApproachF(&this->fogR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->fogG, globalCtx->lightCtx.fogColor[1], 1.0f, 10.0f); - Math_ApproachF(&this->fogB, globalCtx->lightCtx.fogColor[2], 1.0f, 10.0f); - Math_ApproachF(&this->fogNear, globalCtx->lightCtx.fogNear, 1.0f, 10.0f); - Math_ApproachF(&this->fogFar, 1000.0f, 1.0f, 10.0f); - this->work[CS_TIMER_1]++; - this->work[CS_TIMER_2]++; - this->work[TAIL_IDX]++; + pthis->collider.base.colType = COLTYPE_HIT3; + Math_ApproachF(&pthis->fogR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->fogG, globalCtx->lightCtx.fogColor[1], 1.0f, 10.0f); + Math_ApproachF(&pthis->fogB, globalCtx->lightCtx.fogColor[2], 1.0f, 10.0f); + Math_ApproachF(&pthis->fogNear, globalCtx->lightCtx.fogNear, 1.0f, 10.0f); + Math_ApproachF(&pthis->fogFar, 1000.0f, 1.0f, 10.0f); + pthis->work[CS_TIMER_1]++; + pthis->work[CS_TIMER_2]++; + pthis->work[TAIL_IDX]++; - if (this->work[TAIL_IDX] >= ARRAY_COUNT(this->blastTailPos)) { - this->work[TAIL_IDX] = 0; + if (pthis->work[TAIL_IDX] >= ARRAY_COUNT(pthis->blastTailPos)) { + pthis->work[TAIL_IDX] = 0; } - this->blastTailPos[this->work[TAIL_IDX]] = this->actor.world.pos; + pthis->blastTailPos[pthis->work[TAIL_IDX]] = pthis->actor.world.pos; if (1) {} if (1) {} for (i = 0; i < 5; i++) { - if (this->timers[i] != 0) { - this->timers[i]--; + if (pthis->timers[i] != 0) { + pthis->timers[i]--; } } - if (this->work[INVINC_TIMER] != 0) { - this->work[INVINC_TIMER]--; + if (pthis->work[INVINC_TIMER] != 0) { + pthis->work[INVINC_TIMER]--; } - if (this->work[FOG_TIMER] != 0) { - this->work[FOG_TIMER]--; + if (pthis->work[FOG_TIMER] != 0) { + pthis->work[FOG_TIMER]--; } - if (this->actionFunc == BossTw_FlyTo || this->actionFunc == BossTw_Spin || - this->actionFunc == BossTw_TurnToPlayer) { - if ((s16)(player->actor.shape.rot.y - this->actor.yawTowardsPlayer + 0x8000) < 0x1000 && - (s16)(player->actor.shape.rot.y - this->actor.yawTowardsPlayer + 0x8000) > -0x1000 && player->unk_A73) { - BossTw_SetupSpin(this, globalCtx); + if (pthis->actionFunc == BossTw_FlyTo || pthis->actionFunc == BossTw_Spin || + pthis->actionFunc == BossTw_TurnToPlayer) { + if ((s16)(player->actor.shape.rot.y - pthis->actor.yawTowardsPlayer + 0x8000) < 0x1000 && + (s16)(player->actor.shape.rot.y - pthis->actor.yawTowardsPlayer + 0x8000) > -0x1000 && player->unk_A73) { + BossTw_SetupSpin(pthis, globalCtx); } } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->actionFunc != BossTw_Wait) { - this->collider.dim.radius = 45; + if (pthis->actionFunc != BossTw_Wait) { + pthis->collider.dim.radius = 45; - if (this->actionFunc == BossTw_Spin) { - this->collider.dim.radius *= 2; + if (pthis->actionFunc == BossTw_Spin) { + pthis->collider.dim.radius *= 2; } - this->collider.dim.height = 120; - this->collider.dim.yShift = -30; + pthis->collider.dim.height = 120; + pthis->collider.dim.yShift = -30; - if (this->work[INVINC_TIMER] == 0) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; + if (pthis->work[INVINC_TIMER] == 0) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - if (this->actor.params == 0) { - this->workf[OUTR_CRWN_TX_X2] += 1.0f; - this->workf[OUTR_CRWN_TX_Y2] -= 7.0f; - this->workf[INNR_CRWN_TX_Y1] += 1.0f; + if (pthis->actor.params == 0) { + pthis->workf[OUTR_CRWN_TX_X2] += 1.0f; + pthis->workf[OUTR_CRWN_TX_Y2] -= 7.0f; + pthis->workf[INNR_CRWN_TX_Y1] += 1.0f; } else { - this->workf[OUTR_CRWN_TX_X2] += 0.0f; - this->workf[INNR_CRWN_TX_X2] += 0.0f; - this->workf[OUTR_CRWN_TX_Y2] += -15.0f; - this->workf[INNR_CRWN_TX_Y2] += -10.0f; + pthis->workf[OUTR_CRWN_TX_X2] += 0.0f; + pthis->workf[INNR_CRWN_TX_X2] += 0.0f; + pthis->workf[OUTR_CRWN_TX_Y2] += -15.0f; + pthis->workf[INNR_CRWN_TX_Y2] += -10.0f; } - if (((this->work[CS_TIMER_2] % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { - this->work[BLINK_IDX] = 4; + if (((pthis->work[CS_TIMER_2] % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { + pthis->work[BLINK_IDX] = 4; } - this->eyeTexIdx = D_8094A900[this->work[BLINK_IDX]]; + pthis->eyeTexIdx = D_8094A900[pthis->work[BLINK_IDX]]; - if (this->work[BLINK_IDX] != 0) { - this->work[BLINK_IDX]--; + if (pthis->work[BLINK_IDX] != 0) { + pthis->work[BLINK_IDX]--; } - if (this->actionFunc != BossTw_MergeCS && this->unk_5F8 != 0) { + if (pthis->actionFunc != BossTw_MergeCS && pthis->unk_5F8 != 0) { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.0f, 0.0f }; - if (this->scepterAlpha > 0.0f) { + if (pthis->scepterAlpha > 0.0f) { for (i = 0; i <= 0; i++) { - pos = this->scepterFlamePos[0]; + pos = pthis->scepterFlamePos[0]; pos.x += Rand_CenteredFloat(70.0f); pos.y += Rand_CenteredFloat(70.0f); pos.z += Rand_CenteredFloat(70.0f); @@ -2970,12 +2970,12 @@ void BossTw_Update(Actor* thisx, GlobalContext* globalCtx) { accel.x = Rand_CenteredFloat(0.5f); accel.z = Rand_CenteredFloat(0.5f); BossTw_AddDotEffect(globalCtx, &pos, &velocity, &accel, (s16)Rand_ZeroFloat(2.0f) + 8, - this->actor.params, 37); + pthis->actor.params, 37); } } for (i = 0; i <= 0; i++) { - pos = this->crownPos; + pos = pthis->crownPos; pos.x += Rand_CenteredFloat(70.0f); pos.y += Rand_CenteredFloat(70.0f); pos.z += Rand_CenteredFloat(70.0f); @@ -2983,7 +2983,7 @@ void BossTw_Update(Actor* thisx, GlobalContext* globalCtx) { accel.x = Rand_CenteredFloat(0.5f); accel.z = Rand_CenteredFloat(0.5f); BossTw_AddDotEffect(globalCtx, &pos, &velocity, &accel, (s16)Rand_ZeroFloat(2.0f) + 8, - this->actor.params, 37); + pthis->actor.params, 37); } } } @@ -2992,92 +2992,92 @@ void BossTw_Update(Actor* thisx, GlobalContext* globalCtx) { void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { s16 i; GlobalContext* globalCtx = globalCtx2; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; Player* player = GET_PLAYER(globalCtx); - this->actor.flags &= ~ACTOR_FLAG_10; - this->unk_5F8 = 0; - this->collider.base.colType = COLTYPE_HIT3; + pthis->actor.flags &= ~ACTOR_FLAG_10; + pthis->unk_5F8 = 0; + pthis->collider.base.colType = COLTYPE_HIT3; - Math_ApproachF(&this->fogR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->fogG, globalCtx->lightCtx.fogColor[1], 1.0f, 10.0f); - Math_ApproachF(&this->fogB, globalCtx->lightCtx.fogColor[2], 1.0f, 10.0f); - Math_ApproachF(&this->fogNear, globalCtx->lightCtx.fogNear, 1.0f, 10.0f); - Math_ApproachF(&this->fogFar, 1000.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->fogR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->fogG, globalCtx->lightCtx.fogColor[1], 1.0f, 10.0f); + Math_ApproachF(&pthis->fogB, globalCtx->lightCtx.fogColor[2], 1.0f, 10.0f); + Math_ApproachF(&pthis->fogNear, globalCtx->lightCtx.fogNear, 1.0f, 10.0f); + Math_ApproachF(&pthis->fogFar, 1000.0f, 1.0f, 10.0f); - this->work[CS_TIMER_1]++; - this->work[CS_TIMER_2]++; + pthis->work[CS_TIMER_1]++; + pthis->work[CS_TIMER_2]++; for (i = 0; i < 5; i++) { - if (this->timers[i] != 0) { - this->timers[i]--; + if (pthis->timers[i] != 0) { + pthis->timers[i]--; } } - if (this->work[INVINC_TIMER] != 0) { - this->work[INVINC_TIMER]--; + if (pthis->work[INVINC_TIMER] != 0) { + pthis->work[INVINC_TIMER]--; } - if (this->work[FOG_TIMER] != 0) { - this->work[FOG_TIMER]--; + if (pthis->work[FOG_TIMER] != 0) { + pthis->work[FOG_TIMER]--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->actionFunc != BossTw_TwinrovaShootBlast && this->actionFunc != BossTw_TwinrovaChargeBlast && - this->visible && this->unk_5F8 == 0 && - (s16)(player->actor.shape.rot.y - this->actor.yawTowardsPlayer + 0x8000) < 0x1000 && - (s16)(player->actor.shape.rot.y - this->actor.yawTowardsPlayer + 0x8000) > -0x1000 && player->unk_A73 != 0) { - BossTw_TwinrovaSetupSpin(this, globalCtx); + if (pthis->actionFunc != BossTw_TwinrovaShootBlast && pthis->actionFunc != BossTw_TwinrovaChargeBlast && + pthis->visible && pthis->unk_5F8 == 0 && + (s16)(player->actor.shape.rot.y - pthis->actor.yawTowardsPlayer + 0x8000) < 0x1000 && + (s16)(player->actor.shape.rot.y - pthis->actor.yawTowardsPlayer + 0x8000) > -0x1000 && player->unk_A73 != 0) { + BossTw_TwinrovaSetupSpin(pthis, globalCtx); } - this->eyeTexIdx = D_8094A900[this->work[BLINK_IDX]]; - if (this->work[BLINK_IDX] != 0) { - this->work[BLINK_IDX]--; + pthis->eyeTexIdx = D_8094A900[pthis->work[BLINK_IDX]]; + if (pthis->work[BLINK_IDX] != 0) { + pthis->work[BLINK_IDX]--; } - if ((this->work[CS_TIMER_2] % 32) == 0) { - if (this->actionFunc != BossTw_TwinrovaMergeCS) { + if ((pthis->work[CS_TIMER_2] % 32) == 0) { + if (pthis->actionFunc != BossTw_TwinrovaMergeCS) { if (Rand_ZeroOne() < 0.3f) { - this->work[BLINK_IDX] = 4; + pthis->work[BLINK_IDX] = 4; } } } - if (this->actionFunc == BossTw_TwinrovaMergeCS) { - this->leftEyeTexIdx = D_8094A90C[this->work[TW_BLINK_IDX]]; - if (this->work[TW_BLINK_IDX] != 0) { - this->work[TW_BLINK_IDX]--; + if (pthis->actionFunc == BossTw_TwinrovaMergeCS) { + pthis->leftEyeTexIdx = D_8094A90C[pthis->work[TW_BLINK_IDX]]; + if (pthis->work[TW_BLINK_IDX] != 0) { + pthis->work[TW_BLINK_IDX]--; } } else { - if (this->actionFunc == BossTw_TwinrovaStun) { - this->eyeTexIdx = 1; + if (pthis->actionFunc == BossTw_TwinrovaStun) { + pthis->eyeTexIdx = 1; } - if (this->actionFunc == BossTw_TwinrovaDeathCS) { - this->eyeTexIdx = 2; + if (pthis->actionFunc == BossTw_TwinrovaDeathCS) { + pthis->eyeTexIdx = 2; } - this->leftEyeTexIdx = this->eyeTexIdx; + pthis->leftEyeTexIdx = pthis->eyeTexIdx; } - if (this->visible && this->unk_5F8 == 0) { + if (pthis->visible && pthis->unk_5F8 == 0) { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel; - if (this->work[UNK_S8] != 0) { - this->work[UNK_S8] -= 20; - if (this->work[UNK_S8] < 0) { - this->work[UNK_S8] = 0; + if (pthis->work[UNK_S8] != 0) { + pthis->work[UNK_S8] -= 20; + if (pthis->work[UNK_S8] < 0) { + pthis->work[UNK_S8] = 0; } } - Math_ApproachF(&this->workf[UNK_F12], 1.0f, 1.0f, 0.05f); + Math_ApproachF(&pthis->workf[UNK_F12], 1.0f, 1.0f, 0.05f); accel.y = 0.4f; for (i = 0; i < 2; i++) { - pos = this->leftScepterPos; + pos = pthis->leftScepterPos; pos.x += Rand_CenteredFloat(30.0f); pos.y += Rand_CenteredFloat(30.0f); pos.z += Rand_CenteredFloat(30.0f); @@ -3087,7 +3087,7 @@ void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { } for (i = 0; i < 2; i++) { - pos = this->rightScepterPos; + pos = pthis->rightScepterPos; pos.x += Rand_CenteredFloat(30.0f); pos.y += Rand_CenteredFloat(30.0f); pos.z += Rand_CenteredFloat(30.0f); @@ -3097,35 +3097,35 @@ void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { } } - this->collider.dim.radius = 35; + pthis->collider.dim.radius = 35; - if (this->actionFunc == BossTw_TwinrovaSpin) { - this->collider.dim.radius *= 2; + if (pthis->actionFunc == BossTw_TwinrovaSpin) { + pthis->collider.dim.radius *= 2; } - this->collider.dim.height = 150; - this->collider.dim.yShift = -60; - Collider_UpdateCylinder(&this->actor, &this->collider); + pthis->collider.dim.height = 150; + pthis->collider.dim.yShift = -60; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); - if (this->work[INVINC_TIMER] == 0) { - if (this->actionFunc != BossTw_TwinrovaStun) { - if (this->twinrovaStun != 0) { - this->twinrovaStun = 0; - this->work[FOG_TIMER] = 10; - BossTw_TwinrovaDamage(this, globalCtx, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_YOUNG_DAMAGE); - } else if (this->collider.base.acFlags & AC_HIT) { - ColliderInfo* info = this->collider.info.acHitInfo; + if (pthis->work[INVINC_TIMER] == 0) { + if (pthis->actionFunc != BossTw_TwinrovaStun) { + if (pthis->twinrovaStun != 0) { + pthis->twinrovaStun = 0; + pthis->work[FOG_TIMER] = 10; + BossTw_TwinrovaDamage(pthis, globalCtx, 0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_YOUNG_DAMAGE); + } else if (pthis->collider.base.acFlags & AC_HIT) { + ColliderInfo* info = pthis->collider.info.acHitInfo; - this->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.acFlags &= ~AC_HIT; if (info->toucher.dmgFlags & (DMG_SLINGSHOT | DMG_ARROW)) {} } - } else if (this->collider.base.acFlags & AC_HIT) { + } else if (pthis->collider.base.acFlags & AC_HIT) { u8 damage; u8 swordDamage; - ColliderInfo* info = this->collider.info.acHitInfo; + ColliderInfo* info = pthis->collider.info.acHitInfo; - this->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.acFlags &= ~AC_HIT; swordDamage = false; damage = CollisionCheck_GetSwordDamage(info->toucher.dmgFlags); @@ -3136,18 +3136,18 @@ void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { } if (!(info->toucher.dmgFlags & DMG_HOOKSHOT)) { - if (((s8)this->actor.colChkInfo.health < 3) && !swordDamage) { + if (((s8)pthis->actor.colChkInfo.health < 3) && !swordDamage) { damage = 0; } - BossTw_TwinrovaDamage(this, globalCtx, damage); + BossTw_TwinrovaDamage(pthis, globalCtx, damage); } } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); osSyncPrintf("OooooooooooooooooooooooooooooooooCC\n"); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); globalCtx->envCtx.unk_DC = 2; @@ -3161,7 +3161,7 @@ void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { break; case 2: globalCtx->envCtx.unk_BD = 2; - Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_SinS(this->work[CS_TIMER_1] * 0x3000) * 0.03f) + 0.5f, 1.0f, + Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_SinS(pthis->work[CS_TIMER_1] * 0x3000) * 0.03f) + 0.5f, 1.0f, 0.05f); break; case 3: @@ -3170,7 +3170,7 @@ void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { break; case 4: globalCtx->envCtx.unk_BD = 2; - Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_SinS(this->work[CS_TIMER_1] * 0x3E00) * 0.05f) + 0.95f, + Math_ApproachF(&globalCtx->envCtx.unk_D8, (Math_SinS(pthis->work[CS_TIMER_1] * 0x3E00) * 0.05f) + 0.95f, 1.0f, 0.1f); break; case 5: @@ -3200,11 +3200,11 @@ void BossTw_TwinrovaUpdate(Actor* thisx, GlobalContext* globalCtx2) { } s32 BossTw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; if (limbIndex == 21) { - if (this->unk_5F8 == 0) { - if (this->actor.params == 0) { + if (pthis->unk_5F8 == 0) { + if (pthis->actor.params == 0) { *dList = object_tw_DL_012CE0; } else { *dList = object_tw_DL_0134B8; @@ -3213,10 +3213,10 @@ s32 BossTw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 14) { - if (this->actionFunc == BossTw_DeathCS) { + if (pthis->actionFunc == BossTw_DeathCS) { *dList = NULL; - } else if (this->scepterAlpha == 0.0f) { - if (this->actor.params == 0) { + } else if (pthis->scepterAlpha == 0.0f) { + if (pthis->actor.params == 0) { *dList = object_tw_DL_012B38; } else { *dList = object_tw_DL_013310; @@ -3234,19 +3234,19 @@ void BossTw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V { 0.0f, 0.0f, -10000.0f }, { 0.0f, 0.0f, -8000.0f }, { 0.0f, 0.0f, -9000.0f }, { 0.0f, 0.0f, -11000.0f }, { 0.0f, 0.0f, -12000.0f }, }; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6168); switch (limbIndex) { case 21: - Matrix_MultVec3f(&D_8094A944, &this->actor.focus.pos); - Matrix_MultVec3f(&D_8094A950, &this->crownPos); + Matrix_MultVec3f(&D_8094A944, &pthis->actor.focus.pos); + Matrix_MultVec3f(&D_8094A950, &pthis->crownPos); - if (this->unk_5F8 != 0) { + if (pthis->unk_5F8 != 0) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6190), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - if (this->actor.params == 0) { + if (pthis->actor.params == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_013AE8)); } else { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_013D68)); @@ -3254,24 +3254,24 @@ void BossTw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } break; case 14: - Matrix_MultVec3f(&D_8094A95C[0], &this->scepterFlamePos[0]); - Matrix_MultVec3f(&D_8094A95C[1], &this->scepterFlamePos[1]); - Matrix_MultVec3f(&D_8094A95C[2], &this->scepterFlamePos[2]); - Matrix_MultVec3f(&D_8094A95C[3], &this->scepterFlamePos[3]); - Matrix_MultVec3f(&D_8094A95C[4], &this->scepterFlamePos[4]); + Matrix_MultVec3f(&D_8094A95C[0], &pthis->scepterFlamePos[0]); + Matrix_MultVec3f(&D_8094A95C[1], &pthis->scepterFlamePos[1]); + Matrix_MultVec3f(&D_8094A95C[2], &pthis->scepterFlamePos[2]); + Matrix_MultVec3f(&D_8094A95C[3], &pthis->scepterFlamePos[3]); + Matrix_MultVec3f(&D_8094A95C[4], &pthis->scepterFlamePos[4]); - if (this->scepterAlpha > 0.0f) { + if (pthis->scepterAlpha > 0.0f) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6221), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - if (this->actor.params == 0) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 225, 255, (s16)this->scepterAlpha); + if (pthis->actor.params == 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 225, 255, (s16)pthis->scepterAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_013E98)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s16)this->scepterAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s16)pthis->scepterAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_013F98)); } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 20, 0, (s16)this->scepterAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 20, 0, (s16)pthis->scepterAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_014070)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 70, 0, (s16)this->scepterAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 70, 0, (s16)pthis->scepterAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_014158)); } } @@ -3281,27 +3281,27 @@ void BossTw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6236); } -void func_80941BC0(BossTw* this, GlobalContext* globalCtx) { +void func_80941BC0(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6341); Matrix_Push(); func_80093D84(globalCtx->state.gfxCtx); - Matrix_Translate(this->groundBlastPos2.x, this->groundBlastPos2.y, this->groundBlastPos2.z, MTXMODE_NEW); - Matrix_Scale(this->workf[UNK_F12], this->workf[UNK_F12], this->workf[UNK_F12], MTXMODE_APPLY); + Matrix_Translate(pthis->groundBlastPos2.x, pthis->groundBlastPos2.y, pthis->groundBlastPos2.z, MTXMODE_NEW); + Matrix_Scale(pthis->workf[UNK_F12], pthis->workf[UNK_F12], pthis->workf[UNK_F12], MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6358), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)this->workf[UNK_F11]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)pthis->workf[UNK_F11]); gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01BC00)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s16)this->workf[UNK_F11] * this->workf[UNK_F14]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s16)pthis->workf[UNK_F11] * pthis->workf[UNK_F14]); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, (u32)this->workf[UNK_F16] & 0x3F, - (this->work[CS_TIMER_2] * 4) & 0x3F, 0x10, 0x10)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, (u32)pthis->workf[UNK_F16] & 0x3F, + (pthis->work[CS_TIMER_2] * 4) & 0x3F, 0x10, 0x10)); Matrix_Push(); - Matrix_RotateY(this->workf[UNK_F15], MTXMODE_APPLY); + Matrix_RotateY(pthis->workf[UNK_F15], MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6423), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01C1C0)); @@ -3309,10 +3309,10 @@ void func_80941BC0(BossTw* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6427), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPSegment(POLY_XLU_DISP++, 0xD, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->work[CS_TIMER_2] & 0x7F, - (this->work[CS_TIMER_2] * 8) & 0xFF, 0x20, 0x40, 1, - (-this->work[CS_TIMER_2] * 2) & 0x3F, 0, 0x10, 0x10)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s16)this->workf[UNK_F9]); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->work[CS_TIMER_2] & 0x7F, + (pthis->work[CS_TIMER_2] * 8) & 0xFF, 0x20, 0x40, 1, + (-pthis->work[CS_TIMER_2] * 2) & 0x3F, 0, 0x10, 0x10)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s16)pthis->workf[UNK_F9]); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); gDPSetRenderMode(POLY_XLU_DISP++, Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_DEC | FORCE_BL | @@ -3325,7 +3325,7 @@ void func_80941BC0(BossTw* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6461); } -void func_80942180(BossTw* this, GlobalContext* globalCtx) { +void func_80942180(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6468); @@ -3333,14 +3333,14 @@ void func_80942180(BossTw* this, GlobalContext* globalCtx) { Matrix_Push(); func_80093D84(globalCtx->state.gfxCtx); - Matrix_Translate(this->groundBlastPos2.x, this->groundBlastPos2.y, this->groundBlastPos2.z, MTXMODE_NEW); - Matrix_Scale(this->workf[KM_GD_CRTR_SCL], this->workf[KM_GD_CRTR_SCL], this->workf[KM_GD_CRTR_SCL], MTXMODE_APPLY); + Matrix_Translate(pthis->groundBlastPos2.x, pthis->groundBlastPos2.y, pthis->groundBlastPos2.z, MTXMODE_NEW); + Matrix_Scale(pthis->workf[KM_GD_CRTR_SCL], pthis->workf[KM_GD_CRTR_SCL], pthis->workf[KM_GD_CRTR_SCL], MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-this->work[CS_TIMER_1]) & 0x7F, 0, 0x20, 0x20, 1, - (this->work[CS_TIMER_1] * 2) & 0x7F, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-pthis->work[CS_TIMER_1]) & 0x7F, 0, 0x20, 0x20, 1, + (pthis->work[CS_TIMER_1] * 2) & 0x7F, 0, 0x20, 0x20)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6497), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 00, (s16)this->workf[KM_GRND_CRTR_A]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 00, (s16)pthis->workf[KM_GRND_CRTR_A]); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_019D40)); @@ -3349,21 +3349,21 @@ void func_80942180(BossTw* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6514), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->work[CS_TIMER_1] & 0x7F, - (-this->work[CS_TIMER_1] * 6) & 0xFF, 0x20, 0x40, 1, - (this->work[CS_TIMER_1] * 2) & 0x7F, (-this->work[CS_TIMER_1] * 6) & 0xFF, 0x20, 0x40)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s16)this->workf[KM_GD_SMOKE_A]); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->work[CS_TIMER_1] & 0x7F, + (-pthis->work[CS_TIMER_1] * 6) & 0xFF, 0x20, 0x40, 1, + (pthis->work[CS_TIMER_1] * 2) & 0x7F, (-pthis->work[CS_TIMER_1] * 6) & 0xFF, 0x20, 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s16)pthis->workf[KM_GD_SMOKE_A]); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 100); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_018FC0)); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-this->work[CS_TIMER_1] * 3) & 0x7F, 0, 0x20, 0x20, 1, 0, - (-this->work[CS_TIMER_1] * 10) & 0xFF, 0x20, 0x40)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 50, 0, (s16)(this->workf[KM_GD_FLM_A] * 0.7f)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-pthis->work[CS_TIMER_1] * 3) & 0x7F, 0, 0x20, 0x20, 1, 0, + (-pthis->work[CS_TIMER_1] * 10) & 0xFF, 0x20, 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 50, 0, (s16)(pthis->workf[KM_GD_FLM_A] * 0.7f)); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 240, 128); - Matrix_Scale(this->workf[KM_GD_FLM_SCL], this->workf[KM_GD_FLM_SCL], this->workf[KM_GD_FLM_SCL], MTXMODE_APPLY); + Matrix_Scale(pthis->workf[KM_GD_FLM_SCL], pthis->workf[KM_GD_FLM_SCL], pthis->workf[KM_GD_FLM_SCL], MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6575), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_019938)); @@ -3373,49 +3373,49 @@ void func_80942180(BossTw* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6579); } -void func_809426F0(BossTw* this, GlobalContext* globalCtx) { +void func_809426F0(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6587); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (u8)(-this->work[CS_TIMER_2] * 15), 0x20, 0x40, 1, 0, 0, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (u8)(-pthis->work[CS_TIMER_2] * 15), 0x20, 0x40, 1, 0, 0, 0x40, 0x40)); Matrix_Push(); Matrix_Translate(0.0f, 0.0f, 5000.0f, MTXMODE_APPLY); - Matrix_Scale(this->spawnPortalScale / 2000.0f, this->spawnPortalScale / 2000.0f, this->spawnPortalScale / 2000.0f, + Matrix_Scale(pthis->spawnPortalScale / 2000.0f, pthis->spawnPortalScale / 2000.0f, pthis->spawnPortalScale / 2000.0f, MTXMODE_APPLY); - Matrix_RotateZ(this->portalRotation, MTXMODE_APPLY); + Matrix_RotateZ(pthis->portalRotation, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6614), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - if (this->actor.params == 0) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 135, 175, 165, (s16)this->spawnPortalAlpha); + if (pthis->actor.params == 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 135, 175, 165, (s16)pthis->spawnPortalAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01CEE0)); } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (s16)this->spawnPortalAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (s16)pthis->spawnPortalAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01DBE8)); } Matrix_Pop(); - if (this->actor.params == 0) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s16)this->flameAlpha); + if (pthis->actor.params == 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s16)pthis->flameAlpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s16)this->flameAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s16)pthis->flameAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); } for (i = 0; i < 8; i++) { Matrix_Push(); Matrix_Translate(0.0f, 0.0f, 5000.0f, MTXMODE_APPLY); - Matrix_RotateZ(((i * M_PI) * 2.0f * 0.125f) + this->flameRotation, MTXMODE_APPLY); - Matrix_Translate(0.0f, this->spawnPortalScale * 1.5f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZ(((i * M_PI) * 2.0f * 0.125f) + pthis->flameRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, pthis->spawnPortalScale * 1.5f, 0.0f, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, ((this->work[CS_TIMER_2] * 3) + (i * 10)) & 0x7F, - (u8)((-this->work[CS_TIMER_2] * 15) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, ((pthis->work[CS_TIMER_2] * 3) + (i * 10)) & 0x7F, + (u8)((-pthis->work[CS_TIMER_2] * 15) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); Matrix_Scale(0.4f, 0.4f, 0.4f, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6751), @@ -3428,18 +3428,18 @@ void func_809426F0(BossTw* this, GlobalContext* globalCtx) { } void func_80942C70(Actor* thisx, GlobalContext* globalCtx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; s16 alpha; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6765); - if (this->beamDist != 0.0f) { + if (pthis->beamDist != 0.0f) { Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0xC, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (u8)(this->work[CS_TIMER_1] * -0xF), 0x20, 0x40)); - alpha = this->beamScale * 100.0f * 255.0f; + Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (u8)(pthis->work[CS_TIMER_1] * -0xF), 0x20, 0x40)); + alpha = pthis->beamScale * 100.0f * 255.0f; - if (this->actor.params == 1) { + if (pthis->actor.params == 1) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 60, alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } else { @@ -3447,22 +3447,22 @@ void func_80942C70(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 100, 100, 255, 128); } - Matrix_Translate(this->beamOrigin.x, this->beamOrigin.y, this->beamOrigin.z, MTXMODE_NEW); - Matrix_RotateY(this->beamYaw, MTXMODE_APPLY); - Matrix_RotateX(this->beamPitch, MTXMODE_APPLY); - Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY); - Matrix_Scale(this->beamScale, this->beamScale, (this->beamDist * 0.01f * 98.0f) / 20000.0f, MTXMODE_APPLY); + Matrix_Translate(pthis->beamOrigin.x, pthis->beamOrigin.y, pthis->beamOrigin.z, MTXMODE_NEW); + Matrix_RotateY(pthis->beamYaw, MTXMODE_APPLY); + Matrix_RotateX(pthis->beamPitch, MTXMODE_APPLY); + Matrix_RotateZ(pthis->beamRoll, MTXMODE_APPLY); + Matrix_Scale(pthis->beamScale, pthis->beamScale, (pthis->beamDist * 0.01f * 98.0f) / 20000.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6846), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01DDF0)); - if (this->beamReflectionDist > 10.0f) { - Matrix_Translate(this->beamReflectionOrigin.x, this->beamReflectionOrigin.y, this->beamReflectionOrigin.z, + if (pthis->beamReflectionDist > 10.0f) { + Matrix_Translate(pthis->beamReflectionOrigin.x, pthis->beamReflectionOrigin.y, pthis->beamReflectionOrigin.z, MTXMODE_NEW); - Matrix_RotateY(this->beamReflectionYaw, MTXMODE_APPLY); - Matrix_RotateX(this->beamReflectionPitch, MTXMODE_APPLY); - Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY); - Matrix_Scale(this->beamScale, this->beamScale, (this->beamReflectionDist * 0.01f * 100.0f) / 20000.0f, + Matrix_RotateY(pthis->beamReflectionYaw, MTXMODE_APPLY); + Matrix_RotateX(pthis->beamReflectionPitch, MTXMODE_APPLY); + Matrix_RotateZ(pthis->beamRoll, MTXMODE_APPLY); + Matrix_Scale(pthis->beamScale, pthis->beamScale, (pthis->beamReflectionDist * 0.01f * 100.0f) / 20000.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6870), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); @@ -3476,21 +3476,21 @@ void func_80942C70(Actor* thisx, GlobalContext* globalCtx) { } void func_80943028(Actor* thisx, GlobalContext* globalCtx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6885); Matrix_Push(); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 57.0f, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->workf[UNK_F17], this->workf[UNK_F17], this->workf[UNK_F17], MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y + 57.0f, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(pthis->workf[UNK_F17], pthis->workf[UNK_F17], pthis->workf[UNK_F17], MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6908), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01F608)); func_80094044(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 200); - Matrix_Translate(this->actor.world.pos.x, 240.0f, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale((this->actor.scale.x * 4000.0f) / 100.0f, 1.0f, (this->actor.scale.x * 4000.0f) / 100.0f, + Matrix_Translate(pthis->actor.world.pos.x, 240.0f, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale((pthis->actor.scale.x * 4000.0f) / 100.0f, 1.0f, (pthis->actor.scale.x * 4000.0f) / 100.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6926), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3509,78 +3509,78 @@ static void* sEyeTextures[] = { void BossTw_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Vec3f D_8094A9A4 = { 0.0f, 200.0f, 2000.0f }; GlobalContext* globalCtx = globalCtx2; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; Player* player = GET_PLAYER(globalCtx); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 6947); - if (this->visible) { - gSPSegment(POLY_OPA_DISP++, 10, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIdx])); - gSPSegment(POLY_XLU_DISP++, 10, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIdx])); + if (pthis->visible) { + gSPSegment(POLY_OPA_DISP++, 10, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeTexIdx])); + gSPSegment(POLY_XLU_DISP++, 10, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeTexIdx])); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)this->workf[OUTR_CRWN_TX_X1] & 0x7F, - (s16)this->workf[OUTR_CRWN_TX_Y1] & 0x7F, 0x20, 0x20, 1, - (s16)this->workf[OUTR_CRWN_TX_X2] & 0x7F, (s16)this->workf[OUTR_CRWN_TX_Y2] & 0xFF, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)pthis->workf[OUTR_CRWN_TX_X1] & 0x7F, + (s16)pthis->workf[OUTR_CRWN_TX_Y1] & 0x7F, 0x20, 0x20, 1, + (s16)pthis->workf[OUTR_CRWN_TX_X2] & 0x7F, (s16)pthis->workf[OUTR_CRWN_TX_Y2] & 0xFF, 0x20, 0x40)); - if (this->actor.params == TW_KOTAKE) { + if (pthis->actor.params == TW_KOTAKE) { gSPSegment(POLY_XLU_DISP++, 9, - Gfx_TexScroll(globalCtx->state.gfxCtx, (s16)this->workf[INNR_CRWN_TX_X1] & 0x7F, - (s16)this->workf[INNR_CRWN_TX_Y1] & 0xFF, 0x20, 0x40)); + Gfx_TexScroll(globalCtx->state.gfxCtx, (s16)pthis->workf[INNR_CRWN_TX_X1] & 0x7F, + (s16)pthis->workf[INNR_CRWN_TX_Y1] & 0xFF, 0x20, 0x40)); } else { gSPSegment(POLY_XLU_DISP++, 9, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)this->workf[INNR_CRWN_TX_X1] & 0x7F, - (s16)this->workf[INNR_CRWN_TX_Y1] & 0x7F, 0x20, 0x20, 1, - (s16)this->workf[INNR_CRWN_TX_X2] & 0x7F, - (s16)this->workf[INNR_CRWN_TX_Y2] & 0xFF, 0x20, 0x40)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)pthis->workf[INNR_CRWN_TX_X1] & 0x7F, + (s16)pthis->workf[INNR_CRWN_TX_Y1] & 0x7F, 0x20, 0x20, 1, + (s16)pthis->workf[INNR_CRWN_TX_X2] & 0x7F, + (s16)pthis->workf[INNR_CRWN_TX_Y2] & 0xFF, 0x20, 0x40)); } func_80093D18(globalCtx->state.gfxCtx); func_80093D84(globalCtx->state.gfxCtx); - if (this->work[FOG_TIMER] & 2) { + if (pthis->work[FOG_TIMER] & 2) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099); } else { - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, (u32)this->fogR, (u32)this->fogG, (u32)this->fogB, 0, - this->fogNear, this->fogFar); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, (u32)pthis->fogR, (u32)pthis->fogG, (u32)pthis->fogB, 0, + pthis->fogNear, pthis->fogFar); } Matrix_Push(); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossTw_OverrideLimbDraw, BossTw_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossTw_OverrideLimbDraw, BossTw_PostLimbDraw, pthis); Matrix_Pop(); POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); } - if (this->actor.params == TW_KOTAKE) { - if (this->workf[UNK_F9] > 0.0f) { - if (this->workf[UNK_F11] > 0.0f) { + if (pthis->actor.params == TW_KOTAKE) { + if (pthis->workf[UNK_F9] > 0.0f) { + if (pthis->workf[UNK_F11] > 0.0f) { Vec3f diff; - diff.x = this->groundBlastPos2.x - player->actor.world.pos.x; - diff.y = this->groundBlastPos2.y - player->actor.world.pos.y; - diff.z = this->groundBlastPos2.z - player->actor.world.pos.z; + diff.x = pthis->groundBlastPos2.x - player->actor.world.pos.x; + diff.y = pthis->groundBlastPos2.y - player->actor.world.pos.y; + diff.z = pthis->groundBlastPos2.z - player->actor.world.pos.z; if ((fabsf(diff.y) < 10.0f) && (player->actor.bgCheckFlags & 1) && - (sqrtf(SQ(diff.x) + SQ(diff.z)) < (this->workf[UNK_F12] * 4600.0f)) && (sFreezeState == 0) && - (this->workf[UNK_F11] > 200.0f)) { + (sqrtf(SQ(diff.x) + SQ(diff.z)) < (pthis->workf[UNK_F12] * 4600.0f)) && (sFreezeState == 0) && + (pthis->workf[UNK_F11] > 200.0f)) { sFreezeState = 1; sTwinrovaPtr->timers[2] = 100; } } - func_80941BC0(this, globalCtx); + func_80941BC0(pthis, globalCtx); } } else { - func_80942180(this, globalCtx); + func_80942180(pthis, globalCtx); } - if (this->visible) { - if (this->actionFunc == BossTw_DeathCS) { - func_80943028(&this->actor, globalCtx); + if (pthis->visible) { + if (pthis->actionFunc == BossTw_DeathCS) { + func_80943028(&pthis->actor, globalCtx); } else { - func_809426F0(this, globalCtx); - Matrix_MultVec3f(&D_8094A9A4, &this->beamOrigin); - func_80942C70(&this->actor, globalCtx); + func_809426F0(pthis, globalCtx); + Matrix_MultVec3f(&D_8094A9A4, &pthis->beamOrigin); + func_80942C70(&pthis->actor, globalCtx); } } @@ -3595,59 +3595,59 @@ void* D_8094A9B0[] = { s32 BossTw_TwinrovaOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7139); switch (limbIndex) { case 21: gSPSegment(POLY_OPA_DISP++, 0xC, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (s16)(f32)this->work[CS_TIMER_1], 8, 8)); - gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(D_8094A9B0[this->eyeTexIdx])); - gSPSegment(POLY_OPA_DISP++, 9, SEGMENTED_TO_VIRTUAL(D_8094A9B0[this->leftEyeTexIdx])); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->work[UNK_S8]); + Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (s16)(f32)pthis->work[CS_TIMER_1], 8, 8)); + gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(D_8094A9B0[pthis->eyeTexIdx])); + gSPSegment(POLY_OPA_DISP++, 9, SEGMENTED_TO_VIRTUAL(D_8094A9B0[pthis->leftEyeTexIdx])); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, pthis->work[UNK_S8]); break; case 17: case 41: *dList = NULL; gSPSegment(POLY_XLU_DISP++, 0xA, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, 0, - -this->work[CS_TIMER_1] * 0xF, 0x20, 0x40)); + -pthis->work[CS_TIMER_1] * 0xF, 0x20, 0x40)); break; case 18: case 42: *dList = NULL; gSPSegment(POLY_XLU_DISP++, 0xB, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, 0, - -this->work[CS_TIMER_1] * 0xA, 0x20, 0x40)); + -pthis->work[CS_TIMER_1] * 0xA, 0x20, 0x40)); break; case 16: case 32: *dList = NULL; gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->work[CS_TIMER_1], - -this->work[CS_TIMER_1] * 7, 0x20, 0x40)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, pthis->work[CS_TIMER_1], + -pthis->work[CS_TIMER_1] * 7, 0x20, 0x40)); break; case 15: case 31: *dList = NULL; gSPSegment(POLY_XLU_DISP++, 9, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, this->work[CS_TIMER_1], 0x20, 0x40)); + Gfx_TexScroll(globalCtx->state.gfxCtx, 0, pthis->work[CS_TIMER_1], 0x20, 0x40)); break; case 19: - if (this->unk_5F8 != 0) { + if (pthis->unk_5F8 != 0) { *dList = object_tw_DL_02D940; } break; case 20: - if (this->unk_5F8 != 0) { + if (pthis->unk_5F8 != 0) { *dList = object_tw_DL_02D890; } break; } - if (this->unk_5F8 != 0 && ((limbIndex == 34) || (limbIndex == 40))) { + if (pthis->unk_5F8 != 0 && ((limbIndex == 34) || (limbIndex == 40))) { *dList = NULL; } @@ -3662,20 +3662,20 @@ void BossTw_TwinrovaPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** static Vec3f D_8094A9D4 = { 13000.0f, 0.0f, 0.0f }; static Vec3f D_8094A9E0 = { 13000.0f, 0.0f, 0.0f }; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7262); switch (limbIndex) { case 34: - Matrix_MultVec3f(&D_8094A9D4, &this->leftScepterPos); + Matrix_MultVec3f(&D_8094A9D4, &pthis->leftScepterPos); break; case 40: - Matrix_MultVec3f(&D_8094A9E0, &this->rightScepterPos); + Matrix_MultVec3f(&D_8094A9E0, &pthis->rightScepterPos); break; case 21: - Matrix_MultVec3f(&D_8094A9BC, &this->actor.focus.pos); - Matrix_MultVec3f(&D_8094A9C8, &this->crownPos); + Matrix_MultVec3f(&D_8094A9BC, &pthis->actor.focus.pos); + Matrix_MultVec3f(&D_8094A9C8, &pthis->crownPos); break; case 15: case 16: @@ -3686,7 +3686,7 @@ void BossTw_TwinrovaPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** case 41: case 42: Matrix_Push(); - Matrix_Scale(this->workf[UNK_F12], this->workf[UNK_F12], this->workf[UNK_F12], MTXMODE_APPLY); + Matrix_Scale(pthis->workf[UNK_F12], pthis->workf[UNK_F12], pthis->workf[UNK_F12], MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7295), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); Matrix_Pop(); @@ -3697,7 +3697,7 @@ void BossTw_TwinrovaPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7301); } -void BossTw_ShieldChargeDraw(BossTw* this, GlobalContext* globalCtx) { +void BossTw_ShieldChargeDraw(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); s16 temp_t0; @@ -3740,21 +3740,21 @@ void BossTw_ShieldChargeDraw(BossTw* this, GlobalContext* globalCtx) { Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7362), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - temp_a0 = (Math_SinS(this->work[CS_TIMER_1] * 2730 * temp_t0) * D_8094C854 * 0.5f) + (D_8094C854 * 0.5f); + temp_a0 = (Math_SinS(pthis->work[CS_TIMER_1] * 2730 * temp_t0) * D_8094C854 * 0.5f) + (D_8094C854 * 0.5f); if (sShieldFireCharge != 0) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, temp_a0); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01E0E0)); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (this->work[CS_TIMER_1] * 2) * temp_t0, 0, 0x20, - 0x20, 1, (-this->work[CS_TIMER_1] * 2) * temp_t0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (pthis->work[CS_TIMER_1] * 2) * temp_t0, 0, 0x20, + 0x20, 1, (-pthis->work[CS_TIMER_1] * 2) * temp_t0, 0, 0x20, 0x20)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 20, 0, (s16)D_8094C854); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01E020)); } else { gDPSetEnvColor(POLY_XLU_DISP++, 225, 255, 255, temp_a0); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01E3A0)); gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (-this->work[CS_TIMER_1] * 5) * temp_t0, - 0x20, 0x40, 1, (this->work[CS_TIMER_1] * 4) * temp_t0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (-pthis->work[CS_TIMER_1] * 5) * temp_t0, + 0x20, 0x40, 1, (pthis->work[CS_TIMER_1] * 4) * temp_t0, 0, 0x20, 0x20)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 175, 205, 195, (s16)D_8094C854); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01E2C0)); } @@ -3789,8 +3789,8 @@ void BossTw_ShieldChargeDraw(BossTw* this, GlobalContext* globalCtx) { } gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, this->work[CS_TIMER_1] * D_8094C872, 0x20, 0x40, 1, - 0, this->work[CS_TIMER_1] * D_8094C872, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, pthis->work[CS_TIMER_1] * D_8094C872, 0x20, 0x40, 1, + 0, pthis->work[CS_TIMER_1] * D_8094C872, 0x20, 0x20)); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01E9F0)); } @@ -3799,7 +3799,7 @@ void BossTw_ShieldChargeDraw(BossTw* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7531); } -void BossTw_SpawnPortalDraw(BossTw* this, GlobalContext* globalCtx) { +void BossTw_SpawnPortalDraw(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7546); @@ -3807,18 +3807,18 @@ void BossTw_SpawnPortalDraw(BossTw* this, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); gSPSegment( POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -this->work[CS_TIMER_1] * 15, 0x20, 0x40, 1, 0, 0, 0x40, 0x40)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -pthis->work[CS_TIMER_1] * 15, 0x20, 0x40, 1, 0, 0, 0x40, 0x40)); Matrix_Push(); Matrix_Translate(0.0f, 232.0f, -600.0f, MTXMODE_NEW); - Matrix_Scale(this->spawnPortalScale, this->spawnPortalScale, this->spawnPortalScale, MTXMODE_APPLY); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (s16)this->spawnPortalAlpha); + Matrix_Scale(pthis->spawnPortalScale, pthis->spawnPortalScale, pthis->spawnPortalScale, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (s16)pthis->spawnPortalAlpha); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7582), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01EC68)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 135, 175, 165, (s16)this->spawnPortalAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 135, 175, 165, (s16)pthis->spawnPortalAlpha); Matrix_Translate(0.0f, 2.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7596), @@ -3826,13 +3826,13 @@ void BossTw_SpawnPortalDraw(BossTw* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01CEE0)); Matrix_Translate(0.0f, 232.0f, 600.0f, MTXMODE_NEW); - Matrix_Scale(this->spawnPortalScale, this->spawnPortalScale, this->spawnPortalScale, MTXMODE_APPLY); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (s16)this->spawnPortalAlpha); + Matrix_Scale(pthis->spawnPortalScale, pthis->spawnPortalScale, pthis->spawnPortalScale, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (s16)pthis->spawnPortalAlpha); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7617), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01EC68)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (s16)this->spawnPortalAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (s16)pthis->spawnPortalAlpha); Matrix_Translate(0.0f, 2.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7631), @@ -3844,7 +3844,7 @@ void BossTw_SpawnPortalDraw(BossTw* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7635); } -void func_80944C50(BossTw* this, GlobalContext* globalCtx) { +void func_80944C50(BossTw* pthis, GlobalContext* globalCtx) { s32 pad; f32 scale; @@ -3854,7 +3854,7 @@ void func_80944C50(BossTw* this, GlobalContext* globalCtx) { Matrix_Translate(0.0f, 750.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(0.35f, 0.35f, 0.35f, MTXMODE_APPLY); Matrix_Push(); - Matrix_Scale(this->workf[UNK_F19], this->workf[UNK_F19], this->workf[UNK_F19], MTXMODE_APPLY); + Matrix_Scale(pthis->workf[UNK_F19], pthis->workf[UNK_F19], pthis->workf[UNK_F19], MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7671), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01F390)); @@ -3863,7 +3863,7 @@ void func_80944C50(BossTw* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -sKoumePtr->work[CS_TIMER_1] * 2, 0, 0x20, 0x20, 1, -sKoumePtr->work[CS_TIMER_1] * 2, 0, 0x20, 0x40)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)this->workf[UNK_F18] / 2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)pthis->workf[UNK_F18] / 2); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7694), G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01F238)); @@ -3872,9 +3872,9 @@ void func_80944C50(BossTw* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -sKoumePtr->work[CS_TIMER_1] * 5, -sKoumePtr->work[CS_TIMER_1] * 2, 0x20, 0x40, 1, 0, -sKoumePtr->work[CS_TIMER_1] * 2, 0x10, 0x10)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)(this->workf[UNK_F18] * 0.3f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s16)(pthis->workf[UNK_F18] * 0.3f)); - scale = this->workf[UNK_F18] / 150.0f; + scale = pthis->workf[UNK_F18] / 150.0f; scale = CLAMP_MAX(scale, 1.0f); Matrix_Scale(scale, 1.0f, scale, MTXMODE_APPLY); @@ -3889,44 +3889,44 @@ void func_80944C50(BossTw* this, GlobalContext* globalCtx) { void BossTw_TwinrovaDraw(Actor* thisx, GlobalContext* globalCtx2) { static Vec3f D_8094A9EC = { 0.0f, 200.0f, 2000.0f }; GlobalContext* globalCtx = globalCtx2; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7748); - if (this->visible) { + if (pthis->visible) { func_80093D18(globalCtx->state.gfxCtx); func_80093D84(globalCtx->state.gfxCtx); - POLY_OPA_DISP = (this->work[FOG_TIMER] & 2) ? Gfx_SetFog2(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099) - : Gfx_SetFog2(POLY_OPA_DISP, (u32)this->fogR, (u32)this->fogG, - (u32)this->fogB, 0, this->fogNear, this->fogFar); + POLY_OPA_DISP = (pthis->work[FOG_TIMER] & 2) ? Gfx_SetFog2(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099) + : Gfx_SetFog2(POLY_OPA_DISP, (u32)pthis->fogR, (u32)pthis->fogG, + (u32)pthis->fogB, 0, pthis->fogNear, pthis->fogFar); Matrix_Push(); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossTw_TwinrovaOverrideLimbDraw, BossTw_TwinrovaPostLimbDraw, + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossTw_TwinrovaOverrideLimbDraw, BossTw_TwinrovaPostLimbDraw, thisx); Matrix_Pop(); - Matrix_MultVec3f(&D_8094A9EC, &this->beamOrigin); + Matrix_MultVec3f(&D_8094A9EC, &pthis->beamOrigin); POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, globalCtx->lightCtx.fogColor[0], globalCtx->lightCtx.fogColor[1], globalCtx->lightCtx.fogColor[2], 0, globalCtx->lightCtx.fogNear, 1000); } BossTw_DrawEffects(globalCtx); - BossTw_ShieldChargeDraw(this, globalCtx); + BossTw_ShieldChargeDraw(pthis, globalCtx); - if (this->spawnPortalAlpha > 0.0f) { - BossTw_SpawnPortalDraw(this, globalCtx); + if (pthis->spawnPortalAlpha > 0.0f) { + BossTw_SpawnPortalDraw(pthis, globalCtx); } - if (this->workf[UNK_F18] > 0.0f) { - func_80944C50(this, globalCtx); + if (pthis->workf[UNK_F18] > 0.0f) { + func_80944C50(pthis, globalCtx); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_tw.c", 7804); } -void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { +void BossTw_BlastFire(BossTw* pthis, GlobalContext* globalCtx) { s16 i; f32 xDiff; f32 yDiff; @@ -3935,86 +3935,86 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Player* player2 = player; - switch (this->actor.params) { + switch (pthis->actor.params) { case TW_FIRE_BLAST: - switch (this->csState1) { + switch (pthis->csState1) { case 0: - Actor_SetScale(&this->actor, 0.03f); - this->csState1 = 1; - xDiff = player->actor.world.pos.x - this->actor.world.pos.x; - yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y; - zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + Actor_SetScale(&pthis->actor, 0.03f); + pthis->csState1 = 1; + xDiff = player->actor.world.pos.x - pthis->actor.world.pos.x; + yDiff = (player->actor.world.pos.y + 30.0f) - pthis->actor.world.pos.y; + zDiff = player->actor.world.pos.z - pthis->actor.world.pos.z; // yaw - this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); + pthis->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); // pitch distXZ = sqrtf(SQ(xDiff) + SQ(zDiff)); - this->actor.world.rot.x = Math_FAtan2F(yDiff, distXZ) * (32768 / M_PI); - this->actor.speedXZ = 20.0f; + pthis->actor.world.rot.x = Math_FAtan2F(yDiff, distXZ) * (32768 / M_PI); + pthis->actor.speedXZ = 20.0f; for (i = 0; i < 50; i++) { - this->blastTailPos[i] = this->actor.world.pos; + pthis->blastTailPos[i] = pthis->actor.world.pos; } - this->workf[TAIL_ALPHA] = 255.0f; + pthis->workf[TAIL_ALPHA] = 255.0f; // fallthrough case 1: case 10: - this->blastActive = true; - if (this->timers[0] == 0) { - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_SHOOT_FIRE & ~SFX_FLAG); + pthis->blastActive = true; + if (pthis->timers[0] == 0) { + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_SHOOT_FIRE & ~SFX_FLAG); } else { Vec3f velocity; Vec3f velDir; Vec3s blastDir; s16 alpha; - this->actor.world.pos = player2->bodyPartsPos[15]; - this->actor.world.pos.y = -2000.0f; + pthis->actor.world.pos = player2->bodyPartsPos[15]; + pthis->actor.world.pos.y = -2000.0f; Matrix_MtxFToYXZRotS(&player2->shieldMf, &blastDir, 0); blastDir.x = -blastDir.x; blastDir.y = blastDir.y + 0x8000; - Math_ApproachS(&this->magicDir.x, blastDir.x, 0xA, 0x800); - Math_ApproachS(&this->magicDir.y, blastDir.y, 0xA, 0x800); + Math_ApproachS(&pthis->magicDir.x, blastDir.x, 0xA, 0x800); + Math_ApproachS(&pthis->magicDir.y, blastDir.y, 0xA, 0x800); - if (this->timers[0] == 50) { + if (pthis->timers[0] == 50) { D_8094C86F = 10; D_8094C872 = 7; globalCtx->envCtx.unk_D8 = 1.0f; } - if (this->timers[0] <= 50) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_SHOOT_FIRE & ~SFX_FLAG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_REFL_FIRE & ~SFX_FLAG); - Matrix_RotateY((this->magicDir.y / 32678.0f) * M_PI, MTXMODE_NEW); - Matrix_RotateX((this->magicDir.x / 32678.0f) * M_PI, MTXMODE_APPLY); + if (pthis->timers[0] <= 50) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_SHOOT_FIRE & ~SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_REFL_FIRE & ~SFX_FLAG); + Matrix_RotateY((pthis->magicDir.y / 32678.0f) * M_PI, MTXMODE_NEW); + Matrix_RotateX((pthis->magicDir.x / 32678.0f) * M_PI, MTXMODE_APPLY); velDir.x = 0.0f; velDir.y = 0.0f; velDir.z = 50.0f; Matrix_MultVec3f(&velDir, &velocity); - alpha = this->timers[0] * 10; + alpha = pthis->timers[0] * 10; alpha = CLAMP_MAX(alpha, 255); BossTw_AddShieldBlastEffect(globalCtx, &player2->bodyPartsPos[15], &velocity, &sZeroVector, 10.0f, 80.0f, alpha, 1); } - if (this->timers[0] == 1) { + if (pthis->timers[0] == 1) { sEnvType = 0; sShieldFireCharge++; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } return; } - this->groundBlastPos.y = BossTw_GetFloorY(&this->actor.world.pos); + pthis->groundBlastPos.y = BossTw_GetFloorY(&pthis->actor.world.pos); - if (this->groundBlastPos.y >= 0.0f) { - if (this->groundBlastPos.y != 35.0f) { - this->groundBlastPos.x = this->actor.world.pos.x; - this->groundBlastPos.z = this->actor.world.pos.z; - BossTw_SpawnGroundBlast(this, globalCtx, 1); + if (pthis->groundBlastPos.y >= 0.0f) { + if (pthis->groundBlastPos.y != 35.0f) { + pthis->groundBlastPos.x = pthis->actor.world.pos.x; + pthis->groundBlastPos.z = pthis->actor.world.pos.z; + BossTw_SpawnGroundBlast(pthis, globalCtx, 1); } else { Vec3f velocity; Vec3f accel; @@ -4026,22 +4026,22 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { accel.x = 0.0f; accel.y = 0.0f; accel.z = 0.0f; - BossTw_AddFlameEffect(globalCtx, &this->actor.world.pos, &velocity, &accel, - Rand_ZeroFloat(10.0f) + 25.0f, this->blastType); + BossTw_AddFlameEffect(globalCtx, &pthis->actor.world.pos, &velocity, &accel, + Rand_ZeroFloat(10.0f) + 25.0f, pthis->blastType); } globalCtx->envCtx.unk_D8 = 0.5f; } - this->csState1 = 2; - this->timers[0] = 20; + pthis->csState1 = 2; + pthis->timers[0] = 20; } else { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.0f, 0.0f }; for (i = 0; i < 10; i++) { - pos = this->blastTailPos[(s16)Rand_ZeroFloat(29.9f)]; + pos = pthis->blastTailPos[(s16)Rand_ZeroFloat(29.9f)]; pos.x += Rand_CenteredFloat(40.0f); pos.y += Rand_CenteredFloat(40.0f); pos.z += Rand_CenteredFloat(40.0f); @@ -4054,25 +4054,25 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { } break; case 2: - Math_ApproachF(&this->workf[TAIL_ALPHA], 0.0f, 1.0f, 15.0f); - if (this->timers[0] == 0) { - Actor_Kill(&this->actor); + Math_ApproachF(&pthis->workf[TAIL_ALPHA], 0.0f, 1.0f, 15.0f); + if (pthis->timers[0] == 0) { + Actor_Kill(&pthis->actor); } break; } break; case TW_FIRE_BLAST_GROUND: - if (this->timers[0] != 0) { - if (this->timers[0] == 1) { + if (pthis->timers[0] != 0) { + if (pthis->timers[0] == 1) { sEnvType = 0; } if (sGroundBlastType == 2) { - this->timers[0] = 0; + pthis->timers[0] = 0; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_FIRE_EXP - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_FIRE_EXP - SFX_FLAG); xDiff = sKoumePtr->groundBlastPos2.x - player->actor.world.pos.x; yDiff = sKoumePtr->groundBlastPos2.y - player->actor.world.pos.y; @@ -4088,9 +4088,9 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { player->isBurning = 1; - if (this->work[BURN_TMR] == 0) { + if (pthis->work[BURN_TMR] == 0) { func_8002F7DC(&player->actor, player->ageProperties->unk_92 + NA_SE_VO_LI_DEMO_DAMAGE); - this->work[BURN_TMR] = 40; + pthis->work[BURN_TMR] = 40; } sTwinrovaPtr->timers[2] = 100; @@ -4110,14 +4110,14 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { } if (sKoumePtr->workf[TAIL_ALPHA] <= 0.0f) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; } } -void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { +void BossTw_BlastIce(BossTw* pthis, GlobalContext* globalCtx) { s16 i; f32 xDiff; f32 yDiff; @@ -4126,85 +4126,85 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Player* player2 = player; - switch (this->actor.params) { + switch (pthis->actor.params) { case TW_ICE_BLAST: - switch (this->csState1) { + switch (pthis->csState1) { case 0: - Actor_SetScale(&this->actor, 0.03f); - this->csState1 = 1; - xDiff = player->actor.world.pos.x - this->actor.world.pos.x; - yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y; - zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); + Actor_SetScale(&pthis->actor, 0.03f); + pthis->csState1 = 1; + xDiff = player->actor.world.pos.x - pthis->actor.world.pos.x; + yDiff = (player->actor.world.pos.y + 30.0f) - pthis->actor.world.pos.y; + zDiff = player->actor.world.pos.z - pthis->actor.world.pos.z; + pthis->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - this->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI); - this->actor.speedXZ = 20.0f; + pthis->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI); + pthis->actor.speedXZ = 20.0f; for (i = 0; i < 50; i++) { - this->blastTailPos[i] = this->actor.world.pos; + pthis->blastTailPos[i] = pthis->actor.world.pos; } - this->workf[TAIL_ALPHA] = 255.0f; + pthis->workf[TAIL_ALPHA] = 255.0f; // fallthrough case 1: case 10: - this->blastActive = true; + pthis->blastActive = true; - if (this->timers[0] == 0) { - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG); + if (pthis->timers[0] == 0) { + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG); } else { Vec3f velocity; Vec3f spF4; Vec3s reflDir; s16 alpha; - this->actor.world.pos = player2->bodyPartsPos[15]; - this->actor.world.pos.y = -2000.0f; + pthis->actor.world.pos = player2->bodyPartsPos[15]; + pthis->actor.world.pos.y = -2000.0f; Matrix_MtxFToYXZRotS(&player2->shieldMf, &reflDir, 0); reflDir.x = -reflDir.x; reflDir.y += 0x8000; - Math_ApproachS(&this->magicDir.x, reflDir.x, 0xA, 0x800); - Math_ApproachS(&this->magicDir.y, reflDir.y, 0xA, 0x800); + Math_ApproachS(&pthis->magicDir.x, reflDir.x, 0xA, 0x800); + Math_ApproachS(&pthis->magicDir.y, reflDir.y, 0xA, 0x800); - if (this->timers[0] == 50) { + if (pthis->timers[0] == 50) { D_8094C86F = 10; D_8094C872 = 7; globalCtx->envCtx.unk_D8 = 1.0f; } - if (this->timers[0] <= 50) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_REFL_FREEZE - SFX_FLAG); - Matrix_RotateY((this->magicDir.y / 32678.0f) * M_PI, MTXMODE_NEW); - Matrix_RotateX((this->magicDir.x / 32678.0f) * M_PI, MTXMODE_APPLY); + if (pthis->timers[0] <= 50) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_SHOOT_FREEZE - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_REFL_FREEZE - SFX_FLAG); + Matrix_RotateY((pthis->magicDir.y / 32678.0f) * M_PI, MTXMODE_NEW); + Matrix_RotateX((pthis->magicDir.x / 32678.0f) * M_PI, MTXMODE_APPLY); spF4.x = 0.0f; spF4.y = 0.0f; spF4.z = 50.0f; Matrix_MultVec3f(&spF4, &velocity); - alpha = this->timers[0] * 10; + alpha = pthis->timers[0] * 10; alpha = CLAMP_MAX(alpha, 255); BossTw_AddShieldBlastEffect(globalCtx, &player2->bodyPartsPos[15], &velocity, &sZeroVector, 10.0f, 80.0f, alpha, 0); } - if (this->timers[0] == 1) { + if (pthis->timers[0] == 1) { sEnvType = 0; sShieldIceCharge++; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; } - this->groundBlastPos.y = BossTw_GetFloorY(&this->actor.world.pos); + pthis->groundBlastPos.y = BossTw_GetFloorY(&pthis->actor.world.pos); - if (this->groundBlastPos.y >= 0.0f) { - if (this->groundBlastPos.y != 35.0f) { - this->groundBlastPos.x = this->actor.world.pos.x; - this->groundBlastPos.z = this->actor.world.pos.z; - BossTw_SpawnGroundBlast(this, globalCtx, 0); + if (pthis->groundBlastPos.y >= 0.0f) { + if (pthis->groundBlastPos.y != 35.0f) { + pthis->groundBlastPos.x = pthis->actor.world.pos.x; + pthis->groundBlastPos.z = pthis->actor.world.pos.z; + BossTw_SpawnGroundBlast(pthis, globalCtx, 0); } else { for (i = 0; i < 50; i++) { Vec3f velocity; @@ -4216,22 +4216,22 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { accel.x = 0.0f; accel.y = 0.0f; accel.z = 0.0f; - BossTw_AddFlameEffect(globalCtx, &this->actor.world.pos, &velocity, &accel, - Rand_ZeroFloat(10.0f) + 25.0f, this->blastType); + BossTw_AddFlameEffect(globalCtx, &pthis->actor.world.pos, &velocity, &accel, + Rand_ZeroFloat(10.0f) + 25.0f, pthis->blastType); } globalCtx->envCtx.unk_D8 = 0.5f; } - this->csState1 = 2; - this->timers[0] = 20; + pthis->csState1 = 2; + pthis->timers[0] = 20; } else { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.0f, 0.0f }; for (i = 0; i < 10; i++) { - pos = this->blastTailPos[(s16)Rand_ZeroFloat(29.9f)]; + pos = pthis->blastTailPos[(s16)Rand_ZeroFloat(29.9f)]; pos.x += Rand_CenteredFloat(40.0f); pos.y += Rand_CenteredFloat(40.0f); pos.z += Rand_CenteredFloat(40.0f); @@ -4245,27 +4245,27 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { break; case 2: - Math_ApproachF(&this->workf[TAIL_ALPHA], 0.0f, 1.0f, 15.0f); - if (this->timers[0] == 0) { - Actor_Kill(&this->actor); + Math_ApproachF(&pthis->workf[TAIL_ALPHA], 0.0f, 1.0f, 15.0f); + if (pthis->timers[0] == 0) { + Actor_Kill(&pthis->actor); } break; } break; case TW_ICE_BLAST_GROUND: - if (this->timers[0] != 0) { - if (this->timers[0] == 1) { + if (pthis->timers[0] != 0) { + if (pthis->timers[0] == 1) { sEnvType = 0; } if (sGroundBlastType == 1) { - this->timers[0] = 0; + pthis->timers[0] = 0; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - if (this->timers[0] > (sTwinrovaPtr->actionFunc == BossTw_Wait ? 70 : 20)) { + if (pthis->timers[0] > (sTwinrovaPtr->actionFunc == BossTw_Wait ? 70 : 20)) { s32 pad; Vec3f pos; Vec3f velocity; @@ -4295,11 +4295,11 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { Math_ApproachF(&sKotakePtr->workf[UNK_F12], 0.04f, 0.1f, 0.002f); Math_ApproachF(&sKotakePtr->workf[UNK_F16], 70.0f, 1.0f, 5.0f); - if ((this->timers[0] == 70) || (this->timers[0] == 30)) { + if ((pthis->timers[0] == 70) || (pthis->timers[0] == 30)) { sKotakePtr->workf[UNK_F16] = 10.0f; } - if ((this->timers[0] % 4) == 0) { + if ((pthis->timers[0] % 4) == 0) { sKotakePtr->workf[UNK_F15] = (2.0f * (s16)Rand_ZeroFloat(9.9f) * M_PI) / 10.0f; } } else { @@ -4334,33 +4334,33 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { Math_ApproachF(&sKotakePtr->workf[UNK_F9], 0.0f, 1.0f, sp80); if (sKotakePtr->workf[UNK_F9] <= 0.0f) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } break; } } -s32 BossTw_BlastShieldCheck(BossTw* this, GlobalContext* globalCtx) { +s32 BossTw_BlastShieldCheck(BossTw* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 ret = false; ColliderInfo* info; if (1) {} - if (this->csState1 == 1) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - this->collider.base.atFlags &= ~AT_HIT; - info = this->collider.info.acHitInfo; + if (pthis->csState1 == 1) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.atFlags &= ~AT_HIT; + info = pthis->collider.info.acHitInfo; if (info->toucher.dmgFlags & DMG_SHIELD) { - this->work[INVINC_TIMER] = 7; + pthis->work[INVINC_TIMER] = 7; globalCtx->envCtx.unk_D8 = 1.0f; func_800AA000(0.0f, 100, 5, 4); if (Player_HasMirrorShieldEquipped(globalCtx)) { - if (this->blastType == 1) { + if (pthis->blastType == 1) { if (sShieldIceCharge != 0) { sShieldIceCharge = 0; BossTw_AddShieldDeflectEffect(globalCtx, 10.0f, 1); @@ -4384,21 +4384,21 @@ s32 BossTw_BlastShieldCheck(BossTw* this, GlobalContext* globalCtx) { } if ((sShieldIceCharge >= 3) || (sShieldFireCharge >= 3)) { - this->timers[0] = 80; - this->csState1 = 10; - Matrix_MtxFToYXZRotS(&player->shieldMf, &this->magicDir, 0); - this->magicDir.y += 0x8000; - this->magicDir.x = -this->magicDir.x; + pthis->timers[0] = 80; + pthis->csState1 = 10; + Matrix_MtxFToYXZRotS(&player->shieldMf, &pthis->magicDir, 0); + pthis->magicDir.y += 0x8000; + pthis->magicDir.x = -pthis->magicDir.x; D_8094C86F = 8; } else { - this->csState1 = 2; - this->timers[0] = 20; + pthis->csState1 = 2; + pthis->timers[0] = 20; sEnvType = 0; } } else { - BossTw_AddShieldDeflectEffect(globalCtx, 10.0f, this->blastType); - this->csState1 = 2; - this->timers[0] = 20; + BossTw_AddShieldDeflectEffect(globalCtx, 10.0f, pthis->blastType); + pthis->csState1 = 2; + pthis->timers[0] = 20; sEnvType = 0; sShieldIceCharge = 0; sShieldFireCharge = 0; @@ -4414,51 +4414,51 @@ s32 BossTw_BlastShieldCheck(BossTw* this, GlobalContext* globalCtx) { } void BossTw_BlastUpdate(Actor* thisx, GlobalContext* globalCtx) { - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; ColliderCylinder* collider; s16 i; - this->work[CS_TIMER_1]++; - this->work[CS_TIMER_2]++; - this->work[TAIL_IDX]++; + pthis->work[CS_TIMER_1]++; + pthis->work[CS_TIMER_2]++; + pthis->work[TAIL_IDX]++; - if (this->work[TAIL_IDX] > 29) { - this->work[TAIL_IDX] = 0; + if (pthis->work[TAIL_IDX] > 29) { + pthis->work[TAIL_IDX] = 0; } - this->blastTailPos[this->work[TAIL_IDX]] = this->actor.world.pos; + pthis->blastTailPos[pthis->work[TAIL_IDX]] = pthis->actor.world.pos; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); for (i = 0; i < 5; i++) { - if (this->timers[i] != 0) { - this->timers[i]--; + if (pthis->timers[i] != 0) { + pthis->timers[i]--; } } - if (this->work[INVINC_TIMER] != 0) { - this->work[INVINC_TIMER]--; + if (pthis->work[INVINC_TIMER] != 0) { + pthis->work[INVINC_TIMER]--; } - if (this->work[BURN_TMR] != 0) { - this->work[BURN_TMR]--; + if (pthis->work[BURN_TMR] != 0) { + pthis->work[BURN_TMR]--; } - this->actor.focus.pos = this->actor.world.pos; - collider = &this->collider; - Collider_UpdateCylinder(&this->actor, collider); + pthis->actor.focus.pos = pthis->actor.world.pos; + collider = &pthis->collider; + Collider_UpdateCylinder(&pthis->actor, collider); - if (this->blastActive && this->work[INVINC_TIMER] == 0 && !BossTw_BlastShieldCheck(this, globalCtx)) { + if (pthis->blastActive && pthis->work[INVINC_TIMER] == 0 && !BossTw_BlastShieldCheck(pthis, globalCtx)) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &collider->base); CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &collider->base); } - this->blastActive = false; + pthis->blastActive = false; } void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; f32 scaleFactor; s16 tailIdx; s16 i; @@ -4467,21 +4467,21 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { func_80093D84(globalCtx->state.gfxCtx); - switch (this->actor.params) { + switch (pthis->actor.params) { case TW_FIRE_BLAST: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s8)this->workf[TAIL_ALPHA]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s8)pthis->workf[TAIL_ALPHA]); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); for (i = 9; i >= 0; i--) { gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll( - globalCtx->state.gfxCtx, 0, ((this->work[CS_TIMER_1] * 3) + (i * 10)) & 0x7F, - ((-this->work[CS_TIMER_1] * 15) + (i * 50)) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - tailIdx = ((this->work[TAIL_IDX] - i) + 30) % 30; - Matrix_Translate(this->blastTailPos[tailIdx].x, this->blastTailPos[tailIdx].y, - this->blastTailPos[tailIdx].z, MTXMODE_NEW); + globalCtx->state.gfxCtx, 0, ((pthis->work[CS_TIMER_1] * 3) + (i * 10)) & 0x7F, + ((-pthis->work[CS_TIMER_1] * 15) + (i * 50)) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + tailIdx = ((pthis->work[TAIL_IDX] - i) + 30) % 30; + Matrix_Translate(pthis->blastTailPos[tailIdx].x, pthis->blastTailPos[tailIdx].y, + pthis->blastTailPos[tailIdx].z, MTXMODE_NEW); scaleFactor = 1.0f - (i * 0.09f); - Matrix_Scale(this->actor.scale.x * scaleFactor, this->actor.scale.y * scaleFactor, - this->actor.scale.z * scaleFactor, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * scaleFactor, pthis->actor.scale.y * scaleFactor, + pthis->actor.scale.z * scaleFactor, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 8865), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4493,19 +4493,19 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { break; case TW_ICE_BLAST: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s8)this->workf[TAIL_ALPHA]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s8)pthis->workf[TAIL_ALPHA]); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); for (i = 9; i >= 0; i--) { gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll( - globalCtx->state.gfxCtx, 0, ((this->work[CS_TIMER_1] * 3) + (i * 0xA)) & 0x7F, - (u8)((-this->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - tailIdx = ((this->work[TAIL_IDX] - i) + 30) % 30; - Matrix_Translate(this->blastTailPos[tailIdx].x, this->blastTailPos[tailIdx].y, - this->blastTailPos[tailIdx].z, MTXMODE_NEW); + globalCtx->state.gfxCtx, 0, ((pthis->work[CS_TIMER_1] * 3) + (i * 0xA)) & 0x7F, + (u8)((-pthis->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + tailIdx = ((pthis->work[TAIL_IDX] - i) + 30) % 30; + Matrix_Translate(pthis->blastTailPos[tailIdx].x, pthis->blastTailPos[tailIdx].y, + pthis->blastTailPos[tailIdx].z, MTXMODE_NEW); scaleFactor = 1.0f - (i * 0.09f); - Matrix_Scale(this->actor.scale.x * scaleFactor, this->actor.scale.y * scaleFactor, - this->actor.scale.z * scaleFactor, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * scaleFactor, pthis->actor.scale.y * scaleFactor, + pthis->actor.scale.z * scaleFactor, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 9004), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4522,7 +4522,7 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BossTw* this = (BossTw*)thisx; + BossTw* pthis = (BossTw*)thisx; f32 scaleFactor; s16 tailIdx; s16 i; @@ -4531,41 +4531,41 @@ void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { func_80093D84(globalCtx->state.gfxCtx); - if (this->actor.params == TW_DEATHBALL_KOUME) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s8)this->workf[TAIL_ALPHA]); + if (pthis->actor.params == TW_DEATHBALL_KOUME) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s8)pthis->workf[TAIL_ALPHA]); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); for (i = 9; i >= 0; i--) { gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (((this->work[CS_TIMER_1] * 3) + (i * 0xA))) & 0x7F, - (u8)((-this->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (((pthis->work[CS_TIMER_1] * 3) + (i * 0xA))) & 0x7F, + (u8)((-pthis->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - tailIdx = ((this->work[TAIL_IDX] - i) + 30) % 30; - Matrix_Translate(this->blastTailPos[tailIdx].x, this->blastTailPos[tailIdx].y, - this->blastTailPos[tailIdx].z, MTXMODE_NEW); + tailIdx = ((pthis->work[TAIL_IDX] - i) + 30) % 30; + Matrix_Translate(pthis->blastTailPos[tailIdx].x, pthis->blastTailPos[tailIdx].y, + pthis->blastTailPos[tailIdx].z, MTXMODE_NEW); scaleFactor = (1.0f - (i * 0.09f)); - Matrix_Scale(this->actor.scale.x * scaleFactor, this->actor.scale.y * scaleFactor, - this->actor.scale.z * scaleFactor, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * scaleFactor, pthis->actor.scale.y * scaleFactor, + pthis->actor.scale.z * scaleFactor, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 9071), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A430)); } } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s8)this->workf[TAIL_ALPHA]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s8)pthis->workf[TAIL_ALPHA]); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); for (i = 9; i >= 0; i--) { gSPSegment(POLY_XLU_DISP++, 8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (((this->work[CS_TIMER_1] * 3) + (i * 0xA))) & 0x7F, - (u8)((-this->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (((pthis->work[CS_TIMER_1] * 3) + (i * 0xA))) & 0x7F, + (u8)((-pthis->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - tailIdx = ((this->work[TAIL_IDX] - i) + 30) % 30; - Matrix_Translate(this->blastTailPos[tailIdx].x, this->blastTailPos[tailIdx].y, - this->blastTailPos[tailIdx].z, MTXMODE_NEW); + tailIdx = ((pthis->work[TAIL_IDX] - i) + 30) % 30; + Matrix_Translate(pthis->blastTailPos[tailIdx].x, pthis->blastTailPos[tailIdx].y, + pthis->blastTailPos[tailIdx].z, MTXMODE_NEW); scaleFactor = (1.0f - (i * 0.09f)); - Matrix_Scale(this->actor.scale.x * scaleFactor, this->actor.scale.y * scaleFactor, - this->actor.scale.z * scaleFactor, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * scaleFactor, pthis->actor.scale.y * scaleFactor, + pthis->actor.scale.z * scaleFactor, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_tw.c", 9107), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4582,7 +4582,7 @@ void BossTw_UpdateEffects(GlobalContext* globalCtx) { { 100, 100, 100 }, { 255, 255, 255 }, { 150, 150, 150 }, { 255, 255, 255 }, }; Vec3f sp11C; - BossTwEffect* eff = globalCtx->specialEffects; + BossTwEffect* eff = (BossTwEffect*)globalCtx->specialEffects; Player* player = GET_PLAYER(globalCtx); u8 sp113 = 0; s16 i; @@ -4923,7 +4923,7 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); s16 phi_s4; - BossTwEffect* currentEffect = globalCtx->specialEffects; + BossTwEffect* currentEffect = (BossTwEffect*)globalCtx->specialEffects; BossTwEffect* effectHead; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; @@ -5130,46 +5130,46 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_boss_tw.c", 9920); } -void BossTw_TwinrovaSetupArriveAtTarget(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaArriveAtTarget; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, -3.0f); - this->work[CS_TIMER_1] = Rand_ZeroFloat(100.0f); - this->timers[1] = 25; - this->rotateSpeed = 0.0f; +void BossTw_TwinrovaSetupArriveAtTarget(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaArriveAtTarget; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_032BF8, -3.0f); + pthis->work[CS_TIMER_1] = Rand_ZeroFloat(100.0f); + pthis->timers[1] = 25; + pthis->rotateSpeed = 0.0f; } -void BossTw_TwinrovaArriveAtTarget(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.1f, fabsf(this->actor.velocity.x) * 1.5f); - Math_ApproachF(&this->actor.world.pos.y, this->targetPos.y, 0.1f, fabsf(this->actor.velocity.y) * 1.5f); - Math_ApproachF(&this->targetPos.y, 380.0f, 1.0f, 2.0f); - Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.1f, fabsf(this->actor.velocity.z) * 1.5f); +void BossTw_TwinrovaArriveAtTarget(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.world.pos.x, pthis->targetPos.x, 0.1f, fabsf(pthis->actor.velocity.x) * 1.5f); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetPos.y, 0.1f, fabsf(pthis->actor.velocity.y) * 1.5f); + Math_ApproachF(&pthis->targetPos.y, 380.0f, 1.0f, 2.0f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->targetPos.z, 0.1f, fabsf(pthis->actor.velocity.z) * 1.5f); - if (this->timers[1] == 1) { - BossTw_TwinrovaSetupChargeBlast(this, globalCtx); + if (pthis->timers[1] == 1) { + BossTw_TwinrovaSetupChargeBlast(pthis, globalCtx); } - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->rotateSpeed); - Math_ApproachF(&this->rotateSpeed, 4096.0f, 1.0f, 350.0f); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, pthis->rotateSpeed); + Math_ApproachF(&pthis->rotateSpeed, 4096.0f, 1.0f, 350.0f); } -void BossTw_TwinrovaSetupChargeBlast(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaChargeBlast; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_036FBC, -5.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_036FBC); - this->csState1 = 0; +void BossTw_TwinrovaSetupChargeBlast(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaChargeBlast; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_036FBC, -5.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_036FBC); + pthis->csState1 = 0; } -void BossTw_TwinrovaChargeBlast(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void BossTw_TwinrovaChargeBlast(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.03f, fabsf(this->actor.velocity.x) * 1.5f); - Math_ApproachF(&this->actor.world.pos.y, this->targetPos.y, 0.03f, fabsf(this->actor.velocity.y) * 1.5f); - Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.03f, fabsf(this->actor.velocity.z) * 1.5f); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000); + Math_ApproachF(&pthis->actor.world.pos.x, pthis->targetPos.x, 0.03f, fabsf(pthis->actor.velocity.x) * 1.5f); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetPos.y, 0.03f, fabsf(pthis->actor.velocity.y) * 1.5f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->targetPos.z, 0.03f, fabsf(pthis->actor.velocity.z) * 1.5f); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x1000); - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - if ((s8)this->actor.colChkInfo.health < 10) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + if ((s8)pthis->actor.colChkInfo.health < 10) { sTwinrovaBlastType = Rand_ZeroFloat(1.99f); } else { if (++sFixedBlatSeq >= 4) { @@ -5180,46 +5180,46 @@ void BossTw_TwinrovaChargeBlast(BossTw* this, GlobalContext* globalCtx) { sTwinrovaBlastType = sFixedBlastType; } - BossTw_TwinrovaSetupShootBlast(this, globalCtx); + BossTw_TwinrovaSetupShootBlast(pthis, globalCtx); } } -void BossTw_TwinrovaSetupShootBlast(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaShootBlast; +void BossTw_TwinrovaSetupShootBlast(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaShootBlast; if (sTwinrovaBlastType == 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_022700, 0.0f); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_022700, 0.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_023750, 0.0f); + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_023750, 0.0f); } - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_023750); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_023750); } -void BossTw_TwinrovaShootBlast(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaShootBlast(BossTw* pthis, GlobalContext* globalCtx) { BossTw* twMagic; Vec3f* magicSpawnPos; s32 magicParams; s16 i; - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_THROW_MASIC); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_YOUNG_SHOOTVC); + if (Animation_OnFrame(&pthis->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_THROW_MASIC); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_YOUNG_SHOOTVC); } - if (Animation_OnFrame(&this->skelAnime, 12.0f)) { + if (Animation_OnFrame(&pthis->skelAnime, 12.0f)) { if (sTwinrovaBlastType != 0) { magicParams = TW_FIRE_BLAST; - magicSpawnPos = &this->rightScepterPos; + magicSpawnPos = &pthis->rightScepterPos; } else { magicParams = TW_ICE_BLAST; - magicSpawnPos = &this->leftScepterPos; + magicSpawnPos = &pthis->leftScepterPos; } twMagic = - (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, magicSpawnPos->x, + (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_TW, magicSpawnPos->x, magicSpawnPos->y, magicSpawnPos->z, 0, 0, 0, magicParams); if (twMagic != NULL) { @@ -5242,81 +5242,81 @@ void BossTw_TwinrovaShootBlast(BossTw* this, GlobalContext* globalCtx) { } } - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - BossTw_TwinrovaSetupDoneBlastShoot(this, globalCtx); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + BossTw_TwinrovaSetupDoneBlastShoot(pthis, globalCtx); } - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x1000); } -void BossTw_TwinrovaSetupDoneBlastShoot(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaDoneBlastShoot; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, -10.0f); - this->timers[1] = 60; +void BossTw_TwinrovaSetupDoneBlastShoot(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaDoneBlastShoot; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_032BF8, -10.0f); + pthis->timers[1] = 60; } -void BossTw_TwinrovaDoneBlastShoot(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void BossTw_TwinrovaDoneBlastShoot(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - if (this->timers[1] == 0 && D_8094C870 == 0) { + if (pthis->timers[1] == 0 && D_8094C870 == 0) { if (sTwinrovaPtr->timers[2] == 0) { - BossTw_TwinrovaSetupFly(this, globalCtx); + BossTw_TwinrovaSetupFly(pthis, globalCtx); } else { - BossTw_TwinrovaSetupLaugh(this, globalCtx); + BossTw_TwinrovaSetupLaugh(pthis, globalCtx); } } D_8094C870 = 0; - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x1000); } -void BossTw_TwinrovaDamage(BossTw* this, GlobalContext* globalCtx, u8 damage) { - if (this->actionFunc != BossTw_TwinrovaStun) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_0338F0, -15.0f); - this->timers[0] = 150; - this->timers[1] = 20; - this->csState1 = 0; - this->actor.velocity.y = 0.0f; +void BossTw_TwinrovaDamage(BossTw* pthis, GlobalContext* globalCtx, u8 damage) { + if (pthis->actionFunc != BossTw_TwinrovaStun) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_0338F0, -15.0f); + pthis->timers[0] = 150; + pthis->timers[1] = 20; + pthis->csState1 = 0; + pthis->actor.velocity.y = 0.0f; } else { - this->work[FOG_TIMER] = 10; - this->work[INVINC_TIMER] = 20; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_024374, -3.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_024374); - this->csState1 = 1; + pthis->work[FOG_TIMER] = 10; + pthis->work[INVINC_TIMER] = 20; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_024374, -3.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_024374); + pthis->csState1 = 1; - if ((s8)(this->actor.colChkInfo.health -= damage) < 0) { - this->actor.colChkInfo.health = 0; + if ((s8)(pthis->actor.colChkInfo.health -= damage) < 0) { + pthis->actor.colChkInfo.health = 0; } - if ((s8)this->actor.colChkInfo.health <= 0) { - BossTw_TwinrovaSetupDeathCS(this, globalCtx); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_YOUNG_DEAD); + if ((s8)pthis->actor.colChkInfo.health <= 0) { + BossTw_TwinrovaSetupDeathCS(pthis, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_YOUNG_DEAD); return; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_YOUNG_DAMAGE2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_CUTBODY); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_YOUNG_DAMAGE2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_CUTBODY); } - this->actionFunc = BossTw_TwinrovaStun; + pthis->actionFunc = BossTw_TwinrovaStun; } -void BossTw_TwinrovaStun(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaStun(BossTw* pthis, GlobalContext* globalCtx) { s16 cloudType; - this->unk_5F8 = 1; - this->actor.flags |= ACTOR_FLAG_10; + pthis->unk_5F8 = 1; + pthis->actor.flags |= ACTOR_FLAG_10; cloudType = sTwinrovaBlastType == 0 ? 3 : 2; - if ((this->work[CS_TIMER_1] % 8) == 0) { + if ((pthis->work[CS_TIMER_1] % 8) == 0) { Vec3f pos; Vec3f velocity; Vec3f accel; - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(20.0f); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(40.0f) + 20; - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(20.0f); + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(20.0f); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(40.0f) + 20; + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(20.0f); velocity.x = 0.0f; velocity.y = 0.0f; velocity.z = 0.0f; @@ -5326,62 +5326,62 @@ void BossTw_TwinrovaStun(BossTw* this, GlobalContext* globalCtx) { BossTw_AddDmgCloud(globalCtx, cloudType, &pos, &velocity, &accel, Rand_ZeroFloat(5.0f) + 10.0f, 0, 0, 150); } - SkelAnime_Update(&this->skelAnime); - this->work[UNK_S8] += 20; + SkelAnime_Update(&pthis->skelAnime); + pthis->work[UNK_S8] += 20; - if (this->work[UNK_S8] > 255) { - this->work[UNK_S8] = 255; + if (pthis->work[UNK_S8] > 255) { + pthis->work[UNK_S8] = 255; } - Math_ApproachF(&this->workf[UNK_F12], 0.0f, 1.0f, 0.05f); - this->actor.world.pos.y += this->actor.velocity.y; - Math_ApproachF(&this->actor.velocity.y, -5.0f, 1.0f, 0.5f); - this->actor.world.pos.y -= 30.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 4); - this->actor.world.pos.y += 30.0f; + Math_ApproachF(&pthis->workf[UNK_F12], 0.0f, 1.0f, 0.05f); + pthis->actor.world.pos.y += pthis->actor.velocity.y; + Math_ApproachF(&pthis->actor.velocity.y, -5.0f, 1.0f, 0.5f); + pthis->actor.world.pos.y -= 30.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 4); + pthis->actor.world.pos.y += 30.0f; - if (this->csState1 == 0) { - if (this->timers[1] == 0) { - this->csState1 = 1; - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0343B4); - Animation_Change(&this->skelAnime, &object_tw_Anim_0343B4, 1.0f, 0.0f, this->workf[ANIM_SW_TGT], 3, 0.0f); + if (pthis->csState1 == 0) { + if (pthis->timers[1] == 0) { + pthis->csState1 = 1; + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_0343B4); + Animation_Change(&pthis->skelAnime, &object_tw_Anim_0343B4, 1.0f, 0.0f, pthis->workf[ANIM_SW_TGT], 3, 0.0f); } - } else if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - this->workf[ANIM_SW_TGT] = 1000.0f; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_035030, 0.0f); + } else if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + pthis->workf[ANIM_SW_TGT] = 1000.0f; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_035030, 0.0f); } - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 0.0f; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 0.0f; } - if (this->timers[0] == 0) { - BossTw_TwinrovaSetupGetUp(this, globalCtx); + if (pthis->timers[0] == 0) { + BossTw_TwinrovaSetupGetUp(pthis, globalCtx); } } -void BossTw_TwinrovaSetupGetUp(BossTw* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_035988, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_035988); - this->actionFunc = BossTw_TwinrovaGetUp; - this->timers[0] = 50; +void BossTw_TwinrovaSetupGetUp(BossTw* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_035988, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_035988); + pthis->actionFunc = BossTw_TwinrovaGetUp; + pthis->timers[0] = 50; } -void BossTw_TwinrovaGetUp(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.world.pos.y, this->targetPos.y, 0.05f, 5.0f); +void BossTw_TwinrovaGetUp(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetPos.y, 0.05f, 5.0f); - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - this->workf[ANIM_SW_TGT] = 1000.0f; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, 0.0f); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + pthis->workf[ANIM_SW_TGT] = 1000.0f; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_032BF8, 0.0f); } - if (this->timers[0] == 0) { - BossTw_TwinrovaSetupFly(this, globalCtx); + if (pthis->timers[0] == 0) { + BossTw_TwinrovaSetupFly(pthis, globalCtx); } } -void BossTw_TwinrovaSetupFly(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaSetupFly(BossTw* pthis, GlobalContext* globalCtx) { f32 xDiff; f32 zDiff; f32 yDiff; @@ -5389,28 +5389,28 @@ void BossTw_TwinrovaSetupFly(BossTw* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); do { - this->work[TW_PLLR_IDX] += (s16)(((s16)Rand_ZeroFloat(2.99f)) + 1); - this->work[TW_PLLR_IDX] %= 4; - this->targetPos = sTwinrovaPillarPos[this->work[TW_PLLR_IDX]]; - xDiff = this->targetPos.x - player->actor.world.pos.x; - zDiff = this->targetPos.z - player->actor.world.pos.z; + pthis->work[TW_PLLR_IDX] += (s16)(((s16)Rand_ZeroFloat(2.99f)) + 1); + pthis->work[TW_PLLR_IDX] %= 4; + pthis->targetPos = sTwinrovaPillarPos[pthis->work[TW_PLLR_IDX]]; + xDiff = pthis->targetPos.x - player->actor.world.pos.x; + zDiff = pthis->targetPos.z - player->actor.world.pos.z; xzDist = SQ(xDiff) + SQ(zDiff); } while (!(xzDist > SQ(300.0f))); - this->targetPos.y = 480.0f; - xDiff = this->targetPos.x - this->actor.world.pos.x; - yDiff = this->targetPos.y - this->actor.world.pos.y; - zDiff = this->targetPos.z - this->actor.world.pos.z; - this->actionFunc = BossTw_TwinrovaFly; - this->rotateSpeed = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); + pthis->targetPos.y = 480.0f; + xDiff = pthis->targetPos.x - pthis->actor.world.pos.x; + yDiff = pthis->targetPos.y - pthis->actor.world.pos.y; + zDiff = pthis->targetPos.z - pthis->actor.world.pos.z; + pthis->actionFunc = BossTw_TwinrovaFly; + pthis->rotateSpeed = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - this->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI); - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, -10.0f); + pthis->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI); + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_032BF8, -10.0f); } -void BossTw_TwinrovaFly(BossTw* this, GlobalContext* globalCtx) { +void BossTw_TwinrovaFly(BossTw* pthis, GlobalContext* globalCtx) { f32 xDiff; f32 yDiff; f32 zDiff; @@ -5418,68 +5418,68 @@ void BossTw_TwinrovaFly(BossTw* this, GlobalContext* globalCtx) { f32 yaw; f32 xzDist; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); - SkelAnime_Update(&this->skelAnime); - xDiff = this->targetPos.x - this->actor.world.pos.x; - yDiff = this->targetPos.y - this->actor.world.pos.y; - zDiff = this->targetPos.z - this->actor.world.pos.z; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_FLY - SFX_FLAG); + SkelAnime_Update(&pthis->skelAnime); + xDiff = pthis->targetPos.x - pthis->actor.world.pos.x; + yDiff = pthis->targetPos.y - pthis->actor.world.pos.y; + zDiff = pthis->targetPos.z - pthis->actor.world.pos.z; // Convert from radians to degrees, then degrees to binary angle yaw = (s16)(Math_FAtan2F(xDiff, zDiff) * ((180.0f / M_PI) * (65536.0f / 360.0f))); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - Math_ApproachS(&this->actor.world.rot.x, + Math_ApproachS(&pthis->actor.world.rot.x, (f32)(s16)(Math_FAtan2F(yDiff, xzDist) * ((180.0f / M_PI) * (65536.0f / 360.0f))), 0xA, - this->rotateSpeed); - Math_ApproachS(&this->actor.world.rot.y, yaw, 0xA, this->rotateSpeed); - Math_ApproachS(&this->actor.shape.rot.y, yaw, 0xA, this->rotateSpeed); - Math_ApproachF(&this->rotateSpeed, 2000.0f, 1.0f, 100.0f); - Math_ApproachF(&this->actor.speedXZ, 30.0f, 1.0f, 2.0f); - func_8002D908(&this->actor); - Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.1f, fabsf(this->actor.velocity.x) * 1.5f); - Math_ApproachF(&this->actor.world.pos.y, this->targetPos.y, 0.1f, fabsf(this->actor.velocity.y) * 1.5f); - Math_ApproachF(&this->targetPos.y, 380.0f, 1.0f, 2.0f); - Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.1f, fabsf(this->actor.velocity.z) * 1.5f); + pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.world.rot.y, yaw, 0xA, pthis->rotateSpeed); + Math_ApproachS(&pthis->actor.shape.rot.y, yaw, 0xA, pthis->rotateSpeed); + Math_ApproachF(&pthis->rotateSpeed, 2000.0f, 1.0f, 100.0f); + Math_ApproachF(&pthis->actor.speedXZ, 30.0f, 1.0f, 2.0f); + func_8002D908(&pthis->actor); + Math_ApproachF(&pthis->actor.world.pos.x, pthis->targetPos.x, 0.1f, fabsf(pthis->actor.velocity.x) * 1.5f); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetPos.y, 0.1f, fabsf(pthis->actor.velocity.y) * 1.5f); + Math_ApproachF(&pthis->targetPos.y, 380.0f, 1.0f, 2.0f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->targetPos.z, 0.1f, fabsf(pthis->actor.velocity.z) * 1.5f); if (xzDist < 200.0f) { - BossTw_TwinrovaSetupArriveAtTarget(this, globalCtx); + BossTw_TwinrovaSetupArriveAtTarget(pthis, globalCtx); } } -void BossTw_TwinrovaSetupSpin(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaSpin; - Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, 0.0f); - this->timers[0] = 20; - this->actor.speedXZ = 0.0f; +void BossTw_TwinrovaSetupSpin(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaSpin; + Animation_MorphToLoop(&pthis->skelAnime, &object_tw_Anim_032BF8, 0.0f); + pthis->timers[0] = 20; + pthis->actor.speedXZ = 0.0f; } -void BossTw_TwinrovaSpin(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timers[0] != 0) { - this->collider.base.colType = COLTYPE_METAL; - this->actor.shape.rot.y -= 0x3000; +void BossTw_TwinrovaSpin(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timers[0] != 0) { + pthis->collider.base.colType = COLTYPE_METAL; + pthis->actor.shape.rot.y -= 0x3000; - if ((this->timers[0] % 4) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_ROLL); + if ((pthis->timers[0] % 4) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_ROLL); } } else { - BossTw_TwinrovaSetupFly(this, globalCtx); + BossTw_TwinrovaSetupFly(pthis, globalCtx); } } -void BossTw_TwinrovaSetupLaugh(BossTw* this, GlobalContext* globalCtx) { - this->actionFunc = BossTw_TwinrovaLaugh; - Animation_MorphToPlayOnce(&this->skelAnime, &object_tw_Anim_03A2D0, 0.0f); - this->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_03A2D0); - this->actor.speedXZ = 0.0f; +void BossTw_TwinrovaSetupLaugh(BossTw* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = BossTw_TwinrovaLaugh; + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_tw_Anim_03A2D0, 0.0f); + pthis->workf[ANIM_SW_TGT] = Animation_GetLastFrame(&object_tw_Anim_03A2D0); + pthis->actor.speedXZ = 0.0f; } -void BossTw_TwinrovaLaugh(BossTw* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void BossTw_TwinrovaLaugh(BossTw* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_YOUNG_LAUGH); + if (Animation_OnFrame(&pthis->skelAnime, 10.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_YOUNG_LAUGH); } - if (Animation_OnFrame(&this->skelAnime, this->workf[ANIM_SW_TGT])) { - BossTw_TwinrovaSetupFly(this, globalCtx); + if (Animation_OnFrame(&pthis->skelAnime, pthis->workf[ANIM_SW_TGT])) { + BossTw_TwinrovaSetupFly(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h index 575997c26..e67aba054 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h @@ -6,7 +6,7 @@ struct BossTw; -typedef void (*BossTwActionFunc)(struct BossTw* this, GlobalContext* globalCtx); +typedef void (*BossTwActionFunc)(BossTw* pthis, GlobalContext* globalCtx); typedef enum { /* 0 */ CS_TIMER_1, diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.cpp similarity index 55% rename from src/overlays/actors/ovl_Boss_Va/z_boss_va.c rename to src/overlays/actors/ovl_Boss_Va/z_boss_va.cpp index aa233ace7..45d0c2d28 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.cpp @@ -31,7 +31,7 @@ #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) -#define GET_BODY(this) ((BossVa*)(this)->actor.parent) +#define GET_BODY(pthis) ((BossVa*)(pthis)->actor.parent) #define vaGorePulse offset.x #define vaGorePulseRate offset.y #define vaBariUnused headRot @@ -140,75 +140,75 @@ void BossVa_UpdateEffects(GlobalContext* globalCtx); void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx); void BossVa_DrawDoor(GlobalContext* globalCtx, s16 scale); -void BossVa_SetupIntro(BossVa* this); -void BossVa_SetupBodyPhase1(BossVa* this); -void BossVa_SetupBodyPhase2(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupBodyPhase3(BossVa* this); -void BossVa_SetupBodyPhase4(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupBodyDeath(BossVa* this, GlobalContext* globalCtx); +void BossVa_SetupIntro(BossVa* pthis); +void BossVa_SetupBodyPhase1(BossVa* pthis); +void BossVa_SetupBodyPhase2(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupBodyPhase3(BossVa* pthis); +void BossVa_SetupBodyPhase4(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupBodyDeath(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_SetupSupportIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupSupportAttached(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupSupportCut(BossVa* this, GlobalContext* globalCtx); +void BossVa_SetupSupportIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupSupportAttached(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupSupportCut(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_SetupZapperIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupZapperAttack(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupZapperEnraged(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupZapperDamaged(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupZapperHold(BossVa* this, GlobalContext* globalCtx); +void BossVa_SetupZapperIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupZapperAttack(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupZapperEnraged(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupZapperDamaged(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupZapperHold(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_SetupStump(BossVa* this, GlobalContext* globalCtx); +void BossVa_SetupStump(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_SetupDoor(BossVa* this, GlobalContext* globalCtx); +void BossVa_SetupDoor(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_SetupBariIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupBariPhase2Attack(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupBariPhase3Attack(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupBariPhase3Stunned(BossVa* this, GlobalContext* globalCtx); -void BossVa_SetupBariDeath(BossVa* this); +void BossVa_SetupBariIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupBariPhase2Attack(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupBariPhase3Attack(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupBariPhase3Stunned(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SetupBariDeath(BossVa* pthis); -void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_BodyPhase1(BossVa* this, GlobalContext* globalCtx); -void BossVa_BodyPhase2(BossVa* this, GlobalContext* globalCtx); -void BossVa_BodyPhase3(BossVa* this, GlobalContext* globalCtx); -void BossVa_BodyPhase4(BossVa* this, GlobalContext* globalCtx); -void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx); +void BossVa_BodyIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BodyPhase1(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BodyPhase2(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BodyPhase3(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BodyPhase4(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BodyDeath(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_SupportIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_SupportAttached(BossVa* this, GlobalContext* globalCtx); -void BossVa_SupportCut(BossVa* this, GlobalContext* globalCtx); +void BossVa_SupportIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SupportAttached(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_SupportCut(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_ZapperIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_ZapperAttack(BossVa* this, GlobalContext* globalCtx); -void BossVa_ZapperEnraged(BossVa* this, GlobalContext* globalCtx); -void BossVa_ZapperDamaged(BossVa* this, GlobalContext* globalCtx); -void BossVa_ZapperHold(BossVa* this, GlobalContext* globalCtx); -void BossVa_ZapperDeath(BossVa* this, GlobalContext* globalCtx); +void BossVa_ZapperIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_ZapperAttack(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_ZapperEnraged(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_ZapperDamaged(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_ZapperHold(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_ZapperDeath(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_Stump(BossVa* this, GlobalContext* globalCtx); +void BossVa_Stump(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_Door(BossVa* this, GlobalContext* globalCtx); +void BossVa_Door(BossVa* pthis, GlobalContext* globalCtx); -void BossVa_BariIntro(BossVa* this, GlobalContext* globalCtx); -void BossVa_BariPhase3Attack(BossVa* this, GlobalContext* globalCtx); -void BossVa_BariPhase2Attack(BossVa* this, GlobalContext* globalCtx); -void BossVa_BariPhase3Stunned(BossVa* this, GlobalContext* globalCtx); -void BossVa_BariDeath(BossVa* this, GlobalContext* globalCtx); +void BossVa_BariIntro(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BariPhase3Attack(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BariPhase2Attack(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BariPhase3Stunned(BossVa* pthis, GlobalContext* globalCtx); +void BossVa_BariDeath(BossVa* pthis, GlobalContext* globalCtx); void BossVa_SpawnBloodSplatter(GlobalContext* globalCtx, BossVaEffect* effect, Vec3f* pos, s16 yaw, s16 scale); void BossVa_SpawnGore(GlobalContext* globalCtx, BossVaEffect* effect, Vec3f* pos, s16 yaw, s16 scale); -void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* offset, s16 scale, u8 mode); -void BossVa_SpawnZapperCharge(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* pos, Vec3s* rot, +void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* offset, s16 scale, u8 mode); +void BossVa_SpawnZapperCharge(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* pos, Vec3s* rot, s16 scale, u8 mode); -void BossVa_SpawnTumor(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* offset, s16 scale, u8 mode); -void BossVa_SpawnSparkBall(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* offset, s16 scale, +void BossVa_SpawnTumor(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* offset, s16 scale, u8 mode); +void BossVa_SpawnSparkBall(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* offset, s16 scale, u8 mode); void BossVa_SpawnBloodDroplets(GlobalContext* globalCtx, BossVaEffect* effect, Vec3f* pos, s16 scale, s16 phase, s16 yaw); -void BossVa_Tumor(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, f32 xzSpread, f32 ySpread, u8 mode, +void BossVa_Tumor(GlobalContext* globalCtx, BossVa* pthis, s32 count, s16 scale, f32 xzSpread, f32 ySpread, u8 mode, f32 range, u8 fixed); -const ActorInit Boss_Va_InitVars = { +ActorInit Boss_Va_InitVars = { ACTOR_BOSS_VA, ACTORCAT_BOSS, FLAGS, @@ -412,43 +412,43 @@ static Vec3s sZapperRot; static u16 sPhase2Timer; static s8 sPhase4HP; -void BossVa_SetupAction(BossVa* this, BossVaActionFunc func) { - this->actionFunc = func; +void BossVa_SetupAction(BossVa* pthis, BossVaActionFunc func) { + pthis->actionFunc = func; } -void BossVa_AttachToBody(BossVa* this) { - BossVa* vaBody = GET_BODY(this); +void BossVa_AttachToBody(BossVa* pthis) { + BossVa* vaBody = GET_BODY(pthis); Matrix_Translate(vaBody->actor.world.pos.x, vaBody->actor.world.pos.y, vaBody->actor.world.pos.z, MTXMODE_NEW); Matrix_RotateZYX(vaBody->actor.shape.rot.x, 0, vaBody->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultVec3f(&sInitPosOffsets[this->actor.params], &this->actor.world.pos); + Matrix_MultVec3f(&sInitPosOffsets[pthis->actor.params], &pthis->actor.world.pos); - switch (this->actor.params) { + switch (pthis->actor.params) { case BOSSVA_SUPPORT_1: case BOSSVA_SUPPORT_2: case BOSSVA_SUPPORT_3: - if (!this->onCeiling) { - this->actor.shape.rot.x = sInitRot[this->actor.params].x + vaBody->actor.shape.rot.x; - this->actor.shape.rot.y = sInitRot[this->actor.params].y; - this->actor.shape.rot.z = sInitRot[this->actor.params].z + vaBody->actor.shape.rot.z; + if (!pthis->onCeiling) { + pthis->actor.shape.rot.x = sInitRot[pthis->actor.params].x + vaBody->actor.shape.rot.x; + pthis->actor.shape.rot.y = sInitRot[pthis->actor.params].y; + pthis->actor.shape.rot.z = sInitRot[pthis->actor.params].z + vaBody->actor.shape.rot.z; } break; case BOSSVA_ZAPPER_1: case BOSSVA_ZAPPER_2: case BOSSVA_ZAPPER_3: - this->actor.shape.rot.y = sInitRot[this->actor.params].y; - this->actor.shape.rot.x = (sInitRot[this->actor.params].x + - (s16)(Math_CosS(sInitRot[this->actor.params].y) * vaBody->actor.shape.rot.x)) - - (s16)(Math_SinS(sInitRot[this->actor.params].y) * vaBody->actor.shape.rot.z); - this->actor.shape.rot.z = (s16)(Math_CosS(sInitRot[this->actor.params].y) * vaBody->actor.shape.rot.z) + - (sInitRot[this->actor.params].z + - (s16)(Math_SinS(sInitRot[this->actor.params].y) * vaBody->actor.shape.rot.x)); + pthis->actor.shape.rot.y = sInitRot[pthis->actor.params].y; + pthis->actor.shape.rot.x = (sInitRot[pthis->actor.params].x + + (s16)(Math_CosS(sInitRot[pthis->actor.params].y) * vaBody->actor.shape.rot.x)) - + (s16)(Math_SinS(sInitRot[pthis->actor.params].y) * vaBody->actor.shape.rot.z); + pthis->actor.shape.rot.z = (s16)(Math_CosS(sInitRot[pthis->actor.params].y) * vaBody->actor.shape.rot.z) + + (sInitRot[pthis->actor.params].z + + (s16)(Math_SinS(sInitRot[pthis->actor.params].y) * vaBody->actor.shape.rot.x)); break; } - this->actor.world.rot = this->actor.shape.rot; - this->actor.shape.yOffset = GET_BODY(this)->actor.shape.yOffset; + pthis->actor.world.rot = pthis->actor.shape.rot; + pthis->actor.shape.yOffset = GET_BODY(pthis)->actor.shape.yOffset; } void BossVa_BloodDroplets(GlobalContext* globalCtx, Vec3f* pos, s16 phase, s16 yaw) { @@ -487,7 +487,7 @@ void BossVa_Gore(GlobalContext* globalCtx, BossVaEffect* src, s16 yaw, s16 scale } } -void BossVa_Spark(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, f32 xzSpread, f32 ySpread, u8 mode, +void BossVa_Spark(GlobalContext* globalCtx, BossVa* pthis, s32 count, s16 scale, f32 xzSpread, f32 ySpread, u8 mode, f32 range, u8 fixed) { s32 i; s16 index; @@ -499,14 +499,14 @@ void BossVa_Spark(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, } else { index = range - 0.6f; } - offset.x = Rand_CenteredFloat(xzSpread) + this->effectPos[index].x - this->actor.world.pos.x; - offset.y = Rand_CenteredFloat(ySpread) + this->effectPos[index].y - this->actor.world.pos.y; - offset.z = Rand_CenteredFloat(xzSpread) + this->effectPos[index].z - this->actor.world.pos.z; - BossVa_SpawnSpark(globalCtx, sVaEffects, this, &offset, scale, mode); + offset.x = Rand_CenteredFloat(xzSpread) + pthis->effectPos[index].x - pthis->actor.world.pos.x; + offset.y = Rand_CenteredFloat(ySpread) + pthis->effectPos[index].y - pthis->actor.world.pos.y; + offset.z = Rand_CenteredFloat(xzSpread) + pthis->effectPos[index].z - pthis->actor.world.pos.z; + BossVa_SpawnSpark(globalCtx, sVaEffects, pthis, &offset, scale, mode); } } -void BossVa_Tumor(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, f32 xzSpread, f32 ySpread, u8 mode, +void BossVa_Tumor(GlobalContext* globalCtx, BossVa* pthis, s32 count, s16 scale, f32 xzSpread, f32 ySpread, u8 mode, f32 range, u8 fixed) { s16 index; s32 i; @@ -519,10 +519,10 @@ void BossVa_Tumor(GlobalContext* globalCtx, BossVa* this, s32 count, s16 scale, index = range - 0.6f; } - offset.x = Rand_CenteredFloat(xzSpread) + this->effectPos[index].x - this->actor.world.pos.x; - offset.y = Rand_CenteredFloat(ySpread) + this->effectPos[index].y - this->actor.world.pos.y; - offset.z = Rand_CenteredFloat(xzSpread) + this->effectPos[index].z - this->actor.world.pos.z; - BossVa_SpawnTumor(globalCtx, sVaEffects, this, &offset, scale, mode); + offset.x = Rand_CenteredFloat(xzSpread) + pthis->effectPos[index].x - pthis->actor.world.pos.x; + offset.y = Rand_CenteredFloat(ySpread) + pthis->effectPos[index].y - pthis->actor.world.pos.y; + offset.z = Rand_CenteredFloat(xzSpread) + pthis->effectPos[index].z - pthis->actor.world.pos.z; + BossVa_SpawnTumor(globalCtx, sVaEffects, pthis, &offset, scale, mode); } } @@ -569,7 +569,7 @@ EnBoom* BossVa_FindBoomerang(GlobalContext* globalCtx) { return NULL; } -void BossVa_KillBari(BossVa* this, GlobalContext* globalCtx) { +void BossVa_KillBari(BossVa* pthis, GlobalContext* globalCtx) { s32 i; s16 scale; Vec3f pos; @@ -577,10 +577,10 @@ void BossVa_KillBari(BossVa* this, GlobalContext* globalCtx) { Vec3f accel = { 0.0f, 0.0f, 0.0f }; for (i = 7; i >= 0; i--) { - pos.x = Rand_CenteredFloat(60.0f) + this->actor.world.pos.x; + pos.x = Rand_CenteredFloat(60.0f) + pthis->actor.world.pos.x; pos.y = - Rand_CenteredFloat(50.0f) + (this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y)); - pos.z = Rand_CenteredFloat(60.0f) + this->actor.world.pos.z; + Rand_CenteredFloat(50.0f) + (pthis->actor.world.pos.y + (pthis->actor.shape.yOffset * pthis->actor.scale.y)); + pos.z = Rand_CenteredFloat(60.0f) + pthis->actor.world.pos.z; velocity.y = Rand_ZeroOne() + 1.0f; scale = Rand_S16Offset(80, 100); if (Rand_ZeroOne() < 0.7f) { @@ -591,77 +591,77 @@ void BossVa_KillBari(BossVa* this, GlobalContext* globalCtx) { } sFightPhase++; - BossVa_SetupBariDeath(this); + BossVa_SetupBariDeath(pthis); } void BossVa_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; s32 i; s16 warpId; - Actor_SetScale(&this->actor, 0.1f); - this->actor.targetMode = 5; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.1f); + pthis->actor.targetMode = 5; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; - switch (this->actor.params) { + switch (pthis->actor.params) { case BOSSVA_BODY: - SkelAnime_Init(globalCtx, &this->skelAnime, &gBarinadeBodySkel, &gBarinadeBodyAnim, NULL, NULL, 0); - this->actor.flags |= ACTOR_FLAG_24; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBarinadeBodySkel, &gBarinadeBodyAnim, NULL, NULL, 0); + pthis->actor.flags |= ACTOR_FLAG_24; break; case BOSSVA_SUPPORT_1: case BOSSVA_SUPPORT_2: case BOSSVA_SUPPORT_3: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBarinadeSupportSkel, &gBarinadeSupportAttachedAnim, NULL, + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBarinadeSupportSkel, &gBarinadeSupportAttachedAnim, NULL, NULL, 0); break; case BOSSVA_ZAPPER_1: case BOSSVA_ZAPPER_2: case BOSSVA_ZAPPER_3: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBarinadeZapperSkel, &gBarinadeZapperIdleAnim, NULL, NULL, + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBarinadeZapperSkel, &gBarinadeZapperIdleAnim, NULL, NULL, 0); break; case BOSSVA_STUMP_1: case BOSSVA_STUMP_2: case BOSSVA_STUMP_3: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBarinadeStumpSkel, &gBarinadeStumpAnim, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBarinadeStumpSkel, &gBarinadeStumpAnim, NULL, NULL, 0); break; default: - this->actor.flags |= ACTOR_FLAG_24; - SkelAnime_Init(globalCtx, &this->skelAnime, &gBarinadeBariSkel, &gBarinadeBariAnim, NULL, NULL, 0); - this->actor.shape.yOffset = 400.0f; + pthis->actor.flags |= ACTOR_FLAG_24; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBarinadeBariSkel, &gBarinadeBariAnim, NULL, NULL, 0); + pthis->actor.shape.yOffset = 400.0f; break; case BOSSVA_DOOR: break; } - this->actor.focus.pos = this->actor.world.pos; - this->onCeiling = false; - this->actor.naviEnemyId = 0x14; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->onCeiling = false; + pthis->actor.naviEnemyId = 0x14; - switch (this->actor.params) { + switch (pthis->actor.params) { case BOSSVA_BODY: - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_VA, 0.0f, 80.0f, 400.0f, 0, 0, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_VA, 0.0f, 80.0f, 400.0f, 0, 0, 0, BOSSVA_DOOR); if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { warpId = ACTOR_EN_RU1; if (gSaveContext.eventChkInf[3] & 0x80) { warpId = ACTOR_DOOR_WARP1; } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, warpId, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, - 0); //! params could be WARP_DUNGEON_CHILD however this can also spawn Ru1 - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x + 160.0f, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, warpId, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, + 0); //! params could be WARP_DUNGEON_CHILD however pthis can also spawn Ru1 + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, pthis->actor.world.pos.x + 160.0f, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); sDoorState = 100; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - this->actor.colChkInfo.damageTable = sDamageTable; + pthis->actor.colChkInfo.damageTable = sDamageTable; sPhase2Timer = 0xFFFF; if (gSaveContext.eventChkInf[7] & 0x40) { sCsState = INTRO_CALL_BARI; sDoorState = 100; - func_8002DF54(globalCtx, &this->actor, 1); + func_8002DF54(globalCtx, &pthis->actor, 1); globalCtx->envCtx.screenFillColor[0] = 0xDC; globalCtx->envCtx.screenFillColor[1] = 0xDC; globalCtx->envCtx.screenFillColor[2] = 0xBE; @@ -677,15 +677,15 @@ void BossVa_Init(Actor* thisx, GlobalContext* globalCtx2) { sCameraNextAt.y = sCameraAt.y = 50.0f; sCameraNextAt.z = sCameraAt.z = -220.0f; Gameplay_CameraSetAtEye(globalCtx, sCsCamera, &sCameraAt, &sCameraEye); - this->timer = 20; + pthis->timer = 20; for (i = BOSSVA_BARI_LOWER_5; i >= BOSSVA_BARI_UPPER_1; i--) { Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_VA, - sInitPosOffsets[i].x + this->actor.world.pos.x, - sInitPosOffsets[i].y + this->actor.world.pos.y, - sInitPosOffsets[i].z + this->actor.world.pos.z, sInitRot[i].x + this->actor.world.rot.x, - sInitRot[i].y + this->actor.world.rot.y, sInitRot[i].z + this->actor.world.rot.z, i); + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_VA, + sInitPosOffsets[i].x + pthis->actor.world.pos.x, + sInitPosOffsets[i].y + pthis->actor.world.pos.y, + sInitPosOffsets[i].z + pthis->actor.world.pos.z, sInitRot[i].x + pthis->actor.world.rot.x, + sInitRot[i].y + pthis->actor.world.rot.y, sInitRot[i].z + pthis->actor.world.rot.z, i); } sCameraAtMaxVel = sCameraEyeMaxVel = sZeroVec; @@ -695,106 +695,106 @@ void BossVa_Init(Actor* thisx, GlobalContext* globalCtx2) { sDoorState = 5; } - this->zapHeadPos.x = 1.0f; - Collider_InitCylinder(globalCtx, &this->colliderBody); - Collider_SetCylinder(globalCtx, &this->colliderBody, &this->actor, &sCylinderInit); + pthis->zapHeadPos.x = 1.0f; + Collider_InitCylinder(globalCtx, &pthis->colliderBody); + Collider_SetCylinder(globalCtx, &pthis->colliderBody, &pthis->actor, &sCylinderInit); for (i = BOSSVA_ZAPPER_3; i >= BOSSVA_SUPPORT_1; i--) { Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_VA, - sInitPosOffsets[i].x + this->actor.world.pos.x, sInitPosOffsets[i].y + this->actor.world.pos.y, - sInitPosOffsets[i].z + this->actor.world.pos.z, sInitRot[i].x + this->actor.world.rot.x, - sInitRot[i].y + this->actor.world.rot.y, sInitRot[i].z + this->actor.world.rot.z, i); + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_VA, + sInitPosOffsets[i].x + pthis->actor.world.pos.x, sInitPosOffsets[i].y + pthis->actor.world.pos.y, + sInitPosOffsets[i].z + pthis->actor.world.pos.z, sInitRot[i].x + pthis->actor.world.rot.x, + sInitRot[i].y + pthis->actor.world.rot.y, sInitRot[i].z + pthis->actor.world.rot.z, i); } Lib_MemSet((u8*)sVaEffects, ARRAY_COUNT(sVaEffects) * sizeof(BossVaEffect), 0); if (sCsState < BOSSVA_BATTLE) { - BossVa_SetupIntro(this); + BossVa_SetupIntro(pthis); } else { - BossVa_SetupBodyPhase1(this); + BossVa_SetupBodyPhase1(pthis); } } break; case BOSSVA_SUPPORT_1: case BOSSVA_SUPPORT_2: case BOSSVA_SUPPORT_3: - Collider_InitJntSph(globalCtx, &this->colliderSph); - Collider_SetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInitSupport, this->elements); + Collider_InitJntSph(globalCtx, &pthis->colliderSph); + Collider_SetJntSph(globalCtx, &pthis->colliderSph, &pthis->actor, &sJntSphInitSupport, pthis->elements); if (sCsState < BOSSVA_BATTLE) { - BossVa_SetupSupportIntro(this, globalCtx); + BossVa_SetupSupportIntro(pthis, globalCtx); } else { - BossVa_SetupSupportAttached(this, globalCtx); + BossVa_SetupSupportAttached(pthis, globalCtx); } - this->onCeiling++; + pthis->onCeiling++; break; case BOSSVA_ZAPPER_1: case BOSSVA_ZAPPER_2: case BOSSVA_ZAPPER_3: - Collider_InitQuad(globalCtx, &this->colliderLightning); - Collider_SetQuad(globalCtx, &this->colliderLightning, &this->actor, &sQuadInit); + Collider_InitQuad(globalCtx, &pthis->colliderLightning); + Collider_SetQuad(globalCtx, &pthis->colliderLightning, &pthis->actor, &sQuadInit); if (sCsState < BOSSVA_BATTLE) { - BossVa_SetupZapperIntro(this, globalCtx); + BossVa_SetupZapperIntro(pthis, globalCtx); } else { - BossVa_SetupZapperAttack(this, globalCtx); + BossVa_SetupZapperAttack(pthis, globalCtx); } break; case BOSSVA_STUMP_1: case BOSSVA_STUMP_2: case BOSSVA_STUMP_3: - BossVa_SetupStump(this, globalCtx); + BossVa_SetupStump(pthis, globalCtx); break; case BOSSVA_DOOR: - BossVa_SetupDoor(this, globalCtx); + BossVa_SetupDoor(pthis, globalCtx); break; default: - Collider_InitJntSph(globalCtx, &this->colliderSph); - Collider_SetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInitBari, this->elements); - Collider_InitQuad(globalCtx, &this->colliderLightning); - Collider_SetQuad(globalCtx, &this->colliderLightning, &this->actor, &sQuadInit); - this->unk_1D8.x = 1.0f; - this->unk_1D8.y = 1.0f; + Collider_InitJntSph(globalCtx, &pthis->colliderSph); + Collider_SetJntSph(globalCtx, &pthis->colliderSph, &pthis->actor, &sJntSphInitBari, pthis->elements); + Collider_InitQuad(globalCtx, &pthis->colliderLightning); + Collider_SetQuad(globalCtx, &pthis->colliderLightning, &pthis->actor, &sQuadInit); + pthis->unk_1D8.x = 1.0f; + pthis->unk_1D8.y = 1.0f; if (sCsState < BOSSVA_BATTLE) { - BossVa_SetupBariIntro(this, globalCtx); + BossVa_SetupBariIntro(pthis, globalCtx); } else if (sFightPhase >= PHASE_3) { - BossVa_SetupBariPhase3Attack(this, globalCtx); + BossVa_SetupBariPhase3Attack(pthis, globalCtx); } else { - BossVa_SetupBariPhase2Attack(this, globalCtx); + BossVa_SetupBariPhase2Attack(pthis, globalCtx); } break; } } void BossVa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyJntSph(globalCtx, &this->colliderSph); - Collider_DestroyCylinder(globalCtx, &this->colliderBody); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyJntSph(globalCtx, &pthis->colliderSph); + Collider_DestroyCylinder(globalCtx, &pthis->colliderBody); } -void BossVa_SetupIntro(BossVa* this) { +void BossVa_SetupIntro(BossVa* pthis) { f32 lastFrame = Animation_GetLastFrame(&gBarinadeBodyAnim); - Animation_Change(&this->skelAnime, &gBarinadeBodyAnim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); - this->actor.shape.yOffset = -450.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_BodyIntro); + Animation_Change(&pthis->skelAnime, &gBarinadeBodyAnim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + pthis->actor.shape.yOffset = -450.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_BodyIntro); } -void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BodyIntro(BossVa* pthis, GlobalContext* globalCtx) { s32 i; Player* player = GET_PLAYER(globalCtx); - this->unk_1AC += 0xC31; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.1f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.05f) + 1.0f; + pthis->unk_1AC += 0xC31; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.1f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.05f) + 1.0f; switch (sCsState) { case INTRO_UNUSED_START: - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { sCsState = INTRO_CLOSE_DOOR; - this->timer = 10; + pthis->timer = 10; } break; case INTRO_START: @@ -802,7 +802,7 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { globalCtx->envCtx.screenFillColor[1] = 0xDC; globalCtx->envCtx.screenFillColor[2] = 0xBE; globalCtx->envCtx.screenFillColor[3] = 0xD2; - func_8002DF54(globalCtx, &this->actor, 8); + func_8002DF54(globalCtx, &pthis->actor, 8); player->actor.world.rot.y = player->actor.shape.rot.y = 0x7FFF; sCsState++; break; @@ -824,28 +824,28 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { sCameraAtMaxVel = sCameraEyeMaxVel = sZeroVec; - this->timer = 10; + pthis->timer = 10; sCsState++; break; case INTRO_CLOSE_DOOR: - this->timer--; - if (this->timer == 0) { - func_8002DF54(globalCtx, &this->actor, 2); + pthis->timer--; + if (pthis->timer == 0) { + func_8002DF54(globalCtx, &pthis->actor, 2); sCsState++; - this->timer = 30; + pthis->timer = 30; } break; case INTRO_DOOR_SHUT: - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { sCsState++; } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } break; case INTRO_CRACKLE: - func_8002DF54(globalCtx, &this->actor, 1); + func_8002DF54(globalCtx, &pthis->actor, 1); sCsState++; break; case INTRO_SPAWN_BARI: @@ -868,13 +868,13 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { for (i = BOSSVA_BARI_LOWER_5; i >= BOSSVA_BARI_UPPER_1; i--) { Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_VA, - sInitPosOffsets[i].x + this->actor.world.pos.x, sInitPosOffsets[i].y + this->actor.world.pos.y, - sInitPosOffsets[i].z + this->actor.world.pos.z, sInitRot[i].x + this->actor.world.rot.x, - sInitRot[i].y + this->actor.world.rot.y, sInitRot[i].z + this->actor.world.rot.z, i); + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_VA, + sInitPosOffsets[i].x + pthis->actor.world.pos.x, sInitPosOffsets[i].y + pthis->actor.world.pos.y, + sInitPosOffsets[i].z + pthis->actor.world.pos.z, sInitRot[i].x + pthis->actor.world.rot.x, + sInitRot[i].y + pthis->actor.world.rot.y, sInitRot[i].z + pthis->actor.world.rot.z, i); } - this->timer = 90; + pthis->timer = 90; sCsState++; break; case INTRO_REVERSE_CAMERA: @@ -889,10 +889,10 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { sCameraEyeMaxVel.y = sCameraEyeMaxVel.z; sCameraAtMaxVel = sCameraEyeMaxVel; - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { sCsState++; - this->timer = 60; + pthis->timer = 60; } break; case INTRO_SUPPORT_CAMERA: @@ -905,7 +905,7 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { sCameraNextAt.z = sCameraAt.z = -220.0f; sCsState++; - this->timer = 1; + pthis->timer = 1; break; case INTRO_BODY_SOUND: sCameraNextAt.x = 10.0f; @@ -916,15 +916,15 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { sCameraEyeMaxVel.y = sCameraEyeMaxVel.z; sCameraAtMaxVel = sCameraEyeMaxVel; - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { sCsState++; - this->timer = 40; + pthis->timer = 40; } break; case INTRO_LOOK_SUPPORT: - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { sCameraNextAt.x = 10.0f; sCameraNextAt.y = 50.0f; sCameraNextAt.z = -220.0f; @@ -933,7 +933,7 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { sCsState++; sCsState++; - this->timer = 20; + pthis->timer = 20; } break; case INTRO_CALL_BARI: @@ -945,24 +945,24 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { sCameraAtMaxVel = sCameraEyeMaxVel; sCameraAtMaxVel.z = sCameraAtMaxVel.z * 1.75f; - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { sCsState++; - this->timer = 7500; - this->unk_1F2 = 0; + pthis->timer = 7500; + pthis->unk_1F2 = 0; } break; case INTRO_ATTACH_BARI: for (i = 10; i >= 1; i--) { if (sBodyBari[i - 1]) { if (sBodyBari[i - 1] == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_STICK); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_STICK); BossVa_SetSparkEnv(globalCtx); - if (this->onCeiling == 0) { - this->onCeiling = 2; // Not used by body + if (pthis->onCeiling == 0) { + pthis->onCeiling = 2; // Not used by body } } else if (sBodyBari[i - 1] == 2) { - BossVa_Spark(globalCtx, this, 6, 140, 50.0f, 30.0f, SPARK_BARI, i, true); + BossVa_Spark(globalCtx, pthis, 6, 140, 50.0f, 30.0f, SPARK_BARI, i, true); } if (sBodyBari[i - 1] <= 2) { @@ -970,19 +970,19 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { } } } - Math_SmoothStepToS(&this->unk_1F2, 0x280, 1, 0x32, 0); + Math_SmoothStepToS(&pthis->unk_1F2, 0x280, 1, 0x32, 0); Math_SmoothStepToF(&sCameraEyeMaxVel.x, 14.0f, 0.3f, 1.0f, 0.25f); sCameraEyeMaxVel.z = sCameraEyeMaxVel.x; sCameraAtMaxVel = sCameraEyeMaxVel; - if (this->timer >= 45000) { + if (pthis->timer >= 45000) { globalCtx->envCtx.unk_BF = 1; - func_8002DF54(globalCtx, &this->actor, 8); - } else if (this->timer >= 35000) { + func_8002DF54(globalCtx, &pthis->actor, 8); + } else if (pthis->timer >= 35000) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); } - this->timer += this->unk_1F2; - if (this->timer >= 65536) { + pthis->timer += pthis->unk_1F2; + if (pthis->timer >= 65536) { sCameraEyeMaxVel.y = sCameraAtMaxVel.y = 9.8f; sCsState++; @@ -999,60 +999,60 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - this->timer = 40; + pthis->timer = 40; } else { sCameraEyeMaxVel.y = 1.6f; sCameraNextEye.y = 5.0f; - sCameraNextEye.x = Math_SinS(this->timer) * 200.0f; - sCameraNextEye.z = (Math_CosS(this->timer) * 200.0f) + -200.0f; + sCameraNextEye.x = Math_SinS(pthis->timer) * 200.0f; + sCameraNextEye.z = (Math_CosS(pthis->timer) * 200.0f) + -200.0f; } break; case INTRO_TITLE: - BossVa_Spark(globalCtx, this, 3, 140, 50.0f, 30.0f, SPARK_BARI, 10.0f, false); - this->timer--; - if (this->timer == 0) { + BossVa_Spark(globalCtx, pthis, 3, 140, 50.0f, 30.0f, SPARK_BARI, 10.0f, false); + pthis->timer--; + if (pthis->timer == 0) { sCsState++; - this->timer = 45; + pthis->timer = 45; } break; case INTRO_BRIGHTEN: - BossVa_Spark(globalCtx, this, 3, 140, 50.0f, 30.0f, SPARK_BARI, 10.0f, false); - this->timer--; - if (this->timer == 0) { + BossVa_Spark(globalCtx, pthis, 3, 140, 50.0f, 30.0f, SPARK_BARI, 10.0f, false); + pthis->timer--; + if (pthis->timer == 0) { sCsState++; - this->timer = 11; + pthis->timer = 11; } break; case INTRO_FINISH: - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { Gameplay_ClearCamera(globalCtx, sCsCamera); sCsCamera = 0; func_80064534(globalCtx, &globalCtx->csCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); sCsState++; gSaveContext.eventChkInf[7] |= 0x40; - player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + player->actor.shape.rot.y = player->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; } break; case BOSSVA_BATTLE: - BossVa_SetupBodyPhase1(this); + BossVa_SetupBodyPhase1(pthis); break; } if (sCsState >= INTRO_BODY_SOUND) { - func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); + func_800F436C(&pthis->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); if ((sCsState >= INTRO_CALL_BARI) && ((globalCtx->gameplayFrames % 4) == 0)) { - BossVa_Spark(globalCtx, this, 1, 100, 50.0f, 10.0f, SPARK_BODY, 10.0f, false); + BossVa_Spark(globalCtx, pthis, 1, 100, 50.0f, 10.0f, SPARK_BODY, 10.0f, false); } } - this->unk_1B0 += 0xCE4; - this->bodyGlow = (s16)(Math_SinS(this->unk_1B0) * 50.0f) + 150; + pthis->unk_1B0 += 0xCE4; + pthis->bodyGlow = (s16)(Math_SinS(pthis->unk_1B0) * 50.0f) + 150; if ((sCsCamera != 0) && (sCsState <= INTRO_TITLE)) { Math_SmoothStepToF(&sCameraEye.x, sCameraNextEye.x, 0.3f, sCameraEyeMaxVel.x, 0.075f); Math_SmoothStepToF(&sCameraEye.y, sCameraNextEye.y, 0.3f, sCameraEyeMaxVel.y, 0.075f); @@ -1064,485 +1064,485 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { } } -void BossVa_SetupBodyPhase1(BossVa* this) { +void BossVa_SetupBodyPhase1(BossVa* pthis) { f32 lastFrame = Animation_GetLastFrame(&gBarinadeBodyAnim); - Animation_Change(&this->skelAnime, &gBarinadeBodyAnim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); - this->actor.shape.yOffset = -450.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->timer = 25; + Animation_Change(&pthis->skelAnime, &gBarinadeBodyAnim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + pthis->actor.shape.yOffset = -450.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->timer = 25; sBodyState = 0x80; - BossVa_SetupAction(this, BossVa_BodyPhase1); + BossVa_SetupAction(pthis, BossVa_BodyPhase1); } -void BossVa_BodyPhase1(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BodyPhase1(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk_1B0 += 0xCE4; - this->bodyGlow = (s16)(Math_SinS(this->unk_1B0) * 50.0f) + 150; - if (this->timer != 0) { - this->timer--; - if (this->timer == 0) { + pthis->unk_1B0 += 0xCE4; + pthis->bodyGlow = (s16)(Math_SinS(pthis->unk_1B0) * 50.0f) + 150; + if (pthis->timer != 0) { + pthis->timer--; + if (pthis->timer == 0) { sBodyState &= (u8)~0x80; } } - if (this->colliderBody.base.atFlags & AT_HIT) { - this->colliderBody.base.atFlags &= ~AT_HIT; - if (this->colliderBody.base.at == &player->actor) { - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); + if (pthis->colliderBody.base.atFlags & AT_HIT) { + pthis->colliderBody.base.atFlags &= ~AT_HIT; + if (pthis->colliderBody.base.at == &player->actor) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.yawTowardsPlayer, 8.0f); } } if (sBodyState & 0x7F) { - this->skelAnime.curFrame = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 12); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_DAMAGE); + pthis->skelAnime.curFrame = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 12); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_DAMAGE); } - if (SkelAnime_Update(&this->skelAnime) && (sFightPhase >= PHASE_2)) { - BossVa_SetupBodyPhase2(this, globalCtx); + if (SkelAnime_Update(&pthis->skelAnime) && (sFightPhase >= PHASE_2)) { + BossVa_SetupBodyPhase2(pthis, globalCtx); } - Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 1, 0xC8, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->actor.world.rot.z, 1, 0xC8, 0); - this->unk_1AC += 0xC31; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.1f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.05f) + 1.0f; + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->actor.world.rot.x, 1, 0xC8, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->actor.world.rot.z, 1, 0xC8, 0); + pthis->unk_1AC += 0xC31; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.1f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.05f) + 1.0f; if ((globalCtx->gameplayFrames % 4) == 0) { - BossVa_Spark(globalCtx, this, 1, 100, 50.0f, 10.0f, SPARK_BARI, 10.0f, false); + BossVa_Spark(globalCtx, pthis, 1, 100, 50.0f, 10.0f, SPARK_BARI, 10.0f, false); } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - Collider_UpdateCylinder(&this->actor, &this->colliderBody); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderBody); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + func_800F436C(&pthis->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); } -void BossVa_SetupBodyPhase2(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupBodyPhase2(BossVa* pthis, GlobalContext* globalCtx) { s32 i; sFightPhase++; for (i = BOSSVA_BARI_UPPER_5; i >= BOSSVA_BARI_UPPER_1; i--) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_VA, - sInitPosOffsets[i].x + this->actor.world.pos.x, - sInitPosOffsets[i].y + this->actor.world.pos.y, - sInitPosOffsets[i].z + this->actor.world.pos.z, sInitRot[i].x + this->actor.world.rot.x, - sInitRot[i].y + this->actor.world.rot.y, sInitRot[i].z + this->actor.world.rot.z, i); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_VA, + sInitPosOffsets[i].x + pthis->actor.world.pos.x, + sInitPosOffsets[i].y + pthis->actor.world.pos.y, + sInitPosOffsets[i].z + pthis->actor.world.pos.z, sInitRot[i].x + pthis->actor.world.rot.x, + sInitRot[i].y + pthis->actor.world.rot.y, sInitRot[i].z + pthis->actor.world.rot.z, i); } - this->invincibilityTimer = 0; - this->actor.flags |= ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_BodyPhase2); + pthis->invincibilityTimer = 0; + pthis->actor.flags |= ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_BodyPhase2); } -void BossVa_BodyPhase2(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BodyPhase2(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f sp48; - if (this->actor.colorFilterTimer == 0) { + if (pthis->actor.colorFilterTimer == 0) { sPhase2Timer++; - if ((this->invincibilityTimer != 0) && (this->actor.colorFilterParams & 0x4000)) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 160); - this->actor.colorFilterTimer = this->invincibilityTimer; + if ((pthis->invincibilityTimer != 0) && (pthis->actor.colorFilterParams & 0x4000)) { + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 160); + pthis->actor.colorFilterTimer = pthis->invincibilityTimer; } else { - this->colliderBody.info.bumper.dmgFlags = 0x10; + pthis->colliderBody.info.bumper.dmgFlags = 0x10; } } - if (this->colliderBody.base.acFlags & AC_HIT) { - this->colliderBody.base.acFlags &= ~AC_HIT; + if (pthis->colliderBody.base.acFlags & AC_HIT) { + pthis->colliderBody.base.acFlags &= ~AC_HIT; - if (this->colliderBody.base.ac->id == ACTOR_EN_BOOM) { + if (pthis->colliderBody.base.ac->id == ACTOR_EN_BOOM) { sPhase2Timer &= 0xFE00; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 160); - this->colliderBody.info.bumper.dmgFlags = 0xFC00712; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 160); + pthis->colliderBody.info.bumper.dmgFlags = 0xFC00712; } else { sKillBari++; - if ((this->actor.colorFilterTimer != 0) && !(this->actor.colorFilterParams & 0x4000)) { - this->invincibilityTimer = this->actor.colorFilterTimer - 5; - if (this->invincibilityTimer > 160) { - this->invincibilityTimer = 0; + if ((pthis->actor.colorFilterTimer != 0) && !(pthis->actor.colorFilterParams & 0x4000)) { + pthis->invincibilityTimer = pthis->actor.colorFilterTimer - 5; + if (pthis->invincibilityTimer > 160) { + pthis->invincibilityTimer = 0; } } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 12); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 12); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_FAINT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_FAINT); } - if (this->colliderBody.base.atFlags & AT_HIT) { - this->colliderBody.base.atFlags &= ~AT_HIT; + if (pthis->colliderBody.base.atFlags & AT_HIT) { + pthis->colliderBody.base.atFlags &= ~AT_HIT; sPhase2Timer = (sPhase2Timer + 0x18) & 0xFFF0; - if (this->colliderBody.base.at == &player->actor) { - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); + if (pthis->colliderBody.base.at == &player->actor) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.yawTowardsPlayer, 8.0f); Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); } } - if ((sPhase2Timer > 10) && !(sPhase2Timer & 7) && (this->actor.speedXZ == 1.0f)) { - sp48 = this->actor.world.pos; - sp48.y += 310.0f + (this->actor.shape.yOffset * this->actor.scale.y); + if ((sPhase2Timer > 10) && !(sPhase2Timer & 7) && (pthis->actor.speedXZ == 1.0f)) { + sp48 = pthis->actor.world.pos; + sp48.y += 310.0f + (pthis->actor.shape.yOffset * pthis->actor.scale.y); sp48.x += -10.0f; sp48.z += 220.0f; - BossVa_SpawnSparkBall(globalCtx, sVaEffects, this, &sp48, 4, 0); + BossVa_SpawnSparkBall(globalCtx, sVaEffects, pthis, &sp48, 4, 0); } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 1, 0xC8, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->actor.world.rot.z, 1, 0xC8, 0); - Math_SmoothStepToF(&this->actor.shape.yOffset, -1000.0f, 1.0f, 20.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->actor.world.rot.x, 1, 0xC8, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->actor.world.rot.z, 1, 0xC8, 0); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1000.0f, 1.0f, 20.0f, 0.0f); if (!(sPhase2Timer & 0x100)) { - this->actor.flags |= ACTOR_FLAG_0; - this->actor.speedXZ = 1.0f; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.speedXZ = 1.0f; } else { - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; } - if (SkelAnime_Update(&this->skelAnime) && (sFightPhase >= PHASE_3)) { - BossVa_SetupBodyPhase3(this); + if (SkelAnime_Update(&pthis->skelAnime) && (sFightPhase >= PHASE_3)) { + BossVa_SetupBodyPhase3(pthis); } - this->unk_1AC += 0xC31; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.1f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.05f) + 1.0f; + pthis->unk_1AC += 0xC31; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.1f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.05f) + 1.0f; if ((globalCtx->gameplayFrames % 4) == 0) { - BossVa_Spark(globalCtx, this, 1, 100, 50.0f, 10.0f, SPARK_BODY, 10.0f, false); + BossVa_Spark(globalCtx, pthis, 1, 100, 50.0f, 10.0f, SPARK_BODY, 10.0f, false); } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 45.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 45.0f; - Collider_UpdateCylinder(&this->actor, &this->colliderBody); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - if (this->actor.colorFilterTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderBody); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + if (pthis->actor.colorFilterTimer == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); } - if ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); + if ((pthis->actor.colorFilterTimer == 0) || !(pthis->actor.colorFilterParams & 0x4000)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); } - func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, - (this->vaBodySpinRate * 0.00025f) + 1.0f); + func_800F436C(&pthis->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, + (pthis->vaBodySpinRate * 0.00025f) + 1.0f); } -void BossVa_SetupBodyPhase3(BossVa* this) { - this->colliderBody.info.bumper.dmgFlags = 0x10; - this->actor.speedXZ = 0.0f; +void BossVa_SetupBodyPhase3(BossVa* pthis) { + pthis->colliderBody.info.bumper.dmgFlags = 0x10; + pthis->actor.speedXZ = 0.0f; sPhase3StopMoving = false; - BossVa_SetupAction(this, BossVa_BodyPhase3); + BossVa_SetupAction(pthis, BossVa_BodyPhase3); } -void BossVa_BodyPhase3(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BodyPhase3(BossVa* pthis, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); s32 i; s16 sp62; - sp62 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - this->unk_1B0 += 0xCE4; - this->bodyGlow = (s16)(Math_SinS(this->unk_1B0) * 50.0f) + 150; - if (this->colliderBody.base.atFlags & AT_HIT) { - this->colliderBody.base.atFlags &= ~AT_HIT; - if (this->colliderBody.base.at == &player->actor) { - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); - this->actor.world.rot.y += (s16)Rand_CenteredFloat(0x2EE0) + 0x8000; + sp62 = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->unk_1B0 += 0xCE4; + pthis->bodyGlow = (s16)(Math_SinS(pthis->unk_1B0) * 50.0f) + 150; + if (pthis->colliderBody.base.atFlags & AT_HIT) { + pthis->colliderBody.base.atFlags &= ~AT_HIT; + if (pthis->colliderBody.base.at == &player->actor) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.yawTowardsPlayer, 8.0f); + pthis->actor.world.rot.y += (s16)Rand_CenteredFloat(0x2EE0) + 0x8000; Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); } } - if (this->colliderBody.base.acFlags & AC_HIT) { - this->skelAnime.curFrame = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 12); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_FAINT); + if (pthis->colliderBody.base.acFlags & AC_HIT) { + pthis->skelAnime.curFrame = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 12); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_FAINT); sBodyState = 1; - this->timer = 131; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->timer = 131; + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { sBodyState = 0; - if (this->timer == 0) { - if (Math_SmoothStepToS(&this->vaBodySpinRate, 0xFA0, 1, 0x12C, 0) == 0) { - if (this->actor.speedXZ == 0.0f) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if (pthis->timer == 0) { + if (Math_SmoothStepToS(&pthis->vaBodySpinRate, 0xFA0, 1, 0x12C, 0) == 0) { + if (pthis->actor.speedXZ == 0.0f) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; } - Math_SmoothStepToF(&this->actor.speedXZ, 3.0f, 1.0f, 0.15f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, 3.0f, 1.0f, 0.15f, 0.0f); } - this->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags |= ACTOR_FLAG_0; } else { - this->timer--; - if (this->timer < 35) { + pthis->timer--; + if (pthis->timer < 35) { sBodyState = 0x80; } - Math_SmoothStepToS(&this->vaBodySpinRate, 0, 1, 0x12C, 0); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.2f, 0.0f); - Math_SmoothStepToF(&this->actor.shape.yOffset, -1420.0f, 1.0f, 30.0f, 0.0f); + Math_SmoothStepToS(&pthis->vaBodySpinRate, 0, 1, 0x12C, 0); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.2f, 0.0f); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1420.0f, 1.0f, 30.0f, 0.0f); } } - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) >= 400.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, sp62, 1, 0x3E8, 0); + if (Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) >= 400.0f) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, sp62, 1, 0x3E8, 0); } else if (player->invincibilityTimer != 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x8000, 1, 0x12C, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 1, 0x12C, 0); } else if ((globalCtx->gameplayFrames & 0x80) == 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x12C, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x12C, 0); } else { - Math_SmoothStepToS(&this->actor.world.rot.y, sp62, 1, 0x258, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.y, sp62, 1, 0x258, 0); } if (sPhase3StopMoving) { - this->actor.speedXZ = 0.0f; + pthis->actor.speedXZ = 0.0f; } - Actor_MoveForward(&this->actor); - if (SkelAnime_Update(&this->skelAnime) && (sFightPhase >= PHASE_4)) { - BossVa_SetupBodyPhase4(this, globalCtx); + Actor_MoveForward(&pthis->actor); + if (SkelAnime_Update(&pthis->skelAnime) && (sFightPhase >= PHASE_4)) { + BossVa_SetupBodyPhase4(pthis, globalCtx); } - this->actor.shape.rot.y += this->vaBodySpinRate; + pthis->actor.shape.rot.y += pthis->vaBodySpinRate; if (sFightPhase == PHASE_3) { - Math_SmoothStepToF(&this->actor.shape.yOffset, -450.0f, 1.0f, 15.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -450.0f, 1.0f, 15.0f, 0.0f); } else { - Math_SmoothStepToF(&this->actor.shape.yOffset, -810.0f, 1.0f, 15.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -810.0f, 1.0f, 15.0f, 0.0f); } - if ((this->actor.shape.yOffset >= -500.0f) && (sFightPhase == PHASE_3)) { + if ((pthis->actor.shape.yOffset >= -500.0f) && (sFightPhase == PHASE_3)) { for (i = BOSSVA_BARI_LOWER_5; i >= BOSSVA_BARI_LOWER_1; i--) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_VA, - sInitPosOffsets[i].x + this->actor.world.pos.x, - sInitPosOffsets[i].y + this->actor.world.pos.y, - sInitPosOffsets[i].z + this->actor.world.pos.z, sInitRot[i].x + this->actor.world.rot.x, - sInitRot[i].y + this->actor.world.rot.y, sInitRot[i].z + this->actor.world.rot.z, i); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_VA, + sInitPosOffsets[i].x + pthis->actor.world.pos.x, + sInitPosOffsets[i].y + pthis->actor.world.pos.y, + sInitPosOffsets[i].z + pthis->actor.world.pos.z, sInitRot[i].x + pthis->actor.world.rot.x, + sInitRot[i].y + pthis->actor.world.rot.y, sInitRot[i].z + pthis->actor.world.rot.z, i); } sFightPhase++; } - this->unk_1AC += 0xC31; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.1f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.05f) + 1.0f; + pthis->unk_1AC += 0xC31; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.1f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.05f) + 1.0f; if ((globalCtx->gameplayFrames % 4) == 0) { - BossVa_Spark(globalCtx, this, 1, 0x64, 50.0f, 10.0f, SPARK_BODY, 10.0f, false); + BossVa_Spark(globalCtx, pthis, 1, 0x64, 50.0f, 10.0f, SPARK_BODY, 10.0f, false); } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 20.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 20.0f; if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - Collider_UpdateCylinder(&this->actor, &this->colliderBody); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - if (this->timer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderBody); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + if (pthis->timer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); } - func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, - (this->vaBodySpinRate * 0.00025f) + 1.0f); + func_800F436C(&pthis->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, + (pthis->vaBodySpinRate * 0.00025f) + 1.0f); } -void BossVa_SetupBodyPhase4(BossVa* this, GlobalContext* globalCtx) { - this->unk_1AC = 0; - this->actor.flags |= ACTOR_FLAG_0; - this->vaBodySpinRate = this->unk_1AC; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->timer2 = (s16)(Rand_ZeroOne() * 150.0f) + 300; +void BossVa_SetupBodyPhase4(BossVa* pthis, GlobalContext* globalCtx) { + pthis->unk_1AC = 0; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->vaBodySpinRate = pthis->unk_1AC; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->timer2 = (s16)(Rand_ZeroOne() * 150.0f) + 300; sBodyState = 1; sPhase4HP = 4; - if (this->actor.shape.yOffset != 0.0f) { - this->timer = -30; + if (pthis->actor.shape.yOffset != 0.0f) { + pthis->timer = -30; } - this->colliderBody.dim.radius = 55; - BossVa_SetupAction(this, BossVa_BodyPhase4); + pthis->colliderBody.dim.radius = 55; + BossVa_SetupAction(pthis, BossVa_BodyPhase4); } -void BossVa_BodyPhase4(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BodyPhase4(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 tmpf1; EnBoom* boomerang; - this->unk_1B0 = (this->unk_1B0 + (s16)((sFightPhase - PHASE_4 + 1) * 1000.0f)) + 0xCE4; - this->bodyGlow = (s16)(Math_SinS(this->unk_1B0) * 50.0f) + 150; - if (this->colliderBody.base.atFlags & AT_HIT) { - this->colliderBody.base.atFlags &= ~AT_HIT; - if (this->colliderBody.base.at == &player->actor) { - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); - this->actor.world.rot.y += (s16)Rand_CenteredFloat(0x2EE0) + 0x8000; + pthis->unk_1B0 = (pthis->unk_1B0 + (s16)((sFightPhase - PHASE_4 + 1) * 1000.0f)) + 0xCE4; + pthis->bodyGlow = (s16)(Math_SinS(pthis->unk_1B0) * 50.0f) + 150; + if (pthis->colliderBody.base.atFlags & AT_HIT) { + pthis->colliderBody.base.atFlags &= ~AT_HIT; + if (pthis->colliderBody.base.at == &player->actor) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.yawTowardsPlayer, 8.0f); + pthis->actor.world.rot.y += (s16)Rand_CenteredFloat(0x2EE0) + 0x8000; Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); } } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - if (this->colliderBody.base.acFlags & AC_HIT) { - this->colliderBody.base.acFlags &= ~AC_HIT; - this->skelAnime.curFrame = 0.0f; - if (this->timer >= 0) { - if (this->invincibilityTimer == 0) { - this->invincibilityTimer = 8; - if (this->actor.colChkInfo.damageEffect != 1) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_DAMAGE); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 12); - sPhase4HP -= this->actor.colChkInfo.damage; + if (pthis->colliderBody.base.acFlags & AC_HIT) { + pthis->colliderBody.base.acFlags &= ~AC_HIT; + pthis->skelAnime.curFrame = 0.0f; + if (pthis->timer >= 0) { + if (pthis->invincibilityTimer == 0) { + pthis->invincibilityTimer = 8; + if (pthis->actor.colChkInfo.damageEffect != 1) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_DAMAGE); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 12); + sPhase4HP -= pthis->actor.colChkInfo.damage; if (sPhase4HP <= 0) { - this->timer = 0; + pthis->timer = 0; sFightPhase++; sPhase4HP += 3; if (sFightPhase >= PHASE_DEATH) { - BossVa_SetupBodyDeath(this, globalCtx); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + BossVa_SetupBodyDeath(pthis, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); return; } - this->actor.speedXZ = -10.0f; - this->timer = -170 - (s16)(Rand_ZeroOne() * 150.0f); + pthis->actor.speedXZ = -10.0f; + pthis->timer = -170 - (s16)(Rand_ZeroOne() * 150.0f); } } else { - this->timer = (s16)Rand_CenteredFloat(40.0f) + 160; - this->vaBodySpinRate = 0; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 125, 0, 255); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_FAINT); + pthis->timer = (s16)Rand_CenteredFloat(40.0f) + 160; + pthis->vaBodySpinRate = 0; + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 125, 0, 255); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_FAINT); } } - } else if (this->colliderBody.base.ac->id == ACTOR_EN_BOOM) { - boomerang = (EnBoom*)this->colliderBody.base.ac; + } else if (pthis->colliderBody.base.ac->id == ACTOR_EN_BOOM) { + boomerang = (EnBoom*)pthis->colliderBody.base.ac; boomerang->returnTimer = 0; boomerang->moveTo = &player->actor; boomerang->actor.world.rot.y = boomerang->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SHIELD_REFLECT_SW); } - } else if ((this->timer2 == 0) && (this->actor.shape.yOffset == 0.0f)) { - this->timer = -220 - (s16)(Rand_ZeroOne() * 200.0f); - } else if (this->timer2 != 0) { - this->timer2--; + } else if ((pthis->timer2 == 0) && (pthis->actor.shape.yOffset == 0.0f)) { + pthis->timer = -220 - (s16)(Rand_ZeroOne() * 200.0f); + } else if (pthis->timer2 != 0) { + pthis->timer2--; } - SkelAnime_Update(&this->skelAnime); - if (this->timer == 0) { - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, ((sFightPhase - PHASE_4 + 1) * 5.0f) + 10.0f, 0.0f); - if (Math_SmoothStepToS(&this->vaBodySpinRate, (s16)((sFightPhase - PHASE_4 + 1) * 500.0f) + 0xFA0, 1, 0x12C, + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer == 0) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 1.0f, ((sFightPhase - PHASE_4 + 1) * 5.0f) + 10.0f, 0.0f); + if (Math_SmoothStepToS(&pthis->vaBodySpinRate, (s16)((sFightPhase - PHASE_4 + 1) * 500.0f) + 0xFA0, 1, 0x12C, 0) == 0) { - if (this->actor.speedXZ == 0.0f) { - this->actor.colorFilterTimer = 0; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->timer2 = (s16)(Rand_ZeroOne() * 150.0f) + 300; + if (pthis->actor.speedXZ == 0.0f) { + pthis->actor.colorFilterTimer = 0; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->timer2 = (s16)(Rand_ZeroOne() * 150.0f) + 300; } - Math_SmoothStepToF(&this->actor.speedXZ, ((sFightPhase - PHASE_4 + 1) * 1.5f) + 4.0f, 1.0f, 0.25f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, ((sFightPhase - PHASE_4 + 1) * 1.5f) + 4.0f, 1.0f, 0.25f, 0.0f); } - this->colliderBody.info.bumper.dmgFlags = 0x10; + pthis->colliderBody.info.bumper.dmgFlags = 0x10; } else { - Math_SmoothStepToS(&this->vaBodySpinRate, 0, 1, 0x96, 0); - if (this->timer > 0) { - if ((player->stateFlags1 & 0x4000000) && (this->timer > 35)) { - this->timer = 35; + Math_SmoothStepToS(&pthis->vaBodySpinRate, 0, 1, 0x96, 0); + if (pthis->timer > 0) { + if ((player->stateFlags1 & 0x4000000) && (pthis->timer > 35)) { + pthis->timer = 35; } - Math_SmoothStepToF(&this->actor.shape.yOffset, -480.0f, 1.0f, 30.0f, 0.0f); - this->colliderBody.info.bumper.dmgFlags = 0xFC00712; - this->timer--; + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -480.0f, 1.0f, 30.0f, 0.0f); + pthis->colliderBody.info.bumper.dmgFlags = 0xFC00712; + pthis->timer--; } else { - if ((player->stateFlags1 & 0x4000000) && (this->timer < -60)) { - this->timer = -59; + if ((player->stateFlags1 & 0x4000000) && (pthis->timer < -60)) { + pthis->timer = -59; } if ((globalCtx->gameplayFrames % 4) == 0) { - BossVa_Spark(globalCtx, this, 2, 0x64, 220.0f, 5.0f, SPARK_BODY, 12.0f, true); + BossVa_Spark(globalCtx, pthis, 2, 0x64, 220.0f, 5.0f, SPARK_BODY, 12.0f, true); } - if (this->timer < -30) { - if (this->actor.speedXZ > 0.0f) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if (pthis->timer < -30) { + if (pthis->actor.speedXZ > 0.0f) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); } - Math_SmoothStepToF(&this->actor.shape.yOffset, -1400.0f, 1.0f, 60.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1400.0f, 1.0f, 60.0f, 0.0f); } else { - if (this->actor.speedXZ == 0.0f) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; - this->timer2 = (s16)(Rand_ZeroOne() * 150.0f) + 330; + if (pthis->actor.speedXZ == 0.0f) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + pthis->timer2 = (s16)(Rand_ZeroOne() * 150.0f) + 330; } - Math_SmoothStepToS(&this->vaBodySpinRate, 0xFA0, 1, 0x1F4, 0); + Math_SmoothStepToS(&pthis->vaBodySpinRate, 0xFA0, 1, 0x1F4, 0); tmpf1 = sFightPhase - PHASE_4 + 1; - Math_SmoothStepToF(&this->actor.speedXZ, (tmpf1 + tmpf1) + 4.0f, 1.0f, 0.25f, 0.0f); - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 20.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, (tmpf1 + tmpf1) + 4.0f, 1.0f, 0.25f, 0.0f); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 1.0f, 20.0f, 0.0f); } - this->timer++; + pthis->timer++; } } - this->actor.shape.rot.y += this->vaBodySpinRate; - if (this->actor.speedXZ < 0.0f) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + pthis->actor.shape.rot.y += pthis->vaBodySpinRate; + if (pthis->actor.speedXZ < 0.0f) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); } - this->unk_1AC += 0xC31; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.1f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.05f) + 1.0f; - if (this->actor.bgCheckFlags & 8) { - this->actor.bgCheckFlags &= ~8; - this->actor.world.rot.y = (s16)Rand_CenteredFloat(30 * (0x10000 / 360)) + this->actor.wallYaw; + pthis->unk_1AC += 0xC31; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.1f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.05f) + 1.0f; + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.bgCheckFlags &= ~8; + pthis->actor.world.rot.y = (s16)Rand_CenteredFloat(30 * (0x10000 / 360)) + pthis->actor.wallYaw; } if (sFightPhase <= PHASE_4) { - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) >= 400.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + if (Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) >= 400.0f) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos), 1, 0x5DC, 0); } else if (player->invincibilityTimer != 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x8000, 1, 0x12C, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 1, 0x12C, 0); } else if ((globalCtx->gameplayFrames & 0x80) == 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, (s16)((sFightPhase - PHASE_4 + 1) * 100.0f) + 0x64, 0); } } - Actor_MoveForward(&this->actor); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 60.0f; - if (((globalCtx->gameplayFrames % 2) == 0) && (this->timer == 0)) { - BossVa_Spark(globalCtx, this, 2, 125, 40.0f, 10.0f, SPARK_BODY, 10.0f, false); - BossVa_Spark(globalCtx, this, 1, 100, 15.0f, 10.0f, SPARK_BARI, 11.0f, true); + Actor_MoveForward(&pthis->actor); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 60.0f; + if (((globalCtx->gameplayFrames % 2) == 0) && (pthis->timer == 0)) { + BossVa_Spark(globalCtx, pthis, 2, 125, 40.0f, 10.0f, SPARK_BODY, 10.0f, false); + BossVa_Spark(globalCtx, pthis, 1, 100, 15.0f, 10.0f, SPARK_BARI, 11.0f, true); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 70.0f, 0.0f, 1); - Collider_UpdateCylinder(&this->actor, &this->colliderBody); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - if (this->invincibilityTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 70.0f, 0.0f, 1); + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderBody); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + if (pthis->invincibilityTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); } - if ((this->vaBodySpinRate > 0x3E8) || (this->actor.shape.yOffset < -1200.0f)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); + if ((pthis->vaBodySpinRate > 0x3E8) || (pthis->actor.shape.yOffset < -1200.0f)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); } - func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, - (this->vaBodySpinRate * 0.00025f) + 1.0f); - if (this->invincibilityTimer != 0) { - this->invincibilityTimer--; + func_800F436C(&pthis->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, + (pthis->vaBodySpinRate * 0.00025f) + 1.0f); + if (pthis->invincibilityTimer != 0) { + pthis->invincibilityTimer--; sBodyState = (sBodyState & 0x80) | 2; } else { sBodyState = (sBodyState & 0x80) | 1; } } -void BossVa_SetupBodyDeath(BossVa* this, GlobalContext* globalCtx) { - func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); +void BossVa_SetupBodyDeath(BossVa* pthis, GlobalContext* globalCtx) { + func_800F436C(&pthis->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - this->vaCamRotMod = 0xC31; + pthis->vaCamRotMod = 0xC31; sCsState = DEATH_START; - this->actor.speedXZ = 0.0f; - this->unk_1A8 = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->unk_1A8 = 0.0f; Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); - BossVa_SetupAction(this, BossVa_BodyDeath); + BossVa_SetupAction(pthis, BossVa_BodyDeath); } -void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BodyDeath(BossVa* pthis, GlobalContext* globalCtx) { s32 i; Camera* camera = Gameplay_GetCamera(globalCtx, 0); s32 sp7C; @@ -1551,15 +1551,15 @@ void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { switch (sCsState) { case DEATH_START: - func_8002DF54(globalCtx, &this->actor, 1); + func_8002DF54(globalCtx, &pthis->actor, 1); func_80064520(globalCtx, &globalCtx->csCtx); sCsCamera = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); Gameplay_ChangeCameraStatus(globalCtx, sCsCamera, CAM_STAT_ACTIVE); - sCameraNextAt.x = this->actor.world.pos.x; - sCameraNextAt.y = this->actor.world.pos.y; - sCameraNextAt.z = this->actor.world.pos.z; + sCameraNextAt.x = pthis->actor.world.pos.x; + sCameraNextAt.y = pthis->actor.world.pos.y; + sCameraNextAt.z = pthis->actor.world.pos.z; sCameraAt = camera->at; @@ -1570,63 +1570,63 @@ void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { sCameraAtMaxVel = sCameraEyeMaxVel = sZeroVec; - this->unk_1AC = Math_Vec3f_Yaw(&sCameraEye, &sCameraNextAt) - 0x100; - this->unk_1B0 = 15; + pthis->unk_1AC = Math_Vec3f_Yaw(&sCameraEye, &sCameraNextAt) - 0x100; + pthis->unk_1B0 = 15; globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[2] = 0xFF; globalCtx->envCtx.screenFillColor[3] = 0; globalCtx->envCtx.fillScreen = true; sCsState++; case DEATH_BODY_TUMORS: - this->unk_1AC += 0x100; - sCameraNextEye.x = (Math_SinS(this->unk_1AC) * (160.0f + this->unk_1A8)) + sCameraNextAt.x; - sCameraNextEye.z = (Math_CosS(this->unk_1AC) * (160.0f + this->unk_1A8)) + sCameraNextAt.z; + pthis->unk_1AC += 0x100; + sCameraNextEye.x = (Math_SinS(pthis->unk_1AC) * (160.0f + pthis->unk_1A8)) + sCameraNextAt.x; + sCameraNextEye.z = (Math_CosS(pthis->unk_1AC) * (160.0f + pthis->unk_1A8)) + sCameraNextAt.z; Math_SmoothStepToF(&sCameraEyeMaxVel.x, 16.0f, 0.4f, 1.5f, 0.5f); sCameraEyeMaxVel.z = sCameraEyeMaxVel.x; sCameraEyeMaxVel.y = sCameraEyeMaxVel.x * 0.5f; sCameraAtMaxVel = sCameraEyeMaxVel; tmp16 = Rand_CenteredFloat(0.5f) + ((sCameraEyeMaxVel.x * 0.5f) + 0.6f); - if (((globalCtx->gameplayFrames % 4) == 0) && (this->unk_1B0 != 0)) { + if (((globalCtx->gameplayFrames % 4) == 0) && (pthis->unk_1B0 != 0)) { for (i = 6; i > 1; i--) { - BossVa_Tumor(globalCtx, this, 1, tmp16, 0.0f, 0.0f, TUMOR_BODY, i, true); + BossVa_Tumor(globalCtx, pthis, 1, tmp16, 0.0f, 0.0f, TUMOR_BODY, i, true); } - BossVa_Tumor(globalCtx, this, 1, tmp16, 0.0f, 0.0f, TUMOR_BODY, 11.0f, true); - this->unk_1B0--; + BossVa_Tumor(globalCtx, pthis, 1, tmp16, 0.0f, 0.0f, TUMOR_BODY, 11.0f, true); + pthis->unk_1B0--; } - if (this->unk_1B0 == 0) { + if (pthis->unk_1B0 == 0) { sCsState++; sCameraAtMaxVel = sCameraEyeMaxVel = sZeroVec; } break; case DEATH_CORE_DEAD: - this->unk_1AC += 0x1862; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.12f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.075f) + 1.0f; - if (!this->isDead) { - this->burst++; - this->isDead++; - this->timer = 30; + pthis->unk_1AC += 0x1862; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.12f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.075f) + 1.0f; + if (!pthis->isDead) { + pthis->burst++; + pthis->isDead++; + pthis->timer = 30; sCsState++; - EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_BALINADE_DEAD, 1, 1, + EffectSsDeadSound_SpawnStationary(globalCtx, &pthis->actor.projectedPos, NA_SE_EN_BALINADE_DEAD, 1, 1, 0x28); - this->onCeiling = 2; // Not used by body + pthis->onCeiling = 2; // Not used by body BossVa_SetDeathEnv(globalCtx); - func_8002DF54(globalCtx, &this->actor, 8); + func_8002DF54(globalCtx, &pthis->actor, 8); } break; case DEATH_CORE_BURST: - if (this->timer == 13) { + if (pthis->timer == 13) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); } - this->timer--; - if (this->timer == 0) { - sCameraNextAt.x = this->actor.world.pos.x; - sCameraNextAt.y = this->actor.world.pos.y + 30.0f; - sCameraNextAt.z = this->actor.world.pos.z; + pthis->timer--; + if (pthis->timer == 0) { + sCameraNextAt.x = pthis->actor.world.pos.x; + sCameraNextAt.y = pthis->actor.world.pos.y + 30.0f; + sCameraNextAt.z = pthis->actor.world.pos.z; sCameraNextEye.x = (Math_SinS(player->actor.shape.rot.y) * -130.0f) + player->actor.world.pos.x; sCameraNextEye.z = (Math_CosS(player->actor.shape.rot.y) * -130.0f) + player->actor.world.pos.z; @@ -1635,7 +1635,7 @@ void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { sCameraAtMaxVel = sCameraEyeMaxVel = sZeroVec; sCsState++; - this->timer = 133; + pthis->timer = 133; } break; case DEATH_MUSIC: @@ -1644,8 +1644,8 @@ void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { sCameraEyeMaxVel.y = sCameraEyeMaxVel.z; sCameraAtMaxVel = sCameraEyeMaxVel; - this->timer--; - if (this->timer == 0) { + pthis->timer--; + if (pthis->timer == 0) { Gameplay_ClearCamera(globalCtx, sCsCamera); sCsCamera = 0; func_80064534(globalCtx, &globalCtx->csCtx); @@ -1655,11 +1655,11 @@ void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { camera->at = sCameraAt; - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); sCsState++; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); for (i = 2, sp7C = 2; i > 0; i--) { if (Math_Vec3f_DistXYZ(&sWarpPos[i], &player->actor.world.pos) < @@ -1687,151 +1687,151 @@ void BossVa_BodyDeath(BossVa* this, GlobalContext* globalCtx) { Gameplay_CameraSetAtEye(globalCtx, sCsCamera, &sCameraAt, &sCameraEye); } - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->actor.shape.yOffset, -480.0f, 1.0f, 30.0f, 0.0f); - Math_SmoothStepToS(&this->vaBodySpinRate, 0, 1, 0xC8, 0); - Math_SmoothStepToS(&this->vaCamRotMod, 0, 1, 0xC8, 0); - Math_SmoothStepToS(&this->bodyGlow, 200, 1, 10, 0); + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -480.0f, 1.0f, 30.0f, 0.0f); + Math_SmoothStepToS(&pthis->vaBodySpinRate, 0, 1, 0xC8, 0); + Math_SmoothStepToS(&pthis->vaCamRotMod, 0, 1, 0xC8, 0); + Math_SmoothStepToS(&pthis->bodyGlow, 200, 1, 10, 0); if (globalCtx->envCtx.screenFillColor[3] != 0) { globalCtx->envCtx.screenFillColor[3] -= 50; } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - this->actor.shape.rot.y += this->vaBodySpinRate; - this->unk_1AC += this->vaCamRotMod; + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + pthis->actor.shape.rot.y += pthis->vaBodySpinRate; + pthis->unk_1AC += pthis->vaCamRotMod; - this->unk_1A0 = (Math_CosS(this->unk_1AC) * 0.1f) + 1.0f; - this->unk_1A4 = (Math_SinS(this->unk_1AC) * 0.05f) + 1.0f; + pthis->unk_1A0 = (Math_CosS(pthis->unk_1AC) * 0.1f) + 1.0f; + pthis->unk_1A4 = (Math_SinS(pthis->unk_1AC) * 0.05f) + 1.0f; } -void BossVa_SetupSupportIntro(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeSupportAttachedAnim, 0.0f, 0.0f, +void BossVa_SetupSupportIntro(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeSupportAttachedAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gBarinadeSupportAttachedAnim), ANIMMODE_LOOP_INTERP, 0.0f); - this->timer = 0; - BossVa_SetupAction(this, BossVa_SupportIntro); + pthis->timer = 0; + BossVa_SetupAction(pthis, BossVa_SupportIntro); } -void BossVa_SupportIntro(BossVa* this, GlobalContext* globalCtx) { - BossVa_AttachToBody(this); +void BossVa_SupportIntro(BossVa* pthis, GlobalContext* globalCtx) { + BossVa_AttachToBody(pthis); if (sCsState == BOSSVA_BATTLE) { - BossVa_SetupSupportAttached(this, globalCtx); + BossVa_SetupSupportAttached(pthis, globalCtx); } else if (sCsState >= INTRO_REVERSE_CAMERA) { - this->timer++; - if ((this->timer % 2) == 0) { - BossVa_Spark(globalCtx, this, 2, 90, 5.0f, 0.0f, SPARK_BODY, ((this->timer & 0x20) >> 5) + 1, true); + pthis->timer++; + if ((pthis->timer % 2) == 0) { + BossVa_Spark(globalCtx, pthis, 2, 90, 5.0f, 0.0f, SPARK_BODY, ((pthis->timer & 0x20) >> 5) + 1, true); } - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->skelAnime.playSpeed, 1.0f, 1.0f, 0.05f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 1.0f, 1.0f, 0.05f, 0.0f); if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } } } -void BossVa_SetupSupportAttached(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeSupportAttachedAnim, 1.0f, 0.0f, +void BossVa_SetupSupportAttached(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeSupportAttachedAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeSupportAttachedAnim), ANIMMODE_LOOP, 0.0f); - this->timer = this->actor.params * 10; - BossVa_SetupAction(this, BossVa_SupportAttached); + pthis->timer = pthis->actor.params * 10; + BossVa_SetupAction(pthis, BossVa_SupportAttached); } -void BossVa_SupportAttached(BossVa* this, GlobalContext* globalCtx) { - this->timer++; +void BossVa_SupportAttached(BossVa* pthis, GlobalContext* globalCtx) { + pthis->timer++; if (sBodyState & 0x7F) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 12); + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 12); if (Rand_ZeroOne() > 0.5f) { - Animation_Change(&this->skelAnime, &gBarinadeSupportDamage1Anim, 1.0f, 0.0f, + Animation_Change(&pthis->skelAnime, &gBarinadeSupportDamage1Anim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeSupportDamage1Anim), ANIMMODE_ONCE, 0.0f); } else { - Animation_Change(&this->skelAnime, &gBarinadeSupportDamage2Anim, 1.0f, 0.0f, + Animation_Change(&pthis->skelAnime, &gBarinadeSupportDamage2Anim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeSupportDamage2Anim), ANIMMODE_ONCE, 0.0f); } } - if (SkelAnime_Update(&this->skelAnime)) { - Animation_Change(&this->skelAnime, &gBarinadeSupportAttachedAnim, 1.0f, 0.0f, + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_Change(&pthis->skelAnime, &gBarinadeSupportAttachedAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeSupportAttachedAnim), ANIMMODE_LOOP, 0.0f); } - BossVa_AttachToBody(this); + BossVa_AttachToBody(pthis); if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - if (this->colliderSph.base.acFlags & AC_HIT) { - BossVa_SetupSupportCut(this, globalCtx); + if (pthis->colliderSph.base.acFlags & AC_HIT) { + BossVa_SetupSupportCut(pthis, globalCtx); } else { - if (this->actor.colorFilterTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + if (pthis->actor.colorFilterTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); } - if ((this->timer % 2) == 0) { - BossVa_Spark(globalCtx, this, 1, 100, 5.0f, 0.0f, SPARK_BODY, ((this->timer & 0x20) >> 5) + 1, true); + if ((pthis->timer % 2) == 0) { + BossVa_Spark(globalCtx, pthis, 1, 100, 5.0f, 0.0f, SPARK_BODY, ((pthis->timer & 0x20) >> 5) + 1, true); } } } -void BossVa_SetupSupportCut(BossVa* this, GlobalContext* globalCtx) { - s32 stumpParams = this->actor.params + BOSSVA_STUMP_1; +void BossVa_SetupSupportCut(BossVa* pthis, GlobalContext* globalCtx) { + s32 stumpParams = pthis->actor.params + BOSSVA_STUMP_1; sBodyState++; sFightPhase++; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_VA, this->armTip.x, this->armTip.y + 20.0f, this->armTip.z, - 0, this->actor.shape.rot.y, 0, stumpParams); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_VA, pthis->armTip.x, pthis->armTip.y + 20.0f, pthis->armTip.z, + 0, pthis->actor.shape.rot.y, 0, stumpParams); Camera_AddQuake(&globalCtx->mainCamera, 2, 11, 8); - this->burst = false; - this->timer2 = 0; - BossVa_SetupAction(this, BossVa_SupportCut); + pthis->burst = false; + pthis->timer2 = 0; + BossVa_SetupAction(pthis, BossVa_SupportCut); } -void BossVa_SupportCut(BossVa* this, GlobalContext* globalCtx) { - BossVa* vaBody = GET_BODY(this); +void BossVa_SupportCut(BossVa* pthis, GlobalContext* globalCtx) { + BossVa* vaBody = GET_BODY(pthis); f32 lastFrame; - BossVa_AttachToBody(this); + BossVa_AttachToBody(pthis); - if (this->onCeiling) { + if (pthis->onCeiling) { lastFrame = Animation_GetLastFrame(&gBarinadeSupportCutAnim); - this->onCeiling = false; - this->timer = (s32)(Rand_ZeroOne() * 10.0f) + 5; - SkelAnime_Free(&this->skelAnime, globalCtx); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBarinadeCutSupportSkel, &gBarinadeSupportCutAnim, NULL, NULL, + pthis->onCeiling = false; + pthis->timer = (s32)(Rand_ZeroOne() * 10.0f) + 5; + SkelAnime_Free(&pthis->skelAnime, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBarinadeCutSupportSkel, &gBarinadeSupportCutAnim, NULL, NULL, 0); - Animation_Change(&this->skelAnime, &gBarinadeSupportCutAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + Animation_Change(&pthis->skelAnime, &gBarinadeSupportCutAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); sBodyState = 0; - GET_BODY(this)->actor.shape.yOffset -= 60.0f; + GET_BODY(pthis)->actor.shape.yOffset -= 60.0f; - switch (this->actor.params) { + switch (pthis->actor.params) { case BOSSVA_SUPPORT_1: - GET_BODY(this)->actor.world.rot.x += 0x4B0; + GET_BODY(pthis)->actor.world.rot.x += 0x4B0; break; case BOSSVA_SUPPORT_2: - GET_BODY(this)->actor.world.rot.x -= 0x258; - GET_BODY(this)->actor.world.rot.z -= 0x4E2; + GET_BODY(pthis)->actor.world.rot.x -= 0x258; + GET_BODY(pthis)->actor.world.rot.z -= 0x4E2; break; case BOSSVA_SUPPORT_3: - GET_BODY(this)->actor.world.rot.x -= 0x258; - GET_BODY(this)->actor.world.rot.z += 0x4E2; + GET_BODY(pthis)->actor.world.rot.x -= 0x258; + GET_BODY(pthis)->actor.world.rot.z += 0x4E2; break; } } - Math_SmoothStepToS(&this->headRot.x, vaBody->vaBodySpinRate * -3, 1, 0x4B0, 0); - if (SkelAnime_Update(&this->skelAnime)) { + Math_SmoothStepToS(&pthis->headRot.x, vaBody->vaBodySpinRate * -3, 1, 0x4B0, 0); + if (SkelAnime_Update(&pthis->skelAnime)) { lastFrame = Animation_GetLastFrame(&gBarinadeSupportDetachedAnim); - Animation_Change(&this->skelAnime, &gBarinadeSupportDetachedAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, + Animation_Change(&pthis->skelAnime, &gBarinadeSupportDetachedAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } - if ((this->timer == 0) && (sCsState < DEATH_START)) { - this->timer = (s32)(Rand_ZeroOne() * 10.0f) + 10; - BossVa_BloodDroplets(globalCtx, &this->armTip, this->headRot.x, this->actor.shape.rot.y); + if ((pthis->timer == 0) && (sCsState < DEATH_START)) { + pthis->timer = (s32)(Rand_ZeroOne() * 10.0f) + 10; + BossVa_BloodDroplets(globalCtx, &pthis->armTip, pthis->headRot.x, pthis->actor.shape.rot.y); } if (sCsState >= DEATH_START) { - Math_SmoothStepToF(&this->skelAnime.playSpeed, 0.0f, 0.3f, 0.25f, 0.125f); + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 0.0f, 0.3f, 0.25f, 0.125f); } switch (sCsState) { @@ -1846,87 +1846,87 @@ void BossVa_SupportCut(BossVa* this, GlobalContext* globalCtx) { case DEATH_CORE_TUMORS: case DEATH_CORE_DEAD: case DEATH_CORE_BURST: - if (!this->burst) { + if (!pthis->burst) { if ((globalCtx->gameplayFrames % 2) != 0) { - BossVa_Tumor(globalCtx, this, 1, (s16)Rand_CenteredFloat(5.0f) + 6, 7.0f, 5.0f, TUMOR_ARM, - (this->timer2 >> 3) + 1, true); + BossVa_Tumor(globalCtx, pthis, 1, (s16)Rand_CenteredFloat(5.0f) + 6, 7.0f, 5.0f, TUMOR_ARM, + (pthis->timer2 >> 3) + 1, true); } - this->timer2++; - if (this->timer2 >= 32) { - this->burst++; - this->isDead = true; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BREAK2); - if (this->actor.params == BOSSVA_SUPPORT_3) { + pthis->timer2++; + if (pthis->timer2 >= 32) { + pthis->burst++; + pthis->isDead = true; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BREAK2); + if (pthis->actor.params == BOSSVA_SUPPORT_3) { sCsState++; } } } else { - this->timer2--; - if (this->timer2 == 0) { - Actor_Kill(&this->actor); + pthis->timer2--; + if (pthis->timer2 == 0) { + Actor_Kill(&pthis->actor); } } break; } - this->timer--; + pthis->timer--; } -void BossVa_SetupStump(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeStumpAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeStumpAnim), +void BossVa_SetupStump(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeStumpAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeStumpAnim), ANIMMODE_ONCE, 0.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_Stump); + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_Stump); } -void BossVa_Stump(BossVa* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) && (Rand_ZeroOne() < 0.3f)) { - this->skelAnime.curFrame -= Rand_ZeroOne() * 3.0f; +void BossVa_Stump(BossVa* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) && (Rand_ZeroOne() < 0.3f)) { + pthis->skelAnime.curFrame -= Rand_ZeroOne() * 3.0f; } if (sCsState >= DEATH_START) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void BossVa_SetupZapperIntro(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupZapperIntro(BossVa* pthis, GlobalContext* globalCtx) { f32 lastFrame = Animation_GetLastFrame(&gBarinadeZapperIdleAnim); - Animation_Change(&this->skelAnime, &gBarinadeZapperIdleAnim, 1.0f, lastFrame - 1.0f, lastFrame, + Animation_Change(&pthis->skelAnime, &gBarinadeZapperIdleAnim, 1.0f, lastFrame - 1.0f, lastFrame, ANIMMODE_LOOP_INTERP, -6.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_ZapperIntro); + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_ZapperIntro); } -void BossVa_ZapperIntro(BossVa* this, GlobalContext* globalCtx) { - BossVa_AttachToBody(this); +void BossVa_ZapperIntro(BossVa* pthis, GlobalContext* globalCtx) { + BossVa_AttachToBody(pthis); switch (sCsState) { case INTRO_TITLE: case INTRO_BRIGHTEN: case INTRO_FINISH: - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); break; case BOSSVA_BATTLE: - BossVa_SetupZapperAttack(this, globalCtx); + BossVa_SetupZapperAttack(pthis, globalCtx); break; } - Math_SmoothStepToS(&this->unk_1F2, this->actor.shape.rot.y - this->actor.shape.rot.x, 1, 0x2EE, 0); - Math_SmoothStepToS(&this->unk_1F0, this->skelAnime.jointTable[7].z, 1, 0x2EE, 0); + Math_SmoothStepToS(&pthis->unk_1F2, pthis->actor.shape.rot.y - pthis->actor.shape.rot.x, 1, 0x2EE, 0); + Math_SmoothStepToS(&pthis->unk_1F0, pthis->skelAnime.jointTable[7].z, 1, 0x2EE, 0); } -void BossVa_SetupZapperAttack(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupZapperAttack(BossVa* pthis, GlobalContext* globalCtx) { f32 lastFrame = Animation_GetLastFrame(&gBarinadeZapperIdleAnim); - Animation_Change(&this->skelAnime, &gBarinadeZapperIdleAnim, 1.0f, lastFrame - 1.0f, lastFrame, + Animation_Change(&pthis->skelAnime, &gBarinadeZapperIdleAnim, 1.0f, lastFrame - 1.0f, lastFrame, ANIMMODE_LOOP_INTERP, -6.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_ZapperAttack); + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_ZapperAttack); } -void BossVa_ZapperAttack(BossVa* this, GlobalContext* globalCtx) { +void BossVa_ZapperAttack(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnBoom* boomerang; Actor* boomTarget; @@ -2002,36 +2002,36 @@ void BossVa_ZapperAttack(BossVa* this, GlobalContext* globalCtx) { sp90 = 0x3E80; } - SkelAnime_Update(&this->skelAnime); - BossVa_AttachToBody(this); + SkelAnime_Update(&pthis->skelAnime); + BossVa_AttachToBody(pthis); if (sFightPhase >= PHASE_4) { - BossVa_SetupZapperEnraged(this, globalCtx); + BossVa_SetupZapperEnraged(pthis, globalCtx); return; } if (sBodyState & 0x7F) { - BossVa_SetupZapperDamaged(this, globalCtx); + BossVa_SetupZapperDamaged(pthis, globalCtx); return; } - if ((sFightPhase < PHASE_4) && (GET_BODY(this)->actor.speedXZ != 0.0f)) { - BossVa_SetupZapperHold(this, globalCtx); + if ((sFightPhase < PHASE_4) && (GET_BODY(pthis)->actor.speedXZ != 0.0f)) { + BossVa_SetupZapperHold(pthis, globalCtx); return; } - sp98 = Math_Vec3f_Yaw(&sp7C, &this->armTip); - tmp17 = sp98 - this->actor.shape.rot.y; + sp98 = Math_Vec3f_Yaw(&sp7C, &pthis->armTip); + tmp17 = sp98 - pthis->actor.shape.rot.y; - if ((sp8E >= ABS(tmp17) || this->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & 0x04000000)) { + if ((sp8E >= ABS(tmp17) || pthis->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & 0x04000000)) { - if (!this->burst) { - sp94 = sp98 - this->actor.shape.rot.y; + if (!pthis->burst) { + sp94 = sp98 - pthis->actor.shape.rot.y; if (ABS(sp94) > 0x1770) { sp94 = (sp94 > 0) ? 0x1770 : -0x1770; } - tmp17 = Math_SmoothStepToS(&this->unk_1E6, sp94, 1, 0x6D6, 0); + tmp17 = Math_SmoothStepToS(&pthis->unk_1E6, sp94, 1, 0x6D6, 0); sp88 = ABS(tmp17); sp94 = sp98 - sp94; @@ -2040,223 +2040,223 @@ void BossVa_ZapperAttack(BossVa* this, GlobalContext* globalCtx) { sp94 = (sp94 > 0) ? 0x1770 : -0x1770; } - tmp17 = Math_SmoothStepToS(&this->unk_1EC, sp94, 1, 0x6D6, 0); + tmp17 = Math_SmoothStepToS(&pthis->unk_1EC, sp94, 1, 0x6D6, 0); sp88 += ABS(tmp17); - yaw = Math_Vec3f_Yaw(&this->zapHeadPos, &sp7C); - tmp17 = Math_SmoothStepToS(&this->unk_1F2, yaw - 0x4000, 1, 0x9C4, 0); + yaw = Math_Vec3f_Yaw(&pthis->zapHeadPos, &sp7C); + tmp17 = Math_SmoothStepToS(&pthis->unk_1F2, yaw - 0x4000, 1, 0x9C4, 0); sp88 += ABS(tmp17); - sp96 = this->actor.shape.rot.x + this->skelAnime.jointTable[1].z + this->skelAnime.jointTable[2].z + - this->skelAnime.jointTable[3].z + this->skelAnime.jointTable[4].z + this->skelAnime.jointTable[5].z; + sp96 = pthis->actor.shape.rot.x + pthis->skelAnime.jointTable[1].z + pthis->skelAnime.jointTable[2].z + + pthis->skelAnime.jointTable[3].z + pthis->skelAnime.jointTable[4].z + pthis->skelAnime.jointTable[5].z; - yaw = Math_Vec3f_Pitch(&sp7C, &this->zapNeckPos); - tmp17 = Math_SmoothStepToS(&this->unk_1EA, yaw - sp96, 1, 0xFA0, 0); + yaw = Math_Vec3f_Pitch(&sp7C, &pthis->zapNeckPos); + tmp17 = Math_SmoothStepToS(&pthis->unk_1EA, yaw - sp96, 1, 0xFA0, 0); sp88 += ABS(tmp17); - yaw = Math_Vec3f_Pitch(&this->zapHeadPos, &sp7C); - tmp17 = Math_SmoothStepToS(&this->unk_1F0, -yaw, 1, 0xFA0, 0); + yaw = Math_Vec3f_Pitch(&pthis->zapHeadPos, &sp7C); + tmp17 = Math_SmoothStepToS(&pthis->unk_1F0, -yaw, 1, 0xFA0, 0); sp88 += ABS(tmp17); - this->skelAnime.playSpeed = 0.0f; - if (Math_SmoothStepToF(&this->skelAnime.curFrame, 0.0f, 1.0f, 2.0f, 0.0f) == 0.0f) { + pthis->skelAnime.playSpeed = 0.0f; + if (Math_SmoothStepToF(&pthis->skelAnime.curFrame, 0.0f, 1.0f, 2.0f, 0.0f) == 0.0f) { if (sp88 < sp90) { - this->timer2 = 0; - this->burst++; - this->unk_1D8 = sp7C; + pthis->timer2 = 0; + pthis->burst++; + pthis->unk_1D8 = sp7C; } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } } } } else { - if (this->burst || (this->timer2 < 0)) { - if (this->colliderLightning.base.atFlags & AT_HIT) { - if (this->timer2 > 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_HIT_RINK); + if (pthis->burst || (pthis->timer2 < 0)) { + if (pthis->colliderLightning.base.atFlags & AT_HIT) { + if (pthis->timer2 > 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_HIT_RINK); BossVa_SetSparkEnv(globalCtx); - this->timer2 = -1; - GET_BODY(this)->onCeiling = 6; // not used by body + pthis->timer2 = -1; + GET_BODY(pthis)->onCeiling = 6; // not used by body } - } else if (this->timer2 > 0) { - this->timer2 = 0; + } else if (pthis->timer2 > 0) { + pthis->timer2 = 0; } - if ((this->timer2 < 0) && (player->stateFlags1 & 0x4000000)) { - BossVa_Spark(globalCtx, this, 1, 30, 0.0f, 0.0f, SPARK_LINK, 0.0f, true); + if ((pthis->timer2 < 0) && (player->stateFlags1 & 0x4000000)) { + BossVa_Spark(globalCtx, pthis, 1, 30, 0.0f, 0.0f, SPARK_LINK, 0.0f, true); } } - Math_SmoothStepToS(&this->unk_1E6, 0, 1, 0x6D6, 0); - Math_SmoothStepToS(&this->unk_1EC, 0, 1, 0x6D6, 0); - Math_SmoothStepToS(&this->unk_1EA, 0, 1, 0x6D6, 0); - Math_SmoothStepToS(&this->unk_1F2, this->actor.shape.rot.y - this->actor.shape.rot.x, 1, 0x6D6, 0); - Math_SmoothStepToS(&this->unk_1F0, this->skelAnime.jointTable[7].z, 1, 0x6D6, 0); - Math_SmoothStepToF(&this->skelAnime.playSpeed, 1.0f, 1.0f, 0.05f, 0.0f); - this->burst = false; + Math_SmoothStepToS(&pthis->unk_1E6, 0, 1, 0x6D6, 0); + Math_SmoothStepToS(&pthis->unk_1EC, 0, 1, 0x6D6, 0); + Math_SmoothStepToS(&pthis->unk_1EA, 0, 1, 0x6D6, 0); + Math_SmoothStepToS(&pthis->unk_1F2, pthis->actor.shape.rot.y - pthis->actor.shape.rot.x, 1, 0x6D6, 0); + Math_SmoothStepToS(&pthis->unk_1F0, pthis->skelAnime.jointTable[7].z, 1, 0x6D6, 0); + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 1.0f, 1.0f, 0.05f, 0.0f); + pthis->burst = false; } - if (this->burst && (this->burst != 2)) { // burst can never be 2 - if (this->timer2 >= 32) { - if (this->timer2 == 32) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_THUNDER); + if (pthis->burst && (pthis->burst != 2)) { // burst can never be 2 + if (pthis->timer2 >= 32) { + if (pthis->timer2 == 32) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_THUNDER); } - BossVa_Spark(globalCtx, this, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 5.0f, true); - BossVa_Spark(globalCtx, this, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 6.0f, true); - BossVa_Spark(globalCtx, this, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 7.0f, true); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderLightning.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderLightning.base); + BossVa_Spark(globalCtx, pthis, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 5.0f, true); + BossVa_Spark(globalCtx, pthis, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 6.0f, true); + BossVa_Spark(globalCtx, pthis, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 7.0f, true); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLightning.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLightning.base); } else { - BossVa_Spark(globalCtx, this, 2, 50, 15.0f, 0.0f, SPARK_BODY, (this->timer2 >> 3) + 1, true); - if (this->timer2 == 30) { + BossVa_Spark(globalCtx, pthis, 2, 50, 15.0f, 0.0f, SPARK_BODY, (pthis->timer2 >> 3) + 1, true); + if (pthis->timer2 == 30) { BossVa_SetSparkEnv(globalCtx); } - if (this->timer2 == 20) { - Vec3f sp44 = this->zapHeadPos; + if (pthis->timer2 == 20) { + Vec3f sp44 = pthis->zapHeadPos; - BossVa_SpawnZapperCharge(globalCtx, sVaEffects, this, &sp44, &this->headRot, 100, 0); + BossVa_SpawnZapperCharge(globalCtx, sVaEffects, pthis, &sp44, &pthis->headRot, 100, 0); } } - this->timer2++; - if (this->timer2 >= 40) { - this->burst = false; + pthis->timer2++; + if (pthis->timer2 >= 40) { + pthis->burst = false; } } } -void BossVa_SetupZapperDamaged(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupZapperDamaged(BossVa* pthis, GlobalContext* globalCtx) { if (Rand_ZeroOne() > 0.5f) { - Animation_Change(&this->skelAnime, &gBarinadeZapperDamage1Anim, 0.5f, 0.0f, + Animation_Change(&pthis->skelAnime, &gBarinadeZapperDamage1Anim, 0.5f, 0.0f, Animation_GetLastFrame(&gBarinadeZapperDamage1Anim), ANIMMODE_ONCE_INTERP, 4.0f); } else { - Animation_Change(&this->skelAnime, &gBarinadeZapperDamage2Anim, 0.5f, 0.0f, + Animation_Change(&pthis->skelAnime, &gBarinadeZapperDamage2Anim, 0.5f, 0.0f, Animation_GetLastFrame(&gBarinadeZapperDamage2Anim), ANIMMODE_ONCE_INTERP, 4.0f); } - Actor_SetColorFilter(&this->actor, 0, 255, 0, 12); - this->burst = false; - BossVa_SetupAction(this, BossVa_ZapperDamaged); + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 12); + pthis->burst = false; + BossVa_SetupAction(pthis, BossVa_ZapperDamaged); } -void BossVa_ZapperDamaged(BossVa* this, GlobalContext* globalCtx) { - BossVa_AttachToBody(this); - Math_SmoothStepToS(&this->unk_1E6, 0, 1, 0xFA0, 0); - Math_SmoothStepToS(&this->unk_1E4, 0, 1, 0xFA0, 0); - Math_SmoothStepToS(&this->unk_1EC, 0, 1, 0xFA0, 0); - Math_SmoothStepToS(&this->unk_1EA, 0, 1, 0xFA0, 0); - Math_SmoothStepToS(&this->unk_1F2, this->actor.shape.rot.y - this->actor.shape.rot.x, 1, 0x2EE, 0); - Math_SmoothStepToS(&this->unk_1F0, this->skelAnime.jointTable[7].z, 1, 0x2EE, 0); - if (SkelAnime_Update(&this->skelAnime)) { +void BossVa_ZapperDamaged(BossVa* pthis, GlobalContext* globalCtx) { + BossVa_AttachToBody(pthis); + Math_SmoothStepToS(&pthis->unk_1E6, 0, 1, 0xFA0, 0); + Math_SmoothStepToS(&pthis->unk_1E4, 0, 1, 0xFA0, 0); + Math_SmoothStepToS(&pthis->unk_1EC, 0, 1, 0xFA0, 0); + Math_SmoothStepToS(&pthis->unk_1EA, 0, 1, 0xFA0, 0); + Math_SmoothStepToS(&pthis->unk_1F2, pthis->actor.shape.rot.y - pthis->actor.shape.rot.x, 1, 0x2EE, 0); + Math_SmoothStepToS(&pthis->unk_1F0, pthis->skelAnime.jointTable[7].z, 1, 0x2EE, 0); + if (SkelAnime_Update(&pthis->skelAnime)) { if (sFightPhase >= PHASE_4) { - BossVa_SetupZapperEnraged(this, globalCtx); + BossVa_SetupZapperEnraged(pthis, globalCtx); } else { - BossVa_SetupZapperAttack(this, globalCtx); + BossVa_SetupZapperAttack(pthis, globalCtx); } } } -void BossVa_SetupZapperDeath(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupZapperDeath(BossVa* pthis, GlobalContext* globalCtx) { f32 lastFrame = Animation_GetLastFrame(&gBarinadeZapperIdleAnim); - Animation_Change(&this->skelAnime, &gBarinadeZapperIdleAnim, Rand_ZeroOne() + 0.25f, Rand_ZeroOne() * 3.0f, + Animation_Change(&pthis->skelAnime, &gBarinadeZapperIdleAnim, Rand_ZeroOne() + 0.25f, Rand_ZeroOne() * 3.0f, lastFrame, ANIMMODE_LOOP_INTERP, -6.0f); - this->burst = false; - this->timer2 = (this->actor.params * -6) + 18; - this->unk_1B0 = 0; - BossVa_SetupAction(this, BossVa_ZapperDeath); + pthis->burst = false; + pthis->timer2 = (pthis->actor.params * -6) + 18; + pthis->unk_1B0 = 0; + BossVa_SetupAction(pthis, BossVa_ZapperDeath); } -void BossVa_ZapperDeath(BossVa* this, GlobalContext* globalCtx) { +void BossVa_ZapperDeath(BossVa* pthis, GlobalContext* globalCtx) { f32 sp3C = 55.0f; f32 tmpf1; f32 tmpf2; - BossVa_AttachToBody(this); + BossVa_AttachToBody(pthis); if (((globalCtx->gameplayFrames % 32) == 0) && (sCsState <= DEATH_BODY_TUMORS)) { - this->unk_1E8 = Rand_CenteredFloat(0x4000); - this->unk_1EE = Rand_CenteredFloat(0x4000); - this->unk_1F4 = (s16)Rand_CenteredFloat(0x4000) + this->actor.shape.rot.y - this->actor.shape.rot.x; + pthis->unk_1E8 = Rand_CenteredFloat(0x4000); + pthis->unk_1EE = Rand_CenteredFloat(0x4000); + pthis->unk_1F4 = (s16)Rand_CenteredFloat(0x4000) + pthis->actor.shape.rot.y - pthis->actor.shape.rot.x; } else { - Math_SmoothStepToF(&this->skelAnime.playSpeed, 0.0f, 1.0f, 0.025f, 0.0f); + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 0.0f, 1.0f, 0.025f, 0.0f); } - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_1E6, this->unk_1E8, 1, (s16)Rand_CenteredFloat(500.0f) + 0x1F4, 0); - Math_SmoothStepToS(&this->unk_1E4, 0, 1, 0x1F4, 0); - Math_SmoothStepToS(&this->unk_1EC, this->unk_1EE, 1, (s16)Rand_CenteredFloat(500.0f) + 0x1F4, 0); - Math_SmoothStepToS(&this->unk_1EA, 0, 1, 0x1F4, 0); - Math_SmoothStepToS(&this->unk_1F2, this->unk_1F4, 1, (s16)Rand_CenteredFloat(500.0f) + 0x1F4, 0); + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->unk_1E6, pthis->unk_1E8, 1, (s16)Rand_CenteredFloat(500.0f) + 0x1F4, 0); + Math_SmoothStepToS(&pthis->unk_1E4, 0, 1, 0x1F4, 0); + Math_SmoothStepToS(&pthis->unk_1EC, pthis->unk_1EE, 1, (s16)Rand_CenteredFloat(500.0f) + 0x1F4, 0); + Math_SmoothStepToS(&pthis->unk_1EA, 0, 1, 0x1F4, 0); + Math_SmoothStepToS(&pthis->unk_1F2, pthis->unk_1F4, 1, (s16)Rand_CenteredFloat(500.0f) + 0x1F4, 0); switch (sCsState) { case DEATH_ZAPPER_2: sp3C = -55.0f; case DEATH_ZAPPER_1: case DEATH_ZAPPER_3: - if (!this->burst) { - if (((this->actor.params == BOSSVA_ZAPPER_1) && (this->timer2 < 16)) || - ((this->actor.params == BOSSVA_ZAPPER_2) && (this->timer2 < 24)) || - (this->actor.params == BOSSVA_ZAPPER_3)) { + if (!pthis->burst) { + if (((pthis->actor.params == BOSSVA_ZAPPER_1) && (pthis->timer2 < 16)) || + ((pthis->actor.params == BOSSVA_ZAPPER_2) && (pthis->timer2 < 24)) || + (pthis->actor.params == BOSSVA_ZAPPER_3)) { - if ((this->timer2 % 2) == 0 && (this->timer2 >= 0)) { - if (this->timer2 < 8) { - BossVa_Tumor(globalCtx, this, 1, (s16)Rand_CenteredFloat(5.0f) + 0xD, 0.0f, 0.0f, TUMOR_ARM, + if ((pthis->timer2 % 2) == 0 && (pthis->timer2 >= 0)) { + if (pthis->timer2 < 8) { + BossVa_Tumor(globalCtx, pthis, 1, (s16)Rand_CenteredFloat(5.0f) + 0xD, 0.0f, 0.0f, TUMOR_ARM, 0.6f, true); } else { - BossVa_Tumor(globalCtx, this, 1, (s16)Rand_CenteredFloat(5.0f) + 6, 0.0f, 7.0f, TUMOR_ARM, - (this->timer2 >> 3) + 1, true); + BossVa_Tumor(globalCtx, pthis, 1, (s16)Rand_CenteredFloat(5.0f) + 6, 0.0f, 7.0f, TUMOR_ARM, + (pthis->timer2 >> 3) + 1, true); } - BossVa_Spark(globalCtx, this, 2, 50, 15.0f, 0.0f, SPARK_BODY, (this->timer2 >> 3) + 1, true); + BossVa_Spark(globalCtx, pthis, 2, 50, 15.0f, 0.0f, SPARK_BODY, (pthis->timer2 >> 3) + 1, true); } - this->timer2++; - if (this->timer2 >= 32) { - this->burst++; - this->isDead = true; + pthis->timer2++; + if (pthis->timer2 >= 32) { + pthis->burst++; + pthis->isDead = true; BossVa_SetDeathEnv(globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BREAK2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BREAK2); } } else { - this->burst++; - this->isDead = true; - this->timer2 = 32; + pthis->burst++; + pthis->isDead = true; + pthis->timer2 = 32; sCsState++; } - if ((this->actor.params - BOSSVA_ZAPPER_1 + DEATH_ZAPPER_1) == sCsState) { - sCameraAt.x = this->zapNeckPos.x; - sCameraEye.y = sCameraAt.y = this->zapNeckPos.y; - sCameraAt.z = this->zapNeckPos.z; - sCameraEye.x = (Math_CosS(-(this->actor.shape.rot.y + this->unk_1B0)) * sp3C) + this->zapNeckPos.x; - sCameraEye.z = (Math_SinS(-(this->actor.shape.rot.y + this->unk_1B0)) * sp3C) + this->zapNeckPos.z; - this->unk_1B0 += 0x15E; + if ((pthis->actor.params - BOSSVA_ZAPPER_1 + DEATH_ZAPPER_1) == sCsState) { + sCameraAt.x = pthis->zapNeckPos.x; + sCameraEye.y = sCameraAt.y = pthis->zapNeckPos.y; + sCameraAt.z = pthis->zapNeckPos.z; + sCameraEye.x = (Math_CosS(-(pthis->actor.shape.rot.y + pthis->unk_1B0)) * sp3C) + pthis->zapNeckPos.x; + sCameraEye.z = (Math_SinS(-(pthis->actor.shape.rot.y + pthis->unk_1B0)) * sp3C) + pthis->zapNeckPos.z; + pthis->unk_1B0 += 0x15E; } } else { - this->timer2--; - if (this->timer2 == 0) { - if (this->actor.params == BOSSVA_ZAPPER_3) { + pthis->timer2--; + if (pthis->timer2 == 0) { + if (pthis->actor.params == BOSSVA_ZAPPER_3) { sCsState++; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } break; } } -void BossVa_SetupZapperEnraged(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupZapperEnraged(BossVa* pthis, GlobalContext* globalCtx) { f32 lastFrame = Animation_GetLastFrame(&gBarinadeZapperIdleAnim); - Animation_Change(&this->skelAnime, &gBarinadeZapperIdleAnim, 1.0f, lastFrame - 1.0f, lastFrame, + Animation_Change(&pthis->skelAnime, &gBarinadeZapperIdleAnim, 1.0f, lastFrame - 1.0f, lastFrame, ANIMMODE_LOOP_INTERP, -6.0f); - this->burst = false; - BossVa_SetupAction(this, BossVa_ZapperEnraged); + pthis->burst = false; + BossVa_SetupAction(pthis, BossVa_ZapperEnraged); } -void BossVa_ZapperEnraged(BossVa* this, GlobalContext* globalCtx) { +void BossVa_ZapperEnraged(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; s16 tmp16; @@ -2268,32 +2268,32 @@ void BossVa_ZapperEnraged(BossVa* this, GlobalContext* globalCtx) { Vec3f sp54 = player->actor.world.pos; sp54.y += 10.0f; - SkelAnime_Update(&this->skelAnime); - BossVa_AttachToBody(this); + SkelAnime_Update(&pthis->skelAnime); + BossVa_AttachToBody(pthis); if (sFightPhase >= PHASE_DEATH) { - BossVa_SetupZapperDeath(this, globalCtx); + BossVa_SetupZapperDeath(pthis, globalCtx); return; } if (sBodyState & 0x7E) { - BossVa_SetupZapperDamaged(this, globalCtx); + BossVa_SetupZapperDamaged(pthis, globalCtx); return; } sp54.y += 25.0; - sp6C = Math_Vec3f_Yaw(&sp54, &this->armTip); - tmp16 = sp6C - this->actor.shape.rot.y; + sp6C = Math_Vec3f_Yaw(&sp54, &pthis->armTip); + tmp16 = sp6C - pthis->actor.shape.rot.y; - if ((ABS(tmp16) <= 0x4650 || this->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & 0x04000000)) { - if (!this->burst) { + if ((ABS(tmp16) <= 0x4650 || pthis->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & 0x04000000)) { + if (!pthis->burst) { - sp68 = sp6C - this->actor.shape.rot.y; + sp68 = sp6C - pthis->actor.shape.rot.y; if (ABS(sp68) > 0x1770) { sp68 = (sp68 > 0) ? 0x1770 : -0x1770; } - tmp16 = Math_SmoothStepToS(&this->unk_1E6, sp68, 1, 0xDAC, 0); + tmp16 = Math_SmoothStepToS(&pthis->unk_1E6, sp68, 1, 0xDAC, 0); sp60 = ABS(tmp16); sp68 = sp6C - sp68; @@ -2301,199 +2301,199 @@ void BossVa_ZapperEnraged(BossVa* this, GlobalContext* globalCtx) { sp68 = sp68 > 0 ? 0x1770 : -0x1770; } - tmp16 = Math_SmoothStepToS(&this->unk_1EC, sp68, 1, 0xDAC, 0); + tmp16 = Math_SmoothStepToS(&pthis->unk_1EC, sp68, 1, 0xDAC, 0); sp60 += ABS(tmp16); - yaw = Math_Vec3f_Yaw(&this->zapHeadPos, &sp54); - tmp16 = Math_SmoothStepToS(&this->unk_1F2, yaw - 0x4000, 1, 0xEA6, 0); + yaw = Math_Vec3f_Yaw(&pthis->zapHeadPos, &sp54); + tmp16 = Math_SmoothStepToS(&pthis->unk_1F2, yaw - 0x4000, 1, 0xEA6, 0); sp60 += ABS(tmp16); - sp6A = this->actor.shape.rot.x + this->skelAnime.jointTable[1].x + this->skelAnime.jointTable[2].x + - this->skelAnime.jointTable[3].x + this->skelAnime.jointTable[4].x + this->skelAnime.jointTable[5].x; + sp6A = pthis->actor.shape.rot.x + pthis->skelAnime.jointTable[1].x + pthis->skelAnime.jointTable[2].x + + pthis->skelAnime.jointTable[3].x + pthis->skelAnime.jointTable[4].x + pthis->skelAnime.jointTable[5].x; - yaw = Math_Vec3f_Pitch(&sp54, &this->zapNeckPos); - tmp16 = Math_SmoothStepToS(&this->unk_1EA, yaw - sp6A, 1, 0x1B58, 0); + yaw = Math_Vec3f_Pitch(&sp54, &pthis->zapNeckPos); + tmp16 = Math_SmoothStepToS(&pthis->unk_1EA, yaw - sp6A, 1, 0x1B58, 0); sp60 += ABS(tmp16); - yaw = Math_Vec3f_Pitch(&this->zapHeadPos, &sp54); - tmp16 = Math_SmoothStepToS(&this->unk_1F0, -yaw, 1, 0x1B58, 0); + yaw = Math_Vec3f_Pitch(&pthis->zapHeadPos, &sp54); + tmp16 = Math_SmoothStepToS(&pthis->unk_1F0, -yaw, 1, 0x1B58, 0); sp60 += ABS(tmp16); - this->skelAnime.playSpeed = 0.0f; - if ((Math_SmoothStepToF(&this->skelAnime.curFrame, 0.0f, 1.0f, 3.0f, 0.0f) == 0.0f) && (sp60 < 0x258)) { - this->timer2 = 0; - this->burst++; - this->unk_1D8 = sp54; + pthis->skelAnime.playSpeed = 0.0f; + if ((Math_SmoothStepToF(&pthis->skelAnime.curFrame, 0.0f, 1.0f, 3.0f, 0.0f) == 0.0f) && (sp60 < 0x258)) { + pthis->timer2 = 0; + pthis->burst++; + pthis->unk_1D8 = sp54; if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } } } } else { - if (this->burst || (this->timer2 < 0)) { - if (this->colliderLightning.base.atFlags & AT_HIT) { - if (this->timer2 > 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_HIT_RINK); + if (pthis->burst || (pthis->timer2 < 0)) { + if (pthis->colliderLightning.base.atFlags & AT_HIT) { + if (pthis->timer2 > 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_HIT_RINK); BossVa_SetSparkEnv(globalCtx); - this->timer2 = -1; - GET_BODY(this)->onCeiling = 6; // not used by body + pthis->timer2 = -1; + GET_BODY(pthis)->onCeiling = 6; // not used by body } - } else if (this->timer2 > 0) { - this->timer2 = 0; + } else if (pthis->timer2 > 0) { + pthis->timer2 = 0; } - if ((this->timer2 < 0) && (player->stateFlags1 & 0x4000000)) { - BossVa_Spark(globalCtx, this, 1, 30, 0.0f, 0, SPARK_LINK, 0.0f, true); + if ((pthis->timer2 < 0) && (player->stateFlags1 & 0x4000000)) { + BossVa_Spark(globalCtx, pthis, 1, 30, 0.0f, 0, SPARK_LINK, 0.0f, true); } } - Math_SmoothStepToS(&this->unk_1E6, 0, 1, 0xEA6, 0); - Math_SmoothStepToS(&this->unk_1EC, 0, 1, 0xEA6, 0); - Math_SmoothStepToS(&this->unk_1EA, 0, 1, 0xEA6, 0); - Math_SmoothStepToS(&this->unk_1F2, this->actor.shape.rot.y - this->actor.shape.rot.x, 1, 0xEA6, 0); - Math_SmoothStepToS(&this->unk_1F0, this->skelAnime.jointTable[7].z, 1, 0xEA6, 0); - Math_SmoothStepToF(&this->skelAnime.playSpeed, 1.0f, 1.0f, 0.05f, 0.0f); - this->burst = false; + Math_SmoothStepToS(&pthis->unk_1E6, 0, 1, 0xEA6, 0); + Math_SmoothStepToS(&pthis->unk_1EC, 0, 1, 0xEA6, 0); + Math_SmoothStepToS(&pthis->unk_1EA, 0, 1, 0xEA6, 0); + Math_SmoothStepToS(&pthis->unk_1F2, pthis->actor.shape.rot.y - pthis->actor.shape.rot.x, 1, 0xEA6, 0); + Math_SmoothStepToS(&pthis->unk_1F0, pthis->skelAnime.jointTable[7].z, 1, 0xEA6, 0); + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 1.0f, 1.0f, 0.05f, 0.0f); + pthis->burst = false; } - if (this->burst && (this->burst != 2)) { // burst can never be 2 - if (this->timer2 >= 16) { - if (this->timer2 == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_THUNDER); + if (pthis->burst && (pthis->burst != 2)) { // burst can never be 2 + if (pthis->timer2 >= 16) { + if (pthis->timer2 == 18) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_THUNDER); } - BossVa_Spark(globalCtx, this, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 5.0f, true); - BossVa_Spark(globalCtx, this, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 6.0f, true); - BossVa_Spark(globalCtx, this, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 7.0f, true); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderLightning.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderLightning.base); + BossVa_Spark(globalCtx, pthis, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 5.0f, true); + BossVa_Spark(globalCtx, pthis, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 6.0f, true); + BossVa_Spark(globalCtx, pthis, 2, 110, 15.0f, 15.0f, SPARK_BLAST, 7.0f, true); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLightning.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLightning.base); } else { - BossVa_Spark(globalCtx, this, 2, 50, 15.0f, 0.0f, SPARK_BODY, (this->timer2 >> 1) + 1, true); - if (this->timer2 == 14) { + BossVa_Spark(globalCtx, pthis, 2, 50, 15.0f, 0.0f, SPARK_BODY, (pthis->timer2 >> 1) + 1, true); + if (pthis->timer2 == 14) { BossVa_SetSparkEnv(globalCtx); } - if (this->timer2 == 4) { - Vec3f sp48 = this->zapHeadPos; + if (pthis->timer2 == 4) { + Vec3f sp48 = pthis->zapHeadPos; - BossVa_SpawnZapperCharge(globalCtx, sVaEffects, this, &sp48, &this->headRot, 100, 0); + BossVa_SpawnZapperCharge(globalCtx, sVaEffects, pthis, &sp48, &pthis->headRot, 100, 0); } } - this->timer2++; - if (this->timer2 >= 24) { - this->burst = false; + pthis->timer2++; + if (pthis->timer2 >= 24) { + pthis->burst = false; } } } -void BossVa_SetupZapperHold(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeZapperDamage2Anim, 0.0f, 0.0f, +void BossVa_SetupZapperHold(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeZapperDamage2Anim, 0.0f, 0.0f, Animation_GetLastFrame(&gBarinadeZapperDamage2Anim), ANIMMODE_ONCE_INTERP, -6.0f); - this->burst = false; - BossVa_SetupAction(this, BossVa_ZapperHold); + pthis->burst = false; + BossVa_SetupAction(pthis, BossVa_ZapperHold); } -void BossVa_ZapperHold(BossVa* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - BossVa_AttachToBody(this); - Math_SmoothStepToS(&this->unk_1E6, 0, 1, 0x1770, 0); - Math_SmoothStepToS(&this->unk_1E4, 0, 1, 0x1770, 0); - Math_SmoothStepToS(&this->unk_1EC, 0, 1, 0x1770, 0); - Math_SmoothStepToS(&this->unk_1EA, 0, 1, 0x1770, 0); - Math_SmoothStepToS(&this->unk_1F2, this->actor.shape.rot.y - 0x4000, 1, 0x2710, 0); - Math_SmoothStepToS(&this->unk_1F0, this->skelAnime.jointTable[7].z - 0x1388, 1, 0x1770, 0); - if (GET_BODY(this)->actor.speedXZ == 0.0f) { - BossVa_SetupZapperAttack(this, globalCtx); +void BossVa_ZapperHold(BossVa* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + BossVa_AttachToBody(pthis); + Math_SmoothStepToS(&pthis->unk_1E6, 0, 1, 0x1770, 0); + Math_SmoothStepToS(&pthis->unk_1E4, 0, 1, 0x1770, 0); + Math_SmoothStepToS(&pthis->unk_1EC, 0, 1, 0x1770, 0); + Math_SmoothStepToS(&pthis->unk_1EA, 0, 1, 0x1770, 0); + Math_SmoothStepToS(&pthis->unk_1F2, pthis->actor.shape.rot.y - 0x4000, 1, 0x2710, 0); + Math_SmoothStepToS(&pthis->unk_1F0, pthis->skelAnime.jointTable[7].z - 0x1388, 1, 0x1770, 0); + if (GET_BODY(pthis)->actor.speedXZ == 0.0f) { + BossVa_SetupZapperAttack(pthis, globalCtx); } } -void BossVa_SetupBariIntro(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeBariAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeBariAnim), +void BossVa_SetupBariIntro(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeBariAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeBariAnim), ANIMMODE_LOOP, 0.0f); - this->unk_1A0 = 60.0f; - this->unk_1A4 = Rand_ZeroOne() * 360.0f; - this->timer2 = 64; - this->unk_1F0 = 120; - this->unk_1A8 = 0.0f; - this->actor.world.pos.x = sInitPosOffsets[this->actor.params + 10].x + this->actor.home.pos.x; - this->actor.world.pos.y = sInitPosOffsets[this->actor.params + 10].y + this->actor.home.pos.y; - this->actor.world.pos.z = sInitPosOffsets[this->actor.params + 10].z + this->actor.home.pos.z; - this->timer = 45; - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_BariIntro); + pthis->unk_1A0 = 60.0f; + pthis->unk_1A4 = Rand_ZeroOne() * 360.0f; + pthis->timer2 = 64; + pthis->unk_1F0 = 120; + pthis->unk_1A8 = 0.0f; + pthis->actor.world.pos.x = sInitPosOffsets[pthis->actor.params + 10].x + pthis->actor.home.pos.x; + pthis->actor.world.pos.y = sInitPosOffsets[pthis->actor.params + 10].y + pthis->actor.home.pos.y; + pthis->actor.world.pos.z = sInitPosOffsets[pthis->actor.params + 10].z + pthis->actor.home.pos.z; + pthis->timer = 45; + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_BariIntro); } -void BossVa_BariIntro(BossVa* this, GlobalContext* globalCtx) { - Vec3f sp54 = this->actor.home.pos; +void BossVa_BariIntro(BossVa* pthis, GlobalContext* globalCtx) { + Vec3f sp54 = pthis->actor.home.pos; f32 sp50 = 40.0f; s16 sp4E; s16 tmp; - if (this->actor.home.pos.y >= 0.0f) { + if (pthis->actor.home.pos.y >= 0.0f) { sp54.y += 25.0f; } - this->unk_1A4 += Rand_ZeroOne() * 0.25f; + pthis->unk_1A4 += Rand_ZeroOne() * 0.25f; switch (sCsState) { case INTRO_LOOK_BARI: - if (this->actor.params == BOSSVA_BARI_UPPER_1) { - func_8002DF54(globalCtx, &this->actor, 1); - if (Math_SmoothStepToF(&this->actor.world.pos.y, 60.0f, 0.3f, 1.0f, 0.15f) == 0.0f) { - this->timer--; - if (this->timer == 0) { + if (pthis->actor.params == BOSSVA_BARI_UPPER_1) { + func_8002DF54(globalCtx, &pthis->actor, 1); + if (Math_SmoothStepToF(&pthis->actor.world.pos.y, 60.0f, 0.3f, 1.0f, 0.15f) == 0.0f) { + pthis->timer--; + if (pthis->timer == 0) { sCsState++; } } } - this->actor.shape.rot.x = 0; + pthis->actor.shape.rot.x = 0; break; case INTRO_REVERSE_CAMERA: case INTRO_SUPPORT_CAMERA: case INTRO_BODY_SOUND: case INTRO_LOOK_SUPPORT: - if (this->actor.params != BOSSVA_BARI_UPPER_1) { - Math_SmoothStepToF(&this->actor.world.pos.y, - sInitPosOffsets[this->actor.params + 10].y + this->actor.home.pos.y, 0.3f, 1.0f, + if (pthis->actor.params != BOSSVA_BARI_UPPER_1) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, + sInitPosOffsets[pthis->actor.params + 10].y + pthis->actor.home.pos.y, 0.3f, 1.0f, 0.15f); - this->actor.world.pos.x += (Math_SinF(this->unk_1A4 * 0.25f) * 0.5f); + pthis->actor.world.pos.x += (Math_SinF(pthis->unk_1A4 * 0.25f) * 0.5f); } else { - Math_SmoothStepToF(&this->actor.world.pos.y, 60.0f, 0.3f, 1.0f, 0.15f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, 60.0f, 0.3f, 1.0f, 0.15f); } - this->actor.world.pos.y += Math_SinF(this->unk_1A4) * (2.0f - Math_SinF(this->unk_1A4)); + pthis->actor.world.pos.y += Math_SinF(pthis->unk_1A4) * (2.0f - Math_SinF(pthis->unk_1A4)); break; case INTRO_CALL_BARI: case INTRO_ATTACH_BARI: - if ((this->timer2 > 15) && (this->timer < 0)) { - Math_SmoothStepToF(&this->actor.world.pos.x, sp54.x, 1.0f, 6.5f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, sp54.y, 1.0f, 6.5f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, sp54.z, 1.0f, 6.5f, 0.0f); + if ((pthis->timer2 > 15) && (pthis->timer < 0)) { + Math_SmoothStepToF(&pthis->actor.world.pos.x, sp54.x, 1.0f, 6.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, sp54.y, 1.0f, 6.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, sp54.z, 1.0f, 6.5f, 0.0f); - sp50 = Math_Vec3f_DistXYZ(&sp54, &this->actor.world.pos); + sp50 = Math_Vec3f_DistXYZ(&sp54, &pthis->actor.world.pos); if (sp50 <= 60.0f) { - tmp = Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 1, 0x7D0, 0); + tmp = Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->actor.home.rot.x, 1, 0x7D0, 0); sp4E = ABS(tmp); - tmp = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 0x7D0, 0); + tmp = Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, 1, 0x7D0, 0); sp4E += ABS(tmp); if ((sp50 == 0.0f) && (sp4E == 0)) { - if (!this->isDead) { - if (this->actor.params >= BOSSVA_BARI_LOWER_1) { - if (this->actor.params == BOSSVA_BARI_LOWER_1) { + if (!pthis->isDead) { + if (pthis->actor.params >= BOSSVA_BARI_LOWER_1) { + if (pthis->actor.params == BOSSVA_BARI_LOWER_1) { sBodyBari[0]++; } else { - sBodyBari[this->actor.params - BOSSVA_BARI_UPPER_1]++; + sBodyBari[pthis->actor.params - BOSSVA_BARI_UPPER_1]++; } } else { - sBodyBari[this->actor.params - BOSSVA_BARI_UPPER_1 + 1]++; + sBodyBari[pthis->actor.params - BOSSVA_BARI_UPPER_1 + 1]++; } - this->timer = -30; - this->isDead++; + pthis->timer = -30; + pthis->isDead++; } else { - this->timer++; - if (this->timer == 0) { - Actor_Kill(&this->actor); + pthis->timer++; + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); } } return; @@ -2501,21 +2501,21 @@ void BossVa_BariIntro(BossVa* this, GlobalContext* globalCtx) { } } case INTRO_UNUSED_CALL_BARI: - this->timer--; - if (this->timer == 0) { - this->timer2 = 0; + pthis->timer--; + if (pthis->timer == 0) { + pthis->timer2 = 0; } else { - func_80035844(&GET_BODY(this)->actor.world.pos, &this->actor.world.pos, &this->actor.world.rot, false); - this->unk_1A0 = Math_Vec3f_DistXYZ(&GET_BODY(this)->actor.world.pos, &this->actor.world.pos); + func_80035844(&GET_BODY(pthis)->actor.world.pos, &pthis->actor.world.pos, &pthis->actor.world.rot, false); + pthis->unk_1A0 = Math_Vec3f_DistXYZ(&GET_BODY(pthis)->actor.world.pos, &pthis->actor.world.pos); if (sp50 > 30.0f) { - BossVa_Spark(globalCtx, this, 1, 80, 15.0f, 0.0f, SPARK_BARI, 1.0f, true); + BossVa_Spark(globalCtx, pthis, 1, 80, 15.0f, 0.0f, SPARK_BARI, 1.0f, true); } } break; case BOSSVA_BATTLE: - this->timer++; - if (this->timer == 0) { - Actor_Kill(&this->actor); + pthis->timer++; + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); } return; case INTRO_TITLE: @@ -2525,288 +2525,288 @@ void BossVa_BariIntro(BossVa* this, GlobalContext* globalCtx) { } if (((globalCtx->gameplayFrames % 4) == 0) && (sCsState < INTRO_ATTACH_BARI)) { - BossVa_Spark(globalCtx, this, 1, 70, 25.0f, 20.0f, SPARK_BARI, 2.0f, true); + BossVa_Spark(globalCtx, pthis, 1, 70, 25.0f, 20.0f, SPARK_BARI, 2.0f, true); } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } } -void BossVa_SetupBariPhase3Attack(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeBariAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeBariAnim), +void BossVa_SetupBariPhase3Attack(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeBariAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeBariAnim), ANIMMODE_LOOP, 0.0f); - this->timer2 = 0x80; - this->unk_1F0 = 0x78; - this->unk_1A0 = 60.0f; - this->unk_1A8 = 0.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_BariPhase3Attack); + pthis->timer2 = 0x80; + pthis->unk_1F0 = 0x78; + pthis->unk_1A0 = 60.0f; + pthis->unk_1A8 = 0.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_BariPhase3Attack); } -void BossVa_BariPhase3Attack(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BariPhase3Attack(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnBoom* boomerang; - Vec3f sp54 = GET_BODY(this)->unk_1D8; + Vec3f sp54 = GET_BODY(pthis)->unk_1D8; s16 sp52; s32 pad; - this->unk_1A4 += Rand_ZeroOne() * 0.5f; - sp52 = this->timer2 & 0x1FF; + pthis->unk_1A4 += Rand_ZeroOne() * 0.5f; + sp52 = pthis->timer2 & 0x1FF; if ((globalCtx->gameplayFrames % 128) == 0) { - this->vaBariUnused.x = (s16)(Rand_ZeroOne() * 100.0f) + 100; + pthis->vaBariUnused.x = (s16)(Rand_ZeroOne() * 100.0f) + 100; } - Math_SmoothStepToS(&this->vaBariUnused.z, this->vaBariUnused.x, 1, 0x1E, 0); - this->vaBariUnused.y += this->vaBariUnused.z; - if ((this->colliderLightning.base.atFlags & AT_HIT) || (this->colliderSph.base.atFlags & AT_HIT)) { - if ((this->colliderLightning.base.at == &player->actor) || (this->colliderSph.base.at == &player->actor)) { - func_8002F71C(globalCtx, &this->actor, 8.0f, GET_BODY(this)->actor.yawTowardsPlayer, 8.0f); + Math_SmoothStepToS(&pthis->vaBariUnused.z, pthis->vaBariUnused.x, 1, 0x1E, 0); + pthis->vaBariUnused.y += pthis->vaBariUnused.z; + if ((pthis->colliderLightning.base.atFlags & AT_HIT) || (pthis->colliderSph.base.atFlags & AT_HIT)) { + if ((pthis->colliderLightning.base.at == &player->actor) || (pthis->colliderSph.base.at == &player->actor)) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, GET_BODY(pthis)->actor.yawTowardsPlayer, 8.0f); Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - this->colliderSph.base.at = NULL; - this->colliderLightning.base.at = NULL; + pthis->colliderSph.base.at = NULL; + pthis->colliderLightning.base.at = NULL; } - this->colliderLightning.base.atFlags &= ~AT_HIT; - this->colliderSph.base.atFlags &= ~AT_HIT; + pthis->colliderLightning.base.atFlags &= ~AT_HIT; + pthis->colliderSph.base.atFlags &= ~AT_HIT; } - if (this->colliderSph.base.acFlags & AC_HIT) { - this->colliderSph.base.acFlags &= ~AC_HIT; - if ((this->colliderSph.base.ac->id == ACTOR_EN_BOOM) && (sp52 >= 128)) { - boomerang = (EnBoom*)this->colliderSph.base.ac; + if (pthis->colliderSph.base.acFlags & AC_HIT) { + pthis->colliderSph.base.acFlags &= ~AC_HIT; + if ((pthis->colliderSph.base.ac->id == ACTOR_EN_BOOM) && (sp52 >= 128)) { + boomerang = (EnBoom*)pthis->colliderSph.base.ac; boomerang->returnTimer = 0; boomerang->moveTo = &player->actor; boomerang->actor.world.rot.y = boomerang->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SHIELD_REFLECT_SW); } } - this->actor.world.pos.x = (Math_SinS(this->actor.world.rot.y) * this->unk_1A0) + sp54.x; - this->actor.world.pos.z = (Math_CosS(this->actor.world.rot.y) * this->unk_1A0) + sp54.z; - Math_SmoothStepToF(&this->actor.world.pos.y, 4.0f, 1.0f, 2.0f, 0.0f); - this->actor.world.pos.y += 2.0f * Math_SinF(this->unk_1A4); - this->actor.world.rot.x = Math_Vec3f_Pitch(&sp54, &this->actor.world.pos); - Math_SmoothStepToF(&this->unk_1A0, 160.0f, 1.0f, 2.0f, 0.0f); - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x5DC, 0); - if (!(this->timer2 & 0x200)) { - this->unk_1AC = 0xBB8; + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.world.rot.y) * pthis->unk_1A0) + sp54.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.world.rot.y) * pthis->unk_1A0) + sp54.z; + Math_SmoothStepToF(&pthis->actor.world.pos.y, 4.0f, 1.0f, 2.0f, 0.0f); + pthis->actor.world.pos.y += 2.0f * Math_SinF(pthis->unk_1A4); + pthis->actor.world.rot.x = Math_Vec3f_Pitch(&sp54, &pthis->actor.world.pos); + Math_SmoothStepToF(&pthis->unk_1A0, 160.0f, 1.0f, 2.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 0x5DC, 0); + if (!(pthis->timer2 & 0x200)) { + pthis->unk_1AC = 0xBB8; } else { - this->unk_1AC = -0xBB8; + pthis->unk_1AC = -0xBB8; } if (sp52 >= 128) { - BossVa_Spark(globalCtx, this, 1, 75, 15.0f, 7.0f, SPARK_TETHER, 1.0f, true); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + BossVa_Spark(globalCtx, pthis, 1, 75, 15.0f, 7.0f, SPARK_TETHER, 1.0f, true); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); sPhase3StopMoving = false; } else { sPhase3StopMoving = true; } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderLightning.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLightning.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); if ((globalCtx->gameplayFrames % 4) == 0) { - Math_SmoothStepToS(&this->unk_1F0, 0x78, 1, 0xA, 0); + Math_SmoothStepToS(&pthis->unk_1F0, 0x78, 1, 0xA, 0); } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - this->actor.world.rot.y += this->unk_1AC; + pthis->actor.world.rot.y += pthis->unk_1AC; if (sBodyState & 0x7F) { - BossVa_SetupBariPhase3Stunned(this, globalCtx); + BossVa_SetupBariPhase3Stunned(pthis, globalCtx); } } -void BossVa_SetupBariPhase2Attack(BossVa* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gBarinadeBariAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeBariAnim), +void BossVa_SetupBariPhase2Attack(BossVa* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gBarinadeBariAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBarinadeBariAnim), ANIMMODE_LOOP, 0.0f); - this->timer2 = 0x40; - this->unk_1F0 = 0x78; - this->unk_1A0 = 60.0f; - this->unk_1A8 = 0.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_BariPhase2Attack); + pthis->timer2 = 0x40; + pthis->unk_1F0 = 0x78; + pthis->unk_1A0 = 60.0f; + pthis->unk_1A8 = 0.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_BariPhase2Attack); } -void BossVa_BariPhase2Attack(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BariPhase2Attack(BossVa* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnBoom* boomerang; - Vec3f sp54 = GET_BODY(this)->unk_1D8; + Vec3f sp54 = GET_BODY(pthis)->unk_1D8; s16 sp52; s16 sp50; f32 sp4C; s32 pad; - this->unk_1A4 += Rand_ZeroOne() * 0.5f; - sp52 = this->timer2 & 0x1FF; + pthis->unk_1A4 += Rand_ZeroOne() * 0.5f; + sp52 = pthis->timer2 & 0x1FF; if ((globalCtx->gameplayFrames % 128) == 0) { - this->vaBariUnused.x = (s16)(Rand_ZeroOne() * 100.0f) + 100; + pthis->vaBariUnused.x = (s16)(Rand_ZeroOne() * 100.0f) + 100; } sp50 = (sFightPhase * 70) - 280; - Math_SmoothStepToS(&this->vaBariUnused.z, this->vaBariUnused.x, 1, 0x1E, 0); - this->vaBariUnused.y += this->vaBariUnused.z; + Math_SmoothStepToS(&pthis->vaBariUnused.z, pthis->vaBariUnused.x, 1, 0x1E, 0); + pthis->vaBariUnused.y += pthis->vaBariUnused.z; if (sKillBari != 0) { sKillBari--; - BossVa_KillBari(this, globalCtx); + BossVa_KillBari(pthis, globalCtx); return; } - if ((this->colliderLightning.base.atFlags & AT_HIT) || (this->colliderSph.base.atFlags & AT_HIT)) { - if ((this->colliderLightning.base.at == &player->actor) || (this->colliderSph.base.at == &player->actor)) { - func_8002F71C(globalCtx, &this->actor, 8.0f, GET_BODY(this)->actor.yawTowardsPlayer, 8.0f); + if ((pthis->colliderLightning.base.atFlags & AT_HIT) || (pthis->colliderSph.base.atFlags & AT_HIT)) { + if ((pthis->colliderLightning.base.at == &player->actor) || (pthis->colliderSph.base.at == &player->actor)) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, GET_BODY(pthis)->actor.yawTowardsPlayer, 8.0f); Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - this->colliderSph.base.at = NULL; - this->colliderLightning.base.at = NULL; + pthis->colliderSph.base.at = NULL; + pthis->colliderLightning.base.at = NULL; } - this->colliderLightning.base.atFlags &= ~AT_HIT; - this->colliderSph.base.atFlags &= ~AT_HIT; + pthis->colliderLightning.base.atFlags &= ~AT_HIT; + pthis->colliderSph.base.atFlags &= ~AT_HIT; } - Math_SmoothStepToF(&this->actor.world.pos.y, 4.0f, 1.0f, 2.0f, 0.0f); - this->actor.world.rot.x = Math_Vec3f_Pitch(&sp54, &this->actor.world.pos); + Math_SmoothStepToF(&pthis->actor.world.pos.y, 4.0f, 1.0f, 2.0f, 0.0f); + pthis->actor.world.rot.x = Math_Vec3f_Pitch(&sp54, &pthis->actor.world.pos); if ((globalCtx->gameplayFrames % 8) == 0) { - Math_SmoothStepToS(&this->unk_1F0, 0x28, 1, 0xA, 0); - BossVa_Spark(globalCtx, this, 1, this->unk_1F0, 25.0f, 20.0f, 2, 2.0f, true); + Math_SmoothStepToS(&pthis->unk_1F0, 0x28, 1, 0xA, 0); + BossVa_Spark(globalCtx, pthis, 1, pthis->unk_1F0, 25.0f, 20.0f, 2, 2.0f, true); } - if (!(sPhase2Timer & 0x100) && (GET_BODY(this)->actor.colorFilterTimer == 0)) { + if (!(sPhase2Timer & 0x100) && (GET_BODY(pthis)->actor.colorFilterTimer == 0)) { sp4C = 200.0f; - BossVa_Spark(globalCtx, this, 1, 125, 15.0f, 7.0f, SPARK_TETHER, 1.0f, true); - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->actor.params & 1) { + BossVa_Spark(globalCtx, pthis, 1, 125, 15.0f, 7.0f, SPARK_TETHER, 1.0f, true); + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->actor.params & 1) { sp4C = -200.0f; } - Math_SmoothStepToF(&this->unk_1A0, (Math_SinS(sPhase2Timer * 0x190) * sp4C) + 320.0f, 1.0f, 10.0f, 0.0f); - Math_SmoothStepToS(&this->unk_1AC, sp50 + 0x1F4, 1, 0x3C, 0); - this->actor.world.pos.y += 2.0f * Math_SinF(this->unk_1A4); - if (this->colliderSph.base.acFlags & AC_HIT) { - this->colliderSph.base.acFlags &= ~AC_HIT; + Math_SmoothStepToF(&pthis->unk_1A0, (Math_SinS(sPhase2Timer * 0x190) * sp4C) + 320.0f, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToS(&pthis->unk_1AC, sp50 + 0x1F4, 1, 0x3C, 0); + pthis->actor.world.pos.y += 2.0f * Math_SinF(pthis->unk_1A4); + if (pthis->colliderSph.base.acFlags & AC_HIT) { + pthis->colliderSph.base.acFlags &= ~AC_HIT; - if ((this->colliderSph.base.ac->id == ACTOR_EN_BOOM) && (sp52 >= 64)) { - boomerang = (EnBoom*)this->colliderSph.base.ac; + if ((pthis->colliderSph.base.ac->id == ACTOR_EN_BOOM) && (sp52 >= 64)) { + boomerang = (EnBoom*)pthis->colliderSph.base.ac; boomerang->returnTimer = 0; boomerang->moveTo = &player->actor; boomerang->actor.world.rot.y = boomerang->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SHIELD_REFLECT_SW); } } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderLightning.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderLightning.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); } else { - this->actor.flags |= ACTOR_FLAG_0; - Math_SmoothStepToS(&this->unk_1AC, sp50 + 150, 1, 0x3C, 0); - if (GET_BODY(this)->actor.colorFilterTimer == 0) { - Math_SmoothStepToF(&this->unk_1A0, 180.0f, 1.0f, 1.5f, 0.0f); + pthis->actor.flags |= ACTOR_FLAG_0; + Math_SmoothStepToS(&pthis->unk_1AC, sp50 + 150, 1, 0x3C, 0); + if (GET_BODY(pthis)->actor.colorFilterTimer == 0) { + Math_SmoothStepToF(&pthis->unk_1A0, 180.0f, 1.0f, 1.5f, 0.0f); } else { - this->unk_1AC = 0; - if (this->actor.colorFilterTimer == 0) { - Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, GET_BODY(this)->actor.colorFilterTimer); + pthis->unk_1AC = 0; + if (pthis->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&pthis->actor, 0, 255, 0x2000, GET_BODY(pthis)->actor.colorFilterTimer); } } - this->actor.world.pos.y += Math_SinF(this->unk_1A4) * 4.0f; - if (this->colliderSph.base.acFlags & AC_HIT) { - BossVa_KillBari(this, globalCtx); + pthis->actor.world.pos.y += Math_SinF(pthis->unk_1A4) * 4.0f; + if (pthis->colliderSph.base.acFlags & AC_HIT) { + BossVa_KillBari(pthis, globalCtx); } } - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x5DC, 0); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 0x5DC, 0); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); if ((globalCtx->gameplayFrames % 4) == 0) { - Math_SmoothStepToS(&this->unk_1F0, 0x78, 1, 0xA, 0); + Math_SmoothStepToS(&pthis->unk_1F0, 0x78, 1, 0xA, 0); } if (Rand_ZeroOne() < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_SPARK - SFX_FLAG); } - if (GET_BODY(this)->actor.colorFilterTimer == 0) { - if (!(this->timer2 & 0x400)) { - this->actor.world.rot.y += this->unk_1AC; + if (GET_BODY(pthis)->actor.colorFilterTimer == 0) { + if (!(pthis->timer2 & 0x400)) { + pthis->actor.world.rot.y += pthis->unk_1AC; } else { - this->actor.world.rot.y -= this->unk_1AC; + pthis->actor.world.rot.y -= pthis->unk_1AC; } - this->actor.world.pos.x = (Math_SinS(this->actor.world.rot.y) * this->unk_1A0) + sp54.x; - this->actor.world.pos.z = (Math_CosS(this->actor.world.rot.y) * this->unk_1A0) + sp54.z; + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.world.rot.y) * pthis->unk_1A0) + sp54.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.world.rot.y) * pthis->unk_1A0) + sp54.z; } } -void BossVa_SetupBariPhase3Stunned(BossVa* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_0; - this->timer = GET_BODY(this)->timer; - Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, this->timer); - BossVa_SetupAction(this, BossVa_BariPhase3Stunned); +void BossVa_SetupBariPhase3Stunned(BossVa* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->timer = GET_BODY(pthis)->timer; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0x2000, pthis->timer); + BossVa_SetupAction(pthis, BossVa_BariPhase3Stunned); } -void BossVa_BariPhase3Stunned(BossVa* this, GlobalContext* globalCtx) { +void BossVa_BariPhase3Stunned(BossVa* pthis, GlobalContext* globalCtx) { s32 sp44_pad; - Vec3f sp40 = GET_BODY(this)->unk_1D8; + Vec3f sp40 = GET_BODY(pthis)->unk_1D8; - this->actor.world.rot.x = Math_Vec3f_Pitch(&GET_BODY(this)->actor.world.pos, &this->actor.world.pos); - if (this->colliderSph.base.acFlags & AC_HIT) { - BossVa_KillBari(this, globalCtx); + pthis->actor.world.rot.x = Math_Vec3f_Pitch(&GET_BODY(pthis)->actor.world.pos, &pthis->actor.world.pos); + if (pthis->colliderSph.base.acFlags & AC_HIT) { + BossVa_KillBari(pthis, globalCtx); return; } - this->unk_1A4 += Rand_ZeroOne() * 0.5f; - Math_SmoothStepToF(&this->actor.world.pos.y, 4.0f, 1.0f, 2.0f, 0.0f); - this->actor.world.pos.y += Math_SinF(this->unk_1A4) * 3.0f; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + pthis->unk_1A4 += Rand_ZeroOne() * 0.5f; + Math_SmoothStepToF(&pthis->actor.world.pos.y, 4.0f, 1.0f, 2.0f, 0.0f); + pthis->actor.world.pos.y += Math_SinF(pthis->unk_1A4) * 3.0f; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); if ((globalCtx->gameplayFrames % 4) == 0) { - Math_SmoothStepToS(&this->unk_1F0, 0x28, 1, 0xA, 0); - BossVa_Spark(globalCtx, this, 1, this->unk_1F0, 25.0f, 20.0f, SPARK_BARI, 2.0f, true); + Math_SmoothStepToS(&pthis->unk_1F0, 0x28, 1, 0xA, 0); + BossVa_Spark(globalCtx, pthis, 1, pthis->unk_1F0, 25.0f, 20.0f, SPARK_BARI, 2.0f, true); } - this->timer--; - this->actor.world.rot.x = Math_Vec3f_Pitch(&sp40, &this->actor.world.pos); - if (this->timer <= 0) { - if (this->timer == 0) { - this->timer2 = 0; + pthis->timer--; + pthis->actor.world.rot.x = Math_Vec3f_Pitch(&sp40, &pthis->actor.world.pos); + if (pthis->timer <= 0) { + if (pthis->timer == 0) { + pthis->timer2 = 0; } else { - BossVa_Spark(globalCtx, this, 1, 85, 15.0f, 0.0f, SPARK_TETHER, 1.0f, true); - if (this->timer2 >= 0x10) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->timer2 = 0x80; - BossVa_SetupAction(this, BossVa_BariPhase3Attack); + BossVa_Spark(globalCtx, pthis, 1, 85, 15.0f, 0.0f, SPARK_TETHER, 1.0f, true); + if (pthis->timer2 >= 0x10) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->timer2 = 0x80; + BossVa_SetupAction(pthis, BossVa_BariPhase3Attack); } } } } -void BossVa_SetupBariDeath(BossVa* this) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->timer = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_BL_DEAD); - this->isDead++; - BossVa_SetupAction(this, BossVa_BariDeath); +void BossVa_SetupBariDeath(BossVa* pthis) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->timer = 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_BL_DEAD); + pthis->isDead++; + BossVa_SetupAction(pthis, BossVa_BariDeath); } -void BossVa_BariDeath(BossVa* this, GlobalContext* globalCtx) { - this->timer--; - if (this->timer == 0) { - Actor_Kill(&this->actor); +void BossVa_BariDeath(BossVa* pthis, GlobalContext* globalCtx) { + pthis->timer--; + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); } } -void BossVa_SetupDoor(BossVa* this, GlobalContext* globalCtx) { +void BossVa_SetupDoor(BossVa* pthis, GlobalContext* globalCtx) { if (sCsState >= INTRO_SPAWN_BARI) { sDoorState = 100; } - this->actor.flags &= ~ACTOR_FLAG_0; - BossVa_SetupAction(this, BossVa_Door); + pthis->actor.flags &= ~ACTOR_FLAG_0; + BossVa_SetupAction(pthis, BossVa_Door); } -void BossVa_Door(BossVa* this, GlobalContext* globalCtx) { +void BossVa_Door(BossVa* pthis, GlobalContext* globalCtx) { if (sDoorState == 29) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUYODOOR_CLOSE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BUYODOOR_CLOSE); } if (sCsState <= INTRO_DOOR_SHUT) { @@ -2820,18 +2820,18 @@ void BossVa_Door(BossVa* this, GlobalContext* globalCtx) { void BossVa_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; EnBoom* boomerang; s32 i; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - switch (this->actor.params) { + switch (pthis->actor.params) { case BOSSVA_BODY: - if (this->colliderBody.base.acFlags & AC_HIT) { - this->colliderBody.base.acFlags &= ~AC_HIT; - if (this->colliderBody.base.ac->id == ACTOR_EN_BOOM) { - boomerang = (EnBoom*)this->colliderBody.base.ac; + if (pthis->colliderBody.base.acFlags & AC_HIT) { + pthis->colliderBody.base.acFlags &= ~AC_HIT; + if (pthis->colliderBody.base.ac->id == ACTOR_EN_BOOM) { + boomerang = (EnBoom*)pthis->colliderBody.base.ac; boomerang->returnTimer = 0; } } @@ -2858,17 +2858,17 @@ void BossVa_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - if (this->onCeiling > 0) { - this->onCeiling--; // not used by body + if (pthis->onCeiling > 0) { + pthis->onCeiling--; // not used by body } break; default: - this->timer2++; - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 45.0f; - this->unk_1D8.y = (Math_CosS(this->timer2 * 0xFA4) * 0.24f) + 0.76f; - this->unk_1D8.x = (Math_SinS(this->timer2 * 0xFA4) * 0.2f) + 1.0f; + pthis->timer2++; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 45.0f; + pthis->unk_1D8.y = (Math_CosS(pthis->timer2 * 0xFA4) * 0.24f) + 0.76f; + pthis->unk_1D8.x = (Math_SinS(pthis->timer2 * 0xFA4) * 0.2f) + 1.0f; break; case BOSSVA_SUPPORT_1: @@ -2884,7 +2884,7 @@ void BossVa_Update(Actor* thisx, GlobalContext* globalCtx2) { s32 BossVa_BodyOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_va.c", 4156); @@ -2894,15 +2894,15 @@ s32 BossVa_BodyOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 8, 16, 1, 0, (globalCtx->gameplayFrames * -2) % 64, 16, 16)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->bodyGlow); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, pthis->bodyGlow); Matrix_RotateX(-M_PI / 2, MTXMODE_APPLY); } else if ((limbIndex >= 10) && (limbIndex < 20)) { rot->x -= 0x4000; *dList = NULL; } else if (limbIndex == 6) { - Matrix_Scale(this->unk_1A4, this->unk_1A4, this->unk_1A4, MTXMODE_APPLY); + Matrix_Scale(pthis->unk_1A4, pthis->unk_1A4, pthis->unk_1A4, MTXMODE_APPLY); } else if (limbIndex == 61) { - Matrix_Scale(this->unk_1A0, this->unk_1A0, this->unk_1A0, MTXMODE_APPLY); + Matrix_Scale(pthis->unk_1A0, pthis->unk_1A0, pthis->unk_1A0, MTXMODE_APPLY); } else if (limbIndex == 7) { rot->x -= 0xCCC; } @@ -2912,7 +2912,7 @@ s32 BossVa_BodyOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } void BossVa_BodyPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; Vec3f sp78 = { 0.0f, 0.0f, 0.0f }; s32 pad; @@ -2924,7 +2924,7 @@ void BossVa_BodyPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } else { sp78.x = 200.0f; } - Matrix_MultVec3f(&sp78, &this->unk_1D8); + Matrix_MultVec3f(&sp78, &pthis->unk_1D8); } else if ((limbIndex >= 10) && (limbIndex < 20) && (sBodyBari[limbIndex - 10] != 0)) { if (((limbIndex >= 16) || (limbIndex == 10)) && (sFightPhase <= PHASE_3)) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_boss_va.c", 4208), @@ -2941,7 +2941,7 @@ void BossVa_BodyPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis sp78.y = Rand_CenteredFloat(530.0f); sp78.z = -60.0f; } - Matrix_MultVec3f(&sp78, &this->effectPos[limbIndex - 10]); + Matrix_MultVec3f(&sp78, &pthis->effectPos[limbIndex - 10]); } else if (limbIndex == 25) { gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (globalCtx->gameplayFrames * 10) % 128, 16, 32, 1, 0, @@ -2954,10 +2954,10 @@ void BossVa_BodyPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, *dList); } else if ((limbIndex == 24) && (sCsState < DEATH_START)) { - sp78.x = (this->actor.shape.yOffset + 450.0f) + -140.0f; - Matrix_MultVec3f(&sp78, &this->unk_280); + sp78.x = (pthis->actor.shape.yOffset + 450.0f) + -140.0f; + Matrix_MultVec3f(&sp78, &pthis->unk_280); sp78.x = 200.0f; - Matrix_MultVec3f(&sp78, &this->unk_274); + Matrix_MultVec3f(&sp78, &pthis->unk_274); } if ((limbIndex == 7) && (sCsState >= DEATH_START)) { @@ -2976,7 +2976,7 @@ void BossVa_BodyPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } else { sp78.z += 150.0f; } - Matrix_MultVec3f(&sp78, &this->unk_274); + Matrix_MultVec3f(&sp78, &pthis->unk_274); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_boss_va.c", 4264); @@ -2984,53 +2984,53 @@ void BossVa_BodyPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis s32 BossVa_SupportOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; - if (!this->onCeiling && (limbIndex == 4)) { - rot->z += this->headRot.x; + if (!pthis->onCeiling && (limbIndex == 4)) { + rot->z += pthis->headRot.x; } return false; } void BossVa_SupportPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; Vec3f sp20 = { 0.0f, 0.0f, 0.0f }; s32 pad; - if (this->onCeiling) { + if (pthis->onCeiling) { switch (limbIndex) { case 4: - Matrix_MultVec3f(&sZeroVec, &this->actor.focus.pos); - Collider_UpdateSpheres(0, &this->colliderSph); + Matrix_MultVec3f(&sZeroVec, &pthis->actor.focus.pos); + Collider_UpdateSpheres(0, &pthis->colliderSph); break; case 7: - Matrix_MultVec3f(&sZeroVec, &this->armTip); - sp20.x = ((this->timer & 0x1F) >> 1) * -40.0f; - sp20.y = ((this->timer & 0x1F) >> 1) * -7.0f; - Matrix_MultVec3f(&sp20, &this->effectPos[0]); + Matrix_MultVec3f(&sZeroVec, &pthis->armTip); + sp20.x = ((pthis->timer & 0x1F) >> 1) * -40.0f; + sp20.y = ((pthis->timer & 0x1F) >> 1) * -7.0f; + Matrix_MultVec3f(&sp20, &pthis->effectPos[0]); break; case 9: - sp20.x = ((this->timer & 0x1F) >> 1) * -60.0f; - sp20.y = ((this->timer & 0x1F) >> 1) * -45.0f; - Matrix_MultVec3f(&sp20, &this->effectPos[1]); + sp20.x = ((pthis->timer & 0x1F) >> 1) * -60.0f; + sp20.y = ((pthis->timer & 0x1F) >> 1) * -45.0f; + Matrix_MultVec3f(&sp20, &pthis->effectPos[1]); break; } } else { switch (limbIndex) { case 5: - Matrix_MultVec3f(&sZeroVec, &this->armTip); + Matrix_MultVec3f(&sZeroVec, &pthis->armTip); break; case 8: - sp20.x = (this->timer2 & 7) * 90.0f; - Matrix_MultVec3f(&sp20, &this->effectPos[2]); + sp20.x = (pthis->timer2 & 7) * 90.0f; + Matrix_MultVec3f(&sp20, &pthis->effectPos[2]); break; case 9: - sp20.x = (this->timer2 & 7) * 50.0f; - Matrix_MultVec3f(&sp20, &this->effectPos[1]); + sp20.x = (pthis->timer2 & 7) * 50.0f; + Matrix_MultVec3f(&sp20, &pthis->effectPos[1]); break; case 10: - sp20.x = (this->timer2 & 7) * 46.0f; - Matrix_MultVec3f(&sp20, &this->effectPos[0]); + sp20.x = (pthis->timer2 & 7) * 46.0f; + Matrix_MultVec3f(&sp20, &pthis->effectPos[0]); break; } } @@ -3038,17 +3038,17 @@ void BossVa_SupportPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d s32 BossVa_ZapperOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; MtxF zapperMtx; switch (limbIndex) { case 4: - rot->y += this->unk_1E6; - rot->z += this->unk_1E4; + rot->y += pthis->unk_1E6; + rot->z += pthis->unk_1E4; break; case 5: - rot->y += this->unk_1EC; - rot->z += this->unk_1EA; + rot->y += pthis->unk_1EC; + rot->z += pthis->unk_1EA; break; case 7: Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); @@ -3057,8 +3057,8 @@ s32 BossVa_ZapperOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Matrix_RotateX(-sZapperRot.x * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_RotateY(-sZapperRot.y * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_RotateZ(-sZapperRot.z * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateY(this->unk_1F2 * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(this->unk_1F0 * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->unk_1F2 * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_1F0 * (M_PI / 0x8000), MTXMODE_APPLY); pos->x = pos->y = pos->z = 0.0f; rot->x = rot->y = rot->z = 0; break; @@ -3067,7 +3067,7 @@ s32 BossVa_ZapperOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } void BossVa_ZapperPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; Vec3f sp70 = { 0.0f, 0.0f, 0.0f }; Vec3f sp64 = { 15.0f, 0.0f, 0.0f }; Vec3f sp58 = { -15.0f, 0.0f, 0.0f }; @@ -3078,49 +3078,49 @@ void BossVa_ZapperPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL switch (limbIndex) { case 3: - sp70.x = (this->timer2 & 7) * 30.0f; - Matrix_MultVec3f(&sp70, &this->effectPos[0]); + sp70.x = (pthis->timer2 & 7) * 30.0f; + Matrix_MultVec3f(&sp70, &pthis->effectPos[0]); break; case 4: - Matrix_MultVec3f(&sZeroVec, &this->armTip); - sp70.x = (this->timer2 & 7) * 30.0f; - Matrix_MultVec3f(&sp70, &this->effectPos[1]); + Matrix_MultVec3f(&sZeroVec, &pthis->armTip); + sp70.x = (pthis->timer2 & 7) * 30.0f; + Matrix_MultVec3f(&sp70, &pthis->effectPos[1]); break; case 5: - Matrix_MultVec3f(&sZeroVec, &this->zapNeckPos); - sp70.x = (this->timer2 & 7) * 46.0f; - Matrix_MultVec3f(&sp70, &this->effectPos[2]); + Matrix_MultVec3f(&sZeroVec, &pthis->zapNeckPos); + sp70.x = (pthis->timer2 & 7) * 46.0f; + Matrix_MultVec3f(&sp70, &pthis->effectPos[2]); break; case 7: - Matrix_MultVec3f(&sZeroVec, &this->zapHeadPos); - sp70.x = (this->timer2 & 7) * 46.0f; - Matrix_MultVec3f(&sp70, &this->effectPos[3]); + Matrix_MultVec3f(&sZeroVec, &pthis->zapHeadPos); + sp70.x = (pthis->timer2 & 7) * 46.0f; + Matrix_MultVec3f(&sp70, &pthis->effectPos[3]); sp70.x = 20.0f; - Matrix_MultVec3f(&sp70, &this->effectPos[9]); - func_80035844(&this->effectPos[9], &this->unk_1D8, &this->headRot, false); - sp3E = this->headRot.x; - sp3C = this->headRot.y; + Matrix_MultVec3f(&sp70, &pthis->effectPos[9]); + func_80035844(&pthis->effectPos[9], &pthis->unk_1D8, &pthis->headRot, false); + sp3E = pthis->headRot.x; + sp3C = pthis->headRot.y; Matrix_Push(); - Matrix_Translate(this->effectPos[9].x, this->effectPos[9].y, this->effectPos[9].z, MTXMODE_NEW); + Matrix_Translate(pthis->effectPos[9].x, pthis->effectPos[9].y, pthis->effectPos[9].z, MTXMODE_NEW); Matrix_RotateZYX(sp3E, sp3C, 0, MTXMODE_APPLY); sp70.x = 0.0f; if (sFightPhase >= PHASE_4) { - sp70.z = ((this->timer2 - 16) & 7) * 120.0f; + sp70.z = ((pthis->timer2 - 16) & 7) * 120.0f; } else { - sp70.z = ((this->timer2 - 32) & 0xF) * 80.0f; + sp70.z = ((pthis->timer2 - 32) & 0xF) * 80.0f; } sp4C.z = sp40.z = sp70.z += 40.0f; sp70.z += 50.0f; - Matrix_MultVec3f(&sp70, &this->effectPos[4]); + Matrix_MultVec3f(&sp70, &pthis->effectPos[4]); if (sFightPhase >= PHASE_4) { sp70.z -= 33.0f; if (sp70.z < 0.0f) { sp70.z = 0.0f; } - Matrix_MultVec3f(&sp70, &this->effectPos[6]); + Matrix_MultVec3f(&sp70, &pthis->effectPos[6]); sp70.z -= 33.0f; if (sp70.z < 0.0f) { sp70.z = 0.0f; @@ -3130,20 +3130,20 @@ void BossVa_ZapperPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (sp70.z < 0.0f) { sp70.z = 0.0f; } - Matrix_MultVec3f(&sp70, &this->effectPos[6]); + Matrix_MultVec3f(&sp70, &pthis->effectPos[6]); sp70.z -= 22.0f; if (sp70.z < 0.0f) { sp70.z = 0.0f; } } - Matrix_MultVec3f(&sp70, &this->effectPos[5]); - Matrix_MultVec3f(&sp64, &this->colliderLightning.dim.quad[1]); - Matrix_MultVec3f(&sp58, &this->colliderLightning.dim.quad[0]); - Matrix_MultVec3f(&sp4C, &this->colliderLightning.dim.quad[3]); - Matrix_MultVec3f(&sp40, &this->colliderLightning.dim.quad[2]); - Collider_SetQuadVertices(&this->colliderLightning, &this->colliderLightning.dim.quad[0], - &this->colliderLightning.dim.quad[1], &this->colliderLightning.dim.quad[2], - &this->colliderLightning.dim.quad[3]); + Matrix_MultVec3f(&sp70, &pthis->effectPos[5]); + Matrix_MultVec3f(&sp64, &pthis->colliderLightning.dim.quad[1]); + Matrix_MultVec3f(&sp58, &pthis->colliderLightning.dim.quad[0]); + Matrix_MultVec3f(&sp4C, &pthis->colliderLightning.dim.quad[3]); + Matrix_MultVec3f(&sp40, &pthis->colliderLightning.dim.quad[2]); + Collider_SetQuadVertices(&pthis->colliderLightning, &pthis->colliderLightning.dim.quad[0], + &pthis->colliderLightning.dim.quad[1], &pthis->colliderLightning.dim.quad[2], + &pthis->colliderLightning.dim.quad[3]); Matrix_Pop(); break; } @@ -3151,24 +3151,24 @@ void BossVa_ZapperPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL s32 BossVa_BariOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; switch (limbIndex) { case 2: *dList = NULL; break; case 3: - Matrix_Scale(this->unk_1D8.x, 1.0f, this->unk_1D8.x, MTXMODE_APPLY); + Matrix_Scale(pthis->unk_1D8.x, 1.0f, pthis->unk_1D8.x, MTXMODE_APPLY); break; case 4: - Matrix_Scale(1.0f, this->unk_1D8.y, 1.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, pthis->unk_1D8.y, 1.0f, MTXMODE_APPLY); break; } return false; } void BossVa_BariPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_va.c", 4494); @@ -3190,7 +3190,7 @@ void BossVa_BariPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis void BossVa_Draw(Actor* thisx, GlobalContext* globalCtx) { s16* paramsPtr; // This stack slot is almost certainly actually globalCtx2, but can't make it match - BossVa* this = (BossVa*)thisx; + BossVa* pthis = (BossVa*)thisx; Vec3f spBC; Vec3f spB0 = { 0.0f, 45.0f, 0.0f }; Vec3f spA4 = { 0.4f, 0.4f, 0.4f }; @@ -3203,10 +3203,10 @@ void BossVa_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_boss_va.c", 4542); func_80093D18(globalCtx->state.gfxCtx); - paramsPtr = &this->actor.params; + paramsPtr = &pthis->actor.params; func_80093D84(globalCtx->state.gfxCtx); - switch (this->actor.params) { + switch (pthis->actor.params) { case BOSSVA_BODY: if (globalCtx->envCtx.adjFogNear != 0) { globalCtx->envCtx.adjFogNear += 0x15E; @@ -3222,76 +3222,76 @@ void BossVa_Draw(Actor* thisx, GlobalContext* globalCtx) { } } - if (!this->isDead) { + if (!pthis->isDead) { gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 8, 16, 1, 0, (globalCtx->gameplayFrames * -10) % 16, 16, 16)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (globalCtx->gameplayFrames * -10) % 32, 16, 0x20, 1, 0, (globalCtx->gameplayFrames * -5) % 32, 16, 32)); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - BossVa_BodyOverrideLimbDraw, BossVa_BodyPostLimbDraw, this); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + BossVa_BodyOverrideLimbDraw, BossVa_BodyPostLimbDraw, pthis); } break; case BOSSVA_SUPPORT_1: case BOSSVA_SUPPORT_2: case BOSSVA_SUPPORT_3: - if (!this->isDead) { - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossVa_SupportOverrideLimbDraw, - BossVa_SupportPostLimbDraw, this); + if (!pthis->isDead) { + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossVa_SupportOverrideLimbDraw, + BossVa_SupportPostLimbDraw, pthis); } break; case BOSSVA_ZAPPER_1: case BOSSVA_ZAPPER_2: case BOSSVA_ZAPPER_3: - if (!this->isDead) { - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, BossVa_ZapperOverrideLimbDraw, - BossVa_ZapperPostLimbDraw, this); + if (!pthis->isDead) { + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, BossVa_ZapperOverrideLimbDraw, + BossVa_ZapperPostLimbDraw, pthis); } break; case BOSSVA_STUMP_1: case BOSSVA_STUMP_2: case BOSSVA_STUMP_3: - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, NULL, NULL); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, NULL, NULL, NULL); break; default: - if (!this->isDead) { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - BossVa_BariOverrideLimbDraw, BossVa_BariPostLimbDraw, this); - Collider_UpdateSpheres(0, &this->colliderSph); + if (!pthis->isDead) { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + BossVa_BariOverrideLimbDraw, BossVa_BariPostLimbDraw, pthis); + Collider_UpdateSpheres(0, &pthis->colliderSph); if (sCsState < BOSSVA_BATTLE) { - spBC = GET_BODY(this)->actor.world.pos; + spBC = GET_BODY(pthis)->actor.world.pos; } else { - spBC = GET_BODY(this)->unk_1D8; + spBC = GET_BODY(pthis)->unk_1D8; } - Matrix_MultVec3f(&sZeroVec, &this->effectPos[1]); + Matrix_MultVec3f(&sZeroVec, &pthis->effectPos[1]); Matrix_Push(); Matrix_Translate(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, 0, MTXMODE_APPLY); - sp80.z = sp74.z = this->unk_1A0; - spB0.z = (this->timer2 & 0xF) * (this->unk_1A0 * 0.0625f); - Matrix_MultVec3f(&spB0, &this->effectPos[0]); - Matrix_MultVec3f(&sp98, &this->colliderLightning.dim.quad[1]); - Matrix_MultVec3f(&sp8C, &this->colliderLightning.dim.quad[0]); - Matrix_MultVec3f(&sp80, &this->colliderLightning.dim.quad[3]); - Matrix_MultVec3f(&sp74, &this->colliderLightning.dim.quad[2]); - Collider_SetQuadVertices(&this->colliderLightning, &this->colliderLightning.dim.quad[0], - &this->colliderLightning.dim.quad[1], &this->colliderLightning.dim.quad[2], - &this->colliderLightning.dim.quad[3]); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, 0, MTXMODE_APPLY); + sp80.z = sp74.z = pthis->unk_1A0; + spB0.z = (pthis->timer2 & 0xF) * (pthis->unk_1A0 * 0.0625f); + Matrix_MultVec3f(&spB0, &pthis->effectPos[0]); + Matrix_MultVec3f(&sp98, &pthis->colliderLightning.dim.quad[1]); + Matrix_MultVec3f(&sp8C, &pthis->colliderLightning.dim.quad[0]); + Matrix_MultVec3f(&sp80, &pthis->colliderLightning.dim.quad[3]); + Matrix_MultVec3f(&sp74, &pthis->colliderLightning.dim.quad[2]); + Collider_SetQuadVertices(&pthis->colliderLightning, &pthis->colliderLightning.dim.quad[0], + &pthis->colliderLightning.dim.quad[1], &pthis->colliderLightning.dim.quad[2], + &pthis->colliderLightning.dim.quad[3]); Matrix_Pop(); - spBC = this->actor.world.pos; + spBC = pthis->actor.world.pos; spBC.y += 9.0f; - if (this->actor.colorFilterTimer != 0) { + if (pthis->actor.colorFilterTimer != 0) { func_80026A6C(globalCtx); } func_80033C30(&spBC, &spA4, 0xFF, globalCtx); - if (this->actor.colorFilterTimer != 0) { + if (pthis->actor.colorFilterTimer != 0) { Color_RGBA8 blue = { 0, 0, 255, 255 }; - func_80026860(globalCtx, &blue, this->actor.colorFilterTimer, this->actor.colorFilterParams & 0xFF); + func_80026860(globalCtx, &blue, pthis->actor.colorFilterTimer, pthis->actor.colorFilterParams & 0xFF); } } break; @@ -3734,7 +3734,7 @@ void BossVa_DrawEffects(BossVaEffect* effect, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_boss_va.c", 5215); } -void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* offset, s16 scale, +void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* offset, s16 scale, u8 mode) { Player* player = GET_PLAYER(globalCtx); s16 index; @@ -3745,7 +3745,7 @@ void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_LARGE_SPARK; - effect->parent = this; + effect->parent = pthis; effect->pos = pos; effect->timer = (s16)(Rand_ZeroOne() * 10.0f) + 111; effect->velocity = effect->accel = sZeroVec; @@ -3756,10 +3756,10 @@ void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t effect->type = VA_SMALL_SPARK; case SPARK_TETHER: tempVec = *offset; - tempVec.x += this->actor.world.pos.x; - tempVec.z += this->actor.world.pos.z; - effect->offset.x = Math_Vec3f_DistXZ(&this->actor.world.pos, &tempVec); - effect->rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &GET_BODY(this)->unk_1D8); + tempVec.x += pthis->actor.world.pos.x; + tempVec.z += pthis->actor.world.pos.z; + effect->offset.x = Math_Vec3f_DistXZ(&pthis->actor.world.pos, &tempVec); + effect->rot.x = Math_Vec3f_Pitch(&pthis->actor.world.pos, &GET_BODY(pthis)->unk_1D8); break; case SPARK_BODY: @@ -3771,9 +3771,9 @@ void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t case SPARK_BLAST: effect->type = VA_BLAST_SPARK; - effect->pos.x = offset->x + this->actor.world.pos.x; - effect->pos.y = offset->y + this->actor.world.pos.y; - effect->pos.z = offset->z + this->actor.world.pos.z; + effect->pos.x = offset->x + pthis->actor.world.pos.x; + effect->pos.y = offset->y + pthis->actor.world.pos.y; + effect->pos.z = offset->z + pthis->actor.world.pos.z; effect->timer = 111; break; @@ -3794,7 +3794,7 @@ void BossVa_SpawnSpark(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t } } -void BossVa_SpawnSparkBall(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* offset, s16 scale, +void BossVa_SpawnSparkBall(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* offset, s16 scale, u8 mode) { Vec3f pos = { 0.0f, -1000.0f, 0.0f }; s16 i; @@ -3802,7 +3802,7 @@ void BossVa_SpawnSparkBall(GlobalContext* globalCtx, BossVaEffect* effect, BossV for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_SPARK_BALL; - effect->parent = this; + effect->parent = pthis; effect->pos = pos; @@ -3891,7 +3891,7 @@ void BossVa_SpawnBloodSplatter(GlobalContext* globalCtx, BossVaEffect* effect, V } } -void BossVa_SpawnTumor(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* offset, s16 scale, +void BossVa_SpawnTumor(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* offset, s16 scale, u8 mode) { Vec3f pos = { 0.0f, -1000.0f, 0.0f }; s16 i; @@ -3899,7 +3899,7 @@ void BossVa_SpawnTumor(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* t for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_TUMOR; - effect->parent = this; + effect->parent = pthis; effect->pos = pos; effect->velocity = effect->accel = sZeroVec; @@ -3967,7 +3967,7 @@ void BossVa_SpawnGore(GlobalContext* globalCtx, BossVaEffect* effect, Vec3f* pos } } -void BossVa_SpawnZapperCharge(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* this, Vec3f* pos, Vec3s* rot, +void BossVa_SpawnZapperCharge(GlobalContext* globalCtx, BossVaEffect* effect, BossVa* pthis, Vec3f* pos, Vec3s* rot, s16 scale, u8 mode) { Vec3f unused = { 0.0f, -1000.0f, 0.0f }; s16 i; @@ -3975,7 +3975,7 @@ void BossVa_SpawnZapperCharge(GlobalContext* globalCtx, BossVaEffect* effect, Bo for (i = 0; i < ARRAY_COUNT(sVaEffects); i++, effect++) { if (effect->type == VA_NONE) { effect->type = VA_ZAP_CHARGE; - effect->parent = this; + effect->parent = pthis; effect->pos = *pos; effect->velocity = effect->accel = sZeroVec; diff --git a/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c b/src/overlays/actors/ovl_Demo_6K/z_demo_6k.cpp similarity index 55% rename from src/overlays/actors/ovl_Demo_6K/z_demo_6k.c rename to src/overlays/actors/ovl_Demo_6K/z_demo_6k.cpp index daefcb00f..a5153db0a 100644 --- a/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c +++ b/src/overlays/actors/ovl_Demo_6K/z_demo_6k.cpp @@ -30,27 +30,27 @@ void Demo6K_Init(Actor* thisx, GlobalContext* globalCtx); void Demo6K_Destroy(Actor* thisx, GlobalContext* globalCtx); void Demo6K_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80966DB0(Demo6K* this, GlobalContext* globalCtx); -void func_80966E04(Demo6K* this, GlobalContext* globalCtx); -void func_80966E98(Demo6K* this, GlobalContext* globalCtx); -void func_80966F84(Demo6K* this, GlobalContext* globalCtx); -void func_8096712C(Demo6K* this, GlobalContext* globalCtx); -void func_80967410(Demo6K* this, GlobalContext* globalCtx); -void func_809674E0(Demo6K* this, GlobalContext* globalCtx); -void func_8096784C(Demo6K* this, GlobalContext* globalCtx); -void func_80967A04(Demo6K* this, s32 i); -void func_80967AD0(Demo6K* this, GlobalContext* globalCtx); -void func_80967DBC(Demo6K* this, GlobalContext* globalCtx); -void func_80967F10(Demo6K* this, GlobalContext* globalCtx); +void func_80966DB0(Demo6K* pthis, GlobalContext* globalCtx); +void func_80966E04(Demo6K* pthis, GlobalContext* globalCtx); +void func_80966E98(Demo6K* pthis, GlobalContext* globalCtx); +void func_80966F84(Demo6K* pthis, GlobalContext* globalCtx); +void func_8096712C(Demo6K* pthis, GlobalContext* globalCtx); +void func_80967410(Demo6K* pthis, GlobalContext* globalCtx); +void func_809674E0(Demo6K* pthis, GlobalContext* globalCtx); +void func_8096784C(Demo6K* pthis, GlobalContext* globalCtx); +void func_80967A04(Demo6K* pthis, s32 i); +void func_80967AD0(Demo6K* pthis, GlobalContext* globalCtx); +void func_80967DBC(Demo6K* pthis, GlobalContext* globalCtx); +void func_80967F10(Demo6K* pthis, GlobalContext* globalCtx); void func_80967FFC(Actor* thisx, GlobalContext* globalCtx); void func_80968298(Actor* thisx, GlobalContext* globalCtx); void func_8096865C(Actor* thisx, GlobalContext* globalCtx); void func_809688C4(Actor* thisx, GlobalContext* globalCtx); void func_80968B70(Actor* thisx, GlobalContext* globalCtx); void func_80968FB0(Actor* thisx, GlobalContext* globalCtx); -void func_809691BC(Demo6K* this, GlobalContext* globalCtx, s32 params); +void func_809691BC(Demo6K* pthis, GlobalContext* globalCtx, s32 params); -const ActorInit Demo_6K_InitVars = { +ActorInit Demo_6K_InitVars = { ACTOR_DEMO_6K, ACTORCAT_PROP, FLAGS, @@ -74,14 +74,14 @@ static Color_RGB8 sEnvColors[] = { static f32 D_8096930C[] = { 1.0f, 1.04f, 1.0f, 0.96f }; static f32 D_8096931C[] = { 1.1f, 1.0f, 0.9f, 0.8f }; -void Demo6K_SetupAction(Demo6K* this, Demo6KActionFunc actionFunc) { - this->actionFunc = actionFunc; +void Demo6K_SetupAction(Demo6K* pthis, Demo6KActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void Demo6K_Init(Actor* thisx, GlobalContext* globalCtx) { - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; s32 pad; - s32 params = this->actor.params; + s32 params = pthis->actor.params; s32 objBankIndex; s32 i; @@ -98,40 +98,40 @@ void Demo6K_Init(Actor* thisx, GlobalContext* globalCtx) { if (objBankIndex < 0) { ASSERT(0, "0", "../z_demo_6k.c", 334); } else { - this->objBankIndex = objBankIndex; + pthis->objBankIndex = objBankIndex; } - Demo6K_SetupAction(this, func_80966DB0); - this->timer1 = 0; - this->flags = 0; - this->timer2 = 0; + Demo6K_SetupAction(pthis, func_80966DB0); + pthis->timer1 = 0; + pthis->flags = 0; + pthis->timer2 = 0; switch (params) { case 0: - this->drawFunc = func_809688C4; - this->initActionFunc = func_80967AD0; - Actor_SetScale(&this->actor, 1.0f); + pthis->drawFunc = func_809688C4; + pthis->initActionFunc = func_80967AD0; + Actor_SetScale(&pthis->actor, 1.0f); for (i = 0; i < 16; i++) { - func_80967A04(this, i); - this->unk_1B4[i] = 0.0f; + func_80967A04(pthis, i); + pthis->unk_1B4[i] = 0.0f; } - this->unk_170 = 0.0f; + pthis->unk_170 = 0.0f; break; case 1: - this->drawFunc = func_80967FFC; - this->initActionFunc = func_80966E04; - Actor_SetScale(&this->actor, 0.228f); + pthis->drawFunc = func_80967FFC; + pthis->initActionFunc = func_80966E04; + Actor_SetScale(&pthis->actor, 0.228f); break; case 2: - this->drawFunc = func_80968298; - this->initActionFunc = func_80966F84; - Actor_SetScale(&this->actor, 0.1f); - this->unk_164 = 1.0f; - this->unk_168 = 1.0f; - this->unk_16C = 0.0f; - this->unk_170 = 0.0f; + pthis->drawFunc = func_80968298; + pthis->initActionFunc = func_80966F84; + Actor_SetScale(&pthis->actor, 0.1f); + pthis->unk_164 = 1.0f; + pthis->unk_168 = 1.0f; + pthis->unk_16C = 0.0f; + pthis->unk_170 = 0.0f; break; case 3: case 4: @@ -139,35 +139,35 @@ void Demo6K_Init(Actor* thisx, GlobalContext* globalCtx) { case 6: case 7: case 8: - this->drawFunc = func_8096865C; - this->initActionFunc = func_8096712C; - Actor_SetScale(&this->actor, 0.0f); - this->unk_293 = params - 3; + pthis->drawFunc = func_8096865C; + pthis->initActionFunc = func_8096712C; + Actor_SetScale(&pthis->actor, 0.0f); + pthis->unk_293 = params - 3; break; case 9: case 10: - this->drawFunc = func_8096865C; - Actor_SetScale(&this->actor, 0.0f); - this->initActionFunc = func_809674E0; + pthis->drawFunc = func_8096865C; + Actor_SetScale(&pthis->actor, 0.0f); + pthis->initActionFunc = func_809674E0; break; case 11: - this->drawFunc = func_8096865C; - Actor_SetScale(&this->actor, 0.0f); - this->initActionFunc = func_8096784C; - this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_NABALL_VANISH); + pthis->drawFunc = func_8096865C; + Actor_SetScale(&pthis->actor, 0.0f); + pthis->initActionFunc = func_8096784C; + pthis->actor.velocity.x = pthis->actor.velocity.y = pthis->actor.velocity.z = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_NABALL_VANISH); break; case 12: - Actor_SetScale(&this->actor, 0.0f); - this->initActionFunc = func_80967F10; - this->drawFunc = func_80968B70; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ITEMACTION); + Actor_SetScale(&pthis->actor, 0.0f); + pthis->initActionFunc = func_80967F10; + pthis->drawFunc = func_80968B70; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ITEMACTION); break; case 13: - Actor_SetScale(&this->actor, 0.14f); - Demo6K_SetupAction(this, func_80967DBC); - this->actor.draw = func_80968FB0; - this->unk_293 = 0; + Actor_SetScale(&pthis->actor, 0.14f); + Demo6K_SetupAction(pthis, func_80967DBC); + pthis->actor.draw = func_80968FB0; + pthis->unk_293 = 0; break; case 14: case 15: @@ -175,12 +175,12 @@ void Demo6K_Init(Actor* thisx, GlobalContext* globalCtx) { case 17: case 18: case 19: - this->actor.flags |= ACTOR_FLAG_5; - this->drawFunc = func_8096865C; - this->initActionFunc = func_80967410; - this->flags |= 1; - Actor_SetScale(&this->actor, 0.2f); - this->unk_293 = params - 14; + pthis->actor.flags |= ACTOR_FLAG_5; + pthis->drawFunc = func_8096865C; + pthis->initActionFunc = func_80967410; + pthis->flags |= 1; + Actor_SetScale(&pthis->actor, 0.2f); + pthis->unk_293 = params - 14; break; default: ASSERT(0, "0", "../z_demo_6k.c", 435); @@ -189,135 +189,135 @@ void Demo6K_Init(Actor* thisx, GlobalContext* globalCtx) { switch (params) { case 9: - this->unk_293 = 0; + pthis->unk_293 = 0; break; case 10: - this->unk_293 = 5; + pthis->unk_293 = 5; break; case 11: - this->unk_293 = 4; + pthis->unk_293 = 4; break; } - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, 100); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, 100); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); } void Demo6K_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); } -void func_80966DB0(Demo6K* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; - this->actor.draw = this->drawFunc; - this->actionFunc = this->initActionFunc; +void func_80966DB0(Demo6K* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->actor.objBankIndex = pthis->objBankIndex; + pthis->actor.draw = pthis->drawFunc; + pthis->actionFunc = pthis->initActionFunc; } } -void func_80966E04(Demo6K* this, GlobalContext* globalCtx) { +void func_80966E04(Demo6K* pthis, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames > 214) { - func_8002F948(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); } if (globalCtx->csCtx.frames > 264) { - func_8002F948(&this->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); } if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[6] != NULL) && (globalCtx->csCtx.npcActions[6]->action == 2)) { - Demo6K_SetupAction(this, func_80966E98); + Demo6K_SetupAction(pthis, func_80966E98); } } -void func_80966E98(Demo6K* this, GlobalContext* globalCtx) { +void func_80966E98(Demo6K* pthis, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames < 353) { - func_8002F948(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); - func_8002F948(&this->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); } if (globalCtx->csCtx.frames == 342) { func_800F3F3C(2); } - if (this->timer1 == 39) { + if (pthis->timer1 == 39) { func_800788CC(NA_SE_EV_CONSENTRATION); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - this->actor.world.pos.y + 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 10.0f, pthis->actor.world.pos.z, 0, 0, 0, 2); } - if (this->timer1 == 64) { - Actor_Kill(&this->actor); + if (pthis->timer1 == 64) { + Actor_Kill(&pthis->actor); } - this->timer1++; + pthis->timer1++; } -void func_80966F84(Demo6K* this, GlobalContext* globalCtx) { - if (this->timer1 < 5) { - this->unk_168 = D_8096930C[this->timer1 & 3]; - } else if (this->timer1 < 15) { - this->actor.scale.x += 0.012f; - Actor_SetScale(&this->actor, this->actor.scale.x); - Math_StepToF(&this->unk_170, 0.6f, 0.05f); - this->unk_168 = 1.0f; +void func_80966F84(Demo6K* pthis, GlobalContext* globalCtx) { + if (pthis->timer1 < 5) { + pthis->unk_168 = D_8096930C[pthis->timer1 & 3]; + } else if (pthis->timer1 < 15) { + pthis->actor.scale.x += 0.012f; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + Math_StepToF(&pthis->unk_170, 0.6f, 0.05f); + pthis->unk_168 = 1.0f; } else { - if (this->timer1 == 15) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EFF_DUST, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, EFF_DUST_TYPE_1); + if (pthis->timer1 == 15) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EFF_DUST, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, EFF_DUST_TYPE_1); } - Math_StepToF(&this->unk_16C, 1.0f, 0.02f); - this->unk_168 = D_8096930C[this->timer1 & 1]; + Math_StepToF(&pthis->unk_16C, 1.0f, 0.02f); + pthis->unk_168 = D_8096930C[pthis->timer1 & 1]; } - this->timer1++; + pthis->timer1++; } -void func_809670AC(Demo6K* this, GlobalContext* globalCtx) { - this->timer2++; +void func_809670AC(Demo6K* pthis, GlobalContext* globalCtx) { + pthis->timer2++; - if (this->timer1 < 10) { - this->timer1++; - } else if (this->actor.scale.x > 0.0f) { - this->actor.scale.x -= 1.0f / 120.0f; - Actor_SetScale(&this->actor, this->actor.scale.x); + if (pthis->timer1 < 10) { + pthis->timer1++; + } else if (pthis->actor.scale.x > 0.0f) { + pthis->actor.scale.x -= 1.0f / 120.0f; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void func_8096712C(Demo6K* this, GlobalContext* globalCtx) { +void func_8096712C(Demo6K* pthis, GlobalContext* globalCtx) { static u16 D_8096932C[] = { 275, 275, 275, 275, 275, 275 }; u32 frames = globalCtx->state.frames; - if (this->actor.scale.x < 0.1f) { - this->actor.scale.x += 0.0017f; + if (pthis->actor.scale.x < 0.1f) { + pthis->actor.scale.x += 0.0017f; } else if (frames & 1) { - this->actor.scale.x = 0.1f * 1.04f; + pthis->actor.scale.x = 0.1f * 1.04f; } else { - this->actor.scale.x = 0.1f; + pthis->actor.scale.x = 0.1f; } if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[6] != NULL) && (globalCtx->csCtx.npcActions[6]->action == 2)) { - Demo6K_SetupAction(this, func_809670AC); - this->timer1 = 0; - this->actor.scale.x = 0.1f; + Demo6K_SetupAction(pthis, func_809670AC); + pthis->timer1 = 0; + pthis->actor.scale.x = 0.1f; } - Actor_SetScale(&this->actor, this->actor.scale.x); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); - this->timer2++; + pthis->timer2++; - if ((globalCtx->sceneNum == SCENE_GANONTIKA) && (globalCtx->csCtx.frames < D_8096932C[this->actor.params - 3])) { - func_8002F974(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + if ((globalCtx->sceneNum == SCENE_GANONTIKA) && (globalCtx->csCtx.frames < D_8096932C[pthis->actor.params - 3])) { + func_8002F974(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); } } -void func_80967244(Demo6K* this, GlobalContext* globalCtx) { +void func_80967244(Demo6K* pthis, GlobalContext* globalCtx) { static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Color_RGBA8 primColor = { 255, 255, 255, 0 }; @@ -327,9 +327,9 @@ void func_80967244(Demo6K* this, GlobalContext* globalCtx) { s16 rand2; s32 scale; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z; + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z; rand1 = Rand_ZeroFloat(0xFFFF); rand2 = Rand_ZeroFloat(0xFFFF); @@ -340,9 +340,9 @@ void func_80967244(Demo6K* this, GlobalContext* globalCtx) { accel.y = 0.0f; - envColor.r = sEnvColors[this->unk_293].r; - envColor.g = sEnvColors[this->unk_293].g; - envColor.b = sEnvColors[this->unk_293].b; + envColor.r = sEnvColors[pthis->unk_293].r; + envColor.g = sEnvColors[pthis->unk_293].g; + envColor.b = sEnvColors[pthis->unk_293].b; if (globalCtx->sceneNum == SCENE_TOKINOMA) { scale = 6000; @@ -355,73 +355,73 @@ void func_80967244(Demo6K* this, GlobalContext* globalCtx) { EffectSsKiraKira_SpawnFocused(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, scale, 20); } -void func_80967410(Demo6K* this, GlobalContext* globalCtx) { - s32 params = this->actor.params - 14; +void func_80967410(Demo6K* pthis, GlobalContext* globalCtx) { + s32 params = pthis->actor.params - 14; - this->timer2++; + pthis->timer2++; - Actor_SetScale(&this->actor, 0.2f); + Actor_SetScale(&pthis->actor, 0.2f); if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[params] != NULL)) { - func_809691BC(this, globalCtx, params); + func_809691BC(pthis, globalCtx, params); if (globalCtx->csCtx.npcActions[params]->action == 3) { - this->flags &= ~1; - func_80967244(this, globalCtx); + pthis->flags &= ~1; + func_80967244(pthis, globalCtx); } else { - this->flags |= 1; + pthis->flags |= 1; } } else { - this->flags |= 1; + pthis->flags |= 1; } } -void func_809674E0(Demo6K* this, GlobalContext* globalCtx) { +void func_809674E0(Demo6K* pthis, GlobalContext* globalCtx) { u32 frames = globalCtx->state.frames; - if (this->actor.scale.x < 0.05f) { - this->actor.scale.x += 0.005f; + if (pthis->actor.scale.x < 0.05f) { + pthis->actor.scale.x += 0.005f; } else if (frames & 1) { - this->actor.scale.x = 0.05f * 1.04f; + pthis->actor.scale.x = 0.05f * 1.04f; } else { - this->actor.scale.x = 0.05f; + pthis->actor.scale.x = 0.05f; } - Actor_SetScale(&this->actor, this->actor.scale.x); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); - this->timer2++; + pthis->timer2++; - if (this->timer2 > 47) { - Actor_Kill(&this->actor); - } else if (this->timer2 > 39) { - f32 dTimer = this->timer2 - 39; + if (pthis->timer2 > 47) { + Actor_Kill(&pthis->actor); + } else if (pthis->timer2 > 39) { + f32 dTimer = pthis->timer2 - 39; f32 temp = 1.0f / (9.0f - dTimer); - this->actor.world.pos.x += (-1611.0f - this->actor.world.pos.x) * temp; - this->actor.world.pos.y += (19.0f - this->actor.world.pos.y) * temp; - this->actor.world.pos.z += (1613.0f - this->actor.world.pos.z) * temp; + pthis->actor.world.pos.x += (-1611.0f - pthis->actor.world.pos.x) * temp; + pthis->actor.world.pos.y += (19.0f - pthis->actor.world.pos.y) * temp; + pthis->actor.world.pos.z += (1613.0f - pthis->actor.world.pos.z) * temp; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_FIRE - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_FIRE - SFX_FLAG); } - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, sEnvColors[this->unk_293].r, sEnvColors[this->unk_293].g, - sEnvColors[this->unk_293].b, this->actor.scale.x * 4000.0f); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, sEnvColors[pthis->unk_293].r, sEnvColors[pthis->unk_293].g, + sEnvColors[pthis->unk_293].b, pthis->actor.scale.x * 4000.0f); } -void func_809676A4(Demo6K* this, GlobalContext* globalCtx) { +void func_809676A4(Demo6K* pthis, GlobalContext* globalCtx) { static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Color_RGBA8 primColor = { 255, 255, 255, 0 }; static Color_RGBA8 envColor = { 255, 150, 0, 0 }; Vec3f pos; - f32 temp = this->actor.scale.x * 500.0f; + f32 temp = pthis->actor.scale.x * 500.0f; s32 i; for (i = 0; i < 8; i++) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(temp); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(temp); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(temp); + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(temp); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(temp); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(temp); velocity.x = Rand_CenteredFloat(2.0f); velocity.y = (Rand_ZeroFloat(-10.0f) - 5.0f) * 0.1f; @@ -433,65 +433,65 @@ void func_809676A4(Demo6K* this, GlobalContext* globalCtx) { } } -void func_8096784C(Demo6K* this, GlobalContext* globalCtx) { +void func_8096784C(Demo6K* pthis, GlobalContext* globalCtx) { u32 frames = globalCtx->state.frames; - this->timer2++; + pthis->timer2++; - if (this->timer2 > 24) { - Actor_Kill(&this->actor); - } else if (this->timer2 > 4) { - this->actor.velocity.x += Rand_CenteredFloat(0.2f); - this->actor.velocity.y += 0.12f; - this->actor.velocity.z += Rand_CenteredFloat(0.2f); + if (pthis->timer2 > 24) { + Actor_Kill(&pthis->actor); + } else if (pthis->timer2 > 4) { + pthis->actor.velocity.x += Rand_CenteredFloat(0.2f); + pthis->actor.velocity.y += 0.12f; + pthis->actor.velocity.z += Rand_CenteredFloat(0.2f); - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.world.pos.z += this->actor.velocity.z; + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.world.pos.z += pthis->actor.velocity.z; - this->actor.scale.x -= 0.0015f; + pthis->actor.scale.x -= 0.0015f; - func_809676A4(this, globalCtx); + func_809676A4(pthis, globalCtx); } else if (frames & 1) { - this->actor.scale.x = 0.033f; + pthis->actor.scale.x = 0.033f; } else { - this->actor.scale.x = 0.03f; + pthis->actor.scale.x = 0.03f; } - Actor_SetScale(&this->actor, this->actor.scale.x); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, sEnvColors[this->unk_293].r, sEnvColors[this->unk_293].g, - sEnvColors[this->unk_293].b, this->actor.scale.x * 4000.0f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, sEnvColors[pthis->unk_293].r, sEnvColors[pthis->unk_293].g, + sEnvColors[pthis->unk_293].b, pthis->actor.scale.x * 4000.0f); } -void func_80967A04(Demo6K* this, s32 i) { - this->unk_174[i] = (i * 10.0f) - 80.0f; - this->unk_1B4[i] = Rand_ZeroFloat(100.0f) + 100.0f; - this->unk_1F4[i] = -3.0f - Rand_ZeroFloat(6.0f); - this->unk_274[i] = (s32)Rand_ZeroFloat(6.0f); - this->unk_234[i] = Rand_ZeroFloat(0.02f) + 0.01f; +void func_80967A04(Demo6K* pthis, s32 i) { + pthis->unk_174[i] = (i * 10.0f) - 80.0f; + pthis->unk_1B4[i] = Rand_ZeroFloat(100.0f) + 100.0f; + pthis->unk_1F4[i] = -3.0f - Rand_ZeroFloat(6.0f); + pthis->unk_274[i] = (s32)Rand_ZeroFloat(6.0f); + pthis->unk_234[i] = Rand_ZeroFloat(0.02f) + 0.01f; } -void func_80967AD0(Demo6K* this, GlobalContext* globalCtx) { +void func_80967AD0(Demo6K* pthis, GlobalContext* globalCtx) { s32 i; if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[1] != NULL)) { if (globalCtx->csCtx.npcActions[1]->action == 2) { - this->unk_170++; - func_8002F948(&this->actor, NA_SE_EV_RAINBOW_SHOWER - SFX_FLAG); + pthis->unk_170++; + func_8002F948(&pthis->actor, NA_SE_EV_RAINBOW_SHOWER - SFX_FLAG); } - func_809691BC(this, globalCtx, 1); + func_809691BC(pthis, globalCtx, 1); } - for (i = 0; (i < (s32)this->unk_170) && (i < 16); i++) { - this->unk_1B4[i] += this->unk_1F4[i]; - if (this->unk_1B4[i] < 0.0f) { - func_80967A04(this, i); + for (i = 0; (i < (s32)pthis->unk_170) && (i < 16); i++) { + pthis->unk_1B4[i] += pthis->unk_1F4[i]; + if (pthis->unk_1B4[i] < 0.0f) { + func_80967A04(pthis, i); } } - this->timer1++; + pthis->timer1++; } void func_80967BF8(Player* player, GlobalContext* globalCtx) { @@ -518,61 +518,61 @@ void func_80967BF8(Player* player, GlobalContext* globalCtx) { } } -void func_80967DBC(Demo6K* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_ATTACK_DEMO - SFX_FLAG); +void func_80967DBC(Demo6K* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_ATTACK_DEMO - SFX_FLAG); - this->timer2++; + pthis->timer2++; - if (this->timer2 > 44) { - if (this->unk_293 < 236) { - this->unk_293 += 20; + if (pthis->timer2 > 44) { + if (pthis->unk_293 < 236) { + pthis->unk_293 += 20; } else { - this->unk_293 = 255; + pthis->unk_293 = 255; } - if (this->timer2 > 104) { + if (pthis->timer2 > 104) { func_80967BF8(GET_PLAYER(globalCtx), globalCtx); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); Audio_PlayActorSound2(&GET_PLAYER(globalCtx)->actor, NA_SE_EN_FANTOM_HIT_THUNDER); - } else if (this->timer2 > 94) { - Actor_SetScale(&this->actor, this->actor.scale.x + 0.03f); + } else if (pthis->timer2 > 94) { + Actor_SetScale(&pthis->actor, pthis->actor.scale.x + 0.03f); - if (this->timer2 == 95) { + if (pthis->timer2 == 95) { osSyncPrintf(VT_FGCOL(CYAN) " NA_SE_EN_GANON_FIRE_DEMO\n" VT_RST); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_FIRE_DEMO); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_FIRE_DEMO); } } - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 200, 0, this->unk_293); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 200, 0, pthis->unk_293); } } -void func_80967F10(Demo6K* this, GlobalContext* globalCtx) { - if (this->timer2 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 13); +void func_80967F10(Demo6K* pthis, GlobalContext* globalCtx) { + if (pthis->timer2 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 13); } - this->timer2++; + pthis->timer2++; - if (this->timer2 > 60) { - Actor_Kill(&this->actor); + if (pthis->timer2 > 60) { + Actor_Kill(&pthis->actor); } - Actor_SetScale(&this->actor, 0.05f - (this->timer2 * 0.00075f)); + Actor_SetScale(&pthis->actor, 0.05f - (pthis->timer2 * 0.00075f)); } void Demo6K_Update(Actor* thisx, GlobalContext* globalCtx) { - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void func_80967FFC(Actor* thisx, GlobalContext* globalCtx) { - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; s32 pad; - u16 timer1 = this->timer1; + u16 timer1 = pthis->timer1; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1070); @@ -612,10 +612,10 @@ void func_80967FFC(Actor* thisx, GlobalContext* globalCtx) { void func_80968298(Actor* thisx, GlobalContext* globalCtx) { static u8 skipIndices[] = { 6, 7, 11, 16, 20, 24, 28, 33, 35, 41, 45, 50, 57, 58, 62, 255 }; - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; s32 pad; - u32 timer1 = this->timer1; - f32 scale = this->unk_164 * this->unk_168; + u32 timer1 = pthis->timer1; + f32 scale = pthis->unk_164 * pthis->unk_168; Vtx* vertices = SEGMENTED_TO_VIRTUAL(object_demo_6kVtx_0035E0); s32 i; s32 i2; @@ -623,7 +623,7 @@ void func_80968298(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1145); - alpha = (s32)(this->unk_170 * 255.0f); + alpha = (s32)(pthis->unk_170 * 255.0f); POLY_XLU_DISP = func_800937C0(POLY_XLU_DISP); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); @@ -631,7 +631,7 @@ void func_80968298(Actor* thisx, GlobalContext* globalCtx) { gDPFillRectangle(POLY_XLU_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); func_80093D84(globalCtx->state.gfxCtx); - alpha = (s32)(this->unk_16C * 255.0f); + alpha = (s32)(pthis->unk_16C * 255.0f); for (i2 = 0, i = 0; i < 63; i++) { if (i == skipIndices[i2]) { i2++; @@ -661,14 +661,14 @@ void func_80968298(Actor* thisx, GlobalContext* globalCtx) { } void func_8096865C(Actor* thisx, GlobalContext* globalCtx) { - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; s32 pad; Gfx* displayList; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1208); - if (!(this->flags & 1)) { - if (this->actor.params > 8) { + if (!(pthis->flags & 1)) { + if (pthis->actor.params > 8) { displayList = gEffFlash1DL; } else { displayList = gEffFlash2DL; @@ -676,16 +676,16 @@ void func_8096865C(Actor* thisx, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[this->unk_293].r, sEnvColors[this->unk_293].g, - sEnvColors[this->unk_293].b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[pthis->unk_293].r, sEnvColors[pthis->unk_293].g, + sEnvColors[pthis->unk_293].b, 255); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); Matrix_Push(); - Matrix_RotateZ((f32)(this->timer2 * 6) * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateZ((f32)(pthis->timer2 * 6) * (M_PI / 180.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1230), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, displayList); Matrix_Pop(); - Matrix_RotateZ(-(f32)(this->timer2 * 6) * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateZ(-(f32)(pthis->timer2 * 6) * (M_PI / 180.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1236), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, displayList); @@ -695,7 +695,7 @@ void func_8096865C(Actor* thisx, GlobalContext* globalCtx) { } void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { - Demo6K* this = (Demo6K*)thisx; + Demo6K* pthis = (Demo6K*)thisx; GlobalContext* globalCtx = globalCtx2; u32 frames = globalCtx->state.frames; s32 i; @@ -710,13 +710,13 @@ void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < 16; i++) { gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[this->unk_274[i]].r, sEnvColors[this->unk_274[i]].g, - sEnvColors[this->unk_274[i]].b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[pthis->unk_274[i]].r, sEnvColors[pthis->unk_274[i]].g, + sEnvColors[pthis->unk_274[i]].b, 255); Matrix_Push(); - Matrix_Translate(this->unk_174[i], this->unk_1B4[i], 0.0f, MTXMODE_APPLY); - Matrix_Scale(this->unk_234[i] * D_8096931C[(frames + i) & 3], - this->unk_234[i] * D_8096931C[(frames + i) & 3], - this->unk_234[i] * D_8096931C[(frames + i) & 3], MTXMODE_APPLY); + Matrix_Translate(pthis->unk_174[i], pthis->unk_1B4[i], 0.0f, MTXMODE_APPLY); + Matrix_Scale(pthis->unk_234[i] * D_8096931C[(frames + i) & 3], + pthis->unk_234[i] * D_8096931C[(frames + i) & 3], + pthis->unk_234[i] * D_8096931C[(frames + i) & 3], MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1297), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -732,8 +732,8 @@ void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { void func_80968B70(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - Demo6K* this = (Demo6K*)thisx; - u32 timer2 = this->timer2; + Demo6K* pthis = (Demo6K*)thisx; + u32 timer2 = pthis->timer2; u8 primColor[4]; u8 envColor[3]; @@ -750,21 +750,21 @@ void func_80968B70(Actor* thisx, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0xFF - ((timer2 * 2) & 0xFF), 0, 32, 32, 1, 0xFF - ((timer2 * 2) & 0xFF), (timer2 * 15) & 0x3FF, 16, 64)); - if (this->timer2 < 40) { - primColor[0] = primColor[2] = 100 - (this->timer2 * 2.5f); + if (pthis->timer2 < 40) { + primColor[0] = primColor[2] = 100 - (pthis->timer2 * 2.5f); primColor[1] = envColor[1] = 0; envColor[0] = 100 - primColor[2]; - primColor[3] = this->timer2 * 6.375f; + primColor[3] = pthis->timer2 * 6.375f; envColor[2] = envColor[0] * 2; - } else if (this->timer2 < 50) { - primColor[0] = (this->timer2 * 5) - 200; + } else if (pthis->timer2 < 50) { + primColor[0] = (pthis->timer2 * 5) - 200; primColor[1] = primColor[2] = 0; primColor[3] = 255; envColor[0] = 100 - primColor[0]; envColor[1] = primColor[0] * 2; envColor[2] = 200 - (primColor[0] * 4); } else { - primColor[2] = (this->timer2 * 5) - 250; + primColor[2] = (pthis->timer2 * 5) - 250; envColor[2] = 0; primColor[1] = primColor[2] * 3; primColor[3] = 255; @@ -781,8 +781,8 @@ void func_80968B70(Actor* thisx, GlobalContext* globalCtx) { void func_80968FB0(Actor* thisx, GlobalContext* globalCtx) { static u8 D_809693CC[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1 }; - Demo6K* this = (Demo6K*)thisx; - Gfx* displayList = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Gfx)); + Demo6K* pthis = (Demo6K*)thisx; + Gfx* displayList = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Gfx)); u16 frames = globalCtx->gameplayFrames; f32 scaleFactor; s32 pad; @@ -793,13 +793,13 @@ void func_80968FB0(Actor* thisx, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); scaleFactor = ((s16)D_809693CC[(frames * 4) & 0xF] * 0.01f) + 1.0f; - Matrix_Scale(this->actor.scale.x * scaleFactor, this->actor.scale.y * scaleFactor, - this->actor.scale.z * scaleFactor, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x * scaleFactor, pthis->actor.scale.y * scaleFactor, + pthis->actor.scale.z * scaleFactor, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1394), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, displayList); gDPPipeSync(displayList++); - gDPSetPrimColor(displayList++, 0, 0x80, 255, 255, 255, this->unk_293); + gDPSetPrimColor(displayList++, 0, 0x80, 255, 255, 255, pthis->unk_293); gDPSetRenderMode(displayList++, G_RM_PASS, G_RM_ZB_CLD_SURF2); gSPEndDisplayList(displayList++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 255); @@ -808,7 +808,7 @@ void func_80968FB0(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_6k.c", 1411); } -void func_809691BC(Demo6K* this, GlobalContext* globalCtx, s32 params) { +void func_809691BC(Demo6K* pthis, GlobalContext* globalCtx, s32 params) { Vec3f startPos; Vec3f endPos; f32 temp; @@ -824,7 +824,7 @@ void func_809691BC(Demo6K* this, GlobalContext* globalCtx, s32 params) { temp = Environment_LerpWeight(csAction->endFrame, csAction->startFrame, globalCtx->csCtx.frames); - this->actor.world.pos.x = (((endPos.x - startPos.x) * temp) + startPos.x); - this->actor.world.pos.y = (((endPos.y - startPos.y) * temp) + startPos.y); - this->actor.world.pos.z = (((endPos.z - startPos.z) * temp) + startPos.z); + pthis->actor.world.pos.x = (((endPos.x - startPos.x) * temp) + startPos.x); + pthis->actor.world.pos.y = (((endPos.y - startPos.y) * temp) + startPos.y); + pthis->actor.world.pos.z = (((endPos.z - startPos.z) * temp) + startPos.z); } diff --git a/src/overlays/actors/ovl_Demo_Du/z_demo_du.c b/src/overlays/actors/ovl_Demo_Du/z_demo_du.c deleted file mode 100644 index 4c16a9410..000000000 --- a/src/overlays/actors/ovl_Demo_Du/z_demo_du.c +++ /dev/null @@ -1,1059 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_DU_Z_DEMO_DU_C -#include "actor_common.h" -#include "z_demo_du.h" -#include "objects/object_du/object_du.h" -#include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "vt.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef void (*DemoDuActionFunc)(DemoDu*, GlobalContext*); -typedef void (*DemoDuDrawFunc)(Actor*, GlobalContext*); - -void DemoDu_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoDu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoDu_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoDu_Draw(Actor* thisx, GlobalContext* globalCtx); - -static s32 sUnused = 0; - -#include "z_demo_du_cutscene_data.c" EARLY -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -static void* sEyeTextures[] = { gDaruniaEyeOpenTex, gDaruniaEyeOpeningTex, gDaruniaEyeShutTex, gDaruniaEyeClosingTex }; -static void* sMouthTextures[] = { gDaruniaMouthSeriousTex, gDaruniaMouthGrinningTex, gDaruniaMouthOpenTex, - gDaruniaMouthHappyTex }; - -/** - * Cs => Cutscene - * - * FM => Fire Medallion - * GR => Goron's Ruby - * AG => In the chamber of sages, just After the final blow on Ganon. - * CR => Credits - * - */ - -// Each macro maps its argument to an index of sUpdateFuncs. -#define CS_FIREMEDALLION_SUBSCENE(x) (0 + (x)) // DEMO_DU_CS_FIREMEDALLION -#define CS_GORONSRUBY_SUBSCENE(x) (7 + (x)) // DEMO_DU_CS_GORONS_RUBY -#define CS_CHAMBERAFTERGANON_SUBSCENE(x) (21 + (x)) // DEMO_DU_CS_CHAMBER_AFTER_GANON -#define CS_CREDITS_SUBSCENE(x) (24 + (x)) // DEMO_DU_CS_CREDITS - -void DemoDu_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoDu* this = (DemoDu*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); -} - -void DemoDu_UpdateEyes(DemoDu* this) { - s16* blinkTimer = &this->blinkTimer; - s16* eyeTexIndex = &this->eyeTexIndex; - s32 pad[3]; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - - *eyeTexIndex = *blinkTimer; - if (*eyeTexIndex >= 3) { - *eyeTexIndex = 0; - } -} - -void DemoDu_SetEyeTexIndex(DemoDu* this, s16 eyeTexIndex) { - this->eyeTexIndex = eyeTexIndex; -} - -void DemoDu_SetMouthTexIndex(DemoDu* this, s16 mouthTexIndex) { - this->mouthTexIndex = mouthTexIndex; -} - -// Resets all the values used in this cutscene. -void DemoDu_CsAfterGanon_Reset(DemoDu* this) { - this->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(0); - this->drawIndex = 0; - this->shadowAlpha = 0; - this->demo6KSpawned = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_1A4 = 0.0f; -} - -void DemoDu_CsAfterGanon_CheckIfShouldReset(DemoDu* this, GlobalContext* globalCtx) { - static s32 D_8096CE94 = false; - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - if (D_8096CE94) { - if (this->actor.params == DEMO_DU_CS_CHAMBER_AFTER_GANON) { - DemoDu_CsAfterGanon_Reset(this); - } - D_8096CE94 = false; - return; - } - } else if (!D_8096CE94) { - D_8096CE94 = true; - } -} - -s32 DemoDu_UpdateSkelAnime(DemoDu* this) { - return SkelAnime_Update(&this->skelAnime); -} - -void DemoDu_UpdateBgCheckInfo(DemoDu* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -CsCmdActorAction* DemoDu_GetNpcAction(GlobalContext* globalCtx, s32 idx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[idx]; - } - return NULL; -} - -s32 DemoDu_IsNpcDoingThisAction(DemoDu* this, GlobalContext* globalCtx, u16 action, s32 idx) { - CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, idx); - - if ((npcAction != NULL) && (npcAction->action == action)) { - return true; - } - return false; -} - -s32 DemoDu_IsNpcNotDoingThisAction(DemoDu* this, GlobalContext* globalCtx, u16 action, s32 idx) { - CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, idx); - - if ((npcAction != NULL) && (npcAction->action != action)) { - return true; - } - return false; -} - -void DemoDu_MoveToNpcPos(DemoDu* this, GlobalContext* globalCtx, s32 idx) { - CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, idx); - s32 pad; - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -void func_80969DDC(DemoDu* this, AnimationHeader* animation, u8 mode, f32 morphFrames, s32 arg4) { - f32 startFrame; - s16 lastFrame = Animation_GetLastFrame(animation); - f32 endFrame; - f32 playSpeed; - - if (arg4 == 0) { - startFrame = 0.0f; - endFrame = lastFrame; - playSpeed = 1.0f; - } else { - endFrame = 0.0f; - playSpeed = -1.0f; - startFrame = lastFrame; - } - Animation_Change(&this->skelAnime, animation, playSpeed, startFrame, endFrame, mode, morphFrames); -} - -void DemoDu_InitCs_FireMedallion(DemoDu* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDaruniaSkel, &gDaruniaIdleAnim, NULL, NULL, 0); - this->actor.shape.yOffset = -10000.0f; - DemoDu_SetEyeTexIndex(this, 1); - DemoDu_SetMouthTexIndex(this, 3); -} - -// A.k.a Warp portal -void DemoDu_CsFireMedallion_SpawnDoorWarp(DemoDu* this, GlobalContext* globalCtx) { - f32 posX = this->actor.world.pos.x; - f32 posY = this->actor.world.pos.y; - f32 posZ = this->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, - WARP_SAGES); -} - -// Gives the Fire Medallion to Link. -void func_80969F38(DemoDu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 posX = player->actor.world.pos.x; - f32 posY = player->actor.world.pos.y + 80.0f; - f32 posZ = player->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, - DEMO_EFFECT_MEDAL_FIRE); - Item_Give(globalCtx, ITEM_MEDALLION_FIRE); -} - -void func_80969FB4(DemoDu* this, GlobalContext* globalCtx) { - this->actor.shape.yOffset += 250.0f / 3.0f; -} - -// Gives the Fire Medallion to Link too. -void DemoDu_CsFireMedallion_AdvanceTo01(DemoDu* this, GlobalContext* globalCtx) { - s32 pad[2]; - - if ((gSaveContext.chamberCutsceneNum == 1) && (gSaveContext.sceneSetupIndex < 4)) { - Player* player = GET_PLAYER(globalCtx); - - this->updateIndex = CS_FIREMEDALLION_SUBSCENE(1); - globalCtx->csCtx.segment = D_8096C1A4; - gSaveContext.cutsceneTrigger = 2; - Item_Give(globalCtx, ITEM_MEDALLION_FIRE); - - player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - } -} - -void DemoDu_CsFireMedallion_AdvanceTo02(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 1)) { - this->updateIndex = CS_FIREMEDALLION_SUBSCENE(2); - this->drawIndex = 1; - DemoDu_CsFireMedallion_SpawnDoorWarp(this, globalCtx); - } - } -} - -void DemoDu_CsFireMedallion_AdvanceTo03(DemoDu* this) { - if (this->actor.shape.yOffset >= 0.0f) { - this->updateIndex = CS_FIREMEDALLION_SUBSCENE(3); - this->actor.shape.yOffset = 0.0f; - } -} - -void DemoDu_CsFireMedallion_AdvanceTo04(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 2)) { - Animation_Change(&this->skelAnime, &gDaruniaItemGiveAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaItemGiveAnim), 2, 0.0f); - this->updateIndex = CS_FIREMEDALLION_SUBSCENE(4); - } - } -} - -void DemoDu_CsFireMedallion_AdvanceTo05(DemoDu* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gDaruniaItemGiveIdleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaItemGiveIdleAnim), 0, 0.0f); - this->updateIndex = CS_FIREMEDALLION_SUBSCENE(5); - } -} - -void DemoDu_CsFireMedallion_AdvanceTo06(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[6]; - - if ((npcAction != NULL) && (npcAction->action == 2)) { - this->updateIndex = CS_FIREMEDALLION_SUBSCENE(6); - func_80969F38(this, globalCtx); - } - } -} - -void DemoDu_UpdateCs_FM_00(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsFireMedallion_AdvanceTo01(this, globalCtx); -} - -void DemoDu_UpdateCs_FM_01(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsFireMedallion_AdvanceTo02(this, globalCtx); -} - -void DemoDu_UpdateCs_FM_02(DemoDu* this, GlobalContext* globalCtx) { - func_80969FB4(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsFireMedallion_AdvanceTo03(this); -} - -void DemoDu_UpdateCs_FM_03(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsFireMedallion_AdvanceTo04(this, globalCtx); -} - -void DemoDu_UpdateCs_FM_04(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_CsFireMedallion_AdvanceTo05(this, animFinished); -} - -void DemoDu_UpdateCs_FM_05(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsFireMedallion_AdvanceTo06(this, globalCtx); -} - -void DemoDu_UpdateCs_FM_06(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); -} - -void DemoDu_InitCs_GoronsRuby(DemoDu* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDaruniaSkel, NULL, NULL, NULL, 0); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(0); -} - -// Cutscene: Darunia gives Link the Goron's Ruby. -// Sfx played when Darunia lands at the floor at the start of the cutscene. -void DemoDu_CsPlaySfx_GoronLanding(DemoDu* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EN_GOLON_LAND_BIG); -} - -// Cutscene: Darunia gives Link the Goron's Ruby. -// Sfx played when Darunia is falling at the start of the cutscene. -void DemoDu_CsPlaySfx_DaruniaFalling(GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 160) { - func_800788CC(NA_SE_EV_OBJECT_FALL); - } -} - -// Cutscene: Darunia gives Link the Goron's Ruby. -void DemoDu_CsPlaySfx_DaruniaHitsLink(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - - func_80078914(&player->actor.projectedPos, NA_SE_EN_DARUNIA_HIT_LINK); - Audio_PlaySoundGeneral(NA_SE_VO_LI_DAMAGE_S_KID, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); -} - -// Cutscene: Darunia gives Link the Goron's Ruby. -void DemoDu_CsPlaySfx_HitBreast(DemoDu* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EN_DARUNIA_HIT_BREAST - SFX_FLAG); -} - -// Cutscene: Darunia gives Link the Goron's Ruby. -// Sfx played when Link is escaping from the gorons at the end of the scene. -void DemoDu_CsPlaySfx_LinkEscapeFromGorons(GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 1400) { - Player* player = GET_PLAYER(globalCtx); - - Audio_PlaySoundGeneral(NA_SE_VO_LI_FALL_L_KID, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -// Cutscene: Darunia gives Link the Goron's Ruby. -// Sfx played when Link is surprised by Darunia falling from the sky. -void DemoDu_CsPlaySfx_LinkSurprised(GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 174) { - Player* player = GET_PLAYER(globalCtx); - - Audio_PlaySoundGeneral(NA_SE_VO_LI_SURPRISE_KID, &player->actor.projectedPos, 4U, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void DemoDu_CsGoronsRuby_UpdateFaceTextures(DemoDu* this, GlobalContext* globalCtx) { - u16* frames = &globalCtx->csCtx.frames; - - if (*frames < 260) { - DemoDu_UpdateEyes(this); - DemoDu_SetMouthTexIndex(this, 0); - } else if (*frames < 335) { - DemoDu_UpdateEyes(this); - DemoDu_SetMouthTexIndex(this, 3); - } else if (*frames < 365) { - DemoDu_SetEyeTexIndex(this, 3); - DemoDu_SetMouthTexIndex(this, 1); - } else if (*frames < 395) { - DemoDu_SetEyeTexIndex(this, 0); - DemoDu_SetMouthTexIndex(this, 3); - } else if (*frames < 410) { - DemoDu_UpdateEyes(this); - DemoDu_SetMouthTexIndex(this, 0); - } else { - DemoDu_UpdateEyes(this); - DemoDu_SetMouthTexIndex(this, 3); - } -} - -void func_8096A630(DemoDu* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f pos = this->actor.world.pos; - - pos.y += kREG(5); - func_80033480(globalCtx, &pos, kREG(1) + 100.0f, kREG(2) + 10, kREG(3) + 300, kREG(4), 0); - DemoDu_CsPlaySfx_GoronLanding(this); -} - -void DemoDu_CsGoronsRuby_SpawnDustWhenHittingLink(DemoDu* this, GlobalContext* globalCtx) { - static Vec3f dustPosOffsets[] = { - { 11.0f, -11.0f, -6.0f }, { 0.0f, 14.0f, -13.0f }, { 14.0f, -2.0f, -10.0f }, { 10.0f, -6.0f, -8.0f }, - { 8.0f, 6.0f, 8.0f }, { 13.0f, 8.0f, -10.0f }, { -14.0f, 1.0f, -14.0f }, { 5.0f, 12.0f, -9.0f }, - { 11.0f, 6.0f, -7.0f }, { 14.0f, 14.0f, -14.0f }, - }; - - if (Animation_OnFrame(&this->skelAnime, 31.0f) || Animation_OnFrame(&this->skelAnime, 41.0f)) { - s32 pad[2]; - s32 i; - Player* player = GET_PLAYER(globalCtx); - Vec3f* headPos = &player->bodyPartsPos[PLAYER_LIMB_HEAD]; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.3f, 0.0f }; - s32 pad2; - - for (i = 4; i >= 0; --i) { - Color_RGBA8 primColor = { 190, 150, 110, 255 }; - Color_RGBA8 envColor = { 120, 80, 40, 255 }; - s32 colorDelta; - Vec3f position; - - if (Animation_OnFrame(&this->skelAnime, 31.0f)) { - position.x = dustPosOffsets[i + 5].x + headPos->x; - position.y = dustPosOffsets[i + 5].y + headPos->y; - position.z = dustPosOffsets[i + 5].z + headPos->z; - } else { - position.x = dustPosOffsets[i + 0].x + headPos->x; - position.y = dustPosOffsets[i + 0].y + headPos->y; - position.z = dustPosOffsets[i + 0].z + headPos->z; - } - - colorDelta = Rand_ZeroOne() * 20.0f - 10.0f; - - primColor.r += colorDelta; - primColor.g += colorDelta; - primColor.b += colorDelta; - envColor.r += colorDelta; - envColor.g += colorDelta; - envColor.b += colorDelta; - - func_8002829C(globalCtx, &position, &velocity, &accel, &primColor, &envColor, - Rand_ZeroOne() * 40.0f + 200.0f, 0); - } - - DemoDu_CsPlaySfx_DaruniaHitsLink(globalCtx); - } -} - -void DemoDu_CsGoronsRuby_DaruniaFalling(DemoDu* this, GlobalContext* globalCtx) { - s32 pad; - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = csCtx->npcActions[2]; - Vec3f startPos; - Vec3f endPos; - Vec3f* pos = &this->actor.world.pos; - - if (npcAction != NULL) { - f32 traveledPercent = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, csCtx->frames); - - startPos.x = npcAction->startPos.x; - startPos.y = npcAction->startPos.y; - startPos.z = npcAction->startPos.z; - - endPos.x = npcAction->endPos.x; - endPos.y = npcAction->endPos.y; - endPos.z = npcAction->endPos.z; - - pos->x = ((endPos.x - startPos.x) * traveledPercent) + startPos.x; - pos->y = ((endPos.y - startPos.y) * traveledPercent) + startPos.y; - pos->z = ((endPos.z - startPos.z) * traveledPercent) + startPos.z; - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo01(DemoDu* this, GlobalContext* globalCtx) { - this->updateIndex = CS_GORONSRUBY_SUBSCENE(1); -} - -void DemoDu_CsGoronsRuby_AdvanceTo02(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 1)) { - Animation_Change(&this->skelAnime, &gDaruniaStandUpAfterFallingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaStandUpAfterFallingAnim), 2, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(2); - this->drawIndex = 1; - DemoDu_CsGoronsRuby_DaruniaFalling(this, globalCtx); - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo03(DemoDu* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = csCtx->npcActions[2]; - - if ((npcAction != NULL) && (csCtx->frames >= npcAction->endFrame)) { - this->updateIndex = CS_GORONSRUBY_SUBSCENE(3); - func_8096A630(this, globalCtx); - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo04(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 2)) { - this->updateIndex = CS_GORONSRUBY_SUBSCENE(4); - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo05(DemoDu* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(5); - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo06(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 3)) { - Animation_Change(&this->skelAnime, &gDaruniaHitBreastAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaHitBreastAnim), 2, -4.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(6); - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo07(DemoDu* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(7); - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo08(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 4)) { - Animation_Change(&this->skelAnime, &gDaruniaHitLinkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaHitLinkAnim), 2, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(8); - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo09(DemoDu* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gDaruniaHitBreastAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaHitBreastAnim), 2, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(9); - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo10(DemoDu* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(10); - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo11(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 5)) { - Animation_Change(&this->skelAnime, &gDaruniaItemGiveAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaItemGiveAnim), 2, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(11); - } - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo12(DemoDu* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gDaruniaItemGiveIdleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDaruniaItemGiveIdleAnim), 0, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(12); - } -} - -void DemoDu_CsGoronsRuby_AdvanceTo13(DemoDu* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; - - if ((npcAction != NULL) && (npcAction->action != 6)) { - Animation_Change(&this->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->updateIndex = CS_GORONSRUBY_SUBSCENE(13); - } - } -} - -void DemoDu_UpdateCs_GR_00(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsPlaySfx_DaruniaFalling(globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo01(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_01(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsPlaySfx_DaruniaFalling(globalCtx); - DemoDu_CsPlaySfx_LinkSurprised(globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo02(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_02(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsGoronsRuby_DaruniaFalling(this, globalCtx); - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_CsPlaySfx_DaruniaFalling(globalCtx); - DemoDu_CsPlaySfx_LinkSurprised(globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo03(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_03(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_CsPlaySfx_LinkSurprised(globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo04(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_04(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo05(this, animFinished); -} - -void DemoDu_UpdateCs_GR_05(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo06(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_06(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_CsPlaySfx_HitBreast(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo07(this, animFinished); -} - -void DemoDu_UpdateCs_GR_07(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo08(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_08(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_SpawnDustWhenHittingLink(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo09(this, animFinished); -} - -void DemoDu_UpdateCs_GR_09(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_CsPlaySfx_HitBreast(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo10(this, animFinished); -} - -void DemoDu_UpdateCs_GR_10(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo11(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_11(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo12(this, animFinished); -} - -void DemoDu_UpdateCs_GR_12(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsGoronsRuby_AdvanceTo13(this, globalCtx); -} - -void DemoDu_UpdateCs_GR_13(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_CsGoronsRuby_UpdateFaceTextures(this, globalCtx); - DemoDu_CsPlaySfx_LinkEscapeFromGorons(globalCtx); -} - -void DemoDu_InitCs_AfterGanon(DemoDu* this, GlobalContext* globalCtx) { - s32 pad[3]; - f32 lastFrame = Animation_GetLastFrame(&gDaruniaSageFormationAnim); - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDaruniaSkel, NULL, NULL, NULL, 0); - Animation_Change(&this->skelAnime, &gDaruniaSageFormationAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); - this->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(0); - this->actor.shape.shadowAlpha = 0; -} - -void DemoDu_CsPlaySfx_WhiteOut() { - func_800788CC(NA_SE_SY_WHITE_OUT_T); -} - -void DemoDu_CsAfterGanon_SpawnDemo6K(DemoDu* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - kREG(16) + 22.0f + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 3); -} - -void DemoDu_CsAfterGanon_AdvanceTo01(DemoDu* this, GlobalContext* globalCtx) { - if (DemoDu_IsNpcDoingThisAction(this, globalCtx, 4, 2)) { - this->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(1); - this->drawIndex = 2; - this->shadowAlpha = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_1A4 = 0.0f; - DemoDu_CsPlaySfx_WhiteOut(); - } -} - -void DemoDu_CsAfterGanon_AdvanceTo02(DemoDu* this, GlobalContext* globalCtx) { - f32* unk_1A4 = &this->unk_1A4; - s32 shadowAlpha = 255; - - if (DemoDu_IsNpcDoingThisAction(this, globalCtx, 4, 2)) { - *unk_1A4 += 1.0f; - if (*unk_1A4 >= kREG(5) + 10.0f) { - this->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(2); - this->drawIndex = 1; - *unk_1A4 = kREG(5) + 10.0f; - this->shadowAlpha = shadowAlpha; - this->actor.shape.shadowAlpha = shadowAlpha; - return; - } - } else { - *unk_1A4 -= 1.0f; - if (*unk_1A4 <= 0.0f) { - this->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(0); - this->drawIndex = 0; - *unk_1A4 = 0.0f; - this->shadowAlpha = 0; - this->actor.shape.shadowAlpha = 0; - return; - } - } - shadowAlpha = (*unk_1A4 / (kREG(5) + 10.0f)) * 255.0f; - this->shadowAlpha = shadowAlpha; - this->actor.shape.shadowAlpha = shadowAlpha; -} - -void DemoDu_CsAfterGanon_BackTo01(DemoDu* this, GlobalContext* globalCtx) { - if (DemoDu_IsNpcNotDoingThisAction(this, globalCtx, 4, 2)) { - this->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(1); - this->drawIndex = 2; - this->unk_1A4 = kREG(5) + 10.0f; - this->shadowAlpha = 255; - if (!this->demo6KSpawned) { - DemoDu_CsAfterGanon_SpawnDemo6K(this, globalCtx); - this->demo6KSpawned = 1; - } - this->actor.shape.shadowAlpha = 255; - } -} - -void DemoDu_UpdateCs_AG_00(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsAfterGanon_AdvanceTo01(this, globalCtx); - DemoDu_CsAfterGanon_CheckIfShouldReset(this, globalCtx); -} - -void DemoDu_UpdateCs_AG_01(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_UpdateEyes(this); - DemoDu_CsAfterGanon_AdvanceTo02(this, globalCtx); - DemoDu_CsAfterGanon_CheckIfShouldReset(this, globalCtx); -} - -void DemoDu_UpdateCs_AG_02(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_UpdateEyes(this); - DemoDu_CsAfterGanon_BackTo01(this, globalCtx); - DemoDu_CsAfterGanon_CheckIfShouldReset(this, globalCtx); -} - -// Similar to DemoDu_Draw_01, but this uses POLY_XLU_DISP. Also uses this->shadowAlpha for setting the env color. -void DemoDu_Draw_02(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - DemoDu* this = (DemoDu*)thisx; - s16 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = sEyeTextures[eyeTexIndex]; - s32 pad; - s16 mouthTexIndex = this->mouthTexIndex; - void* mouthTexture = sMouthTextures[mouthTexIndex]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_du_inKenjyanomaDemo02.c", 275); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTexture)); - gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gDaruniaNoseSeriousTex)); - - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->shadowAlpha); - - gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, - 0, 0, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_du_inKenjyanomaDemo02.c", 304); -} - -void DemoDu_InitCs_Credits(DemoDu* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDaruniaSkel, &gDaruniaCreditsIdleAnim, NULL, NULL, 0); - this->updateIndex = CS_CREDITS_SUBSCENE(0); - this->drawIndex = 0; - this->actor.shape.shadowAlpha = 0; - DemoDu_SetMouthTexIndex(this, 3); -} - -void DemoDu_CsCredits_UpdateShadowAlpha(DemoDu* this) { - s32 shadowAlpha = 255; - f32 temp_f0; - f32* unk_1A4; - - this->unk_1A4 += 1.0f; - temp_f0 = kREG(17) + 10.0f; - unk_1A4 = &this->unk_1A4; - - if (temp_f0 <= *unk_1A4) { - this->shadowAlpha = shadowAlpha; - this->actor.shape.shadowAlpha = shadowAlpha; - } else { - shadowAlpha = *unk_1A4 / temp_f0 * 255.0f; - this->shadowAlpha = shadowAlpha; - this->actor.shape.shadowAlpha = shadowAlpha; - } -} - -void DemoDu_CsCredits_AdvanceTo01(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_MoveToNpcPos(this, globalCtx, 2); - this->updateIndex = CS_CREDITS_SUBSCENE(1); - this->drawIndex = 2; -} - -void DemoDu_CsCredits_AdvanceTo02(DemoDu* this) { - if (this->unk_1A4 >= kREG(17) + 10.0f) { - this->updateIndex = CS_CREDITS_SUBSCENE(2); - this->drawIndex = 1; - } -} - -void DemoDu_CsCredits_AdvanceTo03(DemoDu* this) { - func_80969DDC(this, &gDaruniaLookingUpToSariaAnim, ANIMMODE_ONCE, -8.0f, 0); - this->updateIndex = CS_CREDITS_SUBSCENE(3); -} - -void DemoDu_CsCredits_AdvanceTo04(DemoDu* this) { - func_80969DDC(this, &gDaruniaCreditsHitBreastAnim, ANIMMODE_ONCE, 0.0f, 0); - this->updateIndex = CS_CREDITS_SUBSCENE(4); -} - -void DemoDu_CsCredits_BackTo02(DemoDu* this, s32 animFinished) { - if (animFinished) { - func_80969DDC(this, &gDaruniaCreditsIdleAnim, ANIMMODE_LOOP, 0.0f, 0); - this->updateIndex = CS_CREDITS_SUBSCENE(2); - } -} - -void DemoDu_CsCredits_HandleSubscenesByNpcAction(DemoDu* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, 2); - - if (npcAction != NULL) { - s32 action = npcAction->action; - s32 lastAction = this->lastAction; - - if (action != lastAction) { - switch (action) { - case 9: - DemoDu_CsCredits_AdvanceTo01(this, globalCtx); - break; - case 10: - DemoDu_CsCredits_AdvanceTo03(this); - break; - case 11: - DemoDu_CsCredits_AdvanceTo04(this); - break; - default: - // "Demo_Du_inEnding_Check_DemoMode:There is no such operation!!!!!!!!" - osSyncPrintf("Demo_Du_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - this->lastAction = action; - } - } -} - -void DemoDu_UpdateCs_CR_00(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_CsCredits_HandleSubscenesByNpcAction(this, globalCtx); -} - -void DemoDu_UpdateCs_CR_01(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_UpdateEyes(this); - DemoDu_CsCredits_UpdateShadowAlpha(this); - DemoDu_CsCredits_AdvanceTo02(this); -} - -void DemoDu_UpdateCs_CR_02(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_UpdateEyes(this); - DemoDu_CsCredits_HandleSubscenesByNpcAction(this, globalCtx); -} - -void DemoDu_UpdateCs_CR_03(DemoDu* this, GlobalContext* globalCtx) { - DemoDu_UpdateBgCheckInfo(this, globalCtx); - DemoDu_UpdateSkelAnime(this); - DemoDu_UpdateEyes(this); - DemoDu_CsCredits_HandleSubscenesByNpcAction(this, globalCtx); -} - -void DemoDu_UpdateCs_CR_04(DemoDu* this, GlobalContext* globalCtx) { - s32 animFinished; - - DemoDu_UpdateBgCheckInfo(this, globalCtx); - animFinished = DemoDu_UpdateSkelAnime(this); - DemoDu_UpdateEyes(this); - DemoDu_CsCredits_BackTo02(this, animFinished); -} - -static DemoDuActionFunc sUpdateFuncs[] = { - DemoDu_UpdateCs_FM_00, DemoDu_UpdateCs_FM_01, DemoDu_UpdateCs_FM_02, DemoDu_UpdateCs_FM_03, DemoDu_UpdateCs_FM_04, - DemoDu_UpdateCs_FM_05, DemoDu_UpdateCs_FM_06, DemoDu_UpdateCs_GR_00, DemoDu_UpdateCs_GR_01, DemoDu_UpdateCs_GR_02, - DemoDu_UpdateCs_GR_03, DemoDu_UpdateCs_GR_04, DemoDu_UpdateCs_GR_05, DemoDu_UpdateCs_GR_06, DemoDu_UpdateCs_GR_07, - DemoDu_UpdateCs_GR_08, DemoDu_UpdateCs_GR_09, DemoDu_UpdateCs_GR_10, DemoDu_UpdateCs_GR_11, DemoDu_UpdateCs_GR_12, - DemoDu_UpdateCs_GR_13, DemoDu_UpdateCs_AG_00, DemoDu_UpdateCs_AG_01, DemoDu_UpdateCs_AG_02, DemoDu_UpdateCs_CR_00, - DemoDu_UpdateCs_CR_01, DemoDu_UpdateCs_CR_02, DemoDu_UpdateCs_CR_03, DemoDu_UpdateCs_CR_04, -}; - -void DemoDu_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoDu* this = (DemoDu*)thisx; - - if (this->updateIndex < 0 || this->updateIndex >= 29 || sUpdateFuncs[this->updateIndex] == NULL) { - // "The main mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sUpdateFuncs[this->updateIndex](this, globalCtx); -} - -void DemoDu_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoDu* this = (DemoDu*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - switch (this->actor.params) { - case DEMO_DU_CS_GORONS_RUBY: - DemoDu_InitCs_GoronsRuby(this, globalCtx); - break; - - case DEMO_DU_CS_CHAMBER_AFTER_GANON: - DemoDu_InitCs_AfterGanon(this, globalCtx); - break; - - case DEMO_DU_CS_CREDITS: - DemoDu_InitCs_Credits(this, globalCtx); - break; - - default: - DemoDu_InitCs_FireMedallion(this, globalCtx); - break; - } -} - -void DemoDu_Draw_NoDraw(Actor* thisx, GlobalContext* globalCtx2) { -} - -// Similar to DemoDu_Draw_02, but this uses POLY_OPA_DISP. Sets the env color to 255. -void DemoDu_Draw_01(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - DemoDu* this = (DemoDu*)thisx; - s16 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = sEyeTextures[eyeTexIndex]; - s32 pad; - s16 mouthTexIndex = this->mouthTexIndex; - void* mouthTexture = sMouthTextures[mouthTexIndex]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_du.c", 615); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTexture)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gDaruniaNoseSeriousTex)); - - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, - this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_du.c", 638); -} - -static DemoDuDrawFunc sDrawFuncs[] = { - DemoDu_Draw_NoDraw, - DemoDu_Draw_01, - DemoDu_Draw_02, -}; - -void DemoDu_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoDu* this = (DemoDu*)thisx; - - if (this->drawIndex < 0 || this->drawIndex >= 3 || sDrawFuncs[this->drawIndex] == NULL) { - // "The drawing mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawIndex](thisx, globalCtx); -} - -const ActorInit Demo_Du_InitVars = { - ACTOR_DEMO_DU, - ACTORCAT_NPC, - FLAGS, - OBJECT_DU, - sizeof(DemoDu), - (ActorFunc)DemoDu_Init, - (ActorFunc)DemoDu_Destroy, - (ActorFunc)DemoDu_Update, - (ActorFunc)DemoDu_Draw, -}; diff --git a/src/overlays/actors/ovl_Demo_Du/z_demo_du.cpp b/src/overlays/actors/ovl_Demo_Du/z_demo_du.cpp new file mode 100644 index 000000000..19260359e --- /dev/null +++ b/src/overlays/actors/ovl_Demo_Du/z_demo_du.cpp @@ -0,0 +1,1059 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_DU_Z_DEMO_DU_C +#include "actor_common.h" +#include "z_demo_du.h" +#include "objects/object_du/object_du.h" +#include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "vt.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef void (*DemoDuActionFunc)(DemoDu*, GlobalContext*); +typedef void (*DemoDuDrawFunc)(Actor*, GlobalContext*); + +void DemoDu_Init(Actor* thisx, GlobalContext* globalCtx); +void DemoDu_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DemoDu_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoDu_Draw(Actor* thisx, GlobalContext* globalCtx); + +static s32 sUnused = 0; + +#include "z_demo_du_cutscene_data.cpp" EARLY +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +static void* sEyeTextures[] = { gDaruniaEyeOpenTex, gDaruniaEyeOpeningTex, gDaruniaEyeShutTex, gDaruniaEyeClosingTex }; +static void* sMouthTextures[] = { gDaruniaMouthSeriousTex, gDaruniaMouthGrinningTex, gDaruniaMouthOpenTex, + gDaruniaMouthHappyTex }; + +/** + * Cs => Cutscene + * + * FM => Fire Medallion + * GR => Goron's Ruby + * AG => In the chamber of sages, just After the final blow on Ganon. + * CR => Credits + * + */ + +// Each macro maps its argument to an index of sUpdateFuncs. +#define CS_FIREMEDALLION_SUBSCENE(x) (0 + (x)) // DEMO_DU_CS_FIREMEDALLION +#define CS_GORONSRUBY_SUBSCENE(x) (7 + (x)) // DEMO_DU_CS_GORONS_RUBY +#define CS_CHAMBERAFTERGANON_SUBSCENE(x) (21 + (x)) // DEMO_DU_CS_CHAMBER_AFTER_GANON +#define CS_CREDITS_SUBSCENE(x) (24 + (x)) // DEMO_DU_CS_CREDITS + +void DemoDu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoDu* pthis = (DemoDu*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); +} + +void DemoDu_UpdateEyes(DemoDu* pthis) { + s16* blinkTimer = &pthis->blinkTimer; + s16* eyeTexIndex = &pthis->eyeTexIndex; + s32 pad[3]; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + + *eyeTexIndex = *blinkTimer; + if (*eyeTexIndex >= 3) { + *eyeTexIndex = 0; + } +} + +void DemoDu_SetEyeTexIndex(DemoDu* pthis, s16 eyeTexIndex) { + pthis->eyeTexIndex = eyeTexIndex; +} + +void DemoDu_SetMouthTexIndex(DemoDu* pthis, s16 mouthTexIndex) { + pthis->mouthTexIndex = mouthTexIndex; +} + +// Resets all the values used in pthis cutscene. +void DemoDu_CsAfterGanon_Reset(DemoDu* pthis) { + pthis->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(0); + pthis->drawIndex = 0; + pthis->shadowAlpha = 0; + pthis->demo6KSpawned = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_1A4 = 0.0f; +} + +void DemoDu_CsAfterGanon_CheckIfShouldReset(DemoDu* pthis, GlobalContext* globalCtx) { + static s32 D_8096CE94 = false; + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + if (D_8096CE94) { + if (pthis->actor.params == DEMO_DU_CS_CHAMBER_AFTER_GANON) { + DemoDu_CsAfterGanon_Reset(pthis); + } + D_8096CE94 = false; + return; + } + } else if (!D_8096CE94) { + D_8096CE94 = true; + } +} + +s32 DemoDu_UpdateSkelAnime(DemoDu* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +void DemoDu_UpdateBgCheckInfo(DemoDu* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +CsCmdActorAction* DemoDu_GetNpcAction(GlobalContext* globalCtx, s32 idx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[idx]; + } + return NULL; +} + +s32 DemoDu_IsNpcDoingThisAction(DemoDu* pthis, GlobalContext* globalCtx, u16 action, s32 idx) { + CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, idx); + + if ((npcAction != NULL) && (npcAction->action == action)) { + return true; + } + return false; +} + +s32 DemoDu_IsNpcNotDoingThisAction(DemoDu* pthis, GlobalContext* globalCtx, u16 action, s32 idx) { + CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, idx); + + if ((npcAction != NULL) && (npcAction->action != action)) { + return true; + } + return false; +} + +void DemoDu_MoveToNpcPos(DemoDu* pthis, GlobalContext* globalCtx, s32 idx) { + CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, idx); + s32 pad; + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +void func_80969DDC(DemoDu* pthis, AnimationHeader* animation, u8 mode, f32 morphFrames, s32 arg4) { + f32 startFrame; + s16 lastFrame = Animation_GetLastFrame(animation); + f32 endFrame; + f32 playSpeed; + + if (arg4 == 0) { + startFrame = 0.0f; + endFrame = lastFrame; + playSpeed = 1.0f; + } else { + endFrame = 0.0f; + playSpeed = -1.0f; + startFrame = lastFrame; + } + Animation_Change(&pthis->skelAnime, animation, playSpeed, startFrame, endFrame, mode, morphFrames); +} + +void DemoDu_InitCs_FireMedallion(DemoDu* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDaruniaSkel, &gDaruniaIdleAnim, NULL, NULL, 0); + pthis->actor.shape.yOffset = -10000.0f; + DemoDu_SetEyeTexIndex(pthis, 1); + DemoDu_SetMouthTexIndex(pthis, 3); +} + +// A.k.a Warp portal +void DemoDu_CsFireMedallion_SpawnDoorWarp(DemoDu* pthis, GlobalContext* globalCtx) { + f32 posX = pthis->actor.world.pos.x; + f32 posY = pthis->actor.world.pos.y; + f32 posZ = pthis->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, + WARP_SAGES); +} + +// Gives the Fire Medallion to Link. +void func_80969F38(DemoDu* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 posX = player->actor.world.pos.x; + f32 posY = player->actor.world.pos.y + 80.0f; + f32 posZ = player->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, + DEMO_EFFECT_MEDAL_FIRE); + Item_Give(globalCtx, ITEM_MEDALLION_FIRE); +} + +void func_80969FB4(DemoDu* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.yOffset += 250.0f / 3.0f; +} + +// Gives the Fire Medallion to Link too. +void DemoDu_CsFireMedallion_AdvanceTo01(DemoDu* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + + if ((gSaveContext.chamberCutsceneNum == 1) && (gSaveContext.sceneSetupIndex < 4)) { + Player* player = GET_PLAYER(globalCtx); + + pthis->updateIndex = CS_FIREMEDALLION_SUBSCENE(1); + globalCtx->csCtx.segment = D_8096C1A4; + gSaveContext.cutsceneTrigger = 2; + Item_Give(globalCtx, ITEM_MEDALLION_FIRE); + + player->actor.world.rot.y = player->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + } +} + +void DemoDu_CsFireMedallion_AdvanceTo02(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 1)) { + pthis->updateIndex = CS_FIREMEDALLION_SUBSCENE(2); + pthis->drawIndex = 1; + DemoDu_CsFireMedallion_SpawnDoorWarp(pthis, globalCtx); + } + } +} + +void DemoDu_CsFireMedallion_AdvanceTo03(DemoDu* pthis) { + if (pthis->actor.shape.yOffset >= 0.0f) { + pthis->updateIndex = CS_FIREMEDALLION_SUBSCENE(3); + pthis->actor.shape.yOffset = 0.0f; + } +} + +void DemoDu_CsFireMedallion_AdvanceTo04(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 2)) { + Animation_Change(&pthis->skelAnime, &gDaruniaItemGiveAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaItemGiveAnim), 2, 0.0f); + pthis->updateIndex = CS_FIREMEDALLION_SUBSCENE(4); + } + } +} + +void DemoDu_CsFireMedallion_AdvanceTo05(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gDaruniaItemGiveIdleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaItemGiveIdleAnim), 0, 0.0f); + pthis->updateIndex = CS_FIREMEDALLION_SUBSCENE(5); + } +} + +void DemoDu_CsFireMedallion_AdvanceTo06(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[6]; + + if ((npcAction != NULL) && (npcAction->action == 2)) { + pthis->updateIndex = CS_FIREMEDALLION_SUBSCENE(6); + func_80969F38(pthis, globalCtx); + } + } +} + +void DemoDu_UpdateCs_FM_00(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsFireMedallion_AdvanceTo01(pthis, globalCtx); +} + +void DemoDu_UpdateCs_FM_01(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsFireMedallion_AdvanceTo02(pthis, globalCtx); +} + +void DemoDu_UpdateCs_FM_02(DemoDu* pthis, GlobalContext* globalCtx) { + func_80969FB4(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsFireMedallion_AdvanceTo03(pthis); +} + +void DemoDu_UpdateCs_FM_03(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsFireMedallion_AdvanceTo04(pthis, globalCtx); +} + +void DemoDu_UpdateCs_FM_04(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsFireMedallion_AdvanceTo05(pthis, animFinished); +} + +void DemoDu_UpdateCs_FM_05(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsFireMedallion_AdvanceTo06(pthis, globalCtx); +} + +void DemoDu_UpdateCs_FM_06(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); +} + +void DemoDu_InitCs_GoronsRuby(DemoDu* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDaruniaSkel, NULL, NULL, NULL, 0); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(0); +} + +// Cutscene: Darunia gives Link the Goron's Ruby. +// Sfx played when Darunia lands at the floor at the start of the cutscene. +void DemoDu_CsPlaySfx_GoronLanding(DemoDu* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_GOLON_LAND_BIG); +} + +// Cutscene: Darunia gives Link the Goron's Ruby. +// Sfx played when Darunia is falling at the start of the cutscene. +void DemoDu_CsPlaySfx_DaruniaFalling(GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 160) { + func_800788CC(NA_SE_EV_OBJECT_FALL); + } +} + +// Cutscene: Darunia gives Link the Goron's Ruby. +void DemoDu_CsPlaySfx_DaruniaHitsLink(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + func_80078914(&player->actor.projectedPos, NA_SE_EN_DARUNIA_HIT_LINK); + Audio_PlaySoundGeneral(NA_SE_VO_LI_DAMAGE_S_KID, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); +} + +// Cutscene: Darunia gives Link the Goron's Ruby. +void DemoDu_CsPlaySfx_HitBreast(DemoDu* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_DARUNIA_HIT_BREAST - SFX_FLAG); +} + +// Cutscene: Darunia gives Link the Goron's Ruby. +// Sfx played when Link is escaping from the gorons at the end of the scene. +void DemoDu_CsPlaySfx_LinkEscapeFromGorons(GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 1400) { + Player* player = GET_PLAYER(globalCtx); + + Audio_PlaySoundGeneral(NA_SE_VO_LI_FALL_L_KID, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +// Cutscene: Darunia gives Link the Goron's Ruby. +// Sfx played when Link is surprised by Darunia falling from the sky. +void DemoDu_CsPlaySfx_LinkSurprised(GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 174) { + Player* player = GET_PLAYER(globalCtx); + + Audio_PlaySoundGeneral(NA_SE_VO_LI_SURPRISE_KID, &player->actor.projectedPos, 4U, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void DemoDu_CsGoronsRuby_UpdateFaceTextures(DemoDu* pthis, GlobalContext* globalCtx) { + u16* frames = &globalCtx->csCtx.frames; + + if (*frames < 260) { + DemoDu_UpdateEyes(pthis); + DemoDu_SetMouthTexIndex(pthis, 0); + } else if (*frames < 335) { + DemoDu_UpdateEyes(pthis); + DemoDu_SetMouthTexIndex(pthis, 3); + } else if (*frames < 365) { + DemoDu_SetEyeTexIndex(pthis, 3); + DemoDu_SetMouthTexIndex(pthis, 1); + } else if (*frames < 395) { + DemoDu_SetEyeTexIndex(pthis, 0); + DemoDu_SetMouthTexIndex(pthis, 3); + } else if (*frames < 410) { + DemoDu_UpdateEyes(pthis); + DemoDu_SetMouthTexIndex(pthis, 0); + } else { + DemoDu_UpdateEyes(pthis); + DemoDu_SetMouthTexIndex(pthis, 3); + } +} + +void func_8096A630(DemoDu* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos = pthis->actor.world.pos; + + pos.y += kREG(5); + func_80033480(globalCtx, &pos, kREG(1) + 100.0f, kREG(2) + 10, kREG(3) + 300, kREG(4), 0); + DemoDu_CsPlaySfx_GoronLanding(pthis); +} + +void DemoDu_CsGoronsRuby_SpawnDustWhenHittingLink(DemoDu* pthis, GlobalContext* globalCtx) { + static Vec3f dustPosOffsets[] = { + { 11.0f, -11.0f, -6.0f }, { 0.0f, 14.0f, -13.0f }, { 14.0f, -2.0f, -10.0f }, { 10.0f, -6.0f, -8.0f }, + { 8.0f, 6.0f, 8.0f }, { 13.0f, 8.0f, -10.0f }, { -14.0f, 1.0f, -14.0f }, { 5.0f, 12.0f, -9.0f }, + { 11.0f, 6.0f, -7.0f }, { 14.0f, 14.0f, -14.0f }, + }; + + if (Animation_OnFrame(&pthis->skelAnime, 31.0f) || Animation_OnFrame(&pthis->skelAnime, 41.0f)) { + s32 pad[2]; + s32 i; + Player* player = GET_PLAYER(globalCtx); + Vec3f* headPos = &player->bodyPartsPos[PLAYER_LIMB_HEAD]; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + s32 pad2; + + for (i = 4; i >= 0; --i) { + Color_RGBA8 primColor = { 190, 150, 110, 255 }; + Color_RGBA8 envColor = { 120, 80, 40, 255 }; + s32 colorDelta; + Vec3f position; + + if (Animation_OnFrame(&pthis->skelAnime, 31.0f)) { + position.x = dustPosOffsets[i + 5].x + headPos->x; + position.y = dustPosOffsets[i + 5].y + headPos->y; + position.z = dustPosOffsets[i + 5].z + headPos->z; + } else { + position.x = dustPosOffsets[i + 0].x + headPos->x; + position.y = dustPosOffsets[i + 0].y + headPos->y; + position.z = dustPosOffsets[i + 0].z + headPos->z; + } + + colorDelta = Rand_ZeroOne() * 20.0f - 10.0f; + + primColor.r += colorDelta; + primColor.g += colorDelta; + primColor.b += colorDelta; + envColor.r += colorDelta; + envColor.g += colorDelta; + envColor.b += colorDelta; + + func_8002829C(globalCtx, &position, &velocity, &accel, &primColor, &envColor, + Rand_ZeroOne() * 40.0f + 200.0f, 0); + } + + DemoDu_CsPlaySfx_DaruniaHitsLink(globalCtx); + } +} + +void DemoDu_CsGoronsRuby_DaruniaFalling(DemoDu* pthis, GlobalContext* globalCtx) { + s32 pad; + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = csCtx->npcActions[2]; + Vec3f startPos; + Vec3f endPos; + Vec3f* pos = &pthis->actor.world.pos; + + if (npcAction != NULL) { + f32 traveledPercent = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, csCtx->frames); + + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; + + endPos.x = npcAction->endPos.x; + endPos.y = npcAction->endPos.y; + endPos.z = npcAction->endPos.z; + + pos->x = ((endPos.x - startPos.x) * traveledPercent) + startPos.x; + pos->y = ((endPos.y - startPos.y) * traveledPercent) + startPos.y; + pos->z = ((endPos.z - startPos.z) * traveledPercent) + startPos.z; + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo01(DemoDu* pthis, GlobalContext* globalCtx) { + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(1); +} + +void DemoDu_CsGoronsRuby_AdvanceTo02(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 1)) { + Animation_Change(&pthis->skelAnime, &gDaruniaStandUpAfterFallingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaStandUpAfterFallingAnim), 2, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(2); + pthis->drawIndex = 1; + DemoDu_CsGoronsRuby_DaruniaFalling(pthis, globalCtx); + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo03(DemoDu* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = csCtx->npcActions[2]; + + if ((npcAction != NULL) && (csCtx->frames >= npcAction->endFrame)) { + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(3); + func_8096A630(pthis, globalCtx); + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo04(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 2)) { + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(4); + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo05(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(5); + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo06(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 3)) { + Animation_Change(&pthis->skelAnime, &gDaruniaHitBreastAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaHitBreastAnim), 2, -4.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(6); + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo07(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(7); + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo08(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 4)) { + Animation_Change(&pthis->skelAnime, &gDaruniaHitLinkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaHitLinkAnim), 2, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(8); + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo09(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gDaruniaHitBreastAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaHitBreastAnim), 2, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(9); + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo10(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(10); + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo11(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 5)) { + Animation_Change(&pthis->skelAnime, &gDaruniaItemGiveAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaItemGiveAnim), 2, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(11); + } + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo12(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gDaruniaItemGiveIdleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDaruniaItemGiveIdleAnim), 0, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(12); + } +} + +void DemoDu_CsGoronsRuby_AdvanceTo13(DemoDu* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[2]; + + if ((npcAction != NULL) && (npcAction->action != 6)) { + Animation_Change(&pthis->skelAnime, &gDaruniaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDaruniaIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->updateIndex = CS_GORONSRUBY_SUBSCENE(13); + } + } +} + +void DemoDu_UpdateCs_GR_00(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsPlaySfx_DaruniaFalling(globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo01(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_01(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsPlaySfx_DaruniaFalling(globalCtx); + DemoDu_CsPlaySfx_LinkSurprised(globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo02(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_02(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsGoronsRuby_DaruniaFalling(pthis, globalCtx); + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_CsPlaySfx_DaruniaFalling(globalCtx); + DemoDu_CsPlaySfx_LinkSurprised(globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo03(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_03(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_CsPlaySfx_LinkSurprised(globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo04(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_04(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo05(pthis, animFinished); +} + +void DemoDu_UpdateCs_GR_05(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo06(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_06(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsPlaySfx_HitBreast(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo07(pthis, animFinished); +} + +void DemoDu_UpdateCs_GR_07(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo08(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_08(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_SpawnDustWhenHittingLink(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo09(pthis, animFinished); +} + +void DemoDu_UpdateCs_GR_09(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsPlaySfx_HitBreast(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo10(pthis, animFinished); +} + +void DemoDu_UpdateCs_GR_10(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo11(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_11(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo12(pthis, animFinished); +} + +void DemoDu_UpdateCs_GR_12(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsGoronsRuby_AdvanceTo13(pthis, globalCtx); +} + +void DemoDu_UpdateCs_GR_13(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_CsGoronsRuby_UpdateFaceTextures(pthis, globalCtx); + DemoDu_CsPlaySfx_LinkEscapeFromGorons(globalCtx); +} + +void DemoDu_InitCs_AfterGanon(DemoDu* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + f32 lastFrame = Animation_GetLastFrame(&gDaruniaSageFormationAnim); + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDaruniaSkel, NULL, NULL, NULL, 0); + Animation_Change(&pthis->skelAnime, &gDaruniaSageFormationAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + pthis->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(0); + pthis->actor.shape.shadowAlpha = 0; +} + +void DemoDu_CsPlaySfx_WhiteOut() { + func_800788CC(NA_SE_SY_WHITE_OUT_T); +} + +void DemoDu_CsAfterGanon_SpawnDemo6K(DemoDu* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + kREG(16) + 22.0f + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 3); +} + +void DemoDu_CsAfterGanon_AdvanceTo01(DemoDu* pthis, GlobalContext* globalCtx) { + if (DemoDu_IsNpcDoingThisAction(pthis, globalCtx, 4, 2)) { + pthis->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(1); + pthis->drawIndex = 2; + pthis->shadowAlpha = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_1A4 = 0.0f; + DemoDu_CsPlaySfx_WhiteOut(); + } +} + +void DemoDu_CsAfterGanon_AdvanceTo02(DemoDu* pthis, GlobalContext* globalCtx) { + f32* unk_1A4 = &pthis->unk_1A4; + s32 shadowAlpha = 255; + + if (DemoDu_IsNpcDoingThisAction(pthis, globalCtx, 4, 2)) { + *unk_1A4 += 1.0f; + if (*unk_1A4 >= kREG(5) + 10.0f) { + pthis->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(2); + pthis->drawIndex = 1; + *unk_1A4 = kREG(5) + 10.0f; + pthis->shadowAlpha = shadowAlpha; + pthis->actor.shape.shadowAlpha = shadowAlpha; + return; + } + } else { + *unk_1A4 -= 1.0f; + if (*unk_1A4 <= 0.0f) { + pthis->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(0); + pthis->drawIndex = 0; + *unk_1A4 = 0.0f; + pthis->shadowAlpha = 0; + pthis->actor.shape.shadowAlpha = 0; + return; + } + } + shadowAlpha = (*unk_1A4 / (kREG(5) + 10.0f)) * 255.0f; + pthis->shadowAlpha = shadowAlpha; + pthis->actor.shape.shadowAlpha = shadowAlpha; +} + +void DemoDu_CsAfterGanon_BackTo01(DemoDu* pthis, GlobalContext* globalCtx) { + if (DemoDu_IsNpcNotDoingThisAction(pthis, globalCtx, 4, 2)) { + pthis->updateIndex = CS_CHAMBERAFTERGANON_SUBSCENE(1); + pthis->drawIndex = 2; + pthis->unk_1A4 = kREG(5) + 10.0f; + pthis->shadowAlpha = 255; + if (!pthis->demo6KSpawned) { + DemoDu_CsAfterGanon_SpawnDemo6K(pthis, globalCtx); + pthis->demo6KSpawned = 1; + } + pthis->actor.shape.shadowAlpha = 255; + } +} + +void DemoDu_UpdateCs_AG_00(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsAfterGanon_AdvanceTo01(pthis, globalCtx); + DemoDu_CsAfterGanon_CheckIfShouldReset(pthis, globalCtx); +} + +void DemoDu_UpdateCs_AG_01(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_UpdateEyes(pthis); + DemoDu_CsAfterGanon_AdvanceTo02(pthis, globalCtx); + DemoDu_CsAfterGanon_CheckIfShouldReset(pthis, globalCtx); +} + +void DemoDu_UpdateCs_AG_02(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_UpdateEyes(pthis); + DemoDu_CsAfterGanon_BackTo01(pthis, globalCtx); + DemoDu_CsAfterGanon_CheckIfShouldReset(pthis, globalCtx); +} + +// Similar to DemoDu_Draw_01, but pthis uses POLY_XLU_DISP. Also uses pthis->shadowAlpha for setting the env color. +void DemoDu_Draw_02(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DemoDu* pthis = (DemoDu*)thisx; + s16 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = sEyeTextures[eyeTexIndex]; + s32 pad; + s16 mouthTexIndex = pthis->mouthTexIndex; + void* mouthTexture = sMouthTextures[mouthTexIndex]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_du_inKenjyanomaDemo02.c", 275); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTexture)); + gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gDaruniaNoseSeriousTex)); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->shadowAlpha); + + gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, + 0, 0, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_du_inKenjyanomaDemo02.c", 304); +} + +void DemoDu_InitCs_Credits(DemoDu* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDaruniaSkel, &gDaruniaCreditsIdleAnim, NULL, NULL, 0); + pthis->updateIndex = CS_CREDITS_SUBSCENE(0); + pthis->drawIndex = 0; + pthis->actor.shape.shadowAlpha = 0; + DemoDu_SetMouthTexIndex(pthis, 3); +} + +void DemoDu_CsCredits_UpdateShadowAlpha(DemoDu* pthis) { + s32 shadowAlpha = 255; + f32 temp_f0; + f32* unk_1A4; + + pthis->unk_1A4 += 1.0f; + temp_f0 = kREG(17) + 10.0f; + unk_1A4 = &pthis->unk_1A4; + + if (temp_f0 <= *unk_1A4) { + pthis->shadowAlpha = shadowAlpha; + pthis->actor.shape.shadowAlpha = shadowAlpha; + } else { + shadowAlpha = *unk_1A4 / temp_f0 * 255.0f; + pthis->shadowAlpha = shadowAlpha; + pthis->actor.shape.shadowAlpha = shadowAlpha; + } +} + +void DemoDu_CsCredits_AdvanceTo01(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_MoveToNpcPos(pthis, globalCtx, 2); + pthis->updateIndex = CS_CREDITS_SUBSCENE(1); + pthis->drawIndex = 2; +} + +void DemoDu_CsCredits_AdvanceTo02(DemoDu* pthis) { + if (pthis->unk_1A4 >= kREG(17) + 10.0f) { + pthis->updateIndex = CS_CREDITS_SUBSCENE(2); + pthis->drawIndex = 1; + } +} + +void DemoDu_CsCredits_AdvanceTo03(DemoDu* pthis) { + func_80969DDC(pthis, &gDaruniaLookingUpToSariaAnim, ANIMMODE_ONCE, -8.0f, 0); + pthis->updateIndex = CS_CREDITS_SUBSCENE(3); +} + +void DemoDu_CsCredits_AdvanceTo04(DemoDu* pthis) { + func_80969DDC(pthis, &gDaruniaCreditsHitBreastAnim, ANIMMODE_ONCE, 0.0f, 0); + pthis->updateIndex = CS_CREDITS_SUBSCENE(4); +} + +void DemoDu_CsCredits_BackTo02(DemoDu* pthis, s32 animFinished) { + if (animFinished) { + func_80969DDC(pthis, &gDaruniaCreditsIdleAnim, ANIMMODE_LOOP, 0.0f, 0); + pthis->updateIndex = CS_CREDITS_SUBSCENE(2); + } +} + +void DemoDu_CsCredits_HandleSubscenesByNpcAction(DemoDu* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = DemoDu_GetNpcAction(globalCtx, 2); + + if (npcAction != NULL) { + s32 action = npcAction->action; + s32 lastAction = pthis->lastAction; + + if (action != lastAction) { + switch (action) { + case 9: + DemoDu_CsCredits_AdvanceTo01(pthis, globalCtx); + break; + case 10: + DemoDu_CsCredits_AdvanceTo03(pthis); + break; + case 11: + DemoDu_CsCredits_AdvanceTo04(pthis); + break; + default: + // "Demo_Du_inEnding_Check_DemoMode:There is no such operation!!!!!!!!" + osSyncPrintf("Demo_Du_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + pthis->lastAction = action; + } + } +} + +void DemoDu_UpdateCs_CR_00(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_CsCredits_HandleSubscenesByNpcAction(pthis, globalCtx); +} + +void DemoDu_UpdateCs_CR_01(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_UpdateEyes(pthis); + DemoDu_CsCredits_UpdateShadowAlpha(pthis); + DemoDu_CsCredits_AdvanceTo02(pthis); +} + +void DemoDu_UpdateCs_CR_02(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_UpdateEyes(pthis); + DemoDu_CsCredits_HandleSubscenesByNpcAction(pthis, globalCtx); +} + +void DemoDu_UpdateCs_CR_03(DemoDu* pthis, GlobalContext* globalCtx) { + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + DemoDu_UpdateSkelAnime(pthis); + DemoDu_UpdateEyes(pthis); + DemoDu_CsCredits_HandleSubscenesByNpcAction(pthis, globalCtx); +} + +void DemoDu_UpdateCs_CR_04(DemoDu* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + DemoDu_UpdateBgCheckInfo(pthis, globalCtx); + animFinished = DemoDu_UpdateSkelAnime(pthis); + DemoDu_UpdateEyes(pthis); + DemoDu_CsCredits_BackTo02(pthis, animFinished); +} + +static DemoDuActionFunc sUpdateFuncs[] = { + DemoDu_UpdateCs_FM_00, DemoDu_UpdateCs_FM_01, DemoDu_UpdateCs_FM_02, DemoDu_UpdateCs_FM_03, DemoDu_UpdateCs_FM_04, + DemoDu_UpdateCs_FM_05, DemoDu_UpdateCs_FM_06, DemoDu_UpdateCs_GR_00, DemoDu_UpdateCs_GR_01, DemoDu_UpdateCs_GR_02, + DemoDu_UpdateCs_GR_03, DemoDu_UpdateCs_GR_04, DemoDu_UpdateCs_GR_05, DemoDu_UpdateCs_GR_06, DemoDu_UpdateCs_GR_07, + DemoDu_UpdateCs_GR_08, DemoDu_UpdateCs_GR_09, DemoDu_UpdateCs_GR_10, DemoDu_UpdateCs_GR_11, DemoDu_UpdateCs_GR_12, + DemoDu_UpdateCs_GR_13, DemoDu_UpdateCs_AG_00, DemoDu_UpdateCs_AG_01, DemoDu_UpdateCs_AG_02, DemoDu_UpdateCs_CR_00, + DemoDu_UpdateCs_CR_01, DemoDu_UpdateCs_CR_02, DemoDu_UpdateCs_CR_03, DemoDu_UpdateCs_CR_04, +}; + +void DemoDu_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoDu* pthis = (DemoDu*)thisx; + + if (pthis->updateIndex < 0 || pthis->updateIndex >= 29 || sUpdateFuncs[pthis->updateIndex] == NULL) { + // "The main mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sUpdateFuncs[pthis->updateIndex](pthis, globalCtx); +} + +void DemoDu_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoDu* pthis = (DemoDu*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + switch (pthis->actor.params) { + case DEMO_DU_CS_GORONS_RUBY: + DemoDu_InitCs_GoronsRuby(pthis, globalCtx); + break; + + case DEMO_DU_CS_CHAMBER_AFTER_GANON: + DemoDu_InitCs_AfterGanon(pthis, globalCtx); + break; + + case DEMO_DU_CS_CREDITS: + DemoDu_InitCs_Credits(pthis, globalCtx); + break; + + default: + DemoDu_InitCs_FireMedallion(pthis, globalCtx); + break; + } +} + +void DemoDu_Draw_NoDraw(Actor* thisx, GlobalContext* globalCtx2) { +} + +// Similar to DemoDu_Draw_02, but pthis uses POLY_OPA_DISP. Sets the env color to 255. +void DemoDu_Draw_01(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DemoDu* pthis = (DemoDu*)thisx; + s16 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = sEyeTextures[eyeTexIndex]; + s32 pad; + s16 mouthTexIndex = pthis->mouthTexIndex; + void* mouthTexture = sMouthTextures[mouthTexIndex]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_du.c", 615); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTexture)); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gDaruniaNoseSeriousTex)); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, + pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_du.c", 638); +} + +static DemoDuDrawFunc sDrawFuncs[] = { + DemoDu_Draw_NoDraw, + DemoDu_Draw_01, + DemoDu_Draw_02, +}; + +void DemoDu_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoDu* pthis = (DemoDu*)thisx; + + if (pthis->drawIndex < 0 || pthis->drawIndex >= 3 || sDrawFuncs[pthis->drawIndex] == NULL) { + // "The drawing mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawIndex](thisx, globalCtx); +} + +ActorInit Demo_Du_InitVars = { + ACTOR_DEMO_DU, + ACTORCAT_NPC, + FLAGS, + OBJECT_DU, + sizeof(DemoDu), + (ActorFunc)DemoDu_Init, + (ActorFunc)DemoDu_Destroy, + (ActorFunc)DemoDu_Update, + (ActorFunc)DemoDu_Draw, +}; diff --git a/src/overlays/actors/ovl_Demo_Du/z_demo_du_cutscene_data.c b/src/overlays/actors/ovl_Demo_Du/z_demo_du_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Du/z_demo_du_cutscene_data.c rename to src/overlays/actors/ovl_Demo_Du/z_demo_du_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c deleted file mode 100644 index 4f3313f8b..000000000 --- a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c +++ /dev/null @@ -1,1352 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_EC_Z_DEMO_EC_C -#include "actor_common.h" -/* - * File: z_demo_ec.c - * Overlay: ovl_Demo_Ec - * Description: Credits revelers in Lon Lon - */ - -#include "z_demo_ec.h" -#include "vt.h" -#include "objects/object_zo/object_zo.h" -#include "objects/object_ec/object_ec.h" -#include "objects/object_ma2/object_ma2.h" -#include "objects/object_in/object_in.h" -#include "objects/object_ge1/object_ge1.h" -#include "objects/object_fu/object_fu.h" -#include "objects/object_fish/object_fish.h" -#include "objects/object_ta/object_ta.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" -#include "objects/object_ma2/object_ma2.h" -#include "objects/object_in/object_in.h" -#include "objects/object_ta/object_ta.h" -#include "objects/object_fu/object_fu.h" -#include "objects/object_toryo/object_toryo.h" -#include "objects/object_daiku/object_daiku.h" -#include "objects/object_ge1/object_ge1.h" -#include "objects/object_kz/object_kz.h" -#include "objects/object_md/object_md.h" -#include "objects/object_niw/object_niw.h" -#include "objects/object_ds2/object_ds2.h" -#include "objects/object_os/object_os.h" -#include "objects/object_rs/object_rs.h" -#include "objects/object_gm/object_gm.h" -#include "objects/object_km1/object_km1.h" -#include "objects/object_kw1/object_kw1.h" -#include "objects/object_bji/object_bji.h" -#include "objects/object_ahg/object_ahg.h" -#include "objects/object_bob/object_bob.h" -#include "objects/object_bba/object_bba.h" -#include "objects/object_ane/object_ane.h" -#include "def/graph.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void DemoEc_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoEc_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoEc_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoEc_Draw(Actor* thisx, GlobalContext* globalCtx); - -typedef enum { - /* 00 */ EC_UPDATE_COMMON, - /* 01 */ EC_UPDATE_INGO, - /* 02 */ EC_UPDATE_TALON, - /* 03 */ EC_UPDATE_WINDMILL_MAN, - /* 04 */ EC_UPDATE_KOKIRI_BOY, - /* 05 */ EC_UPDATE_KOKIRI_GIRL, - /* 06 */ EC_UPDATE_OLD_MAN, - /* 07 */ EC_UPDATE_BEARDED_MAN, - /* 08 */ EC_UPDATE_WOMAN, - /* 09 */ EC_UPDATE_OLD_WOMAN, - /* 10 */ EC_UPDATE_BOSS_CARPENTER, - /* 11 */ EC_UPDATE_CARPENTER, - /* 12 */ EC_UPDATE_DANCING_KOKIRI_BOY, - /* 13 */ EC_UPDATE_DANCING_KOKIRI_GIRL, - /* 14 */ EC_UPDATE_GERUDO, - /* 15 */ EC_UPDATE_DANCING_ZORA, - /* 16 */ EC_UPDATE_KING_ZORA, - /* 17 */ EC_UPDATE_17, - /* 18 */ EC_UPDATE_18, - /* 19 */ EC_UPDATE_MIDO, - /* 20 */ EC_UPDATE_20, - /* 21 */ EC_UPDATE_CUCCO, - /* 22 */ EC_UPDATE_CUCCO_LADY, - /* 23 */ EC_UPDATE_POTION_SHOP_OWNER, - /* 24 */ EC_UPDATE_MASK_SHOP_OWNER, - /* 25 */ EC_UPDATE_FISHING_MAN, - /* 26 */ EC_UPDATE_BOMBCHU_SHOP_OWNER, - /* 27 */ EC_UPDATE_GORON, - /* 28 */ EC_UPDATE_MALON -} DemoEcUpdateMode; - -typedef enum { - /* 00 */ EC_DRAW_COMMON, - /* 01 */ EC_DRAW_INGO, - /* 02 */ EC_DRAW_TALON, - /* 03 */ EC_DRAW_WINDMILL_MAN, - /* 04 */ EC_DRAW_KOKIRI_BOY, - /* 05 */ EC_DRAW_KOKIRI_GIRL, - /* 06 */ EC_DRAW_OLD_MAN, - /* 07 */ EC_DRAW_BEARDED_MAN, - /* 08 */ EC_DRAW_WOMAN, - /* 09 */ EC_DRAW_OLD_WOMAN, - /* 10 */ EC_DRAW_BOSS_CARPENTER, - /* 11 */ EC_DRAW_CARPENTER, - /* 12 */ EC_DRAW_GERUDO, - /* 13 */ EC_DRAW_DANCING_ZORA, - /* 14 */ EC_DRAW_KING_ZORA, - /* 15 */ EC_DRAW_MIDO, - /* 16 */ EC_DRAW_CUCCO, - /* 17 */ EC_DRAW_CUCCO_LADY, - /* 18 */ EC_DRAW_POTION_SHOP_OWNER, - /* 19 */ EC_DRAW_MASK_SHOP_OWNER, - /* 20 */ EC_DRAW_FISHING_MAN, - /* 21 */ EC_DRAW_BOMBCHU_SHOP_OWNER, - /* 22 */ EC_DRAW_GORON, - /* 23 */ EC_DRAW_MALON -} DemoEcDrawconfig; - -static s16 sDrawObjects[] = { - /* 0 */ OBJECT_IN, - /* 1 */ OBJECT_TA, - /* 2 */ OBJECT_FU, - /* 3 */ OBJECT_KM1, - /* 4 */ OBJECT_KW1, - /* 5 */ OBJECT_BJI, - /* 6 */ OBJECT_AHG, - /* 7 */ OBJECT_BOB, - /* 8 */ OBJECT_BBA, - /* 9 */ OBJECT_TORYO, - /* 10 */ OBJECT_DAIKU, - /* 11 */ OBJECT_DAIKU, - /* 12 */ OBJECT_DAIKU, - /* 13 */ OBJECT_DAIKU, - /* 14 */ OBJECT_KM1, - /* 15 */ OBJECT_KW1, - /* 16 */ OBJECT_GE1, - /* 17 */ OBJECT_GE1, - /* 18 */ OBJECT_GE1, - /* 19 */ OBJECT_ZO, - /* 20 */ OBJECT_KZ, - /* 21 */ OBJECT_MD, - /* 22 */ OBJECT_NIW, - /* 23 */ OBJECT_NIW, - /* 24 */ OBJECT_NIW, - /* 25 */ OBJECT_ANE, - /* 26 */ OBJECT_DS2, - /* 27 */ OBJECT_OS, - /* 28 */ OBJECT_FISH, - /* 29 */ OBJECT_RS, - /* 30 */ OBJECT_OF1D_MAP, - /* 31 */ OBJECT_OF1D_MAP, - /* 32 */ OBJECT_OF1D_MAP, - /* 33 */ OBJECT_OF1D_MAP, - /* 34 */ OBJECT_MA2, -}; - -static s16 sAnimationObjects[] = { - OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, - OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, - OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, - OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_GM, OBJECT_MA2, -}; - -void DemoEc_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoEc* this = (DemoEc*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); -} - -void DemoEc_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoEc* this = (DemoEc*)thisx; - - if ((this->actor.params < 0) || (this->actor.params > 34)) { - osSyncPrintf(VT_FGCOL(RED) "Demo_Ec_Actor_ct:arg_dataがおかしい!!!!!!!!!!!!\n" VT_RST); - Actor_Kill(&this->actor); - } else { - this->updateMode = EC_UPDATE_COMMON; - this->drawConfig = EC_DRAW_COMMON; - } -} - -s32 DemoEc_UpdateSkelAnime(DemoEc* this) { - return SkelAnime_Update(&this->skelAnime); -} - -void DemoEc_UpdateBgFlags(DemoEc* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 30.0f, 7); -} - -void func_8096D594(DemoEc* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_8096D5D4(DemoEc* this, GlobalContext* globalCtx) { - this->skelAnime.baseTransl = this->skelAnime.jointTable[0]; - this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_8096D64C(DemoEc* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void DemoEc_UpdateEyes(DemoEc* this) { - s32 pad[3]; - s16* blinkTimer = &this->blinkTimer; - s16* eyeTexIndex = &this->eyeTexIndex; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - - *eyeTexIndex = *blinkTimer; - - if (*eyeTexIndex >= 3) { - *eyeTexIndex = 0; - } -} - -void DemoEc_SetEyeTexIndex(DemoEc* this, s16 texIndex) { - this->eyeTexIndex = texIndex; -} - -void DemoEc_InitSkelAnime(DemoEc* this, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeader) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, SEGMENTED_TO_VIRTUAL(skeletonHeader), NULL, NULL, NULL, 0); -} - -void DemoEc_ChangeAnimation(DemoEc* this, AnimationHeader* animation, u8 mode, f32 transitionRate, s32 reverse) { - f32 frameCount; - f32 startFrame; - AnimationHeader* anim; - f32 playbackSpeed; - s16 frameCountS; - - anim = SEGMENTED_TO_VIRTUAL(animation); - frameCountS = Animation_GetLastFrame(anim); - - if (!reverse) { - startFrame = 0.0f; - frameCount = frameCountS; - playbackSpeed = 1.0f; - } else { - frameCount = 0.0f; - startFrame = frameCountS; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, anim, playbackSpeed, startFrame, frameCount, mode, transitionRate); -} - -Gfx* DemoEc_AllocColorDList(GraphicsContext* gfxCtx, u8* color) { - Gfx* dList; - - dList = Graph_Alloc(gfxCtx, sizeof(Gfx) * 2); - gDPSetEnvColor(dList, color[0], color[1], color[2], color[3]); - gSPEndDisplayList(dList + 1); - - return dList; -} - -void DemoEc_DrawSkeleton(DemoEc* this, GlobalContext* globalCtx, void* eyeTexture, void* arg3, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - SkelAnime* skelAnime = &this->skelAnime; - s32 pad; - - OPEN_DISPS(gfxCtx, "../z_demo_ec.c", 565); - - func_80093D18(gfxCtx); - - if (eyeTexture != NULL) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - } - - if (arg3 != NULL) { - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(arg3)); - } - - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - overrideLimbDraw, postLimbDraw, &this->actor, POLY_OPA_DISP); - CLOSE_DISPS(gfxCtx, "../z_demo_ec.c", 595); -} - -void DemoEc_DrawSkeletonCustomColor(DemoEc* this, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8* color1, - u8* color2, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw) { - s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(gfxCtx, "../z_demo_ec.c", 609); - - func_80093D18(gfxCtx); - - if (arg2 != 0) { - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(arg2)); - } - - if (arg3 != 0) { - gSPSegment(POLY_OPA_DISP++, 0x0B, SEGMENTED_TO_VIRTUAL(arg3)); - } - - if (color1 != NULL) { - //! @bug DemoEc_AllocColorDList is called twice in SEGMENTED_TO_VIRTUAL, allocating two display lists - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(DemoEc_AllocColorDList(gfxCtx, color1))); - } - - if (color2 != NULL) { - //! @bug DemoEc_AllocColorDList is called twice in SEGMENTED_TO_VIRTUAL, allocating two display lists - //! @bug meant to pass color2 instead of color1? - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(DemoEc_AllocColorDList(gfxCtx, color1))); - } - - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - overrideLimbDraw, postLimbDraw, &this->actor, POLY_OPA_DISP); - - CLOSE_DISPS(gfxCtx, "../z_demo_ec.c", 646); -} - -void DemoEc_UseDrawObject(DemoEc* this, GlobalContext* globalCtx) { - s32 pad[2]; - s32 drawObjBankIndex = this->drawObjBankIndex; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_demo_ec.c", 662); - - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[drawObjBankIndex].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[drawObjBankIndex].vromStart); - if (!globalCtx) {} - - CLOSE_DISPS(gfxCtx, "../z_demo_ec.c", 670); -} - -void DemoEc_UseAnimationObject(DemoEc* this, GlobalContext* globalCtx) { - s32 animObjBankIndex = this->animObjBankIndex; - - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[animObjBankIndex].vromStart); -} - -CsCmdActorAction* DemoEc_GetNpcAction(GlobalContext* globalCtx, s32 actionIndex) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[actionIndex]; - } else { - return NULL; - } -} - -void DemoEc_SetNpcActionPosRot(DemoEc* this, GlobalContext* globalCtx, s32 actionIndex) { - CsCmdActorAction* npcAction = DemoEc_GetNpcAction(globalCtx, actionIndex); - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -void DemoEc_InitIngo(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gIngoSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcIngoAnim, 0, 0.0f, false); - func_8096D64C(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_INGO; - this->drawConfig = EC_DRAW_INGO; -} - -void DemoEc_UpdateIngo(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawIngo(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, gIngoEyeClosed2Tex, gIngoRedTex, 0, 0); -} - -void DemoEc_InitTalon(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gTalonSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcTalonAnim, 0, 0.0f, false); - func_8096D64C(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_TALON; - this->drawConfig = EC_DRAW_TALON; -} - -void DemoEc_UpdateTalon(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawTalon(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, gTalonEyeClosed2Tex, gTalonRedTex, NULL, NULL); -} - -void DemoEc_InitWindmillMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gWindmillManSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcWindmillManAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_WINDMILL_MAN; - this->drawConfig = EC_DRAW_WINDMILL_MAN; -} - -void DemoEc_UpdateWindmillMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawWindmillMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, gWindmillManEyeClosedTex, gWindmillManMouthAngryTex, NULL, NULL); -} - -void DemoEc_InitKokiriBoy(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gKm1Skel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcKokiriAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_KOKIRI_BOY; - this->drawConfig = EC_DRAW_KOKIRI_BOY; -} - -void DemoEc_InitDancingKokiriBoy(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gKm1Skel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcDancingKokiriAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_DANCING_KOKIRI_BOY; - this->drawConfig = EC_DRAW_KOKIRI_BOY; -} - -void DemoEc_UpdateKokiriBoy(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_UpdateDancingKokiriBoy(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateKokiriBoy(this, globalCtx); -} - -void DemoEc_DrawKokiriBoy(DemoEc* this, GlobalContext* globalCtx) { - static u8 color1[] = { 0, 130, 70, 255 }; - static u8 color2[] = { 110, 170, 20, 255 }; - - DemoEc_DrawSkeletonCustomColor(this, globalCtx, NULL, NULL, color1, color2, NULL, NULL); -} - -void DemoEc_InitKokiriGirl(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gKw1Skel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcKokiriAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_KOKIRI_GIRL; - this->drawConfig = EC_DRAW_KOKIRI_GIRL; -} - -void DemoEc_InitDancingKokiriGirl(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gKw1Skel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcDancingKokiriAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_DANCING_KOKIRI_GIRL; - this->drawConfig = EC_DRAW_KOKIRI_GIRL; -} - -void DemoEc_UpdateKokiriGirl(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_UpdateDancingKokiriGirl(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateKokiriGirl(this, globalCtx); -} - -void DemoEc_DrawKokiriGirl(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gKw1EyeOpenTex, gKw1EyeHalfTex, gKw1EyeClosedTex }; - static u8 color1[] = { 70, 190, 60, 255 }; - static u8 color2[] = { 100, 30, 0, 255 }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeletonCustomColor(this, globalCtx, eyeTexture, NULL, color1, color2, NULL, NULL); -} -void DemoEc_InitOldMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_bji_Skel_0000F0); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcOldManAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_OLD_MAN; - this->drawConfig = EC_DRAW_OLD_MAN; -} - -void DemoEc_UpdateOldMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawOldMan(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { object_bji_Tex_0005FC, object_bji_Tex_0009FC, object_bji_Tex_000DFC }; - static u8 color1[] = { 0, 50, 100, 255 }; - static u8 color2[] = { 0, 50, 160, 255 }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeletonCustomColor(this, globalCtx, eyeTexture, NULL, color1, color2, NULL, NULL); -} - -void DemoEc_InitBeardedMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_ahg_Skel_0000F0); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcOldManAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_BEARDED_MAN; - this->drawConfig = EC_DRAW_BEARDED_MAN; -} - -void DemoEc_UpdateBeardedMan(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawBeardedMan(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { object_ahg_Tex_00057C, object_ahg_Tex_00067C, object_ahg_Tex_00077C }; - static u8 color1[] = { 255, 255, 255, 255 }; - static u8 color2[] = { 255, 255, 255, 255 }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeletonCustomColor(this, globalCtx, eyeTexture, NULL, color1, color2, NULL, NULL); -} - -void DemoEc_InitWoman(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_bob_Skel_0000F0); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcOldManAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_WOMAN; - this->drawConfig = EC_DRAW_WOMAN; -} - -void DemoEc_UpdateWoman(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawWoman(DemoEc* this, GlobalContext* globalCtx) { - static Gfx* eyeTextures[] = { object_bob_Tex_0007C8, object_bob_Tex_000FC8, object_bob_Tex_0017C8 }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitOldWoman(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_bba_Skel_0000F0); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcOldManAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_OLD_WOMAN; - this->drawConfig = EC_DRAW_OLD_WOMAN; -} - -void DemoEc_UpdateOldWoman(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawOldWoman(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, &object_bba_Tex_0004C8, NULL, NULL, NULL); -} - -void DemoEc_InitBossCarpenter(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_toryo_Skel_007150); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcCarpenterAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_BOSS_CARPENTER; - this->drawConfig = EC_DRAW_BOSS_CARPENTER; -} - -void DemoEc_UpdateBossCarpenter(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawBossCarpenter(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, NULL, NULL, NULL, NULL); -} - -void DemoEc_InitCarpenter(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_daiku_Skel_007958); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcCarpenterAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_CARPENTER; - this->drawConfig = EC_DRAW_CARPENTER; -} - -void DemoEc_UpdateCarpenter(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -s32 DemoEc_CarpenterOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx, Gfx** gfx) { - DemoEc* this = (DemoEc*)thisx; - - if (limbIndex == 1) { - gDPPipeSync((*gfx)++); - switch (this->actor.params) { - case 10: - gDPSetEnvColor((*gfx)++, 170, 10, 70, 255); - break; - case 11: - gDPSetEnvColor((*gfx)++, 170, 200, 255, 255); - break; - case 12: - gDPSetEnvColor((*gfx)++, 0, 230, 70, 255); - break; - case 13: - gDPSetEnvColor((*gfx)++, 200, 0, 150, 255); - break; - } - } - - return false; -} - -Gfx* DemoEc_GetCarpenterPostLimbDList(DemoEc* this) { - switch (this->actor.params) { - case 10: - return object_daiku_DL_005BD0; - case 11: - return object_daiku_DL_005AC0; - case 12: - return object_daiku_DL_005990; - case 13: - return object_daiku_DL_005880; - default: - osSyncPrintf(VT_FGCOL(RED) "かつらが無い!!!!!!!!!!!!!!!!\n" VT_RST); - return NULL; - } -} - -void DemoEc_CarpenterPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, - Gfx** gfx) { - DemoEc* this = (DemoEc*)thisx; - Gfx* postLimbDList; - - if (limbIndex == 15) { - postLimbDList = DemoEc_GetCarpenterPostLimbDList(this); - gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(postLimbDList)); - } -} - -void DemoEc_DrawCarpenter(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, NULL, 0, DemoEc_CarpenterOverrideLimbDraw, DemoEc_CarpenterPostLimbDraw); -} - -void DemoEc_InitGerudo(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gGerudoWhiteSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcGerudoAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_GERUDO; - this->drawConfig = EC_DRAW_GERUDO; -} - -void DemoEc_UpdateGerudo(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -Gfx* DemoEc_GetGerudoPostLimbDList(DemoEc* this) { - switch (this->actor.params) { - case 16: - return gGerudoWhiteHairstyleBobDL; - case 17: - return gGerudoWhiteHairstyleStraightFringeDL; - case 18: - return gGerudoWhiteHairstyleSpikyDL; - default: - osSyncPrintf(VT_FGCOL(RED) "かつらが無い!!!!!!!!!!!!!!!!\n" VT_RST); - return NULL; - } -} - -void DemoEc_GerudoPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, - Gfx** gfx) { - DemoEc* this = (DemoEc*)thisx; - Gfx* postLimbDList; - - if (limbIndex == 15) { - postLimbDList = DemoEc_GetGerudoPostLimbDList(this); - gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(postLimbDList)); - } -} - -void DemoEc_DrawGerudo(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gGerudoWhiteEyeOpenTex, gGerudoWhiteEyeHalfTex, gGerudoWhiteEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, DemoEc_GerudoPostLimbDraw); -} - -void DemoEc_InitDancingZora(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gZoraSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcDancingZoraAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_DANCING_ZORA; - this->drawConfig = EC_DRAW_DANCING_ZORA; -} - -void DemoEc_UpdateDancingZora(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawDancingZora(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitKingZora(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gKzSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcKingZoraAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_KING_ZORA; - this->drawConfig = EC_DRAW_KING_ZORA; - DemoEc_SetEyeTexIndex(this, 3); -} - -void func_8096F1D4(DemoEc* this) { - f32 currentFrame = this->skelAnime.curFrame; - - if (currentFrame <= 32.0f) { - DemoEc_SetEyeTexIndex(this, 3); - } else { - DemoEc_UpdateEyes(this); - } -} - -void func_8096F224(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcAnim_006930, 2, -8.0f, false); - this->updateMode = EC_UPDATE_17; -} - -void func_8096F26C(DemoEc* this, s32 arg1) { - if (arg1 != 0) { - DemoEc_ChangeAnimation(this, &gDemoEcAnim_006220, 0, 0.0f, false); - this->updateMode = EC_UPDATE_18; - } -} - -void func_8096F2B0(DemoEc* this, GlobalContext* globalCtx, s32 arg2) { - CsCmdActorAction* npcAction; - s32 sp18; - - npcAction = DemoEc_GetNpcAction(globalCtx, arg2); - - if (npcAction != NULL) { - sp18 = npcAction->action; - if ((sp18 != this->npcAction)) { - if (this->npcAction) {} - if (sp18 == 2) { - func_8096F224(this, globalCtx); - } - this->npcAction = sp18; - } - } -} - -void DemoEc_UpdateKingZora(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_SetNpcActionPosRot(this, globalCtx, 6); - DemoEc_UpdateBgFlags(this, globalCtx); - func_8096F2B0(this, globalCtx, 6); -} - -void func_8096F378(DemoEc* this, GlobalContext* globalCtx) { - s32 animDone = DemoEc_UpdateSkelAnime(this); - - func_8096D594(this, globalCtx); - func_8096F1D4(this); - DemoEc_UpdateBgFlags(this, globalCtx); - func_8096F26C(this, animDone); -} - -void func_8096F3D4(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawKingZora(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gKzEyeOpenTex, gKzEyeHalfTex, gKzEyeClosedTex, gKzEyeOpen2Tex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitMido(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gMidoSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcMidoAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_MIDO; - this->drawConfig = EC_DRAW_MIDO; - DemoEc_SetEyeTexIndex(this, 3); -} - -void func_8096F4FC(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcAnim_008D1C, 2, -8.0f, false); - this->updateMode = EC_UPDATE_20; -} - -void func_8096F544(DemoEc* this, s32 changeAnim) { - if (changeAnim) { - DemoEc_ChangeAnimation(this, &gDemoEcAnim_009234, 0, 0.0f, false); - } -} - -void func_8096F578(DemoEc* this, GlobalContext* globalCtx, s32 arg2) { - CsCmdActorAction* npcAction; - s32 sp18; - - npcAction = DemoEc_GetNpcAction(globalCtx, arg2); - if (npcAction != NULL) { - sp18 = npcAction->action; - if ((sp18 != this->npcAction)) { - if (this->npcAction) {} - if (sp18 == 2) { - func_8096F4FC(this, globalCtx); - } - this->npcAction = sp18; - } - } -} - -void DemoEc_UpdateMido(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_SetNpcActionPosRot(this, globalCtx, 7); - DemoEc_UpdateBgFlags(this, globalCtx); - func_8096F578(this, globalCtx, 7); -} - -void func_8096F640(DemoEc* this, GlobalContext* globalCtx) { - s32 animDone = DemoEc_UpdateSkelAnime(this); - - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); - func_8096F544(this, animDone); -} - -void DemoEc_DrawMido(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gMidoEyeOpenTex, gMidoEyeHalfTex, gMidoEyeClosedTex, gMidoEyeAngryTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitCucco(DemoEc* this, GlobalContext* globalCtx) { - AnimationHeader* animation; - - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gCuccoSkel); - DemoEc_UseAnimationObject(this, globalCtx); - - if (this->actor.params == 22) { - animation = &gDemoEcJumpingCuccoAnim; - } else if (this->actor.params == 23) { - animation = &gDemoEcJumpingCucco2Anim; - } else { - animation = &gDemoEcWalkingCuccoAnim; - } - - DemoEc_ChangeAnimation(this, animation, 0, 0.0f, false); - func_8096D64C(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_CUCCO; - this->drawConfig = EC_DRAW_CUCCO; -} - -void DemoEc_UpdateCucco(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawCucco(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, NULL, NULL, NULL, NULL); -} - -void DemoEc_InitCuccoLady(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gCuccoLadySkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcCuccoLadyAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_CUCCO_LADY; - this->drawConfig = EC_DRAW_CUCCO_LADY; -} - -void DemoEc_UpdateCuccoLady(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawCuccoLady(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gCuccoLadyEyeOpenTex, gCuccoLadyEyeHalfTex, gCuccoLadyEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitPotionShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_ds2_Skel_004258); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_POTION_SHOP_OWNER; - this->drawConfig = EC_DRAW_POTION_SHOP_OWNER; -} - -void DemoEc_UpdatePotionShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawPotionShopOwner(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gPotionShopkeeperEyeOpenTex, gPotionShopkeeperEyeHalfTex, gPotionShopkeeperEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitMaskShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_os_Skel_004658); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_MASK_SHOP_OWNER; - this->drawConfig = EC_DRAW_MASK_SHOP_OWNER; -} - -void DemoEc_UpdateMaskShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawMaskShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_DrawSkeleton(this, globalCtx, gOsEyeClosedTex, NULL, NULL, NULL); -} - -void DemoEc_InitFishingOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gFishingOwnerSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_FISHING_MAN; - this->drawConfig = EC_DRAW_FISHING_MAN; -} - -void DemoEc_UpdateFishingOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_FishingOwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, - Gfx** gfx) { - DemoEc* this = (DemoEc*)thisx; - - if ((limbIndex == 8) && !(HIGH_SCORE(HS_FISHING) & 0x1000)) { - gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHatDL)); - } -} - -void DemoEc_DrawFishingOwner(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { - gFishingOwnerEyeOpenTex, - gFishingOwnerEyeHalfTex, - gFishingOwnerEyeClosedTex, - }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, DemoEc_FishingOwnerPostLimbDraw); -} - -void DemoEc_InitBombchuShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &object_rs_Skel_004868); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_BOMBCHU_SHOP_OWNER; - this->drawConfig = EC_DRAW_BOMBCHU_SHOP_OWNER; -} - -void DempEc_UpdateBombchuShopOwner(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawBombchuShopOwner(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gBombchuShopkeeperEyeOpenTex, gBombchuShopkeeperEyeHalfTex, - gBombchuShopkeeperEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, NULL, NULL, NULL); -} - -void DemoEc_InitGorons(DemoEc* this, GlobalContext* globalCtx) { - s32 pad[2]; - AnimationHeader* animation; - f32 goronScale; - Vec3f* scale = &this->actor.scale; - - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gGoronSkel); - DemoEc_UseAnimationObject(this, globalCtx); - - if (this->actor.params == 30) { - animation = &gDemoEcGoronAnim; - goronScale = 1.0f; - } else if (this->actor.params == 31) { - animation = &gDemoEcGoron2Anim; - goronScale = 1.0f; - } else if (this->actor.params == 32) { - animation = &gDemoEcGoronAnim; - goronScale = 15.0f; - } else { - goronScale = 5.0f; - animation = &object_gm_Anim_0002B8; - } - - DemoEc_ChangeAnimation(this, animation, 0, 0.0f, false); - - scale->x *= goronScale; - scale->y *= goronScale; - scale->z *= goronScale; - - func_8096D64C(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_GORON; - this->drawConfig = EC_DRAW_GORON; -} - -void DemoEc_UpdateGorons(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawGorons(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, gGoronCsMouthNeutralTex, NULL, NULL); -} - -void DemoEc_InitMalon(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UseDrawObject(this, globalCtx); - DemoEc_InitSkelAnime(this, globalCtx, &gMalonAdultSkel); - DemoEc_UseAnimationObject(this, globalCtx); - DemoEc_ChangeAnimation(this, &gMalonAdultSingAnim, 0, 0.0f, false); - func_8096D5D4(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->updateMode = EC_UPDATE_MALON; - this->drawConfig = EC_DRAW_MALON; -} - -void DemoEc_UpdateMalon(DemoEc* this, GlobalContext* globalCtx) { - DemoEc_UpdateSkelAnime(this); - func_8096D594(this, globalCtx); - DemoEc_UpdateEyes(this); - DemoEc_UpdateBgFlags(this, globalCtx); -} - -void DemoEc_DrawMalon(DemoEc* this, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gMalonAdultEyeOpenTex, gMalonAdultEyeHalfTex, gMalonAdultEyeClosedTex }; - s32 eyeTexIndex = this->eyeTexIndex; - void* eyeTexture = eyeTextures[eyeTexIndex]; - - DemoEc_DrawSkeleton(this, globalCtx, eyeTexture, gMalonAdultMouthHappyTex, NULL, NULL); -} - -static DemoEcInitFunc sInitFuncs[] = { - /* 0 */ DemoEc_InitIngo, - /* 1 */ DemoEc_InitTalon, - /* 2 */ DemoEc_InitWindmillMan, - /* 3 */ DemoEc_InitKokiriBoy, - /* 4 */ DemoEc_InitKokiriGirl, - /* 5 */ DemoEc_InitOldMan, - /* 6 */ DemoEc_InitBeardedMan, - /* 7 */ DemoEc_InitWoman, - /* 8 */ DemoEc_InitOldWoman, - /* 9 */ DemoEc_InitBossCarpenter, - /* 10 */ DemoEc_InitCarpenter, - /* 11 */ DemoEc_InitCarpenter, - /* 12 */ DemoEc_InitCarpenter, - /* 13 */ DemoEc_InitCarpenter, - /* 14 */ DemoEc_InitDancingKokiriBoy, - /* 15 */ DemoEc_InitDancingKokiriGirl, - /* 16 */ DemoEc_InitGerudo, - /* 17 */ DemoEc_InitGerudo, - /* 18 */ DemoEc_InitGerudo, - /* 19 */ DemoEc_InitDancingZora, - /* 20 */ DemoEc_InitKingZora, - /* 21 */ DemoEc_InitMido, - /* 22 */ DemoEc_InitCucco, - /* 23 */ DemoEc_InitCucco, - /* 24 */ DemoEc_InitCucco, - /* 25 */ DemoEc_InitCuccoLady, - /* 26 */ DemoEc_InitPotionShopOwner, - /* 27 */ DemoEc_InitMaskShopOwner, - /* 28 */ DemoEc_InitFishingOwner, - /* 29 */ DemoEc_InitBombchuShopOwner, - /* 30 */ DemoEc_InitGorons, - /* 31 */ DemoEc_InitGorons, - /* 32 */ DemoEc_InitGorons, - /* 33 */ DemoEc_InitGorons, - /* 34 */ DemoEc_InitMalon, -}; - -void DemoEc_InitNpc(DemoEc* this, GlobalContext* globalCtx) { - s16 type = this->actor.params; - - if (sInitFuncs[type] == NULL) { - // "Demo_Ec_main_init: Initialization process is wrong arg_data" - osSyncPrintf(VT_FGCOL(RED) " Demo_Ec_main_init:初期化処理がおかしいarg_data = %d!\n" VT_RST, type); - Actor_Kill(&this->actor); - return; - } - - sInitFuncs[type](this, globalCtx); -} - -void DemoEc_InitCommon(DemoEc* this, GlobalContext* globalCtx) { - s32 pad; - s16 primary; - s32 type; - s16 pad2; - s16 sp28; - s32 primaryBankIndex; - s32 secondaryBankIndex; - - type = this->actor.params; - primary = sDrawObjects[type]; - sp28 = sAnimationObjects[type]; - primaryBankIndex = Object_GetIndex(&globalCtx->objectCtx, primary); - secondaryBankIndex = Object_GetIndex(&globalCtx->objectCtx, sp28); - - if ((secondaryBankIndex < 0) || (primaryBankIndex < 0)) { - // "Demo_Ec_main_bank: Bank unreadable arg_data = %d!" - osSyncPrintf(VT_FGCOL(RED) "Demo_Ec_main_bank:バンクを読めない arg_data = %d!\n" VT_RST, type); - Actor_Kill(&this->actor); - return; - } - - if (Object_IsLoaded(&globalCtx->objectCtx, primaryBankIndex) && - Object_IsLoaded(&globalCtx->objectCtx, secondaryBankIndex)) { - - this->drawObjBankIndex = primaryBankIndex; - this->animObjBankIndex = secondaryBankIndex; - - DemoEc_InitNpc(this, globalCtx); - } -} - -static DemoEcUpdateFunc sUpdateFuncs[] = { - DemoEc_InitCommon, - DemoEc_UpdateIngo, - DemoEc_UpdateTalon, - DemoEc_UpdateWindmillMan, - DemoEc_UpdateKokiriBoy, - DemoEc_UpdateKokiriGirl, - DemoEc_UpdateOldMan, - DemoEc_UpdateBeardedMan, - DemoEc_UpdateWoman, - DemoEc_UpdateOldWoman, - DemoEc_UpdateBossCarpenter, - DemoEc_UpdateCarpenter, - DemoEc_UpdateDancingKokiriBoy, - DemoEc_UpdateDancingKokiriGirl, - DemoEc_UpdateGerudo, - DemoEc_UpdateDancingZora, - DemoEc_UpdateKingZora, - func_8096F378, - func_8096F3D4, - DemoEc_UpdateMido, - func_8096F640, - DemoEc_UpdateCucco, - DemoEc_UpdateCuccoLady, - DemoEc_UpdatePotionShopOwner, - DemoEc_UpdateMaskShopOwner, - DemoEc_UpdateFishingOwner, - DempEc_UpdateBombchuShopOwner, - DemoEc_UpdateGorons, - DemoEc_UpdateMalon, -}; - -void DemoEc_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoEc* this = (DemoEc*)thisx; - s32 updateMode = this->updateMode; - - if ((updateMode < 0) || (updateMode >= ARRAY_COUNT(sUpdateFuncs)) || sUpdateFuncs[updateMode] == NULL) { - // "The main mode is strange !!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - } else { - if (updateMode != EC_UPDATE_COMMON) { - DemoEc_UseAnimationObject(this, globalCtx); - } - sUpdateFuncs[updateMode](this, globalCtx); - } -} - -void DemoEc_DrawCommon(DemoEc* this, GlobalContext* globalCtx) { -} - -static DemoEcDrawFunc sDrawFuncs[] = { - DemoEc_DrawCommon, DemoEc_DrawIngo, - DemoEc_DrawTalon, DemoEc_DrawWindmillMan, - DemoEc_DrawKokiriBoy, DemoEc_DrawKokiriGirl, - DemoEc_DrawOldMan, DemoEc_DrawBeardedMan, - DemoEc_DrawWoman, DemoEc_DrawOldWoman, - DemoEc_DrawBossCarpenter, DemoEc_DrawCarpenter, - DemoEc_DrawGerudo, DemoEc_DrawDancingZora, - DemoEc_DrawKingZora, DemoEc_DrawMido, - DemoEc_DrawCucco, DemoEc_DrawCuccoLady, - DemoEc_DrawPotionShopOwner, DemoEc_DrawMaskShopOwner, - DemoEc_DrawFishingOwner, DemoEc_DrawBombchuShopOwner, - DemoEc_DrawGorons, DemoEc_DrawMalon, -}; - -void DemoEc_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoEc* this = (DemoEc*)thisx; - s32 drawConfig = this->drawConfig; - - if ((drawConfig < 0) || (drawConfig >= ARRAY_COUNT(sDrawFuncs)) || sDrawFuncs[drawConfig] == NULL) { - // "The main mode is strange !!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - } else { - if (drawConfig != EC_DRAW_COMMON) { - DemoEc_UseDrawObject(this, globalCtx); - } - sDrawFuncs[drawConfig](this, globalCtx); - } -} - -const ActorInit Demo_Ec_InitVars = { - ACTOR_DEMO_EC, - ACTORCAT_NPC, - FLAGS, - OBJECT_EC, - sizeof(DemoEc), - (ActorFunc)DemoEc_Init, - (ActorFunc)DemoEc_Destroy, - (ActorFunc)DemoEc_Update, - (ActorFunc)DemoEc_Draw, -}; diff --git a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.cpp b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.cpp new file mode 100644 index 000000000..dafb3b9ff --- /dev/null +++ b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.cpp @@ -0,0 +1,1352 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_EC_Z_DEMO_EC_C +#include "actor_common.h" +/* + * File: z_demo_ec.c + * Overlay: ovl_Demo_Ec + * Description: Credits revelers in Lon Lon + */ + +#include "z_demo_ec.h" +#include "vt.h" +#include "objects/object_zo/object_zo.h" +#include "objects/object_ec/object_ec.h" +#include "objects/object_ma2/object_ma2.h" +#include "objects/object_in/object_in.h" +#include "objects/object_ge1/object_ge1.h" +#include "objects/object_fu/object_fu.h" +#include "objects/object_fish/object_fish.h" +#include "objects/object_ta/object_ta.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "objects/object_ma2/object_ma2.h" +#include "objects/object_in/object_in.h" +#include "objects/object_ta/object_ta.h" +#include "objects/object_fu/object_fu.h" +#include "objects/object_toryo/object_toryo.h" +#include "objects/object_daiku/object_daiku.h" +#include "objects/object_ge1/object_ge1.h" +#include "objects/object_kz/object_kz.h" +#include "objects/object_md/object_md.h" +#include "objects/object_niw/object_niw.h" +#include "objects/object_ds2/object_ds2.h" +#include "objects/object_os/object_os.h" +#include "objects/object_rs/object_rs.h" +#include "objects/object_gm/object_gm.h" +#include "objects/object_km1/object_km1.h" +#include "objects/object_kw1/object_kw1.h" +#include "objects/object_bji/object_bji.h" +#include "objects/object_ahg/object_ahg.h" +#include "objects/object_bob/object_bob.h" +#include "objects/object_bba/object_bba.h" +#include "objects/object_ane/object_ane.h" +#include "def/graph.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void DemoEc_Init(Actor* thisx, GlobalContext* globalCtx); +void DemoEc_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DemoEc_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoEc_Draw(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + /* 00 */ EC_UPDATE_COMMON, + /* 01 */ EC_UPDATE_INGO, + /* 02 */ EC_UPDATE_TALON, + /* 03 */ EC_UPDATE_WINDMILL_MAN, + /* 04 */ EC_UPDATE_KOKIRI_BOY, + /* 05 */ EC_UPDATE_KOKIRI_GIRL, + /* 06 */ EC_UPDATE_OLD_MAN, + /* 07 */ EC_UPDATE_BEARDED_MAN, + /* 08 */ EC_UPDATE_WOMAN, + /* 09 */ EC_UPDATE_OLD_WOMAN, + /* 10 */ EC_UPDATE_BOSS_CARPENTER, + /* 11 */ EC_UPDATE_CARPENTER, + /* 12 */ EC_UPDATE_DANCING_KOKIRI_BOY, + /* 13 */ EC_UPDATE_DANCING_KOKIRI_GIRL, + /* 14 */ EC_UPDATE_GERUDO, + /* 15 */ EC_UPDATE_DANCING_ZORA, + /* 16 */ EC_UPDATE_KING_ZORA, + /* 17 */ EC_UPDATE_17, + /* 18 */ EC_UPDATE_18, + /* 19 */ EC_UPDATE_MIDO, + /* 20 */ EC_UPDATE_20, + /* 21 */ EC_UPDATE_CUCCO, + /* 22 */ EC_UPDATE_CUCCO_LADY, + /* 23 */ EC_UPDATE_POTION_SHOP_OWNER, + /* 24 */ EC_UPDATE_MASK_SHOP_OWNER, + /* 25 */ EC_UPDATE_FISHING_MAN, + /* 26 */ EC_UPDATE_BOMBCHU_SHOP_OWNER, + /* 27 */ EC_UPDATE_GORON, + /* 28 */ EC_UPDATE_MALON +} DemoEcUpdateMode; + +typedef enum { + /* 00 */ EC_DRAW_COMMON, + /* 01 */ EC_DRAW_INGO, + /* 02 */ EC_DRAW_TALON, + /* 03 */ EC_DRAW_WINDMILL_MAN, + /* 04 */ EC_DRAW_KOKIRI_BOY, + /* 05 */ EC_DRAW_KOKIRI_GIRL, + /* 06 */ EC_DRAW_OLD_MAN, + /* 07 */ EC_DRAW_BEARDED_MAN, + /* 08 */ EC_DRAW_WOMAN, + /* 09 */ EC_DRAW_OLD_WOMAN, + /* 10 */ EC_DRAW_BOSS_CARPENTER, + /* 11 */ EC_DRAW_CARPENTER, + /* 12 */ EC_DRAW_GERUDO, + /* 13 */ EC_DRAW_DANCING_ZORA, + /* 14 */ EC_DRAW_KING_ZORA, + /* 15 */ EC_DRAW_MIDO, + /* 16 */ EC_DRAW_CUCCO, + /* 17 */ EC_DRAW_CUCCO_LADY, + /* 18 */ EC_DRAW_POTION_SHOP_OWNER, + /* 19 */ EC_DRAW_MASK_SHOP_OWNER, + /* 20 */ EC_DRAW_FISHING_MAN, + /* 21 */ EC_DRAW_BOMBCHU_SHOP_OWNER, + /* 22 */ EC_DRAW_GORON, + /* 23 */ EC_DRAW_MALON +} DemoEcDrawconfig; + +static s16 sDrawObjects[] = { + /* 0 */ OBJECT_IN, + /* 1 */ OBJECT_TA, + /* 2 */ OBJECT_FU, + /* 3 */ OBJECT_KM1, + /* 4 */ OBJECT_KW1, + /* 5 */ OBJECT_BJI, + /* 6 */ OBJECT_AHG, + /* 7 */ OBJECT_BOB, + /* 8 */ OBJECT_BBA, + /* 9 */ OBJECT_TORYO, + /* 10 */ OBJECT_DAIKU, + /* 11 */ OBJECT_DAIKU, + /* 12 */ OBJECT_DAIKU, + /* 13 */ OBJECT_DAIKU, + /* 14 */ OBJECT_KM1, + /* 15 */ OBJECT_KW1, + /* 16 */ OBJECT_GE1, + /* 17 */ OBJECT_GE1, + /* 18 */ OBJECT_GE1, + /* 19 */ OBJECT_ZO, + /* 20 */ OBJECT_KZ, + /* 21 */ OBJECT_MD, + /* 22 */ OBJECT_NIW, + /* 23 */ OBJECT_NIW, + /* 24 */ OBJECT_NIW, + /* 25 */ OBJECT_ANE, + /* 26 */ OBJECT_DS2, + /* 27 */ OBJECT_OS, + /* 28 */ OBJECT_FISH, + /* 29 */ OBJECT_RS, + /* 30 */ OBJECT_OF1D_MAP, + /* 31 */ OBJECT_OF1D_MAP, + /* 32 */ OBJECT_OF1D_MAP, + /* 33 */ OBJECT_OF1D_MAP, + /* 34 */ OBJECT_MA2, +}; + +static s16 sAnimationObjects[] = { + OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, + OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, + OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, + OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_EC, OBJECT_GM, OBJECT_MA2, +}; + +void DemoEc_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoEc* pthis = (DemoEc*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); +} + +void DemoEc_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoEc* pthis = (DemoEc*)thisx; + + if ((pthis->actor.params < 0) || (pthis->actor.params > 34)) { + osSyncPrintf(VT_FGCOL(RED) "Demo_Ec_Actor_ct:arg_dataがおかしい!!!!!!!!!!!!\n" VT_RST); + Actor_Kill(&pthis->actor); + } else { + pthis->updateMode = EC_UPDATE_COMMON; + pthis->drawConfig = EC_DRAW_COMMON; + } +} + +s32 DemoEc_UpdateSkelAnime(DemoEc* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +void DemoEc_UpdateBgFlags(DemoEc* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 25.0f, 30.0f, 7); +} + +void func_8096D594(DemoEc* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_8096D5D4(DemoEc* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.baseTransl = pthis->skelAnime.jointTable[0]; + pthis->skelAnime.prevTransl = pthis->skelAnime.jointTable[0]; + pthis->skelAnime.moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_8096D64C(DemoEc* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void DemoEc_UpdateEyes(DemoEc* pthis) { + s32 pad[3]; + s16* blinkTimer = &pthis->blinkTimer; + s16* eyeTexIndex = &pthis->eyeTexIndex; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + + *eyeTexIndex = *blinkTimer; + + if (*eyeTexIndex >= 3) { + *eyeTexIndex = 0; + } +} + +void DemoEc_SetEyeTexIndex(DemoEc* pthis, s16 texIndex) { + pthis->eyeTexIndex = texIndex; +} + +void DemoEc_InitSkelAnime(DemoEc* pthis, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeader) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, SEGMENTED_TO_VIRTUAL(skeletonHeader), NULL, NULL, NULL, 0); +} + +void DemoEc_ChangeAnimation(DemoEc* pthis, AnimationHeader* animation, u8 mode, f32 transitionRate, s32 reverse) { + f32 frameCount; + f32 startFrame; + AnimationHeader* anim; + f32 playbackSpeed; + s16 frameCountS; + + anim = SEGMENTED_TO_VIRTUAL(animation); + frameCountS = Animation_GetLastFrame(anim); + + if (!reverse) { + startFrame = 0.0f; + frameCount = frameCountS; + playbackSpeed = 1.0f; + } else { + frameCount = 0.0f; + startFrame = frameCountS; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, anim, playbackSpeed, startFrame, frameCount, mode, transitionRate); +} + +Gfx* DemoEc_AllocColorDList(GraphicsContext* gfxCtx, u8* color) { + Gfx* dList; + + dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 2); + gDPSetEnvColor(dList, color[0], color[1], color[2], color[3]); + gSPEndDisplayList(dList + 1); + + return dList; +} + +void DemoEc_DrawSkeleton(DemoEc* pthis, GlobalContext* globalCtx, void* eyeTexture, void* arg3, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + SkelAnime* skelAnime = &pthis->skelAnime; + s32 pad; + + OPEN_DISPS(gfxCtx, "../z_demo_ec.c", 565); + + func_80093D18(gfxCtx); + + if (eyeTexture != NULL) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + } + + if (arg3 != NULL) { + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(arg3)); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + overrideLimbDraw, postLimbDraw, &pthis->actor, POLY_OPA_DISP); + CLOSE_DISPS(gfxCtx, "../z_demo_ec.c", 595); +} + +void DemoEc_DrawSkeletonCustomColor(DemoEc* pthis, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8* color1, + u8* color2, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(gfxCtx, "../z_demo_ec.c", 609); + + func_80093D18(gfxCtx); + + if (arg2 != 0) { + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(arg2)); + } + + if (arg3 != 0) { + gSPSegment(POLY_OPA_DISP++, 0x0B, SEGMENTED_TO_VIRTUAL(arg3)); + } + + if (color1 != NULL) { + //! @bug DemoEc_AllocColorDList is called twice in SEGMENTED_TO_VIRTUAL, allocating two display lists + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(DemoEc_AllocColorDList(gfxCtx, color1))); + } + + if (color2 != NULL) { + //! @bug DemoEc_AllocColorDList is called twice in SEGMENTED_TO_VIRTUAL, allocating two display lists + //! @bug meant to pass color2 instead of color1? + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(DemoEc_AllocColorDList(gfxCtx, color1))); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + overrideLimbDraw, postLimbDraw, &pthis->actor, POLY_OPA_DISP); + + CLOSE_DISPS(gfxCtx, "../z_demo_ec.c", 646); +} + +void DemoEc_UseDrawObject(DemoEc* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s32 drawObjBankIndex = pthis->drawObjBankIndex; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_demo_ec.c", 662); + + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[drawObjBankIndex].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[drawObjBankIndex].vromStart.get()); + if (!globalCtx) {} + + CLOSE_DISPS(gfxCtx, "../z_demo_ec.c", 670); +} + +void DemoEc_UseAnimationObject(DemoEc* pthis, GlobalContext* globalCtx) { + s32 animObjBankIndex = pthis->animObjBankIndex; + + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[animObjBankIndex].vromStart.get()); +} + +CsCmdActorAction* DemoEc_GetNpcAction(GlobalContext* globalCtx, s32 actionIndex) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[actionIndex]; + } else { + return NULL; + } +} + +void DemoEc_SetNpcActionPosRot(DemoEc* pthis, GlobalContext* globalCtx, s32 actionIndex) { + CsCmdActorAction* npcAction = DemoEc_GetNpcAction(globalCtx, actionIndex); + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +void DemoEc_InitIngo(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gIngoSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcIngoAnim, 0, 0.0f, false); + func_8096D64C(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_INGO; + pthis->drawConfig = EC_DRAW_INGO; +} + +void DemoEc_UpdateIngo(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawIngo(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, gIngoEyeClosed2Tex, gIngoRedTex, 0, 0); +} + +void DemoEc_InitTalon(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gTalonSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcTalonAnim, 0, 0.0f, false); + func_8096D64C(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_TALON; + pthis->drawConfig = EC_DRAW_TALON; +} + +void DemoEc_UpdateTalon(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawTalon(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, gTalonEyeClosed2Tex, gTalonRedTex, NULL, NULL); +} + +void DemoEc_InitWindmillMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gWindmillManSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcWindmillManAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_WINDMILL_MAN; + pthis->drawConfig = EC_DRAW_WINDMILL_MAN; +} + +void DemoEc_UpdateWindmillMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawWindmillMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, gWindmillManEyeClosedTex, gWindmillManMouthAngryTex, NULL, NULL); +} + +void DemoEc_InitKokiriBoy(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gKm1Skel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcKokiriAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_KOKIRI_BOY; + pthis->drawConfig = EC_DRAW_KOKIRI_BOY; +} + +void DemoEc_InitDancingKokiriBoy(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gKm1Skel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcDancingKokiriAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_DANCING_KOKIRI_BOY; + pthis->drawConfig = EC_DRAW_KOKIRI_BOY; +} + +void DemoEc_UpdateKokiriBoy(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_UpdateDancingKokiriBoy(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateKokiriBoy(pthis, globalCtx); +} + +void DemoEc_DrawKokiriBoy(DemoEc* pthis, GlobalContext* globalCtx) { + static u8 color1[] = { 0, 130, 70, 255 }; + static u8 color2[] = { 110, 170, 20, 255 }; + + DemoEc_DrawSkeletonCustomColor(pthis, globalCtx, NULL, NULL, color1, color2, NULL, NULL); +} + +void DemoEc_InitKokiriGirl(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gKw1Skel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcKokiriAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_KOKIRI_GIRL; + pthis->drawConfig = EC_DRAW_KOKIRI_GIRL; +} + +void DemoEc_InitDancingKokiriGirl(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gKw1Skel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcDancingKokiriAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_DANCING_KOKIRI_GIRL; + pthis->drawConfig = EC_DRAW_KOKIRI_GIRL; +} + +void DemoEc_UpdateKokiriGirl(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_UpdateDancingKokiriGirl(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateKokiriGirl(pthis, globalCtx); +} + +void DemoEc_DrawKokiriGirl(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gKw1EyeOpenTex, gKw1EyeHalfTex, gKw1EyeClosedTex }; + static u8 color1[] = { 70, 190, 60, 255 }; + static u8 color2[] = { 100, 30, 0, 255 }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeletonCustomColor(pthis, globalCtx, (Gfx*)eyeTexture, NULL, color1, color2, NULL, NULL); +} +void DemoEc_InitOldMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_bji_Skel_0000F0); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcOldManAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_OLD_MAN; + pthis->drawConfig = EC_DRAW_OLD_MAN; +} + +void DemoEc_UpdateOldMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawOldMan(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { object_bji_Tex_0005FC, object_bji_Tex_0009FC, object_bji_Tex_000DFC }; + static u8 color1[] = { 0, 50, 100, 255 }; + static u8 color2[] = { 0, 50, 160, 255 }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeletonCustomColor(pthis, globalCtx, (Gfx*)eyeTexture, NULL, color1, color2, NULL, NULL); +} + +void DemoEc_InitBeardedMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_ahg_Skel_0000F0); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcOldManAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_BEARDED_MAN; + pthis->drawConfig = EC_DRAW_BEARDED_MAN; +} + +void DemoEc_UpdateBeardedMan(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawBeardedMan(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { object_ahg_Tex_00057C, object_ahg_Tex_00067C, object_ahg_Tex_00077C }; + static u8 color1[] = { 255, 255, 255, 255 }; + static u8 color2[] = { 255, 255, 255, 255 }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeletonCustomColor(pthis, globalCtx, (Gfx*)eyeTexture, NULL, color1, color2, NULL, NULL); +} + +void DemoEc_InitWoman(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_bob_Skel_0000F0); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcOldManAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_WOMAN; + pthis->drawConfig = EC_DRAW_WOMAN; +} + +void DemoEc_UpdateWoman(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawWoman(DemoEc* pthis, GlobalContext* globalCtx) { + static u8* eyeTextures[] = { object_bob_Tex_0007C8, object_bob_Tex_000FC8, object_bob_Tex_0017C8 }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitOldWoman(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_bba_Skel_0000F0); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcOldManAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_OLD_WOMAN; + pthis->drawConfig = EC_DRAW_OLD_WOMAN; +} + +void DemoEc_UpdateOldWoman(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawOldWoman(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, &object_bba_Tex_0004C8, NULL, NULL, NULL); +} + +void DemoEc_InitBossCarpenter(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_toryo_Skel_007150); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcCarpenterAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_BOSS_CARPENTER; + pthis->drawConfig = EC_DRAW_BOSS_CARPENTER; +} + +void DemoEc_UpdateBossCarpenter(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawBossCarpenter(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, NULL, NULL, NULL, NULL); +} + +void DemoEc_InitCarpenter(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_daiku_Skel_007958); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcCarpenterAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_CARPENTER; + pthis->drawConfig = EC_DRAW_CARPENTER; +} + +void DemoEc_UpdateCarpenter(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +s32 DemoEc_CarpenterOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx, Gfx** gfx) { + DemoEc* pthis = (DemoEc*)thisx; + + if (limbIndex == 1) { + gDPPipeSync((*gfx)++); + switch (pthis->actor.params) { + case 10: + gDPSetEnvColor((*gfx)++, 170, 10, 70, 255); + break; + case 11: + gDPSetEnvColor((*gfx)++, 170, 200, 255, 255); + break; + case 12: + gDPSetEnvColor((*gfx)++, 0, 230, 70, 255); + break; + case 13: + gDPSetEnvColor((*gfx)++, 200, 0, 150, 255); + break; + } + } + + return false; +} + +Gfx* DemoEc_GetCarpenterPostLimbDList(DemoEc* pthis) { + switch (pthis->actor.params) { + case 10: + return object_daiku_DL_005BD0; + case 11: + return object_daiku_DL_005AC0; + case 12: + return object_daiku_DL_005990; + case 13: + return object_daiku_DL_005880; + default: + osSyncPrintf(VT_FGCOL(RED) "かつらが無い!!!!!!!!!!!!!!!!\n" VT_RST); + return NULL; + } +} + +void DemoEc_CarpenterPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, + Gfx** gfx) { + DemoEc* pthis = (DemoEc*)thisx; + Gfx* postLimbDList; + + if (limbIndex == 15) { + postLimbDList = DemoEc_GetCarpenterPostLimbDList(pthis); + gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(postLimbDList)); + } +} + +void DemoEc_DrawCarpenter(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, NULL, 0, DemoEc_CarpenterOverrideLimbDraw, DemoEc_CarpenterPostLimbDraw); +} + +void DemoEc_InitGerudo(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gGerudoWhiteSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcGerudoAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_GERUDO; + pthis->drawConfig = EC_DRAW_GERUDO; +} + +void DemoEc_UpdateGerudo(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +Gfx* DemoEc_GetGerudoPostLimbDList(DemoEc* pthis) { + switch (pthis->actor.params) { + case 16: + return gGerudoWhiteHairstyleBobDL; + case 17: + return gGerudoWhiteHairstyleStraightFringeDL; + case 18: + return gGerudoWhiteHairstyleSpikyDL; + default: + osSyncPrintf(VT_FGCOL(RED) "かつらが無い!!!!!!!!!!!!!!!!\n" VT_RST); + return NULL; + } +} + +void DemoEc_GerudoPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, + Gfx** gfx) { + DemoEc* pthis = (DemoEc*)thisx; + Gfx* postLimbDList; + + if (limbIndex == 15) { + postLimbDList = DemoEc_GetGerudoPostLimbDList(pthis); + gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(postLimbDList)); + } +} + +void DemoEc_DrawGerudo(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gGerudoWhiteEyeOpenTex, gGerudoWhiteEyeHalfTex, gGerudoWhiteEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, DemoEc_GerudoPostLimbDraw); +} + +void DemoEc_InitDancingZora(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gZoraSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcDancingZoraAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_DANCING_ZORA; + pthis->drawConfig = EC_DRAW_DANCING_ZORA; +} + +void DemoEc_UpdateDancingZora(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawDancingZora(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitKingZora(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gKzSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcKingZoraAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_KING_ZORA; + pthis->drawConfig = EC_DRAW_KING_ZORA; + DemoEc_SetEyeTexIndex(pthis, 3); +} + +void func_8096F1D4(DemoEc* pthis) { + f32 currentFrame = pthis->skelAnime.curFrame; + + if (currentFrame <= 32.0f) { + DemoEc_SetEyeTexIndex(pthis, 3); + } else { + DemoEc_UpdateEyes(pthis); + } +} + +void func_8096F224(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcAnim_006930, 2, -8.0f, false); + pthis->updateMode = EC_UPDATE_17; +} + +void func_8096F26C(DemoEc* pthis, s32 arg1) { + if (arg1 != 0) { + DemoEc_ChangeAnimation(pthis, &gDemoEcAnim_006220, 0, 0.0f, false); + pthis->updateMode = EC_UPDATE_18; + } +} + +void func_8096F2B0(DemoEc* pthis, GlobalContext* globalCtx, s32 arg2) { + CsCmdActorAction* npcAction; + s32 sp18; + + npcAction = DemoEc_GetNpcAction(globalCtx, arg2); + + if (npcAction != NULL) { + sp18 = npcAction->action; + if ((sp18 != pthis->npcAction)) { + if (pthis->npcAction) {} + if (sp18 == 2) { + func_8096F224(pthis, globalCtx); + } + pthis->npcAction = sp18; + } + } +} + +void DemoEc_UpdateKingZora(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_SetNpcActionPosRot(pthis, globalCtx, 6); + DemoEc_UpdateBgFlags(pthis, globalCtx); + func_8096F2B0(pthis, globalCtx, 6); +} + +void func_8096F378(DemoEc* pthis, GlobalContext* globalCtx) { + s32 animDone = DemoEc_UpdateSkelAnime(pthis); + + func_8096D594(pthis, globalCtx); + func_8096F1D4(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); + func_8096F26C(pthis, animDone); +} + +void func_8096F3D4(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawKingZora(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gKzEyeOpenTex, gKzEyeHalfTex, gKzEyeClosedTex, gKzEyeOpen2Tex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitMido(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gMidoSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcMidoAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_MIDO; + pthis->drawConfig = EC_DRAW_MIDO; + DemoEc_SetEyeTexIndex(pthis, 3); +} + +void func_8096F4FC(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcAnim_008D1C, 2, -8.0f, false); + pthis->updateMode = EC_UPDATE_20; +} + +void func_8096F544(DemoEc* pthis, s32 changeAnim) { + if (changeAnim) { + DemoEc_ChangeAnimation(pthis, &gDemoEcAnim_009234, 0, 0.0f, false); + } +} + +void func_8096F578(DemoEc* pthis, GlobalContext* globalCtx, s32 arg2) { + CsCmdActorAction* npcAction; + s32 sp18; + + npcAction = DemoEc_GetNpcAction(globalCtx, arg2); + if (npcAction != NULL) { + sp18 = npcAction->action; + if ((sp18 != pthis->npcAction)) { + if (pthis->npcAction) {} + if (sp18 == 2) { + func_8096F4FC(pthis, globalCtx); + } + pthis->npcAction = sp18; + } + } +} + +void DemoEc_UpdateMido(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_SetNpcActionPosRot(pthis, globalCtx, 7); + DemoEc_UpdateBgFlags(pthis, globalCtx); + func_8096F578(pthis, globalCtx, 7); +} + +void func_8096F640(DemoEc* pthis, GlobalContext* globalCtx) { + s32 animDone = DemoEc_UpdateSkelAnime(pthis); + + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); + func_8096F544(pthis, animDone); +} + +void DemoEc_DrawMido(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gMidoEyeOpenTex, gMidoEyeHalfTex, gMidoEyeClosedTex, gMidoEyeAngryTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitCucco(DemoEc* pthis, GlobalContext* globalCtx) { + AnimationHeader* animation; + + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gCuccoSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + + if (pthis->actor.params == 22) { + animation = &gDemoEcJumpingCuccoAnim; + } else if (pthis->actor.params == 23) { + animation = &gDemoEcJumpingCucco2Anim; + } else { + animation = &gDemoEcWalkingCuccoAnim; + } + + DemoEc_ChangeAnimation(pthis, animation, 0, 0.0f, false); + func_8096D64C(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_CUCCO; + pthis->drawConfig = EC_DRAW_CUCCO; +} + +void DemoEc_UpdateCucco(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawCucco(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, NULL, NULL, NULL, NULL); +} + +void DemoEc_InitCuccoLady(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gCuccoLadySkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcCuccoLadyAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_CUCCO_LADY; + pthis->drawConfig = EC_DRAW_CUCCO_LADY; +} + +void DemoEc_UpdateCuccoLady(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawCuccoLady(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gCuccoLadyEyeOpenTex, gCuccoLadyEyeHalfTex, gCuccoLadyEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitPotionShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_ds2_Skel_004258); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_POTION_SHOP_OWNER; + pthis->drawConfig = EC_DRAW_POTION_SHOP_OWNER; +} + +void DemoEc_UpdatePotionShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawPotionShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gPotionShopkeeperEyeOpenTex, gPotionShopkeeperEyeHalfTex, gPotionShopkeeperEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitMaskShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_os_Skel_004658); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_MASK_SHOP_OWNER; + pthis->drawConfig = EC_DRAW_MASK_SHOP_OWNER; +} + +void DemoEc_UpdateMaskShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawMaskShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_DrawSkeleton(pthis, globalCtx, gOsEyeClosedTex, NULL, NULL, NULL); +} + +void DemoEc_InitFishingOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gFishingOwnerSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_FISHING_MAN; + pthis->drawConfig = EC_DRAW_FISHING_MAN; +} + +void DemoEc_UpdateFishingOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_FishingOwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, + Gfx** gfx) { + DemoEc* pthis = (DemoEc*)thisx; + + if ((limbIndex == 8) && !(HIGH_SCORE(HS_FISHING) & 0x1000)) { + gSPDisplayList((*gfx)++, SEGMENTED_TO_VIRTUAL(gFishingOwnerHatDL)); + } +} + +void DemoEc_DrawFishingOwner(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { + gFishingOwnerEyeOpenTex, + gFishingOwnerEyeHalfTex, + gFishingOwnerEyeClosedTex, + }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, DemoEc_FishingOwnerPostLimbDraw); +} + +void DemoEc_InitBombchuShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &object_rs_Skel_004868); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gDemoEcPotionShopOwnerAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_BOMBCHU_SHOP_OWNER; + pthis->drawConfig = EC_DRAW_BOMBCHU_SHOP_OWNER; +} + +void DempEc_UpdateBombchuShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawBombchuShopOwner(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gBombchuShopkeeperEyeOpenTex, gBombchuShopkeeperEyeHalfTex, + gBombchuShopkeeperEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, NULL, NULL, NULL); +} + +void DemoEc_InitGorons(DemoEc* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + AnimationHeader* animation; + f32 goronScale; + Vec3f* scale = &pthis->actor.scale; + + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gGoronSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + + if (pthis->actor.params == 30) { + animation = &gDemoEcGoronAnim; + goronScale = 1.0f; + } else if (pthis->actor.params == 31) { + animation = &gDemoEcGoron2Anim; + goronScale = 1.0f; + } else if (pthis->actor.params == 32) { + animation = &gDemoEcGoronAnim; + goronScale = 15.0f; + } else { + goronScale = 5.0f; + animation = &object_gm_Anim_0002B8; + } + + DemoEc_ChangeAnimation(pthis, animation, 0, 0.0f, false); + + scale->x *= goronScale; + scale->y *= goronScale; + scale->z *= goronScale; + + func_8096D64C(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_GORON; + pthis->drawConfig = EC_DRAW_GORON; +} + +void DemoEc_UpdateGorons(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawGorons(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, gGoronCsMouthNeutralTex, NULL, NULL); +} + +void DemoEc_InitMalon(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UseDrawObject(pthis, globalCtx); + DemoEc_InitSkelAnime(pthis, globalCtx, &gMalonAdultSkel); + DemoEc_UseAnimationObject(pthis, globalCtx); + DemoEc_ChangeAnimation(pthis, &gMalonAdultSingAnim, 0, 0.0f, false); + func_8096D5D4(pthis, globalCtx); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->updateMode = EC_UPDATE_MALON; + pthis->drawConfig = EC_DRAW_MALON; +} + +void DemoEc_UpdateMalon(DemoEc* pthis, GlobalContext* globalCtx) { + DemoEc_UpdateSkelAnime(pthis); + func_8096D594(pthis, globalCtx); + DemoEc_UpdateEyes(pthis); + DemoEc_UpdateBgFlags(pthis, globalCtx); +} + +void DemoEc_DrawMalon(DemoEc* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gMalonAdultEyeOpenTex, gMalonAdultEyeHalfTex, gMalonAdultEyeClosedTex }; + s32 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTexture = eyeTextures[eyeTexIndex]; + + DemoEc_DrawSkeleton(pthis, globalCtx, eyeTexture, gMalonAdultMouthHappyTex, NULL, NULL); +} + +static DemoEcInitFunc sInitFuncs[] = { + /* 0 */ DemoEc_InitIngo, + /* 1 */ DemoEc_InitTalon, + /* 2 */ DemoEc_InitWindmillMan, + /* 3 */ DemoEc_InitKokiriBoy, + /* 4 */ DemoEc_InitKokiriGirl, + /* 5 */ DemoEc_InitOldMan, + /* 6 */ DemoEc_InitBeardedMan, + /* 7 */ DemoEc_InitWoman, + /* 8 */ DemoEc_InitOldWoman, + /* 9 */ DemoEc_InitBossCarpenter, + /* 10 */ DemoEc_InitCarpenter, + /* 11 */ DemoEc_InitCarpenter, + /* 12 */ DemoEc_InitCarpenter, + /* 13 */ DemoEc_InitCarpenter, + /* 14 */ DemoEc_InitDancingKokiriBoy, + /* 15 */ DemoEc_InitDancingKokiriGirl, + /* 16 */ DemoEc_InitGerudo, + /* 17 */ DemoEc_InitGerudo, + /* 18 */ DemoEc_InitGerudo, + /* 19 */ DemoEc_InitDancingZora, + /* 20 */ DemoEc_InitKingZora, + /* 21 */ DemoEc_InitMido, + /* 22 */ DemoEc_InitCucco, + /* 23 */ DemoEc_InitCucco, + /* 24 */ DemoEc_InitCucco, + /* 25 */ DemoEc_InitCuccoLady, + /* 26 */ DemoEc_InitPotionShopOwner, + /* 27 */ DemoEc_InitMaskShopOwner, + /* 28 */ DemoEc_InitFishingOwner, + /* 29 */ DemoEc_InitBombchuShopOwner, + /* 30 */ DemoEc_InitGorons, + /* 31 */ DemoEc_InitGorons, + /* 32 */ DemoEc_InitGorons, + /* 33 */ DemoEc_InitGorons, + /* 34 */ DemoEc_InitMalon, +}; + +void DemoEc_InitNpc(DemoEc* pthis, GlobalContext* globalCtx) { + s16 type = pthis->actor.params; + + if (sInitFuncs[type] == NULL) { + // "Demo_Ec_main_init: Initialization process is wrong arg_data" + osSyncPrintf(VT_FGCOL(RED) " Demo_Ec_main_init:初期化処理がおかしいarg_data = %d!\n" VT_RST, type); + Actor_Kill(&pthis->actor); + return; + } + + sInitFuncs[type](pthis, globalCtx); +} + +void DemoEc_InitCommon(DemoEc* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 primary; + s32 type; + s16 pad2; + s16 sp28; + s32 primaryBankIndex; + s32 secondaryBankIndex; + + type = pthis->actor.params; + primary = sDrawObjects[type]; + sp28 = sAnimationObjects[type]; + primaryBankIndex = Object_GetIndex(&globalCtx->objectCtx, primary); + secondaryBankIndex = Object_GetIndex(&globalCtx->objectCtx, sp28); + + if ((secondaryBankIndex < 0) || (primaryBankIndex < 0)) { + // "Demo_Ec_main_bank: Bank unreadable arg_data = %d!" + osSyncPrintf(VT_FGCOL(RED) "Demo_Ec_main_bank:バンクを読めない arg_data = %d!\n" VT_RST, type); + Actor_Kill(&pthis->actor); + return; + } + + if (Object_IsLoaded(&globalCtx->objectCtx, primaryBankIndex) && + Object_IsLoaded(&globalCtx->objectCtx, secondaryBankIndex)) { + + pthis->drawObjBankIndex = primaryBankIndex; + pthis->animObjBankIndex = secondaryBankIndex; + + DemoEc_InitNpc(pthis, globalCtx); + } +} + +static DemoEcUpdateFunc sUpdateFuncs[] = { + DemoEc_InitCommon, + DemoEc_UpdateIngo, + DemoEc_UpdateTalon, + DemoEc_UpdateWindmillMan, + DemoEc_UpdateKokiriBoy, + DemoEc_UpdateKokiriGirl, + DemoEc_UpdateOldMan, + DemoEc_UpdateBeardedMan, + DemoEc_UpdateWoman, + DemoEc_UpdateOldWoman, + DemoEc_UpdateBossCarpenter, + DemoEc_UpdateCarpenter, + DemoEc_UpdateDancingKokiriBoy, + DemoEc_UpdateDancingKokiriGirl, + DemoEc_UpdateGerudo, + DemoEc_UpdateDancingZora, + DemoEc_UpdateKingZora, + func_8096F378, + func_8096F3D4, + DemoEc_UpdateMido, + func_8096F640, + DemoEc_UpdateCucco, + DemoEc_UpdateCuccoLady, + DemoEc_UpdatePotionShopOwner, + DemoEc_UpdateMaskShopOwner, + DemoEc_UpdateFishingOwner, + DempEc_UpdateBombchuShopOwner, + DemoEc_UpdateGorons, + DemoEc_UpdateMalon, +}; + +void DemoEc_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoEc* pthis = (DemoEc*)thisx; + s32 updateMode = pthis->updateMode; + + if ((updateMode < 0) || (updateMode >= ARRAY_COUNT(sUpdateFuncs)) || sUpdateFuncs[updateMode] == NULL) { + // "The main mode is strange !!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + } else { + if (updateMode != EC_UPDATE_COMMON) { + DemoEc_UseAnimationObject(pthis, globalCtx); + } + sUpdateFuncs[updateMode](pthis, globalCtx); + } +} + +void DemoEc_DrawCommon(DemoEc* pthis, GlobalContext* globalCtx) { +} + +static DemoEcDrawFunc sDrawFuncs[] = { + DemoEc_DrawCommon, DemoEc_DrawIngo, + DemoEc_DrawTalon, DemoEc_DrawWindmillMan, + DemoEc_DrawKokiriBoy, DemoEc_DrawKokiriGirl, + DemoEc_DrawOldMan, DemoEc_DrawBeardedMan, + DemoEc_DrawWoman, DemoEc_DrawOldWoman, + DemoEc_DrawBossCarpenter, DemoEc_DrawCarpenter, + DemoEc_DrawGerudo, DemoEc_DrawDancingZora, + DemoEc_DrawKingZora, DemoEc_DrawMido, + DemoEc_DrawCucco, DemoEc_DrawCuccoLady, + DemoEc_DrawPotionShopOwner, DemoEc_DrawMaskShopOwner, + DemoEc_DrawFishingOwner, DemoEc_DrawBombchuShopOwner, + DemoEc_DrawGorons, DemoEc_DrawMalon, +}; + +void DemoEc_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoEc* pthis = (DemoEc*)thisx; + s32 drawConfig = pthis->drawConfig; + + if ((drawConfig < 0) || (drawConfig >= ARRAY_COUNT(sDrawFuncs)) || sDrawFuncs[drawConfig] == NULL) { + // "The main mode is strange !!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + } else { + if (drawConfig != EC_DRAW_COMMON) { + DemoEc_UseDrawObject(pthis, globalCtx); + } + sDrawFuncs[drawConfig](pthis, globalCtx); + } +} + +ActorInit Demo_Ec_InitVars = { + ACTOR_DEMO_EC, + ACTORCAT_NPC, + FLAGS, + OBJECT_EC, + sizeof(DemoEc), + (ActorFunc)DemoEc_Init, + (ActorFunc)DemoEc_Destroy, + (ActorFunc)DemoEc_Update, + (ActorFunc)DemoEc_Draw, +}; diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.cpp similarity index 54% rename from src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c rename to src/overlays/actors/ovl_Demo_Effect/z_demo_effect.cpp index 46712fb82..b24408479 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.cpp @@ -47,41 +47,41 @@ void DemoEffect_DrawLightEffect(Actor* thisx, GlobalContext* globalCtx); void DemoEffect_DrawTimeWarp(Actor* thisx, GlobalContext* globalCtx); void DemoEffect_DrawJewel(Actor* thisx, GlobalContext* globalCtx); -void DemoEffect_Wait(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_InitTimeWarp(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_InitTimeWarpTimeblock(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_InitCreationFireball(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_InitJewel(GlobalContext* globalCtx, DemoEffect* this); -void DemoEffect_InitJewelColor(DemoEffect* this); +void DemoEffect_Wait(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_InitTimeWarp(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_InitTimeWarpTimeblock(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_InitCreationFireball(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_InitJewel(GlobalContext* globalCtx, DemoEffect* pthis); +void DemoEffect_InitJewelColor(DemoEffect* pthis); -void DemoEffect_UpdateCrystalLight(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdatePositionToParent(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateBlueOrbGrow(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateBlueOrbShrink(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateLgtShower(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateGodLgtDin(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateGodLgtNayru(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateGodLgtFarore(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateLightRingExpanding(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateTriforceSpot(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateGetItem(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateLightRingShrinking(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateLightRingTriforce(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateLightEffect(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateJewelChild(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateJewelAdult(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateDust(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateCreationFireball(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateTimeWarpReturnFromChamberOfSages(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateTimeWarpPullMasterSword(DemoEffect* this, GlobalContext* globalCtx); -void DemoEffect_UpdateTimeWarpTimeblock(DemoEffect* this, GlobalContext* globalCtx); +void DemoEffect_UpdateCrystalLight(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdatePositionToParent(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateBlueOrbGrow(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateBlueOrbShrink(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateLgtShower(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateGodLgtDin(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateGodLgtNayru(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateGodLgtFarore(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateLightRingExpanding(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateTriforceSpot(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateGetItem(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateLightRingShrinking(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateLightRingTriforce(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateLightEffect(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateJewelChild(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateJewelAdult(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateDust(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateCreationFireball(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateTimeWarpReturnFromChamberOfSages(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateTimeWarpPullMasterSword(DemoEffect* pthis, GlobalContext* globalCtx); +void DemoEffect_UpdateTimeWarpTimeblock(DemoEffect* pthis, GlobalContext* globalCtx); -s32 DemoEffect_CheckCsAction(DemoEffect* this, GlobalContext* globalCtx, s32 csActionCompareId); -void DemoEffect_InitPositionFromCsAction(DemoEffect* this, GlobalContext* globalCtx, s32 csActionIndex); -void DemoEffect_MoveToCsEndpoint(DemoEffect* this, GlobalContext* globalCtx, s32 csActionId, s32 shouldUpdateFacing); -void DemoEffect_MoveGetItem(DemoEffect* this, GlobalContext* globalCtx, s32 csActionId, f32 speed); +s32 DemoEffect_CheckCsAction(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionCompareId); +void DemoEffect_InitPositionFromCsAction(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionIndex); +void DemoEffect_MoveToCsEndpoint(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionId, s32 shouldUpdateFacing); +void DemoEffect_MoveGetItem(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionId, f32 speed); -const ActorInit Demo_Effect_InitVars = { +ActorInit Demo_Effect_InitVars = { ACTOR_DEMO_EFFECT, ACTORCAT_BG, FLAGS, @@ -137,8 +137,8 @@ static Color_RGB8 sJewelSparkleColors[5][2] = { /** * Sets up the update function. */ -void DemoEffect_SetupUpdate(DemoEffect* this, DemoEffectFunc updateFunc) { - this->updateFunc = updateFunc; +void DemoEffect_SetupUpdate(DemoEffect* pthis, DemoEffectFunc updateFunc) { + pthis->updateFunc = updateFunc; } /** @@ -157,23 +157,23 @@ f32 DemoEffect_InterpolateCsFrames(GlobalContext* globalCtx, s32 csActionId) { /** * Initializes information for Jewel/Spritual Stone actors. */ -void DemoEffect_InitJewel(GlobalContext* globalCtx, DemoEffect* this) { - this->initDrawFunc = DemoEffect_DrawJewel; +void DemoEffect_InitJewel(GlobalContext* globalCtx, DemoEffect* pthis) { + pthis->initDrawFunc = DemoEffect_DrawJewel; if (!LINK_IS_ADULT) { - this->initUpdateFunc = DemoEffect_UpdateJewelChild; + pthis->initUpdateFunc = DemoEffect_UpdateJewelChild; } else { - this->initUpdateFunc = DemoEffect_UpdateJewelAdult; + pthis->initUpdateFunc = DemoEffect_UpdateJewelAdult; } if (globalCtx->sceneNum == SCENE_TOKINOMA) { - Actor_SetScale(&this->actor, 0.35f); + Actor_SetScale(&pthis->actor, 0.35f); } else { - Actor_SetScale(&this->actor, 0.10f); + Actor_SetScale(&pthis->actor, 0.10f); } - this->csActionId = 1; - this->actor.shape.rot.x = 16384; - DemoEffect_InitJewelColor(this); - this->jewel.alpha = 0; - this->jewelCsRotation.x = this->jewelCsRotation.y = this->jewelCsRotation.z = 0; + pthis->csActionId = 1; + pthis->actor.shape.rot.x = 16384; + DemoEffect_InitJewelColor(pthis); + pthis->jewel.alpha = 0; + pthis->jewelCsRotation.x = pthis->jewelCsRotation.y = pthis->jewelCsRotation.z = 0; sSfxJewelId[0] = 0; } @@ -181,13 +181,13 @@ void DemoEffect_InitJewel(GlobalContext* globalCtx, DemoEffect* this) { * Initializes information for Get Item actors. * These are the Medal and Light Arrow actors. */ -void DemoEffect_InitGetItem(DemoEffect* this) { - this->getItem.isPositionInit = 0; - this->getItem.isLoaded = 0; - this->initDrawFunc = DemoEffect_DrawGetItem; - this->initUpdateFunc = DemoEffect_UpdateGetItem; - Actor_SetScale(&this->actor, 0.25f); - this->csActionId = 6; +void DemoEffect_InitGetItem(DemoEffect* pthis) { + pthis->getItem.isPositionInit = 0; + pthis->getItem.isLoaded = 0; + pthis->initDrawFunc = DemoEffect_DrawGetItem; + pthis->initUpdateFunc = DemoEffect_UpdateGetItem; + Actor_SetScale(&pthis->actor, 0.25f); + pthis->csActionId = 6; } /** @@ -195,15 +195,15 @@ void DemoEffect_InitGetItem(DemoEffect* this) { */ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; s32 effectType; s32 lightEffect; s32 objectIndex; DemoEffect* crystalLight; DemoEffect* lightRing; - effectType = (this->actor.params & 0x00FF); - lightEffect = ((this->actor.params & 0xF000) >> 12); + effectType = (pthis->actor.params & 0x00FF); + lightEffect = ((pthis->actor.params & 0xF000) >> 12); osSyncPrintf(VT_FGCOL(CYAN) " no = %d\n" VT_RST, effectType); @@ -216,223 +216,223 @@ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx2) { if (objectIndex < 0) { ASSERT(0, "0", "../z_demo_effect.c", 723); } else { - this->initObjectBankIndex = objectIndex; + pthis->initObjectBankIndex = objectIndex; } - this->effectFlags = 0; - Actor_SetScale(&this->actor, 0.2f); + pthis->effectFlags = 0; + Actor_SetScale(&pthis->actor, 0.2f); switch (effectType) { case DEMO_EFFECT_CRYSTAL_LIGHT: - this->initDrawFunc = DemoEffect_DrawCrystalLight; - this->initUpdateFunc = DemoEffect_UpdateCrystalLight; + pthis->initDrawFunc = DemoEffect_DrawCrystalLight; + pthis->initUpdateFunc = DemoEffect_UpdateCrystalLight; break; case DEMO_EFFECT_FIRE_BALL: - this->initDrawFunc = DemoEffect_DrawFireBall; - this->initUpdateFunc = DemoEffect_UpdatePositionToParent; - Actor_SetScale(&this->actor, 0.1f); + pthis->initDrawFunc = DemoEffect_DrawFireBall; + pthis->initUpdateFunc = DemoEffect_UpdatePositionToParent; + Actor_SetScale(&pthis->actor, 0.1f); break; case DEMO_EFFECT_BLUE_ORB: - this->initDrawFunc = DemoEffect_DrawBlueOrb; - this->initUpdateFunc = DemoEffect_UpdateBlueOrbGrow; - this->blueOrb.alpha = 255; - this->blueOrb.scale = 5; - this->blueOrb.rotation = 0; - Actor_SetScale(&this->actor, 0.05f); - this->primXluColor[0] = 188; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 100; - this->envXluColor[2] = 255; - this->envXluColor[0] = 0; + pthis->initDrawFunc = DemoEffect_DrawBlueOrb; + pthis->initUpdateFunc = DemoEffect_UpdateBlueOrbGrow; + pthis->blueOrb.alpha = 255; + pthis->blueOrb.scale = 5; + pthis->blueOrb.rotation = 0; + Actor_SetScale(&pthis->actor, 0.05f); + pthis->primXluColor[0] = 188; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 100; + pthis->envXluColor[2] = 255; + pthis->envXluColor[0] = 0; break; case DEMO_EFFECT_LIGHT: - this->initDrawFunc = DemoEffect_DrawLightEffect; - this->initUpdateFunc = DemoEffect_UpdateLightEffect; - this->light.alpha = 255; - this->light.scaleFlag = 0; - this->light.flicker = 0; - this->light.rotation = 0; + pthis->initDrawFunc = DemoEffect_DrawLightEffect; + pthis->initUpdateFunc = DemoEffect_UpdateLightEffect; + pthis->light.alpha = 255; + pthis->light.scaleFlag = 0; + pthis->light.flicker = 0; + pthis->light.rotation = 0; switch (lightEffect) { case DEMO_EFFECT_LIGHT_RED: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 50; - this->envXluColor[0] = 255; - this->envXluColor[2] = 0; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 50; + pthis->envXluColor[0] = 255; + pthis->envXluColor[2] = 0; break; case DEMO_EFFECT_LIGHT_BLUE: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 150; - this->envXluColor[0] = 0; - this->envXluColor[2] = 255; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 150; + pthis->envXluColor[0] = 0; + pthis->envXluColor[2] = 255; break; case DEMO_EFFECT_LIGHT_GREEN: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 200; - this->envXluColor[0] = 0; - this->envXluColor[2] = 0; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 200; + pthis->envXluColor[0] = 0; + pthis->envXluColor[2] = 0; break; case DEMO_EFFECT_LIGHT_ORANGE: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 150; - this->envXluColor[0] = 255; - this->envXluColor[2] = 0; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 150; + pthis->envXluColor[0] = 255; + pthis->envXluColor[2] = 0; break; case DEMO_EFFECT_LIGHT_YELLOW: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[0] = 200; - this->envXluColor[1] = 255; - this->envXluColor[2] = 0; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[0] = 200; + pthis->envXluColor[1] = 255; + pthis->envXluColor[2] = 0; break; case DEMO_EFFECT_LIGHT_PURPLE: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; // clang-format off - this->envXluColor[0] = 200; this->envXluColor[1] = 50; this->envXluColor[2] = 255; // Sameline prevents reordering + pthis->envXluColor[0] = 200; pthis->envXluColor[1] = 50; pthis->envXluColor[2] = 255; // Sameline prevents reordering // clang-format on break; case DEMO_EFFECT_LIGHT_GREEN2: - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 200; - this->envXluColor[0] = 0; - this->envXluColor[2] = 0; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 200; + pthis->envXluColor[0] = 0; + pthis->envXluColor[2] = 0; break; } - this->csActionId = 7; + pthis->csActionId = 7; Actor_SetScale(thisx, 0.0f); break; case DEMO_EFFECT_LGT_SHOWER: - this->lgtShower.alpha = 255; - this->initDrawFunc = DemoEffect_DrawLgtShower; - this->initUpdateFunc = DemoEffect_UpdateLgtShower; + pthis->lgtShower.alpha = 255; + pthis->initDrawFunc = DemoEffect_DrawLgtShower; + pthis->initUpdateFunc = DemoEffect_UpdateLgtShower; break; case DEMO_EFFECT_GOD_LGT_DIN: - Actor_SetScale(&this->actor, 0.1f); - this->initDrawFunc = DemoEffect_DrawGodLgt; - this->primXluColor[1] = 170; - this->primXluColor[0] = 255; - this->primXluColor[2] = 255; - this->envXluColor[0] = 255; - this->envXluColor[2] = 255; - this->envXluColor[1] = 0; - this->godLgt.type = GOD_LGT_DIN; - this->godLgt.rotation = 0; - this->initUpdateFunc = DemoEffect_UpdateGodLgtDin; - this->csActionId = 0; + Actor_SetScale(&pthis->actor, 0.1f); + pthis->initDrawFunc = DemoEffect_DrawGodLgt; + pthis->primXluColor[1] = 170; + pthis->primXluColor[0] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[0] = 255; + pthis->envXluColor[2] = 255; + pthis->envXluColor[1] = 0; + pthis->godLgt.type = GOD_LGT_DIN; + pthis->godLgt.rotation = 0; + pthis->initUpdateFunc = DemoEffect_UpdateGodLgtDin; + pthis->csActionId = 0; break; case DEMO_EFFECT_GOD_LGT_NAYRU: if (gSaveContext.entranceIndex == 0x013D) { - Actor_SetScale(&this->actor, 1.0f); + Actor_SetScale(&pthis->actor, 1.0f); } else { - Actor_SetScale(&this->actor, 0.1f); + Actor_SetScale(&pthis->actor, 0.1f); } - this->initDrawFunc = DemoEffect_DrawGodLgt; - this->primXluColor[0] = 170; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[1] = 40; - this->envXluColor[2] = 255; - this->envXluColor[0] = 0; - this->godLgt.type = GOD_LGT_NAYRU; - this->godLgt.lightRingSpawnDelay = 4; - this->godLgt.rotation = 0; - this->godLgt.lightRingSpawnTimer = 0; - this->initUpdateFunc = DemoEffect_UpdateGodLgtNayru; - this->csActionId = 1; + pthis->initDrawFunc = DemoEffect_DrawGodLgt; + pthis->primXluColor[0] = 170; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[1] = 40; + pthis->envXluColor[2] = 255; + pthis->envXluColor[0] = 0; + pthis->godLgt.type = GOD_LGT_NAYRU; + pthis->godLgt.lightRingSpawnDelay = 4; + pthis->godLgt.rotation = 0; + pthis->godLgt.lightRingSpawnTimer = 0; + pthis->initUpdateFunc = DemoEffect_UpdateGodLgtNayru; + pthis->csActionId = 1; break; case DEMO_EFFECT_GOD_LGT_FARORE: if (gSaveContext.entranceIndex == 0x00EE) { - Actor_SetScale(&this->actor, 2.4f); + Actor_SetScale(&pthis->actor, 2.4f); } else { - Actor_SetScale(&this->actor, 0.1f); + Actor_SetScale(&pthis->actor, 0.1f); } - this->initDrawFunc = DemoEffect_DrawGodLgt; - this->primXluColor[0] = 170; - this->primXluColor[2] = 170; - this->primXluColor[1] = 255; - this->envXluColor[1] = 200; - this->envXluColor[0] = 0; - this->envXluColor[2] = 0; - this->godLgt.type = GOD_LGT_FARORE; - this->godLgt.rotation = 0; - this->initUpdateFunc = DemoEffect_UpdateGodLgtFarore; - this->csActionId = 2; + pthis->initDrawFunc = DemoEffect_DrawGodLgt; + pthis->primXluColor[0] = 170; + pthis->primXluColor[2] = 170; + pthis->primXluColor[1] = 255; + pthis->envXluColor[1] = 200; + pthis->envXluColor[0] = 0; + pthis->envXluColor[2] = 0; + pthis->godLgt.type = GOD_LGT_FARORE; + pthis->godLgt.rotation = 0; + pthis->initUpdateFunc = DemoEffect_UpdateGodLgtFarore; + pthis->csActionId = 2; break; case DEMO_EFFECT_LIGHTRING_EXPANDING: - this->initDrawFunc = DemoEffect_DrawLightRing; - this->initUpdateFunc = DemoEffect_UpdateLightRingExpanding; - this->lightRing.timer = 20; - this->lightRing.timerIncrement = 4; - this->lightRing.alpha = 255; + pthis->initDrawFunc = DemoEffect_DrawLightRing; + pthis->initUpdateFunc = DemoEffect_UpdateLightRingExpanding; + pthis->lightRing.timer = 20; + pthis->lightRing.timerIncrement = 4; + pthis->lightRing.alpha = 255; break; case DEMO_EFFECT_LIGHTRING_TRIFORCE: - this->initDrawFunc = DemoEffect_DrawLightRing; - this->initUpdateFunc = DemoEffect_UpdateLightRingTriforce; - this->lightRing.timer = 20; - this->lightRing.timerIncrement = 4; - this->lightRing.alpha = 0; - this->csActionId = 4; + pthis->initDrawFunc = DemoEffect_DrawLightRing; + pthis->initUpdateFunc = DemoEffect_UpdateLightRingTriforce; + pthis->lightRing.timer = 20; + pthis->lightRing.timerIncrement = 4; + pthis->lightRing.alpha = 0; + pthis->csActionId = 4; break; case DEMO_EFFECT_LIGHTRING_SHRINKING: - this->initDrawFunc = DemoEffect_DrawLightRing; - this->initUpdateFunc = DemoEffect_UpdateLightRingShrinking; - this->lightRing.timer = 351; - this->lightRing.timerIncrement = 2; - this->lightRing.alpha = 0; + pthis->initDrawFunc = DemoEffect_DrawLightRing; + pthis->initUpdateFunc = DemoEffect_UpdateLightRingShrinking; + pthis->lightRing.timer = 351; + pthis->lightRing.timerIncrement = 2; + pthis->lightRing.alpha = 0; break; case DEMO_EFFECT_TRIFORCE_SPOT: - this->initDrawFunc = DemoEffect_DrawTriforceSpot; - this->initUpdateFunc = DemoEffect_UpdateTriforceSpot; - this->triforceSpot.crystalLightOpacity = 0; - this->triforceSpot.lightColumnOpacity = 0; - this->triforceSpot.triforceSpotOpacity = 0; - this->triforceSpot.rotation = 0; - this->primXluColor[0] = 0; - this->csActionId = 3; + pthis->initDrawFunc = DemoEffect_DrawTriforceSpot; + pthis->initUpdateFunc = DemoEffect_UpdateTriforceSpot; + pthis->triforceSpot.crystalLightOpacity = 0; + pthis->triforceSpot.lightColumnOpacity = 0; + pthis->triforceSpot.triforceSpotOpacity = 0; + pthis->triforceSpot.rotation = 0; + pthis->primXluColor[0] = 0; + pthis->csActionId = 3; - Actor_SetScale(&this->actor, 0.020f); + Actor_SetScale(&pthis->actor, 0.020f); crystalLight = (DemoEffect*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_CRYSTAL_LIGHT); + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_CRYSTAL_LIGHT); if (crystalLight != NULL) { Actor_SetScale(&crystalLight->actor, 0.6f); } lightRing = (DemoEffect*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &crystalLight->actor, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_LIGHTRING_TRIFORCE); + &globalCtx->actorCtx, &crystalLight->actor, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_LIGHTRING_TRIFORCE); if (lightRing != NULL) { Actor_SetScale(&lightRing->actor, 0.4f); @@ -440,87 +440,87 @@ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx2) { break; case DEMO_EFFECT_MEDAL_FIRE: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_MEDALLION_FIRE; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_MEDALLION_FIRE; break; case DEMO_EFFECT_MEDAL_WATER: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_MEDALLION_WATER; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_MEDALLION_WATER; break; case DEMO_EFFECT_MEDAL_FOREST: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_MEDALLION_FOREST; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_MEDALLION_FOREST; break; case DEMO_EFFECT_MEDAL_SPIRIT: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_MEDALLION_SPIRIT; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_MEDALLION_SPIRIT; break; case DEMO_EFFECT_MEDAL_SHADOW: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_MEDALLION_SHADOW; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_MEDALLION_SHADOW; break; case DEMO_EFFECT_MEDAL_LIGHT: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_MEDALLION_LIGHT; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_MEDALLION_LIGHT; break; case DEMO_EFFECT_LIGHTARROW: - DemoEffect_InitGetItem(this); - this->getItem.drawId = GID_ARROW_LIGHT; + DemoEffect_InitGetItem(pthis); + pthis->getItem.drawId = GID_ARROW_LIGHT; break; case DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE: case DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL: - this->actor.flags |= ACTOR_FLAG_25; + pthis->actor.flags |= ACTOR_FLAG_25; case DEMO_EFFECT_TIMEWARP_MASTERSWORD: - this->initDrawFunc = DemoEffect_DrawTimeWarp; - this->initUpdateFunc = DemoEffect_InitTimeWarp; - this->envXluColor[0] = 0; - this->envXluColor[1] = 100; - this->envXluColor[2] = 255; - SkelCurve_Clear(&this->skelCurve); - this->timeWarp.shrinkTimer = 0; + pthis->initDrawFunc = DemoEffect_DrawTimeWarp; + pthis->initUpdateFunc = DemoEffect_InitTimeWarp; + pthis->envXluColor[0] = 0; + pthis->envXluColor[1] = 100; + pthis->envXluColor[2] = 255; + SkelCurve_Clear(&pthis->skelCurve); + pthis->timeWarp.shrinkTimer = 0; break; case DEMO_EFFECT_JEWEL_KOKIRI: - this->jewelDisplayList = gGiKokiriEmeraldGemDL; - this->jewelHolderDisplayList = gGiKokiriEmeraldSettingDL; - this->jewel.type = DEMO_EFFECT_JEWEL_KOKIRI; - this->jewel.isPositionInit = 0; - DemoEffect_InitJewel(globalCtx, this); + pthis->jewelDisplayList = gGiKokiriEmeraldGemDL; + pthis->jewelHolderDisplayList = gGiKokiriEmeraldSettingDL; + pthis->jewel.type = DEMO_EFFECT_JEWEL_KOKIRI; + pthis->jewel.isPositionInit = 0; + DemoEffect_InitJewel(globalCtx, pthis); break; case DEMO_EFFECT_JEWEL_GORON: - this->jewelDisplayList = gGiGoronRubyGemDL; - this->jewelHolderDisplayList = gGiGoronRubySettingDL; - this->jewel.type = DEMO_EFFECT_JEWEL_GORON; - this->jewel.isPositionInit = 0; - DemoEffect_InitJewel(globalCtx, this); + pthis->jewelDisplayList = gGiGoronRubyGemDL; + pthis->jewelHolderDisplayList = gGiGoronRubySettingDL; + pthis->jewel.type = DEMO_EFFECT_JEWEL_GORON; + pthis->jewel.isPositionInit = 0; + DemoEffect_InitJewel(globalCtx, pthis); break; case DEMO_EFFECT_JEWEL_ZORA: - this->jewelDisplayList = gGiZoraSapphireGemDL; - this->jewelHolderDisplayList = gGiZoraSapphireSettingDL; - this->jewel.type = DEMO_EFFECT_JEWEL_ZORA; - this->jewel.isPositionInit = 0; - DemoEffect_InitJewel(globalCtx, this); - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTOR_EN_DOOR); + pthis->jewelDisplayList = gGiZoraSapphireGemDL; + pthis->jewelHolderDisplayList = gGiZoraSapphireSettingDL; + pthis->jewel.type = DEMO_EFFECT_JEWEL_ZORA; + pthis->jewel.isPositionInit = 0; + DemoEffect_InitJewel(globalCtx, pthis); + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTOR_EN_DOOR); if ((globalCtx->sceneNum == SCENE_BDAN) && (gSaveContext.infTable[20] & 0x20)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } break; case DEMO_EFFECT_DUST: - this->initDrawFunc = NULL; - this->initUpdateFunc = DemoEffect_UpdateDust; - this->dust.timer = 0; - this->csActionId = 2; + pthis->initDrawFunc = NULL; + pthis->initUpdateFunc = DemoEffect_UpdateDust; + pthis->dust.timer = 0; + pthis->csActionId = 2; break; default: @@ -529,19 +529,19 @@ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx2) { } ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - DemoEffect_SetupUpdate(this, DemoEffect_Wait); + DemoEffect_SetupUpdate(pthis, DemoEffect_Wait); } /** * Main Actor Destroy function */ void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; - s32 effectType = (this->actor.params & 0x00FF); + DemoEffect* pthis = (DemoEffect*)thisx; + s32 effectType = (pthis->actor.params & 0x00FF); if (effectType == DEMO_EFFECT_TIMEWARP_MASTERSWORD || effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE || effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL) { - SkelCurve_Destroy(globalCtx, &this->skelCurve); + SkelCurve_Destroy(globalCtx, &pthis->skelCurve); } } @@ -551,11 +551,11 @@ void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { * They are copied to actor.draw and updateFunc. * initUpdateFunc/initDrawFunc are set during initialization and are NOT executed. */ -void DemoEffect_Wait(DemoEffect* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->initObjectBankIndex)) { - this->actor.objBankIndex = this->initObjectBankIndex; - this->actor.draw = this->initDrawFunc; - this->updateFunc = this->initUpdateFunc; +void DemoEffect_Wait(DemoEffect* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->initObjectBankIndex)) { + pthis->actor.objBankIndex = pthis->initObjectBankIndex; + pthis->actor.draw = pthis->initDrawFunc; + pthis->updateFunc = pthis->initUpdateFunc; osSyncPrintf(VT_FGCOL(CYAN) " 転送終了 move_wait " VT_RST); } @@ -564,12 +564,12 @@ void DemoEffect_Wait(DemoEffect* this, GlobalContext* globalCtx) { /** * Copies the current Actor's position to the parent Actor's position. */ -void DemoEffect_UpdatePositionToParent(DemoEffect* this, GlobalContext* globalCtx) { - if (this->actor.parent != NULL) { +void DemoEffect_UpdatePositionToParent(DemoEffect* pthis, GlobalContext* globalCtx) { + if (pthis->actor.parent != NULL) { // Struct copy affects regalloc - this->actor.world.pos.x = this->actor.parent->world.pos.x; - this->actor.world.pos.y = this->actor.parent->world.pos.y; - this->actor.world.pos.z = this->actor.parent->world.pos.z; + pthis->actor.world.pos.x = pthis->actor.parent->world.pos.x; + pthis->actor.world.pos.y = pthis->actor.parent->world.pos.y; + pthis->actor.world.pos.z = pthis->actor.parent->world.pos.z; } } @@ -579,15 +579,15 @@ void DemoEffect_UpdatePositionToParent(DemoEffect* this, GlobalContext* globalCt * The Crystal Light's position is set to the parent Actor (Triforce) each frame. * If the Crystal Light has no parent Actor, then it will raise into the sky. */ -void DemoEffect_UpdateCrystalLight(DemoEffect* this, GlobalContext* globalCtx) { - DemoEffect_UpdatePositionToParent(this, globalCtx); - this->actor.world.pos.y += 14.0f; +void DemoEffect_UpdateCrystalLight(DemoEffect* pthis, GlobalContext* globalCtx) { + DemoEffect_UpdatePositionToParent(pthis, globalCtx); + pthis->actor.world.pos.y += 14.0f; } /** * Spawns sparkle effects for Medals */ -void DemoEffect_MedalSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 isSmallSpawner) { +void DemoEffect_MedalSparkle(DemoEffect* pthis, GlobalContext* globalCtx, s32 isSmallSpawner) { Vec3f velocity; Vec3f accel; Vec3f pos; @@ -617,9 +617,9 @@ void DemoEffect_MedalSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 isS velocity.z = (Rand_ZeroOne() - 0.5f) * 2.0f; } - pos.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; - pos.y = Rand_CenteredFloat(10.0f) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; + pos.x = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.x; + pos.y = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.z; EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 1000, 16); } @@ -630,51 +630,51 @@ void DemoEffect_MedalSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 isS * Medals and Light Arrows. * It spawns Medal Sparkle Effects and scales/moves the Actor based on the current Cutscene Action */ -void DemoEffect_UpdateGetItem(DemoEffect* this, GlobalContext* globalCtx) { - Actor* thisx = &this->actor; +void DemoEffect_UpdateGetItem(DemoEffect* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->actor; - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL) { - if (this->getItem.isPositionInit) { - DemoEffect_MoveGetItem(this, globalCtx, this->csActionId, 0.1f); + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL) { + if (pthis->getItem.isPositionInit) { + DemoEffect_MoveGetItem(pthis, globalCtx, pthis->csActionId, 0.1f); } else { - DemoEffect_InitPositionFromCsAction(this, globalCtx, this->csActionId); - this->getItem.isPositionInit = 1; + DemoEffect_InitPositionFromCsAction(pthis, globalCtx, pthis->csActionId); + pthis->getItem.isPositionInit = 1; } - if (this->getItem.drawId != GID_ARROW_LIGHT) { - this->actor.shape.rot.x = 0xE0C0; + if (pthis->getItem.drawId != GID_ARROW_LIGHT) { + pthis->actor.shape.rot.x = 0xE0C0; } else { - this->actor.shape.rot.y += 0x0400; + pthis->actor.shape.rot.y += 0x0400; } Actor_SetScale(thisx, 0.20f); if (gSaveContext.entranceIndex == 0x0053) { - switch (globalCtx->csCtx.npcActions[this->csActionId]->action) { + switch (globalCtx->csCtx.npcActions[pthis->csActionId]->action) { case 2: - DemoEffect_MedalSparkle(this, globalCtx, 0); + DemoEffect_MedalSparkle(pthis, globalCtx, 0); break; case 3: - DemoEffect_MedalSparkle(this, globalCtx, 1); + DemoEffect_MedalSparkle(pthis, globalCtx, 1); break; } } - switch (globalCtx->csCtx.npcActions[this->csActionId]->action) { + switch (globalCtx->csCtx.npcActions[pthis->csActionId]->action) { case 2: if (gSaveContext.entranceIndex == 0x0053) { Audio_PlayActorSound2(thisx, NA_SE_EV_MEDAL_APPEAR_L - SFX_FLAG); } else { func_800788CC(NA_SE_EV_MEDAL_APPEAR_S - SFX_FLAG); } - if (this->getItem.drawId != GID_ARROW_LIGHT) { - this->actor.shape.rot.y += 0x3E80; + if (pthis->getItem.drawId != GID_ARROW_LIGHT) { + pthis->actor.shape.rot.y += 0x3E80; } - this->getItem.rotation = 0x3E80; + pthis->getItem.rotation = 0x3E80; break; case 3: - this->getItem.rotation -= (s16)((this->getItem.rotation - 0x03E8) * 0.10f); - if (this->getItem.drawId != GID_ARROW_LIGHT) { - this->actor.shape.rot.y += this->getItem.rotation; + pthis->getItem.rotation -= (s16)((pthis->getItem.rotation - 0x03E8) * 0.10f); + if (pthis->getItem.drawId != GID_ARROW_LIGHT) { + pthis->actor.shape.rot.y += pthis->getItem.rotation; } if (gSaveContext.entranceIndex == 0x0053) { Audio_PlayActorSound2(thisx, NA_SE_EV_MEDAL_APPEAR_L - SFX_FLAG); @@ -697,33 +697,33 @@ void DemoEffect_UpdateGetItem(DemoEffect* this, GlobalContext* globalCtx) { * 2) Returns from the Chamber of Sages for the first time * 3) Timeblock is cleared with the Song of Time (Large and Small have different versions of Timewarp) */ -void DemoEffect_InitTimeWarp(DemoEffect* this, GlobalContext* globalCtx) { - s32 effectType = (this->actor.params & 0x00FF); +void DemoEffect_InitTimeWarp(DemoEffect* pthis, GlobalContext* globalCtx) { + s32 effectType = (pthis->actor.params & 0x00FF); - if (!SkelCurve_Init(globalCtx, &this->skelCurve, &gTimeWarpSkel, &gTimeWarpAnim)) { + if (!SkelCurve_Init(globalCtx, &pthis->skelCurve, &gTimeWarpSkel, &gTimeWarpAnim)) { ASSERT(0, "0", "../z_demo_effect.c", 1283); } if (effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE || effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 1.0f, 1.7f); - SkelCurve_Update(globalCtx, &this->skelCurve); - this->updateFunc = DemoEffect_InitTimeWarpTimeblock; + SkelCurve_SetAnim(&pthis->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 1.0f, 1.7f); + SkelCurve_Update(globalCtx, &pthis->skelCurve); + pthis->updateFunc = DemoEffect_InitTimeWarpTimeblock; if (effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE) { - Actor_SetScale(&this->actor, 0.14f); + Actor_SetScale(&pthis->actor, 0.14f); } else { - Actor_SetScale(&this->actor, 84 * 0.001f); + Actor_SetScale(&pthis->actor, 84 * 0.001f); } } else if (gSaveContext.sceneSetupIndex == 5 || gSaveContext.sceneSetupIndex == 4 || (gSaveContext.entranceIndex == 0x0324 && !((gSaveContext.eventChkInf[12] & 0x200)))) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 59.0f, 0.0f); - SkelCurve_Update(globalCtx, &this->skelCurve); - this->updateFunc = DemoEffect_UpdateTimeWarpReturnFromChamberOfSages; + SkelCurve_SetAnim(&pthis->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 59.0f, 0.0f); + SkelCurve_Update(globalCtx, &pthis->skelCurve); + pthis->updateFunc = DemoEffect_UpdateTimeWarpReturnFromChamberOfSages; osSyncPrintf(VT_FGCOL(CYAN) " 縮むバージョン \n" VT_RST); } else { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 1.0f, 1.0f); - SkelCurve_Update(globalCtx, &this->skelCurve); - this->updateFunc = DemoEffect_UpdateTimeWarpPullMasterSword; + SkelCurve_SetAnim(&pthis->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 1.0f, 1.0f); + SkelCurve_Update(globalCtx, &pthis->skelCurve); + pthis->updateFunc = DemoEffect_UpdateTimeWarpPullMasterSword; osSyncPrintf(VT_FGCOL(CYAN) " 通常 バージョン \n" VT_RST); } } @@ -732,15 +732,15 @@ void DemoEffect_InitTimeWarp(DemoEffect* this, GlobalContext* globalCtx) { * Update function for the Timewarp Actor that is used when Link pulls the Mastersword * It changes the Background Music and updates its SkelCurve animation. */ -void DemoEffect_UpdateTimeWarpPullMasterSword(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateTimeWarpPullMasterSword(DemoEffect* pthis, GlobalContext* globalCtx) { if (Flags_GetEnv(globalCtx, 1)) { - if (!(this->effectFlags & 0x2)) { + if (!(pthis->effectFlags & 0x2)) { func_800F3F3C(0); - this->effectFlags |= 0x2; + pthis->effectFlags |= 0x2; } - if (SkelCurve_Update(globalCtx, &this->skelCurve)) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 60.0f, 59.0f, 0.0f); + if (SkelCurve_Update(globalCtx, &pthis->skelCurve)) { + SkelCurve_SetAnim(&pthis->skelCurve, &gTimeWarpAnim, 1.0f, 60.0f, 59.0f, 0.0f); } } } @@ -772,70 +772,70 @@ void DemoEffect_TimewarpShrink(f32 size) { * Update function for the Timewarp Actor that is used when Link returns from the Chamber of Sages for the first time. * It shrinks the timewarp vertices and scales the Actor. */ -void DemoEffect_UpdateTimeWarpReturnFromChamberOfSages(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateTimeWarpReturnFromChamberOfSages(DemoEffect* pthis, GlobalContext* globalCtx) { f32 shrinkProgress; - this->timeWarp.shrinkTimer++; + pthis->timeWarp.shrinkTimer++; - if (this->timeWarp.shrinkTimer > 250) { + if (pthis->timeWarp.shrinkTimer > 250) { if (gSaveContext.entranceIndex == 0x0324) { gSaveContext.eventChkInf[12] |= 0x200; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->timeWarp.shrinkTimer > 100) { - shrinkProgress = (250 - this->timeWarp.shrinkTimer) * (1.0f / 750.0f); - this->actor.scale.x = shrinkProgress; - this->actor.scale.z = shrinkProgress; + if (pthis->timeWarp.shrinkTimer > 100) { + shrinkProgress = (250 - pthis->timeWarp.shrinkTimer) * (1.0f / 750.0f); + pthis->actor.scale.x = shrinkProgress; + pthis->actor.scale.z = shrinkProgress; DemoEffect_TimewarpShrink(shrinkProgress * 5.0f); } - func_8002F948(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); } /** * Update function for the Timewarp Actor that is used when a Timeblock is cleared. * It shrinks the timewarp vertices and scales the Actor. */ -void DemoEffect_UpdateTimeWarpTimeblock(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateTimeWarpTimeblock(DemoEffect* pthis, GlobalContext* globalCtx) { f32 shrinkProgress; f32 scale; - this->timeWarp.shrinkTimer++; + pthis->timeWarp.shrinkTimer++; - if (this->timeWarp.shrinkTimer <= 100) { - shrinkProgress = (100 - this->timeWarp.shrinkTimer) * 0.010f; + if (pthis->timeWarp.shrinkTimer <= 100) { + shrinkProgress = (100 - pthis->timeWarp.shrinkTimer) * 0.010f; scale = shrinkProgress * 0.14f; - if ((this->actor.params & 0x00FF) == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL) { + if ((pthis->actor.params & 0x00FF) == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL) { scale *= 0.6f; } - this->actor.scale.x = scale; - this->actor.scale.z = scale; + pthis->actor.scale.x = scale; + pthis->actor.scale.z = scale; DemoEffect_TimewarpShrink(shrinkProgress); - func_8002F948(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + func_8002F948(&pthis->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); return; } DemoEffect_TimewarpShrink(1.0f); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } /** * Initializes information for the Timewarp Actor used for the Timeblock clear effect. * This is an Update Func that is only ran for one frame. */ -void DemoEffect_InitTimeWarpTimeblock(DemoEffect* this, GlobalContext* globalCtx) { - func_8002F948(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); +void DemoEffect_InitTimeWarpTimeblock(DemoEffect* pthis, GlobalContext* globalCtx) { + func_8002F948(&pthis->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); - if (SkelCurve_Update(globalCtx, &this->skelCurve)) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 60.0f, 59.0f, 0.0f); - this->updateFunc = DemoEffect_UpdateTimeWarpTimeblock; - this->timeWarp.shrinkTimer = 0; + if (SkelCurve_Update(globalCtx, &pthis->skelCurve)) { + SkelCurve_SetAnim(&pthis->skelCurve, &gTimeWarpAnim, 1.0f, 60.0f, 59.0f, 0.0f); + pthis->updateFunc = DemoEffect_UpdateTimeWarpTimeblock; + pthis->timeWarp.shrinkTimer = 0; } } @@ -843,28 +843,28 @@ void DemoEffect_InitTimeWarpTimeblock(DemoEffect* this, GlobalContext* globalCtx * Update function for the Triforce Actor. * It rotates and updates the alpha of the Triforce and child actors. */ -void DemoEffect_UpdateTriforceSpot(DemoEffect* this, GlobalContext* globalCtx) { - this->triforceSpot.rotation += 0x03E8; +void DemoEffect_UpdateTriforceSpot(DemoEffect* pthis, GlobalContext* globalCtx) { + pthis->triforceSpot.rotation += 0x03E8; - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL) { - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 0); + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL) { + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 0); - if (globalCtx->csCtx.npcActions[this->csActionId]->action == 2) { - if (this->primXluColor[0] < 140) { - this->primXluColor[0]++; + if (globalCtx->csCtx.npcActions[pthis->csActionId]->action == 2) { + if (pthis->primXluColor[0] < 140) { + pthis->primXluColor[0]++; } - if (this->primXluColor[0] < 30) { - this->triforceSpot.triforceSpotOpacity = ((s32)this->primXluColor[0]) * 8.5f; + if (pthis->primXluColor[0] < 30) { + pthis->triforceSpot.triforceSpotOpacity = ((s32)pthis->primXluColor[0]) * 8.5f; } else { - this->triforceSpot.triforceSpotOpacity = 255; + pthis->triforceSpot.triforceSpotOpacity = 255; - if (this->primXluColor[0] < 60) { - this->triforceSpot.lightColumnOpacity = (((s32)this->primXluColor[0]) - 30) * 8.5f; + if (pthis->primXluColor[0] < 60) { + pthis->triforceSpot.lightColumnOpacity = (((s32)pthis->primXluColor[0]) - 30) * 8.5f; } else { - if (this->primXluColor[0] <= 140) { - this->triforceSpot.lightColumnOpacity = 255; - this->triforceSpot.crystalLightOpacity = (((s32)this->primXluColor[0]) - 60) * 3.1875f; + if (pthis->primXluColor[0] <= 140) { + pthis->triforceSpot.lightColumnOpacity = 255; + pthis->triforceSpot.crystalLightOpacity = (((s32)pthis->primXluColor[0]) - 60) * 3.1875f; } } } @@ -872,7 +872,7 @@ void DemoEffect_UpdateTriforceSpot(DemoEffect* this, GlobalContext* globalCtx) { if (gSaveContext.entranceIndex == 0x00A0 && gSaveContext.sceneSetupIndex == 6 && globalCtx->csCtx.frames == 143) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_RING_EXPLOSION); } } } @@ -881,23 +881,23 @@ void DemoEffect_UpdateTriforceSpot(DemoEffect* this, GlobalContext* globalCtx) { * Update function for the LightRing actor that shrinks. * This is used in the creation cutscene when Din leaves a fireball that explodes into Death Mountain. */ -void DemoEffect_UpdateLightRingShrinking(DemoEffect* this, GlobalContext* globalCtx) { - if (this->lightRing.timer < this->lightRing.timerIncrement) { - Actor_Kill(&this->actor); - this->lightRing.timer = 0; +void DemoEffect_UpdateLightRingShrinking(DemoEffect* pthis, GlobalContext* globalCtx) { + if (pthis->lightRing.timer < pthis->lightRing.timerIncrement) { + Actor_Kill(&pthis->actor); + pthis->lightRing.timer = 0; } else { - this->lightRing.timer -= this->lightRing.timerIncrement; + pthis->lightRing.timer -= pthis->lightRing.timerIncrement; } - if (this->lightRing.timer <= 255) { - if (this->lightRing.timer >= 225) { - this->lightRing.alpha = (-this->lightRing.timer * 8) + 2048; + if (pthis->lightRing.timer <= 255) { + if (pthis->lightRing.timer >= 225) { + pthis->lightRing.alpha = (-pthis->lightRing.timer * 8) + 2048; } else { - this->lightRing.alpha = 255; + pthis->lightRing.alpha = 255; } } - if (this->lightRing.timer == 255) { + if (pthis->lightRing.timer == 255) { func_800F3F3C(5); } } @@ -907,17 +907,17 @@ void DemoEffect_UpdateLightRingShrinking(DemoEffect* this, GlobalContext* global * These are spawned by Nayru. * These are also used by Din in the creation cutscene when she leaves a fireball that explodes into Death Mountain. */ -void DemoEffect_UpdateLightRingExpanding(DemoEffect* this, GlobalContext* globalCtx) { - DemoEffect_UpdatePositionToParent(this, globalCtx); - this->lightRing.timer += this->lightRing.timerIncrement; +void DemoEffect_UpdateLightRingExpanding(DemoEffect* pthis, GlobalContext* globalCtx) { + DemoEffect_UpdatePositionToParent(pthis, globalCtx); + pthis->lightRing.timer += pthis->lightRing.timerIncrement; - if (this->lightRing.timer >= 225) { - this->lightRing.alpha = (-this->lightRing.timer * 8) + 2048; + if (pthis->lightRing.timer >= 225) { + pthis->lightRing.alpha = (-pthis->lightRing.timer * 8) + 2048; } - if (this->lightRing.timer > 255) { - this->lightRing.timer = 255; - Actor_Kill(&this->actor); - this->lightRing.timer = 0; + if (pthis->lightRing.timer > 255) { + pthis->lightRing.timer = 255; + Actor_Kill(&pthis->actor); + pthis->lightRing.timer = 0; } } @@ -926,24 +926,24 @@ void DemoEffect_UpdateLightRingExpanding(DemoEffect* this, GlobalContext* global * This version spawns a blue orb when the cutscene action state is set to 2. * Once the Blue Orb Actor is spawned the Update Function is changed to the regular Light Ring Expanding Update Func. */ -void DemoEffect_UpdateLightRingTriforce(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateLightRingTriforce(DemoEffect* pthis, GlobalContext* globalCtx) { DemoEffect* blueOrb; - DemoEffect_UpdatePositionToParent(this, globalCtx); + DemoEffect_UpdatePositionToParent(pthis, globalCtx); if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if (globalCtx->csCtx.npcActions[this->csActionId] != NULL && - globalCtx->csCtx.npcActions[this->csActionId]->action == 2) { + if (globalCtx->csCtx.npcActions[pthis->csActionId] != NULL && + globalCtx->csCtx.npcActions[pthis->csActionId]->action == 2) { blueOrb = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_BLUE_ORB); + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_BLUE_ORB); if (blueOrb != NULL) { Actor_SetScale(&blueOrb->actor, 0.0f); } - this->updateFunc = DemoEffect_UpdateLightRingExpanding; - this->lightRing.alpha = 255; + pthis->updateFunc = DemoEffect_UpdateLightRingExpanding; + pthis->lightRing.alpha = 255; } } } @@ -954,39 +954,39 @@ void DemoEffect_UpdateLightRingTriforce(DemoEffect* this, GlobalContext* globalC * It moves based on gravity and decrements a timer until zero. Once the timer is zero it will spawn other Actors: * A Blue Orb Actor, and a Light Ring Expanding Actor, and a Light Ring Shrinking Actor. */ -void DemoEffect_UpdateCreationFireball(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateCreationFireball(DemoEffect* pthis, GlobalContext* globalCtx) { DemoEffect* effect; - Actor_MoveForward(&this->actor); - this->actor.speedXZ = this->actor.speedXZ + (this->actor.gravity * 0.5f); + Actor_MoveForward(&pthis->actor); + pthis->actor.speedXZ = pthis->actor.speedXZ + (pthis->actor.gravity * 0.5f); - if (this->fireBall.timer != 0) { - this->fireBall.timer--; + if (pthis->fireBall.timer != 0) { + pthis->fireBall.timer--; return; } - effect = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_BLUE_ORB); + effect = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_BLUE_ORB); if (effect != NULL) { Actor_SetScale(&effect->actor, 0.0f); } - effect = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, + effect = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_LIGHTRING_EXPANDING); if (effect != NULL) { Actor_SetScale(&effect->actor, 0.1f); } - effect = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, + effect = (DemoEffect*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_LIGHTRING_SHRINKING); if (effect != NULL) { Actor_SetScale(&effect->actor, 0.2f); } func_800788CC(NA_SE_IT_DM_RING_EXPLOSION); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } /** @@ -994,15 +994,15 @@ void DemoEffect_UpdateCreationFireball(DemoEffect* this, GlobalContext* globalCt * This is a special version that is used in the creation cutscene. * It is an Update Function only executed for one frame. The Update Function is then changed to UpdateCreationFireball. */ -void DemoEffect_InitCreationFireball(DemoEffect* this, GlobalContext* globalCtx) { - Actor* parent = this->actor.parent; +void DemoEffect_InitCreationFireball(DemoEffect* pthis, GlobalContext* globalCtx) { + Actor* parent = pthis->actor.parent; - this->actor.world.rot.y = parent->shape.rot.y; - this->fireBall.timer = 50; - this->actor.speedXZ = 1.5f; - this->actor.minVelocityY = -1.5f; - this->actor.gravity = -0.03f; - this->updateFunc = DemoEffect_UpdateCreationFireball; + pthis->actor.world.rot.y = parent->shape.rot.y; + pthis->fireBall.timer = 50; + pthis->actor.speedXZ = 1.5f; + pthis->actor.minVelocityY = -1.5f; + pthis->actor.gravity = -0.03f; + pthis->updateFunc = DemoEffect_UpdateCreationFireball; } /** @@ -1012,12 +1012,12 @@ void DemoEffect_InitCreationFireball(DemoEffect* this, GlobalContext* globalCtx) * It's spawned in the middle of the expanding Light Ring. * The Blue Orb Actor shrinks after it grows to max size. */ -void DemoEffect_UpdateBlueOrbShrink(DemoEffect* this, GlobalContext* globalCtx) { - this->blueOrb.alpha = this->blueOrb.scale * 16; - this->blueOrb.scale--; - Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); - if (this->blueOrb.scale == 0) { - Actor_Kill(&this->actor); +void DemoEffect_UpdateBlueOrbShrink(DemoEffect* pthis, GlobalContext* globalCtx) { + pthis->blueOrb.alpha = pthis->blueOrb.scale * 16; + pthis->blueOrb.scale--; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x * 0.9f); + if (pthis->blueOrb.scale == 0) { + Actor_Kill(&pthis->actor); } } @@ -1028,21 +1028,21 @@ void DemoEffect_UpdateBlueOrbShrink(DemoEffect* this, GlobalContext* globalCtx) * It's spawned in the middle of the expanding Light Ring. * When the scale timer value reaches 0 the Blue Orb's Update Function changes to UpdateBlueOrbShrink. */ -void DemoEffect_UpdateBlueOrbGrow(DemoEffect* this, GlobalContext* globalCtx) { - if (this->actor.parent != NULL) { +void DemoEffect_UpdateBlueOrbGrow(DemoEffect* pthis, GlobalContext* globalCtx) { + if (pthis->actor.parent != NULL) { // s32 cast necessary to match codegen. Without the explicit cast to u32 the compiler generates complex cast of // u8 to float - Actor_SetScale(&this->actor, - (((5.0f - (s32)this->blueOrb.scale) * 0.01f) * 10.0f) * this->actor.parent->scale.x); + Actor_SetScale(&pthis->actor, + (((5.0f - (s32)pthis->blueOrb.scale) * 0.01f) * 10.0f) * pthis->actor.parent->scale.x); } else { - Actor_SetScale(&this->actor, (5.0f - (s32)this->blueOrb.scale) * 0.01f); + Actor_SetScale(&pthis->actor, (5.0f - (s32)pthis->blueOrb.scale) * 0.01f); } - if (this->blueOrb.scale != 0) { - this->blueOrb.scale--; + if (pthis->blueOrb.scale != 0) { + pthis->blueOrb.scale--; } else { - this->blueOrb.scale = 15; - this->updateFunc = DemoEffect_UpdateBlueOrbShrink; + pthis->blueOrb.scale = 15; + pthis->updateFunc = DemoEffect_UpdateBlueOrbShrink; } } @@ -1051,36 +1051,36 @@ void DemoEffect_UpdateBlueOrbGrow(DemoEffect* this, GlobalContext* globalCtx) { * The Light Effect has various use cases. * This function updates the position and scale of the actor based on the current cutscene command. */ -void DemoEffect_UpdateLightEffect(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateLightEffect(DemoEffect* pthis, GlobalContext* globalCtx) { u16 action; s32 isLargeSize; - isLargeSize = ((this->actor.params & 0x0F00) >> 8); + isLargeSize = ((pthis->actor.params & 0x0F00) >> 8); - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL) { - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 0); - switch (globalCtx->csCtx.npcActions[this->csActionId]->action) { + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL) { + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 0); + switch (globalCtx->csCtx.npcActions[pthis->csActionId]->action) { case 2: - if (this->light.rotation < 240) { + if (pthis->light.rotation < 240) { if (!isLargeSize) { - if (this->actor.scale.x < 0.23f) { - this->actor.scale.x += 0.001f; - Actor_SetScale(&this->actor, this->actor.scale.x); + if (pthis->actor.scale.x < 0.23f) { + pthis->actor.scale.x += 0.001f; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); } } else { - if (this->actor.scale.x < 2.03f) { - this->actor.scale.x += 0.05f; - Actor_SetScale(&this->actor, this->actor.scale.x); + if (pthis->actor.scale.x < 2.03f) { + pthis->actor.scale.x += 0.05f; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); } } } - this->light.rotation += 6; - this->light.scaleFlag += 1; + pthis->light.rotation += 6; + pthis->light.scaleFlag += 1; break; case 3: - Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 0.1f, 0.1f, 0.005f); - Actor_SetScale(&this->actor, this->actor.scale.x); + Math_SmoothStepToF(&pthis->actor.scale.x, 0.0f, 0.1f, 0.1f, 0.005f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); break; default: @@ -1089,26 +1089,26 @@ void DemoEffect_UpdateLightEffect(DemoEffect* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_SPOT04 && gSaveContext.sceneSetupIndex == 6 && globalCtx->csCtx.frames == 197) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WHITE_OUT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WHITE_OUT); } if (globalCtx->sceneNum == SCENE_SPOT16 && gSaveContext.sceneSetupIndex == 5) { - if (!DemoEffect_CheckCsAction(this, globalCtx, 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 1)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); } if (globalCtx->csCtx.frames == 640) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WHITE_OUT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WHITE_OUT); } if (0) {} } if (globalCtx->sceneNum == SCENE_SPOT08 && gSaveContext.sceneSetupIndex == 4) { - if (!DemoEffect_CheckCsAction(this, globalCtx, 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 1)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); } if (globalCtx->csCtx.frames == 648) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WHITE_OUT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WHITE_OUT); } // Necessary to match @@ -1118,14 +1118,14 @@ void DemoEffect_UpdateLightEffect(DemoEffect* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_TOKINOMA && gSaveContext.sceneSetupIndex == 14) { if (1) {} - if (globalCtx->csCtx.npcActions[this->csActionId]->action == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + if (globalCtx->csCtx.npcActions[pthis->csActionId]->action == 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); } } if (globalCtx->sceneNum == SCENE_DAIYOUSEI_IZUMI || globalCtx->sceneNum == SCENE_YOUSEI_IZUMI_YOKO) { - if (globalCtx->csCtx.npcActions[this->csActionId]->action == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); + if (globalCtx->csCtx.npcActions[pthis->csActionId]->action == 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_LIGHT_GATHER - SFX_FLAG); } } } @@ -1136,14 +1136,14 @@ void DemoEffect_UpdateLightEffect(DemoEffect* this, GlobalContext* globalCtx) { * The Lgt Shower Actor is the green light effect spawned by Farore in the Kokiri Forst creation cutscene. * This function updates the scale and alpha of the Actor. */ -void DemoEffect_UpdateLgtShower(DemoEffect* this, GlobalContext* globalCtx) { - if (this->lgtShower.alpha > 3) { - this->lgtShower.alpha -= 3; - this->actor.scale.x *= 1.05f; - this->actor.scale.y *= 1.05f; - this->actor.scale.z *= 1.05f; +void DemoEffect_UpdateLgtShower(DemoEffect* pthis, GlobalContext* globalCtx) { + if (pthis->lgtShower.alpha > 3) { + pthis->lgtShower.alpha -= 3; + pthis->actor.scale.x *= 1.05f; + pthis->actor.scale.y *= 1.05f; + pthis->actor.scale.z *= 1.05f; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } @@ -1152,18 +1152,18 @@ void DemoEffect_UpdateLgtShower(DemoEffect* this, GlobalContext* globalCtx) { * This is the Goddess Din. * This function moves God Lgt Din based on the current cutscene command. * This function also spawns a Fireball Actor and sets its update function to the special InitCreationFireball. - * The spawned Fireball Actor is also scaled to be smaller than regular by this function. + * The spawned Fireball Actor is also scaled to be smaller than regular by pthis function. */ -void DemoEffect_UpdateGodLgtDin(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateGodLgtDin(DemoEffect* pthis, GlobalContext* globalCtx) { DemoEffect* fireBall; - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL) { - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 1); + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL) { + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 1); - if (globalCtx->csCtx.npcActions[this->csActionId]->action == 3) { - fireBall = (DemoEffect*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_FIRE_BALL); + if (globalCtx->csCtx.npcActions[pthis->csActionId]->action == 3) { + fireBall = (DemoEffect*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_FIRE_BALL); if (fireBall != NULL) { fireBall->initUpdateFunc = DemoEffect_InitCreationFireball; @@ -1175,22 +1175,22 @@ void DemoEffect_UpdateGodLgtDin(DemoEffect* this, GlobalContext* globalCtx) { switch (gSaveContext.sceneSetupIndex) { case 4: if (globalCtx->csCtx.frames == 288) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_PASS); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_PASS); } if (globalCtx->csCtx.frames == 635) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_PASS); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_PASS); } break; case 6: if (globalCtx->csCtx.frames == 55) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } break; case 11: if (globalCtx->csCtx.frames == 350) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } break; } @@ -1204,21 +1204,21 @@ void DemoEffect_UpdateGodLgtDin(DemoEffect* this, GlobalContext* globalCtx) { * This function moves God Lgt Nayure based on the current cutscene command. * This function also spawns expanding light rings around Nayru in the creation cutscene */ -void DemoEffect_UpdateGodLgtNayru(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateGodLgtNayru(DemoEffect* pthis, GlobalContext* globalCtx) { DemoEffect* lightRing; - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL) { - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 1); + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL) { + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 1); - if (globalCtx->csCtx.npcActions[this->csActionId]->action == 3) { - if (this->godLgt.lightRingSpawnTimer != 0) { - this->godLgt.lightRingSpawnTimer--; + if (globalCtx->csCtx.npcActions[pthis->csActionId]->action == 3) { + if (pthis->godLgt.lightRingSpawnTimer != 0) { + pthis->godLgt.lightRingSpawnTimer--; } else { - this->godLgt.lightRingSpawnTimer = this->godLgt.lightRingSpawnDelay; + pthis->godLgt.lightRingSpawnTimer = pthis->godLgt.lightRingSpawnDelay; lightRing = (DemoEffect*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x + 0x4000, - this->actor.world.rot.y, this->actor.world.rot.z, DEMO_EFFECT_LIGHTRING_EXPANDING); + &globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, pthis->actor.world.rot.x + 0x4000, + pthis->actor.world.rot.y, pthis->actor.world.rot.z, DEMO_EFFECT_LIGHTRING_EXPANDING); if (lightRing != NULL) { Actor_SetScale(&lightRing->actor, 1.0f); @@ -1230,19 +1230,19 @@ void DemoEffect_UpdateGodLgtNayru(DemoEffect* this, GlobalContext* globalCtx) { switch (gSaveContext.sceneSetupIndex) { case 4: if (globalCtx->csCtx.frames == 298) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_PASS); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_PASS); } break; case 6: if (globalCtx->csCtx.frames == 105) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } break; case 11: if (globalCtx->csCtx.frames == 360) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } break; } @@ -1250,7 +1250,7 @@ void DemoEffect_UpdateGodLgtNayru(DemoEffect* this, GlobalContext* globalCtx) { if (gSaveContext.entranceIndex == 0x013D && gSaveContext.sceneSetupIndex == 4) { if (globalCtx->csCtx.frames == 72) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } if (globalCtx->csCtx.frames == 80) { func_800F3F3C(4); @@ -1265,16 +1265,16 @@ void DemoEffect_UpdateGodLgtNayru(DemoEffect* this, GlobalContext* globalCtx) { * This function moves God Lgt Farore based on the current cutscene command. * This function also spawns an Lgt Shower Actor during the Kokiri creation cutscene. */ -void DemoEffect_UpdateGodLgtFarore(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateGodLgtFarore(DemoEffect* pthis, GlobalContext* globalCtx) { DemoEffect* lgtShower; - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL) { - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 1); + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL) { + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 1); - if (globalCtx->csCtx.npcActions[this->csActionId]->action == 3) { + if (globalCtx->csCtx.npcActions[pthis->csActionId]->action == 3) { lgtShower = (DemoEffect*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y - 150.0f, this->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_LGT_SHOWER); + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y - 150.0f, pthis->actor.world.pos.z, 0, 0, 0, DEMO_EFFECT_LGT_SHOWER); if (lgtShower != NULL) { lgtShower->actor.scale.x = 0.23f; @@ -1282,7 +1282,7 @@ void DemoEffect_UpdateGodLgtFarore(DemoEffect* this, GlobalContext* globalCtx) { lgtShower->actor.scale.z = 0.23f; } - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); func_800F3F3C(3); } @@ -1290,19 +1290,19 @@ void DemoEffect_UpdateGodLgtFarore(DemoEffect* this, GlobalContext* globalCtx) { switch (gSaveContext.sceneSetupIndex) { case 4: if (globalCtx->csCtx.frames == 315) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_PASS); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_PASS); } break; case 6: if (globalCtx->csCtx.frames == 80) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } break; case 11: if (globalCtx->csCtx.frames == 370) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_FLYING_GOD_DASH); } break; } @@ -1311,64 +1311,64 @@ void DemoEffect_UpdateGodLgtFarore(DemoEffect* this, GlobalContext* globalCtx) { } /** - * Moves this actor towards the target position with a given speed. + * Moves pthis actor towards the target position with a given speed. */ -void DemoEffect_MoveTowardTarget(Vec3f targetPos, DemoEffect* this, f32 speed) { - this->actor.world.pos.x += (targetPos.x - this->actor.world.pos.x) * speed; - this->actor.world.pos.y += (targetPos.y - this->actor.world.pos.y) * speed; - this->actor.world.pos.z += (targetPos.z - this->actor.world.pos.z) * speed; +void DemoEffect_MoveTowardTarget(Vec3f targetPos, DemoEffect* pthis, f32 speed) { + pthis->actor.world.pos.x += (targetPos.x - pthis->actor.world.pos.x) * speed; + pthis->actor.world.pos.y += (targetPos.y - pthis->actor.world.pos.y) * speed; + pthis->actor.world.pos.z += (targetPos.z - pthis->actor.world.pos.z) * speed; } /** * Initializes Jewel colors. */ -void DemoEffect_InitJewelColor(DemoEffect* this) { - u8 jewelType = this->jewel.type; +void DemoEffect_InitJewelColor(DemoEffect* pthis) { + u8 jewelType = pthis->jewel.type; switch (jewelType) { case DEMO_EFFECT_JEWEL_KOKIRI: - this->primXluColor[2] = 160; - this->primXluColor[0] = 255; - this->primXluColor[1] = 255; - this->envXluColor[0] = 0; - this->envXluColor[1] = 255; - this->envXluColor[2] = 0; - this->primOpaColor[2] = 170; - this->primOpaColor[0] = 255; - this->primOpaColor[1] = 255; - this->envOpaColor[1] = 120; - this->envOpaColor[0] = 150; - this->envOpaColor[2] = 0; + pthis->primXluColor[2] = 160; + pthis->primXluColor[0] = 255; + pthis->primXluColor[1] = 255; + pthis->envXluColor[0] = 0; + pthis->envXluColor[1] = 255; + pthis->envXluColor[2] = 0; + pthis->primOpaColor[2] = 170; + pthis->primOpaColor[0] = 255; + pthis->primOpaColor[1] = 255; + pthis->envOpaColor[1] = 120; + pthis->envOpaColor[0] = 150; + pthis->envOpaColor[2] = 0; break; case DEMO_EFFECT_JEWEL_GORON: - this->primXluColor[1] = 170; - this->primXluColor[0] = 255; - this->primXluColor[2] = 255; - this->envXluColor[2] = 100; - this->envXluColor[0] = 255; - this->envXluColor[1] = 0; - this->primOpaColor[2] = 170; - this->primOpaColor[0] = 255; - this->primOpaColor[1] = 255; - this->envOpaColor[1] = 120; - this->envOpaColor[0] = 150; - this->envOpaColor[2] = 0; + pthis->primXluColor[1] = 170; + pthis->primXluColor[0] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[2] = 100; + pthis->envXluColor[0] = 255; + pthis->envXluColor[1] = 0; + pthis->primOpaColor[2] = 170; + pthis->primOpaColor[0] = 255; + pthis->primOpaColor[1] = 255; + pthis->envOpaColor[1] = 120; + pthis->envOpaColor[0] = 150; + pthis->envOpaColor[2] = 0; break; case DEMO_EFFECT_JEWEL_ZORA: - this->primXluColor[0] = 50; - this->primXluColor[1] = 255; - this->primXluColor[2] = 255; - this->envXluColor[2] = 150; - this->envXluColor[0] = 50; - this->envXluColor[1] = 0; - this->primOpaColor[2] = 170; - this->primOpaColor[0] = 255; - this->primOpaColor[1] = 255; - this->envOpaColor[1] = 120; - this->envOpaColor[0] = 150; - this->envOpaColor[2] = 0; + pthis->primXluColor[0] = 50; + pthis->primXluColor[1] = 255; + pthis->primXluColor[2] = 255; + pthis->envXluColor[2] = 150; + pthis->envXluColor[0] = 50; + pthis->envXluColor[1] = 0; + pthis->primOpaColor[2] = 170; + pthis->primOpaColor[0] = 255; + pthis->primOpaColor[1] = 255; + pthis->envOpaColor[1] = 120; + pthis->envOpaColor[0] = 150; + pthis->envOpaColor[2] = 0; break; } } @@ -1378,29 +1378,29 @@ void DemoEffect_InitJewelColor(DemoEffect* this) { * This function if a value of less than 1.0f is supplied will drain the color from the Jewels. * This effect can be seen in prerelease screenshots. */ -void DemoEffect_SetJewelColor(DemoEffect* this, f32 alpha) { - DemoEffect_InitJewelColor(this); +void DemoEffect_SetJewelColor(DemoEffect* pthis, f32 alpha) { + DemoEffect_InitJewelColor(pthis); - this->primXluColor[0] = (((s32)this->primXluColor[0]) * alpha) + (255.0f * (1.0f - alpha)); - this->primXluColor[1] = (((s32)this->primXluColor[1]) * alpha) + (255.0f * (1.0f - alpha)); - this->primXluColor[2] = (((s32)this->primXluColor[2]) * alpha) + (255.0f * (1.0f - alpha)); - this->primOpaColor[0] = (((s32)this->primOpaColor[0]) * alpha) + (255.0f * (1.0f - alpha)); - this->primOpaColor[1] = (((s32)this->primOpaColor[1]) * alpha) + (255.0f * (1.0f - alpha)); - this->primOpaColor[2] = (((s32)this->primOpaColor[2]) * alpha) + (255.0f * (1.0f - alpha)); - this->envXluColor[0] = ((s32)this->envXluColor[0]) * alpha; - this->envXluColor[1] = ((s32)this->envXluColor[1]) * alpha; - this->envXluColor[2] = ((s32)this->envXluColor[2]) * alpha; - this->envOpaColor[0] = ((s32)this->envOpaColor[0]) * alpha; - this->envOpaColor[1] = ((s32)this->envOpaColor[1]) * alpha; - this->envOpaColor[2] = ((s32)this->envOpaColor[2]) * alpha; + pthis->primXluColor[0] = (((s32)pthis->primXluColor[0]) * alpha) + (255.0f * (1.0f - alpha)); + pthis->primXluColor[1] = (((s32)pthis->primXluColor[1]) * alpha) + (255.0f * (1.0f - alpha)); + pthis->primXluColor[2] = (((s32)pthis->primXluColor[2]) * alpha) + (255.0f * (1.0f - alpha)); + pthis->primOpaColor[0] = (((s32)pthis->primOpaColor[0]) * alpha) + (255.0f * (1.0f - alpha)); + pthis->primOpaColor[1] = (((s32)pthis->primOpaColor[1]) * alpha) + (255.0f * (1.0f - alpha)); + pthis->primOpaColor[2] = (((s32)pthis->primOpaColor[2]) * alpha) + (255.0f * (1.0f - alpha)); + pthis->envXluColor[0] = ((s32)pthis->envXluColor[0]) * alpha; + pthis->envXluColor[1] = ((s32)pthis->envXluColor[1]) * alpha; + pthis->envXluColor[2] = ((s32)pthis->envXluColor[2]) * alpha; + pthis->envOpaColor[0] = ((s32)pthis->envOpaColor[0]) * alpha; + pthis->envOpaColor[1] = ((s32)pthis->envOpaColor[1]) * alpha; + pthis->envOpaColor[2] = ((s32)pthis->envOpaColor[2]) * alpha; } /** * Moves the Jewel Actor during the activation of the Door of Time cutscene. * This is used once the Jewel Actor is done orbiting Link and split up to move into the pedastal slots. */ -void DemoEffect_MoveJewelSplit(PosRot* world, DemoEffect* this) { - switch (this->jewel.type) { +void DemoEffect_MoveJewelSplit(PosRot* world, DemoEffect* pthis) { + switch (pthis->jewel.type) { case DEMO_EFFECT_JEWEL_KOKIRI: world->pos.x -= 40.0f; break; @@ -1418,7 +1418,7 @@ void DemoEffect_MoveJewelSplit(PosRot* world, DemoEffect* this) { * This is run when the Jewels merge from Link and begin orbiting him. */ void DemoEffect_MoveJewelSpherical(f32 degrees, f32 frameDivisor, Vec3f startPos, Vec3f endPos, f32 radius, - Vec3s rotation, DemoEffect* this) { + Vec3s rotation, DemoEffect* pthis) { s32 pad; s32 pad2; f32 distance; @@ -1428,25 +1428,25 @@ void DemoEffect_MoveJewelSpherical(f32 degrees, f32 frameDivisor, Vec3f startPos distance = frameDivisor * sqrtf(SQ(endPos.x - startPos.x) + SQ(endPos.y - startPos.y) + SQ(endPos.z - startPos.z)); - this->actor.world.pos.x = radius * cosf(degrees * (M_PI / 180.0f)); - this->actor.world.pos.y = distance; - this->actor.world.pos.z = radius * sinf(degrees * (M_PI / 180.0f)); + pthis->actor.world.pos.x = radius * cosf(degrees * (M_PI / 180.0f)); + pthis->actor.world.pos.y = distance; + pthis->actor.world.pos.z = radius * sinf(degrees * (M_PI / 180.0f)); - xPos = this->actor.world.pos.x; - ySpherical = (this->actor.world.pos.y * cosf(rotation.x * (M_PI / 0x8000))) - - (sinf(rotation.x * (M_PI / 0x8000)) * this->actor.world.pos.z); - xzSpherical = (this->actor.world.pos.z * cosf(rotation.x * (M_PI / 0x8000))) + - (sinf(rotation.x * (M_PI / 0x8000)) * this->actor.world.pos.y); + xPos = pthis->actor.world.pos.x; + ySpherical = (pthis->actor.world.pos.y * cosf(rotation.x * (M_PI / 0x8000))) - + (sinf(rotation.x * (M_PI / 0x8000)) * pthis->actor.world.pos.z); + xzSpherical = (pthis->actor.world.pos.z * cosf(rotation.x * (M_PI / 0x8000))) + + (sinf(rotation.x * (M_PI / 0x8000)) * pthis->actor.world.pos.y); - this->actor.world.pos.x = + pthis->actor.world.pos.x = (xPos * cosf(rotation.y * (M_PI / 0x8000))) - (sinf(rotation.y * (M_PI / 0x8000)) * xzSpherical); - this->actor.world.pos.y = ySpherical; - this->actor.world.pos.z = + pthis->actor.world.pos.y = ySpherical; + pthis->actor.world.pos.z = (xzSpherical * cosf(rotation.y * (M_PI / 0x8000))) + (sinf(rotation.y * (M_PI / 0x8000)) * xPos); - this->actor.world.pos.x += startPos.x; - this->actor.world.pos.y += startPos.y; - this->actor.world.pos.z += startPos.z; + pthis->actor.world.pos.x += startPos.x; + pthis->actor.world.pos.y += startPos.y; + pthis->actor.world.pos.z += startPos.z; } /** @@ -1454,7 +1454,7 @@ void DemoEffect_MoveJewelSpherical(f32 degrees, f32 frameDivisor, Vec3f startPos * This is used by the Jewel Actor during the Door of Time activation cutscene. * This is run when the Jewels merge from Link and begin orbiting him. */ -void DemoEffect_MoveJewelActivateDoorOfTime(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_MoveJewelActivateDoorOfTime(DemoEffect* pthis, GlobalContext* globalCtx) { Vec3f startPos; Vec3f endPos; f32 frameDivisor; @@ -1462,7 +1462,7 @@ void DemoEffect_MoveJewelActivateDoorOfTime(DemoEffect* this, GlobalContext* glo f32 radius; s32 csActionId; - csActionId = this->csActionId; + csActionId = pthis->csActionId; startPos.x = globalCtx->csCtx.npcActions[csActionId]->startPos.x; startPos.y = globalCtx->csCtx.npcActions[csActionId]->startPos.y; startPos.z = globalCtx->csCtx.npcActions[csActionId]->startPos.z; @@ -1472,7 +1472,7 @@ void DemoEffect_MoveJewelActivateDoorOfTime(DemoEffect* this, GlobalContext* glo frameDivisor = DemoEffect_InterpolateCsFrames(globalCtx, csActionId); - switch (this->jewel.type) { + switch (pthis->jewel.type) { case DEMO_EFFECT_JEWEL_KOKIRI: degrees = 0.0f; break; @@ -1490,20 +1490,20 @@ void DemoEffect_MoveJewelActivateDoorOfTime(DemoEffect* this, GlobalContext* glo } if (startPos.x != endPos.x || startPos.y != endPos.y || startPos.z != endPos.z) { - this->jewelCsRotation.x = Math_Atan2F(endPos.z - startPos.z, -(endPos.x - startPos.x)) * (0x8000 / M_PI); - this->jewelCsRotation.y = Math_Vec3f_Yaw(&startPos, &endPos); + pthis->jewelCsRotation.x = Math_Atan2F(endPos.z - startPos.z, -(endPos.x - startPos.x)) * (0x8000 / M_PI); + pthis->jewelCsRotation.y = Math_Vec3f_Yaw(&startPos, &endPos); } - this->jewelCsRotation.z += 0x0400; + pthis->jewelCsRotation.z += 0x0400; - degrees += this->jewelCsRotation.z * (360.0f / 65536.0f); - DemoEffect_MoveJewelSpherical(degrees, frameDivisor, startPos, endPos, radius, this->jewelCsRotation, this); + degrees += pthis->jewelCsRotation.z * (360.0f / 65536.0f); + DemoEffect_MoveJewelSpherical(degrees, frameDivisor, startPos, endPos, radius, pthis->jewelCsRotation, pthis); } /** * Spawns Sparkle Effects for the Jewel Actor. */ -void DemoEffect_JewelSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 spawnerCount) { +void DemoEffect_JewelSparkle(DemoEffect* pthis, GlobalContext* globalCtx, s32 spawnerCount) { Vec3f velocity; Vec3f accel; Color_RGBA8 primColor; @@ -1517,7 +1517,7 @@ void DemoEffect_JewelSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 spa accel.y = -0.1f; accel.z = 0.0f; - sparkleColors = sJewelSparkleColors[this->jewel.type - DEMO_EFFECT_JEWEL_KOKIRI]; + sparkleColors = sJewelSparkleColors[pthis->jewel.type - DEMO_EFFECT_JEWEL_KOKIRI]; primColor.r = sparkleColors[0].r; primColor.g = sparkleColors[0].g; @@ -1531,7 +1531,7 @@ void DemoEffect_JewelSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 spa velocity.x = (Rand_ZeroOne() - 0.5f) * 1.5f; velocity.z = (Rand_ZeroOne() - 0.5f) * 1.5f; - EffectSsKiraKira_SpawnDispersed(globalCtx, &this->actor.world.pos, &velocity, &accel, &primColor, &envColor, + EffectSsKiraKira_SpawnDispersed(globalCtx, &pthis->actor.world.pos, &velocity, &accel, &primColor, &envColor, 3000, 16); } } @@ -1540,13 +1540,13 @@ void DemoEffect_JewelSparkle(DemoEffect* this, GlobalContext* globalCtx, s32 spa * Plays Jewel sound effects. * The sSfxJewelId global variable is used to ensure only one Jewel Actor is playing SFX when all are spawned. */ -void DemoEffect_PlayJewelSfx(DemoEffect* this, GlobalContext* globalCtx) { - if (!DemoEffect_CheckCsAction(this, globalCtx, 1)) { - if (this->actor.params == sSfxJewelId[0]) { - func_8002F974(&this->actor, NA_SE_EV_SPIRIT_STONE - SFX_FLAG); +void DemoEffect_PlayJewelSfx(DemoEffect* pthis, GlobalContext* globalCtx) { + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 1)) { + if (pthis->actor.params == sSfxJewelId[0]) { + func_8002F974(&pthis->actor, NA_SE_EV_SPIRIT_STONE - SFX_FLAG); } else if (sSfxJewelId[0] == 0) { - sSfxJewelId[0] = this->actor.params; - func_8002F974(&this->actor, NA_SE_EV_SPIRIT_STONE - SFX_FLAG); + sSfxJewelId[0] = pthis->actor.params; + func_8002F974(&pthis->actor, NA_SE_EV_SPIRIT_STONE - SFX_FLAG); } } } @@ -1558,11 +1558,11 @@ void DemoEffect_PlayJewelSfx(DemoEffect* this, GlobalContext* globalCtx) { * If a value of less than 1.0f were passed to SetJewelColor, then it would appear to drain the Jewel's color. * This can be seen in preprelease screenshots. */ -void DemoEffect_UpdateJewelAdult(DemoEffect* this, GlobalContext* globalCtx) { - this->jewel.timer++; - this->actor.shape.rot.y += 0x0400; - DemoEffect_PlayJewelSfx(this, globalCtx); - DemoEffect_SetJewelColor(this, 1.0f); +void DemoEffect_UpdateJewelAdult(DemoEffect* pthis, GlobalContext* globalCtx) { + pthis->jewel.timer++; + pthis->actor.shape.rot.y += 0x0400; + DemoEffect_PlayJewelSfx(pthis, globalCtx); + DemoEffect_SetJewelColor(pthis, 1.0f); } /** @@ -1570,43 +1570,43 @@ void DemoEffect_UpdateJewelAdult(DemoEffect* this, GlobalContext* globalCtx) { * This rotates the Jewel and updates a timer that is used to scroll Jewel textures. * This also updates the Jewel's position based on different cutscenes. */ -void DemoEffect_UpdateJewelChild(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateJewelChild(DemoEffect* pthis, GlobalContext* globalCtx) { s32 hasCmdAction; - Actor* thisx = &this->actor; + Actor* thisx = &pthis->actor; - this->jewel.timer++; + pthis->jewel.timer++; - if (globalCtx->csCtx.state && globalCtx->csCtx.npcActions[this->csActionId]) { - switch (globalCtx->csCtx.npcActions[this->csActionId]->action) { + if (globalCtx->csCtx.state && globalCtx->csCtx.npcActions[pthis->csActionId]) { + switch (globalCtx->csCtx.npcActions[pthis->csActionId]->action) { case 3: if (gSaveContext.eventChkInf[4] & 0x800) { gSaveContext.eventChkInf[4] |= 0x800; } - DemoEffect_MoveJewelActivateDoorOfTime(this, globalCtx); + DemoEffect_MoveJewelActivateDoorOfTime(pthis, globalCtx); if ((globalCtx->gameplayFrames & 1) == 0) { - DemoEffect_JewelSparkle(this, globalCtx, 1); + DemoEffect_JewelSparkle(pthis, globalCtx, 1); } break; case 4: - if (this->jewel.isPositionInit) { - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 0); - DemoEffect_MoveJewelSplit(&thisx->world, this); + if (pthis->jewel.isPositionInit) { + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 0); + DemoEffect_MoveJewelSplit(&thisx->world, pthis); if ((globalCtx->gameplayFrames & 1) == 0) { - DemoEffect_JewelSparkle(this, globalCtx, 1); + DemoEffect_JewelSparkle(pthis, globalCtx, 1); } } else { - DemoEffect_InitPositionFromCsAction(this, globalCtx, this->csActionId); - DemoEffect_MoveJewelSplit(&thisx->world, this); - this->jewel.isPositionInit = 1; + DemoEffect_InitPositionFromCsAction(pthis, globalCtx, pthis->csActionId); + DemoEffect_MoveJewelSplit(&thisx->world, pthis); + pthis->jewel.isPositionInit = 1; } break; case 6: Actor_Kill(thisx); return; default: - DemoEffect_MoveToCsEndpoint(this, globalCtx, this->csActionId, 0); + DemoEffect_MoveToCsEndpoint(pthis, globalCtx, pthis->csActionId, 0); if (gSaveContext.entranceIndex == 0x0053) { - DemoEffect_MoveJewelSplit(&thisx->world, this); + DemoEffect_MoveJewelSplit(&thisx->world, pthis); } break; } @@ -1614,17 +1614,17 @@ void DemoEffect_UpdateJewelChild(DemoEffect* this, GlobalContext* globalCtx) { if (gSaveContext.entranceIndex == 0x0053) { if (!(gSaveContext.eventChkInf[4] & 0x800)) { - hasCmdAction = globalCtx->csCtx.state && globalCtx->csCtx.npcActions[this->csActionId]; + hasCmdAction = globalCtx->csCtx.state && globalCtx->csCtx.npcActions[pthis->csActionId]; if (!hasCmdAction) { - this->effectFlags |= 0x1; + pthis->effectFlags |= 0x1; return; } } } thisx->shape.rot.y += 0x0400; - DemoEffect_PlayJewelSfx(this, globalCtx); - this->effectFlags &= ~1; + DemoEffect_PlayJewelSfx(pthis, globalCtx); + pthis->effectFlags &= ~1; } /** @@ -1632,14 +1632,14 @@ void DemoEffect_UpdateJewelChild(DemoEffect* this, GlobalContext* globalCtx) { * This is the dust that is spawned in the Temple of Time during the Light Arrows cutscene. * This spawns the dust particles and increments a timer */ -void DemoEffect_UpdateDust(DemoEffect* this, GlobalContext* globalCtx) { +void DemoEffect_UpdateDust(DemoEffect* pthis, GlobalContext* globalCtx) { Vec3f pos; Vec3f velocity; Vec3f accel; - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL && - globalCtx->csCtx.npcActions[this->csActionId]->action == 2) { - pos = this->actor.world.pos; + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL && + globalCtx->csCtx.npcActions[pthis->csActionId]->action == 2) { + pos = pthis->actor.world.pos; pos.y += 600.0f; pos.x += Rand_CenteredFloat(300.0f); @@ -1655,7 +1655,7 @@ void DemoEffect_UpdateDust(DemoEffect* this, GlobalContext* globalCtx) { func_8002873C(globalCtx, &pos, &velocity, &accel, 300, 0, 30); - this->dust.timer++; + pthis->dust.timer++; } } @@ -1663,16 +1663,16 @@ void DemoEffect_UpdateDust(DemoEffect* this, GlobalContext* globalCtx) { * This is the main Actor Update Function. */ void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; - this->updateFunc(this, globalCtx); + DemoEffect* pthis = (DemoEffect*)thisx; + pthis->updateFunc(pthis, globalCtx); } /** * Check if the current cutscene action matches the passed in cutscene action ID. */ -s32 DemoEffect_CheckCsAction(DemoEffect* this, GlobalContext* globalCtx, s32 csActionCompareId) { - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->csActionId] != NULL && - globalCtx->csCtx.npcActions[this->csActionId]->action == csActionCompareId) { +s32 DemoEffect_CheckCsAction(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionCompareId) { + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->csActionId] != NULL && + globalCtx->csCtx.npcActions[pthis->csActionId]->action == csActionCompareId) { return 1; } @@ -1683,17 +1683,17 @@ s32 DemoEffect_CheckCsAction(DemoEffect* this, GlobalContext* globalCtx, s32 csA * Draw function for the Jewel Actor. */ void DemoEffect_DrawJewel(Actor* thisx, GlobalContext* globalCtx2) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; GlobalContext* globalCtx = globalCtx2; - u32 frames = this->jewel.timer; + u32 frames = pthis->jewel.timer; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2543); - if (!DemoEffect_CheckCsAction(this, globalCtx, 1)) { + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 1)) { if (1) {} - if (!(this->effectFlags & 0x1)) { - switch (this->jewel.type) { + if (!(pthis->effectFlags & 0x1)) { + switch (pthis->jewel.type) { case DEMO_EFFECT_JEWEL_KOKIRI: gSPSegment(POLY_XLU_DISP++, 9, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (frames * 4) % 256, @@ -1724,17 +1724,17 @@ void DemoEffect_DrawJewel(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2599), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, this->primXluColor[0], this->primXluColor[1], - this->primXluColor[2], 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); - gSPDisplayList(POLY_XLU_DISP++, this->jewelDisplayList); + func_8002ED80(&pthis->actor, globalCtx, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, pthis->primXluColor[0], pthis->primXluColor[1], + pthis->primXluColor[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->envXluColor[0], pthis->envXluColor[1], pthis->envXluColor[2], 255); + gSPDisplayList(POLY_XLU_DISP++, pthis->jewelDisplayList); func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 128, this->primOpaColor[0], this->primOpaColor[1], - this->primOpaColor[2], 255); - gDPSetEnvColor(POLY_OPA_DISP++, this->envOpaColor[0], this->envOpaColor[1], this->envOpaColor[2], 255); - gSPDisplayList(POLY_OPA_DISP++, this->jewelHolderDisplayList); + func_8002EBCC(&pthis->actor, globalCtx, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 128, pthis->primOpaColor[0], pthis->primOpaColor[1], + pthis->primOpaColor[2], 255); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->envOpaColor[0], pthis->envOpaColor[1], pthis->envOpaColor[2], 255); + gSPDisplayList(POLY_OPA_DISP++, pthis->jewelHolderDisplayList); } } @@ -1745,8 +1745,8 @@ void DemoEffect_DrawJewel(Actor* thisx, GlobalContext* globalCtx2) { * Draw function for the Crystal Light Actor. */ void DemoEffect_DrawCrystalLight(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; - DemoEffect* parent = (DemoEffect*)this->actor.parent; + DemoEffect* pthis = (DemoEffect*)thisx; + DemoEffect* parent = (DemoEffect*)pthis->actor.parent; u32 frames = globalCtx->gameplayFrames & 0xFFFF; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2634); @@ -1793,7 +1793,7 @@ void DemoEffect_DrawCrystalLight(Actor* thisx, GlobalContext* globalCtx) { * Draw function for the Fire Ball Actor. */ void DemoEffect_DrawFireBall(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; u32 frames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2701); @@ -1815,23 +1815,23 @@ void DemoEffect_DrawFireBall(Actor* thisx, GlobalContext* globalCtx) { * This draws either Din, Nayru, or Farore based on the colors set in the DemoEffect struct. */ void DemoEffect_DrawGodLgt(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; s32 pad; u32 frames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2737); - if (!DemoEffect_CheckCsAction(this, globalCtx, 2)) { + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 2)) { if (gSaveContext.entranceIndex == 0x00A0) { if (gSaveContext.sceneSetupIndex == 4) { if (globalCtx->csCtx.frames <= 680) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_GOD_FLYING - SFX_FLAG); + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_GOD_FLYING - SFX_FLAG); } } else { - func_80078914(&this->actor.projectedPos, NA_SE_EV_GOD_FLYING - SFX_FLAG); + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_GOD_FLYING - SFX_FLAG); } } else { - func_80078914(&this->actor.projectedPos, NA_SE_EV_GOD_FLYING - SFX_FLAG); + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_GOD_FLYING - SFX_FLAG); } gSPSegment(POLY_XLU_DISP++, 8, @@ -1840,25 +1840,25 @@ void DemoEffect_DrawGodLgt(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 9, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 96, 1, (frames * 10) % 256, 256 - ((frames * 30) % 512) - 1, 8, 32)); - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, this->primXluColor[0], this->primXluColor[1], this->primXluColor[2], + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, pthis->primXluColor[0], pthis->primXluColor[1], pthis->primXluColor[2], 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->envXluColor[0], pthis->envXluColor[1], pthis->envXluColor[2], 255); func_80093D84(globalCtx->state.gfxCtx); Matrix_Push(); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2801), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGoldenGoddessAuraDL); func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); Matrix_Pop(); - this->godLgt.rotation++; - if (this->godLgt.rotation > 120) { - this->godLgt.rotation = 0; + pthis->godLgt.rotation++; + if (pthis->godLgt.rotation > 120) { + pthis->godLgt.rotation = 0; if (1) {} } - Matrix_RotateZ((((s32)this->godLgt.rotation) * 3.0f) * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateZ((((s32)pthis->godLgt.rotation) * 3.0f) * (M_PI / 180.0f), MTXMODE_APPLY); Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); Matrix_Translate(0.0f, -140.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); @@ -1874,35 +1874,35 @@ void DemoEffect_DrawGodLgt(Actor* thisx, GlobalContext* globalCtx) { * Draw function for the Light Effect Actor. */ void DemoEffect_DrawLightEffect(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; u8* alpha; Gfx* disp; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2842); - if (!DemoEffect_CheckCsAction(this, globalCtx, 1)) { + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 1)) { - if (this->light.flicker == 0) { - this->light.flicker = 1; + if (pthis->light.flicker == 0) { + pthis->light.flicker = 1; } else { disp = gEffFlash1DL; // necessary to match, should be able to remove after fake matches are fixed - alpha = &this->light.alpha; + alpha = &pthis->light.alpha; func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, this->primXluColor[0], this->primXluColor[1], - this->primXluColor[2], *alpha); - gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); - Matrix_Scale(((this->light.scaleFlag & 1) * 0.05f) + 1.0f, ((this->light.scaleFlag & 1) * 0.05f) + 1.0f, - ((this->light.scaleFlag & 1) * 0.05f) + 1.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, pthis->primXluColor[0], pthis->primXluColor[1], + pthis->primXluColor[2], *alpha); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->envXluColor[0], pthis->envXluColor[1], pthis->envXluColor[2], 255); + Matrix_Scale(((pthis->light.scaleFlag & 1) * 0.05f) + 1.0f, ((pthis->light.scaleFlag & 1) * 0.05f) + 1.0f, + ((pthis->light.scaleFlag & 1) * 0.05f) + 1.0f, MTXMODE_APPLY); Matrix_Push(); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(this->light.rotation * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateZ(pthis->light.rotation * (M_PI / 180.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2866), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); if (disp) {}; gSPDisplayList(POLY_XLU_DISP++, disp); Matrix_Pop(); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(-(f32)this->light.rotation * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateZ(-(f32)pthis->light.rotation * (M_PI / 180.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2874), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, disp); @@ -1916,18 +1916,18 @@ void DemoEffect_DrawLightEffect(Actor* thisx, GlobalContext* globalCtx) { * Draw function for the Blue Orb Actor. */ void DemoEffect_DrawBlueOrb(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; s32 pad2; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2892); - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 188, 255, 255, this->blueOrb.alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 188, 255, 255, pthis->blueOrb.alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 255); func_80093D84(globalCtx->state.gfxCtx); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(this->blueOrb.rotation * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->blueOrb.rotation * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2901), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - this->blueOrb.rotation += 0x01F4; + pthis->blueOrb.rotation += 0x01F4; gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2907); } @@ -1936,12 +1936,12 @@ void DemoEffect_DrawBlueOrb(Actor* thisx, GlobalContext* globalCtx) { * Draw function for the Lgt Shower Actor. */ void DemoEffect_DrawLgtShower(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; s32 pad; u32 frames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2921); - gDPSetPrimColor(POLY_XLU_DISP++, 64, 64, 255, 255, 160, this->lgtShower.alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 64, 64, 255, 255, 160, pthis->lgtShower.alpha); gDPSetEnvColor(POLY_XLU_DISP++, 50, 200, 0, 255); func_80093D84(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2927), @@ -1957,14 +1957,14 @@ void DemoEffect_DrawLgtShower(Actor* thisx, GlobalContext* globalCtx) { * Draw function for the Light Ring Actor. */ void DemoEffect_DrawLightRing(Actor* thisx, GlobalContext* globalCtx2) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; GlobalContext* globalCtx = globalCtx2; - u32 frames = this->lightRing.timer; + u32 frames = pthis->lightRing.timer; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2956); func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 170, 255, 255, this->lightRing.alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 170, 255, 255, pthis->lightRing.alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2963), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1980,7 +1980,7 @@ void DemoEffect_DrawLightRing(Actor* thisx, GlobalContext* globalCtx2) { * Draw function for the Triforce Spot Actor. */ void DemoEffect_DrawTriforceSpot(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; s32 pad; Vtx* vertices = SEGMENTED_TO_VIRTUAL(gTriforceVtx); u32 frames = globalCtx->gameplayFrames; @@ -1989,8 +1989,8 @@ void DemoEffect_DrawTriforceSpot(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.entranceIndex != 0x0400 || globalCtx->csCtx.frames < 885) { func_80093D84(globalCtx->state.gfxCtx); - if (this->triforceSpot.lightColumnOpacity > 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_AURORA - SFX_FLAG); + if (pthis->triforceSpot.lightColumnOpacity > 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_AURORA - SFX_FLAG); Matrix_Push(); Matrix_Scale(1.0f, 2.4f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 3011), @@ -1999,35 +1999,35 @@ void DemoEffect_DrawTriforceSpot(Actor* thisx, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 256 - ((frames * 4) % 256) - 1, 64, 64, 1, 0, 256 - ((frames * 2) % 256) - 1, 64, 32)); vertices[86].n.a = vertices[87].n.a = vertices[88].n.a = vertices[89].n.a = vertices[92].n.a = - vertices[93].n.a = vertices[94].n.a = vertices[95].n.a = (s8)this->triforceSpot.lightColumnOpacity; - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 180, 255, 255, this->triforceSpot.lightColumnOpacity); + vertices[93].n.a = vertices[94].n.a = vertices[95].n.a = (s8)pthis->triforceSpot.lightColumnOpacity; + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 180, 255, 255, pthis->triforceSpot.lightColumnOpacity); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 150, 255); gSPDisplayList(POLY_XLU_DISP++, gTriforceLightColumnDL); Matrix_Pop(); } - if (this->triforceSpot.triforceSpotOpacity != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_TRIFORCE - SFX_FLAG); + if (pthis->triforceSpot.triforceSpotOpacity != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_TRIFORCE - SFX_FLAG); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 3042), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->triforceSpot.triforceSpotOpacity < 250) { - func_8002ED80(&this->actor, globalCtx, 0); + if (pthis->triforceSpot.triforceSpotOpacity < 250) { + func_8002ED80(&pthis->actor, globalCtx, 0); func_80093D84(globalCtx->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); - Matrix_RotateY(this->triforceSpot.rotation * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->triforceSpot.rotation * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 3053), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 16, 1, 0, 0, 16, 8)); - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 160, this->triforceSpot.triforceSpotOpacity); + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 160, pthis->triforceSpot.triforceSpotOpacity); gDPSetEnvColor(POLY_XLU_DISP++, 170, 140, 0, 255); gSPDisplayList(POLY_XLU_DISP++, gTriforceDL); } else { - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); func_80093D18(globalCtx->state.gfxCtx); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); - Matrix_RotateY(this->triforceSpot.rotation * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->triforceSpot.rotation * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 3085), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 8, @@ -2046,15 +2046,15 @@ void DemoEffect_DrawTriforceSpot(Actor* thisx, GlobalContext* globalCtx) { * This is either Medals or Light Arrows based on the drawId. */ void DemoEffect_DrawGetItem(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; - if (!DemoEffect_CheckCsAction(this, globalCtx, 1) && !DemoEffect_CheckCsAction(this, globalCtx, 4)) { - if (!this->getItem.isLoaded) { - this->getItem.isLoaded = 1; + DemoEffect* pthis = (DemoEffect*)thisx; + if (!DemoEffect_CheckCsAction(pthis, globalCtx, 1) && !DemoEffect_CheckCsAction(pthis, globalCtx, 4)) { + if (!pthis->getItem.isLoaded) { + pthis->getItem.isLoaded = 1; return; } func_8002EBCC(thisx, globalCtx, 0); func_8002ED80(thisx, globalCtx, 0); - GetItem_Draw(globalCtx, this->getItem.drawId); + GetItem_Draw(globalCtx, pthis->getItem.drawId); } } @@ -2063,13 +2063,13 @@ void DemoEffect_DrawGetItem(Actor* thisx, GlobalContext* globalCtx) { */ s32 DemoEffect_DrawTimewarpLimbs(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, void* thisx) { s32 pad; - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; u32 frames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 3154); func_80093D84(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, 170, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->envXluColor[0], pthis->envXluColor[1], pthis->envXluColor[2], 255); gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (frames * 6) % 1024, 256 - ((frames * 16) % 256) - 1, 256, 64, 1, (frames * 4) % 512, 128 - ((frames * 12) % 128) - 1, 128, 32)); @@ -2089,16 +2089,16 @@ s32 DemoEffect_DrawTimewarpLimbs(GlobalContext* globalCtx, SkelAnimeCurve* skelC * Draw function for the Time Warp Actors. */ void DemoEffect_DrawTimeWarp(Actor* thisx, GlobalContext* globalCtx) { - DemoEffect* this = (DemoEffect*)thisx; + DemoEffect* pthis = (DemoEffect*)thisx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 effectType = (this->actor.params & 0x00FF); + u8 effectType = (pthis->actor.params & 0x00FF); if (effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE || effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL || Flags_GetEnv(globalCtx, 1) || gSaveContext.sceneSetupIndex >= 4 || gSaveContext.entranceIndex == 0x0324) { OPEN_DISPS(gfxCtx, "../z_demo_effect.c", 3201); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - SkelCurve_Draw(thisx, globalCtx, &this->skelCurve, DemoEffect_DrawTimewarpLimbs, NULL, 1, this); + SkelCurve_Draw(thisx, globalCtx, &pthis->skelCurve, DemoEffect_DrawTimewarpLimbs, NULL, 1, pthis); CLOSE_DISPS(gfxCtx, "../z_demo_effect.c", 3216); } } @@ -2106,14 +2106,14 @@ void DemoEffect_DrawTimeWarp(Actor* thisx, GlobalContext* globalCtx) { /** * Faces/rotates the Actor towards the current cutscene action end point. */ -void DemoEffect_FaceToCsEndpoint(DemoEffect* this, Vec3f startPos, Vec3f endPos) { +void DemoEffect_FaceToCsEndpoint(DemoEffect* pthis, Vec3f startPos, Vec3f endPos) { s32 pad; f32 x = endPos.x - startPos.x; f32 z = endPos.z - startPos.z; f32 xzDistance = sqrtf(SQ(x) + SQ(z)); - this->actor.shape.rot.y = Math_FAtan2F(x, z) * (32768.0f / M_PI); - this->actor.shape.rot.x = Math_FAtan2F(-(endPos.y - startPos.y), xzDistance) * (32768.0f / M_PI); + pthis->actor.shape.rot.y = Math_FAtan2F(x, z) * (32768.0f / M_PI); + pthis->actor.shape.rot.x = Math_FAtan2F(-(endPos.y - startPos.y), xzDistance) * (32768.0f / M_PI); } /** @@ -2121,7 +2121,7 @@ void DemoEffect_FaceToCsEndpoint(DemoEffect* this, Vec3f startPos, Vec3f endPos) * Will only update the Actor's facing/rotation if the shouldUpdateFacing argument is true. * The speed is based on the current progress in the cutscene action. */ -void DemoEffect_MoveToCsEndpoint(DemoEffect* this, GlobalContext* globalCtx, s32 csActionId, s32 shouldUpdateFacing) { +void DemoEffect_MoveToCsEndpoint(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionId, s32 shouldUpdateFacing) { Vec3f startPos; Vec3f endPos; f32 speed; @@ -2135,35 +2135,35 @@ void DemoEffect_MoveToCsEndpoint(DemoEffect* this, GlobalContext* globalCtx, s32 speed = DemoEffect_InterpolateCsFrames(globalCtx, csActionId); - this->actor.world.pos.x = ((endPos.x - startPos.x) * speed) + startPos.x; - this->actor.world.pos.y = ((endPos.y - startPos.y) * speed) + startPos.y; - this->actor.world.pos.z = ((endPos.z - startPos.z) * speed) + startPos.z; + pthis->actor.world.pos.x = ((endPos.x - startPos.x) * speed) + startPos.x; + pthis->actor.world.pos.y = ((endPos.y - startPos.y) * speed) + startPos.y; + pthis->actor.world.pos.z = ((endPos.z - startPos.z) * speed) + startPos.z; if (shouldUpdateFacing) { - DemoEffect_FaceToCsEndpoint(this, startPos, endPos); + DemoEffect_FaceToCsEndpoint(pthis, startPos, endPos); } } /** * Moves a GetItem actor towards the current cutscene action's endpoint. */ -void DemoEffect_MoveGetItem(DemoEffect* this, GlobalContext* globalCtx, s32 csActionId, f32 speed) { +void DemoEffect_MoveGetItem(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionId, f32 speed) { Vec3f endPos; endPos.x = globalCtx->csCtx.npcActions[csActionId]->endPos.x; endPos.y = globalCtx->csCtx.npcActions[csActionId]->endPos.y; endPos.z = globalCtx->csCtx.npcActions[csActionId]->endPos.z; - DemoEffect_MoveTowardTarget(endPos, this, speed); + DemoEffect_MoveTowardTarget(endPos, pthis, speed); } /** * Initializes the Actor's position to the current cutscene action's start point. */ -void DemoEffect_InitPositionFromCsAction(DemoEffect* this, GlobalContext* globalCtx, s32 csActionIndex) { +void DemoEffect_InitPositionFromCsAction(DemoEffect* pthis, GlobalContext* globalCtx, s32 csActionIndex) { f32 x = globalCtx->csCtx.npcActions[csActionIndex]->startPos.x; f32 y = globalCtx->csCtx.npcActions[csActionIndex]->startPos.y; f32 z = globalCtx->csCtx.npcActions[csActionIndex]->startPos.z; - this->actor.world.pos.x = x; - this->actor.world.pos.y = y; - this->actor.world.pos.z = z; + pthis->actor.world.pos.x = x; + pthis->actor.world.pos.y = y; + pthis->actor.world.pos.z = z; } diff --git a/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c b/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.cpp similarity index 56% rename from src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c rename to src/overlays/actors/ovl_Demo_Ext/z_demo_ext.cpp index 363084499..8b2b7c371 100644 --- a/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c +++ b/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.cpp @@ -37,22 +37,22 @@ void DemoExt_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void DemoExt_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoExt* this = (DemoExt*)thisx; + DemoExt* pthis = (DemoExt*)thisx; - this->scrollIncr[0] = 25; - this->scrollIncr[1] = 40; - this->scrollIncr[2] = 5; - this->scrollIncr[3] = 30; - this->primAlpha = kREG(28) + 255; - this->envAlpha = kREG(32) + 255; - this->scale.x = kREG(19) + 400.0f; - this->scale.y = kREG(20) + 100.0f; - this->scale.z = kREG(21) + 400.0f; + pthis->scrollIncr[0] = 25; + pthis->scrollIncr[1] = 40; + pthis->scrollIncr[2] = 5; + pthis->scrollIncr[3] = 30; + pthis->primAlpha = kREG(28) + 255; + pthis->envAlpha = kREG(32) + 255; + pthis->scale.x = kREG(19) + 400.0f; + pthis->scale.y = kREG(20) + 100.0f; + pthis->scale.z = kREG(21) + 400.0f; } -void DemoExt_PlayVortexSFX(DemoExt* this) { - if (this->alphaTimer <= (kREG(35) + 40.0f) - 15.0f) { - Audio_PlaySoundGeneral(NA_SE_EV_FANTOM_WARP_L - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, +void DemoExt_PlayVortexSFX(DemoExt* pthis) { + if (pthis->alphaTimer <= (kREG(35) + 40.0f) - 15.0f) { + Audio_PlaySoundGeneral(NA_SE_EV_FANTOM_WARP_L - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } @@ -64,108 +64,108 @@ CsCmdActorAction* DemoExt_GetNpcAction(GlobalContext* globalCtx, s32 npcActionIn return NULL; } -void DemoExt_SetupWait(DemoExt* this) { - this->action = EXT_WAIT; - this->drawMode = EXT_DRAW_NOTHING; +void DemoExt_SetupWait(DemoExt* pthis) { + pthis->action = EXT_WAIT; + pthis->drawMode = EXT_DRAW_NOTHING; } -void DemoExt_SetupMaintainVortex(DemoExt* this, GlobalContext* globalCtx) { +void DemoExt_SetupMaintainVortex(DemoExt* pthis, GlobalContext* globalCtx) { CsCmdActorAction* npcAction = DemoExt_GetNpcAction(globalCtx, 5); if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; } - this->action = EXT_MAINTAIN; - this->drawMode = EXT_DRAW_VORTEX; + pthis->action = EXT_MAINTAIN; + pthis->drawMode = EXT_DRAW_VORTEX; } -void DemoExt_SetupDispellVortex(DemoExt* this) { - this->action = EXT_DISPELL; - this->drawMode = EXT_DRAW_VORTEX; +void DemoExt_SetupDispellVortex(DemoExt* pthis) { + pthis->action = EXT_DISPELL; + pthis->drawMode = EXT_DRAW_VORTEX; } -void DemoExt_FinishClosing(DemoExt* this) { - this->alphaTimer += 1.0f; - if ((kREG(35) + 40.0f) <= this->alphaTimer) { - Actor_Kill(&this->actor); +void DemoExt_FinishClosing(DemoExt* pthis) { + pthis->alphaTimer += 1.0f; + if ((kREG(35) + 40.0f) <= pthis->alphaTimer) { + Actor_Kill(&pthis->actor); } } -void DemoExt_CheckCsMode(DemoExt* this, GlobalContext* globalCtx) { +void DemoExt_CheckCsMode(DemoExt* pthis, GlobalContext* globalCtx) { CsCmdActorAction* csCmdNPCAction = DemoExt_GetNpcAction(globalCtx, 5); s32 csAction; s32 previousCsAction; if (csCmdNPCAction != NULL) { csAction = csCmdNPCAction->action; - previousCsAction = this->previousCsAction; + previousCsAction = pthis->previousCsAction; if (csAction != previousCsAction) { switch (csAction) { case 1: - DemoExt_SetupWait(this); + DemoExt_SetupWait(pthis); break; case 2: - DemoExt_SetupMaintainVortex(this, globalCtx); + DemoExt_SetupMaintainVortex(pthis, globalCtx); break; case 3: - DemoExt_SetupDispellVortex(this); + DemoExt_SetupDispellVortex(pthis); break; default: // "Demo_Ext_Check_DemoMode: there is no such action!" osSyncPrintf("Demo_Ext_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); break; } - this->previousCsAction = csAction; + pthis->previousCsAction = csAction; } } } -void DemoExt_SetScrollAndRotation(DemoExt* this) { - s16* scrollIncr = this->scrollIncr; - s16* curScroll = this->curScroll; +void DemoExt_SetScrollAndRotation(DemoExt* pthis) { + s16* scrollIncr = pthis->scrollIncr; + s16* curScroll = pthis->curScroll; s32 i; for (i = 3; i != 0; i--) { curScroll[i] += scrollIncr[i]; } - this->rotationPitch += (s16)(kREG(34) + 1000); + pthis->rotationPitch += (s16)(kREG(34) + 1000); } -void DemoExt_SetColorsAndScales(DemoExt* this) { - Vec3f* scale = &this->scale; +void DemoExt_SetColorsAndScales(DemoExt* pthis) { + Vec3f* scale = &pthis->scale; f32 shrinkFactor; - shrinkFactor = ((kREG(35) + 40.0f) - this->alphaTimer) / (kREG(35) + 40.0f); + shrinkFactor = ((kREG(35) + 40.0f) - pthis->alphaTimer) / (kREG(35) + 40.0f); if (shrinkFactor < 0.0f) { shrinkFactor = 0.0f; } - this->primAlpha = (u32)(kREG(28) + 255) * shrinkFactor; - this->envAlpha = (u32)(kREG(32) + 255) * shrinkFactor; + pthis->primAlpha = (u32)(kREG(28) + 255) * shrinkFactor; + pthis->envAlpha = (u32)(kREG(32) + 255) * shrinkFactor; scale->x = (kREG(19) + 400.0f) * shrinkFactor; scale->y = (kREG(20) + 100.0f) * shrinkFactor; scale->z = (kREG(21) + 400.0f) * shrinkFactor; } -void DemoExt_Wait(DemoExt* this, GlobalContext* globalCtx) { - DemoExt_CheckCsMode(this, globalCtx); +void DemoExt_Wait(DemoExt* pthis, GlobalContext* globalCtx) { + DemoExt_CheckCsMode(pthis, globalCtx); } -void DemoExt_MaintainVortex(DemoExt* this, GlobalContext* globalCtx) { - DemoExt_PlayVortexSFX(this); - DemoExt_SetScrollAndRotation(this); - DemoExt_CheckCsMode(this, globalCtx); +void DemoExt_MaintainVortex(DemoExt* pthis, GlobalContext* globalCtx) { + DemoExt_PlayVortexSFX(pthis); + DemoExt_SetScrollAndRotation(pthis); + DemoExt_CheckCsMode(pthis, globalCtx); } -void DemoExt_DispellVortex(DemoExt* this, GlobalContext* globalCtx) { - DemoExt_PlayVortexSFX(this); - DemoExt_SetScrollAndRotation(this); - DemoExt_SetColorsAndScales(this); - DemoExt_FinishClosing(this); +void DemoExt_DispellVortex(DemoExt* pthis, GlobalContext* globalCtx) { + DemoExt_PlayVortexSFX(pthis); + DemoExt_SetScrollAndRotation(pthis); + DemoExt_SetColorsAndScales(pthis); + DemoExt_FinishClosing(pthis); } static DemoExtActionFunc sActionFuncs[] = { @@ -175,13 +175,13 @@ static DemoExtActionFunc sActionFuncs[] = { }; void DemoExt_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoExt* this = (DemoExt*)thisx; + DemoExt* pthis = (DemoExt*)thisx; - if ((this->action < EXT_WAIT) || (this->action > EXT_DISPELL) || sActionFuncs[this->action] == NULL) { + if ((pthis->action < EXT_WAIT) || (pthis->action > EXT_DISPELL) || sActionFuncs[pthis->action] == NULL) { // "Main mode is abnormal!" osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); } else { - sActionFuncs[this->action](this, globalCtx); + sActionFuncs[pthis->action](pthis, globalCtx); } } @@ -189,29 +189,29 @@ void DemoExt_DrawNothing(Actor* thisx, GlobalContext* globalCtx) { } void DemoExt_DrawVortex(Actor* thisx, GlobalContext* globalCtx) { - DemoExt* this = (DemoExt*)thisx; + DemoExt* pthis = (DemoExt*)thisx; Mtx* mtx; GraphicsContext* gfxCtx; s16* curScroll; Vec3f* scale; - scale = &this->scale; + scale = &pthis->scale; gfxCtx = globalCtx->state.gfxCtx; - mtx = Graph_Alloc(gfxCtx, sizeof(Mtx)); + mtx = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); OPEN_DISPS(gfxCtx, "../z_demo_ext.c", 460); Matrix_Push(); Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); - Matrix_RotateZYX((s16)(kREG(16) + 0x4000), this->rotationPitch, kREG(18), MTXMODE_APPLY); + Matrix_RotateZYX((s16)(kREG(16) + 0x4000), pthis->rotationPitch, kREG(18), MTXMODE_APPLY); Matrix_Translate(kREG(22), kREG(23), kREG(24), MTXMODE_APPLY); Matrix_ToMtx(mtx, "../z_demo_ext.c", 476); Matrix_Pop(); func_80093D84(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, kREG(33) + 128, kREG(25) + 140, kREG(26) + 80, kREG(27) + 140, this->primAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, kREG(29) + 90, kREG(30) + 50, kREG(31) + 95, this->envAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, kREG(33) + 128, kREG(25) + 140, kREG(26) + 80, kREG(27) + 140, pthis->primAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, kREG(29) + 90, kREG(30) + 50, kREG(31) + 95, pthis->envAlpha); - curScroll = this->curScroll; + curScroll = pthis->curScroll; gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(gfxCtx, 0, curScroll[0], curScroll[1], 0x40, 0x40, 1, curScroll[2], curScroll[3], 0x40, 0x40)); @@ -229,18 +229,18 @@ static DemoExtDrawFunc sDrawFuncs[] = { }; void DemoExt_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoExt* this = (DemoExt*)thisx; + DemoExt* pthis = (DemoExt*)thisx; - if ((this->drawMode < EXT_DRAW_NOTHING) || (this->drawMode > EXT_DRAW_VORTEX) || - sDrawFuncs[this->drawMode] == NULL) { + if ((pthis->drawMode < EXT_DRAW_NOTHING) || (pthis->drawMode > EXT_DRAW_VORTEX) || + sDrawFuncs[pthis->drawMode] == NULL) { // "Draw mode is abnormal!" osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); } else { - sDrawFuncs[this->drawMode](thisx, globalCtx); + sDrawFuncs[pthis->drawMode](thisx, globalCtx); } } -const ActorInit Demo_Ext_InitVars = { +ActorInit Demo_Ext_InitVars = { ACTOR_DEMO_EXT, ACTORCAT_NPC, FLAGS, diff --git a/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c b/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.cpp similarity index 63% rename from src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c rename to src/overlays/actors/ovl_Demo_Geff/z_demo_geff.cpp index 2a8ff05bd..ff680700c 100644 --- a/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.c +++ b/src/overlays/actors/ovl_Demo_Geff/z_demo_geff.cpp @@ -21,13 +21,13 @@ void DemoGeff_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoGeff_Update(Actor* thisx, GlobalContext* globalCtx); void DemoGeff_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80978030(DemoGeff* this, GlobalContext* globalCtx); +void func_80978030(DemoGeff* pthis, GlobalContext* globalCtx); -void func_809783D4(DemoGeff* this, GlobalContext* globalCtx); -void func_80978308(DemoGeff* this, GlobalContext* globalCtx); +void func_809783D4(DemoGeff* pthis, GlobalContext* globalCtx); +void func_80978308(DemoGeff* pthis, GlobalContext* globalCtx); -void func_809784D4(DemoGeff* this, GlobalContext* globalCtx); -void func_80978344(DemoGeff* this, GlobalContext* globalCtx); +void func_809784D4(DemoGeff* pthis, GlobalContext* globalCtx); +void func_80978344(DemoGeff* pthis, GlobalContext* globalCtx); static s16 sObjectIDs[] = { OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, OBJECT_GEFF, @@ -48,7 +48,7 @@ static DemoGeffDrawFunc sDrawFuncs[] = { func_80978344, }; -const ActorInit Demo_Geff_InitVars = { +ActorInit Demo_Geff_InitVars = { ACTOR_DEMO_GEFF, ACTORCAT_BOSS, FLAGS, @@ -64,15 +64,15 @@ void DemoGeff_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void DemoGeff_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoGeff* this = (DemoGeff*)thisx; + DemoGeff* pthis = (DemoGeff*)thisx; - if (this->actor.params < 0 || this->actor.params >= 9) { + if (pthis->actor.params < 0 || pthis->actor.params >= 9) { osSyncPrintf(VT_FGCOL(RED) "Demo_Geff_Actor_ct:arg_dataがおかしい!!!!!!!!!!!!\n" VT_RST); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->action = 0; - this->drawConfig = 0; + pthis->action = 0; + pthis->drawConfig = 0; } void func_80977EA8(GlobalContext* globalCtx, Gfx* dlist) { @@ -90,15 +90,15 @@ void func_80977EA8(GlobalContext* globalCtx, Gfx* dlist) { CLOSE_DISPS(gfxCtx, "../z_demo_geff.c", 188); } -void func_80977F80(DemoGeff* this, GlobalContext* globalCtx) { +void func_80977F80(DemoGeff* pthis, GlobalContext* globalCtx) { s32 pad[2]; - s32 objBankIndex = this->objBankIndex; + s32 objBankIndex = pthis->objBankIndex; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_demo_geff.c", 204); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[objBankIndex].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[objBankIndex].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIndex].vromStart.get()); // Necessary to match if (!globalCtx) {} @@ -106,13 +106,13 @@ void func_80977F80(DemoGeff* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_geff.c", 212); } -void func_80978030(DemoGeff* this, GlobalContext* globalCtx) { - Vec3f* thisScale = &this->actor.scale; +void func_80978030(DemoGeff* pthis, GlobalContext* globalCtx) { + Vec3f* thisScale = &pthis->actor.scale; - this->action = 1; - this->drawConfig = 1; + pthis->action = 1; + pthis->drawConfig = 1; - switch (this->actor.params) { + switch (pthis->actor.params) { case 0: case 3: case 6: @@ -135,64 +135,64 @@ void func_80978030(DemoGeff* this, GlobalContext* globalCtx) { } } -void func_809781FC(DemoGeff* this, GlobalContext* globalCtx) { +void func_809781FC(DemoGeff* pthis, GlobalContext* globalCtx) { s32 targetParams = 2; Actor* propIt; - if (this->demoGt == NULL) { + if (pthis->demoGt == NULL) { propIt = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - if ((this->actor.params != 0) && (this->actor.params != 1) && (this->actor.params != 2)) { + if ((pthis->actor.params != 0) && (pthis->actor.params != 1) && (pthis->actor.params != 2)) { targetParams = 2; } else { targetParams = 1; } while (propIt != NULL) { if (propIt->id == ACTOR_DEMO_GT && propIt->params == targetParams) { - this->deltaPosX = this->actor.world.pos.x - propIt->world.pos.x; - this->deltaPosY = this->actor.world.pos.y - propIt->world.pos.y; - this->deltaPosZ = this->actor.world.pos.z - propIt->world.pos.z; - this->demoGt = (DemoGt*)propIt; + pthis->deltaPosX = pthis->actor.world.pos.x - propIt->world.pos.x; + pthis->deltaPosY = pthis->actor.world.pos.y - propIt->world.pos.y; + pthis->deltaPosZ = pthis->actor.world.pos.z - propIt->world.pos.z; + pthis->demoGt = (DemoGt*)propIt; } propIt = propIt->next; } } } -void func_809782A0(DemoGeff* this, GlobalContext* globalCtx) { - DemoGt* demoGt = this->demoGt; - s16 params = this->actor.params; +void func_809782A0(DemoGeff* pthis, GlobalContext* globalCtx) { + DemoGt* demoGt = pthis->demoGt; + s16 params = pthis->actor.params; if (demoGt != NULL && (params != 6) && (params != 7) && (params != 8)) { - this->actor.world.pos.x = demoGt->dyna.actor.world.pos.x + this->deltaPosX; - this->actor.world.pos.y = demoGt->dyna.actor.world.pos.y + this->deltaPosY; - this->actor.world.pos.z = demoGt->dyna.actor.world.pos.z + this->deltaPosZ; + pthis->actor.world.pos.x = demoGt->dyna.actor.world.pos.x + pthis->deltaPosX; + pthis->actor.world.pos.y = demoGt->dyna.actor.world.pos.y + pthis->deltaPosY; + pthis->actor.world.pos.z = demoGt->dyna.actor.world.pos.z + pthis->deltaPosZ; } } -void func_80978308(DemoGeff* this, GlobalContext* globalCtx) { - func_809781FC(this, globalCtx); - func_809782A0(this, globalCtx); - func_80978030(this, globalCtx); +void func_80978308(DemoGeff* pthis, GlobalContext* globalCtx) { + func_809781FC(pthis, globalCtx); + func_809782A0(pthis, globalCtx); + func_80978030(pthis, globalCtx); } -void func_80978344(DemoGeff* this, GlobalContext* globalCtx) { +void func_80978344(DemoGeff* pthis, GlobalContext* globalCtx) { func_80977EA8(globalCtx, gGanonRubbleDL); } -void func_80978370(DemoGeff* this, GlobalContext* globalCtx) { - s16 params = this->actor.params; +void func_80978370(DemoGeff* pthis, GlobalContext* globalCtx) { + s16 params = pthis->actor.params; DemoGeffInitFunc initFunc = sInitFuncs[params]; if (initFunc == NULL) { osSyncPrintf(VT_FGCOL(RED) " Demo_Geff_main_init:初期化処理がおかしいarg_data = %d!\n" VT_RST, params); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - initFunc(this, globalCtx); + initFunc(pthis, globalCtx); } -void func_809783D4(DemoGeff* this, GlobalContext* globalCtx) { +void func_809783D4(DemoGeff* pthis, GlobalContext* globalCtx) { ObjectContext* objCtx = &globalCtx->objectCtx; - Actor* thisx = &this->actor; + Actor* thisx = &pthis->actor; s32 params = thisx->params; s16 objectId = sObjectIDs[params]; s32 objBankIndex = Object_GetIndex(objCtx, objectId); @@ -204,34 +204,34 @@ void func_809783D4(DemoGeff* this, GlobalContext* globalCtx) { return; } if (Object_IsLoaded(objCtx, objBankIndex)) { - this->objBankIndex = objBankIndex; - func_80978370(this, globalCtx); + pthis->objBankIndex = objBankIndex; + func_80978370(pthis, globalCtx); } } void DemoGeff_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoGeff* this = (DemoGeff*)thisx; + DemoGeff* pthis = (DemoGeff*)thisx; - if (this->action < 0 || this->action >= 2 || sActionFuncs[this->action] == NULL) { + if (pthis->action < 0 || pthis->action >= 2 || sActionFuncs[pthis->action] == NULL) { osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - sActionFuncs[this->action](this, globalCtx); + sActionFuncs[pthis->action](pthis, globalCtx); } -void func_809784D4(DemoGeff* this, GlobalContext* globalCtx) { +void func_809784D4(DemoGeff* pthis, GlobalContext* globalCtx) { } void DemoGeff_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoGeff* this = (DemoGeff*)thisx; - s32 drawConfig = this->drawConfig; + DemoGeff* pthis = (DemoGeff*)thisx; + s32 drawConfig = pthis->drawConfig; if (drawConfig < 0 || drawConfig >= 2 || sDrawFuncs[drawConfig] == NULL) { osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } if (drawConfig != 0) { - func_80977F80(this, globalCtx); + func_80977F80(pthis, globalCtx); } - sDrawFuncs[drawConfig](this, globalCtx); + sDrawFuncs[drawConfig](pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c deleted file mode 100644 index 267c0d600..000000000 --- a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c +++ /dev/null @@ -1,1476 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_GJ_Z_DEMO_GJ_C -#include "actor_common.h" -/* - * File: z_demo_gj.c - * Overlay: Demo_Gj - * Description: Ganon battle rubble. - */ - -#include "z_demo_gj.h" -#include "objects/object_gj/object_gj.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/code_8006BA00.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void DemoGj_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoGj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoGj_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoGj_Draw(Actor* thisx, GlobalContext* globalCtx); - -static ColliderCylinderInitType1 sCylinderInit1 = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 30, 100, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInitType1 sCylinderInit2 = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 25, 110, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInitType1 sCylinderInit3 = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 25, 200, 0, { 0, 0, 0 } }, -}; - -typedef void (*DemoGjUpdateFunc)(DemoGj*, GlobalContext*); -typedef void (*DemoGjDrawFunc)(DemoGj*, GlobalContext*); - -// bits 11-15 -s32 DemoGj_GetCollectibleType(DemoGj* this) { - s32 params = this->dyna.actor.params >> 0xB; - - return params & 0x1F; -} - -// bits 8-10 -s32 DemoGj_GetCollectibleAmount(DemoGj* this) { - s32 params = this->dyna.actor.params >> 0x8; - - return params & 7; -} - -// bits 0-7 -s32 DemoGj_GetType(DemoGj* this) { - s32 params = this->dyna.actor.params; - - return params & 0xFF; -} - -void DemoGj_InitCylinder(DemoGj* this, GlobalContext* globalCtx, ColliderCylinder* cylinder, - ColliderCylinderInitType1* cylinderInit) { - Collider_InitCylinder(globalCtx, cylinder); - Collider_SetCylinderType1(globalCtx, cylinder, &this->dyna.actor, cylinderInit); -} - -s32 DemoGj_HitByExplosion(DemoGj* this, GlobalContext* globalCtx, ColliderCylinder* cylinder) { - if (Actor_GetCollidedExplosive(globalCtx, &cylinder->base) != NULL) { - return true; - } - return false; -} - -void DemoGj_DestroyCylinder(DemoGj* this, GlobalContext* globalCtx) { - switch (DemoGj_GetType(this)) { - case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1: - Collider_DestroyCylinder(globalCtx, &this->cylinders[0]); - Collider_DestroyCylinder(globalCtx, &this->cylinders[1]); - Collider_DestroyCylinder(globalCtx, &this->cylinders[2]); - break; - - case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_2: - Collider_DestroyCylinder(globalCtx, &this->cylinders[0]); - Collider_DestroyCylinder(globalCtx, &this->cylinders[1]); - Collider_DestroyCylinder(globalCtx, &this->cylinders[2]); - break; - - case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_TALL: - Collider_DestroyCylinder(globalCtx, &this->cylinders[0]); - break; - } -} - -void DemoGj_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoGj* this = (DemoGj*)thisx; - - DemoGj_DestroyCylinder(this, globalCtx); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void DemoGj_PlayExplosionSfx(DemoGj* this, GlobalContext* globalCtx) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 50, NA_SE_EV_GRAVE_EXPLOSION); -} - -void DemoGj_SpawnSmoke(GlobalContext* globalCtx, Vec3f* pos, f32 arg2) { - static Vec3f velocity = { 0.0f, 6.0f, 0.0f }; - static Vec3f accel = { 0.0f, 0.0f, 0.0f }; - static Color_RGBA8 primColor = { 0, 0, 0, 0 }; - static Color_RGBA8 envColor = { 0, 0, 0, 0 }; - f32 temp = arg2 * 0.2f; - - if (1) {} - func_800283D4(globalCtx, pos, &velocity, &accel, &primColor, &envColor, temp * Rand_ZeroOne() + arg2, 15, 90); -} - -void DemoGj_DropCollectible(DemoGj* this, GlobalContext* globalCtx) { - Vec3f* pos = &this->dyna.actor.world.pos; - s16 collectible = DemoGj_GetCollectibleType(this); - s32 amount = DemoGj_GetCollectibleAmount(this); - s32 i; - - for (i = 0; i < amount; i++) { - Item_DropCollectible(globalCtx, pos, collectible); - } -} - -void DemoGj_Explode(DemoGj* this, GlobalContext* globalCtx, Vec3f* initialPos, Vec3f* direction) { - Vec3f explosionPos; - Vec3f velocity; - s32 phi_s0; - f32 aux; - s16 theta = 0; - s32 i; - - for (i = 0; i < 6; i++) { - explosionPos.x = Math_SinS(theta) * 16.0f; - explosionPos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - explosionPos.z = Math_CosS(theta) * 16.0f; - - velocity.x = (explosionPos.x * 0.6f) + (12.0f * direction->x); - velocity.y = (Rand_ZeroOne() * 36.0f) + 6.0f; - velocity.z = (explosionPos.z * 0.6f) + (12.0f * direction->z); - - explosionPos.x += initialPos->x; - explosionPos.y += initialPos->y; - explosionPos.z += initialPos->z; - - aux = Rand_ZeroOne(); - if (aux < 0.1f) { - phi_s0 = 0x61; - } else if (aux < 0.7f) { - phi_s0 = 0x41; - } else { - phi_s0 = 0x21; - } - - EffectSsKakera_Spawn(globalCtx, &explosionPos, &velocity, initialPos, -200, phi_s0, 10, 10, 0, - Rand_ZeroOne() * 20.0f + 20.0f, 20, 300, (s32)(Rand_ZeroOne() * 30.0f) + 30, -1, - OBJECT_GEFF, &gGanonsCastleRubbleAroundArenaDL[28]); - - theta += 0x2AAA; - } - - DemoGj_PlayExplosionSfx(this, globalCtx); -} - -s32 DemoGj_IsSceneInvalid(void) { - if (gSaveContext.sceneSetupIndex < 4) { - return false; - } - return true; -} - -s32 DemoGj_FindGanon(DemoGj* this, GlobalContext* globalCtx) { - Actor* actor; - - if (this->ganon == NULL) { - actor = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].head; - - while (actor != NULL) { - if (actor->id == ACTOR_BOSS_GANON2) { - this->ganon = (BossGanon2*)actor; - - // "Demo_Gj_Search_Boss_Ganon %d: Discover Ganon !!!!" - osSyncPrintf("Demo_Gj_Search_Boss_Ganon %d:ガノン発見!!!!\n", this->dyna.actor.params); - return true; - } - actor = actor->next; - } - - // "Demo_Gj_Search_Boss_Ganon %d: I couldn't find Ganon" - osSyncPrintf("Demo_Gj_Search_Boss_Ganon %d:ガノン発見出来ず\n", this->dyna.actor.params); - return false; - } - //! @bug: Missing return value when `this->ganon` is already set. - return false; -} - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void DemoGj_InitCommon(DemoGj* this, GlobalContext* globalCtx, CollisionHeader* header) { - s32 pad[3]; - CollisionHeader* newHeader; - - if (header != NULL) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - newHeader = NULL; - CollisionHeader_GetVirtual(header, &newHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, newHeader); - } -} - -// TODO: find a better name -s32 DemoGj_InitSetIndexes(DemoGj* this, GlobalContext* globalCtx, s32 updateMode, s32 drawConfig, - CollisionHeader* header) { - if (!DemoGj_IsSceneInvalid()) { - this->updateMode = updateMode; - this->drawConfig = drawConfig; - DemoGj_InitCommon(this, globalCtx, header); - return true; - } - Actor_Kill(&this->dyna.actor); - return false; -} - -void DemoGj_DrawCommon(DemoGj* this, GlobalContext* globalCtx, Gfx* displayList) { - if (kREG(0) == 0) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_demo_gj.c", 1163); - - func_80093D18(gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_demo_gj.c", 1165), - G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_OPA_DISP++, displayList); - gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); - - CLOSE_DISPS(gfxCtx, "../z_demo_gj.c", 1169); - } -} - -void DemoGj_DrawRotated(DemoGj* this, GlobalContext* globalCtx, Gfx* displayList) { - s32 pad; - GraphicsContext* gfxCtx; - s16 x = this->rotationVec.x; - s16 y = this->rotationVec.y; - s16 z = this->rotationVec.z; - s32 pad2; - Mtx* matrix; - - gfxCtx = globalCtx->state.gfxCtx; - matrix = Graph_Alloc(gfxCtx, sizeof(Mtx)); - - OPEN_DISPS(gfxCtx, "../z_demo_gj.c", 1187); - - Matrix_Push(); - Matrix_RotateZYX(x, y, z, MTXMODE_APPLY); - Matrix_ToMtx(matrix, "../z_demo_gj.c", 1193); - Matrix_Pop(); - - func_80093D18(gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, matrix, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, displayList); - gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); - - CLOSE_DISPS(gfxCtx, "../z_demo_gj.c", 1201); -} - -void DemoGj_SetupRotation(DemoGj* this, GlobalContext* globalCtx) { - f32 yPosition = this->dyna.actor.world.pos.y; - f32* yVelocity = &this->dyna.actor.velocity.y; - f32* speedXZ = &this->dyna.actor.speedXZ; - Vec3s* unk_172 = &this->unk_172; - f32 verticalTranslation; - Vec3f vec; - f32 verticalFactor; - f32 xzPlaneFactor; - - switch (DemoGj_GetType(this)) { - case DEMOGJ_TYPE_RUBBLE_PILE_1: - verticalTranslation = kREG(23); - vec.x = kREG(24) * 0.01f + 1.0f; - vec.y = kREG(25) * 0.01f + 1.0f; - vec.z = kREG(26) * 0.01f + 1.0f; - verticalFactor = kREG(27) * 0.01f + -1.0f; - xzPlaneFactor = kREG(28) * 0.01f + 1.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_2: - verticalTranslation = kREG(36); - vec.x = kREG(37) * 0.01f + 1.0f; - vec.y = kREG(38) * 0.01f + 1.0f; - vec.z = kREG(39) * 0.01f + 1.0f; - verticalFactor = kREG(40) * 0.01f + -1.0f; - xzPlaneFactor = kREG(41) * 0.01f + 1.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_3: - verticalTranslation = kREG(49); - vec.x = kREG(50) * 0.01f + 1.0f; - vec.y = kREG(51) * 0.01f + 1.0f; - vec.z = kREG(52) * 0.01f + 1.0f; - verticalFactor = kREG(53) * 0.01f + -1.0f; - xzPlaneFactor = kREG(54) * 0.01f + 1.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_4: - verticalTranslation = kREG(62); - vec.x = kREG(63) * 0.01f + 1.0f; - vec.y = kREG(64) * 0.01f + 1.0f; - vec.z = kREG(65) * 0.01f + 1.0f; - verticalFactor = kREG(66) * 0.01f + -1.0f; - xzPlaneFactor = kREG(67) * 0.01f + 1.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_5: - verticalTranslation = kREG(75); - vec.x = kREG(76) * 0.01f + 1.0f; - vec.y = kREG(77) * 0.01f + 1.0f; - vec.z = kREG(78) * 0.01f + 1.0f; - verticalFactor = kREG(79) * 0.01f + -1.0f; - xzPlaneFactor = kREG(80) * 0.01f + 1.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_6: - verticalTranslation = kREG(88); - vec.x = kREG(89) * 0.01f + 1.0f; - vec.y = kREG(90) * 0.01f + 1.0f; - vec.z = kREG(91) * 0.01f + 1.0f; - verticalFactor = kREG(92) * 0.01f + -1.0f; - xzPlaneFactor = kREG(93) * 0.01f + 1.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_7: - verticalTranslation = kREG(10) + -190.0f; - vec.x = kREG(9) * 0.01f + 1.0f; - vec.y = kREG(8) * 0.01f + 1.0f; - vec.z = kREG(7) * 0.01f + 1.0f; - verticalFactor = kREG(6) * 0.01f + -1.0f; - xzPlaneFactor = kREG(5) * 0.01f + 1.0f; - break; - - default: - // "Demo_Gj_common_Reflect : This arg_data is not supported = %d" - osSyncPrintf(VT_FGCOL(RED) "Demo_Gj_common_Reflect : そんなarg_dataには対応していない = %d\n" VT_RST, - this->dyna.actor.params); - return; - } - - yPosition += verticalTranslation; - if (yPosition <= 1086.0f && (*yVelocity < 0.0f)) { - if (!this->isRotated) { - *yVelocity *= verticalFactor; - *speedXZ *= xzPlaneFactor; - - unk_172->x *= vec.x; - unk_172->y *= vec.y; - unk_172->z *= vec.z; - - if (*yVelocity <= -this->dyna.actor.gravity) { - *yVelocity = 0.0f; - *speedXZ = 0.0f; - - unk_172->x = 0; - unk_172->y = 0; - unk_172->z = 0; - } - - this->isRotated = true; - } - } -} - -/* - * Returns true if `ganon->unk_314` is equals to `arg1`. - * `ganon->unk_314` can have the following values: - * 0: Before the battle has started. - * 1: When is set: Ganondorf starts rising from the rubble. - * What is happening: Ganondorf is moving vertically and has vertical velocity. - * Proposed name: BOSSGANON2_MODE_GANONDORF_RISING - * 2: When is set: Ganondorf has stopped rising in air. - * What is happening: The camera is in front of him, focusing the clouds and going down to focus him. - * Proposed name: BOSSGANON2_MODE_GANONDORF_FLOATING - * 3: When is set: The camera has stopped moving and is focusing him. - * What is happening: Ganondorf raises his hand, shows the triforce and transforms into Ganon. The battle starts. - * This value is set during the whole real fight against Ganon. Without and with Master Sword. - * Proposed name: BOSSGANON2_MODE_GANON_FIGHTING - * 4: When is set: Link has hit Ganon's tail for last time with Master Sword. - * What is happening: Ganon falls to the floor, Zelda uses her magic and tells Link to kill him. - * Proposed name: BOSSGANON2_MODE_GANON_DEFEATED - * - * Those values should probably be defined as macros or enums in `ovl_Boss_Ganon2/z_boss_ganon2.h`. - * Proposed name for the function: `s32 DemoGj_CheckGanonMode(DemoGj* this, u8 mode)` - */ -s32 func_809797E4(DemoGj* this, u8 arg1) { - BossGanon2* ganon = this->ganon; - - if ((ganon != NULL) && (ganon->unk_314 == arg1)) { - return true; - } - return false; -} - -s32 DemoGj_IsGanondorfRisingFromRubble(DemoGj* this, GlobalContext* globalCtx) { - return func_809797E4(this, 1); -} - -// Ganondorf has stopped rising into the air and is just floating. Just before he transforms. -s32 DemoGj_IsGanondorfFloatingInAir(DemoGj* this, GlobalContext* globalCtx) { - return func_809797E4(this, 2); -} - -void DemoGj_SetupMovement(DemoGj* this, GlobalContext* globalCtx) { - Actor* actor = &this->dyna.actor; - Player* player; - Vec3f* pos = &actor->world.pos; - Vec3s* unk_172; - f32 xDistance; - f32 zDistance; - - if (this->ganon != NULL) { - xDistance = actor->world.pos.x - this->ganon->actor.world.pos.x; - zDistance = actor->world.pos.z - this->ganon->actor.world.pos.z; - unk_172 = &this->unk_172; - - switch (DemoGj_GetType(this)) { - case DEMOGJ_TYPE_RUBBLE_PILE_1: - actor->speedXZ = kREG(16) + 10.0f; - actor->velocity.y = kREG(17) + 40.0f; - unk_172->x = kREG(18); - unk_172->y = kREG(19) + 0x3E8; - unk_172->z = kREG(20) + 0xBB8; - actor->minVelocityY = kREG(21) * 0.01f + -29.0f; - actor->gravity = kREG(22) * 0.01f + -5.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_2: - actor->speedXZ = kREG(29) + 10.0f; - actor->velocity.y = kREG(30) + 40.0f; - unk_172->x = kREG(31); - unk_172->y = kREG(32) + 0x3E8; - unk_172->z = kREG(33) + 0xBB8; - actor->minVelocityY = kREG(34) * 0.01f + -29.0f; - actor->gravity = kREG(35) * 0.01f + -5.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_3: - actor->speedXZ = kREG(42) + 10.0f; - actor->velocity.y = kREG(43) + 40.0f; - unk_172->x = kREG(44); - unk_172->y = kREG(45) + 0x3E8; - unk_172->z = kREG(46) + 0xBB8; - actor->minVelocityY = kREG(47) * 0.01f + -29.0f; - actor->gravity = kREG(48) * 0.01f + -5.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_4: - actor->speedXZ = kREG(55) + 10.0f; - actor->velocity.y = kREG(56) + 40.0f; - unk_172->x = kREG(57); - unk_172->y = kREG(58) + 0x3E8; - unk_172->z = kREG(59) + 0xBB8; - actor->minVelocityY = kREG(60) * 0.01f + -29.0f; - actor->gravity = kREG(61) * 0.01f + -5.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_5: - actor->speedXZ = kREG(68) + 10.0f; - actor->velocity.y = kREG(69) + 40.0f; - unk_172->x = kREG(70); - unk_172->y = kREG(71) + 0x3E8; - unk_172->z = kREG(72) + 0xBB8; - actor->minVelocityY = kREG(73) * 0.01f + -29.0f; - actor->gravity = kREG(74) * 0.01f + -5.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_6: - actor->speedXZ = kREG(81) + 10.0f; - actor->velocity.y = kREG(82) + 40.0f; - unk_172->x = kREG(83); - unk_172->y = kREG(84) + 0x3E8; - unk_172->z = kREG(85) + 0xBB8; - actor->minVelocityY = kREG(86) * 0.01f + -29.0f; - actor->gravity = kREG(87) * 0.01f + -5.0f; - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_7: - actor->speedXZ = kREG(94) + 10.0f; - actor->velocity.y = kREG(95) + 70.0f; - unk_172->x = kREG(15); - unk_172->y = kREG(14) + 0x3E8; - unk_172->z = kREG(13) + 0xBB8; - actor->minVelocityY = kREG(12) * 0.01f + -29.0f; - actor->gravity = kREG(11) * 0.01f + -5.0f; - break; - - default: - // "Demo_Gj_Setup_Move_common : This arg_data is not supported = %d" - osSyncPrintf(VT_FGCOL(RED) "Demo_Gj_Setup_Move_common : そんなarg_dataには対応していない = %d\n" VT_RST, - actor->params); - break; - } - - if (xDistance == 0.0f && zDistance == 0.0f) { - player = GET_PLAYER(globalCtx); - xDistance = player->actor.world.pos.x - pos->x; - zDistance = player->actor.world.pos.z - pos->z; - - if (xDistance != 0.0f || zDistance != 0.0f) { - actor->world.rot.y = (Math_FAtan2F(xDistance, zDistance) * (0x8000 / M_PI)); - } - } else { - actor->world.rot.y = (Math_FAtan2F(xDistance, zDistance) * (0x8000 / M_PI)); - } - } -} - -void DemoGj_CheckIfTransformedIntoGanon(DemoGj* this) { - if (func_809797E4(this, 3)) { - this->isTransformedIntoGanon = true; - } -} - -void DemoGj_InitRubblePile1(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 1, 2, &gGanonsCastleRubble2Col); -} - -void func_8097A000(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(18)); - this->rotationVec.y += (s16)(kREG(19) + 1000); - this->rotationVec.z += (s16)(kREG(20) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void DemoGj_SpawnSmokePreBattle1(DemoGj* this, GlobalContext* globalCtx) { - static Vec3f pos = { -371.0f, 1188.0f, -303.0f }; - u32 gameplayFrames; - - if (!this->isTransformedIntoGanon) { - gameplayFrames = globalCtx->gameplayFrames % 3; - - if (1) {} - if (gameplayFrames == 0) { - if (!globalCtx->gameplayFrames) {} - DemoGj_SpawnSmoke(globalCtx, &pos, 300.0f); - } - - DemoGj_CheckIfTransformedIntoGanon(this); - } -} - -void func_8097A0E4(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 8; - this->drawConfig = 9; - } -} - -void func_8097A130(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097A160 -void DemoGj_Update01(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097A0E4(this, globalCtx); -} - -// func_8097A190 -void DemoGj_Update08(DemoGj* this, GlobalContext* globalCtx) { - func_8097A000(this, globalCtx); - func_8097A130(this, globalCtx); -} - -void DemoGj_DrawRubble2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble2DL); -} - -void DemoGj_DrawRotatedRubble2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubble2DL); -} - -void DemoGj_InitRubblePile2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 2, 3, &gGanonsCastleRubble3Col); -} - -void func_8097A238(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(31)); - this->rotationVec.y += (s16)(kREG(32) + 1000); - this->rotationVec.z += (s16)(kREG(33) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void DemoGj_SpawnSmokePreBattle2(DemoGj* this, GlobalContext* globalCtx) { - static Vec3f pos = { -119.0f, 1056.0f, -147.0f }; - u32 gameplayFrames; - - if (!this->isTransformedIntoGanon) { - gameplayFrames = globalCtx->gameplayFrames % 3; - - if (1) {} - if (gameplayFrames == 1) { - if (!globalCtx->gameplayFrames) {} - DemoGj_SpawnSmoke(globalCtx, &pos, 300.0f); - } - - DemoGj_CheckIfTransformedIntoGanon(this); - } -} - -void func_8097A320(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 9; - this->drawConfig = 10; - } -} - -void func_8097A36C(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097A39C -void DemoGj_Update02(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097A320(this, globalCtx); -} - -// func_8097A3CC -void DemoGj_Update09(DemoGj* this, GlobalContext* globalCtx) { - func_8097A238(this, globalCtx); - func_8097A36C(this, globalCtx); -} - -void DemoGj_DrawRubble3(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble3DL); -} - -void DemoGj_DrawRotatedRubble3(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubble3DL); -} - -void DemoGj_InitRubblePile3(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 3, 4, &gGanonsCastleRubble4Col); -} - -void func_8097A474(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(44)); - this->rotationVec.y += (s16)(kREG(45) + 1000); - this->rotationVec.z += (s16)(kREG(46) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void func_8097A4F0(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 10; - this->drawConfig = 11; - } -} - -void func_8097A53C(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097A56C -void DemoGj_Update03(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097A4F0(this, globalCtx); -} - -// func_8097A59C -void DemoGj_Update10(DemoGj* this, GlobalContext* globalCtx) { - func_8097A474(this, globalCtx); - func_8097A53C(this, globalCtx); -} - -void DemoGj_DrawRubble4(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble4DL); -} - -void DemoGj_DrawRotatedRubble4(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubble4DL); -} - -void DemoGj_InitRubblePile4(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 4, 5, &gGanonsCastleRubble5Col); -} - -void func_8097A644(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(57)); - this->rotationVec.y += (s16)(kREG(58) + 1000); - this->rotationVec.z += (s16)(kREG(59) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void func_8097A6C0(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 11; - this->drawConfig = 12; - } -} - -void func_8097A70C(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097A73C -void DemoGj_Update04(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097A6C0(this, globalCtx); -} - -// func_8097A76C -void DemoGj_Update11(DemoGj* this, GlobalContext* globalCtx) { - func_8097A644(this, globalCtx); - func_8097A70C(this, globalCtx); -} - -void DemoGj_DrawRubble5(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble5DL); -} - -void DemoGj_DrawRotatedRubble5(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubble5DL); -} - -void DemoGj_InitRubblePile5(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 5, 6, &gGanonsCastleRubble6Col); -} - -void func_8097A814(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(70)); - this->rotationVec.y += (s16)(kREG(71) + 1000); - this->rotationVec.z += (s16)(kREG(72) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void func_8097A890(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 12; - this->drawConfig = 13; - } -} - -void func_8097A8DC(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097A90C -void DemoGj_Update05(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097A890(this, globalCtx); -} - -// func_8097A93C -void DemoGj_Update12(DemoGj* this, GlobalContext* globalCtx) { - func_8097A814(this, globalCtx); - func_8097A8DC(this, globalCtx); -} - -void DemoGj_DrawRubble6(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble6DL); -} - -void DemoGj_DrawRotatedRubble6(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubble6DL); -} - -void DemoGj_InitRubblePile6(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 6, 7, &gGanonsCastleRubble7Col); -} - -void func_8097A9E4(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(83)); - this->rotationVec.y += (s16)(kREG(84) + 1000); - this->rotationVec.z += (s16)(kREG(85) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void func_8097AA60(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 13; - this->drawConfig = 14; - } -} - -void func_8097AAAC(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097AADC -void DemoGj_Update06(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097AA60(this, globalCtx); -} - -// func_8097AB0C -void DemoGj_Update13(DemoGj* this, GlobalContext* globalCtx) { - func_8097A9E4(this, globalCtx); - func_8097AAAC(this, globalCtx); -} - -void DemoGj_DrawRubble7(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble7DL); -} - -void DemoGj_DrawRotatedRubble7(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubble7DL); -} - -void DemoGj_InitRubblePile7(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 7, 8, &gGanonsCastleRubbleTallCol); -} - -void func_8097ABB4(DemoGj* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - - this->rotationVec.x += (s16)(kREG(15)); - this->rotationVec.y += (s16)(kREG(14) + 1000); - this->rotationVec.z += (s16)(kREG(13) + 3000); - - DemoGj_SetupRotation(this, globalCtx); -} - -void DemoGj_SpawnSmokePreBattle3(DemoGj* this, GlobalContext* globalCtx) { - static Vec3f pos = { -6.0f, 1053.0f, -473.0f }; - u32 gameplayFrames; - - if (!this->isTransformedIntoGanon) { - gameplayFrames = globalCtx->gameplayFrames % 3; - - if (1) {} - if (gameplayFrames == 2) { - if (!globalCtx->gameplayFrames) {} - DemoGj_SpawnSmoke(globalCtx, &pos, 300.0f); - } - - DemoGj_CheckIfTransformedIntoGanon(this); - } -} - -void func_8097AC9C(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfRisingFromRubble(this, globalCtx)) { - DemoGj_SetupMovement(this, globalCtx); - this->updateMode = 14; - this->drawConfig = 15; - } -} - -void func_8097ACE8(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Actor_Kill(&this->dyna.actor); - } -} - -// func_8097AD18 -void DemoGj_Update07(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097AC9C(this, globalCtx); -} - -// func_8097AD48 -void DemoGj_Update14(DemoGj* this, GlobalContext* globalCtx) { - func_8097ABB4(this, globalCtx); - func_8097ACE8(this, globalCtx); -} - -void DemoGj_DrawRubbleTall(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubbleTallDL); -} - -void DemoGj_DrawRotatedRubbleTall(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawRotated(this, globalCtx, gGanonsCastleRubbleTallDL); -} - -void DemoGj_InitRubbleAroundArena(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 0, 1, &gGanonsCastleRubbleAroundArenaCol); -} - -// func_8097ADF0 -void DemoGj_UpdateRubbleAroundArena(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - DemoGj_SpawnSmokePreBattle1(this, globalCtx); - DemoGj_SpawnSmokePreBattle2(this, globalCtx); - DemoGj_SpawnSmokePreBattle3(this, globalCtx); -} - -void DemoGj_DrawRubbleAroundArena(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubbleAroundArenaDL); -} - -// Inits the three cylinders with `sCylinderInit1` -void DemoGj_InitDestructableRubble1(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 15, 0, NULL); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[0], &sCylinderInit1); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[1], &sCylinderInit1); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[2], &sCylinderInit1); -} - -void DemoGj_DoNothing1(DemoGj* this, GlobalContext* globalCtx) { -} - -/* - * Moves the ColliderCylinder's relative to the actor's position. - * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1 - */ -void func_8097AEE8(DemoGj* this, GlobalContext* globalCtx) { - ColliderCylinder* cylinder0 = &this->cylinders[0]; - ColliderCylinder* cylinder1 = &this->cylinders[1]; - ColliderCylinder* cylinder2 = &this->cylinders[2]; - Vec3f* actorPos = &this->dyna.actor.world.pos; - s32 pad; - s16 theta = this->dyna.actor.world.rot.y; - f32 cos_theta = Math_CosS(theta); - f32 sin_theta = Math_SinS(theta); - - cylinder0->dim.pos.z = actorPos->z + (20.0f * cos_theta) - (-20.0f * sin_theta); - cylinder0->dim.pos.x = actorPos->x + (20.0f * sin_theta) + (-20.0f * cos_theta); - cylinder0->dim.pos.y = actorPos->y; - - cylinder1->dim.pos.z = actorPos->z + (-20.0f * cos_theta) - (20.0f * sin_theta); - cylinder1->dim.pos.x = actorPos->x + (-20.0f * sin_theta) + (20.0f * cos_theta); - cylinder1->dim.pos.y = actorPos->y; - - cylinder2->dim.pos.z = actorPos->z + (-60.0f * cos_theta) - (60.0f * sin_theta); - cylinder2->dim.pos.x = actorPos->x + (-60.0f * sin_theta) + (60.0f * cos_theta); - cylinder2->dim.pos.y = actorPos->y; -} - -void DemoGj_SetCylindersAsAC(DemoGj* this, GlobalContext* globalCtx) { - s32 pad[2]; - Collider* cylinder0 = &this->cylinders[0].base; - Collider* cylinder1 = &this->cylinders[1].base; - Collider* cylinder2 = &this->cylinders[2].base; - s32 pad2[3]; - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder0); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder1); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder2); -} - -void DemoGj_DirectedExplosion(DemoGj* this, GlobalContext* globalCtx, Vec3f* direction) { - Vec3f pos; - - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y; - pos.z = this->dyna.actor.world.pos.z; - - DemoGj_Explode(this, globalCtx, &pos, direction); -} - -void func_8097B128(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Vec3f* scale = &this->dyna.actor.scale; - - DemoGj_InitCommon(this, globalCtx, &gGanonsCastleRubble2Col); - this->updateMode = 18; - this->drawConfig = 16; - scale->x *= 0.8f; - scale->y *= 0.8f; - scale->z *= 0.8f; - } -} - -s32 DemoGj_HasCylinderAnyExploded(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_HitByExplosion(this, globalCtx, &this->cylinders[0])) { - return true; - } - if (DemoGj_HitByExplosion(this, globalCtx, &this->cylinders[1])) { - return true; - } - if (DemoGj_HitByExplosion(this, globalCtx, &this->cylinders[2])) { - return true; - } - return false; -} - -/* - * Checks if should kill the actor and drop collectibles - * Kills the actor if ganon->unk_314==4 (Ganon killed), this rubble was hit by an explosion or killFlag==true - * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1 - */ -void func_8097B22C(DemoGj* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - - if (func_809797E4(this, 4)) { - Actor_Kill(thisx); - } else if (DemoGj_HasCylinderAnyExploded(this, globalCtx)) { - Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; - - DemoGj_DropCollectible(this, globalCtx); - DemoGj_DirectedExplosion(this, globalCtx, &vec1); - - Actor_Kill(thisx); - } else if (this->killFlag) { - Vec3f vec2 = this->unk_26C; - vec2.y = 0.0f; - - DemoGj_DropCollectible(this, globalCtx); - DemoGj_DirectedExplosion(this, globalCtx, &vec2); - - Actor_Kill(thisx); - } - - func_8097AEE8(this, globalCtx); - DemoGj_SetCylindersAsAC(this, globalCtx); -} - -// func_8097B340 -void DemoGj_Update15(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097B128(this, globalCtx); -} - -// func_8097B370 -void DemoGj_Update18(DemoGj* this, GlobalContext* globalCtx) { - func_8097B22C(this, globalCtx); - DemoGj_DoNothing1(this, globalCtx); -} - -void DemoGj_DrawDestructableRubble1(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble2DL); -} - -// Inits the three cylinders with `sCylinderInit2` -void DemoGj_InitDestructableRubble2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 16, 0, NULL); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[0], &sCylinderInit2); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[1], &sCylinderInit2); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[2], &sCylinderInit2); -} - -void DemoGj_DoNothing2(DemoGj* this, GlobalContext* globalCtx) { -} - -// Moves the ColliderCylinder's relative to the actor's position. -void func_8097B450(DemoGj* this, GlobalContext* globalCtx) { - ColliderCylinder* cylinder0 = &this->cylinders[0]; - ColliderCylinder* cylinder1 = &this->cylinders[1]; - ColliderCylinder* cylinder2 = &this->cylinders[2]; - Vec3f* actorPos = &this->dyna.actor.world.pos; - s32 pad; - s16 theta = this->dyna.actor.world.rot.y; - f32 cos_theta = Math_CosS(theta); - f32 sin_theta = Math_SinS(theta); - - cylinder0->dim.pos.z = actorPos->z - (35.0f * sin_theta); - cylinder0->dim.pos.x = actorPos->x + (35.0f * cos_theta); - cylinder0->dim.pos.y = actorPos->y; - - cylinder1->dim.pos.z = actorPos->z - (-10.0f * sin_theta); - cylinder1->dim.pos.x = actorPos->x + (-10.0f * cos_theta); - cylinder1->dim.pos.y = actorPos->y; - - cylinder2->dim.pos.z = actorPos->z - (-55.0f * sin_theta); - cylinder2->dim.pos.x = actorPos->x + (-55.0f * cos_theta); - cylinder2->dim.pos.y = actorPos->y; -} - -void DemoGj_SetCylindersAsAC2(DemoGj* this, GlobalContext* globalCtx) { - s32 pad[2]; - Collider* cylinder0 = &this->cylinders[0].base; - Collider* cylinder1 = &this->cylinders[1].base; - Collider* cylinder2 = &this->cylinders[2].base; - s32 pad2[3]; - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder0); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder1); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder2); -} - -// Does the same as `DemoGj_HasCylinderAnyExploded` -s32 DemoGj_HasCylinderAnyExploded2(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_HitByExplosion(this, globalCtx, &this->cylinders[0])) { - return true; - } - if (DemoGj_HitByExplosion(this, globalCtx, &this->cylinders[1])) { - return true; - } - if (DemoGj_HitByExplosion(this, globalCtx, &this->cylinders[2])) { - return true; - } - return false; -} - -void DemoGj_DirectedExplosion2(DemoGj* this, GlobalContext* globalCtx, Vec3f* direction) { - Vec3f pos; - - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y; - pos.z = this->dyna.actor.world.pos.z; - - DemoGj_Explode(this, globalCtx, &pos, direction); -} - -void func_8097B6C4(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Vec3f* scale = &this->dyna.actor.scale; - - DemoGj_InitCommon(this, globalCtx, &gGanonsCastleRubble3Col); - this->updateMode = 19; - this->drawConfig = 17; - scale->x *= 0.8f; - scale->y *= 0.8f; - scale->z *= 0.8f; - } -} - -/* - * Checks if should kill the actor and drop collectibles - * Kills the actor if ganon->unk_314==4 (Ganon killed), this rubble was hit by an explosion or killFlag==true - * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_2 - */ -void func_8097B750(DemoGj* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - - if (func_809797E4(this, 4)) { - Actor_Kill(thisx); - } else if (DemoGj_HasCylinderAnyExploded2(this, globalCtx)) { - Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; - - DemoGj_DropCollectible(this, globalCtx); - DemoGj_DirectedExplosion2(this, globalCtx, &vec1); - - Actor_Kill(thisx); - } else if (this->killFlag) { - Vec3f vec2 = this->unk_26C; - vec2.y = 0.0f; - - DemoGj_DropCollectible(this, globalCtx); - DemoGj_DirectedExplosion2(this, globalCtx, &vec2); - - Actor_Kill(thisx); - } - - func_8097B450(this, globalCtx); - DemoGj_SetCylindersAsAC2(this, globalCtx); -} - -// func_8097B864 -void DemoGj_Update16(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097B6C4(this, globalCtx); -} - -// func_8097B894 -void DemoGj_Update19(DemoGj* this, GlobalContext* globalCtx) { - func_8097B750(this, globalCtx); - DemoGj_DoNothing2(this, globalCtx); -} - -void DemoGj_DemoGj_InitDestructableRubble2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubble3DL); -} - -// Inits the first cylinder (only that one) with `sCylinderInit3` -void DemoGj_InitDestructableRubbleTall(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 17, 0, NULL); - DemoGj_InitCylinder(this, globalCtx, &this->cylinders[0], &sCylinderInit3); -} - -void DemoGj_DoNothing3(DemoGj* this, GlobalContext* globalCtx) { -} - -void DemoGj_DirectedDoubleExplosion(DemoGj* this, GlobalContext* globalCtx, Vec3f* direction) { - Vec3f pos; - - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y; - pos.z = this->dyna.actor.world.pos.z; - DemoGj_Explode(this, globalCtx, &pos, direction); - - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + 100.0f; - pos.z = this->dyna.actor.world.pos.z; - DemoGj_Explode(this, globalCtx, &pos, direction); -} - -void func_8097B9BC(DemoGj* this, GlobalContext* globalCtx) { - if (DemoGj_IsGanondorfFloatingInAir(this, globalCtx)) { - Vec3f* scale = &this->dyna.actor.scale; - - DemoGj_InitCommon(this, globalCtx, &gGanonsCastleRubbleTallCol); - this->updateMode = 20; - this->drawConfig = 18; - scale->x *= 0.8f; - scale->y *= 0.8f; - scale->z *= 0.8f; - } -} - -/* - * Checks if should kill the actor and drop collectibles - * Kills the actor if ganon->unk_314==4 (Ganon killed), this rubble was hit by an explosion or killFlag==true - * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_TALL - */ -void func_8097BA48(DemoGj* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - ColliderCylinder* cylinder = &this->cylinders[0]; - s32 pad[2]; - - if (func_809797E4(this, 4)) { - Actor_Kill(thisx); - } else if (DemoGj_HitByExplosion(this, globalCtx, cylinder)) { - Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; - - DemoGj_DropCollectible(this, globalCtx); - DemoGj_DirectedDoubleExplosion(this, globalCtx, &vec1); - - Actor_Kill(thisx); - } else if (this->killFlag) { - Vec3f vec2 = this->unk_26C; - vec2.y = 0.0f; - - DemoGj_DropCollectible(this, globalCtx); - DemoGj_DirectedDoubleExplosion(this, globalCtx, &vec2); - - Actor_Kill(thisx); - } - - Collider_UpdateCylinder(thisx, cylinder); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &cylinder->base); -} - -// func_8097BB78 -void DemoGj_Update17(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_FindGanon(this, globalCtx); - func_8097B9BC(this, globalCtx); -} - -// func_8097BBA8 -void DemoGj_Update20(DemoGj* this, GlobalContext* globalCtx) { - func_8097BA48(this, globalCtx); - DemoGj_DoNothing3(this, globalCtx); -} - -void DemoGj_DemoGj_InitDestructableRubbleTall(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_DrawCommon(this, globalCtx, gGanonsCastleRubbleTallDL); -} - -static DemoGjUpdateFunc sUpdateFuncs[] = { - DemoGj_UpdateRubbleAroundArena, - DemoGj_Update01, - DemoGj_Update02, - DemoGj_Update03, - DemoGj_Update04, - DemoGj_Update05, - DemoGj_Update06, - DemoGj_Update07, - DemoGj_Update08, - DemoGj_Update09, - DemoGj_Update10, - DemoGj_Update11, - DemoGj_Update12, - DemoGj_Update13, - DemoGj_Update14, - DemoGj_Update15, - DemoGj_Update16, - DemoGj_Update17, - DemoGj_Update18, - DemoGj_Update19, - DemoGj_Update20, -}; - -void DemoGj_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoGj* this = (DemoGj*)thisx; - - if (this->updateMode < 0 || this->updateMode >= ARRAY_COUNT(sUpdateFuncs) || - sUpdateFuncs[this->updateMode] == NULL) { - // "The main mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sUpdateFuncs[this->updateMode](this, globalCtx); -} - -void DemoGj_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoGj* this = (DemoGj*)thisx; - - switch (DemoGj_GetType(this)) { - case DEMOGJ_TYPE_AROUNDARENA: - DemoGj_InitRubbleAroundArena(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_1: - DemoGj_InitRubblePile1(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_2: - DemoGj_InitRubblePile2(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_3: - DemoGj_InitRubblePile3(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_4: - DemoGj_InitRubblePile4(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_5: - DemoGj_InitRubblePile5(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_6: - DemoGj_InitRubblePile6(this, globalCtx); - break; - - case DEMOGJ_TYPE_RUBBLE_PILE_7: - DemoGj_InitRubblePile7(this, globalCtx); - break; - - case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1: - DemoGj_InitDestructableRubble1(this, globalCtx); - break; - - case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_2: - DemoGj_InitDestructableRubble2(this, globalCtx); - break; - - case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_TALL: - DemoGj_InitDestructableRubbleTall(this, globalCtx); - break; - - default: - // "Demo_Gj_Actor_ct There is no such argument!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "Demo_Gj_Actor_ct そんな引数は無い!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST, globalCtx, - this); - Actor_Kill(&this->dyna.actor); - } -} - -void DemoGj_DrawNothing(DemoGj* this, GlobalContext* globalCtx) { -} - -static DemoGjDrawFunc sDrawFuncs[] = { - DemoGj_DrawNothing, - DemoGj_DrawRubbleAroundArena, - DemoGj_DrawRubble2, - DemoGj_DrawRubble3, - DemoGj_DrawRubble4, - DemoGj_DrawRubble5, - DemoGj_DrawRubble6, - DemoGj_DrawRubble7, - DemoGj_DrawRubbleTall, - DemoGj_DrawRotatedRubble2, - DemoGj_DrawRotatedRubble3, - DemoGj_DrawRotatedRubble4, - DemoGj_DrawRotatedRubble5, - DemoGj_DrawRotatedRubble6, - DemoGj_DrawRotatedRubble7, - DemoGj_DrawRotatedRubbleTall, - DemoGj_DrawDestructableRubble1, - DemoGj_DemoGj_InitDestructableRubble2, - DemoGj_DemoGj_InitDestructableRubbleTall, -}; - -void DemoGj_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoGj* this = (DemoGj*)thisx; - - if (this->drawConfig < 0 || this->drawConfig >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[this->drawConfig] == NULL) { - // "The drawing mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sDrawFuncs[this->drawConfig](this, globalCtx); -} - -const ActorInit Demo_Gj_InitVars = { - ACTOR_DEMO_GJ, - ACTORCAT_PROP, - FLAGS, - OBJECT_GJ, - sizeof(DemoGj), - (ActorFunc)DemoGj_Init, - (ActorFunc)DemoGj_Destroy, - (ActorFunc)DemoGj_Update, - (ActorFunc)DemoGj_Draw, -}; diff --git a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.cpp b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.cpp new file mode 100644 index 000000000..197642ae9 --- /dev/null +++ b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.cpp @@ -0,0 +1,1476 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_GJ_Z_DEMO_GJ_C +#include "actor_common.h" +/* + * File: z_demo_gj.c + * Overlay: Demo_Gj + * Description: Ganon battle rubble. + */ + +#include "z_demo_gj.h" +#include "objects/object_gj/object_gj.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/code_8006BA00.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void DemoGj_Init(Actor* thisx, GlobalContext* globalCtx); +void DemoGj_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DemoGj_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoGj_Draw(Actor* thisx, GlobalContext* globalCtx); + +static ColliderCylinderInitType1 sCylinderInit1 = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 30, 100, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInitType1 sCylinderInit2 = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 25, 110, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInitType1 sCylinderInit3 = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 25, 200, 0, { 0, 0, 0 } }, +}; + +typedef void (*DemoGjUpdateFunc)(DemoGj*, GlobalContext*); +typedef void (*DemoGjDrawFunc)(DemoGj*, GlobalContext*); + +// bits 11-15 +s32 DemoGj_GetCollectibleType(DemoGj* pthis) { + s32 params = pthis->dyna.actor.params >> 0xB; + + return params & 0x1F; +} + +// bits 8-10 +s32 DemoGj_GetCollectibleAmount(DemoGj* pthis) { + s32 params = pthis->dyna.actor.params >> 0x8; + + return params & 7; +} + +// bits 0-7 +s32 DemoGj_GetType(DemoGj* pthis) { + s32 params = pthis->dyna.actor.params; + + return params & 0xFF; +} + +void DemoGj_InitCylinder(DemoGj* pthis, GlobalContext* globalCtx, ColliderCylinder* cylinder, + ColliderCylinderInitType1* cylinderInit) { + Collider_InitCylinder(globalCtx, cylinder); + Collider_SetCylinderType1(globalCtx, cylinder, &pthis->dyna.actor, cylinderInit); +} + +s32 DemoGj_HitByExplosion(DemoGj* pthis, GlobalContext* globalCtx, ColliderCylinder* cylinder) { + if (Actor_GetCollidedExplosive(globalCtx, &cylinder->base) != NULL) { + return true; + } + return false; +} + +void DemoGj_DestroyCylinder(DemoGj* pthis, GlobalContext* globalCtx) { + switch (DemoGj_GetType(pthis)) { + case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1: + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[0]); + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[1]); + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[2]); + break; + + case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_2: + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[0]); + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[1]); + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[2]); + break; + + case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_TALL: + Collider_DestroyCylinder(globalCtx, &pthis->cylinders[0]); + break; + } +} + +void DemoGj_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoGj* pthis = (DemoGj*)thisx; + + DemoGj_DestroyCylinder(pthis, globalCtx); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void DemoGj_PlayExplosionSfx(DemoGj* pthis, GlobalContext* globalCtx) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 50, NA_SE_EV_GRAVE_EXPLOSION); +} + +void DemoGj_SpawnSmoke(GlobalContext* globalCtx, Vec3f* pos, f32 arg2) { + static Vec3f velocity = { 0.0f, 6.0f, 0.0f }; + static Vec3f accel = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 primColor = { 0, 0, 0, 0 }; + static Color_RGBA8 envColor = { 0, 0, 0, 0 }; + f32 temp = arg2 * 0.2f; + + if (1) {} + func_800283D4(globalCtx, pos, &velocity, &accel, &primColor, &envColor, temp * Rand_ZeroOne() + arg2, 15, 90); +} + +void DemoGj_DropCollectible(DemoGj* pthis, GlobalContext* globalCtx) { + Vec3f* pos = &pthis->dyna.actor.world.pos; + s16 collectible = DemoGj_GetCollectibleType(pthis); + s32 amount = DemoGj_GetCollectibleAmount(pthis); + s32 i; + + for (i = 0; i < amount; i++) { + Item_DropCollectible(globalCtx, pos, collectible); + } +} + +void DemoGj_Explode(DemoGj* pthis, GlobalContext* globalCtx, Vec3f* initialPos, Vec3f* direction) { + Vec3f explosionPos; + Vec3f velocity; + s32 phi_s0; + f32 aux; + s16 theta = 0; + s32 i; + + for (i = 0; i < 6; i++) { + explosionPos.x = Math_SinS(theta) * 16.0f; + explosionPos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + explosionPos.z = Math_CosS(theta) * 16.0f; + + velocity.x = (explosionPos.x * 0.6f) + (12.0f * direction->x); + velocity.y = (Rand_ZeroOne() * 36.0f) + 6.0f; + velocity.z = (explosionPos.z * 0.6f) + (12.0f * direction->z); + + explosionPos.x += initialPos->x; + explosionPos.y += initialPos->y; + explosionPos.z += initialPos->z; + + aux = Rand_ZeroOne(); + if (aux < 0.1f) { + phi_s0 = 0x61; + } else if (aux < 0.7f) { + phi_s0 = 0x41; + } else { + phi_s0 = 0x21; + } + + EffectSsKakera_Spawn(globalCtx, &explosionPos, &velocity, initialPos, -200, phi_s0, 10, 10, 0, + Rand_ZeroOne() * 20.0f + 20.0f, 20, 300, (s32)(Rand_ZeroOne() * 30.0f) + 30, -1, + OBJECT_GEFF, &gGanonsCastleRubbleAroundArenaDL[28]); + + theta += 0x2AAA; + } + + DemoGj_PlayExplosionSfx(pthis, globalCtx); +} + +s32 DemoGj_IsSceneInvalid(void) { + if (gSaveContext.sceneSetupIndex < 4) { + return false; + } + return true; +} + +s32 DemoGj_FindGanon(DemoGj* pthis, GlobalContext* globalCtx) { + Actor* actor; + + if (pthis->ganon == NULL) { + actor = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].head; + + while (actor != NULL) { + if (actor->id == ACTOR_BOSS_GANON2) { + pthis->ganon = (BossGanon2*)actor; + + // "Demo_Gj_Search_Boss_Ganon %d: Discover Ganon !!!!" + osSyncPrintf("Demo_Gj_Search_Boss_Ganon %d:ガノン発見!!!!\n", pthis->dyna.actor.params); + return true; + } + actor = actor->next; + } + + // "Demo_Gj_Search_Boss_Ganon %d: I couldn't find Ganon" + osSyncPrintf("Demo_Gj_Search_Boss_Ganon %d:ガノン発見出来ず\n", pthis->dyna.actor.params); + return false; + } + //! @bug: Missing return value when `pthis->ganon` is already set. + return false; +} + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void DemoGj_InitCommon(DemoGj* pthis, GlobalContext* globalCtx, CollisionHeader* header) { + s32 pad[3]; + CollisionHeader* newHeader; + + if (header != NULL) { + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + newHeader = NULL; + CollisionHeader_GetVirtual(header, &newHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, newHeader); + } +} + +// TODO: find a better name +s32 DemoGj_InitSetIndexes(DemoGj* pthis, GlobalContext* globalCtx, s32 updateMode, s32 drawConfig, + CollisionHeader* header) { + if (!DemoGj_IsSceneInvalid()) { + pthis->updateMode = updateMode; + pthis->drawConfig = drawConfig; + DemoGj_InitCommon(pthis, globalCtx, header); + return true; + } + Actor_Kill(&pthis->dyna.actor); + return false; +} + +void DemoGj_DrawCommon(DemoGj* pthis, GlobalContext* globalCtx, Gfx* displayList) { + if (kREG(0) == 0) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_demo_gj.c", 1163); + + func_80093D18(gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_demo_gj.c", 1165), + G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, displayList); + gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); + + CLOSE_DISPS(gfxCtx, "../z_demo_gj.c", 1169); + } +} + +void DemoGj_DrawRotated(DemoGj* pthis, GlobalContext* globalCtx, Gfx* displayList) { + s32 pad; + GraphicsContext* gfxCtx; + s16 x = pthis->rotationVec.x; + s16 y = pthis->rotationVec.y; + s16 z = pthis->rotationVec.z; + s32 pad2; + Mtx* matrix; + + gfxCtx = globalCtx->state.gfxCtx; + matrix = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); + + OPEN_DISPS(gfxCtx, "../z_demo_gj.c", 1187); + + Matrix_Push(); + Matrix_RotateZYX(x, y, z, MTXMODE_APPLY); + Matrix_ToMtx(matrix, "../z_demo_gj.c", 1193); + Matrix_Pop(); + + func_80093D18(gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, matrix, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, displayList); + gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); + + CLOSE_DISPS(gfxCtx, "../z_demo_gj.c", 1201); +} + +void DemoGj_SetupRotation(DemoGj* pthis, GlobalContext* globalCtx) { + f32 yPosition = pthis->dyna.actor.world.pos.y; + f32* yVelocity = &pthis->dyna.actor.velocity.y; + f32* speedXZ = &pthis->dyna.actor.speedXZ; + Vec3s* unk_172 = &pthis->unk_172; + f32 verticalTranslation; + Vec3f vec; + f32 verticalFactor; + f32 xzPlaneFactor; + + switch (DemoGj_GetType(pthis)) { + case DEMOGJ_TYPE_RUBBLE_PILE_1: + verticalTranslation = kREG(23); + vec.x = kREG(24) * 0.01f + 1.0f; + vec.y = kREG(25) * 0.01f + 1.0f; + vec.z = kREG(26) * 0.01f + 1.0f; + verticalFactor = kREG(27) * 0.01f + -1.0f; + xzPlaneFactor = kREG(28) * 0.01f + 1.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_2: + verticalTranslation = kREG(36); + vec.x = kREG(37) * 0.01f + 1.0f; + vec.y = kREG(38) * 0.01f + 1.0f; + vec.z = kREG(39) * 0.01f + 1.0f; + verticalFactor = kREG(40) * 0.01f + -1.0f; + xzPlaneFactor = kREG(41) * 0.01f + 1.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_3: + verticalTranslation = kREG(49); + vec.x = kREG(50) * 0.01f + 1.0f; + vec.y = kREG(51) * 0.01f + 1.0f; + vec.z = kREG(52) * 0.01f + 1.0f; + verticalFactor = kREG(53) * 0.01f + -1.0f; + xzPlaneFactor = kREG(54) * 0.01f + 1.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_4: + verticalTranslation = kREG(62); + vec.x = kREG(63) * 0.01f + 1.0f; + vec.y = kREG(64) * 0.01f + 1.0f; + vec.z = kREG(65) * 0.01f + 1.0f; + verticalFactor = kREG(66) * 0.01f + -1.0f; + xzPlaneFactor = kREG(67) * 0.01f + 1.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_5: + verticalTranslation = kREG(75); + vec.x = kREG(76) * 0.01f + 1.0f; + vec.y = kREG(77) * 0.01f + 1.0f; + vec.z = kREG(78) * 0.01f + 1.0f; + verticalFactor = kREG(79) * 0.01f + -1.0f; + xzPlaneFactor = kREG(80) * 0.01f + 1.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_6: + verticalTranslation = kREG(88); + vec.x = kREG(89) * 0.01f + 1.0f; + vec.y = kREG(90) * 0.01f + 1.0f; + vec.z = kREG(91) * 0.01f + 1.0f; + verticalFactor = kREG(92) * 0.01f + -1.0f; + xzPlaneFactor = kREG(93) * 0.01f + 1.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_7: + verticalTranslation = kREG(10) + -190.0f; + vec.x = kREG(9) * 0.01f + 1.0f; + vec.y = kREG(8) * 0.01f + 1.0f; + vec.z = kREG(7) * 0.01f + 1.0f; + verticalFactor = kREG(6) * 0.01f + -1.0f; + xzPlaneFactor = kREG(5) * 0.01f + 1.0f; + break; + + default: + // "Demo_Gj_common_Reflect : This arg_data is not supported = %d" + osSyncPrintf(VT_FGCOL(RED) "Demo_Gj_common_Reflect : そんなarg_dataには対応していない = %d\n" VT_RST, + pthis->dyna.actor.params); + return; + } + + yPosition += verticalTranslation; + if (yPosition <= 1086.0f && (*yVelocity < 0.0f)) { + if (!pthis->isRotated) { + *yVelocity *= verticalFactor; + *speedXZ *= xzPlaneFactor; + + unk_172->x *= vec.x; + unk_172->y *= vec.y; + unk_172->z *= vec.z; + + if (*yVelocity <= -pthis->dyna.actor.gravity) { + *yVelocity = 0.0f; + *speedXZ = 0.0f; + + unk_172->x = 0; + unk_172->y = 0; + unk_172->z = 0; + } + + pthis->isRotated = true; + } + } +} + +/* + * Returns true if `ganon->unk_314` is equals to `arg1`. + * `ganon->unk_314` can have the following values: + * 0: Before the battle has started. + * 1: When is set: Ganondorf starts rising from the rubble. + * What is happening: Ganondorf is moving vertically and has vertical velocity. + * Proposed name: BOSSGANON2_MODE_GANONDORF_RISING + * 2: When is set: Ganondorf has stopped rising in air. + * What is happening: The camera is in front of him, focusing the clouds and going down to focus him. + * Proposed name: BOSSGANON2_MODE_GANONDORF_FLOATING + * 3: When is set: The camera has stopped moving and is focusing him. + * What is happening: Ganondorf raises his hand, shows the triforce and transforms into Ganon. The battle starts. + * This value is set during the whole real fight against Ganon. Without and with Master Sword. + * Proposed name: BOSSGANON2_MODE_GANON_FIGHTING + * 4: When is set: Link has hit Ganon's tail for last time with Master Sword. + * What is happening: Ganon falls to the floor, Zelda uses her magic and tells Link to kill him. + * Proposed name: BOSSGANON2_MODE_GANON_DEFEATED + * + * Those values should probably be defined as macros or enums in `ovl_Boss_Ganon2/z_boss_ganon2.h`. + * Proposed name for the function: `s32 DemoGj_CheckGanonMode(DemoGj* pthis, u8 mode)` + */ +s32 func_809797E4(DemoGj* pthis, u8 arg1) { + BossGanon2* ganon = pthis->ganon; + + if ((ganon != NULL) && (ganon->unk_314 == arg1)) { + return true; + } + return false; +} + +s32 DemoGj_IsGanondorfRisingFromRubble(DemoGj* pthis, GlobalContext* globalCtx) { + return func_809797E4(pthis, 1); +} + +// Ganondorf has stopped rising into the air and is just floating. Just before he transforms. +s32 DemoGj_IsGanondorfFloatingInAir(DemoGj* pthis, GlobalContext* globalCtx) { + return func_809797E4(pthis, 2); +} + +void DemoGj_SetupMovement(DemoGj* pthis, GlobalContext* globalCtx) { + Actor* actor = &pthis->dyna.actor; + Player* player; + Vec3f* pos = &actor->world.pos; + Vec3s* unk_172; + f32 xDistance; + f32 zDistance; + + if (pthis->ganon != NULL) { + xDistance = actor->world.pos.x - pthis->ganon->actor.world.pos.x; + zDistance = actor->world.pos.z - pthis->ganon->actor.world.pos.z; + unk_172 = &pthis->unk_172; + + switch (DemoGj_GetType(pthis)) { + case DEMOGJ_TYPE_RUBBLE_PILE_1: + actor->speedXZ = kREG(16) + 10.0f; + actor->velocity.y = kREG(17) + 40.0f; + unk_172->x = kREG(18); + unk_172->y = kREG(19) + 0x3E8; + unk_172->z = kREG(20) + 0xBB8; + actor->minVelocityY = kREG(21) * 0.01f + -29.0f; + actor->gravity = kREG(22) * 0.01f + -5.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_2: + actor->speedXZ = kREG(29) + 10.0f; + actor->velocity.y = kREG(30) + 40.0f; + unk_172->x = kREG(31); + unk_172->y = kREG(32) + 0x3E8; + unk_172->z = kREG(33) + 0xBB8; + actor->minVelocityY = kREG(34) * 0.01f + -29.0f; + actor->gravity = kREG(35) * 0.01f + -5.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_3: + actor->speedXZ = kREG(42) + 10.0f; + actor->velocity.y = kREG(43) + 40.0f; + unk_172->x = kREG(44); + unk_172->y = kREG(45) + 0x3E8; + unk_172->z = kREG(46) + 0xBB8; + actor->minVelocityY = kREG(47) * 0.01f + -29.0f; + actor->gravity = kREG(48) * 0.01f + -5.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_4: + actor->speedXZ = kREG(55) + 10.0f; + actor->velocity.y = kREG(56) + 40.0f; + unk_172->x = kREG(57); + unk_172->y = kREG(58) + 0x3E8; + unk_172->z = kREG(59) + 0xBB8; + actor->minVelocityY = kREG(60) * 0.01f + -29.0f; + actor->gravity = kREG(61) * 0.01f + -5.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_5: + actor->speedXZ = kREG(68) + 10.0f; + actor->velocity.y = kREG(69) + 40.0f; + unk_172->x = kREG(70); + unk_172->y = kREG(71) + 0x3E8; + unk_172->z = kREG(72) + 0xBB8; + actor->minVelocityY = kREG(73) * 0.01f + -29.0f; + actor->gravity = kREG(74) * 0.01f + -5.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_6: + actor->speedXZ = kREG(81) + 10.0f; + actor->velocity.y = kREG(82) + 40.0f; + unk_172->x = kREG(83); + unk_172->y = kREG(84) + 0x3E8; + unk_172->z = kREG(85) + 0xBB8; + actor->minVelocityY = kREG(86) * 0.01f + -29.0f; + actor->gravity = kREG(87) * 0.01f + -5.0f; + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_7: + actor->speedXZ = kREG(94) + 10.0f; + actor->velocity.y = kREG(95) + 70.0f; + unk_172->x = kREG(15); + unk_172->y = kREG(14) + 0x3E8; + unk_172->z = kREG(13) + 0xBB8; + actor->minVelocityY = kREG(12) * 0.01f + -29.0f; + actor->gravity = kREG(11) * 0.01f + -5.0f; + break; + + default: + // "Demo_Gj_Setup_Move_common : This arg_data is not supported = %d" + osSyncPrintf(VT_FGCOL(RED) "Demo_Gj_Setup_Move_common : そんなarg_dataには対応していない = %d\n" VT_RST, + actor->params); + break; + } + + if (xDistance == 0.0f && zDistance == 0.0f) { + player = GET_PLAYER(globalCtx); + xDistance = player->actor.world.pos.x - pos->x; + zDistance = player->actor.world.pos.z - pos->z; + + if (xDistance != 0.0f || zDistance != 0.0f) { + actor->world.rot.y = (Math_FAtan2F(xDistance, zDistance) * (0x8000 / M_PI)); + } + } else { + actor->world.rot.y = (Math_FAtan2F(xDistance, zDistance) * (0x8000 / M_PI)); + } + } +} + +void DemoGj_CheckIfTransformedIntoGanon(DemoGj* pthis) { + if (func_809797E4(pthis, 3)) { + pthis->isTransformedIntoGanon = true; + } +} + +void DemoGj_InitRubblePile1(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 1, 2, &gGanonsCastleRubble2Col); +} + +void func_8097A000(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(18)); + pthis->rotationVec.y += (s16)(kREG(19) + 1000); + pthis->rotationVec.z += (s16)(kREG(20) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void DemoGj_SpawnSmokePreBattle1(DemoGj* pthis, GlobalContext* globalCtx) { + static Vec3f pos = { -371.0f, 1188.0f, -303.0f }; + u32 gameplayFrames; + + if (!pthis->isTransformedIntoGanon) { + gameplayFrames = globalCtx->gameplayFrames % 3; + + if (1) {} + if (gameplayFrames == 0) { + if (!globalCtx->gameplayFrames) {} + DemoGj_SpawnSmoke(globalCtx, &pos, 300.0f); + } + + DemoGj_CheckIfTransformedIntoGanon(pthis); + } +} + +void func_8097A0E4(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 8; + pthis->drawConfig = 9; + } +} + +void func_8097A130(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097A160 +void DemoGj_Update01(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097A0E4(pthis, globalCtx); +} + +// func_8097A190 +void DemoGj_Update08(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097A000(pthis, globalCtx); + func_8097A130(pthis, globalCtx); +} + +void DemoGj_DrawRubble2(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble2DL); +} + +void DemoGj_DrawRotatedRubble2(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubble2DL); +} + +void DemoGj_InitRubblePile2(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 2, 3, &gGanonsCastleRubble3Col); +} + +void func_8097A238(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(31)); + pthis->rotationVec.y += (s16)(kREG(32) + 1000); + pthis->rotationVec.z += (s16)(kREG(33) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void DemoGj_SpawnSmokePreBattle2(DemoGj* pthis, GlobalContext* globalCtx) { + static Vec3f pos = { -119.0f, 1056.0f, -147.0f }; + u32 gameplayFrames; + + if (!pthis->isTransformedIntoGanon) { + gameplayFrames = globalCtx->gameplayFrames % 3; + + if (1) {} + if (gameplayFrames == 1) { + if (!globalCtx->gameplayFrames) {} + DemoGj_SpawnSmoke(globalCtx, &pos, 300.0f); + } + + DemoGj_CheckIfTransformedIntoGanon(pthis); + } +} + +void func_8097A320(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 9; + pthis->drawConfig = 10; + } +} + +void func_8097A36C(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097A39C +void DemoGj_Update02(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097A320(pthis, globalCtx); +} + +// func_8097A3CC +void DemoGj_Update09(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097A238(pthis, globalCtx); + func_8097A36C(pthis, globalCtx); +} + +void DemoGj_DrawRubble3(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble3DL); +} + +void DemoGj_DrawRotatedRubble3(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubble3DL); +} + +void DemoGj_InitRubblePile3(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 3, 4, &gGanonsCastleRubble4Col); +} + +void func_8097A474(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(44)); + pthis->rotationVec.y += (s16)(kREG(45) + 1000); + pthis->rotationVec.z += (s16)(kREG(46) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void func_8097A4F0(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 10; + pthis->drawConfig = 11; + } +} + +void func_8097A53C(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097A56C +void DemoGj_Update03(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097A4F0(pthis, globalCtx); +} + +// func_8097A59C +void DemoGj_Update10(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097A474(pthis, globalCtx); + func_8097A53C(pthis, globalCtx); +} + +void DemoGj_DrawRubble4(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble4DL); +} + +void DemoGj_DrawRotatedRubble4(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubble4DL); +} + +void DemoGj_InitRubblePile4(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 4, 5, &gGanonsCastleRubble5Col); +} + +void func_8097A644(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(57)); + pthis->rotationVec.y += (s16)(kREG(58) + 1000); + pthis->rotationVec.z += (s16)(kREG(59) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void func_8097A6C0(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 11; + pthis->drawConfig = 12; + } +} + +void func_8097A70C(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097A73C +void DemoGj_Update04(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097A6C0(pthis, globalCtx); +} + +// func_8097A76C +void DemoGj_Update11(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097A644(pthis, globalCtx); + func_8097A70C(pthis, globalCtx); +} + +void DemoGj_DrawRubble5(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble5DL); +} + +void DemoGj_DrawRotatedRubble5(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubble5DL); +} + +void DemoGj_InitRubblePile5(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 5, 6, &gGanonsCastleRubble6Col); +} + +void func_8097A814(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(70)); + pthis->rotationVec.y += (s16)(kREG(71) + 1000); + pthis->rotationVec.z += (s16)(kREG(72) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void func_8097A890(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 12; + pthis->drawConfig = 13; + } +} + +void func_8097A8DC(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097A90C +void DemoGj_Update05(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097A890(pthis, globalCtx); +} + +// func_8097A93C +void DemoGj_Update12(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097A814(pthis, globalCtx); + func_8097A8DC(pthis, globalCtx); +} + +void DemoGj_DrawRubble6(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble6DL); +} + +void DemoGj_DrawRotatedRubble6(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubble6DL); +} + +void DemoGj_InitRubblePile6(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 6, 7, &gGanonsCastleRubble7Col); +} + +void func_8097A9E4(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(83)); + pthis->rotationVec.y += (s16)(kREG(84) + 1000); + pthis->rotationVec.z += (s16)(kREG(85) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void func_8097AA60(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 13; + pthis->drawConfig = 14; + } +} + +void func_8097AAAC(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097AADC +void DemoGj_Update06(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097AA60(pthis, globalCtx); +} + +// func_8097AB0C +void DemoGj_Update13(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097A9E4(pthis, globalCtx); + func_8097AAAC(pthis, globalCtx); +} + +void DemoGj_DrawRubble7(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble7DL); +} + +void DemoGj_DrawRotatedRubble7(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubble7DL); +} + +void DemoGj_InitRubblePile7(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 7, 8, &gGanonsCastleRubbleTallCol); +} + +void func_8097ABB4(DemoGj* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + + pthis->rotationVec.x += (s16)(kREG(15)); + pthis->rotationVec.y += (s16)(kREG(14) + 1000); + pthis->rotationVec.z += (s16)(kREG(13) + 3000); + + DemoGj_SetupRotation(pthis, globalCtx); +} + +void DemoGj_SpawnSmokePreBattle3(DemoGj* pthis, GlobalContext* globalCtx) { + static Vec3f pos = { -6.0f, 1053.0f, -473.0f }; + u32 gameplayFrames; + + if (!pthis->isTransformedIntoGanon) { + gameplayFrames = globalCtx->gameplayFrames % 3; + + if (1) {} + if (gameplayFrames == 2) { + if (!globalCtx->gameplayFrames) {} + DemoGj_SpawnSmoke(globalCtx, &pos, 300.0f); + } + + DemoGj_CheckIfTransformedIntoGanon(pthis); + } +} + +void func_8097AC9C(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfRisingFromRubble(pthis, globalCtx)) { + DemoGj_SetupMovement(pthis, globalCtx); + pthis->updateMode = 14; + pthis->drawConfig = 15; + } +} + +void func_8097ACE8(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Actor_Kill(&pthis->dyna.actor); + } +} + +// func_8097AD18 +void DemoGj_Update07(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097AC9C(pthis, globalCtx); +} + +// func_8097AD48 +void DemoGj_Update14(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097ABB4(pthis, globalCtx); + func_8097ACE8(pthis, globalCtx); +} + +void DemoGj_DrawRubbleTall(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubbleTallDL); +} + +void DemoGj_DrawRotatedRubbleTall(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawRotated(pthis, globalCtx, gGanonsCastleRubbleTallDL); +} + +void DemoGj_InitRubbleAroundArena(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 0, 1, &gGanonsCastleRubbleAroundArenaCol); +} + +// func_8097ADF0 +void DemoGj_UpdateRubbleAroundArena(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + DemoGj_SpawnSmokePreBattle1(pthis, globalCtx); + DemoGj_SpawnSmokePreBattle2(pthis, globalCtx); + DemoGj_SpawnSmokePreBattle3(pthis, globalCtx); +} + +void DemoGj_DrawRubbleAroundArena(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubbleAroundArenaDL); +} + +// Inits the three cylinders with `sCylinderInit1` +void DemoGj_InitDestructableRubble1(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 15, 0, NULL); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[0], &sCylinderInit1); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[1], &sCylinderInit1); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[2], &sCylinderInit1); +} + +void DemoGj_DoNothing1(DemoGj* pthis, GlobalContext* globalCtx) { +} + +/* + * Moves the ColliderCylinder's relative to the actor's position. + * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1 + */ +void func_8097AEE8(DemoGj* pthis, GlobalContext* globalCtx) { + ColliderCylinder* cylinder0 = &pthis->cylinders[0]; + ColliderCylinder* cylinder1 = &pthis->cylinders[1]; + ColliderCylinder* cylinder2 = &pthis->cylinders[2]; + Vec3f* actorPos = &pthis->dyna.actor.world.pos; + s32 pad; + s16 theta = pthis->dyna.actor.world.rot.y; + f32 cos_theta = Math_CosS(theta); + f32 sin_theta = Math_SinS(theta); + + cylinder0->dim.pos.z = actorPos->z + (20.0f * cos_theta) - (-20.0f * sin_theta); + cylinder0->dim.pos.x = actorPos->x + (20.0f * sin_theta) + (-20.0f * cos_theta); + cylinder0->dim.pos.y = actorPos->y; + + cylinder1->dim.pos.z = actorPos->z + (-20.0f * cos_theta) - (20.0f * sin_theta); + cylinder1->dim.pos.x = actorPos->x + (-20.0f * sin_theta) + (20.0f * cos_theta); + cylinder1->dim.pos.y = actorPos->y; + + cylinder2->dim.pos.z = actorPos->z + (-60.0f * cos_theta) - (60.0f * sin_theta); + cylinder2->dim.pos.x = actorPos->x + (-60.0f * sin_theta) + (60.0f * cos_theta); + cylinder2->dim.pos.y = actorPos->y; +} + +void DemoGj_SetCylindersAsAC(DemoGj* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Collider* cylinder0 = &pthis->cylinders[0].base; + Collider* cylinder1 = &pthis->cylinders[1].base; + Collider* cylinder2 = &pthis->cylinders[2].base; + s32 pad2[3]; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder0); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder1); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder2); +} + +void DemoGj_DirectedExplosion(DemoGj* pthis, GlobalContext* globalCtx, Vec3f* direction) { + Vec3f pos; + + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y; + pos.z = pthis->dyna.actor.world.pos.z; + + DemoGj_Explode(pthis, globalCtx, &pos, direction); +} + +void func_8097B128(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Vec3f* scale = &pthis->dyna.actor.scale; + + DemoGj_InitCommon(pthis, globalCtx, &gGanonsCastleRubble2Col); + pthis->updateMode = 18; + pthis->drawConfig = 16; + scale->x *= 0.8f; + scale->y *= 0.8f; + scale->z *= 0.8f; + } +} + +s32 DemoGj_HasCylinderAnyExploded(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_HitByExplosion(pthis, globalCtx, &pthis->cylinders[0])) { + return true; + } + if (DemoGj_HitByExplosion(pthis, globalCtx, &pthis->cylinders[1])) { + return true; + } + if (DemoGj_HitByExplosion(pthis, globalCtx, &pthis->cylinders[2])) { + return true; + } + return false; +} + +/* + * Checks if should kill the actor and drop collectibles + * Kills the actor if ganon->unk_314==4 (Ganon killed), pthis rubble was hit by an explosion or killFlag==true + * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1 + */ +void func_8097B22C(DemoGj* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + + if (func_809797E4(pthis, 4)) { + Actor_Kill(thisx); + } else if (DemoGj_HasCylinderAnyExploded(pthis, globalCtx)) { + Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; + + DemoGj_DropCollectible(pthis, globalCtx); + DemoGj_DirectedExplosion(pthis, globalCtx, &vec1); + + Actor_Kill(thisx); + } else if (pthis->killFlag) { + Vec3f vec2 = pthis->unk_26C; + vec2.y = 0.0f; + + DemoGj_DropCollectible(pthis, globalCtx); + DemoGj_DirectedExplosion(pthis, globalCtx, &vec2); + + Actor_Kill(thisx); + } + + func_8097AEE8(pthis, globalCtx); + DemoGj_SetCylindersAsAC(pthis, globalCtx); +} + +// func_8097B340 +void DemoGj_Update15(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097B128(pthis, globalCtx); +} + +// func_8097B370 +void DemoGj_Update18(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097B22C(pthis, globalCtx); + DemoGj_DoNothing1(pthis, globalCtx); +} + +void DemoGj_DrawDestructableRubble1(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble2DL); +} + +// Inits the three cylinders with `sCylinderInit2` +void DemoGj_InitDestructableRubble2(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 16, 0, NULL); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[0], &sCylinderInit2); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[1], &sCylinderInit2); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[2], &sCylinderInit2); +} + +void DemoGj_DoNothing2(DemoGj* pthis, GlobalContext* globalCtx) { +} + +// Moves the ColliderCylinder's relative to the actor's position. +void func_8097B450(DemoGj* pthis, GlobalContext* globalCtx) { + ColliderCylinder* cylinder0 = &pthis->cylinders[0]; + ColliderCylinder* cylinder1 = &pthis->cylinders[1]; + ColliderCylinder* cylinder2 = &pthis->cylinders[2]; + Vec3f* actorPos = &pthis->dyna.actor.world.pos; + s32 pad; + s16 theta = pthis->dyna.actor.world.rot.y; + f32 cos_theta = Math_CosS(theta); + f32 sin_theta = Math_SinS(theta); + + cylinder0->dim.pos.z = actorPos->z - (35.0f * sin_theta); + cylinder0->dim.pos.x = actorPos->x + (35.0f * cos_theta); + cylinder0->dim.pos.y = actorPos->y; + + cylinder1->dim.pos.z = actorPos->z - (-10.0f * sin_theta); + cylinder1->dim.pos.x = actorPos->x + (-10.0f * cos_theta); + cylinder1->dim.pos.y = actorPos->y; + + cylinder2->dim.pos.z = actorPos->z - (-55.0f * sin_theta); + cylinder2->dim.pos.x = actorPos->x + (-55.0f * cos_theta); + cylinder2->dim.pos.y = actorPos->y; +} + +void DemoGj_SetCylindersAsAC2(DemoGj* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Collider* cylinder0 = &pthis->cylinders[0].base; + Collider* cylinder1 = &pthis->cylinders[1].base; + Collider* cylinder2 = &pthis->cylinders[2].base; + s32 pad2[3]; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder0); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder1); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, cylinder2); +} + +// Does the same as `DemoGj_HasCylinderAnyExploded` +s32 DemoGj_HasCylinderAnyExploded2(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_HitByExplosion(pthis, globalCtx, &pthis->cylinders[0])) { + return true; + } + if (DemoGj_HitByExplosion(pthis, globalCtx, &pthis->cylinders[1])) { + return true; + } + if (DemoGj_HitByExplosion(pthis, globalCtx, &pthis->cylinders[2])) { + return true; + } + return false; +} + +void DemoGj_DirectedExplosion2(DemoGj* pthis, GlobalContext* globalCtx, Vec3f* direction) { + Vec3f pos; + + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y; + pos.z = pthis->dyna.actor.world.pos.z; + + DemoGj_Explode(pthis, globalCtx, &pos, direction); +} + +void func_8097B6C4(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Vec3f* scale = &pthis->dyna.actor.scale; + + DemoGj_InitCommon(pthis, globalCtx, &gGanonsCastleRubble3Col); + pthis->updateMode = 19; + pthis->drawConfig = 17; + scale->x *= 0.8f; + scale->y *= 0.8f; + scale->z *= 0.8f; + } +} + +/* + * Checks if should kill the actor and drop collectibles + * Kills the actor if ganon->unk_314==4 (Ganon killed), pthis rubble was hit by an explosion or killFlag==true + * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_2 + */ +void func_8097B750(DemoGj* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + + if (func_809797E4(pthis, 4)) { + Actor_Kill(thisx); + } else if (DemoGj_HasCylinderAnyExploded2(pthis, globalCtx)) { + Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; + + DemoGj_DropCollectible(pthis, globalCtx); + DemoGj_DirectedExplosion2(pthis, globalCtx, &vec1); + + Actor_Kill(thisx); + } else if (pthis->killFlag) { + Vec3f vec2 = pthis->unk_26C; + vec2.y = 0.0f; + + DemoGj_DropCollectible(pthis, globalCtx); + DemoGj_DirectedExplosion2(pthis, globalCtx, &vec2); + + Actor_Kill(thisx); + } + + func_8097B450(pthis, globalCtx); + DemoGj_SetCylindersAsAC2(pthis, globalCtx); +} + +// func_8097B864 +void DemoGj_Update16(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097B6C4(pthis, globalCtx); +} + +// func_8097B894 +void DemoGj_Update19(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097B750(pthis, globalCtx); + DemoGj_DoNothing2(pthis, globalCtx); +} + +void DemoGj_DemoGj_InitDestructableRubble2(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubble3DL); +} + +// Inits the first cylinder (only that one) with `sCylinderInit3` +void DemoGj_InitDestructableRubbleTall(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_InitSetIndexes(pthis, globalCtx, 17, 0, NULL); + DemoGj_InitCylinder(pthis, globalCtx, &pthis->cylinders[0], &sCylinderInit3); +} + +void DemoGj_DoNothing3(DemoGj* pthis, GlobalContext* globalCtx) { +} + +void DemoGj_DirectedDoubleExplosion(DemoGj* pthis, GlobalContext* globalCtx, Vec3f* direction) { + Vec3f pos; + + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y; + pos.z = pthis->dyna.actor.world.pos.z; + DemoGj_Explode(pthis, globalCtx, &pos, direction); + + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + 100.0f; + pos.z = pthis->dyna.actor.world.pos.z; + DemoGj_Explode(pthis, globalCtx, &pos, direction); +} + +void func_8097B9BC(DemoGj* pthis, GlobalContext* globalCtx) { + if (DemoGj_IsGanondorfFloatingInAir(pthis, globalCtx)) { + Vec3f* scale = &pthis->dyna.actor.scale; + + DemoGj_InitCommon(pthis, globalCtx, &gGanonsCastleRubbleTallCol); + pthis->updateMode = 20; + pthis->drawConfig = 18; + scale->x *= 0.8f; + scale->y *= 0.8f; + scale->z *= 0.8f; + } +} + +/* + * Checks if should kill the actor and drop collectibles + * Kills the actor if ganon->unk_314==4 (Ganon killed), pthis rubble was hit by an explosion or killFlag==true + * Used by DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_TALL + */ +void func_8097BA48(DemoGj* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + ColliderCylinder* cylinder = &pthis->cylinders[0]; + s32 pad[2]; + + if (func_809797E4(pthis, 4)) { + Actor_Kill(thisx); + } else if (DemoGj_HitByExplosion(pthis, globalCtx, cylinder)) { + Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; + + DemoGj_DropCollectible(pthis, globalCtx); + DemoGj_DirectedDoubleExplosion(pthis, globalCtx, &vec1); + + Actor_Kill(thisx); + } else if (pthis->killFlag) { + Vec3f vec2 = pthis->unk_26C; + vec2.y = 0.0f; + + DemoGj_DropCollectible(pthis, globalCtx); + DemoGj_DirectedDoubleExplosion(pthis, globalCtx, &vec2); + + Actor_Kill(thisx); + } + + Collider_UpdateCylinder(thisx, cylinder); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &cylinder->base); +} + +// func_8097BB78 +void DemoGj_Update17(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_FindGanon(pthis, globalCtx); + func_8097B9BC(pthis, globalCtx); +} + +// func_8097BBA8 +void DemoGj_Update20(DemoGj* pthis, GlobalContext* globalCtx) { + func_8097BA48(pthis, globalCtx); + DemoGj_DoNothing3(pthis, globalCtx); +} + +void DemoGj_DemoGj_InitDestructableRubbleTall(DemoGj* pthis, GlobalContext* globalCtx) { + DemoGj_DrawCommon(pthis, globalCtx, gGanonsCastleRubbleTallDL); +} + +static DemoGjUpdateFunc sUpdateFuncs[] = { + DemoGj_UpdateRubbleAroundArena, + DemoGj_Update01, + DemoGj_Update02, + DemoGj_Update03, + DemoGj_Update04, + DemoGj_Update05, + DemoGj_Update06, + DemoGj_Update07, + DemoGj_Update08, + DemoGj_Update09, + DemoGj_Update10, + DemoGj_Update11, + DemoGj_Update12, + DemoGj_Update13, + DemoGj_Update14, + DemoGj_Update15, + DemoGj_Update16, + DemoGj_Update17, + DemoGj_Update18, + DemoGj_Update19, + DemoGj_Update20, +}; + +void DemoGj_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoGj* pthis = (DemoGj*)thisx; + + if (pthis->updateMode < 0 || pthis->updateMode >= ARRAY_COUNT(sUpdateFuncs) || + sUpdateFuncs[pthis->updateMode] == NULL) { + // "The main mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sUpdateFuncs[pthis->updateMode](pthis, globalCtx); +} + +void DemoGj_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoGj* pthis = (DemoGj*)thisx; + + switch (DemoGj_GetType(pthis)) { + case DEMOGJ_TYPE_AROUNDARENA: + DemoGj_InitRubbleAroundArena(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_1: + DemoGj_InitRubblePile1(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_2: + DemoGj_InitRubblePile2(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_3: + DemoGj_InitRubblePile3(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_4: + DemoGj_InitRubblePile4(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_5: + DemoGj_InitRubblePile5(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_6: + DemoGj_InitRubblePile6(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_RUBBLE_PILE_7: + DemoGj_InitRubblePile7(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_1: + DemoGj_InitDestructableRubble1(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_2: + DemoGj_InitDestructableRubble2(pthis, globalCtx); + break; + + case DEMOGJ_TYPE_DESTRUCTABLE_RUBBLE_TALL: + DemoGj_InitDestructableRubbleTall(pthis, globalCtx); + break; + + default: + // "Demo_Gj_Actor_ct There is no such argument!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "Demo_Gj_Actor_ct そんな引数は無い!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST, globalCtx, + pthis); + Actor_Kill(&pthis->dyna.actor); + } +} + +void DemoGj_DrawNothing(DemoGj* pthis, GlobalContext* globalCtx) { +} + +static DemoGjDrawFunc sDrawFuncs[] = { + DemoGj_DrawNothing, + DemoGj_DrawRubbleAroundArena, + DemoGj_DrawRubble2, + DemoGj_DrawRubble3, + DemoGj_DrawRubble4, + DemoGj_DrawRubble5, + DemoGj_DrawRubble6, + DemoGj_DrawRubble7, + DemoGj_DrawRubbleTall, + DemoGj_DrawRotatedRubble2, + DemoGj_DrawRotatedRubble3, + DemoGj_DrawRotatedRubble4, + DemoGj_DrawRotatedRubble5, + DemoGj_DrawRotatedRubble6, + DemoGj_DrawRotatedRubble7, + DemoGj_DrawRotatedRubbleTall, + DemoGj_DrawDestructableRubble1, + DemoGj_DemoGj_InitDestructableRubble2, + DemoGj_DemoGj_InitDestructableRubbleTall, +}; + +void DemoGj_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoGj* pthis = (DemoGj*)thisx; + + if (pthis->drawConfig < 0 || pthis->drawConfig >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[pthis->drawConfig] == NULL) { + // "The drawing mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} + +ActorInit Demo_Gj_InitVars = { + ACTOR_DEMO_GJ, + ACTORCAT_PROP, + FLAGS, + OBJECT_GJ, + sizeof(DemoGj), + (ActorFunc)DemoGj_Init, + (ActorFunc)DemoGj_Destroy, + (ActorFunc)DemoGj_Update, + (ActorFunc)DemoGj_Draw, +}; diff --git a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c deleted file mode 100644 index e8ed02613..000000000 --- a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c +++ /dev/null @@ -1,362 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_GO_Z_DEMO_GO_C -#include "actor_common.h" -/* - * File: z_demo_go.c - * Overlay: Demo_Go - * Description: Gorons (Cutscene) - */ - -#include "z_demo_go.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" -#include "vt.h" -#include "def/code_8006BA00.h" -#include "def/z_actor.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin_matrix.h" - -#define FLAGS ACTOR_FLAG_4 - -void DemoGo_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoGo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoGo_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoGo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8097CE10(DemoGo* this, GlobalContext* globalCtx); -void func_8097CFDC(DemoGo* this, GlobalContext* globalCtx); -void func_8097CFFC(DemoGo* this, GlobalContext* globalCtx); -void func_8097D01C(DemoGo* this, GlobalContext* globalCtx); -void func_8097D058(DemoGo* this, GlobalContext* globalCtx); -void func_8097D088(DemoGo* this, GlobalContext* globalCtx); -void func_8097D0D0(DemoGo* this, GlobalContext* globalCtx); -void func_8097D130(DemoGo* this, GlobalContext* globalCtx); -void func_8097D290(DemoGo* this, GlobalContext* globalCtx); -void func_8097D29C(DemoGo* this, GlobalContext* globalCtx); - -static void* sEyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; - -static DemoGoActionFunc D_8097D44C[] = { - func_8097CFDC, func_8097CFFC, func_8097D01C, func_8097D058, func_8097D088, func_8097D0D0, func_8097D130, -}; - -static DemoGoDrawFunc D_8097D468[] = { - func_8097D290, - func_8097D29C, -}; - -const ActorInit Demo_Go_InitVars = { - ACTOR_DEMO_GO, - ACTORCAT_NPC, - FLAGS, - OBJECT_OF1D_MAP, - sizeof(DemoGo), - (ActorFunc)DemoGo_Init, - (ActorFunc)DemoGo_Destroy, - (ActorFunc)DemoGo_Update, - (ActorFunc)DemoGo_Draw, -}; - -s32 func_8097C870(DemoGo* this) { - s32 ret; - - switch (this->actor.params) { - case 0: - ret = 3; - break; - case 1: - ret = 4; - break; - default: - if (1) { - ret = 5; - } - break; - } - return ret; -} - -void func_8097C8A8(DemoGo* this, GlobalContext* globalCtx) { - Actor* thisx = &this->actor; - Vec3f sp20; - f32 sp1C; - - if ((thisx->params == 0) || (thisx->params == 1)) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &thisx->world.pos, &sp20, &sp1C); - Audio_PlaySoundAtPosition(globalCtx, &sp20, 20, NA_SE_EV_OBJECT_FALL); - } -} - -void DemoGo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoGo* this = (DemoGo*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); -} - -void func_8097C930(DemoGo* this) { - s16* something = &this->unk_192; - s16* other = &this->unk_190; - s32 pad[3]; - - if (DECR(*something) == 0) { - *something = Rand_S16Offset(60, 60); - } - *other = *something; - if (*other >= 3) { - *other = 0; - } -} - -void func_8097C9B8(DemoGo* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EN_DODO_M_GND); -} - -void func_8097C9DC(DemoGo* this) { - s32 pad[2]; - - if (Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_EN_MORIBLIN_WALK); - } -} - -void func_8097CA30(DemoGo* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -void func_8097CA78(DemoGo* this, GlobalContext* globalCtx) { - s16 pad; - Vec3f vec = this->actor.world.pos; - func_80033480(globalCtx, &vec, kREG(11) + 100.0f, kREG(12) + 0xA, kREG(13) + 0x12C, kREG(14), 0); - func_8097C9B8(this); -} - -void func_8097CB0C(DemoGo* this, GlobalContext* globalCtx) { - Actor* thisx = &this->actor; - PosRot* world = &thisx->world; - CutsceneContext* csCtx = &globalCtx->csCtx; - CsCmdActorAction* npcAction; - f32 temp_ret; - s32 pad; - Vec3f startPos; - Vec3f endPos; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - npcAction = csCtx->npcActions[func_8097C870(this)]; - if (npcAction != NULL) { - temp_ret = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, csCtx->frames); - startPos.x = npcAction->startPos.x; - startPos.y = npcAction->startPos.y; - startPos.z = npcAction->startPos.z; - endPos.x = npcAction->endPos.x; - endPos.y = npcAction->endPos.y; - endPos.z = npcAction->endPos.z; - world->pos.x = (endPos.x - startPos.x) * temp_ret + startPos.x; - world->pos.y = (endPos.y - startPos.y) * temp_ret + startPos.y; - world->pos.z = (endPos.z - startPos.z) * temp_ret + startPos.z; - world->rot.y = thisx->shape.rot.y = npcAction->rot.y; - } - } -} - -void func_8097CC08(DemoGo* this) { - f32 something = this->unk_19C; - - if (something < 8.0f) { - this->actor.speedXZ = (((kREG(15) * 0.01f) + 1.2f) / 8.0f) * something; - } else { - this->actor.speedXZ = (kREG(15) * 0.01f) + 1.2f; - } - Actor_MoveForward(&this->actor); -} - -void func_8097CCC0(DemoGo* this) { - Actor_MoveForward(&this->actor); -} - -void func_8097CCE0(DemoGo* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction; - Actor* thisx = &this->actor; - s32 rotYDelta; - s32 newRotY; - s32 thisRotY; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - npcAction = globalCtx->csCtx.npcActions[func_8097C870(this)]; - if (npcAction != NULL) { - thisRotY = thisx->world.rot.y; - rotYDelta = npcAction->rot.y - thisRotY; - if ((rotYDelta > -(kREG(16) + 0x96)) && (rotYDelta < kREG(16) + 0x96)) { - newRotY = npcAction->rot.y; - } else if (rotYDelta > 0) { - newRotY = (thisRotY + kREG(16)) + 0x96; - } else { - newRotY = (thisRotY - kREG(16)) - 0x96; - } - thisx->shape.rot.y = newRotY; - thisx->world.rot.y = newRotY; - } - } -} - -s32 DemoGo_UpdateSkelAnime(DemoGo* this) { - return SkelAnime_Update(&this->skelAnime); -} - -s32 func_8097CDB0(DemoGo* this, GlobalContext* globalCtx, u16 npcAction) { - CutsceneContext* csCtx = &globalCtx->csCtx; - s32 actionIdx = func_8097C870(this); - - if ((csCtx->state != CS_STATE_IDLE) && (csCtx->npcActions[actionIdx] != NULL) && - (csCtx->npcActions[actionIdx]->action == npcAction)) { - return 1; - } - return 0; -} - -void func_8097CE10(DemoGo* this, GlobalContext* globalCtx) { - this->action = 1; -} - -void func_8097CE20(DemoGo* this, GlobalContext* globalCtx) { - if (func_8097CDB0(this, globalCtx, 2)) { - this->action = 2; - this->drawConfig = 1; - func_8097CB0C(this, globalCtx); - func_8097C8A8(this, globalCtx); - } -} - -void func_8097CE78(DemoGo* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - CsCmdActorAction* npcAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - npcAction = csCtx->npcActions[func_8097C870(this)]; - if (npcAction != NULL && csCtx->frames >= npcAction->endFrame) { - func_8097CA78(this, globalCtx); - this->action = 3; - } - } -} - -void func_8097CEEC(DemoGo* this, GlobalContext* globalCtx) { - if (func_8097CDB0(this, globalCtx, 3)) { - this->action = 4; - } -} - -void func_8097CF20(DemoGo* this, GlobalContext* globalCtx, s32 arg2) { - AnimationHeader* animation = &gGoronAnim_0029A8; - if (arg2 != 0) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, - -8.0f); - this->action = 5; - this->unk_19C = 0.0f; - } -} - -void func_8097CF9C(DemoGo* this) { - this->unk_19C += 1.0f; - if (this->unk_19C >= 8.0f) { - this->action = 6; - } -} - -void func_8097CFDC(DemoGo* this, GlobalContext* globalCtx) { - func_8097CE10(this, globalCtx); -} - -void func_8097CFFC(DemoGo* this, GlobalContext* globalCtx) { - func_8097CE20(this, globalCtx); -} - -void func_8097D01C(DemoGo* this, GlobalContext* globalCtx) { - func_8097CB0C(this, globalCtx); - func_8097CA30(this, globalCtx); - func_8097CE78(this, globalCtx); -} - -void func_8097D058(DemoGo* this, GlobalContext* globalCtx) { - func_8097CA30(this, globalCtx); - func_8097CEEC(this, globalCtx); -} - -void func_8097D088(DemoGo* this, GlobalContext* globalCtx) { - s32 something; - - func_8097CA30(this, globalCtx); - something = DemoGo_UpdateSkelAnime(this); - func_8097C930(this); - func_8097CF20(this, globalCtx, something); -} - -void func_8097D0D0(DemoGo* this, GlobalContext* globalCtx) { - func_8097CCE0(this, globalCtx); - func_8097CCC0(this); - func_8097CA30(this, globalCtx); - DemoGo_UpdateSkelAnime(this); - func_8097C930(this); - func_8097C9DC(this); - func_8097CF9C(this); -} -void func_8097D130(DemoGo* this, GlobalContext* globalCtx) { - func_8097CCE0(this, globalCtx); - func_8097CC08(this); - func_8097CA30(this, globalCtx); - DemoGo_UpdateSkelAnime(this); - func_8097C930(this); - func_8097C9DC(this); -} - -void DemoGo_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoGo* this = (DemoGo*)thisx; - - if (this->action < 0 || this->action >= 7 || D_8097D44C[this->action] == 0) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - D_8097D44C[this->action](this, globalCtx); -} - -void DemoGo_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoGo* this = (DemoGo*)thisx; - AnimationHeader* animation = &gGoronAnim_004930; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, NULL, NULL, 0); - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); - this->action = 0; -} - -void func_8097D290(DemoGo* this, GlobalContext* globalCtx) { -} - -void func_8097D29C(DemoGo* this, GlobalContext* globalCtx) { - s32 pad; - s16 eyeTexIdx = this->unk_190; - SkelAnime* skelAnime = &this->skelAnime; - void* eyeTexture = sEyeTextures[eyeTexIdx]; - void* mouthTexture = gGoronCsMouthSmileTex; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_go.c", 732); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTexture)); - - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, - this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_go.c", 746); -} - -void DemoGo_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoGo* this = (DemoGo*)thisx; - - if (this->drawConfig < 0 || this->drawConfig >= 2 || D_8097D468[this->drawConfig] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - D_8097D468[this->drawConfig](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Demo_Go/z_demo_go.cpp b/src/overlays/actors/ovl_Demo_Go/z_demo_go.cpp new file mode 100644 index 000000000..98bc2c0fb --- /dev/null +++ b/src/overlays/actors/ovl_Demo_Go/z_demo_go.cpp @@ -0,0 +1,362 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_GO_Z_DEMO_GO_C +#include "actor_common.h" +/* + * File: z_demo_go.c + * Overlay: Demo_Go + * Description: Gorons (Cutscene) + */ + +#include "z_demo_go.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "vt.h" +#include "def/code_8006BA00.h" +#include "def/z_actor.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin_matrix.h" + +#define FLAGS ACTOR_FLAG_4 + +void DemoGo_Init(Actor* thisx, GlobalContext* globalCtx); +void DemoGo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DemoGo_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoGo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8097CE10(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097CFDC(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097CFFC(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D01C(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D058(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D088(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D0D0(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D130(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D290(DemoGo* pthis, GlobalContext* globalCtx); +void func_8097D29C(DemoGo* pthis, GlobalContext* globalCtx); + +static void* sEyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; + +static DemoGoActionFunc D_8097D44C[] = { + func_8097CFDC, func_8097CFFC, func_8097D01C, func_8097D058, func_8097D088, func_8097D0D0, func_8097D130, +}; + +static DemoGoDrawFunc D_8097D468[] = { + func_8097D290, + func_8097D29C, +}; + +ActorInit Demo_Go_InitVars = { + ACTOR_DEMO_GO, + ACTORCAT_NPC, + FLAGS, + OBJECT_OF1D_MAP, + sizeof(DemoGo), + (ActorFunc)DemoGo_Init, + (ActorFunc)DemoGo_Destroy, + (ActorFunc)DemoGo_Update, + (ActorFunc)DemoGo_Draw, +}; + +s32 func_8097C870(DemoGo* pthis) { + s32 ret; + + switch (pthis->actor.params) { + case 0: + ret = 3; + break; + case 1: + ret = 4; + break; + default: + if (1) { + ret = 5; + } + break; + } + return ret; +} + +void func_8097C8A8(DemoGo* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->actor; + Vec3f sp20; + f32 sp1C; + + if ((thisx->params == 0) || (thisx->params == 1)) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &thisx->world.pos, &sp20, &sp1C); + Audio_PlaySoundAtPosition(globalCtx, &sp20, 20, NA_SE_EV_OBJECT_FALL); + } +} + +void DemoGo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoGo* pthis = (DemoGo*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); +} + +void func_8097C930(DemoGo* pthis) { + s16* something = &pthis->unk_192; + s16* other = &pthis->unk_190; + s32 pad[3]; + + if (DECR(*something) == 0) { + *something = Rand_S16Offset(60, 60); + } + *other = *something; + if (*other >= 3) { + *other = 0; + } +} + +void func_8097C9B8(DemoGo* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_DODO_M_GND); +} + +void func_8097C9DC(DemoGo* pthis) { + s32 pad[2]; + + if (Animation_OnFrame(&pthis->skelAnime, 12.0f) || Animation_OnFrame(&pthis->skelAnime, 25.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_MORIBLIN_WALK); + } +} + +void func_8097CA30(DemoGo* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +void func_8097CA78(DemoGo* pthis, GlobalContext* globalCtx) { + s16 pad; + Vec3f vec = pthis->actor.world.pos; + func_80033480(globalCtx, &vec, kREG(11) + 100.0f, kREG(12) + 0xA, kREG(13) + 0x12C, kREG(14), 0); + func_8097C9B8(pthis); +} + +void func_8097CB0C(DemoGo* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->actor; + PosRot* world = &thisx->world; + CutsceneContext* csCtx = &globalCtx->csCtx; + CsCmdActorAction* npcAction; + f32 temp_ret; + s32 pad; + Vec3f startPos; + Vec3f endPos; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + npcAction = csCtx->npcActions[func_8097C870(pthis)]; + if (npcAction != NULL) { + temp_ret = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, csCtx->frames); + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; + endPos.x = npcAction->endPos.x; + endPos.y = npcAction->endPos.y; + endPos.z = npcAction->endPos.z; + world->pos.x = (endPos.x - startPos.x) * temp_ret + startPos.x; + world->pos.y = (endPos.y - startPos.y) * temp_ret + startPos.y; + world->pos.z = (endPos.z - startPos.z) * temp_ret + startPos.z; + world->rot.y = thisx->shape.rot.y = npcAction->rot.y; + } + } +} + +void func_8097CC08(DemoGo* pthis) { + f32 something = pthis->unk_19C; + + if (something < 8.0f) { + pthis->actor.speedXZ = (((kREG(15) * 0.01f) + 1.2f) / 8.0f) * something; + } else { + pthis->actor.speedXZ = (kREG(15) * 0.01f) + 1.2f; + } + Actor_MoveForward(&pthis->actor); +} + +void func_8097CCC0(DemoGo* pthis) { + Actor_MoveForward(&pthis->actor); +} + +void func_8097CCE0(DemoGo* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction; + Actor* thisx = &pthis->actor; + s32 rotYDelta; + s32 newRotY; + s32 thisRotY; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + npcAction = globalCtx->csCtx.npcActions[func_8097C870(pthis)]; + if (npcAction != NULL) { + thisRotY = thisx->world.rot.y; + rotYDelta = npcAction->rot.y - thisRotY; + if ((rotYDelta > -(kREG(16) + 0x96)) && (rotYDelta < kREG(16) + 0x96)) { + newRotY = npcAction->rot.y; + } else if (rotYDelta > 0) { + newRotY = (thisRotY + kREG(16)) + 0x96; + } else { + newRotY = (thisRotY - kREG(16)) - 0x96; + } + thisx->shape.rot.y = newRotY; + thisx->world.rot.y = newRotY; + } + } +} + +s32 DemoGo_UpdateSkelAnime(DemoGo* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +s32 func_8097CDB0(DemoGo* pthis, GlobalContext* globalCtx, u16 npcAction) { + CutsceneContext* csCtx = &globalCtx->csCtx; + s32 actionIdx = func_8097C870(pthis); + + if ((csCtx->state != CS_STATE_IDLE) && (csCtx->npcActions[actionIdx] != NULL) && + (csCtx->npcActions[actionIdx]->action == npcAction)) { + return 1; + } + return 0; +} + +void func_8097CE10(DemoGo* pthis, GlobalContext* globalCtx) { + pthis->action = 1; +} + +void func_8097CE20(DemoGo* pthis, GlobalContext* globalCtx) { + if (func_8097CDB0(pthis, globalCtx, 2)) { + pthis->action = 2; + pthis->drawConfig = 1; + func_8097CB0C(pthis, globalCtx); + func_8097C8A8(pthis, globalCtx); + } +} + +void func_8097CE78(DemoGo* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + CsCmdActorAction* npcAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + npcAction = csCtx->npcActions[func_8097C870(pthis)]; + if (npcAction != NULL && csCtx->frames >= npcAction->endFrame) { + func_8097CA78(pthis, globalCtx); + pthis->action = 3; + } + } +} + +void func_8097CEEC(DemoGo* pthis, GlobalContext* globalCtx) { + if (func_8097CDB0(pthis, globalCtx, 3)) { + pthis->action = 4; + } +} + +void func_8097CF20(DemoGo* pthis, GlobalContext* globalCtx, s32 arg2) { + AnimationHeader* animation = &gGoronAnim_0029A8; + if (arg2 != 0) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, + -8.0f); + pthis->action = 5; + pthis->unk_19C = 0.0f; + } +} + +void func_8097CF9C(DemoGo* pthis) { + pthis->unk_19C += 1.0f; + if (pthis->unk_19C >= 8.0f) { + pthis->action = 6; + } +} + +void func_8097CFDC(DemoGo* pthis, GlobalContext* globalCtx) { + func_8097CE10(pthis, globalCtx); +} + +void func_8097CFFC(DemoGo* pthis, GlobalContext* globalCtx) { + func_8097CE20(pthis, globalCtx); +} + +void func_8097D01C(DemoGo* pthis, GlobalContext* globalCtx) { + func_8097CB0C(pthis, globalCtx); + func_8097CA30(pthis, globalCtx); + func_8097CE78(pthis, globalCtx); +} + +void func_8097D058(DemoGo* pthis, GlobalContext* globalCtx) { + func_8097CA30(pthis, globalCtx); + func_8097CEEC(pthis, globalCtx); +} + +void func_8097D088(DemoGo* pthis, GlobalContext* globalCtx) { + s32 something; + + func_8097CA30(pthis, globalCtx); + something = DemoGo_UpdateSkelAnime(pthis); + func_8097C930(pthis); + func_8097CF20(pthis, globalCtx, something); +} + +void func_8097D0D0(DemoGo* pthis, GlobalContext* globalCtx) { + func_8097CCE0(pthis, globalCtx); + func_8097CCC0(pthis); + func_8097CA30(pthis, globalCtx); + DemoGo_UpdateSkelAnime(pthis); + func_8097C930(pthis); + func_8097C9DC(pthis); + func_8097CF9C(pthis); +} +void func_8097D130(DemoGo* pthis, GlobalContext* globalCtx) { + func_8097CCE0(pthis, globalCtx); + func_8097CC08(pthis); + func_8097CA30(pthis, globalCtx); + DemoGo_UpdateSkelAnime(pthis); + func_8097C930(pthis); + func_8097C9DC(pthis); +} + +void DemoGo_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoGo* pthis = (DemoGo*)thisx; + + if (pthis->action < 0 || pthis->action >= 7 || D_8097D44C[pthis->action] == 0) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + D_8097D44C[pthis->action](pthis, globalCtx); +} + +void DemoGo_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoGo* pthis = (DemoGo*)thisx; + AnimationHeader* animation = &gGoronAnim_004930; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGoronSkel, NULL, NULL, NULL, 0); + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); + pthis->action = 0; +} + +void func_8097D290(DemoGo* pthis, GlobalContext* globalCtx) { +} + +void func_8097D29C(DemoGo* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 eyeTexIdx = pthis->unk_190; + SkelAnime* skelAnime = &pthis->skelAnime; + void* eyeTexture = sEyeTextures[eyeTexIdx]; + void* mouthTexture = gGoronCsMouthSmileTex; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_go.c", 732); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTexture)); + + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, + pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_go.c", 746); +} + +void DemoGo_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoGo* pthis = (DemoGo*)thisx; + + if (pthis->drawConfig < 0 || pthis->drawConfig >= 2 || D_8097D468[pthis->drawConfig] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + D_8097D468[pthis->drawConfig](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c b/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.cpp similarity index 67% rename from src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c rename to src/overlays/actors/ovl_Demo_Gt/z_demo_gt.cpp index 1d1cfae19..c00639db2 100644 --- a/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c +++ b/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.cpp @@ -29,10 +29,10 @@ void DemoGt_Update(Actor* thisx, GlobalContext* globalCtx); void DemoGt_Draw(Actor* thisx, GlobalContext* globalCtx); void DemoGt_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoGt* this = (DemoGt*)thisx; + DemoGt* pthis = (DemoGt*)thisx; - if ((this->dyna.actor.params == 1) || (this->dyna.actor.params == 2)) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if ((pthis->dyna.actor.params == 1) || (pthis->dyna.actor.params == 2)) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } @@ -109,7 +109,7 @@ void DemoGt_SpawnExplosionNoSound(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v EffectSsBomb2_SpawnLayered(globalCtx, pos, velocity, accel, (100.0f * scale), (25.0f * scale)); } -void func_8097DAC8(DemoGt* this, GlobalContext* globalCtx, Vec3f* spawnerPos) { +void func_8097DAC8(DemoGt* pthis, GlobalContext* globalCtx, Vec3f* spawnerPos) { Vec3f pos; Vec3f velocity; f32 temp_f0; @@ -150,7 +150,7 @@ void func_8097DAC8(DemoGt* this, GlobalContext* globalCtx, Vec3f* spawnerPos) { } } -void func_8097DD28(DemoGt* this, GlobalContext* globalCtx, Vec3f* spawnerPos) { +void func_8097DD28(DemoGt* pthis, GlobalContext* globalCtx, Vec3f* spawnerPos) { Vec3f pos; Vec3f velocity; f32 temp_f0; @@ -192,7 +192,7 @@ void func_8097DD28(DemoGt* this, GlobalContext* globalCtx, Vec3f* spawnerPos) { } } -void func_8097DF70(DemoGt* this, GlobalContext* globalCtx, Vec3f* spawnerPos) { +void func_8097DF70(DemoGt* pthis, GlobalContext* globalCtx, Vec3f* spawnerPos) { Vec3f pos; Vec3f velocity; f32 temp_f0; @@ -337,9 +337,9 @@ u8 func_8097E704(GlobalContext* globalCtx, u16 arg1, s32 arg2) { } } -void func_8097E744(DemoGt* this, GlobalContext* globalCtx, u32 actionIdx) { +void func_8097E744(DemoGt* pthis, GlobalContext* globalCtx, u32 actionIdx) { CsCmdActorAction* npcAction = DemoGt_GetNpcAction(globalCtx, actionIdx); - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; f32 startX; f32 startY; f32 startZ; @@ -364,12 +364,12 @@ void func_8097E744(DemoGt* this, GlobalContext* globalCtx, u32 actionIdx) { } } -void func_8097E824(DemoGt* this, s32 arg1) { +void func_8097E824(DemoGt* pthis, s32 arg1) { s16 phi_a1; s16 phi_a2; s16 phi_a3; - Vec3f* pos = &this->dyna.actor.world.pos; - Vec3s* unk16C = &this->unk_16C; + Vec3f* pos = &pthis->dyna.actor.world.pos; + Vec3s* unk16C = &pthis->unk_16C; s32 pad; f32 tempf3; f32 tempf2; @@ -449,9 +449,9 @@ void func_8097E824(DemoGt* this, s32 arg1) { pos->z += tempf3; } -void func_8097ED64(DemoGt* this, GlobalContext* globalCtx, s32 actionIdx) { - func_8097E744(this, globalCtx, actionIdx); - func_8097E824(this, actionIdx); +void func_8097ED64(DemoGt* pthis, GlobalContext* globalCtx, s32 actionIdx) { + func_8097E744(pthis, globalCtx, actionIdx); + func_8097E824(pthis, actionIdx); } u8 func_8097ED94() { @@ -468,41 +468,41 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void func_8097EDD8(DemoGt* this, GlobalContext* globalCtx, CollisionHeader* collision) { +void func_8097EDD8(DemoGt* pthis, GlobalContext* globalCtx, CollisionHeader* collision) { s32 pad[3]; CollisionHeader* colHeader; if (collision != NULL) { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); colHeader = NULL; CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } } -u8 func_8097EE44(DemoGt* this, GlobalContext* globalCtx, s32 updateMode, s32 drawConfig, CollisionHeader* colHeader) { +u8 func_8097EE44(DemoGt* pthis, GlobalContext* globalCtx, s32 updateMode, s32 drawConfig, CollisionHeader* colHeader) { if (func_8097ED94()) { - this->updateMode = updateMode; - this->drawConfig = drawConfig; - func_8097EDD8(this, globalCtx, colHeader); + pthis->updateMode = updateMode; + pthis->drawConfig = drawConfig; + func_8097EDD8(pthis, globalCtx, colHeader); return true; } else { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); return false; } } -void func_8097EEA8_Init0(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; +void func_8097EEA8_Init0(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 0, 1, NULL); + func_8097EE44(pthis, globalCtx, 0, 1, NULL); } -void func_8097EF00(DemoGt* this, GlobalContext* globalCtx) { +void func_8097EF00(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (frames == 527) { @@ -510,16 +510,16 @@ void func_8097EF00(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097EF34(DemoGt* this, GlobalContext* globalCtx) { +void func_8097EF34(DemoGt* pthis, GlobalContext* globalCtx) { } -void func_8097EF40(DemoGt* this, GlobalContext* globalCtx) { +void func_8097EF40(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; s32 pad1[3]; Vec3f dustPos; Vec3f velocity = { 0.0f, -16.0f, 0.0f }; Vec3f accel = { 0.0f, 1.2f, 0.0f }; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; s32 pad; if ((kREG(1) == 20) || (frames == 220)) { @@ -537,7 +537,7 @@ void func_8097EF40(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097F0AC(DemoGt* this, GlobalContext* globalCtx) { +void func_8097F0AC(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f sp38; s16 pad1[3]; @@ -546,41 +546,41 @@ void func_8097F0AC(DemoGt* this, GlobalContext* globalCtx) { s32 pad2; if ((frames == 140) || (kREG(1) == 19)) { - sp38.x = this->dyna.actor.world.pos.x + 260.0f; - sp38.y = this->dyna.actor.world.pos.y + 340.0f; - sp38.z = this->dyna.actor.world.pos.z + 45.0f; + sp38.x = pthis->dyna.actor.world.pos.x + 260.0f; + sp38.y = pthis->dyna.actor.world.pos.y + 340.0f; + sp38.z = pthis->dyna.actor.world.pos.z + 45.0f; DemoGt_SpawnExplosionWithSound(globalCtx, &sp38, 2.0f); } if (frames == 176) { - sp24.x = this->dyna.actor.world.pos.x + 260.0f; - sp24.y = this->dyna.actor.world.pos.y + 840.0f; - sp24.z = this->dyna.actor.world.pos.z + 45.0f; + sp24.x = pthis->dyna.actor.world.pos.x + 260.0f; + sp24.y = pthis->dyna.actor.world.pos.y + 840.0f; + sp24.z = pthis->dyna.actor.world.pos.z + 45.0f; DemoGt_SpawnExplosionWithSound(globalCtx, &sp24, 2.0f); } } -void func_8097F19C(DemoGt* this, GlobalContext* globalCtx) { - func_8097EF34(this, globalCtx); - func_8097EF40(this, globalCtx); - func_8097F0AC(this, globalCtx); +void func_8097F19C(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097EF34(pthis, globalCtx); + func_8097EF40(pthis, globalCtx); + func_8097F0AC(pthis, globalCtx); } -void func_8097F1D8(DemoGt* this) { - f32 temp_v0 = this->unk_172; +void func_8097F1D8(DemoGt* pthis) { + f32 temp_v0 = pthis->unk_172; - this->unk_174 = (temp_v0 * ((kREG(64) * 0.001f) + 0.048f)) + (kREG(72) + 10.0f); - this->unk_172 += this->unk_174; + pthis->unk_174 = (temp_v0 * ((kREG(64) * 0.001f) + 0.048f)) + (kREG(72) + 10.0f); + pthis->unk_172 += pthis->unk_174; - if (this->unk_172 > (s16)(kREG(73) + 0x250)) { - this->unk_172 = kREG(73) + 0x250; + if (pthis->unk_172 > (s16)(kREG(73) + 0x250)) { + pthis->unk_172 = kREG(73) + 0x250; } } -void func_8097F280(DemoGt* this, GlobalContext* globalCtx) { - s32* unk178 = this->unk_178; - s32* unk188 = this->unk_188; - s32* unk198 = this->unk_198; +void func_8097F280(DemoGt* pthis, GlobalContext* globalCtx) { + s32* unk178 = pthis->unk_178; + s32* unk188 = pthis->unk_188; + s32* unk198 = pthis->unk_198; f32 temp_f0; if (globalCtx->csCtx.frames < 160) { @@ -615,33 +615,33 @@ void func_8097F280(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097F3EC(DemoGt* this, GlobalContext* globalCtx) { +void func_8097F3EC(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 1)) { - this->updateMode = 8; + pthis->updateMode = 8; } } -void DemoGt_Update0(DemoGt* this, GlobalContext* globalCtx) { - func_8097F280(this, globalCtx); - func_8097E824(this, 1); - func_8097F19C(this, globalCtx); - func_8097F3EC(this, globalCtx); +void DemoGt_Update0(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097F280(pthis, globalCtx); + func_8097E824(pthis, 1); + func_8097F19C(pthis, globalCtx); + func_8097F3EC(pthis, globalCtx); DemoGt_PlayEarthquakeSfx(); DemoGt_Rumble(globalCtx); - func_8097EF00(this, globalCtx); + func_8097EF00(pthis, globalCtx); } -void DemoGt_Update8(DemoGt* this, GlobalContext* globalCtx) { - func_8097F280(this, globalCtx); - func_8097F1D8(this); - func_8097ED64(this, globalCtx, 1); - func_8097F19C(this, globalCtx); +void DemoGt_Update8(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097F280(pthis, globalCtx); + func_8097F1D8(pthis); + func_8097ED64(pthis, globalCtx, 1); + func_8097F19C(pthis, globalCtx); DemoGt_PlayEarthquakeSfx(); DemoGt_Rumble(globalCtx); - func_8097EF00(this, globalCtx); + func_8097EF00(pthis, globalCtx); } -void DemoGt_Draw1(DemoGt* this, GlobalContext* globalCtx) { +void DemoGt_Draw1(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; u32 gameplayFrames = globalCtx->gameplayFrames; @@ -659,12 +659,12 @@ void DemoGt_Draw1(DemoGt* this, GlobalContext* globalCtx) { s32* unk188; s32* unk178; - spC6 = this->unk_172; + spC6 = pthis->unk_172; spC0 = fabsf(spC6 * (M_PI / 0x8000)); spBC = kREG(71); spB8 = (s16)((s32)kREG(70)) + 0x4000; spBA = kREG(70); - spB4 = Graph_Alloc(gfxCtx, sizeof(Mtx)); + spB4 = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); sp98 = 1.0f - Math_CosS(spC6); OPEN_DISPS(gfxCtx, "../z_demo_gt_part1.c", 458); @@ -681,9 +681,9 @@ void DemoGt_Draw1(DemoGt* this, GlobalContext* globalCtx) { Matrix_RotateAxis(spC0, &spA8, MTXMODE_APPLY); Matrix_Translate(sp9C.x, sp9C.y, sp9C.z, MTXMODE_APPLY); Matrix_ToMtx(spB4, "../z_demo_gt_part1.c", 474); - unk198 = this->unk_198; - unk188 = this->unk_188; - unk178 = this->unk_178; + unk198 = pthis->unk_198; + unk188 = pthis->unk_188; + unk178 = pthis->unk_178; Matrix_Pop(); @@ -708,17 +708,17 @@ void DemoGt_Draw1(DemoGt* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_gt_part1.c", 557); } -void func_8097F904_Init1(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 1, 2, &gTowerCollapseCsCollapsedStructureInnerCol); +void func_8097F904_Init1(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; + func_8097EE44(pthis, globalCtx, 1, 2, &gTowerCollapseCsCollapsedStructureInnerCol); } -void func_8097F960(DemoGt* this, GlobalContext* globalCtx) { +void func_8097F960(DemoGt* pthis, GlobalContext* globalCtx) { } -void func_8097F96C(DemoGt* this, GlobalContext* globalCtx) { +void func_8097F96C(DemoGt* pthis, GlobalContext* globalCtx) { static Actor* cloudRing = NULL; s32 pad[4]; Vec3f pos; @@ -726,9 +726,9 @@ void func_8097F96C(DemoGt* this, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (((frames > 1059) && (frames < 1062)) || kREG(1) == 17) { - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + 612.0f; - pos.z = this->dyna.actor.world.pos.z; + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + 612.0f; + pos.z = pthis->dyna.actor.world.pos.z; if (cloudRing == NULL) { cloudRing = DemoGt_SpawnCloudRing(globalCtx, &pos, 2); @@ -741,11 +741,11 @@ void func_8097F96C(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097FA1C(DemoGt* this, GlobalContext* globalCtx) { +void func_8097FA1C(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; u16 frames = globalCtx->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { -12.0f, -17.0, 5.0 }; s32 pad1[3]; @@ -757,7 +757,7 @@ void func_8097FA1C(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097FAFC(DemoGt* this, GlobalContext* globalCtx) { +void func_8097FAFC(DemoGt* pthis, GlobalContext* globalCtx) { static Vec3f velocity = { 0.0f, 1.0f, 0.0f }; static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static f32 arg4 = 280.0f; @@ -771,7 +771,7 @@ void func_8097FAFC(DemoGt* this, GlobalContext* globalCtx) { f32 new_var = -200.0; if (((frames > 582) && (frames < 683)) || (kREG(1) == 6)) { - pos = this->dyna.actor.world.pos; + pos = pthis->dyna.actor.world.pos; pos.y += 680.0f; if (frames == 682) { @@ -784,11 +784,11 @@ void func_8097FAFC(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097FC1C(DemoGt* this, GlobalContext* globalCtx) { +void func_8097FC1C(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; u16 frames = globalCtx->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 5.0f, -16.0f, -16.0f }; s32 pad1[3]; @@ -800,31 +800,31 @@ void func_8097FC1C(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097FCE4(DemoGt* this, GlobalContext* globalCtx) { +void func_8097FCE4(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f vec; u16 frames = globalCtx->csCtx.frames; if (frames == 0x1F7 || kREG(1) == 4) { - vec.x = this->dyna.actor.world.pos.x + 300.0f; - vec.y = this->dyna.actor.world.pos.y + 560.0f; - vec.z = this->dyna.actor.world.pos.z - 377.0f; + vec.x = pthis->dyna.actor.world.pos.x + 300.0f; + vec.y = pthis->dyna.actor.world.pos.y + 560.0f; + vec.z = pthis->dyna.actor.world.pos.z - 377.0f; DemoGt_SpawnExplosionWithSound(globalCtx, &vec, 2.0f); } } -void func_8097FD70(DemoGt* this, GlobalContext* globalCtx) { - func_8097F960(this, globalCtx); - func_8097F96C(this, globalCtx); - func_8097FA1C(this, globalCtx); - func_8097FAFC(this, globalCtx); - func_8097FC1C(this, globalCtx); - func_8097FCE4(this, globalCtx); +void func_8097FD70(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097F960(pthis, globalCtx); + func_8097F96C(pthis, globalCtx); + func_8097FA1C(pthis, globalCtx); + func_8097FAFC(pthis, globalCtx); + func_8097FC1C(pthis, globalCtx); + func_8097FCE4(pthis, globalCtx); } -void func_8097FDDC(DemoGt* this, GlobalContext* globalCtx) { - s32* unk178 = this->unk_178; - s32* unk198 = this->unk_198; +void func_8097FDDC(DemoGt* pthis, GlobalContext* globalCtx) { + s32* unk178 = pthis->unk_178; + s32* unk198 = pthis->unk_198; if (globalCtx->csCtx.frames < 610) { unk178[0] = 163; @@ -845,26 +845,26 @@ void func_8097FDDC(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8097FED8(DemoGt* this, GlobalContext* globalCtx) { +void func_8097FED8(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 2)) { - this->updateMode = 9; + pthis->updateMode = 9; } } -void DemoGt_Update1(DemoGt* this, GlobalContext* globalCtx) { - func_8097FDDC(this, globalCtx); - func_8097E824(this, 2); - func_8097FD70(this, globalCtx); - func_8097FED8(this, globalCtx); +void DemoGt_Update1(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097FDDC(pthis, globalCtx); + func_8097E824(pthis, 2); + func_8097FD70(pthis, globalCtx); + func_8097FED8(pthis, globalCtx); } -void DemoGt_Update9(DemoGt* this, GlobalContext* globalCtx) { - func_8097FDDC(this, globalCtx); - func_8097ED64(this, globalCtx, 2); - func_8097FD70(this, globalCtx); +void DemoGt_Update9(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097FDDC(pthis, globalCtx); + func_8097ED64(pthis, globalCtx, 2); + func_8097FD70(pthis, globalCtx); } -void DemoGt_Draw2(DemoGt* this, GlobalContext* globalCtx) { +void DemoGt_Draw2(DemoGt* pthis, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32* unk198; s32* unk178; @@ -873,8 +873,8 @@ void DemoGt_Draw2(DemoGt* this, GlobalContext* globalCtx) { OPEN_DISPS(gfxCtx, "../z_demo_gt_part2.c", 470); func_80093D18(gfxCtx); - unk198 = this->unk_198; - unk178 = this->unk_178; + unk198 = pthis->unk_198; + unk178 = pthis->unk_178; gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScrollEnvColor(gfxCtx, 0, 0, unk198[0], 0x20, 0x40, 1, 0, unk198[1], 0x20, 0x40, unk178[0], unk178[1], unk178[2], 128)); @@ -886,29 +886,29 @@ void DemoGt_Draw2(DemoGt* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_gt_part2.c", 489); } -void func_80980110_Init2(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 2, 3, &gTowerCollapseCsCollapsedStructureOuterCol); +void func_80980110_Init2(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; + func_8097EE44(pthis, globalCtx, 2, 3, &gTowerCollapseCsCollapsedStructureOuterCol); } -void func_8098016C(DemoGt* this, GlobalContext* globalCtx) { +void func_8098016C(DemoGt* pthis, GlobalContext* globalCtx) { } -void func_80980178(DemoGt* this, GlobalContext* globalCtx) { +void func_80980178(DemoGt* pthis, GlobalContext* globalCtx) { } -void func_80980184(DemoGt* this, GlobalContext* globalCtx) { +void func_80980184(DemoGt* pthis, GlobalContext* globalCtx) { static Actor* cloudRing = NULL; s32 pad[4]; Vec3f pos; Actor* actor; if ((globalCtx->csCtx.frames > 1027) && (globalCtx->csCtx.frames < 1031)) { - pos.x = this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y + 247.0f; - pos.z = this->dyna.actor.world.pos.z; + pos.x = pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y + 247.0f; + pos.z = pthis->dyna.actor.world.pos.z; if (cloudRing == NULL) { cloudRing = DemoGt_SpawnCloudRing(globalCtx, &pos, 3); @@ -921,16 +921,16 @@ void func_80980184(DemoGt* this, GlobalContext* globalCtx) { } } -void func_80980218(DemoGt* this, GlobalContext* globalCtx) { +void func_80980218(DemoGt* pthis, GlobalContext* globalCtx) { static Actor* cloudRing = NULL; s32 pad[4]; Vec3f pos; Actor* actor; if ((globalCtx->csCtx.frames > 997) && (globalCtx->csCtx.frames < 1001)) { - pos.x = this->dyna.actor.home.pos.x; - pos.y = this->dyna.actor.home.pos.y + 38.0f; - pos.z = this->dyna.actor.home.pos.z; + pos.x = pthis->dyna.actor.home.pos.x; + pos.y = pthis->dyna.actor.home.pos.y + 38.0f; + pos.z = pthis->dyna.actor.home.pos.z; if (cloudRing == NULL) { cloudRing = DemoGt_SpawnCloudRing(globalCtx, &pos, 4); @@ -943,11 +943,11 @@ void func_80980218(DemoGt* this, GlobalContext* globalCtx) { } } -void func_809802AC(DemoGt* this, GlobalContext* globalCtx) { +void func_809802AC(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; u16 frames = globalCtx->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 0.0f, 0.0f, -10.0f }; s32 pad1[3]; @@ -959,11 +959,11 @@ void func_809802AC(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8098036C(DemoGt* this, GlobalContext* globalCtx) { +void func_8098036C(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; u16 frames = globalCtx->csCtx.frames; - Vec3f* world = &this->dyna.actor.world.pos; + Vec3f* world = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 5.0f, -3.0f, 0.0f }; s32 pad1[3]; @@ -975,11 +975,11 @@ void func_8098036C(DemoGt* this, GlobalContext* globalCtx) { } } -void func_80980430(DemoGt* this, GlobalContext* globalCtx) { +void func_80980430(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; s32 frames = globalCtx->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 5.0f, -3.0f, 0.0f }; s32 pad1[3]; @@ -991,11 +991,11 @@ void func_80980430(DemoGt* this, GlobalContext* globalCtx) { } } -void func_80980504(DemoGt* this, GlobalContext* globalCtx) { +void func_80980504(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; u16 frames = globalCtx->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 5.0f, -16.0f, -16.0f }; s32 pad1[3]; @@ -1007,11 +1007,11 @@ void func_80980504(DemoGt* this, GlobalContext* globalCtx) { } } -void func_809805D8(DemoGt* this, GlobalContext* globalCtx) { +void func_809805D8(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f dustPos; u16 frames = globalCtx->csCtx.frames; - Vec3f* homePos = &this->dyna.actor.home.pos; + Vec3f* homePos = &pthis->dyna.actor.home.pos; Vec3f velOffset = { 15.0f, -26.0, 0.0f }; s32 pad1[3]; @@ -1023,11 +1023,11 @@ void func_809805D8(DemoGt* this, GlobalContext* globalCtx) { } } -void func_809806B8(DemoGt* this, GlobalContext* globalContext) { +void func_809806B8(DemoGt* pthis, GlobalContext* globalContext) { s32 pad[3]; Vec3f dustPos; u16 frames = globalContext->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 5.0f, -16.0f, -16.0f }; s32 pad1[3]; @@ -1039,11 +1039,11 @@ void func_809806B8(DemoGt* this, GlobalContext* globalContext) { } } -void func_8098078C(DemoGt* this, GlobalContext* globalContext) { +void func_8098078C(DemoGt* pthis, GlobalContext* globalContext) { s32 pad[3]; Vec3f dustPos; u16 frames = globalContext->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; Vec3f velOffset = { 5.0f, -16.0f, -16.0f }; s32 pad1[3]; @@ -1055,11 +1055,11 @@ void func_8098078C(DemoGt* this, GlobalContext* globalContext) { } } -void func_8098085C(DemoGt* this, GlobalContext* globalCtx) { +void func_8098085C(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f sp28; u16 frames = globalCtx->csCtx.frames; - Vec3f* pos = &this->dyna.actor.world.pos; + Vec3f* pos = &pthis->dyna.actor.world.pos; if ((frames == 58) || (kREG(1) == 1)) { sp28.x = pos->x + 900.0f; @@ -1079,9 +1079,9 @@ void func_8098085C(DemoGt* this, GlobalContext* globalCtx) { } } -void func_809809C0(DemoGt* this, GlobalContext* globalCtx2) { +void func_809809C0(DemoGt* pthis, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - DemoGt* this2 = this; + DemoGt* pthis2 = pthis; s32 gameplayFrames = globalCtx->gameplayFrames; u16 frames = globalCtx->csCtx.frames; Vec3f sp54; @@ -1092,9 +1092,9 @@ void func_809809C0(DemoGt* this, GlobalContext* globalCtx2) { Vec3f sp34 = { 0.0f, 0.0f, 0.0f }; s16 pad2[3]; - sp54.x = this2->dyna.actor.world.pos.x + 790.0f; - sp54.y = this2->dyna.actor.world.pos.y + 60.0f; - sp54.z = this2->dyna.actor.world.pos.z + 23.0f; + sp54.x = pthis2->dyna.actor.world.pos.x + 790.0f; + sp54.y = pthis2->dyna.actor.world.pos.y + 60.0f; + sp54.z = pthis2->dyna.actor.world.pos.z + 23.0f; if (ABS(gameplayFrames % 12) == 0) { DemoGt_SpawnExplosionNoSound(globalCtx, &sp54, &sp40, &sp34, 2.0f); @@ -1102,87 +1102,87 @@ void func_809809C0(DemoGt* this, GlobalContext* globalCtx2) { } } -void func_80980AD4(DemoGt* this, GlobalContext* globalCtx) { +void func_80980AD4(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[4]; Vec3f pos; u16 frames = globalCtx->csCtx.frames; if ((frames == 477) || (kREG(2) == 1)) { - pos.x = this->dyna.actor.world.pos.x + 790.0f; - pos.y = this->dyna.actor.world.pos.y + 60.0f; - pos.z = this->dyna.actor.world.pos.z + 23.0f; + pos.x = pthis->dyna.actor.world.pos.x + 790.0f; + pos.y = pthis->dyna.actor.world.pos.y + 60.0f; + pos.z = pthis->dyna.actor.world.pos.z + 23.0f; - func_8097DAC8(this, globalCtx, &pos); + func_8097DAC8(pthis, globalCtx, &pos); DemoGt_PlayExplosion2Sfx(globalCtx, &pos); } } -void func_80980B68(DemoGt* this, GlobalContext* globalCtx) { +void func_80980B68(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[4]; Vec3f pos; u16 frames = globalCtx->csCtx.frames; if ((frames == 317) || (kREG(3) == 1)) { - pos.x = this->dyna.actor.world.pos.x + 980.0f; - pos.y = this->dyna.actor.world.pos.y + 410.0f; - pos.z = this->dyna.actor.world.pos.z - 177.0f; - func_8097DD28(this, globalCtx, &pos); + pos.x = pthis->dyna.actor.world.pos.x + 980.0f; + pos.y = pthis->dyna.actor.world.pos.y + 410.0f; + pos.z = pthis->dyna.actor.world.pos.z - 177.0f; + func_8097DD28(pthis, globalCtx, &pos); DemoGt_PlayExplosion2Sfx(globalCtx, &pos); } } -void func_80980BFC(DemoGt* this, GlobalContext* globalCtx) { +void func_80980BFC(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[4]; Vec3f pos; u16 frames = globalCtx->csCtx.frames; if ((frames == 740) || (kREG(4) == 1)) { - pos.x = this->dyna.actor.world.pos.x + 790.0f; - pos.y = this->dyna.actor.world.pos.y + 60.0f; - pos.z = this->dyna.actor.world.pos.z + 23.0f; + pos.x = pthis->dyna.actor.world.pos.x + 790.0f; + pos.y = pthis->dyna.actor.world.pos.y + 60.0f; + pos.z = pthis->dyna.actor.world.pos.z + 23.0f; - func_8097DF70(this, globalCtx, &pos); + func_8097DF70(pthis, globalCtx, &pos); DemoGt_PlayExplosion2Sfx(globalCtx, &pos); } } -void func_80980C90(DemoGt* this, GlobalContext* globalCtx) { - func_8098016C(this, globalCtx); - func_80980178(this, globalCtx); - func_80980184(this, globalCtx); - func_80980218(this, globalCtx); - func_809802AC(this, globalCtx); - func_8098036C(this, globalCtx); - func_80980430(this, globalCtx); - func_80980504(this, globalCtx); - func_809805D8(this, globalCtx); - func_809806B8(this, globalCtx); - func_8098078C(this, globalCtx); - func_8098085C(this, globalCtx); - func_809809C0(this, globalCtx); - func_80980AD4(this, globalCtx); - func_80980B68(this, globalCtx); - func_80980BFC(this, globalCtx); +void func_80980C90(DemoGt* pthis, GlobalContext* globalCtx) { + func_8098016C(pthis, globalCtx); + func_80980178(pthis, globalCtx); + func_80980184(pthis, globalCtx); + func_80980218(pthis, globalCtx); + func_809802AC(pthis, globalCtx); + func_8098036C(pthis, globalCtx); + func_80980430(pthis, globalCtx); + func_80980504(pthis, globalCtx); + func_809805D8(pthis, globalCtx); + func_809806B8(pthis, globalCtx); + func_8098078C(pthis, globalCtx); + func_8098085C(pthis, globalCtx); + func_809809C0(pthis, globalCtx); + func_80980AD4(pthis, globalCtx); + func_80980B68(pthis, globalCtx); + func_80980BFC(pthis, globalCtx); } -void func_80980D74(DemoGt* this, GlobalContext* globalCtx) { +void func_80980D74(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 3)) { - this->updateMode = 10; + pthis->updateMode = 10; } } -void DemoGt_Update2(DemoGt* this, GlobalContext* globalCtx) { - func_8097E824(this, 3); - func_80980C90(this, globalCtx); - func_80980D74(this, globalCtx); +void DemoGt_Update2(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097E824(pthis, 3); + func_80980C90(pthis, globalCtx); + func_80980D74(pthis, globalCtx); } -void DemoGt_Update10(DemoGt* this, GlobalContext* globalCtx) { - func_8097ED64(this, globalCtx, 3); - func_80980C90(this, globalCtx); +void DemoGt_Update10(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097ED64(pthis, globalCtx, 3); + func_80980C90(pthis, globalCtx); } -void DemoGt_Draw3(DemoGt* this, GlobalContext* globalCtx) { +void DemoGt_Draw3(DemoGt* pthis, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_demo_gt_part3.c", 1026); @@ -1196,23 +1196,23 @@ void DemoGt_Draw3(DemoGt* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_gt_part3.c", 1032); } -void func_80980F00_Init5(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; +void func_80980F00_Init5(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 3, 4, NULL); + func_8097EE44(pthis, globalCtx, 3, 4, NULL); } -void func_80980F58(DemoGt* this, GlobalContext* globalCtx) { +void func_80980F58(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (frames == 244) { - func_80078914(&this->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); + func_80078914(&pthis->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); } } -void func_80980F8C(DemoGt* this, GlobalContext* globalCtx) { +void func_80980F8C(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f sp58; Vec3f dustPos; @@ -1231,37 +1231,37 @@ void func_80980F8C(DemoGt* this, GlobalContext* globalCtx) { } } -void func_8098103C(DemoGt* this, GlobalContext* globalCtx) { +void func_8098103C(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 4)) { - this->updateMode = 11; + pthis->updateMode = 11; } else if (func_8097E704(globalCtx, 3, 4)) { - this->updateMode = 16; + pthis->updateMode = 16; } } -void DemoGt_Update3(DemoGt* this, GlobalContext* globalCtx) { - func_8097E824(this, 4); - func_80980F58(this, globalCtx); - func_8098103C(this, globalCtx); +void DemoGt_Update3(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097E824(pthis, 4); + func_80980F58(pthis, globalCtx); + func_8098103C(pthis, globalCtx); } -void DemoGt_Update11(DemoGt* this, GlobalContext* globalCtx) { - func_8097ED64(this, globalCtx, 4); - func_80980F58(this, globalCtx); +void DemoGt_Update11(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097ED64(pthis, globalCtx, 4); + func_80980F58(pthis, globalCtx); } -void DemoGt_Update16(DemoGt* this, GlobalContext* globalCtx) { - f32 temp = this->unk_172; +void DemoGt_Update16(DemoGt* pthis, GlobalContext* globalCtx) { + f32 temp = pthis->unk_172; - this->unk_174 = (temp * ((kREG(64) * 0.001f) + 0.048f)) + (kREG(65) + 98.0f); - this->unk_172 += this->unk_174; + pthis->unk_174 = (temp * ((kREG(64) * 0.001f) + 0.048f)) + (kREG(65) + 98.0f); + pthis->unk_172 += pthis->unk_174; - if (this->unk_172 > 0x4000) { - this->unk_172 = 0x4000; + if (pthis->unk_172 > 0x4000) { + pthis->unk_172 = 0x4000; } } -void DemoGt_Draw4(DemoGt* this, GlobalContext* globalCtx2) { +void DemoGt_Draw4(DemoGt* pthis, GlobalContext* globalCtx2) { GraphicsContext* gfxCtx; GlobalContext* globalCtx = globalCtx2; u16 frames = globalCtx->csCtx.frames; @@ -1279,13 +1279,13 @@ void DemoGt_Draw4(DemoGt* this, GlobalContext* globalCtx2) { if (frames < 301) { - sp76 = this->unk_172; + sp76 = pthis->unk_172; sp70 = fabsf(sp76 * (M_PI / 0x8000)); sp6C = kREG(61); sp68 = (s16)((s32)kREG(58)) + 0x4000; sp6A = kREG(58); gfxCtx = globalCtx->state.gfxCtx; - sp60 = Graph_Alloc(gfxCtx, sizeof(Mtx)); + sp60 = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); sp44 = 1.0f - Math_CosS(sp76); OPEN_DISPS(gfxCtx, "../z_demo_gt_part4_1.c", 217); @@ -1305,7 +1305,7 @@ void DemoGt_Draw4(DemoGt* this, GlobalContext* globalCtx2) { Matrix_ToMtx(sp60, "../z_demo_gt_part4_1.c", 232); if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80980F8C(this, globalCtx); + func_80980F8C(pthis, globalCtx); } Matrix_Pop(); @@ -1319,23 +1319,23 @@ void DemoGt_Draw4(DemoGt* this, GlobalContext* globalCtx2) { } } -void func_809813CC_Init6(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; +void func_809813CC_Init6(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 4, 5, NULL); + func_8097EE44(pthis, globalCtx, 4, 5, NULL); } -void func_80981424(DemoGt* this, GlobalContext* globalCtx) { +void func_80981424(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (frames == 789) { - func_80078914(&this->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); + func_80078914(&pthis->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); } } -void func_80981458(DemoGt* this, GlobalContext* globalCtx) { +void func_80981458(DemoGt* pthis, GlobalContext* globalCtx) { s32 pad[3]; Vec3f sp58; Vec3f dustPos; @@ -1354,37 +1354,37 @@ void func_80981458(DemoGt* this, GlobalContext* globalCtx) { } } -void func_80981524(DemoGt* this, GlobalContext* globalCtx) { +void func_80981524(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 5)) { - this->updateMode = 12; + pthis->updateMode = 12; } else if (func_8097E704(globalCtx, 3, 5)) { - this->updateMode = 17; + pthis->updateMode = 17; } } -void DemoGt_Update4(DemoGt* this, GlobalContext* globalCtx) { - func_8097E824(this, 5); - func_80981424(this, globalCtx); - func_80981524(this, globalCtx); +void DemoGt_Update4(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097E824(pthis, 5); + func_80981424(pthis, globalCtx); + func_80981524(pthis, globalCtx); } -void DemoGt_Update12(DemoGt* this, GlobalContext* globalCtx) { - func_8097ED64(this, globalCtx, 5); - func_80981424(this, globalCtx); +void DemoGt_Update12(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097ED64(pthis, globalCtx, 5); + func_80981424(pthis, globalCtx); } -void DemoGt_Update17(DemoGt* this, GlobalContext* globalCtx) { - f32 temp = this->unk_172; +void DemoGt_Update17(DemoGt* pthis, GlobalContext* globalCtx) { + f32 temp = pthis->unk_172; - this->unk_174 = temp * ((kREG(66) * 0.001f) + 0.048f) + (kREG(67) + 50.0f); - this->unk_172 += this->unk_174; + pthis->unk_174 = temp * ((kREG(66) * 0.001f) + 0.048f) + (kREG(67) + 50.0f); + pthis->unk_172 += pthis->unk_174; - if (this->unk_172 > 0x4000) { - this->unk_172 = 0x4000; + if (pthis->unk_172 > 0x4000) { + pthis->unk_172 = 0x4000; } } -void DemoGt_Draw5(DemoGt* this, GlobalContext* globalCtx) { +void DemoGt_Draw5(DemoGt* pthis, GlobalContext* globalCtx) { GraphicsContext* gfxCtx; s32 pad; s16 sp76; @@ -1398,13 +1398,13 @@ void DemoGt_Draw5(DemoGt* this, GlobalContext* globalCtx) { Vec3f sp48; f32 sp44; - sp76 = this->unk_172; + sp76 = pthis->unk_172; sp70 = fabsf(sp76 * (M_PI / 0x8000)); sp6C = kREG(62); sp6A = kREG(59) - 0x4000; sp68 = (s16)(kREG(59) - 0x4000) + 0x4000; gfxCtx = globalCtx->state.gfxCtx; - sp60 = Graph_Alloc(gfxCtx, sizeof(Mtx)); + sp60 = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); sp44 = 1 - Math_CosS(sp76); OPEN_DISPS(gfxCtx, "../z_demo_gt_part4_2.c", 212); @@ -1424,7 +1424,7 @@ void DemoGt_Draw5(DemoGt* this, GlobalContext* globalCtx) { Matrix_ToMtx(sp60, "../z_demo_gt_part4_2.c", 227); if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80981458(this, globalCtx); + func_80981458(pthis, globalCtx); } Matrix_Pop(); @@ -1437,53 +1437,53 @@ void DemoGt_Draw5(DemoGt* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_gt_part4_2.c", 241); } -void func_809818A4_Init7(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; +void func_809818A4_Init7(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 5, 6, NULL); + func_8097EE44(pthis, globalCtx, 5, 6, NULL); } -void func_809818FC(DemoGt* this, GlobalContext* globalCtx) { +void func_809818FC(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (frames == 845) { - func_80078914(&this->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); + func_80078914(&pthis->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); } } -void func_80981930(DemoGt* this, GlobalContext* globalCtx) { +void func_80981930(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 6)) { - this->updateMode = 13; + pthis->updateMode = 13; } else if (func_8097E704(globalCtx, 3, 6)) { - this->updateMode = 18; + pthis->updateMode = 18; } } -void DemoGt_Update5(DemoGt* this, GlobalContext* globalCtx) { - func_8097E824(this, 6); - func_809818FC(this, globalCtx); - func_80981930(this, globalCtx); +void DemoGt_Update5(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097E824(pthis, 6); + func_809818FC(pthis, globalCtx); + func_80981930(pthis, globalCtx); } -void DemoGt_Update13(DemoGt* this, GlobalContext* globalCtx) { - func_8097ED64(this, globalCtx, 6); - func_809818FC(this, globalCtx); +void DemoGt_Update13(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097ED64(pthis, globalCtx, 6); + func_809818FC(pthis, globalCtx); } -void DemoGt_Update18(DemoGt* this, GlobalContext* globalCtx) { - f32 temp = this->unk_172; +void DemoGt_Update18(DemoGt* pthis, GlobalContext* globalCtx) { + f32 temp = pthis->unk_172; - this->unk_174 = (temp * ((kREG(68) * 0.001f) + 0.005f)) + (kREG(69) + 50.0f); - this->unk_172 += this->unk_174; + pthis->unk_174 = (temp * ((kREG(68) * 0.001f) + 0.005f)) + (kREG(69) + 50.0f); + pthis->unk_172 += pthis->unk_174; - if (this->unk_172 > 0x4000) { - this->unk_172 = 0x4000; + if (pthis->unk_172 > 0x4000) { + pthis->unk_172 = 0x4000; } } -void DemoGt_Draw6(DemoGt* this, GlobalContext* globalCtx) { - DemoGt* this2 = this; - s16 sp78 = this2->unk_172; +void DemoGt_Draw6(DemoGt* pthis, GlobalContext* globalCtx) { + DemoGt* pthis2 = pthis; + s16 sp78 = pthis2->unk_172; f32 sp74; f32 sp70; s16 sp6E; @@ -1500,7 +1500,7 @@ void DemoGt_Draw6(DemoGt* this, GlobalContext* globalCtx) { sp6C = kREG(60) + 0x4000; sp6C += 0x4000; gfxCtx = globalCtx->state.gfxCtx; - sp64 = Graph_Alloc(gfxCtx, sizeof(Mtx)); + sp64 = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); sp48 = 1.0f - Math_CosS(sp78); OPEN_DISPS(gfxCtx, "../z_demo_gt_part4_3.c", 276); @@ -1529,52 +1529,52 @@ void DemoGt_Draw6(DemoGt* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_gt_part4_3.c", 307); } -void func_80981C94_Init23(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 6, 7, NULL); +void func_80981C94_Init23(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; + func_8097EE44(pthis, globalCtx, 6, 7, NULL); } -void func_80981CEC(DemoGt* this, GlobalContext* globalCtx) { +void func_80981CEC(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (frames == 183) { - func_80078914(&this->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); + func_80078914(&pthis->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); } } -void func_80981D20(DemoGt* this) { - f32 temp = this->unk_172; +void func_80981D20(DemoGt* pthis) { + f32 temp = pthis->unk_172; - this->unk_174 = temp * ((kREG(64) * 0.001f) + 0.048f) + (kREG(76) + 100.0f); - this->unk_172 += this->unk_174; + pthis->unk_174 = temp * ((kREG(64) * 0.001f) + 0.048f) + (kREG(76) + 100.0f); + pthis->unk_172 += pthis->unk_174; - if (this->unk_172 > (s16)(kREG(80) + 0x4000)) { - this->unk_172 = kREG(80) + 0x4000; + if (pthis->unk_172 > (s16)(kREG(80) + 0x4000)) { + pthis->unk_172 = kREG(80) + 0x4000; } } -void func_80981DC8(DemoGt* this, GlobalContext* globalCtx) { +void func_80981DC8(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 7)) { - this->updateMode = 0xE; + pthis->updateMode = 0xE; } } -void DemoGt_Update6(DemoGt* this, GlobalContext* globalCtx) { - func_8097E824(this, 7); - func_80981CEC(this, globalCtx); - func_80981DC8(this, globalCtx); +void DemoGt_Update6(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097E824(pthis, 7); + func_80981CEC(pthis, globalCtx); + func_80981DC8(pthis, globalCtx); } -void DemoGt_Update14(DemoGt* this, GlobalContext* globalCtx) { - func_80981D20(this); - func_8097ED64(this, globalCtx, 7); - func_80981CEC(this, globalCtx); +void DemoGt_Update14(DemoGt* pthis, GlobalContext* globalCtx) { + func_80981D20(pthis); + func_8097ED64(pthis, globalCtx, 7); + func_80981CEC(pthis, globalCtx); } -void DemoGt_Draw7(DemoGt* this, GlobalContext* globalCtx) { - DemoGt* this2 = this; +void DemoGt_Draw7(DemoGt* pthis, GlobalContext* globalCtx) { + DemoGt* pthis2 = pthis; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 sp6E; f32 sp68; @@ -1586,13 +1586,13 @@ void DemoGt_Draw7(DemoGt* this, GlobalContext* globalCtx) { Vec3f sp44; f32 sp40; - sp6E = this2->unk_172; + sp6E = pthis2->unk_172; sp68 = fabsf(sp6E * (M_PI / 0x8000)); sp64 = kREG(75); sp62 = kREG(74) + 0x7FEC; sp60 = kREG(74) + 0x7FEC; sp60 = sp60 + 0x4000; - sp5C = Graph_Alloc(gfxCtx, sizeof(Mtx)); + sp5C = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); sp40 = 1.0f - Math_CosS(sp6E); OPEN_DISPS(gfxCtx, "../z_demo_gt_part5.c", 136); @@ -1620,52 +1620,52 @@ void DemoGt_Draw7(DemoGt* this, GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_demo_gt_part5.c", 160); } -void func_80982054_Init24(DemoGt* this, GlobalContext* globalCtx) { - this->dyna.actor.scale.x *= 10.0f; - this->dyna.actor.scale.y *= 10.0f; - this->dyna.actor.scale.z *= 10.0f; - func_8097EE44(this, globalCtx, 7, 8, NULL); +void func_80982054_Init24(DemoGt* pthis, GlobalContext* globalCtx) { + pthis->dyna.actor.scale.x *= 10.0f; + pthis->dyna.actor.scale.y *= 10.0f; + pthis->dyna.actor.scale.z *= 10.0f; + func_8097EE44(pthis, globalCtx, 7, 8, NULL); } -void func_809820AC(DemoGt* this, GlobalContext* globalCtx) { +void func_809820AC(DemoGt* pthis, GlobalContext* globalCtx) { u16 frames = globalCtx->csCtx.frames; if (frames == 154) { - func_80078914(&this->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); + func_80078914(&pthis->dyna.actor.projectedPos, NA_SE_EV_TOWER_PARTS_BROKEN - SFX_FLAG); } } -void func_809820E0(DemoGt* this) { - f32 temp = this->unk_172; +void func_809820E0(DemoGt* pthis) { + f32 temp = pthis->unk_172; - this->unk_174 = (temp * ((kREG(64) * 0.001f) + 0.048f)) + (kREG(79) + 100.0f); - this->unk_172 += this->unk_174; + pthis->unk_174 = (temp * ((kREG(64) * 0.001f) + 0.048f)) + (kREG(79) + 100.0f); + pthis->unk_172 += pthis->unk_174; - if (this->unk_172 > (s16)(kREG(81) + 0x4000)) { - this->unk_172 = kREG(81) + 0x4000; + if (pthis->unk_172 > (s16)(kREG(81) + 0x4000)) { + pthis->unk_172 = kREG(81) + 0x4000; } } -void func_80982188(DemoGt* this, GlobalContext* globalCtx) { +void func_80982188(DemoGt* pthis, GlobalContext* globalCtx) { if (func_8097E704(globalCtx, 2, 9) != 0) { - this->updateMode = 15; + pthis->updateMode = 15; } } -void DemoGt_Update7(DemoGt* this, GlobalContext* globalCtx) { - func_8097E824(this, 9); - func_809820AC(this, globalCtx); - func_80982188(this, globalCtx); +void DemoGt_Update7(DemoGt* pthis, GlobalContext* globalCtx) { + func_8097E824(pthis, 9); + func_809820AC(pthis, globalCtx); + func_80982188(pthis, globalCtx); } -void DemoGt_Update15(DemoGt* this, GlobalContext* globalCtx) { - func_809820E0(this); - func_8097ED64(this, globalCtx, 9); - func_809820AC(this, globalCtx); +void DemoGt_Update15(DemoGt* pthis, GlobalContext* globalCtx) { + func_809820E0(pthis); + func_8097ED64(pthis, globalCtx, 9); + func_809820AC(pthis, globalCtx); } -void DemoGt_Draw8(DemoGt* this, GlobalContext* globalCtx) { - DemoGt* this2 = this; +void DemoGt_Draw8(DemoGt* pthis, GlobalContext* globalCtx) { + DemoGt* pthis2 = pthis; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 sp6E; f32 sp68; @@ -1677,13 +1677,13 @@ void DemoGt_Draw8(DemoGt* this, GlobalContext* globalCtx) { Vec3f sp44; f32 sp40; - sp6E = this2->unk_172; + sp6E = pthis2->unk_172; sp68 = fabsf(sp6E * (M_PI / 0x8000)); sp64 = kREG(78); sp62 = kREG(77) + 0xBE80; sp60 = kREG(77) + 0xBE80; sp60 += 0x4000; - sp5C = Graph_Alloc(gfxCtx, sizeof(Mtx)); + sp5C = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); sp40 = 1.0f - Math_CosS(sp6E); OPEN_DISPS(gfxCtx, "../z_demo_gt_part6.c", 137); @@ -1719,54 +1719,54 @@ static DemoGtUpdateFunc sUpdateFuncs[] = { }; void DemoGt_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoGt* this = (DemoGt*)thisx; + DemoGt* pthis = (DemoGt*)thisx; DemoGtUpdateFunc updateFunc; - if ((this->updateMode < 0) || (this->updateMode >= 19) || (updateFunc = sUpdateFuncs[this->updateMode]) == NULL) { + if ((pthis->updateMode < 0) || (pthis->updateMode >= 19) || (updateFunc = sUpdateFuncs[pthis->updateMode]) == NULL) { // "The main mode is strange!" osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - updateFunc(this, globalCtx); + updateFunc(pthis, globalCtx); } void DemoGt_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoGt* this = (DemoGt*)thisx; + DemoGt* pthis = (DemoGt*)thisx; - switch (this->dyna.actor.params) { + switch (pthis->dyna.actor.params) { case 0: - func_8097EEA8_Init0(this, globalCtx); + func_8097EEA8_Init0(pthis, globalCtx); break; case 1: - func_8097F904_Init1(this, globalCtx); + func_8097F904_Init1(pthis, globalCtx); break; case 2: - func_80980110_Init2(this, globalCtx); + func_80980110_Init2(pthis, globalCtx); break; case 5: - func_80980F00_Init5(this, globalCtx); + func_80980F00_Init5(pthis, globalCtx); break; case 6: - func_809813CC_Init6(this, globalCtx); + func_809813CC_Init6(pthis, globalCtx); break; case 7: - func_809818A4_Init7(this, globalCtx); + func_809818A4_Init7(pthis, globalCtx); break; case 23: - func_80981C94_Init23(this, globalCtx); + func_80981C94_Init23(pthis, globalCtx); break; case 24: - func_80982054_Init24(this, globalCtx); + func_80982054_Init24(pthis, globalCtx); break; default: // "Demo_Gt_Actor_ct There is no such argument !" osSyncPrintf("Demo_Gt_Actor_ct そんな引数は無い!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - Actor_Kill(&this->dyna.actor); + Actor_Kill(&pthis->dyna.actor); } } -void DemoGt_Draw0(DemoGt* this, GlobalContext* globalCtx) { +void DemoGt_Draw0(DemoGt* pthis, GlobalContext* globalCtx) { } static DemoGtDrawFunc sDrawFuncs[] = { @@ -1775,19 +1775,19 @@ static DemoGtDrawFunc sDrawFuncs[] = { }; void DemoGt_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoGt* this = (DemoGt*)thisx; + DemoGt* pthis = (DemoGt*)thisx; DemoGtDrawFunc drawFunc; - if ((this->drawConfig < 0) || (this->drawConfig >= 9) || (drawFunc = sDrawFuncs[this->drawConfig]) == NULL) { + if ((pthis->drawConfig < 0) || (pthis->drawConfig >= 9) || (drawFunc = sDrawFuncs[pthis->drawConfig]) == NULL) { // "The drawing mode is strange !!!!!!!!!!!!!!!!!!!!!!!!!" osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - drawFunc(this, globalCtx); + drawFunc(pthis, globalCtx); } -const ActorInit Demo_Gt_InitVars = { +ActorInit Demo_Gt_InitVars = { ACTOR_DEMO_GT, ACTORCAT_PROP, FLAGS, diff --git a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.cpp similarity index 58% rename from src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c rename to src/overlays/actors/ovl_Demo_Ik/z_demo_ik.cpp index 4f4f0b2d5..9dce04b9b 100644 --- a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c +++ b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.cpp @@ -18,29 +18,29 @@ void DemoIk_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoIk_Update(Actor* thisx, GlobalContext* globalCtx); void DemoIk_Draw(Actor* thisx, GlobalContext* globalCtx); -void DemoIk_Type1Init(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type2Init(DemoIk* this, GlobalContext* globalCtx); +void DemoIk_Type1Init(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type2Init(DemoIk* pthis, GlobalContext* globalCtx); -void DemoIk_Type1Action0(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type1Action1(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type1Action2(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type2Action0(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type2Action1(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type2Action2(DemoIk* this, GlobalContext* globalCtx); +void DemoIk_Type1Action0(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type1Action1(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type1Action2(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type2Action0(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type2Action1(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type2Action2(DemoIk* pthis, GlobalContext* globalCtx); -void DemoIk_DrawNothing(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type1Draw(DemoIk* this, GlobalContext* globalCtx); -void DemoIk_Type2Draw(DemoIk* this, GlobalContext* globalCtx); +void DemoIk_DrawNothing(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type1Draw(DemoIk* pthis, GlobalContext* globalCtx); +void DemoIk_Type2Draw(DemoIk* pthis, GlobalContext* globalCtx); void DemoIk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void DemoIk_BgCheck(DemoIk* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); +void DemoIk_BgCheck(DemoIk* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); } -s32 DemoIk_UpdateSkelAnime(DemoIk* this) { - return SkelAnime_Update(&this->skelAnime); +s32 DemoIk_UpdateSkelAnime(DemoIk* pthis) { + return SkelAnime_Update(&pthis->skelAnime); } CsCmdActorAction* DemoIk_GetCue(GlobalContext* globalCtx, s32 index) { @@ -59,21 +59,21 @@ s32 DemoIk_CheckCue(GlobalContext* globalCtx, u16 action, s32 index) { return 0; } -void DemoIk_SetMove(DemoIk* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 1; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); +void DemoIk_SetMove(DemoIk* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 1; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); } -void DemoIk_EndMove(DemoIk* this) { - this->skelAnime.moveFlags &= ~1; +void DemoIk_EndMove(DemoIk* pthis) { + pthis->skelAnime.moveFlags &= ~1; } -f32 DemoIk_GetCurFrame(DemoIk* this) { - return this->skelAnime.curFrame; +f32 DemoIk_GetCurFrame(DemoIk* pthis) { + return pthis->skelAnime.curFrame; } Gfx* DemoIk_SetColors(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { - Gfx* head = Graph_Alloc(gfxCtx, 3 * sizeof(Gfx)); + Gfx* head = (Gfx*)Graph_Alloc(gfxCtx, 3 * sizeof(Gfx)); Gfx* entry = head; gDPSetPrimColor(entry++, 0x00, 0x00, primR, primG, primB, 255); @@ -95,37 +95,37 @@ s32 DemoIk_GetIndexFromParams(s32 params) { return ret; } -void DemoIk_Type1PlaySound(DemoIk* this) { - switch (this->actor.params) { +void DemoIk_Type1PlaySound(DemoIk* pthis) { + switch (pthis->actor.params) { case 0: - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_LAND1_DEMO, &this->actor.projectedPos, 4, &D_801333E0, + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_LAND1_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } break; case 1: - if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_LAND3_DEMO, &this->actor.projectedPos, 4, &D_801333E0, + if (Animation_OnFrame(&pthis->skelAnime, 10.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_LAND3_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } break; case 2: - if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_LAND2_DEMO, &this->actor.projectedPos, 4, &D_801333E0, + if (Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_LAND2_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } break; } } -void DemoIk_SpawnDeadDb(DemoIk* this, GlobalContext* globalCtx) { +void DemoIk_SpawnDeadDb(DemoIk* pthis, GlobalContext* globalCtx) { static Vec3f deadDbOffsets[] = { { -14.0f, 5.0f, 5.0f }, { -20.0f, 12.0f, 0.0f }, { -5.0f, 10.0f, -1.0f }, { -10.0f, 8.0f, 14.0f }, { -3.0f, 10.0f, 7.0f }, { -10.0f, 11.0f, 0.0f }, { 9.0f, 10.0f, -8.0f }, { 4.0f, 10.0f, 3.0f }, { -6.0f, 13.0f, -5.0f }, { 1.0f, 9.0f, 3.0f }, { -10.0f, 9.0f, 1.0f }, }; s32 i; - s32 index = DemoIk_GetIndexFromParams(this->actor.params); + s32 index = DemoIk_GetIndexFromParams(pthis->actor.params); if (DemoIk_CheckCue(globalCtx, 5, index)) { Vec3f pos; @@ -144,32 +144,32 @@ void DemoIk_SpawnDeadDb(DemoIk* this, GlobalContext* globalCtx) { endIndex = 11; } for (i = startIndex; i < endIndex; i++) { - pos.x = deadDbOffsets[i].x + this->actor.world.pos.x; - pos.y = deadDbOffsets[i].y + this->actor.world.pos.y; - pos.z = deadDbOffsets[i].z + this->actor.world.pos.z; + pos.x = deadDbOffsets[i].x + pthis->actor.world.pos.x; + pos.y = deadDbOffsets[i].y + pthis->actor.world.pos.y; + pos.z = deadDbOffsets[i].z + pthis->actor.world.pos.z; EffectSsDeadDb_Spawn(globalCtx, &pos, &zeroVec, &zeroVec, 10, 7, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); } } } -void DemoIk_MoveToStartPos(DemoIk* this, GlobalContext* globalCtx, s32 index) { +void DemoIk_MoveToStartPos(DemoIk* pthis, GlobalContext* globalCtx, s32 index) { CsCmdActorAction* cue = DemoIk_GetCue(globalCtx, index); if (cue != NULL) { - this->actor.world.pos.x = cue->startPos.x; - this->actor.world.pos.y = cue->startPos.y; - this->actor.world.pos.z = cue->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = cue->rot.y; + pthis->actor.world.pos.x = cue->startPos.x; + pthis->actor.world.pos.y = cue->startPos.y; + pthis->actor.world.pos.z = cue->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = cue->rot.y; } } -void DemoIk_Type1Init(DemoIk* this, GlobalContext* globalCtx) { +void DemoIk_Type1Init(DemoIk* pthis, GlobalContext* globalCtx) { s32 pad[3]; SkeletonHeader* skeleton; AnimationHeader* animation; f32 phi_f0; - switch (this->actor.params) { + switch (pthis->actor.params) { case 0: skeleton = &object_ik_Skel_000C90; animation = &object_ik_Anim_000C6C; @@ -186,53 +186,53 @@ void DemoIk_Type1Init(DemoIk* this, GlobalContext* globalCtx) { phi_f0 = 20.0f; // No break is required for matching } - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, phi_f0); - SkelAnime_Init(globalCtx, &this->skelAnime, skeleton, NULL, this->jointTable, this->morphTable, 2); - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, phi_f0); + SkelAnime_Init(globalCtx, &pthis->skelAnime, skeleton, NULL, pthis->jointTable, pthis->morphTable, 2); + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); } -void func_8098393C(DemoIk* this) { - this->actionMode = 0; - this->drawMode = 0; - this->actor.shape.shadowAlpha = 0; +void func_8098393C(DemoIk* pthis) { + pthis->actionMode = 0; + pthis->drawMode = 0; + pthis->actor.shape.shadowAlpha = 0; } -void func_8098394C(DemoIk* this, GlobalContext* globalCtx) { - DemoIk_EndMove(this); - DemoIk_MoveToStartPos(this, globalCtx, DemoIk_GetIndexFromParams(this->actor.params)); - this->actionMode = 1; - this->drawMode = 1; - this->actor.shape.shadowAlpha = 255; - this->skelAnime.curFrame = 0.0f; +void func_8098394C(DemoIk* pthis, GlobalContext* globalCtx) { + DemoIk_EndMove(pthis); + DemoIk_MoveToStartPos(pthis, globalCtx, DemoIk_GetIndexFromParams(pthis->actor.params)); + pthis->actionMode = 1; + pthis->drawMode = 1; + pthis->actor.shape.shadowAlpha = 255; + pthis->skelAnime.curFrame = 0.0f; } -void func_809839AC(DemoIk* this) { - this->actionMode = 2; - this->drawMode = 1; - this->actor.shape.shadowAlpha = 255; - this->skelAnime.curFrame = 0.0f; +void func_809839AC(DemoIk* pthis) { + pthis->actionMode = 2; + pthis->drawMode = 1; + pthis->actor.shape.shadowAlpha = 255; + pthis->skelAnime.curFrame = 0.0f; } -void func_809839D0(DemoIk* this, GlobalContext* globalCtx) { - CsCmdActorAction* cue = DemoIk_GetCue(globalCtx, DemoIk_GetIndexFromParams(this->actor.params)); +void func_809839D0(DemoIk* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* cue = DemoIk_GetCue(globalCtx, DemoIk_GetIndexFromParams(pthis->actor.params)); if (cue != NULL) { s32 nextCsAction = cue->action; - s32 csAction = this->csAction; + s32 csAction = pthis->csAction; if (nextCsAction != csAction) { switch (nextCsAction) { case 1: - func_8098393C(this); + func_8098393C(pthis); break; case 2: - func_8098394C(this, globalCtx); + func_8098394C(pthis, globalCtx); break; case 3: - func_809839AC(this); + func_809839AC(pthis); break; case 4: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; case 5: case 6: @@ -241,36 +241,36 @@ void func_809839D0(DemoIk* this, GlobalContext* globalCtx) { // "there is no such action" osSyncPrintf("Demo_Ik_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); } - this->csAction = nextCsAction; + pthis->csAction = nextCsAction; } } } -void DemoIk_Type1Action0(DemoIk* this, GlobalContext* globalCtx) { - func_809839D0(this, globalCtx); +void DemoIk_Type1Action0(DemoIk* pthis, GlobalContext* globalCtx) { + func_809839D0(pthis, globalCtx); } -void DemoIk_Type1Action1(DemoIk* this, GlobalContext* globalCtx) { - DemoIk_BgCheck(this, globalCtx); - func_809839D0(this, globalCtx); +void DemoIk_Type1Action1(DemoIk* pthis, GlobalContext* globalCtx) { + DemoIk_BgCheck(pthis, globalCtx); + func_809839D0(pthis, globalCtx); } -void DemoIk_Type1Action2(DemoIk* this, GlobalContext* globalCtx) { - DemoIk_UpdateSkelAnime(this); - DemoIk_Type1PlaySound(this); - DemoIk_SetMove(this, globalCtx); - DemoIk_BgCheck(this, globalCtx); - DemoIk_SpawnDeadDb(this, globalCtx); - func_809839D0(this, globalCtx); +void DemoIk_Type1Action2(DemoIk* pthis, GlobalContext* globalCtx) { + DemoIk_UpdateSkelAnime(pthis); + DemoIk_Type1PlaySound(pthis); + DemoIk_SetMove(pthis, globalCtx); + DemoIk_BgCheck(pthis, globalCtx); + DemoIk_SpawnDeadDb(pthis, globalCtx); + func_809839D0(pthis, globalCtx); } void DemoIk_Type1PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - DemoIk* this = (DemoIk*)thisx; + DemoIk* pthis = (DemoIk*)thisx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_demo_ik_inArmer.c", 385); if (limbIndex == 1) { - switch (this->actor.params) { + switch (pthis->actor.params) { case 0: gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_demo_ik_inArmer.c", 390), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -286,28 +286,28 @@ void DemoIk_Type1PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi CLOSE_DISPS(gfxCtx, "../z_demo_ik_inArmer.c", 404); } -void DemoIk_Type1Draw(DemoIk* this, GlobalContext* globalCtx) { +void DemoIk_Type1Draw(DemoIk* pthis, GlobalContext* globalCtx) { s32 pad[2]; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - SkelAnime* skelAnime = &this->skelAnime; + SkelAnime* skelAnime = &pthis->skelAnime; OPEN_DISPS(gfxCtx, "../z_demo_ik_inArmer.c", 422); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); func_80093D18(gfxCtx); func_80093D84(gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, DemoIk_SetColors(gfxCtx, 245, 225, 155, 30, 30, 0)); gSPSegment(POLY_OPA_DISP++, 0x09, DemoIk_SetColors(gfxCtx, 255, 40, 0, 40, 0, 0)); gSPSegment(POLY_OPA_DISP++, 0x0A, DemoIk_SetColors(gfxCtx, 255, 255, 255, 20, 40, 30)); - SkelAnime_DrawOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, NULL, DemoIk_Type1PostLimbDraw, this); + SkelAnime_DrawOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, NULL, DemoIk_Type1PostLimbDraw, pthis); CLOSE_DISPS(gfxCtx, "../z_demo_ik_inArmer.c", 444); } -void DemoIk_Type2Init(DemoIk* this, GlobalContext* globalCtx) { +void DemoIk_Type2Init(DemoIk* pthis, GlobalContext* globalCtx) { s32 pad[2]; FlexSkeletonHeader* skeleton; AnimationHeader* animation; - switch (this->actor.params) { + switch (pthis->actor.params) { case 3: skeleton = &object_ik_Skel_01EB40; animation = &object_ik_Anim_01EB14; @@ -325,110 +325,110 @@ void DemoIk_Type2Init(DemoIk* this, GlobalContext* globalCtx) { animation = &object_ik_Anim_0008DC; } - SkelAnime_InitFlex(globalCtx, &this->skelAnime, skeleton, NULL, this->jointTable, this->morphTable, 2); - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); - this->actionMode = 3; - this->drawMode = 0; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, skeleton, NULL, pthis->jointTable, pthis->morphTable, 2); + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); + pthis->actionMode = 3; + pthis->drawMode = 0; } -void DemoIk_Type2PlaySoundOnFrame(DemoIk* this, f32 frame) { - if (Animation_OnFrame(&this->skelAnime, frame)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, +void DemoIk_Type2PlaySoundOnFrame(DemoIk* pthis, f32 frame) { + if (Animation_OnFrame(&pthis->skelAnime, frame)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } -void DemoIk_Type2PlaySound(DemoIk* this) { - switch (this->actor.params) { +void DemoIk_Type2PlaySound(DemoIk* pthis) { + switch (pthis->actor.params) { case 3: - DemoIk_Type2PlaySoundOnFrame(this, 33.0f); + DemoIk_Type2PlaySoundOnFrame(pthis, 33.0f); break; case 5: - DemoIk_Type2PlaySoundOnFrame(this, 44.0f); + DemoIk_Type2PlaySoundOnFrame(pthis, 44.0f); break; } } -void func_80983FDC(DemoIk* this) { - this->actionMode = 3; - this->drawMode = 0; +void func_80983FDC(DemoIk* pthis) { + pthis->actionMode = 3; + pthis->drawMode = 0; } -void func_80983FEC(DemoIk* this, GlobalContext* globalCtx) { - DemoIk_MoveToStartPos(this, globalCtx, 4); - this->actionMode = 4; - this->drawMode = 2; - this->skelAnime.curFrame = 0.0f; +void func_80983FEC(DemoIk* pthis, GlobalContext* globalCtx) { + DemoIk_MoveToStartPos(pthis, globalCtx, 4); + pthis->actionMode = 4; + pthis->drawMode = 2; + pthis->skelAnime.curFrame = 0.0f; } -void func_8098402C(DemoIk* this) { - this->actionMode = 5; - this->drawMode = 2; - this->skelAnime.curFrame = 0.0f; +void func_8098402C(DemoIk* pthis) { + pthis->actionMode = 5; + pthis->drawMode = 2; + pthis->skelAnime.curFrame = 0.0f; } -void func_80984048(DemoIk* this, GlobalContext* globalCtx) { +void func_80984048(DemoIk* pthis, GlobalContext* globalCtx) { CsCmdActorAction* cue = DemoIk_GetCue(globalCtx, 4); if (cue != NULL) { s32 nextCsAction = cue->action; - s32 csAction = this->csAction; + s32 csAction = pthis->csAction; if (nextCsAction != csAction) { switch (nextCsAction) { case 1: - func_80983FDC(this); + func_80983FDC(pthis); break; case 5: - func_80983FEC(this, globalCtx); + func_80983FEC(pthis, globalCtx); break; case 6: - func_8098402C(this); + func_8098402C(pthis); break; case 7: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; default: // "there is no such action" osSyncPrintf("Demo_Ik_inFace_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); } - this->csAction = nextCsAction; + pthis->csAction = nextCsAction; } } } -void DemoIk_Type2Action0(DemoIk* this, GlobalContext* globalCtx) { - func_80984048(this, globalCtx); +void DemoIk_Type2Action0(DemoIk* pthis, GlobalContext* globalCtx) { + func_80984048(pthis, globalCtx); } -void DemoIk_Type2Action1(DemoIk* this, GlobalContext* globalCtx) { - func_80984048(this, globalCtx); +void DemoIk_Type2Action1(DemoIk* pthis, GlobalContext* globalCtx) { + func_80984048(pthis, globalCtx); } -void DemoIk_Type2Action2(DemoIk* this, GlobalContext* globalCtx) { - DemoIk_UpdateSkelAnime(this); - DemoIk_Type2PlaySound(this); - func_80984048(this, globalCtx); +void DemoIk_Type2Action2(DemoIk* pthis, GlobalContext* globalCtx) { + DemoIk_UpdateSkelAnime(pthis); + DemoIk_Type2PlaySound(pthis); + func_80984048(pthis, globalCtx); } s32 DemoIk_Type2OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - DemoIk* this = (DemoIk*)thisx; + DemoIk* pthis = (DemoIk*)thisx; - if ((limbIndex == 1) && (DemoIk_GetCurFrame(this) < 30.0f)) { + if ((limbIndex == 1) && (DemoIk_GetCurFrame(pthis) < 30.0f)) { *dList = NULL; } return 0; } void DemoIk_Type2PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - DemoIk* this = (DemoIk*)thisx; + DemoIk* pthis = (DemoIk*)thisx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - f32 frame = DemoIk_GetCurFrame(this); + f32 frame = DemoIk_GetCurFrame(pthis); OPEN_DISPS(gfxCtx, "../z_demo_ik_inFace.c", 268); if (limbIndex == 1 && (frame >= 30.0f)) { - switch (this->actor.params) { + switch (pthis->actor.params) { case 3: gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_demo_ik_inFace.c", 274), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -454,20 +454,20 @@ void DemoIk_Type2PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi CLOSE_DISPS(gfxCtx, "../z_demo_ik_inFace.c", 300); } -void DemoIk_Type2Draw(DemoIk* this, GlobalContext* globalCtx) { +void DemoIk_Type2Draw(DemoIk* pthis, GlobalContext* globalCtx) { s32 pad[2]; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - SkelAnime* skelAnime = &this->skelAnime; + SkelAnime* skelAnime = &pthis->skelAnime; OPEN_DISPS(gfxCtx, "../z_demo_ik_inFace.c", 318); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); func_80093D18(gfxCtx); func_80093D84(gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, DemoIk_SetColors(gfxCtx, 245, 225, 155, 30, 30, 0)); gSPSegment(POLY_OPA_DISP++, 0x09, DemoIk_SetColors(gfxCtx, 255, 40, 0, 40, 0, 0)); gSPSegment(POLY_OPA_DISP++, 0x0A, DemoIk_SetColors(gfxCtx, 255, 255, 255, 20, 40, 30)); SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - DemoIk_Type2OverrideLimbDraw, DemoIk_Type2PostLimbDraw, this); + DemoIk_Type2OverrideLimbDraw, DemoIk_Type2PostLimbDraw, pthis); CLOSE_DISPS(gfxCtx, "../z_demo_ik_inFace.c", 341); } @@ -478,18 +478,18 @@ static DemoIkActionFunc sActionFuncs[] = { void DemoIk_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoIk* this = (DemoIk*)thisx; + DemoIk* pthis = (DemoIk*)thisx; - if (this->actionMode < 0 || this->actionMode >= ARRAY_COUNT(sActionFuncs) || - sActionFuncs[this->actionMode] == NULL) { + if (pthis->actionMode < 0 || pthis->actionMode >= ARRAY_COUNT(sActionFuncs) || + sActionFuncs[pthis->actionMode] == NULL) { // "The main mode is strange" osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - sActionFuncs[this->actionMode](this, globalCtx); + sActionFuncs[pthis->actionMode](pthis, globalCtx); } -void DemoIk_DrawNothing(DemoIk* this, GlobalContext* globalCtx) { +void DemoIk_DrawNothing(DemoIk* pthis, GlobalContext* globalCtx) { } static DemoIkDrawFunc sDrawFuncs[] = { @@ -500,17 +500,17 @@ static DemoIkDrawFunc sDrawFuncs[] = { void DemoIk_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoIk* this = (DemoIk*)thisx; + DemoIk* pthis = (DemoIk*)thisx; - if (this->drawMode < 0 || this->drawMode >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[this->drawMode] == NULL) { + if (pthis->drawMode < 0 || pthis->drawMode >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[pthis->drawMode] == NULL) { // "The draw mode is strange" osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } - sDrawFuncs[this->drawMode](this, globalCtx); + sDrawFuncs[pthis->drawMode](pthis, globalCtx); } -const ActorInit Demo_Ik_InitVars = { +ActorInit Demo_Ik_InitVars = { ACTOR_DEMO_IK, ACTORCAT_NPC, FLAGS, @@ -524,11 +524,11 @@ const ActorInit Demo_Ik_InitVars = { void DemoIk_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoIk* this = (DemoIk*)thisx; + DemoIk* pthis = (DemoIk*)thisx; - if (this->actor.params == 0 || this->actor.params == 1 || this->actor.params == 2) { - DemoIk_Type1Init(this, globalCtx); + if (pthis->actor.params == 0 || pthis->actor.params == 1 || pthis->actor.params == 2) { + DemoIk_Type1Init(pthis, globalCtx); } else { - DemoIk_Type2Init(this, globalCtx); + DemoIk_Type2Init(pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.h b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.h index 24fe5d094..8e742d885 100644 --- a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.h +++ b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.h @@ -6,8 +6,8 @@ struct DemoIk; -typedef void (*DemoIkActionFunc)(struct DemoIk* this, GlobalContext* globalCtx); -typedef void (*DemoIkDrawFunc)(struct DemoIk* this, GlobalContext* globalCtx); +typedef void (*DemoIkActionFunc)(struct DemoIk* pthis, GlobalContext* globalCtx); +typedef void (*DemoIkDrawFunc)(struct DemoIk* pthis, GlobalContext* globalCtx); typedef struct DemoIk { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c deleted file mode 100644 index 3dd792775..000000000 --- a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c +++ /dev/null @@ -1,1226 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_IM_Z_DEMO_IM_C -#include "actor_common.h" -/* - * File: z_demo_im.c - * Overlay: Demo_Im - * Description: Impa - */ - -#include "z_demo_im.h" -#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "scenes/indoors/nakaniwa/nakaniwa_scene.h" -#include "objects/object_im/object_im.h" -#include "vt.h" -#include "def/code_800F7260.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4) - -void DemoIm_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoIm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoIm_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoIm_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809856F8(DemoIm* this, GlobalContext* globalCtx); -void func_80985718(DemoIm* this, GlobalContext* globalCtx); -void func_80985738(DemoIm* this, GlobalContext* globalCtx); -void func_80985770(DemoIm* this, GlobalContext* globalCtx); -void func_809857B0(DemoIm* this, GlobalContext* globalCtx); -void func_809857F0(DemoIm* this, GlobalContext* globalCtx); -void func_80985830(DemoIm* this, GlobalContext* globalCtx); -void func_80985C10(DemoIm* this, GlobalContext* globalCtx); -void func_80985C40(DemoIm* this, GlobalContext* globalCtx); -void func_80985C94(DemoIm* this, GlobalContext* globalCtx); -void DemoIm_DrawTranslucent(DemoIm* this, GlobalContext* globalCtx); -void func_809863BC(DemoIm* this, GlobalContext* globalCtx); -void func_809863DC(DemoIm* this, GlobalContext* globalCtx); -void func_80986430(DemoIm* this, GlobalContext* globalCtx); -void func_80986494(DemoIm* this, GlobalContext* globalCtx); -void func_809864D4(DemoIm* this, GlobalContext* globalCtx); -void func_809868E8(DemoIm* this, GlobalContext* globalCtx); -void func_80986908(DemoIm* this, GlobalContext* globalCtx); -void func_80986948(DemoIm* this, GlobalContext* globalCtx); -void func_80986D40(DemoIm* this, GlobalContext* globalCtx); -void func_80986DC8(DemoIm* this, GlobalContext* globalCtx); -void func_80986E20(DemoIm* this, GlobalContext* globalCtx); -void func_80986E40(DemoIm* this, GlobalContext* globalCtx); -void func_80986EAC(DemoIm* this, GlobalContext* globalCtx); -void func_80986F08(DemoIm* this, GlobalContext* globalCtx); -void func_80986F28(DemoIm* this, GlobalContext* globalCtx); -void func_80986F88(DemoIm* this, GlobalContext* globalCtx); -void func_80986FA8(DemoIm* this, GlobalContext* globalCtx); -void func_80987288(DemoIm* this, GlobalContext* globalCtx); -void func_809872A8(DemoIm* this, GlobalContext* globalCtx); -void func_809872F0(DemoIm* this, GlobalContext* globalCtx); -void func_80987330(DemoIm* this, GlobalContext* globalCtx); -void DemoIm_DrawNothing(DemoIm* this, GlobalContext* globalCtx); -void DemoIm_DrawSolid(DemoIm* this, GlobalContext* globalCtx); - -static void* sEyeTextures[] = { - gImpaEyeOpenTex, - gImpaEyeHalfTex, - gImpaEyeClosedTex, -}; - -static u32 D_8098783C = 0; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 }, - { 25, 80, 0, { 0, 0, 0 } }, -}; - -#include "z_demo_im_cutscene_data.c" EARLY - -static DemoImActionFunc sActionFuncs[] = { - func_809856F8, func_80985718, func_80985738, func_80985770, func_809857B0, func_809857F0, func_80985830, - func_80985C10, func_80985C40, func_80985C94, func_809863BC, func_809863DC, func_80986430, func_80986494, - func_809864D4, func_809868E8, func_80986908, func_80986948, func_80986D40, func_80986DC8, func_80986E20, - func_80986E40, func_80986EAC, func_80986F08, func_80986F28, func_80986F88, func_80986FA8, func_80987288, - func_809872A8, func_809872F0, func_80987330, -}; - -static Vec3f D_809887D8 = { 0.0f, 10.0f, 0.0f }; - -static DemoImDrawFunc sDrawFuncs[] = { - DemoIm_DrawNothing, - DemoIm_DrawSolid, - DemoIm_DrawTranslucent, -}; - -const ActorInit Demo_Im_InitVars = { - ACTOR_DEMO_IM, - ACTORCAT_NPC, - FLAGS, - OBJECT_IM, - sizeof(DemoIm), - (ActorFunc)DemoIm_Init, - (ActorFunc)DemoIm_Destroy, - (ActorFunc)DemoIm_Update, - (ActorFunc)DemoIm_Draw, -}; - -void func_80984BE0(DemoIm* this) { - s32 pad[3]; - s16* blinkTimer = &this->blinkTimer; - s16* eyeIndex = &this->eyeIndex; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - - *eyeIndex = *blinkTimer; - if (*eyeIndex >= 3) { - *eyeIndex = 0; - } -} - -void func_80984C68(DemoIm* this) { - this->action = 7; - this->drawConfig = 0; - this->alpha = 0; - this->unk_270 = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_268 = 0.0f; -} - -void func_80984C8C(DemoIm* this, GlobalContext* globalCtx) { - u32* something = &D_8098783C; - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - if (*something != 0) { - if (this->actor.params == 2) { - func_80984C68(this); - } - *something = 0; - } - } else { - if (*something == 0) { - *something = 1; - } - } -} - -void DemoIm_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - DemoIm* this = (DemoIm*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); -} - -void DemoIm_DestroyCollider(Actor* thisx, GlobalContext* globalCtx) { - DemoIm* this = (DemoIm*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void DemoIm_UpdateCollider(DemoIm* this, GlobalContext* globalCtx) { - s32 pad[5]; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void func_80984DB8(DemoIm* this) { - s32 pad[2]; - Vec3s* vec1 = &this->unk_2D4.unk_08; - Vec3s* vec2 = &this->unk_2D4.unk_0E; - - Math_SmoothStepToS(&vec1->x, 0, 20, 6200, 100); - Math_SmoothStepToS(&vec1->y, 0, 20, 6200, 100); - - Math_SmoothStepToS(&vec2->x, 0, 20, 6200, 100); - Math_SmoothStepToS(&vec2->y, 0, 20, 6200, 100); -} - -void func_80984E58(DemoIm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff; - s16 phi_a3; - - this->unk_2D4.unk_18 = player->actor.world.pos; - this->unk_2D4.unk_14 = kREG(16) + 4.0f; - - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - phi_a3 = (ABS(yawDiff) < 0x18E3) ? 2 : 1; - func_80034A14(&this->actor, &this->unk_2D4, kREG(17) + 0xC, phi_a3); -} - -void func_80984F10(DemoIm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_2D4.unk_18 = player->actor.world.pos; - this->unk_2D4.unk_14 = kREG(16) + 12.0f; - - func_80034A14(&this->actor, &this->unk_2D4, kREG(17) + 0xC, 2); -} - -void func_80984F94(DemoIm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_2D4.unk_18 = player->actor.world.pos; - this->unk_2D4.unk_14 = kREG(16) + 4.0f; - func_80034A14(&this->actor, &this->unk_2D4, kREG(17) + 0xC, 4); -} - -void DemoIm_UpdateBgCheckInfo(DemoIm* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -s32 DemoIm_UpdateSkelAnime(DemoIm* this) { - return SkelAnime_Update(&this->skelAnime); -} - -s32 DemoIm_IsCsStateIdle(GlobalContext* globalCtx) { - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - return true; - } else { - return false; - } -} - -CsCmdActorAction* DemoIm_GetNpcAction(GlobalContext* globalCtx, s32 actionIdx) { - s32 pad[2]; - CsCmdActorAction* ret = NULL; - - if (!DemoIm_IsCsStateIdle(globalCtx)) { - ret = globalCtx->csCtx.npcActions[actionIdx]; - } - return ret; -} - -s32 func_809850E8(DemoIm* this, GlobalContext* globalCtx, u16 action, s32 actionIdx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); - - if (npcAction != NULL) { - if (npcAction->action == action) { - return true; - } - } - return false; -} - -s32 func_80985134(DemoIm* this, GlobalContext* globalCtx, u16 action, s32 actionIdx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); - - if (npcAction != NULL) { - if (npcAction->action != action) { - return true; - } - } - return false; -} - -void func_80985180(DemoIm* this, GlobalContext* globalCtx, s32 actionIdx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -void func_80985200(DemoIm* this, GlobalContext* globalCtx, s32 actionIdx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -void DemoIm_ChangeAnim(DemoIm* this, AnimationHeader* animHeaderSeg, u8 animMode, f32 transitionRate, - s32 playBackwards) { - f32 frameCount = Animation_GetLastFrame(animHeaderSeg); - f32 playbackSpeed; - f32 startFrame; - f32 endFrame; - - if (!playBackwards) { - startFrame = 0.0f; - endFrame = frameCount; - playbackSpeed = 1.0f; - } else { - endFrame = 0.0f; - startFrame = frameCount; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animHeaderSeg, playbackSpeed, startFrame, endFrame, animMode, transitionRate); -} - -void func_80985310(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_ChangeAnim(this, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->actor.shape.yOffset = -10000.0f; -} - -void func_80985358(DemoIm* this, GlobalContext* globalCtx) { - f32 posX = this->actor.world.pos.x; - f32 posY = this->actor.world.pos.y; - f32 posZ = this->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, - WARP_SAGES); -} - -void func_809853B4(DemoIm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 playerX = player->actor.world.pos.x; - f32 playerY = player->actor.world.pos.y + 80.0f; - f32 playerZ = player->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, playerX, playerY, playerZ, 0, - 0, 0, 0xD); - Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); -} - -void func_80985430(DemoIm* this, GlobalContext* globalCtx) { - this->actor.shape.yOffset += 250.0f / 3.0f; -} - -void func_8098544C(DemoIm* this, GlobalContext* globalCtx) { - s32 pad[2]; - - if ((gSaveContext.chamberCutsceneNum == 4) && (gSaveContext.sceneSetupIndex < 4)) { - Player* player = GET_PLAYER(globalCtx); - - this->action = 1; - globalCtx->csCtx.segment = D_8098786C; - gSaveContext.cutsceneTrigger = 2; - Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); - player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - } -} - -void func_809854DC(DemoIm* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[5] != NULL) && - (globalCtx->csCtx.npcActions[5]->action == 2)) { - Animation_Change(&this->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->action = 2; - this->drawConfig = 1; - func_80985358(this, globalCtx); - } -} - -void func_8098557C(DemoIm* this) { - if (this->actor.shape.yOffset >= 0.0f) { - this->action = 3; - this->actor.shape.yOffset = 0.0f; - } -} - -void func_809855A8(DemoIm* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[5] != NULL) && - (globalCtx->csCtx.npcActions[5]->action == 3)) { - Animation_Change(&this->skelAnime, &gImpaRaiseArmsAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaRaiseArmsAnim), - ANIMMODE_ONCE, 4.0f); - this->action = 4; - } -} - -void func_80985640(DemoIm* this, s32 arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gImpaPresentShadowMedallionAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gImpaPresentShadowMedallionAnim), ANIMMODE_LOOP, 0.0f); - this->action = 5; - } -} - -void func_809856AC(DemoIm* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[6] != NULL) && - (globalCtx->csCtx.npcActions[6]->action == 2)) { - this->action = 6; - func_809853B4(this, globalCtx); - } -} - -void func_809856F8(DemoIm* this, GlobalContext* globalCtx) { - func_8098544C(this, globalCtx); -} - -void func_80985718(DemoIm* this, GlobalContext* globalCtx) { - func_809854DC(this, globalCtx); -} - -void func_80985738(DemoIm* this, GlobalContext* globalCtx) { - func_80985430(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_8098557C(this); -} - -void func_80985770(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_809855A8(this, globalCtx); -} - -void func_809857B0(DemoIm* this, GlobalContext* globalCtx) { - s32 sp1C; - - DemoIm_UpdateBgCheckInfo(this, globalCtx); - sp1C = DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80985640(this, sp1C); -} - -void func_809857F0(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_809856AC(this, globalCtx); -} - -void func_80985830(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); -} - -void func_80985860(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_ChangeAnim(this, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = 7; - this->actor.shape.shadowAlpha = 0; -} - -void func_809858A8(void) { - func_800788CC(NA_SE_SY_WHITE_OUT_T); -} - -void DemoIm_SpawnLightBall(DemoIm* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - (kREG(17) + 24.0f) + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 6); -} - -void func_80985948(DemoIm* this, GlobalContext* globalCtx) { - if (func_809850E8(this, globalCtx, 4, 5)) { - Animation_Change(&this->skelAnime, &gImpaPrepareSealGanonAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gImpaPrepareSealGanonAnim), ANIMMODE_ONCE, 0.0f); - this->action = 8; - this->drawConfig = 2; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_268 = 0.0f; - func_809858A8(); - } -} - -void func_809859E0(DemoIm* this, GlobalContext* globalCtx) { - f32* unk_268 = &this->unk_268; - s32 alpha = 255; - - if (func_809850E8(this, globalCtx, 4, 5)) { - *unk_268 += 1.0f; - if (*unk_268 >= kREG(5) + 10.0f) { - this->action = 9; - this->drawConfig = 1; - *unk_268 = kREG(5) + 10.0f; - this->alpha = this->actor.shape.shadowAlpha = alpha; - return; - } - } else { - *unk_268 -= 1.0f; - if (*unk_268 <= 0.0f) { - this->action = 7; - this->drawConfig = 0; - *unk_268 = 0.0f; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - return; - } - } - this->actor.shape.shadowAlpha = this->alpha = (*unk_268 / (kREG(5) + 10.0f)) * 255.0f; -} - -void func_80985B34(DemoIm* this, GlobalContext* globalCtx) { - if (func_80985134(this, globalCtx, 4, 5)) { - Animation_Change(&this->skelAnime, &gImpaSealGanonAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaSealGanonAnim), - ANIMMODE_ONCE, -8.0f); - this->action = 8; - this->drawConfig = 2; - this->unk_268 = kREG(5) + 10.0f; - this->alpha = 255; - if (this->unk_270 == 0) { - DemoIm_SpawnLightBall(this, globalCtx); - this->unk_270 = 1; - } - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80985C10(DemoIm* this, GlobalContext* globalCtx) { - func_80985948(this, globalCtx); - func_80984C8C(this, globalCtx); -} - -void func_80985C40(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_809859E0(this, globalCtx); - func_80984C8C(this, globalCtx); -} - -void func_80985C94(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80985B34(this, globalCtx); - func_80984C8C(this, globalCtx); -} - -void DemoIm_DrawTranslucent(DemoIm* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeIndex = this->eyeIndex; - void* eyeTex = sEyeTextures[eyeIndex]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_im_inKenjyanomaDemo02.c", 281); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - NULL, NULL, NULL, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_im_inKenjyanomaDemo02.c", 308); -} - -void func_80985E60(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_ChangeAnim(this, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = 10; - this->unk_280 = 1; -} - -void func_80985EAC(DemoIm* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.frames >= 80) && (globalCtx->csCtx.frames < 243)) { - func_80984F10(this, globalCtx); - } else { - func_80984DB8(this); - } -} - -void func_80985EF4(DemoIm* this) { - if (!Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&gImpaWhistlingAnim) - 1.0f)) { - DemoIm_UpdateSkelAnime(this); - } -} - -void func_80985F54(DemoIm* this) { - this->action = 10; - this->drawConfig = 0; -} - -void func_80985F64(DemoIm* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), - ANIMMODE_LOOP, 0.0f); - func_80985180(this, globalCtx, 5); - this->action = 11; - this->drawConfig = 1; -} - -void func_80985FE8(DemoIm* this, s32 arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gImpaWhistlingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaWhistlingAnim), - ANIMMODE_LOOP, -8.0f); - } -} - -void func_8098604C(DemoIm* this) { - f32 frameCount = Animation_GetLastFrame(&gImpaStartWhistlingAnim); - - Animation_Change(&this->skelAnime, &gImpaStartWhistlingAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -8.0f); - this->action = 12; - this->drawConfig = 1; - this->unk_2D0 = 1; -} - -void func_809860C8(DemoIm* this) { - this->action = 13; - this->drawConfig = 1; -} - -void func_809860DC(DemoIm* this, s32 arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), - ANIMMODE_LOOP, -8.0f); - this->unk_2D0 = 0; - } -} - -void func_80986148(DemoIm* this) { - Animation_Change(&this->skelAnime, &gImpaStartWhistlingAnim, -1.0f, - Animation_GetLastFrame(&gImpaStartWhistlingAnim), 0.0f, ANIMMODE_ONCE, -8.0f); - this->action = 14; - this->drawConfig = 1; -} - -void func_809861C4(DemoIm* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); - - if (npcAction != NULL) { - u32 action = npcAction->action; - u32 unk_274 = this->unk_274; - - if (action != unk_274) { - switch (action) { - case 9: - func_80986148(this); - break; - case 7: - Animation_Change(&this->skelAnime, &gImpaWhistlingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gImpaWhistlingAnim), ANIMMODE_LOOP, -8.0f); - this->action = 12; - break; - default: - osSyncPrintf("Demo_Im_Ocarina_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_274 = action; - } - } -} - -void func_8098629C(DemoIm* this, GlobalContext* globalCtx) { - if (DemoIm_IsCsStateIdle(globalCtx)) { - this->action = 21; - this->drawConfig = 1; - this->unk_280 = 1; - } -} - -void func_809862E0(DemoIm* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); - - if (npcAction != NULL) { - u32 action = npcAction->action; - u32 unk_274 = this->unk_274; - - if (action != unk_274) { - switch (action) { - case 1: - func_80985F54(this); - break; - case 2: - func_80985F64(this, globalCtx); - break; - case 7: - func_8098604C(this); - break; - case 8: - func_809860C8(this); - break; - case 9: - func_80986148(this); - break; - default: - osSyncPrintf("Demo_Im_Ocarina_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_274 = action; - } - } -} - -void func_809863BC(DemoIm* this, GlobalContext* globalCtx) { - func_809862E0(this, globalCtx); -} - -void func_809863DC(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80985EAC(this, globalCtx); - func_80984BE0(this); - func_809862E0(this, globalCtx); -} - -void func_80986430(DemoIm* this, GlobalContext* globalCtx) { - s32 sp24; - - DemoIm_UpdateBgCheckInfo(this, globalCtx); - sp24 = DemoIm_UpdateSkelAnime(this); - func_80985EAC(this, globalCtx); - func_80984BE0(this); - func_80985FE8(this, sp24); - func_809862E0(this, globalCtx); -} - -void func_80986494(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - func_80985EF4(this); - func_80984BE0(this); - func_809861C4(this, globalCtx); -} - -void func_809864D4(DemoIm* this, GlobalContext* globalCtx) { - s32 sp24; - - DemoIm_UpdateBgCheckInfo(this, globalCtx); - sp24 = DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_809860DC(this, sp24); - func_8098629C(this, globalCtx); -} - -void func_8098652C(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_ChangeAnim(this, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = 15; -} - -void func_80986570(DemoIm* this, GlobalContext* globalCtx) { - if (Animation_OnFrame(&this->skelAnime, 7.0f) && (this->actor.bgCheckFlags & 1)) { - u32 sfxId = SFX_FLAG; - - sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - Audio_PlaySoundGeneral(sfxId, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -void func_809865F8(DemoIm* this, GlobalContext* globalCtx, s32 arg2) { - s32 pad[2]; - - if (arg2 != 0) { - f32* unk_278 = &this->unk_278; - - if (*unk_278 >= 0.0f) { - if (this->unk_27C == 0) { - Vec3f* thisPos = &this->actor.world.pos; - s16 shapeRotY = this->actor.shape.rot.y; - f32 spawnPosX = thisPos->x + (Math_SinS(shapeRotY) * 30.0f); - f32 spawnPosY = thisPos->y; - f32 spawnPosZ = thisPos->z + (Math_CosS(shapeRotY) * 30.0f); - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, spawnPosX, spawnPosY, spawnPosZ, 0xFA0, - this->actor.shape.rot.y, 0, ARROW_CS_NUT); - this->unk_27C = 1; - } - } else { - *unk_278 += 1.0f; - } - } -} - -void func_80986700(DemoIm* this) { - this->action = 15; - this->drawConfig = 0; -} - -void func_80986710(DemoIm* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), - ANIMMODE_LOOP, 0.0f); - func_80985180(this, globalCtx, 5); - this->action = 16; - this->drawConfig = 1; -} - -void func_80986794(DemoIm* this) { - Animation_Change(&this->skelAnime, &gImpaThrowDekuNutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gImpaThrowDekuNutAnim), ANIMMODE_ONCE, -8.0f); - this->action = 17; - this->drawConfig = 1; -} - -void func_8098680C(DemoIm* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); - - if (npcAction != NULL) { - u32 action = npcAction->action; - u32 unk_274 = this->unk_274; - - if (action != unk_274) { - switch (action) { - case 1: - func_80986700(this); - break; - case 2: - func_80986710(this, globalCtx); - break; - case 10: - func_80986794(this); - break; - case 11: - Actor_Kill(&this->actor); - break; - default: - osSyncPrintf("Demo_Im_Spot00_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_274 = action; - } - } -} - -void func_809868E8(DemoIm* this, GlobalContext* globalCtx) { - func_8098680C(this, globalCtx); -} - -void func_80986908(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_8098680C(this, globalCtx); -} - -void func_80986948(DemoIm* this, GlobalContext* globalCtx) { - s32 sp24; - - DemoIm_UpdateBgCheckInfo(this, globalCtx); - sp24 = DemoIm_UpdateSkelAnime(this); - func_80986570(this, globalCtx); - func_80984BE0(this); - func_809865F8(this, globalCtx, sp24); - func_8098680C(this, globalCtx); -} - -void func_809869B0(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_ChangeAnim(this, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = 18; - this->actor.shape.shadowAlpha = 0; -} - -s32 func_809869F8(DemoIm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 playerPosX = player->actor.world.pos.x; - f32 thisPosX = this->actor.world.pos.x; - - if ((thisPosX - (kREG(16) + 30.0f) > playerPosX) && !(this->actor.flags & ACTOR_FLAG_UNCULLED)) { - return true; - } else { - return false; - } -} - -s32 func_80986A5C(DemoIm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 playerPosX = player->actor.world.pos.x; - f32 thisPosX = this->actor.world.pos.x; - - if ((thisPosX - (kREG(17) + 130.0f) < playerPosX) && (!Gameplay_InCsMode(globalCtx))) { - return true; - } else { - return false; - } -} - -s32 func_80986AD0(DemoIm* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - if (!Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actor.textId = 0x708E; - func_8002F2F4(&this->actor, globalCtx); - } else { - return true; - } - return false; -} - -void func_80986B2C(GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - Player* player = GET_PLAYER(globalCtx); - - globalCtx->nextEntranceIndex = 0xCD; - globalCtx->fadeTransition = 38; - globalCtx->sceneLoadFlag = 0x14; - func_8002DF54(globalCtx, &player->actor, 8); - } -} - -void func_80986BA0(DemoIm* this, GlobalContext* globalCtx) { - if (func_809869F8(this, globalCtx)) { - this->action = 21; - this->drawConfig = 1; - this->unk_280 = 1; - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80986BE4(DemoIm* this, s32 arg1) { - if (arg1 != 0) { - this->action = 22; - } -} - -void func_80986BF8(DemoIm* this, GlobalContext* globalCtx) { - if (gSaveContext.eventChkInf[4] & 1) { - this->action = 24; - this->drawConfig = 1; - this->unk_280 = 1; - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80986C30(DemoIm* this, GlobalContext* globalCtx) { - if (func_80986A5C(this, globalCtx)) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gZeldasCourtyardLullabyCs); - gSaveContext.cutsceneTrigger = 1; - gSaveContext.eventChkInf[5] |= 0x200; - Item_Give(globalCtx, ITEM_SONG_LULLABY); - func_80985F54(this); - } -} - -void func_80986CC8(DemoIm* this) { - if (gSaveContext.eventChkInf[4] & 1) { - this->action = 26; - this->drawConfig = 1; - this->unk_280 = 1; - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80986CFC(DemoIm* this, GlobalContext* globalCtx) { - if (func_80986A5C(this, globalCtx)) { - gSaveContext.eventChkInf[4] |= 0x1000; - this->action = 19; - } -} - -void func_80986D40(DemoIm* this, GlobalContext* globalCtx) { - if (gSaveContext.sceneSetupIndex == 6) { - this->action = 19; - this->drawConfig = 1; - } else if (gSaveContext.eventChkInf[8] & 1) { - Actor_Kill(&this->actor); - } else if (!(gSaveContext.eventChkInf[5] & 0x200)) { - this->action = 23; - } else { - this->action = 20; - } -} - -void func_80986DC8(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80984E58(this, globalCtx); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); -} - -void func_80986E20(DemoIm* this, GlobalContext* globalCtx) { - func_80986BA0(this, globalCtx); -} - -void func_80986E40(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80984E58(this, globalCtx); - DemoIm_UpdateCollider(this, globalCtx); - func_80986BE4(this, func_80986AD0(this, globalCtx)); -} - -void func_80986EAC(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80984F94(this, globalCtx); - DemoIm_UpdateCollider(this, globalCtx); - func_80986B2C(globalCtx); -} - -void func_80986F08(DemoIm* this, GlobalContext* globalCtx) { - func_80986BF8(this, globalCtx); -} - -void func_80986F28(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80984E58(this, globalCtx); - DemoIm_UpdateCollider(this, globalCtx); - func_80986C30(this, globalCtx); -} - -void func_80986F88(DemoIm* this, GlobalContext* globalCtx) { - func_80986CC8(this); -} - -void func_80986FA8(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80984E58(this, globalCtx); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - DemoIm_UpdateCollider(this, globalCtx); - func_80986CFC(this, globalCtx); -} - -void func_80987018(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_ChangeAnim(this, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = 27; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80987064(DemoIm* this) { - f32* unk_268 = &this->unk_268; - f32 temp; - s32 alpha = 255; - - *unk_268 += 1.0f; - temp = kREG(17) + 10.0f; - - if (*unk_268 >= temp) { - this->actor.shape.shadowAlpha = this->alpha = alpha; - } else { - this->actor.shape.shadowAlpha = this->alpha = (*unk_268 / temp) * 255.0f; - } -} - -void func_809870F0(DemoIm* this, GlobalContext* globalCtx) { - func_80985200(this, globalCtx, 5); - this->action = 28; - this->drawConfig = 2; -} - -void func_80987128(DemoIm* this) { - if (this->unk_268 >= kREG(17) + 10.0f) { - this->action = 29; - this->drawConfig = 1; - } -} - -void func_80987174(DemoIm* this) { - DemoIm_ChangeAnim(this, &object_im_Anim_0101C8, ANIMMODE_ONCE, -8.0f, false); - this->action = 30; -} - -void func_809871B4(DemoIm* this, s32 arg1) { - if (arg1 != 0) { - DemoIm_ChangeAnim(this, &object_im_Anim_00FB10, ANIMMODE_LOOP, 0.0f, false); - } -} - -void func_809871E8(DemoIm* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); - - if (npcAction != NULL) { - u32 action = npcAction->action; - u32 unk_274 = this->unk_274; - - if (action != unk_274) { - switch (action) { - case 12: - func_809870F0(this, globalCtx); - break; - case 13: - func_80987174(this); - break; - default: - osSyncPrintf("Demo_Im_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_274 = action; - } - } -} - -void func_80987288(DemoIm* this, GlobalContext* globalCtx) { - func_809871E8(this, globalCtx); -} - -void func_809872A8(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_80987064(this); - func_80987128(this); -} - -void func_809872F0(DemoIm* this, GlobalContext* globalCtx) { - DemoIm_UpdateBgCheckInfo(this, globalCtx); - DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_809871E8(this, globalCtx); -} - -void func_80987330(DemoIm* this, GlobalContext* globalCtx) { - s32 sp1C; - - DemoIm_UpdateBgCheckInfo(this, globalCtx); - sp1C = DemoIm_UpdateSkelAnime(this); - func_80984BE0(this); - func_809871B4(this, sp1C); -} - -void DemoIm_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoIm* this = (DemoIm*)thisx; - - if ((this->action < 0) || (this->action >= 31) || (sActionFuncs[this->action] == NULL)) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sActionFuncs[this->action](this, globalCtx); -} - -void DemoIm_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoIm* this = (DemoIm*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - DemoIm_InitCollider(thisx, globalCtx); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gImpaSkel, NULL, this->jointTable, this->morphTable, 17); - thisx->flags &= ~ACTOR_FLAG_0; - - switch (this->actor.params) { - case 2: - func_80985860(this, globalCtx); - break; - case 3: - func_80985E60(this, globalCtx); - break; - case 4: - func_8098652C(this, globalCtx); - break; - case 5: - func_809869B0(this, globalCtx); - break; - case 6: - func_80987018(this, globalCtx); - break; - default: - func_80985310(this, globalCtx); - } -} - -void DemoIm_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoIm_DestroyCollider(thisx, globalCtx); -} - -s32 DemoIm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - DemoIm* this = (DemoIm*)thisx; - s32* unk_2D0 = &this->unk_2D0; - - if (this->unk_280 != 0) { - Vec3s* unk_2D4_unk_0E = &this->unk_2D4.unk_0E; - Vec3s* unk_2D4_unk_08 = &this->unk_2D4.unk_08; - - switch (limbIndex) { - case IMPA_LIMB_CHEST: - rot->x += unk_2D4_unk_0E->y; - rot->y -= unk_2D4_unk_0E->x; - break; - case IMPA_LIMB_HEAD: - rot->x += unk_2D4_unk_08->y; - rot->z += unk_2D4_unk_08->x; - break; - } - } - - if ((*unk_2D0 != 0) && (limbIndex == IMPA_LIMB_RIGHT_HAND)) { - *dList = gImpaHandPointingDL; - } - - return false; -} - -void DemoIm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - DemoIm* this = (DemoIm*)thisx; - - if (limbIndex == IMPA_LIMB_HEAD) { - Vec3f sp28 = D_809887D8; - Vec3f dest; - - Matrix_MultVec3f(&sp28, &dest); - this->actor.focus.pos.x = dest.x; - this->actor.focus.pos.y = dest.y; - this->actor.focus.pos.z = dest.z; - this->actor.focus.rot.x = this->actor.world.rot.x; - this->actor.focus.rot.y = this->actor.world.rot.y; - this->actor.focus.rot.z = this->actor.world.rot.z; - } -} - -void DemoIm_DrawNothing(DemoIm* this, GlobalContext* globalCtx) { -} - -void DemoIm_DrawSolid(DemoIm* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeIndex = this->eyeIndex; - void* eyeTexture = sEyeTextures[eyeIndex]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_im.c", 904); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - DemoIm_OverrideLimbDraw, DemoIm_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_im.c", 925); -} - -void DemoIm_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoIm* this = (DemoIm*)thisx; - - if ((this->drawConfig < 0) || (this->drawConfig >= 3) || (sDrawFuncs[this->drawConfig] == NULL)) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im.cpp b/src/overlays/actors/ovl_Demo_Im/z_demo_im.cpp new file mode 100644 index 000000000..85c04cc9e --- /dev/null +++ b/src/overlays/actors/ovl_Demo_Im/z_demo_im.cpp @@ -0,0 +1,1226 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_IM_Z_DEMO_IM_C +#include "actor_common.h" +/* + * File: z_demo_im.c + * Overlay: Demo_Im + * Description: Impa + */ + +#include "z_demo_im.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "scenes/indoors/nakaniwa/nakaniwa_scene.h" +#include "objects/object_im/object_im.h" +#include "vt.h" +#include "def/code_800F7260.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4) + +void DemoIm_Init(Actor* thisx, GlobalContext* globalCtx); +void DemoIm_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DemoIm_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoIm_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809856F8(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985718(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985738(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985770(DemoIm* pthis, GlobalContext* globalCtx); +void func_809857B0(DemoIm* pthis, GlobalContext* globalCtx); +void func_809857F0(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985830(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985C10(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985C40(DemoIm* pthis, GlobalContext* globalCtx); +void func_80985C94(DemoIm* pthis, GlobalContext* globalCtx); +void DemoIm_DrawTranslucent(DemoIm* pthis, GlobalContext* globalCtx); +void func_809863BC(DemoIm* pthis, GlobalContext* globalCtx); +void func_809863DC(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986430(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986494(DemoIm* pthis, GlobalContext* globalCtx); +void func_809864D4(DemoIm* pthis, GlobalContext* globalCtx); +void func_809868E8(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986908(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986948(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986D40(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986DC8(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986E20(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986E40(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986EAC(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986F08(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986F28(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986F88(DemoIm* pthis, GlobalContext* globalCtx); +void func_80986FA8(DemoIm* pthis, GlobalContext* globalCtx); +void func_80987288(DemoIm* pthis, GlobalContext* globalCtx); +void func_809872A8(DemoIm* pthis, GlobalContext* globalCtx); +void func_809872F0(DemoIm* pthis, GlobalContext* globalCtx); +void func_80987330(DemoIm* pthis, GlobalContext* globalCtx); +void DemoIm_DrawNothing(DemoIm* pthis, GlobalContext* globalCtx); +void DemoIm_DrawSolid(DemoIm* pthis, GlobalContext* globalCtx); + +static void* sEyeTextures[] = { + gImpaEyeOpenTex, + gImpaEyeHalfTex, + gImpaEyeClosedTex, +}; + +static u32 D_8098783C = 0; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 }, + { 25, 80, 0, { 0, 0, 0 } }, +}; + +#include "z_demo_im_cutscene_data.cpp" EARLY + +static DemoImActionFunc sActionFuncs[] = { + func_809856F8, func_80985718, func_80985738, func_80985770, func_809857B0, func_809857F0, func_80985830, + func_80985C10, func_80985C40, func_80985C94, func_809863BC, func_809863DC, func_80986430, func_80986494, + func_809864D4, func_809868E8, func_80986908, func_80986948, func_80986D40, func_80986DC8, func_80986E20, + func_80986E40, func_80986EAC, func_80986F08, func_80986F28, func_80986F88, func_80986FA8, func_80987288, + func_809872A8, func_809872F0, func_80987330, +}; + +static Vec3f D_809887D8 = { 0.0f, 10.0f, 0.0f }; + +static DemoImDrawFunc sDrawFuncs[] = { + DemoIm_DrawNothing, + DemoIm_DrawSolid, + DemoIm_DrawTranslucent, +}; + +ActorInit Demo_Im_InitVars = { + ACTOR_DEMO_IM, + ACTORCAT_NPC, + FLAGS, + OBJECT_IM, + sizeof(DemoIm), + (ActorFunc)DemoIm_Init, + (ActorFunc)DemoIm_Destroy, + (ActorFunc)DemoIm_Update, + (ActorFunc)DemoIm_Draw, +}; + +void func_80984BE0(DemoIm* pthis) { + s32 pad[3]; + s16* blinkTimer = &pthis->blinkTimer; + s16* eyeIndex = &pthis->eyeIndex; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + + *eyeIndex = *blinkTimer; + if (*eyeIndex >= 3) { + *eyeIndex = 0; + } +} + +void func_80984C68(DemoIm* pthis) { + pthis->action = 7; + pthis->drawConfig = 0; + pthis->alpha = 0; + pthis->unk_270 = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_268 = 0.0f; +} + +void func_80984C8C(DemoIm* pthis, GlobalContext* globalCtx) { + u32* something = &D_8098783C; + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + if (*something != 0) { + if (pthis->actor.params == 2) { + func_80984C68(pthis); + } + *something = 0; + } + } else { + if (*something == 0) { + *something = 1; + } + } +} + +void DemoIm_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + DemoIm* pthis = (DemoIm*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); +} + +void DemoIm_DestroyCollider(Actor* thisx, GlobalContext* globalCtx) { + DemoIm* pthis = (DemoIm*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void DemoIm_UpdateCollider(DemoIm* pthis, GlobalContext* globalCtx) { + s32 pad[5]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void func_80984DB8(DemoIm* pthis) { + s32 pad[2]; + Vec3s* vec1 = &pthis->unk_2D4.unk_08; + Vec3s* vec2 = &pthis->unk_2D4.unk_0E; + + Math_SmoothStepToS(&vec1->x, 0, 20, 6200, 100); + Math_SmoothStepToS(&vec1->y, 0, 20, 6200, 100); + + Math_SmoothStepToS(&vec2->x, 0, 20, 6200, 100); + Math_SmoothStepToS(&vec2->y, 0, 20, 6200, 100); +} + +void func_80984E58(DemoIm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff; + s16 phi_a3; + + pthis->unk_2D4.unk_18 = player->actor.world.pos; + pthis->unk_2D4.unk_14 = kREG(16) + 4.0f; + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + phi_a3 = (ABS(yawDiff) < 0x18E3) ? 2 : 1; + func_80034A14(&pthis->actor, &pthis->unk_2D4, kREG(17) + 0xC, phi_a3); +} + +void func_80984F10(DemoIm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_2D4.unk_18 = player->actor.world.pos; + pthis->unk_2D4.unk_14 = kREG(16) + 12.0f; + + func_80034A14(&pthis->actor, &pthis->unk_2D4, kREG(17) + 0xC, 2); +} + +void func_80984F94(DemoIm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_2D4.unk_18 = player->actor.world.pos; + pthis->unk_2D4.unk_14 = kREG(16) + 4.0f; + func_80034A14(&pthis->actor, &pthis->unk_2D4, kREG(17) + 0xC, 4); +} + +void DemoIm_UpdateBgCheckInfo(DemoIm* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +s32 DemoIm_UpdateSkelAnime(DemoIm* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +s32 DemoIm_IsCsStateIdle(GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + return true; + } else { + return false; + } +} + +CsCmdActorAction* DemoIm_GetNpcAction(GlobalContext* globalCtx, s32 actionIdx) { + s32 pad[2]; + CsCmdActorAction* ret = NULL; + + if (!DemoIm_IsCsStateIdle(globalCtx)) { + ret = globalCtx->csCtx.npcActions[actionIdx]; + } + return ret; +} + +s32 func_809850E8(DemoIm* pthis, GlobalContext* globalCtx, u16 action, s32 actionIdx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); + + if (npcAction != NULL) { + if (npcAction->action == action) { + return true; + } + } + return false; +} + +s32 func_80985134(DemoIm* pthis, GlobalContext* globalCtx, u16 action, s32 actionIdx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); + + if (npcAction != NULL) { + if (npcAction->action != action) { + return true; + } + } + return false; +} + +void func_80985180(DemoIm* pthis, GlobalContext* globalCtx, s32 actionIdx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +void func_80985200(DemoIm* pthis, GlobalContext* globalCtx, s32 actionIdx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, actionIdx); + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +void DemoIm_ChangeAnim(DemoIm* pthis, AnimationHeader* animHeaderSeg, u8 animMode, f32 transitionRate, + s32 playBackwards) { + f32 frameCount = Animation_GetLastFrame(animHeaderSeg); + f32 playbackSpeed; + f32 startFrame; + f32 endFrame; + + if (!playBackwards) { + startFrame = 0.0f; + endFrame = frameCount; + playbackSpeed = 1.0f; + } else { + endFrame = 0.0f; + startFrame = frameCount; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animHeaderSeg, playbackSpeed, startFrame, endFrame, animMode, transitionRate); +} + +void func_80985310(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_ChangeAnim(pthis, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->actor.shape.yOffset = -10000.0f; +} + +void func_80985358(DemoIm* pthis, GlobalContext* globalCtx) { + f32 posX = pthis->actor.world.pos.x; + f32 posY = pthis->actor.world.pos.y; + f32 posZ = pthis->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, + WARP_SAGES); +} + +void func_809853B4(DemoIm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 playerX = player->actor.world.pos.x; + f32 playerY = player->actor.world.pos.y + 80.0f; + f32 playerZ = player->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, playerX, playerY, playerZ, 0, + 0, 0, 0xD); + Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); +} + +void func_80985430(DemoIm* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.yOffset += 250.0f / 3.0f; +} + +void func_8098544C(DemoIm* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + + if ((gSaveContext.chamberCutsceneNum == 4) && (gSaveContext.sceneSetupIndex < 4)) { + Player* player = GET_PLAYER(globalCtx); + + pthis->action = 1; + globalCtx->csCtx.segment = D_8098786C; + gSaveContext.cutsceneTrigger = 2; + Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); + player->actor.world.rot.y = player->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + } +} + +void func_809854DC(DemoIm* pthis, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[5] != NULL) && + (globalCtx->csCtx.npcActions[5]->action == 2)) { + Animation_Change(&pthis->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->action = 2; + pthis->drawConfig = 1; + func_80985358(pthis, globalCtx); + } +} + +void func_8098557C(DemoIm* pthis) { + if (pthis->actor.shape.yOffset >= 0.0f) { + pthis->action = 3; + pthis->actor.shape.yOffset = 0.0f; + } +} + +void func_809855A8(DemoIm* pthis, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[5] != NULL) && + (globalCtx->csCtx.npcActions[5]->action == 3)) { + Animation_Change(&pthis->skelAnime, &gImpaRaiseArmsAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaRaiseArmsAnim), + ANIMMODE_ONCE, 4.0f); + pthis->action = 4; + } +} + +void func_80985640(DemoIm* pthis, s32 arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gImpaPresentShadowMedallionAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gImpaPresentShadowMedallionAnim), ANIMMODE_LOOP, 0.0f); + pthis->action = 5; + } +} + +void func_809856AC(DemoIm* pthis, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[6] != NULL) && + (globalCtx->csCtx.npcActions[6]->action == 2)) { + pthis->action = 6; + func_809853B4(pthis, globalCtx); + } +} + +void func_809856F8(DemoIm* pthis, GlobalContext* globalCtx) { + func_8098544C(pthis, globalCtx); +} + +void func_80985718(DemoIm* pthis, GlobalContext* globalCtx) { + func_809854DC(pthis, globalCtx); +} + +void func_80985738(DemoIm* pthis, GlobalContext* globalCtx) { + func_80985430(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_8098557C(pthis); +} + +void func_80985770(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_809855A8(pthis, globalCtx); +} + +void func_809857B0(DemoIm* pthis, GlobalContext* globalCtx) { + s32 sp1C; + + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + sp1C = DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80985640(pthis, sp1C); +} + +void func_809857F0(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_809856AC(pthis, globalCtx); +} + +void func_80985830(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); +} + +void func_80985860(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_ChangeAnim(pthis, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = 7; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_809858A8(void) { + func_800788CC(NA_SE_SY_WHITE_OUT_T); +} + +void DemoIm_SpawnLightBall(DemoIm* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + (kREG(17) + 24.0f) + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 6); +} + +void func_80985948(DemoIm* pthis, GlobalContext* globalCtx) { + if (func_809850E8(pthis, globalCtx, 4, 5)) { + Animation_Change(&pthis->skelAnime, &gImpaPrepareSealGanonAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gImpaPrepareSealGanonAnim), ANIMMODE_ONCE, 0.0f); + pthis->action = 8; + pthis->drawConfig = 2; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_268 = 0.0f; + func_809858A8(); + } +} + +void func_809859E0(DemoIm* pthis, GlobalContext* globalCtx) { + f32* unk_268 = &pthis->unk_268; + s32 alpha = 255; + + if (func_809850E8(pthis, globalCtx, 4, 5)) { + *unk_268 += 1.0f; + if (*unk_268 >= kREG(5) + 10.0f) { + pthis->action = 9; + pthis->drawConfig = 1; + *unk_268 = kREG(5) + 10.0f; + pthis->alpha = pthis->actor.shape.shadowAlpha = alpha; + return; + } + } else { + *unk_268 -= 1.0f; + if (*unk_268 <= 0.0f) { + pthis->action = 7; + pthis->drawConfig = 0; + *unk_268 = 0.0f; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + return; + } + } + pthis->actor.shape.shadowAlpha = pthis->alpha = (*unk_268 / (kREG(5) + 10.0f)) * 255.0f; +} + +void func_80985B34(DemoIm* pthis, GlobalContext* globalCtx) { + if (func_80985134(pthis, globalCtx, 4, 5)) { + Animation_Change(&pthis->skelAnime, &gImpaSealGanonAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaSealGanonAnim), + ANIMMODE_ONCE, -8.0f); + pthis->action = 8; + pthis->drawConfig = 2; + pthis->unk_268 = kREG(5) + 10.0f; + pthis->alpha = 255; + if (pthis->unk_270 == 0) { + DemoIm_SpawnLightBall(pthis, globalCtx); + pthis->unk_270 = 1; + } + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80985C10(DemoIm* pthis, GlobalContext* globalCtx) { + func_80985948(pthis, globalCtx); + func_80984C8C(pthis, globalCtx); +} + +void func_80985C40(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_809859E0(pthis, globalCtx); + func_80984C8C(pthis, globalCtx); +} + +void func_80985C94(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80985B34(pthis, globalCtx); + func_80984C8C(pthis, globalCtx); +} + +void DemoIm_DrawTranslucent(DemoIm* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeIndex = pthis->eyeIndex; + void* eyeTex = sEyeTextures[eyeIndex]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_im_inKenjyanomaDemo02.c", 281); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + NULL, NULL, NULL, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_im_inKenjyanomaDemo02.c", 308); +} + +void func_80985E60(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_ChangeAnim(pthis, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = 10; + pthis->unk_280 = 1; +} + +void func_80985EAC(DemoIm* pthis, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.frames >= 80) && (globalCtx->csCtx.frames < 243)) { + func_80984F10(pthis, globalCtx); + } else { + func_80984DB8(pthis); + } +} + +void func_80985EF4(DemoIm* pthis) { + if (!Animation_OnFrame(&pthis->skelAnime, Animation_GetLastFrame(&gImpaWhistlingAnim) - 1.0f)) { + DemoIm_UpdateSkelAnime(pthis); + } +} + +void func_80985F54(DemoIm* pthis) { + pthis->action = 10; + pthis->drawConfig = 0; +} + +void func_80985F64(DemoIm* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), + ANIMMODE_LOOP, 0.0f); + func_80985180(pthis, globalCtx, 5); + pthis->action = 11; + pthis->drawConfig = 1; +} + +void func_80985FE8(DemoIm* pthis, s32 arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gImpaWhistlingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaWhistlingAnim), + ANIMMODE_LOOP, -8.0f); + } +} + +void func_8098604C(DemoIm* pthis) { + f32 frameCount = Animation_GetLastFrame(&gImpaStartWhistlingAnim); + + Animation_Change(&pthis->skelAnime, &gImpaStartWhistlingAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -8.0f); + pthis->action = 12; + pthis->drawConfig = 1; + pthis->unk_2D0 = 1; +} + +void func_809860C8(DemoIm* pthis) { + pthis->action = 13; + pthis->drawConfig = 1; +} + +void func_809860DC(DemoIm* pthis, s32 arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), + ANIMMODE_LOOP, -8.0f); + pthis->unk_2D0 = 0; + } +} + +void func_80986148(DemoIm* pthis) { + Animation_Change(&pthis->skelAnime, &gImpaStartWhistlingAnim, -1.0f, + Animation_GetLastFrame(&gImpaStartWhistlingAnim), 0.0f, ANIMMODE_ONCE, -8.0f); + pthis->action = 14; + pthis->drawConfig = 1; +} + +void func_809861C4(DemoIm* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); + + if (npcAction != NULL) { + u32 action = npcAction->action; + u32 unk_274 = pthis->unk_274; + + if (action != unk_274) { + switch (action) { + case 9: + func_80986148(pthis); + break; + case 7: + Animation_Change(&pthis->skelAnime, &gImpaWhistlingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gImpaWhistlingAnim), ANIMMODE_LOOP, -8.0f); + pthis->action = 12; + break; + default: + osSyncPrintf("Demo_Im_Ocarina_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_274 = action; + } + } +} + +void func_8098629C(DemoIm* pthis, GlobalContext* globalCtx) { + if (DemoIm_IsCsStateIdle(globalCtx)) { + pthis->action = 21; + pthis->drawConfig = 1; + pthis->unk_280 = 1; + } +} + +void func_809862E0(DemoIm* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); + + if (npcAction != NULL) { + u32 action = npcAction->action; + u32 unk_274 = pthis->unk_274; + + if (action != unk_274) { + switch (action) { + case 1: + func_80985F54(pthis); + break; + case 2: + func_80985F64(pthis, globalCtx); + break; + case 7: + func_8098604C(pthis); + break; + case 8: + func_809860C8(pthis); + break; + case 9: + func_80986148(pthis); + break; + default: + osSyncPrintf("Demo_Im_Ocarina_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_274 = action; + } + } +} + +void func_809863BC(DemoIm* pthis, GlobalContext* globalCtx) { + func_809862E0(pthis, globalCtx); +} + +void func_809863DC(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80985EAC(pthis, globalCtx); + func_80984BE0(pthis); + func_809862E0(pthis, globalCtx); +} + +void func_80986430(DemoIm* pthis, GlobalContext* globalCtx) { + s32 sp24; + + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + sp24 = DemoIm_UpdateSkelAnime(pthis); + func_80985EAC(pthis, globalCtx); + func_80984BE0(pthis); + func_80985FE8(pthis, sp24); + func_809862E0(pthis, globalCtx); +} + +void func_80986494(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + func_80985EF4(pthis); + func_80984BE0(pthis); + func_809861C4(pthis, globalCtx); +} + +void func_809864D4(DemoIm* pthis, GlobalContext* globalCtx) { + s32 sp24; + + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + sp24 = DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_809860DC(pthis, sp24); + func_8098629C(pthis, globalCtx); +} + +void func_8098652C(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_ChangeAnim(pthis, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = 15; +} + +void func_80986570(DemoIm* pthis, GlobalContext* globalCtx) { + if (Animation_OnFrame(&pthis->skelAnime, 7.0f) && (pthis->actor.bgCheckFlags & 1)) { + u32 sfxId = SFX_FLAG; + + sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + Audio_PlaySoundGeneral(sfxId, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +void func_809865F8(DemoIm* pthis, GlobalContext* globalCtx, s32 arg2) { + s32 pad[2]; + + if (arg2 != 0) { + f32* unk_278 = &pthis->unk_278; + + if (*unk_278 >= 0.0f) { + if (pthis->unk_27C == 0) { + Vec3f* thisPos = &pthis->actor.world.pos; + s16 shapeRotY = pthis->actor.shape.rot.y; + f32 spawnPosX = thisPos->x + (Math_SinS(shapeRotY) * 30.0f); + f32 spawnPosY = thisPos->y; + f32 spawnPosZ = thisPos->z + (Math_CosS(shapeRotY) * 30.0f); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, spawnPosX, spawnPosY, spawnPosZ, 0xFA0, + pthis->actor.shape.rot.y, 0, ARROW_CS_NUT); + pthis->unk_27C = 1; + } + } else { + *unk_278 += 1.0f; + } + } +} + +void func_80986700(DemoIm* pthis) { + pthis->action = 15; + pthis->drawConfig = 0; +} + +void func_80986710(DemoIm* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gImpaIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gImpaIdleAnim), + ANIMMODE_LOOP, 0.0f); + func_80985180(pthis, globalCtx, 5); + pthis->action = 16; + pthis->drawConfig = 1; +} + +void func_80986794(DemoIm* pthis) { + Animation_Change(&pthis->skelAnime, &gImpaThrowDekuNutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gImpaThrowDekuNutAnim), ANIMMODE_ONCE, -8.0f); + pthis->action = 17; + pthis->drawConfig = 1; +} + +void func_8098680C(DemoIm* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); + + if (npcAction != NULL) { + u32 action = npcAction->action; + u32 unk_274 = pthis->unk_274; + + if (action != unk_274) { + switch (action) { + case 1: + func_80986700(pthis); + break; + case 2: + func_80986710(pthis, globalCtx); + break; + case 10: + func_80986794(pthis); + break; + case 11: + Actor_Kill(&pthis->actor); + break; + default: + osSyncPrintf("Demo_Im_Spot00_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_274 = action; + } + } +} + +void func_809868E8(DemoIm* pthis, GlobalContext* globalCtx) { + func_8098680C(pthis, globalCtx); +} + +void func_80986908(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_8098680C(pthis, globalCtx); +} + +void func_80986948(DemoIm* pthis, GlobalContext* globalCtx) { + s32 sp24; + + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + sp24 = DemoIm_UpdateSkelAnime(pthis); + func_80986570(pthis, globalCtx); + func_80984BE0(pthis); + func_809865F8(pthis, globalCtx, sp24); + func_8098680C(pthis, globalCtx); +} + +void func_809869B0(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_ChangeAnim(pthis, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = 18; + pthis->actor.shape.shadowAlpha = 0; +} + +s32 func_809869F8(DemoIm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 playerPosX = player->actor.world.pos.x; + f32 thisPosX = pthis->actor.world.pos.x; + + if ((thisPosX - (kREG(16) + 30.0f) > playerPosX) && !(pthis->actor.flags & ACTOR_FLAG_UNCULLED)) { + return true; + } else { + return false; + } +} + +s32 func_80986A5C(DemoIm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 playerPosX = player->actor.world.pos.x; + f32 thisPosX = pthis->actor.world.pos.x; + + if ((thisPosX - (kREG(17) + 130.0f) < playerPosX) && (!Gameplay_InCsMode(globalCtx))) { + return true; + } else { + return false; + } +} + +s32 func_80986AD0(DemoIm* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + if (!Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actor.textId = 0x708E; + func_8002F2F4(&pthis->actor, globalCtx); + } else { + return true; + } + return false; +} + +void func_80986B2C(GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + Player* player = GET_PLAYER(globalCtx); + + globalCtx->nextEntranceIndex = 0xCD; + globalCtx->fadeTransition = 38; + globalCtx->sceneLoadFlag = 0x14; + func_8002DF54(globalCtx, &player->actor, 8); + } +} + +void func_80986BA0(DemoIm* pthis, GlobalContext* globalCtx) { + if (func_809869F8(pthis, globalCtx)) { + pthis->action = 21; + pthis->drawConfig = 1; + pthis->unk_280 = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80986BE4(DemoIm* pthis, s32 arg1) { + if (arg1 != 0) { + pthis->action = 22; + } +} + +void func_80986BF8(DemoIm* pthis, GlobalContext* globalCtx) { + if (gSaveContext.eventChkInf[4] & 1) { + pthis->action = 24; + pthis->drawConfig = 1; + pthis->unk_280 = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80986C30(DemoIm* pthis, GlobalContext* globalCtx) { + if (func_80986A5C(pthis, globalCtx)) { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gZeldasCourtyardLullabyCs); + gSaveContext.cutsceneTrigger = 1; + gSaveContext.eventChkInf[5] |= 0x200; + Item_Give(globalCtx, ITEM_SONG_LULLABY); + func_80985F54(pthis); + } +} + +void func_80986CC8(DemoIm* pthis) { + if (gSaveContext.eventChkInf[4] & 1) { + pthis->action = 26; + pthis->drawConfig = 1; + pthis->unk_280 = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80986CFC(DemoIm* pthis, GlobalContext* globalCtx) { + if (func_80986A5C(pthis, globalCtx)) { + gSaveContext.eventChkInf[4] |= 0x1000; + pthis->action = 19; + } +} + +void func_80986D40(DemoIm* pthis, GlobalContext* globalCtx) { + if (gSaveContext.sceneSetupIndex == 6) { + pthis->action = 19; + pthis->drawConfig = 1; + } else if (gSaveContext.eventChkInf[8] & 1) { + Actor_Kill(&pthis->actor); + } else if (!(gSaveContext.eventChkInf[5] & 0x200)) { + pthis->action = 23; + } else { + pthis->action = 20; + } +} + +void func_80986DC8(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80984E58(pthis, globalCtx); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); +} + +void func_80986E20(DemoIm* pthis, GlobalContext* globalCtx) { + func_80986BA0(pthis, globalCtx); +} + +void func_80986E40(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80984E58(pthis, globalCtx); + DemoIm_UpdateCollider(pthis, globalCtx); + func_80986BE4(pthis, func_80986AD0(pthis, globalCtx)); +} + +void func_80986EAC(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80984F94(pthis, globalCtx); + DemoIm_UpdateCollider(pthis, globalCtx); + func_80986B2C(globalCtx); +} + +void func_80986F08(DemoIm* pthis, GlobalContext* globalCtx) { + func_80986BF8(pthis, globalCtx); +} + +void func_80986F28(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80984E58(pthis, globalCtx); + DemoIm_UpdateCollider(pthis, globalCtx); + func_80986C30(pthis, globalCtx); +} + +void func_80986F88(DemoIm* pthis, GlobalContext* globalCtx) { + func_80986CC8(pthis); +} + +void func_80986FA8(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80984E58(pthis, globalCtx); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + DemoIm_UpdateCollider(pthis, globalCtx); + func_80986CFC(pthis, globalCtx); +} + +void func_80987018(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_ChangeAnim(pthis, &gImpaIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = 27; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80987064(DemoIm* pthis) { + f32* unk_268 = &pthis->unk_268; + f32 temp; + s32 alpha = 255; + + *unk_268 += 1.0f; + temp = kREG(17) + 10.0f; + + if (*unk_268 >= temp) { + pthis->actor.shape.shadowAlpha = pthis->alpha = alpha; + } else { + pthis->actor.shape.shadowAlpha = pthis->alpha = (*unk_268 / temp) * 255.0f; + } +} + +void func_809870F0(DemoIm* pthis, GlobalContext* globalCtx) { + func_80985200(pthis, globalCtx, 5); + pthis->action = 28; + pthis->drawConfig = 2; +} + +void func_80987128(DemoIm* pthis) { + if (pthis->unk_268 >= kREG(17) + 10.0f) { + pthis->action = 29; + pthis->drawConfig = 1; + } +} + +void func_80987174(DemoIm* pthis) { + DemoIm_ChangeAnim(pthis, &object_im_Anim_0101C8, ANIMMODE_ONCE, -8.0f, false); + pthis->action = 30; +} + +void func_809871B4(DemoIm* pthis, s32 arg1) { + if (arg1 != 0) { + DemoIm_ChangeAnim(pthis, &object_im_Anim_00FB10, ANIMMODE_LOOP, 0.0f, false); + } +} + +void func_809871E8(DemoIm* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = DemoIm_GetNpcAction(globalCtx, 5); + + if (npcAction != NULL) { + u32 action = npcAction->action; + u32 unk_274 = pthis->unk_274; + + if (action != unk_274) { + switch (action) { + case 12: + func_809870F0(pthis, globalCtx); + break; + case 13: + func_80987174(pthis); + break; + default: + osSyncPrintf("Demo_Im_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_274 = action; + } + } +} + +void func_80987288(DemoIm* pthis, GlobalContext* globalCtx) { + func_809871E8(pthis, globalCtx); +} + +void func_809872A8(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_80987064(pthis); + func_80987128(pthis); +} + +void func_809872F0(DemoIm* pthis, GlobalContext* globalCtx) { + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_809871E8(pthis, globalCtx); +} + +void func_80987330(DemoIm* pthis, GlobalContext* globalCtx) { + s32 sp1C; + + DemoIm_UpdateBgCheckInfo(pthis, globalCtx); + sp1C = DemoIm_UpdateSkelAnime(pthis); + func_80984BE0(pthis); + func_809871B4(pthis, sp1C); +} + +void DemoIm_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoIm* pthis = (DemoIm*)thisx; + + if ((pthis->action < 0) || (pthis->action >= 31) || (sActionFuncs[pthis->action] == NULL)) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void DemoIm_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoIm* pthis = (DemoIm*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + DemoIm_InitCollider(thisx, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gImpaSkel, NULL, pthis->jointTable, pthis->morphTable, 17); + thisx->flags &= ~ACTOR_FLAG_0; + + switch (pthis->actor.params) { + case 2: + func_80985860(pthis, globalCtx); + break; + case 3: + func_80985E60(pthis, globalCtx); + break; + case 4: + func_8098652C(pthis, globalCtx); + break; + case 5: + func_809869B0(pthis, globalCtx); + break; + case 6: + func_80987018(pthis, globalCtx); + break; + default: + func_80985310(pthis, globalCtx); + } +} + +void DemoIm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoIm_DestroyCollider(thisx, globalCtx); +} + +s32 DemoIm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + DemoIm* pthis = (DemoIm*)thisx; + s32* unk_2D0 = &pthis->unk_2D0; + + if (pthis->unk_280 != 0) { + Vec3s* unk_2D4_unk_0E = &pthis->unk_2D4.unk_0E; + Vec3s* unk_2D4_unk_08 = &pthis->unk_2D4.unk_08; + + switch (limbIndex) { + case IMPA_LIMB_CHEST: + rot->x += unk_2D4_unk_0E->y; + rot->y -= unk_2D4_unk_0E->x; + break; + case IMPA_LIMB_HEAD: + rot->x += unk_2D4_unk_08->y; + rot->z += unk_2D4_unk_08->x; + break; + } + } + + if ((*unk_2D0 != 0) && (limbIndex == IMPA_LIMB_RIGHT_HAND)) { + *dList = gImpaHandPointingDL; + } + + return false; +} + +void DemoIm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + DemoIm* pthis = (DemoIm*)thisx; + + if (limbIndex == IMPA_LIMB_HEAD) { + Vec3f sp28 = D_809887D8; + Vec3f dest; + + Matrix_MultVec3f(&sp28, &dest); + pthis->actor.focus.pos.x = dest.x; + pthis->actor.focus.pos.y = dest.y; + pthis->actor.focus.pos.z = dest.z; + pthis->actor.focus.rot.x = pthis->actor.world.rot.x; + pthis->actor.focus.rot.y = pthis->actor.world.rot.y; + pthis->actor.focus.rot.z = pthis->actor.world.rot.z; + } +} + +void DemoIm_DrawNothing(DemoIm* pthis, GlobalContext* globalCtx) { +} + +void DemoIm_DrawSolid(DemoIm* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeIndex = pthis->eyeIndex; + void* eyeTexture = sEyeTextures[eyeIndex]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_im.c", 904); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + DemoIm_OverrideLimbDraw, DemoIm_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_im.c", 925); +} + +void DemoIm_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoIm* pthis = (DemoIm*)thisx; + + if ((pthis->drawConfig < 0) || (pthis->drawConfig >= 3) || (sDrawFuncs[pthis->drawConfig] == NULL)) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im_cutscene_data.c b/src/overlays/actors/ovl_Demo_Im/z_demo_im_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Im/z_demo_im_cutscene_data.c rename to src/overlays/actors/ovl_Demo_Im/z_demo_im_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.cpp similarity index 66% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.cpp index 0dfdf091a..e2921aba1 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.cpp @@ -29,13 +29,13 @@ void DemoKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoKankyo_Update(Actor* thisx, GlobalContext* globalCtx); void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); -void DemoKankyo_SetupType(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_UpdateClouds(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_UpdateRock(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_DoNothing2(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_UpdateDoorOfTime(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_DoNothing(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_KillDoorOfTimeCollision(DemoKankyo* this, GlobalContext* globalCtx); +void DemoKankyo_SetupType(DemoKankyo* pthis, GlobalContext* globalCtx); +void DemoKankyo_UpdateClouds(DemoKankyo* pthis, GlobalContext* globalCtx); +void DemoKankyo_UpdateRock(DemoKankyo* pthis, GlobalContext* globalCtx); +void DemoKankyo_DoNothing2(DemoKankyo* pthis, GlobalContext* globalCtx); +void DemoKankyo_UpdateDoorOfTime(DemoKankyo* pthis, GlobalContext* globalCtx); +void DemoKankyo_DoNothing(DemoKankyo* pthis, GlobalContext* globalCtx); +void DemoKankyo_KillDoorOfTimeCollision(DemoKankyo* pthis, GlobalContext* globalCtx); void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx); void DemoKankyo_DrawRock(Actor* thisx, GlobalContext* globalCtx); @@ -58,7 +58,7 @@ extern CutsceneData gChildWarpOutCS[]; extern CutsceneData gChildWarpInToTCS[]; extern CutsceneData gChildWarpOutToTCS[]; -const ActorInit Demo_Kankyo_InitVars = { +ActorInit Demo_Kankyo_InitVars = { ACTOR_DEMO_KANKYO, ACTORCAT_BG, FLAGS, @@ -127,7 +127,7 @@ static CutsceneCameraPoint sWarpInCameraPoints[] = { }; static Color_RGB8 sSparkleEnvColors[] = { - { 0, 200, 0 }, { 255, 50, 0 }, { 0, 150, 255 }, { 255, 150, 0 }, // only this one is used + { 0, 200, 0 }, { 255, 50, 0 }, { 0, 150, 255 }, { 255, 150, 0 }, // only pthis one is used { 0, 255, 255 }, { 200, 255, 0 }, }; @@ -192,23 +192,23 @@ static s16 D_8098CF80; static s16 sRainScale; static s16 D_8098CF84; -void DemoKankyo_SetupAction(DemoKankyo* this, DemoKankyoActionFunc actionFunc) { - this->actionFunc = actionFunc; +void DemoKankyo_SetupAction(DemoKankyo* pthis, DemoKankyoActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; s16 i; - s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjIds[this->actor.params]); + s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjIds[pthis->actor.params]); osSyncPrintf("bank_ID = %d\n", objBankIndex); if (objBankIndex < 0) { ASSERT(0, "0", "../z_demo_kankyo.c", 521); } else { - this->objBankIndex = objBankIndex; + pthis->objBankIndex = objBankIndex; } - switch (this->actor.params) { + switch (pthis->actor.params) { case DEMOKANKYO_BLUE_RAIN: case DEMOKANKYO_BLUE_RAIN_2: switch (globalCtx->sceneNum) { @@ -226,7 +226,7 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { sRainScale = 5; break; default: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; } break; @@ -236,82 +236,82 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { case DEMOKANKYO_ROCK_4: case DEMOKANKYO_ROCK_5: globalCtx->roomCtx.curRoom.segment = NULL; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = Rand_ZeroOne() * 0.5f + 0.5f; - this->unk_150[0].unk_0.x = Rand_ZeroOne() * 3.0f + 1.0f; - this->unk_150[0].unk_0.y = Rand_ZeroOne() * 3.0f + 1.0f; - this->unk_150[0].unk_0.z = Rand_ZeroOne() * 3.0f + 1.0f; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = Rand_ZeroOne() * 0.5f + 0.5f; + pthis->unk_150[0].unk_0.x = Rand_ZeroOne() * 3.0f + 1.0f; + pthis->unk_150[0].unk_0.y = Rand_ZeroOne() * 3.0f + 1.0f; + pthis->unk_150[0].unk_0.z = Rand_ZeroOne() * 3.0f + 1.0f; break; case DEMOKANKYO_CLOUDS: for (i = 0; i < 30; i++) { - this->unk_150[i].unk_20 = Rand_ZeroOne() * 65535.0f; - this->unk_150[i].unk_18 = Rand_ZeroOne() * 100.0f + 60.0f; + pthis->unk_150[i].unk_20 = Rand_ZeroOne() * 65535.0f; + pthis->unk_150[i].unk_18 = Rand_ZeroOne() * 100.0f + 60.0f; } break; case DEMOKANKYO_DOOR_OF_TIME: - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 1.0f; - this->unk_150[0].unk_18 = 0.0f; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 1.0f; + pthis->unk_150[0].unk_18 = 0.0f; if (!(gSaveContext.eventChkInf[4] & 0x800)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_TOKI, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_TOKI, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0x0000); } else { globalCtx->roomCtx.unk_74[1] = 0xFF; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; case DEMOKANKYO_LIGHT_PLANE: - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 1.0f; - this->unk_150[0].unk_18 = 0.0f; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 1.0f; + pthis->unk_150[0].unk_18 = 0.0f; break; case DEMOKANKYO_WARP_OUT: case DEMOKANKYO_WARP_IN: - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ITEMACTION); - this->actor.flags |= ACTOR_FLAG_25; - this->actor.room = -1; - this->warpTimer = 35; - this->sparkleCounter = 0; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 1.0f; - if (this->actor.params == DEMOKANKYO_WARP_OUT) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ITEMACTION); + pthis->actor.flags |= ACTOR_FLAG_25; + pthis->actor.room = -1; + pthis->warpTimer = 35; + pthis->sparkleCounter = 0; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 1.0f; + if (pthis->actor.params == DEMOKANKYO_WARP_OUT) { Audio_PlaySoundGeneral(NA_SE_EV_SARIA_MELODY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } break; case DEMOKANKYO_SPARKLES: - this->warpTimer = 35; - this->sparkleCounter = 0; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 1.0f; + pthis->warpTimer = 35; + pthis->sparkleCounter = 0; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 1.0f; break; default: break; } for (i = 0; i < 30; i++) { - this->unk_150[i].unk_22 = 0; + pthis->unk_150[i].unk_22 = 0; } - DemoKankyo_SetupAction(this, DemoKankyo_SetupType); + DemoKankyo_SetupAction(pthis, DemoKankyo_SetupType); } void DemoKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { if (thisx) {} } -void DemoKankyo_SetupType(DemoKankyo* this, GlobalContext* globalCtx) { +void DemoKankyo_SetupType(DemoKankyo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 temp; - if (this->actor.objBankIndex == this->objBankIndex) { - switch (this->actor.params) { + if (pthis->actor.objBankIndex == pthis->objBankIndex) { + switch (pthis->actor.params) { case DEMOKANKYO_ROCK_1: case DEMOKANKYO_ROCK_2: case DEMOKANKYO_ROCK_3: case DEMOKANKYO_ROCK_4: case DEMOKANKYO_ROCK_5: - DemoKankyo_SetupAction(this, DemoKankyo_UpdateRock); + DemoKankyo_SetupAction(pthis, DemoKankyo_UpdateRock); break; case DEMOKANKYO_CLOUDS: - DemoKankyo_SetupAction(this, DemoKankyo_UpdateClouds); + DemoKankyo_SetupAction(pthis, DemoKankyo_UpdateClouds); break; case DEMOKANKYO_DOOR_OF_TIME: if (Flags_GetEnv(globalCtx, 2)) { - DemoKankyo_SetupAction(this, DemoKankyo_UpdateDoorOfTime); + DemoKankyo_SetupAction(pthis, DemoKankyo_UpdateDoorOfTime); } break; case DEMOKANKYO_WARP_OUT: @@ -319,23 +319,23 @@ void DemoKankyo_SetupType(DemoKankyo* this, GlobalContext* globalCtx) { globalCtx->envCtx.screenFillColor[1] = 0xFF; globalCtx->envCtx.screenFillColor[2] = 0xFF; globalCtx->envCtx.fillScreen = false; - if (this->warpTimer < 21 && this->warpTimer >= 15) { - temp = (this->warpTimer - 15.0f) / 5.0f; + if (pthis->warpTimer < 21 && pthis->warpTimer >= 15) { + temp = (pthis->warpTimer - 15.0f) / 5.0f; globalCtx->envCtx.fillScreen = true; globalCtx->envCtx.screenFillColor[3] = 255 - 255 * temp; } - if (this->warpTimer < 15 && this->warpTimer >= 4) { - temp = (this->warpTimer - 4.0f) / 10.0f; + if (pthis->warpTimer < 15 && pthis->warpTimer >= 4) { + temp = (pthis->warpTimer - 4.0f) / 10.0f; globalCtx->envCtx.fillScreen = true; globalCtx->envCtx.screenFillColor[3] = 255 * temp; } - if (this->warpTimer == 15) { + if (pthis->warpTimer == 15) { player->actor.draw = NULL; } - if ((u32)this->warpTimer != 0) { - this->warpTimer--; + if ((u32)pthis->warpTimer != 0) { + pthis->warpTimer--; } - if (this->warpTimer == 1) { + if (pthis->warpTimer == 1) { if (globalCtx->sceneNum == SCENE_TOKINOMA) { D_8098CF84 = 25; if (!LINK_IS_ADULT) { @@ -354,7 +354,7 @@ void DemoKankyo_SetupType(DemoKankyo* this, GlobalContext* globalCtx) { if (func_800C0CB8(globalCtx) != 0) { gSaveContext.cutsceneTrigger = 1; } - DemoKankyo_SetupAction(this, DemoKankyo_DoNothing); + DemoKankyo_SetupAction(pthis, DemoKankyo_DoNothing); } break; case DEMOKANKYO_WARP_IN: @@ -372,7 +372,7 @@ void DemoKankyo_SetupType(DemoKankyo* this, GlobalContext* globalCtx) { } } gSaveContext.cutsceneTrigger = 1; - DemoKankyo_SetupAction(this, DemoKankyo_DoNothing2); + DemoKankyo_SetupAction(pthis, DemoKankyo_DoNothing2); break; case DEMOKANKYO_BLUE_RAIN: case DEMOKANKYO_SPARKLES: @@ -381,14 +381,14 @@ void DemoKankyo_SetupType(DemoKankyo* this, GlobalContext* globalCtx) { } } -void DemoKankyo_DoNothing(DemoKankyo* this, GlobalContext* globalCtx) { +void DemoKankyo_DoNothing(DemoKankyo* pthis, GlobalContext* globalCtx) { } -void DemoKankyo_DoNothing2(DemoKankyo* this, GlobalContext* globalCtx) { - DemoKankyo_SetupAction(this, DemoKankyo_DoNothing); +void DemoKankyo_DoNothing2(DemoKankyo* pthis, GlobalContext* globalCtx) { + DemoKankyo_SetupAction(pthis, DemoKankyo_DoNothing); } -void DemoKankyo_SetRockPos(DemoKankyo* this, GlobalContext* globalCtx, s32 params) { +void DemoKankyo_SetRockPos(DemoKankyo* pthis, GlobalContext* globalCtx, s32 params) { Vec3f startPos; Vec3f endPos; CsCmdActorAction* csAction = globalCtx->csCtx.npcActions[params]; @@ -401,59 +401,59 @@ void DemoKankyo_SetRockPos(DemoKankyo* this, GlobalContext* globalCtx, s32 param endPos.y = csAction->endPos.y; endPos.z = csAction->endPos.z; temp_f0 = Environment_LerpWeight(csAction->endFrame, csAction->startFrame, globalCtx->csCtx.frames); - this->actor.world.pos.x = ((endPos.x - startPos.x) * temp_f0) + startPos.x; - this->actor.world.pos.y = ((endPos.y - startPos.y) * temp_f0) + startPos.y; - this->actor.world.pos.z = ((endPos.z - startPos.z) * temp_f0) + startPos.z; + pthis->actor.world.pos.x = ((endPos.x - startPos.x) * temp_f0) + startPos.x; + pthis->actor.world.pos.y = ((endPos.y - startPos.y) * temp_f0) + startPos.y; + pthis->actor.world.pos.z = ((endPos.z - startPos.z) * temp_f0) + startPos.z; } -void DemoKankyo_UpdateRock(DemoKankyo* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[this->actor.params - 2] != NULL) { - DemoKankyo_SetRockPos(this, globalCtx, this->actor.params - 2); +void DemoKankyo_UpdateRock(DemoKankyo* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[pthis->actor.params - 2] != NULL) { + DemoKankyo_SetRockPos(pthis, globalCtx, pthis->actor.params - 2); } - this->unk_150[0].unk_C.x += this->unk_150[0].unk_0.x; - this->unk_150[0].unk_C.y += this->unk_150[0].unk_0.y; - this->unk_150[0].unk_C.z += this->unk_150[0].unk_0.z; + pthis->unk_150[0].unk_C.x += pthis->unk_150[0].unk_0.x; + pthis->unk_150[0].unk_C.y += pthis->unk_150[0].unk_0.y; + pthis->unk_150[0].unk_C.z += pthis->unk_150[0].unk_0.z; } -void DemoKankyo_UpdateClouds(DemoKankyo* this, GlobalContext* globalCtx) { +void DemoKankyo_UpdateClouds(DemoKankyo* pthis, GlobalContext* globalCtx) { u8 i; for (i = 0; i < 30; i++) { - this->unk_150[i].unk_20 += (s16)this->unk_150[i].unk_18; + pthis->unk_150[i].unk_20 += (s16)pthis->unk_150[i].unk_18; } } -void DemoKankyo_UpdateDoorOfTime(DemoKankyo* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); - this->unk_150[0].unk_18 += 1.0f; - if (this->unk_150[0].unk_18 >= 102.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONEDOOR_STOP); +void DemoKankyo_UpdateDoorOfTime(DemoKankyo* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); + pthis->unk_150[0].unk_18 += 1.0f; + if (pthis->unk_150[0].unk_18 >= 102.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_STONEDOOR_STOP); gSaveContext.eventChkInf[4] |= 0x800; - Actor_Kill(this->actor.child); - DemoKankyo_SetupAction(this, DemoKankyo_KillDoorOfTimeCollision); + Actor_Kill(pthis->actor.child); + DemoKankyo_SetupAction(pthis, DemoKankyo_KillDoorOfTimeCollision); } } -void DemoKankyo_KillDoorOfTimeCollision(DemoKankyo* this, GlobalContext* globalCtx) { - Actor_Kill(this->actor.child); +void DemoKankyo_KillDoorOfTimeCollision(DemoKankyo* pthis, GlobalContext* globalCtx) { + Actor_Kill(pthis->actor.child); } void DemoKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; - this->actionFunc(this, globalCtx); + DemoKankyo* pthis = (DemoKankyo*)thisx; + pthis->actionFunc(pthis, globalCtx); } void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; - if (this->actor.objBankIndex == this->objBankIndex) { - switch (this->actor.params) { + if (pthis->actor.objBankIndex == pthis->objBankIndex) { + switch (pthis->actor.params) { case DEMOKANKYO_BLUE_RAIN: case DEMOKANKYO_BLUE_RAIN_2: if (globalCtx->sceneNum == SCENE_TOKINOMA) { if (!Flags_GetEnv(globalCtx, 1)) { break; - } else if (!Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7530)) { + } else if (!Actor_IsFacingAndNearPlayer(&pthis->actor, 300.0f, 0x7530)) { break; } else { if (!LINK_IS_ADULT) { @@ -494,40 +494,40 @@ void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } } - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->actor.objBankIndex = pthis->objBankIndex; } } // transform relating to blue rain void func_80989B54(Actor* thisx, GlobalContext* globalCtx, s16 i) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; switch (globalCtx->sceneNum) { case SCENE_HIRAL_DEMO: - this->unk_150[i].unk_0.x = (Rand_ZeroOne() - 0.5f) * 500.0f; - this->unk_150[i].unk_0.y = 500.0f; - this->unk_150[i].unk_0.z = (Rand_ZeroOne() - 0.5f) * 500.0f; + pthis->unk_150[i].unk_0.x = (Rand_ZeroOne() - 0.5f) * 500.0f; + pthis->unk_150[i].unk_0.y = 500.0f; + pthis->unk_150[i].unk_0.z = (Rand_ZeroOne() - 0.5f) * 500.0f; break; case SCENE_TOKINOMA: - this->unk_150[i].unk_C.x = 0.0f; - this->unk_150[i].unk_C.y = 0.0f; - this->unk_150[i].unk_C.z = 0.0f; - this->unk_150[i].unk_0.x = (Rand_ZeroOne() - 0.5f) * 180.0f; - this->unk_150[i].unk_0.y = 10.0f; - this->unk_150[i].unk_0.z = (Rand_ZeroOne() - 0.5f) * 180.0f; + pthis->unk_150[i].unk_C.x = 0.0f; + pthis->unk_150[i].unk_C.y = 0.0f; + pthis->unk_150[i].unk_C.z = 0.0f; + pthis->unk_150[i].unk_0.x = (Rand_ZeroOne() - 0.5f) * 180.0f; + pthis->unk_150[i].unk_0.y = 10.0f; + pthis->unk_150[i].unk_0.z = (Rand_ZeroOne() - 0.5f) * 180.0f; break; case SCENE_SPOT00: - this->unk_150[i].unk_0.x = (Rand_ZeroOne() - 0.5f) * 600.0f; - this->unk_150[i].unk_0.y = -500.0f; - this->unk_150[i].unk_0.z = (Rand_ZeroOne() - 0.5f) * 600.0f; + pthis->unk_150[i].unk_0.x = (Rand_ZeroOne() - 0.5f) * 600.0f; + pthis->unk_150[i].unk_0.y = -500.0f; + pthis->unk_150[i].unk_0.z = (Rand_ZeroOne() - 0.5f) * 600.0f; break; } - this->unk_150[i].unk_18 = Rand_ZeroOne() * (D_8098CF80 * 4.0f) + D_8098CF80; + pthis->unk_150[i].unk_18 = Rand_ZeroOne() * (D_8098CF80 * 4.0f) + D_8098CF80; } void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; f32 temp_f12_2; s16 i; f32 dx; @@ -550,51 +550,51 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { norm = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); if (globalCtx->sceneNum != SCENE_TOKINOMA) { - this->unk_150[i].unk_C.x = globalCtx->view.eye.x + (dx / norm) * 350.0f; - this->unk_150[i].unk_C.y = globalCtx->view.eye.y + (dy / norm) * 80.0f; - this->unk_150[i].unk_C.z = globalCtx->view.eye.z + (dz / norm) * 350.0f; + pthis->unk_150[i].unk_C.x = globalCtx->view.eye.x + (dx / norm) * 350.0f; + pthis->unk_150[i].unk_C.y = globalCtx->view.eye.y + (dy / norm) * 80.0f; + pthis->unk_150[i].unk_C.z = globalCtx->view.eye.z + (dz / norm) * 350.0f; } - switch (this->unk_150[i].unk_22) { + switch (pthis->unk_150[i].unk_22) { case 0: func_80989B54(thisx, globalCtx, i); if (gSaveContext.entranceIndex == 0x00A0) { // Cutscene Map - this->unk_150[i].unk_0.y = Rand_ZeroOne() * 500.0f; + pthis->unk_150[i].unk_0.y = Rand_ZeroOne() * 500.0f; } else { - this->unk_150[i].unk_0.y = Rand_ZeroOne() * -500.0f; + pthis->unk_150[i].unk_0.y = Rand_ZeroOne() * -500.0f; } - this->unk_150[i].unk_22++; + pthis->unk_150[i].unk_22++; break; case 1: temp_f12_2 = globalCtx->view.eye.y + (dy / norm) * 150.0f; if (gSaveContext.entranceIndex == 0x00A0) { // Cutscene Map - this->unk_150[i].unk_0.y -= this->unk_150[i].unk_18; + pthis->unk_150[i].unk_0.y -= pthis->unk_150[i].unk_18; } else { - this->unk_150[i].unk_0.y += this->unk_150[i].unk_18; + pthis->unk_150[i].unk_0.y += pthis->unk_150[i].unk_18; } if (gSaveContext.entranceIndex == 0x00A0) { // Cutscene Map - if (this->unk_150[i].unk_C.y + this->unk_150[i].unk_0.y < temp_f12_2 - 300.0f) { - this->unk_150[i].unk_22++; + if (pthis->unk_150[i].unk_C.y + pthis->unk_150[i].unk_0.y < temp_f12_2 - 300.0f) { + pthis->unk_150[i].unk_22++; } } else if (gSaveContext.entranceIndex == 0x00CD) { // Hyrule Field - if (temp_f12_2 + 300.0f < this->unk_150[i].unk_C.y + this->unk_150[i].unk_0.y) { - this->unk_150[i].unk_22++; + if (temp_f12_2 + 300.0f < pthis->unk_150[i].unk_C.y + pthis->unk_150[i].unk_0.y) { + pthis->unk_150[i].unk_22++; } } else { - if (1000.0f < this->unk_150[i].unk_C.y + this->unk_150[i].unk_0.y) { - this->unk_150[i].unk_22++; + if (1000.0f < pthis->unk_150[i].unk_C.y + pthis->unk_150[i].unk_0.y) { + pthis->unk_150[i].unk_22++; } } break; case 2: func_80989B54(thisx, globalCtx, i); - this->unk_150[i].unk_22--; + pthis->unk_150[i].unk_22--; break; } - Matrix_Translate(this->unk_150[i].unk_C.x + this->unk_150[i].unk_0.x, - this->unk_150[i].unk_C.y + this->unk_150[i].unk_0.y, - this->unk_150[i].unk_C.z + this->unk_150[i].unk_0.z, MTXMODE_NEW); + Matrix_Translate(pthis->unk_150[i].unk_C.x + pthis->unk_150[i].unk_0.x, + pthis->unk_150[i].unk_C.y + pthis->unk_150[i].unk_0.y, + pthis->unk_150[i].unk_C.z + pthis->unk_150[i].unk_0.z, MTXMODE_NEW); if (gSaveContext.entranceIndex != 0x00A0) { // Cutscene Map Matrix_RotateX(M_PI, MTXMODE_APPLY); } @@ -614,12 +614,12 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { s32 pad1; if (globalCtx->sceneNum != SCENE_TOKINOMA) { - if (this->unk_150[i].unk_0.x >= 0.0f) { + if (pthis->unk_150[i].unk_0.x >= 0.0f) { translateX = -j * 1500.0f; } else { translateX = j * 1500.0f; } - if (this->unk_150[i].unk_0.z >= 0.0f) { + if (pthis->unk_150[i].unk_0.z >= 0.0f) { translateZ = -j * 1500.0f; } else { translateZ = j * 1500.0f; @@ -646,17 +646,17 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { } void DemoKankyo_DrawRock(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1376); func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateX(DEG_TO_RAD(this->unk_150[0].unk_C.x), MTXMODE_APPLY); - Matrix_RotateY(DEG_TO_RAD(this->unk_150[0].unk_C.y), MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(this->unk_150[0].unk_C.z), MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateX(DEG_TO_RAD(pthis->unk_150[0].unk_C.x), MTXMODE_APPLY); + Matrix_RotateY(DEG_TO_RAD(pthis->unk_150[0].unk_C.y), MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(pthis->unk_150[0].unk_C.z), MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 55, 255); gDPSetEnvColor(POLY_OPA_DISP++, 155, 255, 55, 255); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1404), @@ -667,7 +667,7 @@ void DemoKankyo_DrawRock(Actor* thisx, GlobalContext* globalCtx) { } void DemoKankyo_DrawClouds(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; s16 i; s32 pad; f32 dx; @@ -677,9 +677,9 @@ void DemoKankyo_DrawClouds(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1425); for (i = 0; i < 30; i++) { - dx = -(Math_SinS(this->unk_150[i].unk_20 - 0x8000) * 120.0f) * (30.0f + (i / 30.0f) * 10.0f); - dy = Math_CosS(this->unk_150[i].unk_20 - 0x8000) * 5.0f + 1200.0f; - dz = (Math_CosS(this->unk_150[i].unk_20 - 0x8000) * 120.0f) * (30.0f + (i / 30.0f) * 10.0f); + dx = -(Math_SinS(pthis->unk_150[i].unk_20 - 0x8000) * 120.0f) * (30.0f + (i / 30.0f) * 10.0f); + dy = Math_CosS(pthis->unk_150[i].unk_20 - 0x8000) * 5.0f + 1200.0f; + dz = (Math_CosS(pthis->unk_150[i].unk_20 - 0x8000) * 120.0f) * (30.0f + (i / 30.0f) * 10.0f); Matrix_Translate(globalCtx->view.eye.x + dx, globalCtx->view.eye.y + dy + ((i - 12.0f) * 300.0f), globalCtx->view.eye.z + dz, MTXMODE_NEW); @@ -704,17 +704,17 @@ void DemoKankyo_DrawClouds(Actor* thisx, GlobalContext* globalCtx) { } void DemoKankyo_DrawDoorOfTime(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1487); func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(-this->unk_150[0].unk_18, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-pthis->unk_150[0].unk_18, 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1492), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_toki_objects_DL_007440); - Matrix_Translate(this->unk_150[0].unk_18 + this->unk_150[0].unk_18, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(pthis->unk_150[0].unk_18 + pthis->unk_150[0].unk_18, 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1497), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_toki_objects_DL_007578); @@ -723,7 +723,7 @@ void DemoKankyo_DrawDoorOfTime(Actor* thisx, GlobalContext* globalCtx) { } void DemoKankyo_DrawLightPlane(Actor* thisx, GlobalContext* globalCtx) { - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1514); @@ -779,7 +779,7 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { s16 i; f32 temp_f22; - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; Gfx* disp; Player* player = GET_PLAYER(globalCtx); Vec3f camPos; @@ -791,88 +791,88 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 1824); - if (this->sparkleCounter < 30) { - this->sparkleCounter += 2; + if (pthis->sparkleCounter < 30) { + pthis->sparkleCounter += 2; } - for (i = this->sparkleCounter - 1; i >= 0; i--) { - temp_f22 = 1.0f - (i / (f32)this->sparkleCounter); + for (i = pthis->sparkleCounter - 1; i >= 0; i--) { + temp_f22 = 1.0f - (i / (f32)pthis->sparkleCounter); - switch (this->unk_150[i].unk_22) { + switch (pthis->unk_150[i].unk_22) { case 0: - this->unk_150[i].unk_20 = 0; - this->unk_150[i].unk_1C = 0; - this->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); - this->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); - this->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); - this->unk_150[i].unk_23 = 0; - this->unk_150[i].unk_22++; + pthis->unk_150[i].unk_20 = 0; + pthis->unk_150[i].unk_1C = 0; + pthis->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); + pthis->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); + pthis->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); + pthis->unk_150[i].unk_23 = 0; + pthis->unk_150[i].unk_22++; case 1: - if (this->actor.params == DEMOKANKYO_WARP_OUT) { - if (func_800BB2B4(&camPos, &sWarpRoll, &sWarpFoV, sWarpOutCameraPoints, &this->unk_150[i].unk_20, - &this->unk_150[i].unk_1C) != 0) { - this->unk_150[i].unk_22++; + if (pthis->actor.params == DEMOKANKYO_WARP_OUT) { + if (func_800BB2B4(&camPos, &sWarpRoll, &sWarpFoV, sWarpOutCameraPoints, &pthis->unk_150[i].unk_20, + &pthis->unk_150[i].unk_1C) != 0) { + pthis->unk_150[i].unk_22++; } if (globalCtx->sceneNum == SCENE_TOKINOMA && globalCtx->csCtx.frames == 25) { - this->unk_150[i].unk_22++; + pthis->unk_150[i].unk_22++; } } else { Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP_OUT - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - if (func_800BB2B4(&camPos, &sWarpRoll, &sWarpFoV, sWarpInCameraPoints, &this->unk_150[i].unk_20, - &this->unk_150[i].unk_1C) != 0) { - this->unk_150[i].unk_22++; + if (func_800BB2B4(&camPos, &sWarpRoll, &sWarpFoV, sWarpInCameraPoints, &pthis->unk_150[i].unk_20, + &pthis->unk_150[i].unk_1C) != 0) { + pthis->unk_150[i].unk_22++; } - if (D_8098CF84 < globalCtx->csCtx.frames && this->actor.params == DEMOKANKYO_WARP_OUT) { - this->unk_150[i].unk_22++; + if (D_8098CF84 < globalCtx->csCtx.frames && pthis->actor.params == DEMOKANKYO_WARP_OUT) { + pthis->unk_150[i].unk_22++; } } Actor_GetWorld(&posRot, &player->actor); DemoKankyo_Vec3fAddPosRot(&posRot, &camPos, &D_8098CF98); break; case 2: - if (this->actor.params == DEMOKANKYO_WARP_OUT) { + if (pthis->actor.params == DEMOKANKYO_WARP_OUT) { if (i == 0) { Environment_WarpSongLeave(globalCtx); - this->unk_150[i].unk_22++; + pthis->unk_150[i].unk_22++; } - } else if (i + 1 == this->sparkleCounter && globalCtx->csCtx.state == CS_STATE_IDLE) { + } else if (i + 1 == pthis->sparkleCounter && globalCtx->csCtx.state == CS_STATE_IDLE) { func_80088AF0(globalCtx); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; } - this->unk_150[i].unk_C.x = D_8098CF98.x; - this->unk_150[i].unk_C.y = D_8098CF98.y; - this->unk_150[i].unk_C.z = D_8098CF98.z; + pthis->unk_150[i].unk_C.x = D_8098CF98.x; + pthis->unk_150[i].unk_C.y = D_8098CF98.y; + pthis->unk_150[i].unk_C.z = D_8098CF98.z; - switch (this->unk_150[i].unk_23) { + switch (pthis->unk_150[i].unk_23) { case 0: - this->unk_150[i].unk_18 = Rand_ZeroOne(); - this->unk_150[i].unk_23++; + pthis->unk_150[i].unk_18 = Rand_ZeroOne(); + pthis->unk_150[i].unk_23++; case 1: - Math_SmoothStepToF(&this->unk_150[i].unk_18, 1.0f, 0.5f, 0.4f, 0.2f); - if (this->unk_150[i].unk_18 >= 1.0f) { - this->unk_150[i].unk_23 = 2; + Math_SmoothStepToF(&pthis->unk_150[i].unk_18, 1.0f, 0.5f, 0.4f, 0.2f); + if (pthis->unk_150[i].unk_18 >= 1.0f) { + pthis->unk_150[i].unk_23 = 2; } break; case 2: - Math_SmoothStepToF(&this->unk_150[i].unk_18, 0.0f, 0.5f, 0.3f, 0.2f); - if (this->unk_150[i].unk_18 <= 0.0f) { - this->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); - this->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); - this->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); - this->unk_150[i].unk_18 = 0.0f; - this->unk_150[i].unk_23 = 1; + Math_SmoothStepToF(&pthis->unk_150[i].unk_18, 0.0f, 0.5f, 0.3f, 0.2f); + if (pthis->unk_150[i].unk_18 <= 0.0f) { + pthis->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); + pthis->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); + pthis->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f22); + pthis->unk_150[i].unk_18 = 0.0f; + pthis->unk_150[i].unk_23 = 1; } break; } - translateX = this->unk_150[i].unk_C.x + this->unk_150[i].unk_0.x; - translateY = this->unk_150[i].unk_C.y + this->unk_150[i].unk_0.y; - translateZ = this->unk_150[i].unk_C.z + this->unk_150[i].unk_0.z; + translateX = pthis->unk_150[i].unk_C.x + pthis->unk_150[i].unk_0.x; + translateY = pthis->unk_150[i].unk_C.y + pthis->unk_150[i].unk_0.y; + translateZ = pthis->unk_150[i].unk_C.z + pthis->unk_150[i].unk_0.z; - if (this->unk_150[i].unk_22 < 2) { + if (pthis->unk_150[i].unk_22 < 2) { disp = gEffFlash1DL; if (linkAge != 0) { Matrix_Translate(translateX, translateY, translateZ, MTXMODE_NEW); @@ -880,10 +880,10 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { if (translateY) {} Matrix_Translate(translateX, translateY + 15.0f, translateZ, MTXMODE_NEW); } - Matrix_Scale(this->unk_150[i].unk_18 * (0.018f * temp_f22), this->unk_150[i].unk_18 * (0.018f * temp_f22), - this->unk_150[i].unk_18 * (0.018f * temp_f22), MTXMODE_APPLY); + Matrix_Scale(pthis->unk_150[i].unk_18 * (0.018f * temp_f22), pthis->unk_150[i].unk_18 * (0.018f * temp_f22), + pthis->unk_150[i].unk_18 * (0.018f * temp_f22), MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); - if (this->actor.params == DEMOKANKYO_WARP_OUT) { + if (pthis->actor.params == DEMOKANKYO_WARP_OUT) { gDPSetEnvColor(POLY_XLU_DISP++, sWarpSparkleEnvColors[globalCtx->msgCtx.lastPlayedSong].r, sWarpSparkleEnvColors[globalCtx->msgCtx.lastPlayedSong].g, sWarpSparkleEnvColors[globalCtx->msgCtx.lastPlayedSong].b, 255); @@ -895,11 +895,11 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { } func_80093D84(globalCtx->state.gfxCtx); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(this->unk_150[i].unk_24), MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(pthis->unk_150[i].unk_24), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 2011), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, disp); - this->unk_150[i].unk_24 += 0x190; + pthis->unk_150[i].unk_24 += 0x190; } } @@ -915,7 +915,7 @@ void DemoKankyo_DrawSparkles(Actor* thisx, GlobalContext* globalCtx) { static u32 D_8098CFB4; static Vec3f D_8098CFB8; - DemoKankyo* this = (DemoKankyo*)thisx; + DemoKankyo* pthis = (DemoKankyo*)thisx; f32 translateX; f32 translateY; f32 translateZ; @@ -927,81 +927,81 @@ void DemoKankyo_DrawSparkles(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 2434); - if (this->sparkleCounter < 20) { - this->sparkleCounter++; + if (pthis->sparkleCounter < 20) { + pthis->sparkleCounter++; } - for (i = this->sparkleCounter - 1; i >= 0; i--) { - temp_f20 = 1.0f - (i / (f32)this->sparkleCounter); + for (i = pthis->sparkleCounter - 1; i >= 0; i--) { + temp_f20 = 1.0f - (i / (f32)pthis->sparkleCounter); - switch (this->unk_150[i].unk_22) { + switch (pthis->unk_150[i].unk_22) { case 0: - this->unk_150[i].unk_20 = 0; - this->unk_150[i].unk_1C = 0; - this->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); - this->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); - this->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); - this->unk_150[i].unk_23 = 0; - this->unk_150[i].unk_22++; + pthis->unk_150[i].unk_20 = 0; + pthis->unk_150[i].unk_1C = 0; + pthis->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); + pthis->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); + pthis->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); + pthis->unk_150[i].unk_23 = 0; + pthis->unk_150[i].unk_22++; case 1: if (func_800BB2B4(&camPos, &sSparklesRoll, &sSparklesFoV, sSparklesCameraPoints, - &this->unk_150[i].unk_20, &this->unk_150[i].unk_1C) != 0) { - this->unk_150[i].unk_22++; + &pthis->unk_150[i].unk_20, &pthis->unk_150[i].unk_1C) != 0) { + pthis->unk_150[i].unk_22++; } - Actor_GetWorld(&posRot, &this->actor); + Actor_GetWorld(&posRot, &pthis->actor); DemoKankyo_Vec3fAddPosRot(&posRot, &camPos, &D_8098CFB8); break; case 2: - if (i + 1 == this->sparkleCounter && globalCtx->csCtx.state == CS_STATE_IDLE) { - Actor_Kill(&this->actor); + if (i + 1 == pthis->sparkleCounter && globalCtx->csCtx.state == CS_STATE_IDLE) { + Actor_Kill(&pthis->actor); } break; } - this->unk_150[i].unk_C.x = D_8098CFB8.x; - this->unk_150[i].unk_C.y = D_8098CFB8.y; - this->unk_150[i].unk_C.z = D_8098CFB8.z; + pthis->unk_150[i].unk_C.x = D_8098CFB8.x; + pthis->unk_150[i].unk_C.y = D_8098CFB8.y; + pthis->unk_150[i].unk_C.z = D_8098CFB8.z; - switch (this->unk_150[i].unk_23) { + switch (pthis->unk_150[i].unk_23) { case 0: - this->unk_150[i].unk_18 = Rand_ZeroOne(); - this->unk_150[i].unk_23++; + pthis->unk_150[i].unk_18 = Rand_ZeroOne(); + pthis->unk_150[i].unk_23++; case 1: - Math_SmoothStepToF(&this->unk_150[i].unk_18, 1.0f, 0.5f, 0.4f, 0.2f); - if (1.0f <= this->unk_150[i].unk_18) { - this->unk_150[i].unk_23 = 2; + Math_SmoothStepToF(&pthis->unk_150[i].unk_18, 1.0f, 0.5f, 0.4f, 0.2f); + if (1.0f <= pthis->unk_150[i].unk_18) { + pthis->unk_150[i].unk_23 = 2; } break; case 2: - Math_SmoothStepToF(&this->unk_150[i].unk_18, 0.0f, 0.5f, 0.3f, 0.2f); - if (this->unk_150[i].unk_18 <= 0.0f) { - this->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); - this->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); - this->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); - this->unk_150[i].unk_18 = 0.0f; - this->unk_150[i].unk_23 = 1; + Math_SmoothStepToF(&pthis->unk_150[i].unk_18, 0.0f, 0.5f, 0.3f, 0.2f); + if (pthis->unk_150[i].unk_18 <= 0.0f) { + pthis->unk_150[i].unk_0.x = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); + pthis->unk_150[i].unk_0.y = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); + pthis->unk_150[i].unk_0.z = (s16)((Rand_ZeroOne() - 0.5f) * 16.0f * temp_f20); + pthis->unk_150[i].unk_18 = 0.0f; + pthis->unk_150[i].unk_23 = 1; } break; } - translateX = this->unk_150[i].unk_C.x + this->unk_150[i].unk_0.x; - translateY = this->unk_150[i].unk_C.y + this->unk_150[i].unk_0.y; - translateZ = this->unk_150[i].unk_C.z + this->unk_150[i].unk_0.z; + translateX = pthis->unk_150[i].unk_C.x + pthis->unk_150[i].unk_0.x; + translateY = pthis->unk_150[i].unk_C.y + pthis->unk_150[i].unk_0.y; + translateZ = pthis->unk_150[i].unk_C.z + pthis->unk_150[i].unk_0.z; - if (this->unk_150[i].unk_22 < 2) { + if (pthis->unk_150[i].unk_22 < 2) { Matrix_Translate(translateX, translateY, translateZ, MTXMODE_NEW); - scale = this->unk_150[i].unk_18 * (0.02f * temp_f20); + scale = pthis->unk_150[i].unk_18 * (0.02f * temp_f20); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, sSparkleEnvColors[3].r, sSparkleEnvColors[3].g, sSparkleEnvColors[3].b, 255); func_80093D84(globalCtx->state.gfxCtx); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(this->unk_150[i].unk_24), MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(pthis->unk_150[i].unk_24), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kankyo.c", 2572), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); - this->unk_150[i].unk_24 += 0x190; + pthis->unk_150[i].unk_24 += 0x190; } } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data1.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data1.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data1.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data1.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data2.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data2.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data2.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data2.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data3.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data3.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data3.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data3.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data4.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data4.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data4.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data4.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data5.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data5.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data5.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data5.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data6.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data6.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data6.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data6.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data7.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data7.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data7.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data7.cpp diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data8.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data8.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data8.c rename to src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo_cutscene_data8.cpp diff --git a/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c b/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.cpp similarity index 66% rename from src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c rename to src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.cpp index ccb2062ac..841370eea 100644 --- a/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c +++ b/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.cpp @@ -29,9 +29,9 @@ void DemoKekkai_TrialBarrierDispel(Actor* thisx, GlobalContext* globalCtx); void DemoKekkai_TrialBarrierIdle(Actor* thisx, GlobalContext* globalCtx); void DemoKekkai_DrawTrialBarrier(Actor* thisx, GlobalContext* globalCtx); -void DemoKekkai_TowerBarrier(DemoKekkai* this, GlobalContext* globalCtx); +void DemoKekkai_TowerBarrier(DemoKekkai* pthis, GlobalContext* globalCtx); -const ActorInit Demo_Kekkai_InitVars = { +ActorInit Demo_Kekkai_InitVars = { ACTOR_DEMO_KEKKAI, ACTORCAT_ITEMACTION, FLAGS, @@ -83,27 +83,27 @@ s32 DemoKekkai_CheckEventFlag(s32 params) { void DemoKekkai_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; - this->sfxFlag = 0; - this->energyAlpha = 1.0f; + pthis->sfxFlag = 0; + pthis->energyAlpha = 1.0f; Actor_SetScale(thisx, 0.1f); thisx->colChkInfo.mass = MASS_IMMOVABLE; - Collider_InitCylinder(globalCtx, &this->collider1); - Collider_SetCylinder(globalCtx, &this->collider1, thisx, &sCylinderInit); - Collider_InitCylinder(globalCtx, &this->collider2); - Collider_SetCylinder(globalCtx, &this->collider2, thisx, &sCylinderInit); - Collider_UpdateCylinder(thisx, &this->collider1); - Collider_UpdateCylinder(thisx, &this->collider2); - this->timer = 0; - this->barrierScrollRate = 1.0f; - this->barrierScroll = 0.0f; + Collider_InitCylinder(globalCtx, &pthis->collider1); + Collider_SetCylinder(globalCtx, &pthis->collider1, thisx, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider2); + Collider_SetCylinder(globalCtx, &pthis->collider2, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &pthis->collider1); + Collider_UpdateCylinder(thisx, &pthis->collider2); + pthis->timer = 0; + pthis->barrierScrollRate = 1.0f; + pthis->barrierScroll = 0.0f; switch (thisx->params) { case KEKKAI_TOWER: - this->updateFunc = DemoKekkai_TowerBarrier; - this->collider2.dim.radius = thisx->scale.x * 6100.0f; - this->collider2.dim.height = thisx->scale.y * 5000.0f; - this->collider2.dim.yShift = 300; + pthis->updateFunc = DemoKekkai_TowerBarrier; + pthis->collider2.dim.radius = thisx->scale.x * 6100.0f; + pthis->collider2.dim.height = thisx->scale.y * 5000.0f; + pthis->collider2.dim.yShift = 300; break; case KEKKAI_WATER: case KEKKAI_LIGHT: @@ -111,17 +111,17 @@ void DemoKekkai_Init(Actor* thisx, GlobalContext* globalCtx) { case KEKKAI_SHADOW: case KEKKAI_SPIRIT: case KEKKAI_FOREST: - this->energyAlpha = 1.0f; - this->orbScale = 1.0f; + pthis->energyAlpha = 1.0f; + pthis->orbScale = 1.0f; Actor_SetScale(thisx, 0.1f); thisx->update = DemoKekkai_TrialBarrierIdle; thisx->draw = DemoKekkai_DrawTrialBarrier; - this->collider1.dim.radius = thisx->scale.x * 120.0f; - this->collider1.dim.height = thisx->scale.y * 2000.0f; - this->collider1.dim.yShift = 0; - this->collider2.dim.radius = thisx->scale.x * 320.0f; - this->collider2.dim.height = thisx->scale.y * 510.0f; - this->collider2.dim.yShift = 95; + pthis->collider1.dim.radius = thisx->scale.x * 120.0f; + pthis->collider1.dim.height = thisx->scale.y * 2000.0f; + pthis->collider1.dim.yShift = 0; + pthis->collider2.dim.radius = thisx->scale.x * 320.0f; + pthis->collider2.dim.height = thisx->scale.y * 510.0f; + pthis->collider2.dim.yShift = 95; break; } if (DemoKekkai_CheckEventFlag(thisx->params)) { @@ -134,13 +134,13 @@ void DemoKekkai_Init(Actor* thisx, GlobalContext* globalCtx) { void DemoKekkai_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &pthis->collider1); + Collider_DestroyCylinder(globalCtx, &pthis->collider2); } -void DemoKekkai_SpawnParticles(DemoKekkai* this, GlobalContext* globalCtx) { +void DemoKekkai_SpawnParticles(DemoKekkai* pthis, GlobalContext* globalCtx) { static Vec3f vel = { 0.0f, 0.0f, 0.0f }; static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Color_RGBA8 lightYellow = { 255, 255, 170, 0 }; @@ -156,87 +156,87 @@ void DemoKekkai_SpawnParticles(DemoKekkai* this, GlobalContext* globalCtx) { vel.z = Math_CosS(yaw) * Math_CosS(roll) * Rand_ZeroFloat(8.0f); vel.y = Math_SinS(roll) * Rand_ZeroFloat(3.0f); - pos.x = (vel.x * 7.0f) + this->actor.world.pos.x; - pos.y = (vel.y * 20.0f) + this->actor.world.pos.y + 120.0f; - pos.z = (vel.z * 7.0f) + this->actor.world.pos.z; + pos.x = (vel.x * 7.0f) + pthis->actor.world.pos.x; + pos.y = (vel.y * 20.0f) + pthis->actor.world.pos.y + 120.0f; + pos.z = (vel.z * 7.0f) + pthis->actor.world.pos.z; EffectSsKiraKira_SpawnFocused(globalCtx, &pos, &vel, &accel, &lightYellow, &darkRed, 3000, (s32)Rand_ZeroFloat(40.0f) + 45); } } -void DemoKekkai_TowerBarrier(DemoKekkai* this, GlobalContext* globalCtx) { +void DemoKekkai_TowerBarrier(DemoKekkai* pthis, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[0] != NULL) && (globalCtx->csCtx.npcActions[0]->action != 1) && (globalCtx->csCtx.npcActions[0]->action == 2)) { - if (!(this->sfxFlag & 1)) { + if (!(pthis->sfxFlag & 1)) { func_800F3F3C(0xC); - this->sfxFlag |= 1; + pthis->sfxFlag |= 1; } - if (this->barrierScrollRate < 7.0f) { - this->barrierScrollRate += 0.2f; + if (pthis->barrierScrollRate < 7.0f) { + pthis->barrierScrollRate += 0.2f; } else { - this->timer++; - if (this->timer > 100) { + pthis->timer++; + if (pthis->timer > 100) { Flags_SetEventChkInf(0xC3); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; - } else if (this->timer > 40) { - this->actor.scale.z = this->actor.scale.x += 0.003f; + } else if (pthis->timer > 40) { + pthis->actor.scale.z = pthis->actor.scale.x += 0.003f; } } } - if (!(this->sfxFlag & 1)) { - func_8002F974(&this->actor, NA_SE_EV_TOWER_BARRIER - SFX_FLAG); + if (!(pthis->sfxFlag & 1)) { + func_8002F974(&pthis->actor, NA_SE_EV_TOWER_BARRIER - SFX_FLAG); } } void DemoKekkai_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; - if (this->energyAlpha > 0.99f) { - if ((this->collider1.base.atFlags & AT_HIT) || (this->collider2.base.atFlags & AT_HIT)) { - func_8002F71C(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f); + if (pthis->energyAlpha > 0.99f) { + if ((pthis->collider1.base.atFlags & AT_HIT) || (pthis->collider2.base.atFlags & AT_HIT)) { + func_8002F71C(globalCtx, &pthis->actor, 6.0f, pthis->actor.yawTowardsPlayer, 6.0f); } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); } - this->updateFunc(this, globalCtx); - this->barrierScroll += this->barrierScrollRate; - if (this->barrierScroll > 65536.0f) { - this->barrierScroll -= 65536.0f; + pthis->updateFunc(pthis, globalCtx); + pthis->barrierScroll += pthis->barrierScrollRate; + if (pthis->barrierScroll > 65536.0f) { + pthis->barrierScroll -= 65536.0f; } } void DemoKekkai_TrialBarrierDispel(Actor* thisx, GlobalContext* globalCtx) { static u16 csFrames[] = { 0, 280, 280, 280, 280, 280, 280 }; s32 pad; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; - if (globalCtx->csCtx.frames == csFrames[this->actor.params]) { + if (globalCtx->csCtx.frames == csFrames[pthis->actor.params]) { func_800F3F3C(0xA); } - if (this->energyAlpha >= 0.05f) { - this->energyAlpha -= 0.05f; + if (pthis->energyAlpha >= 0.05f) { + pthis->energyAlpha -= 0.05f; } else { - this->energyAlpha = 0.0f; + pthis->energyAlpha = 0.0f; } - if (this->timer < 40) { - this->orbScale = ((80 - this->timer) * (f32)this->timer * 0.000625f) + 1.0f; - } else if (this->timer < 50) { - this->orbScale = 2.0f; - } else if (this->timer == 50) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); - DemoKekkai_SpawnParticles(this, globalCtx); + if (pthis->timer < 40) { + pthis->orbScale = ((80 - pthis->timer) * (f32)pthis->timer * 0.000625f) + 1.0f; + } else if (pthis->timer < 50) { + pthis->orbScale = 2.0f; + } else if (pthis->timer == 50) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_DM_RING_EXPLOSION); + DemoKekkai_SpawnParticles(pthis, globalCtx); } else { - this->orbScale = 0.0f; + pthis->orbScale = 0.0f; } - if (this->orbScale != 0.0f) { - func_8002F974(&this->actor, NA_SE_EV_TOWER_ENERGY - SFX_FLAG); + if (pthis->orbScale != 0.0f) { + func_8002F974(&pthis->actor, NA_SE_EV_TOWER_ENERGY - SFX_FLAG); } - this->timer++; + pthis->timer++; } static CutsceneData* sSageCutscenes[] = { @@ -251,24 +251,24 @@ static CutsceneData* sSageCutscenes[] = { void DemoKekkai_TrialBarrierIdle(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; - if (this->collider1.base.atFlags & AT_HIT) { - func_8002F71C(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 5.0f); + if (pthis->collider1.base.atFlags & AT_HIT) { + func_8002F71C(globalCtx, &pthis->actor, 5.0f, pthis->actor.yawTowardsPlayer, 5.0f); } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - if (this->collider2.base.acFlags & AC_HIT) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + if (pthis->collider2.base.acFlags & AC_HIT) { func_80078884(NA_SE_SY_CORRECT_CHIME); // "I got it" LOG_STRING("当ったよ", "../z_demo_kekkai.c", 572); - this->actor.update = DemoKekkai_TrialBarrierDispel; - this->timer = 0; - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(sSageCutscenes[this->actor.params]); + pthis->actor.update = DemoKekkai_TrialBarrierDispel; + pthis->timer = 0; + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(sSageCutscenes[pthis->actor.params]); gSaveContext.cutsceneTrigger = 1; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - func_8002F974(&this->actor, NA_SE_EV_TOWER_ENERGY - SFX_FLAG); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + func_8002F974(&pthis->actor, NA_SE_EV_TOWER_ENERGY - SFX_FLAG); } void DemoKekkai_DrawTrialBarrier(Actor* thisx, GlobalContext* globalCtx2) { @@ -280,25 +280,25 @@ void DemoKekkai_DrawTrialBarrier(Actor* thisx, GlobalContext* globalCtx2) { 1, 1, 0, 0, 0, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 0, 0, }; s32 colorIndex; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; u8 alphas[3]; Vtx* energyVtx = SEGMENTED_TO_VIRTUAL(gTrialBarrierEnergyVtx); s32 i; - if (this->orbScale != 0.0f) { + if (pthis->orbScale != 0.0f) { if (1) {} - alphas[2] = (s32)(this->energyAlpha * 202.0f); - alphas[1] = (s32)(this->energyAlpha * 126.0f); + alphas[2] = (s32)(pthis->energyAlpha * 202.0f); + alphas[1] = (s32)(pthis->energyAlpha * 126.0f); alphas[0] = 0; for (i = 0; i < 102; i++) { energyVtx[i].v.cn[3] = alphas[alphaIndex[i]]; } - colorIndex = (this->actor.params - 1) * 6; + colorIndex = (pthis->actor.params - 1) * 6; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kekkai.c", 632); func_80093D84(globalCtx->state.gfxCtx); Matrix_Push(); Matrix_Translate(0.0f, 1200.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(this->orbScale, this->orbScale, this->orbScale, MTXMODE_APPLY); + Matrix_Scale(pthis->orbScale, pthis->orbScale, pthis->orbScale, MTXMODE_APPLY); Matrix_Translate(0.0f, -1200.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kekkai.c", 639), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -329,10 +329,10 @@ void DemoKekkai_DrawTrialBarrier(Actor* thisx, GlobalContext* globalCtx2) { void DemoKekkai_DrawTowerBarrier(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DemoKekkai* this = (DemoKekkai*)thisx; + DemoKekkai* pthis = (DemoKekkai*)thisx; s32 scroll; - scroll = (s32)this->barrierScroll & 0xFFFF; + scroll = (s32)pthis->barrierScroll & 0xFFFF; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_kekkai.c", 705); func_80093D84(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_kekkai.c", 707), diff --git a/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h b/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h index b8e85058d..30e94dec8 100644 --- a/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h +++ b/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h @@ -6,9 +6,9 @@ struct DemoKekkai; -typedef void (*DemoKekkaiUpdateFunc)(struct DemoKekkai* this, GlobalContext* globalCtx); +typedef void (*DemoKekkaiUpdateFunc)(DemoKekkai* pthis, GlobalContext* globalCtx); -typedef struct DemoKekkai { +struct DemoKekkai { /* 0x0000 */ Actor actor; /* 0x014C */ ColliderCylinder collider1; /* 0x0198 */ ColliderCylinder collider2; @@ -19,9 +19,10 @@ typedef struct DemoKekkai { /* 0x01F4 */ u16 timer; /* 0x01F6 */ u16 sfxFlag; /* 0x01F8 */ DemoKekkaiUpdateFunc updateFunc; -} DemoKekkai; // size = 0x01FC +}; // size = 0x01FC -typedef enum { +enum DemoKekkaiType +{ /* 0 */ KEKKAI_TOWER, /* 1 */ KEKKAI_WATER, /* 2 */ KEKKAI_LIGHT, @@ -29,6 +30,6 @@ typedef enum { /* 4 */ KEKKAI_SHADOW, /* 5 */ KEKKAI_SPIRIT, /* 6 */ KEKKAI_FOREST -} DemoKekkaiType; +}; #endif diff --git a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c deleted file mode 100644 index f19056cda..000000000 --- a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c +++ /dev/null @@ -1,836 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_SA_Z_DEMO_SA_C -#include "actor_common.h" -/* - * File: z_demo_sa.c - * Overlay: Demo_Sa - * Description: Saria (Cutscene) - */ - -#include "z_demo_sa.h" -#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "objects/object_sa/object_sa.h" - -#include "vt.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void DemoSa_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoSa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoSa_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoSa_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_8098EBB8(DemoSa* this, GlobalContext* globalCtx); -void func_8098EBD8(DemoSa* this, GlobalContext* globalCtx); -void func_8098EBF8(DemoSa* this, GlobalContext* globalCtx); -void func_8098EC28(DemoSa* this, GlobalContext* globalCtx); -void func_8098EC60(DemoSa* this, GlobalContext* globalCtx); -void func_8098EC94(DemoSa* this, GlobalContext* globalCtx); -void func_8098ECCC(DemoSa* this, GlobalContext* globalCtx); -void func_8098F0E8(DemoSa* this, GlobalContext* globalCtx); -void func_8098F118(DemoSa* this, GlobalContext* globalCtx); -void func_8098F16C(DemoSa* this, GlobalContext* globalCtx); -void func_8098F3F0(DemoSa* this, GlobalContext* globalCtx); -void func_8098F714(DemoSa* this, GlobalContext* globalCtx); -void func_8098F734(DemoSa* this, GlobalContext* globalCtx); -void func_8098F77C(DemoSa* this, GlobalContext* globalCtx); -void func_8098F7BC(DemoSa* this, GlobalContext* globalCtx); -void func_8098F7FC(DemoSa* this, GlobalContext* globalCtx); -void func_8098FC44(DemoSa* this, GlobalContext* globalCtx); -void func_8098FC64(DemoSa* this, GlobalContext* globalCtx); -void func_8098FC9C(DemoSa* this, GlobalContext* globalCtx); -void func_8098FCD4(DemoSa* this, GlobalContext* globalCtx); -void func_8098FD0C(DemoSa* this, GlobalContext* globalCtx); - -void DemoSa_DrawNothing(DemoSa* this, GlobalContext* globalCtx); -void DemoSa_DrawOpa(DemoSa* this, GlobalContext* globalCtx); -void DemoSa_DrawXlu(DemoSa* this, GlobalContext* globalCtx); - -typedef enum { - /* 0 */ SARIA_EYE_OPEN, - /* 1 */ SARIA_EYE_HALF, - /* 2 */ SARIA_EYE_CLOSED, - /* 3 */ SARIA_EYE_SUPRISED, - /* 4 */ SARIA_EYE_SAD -} SariaEyeState; - -typedef enum { - /* 0 */ SARIA_MOUTH_CLOSED2, - /* 1 */ SARIA_MOUTH_SUPRISED, - /* 2 */ SARIA_MOUTH_CLOSED, - /* 3 */ SARIA_MOUTH_SMILING_OPEN, - /* 4 */ SARIA_MOUTH_FROWNING -} SariaMouthState; - -static void* sEyeTextures[] = { - gSariaEyeOpenTex, gSariaEyeHalfTex, gSariaEyeClosedTex, gSariaEyeSuprisedTex, gSariaEyeSadTex, -}; - -static void* sMouthTextures[] = { - gSariaMouthClosed2Tex, gSariaMouthSuprisedTex, gSariaMouthClosedTex, - gSariaMouthSmilingOpenTex, gSariaMouthFrowningTex, -}; - -static u32 D_80990108 = 0; - -#include "z_demo_sa_cutscene_data.c" EARLY - -static DemoSaActionFunc sActionFuncs[] = { - func_8098EBB8, func_8098EBD8, func_8098EBF8, func_8098EC28, func_8098EC60, func_8098EC94, func_8098ECCC, - func_8098F0E8, func_8098F118, func_8098F16C, func_8098F3F0, func_8098F714, func_8098F734, func_8098F77C, - func_8098F7BC, func_8098F7FC, func_8098FC44, func_8098FC64, func_8098FC9C, func_8098FCD4, func_8098FD0C, -}; - -static DemoSaDrawFunc sDrawFuncs[] = { - DemoSa_DrawNothing, - DemoSa_DrawOpa, - DemoSa_DrawXlu, -}; - -const ActorInit Demo_Sa_InitVars = { - ACTOR_DEMO_SA, - ACTORCAT_NPC, - FLAGS, - OBJECT_SA, - sizeof(DemoSa), - (ActorFunc)DemoSa_Init, - (ActorFunc)DemoSa_Destroy, - (ActorFunc)DemoSa_Update, - (ActorFunc)DemoSa_Draw, -}; - -void DemoSa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoSa* this = (DemoSa*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); -} - -void func_8098E480(DemoSa* this) { - s32 pad[2]; - s16* eyeIndex = &this->eyeIndex; - s16* blinkTimer = &this->blinkTimer; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(0x3C, 0x3C); - } - - *eyeIndex = *blinkTimer; - if (*eyeIndex >= 3) { - *eyeIndex = 0; - } -} - -void DemoSa_SetEyeIndex(DemoSa* this, s16 eyeIndex) { - this->eyeIndex = eyeIndex; -} - -void DemoSa_SetMouthIndex(DemoSa* this, s16 mouthIndex) { - this->mouthIndex = mouthIndex; -} - -void func_8098E530(DemoSa* this) { - this->action = 7; - this->drawConfig = 0; - this->alpha = 0; - this->unk_1A8 = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_1A0 = 0.0f; -} - -void func_8098E554(DemoSa* this, GlobalContext* globalCtx) { - u32* something = &D_80990108; - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - if (*something != 0) { - if (this->actor.params == 2) { - func_8098E530(this); - } - *something = 0; - } - } else if (*something == 0) { - *something = 1; - } -} - -void func_8098E5C8(DemoSa* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -s32 DemoSa_UpdateSkelAnime(DemoSa* this) { - return SkelAnime_Update(&this->skelAnime); -} - -CsCmdActorAction* DemoSa_GetNpcAction(GlobalContext* globalCtx, s32 idx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[idx]; - } - return NULL; -} - -s32 func_8098E654(DemoSa* this, GlobalContext* globalCtx, u16 arg2, s32 arg3) { - CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, arg3); - - if ((npcAction != NULL) && (npcAction->action == arg2)) { - return 1; - } - return 0; -} - -s32 func_8098E6A0(DemoSa* this, GlobalContext* globalCtx, u16 arg2, s32 arg3) { - CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, arg3); - - if ((npcAction != NULL) && (npcAction->action != arg2)) { - return 1; - } - return 0; -} - -void func_8098E6EC(DemoSa* this, GlobalContext* globalCtx, s32 actionIdx) { - CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, actionIdx); - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -void func_8098E76C(DemoSa* this, AnimationHeader* animHeaderSeg, u8 arg2, f32 transitionRate, s32 arg4) { - s32 pad[2]; - f32 frameCount = Animation_GetLastFrame(animHeaderSeg); - f32 playbackSpeed; - f32 unk0; - f32 fc; - - if (arg4 == 0) { - unk0 = 0.0f; - fc = frameCount; - playbackSpeed = 1.0f; - } else { - fc = 0.0f; - unk0 = frameCount; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animHeaderSeg, playbackSpeed, unk0, fc, arg2, transitionRate); -} - -void func_8098E7FC(DemoSa* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSariaSkel, &gSariaWaitArmsToSideAnim, NULL, NULL, 0); - this->actor.shape.yOffset = -10000.0f; - DemoSa_SetEyeIndex(this, SARIA_EYE_HALF); - DemoSa_SetMouthIndex(this, SARIA_MOUTH_CLOSED2); -} - -void func_8098E86C(DemoSa* this, GlobalContext* globalCtx) { - Vec3f* world = &this->actor.world.pos; - f32 posX = world->x; - f32 posY = world->y; - f32 posZ = world->z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, - WARP_SAGES); -} - -void func_8098E8C8(DemoSa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 posX = player->actor.world.pos.x; - f32 posY = player->actor.world.pos.y + 80.0f; - f32 posZ = player->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, - 0xB); - Item_Give(globalCtx, ITEM_MEDALLION_FOREST); -} - -void func_8098E944(DemoSa* this, GlobalContext* globalCtx) { - this->actor.shape.yOffset += (250.0f / 3.0f); -} - -void func_8098E960(DemoSa* this, GlobalContext* globalCtx) { - s32 pad[2]; - Player* player; - - if ((gSaveContext.chamberCutsceneNum == 0) && (gSaveContext.sceneSetupIndex < 4)) { - player = GET_PLAYER(globalCtx); - this->action = 1; - globalCtx->csCtx.segment = D_8099010C; - gSaveContext.cutsceneTrigger = 2; - Item_Give(globalCtx, ITEM_MEDALLION_FOREST); - player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - } -} - -void func_8098E9EC(DemoSa* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - npcAction = globalCtx->csCtx.npcActions[4]; - if ((npcAction != NULL) && (npcAction->action == 2)) { - this->action = 2; - this->drawConfig = 1; - func_8098E86C(this, globalCtx); - } - } -} - -void func_8098EA3C(DemoSa* this) { - if (this->actor.shape.yOffset >= 0.0f) { - this->action = 3; - this->actor.shape.yOffset = 0.0f; - } -} - -void func_8098EA68(DemoSa* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - npcAction = globalCtx->csCtx.npcActions[4]; - if ((npcAction != NULL) && (npcAction->action == 3)) { - Animation_Change(&this->skelAnime, &gSariaGiveForestMedallionAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gSariaGiveForestMedallionAnim), ANIMMODE_ONCE, -4.0f); - this->action = 4; - } - } -} - -void func_8098EB00(DemoSa* this, s32 arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gSariaGiveForestMedallionStandAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gSariaGiveForestMedallionStandAnim), ANIMMODE_LOOP, 0.0f); - this->action = 5; - } -} - -void func_8098EB6C(DemoSa* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - npcAction = globalCtx->csCtx.npcActions[6]; - if ((npcAction != NULL) && (npcAction->action == 2)) { - this->action = 6; - func_8098E8C8(this, globalCtx); - } - } -} - -void func_8098EBB8(DemoSa* this, GlobalContext* globalCtx) { - func_8098E960(this, globalCtx); -} - -void func_8098EBD8(DemoSa* this, GlobalContext* globalCtx) { - func_8098E9EC(this, globalCtx); -} - -void func_8098EBF8(DemoSa* this, GlobalContext* globalCtx) { - func_8098E944(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098EA3C(this); -} - -void func_8098EC28(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098EA68(this, globalCtx); -} - -void func_8098EC60(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - func_8098EB00(this, DemoSa_UpdateSkelAnime(this)); -} - -void func_8098EC94(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098EB6C(this, globalCtx); -} - -void func_8098ECCC(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); -} - -void func_8098ECF4(DemoSa* this, GlobalContext* globalCtx) { - s32 pad[2]; - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSariaSealGanonAnim); - - SkelAnime_InitFlex(globalCtx, skelAnime, &gSariaSkel, NULL, NULL, NULL, 0); - Animation_Change(skelAnime, &gSariaSealGanonAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); - this->action = 7; - this->actor.shape.shadowAlpha = 0; - DemoSa_SetEyeIndex(this, SARIA_EYE_CLOSED); - DemoSa_SetMouthIndex(this, SARIA_MOUTH_CLOSED); -} - -void func_8098EDB0(DemoSa* this) { - f32 curFrame = this->skelAnime.curFrame; - - if ((this->skelAnime.mode == 2) && (curFrame >= 32.0f)) { - DemoSa_SetEyeIndex(this, SARIA_EYE_HALF); - DemoSa_SetMouthIndex(this, SARIA_MOUTH_CLOSED2); - } -} - -void func_8098EE08(void) { - func_800788CC(NA_SE_SY_WHITE_OUT_T); -} - -void func_8098EE28(DemoSa* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - (kREG(23) + 25.0f) + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 4); -} - -void func_8098EEA8(DemoSa* this, GlobalContext* globalCtx) { - if (func_8098E654(this, globalCtx, 4, 4)) { - this->action = 8; - this->drawConfig = 2; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_1A0 = 0.0f; - func_8098EE08(); - } -} - -void func_8098EEFC(DemoSa* this, GlobalContext* globalCtx) { - s32 alpha = 255; - f32* unk_1A0 = &this->unk_1A0; - - if (func_8098E654(this, globalCtx, 4, 4)) { - *unk_1A0 += 1.0f; - if ((kREG(5) + 10.0f) <= *unk_1A0) { - this->action = 9; - this->drawConfig = 1; - *unk_1A0 = kREG(5) + 10.0f; - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; - return; - } - } else { - *unk_1A0 -= 1.0f; - if (*unk_1A0 <= 0.0f) { - this->action = 7; - this->drawConfig = 0; - *unk_1A0 = 0.0f; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - return; - } - } - this->actor.shape.shadowAlpha = this->alpha = (*unk_1A0 / (kREG(5) + 10.0f)) * 255.0f; -} - -void func_8098F050(DemoSa* this, GlobalContext* globalCtx) { - if (func_8098E6A0(this, globalCtx, 4, 4)) { - this->action = 8; - this->drawConfig = 2; - this->unk_1A0 = kREG(5) + 10.0f; - this->alpha = 255; - if (this->unk_1A8 == 0) { - func_8098EE28(this, globalCtx); - this->unk_1A8 = 1; - } - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_8098F0E8(DemoSa* this, GlobalContext* globalCtx) { - func_8098EEA8(this, globalCtx); - func_8098E554(this, globalCtx); -} - -void func_8098F118(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098E480(this); - func_8098EEFC(this, globalCtx); - func_8098E554(this, globalCtx); -} - -void func_8098F16C(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098EDB0(this); - func_8098F050(this, globalCtx); - func_8098E554(this, globalCtx); -} - -void DemoSa_DrawXlu(DemoSa* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeIndex = this->eyeIndex; - void* sp78 = sEyeTextures[eyeIndex]; - s16 mouthIndex = this->mouthIndex; - s32 pad2; - void* sp6C = sMouthTextures[mouthIndex]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa_inKenjyanomaDemo02.c", 296); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sp78)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sp78)); - gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sp6C)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - NULL, NULL, NULL, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa_inKenjyanomaDemo02.c", 325); -} - -void func_8098F390(DemoSa* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSariaSkel, &gSariaWaitArmsToSideAnim, NULL, NULL, 0); - this->action = 10; - this->drawConfig = 1; -} - -void func_8098F3F0(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098E480(this); -} - -void func_8098F420(DemoSa* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSariaSkel, &gSariaSitting3Anim, NULL, NULL, 0); - this->action = 11; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_8098F480(DemoSa* this) { - s32 alpha = 255; - f32* unk_1A0 = &this->unk_1A0; - f32 temp_f0; - - *unk_1A0 += 1.0f; - temp_f0 = kREG(17) + 10.0f; - - if (temp_f0 <= *unk_1A0) { - this->actor.shape.shadowAlpha = this->alpha = alpha; - } else { - this->actor.shape.shadowAlpha = this->alpha = (*unk_1A0 / temp_f0) * 255.0f; - } -} - -void func_8098F50C(DemoSa* this, GlobalContext* globalCtx) { - func_8098E6EC(this, globalCtx, 4); - this->action = 12; - this->drawConfig = 2; -} - -void func_8098F544(DemoSa* this) { - if (this->unk_1A0 >= kREG(17) + 10.0f) { - this->action = 13; - this->drawConfig = 1; - } -} - -void func_8098F590(DemoSa* this) { - func_8098E76C(this, &gSariaSitting1Anim, 2, -8.0f, 0); - this->action = 14; -} - -void func_8098F5D0(DemoSa* this) { - func_8098E76C(this, &gSariaSitting2Anim, 2, 0.0f, 0); - this->action = 15; -} - -void func_8098F610(DemoSa* this, s32 arg1) { - if (arg1 != 0) { - func_8098E76C(this, &gSariaSitting3Anim, 0, 0.0f, 0); - this->action = 13; - } -} - -void func_8098F654(DemoSa* this, GlobalContext* globalCtx) { - s32 unk_1AC; - s32 action; - CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, 4); - - if (npcAction != NULL) { - action = npcAction->action; - unk_1AC = this->unk_1AC; - if (action != unk_1AC) { - switch (action) { - case 7: - func_8098F50C(this, globalCtx); - break; - case 8: - func_8098F590(this); - break; - case 9: - func_8098F5D0(this); - break; - default: - osSyncPrintf("Demo_Sa_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_1AC = action; - } - } -} - -void func_8098F714(DemoSa* this, GlobalContext* globalCtx) { - func_8098F654(this, globalCtx); -} - -void func_8098F734(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098E480(this); - func_8098F480(this); - func_8098F544(this); -} - -void func_8098F77C(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098E480(this); - func_8098F654(this, globalCtx); -} - -void func_8098F7BC(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098E480(this); - func_8098F654(this, globalCtx); -} - -void func_8098F7FC(DemoSa* this, GlobalContext* globalCtx) { - s32 sp1C; - - func_8098E5C8(this, globalCtx); - sp1C = DemoSa_UpdateSkelAnime(this); - func_8098E480(this); - func_8098F610(this, sp1C); -} - -void func_8098F83C(DemoSa* this, GlobalContext* globalCtx) { - Vec3f* thisPos = &this->actor.world.pos; - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSariaSkel, &gSariaWaitOnBridgeAnim, NULL, NULL, 0); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELF, thisPos->x, thisPos->y, thisPos->z, - 0, 0, 0, FAIRY_KOKIRI); - this->action = 16; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; - DemoSa_SetEyeIndex(this, SARIA_EYE_SAD); - DemoSa_SetMouthIndex(this, SARIA_MOUTH_CLOSED); -} - -void func_8098F8F8(DemoSa* this) { - s32 alpha = 255; - f32* unk_1A0 = &this->unk_1A0; - f32 temp_f0; - - *unk_1A0 += 1.0f; - temp_f0 = kREG(17) + 10.0f; - - if (temp_f0 <= *unk_1A0) { - this->actor.shape.shadowAlpha = this->alpha = alpha; - } else { - this->actor.shape.shadowAlpha = this->alpha = (*unk_1A0 / temp_f0) * 255.0f; - } -} - -void func_8098F984(DemoSa* this) { - this->action = 16; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_8098F998(DemoSa* this, GlobalContext* globalCtx) { - if (this->unk_1AC == 4) { - func_8098E6EC(this, globalCtx, 1); - this->action = 17; - this->drawConfig = 2; - this->unk_1B0 = 0; - this->actor.shape.shadowAlpha = 0; - } else { - func_8098E76C(this, &gSariaWaitOnBridgeAnim, 0, 0.0f, 0); - this->action = 18; - this->drawConfig = 1; - this->unk_1B0 = 0; - this->actor.shape.shadowAlpha = 0xFF; - } - DemoSa_SetEyeIndex(this, SARIA_EYE_SAD); -} - -void func_8098FA2C(DemoSa* this) { - if (this->unk_1A0 >= kREG(17) + 10.0f) { - this->action = 18; - this->drawConfig = 1; - this->unk_1B0 = 0; - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_8098FA84(DemoSa* this) { - func_8098E76C(this, &gSariaHoldOcarinaAnim, 0, 0.0f, 0); - this->action = 19; - this->drawConfig = 1; - this->unk_1B0 = 1; - this->actor.shape.shadowAlpha = 0xFF; - DemoSa_SetEyeIndex(this, SARIA_EYE_CLOSED); -} - -void func_8098FAE0(DemoSa* this) { - func_8098E76C(this, &gSariaGiveLinkOcarinaAnim, 2, -8.0f, 0); - this->action = 20; - this->drawConfig = 1; - this->unk_1B0 = 1; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_8098FB34(DemoSa* this, s32 arg1) { - if (arg1 != 0) { - func_8098E76C(this, &gSariaHoldOutOcarinaAnim, 0, 0, 0); - } -} - -void func_8098FB68(DemoSa* this, GlobalContext* globalCtx) { - s32 unk_1AC; - s32 action; - CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, 1); - - if (npcAction != NULL) { - action = npcAction->action; - unk_1AC = this->unk_1AC; - if (action != unk_1AC) { - switch (action) { - case 4: - func_8098F984(this); - break; - case 12: - func_8098F998(this, globalCtx); - break; - case 13: - func_8098FA84(this); - break; - case 14: - func_8098FAE0(this); - break; - default: - osSyncPrintf("Demo_Sa_inPresent_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_1AC = action; - } - } -} - -void func_8098FC44(DemoSa* this, GlobalContext* globalCtx) { - func_8098FB68(this, globalCtx); -} - -void func_8098FC64(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098F8F8(this); - func_8098FA2C(this); -} - -void func_8098FC9C(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098FB68(this, globalCtx); -} - -void func_8098FCD4(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - DemoSa_UpdateSkelAnime(this); - func_8098FB68(this, globalCtx); -} - -void func_8098FD0C(DemoSa* this, GlobalContext* globalCtx) { - func_8098E5C8(this, globalCtx); - func_8098FB34(this, DemoSa_UpdateSkelAnime(this)); - func_8098FB68(this, globalCtx); -} - -void DemoSa_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoSa* this = (DemoSa*)thisx; - - if (this->action < 0 || this->action >= 21 || sActionFuncs[this->action] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sActionFuncs[this->action](this, globalCtx); -} - -void DemoSa_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoSa* this = (DemoSa*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - - switch (this->actor.params) { - case 2: - func_8098ECF4(this, globalCtx); - break; - case 3: - func_8098F390(this, globalCtx); - break; - case 4: - func_8098F420(this, globalCtx); - break; - case 5: - func_8098F83C(this, globalCtx); - break; - default: - func_8098E7FC(this, globalCtx); - } -} - -s32 DemoSa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - DemoSa* this = (DemoSa*)thisx; - - if ((limbIndex == 15) && (this->unk_1B0 != 0)) { - *dList = gSariaRightHandAndOcarinaDL; - } - return false; -} - -void DemoSa_DrawNothing(DemoSa* this, GlobalContext* globalCtx) { -} - -void DemoSa_DrawOpa(DemoSa* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeIndex = this->eyeIndex; - void* eyeTex = sEyeTextures[eyeIndex]; - s32 pad2; - s16 mouthIndex = this->mouthIndex; - void* mouthTex = sMouthTextures[mouthIndex]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa.c", 602); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - DemoSa_OverrideLimbDraw, NULL, &this->actor); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa.c", 626); -} - -void DemoSa_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoSa* this = (DemoSa*)thisx; - - if (this->drawConfig < 0 || this->drawConfig >= 3 || sDrawFuncs[this->drawConfig] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.cpp b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.cpp new file mode 100644 index 000000000..0aaa516f4 --- /dev/null +++ b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.cpp @@ -0,0 +1,836 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DEMO_SA_Z_DEMO_SA_C +#include "actor_common.h" +/* + * File: z_demo_sa.c + * Overlay: Demo_Sa + * Description: Saria (Cutscene) + */ + +#include "z_demo_sa.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "objects/object_sa/object_sa.h" + +#include "vt.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void DemoSa_Init(Actor* thisx, GlobalContext* globalCtx); +void DemoSa_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DemoSa_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoSa_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_8098EBB8(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098EBD8(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098EBF8(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098EC28(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098EC60(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098EC94(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098ECCC(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F0E8(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F118(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F16C(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F3F0(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F714(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F734(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F77C(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F7BC(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098F7FC(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098FC44(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098FC64(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098FC9C(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098FCD4(DemoSa* pthis, GlobalContext* globalCtx); +void func_8098FD0C(DemoSa* pthis, GlobalContext* globalCtx); + +void DemoSa_DrawNothing(DemoSa* pthis, GlobalContext* globalCtx); +void DemoSa_DrawOpa(DemoSa* pthis, GlobalContext* globalCtx); +void DemoSa_DrawXlu(DemoSa* pthis, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SARIA_EYE_OPEN, + /* 1 */ SARIA_EYE_HALF, + /* 2 */ SARIA_EYE_CLOSED, + /* 3 */ SARIA_EYE_SUPRISED, + /* 4 */ SARIA_EYE_SAD +} SariaEyeState; + +typedef enum { + /* 0 */ SARIA_MOUTH_CLOSED2, + /* 1 */ SARIA_MOUTH_SUPRISED, + /* 2 */ SARIA_MOUTH_CLOSED, + /* 3 */ SARIA_MOUTH_SMILING_OPEN, + /* 4 */ SARIA_MOUTH_FROWNING +} SariaMouthState; + +static void* sEyeTextures[] = { + gSariaEyeOpenTex, gSariaEyeHalfTex, gSariaEyeClosedTex, gSariaEyeSuprisedTex, gSariaEyeSadTex, +}; + +static void* sMouthTextures[] = { + gSariaMouthClosed2Tex, gSariaMouthSuprisedTex, gSariaMouthClosedTex, + gSariaMouthSmilingOpenTex, gSariaMouthFrowningTex, +}; + +static u32 D_80990108 = 0; + +#include "z_demo_sa_cutscene_data.cpp" EARLY + +static DemoSaActionFunc sActionFuncs[] = { + func_8098EBB8, func_8098EBD8, func_8098EBF8, func_8098EC28, func_8098EC60, func_8098EC94, func_8098ECCC, + func_8098F0E8, func_8098F118, func_8098F16C, func_8098F3F0, func_8098F714, func_8098F734, func_8098F77C, + func_8098F7BC, func_8098F7FC, func_8098FC44, func_8098FC64, func_8098FC9C, func_8098FCD4, func_8098FD0C, +}; + +static DemoSaDrawFunc sDrawFuncs[] = { + DemoSa_DrawNothing, + DemoSa_DrawOpa, + DemoSa_DrawXlu, +}; + +ActorInit Demo_Sa_InitVars = { + ACTOR_DEMO_SA, + ACTORCAT_NPC, + FLAGS, + OBJECT_SA, + sizeof(DemoSa), + (ActorFunc)DemoSa_Init, + (ActorFunc)DemoSa_Destroy, + (ActorFunc)DemoSa_Update, + (ActorFunc)DemoSa_Draw, +}; + +void DemoSa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoSa* pthis = (DemoSa*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); +} + +void func_8098E480(DemoSa* pthis) { + s32 pad[2]; + s16* eyeIndex = &pthis->eyeIndex; + s16* blinkTimer = &pthis->blinkTimer; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(0x3C, 0x3C); + } + + *eyeIndex = *blinkTimer; + if (*eyeIndex >= 3) { + *eyeIndex = 0; + } +} + +void DemoSa_SetEyeIndex(DemoSa* pthis, s16 eyeIndex) { + pthis->eyeIndex = eyeIndex; +} + +void DemoSa_SetMouthIndex(DemoSa* pthis, s16 mouthIndex) { + pthis->mouthIndex = mouthIndex; +} + +void func_8098E530(DemoSa* pthis) { + pthis->action = 7; + pthis->drawConfig = 0; + pthis->alpha = 0; + pthis->unk_1A8 = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_1A0 = 0.0f; +} + +void func_8098E554(DemoSa* pthis, GlobalContext* globalCtx) { + u32* something = &D_80990108; + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + if (*something != 0) { + if (pthis->actor.params == 2) { + func_8098E530(pthis); + } + *something = 0; + } + } else if (*something == 0) { + *something = 1; + } +} + +void func_8098E5C8(DemoSa* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +s32 DemoSa_UpdateSkelAnime(DemoSa* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +CsCmdActorAction* DemoSa_GetNpcAction(GlobalContext* globalCtx, s32 idx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[idx]; + } + return NULL; +} + +s32 func_8098E654(DemoSa* pthis, GlobalContext* globalCtx, u16 arg2, s32 arg3) { + CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, arg3); + + if ((npcAction != NULL) && (npcAction->action == arg2)) { + return 1; + } + return 0; +} + +s32 func_8098E6A0(DemoSa* pthis, GlobalContext* globalCtx, u16 arg2, s32 arg3) { + CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, arg3); + + if ((npcAction != NULL) && (npcAction->action != arg2)) { + return 1; + } + return 0; +} + +void func_8098E6EC(DemoSa* pthis, GlobalContext* globalCtx, s32 actionIdx) { + CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, actionIdx); + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +void func_8098E76C(DemoSa* pthis, AnimationHeader* animHeaderSeg, u8 arg2, f32 transitionRate, s32 arg4) { + s32 pad[2]; + f32 frameCount = Animation_GetLastFrame(animHeaderSeg); + f32 playbackSpeed; + f32 unk0; + f32 fc; + + if (arg4 == 0) { + unk0 = 0.0f; + fc = frameCount; + playbackSpeed = 1.0f; + } else { + fc = 0.0f; + unk0 = frameCount; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animHeaderSeg, playbackSpeed, unk0, fc, arg2, transitionRate); +} + +void func_8098E7FC(DemoSa* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSariaSkel, &gSariaWaitArmsToSideAnim, NULL, NULL, 0); + pthis->actor.shape.yOffset = -10000.0f; + DemoSa_SetEyeIndex(pthis, SARIA_EYE_HALF); + DemoSa_SetMouthIndex(pthis, SARIA_MOUTH_CLOSED2); +} + +void func_8098E86C(DemoSa* pthis, GlobalContext* globalCtx) { + Vec3f* world = &pthis->actor.world.pos; + f32 posX = world->x; + f32 posY = world->y; + f32 posZ = world->z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, + WARP_SAGES); +} + +void func_8098E8C8(DemoSa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 posX = player->actor.world.pos.x; + f32 posY = player->actor.world.pos.y + 80.0f; + f32 posZ = player->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, + 0xB); + Item_Give(globalCtx, ITEM_MEDALLION_FOREST); +} + +void func_8098E944(DemoSa* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.yOffset += (250.0f / 3.0f); +} + +void func_8098E960(DemoSa* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + + if ((gSaveContext.chamberCutsceneNum == 0) && (gSaveContext.sceneSetupIndex < 4)) { + player = GET_PLAYER(globalCtx); + pthis->action = 1; + globalCtx->csCtx.segment = D_8099010C; + gSaveContext.cutsceneTrigger = 2; + Item_Give(globalCtx, ITEM_MEDALLION_FOREST); + player->actor.world.rot.y = player->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + } +} + +void func_8098E9EC(DemoSa* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + npcAction = globalCtx->csCtx.npcActions[4]; + if ((npcAction != NULL) && (npcAction->action == 2)) { + pthis->action = 2; + pthis->drawConfig = 1; + func_8098E86C(pthis, globalCtx); + } + } +} + +void func_8098EA3C(DemoSa* pthis) { + if (pthis->actor.shape.yOffset >= 0.0f) { + pthis->action = 3; + pthis->actor.shape.yOffset = 0.0f; + } +} + +void func_8098EA68(DemoSa* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + npcAction = globalCtx->csCtx.npcActions[4]; + if ((npcAction != NULL) && (npcAction->action == 3)) { + Animation_Change(&pthis->skelAnime, &gSariaGiveForestMedallionAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gSariaGiveForestMedallionAnim), ANIMMODE_ONCE, -4.0f); + pthis->action = 4; + } + } +} + +void func_8098EB00(DemoSa* pthis, s32 arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gSariaGiveForestMedallionStandAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gSariaGiveForestMedallionStandAnim), ANIMMODE_LOOP, 0.0f); + pthis->action = 5; + } +} + +void func_8098EB6C(DemoSa* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + npcAction = globalCtx->csCtx.npcActions[6]; + if ((npcAction != NULL) && (npcAction->action == 2)) { + pthis->action = 6; + func_8098E8C8(pthis, globalCtx); + } + } +} + +void func_8098EBB8(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E960(pthis, globalCtx); +} + +void func_8098EBD8(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E9EC(pthis, globalCtx); +} + +void func_8098EBF8(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E944(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098EA3C(pthis); +} + +void func_8098EC28(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098EA68(pthis, globalCtx); +} + +void func_8098EC60(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + func_8098EB00(pthis, DemoSa_UpdateSkelAnime(pthis)); +} + +void func_8098EC94(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098EB6C(pthis, globalCtx); +} + +void func_8098ECCC(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); +} + +void func_8098ECF4(DemoSa* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSariaSealGanonAnim); + + SkelAnime_InitFlex(globalCtx, skelAnime, &gSariaSkel, NULL, NULL, NULL, 0); + Animation_Change(skelAnime, &gSariaSealGanonAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + pthis->action = 7; + pthis->actor.shape.shadowAlpha = 0; + DemoSa_SetEyeIndex(pthis, SARIA_EYE_CLOSED); + DemoSa_SetMouthIndex(pthis, SARIA_MOUTH_CLOSED); +} + +void func_8098EDB0(DemoSa* pthis) { + f32 curFrame = pthis->skelAnime.curFrame; + + if ((pthis->skelAnime.mode == 2) && (curFrame >= 32.0f)) { + DemoSa_SetEyeIndex(pthis, SARIA_EYE_HALF); + DemoSa_SetMouthIndex(pthis, SARIA_MOUTH_CLOSED2); + } +} + +void func_8098EE08(void) { + func_800788CC(NA_SE_SY_WHITE_OUT_T); +} + +void func_8098EE28(DemoSa* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + (kREG(23) + 25.0f) + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 4); +} + +void func_8098EEA8(DemoSa* pthis, GlobalContext* globalCtx) { + if (func_8098E654(pthis, globalCtx, 4, 4)) { + pthis->action = 8; + pthis->drawConfig = 2; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_1A0 = 0.0f; + func_8098EE08(); + } +} + +void func_8098EEFC(DemoSa* pthis, GlobalContext* globalCtx) { + s32 alpha = 255; + f32* unk_1A0 = &pthis->unk_1A0; + + if (func_8098E654(pthis, globalCtx, 4, 4)) { + *unk_1A0 += 1.0f; + if ((kREG(5) + 10.0f) <= *unk_1A0) { + pthis->action = 9; + pthis->drawConfig = 1; + *unk_1A0 = kREG(5) + 10.0f; + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; + return; + } + } else { + *unk_1A0 -= 1.0f; + if (*unk_1A0 <= 0.0f) { + pthis->action = 7; + pthis->drawConfig = 0; + *unk_1A0 = 0.0f; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + return; + } + } + pthis->actor.shape.shadowAlpha = pthis->alpha = (*unk_1A0 / (kREG(5) + 10.0f)) * 255.0f; +} + +void func_8098F050(DemoSa* pthis, GlobalContext* globalCtx) { + if (func_8098E6A0(pthis, globalCtx, 4, 4)) { + pthis->action = 8; + pthis->drawConfig = 2; + pthis->unk_1A0 = kREG(5) + 10.0f; + pthis->alpha = 255; + if (pthis->unk_1A8 == 0) { + func_8098EE28(pthis, globalCtx); + pthis->unk_1A8 = 1; + } + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_8098F0E8(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098EEA8(pthis, globalCtx); + func_8098E554(pthis, globalCtx); +} + +void func_8098F118(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098E480(pthis); + func_8098EEFC(pthis, globalCtx); + func_8098E554(pthis, globalCtx); +} + +void func_8098F16C(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098EDB0(pthis); + func_8098F050(pthis, globalCtx); + func_8098E554(pthis, globalCtx); +} + +void DemoSa_DrawXlu(DemoSa* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeIndex = pthis->eyeIndex; + void* sp78 = sEyeTextures[eyeIndex]; + s16 mouthIndex = pthis->mouthIndex; + s32 pad2; + void* sp6C = sMouthTextures[mouthIndex]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa_inKenjyanomaDemo02.c", 296); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sp78)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sp78)); + gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sp6C)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + NULL, NULL, NULL, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa_inKenjyanomaDemo02.c", 325); +} + +void func_8098F390(DemoSa* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSariaSkel, &gSariaWaitArmsToSideAnim, NULL, NULL, 0); + pthis->action = 10; + pthis->drawConfig = 1; +} + +void func_8098F3F0(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098E480(pthis); +} + +void func_8098F420(DemoSa* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSariaSkel, &gSariaSitting3Anim, NULL, NULL, 0); + pthis->action = 11; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_8098F480(DemoSa* pthis) { + s32 alpha = 255; + f32* unk_1A0 = &pthis->unk_1A0; + f32 temp_f0; + + *unk_1A0 += 1.0f; + temp_f0 = kREG(17) + 10.0f; + + if (temp_f0 <= *unk_1A0) { + pthis->actor.shape.shadowAlpha = pthis->alpha = alpha; + } else { + pthis->actor.shape.shadowAlpha = pthis->alpha = (*unk_1A0 / temp_f0) * 255.0f; + } +} + +void func_8098F50C(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E6EC(pthis, globalCtx, 4); + pthis->action = 12; + pthis->drawConfig = 2; +} + +void func_8098F544(DemoSa* pthis) { + if (pthis->unk_1A0 >= kREG(17) + 10.0f) { + pthis->action = 13; + pthis->drawConfig = 1; + } +} + +void func_8098F590(DemoSa* pthis) { + func_8098E76C(pthis, &gSariaSitting1Anim, 2, -8.0f, 0); + pthis->action = 14; +} + +void func_8098F5D0(DemoSa* pthis) { + func_8098E76C(pthis, &gSariaSitting2Anim, 2, 0.0f, 0); + pthis->action = 15; +} + +void func_8098F610(DemoSa* pthis, s32 arg1) { + if (arg1 != 0) { + func_8098E76C(pthis, &gSariaSitting3Anim, 0, 0.0f, 0); + pthis->action = 13; + } +} + +void func_8098F654(DemoSa* pthis, GlobalContext* globalCtx) { + s32 unk_1AC; + s32 action; + CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, 4); + + if (npcAction != NULL) { + action = npcAction->action; + unk_1AC = pthis->unk_1AC; + if (action != unk_1AC) { + switch (action) { + case 7: + func_8098F50C(pthis, globalCtx); + break; + case 8: + func_8098F590(pthis); + break; + case 9: + func_8098F5D0(pthis); + break; + default: + osSyncPrintf("Demo_Sa_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_1AC = action; + } + } +} + +void func_8098F714(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098F654(pthis, globalCtx); +} + +void func_8098F734(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098E480(pthis); + func_8098F480(pthis); + func_8098F544(pthis); +} + +void func_8098F77C(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098E480(pthis); + func_8098F654(pthis, globalCtx); +} + +void func_8098F7BC(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098E480(pthis); + func_8098F654(pthis, globalCtx); +} + +void func_8098F7FC(DemoSa* pthis, GlobalContext* globalCtx) { + s32 sp1C; + + func_8098E5C8(pthis, globalCtx); + sp1C = DemoSa_UpdateSkelAnime(pthis); + func_8098E480(pthis); + func_8098F610(pthis, sp1C); +} + +void func_8098F83C(DemoSa* pthis, GlobalContext* globalCtx) { + Vec3f* thisPos = &pthis->actor.world.pos; + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSariaSkel, &gSariaWaitOnBridgeAnim, NULL, NULL, 0); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ELF, thisPos->x, thisPos->y, thisPos->z, + 0, 0, 0, FAIRY_KOKIRI); + pthis->action = 16; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; + DemoSa_SetEyeIndex(pthis, SARIA_EYE_SAD); + DemoSa_SetMouthIndex(pthis, SARIA_MOUTH_CLOSED); +} + +void func_8098F8F8(DemoSa* pthis) { + s32 alpha = 255; + f32* unk_1A0 = &pthis->unk_1A0; + f32 temp_f0; + + *unk_1A0 += 1.0f; + temp_f0 = kREG(17) + 10.0f; + + if (temp_f0 <= *unk_1A0) { + pthis->actor.shape.shadowAlpha = pthis->alpha = alpha; + } else { + pthis->actor.shape.shadowAlpha = pthis->alpha = (*unk_1A0 / temp_f0) * 255.0f; + } +} + +void func_8098F984(DemoSa* pthis) { + pthis->action = 16; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_8098F998(DemoSa* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1AC == 4) { + func_8098E6EC(pthis, globalCtx, 1); + pthis->action = 17; + pthis->drawConfig = 2; + pthis->unk_1B0 = 0; + pthis->actor.shape.shadowAlpha = 0; + } else { + func_8098E76C(pthis, &gSariaWaitOnBridgeAnim, 0, 0.0f, 0); + pthis->action = 18; + pthis->drawConfig = 1; + pthis->unk_1B0 = 0; + pthis->actor.shape.shadowAlpha = 0xFF; + } + DemoSa_SetEyeIndex(pthis, SARIA_EYE_SAD); +} + +void func_8098FA2C(DemoSa* pthis) { + if (pthis->unk_1A0 >= kREG(17) + 10.0f) { + pthis->action = 18; + pthis->drawConfig = 1; + pthis->unk_1B0 = 0; + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_8098FA84(DemoSa* pthis) { + func_8098E76C(pthis, &gSariaHoldOcarinaAnim, 0, 0.0f, 0); + pthis->action = 19; + pthis->drawConfig = 1; + pthis->unk_1B0 = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + DemoSa_SetEyeIndex(pthis, SARIA_EYE_CLOSED); +} + +void func_8098FAE0(DemoSa* pthis) { + func_8098E76C(pthis, &gSariaGiveLinkOcarinaAnim, 2, -8.0f, 0); + pthis->action = 20; + pthis->drawConfig = 1; + pthis->unk_1B0 = 1; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_8098FB34(DemoSa* pthis, s32 arg1) { + if (arg1 != 0) { + func_8098E76C(pthis, &gSariaHoldOutOcarinaAnim, 0, 0, 0); + } +} + +void func_8098FB68(DemoSa* pthis, GlobalContext* globalCtx) { + s32 unk_1AC; + s32 action; + CsCmdActorAction* npcAction = DemoSa_GetNpcAction(globalCtx, 1); + + if (npcAction != NULL) { + action = npcAction->action; + unk_1AC = pthis->unk_1AC; + if (action != unk_1AC) { + switch (action) { + case 4: + func_8098F984(pthis); + break; + case 12: + func_8098F998(pthis, globalCtx); + break; + case 13: + func_8098FA84(pthis); + break; + case 14: + func_8098FAE0(pthis); + break; + default: + osSyncPrintf("Demo_Sa_inPresent_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_1AC = action; + } + } +} + +void func_8098FC44(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098FB68(pthis, globalCtx); +} + +void func_8098FC64(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098F8F8(pthis); + func_8098FA2C(pthis); +} + +void func_8098FC9C(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098FB68(pthis, globalCtx); +} + +void func_8098FCD4(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + DemoSa_UpdateSkelAnime(pthis); + func_8098FB68(pthis, globalCtx); +} + +void func_8098FD0C(DemoSa* pthis, GlobalContext* globalCtx) { + func_8098E5C8(pthis, globalCtx); + func_8098FB34(pthis, DemoSa_UpdateSkelAnime(pthis)); + func_8098FB68(pthis, globalCtx); +} + +void DemoSa_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoSa* pthis = (DemoSa*)thisx; + + if (pthis->action < 0 || pthis->action >= 21 || sActionFuncs[pthis->action] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void DemoSa_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoSa* pthis = (DemoSa*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + + switch (pthis->actor.params) { + case 2: + func_8098ECF4(pthis, globalCtx); + break; + case 3: + func_8098F390(pthis, globalCtx); + break; + case 4: + func_8098F420(pthis, globalCtx); + break; + case 5: + func_8098F83C(pthis, globalCtx); + break; + default: + func_8098E7FC(pthis, globalCtx); + } +} + +s32 DemoSa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + DemoSa* pthis = (DemoSa*)thisx; + + if ((limbIndex == 15) && (pthis->unk_1B0 != 0)) { + *dList = gSariaRightHandAndOcarinaDL; + } + return false; +} + +void DemoSa_DrawNothing(DemoSa* pthis, GlobalContext* globalCtx) { +} + +void DemoSa_DrawOpa(DemoSa* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeIndex = pthis->eyeIndex; + void* eyeTex = sEyeTextures[eyeIndex]; + s32 pad2; + s16 mouthIndex = pthis->mouthIndex; + void* mouthTex = sMouthTextures[mouthIndex]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa.c", 602); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + DemoSa_OverrideLimbDraw, NULL, &pthis->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_sa.c", 626); +} + +void DemoSa_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoSa* pthis = (DemoSa*)thisx; + + if (pthis->drawConfig < 0 || pthis->drawConfig >= 3 || sDrawFuncs[pthis->drawConfig] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa_cutscene_data.c b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_Demo_Sa/z_demo_sa_cutscene_data.c rename to src/overlays/actors/ovl_Demo_Sa/z_demo_sa_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.cpp similarity index 72% rename from src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c rename to src/overlays/actors/ovl_Demo_Shd/z_demo_shd.cpp index 6dd29a91b..88269f640 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.cpp @@ -19,9 +19,9 @@ void DemoShd_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoShd_Update(Actor* thisx, GlobalContext* globalCtx); void DemoShd_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80991298(DemoShd* this, GlobalContext* globalCtx); +void func_80991298(DemoShd* pthis, GlobalContext* globalCtx); -const ActorInit Demo_Shd_InitVars = { +ActorInit Demo_Shd_InitVars = { ACTOR_DEMO_SHD, ACTORCAT_ITEMACTION, FLAGS, @@ -33,26 +33,26 @@ const ActorInit Demo_Shd_InitVars = { (ActorFunc)DemoShd_Draw, }; -#include "overlays/ovl_Demo_Shd/ovl_Demo_Shd.c" +#include "overlays/ovl_Demo_Shd/ovl_Demo_Shd.cpp" -void DemoShd_SetupAction(DemoShd* this, DemoShdActionFunc actionFunc) { - this->actionFunc = actionFunc; +void DemoShd_SetupAction(DemoShd* pthis, DemoShdActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void DemoShd_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoShd* this = (DemoShd*)thisx; + DemoShd* pthis = (DemoShd*)thisx; - this->unk_14C = 0; - DemoShd_SetupAction(this, func_80991298); - Actor_SetScale(&this->actor, 0.4f); - this->actor.world.pos.y = 0.0f; - this->actor.world.pos.x = 0.0f; + pthis->unk_14C = 0; + DemoShd_SetupAction(pthis, func_80991298); + Actor_SetScale(&pthis->actor, 0.4f); + pthis->actor.world.pos.y = 0.0f; + pthis->actor.world.pos.x = 0.0f; } void DemoShd_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80991298(DemoShd* this, GlobalContext* globalCtx) { +void func_80991298(DemoShd* pthis, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[0] != NULL) || (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[1] != NULL)) { if (globalCtx->csCtx.frames == 800) { @@ -68,12 +68,12 @@ void func_80991298(DemoShd* this, GlobalContext* globalCtx) { if (npcAction0 != NULL) { if (npcAction0->action == 2) { - if (!(this->unk_14C & 1)) { - this->unk_14E = npcAction0->startPos.x; + if (!(pthis->unk_14C & 1)) { + pthis->unk_14E = npcAction0->startPos.x; } - this->unk_14C |= 1; + pthis->unk_14C |= 1; } else { - this->unk_14C &= ~1; + pthis->unk_14C &= ~1; } } } @@ -83,29 +83,29 @@ void func_80991298(DemoShd* this, GlobalContext* globalCtx) { if (npcAction1 != NULL) { if (npcAction1->action == 2) { - if (!(this->unk_14C & 2)) { - this->unk_14E = npcAction1->startPos.x; + if (!(pthis->unk_14C & 2)) { + pthis->unk_14E = npcAction1->startPos.x; } - this->unk_14C |= 2; + pthis->unk_14C |= 2; } else { - this->unk_14C &= ~2; + pthis->unk_14C &= ~2; } } } - this->unk_14E++; + pthis->unk_14E++; } void DemoShd_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoShd* this = (DemoShd*)thisx; + DemoShd* pthis = (DemoShd*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void DemoShd_Draw(Actor* thisx, GlobalContext* globalCtx) { - DemoShd* this = (DemoShd*)thisx; + DemoShd* pthis = (DemoShd*)thisx; s32 pad; - u32 unk_14E = this->unk_14E; + u32 unk_14E = pthis->unk_14E; if (1) {} // Necessary to match, can be anywhere in the function @@ -117,11 +117,11 @@ void DemoShd_Draw(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_809932D0); - if (this->unk_14C & 1) { + if (pthis->unk_14C & 1) { gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0x3FF - ((unk_14E * 5) & 0x3FF), 16, 256, 1, 0, 255 - ((unk_14E * 5) & 255), 32, 32)); gSPDisplayList(POLY_XLU_DISP++, D_80993390); - } else if (this->unk_14C & 2) { + } else if (pthis->unk_14C & 2) { gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0x3FF - ((unk_14E * 5) & 0x3FF), 16, 256, 1, 0, 255 - ((unk_14E * 5) & 255), 32, 32)); gSPDisplayList(POLY_XLU_DISP++, D_809934B8); diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.cpp similarity index 66% rename from src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c rename to src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.cpp index 36ed851d0..63400c035 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.cpp @@ -17,10 +17,10 @@ void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80993848(DemoTreLgt* this, GlobalContext* globalCtx); -void func_80993754(DemoTreLgt* this); -void func_8099375C(DemoTreLgt* this, GlobalContext* globalCtx); -void func_809937B4(DemoTreLgt* this, GlobalContext* globalCtx, f32 currentFrame); +void func_80993848(DemoTreLgt* pthis, GlobalContext* globalCtx); +void func_80993754(DemoTreLgt* pthis); +void func_8099375C(DemoTreLgt* pthis, GlobalContext* globalCtx); +void func_809937B4(DemoTreLgt* pthis, GlobalContext* globalCtx, f32 currentFrame); typedef struct { /* 0x00 */ f32 startFrame; @@ -34,7 +34,7 @@ static DemoTreLgtInfo sDemoTreLgtInfo[] = { { 1.0f, 136.0f, 220.0f, 50.0f }, }; -const ActorInit Demo_Tre_Lgt_InitVars = { +ActorInit Demo_Tre_Lgt_InitVars = { ACTOR_DEMO_TRE_LGT, ACTORCAT_ITEMACTION, FLAGS, @@ -54,44 +54,44 @@ static DemoTreLgtActionFunc sActionFuncs[] = { }; void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx) { - DemoTreLgt* this = (DemoTreLgt*)thisx; + DemoTreLgt* pthis = (DemoTreLgt*)thisx; - if (!SkelCurve_Init(globalCtx, &this->skelCurve, &gTreasureChestCurveSkel, sTransformUpdIdx[0])) { + if (!SkelCurve_Init(globalCtx, &pthis->skelCurve, &gTreasureChestCurveSkel, sTransformUpdIdx[0])) { // "Demo_Tre_Lgt_Actor_ct (); Construct failed" osSyncPrintf("Demo_Tre_Lgt_Actor_ct();コンストラクト失敗\n"); } ASSERT(true, "1", "../z_demo_tre_lgt.c", UNK_LINE); - this->unk_170 = 255; - this->unk_174 = 255; - this->status = 0; - func_80993754(this); + pthis->unk_170 = 255; + pthis->unk_174 = 255; + pthis->status = 0; + func_80993754(pthis); } void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DemoTreLgt* this = (DemoTreLgt*)thisx; + DemoTreLgt* pthis = (DemoTreLgt*)thisx; - SkelCurve_Destroy(globalCtx, &this->skelCurve); + SkelCurve_Destroy(globalCtx, &pthis->skelCurve); } -void func_80993754(DemoTreLgt* this) { - this->action = DEMO_TRE_LGT_ACTION_WAIT; +void func_80993754(DemoTreLgt* pthis) { + pthis->action = DEMO_TRE_LGT_ACTION_WAIT; } -void func_8099375C(DemoTreLgt* this, GlobalContext* globalCtx) { - EnBox* treasureChest = (EnBox*)this->actor.parent; +void func_8099375C(DemoTreLgt* pthis, GlobalContext* globalCtx) { + EnBox* treasureChest = (EnBox*)pthis->actor.parent; if (treasureChest != NULL && Animation_OnFrame(&treasureChest->skelanime, 10.0f)) { - func_809937B4(this, globalCtx, treasureChest->skelanime.curFrame); + func_809937B4(pthis, globalCtx, treasureChest->skelanime.curFrame); } } -void func_809937B4(DemoTreLgt* this, GlobalContext* globalCtx, f32 currentFrame) { - SkelAnimeCurve* skelCurve = &this->skelCurve; +void func_809937B4(DemoTreLgt* pthis, GlobalContext* globalCtx, f32 currentFrame) { + SkelAnimeCurve* skelCurve = &pthis->skelCurve; s32 pad[2]; - this->action = DEMO_TRE_LGT_ACTION_ANIMATE; + pthis->action = DEMO_TRE_LGT_ACTION_ANIMATE; SkelCurve_SetAnim(skelCurve, sTransformUpdIdx[gSaveContext.linkAge], 1.0f, sDemoTreLgtInfo[gSaveContext.linkAge].endFrame + sDemoTreLgtInfo[gSaveContext.linkAge].unk_08, @@ -99,49 +99,49 @@ void func_809937B4(DemoTreLgt* this, GlobalContext* globalCtx, f32 currentFrame) SkelCurve_Update(globalCtx, skelCurve); } -void func_80993848(DemoTreLgt* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelCurve.animCurFrame; +void func_80993848(DemoTreLgt* pthis, GlobalContext* globalCtx) { + f32 currentFrame = pthis->skelCurve.animCurFrame; if (currentFrame < sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].endFrame) { - this->unk_170 = 255; + pthis->unk_170 = 255; } else { if (currentFrame <= (sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].endFrame + sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].unk_08)) { - this->unk_170 = ((((sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].endFrame - currentFrame) / + pthis->unk_170 = ((((sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].endFrame - currentFrame) / sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].unk_08) * 255.0f) + 255.0f); } else { - this->unk_170 = 0; + pthis->unk_170 = 0; } } if (currentFrame < sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].unk_0C) { - this->unk_174 = 255; + pthis->unk_174 = 255; } else if (currentFrame < (sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].unk_0C + 10.0f)) { - this->unk_174 = + pthis->unk_174 = ((((sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].unk_0C - currentFrame) / 10.0f) * 255.0f) + 255.0f); } else { - this->unk_174 = 0; + pthis->unk_174 = 0; } - if ((currentFrame > 30.0f) && !(this->status & 1)) { - this->status |= 1; - Audio_PlaySoundGeneral(NA_SE_EV_TRE_BOX_FLASH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + if ((currentFrame > 30.0f) && !(pthis->status & 1)) { + pthis->status |= 1; + Audio_PlaySoundGeneral(NA_SE_EV_TRE_BOX_FLASH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - if (SkelCurve_Update(globalCtx, &this->skelCurve)) { - Actor_Kill(&this->actor); + if (SkelCurve_Update(globalCtx, &pthis->skelCurve)) { + Actor_Kill(&pthis->actor); } } void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { - DemoTreLgt* this = (DemoTreLgt*)thisx; + DemoTreLgt* pthis = (DemoTreLgt*)thisx; - sActionFuncs[this->action](this, globalCtx); + sActionFuncs[pthis->action](pthis, globalCtx); } s32 DemoTreLgt_PostLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) { s32 pad; - DemoTreLgt* this = (DemoTreLgt*)thisx; + DemoTreLgt* pthis = (DemoTreLgt*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo_tre_lgt.c", 423); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -149,9 +149,9 @@ s32 DemoTreLgt_PostLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, (globalCtx->state.frames * -2) % 256, 0, 64, 32)); if (limbIndex == 1) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->unk_170); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, pthis->unk_170); } else if ((limbIndex == 13) || (limbIndex == 7) || (limbIndex == 4) || (limbIndex == 10)) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->unk_174); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, pthis->unk_174); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_tre_lgt.c", 448); @@ -160,17 +160,17 @@ s32 DemoTreLgt_PostLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - DemoTreLgt* this = (DemoTreLgt*)thisx; + DemoTreLgt* pthis = (DemoTreLgt*)thisx; OPEN_DISPS(gfxCtx, "../z_demo_tre_lgt.c", 461); - if (this->action != DEMO_TRE_LGT_ACTION_ANIMATE) { + if (pthis->action != DEMO_TRE_LGT_ACTION_ANIMATE) { return; } func_80093D84(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); - SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_PostLimbDraw, NULL, 1, thisx); + SkelCurve_Draw(&pthis->actor, globalCtx, &pthis->skelCurve, DemoTreLgt_PostLimbDraw, NULL, 1, thisx); CLOSE_DISPS(gfxCtx, "../z_demo_tre_lgt.c", 476); } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.cpp similarity index 54% rename from src/overlays/actors/ovl_Door_Ana/z_door_ana.c rename to src/overlays/actors/ovl_Door_Ana/z_door_ana.cpp index befab40df..5835aed0c 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.cpp @@ -27,11 +27,11 @@ void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx); void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx); -void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx); -void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx); -void DoorAna_GrabPlayer(DoorAna* this, GlobalContext* globalCtx); +void DoorAna_WaitClosed(DoorAna* pthis, GlobalContext* globalCtx); +void DoorAna_WaitOpen(DoorAna* pthis, GlobalContext* globalCtx); +void DoorAna_GrabPlayer(DoorAna* pthis, GlobalContext* globalCtx); -const ActorInit Door_Ana_InitVars = { +ActorInit Door_Ana_InitVars = { ACTOR_DOOR_ANA, ACTORCAT_ITEMACTION, FLAGS, @@ -69,120 +69,120 @@ static s16 entrances[] = { 0x05B0, 0x05B4, 0x05B8, 0x05BC, 0x05C0, 0x05C4, 0x05FC, }; -void DoorAna_SetupAction(DoorAna* this, DoorAnaActionFunc actionFunc) { - this->actionFunc = actionFunc; +void DoorAna_SetupAction(DoorAna* pthis, DoorAnaActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { - DoorAna* this = (DoorAna*)thisx; + DoorAna* pthis = (DoorAna*)thisx; - this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = this->actor.shape.rot.z; + pthis->actor.shape.rot.z = 0; + pthis->actor.shape.rot.y = pthis->actor.shape.rot.z; // init block for grottos that are initially "hidden" (require explosives/hammer/song of storms to open) - if ((this->actor.params & 0x300) != 0) { + if ((pthis->actor.params & 0x300) != 0) { // only allocate collider for grottos that need bombing/hammering open - if ((this->actor.params & 0x200) != 0) { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if ((pthis->actor.params & 0x200) != 0) { + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); } else { - this->actor.flags |= ACTOR_FLAG_4; + pthis->actor.flags |= ACTOR_FLAG_4; } - Actor_SetScale(&this->actor, 0); - DoorAna_SetupAction(this, DoorAna_WaitClosed); + Actor_SetScale(&pthis->actor, 0); + DoorAna_SetupAction(pthis, DoorAna_WaitClosed); } else { - DoorAna_SetupAction(this, DoorAna_WaitOpen); + DoorAna_SetupAction(pthis, DoorAna_WaitOpen); } - this->actor.targetMode = 0; + pthis->actor.targetMode = 0; } void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DoorAna* this = (DoorAna*)thisx; + DoorAna* pthis = (DoorAna*)thisx; // free collider if it has one - if ((this->actor.params & 0x200) != 0) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if ((pthis->actor.params & 0x200) != 0) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } // update routine for grottos that are currently "hidden"/unopened -void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { +void DoorAna_WaitClosed(DoorAna* pthis, GlobalContext* globalCtx) { u32 openGrotto = false; - if (!(this->actor.params & 0x200)) { + if (!(pthis->actor.params & 0x200)) { // opening with song of storms - if (this->actor.xyzDistToPlayerSq < 40000.0f && Flags_GetEnv(globalCtx, 5)) { + if (pthis->actor.xyzDistToPlayerSq < 40000.0f && Flags_GetEnv(globalCtx, 5)) { openGrotto = true; - this->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.flags &= ~ACTOR_FLAG_4; } } else { // bombing/hammering open a grotto - if (this->collider.base.acFlags & AC_HIT) { + if (pthis->collider.base.acFlags & AC_HIT) { openGrotto = true; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } // open the grotto if (openGrotto) { - this->actor.params &= ~0x0300; - DoorAna_SetupAction(this, DoorAna_WaitOpen); + pthis->actor.params &= ~0x0300; + DoorAna_SetupAction(pthis, DoorAna_WaitOpen); Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - func_8002F5F0(&this->actor, globalCtx); + func_8002F5F0(&pthis->actor, globalCtx); } // update routine for grottos that are open -void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { +void DoorAna_WaitOpen(DoorAna* pthis, GlobalContext* globalCtx) { Player* player; s32 destinationIdx; player = GET_PLAYER(globalCtx); - if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { - if ((this->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (player->stateFlags1 & 0x80000000) && + if (Math_StepToF(&pthis->actor.scale.x, 0.01f, 0.001f)) { + if ((pthis->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (player->stateFlags1 & 0x80000000) && (player->unk_84F == 0)) { - destinationIdx = ((this->actor.params >> 0xC) & 7) - 1; + destinationIdx = ((pthis->actor.params >> 0xC) & 7) - 1; Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_RETURN, 0x4FF); - gSaveContext.respawn[RESPAWN_MODE_RETURN].pos.y = this->actor.world.pos.y; - gSaveContext.respawn[RESPAWN_MODE_RETURN].yaw = this->actor.home.rot.y; - gSaveContext.respawn[RESPAWN_MODE_RETURN].data = this->actor.params & 0xFFFF; + gSaveContext.respawn[RESPAWN_MODE_RETURN].pos.y = pthis->actor.world.pos.y; + gSaveContext.respawn[RESPAWN_MODE_RETURN].yaw = pthis->actor.home.rot.y; + gSaveContext.respawn[RESPAWN_MODE_RETURN].data = pthis->actor.params & 0xFFFF; if (destinationIdx < 0) { - destinationIdx = this->actor.home.rot.z + 1; + destinationIdx = pthis->actor.home.rot.z + 1; } globalCtx->nextEntranceIndex = entrances[destinationIdx]; - DoorAna_SetupAction(this, DoorAna_GrabPlayer); + DoorAna_SetupAction(pthis, DoorAna_GrabPlayer); } else { if (!Player_InCsMode(globalCtx) && !(player->stateFlags1 & 0x8800000) && - this->actor.xzDistToPlayer <= 15.0f && -50.0f <= this->actor.yDistToPlayer && - this->actor.yDistToPlayer <= 15.0f) { + pthis->actor.xzDistToPlayer <= 15.0f && -50.0f <= pthis->actor.yDistToPlayer && + pthis->actor.yDistToPlayer <= 15.0f) { player->stateFlags1 |= 0x80000000; - this->actor.targetMode = 1; + pthis->actor.targetMode = 1; } else { - this->actor.targetMode = 0; + pthis->actor.targetMode = 0; } } } - Actor_SetScale(&this->actor, this->actor.scale.x); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); } // update function for after the player has triggered the grotto -void DoorAna_GrabPlayer(DoorAna* this, GlobalContext* globalCtx) { +void DoorAna_GrabPlayer(DoorAna* pthis, GlobalContext* globalCtx) { Player* player; - if (this->actor.yDistToPlayer <= 0.0f && 15.0f < this->actor.xzDistToPlayer) { + if (pthis->actor.yDistToPlayer <= 0.0f && 15.0f < pthis->actor.xzDistToPlayer) { player = GET_PLAYER(globalCtx); - player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 15.0f + this->actor.world.pos.x; - player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 15.0f + this->actor.world.pos.z; + player->actor.world.pos.x = Math_SinS(pthis->actor.yawTowardsPlayer) * 15.0f + pthis->actor.world.pos.x; + player->actor.world.pos.z = Math_CosS(pthis->actor.yawTowardsPlayer) * 15.0f + pthis->actor.world.pos.z; } } void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { - DoorAna* this = (DoorAna*)thisx; + DoorAna* pthis = (DoorAna*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); // changes the grottos facing angle based on camera angle - this->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + pthis->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.c b/src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.cpp similarity index 59% rename from src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.c rename to src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.cpp index e6e860d0c..64ecd451e 100644 --- a/src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.c +++ b/src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.cpp @@ -23,12 +23,12 @@ void DoorGerudo_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorGerudo_Update(Actor* thisx, GlobalContext* globalCtx); void DoorGerudo_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8099485C(DoorGerudo* this, GlobalContext* globalCtx); -s32 func_80994750(DoorGerudo* this, GlobalContext* globalCtx); -void func_8099496C(DoorGerudo* this, GlobalContext* globalCtx); -void func_809949C8(DoorGerudo* this, GlobalContext* globalCtx); +void func_8099485C(DoorGerudo* pthis, GlobalContext* globalCtx); +s32 func_80994750(DoorGerudo* pthis, GlobalContext* globalCtx); +void func_8099496C(DoorGerudo* pthis, GlobalContext* globalCtx); +void func_809949C8(DoorGerudo* pthis, GlobalContext* globalCtx); -const ActorInit Door_Gerudo_InitVars = { +ActorInit Door_Gerudo_InitVars = { ACTOR_DOOR_GERUDO, ACTORCAT_ITEMACTION, FLAGS, @@ -46,29 +46,29 @@ static InitChainEntry sInitChain[] = { void DoorGerudo_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DoorGerudo* this = (DoorGerudo*)thisx; + DoorGerudo* pthis = (DoorGerudo*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); CollisionHeader_GetVirtual(&gGerudoCellDoorCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); if (Flags_GetSwitch(globalCtx, thisx->params & 0x3F)) { - this->actionFunc = func_8099485C; + pthis->actionFunc = func_8099485C; thisx->world.pos.y = thisx->home.pos.y + 200.0f; } else { - this->actionFunc = func_8099485C; - this->unk_166 = 10; + pthis->actionFunc = func_8099485C; + pthis->unk_166 = 10; } } void DoorGerudo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DoorGerudo* this = (DoorGerudo*)thisx; + DoorGerudo* pthis = (DoorGerudo*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -f32 func_809946BC(GlobalContext* globalCtx, DoorGerudo* this, f32 arg2, f32 arg3, f32 arg4) { +f32 func_809946BC(GlobalContext* globalCtx, DoorGerudo* pthis, f32 arg2, f32 arg3, f32 arg4) { Player* player = GET_PLAYER(globalCtx); Vec3f playerPos; Vec3f sp1C; @@ -76,7 +76,7 @@ f32 func_809946BC(GlobalContext* globalCtx, DoorGerudo* this, f32 arg2, f32 arg3 playerPos.x = player->actor.world.pos.x; playerPos.y = player->actor.world.pos.y + arg2; playerPos.z = player->actor.world.pos.z; - func_8002DBD0(&this->dyna.actor, &sp1C, &playerPos); + func_8002DBD0(&pthis->dyna.actor, &sp1C, &playerPos); if ((arg3 < fabsf(sp1C.x)) || (arg4 < fabsf(sp1C.y))) { return FLT_MAX; @@ -85,15 +85,15 @@ f32 func_809946BC(GlobalContext* globalCtx, DoorGerudo* this, f32 arg2, f32 arg3 } } -s32 func_80994750(DoorGerudo* this, GlobalContext* globalCtx) { +s32 func_80994750(DoorGerudo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 temp_f0; s16 rotYDiff; if (!Player_InCsMode(globalCtx)) { - temp_f0 = func_809946BC(globalCtx, this, 0.0f, 20.0f, 15.0f); + temp_f0 = func_809946BC(globalCtx, pthis, 0.0f, 20.0f, 15.0f); if (fabsf(temp_f0) < 40.0f) { - rotYDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + rotYDiff = player->actor.shape.rot.y - pthis->dyna.actor.shape.rot.y; if (temp_f0 > 0.0f) { rotYDiff = 0x8000 - rotYDiff; } @@ -105,52 +105,52 @@ s32 func_80994750(DoorGerudo* this, GlobalContext* globalCtx) { return 0; } -void func_8099485C(DoorGerudo* this, GlobalContext* globalCtx) { - if (this->unk_164 != 0) { - this->actionFunc = func_8099496C; +void func_8099485C(DoorGerudo* pthis, GlobalContext* globalCtx) { + if (pthis->unk_164 != 0) { + pthis->actionFunc = func_8099496C; gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] -= 1; - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } else { - s32 direction = func_80994750(this, globalCtx); + s32 direction = func_80994750(pthis, globalCtx); if (direction != 0) { Player* player = GET_PLAYER(globalCtx); if (gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] <= 0) { player->naviTextId = -0x203; - } else if (!Flags_GetCollectible(globalCtx, (this->dyna.actor.params >> 8) & 0x1F)) { + } else if (!Flags_GetCollectible(globalCtx, (pthis->dyna.actor.params >> 8) & 0x1F)) { player->naviTextId = -0x225; } else { player->doorType = PLAYER_DOORTYPE_SLIDING; player->doorDirection = direction; - player->doorActor = &this->dyna.actor; + player->doorActor = &pthis->dyna.actor; player->doorTimer = 10; } } } } -void func_8099496C(DoorGerudo* this, GlobalContext* globalCtx) { - if (DECR(this->unk_166) == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); - this->actionFunc = func_809949C8; +void func_8099496C(DoorGerudo* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->unk_166) == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + pthis->actionFunc = func_809949C8; } } -void func_809949C8(DoorGerudo* this, GlobalContext* globalCtx) { - Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); - Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y); +void func_809949C8(DoorGerudo* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->dyna.actor.velocity.y, 15.0f, 3.0f); + Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 200.0f, pthis->dyna.actor.velocity.y); } void DoorGerudo_Update(Actor* thisx, GlobalContext* globalCtx) { - DoorGerudo* this = (DoorGerudo*)thisx; + DoorGerudo* pthis = (DoorGerudo*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void DoorGerudo_Draw(Actor* thisx, GlobalContext* globalCtx) { - DoorGerudo* this = (DoorGerudo*)thisx; + DoorGerudo* pthis = (DoorGerudo*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_gerudo.c", 361); @@ -160,9 +160,9 @@ void DoorGerudo_Draw(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gGerudoCellDoorDL); - if (this->unk_166 != 0) { + if (pthis->unk_166 != 0) { Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY); - Actor_DrawDoorLock(globalCtx, this->unk_166, DOORLOCK_NORMAL); + Actor_DrawDoorLock(globalCtx, pthis->unk_166, DOORLOCK_NORMAL); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_gerudo.c", 377); diff --git a/src/overlays/actors/ovl_Door_Killer/z_door_killer.c b/src/overlays/actors/ovl_Door_Killer/z_door_killer.cpp similarity index 51% rename from src/overlays/actors/ovl_Door_Killer/z_door_killer.c rename to src/overlays/actors/ovl_Door_Killer/z_door_killer.cpp index 5be1eb269..e05215d52 100644 --- a/src/overlays/actors/ovl_Door_Killer/z_door_killer.c +++ b/src/overlays/actors/ovl_Door_Killer/z_door_killer.cpp @@ -36,12 +36,12 @@ typedef enum { void DoorKiller_Init(Actor* thisx, GlobalContext* globalCtx); void DoorKiller_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorKiller_Update(Actor* thisx, GlobalContext* globalCtx); -void DoorKiller_Wait(DoorKiller* this, GlobalContext* globalCtx); -void DoorKiller_SetProperties(DoorKiller* this, GlobalContext* globalCtx); +void DoorKiller_Wait(DoorKiller* pthis, GlobalContext* globalCtx); +void DoorKiller_SetProperties(DoorKiller* pthis, GlobalContext* globalCtx); void DoorKiller_DrawDoor(Actor* thisx, GlobalContext* globalCtx); void DoorKiller_DrawRubble(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Door_Killer_InitVars = { +ActorInit Door_Killer_InitVars = { ACTOR_DOOR_KILLER, ACTORCAT_BG, FLAGS, @@ -110,7 +110,7 @@ static DoorKillerTextureEntry sDoorTextures[4] = { void DoorKiller_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; f32 randF; - DoorKiller* this = (DoorKiller*)thisx; + DoorKiller* pthis = (DoorKiller*)thisx; s32 bankIndex; s32 i; @@ -118,82 +118,82 @@ void DoorKiller_Init(Actor* thisx, GlobalContext* globalCtx2) { bankIndex = -1; for (i = 0; bankIndex < 0; i++) { bankIndex = Object_GetIndex(&globalCtx->objectCtx, sDoorTextures[i].objectId); - this->textureEntryIndex = i; + pthis->textureEntryIndex = i; } osSyncPrintf("bank_ID = %d\n", bankIndex); - osSyncPrintf("status = %d\n", this->textureEntryIndex); - this->doorObjBankIndex = bankIndex; - this->texture = sDoorTextures[this->textureEntryIndex].texture; + osSyncPrintf("status = %d\n", pthis->textureEntryIndex); + pthis->doorObjBankIndex = bankIndex; + pthis->texture = sDoorTextures[pthis->textureEntryIndex].texture; - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - Actor_SetScale(&this->actor, 0.01f); - this->timer = 0; - this->hasHitPlayerOrGround = 0; - this->animStyle = 0; - this->playerIsOpening = 0; + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->timer = 0; + pthis->hasHitPlayerOrGround = 0; + pthis->animStyle = 0; + pthis->playerIsOpening = 0; - switch ((u8)(this->actor.params & 0xFF)) { + switch ((u8)(pthis->actor.params & 0xFF)) { case DOOR_KILLER_DOOR: - // `jointTable` is used for both the `jointTable` and `morphTable` args here. Because this actor doesn't + // `jointTable` is used for both the `jointTable` and `morphTable` args here. Because pthis actor doesn't // play any animations it does not cause problems, but it would need to be changed otherwise. - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_door_killer_Skel_001BC8, NULL, this->jointTable, - this->jointTable, 9); - this->actionFunc = DoorKiller_SetProperties; - DoorKiller_SetProperties(this, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_door_killer_Skel_001BC8, NULL, pthis->jointTable, + pthis->jointTable, 9); + pthis->actionFunc = DoorKiller_SetProperties; + DoorKiller_SetProperties(pthis, globalCtx); // manually set the overall rotation of the door - this->jointTable[1].x = this->jointTable[1].z = 0x4000; + pthis->jointTable[1].x = pthis->jointTable[1].z = 0x4000; // Set a cylinder collider to detect link attacks and larger sphere collider to detect explosions - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - Collider_InitJntSph(globalCtx, &this->colliderJntSph); - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphItems); - this->colliderJntSph.elements[0].dim.worldSphere.radius = 80; - this->colliderJntSph.elements[0].dim.worldSphere.center.x = (s16)this->actor.world.pos.x; - this->colliderJntSph.elements[0].dim.worldSphere.center.y = (s16)this->actor.world.pos.y + 50; - this->colliderJntSph.elements[0].dim.worldSphere.center.z = (s16)this->actor.world.pos.z; + Collider_InitCylinder(globalCtx, &pthis->colliderCylinder); + Collider_SetCylinder(globalCtx, &pthis->colliderCylinder, &pthis->actor, &sCylinderInit); + Collider_InitJntSph(globalCtx, &pthis->colliderJntSph); + Collider_SetJntSph(globalCtx, &pthis->colliderJntSph, &pthis->actor, &sJntSphInit, pthis->colliderJntSphItems); + pthis->colliderJntSph.elements[0].dim.worldSphere.radius = 80; + pthis->colliderJntSph.elements[0].dim.worldSphere.center.x = (s16)pthis->actor.world.pos.x; + pthis->colliderJntSph.elements[0].dim.worldSphere.center.y = (s16)pthis->actor.world.pos.y + 50; + pthis->colliderJntSph.elements[0].dim.worldSphere.center.z = (s16)pthis->actor.world.pos.z; // If tied to a switch flag and that switch flag is already set, kill the actor. - if ((((this->actor.params >> 8) & 0x3F) != 0x3F) && - Flags_GetSwitch(globalCtx, ((this->actor.params >> 8) & 0x3F))) { - Actor_Kill(&this->actor); + if ((((pthis->actor.params >> 8) & 0x3F) != 0x3F) && + Flags_GetSwitch(globalCtx, ((pthis->actor.params >> 8) & 0x3F))) { + Actor_Kill(&pthis->actor); } break; case DOOR_KILLER_RUBBLE_PIECE_1: case DOOR_KILLER_RUBBLE_PIECE_2: case DOOR_KILLER_RUBBLE_PIECE_3: case DOOR_KILLER_RUBBLE_PIECE_4: - this->actionFunc = DoorKiller_SetProperties; - DoorKiller_SetProperties(this, globalCtx); + pthis->actionFunc = DoorKiller_SetProperties; + DoorKiller_SetProperties(pthis, globalCtx); - this->actor.gravity = -0.6f; - this->actor.minVelocityY = -6.0f; + pthis->actor.gravity = -0.6f; + pthis->actor.minVelocityY = -6.0f; // Random trajectories for rubble pieces randF = Rand_CenteredFloat(8.0f); - this->actor.velocity.z = Rand_ZeroFloat(8.0f); - this->actor.velocity.x = (Math_CosS(this->actor.world.rot.y) * randF) + - (Math_SinS(this->actor.world.rot.y) * this->actor.velocity.z); - this->actor.velocity.z = (-Math_SinS(this->actor.world.rot.y) * randF) + - (Math_CosS(this->actor.world.rot.y) * this->actor.velocity.z); - this->actor.velocity.y = Rand_ZeroFloat(4.0f) + 4.0f; + pthis->actor.velocity.z = Rand_ZeroFloat(8.0f); + pthis->actor.velocity.x = (Math_CosS(pthis->actor.world.rot.y) * randF) + + (Math_SinS(pthis->actor.world.rot.y) * pthis->actor.velocity.z); + pthis->actor.velocity.z = (-Math_SinS(pthis->actor.world.rot.y) * randF) + + (Math_CosS(pthis->actor.world.rot.y) * pthis->actor.velocity.z); + pthis->actor.velocity.y = Rand_ZeroFloat(4.0f) + 4.0f; // These are used as the x,y,z rotational velocities in DoorKiller_FallAsRubble - this->actor.world.rot.x = Rand_CenteredFloat(0x1000); - this->actor.world.rot.y = Rand_CenteredFloat(0x1000); - this->actor.world.rot.z = Rand_CenteredFloat(0x1000); - this->timer = 80; + pthis->actor.world.rot.x = Rand_CenteredFloat(0x1000); + pthis->actor.world.rot.y = Rand_CenteredFloat(0x1000); + pthis->actor.world.rot.z = Rand_CenteredFloat(0x1000); + pthis->timer = 80; break; } } void DoorKiller_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DoorKiller* this = (DoorKiller*)thisx; + DoorKiller* pthis = (DoorKiller*)thisx; if ((thisx->params & 0xFF) == DOOR_KILLER_DOOR) { - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &pthis->colliderJntSph); } } @@ -215,88 +215,88 @@ void DoorKiller_SpawnRubble(Actor* thisx, GlobalContext* globalCtx) { /** * action function for the individual door pieces that spawn and fall down when the door is destroyed */ -void DoorKiller_FallAsRubble(DoorKiller* this, GlobalContext* globalCtx) { - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; +void DoorKiller_FallAsRubble(DoorKiller* pthis, GlobalContext* globalCtx) { + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; } - this->actor.velocity.x *= 0.98f; - this->actor.velocity.z *= 0.98f; + pthis->actor.velocity.x *= 0.98f; + pthis->actor.velocity.z *= 0.98f; // world.rot is repurposed to be the rotation velocity for the rubble pieces - this->actor.shape.rot.x += this->actor.world.rot.x; - this->actor.shape.rot.y += this->actor.world.rot.y; - this->actor.shape.rot.z += this->actor.world.rot.z; + pthis->actor.shape.rot.x += pthis->actor.world.rot.x; + pthis->actor.shape.rot.y += pthis->actor.world.rot.y; + pthis->actor.shape.rot.z += pthis->actor.world.rot.z; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - func_8002D7EC(&this->actor); + func_8002D7EC(&pthis->actor); } s32 DoorKiller_IsHit(Actor* thisx, GlobalContext* globalCtx) { - DoorKiller* this = (DoorKiller*)thisx; - if ((this->colliderCylinder.base.acFlags & 2) && (this->colliderCylinder.info.acHitInfo != NULL)) { + DoorKiller* pthis = (DoorKiller*)thisx; + if ((pthis->colliderCylinder.base.acFlags & 2) && (pthis->colliderCylinder.info.acHitInfo != NULL)) { return true; } return false; } -void DoorKiller_SetAC(DoorKiller* this, GlobalContext* globalCtx) { - Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); +void DoorKiller_SetAC(DoorKiller* pthis, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderCylinder); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderJntSph.base); } -void DoorKiller_Die(DoorKiller* this, GlobalContext* globalCtx) { - s32 switchFlag = (this->actor.params >> 8) & 0x3F; +void DoorKiller_Die(DoorKiller* pthis, GlobalContext* globalCtx) { + s32 switchFlag = (pthis->actor.params >> 8) & 0x3F; // Can set a switch flag on death based on params if (switchFlag != 0x3F) { Flags_SetSwitch(globalCtx, switchFlag); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } /** * After slamming on the floor, rise back upright */ -void DoorKiller_RiseBackUp(DoorKiller* this, GlobalContext* globalCtx) { +void DoorKiller_RiseBackUp(DoorKiller* pthis, GlobalContext* globalCtx) { s32 i; s16 rotation; - if (this->timer > 0) { - this->timer--; + if (pthis->timer > 0) { + pthis->timer--; } else { - this->actionFunc = DoorKiller_Wait; - this->timer = 16; - DoorKiller_SetAC(this, globalCtx); + pthis->actionFunc = DoorKiller_Wait; + pthis->timer = 16; + DoorKiller_SetAC(pthis, globalCtx); return; } - this->actor.shape.rot.x = (this->timer >= 8) ? (this->timer * 0x800) - 0x4000 : 0; + pthis->actor.shape.rot.x = (pthis->timer >= 8) ? (pthis->timer * 0x800) - 0x4000 : 0; - if (this->timer >= 12) { - rotation = (-this->timer * -500) - 8000; - } else if (this->timer >= 8) { + if (pthis->timer >= 12) { + rotation = (-pthis->timer * -500) - 8000; + } else if (pthis->timer >= 8) { rotation = -2000; - } else if (this->timer >= 5) { - rotation = (this->timer * -500) + 2000; + } else if (pthis->timer >= 5) { + rotation = (pthis->timer * -500) + 2000; } else { rotation = 0; } for (i = 2; i < 9; i++) { - this->jointTable[i].z = -rotation; + pthis->jointTable[i].z = -rotation; } - if (this->timer < 8) { - rotation = Math_SinS(this->timer * 0x2000) * this->timer * 100.0f; + if (pthis->timer < 8) { + rotation = Math_SinS(pthis->timer * 0x2000) * pthis->timer * 100.0f; for (i = 2; i < 9; i++) { - this->jointTable[i].y = rotation; + pthis->jointTable[i].y = rotation; } } } @@ -305,35 +305,35 @@ void DoorKiller_RiseBackUp(DoorKiller* this, GlobalContext* globalCtx) { * After wobbling, fall over and slam onto the floor, damaging the player if they are in the way. Uses manual distance * check for damaging player, not AT system. */ -void DoorKiller_FallOver(DoorKiller* this, GlobalContext* globalCtx) { +void DoorKiller_FallOver(DoorKiller* pthis, GlobalContext* globalCtx) { s32 i; s16 rotation; - if (this->timer > 0) { - this->timer--; + if (pthis->timer > 0) { + pthis->timer--; } else { - this->actionFunc = DoorKiller_RiseBackUp; - this->timer = 16; + pthis->actionFunc = DoorKiller_RiseBackUp; + pthis->timer = 16; return; } - this->actor.shape.rot.x = (this->timer >= 4) ? 0x8000 + (-this->timer * 0x1000) : 0x4000; + pthis->actor.shape.rot.x = (pthis->timer >= 4) ? 0x8000 + (-pthis->timer * 0x1000) : 0x4000; - if (this->timer >= 6) { - rotation = (-this->timer * -500) - 4000; - } else if (this->timer >= 4) { + if (pthis->timer >= 6) { + rotation = (-pthis->timer * -500) - 4000; + } else if (pthis->timer >= 4) { rotation = -1000; - } else if (this->timer >= 3) { - rotation = (this->timer * -500) + 1000; + } else if (pthis->timer >= 3) { + rotation = (pthis->timer * -500) + 1000; } else { rotation = 0; } for (i = 2; i < 9; i++) { - this->jointTable[i].z = rotation; + pthis->jointTable[i].z = rotation; } - if (this->timer == 4) { + if (pthis->timer == 4) { // spawn 20 random dust particles just before slamming down Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 1.0f, 0.0f }; @@ -345,169 +345,169 @@ void DoorKiller_FallOver(DoorKiller* this, GlobalContext* globalCtx) { pos.y = 0.0f; randF = Rand_CenteredFloat(40.0f); pos.z = Rand_ZeroFloat(100.0f); - pos.x = (Math_CosS(this->actor.world.rot.y) * randF) + (Math_SinS(this->actor.world.rot.y) * pos.z); - pos.z = (-Math_SinS(this->actor.world.rot.y) * randF) + (Math_CosS(this->actor.world.rot.y) * pos.z); + pos.x = (Math_CosS(pthis->actor.world.rot.y) * randF) + (Math_SinS(pthis->actor.world.rot.y) * pos.z); + pos.z = (-Math_SinS(pthis->actor.world.rot.y) * randF) + (Math_CosS(pthis->actor.world.rot.y) * pos.z); velocity.x = pos.x * 0.2f; velocity.z = pos.z * 0.2f; accel.x = -(velocity.x) * 0.1f; accel.z = -(velocity.z) * 0.1f; - pos.x += this->actor.world.pos.x; - pos.y += this->actor.world.pos.y; - pos.z += this->actor.world.pos.z; + pos.x += pthis->actor.world.pos.x; + pos.y += pthis->actor.world.pos.y; + pos.z += pthis->actor.world.pos.z; func_8002865C(globalCtx, &pos, &velocity, &accel, 300, 30); } } - if (!(this->hasHitPlayerOrGround & 1)) { + if (!(pthis->hasHitPlayerOrGround & 1)) { Vec3f playerPosRelToDoor; Player* player = GET_PLAYER(globalCtx); - func_8002DBD0(&this->actor, &playerPosRelToDoor, &player->actor.world.pos); + func_8002DBD0(&pthis->actor, &playerPosRelToDoor, &player->actor.world.pos); if ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && (playerPosRelToDoor.z < 100.0f) && (playerPosRelToDoor.z > 0.0f)) { - this->hasHitPlayerOrGround |= 1; - func_8002F6D4(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f, 16); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KDOOR_HIT); + pthis->hasHitPlayerOrGround |= 1; + func_8002F6D4(globalCtx, &pthis->actor, 6.0f, pthis->actor.yawTowardsPlayer, 6.0f, 16); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KDOOR_HIT); func_8002F7DC(&player->actor, NA_SE_PL_BODY_HIT); } } - if (!(this->hasHitPlayerOrGround & 1) && (this->timer == 2)) { - this->hasHitPlayerOrGround |= 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KDOOR_HIT_GND); + if (!(pthis->hasHitPlayerOrGround & 1) && (pthis->timer == 2)) { + pthis->hasHitPlayerOrGround |= 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KDOOR_HIT_GND); } } /** - * Wobble around, signifying the door is about to fall over. Does not set AC and so cannot be destroyed during this. + * Wobble around, signifying the door is about to fall over. Does not set AC and so cannot be destroyed during pthis. */ -void DoorKiller_Wobble(DoorKiller* this, GlobalContext* globalCtx) { +void DoorKiller_Wobble(DoorKiller* pthis, GlobalContext* globalCtx) { s16 rotation; s32 i; - if ((this->timer == 16) || (this->timer == 8)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KDOOR_WAVE); + if ((pthis->timer == 16) || (pthis->timer == 8)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KDOOR_WAVE); } - if (this->timer > 0) { - this->timer--; + if (pthis->timer > 0) { + pthis->timer--; } else { - this->actionFunc = DoorKiller_FallOver; - this->timer = 8; - this->hasHitPlayerOrGround &= ~1; + pthis->actionFunc = DoorKiller_FallOver; + pthis->timer = 8; + pthis->hasHitPlayerOrGround &= ~1; return; } - rotation = Math_SinS(this->timer * 0x2000) * this->timer * 100.0f; + rotation = Math_SinS(pthis->timer * 0x2000) * pthis->timer * 100.0f; for (i = 2; i < 9; i++) { - this->jointTable[i].y = rotation; + pthis->jointTable[i].y = rotation; } - rotation = (u16)(s32)(-Math_CosS(this->timer * 0x1000) * 1000.0f) + 1000; + rotation = (u16)(s32)(-Math_CosS(pthis->timer * 0x1000) * 1000.0f) + 1000; for (i = 2; i < 9; i++) { - this->jointTable[i].z = rotation; + pthis->jointTable[i].z = rotation; } } /** * Idle while the player attempts to open the door and then begin to wobble */ -void DoorKiller_WaitBeforeWobble(DoorKiller* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; +void DoorKiller_WaitBeforeWobble(DoorKiller* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; } else { - this->timer = 16; - this->actionFunc = DoorKiller_Wobble; + pthis->timer = 16; + pthis->actionFunc = DoorKiller_Wobble; } } -void DoorKiller_Wait(DoorKiller* this, GlobalContext* globalCtx) { +void DoorKiller_Wait(DoorKiller* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f playerPosRelToDoor; s16 angleToFacingPlayer; - func_8002DBD0(&this->actor, &playerPosRelToDoor, &player->actor.world.pos); + func_8002DBD0(&pthis->actor, &playerPosRelToDoor, &player->actor.world.pos); // playerIsOpening is set by player - if (this->playerIsOpening) { - this->actionFunc = DoorKiller_WaitBeforeWobble; - this->timer = 10; - this->playerIsOpening = 0; + if (pthis->playerIsOpening) { + pthis->actionFunc = DoorKiller_WaitBeforeWobble; + pthis->timer = 10; + pthis->playerIsOpening = 0; return; } - if (DoorKiller_IsHit(&this->actor, globalCtx)) { + if (DoorKiller_IsHit(&pthis->actor, globalCtx)) { // AC cylinder: wobble if hit by most weapons, die if hit by explosives or hammer - if ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x1FFA6) != 0) { - this->timer = 16; - this->actionFunc = DoorKiller_Wobble; - } else if ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x48) != 0) { - DoorKiller_SpawnRubble(&this->actor, globalCtx); - this->actionFunc = DoorKiller_Die; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_KDOOR_BREAK); + if ((pthis->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x1FFA6) != 0) { + pthis->timer = 16; + pthis->actionFunc = DoorKiller_Wobble; + } else if ((pthis->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x48) != 0) { + DoorKiller_SpawnRubble(&pthis->actor, globalCtx); + pthis->actionFunc = DoorKiller_Die; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EN_KDOOR_BREAK); } - } else if (Actor_GetCollidedExplosive(globalCtx, &this->colliderJntSph.base) != NULL) { + } else if (Actor_GetCollidedExplosive(globalCtx, &pthis->colliderJntSph.base) != NULL) { // AC sphere: die if hit by explosive - DoorKiller_SpawnRubble(&this->actor, globalCtx); - this->actionFunc = DoorKiller_Die; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_KDOOR_BREAK); + DoorKiller_SpawnRubble(&pthis->actor, globalCtx); + pthis->actionFunc = DoorKiller_Die; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EN_KDOOR_BREAK); } else if (!Player_InCsMode(globalCtx) && (fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && (playerPosRelToDoor.z < 50.0f) && (playerPosRelToDoor.z > 0.0f)) { // Set player properties to make the door openable if within range - angleToFacingPlayer = player->actor.shape.rot.y - this->actor.shape.rot.y; + angleToFacingPlayer = player->actor.shape.rot.y - pthis->actor.shape.rot.y; if (playerPosRelToDoor.z > 0.0f) { angleToFacingPlayer = 0x8000 - angleToFacingPlayer; } if (ABS(angleToFacingPlayer) < 0x3000) { player->doorType = PLAYER_DOORTYPE_FAKE; player->doorDirection = (playerPosRelToDoor.z >= 0.0f) ? 1.0f : -1.0f; - player->doorActor = &this->actor; + player->doorActor = &pthis->actor; } } - DoorKiller_SetAC(this, globalCtx); + DoorKiller_SetAC(pthis, globalCtx); } /** * Grabs the virtual address of the texture from the relevant door object */ void DoorKiller_UpdateTexture(Actor* thisx, GlobalContext* globalCtx) { - DoorKiller* this = (DoorKiller*)thisx; + DoorKiller* pthis = (DoorKiller*)thisx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->doorObjBankIndex].vromStart); - this->texture = SEGMENTED_TO_VIRTUAL(this->texture); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[thisx->objBankIndex].vromStart); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->doorObjBankIndex].vromStart.get()); + pthis->texture = SEGMENTED_TO_VIRTUAL(pthis->texture); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[thisx->objBankIndex].vromStart.get()); } /** * Gets the correct door texture, defines the appropriate draw fucntion and action function based on type behaviour * (door or rubble). */ -void DoorKiller_SetProperties(DoorKiller* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->doorObjBankIndex)) { - DoorKiller_UpdateTexture(&this->actor, globalCtx); - switch (this->actor.params & 0xFF) { +void DoorKiller_SetProperties(DoorKiller* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->doorObjBankIndex)) { + DoorKiller_UpdateTexture(&pthis->actor, globalCtx); + switch (pthis->actor.params & 0xFF) { case DOOR_KILLER_DOOR: - this->actionFunc = DoorKiller_Wait; - this->actor.draw = DoorKiller_DrawDoor; + pthis->actionFunc = DoorKiller_Wait; + pthis->actor.draw = DoorKiller_DrawDoor; break; case DOOR_KILLER_RUBBLE_PIECE_1: case DOOR_KILLER_RUBBLE_PIECE_2: case DOOR_KILLER_RUBBLE_PIECE_3: case DOOR_KILLER_RUBBLE_PIECE_4: - this->actionFunc = DoorKiller_FallAsRubble; - this->actor.draw = DoorKiller_DrawRubble; + pthis->actionFunc = DoorKiller_FallAsRubble; + pthis->actor.draw = DoorKiller_DrawRubble; break; } } } void DoorKiller_Update(Actor* thisx, GlobalContext* globalCtx) { - DoorKiller* this = (DoorKiller*)thisx; + DoorKiller* pthis = (DoorKiller*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void DoorKiller_SetTexture(Actor* thisx, GlobalContext* globalCtx) { - DoorKiller* this = (DoorKiller*)thisx; - void* doorTexture = this->texture; + DoorKiller* pthis = (DoorKiller*)thisx; + void* doorTexture = pthis->texture; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_killer.c", 883); gSPSegment(POLY_OPA_DISP++, 0x08, doorTexture); @@ -515,11 +515,11 @@ void DoorKiller_SetTexture(Actor* thisx, GlobalContext* globalCtx) { } void DoorKiller_DrawDoor(Actor* thisx, GlobalContext* globalCtx) { - DoorKiller* this = (DoorKiller*)thisx; + DoorKiller* pthis = (DoorKiller*)thisx; func_800943C8(globalCtx->state.gfxCtx); - DoorKiller_SetTexture(&this->actor, globalCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DoorKiller_SetTexture(&pthis->actor, globalCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, NULL, NULL, NULL); } @@ -527,9 +527,9 @@ void DoorKiller_DrawRubble(Actor* thisx, GlobalContext* globalCtx) { static Gfx* dLists[] = { object_door_killer_DL_001250, object_door_killer_DL_001550, object_door_killer_DL_0017B8, object_door_killer_DL_001A58 }; s32 rubblePieceIndex = (thisx->params & 0xFF) - 1; - DoorKiller* this = (DoorKiller*)thisx; + DoorKiller* pthis = (DoorKiller*)thisx; - if ((this->timer >= 20) || ((this->timer & 1) == 0)) { + if ((pthis->timer >= 20) || ((pthis->timer & 1) == 0)) { DoorKiller_SetTexture(thisx, globalCtx); Gfx_DrawDListOpa(globalCtx, dLists[rubblePieceIndex]); } diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.cpp similarity index 52% rename from src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c rename to src/overlays/actors/ovl_Door_Shutter/z_door_shutter.cpp index 7bdd39447..4101d9829 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.cpp @@ -51,22 +51,22 @@ void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx); void func_8099803C(GlobalContext* globalCtx, s16 y, s16 countdown, s16 arg3); -void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx); -void func_80996A54(DoorShutter* this, GlobalContext* globalCtx); -void func_80996B00(DoorShutter* this, GlobalContext* globalCtx); -void func_80996B0C(DoorShutter* this, GlobalContext* globalCtx); -void func_80996EE8(DoorShutter* this, GlobalContext* globalCtx); -void func_80996F98(DoorShutter* this, GlobalContext* globalCtx); -void func_80997004(DoorShutter* this, GlobalContext* globalCtx); -void func_80997150(DoorShutter* this, GlobalContext* globalCtx); -void func_809973E8(DoorShutter* this, GlobalContext* globalCtx); -void func_80997528(DoorShutter* this, GlobalContext* globalCtx); -void func_80997568(DoorShutter* this, GlobalContext* globalCtx); -void func_809975C0(DoorShutter* this, GlobalContext* globalCtx); -void func_809976B8(DoorShutter* this, GlobalContext* globalCtx); -void func_80997744(DoorShutter* this, GlobalContext* globalCtx); +void DoorShutter_SetupType(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80996A54(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80996B00(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80996B0C(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80996EE8(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80996F98(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80997004(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80997150(DoorShutter* pthis, GlobalContext* globalCtx); +void func_809973E8(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80997528(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80997568(DoorShutter* pthis, GlobalContext* globalCtx); +void func_809975C0(DoorShutter* pthis, GlobalContext* globalCtx); +void func_809976B8(DoorShutter* pthis, GlobalContext* globalCtx); +void func_80997744(DoorShutter* pthis, GlobalContext* globalCtx); -const ActorInit Door_Shutter_InitVars = { +ActorInit Door_Shutter_InitVars = { ACTOR_DOOR_SHUTTER, ACTORCAT_DOOR, FLAGS, @@ -187,24 +187,24 @@ static void* D_809982D4[] = { object_bdoor_Tex_000000, object_bdoor_Tex_0025C0, object_bdoor_Tex_0015C0, }; -void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc) { - this->actionFunc = actionFunc; - this->unk_16F = 0; +void DoorShutter_SetupAction(DoorShutter* pthis, DoorShutterActionFunc actionFunc) { + pthis->actionFunc = actionFunc; + pthis->unk_16F = 0; } -s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { - TransitionActorEntry* transitionEntry = &globalCtx->transiActorCtx.list[(u16)this->dyna.actor.params >> 0xA]; +s32 DoorShutter_SetupDoor(DoorShutter* pthis, GlobalContext* globalCtx) { + TransitionActorEntry* transitionEntry = &globalCtx->transiActorCtx.list[(u16)pthis->dyna.actor.params >> 0xA]; s8 frontRoom = transitionEntry->sides[0].room; - s32 doorType = this->doorType; - ShutterObjectInfo* temp_t0 = &sObjectInfo[this->unk_16B]; + s32 doorType = pthis->doorType; + ShutterObjectInfo* temp_t0 = &sObjectInfo[pthis->unk_16B]; if (doorType != SHUTTER_KEY_LOCKED) { if (frontRoom == transitionEntry->sides[1].room) { - if (ABS((s16)(this->dyna.actor.shape.rot.y - this->dyna.actor.yawTowardsPlayer)) < 0x4000) { + if (ABS((s16)(pthis->dyna.actor.shape.rot.y - pthis->dyna.actor.yawTowardsPlayer)) < 0x4000) { frontRoom = -1; } } - if (frontRoom == this->dyna.actor.room) { + if (frontRoom == pthis->dyna.actor.room) { if (doorType == SHUTTER_FRONT_SWITCH_BACK_CLEAR) { // Swap the back clear to the front clear doorType = SHUTTER_FRONT_CLEAR; } else { @@ -212,43 +212,43 @@ s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { } } } - this->unk_16C = (doorType == SHUTTER) ? temp_t0->index1 : temp_t0->index2; + pthis->unk_16C = (doorType == SHUTTER) ? temp_t0->index1 : temp_t0->index2; if (doorType == SHUTTER_FRONT_CLEAR) { - if (!Flags_GetClear(globalCtx, this->dyna.actor.room)) { - DoorShutter_SetupAction(this, func_80996A54); - this->unk_170 = 1.0f; + if (!Flags_GetClear(globalCtx, pthis->dyna.actor.room)) { + DoorShutter_SetupAction(pthis, func_80996A54); + pthis->unk_170 = 1.0f; return true; } } else if (doorType == SHUTTER_FRONT_SWITCH || doorType == SHUTTER_FRONT_SWITCH_BACK_CLEAR) { - if (!Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - DoorShutter_SetupAction(this, func_80996EE8); - this->unk_170 = 1.0f; + if (!Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + DoorShutter_SetupAction(pthis, func_80996EE8); + pthis->unk_170 = 1.0f; return true; } - DoorShutter_SetupAction(this, func_80996F98); + DoorShutter_SetupAction(pthis, func_80996F98); return false; } else if (doorType == SHUTTER_BACK_LOCKED) { - DoorShutter_SetupAction(this, func_80996B00); + DoorShutter_SetupAction(pthis, func_80996B00); return false; } - DoorShutter_SetupAction(this, func_80996B0C); + DoorShutter_SetupAction(pthis, func_80996B0C); return false; } void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { - DoorShutter* this = (DoorShutter*)thisx; + DoorShutter* pthis = (DoorShutter*)thisx; GlobalContext* globalCtx = globalCtx2; s32 phi_a3; s32 pad; s32 objectIndex; s32 i; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->dyna.actor.home.pos.z = this->dyna.actor.shape.yOffset; - DynaPolyActor_Init(&this->dyna, DPM_UNK); - this->doorType = (this->dyna.actor.params >> 6) & 0xF; - phi_a3 = D_80998224[this->doorType]; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->dyna.actor.home.pos.z = pthis->dyna.actor.shape.yOffset; + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + pthis->doorType = (pthis->dyna.actor.params >> 6) & 0xF; + phi_a3 = D_80998224[pthis->doorType]; if (phi_a3 < 0) { ShutterSceneInfo* phi_v1; @@ -266,71 +266,71 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { break; } } - this->unk_168 = phi_v1_2->index; + pthis->unk_168 = phi_v1_2->index; } else { - this->dyna.actor.room = -1; + pthis->dyna.actor.room = -1; } - //if (this->requiredObjBankIndex = objectIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectInfo[phi_a3].objectId), + //if (pthis->requiredObjBankIndex = objectIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectInfo[phi_a3].objectId), // (s8)objectIndex < 0) { - // Actor_Kill(&this->dyna.actor); + // Actor_Kill(&pthis->dyna.actor); // return; //} - DoorShutter_SetupAction(this, DoorShutter_SetupType); - this->unk_16B = phi_a3; - if (this->doorType == SHUTTER_KEY_LOCKED || this->doorType == SHUTTER_BOSS) { - if (!Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - this->unk_16E = 10; + DoorShutter_SetupAction(pthis, DoorShutter_SetupType); + pthis->unk_16B = phi_a3; + if (pthis->doorType == SHUTTER_KEY_LOCKED || pthis->doorType == SHUTTER_BOSS) { + if (!Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + pthis->unk_16E = 10; } - Actor_SetFocus(&this->dyna.actor, 60.0f); + Actor_SetFocus(&pthis->dyna.actor, 60.0f); } else if (phi_a3 == 4) { - Actor_SetScale(&this->dyna.actor, 0.1f); - this->unk_166 = 100; - this->dyna.actor.uncullZoneScale = 200.0f; - Actor_SetFocus(&this->dyna.actor, 0.0f); + Actor_SetScale(&pthis->dyna.actor, 0.1f); + pthis->unk_166 = 100; + pthis->dyna.actor.uncullZoneScale = 200.0f; + Actor_SetFocus(&pthis->dyna.actor, 0.0f); } else { - Actor_SetFocus(&this->dyna.actor, 60.0f); + Actor_SetFocus(&pthis->dyna.actor, 60.0f); } } void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DoorShutter* this = (DoorShutter*)thisx; + DoorShutter* pthis = (DoorShutter*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if (this->dyna.actor.room >= 0) { - s32 transitionActorId = (u16)this->dyna.actor.params >> 0xA; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if (pthis->dyna.actor.room >= 0) { + s32 transitionActorId = (u16)pthis->dyna.actor.params >> 0xA; globalCtx->transiActorCtx.list[transitionActorId].id *= -1; } } -void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { - this->dyna.actor.objBankIndex = this->requiredObjBankIndex; - if (this->doorType == SHUTTER_PG_BARS || this->doorType == SHUTTER_GOHMA_BLOCK) { +void DoorShutter_SetupType(DoorShutter* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->requiredObjBankIndex)) { + pthis->dyna.actor.objBankIndex = pthis->requiredObjBankIndex; + if (pthis->doorType == SHUTTER_PG_BARS || pthis->doorType == SHUTTER_GOHMA_BLOCK) { // Init dynapoly for shutters of the type that uses it CollisionHeader* colHeader = NULL; - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); - this->unk_16C = sObjectInfo[this->unk_16B].index1; - CollisionHeader_GetVirtual((this->doorType == SHUTTER_GOHMA_BLOCK) ? &gGohmaDoorCol : &gPhantomGanonBarsCol, + Actor_SetObjectDependency(globalCtx, &pthis->dyna.actor); + pthis->unk_16C = sObjectInfo[pthis->unk_16B].index1; + CollisionHeader_GetVirtual((pthis->doorType == SHUTTER_GOHMA_BLOCK) ? &gGohmaDoorCol : &gPhantomGanonBarsCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->doorType == SHUTTER_GOHMA_BLOCK) { - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.gravity = -2.0f; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); - DoorShutter_SetupAction(this, func_809975C0); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->doorType == SHUTTER_GOHMA_BLOCK) { + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.gravity = -2.0f; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + DoorShutter_SetupAction(pthis, func_809975C0); } else { - DoorShutter_SetupAction(this, func_80997744); - this->unk_164 = 7; + DoorShutter_SetupAction(pthis, func_80997744); + pthis->unk_164 = 7; } } else { - DoorShutter_SetupDoor(this, globalCtx); + DoorShutter_SetupDoor(pthis, globalCtx); } } } -f32 func_80996840(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg3, f32 arg4) { +f32 func_80996840(GlobalContext* globalCtx, DoorShutter* pthis, f32 arg2, f32 arg3, f32 arg4) { s32 pad; Vec3f sp28; Vec3f sp1C; @@ -339,7 +339,7 @@ f32 func_80996840(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg sp28.x = player->actor.world.pos.x; sp28.y = player->actor.world.pos.y + arg2; sp28.z = player->actor.world.pos.z; - func_8002DBD0(&this->dyna.actor, &sp1C, &sp28); + func_8002DBD0(&pthis->dyna.actor, &sp1C, &sp28); if (arg3 < fabsf(sp1C.x) || arg4 < fabsf(sp1C.y)) { return FLT_MAX; } else { @@ -347,15 +347,15 @@ f32 func_80996840(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg } } -s32 func_809968D4(DoorShutter* this, GlobalContext* globalCtx) { +s32 func_809968D4(DoorShutter* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (!Player_InCsMode(globalCtx)) { - ShutterInfo* temp_v1 = &sShutterInfo[this->unk_16C]; - f32 temp_f2 = func_80996840(globalCtx, this, (this->unk_16C != 3) ? 0.0f : 80.0f, temp_v1->e, temp_v1->f); + ShutterInfo* temp_v1 = &sShutterInfo[pthis->unk_16C]; + f32 temp_f2 = func_80996840(globalCtx, pthis, (pthis->unk_16C != 3) ? 0.0f : 80.0f, temp_v1->e, temp_v1->f); if (fabsf(temp_f2) < 50.0f) { - s16 phi_v0 = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + s16 phi_v0 = player->actor.shape.rot.y - pthis->dyna.actor.shape.rot.y; if (temp_f2 > 0.0f) { phi_v0 = 0x8000 - phi_v0; @@ -368,44 +368,44 @@ s32 func_809968D4(DoorShutter* this, GlobalContext* globalCtx) { return 0.0f; } -void func_80996A54(DoorShutter* this, GlobalContext* globalCtx) { - if (Flags_GetClear(globalCtx, this->dyna.actor.room) || Flags_GetTempClear(globalCtx, this->dyna.actor.room)) { - Flags_SetClear(globalCtx, this->dyna.actor.room); - DoorShutter_SetupAction(this, func_80997150); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); +void func_80996A54(DoorShutter* pthis, GlobalContext* globalCtx) { + if (Flags_GetClear(globalCtx, pthis->dyna.actor.room) || Flags_GetTempClear(globalCtx, pthis->dyna.actor.room)) { + Flags_SetClear(globalCtx, pthis->dyna.actor.room); + DoorShutter_SetupAction(pthis, func_80997150); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); OnePointCutscene_Attention(globalCtx, &GET_PLAYER(globalCtx)->actor); - this->unk_16F = -100; - } else if (func_809968D4(this, globalCtx) != 0) { + pthis->unk_16F = -100; + } else if (func_809968D4(pthis, globalCtx) != 0) { Player* player = GET_PLAYER(globalCtx); player->naviTextId = -0x202; } } -void func_80996B00(DoorShutter* this, GlobalContext* globalCtx) { +void func_80996B00(DoorShutter* pthis, GlobalContext* globalCtx) { } -void func_80996B0C(DoorShutter* this, GlobalContext* globalCtx) { - if (this->unk_164 != 0) { - DoorShutter_SetupAction(this, func_80997004); - this->dyna.actor.velocity.y = 0.0f; - if (this->unk_16E != 0) { - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - if (this->doorType != SHUTTER_BOSS) { +void func_80996B0C(DoorShutter* pthis, GlobalContext* globalCtx) { + if (pthis->unk_164 != 0) { + DoorShutter_SetupAction(pthis, func_80997004); + pthis->dyna.actor.velocity.y = 0.0f; + if (pthis->unk_16E != 0) { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + if (pthis->doorType != SHUTTER_BOSS) { gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); } } } else { - s32 doorDirection = func_809968D4(this, globalCtx); + s32 doorDirection = func_809968D4(pthis, globalCtx); if (doorDirection != 0) { Player* player = GET_PLAYER(globalCtx); - if (this->unk_16E != 0) { - if (this->doorType == SHUTTER_BOSS) { + if (pthis->unk_16E != 0) { + if (pthis->doorType == SHUTTER_BOSS) { if (!CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, gSaveContext.mapIndex)) { player->naviTextId = -0x204; return; @@ -418,79 +418,79 @@ void func_80996B0C(DoorShutter* this, GlobalContext* globalCtx) { } player->doorType = PLAYER_DOORTYPE_SLIDING; player->doorDirection = doorDirection; - player->doorActor = &this->dyna.actor; + player->doorActor = &pthis->dyna.actor; } } } -void func_80996C60(DoorShutter* this, GlobalContext* globalCtx) { - if (this->dyna.actor.category == ACTORCAT_DOOR) { +void func_80996C60(DoorShutter* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.category == ACTORCAT_DOOR) { Player* player = GET_PLAYER(globalCtx); - s32 sp38 = this->unk_16C; + s32 sp38 = pthis->unk_16C; s32 sp34 = 0xF; - if (DoorShutter_SetupDoor(this, globalCtx)) { + if (DoorShutter_SetupDoor(pthis, globalCtx)) { sp34 = 0x20; } - DoorShutter_SetupAction(this, func_80997004); - this->unk_16C = sp38; - this->unk_170 = 0.0f; - Camera_ChangeDoorCam(globalCtx->cameraPtrs[MAIN_CAM], &this->dyna.actor, player->unk_46A, 0.0f, 12, sp34, 10); + DoorShutter_SetupAction(pthis, func_80997004); + pthis->unk_16C = sp38; + pthis->unk_170 = 0.0f; + Camera_ChangeDoorCam(globalCtx->cameraPtrs[MAIN_CAM], &pthis->dyna.actor, player->unk_46A, 0.0f, 12, sp34, 10); } } -s32 func_80996D14(DoorShutter* this, GlobalContext* globalCtx) { - if (this->unk_16C != 3) { - if (this->dyna.actor.velocity.y == 0.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); - func_80996C60(this, globalCtx); +s32 func_80996D14(DoorShutter* pthis, GlobalContext* globalCtx) { + if (pthis->unk_16C != 3) { + if (pthis->dyna.actor.velocity.y == 0.0f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + func_80996C60(pthis, globalCtx); } - Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, - this->dyna.actor.velocity.y)) { + Math_StepToF(&pthis->dyna.actor.velocity.y, 15.0f, 3.0f); + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y + 200.0f, + pthis->dyna.actor.velocity.y)) { return true; } } else { - if (this->unk_166 == 100) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYODOOR_OPEN); - func_80996C60(this, globalCtx); + if (pthis->unk_166 == 100) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYODOOR_OPEN); + func_80996C60(pthis, globalCtx); } - if (Math_StepToS(&this->unk_166, 0, 10)) { + if (Math_StepToS(&pthis->unk_166, 0, 10)) { return true; } } return false; } -s32 func_80996E08(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { - if (this->unk_170 == 1.0f - arg2) { - if (this->unk_16C != 3) { +s32 func_80996E08(DoorShutter* pthis, GlobalContext* globalCtx, f32 arg2) { + if (pthis->unk_170 == 1.0f - arg2) { + if (pthis->unk_16C != 3) { if (arg2 == 1.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_METALDOOR_OPEN); } } else { if (arg2 == 1.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSHUTTER_CLOSE); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSHUTTER_CLOSE); } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSHUTTER_OPEN); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSHUTTER_OPEN); } } } - if (Math_StepToF(&this->unk_170, arg2, 0.2f)) { + if (Math_StepToF(&pthis->unk_170, arg2, 0.2f)) { return true; } return false; } -void func_80996EE8(DoorShutter* this, GlobalContext* globalCtx) { - if (func_80996E08(this, globalCtx, 1.0f)) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - DoorShutter_SetupAction(this, func_80997150); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->unk_16F = -100; - } else if (func_809968D4(this, globalCtx)) { +void func_80996EE8(DoorShutter* pthis, GlobalContext* globalCtx) { + if (func_80996E08(pthis, globalCtx, 1.0f)) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + DoorShutter_SetupAction(pthis, func_80997150); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->unk_16F = -100; + } else if (func_809968D4(pthis, globalCtx)) { Player* player = GET_PLAYER(globalCtx); // Jabu navi text for switch doors is different player->naviTextId = (globalCtx->sceneNum == SCENE_BDAN) ? -0x20B : -0x202; @@ -498,68 +498,68 @@ void func_80996EE8(DoorShutter* this, GlobalContext* globalCtx) { } } -void func_80996F98(DoorShutter* this, GlobalContext* globalCtx) { - if (this->unk_164 == 0 && !Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - DoorShutter_SetupAction(this, func_80996EE8); +void func_80996F98(DoorShutter* pthis, GlobalContext* globalCtx) { + if (pthis->unk_164 == 0 && !Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + DoorShutter_SetupAction(pthis, func_80996EE8); } else { - func_80996B0C(this, globalCtx); + func_80996B0C(pthis, globalCtx); } } -void func_80997004(DoorShutter* this, GlobalContext* globalCtx) { - if (DECR(this->unk_16E) == 0 && globalCtx->roomCtx.status == 0 && func_80996D14(this, globalCtx) != 0) { - if (((this->doorType == SHUTTER_BOSS) ? 20.0f : 50.0f) < this->dyna.actor.xzDistToPlayer) { - if (DoorShutter_SetupDoor(this, globalCtx)) { - this->dyna.actor.velocity.y = 30.0f; +void func_80997004(DoorShutter* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->unk_16E) == 0 && globalCtx->roomCtx.status == 0 && func_80996D14(pthis, globalCtx) != 0) { + if (((pthis->doorType == SHUTTER_BOSS) ? 20.0f : 50.0f) < pthis->dyna.actor.xzDistToPlayer) { + if (DoorShutter_SetupDoor(pthis, globalCtx)) { + pthis->dyna.actor.velocity.y = 30.0f; } - if (this->unk_16C != 3) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); - DoorShutter_SetupAction(this, func_809973E8); + if (pthis->unk_16C != 3) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + DoorShutter_SetupAction(pthis, func_809973E8); } else { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYODOOR_CLOSE); - if ((this->doorType == SHUTTER_FRONT_SWITCH || this->doorType == SHUTTER_FRONT_SWITCH_BACK_CLEAR) && - !Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUYOSHUTTER_CLOSE); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYODOOR_CLOSE); + if ((pthis->doorType == SHUTTER_FRONT_SWITCH || pthis->doorType == SHUTTER_FRONT_SWITCH_BACK_CLEAR) && + !Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUYOSHUTTER_CLOSE); } - DoorShutter_SetupAction(this, func_80997528); + DoorShutter_SetupAction(pthis, func_80997528); } } } } -void func_80997150(DoorShutter* this, GlobalContext* globalCtx) { - if (this->unk_16F != 0) { - if (this->unk_16F < 0) { +void func_80997150(DoorShutter* pthis, GlobalContext* globalCtx) { + if (pthis->unk_16F != 0) { + if (pthis->unk_16F < 0) { if (globalCtx->state.frames % 2 != 0) { - this->unk_16F++; + pthis->unk_16F++; } - if (this->dyna.actor.category == func_8005B198() || this->unk_16F == 0) { - this->unk_16F = 5; + if (pthis->dyna.actor.category == func_8005B198() || pthis->unk_16F == 0) { + pthis->unk_16F = 5; } } else { - this->unk_16F--; + pthis->unk_16F--; } - } else if (func_80996E08(this, globalCtx, 0.0f)) { - if (!(this->doorType == SHUTTER || this->doorType == SHUTTER_FRONT_CLEAR)) { - DoorShutter_SetupAction(this, func_80996F98); + } else if (func_80996E08(pthis, globalCtx, 0.0f)) { + if (!(pthis->doorType == SHUTTER || pthis->doorType == SHUTTER_FRONT_CLEAR)) { + DoorShutter_SetupAction(pthis, func_80996F98); } else { - DoorShutter_SetupAction(this, func_80996B0C); + DoorShutter_SetupAction(pthis, func_80996B0C); } func_800F5B58(); } } -void func_80997220(DoorShutter* this, GlobalContext* globalCtx) { +void func_80997220(DoorShutter* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s8 room = this->dyna.actor.room; + s8 room = pthis->dyna.actor.room; - if (this->dyna.actor.room >= 0) { + if (pthis->dyna.actor.room >= 0) { Vec3f vec; - func_8002DBD0(&this->dyna.actor, &vec, &player->actor.world.pos); - this->dyna.actor.room = - globalCtx->transiActorCtx.list[(u16)this->dyna.actor.params >> 0xA].sides[(vec.z < 0.0f) ? 0 : 1].room; - if (room != this->dyna.actor.room) { + func_8002DBD0(&pthis->dyna.actor, &vec, &player->actor.world.pos); + pthis->dyna.actor.room = + globalCtx->transiActorCtx.list[(u16)pthis->dyna.actor.params >> 0xA].sides[(vec.z < 0.0f) ? 0 : 1].room; + if (room != pthis->dyna.actor.room) { Room tempRoom = globalCtx->roomCtx.curRoom; globalCtx->roomCtx.curRoom = globalCtx->roomCtx.prevRoom; @@ -569,101 +569,101 @@ void func_80997220(DoorShutter* this, GlobalContext* globalCtx) { func_80097534(globalCtx, &globalCtx->roomCtx); Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_DOWN, 0x0EFF); } - this->unk_164 = 0; - this->dyna.actor.velocity.y = 0.0f; - if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { - DoorShutter_SetupAction(this, func_80997568); + pthis->unk_164 = 0; + pthis->dyna.actor.velocity.y = 0.0f; + if (DoorShutter_SetupDoor(pthis, globalCtx) && !(player->stateFlags1 & 0x800)) { + DoorShutter_SetupAction(pthis, func_80997568); func_8002DF54(globalCtx, NULL, 2); } } -void func_809973E8(DoorShutter* this, GlobalContext* globalCtx) { +void func_809973E8(DoorShutter* pthis, GlobalContext* globalCtx) { s32 quakeId; - if (this->dyna.actor.velocity.y < 20.0f) { - Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); + if (pthis->dyna.actor.velocity.y < 20.0f) { + Math_StepToF(&pthis->dyna.actor.velocity.y, 20.0f, 8.0f); } - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { - if (this->dyna.actor.velocity.y > 20.0f) { - this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; - Actor_SpawnFloorDustRing(globalCtx, &this->dyna.actor, &this->dyna.actor.world.pos, 45.0f, 0xA, 8.0f, 0x1F4, + if (Math_StepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.velocity.y)) { + if (pthis->dyna.actor.velocity.y > 20.0f) { + pthis->dyna.actor.floorHeight = pthis->dyna.actor.home.pos.y; + Actor_SpawnFloorDustRing(globalCtx, &pthis->dyna.actor, &pthis->dyna.actor.world.pos, 45.0f, 0xA, 8.0f, 0x1F4, 0xA, 0); } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); quakeId = Quake_Add(Gameplay_GetCamera(globalCtx, 0), 3); Quake_SetSpeed(quakeId, -32536); Quake_SetQuakeValues(quakeId, 2, 0, 0, 0); Quake_SetCountdown(quakeId, 10); - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); - func_80997220(this, globalCtx); + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); + func_80997220(pthis, globalCtx); } } -void func_80997528(DoorShutter* this, GlobalContext* globalCtx) { - if (Math_StepToS(&this->unk_166, 0x64, 0xA)) { - func_80997220(this, globalCtx); +void func_80997528(DoorShutter* pthis, GlobalContext* globalCtx) { + if (Math_StepToS(&pthis->unk_166, 0x64, 0xA)) { + func_80997220(pthis, globalCtx); } } -void func_80997568(DoorShutter* this, GlobalContext* globalCtx) { - if (this->unk_16F++ > 30) { +void func_80997568(DoorShutter* pthis, GlobalContext* globalCtx) { + if (pthis->unk_16F++ > 30) { func_8002DF54(globalCtx, NULL, 7); - DoorShutter_SetupDoor(this, globalCtx); + DoorShutter_SetupDoor(pthis, globalCtx); } } -void func_809975C0(DoorShutter* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->dyna.actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); - if (this->dyna.actor.bgCheckFlags & 1) { - DoorShutter_SetupAction(this, func_809976B8); +void func_809975C0(DoorShutter* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + if (pthis->dyna.actor.bgCheckFlags & 1) { + DoorShutter_SetupAction(pthis, func_809976B8); if (!(gSaveContext.eventChkInf[7] & 1)) { - BossGoma* parent = (BossGoma*)this->dyna.actor.parent; + BossGoma* parent = (BossGoma*)pthis->dyna.actor.parent; - this->unk_164 = 10; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); + pthis->unk_164 = 10; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_STONE_BOUND); func_8099803C(globalCtx, 2, 10, parent->subCameraId); - Actor_SpawnFloorDustRing(globalCtx, &this->dyna.actor, &this->dyna.actor.world.pos, 70.0f, 20, 8.0f, 500, + Actor_SpawnFloorDustRing(globalCtx, &pthis->dyna.actor, &pthis->dyna.actor.world.pos, 70.0f, 20, 8.0f, 500, 10, 1); } } } -void func_809976B8(DoorShutter* this, GlobalContext* globalCtx) { +void func_809976B8(DoorShutter* pthis, GlobalContext* globalCtx) { f32 mult; - if (this->unk_164 != 0) { - this->unk_164--; - mult = sinf(this->unk_164 * 250.0f / 100.0f); - this->dyna.actor.shape.yOffset = this->unk_164 * 3.0f / 10.0f * mult; + if (pthis->unk_164 != 0) { + pthis->unk_164--; + mult = sinf(pthis->unk_164 * 250.0f / 100.0f); + pthis->dyna.actor.shape.yOffset = pthis->unk_164 * 3.0f / 10.0f * mult; } } -void func_80997744(DoorShutter* this, GlobalContext* globalCtx) { +void func_80997744(DoorShutter* pthis, GlobalContext* globalCtx) { f32 phi_f0; osSyncPrintf("FHG SAKU START !!\n"); - if (this->unk_164 != 0) { - this->unk_164--; + if (pthis->unk_164 != 0) { + pthis->unk_164--; } - phi_f0 = (this->unk_164 % 2 != 0) ? -3.0f : 0.0f; - Math_SmoothStepToF(&this->dyna.actor.world.pos.y, -34.0f + phi_f0, 1.0f, 20.0f, 0.0f); + phi_f0 = (pthis->unk_164 % 2 != 0) ? -3.0f : 0.0f; + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, -34.0f + phi_f0, 1.0f, 20.0f, 0.0f); osSyncPrintf("FHG SAKU END !!\n"); } void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx) { - DoorShutter* this = (DoorShutter*)thisx; + DoorShutter* pthis = (DoorShutter*)thisx; Player* player = GET_PLAYER(globalCtx); - if (!(player->stateFlags1 & 0x100004C0) || (this->actionFunc == DoorShutter_SetupType)) { - this->actionFunc(this, globalCtx); + if (!(player->stateFlags1 & 0x100004C0) || (pthis->actionFunc == DoorShutter_SetupType)) { + pthis->actionFunc(pthis, globalCtx); } } -Gfx* func_80997838(GlobalContext* globalCtx, DoorShutter* this, Gfx* p) { +Gfx* func_80997838(GlobalContext* globalCtx, DoorShutter* pthis, Gfx* p) { MtxF mtx; f32 angle = 0.0f; - f32 yScale = this->unk_166 * 0.01f; + f32 yScale = pthis->unk_166 * 0.01f; s32 i; Matrix_Get(&mtx); @@ -676,7 +676,7 @@ Gfx* func_80997838(GlobalContext* globalCtx, DoorShutter* this, Gfx* p) { } else { Matrix_Translate(0.0f, 989.94f, 0.0f, MTXMODE_APPLY); } - if (this->unk_166 != 100) { + if (pthis->unk_166 != 100) { Matrix_Scale(1.0f, yScale, 1.0f, MTXMODE_APPLY); } gSPMatrix(p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_shutter.c", 1991), @@ -688,15 +688,15 @@ Gfx* func_80997838(GlobalContext* globalCtx, DoorShutter* this, Gfx* p) { return p; } -s32 func_80997A34(DoorShutter* this, GlobalContext* globalCtx) { +s32 func_80997A34(DoorShutter* pthis, GlobalContext* globalCtx) { s32 phi_a1; s32 phi_a0; if (Player_InCsMode(globalCtx)) { return true; } - phi_a0 = (s16)(Actor_WorldYawTowardPoint(&this->dyna.actor, &globalCtx->view.eye) - this->dyna.actor.shape.rot.y); - phi_a1 = (s16)(this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y); + phi_a0 = (s16)(Actor_WorldYawTowardPoint(&pthis->dyna.actor, &globalCtx->view.eye) - pthis->dyna.actor.shape.rot.y); + phi_a1 = (s16)(pthis->dyna.actor.yawTowardsPlayer - pthis->dyna.actor.shape.rot.y); phi_a0 = ABS(phi_a0); phi_a1 = ABS(phi_a1); if ((phi_a1 < 0x4000 && phi_a0 > 0x4000) || (phi_a1 > 0x4000 && phi_a0 < 0x4000)) { @@ -706,33 +706,33 @@ s32 func_80997A34(DoorShutter* this, GlobalContext* globalCtx) { } void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - DoorShutter* this = (DoorShutter*)thisx; + DoorShutter* pthis = (DoorShutter*)thisx; //! @bug This actor is not fully initialized until the required object dependency is loaded. //! In most cases, the check for objBankIndex to equal requiredObjBankIndex prevents the actor //! from drawing until initialization is complete. However if the required object is the same as the - //! object dependency listed in init vars (gameplay_keep in this case), the check will pass even though - //! initialization has not completed. When this happens, it will try to draw the display list of the + //! object dependency listed in init vars (gameplay_keep in pthis case), the check will pass even though + //! initialization has not completed. When pthis happens, it will try to draw the display list of the //! first entry in `sShutterInfo`, which will likely crash the game. //! This only matters in very specific scenarios, when the door is unculled on the first possible frame //! after spawning. It will try to draw without having run update yet. //! - //! The best way to fix this issue (and what was done in Majora's Mask) is to null out the draw function in + //! The best way to fix pthis issue (and what was done in Majora's Mask) is to null out the draw function in //! the init vars for the actor, and only set draw after initialization is complete. - if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex && - (this->unk_16B == 0 || func_80997A34(this, globalCtx) != 0)) { + if (pthis->dyna.actor.objBankIndex == pthis->requiredObjBankIndex && + (pthis->unk_16B == 0 || func_80997A34(pthis, globalCtx) != 0)) { s32 pad[2]; - ShutterInfo* sp70 = &sShutterInfo[this->unk_16C]; + ShutterInfo* sp70 = &sShutterInfo[pthis->unk_16C]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_shutter.c", 2048); func_80093D18(globalCtx->state.gfxCtx); - if (this->unk_16C == 3) { - POLY_OPA_DISP = func_80997838(globalCtx, this, POLY_OPA_DISP); - if (this->unk_170 != 0.0f) { - f32 sp58 = (this->unk_166 * 0.01f) * this->unk_170; + if (pthis->unk_16C == 3) { + POLY_OPA_DISP = func_80997838(globalCtx, pthis, POLY_OPA_DISP); + if (pthis->unk_170 != 0.0f) { + f32 sp58 = (pthis->unk_166 * 0.01f) * pthis->unk_170; func_80093D18(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255.0f * sp58); @@ -745,38 +745,38 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { if (sp70->b != NULL) { TransitionActorEntry* transitionEntry = - &globalCtx->transiActorCtx.list[(u16)this->dyna.actor.params >> 0xA]; + &globalCtx->transiActorCtx.list[(u16)pthis->dyna.actor.params >> 0xA]; if (globalCtx->roomCtx.prevRoom.num >= 0 || transitionEntry->sides[0].room == transitionEntry->sides[1].room) { - s32 yaw = Math_Vec3f_Yaw(&globalCtx->view.eye, &this->dyna.actor.world.pos); + s32 yaw = Math_Vec3f_Yaw(&globalCtx->view.eye, &pthis->dyna.actor.world.pos); - if (ABS((s16)(this->dyna.actor.shape.rot.y - yaw)) < 0x4000) { + if (ABS((s16)(pthis->dyna.actor.shape.rot.y - yaw)) < 0x4000) { Matrix_RotateY(M_PI, MTXMODE_APPLY); } - } else if (this->dyna.actor.room == transitionEntry->sides[0].room) { + } else if (pthis->dyna.actor.room == transitionEntry->sides[0].room) { Matrix_RotateY(M_PI, MTXMODE_APPLY); } - } else if (this->doorType == SHUTTER_BOSS) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809982D4[this->unk_168])); + } else if (pthis->doorType == SHUTTER_BOSS) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809982D4[pthis->unk_168])); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_shutter.c", 2109), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sp70->a); - if (this->unk_170 != 0.0f && sp70->b != NULL) { - Matrix_Translate(0, sp70->c * (1.0f - this->unk_170), sp70->translateZ, MTXMODE_APPLY); + if (pthis->unk_170 != 0.0f && sp70->b != NULL) { + Matrix_Translate(0, sp70->c * (1.0f - pthis->unk_170), sp70->translateZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_shutter.c", 2119), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sp70->b); } } - if (this->unk_16E != 0) { + if (pthis->unk_16E != 0) { Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY); - Actor_DrawDoorLock(globalCtx, this->unk_16E, - (this->doorType == SHUTTER_BOSS) + Actor_DrawDoorLock(globalCtx, pthis->unk_16E, + (pthis->doorType == SHUTTER_BOSS) ? DOORLOCK_BOSS - : ((this->unk_16C == 6) ? DOORLOCK_NORMAL_SPIRIT : DOORLOCK_NORMAL)); + : ((pthis->unk_16C == 6) ? DOORLOCK_NORMAL_SPIRIT : DOORLOCK_NORMAL)); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_shutter.c", 2135); diff --git a/src/overlays/actors/ovl_Door_Toki/z_door_toki.c b/src/overlays/actors/ovl_Door_Toki/z_door_toki.cpp similarity index 67% rename from src/overlays/actors/ovl_Door_Toki/z_door_toki.c rename to src/overlays/actors/ovl_Door_Toki/z_door_toki.cpp index 2b2da317c..4ad53791f 100644 --- a/src/overlays/actors/ovl_Door_Toki/z_door_toki.c +++ b/src/overlays/actors/ovl_Door_Toki/z_door_toki.cpp @@ -19,7 +19,7 @@ void DoorToki_Init(Actor* thisx, GlobalContext* globalCtx); void DoorToki_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorToki_Update(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Door_Toki_InitVars = { +ActorInit Door_Toki_InitVars = { ACTOR_DOOR_TOKI, ACTORCAT_BG, FLAGS, @@ -37,27 +37,27 @@ static InitChainEntry sInitChain[] = { void DoorToki_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - DoorToki* this = (DoorToki*)thisx; + DoorToki* pthis = (DoorToki*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gDoorTokiCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); } void DoorToki_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DoorToki* this = (DoorToki*)thisx; + DoorToki* pthis = (DoorToki*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void DoorToki_Update(Actor* thisx, GlobalContext* globalCtx) { - DoorToki* this = (DoorToki*)thisx; + DoorToki* pthis = (DoorToki*)thisx; if (gSaveContext.eventChkInf[4] & 0x800) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } else { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c deleted file mode 100644 index 3bf0c5a9a..000000000 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ /dev/null @@ -1,1064 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DOOR_WARP1_Z_DOOR_WARP1_C -#include "actor_common.h" -#include "z_door_warp1.h" -#include "objects/object_warp1/object_warp1.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx); -void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx); -void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx); - -void DoorWarp1_WarpAppear(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_Destination(DoorWarp1* this, GlobalContext* globalCtx); -void func_8099B020(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_AwaitClearFlag(DoorWarp1* this, GlobalContext* globalCtx); -void func_8099A3A4(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_BlueCrystal(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_PurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx); -void func_80999214(DoorWarp1* this, GlobalContext* globalCtx); -void func_80999348(DoorWarp1* this, GlobalContext* globalCtx); -void func_809995D4(DoorWarp1* this, GlobalContext* globalCtx); -void func_809998A4(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_ChildWarpIdle(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_RutoWarpIdle(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_ChildWarpOut(DoorWarp1* this, GlobalContext* globalCtx); -void func_80999EE0(DoorWarp1* this, GlobalContext* globalCtx); -void func_80999FE4(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_RutoWarpOut(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_AdultWarpIdle(DoorWarp1* this, GlobalContext* globalCtx); -void func_8099A508(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_AdultWarpOut(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_DoNothing(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_ChooseInitialAction(DoorWarp1* this, GlobalContext* globalCtx); -void DoorWarp1_FloatPlayer(DoorWarp1* this, GlobalContext* globalCtx); - -const ActorInit Door_Warp1_InitVars = { - ACTOR_DOOR_WARP1, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_WARP1, - sizeof(DoorWarp1), - (ActorFunc)DoorWarp1_Init, - (ActorFunc)DoorWarp1_Destroy, - (ActorFunc)DoorWarp1_Update, - (ActorFunc)DoorWarp1_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 4000, ICHAIN_STOP), -}; - -static s16 sWarpTimerTarget; - -void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { - DoorWarp1* this = (DoorWarp1*)thisx; - GlobalContext* globalCtx2 = globalCtx; - - this->unk_1B8 = 0; - this->unk_1B4 = 0.0f; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - - if (this->actor.params != WARP_SAGES && this->actor.params != WARP_BLUE_CRYSTAL && - this->actor.params != WARP_YELLOW && this->actor.params != WARP_DESTINATION) { - Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); - this->upperLight = LightContext_InsertLight(globalCtx2, &globalCtx2->lightCtx, &this->upperLightInfo); - - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); - this->lowerLight = LightContext_InsertLight(globalCtx2, &globalCtx2->lightCtx, &this->lowerLightInfo); - } - osSyncPrintf("\nBOSSWARP arg_data=[%d]", this->actor.params); - - DoorWarp1_ChooseInitialAction(this, globalCtx2); -} - -void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { - u8 i; - DoorWarp1* this = (DoorWarp1*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->upperLight); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lowerLight); - - for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = globalCtx->envCtx.adjLight1Color[i] = - 0; - } - //! @bug SkelAnime_Free is not called for crystal variants -} - -void DoorWarp1_SetupWarp(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->scale = 0; - this->unk_1AE = -140; - this->unk_1B0 = -80; - sWarpTimerTarget = 100; - this->unk_1BC = 1.0f; - this->lightRayAlpha = 0.0f; - this->warpAlpha = 0.0f; - this->crystalAlpha = 0.0f; - - switch (this->actor.params) { - case WARP_YELLOW: - case WARP_ORANGE: - case WARP_GREEN: - case WARP_RED: - this->unk_194 = 0.23f; - this->unk_198 = 0.6f; - break; - case WARP_DESTINATION: - this->unk_194 = 0.0f; - this->unk_198 = 0.0f; - break; - case WARP_UNK_7: - this->scale = 100; - this->unk_1AE = 120; - this->unk_1B0 = 230; - this->unk_194 = 0.3f; - this->unk_198 = 0.3f; - break; - case WARP_BLUE_RUTO: - default: - this->unk_194 = 0.3f; - this->unk_198 = 0.3f; - break; - } - - this->unk_19C = 0.0f; - this->actor.shape.yOffset = 1.0f; - this->warpTimer = 0; - - switch (this->actor.params) { - case WARP_PURPLE_CRYSTAL: - case WARP_BLUE_RUTO: - case WARP_UNK_7: - default: - Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 200, 255, 255, 255); - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 200, 255, 255, 255); - break; - case WARP_CLEAR_FLAG: - case WARP_SAGES: - case WARP_YELLOW: - case WARP_DESTINATION: - case WARP_ORANGE: - case WARP_GREEN: - case WARP_RED: - break; - } - - switch (this->actor.params) { - case WARP_CLEAR_FLAG: - DoorWarp1_SetupAction(this, DoorWarp1_AwaitClearFlag); - break; - case WARP_DESTINATION: - if ((!(gSaveContext.entranceIndex == 0x608 || // sacred forest meadow - gSaveContext.entranceIndex == 0x564 || // death mountain crater - gSaveContext.entranceIndex == 0x60C || // lake hylia - gSaveContext.entranceIndex == 0x610 || // desert colossus - gSaveContext.entranceIndex == 0x580) && // graveyard - gSaveContext.sceneSetupIndex < 4) || - (GET_PLAYER(globalCtx)->actor.params & 0xF00) != 0x200) { - Actor_Kill(&this->actor); - } - if (Actor_WorldDistXZToActor(&player->actor, &this->actor) > 100.0f) { - Actor_Kill(&this->actor); - } - DoorWarp1_SetupAction(this, DoorWarp1_Destination); - break; - case WARP_UNK_7: - DoorWarp1_SetupAction(this, func_8099B020); - break; - default: - DoorWarp1_SetupAction(this, DoorWarp1_WarpAppear); - break; - } -} - -void DoorWarp1_SetupAdultDungeonWarp(DoorWarp1* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); - Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 40.0f, 1); - - this->scale = 0; - this->unk_1AE = -140; - this->unk_1B0 = -80; - sWarpTimerTarget = 160; - this->actor.shape.yOffset = -400.0f; - this->warpTimer = 0; - this->unk_1BC = 1.0f; - this->unk_194 = 0.3f; - this->unk_198 = 0.3f; - this->lightRayAlpha = 0.0f; - this->warpAlpha = 0.0f; - this->crystalAlpha = 0.0f; - this->unk_19C = 0.0f; - - Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 200, 255, 255, 255); - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 200, 255, 255, 255); - - DoorWarp1_SetupAction(this, func_8099A3A4); -} - -void DoorWarp1_SetupBlueCrystal(DoorWarp1* this, GlobalContext* globalCtx) { - s16 i; - - SkelAnime_Init(globalCtx, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); - Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 0, Animation_GetLastFrame(&gWarpCrystalAnim), - Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 0.0f, 1); - - this->skelAnime.curFrame = Animation_GetLastFrame(&gWarpCrystalAnim); - this->scale = 10; - this->unk_1AE = 120; - this->unk_1B0 = 230; - this->warpTimer = 0; - this->unk_194 = 0.3f; - this->unk_198 = 0.3f; - this->lightRayAlpha = 0.0f; - this->warpAlpha = 0.0f; - this->crystalAlpha = 0.0f; - this->unk_19C = 0.0f; - this->unk_1BC = 1.0f; - this->actor.shape.yOffset = 800.0f; - - for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = globalCtx->envCtx.adjLight1Color[i] = - -255; - } - - globalCtx->envCtx.adjFogNear = -500; - this->warpTimer = 30; - this->unk_1B8 = 4000; - DoorWarp1_SetupAction(this, DoorWarp1_BlueCrystal); -} - -void DoorWarp1_SetupPurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); - Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 0, Animation_GetLastFrame(&gWarpCrystalAnim), - Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 0.0f, 1); - - this->skelAnime.curFrame = Animation_GetLastFrame(&gWarpCrystalAnim); - this->unk_1AE = 120; - this->unk_1B0 = 230; - this->warpTimer = 200; - this->unk_1B8 = 4000; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 1.0f; - this->unk_194 = 0.3f; - this->unk_198 = 0.3f; - this->lightRayAlpha = 0.0f; - this->warpAlpha = 0.0f; - this->crystalAlpha = 0.0f; - this->unk_19C = 0.0f; - this->unk_1BC = 1.f; - this->actor.shape.yOffset = 800.0f; - - if (gSaveContext.entranceIndex != 0x53) { - this->actor.scale.x = 0.0499f; - this->actor.scale.y = 0.077f; - this->actor.scale.z = 0.09f; - this->crystalAlpha = 255.0f; - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SHUT_BY_CRYSTAL); - } - DoorWarp1_SetupAction(this, DoorWarp1_PurpleCrystal); -} - -void DoorWarp1_SetPlayerPos(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - player->actor.velocity.y = 0.0f; - player->actor.world.pos.x = this->actor.world.pos.x; - player->actor.world.pos.y = this->actor.world.pos.y + 55.0f; - player->actor.world.pos.z = this->actor.world.pos.z; -} - -void DoorWarp1_BlueCrystal(DoorWarp1* this, GlobalContext* globalCtx) { - if (this->warpTimer != 0) { - this->warpTimer--; - } else { - DoorWarp1_SetupAction(this, func_80999214); - } - DoorWarp1_SetPlayerPos(this, globalCtx); -} - -void func_80999214(DoorWarp1* this, GlobalContext* globalCtx) { - s32 temp_f4; - f32 darkness; - s16 i; - - Math_SmoothStepToF(&this->crystalAlpha, 255.0f, 0.2f, 5.0f, 0.1f); - - darkness = (f32)(40 - this->warpTimer) / 40.0f; - darkness = CLAMP_MIN(darkness, 0); - - for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = globalCtx->envCtx.adjLight1Color[i] = - -255.0f * darkness; - } - globalCtx->envCtx.adjFogNear = -500.0f * darkness; - - this->warpTimer++; - if (darkness <= 0) { - DoorWarp1_SetupAction(this, func_80999348); - } - this->actor.shape.rot.y += 0x320; - DoorWarp1_SetPlayerPos(this, globalCtx); -} - -void func_80999348(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - DoorWarp1_SetPlayerPos(this, globalCtx); - - if (this->warpTimer == 0) { - Math_SmoothStepToF(&this->crystalAlpha, 0.0f, 0.1f, 4.0f, 1.0f); - if (this->crystalAlpha <= 150.0f) { - player->actor.gravity = -0.1f; - } - if (this->crystalAlpha <= 0.0f) { - DoorWarp1_SetupAction(this, DoorWarp1_FloatPlayer); - } - } else { - this->warpTimer--; - } - this->actor.shape.rot.y += 0x320; -} - -void DoorWarp1_FloatPlayer(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - player->actor.gravity = -0.1f; -} - -void DoorWarp1_PurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx) { - if (this->warpTimer != 0) { - this->warpTimer--; - Math_SmoothStepToF(&this->actor.scale.x, 0.0499f, 0.2f, 0.05f, 0.001f); - Math_SmoothStepToF(&this->actor.scale.y, 0.077f, 0.2f, 0.05f, 0.001f); - Math_SmoothStepToF(&this->actor.scale.z, 0.09f, 0.2f, 0.05f, 0.001f); - Math_SmoothStepToF(&this->crystalAlpha, 255.0f, 0.2f, 5.0f, 0.1f); - } -} - -void DoorWarp1_ChooseInitialAction(DoorWarp1* this, GlobalContext* globalCtx) { - switch (this->actor.params) { - case WARP_DUNGEON_CHILD: - case WARP_CLEAR_FLAG: - case WARP_SAGES: - case WARP_YELLOW: - case WARP_BLUE_RUTO: - case WARP_DESTINATION: - case WARP_UNK_7: - case WARP_ORANGE: - case WARP_GREEN: - case WARP_RED: - DoorWarp1_SetupWarp(this, globalCtx); - break; - case WARP_DUNGEON_ADULT: - DoorWarp1_SetupAdultDungeonWarp(this, globalCtx); - break; - case WARP_BLUE_CRYSTAL: - DoorWarp1_SetupBlueCrystal(this, globalCtx); - break; - case WARP_PURPLE_CRYSTAL: - DoorWarp1_SetupPurpleCrystal(this, globalCtx); - break; - } -} - -void DoorWarp1_AwaitClearFlag(DoorWarp1* this, GlobalContext* globalCtx) { - if (Flags_GetTempClear(globalCtx, this->actor.room)) { - this->warpTimer = 200; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); - DoorWarp1_SetupAction(this, func_809995D4); - } -} - -void func_809995D4(DoorWarp1* this, GlobalContext* globalCtx) { - if (this->warpTimer == 0) { - if (this->actor.xzDistToPlayer < 100.0f) { - this->actor.world.pos.x = -98.0f; - this->actor.world.pos.y = 827.0f; - this->actor.world.pos.z = -3228.0f; - } - Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 200, 255, 255, 255); - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 200, 255, 255, 255); - DoorWarp1_SetupAction(this, DoorWarp1_WarpAppear); - } - this->warpTimer--; -} - -void DoorWarp1_WarpAppear(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - Math_SmoothStepToF(&this->lightRayAlpha, 255.0f, 0.4f, 10.0f, 0.01f); - Math_SmoothStepToF(&this->warpAlpha, 255.0f, 0.4f, 10.0f, 0.01f); - - if (this->actor.params != WARP_YELLOW && this->actor.params != WARP_ORANGE && this->actor.params != WARP_GREEN && - this->actor.params != WARP_RED) { - if (this->scale < 100) { - this->scale += 2; - } - if (this->unk_1AE < 120) { - this->unk_1AE += 4; - } - if (this->unk_1B0 < 230) { - this->unk_1B0 += 4; - } else if (this->actor.params == WARP_BLUE_RUTO) { - DoorWarp1_SetupAction(this, DoorWarp1_RutoWarpIdle); - } else if (this->actor.params != WARP_SAGES && this->actor.params != WARP_YELLOW) { - DoorWarp1_SetupAction(this, DoorWarp1_ChildWarpIdle); - } else { - DoorWarp1_SetupAction(this, func_809998A4); - } - } else { - if (this->unk_1AE < -50) { - this->unk_1AE += 4; - } - if (this->unk_1B0 < 70) { - this->unk_1B0 += 4; - } else { - DoorWarp1_SetupAction(this, func_809998A4); - } - } -} - -void func_809998A4(DoorWarp1* this, GlobalContext* globalCtx) { - if (this->lightRayAlpha != 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - } - Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.1f, 2.0f, 0.01f); - Math_SmoothStepToF(&this->warpAlpha, 0.0f, 0.1f, 2.0f, 0.01f); -} - -s32 DoorWarp1_PlayerInRange(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 ret = false; - - if (fabsf(this->actor.xzDistToPlayer) < 60.0f) { - if ((player->actor.world.pos.y - 20.0f) < this->actor.world.pos.y) { - if (this->actor.world.pos.y < (player->actor.world.pos.y + 20.0f)) { - ret = true; - } - } - } - return ret; -} - -void DoorWarp1_ChildWarpIdle(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player; - - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - - if (DoorWarp1_PlayerInRange(this, globalCtx)) { - player = GET_PLAYER(globalCtx); - - Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - OnePointCutscene_Init(globalCtx, 0x25E7, 999, &this->actor, MAIN_CAM); - func_8002DF54(globalCtx, &this->actor, 10); - - player->unk_450.x = this->actor.world.pos.x; - player->unk_450.z = this->actor.world.pos.z; - this->unk_1B2 = 1; - DoorWarp1_SetupAction(this, DoorWarp1_ChildWarpOut); - } -} - -void DoorWarp1_ChildWarpOut(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->unk_1B2 >= 101) { - if (player->actor.velocity.y < 10.0f) { - player->actor.gravity = 0.1f; - } else { - player->actor.gravity = 0.0f; - } - } else { - this->unk_1B2++; - } - - Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.2f, 6.0f, 0.01f); - this->warpTimer++; - - if (sWarpTimerTarget < this->warpTimer && gSaveContext.nextCutsceneIndex == 0xFFEF) { - osSyncPrintf("\n\n\nじかんがきたからおーしまい fade_direction=[%d]", globalCtx->sceneLoadFlag, 0x14); - - if (globalCtx->sceneNum == SCENE_DDAN_BOSS) { - if (!Flags_GetEventChkInf(0x25)) { - Flags_SetEventChkInf(0x25); - Item_Give(globalCtx, ITEM_GORON_RUBY); - globalCtx->nextEntranceIndex = 0x13D; - gSaveContext.nextCutsceneIndex = 0xFFF1; - } else { - globalCtx->nextEntranceIndex = 0x47A; - gSaveContext.nextCutsceneIndex = 0; - } - } else if (globalCtx->sceneNum == SCENE_YDAN_BOSS) { - if (!Flags_GetEventChkInf(7)) { - Flags_SetEventChkInf(7); - Flags_SetEventChkInf(9); - Item_Give(globalCtx, ITEM_KOKIRI_EMERALD); - globalCtx->nextEntranceIndex = 0xEE; - gSaveContext.nextCutsceneIndex = 0xFFF1; - } else { - globalCtx->nextEntranceIndex = 0x457; - gSaveContext.nextCutsceneIndex = 0; - } - } else if (globalCtx->sceneNum == SCENE_BDAN_BOSS) { - globalCtx->nextEntranceIndex = 0x10E; - gSaveContext.nextCutsceneIndex = 0; - } - osSyncPrintf("\n\n\nおわりおわり"); - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 7; - gSaveContext.nextTransition = 3; - } - - Math_StepToF(&this->unk_194, 2.0f, 0.01f); - Math_StepToF(&this->unk_198, 10.0f, 0.02f); - Lights_PointNoGlowSetInfo(&this->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, - (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, - 255, 255); - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, - (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, - 255, 255); - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); -} - -void DoorWarp1_RutoWarpIdle(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - - if (this->rutoWarpState != WARP_BLUE_RUTO_STATE_INITIAL && DoorWarp1_PlayerInRange(this, globalCtx)) { - this->rutoWarpState = WARP_BLUE_RUTO_STATE_ENTERED; - func_8002DF54(globalCtx, &this->actor, 10); - this->unk_1B2 = 1; - DoorWarp1_SetupAction(this, func_80999EE0); - } -} - -static s16 sRutoWarpSubCamId; - -void func_80999EE0(DoorWarp1* this, GlobalContext* globalCtx) { - Vec3f at; - Vec3f eye; - Player* player = GET_PLAYER(globalCtx); - - if (this->rutoWarpState == WARP_BLUE_RUTO_STATE_3) { - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - sRutoWarpSubCamId = Gameplay_CreateSubCamera(globalCtx); - - Gameplay_ChangeCameraStatus(globalCtx, sRutoWarpSubCamId, CAM_STAT_ACTIVE); - at.x = this->actor.world.pos.x; - at.y = 49.0f; - at.z = this->actor.world.pos.z; - eye.x = player->actor.world.pos.x; - eye.y = 43.0f; - eye.z = player->actor.world.pos.z; - - Gameplay_CameraSetAtEye(globalCtx, sRutoWarpSubCamId, &at, &eye); - Gameplay_CameraSetFov(globalCtx, sRutoWarpSubCamId, 90.0f); - this->rutoWarpState = WARP_BLUE_RUTO_STATE_TALKING; - Message_StartTextbox(globalCtx, 0x4022, NULL); - DoorWarp1_SetupAction(this, func_80999FE4); - } -} - -void func_80999FE4(DoorWarp1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { - Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - OnePointCutscene_Init(globalCtx, 0x25E9, 999, &this->actor, MAIN_CAM); - Gameplay_CopyCamera(globalCtx, -1, sRutoWarpSubCamId); - Gameplay_ChangeCameraStatus(globalCtx, sRutoWarpSubCamId, CAM_STAT_WAIT); - this->rutoWarpState = WARP_BLUE_RUTO_STATE_WARPING; - DoorWarp1_SetupAction(this, DoorWarp1_RutoWarpOut); - } -} - -void DoorWarp1_RutoWarpOut(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->unk_1B2 >= 61) { - if (player->actor.velocity.y < 10.f) { - player->actor.gravity = 0.02f; - } else { - player->actor.gravity = 0.0f; - } - } else { - this->unk_1B2++; - } - Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.2f, 6.0f, 0.01f); - this->warpTimer++; - - if (this->warpTimer > sWarpTimerTarget && gSaveContext.nextCutsceneIndex == 0xFFEF) { - gSaveContext.eventChkInf[3] |= 0x80; - Item_Give(globalCtx, ITEM_ZORA_SAPPHIRE); - globalCtx->nextEntranceIndex = 0x10E; - gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 7; - } - - Math_StepToF(&this->unk_194, 2.0f, 0.01f); - Math_StepToF(&this->unk_198, 10.f, 0.02f); - Lights_PointNoGlowSetInfo(&this->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, - (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, - 255, 255); - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, - (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, - 255, 255); - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); -} - -void func_8099A3A4(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - Math_SmoothStepToF(&this->lightRayAlpha, 255.0f, 0.2f, 2.0f, 0.1f); - Math_SmoothStepToF(&this->warpAlpha, 255.0f, 0.2f, 2.0f, 0.1f); - - if (this->scale < 10) { - this->scale += 2; - } - if (this->unk_1AE < 120) { - this->unk_1AE += 4; - } - if (this->unk_1B0 < 230) { - this->unk_1B0 += 4; - } else { - DoorWarp1_SetupAction(this, DoorWarp1_AdultWarpIdle); - } -} - -void DoorWarp1_AdultWarpIdle(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player; - - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - - if (DoorWarp1_PlayerInRange(this, globalCtx)) { - player = GET_PLAYER(globalCtx); - - OnePointCutscene_Init(globalCtx, 0x25E8, 999, &this->actor, MAIN_CAM); - func_8002DF54(globalCtx, &this->actor, 10); - player->unk_450.x = this->actor.world.pos.x; - player->unk_450.z = this->actor.world.pos.z; - this->unk_1B2 = 20; - DoorWarp1_SetupAction(this, func_8099A508); - } -} - -void func_8099A508(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->unk_1B2 != 0) { - this->unk_1B2--; - return; - } - Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, Animation_GetLastFrame(&gWarpCrystalAnim), - Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 40.0f, 1); - - this->unk_1B2 = 0x32; - DoorWarp1_SetupAction(this, DoorWarp1_AdultWarpOut); -} - -void DoorWarp1_AdultWarpOut(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 temp_f0_2; - - if (this->unk_1B2 != 0) { - this->unk_1B2--; - } - - if (this->unk_1B2 < 31) { - u32 phi_v0 = (LINK_IS_ADULT) ? 35 : 45; - - if ((player->actor.world.pos.y - this->actor.world.pos.y) <= phi_v0) { - player->actor.gravity = 0.0139999995f; - } else { - player->actor.gravity = 0.0f; - player->actor.velocity.y = 0.0f; - } - if (this->unk_1B2 <= 0) { - if (this->unk_1B8 < 4000) { - this->unk_1B8 += 40; - } - player->actor.world.rot.y -= this->unk_1B8; - player->actor.shape.rot.y -= this->unk_1B8; - } - Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 0.5f, 0.1f, 0.01f); - Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 0.5f, 0.1f, 0.01f); - } - this->warpTimer++; - - if (this->warpTimer > sWarpTimerTarget && gSaveContext.nextCutsceneIndex == 0xFFEF) { - if (globalCtx->sceneNum == SCENE_MORIBOSSROOM) { - if (!(gSaveContext.eventChkInf[4] & 0x100)) { - gSaveContext.eventChkInf[4] |= 0x100; - Item_Give(globalCtx, ITEM_MEDALLION_FOREST); - globalCtx->nextEntranceIndex = 0x6B; - gSaveContext.nextCutsceneIndex = 0; - gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST; - } else { - if (!LINK_IS_ADULT) { - globalCtx->nextEntranceIndex = 0x600; - } else { - globalCtx->nextEntranceIndex = 0x608; - } - gSaveContext.nextCutsceneIndex = 0; - } - } else if (globalCtx->sceneNum == SCENE_FIRE_BS) { - if (!(gSaveContext.eventChkInf[4] & 0x200)) { - gSaveContext.eventChkInf[4] |= 0x200; - Item_Give(globalCtx, ITEM_MEDALLION_FIRE); - globalCtx->nextEntranceIndex = 0xDB; - gSaveContext.nextCutsceneIndex = 0xFFF3; - } else { - if (!LINK_IS_ADULT) { - globalCtx->nextEntranceIndex = 0x4F6; - } else { - globalCtx->nextEntranceIndex = 0x564; - } - gSaveContext.nextCutsceneIndex = 0; - } - } else if (globalCtx->sceneNum == SCENE_MIZUSIN_BS) { - if (!(gSaveContext.eventChkInf[4] & 0x400)) { - gSaveContext.eventChkInf[4] |= 0x400; - Item_Give(globalCtx, ITEM_MEDALLION_WATER); - globalCtx->nextEntranceIndex = 0x6B; - gSaveContext.nextCutsceneIndex = 0; - gSaveContext.chamberCutsceneNum = CHAMBER_CS_WATER; - } else { - if (!LINK_IS_ADULT) { - globalCtx->nextEntranceIndex = 0x604; - } else { - globalCtx->nextEntranceIndex = 0x60C; - } - gSaveContext.nextCutsceneIndex = 0; - } - } else if (globalCtx->sceneNum == SCENE_JYASINBOSS) { - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); - globalCtx->nextEntranceIndex = 0x6B; - gSaveContext.nextCutsceneIndex = 0; - gSaveContext.chamberCutsceneNum = CHAMBER_CS_SPIRIT; - } else { - if (!LINK_IS_ADULT) { - globalCtx->nextEntranceIndex = 0x1F1; - } else { - globalCtx->nextEntranceIndex = 0x610; - } - gSaveContext.nextCutsceneIndex = 0; - } - } else if (globalCtx->sceneNum == SCENE_HAKADAN_BS) { - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { - Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); - globalCtx->nextEntranceIndex = 0x6B; - gSaveContext.nextCutsceneIndex = 0; - gSaveContext.chamberCutsceneNum = CHAMBER_CS_SHADOW; - } else { - if (!LINK_IS_ADULT) { - globalCtx->nextEntranceIndex = 0x568; - } else { - globalCtx->nextEntranceIndex = 0x580; - } - gSaveContext.nextCutsceneIndex = 0; - } - } - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; - gSaveContext.nextTransition = 7; - } - if (this->warpTimer >= 141) { - f32 screenFillAlpha; - - globalCtx->envCtx.fillScreen = true; - screenFillAlpha = (f32)(this->warpTimer - 140) / 20.0f; - - if (screenFillAlpha > 1.0f) { - screenFillAlpha = 1.0f; - } - globalCtx->envCtx.screenFillColor[0] = 160; - globalCtx->envCtx.screenFillColor[1] = 160; - globalCtx->envCtx.screenFillColor[2] = 160; - globalCtx->envCtx.screenFillColor[3] = (u32)(255.0f * screenFillAlpha); - - osSyncPrintf("\nparcent=[%f]", screenFillAlpha); - } - Lights_PointNoGlowSetInfo(&this->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, - (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, - 255, 255); - Lights_PointNoGlowSetInfo(&this->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, - (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, - 255, 255); - - Math_SmoothStepToF(&this->actor.shape.yOffset, 800.0f, 0.5f, 15.0f, 0.1f); - this->actor.shape.rot.y += 0x320; - - Math_SmoothStepToF(&this->unk_1BC, 1.13f, 0.2f, 0.1f, 0.01f); - Math_StepToF(&this->unk_194, 2.0f, 0.003f); - Math_StepToF(&this->unk_198, 10.0f, 0.006f); - Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.2f, 3.0f, 0.01f); - Math_SmoothStepToF(&this->warpAlpha, 0.0f, 0.2f, 2.0f, 0.01f); - Math_SmoothStepToF(&this->crystalAlpha, 255.0f, 0.1f, 1.0f, 0.01f); - - temp_f0_2 = 1.0f - (f32)(sWarpTimerTarget - this->warpTimer) / (sWarpTimerTarget - (sWarpTimerTarget - 100)); - if (temp_f0_2 > 0.0f) { - s16 i; - - for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = - globalCtx->envCtx.adjLight1Color[i] = -255.0f * temp_f0_2; - } - - globalCtx->envCtx.adjFogNear = -500.0f * temp_f0_2; - if (globalCtx->envCtx.adjFogNear < -300) { - globalCtx->roomCtx.curRoom.segment = NULL; - } - } -} - -void DoorWarp1_Destination(DoorWarp1* this, GlobalContext* globalCtx) { - f32 alphaFrac; - - this->warpTimer++; - this->unk_194 = 5.0f; - - alphaFrac = 1.0f; - if (this->warpTimer < 20) { - alphaFrac = this->warpTimer / 20.f; - } else if (this->warpTimer >= 60) { - alphaFrac = 1.0f - ((this->warpTimer - 60.0f) / 20.f); - } - this->warpAlpha = 255.0f * alphaFrac; - this->lightRayAlpha = 0.0f; - - if (this->warpTimer >= 80.0f) { - this->warpAlpha = 0.0f; - DoorWarp1_SetupAction(this, DoorWarp1_DoNothing); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); -} - -void DoorWarp1_DoNothing(DoorWarp1* this, GlobalContext* globalCtx) { -} - -void func_8099B020(DoorWarp1* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->lightRayAlpha, 128.0f, 0.2f, 2.0f, 0.1f); - Math_SmoothStepToF(&this->warpAlpha, 128.0f, 0.2f, 2.0f, 0.1f); - - if (this->lightRayAlpha >= 128.0f) { - Math_StepToF(&this->unk_194, 2.0f, 0.01f); - Math_StepToF(&this->unk_198, 10.0f, 0.02f); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); -} - -void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx) { - DoorWarp1* this = (DoorWarp1*)thisx; - - this->actionFunc(this, globalCtx); - - if (this->actor.params != WARP_PURPLE_CRYSTAL) { - Actor_SetScale(&this->actor, this->scale / 100.0f); - } -} - -void DoorWarp1_DrawBlueCrystal(DoorWarp1* this, GlobalContext* globalCtx) { - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2078); - - func_80093D84(globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (u8)this->crystalAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (u8)this->crystalAlpha); - - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, - &this->actor, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2098); - - SkelAnime_Update(&this->skelAnime); -} - -void DoorWarp1_DrawPurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx) { - s32 pad[2]; - Vec3f eye; - - eye.x = -(Math_SinS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; - eye.y = (Math_CosS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; - eye.z = (Math_CosS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2122); - - func_80093D84(globalCtx->state.gfxCtx); - func_8002EB44(&this->actor.world.pos, &eye, &eye, globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->crystalAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 150, 0, 100, (u8)this->crystalAlpha); - - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, - &this->actor, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2152); - - SkelAnime_Update(&this->skelAnime); -} - -void DoorWarp1_DrawWarp(DoorWarp1* this, GlobalContext* globalCtx) { - s32 pad; - u32 pad1; - u32 spEC = globalCtx->state.frames * 10; - f32 spE8 = (this->unk_194 >= 1.0f) ? 0.0f : 1.0f - this->unk_194; - f32 spE4 = (this->unk_198 >= 1.0f) ? 0.0f : 1.0f - this->unk_198; - f32 xzScale; - f32 temp_f0; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2173); - - temp_f0 = 1.0f - (2.0f - this->unk_194) / 1.7f; - if (this->actor.params != WARP_YELLOW && this->actor.params != WARP_DESTINATION && - this->actor.params != WARP_ORANGE && this->actor.params != WARP_GREEN && this->actor.params != WARP_RED) { - this->unk_19C += (s16)(temp_f0 * 15.0f); - } - if (this->actor.params == WARP_DESTINATION) { - this->unk_19C -= (s16)(temp_f0 * 2.0f); - } - func_80093D84(globalCtx->state.gfxCtx); - - switch (this->actor.params) { - case WARP_YELLOW: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 255); - break; - case WARP_ORANGE: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); - break; - case WARP_GREEN: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 200, 0, 255); - break; - case WARP_RED: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); - break; - default: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255 * temp_f0, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255 * temp_f0, 255, 255); - break; - } - gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); - gDPSetColorDither(POLY_XLU_DISP++, G_AD_NOTPATTERN | G_CD_MAGICSQ); - - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 1.0f, this->actor.world.pos.z, MTXMODE_NEW); - gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2247)); - Matrix_Push(); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, spEC & 0xFF, -((s16)(this->unk_19C + this->unk_19C) & 511), - 0x100, 0x100, 1, spEC & 0xFF, -((s16)(this->unk_19C + this->unk_19C) & 511), 0x100, - 0x100)); - - Matrix_Translate(0.0f, this->unk_194 * 230.0f, 0.0f, MTXMODE_APPLY); - xzScale = (((f32)this->unk_1AE * spE8) / 100.0f) + 1.0f; - Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); - gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2267)); - gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); - Matrix_Pop(); - - if (this->lightRayAlpha > 0.0f) { - switch (this->actor.params) { - case WARP_YELLOW: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 255); - break; - case WARP_ORANGE: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); - break; - case WARP_GREEN: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 200, 0, 255); - break; - case WARP_RED: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); - break; - default: - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255 * temp_f0, 255, 255, (u8)this->lightRayAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255 * temp_f0, 255, 255); - break; - } - spEC *= 2; - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, spEC & 0xFF, -((s16)this->unk_19C & 511), 0x100, 0x100, - 1, spEC & 0xFF, -((s16)this->unk_19C & 511), 0x100, 0x100)); - - Matrix_Translate(0.0f, this->unk_198 * 60.0f, 0.0f, MTXMODE_APPLY); - - xzScale = (((f32)this->unk_1B0 * spE4) / 100.0f) + 1.0f; - Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); - - gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2336)); - gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2340); -} - -void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { - DoorWarp1* this = (DoorWarp1*)thisx; - - switch (this->actor.params) { - case WARP_DUNGEON_ADULT: - DoorWarp1_DrawBlueCrystal(this, globalCtx); - DoorWarp1_DrawWarp(this, globalCtx); - break; - case WARP_DUNGEON_CHILD: - case WARP_CLEAR_FLAG: - case WARP_SAGES: - case WARP_YELLOW: - case WARP_BLUE_RUTO: - case WARP_DESTINATION: - case WARP_UNK_7: - case WARP_ORANGE: - case WARP_GREEN: - case WARP_RED: - DoorWarp1_DrawWarp(this, globalCtx); - break; - case WARP_BLUE_CRYSTAL: - DoorWarp1_DrawBlueCrystal(this, globalCtx); - break; - case WARP_PURPLE_CRYSTAL: - DoorWarp1_DrawPurpleCrystal(this, globalCtx); - break; - } -} diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.cpp b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.cpp new file mode 100644 index 000000000..e9aa3eac4 --- /dev/null +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.cpp @@ -0,0 +1,1064 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_DOOR_WARP1_Z_DOOR_WARP1_C +#include "actor_common.h" +#include "z_door_warp1.h" +#include "objects/object_warp1/object_warp1.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx); +void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx); +void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx); + +void DoorWarp1_WarpAppear(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_Destination(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_8099B020(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_AwaitClearFlag(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_8099A3A4(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_BlueCrystal(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_PurpleCrystal(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_80999214(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_80999348(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_809995D4(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_809998A4(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_ChildWarpIdle(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_RutoWarpIdle(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_ChildWarpOut(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_80999EE0(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_80999FE4(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_RutoWarpOut(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_AdultWarpIdle(DoorWarp1* pthis, GlobalContext* globalCtx); +void func_8099A508(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_AdultWarpOut(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_DoNothing(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_ChooseInitialAction(DoorWarp1* pthis, GlobalContext* globalCtx); +void DoorWarp1_FloatPlayer(DoorWarp1* pthis, GlobalContext* globalCtx); + +ActorInit Door_Warp1_InitVars = { + ACTOR_DOOR_WARP1, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_WARP1, + sizeof(DoorWarp1), + (ActorFunc)DoorWarp1_Init, + (ActorFunc)DoorWarp1_Destroy, + (ActorFunc)DoorWarp1_Update, + (ActorFunc)DoorWarp1_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 4000, ICHAIN_STOP), +}; + +static s16 sWarpTimerTarget; + +void DoorWarp1_SetupAction(DoorWarp1* pthis, DoorWarp1ActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* pthis = (DoorWarp1*)thisx; + GlobalContext* globalCtx2 = globalCtx; + + pthis->unk_1B8 = 0; + pthis->unk_1B4 = 0.0f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + + if (pthis->actor.params != WARP_SAGES && pthis->actor.params != WARP_BLUE_CRYSTAL && + pthis->actor.params != WARP_YELLOW && pthis->actor.params != WARP_DESTINATION) { + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0); + pthis->upperLight = LightContext_InsertLight(globalCtx2, &globalCtx2->lightCtx, &pthis->upperLightInfo); + + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0); + pthis->lowerLight = LightContext_InsertLight(globalCtx2, &globalCtx2->lightCtx, &pthis->lowerLightInfo); + } + osSyncPrintf("\nBOSSWARP arg_data=[%d]", pthis->actor.params); + + DoorWarp1_ChooseInitialAction(pthis, globalCtx2); +} + +void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { + u8 i; + DoorWarp1* pthis = (DoorWarp1*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->upperLight); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lowerLight); + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = globalCtx->envCtx.adjLight1Color[i] = + 0; + } + //! @bug SkelAnime_Free is not called for crystal variants +} + +void DoorWarp1_SetupWarp(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->scale = 0; + pthis->unk_1AE = -140; + pthis->unk_1B0 = -80; + sWarpTimerTarget = 100; + pthis->unk_1BC = 1.0f; + pthis->lightRayAlpha = 0.0f; + pthis->warpAlpha = 0.0f; + pthis->crystalAlpha = 0.0f; + + switch (pthis->actor.params) { + case WARP_YELLOW: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + pthis->unk_194 = 0.23f; + pthis->unk_198 = 0.6f; + break; + case WARP_DESTINATION: + pthis->unk_194 = 0.0f; + pthis->unk_198 = 0.0f; + break; + case WARP_UNK_7: + pthis->scale = 100; + pthis->unk_1AE = 120; + pthis->unk_1B0 = 230; + pthis->unk_194 = 0.3f; + pthis->unk_198 = 0.3f; + break; + case WARP_BLUE_RUTO: + default: + pthis->unk_194 = 0.3f; + pthis->unk_198 = 0.3f; + break; + } + + pthis->unk_19C = 0.0f; + pthis->actor.shape.yOffset = 1.0f; + pthis->warpTimer = 0; + + switch (pthis->actor.params) { + case WARP_PURPLE_CRYSTAL: + case WARP_BLUE_RUTO: + case WARP_UNK_7: + default: + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 200, 255, 255, 255); + break; + case WARP_CLEAR_FLAG: + case WARP_SAGES: + case WARP_YELLOW: + case WARP_DESTINATION: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + break; + } + + switch (pthis->actor.params) { + case WARP_CLEAR_FLAG: + DoorWarp1_SetupAction(pthis, DoorWarp1_AwaitClearFlag); + break; + case WARP_DESTINATION: + if ((!(gSaveContext.entranceIndex == 0x608 || // sacred forest meadow + gSaveContext.entranceIndex == 0x564 || // death mountain crater + gSaveContext.entranceIndex == 0x60C || // lake hylia + gSaveContext.entranceIndex == 0x610 || // desert colossus + gSaveContext.entranceIndex == 0x580) && // graveyard + gSaveContext.sceneSetupIndex < 4) || + (GET_PLAYER(globalCtx)->actor.params & 0xF00) != 0x200) { + Actor_Kill(&pthis->actor); + } + if (Actor_WorldDistXZToActor(&player->actor, &pthis->actor) > 100.0f) { + Actor_Kill(&pthis->actor); + } + DoorWarp1_SetupAction(pthis, DoorWarp1_Destination); + break; + case WARP_UNK_7: + DoorWarp1_SetupAction(pthis, func_8099B020); + break; + default: + DoorWarp1_SetupAction(pthis, DoorWarp1_WarpAppear); + break; + } +} + +void DoorWarp1_SetupAdultDungeonWarp(DoorWarp1* pthis, GlobalContext* globalCtx) { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&pthis->skelAnime, &gWarpCrystalAnim, 1.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 40.0f, 1); + + pthis->scale = 0; + pthis->unk_1AE = -140; + pthis->unk_1B0 = -80; + sWarpTimerTarget = 160; + pthis->actor.shape.yOffset = -400.0f; + pthis->warpTimer = 0; + pthis->unk_1BC = 1.0f; + pthis->unk_194 = 0.3f; + pthis->unk_198 = 0.3f; + pthis->lightRayAlpha = 0.0f; + pthis->warpAlpha = 0.0f; + pthis->crystalAlpha = 0.0f; + pthis->unk_19C = 0.0f; + + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 200, 255, 255, 255); + + DoorWarp1_SetupAction(pthis, func_8099A3A4); +} + +void DoorWarp1_SetupBlueCrystal(DoorWarp1* pthis, GlobalContext* globalCtx) { + s16 i; + + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&pthis->skelAnime, &gWarpCrystalAnim, 0, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 0.0f, 1); + + pthis->skelAnime.curFrame = Animation_GetLastFrame(&gWarpCrystalAnim); + pthis->scale = 10; + pthis->unk_1AE = 120; + pthis->unk_1B0 = 230; + pthis->warpTimer = 0; + pthis->unk_194 = 0.3f; + pthis->unk_198 = 0.3f; + pthis->lightRayAlpha = 0.0f; + pthis->warpAlpha = 0.0f; + pthis->crystalAlpha = 0.0f; + pthis->unk_19C = 0.0f; + pthis->unk_1BC = 1.0f; + pthis->actor.shape.yOffset = 800.0f; + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = globalCtx->envCtx.adjLight1Color[i] = + -255; + } + + globalCtx->envCtx.adjFogNear = -500; + pthis->warpTimer = 30; + pthis->unk_1B8 = 4000; + DoorWarp1_SetupAction(pthis, DoorWarp1_BlueCrystal); +} + +void DoorWarp1_SetupPurpleCrystal(DoorWarp1* pthis, GlobalContext* globalCtx) { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&pthis->skelAnime, &gWarpCrystalAnim, 0, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 0.0f, 1); + + pthis->skelAnime.curFrame = Animation_GetLastFrame(&gWarpCrystalAnim); + pthis->unk_1AE = 120; + pthis->unk_1B0 = 230; + pthis->warpTimer = 200; + pthis->unk_1B8 = 4000; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 1.0f; + pthis->unk_194 = 0.3f; + pthis->unk_198 = 0.3f; + pthis->lightRayAlpha = 0.0f; + pthis->warpAlpha = 0.0f; + pthis->crystalAlpha = 0.0f; + pthis->unk_19C = 0.0f; + pthis->unk_1BC = 1.f; + pthis->actor.shape.yOffset = 800.0f; + + if (gSaveContext.entranceIndex != 0x53) { + pthis->actor.scale.x = 0.0499f; + pthis->actor.scale.y = 0.077f; + pthis->actor.scale.z = 0.09f; + pthis->crystalAlpha = 255.0f; + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SHUT_BY_CRYSTAL); + } + DoorWarp1_SetupAction(pthis, DoorWarp1_PurpleCrystal); +} + +void DoorWarp1_SetPlayerPos(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.velocity.y = 0.0f; + player->actor.world.pos.x = pthis->actor.world.pos.x; + player->actor.world.pos.y = pthis->actor.world.pos.y + 55.0f; + player->actor.world.pos.z = pthis->actor.world.pos.z; +} + +void DoorWarp1_BlueCrystal(DoorWarp1* pthis, GlobalContext* globalCtx) { + if (pthis->warpTimer != 0) { + pthis->warpTimer--; + } else { + DoorWarp1_SetupAction(pthis, func_80999214); + } + DoorWarp1_SetPlayerPos(pthis, globalCtx); +} + +void func_80999214(DoorWarp1* pthis, GlobalContext* globalCtx) { + s32 temp_f4; + f32 darkness; + s16 i; + + Math_SmoothStepToF(&pthis->crystalAlpha, 255.0f, 0.2f, 5.0f, 0.1f); + + darkness = (f32)(40 - pthis->warpTimer) / 40.0f; + darkness = CLAMP_MIN(darkness, 0); + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = globalCtx->envCtx.adjLight1Color[i] = + -255.0f * darkness; + } + globalCtx->envCtx.adjFogNear = -500.0f * darkness; + + pthis->warpTimer++; + if (darkness <= 0) { + DoorWarp1_SetupAction(pthis, func_80999348); + } + pthis->actor.shape.rot.y += 0x320; + DoorWarp1_SetPlayerPos(pthis, globalCtx); +} + +void func_80999348(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + DoorWarp1_SetPlayerPos(pthis, globalCtx); + + if (pthis->warpTimer == 0) { + Math_SmoothStepToF(&pthis->crystalAlpha, 0.0f, 0.1f, 4.0f, 1.0f); + if (pthis->crystalAlpha <= 150.0f) { + player->actor.gravity = -0.1f; + } + if (pthis->crystalAlpha <= 0.0f) { + DoorWarp1_SetupAction(pthis, DoorWarp1_FloatPlayer); + } + } else { + pthis->warpTimer--; + } + pthis->actor.shape.rot.y += 0x320; +} + +void DoorWarp1_FloatPlayer(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.gravity = -0.1f; +} + +void DoorWarp1_PurpleCrystal(DoorWarp1* pthis, GlobalContext* globalCtx) { + if (pthis->warpTimer != 0) { + pthis->warpTimer--; + Math_SmoothStepToF(&pthis->actor.scale.x, 0.0499f, 0.2f, 0.05f, 0.001f); + Math_SmoothStepToF(&pthis->actor.scale.y, 0.077f, 0.2f, 0.05f, 0.001f); + Math_SmoothStepToF(&pthis->actor.scale.z, 0.09f, 0.2f, 0.05f, 0.001f); + Math_SmoothStepToF(&pthis->crystalAlpha, 255.0f, 0.2f, 5.0f, 0.1f); + } +} + +void DoorWarp1_ChooseInitialAction(DoorWarp1* pthis, GlobalContext* globalCtx) { + switch (pthis->actor.params) { + case WARP_DUNGEON_CHILD: + case WARP_CLEAR_FLAG: + case WARP_SAGES: + case WARP_YELLOW: + case WARP_BLUE_RUTO: + case WARP_DESTINATION: + case WARP_UNK_7: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + DoorWarp1_SetupWarp(pthis, globalCtx); + break; + case WARP_DUNGEON_ADULT: + DoorWarp1_SetupAdultDungeonWarp(pthis, globalCtx); + break; + case WARP_BLUE_CRYSTAL: + DoorWarp1_SetupBlueCrystal(pthis, globalCtx); + break; + case WARP_PURPLE_CRYSTAL: + DoorWarp1_SetupPurpleCrystal(pthis, globalCtx); + break; + } +} + +void DoorWarp1_AwaitClearFlag(DoorWarp1* pthis, GlobalContext* globalCtx) { + if (Flags_GetTempClear(globalCtx, pthis->actor.room)) { + pthis->warpTimer = 200; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + DoorWarp1_SetupAction(pthis, func_809995D4); + } +} + +void func_809995D4(DoorWarp1* pthis, GlobalContext* globalCtx) { + if (pthis->warpTimer == 0) { + if (pthis->actor.xzDistToPlayer < 100.0f) { + pthis->actor.world.pos.x = -98.0f; + pthis->actor.world.pos.y = 827.0f; + pthis->actor.world.pos.z = -3228.0f; + } + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 200, 255, 255, 255); + DoorWarp1_SetupAction(pthis, DoorWarp1_WarpAppear); + } + pthis->warpTimer--; +} + +void DoorWarp1_WarpAppear(DoorWarp1* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Math_SmoothStepToF(&pthis->lightRayAlpha, 255.0f, 0.4f, 10.0f, 0.01f); + Math_SmoothStepToF(&pthis->warpAlpha, 255.0f, 0.4f, 10.0f, 0.01f); + + if (pthis->actor.params != WARP_YELLOW && pthis->actor.params != WARP_ORANGE && pthis->actor.params != WARP_GREEN && + pthis->actor.params != WARP_RED) { + if (pthis->scale < 100) { + pthis->scale += 2; + } + if (pthis->unk_1AE < 120) { + pthis->unk_1AE += 4; + } + if (pthis->unk_1B0 < 230) { + pthis->unk_1B0 += 4; + } else if (pthis->actor.params == WARP_BLUE_RUTO) { + DoorWarp1_SetupAction(pthis, DoorWarp1_RutoWarpIdle); + } else if (pthis->actor.params != WARP_SAGES && pthis->actor.params != WARP_YELLOW) { + DoorWarp1_SetupAction(pthis, DoorWarp1_ChildWarpIdle); + } else { + DoorWarp1_SetupAction(pthis, func_809998A4); + } + } else { + if (pthis->unk_1AE < -50) { + pthis->unk_1AE += 4; + } + if (pthis->unk_1B0 < 70) { + pthis->unk_1B0 += 4; + } else { + DoorWarp1_SetupAction(pthis, func_809998A4); + } + } +} + +void func_809998A4(DoorWarp1* pthis, GlobalContext* globalCtx) { + if (pthis->lightRayAlpha != 0.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + } + Math_SmoothStepToF(&pthis->lightRayAlpha, 0.0f, 0.1f, 2.0f, 0.01f); + Math_SmoothStepToF(&pthis->warpAlpha, 0.0f, 0.1f, 2.0f, 0.01f); +} + +s32 DoorWarp1_PlayerInRange(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if (fabsf(pthis->actor.xzDistToPlayer) < 60.0f) { + if ((player->actor.world.pos.y - 20.0f) < pthis->actor.world.pos.y) { + if (pthis->actor.world.pos.y < (player->actor.world.pos.y + 20.0f)) { + ret = true; + } + } + } + return ret; +} + +void DoorWarp1_ChildWarpIdle(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player; + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + + if (DoorWarp1_PlayerInRange(pthis, globalCtx)) { + player = GET_PLAYER(globalCtx); + + Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + OnePointCutscene_Init(globalCtx, 0x25E7, 999, &pthis->actor, MAIN_CAM); + func_8002DF54(globalCtx, &pthis->actor, 10); + + player->unk_450.x = pthis->actor.world.pos.x; + player->unk_450.z = pthis->actor.world.pos.z; + pthis->unk_1B2 = 1; + DoorWarp1_SetupAction(pthis, DoorWarp1_ChildWarpOut); + } +} + +void DoorWarp1_ChildWarpOut(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->unk_1B2 >= 101) { + if (player->actor.velocity.y < 10.0f) { + player->actor.gravity = 0.1f; + } else { + player->actor.gravity = 0.0f; + } + } else { + pthis->unk_1B2++; + } + + Math_SmoothStepToF(&pthis->lightRayAlpha, 0.0f, 0.2f, 6.0f, 0.01f); + pthis->warpTimer++; + + if (sWarpTimerTarget < pthis->warpTimer && gSaveContext.nextCutsceneIndex == 0xFFEF) { + osSyncPrintf("\n\n\nじかんがきたからおーしまい fade_direction=[%d]", globalCtx->sceneLoadFlag, 0x14); + + if (globalCtx->sceneNum == SCENE_DDAN_BOSS) { + if (!Flags_GetEventChkInf(0x25)) { + Flags_SetEventChkInf(0x25); + Item_Give(globalCtx, ITEM_GORON_RUBY); + globalCtx->nextEntranceIndex = 0x13D; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + globalCtx->nextEntranceIndex = 0x47A; + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_YDAN_BOSS) { + if (!Flags_GetEventChkInf(7)) { + Flags_SetEventChkInf(7); + Flags_SetEventChkInf(9); + Item_Give(globalCtx, ITEM_KOKIRI_EMERALD); + globalCtx->nextEntranceIndex = 0xEE; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + globalCtx->nextEntranceIndex = 0x457; + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_BDAN_BOSS) { + globalCtx->nextEntranceIndex = 0x10E; + gSaveContext.nextCutsceneIndex = 0; + } + osSyncPrintf("\n\n\nおわりおわり"); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 7; + gSaveContext.nextTransition = 3; + } + + Math_StepToF(&pthis->unk_194, 2.0f, 0.01f); + Math_StepToF(&pthis->unk_198, 10.0f, 0.02f); + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, + (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, + 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, + (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, + 255, 255); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); +} + +void DoorWarp1_RutoWarpIdle(DoorWarp1* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + + if (pthis->rutoWarpState != WARP_BLUE_RUTO_STATE_INITIAL && DoorWarp1_PlayerInRange(pthis, globalCtx)) { + pthis->rutoWarpState = WARP_BLUE_RUTO_STATE_ENTERED; + func_8002DF54(globalCtx, &pthis->actor, 10); + pthis->unk_1B2 = 1; + DoorWarp1_SetupAction(pthis, func_80999EE0); + } +} + +static s16 sRutoWarpSubCamId; + +void func_80999EE0(DoorWarp1* pthis, GlobalContext* globalCtx) { + Vec3f at; + Vec3f eye; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->rutoWarpState == WARP_BLUE_RUTO_STATE_3) { + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + sRutoWarpSubCamId = Gameplay_CreateSubCamera(globalCtx); + + Gameplay_ChangeCameraStatus(globalCtx, sRutoWarpSubCamId, CAM_STAT_ACTIVE); + at.x = pthis->actor.world.pos.x; + at.y = 49.0f; + at.z = pthis->actor.world.pos.z; + eye.x = player->actor.world.pos.x; + eye.y = 43.0f; + eye.z = player->actor.world.pos.z; + + Gameplay_CameraSetAtEye(globalCtx, sRutoWarpSubCamId, &at, &eye); + Gameplay_CameraSetFov(globalCtx, sRutoWarpSubCamId, 90.0f); + pthis->rutoWarpState = WARP_BLUE_RUTO_STATE_TALKING; + Message_StartTextbox(globalCtx, 0x4022, NULL); + DoorWarp1_SetupAction(pthis, func_80999FE4); + } +} + +void func_80999FE4(DoorWarp1* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { + Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + OnePointCutscene_Init(globalCtx, 0x25E9, 999, &pthis->actor, MAIN_CAM); + Gameplay_CopyCamera(globalCtx, -1, sRutoWarpSubCamId); + Gameplay_ChangeCameraStatus(globalCtx, sRutoWarpSubCamId, CAM_STAT_WAIT); + pthis->rutoWarpState = WARP_BLUE_RUTO_STATE_WARPING; + DoorWarp1_SetupAction(pthis, DoorWarp1_RutoWarpOut); + } +} + +void DoorWarp1_RutoWarpOut(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->unk_1B2 >= 61) { + if (player->actor.velocity.y < 10.f) { + player->actor.gravity = 0.02f; + } else { + player->actor.gravity = 0.0f; + } + } else { + pthis->unk_1B2++; + } + Math_SmoothStepToF(&pthis->lightRayAlpha, 0.0f, 0.2f, 6.0f, 0.01f); + pthis->warpTimer++; + + if (pthis->warpTimer > sWarpTimerTarget && gSaveContext.nextCutsceneIndex == 0xFFEF) { + gSaveContext.eventChkInf[3] |= 0x80; + Item_Give(globalCtx, ITEM_ZORA_SAPPHIRE); + globalCtx->nextEntranceIndex = 0x10E; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 7; + } + + Math_StepToF(&pthis->unk_194, 2.0f, 0.01f); + Math_StepToF(&pthis->unk_198, 10.f, 0.02f); + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, + (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, + 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, + (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, + 255, 255); + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); +} + +void func_8099A3A4(DoorWarp1* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Math_SmoothStepToF(&pthis->lightRayAlpha, 255.0f, 0.2f, 2.0f, 0.1f); + Math_SmoothStepToF(&pthis->warpAlpha, 255.0f, 0.2f, 2.0f, 0.1f); + + if (pthis->scale < 10) { + pthis->scale += 2; + } + if (pthis->unk_1AE < 120) { + pthis->unk_1AE += 4; + } + if (pthis->unk_1B0 < 230) { + pthis->unk_1B0 += 4; + } else { + DoorWarp1_SetupAction(pthis, DoorWarp1_AdultWarpIdle); + } +} + +void DoorWarp1_AdultWarpIdle(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player; + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + + if (DoorWarp1_PlayerInRange(pthis, globalCtx)) { + player = GET_PLAYER(globalCtx); + + OnePointCutscene_Init(globalCtx, 0x25E8, 999, &pthis->actor, MAIN_CAM); + func_8002DF54(globalCtx, &pthis->actor, 10); + player->unk_450.x = pthis->actor.world.pos.x; + player->unk_450.z = pthis->actor.world.pos.z; + pthis->unk_1B2 = 20; + DoorWarp1_SetupAction(pthis, func_8099A508); + } +} + +void func_8099A508(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->unk_1B2 != 0) { + pthis->unk_1B2--; + return; + } + Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Animation_ChangeImpl(&pthis->skelAnime, &gWarpCrystalAnim, 1.0f, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 40.0f, 1); + + pthis->unk_1B2 = 0x32; + DoorWarp1_SetupAction(pthis, DoorWarp1_AdultWarpOut); +} + +void DoorWarp1_AdultWarpOut(DoorWarp1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0_2; + + if (pthis->unk_1B2 != 0) { + pthis->unk_1B2--; + } + + if (pthis->unk_1B2 < 31) { + u32 phi_v0 = (LINK_IS_ADULT) ? 35 : 45; + + if ((player->actor.world.pos.y - pthis->actor.world.pos.y) <= phi_v0) { + player->actor.gravity = 0.0139999995f; + } else { + player->actor.gravity = 0.0f; + player->actor.velocity.y = 0.0f; + } + if (pthis->unk_1B2 <= 0) { + if (pthis->unk_1B8 < 4000) { + pthis->unk_1B8 += 40; + } + player->actor.world.rot.y -= pthis->unk_1B8; + player->actor.shape.rot.y -= pthis->unk_1B8; + } + Math_SmoothStepToF(&player->actor.world.pos.x, pthis->actor.world.pos.x, 0.5f, 0.1f, 0.01f); + Math_SmoothStepToF(&player->actor.world.pos.z, pthis->actor.world.pos.z, 0.5f, 0.1f, 0.01f); + } + pthis->warpTimer++; + + if (pthis->warpTimer > sWarpTimerTarget && gSaveContext.nextCutsceneIndex == 0xFFEF) { + if (globalCtx->sceneNum == SCENE_MORIBOSSROOM) { + if (!(gSaveContext.eventChkInf[4] & 0x100)) { + gSaveContext.eventChkInf[4] |= 0x100; + Item_Give(globalCtx, ITEM_MEDALLION_FOREST); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x600; + } else { + globalCtx->nextEntranceIndex = 0x608; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_FIRE_BS) { + if (!(gSaveContext.eventChkInf[4] & 0x200)) { + gSaveContext.eventChkInf[4] |= 0x200; + Item_Give(globalCtx, ITEM_MEDALLION_FIRE); + globalCtx->nextEntranceIndex = 0xDB; + gSaveContext.nextCutsceneIndex = 0xFFF3; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x4F6; + } else { + globalCtx->nextEntranceIndex = 0x564; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_MIZUSIN_BS) { + if (!(gSaveContext.eventChkInf[4] & 0x400)) { + gSaveContext.eventChkInf[4] |= 0x400; + Item_Give(globalCtx, ITEM_MEDALLION_WATER); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_WATER; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x604; + } else { + globalCtx->nextEntranceIndex = 0x60C; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_JYASINBOSS) { + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { + Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_SPIRIT; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x1F1; + } else { + globalCtx->nextEntranceIndex = 0x610; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_HAKADAN_BS) { + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { + Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_SHADOW; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x568; + } else { + globalCtx->nextEntranceIndex = 0x580; + } + gSaveContext.nextCutsceneIndex = 0; + } + } + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 3; + gSaveContext.nextTransition = 7; + } + if (pthis->warpTimer >= 141) { + f32 screenFillAlpha; + + globalCtx->envCtx.fillScreen = true; + screenFillAlpha = (f32)(pthis->warpTimer - 140) / 20.0f; + + if (screenFillAlpha > 1.0f) { + screenFillAlpha = 1.0f; + } + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + globalCtx->envCtx.screenFillColor[3] = (u32)(255.0f * screenFillAlpha); + + osSyncPrintf("\nparcent=[%f]", screenFillAlpha); + } + Lights_PointNoGlowSetInfo(&pthis->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, + (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, + 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, + (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, + 255, 255); + + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 800.0f, 0.5f, 15.0f, 0.1f); + pthis->actor.shape.rot.y += 0x320; + + Math_SmoothStepToF(&pthis->unk_1BC, 1.13f, 0.2f, 0.1f, 0.01f); + Math_StepToF(&pthis->unk_194, 2.0f, 0.003f); + Math_StepToF(&pthis->unk_198, 10.0f, 0.006f); + Math_SmoothStepToF(&pthis->lightRayAlpha, 0.0f, 0.2f, 3.0f, 0.01f); + Math_SmoothStepToF(&pthis->warpAlpha, 0.0f, 0.2f, 2.0f, 0.01f); + Math_SmoothStepToF(&pthis->crystalAlpha, 255.0f, 0.1f, 1.0f, 0.01f); + + temp_f0_2 = 1.0f - (f32)(sWarpTimerTarget - pthis->warpTimer) / (sWarpTimerTarget - (sWarpTimerTarget - 100)); + if (temp_f0_2 > 0.0f) { + s16 i; + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.adjAmbientColor[i] = globalCtx->envCtx.adjFogColor[i] = + globalCtx->envCtx.adjLight1Color[i] = -255.0f * temp_f0_2; + } + + globalCtx->envCtx.adjFogNear = -500.0f * temp_f0_2; + if (globalCtx->envCtx.adjFogNear < -300) { + globalCtx->roomCtx.curRoom.segment = NULL; + } + } +} + +void DoorWarp1_Destination(DoorWarp1* pthis, GlobalContext* globalCtx) { + f32 alphaFrac; + + pthis->warpTimer++; + pthis->unk_194 = 5.0f; + + alphaFrac = 1.0f; + if (pthis->warpTimer < 20) { + alphaFrac = pthis->warpTimer / 20.f; + } else if (pthis->warpTimer >= 60) { + alphaFrac = 1.0f - ((pthis->warpTimer - 60.0f) / 20.f); + } + pthis->warpAlpha = 255.0f * alphaFrac; + pthis->lightRayAlpha = 0.0f; + + if (pthis->warpTimer >= 80.0f) { + pthis->warpAlpha = 0.0f; + DoorWarp1_SetupAction(pthis, DoorWarp1_DoNothing); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); +} + +void DoorWarp1_DoNothing(DoorWarp1* pthis, GlobalContext* globalCtx) { +} + +void func_8099B020(DoorWarp1* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->lightRayAlpha, 128.0f, 0.2f, 2.0f, 0.1f); + Math_SmoothStepToF(&pthis->warpAlpha, 128.0f, 0.2f, 2.0f, 0.1f); + + if (pthis->lightRayAlpha >= 128.0f) { + Math_StepToF(&pthis->unk_194, 2.0f, 0.01f); + Math_StepToF(&pthis->unk_198, 10.0f, 0.02f); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); +} + +void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* pthis = (DoorWarp1*)thisx; + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.params != WARP_PURPLE_CRYSTAL) { + Actor_SetScale(&pthis->actor, pthis->scale / 100.0f); + } +} + +void DoorWarp1_DrawBlueCrystal(DoorWarp1* pthis, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2078); + + func_80093D84(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (u8)pthis->crystalAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (u8)pthis->crystalAlpha); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, + &pthis->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2098); + + SkelAnime_Update(&pthis->skelAnime); +} + +void DoorWarp1_DrawPurpleCrystal(DoorWarp1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f eye; + + eye.x = -(Math_SinS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; + eye.y = (Math_CosS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; + eye.z = (Math_CosS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2122); + + func_80093D84(globalCtx->state.gfxCtx); + func_8002EB44(&pthis->actor.world.pos, &eye, &eye, globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)pthis->crystalAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 0, 100, (u8)pthis->crystalAlpha); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, + &pthis->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2152); + + SkelAnime_Update(&pthis->skelAnime); +} + +void DoorWarp1_DrawWarp(DoorWarp1* pthis, GlobalContext* globalCtx) { + s32 pad; + u32 pad1; + u32 spEC = globalCtx->state.frames * 10; + f32 spE8 = (pthis->unk_194 >= 1.0f) ? 0.0f : 1.0f - pthis->unk_194; + f32 spE4 = (pthis->unk_198 >= 1.0f) ? 0.0f : 1.0f - pthis->unk_198; + f32 xzScale; + f32 temp_f0; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2173); + + temp_f0 = 1.0f - (2.0f - pthis->unk_194) / 1.7f; + if (pthis->actor.params != WARP_YELLOW && pthis->actor.params != WARP_DESTINATION && + pthis->actor.params != WARP_ORANGE && pthis->actor.params != WARP_GREEN && pthis->actor.params != WARP_RED) { + pthis->unk_19C += (s16)(temp_f0 * 15.0f); + } + if (pthis->actor.params == WARP_DESTINATION) { + pthis->unk_19C -= (s16)(temp_f0 * 2.0f); + } + func_80093D84(globalCtx->state.gfxCtx); + + switch (pthis->actor.params) { + case WARP_YELLOW: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 255); + break; + case WARP_ORANGE: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + break; + case WARP_GREEN: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 200, 0, 255); + break; + case WARP_RED: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + break; + default: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255 * temp_f0, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255 * temp_f0, 255, 255); + break; + } + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_AD_NOTPATTERN | G_CD_MAGICSQ); + + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y + 1.0f, pthis->actor.world.pos.z, MTXMODE_NEW); + gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2247)); + Matrix_Push(); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, spEC & 0xFF, -((s16)(pthis->unk_19C + pthis->unk_19C) & 511), + 0x100, 0x100, 1, spEC & 0xFF, -((s16)(pthis->unk_19C + pthis->unk_19C) & 511), 0x100, + 0x100)); + + Matrix_Translate(0.0f, pthis->unk_194 * 230.0f, 0.0f, MTXMODE_APPLY); + xzScale = (((f32)pthis->unk_1AE * spE8) / 100.0f) + 1.0f; + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2267)); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); + Matrix_Pop(); + + if (pthis->lightRayAlpha > 0.0f) { + switch (pthis->actor.params) { + case WARP_YELLOW: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 255); + break; + case WARP_ORANGE: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + break; + case WARP_GREEN: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 200, 0, 255); + break; + case WARP_RED: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)pthis->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + break; + default: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255 * temp_f0, 255, 255, (u8)pthis->lightRayAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255 * temp_f0, 255, 255); + break; + } + spEC *= 2; + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, spEC & 0xFF, -((s16)pthis->unk_19C & 511), 0x100, 0x100, + 1, spEC & 0xFF, -((s16)pthis->unk_19C & 511), 0x100, 0x100)); + + Matrix_Translate(0.0f, pthis->unk_198 * 60.0f, 0.0f, MTXMODE_APPLY); + + xzScale = (((f32)pthis->unk_1B0 * spE4) / 100.0f) + 1.0f; + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2336)); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2340); +} + +void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* pthis = (DoorWarp1*)thisx; + + switch (pthis->actor.params) { + case WARP_DUNGEON_ADULT: + DoorWarp1_DrawBlueCrystal(pthis, globalCtx); + DoorWarp1_DrawWarp(pthis, globalCtx); + break; + case WARP_DUNGEON_CHILD: + case WARP_CLEAR_FLAG: + case WARP_SAGES: + case WARP_YELLOW: + case WARP_BLUE_RUTO: + case WARP_DESTINATION: + case WARP_UNK_7: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + DoorWarp1_DrawWarp(pthis, globalCtx); + break; + case WARP_BLUE_CRYSTAL: + DoorWarp1_DrawBlueCrystal(pthis, globalCtx); + break; + case WARP_PURPLE_CRYSTAL: + DoorWarp1_DrawPurpleCrystal(pthis, globalCtx); + break; + } +} diff --git a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.cpp similarity index 74% rename from src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c rename to src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.cpp index fef2e129f..7e40cbce0 100644 --- a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c +++ b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.cpp @@ -16,13 +16,13 @@ void EfcErupc_Destroy(Actor* thisx, GlobalContext* globalCtx); void EfcErupc_Update(Actor* thisx, GlobalContext* globalCtx); void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx); -void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx); +void EfcErupc_UpdateAction(EfcErupc* pthis, GlobalContext* globalCtx); void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalCtx); -void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx); +void EfcErupc_UpdateParticles(EfcErupc* pthis, GlobalContext* globalCtx); void EfcErupc_AddParticle(EfcErupcParticles* particles, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor); void EfcErupc_InitParticles(EfcErupcParticles* particles); -const ActorInit Efc_Erupc_InitVars = { +ActorInit Efc_Erupc_InitVars = { ACTOR_EFC_ERUPC, ACTORCAT_ITEMACTION, FLAGS, @@ -34,25 +34,25 @@ const ActorInit Efc_Erupc_InitVars = { (ActorFunc)EfcErupc_Draw, }; -void EfcErupc_SetupAction(EfcErupc* this, EfcErupcActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EfcErupc_SetupAction(EfcErupc* pthis, EfcErupcActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EfcErupc_Init(Actor* thisx, GlobalContext* globalCtx) { - EfcErupc* this = (EfcErupc*)thisx; + EfcErupc* pthis = (EfcErupc*)thisx; - EfcErupc_SetupAction(this, EfcErupc_UpdateAction); - Actor_SetScale(&this->actor, 1.0f); - EfcErupc_InitParticles(this->particles); - this->unk14C = this->unk14E = this->unk150 = 0; - this->unk152 = 5; - this->unk154 = -100; + EfcErupc_SetupAction(pthis, EfcErupc_UpdateAction); + Actor_SetScale(&pthis->actor, 1.0f); + EfcErupc_InitParticles(pthis->particles); + pthis->unk14C = pthis->unk14E = pthis->unk150 = 0; + pthis->unk152 = 5; + pthis->unk154 = -100; } void EfcErupc_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx) { +void EfcErupc_UpdateAction(EfcErupc* pthis, GlobalContext* globalCtx) { Vec3f pos; Vec3f vel; Vec3f accel; @@ -61,22 +61,22 @@ void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (globalCtx->csCtx.npcActions[1] != NULL) { if (globalCtx->csCtx.npcActions[1]->action == 2) { - if (this->unk150 == 30) { + if (pthis->unk150 == 30) { func_800788CC(NA_SE_IT_EARTHQUAKE); } - if (this->unk150 <= 64) { - if (this->unk154 < 200) { - this->unk154 += 10; + if (pthis->unk150 <= 64) { + if (pthis->unk154 < 200) { + pthis->unk154 += 10; } } else { - if (this->unk154 > -100) { - this->unk154 -= 10; + if (pthis->unk154 > -100) { + pthis->unk154 -= 10; } } - this->unk150++; + pthis->unk150++; } else { - if (this->unk154 > -100) { - this->unk154 -= 10; + if (pthis->unk154 > -100) { + pthis->unk154 -= 10; } } } @@ -85,41 +85,41 @@ void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.npcActions[2] != NULL) { switch (globalCtx->csCtx.npcActions[2]->action) { case 2: - if (this->unk14E == 0) { + if (pthis->unk14E == 0) { func_800F3F3C(6); gSaveContext.eventChkInf[2] |= 0x8000; } - this->unk14E++; + pthis->unk14E++; break; case 3: - this->unk14E = 30; + pthis->unk14E = 30; } - this->unk14C++; + pthis->unk14C++; } } accel.z = 0.0f; accel.x = 0.0f; - pos.y = this->actor.world.pos.y + 300.0f; - for (i = 0; i < this->unk152; i++) { - pos.x = Rand_CenteredFloat(100.0f) + this->actor.world.pos.x; - pos.z = Rand_CenteredFloat(100.0f) + this->actor.world.pos.z; + pos.y = pthis->actor.world.pos.y + 300.0f; + for (i = 0; i < pthis->unk152; i++) { + pos.x = Rand_CenteredFloat(100.0f) + pthis->actor.world.pos.x; + pos.z = Rand_CenteredFloat(100.0f) + pthis->actor.world.pos.z; vel.x = Rand_CenteredFloat(100.0f); vel.y = Rand_ZeroFloat(100.0f); vel.z = Rand_CenteredFloat(100.0f); - accel.y = this->unk154 * 0.1f; - EfcErupc_AddParticle(this->particles, &pos, &vel, &accel, 80.0f); + accel.y = pthis->unk154 * 0.1f; + EfcErupc_AddParticle(pthis->particles, &pos, &vel, &accel, 80.0f); } } void EfcErupc_Update(Actor* thisx, GlobalContext* globalCtx) { - EfcErupc* this = (EfcErupc*)thisx; + EfcErupc* pthis = (EfcErupc*)thisx; - this->actionFunc(this, globalCtx); - EfcErupc_UpdateParticles(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); + EfcErupc_UpdateParticles(pthis, globalCtx); } void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) { - EfcErupc* this = (EfcErupc*)thisx; + EfcErupc* pthis = (EfcErupc*)thisx; u16 csAction; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_efc_erupc.c", 282); @@ -127,16 +127,16 @@ void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk14C * 1, this->unk14E * -4, 32, 64, 1, - this->unk14C * 4, this->unk14E * -20, 64, 64)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->unk14C * 1, pthis->unk14E * -4, 32, 64, 1, + pthis->unk14C * 4, pthis->unk14E * -20, 64, 64)); gSPSegment( POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, this->unk150 * -4, 16, 128, 1, 0, this->unk150 * 12, 32, 32)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, pthis->unk150 * -4, 16, 128, 1, 0, pthis->unk150 * 12, 32, 32)); gSPSegment( POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, this->unk150 * -4, 16, 128, 1, 0, this->unk150 * 12, 32, 32)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, pthis->unk150 * -4, 16, 128, 1, 0, pthis->unk150 * 12, 32, 32)); Matrix_Push(); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); @@ -164,7 +164,7 @@ void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) { } } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_efc_erupc.c", 356); - EfcErupc_DrawParticles(this->particles, globalCtx); + EfcErupc_DrawParticles(pthis->particles, globalCtx); } void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalCtx) { @@ -199,7 +199,7 @@ static Color_RGB8 D_8099D770[] = { { 255, 0, 0 }, }; -void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) { +void EfcErupc_UpdateParticles(EfcErupc* pthis, GlobalContext* globalCtx) { s16 i; s16 index; Color_RGB8 particleColors[] = { @@ -209,7 +209,7 @@ void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) { { 100, 0, 0 }, }; Color_RGB8* color; - EfcErupcParticles* cur = this->particles; + EfcErupcParticles* cur = pthis->particles; for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, cur++) { if (cur->isActive) { diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c deleted file mode 100644 index 61ef5f903..000000000 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ /dev/null @@ -1,380 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EFF_DUST_Z_EFF_DUST_C -#include "actor_common.h" -/** - * File z_eff_dust.c - * Overlay: ovl_Eff_Dust - * Description: Dust effects - */ - -#include "z_eff_dust.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/system_malloc.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EffDust_Init(Actor* thisx, GlobalContext* globalCtx); -void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffDust_Update(Actor* thisx, GlobalContext* globalCtx); -void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EffDust_InitPosAndDistance(EffDust* this); - -void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx); -void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx); -void EffDust_UpdateFunc_8099DFC0(EffDust* this, GlobalContext* globalCtx); -void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx); -void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx); - -const ActorInit Eff_Dust_InitVars = { - ACTOR_EFF_DUST, - ACTORCAT_NPC, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EffDust), - (ActorFunc)EffDust_Init, - (ActorFunc)EffDust_Destroy, - (ActorFunc)EffDust_Update, - (ActorFunc)EffDust_Draw, -}; - -static Gfx sEmptyDL[] = { - gsSPEndDisplayList(), -}; - -void EffDust_SetupAction(EffDust* this, EffDustActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EffDust_SetupDraw(EffDust* this, EffDustDrawFunc drawFunc) { - this->drawFunc = drawFunc; -} - -void EffDust_InitPosAndDistance(EffDust* this) { - s32 i; - - for (i = 0; i < 64; i++) { - this->initialPositions[i].z = 0.0f; - this->initialPositions[i].y = 0.0f; - this->initialPositions[i].x = 0.0f; - - this->distanceTraveled[i] = 1.0f; - } - this->index = 0; -} - -void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) { - EffDust* this = (EffDust*)thisx; - EffDustType dustEffect = this->actor.params; - - EffDust_InitPosAndDistance(this); - - switch (dustEffect) { - case EFF_DUST_TYPE_0: - EffDust_SetupAction(this, EffDust_UpdateFunc_8099DB28); - EffDust_SetupDraw(this, EffDust_DrawFunc_8099E4F4); - this->dy = 0.8f; - this->dz = 0.8f; - this->dx = 1.0f; - this->scalingFactor = 0.1f; - break; - case EFF_DUST_TYPE_1: - EffDust_SetupAction(this, EffDust_UpdateFunc_8099DD74); - EffDust_SetupDraw(this, EffDust_DrawFunc_8099E4F4); - this->dx = 0.8f; - this->dz = 0.8f; - this->dy = 1.0f; - this->scalingFactor = 0.5f; - break; - case EFF_DUST_TYPE_2: - EffDust_SetupAction(this, EffDust_UpdateFunc_8099DFC0); - EffDust_SetupDraw(this, EffDust_DrawFunc_8099E784); - this->dx = 0.5f; - this->scalingFactor = 15.0f; - break; - case EFF_DUST_TYPE_3: - EffDust_SetupAction(this, EffDust_UpdateFunc_8099DFC0); - EffDust_SetupDraw(this, EffDust_DrawFunc_8099E784); - this->dx = 0.5f; - this->scalingFactor = 10.0f; - break; - case EFF_DUST_TYPE_4: - EffDust_SetupAction(this, EffDust_UpdateFunc_8099DFC0); - EffDust_SetupDraw(this, EffDust_DrawFunc_8099E784); - this->actor.room = -1; - this->dx = 0.5f; - this->scalingFactor = 20.0f; - break; - default: - SystemArena_FreeDebug(this, "../z_eff_dust.c", 202); - break; - } - - this->life = 10; -} - -void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx) { - s16 theta; - s16 fi; - f32* distanceTraveled = this->distanceTraveled; - s32 i; - s32 j; - - for (i = 0; i < 64; i++) { - if ((*distanceTraveled) < 1.0f) { - *distanceTraveled += 0.05f; - } - distanceTraveled++; - } - - for (j = 0; j < 3; j++) { - i = this->index & 0x3F; - if (this->distanceTraveled[i] >= 1.0f) { - // Spherical coordinate system. - fi = Rand_CenteredFloat(8192.0f); - theta = Rand_CenteredFloat(4096.0f); - this->initialPositions[i].x = -800.0f * Math_CosS(fi) * Math_CosS(theta); - this->initialPositions[i].y = -800.0f * Math_SinS(theta); - this->initialPositions[i].z = -800.0f * Math_SinS(fi) * Math_CosS(theta); - this->distanceTraveled[i] = 0.0f; - this->index += 1; - } - } -} - -void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx) { - s16 theta; - s16 fi; - f32* distanceTraveled = this->distanceTraveled; - s32 i; - s32 j; - - for (i = 0; i < 64; i++) { - if ((*distanceTraveled) < 1.0f) { - *distanceTraveled += 0.03f; - } - distanceTraveled++; - } - - for (j = 0; j < 2; j++) { - i = this->index & 0x3F; - if (this->distanceTraveled[i] >= 1.0f) { - // Spherical coordinate system. - fi = Rand_CenteredFloat(65536.0f); - theta = Rand_ZeroFloat(8192.0f); - this->initialPositions[i].x = 400.0f * Math_CosS(fi) * Math_CosS(theta); - this->initialPositions[i].y = 400.0f * Math_SinS(theta); - this->initialPositions[i].z = 400.0f * Math_SinS(fi) * Math_CosS(theta); - this->distanceTraveled[i] = 0.0f; - this->index += 1; - } - } -} - -void EffDust_UpdateFunc_8099DFC0(EffDust* this, GlobalContext* globalCtx) { - s16 theta; - Player* player = GET_PLAYER(globalCtx); - Actor* parent = this->actor.parent; - f32* distanceTraveled = this->distanceTraveled; - s32 i; - s32 j; - - if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & 0x1000)) { - if (this->life != 0) { - this->life -= 1; - } else { - Actor_Kill(&this->actor); - } - - for (i = 0; i < 64; i++) { - if ((*distanceTraveled) < 1.0f) { - *distanceTraveled += 0.2f; - } - distanceTraveled++; - } - - return; - } - - for (i = 0; i < 64; i++) { - if ((*distanceTraveled) < 1.0f) { - *distanceTraveled += 0.1f; - } - distanceTraveled++; - } - - this->actor.world.pos = parent->world.pos; - - for (j = 0; j < 3; j++) { - i = this->index & 0x3F; - if (this->distanceTraveled[i] >= 1.0f) { - - theta = Rand_CenteredFloat(65536.0f); - switch (this->actor.params) { - case EFF_DUST_TYPE_2: - this->initialPositions[i].x = (Rand_ZeroOne() * 4500.0f) + 700.0f; - if (this->initialPositions[i].x > 3000.0f) { - this->initialPositions[i].y = (3000.0f * Rand_ZeroOne()) * Math_SinS(theta); - this->initialPositions[i].z = (3000.0f * Rand_ZeroOne()) * Math_CosS(theta); - } else { - this->initialPositions[i].y = 3000.0f * Math_SinS(theta); - this->initialPositions[i].z = 3000.0f * Math_CosS(theta); - } - break; - - case EFF_DUST_TYPE_3: - this->initialPositions[i].x = (Rand_ZeroOne() * 2500.0f) + 700.0f; - if (this->initialPositions[i].x > 2000.0f) { - this->initialPositions[i].y = (2000.0f * Rand_ZeroOne()) * Math_SinS(theta); - this->initialPositions[i].z = (2000.0f * Rand_ZeroOne()) * Math_CosS(theta); - } else { - this->initialPositions[i].y = 2000.0f * Math_SinS(theta); - this->initialPositions[i].z = 2000.0f * Math_CosS(theta); - } - break; - - case EFF_DUST_TYPE_4: - this->initialPositions[i].x = (Rand_ZeroOne() * 8500.0f) + 1700.0f; - if (this->initialPositions[i].x > 5000.0f) { - this->initialPositions[i].y = (4000.0f * Rand_ZeroOne()) * Math_SinS(theta); - this->initialPositions[i].z = (4000.0f * Rand_ZeroOne()) * Math_CosS(theta); - } else { - this->initialPositions[i].y = 4000.0f * Math_SinS(theta); - this->initialPositions[i].z = 4000.0f * Math_CosS(theta); - } - - break; - default: - break; - } - - this->distanceTraveled[i] = 0.0f; - this->index += 1; - } - } -} - -void EffDust_Update(Actor* thisx, GlobalContext* globalCtx) { - EffDust* this = (EffDust*)thisx; - - this->actionFunc(this, globalCtx); -} - -void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) { - EffDust* this = (EffDust*)thisx; - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - Vec3f* initialPositions; - f32* distanceTraveled; - s32 i; - f32 aux; - - OPEN_DISPS(gfxCtx, "../z_eff_dust.c", 425); - - func_80093D18(gfxCtx); - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 128, 128, 128, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); - - initialPositions = this->initialPositions; - distanceTraveled = this->distanceTraveled; - - gSPSegment(POLY_XLU_DISP++, 0x08, sEmptyDL); - - for (i = 0; i < 64; i++) { - if (*distanceTraveled < 1.0f) { - aux = 1.0f - (*distanceTraveled * *distanceTraveled); - Matrix_Translate(this->actor.world.pos.x + (initialPositions->x * ((this->dx * aux) + (1.0f - this->dx))), - this->actor.world.pos.y + (initialPositions->y * ((this->dy * aux) + (1.0f - this->dy))), - this->actor.world.pos.z + (initialPositions->z * ((this->dz * aux) + (1.0f - this->dz))), - MTXMODE_NEW); - - Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_dust.c", 449), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffSparklesDL)); - } - - initialPositions++; - distanceTraveled++; - // Needed for matching. - if (0) {} - } - - CLOSE_DISPS(gfxCtx, "../z_eff_dust.c", 458); -} - -void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx2) { - EffDust* this = (EffDust*)thisx; - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - f32* distanceTraveled; - Vec3f* initialPositions; - s32 i; - f32 aux; - Player* player = GET_PLAYER(globalCtx); - - OPEN_DISPS(gfxCtx, "../z_eff_dust.c", 472); - - func_80093D18(gfxCtx); - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - if (player->unk_858 >= 0.85f) { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); - } - - initialPositions = this->initialPositions; - distanceTraveled = this->distanceTraveled; - - gSPSegment(POLY_XLU_DISP++, 0x08, sEmptyDL); - - for (i = 0; i < 64; i++) { - if (*distanceTraveled < 1.0f) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, *distanceTraveled * 255); - - // Needed to match. - if (!this) {} - - aux = 1.0f - (*distanceTraveled * *distanceTraveled); - - Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); - - Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - initialPositions->y * (1.0f - *distanceTraveled) + 320.0f, - initialPositions->z * (1.0f - *distanceTraveled) + -20.0f, MTXMODE_APPLY); - - Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, - *distanceTraveled * this->scalingFactor, MTXMODE_APPLY); - - func_800D1FD4(&globalCtx->billboardMtxF); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_dust.c", 506), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffSparklesDL)); - } - - initialPositions++; - distanceTraveled++; - } - - CLOSE_DISPS(gfxCtx, "../z_eff_dust.c", 515); -} - -void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx) { - EffDust* this = (EffDust*)thisx; - - this->drawFunc(thisx, globalCtx); -} diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.cpp b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.cpp new file mode 100644 index 000000000..89380e56d --- /dev/null +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.cpp @@ -0,0 +1,380 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EFF_DUST_Z_EFF_DUST_C +#include "actor_common.h" +/** + * File z_eff_dust.c + * Overlay: ovl_Eff_Dust + * Description: Dust effects + */ + +#include "z_eff_dust.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/system_malloc.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EffDust_Init(Actor* thisx, GlobalContext* globalCtx); +void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EffDust_Update(Actor* thisx, GlobalContext* globalCtx); +void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EffDust_InitPosAndDistance(EffDust* pthis); + +void EffDust_UpdateFunc_8099DB28(EffDust* pthis, GlobalContext* globalCtx); +void EffDust_UpdateFunc_8099DD74(EffDust* pthis, GlobalContext* globalCtx); +void EffDust_UpdateFunc_8099DFC0(EffDust* pthis, GlobalContext* globalCtx); +void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx); +void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx); + +ActorInit Eff_Dust_InitVars = { + ACTOR_EFF_DUST, + ACTORCAT_NPC, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EffDust), + (ActorFunc)EffDust_Init, + (ActorFunc)EffDust_Destroy, + (ActorFunc)EffDust_Update, + (ActorFunc)EffDust_Draw, +}; + +static Gfx sEmptyDL[] = { + gsSPEndDisplayList(), +}; + +void EffDust_SetupAction(EffDust* pthis, EffDustActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EffDust_SetupDraw(EffDust* pthis, EffDustDrawFunc drawFunc) { + pthis->drawFunc = drawFunc; +} + +void EffDust_InitPosAndDistance(EffDust* pthis) { + s32 i; + + for (i = 0; i < 64; i++) { + pthis->initialPositions[i].z = 0.0f; + pthis->initialPositions[i].y = 0.0f; + pthis->initialPositions[i].x = 0.0f; + + pthis->distanceTraveled[i] = 1.0f; + } + pthis->index = 0; +} + +void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) { + EffDust* pthis = (EffDust*)thisx; + EffDustType dustEffect = (EffDustType)pthis->actor.params; + + EffDust_InitPosAndDistance(pthis); + + switch (dustEffect) { + case EFF_DUST_TYPE_0: + EffDust_SetupAction(pthis, EffDust_UpdateFunc_8099DB28); + EffDust_SetupDraw(pthis, EffDust_DrawFunc_8099E4F4); + pthis->dy = 0.8f; + pthis->dz = 0.8f; + pthis->dx = 1.0f; + pthis->scalingFactor = 0.1f; + break; + case EFF_DUST_TYPE_1: + EffDust_SetupAction(pthis, EffDust_UpdateFunc_8099DD74); + EffDust_SetupDraw(pthis, EffDust_DrawFunc_8099E4F4); + pthis->dx = 0.8f; + pthis->dz = 0.8f; + pthis->dy = 1.0f; + pthis->scalingFactor = 0.5f; + break; + case EFF_DUST_TYPE_2: + EffDust_SetupAction(pthis, EffDust_UpdateFunc_8099DFC0); + EffDust_SetupDraw(pthis, EffDust_DrawFunc_8099E784); + pthis->dx = 0.5f; + pthis->scalingFactor = 15.0f; + break; + case EFF_DUST_TYPE_3: + EffDust_SetupAction(pthis, EffDust_UpdateFunc_8099DFC0); + EffDust_SetupDraw(pthis, EffDust_DrawFunc_8099E784); + pthis->dx = 0.5f; + pthis->scalingFactor = 10.0f; + break; + case EFF_DUST_TYPE_4: + EffDust_SetupAction(pthis, EffDust_UpdateFunc_8099DFC0); + EffDust_SetupDraw(pthis, EffDust_DrawFunc_8099E784); + pthis->actor.room = -1; + pthis->dx = 0.5f; + pthis->scalingFactor = 20.0f; + break; + default: + SystemArena_FreeDebug(pthis, "../z_eff_dust.c", 202); + break; + } + + pthis->life = 10; +} + +void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EffDust_UpdateFunc_8099DB28(EffDust* pthis, GlobalContext* globalCtx) { + s16 theta; + s16 fi; + f32* distanceTraveled = pthis->distanceTraveled; + s32 i; + s32 j; + + for (i = 0; i < 64; i++) { + if ((*distanceTraveled) < 1.0f) { + *distanceTraveled += 0.05f; + } + distanceTraveled++; + } + + for (j = 0; j < 3; j++) { + i = pthis->index & 0x3F; + if (pthis->distanceTraveled[i] >= 1.0f) { + // Spherical coordinate system. + fi = Rand_CenteredFloat(8192.0f); + theta = Rand_CenteredFloat(4096.0f); + pthis->initialPositions[i].x = -800.0f * Math_CosS(fi) * Math_CosS(theta); + pthis->initialPositions[i].y = -800.0f * Math_SinS(theta); + pthis->initialPositions[i].z = -800.0f * Math_SinS(fi) * Math_CosS(theta); + pthis->distanceTraveled[i] = 0.0f; + pthis->index += 1; + } + } +} + +void EffDust_UpdateFunc_8099DD74(EffDust* pthis, GlobalContext* globalCtx) { + s16 theta; + s16 fi; + f32* distanceTraveled = pthis->distanceTraveled; + s32 i; + s32 j; + + for (i = 0; i < 64; i++) { + if ((*distanceTraveled) < 1.0f) { + *distanceTraveled += 0.03f; + } + distanceTraveled++; + } + + for (j = 0; j < 2; j++) { + i = pthis->index & 0x3F; + if (pthis->distanceTraveled[i] >= 1.0f) { + // Spherical coordinate system. + fi = Rand_CenteredFloat(65536.0f); + theta = Rand_ZeroFloat(8192.0f); + pthis->initialPositions[i].x = 400.0f * Math_CosS(fi) * Math_CosS(theta); + pthis->initialPositions[i].y = 400.0f * Math_SinS(theta); + pthis->initialPositions[i].z = 400.0f * Math_SinS(fi) * Math_CosS(theta); + pthis->distanceTraveled[i] = 0.0f; + pthis->index += 1; + } + } +} + +void EffDust_UpdateFunc_8099DFC0(EffDust* pthis, GlobalContext* globalCtx) { + s16 theta; + Player* player = GET_PLAYER(globalCtx); + Actor* parent = pthis->actor.parent; + f32* distanceTraveled = pthis->distanceTraveled; + s32 i; + s32 j; + + if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & 0x1000)) { + if (pthis->life != 0) { + pthis->life -= 1; + } else { + Actor_Kill(&pthis->actor); + } + + for (i = 0; i < 64; i++) { + if ((*distanceTraveled) < 1.0f) { + *distanceTraveled += 0.2f; + } + distanceTraveled++; + } + + return; + } + + for (i = 0; i < 64; i++) { + if ((*distanceTraveled) < 1.0f) { + *distanceTraveled += 0.1f; + } + distanceTraveled++; + } + + pthis->actor.world.pos = parent->world.pos; + + for (j = 0; j < 3; j++) { + i = pthis->index & 0x3F; + if (pthis->distanceTraveled[i] >= 1.0f) { + + theta = Rand_CenteredFloat(65536.0f); + switch (pthis->actor.params) { + case EFF_DUST_TYPE_2: + pthis->initialPositions[i].x = (Rand_ZeroOne() * 4500.0f) + 700.0f; + if (pthis->initialPositions[i].x > 3000.0f) { + pthis->initialPositions[i].y = (3000.0f * Rand_ZeroOne()) * Math_SinS(theta); + pthis->initialPositions[i].z = (3000.0f * Rand_ZeroOne()) * Math_CosS(theta); + } else { + pthis->initialPositions[i].y = 3000.0f * Math_SinS(theta); + pthis->initialPositions[i].z = 3000.0f * Math_CosS(theta); + } + break; + + case EFF_DUST_TYPE_3: + pthis->initialPositions[i].x = (Rand_ZeroOne() * 2500.0f) + 700.0f; + if (pthis->initialPositions[i].x > 2000.0f) { + pthis->initialPositions[i].y = (2000.0f * Rand_ZeroOne()) * Math_SinS(theta); + pthis->initialPositions[i].z = (2000.0f * Rand_ZeroOne()) * Math_CosS(theta); + } else { + pthis->initialPositions[i].y = 2000.0f * Math_SinS(theta); + pthis->initialPositions[i].z = 2000.0f * Math_CosS(theta); + } + break; + + case EFF_DUST_TYPE_4: + pthis->initialPositions[i].x = (Rand_ZeroOne() * 8500.0f) + 1700.0f; + if (pthis->initialPositions[i].x > 5000.0f) { + pthis->initialPositions[i].y = (4000.0f * Rand_ZeroOne()) * Math_SinS(theta); + pthis->initialPositions[i].z = (4000.0f * Rand_ZeroOne()) * Math_CosS(theta); + } else { + pthis->initialPositions[i].y = 4000.0f * Math_SinS(theta); + pthis->initialPositions[i].z = 4000.0f * Math_CosS(theta); + } + + break; + default: + break; + } + + pthis->distanceTraveled[i] = 0.0f; + pthis->index += 1; + } + } +} + +void EffDust_Update(Actor* thisx, GlobalContext* globalCtx) { + EffDust* pthis = (EffDust*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) { + EffDust* pthis = (EffDust*)thisx; + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f* initialPositions; + f32* distanceTraveled; + s32 i; + f32 aux; + + OPEN_DISPS(gfxCtx, "../z_eff_dust.c", 425); + + func_80093D18(gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 128, 128, 128, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); + + initialPositions = pthis->initialPositions; + distanceTraveled = pthis->distanceTraveled; + + gSPSegment(POLY_XLU_DISP++, 0x08, sEmptyDL); + + for (i = 0; i < 64; i++) { + if (*distanceTraveled < 1.0f) { + aux = 1.0f - (*distanceTraveled * *distanceTraveled); + Matrix_Translate(pthis->actor.world.pos.x + (initialPositions->x * ((pthis->dx * aux) + (1.0f - pthis->dx))), + pthis->actor.world.pos.y + (initialPositions->y * ((pthis->dy * aux) + (1.0f - pthis->dy))), + pthis->actor.world.pos.z + (initialPositions->z * ((pthis->dz * aux) + (1.0f - pthis->dz))), + MTXMODE_NEW); + + Matrix_Scale(pthis->scalingFactor, pthis->scalingFactor, pthis->scalingFactor, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_dust.c", 449), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffSparklesDL)); + } + + initialPositions++; + distanceTraveled++; + // Needed for matching. + if (0) {} + } + + CLOSE_DISPS(gfxCtx, "../z_eff_dust.c", 458); +} + +void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx2) { + EffDust* pthis = (EffDust*)thisx; + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32* distanceTraveled; + Vec3f* initialPositions; + s32 i; + f32 aux; + Player* player = GET_PLAYER(globalCtx); + + OPEN_DISPS(gfxCtx, "../z_eff_dust.c", 472); + + func_80093D18(gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + if (player->unk_858 >= 0.85f) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); + } + + initialPositions = pthis->initialPositions; + distanceTraveled = pthis->distanceTraveled; + + gSPSegment(POLY_XLU_DISP++, 0x08, sEmptyDL); + + for (i = 0; i < 64; i++) { + if (*distanceTraveled < 1.0f) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, *distanceTraveled * 255); + + // Needed to match. + if (!pthis) {} + + aux = 1.0f - (*distanceTraveled * *distanceTraveled); + + Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); + + Matrix_Translate(initialPositions->x * ((pthis->dx * aux) + (1.0f - pthis->dx)), + initialPositions->y * (1.0f - *distanceTraveled) + 320.0f, + initialPositions->z * (1.0f - *distanceTraveled) + -20.0f, MTXMODE_APPLY); + + Matrix_Scale(*distanceTraveled * pthis->scalingFactor, *distanceTraveled * pthis->scalingFactor, + *distanceTraveled * pthis->scalingFactor, MTXMODE_APPLY); + + func_800D1FD4(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_dust.c", 506), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffSparklesDL)); + } + + initialPositions++; + distanceTraveled++; + } + + CLOSE_DISPS(gfxCtx, "../z_eff_dust.c", 515); +} + +void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx) { + EffDust* pthis = (EffDust*)thisx; + + pthis->drawFunc(thisx, globalCtx); +} diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h index a53866e55..154872756 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h @@ -6,10 +6,10 @@ struct EffDust; -typedef void (*EffDustActionFunc)(struct EffDust*, GlobalContext*); +typedef void (*EffDustActionFunc)(EffDust*, GlobalContext*); typedef void (*EffDustDrawFunc)(Actor*, GlobalContext*); -typedef struct EffDust { +struct EffDust { /* 0x0000 */ Actor actor; /* 0x014C */ f32 distanceTraveled[64]; // For each particle. Normalized. From 0.0f to 1.0f /* 0x024C */ Vec3f initialPositions[64]; // Array of position for each dust particle. @@ -21,14 +21,15 @@ typedef struct EffDust { /* 0x055C */ f32 scalingFactor; /* 0x0560 */ EffDustActionFunc actionFunc; /* 0x0564 */ EffDustDrawFunc drawFunc; -} EffDust; // size = 0x0568 +}; // size = 0x0568 -typedef enum { +enum EffDustType +{ /* 0x00 */ EFF_DUST_TYPE_0, /* 0x01 */ EFF_DUST_TYPE_1, /* 0x02 */ EFF_DUST_TYPE_2, /* 0x03 */ EFF_DUST_TYPE_3, /* 0x04 */ EFF_DUST_TYPE_4 -} EffDustType; +}; #endif diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.cpp similarity index 56% rename from src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c rename to src/overlays/actors/ovl_Elf_Msg/z_elf_msg.cpp index 0ec17d095..1652da7dc 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.cpp @@ -21,10 +21,10 @@ void ElfMsg_Destroy(Actor* thisx, GlobalContext* globalCtx); void ElfMsg_Update(Actor* thisx, GlobalContext* globalCtx); void ElfMsg_Draw(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg_CallNaviCuboid(ElfMsg* this, GlobalContext* globalCtx); -void ElfMsg_CallNaviCylinder(ElfMsg* this, GlobalContext* globalCtx); +void ElfMsg_CallNaviCuboid(ElfMsg* pthis, GlobalContext* globalCtx); +void ElfMsg_CallNaviCylinder(ElfMsg* pthis, GlobalContext* globalCtx); -const ActorInit Elf_Msg_InitVars = { +ActorInit Elf_Msg_InitVars = { ACTOR_ELF_MSG, ACTORCAT_ITEMACTION, FLAGS, @@ -41,41 +41,41 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ElfMsg_SetupAction(ElfMsg* pthis, ElfMsgActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } /** * Checks a scene flag - if flag is set, the actor is killed and function returns 1. Otherwise returns 0. * Can also set a switch flag from params while killing. */ -s32 ElfMsg_KillCheck(ElfMsg* this, GlobalContext* globalCtx) { - if ((this->actor.world.rot.y > 0) && (this->actor.world.rot.y < 0x41) && - Flags_GetSwitch(globalCtx, this->actor.world.rot.y - 1)) { +s32 ElfMsg_KillCheck(ElfMsg* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.world.rot.y > 0) && (pthis->actor.world.rot.y < 0x41) && + Flags_GetSwitch(globalCtx, pthis->actor.world.rot.y - 1)) { LOG_STRING("共倒れ", "../z_elf_msg.c", 161); // "Mutual destruction" - if (((this->actor.params >> 8) & 0x3F) != 0x3F) { - Flags_SetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F); + if (((pthis->actor.params >> 8) & 0x3F) != 0x3F) { + Flags_SetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return 1; - } else if ((this->actor.world.rot.y == -1) && Flags_GetClear(globalCtx, this->actor.room)) { + } else if ((pthis->actor.world.rot.y == -1) && Flags_GetClear(globalCtx, pthis->actor.room)) { LOG_STRING("共倒れ", "../z_elf_msg.c", 172); // "Mutual destruction" - if (((this->actor.params >> 8) & 0x3F) != 0x3F) { - Flags_SetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F); + if (((pthis->actor.params >> 8) & 0x3F) != 0x3F) { + Flags_SetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return 1; - } else if (((this->actor.params >> 8) & 0x3F) == 0x3F) { + } else if (((pthis->actor.params >> 8) & 0x3F) == 0x3F) { return 0; - } else if (Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { - Actor_Kill(&this->actor); + } else if (Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { + Actor_Kill(&pthis->actor); return 1; } return 0; } void ElfMsg_Init(Actor* thisx, GlobalContext* globalCtx) { - ElfMsg* this = (ElfMsg*)thisx; + ElfMsg* pthis = (ElfMsg*)thisx; // "Conditions for Elf Tag disappearing" osSyncPrintf(VT_FGCOL(CYAN) "\nエルフ タグ 消える条件 %d" VT_RST "\n", (thisx->params >> 8) & 0x3F); @@ -85,7 +85,7 @@ void ElfMsg_Init(Actor* thisx, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(CYAN) "\nエルフ タグ 出現条件 %d" VT_RST "\n", thisx->shape.rot.y - 0x41); } - if (!ElfMsg_KillCheck(this, globalCtx)) { + if (!ElfMsg_KillCheck(pthis, globalCtx)) { Actor_ProcessInitChain(thisx, sInitChain); if (thisx->world.rot.x == 0) { thisx->scale.z = 0.4f; @@ -101,9 +101,9 @@ void ElfMsg_Init(Actor* thisx, GlobalContext* globalCtx) { } if (thisx->params & 0x4000) { - ElfMsg_SetupAction(this, ElfMsg_CallNaviCuboid); + ElfMsg_SetupAction(pthis, ElfMsg_CallNaviCuboid); } else { - ElfMsg_SetupAction(this, ElfMsg_CallNaviCylinder); + ElfMsg_SetupAction(pthis, ElfMsg_CallNaviCylinder); } thisx->shape.rot.x = thisx->shape.rot.y = thisx->shape.rot.z = 0; @@ -113,25 +113,25 @@ void ElfMsg_Init(Actor* thisx, GlobalContext* globalCtx) { void ElfMsg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -s32 ElfMsg_GetMessageId(ElfMsg* this) { +s32 ElfMsg_GetMessageId(ElfMsg* pthis) { // Negative message ID forces link to talk to Navi - if (this->actor.params & 0x8000) { - return (this->actor.params & 0xFF) + 0x100; + if (pthis->actor.params & 0x8000) { + return (pthis->actor.params & 0xFF) + 0x100; } else { - return -((this->actor.params & 0xFF) + 0x100); + return -((pthis->actor.params & 0xFF) + 0x100); } } -void ElfMsg_CallNaviCuboid(ElfMsg* this, GlobalContext* globalCtx) { +void ElfMsg_CallNaviCuboid(ElfMsg* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnElf* navi = (EnElf*)player->naviActor; - if ((fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x)) && - (this->actor.world.pos.y <= player->actor.world.pos.y) && - ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y)) && - (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) { - player->naviTextId = ElfMsg_GetMessageId(this); - navi->elfMsg = this; + if ((fabsf(player->actor.world.pos.x - pthis->actor.world.pos.x) < (100.0f * pthis->actor.scale.x)) && + (pthis->actor.world.pos.y <= player->actor.world.pos.y) && + ((player->actor.world.pos.y - pthis->actor.world.pos.y) < (100.0f * pthis->actor.scale.y)) && + (fabsf(player->actor.world.pos.z - pthis->actor.world.pos.z) < (100.0f * pthis->actor.scale.z))) { + player->naviTextId = ElfMsg_GetMessageId(pthis); + navi->elfMsg = pthis; } } @@ -139,37 +139,37 @@ s32 ElfMsg_WithinXZDistance(Vec3f* pos1, Vec3f* pos2, f32 distance) { return (SQ(pos2->x - pos1->x) + SQ(pos2->z - pos1->z)) < SQ(distance); } -void ElfMsg_CallNaviCylinder(ElfMsg* this, GlobalContext* globalCtx) { +void ElfMsg_CallNaviCylinder(ElfMsg* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnElf* navi = (EnElf*)player->naviActor; - if (ElfMsg_WithinXZDistance(&player->actor.world.pos, &this->actor.world.pos, this->actor.scale.x * 100.0f) && - (this->actor.world.pos.y <= player->actor.world.pos.y) && - ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) { - player->naviTextId = ElfMsg_GetMessageId(this); - navi->elfMsg = this; + if (ElfMsg_WithinXZDistance(&player->actor.world.pos, &pthis->actor.world.pos, pthis->actor.scale.x * 100.0f) && + (pthis->actor.world.pos.y <= player->actor.world.pos.y) && + ((player->actor.world.pos.y - pthis->actor.world.pos.y) < (100.0f * pthis->actor.scale.y))) { + player->naviTextId = ElfMsg_GetMessageId(pthis); + navi->elfMsg = pthis; } } void ElfMsg_Update(Actor* thisx, GlobalContext* globalCtx) { - ElfMsg* this = (ElfMsg*)thisx; + ElfMsg* pthis = (ElfMsg*)thisx; - if (!ElfMsg_KillCheck(this, globalCtx)) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (((this->actor.params >> 8) & 0x3F) != 0x3F) { - Flags_SetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F); + if (!ElfMsg_KillCheck(pthis, globalCtx)) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (((pthis->actor.params >> 8) & 0x3F) != 0x3F) { + Flags_SetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if ((this->actor.world.rot.y <= 0x41) || (this->actor.world.rot.y > 0x80) || - Flags_GetSwitch(globalCtx, this->actor.world.rot.y - 0x41)) { - this->actionFunc(this, globalCtx); + if ((pthis->actor.world.rot.y <= 0x41) || (pthis->actor.world.rot.y > 0x80) || + Flags_GetSwitch(globalCtx, pthis->actor.world.rot.y - 0x41)) { + pthis->actionFunc(pthis, globalCtx); } } } -#include "overlays/ovl_Elf_Msg/ovl_Elf_Msg.c" +#include "overlays/ovl_Elf_Msg/ovl_Elf_Msg.cpp" void ElfMsg_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg.c", 436); diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c deleted file mode 100644 index 7db232340..000000000 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ /dev/null @@ -1,173 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ELF_MSG2_Z_ELF_MSG2_C -#include "actor_common.h" -/* - * File: z_elf_msg2.c - * Overlay: ovl_Elf_Msg2 - * Description: Targetable Navi check spot - */ - -#include "z_elf_msg2.h" -#include "vt.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void ElfMsg2_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg2_Update(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg2_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 ElfMsg2_GetMessageId(ElfMsg2* this); -void ElfMsg2_WaitUntilActivated(ElfMsg2* this, GlobalContext* globalCtx); -void ElfMsg2_WaitForTextRead(ElfMsg2* this, GlobalContext* globalCtx); - -const ActorInit Elf_Msg2_InitVars = { - ACTOR_ELF_MSG2, - ACTORCAT_BG, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ElfMsg2), - (ActorFunc)ElfMsg2_Init, - (ActorFunc)ElfMsg2_Destroy, - (ActorFunc)ElfMsg2_Update, - (ActorFunc)ElfMsg2_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), -}; - -void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -/** - * Checks a scene flag - if flag is set, the actor is killed and function returns 1. Otherwise returns 0. - * Can also set a switch flag from params while killing. - */ -s32 ElfMsg2_KillCheck(ElfMsg2* this, GlobalContext* globalCtx) { - if ((this->actor.world.rot.y > 0) && (this->actor.world.rot.y < 0x41) && - Flags_GetSwitch(globalCtx, this->actor.world.rot.y - 1)) { - LOG_STRING("共倒れ", "../z_elf_msg2.c", 171); // "Mutual destruction" - if (((this->actor.params >> 8) & 0x3F) != 0x3F) { - Flags_SetSwitch(globalCtx, ((this->actor.params >> 8) & 0x3F)); - } - Actor_Kill(&this->actor); - return 1; - } else if ((this->actor.world.rot.y == -1) && Flags_GetClear(globalCtx, this->actor.room)) { - LOG_STRING("共倒れ2", "../z_elf_msg2.c", 182); // "Mutual destruction 2" - if (((this->actor.params >> 8) & 0x3F) != 0x3F) { - Flags_SetSwitch(globalCtx, ((this->actor.params >> 8) & 0x3F)); - } - Actor_Kill(&this->actor); - return 1; - } else if (((this->actor.params >> 8) & 0x3F) == 0x3F) { - return 0; - } else if (Flags_GetSwitch(globalCtx, ((this->actor.params >> 8) & 0x3F))) { - LOG_STRING("共倒れ", "../z_elf_msg2.c", 192); // "Mutual destruction" - Actor_Kill(&this->actor); - return 1; - } - return 0; -} - -void ElfMsg2_Init(Actor* thisx, GlobalContext* globalCtx) { - ElfMsg2* this = (ElfMsg2*)thisx; - - osSyncPrintf(VT_FGCOL(CYAN) " Elf_Msg2_Actor_ct %04x\n\n" VT_RST, this->actor.params); - if (!ElfMsg2_KillCheck(this, globalCtx)) { - if ((this->actor.world.rot.x > 0) && (this->actor.world.rot.x < 8)) { - this->actor.targetMode = this->actor.world.rot.x - 1; - } - Actor_ProcessInitChain(thisx, sInitChain); - if (this->actor.world.rot.y >= 0x41) { - ElfMsg2_SetupAction(this, ElfMsg2_WaitUntilActivated); - } else { - ElfMsg2_SetupAction(this, ElfMsg2_WaitForTextRead); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_18; // Make actor targetable and Navi-checkable - this->actor.textId = ElfMsg2_GetMessageId(this); - } - this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - } -} - -void ElfMsg2_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -s32 ElfMsg2_GetMessageId(ElfMsg2* this) { - return (this->actor.params & 0xFF) + 0x100; -} - -/** - * Runs while Navi text is up. Kills the actor upon closing the text box unless rot.z == 1, can also set a switch flag - * from params. - */ -void ElfMsg2_WaitForTextClose(ElfMsg2* this, GlobalContext* globalCtx) { - s32 switchFlag; - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - if (this->actor.world.rot.z != 1) { - Actor_Kill(&this->actor); - switchFlag = (this->actor.params >> 8) & 0x3F; - if (switchFlag != 0x3F) { - Flags_SetSwitch(globalCtx, switchFlag); - } - } else { - ElfMsg2_SetupAction(this, ElfMsg2_WaitForTextRead); - } - } -} - -/** - * Runs while Navi text is not up. - */ -void ElfMsg2_WaitForTextRead(ElfMsg2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - ElfMsg2_SetupAction(this, ElfMsg2_WaitForTextClose); - } -} - -/** - * Idles until a switch flag is set, at which point the actor becomes interactable - */ -void ElfMsg2_WaitUntilActivated(ElfMsg2* this, GlobalContext* globalCtx) { - // If (y >= 0x41) && (y <= 0x80), Idles until switch flag (actor.world.rot.y - 0x41) is set - // If (y > 0x80), Idles forever (Bug?) - if ((this->actor.world.rot.y >= 0x41) && (this->actor.world.rot.y <= 0x80) && - (Flags_GetSwitch(globalCtx, (this->actor.world.rot.y - 0x41)))) { - ElfMsg2_SetupAction(this, ElfMsg2_WaitForTextRead); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_18; // Make actor targetable and Navi-checkable - this->actor.textId = ElfMsg2_GetMessageId(this); - } -} - -void ElfMsg2_Update(Actor* thisx, GlobalContext* globalCtx) { - ElfMsg2* this = (ElfMsg2*)thisx; - - if (!ElfMsg2_KillCheck(this, globalCtx)) { - this->actionFunc(this, globalCtx); - } -} - -#include "overlays/ovl_Elf_Msg2/ovl_Elf_Msg2.c" - -void ElfMsg2_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 355); - - if (R_NAVI_MSG_REGION_ALPHA == 0) { - return; - } - - func_80093D18(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 100, 255, R_NAVI_MSG_REGION_ALPHA); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 362), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_809ADC38); - gSPDisplayList(POLY_XLU_DISP++, sCubeDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 367); -} diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.cpp b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.cpp new file mode 100644 index 000000000..e9866c4c5 --- /dev/null +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.cpp @@ -0,0 +1,173 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ELF_MSG2_Z_ELF_MSG2_C +#include "actor_common.h" +/* + * File: z_elf_msg2.c + * Overlay: ovl_Elf_Msg2 + * Description: Targetable Navi check spot + */ + +#include "z_elf_msg2.h" +#include "vt.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void ElfMsg2_Init(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg2_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg2_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 ElfMsg2_GetMessageId(ElfMsg2* pthis); +void ElfMsg2_WaitUntilActivated(ElfMsg2* pthis, GlobalContext* globalCtx); +void ElfMsg2_WaitForTextRead(ElfMsg2* pthis, GlobalContext* globalCtx); + +ActorInit Elf_Msg2_InitVars = { + ACTOR_ELF_MSG2, + ACTORCAT_BG, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ElfMsg2), + (ActorFunc)ElfMsg2_Init, + (ActorFunc)ElfMsg2_Destroy, + (ActorFunc)ElfMsg2_Update, + (ActorFunc)ElfMsg2_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), +}; + +void ElfMsg2_SetupAction(ElfMsg2* pthis, ElfMsg2ActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +/** + * Checks a scene flag - if flag is set, the actor is killed and function returns 1. Otherwise returns 0. + * Can also set a switch flag from params while killing. + */ +s32 ElfMsg2_KillCheck(ElfMsg2* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.world.rot.y > 0) && (pthis->actor.world.rot.y < 0x41) && + Flags_GetSwitch(globalCtx, pthis->actor.world.rot.y - 1)) { + LOG_STRING("共倒れ", "../z_elf_msg2.c", 171); // "Mutual destruction" + if (((pthis->actor.params >> 8) & 0x3F) != 0x3F) { + Flags_SetSwitch(globalCtx, ((pthis->actor.params >> 8) & 0x3F)); + } + Actor_Kill(&pthis->actor); + return 1; + } else if ((pthis->actor.world.rot.y == -1) && Flags_GetClear(globalCtx, pthis->actor.room)) { + LOG_STRING("共倒れ2", "../z_elf_msg2.c", 182); // "Mutual destruction 2" + if (((pthis->actor.params >> 8) & 0x3F) != 0x3F) { + Flags_SetSwitch(globalCtx, ((pthis->actor.params >> 8) & 0x3F)); + } + Actor_Kill(&pthis->actor); + return 1; + } else if (((pthis->actor.params >> 8) & 0x3F) == 0x3F) { + return 0; + } else if (Flags_GetSwitch(globalCtx, ((pthis->actor.params >> 8) & 0x3F))) { + LOG_STRING("共倒れ", "../z_elf_msg2.c", 192); // "Mutual destruction" + Actor_Kill(&pthis->actor); + return 1; + } + return 0; +} + +void ElfMsg2_Init(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg2* pthis = (ElfMsg2*)thisx; + + osSyncPrintf(VT_FGCOL(CYAN) " Elf_Msg2_Actor_ct %04x\n\n" VT_RST, pthis->actor.params); + if (!ElfMsg2_KillCheck(pthis, globalCtx)) { + if ((pthis->actor.world.rot.x > 0) && (pthis->actor.world.rot.x < 8)) { + pthis->actor.targetMode = pthis->actor.world.rot.x - 1; + } + Actor_ProcessInitChain(thisx, sInitChain); + if (pthis->actor.world.rot.y >= 0x41) { + ElfMsg2_SetupAction(pthis, ElfMsg2_WaitUntilActivated); + } else { + ElfMsg2_SetupAction(pthis, ElfMsg2_WaitForTextRead); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_18; // Make actor targetable and Navi-checkable + pthis->actor.textId = ElfMsg2_GetMessageId(pthis); + } + pthis->actor.shape.rot.x = pthis->actor.shape.rot.y = pthis->actor.shape.rot.z = 0; + } +} + +void ElfMsg2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 ElfMsg2_GetMessageId(ElfMsg2* pthis) { + return (pthis->actor.params & 0xFF) + 0x100; +} + +/** + * Runs while Navi text is up. Kills the actor upon closing the text box unless rot.z == 1, can also set a switch flag + * from params. + */ +void ElfMsg2_WaitForTextClose(ElfMsg2* pthis, GlobalContext* globalCtx) { + s32 switchFlag; + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + if (pthis->actor.world.rot.z != 1) { + Actor_Kill(&pthis->actor); + switchFlag = (pthis->actor.params >> 8) & 0x3F; + if (switchFlag != 0x3F) { + Flags_SetSwitch(globalCtx, switchFlag); + } + } else { + ElfMsg2_SetupAction(pthis, ElfMsg2_WaitForTextRead); + } + } +} + +/** + * Runs while Navi text is not up. + */ +void ElfMsg2_WaitForTextRead(ElfMsg2* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + ElfMsg2_SetupAction(pthis, ElfMsg2_WaitForTextClose); + } +} + +/** + * Idles until a switch flag is set, at which point the actor becomes interactable + */ +void ElfMsg2_WaitUntilActivated(ElfMsg2* pthis, GlobalContext* globalCtx) { + // If (y >= 0x41) && (y <= 0x80), Idles until switch flag (actor.world.rot.y - 0x41) is set + // If (y > 0x80), Idles forever (Bug?) + if ((pthis->actor.world.rot.y >= 0x41) && (pthis->actor.world.rot.y <= 0x80) && + (Flags_GetSwitch(globalCtx, (pthis->actor.world.rot.y - 0x41)))) { + ElfMsg2_SetupAction(pthis, ElfMsg2_WaitForTextRead); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_18; // Make actor targetable and Navi-checkable + pthis->actor.textId = ElfMsg2_GetMessageId(pthis); + } +} + +void ElfMsg2_Update(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg2* pthis = (ElfMsg2*)thisx; + + if (!ElfMsg2_KillCheck(pthis, globalCtx)) { + pthis->actionFunc(pthis, globalCtx); + } +} + +#include "overlays/ovl_Elf_Msg2/ovl_Elf_Msg2.cpp" + +void ElfMsg2_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 355); + + if (R_NAVI_MSG_REGION_ALPHA == 0) { + return; + } + + func_80093D18(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 100, 255, R_NAVI_MSG_REGION_ALPHA); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 362), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_809ADC38); + gSPDisplayList(POLY_XLU_DISP++, sCubeDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 367); +} diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c deleted file mode 100644 index 2b65c1e88..000000000 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ /dev/null @@ -1,989 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_AM_Z_EN_AM_C -#include "actor_common.h" -/* - * File: z_en_am.c - * Overlay: ovl_En_Am - * Description: Armos - */ - -#include "z_en_am.h" -#include "objects/object_am/object_am.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "def/code_80043480.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_26) - -void EnAm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnAm_SetupStatue(EnAm* this); -void EnAm_SetupSleep(EnAm* this); -void EnAm_Statue(EnAm* this, GlobalContext* globalCtx); -void EnAm_Sleep(EnAm* this, GlobalContext* globalCtx); -void EnAm_Lunge(EnAm* this, GlobalContext* globalCtx); -void EnAm_RotateToHome(EnAm* this, GlobalContext* globalCtx); -void EnAm_MoveToHome(EnAm* this, GlobalContext* globalCtx); -void EnAm_RotateToInit(EnAm* this, GlobalContext* globalCtx); -void EnAm_Cooldown(EnAm* this, GlobalContext* globalCtx); -void EnAm_Ricochet(EnAm* this, GlobalContext* globalCtx); -void EnAm_Stunned(EnAm* this, GlobalContext* globalCtx); -void EnAm_RecoilFromDamage(EnAm* this, GlobalContext* globalCtx); - -typedef enum { - /* 00 */ AM_BEHAVIOR_NONE, - /* 01 */ AM_BEHAVIOR_DAMAGED, - /* 03 */ AM_BEHAVIOR_DO_NOTHING = 3, - /* 05 */ AM_BEHAVIOR_5 = 5, // checked but never set - /* 06 */ AM_BEHAVIOR_STUNNED, - /* 07 */ AM_BEHAVIOR_GO_HOME, - /* 08 */ AM_BEHAVIOR_RICOCHET, - /* 10 */ AM_BEHAVIOR_AGGRO = 10 -} ArmosBehavior; - -const ActorInit En_Am_InitVars = { - ACTOR_EN_AM, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_AM, - sizeof(EnAm), - (ActorFunc)EnAm_Init, - (ActorFunc)EnAm_Destroy, - (ActorFunc)EnAm_Update, - (ActorFunc)EnAm_Draw, -}; - -static ColliderCylinderInit sHurtCylinderInit = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 15, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sBlockCylinderInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00400106, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 15, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderQuadInit sQuadInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -typedef enum { - /* 00 */ AM_DMGEFF_NONE, // used by anything that cant kill the armos - /* 01 */ AM_DMGEFF_NUT, - /* 06 */ AM_DMGEFF_STUN = 6, // doesnt include deku nuts - /* 13 */ AM_DMGEFF_ICE = 13, - /* 14 */ AM_DMGEFF_MAGIC_FIRE_LIGHT, - /* 15 */ AM_DMGEFF_KILL // any damage source that can kill the armos (and isnt a special case) -} ArmosDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, AM_DMGEFF_NUT), - /* Deku stick */ DMG_ENTRY(2, AM_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(1, AM_DMGEFF_NONE), - /* Explosive */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Boomerang */ DMG_ENTRY(0, AM_DMGEFF_STUN), - /* Normal arrow */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Hammer swing */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Hookshot */ DMG_ENTRY(0, AM_DMGEFF_STUN), - /* Kokiri sword */ DMG_ENTRY(1, AM_DMGEFF_NONE), - /* Master sword */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Giant's Knife */ DMG_ENTRY(4, AM_DMGEFF_KILL), - /* Fire arrow */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Ice arrow */ DMG_ENTRY(4, AM_DMGEFF_ICE), - /* Light arrow */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Unk arrow 1 */ DMG_ENTRY(2, AM_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(2, AM_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(2, AM_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(0, AM_DMGEFF_MAGIC_FIRE_LIGHT), - /* Ice magic */ DMG_ENTRY(3, AM_DMGEFF_ICE), - /* Light magic */ DMG_ENTRY(0, AM_DMGEFF_MAGIC_FIRE_LIGHT), - /* Shield */ DMG_ENTRY(0, AM_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, AM_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, AM_DMGEFF_NONE), - /* Giant spin */ DMG_ENTRY(4, AM_DMGEFF_KILL), - /* Master spin */ DMG_ENTRY(2, AM_DMGEFF_KILL), - /* Kokiri jump */ DMG_ENTRY(2, AM_DMGEFF_NONE), - /* Giant jump */ DMG_ENTRY(8, AM_DMGEFF_KILL), - /* Master jump */ DMG_ENTRY(4, AM_DMGEFF_KILL), - /* Unknown 1 */ DMG_ENTRY(0, AM_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, AM_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, AM_DMGEFF_KILL), - /* Unknown 2 */ DMG_ENTRY(0, AM_DMGEFF_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x13, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 5300, ICHAIN_STOP), -}; - -void EnAm_SetupAction(EnAm* this, EnAmActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -/** - * Checks bgCheckFlags in the direction of current yaw at the specified distance. - * - * Returns true if the armos would land on the ground in the resulting position. - * - * If it won't land on the ground, it will return true anyway if the floor the armos will be on - * is no more than 20 units lower than the home position. This prevents the armos from going down steep slopes. - */ -s32 EnAm_CanMove(EnAm* this, GlobalContext* globalCtx, f32 distance, s16 yaw) { - s16 ret; - s16 curBgCheckFlags; - f32 sin; - f32 cos; - Vec3f curPos; - - // save current position and bgCheckFlags to restore later - curPos = this->dyna.actor.world.pos; - curBgCheckFlags = this->dyna.actor.bgCheckFlags; - - sin = Math_SinS(yaw) * distance; - cos = Math_CosS(yaw) * distance; - - this->dyna.actor.world.pos.x += sin; - this->dyna.actor.world.pos.z += cos; - - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); - this->dyna.actor.world.pos = curPos; - ret = this->dyna.actor.bgCheckFlags & 1; - - if (!ret && (this->dyna.actor.floorHeight >= (this->dyna.actor.home.pos.y - 20.0f))) { - ret = true; - } - - this->dyna.actor.bgCheckFlags = curBgCheckFlags; - - return ret; -} - -void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { - CollisionHeader* colHeader = NULL; - s32 pad; - EnAm* this = (EnAm*)thisx; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gArmosSkel, &gArmosRicochetAnim, this->jointTable, this->morphTable, - 14); - Actor_SetScale(&this->dyna.actor, 0.01f); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - Collider_InitCylinder(globalCtx, &this->hurtCollider); - Collider_InitCylinder(globalCtx, &this->blockCollider); - Collider_SetCylinder(globalCtx, &this->hurtCollider, &this->dyna.actor, &sHurtCylinderInit); - - if (this->dyna.actor.params == ARMOS_STATUE) { - this->dyna.actor.colChkInfo.health = 1; - Collider_SetCylinder(globalCtx, &this->blockCollider, &this->dyna.actor, &sHurtCylinderInit); - this->hurtCollider.base.ocFlags1 = (OC1_ON | OC1_NO_PUSH | OC1_TYPE_1 | OC1_TYPE_2); - this->blockCollider.base.ocFlags1 = (OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER); - CollisionHeader_GetVirtual(&gArmosCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, ACTORCAT_BG); - EnAm_SetupStatue(this); - } else { - Collider_SetCylinder(globalCtx, &this->blockCollider, &this->dyna.actor, &sBlockCylinderInit); - Collider_InitQuad(globalCtx, &this->hitCollider); - Collider_SetQuad(globalCtx, &this->hitCollider, &this->dyna.actor, &sQuadInit); - this->dyna.actor.colChkInfo.health = 1; - this->dyna.actor.colChkInfo.damageTable = &sDamageTable; - EnAm_SetupSleep(this); - this->unk_258 = 0; - } - - this->dyna.actor.colChkInfo.mass = MASS_HEAVY; -} - -void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnAm* this = (EnAm*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->hurtCollider); - Collider_DestroyCylinder(globalCtx, &this->blockCollider); - //! @bug Quad collider is not destroyed (though destroy doesnt really do anything anyway) -} - -void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { - static Vec3f velocity = { 0.0f, -1.5f, 0.0f }; - static Vec3f accel = { 0.0f, -0.2f, 0.0f }; - s32 i; - Vec3f pos; - Color_RGBA8 primColor = { 100, 100, 100, 0 }; - Color_RGBA8 envColor = { 40, 40, 40, 0 }; - s32 pad; - - for (i = 4; i > 0; i--) { - pos.x = this->dyna.actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 65.0f); - pos.y = (this->dyna.actor.world.pos.y + 40.0f) + ((Rand_ZeroOne() - 0.5f) * 10.0f); - pos.z = this->dyna.actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 65.0f); - - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &velocity, &accel, &primColor, &envColor); - } - - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_AMOS_WALK); - Actor_SpawnFloorDustRing(globalCtx, &this->dyna.actor, &this->dyna.actor.world.pos, 4.0f, 3, 8.0f, 0x12C, 0xF, 0); -} - -void EnAm_SetupSleep(EnAm* this) { - f32 lastFrame = Animation_GetLastFrame(&gArmosRicochetAnim); - - Animation_Change(&this->skelAnime, &gArmosRicochetAnim, 0.0f, lastFrame, lastFrame, ANIMMODE_LOOP, 0.0f); - this->behavior = AM_BEHAVIOR_DO_NOTHING; - this->dyna.actor.speedXZ = 0.0f; - this->unk_258 = (this->textureBlend == 255) ? 0 : 1; - EnAm_SetupAction(this, EnAm_Sleep); -} - -void EnAm_SetupStatue(EnAm* this) { - f32 lastFrame = Animation_GetLastFrame(&gArmosRicochetAnim); - - Animation_Change(&this->skelAnime, &gArmosRicochetAnim, 0.0f, lastFrame, lastFrame, ANIMMODE_LOOP, 0.0f); - this->dyna.actor.flags &= ~ACTOR_FLAG_0; - this->behavior = AM_BEHAVIOR_DO_NOTHING; - this->dyna.actor.speedXZ = 0.0f; - EnAm_SetupAction(this, EnAm_Statue); -} - -void EnAm_SetupLunge(EnAm* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); - this->unk_258 = 3; - this->behavior = AM_BEHAVIOR_AGGRO; - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; - EnAm_SetupAction(this, EnAm_Lunge); -} - -void EnAm_SetupCooldown(EnAm* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); - this->unk_258 = 3; - this->cooldownTimer = 40; - this->behavior = AM_BEHAVIOR_AGGRO; - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; - EnAm_SetupAction(this, EnAm_Cooldown); -} - -void EnAm_SetupMoveToHome(EnAm* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); - this->behavior = AM_BEHAVIOR_GO_HOME; - this->unk_258 = 1; - this->dyna.actor.speedXZ = 0.0f; - EnAm_SetupAction(this, EnAm_MoveToHome); -} - -void EnAm_SetupRotateToInit(EnAm* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); - this->behavior = AM_BEHAVIOR_GO_HOME; - this->unk_258 = 1; - this->dyna.actor.speedXZ = 0.0f; - EnAm_SetupAction(this, EnAm_RotateToInit); -} - -void EnAm_SetupRotateToHome(EnAm* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); - this->behavior = AM_BEHAVIOR_GO_HOME; - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; - EnAm_SetupAction(this, EnAm_RotateToHome); -} - -void EnAm_SetupRecoilFromDamage(EnAm* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gArmosDamagedAnim, 1.0f, 4.0f, - Animation_GetLastFrame(&gArmosDamagedAnim) - 6.0f, ANIMMODE_ONCE, 0.0f); - this->behavior = AM_BEHAVIOR_DAMAGED; - this->dyna.actor.world.rot.y = this->dyna.actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_AMOS_DAMAGE); - - if (EnAm_CanMove(this, globalCtx, -6.0f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = -6.0f; - } - - this->dyna.actor.colorFilterTimer = 0; - Enemy_StartFinishingBlow(globalCtx, &this->dyna.actor); - EnAm_SetupAction(this, EnAm_RecoilFromDamage); -} - -void EnAm_SetupRicochet(EnAm* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gArmosRicochetAnim, 1.0f, 0.0f, 8.0f, ANIMMODE_ONCE, 0.0f); - this->dyna.actor.world.rot.y = this->dyna.actor.yawTowardsPlayer; - - if (EnAm_CanMove(this, globalCtx, -6.0f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = -6.0f; - } - - this->unk_264 = 0; - this->unk_258 = 0; - this->cooldownTimer = 5; - this->behavior = AM_BEHAVIOR_RICOCHET; - EnAm_SetupAction(this, EnAm_Ricochet); -} - -void EnAm_Sleep(EnAm* this, GlobalContext* globalCtx) { - f32 cos; - s32 pad; - f32 rand; - f32 sin; - Player* player = GET_PLAYER(globalCtx); - - if ((this->unk_258 != 0) || - ((this->hurtCollider.base.ocFlags1 & OC1_HIT) && (this->hurtCollider.base.oc == &player->actor)) || - (this->hurtCollider.base.acFlags & AC_HIT)) { - this->hurtCollider.base.acFlags &= ~AC_HIT; - - if (this->textureBlend == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_AMOS_WAVE); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_AMOS_VOICE); - Actor_SetColorFilter(&this->dyna.actor, 0x4000, 255, 0, 8); - } - - if (this->textureBlend >= 240) { - this->attackTimer = 200; - this->textureBlend = 255; - this->dyna.actor.flags |= ACTOR_FLAG_0; - this->dyna.actor.shape.yOffset = 0.0f; - EnAm_SetupLunge(this); - } else { - // shake randomly about the origin while waking up - rand = (Rand_ZeroOne() - 0.5f) * 10.0f; - - cos = Math_CosS(this->dyna.actor.shape.rot.y) * rand; - sin = Math_SinS(this->dyna.actor.shape.rot.y) * rand; - - this->dyna.actor.world.pos.x = this->shakeOrigin.x + cos; - this->dyna.actor.world.pos.z = this->shakeOrigin.z + sin; - - this->textureBlend += 20; - this->unk_258 = 1; - } - } else { - if (this->textureBlend > 10) { - this->textureBlend -= 10; - } else { - this->textureBlend = 0; - this->dyna.actor.flags &= ~ACTOR_FLAG_0; - - if (this->dyna.bgId < 0) { - this->unk_264 = 0; - } - - this->dyna.actor.speedXZ += this->dyna.unk_150; - this->shakeOrigin = this->dyna.actor.world.pos; - this->dyna.actor.world.rot.y = this->dyna.unk_158; - this->dyna.actor.speedXZ = CLAMP(this->dyna.actor.speedXZ, -2.5f, 2.5f); - Math_SmoothStepToF(&this->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - - if (this->dyna.actor.speedXZ != 0.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); - } - - this->dyna.unk_154 = 0.0f; - this->dyna.unk_150 = 0.0f; - } - } -} - -/** - * Spin toward the direction of the home position to start moving back to it. - */ -void EnAm_RotateToHome(EnAm* this, GlobalContext* globalCtx) { - s16 yawToHome = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); - - if (this->skelAnime.curFrame == 8.0f) { - Math_SmoothStepToS(&this->dyna.actor.world.rot.y, yawToHome, 1, 0x1F40, 0); - this->dyna.actor.velocity.y = 12.0f; - } else if (this->skelAnime.curFrame > 11.0f) { - if (!(this->dyna.actor.bgCheckFlags & 1)) { - this->skelAnime.curFrame = 11; - } else { - EnAm_SpawnEffects(this, globalCtx); - - if (this->dyna.actor.world.rot.y == yawToHome) { - this->unk_258 = 0; - } - - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - } - } - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_258 == 0) { - EnAm_SetupMoveToHome(this); - } - - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; -} - -/** - * After reaching the home position, spin back to the starting rotation. - */ -void EnAm_RotateToInit(EnAm* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame == 8.0f) { - if ((this->dyna.actor.world.pos.x == this->dyna.actor.home.pos.x) && - (this->dyna.actor.world.pos.z == this->dyna.actor.home.pos.z)) { - Math_SmoothStepToS(&this->dyna.actor.world.rot.y, this->dyna.actor.home.rot.y, 1, 0x1F40, 0); - } - this->unk_258 = 2; - this->dyna.actor.velocity.y = 12.0f; - } else if (this->skelAnime.curFrame > 11.0f) { - if (!(this->dyna.actor.bgCheckFlags & 1)) { - this->skelAnime.curFrame = 11; - } else { - this->unk_258 = 1; - EnAm_SpawnEffects(this, globalCtx); - - if (this->dyna.actor.home.rot.y == this->dyna.actor.world.rot.y) { - this->unk_258 = 0; - } - - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - } - } - - if (this->unk_258 == 2) { - Math_SmoothStepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x, 1.0f, 8.0f, 0.0f); - Math_SmoothStepToF(&this->dyna.actor.world.pos.z, this->dyna.actor.home.pos.z, 1.0f, 8.0f, 0.0f); - } - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_258 == 0) { - EnAm_SetupSleep(this); - } - - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; -} - -void EnAm_MoveToHome(EnAm* this, GlobalContext* globalCtx) { - s16 yawToHome = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); - - if (this->skelAnime.curFrame == 8.0f) { - this->dyna.actor.velocity.y = 12.0f; - this->dyna.actor.speedXZ = 6.0f; - } else if (this->skelAnime.curFrame > 11.0f) { - if (!(this->dyna.actor.bgCheckFlags & 1)) { - this->skelAnime.curFrame = 11; - } else { - Math_SmoothStepToS(&this->dyna.actor.world.rot.y, yawToHome, 1, 0xBB8, 0); - - if (this->dyna.actor.bgCheckFlags & 2) { - this->unk_258--; - } - - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - EnAm_SpawnEffects(this, globalCtx); - - if (Actor_WorldDistXYZToPoint(&this->dyna.actor, &this->dyna.actor.home.pos) < 80.0f) { - EnAm_SetupRotateToInit(this); - } - } - } - - // turn away from a wall if touching one - if ((this->dyna.actor.speedXZ != 0.0f) && (this->dyna.actor.bgCheckFlags & 8)) { - this->dyna.actor.world.rot.y = this->dyna.actor.wallYaw; - Actor_MoveForward(&this->dyna.actor); - } - - SkelAnime_Update(&this->skelAnime); - - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; -} - -void EnAm_RecoilFromDamage(EnAm* this, GlobalContext* globalCtx) { - if (this->dyna.actor.speedXZ < 0.0f) { - this->dyna.actor.speedXZ += 0.5f; - } - - if ((this->dyna.actor.velocity.y <= 0.0f) && !EnAm_CanMove(this, globalCtx, -8.0f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = 0.0f; - } - - if (SkelAnime_Update(&this->skelAnime)) { - EnAm_SetupLunge(this); - this->deathTimer = 64; - this->panicSpinRot = 0; - } -} - -/** - * After doing 3 lunges, wait for 2 seconds before attacking again. - * Turn toward the player before lunging again. - */ -void EnAm_Cooldown(EnAm* this, GlobalContext* globalCtx) { - s16 yawDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.world.rot.y; - - yawDiff = ABS(yawDiff); - - if (this->cooldownTimer != 0) { - this->cooldownTimer--; - } else { - if (this->skelAnime.curFrame == 8.0f) { - Math_SmoothStepToS(&this->dyna.actor.world.rot.y, this->dyna.actor.yawTowardsPlayer, 1, 0x1F40, 0); - this->dyna.actor.velocity.y = 12.0f; - } else if (this->skelAnime.curFrame > 11.0f) { - if (!(this->dyna.actor.bgCheckFlags & 1)) { - this->skelAnime.curFrame = 11; - } else { - if (yawDiff < 3500) { - this->unk_258 = 0; - } - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - EnAm_SpawnEffects(this, globalCtx); - } - } - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_258 == 0) { - EnAm_SetupLunge(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_AMOS_VOICE); - } - - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; - } -} - -/** - * Lunge toward the player in an attempt to deal damage. Hop 3 times. - * Used for both normal attacks and the death sequence. - */ -void EnAm_Lunge(EnAm* this, GlobalContext* globalCtx) { - if (this->deathTimer < 52) { - if (this->skelAnime.curFrame == 8.0f) { - this->dyna.actor.velocity.y = 12.0f; - - if (EnAm_CanMove(this, globalCtx, 80.0f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = 6.0f; - } else { - this->dyna.actor.speedXZ = 0.0f; - } - - this->unk_264 = 1; - this->hitCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); - } else if (this->skelAnime.curFrame > 11.0f) { - if (!(this->dyna.actor.bgCheckFlags & 1)) { - this->skelAnime.curFrame = 11; - } else { - Math_SmoothStepToS(&this->dyna.actor.world.rot.y, this->dyna.actor.yawTowardsPlayer, 1, 0x1770, 0); - - if (this->dyna.actor.bgCheckFlags & 2) { - this->unk_258--; - } - - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.speedXZ = 0.0f; - this->unk_264 = 0; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - EnAm_SpawnEffects(this, globalCtx); - - if (((Actor_WorldDistXZToPoint(&this->dyna.actor, &this->dyna.actor.home.pos) > 240.0f) || - (this->attackTimer == 0)) && - (this->deathTimer == 0)) { - EnAm_SetupRotateToHome(this); - } - } - } - - // turn and move away from a wall if contact is made with one - if ((this->dyna.actor.speedXZ != 0.0f) && (this->dyna.actor.bgCheckFlags & 8)) { - this->dyna.actor.world.rot.y = - (this->dyna.actor.wallYaw - this->dyna.actor.world.rot.y) + this->dyna.actor.wallYaw; - Actor_MoveForward(&this->dyna.actor); - this->dyna.actor.bgCheckFlags &= ~8; - } - - SkelAnime_Update(&this->skelAnime); - - if ((this->unk_258 == 0) && (this->deathTimer == 0)) { - EnAm_SetupCooldown(this); - } - - if (this->deathTimer == 0) { - this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; - } else { - if (this->panicSpinRot < 8000) { - this->panicSpinRot += 800; - } - this->dyna.actor.shape.rot.y += this->panicSpinRot; - } - } -} - -void EnAm_Statue(EnAm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 temp158f = this->dyna.unk_158; - s16 moveDir = 0; - - if (this->unk_258 == 0) { - if (this->dyna.unk_150 != 0.0f) { - this->unk_258 = 0x8000; - } - } else { - this->unk_258 -= 0x800; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); - - if (this->dyna.unk_150 < 0.0f) { - temp158f = this->dyna.unk_158 + 0x8000; - } - - if (this->hurtCollider.base.ocFlags1 & OC1_HIT) { - moveDir = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->hurtCollider.base.oc->world.pos) - temp158f; - } - - if ((this->dyna.unk_150 == 0.0f) || (this->unk_258 == 0) || !(this->dyna.actor.bgCheckFlags & 1) || - !func_800435D8(globalCtx, &this->dyna, 0x14, - (Math_SinS(this->unk_258) * (this->dyna.unk_150 * 0.5f)) + 40.0f, 0xA) || - ((this->hurtCollider.base.ocFlags1 & OC1_HIT) && (ABS(moveDir) <= 0x2000))) { - - this->unk_258 = 0; - player->stateFlags2 &= ~0x151; - player->actor.speedXZ = 0.0f; - this->dyna.unk_150 = this->dyna.unk_154 = 0.0f; - } - - this->dyna.actor.world.rot.y = this->dyna.unk_158; - this->dyna.actor.speedXZ = Math_SinS(this->unk_258) * (this->dyna.unk_150 * 0.5f); - } - - if (this->dyna.actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - } - - this->dyna.unk_150 = this->dyna.unk_154 = 0.0f; -} - -void EnAm_SetupStunned(EnAm* this, GlobalContext* globalCtx) { - // animation is set but SkelAnime_Update is not called in the action - // likely copy pasted from EnAm_SetupRecoilFromDamage - Animation_Change(&this->skelAnime, &gArmosDamagedAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gArmosDamagedAnim), - ANIMMODE_ONCE, 0.0f); - - this->dyna.actor.world.rot.y = this->dyna.actor.yawTowardsPlayer; - - if (EnAm_CanMove(this, globalCtx, -6.0f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = -6.0f; - } - - Actor_SetColorFilter(&this->dyna.actor, 0, 120, 0, 100); - - if (this->damageEffect == AM_DMGEFF_ICE) { - this->iceTimer = 48; - } - - this->behavior = AM_BEHAVIOR_STUNNED; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_GOMA_JR_FREEZE); - EnAm_SetupAction(this, EnAm_Stunned); -} - -void EnAm_Stunned(EnAm* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->dyna.actor.shape.rot.y, this->dyna.actor.world.rot.y, 1, 0xFA0, 0); - - if (this->dyna.actor.speedXZ < 0.0f) { - this->dyna.actor.speedXZ += 0.5f; - } - - if ((this->dyna.actor.velocity.y <= 0.0f) && !EnAm_CanMove(this, globalCtx, -9.0f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = 0.0f; - } - - if (this->dyna.actor.colorFilterTimer == 0) { - if (this->dyna.actor.colChkInfo.health != 0) { - EnAm_SetupLunge(this); - } else { - EnAm_SetupRecoilFromDamage(this, globalCtx); - } - } -} - -void EnAm_Ricochet(EnAm* this, GlobalContext* globalCtx) { - if (this->dyna.actor.speedXZ < 0.0f) { - this->dyna.actor.speedXZ += 0.5f; - } - - if ((this->dyna.actor.velocity.y <= 0.0f) && - !EnAm_CanMove(this, globalCtx, this->dyna.actor.speedXZ * 1.5f, this->dyna.actor.world.rot.y)) { - this->dyna.actor.speedXZ = 0.0f; - } - - if (SkelAnime_Update(&this->skelAnime)) { - this->dyna.actor.speedXZ = 0.0f; - EnAm_SetupLunge(this); - } -} - -void EnAm_TransformSwordHitbox(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f D_809B0074 = { 2500.0f, 7000.0f, 0.0f }; - static Vec3f D_809B0080 = { -2500.0f, 0.0f, 0.0f }; - static Vec3f D_809B008C = { 2500.0f, 7000.0f, 4000.0f }; - static Vec3f D_809B0098 = { -2500.0f, 0.0f, 4000.0f }; - EnAm* this = (EnAm*)thisx; - - Matrix_MultVec3f(&D_809B0074, &this->hitCollider.dim.quad[1]); - Matrix_MultVec3f(&D_809B0080, &this->hitCollider.dim.quad[0]); - Matrix_MultVec3f(&D_809B008C, &this->hitCollider.dim.quad[3]); - Matrix_MultVec3f(&D_809B0098, &this->hitCollider.dim.quad[2]); - - Collider_SetQuadVertices(&this->hitCollider, &this->hitCollider.dim.quad[0], &this->hitCollider.dim.quad[1], - &this->hitCollider.dim.quad[2], &this->hitCollider.dim.quad[3]); -} - -void EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f sparkPos; - - if (this->deathTimer == 0) { - if (this->blockCollider.base.acFlags & AC_BOUNCED) { - this->blockCollider.base.acFlags &= ~(AC_HIT | AC_BOUNCED); - this->hurtCollider.base.acFlags &= ~AC_HIT; - - if (this->behavior >= AM_BEHAVIOR_5) { - EnAm_SetupRicochet(this, globalCtx); - } - } else if ((this->hurtCollider.base.acFlags & AC_HIT) && (this->behavior >= AM_BEHAVIOR_5)) { - this->hurtCollider.base.acFlags &= ~AC_HIT; - - if (this->dyna.actor.colChkInfo.damageEffect != AM_DMGEFF_MAGIC_FIRE_LIGHT) { - this->unk_264 = 0; - this->damageEffect = this->dyna.actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->dyna.actor, &this->hurtCollider.info, 0); - - if ((this->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_NUT) || - (this->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_STUN) || - (this->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_ICE)) { - if (this->behavior != AM_BEHAVIOR_STUNNED) { - EnAm_SetupStunned(this, globalCtx); - - if (this->dyna.actor.colChkInfo.damage != 0) { - this->dyna.actor.colChkInfo.health = 0; - } - } else if (this->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_STUN) { - sparkPos = this->dyna.actor.world.pos; - sparkPos.y += 50.0f; - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sparkPos); - } - } else if ((this->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_KILL) || - (this->behavior == AM_BEHAVIOR_STUNNED)) { - this->dyna.actor.colChkInfo.health = 0; - - EnAm_SetupRecoilFromDamage(this, globalCtx); - } else { - EnAm_SetupRicochet(this, globalCtx); - } - } - } - } -} - -void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - static Color_RGBA8 dustPrimColor = { 150, 150, 150, 255 }; - static Color_RGBA8 dustEnvColor = { 100, 100, 100, 150 }; - s32 pad; - EnAm* this = (EnAm*)thisx; - EnBom* bomb; - Vec3f dustPos; - s32 i; - f32 dustPosScale; - s32 pad1; - - if (this->dyna.actor.params != ARMOS_STATUE) { - EnAm_UpdateDamage(this, globalCtx); - } - - if (this->dyna.actor.colChkInfo.damageEffect != AM_DMGEFF_MAGIC_FIRE_LIGHT) { - if (this->attackTimer != 0) { - this->attackTimer--; - } - - this->actionFunc(this, globalCtx); - - if (this->deathTimer != 0) { - this->deathTimer--; - - if (this->deathTimer == 0) { - dustPosScale = globalCtx->gameplayFrames * 10; - - EnAm_SpawnEffects(this, globalCtx); - bomb = - (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 2, BOMB_BODY); - if (bomb != NULL) { - bomb->timer = 0; - } - - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_AMOS_DEAD); - Item_DropCollectibleRandom(globalCtx, &this->dyna.actor, &this->dyna.actor.world.pos, 0xA0); - - for (i = 9; i >= 0; i--) { - dustPos.x = (sinf(dustPosScale) * 7.0f) + this->dyna.actor.world.pos.x; - dustPos.y = (Rand_CenteredFloat(10.0f) * 6.0f) + (this->dyna.actor.world.pos.y + 40.0f); - dustPos.z = (cosf(dustPosScale) * 7.0f) + this->dyna.actor.world.pos.z; - - func_8002836C(globalCtx, &dustPos, &zeroVec, &zeroVec, &dustPrimColor, &dustEnvColor, 200, 45, 12); - dustPosScale += 60.0f; - } - - Actor_Kill(&this->dyna.actor); - return; - } - - if ((this->deathTimer % 4) == 0) { - Actor_SetColorFilter(&this->dyna.actor, 0x4000, 255, 0, 4); - } - } - - Actor_MoveForward(&this->dyna.actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 28.0f, 80.0f, 0x1D); - } - - Collider_UpdateCylinder(&this->dyna.actor, &this->hurtCollider); - Collider_UpdateCylinder(&this->dyna.actor, &this->blockCollider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->hurtCollider.base); - - if (this->dyna.actor.params != ARMOS_STATUE) { - Actor_SetFocus(&this->dyna.actor, this->dyna.actor.scale.x * 4500.0f); - - if (this->dyna.actor.colorFilterTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->blockCollider.base); - } - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->hurtCollider.base); - - if ((this->behavior >= 4) && (this->unk_264 > 0)) { - if (!(this->hitCollider.base.atFlags & AT_BOUNCED)) { - if (this->hitCollider.base.atFlags & AT_HIT) { - Player* player = GET_PLAYER(globalCtx); - - if (this->hitCollider.base.at == &player->actor) { - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->hitCollider.base); - } else { - this->hitCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); - this->hitCollider.base.at = NULL; - EnAm_SetupRicochet(this, globalCtx); - } - } - } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->blockCollider.base); - } -} - -static Vec3f sUnused1 = { 1100.0f, -700.0f, 0.0f }; -static Vec3f sUnused2 = { 0.0f, 0.0f, 0.0f }; - -void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnAm* this = (EnAm*)thisx; - - if ((limbIndex == 1) && (this->unk_264 != 0)) { - EnAm_TransformSwordHitbox(&this->dyna.actor, globalCtx); - } -} - -static Vec3f sIcePosOffsets[] = { - { 20.0f, 40.0f, 0.0f }, { 10.0f, 60.0f, 10.0f }, { -10.0f, 60.0f, 10.0f }, { -20.0f, 40.0f, 0.0f }, - { 10.0f, 60.0f, -10.0f }, { -10.0f, 60.0f, -10.0f }, { 0.0f, 40.0f, -20.0f }, { 10.0f, 20.0f, 10.0f }, - { 10.0f, 20.0f, -10.0f }, { 0.0f, 40.0f, 20.0f }, { -10.0f, 20.0f, 10.0f }, { -10.0f, 20.0f, -10.0f }, -}; - -void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - Vec3f sp68; - EnAm* this = (EnAm*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_am.c", 1580); - - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->textureBlend); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, this); - - if (this->iceTimer != 0) { - this->dyna.actor.colorFilterTimer++; - if (1) {}; - this->iceTimer--; - - if ((this->iceTimer % 4) == 0) { - s32 index; - - index = this->iceTimer >> 2; - - sp68.x = this->dyna.actor.world.pos.x + sIcePosOffsets[index].x; - sp68.y = this->dyna.actor.world.pos.y + sIcePosOffsets[index].y; - sp68.z = this->dyna.actor.world.pos.z + sIcePosOffsets[index].z; - - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->dyna.actor, &sp68, 150, 150, 150, 250, 235, 245, 255, - 1.4f); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_am.c", 1605); -} diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.cpp b/src/overlays/actors/ovl_En_Am/z_en_am.cpp new file mode 100644 index 000000000..6bcbb7bb7 --- /dev/null +++ b/src/overlays/actors/ovl_En_Am/z_en_am.cpp @@ -0,0 +1,989 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_AM_Z_EN_AM_C +#include "actor_common.h" +/* + * File: z_en_am.c + * Overlay: ovl_En_Am + * Description: Armos + */ + +#include "z_en_am.h" +#include "objects/object_am/object_am.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "def/code_80043480.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_26) + +void EnAm_Init(Actor* thisx, GlobalContext* globalCtx); +void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnAm_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnAm_SetupStatue(EnAm* pthis); +void EnAm_SetupSleep(EnAm* pthis); +void EnAm_Statue(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_Sleep(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_Lunge(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_RotateToHome(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_MoveToHome(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_RotateToInit(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_Cooldown(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_Ricochet(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_Stunned(EnAm* pthis, GlobalContext* globalCtx); +void EnAm_RecoilFromDamage(EnAm* pthis, GlobalContext* globalCtx); + +typedef enum { + /* 00 */ AM_BEHAVIOR_NONE, + /* 01 */ AM_BEHAVIOR_DAMAGED, + /* 03 */ AM_BEHAVIOR_DO_NOTHING = 3, + /* 05 */ AM_BEHAVIOR_5 = 5, // checked but never set + /* 06 */ AM_BEHAVIOR_STUNNED, + /* 07 */ AM_BEHAVIOR_GO_HOME, + /* 08 */ AM_BEHAVIOR_RICOCHET, + /* 10 */ AM_BEHAVIOR_AGGRO = 10 +} ArmosBehavior; + +ActorInit En_Am_InitVars = { + ACTOR_EN_AM, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_AM, + sizeof(EnAm), + (ActorFunc)EnAm_Init, + (ActorFunc)EnAm_Destroy, + (ActorFunc)EnAm_Update, + (ActorFunc)EnAm_Draw, +}; + +static ColliderCylinderInit sHurtCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 15, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sBlockCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00400106, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 15, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +typedef enum { + /* 00 */ AM_DMGEFF_NONE, // used by anything that cant kill the armos + /* 01 */ AM_DMGEFF_NUT, + /* 06 */ AM_DMGEFF_STUN = 6, // doesnt include deku nuts + /* 13 */ AM_DMGEFF_ICE = 13, + /* 14 */ AM_DMGEFF_MAGIC_FIRE_LIGHT, + /* 15 */ AM_DMGEFF_KILL // any damage source that can kill the armos (and isnt a special case) +} ArmosDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, AM_DMGEFF_NUT), + /* Deku stick */ DMG_ENTRY(2, AM_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(1, AM_DMGEFF_NONE), + /* Explosive */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Boomerang */ DMG_ENTRY(0, AM_DMGEFF_STUN), + /* Normal arrow */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Hammer swing */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Hookshot */ DMG_ENTRY(0, AM_DMGEFF_STUN), + /* Kokiri sword */ DMG_ENTRY(1, AM_DMGEFF_NONE), + /* Master sword */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Giant's Knife */ DMG_ENTRY(4, AM_DMGEFF_KILL), + /* Fire arrow */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Ice arrow */ DMG_ENTRY(4, AM_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Unk arrow 1 */ DMG_ENTRY(2, AM_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(2, AM_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(2, AM_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(0, AM_DMGEFF_MAGIC_FIRE_LIGHT), + /* Ice magic */ DMG_ENTRY(3, AM_DMGEFF_ICE), + /* Light magic */ DMG_ENTRY(0, AM_DMGEFF_MAGIC_FIRE_LIGHT), + /* Shield */ DMG_ENTRY(0, AM_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, AM_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, AM_DMGEFF_NONE), + /* Giant spin */ DMG_ENTRY(4, AM_DMGEFF_KILL), + /* Master spin */ DMG_ENTRY(2, AM_DMGEFF_KILL), + /* Kokiri jump */ DMG_ENTRY(2, AM_DMGEFF_NONE), + /* Giant jump */ DMG_ENTRY(8, AM_DMGEFF_KILL), + /* Master jump */ DMG_ENTRY(4, AM_DMGEFF_KILL), + /* Unknown 1 */ DMG_ENTRY(0, AM_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, AM_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, AM_DMGEFF_KILL), + /* Unknown 2 */ DMG_ENTRY(0, AM_DMGEFF_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x13, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 5300, ICHAIN_STOP), +}; + +void EnAm_SetupAction(EnAm* pthis, EnAmActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +/** + * Checks bgCheckFlags in the direction of current yaw at the specified distance. + * + * Returns true if the armos would land on the ground in the resulting position. + * + * If it won't land on the ground, it will return true anyway if the floor the armos will be on + * is no more than 20 units lower than the home position. This prevents the armos from going down steep slopes. + */ +s32 EnAm_CanMove(EnAm* pthis, GlobalContext* globalCtx, f32 distance, s16 yaw) { + s16 ret; + s16 curBgCheckFlags; + f32 sin; + f32 cos; + Vec3f curPos; + + // save current position and bgCheckFlags to restore later + curPos = pthis->dyna.actor.world.pos; + curBgCheckFlags = pthis->dyna.actor.bgCheckFlags; + + sin = Math_SinS(yaw) * distance; + cos = Math_CosS(yaw) * distance; + + pthis->dyna.actor.world.pos.x += sin; + pthis->dyna.actor.world.pos.z += cos; + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + pthis->dyna.actor.world.pos = curPos; + ret = pthis->dyna.actor.bgCheckFlags & 1; + + if (!ret && (pthis->dyna.actor.floorHeight >= (pthis->dyna.actor.home.pos.y - 20.0f))) { + ret = true; + } + + pthis->dyna.actor.bgCheckFlags = curBgCheckFlags; + + return ret; +} + +void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { + CollisionHeader* colHeader = NULL; + s32 pad; + EnAm* pthis = (EnAm*)thisx; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gArmosSkel, &gArmosRicochetAnim, pthis->jointTable, pthis->morphTable, + 14); + Actor_SetScale(&pthis->dyna.actor, 0.01f); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + Collider_InitCylinder(globalCtx, &pthis->hurtCollider); + Collider_InitCylinder(globalCtx, &pthis->blockCollider); + Collider_SetCylinder(globalCtx, &pthis->hurtCollider, &pthis->dyna.actor, &sHurtCylinderInit); + + if (pthis->dyna.actor.params == ARMOS_STATUE) { + pthis->dyna.actor.colChkInfo.health = 1; + Collider_SetCylinder(globalCtx, &pthis->blockCollider, &pthis->dyna.actor, &sHurtCylinderInit); + pthis->hurtCollider.base.ocFlags1 = (OC1_ON | OC1_NO_PUSH | OC1_TYPE_1 | OC1_TYPE_2); + pthis->blockCollider.base.ocFlags1 = (OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER); + CollisionHeader_GetVirtual(&gArmosCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->dyna.actor, ACTORCAT_BG); + EnAm_SetupStatue(pthis); + } else { + Collider_SetCylinder(globalCtx, &pthis->blockCollider, &pthis->dyna.actor, &sBlockCylinderInit); + Collider_InitQuad(globalCtx, &pthis->hitCollider); + Collider_SetQuad(globalCtx, &pthis->hitCollider, &pthis->dyna.actor, &sQuadInit); + pthis->dyna.actor.colChkInfo.health = 1; + pthis->dyna.actor.colChkInfo.damageTable = &sDamageTable; + EnAm_SetupSleep(pthis); + pthis->unk_258 = 0; + } + + pthis->dyna.actor.colChkInfo.mass = MASS_HEAVY; +} + +void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAm* pthis = (EnAm*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->hurtCollider); + Collider_DestroyCylinder(globalCtx, &pthis->blockCollider); + //! @bug Quad collider is not destroyed (though destroy doesnt really do anything anyway) +} + +void EnAm_SpawnEffects(EnAm* pthis, GlobalContext* globalCtx) { + static Vec3f velocity = { 0.0f, -1.5f, 0.0f }; + static Vec3f accel = { 0.0f, -0.2f, 0.0f }; + s32 i; + Vec3f pos; + Color_RGBA8 primColor = { 100, 100, 100, 0 }; + Color_RGBA8 envColor = { 40, 40, 40, 0 }; + s32 pad; + + for (i = 4; i > 0; i--) { + pos.x = pthis->dyna.actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 65.0f); + pos.y = (pthis->dyna.actor.world.pos.y + 40.0f) + ((Rand_ZeroOne() - 0.5f) * 10.0f); + pos.z = pthis->dyna.actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 65.0f); + + EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &velocity, &accel, &primColor, &envColor); + } + + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_AMOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &pthis->dyna.actor, &pthis->dyna.actor.world.pos, 4.0f, 3, 8.0f, 0x12C, 0xF, 0); +} + +void EnAm_SetupSleep(EnAm* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gArmosRicochetAnim); + + Animation_Change(&pthis->skelAnime, &gArmosRicochetAnim, 0.0f, lastFrame, lastFrame, ANIMMODE_LOOP, 0.0f); + pthis->behavior = AM_BEHAVIOR_DO_NOTHING; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->unk_258 = (pthis->textureBlend == 255) ? 0 : 1; + EnAm_SetupAction(pthis, EnAm_Sleep); +} + +void EnAm_SetupStatue(EnAm* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gArmosRicochetAnim); + + Animation_Change(&pthis->skelAnime, &gArmosRicochetAnim, 0.0f, lastFrame, lastFrame, ANIMMODE_LOOP, 0.0f); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_0; + pthis->behavior = AM_BEHAVIOR_DO_NOTHING; + pthis->dyna.actor.speedXZ = 0.0f; + EnAm_SetupAction(pthis, EnAm_Statue); +} + +void EnAm_SetupLunge(EnAm* pthis) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gArmosHopAnim, 4.0f); + pthis->unk_258 = 3; + pthis->behavior = AM_BEHAVIOR_AGGRO; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.shape.rot.y; + EnAm_SetupAction(pthis, EnAm_Lunge); +} + +void EnAm_SetupCooldown(EnAm* pthis) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gArmosHopAnim, 4.0f); + pthis->unk_258 = 3; + pthis->cooldownTimer = 40; + pthis->behavior = AM_BEHAVIOR_AGGRO; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.shape.rot.y; + EnAm_SetupAction(pthis, EnAm_Cooldown); +} + +void EnAm_SetupMoveToHome(EnAm* pthis) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gArmosHopAnim, 4.0f); + pthis->behavior = AM_BEHAVIOR_GO_HOME; + pthis->unk_258 = 1; + pthis->dyna.actor.speedXZ = 0.0f; + EnAm_SetupAction(pthis, EnAm_MoveToHome); +} + +void EnAm_SetupRotateToInit(EnAm* pthis) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gArmosHopAnim, 4.0f); + pthis->behavior = AM_BEHAVIOR_GO_HOME; + pthis->unk_258 = 1; + pthis->dyna.actor.speedXZ = 0.0f; + EnAm_SetupAction(pthis, EnAm_RotateToInit); +} + +void EnAm_SetupRotateToHome(EnAm* pthis) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gArmosHopAnim, 4.0f); + pthis->behavior = AM_BEHAVIOR_GO_HOME; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.shape.rot.y; + EnAm_SetupAction(pthis, EnAm_RotateToHome); +} + +void EnAm_SetupRecoilFromDamage(EnAm* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gArmosDamagedAnim, 1.0f, 4.0f, + Animation_GetLastFrame(&gArmosDamagedAnim) - 6.0f, ANIMMODE_ONCE, 0.0f); + pthis->behavior = AM_BEHAVIOR_DAMAGED; + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.yawTowardsPlayer; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_AMOS_DAMAGE); + + if (EnAm_CanMove(pthis, globalCtx, -6.0f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = -6.0f; + } + + pthis->dyna.actor.colorFilterTimer = 0; + Enemy_StartFinishingBlow(globalCtx, &pthis->dyna.actor); + EnAm_SetupAction(pthis, EnAm_RecoilFromDamage); +} + +void EnAm_SetupRicochet(EnAm* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gArmosRicochetAnim, 1.0f, 0.0f, 8.0f, ANIMMODE_ONCE, 0.0f); + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.yawTowardsPlayer; + + if (EnAm_CanMove(pthis, globalCtx, -6.0f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = -6.0f; + } + + pthis->unk_264 = 0; + pthis->unk_258 = 0; + pthis->cooldownTimer = 5; + pthis->behavior = AM_BEHAVIOR_RICOCHET; + EnAm_SetupAction(pthis, EnAm_Ricochet); +} + +void EnAm_Sleep(EnAm* pthis, GlobalContext* globalCtx) { + f32 cos; + s32 pad; + f32 rand; + f32 sin; + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->unk_258 != 0) || + ((pthis->hurtCollider.base.ocFlags1 & OC1_HIT) && (pthis->hurtCollider.base.oc == &player->actor)) || + (pthis->hurtCollider.base.acFlags & AC_HIT)) { + pthis->hurtCollider.base.acFlags &= ~AC_HIT; + + if (pthis->textureBlend == 0) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_AMOS_WAVE); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_AMOS_VOICE); + Actor_SetColorFilter(&pthis->dyna.actor, 0x4000, 255, 0, 8); + } + + if (pthis->textureBlend >= 240) { + pthis->attackTimer = 200; + pthis->textureBlend = 255; + pthis->dyna.actor.flags |= ACTOR_FLAG_0; + pthis->dyna.actor.shape.yOffset = 0.0f; + EnAm_SetupLunge(pthis); + } else { + // shake randomly about the origin while waking up + rand = (Rand_ZeroOne() - 0.5f) * 10.0f; + + cos = Math_CosS(pthis->dyna.actor.shape.rot.y) * rand; + sin = Math_SinS(pthis->dyna.actor.shape.rot.y) * rand; + + pthis->dyna.actor.world.pos.x = pthis->shakeOrigin.x + cos; + pthis->dyna.actor.world.pos.z = pthis->shakeOrigin.z + sin; + + pthis->textureBlend += 20; + pthis->unk_258 = 1; + } + } else { + if (pthis->textureBlend > 10) { + pthis->textureBlend -= 10; + } else { + pthis->textureBlend = 0; + pthis->dyna.actor.flags &= ~ACTOR_FLAG_0; + + if (pthis->dyna.bgId < 0) { + pthis->unk_264 = 0; + } + + pthis->dyna.actor.speedXZ += pthis->dyna.unk_150; + pthis->shakeOrigin = pthis->dyna.actor.world.pos; + pthis->dyna.actor.world.rot.y = pthis->dyna.unk_158; + pthis->dyna.actor.speedXZ = CLAMP(pthis->dyna.actor.speedXZ, -2.5f, 2.5f); + Math_SmoothStepToF(&pthis->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + + if (pthis->dyna.actor.speedXZ != 0.0f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } + + pthis->dyna.unk_154 = 0.0f; + pthis->dyna.unk_150 = 0.0f; + } + } +} + +/** + * Spin toward the direction of the home position to start moving back to it. + */ +void EnAm_RotateToHome(EnAm* pthis, GlobalContext* globalCtx) { + s16 yawToHome = Math_Vec3f_Yaw(&pthis->dyna.actor.world.pos, &pthis->dyna.actor.home.pos); + + if (pthis->skelAnime.curFrame == 8.0f) { + Math_SmoothStepToS(&pthis->dyna.actor.world.rot.y, yawToHome, 1, 0x1F40, 0); + pthis->dyna.actor.velocity.y = 12.0f; + } else if (pthis->skelAnime.curFrame > 11.0f) { + if (!(pthis->dyna.actor.bgCheckFlags & 1)) { + pthis->skelAnime.curFrame = 11; + } else { + EnAm_SpawnEffects(pthis, globalCtx); + + if (pthis->dyna.actor.world.rot.y == yawToHome) { + pthis->unk_258 = 0; + } + + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + } + } + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_258 == 0) { + EnAm_SetupMoveToHome(pthis); + } + + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y; +} + +/** + * After reaching the home position, spin back to the starting rotation. + */ +void EnAm_RotateToInit(EnAm* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame == 8.0f) { + if ((pthis->dyna.actor.world.pos.x == pthis->dyna.actor.home.pos.x) && + (pthis->dyna.actor.world.pos.z == pthis->dyna.actor.home.pos.z)) { + Math_SmoothStepToS(&pthis->dyna.actor.world.rot.y, pthis->dyna.actor.home.rot.y, 1, 0x1F40, 0); + } + pthis->unk_258 = 2; + pthis->dyna.actor.velocity.y = 12.0f; + } else if (pthis->skelAnime.curFrame > 11.0f) { + if (!(pthis->dyna.actor.bgCheckFlags & 1)) { + pthis->skelAnime.curFrame = 11; + } else { + pthis->unk_258 = 1; + EnAm_SpawnEffects(pthis, globalCtx); + + if (pthis->dyna.actor.home.rot.y == pthis->dyna.actor.world.rot.y) { + pthis->unk_258 = 0; + } + + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + } + } + + if (pthis->unk_258 == 2) { + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.x, pthis->dyna.actor.home.pos.x, 1.0f, 8.0f, 0.0f); + Math_SmoothStepToF(&pthis->dyna.actor.world.pos.z, pthis->dyna.actor.home.pos.z, 1.0f, 8.0f, 0.0f); + } + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_258 == 0) { + EnAm_SetupSleep(pthis); + } + + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y; +} + +void EnAm_MoveToHome(EnAm* pthis, GlobalContext* globalCtx) { + s16 yawToHome = Math_Vec3f_Yaw(&pthis->dyna.actor.world.pos, &pthis->dyna.actor.home.pos); + + if (pthis->skelAnime.curFrame == 8.0f) { + pthis->dyna.actor.velocity.y = 12.0f; + pthis->dyna.actor.speedXZ = 6.0f; + } else if (pthis->skelAnime.curFrame > 11.0f) { + if (!(pthis->dyna.actor.bgCheckFlags & 1)) { + pthis->skelAnime.curFrame = 11; + } else { + Math_SmoothStepToS(&pthis->dyna.actor.world.rot.y, yawToHome, 1, 0xBB8, 0); + + if (pthis->dyna.actor.bgCheckFlags & 2) { + pthis->unk_258--; + } + + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + EnAm_SpawnEffects(pthis, globalCtx); + + if (Actor_WorldDistXYZToPoint(&pthis->dyna.actor, &pthis->dyna.actor.home.pos) < 80.0f) { + EnAm_SetupRotateToInit(pthis); + } + } + } + + // turn away from a wall if touching one + if ((pthis->dyna.actor.speedXZ != 0.0f) && (pthis->dyna.actor.bgCheckFlags & 8)) { + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.wallYaw; + Actor_MoveForward(&pthis->dyna.actor); + } + + SkelAnime_Update(&pthis->skelAnime); + + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y; +} + +void EnAm_RecoilFromDamage(EnAm* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.speedXZ < 0.0f) { + pthis->dyna.actor.speedXZ += 0.5f; + } + + if ((pthis->dyna.actor.velocity.y <= 0.0f) && !EnAm_CanMove(pthis, globalCtx, -8.0f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + EnAm_SetupLunge(pthis); + pthis->deathTimer = 64; + pthis->panicSpinRot = 0; + } +} + +/** + * After doing 3 lunges, wait for 2 seconds before attacking again. + * Turn toward the player before lunging again. + */ +void EnAm_Cooldown(EnAm* pthis, GlobalContext* globalCtx) { + s16 yawDiff = pthis->dyna.actor.yawTowardsPlayer - pthis->dyna.actor.world.rot.y; + + yawDiff = ABS(yawDiff); + + if (pthis->cooldownTimer != 0) { + pthis->cooldownTimer--; + } else { + if (pthis->skelAnime.curFrame == 8.0f) { + Math_SmoothStepToS(&pthis->dyna.actor.world.rot.y, pthis->dyna.actor.yawTowardsPlayer, 1, 0x1F40, 0); + pthis->dyna.actor.velocity.y = 12.0f; + } else if (pthis->skelAnime.curFrame > 11.0f) { + if (!(pthis->dyna.actor.bgCheckFlags & 1)) { + pthis->skelAnime.curFrame = 11; + } else { + if (yawDiff < 3500) { + pthis->unk_258 = 0; + } + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + EnAm_SpawnEffects(pthis, globalCtx); + } + } + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_258 == 0) { + EnAm_SetupLunge(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_AMOS_VOICE); + } + + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y; + } +} + +/** + * Lunge toward the player in an attempt to deal damage. Hop 3 times. + * Used for both normal attacks and the death sequence. + */ +void EnAm_Lunge(EnAm* pthis, GlobalContext* globalCtx) { + if (pthis->deathTimer < 52) { + if (pthis->skelAnime.curFrame == 8.0f) { + pthis->dyna.actor.velocity.y = 12.0f; + + if (EnAm_CanMove(pthis, globalCtx, 80.0f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = 6.0f; + } else { + pthis->dyna.actor.speedXZ = 0.0f; + } + + pthis->unk_264 = 1; + pthis->hitCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + } else if (pthis->skelAnime.curFrame > 11.0f) { + if (!(pthis->dyna.actor.bgCheckFlags & 1)) { + pthis->skelAnime.curFrame = 11; + } else { + Math_SmoothStepToS(&pthis->dyna.actor.world.rot.y, pthis->dyna.actor.yawTowardsPlayer, 1, 0x1770, 0); + + if (pthis->dyna.actor.bgCheckFlags & 2) { + pthis->unk_258--; + } + + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->unk_264 = 0; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + EnAm_SpawnEffects(pthis, globalCtx); + + if (((Actor_WorldDistXZToPoint(&pthis->dyna.actor, &pthis->dyna.actor.home.pos) > 240.0f) || + (pthis->attackTimer == 0)) && + (pthis->deathTimer == 0)) { + EnAm_SetupRotateToHome(pthis); + } + } + } + + // turn and move away from a wall if contact is made with one + if ((pthis->dyna.actor.speedXZ != 0.0f) && (pthis->dyna.actor.bgCheckFlags & 8)) { + pthis->dyna.actor.world.rot.y = + (pthis->dyna.actor.wallYaw - pthis->dyna.actor.world.rot.y) + pthis->dyna.actor.wallYaw; + Actor_MoveForward(&pthis->dyna.actor); + pthis->dyna.actor.bgCheckFlags &= ~8; + } + + SkelAnime_Update(&pthis->skelAnime); + + if ((pthis->unk_258 == 0) && (pthis->deathTimer == 0)) { + EnAm_SetupCooldown(pthis); + } + + if (pthis->deathTimer == 0) { + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.world.rot.y; + } else { + if (pthis->panicSpinRot < 8000) { + pthis->panicSpinRot += 800; + } + pthis->dyna.actor.shape.rot.y += pthis->panicSpinRot; + } + } +} + +void EnAm_Statue(EnAm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp158f = pthis->dyna.unk_158; + s16 moveDir = 0; + + if (pthis->unk_258 == 0) { + if (pthis->dyna.unk_150 != 0.0f) { + pthis->unk_258 = 0x8000; + } + } else { + pthis->unk_258 -= 0x800; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + + if (pthis->dyna.unk_150 < 0.0f) { + temp158f = pthis->dyna.unk_158 + 0x8000; + } + + if (pthis->hurtCollider.base.ocFlags1 & OC1_HIT) { + moveDir = Math_Vec3f_Yaw(&pthis->dyna.actor.world.pos, &pthis->hurtCollider.base.oc->world.pos) - temp158f; + } + + if ((pthis->dyna.unk_150 == 0.0f) || (pthis->unk_258 == 0) || !(pthis->dyna.actor.bgCheckFlags & 1) || + !func_800435D8(globalCtx, &pthis->dyna, 0x14, + (Math_SinS(pthis->unk_258) * (pthis->dyna.unk_150 * 0.5f)) + 40.0f, 0xA) || + ((pthis->hurtCollider.base.ocFlags1 & OC1_HIT) && (ABS(moveDir) <= 0x2000))) { + + pthis->unk_258 = 0; + player->stateFlags2 &= ~0x151; + player->actor.speedXZ = 0.0f; + pthis->dyna.unk_150 = pthis->dyna.unk_154 = 0.0f; + } + + pthis->dyna.actor.world.rot.y = pthis->dyna.unk_158; + pthis->dyna.actor.speedXZ = Math_SinS(pthis->unk_258) * (pthis->dyna.unk_150 * 0.5f); + } + + if (pthis->dyna.actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + + pthis->dyna.unk_150 = pthis->dyna.unk_154 = 0.0f; +} + +void EnAm_SetupStunned(EnAm* pthis, GlobalContext* globalCtx) { + // animation is set but SkelAnime_Update is not called in the action + // likely copy pasted from EnAm_SetupRecoilFromDamage + Animation_Change(&pthis->skelAnime, &gArmosDamagedAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gArmosDamagedAnim), + ANIMMODE_ONCE, 0.0f); + + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.yawTowardsPlayer; + + if (EnAm_CanMove(pthis, globalCtx, -6.0f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = -6.0f; + } + + Actor_SetColorFilter(&pthis->dyna.actor, 0, 120, 0, 100); + + if (pthis->damageEffect == AM_DMGEFF_ICE) { + pthis->iceTimer = 48; + } + + pthis->behavior = AM_BEHAVIOR_STUNNED; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_GOMA_JR_FREEZE); + EnAm_SetupAction(pthis, EnAm_Stunned); +} + +void EnAm_Stunned(EnAm* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->dyna.actor.shape.rot.y, pthis->dyna.actor.world.rot.y, 1, 0xFA0, 0); + + if (pthis->dyna.actor.speedXZ < 0.0f) { + pthis->dyna.actor.speedXZ += 0.5f; + } + + if ((pthis->dyna.actor.velocity.y <= 0.0f) && !EnAm_CanMove(pthis, globalCtx, -9.0f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = 0.0f; + } + + if (pthis->dyna.actor.colorFilterTimer == 0) { + if (pthis->dyna.actor.colChkInfo.health != 0) { + EnAm_SetupLunge(pthis); + } else { + EnAm_SetupRecoilFromDamage(pthis, globalCtx); + } + } +} + +void EnAm_Ricochet(EnAm* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.speedXZ < 0.0f) { + pthis->dyna.actor.speedXZ += 0.5f; + } + + if ((pthis->dyna.actor.velocity.y <= 0.0f) && + !EnAm_CanMove(pthis, globalCtx, pthis->dyna.actor.speedXZ * 1.5f, pthis->dyna.actor.world.rot.y)) { + pthis->dyna.actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->dyna.actor.speedXZ = 0.0f; + EnAm_SetupLunge(pthis); + } +} + +void EnAm_TransformSwordHitbox(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_809B0074 = { 2500.0f, 7000.0f, 0.0f }; + static Vec3f D_809B0080 = { -2500.0f, 0.0f, 0.0f }; + static Vec3f D_809B008C = { 2500.0f, 7000.0f, 4000.0f }; + static Vec3f D_809B0098 = { -2500.0f, 0.0f, 4000.0f }; + EnAm* pthis = (EnAm*)thisx; + + Matrix_MultVec3f(&D_809B0074, &pthis->hitCollider.dim.quad[1]); + Matrix_MultVec3f(&D_809B0080, &pthis->hitCollider.dim.quad[0]); + Matrix_MultVec3f(&D_809B008C, &pthis->hitCollider.dim.quad[3]); + Matrix_MultVec3f(&D_809B0098, &pthis->hitCollider.dim.quad[2]); + + Collider_SetQuadVertices(&pthis->hitCollider, &pthis->hitCollider.dim.quad[0], &pthis->hitCollider.dim.quad[1], + &pthis->hitCollider.dim.quad[2], &pthis->hitCollider.dim.quad[3]); +} + +void EnAm_UpdateDamage(EnAm* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f sparkPos; + + if (pthis->deathTimer == 0) { + if (pthis->blockCollider.base.acFlags & AC_BOUNCED) { + pthis->blockCollider.base.acFlags &= ~(AC_HIT | AC_BOUNCED); + pthis->hurtCollider.base.acFlags &= ~AC_HIT; + + if (pthis->behavior >= AM_BEHAVIOR_5) { + EnAm_SetupRicochet(pthis, globalCtx); + } + } else if ((pthis->hurtCollider.base.acFlags & AC_HIT) && (pthis->behavior >= AM_BEHAVIOR_5)) { + pthis->hurtCollider.base.acFlags &= ~AC_HIT; + + if (pthis->dyna.actor.colChkInfo.damageEffect != AM_DMGEFF_MAGIC_FIRE_LIGHT) { + pthis->unk_264 = 0; + pthis->damageEffect = pthis->dyna.actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->dyna.actor, &pthis->hurtCollider.info, 0); + + if ((pthis->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_NUT) || + (pthis->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_STUN) || + (pthis->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_ICE)) { + if (pthis->behavior != AM_BEHAVIOR_STUNNED) { + EnAm_SetupStunned(pthis, globalCtx); + + if (pthis->dyna.actor.colChkInfo.damage != 0) { + pthis->dyna.actor.colChkInfo.health = 0; + } + } else if (pthis->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_STUN) { + sparkPos = pthis->dyna.actor.world.pos; + sparkPos.y += 50.0f; + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sparkPos); + } + } else if ((pthis->dyna.actor.colChkInfo.damageEffect == AM_DMGEFF_KILL) || + (pthis->behavior == AM_BEHAVIOR_STUNNED)) { + pthis->dyna.actor.colChkInfo.health = 0; + + EnAm_SetupRecoilFromDamage(pthis, globalCtx); + } else { + EnAm_SetupRicochet(pthis, globalCtx); + } + } + } + } +} + +void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 dustPrimColor = { 150, 150, 150, 255 }; + static Color_RGBA8 dustEnvColor = { 100, 100, 100, 150 }; + s32 pad; + EnAm* pthis = (EnAm*)thisx; + EnBom* bomb; + Vec3f dustPos; + s32 i; + f32 dustPosScale; + s32 pad1; + + if (pthis->dyna.actor.params != ARMOS_STATUE) { + EnAm_UpdateDamage(pthis, globalCtx); + } + + if (pthis->dyna.actor.colChkInfo.damageEffect != AM_DMGEFF_MAGIC_FIRE_LIGHT) { + if (pthis->attackTimer != 0) { + pthis->attackTimer--; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->deathTimer != 0) { + pthis->deathTimer--; + + if (pthis->deathTimer == 0) { + dustPosScale = globalCtx->gameplayFrames * 10; + + EnAm_SpawnEffects(pthis, globalCtx); + bomb = + (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, 0, 2, BOMB_BODY); + if (bomb != NULL) { + bomb->timer = 0; + } + + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_AMOS_DEAD); + Item_DropCollectibleRandom(globalCtx, &pthis->dyna.actor, &pthis->dyna.actor.world.pos, 0xA0); + + for (i = 9; i >= 0; i--) { + dustPos.x = (sinf(dustPosScale) * 7.0f) + pthis->dyna.actor.world.pos.x; + dustPos.y = (Rand_CenteredFloat(10.0f) * 6.0f) + (pthis->dyna.actor.world.pos.y + 40.0f); + dustPos.z = (cosf(dustPosScale) * 7.0f) + pthis->dyna.actor.world.pos.z; + + func_8002836C(globalCtx, &dustPos, &zeroVec, &zeroVec, &dustPrimColor, &dustEnvColor, 200, 45, 12); + dustPosScale += 60.0f; + } + + Actor_Kill(&pthis->dyna.actor); + return; + } + + if ((pthis->deathTimer % 4) == 0) { + Actor_SetColorFilter(&pthis->dyna.actor, 0x4000, 255, 0, 4); + } + } + + Actor_MoveForward(&pthis->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 20.0f, 28.0f, 80.0f, 0x1D); + } + + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->hurtCollider); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->blockCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->hurtCollider.base); + + if (pthis->dyna.actor.params != ARMOS_STATUE) { + Actor_SetFocus(&pthis->dyna.actor, pthis->dyna.actor.scale.x * 4500.0f); + + if (pthis->dyna.actor.colorFilterTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->blockCollider.base); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->hurtCollider.base); + + if ((pthis->behavior >= 4) && (pthis->unk_264 > 0)) { + if (!(pthis->hitCollider.base.atFlags & AT_BOUNCED)) { + if (pthis->hitCollider.base.atFlags & AT_HIT) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->hitCollider.base.at == &player->actor) { + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + } + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->hitCollider.base); + } else { + pthis->hitCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + pthis->hitCollider.base.at = NULL; + EnAm_SetupRicochet(pthis, globalCtx); + } + } + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->blockCollider.base); + } +} + +static Vec3f sUnused1 = { 1100.0f, -700.0f, 0.0f }; +static Vec3f sUnused2 = { 0.0f, 0.0f, 0.0f }; + +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnAm* pthis = (EnAm*)thisx; + + if ((limbIndex == 1) && (pthis->unk_264 != 0)) { + EnAm_TransformSwordHitbox(&pthis->dyna.actor, globalCtx); + } +} + +static Vec3f sIcePosOffsets[] = { + { 20.0f, 40.0f, 0.0f }, { 10.0f, 60.0f, 10.0f }, { -10.0f, 60.0f, 10.0f }, { -20.0f, 40.0f, 0.0f }, + { 10.0f, 60.0f, -10.0f }, { -10.0f, 60.0f, -10.0f }, { 0.0f, 40.0f, -20.0f }, { 10.0f, 20.0f, 10.0f }, + { 10.0f, 20.0f, -10.0f }, { 0.0f, 40.0f, 20.0f }, { -10.0f, 20.0f, 10.0f }, { -10.0f, 20.0f, -10.0f }, +}; + +void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp68; + EnAm* pthis = (EnAm*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_am.c", 1580); + + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, pthis->textureBlend); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, pthis); + + if (pthis->iceTimer != 0) { + pthis->dyna.actor.colorFilterTimer++; + if (1) {}; + pthis->iceTimer--; + + if ((pthis->iceTimer % 4) == 0) { + s32 index; + + index = pthis->iceTimer >> 2; + + sp68.x = pthis->dyna.actor.world.pos.x + sIcePosOffsets[index].x; + sp68.y = pthis->dyna.actor.world.pos.y + sIcePosOffsets[index].y; + sp68.z = pthis->dyna.actor.world.pos.z + sIcePosOffsets[index].z; + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->dyna.actor, &sp68, 150, 150, 150, 250, 235, 245, 255, + 1.4f); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_am.c", 1605); +} diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c deleted file mode 100644 index 6e0bf56eb..000000000 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ /dev/null @@ -1,341 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANI_Z_EN_ANI_C -#include "actor_common.h" -/* - * File: z_en_ani.c - * Overlay: ovl_En_Ani - * Description: Kakariko Roof Guy - */ - -#include "z_en_ani.h" -#include "objects/object_ani/object_ani.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnAni_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAni_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId); -void func_809B04F0(EnAni* this, GlobalContext* globalCtx); -void func_809B0524(EnAni* this, GlobalContext* globalCtx); -void func_809B0558(EnAni* this, GlobalContext* globalCtx); -void func_809B05F0(EnAni* this, GlobalContext* globalCtx); -void func_809B064C(EnAni* this, GlobalContext* globalCtx); -void func_809B07F8(EnAni* this, GlobalContext* globalCtx); -void func_809B0988(EnAni* this, GlobalContext* globalCtx); -void func_809B0994(EnAni* this, GlobalContext* globalCtx); -void func_809B0A28(EnAni* this, GlobalContext* globalCtx); -void func_809B0A6C(EnAni* this, GlobalContext* globalCtx); - -const ActorInit En_Ani_InitVars = { - ACTOR_EN_ANI, - ACTORCAT_NPC, - FLAGS, - OBJECT_ANI, - sizeof(EnAni), - (ActorFunc)EnAni_Init, - (ActorFunc)EnAni_Destroy, - (ActorFunc)EnAni_Update, - (ActorFunc)EnAni_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0 } }, -}; - -void EnAni_SetupAction(EnAni* this, EnAniActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 850, ICHAIN_STOP), -}; - -void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnAni* this = (EnAni*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, -2800.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRoofManSkel, &gRoofManIdleAnim, this->jointTable, - this->morphTable, 0x10); - Animation_PlayOnce(&this->skelAnime, &gRoofManIdleAnim); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - if (!LINK_IS_ADULT) { - EnAni_SetupAction(this, func_809B064C); - } else { - EnAni_SetupAction(this, func_809B07F8); - } - this->unk_2AA = 0; - this->unk_2A8 = 0; - this->actor.minVelocityY = -1.0f; - this->actor.velocity.y = -1.0f; -} - -void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnAni* this = (EnAni*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId) { - this->actor.textId = textId; - this->unk_2A8 |= 1; - func_8002F2CC(&this->actor, globalCtx, 100.0f); - return 0; -} - -void func_809B04F0(EnAni* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - EnAni_SetupAction(this, func_809B064C); - } -} - -void func_809B0524(EnAni* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - EnAni_SetupAction(this, func_809B07F8); - } -} - -void func_809B0558(EnAni* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - if (!LINK_IS_ADULT) { - EnAni_SetupAction(this, func_809B04F0); - } else { - EnAni_SetupAction(this, func_809B0524); - } - gSaveContext.itemGetInf[1] |= 0x20; - } else { - func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 200.0f); - } -} - -void func_809B05F0(EnAni* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - EnAni_SetupAction(this, func_809B0558); - } - func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 200.0f); -} - -void func_809B064C(EnAni* this, GlobalContext* globalCtx) { - u16 textId; - s16 yawDiff; - u16 textId2; - - textId2 = Text_GetFaceReaction(globalCtx, 0xA); - textId = textId2 & 0xFFFF; - - if (!textId) {} - - if (textId2 == 0) { - textId = !IS_DAY ? 0x5051 : 0x5050; - } - - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->actor.textId == 0x5056) { - EnAni_SetupAction(this, func_809B04F0); - } else if (this->actor.textId == 0x5055) { - EnAni_SetupAction(this, func_809B05F0); - } else { - EnAni_SetupAction(this, func_809B04F0); - } - } else if (yawDiff >= -0x36AF && yawDiff < 0 && this->actor.xzDistToPlayer < 150.0f && - -80.0f < this->actor.yDistToPlayer) { - if (gSaveContext.itemGetInf[1] & 0x20) { - EnAni_SetText(this, globalCtx, 0x5056); - } else { - EnAni_SetText(this, globalCtx, 0x5055); - } - } else if (yawDiff >= -0x3E7 && yawDiff < 0x36B0 && this->actor.xzDistToPlayer < 350.0f) { - EnAni_SetText(this, globalCtx, textId); - } -} - -void func_809B07F8(EnAni* this, GlobalContext* globalCtx) { - s16 pad; - s16 yawDiff; - u16 textId; - - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->actor.textId == 0x5056) { - EnAni_SetupAction(this, func_809B0524); - } else if (this->actor.textId == 0x5055) { - EnAni_SetupAction(this, func_809B05F0); - } else { - EnAni_SetupAction(this, func_809B0524); - } - } else if (yawDiff > -0x36B0 && yawDiff < 0 && this->actor.xzDistToPlayer < 150.0f && - -80.0f < this->actor.yDistToPlayer) { - if (gSaveContext.itemGetInf[1] & 0x20) { - EnAni_SetText(this, globalCtx, 0x5056); - } else { - EnAni_SetText(this, globalCtx, 0x5055); - } - } else if (yawDiff > -0x3E8 && yawDiff < 0x36B0 && this->actor.xzDistToPlayer < 350.0f) { - if (!(gSaveContext.eventChkInf[2] & 0x8000)) { - textId = 0x5052; - } else { - textId = (gSaveContext.itemGetInf[1] & 0x20) ? 0x5054 : 0x5053; - } - EnAni_SetText(this, globalCtx, textId); - } -} - -void func_809B0988(EnAni* this, GlobalContext* globalCtx) { -} - -void func_809B0994(EnAni* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.npcActions[0]->action == 4) { - Animation_Change(&this->skelAnime, &gRoofManGettingUpAfterKnockbackAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gRoofManGettingUpAfterKnockbackAnim), ANIMMODE_ONCE, -4.0f); - this->unk_2AA++; - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - } -} - -void func_809B0A28(EnAni* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_2AA++; - } -} - -void func_809B0A6C(EnAni* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->skelAnime.curFrame = 0.0f; - } - if (globalCtx->csCtx.npcActions[0]->action == 2) { - Animation_Change(&this->skelAnime, &gRoofManKnockbackAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gRoofManKnockbackAnim), ANIMMODE_ONCE, 0.0f); - this->actor.shape.shadowDraw = NULL; - this->unk_2AA++; - } -} - -void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { - EnAni* this = (EnAni*)thisx; - s32 pad[2]; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[0] != NULL)) { - switch (this->unk_2AA) { - case 0: - func_809B0A6C(this, globalCtx); - break; - case 1: - func_809B0A28(this, globalCtx); - break; - case 2: - func_809B0994(this, globalCtx); - break; - case 3: - func_809B0A28(this, globalCtx); - break; - case 4: - func_809B0988(this, globalCtx); - break; - } - - if (globalCtx->csCtx.frames == 100) { - func_800788CC(NA_SE_IT_EARTHQUAKE); - } - } else { - if (SkelAnime_Update(&this->skelAnime) != 0) { - this->skelAnime.curFrame = 0.0f; - } - this->actionFunc(this, globalCtx); - } - - if (this->unk_2A8 & 1) { - func_80038290(globalCtx, &this->actor, &this->unk_29C, &this->unk_2A2, this->actor.focus.pos); - this->unk_2A2.z = 0; - this->unk_2A2.y = this->unk_2A2.z; - this->unk_2A2.x = this->unk_2A2.z; - } else { - Math_SmoothStepToS(&this->unk_29C.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_29C.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.y, 0, 6, 6200, 100); - } - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - this->eyeIndex = this->blinkTimer; - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; - } -} - -s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnAni* this = (EnAni*)thisx; - - if (limbIndex == 15) { - rot->x += this->unk_29C.y; - rot->z += this->unk_29C.x; - } - return false; -} - -void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f sMultVec = { 800.0f, 500.0f, 0.0f }; - EnAni* this = (EnAni*)thisx; - - if (limbIndex == 15) { - Matrix_MultVec3f(&sMultVec, &this->actor.focus.pos); - } -} - -void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { - gRoofManEyeOpenTex, - gRoofManEyeHalfTex, - gRoofManEyeClosedTex, - }; - EnAni* this = (EnAni*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ani.c", 719); - - func_800943C8(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ani.c", 736); -} diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.cpp b/src/overlays/actors/ovl_En_Ani/z_en_ani.cpp new file mode 100644 index 000000000..3514d9568 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.cpp @@ -0,0 +1,341 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANI_Z_EN_ANI_C +#include "actor_common.h" +/* + * File: z_en_ani.c + * Overlay: ovl_En_Ani + * Description: Kakariko Roof Guy + */ + +#include "z_en_ani.h" +#include "objects/object_ani/object_ani.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnAni_Init(Actor* thisx, GlobalContext* globalCtx); +void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnAni_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 EnAni_SetText(EnAni* pthis, GlobalContext* globalCtx, u16 textId); +void func_809B04F0(EnAni* pthis, GlobalContext* globalCtx); +void func_809B0524(EnAni* pthis, GlobalContext* globalCtx); +void func_809B0558(EnAni* pthis, GlobalContext* globalCtx); +void func_809B05F0(EnAni* pthis, GlobalContext* globalCtx); +void func_809B064C(EnAni* pthis, GlobalContext* globalCtx); +void func_809B07F8(EnAni* pthis, GlobalContext* globalCtx); +void func_809B0988(EnAni* pthis, GlobalContext* globalCtx); +void func_809B0994(EnAni* pthis, GlobalContext* globalCtx); +void func_809B0A28(EnAni* pthis, GlobalContext* globalCtx); +void func_809B0A6C(EnAni* pthis, GlobalContext* globalCtx); + +ActorInit En_Ani_InitVars = { + ACTOR_EN_ANI, + ACTORCAT_NPC, + FLAGS, + OBJECT_ANI, + sizeof(EnAni), + (ActorFunc)EnAni_Init, + (ActorFunc)EnAni_Destroy, + (ActorFunc)EnAni_Update, + (ActorFunc)EnAni_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0 } }, +}; + +void EnAni_SetupAction(EnAni* pthis, EnAniActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 850, ICHAIN_STOP), +}; + +void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAni* pthis = (EnAni*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, -2800.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gRoofManSkel, &gRoofManIdleAnim, pthis->jointTable, + pthis->morphTable, 0x10); + Animation_PlayOnce(&pthis->skelAnime, &gRoofManIdleAnim); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + if (!LINK_IS_ADULT) { + EnAni_SetupAction(pthis, func_809B064C); + } else { + EnAni_SetupAction(pthis, func_809B07F8); + } + pthis->unk_2AA = 0; + pthis->unk_2A8 = 0; + pthis->actor.minVelocityY = -1.0f; + pthis->actor.velocity.y = -1.0f; +} + +void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAni* pthis = (EnAni*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 EnAni_SetText(EnAni* pthis, GlobalContext* globalCtx, u16 textId) { + pthis->actor.textId = textId; + pthis->unk_2A8 |= 1; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + return 0; +} + +void func_809B04F0(EnAni* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + EnAni_SetupAction(pthis, func_809B064C); + } +} + +void func_809B0524(EnAni* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + EnAni_SetupAction(pthis, func_809B07F8); + } +} + +void func_809B0558(EnAni* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + if (!LINK_IS_ADULT) { + EnAni_SetupAction(pthis, func_809B04F0); + } else { + EnAni_SetupAction(pthis, func_809B0524); + } + gSaveContext.itemGetInf[1] |= 0x20; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 200.0f); + } +} + +void func_809B05F0(EnAni* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + EnAni_SetupAction(pthis, func_809B0558); + } + func_8002F434(&pthis->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 200.0f); +} + +void func_809B064C(EnAni* pthis, GlobalContext* globalCtx) { + u16 textId; + s16 yawDiff; + u16 textId2; + + textId2 = Text_GetFaceReaction(globalCtx, 0xA); + textId = textId2 & 0xFFFF; + + if (!textId) {} + + if (textId2 == 0) { + textId = !IS_DAY ? 0x5051 : 0x5050; + } + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->actor.textId == 0x5056) { + EnAni_SetupAction(pthis, func_809B04F0); + } else if (pthis->actor.textId == 0x5055) { + EnAni_SetupAction(pthis, func_809B05F0); + } else { + EnAni_SetupAction(pthis, func_809B04F0); + } + } else if (yawDiff >= -0x36AF && yawDiff < 0 && pthis->actor.xzDistToPlayer < 150.0f && + -80.0f < pthis->actor.yDistToPlayer) { + if (gSaveContext.itemGetInf[1] & 0x20) { + EnAni_SetText(pthis, globalCtx, 0x5056); + } else { + EnAni_SetText(pthis, globalCtx, 0x5055); + } + } else if (yawDiff >= -0x3E7 && yawDiff < 0x36B0 && pthis->actor.xzDistToPlayer < 350.0f) { + EnAni_SetText(pthis, globalCtx, textId); + } +} + +void func_809B07F8(EnAni* pthis, GlobalContext* globalCtx) { + s16 pad; + s16 yawDiff; + u16 textId; + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->actor.textId == 0x5056) { + EnAni_SetupAction(pthis, func_809B0524); + } else if (pthis->actor.textId == 0x5055) { + EnAni_SetupAction(pthis, func_809B05F0); + } else { + EnAni_SetupAction(pthis, func_809B0524); + } + } else if (yawDiff > -0x36B0 && yawDiff < 0 && pthis->actor.xzDistToPlayer < 150.0f && + -80.0f < pthis->actor.yDistToPlayer) { + if (gSaveContext.itemGetInf[1] & 0x20) { + EnAni_SetText(pthis, globalCtx, 0x5056); + } else { + EnAni_SetText(pthis, globalCtx, 0x5055); + } + } else if (yawDiff > -0x3E8 && yawDiff < 0x36B0 && pthis->actor.xzDistToPlayer < 350.0f) { + if (!(gSaveContext.eventChkInf[2] & 0x8000)) { + textId = 0x5052; + } else { + textId = (gSaveContext.itemGetInf[1] & 0x20) ? 0x5054 : 0x5053; + } + EnAni_SetText(pthis, globalCtx, textId); + } +} + +void func_809B0988(EnAni* pthis, GlobalContext* globalCtx) { +} + +void func_809B0994(EnAni* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.npcActions[0]->action == 4) { + Animation_Change(&pthis->skelAnime, &gRoofManGettingUpAfterKnockbackAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gRoofManGettingUpAfterKnockbackAnim), ANIMMODE_ONCE, -4.0f); + pthis->unk_2AA++; + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } +} + +void func_809B0A28(EnAni* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_2AA++; + } +} + +void func_809B0A6C(EnAni* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->skelAnime.curFrame = 0.0f; + } + if (globalCtx->csCtx.npcActions[0]->action == 2) { + Animation_Change(&pthis->skelAnime, &gRoofManKnockbackAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gRoofManKnockbackAnim), ANIMMODE_ONCE, 0.0f); + pthis->actor.shape.shadowDraw = NULL; + pthis->unk_2AA++; + } +} + +void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAni* pthis = (EnAni*)thisx; + s32 pad[2]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[0] != NULL)) { + switch (pthis->unk_2AA) { + case 0: + func_809B0A6C(pthis, globalCtx); + break; + case 1: + func_809B0A28(pthis, globalCtx); + break; + case 2: + func_809B0994(pthis, globalCtx); + break; + case 3: + func_809B0A28(pthis, globalCtx); + break; + case 4: + func_809B0988(pthis, globalCtx); + break; + } + + if (globalCtx->csCtx.frames == 100) { + func_800788CC(NA_SE_IT_EARTHQUAKE); + } + } else { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + pthis->skelAnime.curFrame = 0.0f; + } + pthis->actionFunc(pthis, globalCtx); + } + + if (pthis->unk_2A8 & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_29C, &pthis->unk_2A2, pthis->actor.focus.pos); + pthis->unk_2A2.z = 0; + pthis->unk_2A2.y = pthis->unk_2A2.z; + pthis->unk_2A2.x = pthis->unk_2A2.z; + } else { + Math_SmoothStepToS(&pthis->unk_29C.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_29C.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.y, 0, 6, 6200, 100); + } + + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + pthis->eyeIndex = pthis->blinkTimer; + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; + } +} + +s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnAni* pthis = (EnAni*)thisx; + + if (limbIndex == 15) { + rot->x += pthis->unk_29C.y; + rot->z += pthis->unk_29C.x; + } + return false; +} + +void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f sMultVec = { 800.0f, 500.0f, 0.0f }; + EnAni* pthis = (EnAni*)thisx; + + if (limbIndex == 15) { + Matrix_MultVec3f(&sMultVec, &pthis->actor.focus.pos); + } +} + +void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { + gRoofManEyeOpenTex, + gRoofManEyeHalfTex, + gRoofManEyeClosedTex, + }; + EnAni* pthis = (EnAni*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ani.c", 719); + + func_800943C8(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ani.c", 736); +} diff --git a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c deleted file mode 100644 index ba9321fda..000000000 --- a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c +++ /dev/null @@ -1,502 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANUBICE_Z_EN_ANUBICE_C -#include "actor_common.h" -/* - * File: z_en_anubice.c - * Overlay: ovl_En_Anubice - * Description: Anubis Body - */ - -#include "z_en_anubice.h" -#include "objects/object_anubice/object_anubice.h" -#include "overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.h" -#include "overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.h" -#include "vt.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnAnubice_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAnubice_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAnubice_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAnubice_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnAnubice_FindFlameCircles(EnAnubice* this, GlobalContext* globalCtx); -void EnAnubice_SetupIdle(EnAnubice* this, GlobalContext* globalCtx); -void EnAnubice_Idle(EnAnubice* this, GlobalContext* globalCtx); -void EnAnubice_GoToHome(EnAnubice* this, GlobalContext* globalCtx); -void EnAnubis_SetupShootFireball(EnAnubice* this, GlobalContext* globalCtx); -void EnAnubis_ShootFireball(EnAnubice* this, GlobalContext* globalCtx); -void EnAnubice_Die(EnAnubice* this, GlobalContext* globalCtx); - -const ActorInit En_Anubice_InitVars = { - ACTOR_EN_ANUBICE, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_ANUBICE, - sizeof(EnAnubice), - (ActorFunc)EnAnubice_Init, - (ActorFunc)EnAnubice_Destroy, - (ActorFunc)EnAnubice_Update, - (ActorFunc)EnAnubice_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 29, 103, 0, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable[] = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0xF), - /* Slingshot */ DMG_ENTRY(0, 0xF), - /* Explosive */ DMG_ENTRY(0, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* Hammer swing */ DMG_ENTRY(1, 0xF), - /* Hookshot */ DMG_ENTRY(2, 0xF), - /* Kokiri sword */ DMG_ENTRY(0, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(6, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(0, 0xF), - /* Unk arrow 1 */ DMG_ENTRY(0, 0xF), - /* Unk arrow 2 */ DMG_ENTRY(0, 0xF), - /* Unk arrow 3 */ DMG_ENTRY(0, 0xF), - /* Fire magic */ DMG_ENTRY(3, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(0, 0xF), - /* Giant spin */ DMG_ENTRY(6, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(0, 0xF), - /* Giant jump */ DMG_ENTRY(12, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -void EnAnubice_Hover(EnAnubice* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->hoverVelocityTimer += 1500.0f; - this->targetHeight = player->actor.world.pos.y + this->playerHeightOffset; - Math_ApproachF(&this->actor.world.pos.y, this->targetHeight, 0.1f, 10.0f); - Math_ApproachF(&this->playerHeightOffset, 10.0f, 0.1f, 0.5f); - this->actor.velocity.y = Math_SinS(this->hoverVelocityTimer); -} - -void EnAnubice_SetFireballRot(EnAnubice* this, GlobalContext* globalCtx) { - f32 xzdist; - f32 x; - f32 y; - f32 z; - Player* player = GET_PLAYER(globalCtx); - - x = player->actor.world.pos.x - this->fireballPos.x; - y = player->actor.world.pos.y + 10.0f - this->fireballPos.y; - z = player->actor.world.pos.z - this->fireballPos.z; - xzdist = sqrtf(SQ(x) + SQ(z)); - - this->fireballRot.x = -RADF_TO_BINANG(Math_FAtan2F(y, xzdist)); - this->fireballRot.y = RADF_TO_BINANG(Math_FAtan2F(x, z)); -} - -void EnAnubice_Init(Actor* thisx, GlobalContext* globalCtx) { - EnAnubice* this = (EnAnubice*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gAnubiceSkel, &gAnubiceIdleAnim, this->jointTable, this->morphTable, - 16); - - osSyncPrintf("\n\n"); - // "☆☆☆☆☆ Anubis occurence ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ アヌビス発生 ☆☆☆☆☆ \n" VT_RST); - - this->actor.naviEnemyId = 0x3A; - - Collider_InitCylinder(globalCtx, &this->col); - Collider_SetCylinder(globalCtx, &this->col, &this->actor, &sCylinderInit); - - Actor_SetScale(&this->actor, 0.015f); - - this->actor.colChkInfo.damageTable = sDamageTable; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.shape.yOffset = -4230.0f; - this->focusHeightOffset = 0.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->home = this->actor.world.pos; - this->actor.targetMode = 3; - this->actionFunc = EnAnubice_FindFlameCircles; -} - -void EnAnubice_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnAnubice* this = (EnAnubice*)thisx; - EnAnubiceTag* temp_v1; - - Collider_DestroyCylinder(globalCtx, &this->col); - - if (this->actor.params != 0) { - if (this->actor.parent) {} - - temp_v1 = (EnAnubiceTag*)this->actor.parent; - if (temp_v1 != NULL && temp_v1->actor.update != NULL) { - temp_v1->anubis = NULL; - } - } -} - -void EnAnubice_FindFlameCircles(EnAnubice* this, GlobalContext* globalCtx) { - Actor* currentProp; - s32 flameCirclesFound; - - if (this->isMirroringLink) { - if (!this->hasSearchedForFlameCircles) { - flameCirclesFound = 0; - currentProp = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - while (currentProp != NULL) { - if (currentProp->id != ACTOR_BG_HIDAN_CURTAIN) { - currentProp = currentProp->next; - } else { - this->flameCircles[flameCirclesFound] = (BgHidanCurtain*)currentProp; - // "☆☆☆☆☆ How many fires? ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 火は幾つ? ☆☆☆☆☆ %d\n" VT_RST, flameCirclesFound); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 火は幾つ? ☆☆☆☆☆ %x\n" VT_RST, - this->flameCircles[flameCirclesFound]); - if (flameCirclesFound < 4) { - flameCirclesFound++; - } - currentProp = currentProp->next; - } - } - this->hasSearchedForFlameCircles = true; - } - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = EnAnubice_SetupIdle; - } -} - -void EnAnubice_SetupIdle(EnAnubice* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gAnubiceIdleAnim); - - Animation_Change(&this->skelAnime, &gAnubiceIdleAnim, 1.0f, 0.0f, (s16)lastFrame, ANIMMODE_LOOP, -10.0f); - - this->actionFunc = EnAnubice_Idle; - this->actor.velocity.x = this->actor.velocity.z = this->actor.gravity = 0.0f; -} - -void EnAnubice_Idle(EnAnubice* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.shape.yOffset, 0.5f, 300.0f); - Math_ApproachF(&this->focusHeightOffset, 70.0f, 0.5f, 5.0f); - - if (!this->isKnockedback) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 3000, 0); - } - - if (this->actor.shape.yOffset > -2.0f) { - this->actor.shape.yOffset = 0.0f; - - if (player->swordState != 0) { - this->actionFunc = EnAnubis_SetupShootFireball; - } else if (this->isLinkOutOfRange) { - this->actor.velocity.y = 0.0f; - this->actor.gravity = -1.0f; - this->actionFunc = EnAnubice_GoToHome; - } - } -} - -void EnAnubice_GoToHome(EnAnubice* this, GlobalContext* globalCtx) { - f32 xzdist; - f32 xRatio; - f32 zRatio; - f32 x; - f32 z; - - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.shape.yOffset, -4230.0f, 0.5f, 300.0f); - Math_ApproachZeroF(&this->focusHeightOffset, 0.5f, 5.0f); - - if (!this->isKnockedback) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 3000, 0); - } - - if (fabsf(this->home.x - this->actor.world.pos.x) > 3.0f && fabsf(this->home.z - this->actor.world.pos.z) > 3.0f) { - x = this->home.x - this->actor.world.pos.x; - z = this->home.z - this->actor.world.pos.z; - xzdist = sqrtf(SQ(x) + SQ(z)); - xRatio = ((x) / xzdist); - zRatio = ((z) / xzdist); - this->actor.world.pos.x += (xRatio * 8); - this->actor.world.pos.z += (zRatio * 8.0f); - } else if (this->actor.shape.yOffset < -4220.0f) { - this->actor.shape.yOffset = -4230.0f; - this->isMirroringLink = this->isLinkOutOfRange = false; - this->actionFunc = EnAnubice_FindFlameCircles; - this->actor.gravity = 0.0f; - } -} - -void EnAnubis_SetupShootFireball(EnAnubice* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gAnubiceAttackingAnim); - - this->animLastFrame = lastFrame; - Animation_Change(&this->skelAnime, &gAnubiceAttackingAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -10.0f); - this->actionFunc = EnAnubis_ShootFireball; - this->actor.velocity.x = this->actor.velocity.z = 0.0f; -} - -void EnAnubis_ShootFireball(EnAnubice* this, GlobalContext* globalCtx) { - f32 curFrame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - - if (!this->isKnockedback) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 3000, 0); - } - - EnAnubice_SetFireballRot(this, globalCtx); - - if (curFrame == 12.0f) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ANUBICE_FIRE, this->fireballPos.x, - this->fireballPos.y + 15.0f, this->fireballPos.z, this->fireballRot.x, this->fireballRot.y, 0, 0); - } - - if (this->animLastFrame <= curFrame) { - this->actionFunc = EnAnubice_SetupIdle; - } -} - -void EnAnubice_SetupDie(EnAnubice* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gAnubiceFallDownAnim); - - this->animLastFrame = lastFrame; - Animation_Change(&this->skelAnime, &gAnubiceFallDownAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -20.0f); - - this->unk_256 = false; - this->unk_258 = 0; - this->deathTimer = 20; - this->actor.velocity.x = this->actor.velocity.z = 0.0f; - this->actor.gravity = -1.0f; - - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->fireballPos, 70.0f)) { - this->unk_256 = true; - this->unk_258 = this->actor.shape.rot.x - 0x7F00; - } - - this->actionFunc = EnAnubice_Die; -} - -void EnAnubice_Die(EnAnubice* this, GlobalContext* globalCtx) { - f32 curFrame; - f32 phi_f2; - Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; - Vec3f fireEffectPos = { 0.0f, 0.0f, 0.0f }; - s32 pad; - - SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.shape.shadowScale, 0.4f, 0.25f); - - if (this->unk_256) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_258, 1, 10000, 0); - if (fabsf(this->actor.shape.rot.y - this->unk_258) < 100.0f) { - this->unk_256 = false; - } - } - - curFrame = this->skelAnime.curFrame; - phi_f2 = curFrame * -3000.0f; - phi_f2 = CLAMP_MIN(phi_f2, -11000.0f); - - Matrix_RotateY(BINANG_TO_RAD(this->actor.shape.rot.y), MTXMODE_NEW); - Matrix_RotateX(BINANG_TO_RAD(phi_f2), MTXMODE_APPLY); - sp4C.y = Rand_CenteredFloat(10.0f) + 30.0f; - Matrix_MultVec3f(&sp4C, &fireEffectPos); - fireEffectPos.x += this->actor.world.pos.x + Rand_CenteredFloat(40.0f); - fireEffectPos.y += this->actor.world.pos.y + Rand_CenteredFloat(40.0f); - fireEffectPos.z += this->actor.world.pos.z + Rand_CenteredFloat(30.0f); - Actor_SetColorFilter(&this->actor, 0x4000, 0x80, 0, 8); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &fireEffectPos, 100, 0, 0, -1); - - if (this->animLastFrame <= curFrame && (this->actor.bgCheckFlags & 1)) { - Math_ApproachF(&this->actor.shape.yOffset, -4230.0f, 0.5f, 300.0f); - if (this->actor.shape.yOffset < -2000.0f) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xC0); - Actor_Kill(&this->actor); - } - } -} - -void EnAnubice_Update(Actor* thisx, GlobalContext* globalCtx) { - f32 zero; - BgHidanCurtain* flameCircle; - s32 i; - Vec3f sp48; - Vec3f sp3C; - EnAnubice* this = (EnAnubice*)thisx; - - if (this->actionFunc != EnAnubice_SetupDie && this->actionFunc != EnAnubice_Die && - this->actor.shape.yOffset == 0.0f) { - EnAnubice_Hover(this, globalCtx); - for (i = 0; i < 5; i++) { - flameCircle = this->flameCircles[i]; - - if (flameCircle != NULL && fabsf(flameCircle->actor.world.pos.x - this->actor.world.pos.x) < 60.0f && - fabsf(this->flameCircles[i]->actor.world.pos.z - this->actor.world.pos.z) < 60.0f && - flameCircle->timer != 0) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - this->actor.flags &= ~ACTOR_FLAG_0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ANUBIS_DEAD); - this->actionFunc = EnAnubice_SetupDie; - return; - } - } - - if (this->col.base.acFlags & 2) { - this->col.base.acFlags &= ~2; - if (this->actor.colChkInfo.damageEffect == 2) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - this->actor.flags &= ~ACTOR_FLAG_0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ANUBIS_DEAD); - this->actionFunc = EnAnubice_SetupDie; - return; - } - - if (!this->isKnockedback) { - this->knockbackTimer = 10; - this->isKnockedback = true; - - sp48.x = 0.0f; - sp48.y = 0.0f; - sp48.z = -10.0f; - sp3C.x = 0.0f; - sp3C.y = 0.0f; - sp3C.z = 0.0f; - - Matrix_RotateY(BINANG_TO_RAD(this->actor.shape.rot.y), MTXMODE_NEW); - Matrix_MultVec3f(&sp48, &sp3C); - - this->actor.velocity.x = sp3C.x; - this->actor.velocity.z = sp3C.z; - this->knockbackRecoveryVelocity.x = -sp3C.x; - this->knockbackRecoveryVelocity.z = -sp3C.z; - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_CUTBODY); - } - } - - if (this->isKnockedback) { - this->actor.shape.rot.y += 6500; - Math_ApproachF(&this->actor.velocity.x, this->knockbackRecoveryVelocity.x, 0.3f, 1.0f); - Math_ApproachF(&this->actor.velocity.z, this->knockbackRecoveryVelocity.z, 0.3f, 1.0f); - - zero = 0.0f; - if (zero) {} - - if (this->knockbackTimer == 0) { - this->actor.velocity.x = this->actor.velocity.z = 0.0f; - this->knockbackRecoveryVelocity.x = this->knockbackRecoveryVelocity.z = 0.0f; - this->isKnockedback = false; - } - } - } - - this->timeAlive++; - - if (this->knockbackTimer != 0) { - this->knockbackTimer--; - } - - if (this->deathTimer != 0) { - this->deathTimer--; - } - - this->actionFunc(this, globalCtx); - - this->actor.velocity.y += this->actor.gravity; - func_8002D7EC(&this->actor); - - if (!this->isLinkOutOfRange) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 5.0f, 10.0f, 0x1D); - } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 5.0f, 10.0f, 0x1C); - } - - if (this->actionFunc != EnAnubice_SetupDie && this->actionFunc != EnAnubice_Die) { - Actor_SetFocus(&this->actor, this->focusHeightOffset); - Collider_UpdateCylinder(&this->actor, &this->col); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->col.base); - - if (!this->isKnockedback && this->actor.shape.yOffset == 0.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->col.base); - } - } -} - -s32 EnAnubis_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnAnubice* this = (EnAnubice*)thisx; - - if (limbIndex == 13) { - rot->z += this->unk_278; - } - - return false; -} - -void EnAnubis_PostLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnAnubice* this = (EnAnubice*)thisx; - Vec3f pos = { 0.0f, 0.0f, 0.0f }; - - if (limbIndex == 13) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice.c", 853); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_anubice.c", 856), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gAnubiceEyesDL); - Matrix_MultVec3f(&pos, &this->fireballPos); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice.c", 868); - } -} - -void EnAnubice_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnAnubice* this = (EnAnubice*)thisx; - - func_80093D84(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnAnubis_OverrideLimbDraw, - EnAnubis_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.cpp b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.cpp new file mode 100644 index 000000000..372601a3d --- /dev/null +++ b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.cpp @@ -0,0 +1,502 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANUBICE_Z_EN_ANUBICE_C +#include "actor_common.h" +/* + * File: z_en_anubice.c + * Overlay: ovl_En_Anubice + * Description: Anubis Body + */ + +#include "z_en_anubice.h" +#include "objects/object_anubice/object_anubice.h" +#include "overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.h" +#include "overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.h" +#include "vt.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnAnubice_Init(Actor* thisx, GlobalContext* globalCtx); +void EnAnubice_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnAnubice_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAnubice_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnAnubice_FindFlameCircles(EnAnubice* pthis, GlobalContext* globalCtx); +void EnAnubice_SetupIdle(EnAnubice* pthis, GlobalContext* globalCtx); +void EnAnubice_Idle(EnAnubice* pthis, GlobalContext* globalCtx); +void EnAnubice_GoToHome(EnAnubice* pthis, GlobalContext* globalCtx); +void EnAnubis_SetupShootFireball(EnAnubice* pthis, GlobalContext* globalCtx); +void EnAnubis_ShootFireball(EnAnubice* pthis, GlobalContext* globalCtx); +void EnAnubice_Die(EnAnubice* pthis, GlobalContext* globalCtx); + +ActorInit En_Anubice_InitVars = { + ACTOR_EN_ANUBICE, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_ANUBICE, + sizeof(EnAnubice), + (ActorFunc)EnAnubice_Init, + (ActorFunc)EnAnubice_Destroy, + (ActorFunc)EnAnubice_Update, + (ActorFunc)EnAnubice_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 29, 103, 0, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable[] = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0xF), + /* Slingshot */ DMG_ENTRY(0, 0xF), + /* Explosive */ DMG_ENTRY(0, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0xF), + /* Normal arrow */ DMG_ENTRY(0, 0xF), + /* Hammer swing */ DMG_ENTRY(1, 0xF), + /* Hookshot */ DMG_ENTRY(2, 0xF), + /* Kokiri sword */ DMG_ENTRY(0, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(6, 0xF), + /* Fire arrow */ DMG_ENTRY(2, 0x2), + /* Ice arrow */ DMG_ENTRY(0, 0xF), + /* Light arrow */ DMG_ENTRY(0, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(0, 0xF), + /* Unk arrow 2 */ DMG_ENTRY(0, 0xF), + /* Unk arrow 3 */ DMG_ENTRY(0, 0xF), + /* Fire magic */ DMG_ENTRY(3, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0xF), + /* Giant spin */ DMG_ENTRY(6, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(0, 0xF), + /* Giant jump */ DMG_ENTRY(12, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +void EnAnubice_Hover(EnAnubice* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->hoverVelocityTimer += 1500.0f; + pthis->targetHeight = player->actor.world.pos.y + pthis->playerHeightOffset; + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetHeight, 0.1f, 10.0f); + Math_ApproachF(&pthis->playerHeightOffset, 10.0f, 0.1f, 0.5f); + pthis->actor.velocity.y = Math_SinS(pthis->hoverVelocityTimer); +} + +void EnAnubice_SetFireballRot(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 xzdist; + f32 x; + f32 y; + f32 z; + Player* player = GET_PLAYER(globalCtx); + + x = player->actor.world.pos.x - pthis->fireballPos.x; + y = player->actor.world.pos.y + 10.0f - pthis->fireballPos.y; + z = player->actor.world.pos.z - pthis->fireballPos.z; + xzdist = sqrtf(SQ(x) + SQ(z)); + + pthis->fireballRot.x = -RADF_TO_BINANG(Math_FAtan2F(y, xzdist)); + pthis->fireballRot.y = RADF_TO_BINANG(Math_FAtan2F(x, z)); +} + +void EnAnubice_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAnubice* pthis = (EnAnubice*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gAnubiceSkel, &gAnubiceIdleAnim, pthis->jointTable, pthis->morphTable, + 16); + + osSyncPrintf("\n\n"); + // "☆☆☆☆☆ Anubis occurence ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ アヌビス発生 ☆☆☆☆☆ \n" VT_RST); + + pthis->actor.naviEnemyId = 0x3A; + + Collider_InitCylinder(globalCtx, &pthis->col); + Collider_SetCylinder(globalCtx, &pthis->col, &pthis->actor, &sCylinderInit); + + Actor_SetScale(&pthis->actor, 0.015f); + + pthis->actor.colChkInfo.damageTable = sDamageTable; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.shape.yOffset = -4230.0f; + pthis->focusHeightOffset = 0.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->home = pthis->actor.world.pos; + pthis->actor.targetMode = 3; + pthis->actionFunc = EnAnubice_FindFlameCircles; +} + +void EnAnubice_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAnubice* pthis = (EnAnubice*)thisx; + EnAnubiceTag* temp_v1; + + Collider_DestroyCylinder(globalCtx, &pthis->col); + + if (pthis->actor.params != 0) { + if (pthis->actor.parent) {} + + temp_v1 = (EnAnubiceTag*)pthis->actor.parent; + if (temp_v1 != NULL && temp_v1->actor.update != NULL) { + temp_v1->anubis = NULL; + } + } +} + +void EnAnubice_FindFlameCircles(EnAnubice* pthis, GlobalContext* globalCtx) { + Actor* currentProp; + s32 flameCirclesFound; + + if (pthis->isMirroringLink) { + if (!pthis->hasSearchedForFlameCircles) { + flameCirclesFound = 0; + currentProp = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + while (currentProp != NULL) { + if (currentProp->id != ACTOR_BG_HIDAN_CURTAIN) { + currentProp = currentProp->next; + } else { + pthis->flameCircles[flameCirclesFound] = (BgHidanCurtain*)currentProp; + // "☆☆☆☆☆ How many fires? ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 火は幾つ? ☆☆☆☆☆ %d\n" VT_RST, flameCirclesFound); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 火は幾つ? ☆☆☆☆☆ %x\n" VT_RST, + pthis->flameCircles[flameCirclesFound]); + if (flameCirclesFound < 4) { + flameCirclesFound++; + } + currentProp = currentProp->next; + } + } + pthis->hasSearchedForFlameCircles = true; + } + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = EnAnubice_SetupIdle; + } +} + +void EnAnubice_SetupIdle(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gAnubiceIdleAnim); + + Animation_Change(&pthis->skelAnime, &gAnubiceIdleAnim, 1.0f, 0.0f, (s16)lastFrame, ANIMMODE_LOOP, -10.0f); + + pthis->actionFunc = EnAnubice_Idle; + pthis->actor.velocity.x = pthis->actor.velocity.z = pthis->actor.gravity = 0.0f; +} + +void EnAnubice_Idle(EnAnubice* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->actor.shape.yOffset, 0.5f, 300.0f); + Math_ApproachF(&pthis->focusHeightOffset, 70.0f, 0.5f, 5.0f); + + if (!pthis->isKnockedback) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 3000, 0); + } + + if (pthis->actor.shape.yOffset > -2.0f) { + pthis->actor.shape.yOffset = 0.0f; + + if (player->swordState != 0) { + pthis->actionFunc = EnAnubis_SetupShootFireball; + } else if (pthis->isLinkOutOfRange) { + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -1.0f; + pthis->actionFunc = EnAnubice_GoToHome; + } + } +} + +void EnAnubice_GoToHome(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 xzdist; + f32 xRatio; + f32 zRatio; + f32 x; + f32 z; + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.shape.yOffset, -4230.0f, 0.5f, 300.0f); + Math_ApproachZeroF(&pthis->focusHeightOffset, 0.5f, 5.0f); + + if (!pthis->isKnockedback) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 3000, 0); + } + + if (fabsf(pthis->home.x - pthis->actor.world.pos.x) > 3.0f && fabsf(pthis->home.z - pthis->actor.world.pos.z) > 3.0f) { + x = pthis->home.x - pthis->actor.world.pos.x; + z = pthis->home.z - pthis->actor.world.pos.z; + xzdist = sqrtf(SQ(x) + SQ(z)); + xRatio = ((x) / xzdist); + zRatio = ((z) / xzdist); + pthis->actor.world.pos.x += (xRatio * 8); + pthis->actor.world.pos.z += (zRatio * 8.0f); + } else if (pthis->actor.shape.yOffset < -4220.0f) { + pthis->actor.shape.yOffset = -4230.0f; + pthis->isMirroringLink = pthis->isLinkOutOfRange = false; + pthis->actionFunc = EnAnubice_FindFlameCircles; + pthis->actor.gravity = 0.0f; + } +} + +void EnAnubis_SetupShootFireball(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gAnubiceAttackingAnim); + + pthis->animLastFrame = lastFrame; + Animation_Change(&pthis->skelAnime, &gAnubiceAttackingAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = EnAnubis_ShootFireball; + pthis->actor.velocity.x = pthis->actor.velocity.z = 0.0f; +} + +void EnAnubis_ShootFireball(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 curFrame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + + if (!pthis->isKnockedback) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 3000, 0); + } + + EnAnubice_SetFireballRot(pthis, globalCtx); + + if (curFrame == 12.0f) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ANUBICE_FIRE, pthis->fireballPos.x, + pthis->fireballPos.y + 15.0f, pthis->fireballPos.z, pthis->fireballRot.x, pthis->fireballRot.y, 0, 0); + } + + if (pthis->animLastFrame <= curFrame) { + pthis->actionFunc = EnAnubice_SetupIdle; + } +} + +void EnAnubice_SetupDie(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gAnubiceFallDownAnim); + + pthis->animLastFrame = lastFrame; + Animation_Change(&pthis->skelAnime, &gAnubiceFallDownAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -20.0f); + + pthis->unk_256 = false; + pthis->unk_258 = 0; + pthis->deathTimer = 20; + pthis->actor.velocity.x = pthis->actor.velocity.z = 0.0f; + pthis->actor.gravity = -1.0f; + + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &pthis->fireballPos, 70.0f)) { + pthis->unk_256 = true; + pthis->unk_258 = pthis->actor.shape.rot.x - 0x7F00; + } + + pthis->actionFunc = EnAnubice_Die; +} + +void EnAnubice_Die(EnAnubice* pthis, GlobalContext* globalCtx) { + f32 curFrame; + f32 phi_f2; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + Vec3f fireEffectPos = { 0.0f, 0.0f, 0.0f }; + s32 pad; + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachZeroF(&pthis->actor.shape.shadowScale, 0.4f, 0.25f); + + if (pthis->unk_256) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->unk_258, 1, 10000, 0); + if (fabsf(pthis->actor.shape.rot.y - pthis->unk_258) < 100.0f) { + pthis->unk_256 = false; + } + } + + curFrame = pthis->skelAnime.curFrame; + phi_f2 = curFrame * -3000.0f; + phi_f2 = CLAMP_MIN(phi_f2, -11000.0f); + + Matrix_RotateY(BINANG_TO_RAD(pthis->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateX(BINANG_TO_RAD(phi_f2), MTXMODE_APPLY); + sp4C.y = Rand_CenteredFloat(10.0f) + 30.0f; + Matrix_MultVec3f(&sp4C, &fireEffectPos); + fireEffectPos.x += pthis->actor.world.pos.x + Rand_CenteredFloat(40.0f); + fireEffectPos.y += pthis->actor.world.pos.y + Rand_CenteredFloat(40.0f); + fireEffectPos.z += pthis->actor.world.pos.z + Rand_CenteredFloat(30.0f); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0x80, 0, 8); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &fireEffectPos, 100, 0, 0, -1); + + if (pthis->animLastFrame <= curFrame && (pthis->actor.bgCheckFlags & 1)) { + Math_ApproachF(&pthis->actor.shape.yOffset, -4230.0f, 0.5f, 300.0f); + if (pthis->actor.shape.yOffset < -2000.0f) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xC0); + Actor_Kill(&pthis->actor); + } + } +} + +void EnAnubice_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 zero; + BgHidanCurtain* flameCircle; + s32 i; + Vec3f sp48; + Vec3f sp3C; + EnAnubice* pthis = (EnAnubice*)thisx; + + if (pthis->actionFunc != EnAnubice_SetupDie && pthis->actionFunc != EnAnubice_Die && + pthis->actor.shape.yOffset == 0.0f) { + EnAnubice_Hover(pthis, globalCtx); + for (i = 0; i < 5; i++) { + flameCircle = pthis->flameCircles[i]; + + if (flameCircle != NULL && fabsf(flameCircle->actor.world.pos.x - pthis->actor.world.pos.x) < 60.0f && + fabsf(pthis->flameCircles[i]->actor.world.pos.z - pthis->actor.world.pos.z) < 60.0f && + flameCircle->timer != 0) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + pthis->actor.flags &= ~ACTOR_FLAG_0; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_ANUBIS_DEAD); + pthis->actionFunc = EnAnubice_SetupDie; + return; + } + } + + if (pthis->col.base.acFlags & 2) { + pthis->col.base.acFlags &= ~2; + if (pthis->actor.colChkInfo.damageEffect == 2) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + pthis->actor.flags &= ~ACTOR_FLAG_0; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_ANUBIS_DEAD); + pthis->actionFunc = EnAnubice_SetupDie; + return; + } + + if (!pthis->isKnockedback) { + pthis->knockbackTimer = 10; + pthis->isKnockedback = true; + + sp48.x = 0.0f; + sp48.y = 0.0f; + sp48.z = -10.0f; + sp3C.x = 0.0f; + sp3C.y = 0.0f; + sp3C.z = 0.0f; + + Matrix_RotateY(BINANG_TO_RAD(pthis->actor.shape.rot.y), MTXMODE_NEW); + Matrix_MultVec3f(&sp48, &sp3C); + + pthis->actor.velocity.x = sp3C.x; + pthis->actor.velocity.z = sp3C.z; + pthis->knockbackRecoveryVelocity.x = -sp3C.x; + pthis->knockbackRecoveryVelocity.z = -sp3C.z; + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_CUTBODY); + } + } + + if (pthis->isKnockedback) { + pthis->actor.shape.rot.y += 6500; + Math_ApproachF(&pthis->actor.velocity.x, pthis->knockbackRecoveryVelocity.x, 0.3f, 1.0f); + Math_ApproachF(&pthis->actor.velocity.z, pthis->knockbackRecoveryVelocity.z, 0.3f, 1.0f); + + zero = 0.0f; + if (zero) {} + + if (pthis->knockbackTimer == 0) { + pthis->actor.velocity.x = pthis->actor.velocity.z = 0.0f; + pthis->knockbackRecoveryVelocity.x = pthis->knockbackRecoveryVelocity.z = 0.0f; + pthis->isKnockedback = false; + } + } + } + + pthis->timeAlive++; + + if (pthis->knockbackTimer != 0) { + pthis->knockbackTimer--; + } + + if (pthis->deathTimer != 0) { + pthis->deathTimer--; + } + + pthis->actionFunc(pthis, globalCtx); + + pthis->actor.velocity.y += pthis->actor.gravity; + func_8002D7EC(&pthis->actor); + + if (!pthis->isLinkOutOfRange) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 5.0f, 10.0f, 0x1D); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 5.0f, 10.0f, 0x1C); + } + + if (pthis->actionFunc != EnAnubice_SetupDie && pthis->actionFunc != EnAnubice_Die) { + Actor_SetFocus(&pthis->actor, pthis->focusHeightOffset); + Collider_UpdateCylinder(&pthis->actor, &pthis->col); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->col.base); + + if (!pthis->isKnockedback && pthis->actor.shape.yOffset == 0.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->col.base); + } + } +} + +s32 EnAnubis_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnAnubice* pthis = (EnAnubice*)thisx; + + if (limbIndex == 13) { + rot->z += pthis->unk_278; + } + + return false; +} + +void EnAnubis_PostLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnAnubice* pthis = (EnAnubice*)thisx; + Vec3f pos = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 13) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice.c", 853); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_anubice.c", 856), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gAnubiceEyesDL); + Matrix_MultVec3f(&pos, &pthis->fireballPos); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice.c", 868); + } +} + +void EnAnubice_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAnubice* pthis = (EnAnubice*)thisx; + + func_80093D84(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnAnubis_OverrideLimbDraw, + EnAnubis_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c b/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c deleted file mode 100644 index 7359a977b..000000000 --- a/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c +++ /dev/null @@ -1,270 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANUBICE_FIRE_Z_EN_ANUBICE_FIRE_C -#include "actor_common.h" -/* - * File: z_en_anubice_fire.c - * Overlay: ovl_En_Anubice_Fire - * Description: Anubis Fire Attack - */ - -#include "z_en_anubice_fire.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_anubice/object_anubice.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnAnubiceFire_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAnubiceFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAnubiceFire_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAnubiceFire_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809B26EC(EnAnubiceFire* this, GlobalContext* globalCtx); -void func_809B27D8(EnAnubiceFire* this, GlobalContext* globalCtx); -void func_809B2B48(EnAnubiceFire* this, GlobalContext* globalCtx); - -const ActorInit En_Anubice_Fire_InitVars = { - ACTOR_EN_ANUBICE_FIRE, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_ANUBICE, - sizeof(EnAnubiceFire), - (ActorFunc)EnAnubiceFire_Init, - (ActorFunc)EnAnubiceFire_Destroy, - (ActorFunc)EnAnubiceFire_Update, - (ActorFunc)EnAnubiceFire_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 0, 0, 0, { 0, 0, 0 } }, -}; - -void EnAnubiceFire_Init(Actor* thisx, GlobalContext* globalCtx) { - EnAnubiceFire* this = (EnAnubiceFire*)thisx; - s32 i; - - Collider_InitCylinder(globalCtx, &this->cylinder); - Collider_SetCylinder(globalCtx, &this->cylinder, &this->actor, &sCylinderInit); - - this->unk_15A = 30; - this->unk_154 = 2.0f; - this->scale = 0.0f; - - for (i = 0; i < 6; i++) { - this->unk_160[i] = this->actor.world.pos; - } - - this->unk_15E = 0; - this->actionFunc = func_809B26EC; -} - -void EnAnubiceFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnAnubiceFire* this = (EnAnubiceFire*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->cylinder); -} - -void func_809B26EC(EnAnubiceFire* this, GlobalContext* globalCtx) { - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - - Matrix_Push(); - Matrix_RotateY(BINANG_TO_RAD(this->actor.world.rot.y), MTXMODE_NEW); - Matrix_RotateX(BINANG_TO_RAD(this->actor.world.rot.x), MTXMODE_APPLY); - velocity.z = 15.0f; - Matrix_MultVec3f(&velocity, &this->actor.velocity); - Matrix_Pop(); - - this->actionFunc = func_809B27D8; - this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; -} - -void func_809B27D8(EnAnubiceFire* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - Color_RGBA8 primColor = { 255, 255, 0, 255 }; - Color_RGBA8 envColor = { 255, 0, 0, 255 }; - Vec3f sp84 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp78 = { 0.0f, 0.0f, 0.0f }; - - this->actor.world.rot.z += 5000; - if (this->unk_15A == 0) { - this->unk_154 = 0.0f; - } - - Math_ApproachF(&this->scale, this->unk_154, 0.2f, 0.4f); - if ((this->unk_15A == 0) && (this->scale < 0.1f)) { - Actor_Kill(&this->actor); - } else if ((this->actor.params == 0) && (this->cylinder.base.atFlags & 4)) { - if (Player_HasMirrorShieldEquipped(globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); - this->cylinder.base.atFlags &= 0xFFE9; - this->cylinder.base.atFlags |= 8; - this->cylinder.info.toucher.dmgFlags = 2; - this->unk_15A = 30; - this->actor.params = 1; - this->actor.velocity.x *= -1.0f; - this->actor.velocity.y *= -0.5f; - this->actor.velocity.z *= -1.0f; - } else { - this->unk_15A = 0; - EffectSsBomb2_SpawnLayered(globalCtx, &this->actor.world.pos, &sp78, &sp84, 10, 5); - this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ANUBIS_FIREBOMB); - this->actionFunc = func_809B2B48; - } - } else if (!(this->scale < .4f)) { - f32 scale = 1000.0f; - f32 life = 10.0f; - s32 i; - - for (i = 0; i < 10; i++) { - pos.x = this->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * (this->scale * 20.0f); - pos.y = this->actor.world.pos.y + (Rand_ZeroOne() - 0.5f) * (this->scale * 20.0f); - pos.z = this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, scale, life); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ANUBIS_FIRE - SFX_FLAG); - } -} - -void func_809B2B48(EnAnubiceFire* this, GlobalContext* globalCtx) { - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - Color_RGBA8 primColor = { 255, 255, 0, 255 }; - Color_RGBA8 envColor = { 255, 0, 0, 255 }; - s32 pad; - s32 i; - - if (this->unk_15C == 0) { - for (i = 0; i < 20; i++) { - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z; - accel.x = Rand_CenteredFloat(8.0f); - accel.y = Rand_CenteredFloat(2.0f); - accel.z = Rand_CenteredFloat(8.0f); - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 2000, 10); - } - - this->unk_15C = 2; - this->unk_15E++; - if (this->unk_15E >= 6) { - Actor_Kill(&this->actor); - } - } -} - -void EnAnubiceFire_Update(Actor* thisx, GlobalContext* globalCtx) { - EnAnubiceFire* this = (EnAnubiceFire*)thisx; - s32 pad; - s32 i; - - Actor_SetScale(&this->actor, this->scale); - this->actionFunc(this, globalCtx); - func_8002D7EC(&this->actor); - this->unk_160[0] = this->actor.world.pos; - - if (1) {} - - for (i = 4; i >= 0; i--) { - this->unk_160[i + 1] = this->unk_160[i]; - } - - if (this->unk_15A != 0) { - this->unk_15A--; - } - - if (this->unk_15C != 0) { - this->unk_15C--; - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 5.0f, 10.0f, 0x1D); - if (!(this->scale < 0.6f || this->actionFunc == func_809B2B48)) { - this->cylinder.dim.radius = this->scale * 15.0f + 5.0f; - this->cylinder.dim.height = this->scale * 15.0f + 5.0f; - this->cylinder.dim.yShift = this->scale * -0.75f + -15.0f; - - if (this->unk_15A != 0) { - Collider_UpdateCylinder(&this->actor, &this->cylinder); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->cylinder.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder.base); - } - - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->actor.world.pos, 30.0f)) { - this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ANUBIS_FIREBOMB); - this->actionFunc = func_809B2B48; - } - } -} - -void EnAnubiceFire_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* D_809B3270[] = { - gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, - }; - EnAnubiceFire* this = (EnAnubiceFire*)thisx; - s32 pad[2]; - s32 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice_fire.c", 503); - func_80093D84(globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809B3270[0])); - - Matrix_Push(); - for (i = this->unk_15E; i < 6; ++i) { - f32 scale = this->actor.scale.x - (i * 0.2f); - - if (scale < 0.0f) { - scale = 0.0f; - } - - if (scale >= 0.1f) { - Matrix_Translate(this->unk_160[i].x, this->unk_160[i].y, this->unk_160[i].z, MTXMODE_NEW); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_RotateZ(this->actor.world.rot.z + i * 1000.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_anubice_fire.c", 546), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_XLU_DISP++, gAnubiceFireAttackDL); - } - - if (this->scale < 0.1f) { - break; - } - } - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice_fire.c", 556); -} diff --git a/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.cpp b/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.cpp new file mode 100644 index 000000000..58af92871 --- /dev/null +++ b/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.cpp @@ -0,0 +1,270 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANUBICE_FIRE_Z_EN_ANUBICE_FIRE_C +#include "actor_common.h" +/* + * File: z_en_anubice_fire.c + * Overlay: ovl_En_Anubice_Fire + * Description: Anubis Fire Attack + */ + +#include "z_en_anubice_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_anubice/object_anubice.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnAnubiceFire_Init(Actor* thisx, GlobalContext* globalCtx); +void EnAnubiceFire_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnAnubiceFire_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAnubiceFire_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809B26EC(EnAnubiceFire* pthis, GlobalContext* globalCtx); +void func_809B27D8(EnAnubiceFire* pthis, GlobalContext* globalCtx); +void func_809B2B48(EnAnubiceFire* pthis, GlobalContext* globalCtx); + +ActorInit En_Anubice_Fire_InitVars = { + ACTOR_EN_ANUBICE_FIRE, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_ANUBICE, + sizeof(EnAnubiceFire), + (ActorFunc)EnAnubiceFire_Init, + (ActorFunc)EnAnubiceFire_Destroy, + (ActorFunc)EnAnubiceFire_Update, + (ActorFunc)EnAnubiceFire_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 0, 0, 0, { 0, 0, 0 } }, +}; + +void EnAnubiceFire_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAnubiceFire* pthis = (EnAnubiceFire*)thisx; + s32 i; + + Collider_InitCylinder(globalCtx, &pthis->cylinder); + Collider_SetCylinder(globalCtx, &pthis->cylinder, &pthis->actor, &sCylinderInit); + + pthis->unk_15A = 30; + pthis->unk_154 = 2.0f; + pthis->scale = 0.0f; + + for (i = 0; i < 6; i++) { + pthis->unk_160[i] = pthis->actor.world.pos; + } + + pthis->unk_15E = 0; + pthis->actionFunc = func_809B26EC; +} + +void EnAnubiceFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAnubiceFire* pthis = (EnAnubiceFire*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->cylinder); +} + +void func_809B26EC(EnAnubiceFire* pthis, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + + Matrix_Push(); + Matrix_RotateY(BINANG_TO_RAD(pthis->actor.world.rot.y), MTXMODE_NEW); + Matrix_RotateX(BINANG_TO_RAD(pthis->actor.world.rot.x), MTXMODE_APPLY); + velocity.z = 15.0f; + Matrix_MultVec3f(&velocity, &pthis->actor.velocity); + Matrix_Pop(); + + pthis->actionFunc = func_809B27D8; + pthis->actor.world.rot.x = pthis->actor.world.rot.y = pthis->actor.world.rot.z = 0; +} + +void func_809B27D8(EnAnubiceFire* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + Color_RGBA8 primColor = { 255, 255, 0, 255 }; + Color_RGBA8 envColor = { 255, 0, 0, 255 }; + Vec3f sp84 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp78 = { 0.0f, 0.0f, 0.0f }; + + pthis->actor.world.rot.z += 5000; + if (pthis->unk_15A == 0) { + pthis->unk_154 = 0.0f; + } + + Math_ApproachF(&pthis->scale, pthis->unk_154, 0.2f, 0.4f); + if ((pthis->unk_15A == 0) && (pthis->scale < 0.1f)) { + Actor_Kill(&pthis->actor); + } else if ((pthis->actor.params == 0) && (pthis->cylinder.base.atFlags & 4)) { + if (Player_HasMirrorShieldEquipped(globalCtx)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SHIELD_REFLECT_SW); + pthis->cylinder.base.atFlags &= 0xFFE9; + pthis->cylinder.base.atFlags |= 8; + pthis->cylinder.info.toucher.dmgFlags = 2; + pthis->unk_15A = 30; + pthis->actor.params = 1; + pthis->actor.velocity.x *= -1.0f; + pthis->actor.velocity.y *= -0.5f; + pthis->actor.velocity.z *= -1.0f; + } else { + pthis->unk_15A = 0; + EffectSsBomb2_SpawnLayered(globalCtx, &pthis->actor.world.pos, &sp78, &sp84, 10, 5); + pthis->actor.velocity.x = pthis->actor.velocity.y = pthis->actor.velocity.z = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_ANUBIS_FIREBOMB); + pthis->actionFunc = func_809B2B48; + } + } else if (!(pthis->scale < .4f)) { + f32 scale = 1000.0f; + f32 life = 10.0f; + s32 i; + + for (i = 0; i < 10; i++) { + pos.x = pthis->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * (pthis->scale * 20.0f); + pos.y = pthis->actor.world.pos.y + (Rand_ZeroOne() - 0.5f) * (pthis->scale * 20.0f); + pos.z = pthis->actor.world.pos.z; + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, scale, life); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_ANUBIS_FIRE - SFX_FLAG); + } +} + +void func_809B2B48(EnAnubiceFire* pthis, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + Color_RGBA8 primColor = { 255, 255, 0, 255 }; + Color_RGBA8 envColor = { 255, 0, 0, 255 }; + s32 pad; + s32 i; + + if (pthis->unk_15C == 0) { + for (i = 0; i < 20; i++) { + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z; + accel.x = Rand_CenteredFloat(8.0f); + accel.y = Rand_CenteredFloat(2.0f); + accel.z = Rand_CenteredFloat(8.0f); + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 2000, 10); + } + + pthis->unk_15C = 2; + pthis->unk_15E++; + if (pthis->unk_15E >= 6) { + Actor_Kill(&pthis->actor); + } + } +} + +void EnAnubiceFire_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAnubiceFire* pthis = (EnAnubiceFire*)thisx; + s32 pad; + s32 i; + + Actor_SetScale(&pthis->actor, pthis->scale); + pthis->actionFunc(pthis, globalCtx); + func_8002D7EC(&pthis->actor); + pthis->unk_160[0] = pthis->actor.world.pos; + + if (1) {} + + for (i = 4; i >= 0; i--) { + pthis->unk_160[i + 1] = pthis->unk_160[i]; + } + + if (pthis->unk_15A != 0) { + pthis->unk_15A--; + } + + if (pthis->unk_15C != 0) { + pthis->unk_15C--; + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 5.0f, 10.0f, 0x1D); + if (!(pthis->scale < 0.6f || pthis->actionFunc == func_809B2B48)) { + pthis->cylinder.dim.radius = pthis->scale * 15.0f + 5.0f; + pthis->cylinder.dim.height = pthis->scale * 15.0f + 5.0f; + pthis->cylinder.dim.yShift = pthis->scale * -0.75f + -15.0f; + + if (pthis->unk_15A != 0) { + Collider_UpdateCylinder(&pthis->actor, &pthis->cylinder); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder.base); + } + + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &pthis->actor.world.pos, 30.0f)) { + pthis->actor.velocity.x = pthis->actor.velocity.y = pthis->actor.velocity.z = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_ANUBIS_FIREBOMB); + pthis->actionFunc = func_809B2B48; + } + } +} + +void EnAnubiceFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* D_809B3270[] = { + gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, + }; + EnAnubiceFire* pthis = (EnAnubiceFire*)thisx; + s32 pad[2]; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice_fire.c", 503); + func_80093D84(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809B3270[0])); + + Matrix_Push(); + for (i = pthis->unk_15E; i < 6; ++i) { + f32 scale = pthis->actor.scale.x - (i * 0.2f); + + if (scale < 0.0f) { + scale = 0.0f; + } + + if (scale >= 0.1f) { + Matrix_Translate(pthis->unk_160[i].x, pthis->unk_160[i].y, pthis->unk_160[i].z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_RotateZ(pthis->actor.world.rot.z + i * 1000.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_anubice_fire.c", 546), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gAnubiceFireAttackDL); + } + + if (pthis->scale < 0.1f) { + break; + } + } + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_anubice_fire.c", 556); +} diff --git a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c deleted file mode 100644 index 14de0be9e..000000000 --- a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c +++ /dev/null @@ -1,110 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANUBICE_TAG_Z_EN_ANUBICE_TAG_C -#include "actor_common.h" -/* - * File: z_en_anubice_tag.c - * Overlay: ovl_En_Anubice_Tag - * Description: Spawns and manages the Anubis enemy - */ - -#include "z_en_anubice_tag.h" -#include "vt.h" -#include "def/z_actor.h" -#include "def/z_lib.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnAnubiceTag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAnubiceTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAnubiceTag_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAnubiceTag_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnAnubiceTag_SpawnAnubis(EnAnubiceTag* this, GlobalContext* globalCtx); -void EnAnubiceTag_ManageAnubis(EnAnubiceTag* this, GlobalContext* globalCtx); - -const ActorInit En_Anubice_Tag_InitVars = { - ACTOR_EN_ANUBICE_TAG, - ACTORCAT_SWITCH, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnAnubiceTag), - (ActorFunc)EnAnubiceTag_Init, - (ActorFunc)EnAnubiceTag_Destroy, - (ActorFunc)EnAnubiceTag_Update, - (ActorFunc)EnAnubiceTag_Draw, -}; - -void EnAnubiceTag_Init(Actor* thisx, GlobalContext* globalCtx) { - EnAnubiceTag* this = (EnAnubiceTag*)thisx; - - osSyncPrintf("\n\n"); - // "Anubis control tag generated" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ アヌビス制御タグ発生 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); - - if (this->actor.params < -1) { - this->actor.params = 0; - } - if (this->actor.params != 0) { - this->triggerRange = this->actor.params * 40.0f; - } - this->actionFunc = EnAnubiceTag_SpawnAnubis; -} - -void EnAnubiceTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnAnubiceTag_SpawnAnubis(EnAnubiceTag* this, GlobalContext* globalCtx) { - this->anubis = (EnAnubice*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ANUBICE, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, this->actor.yawTowardsPlayer, 0, 0); - - if (this->anubis != NULL) { - this->actionFunc = EnAnubiceTag_ManageAnubis; - } -} - -void EnAnubiceTag_ManageAnubis(EnAnubiceTag* this, GlobalContext* globalCtx) { - EnAnubice* anubis; - Vec3f offset; - - if (this->anubis != NULL) { - anubis = this->anubis; - if (anubis->actor.update == NULL) { - return; - } - } else { - Actor_Kill(&this->actor); - return; - } - - if (anubis->deathTimer != 0) { - Actor_Kill(&this->actor); - return; - } - - if (this->actor.xzDistToPlayer < (200.0f + this->triggerRange)) { - if (!anubis->isLinkOutOfRange) { - if (!anubis->isKnockedback) { - anubis->isMirroringLink = true; - offset.x = -Math_SinS(this->actor.yawTowardsPlayer) * this->actor.xzDistToPlayer; - offset.z = -Math_CosS(this->actor.yawTowardsPlayer) * this->actor.xzDistToPlayer; - Math_ApproachF(&anubis->actor.world.pos.x, (this->actor.world.pos.x + offset.x), 0.3f, 10.0f); - Math_ApproachF(&anubis->actor.world.pos.z, (this->actor.world.pos.z + offset.z), 0.3f, 10.0f); - return; - } - } - } else { - if (anubis->isMirroringLink) { - anubis->isLinkOutOfRange = true; - } - } -} - -void EnAnubiceTag_Update(Actor* thisx, GlobalContext* globalCtx) { - EnAnubiceTag* this = (EnAnubiceTag*)thisx; - - this->actionFunc(this, globalCtx); -} - -void EnAnubiceTag_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnAnubiceTag* this = (EnAnubiceTag*)thisx; -} diff --git a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.cpp b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.cpp new file mode 100644 index 000000000..cff79ec7f --- /dev/null +++ b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.cpp @@ -0,0 +1,110 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ANUBICE_TAG_Z_EN_ANUBICE_TAG_C +#include "actor_common.h" +/* + * File: z_en_anubice_tag.c + * Overlay: ovl_En_Anubice_Tag + * Description: Spawns and manages the Anubis enemy + */ + +#include "z_en_anubice_tag.h" +#include "vt.h" +#include "def/z_actor.h" +#include "def/z_lib.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnAnubiceTag_Init(Actor* thisx, GlobalContext* globalCtx); +void EnAnubiceTag_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnAnubiceTag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAnubiceTag_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnAnubiceTag_SpawnAnubis(EnAnubiceTag* pthis, GlobalContext* globalCtx); +void EnAnubiceTag_ManageAnubis(EnAnubiceTag* pthis, GlobalContext* globalCtx); + +ActorInit En_Anubice_Tag_InitVars = { + ACTOR_EN_ANUBICE_TAG, + ACTORCAT_SWITCH, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnAnubiceTag), + (ActorFunc)EnAnubiceTag_Init, + (ActorFunc)EnAnubiceTag_Destroy, + (ActorFunc)EnAnubiceTag_Update, + (ActorFunc)EnAnubiceTag_Draw, +}; + +void EnAnubiceTag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAnubiceTag* pthis = (EnAnubiceTag*)thisx; + + osSyncPrintf("\n\n"); + // "Anubis control tag generated" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ アヌビス制御タグ発生 ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params); + + if (pthis->actor.params < -1) { + pthis->actor.params = 0; + } + if (pthis->actor.params != 0) { + pthis->triggerRange = pthis->actor.params * 40.0f; + } + pthis->actionFunc = EnAnubiceTag_SpawnAnubis; +} + +void EnAnubiceTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnAnubiceTag_SpawnAnubis(EnAnubiceTag* pthis, GlobalContext* globalCtx) { + pthis->anubis = (EnAnubice*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ANUBICE, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, pthis->actor.yawTowardsPlayer, 0, 0); + + if (pthis->anubis != NULL) { + pthis->actionFunc = EnAnubiceTag_ManageAnubis; + } +} + +void EnAnubiceTag_ManageAnubis(EnAnubiceTag* pthis, GlobalContext* globalCtx) { + EnAnubice* anubis; + Vec3f offset; + + if (pthis->anubis != NULL) { + anubis = pthis->anubis; + if (anubis->actor.update == NULL) { + return; + } + } else { + Actor_Kill(&pthis->actor); + return; + } + + if (anubis->deathTimer != 0) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->actor.xzDistToPlayer < (200.0f + pthis->triggerRange)) { + if (!anubis->isLinkOutOfRange) { + if (!anubis->isKnockedback) { + anubis->isMirroringLink = true; + offset.x = -Math_SinS(pthis->actor.yawTowardsPlayer) * pthis->actor.xzDistToPlayer; + offset.z = -Math_CosS(pthis->actor.yawTowardsPlayer) * pthis->actor.xzDistToPlayer; + Math_ApproachF(&anubis->actor.world.pos.x, (pthis->actor.world.pos.x + offset.x), 0.3f, 10.0f); + Math_ApproachF(&anubis->actor.world.pos.z, (pthis->actor.world.pos.z + offset.z), 0.3f, 10.0f); + return; + } + } + } else { + if (anubis->isMirroringLink) { + anubis->isLinkOutOfRange = true; + } + } +} + +void EnAnubiceTag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAnubiceTag* pthis = (EnAnubiceTag*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void EnAnubiceTag_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAnubiceTag* pthis = (EnAnubiceTag*)thisx; +} diff --git a/src/overlays/actors/ovl_En_Arow_Trap/z_en_arow_trap.c b/src/overlays/actors/ovl_En_Arow_Trap/z_en_arow_trap.cpp similarity index 61% rename from src/overlays/actors/ovl_En_Arow_Trap/z_en_arow_trap.c rename to src/overlays/actors/ovl_En_Arow_Trap/z_en_arow_trap.cpp index b5acfc85c..23c1d8d9e 100644 --- a/src/overlays/actors/ovl_En_Arow_Trap/z_en_arow_trap.c +++ b/src/overlays/actors/ovl_En_Arow_Trap/z_en_arow_trap.cpp @@ -15,7 +15,7 @@ void EnArowTrap_Init(Actor* thisx, GlobalContext* globalCtx); void EnArowTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnArowTrap_Update(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Arow_Trap_InitVars = { +ActorInit En_Arow_Trap_InitVars = { ACTOR_EN_AROW_TRAP, ACTORCAT_PROP, FLAGS, @@ -28,28 +28,28 @@ const ActorInit En_Arow_Trap_InitVars = { }; void EnArowTrap_Init(Actor* thisx, GlobalContext* globalCtx) { - EnArowTrap* this = (EnArowTrap*)thisx; + EnArowTrap* pthis = (EnArowTrap*)thisx; - Actor_SetScale(&this->actor, 0.01); - this->unk_14C = 0; - this->attackTimer = 80; - this->actor.focus.pos = this->actor.world.pos; + Actor_SetScale(&pthis->actor, 0.01); + pthis->unk_14C = 0; + pthis->attackTimer = 80; + pthis->actor.focus.pos = pthis->actor.world.pos; } void EnArowTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnArowTrap_Update(Actor* thisx, GlobalContext* globalCtx) { - EnArowTrap* this = (EnArowTrap*)thisx; + EnArowTrap* pthis = (EnArowTrap*)thisx; - if (this->actor.xzDistToPlayer <= 400) { - this->attackTimer--; + if (pthis->actor.xzDistToPlayer <= 400) { + pthis->attackTimer--; - if (this->attackTimer == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, this->actor.shape.rot.z, ARROW_NORMAL_SILENT); - this->attackTimer = 80; + if (pthis->attackTimer == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, pthis->actor.shape.rot.x, + pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, ARROW_NORMAL_SILENT); + pthis->attackTimer = 80; } } } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c deleted file mode 100644 index a6ff9ae1f..000000000 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ /dev/null @@ -1,512 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ARROW_Z_EN_ARROW_C -#include "actor_common.h" -/* - * File: z_en_arrow.c - * Overlay: ovl_En_Arrow - * Description: Arrow, Deku Seed, and Deku Nut Projectile - */ - -#include "z_en_arrow.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnArrow_Shoot(EnArrow* this, GlobalContext* globalCtx); -void EnArrow_Fly(EnArrow* this, GlobalContext* globalCtx); -void func_809B45E0(EnArrow* this, GlobalContext* globalCtx); -void func_809B4640(EnArrow* this, GlobalContext* globalCtx); - -const ActorInit En_Arrow_InitVars = { - ACTOR_EN_ARROW, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnArrow), - (ActorFunc)EnArrow_Init, - (ActorFunc)EnArrow_Destroy, - (ActorFunc)EnArrow_Update, - (ActorFunc)EnArrow_Draw, -}; - -static ColliderQuadInit sColliderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_PLAYER, - AC_NONE, - OC1_NONE, - OC2_TYPE_PLAYER, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK2, - { 0x00000020, 0x00, 0x01 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(minVelocityY, -150, ICHAIN_STOP), -}; - -void EnArrow_SetupAction(EnArrow* this, EnArrowActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { - static EffectBlureInit2 blureNormal = { - 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, - 0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, - }; - static EffectBlureInit2 blureFire = { - 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, - 0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, - }; - static EffectBlureInit2 blureIce = { - 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, - 0, 1, 0, { 170, 255, 255, 255 }, { 0, 100, 255, 0 }, - }; - static EffectBlureInit2 blureLight = { - 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, - 0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, - }; - static u32 dmgFlags[] = { - 0x00000800, 0x00000020, 0x00000020, 0x00000800, 0x00001000, - 0x00002000, 0x00010000, 0x00004000, 0x00008000, 0x00000004, - }; - EnArrow* this = (EnArrow*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - - if (this->actor.params == ARROW_CS_NUT) { - this->isCsNut = true; - this->actor.params = ARROW_NUT; - } - - if (this->actor.params <= ARROW_SEED) { - - if (this->actor.params <= ARROW_0E) { - SkelAnime_Init(globalCtx, &this->skelAnime, &gArrowSkel, &gArrow2Anim, NULL, NULL, 0); - } - - if (this->actor.params <= ARROW_NORMAL) { - if (this->actor.params == ARROW_NORMAL_HORSE) { - blureNormal.elemDuration = 4; - } else { - blureNormal.elemDuration = 16; - } - - Effect_Add(globalCtx, &this->effectIndex, EFFECT_BLURE2, 0, 0, &blureNormal); - - } else if (this->actor.params == ARROW_FIRE) { - - Effect_Add(globalCtx, &this->effectIndex, EFFECT_BLURE2, 0, 0, &blureFire); - - } else if (this->actor.params == ARROW_ICE) { - - Effect_Add(globalCtx, &this->effectIndex, EFFECT_BLURE2, 0, 0, &blureIce); - - } else if (this->actor.params == ARROW_LIGHT) { - - Effect_Add(globalCtx, &this->effectIndex, EFFECT_BLURE2, 0, 0, &blureLight); - } - - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sColliderInit); - - if (this->actor.params <= ARROW_NORMAL) { - this->collider.info.toucherFlags &= ~0x18; - this->collider.info.toucherFlags |= 0; - } - - if (this->actor.params < 0) { - this->collider.base.atFlags = (AT_ON | AT_TYPE_ENEMY); - } else if (this->actor.params <= ARROW_SEED) { - this->collider.info.toucher.dmgFlags = dmgFlags[this->actor.params]; - LOG_HEX("this->at_info.cl_elem.at_btl_info.at_type", this->collider.info.toucher.dmgFlags, - "../z_en_arrow.c", 707); - } - } - - EnArrow_SetupAction(this, EnArrow_Shoot); -} - -void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnArrow* this = (EnArrow*)thisx; - - if (this->actor.params <= ARROW_LIGHT) { - Effect_Delete(globalCtx, this->effectIndex); - } - - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyQuad(globalCtx, &this->collider); - - if ((this->hitActor != NULL) && (this->hitActor->update != NULL)) { - this->hitActor->flags &= ~ACTOR_FLAG_15; - } -} - -void EnArrow_Shoot(EnArrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->actor.parent == NULL) { - if ((this->actor.params != ARROW_NUT) && (player->unk_A73 == 0)) { - Actor_Kill(&this->actor); - return; - } - - switch (this->actor.params) { - case ARROW_SEED: - func_8002F7DC(&player->actor, NA_SE_IT_SLING_SHOT); - break; - - case ARROW_NORMAL_LIT: - case ARROW_NORMAL_HORSE: - case ARROW_NORMAL: - func_8002F7DC(&player->actor, NA_SE_IT_ARROW_SHOT); - break; - - case ARROW_FIRE: - case ARROW_ICE: - case ARROW_LIGHT: - func_8002F7DC(&player->actor, NA_SE_IT_MAGIC_ARROW_SHOT); - break; - } - - EnArrow_SetupAction(this, EnArrow_Fly); - Math_Vec3f_Copy(&this->unk_210, &this->actor.world.pos); - - if (this->actor.params >= ARROW_SEED) { - func_8002D9A4(&this->actor, 80.0f); - this->timer = 15; - this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - } else { - func_8002D9A4(&this->actor, 150.0f); - this->timer = 12; - } - } -} - -void func_809B3CEC(GlobalContext* globalCtx, EnArrow* this) { - EnArrow_SetupAction(this, func_809B4640); - Animation_PlayOnce(&this->skelAnime, &gArrow1Anim); - this->actor.world.rot.y += (s32)(24576.0f * (Rand_ZeroOne() - 0.5f)) + 0x8000; - this->actor.velocity.y += (this->actor.speedXZ * (0.4f + (0.4f * Rand_ZeroOne()))); - this->actor.speedXZ *= (0.04f + 0.3f * Rand_ZeroOne()); - this->timer = 50; - this->actor.gravity = -1.5f; -} - -void EnArrow_CarryActor(EnArrow* this, GlobalContext* globalCtx) { - CollisionPoly* hitPoly; - Vec3f posDiffLastFrame; - Vec3f actorNextPos; - Vec3f hitPos; - f32 temp_f12; - f32 scale; - s32 bgId; - - Math_Vec3f_Diff(&this->actor.world.pos, &this->unk_210, &posDiffLastFrame); - - temp_f12 = ((this->actor.world.pos.x - this->hitActor->world.pos.x) * posDiffLastFrame.x) + - ((this->actor.world.pos.y - this->hitActor->world.pos.y) * posDiffLastFrame.y) + - ((this->actor.world.pos.z - this->hitActor->world.pos.z) * posDiffLastFrame.z); - - if (!(temp_f12 < 0.0f)) { - scale = Math3D_Vec3fMagnitudeSq(&posDiffLastFrame); - - if (!(scale < 1.0f)) { - scale = temp_f12 / scale; - Math_Vec3f_Scale(&posDiffLastFrame, scale); - Math_Vec3f_Sum(&this->hitActor->world.pos, &posDiffLastFrame, &actorNextPos); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->hitActor->world.pos, &actorNextPos, &hitPos, - &hitPoly, true, true, true, true, &bgId)) { - this->hitActor->world.pos.x = hitPos.x + ((actorNextPos.x <= hitPos.x) ? 1.0f : -1.0f); - this->hitActor->world.pos.y = hitPos.y + ((actorNextPos.y <= hitPos.y) ? 1.0f : -1.0f); - this->hitActor->world.pos.z = hitPos.z + ((actorNextPos.z <= hitPos.z) ? 1.0f : -1.0f); - } else { - Math_Vec3f_Copy(&this->hitActor->world.pos, &actorNextPos); - } - } - } -} - -void EnArrow_Fly(EnArrow* this, GlobalContext* globalCtx) { - CollisionPoly* hitPoly; - s32 bgId; - Vec3f hitPoint; - Vec3f posCopy; - s32 atTouched; - u16 sfxId; - Actor* hitActor; - Vec3f sp60; - Vec3f sp54; - - if (DECR(this->timer) == 0) { - Actor_Kill(&this->actor); - return; - } - - if (this->timer < 7.2000003f) { - this->actor.gravity = -0.4f; - } - - atTouched = (this->actor.params != ARROW_NORMAL_LIT) && (this->actor.params <= ARROW_SEED) && - (this->collider.base.atFlags & AT_HIT); - - if (atTouched || this->touchedPoly) { - if (this->actor.params >= ARROW_SEED) { - if (atTouched) { - this->actor.world.pos.x = (this->actor.world.pos.x + this->actor.prevPos.x) * 0.5f; - this->actor.world.pos.y = (this->actor.world.pos.y + this->actor.prevPos.y) * 0.5f; - this->actor.world.pos.z = (this->actor.world.pos.z + this->actor.prevPos.z) * 0.5f; - } - - if (this->actor.params == ARROW_NUT) { - iREG(50) = -1; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - sfxId = NA_SE_IT_DEKU; - } else { - sfxId = NA_SE_IT_SLING_REFLECT; - } - - EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, sfxId); - Actor_Kill(&this->actor); - } else { - EffectSsHitMark_SpawnCustomScale(globalCtx, 0, 150, &this->actor.world.pos); - - if (atTouched && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { - hitActor = this->collider.base.at; - - if ((hitActor->update != NULL) && (!(this->collider.base.atFlags & AT_BOUNCED)) && - (hitActor->flags & ACTOR_FLAG_14)) { - this->hitActor = hitActor; - EnArrow_CarryActor(this, globalCtx); - Math_Vec3f_Diff(&hitActor->world.pos, &this->actor.world.pos, &this->unk_250); - hitActor->flags |= ACTOR_FLAG_15; - this->collider.base.atFlags &= ~AT_HIT; - this->actor.speedXZ /= 2.0f; - this->actor.velocity.y /= 2.0f; - } else { - this->hitFlags |= 1; - this->hitFlags |= 2; - - if (this->collider.info.atHitInfo->bumperFlags & 2) { - this->actor.world.pos.x = this->collider.info.atHitInfo->bumper.hitPos.x; - this->actor.world.pos.y = this->collider.info.atHitInfo->bumper.hitPos.y; - this->actor.world.pos.z = this->collider.info.atHitInfo->bumper.hitPos.z; - } - - func_809B3CEC(globalCtx, this); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_ARROW_STICK_CRE); - } - } else if (this->touchedPoly) { - EnArrow_SetupAction(this, func_809B45E0); - Animation_PlayOnce(&this->skelAnime, &gArrow2Anim); - - if (this->actor.params >= ARROW_NORMAL_LIT) { - this->timer = 60; - } else { - this->timer = 20; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_IT_ARROW_STICK_OBJ); - this->hitFlags |= 1; - } - } - } else { - Math_Vec3f_Copy(&this->unk_210, &this->actor.world.pos); - Actor_MoveForward(&this->actor); - - if ((this->touchedPoly = - BgCheck_ProjectileLineTest(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, &hitPoint, - &this->actor.wallPoly, true, true, true, true, &bgId))) { - func_8002F9EC(globalCtx, &this->actor, this->actor.wallPoly, bgId, &hitPoint); - Math_Vec3f_Copy(&posCopy, &this->actor.world.pos); - Math_Vec3f_Copy(&this->actor.world.pos, &hitPoint); - } - - if (this->actor.params <= ARROW_0E) { - this->actor.shape.rot.x = Math_Atan2S(this->actor.speedXZ, -this->actor.velocity.y); - } - } - - if (this->hitActor != NULL) { - if (this->hitActor->update != NULL) { - Math_Vec3f_Sum(&this->unk_210, &this->unk_250, &sp60); - Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_250, &sp54); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &sp54, &hitPoint, &hitPoly, true, true, true, true, - &bgId)) { - this->hitActor->world.pos.x = hitPoint.x + ((sp54.x <= hitPoint.x) ? 1.0f : -1.0f); - this->hitActor->world.pos.y = hitPoint.y + ((sp54.y <= hitPoint.y) ? 1.0f : -1.0f); - this->hitActor->world.pos.z = hitPoint.z + ((sp54.z <= hitPoint.z) ? 1.0f : -1.0f); - Math_Vec3f_Diff(&this->hitActor->world.pos, &this->actor.world.pos, &this->unk_250); - this->hitActor->flags &= ~ACTOR_FLAG_15; - this->hitActor = NULL; - } else { - Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_250, &this->hitActor->world.pos); - } - - if (this->touchedPoly && (this->hitActor != NULL)) { - this->hitActor->flags &= ~ACTOR_FLAG_15; - this->hitActor = NULL; - } - } else { - this->hitActor = NULL; - } - } -} - -void func_809B45E0(EnArrow* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (DECR(this->timer) == 0) { - Actor_Kill(&this->actor); - } -} - -void func_809B4640(EnArrow* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Actor_MoveForward(&this->actor); - - if (DECR(this->timer) == 0) { - Actor_Kill(&this->actor); - } -} - -void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnArrow* this = (EnArrow*)thisx; - Player* player = GET_PLAYER(globalCtx); - - if (this->isCsNut || ((this->actor.params >= ARROW_NORMAL_LIT) && (player->unk_A73 != 0)) || - !Player_InBlockingCsMode(globalCtx, player)) { - this->actionFunc(this, globalCtx); - } - - if ((this->actor.params >= ARROW_FIRE) && (this->actor.params <= ARROW_0E)) { - s16 elementalActorIds[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT, - ACTOR_ARROW_FIRE, ACTOR_ARROW_FIRE, ACTOR_ARROW_FIRE }; - - if (this->actor.child == NULL) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, elementalActorIds[this->actor.params - 3], - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - } - } else if (this->actor.params == ARROW_NORMAL_LIT) { - static Vec3f velocity = { 0.0f, 0.5f, 0.0f }; - static Vec3f accel = { 0.0f, 0.5f, 0.0f }; - static Color_RGBA8 primColor = { 255, 255, 100, 255 }; - static Color_RGBA8 envColor = { 255, 50, 0, 0 }; - // spawn dust for the flame - func_8002836C(globalCtx, &this->unk_21C, &velocity, &accel, &primColor, &envColor, 100, 0, 8); - } -} - -void func_809B4800(EnArrow* this, GlobalContext* globalCtx) { - static Vec3f D_809B4E88 = { 0.0f, 400.0f, 1500.0f }; - static Vec3f D_809B4E94 = { 0.0f, -400.0f, 1500.0f }; - static Vec3f D_809B4EA0 = { 0.0f, 0.0f, -300.0f }; - Vec3f sp44; - Vec3f sp38; - s32 addBlureVertex; - - Matrix_MultVec3f(&D_809B4EA0, &this->unk_21C); - - if (EnArrow_Fly == this->actionFunc) { - Matrix_MultVec3f(&D_809B4E88, &sp44); - Matrix_MultVec3f(&D_809B4E94, &sp38); - - if (this->actor.params <= ARROW_SEED) { - addBlureVertex = this->actor.params <= ARROW_LIGHT; - - if (this->hitActor == NULL) { - addBlureVertex &= func_80090480(globalCtx, &this->collider, &this->weaponInfo, &sp44, &sp38); - } else { - if (addBlureVertex) { - if ((sp44.x == this->weaponInfo.tip.x) && (sp44.y == this->weaponInfo.tip.y) && - (sp44.z == this->weaponInfo.tip.z) && (sp38.x == this->weaponInfo.base.x) && - (sp38.y == this->weaponInfo.base.y) && (sp38.z == this->weaponInfo.base.z)) { - addBlureVertex = false; - } - } - } - - if (addBlureVertex) { - EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp44, &sp38); - } - } - } -} - -void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnArrow* this = (EnArrow*)thisx; - u8 alpha; - f32 scale; - - if (this->actor.params <= ARROW_0E) { - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawLod(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, this, - (this->actor.projectedPos.z < MREG(95)) ? 0 : 1); - } else if (this->actor.speedXZ != 0.0f) { - alpha = (Math_CosS(this->timer * 5000) * 127.5f) + 127.5f; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_arrow.c", 1346); - - func_80093C14(globalCtx->state.gfxCtx); - - if (this->actor.params == ARROW_SEED) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, alpha); - scale = 50.0f; - } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 12, 0, 0, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 0, alpha); - scale = 150.0f; - } - - Matrix_Push(); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - // redundant check because this is contained in an if block for non-zero speed - Matrix_RotateZ((this->actor.speedXZ == 0.0f) ? 0.0f - : ((globalCtx->gameplayFrames & 0xFF) * 4000) * (M_PI / 0x8000), - MTXMODE_APPLY); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_arrow.c", 1374), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); - Matrix_Pop(); - Matrix_RotateY(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_arrow.c", 1381); - } - - func_809B4800(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.cpp b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.cpp new file mode 100644 index 000000000..ec283d503 --- /dev/null +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.cpp @@ -0,0 +1,512 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ARROW_Z_EN_ARROW_C +#include "actor_common.h" +/* + * File: z_en_arrow.c + * Overlay: ovl_En_Arrow + * Description: Arrow, Deku Seed, and Deku Nut Projectile + */ + +#include "z_en_arrow.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx); +void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx); +void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnArrow_Shoot(EnArrow* pthis, GlobalContext* globalCtx); +void EnArrow_Fly(EnArrow* pthis, GlobalContext* globalCtx); +void func_809B45E0(EnArrow* pthis, GlobalContext* globalCtx); +void func_809B4640(EnArrow* pthis, GlobalContext* globalCtx); + +ActorInit En_Arrow_InitVars = { + ACTOR_EN_ARROW, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnArrow), + (ActorFunc)EnArrow_Init, + (ActorFunc)EnArrow_Destroy, + (ActorFunc)EnArrow_Update, + (ActorFunc)EnArrow_Draw, +}; + +static ColliderQuadInit sColliderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000020, 0x00, 0x01 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(minVelocityY, -150, ICHAIN_STOP), +}; + +void EnArrow_SetupAction(EnArrow* pthis, EnArrowActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { + static EffectBlureInit2 blureNormal = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, + }; + static EffectBlureInit2 blureFire = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, + }; + static EffectBlureInit2 blureIce = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 170, 255, 255, 255 }, { 0, 100, 255, 0 }, + }; + static EffectBlureInit2 blureLight = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, + }; + static u32 dmgFlags[] = { + 0x00000800, 0x00000020, 0x00000020, 0x00000800, 0x00001000, + 0x00002000, 0x00010000, 0x00004000, 0x00008000, 0x00000004, + }; + EnArrow* pthis = (EnArrow*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + + if (pthis->actor.params == ARROW_CS_NUT) { + pthis->isCsNut = true; + pthis->actor.params = ARROW_NUT; + } + + if (pthis->actor.params <= ARROW_SEED) { + + if (pthis->actor.params <= ARROW_0E) { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gArrowSkel, &gArrow2Anim, NULL, NULL, 0); + } + + if (pthis->actor.params <= ARROW_NORMAL) { + if (pthis->actor.params == ARROW_NORMAL_HORSE) { + blureNormal.elemDuration = 4; + } else { + blureNormal.elemDuration = 16; + } + + Effect_Add(globalCtx, &pthis->effectIndex, EFFECT_BLURE2, 0, 0, &blureNormal); + + } else if (pthis->actor.params == ARROW_FIRE) { + + Effect_Add(globalCtx, &pthis->effectIndex, EFFECT_BLURE2, 0, 0, &blureFire); + + } else if (pthis->actor.params == ARROW_ICE) { + + Effect_Add(globalCtx, &pthis->effectIndex, EFFECT_BLURE2, 0, 0, &blureIce); + + } else if (pthis->actor.params == ARROW_LIGHT) { + + Effect_Add(globalCtx, &pthis->effectIndex, EFFECT_BLURE2, 0, 0, &blureLight); + } + + Collider_InitQuad(globalCtx, &pthis->collider); + Collider_SetQuad(globalCtx, &pthis->collider, &pthis->actor, &sColliderInit); + + if (pthis->actor.params <= ARROW_NORMAL) { + pthis->collider.info.toucherFlags &= ~0x18; + pthis->collider.info.toucherFlags |= 0; + } + + if (pthis->actor.params < 0) { + pthis->collider.base.atFlags = (AT_ON | AT_TYPE_ENEMY); + } else if (pthis->actor.params <= ARROW_SEED) { + pthis->collider.info.toucher.dmgFlags = dmgFlags[pthis->actor.params]; + LOG_HEX("pthis->at_info.cl_elem.at_btl_info.at_type", pthis->collider.info.toucher.dmgFlags, + "../z_en_arrow.c", 707); + } + } + + EnArrow_SetupAction(pthis, EnArrow_Shoot); +} + +void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* pthis = (EnArrow*)thisx; + + if (pthis->actor.params <= ARROW_LIGHT) { + Effect_Delete(globalCtx, pthis->effectIndex); + } + + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyQuad(globalCtx, &pthis->collider); + + if ((pthis->hitActor != NULL) && (pthis->hitActor->update != NULL)) { + pthis->hitActor->flags &= ~ACTOR_FLAG_15; + } +} + +void EnArrow_Shoot(EnArrow* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actor.parent == NULL) { + if ((pthis->actor.params != ARROW_NUT) && (player->unk_A73 == 0)) { + Actor_Kill(&pthis->actor); + return; + } + + switch (pthis->actor.params) { + case ARROW_SEED: + func_8002F7DC(&player->actor, NA_SE_IT_SLING_SHOT); + break; + + case ARROW_NORMAL_LIT: + case ARROW_NORMAL_HORSE: + case ARROW_NORMAL: + func_8002F7DC(&player->actor, NA_SE_IT_ARROW_SHOT); + break; + + case ARROW_FIRE: + case ARROW_ICE: + case ARROW_LIGHT: + func_8002F7DC(&player->actor, NA_SE_IT_MAGIC_ARROW_SHOT); + break; + } + + EnArrow_SetupAction(pthis, EnArrow_Fly); + Math_Vec3f_Copy(&pthis->unk_210, &pthis->actor.world.pos); + + if (pthis->actor.params >= ARROW_SEED) { + func_8002D9A4(&pthis->actor, 80.0f); + pthis->timer = 15; + pthis->actor.shape.rot.x = pthis->actor.shape.rot.y = pthis->actor.shape.rot.z = 0; + } else { + func_8002D9A4(&pthis->actor, 150.0f); + pthis->timer = 12; + } + } +} + +void func_809B3CEC(GlobalContext* globalCtx, EnArrow* pthis) { + EnArrow_SetupAction(pthis, func_809B4640); + Animation_PlayOnce(&pthis->skelAnime, &gArrow1Anim); + pthis->actor.world.rot.y += (s32)(24576.0f * (Rand_ZeroOne() - 0.5f)) + 0x8000; + pthis->actor.velocity.y += (pthis->actor.speedXZ * (0.4f + (0.4f * Rand_ZeroOne()))); + pthis->actor.speedXZ *= (0.04f + 0.3f * Rand_ZeroOne()); + pthis->timer = 50; + pthis->actor.gravity = -1.5f; +} + +void EnArrow_CarryActor(EnArrow* pthis, GlobalContext* globalCtx) { + CollisionPoly* hitPoly; + Vec3f posDiffLastFrame; + Vec3f actorNextPos; + Vec3f hitPos; + f32 temp_f12; + f32 scale; + s32 bgId; + + Math_Vec3f_Diff(&pthis->actor.world.pos, &pthis->unk_210, &posDiffLastFrame); + + temp_f12 = ((pthis->actor.world.pos.x - pthis->hitActor->world.pos.x) * posDiffLastFrame.x) + + ((pthis->actor.world.pos.y - pthis->hitActor->world.pos.y) * posDiffLastFrame.y) + + ((pthis->actor.world.pos.z - pthis->hitActor->world.pos.z) * posDiffLastFrame.z); + + if (!(temp_f12 < 0.0f)) { + scale = Math3D_Vec3fMagnitudeSq(&posDiffLastFrame); + + if (!(scale < 1.0f)) { + scale = temp_f12 / scale; + Math_Vec3f_Scale(&posDiffLastFrame, scale); + Math_Vec3f_Sum(&pthis->hitActor->world.pos, &posDiffLastFrame, &actorNextPos); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->hitActor->world.pos, &actorNextPos, &hitPos, + &hitPoly, true, true, true, true, &bgId)) { + pthis->hitActor->world.pos.x = hitPos.x + ((actorNextPos.x <= hitPos.x) ? 1.0f : -1.0f); + pthis->hitActor->world.pos.y = hitPos.y + ((actorNextPos.y <= hitPos.y) ? 1.0f : -1.0f); + pthis->hitActor->world.pos.z = hitPos.z + ((actorNextPos.z <= hitPos.z) ? 1.0f : -1.0f); + } else { + Math_Vec3f_Copy(&pthis->hitActor->world.pos, &actorNextPos); + } + } + } +} + +void EnArrow_Fly(EnArrow* pthis, GlobalContext* globalCtx) { + CollisionPoly* hitPoly; + s32 bgId; + Vec3f hitPoint; + Vec3f posCopy; + s32 atTouched; + u16 sfxId; + Actor* hitActor; + Vec3f sp60; + Vec3f sp54; + + if (DECR(pthis->timer) == 0) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->timer < 7.2000003f) { + pthis->actor.gravity = -0.4f; + } + + atTouched = (pthis->actor.params != ARROW_NORMAL_LIT) && (pthis->actor.params <= ARROW_SEED) && + (pthis->collider.base.atFlags & AT_HIT); + + if (atTouched || pthis->touchedPoly) { + if (pthis->actor.params >= ARROW_SEED) { + if (atTouched) { + pthis->actor.world.pos.x = (pthis->actor.world.pos.x + pthis->actor.prevPos.x) * 0.5f; + pthis->actor.world.pos.y = (pthis->actor.world.pos.y + pthis->actor.prevPos.y) * 0.5f; + pthis->actor.world.pos.z = (pthis->actor.world.pos.z + pthis->actor.prevPos.z) * 0.5f; + } + + if (pthis->actor.params == ARROW_NUT) { + iREG(50) = -1; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_M_FIRE1, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); + sfxId = NA_SE_IT_DEKU; + } else { + sfxId = NA_SE_IT_SLING_REFLECT; + } + + EffectSsStone1_Spawn(globalCtx, &pthis->actor.world.pos, 0); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, sfxId); + Actor_Kill(&pthis->actor); + } else { + EffectSsHitMark_SpawnCustomScale(globalCtx, 0, 150, &pthis->actor.world.pos); + + if (atTouched && (pthis->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { + hitActor = pthis->collider.base.at; + + if ((hitActor->update != NULL) && (!(pthis->collider.base.atFlags & AT_BOUNCED)) && + (hitActor->flags & ACTOR_FLAG_14)) { + pthis->hitActor = hitActor; + EnArrow_CarryActor(pthis, globalCtx); + Math_Vec3f_Diff(&hitActor->world.pos, &pthis->actor.world.pos, &pthis->unk_250); + hitActor->flags |= ACTOR_FLAG_15; + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->actor.speedXZ /= 2.0f; + pthis->actor.velocity.y /= 2.0f; + } else { + pthis->hitFlags |= 1; + pthis->hitFlags |= 2; + + if (pthis->collider.info.atHitInfo->bumperFlags & 2) { + pthis->actor.world.pos.x = pthis->collider.info.atHitInfo->bumper.hitPos.x; + pthis->actor.world.pos.y = pthis->collider.info.atHitInfo->bumper.hitPos.y; + pthis->actor.world.pos.z = pthis->collider.info.atHitInfo->bumper.hitPos.z; + } + + func_809B3CEC(globalCtx, pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_ARROW_STICK_CRE); + } + } else if (pthis->touchedPoly) { + EnArrow_SetupAction(pthis, func_809B45E0); + Animation_PlayOnce(&pthis->skelAnime, &gArrow2Anim); + + if (pthis->actor.params >= ARROW_NORMAL_LIT) { + pthis->timer = 60; + } else { + pthis->timer = 20; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_ARROW_STICK_OBJ); + pthis->hitFlags |= 1; + } + } + } else { + Math_Vec3f_Copy(&pthis->unk_210, &pthis->actor.world.pos); + Actor_MoveForward(&pthis->actor); + + if ((pthis->touchedPoly = + BgCheck_ProjectileLineTest(&globalCtx->colCtx, &pthis->actor.prevPos, &pthis->actor.world.pos, &hitPoint, + &pthis->actor.wallPoly, true, true, true, true, &bgId))) { + func_8002F9EC(globalCtx, &pthis->actor, pthis->actor.wallPoly, bgId, &hitPoint); + Math_Vec3f_Copy(&posCopy, &pthis->actor.world.pos); + Math_Vec3f_Copy(&pthis->actor.world.pos, &hitPoint); + } + + if (pthis->actor.params <= ARROW_0E) { + pthis->actor.shape.rot.x = Math_Atan2S(pthis->actor.speedXZ, -pthis->actor.velocity.y); + } + } + + if (pthis->hitActor != NULL) { + if (pthis->hitActor->update != NULL) { + Math_Vec3f_Sum(&pthis->unk_210, &pthis->unk_250, &sp60); + Math_Vec3f_Sum(&pthis->actor.world.pos, &pthis->unk_250, &sp54); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &sp54, &hitPoint, &hitPoly, true, true, true, true, + &bgId)) { + pthis->hitActor->world.pos.x = hitPoint.x + ((sp54.x <= hitPoint.x) ? 1.0f : -1.0f); + pthis->hitActor->world.pos.y = hitPoint.y + ((sp54.y <= hitPoint.y) ? 1.0f : -1.0f); + pthis->hitActor->world.pos.z = hitPoint.z + ((sp54.z <= hitPoint.z) ? 1.0f : -1.0f); + Math_Vec3f_Diff(&pthis->hitActor->world.pos, &pthis->actor.world.pos, &pthis->unk_250); + pthis->hitActor->flags &= ~ACTOR_FLAG_15; + pthis->hitActor = NULL; + } else { + Math_Vec3f_Sum(&pthis->actor.world.pos, &pthis->unk_250, &pthis->hitActor->world.pos); + } + + if (pthis->touchedPoly && (pthis->hitActor != NULL)) { + pthis->hitActor->flags &= ~ACTOR_FLAG_15; + pthis->hitActor = NULL; + } + } else { + pthis->hitActor = NULL; + } + } +} + +void func_809B45E0(EnArrow* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (DECR(pthis->timer) == 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_809B4640(EnArrow* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Actor_MoveForward(&pthis->actor); + + if (DECR(pthis->timer) == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnArrow* pthis = (EnArrow*)thisx; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->isCsNut || ((pthis->actor.params >= ARROW_NORMAL_LIT) && (player->unk_A73 != 0)) || + !Player_InBlockingCsMode(globalCtx, player)) { + pthis->actionFunc(pthis, globalCtx); + } + + if ((pthis->actor.params >= ARROW_FIRE) && (pthis->actor.params <= ARROW_0E)) { + s16 elementalActorIds[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT, + ACTOR_ARROW_FIRE, ACTOR_ARROW_FIRE, ACTOR_ARROW_FIRE }; + + if (pthis->actor.child == NULL) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, elementalActorIds[pthis->actor.params - 3], + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); + } + } else if (pthis->actor.params == ARROW_NORMAL_LIT) { + static Vec3f velocity = { 0.0f, 0.5f, 0.0f }; + static Vec3f accel = { 0.0f, 0.5f, 0.0f }; + static Color_RGBA8 primColor = { 255, 255, 100, 255 }; + static Color_RGBA8 envColor = { 255, 50, 0, 0 }; + // spawn dust for the flame + func_8002836C(globalCtx, &pthis->unk_21C, &velocity, &accel, &primColor, &envColor, 100, 0, 8); + } +} + +void func_809B4800(EnArrow* pthis, GlobalContext* globalCtx) { + static Vec3f D_809B4E88 = { 0.0f, 400.0f, 1500.0f }; + static Vec3f D_809B4E94 = { 0.0f, -400.0f, 1500.0f }; + static Vec3f D_809B4EA0 = { 0.0f, 0.0f, -300.0f }; + Vec3f sp44; + Vec3f sp38; + s32 addBlureVertex; + + Matrix_MultVec3f(&D_809B4EA0, &pthis->unk_21C); + + if (EnArrow_Fly == pthis->actionFunc) { + Matrix_MultVec3f(&D_809B4E88, &sp44); + Matrix_MultVec3f(&D_809B4E94, &sp38); + + if (pthis->actor.params <= ARROW_SEED) { + addBlureVertex = pthis->actor.params <= ARROW_LIGHT; + + if (pthis->hitActor == NULL) { + addBlureVertex &= func_80090480(globalCtx, &pthis->collider, &pthis->weaponInfo, &sp44, &sp38); + } else { + if (addBlureVertex) { + if ((sp44.x == pthis->weaponInfo.tip.x) && (sp44.y == pthis->weaponInfo.tip.y) && + (sp44.z == pthis->weaponInfo.tip.z) && (sp38.x == pthis->weaponInfo.base.x) && + (sp38.y == pthis->weaponInfo.base.y) && (sp38.z == pthis->weaponInfo.base.z)) { + addBlureVertex = false; + } + } + } + + if (addBlureVertex) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->effectIndex), &sp44, &sp38); + } + } + } +} + +void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnArrow* pthis = (EnArrow*)thisx; + u8 alpha; + f32 scale; + + if (pthis->actor.params <= ARROW_0E) { + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawLod(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, pthis, + (pthis->actor.projectedPos.z < MREG(95)) ? 0 : 1); + } else if (pthis->actor.speedXZ != 0.0f) { + alpha = (Math_CosS(pthis->timer * 5000) * 127.5f) + 127.5f; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_arrow.c", 1346); + + func_80093C14(globalCtx->state.gfxCtx); + + if (pthis->actor.params == ARROW_SEED) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, alpha); + scale = 50.0f; + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 12, 0, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 0, alpha); + scale = 150.0f; + } + + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + // redundant check because pthis is contained in an if block for non-zero speed + Matrix_RotateZ((pthis->actor.speedXZ == 0.0f) ? 0.0f + : ((globalCtx->gameplayFrames & 0xFF) * 4000) * (M_PI / 0x8000), + MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_arrow.c", 1374), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); + Matrix_Pop(); + Matrix_RotateY(pthis->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_arrow.c", 1381); + } + + func_809B4800(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c deleted file mode 100644 index 7ef0bf4ea..000000000 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ /dev/null @@ -1,411 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ATTACK_NIW_Z_EN_ATTACK_NIW_C -#include "actor_common.h" -/* - * File: z_en_attack_niw.c - * Overlay: ovl_En_Attack_Niw - * Description: Attacking Cucco, not solid - */ - -#include "z_en_attack_niw.h" -#include "objects/object_niw/object_niw.h" -#include "overlays/actors/ovl_En_Niw/z_en_niw.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809B5670(EnAttackNiw* this, GlobalContext* globalCtx); -void func_809B5C18(EnAttackNiw* this, GlobalContext* globalCtx); -void func_809B59B0(EnAttackNiw* this, GlobalContext* globalCtx); - -const ActorInit En_Attack_Niw_InitVars = { - ACTOR_EN_ATTACK_NIW, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_NIW, - sizeof(EnAttackNiw), - (ActorFunc)EnAttackNiw_Init, - (ActorFunc)EnAttackNiw_Destroy, - (ActorFunc)EnAttackNiw_Update, - (ActorFunc)EnAttackNiw_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { - EnAttackNiw* this = (EnAttackNiw*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCuccoSkel, &gCuccoAnim, this->jointTable, this->morphTable, 16); - if (this->actor.params < 0) { - this->actor.params = 0; - } - Actor_SetScale(&this->actor, 0.01f); - this->actor.gravity = 0.0f; - this->unk_298.x = Rand_CenteredFloat(100.0f); - this->unk_298.y = Rand_CenteredFloat(10.0f); - this->unk_298.z = Rand_CenteredFloat(100.0f); - Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; - this->actionFunc = func_809B5670; -} - -void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnAttackNiw* this = (EnAttackNiw*)thisx; - EnNiw* cucco = (EnNiw*)this->actor.parent; - - if (this->actor.parent != NULL) { - if ((cucco->actor.update != NULL) && (cucco->unk_296 > 0)) { - cucco->unk_296--; - } - } -} - -void func_809B5268(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { - if (this->unk_254 == 0) { - if (arg2 == 0) { - this->unk_264 = 0.0f; - } else { - this->unk_264 = -10000.0f; - } - this->unk_28E++; - this->unk_254 = 3; - if ((this->unk_28E & 1) == 0) { - this->unk_264 = 0.0f; - if (arg2 == 0) { - this->unk_254 = Rand_ZeroFloat(30.0f); - } - } - } - - if (this->unk_258 == 0) { - this->unk_292++; - this->unk_292 &= 1; - switch (arg2) { - case 0: - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; - break; - case 1: - this->unk_258 = 3; - this->unk_26C = 7000.0f; - this->unk_268 = 7000.0f; - if (this->unk_292 == 0) { - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; - } - break; - case 2: - this->unk_258 = 2; - this->unk_268 = this->unk_26C = -10000.0f; - this->unk_280 = this->unk_278 = 25000.0f; - this->unk_284 = this->unk_27C = 6000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 8000.0f; - this->unk_280 = 8000.0f; - } - break; - case 3: - this->unk_258 = 2; - this->unk_278 = 10000.0f; - this->unk_280 = 10000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 3000.0f; - this->unk_280 = 3000.0f; - } - break; - case 4: - this->unk_254 = this->unk_256 = 5; - break; - case 5: - this->unk_258 = 5; - this->unk_278 = 14000.0f; - this->unk_280 = 14000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 10000.0f; - this->unk_280 = 10000.0f; - } - break; - } - } - - if (this->unk_288 != this->unk_2C0) { - Math_ApproachF(&this->unk_2C0, this->unk_288, 0.5f, 4000.0f); - } - if (this->unk_264 != this->unk_2BC) { - Math_ApproachF(&this->unk_2BC, this->unk_264, 0.5f, 4000.0f); - } - if (this->unk_26C != this->unk_2A4.x) { - Math_ApproachF(&this->unk_2A4.x, this->unk_26C, 0.8f, 7000.0f); - } - if (this->unk_280 != this->unk_2A4.y) { - Math_ApproachF(&this->unk_2A4.y, this->unk_280, 0.8f, 7000.0f); - } - if (this->unk_284 != this->unk_2A4.z) { - Math_ApproachF(&this->unk_2A4.z, this->unk_284, 0.8f, 7000.0f); - } - if (this->unk_268 != this->unk_2B0.x) { - Math_ApproachF(&this->unk_2B0.x, this->unk_268, 0.8f, 7000.0f); - } - if (this->unk_278 != this->unk_2B0.y) { - Math_ApproachF(&this->unk_2B0.y, this->unk_278, 0.8f, 7000.0f); - } - if (this->unk_27C != this->unk_2B0.z) { - Math_ApproachF(&this->unk_2B0.z, this->unk_27C, 0.8f, 7000.0f); - } -} - -s32 func_809B55EC(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp1E; - s16 sp1C; - - Actor_SetFocus(&this->actor, this->unk_2E4); - Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); - if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || - (sp1C > SCREEN_HEIGHT)) { - return 0; - } else { - return 1; - } -} - -void func_809B5670(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp4E; - s16 sp4C; - f32 tmpf1; - f32 tmpf2; - f32 tmpf3; - Vec3f sp34; - - this->actor.speedXZ = 10.0f; - - tmpf1 = (this->unk_298.x + globalCtx->view.lookAt.x) - globalCtx->view.eye.x; - tmpf2 = (this->unk_298.y + globalCtx->view.lookAt.y) - globalCtx->view.eye.y; - tmpf3 = (this->unk_298.z + globalCtx->view.lookAt.z) - globalCtx->view.eye.z; - - sp34.x = globalCtx->view.lookAt.x + tmpf1; - sp34.y = globalCtx->view.lookAt.y + tmpf2; - sp34.z = globalCtx->view.lookAt.z + tmpf3; - - this->unk_2D4 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); - this->unk_2D0 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; - - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2D4, 5, this->unk_2DC, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2D0, 5, this->unk_2DC, 0); - Math_ApproachF(&this->unk_2DC, 5000.0f, 1.0f, 100.0f); - - Actor_SetFocus(&this->actor, this->unk_2E4); - Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); - - if (this->actor.bgCheckFlags & 8) { - this->unk_2D4 = this->actor.yawTowardsPlayer; - this->unk_2D0 = this->actor.world.rot.x - 3000.0f; - this->unk_2DC = 0.0f; - this->unk_284 = 0.0f; - this->unk_27C = 0.0f; - this->unk_254 = this->unk_256 = this->unk_258 = this->unk_25A = 0; - this->unk_25C = 0x64; - this->actor.gravity = -0.2f; - this->unk_2E0 = 5.0f; - this->unk_288 = 0.0f; - this->actionFunc = func_809B59B0; - } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && - (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && - (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || - (this->actor.bgCheckFlags & 1)) { - - this->unk_2D4 = this->actor.yawTowardsPlayer; - this->unk_2D0 = this->actor.world.rot.x - 2000.0f; - this->unk_2DC = 0.0f; - this->unk_27C = 0.0f; - this->unk_284 = 0.0f; - this->unk_254 = this->unk_256 = this->unk_258 = this->unk_25A = 0; - this->actor.gravity = -0.2f; - this->unk_2E0 = 5.0f; - this->unk_288 = 0.0f; - this->actionFunc = func_809B59B0; - } else { - this->unk_254 = 10; - this->unk_264 = -10000.0f; - this->unk_288 = -3000.0f; - func_809B5268(this, globalCtx, 2); - } -} - -void func_809B59B0(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809B55EC(this, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - - if (this->actor.bgCheckFlags & 1) { - if (this->unk_25A == 0) { - this->unk_25A = 3; - this->actor.velocity.y = 3.5f; - } - if (this->actor.gravity != -2.0f) { - this->unk_280 = this->unk_278 = 14000.0f; - this->unk_2D0 = this->unk_26C = this->unk_268 = this->unk_284 = this->unk_27C = 0.0f; - this->unk_2D4 = this->actor.yawTowardsPlayer; - this->unk_262 = 0x32; - this->unk_25C = 0x64; - this->actor.gravity = -2.0f; - } - } - if (this->unk_25C == 0x32) { - this->unk_2D4 = Rand_CenteredFloat(200.0f) + this->actor.yawTowardsPlayer; - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2D4, 2, this->unk_2DC, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2D0, 2, this->unk_2DC, 0); - Math_ApproachF(&this->unk_2DC, 10000.0f, 1.0f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, this->unk_2E0, 0.9f, 1.0f); - if ((this->actor.gravity == -2.0f) && (this->unk_262 == 0) && - ((this->actor.bgCheckFlags & 8) || (this->unk_25C == 0))) { - this->unk_2E0 = 0.0f; - this->actor.gravity = 0.0f; - this->unk_2DC = 0.0f; - this->unk_2D0 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_809B5C18; - } else if (this->actor.bgCheckFlags & 1) { - func_809B5268(this, globalCtx, 5); - } else { - func_809B5268(this, globalCtx, 2); - } -} - -void func_809B5C18(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809B55EC(this, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2D0, 5, this->unk_2DC, 0); - Math_ApproachF(&this->unk_2DC, 5000.0f, 1.0f, 100.0f); - Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); - func_809B5268(this, globalCtx, 2); -} - -void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { - f32 tmpf1; - EnAttackNiw* this = (EnAttackNiw*)thisx; - EnNiw* cucco; - Player* player = GET_PLAYER(globalCtx); - s32 pad; - Vec3f sp30; - GlobalContext* globalCtx2 = globalCtx; - - this->unk_28C++; - if (this->unk_254 != 0) { - this->unk_254--; - } - if (this->unk_258 != 0) { - this->unk_258--; - } - if (this->unk_25A != 0) { - this->unk_25A--; - } - if (this->unk_25E != 0) { - this->unk_25E--; - } - if (this->unk_260 != 0) { - this->unk_260--; - } - if (this->unk_25C != 0) { - this->unk_25C--; - } - if (this->unk_262 != 0) { - this->unk_262--; - } - - this->actor.shape.rot = this->actor.world.rot; - this->actor.shape.shadowScale = 15.0f; - this->actionFunc(this, globalCtx2); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - - if (this->actionFunc == func_809B5670) { - func_8002D97C(&this->actor); - } else { - Actor_MoveForward(&this->actor); - } - - if (this->actor.floorHeight <= BGCHECK_Y_MIN) { - Actor_Kill(&this->actor); - return; - } - - if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_809B5C18)) { - Math_Vec3f_Copy(&sp30, &this->actor.world.pos); - sp30.y += this->actor.yDistToWater; - EffectSsGSplash_Spawn(globalCtx, &sp30, 0, 0, 0, 0x190); - this->unk_2DC = 0.0f; - this->actor.gravity = 0.0f; - this->unk_2E0 = 0.0f; - this->unk_2D0 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_809B5C18; - return; - } - - tmpf1 = 20.0f; - if (this->actor.xyzDistToPlayerSq < SQ(tmpf1)) { - cucco = (EnNiw*)this->actor.parent; - if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (cucco != NULL) && - (cucco->timer9 == 0) && (player->invincibilityTimer == 0)) { - func_8002F6D4(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); - cucco->timer9 = 0x46; - } - } - if (this->unk_25E == 0) { - this->unk_25E = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - } - if (this->unk_260 == 0) { - this->unk_260 = 7; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_WAKEUP); - } -} - -s32 func_809B5F98(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnAttackNiw* this = (EnAttackNiw*)thisx; - Vec3f sp0 = { 0.0f, 0.0f, 0.0f }; - - if (limbIndex == 13) { - rot->y += (s16)this->unk_2BC; - } - if (limbIndex == 15) { - rot->z += (s16)this->unk_2C0; - } - if (limbIndex == 11) { - rot->x += (s16)this->unk_2B0.z; - rot->y += (s16)this->unk_2B0.y; - rot->z += (s16)this->unk_2B0.x; - } - if (limbIndex == 7) { - rot->x += (s16)this->unk_2A4.z; - rot->y += (s16)this->unk_2A4.y; - rot->z += (s16)this->unk_2A4.x; - } - return 0; -} - -void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnAttackNiw* this = (EnAttackNiw*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - func_809B5F98, NULL, this); -} diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.cpp b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.cpp new file mode 100644 index 000000000..c546dccce --- /dev/null +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.cpp @@ -0,0 +1,411 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ATTACK_NIW_Z_EN_ATTACK_NIW_C +#include "actor_common.h" +/* + * File: z_en_attack_niw.c + * Overlay: ovl_En_Attack_Niw + * Description: Attacking Cucco, not solid + */ + +#include "z_en_attack_niw.h" +#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx); +void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809B5670(EnAttackNiw* pthis, GlobalContext* globalCtx); +void func_809B5C18(EnAttackNiw* pthis, GlobalContext* globalCtx); +void func_809B59B0(EnAttackNiw* pthis, GlobalContext* globalCtx); + +ActorInit En_Attack_Niw_InitVars = { + ACTOR_EN_ATTACK_NIW, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_NIW, + sizeof(EnAttackNiw), + (ActorFunc)EnAttackNiw_Init, + (ActorFunc)EnAttackNiw_Destroy, + (ActorFunc)EnAttackNiw_Update, + (ActorFunc)EnAttackNiw_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* pthis = (EnAttackNiw*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCuccoSkel, &gCuccoAnim, pthis->jointTable, pthis->morphTable, 16); + if (pthis->actor.params < 0) { + pthis->actor.params = 0; + } + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.gravity = 0.0f; + pthis->unk_298.x = Rand_CenteredFloat(100.0f); + pthis->unk_298.y = Rand_CenteredFloat(10.0f); + pthis->unk_298.z = Rand_CenteredFloat(100.0f); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; + pthis->actionFunc = func_809B5670; +} + +void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* pthis = (EnAttackNiw*)thisx; + EnNiw* cucco = (EnNiw*)pthis->actor.parent; + + if (pthis->actor.parent != NULL) { + if ((cucco->actor.update != NULL) && (cucco->unk_296 > 0)) { + cucco->unk_296--; + } + } +} + +void func_809B5268(EnAttackNiw* pthis, GlobalContext* globalCtx, s16 arg2) { + if (pthis->unk_254 == 0) { + if (arg2 == 0) { + pthis->unk_264 = 0.0f; + } else { + pthis->unk_264 = -10000.0f; + } + pthis->unk_28E++; + pthis->unk_254 = 3; + if ((pthis->unk_28E & 1) == 0) { + pthis->unk_264 = 0.0f; + if (arg2 == 0) { + pthis->unk_254 = Rand_ZeroFloat(30.0f); + } + } + } + + if (pthis->unk_258 == 0) { + pthis->unk_292++; + pthis->unk_292 &= 1; + switch (arg2) { + case 0: + pthis->unk_26C = 0.0f; + pthis->unk_268 = 0.0f; + break; + case 1: + pthis->unk_258 = 3; + pthis->unk_26C = 7000.0f; + pthis->unk_268 = 7000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_26C = 0.0f; + pthis->unk_268 = 0.0f; + } + break; + case 2: + pthis->unk_258 = 2; + pthis->unk_268 = pthis->unk_26C = -10000.0f; + pthis->unk_280 = pthis->unk_278 = 25000.0f; + pthis->unk_284 = pthis->unk_27C = 6000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_278 = 8000.0f; + pthis->unk_280 = 8000.0f; + } + break; + case 3: + pthis->unk_258 = 2; + pthis->unk_278 = 10000.0f; + pthis->unk_280 = 10000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_278 = 3000.0f; + pthis->unk_280 = 3000.0f; + } + break; + case 4: + pthis->unk_254 = pthis->unk_256 = 5; + break; + case 5: + pthis->unk_258 = 5; + pthis->unk_278 = 14000.0f; + pthis->unk_280 = 14000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_278 = 10000.0f; + pthis->unk_280 = 10000.0f; + } + break; + } + } + + if (pthis->unk_288 != pthis->unk_2C0) { + Math_ApproachF(&pthis->unk_2C0, pthis->unk_288, 0.5f, 4000.0f); + } + if (pthis->unk_264 != pthis->unk_2BC) { + Math_ApproachF(&pthis->unk_2BC, pthis->unk_264, 0.5f, 4000.0f); + } + if (pthis->unk_26C != pthis->unk_2A4.x) { + Math_ApproachF(&pthis->unk_2A4.x, pthis->unk_26C, 0.8f, 7000.0f); + } + if (pthis->unk_280 != pthis->unk_2A4.y) { + Math_ApproachF(&pthis->unk_2A4.y, pthis->unk_280, 0.8f, 7000.0f); + } + if (pthis->unk_284 != pthis->unk_2A4.z) { + Math_ApproachF(&pthis->unk_2A4.z, pthis->unk_284, 0.8f, 7000.0f); + } + if (pthis->unk_268 != pthis->unk_2B0.x) { + Math_ApproachF(&pthis->unk_2B0.x, pthis->unk_268, 0.8f, 7000.0f); + } + if (pthis->unk_278 != pthis->unk_2B0.y) { + Math_ApproachF(&pthis->unk_2B0.y, pthis->unk_278, 0.8f, 7000.0f); + } + if (pthis->unk_27C != pthis->unk_2B0.z) { + Math_ApproachF(&pthis->unk_2B0.z, pthis->unk_27C, 0.8f, 7000.0f); + } +} + +s32 func_809B55EC(EnAttackNiw* pthis, GlobalContext* globalCtx) { + s16 sp1E; + s16 sp1C; + + Actor_SetFocus(&pthis->actor, pthis->unk_2E4); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp1E, &sp1C); + if ((pthis->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || + (sp1C > SCREEN_HEIGHT)) { + return 0; + } else { + return 1; + } +} + +void func_809B5670(EnAttackNiw* pthis, GlobalContext* globalCtx) { + s16 sp4E; + s16 sp4C; + f32 tmpf1; + f32 tmpf2; + f32 tmpf3; + Vec3f sp34; + + pthis->actor.speedXZ = 10.0f; + + tmpf1 = (pthis->unk_298.x + globalCtx->view.lookAt.x) - globalCtx->view.eye.x; + tmpf2 = (pthis->unk_298.y + globalCtx->view.lookAt.y) - globalCtx->view.eye.y; + tmpf3 = (pthis->unk_298.z + globalCtx->view.lookAt.z) - globalCtx->view.eye.z; + + sp34.x = globalCtx->view.lookAt.x + tmpf1; + sp34.y = globalCtx->view.lookAt.y + tmpf2; + sp34.z = globalCtx->view.lookAt.z + tmpf3; + + pthis->unk_2D4 = Math_Vec3f_Yaw(&pthis->actor.world.pos, &sp34); + pthis->unk_2D0 = Math_Vec3f_Pitch(&pthis->actor.world.pos, &sp34) * -1.0f; + + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_2D4, 5, pthis->unk_2DC, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.x, pthis->unk_2D0, 5, pthis->unk_2DC, 0); + Math_ApproachF(&pthis->unk_2DC, 5000.0f, 1.0f, 100.0f); + + Actor_SetFocus(&pthis->actor, pthis->unk_2E4); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp4E, &sp4C); + + if (pthis->actor.bgCheckFlags & 8) { + pthis->unk_2D4 = pthis->actor.yawTowardsPlayer; + pthis->unk_2D0 = pthis->actor.world.rot.x - 3000.0f; + pthis->unk_2DC = 0.0f; + pthis->unk_284 = 0.0f; + pthis->unk_27C = 0.0f; + pthis->unk_254 = pthis->unk_256 = pthis->unk_258 = pthis->unk_25A = 0; + pthis->unk_25C = 0x64; + pthis->actor.gravity = -0.2f; + pthis->unk_2E0 = 5.0f; + pthis->unk_288 = 0.0f; + pthis->actionFunc = func_809B59B0; + } else if (((pthis->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - pthis->actor.world.pos.x) < 50.0f) && + (fabsf(sp34.y - pthis->actor.world.pos.y) < 50.0f) && + (fabsf(sp34.z - pthis->actor.world.pos.z) < 50.0f)) || + (pthis->actor.bgCheckFlags & 1)) { + + pthis->unk_2D4 = pthis->actor.yawTowardsPlayer; + pthis->unk_2D0 = pthis->actor.world.rot.x - 2000.0f; + pthis->unk_2DC = 0.0f; + pthis->unk_27C = 0.0f; + pthis->unk_284 = 0.0f; + pthis->unk_254 = pthis->unk_256 = pthis->unk_258 = pthis->unk_25A = 0; + pthis->actor.gravity = -0.2f; + pthis->unk_2E0 = 5.0f; + pthis->unk_288 = 0.0f; + pthis->actionFunc = func_809B59B0; + } else { + pthis->unk_254 = 10; + pthis->unk_264 = -10000.0f; + pthis->unk_288 = -3000.0f; + func_809B5268(pthis, globalCtx, 2); + } +} + +void func_809B59B0(EnAttackNiw* pthis, GlobalContext* globalCtx) { + if (!func_809B55EC(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->unk_25A == 0) { + pthis->unk_25A = 3; + pthis->actor.velocity.y = 3.5f; + } + if (pthis->actor.gravity != -2.0f) { + pthis->unk_280 = pthis->unk_278 = 14000.0f; + pthis->unk_2D0 = pthis->unk_26C = pthis->unk_268 = pthis->unk_284 = pthis->unk_27C = 0.0f; + pthis->unk_2D4 = pthis->actor.yawTowardsPlayer; + pthis->unk_262 = 0x32; + pthis->unk_25C = 0x64; + pthis->actor.gravity = -2.0f; + } + } + if (pthis->unk_25C == 0x32) { + pthis->unk_2D4 = Rand_CenteredFloat(200.0f) + pthis->actor.yawTowardsPlayer; + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_2D4, 2, pthis->unk_2DC, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.x, pthis->unk_2D0, 2, pthis->unk_2DC, 0); + Math_ApproachF(&pthis->unk_2DC, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&pthis->actor.speedXZ, pthis->unk_2E0, 0.9f, 1.0f); + if ((pthis->actor.gravity == -2.0f) && (pthis->unk_262 == 0) && + ((pthis->actor.bgCheckFlags & 8) || (pthis->unk_25C == 0))) { + pthis->unk_2E0 = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->unk_2DC = 0.0f; + pthis->unk_2D0 = pthis->actor.world.rot.x - 5000.0f; + pthis->actionFunc = func_809B5C18; + } else if (pthis->actor.bgCheckFlags & 1) { + func_809B5268(pthis, globalCtx, 5); + } else { + func_809B5268(pthis, globalCtx, 2); + } +} + +void func_809B5C18(EnAttackNiw* pthis, GlobalContext* globalCtx) { + if (!func_809B55EC(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + Math_SmoothStepToS(&pthis->actor.world.rot.x, pthis->unk_2D0, 5, pthis->unk_2DC, 0); + Math_ApproachF(&pthis->unk_2DC, 5000.0f, 1.0f, 100.0f); + Math_ApproachF(&pthis->actor.velocity.y, 5.0f, 0.3f, 1.0f); + func_809B5268(pthis, globalCtx, 2); +} + +void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 tmpf1; + EnAttackNiw* pthis = (EnAttackNiw*)thisx; + EnNiw* cucco; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + Vec3f sp30; + GlobalContext* globalCtx2 = globalCtx; + + pthis->unk_28C++; + if (pthis->unk_254 != 0) { + pthis->unk_254--; + } + if (pthis->unk_258 != 0) { + pthis->unk_258--; + } + if (pthis->unk_25A != 0) { + pthis->unk_25A--; + } + if (pthis->unk_25E != 0) { + pthis->unk_25E--; + } + if (pthis->unk_260 != 0) { + pthis->unk_260--; + } + if (pthis->unk_25C != 0) { + pthis->unk_25C--; + } + if (pthis->unk_262 != 0) { + pthis->unk_262--; + } + + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->actor.shape.shadowScale = 15.0f; + pthis->actionFunc(pthis, globalCtx2); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 0x1D); + + if (pthis->actionFunc == func_809B5670) { + func_8002D97C(&pthis->actor); + } else { + Actor_MoveForward(&pthis->actor); + } + + if (pthis->actor.floorHeight <= BGCHECK_Y_MIN) { + Actor_Kill(&pthis->actor); + return; + } + + if ((pthis->actor.bgCheckFlags & 0x20) && (pthis->actionFunc != func_809B5C18)) { + Math_Vec3f_Copy(&sp30, &pthis->actor.world.pos); + sp30.y += pthis->actor.yDistToWater; + EffectSsGSplash_Spawn(globalCtx, &sp30, 0, 0, 0, 0x190); + pthis->unk_2DC = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->unk_2E0 = 0.0f; + pthis->unk_2D0 = pthis->actor.world.rot.x - 5000.0f; + pthis->actionFunc = func_809B5C18; + return; + } + + tmpf1 = 20.0f; + if (pthis->actor.xyzDistToPlayerSq < SQ(tmpf1)) { + cucco = (EnNiw*)pthis->actor.parent; + if ((pthis->actor.parent->update != NULL) && (pthis->actor.parent != NULL) && (cucco != NULL) && + (cucco->timer9 == 0) && (player->invincibilityTimer == 0)) { + func_8002F6D4(globalCtx, &pthis->actor, 2.0f, pthis->actor.world.rot.y, 0.0f, 0x10); + cucco->timer9 = 0x46; + } + } + if (pthis->unk_25E == 0) { + pthis->unk_25E = 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_A); + } + if (pthis->unk_260 == 0) { + pthis->unk_260 = 7; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_WAKEUP); + } +} + +s32 func_809B5F98(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnAttackNiw* pthis = (EnAttackNiw*)thisx; + Vec3f sp0 = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 13) { + rot->y += (s16)pthis->unk_2BC; + } + if (limbIndex == 15) { + rot->z += (s16)pthis->unk_2C0; + } + if (limbIndex == 11) { + rot->x += (s16)pthis->unk_2B0.z; + rot->y += (s16)pthis->unk_2B0.y; + rot->z += (s16)pthis->unk_2B0.x; + } + if (limbIndex == 7) { + rot->x += (s16)pthis->unk_2A4.z; + rot->y += (s16)pthis->unk_2A4.y; + rot->z += (s16)pthis->unk_2A4.x; + } + return 0; +} + +void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* pthis = (EnAttackNiw*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + func_809B5F98, NULL, pthis); +} diff --git a/src/overlays/actors/ovl_En_Ba/z_en_ba.c b/src/overlays/actors/ovl_En_Ba/z_en_ba.c deleted file mode 100644 index d8d2aaea0..000000000 --- a/src/overlays/actors/ovl_En_Ba/z_en_ba.c +++ /dev/null @@ -1,533 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BA_Z_EN_BA_C -#include "actor_common.h" -/* - * File: z_en_ba.c - * Overlay: ovl_En_Ba - * Description: Tentacle from inside Lord Jabu-Jabu - */ - -#include "z_en_ba.h" -#include "objects/object_bxa/object_bxa.h" -#include "def/graph.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnBa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBa_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBa_SetupIdle(EnBa* this); -void EnBa_SetupFallAsBlob(EnBa* this); -void EnBa_Idle(EnBa* this, GlobalContext* globalCtx); -void EnBa_FallAsBlob(EnBa* this, GlobalContext* globalCtx); -void EnBa_SwingAtPlayer(EnBa* this, GlobalContext* globalCtx); -void EnBa_RecoilFromDamage(EnBa* this, GlobalContext* globalCtx); -void EnBa_Die(EnBa* this, GlobalContext* globalCtx); -void EnBa_SetupSwingAtPlayer(EnBa* this); - -const ActorInit En_Ba_InitVars = { - ACTOR_EN_BA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BXA, - sizeof(EnBa), - (ActorFunc)EnBa_Init, - (ActorFunc)EnBa_Destroy, - (ActorFunc)EnBa_Update, - (ActorFunc)EnBa_Draw, -}; - -static Vec3f D_809B8080 = { 0.0f, 0.0f, 32.0f }; - -static ColliderJntSphElementInit sJntSphElementInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000010, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 8, { { 0, 0, 0 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x20000000, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { 13, { { 0, 0, 0 }, 25 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_JNTSPH, - }, - 2, - sJntSphElementInit, -}; - -void EnBa_SetupAction(EnBa* this, EnBaActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -static Vec3f D_809B80E4 = { 0.01f, 0.01f, 0.01f }; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x15, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 2500, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void EnBa_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBa* this = (EnBa*)thisx; - Vec3f sp38 = D_809B80E4; - s32 pad; - s16 i; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.world.pos.y = this->actor.home.pos.y + 100.0f; - for (i = 13; i >= 0; i--) { - this->unk200[i] = sp38; - this->unk2A8[i].x = -0x4000; - this->unk158[i] = this->actor.world.pos; - this->unk158[i].y = this->actor.world.pos.y - (i + 1) * 32.0f; - } - - this->actor.targetMode = 4; - this->upperParams = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - - if (this->actor.params < EN_BA_DEAD_BLOB) { - if (Flags_GetSwitch(globalCtx, this->upperParams)) { - Actor_Kill(&this->actor); - return; - } - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); - Actor_SetScale(&this->actor, 0.01f); - EnBa_SetupIdle(this); - this->actor.colChkInfo.health = 4; - this->actor.colChkInfo.mass = MASS_HEAVY; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - } else { - Actor_SetScale(&this->actor, 0.021f); - EnBa_SetupFallAsBlob(this); - } -} - -void EnBa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBa* this = (EnBa*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnBa_SetupIdle(EnBa* this) { - this->unk14C = 2; - this->unk31C = 1500; - this->actor.speedXZ = 10.0f; - EnBa_SetupAction(this, EnBa_Idle); -} - -void EnBa_Idle(EnBa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 i; - s32 pad; - Vec3s sp5C; - - if ((this->actor.colChkInfo.mass == MASS_IMMOVABLE) && (this->actor.xzDistToPlayer > 175.0f)) { - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 330.0f, 1.0f, 7.0f, 0.0f); - } else { - this->actor.flags |= ACTOR_FLAG_0; - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 100.0f, 1.0f, 10.0f, 0.0f); - } - this->unk2FC = this->actor.world.pos; - if (globalCtx->gameplayFrames % 16 == 0) { - this->unk308.z += Rand_CenteredFloat(180.0f); - this->unk314 += Rand_CenteredFloat(180.0f); - this->unk308.x = Math_SinF(this->unk308.z) * 80.0f; - this->unk308.y = Math_CosF(this->unk314) * 80.0f; - } - this->unk2FC.y -= 448.0f; - this->unk2FC.x += this->unk308.x; - this->unk2FC.z += this->unk308.y; - func_80033AEC(&this->unk2FC, &this->unk158[13], 1.0f, this->actor.speedXZ, 0.0f, 0.0f); - for (i = 12; i >= 0; i--) { - func_80035844(&this->unk158[i + 1], &this->unk158[i], &sp5C, 0); - Matrix_Translate(this->unk158[i + 1].x, this->unk158[i + 1].y, this->unk158[i + 1].z, MTXMODE_NEW); - Matrix_RotateZYX(sp5C.x, sp5C.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i]); - } - func_80035844(&this->unk158[0], &this->unk2FC, &sp5C, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk2A8[0].y, 3, this->unk31C, 182); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk2A8[0].x, 3, this->unk31C, 182); - Matrix_RotateZYX(this->actor.shape.rot.x - 0x8000, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[0]); - this->unk2A8[13].y = sp5C.y; - this->unk2A8[13].x = sp5C.x + 0x8000; - - for (i = 0; i < 13; i++) { - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Math_SmoothStepToS(&this->unk2A8[i].y, this->unk2A8[i + 1].y, 3, this->unk31C, 182); - Math_SmoothStepToS(&this->unk2A8[i].x, this->unk2A8[i + 1].x, 3, this->unk31C, 182); - Matrix_RotateZYX(this->unk2A8[i].x - 0x8000, this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i + 1]); - } - this->unk2A8[13].x = this->unk2A8[12].x; - this->unk2A8[13].y = this->unk2A8[12].y; - if (!(player->stateFlags1 & 0x4000000) && (this->actor.xzDistToPlayer <= 175.0f) && - (this->actor.world.pos.y == this->actor.home.pos.y + 100.0f)) { - EnBa_SetupSwingAtPlayer(this); - } -} - -void EnBa_SetupFallAsBlob(EnBa* this) { - this->unk14C = 0; - this->actor.speedXZ = Rand_CenteredFloat(8.0f); - this->actor.world.rot.y = Rand_CenteredFloat(65535.0f); - this->unk318 = 20; - this->actor.gravity = -2.0f; - EnBa_SetupAction(this, EnBa_FallAsBlob); -} - -/** - * Action function of the pink fleshy blobs that spawn and fall to the floor when a tentacle dies - */ -void EnBa_FallAsBlob(EnBa* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { - this->actor.scale.y -= 0.001f; - this->actor.scale.x += 0.0005f; - this->actor.scale.z += 0.0005f; - this->unk318--; - if (this->unk318 == 0) { - Actor_Kill(&this->actor); - } - } else { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 28.0f, 80.0f, 5); - } -} - -void EnBa_SetupSwingAtPlayer(EnBa* this) { - this->unk14C = 3; - this->unk318 = 20; - this->unk31A = 0; - this->unk31C = 1500; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.speedXZ = 20.0f; - EnBa_SetupAction(this, EnBa_SwingAtPlayer); -} - -void EnBa_SwingAtPlayer(EnBa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 temp; - s16 i; - Vec3s sp58; - s16 phi_fp; - - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 60.0f, 1.0f, 10.0f, 0.0f); - if ((this->actor.xzDistToPlayer <= 175.0f) || (this->unk31A != 0)) { - if (this->unk318 == 20) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_HAND_UP); - this->unk31C = 1500; - } - if (this->unk318 != 0) { - this->unk31A = 10; - this->unk318--; - if (this->unk318 >= 11) { - this->unk2FC = player->actor.world.pos; - this->unk2FC.y += 30.0f; - phi_fp = this->actor.yawTowardsPlayer; - } else { - phi_fp = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk2FC); - } - Math_SmoothStepToS(&this->unk31C, 1500, 1, 30, 0); - func_80035844(&this->actor.world.pos, &this->unk158[0], &sp58, 0); - Math_SmoothStepToS(&this->actor.shape.rot.y, sp58.y, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->actor.shape.rot.x, (sp58.x + 0x8000), 1, this->unk31C, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX((this->actor.shape.rot.x - 0x8000), this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[0]); - - for (i = 0; i < 13; i++) { - Math_SmoothStepToS(&this->unk2A8[i].x, (i * 1200) - 0x4000, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->unk2A8[i].y, phi_fp, 1, this->unk31C, 0); - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Matrix_RotateZYX((this->unk2A8[i].x - 0x8000), this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i + 1]); - } - } else { - if (this->unk31A == 10) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_HAND_DOWN); - } - if (this->unk31A != 0) { - this->unk31C = 8000; - this->actor.speedXZ = 30.0f; - phi_fp = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk2FC); - temp = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk158[0]) + 0x8000; - Math_SmoothStepToS(&this->actor.shape.rot.y, phi_fp, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->actor.shape.rot.x, temp, 1, this->unk31C, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateZYX(this->actor.shape.rot.x - 0x8000, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, this->unk158); - - for (i = 0; i < 13; i++) { - temp = -Math_CosS(this->unk31A * 0xCCC) * (i * 1200); - Math_SmoothStepToS(&this->unk2A8[i].x, temp - 0x4000, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->unk2A8[i].y, phi_fp, 1, this->unk31C, 0); - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Matrix_RotateZYX(this->unk2A8[i].x - 0x8000, this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i + 1]); - } - this->unk31A--; - } else if ((this->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & 0x4000000)) { - EnBa_SetupIdle(this); - } else { - EnBa_SetupSwingAtPlayer(this); - this->unk318 = 27; - this->unk31C = 750; - } - } - this->unk2A8[13].x = this->unk2A8[12].x; - this->unk2A8[13].y = this->unk2A8[12].y; - if (this->collider.base.atFlags & 2) { - this->collider.base.atFlags &= ~2; - if (this->collider.base.at == &player->actor) { - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); - } - } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - return; - } - if ((this->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & 0x4000000)) { - EnBa_SetupIdle(this); - } else { - EnBa_SetupSwingAtPlayer(this); - this->unk318 = 27; - this->unk31C = 750; - } -} - -void func_809B7174(EnBa* this) { - this->unk14C = 1; - this->unk31C = 1500; - this->unk318 = 20; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BALINADE_HAND_DAMAGE); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 12); - EnBa_SetupAction(this, EnBa_RecoilFromDamage); -} - -void EnBa_RecoilFromDamage(EnBa* this, GlobalContext* globalCtx) { - s32 i; - Vec3s sp6C; - - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 330.0f, 1.0f, 30.0f, 0.0f); - this->unk2FC = this->actor.world.pos; - if (globalCtx->gameplayFrames % 16 == 0) { - this->unk308.z += Rand_CenteredFloat(180.0f); - this->unk314 += Rand_CenteredFloat(180.0f); - this->unk308.x = Math_SinF(this->unk308.z) * 80.0f; - this->unk308.y = Math_CosF(this->unk314) * 80.0f; - } - this->unk2FC.y -= 448.0f; - this->unk2FC.x += this->unk308.x; - this->unk2FC.z += this->unk308.y; - func_80033AEC(&this->unk2FC, &this->unk158[13], 1.0f, this->actor.speedXZ, 0.0f, 0.0f); - for (i = 12; i >= 0; i--) { - func_80035844(&this->unk158[i + 1], &this->unk158[i], &sp6C, 0); - Matrix_Translate(this->unk158[i + 1].x, this->unk158[i + 1].y, this->unk158[i + 1].z, MTXMODE_NEW); - Matrix_RotateZYX(sp6C.x, sp6C.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i]); - } - func_80035844(&this->actor.world.pos, &this->unk158[0], &sp6C, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Math_SmoothStepToS(&this->actor.shape.rot.y, sp6C.y, 3, this->unk31C, 182); - Math_SmoothStepToS(&this->actor.shape.rot.x, sp6C.x + 0x8000, 3, this->unk31C, 182); - Matrix_RotateZYX(this->actor.shape.rot.x - 0x8000, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[0]); - - for (i = 0; i < 13; i++) { - func_80035844(&this->unk158[i], &this->unk158[i + 1], &sp6C, 0); - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Math_SmoothStepToS(&this->unk2A8[i].y, sp6C.y, 3, this->unk31C, 182); - Math_SmoothStepToS(&this->unk2A8[i].x, sp6C.x + 0x8000, 3, this->unk31C, 182); - Matrix_RotateZYX(this->unk2A8[i].x - 0x8000, this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i + 1]); - } - - this->unk2A8[13].x = this->unk2A8[12].x; - this->unk2A8[13].y = this->unk2A8[12].y; - this->unk318--; - if (this->unk318 == 0) { - EnBa_SetupIdle(this); - } -} - -void func_809B75A0(EnBa* this, GlobalContext* globalCtx2) { - s16 unk_temp; - s32 i; - Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; - GlobalContext* globalCtx = globalCtx2; - - this->unk31C = 2500; - EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_BALINADE_HAND_DEAD, 1, 1, 40); - this->unk14C = 0; - - for (i = 7; i < 14; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BA, this->unk158[i].x, this->unk158[i].y, - this->unk158[i].z, 0, 0, 0, EN_BA_DEAD_BLOB); - } - unk_temp = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk158[0]) + 0x8000; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->actor.shape.rot.x, unk_temp, 1, this->unk31C, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.shape.rot.x - 0x8000, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[0]); - this->actor.flags &= ~ACTOR_FLAG_0; - for (i = 5; i < 13; i++) { - Math_SmoothStepToS(&this->unk2A8[i].x, this->unk2A8[5].x, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->unk2A8[i].y, this->unk2A8[5].y, 1, this->unk31C, 0); - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Matrix_RotateZYX(this->unk2A8[i].x - 0x8000, this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&sp74, &this->unk158[i + 1]); - } - this->unk31A = 15; - EnBa_SetupAction(this, EnBa_Die); -} - -void EnBa_Die(EnBa* this, GlobalContext* globalCtx) { - Vec3f sp6C = { 0.0f, 0.0f, 0.0f }; - s16 temp; - s32 i; - - if (this->unk31A != 0) { - this->actor.speedXZ = 30.0f; - this->unk31C = 8000; - this->actor.world.pos.y += 8.0f; - temp = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk158[0]) + 0x8000; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->actor.shape.rot.x, temp, 1, this->unk31C, 0); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.shape.rot.x - 0x8000, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[0]); - for (i = 0; i < 5; i++) { - temp = -Math_CosS(this->unk31A * 0x444) * (i * 400); - Math_SmoothStepToS(&this->unk2A8[i].x, temp - 0x4000, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->unk2A8[i].y, this->actor.yawTowardsPlayer, 1, this->unk31C, 0); - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Matrix_RotateZYX(this->unk2A8[i].x - 0x8000, this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&D_809B8080, &this->unk158[i + 1]); - } - for (i = 5; i < 13; i++) { - Math_SmoothStepToS(&this->unk2A8[i].x, this->unk2A8[5].x, 1, this->unk31C, 0); - Math_SmoothStepToS(&this->unk2A8[i].y, this->unk2A8[5].y, 1, this->unk31C, 0); - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Matrix_RotateZYX(this->unk2A8[i].x - 0x8000, this->unk2A8[i].y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&sp6C, &this->unk158[i + 1]); - } - this->unk31A--; - } else { - Flags_SetSwitch(globalCtx, this->upperParams); - Actor_Kill(&this->actor); - } -} - -void EnBa_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBa* this = (EnBa*)thisx; - - if ((this->actor.params < EN_BA_DEAD_BLOB) && (this->collider.base.acFlags & 2)) { - this->collider.base.acFlags &= ~2; - this->actor.colChkInfo.health--; - if (this->actor.colChkInfo.health == 0) { - func_809B75A0(this, globalCtx); - } else { - func_809B7174(this); - } - } - this->actionFunc(this, globalCtx); - if (this->actor.params < EN_BA_DEAD_BLOB) { - this->actor.focus.pos = this->unk158[6]; - } - if (this->unk14C >= 2) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -static void* D_809B8118[] = { - object_bxa_Tex_0024F0, - object_bxa_Tex_0027F0, - object_bxa_Tex_0029F0, -}; - -void EnBa_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBa* this = (EnBa*)thisx; - s32 pad; - s16 i; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 14); - Vec3f unused = { 0.0f, 0.0f, 448.0f }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ba.c", 933); - func_80093D18(globalCtx->state.gfxCtx); - if (this->actor.params < EN_BA_DEAD_BLOB) { - Matrix_Push(); - gSPSegment(POLY_OPA_DISP++, 0x0C, mtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809B8118[this->actor.params])); - gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 16, 1, 0, - (globalCtx->gameplayFrames * -10) % 128, 32, 32)); - for (i = 0; i < 14; i++, mtx++) { - Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); - Matrix_RotateZYX(this->unk2A8[i].x, this->unk2A8[i].y, this->unk2A8[i].z, MTXMODE_APPLY); - Matrix_Scale(this->unk200[i].x, this->unk200[i].y, this->unk200[i].z, MTXMODE_APPLY); - if ((i == 6) || (i == 13)) { - switch (i) { - case 13: - Collider_UpdateSpheres(i, &this->collider); - break; - default: - Matrix_Scale(0.5f, 0.5f, 1.0f, MTXMODE_APPLY); - Collider_UpdateSpheres(8, &this->collider); - break; - } - } - Matrix_ToMtx(mtx, "../z_en_ba.c", 970); - } - Matrix_Pop(); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ba.c", 973), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_bxa_DL_000890); - } else { - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->gameplayFrames * 2) % 128, - (globalCtx->gameplayFrames * 2) % 128, 32, 32, 1, - (globalCtx->gameplayFrames * -5) % 128, (globalCtx->gameplayFrames * -5) % 128, 32, - 32)); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 125, 100, 255); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ba.c", 991), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_bxa_DL_001D80); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ba.c", 995); -} diff --git a/src/overlays/actors/ovl_En_Ba/z_en_ba.cpp b/src/overlays/actors/ovl_En_Ba/z_en_ba.cpp new file mode 100644 index 000000000..a9637fc7a --- /dev/null +++ b/src/overlays/actors/ovl_En_Ba/z_en_ba.cpp @@ -0,0 +1,533 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BA_Z_EN_BA_C +#include "actor_common.h" +/* + * File: z_en_ba.c + * Overlay: ovl_En_Ba + * Description: Tentacle from inside Lord Jabu-Jabu + */ + +#include "z_en_ba.h" +#include "objects/object_bxa/object_bxa.h" +#include "def/graph.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnBa_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBa_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBa_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBa_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBa_SetupIdle(EnBa* pthis); +void EnBa_SetupFallAsBlob(EnBa* pthis); +void EnBa_Idle(EnBa* pthis, GlobalContext* globalCtx); +void EnBa_FallAsBlob(EnBa* pthis, GlobalContext* globalCtx); +void EnBa_SwingAtPlayer(EnBa* pthis, GlobalContext* globalCtx); +void EnBa_RecoilFromDamage(EnBa* pthis, GlobalContext* globalCtx); +void EnBa_Die(EnBa* pthis, GlobalContext* globalCtx); +void EnBa_SetupSwingAtPlayer(EnBa* pthis); + +ActorInit En_Ba_InitVars = { + ACTOR_EN_BA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BXA, + sizeof(EnBa), + (ActorFunc)EnBa_Init, + (ActorFunc)EnBa_Destroy, + (ActorFunc)EnBa_Update, + (ActorFunc)EnBa_Draw, +}; + +static Vec3f D_809B8080 = { 0.0f, 0.0f, 32.0f }; + +static ColliderJntSphElementInit sJntSphElementInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000010, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 8, { { 0, 0, 0 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { 13, { { 0, 0, 0 }, 25 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementInit, +}; + +void EnBa_SetupAction(EnBa* pthis, EnBaActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +static Vec3f D_809B80E4 = { 0.01f, 0.01f, 0.01f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x15, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 2500, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void EnBa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBa* pthis = (EnBa*)thisx; + Vec3f sp38 = D_809B80E4; + s32 pad; + s16 i; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 100.0f; + for (i = 13; i >= 0; i--) { + pthis->unk200[i] = sp38; + pthis->unk2A8[i].x = -0x4000; + pthis->unk158[i] = pthis->actor.world.pos; + pthis->unk158[i].y = pthis->actor.world.pos.y - (i + 1) * 32.0f; + } + + pthis->actor.targetMode = 4; + pthis->upperParams = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + + if (pthis->actor.params < EN_BA_DEAD_BLOB) { + if (Flags_GetSwitch(globalCtx, pthis->upperParams)) { + Actor_Kill(&pthis->actor); + return; + } + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); + Actor_SetScale(&pthis->actor, 0.01f); + EnBa_SetupIdle(pthis); + pthis->actor.colChkInfo.health = 4; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + } else { + Actor_SetScale(&pthis->actor, 0.021f); + EnBa_SetupFallAsBlob(pthis); + } +} + +void EnBa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBa* pthis = (EnBa*)thisx; + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnBa_SetupIdle(EnBa* pthis) { + pthis->unk14C = 2; + pthis->unk31C = 1500; + pthis->actor.speedXZ = 10.0f; + EnBa_SetupAction(pthis, EnBa_Idle); +} + +void EnBa_Idle(EnBa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 pad; + Vec3s sp5C; + + if ((pthis->actor.colChkInfo.mass == MASS_IMMOVABLE) && (pthis->actor.xzDistToPlayer > 175.0f)) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 330.0f, 1.0f, 7.0f, 0.0f); + } else { + pthis->actor.flags |= ACTOR_FLAG_0; + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 100.0f, 1.0f, 10.0f, 0.0f); + } + pthis->unk2FC = pthis->actor.world.pos; + if (globalCtx->gameplayFrames % 16 == 0) { + pthis->unk308.z += Rand_CenteredFloat(180.0f); + pthis->unk314 += Rand_CenteredFloat(180.0f); + pthis->unk308.x = Math_SinF(pthis->unk308.z) * 80.0f; + pthis->unk308.y = Math_CosF(pthis->unk314) * 80.0f; + } + pthis->unk2FC.y -= 448.0f; + pthis->unk2FC.x += pthis->unk308.x; + pthis->unk2FC.z += pthis->unk308.y; + func_80033AEC(&pthis->unk2FC, &pthis->unk158[13], 1.0f, pthis->actor.speedXZ, 0.0f, 0.0f); + for (i = 12; i >= 0; i--) { + func_80035844(&pthis->unk158[i + 1], &pthis->unk158[i], &sp5C, 0); + Matrix_Translate(pthis->unk158[i + 1].x, pthis->unk158[i + 1].y, pthis->unk158[i + 1].z, MTXMODE_NEW); + Matrix_RotateZYX(sp5C.x, sp5C.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i]); + } + func_80035844(&pthis->unk158[0], &pthis->unk2FC, &sp5C, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->unk2A8[0].y, 3, pthis->unk31C, 182); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->unk2A8[0].x, 3, pthis->unk31C, 182); + Matrix_RotateZYX(pthis->actor.shape.rot.x - 0x8000, pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[0]); + pthis->unk2A8[13].y = sp5C.y; + pthis->unk2A8[13].x = sp5C.x + 0x8000; + + for (i = 0; i < 13; i++) { + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Math_SmoothStepToS(&pthis->unk2A8[i].y, pthis->unk2A8[i + 1].y, 3, pthis->unk31C, 182); + Math_SmoothStepToS(&pthis->unk2A8[i].x, pthis->unk2A8[i + 1].x, 3, pthis->unk31C, 182); + Matrix_RotateZYX(pthis->unk2A8[i].x - 0x8000, pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i + 1]); + } + pthis->unk2A8[13].x = pthis->unk2A8[12].x; + pthis->unk2A8[13].y = pthis->unk2A8[12].y; + if (!(player->stateFlags1 & 0x4000000) && (pthis->actor.xzDistToPlayer <= 175.0f) && + (pthis->actor.world.pos.y == pthis->actor.home.pos.y + 100.0f)) { + EnBa_SetupSwingAtPlayer(pthis); + } +} + +void EnBa_SetupFallAsBlob(EnBa* pthis) { + pthis->unk14C = 0; + pthis->actor.speedXZ = Rand_CenteredFloat(8.0f); + pthis->actor.world.rot.y = Rand_CenteredFloat(65535.0f); + pthis->unk318 = 20; + pthis->actor.gravity = -2.0f; + EnBa_SetupAction(pthis, EnBa_FallAsBlob); +} + +/** + * Action function of the pink fleshy blobs that spawn and fall to the floor when a tentacle dies + */ +void EnBa_FallAsBlob(EnBa* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.scale.y -= 0.001f; + pthis->actor.scale.x += 0.0005f; + pthis->actor.scale.z += 0.0005f; + pthis->unk318--; + if (pthis->unk318 == 0) { + Actor_Kill(&pthis->actor); + } + } else { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 28.0f, 80.0f, 5); + } +} + +void EnBa_SetupSwingAtPlayer(EnBa* pthis) { + pthis->unk14C = 3; + pthis->unk318 = 20; + pthis->unk31A = 0; + pthis->unk31C = 1500; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.speedXZ = 20.0f; + EnBa_SetupAction(pthis, EnBa_SwingAtPlayer); +} + +void EnBa_SwingAtPlayer(EnBa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp; + s16 i; + Vec3s sp58; + s16 phi_fp; + + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 60.0f, 1.0f, 10.0f, 0.0f); + if ((pthis->actor.xzDistToPlayer <= 175.0f) || (pthis->unk31A != 0)) { + if (pthis->unk318 == 20) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_HAND_UP); + pthis->unk31C = 1500; + } + if (pthis->unk318 != 0) { + pthis->unk31A = 10; + pthis->unk318--; + if (pthis->unk318 >= 11) { + pthis->unk2FC = player->actor.world.pos; + pthis->unk2FC.y += 30.0f; + phi_fp = pthis->actor.yawTowardsPlayer; + } else { + phi_fp = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->unk2FC); + } + Math_SmoothStepToS(&pthis->unk31C, 1500, 1, 30, 0); + func_80035844(&pthis->actor.world.pos, &pthis->unk158[0], &sp58, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, sp58.y, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, (sp58.x + 0x8000), 1, pthis->unk31C, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX((pthis->actor.shape.rot.x - 0x8000), pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[0]); + + for (i = 0; i < 13; i++) { + Math_SmoothStepToS(&pthis->unk2A8[i].x, (i * 1200) - 0x4000, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->unk2A8[i].y, phi_fp, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Matrix_RotateZYX((pthis->unk2A8[i].x - 0x8000), pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i + 1]); + } + } else { + if (pthis->unk31A == 10) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_HAND_DOWN); + } + if (pthis->unk31A != 0) { + pthis->unk31C = 8000; + pthis->actor.speedXZ = 30.0f; + phi_fp = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->unk2FC); + temp = Math_Vec3f_Pitch(&pthis->actor.world.pos, &pthis->unk158[0]) + 0x8000; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, phi_fp, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, temp, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.shape.rot.x - 0x8000, pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, pthis->unk158); + + for (i = 0; i < 13; i++) { + temp = -Math_CosS(pthis->unk31A * 0xCCC) * (i * 1200); + Math_SmoothStepToS(&pthis->unk2A8[i].x, temp - 0x4000, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->unk2A8[i].y, phi_fp, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->unk2A8[i].x - 0x8000, pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i + 1]); + } + pthis->unk31A--; + } else if ((pthis->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & 0x4000000)) { + EnBa_SetupIdle(pthis); + } else { + EnBa_SetupSwingAtPlayer(pthis); + pthis->unk318 = 27; + pthis->unk31C = 750; + } + } + pthis->unk2A8[13].x = pthis->unk2A8[12].x; + pthis->unk2A8[13].y = pthis->unk2A8[12].y; + if (pthis->collider.base.atFlags & 2) { + pthis->collider.base.atFlags &= ~2; + if (pthis->collider.base.at == &player->actor) { + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.yawTowardsPlayer, 8.0f); + } + } + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + return; + } + if ((pthis->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & 0x4000000)) { + EnBa_SetupIdle(pthis); + } else { + EnBa_SetupSwingAtPlayer(pthis); + pthis->unk318 = 27; + pthis->unk31C = 750; + } +} + +void func_809B7174(EnBa* pthis) { + pthis->unk14C = 1; + pthis->unk31C = 1500; + pthis->unk318 = 20; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.speedXZ = 10.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BALINADE_HAND_DAMAGE); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 12); + EnBa_SetupAction(pthis, EnBa_RecoilFromDamage); +} + +void EnBa_RecoilFromDamage(EnBa* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3s sp6C; + + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 330.0f, 1.0f, 30.0f, 0.0f); + pthis->unk2FC = pthis->actor.world.pos; + if (globalCtx->gameplayFrames % 16 == 0) { + pthis->unk308.z += Rand_CenteredFloat(180.0f); + pthis->unk314 += Rand_CenteredFloat(180.0f); + pthis->unk308.x = Math_SinF(pthis->unk308.z) * 80.0f; + pthis->unk308.y = Math_CosF(pthis->unk314) * 80.0f; + } + pthis->unk2FC.y -= 448.0f; + pthis->unk2FC.x += pthis->unk308.x; + pthis->unk2FC.z += pthis->unk308.y; + func_80033AEC(&pthis->unk2FC, &pthis->unk158[13], 1.0f, pthis->actor.speedXZ, 0.0f, 0.0f); + for (i = 12; i >= 0; i--) { + func_80035844(&pthis->unk158[i + 1], &pthis->unk158[i], &sp6C, 0); + Matrix_Translate(pthis->unk158[i + 1].x, pthis->unk158[i + 1].y, pthis->unk158[i + 1].z, MTXMODE_NEW); + Matrix_RotateZYX(sp6C.x, sp6C.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i]); + } + func_80035844(&pthis->actor.world.pos, &pthis->unk158[0], &sp6C, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, sp6C.y, 3, pthis->unk31C, 182); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, sp6C.x + 0x8000, 3, pthis->unk31C, 182); + Matrix_RotateZYX(pthis->actor.shape.rot.x - 0x8000, pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[0]); + + for (i = 0; i < 13; i++) { + func_80035844(&pthis->unk158[i], &pthis->unk158[i + 1], &sp6C, 0); + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Math_SmoothStepToS(&pthis->unk2A8[i].y, sp6C.y, 3, pthis->unk31C, 182); + Math_SmoothStepToS(&pthis->unk2A8[i].x, sp6C.x + 0x8000, 3, pthis->unk31C, 182); + Matrix_RotateZYX(pthis->unk2A8[i].x - 0x8000, pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i + 1]); + } + + pthis->unk2A8[13].x = pthis->unk2A8[12].x; + pthis->unk2A8[13].y = pthis->unk2A8[12].y; + pthis->unk318--; + if (pthis->unk318 == 0) { + EnBa_SetupIdle(pthis); + } +} + +void func_809B75A0(EnBa* pthis, GlobalContext* globalCtx2) { + s16 unk_temp; + s32 i; + Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; + GlobalContext* globalCtx = globalCtx2; + + pthis->unk31C = 2500; + EffectSsDeadSound_SpawnStationary(globalCtx, &pthis->actor.projectedPos, NA_SE_EN_BALINADE_HAND_DEAD, 1, 1, 40); + pthis->unk14C = 0; + + for (i = 7; i < 14; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BA, pthis->unk158[i].x, pthis->unk158[i].y, + pthis->unk158[i].z, 0, 0, 0, EN_BA_DEAD_BLOB); + } + unk_temp = Math_Vec3f_Pitch(&pthis->actor.world.pos, &pthis->unk158[0]) + 0x8000; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, unk_temp, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.shape.rot.x - 0x8000, pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[0]); + pthis->actor.flags &= ~ACTOR_FLAG_0; + for (i = 5; i < 13; i++) { + Math_SmoothStepToS(&pthis->unk2A8[i].x, pthis->unk2A8[5].x, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->unk2A8[i].y, pthis->unk2A8[5].y, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->unk2A8[i].x - 0x8000, pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&sp74, &pthis->unk158[i + 1]); + } + pthis->unk31A = 15; + EnBa_SetupAction(pthis, EnBa_Die); +} + +void EnBa_Die(EnBa* pthis, GlobalContext* globalCtx) { + Vec3f sp6C = { 0.0f, 0.0f, 0.0f }; + s16 temp; + s32 i; + + if (pthis->unk31A != 0) { + pthis->actor.speedXZ = 30.0f; + pthis->unk31C = 8000; + pthis->actor.world.pos.y += 8.0f; + temp = Math_Vec3f_Pitch(&pthis->actor.world.pos, &pthis->unk158[0]) + 0x8000; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, temp, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.shape.rot.x - 0x8000, pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[0]); + for (i = 0; i < 5; i++) { + temp = -Math_CosS(pthis->unk31A * 0x444) * (i * 400); + Math_SmoothStepToS(&pthis->unk2A8[i].x, temp - 0x4000, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->unk2A8[i].y, pthis->actor.yawTowardsPlayer, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->unk2A8[i].x - 0x8000, pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&D_809B8080, &pthis->unk158[i + 1]); + } + for (i = 5; i < 13; i++) { + Math_SmoothStepToS(&pthis->unk2A8[i].x, pthis->unk2A8[5].x, 1, pthis->unk31C, 0); + Math_SmoothStepToS(&pthis->unk2A8[i].y, pthis->unk2A8[5].y, 1, pthis->unk31C, 0); + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->unk2A8[i].x - 0x8000, pthis->unk2A8[i].y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&sp6C, &pthis->unk158[i + 1]); + } + pthis->unk31A--; + } else { + Flags_SetSwitch(globalCtx, pthis->upperParams); + Actor_Kill(&pthis->actor); + } +} + +void EnBa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBa* pthis = (EnBa*)thisx; + + if ((pthis->actor.params < EN_BA_DEAD_BLOB) && (pthis->collider.base.acFlags & 2)) { + pthis->collider.base.acFlags &= ~2; + pthis->actor.colChkInfo.health--; + if (pthis->actor.colChkInfo.health == 0) { + func_809B75A0(pthis, globalCtx); + } else { + func_809B7174(pthis); + } + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->actor.params < EN_BA_DEAD_BLOB) { + pthis->actor.focus.pos = pthis->unk158[6]; + } + if (pthis->unk14C >= 2) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +static void* D_809B8118[] = { + object_bxa_Tex_0024F0, + object_bxa_Tex_0027F0, + object_bxa_Tex_0029F0, +}; + +void EnBa_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBa* pthis = (EnBa*)thisx; + s32 pad; + s16 i; + Mtx* mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 14); + Vec3f unused = { 0.0f, 0.0f, 448.0f }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ba.c", 933); + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->actor.params < EN_BA_DEAD_BLOB) { + Matrix_Push(); + gSPSegment(POLY_OPA_DISP++, 0x0C, mtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809B8118[pthis->actor.params])); + gSPSegment(POLY_OPA_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 16, 1, 0, + (globalCtx->gameplayFrames * -10) % 128, 32, 32)); + for (i = 0; i < 14; i++, mtx++) { + Matrix_Translate(pthis->unk158[i].x, pthis->unk158[i].y, pthis->unk158[i].z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->unk2A8[i].x, pthis->unk2A8[i].y, pthis->unk2A8[i].z, MTXMODE_APPLY); + Matrix_Scale(pthis->unk200[i].x, pthis->unk200[i].y, pthis->unk200[i].z, MTXMODE_APPLY); + if ((i == 6) || (i == 13)) { + switch (i) { + case 13: + Collider_UpdateSpheres(i, &pthis->collider); + break; + default: + Matrix_Scale(0.5f, 0.5f, 1.0f, MTXMODE_APPLY); + Collider_UpdateSpheres(8, &pthis->collider); + break; + } + } + Matrix_ToMtx(mtx, "../z_en_ba.c", 970); + } + Matrix_Pop(); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ba.c", 973), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bxa_DL_000890); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->gameplayFrames * 2) % 128, + (globalCtx->gameplayFrames * 2) % 128, 32, 32, 1, + (globalCtx->gameplayFrames * -5) % 128, (globalCtx->gameplayFrames * -5) % 128, 32, + 32)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 125, 100, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ba.c", 991), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bxa_DL_001D80); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ba.c", 995); +} diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c deleted file mode 100644 index 2f3c9a26f..000000000 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ /dev/null @@ -1,1367 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BB_Z_EN_BB_C -#include "actor_common.h" -/* - * File: z_en_bb.c - * Overlay: ovl_En_Bb - * Description: Bubble (Flying Skull Enemy) - */ - -#include "z_en_bb.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_Bb/object_Bb.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_24) - -#define vBombHopPhase actionVar1 -#define vTrailIdx actionVar1 -#define vTrailMaxAlpha actionVar2 -#define vMoveAngleY actionVar2 -#define vFlameTimer actionVar2 - -typedef enum { - /* 0 */ BB_DAMAGE, - /* 1 */ BB_KILL, - /* 2 */ BB_FLAME_TRAIL, - /* 3 */ BB_DOWN, - /* 4 */ BB_STUNNED, - /* 5 */ BB_UNUSED, - /* 6 */ BB_BLUE, - /* 7 */ BB_RED, - /* 8 */ BB_WHITE, - /* 9 */ BB_GREEN -} EnBbAction; - -typedef enum { - /* 0 */ BBMOVE_NORMAL, - /* 1 */ BBMOVE_NOCLIP, - /* 2 */ BBMOVE_HIDDEN -} EnBbMoveMode; - -typedef enum { - /* 0 */ BBBLUE_NORMAL, - /* 1 */ BBBLUE_AGGRO -} EnBbBlueActionState; - -typedef enum { - /* 0 */ BBRED_WAIT, - /* 1 */ BBRED_ATTACK, - /* 2 */ BBRED_HIDE -} EnBbRedActionState; - -typedef enum { - /* 0 */ BBGREEN_FLAME_ON, - /* 1 */ BBGREEN_FLAME_OFF -} EnBbGreenActionState; - -// Main functions - -void EnBb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBb_Update(Actor* this, GlobalContext* globalCtx); -void EnBb_Draw(Actor* this, GlobalContext* globalCtx); - -// Helper functions - -void EnBb_FaceWaypoint(EnBb* this); -void EnBb_SetWaypoint(EnBb* this, GlobalContext* globalCtx); - -// Action functions - -void EnBb_SetupFlameTrail(EnBb* this); -void EnBb_FlameTrail(EnBb* this, GlobalContext* globalCtx); - -void EnBb_SetupDeath(EnBb* this, GlobalContext* globalCtx); -void EnBb_Death(EnBb* this, GlobalContext* globalCtx); - -void EnBb_Damage(EnBb* this, GlobalContext* globalCtx); - -void EnBb_SetupBlue(EnBb* this); -void EnBb_Blue(EnBb* this, GlobalContext* globalCtx); - -void EnBb_SetupDown(EnBb* this); -void EnBb_Down(EnBb* this, GlobalContext* globalCtx); - -void EnBb_SetupRed(GlobalContext* globalCtx, EnBb* this); -void EnBb_Red(EnBb* this, GlobalContext* globalCtx); - -void EnBb_SetupWhite(GlobalContext* globalCtx, EnBb* this); -void EnBb_White(EnBb* this, GlobalContext* globalCtx); - -void EnBb_InitGreen(EnBb* this, GlobalContext* globalCtx); -void EnBb_Green(EnBb* this, GlobalContext* globalCtx); - -void EnBb_Stunned(EnBb* this, GlobalContext* globalCtx); - -static DamageTable sDamageTableBlueGreen = { - /* Deku nut */ DMG_ENTRY(0, 0xF), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0xA), - /* Boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(2, 0xE), - /* Hammer swing */ DMG_ENTRY(2, 0xA), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0xE), - /* Ice arrow */ DMG_ENTRY(4, 0xC), - /* Light arrow */ DMG_ENTRY(4, 0xB), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x6), - /* Ice magic */ DMG_ENTRY(3, 0x9), - /* Light magic */ DMG_ENTRY(3, 0x8), - /* Shield */ DMG_ENTRY(0, 0xA), - /* Mirror Ray */ DMG_ENTRY(0, 0xA), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x6), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xA), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static DamageTable sDamageTableRed = { - /* Deku nut */ DMG_ENTRY(0, 0xD), - /* Deku stick */ DMG_ENTRY(0, 0xD), - /* Slingshot */ DMG_ENTRY(0, 0xD), - /* Explosive */ DMG_ENTRY(2, 0xA), - /* Boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(2, 0xE), - /* Hammer swing */ DMG_ENTRY(2, 0xA), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Kokiri sword */ DMG_ENTRY(0, 0xD), - /* Master sword */ DMG_ENTRY(2, 0xE), - /* Giant's Knife */ DMG_ENTRY(4, 0xE), - /* Fire arrow */ DMG_ENTRY(2, 0xE), - /* Ice arrow */ DMG_ENTRY(4, 0x9), - /* Light arrow */ DMG_ENTRY(2, 0xE), - /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), - /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), - /* Unk arrow 3 */ DMG_ENTRY(2, 0xE), - /* Fire magic */ DMG_ENTRY(0, 0x6), - /* Ice magic */ DMG_ENTRY(3, 0x9), - /* Light magic */ DMG_ENTRY(0, 0x6), - /* Shield */ DMG_ENTRY(0, 0xA), - /* Mirror Ray */ DMG_ENTRY(0, 0xA), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0xE), - /* Master spin */ DMG_ENTRY(2, 0xE), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0xE), - /* Master jump */ DMG_ENTRY(4, 0xE), - /* Unknown 1 */ DMG_ENTRY(0, 0x6), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xA), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static DamageTable sDamageTableWhite = { - /* Deku nut */ DMG_ENTRY(0, 0xF), - /* Deku stick */ DMG_ENTRY(2, 0xE), - /* Slingshot */ DMG_ENTRY(1, 0xE), - /* Explosive */ DMG_ENTRY(2, 0xA), - /* Boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(2, 0xE), - /* Hammer swing */ DMG_ENTRY(2, 0xA), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Kokiri sword */ DMG_ENTRY(1, 0xE), - /* Master sword */ DMG_ENTRY(2, 0xE), - /* Giant's Knife */ DMG_ENTRY(4, 0xE), - /* Fire arrow */ DMG_ENTRY(4, 0x5), - /* Ice arrow */ DMG_ENTRY(2, 0xE), - /* Light arrow */ DMG_ENTRY(2, 0xE), - /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), - /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), - /* Unk arrow 3 */ DMG_ENTRY(2, 0xE), - /* Fire magic */ DMG_ENTRY(4, 0x7), - /* Ice magic */ DMG_ENTRY(0, 0x6), - /* Light magic */ DMG_ENTRY(0, 0x6), - /* Shield */ DMG_ENTRY(0, 0xA), - /* Mirror Ray */ DMG_ENTRY(0, 0xA), - /* Kokiri spin */ DMG_ENTRY(1, 0xE), - /* Giant spin */ DMG_ENTRY(4, 0xE), - /* Master spin */ DMG_ENTRY(2, 0xE), - /* Kokiri jump */ DMG_ENTRY(2, 0xE), - /* Giant jump */ DMG_ENTRY(8, 0xE), - /* Master jump */ DMG_ENTRY(4, 0xE), - /* Unknown 1 */ DMG_ENTRY(0, 0x6), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xA), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -const ActorInit En_Bb_InitVars = { - ACTOR_EN_BB, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BB, - sizeof(EnBb), - (ActorFunc)EnBb_Init, - (ActorFunc)EnBb_Destroy, - (ActorFunc)EnBb_Update, - (ActorFunc)EnBb_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, -120, 0 }, 4 }, 300 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), -}; - -void EnBb_SetupAction(EnBb* this, EnBbActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -Actor* EnBb_FindExplosive(GlobalContext* globalCtx, EnBb* this, f32 range) { - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; - f32 dist; - - while (explosive != NULL) { - if (explosive->params != 0) { - explosive = explosive->next; - continue; - } - dist = Actor_WorldDistXYZToActor(&this->actor, explosive); - if ((explosive->params == 0) && (dist <= range)) { - return explosive; - } - explosive = explosive->next; - } - return NULL; -} - -void EnBb_SpawnFlameTrail(GlobalContext* globalCtx, EnBb* this, s16 startAtZero) { - EnBb* now = this; - EnBb* next; - s32 i; - - for (i = 0; i < 5; i++) { - next = (EnBb*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BB, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - if (next != NULL) { - now->actor.child = &next->actor; - next->actor.parent = &now->actor; - next->targetActor = &this->actor; - next->vTrailIdx = i + 1; - next->actor.scale.x = 1.0f; - next->vTrailMaxAlpha = next->flamePrimAlpha = 255 - (i * 40); - next->flameScaleY = next->actor.scale.y = 0.8f - (i * 0.075f); - next->flameScaleX = next->actor.scale.z = 1.0f - (i * 0.094f); - if (startAtZero) { - next->flamePrimAlpha = 0; - next->flameScaleY = next->flameScaleX = 0.0f; - } - next->flameScrollMod = i + 1; - next->timer = 2 * i + 2; - next->flameEnvColor.r = 255; - now = next; - } - } -} - -void EnBb_KillFlameTrail(EnBb* this) { - Actor* actor = &this->actor; - - while (actor->child != NULL) { - Actor* nextActor = actor->child; - - if (nextActor->id == ACTOR_EN_BB) { - nextActor->parent = NULL; - actor->child = NULL; - nextActor->params = ENBB_KILL_TRAIL; - } - actor = nextActor; - } - this->actor.child = NULL; -} - -void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { - EffectBlureInit1 blureInit; - s32 pad; - EnBb* this = (EnBb*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_Bb_Skel_001A30, &object_Bb_Anim_000444, this->jointTable, - this->morphTable, 16); - this->unk_254 = 0; - thisx->colChkInfo.health = 4; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, thisx, &sJntSphInit, this->elements); - - this->actionState = thisx->params >> 8; - - if (thisx->params & 0x80) { - thisx->params |= 0xFF00; - } - if (thisx->params <= ENBB_BLUE) { - ActorShape_Init(&thisx->shape, 200.0f, ActorShadow_DrawCircle, 35.0f); - } - if (thisx->params & 0xFF00) { - this->timer = 0; - this->flameScaleY = 80.0f; - this->flameScaleX = 100.0f; - this->collider.elements[0].info.toucherFlags = TOUCH_ON | TOUCH_SFX_HARD; - this->collider.elements[0].info.toucher.dmgFlags = 0xFFCFFFFF; - this->collider.elements[0].info.toucher.damage = 8; - this->bobSize = this->actionState * 20.0f; - this->flamePrimAlpha = 255; - this->moveMode = BBMOVE_NORMAL; - Actor_SetScale(thisx, 0.01f); - switch (thisx->params) { - case ENBB_BLUE: - thisx->naviEnemyId = 0x1C; - thisx->colChkInfo.damageTable = &sDamageTableBlueGreen; - this->flamePrimBlue = this->flameEnvColor.b = 255; - thisx->world.pos.y += 50.0f; - EnBb_SetupBlue(this); - thisx->flags |= ACTOR_FLAG_14; - break; - case ENBB_RED: - thisx->naviEnemyId = 0x24; - thisx->colChkInfo.damageTable = &sDamageTableRed; - this->flameEnvColor.r = 255; - this->collider.elements[0].info.toucher.effect = 1; - EnBb_SetupRed(globalCtx, this); - break; - case ENBB_WHITE: - thisx->naviEnemyId = 0x1D; - thisx->colChkInfo.damageTable = &sDamageTableWhite; - this->path = this->actionState; - blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = - blureInit.p1StartColor[3] = blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = - blureInit.p2StartColor[2] = blureInit.p2StartColor[3] = blureInit.p1EndColor[0] = - blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = - blureInit.p2EndColor[1] = blureInit.p2EndColor[2] = 255; - - blureInit.p1EndColor[3] = 0; - blureInit.p2EndColor[3] = 0; - blureInit.elemDuration = 16; - blureInit.unkFlag = 0; - blureInit.calcMode = 2; - - Effect_Add(globalCtx, &this->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); - EnBb_SetupWhite(globalCtx, this); - EnBb_SetWaypoint(this, globalCtx); - EnBb_FaceWaypoint(this); - thisx->flags |= ACTOR_FLAG_14; - break; - case ENBB_GREEN_BIG: - this->path = this->actionState >> 4; - this->collider.elements[0].dim.modelSphere.radius = 0x16; - Actor_SetScale(thisx, 0.03f); - case ENBB_GREEN: - thisx->naviEnemyId = 0x1E; - this->bobSize = (this->actionState & 0xF) * 20.0f; - thisx->colChkInfo.damageTable = &sDamageTableBlueGreen; - this->flameEnvColor.g = 255; - thisx->colChkInfo.health = 1; - - EnBb_InitGreen(this, globalCtx); - break; - } - thisx->focus.pos = thisx->world.pos; - } else { - EnBb_SetupFlameTrail(this); - } - this->collider.elements[0].dim.worldSphere.radius = - this->collider.elements[0].dim.modelSphere.radius * this->collider.elements[0].dim.scale; -} - -void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnBb* this = (EnBb*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnBb_SetupFlameTrail(EnBb* this) { - this->action = BB_FLAME_TRAIL; - this->moveMode = BBMOVE_NOCLIP; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 0.0f; - EnBb_SetupAction(this, EnBb_FlameTrail); -} - -void EnBb_FlameTrail(EnBb* this, GlobalContext* globalCtx) { - if (this->actor.params == ENBB_KILL_TRAIL) { - if (this->actor.parent == NULL) { - EnBb_SetupDeath(this, globalCtx); - } - } else { - if (this->timer == 0) { - if (((EnBb*)this->targetActor)->flameScaleY != 0.0f) { - Math_SmoothStepToF(&this->flameScaleY, this->actor.scale.y, 1.0f, this->actor.scale.y * 0.1f, 0.0f); - Math_SmoothStepToF(&this->flameScaleX, this->actor.scale.z, 1.0f, this->actor.scale.z * 0.1f, 0.0f); - if (this->flamePrimAlpha != this->vTrailMaxAlpha) { - this->flamePrimAlpha += 10; - if (this->vTrailMaxAlpha < this->flamePrimAlpha) { - this->flamePrimAlpha = this->vTrailMaxAlpha; - } - } - } else { - if (!this->flamePrimAlpha) { - Actor_Kill(&this->actor); - return; - } else if (this->flamePrimAlpha <= 20) { - this->flamePrimAlpha = 0; - } else { - this->flamePrimAlpha -= 20; - } - } - this->actor.world.pos = this->actor.parent->prevPos; - } else { - this->timer--; - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.parent->world.rot.y; - } - } - if (this->actor.parent != NULL) { - this->actor.velocity.y = this->actor.parent->velocity.y; - } -} - -void EnBb_SetupDeath(EnBb* this, GlobalContext* globalCtx) { - if (this->actor.params <= ENBB_BLUE) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = -7.0f; - this->timer = 5; - this->actor.shape.rot.x += 0x4E20; - EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_BUBLE_DEAD, 1, 1, 0x28); - } - this->action = BB_KILL; - EnBb_SetupAction(this, EnBb_Death); -} - -void EnBb_Death(EnBb* this, GlobalContext* globalCtx) { - s16 enpartType = 3; - Vec3f sp40 = { 0.0f, 0.5f, 0.0f }; - Vec3f sp34 = { 0.0f, 0.0f, 0.0f }; - - if (this->actor.params <= ENBB_BLUE) { - Math_SmoothStepToF(&this->flameScaleY, 0.0f, 1.0f, 30.0f, 0.0f); - Math_SmoothStepToF(&this->flameScaleX, 0.0f, 1.0f, 30.0f, 0.0f); - if (this->timer != 0) { - this->timer--; - this->actor.shape.rot.x -= 0x4E20; - return; - } - - if (this->bodyBreak.val == BODYBREAK_STATUS_FINISHED) { - BodyBreak_Alloc(&this->bodyBreak, 12, globalCtx); - } - - if ((this->dmgEffect == 7) || (this->dmgEffect == 5)) { - enpartType = 11; - } - - if (!BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, enpartType)) { - return; - } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xD0); - } else { - if (this->flamePrimAlpha) { - if (this->flamePrimAlpha <= 20) { - this->flamePrimAlpha = 0; - } else { - this->flamePrimAlpha -= 20; - } - return; - } - } - Actor_Kill(&this->actor); -} - -void EnBb_SetupDamage(EnBb* this) { - this->action = BB_DAMAGE; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_DAMAGE); - if (this->actor.params > ENBB_GREEN) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if ((this->actor.bgCheckFlags & 8) == 0) { - this->actor.speedXZ = -7.0f; - } - this->actor.shape.yOffset = 1500.0f; - } - if (this->actor.params == ENBB_RED) { - EnBb_KillFlameTrail(this); - } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0xC); - this->timer = 5; - EnBb_SetupAction(this, EnBb_Damage); -} - -void EnBb_Damage(EnBb* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if (this->actor.speedXZ == 0.0f) { - this->actor.shape.yOffset = 200.0f; - EnBb_SetupDown(this); - } -} - -void EnBb_SetupBlue(EnBb* this) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - this->actor.speedXZ = (Rand_ZeroOne() * 0.5f) + 0.5f; - this->timer = (Rand_ZeroOne() * 20.0f) + 40.0f; - this->unk_264 = (Rand_ZeroOne() * 30.0f) + 180.0f; - this->targetActor = NULL; - this->action = BB_BLUE; - EnBb_SetupAction(this, EnBb_Blue); -} - -void EnBb_Blue(EnBb* this, GlobalContext* globalCtx) { - Actor* explosive; - s16 moveYawToWall; - s16 thisYawToWall; - s16 afterHitAngle; - - Math_SmoothStepToF(&this->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); - Math_SmoothStepToF(&this->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); - if (this->actor.floorHeight > BGCHECK_Y_MIN) { - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight + 50.0f + this->flyHeightMod, 1.0f, 0.5f, - 0.0f); - } - SkelAnime_Update(&this->skelAnime); - if (Math_CosF(this->bobPhase) == 0.0f) { - if (this->charge) { - this->bobSpeedMod = Rand_ZeroOne() * 2.0f; - } else { - this->bobSpeedMod = Rand_ZeroOne() * 4.0f; - } - } - this->actor.world.pos.y += Math_CosF(this->bobPhase) * (1.0f + this->bobSpeedMod); - this->bobPhase += 0.2f; - Math_SmoothStepToF(&this->actor.speedXZ, this->maxSpeed, 1.0f, 0.5f, 0.0f); - - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) > 300.0f) { - this->vMoveAngleY = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_SmoothStepToS(&this->actor.world.rot.y, this->vMoveAngleY, 1, 0x7D0, 0); - } else { - this->timer--; - if (this->timer <= 0) { - this->charge ^= true; - this->flyHeightMod = (s16)(Math_CosF(this->bobPhase) * 10.0f); - this->actor.speedXZ = 0.0f; - if (this->charge && (this->targetActor == NULL)) { - this->vMoveAngleY = this->actor.world.rot.y; - if (this->actor.xzDistToPlayer < 200.0f) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000184); - this->vMoveAngleY = this->actor.yawTowardsPlayer; - } - this->maxSpeed = (Rand_ZeroOne() * 1.5f) + 6.0f; - this->timer = (Rand_ZeroOne() * 5.0f) + 20.0f; - this->actionState = BBBLUE_NORMAL; - } else { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - this->maxSpeed = (Rand_ZeroOne() * 1.5f) + 1.0f; - this->timer = (Rand_ZeroOne() * 20.0f) + 40.0f; - this->vMoveAngleY = Math_SinF(this->bobPhase) * 65535.0f; - } - } - if ((this->actor.xzDistToPlayer < 150.0f) && (this->actionState != BBBLUE_NORMAL)) { - if (!this->charge) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000184); - this->maxSpeed = (Rand_ZeroOne() * 1.5f) + 6.0f; - this->timer = (Rand_ZeroOne() * 5.0f) + 20.0f; - this->vMoveAngleY = this->actor.yawTowardsPlayer; - this->actionState = this->charge = true; // Sets actionState to BBBLUE_AGGRO - } - } else if (this->actor.xzDistToPlayer < 200.0f) { - this->vMoveAngleY = this->actor.yawTowardsPlayer; - } - if (this->targetActor == NULL) { - explosive = EnBb_FindExplosive(globalCtx, this, 300.0f); - } else if (this->targetActor->params == 0) { - explosive = this->targetActor; - } else { - explosive = NULL; - } - if (explosive != NULL) { - this->vMoveAngleY = Actor_WorldYawTowardActor(&this->actor, explosive); - if ((this->vBombHopPhase == 0) && (explosive != this->targetActor)) { - this->vBombHopPhase = -0x8000; - this->targetActor = explosive; - this->actor.speedXZ *= 0.5f; - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->vMoveAngleY, 1, 0x1388, 0); - Math_SmoothStepToF(&this->actor.world.pos.x, explosive->world.pos.x, 1.0f, 1.5f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, explosive->world.pos.y + 40.0f, 1.0f, 1.5f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, explosive->world.pos.z, 1.0f, 1.5f, 0.0f); - } else { - this->targetActor = NULL; - } - if (this->vBombHopPhase != 0) { - this->actor.world.pos.y += -Math_CosS(this->vBombHopPhase) * 10.0f; - this->vBombHopPhase += 0x1000; - Math_SmoothStepToS(&this->actor.world.rot.y, this->vMoveAngleY, 1, 0x7D0, 0); - } - thisYawToWall = this->actor.wallYaw - this->actor.world.rot.y; - moveYawToWall = this->actor.wallYaw - this->vMoveAngleY; - if ((this->targetActor == NULL) && (this->actor.bgCheckFlags & 8) && - (ABS(thisYawToWall) > 0x4000 || ABS(moveYawToWall) > 0x4000)) { - this->vMoveAngleY = this->actor.wallYaw + this->actor.wallYaw - this->actor.world.rot.y - 0x8000; - Math_SmoothStepToS(&this->actor.world.rot.y, this->vMoveAngleY, 1, 0xBB8, 0); - } - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->vMoveAngleY, 1, 0x3E8, 0); - if ((this->collider.base.acFlags & AC_HIT) || (this->collider.base.atFlags & AT_HIT)) { - this->vMoveAngleY = this->actor.yawTowardsPlayer + 0x8000; - if (this->collider.base.acFlags & AC_HIT) { - afterHitAngle = -0x8000; - } else { - afterHitAngle = 0x4000; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_BITE); - if (globalCtx->gameplayFrames & 1) { - afterHitAngle = -0x4000; - } - } - this->actor.world.rot.y = this->actor.yawTowardsPlayer + afterHitAngle; - this->collider.base.acFlags &= ~AC_HIT; - this->collider.base.atFlags &= ~AT_HIT; - } - - if (this->maxSpeed >= 6.0f) { - if ((s32)this->skelAnime.curFrame == 0 || (s32)this->skelAnime.curFrame == 5) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_MOUTH); - } else if ((s32)this->skelAnime.curFrame == 2 || (s32)this->skelAnime.curFrame == 7) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_WING); - } - } else { - if ((s32)this->skelAnime.curFrame == 5) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_WING); - } - } - if (((s32)this->skelAnime.curFrame == 0) && (Rand_ZeroOne() < 0.1f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_LAUGH); - } - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnBb_SetupDown(EnBb* this) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - this->action = BB_DOWN; - this->timer = 200; - this->actor.colorFilterTimer = 0; - this->actor.bgCheckFlags &= ~1; - this->actor.speedXZ = 3.0f; - this->flameScaleX = 0.0f; - this->flameScaleY = 0.0f; - this->actor.gravity = -2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_DOWN); - EnBb_SetupAction(this, EnBb_Down); -} - -void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { - s16 yawDiff = this->actor.world.rot.y - this->actor.wallYaw; - - SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 8) { - if (ABS(yawDiff) > 0x4000) { - this->actor.world.rot.y = this->actor.wallYaw + this->actor.wallYaw - this->actor.world.rot.y - 0x8000; - } - this->actor.bgCheckFlags &= ~8; - } - if (this->actor.bgCheckFlags & 3) { - if (this->actor.params == ENBB_RED) { - s32 floorType = func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - - if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { - this->moveMode = BBMOVE_HIDDEN; - this->timer = 10; - this->actionState++; - this->actor.flags &= ~ACTOR_FLAG_0; - this->action = BB_RED; - EnBb_SetupAction(this, EnBb_Red); - return; - } - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - if (this->actor.velocity.y < -14.0f) { - this->actor.velocity.y *= -0.7f; - } else { - this->actor.velocity.y = 10.0f; - } - this->actor.bgCheckFlags &= ~1; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); - Math_SmoothStepToS(&this->actor.world.rot.y, -this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - } - this->actor.shape.rot.y = this->actor.world.rot.y; - if ((s32)this->skelAnime.curFrame == 5) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_WING); - } - if (this->timer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_UP); - switch (this->actor.params) { - case ENBB_BLUE: - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - EnBb_SetupBlue(this); - break; - case ENBB_RED: - if (this->actor.velocity.y == 10.0f) { - EnBb_SetupRed(globalCtx, this); - EnBb_SpawnFlameTrail(globalCtx, this, true); - } - break; - case ENBB_WHITE: - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - EnBb_SetupWhite(globalCtx, this); - this->actor.world.pos.y -= 60.0f; - break; - } - } else { - this->timer--; - } -} - -void EnBb_SetupRed(GlobalContext* globalCtx, EnBb* this) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000184); - if (this->action == BB_DOWN) { - this->actor.speedXZ = 5.0f; - this->actor.gravity = -1.0f; - this->actor.velocity.y = 16.0f; - this->actionState = BBRED_ATTACK; - this->timer = 0; - this->moveMode = BBMOVE_NORMAL; - this->actor.bgCheckFlags &= ~1; - } else { - this->actor.colChkInfo.health = 4; - this->timer = 0; - this->actionState = BBRED_WAIT; - this->moveMode = BBMOVE_HIDDEN; - this->actor.world.pos.y -= 80.0f; - this->actor.home.pos = this->actor.world.pos; - this->actor.velocity.y = this->actor.gravity = this->actor.speedXZ = 0.0f; - this->actor.bgCheckFlags &= ~1; - this->actor.flags &= ~ACTOR_FLAG_0; - } - this->action = BB_RED; - EnBb_SetupAction(this, EnBb_Red); -} - -void EnBb_Red(EnBb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 floorType; - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - switch (this->actionState) { - case BBRED_WAIT: - if ((Actor_WorldDistXYZToActor(&this->actor, &player->actor) <= 250.0f) && (ABS(yawDiff) <= 0x4000) && - (this->timer == 0)) { - this->actor.speedXZ = 5.0f; - this->actor.gravity = -1.0f; - this->actor.velocity.y = 18.0f; - this->moveMode = BBMOVE_NOCLIP; - this->timer = 7; - this->actor.bgCheckFlags &= ~1; - this->actionState++; - EnBb_SpawnFlameTrail(globalCtx, this, false); - } - break; - case BBRED_ATTACK: - if (this->timer == 0) { - this->moveMode = BBMOVE_NORMAL; - this->actor.flags |= ACTOR_FLAG_0; - } - this->bobPhase += Rand_ZeroOne(); - Math_SmoothStepToF(&this->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); - Math_SmoothStepToF(&this->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); - if (this->actor.bgCheckFlags & 8) { - yawDiff = this->actor.world.rot.y - this->actor.wallYaw; - if (ABS(yawDiff) > 0x4000) { - this->actor.world.rot.y = - this->actor.wallYaw + this->actor.wallYaw - this->actor.world.rot.y - 0x8000; - } - this->actor.bgCheckFlags &= ~8; - } - if (this->actor.bgCheckFlags & 1) { - floorType = func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { - this->moveMode = BBMOVE_HIDDEN; - this->timer = 10; - this->actionState++; - this->actor.flags &= ~ACTOR_FLAG_0; - } else { - this->actor.velocity.y *= -1.06f; - if (this->actor.velocity.y > 13.0f) { - this->actor.velocity.y = 13.0f; - } - this->actor.world.rot.y = Math_SinF(this->bobPhase) * 65535.0f; - } - this->actor.bgCheckFlags &= ~1; - } - this->actor.shape.rot.y = this->actor.world.rot.y; - if (Actor_GetCollidedExplosive(globalCtx, &this->collider.base) != NULL) { - EnBb_SetupDown(this); - } - break; - case BBRED_HIDE: - if (this->timer == 0) { - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actionState = BBRED_WAIT; - this->timer = 120; - this->actor.world.pos = this->actor.home.pos; - this->actor.shape.rot = this->actor.world.rot = this->actor.home.rot; - EnBb_KillFlameTrail(this); - } - break; - } - if (this->actionState != BBRED_WAIT) { - if (((s32)this->skelAnime.curFrame == 0) || ((s32)this->skelAnime.curFrame == 5)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_MOUTH); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); - } -} - -void EnBb_FaceWaypoint(EnBb* this) { - this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos); -} - -void EnBb_SetWaypoint(EnBb* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->path]; - Vec3s* point; - - if (this->waypoint == (s16)(path->count - 1)) { - this->waypoint = 0; - } else { - this->waypoint++; - } - point = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; - this->waypointPos.x = point->x; - this->waypointPos.y = point->y; - this->waypointPos.z = point->z; -} - -void EnBb_SetupWhite(GlobalContext* globalCtx, EnBb* this) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - this->actor.speedXZ = 0.0f; - this->actor.world.pos.y += 60.0f; - this->flameScaleX = 100.0f; - this->action = BB_WHITE; - this->waypoint = 0; - this->timer = (Rand_ZeroOne() * 30.0f) + 40.0f; - this->maxSpeed = 7.0f; - EnBb_SetupAction(this, EnBb_White); -} - -void EnBb_White(EnBb* this, GlobalContext* globalCtx) { - if (this->actor.speedXZ == 0.0f) { - f32 distL1; - f32 vx; - f32 vz; - s16 pitch = Math_Vec3f_Pitch(&this->actor.world.pos, &this->waypointPos); - f32 vy = Math_SinS(pitch) * this->maxSpeed; - f32 vxz = Math_CosS(pitch) * this->maxSpeed; - - vx = Math_SinS(this->actor.shape.rot.y) * vxz; - vz = Math_CosS(this->actor.shape.rot.y) * vxz; - distL1 = Math_SmoothStepToF(&this->actor.world.pos.x, this->waypointPos.x, 1.0f, ABS(vx), 0.0f); - distL1 += Math_SmoothStepToF(&this->actor.world.pos.y, this->waypointPos.y, 1.0f, ABS(vy), 0.0f); - distL1 += Math_SmoothStepToF(&this->actor.world.pos.z, this->waypointPos.z, 1.0f, ABS(vz), 0.0f); - this->bobPhase += (0.05f + (Rand_ZeroOne() * 0.01f)); - if (distL1 == 0.0f) { - this->timer--; - if (this->timer == 0) { - EnBb_SetWaypoint(this, globalCtx); - EnBb_FaceWaypoint(this); - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000184); - this->timer = Rand_ZeroOne() * 30.0f + 40.0f; - } else { - if (this->moveMode != BBMOVE_NORMAL) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - } - this->actor.world.rot.y += 0x1F40; - } - this->moveMode = BBMOVE_NORMAL; - this->maxSpeed = 0.0f; - } else { - this->moveMode = BBMOVE_NOCLIP; - this->maxSpeed = 10.0f; - } - if (this->collider.base.atFlags & AT_HIT) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_BITE); - this->collider.base.atFlags &= ~AT_HIT; - } - this->actor.shape.rot.y = this->actor.world.rot.y; - } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f) == 0.0f) { - EnBb_FaceWaypoint(this); - } - SkelAnime_Update(&this->skelAnime); - if (((s32)this->skelAnime.curFrame == 0) && (Rand_ZeroOne() <= 0.1f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_LAUGH); - } - - if ((this->maxSpeed != 0.0f) && (((s32)this->skelAnime.curFrame == 0) || ((s32)this->skelAnime.curFrame == 5))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_MOUTH); - } else if (((s32)this->skelAnime.curFrame == 2) || ((s32)this->skelAnime.curFrame == 7)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_WING); - } -} - -void EnBb_InitGreen(EnBb* this, GlobalContext* globalCtx) { - Vec3f bobOffset = { 0.0f, 0.0f, 0.0f }; - - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - this->moveMode = BBMOVE_NOCLIP; - this->actionState = BBGREEN_FLAME_ON; - this->bobPhase = Rand_ZeroOne(); - this->actor.shape.rot.x = this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - if (this->actor.params == ENBB_GREEN_BIG) { - EnBb_SetWaypoint(this, globalCtx); - EnBb_FaceWaypoint(this); - } - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, 0, MTXMODE_APPLY); - Matrix_RotateZ(this->bobPhase, MTXMODE_APPLY); - bobOffset.y = this->bobSize; - Matrix_MultVec3f(&bobOffset, &this->actor.world.pos); - this->targetActor = NULL; - this->action = BB_GREEN; - this->actor.speedXZ = 0.0f; - this->vFlameTimer = (Rand_ZeroOne() * 30.0f) + 180.0f; - EnBb_SetupAction(this, EnBb_Green); -} - -void EnBb_SetupGreen(EnBb* this) { - Animation_PlayLoop(&this->skelAnime, &object_Bb_Anim_000444); - this->moveMode = BBMOVE_NOCLIP; - this->actionState = BBGREEN_FLAME_ON; - this->targetActor = NULL; - this->action = BB_GREEN; - this->actor.speedXZ = 0.0f; - this->vFlameTimer = (Rand_ZeroOne() * 30.0f) + 180.0f; - this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - EnBb_SetupAction(this, EnBb_Green); -} - -void EnBb_Green(EnBb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f bobOffset = { 0.0f, 0.0f, 0.0f }; - Vec3f nextPos = player->actor.world.pos; - - nextPos.y += 30.0f; - if (this->actor.params == ENBB_GREEN_BIG) { - if (this->actor.speedXZ == 0.0f) { - s16 pitch = Math_Vec3f_Pitch(&this->actor.home.pos, &this->waypointPos); - s16 yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &this->waypointPos); - f32 vy = Math_SinS(pitch) * this->maxSpeed; - f32 vxz = Math_CosS(pitch) * this->maxSpeed; - f32 vz; - f32 vx; - f32 distL1; - - Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 1, 0x3E8, 0); - vx = Math_SinS(this->actor.world.rot.y) * vxz; - distL1 = Math_CosS(this->actor.world.rot.y) * vxz; - vz = Math_SmoothStepToF(&this->actor.home.pos.x, this->waypointPos.x, 1.0f, ABS(vx), 0.0f); - vz += Math_SmoothStepToF(&this->actor.home.pos.y, this->waypointPos.y, 1.0f, ABS(vy), 0.0f); - vz += Math_SmoothStepToF(&this->actor.home.pos.z, this->waypointPos.z, 1.0f, ABS(distL1), 0.0f); - this->bobPhase += (0.05f + (Rand_ZeroOne() * 0.01f)); - if (vz == 0.0f) { - EnBb_SetWaypoint(this, globalCtx); - } - this->moveMode = BBMOVE_NOCLIP; - this->maxSpeed = 10.0f; - if (this->collider.base.atFlags & AT_HIT) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_BITE); - this->collider.base.atFlags &= ~AT_HIT; - } - if (Math_CosF(this->bobPhase) == 0.0f) { - if (this->charge) { - this->bobSpeedMod = Rand_ZeroOne(); - } else { - this->bobSpeedMod = Rand_ZeroOne() * 3.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_LAUGH); - } - } - this->actor.shape.rot.y = this->actor.world.rot.y; - } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f) == 0.0f) { - EnBb_FaceWaypoint(this); - } - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 0); - Math_SmoothStepToS(&this->actor.shape.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &nextPos), 1, 0xFA0, 0); - } - SkelAnime_Update(&this->skelAnime); - if (Math_CosF(this->bobPhase) <= 0.002f) { - this->bobSpeedMod = Rand_ZeroOne() * 0.05f; - } - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, 0, MTXMODE_APPLY); - Matrix_RotateZ(this->bobPhase, MTXMODE_APPLY); - bobOffset.y = this->bobSize; - Matrix_MultVec3f(&bobOffset, &nextPos); - Math_SmoothStepToF(&this->actor.world.pos.x, nextPos.x, 1.0f, this->bobPhase * 0.75f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, nextPos.y, 1.0f, this->bobPhase * 0.75f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, nextPos.z, 1.0f, this->bobPhase * 0.75f, 0.0f); - this->bobPhase += 0.1f + this->bobSpeedMod; - if (Actor_GetCollidedExplosive(globalCtx, &this->collider.base) || (--this->vFlameTimer == 0)) { - this->actionState++; - this->timer = (Rand_ZeroOne() * 30.0f) + 60.0f; - if (this->vFlameTimer != 0) { - this->collider.base.acFlags &= ~AC_HIT; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_DOWN); - } - if (this->actionState != BBGREEN_FLAME_ON) { - this->timer--; - if (this->timer == 0) { - this->actionState = BBGREEN_FLAME_ON; - this->vFlameTimer = (Rand_ZeroOne() * 30.0f) + 180.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_UP); - } - Math_SmoothStepToF(&this->flameScaleY, 0.0f, 1.0f, 10.0f, 0.0f); - Math_SmoothStepToF(&this->flameScaleX, 0.0f, 1.0f, 10.0f, 0.0f); - } else { - Math_SmoothStepToF(&this->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); - Math_SmoothStepToF(&this->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); - } - if ((s32)this->skelAnime.curFrame == 5) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_WING); - } - if (((s32)this->skelAnime.curFrame == 0) && (Rand_ZeroOne() < 0.1f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_LAUGH); - } -} - -void EnBb_SetupStunned(EnBb* this) { - this->action = BB_STUNNED; - if (this->actor.params != ENBB_WHITE) { - if (this->actor.params != ENBB_RED) { - if (this->actor.params > ENBB_GREEN) { - this->actor.gravity = -2.0f; - this->actor.shape.yOffset = 1500.0f; - } - this->actor.speedXZ = 0.0f; - this->flameScaleX = 0.0f; - this->flameScaleY = 0.0f; - } else { - EnBb_KillFlameTrail(this); - } - } - switch (this->dmgEffect) { - case 8: - Actor_SetColorFilter(&this->actor, -0x8000, 0xC8, 0, 0x50); - break; - case 9: - this->fireIceTimer = 0x30; - case 15: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 0xB4, 0, 0x50); - break; - } - this->actor.bgCheckFlags &= ~1; - EnBb_SetupAction(this, EnBb_Stunned); -} - -void EnBb_Stunned(EnBb* this, GlobalContext* globalCtx) { - s16 yawDiff = this->actor.world.rot.y - this->actor.wallYaw; - - if (this->actor.bgCheckFlags & 8) { - if (ABS(yawDiff) > 0x4000) { - this->actor.world.rot.y = this->actor.wallYaw + this->actor.wallYaw - this->actor.world.rot.y - 0x8000; - } - this->actor.bgCheckFlags &= ~8; - } - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - if (this->actor.velocity.y < -14.0f) { - this->actor.velocity.y *= -0.4f; - } else { - this->actor.velocity.y = 0.0f; - } - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); - } - if (this->actor.colorFilterTimer == 0) { - this->actor.shape.yOffset = 200.0f; - if (this->actor.colChkInfo.health != 0) { - if ((this->actor.params == ENBB_GREEN) || (this->actor.params == ENBB_GREEN_BIG)) { - EnBb_SetupGreen(this); - } else if (this->actor.params == ENBB_WHITE) { - this->action = BB_WHITE; - EnBb_SetupAction(this, EnBb_White); - } else { - EnBb_SetupDown(this); - } - } else { - this->actor.flags &= ~ACTOR_FLAG_0; - EnBb_SetupDeath(this, globalCtx); - } - } -} - -void EnBb_CollisionCheck(EnBb* this, GlobalContext* globalCtx) { - if (this->collider.base.atFlags & AT_BOUNCED) { - this->collider.base.atFlags &= ~AT_BOUNCED; - if (this->action != BB_DOWN) { - if (this->actor.params >= ENBB_RED) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer + 0x8000; - if (this->actor.params == ENBB_RED) { - EnBb_KillFlameTrail(this); - } - EnBb_SetupDown(this); - return; - } - this->actionVar2 = 1; - } - } - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - this->dmgEffect = this->actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->actor, &this->collider.elements[0].info, 0); - switch (this->dmgEffect) { - case 7: - this->actor.freezeTimer = this->collider.elements[0].info.acHitInfo->toucher.damage; - case 5: - this->fireIceTimer = 0x30; - //! @bug - //! Setting fireIceTimer here without calling Actor_SetColorFilter causes a crash if the bubble is - //! killed in a single hit by an attack with damage effect 5 or 7 while actor updating is halted. Using - //! Din's Fire on a white bubble will do just that. The mechanism is complex and described below. - goto block_15; - case 6: - this->actor.freezeTimer = this->collider.elements[0].info.acHitInfo->toucher.damage; - break; - case 8: - case 9: - case 15: - if (this->action != BB_STUNNED) { - Actor_ApplyDamage(&this->actor); - EnBb_SetupStunned(this); - } - break; - default: - block_15: - if ((this->dmgEffect == 14) || (this->dmgEffect == 12) || (this->dmgEffect == 11) || - (this->dmgEffect == 10) || (this->dmgEffect == 7) || (this->dmgEffect == 5)) { - if ((this->action != BB_DOWN) || (this->timer < 190)) { - Actor_ApplyDamage(&this->actor); - } - if ((this->action != BB_DOWN) && (this->actor.params != ENBB_WHITE)) { - EnBb_SetupDown(this); - } - } else { - if (((this->action == BB_DOWN) && (this->timer < 190)) || - ((this->actor.params != ENBB_WHITE) && (this->flameScaleX < 20.0f))) { - Actor_ApplyDamage(&this->actor); - } else { - this->collider.base.acFlags |= AC_HIT; - } - } - if (this->actor.colChkInfo.health == 0) { - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->actor.params == ENBB_RED) { - EnBb_KillFlameTrail(this); - } - EnBb_SetupDeath(this, globalCtx); - //! @bug - //! Because Din's Fire kills the bubble in a single hit, Actor_SetColorFilter is never called and - //! colorFilterParams is never set. And because Din's Fire halts updating during its cutscene, - //! EnBb_Death doesn't kill the bubble on the next frame like it should. This combines with - //! the bug in EnBb_Draw below to crash the game. - } else if ((this->actor.params == ENBB_WHITE) && - ((this->action == BB_WHITE) || (this->action == BB_STUNNED))) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0xC); - this->actor.speedXZ = -8.0f; - this->maxSpeed = 0.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_DAMAGE); - } else if (((this->action == BB_DOWN) && (this->timer < 190)) || - ((this->actor.params != ENBB_WHITE) && (this->flameScaleX < 20.0f))) { - EnBb_SetupDamage(this); - } - case 13: - break; - } - } -} - -void EnBb_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnBb* this = (EnBb*)thisx; - Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; - Vec3f sp40 = { 0.0f, -0.6f, 0.0f }; - Color_RGBA8 sp3C = { 0, 0, 255, 255 }; - Color_RGBA8 sp38 = { 0, 0, 0, 0 }; - f32 sp34 = -15.0f; - - if (this->actor.params <= ENBB_BLUE) { - EnBb_CollisionCheck(this, globalCtx); - } - if (this->actor.colChkInfo.damageEffect != 0xD) { - this->actionFunc(this, globalCtx); - if ((this->actor.params <= ENBB_BLUE) && (this->actor.speedXZ >= -6.0f) && - ((this->actor.flags & ACTOR_FLAG_15) == 0)) { - Actor_MoveForward(&this->actor); - } - if (this->moveMode == BBMOVE_NORMAL) { - if ((this->actor.world.pos.y - 20.0f) <= this->actor.floorHeight) { - sp34 = 20.0f; - } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, sp34, 25.0f, 20.0f, 5); - } - this->actor.focus.pos = this->actor.world.pos; - this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements->dim.worldSphere.center.y = - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); - this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; - - if ((this->action > BB_KILL) && ((this->actor.speedXZ != 0.0f) || (this->action == BB_GREEN))) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if ((this->action > BB_FLAME_TRAIL) && - ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000)) && - (this->moveMode != BBMOVE_HIDDEN)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnBb* this = (EnBb*)thisx; - - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 4, 15, 15, dList, BODYBREAK_OBJECT_DEFAULT); -} - -static Vec3f sFireIceOffsets[] = { - { 13.0f, 10.0f, 0.0f }, { 5.0f, 25.0f, 5.0f }, { -5.0f, 25.0f, 5.0f }, { -13.0f, 10.0f, 0.0f }, - { 5.0f, 25.0f, -5.0f }, { -5.0f, 25.0f, -5.0f }, { 0.0f, 10.0f, -13.0f }, { 5.0f, 0.0f, 5.0f }, - { 5.0f, 0.0f, -5.0f }, { 0.0f, 10.0f, 13.0f }, { -5.0f, 0.0f, 5.0f }, { -5.0f, 0.0f, -5.0f }, -}; - -void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnBb* this = (EnBb*)thisx; - Vec3f blureBase1 = { 0.0f, 5000.0f, 0.0f }; - Vec3f blureBase2 = { 0.0f, 2000.0f, 0.0f }; - Vec3f blureVtx1; - Vec3f blureVtx2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bb.c", 2044); - - blureBase1.z = this->maxSpeed * 80.0f; - blureBase2.z = this->maxSpeed * 80.0f; - if (this->moveMode != BBMOVE_HIDDEN) { - if (this->actor.params <= ENBB_BLUE) { - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnBb_PostLimbDraw, - this); - - if (this->fireIceTimer != 0) { - this->actor.colorFilterTimer++; - //! @bug: - //! The purpose of this is to counteract Actor_UpdateAll decrementing colorFilterTimer. However, - //! the above bugs mean unk_2A8 can be nonzero without damage effects ever having been set. - //! This routine will then increment colorFilterTimer, and on the next frame Actor_Draw will try - //! to draw the unset colorFilterParams. This causes a divide-by-zero error, crashing the game. - if (1) {} - this->fireIceTimer--; - if ((this->fireIceTimer % 4) == 0) { - Vec3f sp70; - s32 index = this->fireIceTimer >> 2; - - sp70.x = this->actor.world.pos.x + sFireIceOffsets[index].x; - sp70.y = this->actor.world.pos.y + sFireIceOffsets[index].y; - sp70.z = this->actor.world.pos.z + sFireIceOffsets[index].z; - - if ((this->dmgEffect != 7) && (this->dmgEffect != 5)) { - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &sp70, 0x96, 0x96, 0x96, 0xFA, 0xEB, - 0xF5, 0xFF, 0.8f); - } else { - sp70.y -= 17.0f; - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &sp70, 0x28, 1, 0, -1); - } - } - } - Matrix_Translate(0.0f, this->flameScaleX * -40.0f, 0.0f, MTXMODE_APPLY); - } else { - Matrix_Translate(0.0f, -40.0f, 0.0f, MTXMODE_APPLY); - } - if (this->actor.params != ENBB_WHITE) { - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - ((globalCtx->gameplayFrames + (this->flameScrollMod * 10)) * - (-20 - (this->flameScrollMod * -2))) % - 0x200, - 0x20, 0x80)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, this->flamePrimBlue, this->flamePrimAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, this->flameEnvColor.r, this->flameEnvColor.g, this->flameEnvColor.b, 0); - Matrix_RotateY(((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y + 0x8000)) * - (M_PI / 0x8000), - MTXMODE_APPLY); - Matrix_Scale(this->flameScaleX * 0.01f, this->flameScaleY * 0.01f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bb.c", 2106), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - } else { - Matrix_MultVec3f(&blureBase1, &blureVtx1); - Matrix_MultVec3f(&blureBase2, &blureVtx2); - if ((this->maxSpeed != 0.0f) && (this->action == BB_WHITE) && !(globalCtx->gameplayFrames & 1) && - (this->actor.colChkInfo.health != 0)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &blureVtx1, &blureVtx2); - } else if (this->action != BB_WHITE) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); - } - } - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bb.c", 2127); -} diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.cpp b/src/overlays/actors/ovl_En_Bb/z_en_bb.cpp new file mode 100644 index 000000000..d0374d393 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.cpp @@ -0,0 +1,1367 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BB_Z_EN_BB_C +#include "actor_common.h" +/* + * File: z_en_bb.c + * Overlay: ovl_En_Bb + * Description: Bubble (Flying Skull Enemy) + */ + +#include "z_en_bb.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_Bb/object_Bb.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_24) + +#define vBombHopPhase actionVar1 +#define vTrailIdx actionVar1 +#define vTrailMaxAlpha actionVar2 +#define vMoveAngleY actionVar2 +#define vFlameTimer actionVar2 + +typedef enum { + /* 0 */ BB_DAMAGE, + /* 1 */ BB_KILL, + /* 2 */ BB_FLAME_TRAIL, + /* 3 */ BB_DOWN, + /* 4 */ BB_STUNNED, + /* 5 */ BB_UNUSED, + /* 6 */ BB_BLUE, + /* 7 */ BB_RED, + /* 8 */ BB_WHITE, + /* 9 */ BB_GREEN +} EnBbAction; + +typedef enum { + /* 0 */ BBMOVE_NORMAL, + /* 1 */ BBMOVE_NOCLIP, + /* 2 */ BBMOVE_HIDDEN +} EnBbMoveMode; + +typedef enum { + /* 0 */ BBBLUE_NORMAL, + /* 1 */ BBBLUE_AGGRO +} EnBbBlueActionState; + +typedef enum { + /* 0 */ BBRED_WAIT, + /* 1 */ BBRED_ATTACK, + /* 2 */ BBRED_HIDE +} EnBbRedActionState; + +typedef enum { + /* 0 */ BBGREEN_FLAME_ON, + /* 1 */ BBGREEN_FLAME_OFF +} EnBbGreenActionState; + +// Main functions + +void EnBb_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBb_Update(Actor* pthis, GlobalContext* globalCtx); +void EnBb_Draw(Actor* pthis, GlobalContext* globalCtx); + +// Helper functions + +void EnBb_FaceWaypoint(EnBb* pthis); +void EnBb_SetWaypoint(EnBb* pthis, GlobalContext* globalCtx); + +// Action functions + +void EnBb_SetupFlameTrail(EnBb* pthis); +void EnBb_FlameTrail(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_SetupDeath(EnBb* pthis, GlobalContext* globalCtx); +void EnBb_Death(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_Damage(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_SetupBlue(EnBb* pthis); +void EnBb_Blue(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_SetupDown(EnBb* pthis); +void EnBb_Down(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_SetupRed(GlobalContext* globalCtx, EnBb* pthis); +void EnBb_Red(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_SetupWhite(GlobalContext* globalCtx, EnBb* pthis); +void EnBb_White(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_InitGreen(EnBb* pthis, GlobalContext* globalCtx); +void EnBb_Green(EnBb* pthis, GlobalContext* globalCtx); + +void EnBb_Stunned(EnBb* pthis, GlobalContext* globalCtx); + +static DamageTable sDamageTableBlueGreen = { + /* Deku nut */ DMG_ENTRY(0, 0xF), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0xA), + /* Boomerang */ DMG_ENTRY(0, 0xF), + /* Normal arrow */ DMG_ENTRY(2, 0xE), + /* Hammer swing */ DMG_ENTRY(2, 0xA), + /* Hookshot */ DMG_ENTRY(0, 0xF), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0xE), + /* Ice arrow */ DMG_ENTRY(4, 0xC), + /* Light arrow */ DMG_ENTRY(4, 0xB), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x6), + /* Ice magic */ DMG_ENTRY(3, 0x9), + /* Light magic */ DMG_ENTRY(3, 0x8), + /* Shield */ DMG_ENTRY(0, 0xA), + /* Mirror Ray */ DMG_ENTRY(0, 0xA), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x6), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xA), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static DamageTable sDamageTableRed = { + /* Deku nut */ DMG_ENTRY(0, 0xD), + /* Deku stick */ DMG_ENTRY(0, 0xD), + /* Slingshot */ DMG_ENTRY(0, 0xD), + /* Explosive */ DMG_ENTRY(2, 0xA), + /* Boomerang */ DMG_ENTRY(0, 0xD), + /* Normal arrow */ DMG_ENTRY(2, 0xE), + /* Hammer swing */ DMG_ENTRY(2, 0xA), + /* Hookshot */ DMG_ENTRY(0, 0xD), + /* Kokiri sword */ DMG_ENTRY(0, 0xD), + /* Master sword */ DMG_ENTRY(2, 0xE), + /* Giant's Knife */ DMG_ENTRY(4, 0xE), + /* Fire arrow */ DMG_ENTRY(2, 0xE), + /* Ice arrow */ DMG_ENTRY(4, 0x9), + /* Light arrow */ DMG_ENTRY(2, 0xE), + /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 3 */ DMG_ENTRY(2, 0xE), + /* Fire magic */ DMG_ENTRY(0, 0x6), + /* Ice magic */ DMG_ENTRY(3, 0x9), + /* Light magic */ DMG_ENTRY(0, 0x6), + /* Shield */ DMG_ENTRY(0, 0xA), + /* Mirror Ray */ DMG_ENTRY(0, 0xA), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0xE), + /* Master spin */ DMG_ENTRY(2, 0xE), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0xE), + /* Master jump */ DMG_ENTRY(4, 0xE), + /* Unknown 1 */ DMG_ENTRY(0, 0x6), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xA), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static DamageTable sDamageTableWhite = { + /* Deku nut */ DMG_ENTRY(0, 0xF), + /* Deku stick */ DMG_ENTRY(2, 0xE), + /* Slingshot */ DMG_ENTRY(1, 0xE), + /* Explosive */ DMG_ENTRY(2, 0xA), + /* Boomerang */ DMG_ENTRY(0, 0xF), + /* Normal arrow */ DMG_ENTRY(2, 0xE), + /* Hammer swing */ DMG_ENTRY(2, 0xA), + /* Hookshot */ DMG_ENTRY(0, 0xF), + /* Kokiri sword */ DMG_ENTRY(1, 0xE), + /* Master sword */ DMG_ENTRY(2, 0xE), + /* Giant's Knife */ DMG_ENTRY(4, 0xE), + /* Fire arrow */ DMG_ENTRY(4, 0x5), + /* Ice arrow */ DMG_ENTRY(2, 0xE), + /* Light arrow */ DMG_ENTRY(2, 0xE), + /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 3 */ DMG_ENTRY(2, 0xE), + /* Fire magic */ DMG_ENTRY(4, 0x7), + /* Ice magic */ DMG_ENTRY(0, 0x6), + /* Light magic */ DMG_ENTRY(0, 0x6), + /* Shield */ DMG_ENTRY(0, 0xA), + /* Mirror Ray */ DMG_ENTRY(0, 0xA), + /* Kokiri spin */ DMG_ENTRY(1, 0xE), + /* Giant spin */ DMG_ENTRY(4, 0xE), + /* Master spin */ DMG_ENTRY(2, 0xE), + /* Kokiri jump */ DMG_ENTRY(2, 0xE), + /* Giant jump */ DMG_ENTRY(8, 0xE), + /* Master jump */ DMG_ENTRY(4, 0xE), + /* Unknown 1 */ DMG_ENTRY(0, 0x6), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xA), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +ActorInit En_Bb_InitVars = { + ACTOR_EN_BB, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BB, + sizeof(EnBb), + (ActorFunc)EnBb_Init, + (ActorFunc)EnBb_Destroy, + (ActorFunc)EnBb_Update, + (ActorFunc)EnBb_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, -120, 0 }, 4 }, 300 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), +}; + +void EnBb_SetupAction(EnBb* pthis, EnBbActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +Actor* EnBb_FindExplosive(GlobalContext* globalCtx, EnBb* pthis, f32 range) { + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; + f32 dist; + + while (explosive != NULL) { + if (explosive->params != 0) { + explosive = explosive->next; + continue; + } + dist = Actor_WorldDistXYZToActor(&pthis->actor, explosive); + if ((explosive->params == 0) && (dist <= range)) { + return explosive; + } + explosive = explosive->next; + } + return NULL; +} + +void EnBb_SpawnFlameTrail(GlobalContext* globalCtx, EnBb* pthis, s16 startAtZero) { + EnBb* now = pthis; + EnBb* next; + s32 i; + + for (i = 0; i < 5; i++) { + next = (EnBb*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BB, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); + if (next != NULL) { + now->actor.child = &next->actor; + next->actor.parent = &now->actor; + next->targetActor = &pthis->actor; + next->vTrailIdx = i + 1; + next->actor.scale.x = 1.0f; + next->vTrailMaxAlpha = next->flamePrimAlpha = 255 - (i * 40); + next->flameScaleY = next->actor.scale.y = 0.8f - (i * 0.075f); + next->flameScaleX = next->actor.scale.z = 1.0f - (i * 0.094f); + if (startAtZero) { + next->flamePrimAlpha = 0; + next->flameScaleY = next->flameScaleX = 0.0f; + } + next->flameScrollMod = i + 1; + next->timer = 2 * i + 2; + next->flameEnvColor.r = 255; + now = next; + } + } +} + +void EnBb_KillFlameTrail(EnBb* pthis) { + Actor* actor = &pthis->actor; + + while (actor->child != NULL) { + Actor* nextActor = actor->child; + + if (nextActor->id == ACTOR_EN_BB) { + nextActor->parent = NULL; + actor->child = NULL; + nextActor->params = ENBB_KILL_TRAIL; + } + actor = nextActor; + } + pthis->actor.child = NULL; +} + +void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { + EffectBlureInit1 blureInit; + s32 pad; + EnBb* pthis = (EnBb*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_Bb_Skel_001A30, &object_Bb_Anim_000444, pthis->jointTable, + pthis->morphTable, 16); + pthis->unk_254 = 0; + thisx->colChkInfo.health = 4; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, thisx, &sJntSphInit, pthis->elements); + + pthis->actionState = thisx->params >> 8; + + if (thisx->params & 0x80) { + thisx->params |= 0xFF00; + } + if (thisx->params <= ENBB_BLUE) { + ActorShape_Init(&thisx->shape, 200.0f, ActorShadow_DrawCircle, 35.0f); + } + if (thisx->params & 0xFF00) { + pthis->timer = 0; + pthis->flameScaleY = 80.0f; + pthis->flameScaleX = 100.0f; + pthis->collider.elements[0].info.toucherFlags = TOUCH_ON | TOUCH_SFX_HARD; + pthis->collider.elements[0].info.toucher.dmgFlags = 0xFFCFFFFF; + pthis->collider.elements[0].info.toucher.damage = 8; + pthis->bobSize = pthis->actionState * 20.0f; + pthis->flamePrimAlpha = 255; + pthis->moveMode = BBMOVE_NORMAL; + Actor_SetScale(thisx, 0.01f); + switch (thisx->params) { + case ENBB_BLUE: + thisx->naviEnemyId = 0x1C; + thisx->colChkInfo.damageTable = &sDamageTableBlueGreen; + pthis->flamePrimBlue = pthis->flameEnvColor.b = 255; + thisx->world.pos.y += 50.0f; + EnBb_SetupBlue(pthis); + thisx->flags |= ACTOR_FLAG_14; + break; + case ENBB_RED: + thisx->naviEnemyId = 0x24; + thisx->colChkInfo.damageTable = &sDamageTableRed; + pthis->flameEnvColor.r = 255; + pthis->collider.elements[0].info.toucher.effect = 1; + EnBb_SetupRed(globalCtx, pthis); + break; + case ENBB_WHITE: + thisx->naviEnemyId = 0x1D; + thisx->colChkInfo.damageTable = &sDamageTableWhite; + pthis->path = pthis->actionState; + blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = + blureInit.p1StartColor[3] = blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = + blureInit.p2StartColor[2] = blureInit.p2StartColor[3] = blureInit.p1EndColor[0] = + blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = + blureInit.p2EndColor[1] = blureInit.p2EndColor[2] = 255; + + blureInit.p1EndColor[3] = 0; + blureInit.p2EndColor[3] = 0; + blureInit.elemDuration = 16; + blureInit.unkFlag = 0; + blureInit.calcMode = 2; + + Effect_Add(globalCtx, &pthis->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); + EnBb_SetupWhite(globalCtx, pthis); + EnBb_SetWaypoint(pthis, globalCtx); + EnBb_FaceWaypoint(pthis); + thisx->flags |= ACTOR_FLAG_14; + break; + case ENBB_GREEN_BIG: + pthis->path = pthis->actionState >> 4; + pthis->collider.elements[0].dim.modelSphere.radius = 0x16; + Actor_SetScale(thisx, 0.03f); + case ENBB_GREEN: + thisx->naviEnemyId = 0x1E; + pthis->bobSize = (pthis->actionState & 0xF) * 20.0f; + thisx->colChkInfo.damageTable = &sDamageTableBlueGreen; + pthis->flameEnvColor.g = 255; + thisx->colChkInfo.health = 1; + + EnBb_InitGreen(pthis, globalCtx); + break; + } + thisx->focus.pos = thisx->world.pos; + } else { + EnBb_SetupFlameTrail(pthis); + } + pthis->collider.elements[0].dim.worldSphere.radius = + pthis->collider.elements[0].dim.modelSphere.radius * pthis->collider.elements[0].dim.scale; +} + +void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBb* pthis = (EnBb*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnBb_SetupFlameTrail(EnBb* pthis) { + pthis->action = BB_FLAME_TRAIL; + pthis->moveMode = BBMOVE_NOCLIP; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 0.0f; + EnBb_SetupAction(pthis, EnBb_FlameTrail); +} + +void EnBb_FlameTrail(EnBb* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == ENBB_KILL_TRAIL) { + if (pthis->actor.parent == NULL) { + EnBb_SetupDeath(pthis, globalCtx); + } + } else { + if (pthis->timer == 0) { + if (((EnBb*)pthis->targetActor)->flameScaleY != 0.0f) { + Math_SmoothStepToF(&pthis->flameScaleY, pthis->actor.scale.y, 1.0f, pthis->actor.scale.y * 0.1f, 0.0f); + Math_SmoothStepToF(&pthis->flameScaleX, pthis->actor.scale.z, 1.0f, pthis->actor.scale.z * 0.1f, 0.0f); + if (pthis->flamePrimAlpha != pthis->vTrailMaxAlpha) { + pthis->flamePrimAlpha += 10; + if (pthis->vTrailMaxAlpha < pthis->flamePrimAlpha) { + pthis->flamePrimAlpha = pthis->vTrailMaxAlpha; + } + } + } else { + if (!pthis->flamePrimAlpha) { + Actor_Kill(&pthis->actor); + return; + } else if (pthis->flamePrimAlpha <= 20) { + pthis->flamePrimAlpha = 0; + } else { + pthis->flamePrimAlpha -= 20; + } + } + pthis->actor.world.pos = pthis->actor.parent->prevPos; + } else { + pthis->timer--; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.parent->world.rot.y; + } + } + if (pthis->actor.parent != NULL) { + pthis->actor.velocity.y = pthis->actor.parent->velocity.y; + } +} + +void EnBb_SetupDeath(EnBb* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params <= ENBB_BLUE) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = -7.0f; + pthis->timer = 5; + pthis->actor.shape.rot.x += 0x4E20; + EffectSsDeadSound_SpawnStationary(globalCtx, &pthis->actor.projectedPos, NA_SE_EN_BUBLE_DEAD, 1, 1, 0x28); + } + pthis->action = BB_KILL; + EnBb_SetupAction(pthis, EnBb_Death); +} + +void EnBb_Death(EnBb* pthis, GlobalContext* globalCtx) { + s16 enpartType = 3; + Vec3f sp40 = { 0.0f, 0.5f, 0.0f }; + Vec3f sp34 = { 0.0f, 0.0f, 0.0f }; + + if (pthis->actor.params <= ENBB_BLUE) { + Math_SmoothStepToF(&pthis->flameScaleY, 0.0f, 1.0f, 30.0f, 0.0f); + Math_SmoothStepToF(&pthis->flameScaleX, 0.0f, 1.0f, 30.0f, 0.0f); + if (pthis->timer != 0) { + pthis->timer--; + pthis->actor.shape.rot.x -= 0x4E20; + return; + } + + if (pthis->bodyBreak.val == BODYBREAK_STATUS_FINISHED) { + BodyBreak_Alloc(&pthis->bodyBreak, 12, globalCtx); + } + + if ((pthis->dmgEffect == 7) || (pthis->dmgEffect == 5)) { + enpartType = 11; + } + + if (!BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, enpartType)) { + return; + } + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xD0); + } else { + if (pthis->flamePrimAlpha) { + if (pthis->flamePrimAlpha <= 20) { + pthis->flamePrimAlpha = 0; + } else { + pthis->flamePrimAlpha -= 20; + } + return; + } + } + Actor_Kill(&pthis->actor); +} + +void EnBb_SetupDamage(EnBb* pthis) { + pthis->action = BB_DAMAGE; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_DAMAGE); + if (pthis->actor.params > ENBB_GREEN) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if ((pthis->actor.bgCheckFlags & 8) == 0) { + pthis->actor.speedXZ = -7.0f; + } + pthis->actor.shape.yOffset = 1500.0f; + } + if (pthis->actor.params == ENBB_RED) { + EnBb_KillFlameTrail(pthis); + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0xC); + pthis->timer = 5; + EnBb_SetupAction(pthis, EnBb_Damage); +} + +void EnBb_Damage(EnBb* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if (pthis->actor.speedXZ == 0.0f) { + pthis->actor.shape.yOffset = 200.0f; + EnBb_SetupDown(pthis); + } +} + +void EnBb_SetupBlue(EnBb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + pthis->actor.speedXZ = (Rand_ZeroOne() * 0.5f) + 0.5f; + pthis->timer = (Rand_ZeroOne() * 20.0f) + 40.0f; + pthis->unk_264 = (Rand_ZeroOne() * 30.0f) + 180.0f; + pthis->targetActor = NULL; + pthis->action = BB_BLUE; + EnBb_SetupAction(pthis, EnBb_Blue); +} + +void EnBb_Blue(EnBb* pthis, GlobalContext* globalCtx) { + Actor* explosive; + s16 moveYawToWall; + s16 thisYawToWall; + s16 afterHitAngle; + + Math_SmoothStepToF(&pthis->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToF(&pthis->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); + if (pthis->actor.floorHeight > BGCHECK_Y_MIN) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 50.0f + pthis->flyHeightMod, 1.0f, 0.5f, + 0.0f); + } + SkelAnime_Update(&pthis->skelAnime); + if (Math_CosF(pthis->bobPhase) == 0.0f) { + if (pthis->charge) { + pthis->bobSpeedMod = Rand_ZeroOne() * 2.0f; + } else { + pthis->bobSpeedMod = Rand_ZeroOne() * 4.0f; + } + } + pthis->actor.world.pos.y += Math_CosF(pthis->bobPhase) * (1.0f + pthis->bobSpeedMod); + pthis->bobPhase += 0.2f; + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->maxSpeed, 1.0f, 0.5f, 0.0f); + + if (Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) > 300.0f) { + pthis->vMoveAngleY = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->vMoveAngleY, 1, 0x7D0, 0); + } else { + pthis->timer--; + if (pthis->timer <= 0) { + pthis->charge ^= true; + pthis->flyHeightMod = (s16)(Math_CosF(pthis->bobPhase) * 10.0f); + pthis->actor.speedXZ = 0.0f; + if (pthis->charge && (pthis->targetActor == NULL)) { + pthis->vMoveAngleY = pthis->actor.world.rot.y; + if (pthis->actor.xzDistToPlayer < 200.0f) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000184); + pthis->vMoveAngleY = pthis->actor.yawTowardsPlayer; + } + pthis->maxSpeed = (Rand_ZeroOne() * 1.5f) + 6.0f; + pthis->timer = (Rand_ZeroOne() * 5.0f) + 20.0f; + pthis->actionState = BBBLUE_NORMAL; + } else { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + pthis->maxSpeed = (Rand_ZeroOne() * 1.5f) + 1.0f; + pthis->timer = (Rand_ZeroOne() * 20.0f) + 40.0f; + pthis->vMoveAngleY = Math_SinF(pthis->bobPhase) * 65535.0f; + } + } + if ((pthis->actor.xzDistToPlayer < 150.0f) && (pthis->actionState != BBBLUE_NORMAL)) { + if (!pthis->charge) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000184); + pthis->maxSpeed = (Rand_ZeroOne() * 1.5f) + 6.0f; + pthis->timer = (Rand_ZeroOne() * 5.0f) + 20.0f; + pthis->vMoveAngleY = pthis->actor.yawTowardsPlayer; + pthis->actionState = pthis->charge = true; // Sets actionState to BBBLUE_AGGRO + } + } else if (pthis->actor.xzDistToPlayer < 200.0f) { + pthis->vMoveAngleY = pthis->actor.yawTowardsPlayer; + } + if (pthis->targetActor == NULL) { + explosive = EnBb_FindExplosive(globalCtx, pthis, 300.0f); + } else if (pthis->targetActor->params == 0) { + explosive = pthis->targetActor; + } else { + explosive = NULL; + } + if (explosive != NULL) { + pthis->vMoveAngleY = Actor_WorldYawTowardActor(&pthis->actor, explosive); + if ((pthis->vBombHopPhase == 0) && (explosive != pthis->targetActor)) { + pthis->vBombHopPhase = -0x8000; + pthis->targetActor = explosive; + pthis->actor.speedXZ *= 0.5f; + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->vMoveAngleY, 1, 0x1388, 0); + Math_SmoothStepToF(&pthis->actor.world.pos.x, explosive->world.pos.x, 1.0f, 1.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, explosive->world.pos.y + 40.0f, 1.0f, 1.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, explosive->world.pos.z, 1.0f, 1.5f, 0.0f); + } else { + pthis->targetActor = NULL; + } + if (pthis->vBombHopPhase != 0) { + pthis->actor.world.pos.y += -Math_CosS(pthis->vBombHopPhase) * 10.0f; + pthis->vBombHopPhase += 0x1000; + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->vMoveAngleY, 1, 0x7D0, 0); + } + thisYawToWall = pthis->actor.wallYaw - pthis->actor.world.rot.y; + moveYawToWall = pthis->actor.wallYaw - pthis->vMoveAngleY; + if ((pthis->targetActor == NULL) && (pthis->actor.bgCheckFlags & 8) && + (ABS(thisYawToWall) > 0x4000 || ABS(moveYawToWall) > 0x4000)) { + pthis->vMoveAngleY = pthis->actor.wallYaw + pthis->actor.wallYaw - pthis->actor.world.rot.y - 0x8000; + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->vMoveAngleY, 1, 0xBB8, 0); + } + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->vMoveAngleY, 1, 0x3E8, 0); + if ((pthis->collider.base.acFlags & AC_HIT) || (pthis->collider.base.atFlags & AT_HIT)) { + pthis->vMoveAngleY = pthis->actor.yawTowardsPlayer + 0x8000; + if (pthis->collider.base.acFlags & AC_HIT) { + afterHitAngle = -0x8000; + } else { + afterHitAngle = 0x4000; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_BITE); + if (globalCtx->gameplayFrames & 1) { + afterHitAngle = -0x4000; + } + } + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + afterHitAngle; + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.atFlags &= ~AT_HIT; + } + + if (pthis->maxSpeed >= 6.0f) { + if ((s32)pthis->skelAnime.curFrame == 0 || (s32)pthis->skelAnime.curFrame == 5) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_MOUTH); + } else if ((s32)pthis->skelAnime.curFrame == 2 || (s32)pthis->skelAnime.curFrame == 7) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_WING); + } + } else { + if ((s32)pthis->skelAnime.curFrame == 5) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_WING); + } + } + if (((s32)pthis->skelAnime.curFrame == 0) && (Rand_ZeroOne() < 0.1f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_LAUGH); + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnBb_SetupDown(EnBb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + pthis->action = BB_DOWN; + pthis->timer = 200; + pthis->actor.colorFilterTimer = 0; + pthis->actor.bgCheckFlags &= ~1; + pthis->actor.speedXZ = 3.0f; + pthis->flameScaleX = 0.0f; + pthis->flameScaleY = 0.0f; + pthis->actor.gravity = -2.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_DOWN); + EnBb_SetupAction(pthis, EnBb_Down); +} + +void EnBb_Down(EnBb* pthis, GlobalContext* globalCtx) { + s16 yawDiff = pthis->actor.world.rot.y - pthis->actor.wallYaw; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.bgCheckFlags & 8) { + if (ABS(yawDiff) > 0x4000) { + pthis->actor.world.rot.y = pthis->actor.wallYaw + pthis->actor.wallYaw - pthis->actor.world.rot.y - 0x8000; + } + pthis->actor.bgCheckFlags &= ~8; + } + if (pthis->actor.bgCheckFlags & 3) { + if (pthis->actor.params == ENBB_RED) { + s32 floorType = func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + + if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + pthis->moveMode = BBMOVE_HIDDEN; + pthis->timer = 10; + pthis->actionState++; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->action = BB_RED; + EnBb_SetupAction(pthis, EnBb_Red); + return; + } + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + if (pthis->actor.velocity.y < -14.0f) { + pthis->actor.velocity.y *= -0.7f; + } else { + pthis->actor.velocity.y = 10.0f; + } + pthis->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.y, -pthis->actor.yawTowardsPlayer, 1, 0xBB8, 0); + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if ((s32)pthis->skelAnime.curFrame == 5) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_WING); + } + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_UP); + switch (pthis->actor.params) { + case ENBB_BLUE: + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + EnBb_SetupBlue(pthis); + break; + case ENBB_RED: + if (pthis->actor.velocity.y == 10.0f) { + EnBb_SetupRed(globalCtx, pthis); + EnBb_SpawnFlameTrail(globalCtx, pthis, true); + } + break; + case ENBB_WHITE: + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + EnBb_SetupWhite(globalCtx, pthis); + pthis->actor.world.pos.y -= 60.0f; + break; + } + } else { + pthis->timer--; + } +} + +void EnBb_SetupRed(GlobalContext* globalCtx, EnBb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000184); + if (pthis->action == BB_DOWN) { + pthis->actor.speedXZ = 5.0f; + pthis->actor.gravity = -1.0f; + pthis->actor.velocity.y = 16.0f; + pthis->actionState = BBRED_ATTACK; + pthis->timer = 0; + pthis->moveMode = BBMOVE_NORMAL; + pthis->actor.bgCheckFlags &= ~1; + } else { + pthis->actor.colChkInfo.health = 4; + pthis->timer = 0; + pthis->actionState = BBRED_WAIT; + pthis->moveMode = BBMOVE_HIDDEN; + pthis->actor.world.pos.y -= 80.0f; + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actor.velocity.y = pthis->actor.gravity = pthis->actor.speedXZ = 0.0f; + pthis->actor.bgCheckFlags &= ~1; + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + pthis->action = BB_RED; + EnBb_SetupAction(pthis, EnBb_Red); +} + +void EnBb_Red(EnBb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 floorType; + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + switch (pthis->actionState) { + case BBRED_WAIT: + if ((Actor_WorldDistXYZToActor(&pthis->actor, &player->actor) <= 250.0f) && (ABS(yawDiff) <= 0x4000) && + (pthis->timer == 0)) { + pthis->actor.speedXZ = 5.0f; + pthis->actor.gravity = -1.0f; + pthis->actor.velocity.y = 18.0f; + pthis->moveMode = BBMOVE_NOCLIP; + pthis->timer = 7; + pthis->actor.bgCheckFlags &= ~1; + pthis->actionState++; + EnBb_SpawnFlameTrail(globalCtx, pthis, false); + } + break; + case BBRED_ATTACK: + if (pthis->timer == 0) { + pthis->moveMode = BBMOVE_NORMAL; + pthis->actor.flags |= ACTOR_FLAG_0; + } + pthis->bobPhase += Rand_ZeroOne(); + Math_SmoothStepToF(&pthis->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToF(&pthis->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); + if (pthis->actor.bgCheckFlags & 8) { + yawDiff = pthis->actor.world.rot.y - pthis->actor.wallYaw; + if (ABS(yawDiff) > 0x4000) { + pthis->actor.world.rot.y = + pthis->actor.wallYaw + pthis->actor.wallYaw - pthis->actor.world.rot.y - 0x8000; + } + pthis->actor.bgCheckFlags &= ~8; + } + if (pthis->actor.bgCheckFlags & 1) { + floorType = func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + pthis->moveMode = BBMOVE_HIDDEN; + pthis->timer = 10; + pthis->actionState++; + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else { + pthis->actor.velocity.y *= -1.06f; + if (pthis->actor.velocity.y > 13.0f) { + pthis->actor.velocity.y = 13.0f; + } + pthis->actor.world.rot.y = Math_SinF(pthis->bobPhase) * 65535.0f; + } + pthis->actor.bgCheckFlags &= ~1; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (Actor_GetCollidedExplosive(globalCtx, &pthis->collider.base) != NULL) { + EnBb_SetupDown(pthis); + } + break; + case BBRED_HIDE: + if (pthis->timer == 0) { + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actionState = BBRED_WAIT; + pthis->timer = 120; + pthis->actor.world.pos = pthis->actor.home.pos; + pthis->actor.shape.rot = pthis->actor.world.rot = pthis->actor.home.rot; + EnBb_KillFlameTrail(pthis); + } + break; + } + if (pthis->actionState != BBRED_WAIT) { + if (((s32)pthis->skelAnime.curFrame == 0) || ((s32)pthis->skelAnime.curFrame == 5)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_MOUTH); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); + } +} + +void EnBb_FaceWaypoint(EnBb* pthis) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->waypointPos); +} + +void EnBb_SetWaypoint(EnBb* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->path]; + Vec3s* point; + + if (pthis->waypoint == (s16)(path->count - 1)) { + pthis->waypoint = 0; + } else { + pthis->waypoint++; + } + point = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->waypoint; + pthis->waypointPos.x = point->x; + pthis->waypointPos.y = point->y; + pthis->waypointPos.z = point->z; +} + +void EnBb_SetupWhite(GlobalContext* globalCtx, EnBb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.pos.y += 60.0f; + pthis->flameScaleX = 100.0f; + pthis->action = BB_WHITE; + pthis->waypoint = 0; + pthis->timer = (Rand_ZeroOne() * 30.0f) + 40.0f; + pthis->maxSpeed = 7.0f; + EnBb_SetupAction(pthis, EnBb_White); +} + +void EnBb_White(EnBb* pthis, GlobalContext* globalCtx) { + if (pthis->actor.speedXZ == 0.0f) { + f32 distL1; + f32 vx; + f32 vz; + s16 pitch = Math_Vec3f_Pitch(&pthis->actor.world.pos, &pthis->waypointPos); + f32 vy = Math_SinS(pitch) * pthis->maxSpeed; + f32 vxz = Math_CosS(pitch) * pthis->maxSpeed; + + vx = Math_SinS(pthis->actor.shape.rot.y) * vxz; + vz = Math_CosS(pthis->actor.shape.rot.y) * vxz; + distL1 = Math_SmoothStepToF(&pthis->actor.world.pos.x, pthis->waypointPos.x, 1.0f, ABS(vx), 0.0f); + distL1 += Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->waypointPos.y, 1.0f, ABS(vy), 0.0f); + distL1 += Math_SmoothStepToF(&pthis->actor.world.pos.z, pthis->waypointPos.z, 1.0f, ABS(vz), 0.0f); + pthis->bobPhase += (0.05f + (Rand_ZeroOne() * 0.01f)); + if (distL1 == 0.0f) { + pthis->timer--; + if (pthis->timer == 0) { + EnBb_SetWaypoint(pthis, globalCtx); + EnBb_FaceWaypoint(pthis); + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000184); + pthis->timer = Rand_ZeroOne() * 30.0f + 40.0f; + } else { + if (pthis->moveMode != BBMOVE_NORMAL) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + } + pthis->actor.world.rot.y += 0x1F40; + } + pthis->moveMode = BBMOVE_NORMAL; + pthis->maxSpeed = 0.0f; + } else { + pthis->moveMode = BBMOVE_NOCLIP; + pthis->maxSpeed = 10.0f; + } + if (pthis->collider.base.atFlags & AT_HIT) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_BITE); + pthis->collider.base.atFlags &= ~AT_HIT; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } else if (Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f) == 0.0f) { + EnBb_FaceWaypoint(pthis); + } + SkelAnime_Update(&pthis->skelAnime); + if (((s32)pthis->skelAnime.curFrame == 0) && (Rand_ZeroOne() <= 0.1f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_LAUGH); + } + + if ((pthis->maxSpeed != 0.0f) && (((s32)pthis->skelAnime.curFrame == 0) || ((s32)pthis->skelAnime.curFrame == 5))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_MOUTH); + } else if (((s32)pthis->skelAnime.curFrame == 2) || ((s32)pthis->skelAnime.curFrame == 7)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_WING); + } +} + +void EnBb_InitGreen(EnBb* pthis, GlobalContext* globalCtx) { + Vec3f bobOffset = { 0.0f, 0.0f, 0.0f }; + + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + pthis->moveMode = BBMOVE_NOCLIP; + pthis->actionState = BBGREEN_FLAME_ON; + pthis->bobPhase = Rand_ZeroOne(); + pthis->actor.shape.rot.x = pthis->actor.shape.rot.z = 0; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + if (pthis->actor.params == ENBB_GREEN_BIG) { + EnBb_SetWaypoint(pthis, globalCtx); + EnBb_FaceWaypoint(pthis); + } + Matrix_Translate(pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, 0, MTXMODE_APPLY); + Matrix_RotateZ(pthis->bobPhase, MTXMODE_APPLY); + bobOffset.y = pthis->bobSize; + Matrix_MultVec3f(&bobOffset, &pthis->actor.world.pos); + pthis->targetActor = NULL; + pthis->action = BB_GREEN; + pthis->actor.speedXZ = 0.0f; + pthis->vFlameTimer = (Rand_ZeroOne() * 30.0f) + 180.0f; + EnBb_SetupAction(pthis, EnBb_Green); +} + +void EnBb_SetupGreen(EnBb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_Bb_Anim_000444); + pthis->moveMode = BBMOVE_NOCLIP; + pthis->actionState = BBGREEN_FLAME_ON; + pthis->targetActor = NULL; + pthis->action = BB_GREEN; + pthis->actor.speedXZ = 0.0f; + pthis->vFlameTimer = (Rand_ZeroOne() * 30.0f) + 180.0f; + pthis->actor.shape.rot.z = 0; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + EnBb_SetupAction(pthis, EnBb_Green); +} + +void EnBb_Green(EnBb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f bobOffset = { 0.0f, 0.0f, 0.0f }; + Vec3f nextPos = player->actor.world.pos; + + nextPos.y += 30.0f; + if (pthis->actor.params == ENBB_GREEN_BIG) { + if (pthis->actor.speedXZ == 0.0f) { + s16 pitch = Math_Vec3f_Pitch(&pthis->actor.home.pos, &pthis->waypointPos); + s16 yaw = Math_Vec3f_Yaw(&pthis->actor.home.pos, &pthis->waypointPos); + f32 vy = Math_SinS(pitch) * pthis->maxSpeed; + f32 vxz = Math_CosS(pitch) * pthis->maxSpeed; + f32 vz; + f32 vx; + f32 distL1; + + Math_SmoothStepToS(&pthis->actor.world.rot.y, yaw, 1, 0x3E8, 0); + vx = Math_SinS(pthis->actor.world.rot.y) * vxz; + distL1 = Math_CosS(pthis->actor.world.rot.y) * vxz; + vz = Math_SmoothStepToF(&pthis->actor.home.pos.x, pthis->waypointPos.x, 1.0f, ABS(vx), 0.0f); + vz += Math_SmoothStepToF(&pthis->actor.home.pos.y, pthis->waypointPos.y, 1.0f, ABS(vy), 0.0f); + vz += Math_SmoothStepToF(&pthis->actor.home.pos.z, pthis->waypointPos.z, 1.0f, ABS(distL1), 0.0f); + pthis->bobPhase += (0.05f + (Rand_ZeroOne() * 0.01f)); + if (vz == 0.0f) { + EnBb_SetWaypoint(pthis, globalCtx); + } + pthis->moveMode = BBMOVE_NOCLIP; + pthis->maxSpeed = 10.0f; + if (pthis->collider.base.atFlags & AT_HIT) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_BITE); + pthis->collider.base.atFlags &= ~AT_HIT; + } + if (Math_CosF(pthis->bobPhase) == 0.0f) { + if (pthis->charge) { + pthis->bobSpeedMod = Rand_ZeroOne(); + } else { + pthis->bobSpeedMod = Rand_ZeroOne() * 3.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_LAUGH); + } + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } else if (Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f) == 0.0f) { + EnBb_FaceWaypoint(pthis); + } + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, Math_Vec3f_Pitch(&pthis->actor.world.pos, &nextPos), 1, 0xFA0, 0); + } + SkelAnime_Update(&pthis->skelAnime); + if (Math_CosF(pthis->bobPhase) <= 0.002f) { + pthis->bobSpeedMod = Rand_ZeroOne() * 0.05f; + } + Matrix_Translate(pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, 0, MTXMODE_APPLY); + Matrix_RotateZ(pthis->bobPhase, MTXMODE_APPLY); + bobOffset.y = pthis->bobSize; + Matrix_MultVec3f(&bobOffset, &nextPos); + Math_SmoothStepToF(&pthis->actor.world.pos.x, nextPos.x, 1.0f, pthis->bobPhase * 0.75f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, nextPos.y, 1.0f, pthis->bobPhase * 0.75f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, nextPos.z, 1.0f, pthis->bobPhase * 0.75f, 0.0f); + pthis->bobPhase += 0.1f + pthis->bobSpeedMod; + if (Actor_GetCollidedExplosive(globalCtx, &pthis->collider.base) || (--pthis->vFlameTimer == 0)) { + pthis->actionState++; + pthis->timer = (Rand_ZeroOne() * 30.0f) + 60.0f; + if (pthis->vFlameTimer != 0) { + pthis->collider.base.acFlags &= ~AC_HIT; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_DOWN); + } + if (pthis->actionState != BBGREEN_FLAME_ON) { + pthis->timer--; + if (pthis->timer == 0) { + pthis->actionState = BBGREEN_FLAME_ON; + pthis->vFlameTimer = (Rand_ZeroOne() * 30.0f) + 180.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_UP); + } + Math_SmoothStepToF(&pthis->flameScaleY, 0.0f, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToF(&pthis->flameScaleX, 0.0f, 1.0f, 10.0f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToF(&pthis->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); + } + if ((s32)pthis->skelAnime.curFrame == 5) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_WING); + } + if (((s32)pthis->skelAnime.curFrame == 0) && (Rand_ZeroOne() < 0.1f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_LAUGH); + } +} + +void EnBb_SetupStunned(EnBb* pthis) { + pthis->action = BB_STUNNED; + if (pthis->actor.params != ENBB_WHITE) { + if (pthis->actor.params != ENBB_RED) { + if (pthis->actor.params > ENBB_GREEN) { + pthis->actor.gravity = -2.0f; + pthis->actor.shape.yOffset = 1500.0f; + } + pthis->actor.speedXZ = 0.0f; + pthis->flameScaleX = 0.0f; + pthis->flameScaleY = 0.0f; + } else { + EnBb_KillFlameTrail(pthis); + } + } + switch (pthis->dmgEffect) { + case 8: + Actor_SetColorFilter(&pthis->actor, -0x8000, 0xC8, 0, 0x50); + break; + case 9: + pthis->fireIceTimer = 0x30; + case 15: + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Actor_SetColorFilter(&pthis->actor, 0, 0xB4, 0, 0x50); + break; + } + pthis->actor.bgCheckFlags &= ~1; + EnBb_SetupAction(pthis, EnBb_Stunned); +} + +void EnBb_Stunned(EnBb* pthis, GlobalContext* globalCtx) { + s16 yawDiff = pthis->actor.world.rot.y - pthis->actor.wallYaw; + + if (pthis->actor.bgCheckFlags & 8) { + if (ABS(yawDiff) > 0x4000) { + pthis->actor.world.rot.y = pthis->actor.wallYaw + pthis->actor.wallYaw - pthis->actor.world.rot.y - 0x8000; + } + pthis->actor.bgCheckFlags &= ~8; + } + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + if (pthis->actor.velocity.y < -14.0f) { + pthis->actor.velocity.y *= -0.4f; + } else { + pthis->actor.velocity.y = 0.0f; + } + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + } + if (pthis->actor.colorFilterTimer == 0) { + pthis->actor.shape.yOffset = 200.0f; + if (pthis->actor.colChkInfo.health != 0) { + if ((pthis->actor.params == ENBB_GREEN) || (pthis->actor.params == ENBB_GREEN_BIG)) { + EnBb_SetupGreen(pthis); + } else if (pthis->actor.params == ENBB_WHITE) { + pthis->action = BB_WHITE; + EnBb_SetupAction(pthis, EnBb_White); + } else { + EnBb_SetupDown(pthis); + } + } else { + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnBb_SetupDeath(pthis, globalCtx); + } + } +} + +void EnBb_CollisionCheck(EnBb* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.atFlags & AT_BOUNCED) { + pthis->collider.base.atFlags &= ~AT_BOUNCED; + if (pthis->action != BB_DOWN) { + if (pthis->actor.params >= ENBB_RED) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + if (pthis->actor.params == ENBB_RED) { + EnBb_KillFlameTrail(pthis); + } + EnBb_SetupDown(pthis); + return; + } + pthis->actionVar2 = 1; + } + } + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->dmgEffect = pthis->actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.elements[0].info, 0); + switch (pthis->dmgEffect) { + case 7: + pthis->actor.freezeTimer = pthis->collider.elements[0].info.acHitInfo->toucher.damage; + case 5: + pthis->fireIceTimer = 0x30; + //! @bug + //! Setting fireIceTimer here without calling Actor_SetColorFilter causes a crash if the bubble is + //! killed in a single hit by an attack with damage effect 5 or 7 while actor updating is halted. Using + //! Din's Fire on a white bubble will do just that. The mechanism is complex and described below. + goto block_15; + case 6: + pthis->actor.freezeTimer = pthis->collider.elements[0].info.acHitInfo->toucher.damage; + break; + case 8: + case 9: + case 15: + if (pthis->action != BB_STUNNED) { + Actor_ApplyDamage(&pthis->actor); + EnBb_SetupStunned(pthis); + } + break; + default: + block_15: + if ((pthis->dmgEffect == 14) || (pthis->dmgEffect == 12) || (pthis->dmgEffect == 11) || + (pthis->dmgEffect == 10) || (pthis->dmgEffect == 7) || (pthis->dmgEffect == 5)) { + if ((pthis->action != BB_DOWN) || (pthis->timer < 190)) { + Actor_ApplyDamage(&pthis->actor); + } + if ((pthis->action != BB_DOWN) && (pthis->actor.params != ENBB_WHITE)) { + EnBb_SetupDown(pthis); + } + } else { + if (((pthis->action == BB_DOWN) && (pthis->timer < 190)) || + ((pthis->actor.params != ENBB_WHITE) && (pthis->flameScaleX < 20.0f))) { + Actor_ApplyDamage(&pthis->actor); + } else { + pthis->collider.base.acFlags |= AC_HIT; + } + } + if (pthis->actor.colChkInfo.health == 0) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->actor.params == ENBB_RED) { + EnBb_KillFlameTrail(pthis); + } + EnBb_SetupDeath(pthis, globalCtx); + //! @bug + //! Because Din's Fire kills the bubble in a single hit, Actor_SetColorFilter is never called and + //! colorFilterParams is never set. And because Din's Fire halts updating during its cutscene, + //! EnBb_Death doesn't kill the bubble on the next frame like it should. This combines with + //! the bug in EnBb_Draw below to crash the game. + } else if ((pthis->actor.params == ENBB_WHITE) && + ((pthis->action == BB_WHITE) || (pthis->action == BB_STUNNED))) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0xC); + pthis->actor.speedXZ = -8.0f; + pthis->maxSpeed = 0.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_DAMAGE); + } else if (((pthis->action == BB_DOWN) && (pthis->timer < 190)) || + ((pthis->actor.params != ENBB_WHITE) && (pthis->flameScaleX < 20.0f))) { + EnBb_SetupDamage(pthis); + } + case 13: + break; + } + } +} + +void EnBb_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBb* pthis = (EnBb*)thisx; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp40 = { 0.0f, -0.6f, 0.0f }; + Color_RGBA8 sp3C = { 0, 0, 255, 255 }; + Color_RGBA8 sp38 = { 0, 0, 0, 0 }; + f32 sp34 = -15.0f; + + if (pthis->actor.params <= ENBB_BLUE) { + EnBb_CollisionCheck(pthis, globalCtx); + } + if (pthis->actor.colChkInfo.damageEffect != 0xD) { + pthis->actionFunc(pthis, globalCtx); + if ((pthis->actor.params <= ENBB_BLUE) && (pthis->actor.speedXZ >= -6.0f) && + ((pthis->actor.flags & ACTOR_FLAG_15) == 0)) { + Actor_MoveForward(&pthis->actor); + } + if (pthis->moveMode == BBMOVE_NORMAL) { + if ((pthis->actor.world.pos.y - 20.0f) <= pthis->actor.floorHeight) { + sp34 = 20.0f; + } + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, sp34, 25.0f, 20.0f, 5); + } + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->collider.elements->dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->collider.elements->dim.worldSphere.center.y = + pthis->actor.world.pos.y + (pthis->actor.shape.yOffset * pthis->actor.scale.y); + pthis->collider.elements->dim.worldSphere.center.z = pthis->actor.world.pos.z; + + if ((pthis->action > BB_KILL) && ((pthis->actor.speedXZ != 0.0f) || (pthis->action == BB_GREEN))) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if ((pthis->action > BB_FLAME_TRAIL) && + ((pthis->actor.colorFilterTimer == 0) || !(pthis->actor.colorFilterParams & 0x4000)) && + (pthis->moveMode != BBMOVE_HIDDEN)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnBb* pthis = (EnBb*)thisx; + + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 4, 15, 15, dList, BODYBREAK_OBJECT_DEFAULT); +} + +static Vec3f sFireIceOffsets[] = { + { 13.0f, 10.0f, 0.0f }, { 5.0f, 25.0f, 5.0f }, { -5.0f, 25.0f, 5.0f }, { -13.0f, 10.0f, 0.0f }, + { 5.0f, 25.0f, -5.0f }, { -5.0f, 25.0f, -5.0f }, { 0.0f, 10.0f, -13.0f }, { 5.0f, 0.0f, 5.0f }, + { 5.0f, 0.0f, -5.0f }, { 0.0f, 10.0f, 13.0f }, { -5.0f, 0.0f, 5.0f }, { -5.0f, 0.0f, -5.0f }, +}; + +void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBb* pthis = (EnBb*)thisx; + Vec3f blureBase1 = { 0.0f, 5000.0f, 0.0f }; + Vec3f blureBase2 = { 0.0f, 2000.0f, 0.0f }; + Vec3f blureVtx1; + Vec3f blureVtx2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bb.c", 2044); + + blureBase1.z = pthis->maxSpeed * 80.0f; + blureBase2.z = pthis->maxSpeed * 80.0f; + if (pthis->moveMode != BBMOVE_HIDDEN) { + if (pthis->actor.params <= ENBB_BLUE) { + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, EnBb_PostLimbDraw, + pthis); + + if (pthis->fireIceTimer != 0) { + pthis->actor.colorFilterTimer++; + //! @bug: + //! The purpose of pthis is to counteract Actor_UpdateAll decrementing colorFilterTimer. However, + //! the above bugs mean unk_2A8 can be nonzero without damage effects ever having been set. + //! This routine will then increment colorFilterTimer, and on the next frame Actor_Draw will try + //! to draw the unset colorFilterParams. This causes a divide-by-zero error, crashing the game. + if (1) {} + pthis->fireIceTimer--; + if ((pthis->fireIceTimer % 4) == 0) { + Vec3f sp70; + s32 index = pthis->fireIceTimer >> 2; + + sp70.x = pthis->actor.world.pos.x + sFireIceOffsets[index].x; + sp70.y = pthis->actor.world.pos.y + sFireIceOffsets[index].y; + sp70.z = pthis->actor.world.pos.z + sFireIceOffsets[index].z; + + if ((pthis->dmgEffect != 7) && (pthis->dmgEffect != 5)) { + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &sp70, 0x96, 0x96, 0x96, 0xFA, 0xEB, + 0xF5, 0xFF, 0.8f); + } else { + sp70.y -= 17.0f; + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &sp70, 0x28, 1, 0, -1); + } + } + } + Matrix_Translate(0.0f, pthis->flameScaleX * -40.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, -40.0f, 0.0f, MTXMODE_APPLY); + } + if (pthis->actor.params != ENBB_WHITE) { + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + ((globalCtx->gameplayFrames + (pthis->flameScrollMod * 10)) * + (-20 - (pthis->flameScrollMod * -2))) % + 0x200, + 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, pthis->flamePrimBlue, pthis->flamePrimAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->flameEnvColor.r, pthis->flameEnvColor.g, pthis->flameEnvColor.b, 0); + Matrix_RotateY(((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y + 0x8000)) * + (M_PI / 0x8000), + MTXMODE_APPLY); + Matrix_Scale(pthis->flameScaleX * 0.01f, pthis->flameScaleY * 0.01f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bb.c", 2106), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + } else { + Matrix_MultVec3f(&blureBase1, &blureVtx1); + Matrix_MultVec3f(&blureBase2, &blureVtx2); + if ((pthis->maxSpeed != 0.0f) && (pthis->action == BB_WHITE) && !(globalCtx->gameplayFrames & 1) && + (pthis->actor.colChkInfo.health != 0)) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIdx), &blureVtx1, &blureVtx2); + } else if (pthis->action != BB_WHITE) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIdx)); + } + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bb.c", 2127); +} diff --git a/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c b/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c deleted file mode 100644 index edc6fbf9c..000000000 --- a/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c +++ /dev/null @@ -1,238 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BDFIRE_Z_EN_BDFIRE_C -#include "actor_common.h" -/* - * File: z_en_bdfire.c - * Overlay: ovl_En_Bdfire - * Description: King Dodongo's Fire Breath - */ - -#include "z_en_bdfire.h" -#include "objects/object_kingdodongo/object_kingdodongo.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnBdfire_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBdfire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBdfire_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBdfire_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBdfire_DrawFire(EnBdfire* this, GlobalContext* globalCtx); -void func_809BC2A4(EnBdfire* this, GlobalContext* globalCtx); -void func_809BC598(EnBdfire* this, GlobalContext* globalCtx); - -const ActorInit En_Bdfire_InitVars = { - 0, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_KINGDODONGO, - sizeof(EnBdfire), - (ActorFunc)EnBdfire_Init, - (ActorFunc)EnBdfire_Destroy, - (ActorFunc)EnBdfire_Update, - (ActorFunc)EnBdfire_Draw, -}; - -void EnBdfire_SetupAction(EnBdfire* this, EnBdfireActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnbdFire_SetupDraw(EnBdfire* this, EnBdfireDrawFunc drawFunc) { - this->drawFunc = drawFunc; -} - -void EnBdfire_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBdfire* this = (EnBdfire*)thisx; - s32 pad; - - Actor_SetScale(&this->actor, 0.6f); - EnbdFire_SetupDraw(this, EnBdfire_DrawFire); - if (this->actor.params < 0) { - EnBdfire_SetupAction(this, func_809BC2A4); - this->actor.scale.x = 2.8f; - this->unk_154 = 90; - Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, 300); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoNoGlow); - } else { - EnBdfire_SetupAction(this, func_809BC598); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - this->actor.speedXZ = 30.0f; - this->unk_154 = (25 - (s32)(this->actor.params * 0.8f)); - if (this->unk_154 < 0) { - this->unk_154 = 0; - } - this->unk_188 = 4.2000003f - (this->actor.params * 0.25f * 0.6f); - - if (this->unk_188 < 0.90000004f) { - this->unk_188 = 0.90000004f; - } - this->unk_18C = 255.0f - (this->actor.params * 10.0f); - if (this->unk_18C < 20.0f) { - this->unk_18C = 20.0f; - } - this->unk_156 = (Rand_ZeroOne() * 8.0f); - } -} - -void EnBdfire_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBdfire* this = (EnBdfire*)thisx; - - if (this->actor.params < 0) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - } -} - -void func_809BC2A4(EnBdfire* this, GlobalContext* globalCtx) { - BossDodongo* kingDodongo; - s32 temp; - - kingDodongo = (BossDodongo*)this->actor.parent; - this->actor.world.pos.x = kingDodongo->firePos.x; - this->actor.world.pos.y = kingDodongo->firePos.y; - this->actor.world.pos.z = kingDodongo->firePos.z; - if (kingDodongo->unk_1E2 == 0) { - Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 1.0f, 0.6f, 0.0f); - if (Math_SmoothStepToF(&this->unk_18C, 0.0f, 1.0f, 20.0f, 0.0f) == 0.0f) { - Actor_Kill(&this->actor); - } - } else { - if (this->unk_154 < 70) { - Math_SmoothStepToF(&this->unk_18C, 128.0f, 0.1f, 1.5f, 0.0f); - Math_SmoothStepToF(&this->unk_190, 255.0f, 1.0f, 3.8249998f, 0.0f); - Math_SmoothStepToF(&this->unk_194, 100.0f, 1.0f, 1.5f, 0.0f); - } - if (this->unk_154 == 0) { - temp = 0; - } else { - this->unk_154--; - temp = this->unk_154; - } - if (temp == 0) { - Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 1.0f, 0.3f, 0.0f); - Math_SmoothStepToF(&this->unk_190, 0.0f, 1.0f, 25.5f, 0.0f); - Math_SmoothStepToF(&this->unk_194, 0.0f, 1.0f, 10.0f, 0.0f); - if (Math_SmoothStepToF(&this->unk_18C, 0.0f, 1.0f, 10.0f, 0.0f) == 0.0f) { - Actor_Kill(&this->actor); - } - } - Actor_SetScale(&this->actor, this->actor.scale.x); - Lights_PointSetColorAndRadius(&this->lightInfoNoGlow, this->unk_190, this->unk_194, 0, 300); - } -} - -void func_809BC598(EnBdfire* this, GlobalContext* globalCtx) { - s16 phi_v1_2; - Player* player = GET_PLAYER(globalCtx); - f32 distToBurn; - BossDodongo* bossDodongo; - s16 i; - s16 phi_v1; - s32 temp; - - bossDodongo = ((BossDodongo*)this->actor.parent); - this->unk_158 = bossDodongo->unk_1A2; - phi_v1_2 = 0; - if (this->actor.params == 0) { - Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_FIRE - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - Math_SmoothStepToF(&this->actor.scale.x, this->unk_188, 0.3f, 0.5f, 0.0f); - Actor_SetScale(&this->actor, this->actor.scale.x); - if (this->actor.world.pos.x < -1390.0f) { - if (this->actor.velocity.x < -10.0f) { - this->actor.world.pos.x = -1390.0f; - phi_v1_2 = 1; - } - } - if ((this->actor.world.pos.x > -390.0f) && (this->actor.velocity.x > 10.0f)) { - this->actor.world.pos.x = -390.0f; - phi_v1_2 = 1; - } - if ((this->actor.world.pos.z > -2804.0f) && (this->actor.velocity.z > 10.0f)) { - this->actor.world.pos.z = -2804.0f; - phi_v1_2 = 1; - } - if ((this->actor.world.pos.z < -3804.0f) && (this->actor.velocity.z < -10.0f)) { - this->actor.world.pos.z = -3804.0f; - phi_v1_2 = 1; - } - if (phi_v1_2 != 0) { - if (this->unk_158 == 0) { - this->actor.world.rot.y += 0x4000; - } else { - this->actor.world.rot.y -= 0x4000; - } - } - if (this->unk_154 == 0) { - temp = 0; - } else { - this->unk_154--; - temp = this->unk_154; - } - if (temp == 0) { - Math_SmoothStepToF(&this->unk_18C, 0.0f, 1.0f, 10.0f, 0.0f); - if (this->unk_18C < 10.0f) { - Actor_Kill(&this->actor); - return; - } - } else if (!player->isBurning) { - distToBurn = (this->actor.scale.x * 130.0f) / 4.2000003f; - if (this->actor.xyzDistToPlayerSq < SQ(distToBurn)) { - for (i = 0; i < 18; i++) { - player->flameTimers[i] = Rand_S16Offset(0, 200); - } - player->isBurning = true; - func_8002F6D4(globalCtx, &this->actor, 20.0f, this->actor.world.rot.y, 0.0f, 8); - osSyncPrintf("POWER\n"); - } - } -} - -void EnBdfire_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBdfire* this = (EnBdfire*)thisx; - - this->unk_156++; - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); -} - -void EnBdfire_DrawFire(EnBdfire* this, GlobalContext* globalCtx) { - static void* D_809BCB10[] = { - object_kingdodongo_Tex_0264E0, object_kingdodongo_Tex_0274E0, object_kingdodongo_Tex_0284E0, - object_kingdodongo_Tex_0294E0, object_kingdodongo_Tex_02A4E0, object_kingdodongo_Tex_02B4E0, - object_kingdodongo_Tex_02C4E0, object_kingdodongo_Tex_02D4E0, - }; - s16 temp; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bdfire.c", 612); - temp = this->unk_156 & 7; - func_800D1FD4(&globalCtx->billboardMtxF); - func_80094BC4(globalCtx->state.gfxCtx); - POLY_XLU_DISP = func_80094968(POLY_XLU_DISP); - gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, - ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, - ENVIRONMENT); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 100, (s8)this->unk_18C); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 0, 0, 0); - gSPSegment(POLY_XLU_DISP++, 8, SEGMENTED_TO_VIRTUAL(D_809BCB10[temp])); - Matrix_Translate(0.0f, 11.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bdfire.c", 647), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_01D950); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bdfire.c", 651); -} - -void EnBdfire_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBdfire* this = (EnBdfire*)thisx; - - this->drawFunc(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.cpp b/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.cpp new file mode 100644 index 000000000..6bc929f5d --- /dev/null +++ b/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.cpp @@ -0,0 +1,238 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BDFIRE_Z_EN_BDFIRE_C +#include "actor_common.h" +/* + * File: z_en_bdfire.c + * Overlay: ovl_En_Bdfire + * Description: King Dodongo's Fire Breath + */ + +#include "z_en_bdfire.h" +#include "objects/object_kingdodongo/object_kingdodongo.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnBdfire_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBdfire_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBdfire_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBdfire_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBdfire_DrawFire(EnBdfire* pthis, GlobalContext* globalCtx); +void func_809BC2A4(EnBdfire* pthis, GlobalContext* globalCtx); +void func_809BC598(EnBdfire* pthis, GlobalContext* globalCtx); + +ActorInit En_Bdfire_InitVars = { + 0, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_KINGDODONGO, + sizeof(EnBdfire), + (ActorFunc)EnBdfire_Init, + (ActorFunc)EnBdfire_Destroy, + (ActorFunc)EnBdfire_Update, + (ActorFunc)EnBdfire_Draw, +}; + +void EnBdfire_SetupAction(EnBdfire* pthis, EnBdfireActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnbdFire_SetupDraw(EnBdfire* pthis, EnBdfireDrawFunc drawFunc) { + pthis->drawFunc = drawFunc; +} + +void EnBdfire_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBdfire* pthis = (EnBdfire*)thisx; + s32 pad; + + Actor_SetScale(&pthis->actor, 0.6f); + EnbdFire_SetupDraw(pthis, EnBdfire_DrawFire); + if (pthis->actor.params < 0) { + EnBdfire_SetupAction(pthis, func_809BC2A4); + pthis->actor.scale.x = 2.8f; + pthis->unk_154 = 90; + Lights_PointNoGlowSetInfo(&pthis->lightInfoNoGlow, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, 300); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfoNoGlow); + } else { + EnBdfire_SetupAction(pthis, func_809BC598); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + pthis->actor.speedXZ = 30.0f; + pthis->unk_154 = (25 - (s32)(pthis->actor.params * 0.8f)); + if (pthis->unk_154 < 0) { + pthis->unk_154 = 0; + } + pthis->unk_188 = 4.2000003f - (pthis->actor.params * 0.25f * 0.6f); + + if (pthis->unk_188 < 0.90000004f) { + pthis->unk_188 = 0.90000004f; + } + pthis->unk_18C = 255.0f - (pthis->actor.params * 10.0f); + if (pthis->unk_18C < 20.0f) { + pthis->unk_18C = 20.0f; + } + pthis->unk_156 = (Rand_ZeroOne() * 8.0f); + } +} + +void EnBdfire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBdfire* pthis = (EnBdfire*)thisx; + + if (pthis->actor.params < 0) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + } +} + +void func_809BC2A4(EnBdfire* pthis, GlobalContext* globalCtx) { + BossDodongo* kingDodongo; + s32 temp; + + kingDodongo = (BossDodongo*)pthis->actor.parent; + pthis->actor.world.pos.x = kingDodongo->firePos.x; + pthis->actor.world.pos.y = kingDodongo->firePos.y; + pthis->actor.world.pos.z = kingDodongo->firePos.z; + if (kingDodongo->unk_1E2 == 0) { + Math_SmoothStepToF(&pthis->actor.scale.x, 0.0f, 1.0f, 0.6f, 0.0f); + if (Math_SmoothStepToF(&pthis->unk_18C, 0.0f, 1.0f, 20.0f, 0.0f) == 0.0f) { + Actor_Kill(&pthis->actor); + } + } else { + if (pthis->unk_154 < 70) { + Math_SmoothStepToF(&pthis->unk_18C, 128.0f, 0.1f, 1.5f, 0.0f); + Math_SmoothStepToF(&pthis->unk_190, 255.0f, 1.0f, 3.8249998f, 0.0f); + Math_SmoothStepToF(&pthis->unk_194, 100.0f, 1.0f, 1.5f, 0.0f); + } + if (pthis->unk_154 == 0) { + temp = 0; + } else { + pthis->unk_154--; + temp = pthis->unk_154; + } + if (temp == 0) { + Math_SmoothStepToF(&pthis->actor.scale.x, 0.0f, 1.0f, 0.3f, 0.0f); + Math_SmoothStepToF(&pthis->unk_190, 0.0f, 1.0f, 25.5f, 0.0f); + Math_SmoothStepToF(&pthis->unk_194, 0.0f, 1.0f, 10.0f, 0.0f); + if (Math_SmoothStepToF(&pthis->unk_18C, 0.0f, 1.0f, 10.0f, 0.0f) == 0.0f) { + Actor_Kill(&pthis->actor); + } + } + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + Lights_PointSetColorAndRadius(&pthis->lightInfoNoGlow, pthis->unk_190, pthis->unk_194, 0, 300); + } +} + +void func_809BC598(EnBdfire* pthis, GlobalContext* globalCtx) { + s16 phi_v1_2; + Player* player = GET_PLAYER(globalCtx); + f32 distToBurn; + BossDodongo* bossDodongo; + s16 i; + s16 phi_v1; + s32 temp; + + bossDodongo = ((BossDodongo*)pthis->actor.parent); + pthis->unk_158 = bossDodongo->unk_1A2; + phi_v1_2 = 0; + if (pthis->actor.params == 0) { + Audio_PlaySoundGeneral(NA_SE_EN_DODO_K_FIRE - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + Math_SmoothStepToF(&pthis->actor.scale.x, pthis->unk_188, 0.3f, 0.5f, 0.0f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + if (pthis->actor.world.pos.x < -1390.0f) { + if (pthis->actor.velocity.x < -10.0f) { + pthis->actor.world.pos.x = -1390.0f; + phi_v1_2 = 1; + } + } + if ((pthis->actor.world.pos.x > -390.0f) && (pthis->actor.velocity.x > 10.0f)) { + pthis->actor.world.pos.x = -390.0f; + phi_v1_2 = 1; + } + if ((pthis->actor.world.pos.z > -2804.0f) && (pthis->actor.velocity.z > 10.0f)) { + pthis->actor.world.pos.z = -2804.0f; + phi_v1_2 = 1; + } + if ((pthis->actor.world.pos.z < -3804.0f) && (pthis->actor.velocity.z < -10.0f)) { + pthis->actor.world.pos.z = -3804.0f; + phi_v1_2 = 1; + } + if (phi_v1_2 != 0) { + if (pthis->unk_158 == 0) { + pthis->actor.world.rot.y += 0x4000; + } else { + pthis->actor.world.rot.y -= 0x4000; + } + } + if (pthis->unk_154 == 0) { + temp = 0; + } else { + pthis->unk_154--; + temp = pthis->unk_154; + } + if (temp == 0) { + Math_SmoothStepToF(&pthis->unk_18C, 0.0f, 1.0f, 10.0f, 0.0f); + if (pthis->unk_18C < 10.0f) { + Actor_Kill(&pthis->actor); + return; + } + } else if (!player->isBurning) { + distToBurn = (pthis->actor.scale.x * 130.0f) / 4.2000003f; + if (pthis->actor.xyzDistToPlayerSq < SQ(distToBurn)) { + for (i = 0; i < 18; i++) { + player->flameTimers[i] = Rand_S16Offset(0, 200); + } + player->isBurning = true; + func_8002F6D4(globalCtx, &pthis->actor, 20.0f, pthis->actor.world.rot.y, 0.0f, 8); + osSyncPrintf("POWER\n"); + } + } +} + +void EnBdfire_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBdfire* pthis = (EnBdfire*)thisx; + + pthis->unk_156++; + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); +} + +void EnBdfire_DrawFire(EnBdfire* pthis, GlobalContext* globalCtx) { + static void* D_809BCB10[] = { + object_kingdodongo_Tex_0264E0, object_kingdodongo_Tex_0274E0, object_kingdodongo_Tex_0284E0, + object_kingdodongo_Tex_0294E0, object_kingdodongo_Tex_02A4E0, object_kingdodongo_Tex_02B4E0, + object_kingdodongo_Tex_02C4E0, object_kingdodongo_Tex_02D4E0, + }; + s16 temp; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bdfire.c", 612); + temp = pthis->unk_156 & 7; + func_800D1FD4(&globalCtx->billboardMtxF); + func_80094BC4(globalCtx->state.gfxCtx); + POLY_XLU_DISP = func_80094968(POLY_XLU_DISP); + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, + ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, + ENVIRONMENT); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 100, (s8)pthis->unk_18C); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 0, 0, 0); + gSPSegment(POLY_XLU_DISP++, 8, SEGMENTED_TO_VIRTUAL(D_809BCB10[temp])); + Matrix_Translate(0.0f, 11.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bdfire.c", 647), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_01D950); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bdfire.c", 651); +} + +void EnBdfire_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBdfire* pthis = (EnBdfire*)thisx; + + pthis->drawFunc(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c deleted file mode 100644 index c901967d6..000000000 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ /dev/null @@ -1,916 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BIGOKUTA_Z_EN_BIGOKUTA_C -#include "actor_common.h" -#include "z_en_bigokuta.h" -#include "objects/object_bigokuta/object_bigokuta.h" -#include "def/code_8006BA00.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBigokuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809BD318(EnBigokuta* this); -void func_809BD3E0(EnBigokuta* this); -void func_809BDF34(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BD84C(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BD8DC(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BDAE8(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BDB90(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BDC08(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BE3E4(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BE4A4(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BE518(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BCF68(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BDFC8(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BE26C(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BE180(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BE058(EnBigokuta* this, GlobalContext* globalCtx); -void func_809BD1C8(EnBigokuta* this, GlobalContext* globalCtx); - -static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 255 }; -static Color_RGBA8 sEffectEnvColor = { 100, 255, 255, 255 }; -static Vec3f sEffectPosAccel = { 0.0f, 0.0f, 0.0f }; - -const ActorInit En_Bigokuta_InitVars = { - ACTOR_EN_BIGOKUTA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BIGOKUTA, - sizeof(EnBigokuta), - (ActorFunc)EnBigokuta_Init, - (ActorFunc)EnBigokuta_Destroy, - (ActorFunc)EnBigokuta_Update, - (ActorFunc)EnBigokuta_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementInit[1] = { - { - { - ELEMTYPE_UNK1, - { 0x20000000, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 1, { { 0, 45, -30 }, 75 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphElementInit), - sJntSphElementInit, -}; - -static ColliderCylinderInit sCylinderInit[] = { - { { - COLTYPE_HARD, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x20000000, 0x00, 0x08 }, - { 0xFFCFFFE7, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 50, 100, 0, { 30, 0, 12 } } }, - { { - COLTYPE_HARD, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x20000000, 0x00, 0x08 }, - { 0xFFCFFFE7, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 50, 100, 0, { -30, 0, 12 } } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit[] = { 4, 130, 120, 200 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(0, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(0, 0x0), - /* Giant's Knife */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(0, 0x0), - /* Master spin */ DMG_ENTRY(0, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(0, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x59, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 33, ICHAIN_STOP), -}; - -// possibly color data -static s32 sUnused[] = { 0xFFFFFFFF, 0x969696FF }; - -void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBigokuta* this = (EnBigokuta*)thisx; - s32 i; - - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bigokuta_Skel_006BC0, &object_bigokuta_Anim_0014B8, - this->jointTable, this->morphTable, 20); - - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->element); - - this->collider.elements->dim.worldSphere.radius = this->collider.elements->dim.modelSphere.radius; - - for (i = 0; i < ARRAY_COUNT(sCylinderInit); i++) { - Collider_InitCylinder(globalCtx, &this->cylinder[i]); - Collider_SetCylinder(globalCtx, &this->cylinder[i], &this->actor, &sCylinderInit[i]); - } - - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, sColChkInfoInit); - - this->unk_194 = 1; - - if (this->actor.params == 0) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - func_809BD318(this); - } else { - func_809BD3E0(this); - this->unk_19A = 0; - this->unk_196 = 1; - this->actor.home.pos.y = -1025.0f; - } -} - -void EnBigokuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBigokuta* this = (EnBigokuta*)thisx; - s32 i; - - Collider_DestroyJntSph(globalCtx, &this->collider); - for (i = 0; i < ARRAY_COUNT(this->cylinder); i++) { - Collider_DestroyCylinder(globalCtx, &this->cylinder[i]); - } -} - -void func_809BCE3C(EnBigokuta* this) { - this->actor.world.rot.y = this->actor.shape.rot.y + this->unk_194 * -0x4000; - this->actor.world.pos.x = Math_SinS(this->actor.world.rot.y) * 263.0f + this->actor.home.pos.x; - this->actor.world.pos.z = Math_CosS(this->actor.world.rot.y) * 263.0f + this->actor.home.pos.z; -} - -void func_809BCEBC(EnBigokuta* this, GlobalContext* globalCtx) { - Vec3f pos; - f32 yDistFromHome = this->actor.world.pos.y - this->actor.home.pos.y; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.home.pos.y + 3.0f; - pos.z = this->actor.world.pos.z; - - if (((globalCtx->gameplayFrames % 7) == 0) && (yDistFromHome <= 0.0f) && (yDistFromHome > -100.0f)) { - EffectSsGRipple_Spawn(globalCtx, &pos, 800, 1300, 0); - } -} - -void func_809BCF68(EnBigokuta* this, GlobalContext* globalCtx) { - Vec3f effectPos; - s16 rot; - - if (globalCtx->gameplayFrames & 1) { - rot = Rand_S16Offset(0x1200, 0xC00) + this->actor.shape.rot.y - this->unk_194 * 0xA00; - } else { - rot = this->actor.shape.rot.y - this->unk_194 * 0xA00 - Rand_S16Offset(0x1200, 0xC00); - } - if (this->actionFunc != func_809BE4A4) { - if (this->actionFunc == func_809BE3E4 || (globalCtx->gameplayFrames & 2)) { - effectPos.x = this->actor.world.pos.x - Math_SinS(rot) * 80.0f; - effectPos.z = this->actor.world.pos.z - Math_CosS(rot) * 80.0f; - effectPos.y = this->actor.home.pos.y + 1.0f; - EffectSsGRipple_Spawn(globalCtx, &effectPos, 100, 500, 0); - } else { - effectPos.x = this->actor.world.pos.x - Math_SinS(rot) * 120.0f; - effectPos.z = this->actor.world.pos.z - Math_CosS(rot) * 120.0f; - effectPos.y = this->actor.home.pos.y + 5.0f; - } - } else { - effectPos.x = this->actor.world.pos.x - Math_SinS(rot) * 50.0f; - effectPos.z = this->actor.world.pos.z - Math_CosS(rot) * 50.0f; - effectPos.y = this->actor.home.pos.y + 1.0f; - EffectSsGRipple_Spawn(globalCtx, &effectPos, 100, 500, 0); - } - EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 800); - if (this->actionFunc != func_809BE4A4) { - func_8002F974(&this->actor, NA_SE_EN_DAIOCTA_SPLASH - SFX_FLAG); - } -} - -void func_809BD1C8(EnBigokuta* this, GlobalContext* globalCtx) { - s32 i; - Vec3f effectPos; - - effectPos.y = this->actor.world.pos.y; - - for (i = 0; i < 4; i++) { - effectPos.x = ((i >= 2) ? 1 : -1) * 60.0f + this->actor.world.pos.x; - effectPos.z = ((i & 1) ? 1 : -1) * 60.0f + this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 2000); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_LAND_WATER); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_LAND_BIG); - func_80033E88(&this->actor, globalCtx, 0xA, 8); -} - -void func_809BD2E4(EnBigokuta* this) { - Actor* parent = this->actor.parent; - - if (parent != NULL) { - Math_ScaledStepToS(&parent->world.rot.y, this->unk_19A, 0x10); - } -} - -void func_809BD318(EnBigokuta* this) { - Animation_PlayLoop(&this->skelAnime, &object_bigokuta_Anim_0014B8); - this->unk_19A = 0; - this->actor.home.pos.y = -1025.0f; - this->unk_196 = 121; - this->actionFunc = func_809BD84C; -} - -void func_809BD370(EnBigokuta* this) { - this->unk_196 = 21; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actionFunc = func_809BD8DC; -} - -void func_809BD3AC(EnBigokuta* this) { - this->actor.world.pos.x = this->actor.home.pos.x + 263.0f; - this->unk_196 = 10; - this->actionFunc = func_809BDAE8; - this->actor.world.pos.y = this->actor.home.pos.y; -} - -void func_809BD3E0(EnBigokuta* this) { - this->unk_196 = 40; - this->actionFunc = func_809BDB90; -} - -void func_809BD3F8(EnBigokuta* this) { - Animation_MorphToLoop(&this->skelAnime, &object_bigokuta_Anim_001CA4, -5.0f); - this->unk_196 = 350; - this->unk_198 = 80; - this->unk_19A = this->unk_194 * -0x200; - func_809BCE3C(this); - this->cylinder[0].base.atFlags |= AT_ON; - this->collider.base.acFlags |= AC_ON; - this->actionFunc = func_809BDC08; -} - -void func_809BD47C(EnBigokuta* this) { - this->unk_196 = 16; - this->collider.base.acFlags &= ~AC_ON; - this->actor.colorFilterTimer = 0; - this->actionFunc = func_809BDF34; -} - -void func_809BD4A4(EnBigokuta* this) { - Animation_MorphToLoop(&this->skelAnime, &object_bigokuta_Anim_0014B8, -5.0f); - this->unk_195 = true; - this->actor.world.rot.x = this->actor.shape.rot.y + 0x8000; - this->unk_19A = this->unk_194 * 0x200; - this->collider.base.acFlags &= ~AC_ON; - this->cylinder[0].base.atFlags |= AT_ON; - this->actionFunc = func_809BDFC8; -} - -void func_809BD524(EnBigokuta* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_bigokuta_Anim_000D1C, -5.0f); - this->unk_196 = 80; - this->unk_19A = 0; - this->cylinder[0].base.atFlags |= AT_ON; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_MAHI); - if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 1) { - this->unk_195 = true; - this->unk_196 = 20; - } else { - this->unk_195 = false; - this->unk_196 = 80; - } - Actor_SetColorFilter(&this->actor, 0, 255, 0, this->unk_196); - this->actionFunc = func_809BE058; -} - -void func_809BD5E0(EnBigokuta* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_bigokuta_Anim_000444, -5.0f); - this->unk_196 = 24; - this->unk_19A = 0; - this->cylinder[0].base.atFlags &= ~AT_ON; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 24); - this->actionFunc = func_809BE180; -} -void func_809BD658(EnBigokuta* this) { - - Animation_MorphToPlayOnce(&this->skelAnime, &object_bigokuta_Anim_000A74, -5.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_DEAD2); - this->unk_196 = 38; - this->unk_198 = 10; - this->actionFunc = func_809BE26C; -} - -void func_809BD6B8(EnBigokuta* this) { - if (!this->unk_195) { - if (Rand_ZeroOne() < 0.5f) { - this->unk_196 = 24; - } else { - this->unk_196 = 28; - } - } else { - if (ABS(this->actor.shape.rot.y - this->actor.yawTowardsPlayer) >= 0x4000) { - this->unk_196 = 4; - } else { - this->unk_196 = 0; - } - } - this->unk_19A = 0; - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = func_809BE3E4; -} - -void func_809BD768(EnBigokuta* this) { - this->unk_194 = Rand_ZeroOne() < 0.5f ? -1 : 1; - this->unk_19A = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->cylinder[0].base.atFlags &= ~AT_ON; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_SINK); - this->actionFunc = func_809BE4A4; -} - -void func_809BD7F0(EnBigokuta* this, GlobalContext* globalCtx) { - this->actor.world.rot.y = Actor_WorldYawTowardPoint(&GET_PLAYER(globalCtx)->actor, &this->actor.home.pos); - this->actor.shape.rot.y = this->actor.world.rot.y + (this->unk_194 * 0x4000); - func_809BCE3C(this); - this->actionFunc = func_809BE518; -} - -void func_809BD84C(EnBigokuta* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - this->unk_196--; - - if (this->unk_196 == 13 || this->unk_196 == -20) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_VOICE); - } - if (this->unk_196 == 1) { - func_800F5ACC(NA_BGM_MINI_BOSS); - } - if (this->actor.params == 1) { - func_809BD370(this); - } -} - -void func_809BD8DC(EnBigokuta* this, GlobalContext* globalCtx) { - Vec3f effectPos; - - this->unk_196--; - - if (this->unk_196 >= 0) { - Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x + 263.0f, 263.0f / 21); - - if (this->unk_196 < 14) { - this->actor.world.pos.y = sinf(this->unk_196 * (M_PI / 28)) * 200.0f + this->actor.home.pos.y; - } else { - this->actor.world.pos.y = - sinf((this->unk_196 - 7) * (M_PI / 14)) * 130.0f + (this->actor.home.pos.y + 70.0f); - } - if (this->unk_196 == 0) { - effectPos.x = this->actor.world.pos.x + 40.0f; - effectPos.y = this->actor.world.pos.y; - effectPos.z = this->actor.world.pos.z - 70.0f; - EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 2000); - effectPos.x = this->actor.world.pos.x - 40.0f; - EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 2000); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_LAND_WATER); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_LAND_BIG); - func_800AA000(0.0f, 0xFF, 0x14, 0x96); - } - } else if (this->unk_196 < -1) { - this->actor.world.pos.y = this->actor.home.pos.y - (sinf((this->unk_196 + 1) * (M_PI / 10)) * 20.0f); - if (this->unk_196 == -10) { - func_809BD3AC(this); - } - } -} - -void func_809BDAE8(EnBigokuta* this, GlobalContext* globalCtx) { - if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y + 0x4000, 0x400)) { - if (this->unk_196 != 0) { - this->unk_196--; - } - if (this->unk_196 == 0) { - func_809BCE3C(this); - this->actor.home.pos.y = this->actor.world.pos.y; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - this->actor.params = 2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_VOICE); - func_809BD3E0(this); - } - } -} - -void func_809BDB90(EnBigokuta* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_196 != 0) { - this->unk_196--; - } - if (this->unk_196 == 0) { - if (this->actor.params == 3) { - func_800F5ACC(NA_BGM_MINI_BOSS); - } - func_809BD3F8(this); - } -} - -void func_809BDC08(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 phi_v0; - s16 pad; - s16 phi_v1; - Vec3f sp28; - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_BUBLE); - } - - if (this->unk_196 < 0) { - this->actor.shape.rot.y += this->unk_194 * 0x200; - func_809BCE3C(this); - this->unk_196++; - if (this->unk_196 == 0) { - this->unk_196 = 350; - } - func_809BCF68(this, globalCtx); - return; - } - - phi_v1 = (Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos) - 180.0f) * (8.0f / 15); - func_8002DBD0(&this->actor, &sp28, &player->actor.world.pos); - if (fabsf(sp28.x) > 263.0f || ((sp28.z > 0.0f) && !Actor_IsFacingPlayer(&this->actor, 0x1B00) && - !Player_IsFacingActor(&this->actor, 0x2000, globalCtx))) { - phi_v1 -= 0x80; - if (this->unk_196 != 0) { - this->unk_196--; - } - } - - if ((this->actor.xzDistToPlayer < 250.0f) && !Actor_IsFacingPlayer(&this->actor, 0x6000)) { - if (this->unk_198 != 0) { - this->unk_198--; - } - if (this->actor.xzDistToPlayer < 180.0f) { - phi_v1 += 0x20; - } - } else { - this->unk_198 = 80; - } - if (this->actor.colChkInfo.health == 1) { - phi_v1 = (phi_v1 + 0x130) * 1.1f; - } else { - phi_v1 += 0x130; - } - this->actor.shape.rot.y += phi_v1 * this->unk_194; - func_809BCE3C(this); - func_809BCF68(this, globalCtx); - if (this->unk_198 == 0) { - func_809BD768(this); - } else if (this->unk_196 == 0) { - func_809BD4A4(this); - } else if (this->unk_195) { - phi_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (phi_v0 < 0) { - phi_v0 = -phi_v0; - } - if (phi_v0 < 0x4100 && phi_v0 > 0x3F00) { - if (Rand_ZeroOne() < 0.6f) { - this->unk_196 = 0; - func_809BD4A4(this); - } - this->unk_195 = false; - } - } -} - -void func_809BDF34(EnBigokuta* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_196 != 0) { - this->unk_196--; - } - this->actor.world.pos.y = (sinf(this->unk_196 * (M_PI / 16)) * 100.0f) + this->actor.home.pos.y; - if (this->unk_196 == 0) { - func_809BD1C8(this, globalCtx); - func_809BD3F8(this); - } -} - -void func_809BDFC8(EnBigokuta* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_196 != 0) { - this->unk_196--; - } - if (this->unk_196 == 20) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_VOICE); - } - if ((this->unk_196 == 0) && Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.world.rot.x, 0x800)) { - this->unk_194 = -this->unk_194; - func_809BD3F8(this); - } -} - -void func_809BE058(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 speedXZ; - - if (this->unk_196 != 0) { - this->unk_196--; - } - - SkelAnime_Update(&this->skelAnime); - - if ((this->collider.base.ocFlags1 & OC1_HIT) || (this->cylinder[0].base.ocFlags1 & OC1_HIT) || - (this->cylinder[1].base.ocFlags1 & OC1_HIT)) { - speedXZ = CLAMP_MIN(player->actor.speedXZ, 1.0f); - if (!(this->collider.base.ocFlags1 & OC1_HIT)) { - this->cylinder[0].base.ocFlags1 &= ~OC1_HIT; - this->cylinder[1].base.ocFlags1 &= ~OC1_HIT; - speedXZ *= -1.0f; - } - player->actor.world.pos.x -= speedXZ * Math_SinS(this->actor.shape.rot.y); - player->actor.world.pos.z -= speedXZ * Math_CosS(this->actor.shape.rot.y); - } - if (this->unk_196 == 0) { - func_809BD6B8(this); - } -} - -void func_809BE180(EnBigokuta* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_196 != 0) { - this->unk_196--; - } - if (this->unk_196 == 0) { - if (this->actor.colChkInfo.health != 0) { - func_809BD4A4(this); - } else { - func_809BD658(this); - } - } else if (this->unk_196 >= 8) { - this->actor.shape.rot.y += this->unk_194 * 0x200; - this->actor.world.pos.y = sinf((this->unk_196 - 8) * (M_PI / 16)) * 100.0f + this->actor.home.pos.y; - func_809BCE3C(this); - if (this->unk_196 == 8) { - func_809BD1C8(this, globalCtx); - } - } -} -void func_809BE26C(EnBigokuta* this, GlobalContext* globalCtx) { - Vec3f effectPos; - - if (this->unk_196 != 0) { - if (this->unk_196 != 0) { - this->unk_196--; - } - if (this->unk_196 >= 10) { - this->actor.shape.rot.y += 0x2000; - } - } else if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_198 != 0) { - this->unk_198--; - } - if (this->unk_198 == 6) { - effectPos.x = this->actor.world.pos.x; - effectPos.y = this->actor.world.pos.y + 150.0f; - effectPos.z = this->actor.world.pos.z; - func_8002829C(globalCtx, &effectPos, &sEffectPosAccel, &sEffectPosAccel, &sEffectPrimColor, - &sEffectEnvColor, 1200, 20); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); - } - if (this->unk_198 == 0 && Math_StepToF(&this->actor.scale.y, 0.0f, 0.001f)) { - Flags_SetClear(globalCtx, this->actor.room); - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); - func_8005ACFC(globalCtx->cameraPtrs[MAIN_CAM], 4); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 50, NA_SE_EN_OCTAROCK_BUBLE); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); - Actor_Kill(&this->actor); - } - } -} - -void func_809BE3E4(EnBigokuta* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->unk_196 != 0) { - if (this->unk_196 != 0) { - this->unk_196--; - } - this->actor.shape.rot.y += 0x2000; - } - if (this->unk_196 == 0) { - if ((s16)(this->actor.shape.rot.y - this->actor.world.rot.y) > 0) { - this->unk_194 = 1; - } else { - this->unk_194 = -1; - } - - func_809BD3F8(this); - if (!this->unk_195) { - this->unk_196 = -40; - } - } - func_809BCF68(this, globalCtx); -} - -void func_809BE4A4(EnBigokuta* this, GlobalContext* globalCtx) { - this->actor.world.pos.y -= 10.0f; - this->actor.shape.rot.y += 0x2000; - if (this->actor.world.pos.y < (this->actor.home.pos.y + -200.0f)) { - func_809BD7F0(this, globalCtx); - } - func_809BCF68(this, globalCtx); -} - -void func_809BE518(EnBigokuta* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 10.0f)) { - this->actor.flags |= ACTOR_FLAG_0; - func_809BD3F8(this); - } -} - -void func_809BE568(EnBigokuta* this) { - s32 i; - f32 sin = Math_SinS(this->actor.shape.rot.y); - f32 cos = Math_CosS(this->actor.shape.rot.y); - - this->collider.elements->dim.worldSphere.center.x = - (this->collider.elements->dim.modelSphere.center.z * sin) + - (this->actor.world.pos.x + (this->collider.elements->dim.modelSphere.center.x * cos)); - this->collider.elements->dim.worldSphere.center.z = - (this->actor.world.pos.z + (this->collider.elements->dim.modelSphere.center.z * cos)) - - (this->collider.elements->dim.modelSphere.center.x * sin); - this->collider.elements->dim.worldSphere.center.y = - this->collider.elements->dim.modelSphere.center.y + this->actor.world.pos.y; - - for (i = 0; i < ARRAY_COUNT(this->cylinder); i++) { - this->cylinder[i].dim.pos.x = - this->actor.world.pos.x + sCylinderInit[i].dim.pos.z * sin + sCylinderInit[i].dim.pos.x * cos; - this->cylinder[i].dim.pos.z = - this->actor.world.pos.z + sCylinderInit[i].dim.pos.z * cos - sCylinderInit[i].dim.pos.x * sin; - this->cylinder[i].dim.pos.y = this->actor.world.pos.y; - } -} - -void func_809BE798(EnBigokuta* this, GlobalContext* globalCtx) { - s16 effectRot; - s16 yawDiff; - - if ((this->cylinder[0].base.atFlags & AT_HIT) || (this->cylinder[1].base.atFlags & AT_HIT) || - (this->collider.base.atFlags & AT_HIT)) { - this->cylinder[0].base.atFlags &= ~AT_HIT; - this->cylinder[1].base.atFlags &= ~AT_HIT; - this->collider.base.atFlags &= ~AT_HIT; - yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - if (yawDiff > 0x4000) { - effectRot = 0x4000; - } else if (yawDiff > 0) { - effectRot = 0x6000; - } else if (yawDiff < -0x4000) { - effectRot = -0x4000; - } else { - effectRot = -0x6000; - } - func_8002F71C(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y + effectRot, 5.0f); - if (this->actionFunc == func_809BDC08) { - func_809BD4A4(this); - this->unk_196 = 40; - } else if (this->actionFunc == func_809BE3E4) { - if ((effectRot * this->unk_194) > 0) { - this->unk_194 = 0 - this->unk_194; - this->unk_196 += 4; - } - } - } -} - -void EnBigokuta_UpdateDamage(EnBigokuta* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != 0 || this->actor.colChkInfo.damage != 0) { - if (this->actor.colChkInfo.damageEffect == 1) { - if (this->actionFunc != func_809BE058) { - func_809BD524(this); - } - } else if (this->actor.colChkInfo.damageEffect == 0xF) { - func_809BD47C(this); - } else if (!Actor_IsFacingPlayer(&this->actor, 0x4000)) { - if (Actor_ApplyDamage(&this->actor) == 0) { // Dead - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_DAMAGE); - } - func_809BD5E0(this); - } - } - } -} - -void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnBigokuta* this = (EnBigokuta*)thisx; - s32 i; - GlobalContext* globalCtx = globalCtx2; - - func_809BE798(this, globalCtx); - EnBigokuta_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - func_809BD2E4(this); - func_809BE568(this); - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BIG_OCTO); - func_8005AD1C(globalCtx->cameraPtrs[MAIN_CAM], 4); - - if (this->cylinder[0].base.atFlags & AT_ON) { - if (this->actionFunc != func_809BE058) { - for (i = 0; i < ARRAY_COUNT(this->cylinder); i++) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->cylinder[i].base); - } - this->actor.flags |= ACTOR_FLAG_24; - } else { - for (i = 0; i < ARRAY_COUNT(this->cylinder); i++) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cylinder[i].base); - } - } - for (i = 0; i < ARRAY_COUNT(this->cylinder); i++) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder[i].base); - } - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } else { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - Actor_SetFocus(&this->actor, this->actor.scale.y * 25.0f * 100.0f); - func_809BCEBC(this, globalCtx); -} - -s32 EnBigokuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnBigokuta* this = (EnBigokuta*)thisx; - u8 intensity; - f32 temp_f0; - s32 temp_hi; - - if (limbIndex == 15) { - if (this->actionFunc == func_809BE058 || this->actionFunc == func_809BE180) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1914); - - if (this->actionFunc == func_809BE058) { - temp_hi = this->unk_196 % 12; - if (temp_hi >= 8) { - temp_f0 = (12 - temp_hi) * (M_PI / 8); - } else { - temp_f0 = temp_hi * (M_PI / 16); - } - } else { - temp_hi = this->unk_196 % 6; - if (temp_hi >= 4) { - temp_f0 = (6 - temp_hi) * (M_PI / 4); - } else { - temp_f0 = temp_hi * (M_PI / 8); - } - } - - temp_f0 = sinf(temp_f0) * 125.0f + 130.0f; - gDPPipeSync(POLY_OPA_DISP++); - - gDPSetEnvColor(POLY_OPA_DISP++, temp_f0, temp_f0, temp_f0, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1945); - } - } else if (limbIndex == 10) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1950); - if (this->actionFunc == func_809BE26C) { - intensity = this->unk_196 * (255.0f / 38); - } else { - intensity = 255; - } - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, intensity, intensity, intensity, intensity); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1972); - } else if (limbIndex == 17 && this->actionFunc == func_809BE26C) { - if (this->unk_198 < 5) { - Matrix_Scale((this->unk_198 * 0.2f * 0.25f) + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - } else if (this->unk_198 < 8) { - temp_f0 = (this->unk_198 - 5) * (1.0f / 12); - Matrix_Scale(1.25f - temp_f0, 1.0f + temp_f0, 1.0f + temp_f0, MTXMODE_APPLY); - } else { - temp_f0 = ((this->unk_198 - 8) * 0.125f); - Matrix_Scale(1.0f, 1.25f - temp_f0, 1.25f - temp_f0, MTXMODE_APPLY); - } - } - return false; -} - -void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBigokuta* this = (EnBigokuta*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 2017); - - if ((this->actionFunc != func_809BE26C) || (this->unk_196 != 0) || (this->unk_198 != 0)) { - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - if (this->unk_196 & 1) { - if ((this->actionFunc == func_809BE180 && this->unk_196 >= 8) || - (this->actionFunc == func_809BE26C && this->unk_196 >= 10)) { - f32 rotX = Rand_ZeroOne() * (M_PI * 2.0f); - f32 rotY = Rand_ZeroOne() * (M_PI * 2.0f); - - Matrix_RotateY(rotY, MTXMODE_APPLY); - Matrix_RotateX(rotX, MTXMODE_APPLY); - Matrix_Scale(0.78999996f, 1.3f, 0.78999996f, MTXMODE_APPLY); - Matrix_RotateX(-rotX, MTXMODE_APPLY); - Matrix_RotateY(-rotY, MTXMODE_APPLY); - } - } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnBigokuta_OverrideLimbDraw, NULL, this); - } else { - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (this->actor.scale.y * (255 / 0.033f))); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, NULL, NULL, POLY_XLU_DISP); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 2076); -} diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.cpp b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.cpp new file mode 100644 index 000000000..db8e09071 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.cpp @@ -0,0 +1,916 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BIGOKUTA_Z_EN_BIGOKUTA_C +#include "actor_common.h" +#include "z_en_bigokuta.h" +#include "objects/object_bigokuta/object_bigokuta.h" +#include "def/code_8006BA00.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBigokuta_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809BD318(EnBigokuta* pthis); +void func_809BD3E0(EnBigokuta* pthis); +void func_809BDF34(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BD84C(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BD8DC(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BDAE8(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BDB90(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BDC08(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BE3E4(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BE4A4(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BE518(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BCF68(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BDFC8(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BE26C(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BE180(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BE058(EnBigokuta* pthis, GlobalContext* globalCtx); +void func_809BD1C8(EnBigokuta* pthis, GlobalContext* globalCtx); + +static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 255 }; +static Color_RGBA8 sEffectEnvColor = { 100, 255, 255, 255 }; +static Vec3f sEffectPosAccel = { 0.0f, 0.0f, 0.0f }; + +ActorInit En_Bigokuta_InitVars = { + ACTOR_EN_BIGOKUTA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BIGOKUTA, + sizeof(EnBigokuta), + (ActorFunc)EnBigokuta_Init, + (ActorFunc)EnBigokuta_Destroy, + (ActorFunc)EnBigokuta_Update, + (ActorFunc)EnBigokuta_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementInit[1] = { + { + { + ELEMTYPE_UNK1, + { 0x20000000, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 1, { { 0, 45, -30 }, 75 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementInit), + sJntSphElementInit, +}; + +static ColliderCylinderInit sCylinderInit[] = { + { { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x20000000, 0x00, 0x08 }, + { 0xFFCFFFE7, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 50, 100, 0, { 30, 0, 12 } } }, + { { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x20000000, 0x00, 0x08 }, + { 0xFFCFFFE7, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 50, 100, 0, { -30, 0, 12 } } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit[] = { 4, 130, 120, 200 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(0, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(0, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(0, 0x0), + /* Giant's Knife */ DMG_ENTRY(0, 0x0), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(0, 0x0), + /* Master spin */ DMG_ENTRY(0, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(0, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x59, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 33, ICHAIN_STOP), +}; + +// possibly color data +static s32 sUnused[] = { 0xFFFFFFFF, 0x969696FF }; + +void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBigokuta* pthis = (EnBigokuta*)thisx; + s32 i; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_bigokuta_Skel_006BC0, &object_bigokuta_Anim_0014B8, + pthis->jointTable, pthis->morphTable, 20); + + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, &pthis->element); + + pthis->collider.elements->dim.worldSphere.radius = pthis->collider.elements->dim.modelSphere.radius; + + for (i = 0; i < ARRAY_COUNT(sCylinderInit); i++) { + Collider_InitCylinder(globalCtx, &pthis->cylinder[i]); + Collider_SetCylinder(globalCtx, &pthis->cylinder[i], &pthis->actor, &sCylinderInit[i]); + } + + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, sColChkInfoInit); + + pthis->unk_194 = 1; + + if (pthis->actor.params == 0) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + func_809BD318(pthis); + } else { + func_809BD3E0(pthis); + pthis->unk_19A = 0; + pthis->unk_196 = 1; + pthis->actor.home.pos.y = -1025.0f; + } +} + +void EnBigokuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBigokuta* pthis = (EnBigokuta*)thisx; + s32 i; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); + for (i = 0; i < ARRAY_COUNT(pthis->cylinder); i++) { + Collider_DestroyCylinder(globalCtx, &pthis->cylinder[i]); + } +} + +void func_809BCE3C(EnBigokuta* pthis) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + pthis->unk_194 * -0x4000; + pthis->actor.world.pos.x = Math_SinS(pthis->actor.world.rot.y) * 263.0f + pthis->actor.home.pos.x; + pthis->actor.world.pos.z = Math_CosS(pthis->actor.world.rot.y) * 263.0f + pthis->actor.home.pos.z; +} + +void func_809BCEBC(EnBigokuta* pthis, GlobalContext* globalCtx) { + Vec3f pos; + f32 yDistFromHome = pthis->actor.world.pos.y - pthis->actor.home.pos.y; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.home.pos.y + 3.0f; + pos.z = pthis->actor.world.pos.z; + + if (((globalCtx->gameplayFrames % 7) == 0) && (yDistFromHome <= 0.0f) && (yDistFromHome > -100.0f)) { + EffectSsGRipple_Spawn(globalCtx, &pos, 800, 1300, 0); + } +} + +void func_809BCF68(EnBigokuta* pthis, GlobalContext* globalCtx) { + Vec3f effectPos; + s16 rot; + + if (globalCtx->gameplayFrames & 1) { + rot = Rand_S16Offset(0x1200, 0xC00) + pthis->actor.shape.rot.y - pthis->unk_194 * 0xA00; + } else { + rot = pthis->actor.shape.rot.y - pthis->unk_194 * 0xA00 - Rand_S16Offset(0x1200, 0xC00); + } + if (pthis->actionFunc != func_809BE4A4) { + if (pthis->actionFunc == func_809BE3E4 || (globalCtx->gameplayFrames & 2)) { + effectPos.x = pthis->actor.world.pos.x - Math_SinS(rot) * 80.0f; + effectPos.z = pthis->actor.world.pos.z - Math_CosS(rot) * 80.0f; + effectPos.y = pthis->actor.home.pos.y + 1.0f; + EffectSsGRipple_Spawn(globalCtx, &effectPos, 100, 500, 0); + } else { + effectPos.x = pthis->actor.world.pos.x - Math_SinS(rot) * 120.0f; + effectPos.z = pthis->actor.world.pos.z - Math_CosS(rot) * 120.0f; + effectPos.y = pthis->actor.home.pos.y + 5.0f; + } + } else { + effectPos.x = pthis->actor.world.pos.x - Math_SinS(rot) * 50.0f; + effectPos.z = pthis->actor.world.pos.z - Math_CosS(rot) * 50.0f; + effectPos.y = pthis->actor.home.pos.y + 1.0f; + EffectSsGRipple_Spawn(globalCtx, &effectPos, 100, 500, 0); + } + EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 800); + if (pthis->actionFunc != func_809BE4A4) { + func_8002F974(&pthis->actor, NA_SE_EN_DAIOCTA_SPLASH - SFX_FLAG); + } +} + +void func_809BD1C8(EnBigokuta* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f effectPos; + + effectPos.y = pthis->actor.world.pos.y; + + for (i = 0; i < 4; i++) { + effectPos.x = ((i >= 2) ? 1 : -1) * 60.0f + pthis->actor.world.pos.x; + effectPos.z = ((i & 1) ? 1 : -1) * 60.0f + pthis->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 2000); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_LAND_WATER); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOLON_LAND_BIG); + func_80033E88(&pthis->actor, globalCtx, 0xA, 8); +} + +void func_809BD2E4(EnBigokuta* pthis) { + Actor* parent = pthis->actor.parent; + + if (parent != NULL) { + Math_ScaledStepToS(&parent->world.rot.y, pthis->unk_19A, 0x10); + } +} + +void func_809BD318(EnBigokuta* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_bigokuta_Anim_0014B8); + pthis->unk_19A = 0; + pthis->actor.home.pos.y = -1025.0f; + pthis->unk_196 = 121; + pthis->actionFunc = func_809BD84C; +} + +void func_809BD370(EnBigokuta* pthis) { + pthis->unk_196 = 21; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actionFunc = func_809BD8DC; +} + +void func_809BD3AC(EnBigokuta* pthis) { + pthis->actor.world.pos.x = pthis->actor.home.pos.x + 263.0f; + pthis->unk_196 = 10; + pthis->actionFunc = func_809BDAE8; + pthis->actor.world.pos.y = pthis->actor.home.pos.y; +} + +void func_809BD3E0(EnBigokuta* pthis) { + pthis->unk_196 = 40; + pthis->actionFunc = func_809BDB90; +} + +void func_809BD3F8(EnBigokuta* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_bigokuta_Anim_001CA4, -5.0f); + pthis->unk_196 = 350; + pthis->unk_198 = 80; + pthis->unk_19A = pthis->unk_194 * -0x200; + func_809BCE3C(pthis); + pthis->cylinder[0].base.atFlags |= AT_ON; + pthis->collider.base.acFlags |= AC_ON; + pthis->actionFunc = func_809BDC08; +} + +void func_809BD47C(EnBigokuta* pthis) { + pthis->unk_196 = 16; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.colorFilterTimer = 0; + pthis->actionFunc = func_809BDF34; +} + +void func_809BD4A4(EnBigokuta* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_bigokuta_Anim_0014B8, -5.0f); + pthis->unk_195 = true; + pthis->actor.world.rot.x = pthis->actor.shape.rot.y + 0x8000; + pthis->unk_19A = pthis->unk_194 * 0x200; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->cylinder[0].base.atFlags |= AT_ON; + pthis->actionFunc = func_809BDFC8; +} + +void func_809BD524(EnBigokuta* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_bigokuta_Anim_000D1C, -5.0f); + pthis->unk_196 = 80; + pthis->unk_19A = 0; + pthis->cylinder[0].base.atFlags |= AT_ON; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_MAHI); + if (pthis->collider.elements->info.acHitInfo->toucher.dmgFlags & 1) { + pthis->unk_195 = true; + pthis->unk_196 = 20; + } else { + pthis->unk_195 = false; + pthis->unk_196 = 80; + } + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, pthis->unk_196); + pthis->actionFunc = func_809BE058; +} + +void func_809BD5E0(EnBigokuta* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_bigokuta_Anim_000444, -5.0f); + pthis->unk_196 = 24; + pthis->unk_19A = 0; + pthis->cylinder[0].base.atFlags &= ~AT_ON; + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 24); + pthis->actionFunc = func_809BE180; +} +void func_809BD658(EnBigokuta* pthis) { + + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_bigokuta_Anim_000A74, -5.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_DEAD2); + pthis->unk_196 = 38; + pthis->unk_198 = 10; + pthis->actionFunc = func_809BE26C; +} + +void func_809BD6B8(EnBigokuta* pthis) { + if (!pthis->unk_195) { + if (Rand_ZeroOne() < 0.5f) { + pthis->unk_196 = 24; + } else { + pthis->unk_196 = 28; + } + } else { + if (ABS(pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer) >= 0x4000) { + pthis->unk_196 = 4; + } else { + pthis->unk_196 = 0; + } + } + pthis->unk_19A = 0; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = func_809BE3E4; +} + +void func_809BD768(EnBigokuta* pthis) { + pthis->unk_194 = Rand_ZeroOne() < 0.5f ? -1 : 1; + pthis->unk_19A = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->cylinder[0].base.atFlags &= ~AT_ON; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_SINK); + pthis->actionFunc = func_809BE4A4; +} + +void func_809BD7F0(EnBigokuta* pthis, GlobalContext* globalCtx) { + pthis->actor.world.rot.y = Actor_WorldYawTowardPoint(&GET_PLAYER(globalCtx)->actor, &pthis->actor.home.pos); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + (pthis->unk_194 * 0x4000); + func_809BCE3C(pthis); + pthis->actionFunc = func_809BE518; +} + +void func_809BD84C(EnBigokuta* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + pthis->unk_196--; + + if (pthis->unk_196 == 13 || pthis->unk_196 == -20) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_VOICE); + } + if (pthis->unk_196 == 1) { + func_800F5ACC(NA_BGM_MINI_BOSS); + } + if (pthis->actor.params == 1) { + func_809BD370(pthis); + } +} + +void func_809BD8DC(EnBigokuta* pthis, GlobalContext* globalCtx) { + Vec3f effectPos; + + pthis->unk_196--; + + if (pthis->unk_196 >= 0) { + Math_StepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x + 263.0f, 263.0f / 21); + + if (pthis->unk_196 < 14) { + pthis->actor.world.pos.y = sinf(pthis->unk_196 * (M_PI / 28)) * 200.0f + pthis->actor.home.pos.y; + } else { + pthis->actor.world.pos.y = + sinf((pthis->unk_196 - 7) * (M_PI / 14)) * 130.0f + (pthis->actor.home.pos.y + 70.0f); + } + if (pthis->unk_196 == 0) { + effectPos.x = pthis->actor.world.pos.x + 40.0f; + effectPos.y = pthis->actor.world.pos.y; + effectPos.z = pthis->actor.world.pos.z - 70.0f; + EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 2000); + effectPos.x = pthis->actor.world.pos.x - 40.0f; + EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 1, 2000); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_LAND_WATER); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOLON_LAND_BIG); + func_800AA000(0.0f, 0xFF, 0x14, 0x96); + } + } else if (pthis->unk_196 < -1) { + pthis->actor.world.pos.y = pthis->actor.home.pos.y - (sinf((pthis->unk_196 + 1) * (M_PI / 10)) * 20.0f); + if (pthis->unk_196 == -10) { + func_809BD3AC(pthis); + } + } +} + +void func_809BDAE8(EnBigokuta* pthis, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y + 0x4000, 0x400)) { + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + if (pthis->unk_196 == 0) { + func_809BCE3C(pthis); + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + pthis->actor.params = 2; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_VOICE); + func_809BD3E0(pthis); + } + } +} + +void func_809BDB90(EnBigokuta* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + if (pthis->unk_196 == 0) { + if (pthis->actor.params == 3) { + func_800F5ACC(NA_BGM_MINI_BOSS); + } + func_809BD3F8(pthis); + } +} + +void func_809BDC08(EnBigokuta* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_v0; + s16 pad; + s16 phi_v1; + Vec3f sp28; + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_BUBLE); + } + + if (pthis->unk_196 < 0) { + pthis->actor.shape.rot.y += pthis->unk_194 * 0x200; + func_809BCE3C(pthis); + pthis->unk_196++; + if (pthis->unk_196 == 0) { + pthis->unk_196 = 350; + } + func_809BCF68(pthis, globalCtx); + return; + } + + phi_v1 = (Actor_WorldDistXZToPoint(&player->actor, &pthis->actor.home.pos) - 180.0f) * (8.0f / 15); + func_8002DBD0(&pthis->actor, &sp28, &player->actor.world.pos); + if (fabsf(sp28.x) > 263.0f || ((sp28.z > 0.0f) && !Actor_IsFacingPlayer(&pthis->actor, 0x1B00) && + !Player_IsFacingActor(&pthis->actor, 0x2000, globalCtx))) { + phi_v1 -= 0x80; + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + } + + if ((pthis->actor.xzDistToPlayer < 250.0f) && !Actor_IsFacingPlayer(&pthis->actor, 0x6000)) { + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + if (pthis->actor.xzDistToPlayer < 180.0f) { + phi_v1 += 0x20; + } + } else { + pthis->unk_198 = 80; + } + if (pthis->actor.colChkInfo.health == 1) { + phi_v1 = (phi_v1 + 0x130) * 1.1f; + } else { + phi_v1 += 0x130; + } + pthis->actor.shape.rot.y += phi_v1 * pthis->unk_194; + func_809BCE3C(pthis); + func_809BCF68(pthis, globalCtx); + if (pthis->unk_198 == 0) { + func_809BD768(pthis); + } else if (pthis->unk_196 == 0) { + func_809BD4A4(pthis); + } else if (pthis->unk_195) { + phi_v0 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (phi_v0 < 0) { + phi_v0 = -phi_v0; + } + if (phi_v0 < 0x4100 && phi_v0 > 0x3F00) { + if (Rand_ZeroOne() < 0.6f) { + pthis->unk_196 = 0; + func_809BD4A4(pthis); + } + pthis->unk_195 = false; + } + } +} + +void func_809BDF34(EnBigokuta* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + pthis->actor.world.pos.y = (sinf(pthis->unk_196 * (M_PI / 16)) * 100.0f) + pthis->actor.home.pos.y; + if (pthis->unk_196 == 0) { + func_809BD1C8(pthis, globalCtx); + func_809BD3F8(pthis); + } +} + +void func_809BDFC8(EnBigokuta* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + if (pthis->unk_196 == 20) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_VOICE); + } + if ((pthis->unk_196 == 0) && Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.x, 0x800)) { + pthis->unk_194 = -pthis->unk_194; + func_809BD3F8(pthis); + } +} + +void func_809BE058(EnBigokuta* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 speedXZ; + + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + + SkelAnime_Update(&pthis->skelAnime); + + if ((pthis->collider.base.ocFlags1 & OC1_HIT) || (pthis->cylinder[0].base.ocFlags1 & OC1_HIT) || + (pthis->cylinder[1].base.ocFlags1 & OC1_HIT)) { + speedXZ = CLAMP_MIN(player->actor.speedXZ, 1.0f); + if (!(pthis->collider.base.ocFlags1 & OC1_HIT)) { + pthis->cylinder[0].base.ocFlags1 &= ~OC1_HIT; + pthis->cylinder[1].base.ocFlags1 &= ~OC1_HIT; + speedXZ *= -1.0f; + } + player->actor.world.pos.x -= speedXZ * Math_SinS(pthis->actor.shape.rot.y); + player->actor.world.pos.z -= speedXZ * Math_CosS(pthis->actor.shape.rot.y); + } + if (pthis->unk_196 == 0) { + func_809BD6B8(pthis); + } +} + +void func_809BE180(EnBigokuta* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + if (pthis->unk_196 == 0) { + if (pthis->actor.colChkInfo.health != 0) { + func_809BD4A4(pthis); + } else { + func_809BD658(pthis); + } + } else if (pthis->unk_196 >= 8) { + pthis->actor.shape.rot.y += pthis->unk_194 * 0x200; + pthis->actor.world.pos.y = sinf((pthis->unk_196 - 8) * (M_PI / 16)) * 100.0f + pthis->actor.home.pos.y; + func_809BCE3C(pthis); + if (pthis->unk_196 == 8) { + func_809BD1C8(pthis, globalCtx); + } + } +} +void func_809BE26C(EnBigokuta* pthis, GlobalContext* globalCtx) { + Vec3f effectPos; + + if (pthis->unk_196 != 0) { + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + if (pthis->unk_196 >= 10) { + pthis->actor.shape.rot.y += 0x2000; + } + } else if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + if (pthis->unk_198 == 6) { + effectPos.x = pthis->actor.world.pos.x; + effectPos.y = pthis->actor.world.pos.y + 150.0f; + effectPos.z = pthis->actor.world.pos.z; + func_8002829C(globalCtx, &effectPos, &sEffectPosAccel, &sEffectPosAccel, &sEffectPrimColor, + &sEffectEnvColor, 1200, 20); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_DEAD2); + } + if (pthis->unk_198 == 0 && Math_StepToF(&pthis->actor.scale.y, 0.0f, 0.001f)) { + Flags_SetClear(globalCtx, pthis->actor.room); + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_DUNGEON0); + func_8005ACFC(globalCtx->cameraPtrs[MAIN_CAM], 4); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 50, NA_SE_EN_OCTAROCK_BUBLE); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xB0); + Actor_Kill(&pthis->actor); + } + } +} + +void func_809BE3E4(EnBigokuta* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_196 != 0) { + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + pthis->actor.shape.rot.y += 0x2000; + } + if (pthis->unk_196 == 0) { + if ((s16)(pthis->actor.shape.rot.y - pthis->actor.world.rot.y) > 0) { + pthis->unk_194 = 1; + } else { + pthis->unk_194 = -1; + } + + func_809BD3F8(pthis); + if (!pthis->unk_195) { + pthis->unk_196 = -40; + } + } + func_809BCF68(pthis, globalCtx); +} + +void func_809BE4A4(EnBigokuta* pthis, GlobalContext* globalCtx) { + pthis->actor.world.pos.y -= 10.0f; + pthis->actor.shape.rot.y += 0x2000; + if (pthis->actor.world.pos.y < (pthis->actor.home.pos.y + -200.0f)) { + func_809BD7F0(pthis, globalCtx); + } + func_809BCF68(pthis, globalCtx); +} + +void func_809BE518(EnBigokuta* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 10.0f)) { + pthis->actor.flags |= ACTOR_FLAG_0; + func_809BD3F8(pthis); + } +} + +void func_809BE568(EnBigokuta* pthis) { + s32 i; + f32 sin = Math_SinS(pthis->actor.shape.rot.y); + f32 cos = Math_CosS(pthis->actor.shape.rot.y); + + pthis->collider.elements->dim.worldSphere.center.x = + (pthis->collider.elements->dim.modelSphere.center.z * sin) + + (pthis->actor.world.pos.x + (pthis->collider.elements->dim.modelSphere.center.x * cos)); + pthis->collider.elements->dim.worldSphere.center.z = + (pthis->actor.world.pos.z + (pthis->collider.elements->dim.modelSphere.center.z * cos)) - + (pthis->collider.elements->dim.modelSphere.center.x * sin); + pthis->collider.elements->dim.worldSphere.center.y = + pthis->collider.elements->dim.modelSphere.center.y + pthis->actor.world.pos.y; + + for (i = 0; i < ARRAY_COUNT(pthis->cylinder); i++) { + pthis->cylinder[i].dim.pos.x = + pthis->actor.world.pos.x + sCylinderInit[i].dim.pos.z * sin + sCylinderInit[i].dim.pos.x * cos; + pthis->cylinder[i].dim.pos.z = + pthis->actor.world.pos.z + sCylinderInit[i].dim.pos.z * cos - sCylinderInit[i].dim.pos.x * sin; + pthis->cylinder[i].dim.pos.y = pthis->actor.world.pos.y; + } +} + +void func_809BE798(EnBigokuta* pthis, GlobalContext* globalCtx) { + s16 effectRot; + s16 yawDiff; + + if ((pthis->cylinder[0].base.atFlags & AT_HIT) || (pthis->cylinder[1].base.atFlags & AT_HIT) || + (pthis->collider.base.atFlags & AT_HIT)) { + pthis->cylinder[0].base.atFlags &= ~AT_HIT; + pthis->cylinder[1].base.atFlags &= ~AT_HIT; + pthis->collider.base.atFlags &= ~AT_HIT; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y; + if (yawDiff > 0x4000) { + effectRot = 0x4000; + } else if (yawDiff > 0) { + effectRot = 0x6000; + } else if (yawDiff < -0x4000) { + effectRot = -0x4000; + } else { + effectRot = -0x6000; + } + func_8002F71C(globalCtx, &pthis->actor, 10.0f, pthis->actor.world.rot.y + effectRot, 5.0f); + if (pthis->actionFunc == func_809BDC08) { + func_809BD4A4(pthis); + pthis->unk_196 = 40; + } else if (pthis->actionFunc == func_809BE3E4) { + if ((effectRot * pthis->unk_194) > 0) { + pthis->unk_194 = 0 - pthis->unk_194; + pthis->unk_196 += 4; + } + } + } +} + +void EnBigokuta_UpdateDamage(EnBigokuta* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != 0 || pthis->actor.colChkInfo.damage != 0) { + if (pthis->actor.colChkInfo.damageEffect == 1) { + if (pthis->actionFunc != func_809BE058) { + func_809BD524(pthis); + } + } else if (pthis->actor.colChkInfo.damageEffect == 0xF) { + func_809BD47C(pthis); + } else if (!Actor_IsFacingPlayer(&pthis->actor, 0x4000)) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { // Dead + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_DEAD); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DAIOCTA_DAMAGE); + } + func_809BD5E0(pthis); + } + } + } +} + +void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnBigokuta* pthis = (EnBigokuta*)thisx; + s32 i; + GlobalContext* globalCtx = globalCtx2; + + func_809BE798(pthis, globalCtx); + EnBigokuta_UpdateDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + func_809BD2E4(pthis); + func_809BE568(pthis); + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BIG_OCTO); + func_8005AD1C(globalCtx->cameraPtrs[MAIN_CAM], 4); + + if (pthis->cylinder[0].base.atFlags & AT_ON) { + if (pthis->actionFunc != func_809BE058) { + for (i = 0; i < ARRAY_COUNT(pthis->cylinder); i++) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder[i].base); + } + pthis->actor.flags |= ACTOR_FLAG_24; + } else { + for (i = 0; i < ARRAY_COUNT(pthis->cylinder); i++) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder[i].base); + } + } + for (i = 0; i < ARRAY_COUNT(pthis->cylinder); i++) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder[i].base); + } + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } else { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + Actor_SetFocus(&pthis->actor, pthis->actor.scale.y * 25.0f * 100.0f); + func_809BCEBC(pthis, globalCtx); +} + +s32 EnBigokuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnBigokuta* pthis = (EnBigokuta*)thisx; + u8 intensity; + f32 temp_f0; + s32 temp_hi; + + if (limbIndex == 15) { + if (pthis->actionFunc == func_809BE058 || pthis->actionFunc == func_809BE180) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1914); + + if (pthis->actionFunc == func_809BE058) { + temp_hi = pthis->unk_196 % 12; + if (temp_hi >= 8) { + temp_f0 = (12 - temp_hi) * (M_PI / 8); + } else { + temp_f0 = temp_hi * (M_PI / 16); + } + } else { + temp_hi = pthis->unk_196 % 6; + if (temp_hi >= 4) { + temp_f0 = (6 - temp_hi) * (M_PI / 4); + } else { + temp_f0 = temp_hi * (M_PI / 8); + } + } + + temp_f0 = sinf(temp_f0) * 125.0f + 130.0f; + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetEnvColor(POLY_OPA_DISP++, temp_f0, temp_f0, temp_f0, 255); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1945); + } + } else if (limbIndex == 10) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1950); + if (pthis->actionFunc == func_809BE26C) { + intensity = pthis->unk_196 * (255.0f / 38); + } else { + intensity = 255; + } + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, intensity, intensity, intensity, intensity); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 1972); + } else if (limbIndex == 17 && pthis->actionFunc == func_809BE26C) { + if (pthis->unk_198 < 5) { + Matrix_Scale((pthis->unk_198 * 0.2f * 0.25f) + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + } else if (pthis->unk_198 < 8) { + temp_f0 = (pthis->unk_198 - 5) * (1.0f / 12); + Matrix_Scale(1.25f - temp_f0, 1.0f + temp_f0, 1.0f + temp_f0, MTXMODE_APPLY); + } else { + temp_f0 = ((pthis->unk_198 - 8) * 0.125f); + Matrix_Scale(1.0f, 1.25f - temp_f0, 1.25f - temp_f0, MTXMODE_APPLY); + } + } + return false; +} + +void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBigokuta* pthis = (EnBigokuta*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 2017); + + if ((pthis->actionFunc != func_809BE26C) || (pthis->unk_196 != 0) || (pthis->unk_198 != 0)) { + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + if (pthis->unk_196 & 1) { + if ((pthis->actionFunc == func_809BE180 && pthis->unk_196 >= 8) || + (pthis->actionFunc == func_809BE26C && pthis->unk_196 >= 10)) { + f32 rotX = Rand_ZeroOne() * (M_PI * 2.0f); + f32 rotY = Rand_ZeroOne() * (M_PI * 2.0f); + + Matrix_RotateY(rotY, MTXMODE_APPLY); + Matrix_RotateX(rotX, MTXMODE_APPLY); + Matrix_Scale(0.78999996f, 1.3f, 0.78999996f, MTXMODE_APPLY); + Matrix_RotateX(-rotX, MTXMODE_APPLY); + Matrix_RotateY(-rotY, MTXMODE_APPLY); + } + } + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnBigokuta_OverrideLimbDraw, NULL, pthis); + } else { + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (pthis->actor.scale.y * (255 / 0.033f))); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, NULL, NULL, NULL, POLY_XLU_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bigokuta.c", 2076); +} diff --git a/src/overlays/actors/ovl_En_Bili/z_en_bili.c b/src/overlays/actors/ovl_En_Bili/z_en_bili.c deleted file mode 100644 index 62631c24c..000000000 --- a/src/overlays/actors/ovl_En_Bili/z_en_bili.c +++ /dev/null @@ -1,784 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BILI_Z_EN_BILI_C -#include "actor_common.h" -/* - * File: z_en_bili.c - * Overlay: ovl_En_Bili - * Description: Biri (small jellyfish-like enemy) - */ - -#include "z_en_bili.h" -#include "objects/object_bl/object_bl.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) - -void EnBili_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBili_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBili_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBili_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBili_SetupFloatIdle(EnBili* this); -void EnBili_SetupSpawnedFlyApart(EnBili* this); -void EnBili_FloatIdle(EnBili* this, GlobalContext* globalCtx); -void EnBili_SpawnedFlyApart(EnBili* this, GlobalContext* globalCtx); -void EnBili_DischargeLightning(EnBili* this, GlobalContext* globalCtx); -void EnBili_Climb(EnBili* this, GlobalContext* globalCtx); -void EnBili_ApproachPlayer(EnBili* this, GlobalContext* globalCtx); -void EnBili_SetNewHomeHeight(EnBili* this, GlobalContext* globalCtx); -void EnBili_Recoil(EnBili* this, GlobalContext* globalCtx); -void EnBili_Burnt(EnBili* this, GlobalContext* globalCtx); -void EnBili_Die(EnBili* this, GlobalContext* globalCtx); -void EnBili_Stunned(EnBili* this, GlobalContext* globalCtx); -void EnBili_Frozen(EnBili* this, GlobalContext* globalCtx); - -const ActorInit En_Bili_InitVars = { - ACTOR_EN_BILI, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BL, - sizeof(EnBili), - (ActorFunc)EnBili_Init, - (ActorFunc)EnBili_Destroy, - (ActorFunc)EnBili_Update, - (ActorFunc)EnBili_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT8, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x03, 0x08 }, - { 0xFFCFFFFF, 0x01, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 9, 28, -20, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 9, 28, -20, 30 }; - -typedef enum { - /* 0x0 */ BIRI_DMGEFF_NONE, - /* 0x1 */ BIRI_DMGEFF_DEKUNUT, - /* 0x2 */ BIRI_DMGEFF_FIRE, - /* 0x3 */ BIRI_DMGEFF_ICE, - /* 0xE */ BIRI_DMGEFF_SLINGSHOT = 0xE, - /* 0xF */ BIRI_DMGEFF_SWORD -} BiriDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, BIRI_DMGEFF_DEKUNUT), - /* Deku stick */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(0, BIRI_DMGEFF_SLINGSHOT), - /* Explosive */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(1, BIRI_DMGEFF_NONE), - /* Normal arrow */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Hookshot */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Kokiri sword */ DMG_ENTRY(1, BIRI_DMGEFF_SWORD), - /* Master sword */ DMG_ENTRY(2, BIRI_DMGEFF_SWORD), - /* Giant's Knife */ DMG_ENTRY(4, BIRI_DMGEFF_SWORD), - /* Fire arrow */ DMG_ENTRY(4, BIRI_DMGEFF_FIRE), - /* Ice arrow */ DMG_ENTRY(4, BIRI_DMGEFF_ICE), - /* Light arrow */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Unk arrow 1 */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(4, BIRI_DMGEFF_FIRE), - /* Ice magic */ DMG_ENTRY(4, BIRI_DMGEFF_ICE), - /* Light magic */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), - /* Shield */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, BIRI_DMGEFF_NONE), - /* Giant spin */ DMG_ENTRY(4, BIRI_DMGEFF_NONE), - /* Master spin */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Kokiri jump */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), - /* Giant jump */ DMG_ENTRY(8, BIRI_DMGEFF_NONE), - /* Master jump */ DMG_ENTRY(4, BIRI_DMGEFF_NONE), - /* Unknown 1 */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, BIRI_DMGEFF_NONE), - /* Unknown 2 */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x17, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), -}; - -void EnBili_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBili* this = (EnBili*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 17.0f); - this->actor.shape.shadowAlpha = 155; - SkelAnime_Init(globalCtx, &this->skelAnime, &gBiriSkel, &gBiriDefaultAnim, this->jointTable, this->morphTable, - EN_BILI_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->playFlySound = false; - - if (this->actor.params == EN_BILI_TYPE_NORMAL) { - EnBili_SetupFloatIdle(this); - } else { - EnBili_SetupSpawnedFlyApart(this); - } -} - -void EnBili_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBili* this = (EnBili*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -// Setup Action Functions - -void EnBili_SetupFloatIdle(EnBili* this) { - this->actor.speedXZ = 0.7f; - this->collider.info.bumper.effect = 1; // Shock? - this->timer = 32; - this->collider.base.atFlags |= AT_ON; - this->collider.base.acFlags |= AC_ON; - this->actionFunc = EnBili_FloatIdle; - this->actor.home.pos.y = this->actor.world.pos.y; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; -} - -/** - * Separates the Biri spawned by a dying EnVali. - */ -void EnBili_SetupSpawnedFlyApart(EnBili* this) { - Animation_PlayLoop(&this->skelAnime, &gBiriDefaultAnim); - this->timer = 25; - this->actor.velocity.y = 6.0f; - this->actor.gravity = -0.3f; - this->collider.base.atFlags &= ~AT_ON; - this->actionFunc = EnBili_SpawnedFlyApart; - this->actor.speedXZ = 3.0f; -} - -/** - * Used for both touching player/player's shield and being hit with sword. What to do next is determined by params. - */ -void EnBili_SetupDischargeLightning(EnBili* this) { - Animation_PlayLoop(&this->skelAnime, &gBiriDischargeLightningAnim); - this->timer = 10; - this->actionFunc = EnBili_DischargeLightning; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = -1.0f; -} - -void EnBili_SetupClimb(EnBili* this) { - Animation_PlayOnce(&this->skelAnime, &gBiriClimbAnim); - this->collider.base.atFlags &= ~AT_ON; - this->actionFunc = EnBili_Climb; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; -} - -void EnBili_SetupApproachPlayer(EnBili* this) { - this->actor.speedXZ = 1.2f; - this->actionFunc = EnBili_ApproachPlayer; -} - -void EnBili_SetupSetNewHomeHeight(EnBili* this) { - Animation_PlayLoop(&this->skelAnime, &gBiriDefaultAnim); - this->timer = 96; - this->actor.speedXZ = 0.9f; - this->collider.base.atFlags |= AT_ON; - this->actionFunc = EnBili_SetNewHomeHeight; - this->actor.home.pos.y = this->actor.world.pos.y; -} - -void EnBili_SetupRecoil(EnBili* this) { - if (this->skelAnime.animation != &gBiriDefaultAnim) { - Animation_PlayLoop(&this->skelAnime, &gBiriDefaultAnim); - } - - this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->collider.base.ac->prevPos) + 0x8000; - this->actor.world.rot.x = Actor_WorldPitchTowardPoint(&this->actor, &this->collider.base.ac->prevPos); - this->actionFunc = EnBili_Recoil; - this->actor.speedXZ = 5.0f; -} - -/** - * Used for both fire damage and generic damage - */ -void EnBili_SetupBurnt(EnBili* this) { - if (this->actionFunc == EnBili_Climb) { - Animation_PlayLoop(&this->skelAnime, &gBiriDefaultAnim); - } - - this->timer = 20; - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= ACTOR_FLAG_4; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0x2000, 0x14); - this->actionFunc = EnBili_Burnt; -} - -void EnBili_SetupDie(EnBili* this) { - this->timer = 18; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnBili_Die; - this->actor.speedXZ = 0.0f; -} - -/** - * Falls to ground - */ -void EnBili_SetupStunned(EnBili* this) { - this->timer = 80; - this->collider.info.bumper.effect = 0; - this->actor.gravity = -1.0f; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 0x96, 0x2000, 0x50); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->collider.base.atFlags &= ~AT_ON; - this->actionFunc = EnBili_Stunned; -} - -void EnBili_SetupFrozen(EnBili* this, GlobalContext* globalCtx) { - s32 i; - Vec3f effectPos; - - if (!(this->actor.flags & ACTOR_FLAG_15)) { - this->actor.gravity = -1.0f; - } - - this->actor.velocity.y = 0.0f; - effectPos.y = this->actor.world.pos.y - 15.0f; - - for (i = 0; i < 8; i++) { - - effectPos.x = this->actor.world.pos.x + ((i & 1) ? 7.0f : -7.0f); - effectPos.y += 2.5f; - effectPos.z = this->actor.world.pos.z + ((i & 4) ? 7.0f : -7.0f); - - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &effectPos, 150, 150, 150, 250, 235, 245, 255, - (Rand_ZeroOne() * 0.2f) + 0.7f); - } - - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 0x96, 0x2000, 0xA); - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->timer = 300; - this->actionFunc = EnBili_Frozen; -} - -// Miscellaneous - -/** - * Changes the texture displayed on the oral arms limb using the current frame. - */ -void EnBili_UpdateTentaclesIndex(EnBili* this) { - s16 curFrame = this->skelAnime.curFrame; - s16 temp; // Not strictly necessary, but avoids a few s16 casts - - if (this->actionFunc == EnBili_DischargeLightning) { - temp = 3 - curFrame; - this->tentaclesTexIndex = (ABS(temp) + 5) % 8; - } else if (this->actionFunc == EnBili_Climb) { - if (curFrame <= 9) { - temp = curFrame >> 1; - this->tentaclesTexIndex = CLAMP_MAX(temp, 3); - } else if (curFrame <= 18) { - temp = 17 - curFrame; - this->tentaclesTexIndex = CLAMP_MIN(temp, 0) >> 1; - } else if (curFrame <= 36) { - this->tentaclesTexIndex = ((36 - curFrame) / 3) + 2; - } else { - this->tentaclesTexIndex = (40 - curFrame) >> 1; - } - } else { - this->tentaclesTexIndex = curFrame >> 1; - } -} - -/** - * Tracks Player height, with oscillation, and moves away from walls - */ -void EnBili_UpdateFloating(EnBili* this) { - f32 playerHeight = this->actor.world.pos.y + this->actor.yDistToPlayer; - f32 heightOffset = ((this->actionFunc == EnBili_SetNewHomeHeight) ? 100.0f : 40.0f); - f32 baseHeight = CLAMP_MIN(this->actor.floorHeight, playerHeight); - - Math_StepToF(&this->actor.home.pos.y, baseHeight + heightOffset, 1.0f); - this->actor.world.pos.y = this->actor.home.pos.y + (sinf(this->timer * (M_PI / 16)) * 3.0f); - - // Turn around if touching wall - if (this->actor.bgCheckFlags & 8) { - this->actor.world.rot.y = this->actor.wallYaw; - } -} - -// Action functions - -void EnBili_FloatIdle(EnBili* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->timer != 0) { - this->timer--; - } - - if (!(this->timer % 4)) { - this->actor.world.rot.y += Rand_CenteredFloat(1820.0f); - } - - EnBili_UpdateFloating(this); - - if (this->timer == 0) { - this->timer = 32; - } - - if ((this->actor.xzDistToPlayer < 160.0f) && (fabsf(this->actor.yDistToPlayer) < 45.0f)) { - EnBili_SetupApproachPlayer(this); - } -} - -void EnBili_SpawnedFlyApart(EnBili* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - EnBili_SetupFloatIdle(this); - } -} - -void EnBili_DischargeLightning(EnBili* this, GlobalContext* globalCtx) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 255, 255, 255 }; - s32 i; - Vec3f effectPos; - s16 effectYaw; - - for (i = 0; i < 4; i++) { - if (!((this->timer + (i << 1)) % 4)) { - effectYaw = (s16)Rand_CenteredFloat(12288.0f) + (i * 0x4000) + 0x2000; - effectPos.x = Rand_CenteredFloat(5.0f) + this->actor.world.pos.x; - effectPos.y = (Rand_ZeroOne() * 5.0f) + this->actor.world.pos.y + 2.5f; - effectPos.z = Rand_CenteredFloat(5.0f) + this->actor.world.pos.z; - EffectSsLightning_Spawn(globalCtx, &effectPos, &primColor, &envColor, 15, effectYaw, 6, 2); - } - } - - SkelAnime_Update(&this->skelAnime); - func_8002F974(&this->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); - - if (this->timer != 0) { - this->timer--; - } - - this->actor.velocity.y *= -1.0f; - - if ((this->timer == 0) && Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->actor.params == EN_BILI_TYPE_DYING) { - EnBili_SetupDie(this); - } else { - EnBili_SetupClimb(this); - } - } -} - -void EnBili_Climb(EnBili* this, GlobalContext* globalCtx) { - s32 skelAnimeUpdate = SkelAnime_Update(&this->skelAnime); - f32 curFrame = this->skelAnime.curFrame; - - if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIRI_JUMP); - } - - if (curFrame > 9.0f) { - Math_ApproachF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.yDistToPlayer + 100.0f, 0.5f, - 5.0f); - } - - if (skelAnimeUpdate) { - EnBili_SetupSetNewHomeHeight(this); - } -} - -void EnBili_ApproachPlayer(EnBili* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ApproachS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 1820); - - if (this->timer != 0) { - this->timer--; - } - - EnBili_UpdateFloating(this); - - if (this->timer == 0) { - this->timer = 32; - } - - if (this->actor.xzDistToPlayer > 200.0f) { - EnBili_SetupFloatIdle(this); - } -} - -void EnBili_SetNewHomeHeight(EnBili* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->timer != 0) { - this->timer--; - } - - Math_ScaledStepToS(&this->actor.world.rot.y, (s16)(this->actor.yawTowardsPlayer + 0x8000), 910); - EnBili_UpdateFloating(this); - - if (this->timer == 0) { - EnBili_SetupFloatIdle(this); - } -} - -void EnBili_Recoil(EnBili* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f)) { - this->actor.world.rot.y += 0x8000; - EnBili_SetupFloatIdle(this); - } -} - -void EnBili_Burnt(EnBili* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->actor.flags & ACTOR_FLAG_15) { - this->actor.colorFilterTimer = 20; - } else { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - EnBili_SetupDie(this); - } - } -} - -void EnBili_Die(EnBili* this, GlobalContext* globalCtx) { - static Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f effectAccel = { 0.0f, 0.0f, 0.0f }; - s16 effectScale; - Vec3f effectPos; - s32 i; - - if (this->actor.draw != NULL) { - if (this->actor.flags & ACTOR_FLAG_15) { - return; - } - this->actor.draw = NULL; - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x50); - } - - if (this->timer != 0) { - this->timer--; - } - - if (this->timer != 0) { - for (i = 0; i < 2; i++) { - effectPos.x = ((Rand_ZeroOne() * 10.0f) + this->actor.world.pos.x) - 5.0f; - effectPos.y = ((Rand_ZeroOne() * 5.0f) + this->actor.world.pos.y) - 2.5f; - effectPos.z = ((Rand_ZeroOne() * 10.0f) + this->actor.world.pos.z) - 5.0f; - - effectVelocity.y = Rand_ZeroOne() + 1.0f; - effectScale = Rand_S16Offset(40, 40); - - if (Rand_ZeroOne() < 0.7f) { - EffectSsDtBubble_SpawnColorProfile(globalCtx, &effectPos, &effectVelocity, &effectAccel, effectScale, - 25, 2, 1); - } else { - EffectSsDtBubble_SpawnColorProfile(globalCtx, &effectPos, &effectVelocity, &effectAccel, effectScale, - 25, 0, 1); - } - } - } else { - Actor_Kill(&this->actor); - } - - if (this->timer == 14) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BIRI_BUBLE); - } -} - -void EnBili_Stunned(EnBili* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - - if (this->timer == 0) { - EnBili_SetupFloatIdle(this); - } -} - -void EnBili_Frozen(EnBili* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (!(this->actor.flags & ACTOR_FLAG_15)) { - this->actor.gravity = -1.0f; - } - - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - this->actor.colorFilterTimer = 0; - EnBili_SetupDie(this); - } else { - this->actor.colorFilterTimer = 10; - } -} - -void EnBili_UpdateDamage(EnBili* this, GlobalContext* globalCtx) { - u8 damageEffect; - - if ((this->actor.colChkInfo.health != 0) && (this->collider.base.acFlags & AC_HIT)) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIRI_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~ACTOR_FLAG_0; - } - - damageEffect = this->actor.colChkInfo.damageEffect; - - if (damageEffect == BIRI_DMGEFF_DEKUNUT) { - if (this->actionFunc != EnBili_Stunned) { - EnBili_SetupStunned(this); - } - } else if (damageEffect == BIRI_DMGEFF_SWORD) { - if (this->actionFunc != EnBili_Stunned) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0x2000, 0xA); - - if (this->actor.colChkInfo.health == 0) { - this->actor.params = EN_BILI_TYPE_DYING; - } - EnBili_SetupDischargeLightning(this); - } else { - EnBili_SetupBurnt(this); - } - } else if (damageEffect == BIRI_DMGEFF_FIRE) { - EnBili_SetupBurnt(this); - this->timer = 2; - } else if (damageEffect == BIRI_DMGEFF_ICE) { - EnBili_SetupFrozen(this, globalCtx); - } else if (damageEffect == BIRI_DMGEFF_SLINGSHOT) { - EnBili_SetupRecoil(this); - } else { - EnBili_SetupBurnt(this); - } - - if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1F820) { // DMG_ARROW - this->actor.flags |= ACTOR_FLAG_4; - } - } - } -} - -void EnBili_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnBili* this = (EnBili*)thisx; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - EnBili_SetupDischargeLightning(this); - } - - EnBili_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - - if (this->actionFunc != EnBili_Die) { - EnBili_UpdateTentaclesIndex(this); - if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - if ((this->actionFunc == EnBili_FloatIdle) || (this->actionFunc == EnBili_SetNewHomeHeight) || - (this->actionFunc == EnBili_ApproachPlayer) || (this->actionFunc == EnBili_Recoil)) { - if (this->playFlySound) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIRI_FLY); - this->playFlySound = false; - } else { - this->playFlySound = true; - } - } - } - if (this->actionFunc == EnBili_Recoil) { - func_8002D97C(&this->actor); - } else { - Actor_MoveForward(&this->actor); - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, this->collider.dim.radius, this->collider.dim.height, 7); - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_SetFocus(&this->actor, 0.0f); - } -} - -// Draw and associated functions - -void EnBili_PulseLimb3(EnBili* this, f32 frame, Vec3f* arg2) { - f32 cos; - f32 sin; - - if (this->actionFunc == EnBili_DischargeLightning) { - arg2->y = 1.0f - (sinf((M_PI * 0.16667f) * frame) * 0.26f); - } else if (this->actionFunc == EnBili_Climb) { - if (frame <= 8.0f) { - arg2->y = (cosf((M_PI * 0.125f) * frame) * 0.15f) + 0.85f; - } else if (frame <= 18.0f) { - cos = cosf((frame - 8.0f) * (M_PI * 0.1f)); - arg2->y = 1.0f - (0.3f * cos); - arg2->x = (0.2f * cos) + 0.8f; - } else { - cos = cosf((frame - 18.0f) * (M_PI * 0.0227f)); - arg2->y = (0.31f * cos) + 1.0f; - arg2->x = 1.0f - (0.4f * cos); - } - - arg2->z = arg2->x; - } else if (this->actionFunc == EnBili_Stunned) { - sin = sinf((M_PI * 0.1f) * this->timer) * 0.08f; - arg2->x -= sin; - arg2->y += sin; - arg2->z -= sin; - } else { - arg2->y = (cosf((M_PI * 0.125f) * frame) * 0.13f) + 0.87f; - } -} - -void EnBili_PulseLimb2(EnBili* this, f32 frame, Vec3f* arg2) { - f32 cos; - f32 sin; - - if (this->actionFunc == EnBili_DischargeLightning) { - arg2->y = (sinf((M_PI * 0.16667f) * frame) * 0.2f) + 1.0f; - } else if (this->actionFunc == EnBili_Climb) { - if (frame <= 8.0f) { - arg2->x = 1.125f - (cosf((M_PI * 0.125f) * frame) * 0.125f); - } else if (frame <= 18.0f) { - cos = cosf((frame - 8.0f) * (M_PI * 0.1f)); - arg2->x = (0.275f * cos) + 0.975f; - arg2->y = 1.25f - (0.25f * cos); - } else { - cos = cosf((frame - 18.0f) * (M_PI * 0.0227f)); - arg2->x = 1.0f - (0.3f * cos); - arg2->y = (0.48f * cos) + 1.0f; - } - arg2->z = arg2->x; - } else if (this->actionFunc == EnBili_Stunned) { - sin = sinf((M_PI * 0.1f) * this->timer) * 0.08f; - arg2->x += sin; - arg2->y -= sin; - arg2->z += sin; - } else { - arg2->y = 1.1f - (cosf((M_PI * 0.125f) * frame) * 0.1f); - } -} - -void EnBili_PulseLimb4(EnBili* this, f32 frame, Vec3f* arg2) { - f32 cos; - - if (this->actionFunc == EnBili_Climb) { - if (frame <= 8.0f) { - cos = cosf((M_PI * 0.125f) * frame); - arg2->x = 1.125f - (0.125f * cos); - arg2->y = (0.3f * cos) + 0.7f; - } else if (frame <= 18.0f) { - cos = cosf((frame - 8.0f) * (M_PI * 0.1f)); - arg2->x = (0.325f * cos) + 0.925f; - arg2->y = 0.95f - (0.55f * cos); - } else { - cos = cosf((frame - 18.0f) * (M_PI * 0.0227f)); - arg2->x = 1.0f - (0.4f * cos); - arg2->y = (0.52f * cos) + 1.0f; - } - arg2->z = arg2->x; - } -} - -s32 EnBili_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnBili* this = (EnBili*)thisx; - Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; - f32 curFrame = this->skelAnime.curFrame; - - if (limbIndex == EN_BILI_LIMB_OUTER_HOOD) { - EnBili_PulseLimb3(this, curFrame, &limbScale); - } else if (limbIndex == EN_BILI_LIMB_INNER_HOOD) { - EnBili_PulseLimb2(this, curFrame, &limbScale); - } else if (limbIndex == EN_BILI_LIMB_TENTACLES) { - EnBili_PulseLimb4(this, curFrame, &limbScale); - rot->y = (Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y) + 0x8000; - } - - Matrix_Scale(limbScale.x, limbScale.y, limbScale.z, MTXMODE_APPLY); - return false; -} - -static void* sTentaclesTextures[] = { - gBiriTentacles0Tex, gBiriTentacles1Tex, gBiriTentacles2Tex, gBiriTentacles3Tex, - gBiriTentacles4Tex, gBiriTentacles5Tex, gBiriTentacles6Tex, gBiriTentacles7Tex, -}; - -#include "overlays/ovl_En_Bili/ovl_En_Bili.c" - -void EnBili_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBili* this = (EnBili*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bili.c", 1521); - func_80093D84(globalCtx->state.gfxCtx); - - this->tentaclesTexIndex = CLAMP_MAX(this->tentaclesTexIndex, 7); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTentaclesTextures[this->tentaclesTexIndex])); - - if ((this->actionFunc == EnBili_DischargeLightning) && ((this->timer & 1) != 0)) { - gSPSegment(POLY_XLU_DISP++, 0x09, D_809C16F0); - } else { - gSPSegment(POLY_XLU_DISP++, 0x09, D_809C1700); - } - - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnBili_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bili.c", 1552); -} diff --git a/src/overlays/actors/ovl_En_Bili/z_en_bili.cpp b/src/overlays/actors/ovl_En_Bili/z_en_bili.cpp new file mode 100644 index 000000000..4cb74d000 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bili/z_en_bili.cpp @@ -0,0 +1,784 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BILI_Z_EN_BILI_C +#include "actor_common.h" +/* + * File: z_en_bili.c + * Overlay: ovl_En_Bili + * Description: Biri (small jellyfish-like enemy) + */ + +#include "z_en_bili.h" +#include "objects/object_bl/object_bl.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) + +void EnBili_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBili_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBili_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBili_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBili_SetupFloatIdle(EnBili* pthis); +void EnBili_SetupSpawnedFlyApart(EnBili* pthis); +void EnBili_FloatIdle(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_SpawnedFlyApart(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_DischargeLightning(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_Climb(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_ApproachPlayer(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_SetNewHomeHeight(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_Recoil(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_Burnt(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_Die(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_Stunned(EnBili* pthis, GlobalContext* globalCtx); +void EnBili_Frozen(EnBili* pthis, GlobalContext* globalCtx); + +ActorInit En_Bili_InitVars = { + ACTOR_EN_BILI, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BL, + sizeof(EnBili), + (ActorFunc)EnBili_Init, + (ActorFunc)EnBili_Destroy, + (ActorFunc)EnBili_Update, + (ActorFunc)EnBili_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT8, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x03, 0x08 }, + { 0xFFCFFFFF, 0x01, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 9, 28, -20, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 9, 28, -20, 30 }; + +typedef enum { + /* 0x0 */ BIRI_DMGEFF_NONE, + /* 0x1 */ BIRI_DMGEFF_DEKUNUT, + /* 0x2 */ BIRI_DMGEFF_FIRE, + /* 0x3 */ BIRI_DMGEFF_ICE, + /* 0xE */ BIRI_DMGEFF_SLINGSHOT = 0xE, + /* 0xF */ BIRI_DMGEFF_SWORD +} BiriDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, BIRI_DMGEFF_DEKUNUT), + /* Deku stick */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(0, BIRI_DMGEFF_SLINGSHOT), + /* Explosive */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(1, BIRI_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Kokiri sword */ DMG_ENTRY(1, BIRI_DMGEFF_SWORD), + /* Master sword */ DMG_ENTRY(2, BIRI_DMGEFF_SWORD), + /* Giant's Knife */ DMG_ENTRY(4, BIRI_DMGEFF_SWORD), + /* Fire arrow */ DMG_ENTRY(4, BIRI_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(4, BIRI_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Unk arrow 1 */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(4, BIRI_DMGEFF_FIRE), + /* Ice magic */ DMG_ENTRY(4, BIRI_DMGEFF_ICE), + /* Light magic */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), + /* Shield */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, BIRI_DMGEFF_NONE), + /* Giant spin */ DMG_ENTRY(4, BIRI_DMGEFF_NONE), + /* Master spin */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Kokiri jump */ DMG_ENTRY(2, BIRI_DMGEFF_NONE), + /* Giant jump */ DMG_ENTRY(8, BIRI_DMGEFF_NONE), + /* Master jump */ DMG_ENTRY(4, BIRI_DMGEFF_NONE), + /* Unknown 1 */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, BIRI_DMGEFF_NONE), + /* Unknown 2 */ DMG_ENTRY(0, BIRI_DMGEFF_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x17, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), +}; + +void EnBili_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBili* pthis = (EnBili*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 17.0f); + pthis->actor.shape.shadowAlpha = 155; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBiriSkel, &gBiriDefaultAnim, pthis->jointTable, pthis->morphTable, + EN_BILI_LIMB_MAX); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->playFlySound = false; + + if (pthis->actor.params == EN_BILI_TYPE_NORMAL) { + EnBili_SetupFloatIdle(pthis); + } else { + EnBili_SetupSpawnedFlyApart(pthis); + } +} + +void EnBili_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBili* pthis = (EnBili*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +// Setup Action Functions + +void EnBili_SetupFloatIdle(EnBili* pthis) { + pthis->actor.speedXZ = 0.7f; + pthis->collider.info.bumper.effect = 1; // Shock? + pthis->timer = 32; + pthis->collider.base.atFlags |= AT_ON; + pthis->collider.base.acFlags |= AC_ON; + pthis->actionFunc = EnBili_FloatIdle; + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; +} + +/** + * Separates the Biri spawned by a dying EnVali. + */ +void EnBili_SetupSpawnedFlyApart(EnBili* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gBiriDefaultAnim); + pthis->timer = 25; + pthis->actor.velocity.y = 6.0f; + pthis->actor.gravity = -0.3f; + pthis->collider.base.atFlags &= ~AT_ON; + pthis->actionFunc = EnBili_SpawnedFlyApart; + pthis->actor.speedXZ = 3.0f; +} + +/** + * Used for both touching player/player's shield and being hit with sword. What to do next is determined by params. + */ +void EnBili_SetupDischargeLightning(EnBili* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gBiriDischargeLightningAnim); + pthis->timer = 10; + pthis->actionFunc = EnBili_DischargeLightning; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = -1.0f; +} + +void EnBili_SetupClimb(EnBili* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gBiriClimbAnim); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->actionFunc = EnBili_Climb; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; +} + +void EnBili_SetupApproachPlayer(EnBili* pthis) { + pthis->actor.speedXZ = 1.2f; + pthis->actionFunc = EnBili_ApproachPlayer; +} + +void EnBili_SetupSetNewHomeHeight(EnBili* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gBiriDefaultAnim); + pthis->timer = 96; + pthis->actor.speedXZ = 0.9f; + pthis->collider.base.atFlags |= AT_ON; + pthis->actionFunc = EnBili_SetNewHomeHeight; + pthis->actor.home.pos.y = pthis->actor.world.pos.y; +} + +void EnBili_SetupRecoil(EnBili* pthis) { + if (pthis->skelAnime.animation != &gBiriDefaultAnim) { + Animation_PlayLoop(&pthis->skelAnime, &gBiriDefaultAnim); + } + + pthis->actor.world.rot.y = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->collider.base.ac->prevPos) + 0x8000; + pthis->actor.world.rot.x = Actor_WorldPitchTowardPoint(&pthis->actor, &pthis->collider.base.ac->prevPos); + pthis->actionFunc = EnBili_Recoil; + pthis->actor.speedXZ = 5.0f; +} + +/** + * Used for both fire damage and generic damage + */ +void EnBili_SetupBurnt(EnBili* pthis) { + if (pthis->actionFunc == EnBili_Climb) { + Animation_PlayLoop(&pthis->skelAnime, &gBiriDefaultAnim); + } + + pthis->timer = 20; + pthis->collider.base.atFlags &= ~AT_ON; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0x2000, 0x14); + pthis->actionFunc = EnBili_Burnt; +} + +void EnBili_SetupDie(EnBili* pthis) { + pthis->timer = 18; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnBili_Die; + pthis->actor.speedXZ = 0.0f; +} + +/** + * Falls to ground + */ +void EnBili_SetupStunned(EnBili* pthis) { + pthis->timer = 80; + pthis->collider.info.bumper.effect = 0; + pthis->actor.gravity = -1.0f; + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 0x96, 0x2000, 0x50); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->actionFunc = EnBili_Stunned; +} + +void EnBili_SetupFrozen(EnBili* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f effectPos; + + if (!(pthis->actor.flags & ACTOR_FLAG_15)) { + pthis->actor.gravity = -1.0f; + } + + pthis->actor.velocity.y = 0.0f; + effectPos.y = pthis->actor.world.pos.y - 15.0f; + + for (i = 0; i < 8; i++) { + + effectPos.x = pthis->actor.world.pos.x + ((i & 1) ? 7.0f : -7.0f); + effectPos.y += 2.5f; + effectPos.z = pthis->actor.world.pos.z + ((i & 4) ? 7.0f : -7.0f); + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &effectPos, 150, 150, 150, 250, 235, 245, 255, + (Rand_ZeroOne() * 0.2f) + 0.7f); + } + + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 0x96, 0x2000, 0xA); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->timer = 300; + pthis->actionFunc = EnBili_Frozen; +} + +// Miscellaneous + +/** + * Changes the texture displayed on the oral arms limb using the current frame. + */ +void EnBili_UpdateTentaclesIndex(EnBili* pthis) { + s16 curFrame = pthis->skelAnime.curFrame; + s16 temp; // Not strictly necessary, but avoids a few s16 casts + + if (pthis->actionFunc == EnBili_DischargeLightning) { + temp = 3 - curFrame; + pthis->tentaclesTexIndex = (ABS(temp) + 5) % 8; + } else if (pthis->actionFunc == EnBili_Climb) { + if (curFrame <= 9) { + temp = curFrame >> 1; + pthis->tentaclesTexIndex = CLAMP_MAX(temp, 3); + } else if (curFrame <= 18) { + temp = 17 - curFrame; + pthis->tentaclesTexIndex = CLAMP_MIN(temp, 0) >> 1; + } else if (curFrame <= 36) { + pthis->tentaclesTexIndex = ((36 - curFrame) / 3) + 2; + } else { + pthis->tentaclesTexIndex = (40 - curFrame) >> 1; + } + } else { + pthis->tentaclesTexIndex = curFrame >> 1; + } +} + +/** + * Tracks Player height, with oscillation, and moves away from walls + */ +void EnBili_UpdateFloating(EnBili* pthis) { + f32 playerHeight = pthis->actor.world.pos.y + pthis->actor.yDistToPlayer; + f32 heightOffset = ((pthis->actionFunc == EnBili_SetNewHomeHeight) ? 100.0f : 40.0f); + f32 baseHeight = CLAMP_MIN(pthis->actor.floorHeight, playerHeight); + + Math_StepToF(&pthis->actor.home.pos.y, baseHeight + heightOffset, 1.0f); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (sinf(pthis->timer * (M_PI / 16)) * 3.0f); + + // Turn around if touching wall + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.world.rot.y = pthis->actor.wallYaw; + } +} + +// Action functions + +void EnBili_FloatIdle(EnBili* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (!(pthis->timer % 4)) { + pthis->actor.world.rot.y += Rand_CenteredFloat(1820.0f); + } + + EnBili_UpdateFloating(pthis); + + if (pthis->timer == 0) { + pthis->timer = 32; + } + + if ((pthis->actor.xzDistToPlayer < 160.0f) && (fabsf(pthis->actor.yDistToPlayer) < 45.0f)) { + EnBili_SetupApproachPlayer(pthis); + } +} + +void EnBili_SpawnedFlyApart(EnBili* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + EnBili_SetupFloatIdle(pthis); + } +} + +void EnBili_DischargeLightning(EnBili* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 255, 255, 255 }; + s32 i; + Vec3f effectPos; + s16 effectYaw; + + for (i = 0; i < 4; i++) { + if (!((pthis->timer + (i << 1)) % 4)) { + effectYaw = (s16)Rand_CenteredFloat(12288.0f) + (i * 0x4000) + 0x2000; + effectPos.x = Rand_CenteredFloat(5.0f) + pthis->actor.world.pos.x; + effectPos.y = (Rand_ZeroOne() * 5.0f) + pthis->actor.world.pos.y + 2.5f; + effectPos.z = Rand_CenteredFloat(5.0f) + pthis->actor.world.pos.z; + EffectSsLightning_Spawn(globalCtx, &effectPos, &primColor, &envColor, 15, effectYaw, 6, 2); + } + } + + SkelAnime_Update(&pthis->skelAnime); + func_8002F974(&pthis->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); + + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.velocity.y *= -1.0f; + + if ((pthis->timer == 0) && Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + if (pthis->actor.params == EN_BILI_TYPE_DYING) { + EnBili_SetupDie(pthis); + } else { + EnBili_SetupClimb(pthis); + } + } +} + +void EnBili_Climb(EnBili* pthis, GlobalContext* globalCtx) { + s32 skelAnimeUpdate = SkelAnime_Update(&pthis->skelAnime); + f32 curFrame = pthis->skelAnime.curFrame; + + if (Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIRI_JUMP); + } + + if (curFrame > 9.0f) { + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.world.pos.y + pthis->actor.yDistToPlayer + 100.0f, 0.5f, + 5.0f); + } + + if (skelAnimeUpdate) { + EnBili_SetupSetNewHomeHeight(pthis); + } +} + +void EnBili_ApproachPlayer(EnBili* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 2, 1820); + + if (pthis->timer != 0) { + pthis->timer--; + } + + EnBili_UpdateFloating(pthis); + + if (pthis->timer == 0) { + pthis->timer = 32; + } + + if (pthis->actor.xzDistToPlayer > 200.0f) { + EnBili_SetupFloatIdle(pthis); + } +} + +void EnBili_SetNewHomeHeight(EnBili* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_ScaledStepToS(&pthis->actor.world.rot.y, (s16)(pthis->actor.yawTowardsPlayer + 0x8000), 910); + EnBili_UpdateFloating(pthis); + + if (pthis->timer == 0) { + EnBili_SetupFloatIdle(pthis); + } +} + +void EnBili_Recoil(EnBili* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.3f)) { + pthis->actor.world.rot.y += 0x8000; + EnBili_SetupFloatIdle(pthis); + } +} + +void EnBili_Burnt(EnBili* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.flags & ACTOR_FLAG_15) { + pthis->actor.colorFilterTimer = 20; + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + EnBili_SetupDie(pthis); + } + } +} + +void EnBili_Die(EnBili* pthis, GlobalContext* globalCtx) { + static Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f effectAccel = { 0.0f, 0.0f, 0.0f }; + s16 effectScale; + Vec3f effectPos; + s32 i; + + if (pthis->actor.draw != NULL) { + if (pthis->actor.flags & ACTOR_FLAG_15) { + return; + } + pthis->actor.draw = NULL; + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x50); + } + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer != 0) { + for (i = 0; i < 2; i++) { + effectPos.x = ((Rand_ZeroOne() * 10.0f) + pthis->actor.world.pos.x) - 5.0f; + effectPos.y = ((Rand_ZeroOne() * 5.0f) + pthis->actor.world.pos.y) - 2.5f; + effectPos.z = ((Rand_ZeroOne() * 10.0f) + pthis->actor.world.pos.z) - 5.0f; + + effectVelocity.y = Rand_ZeroOne() + 1.0f; + effectScale = Rand_S16Offset(40, 40); + + if (Rand_ZeroOne() < 0.7f) { + EffectSsDtBubble_SpawnColorProfile(globalCtx, &effectPos, &effectVelocity, &effectAccel, effectScale, + 25, 2, 1); + } else { + EffectSsDtBubble_SpawnColorProfile(globalCtx, &effectPos, &effectVelocity, &effectAccel, effectScale, + 25, 0, 1); + } + } + } else { + Actor_Kill(&pthis->actor); + } + + if (pthis->timer == 14) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_BIRI_BUBLE); + } +} + +void EnBili_Stunned(EnBili* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + + if (pthis->timer == 0) { + EnBili_SetupFloatIdle(pthis); + } +} + +void EnBili_Frozen(EnBili* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (!(pthis->actor.flags & ACTOR_FLAG_15)) { + pthis->actor.gravity = -1.0f; + } + + if ((pthis->actor.bgCheckFlags & 1) || (pthis->actor.floorHeight == BGCHECK_Y_MIN)) { + pthis->actor.colorFilterTimer = 0; + EnBili_SetupDie(pthis); + } else { + pthis->actor.colorFilterTimer = 10; + } +} + +void EnBili_UpdateDamage(EnBili* pthis, GlobalContext* globalCtx) { + u8 damageEffect; + + if ((pthis->actor.colChkInfo.health != 0) && (pthis->collider.base.acFlags & AC_HIT)) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIRI_DEAD); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + + damageEffect = pthis->actor.colChkInfo.damageEffect; + + if (damageEffect == BIRI_DMGEFF_DEKUNUT) { + if (pthis->actionFunc != EnBili_Stunned) { + EnBili_SetupStunned(pthis); + } + } else if (damageEffect == BIRI_DMGEFF_SWORD) { + if (pthis->actionFunc != EnBili_Stunned) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0x2000, 0xA); + + if (pthis->actor.colChkInfo.health == 0) { + pthis->actor.params = EN_BILI_TYPE_DYING; + } + EnBili_SetupDischargeLightning(pthis); + } else { + EnBili_SetupBurnt(pthis); + } + } else if (damageEffect == BIRI_DMGEFF_FIRE) { + EnBili_SetupBurnt(pthis); + pthis->timer = 2; + } else if (damageEffect == BIRI_DMGEFF_ICE) { + EnBili_SetupFrozen(pthis, globalCtx); + } else if (damageEffect == BIRI_DMGEFF_SLINGSHOT) { + EnBili_SetupRecoil(pthis); + } else { + EnBili_SetupBurnt(pthis); + } + + if (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x1F820) { // DMG_ARROW + pthis->actor.flags |= ACTOR_FLAG_4; + } + } + } +} + +void EnBili_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBili* pthis = (EnBili*)thisx; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + EnBili_SetupDischargeLightning(pthis); + } + + EnBili_UpdateDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actionFunc != EnBili_Die) { + EnBili_UpdateTentaclesIndex(pthis); + if (Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + if ((pthis->actionFunc == EnBili_FloatIdle) || (pthis->actionFunc == EnBili_SetNewHomeHeight) || + (pthis->actionFunc == EnBili_ApproachPlayer) || (pthis->actionFunc == EnBili_Recoil)) { + if (pthis->playFlySound) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIRI_FLY); + pthis->playFlySound = false; + } else { + pthis->playFlySound = true; + } + } + } + if (pthis->actionFunc == EnBili_Recoil) { + func_8002D97C(&pthis->actor); + } else { + Actor_MoveForward(&pthis->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, pthis->collider.dim.radius, pthis->collider.dim.height, 7); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (pthis->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_SetFocus(&pthis->actor, 0.0f); + } +} + +// Draw and associated functions + +void EnBili_PulseLimb3(EnBili* pthis, f32 frame, Vec3f* arg2) { + f32 cos; + f32 sin; + + if (pthis->actionFunc == EnBili_DischargeLightning) { + arg2->y = 1.0f - (sinf((M_PI * 0.16667f) * frame) * 0.26f); + } else if (pthis->actionFunc == EnBili_Climb) { + if (frame <= 8.0f) { + arg2->y = (cosf((M_PI * 0.125f) * frame) * 0.15f) + 0.85f; + } else if (frame <= 18.0f) { + cos = cosf((frame - 8.0f) * (M_PI * 0.1f)); + arg2->y = 1.0f - (0.3f * cos); + arg2->x = (0.2f * cos) + 0.8f; + } else { + cos = cosf((frame - 18.0f) * (M_PI * 0.0227f)); + arg2->y = (0.31f * cos) + 1.0f; + arg2->x = 1.0f - (0.4f * cos); + } + + arg2->z = arg2->x; + } else if (pthis->actionFunc == EnBili_Stunned) { + sin = sinf((M_PI * 0.1f) * pthis->timer) * 0.08f; + arg2->x -= sin; + arg2->y += sin; + arg2->z -= sin; + } else { + arg2->y = (cosf((M_PI * 0.125f) * frame) * 0.13f) + 0.87f; + } +} + +void EnBili_PulseLimb2(EnBili* pthis, f32 frame, Vec3f* arg2) { + f32 cos; + f32 sin; + + if (pthis->actionFunc == EnBili_DischargeLightning) { + arg2->y = (sinf((M_PI * 0.16667f) * frame) * 0.2f) + 1.0f; + } else if (pthis->actionFunc == EnBili_Climb) { + if (frame <= 8.0f) { + arg2->x = 1.125f - (cosf((M_PI * 0.125f) * frame) * 0.125f); + } else if (frame <= 18.0f) { + cos = cosf((frame - 8.0f) * (M_PI * 0.1f)); + arg2->x = (0.275f * cos) + 0.975f; + arg2->y = 1.25f - (0.25f * cos); + } else { + cos = cosf((frame - 18.0f) * (M_PI * 0.0227f)); + arg2->x = 1.0f - (0.3f * cos); + arg2->y = (0.48f * cos) + 1.0f; + } + arg2->z = arg2->x; + } else if (pthis->actionFunc == EnBili_Stunned) { + sin = sinf((M_PI * 0.1f) * pthis->timer) * 0.08f; + arg2->x += sin; + arg2->y -= sin; + arg2->z += sin; + } else { + arg2->y = 1.1f - (cosf((M_PI * 0.125f) * frame) * 0.1f); + } +} + +void EnBili_PulseLimb4(EnBili* pthis, f32 frame, Vec3f* arg2) { + f32 cos; + + if (pthis->actionFunc == EnBili_Climb) { + if (frame <= 8.0f) { + cos = cosf((M_PI * 0.125f) * frame); + arg2->x = 1.125f - (0.125f * cos); + arg2->y = (0.3f * cos) + 0.7f; + } else if (frame <= 18.0f) { + cos = cosf((frame - 8.0f) * (M_PI * 0.1f)); + arg2->x = (0.325f * cos) + 0.925f; + arg2->y = 0.95f - (0.55f * cos); + } else { + cos = cosf((frame - 18.0f) * (M_PI * 0.0227f)); + arg2->x = 1.0f - (0.4f * cos); + arg2->y = (0.52f * cos) + 1.0f; + } + arg2->z = arg2->x; + } +} + +s32 EnBili_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnBili* pthis = (EnBili*)thisx; + Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; + f32 curFrame = pthis->skelAnime.curFrame; + + if (limbIndex == EN_BILI_LIMB_OUTER_HOOD) { + EnBili_PulseLimb3(pthis, curFrame, &limbScale); + } else if (limbIndex == EN_BILI_LIMB_INNER_HOOD) { + EnBili_PulseLimb2(pthis, curFrame, &limbScale); + } else if (limbIndex == EN_BILI_LIMB_TENTACLES) { + EnBili_PulseLimb4(pthis, curFrame, &limbScale); + rot->y = (Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y) + 0x8000; + } + + Matrix_Scale(limbScale.x, limbScale.y, limbScale.z, MTXMODE_APPLY); + return false; +} + +static void* sTentaclesTextures[] = { + gBiriTentacles0Tex, gBiriTentacles1Tex, gBiriTentacles2Tex, gBiriTentacles3Tex, + gBiriTentacles4Tex, gBiriTentacles5Tex, gBiriTentacles6Tex, gBiriTentacles7Tex, +}; + +#include "overlays/ovl_En_Bili/ovl_En_Bili.cpp" + +void EnBili_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBili* pthis = (EnBili*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bili.c", 1521); + func_80093D84(globalCtx->state.gfxCtx); + + pthis->tentaclesTexIndex = CLAMP_MAX(pthis->tentaclesTexIndex, 7); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTentaclesTextures[pthis->tentaclesTexIndex])); + + if ((pthis->actionFunc == EnBili_DischargeLightning) && ((pthis->timer & 1) != 0)) { + gSPSegment(POLY_XLU_DISP++, 0x09, D_809C16F0); + } else { + gSPSegment(POLY_XLU_DISP++, 0x09, D_809C1700); + } + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnBili_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bili.c", 1552); +} diff --git a/src/overlays/actors/ovl_En_Bird/z_en_bird.c b/src/overlays/actors/ovl_En_Bird/z_en_bird.c deleted file mode 100644 index 6377e49e4..000000000 --- a/src/overlays/actors/ovl_En_Bird/z_en_bird.c +++ /dev/null @@ -1,138 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BIRD_Z_EN_BIRD_C -#include "actor_common.h" -/* - * File: z_en_bird.c - * Overlay: ovl_En_Bird - * Description: An unused brown bird - */ - -#include "z_en_bird.h" -#include "objects/object_bird/object_bird.h" -#include "def/sinf.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void EnBird_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBird_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBird_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBird_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809C1E00(EnBird* this, s16 params); -void func_809C1E40(EnBird* this, GlobalContext* globalCtx); -void func_809C1D60(EnBird* this, GlobalContext* globalCtx); -void func_809C1CAC(EnBird* this, s16 params); - -const ActorInit En_Bird_InitVars = { - ACTOR_EN_BIRD, - ACTORCAT_PROP, - FLAGS, - OBJECT_BIRD, - sizeof(EnBird), - (ActorFunc)EnBird_Init, - (ActorFunc)EnBird_Destroy, - (ActorFunc)EnBird_Update, - (ActorFunc)EnBird_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), -}; - -void EnBird_SetupAction(EnBird* this, EnBirdActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnBird_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBird* this = (EnBird*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.01); - SkelAnime_Init(globalCtx, &this->skelAnime, &gBirdSkel, &gBirdFlyAnim, NULL, NULL, 0); - ActorShape_Init(&this->actor.shape, 5500, ActorShadow_DrawCircle, 4); - this->unk_194 = 0; - this->unk_198 = 0; - this->unk_1C0 = 0x9C4; - this->actor.colChkInfo.mass = 0; - this->unk_1A8 = 1.5f; - this->unk_1AC = 0.5f; - this->unk_1A0 = 0.0f; - this->unk_1A4 = 0.0f; - this->unk_1B8 = 0.0f; - this->unk_1B0 = 40.0f; - this->unk_1BC = 70.0f; - func_809C1CAC(this, this->actor.params); -} - -void EnBird_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void func_809C1CAC(EnBird* this, s16 params) { - f32 frameCount = Animation_GetLastFrame(&gBirdFlyAnim); - f32 playbackSpeed = this->unk_19C ? 0.0f : 1.0f; - AnimationHeader* anim = &gBirdFlyAnim; - - this->unk_198 = Rand_S16Offset(5, 0x23); - Animation_Change(&this->skelAnime, anim, playbackSpeed, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - EnBird_SetupAction(this, func_809C1D60); -} - -void func_809C1D60(EnBird* this, GlobalContext* globalCtx) { - f32 fVar2 = sinf(this->unk_1B4); - - this->actor.shape.yOffset = this->actor.shape.yOffset + fVar2 * this->unk_1A0; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); - - if (this->unk_19C != 0) { - this->skelAnime.playSpeed = this->actor.speedXZ + this->actor.speedXZ; - } - - SkelAnime_Update(&this->skelAnime); - this->unk_198 -= 1; - - if (this->unk_198 <= 0) { - func_809C1E00(this, this->actor.params); - } -} - -void func_809C1E00(EnBird* this, s16 params) { - this->unk_198 = Rand_S16Offset(0x14, 0x2D); - EnBird_SetupAction(this, func_809C1E40); -} - -void func_809C1E40(EnBird* this, GlobalContext* globalCtx) { - f32 fVar4 = sinf(this->unk_1B4); - - this->actor.shape.yOffset += fVar4 * this->unk_1A0; - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_1A8, 0.1f, this->unk_1AC, 0.0f); - - if (this->unk_1B0 < Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) || this->unk_198 < 4) { - Math_StepToAngleS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), - this->unk_1C0); - } else { - fVar4 = sinf(this->unk_1B4); - this->actor.world.rot.y += (s16)(fVar4 * this->unk_1A4); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - SkelAnime_Update(&this->skelAnime); - this->unk_198 -= 1; - if (this->unk_198 < 0) { - func_809C1CAC(this, this->actor.params); - } -} - -void EnBird_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBird* this = (EnBird*)thisx; - - this->unk_1B4 += this->unk_1B8; - this->actionFunc(this, globalCtx); -} - -void EnBird_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBird* this = (EnBird*)thisx; - - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); -} diff --git a/src/overlays/actors/ovl_En_Bird/z_en_bird.cpp b/src/overlays/actors/ovl_En_Bird/z_en_bird.cpp new file mode 100644 index 000000000..5c187dd4e --- /dev/null +++ b/src/overlays/actors/ovl_En_Bird/z_en_bird.cpp @@ -0,0 +1,138 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BIRD_Z_EN_BIRD_C +#include "actor_common.h" +/* + * File: z_en_bird.c + * Overlay: ovl_En_Bird + * Description: An unused brown bird + */ + +#include "z_en_bird.h" +#include "objects/object_bird/object_bird.h" +#include "def/sinf.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void EnBird_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBird_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBird_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBird_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809C1E00(EnBird* pthis, s16 params); +void func_809C1E40(EnBird* pthis, GlobalContext* globalCtx); +void func_809C1D60(EnBird* pthis, GlobalContext* globalCtx); +void func_809C1CAC(EnBird* pthis, s16 params); + +ActorInit En_Bird_InitVars = { + ACTOR_EN_BIRD, + ACTORCAT_PROP, + FLAGS, + OBJECT_BIRD, + sizeof(EnBird), + (ActorFunc)EnBird_Init, + (ActorFunc)EnBird_Destroy, + (ActorFunc)EnBird_Update, + (ActorFunc)EnBird_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), +}; + +void EnBird_SetupAction(EnBird* pthis, EnBirdActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnBird_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBird* pthis = (EnBird*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.01); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBirdSkel, &gBirdFlyAnim, NULL, NULL, 0); + ActorShape_Init(&pthis->actor.shape, 5500, ActorShadow_DrawCircle, 4); + pthis->unk_194 = 0; + pthis->unk_198 = 0; + pthis->unk_1C0 = 0x9C4; + pthis->actor.colChkInfo.mass = 0; + pthis->unk_1A8 = 1.5f; + pthis->unk_1AC = 0.5f; + pthis->unk_1A0 = 0.0f; + pthis->unk_1A4 = 0.0f; + pthis->unk_1B8 = 0.0f; + pthis->unk_1B0 = 40.0f; + pthis->unk_1BC = 70.0f; + func_809C1CAC(pthis, pthis->actor.params); +} + +void EnBird_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_809C1CAC(EnBird* pthis, s16 params) { + f32 frameCount = Animation_GetLastFrame(&gBirdFlyAnim); + f32 playbackSpeed = pthis->unk_19C ? 0.0f : 1.0f; + AnimationHeader* anim = &gBirdFlyAnim; + + pthis->unk_198 = Rand_S16Offset(5, 0x23); + Animation_Change(&pthis->skelAnime, anim, playbackSpeed, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + EnBird_SetupAction(pthis, func_809C1D60); +} + +void func_809C1D60(EnBird* pthis, GlobalContext* globalCtx) { + f32 fVar2 = sinf(pthis->unk_1B4); + + pthis->actor.shape.yOffset = pthis->actor.shape.yOffset + fVar2 * pthis->unk_1A0; + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + + if (pthis->unk_19C != 0) { + pthis->skelAnime.playSpeed = pthis->actor.speedXZ + pthis->actor.speedXZ; + } + + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_198 -= 1; + + if (pthis->unk_198 <= 0) { + func_809C1E00(pthis, pthis->actor.params); + } +} + +void func_809C1E00(EnBird* pthis, s16 params) { + pthis->unk_198 = Rand_S16Offset(0x14, 0x2D); + EnBird_SetupAction(pthis, func_809C1E40); +} + +void func_809C1E40(EnBird* pthis, GlobalContext* globalCtx) { + f32 fVar4 = sinf(pthis->unk_1B4); + + pthis->actor.shape.yOffset += fVar4 * pthis->unk_1A0; + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->unk_1A8, 0.1f, pthis->unk_1AC, 0.0f); + + if (pthis->unk_1B0 < Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) || pthis->unk_198 < 4) { + Math_StepToAngleS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos), + pthis->unk_1C0); + } else { + fVar4 = sinf(pthis->unk_1B4); + pthis->actor.world.rot.y += (s16)(fVar4 * pthis->unk_1A4); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_198 -= 1; + if (pthis->unk_198 < 0) { + func_809C1CAC(pthis, pthis->actor.params); + } +} + +void EnBird_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBird* pthis = (EnBird*)thisx; + + pthis->unk_1B4 += pthis->unk_1B8; + pthis->actionFunc(pthis, globalCtx); +} + +void EnBird_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBird* pthis = (EnBird*)thisx; + + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, NULL); +} diff --git a/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c b/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.cpp similarity index 59% rename from src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c rename to src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.cpp index ed9e691f8..129e86c52 100644 --- a/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c +++ b/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.cpp @@ -22,12 +22,12 @@ void EnBlkobj_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBlkobj_Update(Actor* thisx, GlobalContext* globalCtx); void EnBlkobj_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnBlkobj_Wait(EnBlkobj* this, GlobalContext* globalCtx); -void EnBlkobj_SpawnDarkLink(EnBlkobj* this, GlobalContext* globalCtx); -void EnBlkobj_DarkLinkFight(EnBlkobj* this, GlobalContext* globalCtx); -void EnBlkobj_DoNothing(EnBlkobj* this, GlobalContext* globalCtx); +void EnBlkobj_Wait(EnBlkobj* pthis, GlobalContext* globalCtx); +void EnBlkobj_SpawnDarkLink(EnBlkobj* pthis, GlobalContext* globalCtx); +void EnBlkobj_DarkLinkFight(EnBlkobj* pthis, GlobalContext* globalCtx); +void EnBlkobj_DoNothing(EnBlkobj* pthis, GlobalContext* globalCtx); -const ActorInit En_Blkobj_InitVars = { +ActorInit En_Blkobj_InitVars = { ACTOR_EN_BLKOBJ, ACTORCAT_PROP, FLAGS, @@ -56,83 +56,83 @@ static Gfx sSetupXluDL[] = { gsSPEndDisplayList(), }; -void EnBlkobj_SetupAction(EnBlkobj* this, EnBlkobjActionFunc actionFunc) { - this->actionFunc = actionFunc; - this->timer = 0; +void EnBlkobj_SetupAction(EnBlkobj* pthis, EnBlkobjActionFunc actionFunc) { + pthis->actionFunc = actionFunc; + pthis->timer = 0; } void EnBlkobj_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnBlkobj* this = (EnBlkobj*)thisx; + EnBlkobj* pthis = (EnBlkobj*)thisx; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->alpha = 255; - EnBlkobj_SetupAction(this, EnBlkobj_DoNothing); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + if (Flags_GetClear(globalCtx, pthis->dyna.actor.room)) { + pthis->alpha = 255; + EnBlkobj_SetupAction(pthis, EnBlkobj_DoNothing); } else { CollisionHeader_GetVirtual(&gIllusionRoomCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - EnBlkobj_SetupAction(this, EnBlkobj_Wait); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + EnBlkobj_SetupAction(pthis, EnBlkobj_Wait); } } void EnBlkobj_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnBlkobj* this = (EnBlkobj*)thisx; + EnBlkobj* pthis = (EnBlkobj*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void EnBlkobj_Wait(EnBlkobj* this, GlobalContext* globalCtx) { +void EnBlkobj_Wait(EnBlkobj* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->dyna.actor.xzDistToPlayer < 120.0f) { - EnBlkobj_SetupAction(this, EnBlkobj_SpawnDarkLink); + if (pthis->dyna.actor.xzDistToPlayer < 120.0f) { + EnBlkobj_SetupAction(pthis, EnBlkobj_SpawnDarkLink); } player->stateFlags2 |= 0x04000000; } -void EnBlkobj_SpawnDarkLink(EnBlkobj* this, GlobalContext* globalCtx) { - if (!(this->dyna.actor.flags & ACTOR_FLAG_UNCULLED)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TORCH2, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, this->dyna.actor.yawTowardsPlayer, 0, +void EnBlkobj_SpawnDarkLink(EnBlkobj* pthis, GlobalContext* globalCtx) { + if (!(pthis->dyna.actor.flags & ACTOR_FLAG_UNCULLED)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TORCH2, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, pthis->dyna.actor.yawTowardsPlayer, 0, 0); - EnBlkobj_SetupAction(this, EnBlkobj_DarkLinkFight); + EnBlkobj_SetupAction(pthis, EnBlkobj_DarkLinkFight); } } -void EnBlkobj_DarkLinkFight(EnBlkobj* this, GlobalContext* globalCtx) { +void EnBlkobj_DarkLinkFight(EnBlkobj* pthis, GlobalContext* globalCtx) { s32 alphaMod; - if (this->timer == 0) { + if (pthis->timer == 0) { if (Actor_Find(&globalCtx->actorCtx, ACTOR_EN_TORCH2, ACTORCAT_BOSS) == NULL) { - Flags_SetClear(globalCtx, this->dyna.actor.room); - this->timer++; + Flags_SetClear(globalCtx, pthis->dyna.actor.room); + pthis->timer++; } - } else if (this->timer++ > 100) { - alphaMod = (this->timer - 100) >> 2; + } else if (pthis->timer++ > 100) { + alphaMod = (pthis->timer - 100) >> 2; if (alphaMod > 5) { alphaMod = 5; } - this->alpha += alphaMod; - if (this->alpha > 255) { - this->alpha = 255; - EnBlkobj_SetupAction(this, EnBlkobj_DoNothing); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + pthis->alpha += alphaMod; + if (pthis->alpha > 255) { + pthis->alpha = 255; + EnBlkobj_SetupAction(pthis, EnBlkobj_DoNothing); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } } } -void EnBlkobj_DoNothing(EnBlkobj* this, GlobalContext* globalCtx) { +void EnBlkobj_DoNothing(EnBlkobj* pthis, GlobalContext* globalCtx) { } void EnBlkobj_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnBlkobj* this = (EnBlkobj*)thisx; + EnBlkobj* pthis = (EnBlkobj*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void EnBlkobj_DrawAlpha(GlobalContext* globalCtx, Gfx* dList, s32 alpha) { @@ -155,7 +155,7 @@ void EnBlkobj_DrawAlpha(GlobalContext* globalCtx, Gfx* dList, s32 alpha) { void EnBlkobj_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnBlkobj* this = (EnBlkobj*)thisx; + EnBlkobj* pthis = (EnBlkobj*)thisx; s32 illusionAlpha; u32 gameplayFrames; @@ -170,10 +170,10 @@ void EnBlkobj_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_blkobj.c", 363), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->alpha != 0) { - EnBlkobj_DrawAlpha(globalCtx, gIllusionRoomNormalDL, this->alpha); + if (pthis->alpha != 0) { + EnBlkobj_DrawAlpha(globalCtx, gIllusionRoomNormalDL, pthis->alpha); } - illusionAlpha = 255 - this->alpha; + illusionAlpha = 255 - pthis->alpha; if (illusionAlpha != 0) { EnBlkobj_DrawAlpha(globalCtx, gIllusionRoomIllusionDL, illusionAlpha); } diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.cpp similarity index 64% rename from src/overlays/actors/ovl_En_Bom/z_en_bom.c rename to src/overlays/actors/ovl_En_Bom/z_en_bom.cpp index 85f602592..db55a6602 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.cpp @@ -26,10 +26,10 @@ void EnBom_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBom_Update(Actor* thisx, GlobalContext* globalCtx); void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnBom_Move(EnBom* this, GlobalContext* globalCtx); -void EnBom_WaitForRelease(EnBom* this, GlobalContext* globalCtx); +void EnBom_Move(EnBom* pthis, GlobalContext* globalCtx); +void EnBom_WaitForRelease(EnBom* pthis, GlobalContext* globalCtx); -const ActorInit En_Bom_InitVars = { +ActorInit En_Bom_InitVars = { ACTOR_EN_BOM, ACTORCAT_EXPLOSIVE, FLAGS, @@ -94,100 +94,100 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_STOP), }; -void EnBom_SetupAction(EnBom* this, EnBomActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnBom_SetupAction(EnBom* pthis, EnBomActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBom* this = (EnBom*)thisx; + EnBom* pthis = (EnBom*)thisx; Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 700.0f, ActorShadow_DrawCircle, 16.0f); thisx->colChkInfo.mass = 200; thisx->colChkInfo.cylRadius = 5; thisx->colChkInfo.cylHeight = 10; - this->timer = 70; - this->flashSpeedScale = 7; - Collider_InitCylinder(globalCtx, &this->bombCollider); - Collider_InitJntSph(globalCtx, &this->explosionCollider); - Collider_SetCylinder(globalCtx, &this->bombCollider, thisx, &sCylinderInit); - Collider_SetJntSph(globalCtx, &this->explosionCollider, thisx, &sJntSphInit, &this->explosionColliderItems[0]); - this->explosionColliderItems[0].info.toucher.damage += (thisx->shape.rot.z & 0xFF00) >> 8; + pthis->timer = 70; + pthis->flashSpeedScale = 7; + Collider_InitCylinder(globalCtx, &pthis->bombCollider); + Collider_InitJntSph(globalCtx, &pthis->explosionCollider); + Collider_SetCylinder(globalCtx, &pthis->bombCollider, thisx, &sCylinderInit); + Collider_SetJntSph(globalCtx, &pthis->explosionCollider, thisx, &sJntSphInit, &pthis->explosionColliderItems[0]); + pthis->explosionColliderItems[0].info.toucher.damage += (thisx->shape.rot.z & 0xFF00) >> 8; thisx->shape.rot.z &= 0xFF; if (thisx->shape.rot.z & 0x80) { thisx->shape.rot.z |= 0xFF00; } - EnBom_SetupAction(this, EnBom_Move); + EnBom_SetupAction(pthis, EnBom_Move); } void EnBom_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBom* this = (EnBom*)thisx; + EnBom* pthis = (EnBom*)thisx; - Collider_DestroyJntSph(globalCtx, &this->explosionCollider); - Collider_DestroyCylinder(globalCtx, &this->bombCollider); + Collider_DestroyJntSph(globalCtx, &pthis->explosionCollider); + Collider_DestroyCylinder(globalCtx, &pthis->bombCollider); } -void EnBom_Move(EnBom* this, GlobalContext* globalCtx) { +void EnBom_Move(EnBom* pthis, GlobalContext* globalCtx) { // if bomb has a parent actor, the bomb hasnt been released yet - if (Actor_HasParent(&this->actor, globalCtx)) { - EnBom_SetupAction(this, EnBom_WaitForRelease); - this->actor.room = -1; + if (Actor_HasParent(&pthis->actor, globalCtx)) { + EnBom_SetupAction(pthis, EnBom_WaitForRelease); + pthis->actor.room = -1; return; } - if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { - this->actor.velocity.y = -this->actor.velocity.y; + if ((pthis->actor.velocity.y > 0.0f) && (pthis->actor.bgCheckFlags & 0x10)) { + pthis->actor.velocity.y = -pthis->actor.velocity.y; } // rebound bomb off the wall it hits - if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { - if (ABS((s16)(this->actor.wallYaw - this->actor.world.rot.y)) > 0x4000) { - this->actor.world.rot.y = ((this->actor.wallYaw - this->actor.world.rot.y) + this->actor.wallYaw) - 0x8000; + if ((pthis->actor.speedXZ != 0.0f) && (pthis->actor.bgCheckFlags & 8)) { + if (ABS((s16)(pthis->actor.wallYaw - pthis->actor.world.rot.y)) > 0x4000) { + pthis->actor.world.rot.y = ((pthis->actor.wallYaw - pthis->actor.world.rot.y) + pthis->actor.wallYaw) - 0x8000; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_BOUND); - Actor_MoveForward(&this->actor); - this->actor.speedXZ *= 0.7f; - this->actor.bgCheckFlags &= ~8; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BOMB_BOUND); + Actor_MoveForward(&pthis->actor); + pthis->actor.speedXZ *= 0.7f; + pthis->actor.bgCheckFlags &= ~8; } - if (!(this->actor.bgCheckFlags & 1)) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.08f); + if (!(pthis->actor.bgCheckFlags & 1)) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.08f); } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); - if ((this->actor.bgCheckFlags & 2) && (this->actor.velocity.y < -3.0f)) { - func_8002F850(globalCtx, &this->actor); - this->actor.velocity.y *= -0.3f; - this->actor.bgCheckFlags &= ~2; - } else if (this->timer >= 4) { - func_8002F580(&this->actor, globalCtx); + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 1.0f); + if ((pthis->actor.bgCheckFlags & 2) && (pthis->actor.velocity.y < -3.0f)) { + func_8002F850(globalCtx, &pthis->actor); + pthis->actor.velocity.y *= -0.3f; + pthis->actor.bgCheckFlags &= ~2; + } else if (pthis->timer >= 4) { + func_8002F580(&pthis->actor, globalCtx); } } - Actor_MoveForward(&this->actor); + Actor_MoveForward(&pthis->actor); } -void EnBom_WaitForRelease(EnBom* this, GlobalContext* globalCtx) { +void EnBom_WaitForRelease(EnBom* pthis, GlobalContext* globalCtx) { // if parent is NULL bomb has been released - if (Actor_HasNoParent(&this->actor, globalCtx)) { - EnBom_SetupAction(this, EnBom_Move); - EnBom_Move(this, globalCtx); + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + EnBom_SetupAction(pthis, EnBom_Move); + EnBom_Move(pthis, globalCtx); } } -void EnBom_Explode(EnBom* this, GlobalContext* globalCtx) { +void EnBom_Explode(EnBom* pthis, GlobalContext* globalCtx) { Player* player; - if (this->explosionCollider.elements[0].dim.modelSphere.radius == 0) { - this->actor.flags |= ACTOR_FLAG_5; - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + if (pthis->explosionCollider.elements[0].dim.modelSphere.radius == 0) { + pthis->actor.flags |= ACTOR_FLAG_5; + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); } - this->explosionCollider.elements[0].dim.worldSphere.radius += this->actor.shape.rot.z + 8; + pthis->explosionCollider.elements[0].dim.worldSphere.radius += pthis->actor.shape.rot.z + 8; - if (this->actor.params == BOMB_EXPLOSION) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->explosionCollider.base); + if (pthis->actor.params == BOMB_EXPLOSION) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->explosionCollider.base); } if (globalCtx->envCtx.adjLight1Color[0] != 0) { @@ -214,17 +214,17 @@ void EnBom_Explode(EnBom* this, GlobalContext* globalCtx) { globalCtx->envCtx.adjAmbientColor[2] -= 25; } - if (this->timer == 0) { + if (pthis->timer == 0) { player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x800) && (player->heldActor == &this->actor)) { + if ((player->stateFlags1 & 0x800) && (player->heldActor == &pthis->actor)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; player->stateFlags1 &= ~0x800; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } @@ -237,29 +237,29 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx2) { Color_RGBA8 dustColor = { 255, 255, 255, 255 }; s32 pad; GlobalContext* globalCtx = globalCtx2; - EnBom* this = (EnBom*)thisx; + EnBom* pthis = (EnBom*)thisx; thisx->gravity = -1.2f; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - if (this->timer == 67) { + if (pthis->timer == 67) { Audio_PlayActorSound2(thisx, NA_SE_PL_TAKE_OUT_SHIELD); Actor_SetScale(thisx, 0.01f); } if ((thisx->xzDistToPlayer >= 20.0f) || (ABS(thisx->yDistToPlayer) >= 80.0f)) { - this->bumpOn = true; + pthis->bumpOn = true; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, thisx, 5.0f, 10.0f, 15.0f, 0x1F); if (thisx->params == BOMB_BODY) { - if (this->timer < 63) { + if (pthis->timer < 63) { dustAccel.y = 0.2f; // spawn spark effect on even frames @@ -275,15 +275,15 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx2) { func_8002829C(globalCtx, &effPos, &effVelocity, &dustAccel, &dustColor, &dustColor, 50, 5); } - if ((this->bombCollider.base.acFlags & AC_HIT) || ((this->bombCollider.base.ocFlags1 & OC1_HIT) && - (this->bombCollider.base.oc->category == ACTORCAT_ENEMY))) { - this->timer = 0; + if ((pthis->bombCollider.base.acFlags & AC_HIT) || ((pthis->bombCollider.base.ocFlags1 & OC1_HIT) && + (pthis->bombCollider.base.oc->category == ACTORCAT_ENEMY))) { + pthis->timer = 0; thisx->shape.rot.z = 0; } else { // if a lit stick touches the bomb, set timer to 100 - // these bombs never have a timer over 70, so this isnt used - if ((this->timer > 100) && Player_IsBurningStickInRange(globalCtx, &thisx->world.pos, 30.0f, 50.0f)) { - this->timer = 100; + // these bombs never have a timer over 70, so pthis isnt used + if ((pthis->timer > 100) && Player_IsBurningStickInRange(globalCtx, &thisx->world.pos, 30.0f, 50.0f)) { + pthis->timer = 100; } } @@ -292,22 +292,22 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx2) { effPos.y += 10.0f; // double bomb flash speed and adjust red color at certain times during the countdown - if ((this->timer == 3) || (this->timer == 20) || (this->timer == 40)) { + if ((pthis->timer == 3) || (pthis->timer == 20) || (pthis->timer == 40)) { thisx->shape.rot.z = 0; - this->flashSpeedScale >>= 1; + pthis->flashSpeedScale >>= 1; } - if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { - Math_SmoothStepToF(&this->flashIntensity, 140.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); + if ((pthis->timer < 100) && ((pthis->timer & (pthis->flashSpeedScale + 1)) != 0)) { + Math_SmoothStepToF(&pthis->flashIntensity, 140.0f, 1.0f, 140.0f / pthis->flashSpeedScale, 0.0f); } else { - Math_SmoothStepToF(&this->flashIntensity, 0.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); + Math_SmoothStepToF(&pthis->flashIntensity, 0.0f, 1.0f, 140.0f / pthis->flashSpeedScale, 0.0f); } - if (this->timer < 3) { + if (pthis->timer < 3) { Actor_SetScale(thisx, thisx->scale.x + 0.002f); } - if (this->timer == 0) { + if (pthis->timer == 0) { effPos = thisx->world.pos; effPos.y += 10.0f; @@ -333,23 +333,23 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx2) { Camera_AddQuake(&globalCtx->mainCamera, 2, 0xB, 8); thisx->params = BOMB_EXPLOSION; - this->timer = 10; + pthis->timer = 10; thisx->flags |= ACTOR_FLAG_5; - EnBom_SetupAction(this, EnBom_Explode); + EnBom_SetupAction(pthis, EnBom_Explode); } } Actor_SetFocus(thisx, 20.0f); if (thisx->params <= BOMB_BODY) { - Collider_UpdateCylinder(thisx, &this->bombCollider); + Collider_UpdateCylinder(thisx, &pthis->bombCollider); // if link is not holding the bomb anymore and bump conditions are met, subscribe to OC - if (!Actor_HasParent(thisx, globalCtx) && this->bumpOn) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base); + if (!Actor_HasParent(thisx, globalCtx) && pthis->bumpOn) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bombCollider.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bombCollider.base); } if ((thisx->scale.x >= 0.01f) && (thisx->params != BOMB_EXPLOSION)) { @@ -368,7 +368,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx2) { void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnBom* this = (EnBom*)thisx; + EnBom* pthis = (EnBom*)thisx; if (1) {} @@ -386,10 +386,10 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bom.c", 934), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->flashIntensity, 0, 40, 255); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, (s16)this->flashIntensity, 0, 40, 255); + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->flashIntensity, 0, 40, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, (s16)pthis->flashIntensity, 0, 40, 255); gSPDisplayList(POLY_OPA_DISP++, gBombBodyDL); - Collider_UpdateSpheres(0, &this->explosionCollider); + Collider_UpdateSpheres(0, &pthis->explosionCollider); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bom.c", 951); diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c deleted file mode 100644 index cecff8c9b..000000000 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ /dev/null @@ -1,547 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOM_BOWL_MAN_Z_EN_BOM_BOWL_MAN_C -#include "actor_common.h" -#include "z_en_bom_bowl_man.h" -#include "vt.h" -#include "overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h" -#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" -#include "objects/object_bg/object_bg.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_27) - -typedef enum { - /* 0 */ CHU_GIRL_EYES_ASLEEP, - /* 1 */ CHU_GIRL_EYES_OPEN_SLOWLY, - /* 2 */ CHU_GIRL_EYES_BLINK_RAPIDLY, - /* 3 */ CHU_GIRL_EYES_AWAKE -} BombchuGirlEyeMode; - -void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBomBowMan_SetupWaitAsleep(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_WaitAsleep(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_TalkAsleep(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_WakeUp(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_BlinkAwake(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_CheckBeatenDC(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_WaitNotBeatenDC(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_TalkNotBeatenDC(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_SetupRunGame(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_RunGame(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowlMan_HandlePlayChoice(EnBomBowlMan* this, GlobalContext* globalCtx); -void func_809C41FC(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_SetupChooseShowPrize(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowMan_ChooseShowPrize(EnBomBowlMan* this, GlobalContext* globalCtx); -void EnBomBowlMan_BeginPlayGame(EnBomBowlMan* this, GlobalContext* globalCtx); - -const ActorInit En_Bom_Bowl_Man_InitVars = { - ACTOR_EN_BOM_BOWL_MAN, - ACTORCAT_NPC, - FLAGS, - OBJECT_BG, - sizeof(EnBomBowlMan), - (ActorFunc)EnBomBowlMan_Init, - (ActorFunc)EnBomBowlMan_Destroy, - (ActorFunc)EnBomBowlMan_Update, - (ActorFunc)EnBomBowlMan_Draw, -}; - -void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx2) { - static f32 cuccoColliderDims[][3] = { { 16.0f, 46.0f, 0.0f }, { 36.0f, 56.0f, 0.0f } }; - static Vec3f cuccoSpawnPos[] = { { 60, -60, -430 }, { 0, -120, -620 } }; - static f32 cuccoScales[] = { 0.01f, 0.03f }; - EnBomBowlMan* this = (EnBomBowlMan*)thisx; - EnSyatekiNiw* cucco; - s32 i; - GlobalContext* globalCtx = globalCtx2; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gChuGirlSkel, &gChuGirlNoddingOffAnim, this->jointTable, - this->morphTable, 11); - // "☆ Man, my shoulders hurt~ ☆" - osSyncPrintf(VT_FGCOL(GREEN) "☆ もー 肩こっちゃうよねぇ〜 \t\t ☆ \n" VT_RST); - // "☆ Isn't there some sort of job that will pay better and be more relaxing? ☆ %d" - osSyncPrintf(VT_FGCOL(GREEN) "☆ もっとラクしてもうかるバイトないかしら? ☆ %d\n" VT_RST, - globalCtx->bombchuBowlingStatus); - this->posCopy = this->actor.world.pos; - this->actor.shape.yOffset = -60.0f; - Actor_SetScale(&this->actor, 0.013f); - - for (i = 0; i < 2; i++) { - cucco = (EnSyatekiNiw*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SYATEKI_NIW, cuccoSpawnPos[i].x, - cuccoSpawnPos[i].y, cuccoSpawnPos[i].z, 0, 0, 0, 1); - - if (cucco != NULL) { - cucco->unk_2F4 = cuccoScales[i]; - cucco->collider.dim.radius = (s16)cuccoColliderDims[i][0]; - cucco->collider.dim.height = (s16)cuccoColliderDims[i][1]; - } - } - - this->prizeSelect = (s16)Rand_ZeroFloat(4.99f); - this->actor.targetMode = 1; - this->actionFunc = EnBomBowMan_SetupWaitAsleep; -} - -void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnBomBowMan_SetupWaitAsleep(EnBomBowlMan* this, GlobalContext* globalCtx) { - this->frameCount = (f32)Animation_GetLastFrame(&gChuGirlNoddingOffAnim); - Animation_Change(&this->skelAnime, &gChuGirlNoddingOffAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, -10.0f); - this->actor.textId = 0xC0; - this->dialogState = TEXT_STATE_EVENT; - this->actionFunc = EnBomBowMan_WaitAsleep; -} - -void EnBomBowMan_WaitAsleep(EnBomBowlMan* this, GlobalContext* globalCtx) { - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnBomBowMan_TalkAsleep; - } else { - yawDiff = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); - - if (!(this->actor.xzDistToPlayer > 120.0f) && (yawDiff < 0x4300)) { - func_8002F2CC(&this->actor, globalCtx, 120.0f); - } - } -} - -void EnBomBowMan_TalkAsleep(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actionFunc = EnBomBowMan_WakeUp; - } -} - -void EnBomBowMan_WakeUp(EnBomBowlMan* this, GlobalContext* globalCtx) { - this->frameCount = (f32)Animation_GetLastFrame(&gChuGirlWakeUpAnim); - Animation_Change(&this->skelAnime, &gChuGirlWakeUpAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_ONCE, -10.0f); - this->eyeMode = CHU_GIRL_EYES_OPEN_SLOWLY; - this->actionFunc = EnBomBowMan_BlinkAwake; -} - -void EnBomBowMan_BlinkAwake(EnBomBowlMan* this, GlobalContext* globalCtx) { - f32 frameCount = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (frameCount == 30.0f) { - this->dialogState = TEXT_STATE_EVENT; - - // Check for beaten Dodongo's Cavern - if ((gSaveContext.eventChkInf[2] & 0x20) || BREG(2)) { - this->actor.textId = 0xBF; - } else { - this->actor.textId = 0x7058; - } - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - - if ((this->eyeTextureIndex == 0) && (this->eyeMode == CHU_GIRL_EYES_BLINK_RAPIDLY) && (this->blinkTimer == 0)) { - // Blink twice, then move on - this->eyeTextureIndex = 2; - this->blinkCount++; - if (this->blinkCount >= 3) { - this->actionFunc = EnBomBowMan_CheckBeatenDC; - } - } -} - -void EnBomBowMan_CheckBeatenDC(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->frameCount = (f32)Animation_GetLastFrame(&gChuGirlLeanOverCounterAnim); - Animation_Change(&this->skelAnime, &gChuGirlLeanOverCounterAnim, 1.0f, 0.0f, this->frameCount, ANIMMODE_LOOP, - -10.0f); - this->eyeMode = CHU_GIRL_EYES_AWAKE; - this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - - // Check for beaten Dodongo's Cavern - if (!((gSaveContext.eventChkInf[2] & 0x20) || BREG(2))) { - this->actionFunc = EnBomBowMan_WaitNotBeatenDC; - } else { - this->actor.textId = 0x18; - this->dialogState = TEXT_STATE_CHOICE; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->actionFunc = EnBomBowlMan_HandlePlayChoice; - } - } -} - -void EnBomBowMan_WaitNotBeatenDC(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnBomBowMan_TalkNotBeatenDC; - } else { - func_8002F2CC(&this->actor, globalCtx, 120.0f); - } -} - -void EnBomBowMan_TalkNotBeatenDC(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = EnBomBowMan_WaitNotBeatenDC; - } -} - -void EnBomBowMan_SetupRunGame(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->minigamePlayStatus == 0) { - if (!this->startedPlaying) { - this->actor.textId = 0x18; - } else { - this->actor.textId = 0x1A; - } - - this->dialogState = TEXT_STATE_CHOICE; - } else { - this->actor.textId = 0x19; - this->dialogState = TEXT_STATE_EVENT; - } - - this->actionFunc = EnBomBowMan_RunGame; -} - -void EnBomBowMan_RunGame(EnBomBowlMan* this, GlobalContext* globalCtx) { - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - - if (BREG(3)) { - osSyncPrintf(VT_FGCOL(RED) "☆ game_play->bomchu_game_flag ☆ %d\n" VT_RST, globalCtx->bombchuBowlingStatus); - // "HOW'S THE FIRST WALL DOING?" - osSyncPrintf(VT_FGCOL(RED) "☆ 壁1の状態どう? ☆ %d\n" VT_RST, this->wallStatus[0]); - // "HOW'S THE SECOND WALL DOING?" - osSyncPrintf(VT_FGCOL(RED) "☆ 壁2の状態どう? ☆ %d\n" VT_RST, this->wallStatus[1]); - // "HOLE INFORMATION" - osSyncPrintf(VT_FGCOL(RED) "☆ 穴情報\t ☆ %d\n" VT_RST, this->bowlPit->status); - osSyncPrintf("\n\n"); - } - - this->gameResult = 0; - - if (this->bowlPit != NULL) { - if ((this->wallStatus[0] != 1) && (this->wallStatus[1] != 1) && (this->bowlPit->status == 2)) { - this->gameResult = 1; // Won - this->bowlPit->status = 0; - // "Center HIT!" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 中央HIT!!!! ☆☆☆☆☆ \n" VT_RST); - } - - if ((globalCtx->bombchuBowlingStatus == -1) && - (globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].length == 0) && (this->bowlPit->status == 0) && - (this->wallStatus[0] != 1) && (this->wallStatus[1] != 1)) { - this->gameResult = 2; // Lost - // "Bombchu lost" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ボムチュウ消化 ☆☆☆☆☆ \n" VT_RST); - } - } - - if (this->gameResult != 0) { // won or lost - this->actor.textId = 0x1A; - this->dialogState = TEXT_STATE_CHOICE; - this->minigamePlayStatus = 0; - - if ((this->exItem != NULL) && (this->exItem->actor.update != NULL)) { - this->exItem->killItem = true; - this->exItem = NULL; - } - - globalCtx->bombchuBowlingStatus = 0; - this->playingAgain = true; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - - if (this->gameResult == 2) { - func_8002DF54(globalCtx, NULL, 8); - } - this->actionFunc = EnBomBowlMan_HandlePlayChoice; - } else { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->minigamePlayStatus == 0) { - this->actionFunc = EnBomBowlMan_HandlePlayChoice; - } else { - this->actionFunc = func_809C41FC; - } - } else { - yawDiff = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); - - if (!(this->actor.xzDistToPlayer > 120.0f) && (yawDiff < 0x4300)) { - func_8002F2CC(&this->actor, globalCtx, 120.0f); - } - } - } -} - -void EnBomBowlMan_HandlePlayChoice(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // Yes - if (gSaveContext.rupees >= 30) { - Rupees_ChangeBy(-30); - this->minigamePlayStatus = 1; - this->wallStatus[0] = this->wallStatus[1] = 0; - globalCtx->bombchuBowlingStatus = 10; - Flags_SetSwitch(globalCtx, 0x38); - - if (!this->startedPlaying && !this->playingAgain) { - this->actor.textId = 0x19; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - this->actionFunc = func_809C41FC; - } else { - this->actor.textId = 0x1B; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - OnePointCutscene_Init(globalCtx, 8010, -99, NULL, MAIN_CAM); - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = EnBomBowMan_SetupChooseShowPrize; - } - } else { - this->playingAgain = false; - this->actor.textId = 0x85; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - this->actionFunc = func_809C41FC; - } - break; - - case 1: // No - this->playingAgain = false; - this->actor.textId = 0x2D; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - this->actionFunc = func_809C41FC; - } - } -} - -void func_809C41FC(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - - if (((this->actor.textId == 0x2D) || (this->actor.textId == 0x85)) && Flags_GetSwitch(globalCtx, 0x38)) { - Flags_UnsetSwitch(globalCtx, 0x38); - } - - if (this->minigamePlayStatus == 1) { - this->actor.textId = 0x1B; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - OnePointCutscene_Init(globalCtx, 8010, -99, NULL, MAIN_CAM); - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = EnBomBowMan_SetupChooseShowPrize; - } else { - if (this->gameResult == 2) { - func_8002DF54(globalCtx, NULL, 7); - } - this->actionFunc = EnBomBowMan_SetupRunGame; - } - } -} - -void EnBomBowMan_SetupChooseShowPrize(EnBomBowlMan* this, GlobalContext* globalCtx) { - Vec3f accel = { 0.0f, 0.1f, 0.0f }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - - SkelAnime_Update(&this->skelAnime); - - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - pos.x = 148.0f; - pos.y = 40.0f; - pos.z = 300.0f; - EffectSsBomb2_SpawnLayered(globalCtx, &pos, &velocity, &accel, 50, 15); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_GOODS_APPEAR); - this->prizeRevealTimer = 10; - this->actionFunc = EnBomBowMan_ChooseShowPrize; - } -} - -static Vec3f sPrizePosOffset[] = { - { 0.0f, 22.0f, 0.0f }, { 0.0f, 22.0f, 0.0f }, { 0.0f, 8.0f, 0.0f }, { 0.0f, 9.0f, 0.0f }, { 0.0f, -2.0f, 0.0f }, -}; - -static s16 sPrizeRot[] = { 0x4268, 0x4268, -0x03E8, 0x0000, 0x4268, 0x0000 }; - -void EnBomBowMan_ChooseShowPrize(EnBomBowlMan* this, GlobalContext* globalCtx) { - s16 prizeTemp; - s32 pad; - - SkelAnime_Update(&this->skelAnime); - - if (this->prizeRevealTimer == 0) { - switch (this->prizeSelect) { - case 0: - prizeTemp = EXITEM_BOMB_BAG_BOWLING; - if (gSaveContext.itemGetInf[1] & 2) { - prizeTemp = EXITEM_PURPLE_RUPEE_BOWLING; - } - break; - case 1: - prizeTemp = EXITEM_PURPLE_RUPEE_BOWLING; - break; - case 2: - prizeTemp = EXITEM_BOMBCHUS_BOWLING; - break; - case 3: - prizeTemp = EXITEM_HEART_PIECE_BOWLING; - if (gSaveContext.itemGetInf[1] & 4) { - prizeTemp = EXITEM_PURPLE_RUPEE_BOWLING; - } - break; - case 4: - prizeTemp = EXITEM_BOMBS_BOWLING; - break; - } - - this->prizeIndex = prizeTemp; - - if (BREG(7)) { - this->prizeIndex = BREG(7) - 1; - } - - this->exItem = (EnExItem*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_ITEM, - sPrizePosOffset[this->prizeIndex].x + 148.0f, - sPrizePosOffset[this->prizeIndex].y + 40.0f, - sPrizePosOffset[this->prizeIndex].z + 300.0f, 0, - sPrizeRot[this->prizeIndex], 0, this->prizeIndex + EXITEM_COUNTER); - - if (!this->startedPlaying) { - this->bowlPit = (EnBomBowlPit*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, - ACTOR_EN_BOM_BOWL_PIT, 0.0f, 90.0f, -860.0f, 0, 0, 0, 0); - if (this->bowlPit != NULL) { - this->bowlPit->prizeIndex = this->prizeIndex; - } - } else { - this->bowlPit->prizeIndex = this->prizeIndex; - } - - this->bowlPit->start = 1; - this->minigamePlayStatus = 2; - this->actor.textId = 0x405A; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - - // Cycle through prizes in order - this->prizeSelect++; - if (this->prizeSelect >= 5) { - this->prizeSelect = 0; - } - this->actionFunc = EnBomBowlMan_BeginPlayGame; - } -} - -void EnBomBowlMan_BeginPlayGame(EnBomBowlMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if ((Message_GetState(&globalCtx->msgCtx) == this->dialogState) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - this->startedPlaying = true; - - if (BREG(2)) { - BREG(2) = 0; - } - - // "Wow" - osSyncPrintf(VT_FGCOL(YELLOW) "☆ わー ☆ %d\n" VT_RST, globalCtx->bombchuBowlingStatus); - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = EnBomBowMan_SetupRunGame; - } -} - -void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBomBowlMan* this = (EnBomBowlMan*)thisx; - - this->timer++; - this->actor.focus.pos.y = 60.0f; - Actor_SetFocus(&this->actor, 60.0f); - - switch (this->eyeMode) { - case CHU_GIRL_EYES_ASLEEP: - this->eyeTextureIndex = 2; - break; - case CHU_GIRL_EYES_OPEN_SLOWLY: - if (this->eyeTextureIndex > 0) { - this->eyeTextureIndex--; - } else { - this->blinkTimer = 30; - this->eyeMode = CHU_GIRL_EYES_BLINK_RAPIDLY; - } - break; - case CHU_GIRL_EYES_BLINK_RAPIDLY: - if ((this->blinkTimer == 0) && (this->eyeTextureIndex > 0)) { - this->eyeTextureIndex--; - } - break; - default: - if (this->blinkTimer == 0) { - this->eyeTextureIndex++; - if (this->eyeTextureIndex >= 3) { - this->eyeTextureIndex = 0; - this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - } - } - - func_80038290(globalCtx, &this->actor, &this->unk_218, &this->unk_224, this->actor.focus.pos); - break; - } - - DECR(this->prizeRevealTimer); - DECR(this->blinkTimer); - - this->actionFunc(this, globalCtx); -} - -s32 EnBomBowlMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnBomBowlMan* this = (EnBomBowlMan*)thisx; - - if (limbIndex == 4) { // head - rot->x += this->unk_218.y; - rot->z += this->unk_218.z; - } - - return false; -} - -void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gChuGirlEyeOpenTex, gChuGirlEyeHalfTex, gChuGirlEyeClosedTex }; - EnBomBowlMan* this = (EnBomBowlMan*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_bowl_man.c", 907); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTextureIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnBomBowlMan_OverrideLimbDraw, NULL, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_bowl_man.c", 923); -} diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.cpp b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.cpp new file mode 100644 index 000000000..2fce5e787 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.cpp @@ -0,0 +1,547 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOM_BOWL_MAN_Z_EN_BOM_BOWL_MAN_C +#include "actor_common.h" +#include "z_en_bom_bowl_man.h" +#include "vt.h" +#include "overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h" +#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" +#include "objects/object_bg/object_bg.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_27) + +typedef enum { + /* 0 */ CHU_GIRL_EYES_ASLEEP, + /* 1 */ CHU_GIRL_EYES_OPEN_SLOWLY, + /* 2 */ CHU_GIRL_EYES_BLINK_RAPIDLY, + /* 3 */ CHU_GIRL_EYES_AWAKE +} BombchuGirlEyeMode; + +void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBomBowMan_SetupWaitAsleep(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_WaitAsleep(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_TalkAsleep(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_WakeUp(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_BlinkAwake(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_CheckBeatenDC(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_WaitNotBeatenDC(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_TalkNotBeatenDC(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_SetupRunGame(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_RunGame(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowlMan_HandlePlayChoice(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void func_809C41FC(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_SetupChooseShowPrize(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowMan_ChooseShowPrize(EnBomBowlMan* pthis, GlobalContext* globalCtx); +void EnBomBowlMan_BeginPlayGame(EnBomBowlMan* pthis, GlobalContext* globalCtx); + +ActorInit En_Bom_Bowl_Man_InitVars = { + ACTOR_EN_BOM_BOWL_MAN, + ACTORCAT_NPC, + FLAGS, + OBJECT_BG, + sizeof(EnBomBowlMan), + (ActorFunc)EnBomBowlMan_Init, + (ActorFunc)EnBomBowlMan_Destroy, + (ActorFunc)EnBomBowlMan_Update, + (ActorFunc)EnBomBowlMan_Draw, +}; + +void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx2) { + static f32 cuccoColliderDims[][3] = { { 16.0f, 46.0f, 0.0f }, { 36.0f, 56.0f, 0.0f } }; + static Vec3f cuccoSpawnPos[] = { { 60, -60, -430 }, { 0, -120, -620 } }; + static f32 cuccoScales[] = { 0.01f, 0.03f }; + EnBomBowlMan* pthis = (EnBomBowlMan*)thisx; + EnSyatekiNiw* cucco; + s32 i; + GlobalContext* globalCtx = globalCtx2; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gChuGirlSkel, &gChuGirlNoddingOffAnim, pthis->jointTable, + pthis->morphTable, 11); + // "☆ Man, my shoulders hurt~ ☆" + osSyncPrintf(VT_FGCOL(GREEN) "☆ もー 肩こっちゃうよねぇ〜 \t\t ☆ \n" VT_RST); + // "☆ Isn't there some sort of job that will pay better and be more relaxing? ☆ %d" + osSyncPrintf(VT_FGCOL(GREEN) "☆ もっとラクしてもうかるバイトないかしら? ☆ %d\n" VT_RST, + globalCtx->bombchuBowlingStatus); + pthis->posCopy = pthis->actor.world.pos; + pthis->actor.shape.yOffset = -60.0f; + Actor_SetScale(&pthis->actor, 0.013f); + + for (i = 0; i < 2; i++) { + cucco = (EnSyatekiNiw*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SYATEKI_NIW, cuccoSpawnPos[i].x, + cuccoSpawnPos[i].y, cuccoSpawnPos[i].z, 0, 0, 0, 1); + + if (cucco != NULL) { + cucco->unk_2F4 = cuccoScales[i]; + cucco->collider.dim.radius = (s16)cuccoColliderDims[i][0]; + cucco->collider.dim.height = (s16)cuccoColliderDims[i][1]; + } + } + + pthis->prizeSelect = (s16)Rand_ZeroFloat(4.99f); + pthis->actor.targetMode = 1; + pthis->actionFunc = EnBomBowMan_SetupWaitAsleep; +} + +void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnBomBowMan_SetupWaitAsleep(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + pthis->frameCount = (f32)Animation_GetLastFrame(&gChuGirlNoddingOffAnim); + Animation_Change(&pthis->skelAnime, &gChuGirlNoddingOffAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actor.textId = 0xC0; + pthis->dialogState = TEXT_STATE_EVENT; + pthis->actionFunc = EnBomBowMan_WaitAsleep; +} + +void EnBomBowMan_WaitAsleep(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnBomBowMan_TalkAsleep; + } else { + yawDiff = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)); + + if (!(pthis->actor.xzDistToPlayer > 120.0f) && (yawDiff < 0x4300)) { + func_8002F2CC(&pthis->actor, globalCtx, 120.0f); + } + } +} + +void EnBomBowMan_TalkAsleep(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->actionFunc = EnBomBowMan_WakeUp; + } +} + +void EnBomBowMan_WakeUp(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + pthis->frameCount = (f32)Animation_GetLastFrame(&gChuGirlWakeUpAnim); + Animation_Change(&pthis->skelAnime, &gChuGirlWakeUpAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_ONCE, -10.0f); + pthis->eyeMode = CHU_GIRL_EYES_OPEN_SLOWLY; + pthis->actionFunc = EnBomBowMan_BlinkAwake; +} + +void EnBomBowMan_BlinkAwake(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + f32 frameCount = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (frameCount == 30.0f) { + pthis->dialogState = TEXT_STATE_EVENT; + + // Check for beaten Dodongo's Cavern + if ((gSaveContext.eventChkInf[2] & 0x20) || BREG(2)) { + pthis->actor.textId = 0xBF; + } else { + pthis->actor.textId = 0x7058; + } + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + + if ((pthis->eyeTextureIndex == 0) && (pthis->eyeMode == CHU_GIRL_EYES_BLINK_RAPIDLY) && (pthis->blinkTimer == 0)) { + // Blink twice, then move on + pthis->eyeTextureIndex = 2; + pthis->blinkCount++; + if (pthis->blinkCount >= 3) { + pthis->actionFunc = EnBomBowMan_CheckBeatenDC; + } + } +} + +void EnBomBowMan_CheckBeatenDC(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->frameCount = (f32)Animation_GetLastFrame(&gChuGirlLeanOverCounterAnim); + Animation_Change(&pthis->skelAnime, &gChuGirlLeanOverCounterAnim, 1.0f, 0.0f, pthis->frameCount, ANIMMODE_LOOP, + -10.0f); + pthis->eyeMode = CHU_GIRL_EYES_AWAKE; + pthis->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + + // Check for beaten Dodongo's Cavern + if (!((gSaveContext.eventChkInf[2] & 0x20) || BREG(2))) { + pthis->actionFunc = EnBomBowMan_WaitNotBeatenDC; + } else { + pthis->actor.textId = 0x18; + pthis->dialogState = TEXT_STATE_CHOICE; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->actionFunc = EnBomBowlMan_HandlePlayChoice; + } + } +} + +void EnBomBowMan_WaitNotBeatenDC(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnBomBowMan_TalkNotBeatenDC; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 120.0f); + } +} + +void EnBomBowMan_TalkNotBeatenDC(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnBomBowMan_WaitNotBeatenDC; + } +} + +void EnBomBowMan_SetupRunGame(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->minigamePlayStatus == 0) { + if (!pthis->startedPlaying) { + pthis->actor.textId = 0x18; + } else { + pthis->actor.textId = 0x1A; + } + + pthis->dialogState = TEXT_STATE_CHOICE; + } else { + pthis->actor.textId = 0x19; + pthis->dialogState = TEXT_STATE_EVENT; + } + + pthis->actionFunc = EnBomBowMan_RunGame; +} + +void EnBomBowMan_RunGame(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + + if (BREG(3)) { + osSyncPrintf(VT_FGCOL(RED) "☆ game_play->bomchu_game_flag ☆ %d\n" VT_RST, globalCtx->bombchuBowlingStatus); + // "HOW'S THE FIRST WALL DOING?" + osSyncPrintf(VT_FGCOL(RED) "☆ 壁1の状態どう? ☆ %d\n" VT_RST, pthis->wallStatus[0]); + // "HOW'S THE SECOND WALL DOING?" + osSyncPrintf(VT_FGCOL(RED) "☆ 壁2の状態どう? ☆ %d\n" VT_RST, pthis->wallStatus[1]); + // "HOLE INFORMATION" + osSyncPrintf(VT_FGCOL(RED) "☆ 穴情報\t ☆ %d\n" VT_RST, pthis->bowlPit->status); + osSyncPrintf("\n\n"); + } + + pthis->gameResult = 0; + + if (pthis->bowlPit != NULL) { + if ((pthis->wallStatus[0] != 1) && (pthis->wallStatus[1] != 1) && (pthis->bowlPit->status == 2)) { + pthis->gameResult = 1; // Won + pthis->bowlPit->status = 0; + // "Center HIT!" + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 中央HIT!!!! ☆☆☆☆☆ \n" VT_RST); + } + + if ((globalCtx->bombchuBowlingStatus == -1) && + (globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].length == 0) && (pthis->bowlPit->status == 0) && + (pthis->wallStatus[0] != 1) && (pthis->wallStatus[1] != 1)) { + pthis->gameResult = 2; // Lost + // "Bombchu lost" + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ボムチュウ消化 ☆☆☆☆☆ \n" VT_RST); + } + } + + if (pthis->gameResult != 0) { // won or lost + pthis->actor.textId = 0x1A; + pthis->dialogState = TEXT_STATE_CHOICE; + pthis->minigamePlayStatus = 0; + + if ((pthis->exItem != NULL) && (pthis->exItem->actor.update != NULL)) { + pthis->exItem->killItem = true; + pthis->exItem = NULL; + } + + globalCtx->bombchuBowlingStatus = 0; + pthis->playingAgain = true; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + + if (pthis->gameResult == 2) { + func_8002DF54(globalCtx, NULL, 8); + } + pthis->actionFunc = EnBomBowlMan_HandlePlayChoice; + } else { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->minigamePlayStatus == 0) { + pthis->actionFunc = EnBomBowlMan_HandlePlayChoice; + } else { + pthis->actionFunc = func_809C41FC; + } + } else { + yawDiff = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)); + + if (!(pthis->actor.xzDistToPlayer > 120.0f) && (yawDiff < 0x4300)) { + func_8002F2CC(&pthis->actor, globalCtx, 120.0f); + } + } + } +} + +void EnBomBowlMan_HandlePlayChoice(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // Yes + if (gSaveContext.rupees >= 30) { + Rupees_ChangeBy(-30); + pthis->minigamePlayStatus = 1; + pthis->wallStatus[0] = pthis->wallStatus[1] = 0; + globalCtx->bombchuBowlingStatus = 10; + Flags_SetSwitch(globalCtx, 0x38); + + if (!pthis->startedPlaying && !pthis->playingAgain) { + pthis->actor.textId = 0x19; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + pthis->actionFunc = func_809C41FC; + } else { + pthis->actor.textId = 0x1B; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + OnePointCutscene_Init(globalCtx, 8010, -99, NULL, MAIN_CAM); + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = EnBomBowMan_SetupChooseShowPrize; + } + } else { + pthis->playingAgain = false; + pthis->actor.textId = 0x85; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + pthis->actionFunc = func_809C41FC; + } + break; + + case 1: // No + pthis->playingAgain = false; + pthis->actor.textId = 0x2D; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + pthis->actionFunc = func_809C41FC; + } + } +} + +void func_809C41FC(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + + if (((pthis->actor.textId == 0x2D) || (pthis->actor.textId == 0x85)) && Flags_GetSwitch(globalCtx, 0x38)) { + Flags_UnsetSwitch(globalCtx, 0x38); + } + + if (pthis->minigamePlayStatus == 1) { + pthis->actor.textId = 0x1B; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + OnePointCutscene_Init(globalCtx, 8010, -99, NULL, MAIN_CAM); + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = EnBomBowMan_SetupChooseShowPrize; + } else { + if (pthis->gameResult == 2) { + func_8002DF54(globalCtx, NULL, 7); + } + pthis->actionFunc = EnBomBowMan_SetupRunGame; + } + } +} + +void EnBomBowMan_SetupChooseShowPrize(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + Vec3f accel = { 0.0f, 0.1f, 0.0f }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + + SkelAnime_Update(&pthis->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + pos.x = 148.0f; + pos.y = 40.0f; + pos.z = 300.0f; + EffectSsBomb2_SpawnLayered(globalCtx, &pos, &velocity, &accel, 50, 15); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_GOODS_APPEAR); + pthis->prizeRevealTimer = 10; + pthis->actionFunc = EnBomBowMan_ChooseShowPrize; + } +} + +static Vec3f sPrizePosOffset[] = { + { 0.0f, 22.0f, 0.0f }, { 0.0f, 22.0f, 0.0f }, { 0.0f, 8.0f, 0.0f }, { 0.0f, 9.0f, 0.0f }, { 0.0f, -2.0f, 0.0f }, +}; + +static s16 sPrizeRot[] = { 0x4268, 0x4268, -0x03E8, 0x0000, 0x4268, 0x0000 }; + +void EnBomBowMan_ChooseShowPrize(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + s16 prizeTemp; + s32 pad; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->prizeRevealTimer == 0) { + switch (pthis->prizeSelect) { + case 0: + prizeTemp = EXITEM_BOMB_BAG_BOWLING; + if (gSaveContext.itemGetInf[1] & 2) { + prizeTemp = EXITEM_PURPLE_RUPEE_BOWLING; + } + break; + case 1: + prizeTemp = EXITEM_PURPLE_RUPEE_BOWLING; + break; + case 2: + prizeTemp = EXITEM_BOMBCHUS_BOWLING; + break; + case 3: + prizeTemp = EXITEM_HEART_PIECE_BOWLING; + if (gSaveContext.itemGetInf[1] & 4) { + prizeTemp = EXITEM_PURPLE_RUPEE_BOWLING; + } + break; + case 4: + prizeTemp = EXITEM_BOMBS_BOWLING; + break; + } + + pthis->prizeIndex = prizeTemp; + + if (BREG(7)) { + pthis->prizeIndex = BREG(7) - 1; + } + + pthis->exItem = (EnExItem*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_ITEM, + sPrizePosOffset[pthis->prizeIndex].x + 148.0f, + sPrizePosOffset[pthis->prizeIndex].y + 40.0f, + sPrizePosOffset[pthis->prizeIndex].z + 300.0f, 0, + sPrizeRot[pthis->prizeIndex], 0, pthis->prizeIndex + EXITEM_COUNTER); + + if (!pthis->startedPlaying) { + pthis->bowlPit = (EnBomBowlPit*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, + ACTOR_EN_BOM_BOWL_PIT, 0.0f, 90.0f, -860.0f, 0, 0, 0, 0); + if (pthis->bowlPit != NULL) { + pthis->bowlPit->prizeIndex = pthis->prizeIndex; + } + } else { + pthis->bowlPit->prizeIndex = pthis->prizeIndex; + } + + pthis->bowlPit->start = 1; + pthis->minigamePlayStatus = 2; + pthis->actor.textId = 0x405A; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + + // Cycle through prizes in order + pthis->prizeSelect++; + if (pthis->prizeSelect >= 5) { + pthis->prizeSelect = 0; + } + pthis->actionFunc = EnBomBowlMan_BeginPlayGame; + } +} + +void EnBomBowlMan_BeginPlayGame(EnBomBowlMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == pthis->dialogState) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + pthis->startedPlaying = true; + + if (BREG(2)) { + BREG(2) = 0; + } + + // "Wow" + osSyncPrintf(VT_FGCOL(YELLOW) "☆ わー ☆ %d\n" VT_RST, globalCtx->bombchuBowlingStatus); + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = EnBomBowMan_SetupRunGame; + } +} + +void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* pthis = (EnBomBowlMan*)thisx; + + pthis->timer++; + pthis->actor.focus.pos.y = 60.0f; + Actor_SetFocus(&pthis->actor, 60.0f); + + switch (pthis->eyeMode) { + case CHU_GIRL_EYES_ASLEEP: + pthis->eyeTextureIndex = 2; + break; + case CHU_GIRL_EYES_OPEN_SLOWLY: + if (pthis->eyeTextureIndex > 0) { + pthis->eyeTextureIndex--; + } else { + pthis->blinkTimer = 30; + pthis->eyeMode = CHU_GIRL_EYES_BLINK_RAPIDLY; + } + break; + case CHU_GIRL_EYES_BLINK_RAPIDLY: + if ((pthis->blinkTimer == 0) && (pthis->eyeTextureIndex > 0)) { + pthis->eyeTextureIndex--; + } + break; + default: + if (pthis->blinkTimer == 0) { + pthis->eyeTextureIndex++; + if (pthis->eyeTextureIndex >= 3) { + pthis->eyeTextureIndex = 0; + pthis->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + func_80038290(globalCtx, &pthis->actor, &pthis->unk_218, &pthis->unk_224, pthis->actor.focus.pos); + break; + } + + DECR(pthis->prizeRevealTimer); + DECR(pthis->blinkTimer); + + pthis->actionFunc(pthis, globalCtx); +} + +s32 EnBomBowlMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnBomBowlMan* pthis = (EnBomBowlMan*)thisx; + + if (limbIndex == 4) { // head + rot->x += pthis->unk_218.y; + rot->z += pthis->unk_218.z; + } + + return false; +} + +void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gChuGirlEyeOpenTex, gChuGirlEyeHalfTex, gChuGirlEyeClosedTex }; + EnBomBowlMan* pthis = (EnBomBowlMan*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_bowl_man.c", 907); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTextureIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnBomBowlMan_OverrideLimbDraw, NULL, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_bowl_man.c", 923); +} diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c b/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c deleted file mode 100644 index 4b2a57bea..000000000 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c +++ /dev/null @@ -1,229 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOM_BOWL_PIT_Z_EN_BOM_BOWL_PIT_C -#include "actor_common.h" -#include "z_en_bom_bowl_pit.h" -#include "vt.h" -#include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" -#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_play.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnBomBowlPit_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlPit_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlPit_Update(Actor* thisx, GlobalContext* globalCtx); - -void EnBomBowlPit_SetupDetectHit(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_DetectHit(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_CameraDollyIn(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_SpawnPrize(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_SetupGivePrize(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_GivePrize(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* this, GlobalContext* globalCtx); -void EnBomBowlPit_Reset(EnBomBowlPit* this, GlobalContext* globalCtx); - -static s32 sGetItemIds[] = { GI_BOMB_BAG_30, GI_HEART_PIECE, GI_BOMBCHUS_10, GI_BOMBS_1, GI_RUPEE_PURPLE }; - -const ActorInit En_Bom_Bowl_Pit_InitVars = { - ACTOR_EN_BOM_BOWL_PIT, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnBomBowlPit), - (ActorFunc)EnBomBowlPit_Init, - (ActorFunc)EnBomBowlPit_Destroy, - (ActorFunc)EnBomBowlPit_Update, - NULL, -}; - -void EnBomBowlPit_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBomBowlPit* this = (EnBomBowlPit*)thisx; - - this->actionFunc = EnBomBowlPit_SetupDetectHit; -} - -void EnBomBowlPit_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnBomBowlPit_SetupDetectHit(EnBomBowlPit* this, GlobalContext* globalCtx) { - if (this->start != 0) { - this->start = this->status = 0; - this->actionFunc = EnBomBowlPit_DetectHit; - } -} - -void EnBomBowlPit_DetectHit(EnBomBowlPit* this, GlobalContext* globalCtx) { - EnBomChu* chu; - Vec3f chuPosDiff; - - if (globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_CHU_BOWLING) { - chu = (EnBomChu*)globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; - - while (chu != NULL) { - if ((&chu->actor == &this->actor) || (chu->actor.id != ACTOR_EN_BOM_CHU)) { - chu = (EnBomChu*)chu->actor.next; - continue; - } - - chuPosDiff.x = chu->actor.world.pos.x - this->actor.world.pos.x; - chuPosDiff.y = chu->actor.world.pos.y - this->actor.world.pos.y; - chuPosDiff.z = chu->actor.world.pos.z - this->actor.world.pos.z; - - if (((fabsf(chuPosDiff.x) < 40.0f) || (BREG(2))) && ((fabsf(chuPosDiff.y) < 40.0f) || (BREG(2))) && - ((fabsf(chuPosDiff.z) < 40.0f) || (BREG(2)))) { - func_8002DF54(globalCtx, NULL, 8); - chu->timer = 1; - - this->camId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->camId, CAM_STAT_ACTIVE); - - this->unk_1C8.x = this->unk_1C8.y = this->unk_1C8.z = 0.1f; - this->unk_1A4.x = this->unk_1A4.y = this->unk_1A4.z = 0.1f; - - this->unk_180.x = this->unk_168.x = globalCtx->view.lookAt.x; - this->unk_180.y = this->unk_168.y = globalCtx->view.lookAt.y; - this->unk_180.z = this->unk_168.z = globalCtx->view.lookAt.z; - - this->unk_18C.x = this->unk_174.x = globalCtx->view.eye.x; - this->unk_18C.y = this->unk_174.y = globalCtx->view.eye.y; - this->unk_18C.z = this->unk_174.z = globalCtx->view.eye.z; - - this->unk_1BC.x = 20.0f; - this->unk_1BC.y = 100.0f; - this->unk_1BC.z = -800.0f; - - this->unk_198.x = 20.0f; - this->unk_198.y = 50.0f; - this->unk_198.z = -485.0f; - - this->unk_1B0.x = fabsf(this->unk_18C.x - this->unk_198.x) * 0.02f; - this->unk_1B0.y = fabsf(this->unk_18C.y - this->unk_198.y) * 0.02f; - this->unk_1B0.z = fabsf(this->unk_18C.z - this->unk_198.z) * 0.02f; - - this->unk_1D4.x = fabsf(this->unk_180.x - this->unk_1BC.x) * 0.02f; - this->unk_1D4.y = fabsf(this->unk_180.y - this->unk_1BC.y) * 0.02f; - this->unk_1D4.z = fabsf(this->unk_180.z - this->unk_1BC.z) * 0.02f; - - Gameplay_CameraSetAtEye(globalCtx, this->camId, &this->unk_180, &this->unk_18C); - this->actor.textId = 0xF; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_154 = TEXT_STATE_EVENT; - func_80078884(NA_SE_EV_HIT_SOUND); - func_8002DF54(globalCtx, NULL, 8); - this->status = 1; - this->actionFunc = EnBomBowlPit_CameraDollyIn; - break; - } else { - chu = (EnBomChu*)chu->actor.next; - } - } - } -} - -void EnBomBowlPit_CameraDollyIn(EnBomBowlPit* this, GlobalContext* globalCtx) { - if (this->camId != SUBCAM_FREE) { - Math_ApproachF(&this->unk_180.x, this->unk_1BC.x, this->unk_1C8.x, this->unk_1D4.x); - Math_ApproachF(&this->unk_180.y, this->unk_1BC.y, this->unk_1C8.y, this->unk_1D4.y); - Math_ApproachF(&this->unk_180.z, this->unk_1BC.z, this->unk_1C8.z, this->unk_1D4.z); - Math_ApproachF(&this->unk_18C.x, this->unk_198.x, this->unk_1A4.x, this->unk_1B0.x); - Math_ApproachF(&this->unk_18C.y, this->unk_198.y, this->unk_1A4.y, this->unk_1B0.y); - Math_ApproachF(&this->unk_18C.z, this->unk_198.z, this->unk_1A4.z, this->unk_1B0.z); - } - - Gameplay_CameraSetAtEye(globalCtx, this->camId, &this->unk_180, &this->unk_18C); - - if ((this->unk_154 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - } - - if ((fabsf(this->unk_18C.x - this->unk_198.x) < 5.0f) && (fabsf(this->unk_18C.y - this->unk_198.y) < 5.0f) && - (fabsf(this->unk_18C.z - this->unk_198.z) < 5.0f) && (fabsf(this->unk_180.x - this->unk_1BC.x) < 5.0f) && - (fabsf(this->unk_180.y - this->unk_1BC.y) < 5.0f) && (fabsf(this->unk_180.z - this->unk_1BC.z) < 5.0f)) { - Message_CloseTextbox(globalCtx); - this->timer = 30; - this->actionFunc = EnBomBowlPit_SpawnPrize; - } -} - -void EnBomBowlPit_SpawnPrize(EnBomBowlPit* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - this->exItem = (EnExItem*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_ITEM, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z - 70.0f, 0, 0, 0, this->prizeIndex); - if (this->exItem != NULL) { - this->actionFunc = EnBomBowlPit_SetupGivePrize; - } - } -} - -void EnBomBowlPit_SetupGivePrize(EnBomBowlPit* this, GlobalContext* globalCtx) { - if (this->exItemDone != 0) { - switch (this->prizeIndex) { - case EXITEM_BOMB_BAG_BOWLING: - gSaveContext.itemGetInf[1] |= 2; - break; - case EXITEM_HEART_PIECE_BOWLING: - gSaveContext.itemGetInf[1] |= 4; - break; - } - - Gameplay_ClearCamera(globalCtx, this->camId); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = EnBomBowlPit_GivePrize; - } -} - -void EnBomBowlPit_GivePrize(EnBomBowlPit* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - func_8002DF54(globalCtx, NULL, 7); - this->getItemId = sGetItemIds[this->prizeIndex]; - - if ((this->getItemId == GI_BOMB_BAG_30) && (CUR_CAPACITY(UPG_BOMB_BAG) == 30)) { - this->getItemId = GI_BOMB_BAG_40; - } - - player->stateFlags1 &= ~0x20000000; - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); - player->stateFlags1 |= 0x20000000; - this->actionFunc = EnBomBowlPit_WaitTillPrizeGiven; -} - -void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = EnBomBowlPit_Reset; - } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); - } -} - -void EnBomBowlPit_Reset(EnBomBowlPit* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - // "Normal termination"/"completion" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); - if (this->getItemId == GI_HEART_PIECE) { - gSaveContext.healthAccumulator = 0x140; - // "Ah recovery!" (?) - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ あぁ回復! ☆☆☆☆☆ \n" VT_RST); - } - this->exItemDone = 0; - this->status = 2; - this->actionFunc = EnBomBowlPit_SetupDetectHit; - } -} - -void EnBomBowlPit_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBomBowlPit* this = (EnBomBowlPit*)thisx; - - this->actionFunc(this, globalCtx); - - if (this->timer != 0) { - this->timer--; - } -} diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.cpp b/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.cpp new file mode 100644 index 000000000..fe98e7306 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.cpp @@ -0,0 +1,229 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOM_BOWL_PIT_Z_EN_BOM_BOWL_PIT_C +#include "actor_common.h" +#include "z_en_bom_bowl_pit.h" +#include "vt.h" +#include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" +#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_play.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnBomBowlPit_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBomBowlPit_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBomBowlPit_Update(Actor* thisx, GlobalContext* globalCtx); + +void EnBomBowlPit_SetupDetectHit(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_DetectHit(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_CameraDollyIn(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_SpawnPrize(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_SetupGivePrize(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_GivePrize(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* pthis, GlobalContext* globalCtx); +void EnBomBowlPit_Reset(EnBomBowlPit* pthis, GlobalContext* globalCtx); + +static s32 sGetItemIds[] = { GI_BOMB_BAG_30, GI_HEART_PIECE, GI_BOMBCHUS_10, GI_BOMBS_1, GI_RUPEE_PURPLE }; + +ActorInit En_Bom_Bowl_Pit_InitVars = { + ACTOR_EN_BOM_BOWL_PIT, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnBomBowlPit), + (ActorFunc)EnBomBowlPit_Init, + (ActorFunc)EnBomBowlPit_Destroy, + (ActorFunc)EnBomBowlPit_Update, + NULL, +}; + +void EnBomBowlPit_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlPit* pthis = (EnBomBowlPit*)thisx; + + pthis->actionFunc = EnBomBowlPit_SetupDetectHit; +} + +void EnBomBowlPit_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnBomBowlPit_SetupDetectHit(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + if (pthis->start != 0) { + pthis->start = pthis->status = 0; + pthis->actionFunc = EnBomBowlPit_DetectHit; + } +} + +void EnBomBowlPit_DetectHit(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + EnBomChu* chu; + Vec3f chuPosDiff; + + if (globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_CHU_BOWLING) { + chu = (EnBomChu*)globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; + + while (chu != NULL) { + if ((&chu->actor == &pthis->actor) || (chu->actor.id != ACTOR_EN_BOM_CHU)) { + chu = (EnBomChu*)chu->actor.next; + continue; + } + + chuPosDiff.x = chu->actor.world.pos.x - pthis->actor.world.pos.x; + chuPosDiff.y = chu->actor.world.pos.y - pthis->actor.world.pos.y; + chuPosDiff.z = chu->actor.world.pos.z - pthis->actor.world.pos.z; + + if (((fabsf(chuPosDiff.x) < 40.0f) || (BREG(2))) && ((fabsf(chuPosDiff.y) < 40.0f) || (BREG(2))) && + ((fabsf(chuPosDiff.z) < 40.0f) || (BREG(2)))) { + func_8002DF54(globalCtx, NULL, 8); + chu->timer = 1; + + pthis->camId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->camId, CAM_STAT_ACTIVE); + + pthis->unk_1C8.x = pthis->unk_1C8.y = pthis->unk_1C8.z = 0.1f; + pthis->unk_1A4.x = pthis->unk_1A4.y = pthis->unk_1A4.z = 0.1f; + + pthis->unk_180.x = pthis->unk_168.x = globalCtx->view.lookAt.x; + pthis->unk_180.y = pthis->unk_168.y = globalCtx->view.lookAt.y; + pthis->unk_180.z = pthis->unk_168.z = globalCtx->view.lookAt.z; + + pthis->unk_18C.x = pthis->unk_174.x = globalCtx->view.eye.x; + pthis->unk_18C.y = pthis->unk_174.y = globalCtx->view.eye.y; + pthis->unk_18C.z = pthis->unk_174.z = globalCtx->view.eye.z; + + pthis->unk_1BC.x = 20.0f; + pthis->unk_1BC.y = 100.0f; + pthis->unk_1BC.z = -800.0f; + + pthis->unk_198.x = 20.0f; + pthis->unk_198.y = 50.0f; + pthis->unk_198.z = -485.0f; + + pthis->unk_1B0.x = fabsf(pthis->unk_18C.x - pthis->unk_198.x) * 0.02f; + pthis->unk_1B0.y = fabsf(pthis->unk_18C.y - pthis->unk_198.y) * 0.02f; + pthis->unk_1B0.z = fabsf(pthis->unk_18C.z - pthis->unk_198.z) * 0.02f; + + pthis->unk_1D4.x = fabsf(pthis->unk_180.x - pthis->unk_1BC.x) * 0.02f; + pthis->unk_1D4.y = fabsf(pthis->unk_180.y - pthis->unk_1BC.y) * 0.02f; + pthis->unk_1D4.z = fabsf(pthis->unk_180.z - pthis->unk_1BC.z) * 0.02f; + + Gameplay_CameraSetAtEye(globalCtx, pthis->camId, &pthis->unk_180, &pthis->unk_18C); + pthis->actor.textId = 0xF; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_154 = TEXT_STATE_EVENT; + func_80078884(NA_SE_EV_HIT_SOUND); + func_8002DF54(globalCtx, NULL, 8); + pthis->status = 1; + pthis->actionFunc = EnBomBowlPit_CameraDollyIn; + break; + } else { + chu = (EnBomChu*)chu->actor.next; + } + } + } +} + +void EnBomBowlPit_CameraDollyIn(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + if (pthis->camId != SUBCAM_FREE) { + Math_ApproachF(&pthis->unk_180.x, pthis->unk_1BC.x, pthis->unk_1C8.x, pthis->unk_1D4.x); + Math_ApproachF(&pthis->unk_180.y, pthis->unk_1BC.y, pthis->unk_1C8.y, pthis->unk_1D4.y); + Math_ApproachF(&pthis->unk_180.z, pthis->unk_1BC.z, pthis->unk_1C8.z, pthis->unk_1D4.z); + Math_ApproachF(&pthis->unk_18C.x, pthis->unk_198.x, pthis->unk_1A4.x, pthis->unk_1B0.x); + Math_ApproachF(&pthis->unk_18C.y, pthis->unk_198.y, pthis->unk_1A4.y, pthis->unk_1B0.y); + Math_ApproachF(&pthis->unk_18C.z, pthis->unk_198.z, pthis->unk_1A4.z, pthis->unk_1B0.z); + } + + Gameplay_CameraSetAtEye(globalCtx, pthis->camId, &pthis->unk_180, &pthis->unk_18C); + + if ((pthis->unk_154 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + } + + if ((fabsf(pthis->unk_18C.x - pthis->unk_198.x) < 5.0f) && (fabsf(pthis->unk_18C.y - pthis->unk_198.y) < 5.0f) && + (fabsf(pthis->unk_18C.z - pthis->unk_198.z) < 5.0f) && (fabsf(pthis->unk_180.x - pthis->unk_1BC.x) < 5.0f) && + (fabsf(pthis->unk_180.y - pthis->unk_1BC.y) < 5.0f) && (fabsf(pthis->unk_180.z - pthis->unk_1BC.z) < 5.0f)) { + Message_CloseTextbox(globalCtx); + pthis->timer = 30; + pthis->actionFunc = EnBomBowlPit_SpawnPrize; + } +} + +void EnBomBowlPit_SpawnPrize(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + pthis->exItem = (EnExItem*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_ITEM, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z - 70.0f, 0, 0, 0, pthis->prizeIndex); + if (pthis->exItem != NULL) { + pthis->actionFunc = EnBomBowlPit_SetupGivePrize; + } + } +} + +void EnBomBowlPit_SetupGivePrize(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + if (pthis->exItemDone != 0) { + switch (pthis->prizeIndex) { + case EXITEM_BOMB_BAG_BOWLING: + gSaveContext.itemGetInf[1] |= 2; + break; + case EXITEM_HEART_PIECE_BOWLING: + gSaveContext.itemGetInf[1] |= 4; + break; + } + + Gameplay_ClearCamera(globalCtx, pthis->camId); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = EnBomBowlPit_GivePrize; + } +} + +void EnBomBowlPit_GivePrize(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_8002DF54(globalCtx, NULL, 7); + pthis->getItemId = sGetItemIds[pthis->prizeIndex]; + + if ((pthis->getItemId == GI_BOMB_BAG_30) && (CUR_CAPACITY(UPG_BOMB_BAG) == 30)) { + pthis->getItemId = GI_BOMB_BAG_40; + } + + player->stateFlags1 &= ~0x20000000; + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 2000.0f, 1000.0f); + player->stateFlags1 |= 0x20000000; + pthis->actionFunc = EnBomBowlPit_WaitTillPrizeGiven; +} + +void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnBomBowlPit_Reset; + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 2000.0f, 1000.0f); + } +} + +void EnBomBowlPit_Reset(EnBomBowlPit* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + // "Normal termination"/"completion" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); + if (pthis->getItemId == GI_HEART_PIECE) { + gSaveContext.healthAccumulator = 0x140; + // "Ah recovery!" (?) + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ あぁ回復! ☆☆☆☆☆ \n" VT_RST); + } + pthis->exItemDone = 0; + pthis->status = 2; + pthis->actionFunc = EnBomBowlPit_SetupDetectHit; + } +} + +void EnBomBowlPit_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlPit* pthis = (EnBomBowlPit*)thisx; + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->timer != 0) { + pthis->timer--; + } +} diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c deleted file mode 100644 index d9be6e819..000000000 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ /dev/null @@ -1,531 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOM_CHU_Z_EN_BOM_CHU_C -#include "actor_common.h" -#include "z_en_bom_chu.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800430A0.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -#define BOMBCHU_SCALE 0.01f - -void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx); -void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx); -void EnBomChu_WaitForKill(EnBomChu* this, GlobalContext* globalCtx); - -const ActorInit En_Bom_Chu_InitVars = { - ACTOR_EN_BOM_CHU, - ACTORCAT_EXPLOSIVE, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnBomChu), - (ActorFunc)EnBomChu_Init, - (ActorFunc)EnBomChu_Destroy, - (ActorFunc)EnBomChu_Update, - (ActorFunc)EnBomChu_Draw, -}; - -static ColliderJntSphElementInit sJntSphElemInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 1, { { 0, 0, 0 }, 12 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphElemInit), - sJntSphElemInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 1000 * BOMBCHU_SCALE, ICHAIN_STOP), -}; - -void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { - static u8 p1StartColor[] = { 250, 0, 0, 250 }; - static u8 p2StartColor[] = { 200, 0, 0, 130 }; - static u8 p1EndColor[] = { 150, 0, 0, 100 }; - static u8 p2EndColor[] = { 100, 0, 0, 50 }; - EnBomChu* this = (EnBomChu*)thisx; - EffectBlureInit1 blureInit; - s32 i; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - - this->collider.elements[0].dim.worldSphere.radius = this->collider.elements[0].dim.modelSphere.radius; - - for (i = 0; i < 4; i++) { - blureInit.p1StartColor[i] = p1StartColor[i]; - blureInit.p2StartColor[i] = p2StartColor[i]; - blureInit.p1EndColor[i] = p1EndColor[i]; - blureInit.p2EndColor[i] = p2EndColor[i]; - } - - blureInit.elemDuration = 16; - blureInit.unkFlag = 0; - blureInit.calcMode = 0; - - Effect_Add(globalCtx, &this->blure1Index, EFFECT_BLURE1, 0, 0, &blureInit); - Effect_Add(globalCtx, &this->blure2Index, EFFECT_BLURE1, 0, 0, &blureInit); - - this->actor.room = -1; - this->timer = 120; - this->actionFunc = EnBomChu_WaitForRelease; -} - -void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBomChu* this = (EnBomChu*)thisx; - - Effect_Delete(globalCtx, this->blure1Index); - Effect_Delete(globalCtx, this->blure2Index); - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { - EnBom* bomb; - s32 i; - - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, BOMB_BODY); - if (bomb != NULL) { - bomb->timer = 0; - } - - this->timer = 1; - this->actor.speedXZ = 0.0f; - - if (this->actor.yDistToWater > 0.0f) { - for (i = 0; i < 40; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); - } - } - - this->actionFunc = EnBomChu_WaitForKill; -} - -void EnBomChu_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dest) { - dest->x = (a->y * b->z) - (a->z * b->y); - dest->y = (a->z * b->x) - (a->x * b->z); - dest->z = (a->x * b->y) - (a->y * b->x); -} - -void EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalContext* globalCtx) { - Vec3f normal; - Vec3f vec; - f32 angle; - f32 magnitude; - f32 normDotUp; - MtxF mf; - - this->actor.floorPoly = floorPoly; - - normal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); - normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); - normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); - - normDotUp = DOTXYZ(normal, this->axisUp); - - if (!(fabsf(normDotUp) >= 1.0f)) { - angle = Math_FAcosF(normDotUp); - - if (!(angle < 0.001f)) { - EnBomChu_CrossProduct(&this->axisUp, &normal, &vec); - //! @bug this function expects a unit vector but `vec` is not normalized - Matrix_RotateAxis(angle, &vec, MTXMODE_NEW); - - Matrix_MultVec3f(&this->axisLeft, &vec); - this->axisLeft = vec; - - EnBomChu_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); - - magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); - - if (magnitude < 0.001f) { - EnBomChu_Explode(this, globalCtx); - return; - } - - this->axisForwards.x *= 1.0f / magnitude; - this->axisForwards.y *= 1.0f / magnitude; - this->axisForwards.z *= 1.0f / magnitude; - - this->axisUp = normal; - - if (1) {} - - // mf = (axisLeft | axisUp | axisForwards) - - mf.xx = this->axisLeft.x; - mf.yx = this->axisLeft.y; - mf.zx = this->axisLeft.z; - - mf.xy = normal.x; - mf.yy = normal.y; - mf.zy = normal.z; - - mf.xz = this->axisForwards.x; - mf.yz = this->axisForwards.y; - mf.zz = this->axisForwards.z; - - Matrix_MtxFToYXZRotS(&mf, &this->actor.world.rot, 0); - - // A hack for preventing bombchus from sticking to ledges. - // The visual rotation reverts the sign inversion (shape.rot.x = -world.rot.x). - // The better fix would be making func_8002D908 compute XYZ velocity better, - // or not using it and make the bombchu compute its own velocity. - this->actor.world.rot.x = -this->actor.world.rot.x; - } - } -} - -void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - EnBomChu_Explode(this, globalCtx); - return; - } - - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.world.pos = player->actor.world.pos; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actor.shape.rot.y = player->actor.shape.rot.y; - - // rot.y = 0 -> +z (forwards in model space) - this->axisForwards.x = Math_SinS(this->actor.shape.rot.y); - this->axisForwards.y = 0.0f; - this->axisForwards.z = Math_CosS(this->actor.shape.rot.y); - - // +y (up in model space) - this->axisUp.x = 0.0f; - this->axisUp.y = 1.0f; - this->axisUp.z = 0.0f; - - // rot.y = 0 -> +x (left in model space) - this->axisLeft.x = Math_SinS(this->actor.shape.rot.y + 0x4000); - this->axisLeft.y = 0; - this->axisLeft.z = Math_CosS(this->actor.shape.rot.y + 0x4000); - - this->actor.speedXZ = 8.0f; - //! @bug there is no NULL check on the floor poly. If the player is out of bounds the floor poly will be NULL - //! and will cause a crash inside this function. - EnBomChu_UpdateFloorPoly(this, this->actor.floorPoly, globalCtx); - this->actor.flags |= ACTOR_FLAG_0; // make chu targetable - func_8002F850(globalCtx, &this->actor); - this->actionFunc = EnBomChu_Move; - } -} - -void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { - CollisionPoly* polySide; - CollisionPoly* polyUpDown; - s32 bgIdSide; - s32 bgIdUpDown; - s32 i; - f32 lineLength; - Vec3f posA; - Vec3f posB; - Vec3f posSide; - Vec3f posUpDown; - - this->actor.speedXZ = 8.0f; - lineLength = this->actor.speedXZ * 2.0f; - - if (this->timer != 0) { - this->timer--; - } - - if ((this->timer == 0) || (this->collider.base.acFlags & AC_HIT) || - ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.oc->category != ACTORCAT_PLAYER))) { - EnBomChu_Explode(this, globalCtx); - return; - } - - posA.x = this->actor.world.pos.x + (this->axisUp.x * 2.0f); - posA.y = this->actor.world.pos.y + (this->axisUp.y * 2.0f); - posA.z = this->actor.world.pos.z + (this->axisUp.z * 2.0f); - - posB.x = this->actor.world.pos.x - (this->axisUp.x * 4.0f); - posB.y = this->actor.world.pos.y - (this->axisUp.y * 4.0f); - posB.z = this->actor.world.pos.z - (this->axisUp.z * 4.0f); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posUpDown, &polyUpDown, true, true, true, true, - &bgIdUpDown) && - !(func_80041DB8(&globalCtx->colCtx, polyUpDown, bgIdUpDown) & 0x30) && // && not crawl space? - !SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, polyUpDown, bgIdUpDown)) { - // forwards - posB.x = (this->axisForwards.x * lineLength) + posA.x; - posB.y = (this->axisForwards.y * lineLength) + posA.y; - posB.z = (this->axisForwards.z * lineLength) + posA.z; - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posSide, &polySide, true, true, true, true, - &bgIdSide) && - !(func_80041DB8(&globalCtx->colCtx, polySide, bgIdSide) & 0x30) && - !SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, polySide, bgIdSide)) { - EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); - this->actor.world.pos = posSide; - this->actor.floorBgId = bgIdSide; - this->actor.speedXZ = 0.0f; - } else { - if (this->actor.floorPoly != polyUpDown) { - EnBomChu_UpdateFloorPoly(this, polyUpDown, globalCtx); - } - - this->actor.world.pos = posUpDown; - this->actor.floorBgId = bgIdUpDown; - } - } else { - this->actor.speedXZ = 0.0f; - lineLength *= 3.0f; - posA = posB; - - for (i = 0; i < 3; i++) { - if (i == 0) { - // backwards - posB.x = posA.x - (this->axisForwards.x * lineLength); - posB.y = posA.y - (this->axisForwards.y * lineLength); - posB.z = posA.z - (this->axisForwards.z * lineLength); - } else if (i == 1) { - // left - posB.x = posA.x + (this->axisLeft.x * lineLength); - posB.y = posA.y + (this->axisLeft.y * lineLength); - posB.z = posA.z + (this->axisLeft.z * lineLength); - } else { - // right - posB.x = posA.x - (this->axisLeft.x * lineLength); - posB.y = posA.y - (this->axisLeft.y * lineLength); - posB.z = posA.z - (this->axisLeft.z * lineLength); - } - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posSide, &polySide, true, true, true, true, - &bgIdSide) && - !(func_80041DB8(&globalCtx->colCtx, polySide, bgIdSide) & 0x30) && - !SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, polySide, bgIdSide)) { - EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); - this->actor.world.pos = posSide; - this->actor.floorBgId = bgIdSide; - break; - } - } - - if (i == 3) { - // no collision nearby - EnBomChu_Explode(this, globalCtx); - } - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, -this->actor.world.rot.x, 0x800); - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 0x800); - Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.world.rot.z, 0x800); - - func_8002F8F0(&this->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); -} - -void EnBomChu_WaitForKill(EnBomChu* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - Actor_Kill(&this->actor); - } -} - -/** - * Transform coordinates from model space to world space, according to current orientation. - * `posModel` is expected to already be at world scale (1/100 compared to model scale) - */ -void EnBomChu_ModelToWorld(EnBomChu* this, Vec3f* posModel, Vec3f* dest) { - f32 x = posModel->x + this->visualJitter; - - dest->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * posModel->y) + - (this->axisForwards.x * posModel->z); - dest->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * posModel->y) + - (this->axisForwards.y * posModel->z); - dest->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * posModel->y) + - (this->axisForwards.z * posModel->z); -} - -void EnBomChu_SpawnRipples(EnBomChu* this, GlobalContext* globalCtx, f32 y) { - Vec3f pos; - - pos.x = this->actor.world.pos.x; - pos.y = y; - pos.z = this->actor.world.pos.z; - - EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); - EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); -} - -void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx2) { - static Vec3f blureP1Model = { 0.0f, 7.0f, -6.0f }; - static Vec3f blureP2LeftModel = { 12.0f, 0.0f, -5.0f }; - static Vec3f blureP2RightModel = { -12.0f, 0.0f, -5.0f }; - GlobalContext* globalCtx = globalCtx2; - EnBomChu* this = (EnBomChu*)thisx; - s16 yaw; - f32 sin; - f32 cos; - f32 tempX; - Vec3f blureP1; - Vec3f blureP2; - WaterBox* waterBox; - f32 waterY; - - if (this->actor.floorBgId != BGCHECK_SCENE) { - yaw = this->actor.shape.rot.y; - func_800433A4(&globalCtx->colCtx, this->actor.floorBgId, &this->actor); - - if (yaw != this->actor.shape.rot.y) { - yaw = this->actor.shape.rot.y - yaw; - - sin = Math_SinS(yaw); - cos = Math_CosS(yaw); - - tempX = this->axisForwards.x; - this->axisForwards.x = (this->axisForwards.z * sin) + (cos * tempX); - this->axisForwards.z = (this->axisForwards.z * cos) - (sin * tempX); - - tempX = this->axisUp.x; - this->axisUp.x = (this->axisUp.z * sin) + (cos * tempX); - this->axisUp.z = (this->axisUp.z * cos) - (sin * tempX); - - tempX = this->axisLeft.x; - this->axisLeft.x = (this->axisLeft.z * sin) + (cos * tempX); - this->axisLeft.z = (this->axisLeft.z * cos) - (sin * tempX); - } - } - - this->actionFunc(this, globalCtx); - func_8002D97C(&this->actor); - - this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; - this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->actionFunc != EnBomChu_WaitForRelease) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - Actor_SetFocus(&this->actor, 0.0f); - - if (this->actionFunc == EnBomChu_Move) { - this->visualJitter = - (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS(((Rand_ZeroOne() * (f32)0x200) + (f32)0x3000) * this->timer); - - EnBomChu_ModelToWorld(this, &blureP1Model, &blureP1); - - EnBomChu_ModelToWorld(this, &blureP2LeftModel, &blureP2); - EffectBlure_AddVertex(Effect_GetByIndex(this->blure1Index), &blureP1, &blureP2); - - EnBomChu_ModelToWorld(this, &blureP2RightModel, &blureP2); - EffectBlure_AddVertex(Effect_GetByIndex(this->blure2Index), &blureP1, &blureP2); - - waterY = this->actor.world.pos.y; - - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterY, &waterBox)) { - this->actor.yDistToWater = waterY - this->actor.world.pos.y; - - if (this->actor.yDistToWater < 0.0f) { - if (this->actor.bgCheckFlags & 0x20) { - EnBomChu_SpawnRipples(this, globalCtx, waterY); - } - - this->actor.bgCheckFlags &= ~0x20; - } else { - if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { - EnBomChu_SpawnRipples(this, globalCtx, waterY); - } else { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); - } - - this->actor.bgCheckFlags |= 0x20; - } - } else { - this->actor.bgCheckFlags &= ~0x20; - this->actor.yDistToWater = BGCHECK_Y_MIN; - } - } -} - -void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnBomChu* this = (EnBomChu*)thisx; - f32 colorIntensity; - s32 blinkHalfPeriod; - s32 blinkTime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_chu.c", 921); - - func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); - - if (this->timer >= 40) { - blinkTime = this->timer % 20; - blinkHalfPeriod = 10; - } else if (this->timer >= 10) { - blinkTime = this->timer % 10; - blinkHalfPeriod = 5; - } else { - blinkTime = this->timer & 1; - blinkHalfPeriod = 1; - } - - if (blinkTime > blinkHalfPeriod) { - blinkTime = 2 * blinkHalfPeriod - blinkTime; - } - - colorIntensity = blinkTime / (f32)blinkHalfPeriod; - - gDPSetEnvColor(POLY_OPA_DISP++, 9.0f + (colorIntensity * 209.0f), 9.0f + (colorIntensity * 34.0f), - 35.0f + (colorIntensity * -35.0f), 255); - Matrix_Translate(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bom_chu.c", 956), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_chu.c", 961); -} diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.cpp b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.cpp new file mode 100644 index 000000000..6f3ca2114 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.cpp @@ -0,0 +1,531 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOM_CHU_Z_EN_BOM_CHU_C +#include "actor_common.h" +#include "z_en_bom_chu.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800430A0.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +#define BOMBCHU_SCALE 0.01f + +void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBomChu_WaitForRelease(EnBomChu* pthis, GlobalContext* globalCtx); +void EnBomChu_Move(EnBomChu* pthis, GlobalContext* globalCtx); +void EnBomChu_WaitForKill(EnBomChu* pthis, GlobalContext* globalCtx); + +ActorInit En_Bom_Chu_InitVars = { + ACTOR_EN_BOM_CHU, + ACTORCAT_EXPLOSIVE, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnBomChu), + (ActorFunc)EnBomChu_Init, + (ActorFunc)EnBomChu_Destroy, + (ActorFunc)EnBomChu_Update, + (ActorFunc)EnBomChu_Draw, +}; + +static ColliderJntSphElementInit sJntSphElemInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 1, { { 0, 0, 0 }, 12 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElemInit), + sJntSphElemInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 1000 * BOMBCHU_SCALE, ICHAIN_STOP), +}; + +void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { + static u8 p1StartColor[] = { 250, 0, 0, 250 }; + static u8 p2StartColor[] = { 200, 0, 0, 130 }; + static u8 p1EndColor[] = { 150, 0, 0, 100 }; + static u8 p2EndColor[] = { 100, 0, 0, 50 }; + EnBomChu* pthis = (EnBomChu*)thisx; + EffectBlureInit1 blureInit; + s32 i; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderElements); + + pthis->collider.elements[0].dim.worldSphere.radius = pthis->collider.elements[0].dim.modelSphere.radius; + + for (i = 0; i < 4; i++) { + blureInit.p1StartColor[i] = p1StartColor[i]; + blureInit.p2StartColor[i] = p2StartColor[i]; + blureInit.p1EndColor[i] = p1EndColor[i]; + blureInit.p2EndColor[i] = p2EndColor[i]; + } + + blureInit.elemDuration = 16; + blureInit.unkFlag = 0; + blureInit.calcMode = 0; + + Effect_Add(globalCtx, &pthis->blure1Index, EFFECT_BLURE1, 0, 0, &blureInit); + Effect_Add(globalCtx, &pthis->blure2Index, EFFECT_BLURE1, 0, 0, &blureInit); + + pthis->actor.room = -1; + pthis->timer = 120; + pthis->actionFunc = EnBomChu_WaitForRelease; +} + +void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* pthis = (EnBomChu*)thisx; + + Effect_Delete(globalCtx, pthis->blure1Index); + Effect_Delete(globalCtx, pthis->blure2Index); + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnBomChu_Explode(EnBomChu* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + s32 i; + + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, BOMB_BODY); + if (bomb != NULL) { + bomb->timer = 0; + } + + pthis->timer = 1; + pthis->actor.speedXZ = 0.0f; + + if (pthis->actor.yDistToWater > 0.0f) { + for (i = 0; i < 40; i++) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); + } + } + + pthis->actionFunc = EnBomChu_WaitForKill; +} + +void EnBomChu_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dest) { + dest->x = (a->y * b->z) - (a->z * b->y); + dest->y = (a->z * b->x) - (a->x * b->z); + dest->z = (a->x * b->y) - (a->y * b->x); +} + +void EnBomChu_UpdateFloorPoly(EnBomChu* pthis, CollisionPoly* floorPoly, GlobalContext* globalCtx) { + Vec3f normal; + Vec3f vec; + f32 angle; + f32 magnitude; + f32 normDotUp; + MtxF mf; + + pthis->actor.floorPoly = floorPoly; + + normal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + + normDotUp = DOTXYZ(normal, pthis->axisUp); + + if (!(fabsf(normDotUp) >= 1.0f)) { + angle = Math_FAcosF(normDotUp); + + if (!(angle < 0.001f)) { + EnBomChu_CrossProduct(&pthis->axisUp, &normal, &vec); + //! @bug pthis function expects a unit vector but `vec` is not normalized + Matrix_RotateAxis(angle, &vec, MTXMODE_NEW); + + Matrix_MultVec3f(&pthis->axisLeft, &vec); + pthis->axisLeft = vec; + + EnBomChu_CrossProduct(&pthis->axisLeft, &normal, &pthis->axisForwards); + + magnitude = Math3D_Vec3fMagnitude(&pthis->axisForwards); + + if (magnitude < 0.001f) { + EnBomChu_Explode(pthis, globalCtx); + return; + } + + pthis->axisForwards.x *= 1.0f / magnitude; + pthis->axisForwards.y *= 1.0f / magnitude; + pthis->axisForwards.z *= 1.0f / magnitude; + + pthis->axisUp = normal; + + if (1) {} + + // mf = (axisLeft | axisUp | axisForwards) + + mf.xx = pthis->axisLeft.x; + mf.yx = pthis->axisLeft.y; + mf.zx = pthis->axisLeft.z; + + mf.xy = normal.x; + mf.yy = normal.y; + mf.zy = normal.z; + + mf.xz = pthis->axisForwards.x; + mf.yz = pthis->axisForwards.y; + mf.zz = pthis->axisForwards.z; + + Matrix_MtxFToYXZRotS(&mf, &pthis->actor.world.rot, 0); + + // A hack for preventing bombchus from sticking to ledges. + // The visual rotation reverts the sign inversion (shape.rot.x = -world.rot.x). + // The better fix would be making func_8002D908 compute XYZ velocity better, + // or not using it and make the bombchu compute its own velocity. + pthis->actor.world.rot.x = -pthis->actor.world.rot.x; + } + } +} + +void EnBomChu_WaitForRelease(EnBomChu* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + EnBomChu_Explode(pthis, globalCtx); + return; + } + + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + pthis->actor.world.pos = player->actor.world.pos; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actor.shape.rot.y = player->actor.shape.rot.y; + + // rot.y = 0 -> +z (forwards in model space) + pthis->axisForwards.x = Math_SinS(pthis->actor.shape.rot.y); + pthis->axisForwards.y = 0.0f; + pthis->axisForwards.z = Math_CosS(pthis->actor.shape.rot.y); + + // +y (up in model space) + pthis->axisUp.x = 0.0f; + pthis->axisUp.y = 1.0f; + pthis->axisUp.z = 0.0f; + + // rot.y = 0 -> +x (left in model space) + pthis->axisLeft.x = Math_SinS(pthis->actor.shape.rot.y + 0x4000); + pthis->axisLeft.y = 0; + pthis->axisLeft.z = Math_CosS(pthis->actor.shape.rot.y + 0x4000); + + pthis->actor.speedXZ = 8.0f; + //! @bug there is no NULL check on the floor poly. If the player is out of bounds the floor poly will be NULL + //! and will cause a crash inside pthis function. + EnBomChu_UpdateFloorPoly(pthis, pthis->actor.floorPoly, globalCtx); + pthis->actor.flags |= ACTOR_FLAG_0; // make chu targetable + func_8002F850(globalCtx, &pthis->actor); + pthis->actionFunc = EnBomChu_Move; + } +} + +void EnBomChu_Move(EnBomChu* pthis, GlobalContext* globalCtx) { + CollisionPoly* polySide; + CollisionPoly* polyUpDown; + s32 bgIdSide; + s32 bgIdUpDown; + s32 i; + f32 lineLength; + Vec3f posA; + Vec3f posB; + Vec3f posSide; + Vec3f posUpDown; + + pthis->actor.speedXZ = 8.0f; + lineLength = pthis->actor.speedXZ * 2.0f; + + if (pthis->timer != 0) { + pthis->timer--; + } + + if ((pthis->timer == 0) || (pthis->collider.base.acFlags & AC_HIT) || + ((pthis->collider.base.ocFlags1 & OC1_HIT) && (pthis->collider.base.oc->category != ACTORCAT_PLAYER))) { + EnBomChu_Explode(pthis, globalCtx); + return; + } + + posA.x = pthis->actor.world.pos.x + (pthis->axisUp.x * 2.0f); + posA.y = pthis->actor.world.pos.y + (pthis->axisUp.y * 2.0f); + posA.z = pthis->actor.world.pos.z + (pthis->axisUp.z * 2.0f); + + posB.x = pthis->actor.world.pos.x - (pthis->axisUp.x * 4.0f); + posB.y = pthis->actor.world.pos.y - (pthis->axisUp.y * 4.0f); + posB.z = pthis->actor.world.pos.z - (pthis->axisUp.z * 4.0f); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posUpDown, &polyUpDown, true, true, true, true, + &bgIdUpDown) && + !(func_80041DB8(&globalCtx->colCtx, polyUpDown, bgIdUpDown) & 0x30) && // && not crawl space? + !SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, polyUpDown, bgIdUpDown)) { + // forwards + posB.x = (pthis->axisForwards.x * lineLength) + posA.x; + posB.y = (pthis->axisForwards.y * lineLength) + posA.y; + posB.z = (pthis->axisForwards.z * lineLength) + posA.z; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posSide, &polySide, true, true, true, true, + &bgIdSide) && + !(func_80041DB8(&globalCtx->colCtx, polySide, bgIdSide) & 0x30) && + !SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, polySide, bgIdSide)) { + EnBomChu_UpdateFloorPoly(pthis, polySide, globalCtx); + pthis->actor.world.pos = posSide; + pthis->actor.floorBgId = bgIdSide; + pthis->actor.speedXZ = 0.0f; + } else { + if (pthis->actor.floorPoly != polyUpDown) { + EnBomChu_UpdateFloorPoly(pthis, polyUpDown, globalCtx); + } + + pthis->actor.world.pos = posUpDown; + pthis->actor.floorBgId = bgIdUpDown; + } + } else { + pthis->actor.speedXZ = 0.0f; + lineLength *= 3.0f; + posA = posB; + + for (i = 0; i < 3; i++) { + if (i == 0) { + // backwards + posB.x = posA.x - (pthis->axisForwards.x * lineLength); + posB.y = posA.y - (pthis->axisForwards.y * lineLength); + posB.z = posA.z - (pthis->axisForwards.z * lineLength); + } else if (i == 1) { + // left + posB.x = posA.x + (pthis->axisLeft.x * lineLength); + posB.y = posA.y + (pthis->axisLeft.y * lineLength); + posB.z = posA.z + (pthis->axisLeft.z * lineLength); + } else { + // right + posB.x = posA.x - (pthis->axisLeft.x * lineLength); + posB.y = posA.y - (pthis->axisLeft.y * lineLength); + posB.z = posA.z - (pthis->axisLeft.z * lineLength); + } + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posSide, &polySide, true, true, true, true, + &bgIdSide) && + !(func_80041DB8(&globalCtx->colCtx, polySide, bgIdSide) & 0x30) && + !SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, polySide, bgIdSide)) { + EnBomChu_UpdateFloorPoly(pthis, polySide, globalCtx); + pthis->actor.world.pos = posSide; + pthis->actor.floorBgId = bgIdSide; + break; + } + } + + if (i == 3) { + // no collision nearby + EnBomChu_Explode(pthis, globalCtx); + } + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -pthis->actor.world.rot.x, 0x800); + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 0x800); + Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->actor.world.rot.z, 0x800); + + func_8002F8F0(&pthis->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); +} + +void EnBomChu_WaitForKill(EnBomChu* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); + } +} + +/** + * Transform coordinates from model space to world space, according to current orientation. + * `posModel` is expected to already be at world scale (1/100 compared to model scale) + */ +void EnBomChu_ModelToWorld(EnBomChu* pthis, Vec3f* posModel, Vec3f* dest) { + f32 x = posModel->x + pthis->visualJitter; + + dest->x = pthis->actor.world.pos.x + (pthis->axisLeft.x * x) + (pthis->axisUp.x * posModel->y) + + (pthis->axisForwards.x * posModel->z); + dest->y = pthis->actor.world.pos.y + (pthis->axisLeft.y * x) + (pthis->axisUp.y * posModel->y) + + (pthis->axisForwards.y * posModel->z); + dest->z = pthis->actor.world.pos.z + (pthis->axisLeft.z * x) + (pthis->axisUp.z * posModel->y) + + (pthis->axisForwards.z * posModel->z); +} + +void EnBomChu_SpawnRipples(EnBomChu* pthis, GlobalContext* globalCtx, f32 y) { + Vec3f pos; + + pos.x = pthis->actor.world.pos.x; + pos.y = y; + pos.z = pthis->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); +} + +void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx2) { + static Vec3f blureP1Model = { 0.0f, 7.0f, -6.0f }; + static Vec3f blureP2LeftModel = { 12.0f, 0.0f, -5.0f }; + static Vec3f blureP2RightModel = { -12.0f, 0.0f, -5.0f }; + GlobalContext* globalCtx = globalCtx2; + EnBomChu* pthis = (EnBomChu*)thisx; + s16 yaw; + f32 sin; + f32 cos; + f32 tempX; + Vec3f blureP1; + Vec3f blureP2; + WaterBox* waterBox; + f32 waterY; + + if (pthis->actor.floorBgId != BGCHECK_SCENE) { + yaw = pthis->actor.shape.rot.y; + func_800433A4(&globalCtx->colCtx, pthis->actor.floorBgId, &pthis->actor); + + if (yaw != pthis->actor.shape.rot.y) { + yaw = pthis->actor.shape.rot.y - yaw; + + sin = Math_SinS(yaw); + cos = Math_CosS(yaw); + + tempX = pthis->axisForwards.x; + pthis->axisForwards.x = (pthis->axisForwards.z * sin) + (cos * tempX); + pthis->axisForwards.z = (pthis->axisForwards.z * cos) - (sin * tempX); + + tempX = pthis->axisUp.x; + pthis->axisUp.x = (pthis->axisUp.z * sin) + (cos * tempX); + pthis->axisUp.z = (pthis->axisUp.z * cos) - (sin * tempX); + + tempX = pthis->axisLeft.x; + pthis->axisLeft.x = (pthis->axisLeft.z * sin) + (cos * tempX); + pthis->axisLeft.z = (pthis->axisLeft.z * cos) - (sin * tempX); + } + } + + pthis->actionFunc(pthis, globalCtx); + func_8002D97C(&pthis->actor); + + pthis->collider.elements[0].dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->collider.elements[0].dim.worldSphere.center.y = pthis->actor.world.pos.y; + pthis->collider.elements[0].dim.worldSphere.center.z = pthis->actor.world.pos.z; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->actionFunc != EnBomChu_WaitForRelease) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + Actor_SetFocus(&pthis->actor, 0.0f); + + if (pthis->actionFunc == EnBomChu_Move) { + pthis->visualJitter = + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS(((Rand_ZeroOne() * (f32)0x200) + (f32)0x3000) * pthis->timer); + + EnBomChu_ModelToWorld(pthis, &blureP1Model, &blureP1); + + EnBomChu_ModelToWorld(pthis, &blureP2LeftModel, &blureP2); + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blure1Index), &blureP1, &blureP2); + + EnBomChu_ModelToWorld(pthis, &blureP2RightModel, &blureP2); + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blure2Index), &blureP1, &blureP2); + + waterY = pthis->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, + &waterY, &waterBox)) { + pthis->actor.yDistToWater = waterY - pthis->actor.world.pos.y; + + if (pthis->actor.yDistToWater < 0.0f) { + if (pthis->actor.bgCheckFlags & 0x20) { + EnBomChu_SpawnRipples(pthis, globalCtx, waterY); + } + + pthis->actor.bgCheckFlags &= ~0x20; + } else { + if (!(pthis->actor.bgCheckFlags & 0x20) && (pthis->timer != 120)) { + EnBomChu_SpawnRipples(pthis, globalCtx, waterY); + } else { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); + } + + pthis->actor.bgCheckFlags |= 0x20; + } + } else { + pthis->actor.bgCheckFlags &= ~0x20; + pthis->actor.yDistToWater = BGCHECK_Y_MIN; + } + } +} + +void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBomChu* pthis = (EnBomChu*)thisx; + f32 colorIntensity; + s32 blinkHalfPeriod; + s32 blinkTime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_chu.c", 921); + + func_80093D18(globalCtx->state.gfxCtx); + func_8002EBCC(&pthis->actor, globalCtx, 0); + + if (pthis->timer >= 40) { + blinkTime = pthis->timer % 20; + blinkHalfPeriod = 10; + } else if (pthis->timer >= 10) { + blinkTime = pthis->timer % 10; + blinkHalfPeriod = 5; + } else { + blinkTime = pthis->timer & 1; + blinkHalfPeriod = 1; + } + + if (blinkTime > blinkHalfPeriod) { + blinkTime = 2 * blinkHalfPeriod - blinkTime; + } + + colorIntensity = blinkTime / (f32)blinkHalfPeriod; + + gDPSetEnvColor(POLY_OPA_DISP++, 9.0f + (colorIntensity * 209.0f), 9.0f + (colorIntensity * 34.0f), + 35.0f + (colorIntensity * -35.0f), 255); + Matrix_Translate(pthis->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bom_chu.c", 956), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bom_chu.c", 961); +} diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.cpp similarity index 62% rename from src/overlays/actors/ovl_En_Bombf/z_en_bombf.c rename to src/overlays/actors/ovl_En_Bombf/z_en_bombf.cpp index 2c9623322..77ee1567b 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.cpp @@ -27,13 +27,13 @@ void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnBombf_Move(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_GrowBomb(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_WaitForRelease(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_Explode(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_SetupGrowBomb(EnBombf* this, s16 params); +void EnBombf_Move(EnBombf* pthis, GlobalContext* globalCtx); +void EnBombf_GrowBomb(EnBombf* pthis, GlobalContext* globalCtx); +void EnBombf_WaitForRelease(EnBombf* pthis, GlobalContext* globalCtx); +void EnBombf_Explode(EnBombf* pthis, GlobalContext* globalCtx); +void EnBombf_SetupGrowBomb(EnBombf* pthis, s16 params); -const ActorInit En_Bombf_InitVars = { +ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, ACTORCAT_PROP, FLAGS, @@ -92,21 +92,21 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnBombf_SetupAction(EnBombf* pthis, EnBombfActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx) { f32 shapeUnk10 = 0.0f; s32 pad; - EnBombf* this = (EnBombf*)thisx; + EnBombf* pthis = (EnBombf*)thisx; Actor_SetScale(thisx, 0.01f); - this->unk_200 = 1; - Collider_InitCylinder(globalCtx, &this->bombCollider); - Collider_InitJntSph(globalCtx, &this->explosionCollider); - Collider_SetCylinder(globalCtx, &this->bombCollider, thisx, &sCylinderInit); - Collider_SetJntSph(globalCtx, &this->explosionCollider, thisx, &sJntSphInit, &this->explosionColliderItems[0]); + pthis->unk_200 = 1; + Collider_InitCylinder(globalCtx, &pthis->bombCollider); + Collider_InitJntSph(globalCtx, &pthis->explosionCollider); + Collider_SetCylinder(globalCtx, &pthis->bombCollider, thisx, &sCylinderInit); + Collider_SetJntSph(globalCtx, &pthis->explosionCollider, thisx, &sJntSphInit, &pthis->explosionColliderItems[0]); if (thisx->params == BOMBFLOWER_BODY) { shapeUnk10 = 1000.0f; @@ -124,18 +124,18 @@ void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->targetMode = 0; if (thisx->params == BOMBFLOWER_BODY) { - this->timer = 140; - this->flashSpeedScale = 15; + pthis->timer = 140; + pthis->flashSpeedScale = 15; thisx->gravity = -1.5f; Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_EXPLOSIVE); thisx->colChkInfo.mass = 200; thisx->flags &= ~ACTOR_FLAG_0; - EnBombf_SetupAction(this, EnBombf_Move); + EnBombf_SetupAction(pthis, EnBombf_Move); } else { thisx->colChkInfo.mass = MASS_IMMOVABLE; - this->bumpOn = true; - this->flowerBombScale = 1.0f; - EnBombf_SetupGrowBomb(this, thisx->params); + pthis->bumpOn = true; + pthis->flowerBombScale = 1.0f; + EnBombf_SetupGrowBomb(pthis, thisx->params); } thisx->uncullZoneScale += 31000.0f; @@ -143,147 +143,147 @@ void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBombf* this = (EnBombf*)thisx; + EnBombf* pthis = (EnBombf*)thisx; - Collider_DestroyCylinder(globalCtx, &this->bombCollider); - Collider_DestroyJntSph(globalCtx, &this->explosionCollider); + Collider_DestroyCylinder(globalCtx, &pthis->bombCollider); + Collider_DestroyJntSph(globalCtx, &pthis->explosionCollider); } -void EnBombf_SetupGrowBomb(EnBombf* this, s16 params) { - EnBombf_SetupAction(this, EnBombf_GrowBomb); +void EnBombf_SetupGrowBomb(EnBombf* pthis, s16 params) { + EnBombf_SetupAction(pthis, EnBombf_GrowBomb); } -void EnBombf_GrowBomb(EnBombf* this, GlobalContext* globalCtx) { +void EnBombf_GrowBomb(EnBombf* pthis, GlobalContext* globalCtx) { EnBombf* bombFlower; s32 pad; s32 pad1; Player* player = GET_PLAYER(globalCtx); s32 pad2; - if (this->flowerBombScale >= 1.0f) { - if (Actor_HasParent(&this->actor, globalCtx)) { - bombFlower = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + if (pthis->flowerBombScale >= 1.0f) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + bombFlower = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); if (bombFlower != NULL) { - func_8002F5C4(&this->actor, &bombFlower->actor, globalCtx); - this->timer = 180; - this->flowerBombScale = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_PL_PULL_UP_ROCK); - this->actor.flags &= ~ACTOR_FLAG_0; + func_8002F5C4(&pthis->actor, &bombFlower->actor, globalCtx); + pthis->timer = 180; + pthis->flowerBombScale = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_PULL_UP_ROCK); + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; - this->actor.parent = NULL; + pthis->actor.parent = NULL; player->stateFlags1 &= ~0x800; } - } else if (this->bombCollider.base.acFlags & AC_HIT) { - this->bombCollider.base.acFlags &= ~AC_HIT; + } else if (pthis->bombCollider.base.acFlags & AC_HIT) { + pthis->bombCollider.base.acFlags &= ~AC_HIT; - if (this->bombCollider.base.ac->category != ACTORCAT_BOSS) { + if (pthis->bombCollider.base.ac->category != ACTORCAT_BOSS) { bombFlower = - (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); if (bombFlower != NULL) { bombFlower->unk_200 = 1; bombFlower->timer = 0; - this->timer = 180; - this->actor.flags &= ~ACTOR_FLAG_0; - this->flowerBombScale = 0.0f; + pthis->timer = 180; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->flowerBombScale = 0.0f; } } } else { - if (Player_IsBurningStickInRange(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + if (Player_IsBurningStickInRange(globalCtx, &pthis->actor.world.pos, 30.0f, 50.0f)) { bombFlower = - (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); if (bombFlower != NULL) { bombFlower->timer = 100; - this->timer = 180; - this->actor.flags &= ~ACTOR_FLAG_0; - this->flowerBombScale = 0.0f; + pthis->timer = 180; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->flowerBombScale = 0.0f; } } else { - if (!Actor_HasParent(&this->actor, globalCtx)) { - func_8002F580(&this->actor, globalCtx); + if (!Actor_HasParent(&pthis->actor, globalCtx)) { + func_8002F580(&pthis->actor, globalCtx); } else { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; - this->actor.parent = NULL; + pthis->actor.parent = NULL; player->stateFlags1 &= ~0x800; - this->actor.world.pos = this->actor.home.pos; + pthis->actor.world.pos = pthis->actor.home.pos; } } } } else { - if (this->timer == 0) { - this->flowerBombScale += 0.05f; - if (this->flowerBombScale >= 1.0f) { - this->actor.flags |= ACTOR_FLAG_0; + if (pthis->timer == 0) { + pthis->flowerBombScale += 0.05f; + if (pthis->flowerBombScale >= 1.0f) { + pthis->actor.flags |= ACTOR_FLAG_0; } } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; - this->actor.parent = NULL; + pthis->actor.parent = NULL; player->stateFlags1 &= ~0x800; - this->actor.world.pos = this->actor.home.pos; + pthis->actor.world.pos = pthis->actor.home.pos; } } } -void EnBombf_Move(EnBombf* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnBombf_Move(EnBombf* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { // setting flowerBombScale does not do anything in the context of a bomb that link picks up - // this and the assignment below are probably left overs - this->flowerBombScale = 0.0f; - EnBombf_SetupAction(this, EnBombf_WaitForRelease); - this->actor.room = -1; + // pthis and the assignment below are probably left overs + pthis->flowerBombScale = 0.0f; + EnBombf_SetupAction(pthis, EnBombf_WaitForRelease); + pthis->actor.room = -1; return; } - this->flowerBombScale = 1.0f; + pthis->flowerBombScale = 1.0f; - if (!(this->actor.bgCheckFlags & 1)) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f); + if (!(pthis->actor.bgCheckFlags & 1)) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f); } else { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); - if ((this->actor.bgCheckFlags & 2) && (this->actor.velocity.y < -6.0f)) { - func_8002F850(globalCtx, &this->actor); - this->actor.velocity.y *= -0.5f; - } else if (this->timer >= 4) { - func_8002F580(&this->actor, globalCtx); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); + if ((pthis->actor.bgCheckFlags & 2) && (pthis->actor.velocity.y < -6.0f)) { + func_8002F850(globalCtx, &pthis->actor); + pthis->actor.velocity.y *= -0.5f; + } else if (pthis->timer >= 4) { + func_8002F580(&pthis->actor, globalCtx); } } } -void EnBombf_WaitForRelease(EnBombf* this, GlobalContext* globalCtx) { +void EnBombf_WaitForRelease(EnBombf* pthis, GlobalContext* globalCtx) { // if parent is NULL bomb has been released - if (Actor_HasNoParent(&this->actor, globalCtx)) { - EnBombf_SetupAction(this, EnBombf_Move); - EnBombf_Move(this, globalCtx); + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + EnBombf_SetupAction(pthis, EnBombf_Move); + EnBombf_Move(pthis, globalCtx); } else { - this->actor.velocity.y = 0.0f; + pthis->actor.velocity.y = 0.0f; } } -void EnBombf_Explode(EnBombf* this, GlobalContext* globalCtx) { +void EnBombf_Explode(EnBombf* pthis, GlobalContext* globalCtx) { Player* player; - if (this->explosionCollider.elements[0].dim.modelSphere.radius == 0) { - this->actor.flags |= ACTOR_FLAG_5; - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + if (pthis->explosionCollider.elements[0].dim.modelSphere.radius == 0) { + pthis->actor.flags |= ACTOR_FLAG_5; + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); } - this->explosionCollider.elements[0].dim.modelSphere.radius += 8; - this->explosionCollider.elements[0].dim.worldSphere.radius = - this->explosionCollider.elements[0].dim.modelSphere.radius; + pthis->explosionCollider.elements[0].dim.modelSphere.radius += 8; + pthis->explosionCollider.elements[0].dim.worldSphere.radius = + pthis->explosionCollider.elements[0].dim.modelSphere.radius; - if (this->actor.params == BOMBFLOWER_EXPLOSION) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->explosionCollider.base); + if (pthis->actor.params == BOMBFLOWER_EXPLOSION) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->explosionCollider.base); } if (globalCtx->envCtx.adjLight1Color[0] != 0) { @@ -310,17 +310,17 @@ void EnBombf_Explode(EnBombf* this, GlobalContext* globalCtx) { globalCtx->envCtx.adjAmbientColor[2] -= 25; } - if (this->timer == 0) { + if (pthis->timer == 0) { player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x800) && (player->heldActor == &this->actor)) { + if ((player->stateFlags1 & 0x800) && (player->heldActor == &pthis->actor)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; player->stateFlags1 &= ~0x800; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } @@ -332,18 +332,18 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f dustAccel = { 0.0f, 0.6f, 0.0f }; Color_RGBA8 dustColor = { 255, 255, 255, 255 }; s32 pad[2]; - EnBombf* this = (EnBombf*)thisx; + EnBombf* pthis = (EnBombf*)thisx; - if ((this->unk_200 != 0) && (this->timer != 0)) { - this->timer--; + if ((pthis->unk_200 != 0) && (pthis->timer != 0)) { + pthis->timer--; } - if ((!this->bumpOn) && (!Actor_HasParent(thisx, globalCtx)) && + if ((!pthis->bumpOn) && (!Actor_HasParent(thisx, globalCtx)) && ((thisx->xzDistToPlayer >= 20.0f) || (ABS(thisx->yDistToPlayer) >= 80.0f))) { - this->bumpOn = true; + pthis->bumpOn = true; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); if (thisx->params == BOMBFLOWER_BODY) { Actor_MoveForward(thisx); @@ -377,22 +377,22 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { thisx->bgCheckFlags &= ~8; } - if ((this->bombCollider.base.acFlags & AC_HIT) || ((this->bombCollider.base.ocFlags1 & OC1_HIT) && - (this->bombCollider.base.oc->category == ACTORCAT_ENEMY))) { - this->unk_200 = 1; - this->timer = 0; + if ((pthis->bombCollider.base.acFlags & AC_HIT) || ((pthis->bombCollider.base.ocFlags1 & OC1_HIT) && + (pthis->bombCollider.base.oc->category == ACTORCAT_ENEMY))) { + pthis->unk_200 = 1; + pthis->timer = 0; } else { // if a lit stick touches the bomb, set timer to 100 - if ((this->timer > 100) && Player_IsBurningStickInRange(globalCtx, &thisx->world.pos, 30.0f, 50.0f)) { - this->timer = 100; + if ((pthis->timer > 100) && Player_IsBurningStickInRange(globalCtx, &thisx->world.pos, 30.0f, 50.0f)) { + pthis->timer = 100; } } - if (this->unk_200 != 0) { + if (pthis->unk_200 != 0) { dustAccel.y = 0.2f; effPos = thisx->world.pos; effPos.y += 25.0f; - if (this->timer < 127) { + if (pthis->timer < 127) { // spawn spark effect on even frames if ((globalCtx->gameplayFrames % 2) == 0) { EffectSsGSpk_SpawnFuse(globalCtx, thisx, &effPos, &effVelocity, &effAccel); @@ -404,21 +404,21 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { } // double bomb flash speed and adjust red color at certain times during the countdown - if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) { - this->flashSpeedScale >>= 1; + if ((pthis->timer == 3) || (pthis->timer == 30) || (pthis->timer == 50) || (pthis->timer == 70)) { + pthis->flashSpeedScale >>= 1; } - if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { - Math_SmoothStepToF(&this->flashIntensity, 150.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); + if ((pthis->timer < 100) && ((pthis->timer & (pthis->flashSpeedScale + 1)) != 0)) { + Math_SmoothStepToF(&pthis->flashIntensity, 150.0f, 1.0f, 150.0f / pthis->flashSpeedScale, 0.0f); } else { - Math_SmoothStepToF(&this->flashIntensity, 0.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); + Math_SmoothStepToF(&pthis->flashIntensity, 0.0f, 1.0f, 150.0f / pthis->flashSpeedScale, 0.0f); } - if (this->timer < 3) { + if (pthis->timer < 3) { Actor_SetScale(thisx, thisx->scale.x + 0.002f); } - if (this->timer == 0) { + if (pthis->timer == 0) { effPos = thisx->world.pos; effPos.y += 10.0f; @@ -441,9 +441,9 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->envCtx.adjAmbientColor[2] = 250; Camera_AddQuake(&globalCtx->mainCamera, 2, 0xB, 8); thisx->params = BOMBFLOWER_EXPLOSION; - this->timer = 10; + pthis->timer = 10; thisx->flags |= ACTOR_FLAG_5; - EnBombf_SetupAction(this, EnBombf_Explode); + EnBombf_SetupAction(pthis, EnBombf_Explode); } } } @@ -453,13 +453,13 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { if (thisx->params <= BOMBFLOWER_BODY) { - Collider_UpdateCylinder(thisx, &this->bombCollider); + Collider_UpdateCylinder(thisx, &pthis->bombCollider); - if ((this->flowerBombScale >= 1.0f) && (this->bumpOn)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base); + if ((pthis->flowerBombScale >= 1.0f) && (pthis->bumpOn)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bombCollider.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bombCollider.base); } if ((thisx->scale.x >= 0.01f) && (thisx->params != BOMBFLOWER_EXPLOSION)) { @@ -480,7 +480,7 @@ Gfx* EnBombf_NewMtxDList(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { Gfx* displayList; Gfx* displayListHead; - displayList = Graph_Alloc(gfxCtx, 5 * sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(gfxCtx, 5 * sizeof(Gfx)); displayListHead = displayList; func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(displayListHead++, Matrix_NewMtx(gfxCtx, "../z_en_bombf.c", 1021), @@ -491,7 +491,7 @@ Gfx* EnBombf_NewMtxDList(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnBombf* this = (EnBombf*)thisx; + EnBombf* pthis = (EnBombf*)thisx; if (1) {} @@ -507,19 +507,19 @@ void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gBombFlowerBaseLeavesDL); Matrix_Translate(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(this->flowerBombScale, this->flowerBombScale, this->flowerBombScale, MTXMODE_APPLY); + Matrix_Scale(pthis->flowerBombScale, pthis->flowerBombScale, pthis->flowerBombScale, MTXMODE_APPLY); } gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 255, 200, 255); gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->flashIntensity, 20, 10, 0); + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->flashIntensity, 20, 10, 0); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bombf.c", 1054), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(EnBombf_NewMtxDList(globalCtx->state.gfxCtx, globalCtx))); gSPDisplayList(POLY_OPA_DISP++, gBombFlowerBombAndSparkDL); } else { - Collider_UpdateSpheres(0, &this->explosionCollider); + Collider_UpdateSpheres(0, &pthis->explosionCollider); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bombf.c", 1063); diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.cpp similarity index 66% rename from src/overlays/actors/ovl_En_Boom/z_en_boom.c rename to src/overlays/actors/ovl_En_Boom/z_en_boom.cpp index a36aba8b2..8dfefb464 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.cpp @@ -25,9 +25,9 @@ void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx); +void EnBoom_Fly(EnBoom* pthis, GlobalContext* globalCtx); -const ActorInit En_Boom_InitVars = { +ActorInit En_Boom_InitVars = { ACTOR_EN_BOOM, ACTORCAT_MISC, FLAGS, @@ -64,17 +64,17 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnBoom_SetupAction(EnBoom* pthis, EnBoomActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBoom* this = (EnBoom*)thisx; + EnBoom* pthis = (EnBoom*)thisx; EffectBlureInit1 blure; - this->actor.room = -1; + pthis->actor.room = -1; - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(&pthis->actor, sInitChain); blure.p1StartColor[0] = 255; blure.p1StartColor[1] = 255; @@ -100,22 +100,22 @@ void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx) { blure.unkFlag = 0; blure.calcMode = 0; - Effect_Add(globalCtx, &this->effectIndex, EFFECT_BLURE1, 0, 0, &blure); + Effect_Add(globalCtx, &pthis->effectIndex, EFFECT_BLURE1, 0, 0, &blure); - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + Collider_InitQuad(globalCtx, &pthis->collider); + Collider_SetQuad(globalCtx, &pthis->collider, &pthis->actor, &sQuadInit); - EnBoom_SetupAction(this, EnBoom_Fly); + EnBoom_SetupAction(pthis, EnBoom_Fly); } void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBoom* this = (EnBoom*)thisx; + EnBoom* pthis = (EnBoom*)thisx; - Effect_Delete(globalCtx, this->effectIndex); - Collider_DestroyQuad(globalCtx, &this->collider); + Effect_Delete(globalCtx, pthis->effectIndex); + Collider_DestroyQuad(globalCtx, &pthis->collider); } -void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { +void EnBoom_Fly(EnBoom* pthis, GlobalContext* globalCtx) { Actor* target; Player* player; s32 collided; @@ -132,17 +132,17 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { s32 pad2; player = GET_PLAYER(globalCtx); - target = this->moveTo; + target = pthis->moveTo; // If the boomerang is moving toward a targeted actor, handle setting the proper x and y angle to fly toward it. if (target != NULL) { - yawTarget = Actor_WorldYawTowardPoint(&this->actor, &target->focus.pos); - yawDiff = this->actor.world.rot.y - yawTarget; + yawTarget = Actor_WorldYawTowardPoint(&pthis->actor, &target->focus.pos); + yawDiff = pthis->actor.world.rot.y - yawTarget; - pitchTarget = Actor_WorldPitchTowardPoint(&this->actor, &target->focus.pos); - pitchDiff = this->actor.world.rot.x - pitchTarget; + pitchTarget = Actor_WorldPitchTowardPoint(&pthis->actor, &target->focus.pos); + pitchDiff = pthis->actor.world.rot.x - pitchTarget; - distXYZScale = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &target->focus.pos)) * 0.005f; + distXYZScale = (200.0f - Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &target->focus.pos)) * 0.005f; if (distXYZScale < 0.12f) { distXYZScale = 0.12f; } @@ -151,39 +151,39 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { //! @bug This condition is why the boomerang will randomly fly off in a the down left direction sometimes. // If the actor targetted is not Link and the difference between the 2 y angles is greater than 0x4000, // the moveTo pointer is nulled and it flies off in a seemingly random direction. - this->moveTo = NULL; + pthis->moveTo = NULL; } else { - Math_ScaledStepToS(&this->actor.world.rot.y, yawTarget, (s16)(ABS(yawDiff) * distXYZScale)); - Math_ScaledStepToS(&this->actor.world.rot.x, pitchTarget, (s16)(ABS(pitchDiff) * distXYZScale)); + Math_ScaledStepToS(&pthis->actor.world.rot.y, yawTarget, (s16)(ABS(yawDiff) * distXYZScale)); + Math_ScaledStepToS(&pthis->actor.world.rot.x, pitchTarget, (s16)(ABS(pitchDiff) * distXYZScale)); } } // Set xyz speed, move forward, and play the boomerang sound - func_8002D9A4(&this->actor, 12.0f); - Actor_MoveForward(&this->actor); - func_8002F974(&this->actor, NA_SE_IT_BOOMERANG_FLY - SFX_FLAG); + func_8002D9A4(&pthis->actor, 12.0f); + Actor_MoveForward(&pthis->actor); + func_8002F974(&pthis->actor, NA_SE_IT_BOOMERANG_FLY - SFX_FLAG); // If the boomerang collides with EnItem00 or a Skulltula token, set grabbed pointer to pick it up - collided = this->collider.base.atFlags & AT_HIT; + collided = pthis->collider.base.atFlags & AT_HIT; collided = !!(collided); if (collided) { - if (((this->collider.base.at->id == ACTOR_EN_ITEM00) || (this->collider.base.at->id == ACTOR_EN_SI))) { - this->grabbed = this->collider.base.at; - if (this->collider.base.at->id == ACTOR_EN_SI) { - this->collider.base.at->flags |= ACTOR_FLAG_13; + if (((pthis->collider.base.at->id == ACTOR_EN_ITEM00) || (pthis->collider.base.at->id == ACTOR_EN_SI))) { + pthis->grabbed = pthis->collider.base.at; + if (pthis->collider.base.at->id == ACTOR_EN_SI) { + pthis->collider.base.at->flags |= ACTOR_FLAG_13; } } } // Decrement the return timer and check if it's 0. If it is, check if Link can catch it and handle accordingly. // Otherwise handle grabbing and colliding. - if (DECR(this->returnTimer) == 0) { - distFromLink = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos); - this->moveTo = &player->actor; + if (DECR(pthis->returnTimer) == 0) { + distFromLink = Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &player->actor.focus.pos); + pthis->moveTo = &player->actor; // If the boomerang is less than 40 units away from Link, he can catch it. if (distFromLink < 40.0f) { - target = this->grabbed; + target = pthis->grabbed; if (target != NULL) { Math_Vec3f_Copy(&target->world.pos, &player->actor.world.pos); @@ -198,23 +198,23 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { } // Set player flags and kill the boomerang beacause Link caught it. player->stateFlags1 &= ~0x02000000; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } else { - collided = (this->collider.base.atFlags & AT_HIT); + collided = (pthis->collider.base.atFlags & AT_HIT); collided = (!!(collided)); if (collided) { // Copy the position from the prevous frame to the boomerang to start the bounce back. - Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + Math_Vec3f_Copy(&pthis->actor.world.pos, &pthis->actor.prevPos); } else { - collided = BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, - &hitPoint, &this->actor.wallPoly, true, true, true, true, &hitDynaID); + collided = BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.prevPos, &pthis->actor.world.pos, + &hitPoint, &pthis->actor.wallPoly, true, true, true, true, &hitDynaID); if (collided) { // If the boomerang collides with something and it's is a Jabu Object actor with params equal to 0, then // set collided to 0 so that the boomerang will go through the wall. // Otherwise play a clank sound and keep collided set to bounce back. - if (func_8002F9EC(globalCtx, &this->actor, this->actor.wallPoly, hitDynaID, &hitPoint) != 0 || + if (func_8002F9EC(globalCtx, &pthis->actor, pthis->actor.wallPoly, hitDynaID, &hitPoint) != 0 || (hitDynaID != BGCHECK_SCENE && ((hitActor = DynaPoly_GetActor(&globalCtx->colCtx, hitDynaID)) != NULL) && hitActor->actor.id == ACTOR_BG_BDAN_OBJECTS && hitActor->actor.params == 0)) { @@ -228,57 +228,57 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { // If the boomerang needs to bounce back, set x and y angle accordingly. // Set timer to 0 and set return actor to player so it goes back to Link. if (collided) { - this->actor.world.rot.x = -this->actor.world.rot.x; - this->actor.world.rot.y += 0x8000; - this->moveTo = &player->actor; - this->returnTimer = 0; + pthis->actor.world.rot.x = -pthis->actor.world.rot.x; + pthis->actor.world.rot.y += 0x8000; + pthis->moveTo = &player->actor; + pthis->returnTimer = 0; } } // If the actor the boomerang is holding has a null update function, set grabbed to null. // Otherwise, copy the position from the boomerang to the actor to move it. - target = this->grabbed; + target = pthis->grabbed; if (target != NULL) { if (target->update == NULL) { - this->grabbed = NULL; + pthis->grabbed = NULL; } else { - Math_Vec3f_Copy(&target->world.pos, &this->actor.world.pos); + Math_Vec3f_Copy(&target->world.pos, &pthis->actor.world.pos); } } } void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBoom* this = (EnBoom*)thisx; + EnBoom* pthis = (EnBoom*)thisx; Player* player = GET_PLAYER(globalCtx); if (!(player->stateFlags1 & 0x20000000)) { - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, 0.0f); - this->activeTimer = this->activeTimer + 1; + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 0.0f); + pthis->activeTimer = pthis->activeTimer + 1; } } void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { static Vec3f sMultVec1 = { -960.0f, 0.0f, 0.0f }; static Vec3f sMultVec2 = { 960.0f, 0.0f, 0.0f }; - EnBoom* this = (EnBoom*)thisx; + EnBoom* pthis = (EnBoom*)thisx; Vec3f vec1; Vec3f vec2; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_boom.c", 567); - Matrix_RotateY(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_RotateZ(0x1F40 * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX(this->actor.world.rot.x * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->actor.world.rot.x * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_MultVec3f(&sMultVec1, &vec1); Matrix_MultVec3f(&sMultVec2, &vec2); - if (func_80090480(globalCtx, &this->collider, &this->boomerangInfo, &vec1, &vec2) != 0) { - EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &vec1, &vec2); + if (func_80090480(globalCtx, &pthis->collider, &pthis->boomerangInfo, &vec1, &vec2) != 0) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->effectIndex), &vec1, &vec2); } func_80093D18(globalCtx->state.gfxCtx); - Matrix_RotateY((this->activeTimer * 12000) * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY((pthis->activeTimer * 12000) * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_boom.c", 601), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c deleted file mode 100644 index 4d216a5b3..000000000 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ /dev/null @@ -1,667 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOX_Z_EN_BOX_C -#include "actor_common.h" -#include "z_en_box.h" -#include "objects/object_box/object_box.h" -#include "def/code_80043480.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -// movement flags - -/* -set on init unless treasure flag is set -if clear, chest moves (Actor_MoveForward) (falls, likely) -ends up cleared from SWITCH_FLAG_FALL types when switch flag is set -*/ -#define ENBOX_MOVE_IMMOBILE (1 << 0) -/* -set in the logic for SWITCH_FLAG_FALL types -otherwise unused -*/ -#define ENBOX_MOVE_UNUSED (1 << 1) -/* -set with 50% chance on init for SWITCH_FLAG_FALL types -only used for SWITCH_FLAG_FALL types -ends up "blinking" (set/clear every frame) once switch flag is set, -if some collision-related condition (?) is met -only used for signum of z rotation -*/ -#define ENBOX_MOVE_FALL_ANGLE_SIDE (1 << 2) -/* -when set, gets cleared next EnBox_Update call and clip to the floor -*/ -#define ENBOX_MOVE_STICK_TO_GROUND (1 << 4) - -typedef enum { - ENBOX_STATE_0, // waiting for player near / player available / player ? (IDLE) - ENBOX_STATE_1, // used only temporarily, maybe "player is ready" ? - ENBOX_STATE_2 // waiting for something message context-related -} EnBoxStateUnk1FB; - -void EnBox_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBox_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBox_FallOnSwitchFlag(EnBox*, GlobalContext*); -void func_809C9700(EnBox*, GlobalContext*); -void EnBox_AppearOnSwitchFlag(EnBox*, GlobalContext*); -void EnBox_AppearOnRoomClear(EnBox*, GlobalContext*); -void EnBox_AppearInit(EnBox*, GlobalContext*); -void EnBox_AppearAnimation(EnBox*, GlobalContext*); -void EnBox_WaitOpen(EnBox*, GlobalContext*); -void EnBox_Open(EnBox*, GlobalContext*); - -const ActorInit En_Box_InitVars = { - ACTOR_EN_BOX, - ACTORCAT_CHEST, - FLAGS, - OBJECT_BOX, - sizeof(EnBox), - (ActorFunc)EnBox_Init, - (ActorFunc)EnBox_Destroy, - (ActorFunc)EnBox_Update, - (ActorFunc)EnBox_Draw, -}; - -static AnimationHeader* sAnimations[4] = { &gTreasureChestAnim_00024C, &gTreasureChestAnim_000128, - &gTreasureChestAnim_00043C, &gTreasureChestAnim_00043C }; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 0, ICHAIN_STOP), -}; - -static UNK_TYPE sUnused; - -void EnBox_SetupAction(EnBox* this, EnBoxActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnBox_ClipToGround(EnBox* this, GlobalContext* globalCtx) { - f32 newY; - CollisionPoly* poly; - s32 bgId; - Vec3f pos; - - pos = this->dyna.actor.world.pos; - pos.y += 1.0f; - newY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &poly, &bgId, &this->dyna.actor, &pos); - if (newY != BGCHECK_Y_MIN) { - this->dyna.actor.world.pos.y = newY; - } -} - -void EnBox_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnBox* this = (EnBox*)thisx; - AnimationHeader* anim; - CollisionHeader* colHeader; - f32 animFrameStart; - f32 endFrame; - - animFrameStart = 0.0f; - anim = sAnimations[((void)0, gSaveContext.linkAge)]; - colHeader = NULL; - endFrame = Animation_GetLastFrame(anim); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gTreasureChestCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - func_8003ECA8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - - this->movementFlags = 0; - this->type = thisx->params >> 12 & 0xF; - this->iceSmokeTimer = 0; - this->unk_1FB = ENBOX_STATE_0; - this->dyna.actor.gravity = -5.5f; - this->switchFlag = this->dyna.actor.world.rot.z; - this->dyna.actor.minVelocityY = -50.0f; - - if (globalCtx) {} // helps the compiler store globalCtx2 into s1 - - if (Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) { - this->alpha = 255; - this->iceSmokeTimer = 100; - EnBox_SetupAction(this, EnBox_Open); - this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; - animFrameStart = endFrame; - } else if ((this->type == ENBOX_TYPE_SWITCH_FLAG_FALL_BIG || this->type == ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL) && - !Flags_GetSwitch(globalCtx, this->switchFlag)) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - if (Rand_ZeroOne() < 0.5f) { - this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; - } - this->unk_1A8 = -12; - EnBox_SetupAction(this, EnBox_FallOnSwitchFlag); - this->alpha = 0; - this->movementFlags |= ENBOX_MOVE_IMMOBILE; - this->dyna.actor.flags |= ACTOR_FLAG_4; - } else if ((this->type == ENBOX_TYPE_ROOM_CLEAR_BIG || this->type == ENBOX_TYPE_ROOM_CLEAR_SMALL) && - !Flags_GetClear(globalCtx, this->dyna.actor.room)) { - EnBox_SetupAction(this, EnBox_AppearOnRoomClear); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->movementFlags |= ENBOX_MOVE_IMMOBILE; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; - this->alpha = 0; - this->dyna.actor.flags |= ACTOR_FLAG_4; - } else if (this->type == ENBOX_TYPE_9 || this->type == ENBOX_TYPE_10) { - EnBox_SetupAction(this, func_809C9700); - this->dyna.actor.flags |= ACTOR_FLAG_25; - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->movementFlags |= ENBOX_MOVE_IMMOBILE; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; - this->alpha = 0; - this->dyna.actor.flags |= ACTOR_FLAG_4; - } else if (this->type == ENBOX_TYPE_SWITCH_FLAG_BIG && !Flags_GetSwitch(globalCtx, this->switchFlag)) { - EnBox_SetupAction(this, EnBox_AppearOnSwitchFlag); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->movementFlags |= ENBOX_MOVE_IMMOBILE; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; - this->alpha = 0; - this->dyna.actor.flags |= ACTOR_FLAG_4; - } else { - if (this->type == ENBOX_TYPE_4 || this->type == ENBOX_TYPE_6) { - this->dyna.actor.flags |= ACTOR_FLAG_7; - } - EnBox_SetupAction(this, EnBox_WaitOpen); - this->movementFlags |= ENBOX_MOVE_IMMOBILE; - this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; - } - - this->dyna.actor.world.rot.y += 0x8000; - this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; - - SkelAnime_Init(globalCtx, &this->skelanime, &gTreasureChestSkel, anim, this->jointTable, this->morphTable, 5); - Animation_Change(&this->skelanime, anim, 1.5f, animFrameStart, endFrame, ANIMMODE_ONCE, 0.0f); - - switch (this->type) { - case ENBOX_TYPE_SMALL: - case ENBOX_TYPE_6: - case ENBOX_TYPE_ROOM_CLEAR_SMALL: - case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL: - Actor_SetScale(&this->dyna.actor, 0.005f); - Actor_SetFocus(&this->dyna.actor, 20.0f); - break; - default: - Actor_SetScale(&this->dyna.actor, 0.01f); - Actor_SetFocus(&this->dyna.actor, 40.0f); - } -} - -void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void EnBox_RandomDustKinematic(EnBox* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - f32 randomRadius = Rand_ZeroOne() * 25.0f; - s16 randomAngle = Rand_ZeroOne() * 0x10000; - - *pos = this->dyna.actor.world.pos; - pos->x += Math_SinS(randomAngle) * randomRadius; - pos->z += Math_CosS(randomAngle) * randomRadius; - - velocity->y = 1.0f; - velocity->x = Math_SinS(randomAngle); - velocity->z = Math_CosS(randomAngle); - - accel->x = 0.0f; - accel->y = 0.0f; - accel->z = 0.0f; -} - -/** - * Spawns dust randomly around the chest when the chest hits the ground after falling (FALL types) - */ -void EnBox_SpawnDust(EnBox* this, GlobalContext* globalCtx) { - s32 i; - Vec3f pos; - Vec3f velocity; - Vec3f accel; - - for (i = 0; i < 20; i++) { - EnBox_RandomDustKinematic(this, &pos, &velocity, &accel); - func_8002873C(globalCtx, &pos, &velocity, &accel, 100, 30, 15); - } -} - -/** - * Used while the chest is falling (FALL types) - */ -void EnBox_Fall(EnBox* this, GlobalContext* globalCtx) { - f32 yDiff; - - this->alpha = 255; - this->movementFlags &= ~ENBOX_MOVE_IMMOBILE; - if (this->dyna.actor.bgCheckFlags & 1) { - this->movementFlags |= ENBOX_MOVE_UNUSED; - if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { - this->movementFlags &= ~ENBOX_MOVE_FALL_ANGLE_SIDE; - } else { - this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; - } - if (this->type == ENBOX_TYPE_SWITCH_FLAG_FALL_BIG) { - this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.55f; - } else { - this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.65f; - } - if (this->dyna.actor.velocity.y < 5.5f) { - this->dyna.actor.shape.rot.z = 0; - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - EnBox_SetupAction(this, EnBox_WaitOpen); - OnePointCutscene_EndCutscene(globalCtx, this->unk_1AC); - } - Audio_PlaySoundGeneral(NA_SE_EV_COFFIN_CAP_BOUND, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - EnBox_SpawnDust(this, globalCtx); - } - yDiff = this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight; - if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { - this->dyna.actor.shape.rot.z = yDiff * 50.0f; - } else { - this->dyna.actor.shape.rot.z = -yDiff * 50.0f; - } -} - -void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx) { - s32 treasureFlag = this->dyna.actor.params & 0x1F; - - if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { - func_8002F5F0(&this->dyna.actor, globalCtx); - } - - if (this->unk_1A8 >= 0) { - EnBox_SetupAction(this, EnBox_Fall); - this->unk_1AC = OnePointCutscene_Init(globalCtx, 4500, 9999, &this->dyna.actor, MAIN_CAM); - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } else if (this->unk_1A8 >= -11) { - this->unk_1A8++; - } else if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->unk_1A8++; - } -} - -// used for types 9, 10 -void func_809C9700(EnBox* this, GlobalContext* globalCtx) { - s32 treasureFlag = this->dyna.actor.params & 0x1F; - Player* player = GET_PLAYER(globalCtx); - - if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { - func_8002F5F0(&this->dyna.actor, globalCtx); - } - - if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &player->actor.world.pos) > 22500.0f) { - this->unk_1FB = ENBOX_STATE_0; - } else { - if (this->unk_1FB == ENBOX_STATE_0) { - if (!(player->stateFlags2 & 0x1000000)) { - player->stateFlags2 |= 0x800000; - return; - } - this->unk_1FB = ENBOX_STATE_1; - } - - if (this->unk_1FB == ENBOX_STATE_1) { - func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); - this->unk_1FB = ENBOX_STATE_2; - } else if (this->unk_1FB == ENBOX_STATE_2 && globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - if ((globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_LULLABY && this->type == ENBOX_TYPE_9) || - (globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS && this->type == ENBOX_TYPE_10)) { - this->dyna.actor.flags &= ~ACTOR_FLAG_25; - EnBox_SetupAction(this, EnBox_AppearInit); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->unk_1A8 = 0; - this->unk_1FB = ENBOX_STATE_0; - } else { - this->unk_1FB = ENBOX_STATE_0; - } - } - } -} - -void EnBox_AppearOnSwitchFlag(EnBox* this, GlobalContext* globalCtx) { - s32 treasureFlag = this->dyna.actor.params & 0x1F; - - if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { - func_8002F5F0(&this->dyna.actor, globalCtx); - } - - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - EnBox_SetupAction(this, EnBox_AppearInit); - this->unk_1A8 = -30; - } -} - -void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { - s32 treasureFlag = this->dyna.actor.params & 0x1F; - - if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { - func_8002F5F0(&this->dyna.actor, globalCtx); - } - - if (Flags_GetTempClear(globalCtx, this->dyna.actor.room) && !Player_InCsMode(globalCtx)) { - Flags_SetClear(globalCtx, this->dyna.actor.room); - EnBox_SetupAction(this, EnBox_AppearInit); - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - if (OnePointCutscene_CheckForCategory(globalCtx, this->dyna.actor.category)) { - this->unk_1A8 = 0; - } else { - this->unk_1A8 = -30; - } - } -} - -/** - * The chest is ready to appear, possibly waiting for camera/cutscene-related stuff to happen - */ -void EnBox_AppearInit(EnBox* this, GlobalContext* globalCtx) { - if (func_8005B198() == this->dyna.actor.category || this->unk_1A8 != 0) { - EnBox_SetupAction(this, EnBox_AppearAnimation); - this->unk_1A8 = 0; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, this->dyna.actor.home.pos.x, - this->dyna.actor.home.pos.y, this->dyna.actor.home.pos.z, 0, 0, 0, 0x0011); - Audio_PlaySoundGeneral(NA_SE_EV_TRE_BOX_APPEAR, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void EnBox_AppearAnimation(EnBox* this, GlobalContext* globalCtx) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - - if (this->unk_1A8 < 0) { - this->unk_1A8++; - } else if (this->unk_1A8 < 40) { - this->unk_1A8++; - this->dyna.actor.world.pos.y += 1.25f; - } else if (this->unk_1A8 < 60) { - this->alpha += 12; - this->unk_1A8++; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - } else { - EnBox_SetupAction(this, EnBox_WaitOpen); - } -} - -/** - * Chest is ready to be open - */ -void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { - f32 frameCount; - AnimationHeader* anim; - s32 linkAge; - s32 pad; - Vec3f sp4C; - Player* player; - - this->alpha = 255; - this->movementFlags |= ENBOX_MOVE_IMMOBILE; - if (this->unk_1F4 != 0) { // unk_1F4 is modified by player code - linkAge = gSaveContext.linkAge; - anim = sAnimations[(this->unk_1F4 < 0 ? 2 : 0) + linkAge]; - frameCount = Animation_GetLastFrame(anim); - Animation_Change(&this->skelanime, anim, 1.5f, 0, frameCount, ANIMMODE_ONCE, 0.0f); - EnBox_SetupAction(this, EnBox_Open); - if (this->unk_1F4 > 0) { - switch (this->type) { - case ENBOX_TYPE_SMALL: - case ENBOX_TYPE_6: - case ENBOX_TYPE_ROOM_CLEAR_SMALL: - case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL: - break; - default: - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DEMO_TRE_LGT, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, - this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 0xFFFF); - Audio_PlayFanfare(NA_BGM_OPEN_TRE_BOX | 0x900); - } - } - osSyncPrintf("Actor_Environment_Tbox_On() %d\n", this->dyna.actor.params & 0x1F); - Flags_SetTreasure(globalCtx, this->dyna.actor.params & 0x1F); - } else { - player = GET_PLAYER(globalCtx); - func_8002DBD0(&this->dyna.actor, &sp4C, &player->actor.world.pos); - if (sp4C.z > -50.0f && sp4C.z < 0.0f && fabsf(sp4C.y) < 10.0f && fabsf(sp4C.x) < 20.0f && - Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { - func_8002F554(&this->dyna.actor, globalCtx, 0 - (this->dyna.actor.params >> 5 & 0x7F)); - } - if (Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) { - EnBox_SetupAction(this, EnBox_Open); - } - } -} - -/** - * Plays an animation to its end, playing sounds at key points - */ -void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { - u16 sfxId; - - this->dyna.actor.flags &= ~ACTOR_FLAG_7; - - if (SkelAnime_Update(&this->skelanime)) { - if (this->unk_1F4 > 0) { - if (this->unk_1F4 < 120) { - this->unk_1F4++; - } else { - Math_StepToF(&this->unk_1B0, 0.0f, 0.05f); - } - } else { - if (this->unk_1F4 > -120) { - this->unk_1F4--; - } else { - Math_StepToF(&this->unk_1B0, 0.0f, 0.05f); - } - } - } else { - sfxId = 0; - - if (Animation_OnFrame(&this->skelanime, 30.0f)) { - sfxId = NA_SE_EV_TBOX_UNLOCK; - } else if (Animation_OnFrame(&this->skelanime, 90.0f)) { - sfxId = NA_SE_EV_TBOX_OPEN; - } - - if (sfxId != 0) { - Audio_PlaySoundGeneral(sfxId, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - - if (this->skelanime.jointTable[3].z > 0) { - this->unk_1B0 = (0x7D00 - this->skelanime.jointTable[3].z) * 0.00006f; - if (this->unk_1B0 < 0.0f) { - this->unk_1B0 = 0.0f; - } else if (this->unk_1B0 > 1.0f) { - this->unk_1B0 = 1.0f; - } - } - } -} - -void EnBox_SpawnIceSmoke(EnBox* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f vel = { 0.0f, 1.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - f32 f0; - - this->iceSmokeTimer++; - func_8002F974(&this->dyna.actor, NA_SE_EN_MIMICK_BREATH - SFX_FLAG); - if (Rand_ZeroOne() < 0.3f) { - f0 = 2.0f * Rand_ZeroOne() - 1.0f; - pos = this->dyna.actor.world.pos; - if (this->type == ENBOX_TYPE_SMALL || this->type == ENBOX_TYPE_6 || this->type == ENBOX_TYPE_ROOM_CLEAR_SMALL || - this->type == ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL) { - pos.x += f0 * 10.0f * Math_SinS(this->dyna.actor.world.rot.y + 0x4000); - pos.z += f0 * 10.0f * Math_CosS(this->dyna.actor.world.rot.y + 0x4000); - f0 = 2.0f * Rand_ZeroOne() - 1.0f; - vel.x = f0 * 0.8f * Math_SinS(this->dyna.actor.world.rot.y); - vel.y = 1.8f; - vel.z = f0 * 0.8f * Math_CosS(this->dyna.actor.world.rot.y); - } else { - pos.x += f0 * 20.0f * Math_SinS(this->dyna.actor.world.rot.y + 0x4000); - pos.z += f0 * 20.0f * Math_CosS(this->dyna.actor.world.rot.y + 0x4000); - f0 = 2.0f * Rand_ZeroOne() - 1.0f; - vel.x = f0 * 1.6f * Math_SinS(this->dyna.actor.world.rot.y); - vel.y = 1.8f; - vel.z = f0 * 1.6f * Math_CosS(this->dyna.actor.world.rot.y); - } - EffectSsIceSmoke_Spawn(globalCtx, &pos, &vel, &accel, 150); - } -} - -void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; - - if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { - this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; - EnBox_ClipToGround(this, globalCtx); - } - - this->actionFunc(this, globalCtx); - - if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { - Actor_MoveForward(&this->dyna.actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); - } - - switch (this->type) { - case ENBOX_TYPE_SMALL: - case ENBOX_TYPE_6: - case ENBOX_TYPE_ROOM_CLEAR_SMALL: - case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL: - Actor_SetFocus(&this->dyna.actor, 20.0f); - break; - default: - Actor_SetFocus(&this->dyna.actor, 40.0f); - } - - if ((this->dyna.actor.params >> 5 & 0x7F) == 0x7C && this->actionFunc == EnBox_Open && - this->skelanime.curFrame > 45 && this->iceSmokeTimer < 100) { - EnBox_SpawnIceSmoke(this, globalCtx); - } -} - -void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnBox* this = (EnBox*)thisx; - s32 pad; - - if (limbIndex == 1) { - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_box.c", 1492), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->type != ENBOX_TYPE_DECORATED_BIG) { - gSPDisplayList((*gfx)++, gTreasureChestChestFrontDL); - } else { - gSPDisplayList((*gfx)++, gTreasureChestBossKeyChestFrontDL); - } - } else if (limbIndex == 3) { - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_box.c", 1502), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->type != ENBOX_TYPE_DECORATED_BIG) { - gSPDisplayList((*gfx)++, gTreasureChestChestSideAndLidDL); - } else { - gSPDisplayList((*gfx)++, gTreasureChestBossKeyChestSideAndTopDL); - } - } -} - -Gfx* EnBox_EmptyDList(GraphicsContext* gfxCtx) { - Gfx* dListHead; - Gfx* dList; - - dList = Graph_Alloc(gfxCtx, sizeof(Gfx)); - ASSERT(dList != NULL, "gfxp != NULL", "../z_en_box.c", 1528); - - dListHead = dList; - gSPEndDisplayList(dListHead++); - - return dList; -} - -// set render mode with a focus on transparency -Gfx* func_809CA4A0(GraphicsContext* gfxCtx) { - Gfx* dList; - Gfx* dListHead; - - dListHead = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); - ASSERT(dListHead != NULL, "gfxp != NULL", "../z_en_box.c", 1546); - - dList = dListHead; - gDPSetRenderMode(dListHead++, - AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | - GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), - AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); - gSPEndDisplayList(dListHead++); - - return dList; -} - -Gfx* func_809CA518(GraphicsContext* gfxCtx) { - Gfx* dList; - Gfx* dListHead; - - dListHead = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); - ASSERT(dListHead != NULL, "gfxp != NULL", "../z_en_box.c", 1564); - - dList = dListHead; - gDPSetRenderMode(dListHead++, - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | - GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), - G_RM_AA_ZB_OPA_SURF2); - gSPEndDisplayList(dListHead++); - - return dList; -} - -void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_box.c", 1581); - - /* - this->dyna.actor.flags & ACTOR_FLAG_7 is set by Init (if type is 4 or 6) - and cleared by Open - */ - if ((this->alpha == 255 && !(this->type == ENBOX_TYPE_4 || this->type == ENBOX_TYPE_6)) || - (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_7) && - (this->type == ENBOX_TYPE_4 || this->type == ENBOX_TYPE_6))) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_EmptyDList(globalCtx->state.gfxCtx)); - func_80093D18(globalCtx->state.gfxCtx); - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, NULL, - EnBox_PostLimbDraw, this, POLY_OPA_DISP); - } else if (this->alpha != 0) { - gDPPipeSync(POLY_XLU_DISP++); - func_80093D84(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - if (this->type == ENBOX_TYPE_4 || this->type == ENBOX_TYPE_6) { - gSPSegment(POLY_XLU_DISP++, 0x08, func_809CA518(globalCtx->state.gfxCtx)); - } else { - gSPSegment(POLY_XLU_DISP++, 0x08, func_809CA4A0(globalCtx->state.gfxCtx)); - } - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, NULL, - EnBox_PostLimbDraw, this, POLY_XLU_DISP); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_box.c", 1639); -} diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.cpp b/src/overlays/actors/ovl_En_Box/z_en_box.cpp new file mode 100644 index 000000000..9b6eeee9e --- /dev/null +++ b/src/overlays/actors/ovl_En_Box/z_en_box.cpp @@ -0,0 +1,667 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BOX_Z_EN_BOX_C +#include "actor_common.h" +#include "z_en_box.h" +#include "objects/object_box/object_box.h" +#include "def/code_80043480.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +// movement flags + +/* +set on init unless treasure flag is set +if clear, chest moves (Actor_MoveForward) (falls, likely) +ends up cleared from SWITCH_FLAG_FALL types when switch flag is set +*/ +#define ENBOX_MOVE_IMMOBILE (1 << 0) +/* +set in the logic for SWITCH_FLAG_FALL types +otherwise unused +*/ +#define ENBOX_MOVE_UNUSED (1 << 1) +/* +set with 50% chance on init for SWITCH_FLAG_FALL types +only used for SWITCH_FLAG_FALL types +ends up "blinking" (set/clear every frame) once switch flag is set, +if some collision-related condition (?) is met +only used for signum of z rotation +*/ +#define ENBOX_MOVE_FALL_ANGLE_SIDE (1 << 2) +/* +when set, gets cleared next EnBox_Update call and clip to the floor +*/ +#define ENBOX_MOVE_STICK_TO_GROUND (1 << 4) + +typedef enum { + ENBOX_STATE_0, // waiting for player near / player available / player ? (IDLE) + ENBOX_STATE_1, // used only temporarily, maybe "player is ready" ? + ENBOX_STATE_2 // waiting for something message context-related +} EnBoxStateUnk1FB; + +void EnBox_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBox_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBox_FallOnSwitchFlag(EnBox*, GlobalContext*); +void func_809C9700(EnBox*, GlobalContext*); +void EnBox_AppearOnSwitchFlag(EnBox*, GlobalContext*); +void EnBox_AppearOnRoomClear(EnBox*, GlobalContext*); +void EnBox_AppearInit(EnBox*, GlobalContext*); +void EnBox_AppearAnimation(EnBox*, GlobalContext*); +void EnBox_WaitOpen(EnBox*, GlobalContext*); +void EnBox_Open(EnBox*, GlobalContext*); + +ActorInit En_Box_InitVars = { + ACTOR_EN_BOX, + ACTORCAT_CHEST, + FLAGS, + OBJECT_BOX, + sizeof(EnBox), + (ActorFunc)EnBox_Init, + (ActorFunc)EnBox_Destroy, + (ActorFunc)EnBox_Update, + (ActorFunc)EnBox_Draw, +}; + +static AnimationHeader* sAnimations[4] = { &gTreasureChestAnim_00024C, &gTreasureChestAnim_000128, + &gTreasureChestAnim_00043C, &gTreasureChestAnim_00043C }; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 0, ICHAIN_STOP), +}; + +static UNK_TYPE sUnused; + +void EnBox_SetupAction(EnBox* pthis, EnBoxActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnBox_ClipToGround(EnBox* pthis, GlobalContext* globalCtx) { + f32 newY; + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + + pos = pthis->dyna.actor.world.pos; + pos.y += 1.0f; + newY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &poly, &bgId, &pthis->dyna.actor, &pos); + if (newY != BGCHECK_Y_MIN) { + pthis->dyna.actor.world.pos.y = newY; + } +} + +void EnBox_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBox* pthis = (EnBox*)thisx; + AnimationHeader* anim; + CollisionHeader* colHeader; + f32 animFrameStart; + f32 endFrame; + + animFrameStart = 0.0f; + anim = sAnimations[((void)0, gSaveContext.linkAge)]; + colHeader = NULL; + endFrame = Animation_GetLastFrame(anim); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gTreasureChestCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + func_8003ECA8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + + pthis->movementFlags = 0; + pthis->type = thisx->params >> 12 & 0xF; + pthis->iceSmokeTimer = 0; + pthis->unk_1FB = ENBOX_STATE_0; + pthis->dyna.actor.gravity = -5.5f; + pthis->switchFlag = pthis->dyna.actor.world.rot.z; + pthis->dyna.actor.minVelocityY = -50.0f; + + if (globalCtx) {} // helps the compiler store globalCtx2 into s1 + + if (Flags_GetTreasure(globalCtx, pthis->dyna.actor.params & 0x1F)) { + pthis->alpha = 255; + pthis->iceSmokeTimer = 100; + EnBox_SetupAction(pthis, EnBox_Open); + pthis->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + animFrameStart = endFrame; + } else if ((pthis->type == ENBOX_TYPE_SWITCH_FLAG_FALL_BIG || pthis->type == ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL) && + !Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + if (Rand_ZeroOne() < 0.5f) { + pthis->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + pthis->unk_1A8 = -12; + EnBox_SetupAction(pthis, EnBox_FallOnSwitchFlag); + pthis->alpha = 0; + pthis->movementFlags |= ENBOX_MOVE_IMMOBILE; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + } else if ((pthis->type == ENBOX_TYPE_ROOM_CLEAR_BIG || pthis->type == ENBOX_TYPE_ROOM_CLEAR_SMALL) && + !Flags_GetClear(globalCtx, pthis->dyna.actor.room)) { + EnBox_SetupAction(pthis, EnBox_AppearOnRoomClear); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->movementFlags |= ENBOX_MOVE_IMMOBILE; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - 50.0f; + pthis->alpha = 0; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + } else if (pthis->type == ENBOX_TYPE_9 || pthis->type == ENBOX_TYPE_10) { + EnBox_SetupAction(pthis, func_809C9700); + pthis->dyna.actor.flags |= ACTOR_FLAG_25; + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->movementFlags |= ENBOX_MOVE_IMMOBILE; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - 50.0f; + pthis->alpha = 0; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + } else if (pthis->type == ENBOX_TYPE_SWITCH_FLAG_BIG && !Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + EnBox_SetupAction(pthis, EnBox_AppearOnSwitchFlag); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->movementFlags |= ENBOX_MOVE_IMMOBILE; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - 50.0f; + pthis->alpha = 0; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + } else { + if (pthis->type == ENBOX_TYPE_4 || pthis->type == ENBOX_TYPE_6) { + pthis->dyna.actor.flags |= ACTOR_FLAG_7; + } + EnBox_SetupAction(pthis, EnBox_WaitOpen); + pthis->movementFlags |= ENBOX_MOVE_IMMOBILE; + pthis->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + } + + pthis->dyna.actor.world.rot.y += 0x8000; + pthis->dyna.actor.home.rot.z = pthis->dyna.actor.world.rot.z = pthis->dyna.actor.shape.rot.z = 0; + + SkelAnime_Init(globalCtx, &pthis->skelanime, &gTreasureChestSkel, anim, pthis->jointTable, pthis->morphTable, 5); + Animation_Change(&pthis->skelanime, anim, 1.5f, animFrameStart, endFrame, ANIMMODE_ONCE, 0.0f); + + switch (pthis->type) { + case ENBOX_TYPE_SMALL: + case ENBOX_TYPE_6: + case ENBOX_TYPE_ROOM_CLEAR_SMALL: + case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL: + Actor_SetScale(&pthis->dyna.actor, 0.005f); + Actor_SetFocus(&pthis->dyna.actor, 20.0f); + break; + default: + Actor_SetScale(&pthis->dyna.actor, 0.01f); + Actor_SetFocus(&pthis->dyna.actor, 40.0f); + } +} + +void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBox* pthis = (EnBox*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void EnBox_RandomDustKinematic(EnBox* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + f32 randomRadius = Rand_ZeroOne() * 25.0f; + s16 randomAngle = Rand_ZeroOne() * 0x10000; + + *pos = pthis->dyna.actor.world.pos; + pos->x += Math_SinS(randomAngle) * randomRadius; + pos->z += Math_CosS(randomAngle) * randomRadius; + + velocity->y = 1.0f; + velocity->x = Math_SinS(randomAngle); + velocity->z = Math_CosS(randomAngle); + + accel->x = 0.0f; + accel->y = 0.0f; + accel->z = 0.0f; +} + +/** + * Spawns dust randomly around the chest when the chest hits the ground after falling (FALL types) + */ +void EnBox_SpawnDust(EnBox* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + for (i = 0; i < 20; i++) { + EnBox_RandomDustKinematic(pthis, &pos, &velocity, &accel); + func_8002873C(globalCtx, &pos, &velocity, &accel, 100, 30, 15); + } +} + +/** + * Used while the chest is falling (FALL types) + */ +void EnBox_Fall(EnBox* pthis, GlobalContext* globalCtx) { + f32 yDiff; + + pthis->alpha = 255; + pthis->movementFlags &= ~ENBOX_MOVE_IMMOBILE; + if (pthis->dyna.actor.bgCheckFlags & 1) { + pthis->movementFlags |= ENBOX_MOVE_UNUSED; + if (pthis->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + pthis->movementFlags &= ~ENBOX_MOVE_FALL_ANGLE_SIDE; + } else { + pthis->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + if (pthis->type == ENBOX_TYPE_SWITCH_FLAG_FALL_BIG) { + pthis->dyna.actor.velocity.y = -pthis->dyna.actor.velocity.y * 0.55f; + } else { + pthis->dyna.actor.velocity.y = -pthis->dyna.actor.velocity.y * 0.65f; + } + if (pthis->dyna.actor.velocity.y < 5.5f) { + pthis->dyna.actor.shape.rot.z = 0; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + EnBox_SetupAction(pthis, EnBox_WaitOpen); + OnePointCutscene_EndCutscene(globalCtx, pthis->unk_1AC); + } + Audio_PlaySoundGeneral(NA_SE_EV_COFFIN_CAP_BOUND, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + EnBox_SpawnDust(pthis, globalCtx); + } + yDiff = pthis->dyna.actor.world.pos.y - pthis->dyna.actor.floorHeight; + if (pthis->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + pthis->dyna.actor.shape.rot.z = yDiff * 50.0f; + } else { + pthis->dyna.actor.shape.rot.z = -yDiff * 50.0f; + } +} + +void EnBox_FallOnSwitchFlag(EnBox* pthis, GlobalContext* globalCtx) { + s32 treasureFlag = pthis->dyna.actor.params & 0x1F; + + if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { + func_8002F5F0(&pthis->dyna.actor, globalCtx); + } + + if (pthis->unk_1A8 >= 0) { + EnBox_SetupAction(pthis, EnBox_Fall); + pthis->unk_1AC = OnePointCutscene_Init(globalCtx, 4500, 9999, &pthis->dyna.actor, MAIN_CAM); + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } else if (pthis->unk_1A8 >= -11) { + pthis->unk_1A8++; + } else if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->unk_1A8++; + } +} + +// used for types 9, 10 +void func_809C9700(EnBox* pthis, GlobalContext* globalCtx) { + s32 treasureFlag = pthis->dyna.actor.params & 0x1F; + Player* player = GET_PLAYER(globalCtx); + + if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { + func_8002F5F0(&pthis->dyna.actor, globalCtx); + } + + if (Math3D_Vec3fDistSq(&pthis->dyna.actor.world.pos, &player->actor.world.pos) > 22500.0f) { + pthis->unk_1FB = ENBOX_STATE_0; + } else { + if (pthis->unk_1FB == ENBOX_STATE_0) { + if (!(player->stateFlags2 & 0x1000000)) { + player->stateFlags2 |= 0x800000; + return; + } + pthis->unk_1FB = ENBOX_STATE_1; + } + + if (pthis->unk_1FB == ENBOX_STATE_1) { + func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); + pthis->unk_1FB = ENBOX_STATE_2; + } else if (pthis->unk_1FB == ENBOX_STATE_2 && globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + if ((globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_LULLABY && pthis->type == ENBOX_TYPE_9) || + (globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS && pthis->type == ENBOX_TYPE_10)) { + pthis->dyna.actor.flags &= ~ACTOR_FLAG_25; + EnBox_SetupAction(pthis, EnBox_AppearInit); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->unk_1A8 = 0; + pthis->unk_1FB = ENBOX_STATE_0; + } else { + pthis->unk_1FB = ENBOX_STATE_0; + } + } + } +} + +void EnBox_AppearOnSwitchFlag(EnBox* pthis, GlobalContext* globalCtx) { + s32 treasureFlag = pthis->dyna.actor.params & 0x1F; + + if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { + func_8002F5F0(&pthis->dyna.actor, globalCtx); + } + + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + EnBox_SetupAction(pthis, EnBox_AppearInit); + pthis->unk_1A8 = -30; + } +} + +void EnBox_AppearOnRoomClear(EnBox* pthis, GlobalContext* globalCtx) { + s32 treasureFlag = pthis->dyna.actor.params & 0x1F; + + if (treasureFlag >= ENBOX_TREASURE_FLAG_UNK_MIN && treasureFlag < ENBOX_TREASURE_FLAG_UNK_MAX) { + func_8002F5F0(&pthis->dyna.actor, globalCtx); + } + + if (Flags_GetTempClear(globalCtx, pthis->dyna.actor.room) && !Player_InCsMode(globalCtx)) { + Flags_SetClear(globalCtx, pthis->dyna.actor.room); + EnBox_SetupAction(pthis, EnBox_AppearInit); + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + if (OnePointCutscene_CheckForCategory(globalCtx, pthis->dyna.actor.category)) { + pthis->unk_1A8 = 0; + } else { + pthis->unk_1A8 = -30; + } + } +} + +/** + * The chest is ready to appear, possibly waiting for camera/cutscene-related stuff to happen + */ +void EnBox_AppearInit(EnBox* pthis, GlobalContext* globalCtx) { + if (func_8005B198() == pthis->dyna.actor.category || pthis->unk_1A8 != 0) { + EnBox_SetupAction(pthis, EnBox_AppearAnimation); + pthis->unk_1A8 = 0; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, pthis->dyna.actor.home.pos.x, + pthis->dyna.actor.home.pos.y, pthis->dyna.actor.home.pos.z, 0, 0, 0, 0x0011); + Audio_PlaySoundGeneral(NA_SE_EV_TRE_BOX_APPEAR, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void EnBox_AppearAnimation(EnBox* pthis, GlobalContext* globalCtx) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + + if (pthis->unk_1A8 < 0) { + pthis->unk_1A8++; + } else if (pthis->unk_1A8 < 40) { + pthis->unk_1A8++; + pthis->dyna.actor.world.pos.y += 1.25f; + } else if (pthis->unk_1A8 < 60) { + pthis->alpha += 12; + pthis->unk_1A8++; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + } else { + EnBox_SetupAction(pthis, EnBox_WaitOpen); + } +} + +/** + * Chest is ready to be open + */ +void EnBox_WaitOpen(EnBox* pthis, GlobalContext* globalCtx) { + f32 frameCount; + AnimationHeader* anim; + s32 linkAge; + s32 pad; + Vec3f sp4C; + Player* player; + + pthis->alpha = 255; + pthis->movementFlags |= ENBOX_MOVE_IMMOBILE; + if (pthis->unk_1F4 != 0) { // unk_1F4 is modified by player code + linkAge = gSaveContext.linkAge; + anim = sAnimations[(pthis->unk_1F4 < 0 ? 2 : 0) + linkAge]; + frameCount = Animation_GetLastFrame(anim); + Animation_Change(&pthis->skelanime, anim, 1.5f, 0, frameCount, ANIMMODE_ONCE, 0.0f); + EnBox_SetupAction(pthis, EnBox_Open); + if (pthis->unk_1F4 > 0) { + switch (pthis->type) { + case ENBOX_TYPE_SMALL: + case ENBOX_TYPE_6: + case ENBOX_TYPE_ROOM_CLEAR_SMALL: + case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL: + break; + default: + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_DEMO_TRE_LGT, + pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, + pthis->dyna.actor.world.pos.z, pthis->dyna.actor.shape.rot.x, + pthis->dyna.actor.shape.rot.y, pthis->dyna.actor.shape.rot.z, 0xFFFF); + Audio_PlayFanfare(NA_BGM_OPEN_TRE_BOX | 0x900); + } + } + osSyncPrintf("Actor_Environment_Tbox_On() %d\n", pthis->dyna.actor.params & 0x1F); + Flags_SetTreasure(globalCtx, pthis->dyna.actor.params & 0x1F); + } else { + player = GET_PLAYER(globalCtx); + func_8002DBD0(&pthis->dyna.actor, &sp4C, &player->actor.world.pos); + if (sp4C.z > -50.0f && sp4C.z < 0.0f && fabsf(sp4C.y) < 10.0f && fabsf(sp4C.x) < 20.0f && + Player_IsFacingActor(&pthis->dyna.actor, 0x3000, globalCtx)) { + func_8002F554(&pthis->dyna.actor, globalCtx, 0 - (pthis->dyna.actor.params >> 5 & 0x7F)); + } + if (Flags_GetTreasure(globalCtx, pthis->dyna.actor.params & 0x1F)) { + EnBox_SetupAction(pthis, EnBox_Open); + } + } +} + +/** + * Plays an animation to its end, playing sounds at key points + */ +void EnBox_Open(EnBox* pthis, GlobalContext* globalCtx) { + u16 sfxId; + + pthis->dyna.actor.flags &= ~ACTOR_FLAG_7; + + if (SkelAnime_Update(&pthis->skelanime)) { + if (pthis->unk_1F4 > 0) { + if (pthis->unk_1F4 < 120) { + pthis->unk_1F4++; + } else { + Math_StepToF(&pthis->unk_1B0, 0.0f, 0.05f); + } + } else { + if (pthis->unk_1F4 > -120) { + pthis->unk_1F4--; + } else { + Math_StepToF(&pthis->unk_1B0, 0.0f, 0.05f); + } + } + } else { + sfxId = 0; + + if (Animation_OnFrame(&pthis->skelanime, 30.0f)) { + sfxId = NA_SE_EV_TBOX_UNLOCK; + } else if (Animation_OnFrame(&pthis->skelanime, 90.0f)) { + sfxId = NA_SE_EV_TBOX_OPEN; + } + + if (sfxId != 0) { + Audio_PlaySoundGeneral(sfxId, &pthis->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + if (pthis->skelanime.jointTable[3].z > 0) { + pthis->unk_1B0 = (0x7D00 - pthis->skelanime.jointTable[3].z) * 0.00006f; + if (pthis->unk_1B0 < 0.0f) { + pthis->unk_1B0 = 0.0f; + } else if (pthis->unk_1B0 > 1.0f) { + pthis->unk_1B0 = 1.0f; + } + } + } +} + +void EnBox_SpawnIceSmoke(EnBox* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f vel = { 0.0f, 1.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + f32 f0; + + pthis->iceSmokeTimer++; + func_8002F974(&pthis->dyna.actor, NA_SE_EN_MIMICK_BREATH - SFX_FLAG); + if (Rand_ZeroOne() < 0.3f) { + f0 = 2.0f * Rand_ZeroOne() - 1.0f; + pos = pthis->dyna.actor.world.pos; + if (pthis->type == ENBOX_TYPE_SMALL || pthis->type == ENBOX_TYPE_6 || pthis->type == ENBOX_TYPE_ROOM_CLEAR_SMALL || + pthis->type == ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL) { + pos.x += f0 * 10.0f * Math_SinS(pthis->dyna.actor.world.rot.y + 0x4000); + pos.z += f0 * 10.0f * Math_CosS(pthis->dyna.actor.world.rot.y + 0x4000); + f0 = 2.0f * Rand_ZeroOne() - 1.0f; + vel.x = f0 * 0.8f * Math_SinS(pthis->dyna.actor.world.rot.y); + vel.y = 1.8f; + vel.z = f0 * 0.8f * Math_CosS(pthis->dyna.actor.world.rot.y); + } else { + pos.x += f0 * 20.0f * Math_SinS(pthis->dyna.actor.world.rot.y + 0x4000); + pos.z += f0 * 20.0f * Math_CosS(pthis->dyna.actor.world.rot.y + 0x4000); + f0 = 2.0f * Rand_ZeroOne() - 1.0f; + vel.x = f0 * 1.6f * Math_SinS(pthis->dyna.actor.world.rot.y); + vel.y = 1.8f; + vel.z = f0 * 1.6f * Math_CosS(pthis->dyna.actor.world.rot.y); + } + EffectSsIceSmoke_Spawn(globalCtx, &pos, &vel, &accel, 150); + } +} + +void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBox* pthis = (EnBox*)thisx; + + if (pthis->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { + pthis->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; + EnBox_ClipToGround(pthis, globalCtx); + } + + pthis->actionFunc(pthis, globalCtx); + + if (!(pthis->movementFlags & ENBOX_MOVE_IMMOBILE)) { + Actor_MoveForward(&pthis->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + } + + switch (pthis->type) { + case ENBOX_TYPE_SMALL: + case ENBOX_TYPE_6: + case ENBOX_TYPE_ROOM_CLEAR_SMALL: + case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL: + Actor_SetFocus(&pthis->dyna.actor, 20.0f); + break; + default: + Actor_SetFocus(&pthis->dyna.actor, 40.0f); + } + + if ((pthis->dyna.actor.params >> 5 & 0x7F) == 0x7C && pthis->actionFunc == EnBox_Open && + pthis->skelanime.curFrame > 45 && pthis->iceSmokeTimer < 100) { + EnBox_SpawnIceSmoke(pthis, globalCtx); + } +} + +void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + EnBox* pthis = (EnBox*)thisx; + s32 pad; + + if (limbIndex == 1) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_box.c", 1492), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (pthis->type != ENBOX_TYPE_DECORATED_BIG) { + gSPDisplayList((*gfx)++, gTreasureChestChestFrontDL); + } else { + gSPDisplayList((*gfx)++, gTreasureChestBossKeyChestFrontDL); + } + } else if (limbIndex == 3) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_box.c", 1502), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (pthis->type != ENBOX_TYPE_DECORATED_BIG) { + gSPDisplayList((*gfx)++, gTreasureChestChestSideAndLidDL); + } else { + gSPDisplayList((*gfx)++, gTreasureChestBossKeyChestSideAndTopDL); + } + } +} + +Gfx* EnBox_EmptyDList(GraphicsContext* gfxCtx) { + Gfx* dListHead; + Gfx* dList; + + dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); + ASSERT(dList != NULL, "gfxp != NULL", "../z_en_box.c", 1528); + + dListHead = dList; + gSPEndDisplayList(dListHead++); + + return dList; +} + +// set render mode with a focus on transparency +Gfx* func_809CA4A0(GraphicsContext* gfxCtx) { + Gfx* dList; + Gfx* dListHead; + + dListHead = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + ASSERT(dListHead != NULL, "gfxp != NULL", "../z_en_box.c", 1546); + + dList = dListHead; + gDPSetRenderMode(dListHead++, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + gSPEndDisplayList(dListHead++); + + return dList; +} + +Gfx* func_809CA518(GraphicsContext* gfxCtx) { + Gfx* dList; + Gfx* dListHead; + + dListHead = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + ASSERT(dListHead != NULL, "gfxp != NULL", "../z_en_box.c", 1564); + + dList = dListHead; + gDPSetRenderMode(dListHead++, + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | + GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), + G_RM_AA_ZB_OPA_SURF2); + gSPEndDisplayList(dListHead++); + + return dList; +} + +void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBox* pthis = (EnBox*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_box.c", 1581); + + /* + pthis->dyna.actor.flags & ACTOR_FLAG_7 is set by Init (if type is 4 or 6) + and cleared by Open + */ + if ((pthis->alpha == 255 && !(pthis->type == ENBOX_TYPE_4 || pthis->type == ENBOX_TYPE_6)) || + (!CHECK_FLAG_ALL(pthis->dyna.actor.flags, ACTOR_FLAG_7) && + (pthis->type == ENBOX_TYPE_4 || pthis->type == ENBOX_TYPE_6))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_EmptyDList(globalCtx->state.gfxCtx)); + func_80093D18(globalCtx->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, NULL, + EnBox_PostLimbDraw, pthis, POLY_OPA_DISP); + } else if (pthis->alpha != 0) { + gDPPipeSync(POLY_XLU_DISP++); + func_80093D84(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + if (pthis->type == ENBOX_TYPE_4 || pthis->type == ENBOX_TYPE_6) { + gSPSegment(POLY_XLU_DISP++, 0x08, func_809CA518(globalCtx->state.gfxCtx)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, func_809CA4A0(globalCtx->state.gfxCtx)); + } + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, NULL, + EnBox_PostLimbDraw, pthis, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_box.c", 1639); +} diff --git a/src/overlays/actors/ovl_En_Brob/z_en_brob.c b/src/overlays/actors/ovl_En_Brob/z_en_brob.c deleted file mode 100644 index 2ea8ec63e..000000000 --- a/src/overlays/actors/ovl_En_Brob/z_en_brob.c +++ /dev/null @@ -1,339 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BROB_Z_EN_BROB_C -#include "actor_common.h" -/* - * File: z_en_brob.c - * Overlay: ovl_En_Brob - * Description: Flobbery Muscle Block (Jabu-Jabu's Belly) - */ - -#include "z_en_brob.h" -#include "objects/object_brob/object_brob.h" -#include "def/code_80043480.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnBrob_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBrob_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBrob_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBrob_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809CADDC(EnBrob* this, GlobalContext* globalCtx); -void func_809CB054(EnBrob* this, GlobalContext* globalCtx); -void func_809CB114(EnBrob* this, GlobalContext* globalCtx); -void func_809CB218(EnBrob* this, GlobalContext* globalCtx); -void func_809CB2B8(EnBrob* this, GlobalContext* globalCtx); -void func_809CB354(EnBrob* this, GlobalContext* globalCtx); -void func_809CB458(EnBrob* this, GlobalContext* globalCtx); - -const ActorInit En_Brob_InitVars = { - ACTOR_EN_BROB, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BROB, - sizeof(EnBrob), - (ActorFunc)EnBrob_Init, - (ActorFunc)EnBrob_Destroy, - (ActorFunc)EnBrob_Update, - (ActorFunc)EnBrob_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0xFFCFFFFF, 0x03, 0x08 }, - { 0xFFCFFFFF, 0x01, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 8000, 11000, -5000, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0, 60, 120, MASS_IMMOVABLE }; - -void EnBrob_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnBrob* this = (EnBrob*)thisx; - CollisionHeader* colHeader = NULL; - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_brob_Skel_0015D8, &object_brob_Anim_001750, - this->jointTable, this->morphTable, 10); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&object_brob_Col_001A70, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - Collider_InitCylinder(globalCtx, &this->colliders[0]); - Collider_SetCylinder(globalCtx, &this->colliders[0], &this->dyna.actor, &sCylinderInit); - Collider_InitCylinder(globalCtx, &this->colliders[1]); - Collider_SetCylinder(globalCtx, &this->colliders[1], &this->dyna.actor, &sCylinderInit); - CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); - if (((thisx->params >> 8) & 0xFF) == 0) { - Actor_SetScale(&this->dyna.actor, 0.01f); - thisx->params &= 0xFF; - if (thisx->params != 0xFF) { - thisx->scale.y *= (thisx->params & 0xFF) * (1.0f / 30.0f); - } - } else { - Actor_SetScale(&this->dyna.actor, 0.005f); - thisx->params &= 0xFF; - if (thisx->params != 0xFF) { - thisx->scale.y *= (thisx->params & 0xFF) * (2.0f / 30.0f); - } - } - this->colliders[0].dim.radius *= thisx->scale.x; - this->colliders[0].dim.height = thisx->scale.y * 12000.0f; - this->colliders[0].dim.yShift = 0; - this->colliders[1].dim.radius *= thisx->scale.x; - this->colliders[1].dim.height *= thisx->scale.y; - this->colliders[1].dim.yShift *= thisx->scale.y; - this->actionFunc = NULL; - thisx->flags &= ~ACTOR_FLAG_0; - func_809CADDC(this, globalCtx); -} - -void EnBrob_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBrob* this = (EnBrob*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->colliders[0]); - Collider_DestroyCylinder(globalCtx, &this->colliders[1]); -} - -void func_809CADDC(EnBrob* this, GlobalContext* globalCtx) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->timer = this->actionFunc == func_809CB2B8 ? 200 : 0; - this->unk_1AE = 0; - this->actionFunc = func_809CB054; -} - -void func_809CAE44(EnBrob* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &object_brob_Anim_001750); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->unk_1AE = 1000; - this->actionFunc = func_809CB114; -} - -void func_809CAEA0(EnBrob* this) { - Animation_MorphToLoop(&this->skelAnime, &object_brob_Anim_001958, -5.0f); - this->unk_1AE = 8000; - this->timer = 1200; - this->actionFunc = func_809CB218; -} - -void func_809CAEF4(EnBrob* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_brob_Anim_000290, -5.0f); - this->unk_1AE -= 125.0f; - Actor_SetColorFilter(&this->dyna.actor, 0, 0xFF, 0, 0x50); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionFunc = func_809CB2B8; -} - -void func_809CAF88(EnBrob* this) { - Animation_Change(&this->skelAnime, &object_brob_Anim_001750, -1.0f, - Animation_GetLastFrame(&object_brob_Anim_001750), 0.0f, ANIMMODE_ONCE, -5.0f); - this->unk_1AE = 8250; - this->actionFunc = func_809CB354; -} - -void func_809CB008(EnBrob* this) { - Animation_MorphToLoop(&this->skelAnime, &object_brob_Anim_001678, -5.0f); - this->timer = 10; - this->actionFunc = func_809CB458; -} - -void func_809CB054(EnBrob* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - if (func_8004356C(&this->dyna) != 0) { - func_8002F71C(globalCtx, &this->dyna.actor, 5.0f, this->dyna.actor.yawTowardsPlayer, 1.0f); - func_809CAE44(this, globalCtx); - } else if (this->dyna.actor.xzDistToPlayer < 300.0f) { - func_809CAE44(this, globalCtx); - } - } else if (this->timer >= 81) { - this->dyna.actor.colorFilterTimer = 80; - } -} - -void func_809CB114(EnBrob* this, GlobalContext* globalCtx) { - f32 curFrame; - - if (SkelAnime_Update(&this->skelAnime)) { - func_809CAEA0(this); - } else { - curFrame = this->skelAnime.curFrame; - if (curFrame < 8.0f) { - this->unk_1AE += 1000.0f; - } else if (curFrame < 12.0f) { - this->unk_1AE += 250.0f; - } else { - this->unk_1AE -= 250.0f; - } - } -} - -void func_809CB218(EnBrob* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_BROB_WAVE); - } - if (this->timer != 0) { - this->timer--; - } - if ((this->timer == 0) && (this->dyna.actor.xzDistToPlayer > 500.0f)) { - func_809CAF88(this); - } -} - -void func_809CB2B8(EnBrob* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - func_809CADDC(this, globalCtx); - } else if (this->skelAnime.curFrame < 8.0f) { - this->unk_1AE -= 1250.0f; - } - this->dyna.actor.colorFilterTimer = 0x50; -} - -void func_809CB354(EnBrob* this, GlobalContext* globalCtx) { - f32 curFrame; - - if (SkelAnime_Update(&this->skelAnime)) { - func_809CADDC(this, globalCtx); - } else { - curFrame = this->skelAnime.curFrame; - if (curFrame < 8.0f) { - this->unk_1AE -= 1000.0f; - } else if (curFrame < 12.0f) { - this->unk_1AE -= 250.0f; - } else { - this->unk_1AE += 250.0f; - } - } -} - -void func_809CB458(EnBrob* this, GlobalContext* globalCtx) { - Vec3f pos; - f32 dist1; - f32 dist2; - s32 i; - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0) && (this->timer != 0)) { - this->timer--; - } - - dist1 = globalCtx->gameplayFrames % 2 ? 0.0f : this->dyna.actor.scale.x * 5500.0f; - dist2 = this->dyna.actor.scale.x * 5500.0f; - - for (i = 0; i < 4; i++) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 255, 255, 255 }; - - if (i % 2) { - pos.x = this->dyna.actor.world.pos.x + dist1; - pos.z = this->dyna.actor.world.pos.z + dist2; - } else { - pos.x = this->dyna.actor.world.pos.x + dist2; - pos.z = this->dyna.actor.world.pos.z + dist1; - dist1 = -dist1; - dist2 = -dist2; - } - pos.y = (((Rand_ZeroOne() * 15000.0f) + 1000.0f) * this->dyna.actor.scale.y) + this->dyna.actor.world.pos.y; - EffectSsLightning_Spawn(globalCtx, &pos, &primColor, &envColor, this->dyna.actor.scale.y * 8000.0f, - Rand_ZeroOne() * 65536.0f, 4, 1); - } - - if (this->timer == 0) { - func_809CAEA0(this); - } -} - -void EnBrob_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnBrob* this = (EnBrob*)thisx; - s32 i; - s32 acHits[2]; - - acHits[0] = (this->colliders[0].base.acFlags & AC_HIT) != 0; - acHits[1] = (this->colliders[1].base.acFlags & AC_HIT) != 0; - if ((acHits[0] && (this->colliders[0].info.acHitInfo->toucher.dmgFlags & 0x10)) || - (acHits[1] && (this->colliders[1].info.acHitInfo->toucher.dmgFlags & 0x10))) { - - for (i = 0; i < 2; i++) { - this->colliders[i].base.atFlags &= ~(AT_HIT | AT_BOUNCED); - this->colliders[i].base.acFlags &= ~AC_HIT; - } - - func_809CAEF4(this); - } else if ((this->colliders[0].base.atFlags & AT_HIT) || (this->colliders[1].base.atFlags & AT_HIT) || - (acHits[0] && (this->colliders[0].info.acHitInfo->toucher.dmgFlags & 0x100)) || - (acHits[1] && (this->colliders[1].info.acHitInfo->toucher.dmgFlags & 0x100))) { - - if (this->actionFunc == func_809CB114 && !(this->colliders[0].base.atFlags & AT_BOUNCED) && - !(this->colliders[1].base.atFlags & AT_BOUNCED)) { - func_8002F71C(globalCtx, &this->dyna.actor, 5.0f, this->dyna.actor.yawTowardsPlayer, 1.0f); - } else if (this->actionFunc != func_809CB114) { - func_809CB008(this); - } - - for (i = 0; i < 2; i++) { - this->colliders[i].base.atFlags &= ~(AT_HIT | AT_BOUNCED); - this->colliders[i].base.acFlags &= ~AC_HIT; - } - } - this->actionFunc(this, globalCtx); - if (this->actionFunc != func_809CB054 && this->actionFunc != func_809CB354) { - if (this->actionFunc != func_809CB2B8) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); - if (this->actionFunc != func_809CB114) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); - } - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); - } -} - -void EnBrob_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnBrob* this = (EnBrob*)thisx; - MtxF mtx; - - Matrix_Get(&mtx); - if (limbIndex == 3) { - this->colliders[0].dim.pos.x = mtx.xw; - this->colliders[0].dim.pos.y = mtx.yw; - this->colliders[0].dim.pos.z = mtx.zw; - } else if (limbIndex == 8) { - this->colliders[1].dim.pos.x = mtx.xw; - this->colliders[1].dim.pos.y = (mtx.yw + 7.0f); - this->colliders[1].dim.pos.z = mtx.zw; - } -} - -void EnBrob_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBrob* this = (EnBrob*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(0.0f, this->unk_1AE, 0.0f, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnBrob_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Brob/z_en_brob.cpp b/src/overlays/actors/ovl_En_Brob/z_en_brob.cpp new file mode 100644 index 000000000..d5d8488d6 --- /dev/null +++ b/src/overlays/actors/ovl_En_Brob/z_en_brob.cpp @@ -0,0 +1,339 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BROB_Z_EN_BROB_C +#include "actor_common.h" +/* + * File: z_en_brob.c + * Overlay: ovl_En_Brob + * Description: Flobbery Muscle Block (Jabu-Jabu's Belly) + */ + +#include "z_en_brob.h" +#include "objects/object_brob/object_brob.h" +#include "def/code_80043480.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnBrob_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBrob_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBrob_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBrob_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809CADDC(EnBrob* pthis, GlobalContext* globalCtx); +void func_809CB054(EnBrob* pthis, GlobalContext* globalCtx); +void func_809CB114(EnBrob* pthis, GlobalContext* globalCtx); +void func_809CB218(EnBrob* pthis, GlobalContext* globalCtx); +void func_809CB2B8(EnBrob* pthis, GlobalContext* globalCtx); +void func_809CB354(EnBrob* pthis, GlobalContext* globalCtx); +void func_809CB458(EnBrob* pthis, GlobalContext* globalCtx); + +ActorInit En_Brob_InitVars = { + ACTOR_EN_BROB, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BROB, + sizeof(EnBrob), + (ActorFunc)EnBrob_Init, + (ActorFunc)EnBrob_Destroy, + (ActorFunc)EnBrob_Update, + (ActorFunc)EnBrob_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0xFFCFFFFF, 0x03, 0x08 }, + { 0xFFCFFFFF, 0x01, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 8000, 11000, -5000, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 60, 120, MASS_IMMOVABLE }; + +void EnBrob_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBrob* pthis = (EnBrob*)thisx; + CollisionHeader* colHeader = NULL; + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_brob_Skel_0015D8, &object_brob_Anim_001750, + pthis->jointTable, pthis->morphTable, 10); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&object_brob_Col_001A70, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + Collider_InitCylinder(globalCtx, &pthis->colliders[0]); + Collider_SetCylinder(globalCtx, &pthis->colliders[0], &pthis->dyna.actor, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->colliders[1]); + Collider_SetCylinder(globalCtx, &pthis->colliders[1], &pthis->dyna.actor, &sCylinderInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); + if (((thisx->params >> 8) & 0xFF) == 0) { + Actor_SetScale(&pthis->dyna.actor, 0.01f); + thisx->params &= 0xFF; + if (thisx->params != 0xFF) { + thisx->scale.y *= (thisx->params & 0xFF) * (1.0f / 30.0f); + } + } else { + Actor_SetScale(&pthis->dyna.actor, 0.005f); + thisx->params &= 0xFF; + if (thisx->params != 0xFF) { + thisx->scale.y *= (thisx->params & 0xFF) * (2.0f / 30.0f); + } + } + pthis->colliders[0].dim.radius *= thisx->scale.x; + pthis->colliders[0].dim.height = thisx->scale.y * 12000.0f; + pthis->colliders[0].dim.yShift = 0; + pthis->colliders[1].dim.radius *= thisx->scale.x; + pthis->colliders[1].dim.height *= thisx->scale.y; + pthis->colliders[1].dim.yShift *= thisx->scale.y; + pthis->actionFunc = NULL; + thisx->flags &= ~ACTOR_FLAG_0; + func_809CADDC(pthis, globalCtx); +} + +void EnBrob_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBrob* pthis = (EnBrob*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->colliders[0]); + Collider_DestroyCylinder(globalCtx, &pthis->colliders[1]); +} + +void func_809CADDC(EnBrob* pthis, GlobalContext* globalCtx) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->timer = pthis->actionFunc == func_809CB2B8 ? 200 : 0; + pthis->unk_1AE = 0; + pthis->actionFunc = func_809CB054; +} + +void func_809CAE44(EnBrob* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &object_brob_Anim_001750); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->unk_1AE = 1000; + pthis->actionFunc = func_809CB114; +} + +void func_809CAEA0(EnBrob* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_brob_Anim_001958, -5.0f); + pthis->unk_1AE = 8000; + pthis->timer = 1200; + pthis->actionFunc = func_809CB218; +} + +void func_809CAEF4(EnBrob* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_brob_Anim_000290, -5.0f); + pthis->unk_1AE -= 125.0f; + Actor_SetColorFilter(&pthis->dyna.actor, 0, 0xFF, 0, 0x50); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actionFunc = func_809CB2B8; +} + +void func_809CAF88(EnBrob* pthis) { + Animation_Change(&pthis->skelAnime, &object_brob_Anim_001750, -1.0f, + Animation_GetLastFrame(&object_brob_Anim_001750), 0.0f, ANIMMODE_ONCE, -5.0f); + pthis->unk_1AE = 8250; + pthis->actionFunc = func_809CB354; +} + +void func_809CB008(EnBrob* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_brob_Anim_001678, -5.0f); + pthis->timer = 10; + pthis->actionFunc = func_809CB458; +} + +void func_809CB054(EnBrob* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + if (func_8004356C(&pthis->dyna) != 0) { + func_8002F71C(globalCtx, &pthis->dyna.actor, 5.0f, pthis->dyna.actor.yawTowardsPlayer, 1.0f); + func_809CAE44(pthis, globalCtx); + } else if (pthis->dyna.actor.xzDistToPlayer < 300.0f) { + func_809CAE44(pthis, globalCtx); + } + } else if (pthis->timer >= 81) { + pthis->dyna.actor.colorFilterTimer = 80; + } +} + +void func_809CB114(EnBrob* pthis, GlobalContext* globalCtx) { + f32 curFrame; + + if (SkelAnime_Update(&pthis->skelAnime)) { + func_809CAEA0(pthis); + } else { + curFrame = pthis->skelAnime.curFrame; + if (curFrame < 8.0f) { + pthis->unk_1AE += 1000.0f; + } else if (curFrame < 12.0f) { + pthis->unk_1AE += 250.0f; + } else { + pthis->unk_1AE -= 250.0f; + } + } +} + +void func_809CB218(EnBrob* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 6.0f) || Animation_OnFrame(&pthis->skelAnime, 15.0f)) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EN_BROB_WAVE); + } + if (pthis->timer != 0) { + pthis->timer--; + } + if ((pthis->timer == 0) && (pthis->dyna.actor.xzDistToPlayer > 500.0f)) { + func_809CAF88(pthis); + } +} + +void func_809CB2B8(EnBrob* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + func_809CADDC(pthis, globalCtx); + } else if (pthis->skelAnime.curFrame < 8.0f) { + pthis->unk_1AE -= 1250.0f; + } + pthis->dyna.actor.colorFilterTimer = 0x50; +} + +void func_809CB354(EnBrob* pthis, GlobalContext* globalCtx) { + f32 curFrame; + + if (SkelAnime_Update(&pthis->skelAnime)) { + func_809CADDC(pthis, globalCtx); + } else { + curFrame = pthis->skelAnime.curFrame; + if (curFrame < 8.0f) { + pthis->unk_1AE -= 1000.0f; + } else if (curFrame < 12.0f) { + pthis->unk_1AE -= 250.0f; + } else { + pthis->unk_1AE += 250.0f; + } + } +} + +void func_809CB458(EnBrob* pthis, GlobalContext* globalCtx) { + Vec3f pos; + f32 dist1; + f32 dist2; + s32 i; + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0) && (pthis->timer != 0)) { + pthis->timer--; + } + + dist1 = globalCtx->gameplayFrames % 2 ? 0.0f : pthis->dyna.actor.scale.x * 5500.0f; + dist2 = pthis->dyna.actor.scale.x * 5500.0f; + + for (i = 0; i < 4; i++) { + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 255, 255, 255 }; + + if (i % 2) { + pos.x = pthis->dyna.actor.world.pos.x + dist1; + pos.z = pthis->dyna.actor.world.pos.z + dist2; + } else { + pos.x = pthis->dyna.actor.world.pos.x + dist2; + pos.z = pthis->dyna.actor.world.pos.z + dist1; + dist1 = -dist1; + dist2 = -dist2; + } + pos.y = (((Rand_ZeroOne() * 15000.0f) + 1000.0f) * pthis->dyna.actor.scale.y) + pthis->dyna.actor.world.pos.y; + EffectSsLightning_Spawn(globalCtx, &pos, &primColor, &envColor, pthis->dyna.actor.scale.y * 8000.0f, + Rand_ZeroOne() * 65536.0f, 4, 1); + } + + if (pthis->timer == 0) { + func_809CAEA0(pthis); + } +} + +void EnBrob_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBrob* pthis = (EnBrob*)thisx; + s32 i; + s32 acHits[2]; + + acHits[0] = (pthis->colliders[0].base.acFlags & AC_HIT) != 0; + acHits[1] = (pthis->colliders[1].base.acFlags & AC_HIT) != 0; + if ((acHits[0] && (pthis->colliders[0].info.acHitInfo->toucher.dmgFlags & 0x10)) || + (acHits[1] && (pthis->colliders[1].info.acHitInfo->toucher.dmgFlags & 0x10))) { + + for (i = 0; i < 2; i++) { + pthis->colliders[i].base.atFlags &= ~(AT_HIT | AT_BOUNCED); + pthis->colliders[i].base.acFlags &= ~AC_HIT; + } + + func_809CAEF4(pthis); + } else if ((pthis->colliders[0].base.atFlags & AT_HIT) || (pthis->colliders[1].base.atFlags & AT_HIT) || + (acHits[0] && (pthis->colliders[0].info.acHitInfo->toucher.dmgFlags & 0x100)) || + (acHits[1] && (pthis->colliders[1].info.acHitInfo->toucher.dmgFlags & 0x100))) { + + if (pthis->actionFunc == func_809CB114 && !(pthis->colliders[0].base.atFlags & AT_BOUNCED) && + !(pthis->colliders[1].base.atFlags & AT_BOUNCED)) { + func_8002F71C(globalCtx, &pthis->dyna.actor, 5.0f, pthis->dyna.actor.yawTowardsPlayer, 1.0f); + } else if (pthis->actionFunc != func_809CB114) { + func_809CB008(pthis); + } + + for (i = 0; i < 2; i++) { + pthis->colliders[i].base.atFlags &= ~(AT_HIT | AT_BOUNCED); + pthis->colliders[i].base.acFlags &= ~AC_HIT; + } + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc != func_809CB054 && pthis->actionFunc != func_809CB354) { + if (pthis->actionFunc != func_809CB2B8) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[0].base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[1].base); + if (pthis->actionFunc != func_809CB114) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[0].base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[1].base); + } + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[0].base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[1].base); + } +} + +void EnBrob_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnBrob* pthis = (EnBrob*)thisx; + MtxF mtx; + + Matrix_Get(&mtx); + if (limbIndex == 3) { + pthis->colliders[0].dim.pos.x = mtx.xw; + pthis->colliders[0].dim.pos.y = mtx.yw; + pthis->colliders[0].dim.pos.z = mtx.zw; + } else if (limbIndex == 8) { + pthis->colliders[1].dim.pos.x = mtx.xw; + pthis->colliders[1].dim.pos.y = (mtx.yw + 7.0f); + pthis->colliders[1].dim.pos.z = mtx.zw; + } +} + +void EnBrob_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBrob* pthis = (EnBrob*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + Matrix_Translate(0.0f, pthis->unk_1AE, 0.0f, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, EnBrob_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Brob/z_en_brob.h b/src/overlays/actors/ovl_En_Brob/z_en_brob.h index 4f71d489e..ed7b502db 100644 --- a/src/overlays/actors/ovl_En_Brob/z_en_brob.h +++ b/src/overlays/actors/ovl_En_Brob/z_en_brob.h @@ -6,7 +6,7 @@ struct EnBrob; -typedef void (*EnBrobActionFunc)(struct EnBrob* this, GlobalContext* globalCtx); +typedef void (*EnBrobActionFunc)(struct EnBrob* pthis, GlobalContext* globalCtx); typedef struct EnBrob { /* 0x0000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c deleted file mode 100644 index 127f60743..000000000 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ /dev/null @@ -1,449 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BUBBLE_Z_EN_BUBBLE_C -#include "actor_common.h" -#include "z_en_bubble.h" -#include "objects/object_bubble/object_bubble.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_0 - -void EnBubble_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBubble_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBubble_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBubble_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnBubble_Wait(EnBubble* this, GlobalContext* globalCtx); -void EnBubble_Pop(EnBubble* this, GlobalContext* globalCtx); -void EnBubble_Regrow(EnBubble* this, GlobalContext* globalCtx); - -const ActorInit En_Bubble_InitVars = { - ACTOR_EN_BUBBLE, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BUBBLE, - sizeof(EnBubble), - (ActorFunc)EnBubble_Init, - (ActorFunc)EnBubble_Destroy, - (ActorFunc)EnBubble_Update, - (ActorFunc)EnBubble_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x04 }, - { 0xFFCFD753, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 16 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00002824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, - OCELEM_NONE, - }, - { 0, { { 0, 0, 0 }, 16 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 2, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit2 = { - 1, 2, 25, 25, MASS_IMMOVABLE, -}; - -static Vec3f sEffectAccel = { 0.0f, -0.5f, 0.0f }; - -static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 255 }; - -static Color_RGBA8 sEffectEnvColor = { 150, 150, 150, 0 }; - -void EnBubble_SetDimensions(EnBubble* this, f32 dim) { - f32 a; - f32 b; - f32 c; - f32 d; - - this->actor.flags |= ACTOR_FLAG_0; - Actor_SetScale(&this->actor, 1.0f); - this->actor.shape.yOffset = 16.0f; - this->graphicRotSpeed = 16.0f; - this->graphicEccentricity = 0.08f; - this->expansionWidth = dim; - this->expansionHeight = dim; - a = Rand_ZeroOne(); - b = Rand_ZeroOne(); - c = Rand_ZeroOne(); - this->unk_218 = 1.0f; - this->unk_21C = 1.0f; - d = (a * a) + (b * b) + (c * c); - this->unk_1FC.x = a / d; - this->unk_1FC.y = b / d; - this->unk_1FC.z = c / d; -} - -u32 func_809CBCBC(EnBubble* this) { - ColliderInfo* info = &this->colliderSphere.elements[0].info; - - info->toucher.dmgFlags = 0x8; - info->toucher.effect = 0; - info->toucher.damage = 4; - info->toucherFlags = TOUCH_ON; - this->actor.velocity.y = 0.0f; - return 6; -} - -// only called in an unused actionFunc -u32 func_809CBCEC(EnBubble* this) { - EnBubble_SetDimensions(this, -1.0f); - return 12; -} - -void EnBubble_DamagePlayer(EnBubble* this, GlobalContext* globalCtx) { - s32 damage = -this->colliderSphere.elements[0].info.toucher.damage; - - globalCtx->damagePlayer(globalCtx, damage); - func_8002F7A0(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f); -} - -s32 EnBubble_Explosion(EnBubble* this, GlobalContext* globalCtx) { - u32 i; - Vec3f effectAccel; - Vec3f effectVel; - Vec3f effectPos; - - effectAccel = sEffectAccel; - Math_SmoothStepToF(&this->expansionWidth, 4.0f, 0.1f, 1000.0f, 0.0f); - Math_SmoothStepToF(&this->expansionHeight, 4.0f, 0.1f, 1000.0f, 0.0f); - Math_SmoothStepToF(&this->graphicRotSpeed, 54.0f, 0.1f, 1000.0f, 0.0f); - Math_SmoothStepToF(&this->graphicEccentricity, 0.2f, 0.1f, 1000.0f, 0.0f); - this->actor.shape.yOffset = ((this->expansionHeight + 1.0f) * 16.0f); - - if (DECR(this->explosionCountdown) != 0) { - return -1; - } - effectPos.x = this->actor.world.pos.x; - effectPos.y = this->actor.world.pos.y + this->actor.shape.yOffset; - effectPos.z = this->actor.world.pos.z; - for (i = 0; i < 20; i++) { - effectVel.x = (Rand_ZeroOne() - 0.5f) * 7.0f; - effectVel.y = Rand_ZeroOne() * 7.0f; - effectVel.z = (Rand_ZeroOne() - 0.5f) * 7.0f; - EffectSsDtBubble_SpawnCustomColor(globalCtx, &effectPos, &effectVel, &effectAccel, &sEffectPrimColor, - &sEffectEnvColor, Rand_S16Offset(100, 50), 0x19, 0); - } - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x50); - this->actor.flags &= ~ACTOR_FLAG_0; - return Rand_S16Offset(90, 60); -} - -// only called in an unused actionFunc -u32 func_809CBFD4(EnBubble* this) { - if (DECR(this->explosionCountdown) != 0) { - return -1; - } - return func_809CBCEC(this); -} - -// only called in an unused actionFunc -s32 func_809CC020(EnBubble* this) { - this->expansionWidth += 1.0f / 12.0f; - this->expansionHeight += 1.0f / 12.0f; - - if (DECR(this->explosionCountdown) != 0) { - return false; - } - return true; -} - -void EnBubble_Vec3fNormalizedRelfect(Vec3f* vec1, Vec3f* vec2, Vec3f* ret) { - f32 norm; - - Math3D_Vec3fReflect(vec1, vec2, ret); - norm = sqrtf((ret->x * ret->x) + (ret->y * ret->y) + (ret->z * ret->z)); - if (norm != 0.0f) { - ret->x /= norm; - ret->y /= norm; - ret->z /= norm; - } else { - ret->x = ret->y = ret->z = 0.0f; - } -} - -void EnBubble_Vec3fNormalize(Vec3f* vec) { - f32 norm = sqrt((vec->x * vec->x) + (vec->y * vec->y) + (vec->z * vec->z)); - - if (norm != 0.0f) { - vec->x /= norm; - vec->y /= norm; - vec->z /= norm; - } else { - vec->x = vec->y = vec->z = 0.0f; - } -} - -void EnBubble_Fly(EnBubble* this, GlobalContext* globalCtx) { - CollisionPoly* sp94; - Actor* bumpActor; - Vec3f sp84; - Vec3f sp78; - Vec3f sp6C; - Vec3f sp60; - Vec3f sp54; - f32 bounceSpeed; - s32 bgId; - u8 bounceCount; - - if (this->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { - bumpActor = this->colliderSphere.base.ac; - this->normalizedBumpVelocity = bumpActor->velocity; - EnBubble_Vec3fNormalize(&this->normalizedBumpVelocity); - this->velocityFromBump.x += (this->normalizedBumpVelocity.x * 3.0f); - this->velocityFromBump.y += (this->normalizedBumpVelocity.y * 3.0f); - this->velocityFromBump.z += (this->normalizedBumpVelocity.z * 3.0f); - } - this->sinkSpeed -= 0.1f; - if (this->sinkSpeed < this->actor.minVelocityY) { - this->sinkSpeed = this->actor.minVelocityY; - } - sp54.x = this->velocityFromBounce.x + this->velocityFromBump.x; - sp54.y = this->velocityFromBounce.y + this->velocityFromBump.y + this->sinkSpeed; - sp54.z = this->velocityFromBounce.z + this->velocityFromBump.z; - EnBubble_Vec3fNormalize(&sp54); - - sp78.x = this->actor.world.pos.x; - sp78.y = this->actor.world.pos.y + this->actor.shape.yOffset; - sp78.z = this->actor.world.pos.z; - sp6C = sp78; - - sp6C.x += (sp54.x * 24.0f); - sp6C.y += (sp54.y * 24.0f); - sp6C.z += (sp54.z * 24.0f); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp78, &sp6C, &sp84, &sp94, true, true, true, false, &bgId)) { - sp60.x = COLPOLY_GET_NORMAL(sp94->normal.x); - sp60.y = COLPOLY_GET_NORMAL(sp94->normal.y); - sp60.z = COLPOLY_GET_NORMAL(sp94->normal.z); - EnBubble_Vec3fNormalizedRelfect(&sp54, &sp60, &sp54); - this->bounceDirection = sp54; - bounceCount = this->bounceCount; - this->bounceCount = ++bounceCount; - if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { - this->bounceCount = 0; - } - bounceSpeed = (this->bounceCount == 0) ? 3.6000001f : 3.0f; - this->velocityFromBump.x = this->velocityFromBump.y = this->velocityFromBump.z = 0.0f; - this->velocityFromBounce.x = (this->bounceDirection.x * bounceSpeed); - this->velocityFromBounce.y = (this->bounceDirection.y * bounceSpeed); - this->velocityFromBounce.z = (this->bounceDirection.z * bounceSpeed); - this->sinkSpeed = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AWA_BOUND); - this->graphicRotSpeed = 128.0f; - this->graphicEccentricity = 0.48f; - } else if (this->actor.bgCheckFlags & 0x20 && sp54.y < 0.0f) { - sp60.x = sp60.z = 0.0f; - sp60.y = 1.0f; - EnBubble_Vec3fNormalizedRelfect(&sp54, &sp60, &sp54); - this->bounceDirection = sp54; - bounceCount = this->bounceCount; - this->bounceCount = ++bounceCount; - if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { - this->bounceCount = 0; - } - bounceSpeed = (this->bounceCount == 0) ? 3.6000001f : 3.0f; - this->velocityFromBump.x = this->velocityFromBump.y = this->velocityFromBump.z = 0.0f; - this->velocityFromBounce.x = (this->bounceDirection.x * bounceSpeed); - this->velocityFromBounce.y = (this->bounceDirection.y * bounceSpeed); - this->velocityFromBounce.z = (this->bounceDirection.z * bounceSpeed); - this->sinkSpeed = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AWA_BOUND); - this->graphicRotSpeed = 128.0f; - this->graphicEccentricity = 0.48f; - } - this->actor.velocity.x = this->velocityFromBounce.x + this->velocityFromBump.x; - this->actor.velocity.y = this->velocityFromBounce.y + this->velocityFromBump.y + this->sinkSpeed; - this->actor.velocity.z = this->velocityFromBounce.z + this->velocityFromBump.z; - Math_ApproachF(&this->velocityFromBump.x, 0.0f, 0.3f, 0.1f); - Math_ApproachF(&this->velocityFromBump.y, 0.0f, 0.3f, 0.1f); - Math_ApproachF(&this->velocityFromBump.z, 0.0f, 0.3f, 0.1f); -} - -u32 func_809CC648(EnBubble* this) { - if (((this->colliderSphere.base.acFlags & AC_HIT) != 0) == false) { - return false; - } - this->colliderSphere.base.acFlags &= ~AC_HIT; - if (this->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { - this->unk_1F0.x = this->colliderSphere.base.ac->velocity.x / 10.0f; - this->unk_1F0.y = this->colliderSphere.base.ac->velocity.y / 10.0f; - this->unk_1F0.z = this->colliderSphere.base.ac->velocity.z / 10.0f; - this->graphicRotSpeed = 128.0f; - this->graphicEccentricity = 0.48f; - return false; - } - this->unk_208 = 8; - return true; -} - -u32 EnBubble_DetectPop(EnBubble* this, GlobalContext* globalCtx) { - if (DECR(this->unk_208) != 0 || this->actionFunc == EnBubble_Pop) { - return false; - } - if (this->colliderSphere.base.ocFlags2 & OC2_HIT_PLAYER) { - this->colliderSphere.base.ocFlags2 &= ~OC2_HIT_PLAYER; - EnBubble_DamagePlayer(this, globalCtx); - this->unk_208 = 8; - return true; - } - return func_809CC648(this); -} - -void func_809CC774(EnBubble* this) { - ColliderJntSphElementDim* dim; - Vec3f src; - Vec3f dest; - - dim = &this->colliderSphere.elements[0].dim; - src.x = dim->modelSphere.center.x; - src.y = dim->modelSphere.center.y; - src.z = dim->modelSphere.center.z; - - Matrix_MultVec3f(&src, &dest); - dim->worldSphere.center.x = dest.x; - dim->worldSphere.center.y = dest.y; - dim->worldSphere.center.z = dest.z; - dim->worldSphere.radius = dim->modelSphere.radius * (1.0f + this->expansionWidth); - this->colliderSphere.elements[1].dim = *dim; -} - -void EnBubble_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBubble* this = (EnBubble*)thisx; - u32 pad; - - ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); - Collider_InitJntSph(globalCtx, &this->colliderSphere); - Collider_SetJntSph(globalCtx, &this->colliderSphere, &this->actor, &sJntSphInit, this->colliderSphereItems); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(9), &sColChkInfoInit2); - this->actor.naviEnemyId = 0x16; - this->bounceDirection.x = Rand_ZeroOne(); - this->bounceDirection.y = Rand_ZeroOne(); - this->bounceDirection.z = Rand_ZeroOne(); - EnBubble_Vec3fNormalize(&this->bounceDirection); - this->velocityFromBounce.x = this->bounceDirection.x * 3.0f; - this->velocityFromBounce.y = this->bounceDirection.y * 3.0f; - this->velocityFromBounce.z = this->bounceDirection.z * 3.0f; - EnBubble_SetDimensions(this, 0.0f); - this->actionFunc = EnBubble_Wait; -} - -void EnBubble_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBubble* this = (EnBubble*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->colliderSphere); -} - -void EnBubble_Wait(EnBubble* this, GlobalContext* globalCtx) { - if (EnBubble_DetectPop(this, globalCtx)) { - this->explosionCountdown = func_809CBCBC(this); - this->actionFunc = EnBubble_Pop; - } else { - EnBubble_Fly(this, globalCtx); - this->actor.shape.yOffset = ((this->expansionHeight + 1.0f) * 16.0f); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); - } -} - -void EnBubble_Pop(EnBubble* this, GlobalContext* globalCtx) { - if (EnBubble_Explosion(this, globalCtx) >= 0) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); - Actor_Kill(&this->actor); - } -} - -// unused -void EnBubble_Disappear(EnBubble* this, GlobalContext* globalCtx) { - s32 temp_v0; - - temp_v0 = func_809CBFD4(this); - if (temp_v0 >= 0) { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->explosionCountdown = temp_v0; - this->actionFunc = EnBubble_Regrow; - } -} - -// unused -void EnBubble_Regrow(EnBubble* this, GlobalContext* globalCtx) { - if (func_809CC020(this)) { - this->actionFunc = EnBubble_Wait; - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); -} - -void EnBubble_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBubble* this = (EnBubble*)thisx; - - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 16.0f, 16.0f, 0.0f, 7); - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, this->actor.shape.yOffset); -} - -void EnBubble_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBubble* this = (EnBubble*)thisx; - u32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bubble.c", 1175); - - if (this->actionFunc != EnBubble_Disappear) { - func_80093D84(globalCtx->state.gfxCtx); - Math_SmoothStepToF(&this->graphicRotSpeed, 16.0f, 0.2f, 1000.0f, 0.0f); - Math_SmoothStepToF(&this->graphicEccentricity, 0.08f, 0.2f, 1000.0f, 0.0f); - func_800D1FD4(&globalCtx->billboardMtxF); - - Matrix_Scale(this->expansionWidth + 1.0f, this->expansionHeight + 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(((f32)globalCtx->state.frames * (M_PI / 180.0f)) * this->graphicRotSpeed, MTXMODE_APPLY); - Matrix_Scale(this->graphicEccentricity + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ((-(f32)globalCtx->state.frames * (M_PI / 180.0f)) * this->graphicRotSpeed, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bubble.c", 1220), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bubble.c", 1226); - - if (this->actionFunc != EnBubble_Disappear) { - this->actor.shape.shadowScale = (f32)((this->expansionWidth + 1.0f) * 0.2f); - func_809CC774(this); - } -} diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.cpp b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.cpp new file mode 100644 index 000000000..202a75fc0 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.cpp @@ -0,0 +1,449 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BUBBLE_Z_EN_BUBBLE_C +#include "actor_common.h" +#include "z_en_bubble.h" +#include "objects/object_bubble/object_bubble.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_0 + +void EnBubble_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBubble_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBubble_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBubble_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnBubble_Wait(EnBubble* pthis, GlobalContext* globalCtx); +void EnBubble_Pop(EnBubble* pthis, GlobalContext* globalCtx); +void EnBubble_Regrow(EnBubble* pthis, GlobalContext* globalCtx); + +ActorInit En_Bubble_InitVars = { + ACTOR_EN_BUBBLE, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BUBBLE, + sizeof(EnBubble), + (ActorFunc)EnBubble_Init, + (ActorFunc)EnBubble_Destroy, + (ActorFunc)EnBubble_Update, + (ActorFunc)EnBubble_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x04 }, + { 0xFFCFD753, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 16 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_NONE, + }, + { 0, { { 0, 0, 0 }, 16 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit2 = { + 1, 2, 25, 25, MASS_IMMOVABLE, +}; + +static Vec3f sEffectAccel = { 0.0f, -0.5f, 0.0f }; + +static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 255 }; + +static Color_RGBA8 sEffectEnvColor = { 150, 150, 150, 0 }; + +void EnBubble_SetDimensions(EnBubble* pthis, f32 dim) { + f32 a; + f32 b; + f32 c; + f32 d; + + pthis->actor.flags |= ACTOR_FLAG_0; + Actor_SetScale(&pthis->actor, 1.0f); + pthis->actor.shape.yOffset = 16.0f; + pthis->graphicRotSpeed = 16.0f; + pthis->graphicEccentricity = 0.08f; + pthis->expansionWidth = dim; + pthis->expansionHeight = dim; + a = Rand_ZeroOne(); + b = Rand_ZeroOne(); + c = Rand_ZeroOne(); + pthis->unk_218 = 1.0f; + pthis->unk_21C = 1.0f; + d = (a * a) + (b * b) + (c * c); + pthis->unk_1FC.x = a / d; + pthis->unk_1FC.y = b / d; + pthis->unk_1FC.z = c / d; +} + +u32 func_809CBCBC(EnBubble* pthis) { + ColliderInfo* info = &pthis->colliderSphere.elements[0].info; + + info->toucher.dmgFlags = 0x8; + info->toucher.effect = 0; + info->toucher.damage = 4; + info->toucherFlags = TOUCH_ON; + pthis->actor.velocity.y = 0.0f; + return 6; +} + +// only called in an unused actionFunc +u32 func_809CBCEC(EnBubble* pthis) { + EnBubble_SetDimensions(pthis, -1.0f); + return 12; +} + +void EnBubble_DamagePlayer(EnBubble* pthis, GlobalContext* globalCtx) { + s32 damage = -pthis->colliderSphere.elements[0].info.toucher.damage; + + globalCtx->damagePlayer(globalCtx, damage); + func_8002F7A0(globalCtx, &pthis->actor, 6.0f, pthis->actor.yawTowardsPlayer, 6.0f); +} + +s32 EnBubble_Explosion(EnBubble* pthis, GlobalContext* globalCtx) { + u32 i; + Vec3f effectAccel; + Vec3f effectVel; + Vec3f effectPos; + + effectAccel = sEffectAccel; + Math_SmoothStepToF(&pthis->expansionWidth, 4.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->expansionHeight, 4.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->graphicRotSpeed, 54.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->graphicEccentricity, 0.2f, 0.1f, 1000.0f, 0.0f); + pthis->actor.shape.yOffset = ((pthis->expansionHeight + 1.0f) * 16.0f); + + if (DECR(pthis->explosionCountdown) != 0) { + return -1; + } + effectPos.x = pthis->actor.world.pos.x; + effectPos.y = pthis->actor.world.pos.y + pthis->actor.shape.yOffset; + effectPos.z = pthis->actor.world.pos.z; + for (i = 0; i < 20; i++) { + effectVel.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + effectVel.y = Rand_ZeroOne() * 7.0f; + effectVel.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &effectPos, &effectVel, &effectAccel, &sEffectPrimColor, + &sEffectEnvColor, Rand_S16Offset(100, 50), 0x19, 0); + } + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, 0x50); + pthis->actor.flags &= ~ACTOR_FLAG_0; + return Rand_S16Offset(90, 60); +} + +// only called in an unused actionFunc +u32 func_809CBFD4(EnBubble* pthis) { + if (DECR(pthis->explosionCountdown) != 0) { + return -1; + } + return func_809CBCEC(pthis); +} + +// only called in an unused actionFunc +s32 func_809CC020(EnBubble* pthis) { + pthis->expansionWidth += 1.0f / 12.0f; + pthis->expansionHeight += 1.0f / 12.0f; + + if (DECR(pthis->explosionCountdown) != 0) { + return false; + } + return true; +} + +void EnBubble_Vec3fNormalizedRelfect(Vec3f* vec1, Vec3f* vec2, Vec3f* ret) { + f32 norm; + + Math3D_Vec3fReflect(vec1, vec2, ret); + norm = sqrtf((ret->x * ret->x) + (ret->y * ret->y) + (ret->z * ret->z)); + if (norm != 0.0f) { + ret->x /= norm; + ret->y /= norm; + ret->z /= norm; + } else { + ret->x = ret->y = ret->z = 0.0f; + } +} + +void EnBubble_Vec3fNormalize(Vec3f* vec) { + f32 norm = sqrt((vec->x * vec->x) + (vec->y * vec->y) + (vec->z * vec->z)); + + if (norm != 0.0f) { + vec->x /= norm; + vec->y /= norm; + vec->z /= norm; + } else { + vec->x = vec->y = vec->z = 0.0f; + } +} + +void EnBubble_Fly(EnBubble* pthis, GlobalContext* globalCtx) { + CollisionPoly* sp94; + Actor* bumpActor; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + f32 bounceSpeed; + s32 bgId; + u8 bounceCount; + + if (pthis->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { + bumpActor = pthis->colliderSphere.base.ac; + pthis->normalizedBumpVelocity = bumpActor->velocity; + EnBubble_Vec3fNormalize(&pthis->normalizedBumpVelocity); + pthis->velocityFromBump.x += (pthis->normalizedBumpVelocity.x * 3.0f); + pthis->velocityFromBump.y += (pthis->normalizedBumpVelocity.y * 3.0f); + pthis->velocityFromBump.z += (pthis->normalizedBumpVelocity.z * 3.0f); + } + pthis->sinkSpeed -= 0.1f; + if (pthis->sinkSpeed < pthis->actor.minVelocityY) { + pthis->sinkSpeed = pthis->actor.minVelocityY; + } + sp54.x = pthis->velocityFromBounce.x + pthis->velocityFromBump.x; + sp54.y = pthis->velocityFromBounce.y + pthis->velocityFromBump.y + pthis->sinkSpeed; + sp54.z = pthis->velocityFromBounce.z + pthis->velocityFromBump.z; + EnBubble_Vec3fNormalize(&sp54); + + sp78.x = pthis->actor.world.pos.x; + sp78.y = pthis->actor.world.pos.y + pthis->actor.shape.yOffset; + sp78.z = pthis->actor.world.pos.z; + sp6C = sp78; + + sp6C.x += (sp54.x * 24.0f); + sp6C.y += (sp54.y * 24.0f); + sp6C.z += (sp54.z * 24.0f); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp78, &sp6C, &sp84, &sp94, true, true, true, false, &bgId)) { + sp60.x = COLPOLY_GET_NORMAL(sp94->normal.x); + sp60.y = COLPOLY_GET_NORMAL(sp94->normal.y); + sp60.z = COLPOLY_GET_NORMAL(sp94->normal.z); + EnBubble_Vec3fNormalizedRelfect(&sp54, &sp60, &sp54); + pthis->bounceDirection = sp54; + bounceCount = pthis->bounceCount; + pthis->bounceCount = ++bounceCount; + if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { + pthis->bounceCount = 0; + } + bounceSpeed = (pthis->bounceCount == 0) ? 3.6000001f : 3.0f; + pthis->velocityFromBump.x = pthis->velocityFromBump.y = pthis->velocityFromBump.z = 0.0f; + pthis->velocityFromBounce.x = (pthis->bounceDirection.x * bounceSpeed); + pthis->velocityFromBounce.y = (pthis->bounceDirection.y * bounceSpeed); + pthis->velocityFromBounce.z = (pthis->bounceDirection.z * bounceSpeed); + pthis->sinkSpeed = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_AWA_BOUND); + pthis->graphicRotSpeed = 128.0f; + pthis->graphicEccentricity = 0.48f; + } else if (pthis->actor.bgCheckFlags & 0x20 && sp54.y < 0.0f) { + sp60.x = sp60.z = 0.0f; + sp60.y = 1.0f; + EnBubble_Vec3fNormalizedRelfect(&sp54, &sp60, &sp54); + pthis->bounceDirection = sp54; + bounceCount = pthis->bounceCount; + pthis->bounceCount = ++bounceCount; + if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { + pthis->bounceCount = 0; + } + bounceSpeed = (pthis->bounceCount == 0) ? 3.6000001f : 3.0f; + pthis->velocityFromBump.x = pthis->velocityFromBump.y = pthis->velocityFromBump.z = 0.0f; + pthis->velocityFromBounce.x = (pthis->bounceDirection.x * bounceSpeed); + pthis->velocityFromBounce.y = (pthis->bounceDirection.y * bounceSpeed); + pthis->velocityFromBounce.z = (pthis->bounceDirection.z * bounceSpeed); + pthis->sinkSpeed = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_AWA_BOUND); + pthis->graphicRotSpeed = 128.0f; + pthis->graphicEccentricity = 0.48f; + } + pthis->actor.velocity.x = pthis->velocityFromBounce.x + pthis->velocityFromBump.x; + pthis->actor.velocity.y = pthis->velocityFromBounce.y + pthis->velocityFromBump.y + pthis->sinkSpeed; + pthis->actor.velocity.z = pthis->velocityFromBounce.z + pthis->velocityFromBump.z; + Math_ApproachF(&pthis->velocityFromBump.x, 0.0f, 0.3f, 0.1f); + Math_ApproachF(&pthis->velocityFromBump.y, 0.0f, 0.3f, 0.1f); + Math_ApproachF(&pthis->velocityFromBump.z, 0.0f, 0.3f, 0.1f); +} + +u32 func_809CC648(EnBubble* pthis) { + if (((pthis->colliderSphere.base.acFlags & AC_HIT) != 0) == false) { + return false; + } + pthis->colliderSphere.base.acFlags &= ~AC_HIT; + if (pthis->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { + pthis->unk_1F0.x = pthis->colliderSphere.base.ac->velocity.x / 10.0f; + pthis->unk_1F0.y = pthis->colliderSphere.base.ac->velocity.y / 10.0f; + pthis->unk_1F0.z = pthis->colliderSphere.base.ac->velocity.z / 10.0f; + pthis->graphicRotSpeed = 128.0f; + pthis->graphicEccentricity = 0.48f; + return false; + } + pthis->unk_208 = 8; + return true; +} + +u32 EnBubble_DetectPop(EnBubble* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->unk_208) != 0 || pthis->actionFunc == EnBubble_Pop) { + return false; + } + if (pthis->colliderSphere.base.ocFlags2 & OC2_HIT_PLAYER) { + pthis->colliderSphere.base.ocFlags2 &= ~OC2_HIT_PLAYER; + EnBubble_DamagePlayer(pthis, globalCtx); + pthis->unk_208 = 8; + return true; + } + return func_809CC648(pthis); +} + +void func_809CC774(EnBubble* pthis) { + ColliderJntSphElementDim* dim; + Vec3f src; + Vec3f dest; + + dim = &pthis->colliderSphere.elements[0].dim; + src.x = dim->modelSphere.center.x; + src.y = dim->modelSphere.center.y; + src.z = dim->modelSphere.center.z; + + Matrix_MultVec3f(&src, &dest); + dim->worldSphere.center.x = dest.x; + dim->worldSphere.center.y = dest.y; + dim->worldSphere.center.z = dest.z; + dim->worldSphere.radius = dim->modelSphere.radius * (1.0f + pthis->expansionWidth); + pthis->colliderSphere.elements[1].dim = *dim; +} + +void EnBubble_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBubble* pthis = (EnBubble*)thisx; + u32 pad; + + ActorShape_Init(&pthis->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); + Collider_InitJntSph(globalCtx, &pthis->colliderSphere); + Collider_SetJntSph(globalCtx, &pthis->colliderSphere, &pthis->actor, &sJntSphInit, pthis->colliderSphereItems); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(9), &sColChkInfoInit2); + pthis->actor.naviEnemyId = 0x16; + pthis->bounceDirection.x = Rand_ZeroOne(); + pthis->bounceDirection.y = Rand_ZeroOne(); + pthis->bounceDirection.z = Rand_ZeroOne(); + EnBubble_Vec3fNormalize(&pthis->bounceDirection); + pthis->velocityFromBounce.x = pthis->bounceDirection.x * 3.0f; + pthis->velocityFromBounce.y = pthis->bounceDirection.y * 3.0f; + pthis->velocityFromBounce.z = pthis->bounceDirection.z * 3.0f; + EnBubble_SetDimensions(pthis, 0.0f); + pthis->actionFunc = EnBubble_Wait; +} + +void EnBubble_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBubble* pthis = (EnBubble*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->colliderSphere); +} + +void EnBubble_Wait(EnBubble* pthis, GlobalContext* globalCtx) { + if (EnBubble_DetectPop(pthis, globalCtx)) { + pthis->explosionCountdown = func_809CBCBC(pthis); + pthis->actionFunc = EnBubble_Pop; + } else { + EnBubble_Fly(pthis, globalCtx); + pthis->actor.shape.yOffset = ((pthis->expansionHeight + 1.0f) * 16.0f); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSphere.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSphere.base); + } +} + +void EnBubble_Pop(EnBubble* pthis, GlobalContext* globalCtx) { + if (EnBubble_Explosion(pthis, globalCtx) >= 0) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + Actor_Kill(&pthis->actor); + } +} + +// unused +void EnBubble_Disappear(EnBubble* pthis, GlobalContext* globalCtx) { + s32 temp_v0; + + temp_v0 = func_809CBFD4(pthis); + if (temp_v0 >= 0) { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + pthis->explosionCountdown = temp_v0; + pthis->actionFunc = EnBubble_Regrow; + } +} + +// unused +void EnBubble_Regrow(EnBubble* pthis, GlobalContext* globalCtx) { + if (func_809CC020(pthis)) { + pthis->actionFunc = EnBubble_Wait; + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSphere.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSphere.base); +} + +void EnBubble_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBubble* pthis = (EnBubble*)thisx; + + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 16.0f, 16.0f, 0.0f, 7); + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, pthis->actor.shape.yOffset); +} + +void EnBubble_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBubble* pthis = (EnBubble*)thisx; + u32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bubble.c", 1175); + + if (pthis->actionFunc != EnBubble_Disappear) { + func_80093D84(globalCtx->state.gfxCtx); + Math_SmoothStepToF(&pthis->graphicRotSpeed, 16.0f, 0.2f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->graphicEccentricity, 0.08f, 0.2f, 1000.0f, 0.0f); + func_800D1FD4(&globalCtx->billboardMtxF); + + Matrix_Scale(pthis->expansionWidth + 1.0f, pthis->expansionHeight + 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(((f32)globalCtx->state.frames * (M_PI / 180.0f)) * pthis->graphicRotSpeed, MTXMODE_APPLY); + Matrix_Scale(pthis->graphicEccentricity + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ((-(f32)globalCtx->state.frames * (M_PI / 180.0f)) * pthis->graphicRotSpeed, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bubble.c", 1220), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bubble.c", 1226); + + if (pthis->actionFunc != EnBubble_Disappear) { + pthis->actor.shape.shadowScale = (f32)((pthis->expansionWidth + 1.0f) * 0.2f); + func_809CC774(pthis); + } +} diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c deleted file mode 100644 index 45e6e96e8..000000000 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ /dev/null @@ -1,447 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BUTTE_Z_EN_BUTTE_C -#include "actor_common.h" -/* - * File: z_en_butte.c - * Overlay: ovl_En_Butte - * Description: Butterfly - */ - -#include "z_en_butte.h" -#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void EnButte_Init(Actor* thisx, GlobalContext* globalCtx); -void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnButte_Update(Actor* thisx, GlobalContext* globalCtx); -void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnButte_SetupFlyAround(EnButte* this); -void EnButte_FlyAround(EnButte* this, GlobalContext* globalCtx); -void EnButte_SetupFollowLink(EnButte* this); -void EnButte_FollowLink(EnButte* this, GlobalContext* globalCtx); -void EnButte_SetupTransformIntoFairy(EnButte* this); -void EnButte_TransformIntoFairy(EnButte* this, GlobalContext* globalCtx); -void EnButte_SetupWaitToDie(EnButte* this); -void EnButte_WaitToDie(EnButte* this, GlobalContext* globalCtx); - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x000, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 5 }, 100 } }, -}; -static ColliderJntSphInit sColliderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -const ActorInit En_Butte_InitVars = { - ACTOR_EN_BUTTE, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_FIELD_KEEP, - sizeof(EnButte), - (ActorFunc)EnButte_Init, - (ActorFunc)EnButte_Destroy, - (ActorFunc)EnButte_Update, - (ActorFunc)EnButte_Draw, -}; - -typedef struct { - /* 0x00 */ s16 minTime; - /* 0x02 */ s16 maxTime; - /* 0x04 */ f32 speedXZTarget; - /* 0x08 */ f32 speedXZScale; - /* 0x0C */ f32 speedXZStep; - /* 0x10 */ s16 rotYStep; -} EnButteFlightParams; // size = 0x14 - -static EnButteFlightParams sFlyAroundParams[] = { - { 5, 35, 0.0f, 0.1f, 0.5f, 0 }, - { 10, 45, 1.1f, 0.1f, 0.25f, 1000 }, - { 10, 40, 1.5f, 0.1f, 0.3f, 2000 }, -}; -static EnButteFlightParams sFollowLinkParams[] = { - { 3, 3, 0.8f, 0.1f, 0.2f, 0 }, - { 10, 20, 2.0f, 0.3f, 1.0f, 0 }, - { 10, 20, 2.4f, 0.3f, 1.0f, 0 }, -}; - -void EnButte_SelectFlightParams(EnButte* this, EnButteFlightParams* flightParams) { - if (this->flightParamsIdx == 0) { - if (Rand_ZeroOne() < 0.6f) { - this->flightParamsIdx = 1; - } else { - this->flightParamsIdx = 2; - } - } else { - this->flightParamsIdx = 0; - } - - this->timer = Rand_S16Offset(flightParams->minTime, flightParams->maxTime); -} - -static f32 sTransformationEffectScale = 0.0f; -static s16 sTransformationEffectAlpha = 0; - -void EnButte_ResetTransformationEffect(void) { - sTransformationEffectScale = 0.0f; - sTransformationEffectAlpha = 0; -} - -void EnButte_UpdateTransformationEffect(void) { - sTransformationEffectScale += 0.003f; - sTransformationEffectAlpha += 4000; -} - -void EnButte_DrawTransformationEffect(EnButte* this, GlobalContext* globalCtx) { - static Vec3f D_809CE3C4 = { 0.0f, 0.0f, -3.0f }; - Vec3f sp5C; - s32 alpha; - Vec3s camDir; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_choo.c", 295); - - func_80093C14(globalCtx->state.gfxCtx); - - alpha = Math_SinS(sTransformationEffectAlpha) * 250; - alpha = CLAMP(alpha, 0, 255); - - Camera_GetCamDir(&camDir, GET_ACTIVE_CAM(globalCtx)); - Matrix_RotateY(camDir.y * (M_PI / 0x8000), MTXMODE_NEW); - Matrix_RotateX(camDir.x * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(camDir.z * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultVec3f(&D_809CE3C4, &sp5C); - func_800D1694(this->actor.focus.pos.x + sp5C.x, this->actor.focus.pos.y + sp5C.y, this->actor.focus.pos.z + sp5C.z, - &camDir); - Matrix_Scale(sTransformationEffectScale, sTransformationEffectScale, sTransformationEffectScale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_choo.c", 317), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 180, alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 210, 255); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffFlash1DL)); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_choo.c", 326); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), -}; - -void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { - EnButte* this = (EnButte*)thisx; - - if (this->actor.params == -1) { - this->actor.params = 0; - } - - Actor_ProcessInitChain(&this->actor, sInitChain); - - if ((this->actor.params & 1) == 1) { - this->actor.uncullZoneScale = 200.0f; - } - - SkelAnime_Init(globalCtx, &this->skelAnime, &gButterflySkel, &gButterflyAnim, this->jointTable, this->morphTable, - 8); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderInit, this->colliderItems); - this->actor.colChkInfo.mass = 0; - this->unk_25C = Rand_ZeroOne() * 0xFFFF; - this->unk_25E = Rand_ZeroOne() * 0xFFFF; - this->unk_260 = Rand_ZeroOne() * 0xFFFF; - Animation_Change(&this->skelAnime, &gButterflyAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); - EnButte_SetupFlyAround(this); - this->actor.shape.rot.x -= 0x2320; - this->drawSkelAnime = true; - // "field keep butterfly" - osSyncPrintf("(field keep 蝶)(%x)(arg_data 0x%04x)\n", this, this->actor.params); -} - -void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnButte* this = (EnButte*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void func_809CD56C(EnButte* this) { - static f32 D_809CE3E0[] = { 50.0f, 80.0f, 100.0f }; - static f32 D_809CE3EC[] = { 30.0f, 40.0f, 50.0f }; - - this->actor.shape.yOffset += Math_SinS(this->unk_25C) * D_809CE3E0[this->flightParamsIdx] + - Math_SinS(this->unk_25E) * D_809CE3EC[this->flightParamsIdx]; - this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -2000.0f, 2000.0f); -} - -void func_809CD634(EnButte* this) { - static f32 D_809CE3F8[] = { 15.0f, 20.0f, 25.0f }; - static f32 D_809CE404[] = { 7.5f, 10.0f, 12.5f }; - - this->actor.shape.yOffset += Math_SinS(this->unk_25C) * D_809CE3F8[this->flightParamsIdx] + - Math_SinS(this->unk_25E) * D_809CE404[this->flightParamsIdx]; - this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -500.0f, 500.0f); -} - -void EnButte_Turn(EnButte* this) { - s16 target = this->actor.world.rot.y + 0x8000; - s16 diff = target - this->actor.shape.rot.y; - - Math_ScaledStepToS(&this->actor.shape.rot.y, target, ABS(diff) >> 3); - this->actor.shape.rot.x = (s16)(sinf(this->unk_260) * 600.0f) - 0x2320; -} - -void EnButte_SetupFlyAround(EnButte* this) { - EnButte_SelectFlightParams(this, &sFlyAroundParams[this->flightParamsIdx]); - this->actionFunc = EnButte_FlyAround; -} - -void EnButte_FlyAround(EnButte* this, GlobalContext* globalCtx) { - EnButteFlightParams* flightParams = &sFlyAroundParams[this->flightParamsIdx]; - s16 yaw; - Player* player = GET_PLAYER(globalCtx); - f32 distSqFromHome; - f32 maxDistSqFromHome; - f32 minAnimSpeed; - f32 animSpeed; - s16 rotStep; - - distSqFromHome = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, - this->actor.home.pos.z); - func_809CD56C(this); - Math_SmoothStepToF(&this->actor.speedXZ, flightParams->speedXZTarget, flightParams->speedXZScale, - flightParams->speedXZStep, 0.0f); - - if (this->unk_257 == 1) { - maxDistSqFromHome = SQ(100.0f); - rotStep = 1000; - } else { - maxDistSqFromHome = SQ(35.0f); - rotStep = 600; - } - - minAnimSpeed = 0.0f; - this->posYTarget = this->actor.home.pos.y; - - if ((this->flightParamsIdx != 0) && ((distSqFromHome > maxDistSqFromHome) || (this->timer < 4))) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw, flightParams->rotYStep) == 0) { - minAnimSpeed = 0.5f; - } - } else if ((this->unk_257 == 0) && (this->actor.child != NULL) && (this->actor.child != &this->actor)) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); - if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw, rotStep) == 0) { - minAnimSpeed = 0.3f; - } - } else if (this->unk_257 == 1) { - yaw = this->actor.yawTowardsPlayer + 0x8000 + (s16)((Rand_ZeroOne() - 0.5f) * 0x6000); - if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw, rotStep) == 0) { - minAnimSpeed = 0.4f; - } - } else { - this->actor.world.rot.y += (s16)(sinf(this->unk_25C) * 100.0f); - } - - EnButte_Turn(this); - - animSpeed = this->actor.speedXZ / 2.0f + Rand_ZeroOne() * 0.2f + (1.0f - Math_SinS(this->unk_260)) * 0.15f + - (1.0f - Math_SinS(this->unk_25E)) * 0.3f + minAnimSpeed; - this->skelAnime.playSpeed = CLAMP(animSpeed, 0.2f, 1.5f); - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - EnButte_SelectFlightParams(this, &sFlyAroundParams[this->flightParamsIdx]); - } - - if (((this->actor.params & 1) == 1) && (player->heldItemActionParam == PLAYER_AP_STICK) && - (this->swordDownTimer <= 0) && - ((Math3D_Dist2DSq(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x, - this->actor.home.pos.z) < SQ(120.0f)) || - (this->actor.xzDistToPlayer < 60.0f))) { - EnButte_SetupFollowLink(this); - this->unk_257 = 2; - } else if (this->actor.xzDistToPlayer < 120.0) { - this->unk_257 = 1; - } else { - this->unk_257 = 0; - } -} - -void EnButte_SetupFollowLink(EnButte* this) { - EnButte_SelectFlightParams(this, &sFollowLinkParams[this->flightParamsIdx]); - this->actionFunc = EnButte_FollowLink; -} - -void EnButte_FollowLink(EnButte* this, GlobalContext* globalCtx) { - static s32 D_809CE410 = 1500; - EnButteFlightParams* flightParams = &sFollowLinkParams[this->flightParamsIdx]; - Player* player = GET_PLAYER(globalCtx); - f32 distSqFromHome; - Vec3f swordTip; - f32 animSpeed; - f32 minAnimSpeed; - f32 distSqFromSword; - s16 yaw; - - func_809CD634(this); - Math_SmoothStepToF(&this->actor.speedXZ, flightParams->speedXZTarget, flightParams->speedXZScale, - flightParams->speedXZStep, 0.0f); - minAnimSpeed = 0.0f; - - if ((this->flightParamsIdx != 0) && (this->timer < 12)) { - swordTip.x = player->swordInfo[0].tip.x + Math_SinS(player->actor.shape.rot.y) * 10.0f; - swordTip.y = player->swordInfo[0].tip.y; - swordTip.z = player->swordInfo[0].tip.z + Math_CosS(player->actor.shape.rot.y) * 10.0f; - - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &swordTip) + (s16)(Rand_ZeroOne() * D_809CE410); - if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000) != 0) { - if (globalCtx->gameplayFrames % 2) { - this->actor.world.rot.y += (s16)(sinf(this->unk_25C) * 60.0f); - } - } else { - minAnimSpeed = 0.3f; - } - } - - this->posYTarget = MAX(player->actor.world.pos.y + 30.0f, player->swordInfo[0].tip.y); - - EnButte_Turn(this); - - animSpeed = this->actor.speedXZ / 2.0f + Rand_ZeroOne() * 0.2f + (1.0f - Math_SinS(this->unk_260)) * 0.15f + - (1.0f - Math_SinS(this->unk_25E)) * 0.3f + minAnimSpeed; - this->skelAnime.playSpeed = CLAMP(animSpeed, 0.2f, 1.5f); - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - EnButte_SelectFlightParams(this, &sFollowLinkParams[this->flightParamsIdx]); - D_809CE410 = -D_809CE410; - } - - distSqFromHome = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, - this->actor.home.pos.z); - if (!((player->heldItemActionParam == PLAYER_AP_STICK) && (fabsf(player->actor.speedXZ) < 1.8f) && - (this->swordDownTimer <= 0) && (distSqFromHome < SQ(320.0f)))) { - EnButte_SetupFlyAround(this); - } else if (distSqFromHome > SQ(240.0f)) { - distSqFromSword = Math3D_Dist2DSq(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, - this->actor.world.pos.x, this->actor.world.pos.z); - if (distSqFromSword < SQ(60.0f)) { - EnButte_SetupTransformIntoFairy(this); - } - } -} - -void EnButte_SetupTransformIntoFairy(EnButte* this) { - this->timer = 9; - this->actor.flags |= ACTOR_FLAG_4; - this->skelAnime.playSpeed = 1.0f; - EnButte_ResetTransformationEffect(); - this->actionFunc = EnButte_TransformIntoFairy; -} - -void EnButte_TransformIntoFairy(EnButte* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - EnButte_UpdateTransformationEffect(); - - if (this->timer == 5) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 60, NA_SE_EV_BUTTERFRY_TO_FAIRY); - } else if (this->timer == 4) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.focus.pos.x, this->actor.focus.pos.y, - this->actor.focus.pos.z, 0, this->actor.shape.rot.y, 0, FAIRY_HEAL_TIMED); - this->drawSkelAnime = false; - } else if (this->timer <= 0) { - EnButte_SetupWaitToDie(this); - } -} - -void EnButte_SetupWaitToDie(EnButte* this) { - this->timer = 64; - this->actionFunc = EnButte_WaitToDie; - this->actor.draw = NULL; -} - -void EnButte_WaitToDie(EnButte* this, GlobalContext* globalCtx) { - if (this->timer <= 0) { - Actor_Kill(&this->actor); - } -} - -void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { - EnButte* this = (EnButte*)thisx; - - if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (this->actor.child != &this->actor)) { - this->actor.child = NULL; - } - - if (this->timer > 0) { - this->timer--; - } - - this->unk_25C += 0x222; - this->unk_25E += 0x1000; - this->unk_260 += 0x600; - - if ((this->actor.params & 1) == 1) { - if (GET_PLAYER(globalCtx)->swordState == 0) { - if (this->swordDownTimer > 0) { - this->swordDownTimer--; - } - } else { - this->swordDownTimer = 80; - } - } - - this->actionFunc(this, globalCtx); - - if (this->actor.update != NULL) { - Actor_MoveForward(&this->actor); - Math_StepToF(&this->actor.world.pos.y, this->posYTarget, 0.6f); - if (this->actor.xyzDistToPlayerSq < 5000.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - Actor_SetFocus(&this->actor, this->actor.shape.yOffset * this->actor.scale.y); - } -} - -void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnButte* this = (EnButte*)thisx; - - if (this->drawSkelAnime) { - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - Collider_UpdateSpheres(0, &this->collider); - } - - if (((this->actor.params & 1) == 1) && (this->actionFunc == EnButte_TransformIntoFairy)) { - EnButte_DrawTransformationEffect(this, globalCtx); - } -} diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.cpp b/src/overlays/actors/ovl_En_Butte/z_en_butte.cpp new file mode 100644 index 000000000..b41f43770 --- /dev/null +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.cpp @@ -0,0 +1,447 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BUTTE_Z_EN_BUTTE_C +#include "actor_common.h" +/* + * File: z_en_butte.c + * Overlay: ovl_En_Butte + * Description: Butterfly + */ + +#include "z_en_butte.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void EnButte_Init(Actor* thisx, GlobalContext* globalCtx); +void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnButte_Update(Actor* thisx, GlobalContext* globalCtx); +void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnButte_SetupFlyAround(EnButte* pthis); +void EnButte_FlyAround(EnButte* pthis, GlobalContext* globalCtx); +void EnButte_SetupFollowLink(EnButte* pthis); +void EnButte_FollowLink(EnButte* pthis, GlobalContext* globalCtx); +void EnButte_SetupTransformIntoFairy(EnButte* pthis); +void EnButte_TransformIntoFairy(EnButte* pthis, GlobalContext* globalCtx); +void EnButte_SetupWaitToDie(EnButte* pthis); +void EnButte_WaitToDie(EnButte* pthis, GlobalContext* globalCtx); + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x000, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 5 }, 100 } }, +}; +static ColliderJntSphInit sColliderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +ActorInit En_Butte_InitVars = { + ACTOR_EN_BUTTE, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_FIELD_KEEP, + sizeof(EnButte), + (ActorFunc)EnButte_Init, + (ActorFunc)EnButte_Destroy, + (ActorFunc)EnButte_Update, + (ActorFunc)EnButte_Draw, +}; + +typedef struct { + /* 0x00 */ s16 minTime; + /* 0x02 */ s16 maxTime; + /* 0x04 */ f32 speedXZTarget; + /* 0x08 */ f32 speedXZScale; + /* 0x0C */ f32 speedXZStep; + /* 0x10 */ s16 rotYStep; +} EnButteFlightParams; // size = 0x14 + +static EnButteFlightParams sFlyAroundParams[] = { + { 5, 35, 0.0f, 0.1f, 0.5f, 0 }, + { 10, 45, 1.1f, 0.1f, 0.25f, 1000 }, + { 10, 40, 1.5f, 0.1f, 0.3f, 2000 }, +}; +static EnButteFlightParams sFollowLinkParams[] = { + { 3, 3, 0.8f, 0.1f, 0.2f, 0 }, + { 10, 20, 2.0f, 0.3f, 1.0f, 0 }, + { 10, 20, 2.4f, 0.3f, 1.0f, 0 }, +}; + +void EnButte_SelectFlightParams(EnButte* pthis, EnButteFlightParams* flightParams) { + if (pthis->flightParamsIdx == 0) { + if (Rand_ZeroOne() < 0.6f) { + pthis->flightParamsIdx = 1; + } else { + pthis->flightParamsIdx = 2; + } + } else { + pthis->flightParamsIdx = 0; + } + + pthis->timer = Rand_S16Offset(flightParams->minTime, flightParams->maxTime); +} + +static f32 sTransformationEffectScale = 0.0f; +static s16 sTransformationEffectAlpha = 0; + +void EnButte_ResetTransformationEffect(void) { + sTransformationEffectScale = 0.0f; + sTransformationEffectAlpha = 0; +} + +void EnButte_UpdateTransformationEffect(void) { + sTransformationEffectScale += 0.003f; + sTransformationEffectAlpha += 4000; +} + +void EnButte_DrawTransformationEffect(EnButte* pthis, GlobalContext* globalCtx) { + static Vec3f D_809CE3C4 = { 0.0f, 0.0f, -3.0f }; + Vec3f sp5C; + s32 alpha; + Vec3s camDir; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_choo.c", 295); + + func_80093C14(globalCtx->state.gfxCtx); + + alpha = Math_SinS(sTransformationEffectAlpha) * 250; + alpha = CLAMP(alpha, 0, 255); + + Camera_GetCamDir(&camDir, GET_ACTIVE_CAM(globalCtx)); + Matrix_RotateY(camDir.y * (M_PI / 0x8000), MTXMODE_NEW); + Matrix_RotateX(camDir.x * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(camDir.z * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&D_809CE3C4, &sp5C); + func_800D1694(pthis->actor.focus.pos.x + sp5C.x, pthis->actor.focus.pos.y + sp5C.y, pthis->actor.focus.pos.z + sp5C.z, + &camDir); + Matrix_Scale(sTransformationEffectScale, sTransformationEffectScale, sTransformationEffectScale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_choo.c", 317), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 180, alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 210, 255); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffFlash1DL)); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_choo.c", 326); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), +}; + +void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { + EnButte* pthis = (EnButte*)thisx; + + if (pthis->actor.params == -1) { + pthis->actor.params = 0; + } + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + + if ((pthis->actor.params & 1) == 1) { + pthis->actor.uncullZoneScale = 200.0f; + } + + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gButterflySkel, &gButterflyAnim, pthis->jointTable, pthis->morphTable, + 8); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sColliderInit, pthis->colliderItems); + pthis->actor.colChkInfo.mass = 0; + pthis->unk_25C = Rand_ZeroOne() * 0xFFFF; + pthis->unk_25E = Rand_ZeroOne() * 0xFFFF; + pthis->unk_260 = Rand_ZeroOne() * 0xFFFF; + Animation_Change(&pthis->skelAnime, &gButterflyAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); + EnButte_SetupFlyAround(pthis); + pthis->actor.shape.rot.x -= 0x2320; + pthis->drawSkelAnime = true; + // "field keep butterfly" + osSyncPrintf("(field keep 蝶)(%x)(arg_data 0x%04x)\n", pthis, pthis->actor.params); +} + +void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnButte* pthis = (EnButte*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void func_809CD56C(EnButte* pthis) { + static f32 D_809CE3E0[] = { 50.0f, 80.0f, 100.0f }; + static f32 D_809CE3EC[] = { 30.0f, 40.0f, 50.0f }; + + pthis->actor.shape.yOffset += Math_SinS(pthis->unk_25C) * D_809CE3E0[pthis->flightParamsIdx] + + Math_SinS(pthis->unk_25E) * D_809CE3EC[pthis->flightParamsIdx]; + pthis->actor.shape.yOffset = CLAMP(pthis->actor.shape.yOffset, -2000.0f, 2000.0f); +} + +void func_809CD634(EnButte* pthis) { + static f32 D_809CE3F8[] = { 15.0f, 20.0f, 25.0f }; + static f32 D_809CE404[] = { 7.5f, 10.0f, 12.5f }; + + pthis->actor.shape.yOffset += Math_SinS(pthis->unk_25C) * D_809CE3F8[pthis->flightParamsIdx] + + Math_SinS(pthis->unk_25E) * D_809CE404[pthis->flightParamsIdx]; + pthis->actor.shape.yOffset = CLAMP(pthis->actor.shape.yOffset, -500.0f, 500.0f); +} + +void EnButte_Turn(EnButte* pthis) { + s16 target = pthis->actor.world.rot.y + 0x8000; + s16 diff = target - pthis->actor.shape.rot.y; + + Math_ScaledStepToS(&pthis->actor.shape.rot.y, target, ABS(diff) >> 3); + pthis->actor.shape.rot.x = (s16)(sinf(pthis->unk_260) * 600.0f) - 0x2320; +} + +void EnButte_SetupFlyAround(EnButte* pthis) { + EnButte_SelectFlightParams(pthis, &sFlyAroundParams[pthis->flightParamsIdx]); + pthis->actionFunc = EnButte_FlyAround; +} + +void EnButte_FlyAround(EnButte* pthis, GlobalContext* globalCtx) { + EnButteFlightParams* flightParams = &sFlyAroundParams[pthis->flightParamsIdx]; + s16 yaw; + Player* player = GET_PLAYER(globalCtx); + f32 distSqFromHome; + f32 maxDistSqFromHome; + f32 minAnimSpeed; + f32 animSpeed; + s16 rotStep; + + distSqFromHome = Math3D_Dist2DSq(pthis->actor.world.pos.x, pthis->actor.world.pos.z, pthis->actor.home.pos.x, + pthis->actor.home.pos.z); + func_809CD56C(pthis); + Math_SmoothStepToF(&pthis->actor.speedXZ, flightParams->speedXZTarget, flightParams->speedXZScale, + flightParams->speedXZStep, 0.0f); + + if (pthis->unk_257 == 1) { + maxDistSqFromHome = SQ(100.0f); + rotStep = 1000; + } else { + maxDistSqFromHome = SQ(35.0f); + rotStep = 600; + } + + minAnimSpeed = 0.0f; + pthis->posYTarget = pthis->actor.home.pos.y; + + if ((pthis->flightParamsIdx != 0) && ((distSqFromHome > maxDistSqFromHome) || (pthis->timer < 4))) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, flightParams->rotYStep) == 0) { + minAnimSpeed = 0.5f; + } + } else if ((pthis->unk_257 == 0) && (pthis->actor.child != NULL) && (pthis->actor.child != &pthis->actor)) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.child->world.pos); + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, rotStep) == 0) { + minAnimSpeed = 0.3f; + } + } else if (pthis->unk_257 == 1) { + yaw = pthis->actor.yawTowardsPlayer + 0x8000 + (s16)((Rand_ZeroOne() - 0.5f) * 0x6000); + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, rotStep) == 0) { + minAnimSpeed = 0.4f; + } + } else { + pthis->actor.world.rot.y += (s16)(sinf(pthis->unk_25C) * 100.0f); + } + + EnButte_Turn(pthis); + + animSpeed = pthis->actor.speedXZ / 2.0f + Rand_ZeroOne() * 0.2f + (1.0f - Math_SinS(pthis->unk_260)) * 0.15f + + (1.0f - Math_SinS(pthis->unk_25E)) * 0.3f + minAnimSpeed; + pthis->skelAnime.playSpeed = CLAMP(animSpeed, 0.2f, 1.5f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + EnButte_SelectFlightParams(pthis, &sFlyAroundParams[pthis->flightParamsIdx]); + } + + if (((pthis->actor.params & 1) == 1) && (player->heldItemActionParam == PLAYER_AP_STICK) && + (pthis->swordDownTimer <= 0) && + ((Math3D_Dist2DSq(player->actor.world.pos.x, player->actor.world.pos.z, pthis->actor.home.pos.x, + pthis->actor.home.pos.z) < SQ(120.0f)) || + (pthis->actor.xzDistToPlayer < 60.0f))) { + EnButte_SetupFollowLink(pthis); + pthis->unk_257 = 2; + } else if (pthis->actor.xzDistToPlayer < 120.0) { + pthis->unk_257 = 1; + } else { + pthis->unk_257 = 0; + } +} + +void EnButte_SetupFollowLink(EnButte* pthis) { + EnButte_SelectFlightParams(pthis, &sFollowLinkParams[pthis->flightParamsIdx]); + pthis->actionFunc = EnButte_FollowLink; +} + +void EnButte_FollowLink(EnButte* pthis, GlobalContext* globalCtx) { + static s32 D_809CE410 = 1500; + EnButteFlightParams* flightParams = &sFollowLinkParams[pthis->flightParamsIdx]; + Player* player = GET_PLAYER(globalCtx); + f32 distSqFromHome; + Vec3f swordTip; + f32 animSpeed; + f32 minAnimSpeed; + f32 distSqFromSword; + s16 yaw; + + func_809CD634(pthis); + Math_SmoothStepToF(&pthis->actor.speedXZ, flightParams->speedXZTarget, flightParams->speedXZScale, + flightParams->speedXZStep, 0.0f); + minAnimSpeed = 0.0f; + + if ((pthis->flightParamsIdx != 0) && (pthis->timer < 12)) { + swordTip.x = player->swordInfo[0].tip.x + Math_SinS(player->actor.shape.rot.y) * 10.0f; + swordTip.y = player->swordInfo[0].tip.y; + swordTip.z = player->swordInfo[0].tip.z + Math_CosS(player->actor.shape.rot.y) * 10.0f; + + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &swordTip) + (s16)(Rand_ZeroOne() * D_809CE410); + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, 2000) != 0) { + if (globalCtx->gameplayFrames % 2) { + pthis->actor.world.rot.y += (s16)(sinf(pthis->unk_25C) * 60.0f); + } + } else { + minAnimSpeed = 0.3f; + } + } + + pthis->posYTarget = MAX(player->actor.world.pos.y + 30.0f, player->swordInfo[0].tip.y); + + EnButte_Turn(pthis); + + animSpeed = pthis->actor.speedXZ / 2.0f + Rand_ZeroOne() * 0.2f + (1.0f - Math_SinS(pthis->unk_260)) * 0.15f + + (1.0f - Math_SinS(pthis->unk_25E)) * 0.3f + minAnimSpeed; + pthis->skelAnime.playSpeed = CLAMP(animSpeed, 0.2f, 1.5f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + EnButte_SelectFlightParams(pthis, &sFollowLinkParams[pthis->flightParamsIdx]); + D_809CE410 = -D_809CE410; + } + + distSqFromHome = Math3D_Dist2DSq(pthis->actor.world.pos.x, pthis->actor.world.pos.z, pthis->actor.home.pos.x, + pthis->actor.home.pos.z); + if (!((player->heldItemActionParam == PLAYER_AP_STICK) && (fabsf(player->actor.speedXZ) < 1.8f) && + (pthis->swordDownTimer <= 0) && (distSqFromHome < SQ(320.0f)))) { + EnButte_SetupFlyAround(pthis); + } else if (distSqFromHome > SQ(240.0f)) { + distSqFromSword = Math3D_Dist2DSq(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + pthis->actor.world.pos.x, pthis->actor.world.pos.z); + if (distSqFromSword < SQ(60.0f)) { + EnButte_SetupTransformIntoFairy(pthis); + } + } +} + +void EnButte_SetupTransformIntoFairy(EnButte* pthis) { + pthis->timer = 9; + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->skelAnime.playSpeed = 1.0f; + EnButte_ResetTransformationEffect(); + pthis->actionFunc = EnButte_TransformIntoFairy; +} + +void EnButte_TransformIntoFairy(EnButte* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + EnButte_UpdateTransformationEffect(); + + if (pthis->timer == 5) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 60, NA_SE_EV_BUTTERFRY_TO_FAIRY); + } else if (pthis->timer == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pthis->actor.focus.pos.x, pthis->actor.focus.pos.y, + pthis->actor.focus.pos.z, 0, pthis->actor.shape.rot.y, 0, FAIRY_HEAL_TIMED); + pthis->drawSkelAnime = false; + } else if (pthis->timer <= 0) { + EnButte_SetupWaitToDie(pthis); + } +} + +void EnButte_SetupWaitToDie(EnButte* pthis) { + pthis->timer = 64; + pthis->actionFunc = EnButte_WaitToDie; + pthis->actor.draw = NULL; +} + +void EnButte_WaitToDie(EnButte* pthis, GlobalContext* globalCtx) { + if (pthis->timer <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { + EnButte* pthis = (EnButte*)thisx; + + if ((pthis->actor.child != NULL) && (pthis->actor.child->update == NULL) && (pthis->actor.child != &pthis->actor)) { + pthis->actor.child = NULL; + } + + if (pthis->timer > 0) { + pthis->timer--; + } + + pthis->unk_25C += 0x222; + pthis->unk_25E += 0x1000; + pthis->unk_260 += 0x600; + + if ((pthis->actor.params & 1) == 1) { + if (GET_PLAYER(globalCtx)->swordState == 0) { + if (pthis->swordDownTimer > 0) { + pthis->swordDownTimer--; + } + } else { + pthis->swordDownTimer = 80; + } + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.update != NULL) { + Actor_MoveForward(&pthis->actor); + Math_StepToF(&pthis->actor.world.pos.y, pthis->posYTarget, 0.6f); + if (pthis->actor.xyzDistToPlayerSq < 5000.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + Actor_SetFocus(&pthis->actor, pthis->actor.shape.yOffset * pthis->actor.scale.y); + } +} + +void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnButte* pthis = (EnButte*)thisx; + + if (pthis->drawSkelAnime) { + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, NULL); + Collider_UpdateSpheres(0, &pthis->collider); + } + + if (((pthis->actor.params & 1) == 1) && (pthis->actionFunc == EnButte_TransformIntoFairy)) { + EnButte_DrawTransformationEffect(pthis, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/src/overlays/actors/ovl_En_Bw/z_en_bw.c deleted file mode 100644 index 5af72595d..000000000 --- a/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ /dev/null @@ -1,918 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BW_Z_EN_BW_C -#include "actor_common.h" -/* - * File: z_en_bw.c - * Overlay: ovl_En_Bw - * Description: Torch slug - */ - -#include "z_en_bw.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_bw/object_bw.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnBw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBw_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809CE884(EnBw* this, GlobalContext* globalCtx); -void func_809CE9A8(EnBw* this); -void func_809CEA24(EnBw* this, GlobalContext* globalCtx); -void func_809CF72C(EnBw* this); -void func_809CF7AC(EnBw* this, GlobalContext* globalCtx); -void func_809CF8F0(EnBw* this); -void func_809CF984(EnBw* this, GlobalContext* globalCtx); -void func_809CFBA8(EnBw* this); -void func_809CFC4C(EnBw* this, GlobalContext* globalCtx); -void func_809CFF10(EnBw* this); -void func_809CFF98(EnBw* this, GlobalContext* globalCtx); -void func_809D00F4(EnBw* this); -void func_809D014C(EnBw* this, GlobalContext* globalCtx); -void func_809D01CC(EnBw* this); -void func_809D0268(EnBw* this, GlobalContext* globalCtx); -void func_809D03CC(EnBw* this); -void func_809D0424(EnBw* this, GlobalContext* globalCtx); - -const ActorInit En_Bw_InitVars = { - ACTOR_EN_BW, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_BW, - sizeof(EnBw), - (ActorFunc)EnBw_Init, - (ActorFunc)EnBw_Destroy, - (ActorFunc)EnBw_Update, - (ActorFunc)EnBw_Draw, -}; - -static ColliderCylinderInit sCylinderInit1 = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { 30, 65, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInit2 = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 35, 0, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(2, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0xF), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(0, 0x0), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0xF), - /* Ice arrow */ DMG_ENTRY(4, 0xE), - /* Light arrow */ DMG_ENTRY(2, 0xF), - /* Unk arrow 1 */ DMG_ENTRY(2, 0xF), - /* Unk arrow 2 */ DMG_ENTRY(2, 0xF), - /* Unk arrow 3 */ DMG_ENTRY(2, 0xF), - /* Fire magic */ DMG_ENTRY(0, 0x6), - /* Ice magic */ DMG_ENTRY(3, 0xE), - /* Light magic */ DMG_ENTRY(0, 0x6), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0xF), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(2, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xF), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static s32 sSlugGroup = 0; - -void EnBw_SetupAction(EnBw* this, EnBwActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnBw_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBw* this = (EnBw*)thisx; - - Actor_SetScale(&this->actor, 0.012999999f); - this->actor.naviEnemyId = 0x23; - this->actor.gravity = -2.0f; - SkelAnime_Init(globalCtx, &this->skelAnime, &object_bw_Skel_0020F0, &object_bw_Anim_000228, this->jointTable, - this->morphTable, 12); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.health = 6; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.focus.pos = this->actor.world.pos; - func_809CE9A8(this); - this->color1.a = this->color1.r = 255; - this->color1.g = this->color1.b = 0; - this->unk_248 = 0.6f; - this->unk_221 = 3; - Collider_InitCylinder(globalCtx, &this->collider1); - //! this->collider2 should have Init called on it, but it doesn't matter since the heap is zeroed before use. - Collider_SetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_SetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); - this->unk_236 = this->actor.world.rot.y; - this->actor.params = sSlugGroup; - sSlugGroup = (sSlugGroup + 1) & 3; -} - -void EnBw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnBw* this = (EnBw*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); -} - -void func_809CE884(EnBw* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - this->unk_222 -= 250; - this->actor.scale.x = 0.013f + Math_SinF(this->unk_222 * 0.001f) * 0.0069999998f; - this->actor.scale.y = 0.013f - Math_SinF(this->unk_222 * 0.001f) * 0.0069999998f; - this->actor.scale.z = 0.013f + Math_SinF(this->unk_222 * 0.001f) * 0.0069999998f; - if (this->unk_222 == 0) { - this->actor.world.rot.y = this->actor.shape.rot.y; - func_809CE9A8(this); - } -} - -void func_809CE9A8(EnBw* this) { - Animation_MorphToLoop(&this->skelAnime, &object_bw_Anim_000228, -2.0f); - this->unk_220 = 2; - this->unk_222 = Rand_ZeroOne() * 200.0f + 200.0f; - this->unk_232 = 0; - this->actor.speedXZ = 0.0f; - EnBw_SetupAction(this, func_809CEA24); -} - -void func_809CEA24(EnBw* this, GlobalContext* globalCtx) { - CollisionPoly* sp74 = NULL; - Vec3f sp68; - u32 sp64 = 0; - s16 sp62; - s16 sp60; - f32 sp5C; - f32 sp58; - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - this->unk_244 = this->unk_250 + 0.1f; - sp58 = Math_CosF(this->unk_240); - this->unk_240 += this->unk_244; - if (this->unk_24C < 0.8f) { - this->unk_24C += 0.1f; - } - this->actor.scale.x = 0.013f - Math_SinF(this->unk_240) * (this->unk_24C * 0.004f); - this->actor.scale.y = 0.013f - Math_SinF(this->unk_240) * (this->unk_24C * 0.004f); - this->actor.scale.z = 0.013f + Math_SinF(this->unk_240) * (this->unk_24C * 0.004f); - sp5C = Math_CosF(this->unk_240); - if (this->unk_232 == 0) { - if (ABS(sp58) < ABS(sp5C)) { - this->unk_232++; - } - } else { - if (ABS(sp58) > ABS(sp5C)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEWALK_WALK); - this->unk_232 = 0; - } - } - sp5C *= this->unk_24C * (10.0f * this->unk_244); - this->actor.speedXZ = ABS(sp5C); - if (this->unk_221 != 1) { - sp58 = Math_SinF(this->unk_240); - sp60 = ABS(sp58) * 85.0f; - this->color1.g = sp60; - } - if ((((globalCtx->gameplayFrames % 4) == (u32)this->actor.params) && (this->actor.speedXZ != 0.0f) && - (sp64 = BgCheck_AnyLineTest2(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_264, &sp68, &sp74, 1, 0, 0, - 1))) || - (this->unk_222 == 0)) { - if (sp74 != NULL) { - sp74 = SEGMENTED_TO_VIRTUAL(sp74); - sp62 = Math_FAtan2F(sp74->normal.x, sp74->normal.z) * ((f32)0x8000 / M_PI); - } else { - sp62 = this->actor.world.rot.y + 0x8000; - } - if ((this->unk_236 != sp62) || (sp64 == 0)) { - if (BgCheck_AnyLineTest2(&globalCtx->colCtx, &this->unk_270, &this->unk_288, &sp68, &sp74, 1, 0, 0, 1)) { - sp64 |= 2; - } - if (BgCheck_AnyLineTest2(&globalCtx->colCtx, &this->unk_270, &this->unk_27C, &sp68, &sp74, 1, 0, 0, 1)) { - sp64 |= 4; - } - switch (sp64) { - case 0: - this->unk_236 += this->unk_238; - case 1: - if (this->unk_221 == 3) { - if (globalCtx->gameplayFrames & 2) { - this->unk_238 = 0x4000; - } else { - this->unk_238 = -0x4000; - } - } else { - if ((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) >= 0.0f) { - this->unk_238 = 0x4000; - } else { - this->unk_238 = -0x4000; - } - if (this->unk_221 == 1) { - this->unk_238 = -this->unk_238; - } - } - break; - case 2: - this->unk_236 += this->unk_238; - case 3: - this->unk_238 = 0x4000; - break; - case 4: - this->unk_236 += this->unk_238; - case 5: - this->unk_238 = -0x4000; - break; - case 7: - this->unk_238 = 0; - break; - } - if (sp64 != 6) { - this->unk_236 = sp62; - } - this->unk_222 = (Rand_ZeroOne() * 200.0f) + 200.0f; - } - } else if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { - if (this->unk_236 != this->actor.wallYaw) { - sp64 = 1; - this->unk_236 = this->actor.wallYaw; - if (this->unk_221 == 3) { - if (globalCtx->gameplayFrames & 0x20) { - this->unk_238 = 0x4000; - } else { - this->unk_238 = -0x4000; - } - this->actor.bgCheckFlags &= ~8; - this->unk_222 = (Rand_ZeroOne() * 20.0f) + 160.0f; - } else { - if ((s16)(this->actor.yawTowardsPlayer - this->unk_236) >= 0) { - this->unk_238 = 0x4000; - } else { - this->unk_238 = -0x4000; - } - if (this->unk_221 == 1) { - this->unk_238 = -this->unk_238; - } - } - } else if (this->unk_221 == 0) { - sp64 = BgCheck_AnyLineTest2(&globalCtx->colCtx, &this->actor.world.pos, &player->actor.world.pos, &sp68, - &sp74, 1, 0, 0, 1); - if (sp64 != 0) { - sp74 = SEGMENTED_TO_VIRTUAL(sp74); - sp60 = Math_FAtan2F(sp74->normal.x, sp74->normal.z) * ((f32)0x8000 / M_PI); - if (this->unk_236 != sp60) { - if ((s16)(this->actor.yawTowardsPlayer - sp60) >= 0) { - this->unk_238 = 0x4000; - } else { - this->unk_238 = -0x4000; - } - this->unk_236 = sp60; - } - } - } - } - this->unk_222--; - if (this->unk_224 != 0) { - this->unk_224--; - } - if ((this->unk_234 == 0) && - !Actor_TestFloorInDirection(&this->actor, globalCtx, 50.0f, this->unk_236 + this->unk_238)) { - if (this->unk_238 != 0x4000) { - this->unk_238 = 0x4000; - } else { - this->unk_238 = -0x4000; - } - } - switch (this->unk_221) { - case 3: - Math_SmoothStepToF(&this->unk_248, 0.6f, 1.0f, 0.05f, 0.0f); - if ((this->unk_224 == 0) && (this->actor.xzDistToPlayer < 200.0f) && - (ABS(this->actor.yDistToPlayer) < 50.0f) && Actor_IsFacingPlayer(&this->actor, 0x1C70)) { - func_809CF72C(this); - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_236 + this->unk_238, 1, - this->actor.speedXZ * 1000.0f, 0); - } - break; - case 0: - Math_SmoothStepToF(&this->unk_248, 0.6f, 1.0f, 0.05f, 0.0f); - if (sp64 == 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, - this->actor.speedXZ * 1000.0f, 0); - if ((this->actor.xzDistToPlayer < 90.0f) && (this->actor.yDistToPlayer < 50.0f) && - Actor_IsFacingPlayer(&this->actor, 0x1554) && - Actor_TestFloorInDirection(&this->actor, globalCtx, 71.24802f, this->actor.yawTowardsPlayer)) { - func_809CF8F0(this); - } - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_236 + this->unk_238, 1, - this->actor.speedXZ * 1000.0f, 0); - } - if ((this->unk_224 == 0) || (ABS(this->actor.yDistToPlayer) > 60.0f) || (player2->stateFlags1 & 0x6000)) { - this->unk_221 = 3; - this->unk_224 = 150; - this->unk_250 = 0.0f; - } - break; - case 1: - if (((sp64 == 0) && !(this->actor.bgCheckFlags & 8)) || Actor_IsFacingPlayer(&this->actor, 0x1C70)) { - if (Actor_IsFacingPlayer(&this->actor, 0x1C70)) { - this->unk_238 = -this->unk_238; - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x8000, 1, - this->actor.speedXZ * 1000.0f, 0); - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_236 + this->unk_238, 1, - this->actor.speedXZ * 1000.0f, 0); - } - if (this->unk_224 <= 200) { - sp60 = Math_SinS(this->unk_224 * (0x960 - this->unk_224)) * 55.0f; - this->color1.r = 255 - ABS(sp60); - sp60 = Math_SinS(this->unk_224 * (0x960 - this->unk_224)) * 115.0f; - this->color1.g = ABS(sp60) + 85; - sp60 = Math_SinS(0x960 - this->unk_224) * 255.0f; - this->color1.b = ABS(sp60); - if (this->unk_224 == 0) { - this->unk_221 = 3; - this->unk_250 = 0.0f; - } - } - break; - } - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void func_809CF72C(EnBw* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_bw_Anim_0021A0, -2.0f); - this->unk_220 = 3; - this->unk_221 = 0; - this->unk_250 = 0.6f; - this->unk_222 = 20; - this->unk_224 = 0xBB8; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEWALK_AIM); - EnBw_SetupAction(this, func_809CF7AC); -} - -void func_809CF7AC(EnBw* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_222 > 0) { - this->unk_222--; - } else { - this->unk_222 = 100; - } - } - if (this->unk_222 >= 20) { - this->unk_224 -= 250; - } - this->actor.scale.x = 0.013f - Math_SinF(this->unk_224 * 0.001f) * 0.0034999999f; - this->actor.scale.y = 0.013f + Math_SinF(this->unk_224 * 0.001f) * 0.0245f; - this->actor.scale.z = 0.013f - Math_SinF(this->unk_224 * 0.001f) * 0.0034999999f; - if (this->unk_224 == 0) { - func_809CE9A8(this); - this->unk_224 = 200; - } -} - -void func_809CF8F0(EnBw* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_bw_Anim_002250, -1.0f); - this->actor.speedXZ = 7.0f; - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->unk_220 = 4; - this->unk_222 = 1000; - this->actor.velocity.y = 11.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actor.flags |= ACTOR_FLAG_24; - EnBw_SetupAction(this, func_809CF984); -} - -void func_809CF984(EnBw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 floorPolyType; - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - this->unk_222 += 250; - this->actor.scale.x = 0.013f - Math_SinF(this->unk_222 * 0.001f) * 0.0034999999f; - this->actor.scale.y = 0.013f + Math_SinF(this->unk_222 * 0.001f) * 0.0245f; - this->actor.scale.z = 0.013f - Math_SinF(this->unk_222 * 0.001f) * 0.0034999999f; - if (this->collider1.base.atFlags & AT_HIT) { - this->collider1.base.atFlags &= ~AT_HIT; - this->actor.speedXZ = -6.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if ((&player->actor == this->collider1.base.at) && !(this->collider1.base.atFlags & AT_BOUNCED)) { - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - } - SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 3) { - floorPolyType = func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorPolyType == 2) || (floorPolyType == 3) || (floorPolyType == 9)) { - Actor_Kill(&this->actor); - return; - } - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); - this->unk_222 = 3000; - this->actor.flags &= ~ACTOR_FLAG_24; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - EnBw_SetupAction(this, func_809CE884); - } -} - -void func_809CFBA8(EnBw* this) { - Animation_MorphToLoop(&this->skelAnime, &object_bw_Anim_002250, -1.0f); - this->unk_220 = 5; - this->unk_222 = 1000; - this->unk_260 = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 11.0f; - this->unk_25C = Rand_ZeroOne() * 0.25f + 1.0f; - this->unk_224 = 0xBB8; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEWALK_REVERSE); - EnBw_SetupAction(this, func_809CFC4C); -} - -void func_809CFC4C(EnBw* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.z, 0x7FFF, 1, 0xFA0, 0); - Math_SmoothStepToF(&this->unk_248, 0.0f, 1.0f, 0.05f, 0.0f); - SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 3) { - if ((globalCtx->gameplayFrames % 0x80) == 0) { - this->unk_25C = (Rand_ZeroOne() * 0.25f) + 0.7f; - } - this->unk_221 = 4; - this->unk_258 += this->unk_25C; - Math_SmoothStepToF(&this->unk_260, 0.075f, 1.0f, 0.005f, 0.0f); - if (this->actor.bgCheckFlags & 2) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - if (this->unk_224 != 0) { - this->unk_224 -= 250; - this->actor.scale.x = 0.013f + Math_SinF(this->unk_224 * 0.001f) * 0.0069999998f; - this->actor.scale.y = 0.013f - Math_SinF(this->unk_224 * 0.001f) * 0.0069999998f; - this->actor.scale.z = 0.013f + Math_SinF(this->unk_224 * 0.001f) * 0.0069999998f; - } - this->unk_222--; - if (this->unk_222 == 0) { - func_809CFF10(this); - } - } else { - this->color1.r -= 8; - this->color1.g += 32; - if (this->color1.r < 200) { - this->color1.r = 200; - } - if (this->color1.g > 200) { - this->color1.g = 200; - } - if (this->color1.b > 235) { - this->color1.b = 255; - } else { - this->color1.b += 40; - } - if (this->actor.shape.yOffset < 1000.0f) { - this->actor.shape.yOffset += 200.0f; - } - } -} - -void func_809CFF10(EnBw* this) { - Animation_MorphToLoop(&this->skelAnime, &object_bw_Anim_002250, -1.0f); - this->unk_220 = 6; - this->unk_222 = 1000; - this->unk_221 = 3; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 11.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEWALK_REVERSE); - this->actor.bgCheckFlags &= ~1; - EnBw_SetupAction(this, func_809CFF98); -} - -void func_809CFF98(EnBw* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 0xFA0, 0); - Math_SmoothStepToF(&this->unk_248, 0.6f, 1.0f, 0.05f, 0.0f); - SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 3) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); - this->unk_222 = 0xBB8; - this->unk_250 = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - EnBw_SetupAction(this, func_809CE884); - } - if (this->color1.r < 247) { - this->color1.r += 8; - } else { - this->color1.r = 255; - } - if (this->color1.g < 32) { - this->color1.g = 0; - } else { - this->color1.g -= 32; - } - if (this->color1.b < 40) { - this->color1.b = 0; - } else { - this->color1.b -= 40; - } - if (this->actor.shape.yOffset > 0.0f) { - this->actor.shape.yOffset -= 200.0f; - } -} - -void func_809D00F4(EnBw* this) { - this->unk_220 = 0; - this->unk_222 = 40; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); - EnBw_SetupAction(this, func_809D014C); -} - -void func_809D014C(EnBw* this, GlobalContext* globalCtx) { - if (this->unk_230) { - this->actor.scale.x += 0.0002f; - this->actor.scale.y -= 0.0002f; - this->actor.scale.z += 0.0002f; - } - this->actor.shape.shadowAlpha = this->color1.a -= 6; - this->unk_222--; - if (this->unk_222 <= 0) { - Actor_Kill(&this->actor); - } -} - -void func_809D01CC(EnBw* this) { - this->unk_220 = 1; - this->actor.speedXZ = 0.0f; - this->unk_25C = (Rand_ZeroOne() * 0.25f) + 1.0f; - this->unk_260 = 0.0f; - if (this->damageEffect == 0xE) { - this->iceTimer = 0x50; - } - this->unk_222 = (this->actor.colorFilterParams & 0x4000) ? 25 : 80; - EnBw_SetupAction(this, func_809D0268); -} - -void func_809D0268(EnBw* this, GlobalContext* globalCtx) { - this->color1.r -= 1; - this->color1.g += 4; - this->color1.b += 5; - if (this->color1.r < 200) { - this->color1.r = 200; - } - if (this->color1.g > 200) { - this->color1.g = 200; - } - if (this->color1.b > 230) { - this->color1.b = 230; - } - if (this->actor.colorFilterParams & 0x4000) { - if ((globalCtx->gameplayFrames % 0x80) == 0) { - this->unk_25C = 0.5f + Rand_ZeroOne() * 0.25f; - } - this->unk_258 += this->unk_25C; - Math_SmoothStepToF(&this->unk_260, 0.075f, 1.0f, 0.005f, 0.0f); - } - this->unk_222--; - if (this->unk_222 == 0) { - func_809CE9A8(this); - this->color1.r = this->color1.g = 200; - this->color1.b = 255; - this->unk_224 = 0x258; - this->unk_221 = 1; - this->unk_250 = 0.7f; - this->unk_236++; - } -} - -void func_809D03CC(EnBw* this) { - this->actor.speedXZ = 0.0f; - if (this->damageEffect == 0xE) { - this->iceTimer = 32; - } - this->unk_23C = this->actor.colorFilterTimer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - EnBw_SetupAction(this, func_809D0424); -} - -void func_809D0424(EnBw* this, GlobalContext* globalCtx) { - if (this->actor.colorFilterTimer == 0) { - this->unk_23C = 0; - if (this->actor.colChkInfo.health != 0) { - if ((this->unk_220 != 5) && (this->unk_220 != 6)) { - func_809CE9A8(this); - this->color1.r = this->color1.g = 200; - this->color1.b = 255; - this->unk_224 = 0x258; - this->unk_221 = 1; - this->unk_250 = 0.7f; - this->unk_236++; - } else if (this->unk_220 != 5) { - EnBw_SetupAction(this, func_809CFF98); - } else { - func_809CFF10(this); - } - } else { - if (func_800355E4(globalCtx, &this->collider2.base)) { - this->unk_230 = 0; - this->actor.scale.y -= 0.009f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); - } else { - this->unk_230 = 1; - } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); - func_809D00F4(this); - } - } -} - -void func_809D0584(EnBw* this, GlobalContext* globalCtx) { - if ((this->actor.bgCheckFlags & 0x10) && (this->actor.bgCheckFlags & 1)) { - this->unk_230 = 0; - this->actor.scale.y -= 0.009f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); - func_809D00F4(this); - } else { - if (this->collider2.base.acFlags & AC_HIT) { - this->collider2.base.acFlags &= ~AC_HIT; - if ((this->actor.colChkInfo.damageEffect == 0) || (this->unk_220 == 6)) { - return; - } - this->damageEffect = this->actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->actor, &this->collider2.info, 0); - if ((this->damageEffect == 1) || (this->damageEffect == 0xE)) { - if (this->unk_23C == 0) { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); - func_809D03CC(this); - this->unk_248 = 0.0f; - } - return; - } - if (this->unk_248 == 0.0f) { - Actor_ApplyDamage(&this->actor); - } - if (((this->unk_221 == 1) || (this->unk_221 == 4)) && (this->actor.colChkInfo.health == 0)) { - if (this->unk_220 != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - if (func_800355E4(globalCtx, &this->collider2.base)) { - this->unk_230 = 0; - this->actor.scale.y -= 0.009f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 30.0f, 0xB, 4.0f, 0, - 0, 0); - } else { - this->unk_230 = 1; - } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); - func_809D00F4(this); - } - } else if ((this->unk_220 != 1) && (this->unk_220 != 6)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLEWALK_DAMAGE); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - if (this->unk_220 != 5) { - func_809D01CC(this); - } - this->unk_248 = 0.0f; - } - } - if ((globalCtx->actorCtx.unk_02 != 0) && (this->actor.xzDistToPlayer <= 400.0f) && - (this->actor.bgCheckFlags & 1)) { - if (this->unk_220 == 5) { - this->unk_23C = 0; - func_809CFF10(this); - } else if (this->unk_220 != 0) { - this->unk_23C = 0; - func_809CFBA8(this); - } - } - } -} - -void EnBw_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnBw* this = (EnBw*)thisx; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - s32 pad[3]; // probably an unused Vec3f - Color_RGBA8 sp50 = { 255, 200, 0, 255 }; - Color_RGBA8 sp4C = { 255, 80, 0, 255 }; - Color_RGBA8 sp48 = { 0, 0, 0, 255 }; - Color_RGBA8 sp44 = { 0, 0, 0, 220 }; - - func_809D0584(this, globalCtx); - if (thisx->colChkInfo.damageEffect != 6) { - this->actionFunc(this, globalCtx); - if (this->unk_23C == 0) { - this->unk_23A = (this->unk_23A + 4) & 0x7F; - } - if ((globalCtx->gameplayFrames & this->unk_221) == 0) { - accel.y = -3.0f; - velocity.x = Rand_CenteredFloat(this->unk_248 * 24.0f); - velocity.y = this->unk_248 * 30.0f; - velocity.z = Rand_CenteredFloat(this->unk_248 * 24.0f); - accel.x = velocity.x * -0.075f; - accel.z = velocity.z * -0.075f; - func_8002836C(globalCtx, &thisx->world.pos, &velocity, &accel, &sp50, &sp4C, 0x3C, 0, 0x14); - } - if (this->unk_248 <= 0.4f) { - this->collider1.info.toucher.effect = 0; - if (((globalCtx->gameplayFrames & 1) == 0) && (this->unk_220 < 5) && (this->unk_23C == 0)) { - accel.y = -0.1f; - velocity.x = Rand_CenteredFloat(4.0f); - velocity.y = Rand_CenteredFloat(2.0f) + 6.0f; - velocity.z = Rand_CenteredFloat(4.0f); - accel.x = velocity.x * -0.1f; - accel.z = velocity.z * -0.1f; - Rand_CenteredFloat(4.0f); - Rand_CenteredFloat(4.0f); - sp48.a = this->color1.a; - if (sp48.a >= 30) { - sp44.a = sp48.a - 30; - } else { - sp44.a = 0; - } - func_8002836C(globalCtx, &thisx->world.pos, &velocity, &accel, &sp48, &sp44, 0xB4, 0x28, - 20.0f - (this->unk_248 * 40.0f)); - } - } else { - this->collider1.info.toucher.effect = 1; - } - - this->unk_234 = Actor_TestFloorInDirection(thisx, globalCtx, 50.0f, thisx->world.rot.y); - if ((this->unk_220 == 4) || (this->unk_220 == 6) || (this->unk_220 == 5) || (this->unk_220 == 1) || - (this->unk_234 != 0)) { - Actor_MoveForward(thisx); - } - Actor_UpdateBgCheckInfo(globalCtx, thisx, 20.0f, 30.0f, 21.0f, 0x1F); - } - Collider_UpdateCylinder(thisx, &this->collider2); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - if ((this->unk_220 != 0) && ((thisx->colorFilterTimer == 0) || !(thisx->colorFilterParams & 0x4000))) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - } - if ((this->unk_221 != 1) && (this->unk_220 < 5) && (this->unk_248 > 0.4f)) { - Collider_UpdateCylinder(thisx, &this->collider1); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - } - thisx->focus.pos = thisx->world.pos; - thisx->focus.pos.y += 5.0f; -} - -s32 EnBw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnBw* this = (EnBw*)thisx; - - if (limbIndex == 1) { - gSPSegment((*gfx)++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, 0, this->unk_23A, 0x20, 0x20)); - if ((this->unk_220 == 1) || (this->unk_220 == 5)) { - Matrix_Push(); - Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateX(this->unk_258 * 0.115f, MTXMODE_APPLY); - Matrix_RotateY(this->unk_258 * 0.13f, MTXMODE_APPLY); - Matrix_RotateZ(this->unk_258 * 0.1f, MTXMODE_APPLY); - Matrix_Scale(1.0f - this->unk_260, 1.0f + this->unk_260, 1.0f - this->unk_260, MTXMODE_APPLY); - Matrix_RotateZ(-(this->unk_258 * 0.1f), MTXMODE_APPLY); - Matrix_RotateY(-(this->unk_258 * 0.13f), MTXMODE_APPLY); - Matrix_RotateX(-(this->unk_258 * 0.115f), MTXMODE_APPLY); - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bw.c", 1388), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, *dList); - Matrix_Pop(); - return 1; - } - } - return 0; -} - -static Vec3f sIceOffsets[] = { - { 20.0f, 10.0f, 0.0f }, { -20.0f, 10.0f, 0.0f }, { 0.0f, 10.0f, -25.0f }, { 10.0f, 0.0f, 15.0f }, - { 10.0f, 0.0f, -15.0f }, { 0.0f, 10.0f, 25.0f }, { -10.0f, 0.0f, 15.0f }, { -10.0f, 0.0f, -15.0f }, -}; - -void EnBw_Draw(Actor* thisx, GlobalContext* globalCtx2) { - Vec3f spAC = { 0.0f, 0.0f, 0.0f }; - GlobalContext* globalCtx = globalCtx2; - EnBw* this = (EnBw*)thisx; - Vec3f icePos; - s32 iceIndex; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bw.c", 1423); - - if (this->color1.a == 0xFF) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, this->color1.r, this->color1.g, this->color1.b, this->color1.a); - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnBw_OverrideLimbDraw, NULL, this, POLY_OPA_DISP); - } else { - func_80093D84(globalCtx->state.gfxCtx); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 0, 0, 0, this->color1.a); - gDPSetEnvColor(POLY_XLU_DISP++, this->color1.r, this->color1.g, this->color1.b, this->color1.a); - gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnBw_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - } - - if (((globalCtx->gameplayFrames + 1) % 4) == (u32)thisx->params) { - spAC.z = thisx->scale.z * 375000.0f; - Matrix_MultVec3f(&spAC, &this->unk_264); - spAC.z = thisx->scale.z * 150000.0f; - Matrix_MultVec3f(&spAC, &this->unk_270); - spAC.x = thisx->scale.x * 550000.0f; - Matrix_MultVec3f(&spAC, &this->unk_288); - spAC.x = -spAC.x; - Matrix_MultVec3f(&spAC, &this->unk_27C); - } - - Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y + ((thisx->scale.y - 0.013f) * 1000.0f), thisx->world.pos.z, - MTXMODE_NEW); - func_80093D84(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (globalCtx->gameplayFrames * -20) % 0x200, 0x20, 0x80)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); - Matrix_Scale(this->unk_248 * 0.01f, this->unk_248 * 0.01f, this->unk_248 * 0.01f, MTXMODE_APPLY); - func_800D1FD4(&globalCtx->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bw.c", 1500), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - - if (this->iceTimer != 0) { - thisx->colorFilterTimer++; - this->iceTimer--; - if ((this->iceTimer & 3) == 0) { - iceIndex = this->iceTimer >> 2; - - icePos.x = sIceOffsets[iceIndex].x + thisx->world.pos.x; - icePos.y = sIceOffsets[iceIndex].y + thisx->world.pos.y; - icePos.z = sIceOffsets[iceIndex].z + thisx->world.pos.z; - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, thisx, &icePos, 0x96, 0x96, 0x96, 0xFA, 0xEB, 0xF5, 0xFF, 1.3f); - } - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bw.c", 1521); -} diff --git a/src/overlays/actors/ovl_En_Bw/z_en_bw.cpp b/src/overlays/actors/ovl_En_Bw/z_en_bw.cpp new file mode 100644 index 000000000..c6e79a989 --- /dev/null +++ b/src/overlays/actors/ovl_En_Bw/z_en_bw.cpp @@ -0,0 +1,918 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_BW_Z_EN_BW_C +#include "actor_common.h" +/* + * File: z_en_bw.c + * Overlay: ovl_En_Bw + * Description: Torch slug + */ + +#include "z_en_bw.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_bw/object_bw.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnBw_Init(Actor* thisx, GlobalContext* globalCtx); +void EnBw_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnBw_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBw_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809CE884(EnBw* pthis, GlobalContext* globalCtx); +void func_809CE9A8(EnBw* pthis); +void func_809CEA24(EnBw* pthis, GlobalContext* globalCtx); +void func_809CF72C(EnBw* pthis); +void func_809CF7AC(EnBw* pthis, GlobalContext* globalCtx); +void func_809CF8F0(EnBw* pthis); +void func_809CF984(EnBw* pthis, GlobalContext* globalCtx); +void func_809CFBA8(EnBw* pthis); +void func_809CFC4C(EnBw* pthis, GlobalContext* globalCtx); +void func_809CFF10(EnBw* pthis); +void func_809CFF98(EnBw* pthis, GlobalContext* globalCtx); +void func_809D00F4(EnBw* pthis); +void func_809D014C(EnBw* pthis, GlobalContext* globalCtx); +void func_809D01CC(EnBw* pthis); +void func_809D0268(EnBw* pthis, GlobalContext* globalCtx); +void func_809D03CC(EnBw* pthis); +void func_809D0424(EnBw* pthis, GlobalContext* globalCtx); + +ActorInit En_Bw_InitVars = { + ACTOR_EN_BW, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_BW, + sizeof(EnBw), + (ActorFunc)EnBw_Init, + (ActorFunc)EnBw_Destroy, + (ActorFunc)EnBw_Update, + (ActorFunc)EnBw_Draw, +}; + +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { 30, 65, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 35, 0, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0xF), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(0, 0x0), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(2, 0xF), + /* Ice arrow */ DMG_ENTRY(4, 0xE), + /* Light arrow */ DMG_ENTRY(2, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(2, 0xF), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xF), + /* Unk arrow 3 */ DMG_ENTRY(2, 0xF), + /* Fire magic */ DMG_ENTRY(0, 0x6), + /* Ice magic */ DMG_ENTRY(3, 0xE), + /* Light magic */ DMG_ENTRY(0, 0x6), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(2, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static s32 sSlugGroup = 0; + +void EnBw_SetupAction(EnBw* pthis, EnBwActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnBw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBw* pthis = (EnBw*)thisx; + + Actor_SetScale(&pthis->actor, 0.012999999f); + pthis->actor.naviEnemyId = 0x23; + pthis->actor.gravity = -2.0f; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_bw_Skel_0020F0, &object_bw_Anim_000228, pthis->jointTable, + pthis->morphTable, 12); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.colChkInfo.health = 6; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.focus.pos = pthis->actor.world.pos; + func_809CE9A8(pthis); + pthis->color1.a = pthis->color1.r = 255; + pthis->color1.g = pthis->color1.b = 0; + pthis->unk_248 = 0.6f; + pthis->unk_221 = 3; + Collider_InitCylinder(globalCtx, &pthis->collider1); + //! pthis->collider2 should have Init called on it, but it doesn't matter since the heap is zeroed before use. + Collider_SetCylinder(globalCtx, &pthis->collider1, &pthis->actor, &sCylinderInit1); + Collider_SetCylinder(globalCtx, &pthis->collider2, &pthis->actor, &sCylinderInit2); + pthis->unk_236 = pthis->actor.world.rot.y; + pthis->actor.params = sSlugGroup; + sSlugGroup = (sSlugGroup + 1) & 3; +} + +void EnBw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBw* pthis = (EnBw*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider1); + Collider_DestroyCylinder(globalCtx, &pthis->collider2); +} + +void func_809CE884(EnBw* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + pthis->unk_222 -= 250; + pthis->actor.scale.x = 0.013f + Math_SinF(pthis->unk_222 * 0.001f) * 0.0069999998f; + pthis->actor.scale.y = 0.013f - Math_SinF(pthis->unk_222 * 0.001f) * 0.0069999998f; + pthis->actor.scale.z = 0.013f + Math_SinF(pthis->unk_222 * 0.001f) * 0.0069999998f; + if (pthis->unk_222 == 0) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_809CE9A8(pthis); + } +} + +void func_809CE9A8(EnBw* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_bw_Anim_000228, -2.0f); + pthis->unk_220 = 2; + pthis->unk_222 = Rand_ZeroOne() * 200.0f + 200.0f; + pthis->unk_232 = 0; + pthis->actor.speedXZ = 0.0f; + EnBw_SetupAction(pthis, func_809CEA24); +} + +void func_809CEA24(EnBw* pthis, GlobalContext* globalCtx) { + CollisionPoly* sp74 = NULL; + Vec3f sp68; + u32 sp64 = 0; + s16 sp62; + s16 sp60; + f32 sp5C; + f32 sp58; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_244 = pthis->unk_250 + 0.1f; + sp58 = Math_CosF(pthis->unk_240); + pthis->unk_240 += pthis->unk_244; + if (pthis->unk_24C < 0.8f) { + pthis->unk_24C += 0.1f; + } + pthis->actor.scale.x = 0.013f - Math_SinF(pthis->unk_240) * (pthis->unk_24C * 0.004f); + pthis->actor.scale.y = 0.013f - Math_SinF(pthis->unk_240) * (pthis->unk_24C * 0.004f); + pthis->actor.scale.z = 0.013f + Math_SinF(pthis->unk_240) * (pthis->unk_24C * 0.004f); + sp5C = Math_CosF(pthis->unk_240); + if (pthis->unk_232 == 0) { + if (ABS(sp58) < ABS(sp5C)) { + pthis->unk_232++; + } + } else { + if (ABS(sp58) > ABS(sp5C)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEWALK_WALK); + pthis->unk_232 = 0; + } + } + sp5C *= pthis->unk_24C * (10.0f * pthis->unk_244); + pthis->actor.speedXZ = ABS(sp5C); + if (pthis->unk_221 != 1) { + sp58 = Math_SinF(pthis->unk_240); + sp60 = ABS(sp58) * 85.0f; + pthis->color1.g = sp60; + } + if ((((globalCtx->gameplayFrames % 4) == (u32)pthis->actor.params) && (pthis->actor.speedXZ != 0.0f) && + (sp64 = BgCheck_AnyLineTest2(&globalCtx->colCtx, &pthis->actor.world.pos, &pthis->unk_264, &sp68, &sp74, 1, 0, 0, + 1))) || + (pthis->unk_222 == 0)) { + if (sp74 != NULL) { + sp74 = SEGMENTED_TO_VIRTUAL(sp74); + sp62 = Math_FAtan2F(sp74->normal.x, sp74->normal.z) * ((f32)0x8000 / M_PI); + } else { + sp62 = pthis->actor.world.rot.y + 0x8000; + } + if ((pthis->unk_236 != sp62) || (sp64 == 0)) { + if (BgCheck_AnyLineTest2(&globalCtx->colCtx, &pthis->unk_270, &pthis->unk_288, &sp68, &sp74, 1, 0, 0, 1)) { + sp64 |= 2; + } + if (BgCheck_AnyLineTest2(&globalCtx->colCtx, &pthis->unk_270, &pthis->unk_27C, &sp68, &sp74, 1, 0, 0, 1)) { + sp64 |= 4; + } + switch (sp64) { + case 0: + pthis->unk_236 += pthis->unk_238; + case 1: + if (pthis->unk_221 == 3) { + if (globalCtx->gameplayFrames & 2) { + pthis->unk_238 = 0x4000; + } else { + pthis->unk_238 = -0x4000; + } + } else { + if ((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) >= 0.0f) { + pthis->unk_238 = 0x4000; + } else { + pthis->unk_238 = -0x4000; + } + if (pthis->unk_221 == 1) { + pthis->unk_238 = -pthis->unk_238; + } + } + break; + case 2: + pthis->unk_236 += pthis->unk_238; + case 3: + pthis->unk_238 = 0x4000; + break; + case 4: + pthis->unk_236 += pthis->unk_238; + case 5: + pthis->unk_238 = -0x4000; + break; + case 7: + pthis->unk_238 = 0; + break; + } + if (sp64 != 6) { + pthis->unk_236 = sp62; + } + pthis->unk_222 = (Rand_ZeroOne() * 200.0f) + 200.0f; + } + } else if ((pthis->actor.speedXZ != 0.0f) && (pthis->actor.bgCheckFlags & 8)) { + if (pthis->unk_236 != pthis->actor.wallYaw) { + sp64 = 1; + pthis->unk_236 = pthis->actor.wallYaw; + if (pthis->unk_221 == 3) { + if (globalCtx->gameplayFrames & 0x20) { + pthis->unk_238 = 0x4000; + } else { + pthis->unk_238 = -0x4000; + } + pthis->actor.bgCheckFlags &= ~8; + pthis->unk_222 = (Rand_ZeroOne() * 20.0f) + 160.0f; + } else { + if ((s16)(pthis->actor.yawTowardsPlayer - pthis->unk_236) >= 0) { + pthis->unk_238 = 0x4000; + } else { + pthis->unk_238 = -0x4000; + } + if (pthis->unk_221 == 1) { + pthis->unk_238 = -pthis->unk_238; + } + } + } else if (pthis->unk_221 == 0) { + sp64 = BgCheck_AnyLineTest2(&globalCtx->colCtx, &pthis->actor.world.pos, &player->actor.world.pos, &sp68, + &sp74, 1, 0, 0, 1); + if (sp64 != 0) { + sp74 = SEGMENTED_TO_VIRTUAL(sp74); + sp60 = Math_FAtan2F(sp74->normal.x, sp74->normal.z) * ((f32)0x8000 / M_PI); + if (pthis->unk_236 != sp60) { + if ((s16)(pthis->actor.yawTowardsPlayer - sp60) >= 0) { + pthis->unk_238 = 0x4000; + } else { + pthis->unk_238 = -0x4000; + } + pthis->unk_236 = sp60; + } + } + } + } + pthis->unk_222--; + if (pthis->unk_224 != 0) { + pthis->unk_224--; + } + if ((pthis->unk_234 == 0) && + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, 50.0f, pthis->unk_236 + pthis->unk_238)) { + if (pthis->unk_238 != 0x4000) { + pthis->unk_238 = 0x4000; + } else { + pthis->unk_238 = -0x4000; + } + } + switch (pthis->unk_221) { + case 3: + Math_SmoothStepToF(&pthis->unk_248, 0.6f, 1.0f, 0.05f, 0.0f); + if ((pthis->unk_224 == 0) && (pthis->actor.xzDistToPlayer < 200.0f) && + (ABS(pthis->actor.yDistToPlayer) < 50.0f) && Actor_IsFacingPlayer(&pthis->actor, 0x1C70)) { + func_809CF72C(pthis); + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_236 + pthis->unk_238, 1, + pthis->actor.speedXZ * 1000.0f, 0); + } + break; + case 0: + Math_SmoothStepToF(&pthis->unk_248, 0.6f, 1.0f, 0.05f, 0.0f); + if (sp64 == 0) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, + pthis->actor.speedXZ * 1000.0f, 0); + if ((pthis->actor.xzDistToPlayer < 90.0f) && (pthis->actor.yDistToPlayer < 50.0f) && + Actor_IsFacingPlayer(&pthis->actor, 0x1554) && + Actor_TestFloorInDirection(&pthis->actor, globalCtx, 71.24802f, pthis->actor.yawTowardsPlayer)) { + func_809CF8F0(pthis); + } + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_236 + pthis->unk_238, 1, + pthis->actor.speedXZ * 1000.0f, 0); + } + if ((pthis->unk_224 == 0) || (ABS(pthis->actor.yDistToPlayer) > 60.0f) || (player2->stateFlags1 & 0x6000)) { + pthis->unk_221 = 3; + pthis->unk_224 = 150; + pthis->unk_250 = 0.0f; + } + break; + case 1: + if (((sp64 == 0) && !(pthis->actor.bgCheckFlags & 8)) || Actor_IsFacingPlayer(&pthis->actor, 0x1C70)) { + if (Actor_IsFacingPlayer(&pthis->actor, 0x1C70)) { + pthis->unk_238 = -pthis->unk_238; + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer - 0x8000, 1, + pthis->actor.speedXZ * 1000.0f, 0); + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_236 + pthis->unk_238, 1, + pthis->actor.speedXZ * 1000.0f, 0); + } + if (pthis->unk_224 <= 200) { + sp60 = Math_SinS(pthis->unk_224 * (0x960 - pthis->unk_224)) * 55.0f; + pthis->color1.r = 255 - ABS(sp60); + sp60 = Math_SinS(pthis->unk_224 * (0x960 - pthis->unk_224)) * 115.0f; + pthis->color1.g = ABS(sp60) + 85; + sp60 = Math_SinS(0x960 - pthis->unk_224) * 255.0f; + pthis->color1.b = ABS(sp60); + if (pthis->unk_224 == 0) { + pthis->unk_221 = 3; + pthis->unk_250 = 0.0f; + } + } + break; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void func_809CF72C(EnBw* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_bw_Anim_0021A0, -2.0f); + pthis->unk_220 = 3; + pthis->unk_221 = 0; + pthis->unk_250 = 0.6f; + pthis->unk_222 = 20; + pthis->unk_224 = 0xBB8; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEWALK_AIM); + EnBw_SetupAction(pthis, func_809CF7AC); +} + +void func_809CF7AC(EnBw* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->unk_222 > 0) { + pthis->unk_222--; + } else { + pthis->unk_222 = 100; + } + } + if (pthis->unk_222 >= 20) { + pthis->unk_224 -= 250; + } + pthis->actor.scale.x = 0.013f - Math_SinF(pthis->unk_224 * 0.001f) * 0.0034999999f; + pthis->actor.scale.y = 0.013f + Math_SinF(pthis->unk_224 * 0.001f) * 0.0245f; + pthis->actor.scale.z = 0.013f - Math_SinF(pthis->unk_224 * 0.001f) * 0.0034999999f; + if (pthis->unk_224 == 0) { + func_809CE9A8(pthis); + pthis->unk_224 = 200; + } +} + +void func_809CF8F0(EnBw* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_bw_Anim_002250, -1.0f); + pthis->actor.speedXZ = 7.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->unk_220 = 4; + pthis->unk_222 = 1000; + pthis->actor.velocity.y = 11.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actor.flags |= ACTOR_FLAG_24; + EnBw_SetupAction(pthis, func_809CF984); +} + +void func_809CF984(EnBw* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 floorPolyType; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + pthis->unk_222 += 250; + pthis->actor.scale.x = 0.013f - Math_SinF(pthis->unk_222 * 0.001f) * 0.0034999999f; + pthis->actor.scale.y = 0.013f + Math_SinF(pthis->unk_222 * 0.001f) * 0.0245f; + pthis->actor.scale.z = 0.013f - Math_SinF(pthis->unk_222 * 0.001f) * 0.0034999999f; + if (pthis->collider1.base.atFlags & AT_HIT) { + pthis->collider1.base.atFlags &= ~AT_HIT; + pthis->actor.speedXZ = -6.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if ((&player->actor == pthis->collider1.base.at) && !(pthis->collider1.base.atFlags & AT_BOUNCED)) { + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + } + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.bgCheckFlags & 3) { + floorPolyType = func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + if ((floorPolyType == 2) || (floorPolyType == 3) || (floorPolyType == 9)) { + Actor_Kill(&pthis->actor); + return; + } + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); + pthis->unk_222 = 3000; + pthis->actor.flags &= ~ACTOR_FLAG_24; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + EnBw_SetupAction(pthis, func_809CE884); + } +} + +void func_809CFBA8(EnBw* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_bw_Anim_002250, -1.0f); + pthis->unk_220 = 5; + pthis->unk_222 = 1000; + pthis->unk_260 = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 11.0f; + pthis->unk_25C = Rand_ZeroOne() * 0.25f + 1.0f; + pthis->unk_224 = 0xBB8; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEWALK_REVERSE); + EnBw_SetupAction(pthis, func_809CFC4C); +} + +void func_809CFC4C(EnBw* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.z, 0x7FFF, 1, 0xFA0, 0); + Math_SmoothStepToF(&pthis->unk_248, 0.0f, 1.0f, 0.05f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.bgCheckFlags & 3) { + if ((globalCtx->gameplayFrames % 0x80) == 0) { + pthis->unk_25C = (Rand_ZeroOne() * 0.25f) + 0.7f; + } + pthis->unk_221 = 4; + pthis->unk_258 += pthis->unk_25C; + Math_SmoothStepToF(&pthis->unk_260, 0.075f, 1.0f, 0.005f, 0.0f); + if (pthis->actor.bgCheckFlags & 2) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + if (pthis->unk_224 != 0) { + pthis->unk_224 -= 250; + pthis->actor.scale.x = 0.013f + Math_SinF(pthis->unk_224 * 0.001f) * 0.0069999998f; + pthis->actor.scale.y = 0.013f - Math_SinF(pthis->unk_224 * 0.001f) * 0.0069999998f; + pthis->actor.scale.z = 0.013f + Math_SinF(pthis->unk_224 * 0.001f) * 0.0069999998f; + } + pthis->unk_222--; + if (pthis->unk_222 == 0) { + func_809CFF10(pthis); + } + } else { + pthis->color1.r -= 8; + pthis->color1.g += 32; + if (pthis->color1.r < 200) { + pthis->color1.r = 200; + } + if (pthis->color1.g > 200) { + pthis->color1.g = 200; + } + if (pthis->color1.b > 235) { + pthis->color1.b = 255; + } else { + pthis->color1.b += 40; + } + if (pthis->actor.shape.yOffset < 1000.0f) { + pthis->actor.shape.yOffset += 200.0f; + } + } +} + +void func_809CFF10(EnBw* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_bw_Anim_002250, -1.0f); + pthis->unk_220 = 6; + pthis->unk_222 = 1000; + pthis->unk_221 = 3; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 11.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEWALK_REVERSE); + pthis->actor.bgCheckFlags &= ~1; + EnBw_SetupAction(pthis, func_809CFF98); +} + +void func_809CFF98(EnBw* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.z, 0, 1, 0xFA0, 0); + Math_SmoothStepToF(&pthis->unk_248, 0.6f, 1.0f, 0.05f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.bgCheckFlags & 3) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); + pthis->unk_222 = 0xBB8; + pthis->unk_250 = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + EnBw_SetupAction(pthis, func_809CE884); + } + if (pthis->color1.r < 247) { + pthis->color1.r += 8; + } else { + pthis->color1.r = 255; + } + if (pthis->color1.g < 32) { + pthis->color1.g = 0; + } else { + pthis->color1.g -= 32; + } + if (pthis->color1.b < 40) { + pthis->color1.b = 0; + } else { + pthis->color1.b -= 40; + } + if (pthis->actor.shape.yOffset > 0.0f) { + pthis->actor.shape.yOffset -= 200.0f; + } +} + +void func_809D00F4(EnBw* pthis) { + pthis->unk_220 = 0; + pthis->unk_222 = 40; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEWALK_DEAD); + EnBw_SetupAction(pthis, func_809D014C); +} + +void func_809D014C(EnBw* pthis, GlobalContext* globalCtx) { + if (pthis->unk_230) { + pthis->actor.scale.x += 0.0002f; + pthis->actor.scale.y -= 0.0002f; + pthis->actor.scale.z += 0.0002f; + } + pthis->actor.shape.shadowAlpha = pthis->color1.a -= 6; + pthis->unk_222--; + if (pthis->unk_222 <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_809D01CC(EnBw* pthis) { + pthis->unk_220 = 1; + pthis->actor.speedXZ = 0.0f; + pthis->unk_25C = (Rand_ZeroOne() * 0.25f) + 1.0f; + pthis->unk_260 = 0.0f; + if (pthis->damageEffect == 0xE) { + pthis->iceTimer = 0x50; + } + pthis->unk_222 = (pthis->actor.colorFilterParams & 0x4000) ? 25 : 80; + EnBw_SetupAction(pthis, func_809D0268); +} + +void func_809D0268(EnBw* pthis, GlobalContext* globalCtx) { + pthis->color1.r -= 1; + pthis->color1.g += 4; + pthis->color1.b += 5; + if (pthis->color1.r < 200) { + pthis->color1.r = 200; + } + if (pthis->color1.g > 200) { + pthis->color1.g = 200; + } + if (pthis->color1.b > 230) { + pthis->color1.b = 230; + } + if (pthis->actor.colorFilterParams & 0x4000) { + if ((globalCtx->gameplayFrames % 0x80) == 0) { + pthis->unk_25C = 0.5f + Rand_ZeroOne() * 0.25f; + } + pthis->unk_258 += pthis->unk_25C; + Math_SmoothStepToF(&pthis->unk_260, 0.075f, 1.0f, 0.005f, 0.0f); + } + pthis->unk_222--; + if (pthis->unk_222 == 0) { + func_809CE9A8(pthis); + pthis->color1.r = pthis->color1.g = 200; + pthis->color1.b = 255; + pthis->unk_224 = 0x258; + pthis->unk_221 = 1; + pthis->unk_250 = 0.7f; + pthis->unk_236++; + } +} + +void func_809D03CC(EnBw* pthis) { + pthis->actor.speedXZ = 0.0f; + if (pthis->damageEffect == 0xE) { + pthis->iceTimer = 32; + } + pthis->unk_23C = pthis->actor.colorFilterTimer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + EnBw_SetupAction(pthis, func_809D0424); +} + +void func_809D0424(EnBw* pthis, GlobalContext* globalCtx) { + if (pthis->actor.colorFilterTimer == 0) { + pthis->unk_23C = 0; + if (pthis->actor.colChkInfo.health != 0) { + if ((pthis->unk_220 != 5) && (pthis->unk_220 != 6)) { + func_809CE9A8(pthis); + pthis->color1.r = pthis->color1.g = 200; + pthis->color1.b = 255; + pthis->unk_224 = 0x258; + pthis->unk_221 = 1; + pthis->unk_250 = 0.7f; + pthis->unk_236++; + } else if (pthis->unk_220 != 5) { + EnBw_SetupAction(pthis, func_809CFF98); + } else { + func_809CFF10(pthis); + } + } else { + if (func_800355E4(globalCtx, &pthis->collider2.base)) { + pthis->unk_230 = 0; + pthis->actor.scale.y -= 0.009f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); + } else { + pthis->unk_230 = 1; + } + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x90); + func_809D00F4(pthis); + } + } +} + +void func_809D0584(EnBw* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.bgCheckFlags & 0x10) && (pthis->actor.bgCheckFlags & 1)) { + pthis->unk_230 = 0; + pthis->actor.scale.y -= 0.009f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 30.0f, 0xB, 4.0f, 0, 0, 0); + func_809D00F4(pthis); + } else { + if (pthis->collider2.base.acFlags & AC_HIT) { + pthis->collider2.base.acFlags &= ~AC_HIT; + if ((pthis->actor.colChkInfo.damageEffect == 0) || (pthis->unk_220 == 6)) { + return; + } + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->actor, &pthis->collider2.info, 0); + if ((pthis->damageEffect == 1) || (pthis->damageEffect == 0xE)) { + if (pthis->unk_23C == 0) { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0, 0x78, 0, 0x50); + func_809D03CC(pthis); + pthis->unk_248 = 0.0f; + } + return; + } + if (pthis->unk_248 == 0.0f) { + Actor_ApplyDamage(&pthis->actor); + } + if (((pthis->unk_221 == 1) || (pthis->unk_221 == 4)) && (pthis->actor.colChkInfo.health == 0)) { + if (pthis->unk_220 != 0) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + if (func_800355E4(globalCtx, &pthis->collider2.base)) { + pthis->unk_230 = 0; + pthis->actor.scale.y -= 0.009f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 30.0f, 0xB, 4.0f, 0, + 0, 0); + } else { + pthis->unk_230 = 1; + } + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x90); + func_809D00F4(pthis); + } + } else if ((pthis->unk_220 != 1) && (pthis->unk_220 != 6)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLEWALK_DAMAGE); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + if (pthis->unk_220 != 5) { + func_809D01CC(pthis); + } + pthis->unk_248 = 0.0f; + } + } + if ((globalCtx->actorCtx.unk_02 != 0) && (pthis->actor.xzDistToPlayer <= 400.0f) && + (pthis->actor.bgCheckFlags & 1)) { + if (pthis->unk_220 == 5) { + pthis->unk_23C = 0; + func_809CFF10(pthis); + } else if (pthis->unk_220 != 0) { + pthis->unk_23C = 0; + func_809CFBA8(pthis); + } + } + } +} + +void EnBw_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBw* pthis = (EnBw*)thisx; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + s32 pad[3]; // probably an unused Vec3f + Color_RGBA8 sp50 = { 255, 200, 0, 255 }; + Color_RGBA8 sp4C = { 255, 80, 0, 255 }; + Color_RGBA8 sp48 = { 0, 0, 0, 255 }; + Color_RGBA8 sp44 = { 0, 0, 0, 220 }; + + func_809D0584(pthis, globalCtx); + if (thisx->colChkInfo.damageEffect != 6) { + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_23C == 0) { + pthis->unk_23A = (pthis->unk_23A + 4) & 0x7F; + } + if ((globalCtx->gameplayFrames & pthis->unk_221) == 0) { + accel.y = -3.0f; + velocity.x = Rand_CenteredFloat(pthis->unk_248 * 24.0f); + velocity.y = pthis->unk_248 * 30.0f; + velocity.z = Rand_CenteredFloat(pthis->unk_248 * 24.0f); + accel.x = velocity.x * -0.075f; + accel.z = velocity.z * -0.075f; + func_8002836C(globalCtx, &thisx->world.pos, &velocity, &accel, &sp50, &sp4C, 0x3C, 0, 0x14); + } + if (pthis->unk_248 <= 0.4f) { + pthis->collider1.info.toucher.effect = 0; + if (((globalCtx->gameplayFrames & 1) == 0) && (pthis->unk_220 < 5) && (pthis->unk_23C == 0)) { + accel.y = -0.1f; + velocity.x = Rand_CenteredFloat(4.0f); + velocity.y = Rand_CenteredFloat(2.0f) + 6.0f; + velocity.z = Rand_CenteredFloat(4.0f); + accel.x = velocity.x * -0.1f; + accel.z = velocity.z * -0.1f; + Rand_CenteredFloat(4.0f); + Rand_CenteredFloat(4.0f); + sp48.a = pthis->color1.a; + if (sp48.a >= 30) { + sp44.a = sp48.a - 30; + } else { + sp44.a = 0; + } + func_8002836C(globalCtx, &thisx->world.pos, &velocity, &accel, &sp48, &sp44, 0xB4, 0x28, + 20.0f - (pthis->unk_248 * 40.0f)); + } + } else { + pthis->collider1.info.toucher.effect = 1; + } + + pthis->unk_234 = Actor_TestFloorInDirection(thisx, globalCtx, 50.0f, thisx->world.rot.y); + if ((pthis->unk_220 == 4) || (pthis->unk_220 == 6) || (pthis->unk_220 == 5) || (pthis->unk_220 == 1) || + (pthis->unk_234 != 0)) { + Actor_MoveForward(thisx); + } + Actor_UpdateBgCheckInfo(globalCtx, thisx, 20.0f, 30.0f, 21.0f, 0x1F); + } + Collider_UpdateCylinder(thisx, &pthis->collider2); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + if ((pthis->unk_220 != 0) && ((thisx->colorFilterTimer == 0) || !(thisx->colorFilterParams & 0x4000))) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + } + if ((pthis->unk_221 != 1) && (pthis->unk_220 < 5) && (pthis->unk_248 > 0.4f)) { + Collider_UpdateCylinder(thisx, &pthis->collider1); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + } + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 5.0f; +} + +s32 EnBw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnBw* pthis = (EnBw*)thisx; + + if (limbIndex == 1) { + gSPSegment((*gfx)++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, 0, pthis->unk_23A, 0x20, 0x20)); + if ((pthis->unk_220 == 1) || (pthis->unk_220 == 5)) { + Matrix_Push(); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateX(pthis->unk_258 * 0.115f, MTXMODE_APPLY); + Matrix_RotateY(pthis->unk_258 * 0.13f, MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_258 * 0.1f, MTXMODE_APPLY); + Matrix_Scale(1.0f - pthis->unk_260, 1.0f + pthis->unk_260, 1.0f - pthis->unk_260, MTXMODE_APPLY); + Matrix_RotateZ(-(pthis->unk_258 * 0.1f), MTXMODE_APPLY); + Matrix_RotateY(-(pthis->unk_258 * 0.13f), MTXMODE_APPLY); + Matrix_RotateX(-(pthis->unk_258 * 0.115f), MTXMODE_APPLY); + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bw.c", 1388), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, *dList); + Matrix_Pop(); + return 1; + } + } + return 0; +} + +static Vec3f sIceOffsets[] = { + { 20.0f, 10.0f, 0.0f }, { -20.0f, 10.0f, 0.0f }, { 0.0f, 10.0f, -25.0f }, { 10.0f, 0.0f, 15.0f }, + { 10.0f, 0.0f, -15.0f }, { 0.0f, 10.0f, 25.0f }, { -10.0f, 0.0f, 15.0f }, { -10.0f, 0.0f, -15.0f }, +}; + +void EnBw_Draw(Actor* thisx, GlobalContext* globalCtx2) { + Vec3f spAC = { 0.0f, 0.0f, 0.0f }; + GlobalContext* globalCtx = globalCtx2; + EnBw* pthis = (EnBw*)thisx; + Vec3f icePos; + s32 iceIndex; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bw.c", 1423); + + if (pthis->color1.a == 0xFF) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->color1.r, pthis->color1.g, pthis->color1.b, pthis->color1.a); + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnBw_OverrideLimbDraw, NULL, pthis, POLY_OPA_DISP); + } else { + func_80093D84(globalCtx->state.gfxCtx); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 0, 0, 0, pthis->color1.a); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->color1.r, pthis->color1.g, pthis->color1.b, pthis->color1.a); + gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnBw_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + } + + if (((globalCtx->gameplayFrames + 1) % 4) == (u32)thisx->params) { + spAC.z = thisx->scale.z * 375000.0f; + Matrix_MultVec3f(&spAC, &pthis->unk_264); + spAC.z = thisx->scale.z * 150000.0f; + Matrix_MultVec3f(&spAC, &pthis->unk_270); + spAC.x = thisx->scale.x * 550000.0f; + Matrix_MultVec3f(&spAC, &pthis->unk_288); + spAC.x = -spAC.x; + Matrix_MultVec3f(&spAC, &pthis->unk_27C); + } + + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y + ((thisx->scale.y - 0.013f) * 1000.0f), thisx->world.pos.z, + MTXMODE_NEW); + func_80093D84(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + (globalCtx->gameplayFrames * -20) % 0x200, 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); + Matrix_Scale(pthis->unk_248 * 0.01f, pthis->unk_248 * 0.01f, pthis->unk_248 * 0.01f, MTXMODE_APPLY); + func_800D1FD4(&globalCtx->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bw.c", 1500), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + if (pthis->iceTimer != 0) { + thisx->colorFilterTimer++; + pthis->iceTimer--; + if ((pthis->iceTimer & 3) == 0) { + iceIndex = pthis->iceTimer >> 2; + + icePos.x = sIceOffsets[iceIndex].x + thisx->world.pos.x; + icePos.y = sIceOffsets[iceIndex].y + thisx->world.pos.y; + icePos.z = sIceOffsets[iceIndex].z + thisx->world.pos.z; + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, thisx, &icePos, 0x96, 0x96, 0x96, 0xFA, 0xEB, 0xF5, 0xFF, 1.3f); + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_bw.c", 1521); +} diff --git a/src/overlays/actors/ovl_En_Bx/z_en_bx.c b/src/overlays/actors/ovl_En_Bx/z_en_bx.cpp similarity index 63% rename from src/overlays/actors/ovl_En_Bx/z_en_bx.c rename to src/overlays/actors/ovl_En_Bx/z_en_bx.cpp index e766d44d3..3de121085 100644 --- a/src/overlays/actors/ovl_En_Bx/z_en_bx.c +++ b/src/overlays/actors/ovl_En_Bx/z_en_bx.cpp @@ -23,7 +23,7 @@ void EnBx_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBx_Update(Actor* thisx, GlobalContext* globalCtx); void EnBx_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Bx_InitVars = { +ActorInit En_Bx_InitVars = { ACTOR_EN_BX, ACTORCAT_ENEMY, FLAGS, @@ -76,7 +76,7 @@ static ColliderQuadInit sQuadInit = { }; void EnBx_Init(Actor* thisx, GlobalContext* globalCtx) { - EnBx* this = (EnBx*)thisx; + EnBx* pthis = (EnBx*)thisx; Vec3f sp48 = { 0.015f, 0.015f, 0.015f }; Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; static InitChainEntry sInitChain[] = { @@ -85,38 +85,38 @@ void EnBx_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; s32 pad; - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(&pthis->actor, sInitChain); thisx->scale.x = thisx->scale.z = 0.01f; thisx->scale.y = 0.03f; thisx->world.pos.y = thisx->world.pos.y - 100.0f; for (i = 0; i < 4; i++) { - this->unk_184[i] = sp48; + pthis->unk_184[i] = sp48; if (i == 0) { - this->unk_1B4[i].x = thisx->shape.rot.x - 0x4000; + pthis->unk_1B4[i].x = thisx->shape.rot.x - 0x4000; } - this->unk_154[i] = thisx->world.pos; - this->unk_154[i].y = thisx->world.pos.y + ((i + 1) * 140.0f); + pthis->unk_154[i] = thisx->world.pos; + pthis->unk_154[i].y = thisx->world.pos.y + ((i + 1) * 140.0f); } ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 48.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_InitQuad(globalCtx, &this->colliderQuad); - Collider_SetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_InitQuad(globalCtx, &pthis->colliderQuad); + Collider_SetQuad(globalCtx, &pthis->colliderQuad, &pthis->actor, &sQuadInit); thisx->colChkInfo.mass = MASS_IMMOVABLE; - this->unk_14C = 0; + pthis->unk_14C = 0; thisx->uncullZoneDownward = 2000.0f; if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0xFF)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } thisx->params &= 0xFF; } void EnBx_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBx* this = (EnBx*)thisx; + EnBx* pthis = (EnBx*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void func_809D1D0C(Actor* thisx, GlobalContext* globalCtx) { @@ -126,34 +126,34 @@ void func_809D1D0C(Actor* thisx, GlobalContext* globalCtx) { static Vec3f D_809D254C = { -8000.0f, 10000.0f, 2500.0f }; Vec3f sp44; Vec3f sp38; - EnBx* this = (EnBx*)thisx; + EnBx* pthis = (EnBx*)thisx; Matrix_MultVec3f(&D_809D2540, &sp44); Matrix_MultVec3f(&D_809D254C, &sp38); - Matrix_MultVec3f(&sp5C, &this->colliderQuad.dim.quad[1]); - Matrix_MultVec3f(&sp50, &this->colliderQuad.dim.quad[0]); - Collider_SetQuadVertices(&this->colliderQuad, &sp38, &sp44, &this->colliderQuad.dim.quad[0], - &this->colliderQuad.dim.quad[1]); + Matrix_MultVec3f(&sp5C, &pthis->colliderQuad.dim.quad[1]); + Matrix_MultVec3f(&sp50, &pthis->colliderQuad.dim.quad[0]); + Collider_SetQuadVertices(&pthis->colliderQuad, &sp38, &sp44, &pthis->colliderQuad.dim.quad[0], + &pthis->colliderQuad.dim.quad[1]); } void EnBx_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBx* this = (EnBx*)thisx; + EnBx* pthis = (EnBx*)thisx; Player* player = GET_PLAYER(globalCtx); s32 i; s16 tmp32; s32 tmp33; - if ((thisx->xzDistToPlayer <= 70.0f) || (this->collider.base.atFlags & AT_HIT) || - (this->collider.base.acFlags & AC_HIT) || (this->colliderQuad.base.atFlags & AT_HIT)) { - if ((thisx->xzDistToPlayer <= 70.0f) || (&player->actor == this->collider.base.at) || - (&player->actor == this->collider.base.ac) || (&player->actor == this->colliderQuad.base.at)) { + if ((thisx->xzDistToPlayer <= 70.0f) || (pthis->collider.base.atFlags & AT_HIT) || + (pthis->collider.base.acFlags & AC_HIT) || (pthis->colliderQuad.base.atFlags & AT_HIT)) { + if ((thisx->xzDistToPlayer <= 70.0f) || (&player->actor == pthis->collider.base.at) || + (&player->actor == pthis->collider.base.ac) || (&player->actor == pthis->colliderQuad.base.at)) { tmp33 = player->invincibilityTimer & 0xFF; tmp32 = thisx->world.rot.y; if (!(thisx->params & 0x80)) { tmp32 = thisx->yawTowardsPlayer; } - if ((&player->actor != this->collider.base.at) && (&player->actor != this->collider.base.ac) && - (&player->actor != this->colliderQuad.base.at) && (player->invincibilityTimer <= 0)) { + if ((&player->actor != pthis->collider.base.at) && (&player->actor != pthis->collider.base.ac) && + (&player->actor != pthis->colliderQuad.base.at) && (player->invincibilityTimer <= 0)) { if (player->invincibilityTimer < -39) { player->invincibilityTimer = 0; } else { @@ -161,23 +161,23 @@ void EnBx_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->damagePlayer(globalCtx, -4); } } - func_8002F71C(globalCtx, &this->actor, 6.0f, tmp32, 6.0f); + func_8002F71C(globalCtx, &pthis->actor, 6.0f, tmp32, 6.0f); player->invincibilityTimer = tmp33; } - this->collider.base.atFlags &= ~AT_HIT; - this->collider.base.acFlags &= ~AC_HIT; - this->colliderQuad.base.atFlags &= ~AT_HIT; - this->colliderQuad.base.at = NULL; - this->collider.base.ac = NULL; - this->collider.base.at = NULL; - this->unk_14C = 0x14; + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->colliderQuad.base.atFlags &= ~AT_HIT; + pthis->colliderQuad.base.at = NULL; + pthis->collider.base.ac = NULL; + pthis->collider.base.at = NULL; + pthis->unk_14C = 0x14; } - if (this->unk_14C != 0) { - this->unk_14C--; + if (pthis->unk_14C != 0) { + pthis->unk_14C--; for (i = 0; i < 4; i++) { - if (!((this->unk_14C + (i << 1)) % 4)) { + if (!((pthis->unk_14C + (i << 1)) % 4)) { static Color_RGBA8 primColor = { 255, 255, 255, 255 }; static Color_RGBA8 envColor = { 200, 255, 255, 255 }; Vec3f pos; @@ -195,11 +195,11 @@ void EnBx_Update(Actor* thisx, GlobalContext* globalCtx) { Audio_PlayActorSound2(thisx, NA_SE_EN_BIRI_SPARK - SFX_FLAG); } thisx->focus.pos = thisx->world.pos; - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); if (thisx->params & 0x80) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderQuad.base); } } @@ -209,9 +209,9 @@ void EnBx_Draw(Actor* thisx, GlobalContext* globalCtx) { object_bxa_Tex_0027F0, object_bxa_Tex_0029F0, }; - EnBx* this = (EnBx*)thisx; + EnBx* pthis = (EnBx*)thisx; s32 pad; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Mtx)); + Mtx* mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Mtx)); s16 i; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_bx.c", 464); @@ -219,33 +219,33 @@ void EnBx_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0C, mtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809D2560[this->actor.params & 0x7F])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_809D2560[pthis->actor.params & 0x7F])); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 16, 1, 0, (globalCtx->gameplayFrames * -10) % 128, 32, 32)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bx.c", 478), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->actor.params & 0x80) { - func_809D1D0C(&this->actor, globalCtx); + if (pthis->actor.params & 0x80) { + func_809D1D0C(&pthis->actor, globalCtx); } - this->unk_14E -= 0xBB8; - thisx->scale.z = thisx->scale.x = (Math_CosS(this->unk_14E) * 0.0075f) + 0.015f; + pthis->unk_14E -= 0xBB8; + thisx->scale.z = thisx->scale.x = (Math_CosS(pthis->unk_14E) * 0.0075f) + 0.015f; for (i = 3; i >= 0; i--) { s16 off = (0x2000 * i); - this->unk_184[i].z = this->unk_184[i].x = (Math_CosS(this->unk_14E + off) * 0.0075f) + 0.015f; - this->unk_1B4[i].x = thisx->shape.rot.x; - this->unk_1B4[i].y = thisx->shape.rot.y; - this->unk_1B4[i].z = thisx->shape.rot.z; + pthis->unk_184[i].z = pthis->unk_184[i].x = (Math_CosS(pthis->unk_14E + off) * 0.0075f) + 0.015f; + pthis->unk_1B4[i].x = thisx->shape.rot.x; + pthis->unk_1B4[i].y = thisx->shape.rot.y; + pthis->unk_1B4[i].z = thisx->shape.rot.z; } for (i = 0; i < 4; i++, mtx++) { - Matrix_Translate(this->unk_154[i].x, this->unk_154[i].y, this->unk_154[i].z, MTXMODE_NEW); - Matrix_RotateZYX(this->unk_1B4[i].x, this->unk_1B4[i].y, this->unk_1B4[i].z, MTXMODE_APPLY); - Matrix_Scale(this->unk_184[i].x, this->unk_184[i].y, this->unk_184[i].z, MTXMODE_APPLY); + Matrix_Translate(pthis->unk_154[i].x, pthis->unk_154[i].y, pthis->unk_154[i].z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->unk_1B4[i].x, pthis->unk_1B4[i].y, pthis->unk_1B4[i].z, MTXMODE_APPLY); + Matrix_Scale(pthis->unk_184[i].x, pthis->unk_184[i].y, pthis->unk_184[i].z, MTXMODE_APPLY); Matrix_ToMtx(mtx, "../z_en_bx.c", 507); } diff --git a/src/overlays/actors/ovl_En_Changer/z_en_changer.c b/src/overlays/actors/ovl_En_Changer/z_en_changer.cpp similarity index 72% rename from src/overlays/actors/ovl_En_Changer/z_en_changer.c rename to src/overlays/actors/ovl_En_Changer/z_en_changer.cpp index 8303cbe61..9e66b1756 100644 --- a/src/overlays/actors/ovl_En_Changer/z_en_changer.c +++ b/src/overlays/actors/ovl_En_Changer/z_en_changer.cpp @@ -24,11 +24,11 @@ void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx); void EnChanger_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnChanger_Update(Actor* thisx, GlobalContext* globalCtx); -void EnChanger_Wait(EnChanger* this, GlobalContext* globalCtx); -void EnChanger_OpenChests(EnChanger* this, GlobalContext* globalCtx); -void EnChanger_SetHeartPieceFlag(EnChanger* this, GlobalContext* globalCtx); +void EnChanger_Wait(EnChanger* pthis, GlobalContext* globalCtx); +void EnChanger_OpenChests(EnChanger* pthis, GlobalContext* globalCtx); +void EnChanger_SetHeartPieceFlag(EnChanger* pthis, GlobalContext* globalCtx); -const ActorInit En_Changer_InitVars = { +ActorInit En_Changer_InitVars = { ACTOR_EN_CHANGER, ACTORCAT_PROP, FLAGS, @@ -69,7 +69,7 @@ void EnChanger_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnChanger* this = (EnChanger*)thisx; + EnChanger* pthis = (EnChanger*)thisx; GlobalContext* globalCtx = globalCtx2; s16 leftChestParams; s16 rightChestParams; @@ -88,7 +88,7 @@ void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx2) { minigameRoomNum = 0; } if (Flags_GetTreasure(globalCtx, sTreasureFlags[minigameRoomNum])) { - this->roomChestsOpened = true; + pthis->roomChestsOpened = true; } osSyncPrintf("\n\n"); @@ -99,7 +99,7 @@ void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx2) { // "How is the Save BIT?" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セーブBITは? %x\n" VT_RST, sTreasureFlags[minigameRoomNum]); // "Is it already a zombie?" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もう、ゾンビ?\t %d\n" VT_RST, this->roomChestsOpened); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もう、ゾンビ?\t %d\n" VT_RST, pthis->roomChestsOpened); osSyncPrintf("\n\n"); minigameRoomNum *= 2; @@ -107,12 +107,12 @@ void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx2) { if (globalCtx->roomCtx.curRoom.num >= 6) { rewardChestParams = ((gSaveContext.itemGetInf[1] & 0x800) ? (0x4EA0) : (0x4EC0)); rewardChestParams = sTreasureFlags[5] | rewardChestParams; - this->finalChest = (EnBox*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOX, + pthis->finalChest = (EnBox*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_BOX, 20.0f, 20.0f, -2500.0f, 0, 0x7FFF, 0, rewardChestParams); - if (this->finalChest != NULL) { - if (this->roomChestsOpened) { + if (pthis->finalChest != NULL) { + if (pthis->roomChestsOpened) { Flags_SetTreasure(globalCtx, rewardChestParams & 0x1F); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } else { rewardParams = ((gSaveContext.itemGetInf[1] & 0x800) ? (ITEM_ETC_RUPEE_PURPLE_CHEST_GAME) @@ -122,7 +122,7 @@ void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx2) { ((sTreasureFlags[5] & 0x1F) << 8) + rewardParams); // "Central treasure instance/occurrence (GREAT)" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 中央宝発生(GREAT) ☆☆☆☆☆ %x\n" VT_RST, rewardChestParams); - this->actionFunc = EnChanger_SetHeartPieceFlag; + pthis->actionFunc = EnChanger_SetHeartPieceFlag; return; } } @@ -132,99 +132,99 @@ void EnChanger_Init(Actor* thisx, GlobalContext* globalCtx2) { // Set up items in chests, swap them round with probability 1/2 leftChestParams = (sLoserGetItemIds[globalCtx->roomCtx.curRoom.num] << 5) | 0x4000; new_var = temp_v1_3; - this->leftChestNum = new_var; - this->leftChestGetItemId = sLoserGetItemIds[globalCtx->roomCtx.curRoom.num]; + pthis->leftChestNum = new_var; + pthis->leftChestGetItemId = sLoserGetItemIds[globalCtx->roomCtx.curRoom.num]; leftChestItem = sItemEtcTypes[globalCtx->roomCtx.curRoom.num]; leftChestParams |= new_var; rightChestParams = new_var | 0x4E21; - this->rightChestNum = new_var | 1; - this->rightChestGetItemId = GI_DOOR_KEY; + pthis->rightChestNum = new_var | 1; + pthis->rightChestGetItemId = GI_DOOR_KEY; rightChestItem = ITEM_ETC_KEY_SMALL_CHEST_GAME; if (Rand_ZeroFloat(1.99f) < 1.0f) { rightChestParams = (sLoserGetItemIds[globalCtx->roomCtx.curRoom.num] << 5) | 0x4000; - this->rightChestNum = new_var; - this->rightChestGetItemId = sLoserGetItemIds[globalCtx->roomCtx.curRoom.num]; + pthis->rightChestNum = new_var; + pthis->rightChestGetItemId = sLoserGetItemIds[globalCtx->roomCtx.curRoom.num]; rightChestItem = sItemEtcTypes[globalCtx->roomCtx.curRoom.num]; leftChestParams = new_var | 0x4E21; rightChestParams |= new_var; - this->leftChestNum = temp_v1_3 | 1; - this->leftChestGetItemId = GI_DOOR_KEY; + pthis->leftChestNum = temp_v1_3 | 1; + pthis->leftChestGetItemId = GI_DOOR_KEY; leftChestItem = ITEM_ETC_KEY_SMALL_CHEST_GAME; } - this->leftChest = (EnBox*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOX, sLeftChestPos[globalCtx->roomCtx.curRoom.num].x, + pthis->leftChest = (EnBox*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_BOX, sLeftChestPos[globalCtx->roomCtx.curRoom.num].x, sLeftChestPos[globalCtx->roomCtx.curRoom.num].y, sLeftChestPos[globalCtx->roomCtx.curRoom.num].z, 0, -0x3FFF, 0, leftChestParams); - if (this->leftChest != NULL) { + if (pthis->leftChest != NULL) { // "Left treasure generation (what does it contain?)" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 左宝発生(ナニがはいってるの?) ☆☆☆☆☆ %x\n" VT_RST, leftChestParams); // "What is the room number?" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 部屋番号は? %x\n" VT_RST, globalCtx->roomCtx.curRoom.num); // "What is the bit?" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ビットはなぁに? %x\n" VT_RST, this->rightChestNum); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ビットはなぁに? %x\n" VT_RST, pthis->rightChestNum); // "Sukesuke-kun" (something to do with being invisible) osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ すけすけ君? %x\n" VT_RST, rightChestItem); osSyncPrintf("\n\n"); - if (this->roomChestsOpened) { - Flags_SetTreasure(globalCtx, this->leftChestNum & 0x1F); + if (pthis->roomChestsOpened) { + Flags_SetTreasure(globalCtx, pthis->leftChestNum & 0x1F); } else { Actor_Spawn( &globalCtx->actorCtx, globalCtx, ACTOR_ITEM_ETCETERA, sLeftChestPos[globalCtx->roomCtx.curRoom.num].x, sLeftChestPos[globalCtx->roomCtx.curRoom.num].y, sLeftChestPos[globalCtx->roomCtx.curRoom.num].z, 0, 0, - 0, ((this->leftChestNum & 0x1F) << 8) + (leftChestItem & 0xFF)); + 0, ((pthis->leftChestNum & 0x1F) << 8) + (leftChestItem & 0xFF)); } } - this->rightChest = (EnBox*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOX, sRightChestPos[globalCtx->roomCtx.curRoom.num].x, + pthis->rightChest = (EnBox*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_BOX, sRightChestPos[globalCtx->roomCtx.curRoom.num].x, sRightChestPos[globalCtx->roomCtx.curRoom.num].y, sRightChestPos[globalCtx->roomCtx.curRoom.num].z, 0, 0x3FFF, 0, rightChestParams); - if (this->rightChest != NULL) { + if (pthis->rightChest != NULL) { // "Right treasure generation (what does it contain?)" osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 右宝発生(ナニがはいってるの?) ☆☆☆☆☆ %x\n" VT_RST, rightChestParams); // "What is the room number?" osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 部屋番号は? %d\n" VT_RST, globalCtx->roomCtx.curRoom.num); // "What is the bit?" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ ビットはなぁに? %x\n" VT_RST, this->leftChestNum); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ ビットはなぁに? %x\n" VT_RST, pthis->leftChestNum); // "Sukesuke-kun" (something to do with being invisible) osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ すけすけ君? %x\n" VT_RST, leftChestItem); osSyncPrintf("\n\n"); - if (this->roomChestsOpened) { - Flags_SetTreasure(globalCtx, this->rightChestNum & 0x1F); - Actor_Kill(&this->actor); + if (pthis->roomChestsOpened) { + Flags_SetTreasure(globalCtx, pthis->rightChestNum & 0x1F); + Actor_Kill(&pthis->actor); return; } Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_ETCETERA, sRightChestPos[globalCtx->roomCtx.curRoom.num].x, sRightChestPos[globalCtx->roomCtx.curRoom.num].y, sRightChestPos[globalCtx->roomCtx.curRoom.num].z, 0, 0, 0, - ((this->rightChestNum & 0x1F) << 8) + (rightChestItem & 0xFF)); + ((pthis->rightChestNum & 0x1F) << 8) + (rightChestItem & 0xFF)); } - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnChanger_Wait; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnChanger_Wait; } -void EnChanger_Wait(EnChanger* this, GlobalContext* globalCtx) { - if (this->leftChest->unk_1F4 != 0) { - this->timer = 80; - Flags_SetTreasure(globalCtx, this->rightChestNum & 0x1F); - this->actionFunc = EnChanger_OpenChests; - } else if (this->rightChest->unk_1F4 != 0) { - this->chestOpened = CHEST_RIGHT; - this->timer = 80; - Flags_SetTreasure(globalCtx, this->leftChestNum & 0x1F); - this->actionFunc = EnChanger_OpenChests; +void EnChanger_Wait(EnChanger* pthis, GlobalContext* globalCtx) { + if (pthis->leftChest->unk_1F4 != 0) { + pthis->timer = 80; + Flags_SetTreasure(globalCtx, pthis->rightChestNum & 0x1F); + pthis->actionFunc = EnChanger_OpenChests; + } else if (pthis->rightChest->unk_1F4 != 0) { + pthis->chestOpened = CHEST_RIGHT; + pthis->timer = 80; + Flags_SetTreasure(globalCtx, pthis->leftChestNum & 0x1F); + pthis->actionFunc = EnChanger_OpenChests; } } // Spawns the EnExItem showing what was in the other chest -void EnChanger_OpenChests(EnChanger* this, GlobalContext* globalCtx) { +void EnChanger_OpenChests(EnChanger* pthis, GlobalContext* globalCtx) { f32 zPos; f32 yPos; f32 xPos; @@ -233,11 +233,11 @@ void EnChanger_OpenChests(EnChanger* this, GlobalContext* globalCtx) { EnBox* left; EnBox* right; - left = this->leftChest; - right = this->rightChest; + left = pthis->leftChest; + right = pthis->rightChest; - if (this->timer == 0) { - temp_s0_2 = temp_s0 = this->chestOpened; // Required to use the right registers + if (pthis->timer == 0) { + temp_s0_2 = temp_s0 = pthis->chestOpened; // Required to use the right registers switch (temp_s0_2) { case CHEST_LEFT: @@ -245,11 +245,11 @@ void EnChanger_OpenChests(EnChanger* this, GlobalContext* globalCtx) { yPos = right->dyna.actor.world.pos.y; zPos = right->dyna.actor.world.pos.z; - if (this->rightChestGetItemId == GI_DOOR_KEY) { + if (pthis->rightChestGetItemId == GI_DOOR_KEY) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, 0xF); Flags_SetSwitch(globalCtx, 0x32); } else { - temp_s0_2 = (s16)(this->rightChestGetItemId - GI_RUPEE_GREEN_LOSE) + EXITEM_CHEST; + temp_s0_2 = (s16)(pthis->rightChestGetItemId - GI_RUPEE_GREEN_LOSE) + EXITEM_CHEST; // "Open right treasure (chest)" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 右宝開く ☆☆☆☆☆ %d\n" VT_RST, temp_s0_2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, @@ -261,11 +261,11 @@ void EnChanger_OpenChests(EnChanger* this, GlobalContext* globalCtx) { yPos = left->dyna.actor.world.pos.y; zPos = left->dyna.actor.world.pos.z; - if (this->leftChestGetItemId == GI_DOOR_KEY) { + if (pthis->leftChestGetItemId == GI_DOOR_KEY) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, 0xF); Flags_SetSwitch(globalCtx, 0x32); } else { - temp_s0_2 = (s16)(this->leftChestGetItemId - 0x72) + 0xA; + temp_s0_2 = (s16)(pthis->leftChestGetItemId - 0x72) + 0xA; // "Open left treasure (chest)" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 左宝開く ☆☆☆☆☆ %d\n" VT_RST, temp_s0_2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, @@ -274,25 +274,25 @@ void EnChanger_OpenChests(EnChanger* this, GlobalContext* globalCtx) { break; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void EnChanger_SetHeartPieceFlag(EnChanger* this, GlobalContext* globalCtx) { - if (this->finalChest->unk_1F4 != 0) { +void EnChanger_SetHeartPieceFlag(EnChanger* pthis, GlobalContext* globalCtx) { + if (pthis->finalChest->unk_1F4 != 0) { if (!(gSaveContext.itemGetInf[1] & 0x800)) { gSaveContext.itemGetInf[1] |= 0x800; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void EnChanger_Update(Actor* thisx, GlobalContext* globalCtx) { - EnChanger* this = (EnChanger*)thisx; + EnChanger* pthis = (EnChanger*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.cpp similarity index 68% rename from src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c rename to src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.cpp index 433c4458a..0d9bfdb08 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.cpp @@ -33,9 +33,9 @@ void EnClearTag_CreateSmokeEffect(GlobalContext* globalCtx, Vec3f* position, f32 void EnClearTag_CreateFlashEffect(GlobalContext* globalCtx, Vec3f* position, f32 scale, f32 floorHeight, Vec3f* floorTangent); -void EnClearTag_CalculateFloorTangent(EnClearTag* this); +void EnClearTag_CalculateFloorTangent(EnClearTag* pthis); -const ActorInit En_Clear_Tag_InitVars = { +ActorInit En_Clear_Tag_InitVars = { ACTOR_EN_CLEAR_TAG, ACTORCAT_BOSS, FLAGS, @@ -96,7 +96,7 @@ static UNK_TYPE4 D_809D5C9C = 0; // unused static EnClearTagEffect sClearTagEffects[CLEAR_TAG_EFFECT_MAX_COUNT]; -#include "overlays/ovl_En_Clear_Tag/ovl_En_Clear_Tag.c" +#include "overlays/ovl_En_Clear_Tag/ovl_En_Clear_Tag.cpp" /** * Creates a debris effect. @@ -232,9 +232,9 @@ void EnClearTag_CreateFlashEffect(GlobalContext* globalCtx, Vec3f* position, f32 * This just destroys the collider. */ void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnClearTag* this = (EnClearTag*)thisx; + EnClearTag* pthis = (EnClearTag*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } /** @@ -242,46 +242,46 @@ void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { * This allocates a collider, initializes effects, and sets up ClearTag instance data. */ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { - EnClearTag* this = (EnClearTag*)thisx; + EnClearTag* pthis = (EnClearTag*)thisx; s32 defaultCutsceneTimer = 100; s16 i; s16 j; - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(globalCtx, &pthis->collider); // Initialize the Arwing laser. - if (this->actor.params == CLEAR_TAG_LASER) { - this->state = CLEAR_TAG_STATE_LASER; - this->timers[CLEAR_TAG_TIMER_LASER_DEATH] = 70; - this->actor.speedXZ = 35.0f; - func_8002D908(&this->actor); + if (pthis->actor.params == CLEAR_TAG_LASER) { + pthis->state = CLEAR_TAG_STATE_LASER; + pthis->timers[CLEAR_TAG_TIMER_LASER_DEATH] = 70; + pthis->actor.speedXZ = 35.0f; + func_8002D908(&pthis->actor); for (j = 0; j <= 0; j++) { - func_8002D7EC(&this->actor); + func_8002D7EC(&pthis->actor); } - this->actor.scale.x = 0.4f; - this->actor.scale.y = 0.4f; - this->actor.scale.z = 2.0f; - this->actor.speedXZ = 70.0f; - this->actor.shape.rot.x = -this->actor.shape.rot.x; + pthis->actor.scale.x = 0.4f; + pthis->actor.scale.y = 0.4f; + pthis->actor.scale.z = 2.0f; + pthis->actor.speedXZ = 70.0f; + pthis->actor.shape.rot.x = -pthis->actor.shape.rot.x; - func_8002D908(&this->actor); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sLaserCylinderInit); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SWORD_REFLECT_MG); + func_8002D908(&pthis->actor); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sLaserCylinderInit); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SWORD_REFLECT_MG); } else { // Initialize the Arwing. - this->actor.flags |= ACTOR_FLAG_0; - this->actor.targetMode = 5; - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sArwingCylinderInit); - this->actor.colChkInfo.health = 3; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.targetMode = 5; + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sArwingCylinderInit); + pthis->actor.colChkInfo.health = 3; // Update the Arwing to play the intro cutscene. - if (this->actor.params == CLEAR_TAG_CUTSCENE_ARWING) { - this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = 70; - this->timers[CLEAR_TAG_TIMER_ARWING_ENTER_LOCKED_ON] = 250; - this->state = CLEAR_TAG_STATE_DEMO; - this->actor.world.rot.x = 0x4000; - this->cutsceneMode = CLEAR_TAG_CUTSCENE_MODE_SETUP; - this->cutsceneTimer = defaultCutsceneTimer; - this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_BG_INFO] = 20; + if (pthis->actor.params == CLEAR_TAG_CUTSCENE_ARWING) { + pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = 70; + pthis->timers[CLEAR_TAG_TIMER_ARWING_ENTER_LOCKED_ON] = 250; + pthis->state = CLEAR_TAG_STATE_DEMO; + pthis->actor.world.rot.x = 0x4000; + pthis->cutsceneMode = CLEAR_TAG_CUTSCENE_MODE_SETUP; + pthis->cutsceneTimer = defaultCutsceneTimer; + pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_BG_INFO] = 20; } // Initialize all effects to available if effects have not been initialized. @@ -291,7 +291,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++) { sClearTagEffects[i].type = CLEAR_TAG_EFFECT_AVAILABLE; } - this->drawMode = CLEAR_TAG_DRAW_MODE_ALL; + pthis->drawMode = CLEAR_TAG_DRAW_MODE_ALL; } } } @@ -302,15 +302,15 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { * Calculate a floor tangent. * This is used for the ground flash display lists and Arwing shadow display lists to snap onto the floor. */ -void EnClearTag_CalculateFloorTangent(EnClearTag* this) { +void EnClearTag_CalculateFloorTangent(EnClearTag* pthis) { // If there is a floor poly below the Arwing, calculate the floor tangent. - if (this->actor.floorPoly != NULL) { - f32 x = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); - f32 y = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - f32 z = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + if (pthis->actor.floorPoly != NULL) { + f32 x = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.x); + f32 y = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.y); + f32 z = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.z); - this->floorTangent.x = -Math_FAtan2F(-z * y, 1.0f); - this->floorTangent.z = Math_FAtan2F(-x * y, 1.0f); + pthis->floorTangent.x = -Math_FAtan2F(-z * y, 1.0f); + pthis->floorTangent.z = Math_FAtan2F(-x * y, 1.0f); } } @@ -334,23 +334,23 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { s16 xRotationTarget; s16 rotationScale; GlobalContext* globalCtx = globalCtx2; - EnClearTag* this = (EnClearTag*)thisx; + EnClearTag* pthis = (EnClearTag*)thisx; Player* player = GET_PLAYER(globalCtx); - this->frameCounter++; + pthis->frameCounter++; - if (this->drawMode != CLEAR_TAG_DRAW_MODE_EFFECT) { + if (pthis->drawMode != CLEAR_TAG_DRAW_MODE_EFFECT) { for (i = 0; i < 3; i++) { - if (this->timers[i] != 0) { - this->timers[i]--; + if (pthis->timers[i] != 0) { + pthis->timers[i]--; } } - if (this->cutsceneTimer != 0) { - this->cutsceneTimer--; + if (pthis->cutsceneTimer != 0) { + pthis->cutsceneTimer--; } - switch (this->state) { + switch (pthis->state) { case CLEAR_TAG_STATE_DEMO: case CLEAR_TAG_STATE_TARGET_LOCKED: case CLEAR_TAG_STATE_FLYING: { @@ -364,101 +364,101 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { s32 pad; // Check if the Arwing should crash. - if (this->collider.base.acFlags & AC_HIT) { + if (pthis->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - this->crashingTimer = 20; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 5); - this->acceleration.x = Rand_CenteredFloat(15.0f); - this->acceleration.y = Rand_CenteredFloat(15.0f); - this->acceleration.z = Rand_CenteredFloat(15.0f); + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->crashingTimer = 20; + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 5); + pthis->acceleration.x = Rand_CenteredFloat(15.0f); + pthis->acceleration.y = Rand_CenteredFloat(15.0f); + pthis->acceleration.z = Rand_CenteredFloat(15.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_THUNDER_GND); - this->actor.colChkInfo.health--; - if ((s8)this->actor.colChkInfo.health <= 0) { - this->state = CLEAR_TAG_STATE_CRASHING; - this->actor.velocity.y = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_THUNDER_GND); + pthis->actor.colChkInfo.health--; + if ((s8)pthis->actor.colChkInfo.health <= 0) { + pthis->state = CLEAR_TAG_STATE_CRASHING; + pthis->actor.velocity.y = 0.0f; goto state_crashing; } } - Actor_SetScale(&this->actor, 0.2f); - this->actor.speedXZ = 7.0f; + Actor_SetScale(&pthis->actor, 0.2f); + pthis->actor.speedXZ = 7.0f; - if (this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] == 0) { - if (this->timers[CLEAR_TAG_TIMER_ARWING_ENTER_LOCKED_ON] == 0) { - this->state = CLEAR_TAG_STATE_TARGET_LOCKED; - this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = 300; + if (pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] == 0) { + if (pthis->timers[CLEAR_TAG_TIMER_ARWING_ENTER_LOCKED_ON] == 0) { + pthis->state = CLEAR_TAG_STATE_TARGET_LOCKED; + pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = 300; } else { - this->state = CLEAR_TAG_STATE_FLYING; - this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = (s16)Rand_ZeroFloat(50.0f) + 20; + pthis->state = CLEAR_TAG_STATE_FLYING; + pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = (s16)Rand_ZeroFloat(50.0f) + 20; - if (this->actor.params == CLEAR_TAG_ARWING) { + if (pthis->actor.params == CLEAR_TAG_ARWING) { // Set the Arwing to fly in a circle around the player. f32 targetCircleX = Math_SinS(player->actor.shape.rot.y) * 400.0f; f32 targetCircleZ = Math_CosS(player->actor.shape.rot.y) * 400.0f; - this->targetPosition.x = + pthis->targetPosition.x = Rand_CenteredFloat(700.0f) + (player->actor.world.pos.x + targetCircleX); - this->targetPosition.y = Rand_ZeroFloat(200.0f) + player->actor.world.pos.y + 150.0f; - this->targetPosition.z = + pthis->targetPosition.y = Rand_ZeroFloat(200.0f) + player->actor.world.pos.y + 150.0f; + pthis->targetPosition.z = Rand_CenteredFloat(700.0f) + (player->actor.world.pos.z + targetCircleZ); } else { // Set the Arwing to fly to a random position. - this->targetPosition.x = Rand_CenteredFloat(700.0f); - this->targetPosition.y = Rand_ZeroFloat(200.0f) + 150.0f; - this->targetPosition.z = Rand_CenteredFloat(700.0f); + pthis->targetPosition.x = Rand_CenteredFloat(700.0f); + pthis->targetPosition.y = Rand_ZeroFloat(200.0f) + 150.0f; + pthis->targetPosition.z = Rand_CenteredFloat(700.0f); } } - this->targetDirection.x = this->targetDirection.y = this->targetDirection.z = 0.0f; + pthis->targetDirection.x = pthis->targetDirection.y = pthis->targetDirection.z = 0.0f; } rotationScale = 10; xRotationTarget = 0x800; loseTargetLockDistance = 100.0f; - if (this->state == CLEAR_TAG_STATE_TARGET_LOCKED) { + if (pthis->state == CLEAR_TAG_STATE_TARGET_LOCKED) { // Set the Arwing to fly towards the player. - this->targetPosition.x = player->actor.world.pos.x; - this->targetPosition.y = player->actor.world.pos.y + 40.0f; - this->targetPosition.z = player->actor.world.pos.z; + pthis->targetPosition.x = player->actor.world.pos.x; + pthis->targetPosition.y = player->actor.world.pos.y + 40.0f; + pthis->targetPosition.z = player->actor.world.pos.z; rotationScale = 7; xRotationTarget = 0x1000; loseTargetLockDistance = 150.0f; - } else if (this->state == CLEAR_TAG_STATE_DEMO) { + } else if (pthis->state == CLEAR_TAG_STATE_DEMO) { // Move the Arwing for the intro cutscene. // Do a Barrel Roll! - this->roll += 0.5f; - if (this->roll > M_PI * 2) { - this->roll -= M_PI * 2; + pthis->roll += 0.5f; + if (pthis->roll > M_PI * 2) { + pthis->roll -= M_PI * 2; } // Set the Arwing to fly to a hardcoded position. - this->targetPosition.x = 0.0f; - this->targetPosition.y = 300.0f; - this->targetPosition.z = 0.0f; + pthis->targetPosition.x = 0.0f; + pthis->targetPosition.y = 300.0f; + pthis->targetPosition.z = 0.0f; loseTargetLockDistance = 100.0f; } // If the Arwing is not in cutscene state, smoothly update the roll to zero. // This will reset the Arwing to be right side up after the cutscene is done. // The cutscene will set the Arwing to do a barrel roll and doesn't end on right side up. - if (this->state != CLEAR_TAG_STATE_DEMO) { - Math_ApproachZeroF(&this->roll, 0.1f, 0.2f); + if (pthis->state != CLEAR_TAG_STATE_DEMO) { + Math_ApproachZeroF(&pthis->roll, 0.1f, 0.2f); } // Calculate a vector towards the targetted position. - vectorToTargetX = this->targetPosition.x - this->actor.world.pos.x; - vectorToTargetY = this->targetPosition.y - this->actor.world.pos.y; - vectorToTargetZ = this->targetPosition.z - this->actor.world.pos.z; + vectorToTargetX = pthis->targetPosition.x - pthis->actor.world.pos.x; + vectorToTargetY = pthis->targetPosition.y - pthis->actor.world.pos.y; + vectorToTargetZ = pthis->targetPosition.z - pthis->actor.world.pos.z; // If the Arwing is within a certain distance to the target position, it will be updated to flymode if (sqrtf(SQ(vectorToTargetX) + SQ(vectorToTargetY) + SQ(vectorToTargetZ)) < loseTargetLockDistance) { - this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = 0; - if (this->state == CLEAR_TAG_STATE_TARGET_LOCKED) { - this->timers[CLEAR_TAG_TIMER_ARWING_ENTER_LOCKED_ON] = (s16)Rand_ZeroFloat(100.0f) + 100; + pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_STATE] = 0; + if (pthis->state == CLEAR_TAG_STATE_TARGET_LOCKED) { + pthis->timers[CLEAR_TAG_TIMER_ARWING_ENTER_LOCKED_ON] = (s16)Rand_ZeroFloat(100.0f) + 100; } - this->state = CLEAR_TAG_STATE_FLYING; + pthis->state = CLEAR_TAG_STATE_FLYING; } // Calculate the direction for the Arwing to fly and the rotation for the Arwing @@ -466,175 +466,175 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { worldRotationTargetY = Math_FAtan2F(vectorToTargetX, vectorToTargetZ) * (0x8000 / M_PI); worldRotationTargetX = Math_FAtan2F(vectorToTargetY, sqrtf(SQ(vectorToTargetX) + SQ(vectorToTargetZ))) * (0x8000 / M_PI); - if ((worldRotationTargetX < 0) && (this->actor.world.pos.y < this->actor.floorHeight + 20.0f)) { + if ((worldRotationTargetX < 0) && (pthis->actor.world.pos.y < pthis->actor.floorHeight + 20.0f)) { worldRotationTargetX = 0; } - Math_ApproachS(&this->actor.world.rot.x, worldRotationTargetX, rotationScale, this->targetDirection.x); - worldRotationTargetZ = Math_SmoothStepToS(&this->actor.world.rot.y, worldRotationTargetY, rotationScale, - this->targetDirection.y, 0); - Math_ApproachF(&this->targetDirection.x, xRotationTarget, 1.0f, 0x100); - this->targetDirection.y = this->targetDirection.x; + Math_ApproachS(&pthis->actor.world.rot.x, worldRotationTargetX, rotationScale, pthis->targetDirection.x); + worldRotationTargetZ = Math_SmoothStepToS(&pthis->actor.world.rot.y, worldRotationTargetY, rotationScale, + pthis->targetDirection.y, 0); + Math_ApproachF(&pthis->targetDirection.x, xRotationTarget, 1.0f, 0x100); + pthis->targetDirection.y = pthis->targetDirection.x; if (ABS(worldRotationTargetZ) < 0x1000) { - Math_ApproachS(&this->actor.world.rot.z, 0, 15, this->targetDirection.z); - Math_ApproachF(&this->targetDirection.z, 0x500, 1.0f, 0x100); + Math_ApproachS(&pthis->actor.world.rot.z, 0, 15, pthis->targetDirection.z); + Math_ApproachF(&pthis->targetDirection.z, 0x500, 1.0f, 0x100); // Check if the Arwing should fire its laser. - if ((this->frameCounter % 4) == 0 && (Rand_ZeroOne() < 0.75f) && - (this->state == CLEAR_TAG_STATE_TARGET_LOCKED)) { - this->shouldShootLaser = true; + if ((pthis->frameCounter % 4) == 0 && (Rand_ZeroOne() < 0.75f) && + (pthis->state == CLEAR_TAG_STATE_TARGET_LOCKED)) { + pthis->shouldShootLaser = true; } } else { worldRotationTargetZ = worldRotationTargetZ > 0 ? -0x2500 : 0x2500; - Math_ApproachS(&this->actor.world.rot.z, worldRotationTargetZ, rotationScale, - this->targetDirection.z); - Math_ApproachF(&this->targetDirection.z, 0x1000, 1.0f, 0x200); + Math_ApproachS(&pthis->actor.world.rot.z, worldRotationTargetZ, rotationScale, + pthis->targetDirection.z); + Math_ApproachF(&pthis->targetDirection.z, 0x1000, 1.0f, 0x200); } - this->actor.shape.rot = this->actor.world.rot; - this->actor.shape.rot.x = -this->actor.shape.rot.x; + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->actor.shape.rot.x = -pthis->actor.shape.rot.x; // Update the Arwing's velocity. - func_8002D908(&this->actor); - this->actor.velocity.x += this->acceleration.x; - this->actor.velocity.y += this->acceleration.y; - this->actor.velocity.z += this->acceleration.z; - Math_ApproachZeroF(&this->acceleration.x, 1.0f, 1.0f); - Math_ApproachZeroF(&this->acceleration.y, 1.0f, 1.0f); - Math_ApproachZeroF(&this->acceleration.z, 1.0f, 1.0f); + func_8002D908(&pthis->actor); + pthis->actor.velocity.x += pthis->acceleration.x; + pthis->actor.velocity.y += pthis->acceleration.y; + pthis->actor.velocity.z += pthis->acceleration.z; + Math_ApproachZeroF(&pthis->acceleration.x, 1.0f, 1.0f); + Math_ApproachZeroF(&pthis->acceleration.y, 1.0f, 1.0f); + Math_ApproachZeroF(&pthis->acceleration.z, 1.0f, 1.0f); // Fire the Arwing laser. - if (this->shouldShootLaser) { - this->shouldShootLaser = false; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, CLEAR_TAG_STATE_LASER); + if (pthis->shouldShootLaser) { + pthis->shouldShootLaser = false; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, pthis->actor.world.rot.x, + pthis->actor.world.rot.y, pthis->actor.world.rot.z, CLEAR_TAG_STATE_LASER); } } case CLEAR_TAG_STATE_CRASHING: state_crashing: - if (this->crashingTimer != 0) { - this->crashingTimer--; + if (pthis->crashingTimer != 0) { + pthis->crashingTimer--; } - func_8002D7EC(&this->actor); + func_8002D7EC(&pthis->actor); - Actor_SetFocus(&this->actor, 0.0f); + Actor_SetFocus(&pthis->actor, 0.0f); // Update Arwing collider to better match a ground collision. - this->collider.dim.radius = 20; - this->collider.dim.height = 15; - this->collider.dim.yShift = -5; - Collider_UpdateCylinder(&this->actor, &this->collider); + pthis->collider.dim.radius = 20; + pthis->collider.dim.height = 15; + pthis->collider.dim.yShift = -5; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - if (this->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_BG_INFO] == 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 30.0f, 100.0f, 5); - EnClearTag_CalculateFloorTangent(this); + if (pthis->timers[CLEAR_TAG_TIMER_ARWING_UPDATE_BG_INFO] == 0) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 30.0f, 100.0f, 5); + EnClearTag_CalculateFloorTangent(pthis); } - if (this->state == CLEAR_TAG_STATE_CRASHING) { + if (pthis->state == CLEAR_TAG_STATE_CRASHING) { // Create fire effects while the Arwing crashes. - EnClearTag_CreateFireEffect(globalCtx, &this->actor.world.pos, 1.0f); + EnClearTag_CreateFireEffect(globalCtx, &pthis->actor.world.pos, 1.0f); // Causes the Arwing to roll around seemingly randomly while crashing. - this->roll -= 0.5f; - this->actor.velocity.y -= 0.2f; - this->actor.shape.rot.x += 0x10; + pthis->roll -= 0.5f; + pthis->actor.velocity.y -= 0.2f; + pthis->actor.shape.rot.x += 0x10; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_BREATH - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_BREATH - SFX_FLAG); // Check if the Arwing has hit the ground. - if (this->actor.bgCheckFlags & 9) { - this->shouldExplode = true; + if (pthis->actor.bgCheckFlags & 9) { + pthis->shouldExplode = true; - if (this->drawMode != CLEAR_TAG_DRAW_MODE_ARWING) { - this->drawMode = CLEAR_TAG_DRAW_MODE_EFFECT; - this->deathTimer = 70; - this->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->drawMode != CLEAR_TAG_DRAW_MODE_ARWING) { + pthis->drawMode = CLEAR_TAG_DRAW_MODE_EFFECT; + pthis->deathTimer = 70; + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } } break; case CLEAR_TAG_STATE_LASER: - func_8002D7EC(&this->actor); + func_8002D7EC(&pthis->actor); // Check if the laser has hit a target. - if (this->collider.base.atFlags & AT_HIT) { + if (pthis->collider.base.atFlags & AT_HIT) { hasAtHit = true; } // Set laser collider properties. - this->collider.dim.radius = 23; - this->collider.dim.height = 25; - this->collider.dim.yShift = -10; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 80.0f, 100.0f, 5); + pthis->collider.dim.radius = 23; + pthis->collider.dim.height = 25; + pthis->collider.dim.yShift = -10; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 80.0f, 100.0f, 5); // Check if the laser has hit a target, timed out, or hit the ground. - if (this->actor.bgCheckFlags & 9 || hasAtHit || this->timers[CLEAR_TAG_TIMER_LASER_DEATH] == 0) { + if (pthis->actor.bgCheckFlags & 9 || hasAtHit || pthis->timers[CLEAR_TAG_TIMER_LASER_DEATH] == 0) { // Kill the laser. - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); // Player laser sound effect if the laser did not time out. - if (this->timers[CLEAR_TAG_TIMER_LASER_DEATH] != 0) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_FANTOM_THUNDER_GND); + if (pthis->timers[CLEAR_TAG_TIMER_LASER_DEATH] != 0) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EN_FANTOM_THUNDER_GND); } } break; } - if (this->state < CLEAR_TAG_STATE_LASER) { + if (pthis->state < CLEAR_TAG_STATE_LASER) { // Play the Arwing cutscene. - osSyncPrintf("DEMO_MODE %d\n", this->cutsceneMode); - osSyncPrintf("CAMERA_NO %d\n", this->cameraId); + osSyncPrintf("DEMO_MODE %d\n", pthis->cutsceneMode); + osSyncPrintf("CAMERA_NO %d\n", pthis->cameraId); - if (this->cutsceneMode != CLEAR_TAG_CUTSCENE_MODE_NONE) { + if (pthis->cutsceneMode != CLEAR_TAG_CUTSCENE_MODE_NONE) { f32 cutsceneCameraCircleX; f32 cutsceneCameraCircleZ; s16 cutsceneTimer; Vec3f cutsceneCameraAtTarget; Vec3f cutsceneCameraEyeTarget; - switch (this->cutsceneMode) { + switch (pthis->cutsceneMode) { case CLEAR_TAG_CUTSCENE_MODE_SETUP: // Initializes Arwing cutscene camera data. - this->cutsceneMode = CLEAR_TAG_CUTSCENE_MODE_PLAY; + pthis->cutsceneMode = CLEAR_TAG_CUTSCENE_MODE_PLAY; func_80064520(globalCtx, &globalCtx->csCtx); - this->cameraId = Gameplay_CreateSubCamera(globalCtx); + pthis->cameraId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->cameraId, CAM_STAT_ACTIVE); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cameraId, CAM_STAT_ACTIVE); case CLEAR_TAG_CUTSCENE_MODE_PLAY: // Update the Arwing cutscene camera to spin around in a circle. - cutsceneTimer = this->frameCounter * 128; + cutsceneTimer = pthis->frameCounter * 128; cutsceneCameraCircleX = Math_SinS(cutsceneTimer) * 200.0f; cutsceneCameraCircleZ = Math_CosS(cutsceneTimer) * 200.0f; - cutsceneCameraAtTarget.x = this->actor.world.pos.x + cutsceneCameraCircleX; + cutsceneCameraAtTarget.x = pthis->actor.world.pos.x + cutsceneCameraCircleX; cutsceneCameraAtTarget.y = 200.0f; - cutsceneCameraAtTarget.z = this->actor.world.pos.z + cutsceneCameraCircleZ; - cutsceneCameraEyeTarget = this->actor.world.pos; + cutsceneCameraAtTarget.z = pthis->actor.world.pos.z + cutsceneCameraCircleZ; + cutsceneCameraEyeTarget = pthis->actor.world.pos; break; } // Make the Arwing cutscene camera approach the target. - if (this->cameraId != SUBCAM_FREE) { - Math_ApproachF(&this->cutsceneCameraAt.x, cutsceneCameraAtTarget.x, 0.1f, 500.0f); - Math_ApproachF(&this->cutsceneCameraAt.y, cutsceneCameraAtTarget.y, 0.1f, 500.0f); - Math_ApproachF(&this->cutsceneCameraAt.z, cutsceneCameraAtTarget.z, 0.1f, 500.0f); - Math_ApproachF(&this->cutsceneCameraEye.x, cutsceneCameraEyeTarget.x, 0.2f, 500.0f); - Math_ApproachF(&this->cutsceneCameraEye.y, cutsceneCameraEyeTarget.y, 0.2f, 500.0f); - Math_ApproachF(&this->cutsceneCameraEye.z, cutsceneCameraEyeTarget.z, 0.2f, 500.0f); - Gameplay_CameraSetAtEye(globalCtx, this->cameraId, &this->cutsceneCameraEye, - &this->cutsceneCameraAt); + if (pthis->cameraId != SUBCAM_FREE) { + Math_ApproachF(&pthis->cutsceneCameraAt.x, cutsceneCameraAtTarget.x, 0.1f, 500.0f); + Math_ApproachF(&pthis->cutsceneCameraAt.y, cutsceneCameraAtTarget.y, 0.1f, 500.0f); + Math_ApproachF(&pthis->cutsceneCameraAt.z, cutsceneCameraAtTarget.z, 0.1f, 500.0f); + Math_ApproachF(&pthis->cutsceneCameraEye.x, cutsceneCameraEyeTarget.x, 0.2f, 500.0f); + Math_ApproachF(&pthis->cutsceneCameraEye.y, cutsceneCameraEyeTarget.y, 0.2f, 500.0f); + Math_ApproachF(&pthis->cutsceneCameraEye.z, cutsceneCameraEyeTarget.z, 0.2f, 500.0f); + Gameplay_CameraSetAtEye(globalCtx, pthis->cameraId, &pthis->cutsceneCameraEye, + &pthis->cutsceneCameraAt); } // Cutscene has finished. - if (this->cutsceneTimer == 1) { - func_800C08AC(globalCtx, this->cameraId, 0); - this->cutsceneMode = this->cameraId = SUBCAM_FREE; + if (pthis->cutsceneTimer == 1) { + func_800C08AC(globalCtx, pthis->cameraId, 0); + pthis->cutsceneMode = pthis->cameraId = SUBCAM_FREE; func_80064534(globalCtx, &globalCtx->csCtx); } } @@ -642,25 +642,25 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { } // Explode the Arwing - if (this->shouldExplode) { + if (pthis->shouldExplode) { Vec3f crashEffectLocation; Vec3f crashEffectVelocity; Vec3f debrisEffectAcceleration; - this->shouldExplode = false; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_BOMB_EXPLOSION); + pthis->shouldExplode = false; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_IT_BOMB_EXPLOSION); // Spawn flash effect. - crashEffectLocation.x = this->actor.world.pos.x; - crashEffectLocation.y = (this->actor.world.pos.y + 40.0f) - 30.0f; - crashEffectLocation.z = this->actor.world.pos.z; - EnClearTag_CreateFlashEffect(globalCtx, &crashEffectLocation, 6.0f, this->actor.floorHeight, - &this->floorTangent); + crashEffectLocation.x = pthis->actor.world.pos.x; + crashEffectLocation.y = (pthis->actor.world.pos.y + 40.0f) - 30.0f; + crashEffectLocation.z = pthis->actor.world.pos.z; + EnClearTag_CreateFlashEffect(globalCtx, &crashEffectLocation, 6.0f, pthis->actor.floorHeight, + &pthis->floorTangent); // Spawn smoke effect. - crashEffectLocation.y = (this->actor.world.pos.y + 30.0f) - 50.0f; + crashEffectLocation.y = (pthis->actor.world.pos.y + 30.0f) - 50.0f; EnClearTag_CreateSmokeEffect(globalCtx, &crashEffectLocation, 3.0f); - crashEffectLocation.y = this->actor.world.pos.y; + crashEffectLocation.y = pthis->actor.world.pos.y; // Spawn debris effects. for (i = 0; i < 15; i++) { @@ -676,14 +676,14 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { EnClearTag_CreateDebrisEffect(globalCtx, &crashEffectLocation, &crashEffectVelocity, &debrisEffectAcceleration, Rand_ZeroFloat(0.15f) + 0.075f, - this->actor.floorHeight); + pthis->actor.floorHeight); } } - if (this->drawMode != CLEAR_TAG_DRAW_MODE_ARWING) { + if (pthis->drawMode != CLEAR_TAG_DRAW_MODE_ARWING) { // Check if the Arwing should be removed. - if ((this->drawMode == CLEAR_TAG_DRAW_MODE_EFFECT) && (DECR(this->deathTimer) == 0)) { - Actor_Kill(&this->actor); + if ((pthis->drawMode == CLEAR_TAG_DRAW_MODE_EFFECT) && (DECR(pthis->deathTimer) == 0)) { + Actor_Kill(&pthis->actor); } EnClearTag_UpdateEffects(globalCtx); @@ -697,13 +697,13 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { */ void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnClearTag* this = (EnClearTag*)thisx; + EnClearTag* pthis = (EnClearTag*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_clear_tag.c", 983); - if (this->drawMode != CLEAR_TAG_DRAW_MODE_EFFECT) { + if (pthis->drawMode != CLEAR_TAG_DRAW_MODE_EFFECT) { func_80093D84(globalCtx->state.gfxCtx); - if (this->state >= CLEAR_TAG_STATE_LASER) { + if (pthis->state >= CLEAR_TAG_STATE_LASER) { // Draw Arwing lasers. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 255, 0, 255); @@ -720,17 +720,17 @@ void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx) { // Draw the Arwing itself. func_80093D18(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - if (this->crashingTimer != 0) { + if (pthis->crashingTimer != 0) { f32 xRotation; f32 yRotation; - f32 scaledCrashingTimer = this->crashingTimer * 0.05f; + f32 scaledCrashingTimer = pthis->crashingTimer * 0.05f; - xRotation = Math_SinS(this->frameCounter * 0x3000) * scaledCrashingTimer; - yRotation = Math_SinS(this->frameCounter * 0x3700) * scaledCrashingTimer; + xRotation = Math_SinS(pthis->frameCounter * 0x3000) * scaledCrashingTimer; + yRotation = Math_SinS(pthis->frameCounter * 0x3700) * scaledCrashingTimer; Matrix_RotateX(xRotation, MTXMODE_APPLY); Matrix_RotateY(yRotation, MTXMODE_APPLY); } - Matrix_RotateZ(this->roll, MTXMODE_APPLY); + Matrix_RotateZ(pthis->roll, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_clear_tag.c", 1030), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gArwingDL); @@ -739,7 +739,7 @@ void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Translate(0.0f, 0.0f, -60.0f, MTXMODE_APPLY); func_800D1FD4(&globalCtx->billboardMtxF); Matrix_Scale(2.5f, 1.3f, 0.0f, MTXMODE_APPLY); - if ((this->frameCounter % 2) != 0) { + if ((pthis->frameCounter % 2) != 0) { Matrix_Scale(1.15f, 1.15f, 1.15f, MTXMODE_APPLY); } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, 155); @@ -751,31 +751,31 @@ void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx) { // Draw the Arwing shadow. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 130); - Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateX(this->floorTangent.x, MTXMODE_APPLY); - Matrix_RotateZ(this->floorTangent.z, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x + 0.35f, 0.0f, this->actor.scale.z + 0.35f, MTXMODE_APPLY); - Matrix_RotateY((this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateX((this->actor.shape.rot.x / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateZ((this->actor.shape.rot.z / 32768.0f) * M_PI, MTXMODE_APPLY); - if (this->crashingTimer != 0) { + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.floorHeight, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateX(pthis->floorTangent.x, MTXMODE_APPLY); + Matrix_RotateZ(pthis->floorTangent.z, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x + 0.35f, 0.0f, pthis->actor.scale.z + 0.35f, MTXMODE_APPLY); + Matrix_RotateY((pthis->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateX((pthis->actor.shape.rot.x / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateZ((pthis->actor.shape.rot.z / 32768.0f) * M_PI, MTXMODE_APPLY); + if (pthis->crashingTimer != 0) { f32 xRotation; f32 yRotation; - f32 scaledCrashingTimer = this->crashingTimer * 0.05f; + f32 scaledCrashingTimer = pthis->crashingTimer * 0.05f; - xRotation = Math_SinS(this->frameCounter * 0x3000) * scaledCrashingTimer; - yRotation = Math_SinS(this->frameCounter * 0x3700) * scaledCrashingTimer; + xRotation = Math_SinS(pthis->frameCounter * 0x3000) * scaledCrashingTimer; + yRotation = Math_SinS(pthis->frameCounter * 0x3700) * scaledCrashingTimer; Matrix_RotateX(xRotation, MTXMODE_APPLY); Matrix_RotateY(yRotation, MTXMODE_APPLY); } - Matrix_RotateZ(this->roll, MTXMODE_APPLY); + Matrix_RotateZ(pthis->roll, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_clear_tag.c", 1104), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gArwingShadowDL); } } - if (this->drawMode != CLEAR_TAG_DRAW_MODE_ARWING) { + if (pthis->drawMode != CLEAR_TAG_DRAW_MODE_ARWING) { EnClearTag_DrawEffects(globalCtx); } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c deleted file mode 100644 index 34e421210..000000000 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ /dev/null @@ -1,404 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_COW_Z_EN_COW_C -#include "actor_common.h" -/* - * File: z_en_cow.c - * Overlay: ovl_En_Cow - * Description: Cow - */ - -#include "z_en_cow.h" -#include "objects/object_cow/object_cow.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnCow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnCow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809DFE98(Actor* thisx, GlobalContext* globalCtx); -void func_809E0070(Actor* thisx, GlobalContext* globalCtx); - -void func_809DF494(EnCow* this, GlobalContext* globalCtx); -void func_809DF6BC(EnCow* this, GlobalContext* globalCtx); -void func_809DF778(EnCow* this, GlobalContext* globalCtx); -void func_809DF7D8(EnCow* this, GlobalContext* globalCtx); -void func_809DF870(EnCow* this, GlobalContext* globalCtx); -void func_809DF8FC(EnCow* this, GlobalContext* globalCtx); -void func_809DF96C(EnCow* this, GlobalContext* globalCtx); -void func_809DFA84(EnCow* this, GlobalContext* globalCtx); - -const ActorInit En_Cow_InitVars = { - ACTOR_EN_COW, - ACTORCAT_NPC, - FLAGS, - OBJECT_COW, - sizeof(EnCow), - (ActorFunc)EnCow_Init, - (ActorFunc)EnCow_Destroy, - (ActorFunc)EnCow_Update, - (ActorFunc)EnCow_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -static Vec3f D_809E010C = { 0.0f, -1300.0f, 1100.0f }; - -void func_809DEE00(Vec3f* vec, s16 rotY) { - f32 xCalc; - f32 rotCalcTemp; - - rotCalcTemp = Math_CosS(rotY); - xCalc = (Math_SinS(rotY) * vec->z) + (rotCalcTemp * vec->x); - rotCalcTemp = Math_SinS(rotY); - vec->z = (Math_CosS(rotY) * vec->z) + (-rotCalcTemp * vec->x); - vec->x = xCalc; -} - -void func_809DEE9C(EnCow* this) { - Vec3f vec; - - vec.y = 0.0f; - vec.x = 0.0f; - vec.z = 30.0f; - func_809DEE00(&vec, this->actor.shape.rot.y); - this->colliders[0].dim.pos.x = this->actor.world.pos.x + vec.x; - this->colliders[0].dim.pos.y = this->actor.world.pos.y; - this->colliders[0].dim.pos.z = this->actor.world.pos.z + vec.z; - - vec.x = 0.0f; - vec.y = 0.0f; - vec.z = -20.0f; - func_809DEE00(&vec, this->actor.shape.rot.y); - this->colliders[1].dim.pos.x = this->actor.world.pos.x + vec.x; - this->colliders[1].dim.pos.y = this->actor.world.pos.y; - this->colliders[1].dim.pos.z = this->actor.world.pos.z + vec.z; -} - -void func_809DEF94(EnCow* this) { - Vec3f vec; - - VEC_SET(vec, 0.0f, 57.0f, -36.0f); - - func_809DEE00(&vec, this->actor.shape.rot.y); - this->actor.world.pos.x += vec.x; - this->actor.world.pos.y += vec.y; - this->actor.world.pos.z += vec.z; -} - -void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { - EnCow* this = (EnCow*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 72.0f); - switch (this->actor.params) { - case 0: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, 6); - Animation_PlayLoop(&this->skelAnime, &gCowBodyChewAnim); - Collider_InitCylinder(globalCtx, &this->colliders[0]); - Collider_SetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); - Collider_InitCylinder(globalCtx, &this->colliders[1]); - Collider_SetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); - func_809DEE9C(this); - this->actionFunc = func_809DF96C; - if (globalCtx->sceneNum == SCENE_LINK_HOME) { - if (!LINK_IS_ADULT) { - Actor_Kill(&this->actor); - return; - } - if (!(gSaveContext.eventChkInf[1] & 0x4000)) { - Actor_Kill(&this->actor); - return; - } - } - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_COW, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 1); - this->unk_278 = Rand_ZeroFloat(1000.0f) + 40.0f; - this->unk_27A = 0; - this->actor.targetMode = 6; - DREG(53) = 0; - break; - case 1: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, 6); - Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); - this->actor.update = func_809DFE98; - this->actor.draw = func_809E0070; - this->actionFunc = func_809DFA84; - func_809DEF94(this); - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_278 = ((u32)(Rand_ZeroFloat(1000.0f)) & 0xFFFF) + 40.0f; - break; - } - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - this->unk_276 = 0; -} - -void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnCow* this = (EnCow*)thisx; - - if (this->actor.params == 0) { - Collider_DestroyCylinder(globalCtx, &this->colliders[0]); - Collider_DestroyCylinder(globalCtx, &this->colliders[1]); - } -} - -void func_809DF494(EnCow* this, GlobalContext* globalCtx) { - if (this->unk_278 > 0) { - this->unk_278 -= 1; - } else { - this->unk_278 = Rand_ZeroFloat(500.0f) + 40.0f; - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); - } - - if ((this->actor.xzDistToPlayer < 150.0f) && (!(this->unk_276 & 2))) { - this->unk_276 |= 2; - if (this->skelAnime.animation == &gCowBodyChewAnim) { - this->unk_278 = 0; - } - } - - this->unk_27A += 1; - if (this->unk_27A >= 0x31) { - this->unk_27A = 0; - } - - // (1.0f / 100.0f) instead of 0.01f below is necessary so 0.01f doesn't get reused mistakenly - if (this->unk_27A < 0x20) { - this->actor.scale.x = ((Math_SinS(this->unk_27A << 0xA) * (1.0f / 100.0f)) + 1.0f) * 0.01f; - } else { - this->actor.scale.x = 0.01f; - } - - if (this->unk_27A >= 0x11) { - this->actor.scale.y = ((Math_SinS((this->unk_27A << 0xA) - 0x4000) * (1.0f / 100.0f)) + 1.0f) * 0.01f; - } else { - this->actor.scale.y = 0.01f; - } -} - -void func_809DF6BC(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - Message_CloseTextbox(globalCtx); - this->actionFunc = func_809DF96C; - } -} - -void func_809DF730(EnCow* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = func_809DF96C; - } -} - -void func_809DF778(EnCow* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_809DF730; - } else { - func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); - } -} - -void func_809DF7D8(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - Message_CloseTextbox(globalCtx); - this->actionFunc = func_809DF778; - func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); - } -} - -void func_809DF870(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - if (Inventory_HasEmptyBottle()) { - Message_ContinueTextbox(globalCtx, 0x2007); - this->actionFunc = func_809DF7D8; - } else { - Message_ContinueTextbox(globalCtx, 0x2013); - this->actionFunc = func_809DF6BC; - } - } -} - -void func_809DF8FC(EnCow* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_809DF870; - } else { - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2CC(&this->actor, globalCtx, 170.0f); - this->actor.textId = 0x2006; - } - func_809DF494(this, globalCtx); -} - -void func_809DF96C(EnCow* this, GlobalContext* globalCtx) { - if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_00) || (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04)) { - if (DREG(53) != 0) { - if (this->unk_276 & 4) { - this->unk_276 &= ~0x4; - DREG(53) = 0; - } else { - if ((this->actor.xzDistToPlayer < 150.0f) && - (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x61A8)) { - DREG(53) = 0; - this->actionFunc = func_809DF8FC; - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2CC(&this->actor, globalCtx, 170.0f); - this->actor.textId = 0x2006; - } else { - this->unk_276 |= 4; - } - } - } else { - this->unk_276 &= ~0x4; - } - } - func_809DF494(this, globalCtx); -} - -void func_809DFA84(EnCow* this, GlobalContext* globalCtx) { - if (this->unk_278 > 0) { - this->unk_278--; - } else { - this->unk_278 = Rand_ZeroFloat(200.0f) + 40.0f; - Animation_Change(&this->skelAnime, &gCowTailIdleAnim, 1.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gCowTailIdleAnim), ANIMMODE_ONCE, 1.0f); - } - - if ((this->actor.xzDistToPlayer < 150.0f) && - (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) >= 0x61A9) && (!(this->unk_276 & 2))) { - this->unk_276 |= 2; - if (this->skelAnime.animation == &gCowTailIdleAnim) { - this->unk_278 = 0; - } - } -} - -void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnCow* this = (EnCow*)thisx; - GlobalContext* globalCtx = globalCtx2; - s16 targetX; - s16 targetY; - Player* player = GET_PLAYER(globalCtx); - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); - Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &gCowBodyChewAnim) { - Audio_PlayActorSound2(thisx, NA_SE_EV_COW_CRY); - Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCowBodyMoveHeadAnim), ANIMMODE_ONCE, 1.0f); - } else { - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowBodyChewAnim), - ANIMMODE_LOOP, 1.0f); - } - } - this->actionFunc(this, globalCtx); - if ((thisx->xzDistToPlayer < 150.0f) && - (ABS(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000)) { - targetX = Math_Vec3f_Pitch(&thisx->focus.pos, &player->actor.focus.pos); - targetY = Math_Vec3f_Yaw(&thisx->focus.pos, &player->actor.focus.pos) - thisx->shape.rot.y; - - if (targetX > 0x1000) { - targetX = 0x1000; - } else if (targetX < -0x1000) { - targetX = -0x1000; - } - - if (targetY > 0x2500) { - targetY = 0x2500; - } else if (targetY < -0x2500) { - targetY = -0x2500; - } - - } else { - targetY = 0; - targetX = 0; - } - Math_SmoothStepToS(&this->someRot.x, targetX, 0xA, 0xC8, 0xA); - Math_SmoothStepToS(&this->someRot.y, targetY, 0xA, 0xC8, 0xA); -} - -void func_809DFE98(Actor* thisx, GlobalContext* globalCtx) { - EnCow* this = (EnCow*)thisx; - s32 pad; - - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &gCowTailIdleAnim) { - Animation_Change(&this->skelAnime, &gCowTailSwishAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCowTailSwishAnim), ANIMMODE_ONCE, 1.0f); - } else { - Animation_Change(&this->skelAnime, &gCowTailIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowTailIdleAnim), - ANIMMODE_LOOP, 1.0f); - } - } - this->actionFunc(this, globalCtx); -} - -s32 EnCow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnCow* this = (EnCow*)thisx; - - if (limbIndex == 2) { - rot->y += this->someRot.y; - rot->x += this->someRot.x; - } - if (limbIndex == 5) { - *dList = NULL; - } - return false; -} - -void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnCow* this = (EnCow*)thisx; - - if (limbIndex == 2) { - Matrix_MultVec3f(&D_809E010C, &this->actor.focus.pos); - } -} - -void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnCow* this = (EnCow*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnCow_OverrideLimbDraw, EnCow_PostLimbDraw, this); -} - -void func_809E0070(Actor* thisx, GlobalContext* globalCtx) { - EnCow* this = (EnCow*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); -} diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.cpp b/src/overlays/actors/ovl_En_Cow/z_en_cow.cpp new file mode 100644 index 000000000..95ead1156 --- /dev/null +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.cpp @@ -0,0 +1,404 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_COW_Z_EN_COW_C +#include "actor_common.h" +/* + * File: z_en_cow.c + * Overlay: ovl_En_Cow + * Description: Cow + */ + +#include "z_en_cow.h" +#include "objects/object_cow/object_cow.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnCow_Init(Actor* thisx, GlobalContext* globalCtx); +void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnCow_Update(Actor* thisx, GlobalContext* globalCtx); +void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809DFE98(Actor* thisx, GlobalContext* globalCtx); +void func_809E0070(Actor* thisx, GlobalContext* globalCtx); + +void func_809DF494(EnCow* pthis, GlobalContext* globalCtx); +void func_809DF6BC(EnCow* pthis, GlobalContext* globalCtx); +void func_809DF778(EnCow* pthis, GlobalContext* globalCtx); +void func_809DF7D8(EnCow* pthis, GlobalContext* globalCtx); +void func_809DF870(EnCow* pthis, GlobalContext* globalCtx); +void func_809DF8FC(EnCow* pthis, GlobalContext* globalCtx); +void func_809DF96C(EnCow* pthis, GlobalContext* globalCtx); +void func_809DFA84(EnCow* pthis, GlobalContext* globalCtx); + +ActorInit En_Cow_InitVars = { + ACTOR_EN_COW, + ACTORCAT_NPC, + FLAGS, + OBJECT_COW, + sizeof(EnCow), + (ActorFunc)EnCow_Init, + (ActorFunc)EnCow_Destroy, + (ActorFunc)EnCow_Update, + (ActorFunc)EnCow_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +static Vec3f D_809E010C = { 0.0f, -1300.0f, 1100.0f }; + +void func_809DEE00(Vec3f* vec, s16 rotY) { + f32 xCalc; + f32 rotCalcTemp; + + rotCalcTemp = Math_CosS(rotY); + xCalc = (Math_SinS(rotY) * vec->z) + (rotCalcTemp * vec->x); + rotCalcTemp = Math_SinS(rotY); + vec->z = (Math_CosS(rotY) * vec->z) + (-rotCalcTemp * vec->x); + vec->x = xCalc; +} + +void func_809DEE9C(EnCow* pthis) { + Vec3f vec; + + vec.y = 0.0f; + vec.x = 0.0f; + vec.z = 30.0f; + func_809DEE00(&vec, pthis->actor.shape.rot.y); + pthis->colliders[0].dim.pos.x = pthis->actor.world.pos.x + vec.x; + pthis->colliders[0].dim.pos.y = pthis->actor.world.pos.y; + pthis->colliders[0].dim.pos.z = pthis->actor.world.pos.z + vec.z; + + vec.x = 0.0f; + vec.y = 0.0f; + vec.z = -20.0f; + func_809DEE00(&vec, pthis->actor.shape.rot.y); + pthis->colliders[1].dim.pos.x = pthis->actor.world.pos.x + vec.x; + pthis->colliders[1].dim.pos.y = pthis->actor.world.pos.y; + pthis->colliders[1].dim.pos.z = pthis->actor.world.pos.z + vec.z; +} + +void func_809DEF94(EnCow* pthis) { + Vec3f vec; + + VEC_SET(vec, 0.0f, 57.0f, -36.0f); + + func_809DEE00(&vec, pthis->actor.shape.rot.y); + pthis->actor.world.pos.x += vec.x; + pthis->actor.world.pos.y += vec.y; + pthis->actor.world.pos.z += vec.z; +} + +void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnCow* pthis = (EnCow*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 72.0f); + switch (pthis->actor.params) { + case 0: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCowBodySkel, NULL, pthis->jointTable, pthis->morphTable, 6); + Animation_PlayLoop(&pthis->skelAnime, &gCowBodyChewAnim); + Collider_InitCylinder(globalCtx, &pthis->colliders[0]); + Collider_SetCylinder(globalCtx, &pthis->colliders[0], &pthis->actor, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->colliders[1]); + Collider_SetCylinder(globalCtx, &pthis->colliders[1], &pthis->actor, &sCylinderInit); + func_809DEE9C(pthis); + pthis->actionFunc = func_809DF96C; + if (globalCtx->sceneNum == SCENE_LINK_HOME) { + if (!LINK_IS_ADULT) { + Actor_Kill(&pthis->actor); + return; + } + if (!(gSaveContext.eventChkInf[1] & 0x4000)) { + Actor_Kill(&pthis->actor); + return; + } + } + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_COW, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, pthis->actor.shape.rot.y, 0, 1); + pthis->unk_278 = Rand_ZeroFloat(1000.0f) + 40.0f; + pthis->unk_27A = 0; + pthis->actor.targetMode = 6; + DREG(53) = 0; + break; + case 1: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCowTailSkel, NULL, pthis->jointTable, pthis->morphTable, 6); + Animation_PlayLoop(&pthis->skelAnime, &gCowTailIdleAnim); + pthis->actor.update = func_809DFE98; + pthis->actor.draw = func_809E0070; + pthis->actionFunc = func_809DFA84; + func_809DEF94(pthis); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_278 = ((u32)(Rand_ZeroFloat(1000.0f)) & 0xFFFF) + 40.0f; + break; + } + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->unk_276 = 0; +} + +void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCow* pthis = (EnCow*)thisx; + + if (pthis->actor.params == 0) { + Collider_DestroyCylinder(globalCtx, &pthis->colliders[0]); + Collider_DestroyCylinder(globalCtx, &pthis->colliders[1]); + } +} + +void func_809DF494(EnCow* pthis, GlobalContext* globalCtx) { + if (pthis->unk_278 > 0) { + pthis->unk_278 -= 1; + } else { + pthis->unk_278 = Rand_ZeroFloat(500.0f) + 40.0f; + Animation_Change(&pthis->skelAnime, &gCowBodyChewAnim, 1.0f, pthis->skelAnime.curFrame, + Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); + } + + if ((pthis->actor.xzDistToPlayer < 150.0f) && (!(pthis->unk_276 & 2))) { + pthis->unk_276 |= 2; + if (pthis->skelAnime.animation == &gCowBodyChewAnim) { + pthis->unk_278 = 0; + } + } + + pthis->unk_27A += 1; + if (pthis->unk_27A >= 0x31) { + pthis->unk_27A = 0; + } + + // (1.0f / 100.0f) instead of 0.01f below is necessary so 0.01f doesn't get reused mistakenly + if (pthis->unk_27A < 0x20) { + pthis->actor.scale.x = ((Math_SinS(pthis->unk_27A << 0xA) * (1.0f / 100.0f)) + 1.0f) * 0.01f; + } else { + pthis->actor.scale.x = 0.01f; + } + + if (pthis->unk_27A >= 0x11) { + pthis->actor.scale.y = ((Math_SinS((pthis->unk_27A << 0xA) - 0x4000) * (1.0f / 100.0f)) + 1.0f) * 0.01f; + } else { + pthis->actor.scale.y = 0.01f; + } +} + +void func_809DF6BC(EnCow* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + Message_CloseTextbox(globalCtx); + pthis->actionFunc = func_809DF96C; + } +} + +void func_809DF730(EnCow* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = func_809DF96C; + } +} + +void func_809DF778(EnCow* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_809DF730; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + } +} + +void func_809DF7D8(EnCow* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + Message_CloseTextbox(globalCtx); + pthis->actionFunc = func_809DF778; + func_8002F434(&pthis->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + } +} + +void func_809DF870(EnCow* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + if (Inventory_HasEmptyBottle()) { + Message_ContinueTextbox(globalCtx, 0x2007); + pthis->actionFunc = func_809DF7D8; + } else { + Message_ContinueTextbox(globalCtx, 0x2013); + pthis->actionFunc = func_809DF6BC; + } + } +} + +void func_809DF8FC(EnCow* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_809DF870; + } else { + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2CC(&pthis->actor, globalCtx, 170.0f); + pthis->actor.textId = 0x2006; + } + func_809DF494(pthis, globalCtx); +} + +void func_809DF96C(EnCow* pthis, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_00) || (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04)) { + if (DREG(53) != 0) { + if (pthis->unk_276 & 4) { + pthis->unk_276 &= ~0x4; + DREG(53) = 0; + } else { + if ((pthis->actor.xzDistToPlayer < 150.0f) && + (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) < 0x61A8)) { + DREG(53) = 0; + pthis->actionFunc = func_809DF8FC; + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2CC(&pthis->actor, globalCtx, 170.0f); + pthis->actor.textId = 0x2006; + } else { + pthis->unk_276 |= 4; + } + } + } else { + pthis->unk_276 &= ~0x4; + } + } + func_809DF494(pthis, globalCtx); +} + +void func_809DFA84(EnCow* pthis, GlobalContext* globalCtx) { + if (pthis->unk_278 > 0) { + pthis->unk_278--; + } else { + pthis->unk_278 = Rand_ZeroFloat(200.0f) + 40.0f; + Animation_Change(&pthis->skelAnime, &gCowTailIdleAnim, 1.0f, pthis->skelAnime.curFrame, + Animation_GetLastFrame(&gCowTailIdleAnim), ANIMMODE_ONCE, 1.0f); + } + + if ((pthis->actor.xzDistToPlayer < 150.0f) && + (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) >= 0x61A9) && (!(pthis->unk_276 & 2))) { + pthis->unk_276 |= 2; + if (pthis->skelAnime.animation == &gCowTailIdleAnim) { + pthis->unk_278 = 0; + } + } +} + +void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnCow* pthis = (EnCow*)thisx; + GlobalContext* globalCtx = globalCtx2; + s16 targetX; + s16 targetY; + Player* player = GET_PLAYER(globalCtx); + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[0].base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliders[1].base); + Actor_MoveForward(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->skelAnime.animation == &gCowBodyChewAnim) { + Audio_PlayActorSound2(thisx, NA_SE_EV_COW_CRY); + Animation_Change(&pthis->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gCowBodyMoveHeadAnim), ANIMMODE_ONCE, 1.0f); + } else { + Animation_Change(&pthis->skelAnime, &gCowBodyChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowBodyChewAnim), + ANIMMODE_LOOP, 1.0f); + } + } + pthis->actionFunc(pthis, globalCtx); + if ((thisx->xzDistToPlayer < 150.0f) && + (ABS(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000)) { + targetX = Math_Vec3f_Pitch(&thisx->focus.pos, &player->actor.focus.pos); + targetY = Math_Vec3f_Yaw(&thisx->focus.pos, &player->actor.focus.pos) - thisx->shape.rot.y; + + if (targetX > 0x1000) { + targetX = 0x1000; + } else if (targetX < -0x1000) { + targetX = -0x1000; + } + + if (targetY > 0x2500) { + targetY = 0x2500; + } else if (targetY < -0x2500) { + targetY = -0x2500; + } + + } else { + targetY = 0; + targetX = 0; + } + Math_SmoothStepToS(&pthis->someRot.x, targetX, 0xA, 0xC8, 0xA); + Math_SmoothStepToS(&pthis->someRot.y, targetY, 0xA, 0xC8, 0xA); +} + +void func_809DFE98(Actor* thisx, GlobalContext* globalCtx) { + EnCow* pthis = (EnCow*)thisx; + s32 pad; + + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->skelAnime.animation == &gCowTailIdleAnim) { + Animation_Change(&pthis->skelAnime, &gCowTailSwishAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gCowTailSwishAnim), ANIMMODE_ONCE, 1.0f); + } else { + Animation_Change(&pthis->skelAnime, &gCowTailIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowTailIdleAnim), + ANIMMODE_LOOP, 1.0f); + } + } + pthis->actionFunc(pthis, globalCtx); +} + +s32 EnCow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnCow* pthis = (EnCow*)thisx; + + if (limbIndex == 2) { + rot->y += pthis->someRot.y; + rot->x += pthis->someRot.x; + } + if (limbIndex == 5) { + *dList = NULL; + } + return false; +} + +void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnCow* pthis = (EnCow*)thisx; + + if (limbIndex == 2) { + Matrix_MultVec3f(&D_809E010C, &pthis->actor.focus.pos); + } +} + +void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCow* pthis = (EnCow*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnCow_OverrideLimbDraw, EnCow_PostLimbDraw, pthis); +} + +void func_809E0070(Actor* thisx, GlobalContext* globalCtx) { + EnCow* pthis = (EnCow*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); +} diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c deleted file mode 100644 index 835a1003f..000000000 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ /dev/null @@ -1,522 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_CROW_Z_EN_CROW_C -#include "actor_common.h" -#include "z_en_crow.h" -#include "objects/object_crow/object_crow.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) - -void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnCrow_SetupFlyIdle(EnCrow* this); -void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx); -void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx); -void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx); -void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx); -void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx); -void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx); - -static Vec3f sZeroVecAccel = { 0.0f, 0.0f, 0.0f }; - -const ActorInit En_Crow_InitVars = { - ACTOR_EN_CROW, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_CROW, - sizeof(EnCrow), - (ActorFunc)EnCrow_Init, - (ActorFunc)EnCrow_Destroy, - (ActorFunc)EnCrow_Update, - (ActorFunc)EnCrow_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 1, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(4, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static u32 sDeathCount = 0; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x58, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -200, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), -}; - -static Vec3f sHeadVec = { 2500.0f, 0.0f, 0.0f }; - -void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { - EnCrow* this = (EnCrow*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, 9); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - this->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); - sDeathCount = 0; - EnCrow_SetupFlyIdle(this); -} - -void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnCrow* this = (EnCrow*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -// Setup Action functions - -void EnCrow_SetupFlyIdle(EnCrow* this) { - this->timer = 100; - this->collider.base.acFlags |= AC_ON; - this->actionFunc = EnCrow_FlyIdle; - this->skelAnime.playSpeed = 1.0f; -} - -void EnCrow_SetupDiveAttack(EnCrow* this) { - this->timer = 300; - this->actor.speedXZ = 4.0f; - this->skelAnime.playSpeed = 2.0f; - this->actionFunc = EnCrow_DiveAttack; -} - -void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { - s32 i; - f32 scale; - Vec3f iceParticlePos; - - this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); - this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); - scale = this->actor.scale.x * 100.0f; - this->actor.world.pos.y += 20.0f * scale; - this->actor.bgCheckFlags &= ~1; - this->actor.shape.yOffset = 0.0f; - this->actor.targetArrowOffset = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_DEAD); - - if (this->actor.colChkInfo.damageEffect == 3) { // Ice arrows - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - for (i = 0; i < 8; i++) { - iceParticlePos.x = ((i & 1 ? 7.0f : -7.0f) * scale) + this->actor.world.pos.x; - iceParticlePos.y = ((i & 2 ? 7.0f : -7.0f) * scale) + this->actor.world.pos.y; - iceParticlePos.z = ((i & 4 ? 7.0f : -7.0f) * scale) + this->actor.world.pos.z; - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &iceParticlePos, 150, 150, 150, 250, 235, 245, 255, - ((Rand_ZeroOne() * 0.15f) + 0.85f) * scale); - } - } else if (this->actor.colChkInfo.damageEffect == 2) { // Fire arrows and Din's Fire - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - - for (i = 0; i < 4; i++) { - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &this->actor.world.pos, 50.0f * scale, 0, 0, i); - } - } else { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - } - - if (this->actor.flags & ACTOR_FLAG_15) { - this->actor.speedXZ = 0.0f; - } - - this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= ACTOR_FLAG_4; - - this->actionFunc = EnCrow_Damaged; -} - -void EnCrow_SetupDie(EnCrow* this) { - this->actor.colorFilterTimer = 0; - this->actionFunc = EnCrow_Die; -} - -void EnCrow_SetupTurnAway(EnCrow* this) { - this->timer = 100; - this->actor.speedXZ = 3.5f; - this->aimRotX = -0x1000; - this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; - this->skelAnime.playSpeed = 2.0f; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 5); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionFunc = EnCrow_TurnAway; -} - -void EnCrow_SetupRespawn(EnCrow* this) { - if (sDeathCount == 10) { - this->actor.params = 1; - sDeathCount = 0; - this->collider.elements[0].dim.worldSphere.radius = - sJntSphInit.elements[0].dim.modelSphere.radius * 0.03f * 100.0f; - } else { - this->actor.params = 0; - this->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; - } - - Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); - Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - this->actor.shape.rot.x = 0; - this->actor.shape.rot.z = 0; - this->timer = 300; - this->actor.shape.yOffset = 2000; - this->actor.targetArrowOffset = 2000.0f; - this->actor.draw = NULL; - this->actionFunc = EnCrow_Respawn; -} - -// Action functions - -void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 skelanimeUpdated; - s16 var; - - SkelAnime_Update(&this->skelAnime); - skelanimeUpdated = Animation_OnFrame(&this->skelAnime, 0.0f); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; - - if (this->actor.bgCheckFlags & 8) { - this->aimRotY = this->actor.wallYaw; - } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - this->aimRotY = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - } - - if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && skelanimeUpdated && - (Rand_ZeroOne() < 0.1f)) { - var = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y; - if (var > 0) { - this->aimRotY += 0x1000 + (0x1000 * Rand_ZeroOne()); - } else { - this->aimRotY -= 0x1000 + (0x1000 * Rand_ZeroOne()); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_CRY); - } - - if (this->actor.yDistToWater > -40.0f) { - this->aimRotX = -0x1000; - } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { - this->aimRotX = -0x800 - (Rand_ZeroOne() * 0x800); - } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { - this->aimRotX = 0x800 + (Rand_ZeroOne() * 0x800); - } - - if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 10, 0x100, 8) == 0) && (skelanimeUpdated) && - (Rand_ZeroOne() < 0.1f)) { - if (this->actor.home.pos.y < this->actor.world.pos.y) { - this->aimRotX -= (0x400 * Rand_ZeroOne()) + 0x400; - } else { - this->aimRotX += (0x400 * Rand_ZeroOne()) + 0x400; - } - this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); - } - - if (this->actor.bgCheckFlags & 1) { - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x100, 0x400); - } - - if (this->timer != 0) { - this->timer--; - } - if ((this->timer == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x00800000) && - (this->actor.yDistToWater < -40.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_SKULL)) { - EnCrow_SetupDiveAttack(this); - } -} - -void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 facingPlayer; - Vec3f pos; - s16 target; - - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - facingPlayer = Actor_IsFacingPlayer(&this->actor, 0x2800); - - if (facingPlayer) { - pos.x = player->actor.world.pos.x; - pos.y = player->actor.world.pos.y + 20.0f; - pos.z = player->actor.world.pos.z; - target = Actor_WorldPitchTowardPoint(&this->actor, &pos); - if (target > 0x3000) { - target = 0x3000; - } - Math_ApproachS(&this->actor.shape.rot.x, target, 2, 0x400); - } else { - Math_ApproachS(&this->actor.shape.rot.x, -0x1000, 2, 0x100); - } - - if (facingPlayer || (this->actor.xzDistToPlayer > 80.0f)) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); - } - - if ((this->timer == 0) || (Player_GetMask(globalCtx) == PLAYER_MASK_SKULL) || - (this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9) || - (player->stateFlags1 & 0x00800000) || (this->actor.yDistToWater > -40.0f)) { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_ATTACK); - } - - EnCrow_SetupFlyIdle(this); - } -} - -void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - this->actor.colorFilterTimer = 40; - - if (!(this->actor.flags & ACTOR_FLAG_15)) { - if (this->actor.colorFilterParams & 0x4000) { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); - this->actor.shape.rot.z += 0x1780; - } - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - EffectSsDeadDb_Spawn(globalCtx, &this->actor.world.pos, &sZeroVecAccel, &sZeroVecAccel, - this->actor.scale.x * 10000.0f, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, 1); - EnCrow_SetupDie(this); - } - } -} - -void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { - f32 step; - - if (this->actor.params != 0) { - step = 0.006f; - } else { - step = 0.002f; - } - - if (Math_StepToF(&this->actor.scale.x, 0.0f, step)) { - if (this->actor.params == 0) { - sDeathCount++; - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - } - EnCrow_SetupRespawn(this); - } - - this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; -} - -void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->actor.bgCheckFlags & 8) { - this->aimRotY = this->actor.wallYaw; - } else { - this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; - } - - Math_ApproachS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00); - Math_ApproachS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100); - - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - EnCrow_SetupFlyIdle(this); - } -} - -void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { - f32 target; - - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - SkelAnime_Update(&this->skelAnime); - this->actor.draw = EnCrow_Draw; - if (this->actor.params != 0) { - target = 0.03f; - } else { - target = 0.01f; - } - if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { - this->actor.flags |= ACTOR_FLAG_0; - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.colChkInfo.health = 1; - EnCrow_SetupFlyIdle(this); - } - this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; - } -} - -void EnCrow_UpdateDamage(EnCrow* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.elements[0].info, 1); - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (this->actor.colChkInfo.damageEffect == 1) { // Deku Nuts - EnCrow_SetupTurnAway(this); - } else { - Actor_ApplyDamage(&this->actor); - this->actor.flags &= ~ACTOR_FLAG_0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - EnCrow_SetupDamaged(this, globalCtx); - } - } - } -} - -void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { - EnCrow* this = (EnCrow*)thisx; - f32 pad; - f32 height; - f32 scale; - - EnCrow_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - scale = this->actor.scale.x * 100.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.world.rot.x = -this->actor.shape.rot.x; - - if (this->actionFunc != EnCrow_Respawn) { - if (this->actor.colChkInfo.health != 0) { - height = 20.0f * scale; - func_8002D97C(&this->actor); - } else { - height = 0.0f; - Actor_MoveForward(&this->actor); - } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); - } else { - height = 0.0f; - } - - this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + height; - this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - - if (this->actionFunc == EnCrow_DiveAttack) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (this->actionFunc != EnCrow_Respawn) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - Actor_SetFocus(&this->actor, height); - - if (this->actor.colChkInfo.health != 0 && Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); - } -} - -s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnCrow* this = (EnCrow*)thisx; - - if (this->actor.colChkInfo.health != 0) { - if (limbIndex == 7) { - rot->y += 0xC00 * sinf(this->skelAnime.curFrame * (M_PI / 4)); - } else if (limbIndex == 8) { - rot->y += 0x1400 * sinf((this->skelAnime.curFrame + 2.5f) * (M_PI / 4)); - } - } - return false; -} - -void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnCrow* this = (EnCrow*)thisx; - Vec3f* vec; - - if (limbIndex == 2) { - Matrix_MultVec3f(&sHeadVec, &this->bodyPartsPos[0]); - this->bodyPartsPos[0].y -= 20.0f; - } else if ((limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8)) { - vec = &this->bodyPartsPos[(limbIndex >> 1) - 1]; - Matrix_MultVec3f(&sZeroVecAccel, vec); - vec->y -= 20.0f; - } -} - -void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnCrow* this = (EnCrow*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.cpp b/src/overlays/actors/ovl_En_Crow/z_en_crow.cpp new file mode 100644 index 000000000..ea2bc83f6 --- /dev/null +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.cpp @@ -0,0 +1,522 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_CROW_Z_EN_CROW_C +#include "actor_common.h" +#include "z_en_crow.h" +#include "objects/object_crow/object_crow.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) + +void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx); +void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); +void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnCrow_SetupFlyIdle(EnCrow* pthis); +void EnCrow_FlyIdle(EnCrow* pthis, GlobalContext* globalCtx); +void EnCrow_Respawn(EnCrow* pthis, GlobalContext* globalCtx); +void EnCrow_DiveAttack(EnCrow* pthis, GlobalContext* globalCtx); +void EnCrow_Die(EnCrow* pthis, GlobalContext* globalCtx); +void EnCrow_TurnAway(EnCrow* pthis, GlobalContext* globalCtx); +void EnCrow_Damaged(EnCrow* pthis, GlobalContext* globalCtx); + +static Vec3f sZeroVecAccel = { 0.0f, 0.0f, 0.0f }; + +ActorInit En_Crow_InitVars = { + ACTOR_EN_CROW, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_CROW, + sizeof(EnCrow), + (ActorFunc)EnCrow_Init, + (ActorFunc)EnCrow_Destroy, + (ActorFunc)EnCrow_Update, + (ActorFunc)EnCrow_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 1, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(1, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(2, 0x3), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(4, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static u32 sDeathCount = 0; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x58, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -200, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), +}; + +static Vec3f sHeadVec = { 2500.0f, 0.0f, 0.0f }; + +void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* pthis = (EnCrow*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGuaySkel, &gGuayFlyAnim, pthis->jointTable, pthis->morphTable, 9); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + pthis->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + sDeathCount = 0; + EnCrow_SetupFlyIdle(pthis); +} + +void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* pthis = (EnCrow*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +// Setup Action functions + +void EnCrow_SetupFlyIdle(EnCrow* pthis) { + pthis->timer = 100; + pthis->collider.base.acFlags |= AC_ON; + pthis->actionFunc = EnCrow_FlyIdle; + pthis->skelAnime.playSpeed = 1.0f; +} + +void EnCrow_SetupDiveAttack(EnCrow* pthis) { + pthis->timer = 300; + pthis->actor.speedXZ = 4.0f; + pthis->skelAnime.playSpeed = 2.0f; + pthis->actionFunc = EnCrow_DiveAttack; +} + +void EnCrow_SetupDamaged(EnCrow* pthis, GlobalContext* globalCtx) { + s32 i; + f32 scale; + Vec3f iceParticlePos; + + pthis->actor.speedXZ *= Math_CosS(pthis->actor.world.rot.x); + pthis->actor.velocity.y = 0.0f; + Animation_Change(&pthis->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); + scale = pthis->actor.scale.x * 100.0f; + pthis->actor.world.pos.y += 20.0f * scale; + pthis->actor.bgCheckFlags &= ~1; + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.targetArrowOffset = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KAICHO_DEAD); + + if (pthis->actor.colChkInfo.damageEffect == 3) { // Ice arrows + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 40); + for (i = 0; i < 8; i++) { + iceParticlePos.x = ((i & 1 ? 7.0f : -7.0f) * scale) + pthis->actor.world.pos.x; + iceParticlePos.y = ((i & 2 ? 7.0f : -7.0f) * scale) + pthis->actor.world.pos.y; + iceParticlePos.z = ((i & 4 ? 7.0f : -7.0f) * scale) + pthis->actor.world.pos.z; + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &iceParticlePos, 150, 150, 150, 250, 235, 245, 255, + ((Rand_ZeroOne() * 0.15f) + 0.85f) * scale); + } + } else if (pthis->actor.colChkInfo.damageEffect == 2) { // Fire arrows and Din's Fire + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 40); + + for (i = 0; i < 4; i++) { + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &pthis->actor.world.pos, 50.0f * scale, 0, 0, i); + } + } else { + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 40); + } + + if (pthis->actor.flags & ACTOR_FLAG_15) { + pthis->actor.speedXZ = 0.0f; + } + + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.flags |= ACTOR_FLAG_4; + + pthis->actionFunc = EnCrow_Damaged; +} + +void EnCrow_SetupDie(EnCrow* pthis) { + pthis->actor.colorFilterTimer = 0; + pthis->actionFunc = EnCrow_Die; +} + +void EnCrow_SetupTurnAway(EnCrow* pthis) { + pthis->timer = 100; + pthis->actor.speedXZ = 3.5f; + pthis->aimRotX = -0x1000; + pthis->aimRotY = pthis->actor.yawTowardsPlayer + 0x8000; + pthis->skelAnime.playSpeed = 2.0f; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0, 5); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actionFunc = EnCrow_TurnAway; +} + +void EnCrow_SetupRespawn(EnCrow* pthis) { + if (sDeathCount == 10) { + pthis->actor.params = 1; + sDeathCount = 0; + pthis->collider.elements[0].dim.worldSphere.radius = + sJntSphInit.elements[0].dim.modelSphere.radius * 0.03f * 100.0f; + } else { + pthis->actor.params = 0; + pthis->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + } + + Animation_PlayLoop(&pthis->skelAnime, &gGuayFlyAnim); + Math_Vec3f_Copy(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->actor.shape.rot.x = 0; + pthis->actor.shape.rot.z = 0; + pthis->timer = 300; + pthis->actor.shape.yOffset = 2000; + pthis->actor.targetArrowOffset = 2000.0f; + pthis->actor.draw = NULL; + pthis->actionFunc = EnCrow_Respawn; +} + +// Action functions + +void EnCrow_FlyIdle(EnCrow* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 skelanimeUpdated; + s16 var; + + SkelAnime_Update(&pthis->skelAnime); + skelanimeUpdated = Animation_OnFrame(&pthis->skelAnime, 0.0f); + pthis->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; + + if (pthis->actor.bgCheckFlags & 8) { + pthis->aimRotY = pthis->actor.wallYaw; + } else if (Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) > 300.0f) { + pthis->aimRotY = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + } + + if ((Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->aimRotY, 5, 0x300, 0x10) == 0) && skelanimeUpdated && + (Rand_ZeroOne() < 0.1f)) { + var = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos) - pthis->actor.shape.rot.y; + if (var > 0) { + pthis->aimRotY += 0x1000 + (0x1000 * Rand_ZeroOne()); + } else { + pthis->aimRotY -= 0x1000 + (0x1000 * Rand_ZeroOne()); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KAICHO_CRY); + } + + if (pthis->actor.yDistToWater > -40.0f) { + pthis->aimRotX = -0x1000; + } else if (pthis->actor.world.pos.y < (pthis->actor.home.pos.y - 50.0f)) { + pthis->aimRotX = -0x800 - (Rand_ZeroOne() * 0x800); + } else if (pthis->actor.world.pos.y > (pthis->actor.home.pos.y + 50.0f)) { + pthis->aimRotX = 0x800 + (Rand_ZeroOne() * 0x800); + } + + if ((Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->aimRotX, 10, 0x100, 8) == 0) && (skelanimeUpdated) && + (Rand_ZeroOne() < 0.1f)) { + if (pthis->actor.home.pos.y < pthis->actor.world.pos.y) { + pthis->aimRotX -= (0x400 * Rand_ZeroOne()) + 0x400; + } else { + pthis->aimRotX += (0x400 * Rand_ZeroOne()) + 0x400; + } + pthis->aimRotX = CLAMP(pthis->aimRotX, -0x1000, 0x1000); + } + + if (pthis->actor.bgCheckFlags & 1) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x100, 0x400); + } + + if (pthis->timer != 0) { + pthis->timer--; + } + if ((pthis->timer == 0) && (pthis->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x00800000) && + (pthis->actor.yDistToWater < -40.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_SKULL)) { + EnCrow_SetupDiveAttack(pthis); + } +} + +void EnCrow_DiveAttack(EnCrow* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 facingPlayer; + Vec3f pos; + s16 target; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + facingPlayer = Actor_IsFacingPlayer(&pthis->actor, 0x2800); + + if (facingPlayer) { + pos.x = player->actor.world.pos.x; + pos.y = player->actor.world.pos.y + 20.0f; + pos.z = player->actor.world.pos.z; + target = Actor_WorldPitchTowardPoint(&pthis->actor, &pos); + if (target > 0x3000) { + target = 0x3000; + } + Math_ApproachS(&pthis->actor.shape.rot.x, target, 2, 0x400); + } else { + Math_ApproachS(&pthis->actor.shape.rot.x, -0x1000, 2, 0x100); + } + + if (facingPlayer || (pthis->actor.xzDistToPlayer > 80.0f)) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 4, 0xC00); + } + + if ((pthis->timer == 0) || (Player_GetMask(globalCtx) == PLAYER_MASK_SKULL) || + (pthis->collider.base.atFlags & AT_HIT) || (pthis->actor.bgCheckFlags & 9) || + (player->stateFlags1 & 0x00800000) || (pthis->actor.yDistToWater > -40.0f)) { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KAICHO_ATTACK); + } + + EnCrow_SetupFlyIdle(pthis); + } +} + +void EnCrow_Damaged(EnCrow* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + pthis->actor.colorFilterTimer = 40; + + if (!(pthis->actor.flags & ACTOR_FLAG_15)) { + if (pthis->actor.colorFilterParams & 0x4000) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x4000, 0x200); + pthis->actor.shape.rot.z += 0x1780; + } + if ((pthis->actor.bgCheckFlags & 1) || (pthis->actor.floorHeight == BGCHECK_Y_MIN)) { + EffectSsDeadDb_Spawn(globalCtx, &pthis->actor.world.pos, &sZeroVecAccel, &sZeroVecAccel, + pthis->actor.scale.x * 10000.0f, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, 1); + EnCrow_SetupDie(pthis); + } + } +} + +void EnCrow_Die(EnCrow* pthis, GlobalContext* globalCtx) { + f32 step; + + if (pthis->actor.params != 0) { + step = 0.006f; + } else { + step = 0.002f; + } + + if (Math_StepToF(&pthis->actor.scale.x, 0.0f, step)) { + if (pthis->actor.params == 0) { + sDeathCount++; + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0); + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_RUPEE_RED); + } + EnCrow_SetupRespawn(pthis); + } + + pthis->actor.scale.z = pthis->actor.scale.y = pthis->actor.scale.x; +} + +void EnCrow_TurnAway(EnCrow* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.bgCheckFlags & 8) { + pthis->aimRotY = pthis->actor.wallYaw; + } else { + pthis->aimRotY = pthis->actor.yawTowardsPlayer + 0x8000; + } + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->aimRotY, 3, 0xC00); + Math_ApproachS(&pthis->actor.shape.rot.x, pthis->aimRotX, 5, 0x100); + + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + EnCrow_SetupFlyIdle(pthis); + } +} + +void EnCrow_Respawn(EnCrow* pthis, GlobalContext* globalCtx) { + f32 target; + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.draw = EnCrow_Draw; + if (pthis->actor.params != 0) { + target = 0.03f; + } else { + target = 0.01f; + } + if (Math_StepToF(&pthis->actor.scale.x, target, target * 0.1f)) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.colChkInfo.health = 1; + EnCrow_SetupFlyIdle(pthis); + } + pthis->actor.scale.z = pthis->actor.scale.y = pthis->actor.scale.x; + } +} + +void EnCrow_UpdateDamage(EnCrow* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.elements[0].info, 1); + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (pthis->actor.colChkInfo.damageEffect == 1) { // Deku Nuts + EnCrow_SetupTurnAway(pthis); + } else { + Actor_ApplyDamage(&pthis->actor); + pthis->actor.flags &= ~ACTOR_FLAG_0; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + EnCrow_SetupDamaged(pthis, globalCtx); + } + } + } +} + +void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* pthis = (EnCrow*)thisx; + f32 pad; + f32 height; + f32 scale; + + EnCrow_UpdateDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + scale = pthis->actor.scale.x * 100.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.world.rot.x = -pthis->actor.shape.rot.x; + + if (pthis->actionFunc != EnCrow_Respawn) { + if (pthis->actor.colChkInfo.health != 0) { + height = 20.0f * scale; + func_8002D97C(&pthis->actor); + } else { + height = 0.0f; + Actor_MoveForward(&pthis->actor); + } + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + } else { + height = 0.0f; + } + + pthis->collider.elements[0].dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->collider.elements[0].dim.worldSphere.center.y = pthis->actor.world.pos.y + height; + pthis->collider.elements[0].dim.worldSphere.center.z = pthis->actor.world.pos.z; + + if (pthis->actionFunc == EnCrow_DiveAttack) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (pthis->actionFunc != EnCrow_Respawn) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + Actor_SetFocus(&pthis->actor, height); + + if (pthis->actor.colChkInfo.health != 0 && Animation_OnFrame(&pthis->skelAnime, 3.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_KAICHO_FLUTTER); + } +} + +s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnCrow* pthis = (EnCrow*)thisx; + + if (pthis->actor.colChkInfo.health != 0) { + if (limbIndex == 7) { + rot->y += 0xC00 * sinf(pthis->skelAnime.curFrame * (M_PI / 4)); + } else if (limbIndex == 8) { + rot->y += 0x1400 * sinf((pthis->skelAnime.curFrame + 2.5f) * (M_PI / 4)); + } + } + return false; +} + +void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnCrow* pthis = (EnCrow*)thisx; + Vec3f* vec; + + if (limbIndex == 2) { + Matrix_MultVec3f(&sHeadVec, &pthis->bodyPartsPos[0]); + pthis->bodyPartsPos[0].y -= 20.0f; + } else if ((limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8)) { + vec = &pthis->bodyPartsPos[(limbIndex >> 1) - 1]; + Matrix_MultVec3f(&sZeroVecAccel, vec); + vec->y -= 20.0f; + } +} + +void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* pthis = (EnCrow*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Cs/z_en_cs.c b/src/overlays/actors/ovl_En_Cs/z_en_cs.cpp similarity index 55% rename from src/overlays/actors/ovl_En_Cs/z_en_cs.c rename to src/overlays/actors/ovl_En_Cs/z_en_cs.cpp index 6f25dbcab..0ef14df19 100644 --- a/src/overlays/actors/ovl_En_Cs/z_en_cs.c +++ b/src/overlays/actors/ovl_En_Cs/z_en_cs.cpp @@ -25,13 +25,13 @@ void EnCs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCs_Update(Actor* thisx, GlobalContext* globalCtx); void EnCs_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnCs_Walk(EnCs* this, GlobalContext* globalCtx); -void EnCs_Talk(EnCs* this, GlobalContext* globalCtx); -void EnCs_Wait(EnCs* this, GlobalContext* globalCtx); +void EnCs_Walk(EnCs* pthis, GlobalContext* globalCtx); +void EnCs_Talk(EnCs* pthis, GlobalContext* globalCtx); +void EnCs_Wait(EnCs* pthis, GlobalContext* globalCtx); s32 EnCs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); void EnCs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); -const ActorInit En_Cs_InitVars = { +ActorInit En_Cs_InitVars = { ACTOR_EN_CS, ACTORCAT_NPC, FLAGS, @@ -107,7 +107,7 @@ static struct_D_80AA1678 sAnimations[] = { { &gGraveyardKidIdleAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, }; -void EnCs_SetAnimFromIndex(EnCs* this, s32 animIndex, s32* currentAnimIndex) { +void EnCs_SetAnimFromIndex(EnCs* pthis, s32 animIndex, s32* currentAnimIndex) { f32 morphFrames; if ((*currentAnimIndex < 0) || (animIndex == *currentAnimIndex)) { @@ -117,11 +117,11 @@ void EnCs_SetAnimFromIndex(EnCs* this, s32 animIndex, s32* currentAnimIndex) { } if (sAnimations[animIndex].frameCount >= 0.0f) { - Animation_Change(&this->skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].frameCount, 0.0f, + Animation_Change(&pthis->skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].frameCount, 0.0f, Animation_GetLastFrame(sAnimations[animIndex].animation), sAnimations[animIndex].mode, morphFrames); } else { - Animation_Change(&this->skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].frameCount, + Animation_Change(&pthis->skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].frameCount, Animation_GetLastFrame(sAnimations[animIndex].animation), 0.0f, sAnimations[animIndex].mode, morphFrames); } @@ -130,48 +130,48 @@ void EnCs_SetAnimFromIndex(EnCs* this, s32 animIndex, s32* currentAnimIndex) { } void EnCs_Init(Actor* thisx, GlobalContext* globalCtx) { - EnCs* this = (EnCs*)thisx; + EnCs* pthis = (EnCs*)thisx; s32 pad; if (!IS_DAY) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGraveyardKidSkel, NULL, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGraveyardKidSkel, NULL, pthis->jointTable, pthis->morphTable, 16); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, sDamageTable, &sColChkInfoInit2); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, sDamageTable, &sColChkInfoInit2); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimations[0].animation, 1.0f, 0.0f, + Animation_Change(&pthis->skelAnime, sAnimations[0].animation, 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[0].animation), sAnimations[0].mode, sAnimations[0].transitionRate); - this->actor.targetMode = 6; - this->path = this->actor.params & 0xFF; - this->unk_1EC = 0; // This variable is unused anywhere else - this->talkState = 0; - this->currentAnimIndex = -1; - this->actor.gravity = -1.0f; + pthis->actor.targetMode = 6; + pthis->path = pthis->actor.params & 0xFF; + pthis->unk_1EC = 0; // This variable is unused anywhere else + pthis->talkState = 0; + pthis->currentAnimIndex = -1; + pthis->actor.gravity = -1.0f; - EnCs_SetAnimFromIndex(this, 0, &this->currentAnimIndex); + EnCs_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); - this->actionFunc = EnCs_Walk; - this->walkSpeed = 1.0f; + pthis->actionFunc = EnCs_Walk; + pthis->walkSpeed = 1.0f; } void EnCs_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnCs* this = (EnCs*)thisx; + EnCs* pthis = (EnCs*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 EnCs_GetTalkState(EnCs* this, GlobalContext* globalCtx) { +s32 EnCs_GetTalkState(EnCs* pthis, GlobalContext* globalCtx) { s32 pad; s32 pad2; s32 talkState = 1; @@ -180,24 +180,24 @@ s32 EnCs_GetTalkState(EnCs* this, GlobalContext* globalCtx) { case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { - this->actor.textId = 0x2026; - EnCs_SetAnimFromIndex(this, 3, &this->currentAnimIndex); + pthis->actor.textId = 0x2026; + EnCs_SetAnimFromIndex(pthis, 3, &pthis->currentAnimIndex); talkState = 2; } else { - this->actor.textId = 0x2024; - EnCs_SetAnimFromIndex(this, 1, &this->currentAnimIndex); + pthis->actor.textId = 0x2024; + EnCs_SetAnimFromIndex(pthis, 1, &pthis->currentAnimIndex); talkState = 2; } } break; case TEXT_STATE_DONE: if (Message_ShouldAdvance(globalCtx)) { - if (this->actor.textId == 0x2026) { + if (pthis->actor.textId == 0x2026) { Player_UnsetMask(globalCtx); Item_Give(globalCtx, ITEM_SOLD_OUT); gSaveContext.itemGetInf[3] |= 0x400; Rupees_ChangeBy(30); - this->actor.textId = 0x2027; + pthis->actor.textId = 0x2027; talkState = 2; } else { talkState = 0; @@ -215,7 +215,7 @@ s32 EnCs_GetTalkState(EnCs* this, GlobalContext* globalCtx) { return talkState; } -s32 EnCs_GetTextID(EnCs* this, GlobalContext* globalCtx) { +s32 EnCs_GetTextID(EnCs* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 textId = Text_GetFaceReaction(globalCtx, 15); @@ -234,36 +234,36 @@ s32 EnCs_GetTextID(EnCs* this, GlobalContext* globalCtx) { return textId; } -void EnCs_HandleTalking(EnCs* this, GlobalContext* globalCtx) { +void EnCs_HandleTalking(EnCs* pthis, GlobalContext* globalCtx) { s32 pad; s16 sp2A; s16 sp28; - if (this->talkState == 2) { - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->talkState = 1; - } else if (this->talkState == 1) { - this->talkState = EnCs_GetTalkState(this, globalCtx); - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if ((this->actor.textId == 0x2022) || ((this->actor.textId != 0x2022) && (this->actor.textId != 0x2028))) { - EnCs_SetAnimFromIndex(this, 3, &this->currentAnimIndex); + if (pthis->talkState == 2) { + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->talkState = 1; + } else if (pthis->talkState == 1) { + pthis->talkState = EnCs_GetTalkState(pthis, globalCtx); + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if ((pthis->actor.textId == 0x2022) || ((pthis->actor.textId != 0x2022) && (pthis->actor.textId != 0x2028))) { + EnCs_SetAnimFromIndex(pthis, 3, &pthis->currentAnimIndex); } - if ((this->actor.textId == 0x2023) || (this->actor.textId == 0x2028)) { - EnCs_SetAnimFromIndex(this, 1, &this->currentAnimIndex); + if ((pthis->actor.textId == 0x2023) || (pthis->actor.textId == 0x2028)) { + EnCs_SetAnimFromIndex(pthis, 1, &pthis->currentAnimIndex); } - if (this->actor.textId == 0x2023) { + if (pthis->actor.textId == 0x2023) { func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } - this->talkState = 1; + pthis->talkState = 1; } else { - Actor_GetScreenPos(globalCtx, &this->actor, &sp2A, &sp28); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp2A, &sp28); if ((sp2A >= 0) && (sp2A <= 320) && (sp28 >= 0) && (sp28 <= 240) && - (func_8002F2CC(&this->actor, globalCtx, 100.0f))) { - this->actor.textId = EnCs_GetTextID(this, globalCtx); + (func_8002F2CC(&pthis->actor, globalCtx, 100.0f))) { + pthis->actor.textId = EnCs_GetTextID(pthis, globalCtx); } } } @@ -288,7 +288,7 @@ s32 EnCs_GetPathPoint(Path* pathList, Vec3f* dest, s32 pathIndex, s32 waypoint) return 0; } -s32 EnCs_HandleWalking(EnCs* this, GlobalContext* globalCtx) { +s32 EnCs_HandleWalking(EnCs* pthis, GlobalContext* globalCtx) { f32 xDiff; f32 zDiff; Vec3f pathPos; @@ -296,52 +296,52 @@ s32 EnCs_HandleWalking(EnCs* this, GlobalContext* globalCtx) { s16 walkAngle1; s16 walkAngle2; - EnCs_GetPathPoint(globalCtx->setupPathList, &pathPos, this->path, this->waypoint); - xDiff = pathPos.x - this->actor.world.pos.x; - zDiff = pathPos.z - this->actor.world.pos.z; + EnCs_GetPathPoint(globalCtx->setupPathList, &pathPos, pthis->path, pthis->waypoint); + xDiff = pathPos.x - pthis->actor.world.pos.x; + zDiff = pathPos.z - pthis->actor.world.pos.z; walkAngle1 = Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI); - this->walkAngle = walkAngle1; - this->walkDist = sqrtf((xDiff * xDiff) + (zDiff * zDiff)); + pthis->walkAngle = walkAngle1; + pthis->walkDist = sqrtf((xDiff * xDiff) + (zDiff * zDiff)); - while (this->walkDist <= 10.44f) { - this->waypoint++; - waypointCount = EnCs_GetwaypointCount(globalCtx->setupPathList, this->path); + while (pthis->walkDist <= 10.44f) { + pthis->waypoint++; + waypointCount = EnCs_GetwaypointCount(globalCtx->setupPathList, pthis->path); - if ((this->waypoint < 0) || (!(this->waypoint < waypointCount))) { - this->waypoint = 0; + if ((pthis->waypoint < 0) || (!(pthis->waypoint < waypointCount))) { + pthis->waypoint = 0; } - EnCs_GetPathPoint(globalCtx->setupPathList, &pathPos, this->path, this->waypoint); - xDiff = pathPos.x - this->actor.world.pos.x; - zDiff = pathPos.z - this->actor.world.pos.z; + EnCs_GetPathPoint(globalCtx->setupPathList, &pathPos, pthis->path, pthis->waypoint); + xDiff = pathPos.x - pthis->actor.world.pos.x; + zDiff = pathPos.z - pthis->actor.world.pos.z; walkAngle2 = Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI); - this->walkAngle = walkAngle2; - this->walkDist = sqrtf((xDiff * xDiff) + (zDiff * zDiff)); + pthis->walkAngle = walkAngle2; + pthis->walkDist = sqrtf((xDiff * xDiff) + (zDiff * zDiff)); } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->walkAngle, 1, 2500, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.speedXZ = this->walkSpeed; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->walkAngle, 1, 2500, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.speedXZ = pthis->walkSpeed; + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); return 0; } -void EnCs_Walk(EnCs* this, GlobalContext* globalCtx) { +void EnCs_Walk(EnCs* pthis, GlobalContext* globalCtx) { s32 rnd; s32 animIndex; s32 curAnimFrame; - if (this->talkState != 0) { - this->actionFunc = EnCs_Talk; + if (pthis->talkState != 0) { + pthis->actionFunc = EnCs_Talk; return; } - if (SkelAnime_Update(&this->skelAnime)) { - animIndex = this->currentAnimIndex; + if (SkelAnime_Update(&pthis->skelAnime)) { + animIndex = pthis->currentAnimIndex; - if (this->talkState == 0) { + if (pthis->talkState == 0) { if (gSaveContext.itemGetInf[3] & 0x400) { rnd = Rand_ZeroOne() * 10.0f; } else { @@ -356,108 +356,108 @@ void EnCs_Walk(EnCs* this, GlobalContext* globalCtx) { animIndex = 2; } - this->actionFunc = EnCs_Wait; + pthis->actionFunc = EnCs_Wait; } else { animIndex = 0; } } - EnCs_SetAnimFromIndex(this, animIndex, &this->currentAnimIndex); + EnCs_SetAnimFromIndex(pthis, animIndex, &pthis->currentAnimIndex); } - if (this->talkState == 0) { - curAnimFrame = this->skelAnime.curFrame; + if (pthis->talkState == 0) { + curAnimFrame = pthis->skelAnime.curFrame; if (((curAnimFrame >= 8) && (curAnimFrame < 16)) || ((curAnimFrame >= 23) && (curAnimFrame < 30)) || (curAnimFrame == 0)) { - this->walkSpeed = 0.0f; + pthis->walkSpeed = 0.0f; } else { - this->walkSpeed = 1.0f; + pthis->walkSpeed = 1.0f; } - EnCs_HandleWalking(this, globalCtx); + EnCs_HandleWalking(pthis, globalCtx); } } -void EnCs_Wait(EnCs* this, GlobalContext* globalCtx) { +void EnCs_Wait(EnCs* pthis, GlobalContext* globalCtx) { s32 animIndex; - if (this->talkState != 0) { - this->actionFunc = EnCs_Talk; + if (pthis->talkState != 0) { + pthis->actionFunc = EnCs_Talk; return; } - if (SkelAnime_Update(&this->skelAnime)) { - animIndex = this->currentAnimIndex; + if (SkelAnime_Update(&pthis->skelAnime)) { + animIndex = pthis->currentAnimIndex; - if (this->talkState == 0) { - if (this->animLoopCount > 0) { - this->animLoopCount--; - animIndex = this->currentAnimIndex; + if (pthis->talkState == 0) { + if (pthis->animLoopCount > 0) { + pthis->animLoopCount--; + animIndex = pthis->currentAnimIndex; } else { animIndex = 0; - this->actionFunc = EnCs_Walk; + pthis->actionFunc = EnCs_Walk; } } - EnCs_SetAnimFromIndex(this, animIndex, &this->currentAnimIndex); + EnCs_SetAnimFromIndex(pthis, animIndex, &pthis->currentAnimIndex); } } -void EnCs_Talk(EnCs* this, GlobalContext* globalCtx) { +void EnCs_Talk(EnCs* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnCs_SetAnimFromIndex(this, this->currentAnimIndex, &this->currentAnimIndex); + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnCs_SetAnimFromIndex(pthis, pthis->currentAnimIndex, &pthis->currentAnimIndex); } - this->flag |= 1; - this->npcInfo.unk_18.x = player->actor.focus.pos.x; - this->npcInfo.unk_18.y = player->actor.focus.pos.y; - this->npcInfo.unk_18.z = player->actor.focus.pos.z; - func_80034A14(&this->actor, &this->npcInfo, 0, 4); + pthis->flag |= 1; + pthis->npcInfo.unk_18.x = player->actor.focus.pos.x; + pthis->npcInfo.unk_18.y = player->actor.focus.pos.y; + pthis->npcInfo.unk_18.z = player->actor.focus.pos.z; + func_80034A14(&pthis->actor, &pthis->npcInfo, 0, 4); - if (this->talkState == 0) { - EnCs_SetAnimFromIndex(this, 0, &this->currentAnimIndex); - this->actionFunc = EnCs_Walk; - this->flag &= ~1; + if (pthis->talkState == 0) { + EnCs_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); + pthis->actionFunc = EnCs_Walk; + pthis->flag &= ~1; } } void EnCs_Update(Actor* thisx, GlobalContext* globalCtx) { static s32 eyeBlinkFrames[] = { 70, 1, 1 }; - EnCs* this = (EnCs*)thisx; + EnCs* pthis = (EnCs*)thisx; s32 pad; - if (this->currentAnimIndex == 0) { - if (((s32)this->skelAnime.curFrame == 9) || ((s32)this->skelAnime.curFrame == 23)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK); + if (pthis->currentAnimIndex == 0) { + if (((s32)pthis->skelAnime.curFrame == 9) || ((s32)pthis->skelAnime.curFrame == 23)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHIBI_WALK); } - } else if (this->currentAnimIndex == 1) { - if (((s32)this->skelAnime.curFrame == 10) || ((s32)this->skelAnime.curFrame == 25)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK); + } else if (pthis->currentAnimIndex == 1) { + if (((s32)pthis->skelAnime.curFrame == 10) || ((s32)pthis->skelAnime.curFrame == 25)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHIBI_WALK); } - } else if ((this->currentAnimIndex == 2) && ((s32)this->skelAnime.curFrame == 20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK); + } else if ((pthis->currentAnimIndex == 2) && ((s32)pthis->skelAnime.curFrame == 20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHIBI_WALK); } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - EnCs_HandleTalking(this, globalCtx); + EnCs_HandleTalking(pthis, globalCtx); - this->eyeBlinkTimer--; + pthis->eyeBlinkTimer--; - if (this->eyeBlinkTimer < 0) { - this->eyeIndex++; + if (pthis->eyeBlinkTimer < 0) { + pthis->eyeIndex++; - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; } - this->eyeBlinkTimer = eyeBlinkFrames[this->eyeIndex]; + pthis->eyeBlinkTimer = eyeBlinkFrames[pthis->eyeIndex]; } } @@ -467,16 +467,16 @@ void EnCs_Draw(Actor* thisx, GlobalContext* globalCtx) { gGraveyardKidEyesHalfTex, gGraveyardKidEyesClosedTex, }; - EnCs* this = (EnCs*)thisx; + EnCs* pthis = (EnCs*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_cs.c", 968); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnCs_OverrideLimbDraw, EnCs_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnCs_OverrideLimbDraw, EnCs_PostLimbDraw, &pthis->actor); if (gSaveContext.itemGetInf[3] & 0x400) { s32 childLinkObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_LINK_CHILD); @@ -485,12 +485,12 @@ void EnCs_Draw(Actor* thisx, GlobalContext* globalCtx) { if (childLinkObjectIndex >= 0) { Mtx* mtx; - Matrix_Put(&this->spookyMaskMtx); + Matrix_Put(&pthis->spookyMaskMtx); mtx = Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_cs.c", 1000); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[childLinkObjectIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[childLinkObjectIndex].vromStart.get()); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx - 7); gSPDisplayList(POLY_OPA_DISP++, gLinkChildSpookyMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->actor.objBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->actor.objBankIndex].vromStart.get()); } } @@ -498,17 +498,17 @@ void EnCs_Draw(Actor* thisx, GlobalContext* globalCtx) { } s32 EnCs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnCs* this = (EnCs*)thisx; + EnCs* pthis = (EnCs*)thisx; - if (this->flag & 1) { + if (pthis->flag & 1) { switch (limbIndex) { case 8: - rot->x += this->npcInfo.unk_0E.y; - rot->y -= this->npcInfo.unk_0E.x; + rot->x += pthis->npcInfo.unk_0E.y; + rot->y -= pthis->npcInfo.unk_0E.x; break; case 15: - rot->x += this->npcInfo.unk_08.y; - rot->z += this->npcInfo.unk_08.x; + rot->x += pthis->npcInfo.unk_08.y; + rot->z += pthis->npcInfo.unk_08.x; break; } } @@ -518,14 +518,14 @@ s32 EnCs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnCs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f D_809E2970 = { 500.0f, 800.0f, 0.0f }; - EnCs* this = (EnCs*)thisx; + EnCs* pthis = (EnCs*)thisx; if (limbIndex == 15) { - Matrix_MultVec3f(&D_809E2970, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809E2970, &pthis->actor.focus.pos); Matrix_Translate(0.0f, -200.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateY(0.0f, MTXMODE_APPLY); Matrix_RotateX(0.0f, MTXMODE_APPLY); Matrix_RotateZ(5.0 * M_PI / 9.0, MTXMODE_APPLY); - Matrix_Get(&this->spookyMaskMtx); + Matrix_Get(&pthis->spookyMaskMtx); } } diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.cpp similarity index 51% rename from src/overlays/actors/ovl_En_Daiku/z_en_daiku.c rename to src/overlays/actors/ovl_En_Daiku/z_en_daiku.cpp index b3930879c..550a7498f 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.cpp @@ -60,17 +60,17 @@ void EnDaiku_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx); void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku_TentIdle(EnDaiku* this, GlobalContext* globalCtx); -void EnDaiku_Jailed(EnDaiku* this, GlobalContext* globalCtx); -void EnDaiku_WaitFreedom(EnDaiku* this, GlobalContext* globalCtx); -void EnDaiku_InitEscape(EnDaiku* this, GlobalContext* globalCtx); -void EnDaiku_EscapeRotate(EnDaiku* this, GlobalContext* globalCtx); -void EnDaiku_InitSubCamera(EnDaiku* this, GlobalContext* globalCtx); -void EnDaiku_EscapeRun(EnDaiku* this, GlobalContext* globalCtx); +void EnDaiku_TentIdle(EnDaiku* pthis, GlobalContext* globalCtx); +void EnDaiku_Jailed(EnDaiku* pthis, GlobalContext* globalCtx); +void EnDaiku_WaitFreedom(EnDaiku* pthis, GlobalContext* globalCtx); +void EnDaiku_InitEscape(EnDaiku* pthis, GlobalContext* globalCtx); +void EnDaiku_EscapeRotate(EnDaiku* pthis, GlobalContext* globalCtx); +void EnDaiku_InitSubCamera(EnDaiku* pthis, GlobalContext* globalCtx); +void EnDaiku_EscapeRun(EnDaiku* pthis, GlobalContext* globalCtx); s32 EnDaiku_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); void EnDaiku_PostLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3s* rot, void* thisx); -const ActorInit En_Daiku_InitVars = { +ActorInit En_Daiku_InitVars = { ACTOR_EN_DAIKU, ACTORCAT_NPC, FLAGS, @@ -152,7 +152,7 @@ static EnDaikuEscapeSubCamParam sEscapeSubCamParams[] = { { { -40, 60, 60 }, 120 }, }; -void EnDaiku_Change(EnDaiku* this, s32 animIndex, s32* currentAnimIndex) { +void EnDaiku_Change(EnDaiku* pthis, s32 animIndex, s32* currentAnimIndex) { f32 transitionRate; if (*currentAnimIndex < 0 || *currentAnimIndex == animIndex) { @@ -161,25 +161,25 @@ void EnDaiku_Change(EnDaiku* this, s32 animIndex, s32* currentAnimIndex) { transitionRate = sAnimations[animIndex].transitionRate; } - Animation_Change(&this->skelAnime, sAnimations[animIndex].anim, 1.0f, 0.0f, + Animation_Change(&pthis->skelAnime, sAnimations[animIndex].anim, 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[animIndex].anim), sAnimations[animIndex].mode, transitionRate); *currentAnimIndex = animIndex; } void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDaiku* this = (EnDaiku*)thisx; + EnDaiku* pthis = (EnDaiku*)thisx; s32 pad; s32 noKill = true; s32 isFree = false; - if ((this->actor.params & 3) == 0 && (gSaveContext.eventChkInf[9] & 1)) { + if ((pthis->actor.params & 3) == 0 && (gSaveContext.eventChkInf[9] & 1)) { isFree = true; - } else if ((this->actor.params & 3) == 1 && (gSaveContext.eventChkInf[9] & 2)) { + } else if ((pthis->actor.params & 3) == 1 && (gSaveContext.eventChkInf[9] & 2)) { isFree = true; - } else if ((this->actor.params & 3) == 2 && (gSaveContext.eventChkInf[9] & 4)) { + } else if ((pthis->actor.params & 3) == 2 && (gSaveContext.eventChkInf[9] & 4)) { isFree = true; - } else if ((this->actor.params & 3) == 3 && (gSaveContext.eventChkInf[9] & 8)) { + } else if ((pthis->actor.params & 3) == 3 && (gSaveContext.eventChkInf[9] & 8)) { isFree = true; } @@ -189,74 +189,74 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { noKill = false; } - this->startFightSwitchFlag = this->actor.shape.rot.z & 0x3F; - this->actor.shape.rot.z = 0; + pthis->startFightSwitchFlag = pthis->actor.shape.rot.z & 0x3F; + pthis->actor.shape.rot.z = 0; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_daiku_Skel_007958, NULL, this->jointTable, this->morphTable, + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_daiku_Skel_007958, NULL, pthis->jointTable, pthis->morphTable, 17); if (!noKill) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - Animation_Change(&this->skelAnime, sAnimations[0].anim, 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[0].anim), + Animation_Change(&pthis->skelAnime, sAnimations[0].anim, 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[0].anim), sAnimations[0].mode, sAnimations[0].transitionRate); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); - this->actor.targetMode = 6; - this->currentAnimIndex = -1; - this->runSpeed = 5.0f; - this->initRot = this->actor.world.rot; - this->initPos = this->actor.world.pos; + pthis->actor.targetMode = 6; + pthis->currentAnimIndex = -1; + pthis->runSpeed = 5.0f; + pthis->initRot = pthis->actor.world.rot; + pthis->initPos = pthis->actor.world.pos; if (globalCtx->sceneNum == SCENE_GERUDOWAY) { - EnDaiku_Change(this, ENDAIKU_ANIM_STAND, &this->currentAnimIndex); - this->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; - this->actionFunc = EnDaiku_Jailed; + EnDaiku_Change(pthis, ENDAIKU_ANIM_STAND, &pthis->currentAnimIndex); + pthis->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; + pthis->actionFunc = EnDaiku_Jailed; } else { - if ((this->actor.params & 3) == 1 || (this->actor.params & 3) == 3) { - EnDaiku_Change(this, ENDAIKU_ANIM_SIT, &this->currentAnimIndex); - this->stateFlags |= ENDAIKU_STATEFLAG_1; + if ((pthis->actor.params & 3) == 1 || (pthis->actor.params & 3) == 3) { + EnDaiku_Change(pthis, ENDAIKU_ANIM_SIT, &pthis->currentAnimIndex); + pthis->stateFlags |= ENDAIKU_STATEFLAG_1; } else { - EnDaiku_Change(this, ENDAIKU_ANIM_SHOUT, &this->currentAnimIndex); - this->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; + EnDaiku_Change(pthis, ENDAIKU_ANIM_SHOUT, &pthis->currentAnimIndex); + pthis->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; } - this->skelAnime.curFrame = (s32)(Rand_ZeroOne() * this->skelAnime.endFrame); - this->actionFunc = EnDaiku_TentIdle; + pthis->skelAnime.curFrame = (s32)(Rand_ZeroOne() * pthis->skelAnime.endFrame); + pthis->actionFunc = EnDaiku_TentIdle; } } void EnDaiku_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDaiku* this = (EnDaiku*)thisx; + EnDaiku* pthis = (EnDaiku*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 EnDaiku_UpdateTalking(EnDaiku* this, GlobalContext* globalCtx) { +s32 EnDaiku_UpdateTalking(EnDaiku* pthis, GlobalContext* globalCtx) { s32 newTalkState = ENDAIKU_STATE_TALKING; if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) { if (globalCtx->sceneNum == SCENE_GERUDOWAY) { if (Message_ShouldAdvance(globalCtx)) { - if (this->actor.textId == 0x6007) { - Flags_SetSwitch(globalCtx, this->startFightSwitchFlag); + if (pthis->actor.textId == 0x6007) { + Flags_SetSwitch(globalCtx, pthis->startFightSwitchFlag); newTalkState = ENDAIKU_STATE_CAN_TALK; } else { - this->actionFunc = EnDaiku_InitEscape; + pthis->actionFunc = EnDaiku_InitEscape; newTalkState = ENDAIKU_STATE_NO_TALK; } } } else if (globalCtx->sceneNum == SCENE_TENT) { if (Message_ShouldAdvance(globalCtx)) { - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x6061: gSaveContext.infTable[23] |= 0x40; break; @@ -273,22 +273,22 @@ s32 EnDaiku_UpdateTalking(EnDaiku* this, GlobalContext* globalCtx) { return newTalkState; } -void EnDaiku_UpdateText(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_UpdateText(EnDaiku* pthis, GlobalContext* globalCtx) { s32 carpenterType; s32 freedCount; s16 sp2E; s16 sp2C; - if (this->talkState == ENDAIKU_STATE_TALKING) { - this->talkState = EnDaiku_UpdateTalking(this, globalCtx); - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->talkState = ENDAIKU_STATE_TALKING; + if (pthis->talkState == ENDAIKU_STATE_TALKING) { + pthis->talkState = EnDaiku_UpdateTalking(pthis, globalCtx); + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->talkState = ENDAIKU_STATE_TALKING; } else { - Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); - if (sp2E >= 0 && sp2E <= 320 && sp2C >= 0 && sp2C <= 240 && this->talkState == ENDAIKU_STATE_CAN_TALK && - func_8002F2CC(&this->actor, globalCtx, 100.0f) == 1) { + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp2E, &sp2C); + if (sp2E >= 0 && sp2E <= 320 && sp2C >= 0 && sp2C <= 240 && pthis->talkState == ENDAIKU_STATE_CAN_TALK && + func_8002F2CC(&pthis->actor, globalCtx, 100.0f) == 1) { if (globalCtx->sceneNum == SCENE_GERUDOWAY) { - if (this->stateFlags & ENDAIKU_STATEFLAG_GERUDODEFEATED) { + if (pthis->stateFlags & ENDAIKU_STATEFLAG_GERUDODEFEATED) { freedCount = 0; for (carpenterType = 0; carpenterType < 4; carpenterType++) { if (gSaveContext.eventChkInf[9] & (1 << carpenterType)) { @@ -298,58 +298,58 @@ void EnDaiku_UpdateText(EnDaiku* this, GlobalContext* globalCtx) { switch (freedCount) { case 0: - this->actor.textId = 0x605B; + pthis->actor.textId = 0x605B; break; case 1: - this->actor.textId = 0x605C; + pthis->actor.textId = 0x605C; break; case 2: - this->actor.textId = 0x605D; + pthis->actor.textId = 0x605D; break; case 3: - this->actor.textId = 0x605E; + pthis->actor.textId = 0x605E; break; } - } else if (!(this->stateFlags & + } else if (!(pthis->stateFlags & (ENDAIKU_STATEFLAG_GERUDOFIGHTING | ENDAIKU_STATEFLAG_GERUDODEFEATED))) { - this->actor.textId = 0x6007; + pthis->actor.textId = 0x6007; } } else if (globalCtx->sceneNum == SCENE_TENT) { - switch (this->actor.params & 3) { + switch (pthis->actor.params & 3) { case 0: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - this->actor.textId = 0x6060; + pthis->actor.textId = 0x6060; } else { - this->actor.textId = 0x605F; + pthis->actor.textId = 0x605F; } break; case 1: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - this->actor.textId = 0x6063; + pthis->actor.textId = 0x6063; } else { if (!(gSaveContext.infTable[23] & 0x40)) { - this->actor.textId = 0x6061; + pthis->actor.textId = 0x6061; } else { - this->actor.textId = 0x6062; + pthis->actor.textId = 0x6062; } } break; case 2: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - this->actor.textId = 0x6066; + pthis->actor.textId = 0x6066; } else { if (!(gSaveContext.infTable[23] & 0x100)) { - this->actor.textId = 0x6064; + pthis->actor.textId = 0x6064; } else { - this->actor.textId = 0x6065; + pthis->actor.textId = 0x6065; } } break; case 3: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - this->actor.textId = 0x6068; + pthis->actor.textId = 0x6068; } else { - this->actor.textId = 0x6067; + pthis->actor.textId = 0x6067; } break; } @@ -361,33 +361,33 @@ void EnDaiku_UpdateText(EnDaiku* this, GlobalContext* globalCtx) { /** * The carpenter is idling in the tent. */ -void EnDaiku_TentIdle(EnDaiku* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - EnDaiku_UpdateText(this, globalCtx); +void EnDaiku_TentIdle(EnDaiku* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + EnDaiku_UpdateText(pthis, globalCtx); } /** * The carpenter is jailed in a Gerudo fortress cell, talking to him starts a fight against a gerudo guard */ -void EnDaiku_Jailed(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_Jailed(EnDaiku* pthis, GlobalContext* globalCtx) { EnGeldB* gerudo; s32 temp_t9; s32 temp_v1; - if (!(this->stateFlags & ENDAIKU_STATEFLAG_GERUDOFIGHTING)) { - EnDaiku_UpdateText(this, globalCtx); + if (!(pthis->stateFlags & ENDAIKU_STATEFLAG_GERUDOFIGHTING)) { + EnDaiku_UpdateText(pthis, globalCtx); } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); gerudo = (EnGeldB*)Actor_Find(&globalCtx->actorCtx, ACTOR_EN_GELDB, ACTORCAT_ENEMY); if (gerudo == NULL) { - this->stateFlags |= ENDAIKU_STATEFLAG_GERUDODEFEATED; - this->stateFlags &= ~ENDAIKU_STATEFLAG_GERUDOFIGHTING; - EnDaiku_Change(this, ENDAIKU_ANIM_CELEBRATE, &this->currentAnimIndex); - this->actionFunc = EnDaiku_WaitFreedom; - } else if (!(this->stateFlags & ENDAIKU_STATEFLAG_GERUDOFIGHTING) && !gerudo->invisible) { - this->stateFlags |= ENDAIKU_STATEFLAG_GERUDOFIGHTING; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->stateFlags |= ENDAIKU_STATEFLAG_GERUDODEFEATED; + pthis->stateFlags &= ~ENDAIKU_STATEFLAG_GERUDOFIGHTING; + EnDaiku_Change(pthis, ENDAIKU_ANIM_CELEBRATE, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaiku_WaitFreedom; + } else if (!(pthis->stateFlags & ENDAIKU_STATEFLAG_GERUDOFIGHTING) && !gerudo->invisible) { + pthis->stateFlags |= ENDAIKU_STATEFLAG_GERUDOFIGHTING; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); } } @@ -395,19 +395,19 @@ void EnDaiku_Jailed(EnDaiku* this, GlobalContext* globalCtx) { * The player defeated the gerudo guard and the carpenter is waiting for the cell door to be opened, and for the player * to then talk to him */ -void EnDaiku_WaitFreedom(EnDaiku* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void EnDaiku_WaitFreedom(EnDaiku* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - if (Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F)) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - EnDaiku_UpdateText(this, globalCtx); + if (Flags_GetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F)) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + EnDaiku_UpdateText(pthis, globalCtx); } } /** * The carpenter is free, initializes his running away animation */ -void EnDaiku_InitEscape(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_InitEscape(EnDaiku* pthis, GlobalContext* globalCtx) { Path* path; f32 dxz; f32 dx; @@ -416,123 +416,123 @@ void EnDaiku_InitEscape(EnDaiku* this, GlobalContext* globalCtx) { s32 exitLoop; Audio_PlayFanfare(NA_BGM_APPEAR); - EnDaiku_Change(this, ENDAIKU_ANIM_RUN, &this->currentAnimIndex); - this->stateFlags &= ~(ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2); + EnDaiku_Change(pthis, ENDAIKU_ANIM_RUN, &pthis->currentAnimIndex); + pthis->stateFlags &= ~(ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2); - gSaveContext.eventChkInf[9] |= 1 << (this->actor.params & 3); + gSaveContext.eventChkInf[9] |= 1 << (pthis->actor.params & 3); - this->actor.gravity = -1.0f; - this->escapeSubCamTimer = sEscapeSubCamParams[this->actor.params & 3].maxFramesActive; - EnDaiku_InitSubCamera(this, globalCtx); + pthis->actor.gravity = -1.0f; + pthis->escapeSubCamTimer = sEscapeSubCamParams[pthis->actor.params & 3].maxFramesActive; + EnDaiku_InitSubCamera(pthis, globalCtx); exitLoop = false; - path = &globalCtx->setupPathList[this->actor.params >> 4 & 0xF]; + path = &globalCtx->setupPathList[pthis->actor.params >> 4 & 0xF]; while (!exitLoop) { - pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; - dx = pointPos->x - this->actor.world.pos.x; - dz = pointPos->z - this->actor.world.pos.z; - this->rotYtowardsPath = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); + pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->waypoint; + dx = pointPos->x - pthis->actor.world.pos.x; + dz = pointPos->z - pthis->actor.world.pos.z; + pthis->rotYtowardsPath = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); dxz = sqrtf(SQ(dx) + SQ(dz)); if (dxz > 10.0f) { exitLoop = true; } else { - this->waypoint++; + pthis->waypoint++; } } - this->actionFunc = EnDaiku_EscapeRotate; + pthis->actionFunc = EnDaiku_EscapeRotate; } /** * The carpenter is rotating towards where he is going next */ -void EnDaiku_EscapeRotate(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_EscapeRotate(EnDaiku* pthis, GlobalContext* globalCtx) { s16 diff; - diff = Math_SmoothStepToS(&this->actor.shape.rot.y, this->rotYtowardsPath, 1, 0x1388, 0); - SkelAnime_Update(&this->skelAnime); + diff = Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->rotYtowardsPath, 1, 0x1388, 0); + SkelAnime_Update(&pthis->skelAnime); if (diff == 0) { - this->actionFunc = EnDaiku_EscapeRun; - this->actionFunc(this, globalCtx); + pthis->actionFunc = EnDaiku_EscapeRun; + pthis->actionFunc(pthis, globalCtx); } } -void EnDaiku_InitSubCamera(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_InitSubCamera(EnDaiku* pthis, GlobalContext* globalCtx) { s32 pad; Vec3f eyePosDeltaLocal; Vec3f eyePosDeltaWorld; - this->subCamActive = true; - this->escapeSubCamTimer = sEscapeSubCamParams[this->actor.params & 3].maxFramesActive; + pthis->subCamActive = true; + pthis->escapeSubCamTimer = sEscapeSubCamParams[pthis->actor.params & 3].maxFramesActive; - eyePosDeltaLocal.x = sEscapeSubCamParams[this->actor.params & 3].eyePosDeltaLocal.x; - eyePosDeltaLocal.y = sEscapeSubCamParams[this->actor.params & 3].eyePosDeltaLocal.y; - eyePosDeltaLocal.z = sEscapeSubCamParams[this->actor.params & 3].eyePosDeltaLocal.z; - Matrix_RotateY(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_NEW); + eyePosDeltaLocal.x = sEscapeSubCamParams[pthis->actor.params & 3].eyePosDeltaLocal.x; + eyePosDeltaLocal.y = sEscapeSubCamParams[pthis->actor.params & 3].eyePosDeltaLocal.y; + eyePosDeltaLocal.z = sEscapeSubCamParams[pthis->actor.params & 3].eyePosDeltaLocal.z; + Matrix_RotateY(pthis->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_NEW); Matrix_MultVec3f(&eyePosDeltaLocal, &eyePosDeltaWorld); - this->subCamEyeInit.x = this->subCamEye.x = this->actor.world.pos.x + eyePosDeltaWorld.x; - this->subCamEyeInit.y = this->subCamEye.y = this->actor.world.pos.y + eyePosDeltaWorld.y; + pthis->subCamEyeInit.x = pthis->subCamEye.x = pthis->actor.world.pos.x + eyePosDeltaWorld.x; + pthis->subCamEyeInit.y = pthis->subCamEye.y = pthis->actor.world.pos.y + eyePosDeltaWorld.y; if (1) {} - this->subCamEyeInit.z = this->subCamEye.z = this->actor.world.pos.z + eyePosDeltaWorld.z; + pthis->subCamEyeInit.z = pthis->subCamEye.z = pthis->actor.world.pos.z + eyePosDeltaWorld.z; if (1) {} - this->subCamAtTarget.x = this->subCamAt.x = this->actor.world.pos.x; - this->subCamAtTarget.y = this->subCamAt.y = this->actor.world.pos.y + 60.0f; + pthis->subCamAtTarget.x = pthis->subCamAt.x = pthis->actor.world.pos.x; + pthis->subCamAtTarget.y = pthis->subCamAt.y = pthis->actor.world.pos.y + 60.0f; if (1) {} - this->subCamAtTarget.z = this->subCamAt.z = this->actor.world.pos.z; + pthis->subCamAtTarget.z = pthis->subCamAt.z = pthis->actor.world.pos.z; - this->subCamId = Gameplay_CreateSubCamera(globalCtx); + pthis->subCamId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->subCamId, CAM_STAT_ACTIVE); + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCamId, CAM_STAT_ACTIVE); - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); - Gameplay_CameraSetFov(globalCtx, this->subCamId, globalCtx->mainCamera.fov); - func_8002DF54(globalCtx, &this->actor, 1); + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->subCamAt, &pthis->subCamEye); + Gameplay_CameraSetFov(globalCtx, pthis->subCamId, globalCtx->mainCamera.fov); + func_8002DF54(globalCtx, &pthis->actor, 1); } -void EnDaiku_UpdateSubCamera(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_UpdateSubCamera(EnDaiku* pthis, GlobalContext* globalCtx) { s32 pad; - this->subCamAtTarget.x = this->actor.world.pos.x; - this->subCamAtTarget.y = this->actor.world.pos.y + 60.0f; - this->subCamAtTarget.z = this->actor.world.pos.z; + pthis->subCamAtTarget.x = pthis->actor.world.pos.x; + pthis->subCamAtTarget.y = pthis->actor.world.pos.y + 60.0f; + pthis->subCamAtTarget.z = pthis->actor.world.pos.z; - Math_SmoothStepToF(&this->subCamAt.x, this->subCamAtTarget.x, 1.0f, 1000.0f, 0.0f); - Math_SmoothStepToF(&this->subCamAt.y, this->subCamAtTarget.y, 1.0f, 1000.0f, 0.0f); - Math_SmoothStepToF(&this->subCamAt.z, this->subCamAtTarget.z, 1.0f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->subCamAt.x, pthis->subCamAtTarget.x, 1.0f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->subCamAt.y, pthis->subCamAtTarget.y, 1.0f, 1000.0f, 0.0f); + Math_SmoothStepToF(&pthis->subCamAt.z, pthis->subCamAtTarget.z, 1.0f, 1000.0f, 0.0f); - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->subCamAt, &pthis->subCamEye); } -void EnDaiku_EscapeSuccess(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_EscapeSuccess(EnDaiku* pthis, GlobalContext* globalCtx) { static Vec3f D_809E4148 = { 0.0f, 0.0f, 120.0f }; Actor* gerudoGuard; Vec3f vec; - Gameplay_ClearCamera(globalCtx, this->subCamId); + Gameplay_ClearCamera(globalCtx, pthis->subCamId); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - this->subCamActive = false; + pthis->subCamActive = false; if ((gSaveContext.eventChkInf[9] & 0xF) == 0xF) { - Matrix_RotateY(this->initRot.y * (M_PI / 0x8000), MTXMODE_NEW); + Matrix_RotateY(pthis->initRot.y * (M_PI / 0x8000), MTXMODE_NEW); Matrix_MultVec3f(&D_809E4148, &vec); gerudoGuard = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GE3, this->initPos.x + vec.x, this->initPos.y + vec.y, - this->initPos.z + vec.z, 0, Math_FAtan2F(-vec.x, -vec.z) * (0x8000 / M_PI), 0, 2); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GE3, pthis->initPos.x + vec.x, pthis->initPos.y + vec.y, + pthis->initPos.z + vec.z, 0, Math_FAtan2F(-vec.x, -vec.z) * (0x8000 / M_PI), 0, 2); if (gerudoGuard == NULL) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } else { - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); } } /** * The carpenter is running away */ -void EnDaiku_EscapeRun(EnDaiku* this, GlobalContext* globalCtx) { +void EnDaiku_EscapeRun(EnDaiku* pthis, GlobalContext* globalCtx) { s32 pad1; Path* path; s16 ry; @@ -542,71 +542,71 @@ void EnDaiku_EscapeRun(EnDaiku* this, GlobalContext* globalCtx) { f32 dxz; Vec3s* pointPos; - path = &globalCtx->setupPathList[this->actor.params >> 4 & 0xF]; - pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; - dx = pointPos->x - this->actor.world.pos.x; - dz = pointPos->z - this->actor.world.pos.z; + path = &globalCtx->setupPathList[pthis->actor.params >> 4 & 0xF]; + pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->waypoint; + dx = pointPos->x - pthis->actor.world.pos.x; + dz = pointPos->z - pthis->actor.world.pos.z; ry = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); dxz = sqrtf(SQ(dx) + SQ(dz)); if (dxz <= 20.88f) { - this->waypoint++; - if (this->waypoint >= path->count) { - if (this->subCamActive) { - EnDaiku_EscapeSuccess(this, globalCtx); + pthis->waypoint++; + if (pthis->waypoint >= path->count) { + if (pthis->subCamActive) { + EnDaiku_EscapeSuccess(pthis, globalCtx); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } } - Math_SmoothStepToS(&this->actor.shape.rot.y, ry, 1, 0xFA0, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - Math_SmoothStepToF(&this->actor.speedXZ, this->runSpeed, 0.6f, dxz, 0.0f); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, ry, 1, 0xFA0, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->runSpeed, 0.6f, dxz, 0.0f); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); - if (this->subCamActive) { - EnDaiku_UpdateSubCamera(this, globalCtx); - if (this->escapeSubCamTimer-- <= 0) { - EnDaiku_EscapeSuccess(this, globalCtx); + if (pthis->subCamActive) { + EnDaiku_UpdateSubCamera(pthis, globalCtx); + if (pthis->escapeSubCamTimer-- <= 0) { + EnDaiku_EscapeSuccess(pthis, globalCtx); } } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); } void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDaiku* this = (EnDaiku*)thisx; + EnDaiku* pthis = (EnDaiku*)thisx; s32 curFrame; Player* player = GET_PLAYER(globalCtx); - if (this->currentAnimIndex == ENDAIKU_ANIM_RUN) { - curFrame = this->skelAnime.curFrame; + if (pthis->currentAnimIndex == ENDAIKU_ANIM_RUN) { + curFrame = pthis->skelAnime.curFrame; if (curFrame == 6 || curFrame == 15) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); } } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->stateFlags & ENDAIKU_STATEFLAG_1) { - this->unk_244.unk_18.x = player->actor.focus.pos.x; - this->unk_244.unk_18.y = player->actor.focus.pos.y; - this->unk_244.unk_18.z = player->actor.focus.pos.z; + if (pthis->stateFlags & ENDAIKU_STATEFLAG_1) { + pthis->unk_244.unk_18.x = player->actor.focus.pos.x; + pthis->unk_244.unk_18.y = player->actor.focus.pos.y; + pthis->unk_244.unk_18.z = player->actor.focus.pos.z; - if (this->stateFlags & ENDAIKU_STATEFLAG_2) { - func_80034A14(&this->actor, &this->unk_244, 0, 4); + if (pthis->stateFlags & ENDAIKU_STATEFLAG_2) { + func_80034A14(&pthis->actor, &pthis->unk_244, 0, 4); } else { - func_80034A14(&this->actor, &this->unk_244, 0, 2); + func_80034A14(&pthis->actor, &pthis->unk_244, 0, 2); } } } void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDaiku* this = (EnDaiku*)thisx; + EnDaiku* pthis = (EnDaiku*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku.c", 1227); @@ -622,23 +622,23 @@ void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnDaiku_OverrideLimbDraw, EnDaiku_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnDaiku_OverrideLimbDraw, EnDaiku_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku.c", 1255); } s32 EnDaiku_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnDaiku* this = (EnDaiku*)thisx; + EnDaiku* pthis = (EnDaiku*)thisx; switch (limb) { case 8: // torso - rot->x += this->unk_244.unk_0E.y; - rot->y -= this->unk_244.unk_0E.x; + rot->x += pthis->unk_244.unk_0E.y; + rot->y -= pthis->unk_244.unk_0E.x; break; case 15: // head - rot->x += this->unk_244.unk_08.y; - rot->z += this->unk_244.unk_08.x; + rot->x += pthis->unk_244.unk_08.y; + rot->z += pthis->unk_244.unk_08.x; break; } @@ -649,13 +649,13 @@ void EnDaiku_PostLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3s static Gfx* hairDLists[] = { object_daiku_DL_005BD0, object_daiku_DL_005AC0, object_daiku_DL_005990, object_daiku_DL_005880 }; static Vec3f targetPosHeadLocal = { 700, 1100, 0 }; - EnDaiku* this = (EnDaiku*)thisx; + EnDaiku* pthis = (EnDaiku*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku.c", 1323); if (limb == 15) { // head - Matrix_MultVec3f(&targetPosHeadLocal, &this->actor.focus.pos); - gSPDisplayList(POLY_OPA_DISP++, hairDLists[this->actor.params & 3]); + Matrix_MultVec3f(&targetPosHeadLocal, &pthis->actor.focus.pos); + gSPDisplayList(POLY_OPA_DISP++, hairDLists[pthis->actor.params & 3]); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku.c", 1330); diff --git a/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c b/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c deleted file mode 100644 index 8868fa9c4..000000000 --- a/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c +++ /dev/null @@ -1,567 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DAIKU_KAKARIKO_Z_EN_DAIKU_KAKARIKO_C -#include "actor_common.h" -/* - * File: z_en_daiku_kakariko.c - * Overlay: ovl_En_Daiku_Kakariko - * Description: Kakariko Village Carpenters - */ - -#include "z_en_daiku_kakariko.h" -#include "objects/object_daiku/object_daiku.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -typedef enum { - /* 0x0 */ CARPENTER_ICHIRO, // Red and purple pants, normal hair - /* 0x1 */ CARPENTER_SABOORO, // Light blue pants - /* 0x2 */ CARPENTER_JIRO, // Green pants - /* 0x3 */ CARPENTER_SHIRO // Pink and purple pants, two-spiked hair -} KakarikoCarpenterType; - -void EnDaikuKakariko_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDaikuKakariko_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDaikuKakariko_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDaikuKakariko_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDaikuKakariko_Wait(EnDaikuKakariko* this, GlobalContext* globalCtx); -void EnDaikuKakariko_Run(EnDaikuKakariko* this, GlobalContext* globalCtx); - -const ActorInit En_Daiku_Kakariko_InitVars = { - ACTOR_EN_DAIKU_KAKARIKO, - ACTORCAT_NPC, - FLAGS, - OBJECT_DAIKU, - sizeof(EnDaikuKakariko), - (ActorFunc)EnDaikuKakariko_Init, - (ActorFunc)EnDaikuKakariko_Destroy, - (ActorFunc)EnDaikuKakariko_Update, - (ActorFunc)EnDaikuKakariko_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 18, 66, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(0, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Kokiri sword */ DMG_ENTRY(0, 0x0), - /* Master sword */ DMG_ENTRY(0, 0x0), - /* Giant's Knife */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(0, 0x0), - /* Giant spin */ DMG_ENTRY(0, 0x0), - /* Master spin */ DMG_ENTRY(0, 0x0), - /* Kokiri jump */ DMG_ENTRY(0, 0x0), - /* Giant jump */ DMG_ENTRY(0, 0x0), - /* Master jump */ DMG_ENTRY(0, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static struct_D_80AA1678 sAnimations[] = { - { &object_daiku_Anim_001AB0, 1.0f, 2, -7.0f }, { &object_daiku_Anim_007DE0, 1.0f, 0, -7.0f }, - { &object_daiku_Anim_00885C, 1.0f, 0, -7.0f }, { &object_daiku_Anim_000C44, 1.0f, 0, -7.0f }, - { &object_daiku_Anim_000600, 1.0f, 0, -7.0f }, { &object_daiku_Anim_008164, 1.0f, 0, -7.0f }, -}; - -void EnDaikuKakariko_SetAnimFromIndex(EnDaikuKakariko* this, s32 animIndex, s32* currentAnimIndex) { - f32 morphFrames; - - if ((*currentAnimIndex < 0) || (animIndex == *currentAnimIndex)) { - morphFrames = 0.0f; - } else { - morphFrames = sAnimations[animIndex].transitionRate; - } - - Animation_Change(&this->skelAnime, sAnimations[animIndex].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[animIndex].animation), sAnimations[animIndex].mode, - morphFrames); - - *currentAnimIndex = animIndex; -} - -void EnDaikuKakariko_Init(Actor* thisx, GlobalContext* globalCtx) { - static u16 initFlags[] = { 0x0080, 0x00B0, 0x0070, 0x0470 }; // List of inital values for this->flags - EnDaikuKakariko* this = (EnDaikuKakariko*)thisx; - s32 pad; - - if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - switch (globalCtx->sceneNum) { - case SCENE_SPOT01: - if (IS_DAY) { - this->flags |= 1; - this->flags |= initFlags[this->actor.params & 3]; - } - break; - case SCENE_KAKARIKO: - if (IS_NIGHT) { - this->flags |= 2; - } - break; - case SCENE_DRAG: - this->flags |= 4; - break; - } - } - - if (!(this->flags & 7)) { - Actor_Kill(&this->actor); - } - - if (IS_NIGHT) { - this->flags |= 8; - } - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_daiku_Skel_007958, NULL, this->jointTable, this->morphTable, - 17); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - - CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInit); - - Animation_Change(&this->skelAnime, sAnimations->animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations->animation), sAnimations->mode, sAnimations->transitionRate); - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - - this->actor.gravity = 0.0f; - this->runSpeed = 3.0f; - this->actor.uncullZoneForward = 1200.0f; - this->actor.targetMode = 6; - this->currentAnimIndex = -1; - - if (this->flags & 0x40) { - this->actor.gravity = -1.0f; - } - - if (this->flags & 0x10) { - EnDaikuKakariko_SetAnimFromIndex(this, 3, &this->currentAnimIndex); - this->actionFunc = EnDaikuKakariko_Run; - } else { - if (this->flags & 8) { - if (((this->actor.params & 3) == CARPENTER_SABOORO) || ((this->actor.params & 3) == CARPENTER_SHIRO)) { - EnDaikuKakariko_SetAnimFromIndex(this, 5, &this->currentAnimIndex); - this->flags |= 0x800; - } else { - EnDaikuKakariko_SetAnimFromIndex(this, 1, &this->currentAnimIndex); - } - - this->skelAnime.curFrame = (s32)(Rand_ZeroOne() * this->skelAnime.endFrame); - } else { - EnDaikuKakariko_SetAnimFromIndex(this, 0, &this->currentAnimIndex); - this->skelAnime.curFrame = (s32)(Rand_ZeroOne() * this->skelAnime.endFrame); - } - - this->flags |= 0x100; - this->actionFunc = EnDaikuKakariko_Wait; - } -} - -void EnDaikuKakariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDaikuKakariko* this = (EnDaikuKakariko*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 EnDaikuKakariko_GetTalkState(EnDaikuKakariko* this, GlobalContext* globalCtx) { - s32 talkState = 2; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - switch (this->actor.textId) { - case 0x6061: - gSaveContext.infTable[23] |= 0x40; - break; - case 0x6064: - gSaveContext.infTable[23] |= 0x100; - break; - } - talkState = 0; - } - return talkState; -} - -void EnDaikuKakariko_HandleTalking(EnDaikuKakariko* this, GlobalContext* globalCtx) { - static s32 maskReactionSets[] = { 1, 2, 3, 4 }; - s16 sp26; - s16 sp24; - - if (this->talkState == 2) { - this->talkState = EnDaikuKakariko_GetTalkState(this, globalCtx); - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->talkState = 2; - } else { - Actor_GetScreenPos(globalCtx, &this->actor, &sp26, &sp24); - - if ((sp26 >= 0) && (sp26 <= 320) && (sp24 >= 0) && (sp24 <= 240) && (this->talkState == 0) && - (func_8002F2CC(&this->actor, globalCtx, 100.0f) == 1)) { - this->actor.textId = Text_GetFaceReaction(globalCtx, maskReactionSets[this->actor.params & 3]); - - if (this->actor.textId == 0) { - switch (this->actor.params & 3) { - case 0: - if (this->flags & 8) { - this->actor.textId = 0x5076; - } else { - this->actor.textId = 0x5075; - } - break; - case 1: - if (this->flags & 1) { - this->actor.textId = 0x502A; - } else { - this->actor.textId = 0x5074; - } - break; - case 2: - if (this->flags & 1) { - this->actor.textId = 0x506A; - } else { - this->actor.textId = 0x506B; - } - break; - case 3: - if (this->flags & 1) { - this->actor.textId = 0x5077; - } else { - this->actor.textId = 0x5078; - } - break; - } - } - } - } -} - -void EnDaikuKakariko_Talk(EnDaikuKakariko* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnDaikuKakariko_SetAnimFromIndex(this, 3, &this->currentAnimIndex); - } - - EnDaikuKakariko_HandleTalking(this, globalCtx); - - if (this->talkState == 0) { - if (this->flags & 0x10) { - EnDaikuKakariko_SetAnimFromIndex(this, 3, &this->currentAnimIndex); - this->flags &= ~0x0300; - this->actionFunc = EnDaikuKakariko_Run; - return; - } - - if (!(this->flags & 8)) { - EnDaikuKakariko_SetAnimFromIndex(this, 0, &this->currentAnimIndex); - } - - if ((this->flags & 0x800) == 0) { - this->flags &= ~0x0200; - this->flags |= 0x100; - } - - this->actionFunc = EnDaikuKakariko_Wait; - } -} - -void EnDaikuKakariko_Wait(EnDaikuKakariko* this, GlobalContext* globalCtx) { - EnDaikuKakariko_HandleTalking(this, globalCtx); - - if (SkelAnime_Update(&this->skelAnime)) { - EnDaikuKakariko_SetAnimFromIndex(this, 0, &this->currentAnimIndex); - } - - if (this->talkState != 0) { - if (!(this->flags & 8)) { - EnDaikuKakariko_SetAnimFromIndex(this, 4, &this->currentAnimIndex); - } - - if (!(this->flags & 0x800)) { - this->flags |= 0x200; - this->flags &= ~0x0100; - } - - this->actionFunc = EnDaikuKakariko_Talk; - } -} - -void EnDaikuKakariko_StopRunning(EnDaikuKakariko* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->timer--; - - if (this->timer <= 0) { - EnDaikuKakariko_SetAnimFromIndex(this, 3, &this->currentAnimIndex); - this->actionFunc = EnDaikuKakariko_Run; - } else { - this->skelAnime.curFrame = this->skelAnime.startFrame; - } - } - - EnDaikuKakariko_HandleTalking(this, globalCtx); - - if (this->talkState != 0) { - this->flags |= 0x200; - EnDaikuKakariko_SetAnimFromIndex(this, 4, &this->currentAnimIndex); - this->actionFunc = EnDaikuKakariko_Talk; - } -} - -void EnDaikuKakariko_Run(EnDaikuKakariko* this, GlobalContext* globalCtx) { - s32 pad; - Path* path; - Vec3s* pathPos; - f32 xDist; - f32 zDist; - s16 runAngle; - f32 runDist; - s16 angleStepDiff; - s32 run; - - do { - path = &globalCtx->setupPathList[(this->actor.params >> 8) & 0xFF]; - pathPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->waypoint]; - xDist = pathPos->x - this->actor.world.pos.x; - zDist = pathPos->z - this->actor.world.pos.z; - runAngle = Math_FAtan2F(xDist, zDist) * (32768.0f / M_PI); - runDist = sqrtf((xDist * xDist) + (zDist * zDist)); - - run = false; - - if (runDist <= 10.0f) { - if (this->pathContinue == false) { - this->waypoint++; - - if (this->waypoint >= path->count) { - if (this->flags & 0x20) { - this->waypoint = path->count - 2; - this->pathContinue = true; - this->run = run = false; - - if (this->flags & 0x400) { - this->timer = 2; - EnDaikuKakariko_SetAnimFromIndex(this, 0, &this->currentAnimIndex); - this->actionFunc = EnDaikuKakariko_StopRunning; - return; - } - } else { - this->waypoint = 0; - run = true; - } - } else { - this->run = run = true; - } - } else { - this->waypoint--; - - if (this->waypoint < 0) { - this->waypoint = 1; - this->pathContinue = false; - this->run = run = false; - - if (this->flags & 0x400) { - this->timer = 2; - EnDaikuKakariko_SetAnimFromIndex(this, 0, &this->currentAnimIndex); - this->actionFunc = EnDaikuKakariko_StopRunning; - return; - } - } else { - run = true; - } - } - } - } while (run); - - angleStepDiff = Math_SmoothStepToS(&this->actor.shape.rot.y, runAngle, 1, 5000, 0); - - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (this->run == false) { - if (angleStepDiff == 0) { - this->run = true; - } else { - this->actor.speedXZ = 0.0f; - } - } - - if (this->run == true) { - Math_SmoothStepToF(&this->actor.speedXZ, this->runSpeed, 0.8f, runDist, 0.0f); - } - - Actor_MoveForward(&this->actor); - - if (this->flags & 0x40) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - } else if (this->flags & 0x80) { - this->runFlag |= 1; - this->flags &= ~0x0080; - } else if (this->runFlag & 1) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->runFlag &= ~1; - } - - SkelAnime_Update(&this->skelAnime); - EnDaikuKakariko_HandleTalking(this, globalCtx); - - if (this->talkState != 0) { - this->flags |= 0x200; - EnDaikuKakariko_SetAnimFromIndex(this, 4, &this->currentAnimIndex); - this->actionFunc = EnDaikuKakariko_Talk; - } -} - -void EnDaikuKakariko_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDaikuKakariko* this = (EnDaikuKakariko*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 pad2; - - if (this->currentAnimIndex == 3) { - if (((s32)this->skelAnime.curFrame == 6) || ((s32)this->skelAnime.curFrame == 15)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); - } - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (this->flags & 4) { - this->collider.dim.pos.x -= 27; - this->collider.dim.pos.z -= 27; - this->collider.dim.radius = 63; - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - this->actionFunc(this, globalCtx); - - this->npcInfo.unk_18.x = player->actor.focus.pos.x; - this->npcInfo.unk_18.y = player->actor.focus.pos.y; - this->npcInfo.unk_18.z = player->actor.focus.pos.z; - - if (this->flags & 0x100) { - this->neckAngleTarget.x = 5900; - this->flags |= 0x1000; - func_80034A14(&this->actor, &this->npcInfo, 0, 2); - } else if (this->flags & 0x200) { - this->neckAngleTarget.x = 5900; - this->flags |= 0x1000; - func_80034A14(&this->actor, &this->npcInfo, 0, 4); - } - - Math_SmoothStepToS(&this->neckAngle.x, this->neckAngleTarget.x, 1, 1820, 0); -} - -s32 EnDaikuKakariko_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnDaikuKakariko* this = (EnDaikuKakariko*)thisx; - Vec3s angle; - - switch (limbIndex) { - case 8: - angle = this->npcInfo.unk_0E; - Matrix_RotateX(-(angle.y * (M_PI / 32768.0f)), MTXMODE_APPLY); - Matrix_RotateZ(-(angle.x * (M_PI / 32768.0f)), MTXMODE_APPLY); - break; - case 15: - Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - angle = this->npcInfo.unk_08; - - if (this->flags & 0x1000) { - osSyncPrintf("<%d>\n", this->neckAngle.x); - Matrix_RotateX((angle.y + this->neckAngle.y) * (M_PI / 32768.0f), MTXMODE_APPLY); - Matrix_RotateZ((angle.x + this->neckAngle.x) * (M_PI / 32768.0f), MTXMODE_APPLY); - } else { - Matrix_RotateX(angle.y * (M_PI / 32768.0f), MTXMODE_APPLY); - Matrix_RotateZ(angle.x * (M_PI / 32768.0f), MTXMODE_APPLY); - } - - Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - break; - } - - return 0; -} - -void EnDaikuKakariko_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Gfx* carpenterHeadDLists[] = { object_daiku_DL_005BD0, object_daiku_DL_005AC0, object_daiku_DL_005990, - object_daiku_DL_005880 }; - static Vec3f unkVec = { 700.0f, 1100.0f, 0.0f }; - EnDaikuKakariko* this = (EnDaikuKakariko*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1104); - - if (limbIndex == 15) { - Matrix_MultVec3f(&unkVec, &this->actor.focus.pos); - gSPDisplayList(POLY_OPA_DISP++, carpenterHeadDLists[this->actor.params & 3]); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1113); -} - -void EnDaikuKakariko_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDaikuKakariko* this = (EnDaikuKakariko*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1124); - - func_80093D18(globalCtx->state.gfxCtx); - - if ((thisx->params & 3) == CARPENTER_ICHIRO) { - gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255); - } else if ((thisx->params & 3) == CARPENTER_SABOORO) { - gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255); - } else if ((thisx->params & 3) == CARPENTER_JIRO) { - gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255); - } else if ((thisx->params & 3) == CARPENTER_SHIRO) { - gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); - } - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnDaikuKakariko_OverrideLimbDraw, EnDaikuKakariko_PostLimbDraw, thisx); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1151); -} diff --git a/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.cpp b/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.cpp new file mode 100644 index 000000000..f8639be93 --- /dev/null +++ b/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.cpp @@ -0,0 +1,567 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DAIKU_KAKARIKO_Z_EN_DAIKU_KAKARIKO_C +#include "actor_common.h" +/* + * File: z_en_daiku_kakariko.c + * Overlay: ovl_En_Daiku_Kakariko + * Description: Kakariko Village Carpenters + */ + +#include "z_en_daiku_kakariko.h" +#include "objects/object_daiku/object_daiku.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +typedef enum { + /* 0x0 */ CARPENTER_ICHIRO, // Red and purple pants, normal hair + /* 0x1 */ CARPENTER_SABOORO, // Light blue pants + /* 0x2 */ CARPENTER_JIRO, // Green pants + /* 0x3 */ CARPENTER_SHIRO // Pink and purple pants, two-spiked hair +} KakarikoCarpenterType; + +void EnDaikuKakariko_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDaikuKakariko_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDaikuKakariko_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDaikuKakariko_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDaikuKakariko_Wait(EnDaikuKakariko* pthis, GlobalContext* globalCtx); +void EnDaikuKakariko_Run(EnDaikuKakariko* pthis, GlobalContext* globalCtx); + +ActorInit En_Daiku_Kakariko_InitVars = { + ACTOR_EN_DAIKU_KAKARIKO, + ACTORCAT_NPC, + FLAGS, + OBJECT_DAIKU, + sizeof(EnDaikuKakariko), + (ActorFunc)EnDaikuKakariko_Init, + (ActorFunc)EnDaikuKakariko_Destroy, + (ActorFunc)EnDaikuKakariko_Update, + (ActorFunc)EnDaikuKakariko_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 18, 66, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(0, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(0, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x0), + /* Kokiri sword */ DMG_ENTRY(0, 0x0), + /* Master sword */ DMG_ENTRY(0, 0x0), + /* Giant's Knife */ DMG_ENTRY(0, 0x0), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0x0), + /* Giant spin */ DMG_ENTRY(0, 0x0), + /* Master spin */ DMG_ENTRY(0, 0x0), + /* Kokiri jump */ DMG_ENTRY(0, 0x0), + /* Giant jump */ DMG_ENTRY(0, 0x0), + /* Master jump */ DMG_ENTRY(0, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static struct_D_80AA1678 sAnimations[] = { + { &object_daiku_Anim_001AB0, 1.0f, 2, -7.0f }, { &object_daiku_Anim_007DE0, 1.0f, 0, -7.0f }, + { &object_daiku_Anim_00885C, 1.0f, 0, -7.0f }, { &object_daiku_Anim_000C44, 1.0f, 0, -7.0f }, + { &object_daiku_Anim_000600, 1.0f, 0, -7.0f }, { &object_daiku_Anim_008164, 1.0f, 0, -7.0f }, +}; + +void EnDaikuKakariko_SetAnimFromIndex(EnDaikuKakariko* pthis, s32 animIndex, s32* currentAnimIndex) { + f32 morphFrames; + + if ((*currentAnimIndex < 0) || (animIndex == *currentAnimIndex)) { + morphFrames = 0.0f; + } else { + morphFrames = sAnimations[animIndex].transitionRate; + } + + Animation_Change(&pthis->skelAnime, sAnimations[animIndex].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[animIndex].animation), sAnimations[animIndex].mode, + morphFrames); + + *currentAnimIndex = animIndex; +} + +void EnDaikuKakariko_Init(Actor* thisx, GlobalContext* globalCtx) { + static u16 initFlags[] = { 0x0080, 0x00B0, 0x0070, 0x0470 }; // List of inital values for pthis->flags + EnDaikuKakariko* pthis = (EnDaikuKakariko*)thisx; + s32 pad; + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + switch (globalCtx->sceneNum) { + case SCENE_SPOT01: + if (IS_DAY) { + pthis->flags |= 1; + pthis->flags |= initFlags[pthis->actor.params & 3]; + } + break; + case SCENE_KAKARIKO: + if (IS_NIGHT) { + pthis->flags |= 2; + } + break; + case SCENE_DRAG: + pthis->flags |= 4; + break; + } + } + + if (!(pthis->flags & 7)) { + Actor_Kill(&pthis->actor); + } + + if (IS_NIGHT) { + pthis->flags |= 8; + } + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_daiku_Skel_007958, NULL, pthis->jointTable, pthis->morphTable, + 17); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInit); + + Animation_Change(&pthis->skelAnime, sAnimations->animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations->animation), sAnimations->mode, sAnimations->transitionRate); + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + + pthis->actor.gravity = 0.0f; + pthis->runSpeed = 3.0f; + pthis->actor.uncullZoneForward = 1200.0f; + pthis->actor.targetMode = 6; + pthis->currentAnimIndex = -1; + + if (pthis->flags & 0x40) { + pthis->actor.gravity = -1.0f; + } + + if (pthis->flags & 0x10) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 3, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaikuKakariko_Run; + } else { + if (pthis->flags & 8) { + if (((pthis->actor.params & 3) == CARPENTER_SABOORO) || ((pthis->actor.params & 3) == CARPENTER_SHIRO)) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 5, &pthis->currentAnimIndex); + pthis->flags |= 0x800; + } else { + EnDaikuKakariko_SetAnimFromIndex(pthis, 1, &pthis->currentAnimIndex); + } + + pthis->skelAnime.curFrame = (s32)(Rand_ZeroOne() * pthis->skelAnime.endFrame); + } else { + EnDaikuKakariko_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); + pthis->skelAnime.curFrame = (s32)(Rand_ZeroOne() * pthis->skelAnime.endFrame); + } + + pthis->flags |= 0x100; + pthis->actionFunc = EnDaikuKakariko_Wait; + } +} + +void EnDaikuKakariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDaikuKakariko* pthis = (EnDaikuKakariko*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 EnDaikuKakariko_GetTalkState(EnDaikuKakariko* pthis, GlobalContext* globalCtx) { + s32 talkState = 2; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + switch (pthis->actor.textId) { + case 0x6061: + gSaveContext.infTable[23] |= 0x40; + break; + case 0x6064: + gSaveContext.infTable[23] |= 0x100; + break; + } + talkState = 0; + } + return talkState; +} + +void EnDaikuKakariko_HandleTalking(EnDaikuKakariko* pthis, GlobalContext* globalCtx) { + static s32 maskReactionSets[] = { 1, 2, 3, 4 }; + s16 sp26; + s16 sp24; + + if (pthis->talkState == 2) { + pthis->talkState = EnDaikuKakariko_GetTalkState(pthis, globalCtx); + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->talkState = 2; + } else { + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp26, &sp24); + + if ((sp26 >= 0) && (sp26 <= 320) && (sp24 >= 0) && (sp24 <= 240) && (pthis->talkState == 0) && + (func_8002F2CC(&pthis->actor, globalCtx, 100.0f) == 1)) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, maskReactionSets[pthis->actor.params & 3]); + + if (pthis->actor.textId == 0) { + switch (pthis->actor.params & 3) { + case 0: + if (pthis->flags & 8) { + pthis->actor.textId = 0x5076; + } else { + pthis->actor.textId = 0x5075; + } + break; + case 1: + if (pthis->flags & 1) { + pthis->actor.textId = 0x502A; + } else { + pthis->actor.textId = 0x5074; + } + break; + case 2: + if (pthis->flags & 1) { + pthis->actor.textId = 0x506A; + } else { + pthis->actor.textId = 0x506B; + } + break; + case 3: + if (pthis->flags & 1) { + pthis->actor.textId = 0x5077; + } else { + pthis->actor.textId = 0x5078; + } + break; + } + } + } + } +} + +void EnDaikuKakariko_Talk(EnDaikuKakariko* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 3, &pthis->currentAnimIndex); + } + + EnDaikuKakariko_HandleTalking(pthis, globalCtx); + + if (pthis->talkState == 0) { + if (pthis->flags & 0x10) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 3, &pthis->currentAnimIndex); + pthis->flags &= ~0x0300; + pthis->actionFunc = EnDaikuKakariko_Run; + return; + } + + if (!(pthis->flags & 8)) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); + } + + if ((pthis->flags & 0x800) == 0) { + pthis->flags &= ~0x0200; + pthis->flags |= 0x100; + } + + pthis->actionFunc = EnDaikuKakariko_Wait; + } +} + +void EnDaikuKakariko_Wait(EnDaikuKakariko* pthis, GlobalContext* globalCtx) { + EnDaikuKakariko_HandleTalking(pthis, globalCtx); + + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); + } + + if (pthis->talkState != 0) { + if (!(pthis->flags & 8)) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 4, &pthis->currentAnimIndex); + } + + if (!(pthis->flags & 0x800)) { + pthis->flags |= 0x200; + pthis->flags &= ~0x0100; + } + + pthis->actionFunc = EnDaikuKakariko_Talk; + } +} + +void EnDaikuKakariko_StopRunning(EnDaikuKakariko* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->timer--; + + if (pthis->timer <= 0) { + EnDaikuKakariko_SetAnimFromIndex(pthis, 3, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaikuKakariko_Run; + } else { + pthis->skelAnime.curFrame = pthis->skelAnime.startFrame; + } + } + + EnDaikuKakariko_HandleTalking(pthis, globalCtx); + + if (pthis->talkState != 0) { + pthis->flags |= 0x200; + EnDaikuKakariko_SetAnimFromIndex(pthis, 4, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaikuKakariko_Talk; + } +} + +void EnDaikuKakariko_Run(EnDaikuKakariko* pthis, GlobalContext* globalCtx) { + s32 pad; + Path* path; + Vec3s* pathPos; + f32 xDist; + f32 zDist; + s16 runAngle; + f32 runDist; + s16 angleStepDiff; + s32 run; + + do { + path = &globalCtx->setupPathList[(pthis->actor.params >> 8) & 0xFF]; + pathPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[pthis->waypoint]; + xDist = pathPos->x - pthis->actor.world.pos.x; + zDist = pathPos->z - pthis->actor.world.pos.z; + runAngle = Math_FAtan2F(xDist, zDist) * (32768.0f / M_PI); + runDist = sqrtf((xDist * xDist) + (zDist * zDist)); + + run = false; + + if (runDist <= 10.0f) { + if (pthis->pathContinue == false) { + pthis->waypoint++; + + if (pthis->waypoint >= path->count) { + if (pthis->flags & 0x20) { + pthis->waypoint = path->count - 2; + pthis->pathContinue = true; + pthis->run = run = false; + + if (pthis->flags & 0x400) { + pthis->timer = 2; + EnDaikuKakariko_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaikuKakariko_StopRunning; + return; + } + } else { + pthis->waypoint = 0; + run = true; + } + } else { + pthis->run = run = true; + } + } else { + pthis->waypoint--; + + if (pthis->waypoint < 0) { + pthis->waypoint = 1; + pthis->pathContinue = false; + pthis->run = run = false; + + if (pthis->flags & 0x400) { + pthis->timer = 2; + EnDaikuKakariko_SetAnimFromIndex(pthis, 0, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaikuKakariko_StopRunning; + return; + } + } else { + run = true; + } + } + } + } while (run); + + angleStepDiff = Math_SmoothStepToS(&pthis->actor.shape.rot.y, runAngle, 1, 5000, 0); + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (pthis->run == false) { + if (angleStepDiff == 0) { + pthis->run = true; + } else { + pthis->actor.speedXZ = 0.0f; + } + } + + if (pthis->run == true) { + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->runSpeed, 0.8f, runDist, 0.0f); + } + + Actor_MoveForward(&pthis->actor); + + if (pthis->flags & 0x40) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + } else if (pthis->flags & 0x80) { + pthis->runFlag |= 1; + pthis->flags &= ~0x0080; + } else if (pthis->runFlag & 1) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->runFlag &= ~1; + } + + SkelAnime_Update(&pthis->skelAnime); + EnDaikuKakariko_HandleTalking(pthis, globalCtx); + + if (pthis->talkState != 0) { + pthis->flags |= 0x200; + EnDaikuKakariko_SetAnimFromIndex(pthis, 4, &pthis->currentAnimIndex); + pthis->actionFunc = EnDaikuKakariko_Talk; + } +} + +void EnDaikuKakariko_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDaikuKakariko* pthis = (EnDaikuKakariko*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + + if (pthis->currentAnimIndex == 3) { + if (((s32)pthis->skelAnime.curFrame == 6) || ((s32)pthis->skelAnime.curFrame == 15)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); + } + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (pthis->flags & 4) { + pthis->collider.dim.pos.x -= 27; + pthis->collider.dim.pos.z -= 27; + pthis->collider.dim.radius = 63; + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + pthis->actionFunc(pthis, globalCtx); + + pthis->npcInfo.unk_18.x = player->actor.focus.pos.x; + pthis->npcInfo.unk_18.y = player->actor.focus.pos.y; + pthis->npcInfo.unk_18.z = player->actor.focus.pos.z; + + if (pthis->flags & 0x100) { + pthis->neckAngleTarget.x = 5900; + pthis->flags |= 0x1000; + func_80034A14(&pthis->actor, &pthis->npcInfo, 0, 2); + } else if (pthis->flags & 0x200) { + pthis->neckAngleTarget.x = 5900; + pthis->flags |= 0x1000; + func_80034A14(&pthis->actor, &pthis->npcInfo, 0, 4); + } + + Math_SmoothStepToS(&pthis->neckAngle.x, pthis->neckAngleTarget.x, 1, 1820, 0); +} + +s32 EnDaikuKakariko_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnDaikuKakariko* pthis = (EnDaikuKakariko*)thisx; + Vec3s angle; + + switch (limbIndex) { + case 8: + angle = pthis->npcInfo.unk_0E; + Matrix_RotateX(-(angle.y * (M_PI / 32768.0f)), MTXMODE_APPLY); + Matrix_RotateZ(-(angle.x * (M_PI / 32768.0f)), MTXMODE_APPLY); + break; + case 15: + Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); + angle = pthis->npcInfo.unk_08; + + if (pthis->flags & 0x1000) { + osSyncPrintf("<%d>\n", pthis->neckAngle.x); + Matrix_RotateX((angle.y + pthis->neckAngle.y) * (M_PI / 32768.0f), MTXMODE_APPLY); + Matrix_RotateZ((angle.x + pthis->neckAngle.x) * (M_PI / 32768.0f), MTXMODE_APPLY); + } else { + Matrix_RotateX(angle.y * (M_PI / 32768.0f), MTXMODE_APPLY); + Matrix_RotateZ(angle.x * (M_PI / 32768.0f), MTXMODE_APPLY); + } + + Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); + break; + } + + return 0; +} + +void EnDaikuKakariko_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Gfx* carpenterHeadDLists[] = { object_daiku_DL_005BD0, object_daiku_DL_005AC0, object_daiku_DL_005990, + object_daiku_DL_005880 }; + static Vec3f unkVec = { 700.0f, 1100.0f, 0.0f }; + EnDaikuKakariko* pthis = (EnDaikuKakariko*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1104); + + if (limbIndex == 15) { + Matrix_MultVec3f(&unkVec, &pthis->actor.focus.pos); + gSPDisplayList(POLY_OPA_DISP++, carpenterHeadDLists[pthis->actor.params & 3]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1113); +} + +void EnDaikuKakariko_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDaikuKakariko* pthis = (EnDaikuKakariko*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1124); + + func_80093D18(globalCtx->state.gfxCtx); + + if ((thisx->params & 3) == CARPENTER_ICHIRO) { + gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255); + } else if ((thisx->params & 3) == CARPENTER_SABOORO) { + gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255); + } else if ((thisx->params & 3) == CARPENTER_JIRO) { + gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255); + } else if ((thisx->params & 3) == CARPENTER_SHIRO) { + gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); + } + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnDaikuKakariko_OverrideLimbDraw, EnDaikuKakariko_PostLimbDraw, thisx); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_daiku_kakariko.c", 1151); +} diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c deleted file mode 100644 index c6538f028..000000000 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ /dev/null @@ -1,1330 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DEKUBABA_Z_EN_DEKUBABA_C -#include "actor_common.h" -#include "z_en_dekubaba.h" -#include "objects/object_dekubaba/object_dekubaba.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnDekubaba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDekubaba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDekubaba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDekubaba_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDekubaba_SetupWait(EnDekubaba* this); -void EnDekubaba_SetupGrow(EnDekubaba* this); -void EnDekubaba_Wait(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_Grow(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_Retract(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_DecideLunge(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_Lunge(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_PrepareLunge(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_PullBack(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_Recover(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_Hit(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_StunnedVertical(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_Sway(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_PrunedSomersault(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_ShrinkDie(EnDekubaba* this, GlobalContext* globalCtx); -void EnDekubaba_DeadStickDrop(EnDekubaba* this, GlobalContext* globalCtx); - -static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; - -const ActorInit En_Dekubaba_InitVars = { - ACTOR_EN_DEKUBABA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DEKUBABA, - sizeof(EnDekubaba), - (ActorFunc)EnDekubaba_Init, - (ActorFunc)EnDekubaba_Destroy, - (ActorFunc)EnDekubaba_Update, - (ActorFunc)EnDekubaba_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[7] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 1, { { 0, 100, 1000 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 51, { { 0, 0, 1500 }, 8 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 52, { { 0, 0, 500 }, 8 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 53, { { 0, 0, 1500 }, 8 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 54, { { 0, 0, 500 }, 8 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 55, { { 0, 0, 1500 }, 8 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 56, { { 0, 0, 500 }, 8 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 7, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 25, MASS_IMMOVABLE }; - -typedef enum { - /* 0x0 */ DEKUBABA_DMGEFF_NONE, - /* 0x1 */ DEKUBABA_DMGEFF_DEKUNUT, - /* 0x2 */ DEKUBABA_DMGEFF_FIRE, - /* 0xE */ DEKUBABA_DMGEFF_BOOMERANG = 14, - /* 0xF */ DEKUBABA_DMGEFF_SWORD -} DekuBabaDamageEffect; - -static DamageTable sDekuBabaDamageTable = { - /* Deku nut */ DMG_ENTRY(0, DEKUBABA_DMGEFF_DEKUNUT), - /* Deku stick */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), - /* Explosive */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(2, DEKUBABA_DMGEFF_BOOMERANG), - /* Normal arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Hookshot */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Kokiri sword */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), - /* Master sword */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), - /* Giant's Knife */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), - /* Fire arrow */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), - /* Ice arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Light arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Unk arrow 1 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), - /* Ice magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Light magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Shield */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), - /* Giant spin */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), - /* Master spin */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), - /* Kokiri jump */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), - /* Giant jump */ DMG_ENTRY(8, DEKUBABA_DMGEFF_SWORD), - /* Master jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), - /* Unknown 1 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE), - /* Unknown 2 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), -}; - -// The only difference is that for Big Deku Babas, Hookshot will act the same as Deku Nuts: i.e. it will stun, but -// cannot kill. -static DamageTable sBigDekuBabaDamageTable = { - /* Deku nut */ DMG_ENTRY(0, DEKUBABA_DMGEFF_DEKUNUT), - /* Deku stick */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), - /* Explosive */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(2, DEKUBABA_DMGEFF_BOOMERANG), - /* Normal arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Hookshot */ DMG_ENTRY(0, DEKUBABA_DMGEFF_DEKUNUT), - /* Kokiri sword */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), - /* Master sword */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), - /* Giant's Knife */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), - /* Fire arrow */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), - /* Ice arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Light arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Unk arrow 1 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), - /* Ice magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Light magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Shield */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), - /* Giant spin */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), - /* Master spin */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), - /* Kokiri jump */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), - /* Giant jump */ DMG_ENTRY(8, DEKUBABA_DMGEFF_SWORD), - /* Master jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), - /* Unknown 1 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE), - /* Unknown 2 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_STOP), -}; - -void EnDekubaba_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDekubaba* this = (EnDekubaba*)thisx; - s32 i; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuBabaSkel, &gDekuBabaFastChompAnim, this->jointTable, - this->morphTable, 8); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - - if (this->actor.params == DEKUBABA_BIG) { - this->size = 2.5f; - - for (i = 0; i < sJntSphInit.count; i++) { - this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius = - (sJntSphElementsInit[i].dim.modelSphere.radius * 2.50f); - } - - // This and its counterpart below mean that a Deku Stick jumpslash will not trigger the Deku Stick drop route. - // (Of course they reckoned without each age being able to use the other's items, so Stick and Master Sword - // jumpslash can give the Stick drop as adult, and neither will as child.) - if (!LINK_IS_ADULT) { - sBigDekuBabaDamageTable.table[0x1B] = DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE); // DMG_JUMP_MASTER - } - - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sBigDekuBabaDamageTable, &sColChkInfoInit); - this->actor.colChkInfo.health = 4; - this->actor.naviEnemyId = 0x08; // Big Deku Baba - this->actor.targetMode = 2; - } else { - this->size = 1.0f; - - for (i = 0; i < sJntSphInit.count; i++) { - this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; - } - - if (!LINK_IS_ADULT) { - sDekuBabaDamageTable.table[0x1B] = DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE); // DMG_JUMP_MASTER - } - - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDekuBabaDamageTable, &sColChkInfoInit); - this->actor.naviEnemyId = 0x07; // Deku Baba - this->actor.targetMode = 1; - } - - EnDekubaba_SetupWait(this); - this->timer = 0; - this->boundFloor = NULL; - this->bodyPartsPos[3] = this->actor.home.pos; -} - -void EnDekubaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDekubaba* this = (EnDekubaba*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnDekubaba_DisableHitboxes(EnDekubaba* this) { - s32 i; - - for (i = 1; i < ARRAY_COUNT(this->colliderElements); i++) { - this->collider.elements[i].info.bumperFlags &= ~BUMP_ON; - } -} - -void EnDekubaba_SetupWait(EnDekubaba* this) { - s32 i; - ColliderJntSphElement* element; - - this->actor.shape.rot.x = -0x4000; - this->stemSectionAngle[0] = this->stemSectionAngle[1] = this->stemSectionAngle[2] = this->actor.shape.rot.x; - - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.y = this->actor.home.pos.y + 14.0f * this->size; - - Actor_SetScale(&this->actor, this->size * 0.01f * 0.5f); - - this->collider.base.colType = COLTYPE_HARD; - this->collider.base.acFlags |= AC_HARD; - this->timer = 45; - - for (i = 1; i < ARRAY_COUNT(this->colliderElements); i++) { - element = &this->collider.elements[i]; - element->dim.worldSphere.center.x = this->actor.world.pos.x; - element->dim.worldSphere.center.y = (s16)this->actor.world.pos.y - 7; - element->dim.worldSphere.center.z = this->actor.world.pos.z; - } - - this->actionFunc = EnDekubaba_Wait; -} - -void EnDekubaba_SetupGrow(EnDekubaba* this) { - s32 i; - - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, - Animation_GetLastFrame(&gDekuBabaFastChompAnim) * (1.0f / 15), 0.0f, - Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_ONCE, 0.0f); - - this->timer = 15; - - for (i = 2; i < ARRAY_COUNT(this->colliderElements); i++) { - this->collider.elements[i].info.ocElemFlags |= OCELEM_ON; - } - - this->collider.base.colType = COLTYPE_HIT6; - this->collider.base.acFlags &= ~AC_HARD; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DUMMY482); - this->actionFunc = EnDekubaba_Grow; -} - -void EnDekubaba_SetupRetract(EnDekubaba* this) { - s32 i; - - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, -1.5f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), - 0.0f, ANIMMODE_ONCE, -3.0f); - - this->timer = 15; - - for (i = 2; i < ARRAY_COUNT(this->colliderElements); i++) { - this->collider.elements[i].info.ocElemFlags &= ~OCELEM_ON; - } - - this->actionFunc = EnDekubaba_Retract; -} - -void EnDekubaba_SetupDecideLunge(EnDekubaba* this) { - this->timer = Animation_GetLastFrame(&gDekuBabaFastChompAnim) * 2; - Animation_MorphToLoop(&this->skelAnime, &gDekuBabaFastChompAnim, -3.0f); - this->actionFunc = EnDekubaba_DecideLunge; -} - -void EnDekubaba_SetupPrepareLunge(EnDekubaba* this) { - this->timer = 8; - this->skelAnime.playSpeed = 0.0f; - this->actionFunc = EnDekubaba_PrepareLunge; -} - -void EnDekubaba_SetupLunge(EnDekubaba* this) { - Animation_PlayOnce(&this->skelAnime, &gDekuBabaPauseChompAnim); - this->timer = 0; - this->actionFunc = EnDekubaba_Lunge; -} - -void EnDekubaba_SetupPullBack(EnDekubaba* this) { - Animation_Change(&this->skelAnime, &gDekuBabaPauseChompAnim, 1.0f, 15.0f, - Animation_GetLastFrame(&gDekuBabaPauseChompAnim), ANIMMODE_ONCE, -3.0f); - this->timer = 0; - this->actionFunc = EnDekubaba_PullBack; -} - -void EnDekubaba_SetupRecover(EnDekubaba* this) { - this->timer = 9; - this->collider.base.acFlags |= AC_ON; - this->skelAnime.playSpeed = -1.0f; - this->actionFunc = EnDekubaba_Recover; -} - -void EnDekubaba_SetupHit(EnDekubaba* this, s32 arg1) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDekuBabaPauseChompAnim, -5.0f); - this->timer = arg1; - this->collider.base.acFlags &= ~AC_ON; - Actor_SetScale(&this->actor, this->size * 0.01f); - - if (arg1 == 2) { - Actor_SetColorFilter(&this->actor, 0, 155, 0, 62); - } else { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 42); - } - - this->actionFunc = EnDekubaba_Hit; -} - -void EnDekubaba_SetupPrunedSomersault(EnDekubaba* this) { - this->timer = 0; - this->skelAnime.playSpeed = 0.0f; - this->actor.gravity = -0.8f; - this->actor.velocity.y = 4.0f; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; - this->collider.base.acFlags &= ~AC_ON; - this->actor.speedXZ = this->size * 3.0f; - this->actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - this->actionFunc = EnDekubaba_PrunedSomersault; -} - -void EnDekubaba_SetupShrinkDie(EnDekubaba* this) { - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, -1.5f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), - 0.0f, ANIMMODE_ONCE, -3.0f); - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnDekubaba_ShrinkDie; -} - -void EnDekubaba_SetupStunnedVertical(EnDekubaba* this) { - s32 i; - - for (i = 1; i < ARRAY_COUNT(this->colliderElements); i++) { - this->collider.elements[i].info.bumperFlags |= BUMP_ON; - } - - if (this->timer == 1) { - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 4.0f, 0.0f, - Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); - this->timer = 40; - } else { - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 0.0f, 0.0f, - Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); - this->timer = 60; - } - - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.y = this->actor.home.pos.y + (60.0f * this->size); - this->actor.world.pos.z = this->actor.home.pos.z; - this->actionFunc = EnDekubaba_StunnedVertical; -} - -void EnDekubaba_SetupSway(EnDekubaba* this) { - this->targetSwayAngle = -0x6000; - this->stemSectionAngle[2] = -0x5000; - this->stemSectionAngle[1] = -0x4800; - - EnDekubaba_DisableHitboxes(this); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 35); - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnDekubaba_Sway; -} - -void EnDekubaba_SetupDeadStickDrop(EnDekubaba* this, GlobalContext* globalCtx) { - Actor_SetScale(&this->actor, 0.03f); - this->actor.shape.rot.x -= 0x4000; - this->actor.shape.yOffset = 1000.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.shape.shadowScale = 3.0f; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); - this->actor.flags &= ~ACTOR_FLAG_5; - this->timer = 200; - this->actionFunc = EnDekubaba_DeadStickDrop; -} - -// Action functions - -void EnDekubaba_Wait(EnDekubaba* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.y = this->actor.home.pos.y + 14.0f * this->size; - - if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f * this->size) && - (fabsf(this->actor.yDistToPlayer) < 30.0f * this->size)) { - EnDekubaba_SetupGrow(this); - } -} - -void EnDekubaba_Grow(EnDekubaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 headDistHorizontal; - f32 headDistVertical; - f32 headShiftX; - f32 headShiftZ = 0; - - if (this->timer != 0) { - this->timer--; - } - - SkelAnime_Update(&this->skelAnime); - - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = - this->size * 0.01f * (0.5f + (15 - this->timer) * 0.5f / 15.0f); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1800, 0x800); - - headDistVertical = sinf(CLAMP_MAX((15 - this->timer) * (1.0f / 15), 0.7f) * M_PI) * 32.0f + 14.0f; - - if (this->actor.shape.rot.x < -0x38E3) { - headDistHorizontal = 0.0f; - } else if (this->actor.shape.rot.x < -0x238E) { - Math_ScaledStepToS(&this->stemSectionAngle[0], -0x5555, 0x38E); - headDistHorizontal = Math_CosS(this->stemSectionAngle[0]) * 20.0f; - } else if (this->actor.shape.rot.x < -0xE38) { - Math_ScaledStepToS(&this->stemSectionAngle[0], -0xAAA, 0x38E); - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x5555, 0x38E); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5555, 0x222); - - headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + - (headDistVertical - - 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * - Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); - } else { - Math_ScaledStepToS(&this->stemSectionAngle[0], -0xAAA, 0x38E); - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x31C7, 0x222); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5555, 0x222); - - headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + - (headDistVertical - - 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * - Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); - } - - if (this->timer < 10) { - Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos), 2, - 0xE38); - if (headShiftZ) {} // One way of fake-matching - } - - this->actor.world.pos.y = this->actor.home.pos.y + (headDistVertical * this->size); - headShiftX = headDistHorizontal * this->size * Math_SinS(this->actor.shape.rot.y); - headShiftZ = headDistHorizontal * this->size * Math_CosS(this->actor.shape.rot.y); - this->actor.world.pos.x = this->actor.home.pos.x + headShiftX; - this->actor.world.pos.z = this->actor.home.pos.z + headShiftZ; - - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, this->size * 3.0f, 0, this->size * 12.0f, - this->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); - - if (this->timer == 0) { - if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 240.0f * this->size) { - EnDekubaba_SetupPrepareLunge(this); - } else { - EnDekubaba_SetupRetract(this); - } - } -} - -void EnDekubaba_Retract(EnDekubaba* this, GlobalContext* globalCtx) { - f32 headDistHorizontal; - f32 headDistVertical; - f32 xShift; - f32 zShift; - - if (this->timer != 0) { - this->timer--; - } - - SkelAnime_Update(&this->skelAnime); - - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = - this->size * 0.01f * (0.5f + this->timer * (1.0f / 30)); - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0x300); - - headDistVertical = (sinf(CLAMP_MAX(this->timer * 0.033f, 0.7f) * M_PI) * 32.0f) + 14.0f; - - if (this->actor.shape.rot.x < -0x38E3) { - headDistHorizontal = 0.0f; - } else if (this->actor.shape.rot.x < -0x238E) { - Math_ScaledStepToS(&this->stemSectionAngle[0], -0x4000, 0x555); - headDistHorizontal = Math_CosS(this->stemSectionAngle[0]) * 20.0f; - } else if (this->actor.shape.rot.x < -0xE38) { - Math_ScaledStepToS(&this->stemSectionAngle[0], -0x5555, 0x555); - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x4000, 0x555); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x4000, 0x333); - - headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + - (headDistVertical - - 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * - Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); - } else { - Math_ScaledStepToS(&this->stemSectionAngle[0], -0x5555, 0x555); - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x5555, 0x333); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x4000, 0x333); - - headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + - (headDistVertical - - 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * - Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); - } - - this->actor.world.pos.y = this->actor.home.pos.y + (headDistVertical * this->size); - xShift = headDistHorizontal * this->size * Math_SinS(this->actor.shape.rot.y); - zShift = headDistHorizontal * this->size * Math_CosS(this->actor.shape.rot.y); - this->actor.world.pos.x = this->actor.home.pos.x + xShift; - this->actor.world.pos.z = this->actor.home.pos.z + zShift; - - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, this->size * 3.0f, 0, this->size * 12.0f, - this->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 0xA, NULL); - - if (this->timer == 0) { - EnDekubaba_SetupWait(this); - } -} - -void EnDekubaba_UpdateHeadPosition(EnDekubaba* this) { - f32 horizontalHeadShift = (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1]) + - Math_CosS(this->stemSectionAngle[2])) * - 20.0f; - - this->actor.world.pos.x = - this->actor.home.pos.x + Math_SinS(this->actor.shape.rot.y) * (horizontalHeadShift * this->size); - this->actor.world.pos.y = - this->actor.home.pos.y - (Math_SinS(this->stemSectionAngle[0]) + Math_SinS(this->stemSectionAngle[1]) + - Math_SinS(this->stemSectionAngle[2])) * - 20.0f * this->size; - this->actor.world.pos.z = - this->actor.home.pos.z + Math_CosS(this->actor.shape.rot.y) * (horizontalHeadShift * this->size); -} - -void EnDekubaba_DecideLunge(EnDekubaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { - if (this->actor.params == DEKUBABA_BIG) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_MOUTH); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_MOUTH); - } - } - - if (this->timer != 0) { - this->timer--; - } - - Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos), 2, - (this->timer % 5) * 0x222); - - if (this->timer < 10) { - this->stemSectionAngle[0] += 0x16C; - this->stemSectionAngle[1] += 0x16C; - this->stemSectionAngle[2] += 0xB6; - this->actor.shape.rot.x += 0x222; - } else if (this->timer < 20) { - this->stemSectionAngle[0] -= 0x16C; - this->stemSectionAngle[1] += 0x111; - this->actor.shape.rot.x += 0x16C; - } else if (this->timer < 30) { - this->stemSectionAngle[1] -= 0x111; - this->actor.shape.rot.x -= 0xB6; - } else { - this->stemSectionAngle[1] -= 0xB6; - this->stemSectionAngle[2] += 0xB6; - this->actor.shape.rot.x -= 0x16C; - } - - EnDekubaba_UpdateHeadPosition(this); - - if (240.0f * this->size < Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos)) { - EnDekubaba_SetupRetract(this); - } else if ((this->timer == 0) || (this->actor.xzDistToPlayer < 80.0f * this->size)) { - EnDekubaba_SetupPrepareLunge(this); - } -} - -void EnDekubaba_Lunge(EnDekubaba* this, GlobalContext* globalCtx) { - static Color_RGBA8 primColor = { 105, 255, 105, 255 }; - static Color_RGBA8 envColor = { 150, 250, 150, 0 }; - s32 allStepsDone; - s16 curFrame10; - Vec3f velocity; - - SkelAnime_Update(&this->skelAnime); - - if (this->timer == 0) { - if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - if (this->actor.params == DEKUBABA_BIG) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_ATTACK); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_ATTACK); - } - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x222); - - curFrame10 = this->skelAnime.curFrame * 10.0f; - - allStepsDone = true; - allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[0], -0xE38, curFrame10 + 0x38E); - allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[1], -0xE38, curFrame10 + 0x71C); - allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[2], -0xE38, curFrame10 + 0xE38); - - if (allStepsDone) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gDekuBabaFastChompAnim, 4.0f); - velocity.x = Math_SinS(this->actor.shape.rot.y) * 5.0f; - velocity.y = 0.0f; - velocity.z = Math_CosS(this->actor.shape.rot.y) * 5.0f; - - func_8002829C(globalCtx, &this->actor.world.pos, &velocity, &sZeroVec, &primColor, &envColor, 1, - this->size * 100.0f); - this->timer = 1; - this->collider.base.acFlags |= AC_ON; - } - } else if (this->timer > 10) { - EnDekubaba_SetupPullBack(this); - } else { - this->timer++; - - if ((this->timer >= 4) && !Actor_IsFacingPlayer(&this->actor, 0x16C)) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xF, 0x71C); - } - - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { - if (this->actor.params == DEKUBABA_BIG) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_MOUTH); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_MOUTH); - } - } - } - - EnDekubaba_UpdateHeadPosition(this); -} - -void EnDekubaba_PrepareLunge(EnDekubaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->timer != 0) { - this->timer--; - } - - Math_SmoothStepToS(&this->actor.shape.rot.x, 0x1800, 2, 0xE38, 0x71C); - Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos), 2, 0xE38); - Math_ScaledStepToS(&this->stemSectionAngle[0], 0xAAA, 0x444); - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x4718, 0x888); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x6AA4, 0x888); - - if (this->timer == 0) { - EnDekubaba_SetupLunge(this); - } - - EnDekubaba_UpdateHeadPosition(this); -} - -void EnDekubaba_PullBack(EnDekubaba* this, GlobalContext* globalCtx) { - Vec3f dustPos; - f32 xIncr; - f32 zIncr; - s32 i; - - SkelAnime_Update(&this->skelAnime); - - if (this->timer == 0) { - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x93E, 0x38E); - Math_ScaledStepToS(&this->stemSectionAngle[0], -0x888, 0x16C); - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x888, 0x16C); - if (Math_ScaledStepToS(&this->stemSectionAngle[2], -0x888, 0x16C)) { - xIncr = Math_SinS(this->actor.shape.rot.y) * 30.0f * this->size; - zIncr = Math_CosS(this->actor.shape.rot.y) * 30.0f * this->size; - dustPos = this->actor.home.pos; - - for (i = 0; i < 3; i++) { - func_800286CC(globalCtx, &dustPos, &sZeroVec, &sZeroVec, this->size * 500.0f, this->size * 50.0f); - dustPos.x += xIncr; - dustPos.z += zIncr; - } - - this->timer = 1; - } - } else if (this->timer == 11) { - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x93E, 0x200); - Math_ScaledStepToS(&this->stemSectionAngle[0], -0xAAA, 0x200); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x200); - - if (Math_ScaledStepToS(&this->stemSectionAngle[1], 0x238C, 0x200)) { - this->timer = 12; - } - } else if (this->timer == 18) { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x2AA8, 0xAAA); - - if (Math_ScaledStepToS(&this->stemSectionAngle[0], 0x1554, 0x5B0)) { - this->timer = 25; - } - - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x38E3, 0xAAA); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x2D8); - } else if (this->timer == 25) { - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x5550, 0xAAA); - - if (Math_ScaledStepToS(&this->stemSectionAngle[0], -0x6388, 0x93E)) { - this->timer = 26; - } - - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x3FFC, 0x4FA); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x238C, 0x444); - } else if (this->timer == 26) { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1800, 0x93E); - - if (Math_ScaledStepToS(&this->stemSectionAngle[0], -0x1555, 0x71C)) { - this->timer = 27; - } - - Math_ScaledStepToS(&this->stemSectionAngle[1], -0x38E3, 0x2D8); - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x5B0); - } else if (this->timer >= 27) { - this->timer++; - - if (this->timer > 30) { - if (this->actor.xzDistToPlayer < 80.0f * this->size) { - EnDekubaba_SetupPrepareLunge(this); - } else { - EnDekubaba_SetupDecideLunge(this); - } - } - } else { - this->timer++; - - if (this->timer == 10) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_SCRAPE); - } - - if (this->timer >= 12) { - Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x88); - } - } - - EnDekubaba_UpdateHeadPosition(this); -} - -void EnDekubaba_Recover(EnDekubaba* this, GlobalContext* globalCtx) { - s32 anyStepsDone; - - SkelAnime_Update(&this->skelAnime); - - if (this->timer > 8) { - anyStepsDone = Math_SmoothStepToS(&this->actor.shape.rot.x, 0x1800, 1, 0x11C6, 0x71C); - anyStepsDone |= Math_SmoothStepToS(&this->stemSectionAngle[0], -0x1555, 1, 0xAAA, 0x71C); - anyStepsDone |= Math_SmoothStepToS(&this->stemSectionAngle[1], -0x38E3, 1, 0xE38, 0x71C); - anyStepsDone |= Math_SmoothStepToS(&this->stemSectionAngle[2], -0x5C71, 1, 0x11C6, 0x71C); - - if (!anyStepsDone) { - this->timer = 8; - } - } else { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - EnDekubaba_SetupDecideLunge(this); - } - } - - EnDekubaba_UpdateHeadPosition(this); -} - -/** - * Hit by a weapon or hit something when lunging. - */ -void EnDekubaba_Hit(EnDekubaba* this, GlobalContext* globalCtx) { - s32 allStepsDone; - - SkelAnime_Update(&this->skelAnime); - - allStepsDone = true; - allStepsDone &= Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0xE38); - allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[0], -0x4000, 0xE38); - allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[1], -0x4000, 0xE38); - allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[2], -0x4000, 0xE38); - - if (allStepsDone) { - if (this->actor.colChkInfo.health == 0) { - EnDekubaba_SetupShrinkDie(this); - } else { - this->collider.base.acFlags |= AC_ON; - if (this->timer == 0) { - if (this->actor.xzDistToPlayer < 80.0f * this->size) { - EnDekubaba_SetupPrepareLunge(this); - } else { - EnDekubaba_SetupRecover(this); - } - } else { - EnDekubaba_SetupStunnedVertical(this); - } - } - } - - EnDekubaba_UpdateHeadPosition(this); -} - -void EnDekubaba_StunnedVertical(EnDekubaba* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - EnDekubaba_DisableHitboxes(this); - - if (this->actor.xzDistToPlayer < 80.0f * this->size) { - EnDekubaba_SetupPrepareLunge(this); - } else { - EnDekubaba_SetupRecover(this); - } - } -} - -/** - * Sway back and forth with decaying amplitude until close enough to vertical. - */ -void EnDekubaba_Sway(EnDekubaba* this, GlobalContext* globalCtx) { - s16 angleToVertical; - - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, this->stemSectionAngle[0], 0x71C); - Math_ScaledStepToS(&this->stemSectionAngle[0], this->stemSectionAngle[1], 0x71C); - Math_ScaledStepToS(&this->stemSectionAngle[1], this->stemSectionAngle[2], 0x71C); - - if (Math_ScaledStepToS(&this->stemSectionAngle[2], this->targetSwayAngle, 0x71C)) { - this->targetSwayAngle = -0x4000 - (this->targetSwayAngle + 0x4000) * 0.8f; - } - angleToVertical = this->targetSwayAngle + 0x4000; - - if (ABS(angleToVertical) < 0x100) { - this->collider.base.acFlags |= AC_ON; - if (this->actor.xzDistToPlayer < 80.0f * this->size) { - EnDekubaba_SetupPrepareLunge(this); - } else { - EnDekubaba_SetupRecover(this); - } - } - - EnDekubaba_UpdateHeadPosition(this); -} - -void EnDekubaba_PrunedSomersault(EnDekubaba* this, GlobalContext* globalCtx) { - s32 i; - Vec3f dustPos; - f32 deltaX; - f32 deltaZ; - f32 deltaY; - - Math_StepToF(&this->actor.speedXZ, 0.0f, this->size * 0.1f); - - if (this->timer == 0) { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); - Math_ScaledStepToS(&this->stemSectionAngle[0], 0x4800, 0x71C); - Math_ScaledStepToS(&this->stemSectionAngle[1], 0x4800, 0x71C); - - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, this->size * 3.0f, 0, this->size * 12.0f, - this->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); - - if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, this->size * 3.0f, 0, this->size * 12.0f, - this->size * 5.0f, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - } - - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - this->timer = 1; - } - } else if (this->timer == 1) { - dustPos = this->actor.world.pos; - - deltaY = 20.0f * Math_SinS(this->actor.shape.rot.x); - deltaX = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y); - deltaZ = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y); - - for (i = 0; i < 4; i++) { - func_800286CC(globalCtx, &dustPos, &sZeroVec, &sZeroVec, 500, 50); - dustPos.x += deltaX; - dustPos.y += deltaY; - dustPos.z += deltaZ; - } - - func_800286CC(globalCtx, &this->actor.home.pos, &sZeroVec, &sZeroVec, this->size * 500.0f, this->size * 100.0f); - EnDekubaba_SetupDeadStickDrop(this, globalCtx); - } -} - -/** - * Die and drop Deku Nuts (Stick drop is handled elsewhere) - */ -void EnDekubaba_ShrinkDie(EnDekubaba* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, this->size * 5.0f); - - if (Math_StepToF(&this->actor.scale.x, this->size * 0.1f * 0.01f, this->size * 0.1f * 0.01f)) { - func_800286CC(globalCtx, &this->actor.home.pos, &sZeroVec, &sZeroVec, this->size * 500.0f, this->size * 100.0f); - if (this->actor.dropFlag == 0) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS); - - if (this->actor.params == DEKUBABA_BIG) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS); - } - } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x30); - } - Actor_Kill(&this->actor); - } - - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; - this->actor.shape.rot.z += 0x1C70; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, this->size * 3.0f, 0, this->size * 12.0f, - this->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); -} - -void EnDekubaba_DeadStickDrop(EnDekubaba* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (Actor_HasParent(&this->actor, globalCtx) || (this->timer == 0)) { - Actor_Kill(&this->actor); - return; - } - - func_8002F554(&this->actor, globalCtx, GI_STICKS_1); -} - -// Update and associated functions - -void EnDekubaba_UpdateDamage(EnDekubaba* this, GlobalContext* globalCtx) { - Vec3f* firePos; - f32 fireScale; - s32 phi_s0; // Used for both health and iterator - - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlagJntSph(&this->actor, &this->collider, 1); - - if ((this->collider.base.colType != COLTYPE_HARD) && - ((this->actor.colChkInfo.damageEffect != DEKUBABA_DMGEFF_NONE) || (this->actor.colChkInfo.damage != 0))) { - - phi_s0 = this->actor.colChkInfo.health - this->actor.colChkInfo.damage; - - if (this->actionFunc != EnDekubaba_StunnedVertical) { - if ((this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_BOOMERANG) || - (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_DEKUNUT)) { - if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_BOOMERANG) { - phi_s0 = this->actor.colChkInfo.health; - } - - EnDekubaba_SetupHit(this, 2); - } else if (this->actionFunc == EnDekubaba_PullBack) { - if (phi_s0 <= 0) { - phi_s0 = 1; - } - - EnDekubaba_SetupHit(this, 1); - } else { - EnDekubaba_SetupHit(this, 0); - } - } else if ((this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_BOOMERANG) || - (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_SWORD)) { - if (phi_s0 > 0) { - EnDekubaba_SetupSway(this); - } else { - EnDekubaba_SetupPrunedSomersault(this); - } - } else if (this->actor.colChkInfo.damageEffect != DEKUBABA_DMGEFF_DEKUNUT) { - EnDekubaba_SetupHit(this, 0); - } else { - return; - } - - this->actor.colChkInfo.health = CLAMP_MIN(phi_s0, 0); - - if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_FIRE) { - firePos = &this->actor.world.pos; - fireScale = (this->size * 70.0f); - - for (phi_s0 = 0; phi_s0 < 4; phi_s0++) { - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, firePos, fireScale, 0, 0, phi_s0); - } - } - } else { - return; - } - } else if ((globalCtx->actorCtx.unk_02 != 0) && (this->collider.base.colType != COLTYPE_HARD) && - (this->actionFunc != EnDekubaba_StunnedVertical) && (this->actionFunc != EnDekubaba_Hit) && - (this->actor.colChkInfo.health != 0)) { - this->actor.colChkInfo.health--; - this->actor.dropFlag = 0x00; - EnDekubaba_SetupHit(this, 1); - } else { - return; - } - - if (this->actor.colChkInfo.health != 0) { - if (this->timer == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_DAMAGE); - } - } else { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - if (this->actor.params == DEKUBABA_BIG) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_DEAD); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_DEAD); - } - } -} - -void EnDekubaba_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDekubaba* this = (EnDekubaba*)thisx; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - EnDekubaba_SetupRecover(this); - } - - EnDekubaba_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - - if (this->actionFunc == EnDekubaba_PrunedSomersault) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, this->size * 15.0f, 10.0f, 5); - } else if (this->actionFunc != EnDekubaba_DeadStickDrop) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (this->boundFloor == NULL) { - this->boundFloor = this->actor.floorPoly; - } - } - if (this->actionFunc == EnDekubaba_Lunge) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - this->actor.flags |= ACTOR_FLAG_24; - } - - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (this->actionFunc != EnDekubaba_DeadStickDrop) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -// Draw functions - -void EnDekubaba_DrawStemRetracted(EnDekubaba* this, GlobalContext* globalCtx) { - f32 horizontalScale; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2445); - - horizontalScale = this->size * 0.01f; - - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (-6.0f * this->size), this->actor.home.pos.z, - MTXMODE_NEW); - Matrix_RotateZYX(this->stemSectionAngle[0], this->actor.shape.rot.y, 0, MTXMODE_APPLY); - Matrix_Scale(horizontalScale, horizontalScale, horizontalScale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2461), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemTopDL); - - Actor_SetFocus(&this->actor, 0.0f); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2468); -} - -void EnDekubaba_DrawStemExtended(EnDekubaba* this, GlobalContext* globalCtx) { - static Gfx* stemDLists[] = { gDekuBabaStemTopDL, gDekuBabaStemMiddleDL, gDekuBabaStemBaseDL }; - MtxF mtx; - s32 i; - f32 horizontalStepSize; - f32 spA4; - f32 scale; - s32 stemSections; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2487); - - if (this->actionFunc == EnDekubaba_PrunedSomersault) { - stemSections = 2; - } else { - stemSections = 3; - } - - scale = this->size * 0.01f; - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_Get(&mtx); - if (this->actor.colorFilterTimer != 0) { - spA4 = this->size * 20.0f; - this->bodyPartsPos[2].x = this->actor.world.pos.x; - this->bodyPartsPos[2].y = this->actor.world.pos.y - spA4; - this->bodyPartsPos[2].z = this->actor.world.pos.z; - } - - for (i = 0; i < stemSections; i++) { - mtx.yw += 20.0f * Math_SinS(this->stemSectionAngle[i]) * this->size; - horizontalStepSize = 20.0f * Math_CosS(this->stemSectionAngle[i]) * this->size; - mtx.xw -= horizontalStepSize * Math_SinS(this->actor.shape.rot.y); - mtx.zw -= horizontalStepSize * Math_CosS(this->actor.shape.rot.y); - - Matrix_Put(&mtx); - Matrix_RotateZYX(this->stemSectionAngle[i], this->actor.shape.rot.y, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2533), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(POLY_OPA_DISP++, stemDLists[i]); - - Collider_UpdateSpheres(51 + 2 * i, &this->collider); - Collider_UpdateSpheres(52 + 2 * i, &this->collider); - - if (i == 0) { - if (this->actionFunc != EnDekubaba_Sway) { - this->actor.focus.pos.x = mtx.xw; - this->actor.focus.pos.y = mtx.yw; - this->actor.focus.pos.z = mtx.zw; - } else { - this->actor.focus.pos.x = this->actor.home.pos.x; - this->actor.focus.pos.y = this->actor.home.pos.y + (40.0f * this->size); - this->actor.focus.pos.z = this->actor.home.pos.z; - } - } - - if ((i < 2) && (this->actor.colorFilterTimer != 0)) { - // checking colorFilterTimer ensures that spA4 has been initialized earlier, so not a bug - this->bodyPartsPos[i].x = mtx.xw; - this->bodyPartsPos[i].y = mtx.yw - spA4; - this->bodyPartsPos[i].z = mtx.zw; - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2569); -} - -void EnDekubaba_DrawStemBasePruned(EnDekubaba* this, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2579); - - Matrix_RotateZYX(this->stemSectionAngle[2], this->actor.shape.rot.y, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2586), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemBaseDL); - - Collider_UpdateSpheres(55, &this->collider); - Collider_UpdateSpheres(56, &this->collider); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2596); -} - -void EnDekubaba_DrawBaseShadow(EnDekubaba* this, GlobalContext* globalCtx) { - MtxF mtx; - f32 horizontalScale; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2692); - func_80094044(globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); - - func_80038A28(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &mtx); - Matrix_Mult(&mtx, MTXMODE_NEW); - - horizontalScale = this->size * 0.15f; - Matrix_Scale(horizontalScale, 1.0f, horizontalScale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2710), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2715); -} - -void EnDekubaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnDekubaba* this = (EnDekubaba*)thisx; - - if (limbIndex == 1) { - Collider_UpdateSpheres(limbIndex, &this->collider); - } -} - -void EnDekubaba_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDekubaba* this = (EnDekubaba*)thisx; - f32 scale; - - if (1) {} - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2752); - func_80093D18(globalCtx->state.gfxCtx); - - if (this->actionFunc != EnDekubaba_DeadStickDrop) { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, - EnDekubaba_PostLimbDraw, this); - - if (this->actionFunc == EnDekubaba_Wait) { - EnDekubaba_DrawStemRetracted(this, globalCtx); - } else { - EnDekubaba_DrawStemExtended(this, globalCtx); - } - - scale = this->size * 0.01f; - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.home.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2780), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaBaseLeavesDL); - - if (this->actionFunc == EnDekubaba_PrunedSomersault) { - EnDekubaba_DrawStemBasePruned(this, globalCtx); - } - - if (this->boundFloor != NULL) { - EnDekubaba_DrawBaseShadow(this, globalCtx); - } - - // Display solid until 40 frames left, then blink until killed. - } else if ((this->timer > 40) || ((this->timer % 2) != 0)) { - Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2797), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStickDropDL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2804); -} diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.cpp b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.cpp new file mode 100644 index 000000000..70a5c7af5 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.cpp @@ -0,0 +1,1330 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DEKUBABA_Z_EN_DEKUBABA_C +#include "actor_common.h" +#include "z_en_dekubaba.h" +#include "objects/object_dekubaba/object_dekubaba.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnDekubaba_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDekubaba_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDekubaba_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDekubaba_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDekubaba_SetupWait(EnDekubaba* pthis); +void EnDekubaba_SetupGrow(EnDekubaba* pthis); +void EnDekubaba_Wait(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_Grow(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_Retract(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_DecideLunge(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_Lunge(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_PrepareLunge(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_PullBack(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_Recover(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_Hit(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_StunnedVertical(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_Sway(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_PrunedSomersault(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_ShrinkDie(EnDekubaba* pthis, GlobalContext* globalCtx); +void EnDekubaba_DeadStickDrop(EnDekubaba* pthis, GlobalContext* globalCtx); + +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +ActorInit En_Dekubaba_InitVars = { + ACTOR_EN_DEKUBABA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DEKUBABA, + sizeof(EnDekubaba), + (ActorFunc)EnDekubaba_Init, + (ActorFunc)EnDekubaba_Destroy, + (ActorFunc)EnDekubaba_Update, + (ActorFunc)EnDekubaba_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[7] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 1, { { 0, 100, 1000 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 51, { { 0, 0, 1500 }, 8 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 52, { { 0, 0, 500 }, 8 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 53, { { 0, 0, 1500 }, 8 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 54, { { 0, 0, 500 }, 8 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 55, { { 0, 0, 1500 }, 8 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 56, { { 0, 0, 500 }, 8 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 7, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 25, MASS_IMMOVABLE }; + +typedef enum { + /* 0x0 */ DEKUBABA_DMGEFF_NONE, + /* 0x1 */ DEKUBABA_DMGEFF_DEKUNUT, + /* 0x2 */ DEKUBABA_DMGEFF_FIRE, + /* 0xE */ DEKUBABA_DMGEFF_BOOMERANG = 14, + /* 0xF */ DEKUBABA_DMGEFF_SWORD +} DekuBabaDamageEffect; + +static DamageTable sDekuBabaDamageTable = { + /* Deku nut */ DMG_ENTRY(0, DEKUBABA_DMGEFF_DEKUNUT), + /* Deku stick */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Explosive */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(2, DEKUBABA_DMGEFF_BOOMERANG), + /* Normal arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Kokiri sword */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), + /* Master sword */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), + /* Giant's Knife */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), + /* Fire arrow */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Unk arrow 1 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), + /* Ice magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Light magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Shield */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), + /* Giant spin */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), + /* Master spin */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), + /* Kokiri jump */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), + /* Giant jump */ DMG_ENTRY(8, DEKUBABA_DMGEFF_SWORD), + /* Master jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), + /* Unknown 1 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE), + /* Unknown 2 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), +}; + +// The only difference is that for Big Deku Babas, Hookshot will act the same as Deku Nuts: i.e. it will stun, but +// cannot kill. +static DamageTable sBigDekuBabaDamageTable = { + /* Deku nut */ DMG_ENTRY(0, DEKUBABA_DMGEFF_DEKUNUT), + /* Deku stick */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Explosive */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(2, DEKUBABA_DMGEFF_BOOMERANG), + /* Normal arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DEKUBABA_DMGEFF_DEKUNUT), + /* Kokiri sword */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), + /* Master sword */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), + /* Giant's Knife */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), + /* Fire arrow */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Unk arrow 1 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(4, DEKUBABA_DMGEFF_FIRE), + /* Ice magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Light magic */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Shield */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, DEKUBABA_DMGEFF_SWORD), + /* Giant spin */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), + /* Master spin */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), + /* Kokiri jump */ DMG_ENTRY(2, DEKUBABA_DMGEFF_SWORD), + /* Giant jump */ DMG_ENTRY(8, DEKUBABA_DMGEFF_SWORD), + /* Master jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_SWORD), + /* Unknown 1 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE), + /* Unknown 2 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_STOP), +}; + +void EnDekubaba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDekubaba* pthis = (EnDekubaba*)thisx; + s32 i; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDekuBabaSkel, &gDekuBabaFastChompAnim, pthis->jointTable, + pthis->morphTable, 8); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderElements); + + if (pthis->actor.params == DEKUBABA_BIG) { + pthis->size = 2.5f; + + for (i = 0; i < sJntSphInit.count; i++) { + pthis->collider.elements[i].dim.worldSphere.radius = pthis->collider.elements[i].dim.modelSphere.radius = + (sJntSphElementsInit[i].dim.modelSphere.radius * 2.50f); + } + + // This and its counterpart below mean that a Deku Stick jumpslash will not trigger the Deku Stick drop route. + // (Of course they reckoned without each age being able to use the other's items, so Stick and Master Sword + // jumpslash can give the Stick drop as adult, and neither will as child.) + if (!LINK_IS_ADULT) { + sBigDekuBabaDamageTable.table[0x1B] = DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE); // DMG_JUMP_MASTER + } + + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sBigDekuBabaDamageTable, &sColChkInfoInit); + pthis->actor.colChkInfo.health = 4; + pthis->actor.naviEnemyId = 0x08; // Big Deku Baba + pthis->actor.targetMode = 2; + } else { + pthis->size = 1.0f; + + for (i = 0; i < sJntSphInit.count; i++) { + pthis->collider.elements[i].dim.worldSphere.radius = pthis->collider.elements[i].dim.modelSphere.radius; + } + + if (!LINK_IS_ADULT) { + sDekuBabaDamageTable.table[0x1B] = DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE); // DMG_JUMP_MASTER + } + + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDekuBabaDamageTable, &sColChkInfoInit); + pthis->actor.naviEnemyId = 0x07; // Deku Baba + pthis->actor.targetMode = 1; + } + + EnDekubaba_SetupWait(pthis); + pthis->timer = 0; + pthis->boundFloor = NULL; + pthis->bodyPartsPos[3] = pthis->actor.home.pos; +} + +void EnDekubaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDekubaba* pthis = (EnDekubaba*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnDekubaba_DisableHitboxes(EnDekubaba* pthis) { + s32 i; + + for (i = 1; i < ARRAY_COUNT(pthis->colliderElements); i++) { + pthis->collider.elements[i].info.bumperFlags &= ~BUMP_ON; + } +} + +void EnDekubaba_SetupWait(EnDekubaba* pthis) { + s32 i; + ColliderJntSphElement* element; + + pthis->actor.shape.rot.x = -0x4000; + pthis->stemSectionAngle[0] = pthis->stemSectionAngle[1] = pthis->stemSectionAngle[2] = pthis->actor.shape.rot.x; + + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 14.0f * pthis->size; + + Actor_SetScale(&pthis->actor, pthis->size * 0.01f * 0.5f); + + pthis->collider.base.colType = COLTYPE_HARD; + pthis->collider.base.acFlags |= AC_HARD; + pthis->timer = 45; + + for (i = 1; i < ARRAY_COUNT(pthis->colliderElements); i++) { + element = &pthis->collider.elements[i]; + element->dim.worldSphere.center.x = pthis->actor.world.pos.x; + element->dim.worldSphere.center.y = (s16)pthis->actor.world.pos.y - 7; + element->dim.worldSphere.center.z = pthis->actor.world.pos.z; + } + + pthis->actionFunc = EnDekubaba_Wait; +} + +void EnDekubaba_SetupGrow(EnDekubaba* pthis) { + s32 i; + + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, + Animation_GetLastFrame(&gDekuBabaFastChompAnim) * (1.0f / 15), 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_ONCE, 0.0f); + + pthis->timer = 15; + + for (i = 2; i < ARRAY_COUNT(pthis->colliderElements); i++) { + pthis->collider.elements[i].info.ocElemFlags |= OCELEM_ON; + } + + pthis->collider.base.colType = COLTYPE_HIT6; + pthis->collider.base.acFlags &= ~AC_HARD; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DUMMY482); + pthis->actionFunc = EnDekubaba_Grow; +} + +void EnDekubaba_SetupRetract(EnDekubaba* pthis) { + s32 i; + + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, -1.5f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); + + pthis->timer = 15; + + for (i = 2; i < ARRAY_COUNT(pthis->colliderElements); i++) { + pthis->collider.elements[i].info.ocElemFlags &= ~OCELEM_ON; + } + + pthis->actionFunc = EnDekubaba_Retract; +} + +void EnDekubaba_SetupDecideLunge(EnDekubaba* pthis) { + pthis->timer = Animation_GetLastFrame(&gDekuBabaFastChompAnim) * 2; + Animation_MorphToLoop(&pthis->skelAnime, &gDekuBabaFastChompAnim, -3.0f); + pthis->actionFunc = EnDekubaba_DecideLunge; +} + +void EnDekubaba_SetupPrepareLunge(EnDekubaba* pthis) { + pthis->timer = 8; + pthis->skelAnime.playSpeed = 0.0f; + pthis->actionFunc = EnDekubaba_PrepareLunge; +} + +void EnDekubaba_SetupLunge(EnDekubaba* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gDekuBabaPauseChompAnim); + pthis->timer = 0; + pthis->actionFunc = EnDekubaba_Lunge; +} + +void EnDekubaba_SetupPullBack(EnDekubaba* pthis) { + Animation_Change(&pthis->skelAnime, &gDekuBabaPauseChompAnim, 1.0f, 15.0f, + Animation_GetLastFrame(&gDekuBabaPauseChompAnim), ANIMMODE_ONCE, -3.0f); + pthis->timer = 0; + pthis->actionFunc = EnDekubaba_PullBack; +} + +void EnDekubaba_SetupRecover(EnDekubaba* pthis) { + pthis->timer = 9; + pthis->collider.base.acFlags |= AC_ON; + pthis->skelAnime.playSpeed = -1.0f; + pthis->actionFunc = EnDekubaba_Recover; +} + +void EnDekubaba_SetupHit(EnDekubaba* pthis, s32 arg1) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDekuBabaPauseChompAnim, -5.0f); + pthis->timer = arg1; + pthis->collider.base.acFlags &= ~AC_ON; + Actor_SetScale(&pthis->actor, pthis->size * 0.01f); + + if (arg1 == 2) { + Actor_SetColorFilter(&pthis->actor, 0, 155, 0, 62); + } else { + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 42); + } + + pthis->actionFunc = EnDekubaba_Hit; +} + +void EnDekubaba_SetupPrunedSomersault(EnDekubaba* pthis) { + pthis->timer = 0; + pthis->skelAnime.playSpeed = 0.0f; + pthis->actor.gravity = -0.8f; + pthis->actor.velocity.y = 4.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x8000; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.speedXZ = pthis->size * 3.0f; + pthis->actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + pthis->actionFunc = EnDekubaba_PrunedSomersault; +} + +void EnDekubaba_SetupShrinkDie(EnDekubaba* pthis) { + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, -1.5f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnDekubaba_ShrinkDie; +} + +void EnDekubaba_SetupStunnedVertical(EnDekubaba* pthis) { + s32 i; + + for (i = 1; i < ARRAY_COUNT(pthis->colliderElements); i++) { + pthis->collider.elements[i].info.bumperFlags |= BUMP_ON; + } + + if (pthis->timer == 1) { + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, 4.0f, 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); + pthis->timer = 40; + } else { + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, 0.0f, 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); + pthis->timer = 60; + } + + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (60.0f * pthis->size); + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + pthis->actionFunc = EnDekubaba_StunnedVertical; +} + +void EnDekubaba_SetupSway(EnDekubaba* pthis) { + pthis->targetSwayAngle = -0x6000; + pthis->stemSectionAngle[2] = -0x5000; + pthis->stemSectionAngle[1] = -0x4800; + + EnDekubaba_DisableHitboxes(pthis); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 35); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnDekubaba_Sway; +} + +void EnDekubaba_SetupDeadStickDrop(EnDekubaba* pthis, GlobalContext* globalCtx) { + Actor_SetScale(&pthis->actor, 0.03f); + pthis->actor.shape.rot.x -= 0x4000; + pthis->actor.shape.yOffset = 1000.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.shape.shadowScale = 3.0f; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_MISC); + pthis->actor.flags &= ~ACTOR_FLAG_5; + pthis->timer = 200; + pthis->actionFunc = EnDekubaba_DeadStickDrop; +} + +// Action functions + +void EnDekubaba_Wait(EnDekubaba* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 14.0f * pthis->size; + + if ((pthis->timer == 0) && (pthis->actor.xzDistToPlayer < 200.0f * pthis->size) && + (fabsf(pthis->actor.yDistToPlayer) < 30.0f * pthis->size)) { + EnDekubaba_SetupGrow(pthis); + } +} + +void EnDekubaba_Grow(EnDekubaba* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 headDistHorizontal; + f32 headDistVertical; + f32 headShiftX; + f32 headShiftZ = 0; + + if (pthis->timer != 0) { + pthis->timer--; + } + + SkelAnime_Update(&pthis->skelAnime); + + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = + pthis->size * 0.01f * (0.5f + (15 - pthis->timer) * 0.5f / 15.0f); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x1800, 0x800); + + headDistVertical = sinf(CLAMP_MAX((15 - pthis->timer) * (1.0f / 15), 0.7f) * M_PI) * 32.0f + 14.0f; + + if (pthis->actor.shape.rot.x < -0x38E3) { + headDistHorizontal = 0.0f; + } else if (pthis->actor.shape.rot.x < -0x238E) { + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x5555, 0x38E); + headDistHorizontal = Math_CosS(pthis->stemSectionAngle[0]) * 20.0f; + } else if (pthis->actor.shape.rot.x < -0xE38) { + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0xAAA, 0x38E); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x5555, 0x38E); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x5555, 0x222); + + headDistHorizontal = 20.0f * (Math_CosS(pthis->stemSectionAngle[0]) + Math_CosS(pthis->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(pthis->stemSectionAngle[0]) - Math_SinS(pthis->stemSectionAngle[1]))) * + Math_CosS(pthis->stemSectionAngle[2]) / -Math_SinS(pthis->stemSectionAngle[2]); + } else { + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0xAAA, 0x38E); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x31C7, 0x222); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x5555, 0x222); + + headDistHorizontal = 20.0f * (Math_CosS(pthis->stemSectionAngle[0]) + Math_CosS(pthis->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(pthis->stemSectionAngle[0]) - Math_SinS(pthis->stemSectionAngle[1]))) * + Math_CosS(pthis->stemSectionAngle[2]) / -Math_SinS(pthis->stemSectionAngle[2]); + } + + if (pthis->timer < 10) { + Math_ApproachS(&pthis->actor.shape.rot.y, Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos), 2, + 0xE38); + if (headShiftZ) {} // One way of fake-matching + } + + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (headDistVertical * pthis->size); + headShiftX = headDistHorizontal * pthis->size * Math_SinS(pthis->actor.shape.rot.y); + headShiftZ = headDistHorizontal * pthis->size * Math_CosS(pthis->actor.shape.rot.y); + pthis->actor.world.pos.x = pthis->actor.home.pos.x + headShiftX; + pthis->actor.world.pos.z = pthis->actor.home.pos.z + headShiftZ; + + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.home.pos, pthis->size * 3.0f, 0, pthis->size * 12.0f, + pthis->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if (pthis->timer == 0) { + if (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < 240.0f * pthis->size) { + EnDekubaba_SetupPrepareLunge(pthis); + } else { + EnDekubaba_SetupRetract(pthis); + } + } +} + +void EnDekubaba_Retract(EnDekubaba* pthis, GlobalContext* globalCtx) { + f32 headDistHorizontal; + f32 headDistVertical; + f32 xShift; + f32 zShift; + + if (pthis->timer != 0) { + pthis->timer--; + } + + SkelAnime_Update(&pthis->skelAnime); + + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = + pthis->size * 0.01f * (0.5f + pthis->timer * (1.0f / 30)); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x4000, 0x300); + + headDistVertical = (sinf(CLAMP_MAX(pthis->timer * 0.033f, 0.7f) * M_PI) * 32.0f) + 14.0f; + + if (pthis->actor.shape.rot.x < -0x38E3) { + headDistHorizontal = 0.0f; + } else if (pthis->actor.shape.rot.x < -0x238E) { + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x4000, 0x555); + headDistHorizontal = Math_CosS(pthis->stemSectionAngle[0]) * 20.0f; + } else if (pthis->actor.shape.rot.x < -0xE38) { + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x5555, 0x555); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x4000, 0x555); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x4000, 0x333); + + headDistHorizontal = 20.0f * (Math_CosS(pthis->stemSectionAngle[0]) + Math_CosS(pthis->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(pthis->stemSectionAngle[0]) - Math_SinS(pthis->stemSectionAngle[1]))) * + Math_CosS(pthis->stemSectionAngle[2]) / -Math_SinS(pthis->stemSectionAngle[2]); + } else { + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x5555, 0x555); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x5555, 0x333); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x4000, 0x333); + + headDistHorizontal = 20.0f * (Math_CosS(pthis->stemSectionAngle[0]) + Math_CosS(pthis->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(pthis->stemSectionAngle[0]) - Math_SinS(pthis->stemSectionAngle[1]))) * + Math_CosS(pthis->stemSectionAngle[2]) / -Math_SinS(pthis->stemSectionAngle[2]); + } + + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (headDistVertical * pthis->size); + xShift = headDistHorizontal * pthis->size * Math_SinS(pthis->actor.shape.rot.y); + zShift = headDistHorizontal * pthis->size * Math_CosS(pthis->actor.shape.rot.y); + pthis->actor.world.pos.x = pthis->actor.home.pos.x + xShift; + pthis->actor.world.pos.z = pthis->actor.home.pos.z + zShift; + + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.home.pos, pthis->size * 3.0f, 0, pthis->size * 12.0f, + pthis->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 0xA, NULL); + + if (pthis->timer == 0) { + EnDekubaba_SetupWait(pthis); + } +} + +void EnDekubaba_UpdateHeadPosition(EnDekubaba* pthis) { + f32 horizontalHeadShift = (Math_CosS(pthis->stemSectionAngle[0]) + Math_CosS(pthis->stemSectionAngle[1]) + + Math_CosS(pthis->stemSectionAngle[2])) * + 20.0f; + + pthis->actor.world.pos.x = + pthis->actor.home.pos.x + Math_SinS(pthis->actor.shape.rot.y) * (horizontalHeadShift * pthis->size); + pthis->actor.world.pos.y = + pthis->actor.home.pos.y - (Math_SinS(pthis->stemSectionAngle[0]) + Math_SinS(pthis->stemSectionAngle[1]) + + Math_SinS(pthis->stemSectionAngle[2])) * + 20.0f * pthis->size; + pthis->actor.world.pos.z = + pthis->actor.home.pos.z + Math_CosS(pthis->actor.shape.rot.y) * (horizontalHeadShift * pthis->size); +} + +void EnDekubaba_DecideLunge(EnDekubaba* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + if (pthis->actor.params == DEKUBABA_BIG) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_MOUTH); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_MOUTH); + } + } + + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_ApproachS(&pthis->actor.shape.rot.y, Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos), 2, + (pthis->timer % 5) * 0x222); + + if (pthis->timer < 10) { + pthis->stemSectionAngle[0] += 0x16C; + pthis->stemSectionAngle[1] += 0x16C; + pthis->stemSectionAngle[2] += 0xB6; + pthis->actor.shape.rot.x += 0x222; + } else if (pthis->timer < 20) { + pthis->stemSectionAngle[0] -= 0x16C; + pthis->stemSectionAngle[1] += 0x111; + pthis->actor.shape.rot.x += 0x16C; + } else if (pthis->timer < 30) { + pthis->stemSectionAngle[1] -= 0x111; + pthis->actor.shape.rot.x -= 0xB6; + } else { + pthis->stemSectionAngle[1] -= 0xB6; + pthis->stemSectionAngle[2] += 0xB6; + pthis->actor.shape.rot.x -= 0x16C; + } + + EnDekubaba_UpdateHeadPosition(pthis); + + if (240.0f * pthis->size < Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos)) { + EnDekubaba_SetupRetract(pthis); + } else if ((pthis->timer == 0) || (pthis->actor.xzDistToPlayer < 80.0f * pthis->size)) { + EnDekubaba_SetupPrepareLunge(pthis); + } +} + +void EnDekubaba_Lunge(EnDekubaba* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 primColor = { 105, 255, 105, 255 }; + static Color_RGBA8 envColor = { 150, 250, 150, 0 }; + s32 allStepsDone; + s16 curFrame10; + Vec3f velocity; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer == 0) { + if (Animation_OnFrame(&pthis->skelAnime, 1.0f)) { + if (pthis->actor.params == DEKUBABA_BIG) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_ATTACK); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_ATTACK); + } + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x222); + + curFrame10 = pthis->skelAnime.curFrame * 10.0f; + + allStepsDone = true; + allStepsDone &= Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0xE38, curFrame10 + 0x38E); + allStepsDone &= Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0xE38, curFrame10 + 0x71C); + allStepsDone &= Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0xE38, curFrame10 + 0xE38); + + if (allStepsDone) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gDekuBabaFastChompAnim, 4.0f); + velocity.x = Math_SinS(pthis->actor.shape.rot.y) * 5.0f; + velocity.y = 0.0f; + velocity.z = Math_CosS(pthis->actor.shape.rot.y) * 5.0f; + + func_8002829C(globalCtx, &pthis->actor.world.pos, &velocity, &sZeroVec, &primColor, &envColor, 1, + pthis->size * 100.0f); + pthis->timer = 1; + pthis->collider.base.acFlags |= AC_ON; + } + } else if (pthis->timer > 10) { + EnDekubaba_SetupPullBack(pthis); + } else { + pthis->timer++; + + if ((pthis->timer >= 4) && !Actor_IsFacingPlayer(&pthis->actor, 0x16C)) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xF, 0x71C); + } + + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + if (pthis->actor.params == DEKUBABA_BIG) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_MOUTH); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_MOUTH); + } + } + } + + EnDekubaba_UpdateHeadPosition(pthis); +} + +void EnDekubaba_PrepareLunge(EnDekubaba* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0x1800, 2, 0xE38, 0x71C); + Math_ApproachS(&pthis->actor.shape.rot.y, Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos), 2, 0xE38); + Math_ScaledStepToS(&pthis->stemSectionAngle[0], 0xAAA, 0x444); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x4718, 0x888); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x6AA4, 0x888); + + if (pthis->timer == 0) { + EnDekubaba_SetupLunge(pthis); + } + + EnDekubaba_UpdateHeadPosition(pthis); +} + +void EnDekubaba_PullBack(EnDekubaba* pthis, GlobalContext* globalCtx) { + Vec3f dustPos; + f32 xIncr; + f32 zIncr; + s32 i; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer == 0) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x93E, 0x38E); + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x888, 0x16C); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x888, 0x16C); + if (Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x888, 0x16C)) { + xIncr = Math_SinS(pthis->actor.shape.rot.y) * 30.0f * pthis->size; + zIncr = Math_CosS(pthis->actor.shape.rot.y) * 30.0f * pthis->size; + dustPos = pthis->actor.home.pos; + + for (i = 0; i < 3; i++) { + func_800286CC(globalCtx, &dustPos, &sZeroVec, &sZeroVec, pthis->size * 500.0f, pthis->size * 50.0f); + dustPos.x += xIncr; + dustPos.z += zIncr; + } + + pthis->timer = 1; + } + } else if (pthis->timer == 11) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x93E, 0x200); + Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0xAAA, 0x200); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x5C71, 0x200); + + if (Math_ScaledStepToS(&pthis->stemSectionAngle[1], 0x238C, 0x200)) { + pthis->timer = 12; + } + } else if (pthis->timer == 18) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x2AA8, 0xAAA); + + if (Math_ScaledStepToS(&pthis->stemSectionAngle[0], 0x1554, 0x5B0)) { + pthis->timer = 25; + } + + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x38E3, 0xAAA); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x5C71, 0x2D8); + } else if (pthis->timer == 25) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x5550, 0xAAA); + + if (Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x6388, 0x93E)) { + pthis->timer = 26; + } + + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x3FFC, 0x4FA); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x238C, 0x444); + } else if (pthis->timer == 26) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x1800, 0x93E); + + if (Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x1555, 0x71C)) { + pthis->timer = 27; + } + + Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x38E3, 0x2D8); + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x5C71, 0x5B0); + } else if (pthis->timer >= 27) { + pthis->timer++; + + if (pthis->timer > 30) { + if (pthis->actor.xzDistToPlayer < 80.0f * pthis->size) { + EnDekubaba_SetupPrepareLunge(pthis); + } else { + EnDekubaba_SetupDecideLunge(pthis); + } + } + } else { + pthis->timer++; + + if (pthis->timer == 10) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_SCRAPE); + } + + if (pthis->timer >= 12) { + Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x5C71, 0x88); + } + } + + EnDekubaba_UpdateHeadPosition(pthis); +} + +void EnDekubaba_Recover(EnDekubaba* pthis, GlobalContext* globalCtx) { + s32 anyStepsDone; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer > 8) { + anyStepsDone = Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0x1800, 1, 0x11C6, 0x71C); + anyStepsDone |= Math_SmoothStepToS(&pthis->stemSectionAngle[0], -0x1555, 1, 0xAAA, 0x71C); + anyStepsDone |= Math_SmoothStepToS(&pthis->stemSectionAngle[1], -0x38E3, 1, 0xE38, 0x71C); + anyStepsDone |= Math_SmoothStepToS(&pthis->stemSectionAngle[2], -0x5C71, 1, 0x11C6, 0x71C); + + if (!anyStepsDone) { + pthis->timer = 8; + } + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + EnDekubaba_SetupDecideLunge(pthis); + } + } + + EnDekubaba_UpdateHeadPosition(pthis); +} + +/** + * Hit by a weapon or hit something when lunging. + */ +void EnDekubaba_Hit(EnDekubaba* pthis, GlobalContext* globalCtx) { + s32 allStepsDone; + + SkelAnime_Update(&pthis->skelAnime); + + allStepsDone = true; + allStepsDone &= Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x4000, 0xE38); + allStepsDone &= Math_ScaledStepToS(&pthis->stemSectionAngle[0], -0x4000, 0xE38); + allStepsDone &= Math_ScaledStepToS(&pthis->stemSectionAngle[1], -0x4000, 0xE38); + allStepsDone &= Math_ScaledStepToS(&pthis->stemSectionAngle[2], -0x4000, 0xE38); + + if (allStepsDone) { + if (pthis->actor.colChkInfo.health == 0) { + EnDekubaba_SetupShrinkDie(pthis); + } else { + pthis->collider.base.acFlags |= AC_ON; + if (pthis->timer == 0) { + if (pthis->actor.xzDistToPlayer < 80.0f * pthis->size) { + EnDekubaba_SetupPrepareLunge(pthis); + } else { + EnDekubaba_SetupRecover(pthis); + } + } else { + EnDekubaba_SetupStunnedVertical(pthis); + } + } + } + + EnDekubaba_UpdateHeadPosition(pthis); +} + +void EnDekubaba_StunnedVertical(EnDekubaba* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + EnDekubaba_DisableHitboxes(pthis); + + if (pthis->actor.xzDistToPlayer < 80.0f * pthis->size) { + EnDekubaba_SetupPrepareLunge(pthis); + } else { + EnDekubaba_SetupRecover(pthis); + } + } +} + +/** + * Sway back and forth with decaying amplitude until close enough to vertical. + */ +void EnDekubaba_Sway(EnDekubaba* pthis, GlobalContext* globalCtx) { + s16 angleToVertical; + + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->stemSectionAngle[0], 0x71C); + Math_ScaledStepToS(&pthis->stemSectionAngle[0], pthis->stemSectionAngle[1], 0x71C); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], pthis->stemSectionAngle[2], 0x71C); + + if (Math_ScaledStepToS(&pthis->stemSectionAngle[2], pthis->targetSwayAngle, 0x71C)) { + pthis->targetSwayAngle = -0x4000 - (pthis->targetSwayAngle + 0x4000) * 0.8f; + } + angleToVertical = pthis->targetSwayAngle + 0x4000; + + if (ABS(angleToVertical) < 0x100) { + pthis->collider.base.acFlags |= AC_ON; + if (pthis->actor.xzDistToPlayer < 80.0f * pthis->size) { + EnDekubaba_SetupPrepareLunge(pthis); + } else { + EnDekubaba_SetupRecover(pthis); + } + } + + EnDekubaba_UpdateHeadPosition(pthis); +} + +void EnDekubaba_PrunedSomersault(EnDekubaba* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f dustPos; + f32 deltaX; + f32 deltaZ; + f32 deltaY; + + Math_StepToF(&pthis->actor.speedXZ, 0.0f, pthis->size * 0.1f); + + if (pthis->timer == 0) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x4800, 0x71C); + Math_ScaledStepToS(&pthis->stemSectionAngle[0], 0x4800, 0x71C); + Math_ScaledStepToS(&pthis->stemSectionAngle[1], 0x4800, 0x71C); + + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, pthis->size * 3.0f, 0, pthis->size * 12.0f, + pthis->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if ((pthis->actor.scale.x > 0.005f) && ((pthis->actor.bgCheckFlags & 2) || (pthis->actor.bgCheckFlags & 8))) { + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, pthis->size * 3.0f, 0, pthis->size * 12.0f, + pthis->size * 5.0f, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + } + + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + pthis->timer = 1; + } + } else if (pthis->timer == 1) { + dustPos = pthis->actor.world.pos; + + deltaY = 20.0f * Math_SinS(pthis->actor.shape.rot.x); + deltaX = -20.0f * Math_CosS(pthis->actor.shape.rot.x) * Math_SinS(pthis->actor.shape.rot.y); + deltaZ = -20.0f * Math_CosS(pthis->actor.shape.rot.x) * Math_CosS(pthis->actor.shape.rot.y); + + for (i = 0; i < 4; i++) { + func_800286CC(globalCtx, &dustPos, &sZeroVec, &sZeroVec, 500, 50); + dustPos.x += deltaX; + dustPos.y += deltaY; + dustPos.z += deltaZ; + } + + func_800286CC(globalCtx, &pthis->actor.home.pos, &sZeroVec, &sZeroVec, pthis->size * 500.0f, pthis->size * 100.0f); + EnDekubaba_SetupDeadStickDrop(pthis, globalCtx); + } +} + +/** + * Die and drop Deku Nuts (Stick drop is handled elsewhere) + */ +void EnDekubaba_ShrinkDie(EnDekubaba* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, pthis->size * 5.0f); + + if (Math_StepToF(&pthis->actor.scale.x, pthis->size * 0.1f * 0.01f, pthis->size * 0.1f * 0.01f)) { + func_800286CC(globalCtx, &pthis->actor.home.pos, &sZeroVec, &sZeroVec, pthis->size * 500.0f, pthis->size * 100.0f); + if (pthis->actor.dropFlag == 0) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_NUTS); + + if (pthis->actor.params == DEKUBABA_BIG) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_NUTS); + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_NUTS); + } + } else { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x30); + } + Actor_Kill(&pthis->actor); + } + + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; + pthis->actor.shape.rot.z += 0x1C70; + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.home.pos, pthis->size * 3.0f, 0, pthis->size * 12.0f, + pthis->size * 5.0f, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); +} + +void EnDekubaba_DeadStickDrop(EnDekubaba* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (Actor_HasParent(&pthis->actor, globalCtx) || (pthis->timer == 0)) { + Actor_Kill(&pthis->actor); + return; + } + + func_8002F554(&pthis->actor, globalCtx, GI_STICKS_1); +} + +// Update and associated functions + +void EnDekubaba_UpdateDamage(EnDekubaba* pthis, GlobalContext* globalCtx) { + Vec3f* firePos; + f32 fireScale; + s32 phi_s0; // Used for both health and iterator + + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlagJntSph(&pthis->actor, &pthis->collider, 1); + + if ((pthis->collider.base.colType != COLTYPE_HARD) && + ((pthis->actor.colChkInfo.damageEffect != DEKUBABA_DMGEFF_NONE) || (pthis->actor.colChkInfo.damage != 0))) { + + phi_s0 = pthis->actor.colChkInfo.health - pthis->actor.colChkInfo.damage; + + if (pthis->actionFunc != EnDekubaba_StunnedVertical) { + if ((pthis->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_BOOMERANG) || + (pthis->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_DEKUNUT)) { + if (pthis->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_BOOMERANG) { + phi_s0 = pthis->actor.colChkInfo.health; + } + + EnDekubaba_SetupHit(pthis, 2); + } else if (pthis->actionFunc == EnDekubaba_PullBack) { + if (phi_s0 <= 0) { + phi_s0 = 1; + } + + EnDekubaba_SetupHit(pthis, 1); + } else { + EnDekubaba_SetupHit(pthis, 0); + } + } else if ((pthis->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_BOOMERANG) || + (pthis->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_SWORD)) { + if (phi_s0 > 0) { + EnDekubaba_SetupSway(pthis); + } else { + EnDekubaba_SetupPrunedSomersault(pthis); + } + } else if (pthis->actor.colChkInfo.damageEffect != DEKUBABA_DMGEFF_DEKUNUT) { + EnDekubaba_SetupHit(pthis, 0); + } else { + return; + } + + pthis->actor.colChkInfo.health = CLAMP_MIN(phi_s0, 0); + + if (pthis->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_FIRE) { + firePos = &pthis->actor.world.pos; + fireScale = (pthis->size * 70.0f); + + for (phi_s0 = 0; phi_s0 < 4; phi_s0++) { + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, firePos, fireScale, 0, 0, phi_s0); + } + } + } else { + return; + } + } else if ((globalCtx->actorCtx.unk_02 != 0) && (pthis->collider.base.colType != COLTYPE_HARD) && + (pthis->actionFunc != EnDekubaba_StunnedVertical) && (pthis->actionFunc != EnDekubaba_Hit) && + (pthis->actor.colChkInfo.health != 0)) { + pthis->actor.colChkInfo.health--; + pthis->actor.dropFlag = 0x00; + EnDekubaba_SetupHit(pthis, 1); + } else { + return; + } + + if (pthis->actor.colChkInfo.health != 0) { + if (pthis->timer == 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_DAMAGE); + } + } else { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + if (pthis->actor.params == DEKUBABA_BIG) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_DEAD); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_DEAD); + } + } +} + +void EnDekubaba_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDekubaba* pthis = (EnDekubaba*)thisx; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + EnDekubaba_SetupRecover(pthis); + } + + EnDekubaba_UpdateDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actionFunc == EnDekubaba_PrunedSomersault) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, pthis->size * 15.0f, 10.0f, 5); + } else if (pthis->actionFunc != EnDekubaba_DeadStickDrop) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if (pthis->boundFloor == NULL) { + pthis->boundFloor = pthis->actor.floorPoly; + } + } + if (pthis->actionFunc == EnDekubaba_Lunge) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + pthis->actor.flags |= ACTOR_FLAG_24; + } + + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (pthis->actionFunc != EnDekubaba_DeadStickDrop) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +// Draw functions + +void EnDekubaba_DrawStemRetracted(EnDekubaba* pthis, GlobalContext* globalCtx) { + f32 horizontalScale; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2445); + + horizontalScale = pthis->size * 0.01f; + + Matrix_Translate(pthis->actor.home.pos.x, pthis->actor.home.pos.y + (-6.0f * pthis->size), pthis->actor.home.pos.z, + MTXMODE_NEW); + Matrix_RotateZYX(pthis->stemSectionAngle[0], pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Scale(horizontalScale, horizontalScale, horizontalScale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2461), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemTopDL); + + Actor_SetFocus(&pthis->actor, 0.0f); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2468); +} + +void EnDekubaba_DrawStemExtended(EnDekubaba* pthis, GlobalContext* globalCtx) { + static Gfx* stemDLists[] = { gDekuBabaStemTopDL, gDekuBabaStemMiddleDL, gDekuBabaStemBaseDL }; + MtxF mtx; + s32 i; + f32 horizontalStepSize; + f32 spA4; + f32 scale; + s32 stemSections; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2487); + + if (pthis->actionFunc == EnDekubaba_PrunedSomersault) { + stemSections = 2; + } else { + stemSections = 3; + } + + scale = pthis->size * 0.01f; + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Get(&mtx); + if (pthis->actor.colorFilterTimer != 0) { + spA4 = pthis->size * 20.0f; + pthis->bodyPartsPos[2].x = pthis->actor.world.pos.x; + pthis->bodyPartsPos[2].y = pthis->actor.world.pos.y - spA4; + pthis->bodyPartsPos[2].z = pthis->actor.world.pos.z; + } + + for (i = 0; i < stemSections; i++) { + mtx.yw += 20.0f * Math_SinS(pthis->stemSectionAngle[i]) * pthis->size; + horizontalStepSize = 20.0f * Math_CosS(pthis->stemSectionAngle[i]) * pthis->size; + mtx.xw -= horizontalStepSize * Math_SinS(pthis->actor.shape.rot.y); + mtx.zw -= horizontalStepSize * Math_CosS(pthis->actor.shape.rot.y); + + Matrix_Put(&mtx); + Matrix_RotateZYX(pthis->stemSectionAngle[i], pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2533), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, stemDLists[i]); + + Collider_UpdateSpheres(51 + 2 * i, &pthis->collider); + Collider_UpdateSpheres(52 + 2 * i, &pthis->collider); + + if (i == 0) { + if (pthis->actionFunc != EnDekubaba_Sway) { + pthis->actor.focus.pos.x = mtx.xw; + pthis->actor.focus.pos.y = mtx.yw; + pthis->actor.focus.pos.z = mtx.zw; + } else { + pthis->actor.focus.pos.x = pthis->actor.home.pos.x; + pthis->actor.focus.pos.y = pthis->actor.home.pos.y + (40.0f * pthis->size); + pthis->actor.focus.pos.z = pthis->actor.home.pos.z; + } + } + + if ((i < 2) && (pthis->actor.colorFilterTimer != 0)) { + // checking colorFilterTimer ensures that spA4 has been initialized earlier, so not a bug + pthis->bodyPartsPos[i].x = mtx.xw; + pthis->bodyPartsPos[i].y = mtx.yw - spA4; + pthis->bodyPartsPos[i].z = mtx.zw; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2569); +} + +void EnDekubaba_DrawStemBasePruned(EnDekubaba* pthis, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2579); + + Matrix_RotateZYX(pthis->stemSectionAngle[2], pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2586), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemBaseDL); + + Collider_UpdateSpheres(55, &pthis->collider); + Collider_UpdateSpheres(56, &pthis->collider); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2596); +} + +void EnDekubaba_DrawBaseShadow(EnDekubaba* pthis, GlobalContext* globalCtx) { + MtxF mtx; + f32 horizontalScale; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2692); + func_80094044(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_80038A28(pthis->boundFloor, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, &mtx); + Matrix_Mult(&mtx, MTXMODE_NEW); + + horizontalScale = pthis->size * 0.15f; + Matrix_Scale(horizontalScale, 1.0f, horizontalScale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2710), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2715); +} + +void EnDekubaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnDekubaba* pthis = (EnDekubaba*)thisx; + + if (limbIndex == 1) { + Collider_UpdateSpheres(limbIndex, &pthis->collider); + } +} + +void EnDekubaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDekubaba* pthis = (EnDekubaba*)thisx; + f32 scale; + + if (1) {} + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2752); + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->actionFunc != EnDekubaba_DeadStickDrop) { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, + EnDekubaba_PostLimbDraw, pthis); + + if (pthis->actionFunc == EnDekubaba_Wait) { + EnDekubaba_DrawStemRetracted(pthis, globalCtx); + } else { + EnDekubaba_DrawStemExtended(pthis, globalCtx); + } + + scale = pthis->size * 0.01f; + Matrix_Translate(pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->actor.home.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2780), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaBaseLeavesDL); + + if (pthis->actionFunc == EnDekubaba_PrunedSomersault) { + EnDekubaba_DrawStemBasePruned(pthis, globalCtx); + } + + if (pthis->boundFloor != NULL) { + EnDekubaba_DrawBaseShadow(pthis, globalCtx); + } + + // Display solid until 40 frames left, then blink until killed. + } else if ((pthis->timer > 40) || ((pthis->timer % 2) != 0)) { + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2797), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStickDropDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dekubaba.c", 2804); +} diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c deleted file mode 100644 index f42bc0ba0..000000000 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ /dev/null @@ -1,546 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DEKUNUTS_Z_EN_DEKUNUTS_C -#include "actor_common.h" -/* - * File: z_en_dekunuts.c - * Overlay: ovl_En_Dekunuts - * Description: Mad Scrub - */ - -#include "z_en_dekunuts.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -#define DEKUNUTS_FLOWER 10 - -void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDekunuts_SetupWait(EnDekunuts* this); -void EnDekunuts_Wait(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_LookAround(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_Stand(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_ThrowNut(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_Burrow(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_BeginRun(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_Run(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_Gasp(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_BeDamaged(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_BeStunned(EnDekunuts* this, GlobalContext* globalCtx); -void EnDekunuts_Die(EnDekunuts* this, GlobalContext* globalCtx); - -const ActorInit En_Dekunuts_InitVars = { - ACTOR_EN_DEKUNUTS, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DEKUNUTS, - sizeof(EnDekunuts), - (ActorFunc)EnDekunuts_Init, - (ActorFunc)EnDekunuts_Destroy, - (ActorFunc)EnDekunuts_Update, - (ActorFunc)EnDekunuts_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 18, 32, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0x01, 0x0012, 0x0020, MASS_IMMOVABLE }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x4D, ICHAIN_CONTINUE), - ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), -}; - -void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDekunuts* this = (EnDekunuts*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - if (thisx->params == DEKUNUTS_FLOWER) { - thisx->flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - } else { - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuNutsSkel, &gDekuNutsStandAnim, this->jointTable, - this->morphTable, 25); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); - this->shotsPerRound = ((thisx->params >> 8) & 0xFF); - thisx->params &= 0xFF; - if ((this->shotsPerRound == 0xFF) || (this->shotsPerRound == 0)) { - this->shotsPerRound = 1; - } - EnDekunuts_SetupWait(this); - Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_DEKUNUTS, thisx->world.pos.x, - thisx->world.pos.y, thisx->world.pos.z, 0, thisx->world.rot.y, 0, DEKUNUTS_FLOWER); - } -} - -void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDekunuts* this = (EnDekunuts*)thisx; - - if (this->actor.params != DEKUNUTS_FLOWER) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void EnDekunuts_SetupWait(EnDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuNutsUpAnim, 0.0f); - this->animFlagAndTimer = Rand_S16Offset(100, 50); - this->collider.dim.height = 5; - Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnDekunuts_Wait; -} - -void EnDekunuts_SetupLookAround(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &gDekuNutsLookAroundAnim); - this->animFlagAndTimer = 2; - this->actionFunc = EnDekunuts_LookAround; -} - -void EnDekunuts_SetupThrowNut(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &gDekuNutsSpitAnim); - this->animFlagAndTimer = this->shotsPerRound; - this->actionFunc = EnDekunuts_ThrowNut; -} - -void EnDekunuts_SetupStand(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &gDekuNutsStandAnim, -3.0f); - if (this->actionFunc == EnDekunuts_ThrowNut) { - this->animFlagAndTimer = 2 | 0x1000; // sets timer and flag - } else { - this->animFlagAndTimer = 1; - } - this->actionFunc = EnDekunuts_Stand; -} - -void EnDekunuts_SetupBurrow(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDekuNutsBurrowAnim, -5.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); - this->actionFunc = EnDekunuts_Burrow; -} - -void EnDekunuts_SetupBeginRun(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDekuNutsUnburrowAnim, -3.0f); - this->collider.dim.height = 37; - this->actor.colChkInfo.mass = 0x32; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnDekunuts_BeginRun; -} - -void EnDekunuts_SetupRun(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &gDekuNutsRunAnim); - this->animFlagAndTimer = 2; - this->playWalkSound = false; - this->collider.base.acFlags |= AC_ON; - this->actionFunc = EnDekunuts_Run; -} - -void EnDekunuts_SetupGasp(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &gDekuNutsGaspAnim); - this->animFlagAndTimer = 3; - this->actor.speedXZ = 0.0f; - if (this->runAwayCount != 0) { - this->runAwayCount--; - } - this->actionFunc = EnDekunuts_Gasp; -} - -void EnDekunuts_SetupBeDamaged(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDekuNutsDamageAnim, -3.0f); - if ((this->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) != 0) { - this->actor.world.rot.y = this->collider.base.ac->world.rot.y; - } else { - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac) + 0x8000; - } - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnDekunuts_BeDamaged; - this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_CUTBODY); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gDekuNutsDamageAnim)); -} - -void EnDekunuts_SetupBeStunned(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &gDekuNutsDamageAnim, -3.0f); - this->animFlagAndTimer = 5; - this->actionFunc = EnDekunuts_BeStunned; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, - Animation_GetLastFrame(&gDekuNutsDamageAnim) * this->animFlagAndTimer); -} - -void EnDekunuts_SetupDie(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &gDekuNutsDieAnim); - this->actionFunc = EnDekunuts_Die; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DEAD); -} - -void EnDekunuts_Wait(EnDekunuts* this, GlobalContext* globalCtx) { - s32 hasSlowPlaybackSpeed = false; - - if (this->skelAnime.playSpeed < 0.5f) { - hasSlowPlaybackSpeed = true; - } - if (hasSlowPlaybackSpeed && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - this->collider.base.acFlags |= AC_ON; - } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - } - - this->collider.dim.height = ((CLAMP(this->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5.0f; - if (!hasSlowPlaybackSpeed && (this->actor.xzDistToPlayer < 120.0f)) { - EnDekunuts_SetupBurrow(this); - } else if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.xzDistToPlayer < 120.0f) { - EnDekunuts_SetupBurrow(this); - } else if ((this->animFlagAndTimer == 0) && (this->actor.xzDistToPlayer > 320.0f)) { - EnDekunuts_SetupLookAround(this); - } else { - EnDekunuts_SetupStand(this); - } - } - if (hasSlowPlaybackSpeed && - ((this->actor.xzDistToPlayer > 160.0f) && (fabsf(this->actor.yDistToPlayer) < 120.0f)) && - ((this->animFlagAndTimer == 0) || (this->actor.xzDistToPlayer < 480.0f))) { - this->skelAnime.playSpeed = 1.0f; - } -} - -void EnDekunuts_LookAround(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if ((this->actor.xzDistToPlayer < 120.0f) || (this->animFlagAndTimer == 0)) { - EnDekunuts_SetupBurrow(this); - } -} - -void EnDekunuts_Stand(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (!(this->animFlagAndTimer & 0x1000)) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - } - if (this->animFlagAndTimer == 0x1000) { - if ((this->actor.xzDistToPlayer > 480.0f) || (this->actor.xzDistToPlayer < 120.0f)) { - EnDekunuts_SetupBurrow(this); - } else { - EnDekunuts_SetupThrowNut(this); - } - } else if (this->animFlagAndTimer == 0) { - EnDekunuts_SetupThrowNut(this); - } -} - -void EnDekunuts_ThrowNut(EnDekunuts* this, GlobalContext* globalCtx) { - Vec3f spawnPos; - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (SkelAnime_Update(&this->skelAnime)) { - EnDekunuts_SetupStand(this); - } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - spawnPos.x = this->actor.world.pos.x + (Math_SinS(this->actor.shape.rot.y) * 23.0f); - spawnPos.y = this->actor.world.pos.y + 12.0f; - spawnPos.z = this->actor.world.pos.z + (Math_CosS(this->actor.shape.rot.y) * 23.0f); - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, spawnPos.x, spawnPos.y, spawnPos.z, - this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 0) != NULL) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); - } - } else if ((this->animFlagAndTimer > 1) && Animation_OnFrame(&this->skelAnime, 12.0f)) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDekuNutsSpitAnim, -3.0f); - if (this->animFlagAndTimer != 0) { - this->animFlagAndTimer--; - } - } -} - -void EnDekunuts_Burrow(EnDekunuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnDekunuts_SetupWait(this); - } else { - this->collider.dim.height = ((3.0f - CLAMP(this->skelAnime.curFrame, 1.0f, 3.0f)) * 12.0f) + 5.0f; - } - if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - this->collider.base.acFlags &= ~AC_ON; - } - Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.5f, 3.0f); - Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.5f, 3.0f); -} - -void EnDekunuts_BeginRun(EnDekunuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->runDirection = this->actor.yawTowardsPlayer + 0x8000; - this->runAwayCount = 3; - EnDekunuts_SetupRun(this); - } - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); -} - -void EnDekunuts_Run(EnDekunuts* this, GlobalContext* globalCtx) { - s16 diffRotInit; - s16 diffRot; - f32 phi_f0; - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (this->playWalkSound) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - this->playWalkSound = false; - } else { - this->playWalkSound = true; - } - - Math_StepToF(&this->actor.speedXZ, 7.5f, 1.0f); - if (Math_SmoothStepToS(&this->actor.world.rot.y, this->runDirection, 1, 0xE38, 0xB6) == 0) { - if (this->actor.bgCheckFlags & 0x20) { - this->runDirection = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - } else if (this->actor.bgCheckFlags & 8) { - this->runDirection = this->actor.wallYaw; - } else if (this->runAwayCount == 0) { - diffRotInit = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - diffRot = diffRotInit - this->actor.yawTowardsPlayer; - if (ABS(diffRot) > 0x2000) { - this->runDirection = diffRotInit; - } else { - phi_f0 = (diffRot >= 0.0f) ? 1.0f : -1.0f; - this->runDirection = (phi_f0 * -0x2000) + this->actor.yawTowardsPlayer; - } - } else { - this->runDirection = this->actor.yawTowardsPlayer + 0x8000; - } - } - - this->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - if ((this->runAwayCount == 0) && Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 20.0f && - fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f) { - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.speedXZ = 0.0f; - EnDekunuts_SetupBurrow(this); - } else if (this->animFlagAndTimer == 0) { - EnDekunuts_SetupGasp(this); - } -} - -void EnDekunuts_Gasp(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (this->animFlagAndTimer == 0) { - EnDekunuts_SetupRun(this); - } -} - -void EnDekunuts_BeDamaged(EnDekunuts* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); - if (SkelAnime_Update(&this->skelAnime)) { - EnDekunuts_SetupDie(this); - } -} - -void EnDekunuts_BeStunned(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->animFlagAndTimer != 0) { - this->animFlagAndTimer--; - } - if (this->animFlagAndTimer == 0) { - EnDekunuts_SetupRun(this); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_FAINT); - } - } -} - -void EnDekunuts_Die(EnDekunuts* this, GlobalContext* globalCtx) { - static Vec3f effectVelAndAccel = { 0.0f, 0.0f, 0.0f }; - - s32 pad; - Vec3f effectPos; - - if (SkelAnime_Update(&this->skelAnime)) { - effectPos.x = this->actor.world.pos.x; - effectPos.y = this->actor.world.pos.y + 18.0f; - effectPos.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVelAndAccel, &effectVelAndAccel, 200, 0, 255, 255, 255, 255, - 150, 150, 150, 1, 13, 1); - effectPos.y = this->actor.world.pos.y + 10.0f; - EffectSsHahen_SpawnBurst(globalCtx, &effectPos, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x30); - if (this->actor.child != NULL) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, this->actor.child, ACTORCAT_PROP); - } - Actor_Kill(&this->actor); - } -} - -void EnDekunuts_ColliderCheck(EnDekunuts* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if (this->actor.colChkInfo.mass == 0x32) { - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (this->actor.colChkInfo.damageEffect != 1) { - if (this->actor.colChkInfo.damageEffect == 2) { - EffectSsFCircle_Spawn(globalCtx, &this->actor, &this->actor.world.pos, 40, 50); - } - EnDekunuts_SetupBeDamaged(this); - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } - } else if (this->actionFunc != EnDekunuts_BeStunned) { - EnDekunuts_SetupBeStunned(this); - } - } - } else { - EnDekunuts_SetupBeginRun(this); - } - } else if ((this->actor.colChkInfo.mass == MASS_IMMOVABLE) && (globalCtx->actorCtx.unk_02 != 0)) { - EnDekunuts_SetupBeginRun(this); - } -} - -void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDekunuts* this = (EnDekunuts*)thisx; - s32 pad; - - if (this->actor.params != DEKUNUTS_FLOWER) { - EnDekunuts_ColliderCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, - 0x1D); - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actionFunc == EnDekunuts_Wait) { - Actor_SetFocus(&this->actor, this->skelAnime.curFrame); - } else if (this->actionFunc == EnDekunuts_Burrow) { - Actor_SetFocus(&this->actor, - 20.0f - ((this->skelAnime.curFrame * 20.0f) / Animation_GetLastFrame(&gDekuNutsBurrowAnim))); - } else { - Actor_SetFocus(&this->actor, 20.0f); - } - } -} - -s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnDekunuts* this = (EnDekunuts*)thisx; - f32 x; - f32 y; - f32 z; - f32 curFrame; - - if ((limbIndex == 7) && (this->actionFunc == EnDekunuts_ThrowNut)) { - curFrame = this->skelAnime.curFrame; - if (curFrame <= 6.0f) { - x = 1.0f - (curFrame * 0.0833f); - z = 1.0f + (curFrame * 0.1167f); - y = 1.0f + (curFrame * 0.1167f); - } else if (curFrame <= 7.0f) { - curFrame -= 6.0f; - x = 0.5f + curFrame; - z = 1.7f - (curFrame * 0.7f); - y = 1.7f - (curFrame * 0.7f); - } else if (curFrame <= 10.0f) { - x = 1.5f - ((curFrame - 7.0f) * 0.1667f); - z = 1.0f; - y = 1.0f; - } else { - return false; - } - Matrix_Scale(x, y, z, MTXMODE_APPLY); - } - return false; -} - -void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDekunuts* this = (EnDekunuts*)thisx; - - if (this->actor.params == DEKUNUTS_FLOWER) { - Gfx_DrawDListOpa(globalCtx, gDekuNutsFlowerDL); - } else { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDekunuts_OverrideLimbDraw, - NULL, this); - } -} diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.cpp b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.cpp new file mode 100644 index 000000000..415f61ccb --- /dev/null +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.cpp @@ -0,0 +1,546 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DEKUNUTS_Z_EN_DEKUNUTS_C +#include "actor_common.h" +/* + * File: z_en_dekunuts.c + * Overlay: ovl_En_Dekunuts + * Description: Mad Scrub + */ + +#include "z_en_dekunuts.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_dekunuts/object_dekunuts.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +#define DEKUNUTS_FLOWER 10 + +void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDekunuts_SetupWait(EnDekunuts* pthis); +void EnDekunuts_Wait(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_LookAround(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_Stand(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_ThrowNut(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_Burrow(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_BeginRun(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_Run(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_Gasp(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_BeDamaged(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_BeStunned(EnDekunuts* pthis, GlobalContext* globalCtx); +void EnDekunuts_Die(EnDekunuts* pthis, GlobalContext* globalCtx); + +ActorInit En_Dekunuts_InitVars = { + ACTOR_EN_DEKUNUTS, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DEKUNUTS, + sizeof(EnDekunuts), + (ActorFunc)EnDekunuts_Init, + (ActorFunc)EnDekunuts_Destroy, + (ActorFunc)EnDekunuts_Update, + (ActorFunc)EnDekunuts_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 18, 32, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0x01, 0x0012, 0x0020, MASS_IMMOVABLE }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(1, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x4D, ICHAIN_CONTINUE), + ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), +}; + +void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* pthis = (EnDekunuts*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + if (thisx->params == DEKUNUTS_FLOWER) { + thisx->flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + } else { + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDekuNutsSkel, &gDekuNutsStandAnim, pthis->jointTable, + pthis->morphTable, 25); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->shotsPerRound = ((thisx->params >> 8) & 0xFF); + thisx->params &= 0xFF; + if ((pthis->shotsPerRound == 0xFF) || (pthis->shotsPerRound == 0)) { + pthis->shotsPerRound = 1; + } + EnDekunuts_SetupWait(pthis); + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_DEKUNUTS, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, 0, thisx->world.rot.y, 0, DEKUNUTS_FLOWER); + } +} + +void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* pthis = (EnDekunuts*)thisx; + + if (pthis->actor.params != DEKUNUTS_FLOWER) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void EnDekunuts_SetupWait(EnDekunuts* pthis) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gDekuNutsUpAnim, 0.0f); + pthis->animFlagAndTimer = Rand_S16Offset(100, 50); + pthis->collider.dim.height = 5; + Math_Vec3f_Copy(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnDekunuts_Wait; +} + +void EnDekunuts_SetupLookAround(EnDekunuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gDekuNutsLookAroundAnim); + pthis->animFlagAndTimer = 2; + pthis->actionFunc = EnDekunuts_LookAround; +} + +void EnDekunuts_SetupThrowNut(EnDekunuts* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gDekuNutsSpitAnim); + pthis->animFlagAndTimer = pthis->shotsPerRound; + pthis->actionFunc = EnDekunuts_ThrowNut; +} + +void EnDekunuts_SetupStand(EnDekunuts* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gDekuNutsStandAnim, -3.0f); + if (pthis->actionFunc == EnDekunuts_ThrowNut) { + pthis->animFlagAndTimer = 2 | 0x1000; // sets timer and flag + } else { + pthis->animFlagAndTimer = 1; + } + pthis->actionFunc = EnDekunuts_Stand; +} + +void EnDekunuts_SetupBurrow(EnDekunuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDekuNutsBurrowAnim, -5.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DOWN); + pthis->actionFunc = EnDekunuts_Burrow; +} + +void EnDekunuts_SetupBeginRun(EnDekunuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDekuNutsUnburrowAnim, -3.0f); + pthis->collider.dim.height = 37; + pthis->actor.colChkInfo.mass = 0x32; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DAMAGE); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnDekunuts_BeginRun; +} + +void EnDekunuts_SetupRun(EnDekunuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gDekuNutsRunAnim); + pthis->animFlagAndTimer = 2; + pthis->playWalkSound = false; + pthis->collider.base.acFlags |= AC_ON; + pthis->actionFunc = EnDekunuts_Run; +} + +void EnDekunuts_SetupGasp(EnDekunuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gDekuNutsGaspAnim); + pthis->animFlagAndTimer = 3; + pthis->actor.speedXZ = 0.0f; + if (pthis->runAwayCount != 0) { + pthis->runAwayCount--; + } + pthis->actionFunc = EnDekunuts_Gasp; +} + +void EnDekunuts_SetupBeDamaged(EnDekunuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDekuNutsDamageAnim, -3.0f); + if ((pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) != 0) { + pthis->actor.world.rot.y = pthis->collider.base.ac->world.rot.y; + } else { + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; + } + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnDekunuts_BeDamaged; + pthis->actor.speedXZ = 10.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DAMAGE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_CUTBODY); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gDekuNutsDamageAnim)); +} + +void EnDekunuts_SetupBeStunned(EnDekunuts* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gDekuNutsDamageAnim, -3.0f); + pthis->animFlagAndTimer = 5; + pthis->actionFunc = EnDekunuts_BeStunned; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, + Animation_GetLastFrame(&gDekuNutsDamageAnim) * pthis->animFlagAndTimer); +} + +void EnDekunuts_SetupDie(EnDekunuts* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gDekuNutsDieAnim); + pthis->actionFunc = EnDekunuts_Die; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DEAD); +} + +void EnDekunuts_Wait(EnDekunuts* pthis, GlobalContext* globalCtx) { + s32 hasSlowPlaybackSpeed = false; + + if (pthis->skelAnime.playSpeed < 0.5f) { + hasSlowPlaybackSpeed = true; + } + if (hasSlowPlaybackSpeed && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + pthis->collider.base.acFlags |= AC_ON; + } else if (Animation_OnFrame(&pthis->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + } + + pthis->collider.dim.height = ((CLAMP(pthis->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5.0f; + if (!hasSlowPlaybackSpeed && (pthis->actor.xzDistToPlayer < 120.0f)) { + EnDekunuts_SetupBurrow(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.xzDistToPlayer < 120.0f) { + EnDekunuts_SetupBurrow(pthis); + } else if ((pthis->animFlagAndTimer == 0) && (pthis->actor.xzDistToPlayer > 320.0f)) { + EnDekunuts_SetupLookAround(pthis); + } else { + EnDekunuts_SetupStand(pthis); + } + } + if (hasSlowPlaybackSpeed && + ((pthis->actor.xzDistToPlayer > 160.0f) && (fabsf(pthis->actor.yDistToPlayer) < 120.0f)) && + ((pthis->animFlagAndTimer == 0) || (pthis->actor.xzDistToPlayer < 480.0f))) { + pthis->skelAnime.playSpeed = 1.0f; + } +} + +void EnDekunuts_LookAround(EnDekunuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if ((pthis->actor.xzDistToPlayer < 120.0f) || (pthis->animFlagAndTimer == 0)) { + EnDekunuts_SetupBurrow(pthis); + } +} + +void EnDekunuts_Stand(EnDekunuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (!(pthis->animFlagAndTimer & 0x1000)) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + } + if (pthis->animFlagAndTimer == 0x1000) { + if ((pthis->actor.xzDistToPlayer > 480.0f) || (pthis->actor.xzDistToPlayer < 120.0f)) { + EnDekunuts_SetupBurrow(pthis); + } else { + EnDekunuts_SetupThrowNut(pthis); + } + } else if (pthis->animFlagAndTimer == 0) { + EnDekunuts_SetupThrowNut(pthis); + } +} + +void EnDekunuts_ThrowNut(EnDekunuts* pthis, GlobalContext* globalCtx) { + Vec3f spawnPos; + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDekunuts_SetupStand(pthis); + } else if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + spawnPos.x = pthis->actor.world.pos.x + (Math_SinS(pthis->actor.shape.rot.y) * 23.0f); + spawnPos.y = pthis->actor.world.pos.y + 12.0f; + spawnPos.z = pthis->actor.world.pos.z + (Math_CosS(pthis->actor.shape.rot.y) * 23.0f); + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, spawnPos.x, spawnPos.y, spawnPos.z, + pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 0) != NULL) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_THROW); + } + } else if ((pthis->animFlagAndTimer > 1) && Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDekuNutsSpitAnim, -3.0f); + if (pthis->animFlagAndTimer != 0) { + pthis->animFlagAndTimer--; + } + } +} + +void EnDekunuts_Burrow(EnDekunuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDekunuts_SetupWait(pthis); + } else { + pthis->collider.dim.height = ((3.0f - CLAMP(pthis->skelAnime.curFrame, 1.0f, 3.0f)) * 12.0f) + 5.0f; + } + if (Animation_OnFrame(&pthis->skelAnime, 4.0f)) { + pthis->collider.base.acFlags &= ~AC_ON; + } + Math_ApproachF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 0.5f, 3.0f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 0.5f, 3.0f); +} + +void EnDekunuts_BeginRun(EnDekunuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->runDirection = pthis->actor.yawTowardsPlayer + 0x8000; + pthis->runAwayCount = 3; + EnDekunuts_SetupRun(pthis); + } + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); +} + +void EnDekunuts_Run(EnDekunuts* pthis, GlobalContext* globalCtx) { + s16 diffRotInit; + s16 diffRot; + f32 phi_f0; + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (pthis->playWalkSound) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + pthis->playWalkSound = false; + } else { + pthis->playWalkSound = true; + } + + Math_StepToF(&pthis->actor.speedXZ, 7.5f, 1.0f); + if (Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->runDirection, 1, 0xE38, 0xB6) == 0) { + if (pthis->actor.bgCheckFlags & 0x20) { + pthis->runDirection = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + } else if (pthis->actor.bgCheckFlags & 8) { + pthis->runDirection = pthis->actor.wallYaw; + } else if (pthis->runAwayCount == 0) { + diffRotInit = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + diffRot = diffRotInit - pthis->actor.yawTowardsPlayer; + if (ABS(diffRot) > 0x2000) { + pthis->runDirection = diffRotInit; + } else { + phi_f0 = (diffRot >= 0.0f) ? 1.0f : -1.0f; + pthis->runDirection = (phi_f0 * -0x2000) + pthis->actor.yawTowardsPlayer; + } + } else { + pthis->runDirection = pthis->actor.yawTowardsPlayer + 0x8000; + } + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + if ((pthis->runAwayCount == 0) && Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) < 20.0f && + fabsf(pthis->actor.world.pos.y - pthis->actor.home.pos.y) < 2.0f) { + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.speedXZ = 0.0f; + EnDekunuts_SetupBurrow(pthis); + } else if (pthis->animFlagAndTimer == 0) { + EnDekunuts_SetupGasp(pthis); + } +} + +void EnDekunuts_Gasp(EnDekunuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (pthis->animFlagAndTimer == 0) { + EnDekunuts_SetupRun(pthis); + } +} + +void EnDekunuts_BeDamaged(EnDekunuts* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 1.0f); + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDekunuts_SetupDie(pthis); + } +} + +void EnDekunuts_BeStunned(EnDekunuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + if (pthis->animFlagAndTimer != 0) { + pthis->animFlagAndTimer--; + } + if (pthis->animFlagAndTimer == 0) { + EnDekunuts_SetupRun(pthis); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_FAINT); + } + } +} + +void EnDekunuts_Die(EnDekunuts* pthis, GlobalContext* globalCtx) { + static Vec3f effectVelAndAccel = { 0.0f, 0.0f, 0.0f }; + + s32 pad; + Vec3f effectPos; + + if (SkelAnime_Update(&pthis->skelAnime)) { + effectPos.x = pthis->actor.world.pos.x; + effectPos.y = pthis->actor.world.pos.y + 18.0f; + effectPos.z = pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVelAndAccel, &effectVelAndAccel, 200, 0, 255, 255, 255, 255, + 150, 150, 150, 1, 13, 1); + effectPos.y = pthis->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(globalCtx, &effectPos, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x30); + if (pthis->actor.child != NULL) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, pthis->actor.child, ACTORCAT_PROP); + } + Actor_Kill(&pthis->actor); + } +} + +void EnDekunuts_ColliderCheck(EnDekunuts* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if (pthis->actor.colChkInfo.mass == 0x32) { + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (pthis->actor.colChkInfo.damageEffect != 1) { + if (pthis->actor.colChkInfo.damageEffect == 2) { + EffectSsFCircle_Spawn(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40, 50); + } + EnDekunuts_SetupBeDamaged(pthis); + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } + } else if (pthis->actionFunc != EnDekunuts_BeStunned) { + EnDekunuts_SetupBeStunned(pthis); + } + } + } else { + EnDekunuts_SetupBeginRun(pthis); + } + } else if ((pthis->actor.colChkInfo.mass == MASS_IMMOVABLE) && (globalCtx->actorCtx.unk_02 != 0)) { + EnDekunuts_SetupBeginRun(pthis); + } +} + +void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* pthis = (EnDekunuts*)thisx; + s32 pad; + + if (pthis->actor.params != DEKUNUTS_FLOWER) { + EnDekunuts_ColliderCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, pthis->collider.dim.radius, pthis->collider.dim.height, + 0x1D); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actionFunc == EnDekunuts_Wait) { + Actor_SetFocus(&pthis->actor, pthis->skelAnime.curFrame); + } else if (pthis->actionFunc == EnDekunuts_Burrow) { + Actor_SetFocus(&pthis->actor, + 20.0f - ((pthis->skelAnime.curFrame * 20.0f) / Animation_GetLastFrame(&gDekuNutsBurrowAnim))); + } else { + Actor_SetFocus(&pthis->actor, 20.0f); + } + } +} + +s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnDekunuts* pthis = (EnDekunuts*)thisx; + f32 x; + f32 y; + f32 z; + f32 curFrame; + + if ((limbIndex == 7) && (pthis->actionFunc == EnDekunuts_ThrowNut)) { + curFrame = pthis->skelAnime.curFrame; + if (curFrame <= 6.0f) { + x = 1.0f - (curFrame * 0.0833f); + z = 1.0f + (curFrame * 0.1167f); + y = 1.0f + (curFrame * 0.1167f); + } else if (curFrame <= 7.0f) { + curFrame -= 6.0f; + x = 0.5f + curFrame; + z = 1.7f - (curFrame * 0.7f); + y = 1.7f - (curFrame * 0.7f); + } else if (curFrame <= 10.0f) { + x = 1.5f - ((curFrame - 7.0f) * 0.1667f); + z = 1.0f; + y = 1.0f; + } else { + return false; + } + Matrix_Scale(x, y, z, MTXMODE_APPLY); + } + return false; +} + +void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* pthis = (EnDekunuts*)thisx; + + if (pthis->actor.params == DEKUNUTS_FLOWER) { + Gfx_DrawDListOpa(globalCtx, gDekuNutsFlowerDL); + } else { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnDekunuts_OverrideLimbDraw, + NULL, pthis); + } +} diff --git a/src/overlays/actors/ovl_En_Dh/z_en_dh.c b/src/overlays/actors/ovl_En_Dh/z_en_dh.c deleted file mode 100644 index 7d81a17dc..000000000 --- a/src/overlays/actors/ovl_En_Dh/z_en_dh.c +++ /dev/null @@ -1,595 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DH_Z_EN_DH_C -#include "actor_common.h" -#include "z_en_dh.h" -#include "objects/object_dh/object_dh.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) - -typedef enum { - /* 0 */ DH_WAIT, - /* 1 */ DH_RETREAT, - /* 2 */ DH_BURROW, - /* 3 */ DH_WALK, - /* 4 */ DH_ATTACK, - /* 5 */ DH_DEATH, - /* 6 */ DH_DAMAGE -} EnDhAction; - -void EnDh_Init(Actor* this, GlobalContext* globalCtx); -void EnDh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDh_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDh_SetupWait(EnDh* this); -void EnDh_SetupWalk(EnDh* this); -void EnDh_SetupAttack(EnDh* this); -void EnDh_SetupBurrow(EnDh* this); - -void EnDh_Wait(EnDh* this, GlobalContext* globalCtx); -void EnDh_Walk(EnDh* this, GlobalContext* globalCtx); -void EnDh_Retreat(EnDh* this, GlobalContext* globalCtx); -void EnDh_Attack(EnDh* this, GlobalContext* globalCtx); -void EnDh_Burrow(EnDh* this, GlobalContext* globalCtx); -void EnDh_Damage(EnDh* this, GlobalContext* globalCtx); -void EnDh_Death(EnDh* this, GlobalContext* globalCtx); - -const ActorInit En_Dh_InitVars = { - ACTOR_EN_DH, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DH, - sizeof(EnDh), - (ActorFunc)EnDh_Init, - (ActorFunc)EnDh_Destroy, - (ActorFunc)EnDh_Update, - (ActorFunc)EnDh_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 35, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON | OCELEM_UNK3, - }, - { 1, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static DamageTable D_809EC620 = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0xF), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(0, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Kokiri sword */ DMG_ENTRY(2, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(2, 0xF), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(4, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xF), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x2F, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), -}; - -void EnDh_SetupAction(EnDh* this, EnDhActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnDh_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDh* this = (EnDh*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &D_809EC620; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dh_Skel_007E88, &object_dh_Anim_005880, this->jointTable, - this->limbRotTable, 16); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 64.0f); - this->actor.params = ENDH_WAIT_UNDERGROUND; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.colChkInfo.health = LINK_IS_ADULT ? 14 : 20; - this->alpha = this->unk_258 = 255; - this->actor.flags &= ~ACTOR_FLAG_0; - Collider_InitCylinder(globalCtx, &this->collider1); - Collider_SetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); - Collider_InitJntSph(globalCtx, &this->collider2); - Collider_SetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit, this->elements); - EnDh_SetupWait(this); -} - -void EnDh_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDh* this = (EnDh*)thisx; - - func_800F5B58(); - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyJntSph(globalCtx, &this->collider2); -} - -void EnDh_SpawnDebris(GlobalContext* globalCtx, EnDh* this, Vec3f* spawnPos, f32 spread, s32 arg4, f32 accelXZ, - f32 scale) { - Vec3f pos; - Vec3f vel = { 0.0f, 8.0f, 0.0f }; - Vec3f accel = { 0.0f, -1.5f, 0.0f }; - f32 spreadAngle; - f32 scaleMod; - - spreadAngle = (Rand_ZeroOne() - 0.5f) * 6.28f; - pos.y = this->actor.floorHeight; - pos.x = (Math_SinF(spreadAngle) * spread) + spawnPos->x; - pos.z = (Math_CosF(spreadAngle) * spread) + spawnPos->z; - accel.x = (Rand_ZeroOne() - 0.5f) * accelXZ; - accel.z = (Rand_ZeroOne() - 0.5f) * accelXZ; - vel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - scaleMod = (Rand_ZeroOne() * 5.0f) + 12.0f; - EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accel, arg4, scaleMod * scale, -1, 10, NULL); -} - -void EnDh_SetupWait(EnDh* this) { - Animation_PlayLoop(&this->skelAnime, &object_dh_Anim_003A8C); - this->curAction = DH_WAIT; - this->actor.world.pos.x = Rand_CenteredFloat(600.0f) + this->actor.home.pos.x; - this->actor.world.pos.z = Rand_CenteredFloat(600.0f) + this->actor.home.pos.z; - this->actor.shape.yOffset = -15000.0f; - this->dirtWaveSpread = this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.flags |= ACTOR_FLAG_7; - this->dirtWavePhase = this->actionState = this->actor.params = ENDH_WAIT_UNDERGROUND; - EnDh_SetupAction(this, EnDh_Wait); -} - -void EnDh_Wait(EnDh* this, GlobalContext* globalCtx) { - if ((s32)this->skelAnime.curFrame == 5) { - func_800F5ACC(NA_BGM_MINI_BOSS); - } - if (Actor_GetCollidedExplosive(globalCtx, &this->collider1.base)) { - this->actor.params = ENDH_START_ATTACK_BOMB; - } - if ((this->actor.params >= ENDH_START_ATTACK_GRAB) || (this->actor.params <= ENDH_HANDS_KILLED_4)) { - switch (this->actionState) { - case 0: - this->actor.flags |= ACTOR_FLAG_0; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.flags &= ~ACTOR_FLAG_7; - this->actionState++; - this->drawDirtWave++; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_HIDE); - case 1: - this->dirtWavePhase += 0x3A7; - Math_SmoothStepToF(&this->dirtWaveSpread, 300.0f, 1.0f, 5.0f, 0.0f); - this->dirtWaveHeight = Math_SinS(this->dirtWavePhase) * 55.0f; - this->dirtWaveAlpha = (s16)(Math_SinS(this->dirtWavePhase) * 255.0f); - EnDh_SpawnDebris(globalCtx, this, &this->actor.world.pos, this->dirtWaveSpread, 4, 2.05f, 1.2f); - if (this->actor.shape.yOffset == 0.0f) { - this->drawDirtWave = false; - this->actionState++; - } else if (this->dirtWavePhase > 0x12C0) { - this->actor.shape.yOffset += 500.0f; - } - break; - case 2: - EnDh_SetupWalk(this); - break; - } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x7D0, 0); - SkelAnime_Update(&this->skelAnime); - if (this->actor.params != ENDH_START_ATTACK_BOMB) { - func_8008EEAC(globalCtx, &this->actor); - } - } -} - -void EnDh_SetupWalk(EnDh* this) { - Animation_Change(&this->skelAnime, &object_dh_Anim_003A8C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_dh_Anim_003A8C) - 3.0f, ANIMMODE_LOOP, -6.0f); - this->curAction = DH_WALK; - this->timer = 300; - this->actor.speedXZ = 1.0f; - EnDh_SetupAction(this, EnDh_Walk); -} - -void EnDh_Walk(EnDh* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_Update(&this->skelAnime); - if (((s32)this->skelAnime.curFrame % 8) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_WALK); - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_LAUGH); - } - if (this->actor.xzDistToPlayer <= 100.0f) { - this->actor.speedXZ = 0.0f; - if (Actor_IsFacingPlayer(&this->actor, 60 * 0x10000 / 360)) { - EnDh_SetupAttack(this); - } - } else if (--this->timer == 0) { - EnDh_SetupBurrow(this); - } -} - -void EnDh_SetupRetreat(EnDh* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &object_dh_Anim_005880, -4.0f); - this->curAction = DH_RETREAT; - this->timer = 70; - this->actor.speedXZ = 1.0f; - EnDh_SetupAction(this, EnDh_Retreat); -} - -void EnDh_Retreat(EnDh* this, GlobalContext* globalCtx) { - this->timer--; - if (this->timer == 0) { - this->retreat = false; - EnDh_SetupBurrow(this); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, (s16)(this->actor.yawTowardsPlayer + 0x8000), 1, 0xBB8, 0); - } - this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_Update(&this->skelAnime); -} - -void EnDh_SetupAttack(EnDh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dh_Anim_004658, -6.0f); - this->timer = this->actionState = 0; - this->curAction = DH_ATTACK; - this->actor.speedXZ = 0.0f; - EnDh_SetupAction(this, EnDh_Attack); -} - -void EnDh_Attack(EnDh* this, GlobalContext* globalCtx) { - s32 pad; - - if (SkelAnime_Update(&this->skelAnime)) { - this->actionState++; - } else if ((this->actor.xzDistToPlayer > 100.0f) || !Actor_IsFacingPlayer(&this->actor, 60 * 0x10000 / 360)) { - Animation_Change(&this->skelAnime, &object_dh_Anim_004658, -1.0f, this->skelAnime.curFrame, 0.0f, ANIMMODE_ONCE, - -4.0f); - this->actionState = 4; - this->collider2.base.atFlags = this->collider2.elements[0].info.toucherFlags = AT_NONE; // also TOUCH_NONE - this->collider2.elements[0].info.toucher.dmgFlags = this->collider2.elements[0].info.toucher.damage = 0; - } - switch (this->actionState) { - case 1: - Animation_PlayOnce(&this->skelAnime, &object_dh_Anim_001A3C); - this->actionState++; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_BITE); - case 0: - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x5DC, 0); - break; - case 2: - if (this->skelAnime.curFrame >= 4.0f) { - this->collider2.base.atFlags = this->collider2.elements[0].info.toucherFlags = - AT_ON | AT_TYPE_ENEMY; // also TOUCH_ON | TOUCH_SFX_WOOD - this->collider2.elements[0].info.toucher.dmgFlags = 0xFFCFFFFF; - this->collider2.elements[0].info.toucher.damage = 8; - } - if (this->collider2.base.atFlags & AT_BOUNCED) { - this->collider2.base.atFlags &= ~(AT_HIT | AT_BOUNCED); - this->collider2.base.atFlags = this->collider2.elements[0].info.toucherFlags = - AT_NONE; // also TOUCH_NONE - this->collider2.elements[0].info.toucher.dmgFlags = this->collider2.elements[0].info.toucher.damage = 0; - this->actionState++; - } else if (this->collider2.base.atFlags & AT_HIT) { - this->collider2.base.atFlags &= ~AT_HIT; - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.shape.rot.y, 8.0f); - } - break; - case 3: - if ((this->actor.xzDistToPlayer <= 100.0f) && (Actor_IsFacingPlayer(&this->actor, 60 * 0x10000 / 360))) { - Animation_Change(&this->skelAnime, &object_dh_Anim_004658, 1.0f, 20.0f, - Animation_GetLastFrame(&object_dh_Anim_004658), ANIMMODE_ONCE, -6.0f); - this->actionState = 0; - } else { - Animation_Change(&this->skelAnime, &object_dh_Anim_004658, -1.0f, - Animation_GetLastFrame(&object_dh_Anim_004658), 0.0f, ANIMMODE_ONCE, -4.0f); - this->actionState++; - this->collider2.base.atFlags = this->collider2.elements[0].info.toucherFlags = - AT_NONE; // also TOUCH_NONE - this->collider2.elements[0].info.toucher.dmgFlags = this->collider2.elements[0].info.toucher.damage = 0; - } - break; - case 5: - EnDh_SetupWalk(this); - break; - case 4: - break; - } - this->actor.world.rot.y = this->actor.shape.rot.y; -} - -void EnDh_SetupBurrow(EnDh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dh_Anim_002148, -6.0f); - this->curAction = DH_BURROW; - this->dirtWaveSpread = this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->dirtWavePhase = 0; - this->actionState = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_HIDE); - EnDh_SetupAction(this, EnDh_Burrow); -} - -void EnDh_Burrow(EnDh* this, GlobalContext* globalCtx) { - switch (this->actionState) { - case 0: - this->actionState++; - this->drawDirtWave++; - this->collider1.base.atFlags = this->collider1.info.toucherFlags = - AT_ON | AT_TYPE_ENEMY; // also TOUCH_ON | TOUCH_SFX_WOOD - this->collider1.info.toucher.dmgFlags = 0xFFCFFFFF; - this->collider1.info.toucher.damage = 4; - case 1: - this->dirtWavePhase += 0x47E; - Math_SmoothStepToF(&this->dirtWaveSpread, 300.0f, 1.0f, 8.0f, 0.0f); - this->dirtWaveHeight = Math_SinS(this->dirtWavePhase) * 55.0f; - this->dirtWaveAlpha = (s16)(Math_SinS(this->dirtWavePhase) * 255.0f); - EnDh_SpawnDebris(globalCtx, this, &this->actor.world.pos, this->dirtWaveSpread, 4, 2.05f, 1.2f); - this->collider1.dim.radius = this->dirtWaveSpread * 0.6f; - if (SkelAnime_Update(&this->skelAnime)) { - this->actionState++; - } - break; - case 2: - this->drawDirtWave = false; - this->collider1.dim.radius = 35; - this->collider1.base.atFlags = this->collider1.info.toucherFlags = AT_NONE; // Also TOUCH_NONE - this->collider1.info.toucher.dmgFlags = this->collider1.info.toucher.damage = 0; - EnDh_SetupWait(this); - break; - } -} - -void EnDh_SetupDamage(EnDh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dh_Anim_003D6C, -6.0f); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -1.0f; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_DAMAGE); - this->curAction = DH_DAMAGE; - EnDh_SetupAction(this, EnDh_Damage); -} - -void EnDh_Damage(EnDh* this, GlobalContext* globalCtx) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; - } - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->retreat) { - EnDh_SetupRetreat(this, globalCtx); - } else if ((this->actor.xzDistToPlayer <= 105.0f) && Actor_IsFacingPlayer(&this->actor, 60 * 0x10000 / 360)) { - f32 frames = Animation_GetLastFrame(&object_dh_Anim_004658); - - EnDh_SetupAttack(this); - Animation_Change(&this->skelAnime, &object_dh_Anim_004658, 1.0f, 20.0f, frames, ANIMMODE_ONCE, -6.0f); - } else { - EnDh_SetupWalk(this); - } - this->unk_258 = 255; - } -} - -void EnDh_SetupDeath(EnDh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dh_Anim_0032BC, -1.0f); - this->curAction = DH_DEATH; - this->timer = 300; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - func_800F5B58(); - this->actor.params = ENDH_DEATH; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_DEAD); - EnDh_SetupAction(this, EnDh_Death); -} - -void EnDh_Death(EnDh* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) || (this->timer != 300)) { - if (this->timer == 300) { - Animation_PlayLoop(&this->skelAnime, &object_dh_Anim_00375C); - } - this->timer--; - if (this->timer < 150) { - if (this->alpha != 0) { - this->actor.scale.y -= 0.000075f; - this->actor.shape.shadowAlpha = this->alpha -= 5; - } else { - Actor_Kill(&this->actor); - return; - } - } - } else { - if (((s32)this->skelAnime.curFrame == 53) || ((s32)this->skelAnime.curFrame == 56) || - ((s32)this->skelAnime.curFrame == 61)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } - if ((s32)this->skelAnime.curFrame == 61) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - } - } -} - -void EnDh_CollisionCheck(EnDh* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 lastHealth; - - if ((this->collider2.base.acFlags & AC_HIT) && !this->retreat) { - this->collider2.base.acFlags &= ~AC_HIT; - if ((this->actor.colChkInfo.damageEffect != 0) && (this->actor.colChkInfo.damageEffect != 6)) { - this->collider2.base.atFlags = this->collider2.elements[0].info.toucherFlags = AT_NONE; // also TOUCH_NONE - this->collider2.elements[0].info.toucher.dmgFlags = this->collider2.elements[0].info.toucher.damage = 0; - if (player->unk_844 != 0) { - this->unk_258 = player->unk_845; - } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - lastHealth = this->actor.colChkInfo.health; - if (Actor_ApplyDamage(&this->actor) == 0) { - EnDh_SetupDeath(this); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); - } else { - if (((lastHealth >= 15) && (this->actor.colChkInfo.health < 15)) || - ((lastHealth >= 9) && (this->actor.colChkInfo.health < 9)) || - ((lastHealth >= 3) && (this->actor.colChkInfo.health < 3))) { - - this->retreat++; - } - EnDh_SetupDamage(this); - } - } - } -} - -void EnDh_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDh* this = (EnDh*)thisx; - Player* player = GET_PLAYER(globalCtx); - s32 pad40; - - EnDh_CollisionCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 45.0f, 45.0f, 0x1D); - this->actor.focus.pos = this->headPos; - Collider_UpdateCylinder(&this->actor, &this->collider1); - if (this->actor.colChkInfo.health > 0) { - if (this->curAction == DH_WAIT) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - } - if (((this->curAction != DH_DAMAGE) && (this->actor.shape.yOffset == 0.0f)) || - ((player->unk_844 != 0) && (player->unk_845 != this->unk_258))) { - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - } - } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - } -} - -void EnDh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - Vec3f headOffset = { 2000.0f, 1000.0f, 0.0f }; - EnDh* this = (EnDh*)thisx; - - if (limbIndex == 13) { - Matrix_MultVec3f(&headOffset, &this->headPos); - Matrix_Push(); - Matrix_Translate(headOffset.x, headOffset.y, headOffset.z, MTXMODE_APPLY); - Collider_UpdateSpheres(1, &this->collider2); - Matrix_Pop(); - } -} - -void EnDh_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDh* this = (EnDh*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dh.c", 1099); - if (this->alpha == 255) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - POLY_OPA_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, EnDh_PostLimbDraw, &this->actor, POLY_OPA_DISP); - } else { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); - } - if (this->drawDirtWave) { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 85, 55, 0, 130); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->state.frames * -3) % 0x80, 0, 0x20, 0x40, 1, - (globalCtx->state.frames * -10) % 0x80, (globalCtx->state.frames * -20) % 0x100, - 0x20, 0x40)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 0, 0, 0, this->dirtWaveAlpha); - - Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_Scale(this->dirtWaveSpread * 0.01f, this->dirtWaveHeight * 0.01f, this->dirtWaveSpread * 0.01f, - MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dh.c", 1160), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_dh_DL_007FC0); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dh.c", 1166); -} diff --git a/src/overlays/actors/ovl_En_Dh/z_en_dh.cpp b/src/overlays/actors/ovl_En_Dh/z_en_dh.cpp new file mode 100644 index 000000000..70c8d3b53 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dh/z_en_dh.cpp @@ -0,0 +1,595 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DH_Z_EN_DH_C +#include "actor_common.h" +#include "z_en_dh.h" +#include "objects/object_dh/object_dh.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) + +typedef enum { + /* 0 */ DH_WAIT, + /* 1 */ DH_RETREAT, + /* 2 */ DH_BURROW, + /* 3 */ DH_WALK, + /* 4 */ DH_ATTACK, + /* 5 */ DH_DEATH, + /* 6 */ DH_DAMAGE +} EnDhAction; + +void EnDh_Init(Actor* pthis, GlobalContext* globalCtx); +void EnDh_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDh_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDh_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDh_SetupWait(EnDh* pthis); +void EnDh_SetupWalk(EnDh* pthis); +void EnDh_SetupAttack(EnDh* pthis); +void EnDh_SetupBurrow(EnDh* pthis); + +void EnDh_Wait(EnDh* pthis, GlobalContext* globalCtx); +void EnDh_Walk(EnDh* pthis, GlobalContext* globalCtx); +void EnDh_Retreat(EnDh* pthis, GlobalContext* globalCtx); +void EnDh_Attack(EnDh* pthis, GlobalContext* globalCtx); +void EnDh_Burrow(EnDh* pthis, GlobalContext* globalCtx); +void EnDh_Damage(EnDh* pthis, GlobalContext* globalCtx); +void EnDh_Death(EnDh* pthis, GlobalContext* globalCtx); + +ActorInit En_Dh_InitVars = { + ACTOR_EN_DH, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DH, + sizeof(EnDh), + (ActorFunc)EnDh_Init, + (ActorFunc)EnDh_Destroy, + (ActorFunc)EnDh_Update, + (ActorFunc)EnDh_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 35, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON | OCELEM_UNK3, + }, + { 1, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static DamageTable D_809EC620 = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0xF), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(0, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(0, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x0), + /* Kokiri sword */ DMG_ENTRY(2, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(2, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(4, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x2F, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), +}; + +void EnDh_SetupAction(EnDh* pthis, EnDhActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnDh_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDh* pthis = (EnDh*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = &D_809EC620; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_dh_Skel_007E88, &object_dh_Anim_005880, pthis->jointTable, + pthis->limbRotTable, 16); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 64.0f); + pthis->actor.params = ENDH_WAIT_UNDERGROUND; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.colChkInfo.health = LINK_IS_ADULT ? 14 : 20; + pthis->alpha = pthis->unk_258 = 255; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Collider_InitCylinder(globalCtx, &pthis->collider1); + Collider_SetCylinder(globalCtx, &pthis->collider1, &pthis->actor, &sCylinderInit); + Collider_InitJntSph(globalCtx, &pthis->collider2); + Collider_SetJntSph(globalCtx, &pthis->collider2, &pthis->actor, &sJntSphInit, pthis->elements); + EnDh_SetupWait(pthis); +} + +void EnDh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDh* pthis = (EnDh*)thisx; + + func_800F5B58(); + Collider_DestroyCylinder(globalCtx, &pthis->collider1); + Collider_DestroyJntSph(globalCtx, &pthis->collider2); +} + +void EnDh_SpawnDebris(GlobalContext* globalCtx, EnDh* pthis, Vec3f* spawnPos, f32 spread, s32 arg4, f32 accelXZ, + f32 scale) { + Vec3f pos; + Vec3f vel = { 0.0f, 8.0f, 0.0f }; + Vec3f accel = { 0.0f, -1.5f, 0.0f }; + f32 spreadAngle; + f32 scaleMod; + + spreadAngle = (Rand_ZeroOne() - 0.5f) * 6.28f; + pos.y = pthis->actor.floorHeight; + pos.x = (Math_SinF(spreadAngle) * spread) + spawnPos->x; + pos.z = (Math_CosF(spreadAngle) * spread) + spawnPos->z; + accel.x = (Rand_ZeroOne() - 0.5f) * accelXZ; + accel.z = (Rand_ZeroOne() - 0.5f) * accelXZ; + vel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; + scaleMod = (Rand_ZeroOne() * 5.0f) + 12.0f; + EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accel, arg4, scaleMod * scale, -1, 10, NULL); +} + +void EnDh_SetupWait(EnDh* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_dh_Anim_003A8C); + pthis->curAction = DH_WAIT; + pthis->actor.world.pos.x = Rand_CenteredFloat(600.0f) + pthis->actor.home.pos.x; + pthis->actor.world.pos.z = Rand_CenteredFloat(600.0f) + pthis->actor.home.pos.z; + pthis->actor.shape.yOffset = -15000.0f; + pthis->dirtWaveSpread = pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.flags |= ACTOR_FLAG_7; + pthis->dirtWavePhase = pthis->actionState = pthis->actor.params = ENDH_WAIT_UNDERGROUND; + EnDh_SetupAction(pthis, EnDh_Wait); +} + +void EnDh_Wait(EnDh* pthis, GlobalContext* globalCtx) { + if ((s32)pthis->skelAnime.curFrame == 5) { + func_800F5ACC(NA_BGM_MINI_BOSS); + } + if (Actor_GetCollidedExplosive(globalCtx, &pthis->collider1.base)) { + pthis->actor.params = ENDH_START_ATTACK_BOMB; + } + if ((pthis->actor.params >= ENDH_START_ATTACK_GRAB) || (pthis->actor.params <= ENDH_HANDS_KILLED_4)) { + switch (pthis->actionState) { + case 0: + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.flags &= ~ACTOR_FLAG_7; + pthis->actionState++; + pthis->drawDirtWave++; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_HIDE); + case 1: + pthis->dirtWavePhase += 0x3A7; + Math_SmoothStepToF(&pthis->dirtWaveSpread, 300.0f, 1.0f, 5.0f, 0.0f); + pthis->dirtWaveHeight = Math_SinS(pthis->dirtWavePhase) * 55.0f; + pthis->dirtWaveAlpha = (s16)(Math_SinS(pthis->dirtWavePhase) * 255.0f); + EnDh_SpawnDebris(globalCtx, pthis, &pthis->actor.world.pos, pthis->dirtWaveSpread, 4, 2.05f, 1.2f); + if (pthis->actor.shape.yOffset == 0.0f) { + pthis->drawDirtWave = false; + pthis->actionState++; + } else if (pthis->dirtWavePhase > 0x12C0) { + pthis->actor.shape.yOffset += 500.0f; + } + break; + case 2: + EnDh_SetupWalk(pthis); + break; + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x7D0, 0); + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.params != ENDH_START_ATTACK_BOMB) { + func_8008EEAC(globalCtx, &pthis->actor); + } + } +} + +void EnDh_SetupWalk(EnDh* pthis) { + Animation_Change(&pthis->skelAnime, &object_dh_Anim_003A8C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_dh_Anim_003A8C) - 3.0f, ANIMMODE_LOOP, -6.0f); + pthis->curAction = DH_WALK; + pthis->timer = 300; + pthis->actor.speedXZ = 1.0f; + EnDh_SetupAction(pthis, EnDh_Walk); +} + +void EnDh_Walk(EnDh* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + SkelAnime_Update(&pthis->skelAnime); + if (((s32)pthis->skelAnime.curFrame % 8) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_WALK); + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_LAUGH); + } + if (pthis->actor.xzDistToPlayer <= 100.0f) { + pthis->actor.speedXZ = 0.0f; + if (Actor_IsFacingPlayer(&pthis->actor, 60 * 0x10000 / 360)) { + EnDh_SetupAttack(pthis); + } + } else if (--pthis->timer == 0) { + EnDh_SetupBurrow(pthis); + } +} + +void EnDh_SetupRetreat(EnDh* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &object_dh_Anim_005880, -4.0f); + pthis->curAction = DH_RETREAT; + pthis->timer = 70; + pthis->actor.speedXZ = 1.0f; + EnDh_SetupAction(pthis, EnDh_Retreat); +} + +void EnDh_Retreat(EnDh* pthis, GlobalContext* globalCtx) { + pthis->timer--; + if (pthis->timer == 0) { + pthis->retreat = false; + EnDh_SetupBurrow(pthis); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, (s16)(pthis->actor.yawTowardsPlayer + 0x8000), 1, 0xBB8, 0); + } + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + SkelAnime_Update(&pthis->skelAnime); +} + +void EnDh_SetupAttack(EnDh* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_dh_Anim_004658, -6.0f); + pthis->timer = pthis->actionState = 0; + pthis->curAction = DH_ATTACK; + pthis->actor.speedXZ = 0.0f; + EnDh_SetupAction(pthis, EnDh_Attack); +} + +void EnDh_Attack(EnDh* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actionState++; + } else if ((pthis->actor.xzDistToPlayer > 100.0f) || !Actor_IsFacingPlayer(&pthis->actor, 60 * 0x10000 / 360)) { + Animation_Change(&pthis->skelAnime, &object_dh_Anim_004658, -1.0f, pthis->skelAnime.curFrame, 0.0f, ANIMMODE_ONCE, + -4.0f); + pthis->actionState = 4; + pthis->collider2.base.atFlags = pthis->collider2.elements[0].info.toucherFlags = AT_NONE; // also TOUCH_NONE + pthis->collider2.elements[0].info.toucher.dmgFlags = pthis->collider2.elements[0].info.toucher.damage = 0; + } + switch (pthis->actionState) { + case 1: + Animation_PlayOnce(&pthis->skelAnime, &object_dh_Anim_001A3C); + pthis->actionState++; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_BITE); + case 0: + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x5DC, 0); + break; + case 2: + if (pthis->skelAnime.curFrame >= 4.0f) { + pthis->collider2.base.atFlags = pthis->collider2.elements[0].info.toucherFlags = + AT_ON | AT_TYPE_ENEMY; // also TOUCH_ON | TOUCH_SFX_WOOD + pthis->collider2.elements[0].info.toucher.dmgFlags = 0xFFCFFFFF; + pthis->collider2.elements[0].info.toucher.damage = 8; + } + if (pthis->collider2.base.atFlags & AT_BOUNCED) { + pthis->collider2.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + pthis->collider2.base.atFlags = pthis->collider2.elements[0].info.toucherFlags = + AT_NONE; // also TOUCH_NONE + pthis->collider2.elements[0].info.toucher.dmgFlags = pthis->collider2.elements[0].info.toucher.damage = 0; + pthis->actionState++; + } else if (pthis->collider2.base.atFlags & AT_HIT) { + pthis->collider2.base.atFlags &= ~AT_HIT; + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.shape.rot.y, 8.0f); + } + break; + case 3: + if ((pthis->actor.xzDistToPlayer <= 100.0f) && (Actor_IsFacingPlayer(&pthis->actor, 60 * 0x10000 / 360))) { + Animation_Change(&pthis->skelAnime, &object_dh_Anim_004658, 1.0f, 20.0f, + Animation_GetLastFrame(&object_dh_Anim_004658), ANIMMODE_ONCE, -6.0f); + pthis->actionState = 0; + } else { + Animation_Change(&pthis->skelAnime, &object_dh_Anim_004658, -1.0f, + Animation_GetLastFrame(&object_dh_Anim_004658), 0.0f, ANIMMODE_ONCE, -4.0f); + pthis->actionState++; + pthis->collider2.base.atFlags = pthis->collider2.elements[0].info.toucherFlags = + AT_NONE; // also TOUCH_NONE + pthis->collider2.elements[0].info.toucher.dmgFlags = pthis->collider2.elements[0].info.toucher.damage = 0; + } + break; + case 5: + EnDh_SetupWalk(pthis); + break; + case 4: + break; + } + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; +} + +void EnDh_SetupBurrow(EnDh* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_dh_Anim_002148, -6.0f); + pthis->curAction = DH_BURROW; + pthis->dirtWaveSpread = pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->dirtWavePhase = 0; + pthis->actionState = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_HIDE); + EnDh_SetupAction(pthis, EnDh_Burrow); +} + +void EnDh_Burrow(EnDh* pthis, GlobalContext* globalCtx) { + switch (pthis->actionState) { + case 0: + pthis->actionState++; + pthis->drawDirtWave++; + pthis->collider1.base.atFlags = pthis->collider1.info.toucherFlags = + AT_ON | AT_TYPE_ENEMY; // also TOUCH_ON | TOUCH_SFX_WOOD + pthis->collider1.info.toucher.dmgFlags = 0xFFCFFFFF; + pthis->collider1.info.toucher.damage = 4; + case 1: + pthis->dirtWavePhase += 0x47E; + Math_SmoothStepToF(&pthis->dirtWaveSpread, 300.0f, 1.0f, 8.0f, 0.0f); + pthis->dirtWaveHeight = Math_SinS(pthis->dirtWavePhase) * 55.0f; + pthis->dirtWaveAlpha = (s16)(Math_SinS(pthis->dirtWavePhase) * 255.0f); + EnDh_SpawnDebris(globalCtx, pthis, &pthis->actor.world.pos, pthis->dirtWaveSpread, 4, 2.05f, 1.2f); + pthis->collider1.dim.radius = pthis->dirtWaveSpread * 0.6f; + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actionState++; + } + break; + case 2: + pthis->drawDirtWave = false; + pthis->collider1.dim.radius = 35; + pthis->collider1.base.atFlags = pthis->collider1.info.toucherFlags = AT_NONE; // Also TOUCH_NONE + pthis->collider1.info.toucher.dmgFlags = pthis->collider1.info.toucher.damage = 0; + EnDh_SetupWait(pthis); + break; + } +} + +void EnDh_SetupDamage(EnDh* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_dh_Anim_003D6C, -6.0f); + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = -1.0f; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_DAMAGE); + pthis->curAction = DH_DAMAGE; + EnDh_SetupAction(pthis, EnDh_Damage); +} + +void EnDh_Damage(EnDh* pthis, GlobalContext* globalCtx) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.15f; + } + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->retreat) { + EnDh_SetupRetreat(pthis, globalCtx); + } else if ((pthis->actor.xzDistToPlayer <= 105.0f) && Actor_IsFacingPlayer(&pthis->actor, 60 * 0x10000 / 360)) { + f32 frames = Animation_GetLastFrame(&object_dh_Anim_004658); + + EnDh_SetupAttack(pthis); + Animation_Change(&pthis->skelAnime, &object_dh_Anim_004658, 1.0f, 20.0f, frames, ANIMMODE_ONCE, -6.0f); + } else { + EnDh_SetupWalk(pthis); + } + pthis->unk_258 = 255; + } +} + +void EnDh_SetupDeath(EnDh* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_dh_Anim_0032BC, -1.0f); + pthis->curAction = DH_DEATH; + pthis->timer = 300; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + func_800F5B58(); + pthis->actor.params = ENDH_DEATH; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_DEAD); + EnDh_SetupAction(pthis, EnDh_Death); +} + +void EnDh_Death(EnDh* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) || (pthis->timer != 300)) { + if (pthis->timer == 300) { + Animation_PlayLoop(&pthis->skelAnime, &object_dh_Anim_00375C); + } + pthis->timer--; + if (pthis->timer < 150) { + if (pthis->alpha != 0) { + pthis->actor.scale.y -= 0.000075f; + pthis->actor.shape.shadowAlpha = pthis->alpha -= 5; + } else { + Actor_Kill(&pthis->actor); + return; + } + } + } else { + if (((s32)pthis->skelAnime.curFrame == 53) || ((s32)pthis->skelAnime.curFrame == 56) || + ((s32)pthis->skelAnime.curFrame == 61)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } + if ((s32)pthis->skelAnime.curFrame == 61) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + } + } +} + +void EnDh_CollisionCheck(EnDh* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 lastHealth; + + if ((pthis->collider2.base.acFlags & AC_HIT) && !pthis->retreat) { + pthis->collider2.base.acFlags &= ~AC_HIT; + if ((pthis->actor.colChkInfo.damageEffect != 0) && (pthis->actor.colChkInfo.damageEffect != 6)) { + pthis->collider2.base.atFlags = pthis->collider2.elements[0].info.toucherFlags = AT_NONE; // also TOUCH_NONE + pthis->collider2.elements[0].info.toucher.dmgFlags = pthis->collider2.elements[0].info.toucher.damage = 0; + if (player->unk_844 != 0) { + pthis->unk_258 = player->unk_845; + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + lastHealth = pthis->actor.colChkInfo.health; + if (Actor_ApplyDamage(&pthis->actor) == 0) { + EnDh_SetupDeath(pthis); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x90); + } else { + if (((lastHealth >= 15) && (pthis->actor.colChkInfo.health < 15)) || + ((lastHealth >= 9) && (pthis->actor.colChkInfo.health < 9)) || + ((lastHealth >= 3) && (pthis->actor.colChkInfo.health < 3))) { + + pthis->retreat++; + } + EnDh_SetupDamage(pthis); + } + } + } +} + +void EnDh_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDh* pthis = (EnDh*)thisx; + Player* player = GET_PLAYER(globalCtx); + s32 pad40; + + EnDh_CollisionCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 45.0f, 45.0f, 0x1D); + pthis->actor.focus.pos = pthis->headPos; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider1); + if (pthis->actor.colChkInfo.health > 0) { + if (pthis->curAction == DH_WAIT) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + } + if (((pthis->curAction != DH_DAMAGE) && (pthis->actor.shape.yOffset == 0.0f)) || + ((player->unk_844 != 0) && (player->unk_845 != pthis->unk_258))) { + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + } + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + } +} + +void EnDh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + Vec3f headOffset = { 2000.0f, 1000.0f, 0.0f }; + EnDh* pthis = (EnDh*)thisx; + + if (limbIndex == 13) { + Matrix_MultVec3f(&headOffset, &pthis->headPos); + Matrix_Push(); + Matrix_Translate(headOffset.x, headOffset.y, headOffset.z, MTXMODE_APPLY); + Collider_UpdateSpheres(1, &pthis->collider2); + Matrix_Pop(); + } +} + +void EnDh_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDh* pthis = (EnDh*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dh.c", 1099); + if (pthis->alpha == 255) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + POLY_OPA_DISP = + SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, NULL, EnDh_PostLimbDraw, &pthis->actor, POLY_OPA_DISP); + } else { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, NULL, NULL, &pthis->actor, POLY_XLU_DISP); + } + if (pthis->drawDirtWave) { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 85, 55, 0, 130); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->state.frames * -3) % 0x80, 0, 0x20, 0x40, 1, + (globalCtx->state.frames * -10) % 0x80, (globalCtx->state.frames * -20) % 0x100, + 0x20, 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 0, 0, 0, pthis->dirtWaveAlpha); + + Matrix_Translate(0.0f, -pthis->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Scale(pthis->dirtWaveSpread * 0.01f, pthis->dirtWaveHeight * 0.01f, pthis->dirtWaveSpread * 0.01f, + MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dh.c", 1160), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_dh_DL_007FC0); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dh.c", 1166); +} diff --git a/src/overlays/actors/ovl_En_Dha/z_en_dha.c b/src/overlays/actors/ovl_En_Dha/z_en_dha.c deleted file mode 100644 index 66143a36a..000000000 --- a/src/overlays/actors/ovl_En_Dha/z_en_dha.c +++ /dev/null @@ -1,475 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DHA_Z_EN_DHA_C -#include "actor_common.h" -/* - * File: z_en_dha.c - * Overlay: ovl_En_Dha - * Description: Dead Hand's Hand - */ - -#include "z_en_dha.h" -#include "overlays/actors/ovl_En_Dh/z_en_dh.h" -#include "objects/object_dh/object_dh.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnDha_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDha_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDha_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDha_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDha_SetupWait(EnDha* this); -void EnDha_Wait(EnDha* this, GlobalContext* globalCtx); -void EnDha_SetupTakeDamage(EnDha* this); -void EnDha_TakeDamage(EnDha* this, GlobalContext* globalCtx); -void EnDha_SetupDeath(EnDha* this); -void EnDha_Die(EnDha* this, GlobalContext* globalCtx); -void EnDha_UpdateHealth(EnDha* this, GlobalContext* globalCtx); - -const ActorInit En_Dha_InitVars = { - ACTOR_EN_DHA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DH, - sizeof(EnDha), - (ActorFunc)EnDha_Init, - (ActorFunc)EnDha_Destroy, - (ActorFunc)EnDha_Update, - (ActorFunc)EnDha_Draw, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0xF), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(0, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Kokiri sword */ DMG_ENTRY(2, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(2, 0xF), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(4, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xF), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 1, { { 0, 0, 0 }, 12 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 2, { { 3200, 0, 0 }, 10 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 3, { { 1200, 0, 0 }, 10 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 4, { { 2700, 0, 0 }, 10 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 5, { { 1200, 0, 0 }, 10 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 5, - sJntSphElementsInit, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x2E, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), -}; - -void EnDha_SetupAction(EnDha* this, EnDhaActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnDha_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDha* this = (EnDha*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &sDamageTable; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dh_Skel_000BD8, &object_dh_Anim_0015B0, this->jointTable, - this->morphTable, 4); - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawFeet, 90.0f); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 50.0f; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.colChkInfo.health = 8; - this->limbAngleX[0] = -0x4000; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItem); - this->actor.flags &= ~ACTOR_FLAG_0; - - EnDha_SetupWait(this); -} - -void EnDha_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDha* this = (EnDha*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnDha_SetupWait(EnDha* this) { - Animation_PlayLoop(&this->skelAnime, &object_dh_Anim_0015B0); - this->unk_1C0 = 0; - this->actionTimer = ((Rand_ZeroOne() * 10.0f) + 5.0f); - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.home.rot.z = 1; - EnDha_SetupAction(this, EnDha_Wait); -} - -void EnDha_Wait(EnDha* this, GlobalContext* globalCtx) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; // unused - Vec3f armPosMultiplier1 = { 0.0f, 0.0f, 55.0f }; - Vec3f armPosMultiplier2 = { 0.0f, 0.0f, -54.0f }; - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s32 pad2; - Vec3f playerPos = player->actor.world.pos; - Vec3s angle; - s16 yaw; - - playerPos.x += Math_SinS(player->actor.shape.rot.y) * -5.0f; - playerPos.z += Math_CosS(player->actor.shape.rot.y) * -5.0f; - - if (!LINK_IS_ADULT) { - playerPos.y += 38.0f; - } else { - playerPos.y += 56.0f; - } - - if (this->actor.xzDistToPlayer <= 100.0f) { - this->handAngle.y = this->handAngle.x = this->limbAngleY = 0; - - if (Math_Vec3f_DistXYZ(&playerPos, &this->handPos[0]) <= 12.0f) { - if (this->unk_1CC == 0) { - if (globalCtx->grabPlayer(globalCtx, player)) { - this->timer = 0; - this->unk_1CC++; - - if (this->actor.parent != NULL) { - this->actor.parent->params = ENDH_START_ATTACK_GRAB; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_GRIP); - } - } else { - this->timer += 0x1194; - this->limbAngleY = Math_SinS(this->timer) * 1820.0f; - - if (!(player->stateFlags2 & 0x80)) { - this->unk_1CC = 0; - EnDha_SetupTakeDamage(this); - return; - } - - if (this->timer < -0x6E6B) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_GRIP); - } - } - - func_80035844(&this->handPos[1], &playerPos, &this->handAngle, 0); - this->handAngle.y -= this->actor.shape.rot.y + this->limbAngleY; - this->handAngle.x -= this->actor.shape.rot.x + this->limbAngleX[0] + this->limbAngleX[1]; - } else { - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - } - - if (this->actor.home.rot.z != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_HAND_AT); - this->actor.home.rot.z = 0; - } - } - - this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &playerPos); - - Math_SmoothStepToF(&this->handPos[0].x, playerPos.x, 1.0f, 16.0f, 0.0f); - Math_SmoothStepToF(&this->handPos[0].y, playerPos.y, 1.0f, 16.0f, 0.0f); - Math_SmoothStepToF(&this->handPos[0].z, playerPos.z, 1.0f, 16.0f, 0.0f); - - func_80035844(&this->armPos, &this->handPos[0], &angle, 0); - Matrix_Translate(this->handPos[0].x, this->handPos[0].y, this->handPos[0].z, MTXMODE_NEW); - Matrix_RotateZYX(angle.x, angle.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&armPosMultiplier2, &this->armPos); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - func_80035844(&this->actor.world.pos, &this->armPos, &angle, 0); - Matrix_RotateZYX(angle.x, angle.y, 0, MTXMODE_APPLY); - Matrix_MultVec3f(&armPosMultiplier1, &this->armPos); - this->limbAngleX[0] = Math_Vec3f_Pitch(&this->actor.world.pos, &this->armPos); - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->armPos) - this->actor.shape.rot.y; - - if (ABS(yaw) >= 0x4000) { - this->limbAngleX[0] = -0x8000 - this->limbAngleX[0]; - } - - this->limbAngleX[1] = (Math_Vec3f_Pitch(&this->armPos, &this->handPos[0]) - this->limbAngleX[0]); - - if (this->limbAngleX[1] < 0) { - this->limbAngleX[0] += this->limbAngleX[1] * 2; - this->limbAngleX[1] *= -2; - } - } else { - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - } - - this->actor.home.rot.z = 1; - Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 0x3E8, 0); - Math_SmoothStepToS(&this->limbAngleX[0], -0x4000, 1, 0x3E8, 0); - SkelAnime_Update(&this->skelAnime); - } -} - -void EnDha_SetupTakeDamage(EnDha* this) { - this->actionTimer = 15; - EnDha_SetupAction(this, EnDha_TakeDamage); -} - -void EnDha_TakeDamage(EnDha* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - } - - Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 2000, 0); - Math_SmoothStepToS(&this->limbAngleY, 0, 1, 600, 0); - Math_SmoothStepToS(&this->limbAngleX[0], -0x4000, 1, 2000, 0); - SkelAnime_Update(&this->skelAnime); - this->actionTimer--; - - if (this->actionTimer == 0) { - EnDha_SetupWait(this); - } -} - -void EnDha_SetupDeath(EnDha* this) { - this->unk_1C0 = 8; - this->actionTimer = 300; - - if (this->actor.parent != NULL) { - if (this->actor.parent->params != ENDH_DEATH) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_HAND_DEAD); - } - if (this->actor.parent->params <= ENDH_WAIT_UNDERGROUND) { - this->actor.parent->params--; - } - } - - EnDha_SetupAction(this, EnDha_Die); -} - -void EnDha_Die(EnDha* this, GlobalContext* globalCtx) { - s16 angle; - Vec3f vec; - Player* player = GET_PLAYER(globalCtx); - - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - } - - Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 0x7D0, 0); - angle = Math_SmoothStepToS(&this->limbAngleX[0], -0x4000, 1, 0x7D0, 0); - SkelAnime_Update(&this->skelAnime); - - if (angle == 0) { - vec = this->actor.world.pos; - - if (this->actionTimer != 0) { - if (-12000.0f < this->actor.shape.yOffset) { - this->actor.shape.yOffset -= 1000.0f; - func_80033480(globalCtx, &vec, 7.0f, 1, 0x5A, 0x14, 1); - } else { - this->actionTimer--; - - if ((this->actor.parent != NULL) && (this->actor.parent->params == ENDH_DEATH)) { - Actor_Kill(&this->actor); - } - } - } else { - this->actor.shape.yOffset += 500.0f; - func_80033480(globalCtx, &vec, 7.0f, 1, 0x5A, 0x14, 1); - - if (this->actor.shape.yOffset == 0.0f) { - EnDha_SetupWait(this); - } - } - } -} - -void EnDha_UpdateHealth(EnDha* this, GlobalContext* globalCtx) { - if (!((this->unk_1C0 >= 8) || !(this->collider.base.acFlags & AC_HIT))) { - this->collider.base.acFlags &= ~AC_HIT; - - if (this->actor.colChkInfo.damageEffect == 0 || this->actor.colChkInfo.damageEffect == 6) { - return; - } else { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - if (Actor_ApplyDamage(&this->actor) == 0) { - EnDha_SetupDeath(this); - this->actor.colChkInfo.health = 8; - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEADHAND_DAMAGE); - this->unk_1C0 = 9; - EnDha_SetupTakeDamage(this); - } - } - } - - if ((this->actor.parent != NULL) && (this->actor.parent->params == ENDH_DEATH)) { - EnDha_SetupDeath(this); - } -} - -void EnDha_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDha* this = (EnDha*)thisx; - - if (this->actor.parent == NULL) { - this->actor.parent = Actor_FindNearby(globalCtx, &this->actor, ACTOR_EN_DH, ACTORCAT_ENEMY, 10000.0f); - } - - EnDha_UpdateHealth(this, globalCtx); - this->actionFunc(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnDha_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnDha* this = (EnDha*)thisx; - - if (limbIndex == 1) { - rot->y = -(s16)(this->limbAngleX[0] + 0x4000); - rot->z += this->limbAngleY; - } else if (limbIndex == 2) { - rot->z = this->limbAngleX[1]; - rot->y -= this->limbAngleY; - } else if (limbIndex == 3) { - rot->y = -this->handAngle.y; - rot->z = -this->handAngle.x; - } - - return false; -} - -void EnDha_OverridePostDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - Vec3f handVec = { 1100.0f, 0.0f, 0.0f }; - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - EnDha* this = (EnDha*)thisx; - - switch (limbIndex) { - case 1: - Collider_UpdateSpheres(2, &this->collider); - Collider_UpdateSpheres(3, &this->collider); - break; - case 2: - Collider_UpdateSpheres(4, &this->collider); - Collider_UpdateSpheres(5, &this->collider); - Matrix_MultVec3f(&zeroVec, &this->armPos); - break; - case 3: - Collider_UpdateSpheres(1, &this->collider); - Matrix_MultVec3f(&handVec, &this->handPos[0]); - Matrix_MultVec3f(&zeroVec, &this->handPos[1]); - break; - } -} - -void EnDha_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDha* this = (EnDha*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnDha_OverrideLimbDraw, EnDha_OverridePostDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Dha/z_en_dha.cpp b/src/overlays/actors/ovl_En_Dha/z_en_dha.cpp new file mode 100644 index 000000000..f9f5ab00a --- /dev/null +++ b/src/overlays/actors/ovl_En_Dha/z_en_dha.cpp @@ -0,0 +1,475 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DHA_Z_EN_DHA_C +#include "actor_common.h" +/* + * File: z_en_dha.c + * Overlay: ovl_En_Dha + * Description: Dead Hand's Hand + */ + +#include "z_en_dha.h" +#include "overlays/actors/ovl_En_Dh/z_en_dh.h" +#include "objects/object_dh/object_dh.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnDha_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDha_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDha_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDha_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDha_SetupWait(EnDha* pthis); +void EnDha_Wait(EnDha* pthis, GlobalContext* globalCtx); +void EnDha_SetupTakeDamage(EnDha* pthis); +void EnDha_TakeDamage(EnDha* pthis, GlobalContext* globalCtx); +void EnDha_SetupDeath(EnDha* pthis); +void EnDha_Die(EnDha* pthis, GlobalContext* globalCtx); +void EnDha_UpdateHealth(EnDha* pthis, GlobalContext* globalCtx); + +ActorInit En_Dha_InitVars = { + ACTOR_EN_DHA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DH, + sizeof(EnDha), + (ActorFunc)EnDha_Init, + (ActorFunc)EnDha_Destroy, + (ActorFunc)EnDha_Update, + (ActorFunc)EnDha_Draw, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0xF), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(0, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(0, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x0), + /* Kokiri sword */ DMG_ENTRY(2, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(2, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(4, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 1, { { 0, 0, 0 }, 12 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 2, { { 3200, 0, 0 }, 10 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 3, { { 1200, 0, 0 }, 10 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 4, { { 2700, 0, 0 }, 10 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 5, { { 1200, 0, 0 }, 10 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 5, + sJntSphElementsInit, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x2E, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), +}; + +void EnDha_SetupAction(EnDha* pthis, EnDhaActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnDha_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDha* pthis = (EnDha*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_dh_Skel_000BD8, &object_dh_Anim_0015B0, pthis->jointTable, + pthis->morphTable, 4); + ActorShape_Init(&pthis->actor.shape, 0, ActorShadow_DrawFeet, 90.0f); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 50.0f; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.colChkInfo.health = 8; + pthis->limbAngleX[0] = -0x4000; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItem); + pthis->actor.flags &= ~ACTOR_FLAG_0; + + EnDha_SetupWait(pthis); +} + +void EnDha_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDha* pthis = (EnDha*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnDha_SetupWait(EnDha* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_dh_Anim_0015B0); + pthis->unk_1C0 = 0; + pthis->actionTimer = ((Rand_ZeroOne() * 10.0f) + 5.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.home.rot.z = 1; + EnDha_SetupAction(pthis, EnDha_Wait); +} + +void EnDha_Wait(EnDha* pthis, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; // unused + Vec3f armPosMultiplier1 = { 0.0f, 0.0f, 55.0f }; + Vec3f armPosMultiplier2 = { 0.0f, 0.0f, -54.0f }; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 pad2; + Vec3f playerPos = player->actor.world.pos; + Vec3s angle; + s16 yaw; + + playerPos.x += Math_SinS(player->actor.shape.rot.y) * -5.0f; + playerPos.z += Math_CosS(player->actor.shape.rot.y) * -5.0f; + + if (!LINK_IS_ADULT) { + playerPos.y += 38.0f; + } else { + playerPos.y += 56.0f; + } + + if (pthis->actor.xzDistToPlayer <= 100.0f) { + pthis->handAngle.y = pthis->handAngle.x = pthis->limbAngleY = 0; + + if (Math_Vec3f_DistXYZ(&playerPos, &pthis->handPos[0]) <= 12.0f) { + if (pthis->unk_1CC == 0) { + if (globalCtx->grabPlayer(globalCtx, player)) { + pthis->timer = 0; + pthis->unk_1CC++; + + if (pthis->actor.parent != NULL) { + pthis->actor.parent->params = ENDH_START_ATTACK_GRAB; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_GRIP); + } + } else { + pthis->timer += 0x1194; + pthis->limbAngleY = Math_SinS(pthis->timer) * 1820.0f; + + if (!(player->stateFlags2 & 0x80)) { + pthis->unk_1CC = 0; + EnDha_SetupTakeDamage(pthis); + return; + } + + if (pthis->timer < -0x6E6B) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_GRIP); + } + } + + func_80035844(&pthis->handPos[1], &playerPos, &pthis->handAngle, 0); + pthis->handAngle.y -= pthis->actor.shape.rot.y + pthis->limbAngleY; + pthis->handAngle.x -= pthis->actor.shape.rot.x + pthis->limbAngleX[0] + pthis->limbAngleX[1]; + } else { + if ((player->stateFlags2 & 0x80) && (&pthis->actor == player->actor.parent)) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + } + + if (pthis->actor.home.rot.z != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_HAND_AT); + pthis->actor.home.rot.z = 0; + } + } + + pthis->actor.shape.rot.y = Math_Vec3f_Yaw(&pthis->actor.world.pos, &playerPos); + + Math_SmoothStepToF(&pthis->handPos[0].x, playerPos.x, 1.0f, 16.0f, 0.0f); + Math_SmoothStepToF(&pthis->handPos[0].y, playerPos.y, 1.0f, 16.0f, 0.0f); + Math_SmoothStepToF(&pthis->handPos[0].z, playerPos.z, 1.0f, 16.0f, 0.0f); + + func_80035844(&pthis->armPos, &pthis->handPos[0], &angle, 0); + Matrix_Translate(pthis->handPos[0].x, pthis->handPos[0].y, pthis->handPos[0].z, MTXMODE_NEW); + Matrix_RotateZYX(angle.x, angle.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&armPosMultiplier2, &pthis->armPos); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + func_80035844(&pthis->actor.world.pos, &pthis->armPos, &angle, 0); + Matrix_RotateZYX(angle.x, angle.y, 0, MTXMODE_APPLY); + Matrix_MultVec3f(&armPosMultiplier1, &pthis->armPos); + pthis->limbAngleX[0] = Math_Vec3f_Pitch(&pthis->actor.world.pos, &pthis->armPos); + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->armPos) - pthis->actor.shape.rot.y; + + if (ABS(yaw) >= 0x4000) { + pthis->limbAngleX[0] = -0x8000 - pthis->limbAngleX[0]; + } + + pthis->limbAngleX[1] = (Math_Vec3f_Pitch(&pthis->armPos, &pthis->handPos[0]) - pthis->limbAngleX[0]); + + if (pthis->limbAngleX[1] < 0) { + pthis->limbAngleX[0] += pthis->limbAngleX[1] * 2; + pthis->limbAngleX[1] *= -2; + } + } else { + if ((player->stateFlags2 & 0x80) && (&pthis->actor == player->actor.parent)) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + } + + pthis->actor.home.rot.z = 1; + Math_SmoothStepToS(&pthis->limbAngleX[1], 0, 1, 0x3E8, 0); + Math_SmoothStepToS(&pthis->limbAngleX[0], -0x4000, 1, 0x3E8, 0); + SkelAnime_Update(&pthis->skelAnime); + } +} + +void EnDha_SetupTakeDamage(EnDha* pthis) { + pthis->actionTimer = 15; + EnDha_SetupAction(pthis, EnDha_TakeDamage); +} + +void EnDha_TakeDamage(EnDha* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags2 & 0x80) && (&pthis->actor == player->actor.parent)) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + } + + Math_SmoothStepToS(&pthis->limbAngleX[1], 0, 1, 2000, 0); + Math_SmoothStepToS(&pthis->limbAngleY, 0, 1, 600, 0); + Math_SmoothStepToS(&pthis->limbAngleX[0], -0x4000, 1, 2000, 0); + SkelAnime_Update(&pthis->skelAnime); + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + EnDha_SetupWait(pthis); + } +} + +void EnDha_SetupDeath(EnDha* pthis) { + pthis->unk_1C0 = 8; + pthis->actionTimer = 300; + + if (pthis->actor.parent != NULL) { + if (pthis->actor.parent->params != ENDH_DEATH) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_HAND_DEAD); + } + if (pthis->actor.parent->params <= ENDH_WAIT_UNDERGROUND) { + pthis->actor.parent->params--; + } + } + + EnDha_SetupAction(pthis, EnDha_Die); +} + +void EnDha_Die(EnDha* pthis, GlobalContext* globalCtx) { + s16 angle; + Vec3f vec; + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags2 & 0x80) && (&pthis->actor == player->actor.parent)) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + } + + Math_SmoothStepToS(&pthis->limbAngleX[1], 0, 1, 0x7D0, 0); + angle = Math_SmoothStepToS(&pthis->limbAngleX[0], -0x4000, 1, 0x7D0, 0); + SkelAnime_Update(&pthis->skelAnime); + + if (angle == 0) { + vec = pthis->actor.world.pos; + + if (pthis->actionTimer != 0) { + if (-12000.0f < pthis->actor.shape.yOffset) { + pthis->actor.shape.yOffset -= 1000.0f; + func_80033480(globalCtx, &vec, 7.0f, 1, 0x5A, 0x14, 1); + } else { + pthis->actionTimer--; + + if ((pthis->actor.parent != NULL) && (pthis->actor.parent->params == ENDH_DEATH)) { + Actor_Kill(&pthis->actor); + } + } + } else { + pthis->actor.shape.yOffset += 500.0f; + func_80033480(globalCtx, &vec, 7.0f, 1, 0x5A, 0x14, 1); + + if (pthis->actor.shape.yOffset == 0.0f) { + EnDha_SetupWait(pthis); + } + } + } +} + +void EnDha_UpdateHealth(EnDha* pthis, GlobalContext* globalCtx) { + if (!((pthis->unk_1C0 >= 8) || !(pthis->collider.base.acFlags & AC_HIT))) { + pthis->collider.base.acFlags &= ~AC_HIT; + + if (pthis->actor.colChkInfo.damageEffect == 0 || pthis->actor.colChkInfo.damageEffect == 6) { + return; + } else { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + if (Actor_ApplyDamage(&pthis->actor) == 0) { + EnDha_SetupDeath(pthis); + pthis->actor.colChkInfo.health = 8; + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xE0); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEADHAND_DAMAGE); + pthis->unk_1C0 = 9; + EnDha_SetupTakeDamage(pthis); + } + } + } + + if ((pthis->actor.parent != NULL) && (pthis->actor.parent->params == ENDH_DEATH)) { + EnDha_SetupDeath(pthis); + } +} + +void EnDha_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDha* pthis = (EnDha*)thisx; + + if (pthis->actor.parent == NULL) { + pthis->actor.parent = Actor_FindNearby(globalCtx, &pthis->actor, ACTOR_EN_DH, ACTORCAT_ENEMY, 10000.0f); + } + + EnDha_UpdateHealth(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnDha_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnDha* pthis = (EnDha*)thisx; + + if (limbIndex == 1) { + rot->y = -(s16)(pthis->limbAngleX[0] + 0x4000); + rot->z += pthis->limbAngleY; + } else if (limbIndex == 2) { + rot->z = pthis->limbAngleX[1]; + rot->y -= pthis->limbAngleY; + } else if (limbIndex == 3) { + rot->y = -pthis->handAngle.y; + rot->z = -pthis->handAngle.x; + } + + return false; +} + +void EnDha_OverridePostDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + Vec3f handVec = { 1100.0f, 0.0f, 0.0f }; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + EnDha* pthis = (EnDha*)thisx; + + switch (limbIndex) { + case 1: + Collider_UpdateSpheres(2, &pthis->collider); + Collider_UpdateSpheres(3, &pthis->collider); + break; + case 2: + Collider_UpdateSpheres(4, &pthis->collider); + Collider_UpdateSpheres(5, &pthis->collider); + Matrix_MultVec3f(&zeroVec, &pthis->armPos); + break; + case 3: + Collider_UpdateSpheres(1, &pthis->collider); + Matrix_MultVec3f(&handVec, &pthis->handPos[0]); + Matrix_MultVec3f(&zeroVec, &pthis->handPos[1]); + break; + } +} + +void EnDha_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDha* pthis = (EnDha*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnDha_OverrideLimbDraw, EnDha_OverridePostDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c deleted file mode 100644 index 375c2e930..000000000 --- a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c +++ /dev/null @@ -1,588 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DIVING_GAME_Z_EN_DIVING_GAME_C -#include "actor_common.h" -/* - * File: z_en_diving_game.c - * Overlay: ovl_En_Diving_Game - * Description: Diving minigame - */ - -#include "z_en_diving_game.h" -#include "overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.h" -#include "objects/object_zo/object_zo.h" -#include "vt.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnDivingGame_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDivingGame_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDivingGame_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDivingGame_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809EDCB0(EnDivingGame* this, GlobalContext* globalCtx); -void EnDivingGame_Talk(EnDivingGame* this, GlobalContext* globalCtx); -void EnDivingGame_HandlePlayChoice(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE048(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE0FC(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE194(EnDivingGame* this, GlobalContext* globalCtx); -void EnDivingGame_SetupRupeeThrow(EnDivingGame* this, GlobalContext* globalCtx); -void EnDivingGame_RupeeThrow(EnDivingGame* this, GlobalContext* globalCtx); -void EnDivingGame_SetupUnderwaterViewCs(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE780(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE800(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE8F0(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EE96C(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EEA00(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EEA90(EnDivingGame* this, GlobalContext* globalCtx); -void func_809EEAF8(EnDivingGame* this, GlobalContext* globalCtx); - -const ActorInit En_Diving_Game_InitVars = { - ACTOR_EN_DIVING_GAME, - ACTORCAT_NPC, - FLAGS, - OBJECT_ZO, - sizeof(EnDivingGame), - (ActorFunc)EnDivingGame_Init, - (ActorFunc)EnDivingGame_Destroy, - (ActorFunc)EnDivingGame_Update, - (ActorFunc)EnDivingGame_Draw, -}; - -// used to ensure there's only one instance of this actor. -static u8 D_809EF0B0 = false; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 10, 10, 0, { 0, 0, 0 } }, -}; - -static void* sEyeTextures[] = { - gZoraEyeOpenTex, - gZoraEyeHalfTex, - gZoraEyeClosedTex, -}; - -void EnDivingGame_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDivingGame* this = (EnDivingGame*)thisx; - - this->actor.gravity = -3.0f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 素もぐりGO ☆☆☆☆☆ \n" VT_RST); - this->actor.room = -1; - this->actor.scale.x = 0.01f; - this->actor.scale.y = 0.012999999f; - this->actor.scale.z = 0.0139999995f; - if (D_809EF0B0) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もういてる原 ☆☆☆☆☆ \n" VT_RST); - this->unk_31F = 1; - Actor_Kill(&this->actor); - } else { - D_809EF0B0 = true; - this->actor.targetMode = 0; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actionFunc = func_809EDCB0; - } -} - -void EnDivingGame_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDivingGame* this = (EnDivingGame*)thisx; - - if (this->unk_31F == 0) { - gSaveContext.timer1State = 0; - } - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnDivingGame_SpawnRuppy(EnDivingGame* this, GlobalContext* globalCtx) { - EnExRuppy* rupee; - Vec3f rupeePos; - - rupeePos.x = (Rand_ZeroOne() - 0.5f) * 30.0f + this->actor.world.pos.x; - rupeePos.y = (Rand_ZeroOne() - 0.5f) * 20.0f + (this->actor.world.pos.y + 30.0f); - rupeePos.z = (Rand_ZeroOne() - 0.5f) * 20.0f + this->actor.world.pos.z; - rupee = (EnExRuppy*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_RUPPY, rupeePos.x, - rupeePos.y, rupeePos.z, 0, (s16)Rand_CenteredFloat(3500.0f) - 1000, - this->rupeesLeftToThrow, 0); - if (rupee != NULL) { - rupee->actor.speedXZ = 12.0f; - rupee->actor.velocity.y = 6.0f; - } -} - -s32 EnDivingGame_HasMinigameFinished(EnDivingGame* this, GlobalContext* globalCtx) { - if (gSaveContext.timer1State == 10 && !Gameplay_InCsMode(globalCtx)) { - // Failed. - gSaveContext.timer1State = 0; - func_800F5B58(); - func_80078884(NA_SE_SY_FOUND); - this->actor.textId = 0x71AD; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_292 = TEXT_STATE_EVENT; - this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_809EE048; - return true; - } else { - s32 rupeesNeeded = 5; - - if (gSaveContext.eventChkInf[3] & 0x100) { - rupeesNeeded = 10; - } - if (this->grabbedRupeesCounter >= rupeesNeeded) { - // Won. - gSaveContext.timer1State = 0; - this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0; - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - this->actor.textId = 0x4055; - } else { - this->actor.textId = 0x405D; - if (this->extraWinCount < 100) { - this->extraWinCount++; - } - } - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_292 = TEXT_STATE_EVENT; - func_800F5B58(); - Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); - func_8002DF54(globalCtx, NULL, 8); - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - this->actionFunc = func_809EE96C; - } else { - this->actionFunc = func_809EE048; - } - return true; - } - } - return false; -} - -// EnDivingGame_FinishMinigame ? // Reset probably -void func_809EDCB0(EnDivingGame* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gZoraIdleAnim); - - Animation_Change(&this->skelAnime, &gZoraIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->notPlayingMinigame = true; - this->actionFunc = EnDivingGame_Talk; -} - -void EnDivingGame_Talk(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->state != ENDIVINGGAME_STATE_PLAYING || !EnDivingGame_HasMinigameFinished(this, globalCtx)) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->unk_292 != TEXT_STATE_DONE) { - switch (this->state) { - case ENDIVINGGAME_STATE_NOTPLAYING: - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = EnDivingGame_HandlePlayChoice; - break; - case ENDIVINGGAME_STATE_AWARDPRIZE: - this->actionFunc = func_809EEA00; - break; - case ENDIVINGGAME_STATE_PLAYING: - this->actionFunc = func_809EE8F0; - break; - } - } - } else { - if (Text_GetFaceReaction(globalCtx, 0x1D) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x1D); - this->unk_292 = TEXT_STATE_DONE; - } else { - switch (this->state) { - case ENDIVINGGAME_STATE_NOTPLAYING: - this->unk_292 = TEXT_STATE_CHOICE; - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - this->actor.textId = 0x4053; - this->phase = ENDIVINGGAME_PHASE_1; - } else { - this->actor.textId = 0x405C; - this->phase = ENDIVINGGAME_PHASE_2; - } - break; - case ENDIVINGGAME_STATE_AWARDPRIZE: - this->actor.textId = 0x4056; - this->unk_292 = TEXT_STATE_EVENT; - break; - case ENDIVINGGAME_STATE_PLAYING: - this->actor.textId = 0x405B; - this->unk_292 = TEXT_STATE_EVENT; - break; - } - } - func_8002F2CC(&this->actor, globalCtx, 80.0f); - } - } -} - -void EnDivingGame_HandlePlayChoice(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_292 == Message_GetState(&globalCtx->msgCtx) && - Message_ShouldAdvance(globalCtx)) { // Did player selected an answer? - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // Yes - if (gSaveContext.rupees >= 20) { - Rupees_ChangeBy(-20); - this->actor.textId = 0x4054; - } else { - this->actor.textId = 0x85; - this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0; - } - break; - case 1: // No - this->actor.textId = 0x2D; - this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0; - break; - } - if (!(gSaveContext.eventChkInf[3] & 0x100) || this->actor.textId == 0x85 || this->actor.textId == 0x2D) { - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_292 = TEXT_STATE_EVENT; - this->actionFunc = func_809EE048; - } else { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_809EE0FC; - } - } -} - -// Waits for the message to close -void func_809EE048(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - if (this->phase == ENDIVINGGAME_PHASE_ENDED) { - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = func_809EDCB0; - } else { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_809EE0FC; - } - } -} - -// another "start minigame" step -void func_809EE0FC(EnDivingGame* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gZoraThrowRupeesAnim); - - Animation_Change(&this->skelAnime, &gZoraThrowRupeesAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_ONCE, -10.0f); - this->notPlayingMinigame = false; - this->actionFunc = func_809EE194; -} - -// Wait a bit before start throwing the rupees. -void func_809EE194(EnDivingGame* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (currentFrame >= 15.0f) { - this->actionFunc = EnDivingGame_SetupRupeeThrow; - } -} - -void EnDivingGame_SetupRupeeThrow(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - this->subCamId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->subCamId, CAM_STAT_ACTIVE); - this->spawnRuppyTimer = 10; - this->unk_2F4.x = -210.0f; - this->unk_2F4.y = -80.0f; - this->unk_2F4.z = -1020.0f; - this->unk_2D0.x = -280.0f; - this->unk_2D0.y = -20.0f; - this->unk_2D0.z = -240.0f; - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - this->rupeesLeftToThrow = 5; - } else { - this->rupeesLeftToThrow = 10; - } - this->unk_2DC.x = this->unk_2DC.y = this->unk_2DC.z = this->unk_300.x = this->unk_300.y = this->unk_300.z = 0.1f; - this->camLookAt.x = globalCtx->view.lookAt.x; - this->camLookAt.y = globalCtx->view.lookAt.y; - this->camLookAt.z = globalCtx->view.lookAt.z; - this->camEye.x = globalCtx->view.eye.x; - this->camEye.y = globalCtx->view.eye.y + 80.0f; - this->camEye.z = globalCtx->view.eye.z + 250.0f; - this->unk_2E8.x = fabsf(this->camEye.x - this->unk_2D0.x) * 0.04f; - this->unk_2E8.y = fabsf(this->camEye.y - this->unk_2D0.y) * 0.04f; - this->unk_2E8.z = fabsf(this->camEye.z - this->unk_2D0.z) * 0.04f; - this->unk_30C.x = fabsf(this->camLookAt.x - this->unk_2F4.x) * 0.04f; - this->unk_30C.y = fabsf(this->camLookAt.y - this->unk_2F4.y) * 0.04f; - this->unk_30C.z = fabsf(this->camLookAt.z - this->unk_2F4.z) * 0.04f; - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->camLookAt, &this->camEye); - Gameplay_CameraSetFov(globalCtx, this->subCamId, globalCtx->mainCamera.fov); - this->csCameraTimer = 60; - this->actionFunc = EnDivingGame_RupeeThrow; - this->unk_318 = 0.0f; -} - -// Throws rupee when this->spawnRuppyTimer == 0 -void EnDivingGame_RupeeThrow(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (func_800C0DB4(globalCtx, &this->actor.projectedPos)) { - Audio_SetExtraFilter(0); - } - if (this->subCamId != 0) { - Math_ApproachF(&this->camEye.x, this->unk_2D0.x, this->unk_2DC.x, this->unk_2E8.x * this->unk_318); - Math_ApproachF(&this->camEye.z, this->unk_2D0.z, this->unk_2DC.z, this->unk_2E8.z * this->unk_318); - Math_ApproachF(&this->camLookAt.x, this->unk_2F4.x, this->unk_300.x, this->unk_30C.x * this->unk_318); - Math_ApproachF(&this->camLookAt.y, this->unk_2F4.y, this->unk_300.y, this->unk_30C.y * this->unk_318); - Math_ApproachF(&this->camLookAt.z, this->unk_2F4.z, this->unk_300.z, this->unk_30C.z * this->unk_318); - Math_ApproachF(&this->unk_318, 1.0f, 1.0f, 0.02f); - } - Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->camLookAt, &this->camEye); - if (!this->allRupeesThrown && this->spawnRuppyTimer == 0) { - this->spawnRuppyTimer = 5; - EnDivingGame_SpawnRuppy(this, globalCtx); - this->rupeesLeftToThrow--; - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - this->unk_296 = 30; - } else { - this->unk_296 = 5; - } - if (this->rupeesLeftToThrow <= 0) { - this->rupeesLeftToThrow = 0; - this->allRupeesThrown = true; - } - } - if (this->csCameraTimer == 0 || - ((fabsf(this->camEye.x - this->unk_2D0.x) < 2.0f) && (fabsf(this->camEye.y - this->unk_2D0.y) < 2.0f) && - (fabsf(this->camEye.z - this->unk_2D0.z) < 2.0f) && (fabsf(this->camLookAt.x - this->unk_2F4.x) < 2.0f) && - (fabsf(this->camLookAt.y - this->unk_2F4.y) < 2.0f) && (fabsf(this->camLookAt.z - this->unk_2F4.z) < 2.0f))) { - if (this->unk_2A2 != 0) { - this->csCameraTimer = 70; - this->unk_2A2 = 2; - this->actionFunc = func_809EE780; - } else { - this->actionFunc = EnDivingGame_SetupUnderwaterViewCs; - } - } -} - -// Called just before changing the camera to focus the underwater rupees. -void EnDivingGame_SetupUnderwaterViewCs(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_296 == 0) { - this->unk_2A2 = 1; - this->csCameraTimer = 100; - this->actionFunc = EnDivingGame_RupeeThrow; - this->camLookAt.x = this->unk_2F4.x = -210.0f; - this->camLookAt.y = this->unk_2F4.y = -80.0f; - this->camLookAt.z = this->unk_2F4.z = -1020.0f; - this->camEye.x = this->unk_2D0.x = -280.0f; - this->camEye.y = this->unk_2D0.y = -20.0f; - this->camEye.z = this->unk_2D0.z = -240.0f; - } -} - -// EnDivingGame_SayStartAndWait ? -void func_809EE780(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->csCameraTimer == 0) { - Gameplay_ClearCamera(globalCtx, this->subCamId); - Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_ACTIVE); - this->actor.textId = 0x405A; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_292 = TEXT_STATE_EVENT; - this->actionFunc = func_809EE800; - } -} - -// EnDivingGame_TalkDuringMinigame -void func_809EE800(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - func_80088B34(BREG(2) + 50); - } else { - func_80088B34(BREG(2) + 50); - } - func_800F5ACC(NA_BGM_MINI_GAME_2); - func_8002DF54(globalCtx, NULL, 7); - this->actor.textId = 0x405B; - this->unk_292 = TEXT_STATE_EVENT; - this->state = ENDIVINGGAME_STATE_PLAYING; - this->actionFunc = EnDivingGame_Talk; - } -} - -void func_809EE8F0(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((this->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { - Message_CloseTextbox(globalCtx); - this->actionFunc = EnDivingGame_Talk; - } else { - EnDivingGame_HasMinigameFinished(this, globalCtx); - } -} - -// EnDivingGame_SayCongratsAndWait ? // EnDivingGame_PlayerWonPhase1 -void func_809EE96C(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((this->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, NULL, 7); - this->actor.textId = 0x4056; - this->unk_292 = TEXT_STATE_EVENT; - this->state = ENDIVINGGAME_STATE_AWARDPRIZE; - this->actionFunc = EnDivingGame_Talk; - } -} - -void func_809EEA00(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((this->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { - Message_CloseTextbox(globalCtx); - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); - this->actionFunc = func_809EEA90; - } -} - -void func_809EEA90(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = func_809EEAF8; - } else { - func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); - } -} - -// Award the scale? -void func_809EEAF8(EnDivingGame* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - // "Successful completion" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); - this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0; - gSaveContext.eventChkInf[3] |= 0x100; - this->actionFunc = func_809EDCB0; - } -} - -void EnDivingGame_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnDivingGame* this = (EnDivingGame*)thisx; - Player* player = GET_PLAYER(globalCtx); - Vec3f pos; - - if (this->csCameraTimer != 0) { - this->csCameraTimer--; - } - if (this->unk_296 != 0) { - this->unk_296--; - } - if (this->eyeTimer != 0) { - this->eyeTimer--; - } - if (this->spawnRuppyTimer != 0) { - this->spawnRuppyTimer--; - } - - if (1) {} - - if (gSaveContext.timer1Value == 10) { - func_800F5918(); - } - if (this->eyeTimer == 0) { - this->eyeTimer = 2; - this->eyeTexIndex++; - if (this->eyeTexIndex >= 3) { - this->eyeTexIndex = 0; - this->eyeTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - } - } - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, 80.0f); - this->unk_324.unk_18 = player->actor.world.pos; - this->unk_324.unk_18.y = player->actor.world.pos.y; - func_80034A14(&this->actor, &this->unk_324, 2, 4); - this->vec_284 = this->unk_324.unk_08; - this->vec_28A = this->unk_324.unk_0E; - if ((globalCtx->gameplayFrames % 16) == 0) { - pos = this->actor.world.pos; - pos.y += 20.0f; - EffectSsGRipple_Spawn(globalCtx, &pos, 100, 500, 30); - } - this->unk_290++; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 29); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -Gfx* EnDivingGame_EmptyDList(GraphicsContext* gfxCtx) { - Gfx* displayList = Graph_Alloc(gfxCtx, sizeof(Gfx)); - - gSPEndDisplayList(displayList); - return displayList; -} - -s32 EnDivingGame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnDivingGame* this = (EnDivingGame*)thisx; - s32 pad; - - if (limbIndex == 6) { - rot->x += this->vec_28A.y; - } - - if (limbIndex == 15) { - rot->x += this->vec_284.y; - rot->z += this->vec_284.z; - } - - if (this->notPlayingMinigame && (limbIndex == 8 || limbIndex == 9 || limbIndex == 12)) { - rot->y += Math_SinS((globalCtx->state.frames * (limbIndex * 50 + 0x814))) * 200.0f; - rot->z += Math_CosS((globalCtx->state.frames * (limbIndex * 50 + 0x940))) * 200.0f; - } - - return 0; -} - -void EnDivingGame_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDivingGame* this = (EnDivingGame*)thisx; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_diving_game.c", 1212); - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, EnDivingGame_EmptyDList(globalCtx->state.gfxCtx)); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnDivingGame_OverrideLimbDraw, NULL, this); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_diving_game.c", 1232); -} diff --git a/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.cpp b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.cpp new file mode 100644 index 000000000..4797b649c --- /dev/null +++ b/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.cpp @@ -0,0 +1,588 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DIVING_GAME_Z_EN_DIVING_GAME_C +#include "actor_common.h" +/* + * File: z_en_diving_game.c + * Overlay: ovl_En_Diving_Game + * Description: Diving minigame + */ + +#include "z_en_diving_game.h" +#include "overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.h" +#include "objects/object_zo/object_zo.h" +#include "vt.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnDivingGame_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDivingGame_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDivingGame_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDivingGame_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809EDCB0(EnDivingGame* pthis, GlobalContext* globalCtx); +void EnDivingGame_Talk(EnDivingGame* pthis, GlobalContext* globalCtx); +void EnDivingGame_HandlePlayChoice(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE048(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE0FC(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE194(EnDivingGame* pthis, GlobalContext* globalCtx); +void EnDivingGame_SetupRupeeThrow(EnDivingGame* pthis, GlobalContext* globalCtx); +void EnDivingGame_RupeeThrow(EnDivingGame* pthis, GlobalContext* globalCtx); +void EnDivingGame_SetupUnderwaterViewCs(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE780(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE800(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE8F0(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EE96C(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EEA00(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EEA90(EnDivingGame* pthis, GlobalContext* globalCtx); +void func_809EEAF8(EnDivingGame* pthis, GlobalContext* globalCtx); + +ActorInit En_Diving_Game_InitVars = { + ACTOR_EN_DIVING_GAME, + ACTORCAT_NPC, + FLAGS, + OBJECT_ZO, + sizeof(EnDivingGame), + (ActorFunc)EnDivingGame_Init, + (ActorFunc)EnDivingGame_Destroy, + (ActorFunc)EnDivingGame_Update, + (ActorFunc)EnDivingGame_Draw, +}; + +// used to ensure there's only one instance of pthis actor. +static u8 D_809EF0B0 = false; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 10, 10, 0, { 0, 0, 0 } }, +}; + +static void* sEyeTextures[] = { + gZoraEyeOpenTex, + gZoraEyeHalfTex, + gZoraEyeClosedTex, +}; + +void EnDivingGame_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDivingGame* pthis = (EnDivingGame*)thisx; + + pthis->actor.gravity = -3.0f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gZoraSkel, &gZoraIdleAnim, pthis->jointTable, pthis->morphTable, 20); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 素もぐりGO ☆☆☆☆☆ \n" VT_RST); + pthis->actor.room = -1; + pthis->actor.scale.x = 0.01f; + pthis->actor.scale.y = 0.012999999f; + pthis->actor.scale.z = 0.0139999995f; + if (D_809EF0B0) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もういてる原 ☆☆☆☆☆ \n" VT_RST); + pthis->unk_31F = 1; + Actor_Kill(&pthis->actor); + } else { + D_809EF0B0 = true; + pthis->actor.targetMode = 0; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actionFunc = func_809EDCB0; + } +} + +void EnDivingGame_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDivingGame* pthis = (EnDivingGame*)thisx; + + if (pthis->unk_31F == 0) { + gSaveContext.timer1State = 0; + } + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnDivingGame_SpawnRuppy(EnDivingGame* pthis, GlobalContext* globalCtx) { + EnExRuppy* rupee; + Vec3f rupeePos; + + rupeePos.x = (Rand_ZeroOne() - 0.5f) * 30.0f + pthis->actor.world.pos.x; + rupeePos.y = (Rand_ZeroOne() - 0.5f) * 20.0f + (pthis->actor.world.pos.y + 30.0f); + rupeePos.z = (Rand_ZeroOne() - 0.5f) * 20.0f + pthis->actor.world.pos.z; + rupee = (EnExRuppy*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_RUPPY, rupeePos.x, + rupeePos.y, rupeePos.z, 0, (s16)Rand_CenteredFloat(3500.0f) - 1000, + pthis->rupeesLeftToThrow, 0); + if (rupee != NULL) { + rupee->actor.speedXZ = 12.0f; + rupee->actor.velocity.y = 6.0f; + } +} + +s32 EnDivingGame_HasMinigameFinished(EnDivingGame* pthis, GlobalContext* globalCtx) { + if (gSaveContext.timer1State == 10 && !Gameplay_InCsMode(globalCtx)) { + // Failed. + gSaveContext.timer1State = 0; + func_800F5B58(); + func_80078884(NA_SE_SY_FOUND); + pthis->actor.textId = 0x71AD; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_292 = TEXT_STATE_EVENT; + pthis->allRupeesThrown = pthis->state = pthis->phase = pthis->unk_2A2 = pthis->grabbedRupeesCounter = 0; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_809EE048; + return true; + } else { + s32 rupeesNeeded = 5; + + if (gSaveContext.eventChkInf[3] & 0x100) { + rupeesNeeded = 10; + } + if (pthis->grabbedRupeesCounter >= rupeesNeeded) { + // Won. + gSaveContext.timer1State = 0; + pthis->allRupeesThrown = pthis->state = pthis->phase = pthis->unk_2A2 = pthis->grabbedRupeesCounter = 0; + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + pthis->actor.textId = 0x4055; + } else { + pthis->actor.textId = 0x405D; + if (pthis->extraWinCount < 100) { + pthis->extraWinCount++; + } + } + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_292 = TEXT_STATE_EVENT; + func_800F5B58(); + Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); + func_8002DF54(globalCtx, NULL, 8); + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + pthis->actionFunc = func_809EE96C; + } else { + pthis->actionFunc = func_809EE048; + } + return true; + } + } + return false; +} + +// EnDivingGame_FinishMinigame ? // Reset probably +void func_809EDCB0(EnDivingGame* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gZoraIdleAnim); + + Animation_Change(&pthis->skelAnime, &gZoraIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->notPlayingMinigame = true; + pthis->actionFunc = EnDivingGame_Talk; +} + +void EnDivingGame_Talk(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->state != ENDIVINGGAME_STATE_PLAYING || !EnDivingGame_HasMinigameFinished(pthis, globalCtx)) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->unk_292 != TEXT_STATE_DONE) { + switch (pthis->state) { + case ENDIVINGGAME_STATE_NOTPLAYING: + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = EnDivingGame_HandlePlayChoice; + break; + case ENDIVINGGAME_STATE_AWARDPRIZE: + pthis->actionFunc = func_809EEA00; + break; + case ENDIVINGGAME_STATE_PLAYING: + pthis->actionFunc = func_809EE8F0; + break; + } + } + } else { + if (Text_GetFaceReaction(globalCtx, 0x1D) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 0x1D); + pthis->unk_292 = TEXT_STATE_DONE; + } else { + switch (pthis->state) { + case ENDIVINGGAME_STATE_NOTPLAYING: + pthis->unk_292 = TEXT_STATE_CHOICE; + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + pthis->actor.textId = 0x4053; + pthis->phase = ENDIVINGGAME_PHASE_1; + } else { + pthis->actor.textId = 0x405C; + pthis->phase = ENDIVINGGAME_PHASE_2; + } + break; + case ENDIVINGGAME_STATE_AWARDPRIZE: + pthis->actor.textId = 0x4056; + pthis->unk_292 = TEXT_STATE_EVENT; + break; + case ENDIVINGGAME_STATE_PLAYING: + pthis->actor.textId = 0x405B; + pthis->unk_292 = TEXT_STATE_EVENT; + break; + } + } + func_8002F2CC(&pthis->actor, globalCtx, 80.0f); + } + } +} + +void EnDivingGame_HandlePlayChoice(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_292 == Message_GetState(&globalCtx->msgCtx) && + Message_ShouldAdvance(globalCtx)) { // Did player selected an answer? + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // Yes + if (gSaveContext.rupees >= 20) { + Rupees_ChangeBy(-20); + pthis->actor.textId = 0x4054; + } else { + pthis->actor.textId = 0x85; + pthis->allRupeesThrown = pthis->state = pthis->phase = pthis->unk_2A2 = pthis->grabbedRupeesCounter = 0; + } + break; + case 1: // No + pthis->actor.textId = 0x2D; + pthis->allRupeesThrown = pthis->state = pthis->phase = pthis->unk_2A2 = pthis->grabbedRupeesCounter = 0; + break; + } + if (!(gSaveContext.eventChkInf[3] & 0x100) || pthis->actor.textId == 0x85 || pthis->actor.textId == 0x2D) { + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_292 = TEXT_STATE_EVENT; + pthis->actionFunc = func_809EE048; + } else { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_809EE0FC; + } + } +} + +// Waits for the message to close +void func_809EE048(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + if (pthis->phase == ENDIVINGGAME_PHASE_ENDED) { + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = func_809EDCB0; + } else { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_809EE0FC; + } + } +} + +// another "start minigame" step +void func_809EE0FC(EnDivingGame* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gZoraThrowRupeesAnim); + + Animation_Change(&pthis->skelAnime, &gZoraThrowRupeesAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_ONCE, -10.0f); + pthis->notPlayingMinigame = false; + pthis->actionFunc = func_809EE194; +} + +// Wait a bit before start throwing the rupees. +void func_809EE194(EnDivingGame* pthis, GlobalContext* globalCtx) { + f32 currentFrame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (currentFrame >= 15.0f) { + pthis->actionFunc = EnDivingGame_SetupRupeeThrow; + } +} + +void EnDivingGame_SetupRupeeThrow(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + pthis->subCamId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->subCamId, CAM_STAT_ACTIVE); + pthis->spawnRuppyTimer = 10; + pthis->unk_2F4.x = -210.0f; + pthis->unk_2F4.y = -80.0f; + pthis->unk_2F4.z = -1020.0f; + pthis->unk_2D0.x = -280.0f; + pthis->unk_2D0.y = -20.0f; + pthis->unk_2D0.z = -240.0f; + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + pthis->rupeesLeftToThrow = 5; + } else { + pthis->rupeesLeftToThrow = 10; + } + pthis->unk_2DC.x = pthis->unk_2DC.y = pthis->unk_2DC.z = pthis->unk_300.x = pthis->unk_300.y = pthis->unk_300.z = 0.1f; + pthis->camLookAt.x = globalCtx->view.lookAt.x; + pthis->camLookAt.y = globalCtx->view.lookAt.y; + pthis->camLookAt.z = globalCtx->view.lookAt.z; + pthis->camEye.x = globalCtx->view.eye.x; + pthis->camEye.y = globalCtx->view.eye.y + 80.0f; + pthis->camEye.z = globalCtx->view.eye.z + 250.0f; + pthis->unk_2E8.x = fabsf(pthis->camEye.x - pthis->unk_2D0.x) * 0.04f; + pthis->unk_2E8.y = fabsf(pthis->camEye.y - pthis->unk_2D0.y) * 0.04f; + pthis->unk_2E8.z = fabsf(pthis->camEye.z - pthis->unk_2D0.z) * 0.04f; + pthis->unk_30C.x = fabsf(pthis->camLookAt.x - pthis->unk_2F4.x) * 0.04f; + pthis->unk_30C.y = fabsf(pthis->camLookAt.y - pthis->unk_2F4.y) * 0.04f; + pthis->unk_30C.z = fabsf(pthis->camLookAt.z - pthis->unk_2F4.z) * 0.04f; + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->camLookAt, &pthis->camEye); + Gameplay_CameraSetFov(globalCtx, pthis->subCamId, globalCtx->mainCamera.fov); + pthis->csCameraTimer = 60; + pthis->actionFunc = EnDivingGame_RupeeThrow; + pthis->unk_318 = 0.0f; +} + +// Throws rupee when pthis->spawnRuppyTimer == 0 +void EnDivingGame_RupeeThrow(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (func_800C0DB4(globalCtx, &pthis->actor.projectedPos)) { + Audio_SetExtraFilter(0); + } + if (pthis->subCamId != 0) { + Math_ApproachF(&pthis->camEye.x, pthis->unk_2D0.x, pthis->unk_2DC.x, pthis->unk_2E8.x * pthis->unk_318); + Math_ApproachF(&pthis->camEye.z, pthis->unk_2D0.z, pthis->unk_2DC.z, pthis->unk_2E8.z * pthis->unk_318); + Math_ApproachF(&pthis->camLookAt.x, pthis->unk_2F4.x, pthis->unk_300.x, pthis->unk_30C.x * pthis->unk_318); + Math_ApproachF(&pthis->camLookAt.y, pthis->unk_2F4.y, pthis->unk_300.y, pthis->unk_30C.y * pthis->unk_318); + Math_ApproachF(&pthis->camLookAt.z, pthis->unk_2F4.z, pthis->unk_300.z, pthis->unk_30C.z * pthis->unk_318); + Math_ApproachF(&pthis->unk_318, 1.0f, 1.0f, 0.02f); + } + Gameplay_CameraSetAtEye(globalCtx, pthis->subCamId, &pthis->camLookAt, &pthis->camEye); + if (!pthis->allRupeesThrown && pthis->spawnRuppyTimer == 0) { + pthis->spawnRuppyTimer = 5; + EnDivingGame_SpawnRuppy(pthis, globalCtx); + pthis->rupeesLeftToThrow--; + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + pthis->unk_296 = 30; + } else { + pthis->unk_296 = 5; + } + if (pthis->rupeesLeftToThrow <= 0) { + pthis->rupeesLeftToThrow = 0; + pthis->allRupeesThrown = true; + } + } + if (pthis->csCameraTimer == 0 || + ((fabsf(pthis->camEye.x - pthis->unk_2D0.x) < 2.0f) && (fabsf(pthis->camEye.y - pthis->unk_2D0.y) < 2.0f) && + (fabsf(pthis->camEye.z - pthis->unk_2D0.z) < 2.0f) && (fabsf(pthis->camLookAt.x - pthis->unk_2F4.x) < 2.0f) && + (fabsf(pthis->camLookAt.y - pthis->unk_2F4.y) < 2.0f) && (fabsf(pthis->camLookAt.z - pthis->unk_2F4.z) < 2.0f))) { + if (pthis->unk_2A2 != 0) { + pthis->csCameraTimer = 70; + pthis->unk_2A2 = 2; + pthis->actionFunc = func_809EE780; + } else { + pthis->actionFunc = EnDivingGame_SetupUnderwaterViewCs; + } + } +} + +// Called just before changing the camera to focus the underwater rupees. +void EnDivingGame_SetupUnderwaterViewCs(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_296 == 0) { + pthis->unk_2A2 = 1; + pthis->csCameraTimer = 100; + pthis->actionFunc = EnDivingGame_RupeeThrow; + pthis->camLookAt.x = pthis->unk_2F4.x = -210.0f; + pthis->camLookAt.y = pthis->unk_2F4.y = -80.0f; + pthis->camLookAt.z = pthis->unk_2F4.z = -1020.0f; + pthis->camEye.x = pthis->unk_2D0.x = -280.0f; + pthis->camEye.y = pthis->unk_2D0.y = -20.0f; + pthis->camEye.z = pthis->unk_2D0.z = -240.0f; + } +} + +// EnDivingGame_SayStartAndWait ? +void func_809EE780(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->csCameraTimer == 0) { + Gameplay_ClearCamera(globalCtx, pthis->subCamId); + Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_ACTIVE); + pthis->actor.textId = 0x405A; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_292 = TEXT_STATE_EVENT; + pthis->actionFunc = func_809EE800; + } +} + +// EnDivingGame_TalkDuringMinigame +void func_809EE800(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + func_80088B34(BREG(2) + 50); + } else { + func_80088B34(BREG(2) + 50); + } + func_800F5ACC(NA_BGM_MINI_GAME_2); + func_8002DF54(globalCtx, NULL, 7); + pthis->actor.textId = 0x405B; + pthis->unk_292 = TEXT_STATE_EVENT; + pthis->state = ENDIVINGGAME_STATE_PLAYING; + pthis->actionFunc = EnDivingGame_Talk; + } +} + +void func_809EE8F0(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnDivingGame_Talk; + } else { + EnDivingGame_HasMinigameFinished(pthis, globalCtx); + } +} + +// EnDivingGame_SayCongratsAndWait ? // EnDivingGame_PlayerWonPhase1 +void func_809EE96C(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, NULL, 7); + pthis->actor.textId = 0x4056; + pthis->unk_292 = TEXT_STATE_EVENT; + pthis->state = ENDIVINGGAME_STATE_AWARDPRIZE; + pthis->actionFunc = EnDivingGame_Talk; + } +} + +void func_809EEA00(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { + Message_CloseTextbox(globalCtx); + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); + pthis->actionFunc = func_809EEA90; + } +} + +void func_809EEA90(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_809EEAF8; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); + } +} + +// Award the scale? +void func_809EEAF8(EnDivingGame* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + // "Successful completion" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); + pthis->allRupeesThrown = pthis->state = pthis->phase = pthis->unk_2A2 = pthis->grabbedRupeesCounter = 0; + gSaveContext.eventChkInf[3] |= 0x100; + pthis->actionFunc = func_809EDCB0; + } +} + +void EnDivingGame_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnDivingGame* pthis = (EnDivingGame*)thisx; + Player* player = GET_PLAYER(globalCtx); + Vec3f pos; + + if (pthis->csCameraTimer != 0) { + pthis->csCameraTimer--; + } + if (pthis->unk_296 != 0) { + pthis->unk_296--; + } + if (pthis->eyeTimer != 0) { + pthis->eyeTimer--; + } + if (pthis->spawnRuppyTimer != 0) { + pthis->spawnRuppyTimer--; + } + + if (1) {} + + if (gSaveContext.timer1Value == 10) { + func_800F5918(); + } + if (pthis->eyeTimer == 0) { + pthis->eyeTimer = 2; + pthis->eyeTexIndex++; + if (pthis->eyeTexIndex >= 3) { + pthis->eyeTexIndex = 0; + pthis->eyeTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 80.0f); + pthis->unk_324.unk_18 = player->actor.world.pos; + pthis->unk_324.unk_18.y = player->actor.world.pos.y; + func_80034A14(&pthis->actor, &pthis->unk_324, 2, 4); + pthis->vec_284 = pthis->unk_324.unk_08; + pthis->vec_28A = pthis->unk_324.unk_0E; + if ((globalCtx->gameplayFrames % 16) == 0) { + pos = pthis->actor.world.pos; + pos.y += 20.0f; + EffectSsGRipple_Spawn(globalCtx, &pos, 100, 500, 30); + } + pthis->unk_290++; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 29); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +Gfx* EnDivingGame_EmptyDList(GraphicsContext* gfxCtx) { + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); + + gSPEndDisplayList(displayList); + return displayList; +} + +s32 EnDivingGame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnDivingGame* pthis = (EnDivingGame*)thisx; + s32 pad; + + if (limbIndex == 6) { + rot->x += pthis->vec_28A.y; + } + + if (limbIndex == 15) { + rot->x += pthis->vec_284.y; + rot->z += pthis->vec_284.z; + } + + if (pthis->notPlayingMinigame && (limbIndex == 8 || limbIndex == 9 || limbIndex == 12)) { + rot->y += Math_SinS((globalCtx->state.frames * (limbIndex * 50 + 0x814))) * 200.0f; + rot->z += Math_CosS((globalCtx->state.frames * (limbIndex * 50 + 0x940))) * 200.0f; + } + + return 0; +} + +void EnDivingGame_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDivingGame* pthis = (EnDivingGame*)thisx; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_diving_game.c", 1212); + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, EnDivingGame_EmptyDList(globalCtx->state.gfxCtx)); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeTexIndex])); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnDivingGame_OverrideLimbDraw, NULL, pthis); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_diving_game.c", 1232); +} diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c deleted file mode 100644 index 2937f379a..000000000 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ /dev/null @@ -1,513 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DNS_Z_EN_DNS_C -#include "actor_common.h" -/* - * File: z_en_dns.c - * Overlay: En_Dns - * Description: Deku Salesman - */ - -#include "z_en_dns.h" -#include "objects/object_shopnuts/object_shopnuts.h" -#include "vt.h" -#include "def/code_80097A00.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnDns_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDns_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx); - -u32 func_809EF5A4(EnDns* this); -u32 func_809EF658(EnDns* this); -u32 func_809EF70C(EnDns* this); -u32 func_809EF73C(EnDns* this); -u32 func_809EF800(EnDns* this); -u32 func_809EF854(EnDns* this); -u32 func_809EF8F4(EnDns* this); -u32 func_809EF9A4(EnDns* this); - -void func_809EF9F8(EnDns* this); -void func_809EFA28(EnDns* this); -void func_809EFA58(EnDns* this); -void func_809EFA9C(EnDns* this); -void func_809EFACC(EnDns* this); -void func_809EFAFC(EnDns* this); -void func_809EFB40(EnDns* this); - -void EnDns_SetupWait(EnDns* this, GlobalContext* globalCtx); -void EnDns_Wait(EnDns* this, GlobalContext* globalCtx); -void EnDns_Talk(EnDns* this, GlobalContext* globalCtx); -void func_809EFDD0(EnDns* this, GlobalContext* globalCtx); -void func_809EFEE8(EnDns* this, GlobalContext* globalCtx); -void func_809EFF50(EnDns* this, GlobalContext* globalCtx); -void func_809EFF98(EnDns* this, GlobalContext* globalCtx); -void func_809F008C(EnDns* this, GlobalContext* globalCtx); -void EnDns_SetupBurrow(EnDns* this, GlobalContext* globalCtx); -void EnDns_Burrow(EnDns* this, GlobalContext* globalCtx); - -const ActorInit En_Dns_InitVars = { - ACTOR_EN_DNS, - ACTORCAT_BG, - FLAGS, - OBJECT_SHOPNUTS, - sizeof(EnDns), - (ActorFunc)EnDns_Init, - (ActorFunc)EnDns_Destroy, - (ActorFunc)EnDns_Update, - (ActorFunc)EnDns_Draw, -}; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 18, 32, 0, { 0, 0, 0 } }, -}; - -static u16 D_809F040C[] = { - 0x10A0, 0x10A1, 0x10A2, 0x10CA, 0x10CB, 0x10CC, 0x10CD, 0x10CE, 0x10CF, 0x10DC, 0x10DD, -}; - -// Debug text: "sells" { "Deku Nuts", "Deku Sticks", "Piece of Heart", "Deku Seeds", -// "Deku Shield", "Bombs", "Arrows", "Red Potion", -// "Green Potion", "Deku Stick Upgrade", "Deku Nut Upgrade" } -static char* D_809F0424[] = { - "デクの実売り ", "デクの棒売り ", "ハートの欠片売り ", "デクの種売り ", - "デクの盾売り ", "バクダン売り ", "矢売り ", "赤のくすり売り ", - "緑のくすり売り ", "デクの棒持てる数を増やす", "デクの実持てる数を増やす", -}; - -static DnsItemEntry D_809F0450 = { 20, 5, GI_NUTS_5_2, func_809EF5A4, func_809EFA28 }; - -static DnsItemEntry D_809F0460 = { 15, 1, GI_STICKS_1, func_809EF658, func_809EF9F8 }; - -static DnsItemEntry D_809F0470 = { 10, 1, GI_HEART_PIECE, func_809EF70C, func_809EFA58 }; - -static DnsItemEntry D_809F0480 = { 40, 30, GI_SEEDS_30, func_809EF73C, func_809EF9F8 }; - -static DnsItemEntry D_809F0490 = { 50, 1, GI_SHIELD_DEKU, func_809EF800, func_809EF9F8 }; - -static DnsItemEntry D_809F04A0 = { 40, 5, GI_BOMBS_5, func_809EF854, func_809EFA9C }; - -static DnsItemEntry D_809F04B0 = { 70, 20, GI_ARROWS_LARGE, func_809EF8F4, func_809EFACC }; - -static DnsItemEntry D_809F04C0 = { 40, 1, GI_POTION_RED, func_809EF9A4, func_809EF9F8 }; - -static DnsItemEntry D_809F04D0 = { 40, 1, GI_POTION_GREEN, func_809EF9A4, func_809EF9F8 }; - -static DnsItemEntry D_809F04E0 = { 40, 1, GI_STICK_UPGRADE_20, func_809EF70C, func_809EFAFC }; - -static DnsItemEntry D_809F04F0 = { 40, 1, GI_NUT_UPGRADE_30, func_809EF70C, func_809EFB40 }; - -static DnsItemEntry* sItemEntries[] = { - &D_809F0450, &D_809F0460, &D_809F0470, &D_809F0480, &D_809F0490, &D_809F04A0, - &D_809F04B0, &D_809F04C0, &D_809F04D0, &D_809F04E0, &D_809F04F0, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x4E, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -typedef struct { - /* 0x00 */ AnimationHeader* anim; - /* 0x04 */ u8 mode; - /* 0x08 */ f32 transitionRate; -} DnsAnimInfo; // size = 0xC - -static DnsAnimInfo sAnimInfo[] = { - { &gBusinessScrubNervousIdleAnim, ANIMMODE_LOOP, 0.0f }, - { &gBusinessScrubAnim_4404, ANIMMODE_ONCE, 0.0f }, - { &gBusinessScrubNervousTransitionAnim, ANIMMODE_ONCE, 0.0f }, -}; - -void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDns* this = (EnDns*)thisx; - - if (this->actor.params < 0) { - // "Function Error (Deku Salesman)" - osSyncPrintf(VT_FGCOL(RED) "引数エラー(売りナッツ)[ arg_data = %d ]" VT_RST "\n", this->actor.params); - Actor_Kill(&this->actor); - return; - } - // Sell Seeds instead of Arrows if Link is child - if ((this->actor.params == 0x0006) && (LINK_AGE_IN_YEARS == YEARS_CHILD)) { - this->actor.params = 0x0003; - } - // "Deku Salesman" - osSyncPrintf(VT_FGCOL(GREEN) "◆◆◆ 売りナッツ『%s』 ◆◆◆" VT_RST "\n", D_809F0424[this->actor.params], - this->actor.params); - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBusinessScrubSkel, &gBusinessScrubNervousTransitionAnim, - this->jointTable, this->morphTable, 18); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->actor.textId = D_809F040C[this->actor.params]; - Actor_SetScale(&this->actor, 0.01f); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->maintainCollider = 1; - this->standOnGround = 1; - this->dropCollectible = 0; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -1.0f; - this->dnsItemEntry = sItemEntries[this->actor.params]; - this->actionFunc = EnDns_SetupWait; -} - -void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDns* this = (EnDns*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnDns_Change(EnDns* this, u8 arg1) { - s16 frameCount; - - frameCount = Animation_GetLastFrame(sAnimInfo[arg1].anim); - this->unk_2BA = arg1; // Not used anywhere else? - Animation_Change(&this->skelAnime, sAnimInfo[arg1].anim, 1.0f, 0.0f, (f32)frameCount, sAnimInfo[arg1].mode, - sAnimInfo[arg1].transitionRate); -} - -/* Item give checking functions */ - -u32 func_809EF5A4(EnDns* this) { - if ((CUR_CAPACITY(UPG_NUTS) != 0) && (AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS))) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) { - return 2; - } - return 4; -} - -u32 func_809EF658(EnDns* this) { - if ((CUR_CAPACITY(UPG_STICKS) != 0) && (AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS))) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) { - return 2; - } - return 4; -} - -u32 func_809EF70C(EnDns* this) { - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - return 4; -} - -u32 func_809EF73C(EnDns* this) { - if (INV_CONTENT(ITEM_SLINGSHOT) == ITEM_NONE) { - return 3; - } - if (AMMO(ITEM_SLINGSHOT) >= CUR_CAPACITY(UPG_BULLET_BAG)) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - if (Item_CheckObtainability(ITEM_SEEDS) == ITEM_NONE) { - return 2; - } - return 4; -} - -u32 func_809EF800(EnDns* this) { - if (gBitFlags[4] & gSaveContext.inventory.equipment) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - return 4; -} - -u32 func_809EF854(EnDns* this) { - if (!CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - return 3; - } - if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - return 4; -} - -u32 func_809EF8F4(EnDns* this) { - if (Item_CheckObtainability(ITEM_BOW) == ITEM_NONE) { - return 3; - } - if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - return 4; -} - -u32 func_809EF9A4(EnDns* this) { - if (!Inventory_HasEmptyBottle()) { - return 1; - } - if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { - return 0; - } - return 4; -} - -/* Paying and flagging functions */ - -void func_809EF9F8(EnDns* this) { - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void func_809EFA28(EnDns* this) { - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void func_809EFA58(EnDns* this) { - gSaveContext.itemGetInf[0] |= 0x800; - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void func_809EFA9C(EnDns* this) { - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void func_809EFACC(EnDns* this) { - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void func_809EFAFC(EnDns* this) { - gSaveContext.infTable[25] |= 0x4; - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void func_809EFB40(EnDns* this) { - gSaveContext.infTable[25] |= 0x8; - Rupees_ChangeBy(-this->dnsItemEntry->itemPrice); -} - -void EnDns_SetupWait(EnDns* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - this->actionFunc = EnDns_Wait; - EnDns_Change(this, 0); - } -} - -void EnDns_Wait(EnDns* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 2000, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnDns_Talk; - } else { - if ((this->collider.base.ocFlags1 & OC1_HIT) || this->actor.isTargeted) { - this->actor.flags |= ACTOR_FLAG_16; - } else { - this->actor.flags &= ~ACTOR_FLAG_16; - } - if (this->actor.xzDistToPlayer < 130.0f) { - func_8002F2F4(&this->actor, globalCtx); - } - } -} - -void EnDns_Talk(EnDns* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // OK - switch (this->dnsItemEntry->purchaseableCheck(this)) { - case 0: - Message_ContinueTextbox(globalCtx, 0x10A5); - this->actionFunc = func_809F008C; - break; - case 1: - Message_ContinueTextbox(globalCtx, 0x10A6); - this->actionFunc = func_809F008C; - break; - case 3: - Message_ContinueTextbox(globalCtx, 0x10DE); - this->actionFunc = func_809F008C; - break; - case 2: - case 4: - Message_ContinueTextbox(globalCtx, 0x10A7); - this->actionFunc = func_809EFEE8; - break; - } - break; - case 1: // No way - Message_ContinueTextbox(globalCtx, 0x10A4); - this->actionFunc = func_809F008C; - } - } -} - -void func_809EFDD0(EnDns* this, GlobalContext* globalCtx) { - if (this->actor.params == 0x9) { - if (CUR_UPG_VALUE(UPG_STICKS) < 2) { - func_8002F434(&this->actor, globalCtx, GI_STICK_UPGRADE_20, 130.0f, 100.0f); - } else { - func_8002F434(&this->actor, globalCtx, GI_STICK_UPGRADE_30, 130.0f, 100.0f); - } - } else if (this->actor.params == 0xA) { - if (CUR_UPG_VALUE(UPG_NUTS) < 2) { - func_8002F434(&this->actor, globalCtx, GI_NUT_UPGRADE_30, 130.0f, 100.0f); - } else { - func_8002F434(&this->actor, globalCtx, GI_NUT_UPGRADE_40, 130.0f, 100.0f); - } - } else { - func_8002F434(&this->actor, globalCtx, this->dnsItemEntry->getItemId, 130.0f, 100.0f); - } -} - -void func_809EFEE8(EnDns* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - func_809EFDD0(this, globalCtx); - this->actionFunc = func_809EFF50; - } -} - -void func_809EFF50(EnDns* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_809EFF98; - } else { - func_809EFDD0(this, globalCtx); - } -} - -void func_809EFF98(EnDns* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (player->stateFlags1 & 0x400) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->dnsItemEntry->setRupeesAndFlags(this); - this->dropCollectible = 1; - this->maintainCollider = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - EnDns_Change(this, 1); - this->actionFunc = EnDns_SetupBurrow; - } - } else { - this->dnsItemEntry->setRupeesAndFlags(this); - this->dropCollectible = 1; - this->maintainCollider = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - EnDns_Change(this, 1); - this->actionFunc = EnDns_SetupBurrow; - } -} - -void func_809F008C(EnDns* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->maintainCollider = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - EnDns_Change(this, 1); - this->actionFunc = EnDns_SetupBurrow; - } -} - -void EnDns_SetupBurrow(EnDns* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gBusinessScrubAnim_4404); - - if (this->skelAnime.curFrame == frameCount) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - this->actionFunc = EnDns_Burrow; - this->standOnGround = 0; - this->yInitPos = this->actor.world.pos.y; - } -} - -void EnDns_Burrow(EnDns* this, GlobalContext* globalCtx) { - f32 depth; - Vec3f initPos; - s32 i; - - depth = this->yInitPos - this->actor.world.pos.y; - if ((this->dustTimer & 3) == 0) { - initPos.x = this->actor.world.pos.x; - initPos.y = this->yInitPos; - initPos.z = this->actor.world.pos.z; - func_80028990(globalCtx, 20.0f, &initPos); - } - this->actor.shape.rot.y += 0x2000; - // Drops only if you bought its item - if (depth > 400.0f) { - if (this->dropCollectible) { - initPos.x = this->actor.world.pos.x; - initPos.y = this->yInitPos; - initPos.z = this->actor.world.pos.z; - for (i = 0; i < 3; i++) { - Item_DropCollectible(globalCtx, &initPos, ITEM00_HEART); - } - } - Actor_Kill(&this->actor); - } -} - -void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDns* this = (EnDns*)thisx; - s16 pad; - - this->dustTimer++; - this->actor.textId = D_809F040C[this->actor.params]; - Actor_SetFocus(&this->actor, 60.0f); - Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Update(&this->skelAnime); - Actor_MoveForward(&this->actor); - this->actionFunc(this, globalCtx); - if (this->standOnGround) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 4); - } - if (this->maintainCollider) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDns* this = (EnDns*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); -} diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.cpp b/src/overlays/actors/ovl_En_Dns/z_en_dns.cpp new file mode 100644 index 000000000..1292f9523 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.cpp @@ -0,0 +1,513 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DNS_Z_EN_DNS_C +#include "actor_common.h" +/* + * File: z_en_dns.c + * Overlay: En_Dns + * Description: Deku Salesman + */ + +#include "z_en_dns.h" +#include "objects/object_shopnuts/object_shopnuts.h" +#include "vt.h" +#include "def/code_80097A00.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnDns_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDns_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx); + +u32 func_809EF5A4(EnDns* pthis); +u32 func_809EF658(EnDns* pthis); +u32 func_809EF70C(EnDns* pthis); +u32 func_809EF73C(EnDns* pthis); +u32 func_809EF800(EnDns* pthis); +u32 func_809EF854(EnDns* pthis); +u32 func_809EF8F4(EnDns* pthis); +u32 func_809EF9A4(EnDns* pthis); + +void func_809EF9F8(EnDns* pthis); +void func_809EFA28(EnDns* pthis); +void func_809EFA58(EnDns* pthis); +void func_809EFA9C(EnDns* pthis); +void func_809EFACC(EnDns* pthis); +void func_809EFAFC(EnDns* pthis); +void func_809EFB40(EnDns* pthis); + +void EnDns_SetupWait(EnDns* pthis, GlobalContext* globalCtx); +void EnDns_Wait(EnDns* pthis, GlobalContext* globalCtx); +void EnDns_Talk(EnDns* pthis, GlobalContext* globalCtx); +void func_809EFDD0(EnDns* pthis, GlobalContext* globalCtx); +void func_809EFEE8(EnDns* pthis, GlobalContext* globalCtx); +void func_809EFF50(EnDns* pthis, GlobalContext* globalCtx); +void func_809EFF98(EnDns* pthis, GlobalContext* globalCtx); +void func_809F008C(EnDns* pthis, GlobalContext* globalCtx); +void EnDns_SetupBurrow(EnDns* pthis, GlobalContext* globalCtx); +void EnDns_Burrow(EnDns* pthis, GlobalContext* globalCtx); + +ActorInit En_Dns_InitVars = { + ACTOR_EN_DNS, + ACTORCAT_BG, + FLAGS, + OBJECT_SHOPNUTS, + sizeof(EnDns), + (ActorFunc)EnDns_Init, + (ActorFunc)EnDns_Destroy, + (ActorFunc)EnDns_Update, + (ActorFunc)EnDns_Draw, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 18, 32, 0, { 0, 0, 0 } }, +}; + +static u16 D_809F040C[] = { + 0x10A0, 0x10A1, 0x10A2, 0x10CA, 0x10CB, 0x10CC, 0x10CD, 0x10CE, 0x10CF, 0x10DC, 0x10DD, +}; + +// Debug text: "sells" { "Deku Nuts", "Deku Sticks", "Piece of Heart", "Deku Seeds", +// "Deku Shield", "Bombs", "Arrows", "Red Potion", +// "Green Potion", "Deku Stick Upgrade", "Deku Nut Upgrade" } +static const char* D_809F0424[] = { + "デクの実売り ", "デクの棒売り ", "ハートの欠片売り ", "デクの種売り ", + "デクの盾売り ", "バクダン売り ", "矢売り ", "赤のくすり売り ", + "緑のくすり売り ", "デクの棒持てる数を増やす", "デクの実持てる数を増やす", +}; + +static DnsItemEntry D_809F0450 = { 20, 5, GI_NUTS_5_2, func_809EF5A4, func_809EFA28 }; + +static DnsItemEntry D_809F0460 = { 15, 1, GI_STICKS_1, func_809EF658, func_809EF9F8 }; + +static DnsItemEntry D_809F0470 = { 10, 1, GI_HEART_PIECE, func_809EF70C, func_809EFA58 }; + +static DnsItemEntry D_809F0480 = { 40, 30, GI_SEEDS_30, func_809EF73C, func_809EF9F8 }; + +static DnsItemEntry D_809F0490 = { 50, 1, GI_SHIELD_DEKU, func_809EF800, func_809EF9F8 }; + +static DnsItemEntry D_809F04A0 = { 40, 5, GI_BOMBS_5, func_809EF854, func_809EFA9C }; + +static DnsItemEntry D_809F04B0 = { 70, 20, GI_ARROWS_LARGE, func_809EF8F4, func_809EFACC }; + +static DnsItemEntry D_809F04C0 = { 40, 1, GI_POTION_RED, func_809EF9A4, func_809EF9F8 }; + +static DnsItemEntry D_809F04D0 = { 40, 1, GI_POTION_GREEN, func_809EF9A4, func_809EF9F8 }; + +static DnsItemEntry D_809F04E0 = { 40, 1, GI_STICK_UPGRADE_20, func_809EF70C, func_809EFAFC }; + +static DnsItemEntry D_809F04F0 = { 40, 1, GI_NUT_UPGRADE_30, func_809EF70C, func_809EFB40 }; + +static DnsItemEntry* sItemEntries[] = { + &D_809F0450, &D_809F0460, &D_809F0470, &D_809F0480, &D_809F0490, &D_809F04A0, + &D_809F04B0, &D_809F04C0, &D_809F04D0, &D_809F04E0, &D_809F04F0, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x4E, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +typedef struct { + /* 0x00 */ AnimationHeader* anim; + /* 0x04 */ u8 mode; + /* 0x08 */ f32 transitionRate; +} DnsAnimInfo; // size = 0xC + +static DnsAnimInfo sAnimInfo[] = { + { &gBusinessScrubNervousIdleAnim, ANIMMODE_LOOP, 0.0f }, + { &gBusinessScrubAnim_4404, ANIMMODE_ONCE, 0.0f }, + { &gBusinessScrubNervousTransitionAnim, ANIMMODE_ONCE, 0.0f }, +}; + +void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDns* pthis = (EnDns*)thisx; + + if (pthis->actor.params < 0) { + // "Function Error (Deku Salesman)" + osSyncPrintf(VT_FGCOL(RED) "引数エラー(売りナッツ)[ arg_data = %d ]" VT_RST "\n", pthis->actor.params); + Actor_Kill(&pthis->actor); + return; + } + // Sell Seeds instead of Arrows if Link is child + if ((pthis->actor.params == 0x0006) && (LINK_AGE_IN_YEARS == YEARS_CHILD)) { + pthis->actor.params = 0x0003; + } + // "Deku Salesman" + osSyncPrintf(VT_FGCOL(GREEN) "◆◆◆ 売りナッツ『%s』 ◆◆◆" VT_RST "\n", D_809F0424[pthis->actor.params], + pthis->actor.params); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBusinessScrubSkel, &gBusinessScrubNervousTransitionAnim, + pthis->jointTable, pthis->morphTable, 18); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + pthis->actor.textId = D_809F040C[pthis->actor.params]; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->maintainCollider = 1; + pthis->standOnGround = 1; + pthis->dropCollectible = 0; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -1.0f; + pthis->dnsItemEntry = sItemEntries[pthis->actor.params]; + pthis->actionFunc = EnDns_SetupWait; +} + +void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDns* pthis = (EnDns*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnDns_Change(EnDns* pthis, u8 arg1) { + s16 frameCount; + + frameCount = Animation_GetLastFrame(sAnimInfo[arg1].anim); + pthis->unk_2BA = arg1; // Not used anywhere else? + Animation_Change(&pthis->skelAnime, sAnimInfo[arg1].anim, 1.0f, 0.0f, (f32)frameCount, sAnimInfo[arg1].mode, + sAnimInfo[arg1].transitionRate); +} + +/* Item give checking functions */ + +u32 func_809EF5A4(EnDns* pthis) { + if ((CUR_CAPACITY(UPG_NUTS) != 0) && (AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS))) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) { + return 2; + } + return 4; +} + +u32 func_809EF658(EnDns* pthis) { + if ((CUR_CAPACITY(UPG_STICKS) != 0) && (AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS))) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) { + return 2; + } + return 4; +} + +u32 func_809EF70C(EnDns* pthis) { + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + return 4; +} + +u32 func_809EF73C(EnDns* pthis) { + if (INV_CONTENT(ITEM_SLINGSHOT) == ITEM_NONE) { + return 3; + } + if (AMMO(ITEM_SLINGSHOT) >= CUR_CAPACITY(UPG_BULLET_BAG)) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + if (Item_CheckObtainability(ITEM_SEEDS) == ITEM_NONE) { + return 2; + } + return 4; +} + +u32 func_809EF800(EnDns* pthis) { + if (gBitFlags[4] & gSaveContext.inventory.equipment) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + return 4; +} + +u32 func_809EF854(EnDns* pthis) { + if (!CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + return 3; + } + if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + return 4; +} + +u32 func_809EF8F4(EnDns* pthis) { + if (Item_CheckObtainability(ITEM_BOW) == ITEM_NONE) { + return 3; + } + if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + return 4; +} + +u32 func_809EF9A4(EnDns* pthis) { + if (!Inventory_HasEmptyBottle()) { + return 1; + } + if (gSaveContext.rupees < pthis->dnsItemEntry->itemPrice) { + return 0; + } + return 4; +} + +/* Paying and flagging functions */ + +void func_809EF9F8(EnDns* pthis) { + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void func_809EFA28(EnDns* pthis) { + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void func_809EFA58(EnDns* pthis) { + gSaveContext.itemGetInf[0] |= 0x800; + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void func_809EFA9C(EnDns* pthis) { + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void func_809EFACC(EnDns* pthis) { + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void func_809EFAFC(EnDns* pthis) { + gSaveContext.infTable[25] |= 0x4; + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void func_809EFB40(EnDns* pthis) { + gSaveContext.infTable[25] |= 0x8; + Rupees_ChangeBy(-pthis->dnsItemEntry->itemPrice); +} + +void EnDns_SetupWait(EnDns* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame == pthis->skelAnime.endFrame) { + pthis->actionFunc = EnDns_Wait; + EnDns_Change(pthis, 0); + } +} + +void EnDns_Wait(EnDns* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 2000, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDns_Talk; + } else { + if ((pthis->collider.base.ocFlags1 & OC1_HIT) || pthis->actor.isTargeted) { + pthis->actor.flags |= ACTOR_FLAG_16; + } else { + pthis->actor.flags &= ~ACTOR_FLAG_16; + } + if (pthis->actor.xzDistToPlayer < 130.0f) { + func_8002F2F4(&pthis->actor, globalCtx); + } + } +} + +void EnDns_Talk(EnDns* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // OK + switch (pthis->dnsItemEntry->purchaseableCheck(pthis)) { + case 0: + Message_ContinueTextbox(globalCtx, 0x10A5); + pthis->actionFunc = func_809F008C; + break; + case 1: + Message_ContinueTextbox(globalCtx, 0x10A6); + pthis->actionFunc = func_809F008C; + break; + case 3: + Message_ContinueTextbox(globalCtx, 0x10DE); + pthis->actionFunc = func_809F008C; + break; + case 2: + case 4: + Message_ContinueTextbox(globalCtx, 0x10A7); + pthis->actionFunc = func_809EFEE8; + break; + } + break; + case 1: // No way + Message_ContinueTextbox(globalCtx, 0x10A4); + pthis->actionFunc = func_809F008C; + } + } +} + +void func_809EFDD0(EnDns* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == 0x9) { + if (CUR_UPG_VALUE(UPG_STICKS) < 2) { + func_8002F434(&pthis->actor, globalCtx, GI_STICK_UPGRADE_20, 130.0f, 100.0f); + } else { + func_8002F434(&pthis->actor, globalCtx, GI_STICK_UPGRADE_30, 130.0f, 100.0f); + } + } else if (pthis->actor.params == 0xA) { + if (CUR_UPG_VALUE(UPG_NUTS) < 2) { + func_8002F434(&pthis->actor, globalCtx, GI_NUT_UPGRADE_30, 130.0f, 100.0f); + } else { + func_8002F434(&pthis->actor, globalCtx, GI_NUT_UPGRADE_40, 130.0f, 100.0f); + } + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->dnsItemEntry->getItemId, 130.0f, 100.0f); + } +} + +void func_809EFEE8(EnDns* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + func_809EFDD0(pthis, globalCtx); + pthis->actionFunc = func_809EFF50; + } +} + +void func_809EFF50(EnDns* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_809EFF98; + } else { + func_809EFDD0(pthis, globalCtx); + } +} + +void func_809EFF98(EnDns* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->stateFlags1 & 0x400) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + pthis->dnsItemEntry->setRupeesAndFlags(pthis); + pthis->dropCollectible = 1; + pthis->maintainCollider = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnDns_Change(pthis, 1); + pthis->actionFunc = EnDns_SetupBurrow; + } + } else { + pthis->dnsItemEntry->setRupeesAndFlags(pthis); + pthis->dropCollectible = 1; + pthis->maintainCollider = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnDns_Change(pthis, 1); + pthis->actionFunc = EnDns_SetupBurrow; + } +} + +void func_809F008C(EnDns* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + pthis->maintainCollider = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnDns_Change(pthis, 1); + pthis->actionFunc = EnDns_SetupBurrow; + } +} + +void EnDns_SetupBurrow(EnDns* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gBusinessScrubAnim_4404); + + if (pthis->skelAnime.curFrame == frameCount) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_AKINDONUTS_HIDE); + pthis->actionFunc = EnDns_Burrow; + pthis->standOnGround = 0; + pthis->yInitPos = pthis->actor.world.pos.y; + } +} + +void EnDns_Burrow(EnDns* pthis, GlobalContext* globalCtx) { + f32 depth; + Vec3f initPos; + s32 i; + + depth = pthis->yInitPos - pthis->actor.world.pos.y; + if ((pthis->dustTimer & 3) == 0) { + initPos.x = pthis->actor.world.pos.x; + initPos.y = pthis->yInitPos; + initPos.z = pthis->actor.world.pos.z; + func_80028990(globalCtx, 20.0f, &initPos); + } + pthis->actor.shape.rot.y += 0x2000; + // Drops only if you bought its item + if (depth > 400.0f) { + if (pthis->dropCollectible) { + initPos.x = pthis->actor.world.pos.x; + initPos.y = pthis->yInitPos; + initPos.z = pthis->actor.world.pos.z; + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &initPos, ITEM00_HEART); + } + } + Actor_Kill(&pthis->actor); + } +} + +void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDns* pthis = (EnDns*)thisx; + s16 pad; + + pthis->dustTimer++; + pthis->actor.textId = D_809F040C[pthis->actor.params]; + Actor_SetFocus(&pthis->actor, 60.0f); + Actor_SetScale(&pthis->actor, 0.01f); + SkelAnime_Update(&pthis->skelAnime); + Actor_MoveForward(&pthis->actor); + pthis->actionFunc(pthis, globalCtx); + if (pthis->standOnGround) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 20.0f, 4); + } + if (pthis->maintainCollider) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDns* pthis = (EnDns*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, &pthis->actor); +} diff --git a/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c b/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.cpp similarity index 59% rename from src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c rename to src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.cpp index 9ed71be5c..7b87ed3aa 100644 --- a/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c +++ b/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.cpp @@ -31,13 +31,13 @@ typedef enum { void EnDntDemo_Init(Actor* thisx, GlobalContext* globalCtx); void EnDntDemo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDntDemo_Update(Actor* this, GlobalContext* globalCtx); +void EnDntDemo_Update(Actor* pthis, GlobalContext* globalCtx); -void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx); -void EnDntDemo_Results(EnDntDemo* this, GlobalContext* globalCtx); -void EnDntDemo_Prize(EnDntDemo* this, GlobalContext* globalCtx); +void EnDntDemo_Judge(EnDntDemo* pthis, GlobalContext* globalCtx); +void EnDntDemo_Results(EnDntDemo* pthis, GlobalContext* globalCtx); +void EnDntDemo_Prize(EnDntDemo* pthis, GlobalContext* globalCtx); -const ActorInit En_Dnt_Demo_InitVars = { +ActorInit En_Dnt_Demo_InitVars = { ACTOR_EN_DNT_DEMO, ACTORCAT_PROP, FLAGS, @@ -51,7 +51,7 @@ const ActorInit En_Dnt_Demo_InitVars = { //! @bug //! This table is missing a column for the Mask of Truth, so it reads the first value of the next row. In the last row, -//! it reads the first entry of sResultValues (4), which is an invalid result. The scrubs have no reaction in this case. +//! it reads the first entry of sResultValues (4), which is an invalid result. The scrubs have no reaction in pthis case. static s16 sResultTable[8][7] = { /* Keaton Skull Spooky Bunny Goron Zora Gerudo Truth */ { DNT_LIKE, DNT_HATE, DNT_LIKE, DNT_HATE, DNT_LOVE, DNT_LIKE, DNT_HATE }, /* DNT_HATE */ @@ -81,7 +81,7 @@ void EnDntDemo_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnDntDemo_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnDntDemo* this = (EnDntDemo*)thisx; + EnDntDemo* pthis = (EnDntDemo*)thisx; s32 i; s32 pad; @@ -89,31 +89,31 @@ void EnDntDemo_Init(Actor* thisx, GlobalContext* globalCtx2) { // "Deku Scrub mask show start" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デグナッツお面品評会開始 ☆☆☆☆☆ \n" VT_RST); for (i = 0; i < 9; i++) { - this->scrubPos[i] = sScrubPos[i]; - this->scrubs[i] = (EnDntNomal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, - ACTOR_EN_DNT_NOMAL, this->scrubPos[i].x, this->scrubPos[i].y, - this->scrubPos[i].z, 0, 0, 0, i + ENDNTNOMAL_STAGE); - if (this->scrubs[i] != NULL) { + pthis->scrubPos[i] = sScrubPos[i]; + pthis->scrubs[i] = (EnDntNomal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, + ACTOR_EN_DNT_NOMAL, pthis->scrubPos[i].x, pthis->scrubPos[i].y, + pthis->scrubPos[i].z, 0, 0, 0, i + ENDNTNOMAL_STAGE); + if (pthis->scrubs[i] != NULL) { // "zako zako" [small fries] - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ザコザコ ☆☆☆☆☆ %x\n" VT_RST, this->scrubs[i]); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ザコザコ ☆☆☆☆☆ %x\n" VT_RST, pthis->scrubs[i]); } } - this->leaderPos.x = 4050.0f; - this->leaderPos.y = -20.0f; - this->leaderPos.z = 1000.0f; - this->leader = (EnDntJiji*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_DNT_JIJI, - this->leaderPos.x, this->leaderPos.y, this->leaderPos.z, 0, 0, 0, 0); - if (this->leader != NULL) { + pthis->leaderPos.x = 4050.0f; + pthis->leaderPos.y = -20.0f; + pthis->leaderPos.z = 1000.0f; + pthis->leader = (EnDntJiji*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_DNT_JIJI, + pthis->leaderPos.x, pthis->leaderPos.y, pthis->leaderPos.z, 0, 0, 0, 0); + if (pthis->leader != NULL) { // "jiji jiji jiji jiji jiji" [onomatopoeia for the scrub sound?] - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ じじじじじじじじじじい ☆☆☆☆☆ %x\n" VT_RST, this->leader); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ じじじじじじじじじじい ☆☆☆☆☆ %x\n" VT_RST, pthis->leader); } - this->subCamera = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnDntDemo_Judge; + pthis->subCamera = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnDntDemo_Judge; } -void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { +void EnDntDemo_Judge(EnDntDemo* pthis, GlobalContext* globalCtx) { s16 delay; s16 reaction; s16 rand9; @@ -122,45 +122,45 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { u8 ignore; s32 i; - if (this->leaderSignal != DNT_SIGNAL_NONE) { + if (pthis->leaderSignal != DNT_SIGNAL_NONE) { for (i = 0; i < 9; i++) { - this->scrubs[i]->stageSignal = this->leaderSignal; - this->scrubs[i]->action = this->action; - this->scrubs[i]->stagePrize = DNT_PRIZE_NONE; + pthis->scrubs[i]->stageSignal = pthis->leaderSignal; + pthis->scrubs[i]->action = pthis->action; + pthis->scrubs[i]->stagePrize = DNT_PRIZE_NONE; } - if (this->leader->isSolid) { - this->leader->stageSignal = DNT_LEADER_SIGNAL_BURROW; + if (pthis->leader->isSolid) { + pthis->leader->stageSignal = DNT_LEADER_SIGNAL_BURROW; } - this->leaderSignal = DNT_SIGNAL_NONE; - this->actionFunc = EnDntDemo_Results; - } else if ((this->actor.xzDistToPlayer > 30.0f) || (Player_GetMask(globalCtx) == 0)) { - this->debugArrowTimer++; - if (this->subCamera != SUBCAM_FREE) { - this->subCamera = SUBCAM_FREE; + pthis->leaderSignal = DNT_SIGNAL_NONE; + pthis->actionFunc = EnDntDemo_Results; + } else if ((pthis->actor.xzDistToPlayer > 30.0f) || (Player_GetMask(globalCtx) == 0)) { + pthis->debugArrowTimer++; + if (pthis->subCamera != SUBCAM_FREE) { + pthis->subCamera = SUBCAM_FREE; } - if (this->judgeTimer != 0) { + if (pthis->judgeTimer != 0) { for (i = 0; i < 9; i++) { - this->scrubs[i]->stageSignal = DNT_SIGNAL_HIDE; + pthis->scrubs[i]->stageSignal = DNT_SIGNAL_HIDE; } - this->judgeTimer = 0; + pthis->judgeTimer = 0; } } else { - if ((Player_GetMask(globalCtx) != 0) && (this->subCamera == SUBCAM_FREE)) { - this->subCamera = OnePointCutscene_Init(globalCtx, 2220, -99, &this->scrubs[3]->actor, MAIN_CAM); + if ((Player_GetMask(globalCtx) != 0) && (pthis->subCamera == SUBCAM_FREE)) { + pthis->subCamera = OnePointCutscene_Init(globalCtx, 2220, -99, &pthis->scrubs[3]->actor, MAIN_CAM); } - this->debugArrowTimer = 0; - if (this->judgeTimer == 40) { + pthis->debugArrowTimer = 0; + if (pthis->judgeTimer == 40) { for (i = 0; i < 9; i++) { - this->scrubs[i]->stageSignal = DNT_SIGNAL_LOOK; + pthis->scrubs[i]->stageSignal = DNT_SIGNAL_LOOK; } } - if (this->judgeTimer > 40) { + if (pthis->judgeTimer > 40) { // "gera gera" [onomatopoeia for loud giggling] osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ げらげら ☆☆☆☆☆ \n" VT_RST); - func_800F436C(&this->actor.projectedPos, NA_SE_EV_CROWD - SFX_FLAG, 2.0f); + func_800F436C(&pthis->actor.projectedPos, NA_SE_EV_CROWD - SFX_FLAG, 2.0f); } - if (this->judgeTimer < 120) { - this->judgeTimer++; + if (pthis->judgeTimer < 120) { + pthis->judgeTimer++; } else { ignore = false; reaction = DNT_SIGNAL_NONE; @@ -169,7 +169,7 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { case PLAYER_MASK_SKULL: if (!(gSaveContext.itemGetInf[1] & 0x4000)) { reaction = DNT_SIGNAL_CELEBRATE; - this->prize = DNT_PRIZE_STICK; + pthis->prize = DNT_PRIZE_STICK; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_SARIA_THEME); break; } @@ -177,13 +177,13 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { if (!(gSaveContext.itemGetInf[1] & 0x8000) && (Player_GetMask(globalCtx) != PLAYER_MASK_SKULL)) { Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->prize = DNT_PRIZE_NUTS; - this->leader->stageSignal = DNT_LEADER_SIGNAL_UP; + pthis->prize = DNT_PRIZE_NUTS; + pthis->leader->stageSignal = DNT_LEADER_SIGNAL_UP; reaction = DNT_SIGNAL_LOOK; - if (this->subCamera != SUBCAM_FREE) { - this->subCamera = SUBCAM_FREE; + if (pthis->subCamera != SUBCAM_FREE) { + pthis->subCamera = SUBCAM_FREE; reaction = DNT_SIGNAL_LOOK; - OnePointCutscene_Init(globalCtx, 2340, -99, &this->leader->actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 2340, -99, &pthis->leader->actor, MAIN_CAM); } break; } @@ -214,15 +214,15 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { resultIdx = sResultTable[rand9][maskIdx]; reaction = sResultValues[resultIdx][0]; - this->action = sResultValues[resultIdx][1]; - switch (this->action) { + pthis->action = sResultValues[resultIdx][1]; + switch (pthis->action) { case DNT_ACTION_LOW_RUPEES: Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_COURTYARD); break; case DNT_ACTION_ATTACK: - if (this->subCamera != SUBCAM_FREE) { - this->subCamera = SUBCAM_FREE; - OnePointCutscene_Init(globalCtx, 2350, -99, &this->scrubs[3]->actor, MAIN_CAM); + if (pthis->subCamera != SUBCAM_FREE) { + pthis->subCamera = SUBCAM_FREE; + OnePointCutscene_Init(globalCtx, 2350, -99, &pthis->scrubs[3]->actor, MAIN_CAM); } Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); break; @@ -241,7 +241,7 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { // "What kind of evaluation?" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ どういう評価? ☆☆☆☆☆☆ %d\n" VT_RST, reaction); // "What kind of action?" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ どういうアクション? ☆☆☆ %d\n" VT_RST, this->action); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ どういうアクション? ☆☆☆ %d\n" VT_RST, pthis->action); osSyncPrintf("\n\n"); break; } @@ -249,88 +249,88 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { if (reaction != DNT_SIGNAL_NONE) { for (i = 0; i < 9; i++) { if (delay != 0) { - this->scrubs[i]->timer3 = delay * i; + pthis->scrubs[i]->timer3 = delay * i; } - this->scrubs[i]->action = this->action; - this->scrubs[i]->stageSignal = reaction; - this->scrubs[i]->ignore = ignore; - if (this->prize != DNT_PRIZE_NONE) { - this->scrubs[i]->timer1 = 300; - this->scrubs[i]->stagePrize = this->prize; - this->scrubs[i]->targetPos = this->leader->actor.world.pos; - if (this->prize == DNT_PRIZE_NUTS) { - this->leader->stageSignal = DNT_LEADER_SIGNAL_UP; + pthis->scrubs[i]->action = pthis->action; + pthis->scrubs[i]->stageSignal = reaction; + pthis->scrubs[i]->ignore = ignore; + if (pthis->prize != DNT_PRIZE_NONE) { + pthis->scrubs[i]->timer1 = 300; + pthis->scrubs[i]->stagePrize = pthis->prize; + pthis->scrubs[i]->targetPos = pthis->leader->actor.world.pos; + if (pthis->prize == DNT_PRIZE_NUTS) { + pthis->leader->stageSignal = DNT_LEADER_SIGNAL_UP; } - if (this->prize == DNT_PRIZE_STICK) { - this->leader->timer = 300; + if (pthis->prize == DNT_PRIZE_STICK) { + pthis->leader->timer = 300; } } } - this->actionFunc = EnDntDemo_Results; + pthis->actionFunc = EnDntDemo_Results; } } } } -void EnDntDemo_Results(EnDntDemo* this, GlobalContext* globalCtx) { +void EnDntDemo_Results(EnDntDemo* pthis, GlobalContext* globalCtx) { s32 i; - if (this->leaderSignal != DNT_SIGNAL_NONE) { + if (pthis->leaderSignal != DNT_SIGNAL_NONE) { for (i = 0; i < 9; i++) { - this->scrubs[i]->action = this->action; - this->scrubs[i]->stageSignal = this->leaderSignal; - this->scrubs[i]->stagePrize = DNT_PRIZE_NONE; + pthis->scrubs[i]->action = pthis->action; + pthis->scrubs[i]->stageSignal = pthis->leaderSignal; + pthis->scrubs[i]->stagePrize = DNT_PRIZE_NONE; } - if (this->leader->action == DNT_LEADER_ACTION_UP) { - this->leader->stageSignal = DNT_LEADER_SIGNAL_BURROW; - } else if (this->leader->unburrow) { - this->leader->stageSignal = DNT_LEADER_SIGNAL_RETURN; + if (pthis->leader->action == DNT_LEADER_ACTION_UP) { + pthis->leader->stageSignal = DNT_LEADER_SIGNAL_BURROW; + } else if (pthis->leader->unburrow) { + pthis->leader->stageSignal = DNT_LEADER_SIGNAL_RETURN; } else { - this->leader->action = DNT_LEADER_ACTION_ATTACK; + pthis->leader->action = DNT_LEADER_ACTION_ATTACK; } - this->leader->timer = 0; - this->leaderSignal = this->action = DNT_SIGNAL_NONE; - this->actionFunc = EnDntDemo_Prize; - } else if (this->prize == DNT_PRIZE_STICK) { + pthis->leader->timer = 0; + pthis->leaderSignal = pthis->action = DNT_SIGNAL_NONE; + pthis->actionFunc = EnDntDemo_Prize; + } else if (pthis->prize == DNT_PRIZE_STICK) { for (i = 0; i < 9; i++) { - s16 offsetAngle = -this->leader->actor.shape.rot.y; - Vec3f leaderPos = this->leader->actor.world.pos; + s16 offsetAngle = -pthis->leader->actor.shape.rot.y; + Vec3f leaderPos = pthis->leader->actor.world.pos; f32 offsetDist; if (!(i & 1)) { offsetAngle -= 0x59D8; } offsetDist = ((i + 1) * 20.0f) + 20.0f; - this->scrubs[i]->timer2 = 10; - this->scrubs[i]->targetPos.x = leaderPos.x + Math_SinS(offsetAngle) * offsetDist; - this->scrubs[i]->targetPos.y = leaderPos.y; - this->scrubs[i]->targetPos.z = leaderPos.z + Math_CosS(offsetAngle) * offsetDist; + pthis->scrubs[i]->timer2 = 10; + pthis->scrubs[i]->targetPos.x = leaderPos.x + Math_SinS(offsetAngle) * offsetDist; + pthis->scrubs[i]->targetPos.y = leaderPos.y; + pthis->scrubs[i]->targetPos.z = leaderPos.z + Math_CosS(offsetAngle) * offsetDist; } } } -void EnDntDemo_Prize(EnDntDemo* this, GlobalContext* globalCtx) { +void EnDntDemo_Prize(EnDntDemo* pthis, GlobalContext* globalCtx) { s32 i; - if (this->leaderSignal != DNT_SIGNAL_NONE) { + if (pthis->leaderSignal != DNT_SIGNAL_NONE) { for (i = 0; i < 9; i++) { - this->scrubs[i]->action = this->action; - this->scrubs[i]->stageSignal = this->leaderSignal; - this->scrubs[i]->stagePrize = DNT_PRIZE_NONE; + pthis->scrubs[i]->action = pthis->action; + pthis->scrubs[i]->stageSignal = pthis->leaderSignal; + pthis->scrubs[i]->stagePrize = DNT_PRIZE_NONE; } - this->leaderSignal = this->action = DNT_SIGNAL_NONE; + pthis->leaderSignal = pthis->action = DNT_SIGNAL_NONE; } } void EnDntDemo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnDntDemo* this = (EnDntDemo*)thisx; + EnDntDemo* pthis = (EnDntDemo*)thisx; - if (this->unkTimer2 != 0) { - this->unkTimer2--; + if (pthis->unkTimer2 != 0) { + pthis->unkTimer2--; } - if (this->unkTimer1 != 0) { - this->unkTimer1--; + if (pthis->unkTimer1 != 0) { + pthis->unkTimer1--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c deleted file mode 100644 index cda5a7294..000000000 --- a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c +++ /dev/null @@ -1,461 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DNT_JIJI_Z_EN_DNT_JIJI_C -#include "actor_common.h" -/* - * File: z_en_dnt_jiji.c - * Overlay: ovl_En_Dnt_Jiji - * Description: Forest Stage scrub leader - */ - -#include "z_en_dnt_jiji.h" -#include "objects/object_dns/object_dns.h" -#include "overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "vt.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnDntJiji_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDntJiji_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDntJiji_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDntJiji_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDntJiji_SetFlower(EnDntJiji* this, GlobalContext* globalCtx); - -void EnDntJiji_SetupWait(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupUnburrow(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupWalk(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupCower(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupGivePrize(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupHide(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupReturn(EnDntJiji* this, GlobalContext* globalCtx); - -void EnDntJiji_Wait(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Up(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Unburrow(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Walk(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Burrow(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Cower(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_SetupTalk(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Talk(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_GivePrize(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Hide(EnDntJiji* this, GlobalContext* globalCtx); -void EnDntJiji_Return(EnDntJiji* this, GlobalContext* globalCtx); - -const ActorInit En_Dnt_Jiji_InitVars = { - ACTOR_EN_DNT_JIJI, - ACTORCAT_NPC, - FLAGS, - OBJECT_DNS, - sizeof(EnDntJiji), - (ActorFunc)EnDntJiji_Init, - (ActorFunc)EnDntJiji_Destroy, - (ActorFunc)EnDntJiji_Update, - (ActorFunc)EnDntJiji_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 30, 80, 0, { 0, 0, 0 } }, -}; - -void EnDntJiji_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDntJiji* this = (EnDntJiji*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDntJijiSkel, &gDntJijiBurrowAnim, this->jointTable, this->morphTable, - 13); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->stage = (EnDntDemo*)this->actor.parent; - osSyncPrintf("\n\n"); - // "Deku Scrub mask show elder" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ デグナッツお面品評会長老 ☆☆☆☆☆ %x\n" VT_RST, this->stage); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.colChkInfo.mass = 0xFF; - this->actor.targetMode = 6; - this->actionFunc = EnDntJiji_SetFlower; - this->actor.gravity = -2.0f; -} - -void EnDntJiji_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDntJiji* this = (EnDntJiji*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnDntJiji_SetFlower(EnDntJiji* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { - this->flowerPos = this->actor.world.pos; - this->actionFunc = EnDntJiji_SetupWait; - } -} - -void EnDntJiji_SetupWait(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiBurrowAnim); - Animation_Change(&this->skelAnime, &gDntJijiBurrowAnim, 0.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->skelAnime.curFrame = 8.0f; - this->isSolid = this->action = DNT_LEADER_ACTION_NONE; - this->actionFunc = EnDntJiji_Wait; -} - -void EnDntJiji_Wait(EnDntJiji* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - if ((this->timer == 1) && (this->actor.xzDistToPlayer < 150.0f) && !Gameplay_InCsMode(globalCtx) && - !(player->stateFlags1 & 0x800)) { - OnePointCutscene_Init(globalCtx, 2230, -99, &this->actor, MAIN_CAM); - this->timer = 0; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = EnDntJiji_SetupUnburrow; - } -} - -void EnDntJiji_SetupUp(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiUpAnim); - Animation_Change(&this->skelAnime, &gDntJijiUpAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 15, 5, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - this->actionFunc = EnDntJiji_Up; -} - -void EnDntJiji_Up(EnDntJiji* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - if (this->actor.xzDistToPlayer < 150.0f) { - this->actionFunc = EnDntJiji_SetupCower; - } -} - -void EnDntJiji_SetupUnburrow(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiUnburrowAnim); - Animation_Change(&this->skelAnime, &gDntJijiUnburrowAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 15, 5, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - this->actionFunc = EnDntJiji_Unburrow; -} - -void EnDntJiji_Unburrow(EnDntJiji* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (this->endFrame <= frame) { - if (this->action != DNT_LEADER_ACTION_ATTACK) { - this->actionFunc = EnDntJiji_SetupWalk; - } else { - this->actionFunc = EnDntJiji_SetupReturn; - } - } -} - -void EnDntJiji_SetupWalk(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiWalkAnim); - Animation_Change(&this->skelAnime, &gDntJijiWalkAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actor.speedXZ = 1.0f; - this->isSolid = true; - this->unburrow = true; - this->actionFunc = EnDntJiji_Walk; -} - -void EnDntJiji_Walk(EnDntJiji* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3E8, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 0.4f); - if (this->sfxTimer == 0) { - this->sfxTimer = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if ((this->actor.bgCheckFlags & 8) && (this->actor.bgCheckFlags & 1)) { - this->actor.velocity.y = 9.0f; - this->actor.speedXZ = 3.0f; - } - if (this->actor.xzDistToPlayer < 100.0f) { - if (CUR_UPG_VALUE(UPG_STICKS) == 1) { - this->getItemId = GI_STICK_UPGRADE_20; - } else { - this->getItemId = GI_STICK_UPGRADE_30; - } - this->actor.textId = 0x104D; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->actor.speedXZ = 0.0f; - this->unused = 5; - this->actionFunc = EnDntJiji_Talk; - } -} - -void EnDntJiji_SetupBurrow(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiBurrowAnim); - Animation_Change(&this->skelAnime, &gDntJijiBurrowAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 15, 5, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); - this->actionFunc = EnDntJiji_Burrow; -} - -void EnDntJiji_Burrow(EnDntJiji* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); -} - -void EnDntJiji_SetupCower(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiCowerAnim); - Animation_Change(&this->skelAnime, &gDntJijiCowerAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 9, 3, 10, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - - if ((CUR_UPG_VALUE(UPG_NUTS) == 1) || (CUR_UPG_VALUE(UPG_NUTS) == 0)) { - this->getItemId = GI_NUT_UPGRADE_30; - } else { - this->getItemId = GI_NUT_UPGRADE_40; - } - this->actor.flags |= ACTOR_FLAG_0; - this->actor.textId = 0x10DB; - this->unused = 5; - this->actionFunc = EnDntJiji_Cower; -} - -void EnDntJiji_Cower(EnDntJiji* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - if (frame >= this->endFrame) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnDntJiji_SetupTalk; - } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } -} - -void EnDntJiji_SetupTalk(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiTalkAnim); - Animation_Change(&this->skelAnime, &gDntJijiTalkAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actionFunc = EnDntJiji_Talk; -} - -void EnDntJiji_Talk(EnDntJiji* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, NULL, 7); - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, this->getItemId, 400.0f, 200.0f); - this->actionFunc = EnDntJiji_SetupGivePrize; - } -} - -void EnDntJiji_SetupGivePrize(EnDntJiji* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = EnDntJiji_GivePrize; - } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, 400.0f, 200.0f); - } -} - -void EnDntJiji_GivePrize(EnDntJiji* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - if ((this->getItemId == GI_NUT_UPGRADE_30) || (this->getItemId == GI_NUT_UPGRADE_40)) { - // "nut" - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - osSyncPrintf("実 \n"); - gSaveContext.itemGetInf[1] |= 0x8000; - } else { - // "stick" - osSyncPrintf("棒 \n"); - osSyncPrintf("棒 \n"); - osSyncPrintf("棒 \n"); - osSyncPrintf("棒 \n"); - osSyncPrintf("棒 \n"); - osSyncPrintf("棒 \n"); - gSaveContext.itemGetInf[1] |= 0x4000; - } - this->actor.textId = 0; - if ((this->stage != NULL) && (this->stage->actor.update != NULL)) { - this->stage->action = DNT_ACTION_NONE; - if (!this->unburrow) { - this->stage->leaderSignal = DNT_SIGNAL_HIDE; - } else { - this->stage->leaderSignal = DNT_SIGNAL_RETURN; - } - } - this->actor.flags &= ~ACTOR_FLAG_0; - if (!this->unburrow) { - this->actionFunc = EnDntJiji_SetupHide; - } else { - this->actionFunc = EnDntJiji_SetupReturn; - } - } -} - -void EnDntJiji_SetupHide(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiHideAnim); - Animation_Change(&this->skelAnime, &gDntJijiHideAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->actionFunc = EnDntJiji_Hide; -} - -void EnDntJiji_Hide(EnDntJiji* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (this->endFrame <= frame) { - this->actionFunc = EnDntJiji_SetupWait; - } -} - -void EnDntJiji_SetupReturn(EnDntJiji* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntJijiWalkAnim); - Animation_Change(&this->skelAnime, &gDntJijiWalkAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actor.speedXZ = 2.0f; - this->isSolid = this->unburrow = true; - this->actionFunc = EnDntJiji_Return; -} - -void EnDntJiji_Return(EnDntJiji* this, GlobalContext* globalCtx) { - f32 dx; - f32 dz; - - SkelAnime_Update(&this->skelAnime); - dx = this->flowerPos.x - this->actor.world.pos.x; - dz = this->flowerPos.z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actor.bgCheckFlags & 8) && (this->actor.bgCheckFlags & 1)) { - this->actor.velocity.y = 9.0f; - this->actor.speedXZ = 3.0f; - } - if (this->sfxTimer == 0) { - this->sfxTimer = 3; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if ((fabsf(dx) < 5.0f) && (fabsf(dz) < 5.0f)) { - this->actor.world.pos.x = this->flowerPos.x; - this->actor.world.pos.z = this->flowerPos.z; - if (this->attackFlag) { - if ((this->stage->actor.update != NULL) && (this->stage->leaderSignal == DNT_SIGNAL_NONE)) { - this->stage->leaderSignal = DNT_SIGNAL_HIDE; - this->stage->action = DNT_ACTION_ATTACK; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); - } - } - this->actor.speedXZ = 0.0f; - this->isSolid = 0; - this->actionFunc = EnDntJiji_SetupBurrow; - } -} - -void EnDntJiji_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDntJiji* this = (EnDntJiji*)thisx; - - Actor_SetScale(&this->actor, 0.015f); - this->unkTimer++; - if (BREG(0)) { - // "time" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 時間 ☆☆☆☆☆ %d\n" VT_RST, this->timer); - } - if ((this->timer > 1) && (this->timer != 0)) { - this->timer--; - } - if (this->sfxTimer != 0) { - this->sfxTimer--; - } - if (this->blinkTimer != 0) { - this->blinkTimer--; - } - switch (this->stageSignal) { - case DNT_LEADER_SIGNAL_UP: - this->isSolid = true; - this->action = DNT_LEADER_ACTION_UP; - this->actionFunc = EnDntJiji_SetupUp; - break; - case DNT_LEADER_SIGNAL_BURROW: - this->isSolid = false; - this->action = DNT_LEADER_ACTION_NONE; - this->actionFunc = EnDntJiji_SetupBurrow; - break; - case DNT_LEADER_SIGNAL_RETURN: - this->actionFunc = EnDntJiji_SetupReturn; - break; - case DNT_LEADER_SIGNAL_NONE: - break; - } - if (this->actor.textId != 0) { - Actor_SetFocus(&this->actor, 30.0f); - } - if (this->stageSignal != DNT_LEADER_SIGNAL_NONE) { - this->stageSignal = DNT_LEADER_SIGNAL_NONE; - } - if (this->blinkTimer == 0) { - this->eyeState++; - if (this->eyeState > 2) { - this->eyeState = 0; - this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - } - } - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->isSolid != 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void EnDntJiji_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* blinkTex[] = { gDntJijiEyeOpenTex, gDntJijiEyeHalfTex, gDntJijiEyeShutTex }; - EnDntJiji* this = (EnDntJiji*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_jiji.c", 1019); - func_80093D18(globalCtx->state.gfxCtx); - Matrix_Push(); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(blinkTex[this->eyeState])); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, this); - Matrix_Pop(); - Matrix_Translate(this->flowerPos.x, this->flowerPos.y, this->flowerPos.z, MTXMODE_NEW); - Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dnt_jiji.c", 1040), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDntJijiFlowerDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_jiji.c", 1043); -} diff --git a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.cpp b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.cpp new file mode 100644 index 000000000..7e93be202 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.cpp @@ -0,0 +1,461 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DNT_JIJI_Z_EN_DNT_JIJI_C +#include "actor_common.h" +/* + * File: z_en_dnt_jiji.c + * Overlay: ovl_En_Dnt_Jiji + * Description: Forest Stage scrub leader + */ + +#include "z_en_dnt_jiji.h" +#include "objects/object_dns/object_dns.h" +#include "overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "vt.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnDntJiji_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDntJiji_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDntJiji_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDntJiji_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDntJiji_SetFlower(EnDntJiji* pthis, GlobalContext* globalCtx); + +void EnDntJiji_SetupWait(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupUnburrow(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupWalk(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupCower(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupGivePrize(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupHide(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupReturn(EnDntJiji* pthis, GlobalContext* globalCtx); + +void EnDntJiji_Wait(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Up(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Unburrow(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Walk(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Burrow(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Cower(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_SetupTalk(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Talk(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_GivePrize(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Hide(EnDntJiji* pthis, GlobalContext* globalCtx); +void EnDntJiji_Return(EnDntJiji* pthis, GlobalContext* globalCtx); + +ActorInit En_Dnt_Jiji_InitVars = { + ACTOR_EN_DNT_JIJI, + ACTORCAT_NPC, + FLAGS, + OBJECT_DNS, + sizeof(EnDntJiji), + (ActorFunc)EnDntJiji_Init, + (ActorFunc)EnDntJiji_Destroy, + (ActorFunc)EnDntJiji_Update, + (ActorFunc)EnDntJiji_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 30, 80, 0, { 0, 0, 0 } }, +}; + +void EnDntJiji_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDntJiji* pthis = (EnDntJiji*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDntJijiSkel, &gDntJijiBurrowAnim, pthis->jointTable, pthis->morphTable, + 13); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->stage = (EnDntDemo*)pthis->actor.parent; + osSyncPrintf("\n\n"); + // "Deku Scrub mask show elder" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ デグナッツお面品評会長老 ☆☆☆☆☆ %x\n" VT_RST, pthis->stage); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.colChkInfo.mass = 0xFF; + pthis->actor.targetMode = 6; + pthis->actionFunc = EnDntJiji_SetFlower; + pthis->actor.gravity = -2.0f; +} + +void EnDntJiji_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDntJiji* pthis = (EnDntJiji*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnDntJiji_SetFlower(EnDntJiji* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->flowerPos = pthis->actor.world.pos; + pthis->actionFunc = EnDntJiji_SetupWait; + } +} + +void EnDntJiji_SetupWait(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiBurrowAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiBurrowAnim, 0.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->skelAnime.curFrame = 8.0f; + pthis->isSolid = pthis->action = DNT_LEADER_ACTION_NONE; + pthis->actionFunc = EnDntJiji_Wait; +} + +void EnDntJiji_Wait(EnDntJiji* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->timer == 1) && (pthis->actor.xzDistToPlayer < 150.0f) && !Gameplay_InCsMode(globalCtx) && + !(player->stateFlags1 & 0x800)) { + OnePointCutscene_Init(globalCtx, 2230, -99, &pthis->actor, MAIN_CAM); + pthis->timer = 0; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = EnDntJiji_SetupUnburrow; + } +} + +void EnDntJiji_SetupUp(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiUpAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiUpAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 6.0f, 0, 15, 5, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + pthis->actionFunc = EnDntJiji_Up; +} + +void EnDntJiji_Up(EnDntJiji* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + if (pthis->actor.xzDistToPlayer < 150.0f) { + pthis->actionFunc = EnDntJiji_SetupCower; + } +} + +void EnDntJiji_SetupUnburrow(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiUnburrowAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiUnburrowAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 6.0f, 0, 15, 5, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + pthis->actionFunc = EnDntJiji_Unburrow; +} + +void EnDntJiji_Unburrow(EnDntJiji* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->endFrame <= frame) { + if (pthis->action != DNT_LEADER_ACTION_ATTACK) { + pthis->actionFunc = EnDntJiji_SetupWalk; + } else { + pthis->actionFunc = EnDntJiji_SetupReturn; + } + } +} + +void EnDntJiji_SetupWalk(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiWalkAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiWalkAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.speedXZ = 1.0f; + pthis->isSolid = true; + pthis->unburrow = true; + pthis->actionFunc = EnDntJiji_Walk; +} + +void EnDntJiji_Walk(EnDntJiji* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, 0x3E8, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + Math_ApproachF(&pthis->actor.speedXZ, 1.0f, 0.2f, 0.4f); + if (pthis->sfxTimer == 0) { + pthis->sfxTimer = 5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if ((pthis->actor.bgCheckFlags & 8) && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.velocity.y = 9.0f; + pthis->actor.speedXZ = 3.0f; + } + if (pthis->actor.xzDistToPlayer < 100.0f) { + if (CUR_UPG_VALUE(UPG_STICKS) == 1) { + pthis->getItemId = GI_STICK_UPGRADE_20; + } else { + pthis->getItemId = GI_STICK_UPGRADE_30; + } + pthis->actor.textId = 0x104D; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->actor.speedXZ = 0.0f; + pthis->unused = 5; + pthis->actionFunc = EnDntJiji_Talk; + } +} + +void EnDntJiji_SetupBurrow(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiBurrowAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiBurrowAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 6.0f, 0, 15, 5, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DOWN); + pthis->actionFunc = EnDntJiji_Burrow; +} + +void EnDntJiji_Burrow(EnDntJiji* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); +} + +void EnDntJiji_SetupCower(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiCowerAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiCowerAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 3.0f, 0, 9, 3, 10, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + + if ((CUR_UPG_VALUE(UPG_NUTS) == 1) || (CUR_UPG_VALUE(UPG_NUTS) == 0)) { + pthis->getItemId = GI_NUT_UPGRADE_30; + } else { + pthis->getItemId = GI_NUT_UPGRADE_40; + } + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.textId = 0x10DB; + pthis->unused = 5; + pthis->actionFunc = EnDntJiji_Cower; +} + +void EnDntJiji_Cower(EnDntJiji* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + if (frame >= pthis->endFrame) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDntJiji_SetupTalk; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } +} + +void EnDntJiji_SetupTalk(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiTalkAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiTalkAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = EnDntJiji_Talk; +} + +void EnDntJiji_Talk(EnDntJiji* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, NULL, 7); + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 400.0f, 200.0f); + pthis->actionFunc = EnDntJiji_SetupGivePrize; + } +} + +void EnDntJiji_SetupGivePrize(EnDntJiji* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDntJiji_GivePrize; + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 400.0f, 200.0f); + } +} + +void EnDntJiji_GivePrize(EnDntJiji* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + if ((pthis->getItemId == GI_NUT_UPGRADE_30) || (pthis->getItemId == GI_NUT_UPGRADE_40)) { + // "nut" + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + osSyncPrintf("実 \n"); + gSaveContext.itemGetInf[1] |= 0x8000; + } else { + // "stick" + osSyncPrintf("棒 \n"); + osSyncPrintf("棒 \n"); + osSyncPrintf("棒 \n"); + osSyncPrintf("棒 \n"); + osSyncPrintf("棒 \n"); + osSyncPrintf("棒 \n"); + gSaveContext.itemGetInf[1] |= 0x4000; + } + pthis->actor.textId = 0; + if ((pthis->stage != NULL) && (pthis->stage->actor.update != NULL)) { + pthis->stage->action = DNT_ACTION_NONE; + if (!pthis->unburrow) { + pthis->stage->leaderSignal = DNT_SIGNAL_HIDE; + } else { + pthis->stage->leaderSignal = DNT_SIGNAL_RETURN; + } + } + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (!pthis->unburrow) { + pthis->actionFunc = EnDntJiji_SetupHide; + } else { + pthis->actionFunc = EnDntJiji_SetupReturn; + } + } +} + +void EnDntJiji_SetupHide(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiHideAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiHideAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = EnDntJiji_Hide; +} + +void EnDntJiji_Hide(EnDntJiji* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->endFrame <= frame) { + pthis->actionFunc = EnDntJiji_SetupWait; + } +} + +void EnDntJiji_SetupReturn(EnDntJiji* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntJijiWalkAnim); + Animation_Change(&pthis->skelAnime, &gDntJijiWalkAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.speedXZ = 2.0f; + pthis->isSolid = pthis->unburrow = true; + pthis->actionFunc = EnDntJiji_Return; +} + +void EnDntJiji_Return(EnDntJiji* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dz; + + SkelAnime_Update(&pthis->skelAnime); + dx = pthis->flowerPos.x - pthis->actor.world.pos.x; + dz = pthis->flowerPos.z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if ((pthis->actor.bgCheckFlags & 8) && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.velocity.y = 9.0f; + pthis->actor.speedXZ = 3.0f; + } + if (pthis->sfxTimer == 0) { + pthis->sfxTimer = 3; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if ((fabsf(dx) < 5.0f) && (fabsf(dz) < 5.0f)) { + pthis->actor.world.pos.x = pthis->flowerPos.x; + pthis->actor.world.pos.z = pthis->flowerPos.z; + if (pthis->attackFlag) { + if ((pthis->stage->actor.update != NULL) && (pthis->stage->leaderSignal == DNT_SIGNAL_NONE)) { + pthis->stage->leaderSignal = DNT_SIGNAL_HIDE; + pthis->stage->action = DNT_ACTION_ATTACK; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); + } + } + pthis->actor.speedXZ = 0.0f; + pthis->isSolid = 0; + pthis->actionFunc = EnDntJiji_SetupBurrow; + } +} + +void EnDntJiji_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDntJiji* pthis = (EnDntJiji*)thisx; + + Actor_SetScale(&pthis->actor, 0.015f); + pthis->unkTimer++; + if (BREG(0)) { + // "time" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 時間 ☆☆☆☆☆ %d\n" VT_RST, pthis->timer); + } + if ((pthis->timer > 1) && (pthis->timer != 0)) { + pthis->timer--; + } + if (pthis->sfxTimer != 0) { + pthis->sfxTimer--; + } + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + } + switch (pthis->stageSignal) { + case DNT_LEADER_SIGNAL_UP: + pthis->isSolid = true; + pthis->action = DNT_LEADER_ACTION_UP; + pthis->actionFunc = EnDntJiji_SetupUp; + break; + case DNT_LEADER_SIGNAL_BURROW: + pthis->isSolid = false; + pthis->action = DNT_LEADER_ACTION_NONE; + pthis->actionFunc = EnDntJiji_SetupBurrow; + break; + case DNT_LEADER_SIGNAL_RETURN: + pthis->actionFunc = EnDntJiji_SetupReturn; + break; + case DNT_LEADER_SIGNAL_NONE: + break; + } + if (pthis->actor.textId != 0) { + Actor_SetFocus(&pthis->actor, 30.0f); + } + if (pthis->stageSignal != DNT_LEADER_SIGNAL_NONE) { + pthis->stageSignal = DNT_LEADER_SIGNAL_NONE; + } + if (pthis->blinkTimer == 0) { + pthis->eyeState++; + if (pthis->eyeState > 2) { + pthis->eyeState = 0; + pthis->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (pthis->isSolid != 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void EnDntJiji_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* blinkTex[] = { gDntJijiEyeOpenTex, gDntJijiEyeHalfTex, gDntJijiEyeShutTex }; + EnDntJiji* pthis = (EnDntJiji*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_jiji.c", 1019); + func_80093D18(globalCtx->state.gfxCtx); + Matrix_Push(); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(blinkTex[pthis->eyeState])); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, pthis); + Matrix_Pop(); + Matrix_Translate(pthis->flowerPos.x, pthis->flowerPos.y, pthis->flowerPos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dnt_jiji.c", 1040), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDntJijiFlowerDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_jiji.c", 1043); +} diff --git a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c deleted file mode 100644 index 49998970b..000000000 --- a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c +++ /dev/null @@ -1,903 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DNT_NOMAL_Z_EN_DNT_NOMAL_C -#include "actor_common.h" -/* - * File: z_en_dnt_nomal - * Overlay: ovl_En_Dnt_Nomal - * Description: Lost Woods minigame scrubs - */ - -#include "z_en_dnt_nomal.h" -#include "objects/object_dnk/object_dnk.h" -#include "overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.h" -#include "overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.h" -#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_hintnuts/object_hintnuts.h" -#include "vt.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnDntNomal_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDntNomal_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDntNomal_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDntNomal_DrawTargetScrub(Actor* thisx, GlobalContext* globalCtx); -void EnDntNomal_DrawStageScrub(Actor* thisx, GlobalContext* globalCtx); - -void EnDntNomal_WaitForObject(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetFlower(EnDntNomal* this, GlobalContext* globalCtx); - -void EnDntNomal_SetupTargetWait(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupTargetUnburrow(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupTargetWalk(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupTargetTalk(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupTargetGivePrize(EnDntNomal* this, GlobalContext* globalCtx); - -void EnDntNomal_TargetWait(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetUnburrow(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetWalk(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetFacePlayer(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetTalk(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetGivePrize(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetReturn(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_TargetBurrow(EnDntNomal* this, GlobalContext* globalCtx); - -void EnDntNomal_SetupStageWait(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupStageCelebrate(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupStageDance(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupStageHide(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_SetupStageAttack(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageSetupReturn(EnDntNomal* this, GlobalContext* globalCtx); - -void EnDntNomal_StageWait(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageUp(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageUnburrow(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageCelebrate(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageDance(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageHide(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageAttackHide(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageAttack(EnDntNomal* this, GlobalContext* globalCtx); -void EnDntNomal_StageReturn(EnDntNomal* this, GlobalContext* globalCtx); - -const ActorInit En_Dnt_Nomal_InitVars = { - ACTOR_EN_DNT_NOMAL, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnDntNomal), - (ActorFunc)EnDntNomal_Init, - (ActorFunc)EnDntNomal_Destroy, - (ActorFunc)EnDntNomal_Update, - NULL, -}; - -static ColliderCylinderInit sBodyCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 16, 46, 0, { 0, 0, 0 } }, -}; - -static ColliderQuadInit sTargetQuadInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static Color_RGBA8 sLeafColors[] = { - { 255, 255, 255, 255 }, { 255, 195, 175, 255 }, { 210, 255, 0, 255 }, - { 255, 255, 255, 255 }, { 210, 255, 0, 255 }, { 255, 195, 175, 255 }, - { 255, 255, 255, 255 }, { 255, 195, 175, 255 }, { 210, 255, 0, 255 }, -}; - -void EnDntNomal_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDntNomal* this = (EnDntNomal*)thisx; - - this->type = this->actor.params; - if (this->type < ENDNTNOMAL_TARGET) { - this->type = ENDNTNOMAL_TARGET; - } - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.colChkInfo.mass = 0xFF; - this->objId = -1; - if (this->type == ENDNTNOMAL_TARGET) { - osSyncPrintf("\n\n"); - // "Deku Scrub target" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デグナッツ的当て ☆☆☆☆☆ \n" VT_RST); - Collider_InitQuad(globalCtx, &this->targetQuad); - Collider_SetQuad(globalCtx, &this->targetQuad, &this->actor, &sTargetQuadInit); - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->objId = OBJECT_HINTNUTS; - } else { - osSyncPrintf("\n\n"); - // "Deku Scrub mask show audience" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デグナッツお面品評会一般人 ☆☆☆☆☆ \n" VT_RST); - Collider_InitCylinder(globalCtx, &this->bodyCyl); - Collider_SetCylinder(globalCtx, &this->bodyCyl, &this->actor, &sBodyCylinderInit); - this->objId = OBJECT_DNK; - } - if (this->objId >= 0) { - this->objIndex = Object_GetIndex(&globalCtx->objectCtx, this->objId); - if (this->objIndex < 0) { - Actor_Kill(&this->actor); - // "What?" - osSyncPrintf(VT_FGCOL(PURPLE) " なにみの? %d\n" VT_RST "\n", this->objIndex); - // "Bank is funny" - osSyncPrintf(VT_FGCOL(CYAN) " バンクおかしいしぞ!%d\n" VT_RST "\n", this->actor.params); - return; - } - } else { - Actor_Kill(&this->actor); - } - this->actionFunc = EnDntNomal_WaitForObject; -} - -void EnDntNomal_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDntNomal* this = (EnDntNomal*)thisx; - - if (this->type == ENDNTNOMAL_TARGET) { - Collider_DestroyQuad(globalCtx, &this->targetQuad); - } else { - Collider_DestroyCylinder(globalCtx, &this->bodyCyl); - } -} - -void EnDntNomal_WaitForObject(EnDntNomal* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[this->objIndex].vromStart); - this->actor.objBankIndex = this->objIndex; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - this->actor.gravity = -2.0f; - Actor_SetScale(&this->actor, 0.01f); - if (this->type == ENDNTNOMAL_TARGET) { - SkelAnime_Init(globalCtx, &this->skelAnime, &gHintNutsSkel, &gHintNutsBurrowAnim, this->jointTable, - this->morphTable, 10); - this->actor.draw = EnDntNomal_DrawTargetScrub; - } else { - SkelAnime_Init(globalCtx, &this->skelAnime, &gDntStageSkel, &gDntStageHideAnim, this->jointTable, - this->morphTable, 11); - this->actor.draw = EnDntNomal_DrawStageScrub; - } - this->actionFunc = EnDntNomal_SetFlower; - } -} - -void EnDntNomal_SetFlower(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { - this->flowerPos = this->actor.world.pos; - if (this->type == ENDNTNOMAL_TARGET) { - this->actionFunc = EnDntNomal_SetupTargetWait; - } else { - this->actionFunc = EnDntNomal_SetupStageWait; - } - } -} - -void EnDntNomal_SetupTargetWait(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsBurrowAnim); - Animation_Change(&this->skelAnime, &gHintNutsBurrowAnim, 0.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->skelAnime.curFrame = 8.0f; - this->actionFunc = EnDntNomal_TargetWait; -} - -void EnDntNomal_TargetWait(EnDntNomal* this, GlobalContext* globalCtx) { - Vec3f scorePos; - f32 targetX = 1340.0f; - f32 targetY = 50.0f; - f32 targetZ = -30.0f; - f32 dx; - f32 dy; - f32 dz; - Vec3f scoreAccel = { 0.0f, 0.0f, 0.0f }; - Vec3f scoreVel = { 0.0f, 0.0f, 0.0f }; - - this->targetVtx[0].x = this->targetVtx[1].x = this->targetVtx[2].x = this->targetVtx[3].x = targetX; - - this->targetVtx[1].y = this->targetVtx[0].y = targetY - 24.0f; - - this->targetVtx[2].z = this->targetVtx[0].z = targetZ + 24.0f; - - this->targetVtx[3].z = this->targetVtx[1].z = targetZ - 24.0f; - - this->targetVtx[3].y = this->targetVtx[2].y = targetY + 24.0f; - - SkelAnime_Update(&this->skelAnime); - if ((this->targetQuad.base.acFlags & AC_HIT) || BREG(0)) { - this->targetQuad.base.acFlags &= ~AC_HIT; - - dx = fabsf(targetX - this->targetQuad.info.bumper.hitPos.x); - dy = fabsf(targetY - this->targetQuad.info.bumper.hitPos.y); - dz = fabsf(targetZ - this->targetQuad.info.bumper.hitPos.z); - - scoreVel.y = 5.0f; - - if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 8.0f) { - scorePos.x = this->actor.world.pos.x - 20.0f; - scorePos.y = this->actor.world.pos.y + 20.0f; - scorePos.z = this->actor.world.pos.z; - EffectSsExtra_Spawn(globalCtx, &scorePos, &scoreVel, &scoreAccel, 4, 2); - Audio_StopSfxById(NA_SE_SY_TRE_BOX_APPEAR); - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - // "Big hit" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 大当り ☆☆☆☆☆ %d\n" VT_RST, this->hitCounter); - if (!LINK_IS_ADULT && !(gSaveContext.itemGetInf[1] & 0x2000)) { - this->hitCounter++; - if (this->hitCounter >= 3) { - OnePointCutscene_Init(globalCtx, 4140, -99, &this->actor, MAIN_CAM); - func_8002DF54(globalCtx, &this->actor, 1); - this->timer4 = 50; - this->actionFunc = EnDntNomal_SetupTargetUnburrow; - } - } - } else if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 24.0f) { - scorePos.x = this->actor.world.pos.x; - scorePos.y = this->actor.world.pos.y + 20.0f; - scorePos.z = this->actor.world.pos.z; - EffectSsExtra_Spawn(globalCtx, &scorePos, &scoreVel, &scoreAccel, 4, 0); - this->hitCounter = 0; - } - } -} - -void EnDntNomal_SetupTargetUnburrow(EnDntNomal* this, GlobalContext* globalCtx) { - Vec3f spawnPos; - - if (this->timer4 == 0) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsUnburrowAnim); - Animation_Change(&this->skelAnime, &gHintNutsUnburrowAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - spawnPos = this->actor.world.pos; - spawnPos.y = this->actor.world.pos.y + 50.0f; - EffectSsHahen_SpawnBurst(globalCtx, &spawnPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - this->actionFunc = EnDntNomal_TargetUnburrow; - } -} - -void EnDntNomal_TargetUnburrow(EnDntNomal* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (frame >= this->endFrame) { - this->actionFunc = EnDntNomal_SetupTargetWalk; - } -} - -void EnDntNomal_SetupTargetWalk(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsRunAnim); - Animation_Change(&this->skelAnime, &gHintNutsRunAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actor.speedXZ = 1.0f; - this->actor.colChkInfo.mass = 0; - this->actionFunc = EnDntNomal_TargetWalk; -} - -void EnDntNomal_TargetWalk(EnDntNomal* this, GlobalContext* globalCtx) { - f32 dx; - f32 dz; - - SkelAnime_Update(&this->skelAnime); - dx = 1340.0f + 3.0f - this->actor.world.pos.x; - dz = 0.0f - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 0x32, 0xBB8, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if (this->actor.world.pos.z > -30.0f) { - this->actor.speedXZ = 0.0f; - this->actionFunc = EnDntNomal_TargetFacePlayer; - } -} - -void EnDntNomal_TargetFacePlayer(EnDntNomal* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if (fabsf(this->actor.shape.rot.y - this->actor.yawTowardsPlayer) < 30.0f) { - this->actionFunc = EnDntNomal_SetupTargetTalk; - } -} - -void EnDntNomal_SetupTargetTalk(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsTalkAnim); - Animation_Change(&this->skelAnime, &gHintNutsTalkAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actor.textId = 0x10AF; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->actionFunc = EnDntNomal_TargetTalk; -} - -void EnDntNomal_TargetTalk(EnDntNomal* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - GET_ACTIVE_CAM(globalCtx)->csId = 0; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = EnDntNomal_SetupTargetGivePrize; - } -} - -void EnDntNomal_SetupTargetGivePrize(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsSpitAnim); - Animation_Change(&this->skelAnime, &gHintNutsSpitAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->actionFunc = EnDntNomal_TargetGivePrize; -} - -void EnDntNomal_TargetGivePrize(EnDntNomal* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if ((frame >= 8.0f) && !this->spawnedItem) { - f32 itemX = this->mouthPos.x - 10.0f; - f32 itemY = this->mouthPos.y; - f32 itemZ = this->mouthPos.z; - - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_ITEM, itemX, itemY, itemZ, 0, - 0, 0, EXITEM_BULLET_BAG) == NULL) { - func_8002DF54(globalCtx, NULL, 7); - Actor_Kill(&this->actor); - } - this->spawnedItem = true; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); - } - if (frame >= this->endFrame) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsRunAnim); - Animation_Change(&this->skelAnime, &gHintNutsRunAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actionFunc = EnDntNomal_TargetReturn; - } -} - -void EnDntNomal_TargetReturn(EnDntNomal* this, GlobalContext* globalCtx) { - f32 dx; - f32 dz; - - SkelAnime_Update(&this->skelAnime); - dx = this->flowerPos.x - this->actor.world.pos.x; - dz = -180.0f - this->actor.world.pos.z; - - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 3, 0x1388, 0); - if (fabsf(this->actor.shape.rot.y - (s16)(Math_FAtan2F(dx, dz) * (0x8000 / M_PI))) < 20.0f) { - this->actor.speedXZ = 1.0f; - } - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->actor.world.pos.z < -172.0f) { - this->endFrame = (f32)Animation_GetLastFrame(&gHintNutsBurrowAnim); - Animation_Change(&this->skelAnime, &gHintNutsBurrowAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->actor.world.pos.z = -173.0f; - this->actor.speedXZ = 0.0f; - this->actionFunc = EnDntNomal_TargetBurrow; - } -} - -void EnDntNomal_TargetBurrow(EnDntNomal* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (frame >= this->endFrame) { - this->actionFunc = EnDntNomal_SetupTargetWait; - } -} - -void EnDntNomal_SetupStageWait(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->timer3 == 0) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageHideAnim); - Animation_Change(&this->skelAnime, &gDntStageHideAnim, 0.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->skelAnime.curFrame = 8.0f; - this->isSolid = false; - this->actionFunc = EnDntNomal_StageWait; - } -} - -void EnDntNomal_StageWait(EnDntNomal* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); -} - -void EnDntNomal_SetupStageUp(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->timer3 == 0) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageUpAnim); - Animation_Change(&this->skelAnime, &gDntStageUpAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - if (this->action != DNT_ACTION_ATTACK) { - this->rotDirection = -1; - } - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - this->isSolid = true; - this->actionFunc = EnDntNomal_StageUp; - } -} - -void EnDntNomal_StageUp(EnDntNomal* this, GlobalContext* globalCtx) { - s16 rotTarget; - f32 frame = this->skelAnime.curFrame; - f32 turnMod; - - SkelAnime_Update(&this->skelAnime); - if ((frame >= this->endFrame) && (this->action == DNT_ACTION_ATTACK)) { - this->actionFunc = EnDntNomal_SetupStageAttack; - } else { - if (this->timer4 == 0) { - turnMod = 0.0f; - if (this->stagePrize == DNT_PRIZE_NONE) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - } else { - f32 dx = this->targetPos.x - this->actor.world.pos.x; - f32 dz = this->targetPos.z - this->actor.world.pos.z; - - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); - turnMod = 90.0f; - } - if ((Rand_ZeroFloat(10.0f + turnMod) < 1.0f) && (this->action != DNT_ACTION_ATTACK)) { - this->timer4 = (s16)Rand_ZeroFloat(30.0f) + 30; - } - } else { - if (this->timer2 == 0) { - this->rotDirection++; - if (this->rotDirection > 1) { - this->rotDirection = -1; - } - this->timer2 = (s16)Rand_ZeroFloat(10.0f) + 10; - } - rotTarget = this->actor.yawTowardsPlayer; - if (this->rotDirection != 0) { - rotTarget += this->rotDirection * 0x1388; - } - Math_SmoothStepToS(&this->actor.shape.rot.y, rotTarget, 3, 0x1388, 0); - } - if (this->actor.xzDistToPlayer < 70.0f) { - this->actionFunc = EnDntNomal_SetupStageHide; - } - } -} - -void EnDntNomal_SetupStageUnburrow(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->timer3 == 0) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageUnburrowAnim); - Animation_Change(&this->skelAnime, &gDntStageUnburrowAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->isSolid = false; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - this->actionFunc = EnDntNomal_StageUnburrow; - } -} - -void EnDntNomal_StageUnburrow(EnDntNomal* this, GlobalContext* globalCtx) { - f32 frame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (frame >= this->endFrame) { - if (this->action != DNT_ACTION_DANCE) { - this->timer3 = (s16)Rand_ZeroFloat(2.0f) + (s16)(this->type * 0.5f); - this->actionFunc = EnDntNomal_SetupStageCelebrate; - } else { - this->timer2 = 300; - this->actionFunc = EnDntNomal_SetupStageDance; - } - } -} - -void EnDntNomal_SetupStageCelebrate(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageWalkAnim); - Animation_Change(&this->skelAnime, &gDntStageWalkAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actor.speedXZ = 3.0f; - this->isSolid = true; - this->actionFunc = EnDntNomal_StageCelebrate; -} - -void EnDntNomal_StageCelebrate(EnDntNomal* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((this->timer1 == 0) && (this->timer3 == 0)) { - f32 dx = this->targetPos.x - this->actor.world.pos.x; - f32 dz = this->targetPos.z - this->actor.world.pos.z; - - if ((fabsf(dx) < 10.0f) && (fabsf(dz) < 10.0f) && (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { - this->action = DNT_ACTION_PRIZE; - this->actionFunc = EnDntNomal_SetupStageDance; - this->actor.speedXZ = 0.0f; - return; - } - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - } else { - if (this->timer1 == 1) { - this->timer3 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x14, 0x1388, 0); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - } - if (this->timer5 == 0) { - this->timer5 = 20; - if ((this->type & 1) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - } - } else if ((this->timer5 & 3) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if ((this->actor.bgCheckFlags & 8) && (this->actor.bgCheckFlags & 1)) { - this->actor.velocity.y = 7.5f; - } -} - -void EnDntNomal_SetupStageDance(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageDanceAnim); - Animation_Change(&this->skelAnime, &gDntStageDanceAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->isSolid = true; - this->timer3 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; - this->rotDirection = -1; - if (Rand_ZeroFloat(1.99f) < 1.0f) { - this->rotDirection = 1; - } - this->actionFunc = EnDntNomal_StageDance; -} - -void EnDntNomal_StageDance(EnDntNomal* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer2 == 0) { - if (this->action == DNT_ACTION_DANCE) { - this->action = DNT_ACTION_HIGH_RUPEES; - this->actionFunc = EnDntNomal_SetupStageHide; - } else { - this->action = DNT_ACTION_NONE; - this->actionFunc = EnDntNomal_StageSetupReturn; - } - } else if (this->timer3 != 0) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - if (this->timer3 == 1) { - this->timer4 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; - this->rotDirection = -this->rotDirection; - } - } else if (this->timer4 != 0) { - this->actor.shape.rot.y += this->rotDirection * 0x800; - if (this->timer4 == 1) { - this->timer3 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; - } - } -} - -void EnDntNomal_SetupStageHide(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->timer3 != 0) { - if ((this->timer3 == 1) && (this->ignore == 1)) { - func_80078884(NA_SE_SY_ERROR); - } - } else { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageHideAnim); - Animation_Change(&this->skelAnime, &gDntStageHideAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->isSolid = false; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); - this->actionFunc = EnDntNomal_StageHide; - } -} - -void EnDntNomal_StageHide(EnDntNomal* this, GlobalContext* globalCtx) { - EnExRuppy* rupee; - f32 frame = this->skelAnime.curFrame; - s16 rupeeColor; - - SkelAnime_Update(&this->skelAnime); - if (frame >= this->endFrame) { - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - switch (this->action) { - case DNT_ACTION_NONE: - this->actionFunc = EnDntNomal_SetupStageWait; - break; - case DNT_ACTION_ATTACK: - this->actionFunc = EnDntNomal_StageAttackHide; - break; - case DNT_ACTION_LOW_RUPEES: - case DNT_ACTION_HIGH_RUPEES: - rupee = - (EnExRuppy*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EX_RUPPY, this->actor.world.pos.x, - this->actor.world.pos.y + 20.0f, this->actor.world.pos.z, 0, 0, 0, 3); - if (rupee != NULL) { - rupeeColor = this->action - DNT_ACTION_LOW_RUPEES; - rupee->colorIdx = rupeeColor; - if (Rand_ZeroFloat(3.99f) < 1.0f) { - rupee->colorIdx = rupeeColor + 1; - } - rupee->actor.velocity.y = 5.0f; - if (rupee->colorIdx == 2) { - rupee->actor.velocity.y = 7.0f; - } - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - this->action = DNT_ACTION_NONE; - this->actionFunc = EnDntNomal_SetupStageWait; - break; - } - } -} - -void EnDntNomal_StageAttackHide(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer > 70.0f) { - this->actionFunc = EnDntNomal_SetupStageUp; - } -} - -void EnDntNomal_SetupStageAttack(EnDntNomal* this, GlobalContext* globalCtx) { - if (this->timer3 == 0) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageSpitAnim); - Animation_Change(&this->skelAnime, &gDntStageSpitAnim, 1.0f, 0.0f, this->endFrame, ANIMMODE_ONCE, -10.0f); - this->actor.colChkInfo.mass = 0xFF; - this->isSolid = true; - this->timer2 = 0; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - this->actionFunc = EnDntNomal_StageAttack; - } -} - -void EnDntNomal_StageAttack(EnDntNomal* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Actor* nut; - f32 frame = this->skelAnime.curFrame; - f32 dz; - f32 dx; - f32 dy; - - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); - dx = player->actor.world.pos.x - this->mouthPos.x; - dy = player->actor.world.pos.y + 30.0f - this->mouthPos.y; - dz = player->actor.world.pos.z - this->mouthPos.z; - Math_SmoothStepToS(&this->actor.shape.rot.x, -(s16)(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))) * (0x8000 / M_PI)), 3, - 0x1388, 0); - if ((frame >= this->endFrame) && (this->timer2 == 0)) { - this->timer2 = (s16)Rand_ZeroFloat(10.0f) + 10; - } - if (this->timer2 == 1) { - this->spawnedItem = false; - this->actionFunc = EnDntNomal_SetupStageAttack; - } else if (this->actor.xzDistToPlayer < 50.0f) { - this->action = DNT_ACTION_ATTACK; - this->actionFunc = EnDntNomal_SetupStageHide; - } else if ((frame >= 8.0f) && (!this->spawnedItem)) { - Vec3f baseOffset; - Vec3f spawnOffset; - f32 spawnX; - f32 spawnY; - f32 spawnZ; - - Matrix_RotateY(this->actor.shape.rot.y / (f32)0x8000 * M_PI, MTXMODE_NEW); - Matrix_RotateX(this->actor.shape.rot.x / (f32)0x8000 * M_PI, MTXMODE_APPLY); - baseOffset.x = 0.0f; - baseOffset.y = 0.0f; - baseOffset.z = 5.0f; - Matrix_MultVec3f(&baseOffset, &spawnOffset); - spawnX = this->mouthPos.x + spawnOffset.x; - spawnY = this->mouthPos.y + spawnOffset.y; - spawnZ = this->mouthPos.z + spawnOffset.z; - - nut = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, spawnX, spawnY, spawnZ, - this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 4); - if (nut != NULL) { - nut->velocity.y = spawnOffset.y * 0.5f; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); - this->spawnedItem = true; - } -} - -void EnDntNomal_StageSetupReturn(EnDntNomal* this, GlobalContext* globalCtx) { - this->endFrame = (f32)Animation_GetLastFrame(&gDntStageWalkAnim); - Animation_Change(&this->skelAnime, &gDntStageWalkAnim, 1.5f, 0.0f, this->endFrame, ANIMMODE_LOOP, -10.0f); - this->actor.speedXZ = 4.0f; - this->isSolid = false; - this->actionFunc = EnDntNomal_StageReturn; -} - -void EnDntNomal_StageReturn(EnDntNomal* this, GlobalContext* globalCtx) { - f32 sp2C; - f32 sp28; - - SkelAnime_Update(&this->skelAnime); - sp2C = this->flowerPos.x - this->actor.world.pos.x; - sp28 = this->flowerPos.z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(sp2C, sp28) * (0x8000 / M_PI), 1, 0xBB8, 0); - if (this->timer5 == 0) { - this->timer5 = 10; - } else if (!(this->timer5 & 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if ((fabsf(sp2C) < 7.0f) && (fabsf(sp28) < 7.0f)) { - this->actor.world.pos.x = this->flowerPos.x; - this->actor.world.pos.z = this->flowerPos.z; - this->actor.speedXZ = 0.0f; - this->actionFunc = EnDntNomal_SetupStageHide; - } -} - -void EnDntNomal_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDntNomal* this = (EnDntNomal*)thisx; - - if (this->timer1 != 0) { - this->timer1--; - } - if (this->timer2 != 0) { - this->timer2--; - } - if (this->timer3 != 0) { - this->timer3--; - } - if (this->timer4 != 0) { - this->timer4--; - } - if (this->timer5 != 0) { - this->timer5--; - } - if (this->blinkTimer != 0) { - this->blinkTimer--; - } - this->actor.world.rot.x = this->actor.shape.rot.x; - if (this->actionFunc != EnDntNomal_StageCelebrate) { - this->actor.world.rot.y = this->actor.shape.rot.y; - } - this->unkCounter++; - if (this->type != ENDNTNOMAL_TARGET) { - switch (this->stageSignal) { - case DNT_SIGNAL_LOOK: - if (this->stagePrize == DNT_PRIZE_NONE) { - this->actionFunc = EnDntNomal_SetupStageUp; - } else { - this->actionFunc = EnDntNomal_StageUp; - } - break; - case DNT_SIGNAL_CELEBRATE: - this->action = DNT_ACTION_NONE; - this->actor.colChkInfo.mass = 0; - this->timer3 = (s16)Rand_ZeroFloat(3.0f) + (s16)(this->type * 0.5f); - this->actionFunc = EnDntNomal_SetupStageUnburrow; - break; - case DNT_SIGNAL_DANCE: - this->action = DNT_ACTION_DANCE; - this->actionFunc = EnDntNomal_SetupStageUnburrow; - break; - case DNT_SIGNAL_HIDE: - this->actionFunc = EnDntNomal_SetupStageHide; - break; - case DNT_SIGNAL_RETURN: - this->actionFunc = EnDntNomal_StageSetupReturn; - break; - case DNT_SIGNAL_UNUSED: - this->actionFunc = EnDntNomal_SetupStageDance; - break; - case DNT_SIGNAL_NONE: - break; - } - } - if (this->stageSignal != DNT_SIGNAL_NONE) { - this->stageSignal = DNT_SIGNAL_NONE; - } - if (this->blinkTimer == 0) { - this->eyeState++; - if (this->eyeState >= 3) { - this->eyeState = 0; - this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - } - } - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - if (this->type == ENDNTNOMAL_TARGET) { - Collider_SetQuadVertices(&this->targetQuad, &this->targetVtx[0], &this->targetVtx[1], &this->targetVtx[2], - &this->targetVtx[3]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->targetQuad.base); - } else { - Collider_UpdateCylinder(&this->actor, &this->bodyCyl); - if (this->isSolid) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCyl.base); - } - } -} - -s32 EnDntNomal_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnDntNomal* this = (EnDntNomal*)thisx; - - if ((limbIndex == 1) || (limbIndex == 3) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1733); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, sLeafColors[this->type - ENDNTNOMAL_STAGE].r, - sLeafColors[this->type - ENDNTNOMAL_STAGE].g, sLeafColors[this->type - ENDNTNOMAL_STAGE].b, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1743); - } - return false; -} - -void EnDntNomal_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnDntNomal* this = (EnDntNomal*)thisx; - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - - if (this->type == ENDNTNOMAL_TARGET) { - if (limbIndex == 5) { - Matrix_MultVec3f(&zeroVec, &this->mouthPos); - } - } else if (limbIndex == 7) { - Matrix_MultVec3f(&zeroVec, &this->mouthPos); - } -} - -void EnDntNomal_DrawStageScrub(Actor* thisx, GlobalContext* globalCtx) { - static void* blinkTex[] = { gDntStageEyeOpenTex, gDntStageEyeHalfTex, gDntStageEyeShutTex }; - EnDntNomal* this = (EnDntNomal*)thisx; - Vec3f dustScale = { 0.25f, 0.25f, 0.25f }; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1790); - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(blinkTex[this->eyeState])); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDntNomal_OverrideLimbDraw, - EnDntNomal_PostLimbDraw, this); - Matrix_Translate(this->flowerPos.x, this->flowerPos.y, this->flowerPos.z, MTXMODE_NEW); - Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, sLeafColors[this->type - ENDNTNOMAL_STAGE].r, - sLeafColors[this->type - ENDNTNOMAL_STAGE].g, sLeafColors[this->type - ENDNTNOMAL_STAGE].b, 255); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1814), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDntStageFlowerDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1817); - if (this->actionFunc == EnDntNomal_StageCelebrate) { - func_80033C30(&this->actor.world.pos, &dustScale, 255, globalCtx); - } -} - -void EnDntNomal_DrawTargetScrub(Actor* thisx, GlobalContext* globalCtx) { - EnDntNomal* this = (EnDntNomal*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1833); - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnDntNomal_PostLimbDraw, - this); - Matrix_Translate(this->flowerPos.x, this->flowerPos.y, this->flowerPos.z, MTXMODE_NEW); - Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1848), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gHintNutsFlowerDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1851); -} diff --git a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.cpp b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.cpp new file mode 100644 index 000000000..79b3ec48b --- /dev/null +++ b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.cpp @@ -0,0 +1,903 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DNT_NOMAL_Z_EN_DNT_NOMAL_C +#include "actor_common.h" +/* + * File: z_en_dnt_nomal + * Overlay: ovl_En_Dnt_Nomal + * Description: Lost Woods minigame scrubs + */ + +#include "z_en_dnt_nomal.h" +#include "objects/object_dnk/object_dnk.h" +#include "overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.h" +#include "overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.h" +#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_hintnuts/object_hintnuts.h" +#include "vt.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnDntNomal_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDntNomal_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDntNomal_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDntNomal_DrawTargetScrub(Actor* thisx, GlobalContext* globalCtx); +void EnDntNomal_DrawStageScrub(Actor* thisx, GlobalContext* globalCtx); + +void EnDntNomal_WaitForObject(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetFlower(EnDntNomal* pthis, GlobalContext* globalCtx); + +void EnDntNomal_SetupTargetWait(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupTargetUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupTargetWalk(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupTargetTalk(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupTargetGivePrize(EnDntNomal* pthis, GlobalContext* globalCtx); + +void EnDntNomal_TargetWait(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetWalk(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetFacePlayer(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetTalk(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetGivePrize(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetReturn(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_TargetBurrow(EnDntNomal* pthis, GlobalContext* globalCtx); + +void EnDntNomal_SetupStageWait(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupStageCelebrate(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupStageDance(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupStageHide(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_SetupStageAttack(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageSetupReturn(EnDntNomal* pthis, GlobalContext* globalCtx); + +void EnDntNomal_StageWait(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageUp(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageCelebrate(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageDance(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageHide(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageAttackHide(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageAttack(EnDntNomal* pthis, GlobalContext* globalCtx); +void EnDntNomal_StageReturn(EnDntNomal* pthis, GlobalContext* globalCtx); + +ActorInit En_Dnt_Nomal_InitVars = { + ACTOR_EN_DNT_NOMAL, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnDntNomal), + (ActorFunc)EnDntNomal_Init, + (ActorFunc)EnDntNomal_Destroy, + (ActorFunc)EnDntNomal_Update, + NULL, +}; + +static ColliderCylinderInit sBodyCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 16, 46, 0, { 0, 0, 0 } }, +}; + +static ColliderQuadInit sTargetQuadInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static Color_RGBA8 sLeafColors[] = { + { 255, 255, 255, 255 }, { 255, 195, 175, 255 }, { 210, 255, 0, 255 }, + { 255, 255, 255, 255 }, { 210, 255, 0, 255 }, { 255, 195, 175, 255 }, + { 255, 255, 255, 255 }, { 255, 195, 175, 255 }, { 210, 255, 0, 255 }, +}; + +void EnDntNomal_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDntNomal* pthis = (EnDntNomal*)thisx; + + pthis->type = pthis->actor.params; + if (pthis->type < ENDNTNOMAL_TARGET) { + pthis->type = ENDNTNOMAL_TARGET; + } + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.colChkInfo.mass = 0xFF; + pthis->objId = -1; + if (pthis->type == ENDNTNOMAL_TARGET) { + osSyncPrintf("\n\n"); + // "Deku Scrub target" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デグナッツ的当て ☆☆☆☆☆ \n" VT_RST); + Collider_InitQuad(globalCtx, &pthis->targetQuad); + Collider_SetQuad(globalCtx, &pthis->targetQuad, &pthis->actor, &sTargetQuadInit); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->objId = OBJECT_HINTNUTS; + } else { + osSyncPrintf("\n\n"); + // "Deku Scrub mask show audience" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デグナッツお面品評会一般人 ☆☆☆☆☆ \n" VT_RST); + Collider_InitCylinder(globalCtx, &pthis->bodyCyl); + Collider_SetCylinder(globalCtx, &pthis->bodyCyl, &pthis->actor, &sBodyCylinderInit); + pthis->objId = OBJECT_DNK; + } + if (pthis->objId >= 0) { + pthis->objIndex = Object_GetIndex(&globalCtx->objectCtx, pthis->objId); + if (pthis->objIndex < 0) { + Actor_Kill(&pthis->actor); + // "What?" + osSyncPrintf(VT_FGCOL(PURPLE) " なにみの? %d\n" VT_RST "\n", pthis->objIndex); + // "Bank is funny" + osSyncPrintf(VT_FGCOL(CYAN) " バンクおかしいしぞ!%d\n" VT_RST "\n", pthis->actor.params); + return; + } + } else { + Actor_Kill(&pthis->actor); + } + pthis->actionFunc = EnDntNomal_WaitForObject; +} + +void EnDntNomal_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDntNomal* pthis = (EnDntNomal*)thisx; + + if (pthis->type == ENDNTNOMAL_TARGET) { + Collider_DestroyQuad(globalCtx, &pthis->targetQuad); + } else { + Collider_DestroyCylinder(globalCtx, &pthis->bodyCyl); + } +} + +void EnDntNomal_WaitForObject(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objIndex)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[pthis->objIndex].vromStart.get()); + pthis->actor.objBankIndex = pthis->objIndex; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + pthis->actor.gravity = -2.0f; + Actor_SetScale(&pthis->actor, 0.01f); + if (pthis->type == ENDNTNOMAL_TARGET) { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gHintNutsSkel, &gHintNutsBurrowAnim, pthis->jointTable, + pthis->morphTable, 10); + pthis->actor.draw = EnDntNomal_DrawTargetScrub; + } else { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDntStageSkel, &gDntStageHideAnim, pthis->jointTable, + pthis->morphTable, 11); + pthis->actor.draw = EnDntNomal_DrawStageScrub; + } + pthis->actionFunc = EnDntNomal_SetFlower; + } +} + +void EnDntNomal_SetFlower(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->flowerPos = pthis->actor.world.pos; + if (pthis->type == ENDNTNOMAL_TARGET) { + pthis->actionFunc = EnDntNomal_SetupTargetWait; + } else { + pthis->actionFunc = EnDntNomal_SetupStageWait; + } + } +} + +void EnDntNomal_SetupTargetWait(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsBurrowAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsBurrowAnim, 0.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->skelAnime.curFrame = 8.0f; + pthis->actionFunc = EnDntNomal_TargetWait; +} + +void EnDntNomal_TargetWait(EnDntNomal* pthis, GlobalContext* globalCtx) { + Vec3f scorePos; + f32 targetX = 1340.0f; + f32 targetY = 50.0f; + f32 targetZ = -30.0f; + f32 dx; + f32 dy; + f32 dz; + Vec3f scoreAccel = { 0.0f, 0.0f, 0.0f }; + Vec3f scoreVel = { 0.0f, 0.0f, 0.0f }; + + pthis->targetVtx[0].x = pthis->targetVtx[1].x = pthis->targetVtx[2].x = pthis->targetVtx[3].x = targetX; + + pthis->targetVtx[1].y = pthis->targetVtx[0].y = targetY - 24.0f; + + pthis->targetVtx[2].z = pthis->targetVtx[0].z = targetZ + 24.0f; + + pthis->targetVtx[3].z = pthis->targetVtx[1].z = targetZ - 24.0f; + + pthis->targetVtx[3].y = pthis->targetVtx[2].y = targetY + 24.0f; + + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->targetQuad.base.acFlags & AC_HIT) || BREG(0)) { + pthis->targetQuad.base.acFlags &= ~AC_HIT; + + dx = fabsf(targetX - pthis->targetQuad.info.bumper.hitPos.x); + dy = fabsf(targetY - pthis->targetQuad.info.bumper.hitPos.y); + dz = fabsf(targetZ - pthis->targetQuad.info.bumper.hitPos.z); + + scoreVel.y = 5.0f; + + if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 8.0f) { + scorePos.x = pthis->actor.world.pos.x - 20.0f; + scorePos.y = pthis->actor.world.pos.y + 20.0f; + scorePos.z = pthis->actor.world.pos.z; + EffectSsExtra_Spawn(globalCtx, &scorePos, &scoreVel, &scoreAccel, 4, 2); + Audio_StopSfxById(NA_SE_SY_TRE_BOX_APPEAR); + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + // "Big hit" + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 大当り ☆☆☆☆☆ %d\n" VT_RST, pthis->hitCounter); + if (!LINK_IS_ADULT && !(gSaveContext.itemGetInf[1] & 0x2000)) { + pthis->hitCounter++; + if (pthis->hitCounter >= 3) { + OnePointCutscene_Init(globalCtx, 4140, -99, &pthis->actor, MAIN_CAM); + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->timer4 = 50; + pthis->actionFunc = EnDntNomal_SetupTargetUnburrow; + } + } + } else if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 24.0f) { + scorePos.x = pthis->actor.world.pos.x; + scorePos.y = pthis->actor.world.pos.y + 20.0f; + scorePos.z = pthis->actor.world.pos.z; + EffectSsExtra_Spawn(globalCtx, &scorePos, &scoreVel, &scoreAccel, 4, 0); + pthis->hitCounter = 0; + } + } +} + +void EnDntNomal_SetupTargetUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx) { + Vec3f spawnPos; + + if (pthis->timer4 == 0) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsUnburrowAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsUnburrowAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + spawnPos = pthis->actor.world.pos; + spawnPos.y = pthis->actor.world.pos.y + 50.0f; + EffectSsHahen_SpawnBurst(globalCtx, &spawnPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + pthis->actionFunc = EnDntNomal_TargetUnburrow; + } +} + +void EnDntNomal_TargetUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (frame >= pthis->endFrame) { + pthis->actionFunc = EnDntNomal_SetupTargetWalk; + } +} + +void EnDntNomal_SetupTargetWalk(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsRunAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsRunAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.speedXZ = 1.0f; + pthis->actor.colChkInfo.mass = 0; + pthis->actionFunc = EnDntNomal_TargetWalk; +} + +void EnDntNomal_TargetWalk(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dz; + + SkelAnime_Update(&pthis->skelAnime); + dx = 1340.0f + 3.0f - pthis->actor.world.pos.x; + dz = 0.0f - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 0x32, 0xBB8, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if (pthis->actor.world.pos.z > -30.0f) { + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnDntNomal_TargetFacePlayer; + } +} + +void EnDntNomal_TargetFacePlayer(EnDntNomal* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if (fabsf(pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer) < 30.0f) { + pthis->actionFunc = EnDntNomal_SetupTargetTalk; + } +} + +void EnDntNomal_SetupTargetTalk(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsTalkAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsTalkAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.textId = 0x10AF; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->actionFunc = EnDntNomal_TargetTalk; +} + +void EnDntNomal_TargetTalk(EnDntNomal* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + GET_ACTIVE_CAM(globalCtx)->csId = 0; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = EnDntNomal_SetupTargetGivePrize; + } +} + +void EnDntNomal_SetupTargetGivePrize(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsSpitAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsSpitAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = EnDntNomal_TargetGivePrize; +} + +void EnDntNomal_TargetGivePrize(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if ((frame >= 8.0f) && !pthis->spawnedItem) { + f32 itemX = pthis->mouthPos.x - 10.0f; + f32 itemY = pthis->mouthPos.y; + f32 itemZ = pthis->mouthPos.z; + + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_ITEM, itemX, itemY, itemZ, 0, + 0, 0, EXITEM_BULLET_BAG) == NULL) { + func_8002DF54(globalCtx, NULL, 7); + Actor_Kill(&pthis->actor); + } + pthis->spawnedItem = true; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_THROW); + } + if (frame >= pthis->endFrame) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsRunAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsRunAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = EnDntNomal_TargetReturn; + } +} + +void EnDntNomal_TargetReturn(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dz; + + SkelAnime_Update(&pthis->skelAnime); + dx = pthis->flowerPos.x - pthis->actor.world.pos.x; + dz = -180.0f - pthis->actor.world.pos.z; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 3, 0x1388, 0); + if (fabsf(pthis->actor.shape.rot.y - (s16)(Math_FAtan2F(dx, dz) * (0x8000 / M_PI))) < 20.0f) { + pthis->actor.speedXZ = 1.0f; + } + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->actor.world.pos.z < -172.0f) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gHintNutsBurrowAnim); + Animation_Change(&pthis->skelAnime, &gHintNutsBurrowAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->actor.world.pos.z = -173.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnDntNomal_TargetBurrow; + } +} + +void EnDntNomal_TargetBurrow(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (frame >= pthis->endFrame) { + pthis->actionFunc = EnDntNomal_SetupTargetWait; + } +} + +void EnDntNomal_SetupStageWait(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->timer3 == 0) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageHideAnim); + Animation_Change(&pthis->skelAnime, &gDntStageHideAnim, 0.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->skelAnime.curFrame = 8.0f; + pthis->isSolid = false; + pthis->actionFunc = EnDntNomal_StageWait; + } +} + +void EnDntNomal_StageWait(EnDntNomal* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); +} + +void EnDntNomal_SetupStageUp(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->timer3 == 0) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageUpAnim); + Animation_Change(&pthis->skelAnime, &gDntStageUpAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + if (pthis->action != DNT_ACTION_ATTACK) { + pthis->rotDirection = -1; + } + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + pthis->isSolid = true; + pthis->actionFunc = EnDntNomal_StageUp; + } +} + +void EnDntNomal_StageUp(EnDntNomal* pthis, GlobalContext* globalCtx) { + s16 rotTarget; + f32 frame = pthis->skelAnime.curFrame; + f32 turnMod; + + SkelAnime_Update(&pthis->skelAnime); + if ((frame >= pthis->endFrame) && (pthis->action == DNT_ACTION_ATTACK)) { + pthis->actionFunc = EnDntNomal_SetupStageAttack; + } else { + if (pthis->timer4 == 0) { + turnMod = 0.0f; + if (pthis->stagePrize == DNT_PRIZE_NONE) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + } else { + f32 dx = pthis->targetPos.x - pthis->actor.world.pos.x; + f32 dz = pthis->targetPos.z - pthis->actor.world.pos.z; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); + turnMod = 90.0f; + } + if ((Rand_ZeroFloat(10.0f + turnMod) < 1.0f) && (pthis->action != DNT_ACTION_ATTACK)) { + pthis->timer4 = (s16)Rand_ZeroFloat(30.0f) + 30; + } + } else { + if (pthis->timer2 == 0) { + pthis->rotDirection++; + if (pthis->rotDirection > 1) { + pthis->rotDirection = -1; + } + pthis->timer2 = (s16)Rand_ZeroFloat(10.0f) + 10; + } + rotTarget = pthis->actor.yawTowardsPlayer; + if (pthis->rotDirection != 0) { + rotTarget += pthis->rotDirection * 0x1388; + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, rotTarget, 3, 0x1388, 0); + } + if (pthis->actor.xzDistToPlayer < 70.0f) { + pthis->actionFunc = EnDntNomal_SetupStageHide; + } + } +} + +void EnDntNomal_SetupStageUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->timer3 == 0) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageUnburrowAnim); + Animation_Change(&pthis->skelAnime, &gDntStageUnburrowAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->isSolid = false; + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + pthis->actionFunc = EnDntNomal_StageUnburrow; + } +} + +void EnDntNomal_StageUnburrow(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 frame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (frame >= pthis->endFrame) { + if (pthis->action != DNT_ACTION_DANCE) { + pthis->timer3 = (s16)Rand_ZeroFloat(2.0f) + (s16)(pthis->type * 0.5f); + pthis->actionFunc = EnDntNomal_SetupStageCelebrate; + } else { + pthis->timer2 = 300; + pthis->actionFunc = EnDntNomal_SetupStageDance; + } + } +} + +void EnDntNomal_SetupStageCelebrate(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageWalkAnim); + Animation_Change(&pthis->skelAnime, &gDntStageWalkAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.speedXZ = 3.0f; + pthis->isSolid = true; + pthis->actionFunc = EnDntNomal_StageCelebrate; +} + +void EnDntNomal_StageCelebrate(EnDntNomal* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->timer1 == 0) && (pthis->timer3 == 0)) { + f32 dx = pthis->targetPos.x - pthis->actor.world.pos.x; + f32 dz = pthis->targetPos.z - pthis->actor.world.pos.z; + + if ((fabsf(dx) < 10.0f) && (fabsf(dz) < 10.0f) && (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { + pthis->action = DNT_ACTION_PRIZE; + pthis->actionFunc = EnDntNomal_SetupStageDance; + pthis->actor.speedXZ = 0.0f; + return; + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } else { + if (pthis->timer1 == 1) { + pthis->timer3 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0x14, 0x1388, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + } + if (pthis->timer5 == 0) { + pthis->timer5 = 20; + if ((pthis->type & 1) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DAMAGE); + } + } else if ((pthis->timer5 & 3) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if ((pthis->actor.bgCheckFlags & 8) && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.velocity.y = 7.5f; + } +} + +void EnDntNomal_SetupStageDance(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageDanceAnim); + Animation_Change(&pthis->skelAnime, &gDntStageDanceAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->isSolid = true; + pthis->timer3 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; + pthis->rotDirection = -1; + if (Rand_ZeroFloat(1.99f) < 1.0f) { + pthis->rotDirection = 1; + } + pthis->actionFunc = EnDntNomal_StageDance; +} + +void EnDntNomal_StageDance(EnDntNomal* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer2 == 0) { + if (pthis->action == DNT_ACTION_DANCE) { + pthis->action = DNT_ACTION_HIGH_RUPEES; + pthis->actionFunc = EnDntNomal_SetupStageHide; + } else { + pthis->action = DNT_ACTION_NONE; + pthis->actionFunc = EnDntNomal_StageSetupReturn; + } + } else if (pthis->timer3 != 0) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + if (pthis->timer3 == 1) { + pthis->timer4 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; + pthis->rotDirection = -pthis->rotDirection; + } + } else if (pthis->timer4 != 0) { + pthis->actor.shape.rot.y += pthis->rotDirection * 0x800; + if (pthis->timer4 == 1) { + pthis->timer3 = (s16)Rand_ZeroFloat(20.0f) + 20.0f; + } + } +} + +void EnDntNomal_SetupStageHide(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->timer3 != 0) { + if ((pthis->timer3 == 1) && (pthis->ignore == 1)) { + func_80078884(NA_SE_SY_ERROR); + } + } else { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageHideAnim); + Animation_Change(&pthis->skelAnime, &gDntStageHideAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->isSolid = false; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DOWN); + pthis->actionFunc = EnDntNomal_StageHide; + } +} + +void EnDntNomal_StageHide(EnDntNomal* pthis, GlobalContext* globalCtx) { + EnExRuppy* rupee; + f32 frame = pthis->skelAnime.curFrame; + s16 rupeeColor; + + SkelAnime_Update(&pthis->skelAnime); + if (frame >= pthis->endFrame) { + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + switch (pthis->action) { + case DNT_ACTION_NONE: + pthis->actionFunc = EnDntNomal_SetupStageWait; + break; + case DNT_ACTION_ATTACK: + pthis->actionFunc = EnDntNomal_StageAttackHide; + break; + case DNT_ACTION_LOW_RUPEES: + case DNT_ACTION_HIGH_RUPEES: + rupee = + (EnExRuppy*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EX_RUPPY, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 20.0f, pthis->actor.world.pos.z, 0, 0, 0, 3); + if (rupee != NULL) { + rupeeColor = pthis->action - DNT_ACTION_LOW_RUPEES; + rupee->colorIdx = rupeeColor; + if (Rand_ZeroFloat(3.99f) < 1.0f) { + rupee->colorIdx = rupeeColor + 1; + } + rupee->actor.velocity.y = 5.0f; + if (rupee->colorIdx == 2) { + rupee->actor.velocity.y = 7.0f; + } + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + pthis->action = DNT_ACTION_NONE; + pthis->actionFunc = EnDntNomal_SetupStageWait; + break; + } + } +} + +void EnDntNomal_StageAttackHide(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer > 70.0f) { + pthis->actionFunc = EnDntNomal_SetupStageUp; + } +} + +void EnDntNomal_SetupStageAttack(EnDntNomal* pthis, GlobalContext* globalCtx) { + if (pthis->timer3 == 0) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageSpitAnim); + Animation_Change(&pthis->skelAnime, &gDntStageSpitAnim, 1.0f, 0.0f, pthis->endFrame, ANIMMODE_ONCE, -10.0f); + pthis->actor.colChkInfo.mass = 0xFF; + pthis->isSolid = true; + pthis->timer2 = 0; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + pthis->actionFunc = EnDntNomal_StageAttack; + } +} + +void EnDntNomal_StageAttack(EnDntNomal* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* nut; + f32 frame = pthis->skelAnime.curFrame; + f32 dz; + f32 dx; + f32 dy; + + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x1388, 0); + dx = player->actor.world.pos.x - pthis->mouthPos.x; + dy = player->actor.world.pos.y + 30.0f - pthis->mouthPos.y; + dz = player->actor.world.pos.z - pthis->mouthPos.z; + Math_SmoothStepToS(&pthis->actor.shape.rot.x, -(s16)(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))) * (0x8000 / M_PI)), 3, + 0x1388, 0); + if ((frame >= pthis->endFrame) && (pthis->timer2 == 0)) { + pthis->timer2 = (s16)Rand_ZeroFloat(10.0f) + 10; + } + if (pthis->timer2 == 1) { + pthis->spawnedItem = false; + pthis->actionFunc = EnDntNomal_SetupStageAttack; + } else if (pthis->actor.xzDistToPlayer < 50.0f) { + pthis->action = DNT_ACTION_ATTACK; + pthis->actionFunc = EnDntNomal_SetupStageHide; + } else if ((frame >= 8.0f) && (!pthis->spawnedItem)) { + Vec3f baseOffset; + Vec3f spawnOffset; + f32 spawnX; + f32 spawnY; + f32 spawnZ; + + Matrix_RotateY(pthis->actor.shape.rot.y / (f32)0x8000 * M_PI, MTXMODE_NEW); + Matrix_RotateX(pthis->actor.shape.rot.x / (f32)0x8000 * M_PI, MTXMODE_APPLY); + baseOffset.x = 0.0f; + baseOffset.y = 0.0f; + baseOffset.z = 5.0f; + Matrix_MultVec3f(&baseOffset, &spawnOffset); + spawnX = pthis->mouthPos.x + spawnOffset.x; + spawnY = pthis->mouthPos.y + spawnOffset.y; + spawnZ = pthis->mouthPos.z + spawnOffset.z; + + nut = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, spawnX, spawnY, spawnZ, + pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 4); + if (nut != NULL) { + nut->velocity.y = spawnOffset.y * 0.5f; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_THROW); + pthis->spawnedItem = true; + } +} + +void EnDntNomal_StageSetupReturn(EnDntNomal* pthis, GlobalContext* globalCtx) { + pthis->endFrame = (f32)Animation_GetLastFrame(&gDntStageWalkAnim); + Animation_Change(&pthis->skelAnime, &gDntStageWalkAnim, 1.5f, 0.0f, pthis->endFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.speedXZ = 4.0f; + pthis->isSolid = false; + pthis->actionFunc = EnDntNomal_StageReturn; +} + +void EnDntNomal_StageReturn(EnDntNomal* pthis, GlobalContext* globalCtx) { + f32 sp2C; + f32 sp28; + + SkelAnime_Update(&pthis->skelAnime); + sp2C = pthis->flowerPos.x - pthis->actor.world.pos.x; + sp28 = pthis->flowerPos.z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(sp2C, sp28) * (0x8000 / M_PI), 1, 0xBB8, 0); + if (pthis->timer5 == 0) { + pthis->timer5 = 10; + } else if (!(pthis->timer5 & 1)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if ((fabsf(sp2C) < 7.0f) && (fabsf(sp28) < 7.0f)) { + pthis->actor.world.pos.x = pthis->flowerPos.x; + pthis->actor.world.pos.z = pthis->flowerPos.z; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnDntNomal_SetupStageHide; + } +} + +void EnDntNomal_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDntNomal* pthis = (EnDntNomal*)thisx; + + if (pthis->timer1 != 0) { + pthis->timer1--; + } + if (pthis->timer2 != 0) { + pthis->timer2--; + } + if (pthis->timer3 != 0) { + pthis->timer3--; + } + if (pthis->timer4 != 0) { + pthis->timer4--; + } + if (pthis->timer5 != 0) { + pthis->timer5--; + } + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + } + pthis->actor.world.rot.x = pthis->actor.shape.rot.x; + if (pthis->actionFunc != EnDntNomal_StageCelebrate) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } + pthis->unkCounter++; + if (pthis->type != ENDNTNOMAL_TARGET) { + switch (pthis->stageSignal) { + case DNT_SIGNAL_LOOK: + if (pthis->stagePrize == DNT_PRIZE_NONE) { + pthis->actionFunc = EnDntNomal_SetupStageUp; + } else { + pthis->actionFunc = EnDntNomal_StageUp; + } + break; + case DNT_SIGNAL_CELEBRATE: + pthis->action = DNT_ACTION_NONE; + pthis->actor.colChkInfo.mass = 0; + pthis->timer3 = (s16)Rand_ZeroFloat(3.0f) + (s16)(pthis->type * 0.5f); + pthis->actionFunc = EnDntNomal_SetupStageUnburrow; + break; + case DNT_SIGNAL_DANCE: + pthis->action = DNT_ACTION_DANCE; + pthis->actionFunc = EnDntNomal_SetupStageUnburrow; + break; + case DNT_SIGNAL_HIDE: + pthis->actionFunc = EnDntNomal_SetupStageHide; + break; + case DNT_SIGNAL_RETURN: + pthis->actionFunc = EnDntNomal_StageSetupReturn; + break; + case DNT_SIGNAL_UNUSED: + pthis->actionFunc = EnDntNomal_SetupStageDance; + break; + case DNT_SIGNAL_NONE: + break; + } + } + if (pthis->stageSignal != DNT_SIGNAL_NONE) { + pthis->stageSignal = DNT_SIGNAL_NONE; + } + if (pthis->blinkTimer == 0) { + pthis->eyeState++; + if (pthis->eyeState >= 3) { + pthis->eyeState = 0; + pthis->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 0x1D); + if (pthis->type == ENDNTNOMAL_TARGET) { + Collider_SetQuadVertices(&pthis->targetQuad, &pthis->targetVtx[0], &pthis->targetVtx[1], &pthis->targetVtx[2], + &pthis->targetVtx[3]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->targetQuad.base); + } else { + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCyl); + if (pthis->isSolid) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCyl.base); + } + } +} + +s32 EnDntNomal_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnDntNomal* pthis = (EnDntNomal*)thisx; + + if ((limbIndex == 1) || (limbIndex == 3) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1733); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, sLeafColors[pthis->type - ENDNTNOMAL_STAGE].r, + sLeafColors[pthis->type - ENDNTNOMAL_STAGE].g, sLeafColors[pthis->type - ENDNTNOMAL_STAGE].b, 255); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1743); + } + return false; +} + +void EnDntNomal_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnDntNomal* pthis = (EnDntNomal*)thisx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (pthis->type == ENDNTNOMAL_TARGET) { + if (limbIndex == 5) { + Matrix_MultVec3f(&zeroVec, &pthis->mouthPos); + } + } else if (limbIndex == 7) { + Matrix_MultVec3f(&zeroVec, &pthis->mouthPos); + } +} + +void EnDntNomal_DrawStageScrub(Actor* thisx, GlobalContext* globalCtx) { + static void* blinkTex[] = { gDntStageEyeOpenTex, gDntStageEyeHalfTex, gDntStageEyeShutTex }; + EnDntNomal* pthis = (EnDntNomal*)thisx; + Vec3f dustScale = { 0.25f, 0.25f, 0.25f }; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1790); + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(blinkTex[pthis->eyeState])); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnDntNomal_OverrideLimbDraw, + EnDntNomal_PostLimbDraw, pthis); + Matrix_Translate(pthis->flowerPos.x, pthis->flowerPos.y, pthis->flowerPos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, sLeafColors[pthis->type - ENDNTNOMAL_STAGE].r, + sLeafColors[pthis->type - ENDNTNOMAL_STAGE].g, sLeafColors[pthis->type - ENDNTNOMAL_STAGE].b, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1814), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDntStageFlowerDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1817); + if (pthis->actionFunc == EnDntNomal_StageCelebrate) { + func_80033C30(&pthis->actor.world.pos, &dustScale, 255, globalCtx); + } +} + +void EnDntNomal_DrawTargetScrub(Actor* thisx, GlobalContext* globalCtx) { + EnDntNomal* pthis = (EnDntNomal*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1833); + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, EnDntNomal_PostLimbDraw, + pthis); + Matrix_Translate(pthis->flowerPos.x, pthis->flowerPos.y, pthis->flowerPos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1848), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHintNutsFlowerDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dnt_nomal.c", 1851); +} diff --git a/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c b/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c deleted file mode 100644 index f7b96722f..000000000 --- a/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c +++ /dev/null @@ -1,663 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DODOJR_Z_EN_DODOJR_C -#include "actor_common.h" -/* - * File: z_en_dodojr.c - * Overlay: ovl_En_Dodojr - * Description: Baby Dodongo - */ - -#include "z_en_dodojr.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "objects/object_dodojr/object_dodojr.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnDodojr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDodojr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDodojr_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDodojr_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_809F73AC(EnDodojr* this, GlobalContext* globalCtx); -void func_809F7BE4(EnDodojr* this, GlobalContext* globalCtx); -void func_809F74C4(EnDodojr* this, GlobalContext* globalCtx); -void func_809F758C(EnDodojr* this, GlobalContext* globalCtx); -void func_809F786C(EnDodojr* this, GlobalContext* globalCtx); -void func_809F799C(EnDodojr* this, GlobalContext* globalCtx); -void func_809F78EC(EnDodojr* this, GlobalContext* globalCtx); -void func_809F773C(EnDodojr* this, GlobalContext* globalCtx); -void func_809F77AC(EnDodojr* this, GlobalContext* globalCtx); -void func_809F784C(EnDodojr* this, GlobalContext* globalCtx); -void func_809F7AB8(EnDodojr* this, GlobalContext* globalCtx); -void func_809F7A00(EnDodojr* this, GlobalContext* globalCtx); -void func_809F7B3C(EnDodojr* this, GlobalContext* globalCtx); -void func_809F7C48(EnDodojr* this, GlobalContext* globalCtx); -void func_809F768C(EnDodojr* this, GlobalContext* globalCtx); - -const ActorInit En_Dodojr_InitVars = { - ACTOR_EN_DODOJR, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DODOJR, - sizeof(EnDodojr), - (ActorFunc)EnDodojr_Init, - (ActorFunc)EnDodojr_Destroy, - (ActorFunc)EnDodojr_Update, - (ActorFunc)EnDodojr_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFC5FFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 18, 20, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInit = { 1, 2, 25, 25, 0xFF }; - -void EnDodojr_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDodojr* this = (EnDodojr*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dodojr_Skel_0020E0, &object_dodojr_Anim_0009D4, - this->jointTable, this->morphTable, 15); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(4), &sColChkInit); - - this->actor.naviEnemyId = 0xE; - this->actor.flags &= ~ACTOR_FLAG_0; - - Actor_SetScale(&this->actor, 0.02f); - - this->actionFunc = func_809F73AC; -} - -void EnDodojr_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDodojr* this = (EnDodojr*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_809F64D0(EnDodojr* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, 8); -} - -void func_809F6510(EnDodojr* this, GlobalContext* globalCtx, s32 count) { - Color_RGBA8 prim = { 170, 130, 90, 255 }; - Color_RGBA8 env = { 100, 60, 20, 0 }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.3f, 0.0f }; - Vec3f pos; - s16 angle = ((Rand_ZeroOne() - 0.5f) * 65536.0f); - s32 i; - - pos.y = this->dustPos.y; - - for (i = count; i >= 0; i--, angle += (s16)(0x10000 / count)) { - accel.x = (Rand_ZeroOne() - 0.5f) * 4.0f; - accel.z = (Rand_ZeroOne() - 0.5f) * 4.0f; - - pos.x = (Math_SinS(angle) * 22.0f) + this->dustPos.x; - pos.z = (Math_CosS(angle) * 22.0f) + this->dustPos.z; - - func_8002836C(globalCtx, &pos, &velocity, &accel, &prim, &env, 120, 40, 10); - } -} - -void func_809F6730(EnDodojr* this, GlobalContext* globalCtx, Vec3f* arg2) { - Color_RGBA8 prim = { 170, 130, 90, 255 }; - Color_RGBA8 env = { 100, 60, 20, 0 }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.3f, 0.0f }; - Vec3f pos; - s16 angle = ((Rand_ZeroOne() - 0.5f) * 65536.0f); - - pos.y = this->actor.floorHeight; - - accel.x = (Rand_ZeroOne() - 0.5f) * 2; - accel.z = (Rand_ZeroOne() - 0.5f) * 2; - - pos.x = (Math_SinS(angle) * 11.0f) + arg2->x; - pos.z = (Math_CosS(angle) * 11.0f) + arg2->z; - - func_8002836C(globalCtx, &pos, &velocity, &accel, &prim, &env, 100, 60, 8); -} - -s32 func_809F68B0(EnDodojr* this, GlobalContext* globalCtx) { - if (this->actor.velocity.y >= 0.0f) { - return 0; - } - - if (this->unk_1FC == 0) { - return 0; - } - - if (this->actor.bgCheckFlags & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - this->dustPos = this->actor.world.pos; - func_809F6510(this, globalCtx, 10); - this->actor.velocity.y = 10.0f / (4 - this->unk_1FC); - this->unk_1FC--; - - if (this->unk_1FC == 0) { - this->actor.velocity.y = 0.0f; - return 1; - } - } - - return 0; -} - -void func_809F6994(EnDodojr* this) { - f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_000860); - - Animation_Change(&this->skelAnime, &object_dodojr_Anim_000860, 1.8f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -10.0f); - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 2.6f; - this->actor.gravity = -0.8f; -} - -void func_809F6A20(EnDodojr* this) { - f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_0004A0); - - Animation_Change(&this->skelAnime, &object_dodojr_Anim_0004A0, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -10.0f); - this->actor.speedXZ = 0.0f; - this->actor.velocity.x = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.gravity = -0.8f; - - if (this->unk_1FC == 0) { - this->unk_1FC = 3; - this->actor.velocity.y = 10.0f; - } -} - -void func_809F6AC4(EnDodojr* this) { - f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_0005F0); - - Animation_Change(&this->skelAnime, &object_dodojr_Anim_0005F0, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, 0.0f); - this->actor.velocity.y = 0.0f; - this->actor.gravity = -0.8f; -} - -void func_809F6B38(EnDodojr* this) { - f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_000724); - - Animation_Change(&this->skelAnime, &object_dodojr_Anim_000724, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -10.0f); - this->actor.gravity = -0.8f; - this->unk_1FC = 3; - this->actor.velocity.y = 10.0f; -} - -void func_809F6BBC(EnDodojr* this) { - this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.home.pos = this->actor.world.pos; - this->actor.speedXZ = 0.0f; - this->actor.gravity = -0.8f; - this->timer3 = 30; - this->dustPos = this->actor.world.pos; -} - -void func_809F6C24(EnDodojr* this) { - Animation_Change(&this->skelAnime, &object_dodojr_Anim_000724, 1.0f, 8.0f, 12.0f, ANIMMODE_ONCE, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_EAT); - this->actor.speedXZ = 0.0f; - this->actor.velocity.x = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.gravity = -0.8f; -} - -s32 func_809F6CA4(EnDodojr* this, GlobalContext* globalCtx) { - Actor* bomb; - Vec3f unkVec = { 99999.0f, 99999.0f, 99999.0f }; - s32 retVar = 0; - f32 xDist; - f32 yDist; - f32 zDist; - - bomb = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; - this->bomb = NULL; - - while (bomb != NULL) { - if ((bomb->params != 0) || (bomb->parent != NULL) || (bomb->update == NULL)) { - bomb = bomb->next; - continue; - } - - if (bomb->id != ACTOR_EN_BOM) { - bomb = bomb->next; - continue; - } - - xDist = bomb->world.pos.x - this->actor.world.pos.x; - yDist = bomb->world.pos.y - this->actor.world.pos.y; - zDist = bomb->world.pos.z - this->actor.world.pos.z; - - if ((fabsf(xDist) >= fabsf(unkVec.x)) || (fabsf(yDist) >= fabsf(unkVec.y)) || - (fabsf(zDist) >= fabsf(unkVec.z))) { - bomb = bomb->next; - continue; - } - - this->bomb = bomb; - unkVec = bomb->world.pos; - retVar = 1; - bomb = bomb->next; - } - - return retVar; -} - -s32 func_809F6DD0(EnDodojr* this) { - if (this->bomb == NULL) { - return 0; - } else if (this->bomb->parent != NULL) { - return 0; - } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->bomb->world.pos) > 30.0f) { - return 0; - } else { - this->bomb->parent = &this->actor; - return 1; - } -} - -void func_809F6E54(EnDodojr* this, GlobalContext* globalCtx) { - f32 angles[] = { 0.0f, 210.0f, 60.0f, 270.0f, 120.0f, 330.0f, 180.0f, 30.0f, 240.0f, 90.0f, 300.0f, 150.0f }; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - Vec3f pos; - s16 angleIndex; - - if ((this->bomb == NULL) || (this->bomb->update == NULL) || - ((this->bomb != NULL) && (this->bomb->parent != NULL))) { - func_809F6CA4(this, globalCtx); - } - - if (this->bomb != NULL) { - pos = this->bomb->world.pos; - } else { - pos = player->actor.world.pos; - } - - if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &pos) > 80.0f) { - angleIndex = (s16)(this->actor.home.pos.x + this->actor.home.pos.y + this->actor.home.pos.z + - globalCtx->state.frames / 30) % - 12; - angleIndex = ABS(angleIndex); - pos.x += 80.0f * sinf(angles[angleIndex]); - pos.z += 80.0f * cosf(angles[angleIndex]); - } - - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &pos), 10, 1000, 1); - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -s32 func_809F706C(EnDodojr* this) { - if (this->actor.xzDistToPlayer > 40.0f) { - return 0; - } else { - return 1; - } -} - -void func_809F709C(EnDodojr* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_DEAD); - this->actor.flags &= ~ACTOR_FLAG_0; - func_809F6A20(this); - this->actionFunc = func_809F7AB8; -} - -s32 func_809F70E8(EnDodojr* this, GlobalContext* globalCtx) { - if ((this->actionFunc == func_809F773C) || (this->actionFunc == func_809F77AC) || - (this->actionFunc == func_809F784C) || (this->actionFunc == func_809F7A00) || - (this->actionFunc == func_809F7AB8) || (this->actionFunc == func_809F7B3C) || - (this->actionFunc == func_809F7BE4)) { - return 0; - } - - if (globalCtx->actorCtx.unk_02 != 0) { - if (this->actionFunc != func_809F73AC) { - if (this->actionFunc == func_809F74C4) { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - } - - func_809F709C(this); - } - return 0; - } - - if (!(this->collider.base.acFlags & 2)) { - return 0; - } else { - this->collider.base.acFlags &= ~2; - - if ((this->actionFunc == func_809F73AC) || (this->actionFunc == func_809F74C4)) { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - } - - if ((this->actor.colChkInfo.damageEffect == 0) && (this->actor.colChkInfo.damage != 0)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->timer2 = 2; - this->actionFunc = func_809F7C48; - return 1; - } - - if ((this->actor.colChkInfo.damageEffect == 1) && (this->actionFunc != func_809F78EC) && - (this->actionFunc != func_809F786C)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->timer1 = 120; - Actor_SetColorFilter(&this->actor, 0, 200, 0, 120); - func_809F6A20(this); - this->actionFunc = func_809F786C; - } - - return 0; - } -} - -void func_809F72A4(EnDodojr* this, GlobalContext* globalCtx) { - Collider_UpdateCylinder(&this->actor, &this->collider); - - if ((this->actionFunc != func_809F73AC) && (this->actionFunc != func_809F7BE4)) { - if ((this->actionFunc == func_809F74C4) || (this->actionFunc == func_809F758C) || - (this->actionFunc == func_809F799C)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if ((this->actionFunc == func_809F74C4) || (this->actionFunc == func_809F758C) || - (this->actionFunc == func_809F786C) || (this->actionFunc == func_809F78EC) || - (this->actionFunc == func_809F799C)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void func_809F73AC(EnDodojr* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_000860); - Player* player = GET_PLAYER(globalCtx); - f32 dist; - - if (!(this->actor.xzDistToPlayer >= 320.0f)) { - dist = this->actor.world.pos.y - player->actor.world.pos.y; - - if (!(dist >= 40.0f)) { - Animation_Change(&this->skelAnime, &object_dodojr_Anim_000860, 1.8f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, - -10.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_UP); - this->actor.world.pos.y -= 60.0f; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.world.rot.x -= 0x4000; - this->actor.shape.rot.x = this->actor.world.rot.x; - this->dustPos = this->actor.world.pos; - this->dustPos.y = this->actor.floorHeight; - this->actionFunc = func_809F74C4; - } - } -} - -void func_809F74C4(EnDodojr* this, GlobalContext* globalCtx) { - f32 sp2C; - - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 4, 0x3E8, 0x64); - sp2C = this->actor.shape.rot.x; - sp2C /= 16384.0f; - this->actor.world.pos.y = this->actor.home.pos.y + (60.0f * sp2C); - func_809F6510(this, globalCtx, 3); - - if (sp2C == 0.0f) { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.world.rot.x = this->actor.shape.rot.x; - this->actor.speedXZ = 2.6f; - this->actionFunc = func_809F758C; - } -} - -void func_809F758C(EnDodojr* this, GlobalContext* globalCtx) { - func_8002D868(&this->actor); - func_809F6730(this, globalCtx, &this->actor.world.pos); - - if (DECR(this->timer4) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_MOVE); - this->timer4 = 5; - } - - if (func_809F6DD0(this) != 0) { - func_809F6C24(this); - this->actionFunc = func_809F768C; - return; - } - - func_809F6E54(this, globalCtx); - - if (func_809F706C(this) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_CRY); - func_809F6B38(this); - this->actionFunc = func_809F799C; - } - - if (this->actor.bgCheckFlags & 8) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_DOWN); - func_809F6BBC(this); - this->actionFunc = func_809F7A00; - } -} - -void func_809F768C(EnDodojr* this, GlobalContext* globalCtx) { - EnBom* bomb; - - if (((s16)this->skelAnime.curFrame - 8) < 4) { - bomb = (EnBom*)this->bomb; - bomb->timer++; - this->bomb->world.pos = this->headPos; - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_K_DRINK); - Actor_Kill(this->bomb); - this->timer3 = 24; - this->unk_1FC = 0; - this->actionFunc = func_809F773C; - } -} - -void func_809F773C(EnDodojr* this, GlobalContext* globalCtx) { - if (DECR(this->timer3) == 0) { - func_809F64D0(this); - this->actor.flags &= ~ACTOR_FLAG_0; - func_809F6A20(this); - this->actionFunc = func_809F77AC; - } -} - -void func_809F77AC(EnDodojr* this, GlobalContext* globalCtx) { - this->rootScale = 1.2f; - this->rootScale *= ((f32)this->actor.colorFilterTimer / 8); - func_8002D868(&this->actor); - - if (func_809F68B0(this, globalCtx) != 0) { - this->timer3 = 60; - func_809F6AC4(this); - this->unk_1FC = 7; - this->actionFunc = func_809F784C; - } -} - -void func_809F784C(EnDodojr* this, GlobalContext* globalCtx) { - func_809F7B3C(this, globalCtx); -} - -void func_809F786C(EnDodojr* this, GlobalContext* globalCtx) { - func_8002D868(&this->actor); - - if (func_809F68B0(this, globalCtx) != 0) { - func_809F6AC4(this); - this->actionFunc = func_809F78EC; - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 4, 1000, 10); - this->actor.world.rot.x = this->actor.shape.rot.x; - this->actor.colorFilterTimer = this->timer1; -} - -void func_809F78EC(EnDodojr* this, GlobalContext* globalCtx) { - if (DECR(this->timer1) != 0) { - if (this->timer1 < 30) { - if ((this->timer1 & 1) != 0) { - this->actor.world.pos.x += 1.5f; - this->actor.world.pos.z += 1.5f; - } else { - this->actor.world.pos.x -= 1.5f; - this->actor.world.pos.z -= 1.5f; - } - - return; - } - } else { - func_809F6994(this); - this->actionFunc = func_809F758C; - } -} - -void func_809F799C(EnDodojr* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_24; - func_8002D868(&this->actor); - - if (func_809F68B0(this, globalCtx) != 0) { - func_809F6994(this); - this->actionFunc = func_809F758C; - } -} - -void func_809F7A00(EnDodojr* this, GlobalContext* globalCtx) { - f32 tmp; - - Math_SmoothStepToS(&this->actor.shape.rot.x, 0x4000, 4, 1000, 100); - - if (DECR(this->timer3) != 0) { - tmp = (30 - this->timer3) / 30.0f; - this->actor.world.pos.y = this->actor.home.pos.y - (60.0f * tmp); - } else { - Actor_Kill(&this->actor); - } - - func_809F6510(this, globalCtx, 3); -} - -void func_809F7AB8(EnDodojr* this, GlobalContext* globalCtx) { - func_8002D868(&this->actor); - Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 4, 1000, 10); - this->actor.world.rot.x = this->actor.shape.rot.x; - - if (func_809F68B0(this, globalCtx) != 0) { - this->timer3 = 60; - func_809F6AC4(this); - this->unk_1FC = 7; - this->actionFunc = func_809F7B3C; - } -} - -void func_809F7B3C(EnDodojr* this, GlobalContext* globalCtx) { - EnBom* bomb; - - if (this->unk_1FC != 0) { - if (this->actor.colorFilterTimer == 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_1FC); - this->unk_1FC--; - } - } else { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, BOMB_BODY); - - if (bomb != NULL) { - bomb->timer = 0; - } - - this->timer3 = 8; - this->actionFunc = func_809F7BE4; - } -} - -void func_809F7BE4(EnDodojr* this, GlobalContext* globalCtx) { - if (DECR(this->timer3) == 0) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x40); - Actor_Kill(&this->actor); - } -} - -void func_809F7C48(EnDodojr* this, GlobalContext* globalCtx) { - if (DECR(this->timer2) == 0) { - func_809F709C(this); - } -} - -void EnDodojr_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDodojr* this = (EnDodojr*)thisx; - - SkelAnime_Update(&this->skelAnime); - Actor_MoveForward(&this->actor); - func_809F70E8(this, globalCtx); - - if (this->actionFunc != func_809F73AC) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, this->collider.dim.radius, this->collider.dim.height, 0.0f, 5); - } - - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, 10.0f); - func_809F72A4(this, globalCtx); -} - -s32 func_809F7D50(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnDodojr* this = (EnDodojr*)thisx; - Vec3f D_809F7F64 = { 480.0f, 620.0f, 0.0f }; - - if (limbIndex == 1) { - Matrix_Scale((this->rootScale * 0.5f) + 1.0f, this->rootScale + 1.0f, (this->rootScale * 0.5f) + 1.0f, - MTXMODE_APPLY); - } - - if (limbIndex == 4) { - Matrix_MultVec3f(&D_809F7F64, &this->headPos); - } - - return false; -} - -void func_809F7DFC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { -} - -void EnDodojr_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDodojr* this = (EnDodojr*)thisx; - - if ((this->actionFunc != func_809F73AC) && (this->actionFunc != func_809F7BE4)) { - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, func_809F7D50, func_809F7DFC, - &this->actor); - } -} diff --git a/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.cpp b/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.cpp new file mode 100644 index 000000000..d590c5697 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.cpp @@ -0,0 +1,663 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DODOJR_Z_EN_DODOJR_C +#include "actor_common.h" +/* + * File: z_en_dodojr.c + * Overlay: ovl_En_Dodojr + * Description: Baby Dodongo + */ + +#include "z_en_dodojr.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/object_dodojr/object_dodojr.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnDodojr_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDodojr_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDodojr_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDodojr_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_809F73AC(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F7BE4(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F74C4(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F758C(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F786C(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F799C(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F78EC(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F773C(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F77AC(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F784C(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F7AB8(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F7A00(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F7B3C(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F7C48(EnDodojr* pthis, GlobalContext* globalCtx); +void func_809F768C(EnDodojr* pthis, GlobalContext* globalCtx); + +ActorInit En_Dodojr_InitVars = { + ACTOR_EN_DODOJR, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DODOJR, + sizeof(EnDodojr), + (ActorFunc)EnDodojr_Init, + (ActorFunc)EnDodojr_Destroy, + (ActorFunc)EnDodojr_Update, + (ActorFunc)EnDodojr_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFC5FFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 18, 20, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInit = { 1, 2, 25, 25, 0xFF }; + +void EnDodojr_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDodojr* pthis = (EnDodojr*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 18.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_dodojr_Skel_0020E0, &object_dodojr_Anim_0009D4, + pthis->jointTable, pthis->morphTable, 15); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(4), &sColChkInit); + + pthis->actor.naviEnemyId = 0xE; + pthis->actor.flags &= ~ACTOR_FLAG_0; + + Actor_SetScale(&pthis->actor, 0.02f); + + pthis->actionFunc = func_809F73AC; +} + +void EnDodojr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDodojr* pthis = (EnDodojr*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_809F64D0(EnDodojr* pthis) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_SetColorFilter(&pthis->actor, 0x4000, 200, 0, 8); +} + +void func_809F6510(EnDodojr* pthis, GlobalContext* globalCtx, s32 count) { + Color_RGBA8 prim = { 170, 130, 90, 255 }; + Color_RGBA8 env = { 100, 60, 20, 0 }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + Vec3f pos; + s16 angle = ((Rand_ZeroOne() - 0.5f) * 65536.0f); + s32 i; + + pos.y = pthis->dustPos.y; + + for (i = count; i >= 0; i--, angle += (s16)(0x10000 / count)) { + accel.x = (Rand_ZeroOne() - 0.5f) * 4.0f; + accel.z = (Rand_ZeroOne() - 0.5f) * 4.0f; + + pos.x = (Math_SinS(angle) * 22.0f) + pthis->dustPos.x; + pos.z = (Math_CosS(angle) * 22.0f) + pthis->dustPos.z; + + func_8002836C(globalCtx, &pos, &velocity, &accel, &prim, &env, 120, 40, 10); + } +} + +void func_809F6730(EnDodojr* pthis, GlobalContext* globalCtx, Vec3f* arg2) { + Color_RGBA8 prim = { 170, 130, 90, 255 }; + Color_RGBA8 env = { 100, 60, 20, 0 }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + Vec3f pos; + s16 angle = ((Rand_ZeroOne() - 0.5f) * 65536.0f); + + pos.y = pthis->actor.floorHeight; + + accel.x = (Rand_ZeroOne() - 0.5f) * 2; + accel.z = (Rand_ZeroOne() - 0.5f) * 2; + + pos.x = (Math_SinS(angle) * 11.0f) + arg2->x; + pos.z = (Math_CosS(angle) * 11.0f) + arg2->z; + + func_8002836C(globalCtx, &pos, &velocity, &accel, &prim, &env, 100, 60, 8); +} + +s32 func_809F68B0(EnDodojr* pthis, GlobalContext* globalCtx) { + if (pthis->actor.velocity.y >= 0.0f) { + return 0; + } + + if (pthis->unk_1FC == 0) { + return 0; + } + + if (pthis->actor.bgCheckFlags & 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + pthis->dustPos = pthis->actor.world.pos; + func_809F6510(pthis, globalCtx, 10); + pthis->actor.velocity.y = 10.0f / (4 - pthis->unk_1FC); + pthis->unk_1FC--; + + if (pthis->unk_1FC == 0) { + pthis->actor.velocity.y = 0.0f; + return 1; + } + } + + return 0; +} + +void func_809F6994(EnDodojr* pthis) { + f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_000860); + + Animation_Change(&pthis->skelAnime, &object_dodojr_Anim_000860, 1.8f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -10.0f); + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 2.6f; + pthis->actor.gravity = -0.8f; +} + +void func_809F6A20(EnDodojr* pthis) { + f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_0004A0); + + Animation_Change(&pthis->skelAnime, &object_dodojr_Anim_0004A0, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -10.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.z = 0.0f; + pthis->actor.gravity = -0.8f; + + if (pthis->unk_1FC == 0) { + pthis->unk_1FC = 3; + pthis->actor.velocity.y = 10.0f; + } +} + +void func_809F6AC4(EnDodojr* pthis) { + f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_0005F0); + + Animation_Change(&pthis->skelAnime, &object_dodojr_Anim_0005F0, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, 0.0f); + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -0.8f; +} + +void func_809F6B38(EnDodojr* pthis) { + f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_000724); + + Animation_Change(&pthis->skelAnime, &object_dodojr_Anim_000724, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -10.0f); + pthis->actor.gravity = -0.8f; + pthis->unk_1FC = 3; + pthis->actor.velocity.y = 10.0f; +} + +void func_809F6BBC(EnDodojr* pthis) { + pthis->actor.shape.shadowDraw = NULL; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = -0.8f; + pthis->timer3 = 30; + pthis->dustPos = pthis->actor.world.pos; +} + +void func_809F6C24(EnDodojr* pthis) { + Animation_Change(&pthis->skelAnime, &object_dodojr_Anim_000724, 1.0f, 8.0f, 12.0f, ANIMMODE_ONCE, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_EAT); + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.z = 0.0f; + pthis->actor.gravity = -0.8f; +} + +s32 func_809F6CA4(EnDodojr* pthis, GlobalContext* globalCtx) { + Actor* bomb; + Vec3f unkVec = { 99999.0f, 99999.0f, 99999.0f }; + s32 retVar = 0; + f32 xDist; + f32 yDist; + f32 zDist; + + bomb = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; + pthis->bomb = NULL; + + while (bomb != NULL) { + if ((bomb->params != 0) || (bomb->parent != NULL) || (bomb->update == NULL)) { + bomb = bomb->next; + continue; + } + + if (bomb->id != ACTOR_EN_BOM) { + bomb = bomb->next; + continue; + } + + xDist = bomb->world.pos.x - pthis->actor.world.pos.x; + yDist = bomb->world.pos.y - pthis->actor.world.pos.y; + zDist = bomb->world.pos.z - pthis->actor.world.pos.z; + + if ((fabsf(xDist) >= fabsf(unkVec.x)) || (fabsf(yDist) >= fabsf(unkVec.y)) || + (fabsf(zDist) >= fabsf(unkVec.z))) { + bomb = bomb->next; + continue; + } + + pthis->bomb = bomb; + unkVec = bomb->world.pos; + retVar = 1; + bomb = bomb->next; + } + + return retVar; +} + +s32 func_809F6DD0(EnDodojr* pthis) { + if (pthis->bomb == NULL) { + return 0; + } else if (pthis->bomb->parent != NULL) { + return 0; + } else if (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->bomb->world.pos) > 30.0f) { + return 0; + } else { + pthis->bomb->parent = &pthis->actor; + return 1; + } +} + +void func_809F6E54(EnDodojr* pthis, GlobalContext* globalCtx) { + f32 angles[] = { 0.0f, 210.0f, 60.0f, 270.0f, 120.0f, 330.0f, 180.0f, 30.0f, 240.0f, 90.0f, 300.0f, 150.0f }; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f pos; + s16 angleIndex; + + if ((pthis->bomb == NULL) || (pthis->bomb->update == NULL) || + ((pthis->bomb != NULL) && (pthis->bomb->parent != NULL))) { + func_809F6CA4(pthis, globalCtx); + } + + if (pthis->bomb != NULL) { + pos = pthis->bomb->world.pos; + } else { + pos = player->actor.world.pos; + } + + if (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &pos) > 80.0f) { + angleIndex = (s16)(pthis->actor.home.pos.x + pthis->actor.home.pos.y + pthis->actor.home.pos.z + + globalCtx->state.frames / 30) % + 12; + angleIndex = ABS(angleIndex); + pos.x += 80.0f * sinf(angles[angleIndex]); + pos.z += 80.0f * cosf(angles[angleIndex]); + } + + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pos), 10, 1000, 1); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +s32 func_809F706C(EnDodojr* pthis) { + if (pthis->actor.xzDistToPlayer > 40.0f) { + return 0; + } else { + return 1; + } +} + +void func_809F709C(EnDodojr* pthis) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_DEAD); + pthis->actor.flags &= ~ACTOR_FLAG_0; + func_809F6A20(pthis); + pthis->actionFunc = func_809F7AB8; +} + +s32 func_809F70E8(EnDodojr* pthis, GlobalContext* globalCtx) { + if ((pthis->actionFunc == func_809F773C) || (pthis->actionFunc == func_809F77AC) || + (pthis->actionFunc == func_809F784C) || (pthis->actionFunc == func_809F7A00) || + (pthis->actionFunc == func_809F7AB8) || (pthis->actionFunc == func_809F7B3C) || + (pthis->actionFunc == func_809F7BE4)) { + return 0; + } + + if (globalCtx->actorCtx.unk_02 != 0) { + if (pthis->actionFunc != func_809F73AC) { + if (pthis->actionFunc == func_809F74C4) { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } + + func_809F709C(pthis); + } + return 0; + } + + if (!(pthis->collider.base.acFlags & 2)) { + return 0; + } else { + pthis->collider.base.acFlags &= ~2; + + if ((pthis->actionFunc == func_809F73AC) || (pthis->actionFunc == func_809F74C4)) { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } + + if ((pthis->actor.colChkInfo.damageEffect == 0) && (pthis->actor.colChkInfo.damage != 0)) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->timer2 = 2; + pthis->actionFunc = func_809F7C48; + return 1; + } + + if ((pthis->actor.colChkInfo.damageEffect == 1) && (pthis->actionFunc != func_809F78EC) && + (pthis->actionFunc != func_809F786C)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->timer1 = 120; + Actor_SetColorFilter(&pthis->actor, 0, 200, 0, 120); + func_809F6A20(pthis); + pthis->actionFunc = func_809F786C; + } + + return 0; + } +} + +void func_809F72A4(EnDodojr* pthis, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if ((pthis->actionFunc != func_809F73AC) && (pthis->actionFunc != func_809F7BE4)) { + if ((pthis->actionFunc == func_809F74C4) || (pthis->actionFunc == func_809F758C) || + (pthis->actionFunc == func_809F799C)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if ((pthis->actionFunc == func_809F74C4) || (pthis->actionFunc == func_809F758C) || + (pthis->actionFunc == func_809F786C) || (pthis->actionFunc == func_809F78EC) || + (pthis->actionFunc == func_809F799C)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void func_809F73AC(EnDodojr* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&object_dodojr_Anim_000860); + Player* player = GET_PLAYER(globalCtx); + f32 dist; + + if (!(pthis->actor.xzDistToPlayer >= 320.0f)) { + dist = pthis->actor.world.pos.y - player->actor.world.pos.y; + + if (!(dist >= 40.0f)) { + Animation_Change(&pthis->skelAnime, &object_dodojr_Anim_000860, 1.8f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, + -10.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_UP); + pthis->actor.world.pos.y -= 60.0f; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.world.rot.x -= 0x4000; + pthis->actor.shape.rot.x = pthis->actor.world.rot.x; + pthis->dustPos = pthis->actor.world.pos; + pthis->dustPos.y = pthis->actor.floorHeight; + pthis->actionFunc = func_809F74C4; + } + } +} + +void func_809F74C4(EnDodojr* pthis, GlobalContext* globalCtx) { + f32 sp2C; + + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 4, 0x3E8, 0x64); + sp2C = pthis->actor.shape.rot.x; + sp2C /= 16384.0f; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (60.0f * sp2C); + func_809F6510(pthis, globalCtx, 3); + + if (sp2C == 0.0f) { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + pthis->actor.world.rot.x = pthis->actor.shape.rot.x; + pthis->actor.speedXZ = 2.6f; + pthis->actionFunc = func_809F758C; + } +} + +void func_809F758C(EnDodojr* pthis, GlobalContext* globalCtx) { + func_8002D868(&pthis->actor); + func_809F6730(pthis, globalCtx, &pthis->actor.world.pos); + + if (DECR(pthis->timer4) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_MOVE); + pthis->timer4 = 5; + } + + if (func_809F6DD0(pthis) != 0) { + func_809F6C24(pthis); + pthis->actionFunc = func_809F768C; + return; + } + + func_809F6E54(pthis, globalCtx); + + if (func_809F706C(pthis) != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_CRY); + func_809F6B38(pthis); + pthis->actionFunc = func_809F799C; + } + + if (pthis->actor.bgCheckFlags & 8) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_DOWN); + func_809F6BBC(pthis); + pthis->actionFunc = func_809F7A00; + } +} + +void func_809F768C(EnDodojr* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + + if (((s16)pthis->skelAnime.curFrame - 8) < 4) { + bomb = (EnBom*)pthis->bomb; + bomb->timer++; + pthis->bomb->world.pos = pthis->headPos; + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_K_DRINK); + Actor_Kill(pthis->bomb); + pthis->timer3 = 24; + pthis->unk_1FC = 0; + pthis->actionFunc = func_809F773C; + } +} + +void func_809F773C(EnDodojr* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->timer3) == 0) { + func_809F64D0(pthis); + pthis->actor.flags &= ~ACTOR_FLAG_0; + func_809F6A20(pthis); + pthis->actionFunc = func_809F77AC; + } +} + +void func_809F77AC(EnDodojr* pthis, GlobalContext* globalCtx) { + pthis->rootScale = 1.2f; + pthis->rootScale *= ((f32)pthis->actor.colorFilterTimer / 8); + func_8002D868(&pthis->actor); + + if (func_809F68B0(pthis, globalCtx) != 0) { + pthis->timer3 = 60; + func_809F6AC4(pthis); + pthis->unk_1FC = 7; + pthis->actionFunc = func_809F784C; + } +} + +void func_809F784C(EnDodojr* pthis, GlobalContext* globalCtx) { + func_809F7B3C(pthis, globalCtx); +} + +void func_809F786C(EnDodojr* pthis, GlobalContext* globalCtx) { + func_8002D868(&pthis->actor); + + if (func_809F68B0(pthis, globalCtx) != 0) { + func_809F6AC4(pthis); + pthis->actionFunc = func_809F78EC; + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, 0, 4, 1000, 10); + pthis->actor.world.rot.x = pthis->actor.shape.rot.x; + pthis->actor.colorFilterTimer = pthis->timer1; +} + +void func_809F78EC(EnDodojr* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->timer1) != 0) { + if (pthis->timer1 < 30) { + if ((pthis->timer1 & 1) != 0) { + pthis->actor.world.pos.x += 1.5f; + pthis->actor.world.pos.z += 1.5f; + } else { + pthis->actor.world.pos.x -= 1.5f; + pthis->actor.world.pos.z -= 1.5f; + } + + return; + } + } else { + func_809F6994(pthis); + pthis->actionFunc = func_809F758C; + } +} + +void func_809F799C(EnDodojr* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_24; + func_8002D868(&pthis->actor); + + if (func_809F68B0(pthis, globalCtx) != 0) { + func_809F6994(pthis); + pthis->actionFunc = func_809F758C; + } +} + +void func_809F7A00(EnDodojr* pthis, GlobalContext* globalCtx) { + f32 tmp; + + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0x4000, 4, 1000, 100); + + if (DECR(pthis->timer3) != 0) { + tmp = (30 - pthis->timer3) / 30.0f; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - (60.0f * tmp); + } else { + Actor_Kill(&pthis->actor); + } + + func_809F6510(pthis, globalCtx, 3); +} + +void func_809F7AB8(EnDodojr* pthis, GlobalContext* globalCtx) { + func_8002D868(&pthis->actor); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, 0, 4, 1000, 10); + pthis->actor.world.rot.x = pthis->actor.shape.rot.x; + + if (func_809F68B0(pthis, globalCtx) != 0) { + pthis->timer3 = 60; + func_809F6AC4(pthis); + pthis->unk_1FC = 7; + pthis->actionFunc = func_809F7B3C; + } +} + +void func_809F7B3C(EnDodojr* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + + if (pthis->unk_1FC != 0) { + if (pthis->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 200, 0, pthis->unk_1FC); + pthis->unk_1FC--; + } + } else { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, BOMB_BODY); + + if (bomb != NULL) { + bomb->timer = 0; + } + + pthis->timer3 = 8; + pthis->actionFunc = func_809F7BE4; + } +} + +void func_809F7BE4(EnDodojr* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->timer3) == 0) { + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, 0x40); + Actor_Kill(&pthis->actor); + } +} + +void func_809F7C48(EnDodojr* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->timer2) == 0) { + func_809F709C(pthis); + } +} + +void EnDodojr_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDodojr* pthis = (EnDodojr*)thisx; + + SkelAnime_Update(&pthis->skelAnime); + Actor_MoveForward(&pthis->actor); + func_809F70E8(pthis, globalCtx); + + if (pthis->actionFunc != func_809F73AC) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, pthis->collider.dim.radius, pthis->collider.dim.height, 0.0f, 5); + } + + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 10.0f); + func_809F72A4(pthis, globalCtx); +} + +s32 func_809F7D50(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnDodojr* pthis = (EnDodojr*)thisx; + Vec3f D_809F7F64 = { 480.0f, 620.0f, 0.0f }; + + if (limbIndex == 1) { + Matrix_Scale((pthis->rootScale * 0.5f) + 1.0f, pthis->rootScale + 1.0f, (pthis->rootScale * 0.5f) + 1.0f, + MTXMODE_APPLY); + } + + if (limbIndex == 4) { + Matrix_MultVec3f(&D_809F7F64, &pthis->headPos); + } + + return false; +} + +void func_809F7DFC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +} + +void EnDodojr_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDodojr* pthis = (EnDodojr*)thisx; + + if ((pthis->actionFunc != func_809F73AC) && (pthis->actionFunc != func_809F7BE4)) { + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, func_809F7D50, func_809F7DFC, + &pthis->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c deleted file mode 100644 index 302a79815..000000000 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ /dev/null @@ -1,981 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DODONGO_Z_EN_DODONGO_C -#include "actor_common.h" -#include "z_en_dodongo.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" -#include "objects/object_dodongo/object_dodongo.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -typedef enum { - DODONGO_SWEEP_TAIL, - DODONGO_SWALLOW_BOMB, - DODONGO_DEATH, - DODONGO_BREATHE_FIRE, - DODONGO_IDLE, - DODONGO_END_BREATHE_FIRE, - DODONGO_UNUSED, - DODONGO_STUNNED, - DODONGO_WALK -} EnDodongoActionState; - -void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDodongo_SetupDeath(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_ShiftVecRadial(s16 yaw, f32 radius, Vec3f* vec); -s32 EnDodongo_AteBomb(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_SetupIdle(EnDodongo* this); - -void EnDodongo_Idle(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_EndBreatheFire(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_BreatheFire(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_SwallowBomb(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_Walk(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_Stunned(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_Death(EnDodongo* this, GlobalContext* globalCtx); -void EnDodongo_SweepTail(EnDodongo* this, GlobalContext* globalCtx); - -const ActorInit En_Dodongo_InitVars = { - ACTOR_EN_DODONGO, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DODONGO, - sizeof(EnDodongo), - (ActorFunc)EnDodongo_Init, - (ActorFunc)EnDodongo_Destroy, - (ActorFunc)EnDodongo_Update, - (ActorFunc)EnDodongo_Draw, -}; - -static ColliderJntSphElementInit sBodyElementsInit[6] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 15, { { 0, 0, 0 }, 17 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 14, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 13, { { 0, 0, 0 }, 10 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 21, { { 0, 0, 0 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 28, { { 0, 0, 0 }, 20 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x0D800691, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON | OCELEM_UNK3, - }, - { 6, { { 0, 0, 0 }, 35 }, 100 }, - }, -}; - -static ColliderJntSphInit sBodyJntSphInit = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 6, - sBodyElementsInit, -}; - -static ColliderTrisElementInit sHardElementsInit[3] = { - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xF24BF96E, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCBF96E, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCBF96E, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, -}; - -static ColliderTrisInit sHardTrisInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 3, - sHardElementsInit, -}; - -static ColliderQuadInit sAttackQuadInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x01, 0x10 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(4, 0xF), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x6), - /* Ice magic */ DMG_ENTRY(3, 0xF), - /* Light magic */ DMG_ENTRY(0, 0x6), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -void EnDodongo_SetupAction(EnDodongo* this, EnDodongoActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnDodongo_SpawnBombSmoke(EnDodongo* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.3f, 0.0f }; - Vec3f pos = this->headPos; - s16 randAngle = Rand_CenteredFloat(0x4000); - f32 randCos; - f32 randSin; - - randCos = Math_CosS(this->actor.shape.rot.y + randAngle); - randSin = Math_SinS(this->actor.shape.rot.y + randAngle); - if (this->bombSmokePrimColor.r > 30) { - this->bombSmokePrimColor.r -= 16; - this->bombSmokePrimColor.g -= 16; - } - - if (this->bombSmokePrimColor.b < 30) { - this->bombSmokePrimColor.b += 5; - this->bombSmokePrimColor.a += 8; - this->bombSmokeEnvColor.a += 8; - } - if (this->bombSmokeEnvColor.r != 0) { - this->bombSmokeEnvColor.r -= 15; - } - if (this->bombSmokeEnvColor.g != 0) { - this->bombSmokeEnvColor.g--; - } - velocity.x = randSin * 3.5f; - velocity.y = this->bombSmokeEnvColor.r * 0.02f; - velocity.z = randCos * 3.5f; - accel.x = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randSin; - accel.z = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randCos; - func_8002836C(globalCtx, &pos, &velocity, &accel, &this->bombSmokePrimColor, &this->bombSmokeEnvColor, 100, 25, 20); - - randAngle = Rand_ZeroOne() * 0x2000; - randCos = Math_CosS(this->actor.shape.rot.y + randAngle); - randSin = Math_SinS(this->actor.shape.rot.y + randAngle); - pos.x -= randCos * 6.0f; - pos.z += randSin * 6.0f; - velocity.x = -randCos * 3.5f; - velocity.y = this->bombSmokeEnvColor.r * 0.02f; - velocity.z = randSin * 3.5f; - accel.x = ((Rand_ZeroOne() * 0.1f) + 0.15f) * randCos; - accel.z = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randSin; - func_8002836C(globalCtx, &pos, &velocity, &accel, &this->bombSmokePrimColor, &this->bombSmokeEnvColor, 100, 25, 20); - - randAngle = Rand_ZeroOne() * 0x2000; - randCos = Math_CosS(this->actor.shape.rot.y + randAngle); - randSin = Math_SinS(this->actor.shape.rot.y + randAngle); - - pos.x = this->headPos.x + (randCos * 6.0f); - pos.z = this->headPos.z - (randSin * 6.0f); - velocity.x = randCos * 3.5f; - velocity.y = this->bombSmokeEnvColor.r * 0.02f; - velocity.z = -randSin * 3.5f; - accel.x = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randCos; - accel.z = ((Rand_ZeroOne() * 0.1f) + 0.15f) * randSin; - func_8002836C(globalCtx, &pos, &velocity, &accel, &this->bombSmokePrimColor, &this->bombSmokeEnvColor, 100, 25, 20); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x0D, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2800, ICHAIN_STOP), -}; - -void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDodongo* this = (EnDodongo*)thisx; - EffectBlureInit1 blureInit; - - this->actor.targetMode = 3; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->bombSmokePrimColor.r = this->bombSmokePrimColor.g = this->bombSmokeEnvColor.r = 255; - this->bombSmokePrimColor.a = this->bombSmokeEnvColor.a = 200; - this->bombSmokeEnvColor.g = 10; - this->bodyScale.x = this->bodyScale.y = this->bodyScale.z = 1.0f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); - Actor_SetScale(&this->actor, 0.01875f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDodongoSkel, &gDodongoWaitAnim, this->jointTable, this->morphTable, - 31); - this->actor.colChkInfo.health = 4; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.colChkInfo.damageTable = &sDamageTable; - Collider_InitQuad(globalCtx, &this->colliderAT); - Collider_InitTris(globalCtx, &this->colliderHard); - Collider_InitJntSph(globalCtx, &this->colliderBody); - Collider_SetQuad(globalCtx, &this->colliderAT, &this->actor, &sAttackQuadInit); - Collider_SetTris(globalCtx, &this->colliderHard, &this->actor, &sHardTrisInit, this->trisElements); - Collider_SetJntSph(globalCtx, &this->colliderBody, &this->actor, &sBodyJntSphInit, this->sphElements); - - blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = - blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = - blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = blureInit.p2EndColor[1] = - blureInit.p2EndColor[2] = 255; - - blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; - blureInit.p2StartColor[3] = 64; - blureInit.elemDuration = 8; - blureInit.unkFlag = false; - blureInit.calcMode = 2; - - Effect_Add(globalCtx, &this->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); - EnDodongo_SetupIdle(this); -} - -void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDodongo* this = (EnDodongo*)thisx; - - Effect_Delete(globalCtx, this->blureIdx); - Collider_DestroyTris(globalCtx, &this->colliderHard); - Collider_DestroyJntSph(globalCtx, &this->colliderBody); - Collider_DestroyQuad(globalCtx, &this->colliderAT); -} - -void EnDodongo_SetupIdle(EnDodongo* this) { - Animation_MorphToLoop(&this->skelAnime, &gDodongoWaitAnim, -4.0f); - this->actor.speedXZ = 0.0f; - this->timer = Rand_S16Offset(30, 50); - this->actionState = DODONGO_IDLE; - EnDodongo_SetupAction(this, EnDodongo_Idle); -} - -void EnDodongo_SetupWalk(EnDodongo* this) { - f32 frames = Animation_GetLastFrame(&gDodongoWalkAnim); - - Animation_Change(&this->skelAnime, &gDodongoWalkAnim, 0.0f, 0.0f, frames, ANIMMODE_LOOP, -4.0f); - this->actor.speedXZ = 1.5f; - this->timer = Rand_S16Offset(50, 70); - this->rightFootStep = true; - this->actionState = DODONGO_WALK; - EnDodongo_SetupAction(this, EnDodongo_Walk); -} - -void EnDodongo_SetupBreatheFire(EnDodongo* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDodongoBreatheFireAnim, -4.0f); - this->actionState = DODONGO_BREATHE_FIRE; - this->actor.speedXZ = 0.0f; - EnDodongo_SetupAction(this, EnDodongo_BreatheFire); -} - -void EnDodongo_SetupEndBreatheFire(EnDodongo* this) { - Animation_PlayOnce(&this->skelAnime, &gDodongoAfterBreatheFireAnim); - this->actionState = DODONGO_END_BREATHE_FIRE; - this->actor.speedXZ = 0.0f; - EnDodongo_SetupAction(this, EnDodongo_EndBreatheFire); -} - -void EnDodongo_SetupSwallowBomb(EnDodongo* this) { - Animation_Change(&this->skelAnime, &gDodongoBreatheFireAnim, -1.0f, 35.0f, 0.0f, ANIMMODE_ONCE, -4.0f); - this->actionState = DODONGO_SWALLOW_BOMB; - this->timer = 25; - this->actor.speedXZ = 0.0f; - EnDodongo_SetupAction(this, EnDodongo_SwallowBomb); -} - -void EnDodongo_SetupStunned(EnDodongo* this) { - Animation_Change(&this->skelAnime, &gDodongoBreatheFireAnim, 0.0f, 25.0f, 0.0f, ANIMMODE_ONCE, -4.0f); - this->actionState = DODONGO_STUNNED; - this->actor.speedXZ = 0.0f; - if (this->damageEffect == 0xF) { - this->iceTimer = 36; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - EnDodongo_SetupAction(this, EnDodongo_Stunned); -} - -void EnDodongo_Idle(EnDodongo* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((DECR(this->timer) == 0) && Animation_OnFrame(&this->skelAnime, 0.0f)) { - EnDodongo_SetupWalk(this); - } -} - -void EnDodongo_EndBreatheFire(EnDodongo* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnDodongo_SetupIdle(this); - this->timer = Rand_S16Offset(10, 20); - } -} - -void EnDodongo_BreatheFire(EnDodongo* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - s16 pad2; - s16 fireFrame; - - if ((s32)this->skelAnime.curFrame == 24) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_CRY); - } - if ((29.0f <= this->skelAnime.curFrame) && (this->skelAnime.curFrame <= 43.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); - fireFrame = this->skelAnime.curFrame - 29.0f; - pos = this->actor.world.pos; - pos.y += 35.0f; - EnDodongo_ShiftVecRadial(this->actor.world.rot.y, 30.0f, &pos); - EnDodongo_ShiftVecRadial(this->actor.world.rot.y, 2.5f, &accel); - EffectSsDFire_SpawnFixedScale(globalCtx, &pos, &velocity, &accel, 255 - (fireFrame * 10), fireFrame + 3); - } else if ((2.0f <= this->skelAnime.curFrame) && (this->skelAnime.curFrame <= 20.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); - } - if (SkelAnime_Update(&this->skelAnime)) { - EnDodongo_SetupEndBreatheFire(this); - } -} - -void EnDodongo_SwallowBomb(EnDodongo* this, GlobalContext* globalCtx) { - Vec3f smokeVel = { 0.0f, 0.0f, 0.0f }; - Vec3f smokeAccel = { 0.0f, 0.6f, 0.0f }; - Color_RGBA8 white = { 255, 255, 255, 255 }; - Vec3f deathFireVel = { 0.0f, 0.0f, 0.0f }; - Vec3f deathFireAccel = { 0.0f, 1.0f, 0.0f }; - s16 i; - Vec3f pos; - s32 pad; - - if (this->actor.child != NULL) { - this->actor.child->world.pos = this->mouthPos; - ((EnBom*)this->actor.child)->timer++; - } else if (this->actor.parent != NULL) { - this->actor.parent->world.pos = this->mouthPos; - ((EnBombf*)this->actor.parent)->timer++; - //! @bug An explosive can also be a bombchu, not always a bomb, which leads to a serious bug. ->timer (0x1F8) is - //! outside the bounds of the bombchu actor, and the memory it writes to happens to be one of the pointers in - //! the next arena node. When this value is written to, massive memory corruption occurs. - } - - if ((s32)this->skelAnime.curFrame == 28) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_EAT); - if (this->actor.child != NULL) { - Actor_Kill(this->actor.child); - this->actor.child = NULL; - } else if (this->actor.parent != NULL) { - Actor_Kill(this->actor.parent); - this->actor.parent = NULL; - } - } else if ((s32)this->skelAnime.curFrame == 24) { - this->timer--; - if (this->timer != 0) { - this->skelAnime.curFrame++; - if (this->timer == 10) { - for (i = 10; i >= 0; i--) { - deathFireVel.x = Rand_CenteredFloat(10.0f); - deathFireVel.y = Rand_CenteredFloat(10.0f); - deathFireVel.z = Rand_CenteredFloat(10.0f); - deathFireAccel.x = deathFireVel.x * -0.1f; - deathFireAccel.y = deathFireVel.y * -0.1f; - deathFireAccel.z = deathFireVel.z * -0.1f; - pos.x = this->sphElements[0].dim.worldSphere.center.x + deathFireVel.x; - pos.y = this->sphElements[0].dim.worldSphere.center.y + deathFireVel.y; - pos.z = this->sphElements[0].dim.worldSphere.center.z + deathFireVel.z; - func_8002836C(globalCtx, &pos, &deathFireVel, &deathFireAccel, &this->bombSmokePrimColor, - &this->bombSmokeEnvColor, 400, 10, 10); - } - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 8); - } - } - } - if ((s32)this->skelAnime.curFrame < 28) { - if (((s32)this->skelAnime.curFrame < 26) && (this->timer <= 10)) { - EnDodongo_SpawnBombSmoke(this, globalCtx); - } else { - pos = this->headPos; - func_8002829C(globalCtx, &pos, &smokeVel, &smokeAccel, &white, &white, 50, 5); - pos.x -= (Math_CosS(this->actor.shape.rot.y) * 6.0f); - pos.z += (Math_SinS(this->actor.shape.rot.y) * 6.0f); - func_8002829C(globalCtx, &pos, &smokeVel, &smokeAccel, &white, &white, 50, 5); - pos.x = this->headPos.x + (Math_CosS(this->actor.shape.rot.y) * 6.0f); - pos.z = this->headPos.z - (Math_SinS(this->actor.shape.rot.y) * 6.0f); - func_8002829C(globalCtx, &pos, &smokeVel, &smokeAccel, &white, &white, 50, 5); - } - } - this->bodyScale.y = this->bodyScale.z = (Math_SinS(this->actor.colorFilterTimer * 0x1000) * 0.5f) + 1.0f; - this->bodyScale.x = Math_SinS(this->actor.colorFilterTimer * 0x1000) + 1.0f; - - SkelAnime_Update(&this->skelAnime); - if (this->timer == 0) { - EnDodongo_SetupDeath(this, globalCtx); - } -} - -void EnDodongo_Walk(EnDodongo* this, GlobalContext* globalCtx) { - s32 pad; - f32 playbackSpeed; - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff = (s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y); - - yawDiff = ABS(yawDiff); - - Math_SmoothStepToF(&this->actor.speedXZ, 1.5f, 0.1f, 1.0f, 0.0f); - - playbackSpeed = this->actor.speedXZ * 0.75f; - if (this->actor.speedXZ >= 0.0f) { - if (playbackSpeed > 3.0f / 2) { - playbackSpeed = 3.0f / 2; - } - } else { - if (playbackSpeed < -3.0f / 2) { - playbackSpeed = -3.0f / 2; - } - } - this->skelAnime.playSpeed = playbackSpeed; - - SkelAnime_Update(&this->skelAnime); - if ((s32)this->skelAnime.curFrame < 21) { - if (!this->rightFootStep) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftFootPos, 10.0f, 3, 2.0f, 0xC8, 0xF, 0); - this->rightFootStep = true; - } - } else { - if (this->rightFootStep) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightFootPos, 10.0f, 3, 2.0f, 0xC8, 0xF, 0); - this->rightFootStep = false; - } - } - - if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 400.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x1F4, 0); - this->actor.flags |= ACTOR_FLAG_0; - if ((this->actor.xzDistToPlayer < 100.0f) && (yawDiff < 0x1388) && (this->actor.yDistToPlayer < 60.0f)) { - EnDodongo_SetupBreatheFire(this); - } - } else { - this->actor.flags &= ~ACTOR_FLAG_0; - if ((Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) > 150.0f) || (this->retreatTimer != 0)) { - s16 yawToHome = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - - Math_SmoothStepToS(&this->actor.world.rot.y, yawToHome, 1, 0x1F4, 0); - } - if (this->retreatTimer != 0) { - this->retreatTimer--; - } - this->timer--; - if (this->timer == 0) { - if (Rand_ZeroOne() > 0.7f) { - this->timer = Rand_S16Offset(50, 70); - this->retreatTimer = Rand_S16Offset(15, 40); - } else { - EnDodongo_SetupIdle(this); - } - } - } - - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnDodongo_SetupSweepTail(EnDodongo* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDodongoDamageAnim, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DAMAGE); - this->actionState = DODONGO_SWEEP_TAIL; - this->timer = 0; - this->actor.speedXZ = 0.0f; - EnDodongo_SetupAction(this, EnDodongo_SweepTail); -} - -void EnDodongo_SweepTail(EnDodongo* this, GlobalContext* globalCtx) { - s16 yawDiff1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (SkelAnime_Update(&this->skelAnime)) { - if ((this->timer != 0) || (ABS(yawDiff1) < 0x4000)) { - this->sphElements[2].info.toucherFlags = TOUCH_NONE; - this->sphElements[1].info.toucherFlags = TOUCH_NONE; - this->colliderBody.base.atFlags = AT_NONE; - this->sphElements[2].info.toucher.dmgFlags = 0; - this->sphElements[1].info.toucher.dmgFlags = 0; - this->sphElements[2].info.toucher.damage = 0; - this->sphElements[1].info.toucher.damage = 0; - EnDodongo_SetupBreatheFire(this); - this->timer = Rand_S16Offset(5, 10); - } else { - s16 yawDiff2 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - AnimationHeader* animation; - - this->tailSwipeSpeed = (0xFFFF - ABS(yawDiff2)) / 0xF; - if ((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) >= 0) { - this->tailSwipeSpeed = -this->tailSwipeSpeed; - animation = &gDodongoSweepTailLeftAnim; - } else { - animation = &gDodongoSweepTailRightAnim; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_TAIL); - Animation_PlayOnceSetSpeed(&this->skelAnime, animation, 2.0f); - this->timer = 18; - this->colliderBody.base.atFlags = this->sphElements[1].info.toucherFlags = - this->sphElements[2].info.toucherFlags = AT_ON | AT_TYPE_ENEMY; // also TOUCH_ON | TOUCH_SFX_WOOD - this->sphElements[1].info.toucher.dmgFlags = this->sphElements[2].info.toucher.dmgFlags = 0xFFCFFFFF; - this->sphElements[1].info.toucher.damage = this->sphElements[2].info.toucher.damage = 8; - } - } else if (this->timer > 1) { - Vec3f tailPos; - - this->timer--; - this->actor.shape.rot.y = this->actor.world.rot.y += this->tailSwipeSpeed; - tailPos.x = this->sphElements[1].dim.worldSphere.center.x; - tailPos.y = this->sphElements[1].dim.worldSphere.center.y; - tailPos.z = this->sphElements[1].dim.worldSphere.center.z; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &tailPos, 5.0f, 2, 2.0f, 100, 15, 0); - tailPos.x = this->sphElements[2].dim.worldSphere.center.x; - tailPos.y = this->sphElements[2].dim.worldSphere.center.y; - tailPos.z = this->sphElements[2].dim.worldSphere.center.z; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &tailPos, 5.0f, 2, 2.0f, 100, 15, 0); - - if (this->colliderBody.base.atFlags & AT_HIT) { - Player* player = GET_PLAYER(globalCtx); - - if (this->colliderBody.base.at == &player->actor) { - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - } -} - -void EnDodongo_SetupDeath(EnDodongo* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDodongoDieAnim, -8.0f); - this->timer = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DEAD); - this->actionState = DODONGO_DEATH; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - EnDodongo_SetupAction(this, EnDodongo_Death); -} - -void EnDodongo_Death(EnDodongo* this, GlobalContext* globalCtx) { - EnBom* bomb; - - if (this->skelAnime.curFrame < 35.0f) { - if (this->actor.params == EN_DODONGO_SMOKE_DEATH) { - EnDodongo_SpawnBombSmoke(this, globalCtx); - } - } else if (this->actor.colorFilterTimer == 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4); - } - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->timer == 0) { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 6, BOMB_BODY); - if (bomb != NULL) { - bomb->timer = 0; - this->timer = 8; - } - } - } else if ((s32)this->skelAnime.curFrame == 52) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } - if (this->timer != 0) { - this->timer--; - if (this->timer == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x40); - Actor_Kill(&this->actor); - } - } -} - -void EnDodongo_Stunned(EnDodongo* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->actor.colorFilterTimer == 0) { - if (this->actor.colChkInfo.health == 0) { - EnDodongo_SetupDeath(this, globalCtx); - } else { - EnDodongo_SetupIdle(this); - } - } -} - -void EnDodongo_CollisionCheck(EnDodongo* this, GlobalContext* globalCtx) { - if (this->colliderHard.base.acFlags & AC_BOUNCED) { - this->colliderHard.base.acFlags &= ~AC_BOUNCED; - this->colliderBody.base.acFlags &= ~AC_HIT; - } else if ((this->colliderBody.base.acFlags & AC_HIT) && (this->actionState > DODONGO_DEATH)) { - this->colliderBody.base.acFlags &= ~AC_HIT; - Actor_SetDropFlagJntSph(&this->actor, &this->colliderBody, 0); - if (this->actor.colChkInfo.damageEffect != 0xE) { - this->damageEffect = this->actor.colChkInfo.damageEffect; - if ((this->actor.colChkInfo.damageEffect == 1) || (this->actor.colChkInfo.damageEffect == 0xF)) { - if (this->actionState != DODONGO_STUNNED) { - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); - Actor_ApplyDamage(&this->actor); - EnDodongo_SetupStunned(this); - } - } else { - Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 8); - if (Actor_ApplyDamage(&this->actor) == 0) { - EnDodongo_SetupDeath(this, globalCtx); - } else { - EnDodongo_SetupSweepTail(this); - } - } - } - } -} - -void EnDodongo_UpdateQuad(EnDodongo* this, GlobalContext* globalCtx) { - Vec3f sp94 = { -1000.0f, -1500.0f, 0.0f }; - Vec3f sp88 = { -1000.0f, -200.0f, 1500.0f }; - Vec3f sp7C = { -1000.0f, -200.0f, -1500.0f }; - Vec3f sp70 = { 0.0f, 0.0f, 0.0f }; - s32 pad4C[9]; // Possibly 3 more Vec3fs? - s32 a = 0; - s32 b = 1; // These indices are needed to match. - s32 c = 2; // Might be a way to quickly test vertex arrangements - s32 d = 3; - f32 xMod = Math_SinF((this->skelAnime.curFrame - 28.0f) * 0.08f) * 5500.0f; - - sp7C.x -= xMod; - sp94.x -= xMod; - sp88.x -= xMod; - - Matrix_MultVec3f(&sp94, &this->colliderAT.dim.quad[b]); - Matrix_MultVec3f(&sp88, &this->colliderAT.dim.quad[a]); - Matrix_MultVec3f(&sp7C, &this->colliderAT.dim.quad[d]); - Matrix_MultVec3f(&sp70, &this->colliderAT.dim.quad[c]); - - Collider_SetQuadVertices(&this->colliderAT, &this->colliderAT.dim.quad[a], &this->colliderAT.dim.quad[b], - &this->colliderAT.dim.quad[c], &this->colliderAT.dim.quad[d]); -} - -void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnDodongo* this = (EnDodongo*)thisx; - - EnDodongo_CollisionCheck(this, globalCtx); - if (this->actor.colChkInfo.damageEffect != 0xE) { - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - if (this->actionState != DODONGO_DEATH) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderHard.base); - } - if (this->actionState > DODONGO_DEATH) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); - } - if ((this->actionState >= DODONGO_IDLE) && EnDodongo_AteBomb(this, globalCtx)) { - EnDodongo_SetupSwallowBomb(this); - } - if (this->actionState == DODONGO_BREATHE_FIRE) { - if ((29.0f < this->skelAnime.curFrame) && (this->skelAnime.curFrame < 43.0f)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderAT.base); - } - } - this->actor.focus.pos.x = this->actor.world.pos.x + Math_SinS(this->actor.shape.rot.y) * -30.0f; - this->actor.focus.pos.y = this->actor.world.pos.y + 20.0f; - this->actor.focus.pos.z = this->actor.world.pos.z + Math_CosS(this->actor.shape.rot.y) * -30.0f; -} - -s32 EnDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnDodongo* this = (EnDodongo*)thisx; - - if ((limbIndex == 15) || (limbIndex == 16)) { - Matrix_Scale(this->bodyScale.x, this->bodyScale.y, this->bodyScale.z, MTXMODE_APPLY); - } - return false; -} - -void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f legOffsets[3] = { - { 1100.0f, -700.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f }, - { 2190.0f, 0.0f, 0.0f }, - }; - Vec3f tailTipOffset = { 3000.0f, 0.0f, 0.0f }; - Vec3f baseOffset = { 0.0f, 0.0f, 0.0f }; - s32 i; - Vec3f hardTris0Vtx[3]; - Vec3f hardTris1Vtx[3]; - Vec3f hardTris2Vtx[3]; - Vec3f tailTip; - Vec3f tailBase; - EnDodongo* this = (EnDodongo*)thisx; - Vec3f hardTris0VtxOffset[] = { - { -300.0f, -2500.0f, 0.0f }, - { -300.0f, 1200.0f, -2700.0f }, - { 3000.0f, 1200.0f, 0.0f }, - }; - Vec3f hardTris1VtxOffset[] = { - { -300.0f, -2500.0f, 0.0f }, - { -300.0f, 1200.0f, 2700.0f }, - { 3000.0f, 1200.0f, 0.0f }, - }; - Vec3f hardTris2VtxOffset[] = { - { -600.0f, 1200.0f, -2800.0f }, - { -600.0f, 1200.0f, 2800.0f }, - { 3000.0f, 1200.0f, 0.0f }, - }; - Vec3f mouthOffset = { 1800.0f, 1200.0f, 0.0f }; - Vec3f headOffset = { 1500.0f, 300.0f, 0.0f }; - - Collider_UpdateSpheres(limbIndex, &this->colliderBody); - - switch (limbIndex) { - case 2: - if ((this->actionState == DODONGO_BREATHE_FIRE) && (29.0f < this->skelAnime.curFrame) && - (this->skelAnime.curFrame < 43.0f)) { - EnDodongo_UpdateQuad(this, globalCtx); - } - break; - case 7: - for (i = 0; i < 3; i++) { - Matrix_MultVec3f(&hardTris0VtxOffset[i], &hardTris0Vtx[i]); - Matrix_MultVec3f(&hardTris1VtxOffset[i], &hardTris1Vtx[i]); - Matrix_MultVec3f(&hardTris2VtxOffset[i], &hardTris2Vtx[i]); - } - Collider_SetTrisVertices(&this->colliderHard, 0, &hardTris0Vtx[0], &hardTris0Vtx[1], &hardTris0Vtx[2]); - Collider_SetTrisVertices(&this->colliderHard, 1, &hardTris1Vtx[0], &hardTris1Vtx[1], &hardTris1Vtx[2]); - Collider_SetTrisVertices(&this->colliderHard, 2, &hardTris2Vtx[0], &hardTris2Vtx[1], &hardTris2Vtx[2]); - Matrix_MultVec3f(&mouthOffset, &this->mouthPos); - Matrix_MultVec3f(&headOffset, &this->headPos); - break; - case 15: - if ((this->actionState == DODONGO_SWEEP_TAIL) && (this->timer >= 2)) { - Matrix_MultVec3f(&tailTipOffset, &tailTip); - Matrix_MultVec3f(&baseOffset, &tailBase); - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &tailTip, &tailBase); - } else if ((this->actionState == DODONGO_SWEEP_TAIL) && (this->timer != 0)) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); - } - break; - case 21: - Matrix_MultVec3f(&legOffsets[1], &this->leftFootPos); - break; - case 28: - Matrix_MultVec3f(&legOffsets[1], &this->rightFootPos); - break; - } - if (this->iceTimer != 0) { - i = -1; - switch (limbIndex) { - case 7: - baseOffset.x = 1200.0f; - i = 0; - break; - case 13: - i = 1; - break; - case 14: - i = 2; - break; - case 15: - i = 3; - break; - case 16: - i = 4; - break; - case 22: - i = 5; - break; - case 29: - i = 6; - break; - case 21: - i = 7; - break; - case 28: - i = 8; - break; - } - if (i >= 0) { - Matrix_MultVec3f(&baseOffset, &this->icePos[i]); - } - } -} - -void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnDodongo* this = (EnDodongo*)thisx; - s32 index; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, - EnDodongo_PostLimbDraw, this); - - if (this->iceTimer != 0) { - this->actor.colorFilterTimer++; - if (1) {} - this->iceTimer--; - if ((this->iceTimer % 4) == 0) { - index = this->iceTimer >> 2; - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &this->icePos[index], 150, 150, 150, 250, 235, 245, - 255, 1.8f); - } - } -} - -void EnDodongo_ShiftVecRadial(s16 yaw, f32 radius, Vec3f* vec) { - vec->x += Math_SinS(yaw) * radius; - vec->z += Math_CosS(yaw) * radius; -} - -s32 EnDodongo_AteBomb(EnDodongo* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; - f32 dx; - f32 dy; - f32 dz; - - while (actor != NULL) { - if ((actor->params != 0) || (actor->parent != NULL)) { - actor = actor->next; - continue; - } - dx = actor->world.pos.x - this->mouthPos.x; - dy = actor->world.pos.y - this->mouthPos.y; - dz = actor->world.pos.z - this->mouthPos.z; - if ((fabsf(dx) < 20.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 20.0f)) { - if (actor->id == ACTOR_EN_BOM) { - this->actor.child = actor; - } else { - this->actor.parent = actor; - } - actor->parent = &this->actor; - return true; - } - actor = actor->next; - } - return false; -} diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.cpp b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.cpp new file mode 100644 index 000000000..cdbc872e3 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.cpp @@ -0,0 +1,981 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DODONGO_Z_EN_DODONGO_C +#include "actor_common.h" +#include "z_en_dodongo.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" +#include "objects/object_dodongo/object_dodongo.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +typedef enum { + DODONGO_SWEEP_TAIL, + DODONGO_SWALLOW_BOMB, + DODONGO_DEATH, + DODONGO_BREATHE_FIRE, + DODONGO_IDLE, + DODONGO_END_BREATHE_FIRE, + DODONGO_UNUSED, + DODONGO_STUNNED, + DODONGO_WALK +} EnDodongoActionState; + +void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDodongo_SetupDeath(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_ShiftVecRadial(s16 yaw, f32 radius, Vec3f* vec); +s32 EnDodongo_AteBomb(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_SetupIdle(EnDodongo* pthis); + +void EnDodongo_Idle(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_EndBreatheFire(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_BreatheFire(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_SwallowBomb(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_Walk(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_Stunned(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_Death(EnDodongo* pthis, GlobalContext* globalCtx); +void EnDodongo_SweepTail(EnDodongo* pthis, GlobalContext* globalCtx); + +ActorInit En_Dodongo_InitVars = { + ACTOR_EN_DODONGO, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DODONGO, + sizeof(EnDodongo), + (ActorFunc)EnDodongo_Init, + (ActorFunc)EnDodongo_Destroy, + (ActorFunc)EnDodongo_Update, + (ActorFunc)EnDodongo_Draw, +}; + +static ColliderJntSphElementInit sBodyElementsInit[6] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 15, { { 0, 0, 0 }, 17 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 14, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 13, { { 0, 0, 0 }, 10 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 21, { { 0, 0, 0 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 28, { { 0, 0, 0 }, 20 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0D800691, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON | OCELEM_UNK3, + }, + { 6, { { 0, 0, 0 }, 35 }, 100 }, + }, +}; + +static ColliderJntSphInit sBodyJntSphInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 6, + sBodyElementsInit, +}; + +static ColliderTrisElementInit sHardElementsInit[3] = { + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF24BF96E, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCBF96E, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCBF96E, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, +}; + +static ColliderTrisInit sHardTrisInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 3, + sHardElementsInit, +}; + +static ColliderQuadInit sAttackQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(1, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(4, 0xF), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x6), + /* Ice magic */ DMG_ENTRY(3, 0xF), + /* Light magic */ DMG_ENTRY(0, 0x6), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +void EnDodongo_SetupAction(EnDodongo* pthis, EnDodongoActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnDodongo_SpawnBombSmoke(EnDodongo* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + Vec3f pos = pthis->headPos; + s16 randAngle = Rand_CenteredFloat(0x4000); + f32 randCos; + f32 randSin; + + randCos = Math_CosS(pthis->actor.shape.rot.y + randAngle); + randSin = Math_SinS(pthis->actor.shape.rot.y + randAngle); + if (pthis->bombSmokePrimColor.r > 30) { + pthis->bombSmokePrimColor.r -= 16; + pthis->bombSmokePrimColor.g -= 16; + } + + if (pthis->bombSmokePrimColor.b < 30) { + pthis->bombSmokePrimColor.b += 5; + pthis->bombSmokePrimColor.a += 8; + pthis->bombSmokeEnvColor.a += 8; + } + if (pthis->bombSmokeEnvColor.r != 0) { + pthis->bombSmokeEnvColor.r -= 15; + } + if (pthis->bombSmokeEnvColor.g != 0) { + pthis->bombSmokeEnvColor.g--; + } + velocity.x = randSin * 3.5f; + velocity.y = pthis->bombSmokeEnvColor.r * 0.02f; + velocity.z = randCos * 3.5f; + accel.x = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randSin; + accel.z = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randCos; + func_8002836C(globalCtx, &pos, &velocity, &accel, &pthis->bombSmokePrimColor, &pthis->bombSmokeEnvColor, 100, 25, 20); + + randAngle = Rand_ZeroOne() * 0x2000; + randCos = Math_CosS(pthis->actor.shape.rot.y + randAngle); + randSin = Math_SinS(pthis->actor.shape.rot.y + randAngle); + pos.x -= randCos * 6.0f; + pos.z += randSin * 6.0f; + velocity.x = -randCos * 3.5f; + velocity.y = pthis->bombSmokeEnvColor.r * 0.02f; + velocity.z = randSin * 3.5f; + accel.x = ((Rand_ZeroOne() * 0.1f) + 0.15f) * randCos; + accel.z = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randSin; + func_8002836C(globalCtx, &pos, &velocity, &accel, &pthis->bombSmokePrimColor, &pthis->bombSmokeEnvColor, 100, 25, 20); + + randAngle = Rand_ZeroOne() * 0x2000; + randCos = Math_CosS(pthis->actor.shape.rot.y + randAngle); + randSin = Math_SinS(pthis->actor.shape.rot.y + randAngle); + + pos.x = pthis->headPos.x + (randCos * 6.0f); + pos.z = pthis->headPos.z - (randSin * 6.0f); + velocity.x = randCos * 3.5f; + velocity.y = pthis->bombSmokeEnvColor.r * 0.02f; + velocity.z = -randSin * 3.5f; + accel.x = ((Rand_ZeroOne() * 0.1f) + 0.15f) * -randCos; + accel.z = ((Rand_ZeroOne() * 0.1f) + 0.15f) * randSin; + func_8002836C(globalCtx, &pos, &velocity, &accel, &pthis->bombSmokePrimColor, &pthis->bombSmokeEnvColor, 100, 25, 20); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x0D, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2800, ICHAIN_STOP), +}; + +void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDodongo* pthis = (EnDodongo*)thisx; + EffectBlureInit1 blureInit; + + pthis->actor.targetMode = 3; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->bombSmokePrimColor.r = pthis->bombSmokePrimColor.g = pthis->bombSmokeEnvColor.r = 255; + pthis->bombSmokePrimColor.a = pthis->bombSmokeEnvColor.a = 200; + pthis->bombSmokeEnvColor.g = 10; + pthis->bodyScale.x = pthis->bodyScale.y = pthis->bodyScale.z = 1.0f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); + Actor_SetScale(&pthis->actor, 0.01875f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDodongoSkel, &gDodongoWaitAnim, pthis->jointTable, pthis->morphTable, + 31); + pthis->actor.colChkInfo.health = 4; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.colChkInfo.damageTable = &sDamageTable; + Collider_InitQuad(globalCtx, &pthis->colliderAT); + Collider_InitTris(globalCtx, &pthis->colliderHard); + Collider_InitJntSph(globalCtx, &pthis->colliderBody); + Collider_SetQuad(globalCtx, &pthis->colliderAT, &pthis->actor, &sAttackQuadInit); + Collider_SetTris(globalCtx, &pthis->colliderHard, &pthis->actor, &sHardTrisInit, pthis->trisElements); + Collider_SetJntSph(globalCtx, &pthis->colliderBody, &pthis->actor, &sBodyJntSphInit, pthis->sphElements); + + blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = + blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = + blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = blureInit.p2EndColor[1] = + blureInit.p2EndColor[2] = 255; + + blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; + blureInit.p2StartColor[3] = 64; + blureInit.elemDuration = 8; + blureInit.unkFlag = false; + blureInit.calcMode = 2; + + Effect_Add(globalCtx, &pthis->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 60.0f, 70.0f, 0x1D); + EnDodongo_SetupIdle(pthis); +} + +void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDodongo* pthis = (EnDodongo*)thisx; + + Effect_Delete(globalCtx, pthis->blureIdx); + Collider_DestroyTris(globalCtx, &pthis->colliderHard); + Collider_DestroyJntSph(globalCtx, &pthis->colliderBody); + Collider_DestroyQuad(globalCtx, &pthis->colliderAT); +} + +void EnDodongo_SetupIdle(EnDodongo* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gDodongoWaitAnim, -4.0f); + pthis->actor.speedXZ = 0.0f; + pthis->timer = Rand_S16Offset(30, 50); + pthis->actionState = DODONGO_IDLE; + EnDodongo_SetupAction(pthis, EnDodongo_Idle); +} + +void EnDodongo_SetupWalk(EnDodongo* pthis) { + f32 frames = Animation_GetLastFrame(&gDodongoWalkAnim); + + Animation_Change(&pthis->skelAnime, &gDodongoWalkAnim, 0.0f, 0.0f, frames, ANIMMODE_LOOP, -4.0f); + pthis->actor.speedXZ = 1.5f; + pthis->timer = Rand_S16Offset(50, 70); + pthis->rightFootStep = true; + pthis->actionState = DODONGO_WALK; + EnDodongo_SetupAction(pthis, EnDodongo_Walk); +} + +void EnDodongo_SetupBreatheFire(EnDodongo* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDodongoBreatheFireAnim, -4.0f); + pthis->actionState = DODONGO_BREATHE_FIRE; + pthis->actor.speedXZ = 0.0f; + EnDodongo_SetupAction(pthis, EnDodongo_BreatheFire); +} + +void EnDodongo_SetupEndBreatheFire(EnDodongo* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gDodongoAfterBreatheFireAnim); + pthis->actionState = DODONGO_END_BREATHE_FIRE; + pthis->actor.speedXZ = 0.0f; + EnDodongo_SetupAction(pthis, EnDodongo_EndBreatheFire); +} + +void EnDodongo_SetupSwallowBomb(EnDodongo* pthis) { + Animation_Change(&pthis->skelAnime, &gDodongoBreatheFireAnim, -1.0f, 35.0f, 0.0f, ANIMMODE_ONCE, -4.0f); + pthis->actionState = DODONGO_SWALLOW_BOMB; + pthis->timer = 25; + pthis->actor.speedXZ = 0.0f; + EnDodongo_SetupAction(pthis, EnDodongo_SwallowBomb); +} + +void EnDodongo_SetupStunned(EnDodongo* pthis) { + Animation_Change(&pthis->skelAnime, &gDodongoBreatheFireAnim, 0.0f, 25.0f, 0.0f, ANIMMODE_ONCE, -4.0f); + pthis->actionState = DODONGO_STUNNED; + pthis->actor.speedXZ = 0.0f; + if (pthis->damageEffect == 0xF) { + pthis->iceTimer = 36; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + EnDodongo_SetupAction(pthis, EnDodongo_Stunned); +} + +void EnDodongo_Idle(EnDodongo* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((DECR(pthis->timer) == 0) && Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + EnDodongo_SetupWalk(pthis); + } +} + +void EnDodongo_EndBreatheFire(EnDodongo* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDodongo_SetupIdle(pthis); + pthis->timer = Rand_S16Offset(10, 20); + } +} + +void EnDodongo_BreatheFire(EnDodongo* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + s16 pad2; + s16 fireFrame; + + if ((s32)pthis->skelAnime.curFrame == 24) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_CRY); + } + if ((29.0f <= pthis->skelAnime.curFrame) && (pthis->skelAnime.curFrame <= 43.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); + fireFrame = pthis->skelAnime.curFrame - 29.0f; + pos = pthis->actor.world.pos; + pos.y += 35.0f; + EnDodongo_ShiftVecRadial(pthis->actor.world.rot.y, 30.0f, &pos); + EnDodongo_ShiftVecRadial(pthis->actor.world.rot.y, 2.5f, &accel); + EffectSsDFire_SpawnFixedScale(globalCtx, &pos, &velocity, &accel, 255 - (fireFrame * 10), fireFrame + 3); + } else if ((2.0f <= pthis->skelAnime.curFrame) && (pthis->skelAnime.curFrame <= 20.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); + } + if (SkelAnime_Update(&pthis->skelAnime)) { + EnDodongo_SetupEndBreatheFire(pthis); + } +} + +void EnDodongo_SwallowBomb(EnDodongo* pthis, GlobalContext* globalCtx) { + Vec3f smokeVel = { 0.0f, 0.0f, 0.0f }; + Vec3f smokeAccel = { 0.0f, 0.6f, 0.0f }; + Color_RGBA8 white = { 255, 255, 255, 255 }; + Vec3f deathFireVel = { 0.0f, 0.0f, 0.0f }; + Vec3f deathFireAccel = { 0.0f, 1.0f, 0.0f }; + s16 i; + Vec3f pos; + s32 pad; + + if (pthis->actor.child != NULL) { + pthis->actor.child->world.pos = pthis->mouthPos; + ((EnBom*)pthis->actor.child)->timer++; + } else if (pthis->actor.parent != NULL) { + pthis->actor.parent->world.pos = pthis->mouthPos; + ((EnBombf*)pthis->actor.parent)->timer++; + //! @bug An explosive can also be a bombchu, not always a bomb, which leads to a serious bug. ->timer (0x1F8) is + //! outside the bounds of the bombchu actor, and the memory it writes to happens to be one of the pointers in + //! the next arena node. When pthis value is written to, massive memory corruption occurs. + } + + if ((s32)pthis->skelAnime.curFrame == 28) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_EAT); + if (pthis->actor.child != NULL) { + Actor_Kill(pthis->actor.child); + pthis->actor.child = NULL; + } else if (pthis->actor.parent != NULL) { + Actor_Kill(pthis->actor.parent); + pthis->actor.parent = NULL; + } + } else if ((s32)pthis->skelAnime.curFrame == 24) { + pthis->timer--; + if (pthis->timer != 0) { + pthis->skelAnime.curFrame++; + if (pthis->timer == 10) { + for (i = 10; i >= 0; i--) { + deathFireVel.x = Rand_CenteredFloat(10.0f); + deathFireVel.y = Rand_CenteredFloat(10.0f); + deathFireVel.z = Rand_CenteredFloat(10.0f); + deathFireAccel.x = deathFireVel.x * -0.1f; + deathFireAccel.y = deathFireVel.y * -0.1f; + deathFireAccel.z = deathFireVel.z * -0.1f; + pos.x = pthis->sphElements[0].dim.worldSphere.center.x + deathFireVel.x; + pos.y = pthis->sphElements[0].dim.worldSphere.center.y + deathFireVel.y; + pos.z = pthis->sphElements[0].dim.worldSphere.center.z + deathFireVel.z; + func_8002836C(globalCtx, &pos, &deathFireVel, &deathFireAccel, &pthis->bombSmokePrimColor, + &pthis->bombSmokeEnvColor, 400, 10, 10); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0x78, 0, 8); + } + } + } + if ((s32)pthis->skelAnime.curFrame < 28) { + if (((s32)pthis->skelAnime.curFrame < 26) && (pthis->timer <= 10)) { + EnDodongo_SpawnBombSmoke(pthis, globalCtx); + } else { + pos = pthis->headPos; + func_8002829C(globalCtx, &pos, &smokeVel, &smokeAccel, &white, &white, 50, 5); + pos.x -= (Math_CosS(pthis->actor.shape.rot.y) * 6.0f); + pos.z += (Math_SinS(pthis->actor.shape.rot.y) * 6.0f); + func_8002829C(globalCtx, &pos, &smokeVel, &smokeAccel, &white, &white, 50, 5); + pos.x = pthis->headPos.x + (Math_CosS(pthis->actor.shape.rot.y) * 6.0f); + pos.z = pthis->headPos.z - (Math_SinS(pthis->actor.shape.rot.y) * 6.0f); + func_8002829C(globalCtx, &pos, &smokeVel, &smokeAccel, &white, &white, 50, 5); + } + } + pthis->bodyScale.y = pthis->bodyScale.z = (Math_SinS(pthis->actor.colorFilterTimer * 0x1000) * 0.5f) + 1.0f; + pthis->bodyScale.x = Math_SinS(pthis->actor.colorFilterTimer * 0x1000) + 1.0f; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer == 0) { + EnDodongo_SetupDeath(pthis, globalCtx); + } +} + +void EnDodongo_Walk(EnDodongo* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 playbackSpeed; + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff = (s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y); + + yawDiff = ABS(yawDiff); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 1.5f, 0.1f, 1.0f, 0.0f); + + playbackSpeed = pthis->actor.speedXZ * 0.75f; + if (pthis->actor.speedXZ >= 0.0f) { + if (playbackSpeed > 3.0f / 2) { + playbackSpeed = 3.0f / 2; + } + } else { + if (playbackSpeed < -3.0f / 2) { + playbackSpeed = -3.0f / 2; + } + } + pthis->skelAnime.playSpeed = playbackSpeed; + + SkelAnime_Update(&pthis->skelAnime); + if ((s32)pthis->skelAnime.curFrame < 21) { + if (!pthis->rightFootStep) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_WALK); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftFootPos, 10.0f, 3, 2.0f, 0xC8, 0xF, 0); + pthis->rightFootStep = true; + } + } else { + if (pthis->rightFootStep) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_WALK); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightFootPos, 10.0f, 3, 2.0f, 0xC8, 0xF, 0); + pthis->rightFootStep = false; + } + } + + if (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < 400.0f) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x1F4, 0); + pthis->actor.flags |= ACTOR_FLAG_0; + if ((pthis->actor.xzDistToPlayer < 100.0f) && (yawDiff < 0x1388) && (pthis->actor.yDistToPlayer < 60.0f)) { + EnDodongo_SetupBreatheFire(pthis); + } + } else { + pthis->actor.flags &= ~ACTOR_FLAG_0; + if ((Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) > 150.0f) || (pthis->retreatTimer != 0)) { + s16 yawToHome = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + + Math_SmoothStepToS(&pthis->actor.world.rot.y, yawToHome, 1, 0x1F4, 0); + } + if (pthis->retreatTimer != 0) { + pthis->retreatTimer--; + } + pthis->timer--; + if (pthis->timer == 0) { + if (Rand_ZeroOne() > 0.7f) { + pthis->timer = Rand_S16Offset(50, 70); + pthis->retreatTimer = Rand_S16Offset(15, 40); + } else { + EnDodongo_SetupIdle(pthis); + } + } + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnDodongo_SetupSweepTail(EnDodongo* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDodongoDamageAnim, -4.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_DAMAGE); + pthis->actionState = DODONGO_SWEEP_TAIL; + pthis->timer = 0; + pthis->actor.speedXZ = 0.0f; + EnDodongo_SetupAction(pthis, EnDodongo_SweepTail); +} + +void EnDodongo_SweepTail(EnDodongo* pthis, GlobalContext* globalCtx) { + s16 yawDiff1 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (SkelAnime_Update(&pthis->skelAnime)) { + if ((pthis->timer != 0) || (ABS(yawDiff1) < 0x4000)) { + pthis->sphElements[2].info.toucherFlags = TOUCH_NONE; + pthis->sphElements[1].info.toucherFlags = TOUCH_NONE; + pthis->colliderBody.base.atFlags = AT_NONE; + pthis->sphElements[2].info.toucher.dmgFlags = 0; + pthis->sphElements[1].info.toucher.dmgFlags = 0; + pthis->sphElements[2].info.toucher.damage = 0; + pthis->sphElements[1].info.toucher.damage = 0; + EnDodongo_SetupBreatheFire(pthis); + pthis->timer = Rand_S16Offset(5, 10); + } else { + s16 yawDiff2 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + AnimationHeader* animation; + + pthis->tailSwipeSpeed = (0xFFFF - ABS(yawDiff2)) / 0xF; + if ((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) >= 0) { + pthis->tailSwipeSpeed = -pthis->tailSwipeSpeed; + animation = &gDodongoSweepTailLeftAnim; + } else { + animation = &gDodongoSweepTailRightAnim; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_TAIL); + Animation_PlayOnceSetSpeed(&pthis->skelAnime, animation, 2.0f); + pthis->timer = 18; + pthis->colliderBody.base.atFlags = pthis->sphElements[1].info.toucherFlags = + pthis->sphElements[2].info.toucherFlags = AT_ON | AT_TYPE_ENEMY; // also TOUCH_ON | TOUCH_SFX_WOOD + pthis->sphElements[1].info.toucher.dmgFlags = pthis->sphElements[2].info.toucher.dmgFlags = 0xFFCFFFFF; + pthis->sphElements[1].info.toucher.damage = pthis->sphElements[2].info.toucher.damage = 8; + } + } else if (pthis->timer > 1) { + Vec3f tailPos; + + pthis->timer--; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y += pthis->tailSwipeSpeed; + tailPos.x = pthis->sphElements[1].dim.worldSphere.center.x; + tailPos.y = pthis->sphElements[1].dim.worldSphere.center.y; + tailPos.z = pthis->sphElements[1].dim.worldSphere.center.z; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &tailPos, 5.0f, 2, 2.0f, 100, 15, 0); + tailPos.x = pthis->sphElements[2].dim.worldSphere.center.x; + tailPos.y = pthis->sphElements[2].dim.worldSphere.center.y; + tailPos.z = pthis->sphElements[2].dim.worldSphere.center.z; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &tailPos, 5.0f, 2, 2.0f, 100, 15, 0); + + if (pthis->colliderBody.base.atFlags & AT_HIT) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->colliderBody.base.at == &player->actor) { + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + } + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + } +} + +void EnDodongo_SetupDeath(EnDodongo* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gDodongoDieAnim, -8.0f); + pthis->timer = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_J_DEAD); + pthis->actionState = DODONGO_DEATH; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + EnDodongo_SetupAction(pthis, EnDodongo_Death); +} + +void EnDodongo_Death(EnDodongo* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + + if (pthis->skelAnime.curFrame < 35.0f) { + if (pthis->actor.params == EN_DODONGO_SMOKE_DEATH) { + EnDodongo_SpawnBombSmoke(pthis, globalCtx); + } + } else if (pthis->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0x78, 0, 4); + } + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->timer == 0) { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 6, BOMB_BODY); + if (bomb != NULL) { + bomb->timer = 0; + pthis->timer = 8; + } + } + } else if ((s32)pthis->skelAnime.curFrame == 52) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } + if (pthis->timer != 0) { + pthis->timer--; + if (pthis->timer == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x40); + Actor_Kill(&pthis->actor); + } + } +} + +void EnDodongo_Stunned(EnDodongo* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.colorFilterTimer == 0) { + if (pthis->actor.colChkInfo.health == 0) { + EnDodongo_SetupDeath(pthis, globalCtx); + } else { + EnDodongo_SetupIdle(pthis); + } + } +} + +void EnDodongo_CollisionCheck(EnDodongo* pthis, GlobalContext* globalCtx) { + if (pthis->colliderHard.base.acFlags & AC_BOUNCED) { + pthis->colliderHard.base.acFlags &= ~AC_BOUNCED; + pthis->colliderBody.base.acFlags &= ~AC_HIT; + } else if ((pthis->colliderBody.base.acFlags & AC_HIT) && (pthis->actionState > DODONGO_DEATH)) { + pthis->colliderBody.base.acFlags &= ~AC_HIT; + Actor_SetDropFlagJntSph(&pthis->actor, &pthis->colliderBody, 0); + if (pthis->actor.colChkInfo.damageEffect != 0xE) { + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + if ((pthis->actor.colChkInfo.damageEffect == 1) || (pthis->actor.colChkInfo.damageEffect == 0xF)) { + if (pthis->actionState != DODONGO_STUNNED) { + Actor_SetColorFilter(&pthis->actor, 0, 0x78, 0, 0x50); + Actor_ApplyDamage(&pthis->actor); + EnDodongo_SetupStunned(pthis); + } + } else { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0x78, 0, 8); + if (Actor_ApplyDamage(&pthis->actor) == 0) { + EnDodongo_SetupDeath(pthis, globalCtx); + } else { + EnDodongo_SetupSweepTail(pthis); + } + } + } + } +} + +void EnDodongo_UpdateQuad(EnDodongo* pthis, GlobalContext* globalCtx) { + Vec3f sp94 = { -1000.0f, -1500.0f, 0.0f }; + Vec3f sp88 = { -1000.0f, -200.0f, 1500.0f }; + Vec3f sp7C = { -1000.0f, -200.0f, -1500.0f }; + Vec3f sp70 = { 0.0f, 0.0f, 0.0f }; + s32 pad4C[9]; // Possibly 3 more Vec3fs? + s32 a = 0; + s32 b = 1; // These indices are needed to match. + s32 c = 2; // Might be a way to quickly test vertex arrangements + s32 d = 3; + f32 xMod = Math_SinF((pthis->skelAnime.curFrame - 28.0f) * 0.08f) * 5500.0f; + + sp7C.x -= xMod; + sp94.x -= xMod; + sp88.x -= xMod; + + Matrix_MultVec3f(&sp94, &pthis->colliderAT.dim.quad[b]); + Matrix_MultVec3f(&sp88, &pthis->colliderAT.dim.quad[a]); + Matrix_MultVec3f(&sp7C, &pthis->colliderAT.dim.quad[d]); + Matrix_MultVec3f(&sp70, &pthis->colliderAT.dim.quad[c]); + + Collider_SetQuadVertices(&pthis->colliderAT, &pthis->colliderAT.dim.quad[a], &pthis->colliderAT.dim.quad[b], + &pthis->colliderAT.dim.quad[c], &pthis->colliderAT.dim.quad[d]); +} + +void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDodongo* pthis = (EnDodongo*)thisx; + + EnDodongo_CollisionCheck(pthis, globalCtx); + if (pthis->actor.colChkInfo.damageEffect != 0xE) { + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 60.0f, 70.0f, 0x1D); + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + if (pthis->actionState != DODONGO_DEATH) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderHard.base); + } + if (pthis->actionState > DODONGO_DEATH) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); + } + if ((pthis->actionState >= DODONGO_IDLE) && EnDodongo_AteBomb(pthis, globalCtx)) { + EnDodongo_SetupSwallowBomb(pthis); + } + if (pthis->actionState == DODONGO_BREATHE_FIRE) { + if ((29.0f < pthis->skelAnime.curFrame) && (pthis->skelAnime.curFrame < 43.0f)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderAT.base); + } + } + pthis->actor.focus.pos.x = pthis->actor.world.pos.x + Math_SinS(pthis->actor.shape.rot.y) * -30.0f; + pthis->actor.focus.pos.y = pthis->actor.world.pos.y + 20.0f; + pthis->actor.focus.pos.z = pthis->actor.world.pos.z + Math_CosS(pthis->actor.shape.rot.y) * -30.0f; +} + +s32 EnDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnDodongo* pthis = (EnDodongo*)thisx; + + if ((limbIndex == 15) || (limbIndex == 16)) { + Matrix_Scale(pthis->bodyScale.x, pthis->bodyScale.y, pthis->bodyScale.z, MTXMODE_APPLY); + } + return false; +} + +void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f legOffsets[3] = { + { 1100.0f, -700.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, + { 2190.0f, 0.0f, 0.0f }, + }; + Vec3f tailTipOffset = { 3000.0f, 0.0f, 0.0f }; + Vec3f baseOffset = { 0.0f, 0.0f, 0.0f }; + s32 i; + Vec3f hardTris0Vtx[3]; + Vec3f hardTris1Vtx[3]; + Vec3f hardTris2Vtx[3]; + Vec3f tailTip; + Vec3f tailBase; + EnDodongo* pthis = (EnDodongo*)thisx; + Vec3f hardTris0VtxOffset[] = { + { -300.0f, -2500.0f, 0.0f }, + { -300.0f, 1200.0f, -2700.0f }, + { 3000.0f, 1200.0f, 0.0f }, + }; + Vec3f hardTris1VtxOffset[] = { + { -300.0f, -2500.0f, 0.0f }, + { -300.0f, 1200.0f, 2700.0f }, + { 3000.0f, 1200.0f, 0.0f }, + }; + Vec3f hardTris2VtxOffset[] = { + { -600.0f, 1200.0f, -2800.0f }, + { -600.0f, 1200.0f, 2800.0f }, + { 3000.0f, 1200.0f, 0.0f }, + }; + Vec3f mouthOffset = { 1800.0f, 1200.0f, 0.0f }; + Vec3f headOffset = { 1500.0f, 300.0f, 0.0f }; + + Collider_UpdateSpheres(limbIndex, &pthis->colliderBody); + + switch (limbIndex) { + case 2: + if ((pthis->actionState == DODONGO_BREATHE_FIRE) && (29.0f < pthis->skelAnime.curFrame) && + (pthis->skelAnime.curFrame < 43.0f)) { + EnDodongo_UpdateQuad(pthis, globalCtx); + } + break; + case 7: + for (i = 0; i < 3; i++) { + Matrix_MultVec3f(&hardTris0VtxOffset[i], &hardTris0Vtx[i]); + Matrix_MultVec3f(&hardTris1VtxOffset[i], &hardTris1Vtx[i]); + Matrix_MultVec3f(&hardTris2VtxOffset[i], &hardTris2Vtx[i]); + } + Collider_SetTrisVertices(&pthis->colliderHard, 0, &hardTris0Vtx[0], &hardTris0Vtx[1], &hardTris0Vtx[2]); + Collider_SetTrisVertices(&pthis->colliderHard, 1, &hardTris1Vtx[0], &hardTris1Vtx[1], &hardTris1Vtx[2]); + Collider_SetTrisVertices(&pthis->colliderHard, 2, &hardTris2Vtx[0], &hardTris2Vtx[1], &hardTris2Vtx[2]); + Matrix_MultVec3f(&mouthOffset, &pthis->mouthPos); + Matrix_MultVec3f(&headOffset, &pthis->headPos); + break; + case 15: + if ((pthis->actionState == DODONGO_SWEEP_TAIL) && (pthis->timer >= 2)) { + Matrix_MultVec3f(&tailTipOffset, &tailTip); + Matrix_MultVec3f(&baseOffset, &tailBase); + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIdx), &tailTip, &tailBase); + } else if ((pthis->actionState == DODONGO_SWEEP_TAIL) && (pthis->timer != 0)) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIdx)); + } + break; + case 21: + Matrix_MultVec3f(&legOffsets[1], &pthis->leftFootPos); + break; + case 28: + Matrix_MultVec3f(&legOffsets[1], &pthis->rightFootPos); + break; + } + if (pthis->iceTimer != 0) { + i = -1; + switch (limbIndex) { + case 7: + baseOffset.x = 1200.0f; + i = 0; + break; + case 13: + i = 1; + break; + case 14: + i = 2; + break; + case 15: + i = 3; + break; + case 16: + i = 4; + break; + case 22: + i = 5; + break; + case 29: + i = 6; + break; + case 21: + i = 7; + break; + case 28: + i = 8; + break; + } + if (i >= 0) { + Matrix_MultVec3f(&baseOffset, &pthis->icePos[i]); + } + } +} + +void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnDodongo* pthis = (EnDodongo*)thisx; + s32 index; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, + EnDodongo_PostLimbDraw, pthis); + + if (pthis->iceTimer != 0) { + pthis->actor.colorFilterTimer++; + if (1) {} + pthis->iceTimer--; + if ((pthis->iceTimer % 4) == 0) { + index = pthis->iceTimer >> 2; + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &pthis->icePos[index], 150, 150, 150, 250, 235, 245, + 255, 1.8f); + } + } +} + +void EnDodongo_ShiftVecRadial(s16 yaw, f32 radius, Vec3f* vec) { + vec->x += Math_SinS(yaw) * radius; + vec->z += Math_CosS(yaw) * radius; +} + +s32 EnDodongo_AteBomb(EnDodongo* pthis, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; + f32 dx; + f32 dy; + f32 dz; + + while (actor != NULL) { + if ((actor->params != 0) || (actor->parent != NULL)) { + actor = actor->next; + continue; + } + dx = actor->world.pos.x - pthis->mouthPos.x; + dy = actor->world.pos.y - pthis->mouthPos.y; + dz = actor->world.pos.z - pthis->mouthPos.z; + if ((fabsf(dx) < 20.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 20.0f)) { + if (actor->id == ACTOR_EN_BOM) { + pthis->actor.child = actor; + } else { + pthis->actor.parent = actor; + } + actor->parent = &pthis->actor; + return true; + } + actor = actor->next; + } + return false; +} diff --git a/src/overlays/actors/ovl_En_Dog/z_en_dog.c b/src/overlays/actors/ovl_En_Dog/z_en_dog.c deleted file mode 100644 index 66e49b165..000000000 --- a/src/overlays/actors/ovl_En_Dog/z_en_dog.c +++ /dev/null @@ -1,485 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DOG_Z_EN_DOG_C -#include "actor_common.h" -/* - * File: z_en_dog.c - * Overlay: ovl_En_Dog - * Description: Dog - */ - -#include "z_en_dog.h" -#include "objects/object_dog/object_dog.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_path.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void EnDog_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDog_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDog_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDog_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDog_FollowPath(EnDog* this, GlobalContext* globalCtx); -void EnDog_ChooseMovement(EnDog* this, GlobalContext* globalCtx); -void EnDog_FollowPlayer(EnDog* this, GlobalContext* globalCtx); -void EnDog_RunAway(EnDog* this, GlobalContext* globalCtx); -void EnDog_FaceLink(EnDog* this, GlobalContext* globalCtx); -void EnDog_Wait(EnDog* this, GlobalContext* globalCtx); - -const ActorInit En_Dog_InitVars = { - ACTOR_EN_DOG, - ACTORCAT_NPC, - FLAGS, - OBJECT_DOG, - sizeof(EnDog), - (ActorFunc)EnDog_Init, - (ActorFunc)EnDog_Destroy, - (ActorFunc)EnDog_Update, - (ActorFunc)EnDog_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 16, 20, 0, { 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, 50 }; - -static struct_80034EC0_Entry sAnimations[] = { - { &gDogWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &gDogWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, - { &gDogRunAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, - { &gDogBarkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, - { &gDogSitAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, -6.0f }, - { &gDogSitAnim, 1.0f, 5.0f, 25.0f, ANIMMODE_LOOP_PARTIAL, -6.0f }, - { &gDogBowAnim, 1.0f, 0.0f, 6.0f, ANIMMODE_ONCE, -6.0f }, - { &gDogBow2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, -}; - -typedef enum { - /* 0x00 */ DOG_WALK, - /* 0x01 */ DOG_RUN, - /* 0x02 */ DOG_BARK, - /* 0x03 */ DOG_SIT, - /* 0x04 */ DOG_SIT_2, - /* 0x05 */ DOG_BOW, - /* 0x06 */ DOG_BOW_2 -} DogBehavior; - -void EnDog_PlayWalkSFX(EnDog* this) { - AnimationHeader* walk = &gDogWalkAnim; - - if (this->skelAnime.animation == walk) { - if ((this->skelAnime.curFrame == 1.0f) || (this->skelAnime.curFrame == 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK); - } - } -} - -void EnDog_PlayRunSFX(EnDog* this) { - AnimationHeader* run = &gDogRunAnim; - - if (this->skelAnime.animation == run) { - if ((this->skelAnime.curFrame == 2.0f) || (this->skelAnime.curFrame == 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK); - } - } -} - -void EnDog_PlayBarkSFX(EnDog* this) { - AnimationHeader* bark = &gDogBarkAnim; - - if (this->skelAnime.animation == bark) { - if ((this->skelAnime.curFrame == 13.0f) || (this->skelAnime.curFrame == 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); - } - } -} - -s32 EnDog_PlayAnimAndSFX(EnDog* this) { - s32 animation; - - if (this->behavior != this->nextBehavior) { - if (this->nextBehavior == DOG_SIT_2) { - this->nextBehavior = DOG_SIT; - } - if (this->nextBehavior == DOG_BOW_2) { - this->nextBehavior = DOG_BOW; - } - - this->behavior = this->nextBehavior; - switch (this->behavior) { - case DOG_WALK: - animation = 1; - break; - case DOG_RUN: - animation = 2; - break; - case DOG_BARK: - animation = 3; - break; - case DOG_SIT: - animation = 4; - break; - case DOG_BOW: - animation = 6; - break; - } - func_80034EC0(&this->skelAnime, sAnimations, animation); - } - - switch (this->behavior) { - case DOG_SIT: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 5); - this->behavior = this->nextBehavior = DOG_SIT_2; - } - break; - case DOG_BOW: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 7); - this->behavior = this->nextBehavior = DOG_BOW_2; - } - break; - case DOG_WALK: - EnDog_PlayWalkSFX(this); - break; - case DOG_RUN: - EnDog_PlayRunSFX(this); - break; - case DOG_BARK: - EnDog_PlayBarkSFX(this); - break; - } - return 0; -} - -s8 EnDog_CanFollow(EnDog* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - return 2; - } - - if (globalCtx->sceneNum == SCENE_MARKET_DAY) { - return 0; - } - - if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - if (gSaveContext.dogParams != 0) { - return 0; - } - gSaveContext.dogParams = (this->actor.params & 0x7FFF); - return 1; - } - - return 0; -} - -s32 EnDog_UpdateWaypoint(EnDog* this, GlobalContext* globalCtx) { - s32 change; - - if (this->path == NULL) { - return 0; - } - - if (this->reverse) { - change = -1; - } else { - change = 1; - } - - this->waypoint += change; - - if (this->reverse) { - if (this->waypoint < 0) { - this->waypoint = this->path->count - 1; - } - } else { - if ((this->path->count - 1) < this->waypoint) { - this->waypoint = 0; - } - } - - return 1; -} - -s32 EnDog_Orient(EnDog* this, GlobalContext* globalCtx) { - s16 targetYaw; - f32 waypointDistSq; - - waypointDistSq = Path_OrientAndGetDistSq(&this->actor, this->path, this->waypoint, &targetYaw); - Math_SmoothStepToS(&this->actor.world.rot.y, targetYaw, 10, 1000, 1); - - if ((waypointDistSq > 0.0f) && (waypointDistSq < 1000.0f)) { - return EnDog_UpdateWaypoint(this, globalCtx); - } else { - return 0; - } -} - -void EnDog_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDog* this = (EnDog*)thisx; - s16 followingDog; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, 13); - func_80034EC0(&this->skelAnime, sAnimations, 0); - - if ((this->actor.params & 0x8000) == 0) { - this->actor.params = (this->actor.params & 0xF0FF) | ((((this->actor.params & 0x0F00) >> 8) + 1) << 8); - } - - followingDog = ((gSaveContext.dogParams & 0x0F00) >> 8); - if (followingDog == ((this->actor.params & 0x0F00) >> 8) && ((this->actor.params & 0x8000) == 0)) { - Actor_Kill(&this->actor); - return; - } - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, 0, &sColChkInfoInit); - Actor_SetScale(&this->actor, 0.0075f); - this->waypoint = 0; - this->actor.gravity = -1.0f; - this->path = Path_GetByIndex(globalCtx, (this->actor.params & 0x00F0) >> 4, 0xF); - - switch (globalCtx->sceneNum) { - case SCENE_MARKET_NIGHT: - if ((!gSaveContext.dogIsLost) && (((this->actor.params & 0x0F00) >> 8) == 1)) { - Actor_Kill(&this->actor); - } - break; - case SCENE_IMPA: // Richard's Home - if (!(this->actor.params & 0x8000)) { - if (!gSaveContext.dogIsLost) { - this->nextBehavior = DOG_SIT; - this->actionFunc = EnDog_Wait; - this->actor.speedXZ = 0.0f; - return; - } else { - Actor_Kill(&this->actor); - return; - } - } - break; - } - - if (this->actor.params & 0x8000) { - this->nextBehavior = DOG_WALK; - this->actionFunc = EnDog_FollowPlayer; - } else { - this->nextBehavior = DOG_SIT; - this->actionFunc = EnDog_ChooseMovement; - } -} - -void EnDog_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDog* this = (EnDog*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnDog_FollowPath(EnDog* this, GlobalContext* globalCtx) { - s32 behaviors[] = { DOG_SIT, DOG_BOW, DOG_BARK }; - s32 unused[] = { 40, 80, 20 }; - f32 speed; - s32 frame; - - if (EnDog_CanFollow(this, globalCtx) == 1) { - this->actionFunc = EnDog_FollowPlayer; - } - - if (DECR(this->behaviorTimer) != 0) { - if (this->nextBehavior == DOG_WALK) { - speed = 1.0f; - } else { - speed = 4.0f; - } - Math_SmoothStepToF(&this->actor.speedXZ, speed, 0.4f, 1.0f, 0.0f); - EnDog_Orient(this, globalCtx); - this->actor.shape.rot = this->actor.world.rot; - - // Used to change between two text boxes for Richard's owner in the Market Day scene - // depending on where he is on his path. En_Hy checks these event flags. - if (this->waypoint < 9) { - // Richard is close to her, text says something about his coat - gSaveContext.eventInf[3] |= 1; - } else { - // Richard is far, text says something about running fast - gSaveContext.eventInf[3] &= ~1; - } - } else { - frame = globalCtx->state.frames % 3; - this->nextBehavior = behaviors[frame]; - // no clue why they're using the behavior id to calculate timer. possibly meant to use the unused array? - this->behaviorTimer = Rand_S16Offset(60, behaviors[frame]); - this->actionFunc = EnDog_ChooseMovement; - } -} - -void EnDog_ChooseMovement(EnDog* this, GlobalContext* globalCtx) { - if (EnDog_CanFollow(this, globalCtx) == 1) { - this->actionFunc = EnDog_FollowPlayer; - } - - if (DECR(this->behaviorTimer) == 0) { - this->behaviorTimer = Rand_S16Offset(200, 100); - if (globalCtx->state.frames % 2) { - this->nextBehavior = DOG_WALK; - } else { - this->nextBehavior = DOG_RUN; - } - - if (this->nextBehavior == DOG_RUN) { - this->behaviorTimer /= 2; - } - this->actionFunc = EnDog_FollowPath; - } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.4f, 1.0f, 0.0f); -} - -void EnDog_FollowPlayer(EnDog* this, GlobalContext* globalCtx) { - f32 speed; - - if (gSaveContext.dogParams == 0) { - this->nextBehavior = DOG_SIT; - this->actionFunc = EnDog_Wait; - this->actor.speedXZ = 0.0f; - return; - } - - if (this->actor.xzDistToPlayer > 400.0f) { - if (this->nextBehavior != DOG_SIT && this->nextBehavior != DOG_SIT_2) { - this->nextBehavior = DOG_BOW; - } - gSaveContext.dogParams = 0; - speed = 0.0f; - } else if (this->actor.xzDistToPlayer > 100.0f) { - this->nextBehavior = DOG_RUN; - speed = 4.0f; - } else if (this->actor.xzDistToPlayer < 40.0f) { - if (this->nextBehavior != DOG_BOW && this->nextBehavior != DOG_BOW_2) { - this->nextBehavior = DOG_BOW; - } - speed = 0.0f; - } else { - this->nextBehavior = DOG_WALK; - speed = 1.0f; - } - - Math_ApproachF(&this->actor.speedXZ, speed, 0.6f, 1.0f); - - if (!(this->actor.xzDistToPlayer > 400.0f)) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 10, 1000, 1); - this->actor.shape.rot = this->actor.world.rot; - } -} - -void EnDog_RunAway(EnDog* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < 200.0f) { - Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.6f, 1.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, (this->actor.yawTowardsPlayer ^ 0x8000), 10, 1000, 1); - } else { - this->actionFunc = EnDog_FaceLink; - } - this->actor.shape.rot = this->actor.world.rot; -} - -void EnDog_FaceLink(EnDog* this, GlobalContext* globalCtx) { - s16 rotTowardLink; - s16 prevRotY; - f32 absAngleDiff; - - // if the dog is more than 200 units away from Link, turn to face him then wait - if (200.0f <= this->actor.xzDistToPlayer) { - this->nextBehavior = DOG_WALK; - - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.6f, 1.0f); - - rotTowardLink = this->actor.yawTowardsPlayer; - prevRotY = this->actor.world.rot.y; - Math_SmoothStepToS(&this->actor.world.rot.y, rotTowardLink, 10, 1000, 1); - - absAngleDiff = this->actor.world.rot.y; - absAngleDiff -= prevRotY; - absAngleDiff = fabsf(absAngleDiff); - if (absAngleDiff < 200.0f) { - this->nextBehavior = DOG_SIT; - this->actionFunc = EnDog_Wait; - this->actor.speedXZ = 0.0f; - } - } else { - this->nextBehavior = DOG_RUN; - this->actionFunc = EnDog_RunAway; - } - this->actor.shape.rot = this->actor.world.rot; -} - -void EnDog_Wait(EnDog* this, GlobalContext* globalCtx) { - this->unusedAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y); - - // If another dog is following Link and he gets within 200 units of waiting dog, run away - if ((gSaveContext.dogParams != 0) && (this->actor.xzDistToPlayer < 200.0f)) { - this->nextBehavior = DOG_RUN; - this->actionFunc = EnDog_RunAway; - } -} - -void EnDog_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDog* this = (EnDog*)thisx; - s32 pad; - - EnDog_PlayAnimAndSFX(this); - SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, this->collider.dim.radius, this->collider.dim.height * 0.5f, 0.0f, - 5); - Actor_MoveForward(&this->actor); - this->actionFunc(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnDog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - return false; -} - -void EnDog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { -} - -void EnDog_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDog* this = (EnDog*)thisx; - Color_RGBA8 colors[] = { { 255, 255, 200, 0 }, { 150, 100, 50, 0 } }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dog.c", 972); - - func_80093D18(globalCtx->state.gfxCtx); - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, colors[this->actor.params & 0xF].r, colors[this->actor.params & 0xF].g, - colors[this->actor.params & 0xF].b, colors[this->actor.params & 0xF].a); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnDog_OverrideLimbDraw, EnDog_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dog.c", 994); -} diff --git a/src/overlays/actors/ovl_En_Dog/z_en_dog.cpp b/src/overlays/actors/ovl_En_Dog/z_en_dog.cpp new file mode 100644 index 000000000..299697ce3 --- /dev/null +++ b/src/overlays/actors/ovl_En_Dog/z_en_dog.cpp @@ -0,0 +1,485 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DOG_Z_EN_DOG_C +#include "actor_common.h" +/* + * File: z_en_dog.c + * Overlay: ovl_En_Dog + * Description: Dog + */ + +#include "z_en_dog.h" +#include "objects/object_dog/object_dog.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_path.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void EnDog_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDog_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDog_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDog_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDog_FollowPath(EnDog* pthis, GlobalContext* globalCtx); +void EnDog_ChooseMovement(EnDog* pthis, GlobalContext* globalCtx); +void EnDog_FollowPlayer(EnDog* pthis, GlobalContext* globalCtx); +void EnDog_RunAway(EnDog* pthis, GlobalContext* globalCtx); +void EnDog_FaceLink(EnDog* pthis, GlobalContext* globalCtx); +void EnDog_Wait(EnDog* pthis, GlobalContext* globalCtx); + +ActorInit En_Dog_InitVars = { + ACTOR_EN_DOG, + ACTORCAT_NPC, + FLAGS, + OBJECT_DOG, + sizeof(EnDog), + (ActorFunc)EnDog_Init, + (ActorFunc)EnDog_Destroy, + (ActorFunc)EnDog_Update, + (ActorFunc)EnDog_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 16, 20, 0, { 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, 50 }; + +static struct_80034EC0_Entry sAnimations[] = { + { &gDogWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDogWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, + { &gDogRunAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, + { &gDogBarkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, + { &gDogSitAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, -6.0f }, + { &gDogSitAnim, 1.0f, 5.0f, 25.0f, ANIMMODE_LOOP_PARTIAL, -6.0f }, + { &gDogBowAnim, 1.0f, 0.0f, 6.0f, ANIMMODE_ONCE, -6.0f }, + { &gDogBow2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -6.0f }, +}; + +typedef enum { + /* 0x00 */ DOG_WALK, + /* 0x01 */ DOG_RUN, + /* 0x02 */ DOG_BARK, + /* 0x03 */ DOG_SIT, + /* 0x04 */ DOG_SIT_2, + /* 0x05 */ DOG_BOW, + /* 0x06 */ DOG_BOW_2 +} DogBehavior; + +void EnDog_PlayWalkSFX(EnDog* pthis) { + AnimationHeader* walk = &gDogWalkAnim; + + if (pthis->skelAnime.animation == walk) { + if ((pthis->skelAnime.curFrame == 1.0f) || (pthis->skelAnime.curFrame == 7.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHIBI_WALK); + } + } +} + +void EnDog_PlayRunSFX(EnDog* pthis) { + AnimationHeader* run = &gDogRunAnim; + + if (pthis->skelAnime.animation == run) { + if ((pthis->skelAnime.curFrame == 2.0f) || (pthis->skelAnime.curFrame == 4.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHIBI_WALK); + } + } +} + +void EnDog_PlayBarkSFX(EnDog* pthis) { + AnimationHeader* bark = &gDogBarkAnim; + + if (pthis->skelAnime.animation == bark) { + if ((pthis->skelAnime.curFrame == 13.0f) || (pthis->skelAnime.curFrame == 19.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SMALL_DOG_BARK); + } + } +} + +s32 EnDog_PlayAnimAndSFX(EnDog* pthis) { + s32 animation; + + if (pthis->behavior != pthis->nextBehavior) { + if (pthis->nextBehavior == DOG_SIT_2) { + pthis->nextBehavior = DOG_SIT; + } + if (pthis->nextBehavior == DOG_BOW_2) { + pthis->nextBehavior = DOG_BOW; + } + + pthis->behavior = pthis->nextBehavior; + switch (pthis->behavior) { + case DOG_WALK: + animation = 1; + break; + case DOG_RUN: + animation = 2; + break; + case DOG_BARK: + animation = 3; + break; + case DOG_SIT: + animation = 4; + break; + case DOG_BOW: + animation = 6; + break; + } + func_80034EC0(&pthis->skelAnime, sAnimations, animation); + } + + switch (pthis->behavior) { + case DOG_SIT: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 5); + pthis->behavior = pthis->nextBehavior = DOG_SIT_2; + } + break; + case DOG_BOW: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 7); + pthis->behavior = pthis->nextBehavior = DOG_BOW_2; + } + break; + case DOG_WALK: + EnDog_PlayWalkSFX(pthis); + break; + case DOG_RUN: + EnDog_PlayRunSFX(pthis); + break; + case DOG_BARK: + EnDog_PlayBarkSFX(pthis); + break; + } + return 0; +} + +s8 EnDog_CanFollow(EnDog* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + return 2; + } + + if (globalCtx->sceneNum == SCENE_MARKET_DAY) { + return 0; + } + + if (pthis->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + pthis->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + if (gSaveContext.dogParams != 0) { + return 0; + } + gSaveContext.dogParams = (pthis->actor.params & 0x7FFF); + return 1; + } + + return 0; +} + +s32 EnDog_UpdateWaypoint(EnDog* pthis, GlobalContext* globalCtx) { + s32 change; + + if (pthis->path == NULL) { + return 0; + } + + if (pthis->reverse) { + change = -1; + } else { + change = 1; + } + + pthis->waypoint += change; + + if (pthis->reverse) { + if (pthis->waypoint < 0) { + pthis->waypoint = pthis->path->count - 1; + } + } else { + if ((pthis->path->count - 1) < pthis->waypoint) { + pthis->waypoint = 0; + } + } + + return 1; +} + +s32 EnDog_Orient(EnDog* pthis, GlobalContext* globalCtx) { + s16 targetYaw; + f32 waypointDistSq; + + waypointDistSq = Path_OrientAndGetDistSq(&pthis->actor, pthis->path, pthis->waypoint, &targetYaw); + Math_SmoothStepToS(&pthis->actor.world.rot.y, targetYaw, 10, 1000, 1); + + if ((waypointDistSq > 0.0f) && (waypointDistSq < 1000.0f)) { + return EnDog_UpdateWaypoint(pthis, globalCtx); + } else { + return 0; + } +} + +void EnDog_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDog* pthis = (EnDog*)thisx; + s16 followingDog; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDogSkel, NULL, pthis->jointTable, pthis->morphTable, 13); + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + + if ((pthis->actor.params & 0x8000) == 0) { + pthis->actor.params = (pthis->actor.params & 0xF0FF) | ((((pthis->actor.params & 0x0F00) >> 8) + 1) << 8); + } + + followingDog = ((gSaveContext.dogParams & 0x0F00) >> 8); + if (followingDog == ((pthis->actor.params & 0x0F00) >> 8) && ((pthis->actor.params & 0x8000) == 0)) { + Actor_Kill(&pthis->actor); + return; + } + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, 0, &sColChkInfoInit); + Actor_SetScale(&pthis->actor, 0.0075f); + pthis->waypoint = 0; + pthis->actor.gravity = -1.0f; + pthis->path = Path_GetByIndex(globalCtx, (pthis->actor.params & 0x00F0) >> 4, 0xF); + + switch (globalCtx->sceneNum) { + case SCENE_MARKET_NIGHT: + if ((!gSaveContext.dogIsLost) && (((pthis->actor.params & 0x0F00) >> 8) == 1)) { + Actor_Kill(&pthis->actor); + } + break; + case SCENE_IMPA: // Richard's Home + if (!(pthis->actor.params & 0x8000)) { + if (!gSaveContext.dogIsLost) { + pthis->nextBehavior = DOG_SIT; + pthis->actionFunc = EnDog_Wait; + pthis->actor.speedXZ = 0.0f; + return; + } else { + Actor_Kill(&pthis->actor); + return; + } + } + break; + } + + if (pthis->actor.params & 0x8000) { + pthis->nextBehavior = DOG_WALK; + pthis->actionFunc = EnDog_FollowPlayer; + } else { + pthis->nextBehavior = DOG_SIT; + pthis->actionFunc = EnDog_ChooseMovement; + } +} + +void EnDog_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDog* pthis = (EnDog*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnDog_FollowPath(EnDog* pthis, GlobalContext* globalCtx) { + s32 behaviors[] = { DOG_SIT, DOG_BOW, DOG_BARK }; + s32 unused[] = { 40, 80, 20 }; + f32 speed; + s32 frame; + + if (EnDog_CanFollow(pthis, globalCtx) == 1) { + pthis->actionFunc = EnDog_FollowPlayer; + } + + if (DECR(pthis->behaviorTimer) != 0) { + if (pthis->nextBehavior == DOG_WALK) { + speed = 1.0f; + } else { + speed = 4.0f; + } + Math_SmoothStepToF(&pthis->actor.speedXZ, speed, 0.4f, 1.0f, 0.0f); + EnDog_Orient(pthis, globalCtx); + pthis->actor.shape.rot = pthis->actor.world.rot; + + // Used to change between two text boxes for Richard's owner in the Market Day scene + // depending on where he is on his path. En_Hy checks these event flags. + if (pthis->waypoint < 9) { + // Richard is close to her, text says something about his coat + gSaveContext.eventInf[3] |= 1; + } else { + // Richard is far, text says something about running fast + gSaveContext.eventInf[3] &= ~1; + } + } else { + frame = globalCtx->state.frames % 3; + pthis->nextBehavior = behaviors[frame]; + // no clue why they're using the behavior id to calculate timer. possibly meant to use the unused array? + pthis->behaviorTimer = Rand_S16Offset(60, behaviors[frame]); + pthis->actionFunc = EnDog_ChooseMovement; + } +} + +void EnDog_ChooseMovement(EnDog* pthis, GlobalContext* globalCtx) { + if (EnDog_CanFollow(pthis, globalCtx) == 1) { + pthis->actionFunc = EnDog_FollowPlayer; + } + + if (DECR(pthis->behaviorTimer) == 0) { + pthis->behaviorTimer = Rand_S16Offset(200, 100); + if (globalCtx->state.frames % 2) { + pthis->nextBehavior = DOG_WALK; + } else { + pthis->nextBehavior = DOG_RUN; + } + + if (pthis->nextBehavior == DOG_RUN) { + pthis->behaviorTimer /= 2; + } + pthis->actionFunc = EnDog_FollowPath; + } + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.4f, 1.0f, 0.0f); +} + +void EnDog_FollowPlayer(EnDog* pthis, GlobalContext* globalCtx) { + f32 speed; + + if (gSaveContext.dogParams == 0) { + pthis->nextBehavior = DOG_SIT; + pthis->actionFunc = EnDog_Wait; + pthis->actor.speedXZ = 0.0f; + return; + } + + if (pthis->actor.xzDistToPlayer > 400.0f) { + if (pthis->nextBehavior != DOG_SIT && pthis->nextBehavior != DOG_SIT_2) { + pthis->nextBehavior = DOG_BOW; + } + gSaveContext.dogParams = 0; + speed = 0.0f; + } else if (pthis->actor.xzDistToPlayer > 100.0f) { + pthis->nextBehavior = DOG_RUN; + speed = 4.0f; + } else if (pthis->actor.xzDistToPlayer < 40.0f) { + if (pthis->nextBehavior != DOG_BOW && pthis->nextBehavior != DOG_BOW_2) { + pthis->nextBehavior = DOG_BOW; + } + speed = 0.0f; + } else { + pthis->nextBehavior = DOG_WALK; + speed = 1.0f; + } + + Math_ApproachF(&pthis->actor.speedXZ, speed, 0.6f, 1.0f); + + if (!(pthis->actor.xzDistToPlayer > 400.0f)) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 10, 1000, 1); + pthis->actor.shape.rot = pthis->actor.world.rot; + } +} + +void EnDog_RunAway(EnDog* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer < 200.0f) { + Math_ApproachF(&pthis->actor.speedXZ, 4.0f, 0.6f, 1.0f); + Math_SmoothStepToS(&pthis->actor.world.rot.y, (pthis->actor.yawTowardsPlayer ^ 0x8000), 10, 1000, 1); + } else { + pthis->actionFunc = EnDog_FaceLink; + } + pthis->actor.shape.rot = pthis->actor.world.rot; +} + +void EnDog_FaceLink(EnDog* pthis, GlobalContext* globalCtx) { + s16 rotTowardLink; + s16 prevRotY; + f32 absAngleDiff; + + // if the dog is more than 200 units away from Link, turn to face him then wait + if (200.0f <= pthis->actor.xzDistToPlayer) { + pthis->nextBehavior = DOG_WALK; + + Math_ApproachF(&pthis->actor.speedXZ, 1.0f, 0.6f, 1.0f); + + rotTowardLink = pthis->actor.yawTowardsPlayer; + prevRotY = pthis->actor.world.rot.y; + Math_SmoothStepToS(&pthis->actor.world.rot.y, rotTowardLink, 10, 1000, 1); + + absAngleDiff = pthis->actor.world.rot.y; + absAngleDiff -= prevRotY; + absAngleDiff = fabsf(absAngleDiff); + if (absAngleDiff < 200.0f) { + pthis->nextBehavior = DOG_SIT; + pthis->actionFunc = EnDog_Wait; + pthis->actor.speedXZ = 0.0f; + } + } else { + pthis->nextBehavior = DOG_RUN; + pthis->actionFunc = EnDog_RunAway; + } + pthis->actor.shape.rot = pthis->actor.world.rot; +} + +void EnDog_Wait(EnDog* pthis, GlobalContext* globalCtx) { + pthis->unusedAngle = (pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y); + + // If another dog is following Link and he gets within 200 units of waiting dog, run away + if ((gSaveContext.dogParams != 0) && (pthis->actor.xzDistToPlayer < 200.0f)) { + pthis->nextBehavior = DOG_RUN; + pthis->actionFunc = EnDog_RunAway; + } +} + +void EnDog_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDog* pthis = (EnDog*)thisx; + s32 pad; + + EnDog_PlayAnimAndSFX(pthis); + SkelAnime_Update(&pthis->skelAnime); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, pthis->collider.dim.radius, pthis->collider.dim.height * 0.5f, 0.0f, + 5); + Actor_MoveForward(&pthis->actor); + pthis->actionFunc(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnDog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + return false; +} + +void EnDog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +} + +void EnDog_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDog* pthis = (EnDog*)thisx; + Color_RGBA8 colors[] = { { 255, 255, 200, 0 }, { 150, 100, 50, 0 } }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_dog.c", 972); + + func_80093D18(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, colors[pthis->actor.params & 0xF].r, colors[pthis->actor.params & 0xF].g, + colors[pthis->actor.params & 0xF].b, colors[pthis->actor.params & 0xF].a); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnDog_OverrideLimbDraw, EnDog_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_dog.c", 994); +} diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.cpp similarity index 52% rename from src/overlays/actors/ovl_En_Door/z_en_door.c rename to src/overlays/actors/ovl_En_Door/z_en_door.cpp index ab54c9943..a04c60190 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.cpp @@ -34,16 +34,16 @@ void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnDoor_SetupType(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_Idle(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_WaitForCheck(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_Check(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_AjarWait(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_AjarOpen(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_AjarClose(EnDoor* this, GlobalContext* globalCtx); -void EnDoor_Open(EnDoor* this, GlobalContext* globalCtx); +void EnDoor_SetupType(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_Idle(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_WaitForCheck(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_Check(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_AjarWait(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_AjarOpen(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_AjarClose(EnDoor* pthis, GlobalContext* globalCtx); +void EnDoor_Open(EnDoor* pthis, GlobalContext* globalCtx); -const ActorInit En_Door_InitVars = { +ActorInit En_Door_InitVars = { ACTOR_EN_DOOR, ACTORCAT_DOOR, FLAGS, @@ -63,7 +63,7 @@ static EnDoorInfo sDoorInfo[] = { { SCENE_MIZUSIN, 2, OBJECT_MIZU_OBJECTS }, { SCENE_HAKADAN, 3, OBJECT_HAKA_DOOR }, { SCENE_HAKADANCH, 3, OBJECT_HAKA_DOOR }, - // KEEP objects should remain last and in this order + // KEEP objects should remain last and in pthis order { -1, 0, OBJECT_GAMEPLAY_KEEP }, { -1, 4, OBJECT_GAMEPLAY_FIELD_KEEP }, }; @@ -89,7 +89,7 @@ static Gfx* D_809FCEE4[5][2] = { void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnDoor* this = (EnDoor*)thisx; + EnDoor* pthis = (EnDoor*)thisx; EnDoorInfo* objectInfo; s32 i; s32 objBankIndex; @@ -97,8 +97,8 @@ void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { f32 zOffset; objectInfo = &sDoorInfo[0]; - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDoorSkel, &gDoor3Anim, this->jointTable, this->morphTable, 5); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDoorSkel, &gDoor3Anim, pthis->jointTable, pthis->morphTable, 5); for (i = 0; i < ARRAY_COUNT(sDoorInfo) - 2; i++, objectInfo++) { if (globalCtx->sceneNum == objectInfo->sceneNum) { break; @@ -108,116 +108,116 @@ void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { objectInfo++; } - this->dListIndex = objectInfo->dListIndex; + pthis->dListIndex = objectInfo->dListIndex; objBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); if (objBankIndex < 0) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->requiredObjBankIndex = objBankIndex; - this->dListIndex = objectInfo->dListIndex; - if (this->actor.objBankIndex == this->requiredObjBankIndex) { - EnDoor_SetupType(this, globalCtx); + pthis->requiredObjBankIndex = objBankIndex; + pthis->dListIndex = objectInfo->dListIndex; + if (pthis->actor.objBankIndex == pthis->requiredObjBankIndex) { + EnDoor_SetupType(pthis, globalCtx); } else { - this->actionFunc = EnDoor_SetupType; + pthis->actionFunc = EnDoor_SetupType; } // Double doors - if (this->actor.params & 0x40) { + if (pthis->actor.params & 0x40) { EnDoor* other; - xOffset = Math_CosS(this->actor.shape.rot.y) * 30.0f; - zOffset = Math_SinS(this->actor.shape.rot.y) * 30.0f; - other = (EnDoor*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_DOOR, - this->actor.world.pos.x + xOffset, this->actor.world.pos.y, - this->actor.world.pos.z - zOffset, 0, this->actor.shape.rot.y + 0x8000, 0, - this->actor.params & ~0x40); + xOffset = Math_CosS(pthis->actor.shape.rot.y) * 30.0f; + zOffset = Math_SinS(pthis->actor.shape.rot.y) * 30.0f; + other = (EnDoor*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_DOOR, + pthis->actor.world.pos.x + xOffset, pthis->actor.world.pos.y, + pthis->actor.world.pos.z - zOffset, 0, pthis->actor.shape.rot.y + 0x8000, 0, + pthis->actor.params & ~0x40); if (other != NULL) { other->unk_192 = 1; } - this->actor.world.pos.x -= xOffset; - this->actor.world.pos.z += zOffset; + pthis->actor.world.pos.x -= xOffset; + pthis->actor.world.pos.z += zOffset; } - Actor_SetFocus(&this->actor, 70.0f); + Actor_SetFocus(&pthis->actor, 70.0f); } void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { TransitionActorEntry* transitionEntry; - EnDoor* this = (EnDoor*)thisx; + EnDoor* pthis = (EnDoor*)thisx; - transitionEntry = &globalCtx->transiActorCtx.list[(u16)this->actor.params >> 0xA]; + transitionEntry = &globalCtx->transiActorCtx.list[(u16)pthis->actor.params >> 0xA]; if (transitionEntry->id < 0) { transitionEntry->id = -transitionEntry->id; } } -void EnDoor_SetupType(EnDoor* this, GlobalContext* globalCtx) { +void EnDoor_SetupType(EnDoor* pthis, GlobalContext* globalCtx) { s32 doorType; - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { - doorType = this->actor.params >> 7 & 7; - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->requiredObjBankIndex; - this->actionFunc = EnDoor_Idle; + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->requiredObjBankIndex)) { + doorType = pthis->actor.params >> 7 & 7; + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.objBankIndex = pthis->requiredObjBankIndex; + pthis->actionFunc = EnDoor_Idle; if (doorType == DOOR_EVENING) { doorType = (gSaveContext.dayTime > 0xC000 && gSaveContext.dayTime < 0xE000) ? DOOR_SCENEEXIT : DOOR_CHECKABLE; } - this->actor.world.rot.y = 0x0000; + pthis->actor.world.rot.y = 0x0000; if (doorType == DOOR_LOCKED) { - if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x3F)) { - this->lockTimer = 10; + if (!Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F)) { + pthis->lockTimer = 10; } } else if (doorType == DOOR_AJAR) { - if (Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor) > DOOR_AJAR_SLAM_RANGE) { - this->actionFunc = EnDoor_AjarWait; - this->actor.world.rot.y = -0x1800; + if (Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) > DOOR_AJAR_SLAM_RANGE) { + pthis->actionFunc = EnDoor_AjarWait; + pthis->actor.world.rot.y = -0x1800; } } else if (doorType == DOOR_CHECKABLE) { - this->actor.textId = (this->actor.params & 0x3F) + 0x0200; - if (this->actor.textId == 0x0229 && !(gSaveContext.eventChkInf[1] & 0x10)) { + pthis->actor.textId = (pthis->actor.params & 0x3F) + 0x0200; + if (pthis->actor.textId == 0x0229 && !(gSaveContext.eventChkInf[1] & 0x10)) { // Talon's house door. If Talon has not been woken up at Hyrule Castle - // this door should be openable at any time of day. Note that there is no + // pthis door should be openable at any time of day. Note that there is no // check for time of day as the scene setup for Lon Lon merely initializes // the door with a different text id between day and night setups doorType = DOOR_SCENEEXIT; } else { - this->actionFunc = EnDoor_WaitForCheck; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_27; + pthis->actionFunc = EnDoor_WaitForCheck; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_27; } } // Replace the door type it was loaded with by the new type - this->actor.params = (this->actor.params & ~0x380) | (doorType << 7); + pthis->actor.params = (pthis->actor.params & ~0x380) | (doorType << 7); } } -void EnDoor_Idle(EnDoor* this, GlobalContext* globalCtx) { +void EnDoor_Idle(EnDoor* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 doorType; Vec3f playerPosRelToDoor; s16 phi_v0; - doorType = this->actor.params >> 7 & 7; - func_8002DBD0(&this->actor, &playerPosRelToDoor, &player->actor.world.pos); - if (this->playerIsOpening != 0) { - this->actionFunc = EnDoor_Open; - Animation_PlayOnceSetSpeed(&this->skelAnime, D_809FCECC[this->animStyle], + doorType = pthis->actor.params >> 7 & 7; + func_8002DBD0(&pthis->actor, &playerPosRelToDoor, &player->actor.world.pos); + if (pthis->playerIsOpening != 0) { + pthis->actionFunc = EnDoor_Open; + Animation_PlayOnceSetSpeed(&pthis->skelAnime, D_809FCECC[pthis->animStyle], (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); - if (this->lockTimer != 0) { + if (pthis->lockTimer != 0) { gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; - Flags_SetSwitch(globalCtx, this->actor.params & 0x3F); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + Flags_SetSwitch(globalCtx, pthis->actor.params & 0x3F); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } } else if (!Player_InCsMode(globalCtx)) { if (fabsf(playerPosRelToDoor.y) < 20.0f && fabsf(playerPosRelToDoor.x) < 20.0f && fabsf(playerPosRelToDoor.z) < 50.0f) { - phi_v0 = player->actor.shape.rot.y - this->actor.shape.rot.y; + phi_v0 = player->actor.shape.rot.y - pthis->actor.shape.rot.y; if (playerPosRelToDoor.z > 0.0f) { phi_v0 = 0x8000 - phi_v0; } if (ABS(phi_v0) < 0x3000) { - if (this->lockTimer != 0) { + if (pthis->lockTimer != 0) { if (gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] <= 0) { Player* player2 = GET_PLAYER(globalCtx); @@ -229,70 +229,70 @@ void EnDoor_Idle(EnDoor* this, GlobalContext* globalCtx) { } player->doorType = (doorType == DOOR_AJAR) ? PLAYER_DOORTYPE_AJAR : PLAYER_DOORTYPE_HANDLE; player->doorDirection = (playerPosRelToDoor.z >= 0.0f) ? 1.0f : -1.0f; - player->doorActor = &this->actor; + player->doorActor = &pthis->actor; } - } else if (doorType == DOOR_AJAR && this->actor.xzDistToPlayer > DOOR_AJAR_OPEN_RANGE) { - this->actionFunc = EnDoor_AjarOpen; + } else if (doorType == DOOR_AJAR && pthis->actor.xzDistToPlayer > DOOR_AJAR_OPEN_RANGE) { + pthis->actionFunc = EnDoor_AjarOpen; } } } -void EnDoor_WaitForCheck(EnDoor* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnDoor_Check; +void EnDoor_WaitForCheck(EnDoor* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDoor_Check; } else { - func_8002F2CC(&this->actor, globalCtx, DOOR_CHECK_RANGE); + func_8002F2CC(&pthis->actor, globalCtx, DOOR_CHECK_RANGE); } } -void EnDoor_Check(EnDoor* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnDoor_WaitForCheck; +void EnDoor_Check(EnDoor* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDoor_WaitForCheck; } } -void EnDoor_AjarWait(EnDoor* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < DOOR_AJAR_SLAM_RANGE) { - this->actionFunc = EnDoor_AjarClose; +void EnDoor_AjarWait(EnDoor* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer < DOOR_AJAR_SLAM_RANGE) { + pthis->actionFunc = EnDoor_AjarClose; } } -void EnDoor_AjarOpen(EnDoor* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < DOOR_AJAR_SLAM_RANGE) { - this->actionFunc = EnDoor_AjarClose; - } else if (Math_ScaledStepToS(&this->actor.world.rot.y, -0x1800, 0x100)) { - this->actionFunc = EnDoor_AjarWait; +void EnDoor_AjarOpen(EnDoor* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer < DOOR_AJAR_SLAM_RANGE) { + pthis->actionFunc = EnDoor_AjarClose; + } else if (Math_ScaledStepToS(&pthis->actor.world.rot.y, -0x1800, 0x100)) { + pthis->actionFunc = EnDoor_AjarWait; } } -void EnDoor_AjarClose(EnDoor* this, GlobalContext* globalCtx) { - if (Math_ScaledStepToS(&this->actor.world.rot.y, 0, 0x700)) { - this->actionFunc = EnDoor_Idle; +void EnDoor_AjarClose(EnDoor* pthis, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, 0, 0x700)) { + pthis->actionFunc = EnDoor_Idle; } } -void EnDoor_Open(EnDoor* this, GlobalContext* globalCtx) { +void EnDoor_Open(EnDoor* pthis, GlobalContext* globalCtx) { s32 i; s32 numEffects; - if (DECR(this->lockTimer) == 0) { - if (SkelAnime_Update(&this->skelAnime)) { - this->actionFunc = EnDoor_Idle; - this->playerIsOpening = 0; - } else if (Animation_OnFrame(&this->skelAnime, sDoorAnimOpenFrames[this->animStyle])) { - Audio_PlayActorSound2(&this->actor, + if (DECR(pthis->lockTimer) == 0) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actionFunc = EnDoor_Idle; + pthis->playerIsOpening = 0; + } else if (Animation_OnFrame(&pthis->skelAnime, sDoorAnimOpenFrames[pthis->animStyle])) { + Audio_PlayActorSound2(&pthis->actor, (globalCtx->sceneNum == SCENE_HAKADAN || globalCtx->sceneNum == SCENE_HAKADANCH || globalCtx->sceneNum == SCENE_HIDAN) ? NA_SE_EV_IRON_DOOR_OPEN : NA_SE_OC_DOOR_OPEN); - if (this->skelAnime.playSpeed < 1.5f) { + if (pthis->skelAnime.playSpeed < 1.5f) { numEffects = (s32)(Rand_ZeroOne() * 30.0f) + 50; for (i = 0; i < numEffects; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 60.0f, 100.0f, 50.0f, 0.15f); + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 60.0f, 100.0f, 50.0f, 0.15f); } } - } else if (Animation_OnFrame(&this->skelAnime, sDoorAnimCloseFrames[this->animStyle])) { - Audio_PlayActorSound2(&this->actor, + } else if (Animation_OnFrame(&pthis->skelAnime, sDoorAnimCloseFrames[pthis->animStyle])) { + Audio_PlayActorSound2(&pthis->actor, (globalCtx->sceneNum == SCENE_HAKADAN || globalCtx->sceneNum == SCENE_HAKADANCH || globalCtx->sceneNum == SCENE_HIDAN) ? NA_SE_EV_IRON_DOOR_CLOSE @@ -302,9 +302,9 @@ void EnDoor_Open(EnDoor* this, GlobalContext* globalCtx) { } void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDoor* this = (EnDoor*)thisx; + EnDoor* pthis = (EnDoor*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { @@ -314,20 +314,20 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList s32 pad2; s16 phi_v0_2; s32 phi_v0; - EnDoor* this = (EnDoor*)thisx; + EnDoor* pthis = (EnDoor*)thisx; if (limbIndex == 4) { - temp_a2 = D_809FCEE4[this->dListIndex]; - transitionEntry = &globalCtx->transiActorCtx.list[(u16)this->actor.params >> 0xA]; - rot->z += this->actor.world.rot.y; + temp_a2 = D_809FCEE4[pthis->dListIndex]; + transitionEntry = &globalCtx->transiActorCtx.list[(u16)pthis->actor.params >> 0xA]; + rot->z += pthis->actor.world.rot.y; if ((globalCtx->roomCtx.prevRoom.num >= 0) || (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { - phi_v0_2 = ((this->actor.shape.rot.y + this->skelAnime.jointTable[3].z) + rot->z) - - Math_Vec3f_Yaw(&globalCtx->view.eye, &this->actor.world.pos); + phi_v0_2 = ((pthis->actor.shape.rot.y + pthis->skelAnime.jointTable[3].z) + rot->z) - + Math_Vec3f_Yaw(&globalCtx->view.eye, &pthis->actor.world.pos); *dList = (ABS(phi_v0_2) < 0x4000) ? temp_a2[0] : temp_a2[1]; } else { - phi_v0 = this->unk_192; - if (transitionEntry->sides[0].room != this->actor.room) { + phi_v0 = pthis->unk_192; + if (transitionEntry->sides[0].room != pthis->actor.room) { phi_v0 ^= 1; } *dList = temp_a2[phi_v0]; @@ -337,24 +337,24 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDoor* this = (EnDoor*)thisx; + EnDoor* pthis = (EnDoor*)thisx; - if (this->actor.objBankIndex == this->requiredObjBankIndex) { + if (pthis->actor.objBankIndex == pthis->requiredObjBankIndex) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_door.c", 910); func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDoor_OverrideLimbDraw, - NULL, &this->actor); - if (this->actor.world.rot.y != 0) { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnDoor_OverrideLimbDraw, + NULL, &pthis->actor); + if (pthis->actor.world.rot.y != 0) { if (1) {} - if (this->actor.world.rot.y > 0) { + if (pthis->actor.world.rot.y > 0) { gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); } else { gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); } } - if (this->lockTimer != 0) { - Actor_DrawDoorLock(globalCtx, this->lockTimer, DOORLOCK_NORMAL); + if (pthis->lockTimer != 0) { + Actor_DrawDoorLock(globalCtx, pthis->lockTimer, DOORLOCK_NORMAL); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_door.c", 941); diff --git a/src/overlays/actors/ovl_En_Ds/z_en_ds.c b/src/overlays/actors/ovl_En_Ds/z_en_ds.c deleted file mode 100644 index 020022ad1..000000000 --- a/src/overlays/actors/ovl_En_Ds/z_en_ds.c +++ /dev/null @@ -1,291 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DS_Z_EN_DS_C -#include "actor_common.h" -/* - * File: z_en_ds.c - * Overlay: ovl_En_Ds - * Description: Potion Shop Granny - */ - -#include "z_en_ds.h" -#include "objects/object_ds/object_ds.h" -#include "def/code_800F7260.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnDs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDs_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnDs_Wait(EnDs* this, GlobalContext* globalCtx); - -const ActorInit En_Ds_InitVars = { - ACTOR_EN_DS, - ACTORCAT_NPC, - FLAGS, - OBJECT_DS, - sizeof(EnDs), - (ActorFunc)EnDs_Init, - (ActorFunc)EnDs_Destroy, - (ActorFunc)EnDs_Update, - (ActorFunc)EnDs_Draw, -}; - -void EnDs_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDs* this = (EnDs*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gPotionShopLadySkel, &gPotionShopLadyAnim, this->jointTable, - this->morphTable, 6); - Animation_PlayOnce(&this->skelAnime, &gPotionShopLadyAnim); - - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - - Actor_SetScale(&this->actor, 0.013f); - - this->actionFunc = EnDs_Wait; - this->actor.targetMode = 1; - this->unk_1E8 = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_1E4 = 0.0f; -} - -void EnDs_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnDs_Talk(EnDs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnDs_Wait; - this->actor.flags &= ~ACTOR_FLAG_16; - } - this->unk_1E8 |= 1; -} - -void EnDs_TalkNoEmptyBottle(EnDs* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = EnDs_Wait; - } - this->unk_1E8 |= 1; -} - -void EnDs_TalkAfterGiveOddPotion(EnDs* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnDs_Talk; - } else { - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2CC(&this->actor, globalCtx, 1000.0f); - } -} - -void EnDs_DisplayOddPotionText(EnDs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.textId = 0x504F; - this->actionFunc = EnDs_TalkAfterGiveOddPotion; - this->actor.flags &= ~ACTOR_FLAG_8; - gSaveContext.itemGetInf[3] |= 1; - } -} - -void EnDs_GiveOddPotion(EnDs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnDs_DisplayOddPotionText; - gSaveContext.timer2State = 0; - } else { - func_8002F434(&this->actor, globalCtx, GI_ODD_POTION, 10000.0f, 50.0f); - } -} - -void EnDs_TalkAfterBrewOddPotion(EnDs* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = EnDs_GiveOddPotion; - func_8002F434(&this->actor, globalCtx, GI_ODD_POTION, 10000.0f, 50.0f); - } -} - -void EnDs_BrewOddPotion3(EnDs* this, GlobalContext* globalCtx) { - if (this->brewTimer > 0) { - this->brewTimer -= 1; - } else { - this->actionFunc = EnDs_TalkAfterBrewOddPotion; - Message_ContinueTextbox(globalCtx, 0x504D); - } - - Math_StepToF(&this->unk_1E4, 0, 0.03f); - Environment_AdjustLights(globalCtx, this->unk_1E4 * (2.0f - this->unk_1E4), 0.0f, 0.1f, 1.0f); -} - -void EnDs_BrewOddPotion2(EnDs* this, GlobalContext* globalCtx) { - if (this->brewTimer > 0) { - this->brewTimer -= 1; - } else { - this->actionFunc = EnDs_BrewOddPotion3; - this->brewTimer = 60; - Flags_UnsetSwitch(globalCtx, 0x3F); - } -} - -void EnDs_BrewOddPotion1(EnDs* this, GlobalContext* globalCtx) { - if (this->brewTimer > 0) { - this->brewTimer -= 1; - } else { - this->actionFunc = EnDs_BrewOddPotion2; - this->brewTimer = 20; - } - - Math_StepToF(&this->unk_1E4, 1.0f, 0.01f); - Environment_AdjustLights(globalCtx, this->unk_1E4 * (2.0f - this->unk_1E4), 0.0f, 0.1f, 1.0f); -} - -void EnDs_OfferOddPotion(EnDs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - this->actionFunc = EnDs_BrewOddPotion1; - this->brewTimer = 60; - Flags_SetSwitch(globalCtx, 0x3F); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - player->exchangeItemId = EXCH_ITEM_NONE; - break; - case 1: // no - Message_ContinueTextbox(globalCtx, 0x504C); - this->actionFunc = EnDs_Talk; - } - } -} - -s32 EnDs_CheckRupeesAndBottle() { - if (gSaveContext.rupees < 100) { - return 0; - } else if (Inventory_HasEmptyBottle() == 0) { - return 1; - } else { - return 2; - } -} - -void EnDs_GiveBluePotion(EnDs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnDs_Talk; - } else { - func_8002F434(&this->actor, globalCtx, GI_POTION_BLUE, 10000.0f, 50.0f); - } -} - -void EnDs_OfferBluePotion(EnDs* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - switch (EnDs_CheckRupeesAndBottle()) { - case 0: // have less than 100 rupees - Message_ContinueTextbox(globalCtx, 0x500E); - break; - case 1: // have 100 rupees but no empty bottle - Message_ContinueTextbox(globalCtx, 0x96); - this->actionFunc = EnDs_TalkNoEmptyBottle; - return; - case 2: // have 100 rupees and empty bottle - Rupees_ChangeBy(-100); - this->actor.flags &= ~ACTOR_FLAG_16; - func_8002F434(&this->actor, globalCtx, GI_POTION_BLUE, 10000.0f, 50.0f); - this->actionFunc = EnDs_GiveBluePotion; - return; - } - break; - case 1: // no - Message_ContinueTextbox(globalCtx, 0x500D); - } - this->actionFunc = EnDs_Talk; - } -} - -void EnDs_Wait(EnDs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (func_8002F368(globalCtx) == EXCH_ITEM_ODD_MUSHROOM) { - Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - player->actor.textId = 0x504A; - this->actionFunc = EnDs_OfferOddPotion; - } else if (gSaveContext.itemGetInf[3] & 1) { - player->actor.textId = 0x500C; - this->actionFunc = EnDs_OfferBluePotion; - } else { - if (INV_CONTENT(ITEM_ODD_MUSHROOM) == ITEM_ODD_MUSHROOM) { - player->actor.textId = 0x5049; - } else { - player->actor.textId = 0x5048; - } - this->actionFunc = EnDs_Talk; - } - } else { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - this->actor.textId = 0x5048; - - if ((ABS(yawDiff) < 0x2151) && (this->actor.xzDistToPlayer < 200.0f)) { - func_8002F298(&this->actor, globalCtx, 100.0f, EXCH_ITEM_ODD_MUSHROOM); - this->unk_1E8 |= 1; - } - } -} - -void EnDs_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDs* this = (EnDs*)thisx; - - if (SkelAnime_Update(&this->skelAnime) != 0) { - this->skelAnime.curFrame = 0.0f; - } - - this->actionFunc(this, globalCtx); - - if (this->unk_1E8 & 1) { - func_80038290(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->unk_1D8.x, 0, 6, 0x1838, 100); - Math_SmoothStepToS(&this->unk_1D8.y, 0, 6, 0x1838, 100); - Math_SmoothStepToS(&this->unk_1DE.x, 0, 6, 0x1838, 100); - Math_SmoothStepToS(&this->unk_1DE.y, 0, 6, 0x1838, 100); - } -} - -s32 EnDs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnDs* this = (EnDs*)thisx; - - if (limbIndex == 5) { - rot->x += this->unk_1D8.y; - rot->z += this->unk_1D8.x; - } - return false; -} - -void EnDs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f sMultVec = { 1100.0f, 500.0f, 0.0f }; - EnDs* this = (EnDs*)thisx; - - if (limbIndex == 5) { - Matrix_MultVec3f(&sMultVec, &this->actor.focus.pos); - } -} - -void EnDs_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnDs* this = (EnDs*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnDs_OverrideLimbDraw, EnDs_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Ds/z_en_ds.cpp b/src/overlays/actors/ovl_En_Ds/z_en_ds.cpp new file mode 100644 index 000000000..fd331cd79 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ds/z_en_ds.cpp @@ -0,0 +1,291 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_DS_Z_EN_DS_C +#include "actor_common.h" +/* + * File: z_en_ds.c + * Overlay: ovl_En_Ds + * Description: Potion Shop Granny + */ + +#include "z_en_ds.h" +#include "objects/object_ds/object_ds.h" +#include "def/code_800F7260.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnDs_Init(Actor* thisx, GlobalContext* globalCtx); +void EnDs_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnDs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDs_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnDs_Wait(EnDs* pthis, GlobalContext* globalCtx); + +ActorInit En_Ds_InitVars = { + ACTOR_EN_DS, + ACTORCAT_NPC, + FLAGS, + OBJECT_DS, + sizeof(EnDs), + (ActorFunc)EnDs_Init, + (ActorFunc)EnDs_Destroy, + (ActorFunc)EnDs_Update, + (ActorFunc)EnDs_Draw, +}; + +void EnDs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDs* pthis = (EnDs*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gPotionShopLadySkel, &gPotionShopLadyAnim, pthis->jointTable, + pthis->morphTable, 6); + Animation_PlayOnce(&pthis->skelAnime, &gPotionShopLadyAnim); + + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + + Actor_SetScale(&pthis->actor, 0.013f); + + pthis->actionFunc = EnDs_Wait; + pthis->actor.targetMode = 1; + pthis->unk_1E8 = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_1E4 = 0.0f; +} + +void EnDs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnDs_Talk(EnDs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDs_Wait; + pthis->actor.flags &= ~ACTOR_FLAG_16; + } + pthis->unk_1E8 |= 1; +} + +void EnDs_TalkNoEmptyBottle(EnDs* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnDs_Wait; + } + pthis->unk_1E8 |= 1; +} + +void EnDs_TalkAfterGiveOddPotion(EnDs* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnDs_Talk; + } else { + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2CC(&pthis->actor, globalCtx, 1000.0f); + } +} + +void EnDs_DisplayOddPotionText(EnDs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actor.textId = 0x504F; + pthis->actionFunc = EnDs_TalkAfterGiveOddPotion; + pthis->actor.flags &= ~ACTOR_FLAG_8; + gSaveContext.itemGetInf[3] |= 1; + } +} + +void EnDs_GiveOddPotion(EnDs* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnDs_DisplayOddPotionText; + gSaveContext.timer2State = 0; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_ODD_POTION, 10000.0f, 50.0f); + } +} + +void EnDs_TalkAfterBrewOddPotion(EnDs* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnDs_GiveOddPotion; + func_8002F434(&pthis->actor, globalCtx, GI_ODD_POTION, 10000.0f, 50.0f); + } +} + +void EnDs_BrewOddPotion3(EnDs* pthis, GlobalContext* globalCtx) { + if (pthis->brewTimer > 0) { + pthis->brewTimer -= 1; + } else { + pthis->actionFunc = EnDs_TalkAfterBrewOddPotion; + Message_ContinueTextbox(globalCtx, 0x504D); + } + + Math_StepToF(&pthis->unk_1E4, 0, 0.03f); + Environment_AdjustLights(globalCtx, pthis->unk_1E4 * (2.0f - pthis->unk_1E4), 0.0f, 0.1f, 1.0f); +} + +void EnDs_BrewOddPotion2(EnDs* pthis, GlobalContext* globalCtx) { + if (pthis->brewTimer > 0) { + pthis->brewTimer -= 1; + } else { + pthis->actionFunc = EnDs_BrewOddPotion3; + pthis->brewTimer = 60; + Flags_UnsetSwitch(globalCtx, 0x3F); + } +} + +void EnDs_BrewOddPotion1(EnDs* pthis, GlobalContext* globalCtx) { + if (pthis->brewTimer > 0) { + pthis->brewTimer -= 1; + } else { + pthis->actionFunc = EnDs_BrewOddPotion2; + pthis->brewTimer = 20; + } + + Math_StepToF(&pthis->unk_1E4, 1.0f, 0.01f); + Environment_AdjustLights(globalCtx, pthis->unk_1E4 * (2.0f - pthis->unk_1E4), 0.0f, 0.1f, 1.0f); +} + +void EnDs_OfferOddPotion(EnDs* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + pthis->actionFunc = EnDs_BrewOddPotion1; + pthis->brewTimer = 60; + Flags_SetSwitch(globalCtx, 0x3F); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + player->exchangeItemId = EXCH_ITEM_NONE; + break; + case 1: // no + Message_ContinueTextbox(globalCtx, 0x504C); + pthis->actionFunc = EnDs_Talk; + } + } +} + +s32 EnDs_CheckRupeesAndBottle() { + if (gSaveContext.rupees < 100) { + return 0; + } else if (Inventory_HasEmptyBottle() == 0) { + return 1; + } else { + return 2; + } +} + +void EnDs_GiveBluePotion(EnDs* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnDs_Talk; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_POTION_BLUE, 10000.0f, 50.0f); + } +} + +void EnDs_OfferBluePotion(EnDs* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + switch (EnDs_CheckRupeesAndBottle()) { + case 0: // have less than 100 rupees + Message_ContinueTextbox(globalCtx, 0x500E); + break; + case 1: // have 100 rupees but no empty bottle + Message_ContinueTextbox(globalCtx, 0x96); + pthis->actionFunc = EnDs_TalkNoEmptyBottle; + return; + case 2: // have 100 rupees and empty bottle + Rupees_ChangeBy(-100); + pthis->actor.flags &= ~ACTOR_FLAG_16; + func_8002F434(&pthis->actor, globalCtx, GI_POTION_BLUE, 10000.0f, 50.0f); + pthis->actionFunc = EnDs_GiveBluePotion; + return; + } + break; + case 1: // no + Message_ContinueTextbox(globalCtx, 0x500D); + } + pthis->actionFunc = EnDs_Talk; + } +} + +void EnDs_Wait(EnDs* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (func_8002F368(globalCtx) == EXCH_ITEM_ODD_MUSHROOM) { + Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + player->actor.textId = 0x504A; + pthis->actionFunc = EnDs_OfferOddPotion; + } else if (gSaveContext.itemGetInf[3] & 1) { + player->actor.textId = 0x500C; + pthis->actionFunc = EnDs_OfferBluePotion; + } else { + if (INV_CONTENT(ITEM_ODD_MUSHROOM) == ITEM_ODD_MUSHROOM) { + player->actor.textId = 0x5049; + } else { + player->actor.textId = 0x5048; + } + pthis->actionFunc = EnDs_Talk; + } + } else { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + pthis->actor.textId = 0x5048; + + if ((ABS(yawDiff) < 0x2151) && (pthis->actor.xzDistToPlayer < 200.0f)) { + func_8002F298(&pthis->actor, globalCtx, 100.0f, EXCH_ITEM_ODD_MUSHROOM); + pthis->unk_1E8 |= 1; + } + } +} + +void EnDs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDs* pthis = (EnDs*)thisx; + + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + pthis->skelAnime.curFrame = 0.0f; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->unk_1E8 & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_1D8, &pthis->unk_1DE, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->unk_1D8.x, 0, 6, 0x1838, 100); + Math_SmoothStepToS(&pthis->unk_1D8.y, 0, 6, 0x1838, 100); + Math_SmoothStepToS(&pthis->unk_1DE.x, 0, 6, 0x1838, 100); + Math_SmoothStepToS(&pthis->unk_1DE.y, 0, 6, 0x1838, 100); + } +} + +s32 EnDs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnDs* pthis = (EnDs*)thisx; + + if (limbIndex == 5) { + rot->x += pthis->unk_1D8.y; + rot->z += pthis->unk_1D8.x; + } + return false; +} + +void EnDs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f sMultVec = { 1100.0f, 500.0f, 0.0f }; + EnDs* pthis = (EnDs*)thisx; + + if (limbIndex == 5) { + Matrix_MultVec3f(&sMultVec, &pthis->actor.focus.pos); + } +} + +void EnDs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDs* pthis = (EnDs*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnDs_OverrideLimbDraw, EnDs_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Du/z_en_du.c b/src/overlays/actors/ovl_En_Du/z_en_du.cpp similarity index 50% rename from src/overlays/actors/ovl_En_Du/z_en_du.c rename to src/overlays/actors/ovl_En_Du/z_en_du.cpp index 9a32c00f5..cb8580641 100644 --- a/src/overlays/actors/ovl_En_Du/z_en_du.c +++ b/src/overlays/actors/ovl_En_Du/z_en_du.cpp @@ -24,20 +24,20 @@ void EnDu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDu_Update(Actor* thisx, GlobalContext* globalCtx); void EnDu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809FE3B4(EnDu* this, GlobalContext* globalCtx); -void func_809FE3C0(EnDu* this, GlobalContext* globalCtx); -void func_809FE638(EnDu* this, GlobalContext* globalCtx); -void func_809FE890(EnDu* this, GlobalContext* globalCtx); -void func_809FE4A4(EnDu* this, GlobalContext* globalCtx); -void func_809FE6CC(EnDu* this, GlobalContext* globalCtx); -void func_809FE740(EnDu* this, GlobalContext* globalCtx); -void func_809FE798(EnDu* this, GlobalContext* globalCtx); -void func_809FEC14(EnDu* this, GlobalContext* globalCtx); -void func_809FEC70(EnDu* this, GlobalContext* globalCtx); -void func_809FECE4(EnDu* this, GlobalContext* globalCtx); -void func_809FEB08(EnDu* this, GlobalContext* globalCtx); +void func_809FE3B4(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE3C0(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE638(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE890(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE4A4(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE6CC(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE740(EnDu* pthis, GlobalContext* globalCtx); +void func_809FE798(EnDu* pthis, GlobalContext* globalCtx); +void func_809FEC14(EnDu* pthis, GlobalContext* globalCtx); +void func_809FEC70(EnDu* pthis, GlobalContext* globalCtx); +void func_809FECE4(EnDu* pthis, GlobalContext* globalCtx); +void func_809FEB08(EnDu* pthis, GlobalContext* globalCtx); -const ActorInit En_Du_InitVars = { +ActorInit En_Du_InitVars = { ACTOR_EN_DU, ACTORCAT_NPC, FLAGS, @@ -91,8 +91,8 @@ static struct_80034EC0_Entry sAnimations[] = { { &gDaruniaDancingEndAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -6.0f }, }; -void EnDu_SetupAction(EnDu* this, EnDuActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnDu_SetupAction(EnDu* pthis, EnDuActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } u16 func_809FDC38(GlobalContext* globalCtx, Actor* actor) { @@ -150,7 +150,7 @@ s16 func_809FDCDC(GlobalContext* globalCtx, Actor* actor) { return 1; } -s32 func_809FDDB4(EnDu* this, GlobalContext* globalCtx) { +s32 func_809FDDB4(EnDu* pthis, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_SPOT18 && LINK_IS_CHILD) { return 1; } else if (globalCtx->sceneNum == SCENE_HIDAN && !(gSaveContext.infTable[0x11] & 0x400) && LINK_IS_ADULT) { @@ -159,73 +159,73 @@ s32 func_809FDDB4(EnDu* this, GlobalContext* globalCtx) { return 0; } -void func_809FDE24(EnDu* this, GlobalContext* globalCtx) { +void func_809FDE24(EnDu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 phi_a3 = 0; - if (this->unk_1F4.unk_00 == 0) { + if (pthis->unk_1F4.unk_00 == 0) { phi_a3 = 1; } - if (this->actionFunc == func_809FE890) { + if (pthis->actionFunc == func_809FE890) { phi_a3 = 1; } - this->unk_1F4.unk_18 = player->actor.world.pos; - this->unk_1F4.unk_14 = 10.0f; - func_80034A14(&this->actor, &this->unk_1F4, 3, phi_a3); + pthis->unk_1F4.unk_18 = player->actor.world.pos; + pthis->unk_1F4.unk_14 = 10.0f; + func_80034A14(&pthis->actor, &pthis->unk_1F4, 3, phi_a3); } -void func_809FDE9C(EnDu* this) { - if (this->blinkTimer > 0) { - this->blinkTimer--; +void func_809FDE9C(EnDu* pthis) { + if (pthis->blinkTimer > 0) { + pthis->blinkTimer--; } else { - this->blinkTimer = 0; + pthis->blinkTimer = 0; } - if (this->blinkTimer < 3) { - this->eyeTexIndex = this->blinkTimer; + if (pthis->blinkTimer < 3) { + pthis->eyeTexIndex = pthis->blinkTimer; } - switch (this->unk_1EC) { + switch (pthis->unk_1EC) { case 0: - if (this->blinkTimer == 0) { - this->blinkTimer = Rand_S16Offset(30, 30); + if (pthis->blinkTimer == 0) { + pthis->blinkTimer = Rand_S16Offset(30, 30); } break; case 1: - if (this->blinkTimer == 0) { - this->eyeTexIndex = 2; + if (pthis->blinkTimer == 0) { + pthis->eyeTexIndex = 2; } break; case 2: - if (this->blinkTimer == 0) { - this->eyeTexIndex = 2; + if (pthis->blinkTimer == 0) { + pthis->eyeTexIndex = 2; } break; case 3: - if (this->blinkTimer == 0) { - this->eyeTexIndex = 0; + if (pthis->blinkTimer == 0) { + pthis->eyeTexIndex = 0; } break; } - switch (this->unk_1ED) { + switch (pthis->unk_1ED) { case 1: - this->mouthTexIndex = 1; + pthis->mouthTexIndex = 1; break; case 2: - this->mouthTexIndex = 2; + pthis->mouthTexIndex = 2; break; case 3: - this->mouthTexIndex = 3; + pthis->mouthTexIndex = 3; break; default: - this->mouthTexIndex = 0; + pthis->mouthTexIndex = 0; break; } - if (this->unk_1EE == 1) { - this->noseTexIndex = 1; + if (pthis->unk_1EE == 1) { + pthis->noseTexIndex = 1; } else { - this->noseTexIndex = 0; + pthis->noseTexIndex = 0; } } @@ -241,186 +241,186 @@ void func_809FE000(CsCmdActorAction* csAction, Vec3f* dst) { dst->z = csAction->endPos.z; } -void func_809FE040(EnDu* this) { +void func_809FE040(EnDu* pthis) { s32 animationIndices[] = { 8, 8, 8, 8, 9, 10, 10, 13 }; - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_1E6++; - if (this->unk_1E6 >= 8) { - this->unk_1E6 = 0; + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + pthis->unk_1E6++; + if (pthis->unk_1E6 >= 8) { + pthis->unk_1E6 = 0; } - func_80034EC0(&this->skelAnime, sAnimations, animationIndices[this->unk_1E6]); + func_80034EC0(&pthis->skelAnime, sAnimations, animationIndices[pthis->unk_1E6]); } } -void func_809FE104(EnDu* this) { +void func_809FE104(EnDu* pthis) { s32 animationIndices[] = { 8, 8, 11, 12 }; - if (this->unk_1E6 < 4) { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_1E6++; - if (this->unk_1E6 < 4) { - func_80034EC0(&this->skelAnime, sAnimations, animationIndices[this->unk_1E6]); + if (pthis->unk_1E6 < 4) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + pthis->unk_1E6++; + if (pthis->unk_1E6 < 4) { + func_80034EC0(&pthis->skelAnime, sAnimations, animationIndices[pthis->unk_1E6]); } } } } void EnDu_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDu* this = (EnDu*)thisx; + EnDu* pthis = (EnDu*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDaruniaSkel, NULL, 0, 0, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - if (func_809FDDB4(this, globalCtx) == 0) { - Actor_Kill(&this->actor); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDaruniaSkel, NULL, 0, 0, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + if (func_809FDDB4(pthis, globalCtx) == 0) { + Actor_Kill(&pthis->actor); return; } - func_80034EC0(&this->skelAnime, sAnimations, 0); - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 1; - this->unk_1F4.unk_00 = 0; + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 1; + pthis->unk_1F4.unk_00 = 0; if (gSaveContext.cutsceneIndex >= 0xFFF0) { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGoronCityDarunia01Cs); gSaveContext.cutsceneTrigger = 1; - EnDu_SetupAction(this, func_809FE890); + EnDu_SetupAction(pthis, func_809FE890); } else if (globalCtx->sceneNum == 4) { - EnDu_SetupAction(this, func_809FE638); + EnDu_SetupAction(pthis, func_809FE638); } else if (!LINK_IS_ADULT) { - EnDu_SetupAction(this, func_809FE3C0); + EnDu_SetupAction(pthis, func_809FE3C0); } else { - EnDu_SetupAction(this, func_809FE3B4); + EnDu_SetupAction(pthis, func_809FE3B4); } } void EnDu_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnDu* this = (EnDu*)thisx; + EnDu* pthis = (EnDu*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_809FE3B4(EnDu* this, GlobalContext* globalCtx) { +void func_809FE3B4(EnDu* pthis, GlobalContext* globalCtx) { } -void func_809FE3C0(EnDu* this, GlobalContext* globalCtx) { +void func_809FE3C0(EnDu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->stateFlags2 & 0x1000000) { func_8010BD88(globalCtx, OCARINA_ACTION_CHECK_SARIA); player->stateFlags2 |= 0x2000000; - player->unk_6A8 = &this->actor; - EnDu_SetupAction(this, func_809FE4A4); + player->unk_6A8 = &pthis->actor; + EnDu_SetupAction(pthis, func_809FE4A4); return; } - if (this->unk_1F4.unk_00 == 2) { - func_8002DF54(globalCtx, &this->actor, 7); - this->unk_1F4.unk_00 = 0; + if (pthis->unk_1F4.unk_00 == 2) { + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->unk_1F4.unk_00 = 0; } - if (this->actor.xzDistToPlayer < 116.0f + this->collider.dim.radius) { + if (pthis->actor.xzDistToPlayer < 116.0f + pthis->collider.dim.radius) { player->stateFlags2 |= 0x800000; } } -void func_809FE4A4(EnDu* this, GlobalContext* globalCtx) { +void func_809FE4A4(EnDu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; - EnDu_SetupAction(this, func_809FE3C0); + EnDu_SetupAction(pthis, func_809FE3C0); } else if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_06) { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGoronCityDaruniaWrongCs); gSaveContext.cutsceneTrigger = 1; - this->unk_1E8 = 1; - EnDu_SetupAction(this, func_809FE890); + pthis->unk_1E8 = 1; + EnDu_SetupAction(pthis, func_809FE890); globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGoronCityDaruniaCorrectCs); gSaveContext.cutsceneTrigger = 1; - this->unk_1E8 = 0; - EnDu_SetupAction(this, func_809FE890); + pthis->unk_1E8 = 0; + EnDu_SetupAction(pthis, func_809FE890); globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } else { player->stateFlags2 |= 0x800000; } } -void func_809FE638(EnDu* this, GlobalContext* globalCtx) { +void func_809FE638(EnDu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (!(player->stateFlags1 & 0x20000000)) { - OnePointCutscene_Init(globalCtx, 3330, -99, &this->actor, MAIN_CAM); - player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x7FFF; + OnePointCutscene_Init(globalCtx, 3330, -99, &pthis->actor, MAIN_CAM); + player->actor.shape.rot.y = player->actor.world.rot.y = pthis->actor.world.rot.y + 0x7FFF; Audio_PlayFanfare(NA_BGM_APPEAR); - EnDu_SetupAction(this, func_809FE6CC); - this->unk_1E2 = 0x32; + EnDu_SetupAction(pthis, func_809FE6CC); + pthis->unk_1E2 = 0x32; } } -void func_809FE6CC(EnDu* this, GlobalContext* globalCtx) { +void func_809FE6CC(EnDu* pthis, GlobalContext* globalCtx) { s16 phi_v1; - if (this->unk_1E2 == 0) { + if (pthis->unk_1E2 == 0) { phi_v1 = 0; } else { - this->unk_1E2--; - phi_v1 = this->unk_1E2; + pthis->unk_1E2--; + phi_v1 = pthis->unk_1E2; } if (phi_v1 == 0) { - this->actor.textId = 0x3039; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_1F4.unk_00 = 1; - EnDu_SetupAction(this, func_809FE740); + pthis->actor.textId = 0x3039; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_1F4.unk_00 = 1; + EnDu_SetupAction(pthis, func_809FE740); } } -void func_809FE740(EnDu* this, GlobalContext* globalCtx) { - if (this->unk_1F4.unk_00 == 0) { +void func_809FE740(EnDu* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1F4.unk_00 == 0) { func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - this->unk_1E2 = 0x5A; - EnDu_SetupAction(this, func_809FE798); + pthis->unk_1E2 = 0x5A; + EnDu_SetupAction(pthis, func_809FE798); } } -void func_809FE798(EnDu* this, GlobalContext* globalCtx) { +void func_809FE798(EnDu* pthis, GlobalContext* globalCtx) { s32 phi_v0; - if (this->unk_1E2 == 0) { + if (pthis->unk_1E2 == 0) { phi_v0 = 0; } else { - this->unk_1E2--; - phi_v0 = this->unk_1E2; + pthis->unk_1E2--; + phi_v0 = pthis->unk_1E2; } if (phi_v0 != 0) { - switch (this->unk_1E2) { + switch (pthis->unk_1E2) { case 0x50: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); break; case 0x3C: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SLIDE_DOOR_OPEN); break; case 0xF: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); break; case 5: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_BOUND); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_STONE_BOUND); break; } - if (this->unk_1E2 >= 0x3D) { - this->actor.world.pos.x -= 10.0f; + if (pthis->unk_1E2 >= 0x3D) { + pthis->actor.world.pos.x -= 10.0f; } } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); gSaveContext.infTable[0x11] |= 0x400; } } -void func_809FE890(EnDu* this, GlobalContext* globalCtx) { +void func_809FE890(EnDu* pthis, GlobalContext* globalCtx) { f32 frame; Vec3f startPos; Vec3f endPos; @@ -428,8 +428,8 @@ void func_809FE890(EnDu* this, GlobalContext* globalCtx) { CsCmdActorAction* csAction; if (globalCtx->csCtx.state == CS_STATE_IDLE) { - func_8002DF54(globalCtx, &this->actor, 1); - EnDu_SetupAction(this, func_809FEB08); + func_8002DF54(globalCtx, &pthis->actor, 1); + EnDu_SetupAction(pthis, func_809FEB08); return; } csAction = globalCtx->csCtx.npcActions[2]; @@ -437,153 +437,153 @@ void func_809FE890(EnDu* this, GlobalContext* globalCtx) { if (csAction != NULL) { func_809FDFC0(csAction, &startPos); func_809FE000(csAction, &endPos); - if (this->unk_1EA == 0) { + if (pthis->unk_1EA == 0) { func_809FDFC0(csAction, &startPos); - this->actor.world.pos = startPos; + pthis->actor.world.pos = startPos; } - if (this->unk_1EA != csAction->action) { + if (pthis->unk_1EA != csAction->action) { if (csAction->action == 1) { - func_80034EC0(&this->skelAnime, sAnimations, 1); + func_80034EC0(&pthis->skelAnime, sAnimations, 1); } if (csAction->action == 7 || csAction->action == 8) { - this->unk_1E6 = 0; - func_80034EC0(&this->skelAnime, sAnimations, 7); + pthis->unk_1E6 = 0; + func_80034EC0(&pthis->skelAnime, sAnimations, 7); } - this->unk_1EA = csAction->action; - if (this->unk_1EA == 7) { - this->blinkTimer = 11; - this->unk_1EC = 2; - this->unk_1ED = 2; - this->unk_1EE = 1; + pthis->unk_1EA = csAction->action; + if (pthis->unk_1EA == 7) { + pthis->blinkTimer = 11; + pthis->unk_1EC = 2; + pthis->unk_1ED = 2; + pthis->unk_1EE = 1; } - if (this->unk_1EA == 8) { - this->blinkTimer = 11; - this->unk_1EC = 3; - this->unk_1ED = 3; - this->unk_1EE = 0; + if (pthis->unk_1EA == 8) { + pthis->blinkTimer = 11; + pthis->unk_1EC = 3; + pthis->unk_1ED = 3; + pthis->unk_1EE = 0; } } - if (this->unk_1EA == 7) { - func_809FE040(this); + if (pthis->unk_1EA == 7) { + func_809FE040(pthis); } - if (this->unk_1EA == 8) { - func_809FE104(this); + if (pthis->unk_1EA == 8) { + func_809FE104(pthis); } - this->actor.shape.rot.x = csAction->urot.x; - this->actor.shape.rot.y = csAction->urot.y; - this->actor.shape.rot.z = csAction->urot.z; - this->actor.velocity = velocity; + pthis->actor.shape.rot.x = csAction->urot.x; + pthis->actor.shape.rot.y = csAction->urot.y; + pthis->actor.shape.rot.z = csAction->urot.z; + pthis->actor.velocity = velocity; if (globalCtx->csCtx.frames < csAction->endFrame) { frame = csAction->endFrame - csAction->startFrame; - this->actor.velocity.x = (endPos.x - startPos.x) / frame; - this->actor.velocity.y = (endPos.y - startPos.y) / frame; - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; + pthis->actor.velocity.x = (endPos.x - startPos.x) / frame; + pthis->actor.velocity.y = (endPos.y - startPos.y) / frame; + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; } - this->actor.velocity.z = (endPos.z - startPos.z) / frame; + pthis->actor.velocity.z = (endPos.z - startPos.z) / frame; } } } -void func_809FEB08(EnDu* this, GlobalContext* globalCtx) { - this->blinkTimer = 11; - this->unk_1EC = 0; - this->unk_1ED = 0; - this->unk_1EE = 0; +void func_809FEB08(EnDu* pthis, GlobalContext* globalCtx) { + pthis->blinkTimer = 11; + pthis->unk_1EC = 0; + pthis->unk_1ED = 0; + pthis->unk_1EE = 0; - if (this->unk_1E8 == 1) { - func_8002DF54(globalCtx, &this->actor, 7); - func_80034EC0(&this->skelAnime, sAnimations, 1); - EnDu_SetupAction(this, func_809FE3C0); + if (pthis->unk_1E8 == 1) { + func_8002DF54(globalCtx, &pthis->actor, 7); + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + EnDu_SetupAction(pthis, func_809FE3C0); return; } if (CUR_UPG_VALUE(UPG_STRENGTH) <= 0) { - this->actor.textId = 0x301C; - EnDu_SetupAction(this, func_809FEC14); + pthis->actor.textId = 0x301C; + EnDu_SetupAction(pthis, func_809FEC14); } else { - this->actor.textId = 0x301F; - EnDu_SetupAction(this, func_809FE3C0); + pthis->actor.textId = 0x301F; + EnDu_SetupAction(pthis, func_809FE3C0); } - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - func_80034EC0(&this->skelAnime, sAnimations, 14); - this->unk_1F4.unk_00 = 1; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + func_80034EC0(&pthis->skelAnime, sAnimations, 14); + pthis->unk_1F4.unk_00 = 1; } -void func_809FEC14(EnDu* this, GlobalContext* globalCtx) { - if (this->unk_1F4.unk_00 == 2) { - func_8002DF54(globalCtx, &this->actor, 7); - EnDu_SetupAction(this, func_809FEC70); - func_809FEC70(this, globalCtx); +void func_809FEC14(EnDu* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1F4.unk_00 == 2) { + func_8002DF54(globalCtx, &pthis->actor, 7); + EnDu_SetupAction(pthis, func_809FEC70); + func_809FEC70(pthis, globalCtx); } } -void func_809FEC70(EnDu* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - EnDu_SetupAction(this, func_809FECE4); +void func_809FEC70(EnDu* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + EnDu_SetupAction(pthis, func_809FECE4); } else { - f32 xzRange = this->actor.xzDistToPlayer + 1.0f; - func_8002F434(&this->actor, globalCtx, GI_BRACELET, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); + f32 xzRange = pthis->actor.xzDistToPlayer + 1.0f; + func_8002F434(&pthis->actor, globalCtx, GI_BRACELET, xzRange, fabsf(pthis->actor.yDistToPlayer) + 1.0f); } } -void func_809FECE4(EnDu* this, GlobalContext* globalCtx) { - if (this->unk_1F4.unk_00 == 3) { - this->unk_1F4.unk_00 = 0; - EnDu_SetupAction(this, func_809FE3C0); +void func_809FECE4(EnDu* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1F4.unk_00 == 3) { + pthis->unk_1F4.unk_00 = 0; + EnDu_SetupAction(pthis, func_809FE3C0); } } void EnDu_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDu* this = (EnDu*)thisx; + EnDu* pthis = (EnDu*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - if (this->skelAnime.animation == &gDaruniaDancingEndAnim && - Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 1); + if (pthis->skelAnime.animation == &gDaruniaDancingEndAnim && + Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 1); } - SkelAnime_Update(&this->skelAnime); - func_809FDE9C(this); - func_809FDE24(this, globalCtx); + SkelAnime_Update(&pthis->skelAnime); + func_809FDE9C(pthis); + func_809FDE24(pthis, globalCtx); - if (this->actionFunc == func_809FE890) { - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.world.pos.z += this->actor.velocity.z; + if (pthis->actionFunc == func_809FE890) { + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.world.pos.z += pthis->actor.velocity.z; } else { - func_8002D7EC(&this->actor); + func_8002D7EC(&pthis->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); - if (this->actionFunc != func_809FE4A4) { - func_800343CC(globalCtx, &this->actor, &this->unk_1F4.unk_00, this->collider.dim.radius + 116.0f, func_809FDC38, + if (pthis->actionFunc != func_809FE4A4) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1F4.unk_00, pthis->collider.dim.radius + 116.0f, func_809FDC38, func_809FDCDC); } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } s32 EnDu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx) { - EnDu* this = (EnDu*)thisx; + EnDu* pthis = (EnDu*)thisx; Vec3s sp1C; if (limbIndex == 16) { Matrix_Translate(2400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - sp1C = this->unk_1F4.unk_08; + sp1C = pthis->unk_1F4.unk_08; Matrix_RotateX(BINANG_TO_RAD(sp1C.y), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD(sp1C.x), MTXMODE_APPLY); Matrix_Translate(-2400.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - sp1C = this->unk_1F4.unk_0E; + sp1C = pthis->unk_1F4.unk_0E; Matrix_RotateY(BINANG_TO_RAD(sp1C.y), MTXMODE_APPLY); Matrix_RotateX(BINANG_TO_RAD(sp1C.x), MTXMODE_APPLY); } @@ -591,11 +591,11 @@ s32 EnDu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnDu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnDu* this = (EnDu*)thisx; + EnDu* pthis = (EnDu*)thisx; Vec3f D_809FF40C = { 0.0f, -1000.0f, 0.0f }; if (limbIndex == 16) { - Matrix_MultVec3f(&D_809FF40C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809FF40C, &pthis->actor.focus.pos); } } @@ -616,15 +616,15 @@ void EnDu_Draw(Actor* thisx, GlobalContext* globalCtx) { gDaruniaNoseSeriousTex, gDaruniaNoseHappyTex, }; - EnDu* this = (EnDu*)thisx; + EnDu* pthis = (EnDu*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_du.c", 1470); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexIndex])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTextures[this->mouthTexIndex])); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(noseTextures[this->noseTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTextures[pthis->mouthTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(noseTextures[pthis->noseTexIndex])); - func_80034BA0(globalCtx, &this->skelAnime, EnDu_OverrideLimbDraw, EnDu_PostLimbDraw, &this->actor, 255); + func_80034BA0(globalCtx, &pthis->skelAnime, EnDu_OverrideLimbDraw, EnDu_PostLimbDraw, &pthis->actor, 255); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_du.c", 1487); } diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.cpp similarity index 56% rename from src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c rename to src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.cpp index 876233853..433cb4fa3 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.cpp @@ -21,10 +21,10 @@ void EnDyExtra_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx); void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnDyExtra_WaitForTrigger(EnDyExtra* this, GlobalContext* globalCtx); -void EnDyExtra_FallAndKill(EnDyExtra* this, GlobalContext* globalCtx); +void EnDyExtra_WaitForTrigger(EnDyExtra* pthis, GlobalContext* globalCtx); +void EnDyExtra_FallAndKill(EnDyExtra* pthis, GlobalContext* globalCtx); -const ActorInit En_Dy_Extra_InitVars = { +ActorInit En_Dy_Extra_InitVars = { ACTOR_EN_DY_EXTRA, ACTORCAT_PROP, FLAGS, @@ -40,57 +40,57 @@ void EnDyExtra_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnDyExtra_Init(Actor* thisx, GlobalContext* globalCtx) { - EnDyExtra* this = (EnDyExtra*)thisx; + EnDyExtra* pthis = (EnDyExtra*)thisx; osSyncPrintf("\n\n"); // "Big fairy effect" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 大妖精効果 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); - this->type = this->actor.params; - this->scale.x = 0.025f; - this->scale.y = 0.039f; - this->scale.z = 0.025f; - this->unk_168 = this->actor.world.pos; - this->actor.gravity = -0.2f; - this->unk_158 = 1.0f; - this->timer = 60; - this->actionFunc = EnDyExtra_WaitForTrigger; + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 大妖精効果 ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params); + pthis->type = pthis->actor.params; + pthis->scale.x = 0.025f; + pthis->scale.y = 0.039f; + pthis->scale.z = 0.025f; + pthis->unk_168 = pthis->actor.world.pos; + pthis->actor.gravity = -0.2f; + pthis->unk_158 = 1.0f; + pthis->timer = 60; + pthis->actionFunc = EnDyExtra_WaitForTrigger; } -void EnDyExtra_WaitForTrigger(EnDyExtra* this, GlobalContext* globalCtx) { - Math_ApproachF(&this->actor.gravity, 0.0f, 0.1f, 0.005f); - if (this->actor.world.pos.y < -55.0f) { - this->actor.velocity.y = 0.0f; +void EnDyExtra_WaitForTrigger(EnDyExtra* pthis, GlobalContext* globalCtx) { + Math_ApproachF(&pthis->actor.gravity, 0.0f, 0.1f, 0.005f); + if (pthis->actor.world.pos.y < -55.0f) { + pthis->actor.velocity.y = 0.0f; } - if (this->timer == 0 && this->trigger != 0) { - this->timer = 200; - this->actionFunc = EnDyExtra_FallAndKill; + if (pthis->timer == 0 && pthis->trigger != 0) { + pthis->timer = 200; + pthis->actionFunc = EnDyExtra_FallAndKill; } } -void EnDyExtra_FallAndKill(EnDyExtra* this, GlobalContext* globalCtx) { - Math_ApproachF(&this->actor.gravity, 0.0f, 0.1f, 0.005f); - if (this->timer == 0 || this->unk_158 < 0.02f) { - Actor_Kill(&this->actor); +void EnDyExtra_FallAndKill(EnDyExtra* pthis, GlobalContext* globalCtx) { + Math_ApproachF(&pthis->actor.gravity, 0.0f, 0.1f, 0.005f); + if (pthis->timer == 0 || pthis->unk_158 < 0.02f) { + Actor_Kill(&pthis->actor); return; } - Math_ApproachZeroF(&this->unk_158, 0.03f, 0.05f); - if (this->actor.world.pos.y < -55.0f) { - this->actor.velocity.y = 0.0f; + Math_ApproachZeroF(&pthis->unk_158, 0.03f, 0.05f); + if (pthis->actor.world.pos.y < -55.0f) { + pthis->actor.velocity.y = 0.0f; } } void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx) { - EnDyExtra* this = (EnDyExtra*)thisx; + EnDyExtra* pthis = (EnDyExtra*)thisx; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - this->actor.scale.x = this->scale.x; - this->actor.scale.y = this->scale.y; - this->actor.scale.z = this->scale.z; - Audio_PlayActorSound2(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); + pthis->actor.scale.x = pthis->scale.x; + pthis->actor.scale.y = pthis->scale.y; + pthis->actor.scale.z = pthis->scale.z; + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); } void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -98,7 +98,7 @@ void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { static Color_RGBA8 envColors[] = { { 255, 100, 255, 255 }, { 100, 255, 255, 255 } }; static u8 D_809FFC50[] = { 0x02, 0x01, 0x01, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x02 }; - EnDyExtra* this = (EnDyExtra*)thisx; + EnDyExtra* pthis = (EnDyExtra*)thisx; s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; Vtx* vertices = SEGMENTED_TO_VIRTUAL(gGreatFairySpiralBeamVtx); @@ -106,8 +106,8 @@ void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { u8 unk[3]; unk[0] = 0.0f; - unk[1] = (s8)(this->unk_158 * 240.0f); - unk[2] = (s8)(this->unk_158 * 255.0f); + unk[1] = (s8)(pthis->unk_158 * 240.0f); + unk[2] = (s8)(pthis->unk_158 * 255.0f); for (i = 0; i < 27; i++) { if (D_809FFC50[i]) { @@ -124,9 +124,9 @@ void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_dy_extra.c", 307), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColors[this->type].r, primColors[this->type].g, - primColors[this->type].b, 255); - gDPSetEnvColor(POLY_XLU_DISP++, envColors[this->type].r, envColors[this->type].g, envColors[this->type].b, 128); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColors[pthis->type].r, primColors[pthis->type].g, + primColors[pthis->type].b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, envColors[pthis->type].r, envColors[pthis->type].g, envColors[pthis->type].b, 128); gSPDisplayList(POLY_XLU_DISP++, gGreatFairySpiralBeamDL); CLOSE_DISPS(gfxCtx, "../z_en_dy_extra.c", 325); diff --git a/src/overlays/actors/ovl_En_Eg/z_en_eg.c b/src/overlays/actors/ovl_En_Eg/z_en_eg.cpp similarity index 85% rename from src/overlays/actors/ovl_En_Eg/z_en_eg.c rename to src/overlays/actors/ovl_En_Eg/z_en_eg.cpp index d39dee7eb..3ffd5d951 100644 --- a/src/overlays/actors/ovl_En_Eg/z_en_eg.c +++ b/src/overlays/actors/ovl_En_Eg/z_en_eg.cpp @@ -21,7 +21,7 @@ void EnEg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnEg_Update(Actor* thisx, GlobalContext* globalCtx); void EnEg_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809FFDC8(EnEg* this, GlobalContext* globalCtx); +void func_809FFDC8(EnEg* pthis, GlobalContext* globalCtx); static s32 voided = false; @@ -29,7 +29,7 @@ static EnEgActionFunc sActionFuncs[] = { func_809FFDC8, }; -const ActorInit En_Eg_InitVars = { +ActorInit En_Eg_InitVars = { ACTOR_EN_EG, ACTORCAT_ITEMACTION, FLAGS, @@ -49,12 +49,12 @@ void EnEg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnEg_Init(Actor* thisx, GlobalContext* globalCtx) { - EnEg* this = (EnEg*)thisx; + EnEg* pthis = (EnEg*)thisx; - this->action = 0; + pthis->action = 0; } -void func_809FFDC8(EnEg* this, GlobalContext* globalCtx) { +void func_809FFDC8(EnEg* pthis, GlobalContext* globalCtx) { if (!voided && (gSaveContext.timer2Value < 1) && Flags_GetSwitch(globalCtx, 0x36) && (kREG(0) == 0)) { // Void the player out Gameplay_TriggerRespawn(globalCtx); @@ -67,14 +67,14 @@ void func_809FFDC8(EnEg* this, GlobalContext* globalCtx) { } void EnEg_Update(Actor* thisx, GlobalContext* globalCtx) { - EnEg* this = (EnEg*)thisx; - s32 action = this->action; + EnEg* pthis = (EnEg*)thisx; + s32 action = pthis->action; if (((action < 0) || (0 < action)) || (sActionFuncs[action] == NULL)) { // "Main Mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!" osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); } else { - sActionFuncs[action](this, globalCtx); + sActionFuncs[action](pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c b/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c deleted file mode 100644 index 84644dc05..000000000 --- a/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c +++ /dev/null @@ -1,731 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_EIYER_Z_EN_EIYER_C -#include "actor_common.h" -#include "z_en_eiyer.h" -#include "objects/object_ei/object_ei.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnEiyer_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEiyer_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEiyer_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEiyer_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnEiyer_SetupAppearFromGround(EnEiyer* this); -void EnEiyer_SetupUnderground(EnEiyer* this); -void EnEiyer_SetupInactive(EnEiyer* this); -void EnEiyer_SetupAmbush(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_SetupGlide(EnEiyer* this); -void EnEiyer_SetupStartAttack(EnEiyer* this); -void EnEiyer_SetupDiveAttack(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_SetupLand(EnEiyer* this); -void EnEiyer_SetupHurt(EnEiyer* this); -void EnEiyer_SetupDie(EnEiyer* this); -void EnEiyer_SetupDead(EnEiyer* this); -void EnEiyer_SetupStunned(EnEiyer* this); - -void EnEiyer_AppearFromGround(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_WanderUnderground(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_CircleUnderground(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Inactive(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Ambush(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Glide(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_StartAttack(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_DiveAttack(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Land(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Hurt(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Die(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Dead(EnEiyer* this, GlobalContext* globalCtx); -void EnEiyer_Stunned(EnEiyer* this, GlobalContext* globalCtx); - -const ActorInit En_Eiyer_InitVars = { - ACTOR_EN_EIYER, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_EI, - sizeof(EnEiyer), - (ActorFunc)EnEiyer_Init, - (ActorFunc)EnEiyer_Destroy, - (ActorFunc)EnEiyer_Update, - (ActorFunc)EnEiyer_Draw, -}; - -static ColliderCylinderInit sColCylInit = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x04, 0x08 }, - { 0x00000019, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 27, 17, -10, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 2, 45, 15, 100 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(4, 0x0), - /* Light magic */ DMG_ENTRY(4, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x19, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 5, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_STOP), -}; - -/** - * params 0: Spawn 3 clones and circle around spawn point - * params 1-3: Clone, spawn another clone for the main Eiyer if params < 3 - * params 10: Normal Eiyer, wander around spawn point - */ -void EnEiyer_Init(Actor* thisx, GlobalContext* globalCtx) { - EnEiyer* this = (EnEiyer*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 600.0f, ActorShadow_DrawCircle, 65.0f); - SkelAnime_Init(globalCtx, &this->skelanime, &gStingerSkel, &gStingerIdleAnim, this->jointTable, this->morphTable, - 19); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sColCylInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - - if (this->actor.params < 3) { - // Each clone spawns another clone - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EIYER, this->actor.home.pos.x, - this->actor.home.pos.y, this->actor.home.pos.z, 0, this->actor.shape.rot.y + 0x4000, 0, - this->actor.params + 1) == NULL) { - Actor_Kill(&this->actor); - return; - } - - if (this->actor.params == 0) { - Actor* child = this->actor.child; - s32 clonesSpawned; - - for (clonesSpawned = 0; clonesSpawned != 3; clonesSpawned++) { - if (child == NULL) { - break; - } - child = child->child; - } - - if (clonesSpawned != 3) { - for (child = &this->actor; child != NULL; child = child->child) { - Actor_Kill(child); - } - return; - } else { - this->actor.child->parent = &this->actor; - this->actor.child->child->parent = &this->actor; - this->actor.child->child->child->parent = &this->actor; - } - } - } - - if (this->actor.params == 0 || this->actor.params == 10) { - EnEiyer_SetupAppearFromGround(this); - } else { - EnEiyer_SetupInactive(this); - } -} - -void EnEiyer_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnEiyer* this = (EnEiyer*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnEiyer_RotateAroundHome(EnEiyer* this) { - this->actor.world.pos.x = Math_SinS(this->actor.world.rot.y) * 80.0f + this->actor.home.pos.x; - this->actor.world.pos.z = Math_CosS(this->actor.world.rot.y) * 80.0f + this->actor.home.pos.z; - this->actor.shape.rot.y = this->actor.world.rot.y + 0x4000; -} - -void EnEiyer_SetupAppearFromGround(EnEiyer* this) { - this->collider.info.bumper.dmgFlags = 0x19; - Animation_PlayLoop(&this->skelanime, &gStingerIdleAnim); - - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.y = this->actor.home.pos.y - 40.0f; - this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - - if (this->actor.params != 0xA) { - if (this->actor.params == 0) { - this->actor.world.rot.y = Rand_ZeroOne() * 0x10000; - } else { - this->actor.world.rot.y = this->actor.parent->world.rot.y + this->actor.params * 0x4000; - } - EnEiyer_RotateAroundHome(this); - } else { - this->actor.world.rot.y = this->actor.shape.rot.y = Rand_ZeroOne() * 0x10000; - } - - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_12); - this->actor.shape.shadowScale = 0.0f; - this->actor.shape.yOffset = 0.0f; - this->actionFunc = EnEiyer_AppearFromGround; -} - -void EnEiyer_SetupUnderground(EnEiyer* this) { - if (this->actor.params == 0xA) { - this->actor.speedXZ = -0.5f; - this->actionFunc = EnEiyer_WanderUnderground; - } else { - this->actionFunc = EnEiyer_CircleUnderground; - } - - this->collider.base.acFlags |= AC_ON; - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.flags |= ACTOR_FLAG_0; -} - -void EnEiyer_SetupInactive(EnEiyer* this) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = EnEiyer_Inactive; -} - -void EnEiyer_SetupAmbush(EnEiyer* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - Animation_PlayOnce(&this->skelanime, &gStingerBackflipAnim); - this->collider.info.bumper.dmgFlags = ~0x00300000; - this->basePos = this->actor.world.pos; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.flags |= ACTOR_FLAG_12; - this->collider.base.acFlags &= ~AC_ON; - this->actor.shape.shadowScale = 65.0f; - this->actor.shape.yOffset = 600.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_JUMP); - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 1, 700); - this->actionFunc = EnEiyer_Ambush; -} - -void EnEiyer_SetupGlide(EnEiyer* this) { - this->targetYaw = this->actor.shape.rot.y; - this->basePos.y = (cosf(-M_PI / 8) * 5.0f) + this->actor.world.pos.y; - Animation_MorphToLoop(&this->skelanime, &gStingerHitAnim, -5.0f); - this->timer = 60; - this->actionFunc = EnEiyer_Glide; -} - -void EnEiyer_SetupStartAttack(EnEiyer* this) { - this->actionFunc = EnEiyer_StartAttack; -} - -void EnEiyer_SetupDiveAttack(EnEiyer* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->actor.velocity.y = 0.0f; - this->basePos.y = player->actor.world.pos.y + 15.0f; - this->collider.base.atFlags |= AT_ON; - this->collider.base.atFlags &= ~AT_HIT; - this->actionFunc = EnEiyer_DiveAttack; -} - -void EnEiyer_SetupLand(EnEiyer* this) { - Animation_MorphToPlayOnce(&this->skelanime, &gStingerDiveAnim, -3.0f); - this->collider.base.atFlags &= ~AT_ON; - this->actor.flags |= ACTOR_FLAG_4; - - // Update BgCheck info, play sound, and spawn effect on the first frame of the land action - this->timer = -1; - this->actor.gravity = 0.0f; - this->collider.dim.height = sColCylInit.dim.height; - this->actionFunc = EnEiyer_Land; -} - -void EnEiyer_SetupHurt(EnEiyer* this) { - this->basePos.y = this->actor.world.pos.y; - Animation_Change(&this->skelanime, &gStingerHitAnim, 2.0f, 0.0f, 0.0f, 0, -3.0f); - this->timer = 40; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 5.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, 40); - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnEiyer_Hurt; -} - -void EnEiyer_SetupDie(EnEiyer* this) { - this->timer = 20; - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, 40); - - if (this->collider.info.bumper.dmgFlags != 0x19) { - this->actor.speedXZ = 6.0f; - Animation_MorphToLoop(&this->skelanime, &gStingerHitAnim, -3.0f); - } else { - this->actor.speedXZ -= 6.0f; - } - - this->collider.info.bumper.dmgFlags = ~0x00300000; - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnEiyer_Die; -} - -void EnEiyer_SetupDead(EnEiyer* this) { - this->actor.colorFilterParams |= 0x2000; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actionFunc = EnEiyer_Dead; -} - -void EnEiyer_SetupStunned(EnEiyer* this) { - Animation_Change(&this->skelanime, &gStingerPopOutAnim, 2.0f, 0.0f, 0.0f, 0, -8.0f); - this->timer = 80; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -1.0f; - this->collider.dim.height = sColCylInit.dim.height + 8; - Actor_SetColorFilter(&this->actor, 0, 200, 0, 80); - this->collider.base.atFlags &= ~AT_ON; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionFunc = EnEiyer_Stunned; -} - -void EnEiyer_AppearFromGround(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.75f)) { - EnEiyer_SetupUnderground(this); - } -} - -void EnEiyer_CheckPlayerCollision(EnEiyer* this, GlobalContext* globalCtx) { - if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - EnEiyer_SetupAmbush(this, globalCtx); - } -} - -void EnEiyer_CircleUnderground(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - this->actor.world.rot.y += -0x60; - EnEiyer_RotateAroundHome(this); - EnEiyer_CheckPlayerCollision(this, globalCtx); - - // Clones disappear when the main Eiyer leaves the ground - if (this->actor.params != 0 && ((EnEiyer*)this->actor.parent)->actionFunc != EnEiyer_CircleUnderground) { - EnEiyer_SetupInactive(this); - } -} - -void EnEiyer_WanderUnderground(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 100.0f) { - this->targetYaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) + 0x8000; - } else if (this->targetYaw == this->actor.world.rot.y && Rand_ZeroOne() > 0.99f) { - this->targetYaw = - this->actor.world.rot.y + (Rand_ZeroOne() < 0.5f ? -1 : 1) * (Rand_ZeroOne() * 0x2000 + 0x2000); - } - - Math_ScaledStepToS(&this->actor.world.rot.y, this->targetYaw, 0xB6); - EnEiyer_CheckPlayerCollision(this, globalCtx); -} - -void EnEiyer_Inactive(EnEiyer* this, GlobalContext* globalCtx) { - EnEiyer* parent; - - if (this->actor.home.pos.y - 50.0f < this->actor.world.pos.y) { - this->actor.world.pos.y -= 0.5f; - } - - parent = (EnEiyer*)this->actor.parent; - if (parent->actionFunc == EnEiyer_Dead) { - Actor_Kill(&this->actor); - } else if (parent->actionFunc == EnEiyer_AppearFromGround) { - EnEiyer_SetupAppearFromGround(this); - } -} - -void EnEiyer_Ambush(EnEiyer* this, GlobalContext* globalCtx) { - s32 animFinished; - f32 curFrame; - f32 xzOffset; - s32 bgId; - - animFinished = SkelAnime_Update(&this->skelanime); - curFrame = this->skelanime.curFrame; - - if (this->skelanime.curFrame < 12.0f) { - this->actor.world.pos.y = ((1.0f - cosf((0.996f * M_PI / 12.0f) * curFrame)) * 40.0f) + this->actor.home.pos.y; - xzOffset = sinf((0.996f * M_PI / 12.0f) * curFrame) * -40.0f; - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * xzOffset) + this->basePos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * xzOffset) + this->basePos.z; - } else { - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 80.0f, 0.5f); - this->actor.speedXZ = 0.8f; - } - - if (animFinished) { - this->collider.base.acFlags |= AC_ON; - EnEiyer_SetupGlide(this); - } else { - this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); - } -} - -void EnEiyer_Glide(EnEiyer* this, GlobalContext* globalCtx) { - f32 curFrame; - s32 pad; - s16 yawChange; - - SkelAnime_Update(&this->skelanime); - - if (this->timer != 0) { - this->timer--; - } - - curFrame = this->skelanime.curFrame; - Math_ApproachF(&this->basePos.y, this->actor.floorHeight + 80.0f + 5.0f, 0.3f, this->actor.speedXZ); - this->actor.world.pos.y = this->basePos.y - cosf((curFrame - 5.0f) * (M_PI / 40)) * 5.0f; - - if (curFrame <= 45.0f) { - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.03f); - } else { - Math_StepToF(&this->actor.speedXZ, 1.5f, 0.03f); - } - - if (this->actor.bgCheckFlags & 8) { - this->targetYaw = this->actor.wallYaw; - } - - if (Math_ScaledStepToS(&this->actor.world.rot.y, this->targetYaw, 0xB6)) { - if (this->timer != 0 || Rand_ZeroOne() > 0.05f) { - this->actor.world.rot.y += 0x100; - } else { - yawChange = Rand_S16Offset(0x2000, 0x2000); - this->targetYaw = (Rand_ZeroOne() < 0.5f ? -1 : 1) * yawChange + this->actor.world.rot.y; - } - } - - if (this->timer == 0 && this->actor.yDistToPlayer < 0.0f && this->actor.xzDistToPlayer < 120.0f) { - EnEiyer_SetupStartAttack(this); - } - - func_8002F974(&this->actor, NA_SE_EN_EIER_FLY - SFX_FLAG); -} - -void EnEiyer_StartAttack(EnEiyer* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f focus; - - SkelAnime_Update(&this->skelanime); - - if (this->actor.shape.rot.x > 0 && this->actor.shape.rot.x < 0x8000) { - focus.x = player->actor.world.pos.x; - focus.y = player->actor.world.pos.y + 20.0f; - focus.z = player->actor.world.pos.z; - - if (Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &focus), 0x1000)) { - EnEiyer_SetupDiveAttack(this, globalCtx); - } - } else { - this->actor.shape.rot.x -= 0x1000; - } - - this->actor.world.rot.x = -this->actor.shape.rot.x; - Math_StepToF(&this->actor.speedXZ, 5.0f, 0.3f); - Math_ApproachS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 0x71C); - func_8002F974(&this->actor, NA_SE_EN_EIER_FLY - SFX_FLAG); -} - -void EnEiyer_DiveAttack(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - this->actor.speedXZ *= 1.1f; - - if (this->actor.bgCheckFlags & 8 || this->actor.bgCheckFlags & 1) { - EnEiyer_SetupLand(this); - } - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~(AT_ON | AT_HIT); - } - - func_8002F974(&this->actor, NA_SE_EN_EIER_FLY - SFX_FLAG); -} - -void EnEiyer_Land(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ScaledStepToS(&this->actor.world.rot.x, -0x4000, 0x450); - Math_StepToF(&this->actor.speedXZ, 7.0f, 1.0f); - - if (this->timer == -1) { - if (this->actor.bgCheckFlags & 8 || this->actor.bgCheckFlags & 1) { - this->timer = 10; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_OCTAROCK_SINK); - - if (this->actor.bgCheckFlags & 1) { - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 1, 700); - } - } - } else { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - this->actor.shape.rot.x = 0; - this->actor.world.rot.x = 0; - EnEiyer_SetupAppearFromGround(this); - } - } -} - -void EnEiyer_Hurt(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->timer != 0) { - this->timer--; - } - - Math_ApproachF(&this->basePos.y, this->actor.floorHeight + 80.0f + 5.0f, 0.5f, this->actor.speedXZ); - this->actor.world.pos.y = this->basePos.y - 5.0f; - - if (this->actor.bgCheckFlags & 8) { - this->targetYaw = this->actor.wallYaw; - } else { - this->targetYaw = this->actor.yawTowardsPlayer + 0x8000; - } - - Math_ScaledStepToS(&this->actor.world.rot.y, this->targetYaw, 0x38E); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x200); - this->actor.shape.rot.z = sinf(this->timer * (M_PI / 5)) * 5120.0f; - - if (this->timer == 0) { - this->actor.shape.rot.x = 0; - this->actor.shape.rot.z = 0; - this->collider.base.acFlags |= AC_ON; - EnEiyer_SetupGlide(this); - } - this->actor.world.rot.x = -this->actor.shape.rot.x; -} - -void EnEiyer_Die(EnEiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->actor.speedXZ > 0.0f) { - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0x400); - } else { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x400); - } - - this->actor.shape.rot.z += 0x1000; - - if (this->timer != 0) { - this->timer--; - } - - this->actor.world.rot.x = -this->actor.shape.rot.x; - - if (this->timer == 0 || this->actor.bgCheckFlags & 0x10) { - EnEiyer_SetupDead(this); - } -} - -void EnEiyer_Dead(EnEiyer* this, GlobalContext* globalCtx) { - this->actor.shape.shadowAlpha = CLAMP_MIN((s16)(this->actor.shape.shadowAlpha - 5), 0); - this->actor.world.pos.y -= 2.0f; - - if (this->actor.shape.shadowAlpha == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 80); - Actor_Kill(&this->actor); - } -} - -void EnEiyer_Stunned(EnEiyer* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x200); - SkelAnime_Update(&this->skelanime); - - if (Animation_OnFrame(&this->skelanime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_FLUTTER); - } - - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - - if (this->timer == 0) { - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->collider.dim.height = sColCylInit.dim.height; - EnEiyer_SetupGlide(this); - } -} - -void EnEiyer_UpdateDamage(EnEiyer* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - - if (this->actor.colChkInfo.damageEffect != 0 || this->actor.colChkInfo.damage != 0) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_DEAD); - this->actor.flags &= ~ACTOR_FLAG_0; - } - - // If underground, one hit kill - if (this->collider.info.bumper.dmgFlags == 0x19) { - if (this->actor.colChkInfo.damage == 0) { - EnEiyer_SetupAmbush(this, globalCtx); - } else { - EnEiyer_SetupDie(this); - } - } else if (this->actor.colChkInfo.damageEffect == 1) { - if (this->actionFunc != EnEiyer_Stunned) { - EnEiyer_SetupStunned(this); - } - } else if (this->actor.colChkInfo.health != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_DAMAGE); - EnEiyer_SetupHurt(this); - } else { - this->collider.dim.height = sColCylInit.dim.height; - EnEiyer_SetupDie(this); - } - } - } -} - -void EnEiyer_Update(Actor* thisx, GlobalContext* globalCtx) { - EnEiyer* this = (EnEiyer*)thisx; - s32 pad; - - EnEiyer_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - - if (this->actor.world.rot.x == 0 || this->actionFunc == EnEiyer_Stunned) { - Actor_MoveForward(&this->actor); - } else { - func_8002D97C(&this->actor); - } - - if (this->actionFunc == EnEiyer_Glide || this->actionFunc == EnEiyer_DiveAttack || - this->actionFunc == EnEiyer_Stunned || this->actionFunc == EnEiyer_Die || this->actionFunc == EnEiyer_Hurt || - (this->actionFunc == EnEiyer_Land && this->timer == -1)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 27.0f, 30.0f, 7); - } - - if (this->actor.params == 0xA || - (this->actionFunc != EnEiyer_AppearFromGround && this->actionFunc != EnEiyer_CircleUnderground)) { - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - // only the main Eiyer can ambush the player - if (this->actor.params == 0 || this->actor.params == 0xA) { - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->actionFunc != EnEiyer_Ambush) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - if (this->actor.flags & ACTOR_FLAG_0) { - this->actor.focus.pos.x = this->actor.world.pos.x + Math_SinS(this->actor.shape.rot.y) * 12.5f; - this->actor.focus.pos.z = this->actor.world.pos.z + Math_CosS(this->actor.shape.rot.y) * 12.5f; - this->actor.focus.pos.y = this->actor.world.pos.y; - } -} - -s32 EnEiyer_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnEiyer* this = (EnEiyer*)thisx; - - if (limbIndex == 1) { - pos->z += 2500.0f; - } - - if (this->collider.info.bumper.dmgFlags == 0x19 && limbIndex != 9 && limbIndex != 10) { - *dList = NULL; - } - return 0; -} - -void EnEiyer_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnEiyer* this = (EnEiyer*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_eiyer.c", 1494); - if (this->actionFunc != EnEiyer_Dead) { - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, - EnEiyer_OverrideLimbDraw, NULL, this, POLY_OPA_DISP); - } else { - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, D_80116280); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->actor.shape.shadowAlpha); - - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, - EnEiyer_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_eiyer.c", 1541); -} diff --git a/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.cpp b/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.cpp new file mode 100644 index 000000000..ad9e4b766 --- /dev/null +++ b/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.cpp @@ -0,0 +1,731 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_EIYER_Z_EN_EIYER_C +#include "actor_common.h" +#include "z_en_eiyer.h" +#include "objects/object_ei/object_ei.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnEiyer_Init(Actor* thisx, GlobalContext* globalCtx); +void EnEiyer_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnEiyer_Update(Actor* thisx, GlobalContext* globalCtx); +void EnEiyer_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnEiyer_SetupAppearFromGround(EnEiyer* pthis); +void EnEiyer_SetupUnderground(EnEiyer* pthis); +void EnEiyer_SetupInactive(EnEiyer* pthis); +void EnEiyer_SetupAmbush(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_SetupGlide(EnEiyer* pthis); +void EnEiyer_SetupStartAttack(EnEiyer* pthis); +void EnEiyer_SetupDiveAttack(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_SetupLand(EnEiyer* pthis); +void EnEiyer_SetupHurt(EnEiyer* pthis); +void EnEiyer_SetupDie(EnEiyer* pthis); +void EnEiyer_SetupDead(EnEiyer* pthis); +void EnEiyer_SetupStunned(EnEiyer* pthis); + +void EnEiyer_AppearFromGround(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_WanderUnderground(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_CircleUnderground(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Inactive(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Ambush(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Glide(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_StartAttack(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_DiveAttack(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Land(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Hurt(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Die(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Dead(EnEiyer* pthis, GlobalContext* globalCtx); +void EnEiyer_Stunned(EnEiyer* pthis, GlobalContext* globalCtx); + +ActorInit En_Eiyer_InitVars = { + ACTOR_EN_EIYER, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_EI, + sizeof(EnEiyer), + (ActorFunc)EnEiyer_Init, + (ActorFunc)EnEiyer_Destroy, + (ActorFunc)EnEiyer_Update, + (ActorFunc)EnEiyer_Draw, +}; + +static ColliderCylinderInit sColCylInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x04, 0x08 }, + { 0x00000019, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 27, 17, -10, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 2, 45, 15, 100 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(4, 0x0), + /* Light magic */ DMG_ENTRY(4, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x19, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 5, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_STOP), +}; + +/** + * params 0: Spawn 3 clones and circle around spawn point + * params 1-3: Clone, spawn another clone for the main Eiyer if params < 3 + * params 10: Normal Eiyer, wander around spawn point + */ +void EnEiyer_Init(Actor* thisx, GlobalContext* globalCtx) { + EnEiyer* pthis = (EnEiyer*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 600.0f, ActorShadow_DrawCircle, 65.0f); + SkelAnime_Init(globalCtx, &pthis->skelanime, &gStingerSkel, &gStingerIdleAnim, pthis->jointTable, pthis->morphTable, + 19); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sColCylInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + if (pthis->actor.params < 3) { + // Each clone spawns another clone + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EIYER, pthis->actor.home.pos.x, + pthis->actor.home.pos.y, pthis->actor.home.pos.z, 0, pthis->actor.shape.rot.y + 0x4000, 0, + pthis->actor.params + 1) == NULL) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->actor.params == 0) { + Actor* child = pthis->actor.child; + s32 clonesSpawned; + + for (clonesSpawned = 0; clonesSpawned != 3; clonesSpawned++) { + if (child == NULL) { + break; + } + child = child->child; + } + + if (clonesSpawned != 3) { + for (child = &pthis->actor; child != NULL; child = child->child) { + Actor_Kill(child); + } + return; + } else { + pthis->actor.child->parent = &pthis->actor; + pthis->actor.child->child->parent = &pthis->actor; + pthis->actor.child->child->child->parent = &pthis->actor; + } + } + } + + if (pthis->actor.params == 0 || pthis->actor.params == 10) { + EnEiyer_SetupAppearFromGround(pthis); + } else { + EnEiyer_SetupInactive(pthis); + } +} + +void EnEiyer_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnEiyer* pthis = (EnEiyer*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnEiyer_RotateAroundHome(EnEiyer* pthis) { + pthis->actor.world.pos.x = Math_SinS(pthis->actor.world.rot.y) * 80.0f + pthis->actor.home.pos.x; + pthis->actor.world.pos.z = Math_CosS(pthis->actor.world.rot.y) * 80.0f + pthis->actor.home.pos.z; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + 0x4000; +} + +void EnEiyer_SetupAppearFromGround(EnEiyer* pthis) { + pthis->collider.info.bumper.dmgFlags = 0x19; + Animation_PlayLoop(&pthis->skelanime, &gStingerIdleAnim); + + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 40.0f; + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + + if (pthis->actor.params != 0xA) { + if (pthis->actor.params == 0) { + pthis->actor.world.rot.y = Rand_ZeroOne() * 0x10000; + } else { + pthis->actor.world.rot.y = pthis->actor.parent->world.rot.y + pthis->actor.params * 0x4000; + } + EnEiyer_RotateAroundHome(pthis); + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = Rand_ZeroOne() * 0x10000; + } + + pthis->collider.base.atFlags &= ~AT_ON; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_12); + pthis->actor.shape.shadowScale = 0.0f; + pthis->actor.shape.yOffset = 0.0f; + pthis->actionFunc = EnEiyer_AppearFromGround; +} + +void EnEiyer_SetupUnderground(EnEiyer* pthis) { + if (pthis->actor.params == 0xA) { + pthis->actor.speedXZ = -0.5f; + pthis->actionFunc = EnEiyer_WanderUnderground; + } else { + pthis->actionFunc = EnEiyer_CircleUnderground; + } + + pthis->collider.base.acFlags |= AC_ON; + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.flags |= ACTOR_FLAG_0; +} + +void EnEiyer_SetupInactive(EnEiyer* pthis) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actionFunc = EnEiyer_Inactive; +} + +void EnEiyer_SetupAmbush(EnEiyer* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + Animation_PlayOnce(&pthis->skelanime, &gStingerBackflipAnim); + pthis->collider.info.bumper.dmgFlags = ~0x00300000; + pthis->basePos = pthis->actor.world.pos; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.flags |= ACTOR_FLAG_12; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.shape.shadowScale = 65.0f; + pthis->actor.shape.yOffset = 600.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_JUMP); + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, NULL, NULL, 1, 700); + pthis->actionFunc = EnEiyer_Ambush; +} + +void EnEiyer_SetupGlide(EnEiyer* pthis) { + pthis->targetYaw = pthis->actor.shape.rot.y; + pthis->basePos.y = (cosf(-M_PI / 8) * 5.0f) + pthis->actor.world.pos.y; + Animation_MorphToLoop(&pthis->skelanime, &gStingerHitAnim, -5.0f); + pthis->timer = 60; + pthis->actionFunc = EnEiyer_Glide; +} + +void EnEiyer_SetupStartAttack(EnEiyer* pthis) { + pthis->actionFunc = EnEiyer_StartAttack; +} + +void EnEiyer_SetupDiveAttack(EnEiyer* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->actor.velocity.y = 0.0f; + pthis->basePos.y = player->actor.world.pos.y + 15.0f; + pthis->collider.base.atFlags |= AT_ON; + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->actionFunc = EnEiyer_DiveAttack; +} + +void EnEiyer_SetupLand(EnEiyer* pthis) { + Animation_MorphToPlayOnce(&pthis->skelanime, &gStingerDiveAnim, -3.0f); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->actor.flags |= ACTOR_FLAG_4; + + // Update BgCheck info, play sound, and spawn effect on the first frame of the land action + pthis->timer = -1; + pthis->actor.gravity = 0.0f; + pthis->collider.dim.height = sColCylInit.dim.height; + pthis->actionFunc = EnEiyer_Land; +} + +void EnEiyer_SetupHurt(EnEiyer* pthis) { + pthis->basePos.y = pthis->actor.world.pos.y; + Animation_Change(&pthis->skelanime, &gStingerHitAnim, 2.0f, 0.0f, 0.0f, 0, -3.0f); + pthis->timer = 40; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 5.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 200, 0, 40); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnEiyer_Hurt; +} + +void EnEiyer_SetupDie(EnEiyer* pthis) { + pthis->timer = 20; + Actor_SetColorFilter(&pthis->actor, 0x4000, 200, 0, 40); + + if (pthis->collider.info.bumper.dmgFlags != 0x19) { + pthis->actor.speedXZ = 6.0f; + Animation_MorphToLoop(&pthis->skelanime, &gStingerHitAnim, -3.0f); + } else { + pthis->actor.speedXZ -= 6.0f; + } + + pthis->collider.info.bumper.dmgFlags = ~0x00300000; + pthis->collider.base.atFlags &= ~AT_ON; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnEiyer_Die; +} + +void EnEiyer_SetupDead(EnEiyer* pthis) { + pthis->actor.colorFilterParams |= 0x2000; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actionFunc = EnEiyer_Dead; +} + +void EnEiyer_SetupStunned(EnEiyer* pthis) { + Animation_Change(&pthis->skelanime, &gStingerPopOutAnim, 2.0f, 0.0f, 0.0f, 0, -8.0f); + pthis->timer = 80; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -1.0f; + pthis->collider.dim.height = sColCylInit.dim.height + 8; + Actor_SetColorFilter(&pthis->actor, 0, 200, 0, 80); + pthis->collider.base.atFlags &= ~AT_ON; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actionFunc = EnEiyer_Stunned; +} + +void EnEiyer_AppearFromGround(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.75f)) { + EnEiyer_SetupUnderground(pthis); + } +} + +void EnEiyer_CheckPlayerCollision(EnEiyer* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + pthis->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + EnEiyer_SetupAmbush(pthis, globalCtx); + } +} + +void EnEiyer_CircleUnderground(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + pthis->actor.world.rot.y += -0x60; + EnEiyer_RotateAroundHome(pthis); + EnEiyer_CheckPlayerCollision(pthis, globalCtx); + + // Clones disappear when the main Eiyer leaves the ground + if (pthis->actor.params != 0 && ((EnEiyer*)pthis->actor.parent)->actionFunc != EnEiyer_CircleUnderground) { + EnEiyer_SetupInactive(pthis); + } +} + +void EnEiyer_WanderUnderground(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) > 100.0f) { + pthis->targetYaw = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos) + 0x8000; + } else if (pthis->targetYaw == pthis->actor.world.rot.y && Rand_ZeroOne() > 0.99f) { + pthis->targetYaw = + pthis->actor.world.rot.y + (Rand_ZeroOne() < 0.5f ? -1 : 1) * (Rand_ZeroOne() * 0x2000 + 0x2000); + } + + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->targetYaw, 0xB6); + EnEiyer_CheckPlayerCollision(pthis, globalCtx); +} + +void EnEiyer_Inactive(EnEiyer* pthis, GlobalContext* globalCtx) { + EnEiyer* parent; + + if (pthis->actor.home.pos.y - 50.0f < pthis->actor.world.pos.y) { + pthis->actor.world.pos.y -= 0.5f; + } + + parent = (EnEiyer*)pthis->actor.parent; + if (parent->actionFunc == EnEiyer_Dead) { + Actor_Kill(&pthis->actor); + } else if (parent->actionFunc == EnEiyer_AppearFromGround) { + EnEiyer_SetupAppearFromGround(pthis); + } +} + +void EnEiyer_Ambush(EnEiyer* pthis, GlobalContext* globalCtx) { + s32 animFinished; + f32 curFrame; + f32 xzOffset; + s32 bgId; + + animFinished = SkelAnime_Update(&pthis->skelanime); + curFrame = pthis->skelanime.curFrame; + + if (pthis->skelanime.curFrame < 12.0f) { + pthis->actor.world.pos.y = ((1.0f - cosf((0.996f * M_PI / 12.0f) * curFrame)) * 40.0f) + pthis->actor.home.pos.y; + xzOffset = sinf((0.996f * M_PI / 12.0f) * curFrame) * -40.0f; + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y) * xzOffset) + pthis->basePos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y) * xzOffset) + pthis->basePos.z; + } else { + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 80.0f, 0.5f); + pthis->actor.speedXZ = 0.8f; + } + + if (animFinished) { + pthis->collider.base.acFlags |= AC_ON; + EnEiyer_SetupGlide(pthis); + } else { + pthis->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, + &pthis->actor, &pthis->actor.world.pos); + } +} + +void EnEiyer_Glide(EnEiyer* pthis, GlobalContext* globalCtx) { + f32 curFrame; + s32 pad; + s16 yawChange; + + SkelAnime_Update(&pthis->skelanime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + curFrame = pthis->skelanime.curFrame; + Math_ApproachF(&pthis->basePos.y, pthis->actor.floorHeight + 80.0f + 5.0f, 0.3f, pthis->actor.speedXZ); + pthis->actor.world.pos.y = pthis->basePos.y - cosf((curFrame - 5.0f) * (M_PI / 40)) * 5.0f; + + if (curFrame <= 45.0f) { + Math_StepToF(&pthis->actor.speedXZ, 1.0f, 0.03f); + } else { + Math_StepToF(&pthis->actor.speedXZ, 1.5f, 0.03f); + } + + if (pthis->actor.bgCheckFlags & 8) { + pthis->targetYaw = pthis->actor.wallYaw; + } + + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->targetYaw, 0xB6)) { + if (pthis->timer != 0 || Rand_ZeroOne() > 0.05f) { + pthis->actor.world.rot.y += 0x100; + } else { + yawChange = Rand_S16Offset(0x2000, 0x2000); + pthis->targetYaw = (Rand_ZeroOne() < 0.5f ? -1 : 1) * yawChange + pthis->actor.world.rot.y; + } + } + + if (pthis->timer == 0 && pthis->actor.yDistToPlayer < 0.0f && pthis->actor.xzDistToPlayer < 120.0f) { + EnEiyer_SetupStartAttack(pthis); + } + + func_8002F974(&pthis->actor, NA_SE_EN_EIER_FLY - SFX_FLAG); +} + +void EnEiyer_StartAttack(EnEiyer* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f focus; + + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.shape.rot.x > 0 && pthis->actor.shape.rot.x < 0x8000) { + focus.x = player->actor.world.pos.x; + focus.y = player->actor.world.pos.y + 20.0f; + focus.z = player->actor.world.pos.z; + + if (Math_ScaledStepToS(&pthis->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&pthis->actor, &focus), 0x1000)) { + EnEiyer_SetupDiveAttack(pthis, globalCtx); + } + } else { + pthis->actor.shape.rot.x -= 0x1000; + } + + pthis->actor.world.rot.x = -pthis->actor.shape.rot.x; + Math_StepToF(&pthis->actor.speedXZ, 5.0f, 0.3f); + Math_ApproachS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 2, 0x71C); + func_8002F974(&pthis->actor, NA_SE_EN_EIER_FLY - SFX_FLAG); +} + +void EnEiyer_DiveAttack(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + pthis->actor.speedXZ *= 1.1f; + + if (pthis->actor.bgCheckFlags & 8 || pthis->actor.bgCheckFlags & 1) { + EnEiyer_SetupLand(pthis); + } + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~(AT_ON | AT_HIT); + } + + func_8002F974(&pthis->actor, NA_SE_EN_EIER_FLY - SFX_FLAG); +} + +void EnEiyer_Land(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ScaledStepToS(&pthis->actor.world.rot.x, -0x4000, 0x450); + Math_StepToF(&pthis->actor.speedXZ, 7.0f, 1.0f); + + if (pthis->timer == -1) { + if (pthis->actor.bgCheckFlags & 8 || pthis->actor.bgCheckFlags & 1) { + pthis->timer = 10; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 30, NA_SE_EN_OCTAROCK_SINK); + + if (pthis->actor.bgCheckFlags & 1) { + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, NULL, NULL, 1, 700); + } + } + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + pthis->actor.shape.rot.x = 0; + pthis->actor.world.rot.x = 0; + EnEiyer_SetupAppearFromGround(pthis); + } + } +} + +void EnEiyer_Hurt(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_ApproachF(&pthis->basePos.y, pthis->actor.floorHeight + 80.0f + 5.0f, 0.5f, pthis->actor.speedXZ); + pthis->actor.world.pos.y = pthis->basePos.y - 5.0f; + + if (pthis->actor.bgCheckFlags & 8) { + pthis->targetYaw = pthis->actor.wallYaw; + } else { + pthis->targetYaw = pthis->actor.yawTowardsPlayer + 0x8000; + } + + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->targetYaw, 0x38E); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x200); + pthis->actor.shape.rot.z = sinf(pthis->timer * (M_PI / 5)) * 5120.0f; + + if (pthis->timer == 0) { + pthis->actor.shape.rot.x = 0; + pthis->actor.shape.rot.z = 0; + pthis->collider.base.acFlags |= AC_ON; + EnEiyer_SetupGlide(pthis); + } + pthis->actor.world.rot.x = -pthis->actor.shape.rot.x; +} + +void EnEiyer_Die(EnEiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.speedXZ > 0.0f) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x4000, 0x400); + } else { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x4000, 0x400); + } + + pthis->actor.shape.rot.z += 0x1000; + + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.world.rot.x = -pthis->actor.shape.rot.x; + + if (pthis->timer == 0 || pthis->actor.bgCheckFlags & 0x10) { + EnEiyer_SetupDead(pthis); + } +} + +void EnEiyer_Dead(EnEiyer* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.shadowAlpha = CLAMP_MIN((s16)(pthis->actor.shape.shadowAlpha - 5), 0); + pthis->actor.world.pos.y -= 2.0f; + + if (pthis->actor.shape.shadowAlpha == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 80); + Actor_Kill(&pthis->actor); + } +} + +void EnEiyer_Stunned(EnEiyer* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x200); + SkelAnime_Update(&pthis->skelanime); + + if (Animation_OnFrame(&pthis->skelanime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_FLUTTER); + } + + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + + if (pthis->timer == 0) { + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->collider.dim.height = sColCylInit.dim.height; + EnEiyer_SetupGlide(pthis); + } +} + +void EnEiyer_UpdateDamage(EnEiyer* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + + if (pthis->actor.colChkInfo.damageEffect != 0 || pthis->actor.colChkInfo.damage != 0) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_DEAD); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + + // If underground, one hit kill + if (pthis->collider.info.bumper.dmgFlags == 0x19) { + if (pthis->actor.colChkInfo.damage == 0) { + EnEiyer_SetupAmbush(pthis, globalCtx); + } else { + EnEiyer_SetupDie(pthis); + } + } else if (pthis->actor.colChkInfo.damageEffect == 1) { + if (pthis->actionFunc != EnEiyer_Stunned) { + EnEiyer_SetupStunned(pthis); + } + } else if (pthis->actor.colChkInfo.health != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_DAMAGE); + EnEiyer_SetupHurt(pthis); + } else { + pthis->collider.dim.height = sColCylInit.dim.height; + EnEiyer_SetupDie(pthis); + } + } + } +} + +void EnEiyer_Update(Actor* thisx, GlobalContext* globalCtx) { + EnEiyer* pthis = (EnEiyer*)thisx; + s32 pad; + + EnEiyer_UpdateDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.world.rot.x == 0 || pthis->actionFunc == EnEiyer_Stunned) { + Actor_MoveForward(&pthis->actor); + } else { + func_8002D97C(&pthis->actor); + } + + if (pthis->actionFunc == EnEiyer_Glide || pthis->actionFunc == EnEiyer_DiveAttack || + pthis->actionFunc == EnEiyer_Stunned || pthis->actionFunc == EnEiyer_Die || pthis->actionFunc == EnEiyer_Hurt || + (pthis->actionFunc == EnEiyer_Land && pthis->timer == -1)) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 27.0f, 30.0f, 7); + } + + if (pthis->actor.params == 0xA || + (pthis->actionFunc != EnEiyer_AppearFromGround && pthis->actionFunc != EnEiyer_CircleUnderground)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + // only the main Eiyer can ambush the player + if (pthis->actor.params == 0 || pthis->actor.params == 0xA) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (pthis->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->actionFunc != EnEiyer_Ambush) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + if (pthis->actor.flags & ACTOR_FLAG_0) { + pthis->actor.focus.pos.x = pthis->actor.world.pos.x + Math_SinS(pthis->actor.shape.rot.y) * 12.5f; + pthis->actor.focus.pos.z = pthis->actor.world.pos.z + Math_CosS(pthis->actor.shape.rot.y) * 12.5f; + pthis->actor.focus.pos.y = pthis->actor.world.pos.y; + } +} + +s32 EnEiyer_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnEiyer* pthis = (EnEiyer*)thisx; + + if (limbIndex == 1) { + pos->z += 2500.0f; + } + + if (pthis->collider.info.bumper.dmgFlags == 0x19 && limbIndex != 9 && limbIndex != 10) { + *dList = NULL; + } + return 0; +} + +void EnEiyer_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnEiyer* pthis = (EnEiyer*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_eiyer.c", 1494); + if (pthis->actionFunc != EnEiyer_Dead) { + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, + EnEiyer_OverrideLimbDraw, NULL, pthis, POLY_OPA_DISP); + } else { + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, D_80116280); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, pthis->actor.shape.shadowAlpha); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, + EnEiyer_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_eiyer.c", 1541); +} diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c deleted file mode 100644 index 1270257ac..000000000 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ /dev/null @@ -1,1576 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ELF_Z_EN_ELF_C -#include "actor_common.h" -/* - * File: z_en_elf.c - * Overlay: ovl_En_Elf - * Description: Fairy - */ - -#include "z_en_elf.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_elf_message.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25) - -#define FAIRY_FLAG_TIMED (1 << 8) -#define FAIRY_FLAG_BIG (1 << 9) - -void EnElf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnElf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A053F0(Actor* thisx, GlobalContext* globalCtx); -void func_80A052F4(Actor* thisx, GlobalContext* globalCtx); -void func_80A05208(Actor* thisx, GlobalContext* globalCtx); -void func_80A05188(Actor* thisx, GlobalContext* globalCtx); -void func_80A05114(Actor* thisx, GlobalContext* globalCtx); -void func_80A05040(Actor* thisx, GlobalContext* globalCtx); - -// Navi -void func_80A03CF8(EnElf* this, GlobalContext* globalCtx); - -// Healing Fairies -void func_80A0329C(EnElf* this, GlobalContext* globalCtx); -void func_80A03610(EnElf* this, GlobalContext* globalCtx); - -// Healing Fairies Revive From Death -void func_80A03990(EnElf* this, GlobalContext* globalCtx); -void func_80A03814(EnElf* this, GlobalContext* globalCtx); - -// Kokiri Fairies -void func_80A0353C(EnElf* this, GlobalContext* globalCtx); - -// Fairy Spawner -void func_80A03604(EnElf* this, GlobalContext* globalCtx); - -// Move(?) functions -void func_80A0214C(EnElf* this, GlobalContext* globalCtx); -void func_80A02AA4(EnElf* this, GlobalContext* globalCtx); -void func_80A02A20(EnElf* this, GlobalContext* globalCtx); -void func_80A02B38(EnElf* this, GlobalContext* globalCtx); -void func_80A020A4(EnElf* this, GlobalContext* globalCtx); -void func_80A01FE0(EnElf* this, GlobalContext* globalCtx); - -// misc -void func_80A04414(EnElf* this, GlobalContext* globalCtx); -void func_80A0461C(EnElf* this, GlobalContext* globalCtx); -void EnElf_SpawnSparkles(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife); -void EnElf_GetCutsceneNextPos(Vec3f* vec, GlobalContext* globalCtx, s32 action); - -const ActorInit En_Elf_InitVars = { - ACTOR_EN_ELF, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnElf), - (ActorFunc)EnElf_Init, - (ActorFunc)EnElf_Destroy, - (ActorFunc)EnElf_Update, - (ActorFunc)EnElf_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 8, ICHAIN_STOP), -}; - -static Color_RGBAf sInnerColors[] = { - { 255.0f, 255.0f, 255.0f, 255.0f }, - { 255.0f, 220.0f, 220.0f, 255.0f }, -}; - -static Color_RGBAf sOuterColors[] = { - { 255.0f, 255.0f, 255.0f, 255.0f }, - { 255.0f, 50.0f, 100.0f, 255.0f }, -}; - -typedef struct { - u8 r, g, b; -} FairyColorFlags; - -static FairyColorFlags sColorFlags[] = { - { 0, 0, 0 }, { 1, 0, 0 }, { 1, 2, 0 }, { 1, 0, 2 }, { 0, 1, 0 }, { 2, 1, 0 }, { 0, 1, 2 }, - { 0, 0, 1 }, { 2, 0, 1 }, { 0, 2, 1 }, { 1, 1, 0 }, { 1, 0, 1 }, { 0, 1, 1 }, -}; - -void EnElf_SetupAction(EnElf* this, EnElfActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void func_80A01C38(EnElf* this, s32 arg1) { - this->unk_2A8 = arg1; - - switch (this->unk_2A8) { - case 0: - this->unk_2AE = 0x400; - this->unk_2B0 = 0x200; - this->func_2C8 = func_80A02A20; - this->unk_2C0 = 100; - this->unk_2B4 = 5.0f; - this->unk_2B8 = 20.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 12: - this->unk_2AE = 0x400; - this->unk_2B0 = 0x200; - this->func_2C8 = func_80A02A20; - this->unk_2C0 = 100; - this->unk_2B4 = 1.0f; - this->unk_2B8 = 5.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 10: - this->unk_2AE = 0x400; - this->unk_2B0 = 0; - this->func_2C8 = func_80A02A20; - this->unk_2B8 = 0.0f; - this->unk_2B4 = 5.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 9: - this->unk_2AE = 0x1000; - this->unk_2B0 = 0x200; - this->func_2C8 = func_80A02A20; - this->unk_2B4 = 3.0f; - this->unk_2B8 = 10.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 7: - this->func_2C8 = func_80A02A20; - this->unk_2AE = 0x1E; - this->unk_2C0 = 1; - this->unk_2B4 = 0.0f; - this->unk_2B8 = 0.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 8: - this->unk_2AE = 0x1000; - this->unk_2B0 = 0x200; - this->func_2C8 = func_80A02A20; - this->unk_2B4 = 0.0f; - this->unk_2B8 = 0.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 1: - this->unk_2AE = 0x1000; - this->unk_2B0 = 0x800; - this->func_2C8 = func_80A02A20; - this->unk_2B4 = 5.0f; - this->unk_2B8 = 7.5f; - this->skelAnime.playSpeed = 2.0f; - break; - case 2: - this->unk_2AE = 0x400; - this->unk_2B0 = 0x1000; - this->func_2C8 = func_80A02AA4; - this->unk_2B4 = 10.0f; - this->unk_2B8 = 20.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 3: - this->unk_2B0 = 0x600; - this->func_2C8 = func_80A02B38; - this->unk_2B8 = 1.0f; - this->unk_2B4 = 1.0f; - this->skelAnime.playSpeed = 1.0f; - break; - case 4: - this->unk_2B0 = 0x800; - this->func_2C8 = func_80A02B38; - this->unk_2B4 = 20.0f; - this->unk_2B8 = 10.0; - this->skelAnime.playSpeed = 2.0f; - break; - case 5: - this->unk_2B0 = 0x200; - this->func_2C8 = func_80A02B38; - this->unk_2B4 = 10.0f; - this->unk_2B8 = 10.0f; - this->skelAnime.playSpeed = 0.5f; - break; - case 6: - this->unk_2AE = 0x1000; - this->unk_2B0 = 0x800; - this->func_2C8 = func_80A02A20; - this->unk_2B4 = 60.0f; - this->unk_2B8 = 20.0f; - this->skelAnime.playSpeed = 2.0f; - break; - case 11: - this->unk_2AE = 0x400; - this->unk_2B0 = 0x2000; - this->func_2C8 = func_80A02A20; - this->unk_2C0 = 42; - this->unk_2B4 = 5.0f; - this->unk_2B8 = 1.0f; - this->skelAnime.playSpeed = 1.0f; - break; - } -} - -s32 func_80A01F90(Vec3f* this, Vec3f* arg1, f32 arg2) { - return SQ(arg2) < (SQ(arg1->x - this->x) + SQ(arg1->z - this->z)); -} - -void func_80A01FE0(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (!func_80A01F90(&this->actor.world.pos, &player->actor.world.pos, 30.0f)) { - this->unk_2B8 = 0.5f; - } else { - this->unk_2B8 = 2.0f; - } - - if (this->unk_2C0 > 0) { - this->unk_2C0--; - } else { - this->unk_2A8 = 1; - this->unk_2AC = 0x80; - this->unk_2B8 = Rand_ZeroFloat(1.0f) + 0.5f; - this->unk_2B0 = Rand_CenteredFloat(32767.0f); - this->func_2C8 = func_80A0214C; - } -} - -void func_80A020A4(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (func_80A01F90(&this->actor.world.pos, &player->actor.world.pos, 50.0f)) { - if (this->unk_2C0 > 0) { - this->unk_2C0--; - } else { - this->unk_2A8 = 1; - this->unk_2AC = 0x80; - this->unk_2B8 = Rand_ZeroFloat(1.0f) + 0.5f; - this->unk_2B0 = Rand_CenteredFloat(32767.0f); - this->func_2C8 = func_80A0214C; - } - } -} - -void func_80A0214C(EnElf* this, GlobalContext* globalCtx) { - f32 xzDistToPlayer; - - if (this->unk_2C0 > 0) { - this->unk_2C0--; - } else { - xzDistToPlayer = this->actor.xzDistToPlayer; - if (xzDistToPlayer < 50.0f) { - if (Rand_ZeroOne() < 0.2f) { - this->unk_2A8 = 2; - this->unk_2AC = 0x400; - this->unk_2B8 = 2.0f; - this->func_2C8 = func_80A020A4; - this->actor.speedXZ = 1.5f; - this->unk_2C0 = (s16)Rand_ZeroFloat(8.0f) + 4; - } else { - this->unk_2C0 = 10; - } - } else { - if (xzDistToPlayer > 150.0f) { - xzDistToPlayer = 150.0f; - } - - xzDistToPlayer = ((xzDistToPlayer - 50.0f) * 0.95f) + 0.05f; - - if (Rand_ZeroOne() < xzDistToPlayer) { - this->unk_2A8 = 3; - this->unk_2AC = 0x200; - this->unk_2B8 = (xzDistToPlayer * 2.0f) + 1.0f; - this->func_2C8 = func_80A01FE0; - this->unk_2C0 = (s16)Rand_ZeroFloat(16.0f) + 0x10; - } else { - this->unk_2C0 = 10; - } - } - } - - if (Rand_ZeroOne() < 0.1f) { - this->unk_2A8 = 1; - this->unk_2AC = 0x80; - this->unk_2B8 = Rand_ZeroFloat(0.5f) + 0.5f; - this->unk_2B0 = Rand_CenteredFloat(32767.0f); - } -} - -void func_80A0232C(EnElf* this, GlobalContext* globalCtx) { - if (func_80A01F90(&this->unk_28C, &this->actor.world.pos, 100.0f)) { - this->unk_2A8 = 0; - this->unk_2AC = 0x200; - this->func_2C8 = func_80A0214C; - this->unk_2B8 = 1.5f; - } else { - this->func_2C8(this, globalCtx); - } -} - -f32 EnElf_GetColorValue(s32 colorFlag) { - switch (colorFlag) { - case 1: - return Rand_ZeroFloat(55.0f) + 200.0f; - case 2: - return Rand_ZeroFloat(255.0f); - default: - return 0.0f; - } -} - -void EnElf_Init(Actor* thisx, GlobalContext* globalCtx) { - EnElf* this = (EnElf*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 colorConfig; - s32 i; - - Actor_ProcessInitChain(thisx, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gFairySkel, &gFairyAnim, this->jointTable, this->morphTable, 15); - ActorShape_Init(&thisx->shape, 0.0f, NULL, 15.0f); - thisx->shape.shadowAlpha = 0xFF; - - Lights_PointGlowSetInfo(&this->lightInfoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, 255, - 255, 0); - this->lightNodeGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoGlow); - - Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, - 255, 255, 0); - this->lightNodeNoGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoNoGlow); - - this->fairyFlags = 0; - this->disappearTimer = 600; - this->unk_2A4 = 0.0f; - colorConfig = 0; - - switch (thisx->params) { - case FAIRY_NAVI: - thisx->room = -1; - EnElf_SetupAction(this, func_80A03CF8); - func_80A01C38(this, 0); - this->fairyFlags |= 4; - thisx->update = func_80A053F0; - this->elfMsg = NULL; - this->unk_2C7 = 0x14; - - if ((gSaveContext.naviTimer >= 25800) || (gSaveContext.naviTimer < 3000)) { - gSaveContext.naviTimer = 0; - } - break; - case FAIRY_REVIVE_BOTTLE: - colorConfig = -1; - EnElf_SetupAction(this, func_80A03610); - this->unk_2B8 = Math_Vec3f_DistXZ(&thisx->world.pos, &player->actor.world.pos); - this->unk_2AC = player->actor.shape.rot.y; - this->unk_2B0 = -0x1000; - this->unk_28C.y = thisx->world.pos.y - player->actor.world.pos.y; - this->unk_2AA = 0; - this->unk_2B4 = 0.0f; - break; - case FAIRY_REVIVE_DEATH: - colorConfig = -1; - EnElf_SetupAction(this, func_80A03990); - this->unk_2B8 = 0.0f; - this->unk_2AC = player->actor.shape.rot.y; - this->unk_2B0 = 0; - this->unk_28C.y = thisx->world.pos.y - player->actor.world.pos.y; - this->unk_2AA = 0; - this->unk_2B4 = 7.0f; - break; - case FAIRY_HEAL_BIG: - this->fairyFlags |= FAIRY_FLAG_BIG; - thisx->shape.shadowDraw = ActorShadow_DrawWhiteCircle; - case FAIRY_HEAL_TIMED: - this->fairyFlags |= FAIRY_FLAG_TIMED; - case FAIRY_HEAL: - colorConfig = -1; - EnElf_SetupAction(this, func_80A0329C); - this->unk_2B4 = Rand_ZeroFloat(10.0f) + 10.0f; - this->unk_2AA = 0; - this->unk_2AE = (s16)(Rand_ZeroFloat(1048.0f)) + 0x200; - this->unk_28C = thisx->world.pos; - this->unk_2BC = Rand_CenteredFloat(32767.0f); - this->func_2C8 = func_80A0214C; - func_80A0232C(this, globalCtx); - this->unk_2C0 = 0; - this->disappearTimer = 240; - break; - case FAIRY_KOKIRI: - colorConfig = Rand_ZeroFloat(11.99f) + 1.0f; - EnElf_SetupAction(this, func_80A0353C); - func_80A01C38(this, 0); - break; - case FAIRY_SPAWNER: - EnElf_SetupAction(this, func_80A03604); - func_80A01C38(this, 8); - - for (i = 0; i < 8; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, thisx->world.pos.x, - thisx->world.pos.y - 30.0f, thisx->world.pos.z, 0, 0, 0, FAIRY_HEAL); - } - break; - default: - ASSERT(0, "0", "../z_en_elf.c", 1103); - break; - } - - this->unk_2A0 = 3.0f; - this->innerColor = sInnerColors[0]; - - if (colorConfig > 0) { - this->outerColor.r = EnElf_GetColorValue(sColorFlags[colorConfig].r); - this->outerColor.g = EnElf_GetColorValue(sColorFlags[colorConfig].g); - this->outerColor.b = EnElf_GetColorValue(sColorFlags[colorConfig].b); - this->outerColor.a = 0.0f; - } else { - this->innerColor = sInnerColors[-colorConfig]; - this->outerColor = sOuterColors[-colorConfig]; - } -} - -void func_80A0299C(EnElf* this, s32 arg1) { -} - -void func_80A029A8(EnElf* this, s16 increment) { - if (this->disappearTimer < 600) { - this->disappearTimer += increment; - } -} - -void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnElf* this = (EnElf*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNodeGlow); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNodeNoGlow); -} - -void func_80A02A20(EnElf* this, GlobalContext* globalCtx) { - this->unk_28C.x = Math_SinS(this->unk_2AC) * this->unk_2B8; - this->unk_28C.y = Math_SinS(this->unk_2AA) * this->unk_2B4; - this->unk_28C.z = Math_CosS(this->unk_2AC) * this->unk_2B8; - this->unk_2AC += this->unk_2B0; - this->unk_2AA += this->unk_2AE; -} - -void func_80A02AA4(EnElf* this, GlobalContext* globalCtx) { - f32 xzScale; - - xzScale = (Math_CosS(this->unk_2AA) * this->unk_2B4) + this->unk_2B8; - - this->unk_28C.x = Math_SinS(this->unk_2AC) * xzScale; - this->unk_28C.y = 0.0f; - this->unk_28C.z = Math_CosS(this->unk_2AC) * xzScale; - - this->unk_2AC += this->unk_2B0; - this->unk_2AA += this->unk_2AE; -} - -void func_80A02B38(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_2AA = (this->unk_2AC * 2) & 0xFFFF; - this->unk_28C.x = Math_SinS(this->unk_2AC) * this->unk_2B8; - this->unk_28C.y = Math_SinS(this->unk_2AA) * this->unk_2B4; - this->unk_28C.z = -Math_SinS(player->actor.shape.rot.y) * this->unk_28C.x; - this->unk_28C.x = Math_CosS(player->actor.shape.rot.y) * this->unk_28C.x; - this->unk_2AC += this->unk_2B0; -} - -void func_80A02BD8(EnElf* this, Vec3f* targetPos, f32 arg2) { - f32 yVelTarget; - f32 yVelDirection; - - yVelTarget = ((targetPos->y + this->unk_28C.y) - this->actor.world.pos.y) * arg2; - yVelDirection = (yVelTarget >= 0.0f) ? 1.0f : -1.0f; - yVelTarget = fabsf(yVelTarget); - yVelTarget = CLAMP(yVelTarget, 0.0f, 20.0f) * yVelDirection; - Math_StepToF(&this->actor.velocity.y, yVelTarget, 32.0f); -} - -void func_80A02C98(EnElf* this, Vec3f* targetPos, f32 arg2) { - f32 xVelTarget; - f32 zVelTarget; - f32 xVelDirection; - f32 zVelDirection; - - xVelTarget = ((targetPos->x + this->unk_28C.x) - this->actor.world.pos.x) * arg2; - zVelTarget = ((targetPos->z + this->unk_28C.z) - this->actor.world.pos.z) * arg2; - - xVelDirection = (xVelTarget >= 0.0f) ? 1.0f : -1.0f; - zVelDirection = (zVelTarget >= 0.0f) ? 1.0f : -1.0f; - - xVelTarget = fabsf(xVelTarget); - zVelTarget = fabsf(zVelTarget); - - xVelTarget = CLAMP(xVelTarget, 0.0f, 20.0f) * xVelDirection; - zVelTarget = CLAMP(zVelTarget, 0.0f, 20.0f) * zVelDirection; - - func_80A02BD8(this, targetPos, arg2); - Math_StepToF(&this->actor.velocity.x, xVelTarget, 1.5f); - Math_StepToF(&this->actor.velocity.z, zVelTarget, 1.5f); - func_8002D7EC(&this->actor); -} - -void func_80A02E30(EnElf* this, Vec3f* targetPos) { - func_80A02BD8(this, targetPos, 0.2f); - this->actor.velocity.x = (targetPos->x + this->unk_28C.x) - this->actor.world.pos.x; - this->actor.velocity.z = (targetPos->z + this->unk_28C.z) - this->actor.world.pos.z; - func_8002D7EC(&this->actor); - this->actor.world.pos.x = targetPos->x + this->unk_28C.x; - this->actor.world.pos.z = targetPos->z + this->unk_28C.z; -} - -void func_80A02EC0(EnElf* this, Vec3f* targetPos) { - func_80A02BD8(this, targetPos, 0.2f); - this->actor.velocity.x = this->actor.velocity.z = 0.0f; - func_8002D7EC(&this->actor); - this->actor.world.pos.x = targetPos->x + this->unk_28C.x; - this->actor.world.pos.z = targetPos->z + this->unk_28C.z; -} - -void func_80A02F2C(EnElf* this, Vec3f* targetPos) { - f32 yVelTarget; - f32 yVelDirection; - - yVelTarget = (((Math_SinS(this->unk_2AA) * this->unk_2B4) + targetPos->y) - this->actor.world.pos.y) * 0.2f; - yVelDirection = (yVelTarget >= 0.0f) ? 1.0f : -1.0f; - this->unk_2AA += this->unk_2AE; - yVelTarget = fabsf(yVelTarget); - yVelTarget = CLAMP(yVelTarget, 0.0f, 20.0f) * yVelDirection; - Math_StepToF(&this->actor.velocity.y, yVelTarget, 1.5f); -} - -void func_80A03018(EnElf* this, GlobalContext* globalCtx) { - s32 pad[2]; - Player* player = GET_PLAYER(globalCtx); - s16 targetYaw; - Vec3f* unk_28C = &this->unk_28C; - - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_2B8, 0.2f, 0.5f, 0.01f); - - switch (this->unk_2A8) { - case 0: - targetYaw = Math_Atan2S(-(this->actor.world.pos.z - unk_28C->z), -(this->actor.world.pos.x - unk_28C->x)); - break; - - case 3: - targetYaw = Math_Atan2S(-(this->actor.world.pos.z - player->actor.world.pos.z), - -(this->actor.world.pos.x - player->actor.world.pos.x)); - break; - - case 2: - targetYaw = Math_Atan2S(this->actor.world.pos.z - player->actor.world.pos.z, - this->actor.world.pos.x - player->actor.world.pos.x); - break; - - default: - targetYaw = this->unk_2B0; - break; - } - - Math_SmoothStepToS(&this->unk_2BC, targetYaw, 10, this->unk_2AC, 0x20); - this->actor.world.rot.y = this->unk_2BC; - Actor_MoveForward(&this->actor); -} - -void func_80A03148(EnElf* this, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { - f32 xVelTarget; - f32 zVelTarget; - f32 xzVelocity; - f32 clampedXZ; - - xVelTarget = ((arg1->x + this->unk_28C.x) - this->actor.world.pos.x) * arg4; - zVelTarget = ((arg1->z + this->unk_28C.z) - this->actor.world.pos.z) * arg4; - arg4 += 0.3f; - arg3 += 30.0f; - - func_80A02BD8(this, arg1, arg4); - - xzVelocity = sqrtf(SQ(xVelTarget) + SQ(zVelTarget)); - - this->actor.speedXZ = clampedXZ = CLAMP(xzVelocity, arg2, arg3); - - if ((xzVelocity != clampedXZ) && (xzVelocity != 0.0f)) { - xzVelocity = clampedXZ / xzVelocity; - xVelTarget *= xzVelocity; - zVelTarget *= xzVelocity; - } - - Math_StepToF(&this->actor.velocity.x, xVelTarget, 5.0f); - Math_StepToF(&this->actor.velocity.z, zVelTarget, 5.0f); - func_8002D7EC(&this->actor); -} - -void func_80A0329C(EnElf* this, GlobalContext* globalCtx) { - Player* refActor = GET_PLAYER(globalCtx); - s32 pad; - Player* player = GET_PLAYER(globalCtx); - f32 heightDiff; - - SkelAnime_Update(&this->skelAnime); - - if (Rand_ZeroOne() < 0.05f) { - this->unk_2B4 = Rand_ZeroFloat(10.0f) + 10.0f; - this->unk_2AE = (s16)(Rand_ZeroFloat(1024.0f)) + 0x200; - } - - func_80A0232C(this, globalCtx); - this->unk_28C.y = player->bodyPartsPos[0].y; - func_80A02F2C(this, &this->unk_28C); - func_80A03018(this, globalCtx); - - if ((this->unk_2A8 == 2) || (this->unk_2A8 == 3)) { - EnElf_SpawnSparkles(this, globalCtx, 16); - } - - if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - - if (!Player_InCsMode(globalCtx)) { - heightDiff = this->actor.world.pos.y - refActor->actor.world.pos.y; - - if ((heightDiff > 0.0f) && (heightDiff < 60.0f)) { - if (!func_80A01F90(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { - Health_ChangeBy(globalCtx, 128); - if (this->fairyFlags & FAIRY_FLAG_BIG) { - Magic_Fill(globalCtx); - } - this->unk_2B8 = 50.0f; - this->unk_2AC = refActor->actor.shape.rot.y; - this->unk_2B0 = -0x1000; - this->unk_28C.y = 30.0f; - this->unk_2B4 = 0.0f; - this->unk_2AA = 0; - EnElf_SetupAction(this, func_80A03610); - return; - } - } - - if (this->fairyFlags & FAIRY_FLAG_TIMED) { - if (this->disappearTimer > 0) { - this->disappearTimer--; - } else { - this->disappearTimer--; - - if (this->disappearTimer > -10) { - Actor_SetScale(&this->actor, ((this->disappearTimer + 10) * 0.008f) * 0.1f); - } else { - Actor_Kill(&this->actor); - return; - } - } - } - - if (!(this->fairyFlags & FAIRY_FLAG_BIG)) { - // GI_MAX in this case allows the player to catch the actor in a bottle - func_8002F434(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); - } - } -} - -void func_80A0353C(EnElf* this, GlobalContext* globalCtx) { - Vec3f parentPos; - Actor* parent; - - SkelAnime_Update(&this->skelAnime); - func_80A02A20(this, globalCtx); - parent = this->actor.parent; - - if ((parent != NULL) && (parent->update != NULL)) { - parentPos = this->actor.parent->world.pos; - parentPos.y += ((1500.0f * this->actor.scale.y) + 40.0f); - func_80A02C98(this, &parentPos, 0.2f); - } else { - Actor_Kill(&this->actor); - } - - this->unk_2BC = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); -} - -void func_80A03604(EnElf* this, GlobalContext* globalCtx) { -} - -void func_80A03610(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->unk_2B8, 30.0f, 0.1f, 4.0f, 1.0f); - - this->unk_28C.x = Math_CosS(this->unk_2AC) * this->unk_2B8; - this->unk_28C.y = this->unk_28C.y + this->unk_2B4; - - switch (this->unk_2AA) { - case 0: - if (this->unk_2B4 < 2.0f) { - this->unk_2B4 += 0.1f; - } else { - this->unk_2AA++; - } - break; - case 1: - if (this->unk_2B4 > -1.0f) { - this->unk_2B4 -= 0.2f; - } - } - - this->unk_28C.z = Math_SinS(this->unk_2AC) * -this->unk_2B8; - this->unk_2AC += this->unk_2B0; - func_80A02C98(this, &player->actor.world.pos, 0.2f); - - if (this->unk_2B4 < 0.0f) { - if ((this->unk_28C.y < 20.0f) && (this->unk_28C.y > 0.0f)) { - Actor_SetScale(&this->actor, (this->unk_28C.y * 0.008f) * 0.05f); - } - } - - if (this->unk_28C.y < -10.0f) { - Actor_Kill(&this->actor); - return; - } - - this->unk_2BC = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - EnElf_SpawnSparkles(this, globalCtx, 32); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); -} - -void func_80A03814(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_28C.y > 200.0f) { - Actor_Kill(&this->actor); - return; - } - - if (this->unk_2AE >= 0x7E) { - this->unk_2B8 += 0.1f; - this->unk_2B4 += 0.5f; - this->unk_28C.y += this->unk_2B4; - } else { - this->unk_2AE++; - - if (this->unk_2B8 < 30.0f) { - this->unk_2B8 += 0.5f; - } - - if (this->unk_28C.y > 0.0f) { - this->unk_28C.y -= 0.7f; - } - } - - this->unk_28C.x = Math_CosS(this->unk_2AC) * this->unk_2B8; - this->unk_28C.z = Math_SinS(this->unk_2AC) * -this->unk_2B8; - this->unk_2AC += this->unk_2B0; - func_80A02E30(this, &player->bodyPartsPos[0]); - this->unk_2BC = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - EnElf_SpawnSparkles(this, globalCtx, 32); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); -} - -void func_80A03990(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - - this->unk_28C.z = 0.0f; - this->unk_28C.x = 0.0f; - this->unk_28C.y += this->unk_2B4; - this->unk_2B4 -= 0.35f; - - if (this->unk_2B4 <= 0.0f) { - EnElf_SetupAction(this, func_80A03814); - this->unk_2B0 = 0x800; - this->unk_2AE = 0; - this->unk_2B4 = 0.0f; - this->unk_2B8 = 1.0f; - } - - func_80A02E30(this, &player->bodyPartsPos[0]); - Actor_SetScale(&this->actor, (1.0f - (SQ(this->unk_2B4) * SQ(1.0f / 9.0f))) * 0.008f); - this->unk_2BC = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - EnElf_SpawnSparkles(this, globalCtx, 32); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); -} - -void func_80A03AB0(EnElf* this, GlobalContext* globalCtx) { - if (this->fairyFlags & 4) { - func_80A04414(this, globalCtx); - } - - SkelAnime_Update(&this->skelAnime); - - if (this->func_2C8 == NULL) { - ASSERT(0, "0", "../z_en_elf.c", 1725); - } - - this->func_2C8(this, globalCtx); -} - -void EnElf_UpdateLights(EnElf* this, GlobalContext* globalCtx) { - s16 glowLightRadius; - Player* player; - - glowLightRadius = 100; - - if (this->unk_2A8 == 8) { - glowLightRadius = 0; - } - - if (this->fairyFlags & 0x20) { - player = GET_PLAYER(globalCtx); - Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, player->actor.world.pos.x, - (s16)(player->actor.world.pos.y) + 60.0f, player->actor.world.pos.z, 255, 255, 255, - 200); - } else { - Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, -1); - } - - Lights_PointGlowSetInfo(&this->lightInfoGlow, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, glowLightRadius); - - this->unk_2BC = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - - Actor_SetScale(&this->actor, this->actor.scale.x); -} - -void func_80A03CF8(EnElf* this, GlobalContext* globalCtx) { - Vec3f nextPos; - Vec3f prevPos; - Player* player = GET_PLAYER(globalCtx); - Actor* arrowPointedActor; - f32 xScale; - f32 distFromLinksHead; - - func_80A0461C(this, globalCtx); - func_80A03AB0(this, globalCtx); - - xScale = 0.0f; - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[8] != NULL)) { - EnElf_GetCutsceneNextPos(&nextPos, globalCtx, 8); - - if (globalCtx->csCtx.npcActions[8]->action == 5) { - if (1) {} - EnElf_SpawnSparkles(this, globalCtx, 16); - } - - prevPos = this->actor.world.pos; - - if (this->unk_2A8 == 0xA) { - func_80A02EC0(this, &nextPos); - } else { - func_80A02C98(this, &nextPos, 0.2f); - } - - if ((globalCtx->sceneNum == SCENE_LINK_HOME) && (gSaveContext.sceneSetupIndex == 4)) { - // play dash sound as Navi enters Links house in the intro - if (1) {} - if (globalCtx->csCtx.frames == 55) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIRY_DASH); - } - - // play dash sound in intervals as Navi is waking up Link in the intro - if (this->unk_2A8 == 6) { - if (this->fairyFlags & 0x40) { - if (prevPos.y < this->actor.world.pos.y) { - this->fairyFlags &= ~0x40; - } - } else { - if (this->actor.world.pos.y < prevPos.y) { - this->fairyFlags |= 0x40; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIRY_DASH); - } - } - } - } - } else { - distFromLinksHead = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &this->actor.world.pos); - - switch (this->unk_2A8) { - case 7: - func_80A02C98(this, &player->bodyPartsPos[8], 1.0f - this->unk_2AE * (1.0f / 30.0f)); - xScale = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &this->actor.world.pos); - - if (distFromLinksHead < 7.0f) { - this->unk_2C0 = 0; - xScale = 0.0f; - } else if (distFromLinksHead < 25.0f) { - xScale = (xScale - 5.0f) * 0.05f; - xScale = 1.0f - xScale; - xScale = (1.0f - SQ(xScale)) * 0.008f; - } else { - xScale = 0.008f; - } - EnElf_SpawnSparkles(this, globalCtx, 16); - break; - case 8: - func_80A02C98(this, &player->bodyPartsPos[8], 0.2f); - this->actor.world.pos = player->bodyPartsPos[8]; - func_80A029A8(this, 1); - break; - case 11: - nextPos = player->bodyPartsPos[8]; - nextPos.y += 1500.0f * this->actor.scale.y; - func_80A02E30(this, &nextPos); - EnElf_SpawnSparkles(this, globalCtx, 16); - - if (this->unk_2B8 <= 19.0f) { - this->unk_2B8 += 1.0f; - } - - if (this->unk_2B8 >= 21.0f) { - this->unk_2B8 -= 1.0f; - } - - if (this->unk_2C0 < 0x20) { - this->unk_2B0 = (this->unk_2C0 * 0xF0) + 0x200; - func_80A0299C(this, 1); - } - break; - case 12: - nextPos = GET_ACTIVE_CAM(globalCtx)->eye; - nextPos.y += (-2000.0f * this->actor.scale.y); - func_80A03148(this, &nextPos, 0.0f, 20.0f, 0.2f); - break; - default: - func_80A029A8(this, 1); - nextPos = globalCtx->actorCtx.targetCtx.naviRefPos; - nextPos.y += (1500.0f * this->actor.scale.y); - arrowPointedActor = globalCtx->actorCtx.targetCtx.arrowPointedActor; - - if (arrowPointedActor != NULL) { - func_80A03148(this, &nextPos, 0.0f, 20.0f, 0.2f); - - if (this->actor.speedXZ >= 5.0f) { - EnElf_SpawnSparkles(this, globalCtx, 16); - } - } else { - if ((this->timer % 32) == 0) { - this->unk_2A0 = Rand_ZeroFloat(7.0f) + 3.0f; - } - - if (this->fairyFlags & 2) { - if (distFromLinksHead < 30.0f) { - this->fairyFlags ^= 2; - } - - func_80A03148(this, &nextPos, 0.0f, 20.0f, 0.2f); - EnElf_SpawnSparkles(this, globalCtx, 16); - } else { - if (distFromLinksHead > 100.0f) { - this->fairyFlags |= 2; - - if (this->unk_2C7 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIRY_DASH); - } - - this->unk_2C0 = 0x64; - } - func_80A03148(this, &nextPos, 0.0f, this->unk_2A0, 0.2f); - } - } - break; - } - } - - if (this->unk_2A8 == 7) { - this->actor.scale.x = xScale; - } else if (this->unk_2A8 == 8) { - this->actor.scale.x = 0.0f; - } else { - Math_SmoothStepToF(&this->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); - } - - EnElf_UpdateLights(this, globalCtx); -} - -void EnElf_ChangeColor(Color_RGBAf* dest, Color_RGBAf* newColor, Color_RGBAf* curColor, f32 rate) { - Color_RGBAf rgbaDiff; - - rgbaDiff.r = (newColor->r - curColor->r); - rgbaDiff.g = (newColor->g - curColor->g); - rgbaDiff.b = (newColor->b - curColor->b); - rgbaDiff.a = (newColor->a - curColor->a); - - dest->r += (rgbaDiff.r * rate); - dest->g += (rgbaDiff.g * rate); - dest->b += (rgbaDiff.b * rate); - dest->a += (rgbaDiff.a * rate); -} - -void func_80A04414(EnElf* this, GlobalContext* globalCtx) { - Actor* arrowPointedActor = globalCtx->actorCtx.targetCtx.arrowPointedActor; - Player* player = GET_PLAYER(globalCtx); - f32 transitionRate; - u16 targetSound; - - if (globalCtx->actorCtx.targetCtx.unk_40 != 0.0f) { - this->unk_2C6 = 0; - this->unk_29C = 1.0f; - - if (this->unk_2C7 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIRY_DASH); - } - - } else { - if (this->unk_2C6 == 0) { - if ((arrowPointedActor == NULL) || - (Math_Vec3f_DistXYZ(&this->actor.world.pos, &globalCtx->actorCtx.targetCtx.naviRefPos) < 50.0f)) { - this->unk_2C6 = 1; - } - } else if (this->unk_29C != 0.0f) { - if (Math_StepToF(&this->unk_29C, 0.0f, 0.25f) != 0) { - this->innerColor = globalCtx->actorCtx.targetCtx.naviInner; - this->outerColor = globalCtx->actorCtx.targetCtx.naviOuter; - } else { - transitionRate = 0.25f / this->unk_29C; - EnElf_ChangeColor(&this->innerColor, &globalCtx->actorCtx.targetCtx.naviInner, &this->innerColor, - transitionRate); - EnElf_ChangeColor(&this->outerColor, &globalCtx->actorCtx.targetCtx.naviOuter, &this->outerColor, - transitionRate); - } - } - } - - if (this->fairyFlags & 1) { - if ((arrowPointedActor == NULL) || (player->unk_664 == NULL)) { - this->fairyFlags ^= 1; - } - } else { - if ((arrowPointedActor != NULL) && (player->unk_664 != NULL)) { - if (arrowPointedActor->category == ACTORCAT_NPC) { - targetSound = NA_SE_VO_NAVY_HELLO; - } else { - targetSound = - (arrowPointedActor->category == ACTORCAT_ENEMY) ? NA_SE_VO_NAVY_ENEMY : NA_SE_VO_NAVY_HEAR; - } - - if (this->unk_2C7 == 0) { - Audio_PlayActorSound2(&this->actor, targetSound); - } - - this->fairyFlags |= 1; - } - } -} - -void func_80A0461C(EnElf* this, GlobalContext* globalCtx) { - s32 temp; - Actor* arrowPointedActor; - Player* player = GET_PLAYER(globalCtx); - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if (globalCtx->csCtx.npcActions[8] != NULL) { - switch (globalCtx->csCtx.npcActions[8]->action) { - case 4: - temp = 9; - break; - case 3: - temp = 6; - break; - case 1: - temp = 10; - break; - default: - temp = 0; - break; - } - } else { - temp = 0; - this->unk_2C0 = 100; - } - - } else { - arrowPointedActor = globalCtx->actorCtx.targetCtx.arrowPointedActor; - - if ((player->stateFlags1 & 0x400) || ((YREG(15) & 0x10) && func_800BC56C(globalCtx, 2))) { - temp = 12; - this->unk_2C0 = 100; - } else if (arrowPointedActor == NULL || arrowPointedActor->category == ACTORCAT_NPC) { - if (arrowPointedActor != NULL) { - this->unk_2C0 = 100; - player->stateFlags2 |= 0x100000; - temp = 0; - } else { - switch (this->unk_2A8) { - case 0: - if (this->unk_2C0 != 0) { - this->unk_2C0--; - temp = 0; - } else { - if (this->unk_2C7 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_NAVY_VANISH); - } - temp = 7; - } - break; - case 7: - if (this->unk_2C0 != 0) { - if (this->unk_2AE > 0) { - this->unk_2AE--; - temp = 7; - } else { - player->stateFlags2 |= 0x100000; - temp = 0; - } - } else { - temp = 8; - func_80A029A8(this, 10); - } - break; - case 8: - temp = 8; - break; - case 11: - temp = this->unk_2A8; - if (this->unk_2C0 > 0) { - this->unk_2C0--; - } else { - temp = 0; - } - break; - default: - temp = 0; - break; - } - } - } else { - temp = 1; - } - - switch (temp) { - case 0: - if (!(player->stateFlags2 & 0x100000)) { - temp = 7; - if (this->unk_2C7 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_NAVY_VANISH); - } - } - break; - case 8: - if (player->stateFlags2 & 0x100000) { - func_80A0299C(this, 0x32); - this->unk_2C0 = 42; - temp = 11; - if (this->unk_2C7 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIRY_DASH); - } - } - break; - case 7: - player->stateFlags2 &= ~0x100000; - break; - default: - player->stateFlags2 |= 0x100000; - break; - } - } - - if (temp != this->unk_2A8) { - func_80A01C38(this, temp); - - if (temp == 11) { - this->unk_2B8 = Math_Vec3f_DistXZ(&player->bodyPartsPos[8], &this->actor.world.pos); - this->unk_2AC = Math_Vec3f_Yaw(&this->actor.world.pos, &player->bodyPartsPos[8]); - } - } -} - -void EnElf_SpawnSparkles(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife) { - static Vec3f sparkleVelocity = { 0.0f, -0.05f, 0.0f }; - static Vec3f sparkleAccel = { 0.0f, -0.025f, 0.0f }; - s32 pad; - Vec3f sparklePos; - Color_RGBA8 primColor; - Color_RGBA8 envColor; - - sparklePos.x = Rand_CenteredFloat(6.0f) + this->actor.world.pos.x; - sparklePos.y = (Rand_ZeroOne() * 6.0f) + this->actor.world.pos.y; - sparklePos.z = Rand_CenteredFloat(6.0f) + this->actor.world.pos.z; - - primColor.r = this->innerColor.r; - primColor.g = this->innerColor.g; - primColor.b = this->innerColor.b; - - envColor.r = this->outerColor.r; - envColor.g = this->outerColor.g; - envColor.b = this->outerColor.b; - - EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, - 1000, sparkleLife); -} - -void func_80A04D90(EnElf* this, GlobalContext* globalCtx) { - s32 pad; - s32 bgId; - - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); - this->actor.shape.shadowAlpha = 0x32; -} - -// move to talk to player -void func_80A04DE4(EnElf* this, GlobalContext* globalCtx) { - Vec3f headCopy; - Player* player = GET_PLAYER(globalCtx); - Vec3f naviRefPos; - - if (this->fairyFlags & 0x10) { - naviRefPos = globalCtx->actorCtx.targetCtx.naviRefPos; - - if ((player->unk_664 == NULL) || (&player->actor == player->unk_664) || (&this->actor == player->unk_664)) { - naviRefPos.x = player->bodyPartsPos[7].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); - naviRefPos.y = player->bodyPartsPos[7].y + 5.0f; - naviRefPos.z = player->bodyPartsPos[7].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); - } - - this->actor.focus.pos = naviRefPos; - this->fairyFlags &= ~0x10; - } - - func_80A03AB0(this, globalCtx); - headCopy = this->actor.focus.pos; - - func_80A03148(this, &headCopy, 0, 20.0f, 0.2f); - - if (this->actor.speedXZ >= 5.0f) { - EnElf_SpawnSparkles(this, globalCtx, 16); - } - - Math_SmoothStepToF(&this->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); - EnElf_UpdateLights(this, globalCtx); -} - -// move after talking to player -void func_80A04F94(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_2BC, 5, 0x1000, 0x400); - this->timer++; - Math_StepToF(&this->unk_2A4, 1.0f, 0.05f); - Environment_AdjustLights(globalCtx, SQ(this->unk_2A4), player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f); -} - -// ask to talk to saria again -void func_80A05040(Actor* thisx, GlobalContext* globalCtx) { - EnElf* this = (EnElf*)thisx; - - func_80A04DE4(this, globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - Message_ContinueTextbox(globalCtx, ElfMessage_GetSariaText(globalCtx)); - this->actor.update = func_80A05114; - break; - case 1: // no - Message_CloseTextbox(globalCtx); - this->actor.update = func_80A053F0; - func_80A01C38(this, 0); - this->fairyFlags &= ~0x20; - break; - } - } - - func_80A04F94(this, globalCtx); -} - -void func_80A05114(Actor* thisx, GlobalContext* globalCtx) { - EnElf* this = (EnElf*)thisx; - - func_80A04DE4(this, globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0xE3); - this->actor.update = func_80A05040; - } - - func_80A04F94(this, globalCtx); -} - -void func_80A05188(Actor* thisx, GlobalContext* globalCtx) { - EnElf* this = (EnElf*)thisx; - - func_80A04DE4(this, globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, ElfMessage_GetSariaText(globalCtx)); - this->actor.update = func_80A05114; - } - - func_80A04F94(this, globalCtx); -} - -// ask to talk to navi -void func_80A05208(Actor* thisx, GlobalContext* globalCtx) { - s32 naviCUpText; - EnElf* this = (EnElf*)thisx; - - func_80A04DE4(this, globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - naviCUpText = ElfMessage_GetCUpText(globalCtx); - - if (naviCUpText != 0) { - Message_ContinueTextbox(globalCtx, naviCUpText); - } else { - Message_ContinueTextbox(globalCtx, 0x15F); - } - - this->actor.update = func_80A052F4; - break; - case 1: // no - Message_CloseTextbox(globalCtx); - this->actor.update = func_80A053F0; - func_80A01C38(this, 0); - this->fairyFlags &= ~0x20; - break; - } - } - - func_80A04F94(this, globalCtx); -} - -// ask to talk to saria -void func_80A052F4(Actor* thisx, GlobalContext* globalCtx) { - EnElf* this = (EnElf*)thisx; - - func_80A04DE4(this, globalCtx); - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { - if (Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.unk_E3F2 = 0xFF; - - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - this->actor.update = func_80A05188; - Message_ContinueTextbox(globalCtx, 0xE2); - break; - case 1: // no - this->actor.update = func_80A05208; - Message_ContinueTextbox(globalCtx, 0xE1); - break; - } - } - } else if (Actor_TextboxIsClosing(thisx, globalCtx)) { - this->actor.update = func_80A053F0; - func_80A01C38(this, 0); - this->fairyFlags &= ~0x20; - } - - func_80A04F94(this, globalCtx); -} - -void func_80A053F0(Actor* thisx, GlobalContext* globalCtx) { - u8 unk2C7; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - EnElf* this = (EnElf*)thisx; - - if (player->naviTextId == 0) { - if (player->unk_664 == NULL) { - if (((gSaveContext.naviTimer >= 600) && (gSaveContext.naviTimer <= 3000)) || (nREG(89) != 0)) { - player->naviTextId = ElfMessage_GetCUpText(globalCtx); - - if (player->naviTextId == 0x15F) { - player->naviTextId = 0; - } - } - } - } else if (player->naviTextId < 0) { - // trigger dialog instantly for negative message IDs - thisx->flags |= ACTOR_FLAG_16; - } - - if (Actor_ProcessTalkRequest(thisx, globalCtx)) { - func_800F4524(&D_801333D4, NA_SE_VO_SK_LAUGH, 0x20); - thisx->focus.pos = thisx->world.pos; - - if (thisx->textId == ElfMessage_GetCUpText(globalCtx)) { - this->fairyFlags |= 0x80; - gSaveContext.naviTimer = 3001; - } - - this->fairyFlags |= 0x10; - this->fairyFlags |= 0x20; - thisx->update = func_80A052F4; - func_80A01C38(this, 3); - - if (this->elfMsg != NULL) { - this->elfMsg->actor.flags |= ACTOR_FLAG_8; - } - - thisx->flags &= ~ACTOR_FLAG_16; - } else { - this->actionFunc(this, globalCtx); - thisx->shape.rot.y = this->unk_2BC; - nREG(80) = gSaveContext.sceneFlags[127].chest; - - if (nREG(81) != 0) { - if (gSaveContext.sceneFlags[127].chest) { - LOG_NUM("z_common_data.memory.information.room_inf[127][ 0 ]", gSaveContext.sceneFlags[127].chest, - "../z_en_elf.c", 2595); - } - } - - if (!Gameplay_InCsMode(globalCtx)) { - if (gSaveContext.naviTimer < 25800) { - gSaveContext.naviTimer++; - } else if (!(this->fairyFlags & 0x80)) { - gSaveContext.naviTimer = 0; - } - } - } - - this->elfMsg = NULL; - this->timer++; - - if (this->unk_2A4 > 0.0f) { - Math_StepToF(&this->unk_2A4, 0.0f, 0.05f); - Environment_AdjustLights(globalCtx, SQ(this->unk_2A4) * this->unk_2A4, player->actor.projectedPos.z + 780.0f, - 0.2f, 0.5f); - } - - // temp probably fake match - unk2C7 = this->unk_2C7; - if (unk2C7 > 0) { - this->unk_2C7--; - } - - if ((this->unk_2C7 == 0) && (globalCtx->csCtx.state != CS_STATE_IDLE)) { - this->unk_2C7 = 1; - } - - func_80A04D90(this, globalCtx); -} - -void EnElf_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnElf* this = (EnElf*)thisx; - - this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = this->unk_2BC; - this->timer++; - - if (this->fairyFlags & FAIRY_FLAG_BIG) { - func_80A04D90(this, globalCtx); - } -} - -s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - s32 pad; - f32 scale; - Vec3f mtxMult; - EnElf* this = (EnElf*)thisx; - - if (limbIndex == 8) { - scale = ((Math_SinS(this->timer * 4096) * 0.1f) + 1.0f) * 0.012f; - - if (this->fairyFlags & FAIRY_FLAG_BIG) { - scale *= 2.0f; - } - - scale *= (this->actor.scale.x * 124.99999f); - Matrix_MultVec3f(&zeroVec, &mtxMult); - Matrix_Translate(mtxMult.x, mtxMult.y, mtxMult.z, MTXMODE_NEW); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - } - - // do not draw wings for big fairies - if (this->fairyFlags & FAIRY_FLAG_BIG) { - if (limbIndex == 4 || limbIndex == 7 || limbIndex == 11 || limbIndex == 14) { - *dList = NULL; - } - } - - return false; -} - -void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - f32 alphaScale; - s32 envAlpha; - EnElf* this = (EnElf*)thisx; - s32 pad1; - Gfx* dListHead; - Player* player = GET_PLAYER(globalCtx); - - if ((this->unk_2A8 != 8) && !(this->fairyFlags & 8)) { - if (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z)) { - dListHead = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_elf.c", 2730); - - func_80094B58(globalCtx->state.gfxCtx); - - envAlpha = (this->timer * 50) & 0x1FF; - envAlpha = (envAlpha > 255) ? 511 - envAlpha : envAlpha; - - alphaScale = this->disappearTimer < 0 ? (this->disappearTimer * (7.0f / 6000.0f)) + 1.0f : 1.0f; - - gSPSegment(POLY_XLU_DISP++, 0x08, dListHead); - gDPPipeSync(dListHead++); - gDPSetPrimColor(dListHead++, 0, 0x01, (u8)this->innerColor.r, (u8)this->innerColor.g, - (u8)this->innerColor.b, (u8)(this->innerColor.a * alphaScale)); - - if (this->fairyFlags & 4) { - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_CLD_SURF2); - } else { - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_ZB_CLD_SURF2); - } - - gSPEndDisplayList(dListHead++); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)this->outerColor.r, (u8)this->outerColor.g, (u8)this->outerColor.b, - (u8)(envAlpha * alphaScale)); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnElf_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_elf.c", 2793); - } - } -} - -void EnElf_GetCutsceneNextPos(Vec3f* vec, GlobalContext* globalCtx, s32 action) { - Vec3f startPos; - Vec3f endPos; - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[action]; - f32 lerp; - - startPos.x = npcAction->startPos.x; - startPos.y = npcAction->startPos.y; - startPos.z = npcAction->startPos.z; - - endPos.x = npcAction->endPos.x; - endPos.y = npcAction->endPos.y; - endPos.z = npcAction->endPos.z; - - lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); - - vec->x = ((endPos.x - startPos.x) * lerp) + startPos.x; - vec->y = ((endPos.y - startPos.y) * lerp) + startPos.y; - vec->z = ((endPos.z - startPos.z) * lerp) + startPos.z; -} diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.cpp b/src/overlays/actors/ovl_En_Elf/z_en_elf.cpp new file mode 100644 index 000000000..c18200fe1 --- /dev/null +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.cpp @@ -0,0 +1,1576 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ELF_Z_EN_ELF_C +#include "actor_common.h" +/* + * File: z_en_elf.c + * Overlay: ovl_En_Elf + * Description: Fairy + */ + +#include "z_en_elf.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_elf_message.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25) + +#define FAIRY_FLAG_TIMED (1 << 8) +#define FAIRY_FLAG_BIG (1 << 9) + +void EnElf_Init(Actor* thisx, GlobalContext* globalCtx); +void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnElf_Update(Actor* thisx, GlobalContext* globalCtx); +void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A053F0(Actor* thisx, GlobalContext* globalCtx); +void func_80A052F4(Actor* thisx, GlobalContext* globalCtx); +void func_80A05208(Actor* thisx, GlobalContext* globalCtx); +void func_80A05188(Actor* thisx, GlobalContext* globalCtx); +void func_80A05114(Actor* thisx, GlobalContext* globalCtx); +void func_80A05040(Actor* thisx, GlobalContext* globalCtx); + +// Navi +void func_80A03CF8(EnElf* pthis, GlobalContext* globalCtx); + +// Healing Fairies +void func_80A0329C(EnElf* pthis, GlobalContext* globalCtx); +void func_80A03610(EnElf* pthis, GlobalContext* globalCtx); + +// Healing Fairies Revive From Death +void func_80A03990(EnElf* pthis, GlobalContext* globalCtx); +void func_80A03814(EnElf* pthis, GlobalContext* globalCtx); + +// Kokiri Fairies +void func_80A0353C(EnElf* pthis, GlobalContext* globalCtx); + +// Fairy Spawner +void func_80A03604(EnElf* pthis, GlobalContext* globalCtx); + +// Move(?) functions +void func_80A0214C(EnElf* pthis, GlobalContext* globalCtx); +void func_80A02AA4(EnElf* pthis, GlobalContext* globalCtx); +void func_80A02A20(EnElf* pthis, GlobalContext* globalCtx); +void func_80A02B38(EnElf* pthis, GlobalContext* globalCtx); +void func_80A020A4(EnElf* pthis, GlobalContext* globalCtx); +void func_80A01FE0(EnElf* pthis, GlobalContext* globalCtx); + +// misc +void func_80A04414(EnElf* pthis, GlobalContext* globalCtx); +void func_80A0461C(EnElf* pthis, GlobalContext* globalCtx); +void EnElf_SpawnSparkles(EnElf* pthis, GlobalContext* globalCtx, s32 sparkleLife); +void EnElf_GetCutsceneNextPos(Vec3f* vec, GlobalContext* globalCtx, s32 action); + +ActorInit En_Elf_InitVars = { + ACTOR_EN_ELF, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnElf), + (ActorFunc)EnElf_Init, + (ActorFunc)EnElf_Destroy, + (ActorFunc)EnElf_Update, + (ActorFunc)EnElf_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 8, ICHAIN_STOP), +}; + +static Color_RGBAf sInnerColors[] = { + { 255.0f, 255.0f, 255.0f, 255.0f }, + { 255.0f, 220.0f, 220.0f, 255.0f }, +}; + +static Color_RGBAf sOuterColors[] = { + { 255.0f, 255.0f, 255.0f, 255.0f }, + { 255.0f, 50.0f, 100.0f, 255.0f }, +}; + +typedef struct { + u8 r, g, b; +} FairyColorFlags; + +static FairyColorFlags sColorFlags[] = { + { 0, 0, 0 }, { 1, 0, 0 }, { 1, 2, 0 }, { 1, 0, 2 }, { 0, 1, 0 }, { 2, 1, 0 }, { 0, 1, 2 }, + { 0, 0, 1 }, { 2, 0, 1 }, { 0, 2, 1 }, { 1, 1, 0 }, { 1, 0, 1 }, { 0, 1, 1 }, +}; + +void EnElf_SetupAction(EnElf* pthis, EnElfActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void func_80A01C38(EnElf* pthis, s32 arg1) { + pthis->unk_2A8 = arg1; + + switch (pthis->unk_2A8) { + case 0: + pthis->unk_2AE = 0x400; + pthis->unk_2B0 = 0x200; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2C0 = 100; + pthis->unk_2B4 = 5.0f; + pthis->unk_2B8 = 20.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 12: + pthis->unk_2AE = 0x400; + pthis->unk_2B0 = 0x200; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2C0 = 100; + pthis->unk_2B4 = 1.0f; + pthis->unk_2B8 = 5.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 10: + pthis->unk_2AE = 0x400; + pthis->unk_2B0 = 0; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2B8 = 0.0f; + pthis->unk_2B4 = 5.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 9: + pthis->unk_2AE = 0x1000; + pthis->unk_2B0 = 0x200; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2B4 = 3.0f; + pthis->unk_2B8 = 10.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 7: + pthis->func_2C8 = func_80A02A20; + pthis->unk_2AE = 0x1E; + pthis->unk_2C0 = 1; + pthis->unk_2B4 = 0.0f; + pthis->unk_2B8 = 0.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 8: + pthis->unk_2AE = 0x1000; + pthis->unk_2B0 = 0x200; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2B4 = 0.0f; + pthis->unk_2B8 = 0.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 1: + pthis->unk_2AE = 0x1000; + pthis->unk_2B0 = 0x800; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2B4 = 5.0f; + pthis->unk_2B8 = 7.5f; + pthis->skelAnime.playSpeed = 2.0f; + break; + case 2: + pthis->unk_2AE = 0x400; + pthis->unk_2B0 = 0x1000; + pthis->func_2C8 = func_80A02AA4; + pthis->unk_2B4 = 10.0f; + pthis->unk_2B8 = 20.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 3: + pthis->unk_2B0 = 0x600; + pthis->func_2C8 = func_80A02B38; + pthis->unk_2B8 = 1.0f; + pthis->unk_2B4 = 1.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + case 4: + pthis->unk_2B0 = 0x800; + pthis->func_2C8 = func_80A02B38; + pthis->unk_2B4 = 20.0f; + pthis->unk_2B8 = 10.0; + pthis->skelAnime.playSpeed = 2.0f; + break; + case 5: + pthis->unk_2B0 = 0x200; + pthis->func_2C8 = func_80A02B38; + pthis->unk_2B4 = 10.0f; + pthis->unk_2B8 = 10.0f; + pthis->skelAnime.playSpeed = 0.5f; + break; + case 6: + pthis->unk_2AE = 0x1000; + pthis->unk_2B0 = 0x800; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2B4 = 60.0f; + pthis->unk_2B8 = 20.0f; + pthis->skelAnime.playSpeed = 2.0f; + break; + case 11: + pthis->unk_2AE = 0x400; + pthis->unk_2B0 = 0x2000; + pthis->func_2C8 = func_80A02A20; + pthis->unk_2C0 = 42; + pthis->unk_2B4 = 5.0f; + pthis->unk_2B8 = 1.0f; + pthis->skelAnime.playSpeed = 1.0f; + break; + } +} + +s32 func_80A01F90(Vec3f* pthis, Vec3f* arg1, f32 arg2) { + return SQ(arg2) < (SQ(arg1->x - pthis->x) + SQ(arg1->z - pthis->z)); +} + +void func_80A01FE0(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!func_80A01F90(&pthis->actor.world.pos, &player->actor.world.pos, 30.0f)) { + pthis->unk_2B8 = 0.5f; + } else { + pthis->unk_2B8 = 2.0f; + } + + if (pthis->unk_2C0 > 0) { + pthis->unk_2C0--; + } else { + pthis->unk_2A8 = 1; + pthis->unk_2AC = 0x80; + pthis->unk_2B8 = Rand_ZeroFloat(1.0f) + 0.5f; + pthis->unk_2B0 = Rand_CenteredFloat(32767.0f); + pthis->func_2C8 = func_80A0214C; + } +} + +void func_80A020A4(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80A01F90(&pthis->actor.world.pos, &player->actor.world.pos, 50.0f)) { + if (pthis->unk_2C0 > 0) { + pthis->unk_2C0--; + } else { + pthis->unk_2A8 = 1; + pthis->unk_2AC = 0x80; + pthis->unk_2B8 = Rand_ZeroFloat(1.0f) + 0.5f; + pthis->unk_2B0 = Rand_CenteredFloat(32767.0f); + pthis->func_2C8 = func_80A0214C; + } + } +} + +void func_80A0214C(EnElf* pthis, GlobalContext* globalCtx) { + f32 xzDistToPlayer; + + if (pthis->unk_2C0 > 0) { + pthis->unk_2C0--; + } else { + xzDistToPlayer = pthis->actor.xzDistToPlayer; + if (xzDistToPlayer < 50.0f) { + if (Rand_ZeroOne() < 0.2f) { + pthis->unk_2A8 = 2; + pthis->unk_2AC = 0x400; + pthis->unk_2B8 = 2.0f; + pthis->func_2C8 = func_80A020A4; + pthis->actor.speedXZ = 1.5f; + pthis->unk_2C0 = (s16)Rand_ZeroFloat(8.0f) + 4; + } else { + pthis->unk_2C0 = 10; + } + } else { + if (xzDistToPlayer > 150.0f) { + xzDistToPlayer = 150.0f; + } + + xzDistToPlayer = ((xzDistToPlayer - 50.0f) * 0.95f) + 0.05f; + + if (Rand_ZeroOne() < xzDistToPlayer) { + pthis->unk_2A8 = 3; + pthis->unk_2AC = 0x200; + pthis->unk_2B8 = (xzDistToPlayer * 2.0f) + 1.0f; + pthis->func_2C8 = func_80A01FE0; + pthis->unk_2C0 = (s16)Rand_ZeroFloat(16.0f) + 0x10; + } else { + pthis->unk_2C0 = 10; + } + } + } + + if (Rand_ZeroOne() < 0.1f) { + pthis->unk_2A8 = 1; + pthis->unk_2AC = 0x80; + pthis->unk_2B8 = Rand_ZeroFloat(0.5f) + 0.5f; + pthis->unk_2B0 = Rand_CenteredFloat(32767.0f); + } +} + +void func_80A0232C(EnElf* pthis, GlobalContext* globalCtx) { + if (func_80A01F90(&pthis->unk_28C, &pthis->actor.world.pos, 100.0f)) { + pthis->unk_2A8 = 0; + pthis->unk_2AC = 0x200; + pthis->func_2C8 = func_80A0214C; + pthis->unk_2B8 = 1.5f; + } else { + pthis->func_2C8(pthis, globalCtx); + } +} + +f32 EnElf_GetColorValue(s32 colorFlag) { + switch (colorFlag) { + case 1: + return Rand_ZeroFloat(55.0f) + 200.0f; + case 2: + return Rand_ZeroFloat(255.0f); + default: + return 0.0f; + } +} + +void EnElf_Init(Actor* thisx, GlobalContext* globalCtx) { + EnElf* pthis = (EnElf*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 colorConfig; + s32 i; + + Actor_ProcessInitChain(thisx, sInitChain); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gFairySkel, &gFairyAnim, pthis->jointTable, pthis->morphTable, 15); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 15.0f); + thisx->shape.shadowAlpha = 0xFF; + + Lights_PointGlowSetInfo(&pthis->lightInfoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, 255, + 255, 0); + pthis->lightNodeGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfoGlow); + + Lights_PointNoGlowSetInfo(&pthis->lightInfoNoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, + 255, 255, 0); + pthis->lightNodeNoGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfoNoGlow); + + pthis->fairyFlags = 0; + pthis->disappearTimer = 600; + pthis->unk_2A4 = 0.0f; + colorConfig = 0; + + switch (thisx->params) { + case FAIRY_NAVI: + thisx->room = -1; + EnElf_SetupAction(pthis, func_80A03CF8); + func_80A01C38(pthis, 0); + pthis->fairyFlags |= 4; + thisx->update = func_80A053F0; + pthis->elfMsg = NULL; + pthis->unk_2C7 = 0x14; + + if ((gSaveContext.naviTimer >= 25800) || (gSaveContext.naviTimer < 3000)) { + gSaveContext.naviTimer = 0; + } + break; + case FAIRY_REVIVE_BOTTLE: + colorConfig = -1; + EnElf_SetupAction(pthis, func_80A03610); + pthis->unk_2B8 = Math_Vec3f_DistXZ(&thisx->world.pos, &player->actor.world.pos); + pthis->unk_2AC = player->actor.shape.rot.y; + pthis->unk_2B0 = -0x1000; + pthis->unk_28C.y = thisx->world.pos.y - player->actor.world.pos.y; + pthis->unk_2AA = 0; + pthis->unk_2B4 = 0.0f; + break; + case FAIRY_REVIVE_DEATH: + colorConfig = -1; + EnElf_SetupAction(pthis, func_80A03990); + pthis->unk_2B8 = 0.0f; + pthis->unk_2AC = player->actor.shape.rot.y; + pthis->unk_2B0 = 0; + pthis->unk_28C.y = thisx->world.pos.y - player->actor.world.pos.y; + pthis->unk_2AA = 0; + pthis->unk_2B4 = 7.0f; + break; + case FAIRY_HEAL_BIG: + pthis->fairyFlags |= FAIRY_FLAG_BIG; + thisx->shape.shadowDraw = ActorShadow_DrawWhiteCircle; + case FAIRY_HEAL_TIMED: + pthis->fairyFlags |= FAIRY_FLAG_TIMED; + case FAIRY_HEAL: + colorConfig = -1; + EnElf_SetupAction(pthis, func_80A0329C); + pthis->unk_2B4 = Rand_ZeroFloat(10.0f) + 10.0f; + pthis->unk_2AA = 0; + pthis->unk_2AE = (s16)(Rand_ZeroFloat(1048.0f)) + 0x200; + pthis->unk_28C = thisx->world.pos; + pthis->unk_2BC = Rand_CenteredFloat(32767.0f); + pthis->func_2C8 = func_80A0214C; + func_80A0232C(pthis, globalCtx); + pthis->unk_2C0 = 0; + pthis->disappearTimer = 240; + break; + case FAIRY_KOKIRI: + colorConfig = Rand_ZeroFloat(11.99f) + 1.0f; + EnElf_SetupAction(pthis, func_80A0353C); + func_80A01C38(pthis, 0); + break; + case FAIRY_SPAWNER: + EnElf_SetupAction(pthis, func_80A03604); + func_80A01C38(pthis, 8); + + for (i = 0; i < 8; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, thisx->world.pos.x, + thisx->world.pos.y - 30.0f, thisx->world.pos.z, 0, 0, 0, FAIRY_HEAL); + } + break; + default: + ASSERT(0, "0", "../z_en_elf.c", 1103); + break; + } + + pthis->unk_2A0 = 3.0f; + pthis->innerColor = sInnerColors[0]; + + if (colorConfig > 0) { + pthis->outerColor.r = EnElf_GetColorValue(sColorFlags[colorConfig].r); + pthis->outerColor.g = EnElf_GetColorValue(sColorFlags[colorConfig].g); + pthis->outerColor.b = EnElf_GetColorValue(sColorFlags[colorConfig].b); + pthis->outerColor.a = 0.0f; + } else { + pthis->innerColor = sInnerColors[-colorConfig]; + pthis->outerColor = sOuterColors[-colorConfig]; + } +} + +void func_80A0299C(EnElf* pthis, s32 arg1) { +} + +void func_80A029A8(EnElf* pthis, s16 increment) { + if (pthis->disappearTimer < 600) { + pthis->disappearTimer += increment; + } +} + +void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElf* pthis = (EnElf*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNodeGlow); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNodeNoGlow); +} + +void func_80A02A20(EnElf* pthis, GlobalContext* globalCtx) { + pthis->unk_28C.x = Math_SinS(pthis->unk_2AC) * pthis->unk_2B8; + pthis->unk_28C.y = Math_SinS(pthis->unk_2AA) * pthis->unk_2B4; + pthis->unk_28C.z = Math_CosS(pthis->unk_2AC) * pthis->unk_2B8; + pthis->unk_2AC += pthis->unk_2B0; + pthis->unk_2AA += pthis->unk_2AE; +} + +void func_80A02AA4(EnElf* pthis, GlobalContext* globalCtx) { + f32 xzScale; + + xzScale = (Math_CosS(pthis->unk_2AA) * pthis->unk_2B4) + pthis->unk_2B8; + + pthis->unk_28C.x = Math_SinS(pthis->unk_2AC) * xzScale; + pthis->unk_28C.y = 0.0f; + pthis->unk_28C.z = Math_CosS(pthis->unk_2AC) * xzScale; + + pthis->unk_2AC += pthis->unk_2B0; + pthis->unk_2AA += pthis->unk_2AE; +} + +void func_80A02B38(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_2AA = (pthis->unk_2AC * 2) & 0xFFFF; + pthis->unk_28C.x = Math_SinS(pthis->unk_2AC) * pthis->unk_2B8; + pthis->unk_28C.y = Math_SinS(pthis->unk_2AA) * pthis->unk_2B4; + pthis->unk_28C.z = -Math_SinS(player->actor.shape.rot.y) * pthis->unk_28C.x; + pthis->unk_28C.x = Math_CosS(player->actor.shape.rot.y) * pthis->unk_28C.x; + pthis->unk_2AC += pthis->unk_2B0; +} + +void func_80A02BD8(EnElf* pthis, Vec3f* targetPos, f32 arg2) { + f32 yVelTarget; + f32 yVelDirection; + + yVelTarget = ((targetPos->y + pthis->unk_28C.y) - pthis->actor.world.pos.y) * arg2; + yVelDirection = (yVelTarget >= 0.0f) ? 1.0f : -1.0f; + yVelTarget = fabsf(yVelTarget); + yVelTarget = CLAMP(yVelTarget, 0.0f, 20.0f) * yVelDirection; + Math_StepToF(&pthis->actor.velocity.y, yVelTarget, 32.0f); +} + +void func_80A02C98(EnElf* pthis, Vec3f* targetPos, f32 arg2) { + f32 xVelTarget; + f32 zVelTarget; + f32 xVelDirection; + f32 zVelDirection; + + xVelTarget = ((targetPos->x + pthis->unk_28C.x) - pthis->actor.world.pos.x) * arg2; + zVelTarget = ((targetPos->z + pthis->unk_28C.z) - pthis->actor.world.pos.z) * arg2; + + xVelDirection = (xVelTarget >= 0.0f) ? 1.0f : -1.0f; + zVelDirection = (zVelTarget >= 0.0f) ? 1.0f : -1.0f; + + xVelTarget = fabsf(xVelTarget); + zVelTarget = fabsf(zVelTarget); + + xVelTarget = CLAMP(xVelTarget, 0.0f, 20.0f) * xVelDirection; + zVelTarget = CLAMP(zVelTarget, 0.0f, 20.0f) * zVelDirection; + + func_80A02BD8(pthis, targetPos, arg2); + Math_StepToF(&pthis->actor.velocity.x, xVelTarget, 1.5f); + Math_StepToF(&pthis->actor.velocity.z, zVelTarget, 1.5f); + func_8002D7EC(&pthis->actor); +} + +void func_80A02E30(EnElf* pthis, Vec3f* targetPos) { + func_80A02BD8(pthis, targetPos, 0.2f); + pthis->actor.velocity.x = (targetPos->x + pthis->unk_28C.x) - pthis->actor.world.pos.x; + pthis->actor.velocity.z = (targetPos->z + pthis->unk_28C.z) - pthis->actor.world.pos.z; + func_8002D7EC(&pthis->actor); + pthis->actor.world.pos.x = targetPos->x + pthis->unk_28C.x; + pthis->actor.world.pos.z = targetPos->z + pthis->unk_28C.z; +} + +void func_80A02EC0(EnElf* pthis, Vec3f* targetPos) { + func_80A02BD8(pthis, targetPos, 0.2f); + pthis->actor.velocity.x = pthis->actor.velocity.z = 0.0f; + func_8002D7EC(&pthis->actor); + pthis->actor.world.pos.x = targetPos->x + pthis->unk_28C.x; + pthis->actor.world.pos.z = targetPos->z + pthis->unk_28C.z; +} + +void func_80A02F2C(EnElf* pthis, Vec3f* targetPos) { + f32 yVelTarget; + f32 yVelDirection; + + yVelTarget = (((Math_SinS(pthis->unk_2AA) * pthis->unk_2B4) + targetPos->y) - pthis->actor.world.pos.y) * 0.2f; + yVelDirection = (yVelTarget >= 0.0f) ? 1.0f : -1.0f; + pthis->unk_2AA += pthis->unk_2AE; + yVelTarget = fabsf(yVelTarget); + yVelTarget = CLAMP(yVelTarget, 0.0f, 20.0f) * yVelDirection; + Math_StepToF(&pthis->actor.velocity.y, yVelTarget, 1.5f); +} + +void func_80A03018(EnElf* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + s16 targetYaw; + Vec3f* unk_28C = &pthis->unk_28C; + + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->unk_2B8, 0.2f, 0.5f, 0.01f); + + switch (pthis->unk_2A8) { + case 0: + targetYaw = Math_Atan2S(-(pthis->actor.world.pos.z - unk_28C->z), -(pthis->actor.world.pos.x - unk_28C->x)); + break; + + case 3: + targetYaw = Math_Atan2S(-(pthis->actor.world.pos.z - player->actor.world.pos.z), + -(pthis->actor.world.pos.x - player->actor.world.pos.x)); + break; + + case 2: + targetYaw = Math_Atan2S(pthis->actor.world.pos.z - player->actor.world.pos.z, + pthis->actor.world.pos.x - player->actor.world.pos.x); + break; + + default: + targetYaw = pthis->unk_2B0; + break; + } + + Math_SmoothStepToS(&pthis->unk_2BC, targetYaw, 10, pthis->unk_2AC, 0x20); + pthis->actor.world.rot.y = pthis->unk_2BC; + Actor_MoveForward(&pthis->actor); +} + +void func_80A03148(EnElf* pthis, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { + f32 xVelTarget; + f32 zVelTarget; + f32 xzVelocity; + f32 clampedXZ; + + xVelTarget = ((arg1->x + pthis->unk_28C.x) - pthis->actor.world.pos.x) * arg4; + zVelTarget = ((arg1->z + pthis->unk_28C.z) - pthis->actor.world.pos.z) * arg4; + arg4 += 0.3f; + arg3 += 30.0f; + + func_80A02BD8(pthis, arg1, arg4); + + xzVelocity = sqrtf(SQ(xVelTarget) + SQ(zVelTarget)); + + pthis->actor.speedXZ = clampedXZ = CLAMP(xzVelocity, arg2, arg3); + + if ((xzVelocity != clampedXZ) && (xzVelocity != 0.0f)) { + xzVelocity = clampedXZ / xzVelocity; + xVelTarget *= xzVelocity; + zVelTarget *= xzVelocity; + } + + Math_StepToF(&pthis->actor.velocity.x, xVelTarget, 5.0f); + Math_StepToF(&pthis->actor.velocity.z, zVelTarget, 5.0f); + func_8002D7EC(&pthis->actor); +} + +void func_80A0329C(EnElf* pthis, GlobalContext* globalCtx) { + Player* refActor = GET_PLAYER(globalCtx); + s32 pad; + Player* player = GET_PLAYER(globalCtx); + f32 heightDiff; + + SkelAnime_Update(&pthis->skelAnime); + + if (Rand_ZeroOne() < 0.05f) { + pthis->unk_2B4 = Rand_ZeroFloat(10.0f) + 10.0f; + pthis->unk_2AE = (s16)(Rand_ZeroFloat(1024.0f)) + 0x200; + } + + func_80A0232C(pthis, globalCtx); + pthis->unk_28C.y = player->bodyPartsPos[0].y; + func_80A02F2C(pthis, &pthis->unk_28C); + func_80A03018(pthis, globalCtx); + + if ((pthis->unk_2A8 == 2) || (pthis->unk_2A8 == 3)) { + EnElf_SpawnSparkles(pthis, globalCtx, 16); + } + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + + if (!Player_InCsMode(globalCtx)) { + heightDiff = pthis->actor.world.pos.y - refActor->actor.world.pos.y; + + if ((heightDiff > 0.0f) && (heightDiff < 60.0f)) { + if (!func_80A01F90(&pthis->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { + Health_ChangeBy(globalCtx, 128); + if (pthis->fairyFlags & FAIRY_FLAG_BIG) { + Magic_Fill(globalCtx); + } + pthis->unk_2B8 = 50.0f; + pthis->unk_2AC = refActor->actor.shape.rot.y; + pthis->unk_2B0 = -0x1000; + pthis->unk_28C.y = 30.0f; + pthis->unk_2B4 = 0.0f; + pthis->unk_2AA = 0; + EnElf_SetupAction(pthis, func_80A03610); + return; + } + } + + if (pthis->fairyFlags & FAIRY_FLAG_TIMED) { + if (pthis->disappearTimer > 0) { + pthis->disappearTimer--; + } else { + pthis->disappearTimer--; + + if (pthis->disappearTimer > -10) { + Actor_SetScale(&pthis->actor, ((pthis->disappearTimer + 10) * 0.008f) * 0.1f); + } else { + Actor_Kill(&pthis->actor); + return; + } + } + } + + if (!(pthis->fairyFlags & FAIRY_FLAG_BIG)) { + // GI_MAX in pthis case allows the player to catch the actor in a bottle + func_8002F434(&pthis->actor, globalCtx, GI_MAX, 80.0f, 60.0f); + } + } +} + +void func_80A0353C(EnElf* pthis, GlobalContext* globalCtx) { + Vec3f parentPos; + Actor* parent; + + SkelAnime_Update(&pthis->skelAnime); + func_80A02A20(pthis, globalCtx); + parent = pthis->actor.parent; + + if ((parent != NULL) && (parent->update != NULL)) { + parentPos = pthis->actor.parent->world.pos; + parentPos.y += ((1500.0f * pthis->actor.scale.y) + 40.0f); + func_80A02C98(pthis, &parentPos, 0.2f); + } else { + Actor_Kill(&pthis->actor); + } + + pthis->unk_2BC = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); +} + +void func_80A03604(EnElf* pthis, GlobalContext* globalCtx) { +} + +void func_80A03610(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToF(&pthis->unk_2B8, 30.0f, 0.1f, 4.0f, 1.0f); + + pthis->unk_28C.x = Math_CosS(pthis->unk_2AC) * pthis->unk_2B8; + pthis->unk_28C.y = pthis->unk_28C.y + pthis->unk_2B4; + + switch (pthis->unk_2AA) { + case 0: + if (pthis->unk_2B4 < 2.0f) { + pthis->unk_2B4 += 0.1f; + } else { + pthis->unk_2AA++; + } + break; + case 1: + if (pthis->unk_2B4 > -1.0f) { + pthis->unk_2B4 -= 0.2f; + } + } + + pthis->unk_28C.z = Math_SinS(pthis->unk_2AC) * -pthis->unk_2B8; + pthis->unk_2AC += pthis->unk_2B0; + func_80A02C98(pthis, &player->actor.world.pos, 0.2f); + + if (pthis->unk_2B4 < 0.0f) { + if ((pthis->unk_28C.y < 20.0f) && (pthis->unk_28C.y > 0.0f)) { + Actor_SetScale(&pthis->actor, (pthis->unk_28C.y * 0.008f) * 0.05f); + } + } + + if (pthis->unk_28C.y < -10.0f) { + Actor_Kill(&pthis->actor); + return; + } + + pthis->unk_2BC = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + EnElf_SpawnSparkles(pthis, globalCtx, 32); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); +} + +void func_80A03814(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_28C.y > 200.0f) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->unk_2AE >= 0x7E) { + pthis->unk_2B8 += 0.1f; + pthis->unk_2B4 += 0.5f; + pthis->unk_28C.y += pthis->unk_2B4; + } else { + pthis->unk_2AE++; + + if (pthis->unk_2B8 < 30.0f) { + pthis->unk_2B8 += 0.5f; + } + + if (pthis->unk_28C.y > 0.0f) { + pthis->unk_28C.y -= 0.7f; + } + } + + pthis->unk_28C.x = Math_CosS(pthis->unk_2AC) * pthis->unk_2B8; + pthis->unk_28C.z = Math_SinS(pthis->unk_2AC) * -pthis->unk_2B8; + pthis->unk_2AC += pthis->unk_2B0; + func_80A02E30(pthis, &player->bodyPartsPos[0]); + pthis->unk_2BC = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + EnElf_SpawnSparkles(pthis, globalCtx, 32); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); +} + +void func_80A03990(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + + pthis->unk_28C.z = 0.0f; + pthis->unk_28C.x = 0.0f; + pthis->unk_28C.y += pthis->unk_2B4; + pthis->unk_2B4 -= 0.35f; + + if (pthis->unk_2B4 <= 0.0f) { + EnElf_SetupAction(pthis, func_80A03814); + pthis->unk_2B0 = 0x800; + pthis->unk_2AE = 0; + pthis->unk_2B4 = 0.0f; + pthis->unk_2B8 = 1.0f; + } + + func_80A02E30(pthis, &player->bodyPartsPos[0]); + Actor_SetScale(&pthis->actor, (1.0f - (SQ(pthis->unk_2B4) * SQ(1.0f / 9.0f))) * 0.008f); + pthis->unk_2BC = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + EnElf_SpawnSparkles(pthis, globalCtx, 32); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); +} + +void func_80A03AB0(EnElf* pthis, GlobalContext* globalCtx) { + if (pthis->fairyFlags & 4) { + func_80A04414(pthis, globalCtx); + } + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->func_2C8 == NULL) { + ASSERT(0, "0", "../z_en_elf.c", 1725); + } + + pthis->func_2C8(pthis, globalCtx); +} + +void EnElf_UpdateLights(EnElf* pthis, GlobalContext* globalCtx) { + s16 glowLightRadius; + Player* player; + + glowLightRadius = 100; + + if (pthis->unk_2A8 == 8) { + glowLightRadius = 0; + } + + if (pthis->fairyFlags & 0x20) { + player = GET_PLAYER(globalCtx); + Lights_PointNoGlowSetInfo(&pthis->lightInfoNoGlow, player->actor.world.pos.x, + (s16)(player->actor.world.pos.y) + 60.0f, player->actor.world.pos.z, 255, 255, 255, + 200); + } else { + Lights_PointNoGlowSetInfo(&pthis->lightInfoNoGlow, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, -1); + } + + Lights_PointGlowSetInfo(&pthis->lightInfoGlow, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, glowLightRadius); + + pthis->unk_2BC = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); +} + +void func_80A03CF8(EnElf* pthis, GlobalContext* globalCtx) { + Vec3f nextPos; + Vec3f prevPos; + Player* player = GET_PLAYER(globalCtx); + Actor* arrowPointedActor; + f32 xScale; + f32 distFromLinksHead; + + func_80A0461C(pthis, globalCtx); + func_80A03AB0(pthis, globalCtx); + + xScale = 0.0f; + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[8] != NULL)) { + EnElf_GetCutsceneNextPos(&nextPos, globalCtx, 8); + + if (globalCtx->csCtx.npcActions[8]->action == 5) { + if (1) {} + EnElf_SpawnSparkles(pthis, globalCtx, 16); + } + + prevPos = pthis->actor.world.pos; + + if (pthis->unk_2A8 == 0xA) { + func_80A02EC0(pthis, &nextPos); + } else { + func_80A02C98(pthis, &nextPos, 0.2f); + } + + if ((globalCtx->sceneNum == SCENE_LINK_HOME) && (gSaveContext.sceneSetupIndex == 4)) { + // play dash sound as Navi enters Links house in the intro + if (1) {} + if (globalCtx->csCtx.frames == 55) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FAIRY_DASH); + } + + // play dash sound in intervals as Navi is waking up Link in the intro + if (pthis->unk_2A8 == 6) { + if (pthis->fairyFlags & 0x40) { + if (prevPos.y < pthis->actor.world.pos.y) { + pthis->fairyFlags &= ~0x40; + } + } else { + if (pthis->actor.world.pos.y < prevPos.y) { + pthis->fairyFlags |= 0x40; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FAIRY_DASH); + } + } + } + } + } else { + distFromLinksHead = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &pthis->actor.world.pos); + + switch (pthis->unk_2A8) { + case 7: + func_80A02C98(pthis, &player->bodyPartsPos[8], 1.0f - pthis->unk_2AE * (1.0f / 30.0f)); + xScale = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &pthis->actor.world.pos); + + if (distFromLinksHead < 7.0f) { + pthis->unk_2C0 = 0; + xScale = 0.0f; + } else if (distFromLinksHead < 25.0f) { + xScale = (xScale - 5.0f) * 0.05f; + xScale = 1.0f - xScale; + xScale = (1.0f - SQ(xScale)) * 0.008f; + } else { + xScale = 0.008f; + } + EnElf_SpawnSparkles(pthis, globalCtx, 16); + break; + case 8: + func_80A02C98(pthis, &player->bodyPartsPos[8], 0.2f); + pthis->actor.world.pos = player->bodyPartsPos[8]; + func_80A029A8(pthis, 1); + break; + case 11: + nextPos = player->bodyPartsPos[8]; + nextPos.y += 1500.0f * pthis->actor.scale.y; + func_80A02E30(pthis, &nextPos); + EnElf_SpawnSparkles(pthis, globalCtx, 16); + + if (pthis->unk_2B8 <= 19.0f) { + pthis->unk_2B8 += 1.0f; + } + + if (pthis->unk_2B8 >= 21.0f) { + pthis->unk_2B8 -= 1.0f; + } + + if (pthis->unk_2C0 < 0x20) { + pthis->unk_2B0 = (pthis->unk_2C0 * 0xF0) + 0x200; + func_80A0299C(pthis, 1); + } + break; + case 12: + nextPos = GET_ACTIVE_CAM(globalCtx)->eye; + nextPos.y += (-2000.0f * pthis->actor.scale.y); + func_80A03148(pthis, &nextPos, 0.0f, 20.0f, 0.2f); + break; + default: + func_80A029A8(pthis, 1); + nextPos = globalCtx->actorCtx.targetCtx.naviRefPos; + nextPos.y += (1500.0f * pthis->actor.scale.y); + arrowPointedActor = globalCtx->actorCtx.targetCtx.arrowPointedActor; + + if (arrowPointedActor != NULL) { + func_80A03148(pthis, &nextPos, 0.0f, 20.0f, 0.2f); + + if (pthis->actor.speedXZ >= 5.0f) { + EnElf_SpawnSparkles(pthis, globalCtx, 16); + } + } else { + if ((pthis->timer % 32) == 0) { + pthis->unk_2A0 = Rand_ZeroFloat(7.0f) + 3.0f; + } + + if (pthis->fairyFlags & 2) { + if (distFromLinksHead < 30.0f) { + pthis->fairyFlags ^= 2; + } + + func_80A03148(pthis, &nextPos, 0.0f, 20.0f, 0.2f); + EnElf_SpawnSparkles(pthis, globalCtx, 16); + } else { + if (distFromLinksHead > 100.0f) { + pthis->fairyFlags |= 2; + + if (pthis->unk_2C7 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FAIRY_DASH); + } + + pthis->unk_2C0 = 0x64; + } + func_80A03148(pthis, &nextPos, 0.0f, pthis->unk_2A0, 0.2f); + } + } + break; + } + } + + if (pthis->unk_2A8 == 7) { + pthis->actor.scale.x = xScale; + } else if (pthis->unk_2A8 == 8) { + pthis->actor.scale.x = 0.0f; + } else { + Math_SmoothStepToF(&pthis->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); + } + + EnElf_UpdateLights(pthis, globalCtx); +} + +void EnElf_ChangeColor(Color_RGBAf* dest, Color_RGBAf* newColor, Color_RGBAf* curColor, f32 rate) { + Color_RGBAf rgbaDiff; + + rgbaDiff.r = (newColor->r - curColor->r); + rgbaDiff.g = (newColor->g - curColor->g); + rgbaDiff.b = (newColor->b - curColor->b); + rgbaDiff.a = (newColor->a - curColor->a); + + dest->r += (rgbaDiff.r * rate); + dest->g += (rgbaDiff.g * rate); + dest->b += (rgbaDiff.b * rate); + dest->a += (rgbaDiff.a * rate); +} + +void func_80A04414(EnElf* pthis, GlobalContext* globalCtx) { + Actor* arrowPointedActor = globalCtx->actorCtx.targetCtx.arrowPointedActor; + Player* player = GET_PLAYER(globalCtx); + f32 transitionRate; + u16 targetSound; + + if (globalCtx->actorCtx.targetCtx.unk_40 != 0.0f) { + pthis->unk_2C6 = 0; + pthis->unk_29C = 1.0f; + + if (pthis->unk_2C7 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FAIRY_DASH); + } + + } else { + if (pthis->unk_2C6 == 0) { + if ((arrowPointedActor == NULL) || + (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &globalCtx->actorCtx.targetCtx.naviRefPos) < 50.0f)) { + pthis->unk_2C6 = 1; + } + } else if (pthis->unk_29C != 0.0f) { + if (Math_StepToF(&pthis->unk_29C, 0.0f, 0.25f) != 0) { + pthis->innerColor = globalCtx->actorCtx.targetCtx.naviInner; + pthis->outerColor = globalCtx->actorCtx.targetCtx.naviOuter; + } else { + transitionRate = 0.25f / pthis->unk_29C; + EnElf_ChangeColor(&pthis->innerColor, &globalCtx->actorCtx.targetCtx.naviInner, &pthis->innerColor, + transitionRate); + EnElf_ChangeColor(&pthis->outerColor, &globalCtx->actorCtx.targetCtx.naviOuter, &pthis->outerColor, + transitionRate); + } + } + } + + if (pthis->fairyFlags & 1) { + if ((arrowPointedActor == NULL) || (player->unk_664 == NULL)) { + pthis->fairyFlags ^= 1; + } + } else { + if ((arrowPointedActor != NULL) && (player->unk_664 != NULL)) { + if (arrowPointedActor->category == ACTORCAT_NPC) { + targetSound = NA_SE_VO_NAVY_HELLO; + } else { + targetSound = + (arrowPointedActor->category == ACTORCAT_ENEMY) ? NA_SE_VO_NAVY_ENEMY : NA_SE_VO_NAVY_HEAR; + } + + if (pthis->unk_2C7 == 0) { + Audio_PlayActorSound2(&pthis->actor, targetSound); + } + + pthis->fairyFlags |= 1; + } + } +} + +void func_80A0461C(EnElf* pthis, GlobalContext* globalCtx) { + s32 temp; + Actor* arrowPointedActor; + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if (globalCtx->csCtx.npcActions[8] != NULL) { + switch (globalCtx->csCtx.npcActions[8]->action) { + case 4: + temp = 9; + break; + case 3: + temp = 6; + break; + case 1: + temp = 10; + break; + default: + temp = 0; + break; + } + } else { + temp = 0; + pthis->unk_2C0 = 100; + } + + } else { + arrowPointedActor = globalCtx->actorCtx.targetCtx.arrowPointedActor; + + if ((player->stateFlags1 & 0x400) || ((YREG(15) & 0x10) && func_800BC56C(globalCtx, 2))) { + temp = 12; + pthis->unk_2C0 = 100; + } else if (arrowPointedActor == NULL || arrowPointedActor->category == ACTORCAT_NPC) { + if (arrowPointedActor != NULL) { + pthis->unk_2C0 = 100; + player->stateFlags2 |= 0x100000; + temp = 0; + } else { + switch (pthis->unk_2A8) { + case 0: + if (pthis->unk_2C0 != 0) { + pthis->unk_2C0--; + temp = 0; + } else { + if (pthis->unk_2C7 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_NAVY_VANISH); + } + temp = 7; + } + break; + case 7: + if (pthis->unk_2C0 != 0) { + if (pthis->unk_2AE > 0) { + pthis->unk_2AE--; + temp = 7; + } else { + player->stateFlags2 |= 0x100000; + temp = 0; + } + } else { + temp = 8; + func_80A029A8(pthis, 10); + } + break; + case 8: + temp = 8; + break; + case 11: + temp = pthis->unk_2A8; + if (pthis->unk_2C0 > 0) { + pthis->unk_2C0--; + } else { + temp = 0; + } + break; + default: + temp = 0; + break; + } + } + } else { + temp = 1; + } + + switch (temp) { + case 0: + if (!(player->stateFlags2 & 0x100000)) { + temp = 7; + if (pthis->unk_2C7 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_NAVY_VANISH); + } + } + break; + case 8: + if (player->stateFlags2 & 0x100000) { + func_80A0299C(pthis, 0x32); + pthis->unk_2C0 = 42; + temp = 11; + if (pthis->unk_2C7 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FAIRY_DASH); + } + } + break; + case 7: + player->stateFlags2 &= ~0x100000; + break; + default: + player->stateFlags2 |= 0x100000; + break; + } + } + + if (temp != pthis->unk_2A8) { + func_80A01C38(pthis, temp); + + if (temp == 11) { + pthis->unk_2B8 = Math_Vec3f_DistXZ(&player->bodyPartsPos[8], &pthis->actor.world.pos); + pthis->unk_2AC = Math_Vec3f_Yaw(&pthis->actor.world.pos, &player->bodyPartsPos[8]); + } + } +} + +void EnElf_SpawnSparkles(EnElf* pthis, GlobalContext* globalCtx, s32 sparkleLife) { + static Vec3f sparkleVelocity = { 0.0f, -0.05f, 0.0f }; + static Vec3f sparkleAccel = { 0.0f, -0.025f, 0.0f }; + s32 pad; + Vec3f sparklePos; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + sparklePos.x = Rand_CenteredFloat(6.0f) + pthis->actor.world.pos.x; + sparklePos.y = (Rand_ZeroOne() * 6.0f) + pthis->actor.world.pos.y; + sparklePos.z = Rand_CenteredFloat(6.0f) + pthis->actor.world.pos.z; + + primColor.r = pthis->innerColor.r; + primColor.g = pthis->innerColor.g; + primColor.b = pthis->innerColor.b; + + envColor.r = pthis->outerColor.r; + envColor.g = pthis->outerColor.g; + envColor.b = pthis->outerColor.b; + + EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, + 1000, sparkleLife); +} + +void func_80A04D90(EnElf* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 bgId; + + pthis->actor.floorHeight = BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, + &pthis->actor, &pthis->actor.world.pos); + pthis->actor.shape.shadowAlpha = 0x32; +} + +// move to talk to player +void func_80A04DE4(EnElf* pthis, GlobalContext* globalCtx) { + Vec3f headCopy; + Player* player = GET_PLAYER(globalCtx); + Vec3f naviRefPos; + + if (pthis->fairyFlags & 0x10) { + naviRefPos = globalCtx->actorCtx.targetCtx.naviRefPos; + + if ((player->unk_664 == NULL) || (&player->actor == player->unk_664) || (&pthis->actor == player->unk_664)) { + naviRefPos.x = player->bodyPartsPos[7].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); + naviRefPos.y = player->bodyPartsPos[7].y + 5.0f; + naviRefPos.z = player->bodyPartsPos[7].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); + } + + pthis->actor.focus.pos = naviRefPos; + pthis->fairyFlags &= ~0x10; + } + + func_80A03AB0(pthis, globalCtx); + headCopy = pthis->actor.focus.pos; + + func_80A03148(pthis, &headCopy, 0, 20.0f, 0.2f); + + if (pthis->actor.speedXZ >= 5.0f) { + EnElf_SpawnSparkles(pthis, globalCtx, 16); + } + + Math_SmoothStepToF(&pthis->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); + EnElf_UpdateLights(pthis, globalCtx); +} + +// move after talking to player +void func_80A04F94(EnElf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->unk_2BC, 5, 0x1000, 0x400); + pthis->timer++; + Math_StepToF(&pthis->unk_2A4, 1.0f, 0.05f); + Environment_AdjustLights(globalCtx, SQ(pthis->unk_2A4), player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f); +} + +// ask to talk to saria again +void func_80A05040(Actor* thisx, GlobalContext* globalCtx) { + EnElf* pthis = (EnElf*)thisx; + + func_80A04DE4(pthis, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + Message_ContinueTextbox(globalCtx, ElfMessage_GetSariaText(globalCtx)); + pthis->actor.update = func_80A05114; + break; + case 1: // no + Message_CloseTextbox(globalCtx); + pthis->actor.update = func_80A053F0; + func_80A01C38(pthis, 0); + pthis->fairyFlags &= ~0x20; + break; + } + } + + func_80A04F94(pthis, globalCtx); +} + +void func_80A05114(Actor* thisx, GlobalContext* globalCtx) { + EnElf* pthis = (EnElf*)thisx; + + func_80A04DE4(pthis, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0xE3); + pthis->actor.update = func_80A05040; + } + + func_80A04F94(pthis, globalCtx); +} + +void func_80A05188(Actor* thisx, GlobalContext* globalCtx) { + EnElf* pthis = (EnElf*)thisx; + + func_80A04DE4(pthis, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, ElfMessage_GetSariaText(globalCtx)); + pthis->actor.update = func_80A05114; + } + + func_80A04F94(pthis, globalCtx); +} + +// ask to talk to navi +void func_80A05208(Actor* thisx, GlobalContext* globalCtx) { + s32 naviCUpText; + EnElf* pthis = (EnElf*)thisx; + + func_80A04DE4(pthis, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + naviCUpText = ElfMessage_GetCUpText(globalCtx); + + if (naviCUpText != 0) { + Message_ContinueTextbox(globalCtx, naviCUpText); + } else { + Message_ContinueTextbox(globalCtx, 0x15F); + } + + pthis->actor.update = func_80A052F4; + break; + case 1: // no + Message_CloseTextbox(globalCtx); + pthis->actor.update = func_80A053F0; + func_80A01C38(pthis, 0); + pthis->fairyFlags &= ~0x20; + break; + } + } + + func_80A04F94(pthis, globalCtx); +} + +// ask to talk to saria +void func_80A052F4(Actor* thisx, GlobalContext* globalCtx) { + EnElf* pthis = (EnElf*)thisx; + + func_80A04DE4(pthis, globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.unk_E3F2 = 0xFF; + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + pthis->actor.update = func_80A05188; + Message_ContinueTextbox(globalCtx, 0xE2); + break; + case 1: // no + pthis->actor.update = func_80A05208; + Message_ContinueTextbox(globalCtx, 0xE1); + break; + } + } + } else if (Actor_TextboxIsClosing(thisx, globalCtx)) { + pthis->actor.update = func_80A053F0; + func_80A01C38(pthis, 0); + pthis->fairyFlags &= ~0x20; + } + + func_80A04F94(pthis, globalCtx); +} + +void func_80A053F0(Actor* thisx, GlobalContext* globalCtx) { + u8 unk2C7; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + EnElf* pthis = (EnElf*)thisx; + + if (player->naviTextId == 0) { + if (player->unk_664 == NULL) { + if (((gSaveContext.naviTimer >= 600) && (gSaveContext.naviTimer <= 3000)) || (nREG(89) != 0)) { + player->naviTextId = ElfMessage_GetCUpText(globalCtx); + + if (player->naviTextId == 0x15F) { + player->naviTextId = 0; + } + } + } + } else if (player->naviTextId < 0) { + // trigger dialog instantly for negative message IDs + thisx->flags |= ACTOR_FLAG_16; + } + + if (Actor_ProcessTalkRequest(thisx, globalCtx)) { + func_800F4524(&D_801333D4, NA_SE_VO_SK_LAUGH, 0x20); + thisx->focus.pos = thisx->world.pos; + + if (thisx->textId == ElfMessage_GetCUpText(globalCtx)) { + pthis->fairyFlags |= 0x80; + gSaveContext.naviTimer = 3001; + } + + pthis->fairyFlags |= 0x10; + pthis->fairyFlags |= 0x20; + thisx->update = func_80A052F4; + func_80A01C38(pthis, 3); + + if (pthis->elfMsg != NULL) { + pthis->elfMsg->actor.flags |= ACTOR_FLAG_8; + } + + thisx->flags &= ~ACTOR_FLAG_16; + } else { + pthis->actionFunc(pthis, globalCtx); + thisx->shape.rot.y = pthis->unk_2BC; + nREG(80) = gSaveContext.sceneFlags[127].chest; + + if (nREG(81) != 0) { + if (gSaveContext.sceneFlags[127].chest) { + LOG_NUM("z_common_data.memory.information.room_inf[127][ 0 ]", gSaveContext.sceneFlags[127].chest, + "../z_en_elf.c", 2595); + } + } + + if (!Gameplay_InCsMode(globalCtx)) { + if (gSaveContext.naviTimer < 25800) { + gSaveContext.naviTimer++; + } else if (!(pthis->fairyFlags & 0x80)) { + gSaveContext.naviTimer = 0; + } + } + } + + pthis->elfMsg = NULL; + pthis->timer++; + + if (pthis->unk_2A4 > 0.0f) { + Math_StepToF(&pthis->unk_2A4, 0.0f, 0.05f); + Environment_AdjustLights(globalCtx, SQ(pthis->unk_2A4) * pthis->unk_2A4, player->actor.projectedPos.z + 780.0f, + 0.2f, 0.5f); + } + + // temp probably fake match + unk2C7 = pthis->unk_2C7; + if (unk2C7 > 0) { + pthis->unk_2C7--; + } + + if ((pthis->unk_2C7 == 0) && (globalCtx->csCtx.state != CS_STATE_IDLE)) { + pthis->unk_2C7 = 1; + } + + func_80A04D90(pthis, globalCtx); +} + +void EnElf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElf* pthis = (EnElf*)thisx; + + pthis->actionFunc(pthis, globalCtx); + pthis->actor.shape.rot.y = pthis->unk_2BC; + pthis->timer++; + + if (pthis->fairyFlags & FAIRY_FLAG_BIG) { + func_80A04D90(pthis, globalCtx); + } +} + +s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 pad; + f32 scale; + Vec3f mtxMult; + EnElf* pthis = (EnElf*)thisx; + + if (limbIndex == 8) { + scale = ((Math_SinS(pthis->timer * 4096) * 0.1f) + 1.0f) * 0.012f; + + if (pthis->fairyFlags & FAIRY_FLAG_BIG) { + scale *= 2.0f; + } + + scale *= (pthis->actor.scale.x * 124.99999f); + Matrix_MultVec3f(&zeroVec, &mtxMult); + Matrix_Translate(mtxMult.x, mtxMult.y, mtxMult.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + } + + // do not draw wings for big fairies + if (pthis->fairyFlags & FAIRY_FLAG_BIG) { + if (limbIndex == 4 || limbIndex == 7 || limbIndex == 11 || limbIndex == 14) { + *dList = NULL; + } + } + + return false; +} + +void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + f32 alphaScale; + s32 envAlpha; + EnElf* pthis = (EnElf*)thisx; + s32 pad1; + Gfx* dListHead; + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->unk_2A8 != 8) && !(pthis->fairyFlags & 8)) { + if (!(player->stateFlags1 & 0x100000) || (kREG(90) < pthis->actor.projectedPos.z)) { + dListHead = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_elf.c", 2730); + + func_80094B58(globalCtx->state.gfxCtx); + + envAlpha = (pthis->timer * 50) & 0x1FF; + envAlpha = (envAlpha > 255) ? 511 - envAlpha : envAlpha; + + alphaScale = pthis->disappearTimer < 0 ? (pthis->disappearTimer * (7.0f / 6000.0f)) + 1.0f : 1.0f; + + gSPSegment(POLY_XLU_DISP++, 0x08, dListHead); + gDPPipeSync(dListHead++); + gDPSetPrimColor(dListHead++, 0, 0x01, (u8)pthis->innerColor.r, (u8)pthis->innerColor.g, + (u8)pthis->innerColor.b, (u8)(pthis->innerColor.a * alphaScale)); + + if (pthis->fairyFlags & 4) { + gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_CLD_SURF2); + } else { + gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + } + + gSPEndDisplayList(dListHead++); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)pthis->outerColor.r, (u8)pthis->outerColor.g, (u8)pthis->outerColor.b, + (u8)(envAlpha * alphaScale)); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnElf_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_elf.c", 2793); + } + } +} + +void EnElf_GetCutsceneNextPos(Vec3f* vec, GlobalContext* globalCtx, s32 action) { + Vec3f startPos; + Vec3f endPos; + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[action]; + f32 lerp; + + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; + + endPos.x = npcAction->endPos.x; + endPos.y = npcAction->endPos.y; + endPos.z = npcAction->endPos.z; + + lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); + + vec->x = ((endPos.x - startPos.x) * lerp) + startPos.x; + vec->y = ((endPos.y - startPos.y) * lerp) + startPos.y; + vec->z = ((endPos.z - startPos.z) * lerp) + startPos.z; +} diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.cpp similarity index 59% rename from src/overlays/actors/ovl_En_Encount1/z_en_encount1.c rename to src/overlays/actors/ovl_En_Encount1/z_en_encount1.cpp index dbc3a8e17..aca74012c 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.cpp @@ -14,14 +14,14 @@ void EnEncount1_Init(Actor* thisx, GlobalContext* globalCtx); void EnEncount1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx); -void EnEncount1_SpawnTektites(EnEncount1* this, GlobalContext* globalCtx); -void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCtx); +void EnEncount1_SpawnLeevers(EnEncount1* pthis, GlobalContext* globalCtx); +void EnEncount1_SpawnTektites(EnEncount1* pthis, GlobalContext* globalCtx); +void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* pthis, GlobalContext* globalCtx); static s16 sLeeverAngles[] = { 0x0000, 0x2710, 0x7148, 0x8EB8, 0xD8F0 }; static f32 sLeeverDists[] = { 200.0f, 170.0f, 120.0f, 120.0f, 170.0f }; -const ActorInit En_Encount1_InitVars = { +ActorInit En_Encount1_InitVars = { ACTOR_EN_ENCOUNT1, ACTORCAT_PROP, FLAGS, @@ -35,10 +35,10 @@ const ActorInit En_Encount1_InitVars = { void EnEncount1_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnEncount1* this = (EnEncount1*)thisx; + EnEncount1* pthis = (EnEncount1*)thisx; f32 spawnRange; - if (this->actor.params <= 0) { + if (pthis->actor.params <= 0) { osSyncPrintf("\n\n"); // "Input error death!" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST); @@ -47,56 +47,56 @@ void EnEncount1_Init(Actor* thisx, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST); osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 入力エラーデッス! ☆☆☆☆☆ \n" VT_RST); osSyncPrintf("\n\n"); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->spawnType = (this->actor.params >> 0xB) & 0x1F; - this->maxCurSpawns = (this->actor.params >> 6) & 0x1F; - this->maxTotalSpawns = this->actor.params & 0x3F; - this->curNumSpawn = this->totalNumSpawn = 0; - spawnRange = 120.0f + (40.0f * this->actor.world.rot.z); - this->spawnRange = spawnRange; + pthis->spawnType = (pthis->actor.params >> 0xB) & 0x1F; + pthis->maxCurSpawns = (pthis->actor.params >> 6) & 0x1F; + pthis->maxTotalSpawns = pthis->actor.params & 0x3F; + pthis->curNumSpawn = pthis->totalNumSpawn = 0; + spawnRange = 120.0f + (40.0f * pthis->actor.world.rot.z); + pthis->spawnRange = spawnRange; osSyncPrintf("\n\n"); // "It's an enemy spawner!" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 敵発生ゾーンでた! ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 敵発生ゾーンでた! ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); // "Type" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 種類\t\t ☆☆☆☆☆ %d\n" VT_RST, this->spawnType); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 種類\t\t ☆☆☆☆☆ %d\n" VT_RST, pthis->spawnType); // "Maximum number of simultaneous spawns" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 最大同時発生数 ☆☆☆☆☆ %d\n" VT_RST, this->maxCurSpawns); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 最大同時発生数 ☆☆☆☆☆ %d\n" VT_RST, pthis->maxCurSpawns); // "Maximum number of spawns" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 最大発生数 \t ☆☆☆☆☆ %d\n" VT_RST, this->maxTotalSpawns); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 最大発生数 \t ☆☆☆☆☆ %d\n" VT_RST, pthis->maxTotalSpawns); // "Spawn check range" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生チェック範囲 ☆☆☆☆☆ %f\n" VT_RST, this->spawnRange); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生チェック範囲 ☆☆☆☆☆ %f\n" VT_RST, pthis->spawnRange); osSyncPrintf("\n\n"); - this->actor.flags &= ~ACTOR_FLAG_0; - switch (this->spawnType) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + switch (pthis->spawnType) { case SPAWNER_LEEVER: - this->timer = 30; - this->maxCurSpawns = 5; + pthis->timer = 30; + pthis->maxCurSpawns = 5; if (globalCtx->sceneNum == SCENE_SPOT13) { // Haunted Wasteland - this->reduceLeevers = true; - this->maxCurSpawns = 3; + pthis->reduceLeevers = true; + pthis->maxCurSpawns = 3; } - this->updateFunc = EnEncount1_SpawnLeevers; + pthis->updateFunc = EnEncount1_SpawnLeevers; break; case SPAWNER_TEKTITE: - this->maxCurSpawns = 2; - this->updateFunc = EnEncount1_SpawnTektites; + pthis->maxCurSpawns = 2; + pthis->updateFunc = EnEncount1_SpawnTektites; break; case SPAWNER_STALCHILDREN: case SPAWNER_WOLFOS: if (globalCtx->sceneNum == SCENE_SPOT00) { // Hyrule Field - this->maxTotalSpawns = 10000; + pthis->maxTotalSpawns = 10000; } - this->updateFunc = EnEncount1_SpawnStalchildOrWolfos; + pthis->updateFunc = EnEncount1_SpawnStalchildOrWolfos; break; } } -void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx) { +void EnEncount1_SpawnLeevers(EnEncount1* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 floorType; f32 spawnDist; @@ -109,26 +109,26 @@ void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx) { f32 floorY; EnReeba* leever; - this->outOfRangeTimer = 0; - spawnPos = this->actor.world.pos; + pthis->outOfRangeTimer = 0; + spawnPos = pthis->actor.world.pos; - if ((this->timer == 0) && (globalCtx->csCtx.state == CS_STATE_IDLE) && (this->curNumSpawn <= this->maxCurSpawns) && - (this->curNumSpawn < 5)) { + if ((pthis->timer == 0) && (globalCtx->csCtx.state == CS_STATE_IDLE) && (pthis->curNumSpawn <= pthis->maxCurSpawns) && + (pthis->curNumSpawn < 5)) { floorType = func_80041D4C(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId); if ((floorType != 4) && (floorType != 7) && (floorType != 12)) { - this->numLeeverSpawns = 0; - } else if (!(this->reduceLeevers && (this->actor.xzDistToPlayer > 1300.0f))) { + pthis->numLeeverSpawns = 0; + } else if (!(pthis->reduceLeevers && (pthis->actor.xzDistToPlayer > 1300.0f))) { spawnLimit = 5; - if (this->reduceLeevers) { + if (pthis->reduceLeevers) { spawnLimit = 3; } - while ((this->curNumSpawn < this->maxCurSpawns) && (this->curNumSpawn < spawnLimit) && (this->timer == 0)) { - spawnDist = sLeeverDists[this->leeverIndex]; - spawnAngle = sLeeverAngles[this->leeverIndex] + player->actor.shape.rot.y; + while ((pthis->curNumSpawn < pthis->maxCurSpawns) && (pthis->curNumSpawn < spawnLimit) && (pthis->timer == 0)) { + spawnDist = sLeeverDists[pthis->leeverIndex]; + spawnAngle = sLeeverAngles[pthis->leeverIndex] + player->actor.shape.rot.y; spawnParams = LEEVER_SMALL; - if ((this->killCount >= 10) && (this->bigLeever == NULL)) { - this->killCount = this->numLeeverSpawns = 0; + if ((pthis->killCount >= 10) && (pthis->bigLeever == NULL)) { + pthis->killCount = pthis->numLeeverSpawns = 0; spawnAngle = sLeeverAngles[0]; spawnDist = sLeeverDists[2]; spawnParams = LEEVER_BIG; @@ -138,36 +138,36 @@ void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx) { spawnPos.y = player->actor.floorHeight + 120.0f; spawnPos.z = player->actor.world.pos.z + Math_CosS(spawnAngle) * spawnDist; - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgId, &pthis->actor, &spawnPos); if (floorY <= BGCHECK_Y_MIN) { break; } spawnPos.y = floorY; - leever = (EnReeba*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_REEBA, + leever = (EnReeba*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_REEBA, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, spawnParams); if (1) {} if (1) {} if (leever != NULL) { - this->curNumSpawn++; - leever->unk_280 = this->leeverIndex++; - if (this->leeverIndex >= 5) { - this->leeverIndex = 0; + pthis->curNumSpawn++; + leever->unk_280 = pthis->leeverIndex++; + if (pthis->leeverIndex >= 5) { + pthis->leeverIndex = 0; } - this->numLeeverSpawns++; - if (this->numLeeverSpawns >= 12) { - this->timer = 150; - this->numLeeverSpawns = 0; + pthis->numLeeverSpawns++; + if (pthis->numLeeverSpawns >= 12) { + pthis->timer = 150; + pthis->numLeeverSpawns = 0; } if (spawnParams != LEEVER_SMALL) { - this->timer = 300; - this->bigLeever = leever; + pthis->timer = 300; + pthis->bigLeever = leever; } - if (!this->reduceLeevers) { - this->maxCurSpawns = (s16)Rand_ZeroFloat(3.99f) + 2; + if (!pthis->reduceLeevers) { + pthis->maxCurSpawns = (s16)Rand_ZeroFloat(3.99f) + 2; } else { - this->maxCurSpawns = (s16)Rand_ZeroFloat(2.99f) + 1; + pthis->maxCurSpawns = (s16)Rand_ZeroFloat(2.99f) + 1; } } else { // "Cannot spawn!" @@ -181,33 +181,33 @@ void EnEncount1_SpawnLeevers(EnEncount1* this, GlobalContext* globalCtx) { } } -void EnEncount1_SpawnTektites(EnEncount1* this, GlobalContext* globalCtx) { +void EnEncount1_SpawnTektites(EnEncount1* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 bgId; CollisionPoly* floorPoly; Vec3f spawnPos; f32 floorY; - if (this->timer == 0) { - this->timer = 10; - if ((fabsf(player->actor.world.pos.y - this->actor.world.pos.y) > 100.0f) || - (this->actor.xzDistToPlayer > this->spawnRange)) { - this->outOfRangeTimer++; + if (pthis->timer == 0) { + pthis->timer = 10; + if ((fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) > 100.0f) || + (pthis->actor.xzDistToPlayer > pthis->spawnRange)) { + pthis->outOfRangeTimer++; } else { - this->outOfRangeTimer = 0; - if ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) { - spawnPos.x = this->actor.world.pos.x + Rand_CenteredFloat(50.0f); - spawnPos.y = this->actor.world.pos.y + 120.0f; - spawnPos.z = this->actor.world.pos.z + Rand_CenteredFloat(50.0f); - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); + pthis->outOfRangeTimer = 0; + if ((pthis->curNumSpawn < pthis->maxCurSpawns) && (pthis->totalNumSpawn < pthis->maxTotalSpawns)) { + spawnPos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(50.0f); + spawnPos.y = pthis->actor.world.pos.y + 120.0f; + spawnPos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(50.0f); + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgId, &pthis->actor, &spawnPos); if (floorY <= BGCHECK_Y_MIN) { return; } spawnPos.y = floorY; - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TITE, spawnPos.x, + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_TITE, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, TEKTITE_RED) != NULL) { // Red tektite - this->curNumSpawn++; - this->totalNumSpawn++; + pthis->curNumSpawn++; + pthis->totalNumSpawn++; } else { // "Cannot spawn!" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生できません! ☆☆☆☆☆\n" VT_RST); @@ -219,7 +219,7 @@ void EnEncount1_SpawnTektites(EnEncount1* this, GlobalContext* globalCtx) { } } -void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCtx) { +void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 spawnDist; s16 spawnAngle; @@ -233,38 +233,38 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCt f32 floorY; if (globalCtx->sceneNum != SCENE_SPOT00) { - if ((fabsf(player->actor.world.pos.y - this->actor.world.pos.y) > 100.0f) || - (this->actor.xzDistToPlayer > this->spawnRange)) { - this->outOfRangeTimer++; + if ((fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) > 100.0f) || + (pthis->actor.xzDistToPlayer > pthis->spawnRange)) { + pthis->outOfRangeTimer++; return; } } else if (IS_DAY || (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY)) { - this->killCount = 0; + pthis->killCount = 0; return; } - this->outOfRangeTimer = 0; - spawnPos = this->actor.world.pos; - if ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) { - while ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) { + pthis->outOfRangeTimer = 0; + spawnPos = pthis->actor.world.pos; + if ((pthis->curNumSpawn < pthis->maxCurSpawns) && (pthis->totalNumSpawn < pthis->maxTotalSpawns)) { + while ((pthis->curNumSpawn < pthis->maxCurSpawns) && (pthis->totalNumSpawn < pthis->maxTotalSpawns)) { if (globalCtx->sceneNum == SCENE_SPOT00) { if ((player->unk_89E == 0) || (player->actor.floorBgId != BGCHECK_SCENE) || !(player->actor.bgCheckFlags & 1) || (player->stateFlags1 & 0x08000000)) { - this->fieldSpawnTimer = 60; + pthis->fieldSpawnTimer = 60; break; } - if (this->fieldSpawnTimer == 60) { - this->maxCurSpawns = 2; + if (pthis->fieldSpawnTimer == 60) { + pthis->maxCurSpawns = 2; } - if (this->fieldSpawnTimer != 0) { - this->fieldSpawnTimer--; + if (pthis->fieldSpawnTimer != 0) { + pthis->fieldSpawnTimer--; break; } spawnDist = Rand_CenteredFloat(40.0f) + 200.0f; spawnAngle = player->actor.shape.rot.y; - if (this->curNumSpawn != 0) { + if (pthis->curNumSpawn != 0) { spawnAngle = -spawnAngle; spawnDist = Rand_CenteredFloat(40.0f) + 100.0f; } @@ -273,7 +273,7 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCt spawnPos.y = player->actor.floorHeight + 120.0f; spawnPos.z = player->actor.world.pos.z + (Math_CosS(spawnAngle) * spawnDist) + Rand_CenteredFloat(40.0f); - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgId, &pthis->actor, &spawnPos); if (floorY <= BGCHECK_Y_MIN) { break; } @@ -283,30 +283,30 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCt } spawnPos.y = floorY; } - if (this->spawnType == SPAWNER_WOLFOS) { + if (pthis->spawnType == SPAWNER_WOLFOS) { spawnId = ACTOR_EN_WF; spawnParams = (0xFF << 8) | 0x00; } else { spawnId = ACTOR_EN_SKB; spawnParams = 0; - kcOver10 = this->killCount / 10; + kcOver10 = pthis->killCount / 10; if (kcOver10 > 0) { - tempmod = this->killCount % 10; + tempmod = pthis->killCount % 10; if (tempmod == 0) { spawnParams = kcOver10 * 5; } } - this->killCount++; + pthis->killCount++; } - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, spawnId, spawnPos.x, spawnPos.y, + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, spawnId, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, spawnParams) != NULL) { - this->curNumSpawn++; - if (this->curNumSpawn >= this->maxCurSpawns) { - this->fieldSpawnTimer = 100; + pthis->curNumSpawn++; + if (pthis->curNumSpawn >= pthis->maxCurSpawns) { + pthis->fieldSpawnTimer = 100; } if (globalCtx->sceneNum != SCENE_SPOT00) { - this->totalNumSpawn++; + pthis->totalNumSpawn++; } } else { // "Cannot spawn!" @@ -321,11 +321,11 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, GlobalContext* globalCt void EnEncount1_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnEncount1* this = (EnEncount1*)thisx; + EnEncount1* pthis = (EnEncount1*)thisx; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - this->updateFunc(this, globalCtx); + pthis->updateFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.cpp similarity index 73% rename from src/overlays/actors/ovl_En_Encount2/z_en_encount2.c rename to src/overlays/actors/ovl_En_Encount2/z_en_encount2.cpp index eba618326..0d129bd4e 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.cpp @@ -24,14 +24,14 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx); void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx); void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnEncount2_Wait(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_Wait(EnEncount2* pthis, GlobalContext* globalCtx); +void EnEncount2_SpawnRocks(EnEncount2* pthis, GlobalContext* globalCtx); -void EnEncount2_ParticleInit(EnEncount2* this, Vec3f* particlePos, f32 scale); +void EnEncount2_ParticleInit(EnEncount2* pthis, Vec3f* particlePos, f32 scale); void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx); -void EnEncount2_ParticleUpdate(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_ParticleUpdate(EnEncount2* pthis, GlobalContext* globalCtx); -const ActorInit En_Encount2_InitVars = { +ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, ACTORCAT_ENEMY, FLAGS, @@ -44,17 +44,17 @@ const ActorInit En_Encount2_InitVars = { }; void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnEncount2* this = (EnEncount2*)thisx; + EnEncount2* pthis = (EnEncount2*)thisx; if (globalCtx->sceneNum != SCENE_SPOT16) { - this->isNotDeathMountain = true; + pthis->isNotDeathMountain = true; } - if (!this->isNotDeathMountain) { + if (!pthis->isNotDeathMountain) { osSyncPrintf("\n\n"); // "☆☆☆☆☆ Death Mountain Encount2 set ☆☆☆☆☆" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ デスマウンテンエンカウント2セットされました ☆☆☆☆☆ %d\n" VT_RST, - this->actor.params); + pthis->actor.params); if (LINK_IS_ADULT && (gSaveContext.eventChkInf[4] & 0x200)) { // flag for having used fire temple blue warp Actor_Kill(thisx); } @@ -62,67 +62,67 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { osSyncPrintf("\n\n"); // "☆☆☆☆☆ Ganon Tower Escape Encount2 set ☆☆☆☆☆" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ガノンタワー脱出エンカウント2セットされました ☆☆☆☆☆ %d\n" VT_RST, - this->actor.params); + pthis->actor.params); } - this->actionFunc = EnEncount2_Wait; + pthis->actionFunc = EnEncount2_Wait; } -void EnEncount2_Wait(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_Wait(EnEncount2* pthis, GlobalContext* globalCtx) { s32 pad; s16 quakeIndex; s16 spawnerState; Player* player = GET_PLAYER(globalCtx); spawnerState = ENCOUNT2_INACTIVE; - if (!this->isNotDeathMountain) { + if (!pthis->isNotDeathMountain) { if ((player->actor.world.pos.y > 1500.0f) && (player->actor.world.pos.x > -700.0f) && (player->actor.world.pos.x < 100.0f) && (player->actor.world.pos.z < -1290.0f) && (player->actor.world.pos.z > -3600.0f)) { spawnerState = ENCOUNT2_ACTIVE_DEATH_MOUNTAIN; } - } else if ((this->actor.xzDistToPlayer < 700.0f) && (Flags_GetSwitch(globalCtx, 0x37))) { + } else if ((pthis->actor.xzDistToPlayer < 700.0f) && (Flags_GetSwitch(globalCtx, 0x37))) { s16 scene = globalCtx->sceneNum; if (((scene == SCENE_GANON_DEMO) || (scene == SCENE_GANON_FINAL) || (scene == SCENE_GANON_SONOGO) || (scene == SCENE_GANONTIKA_SONOGO)) && - (!this->collapseSpawnerInactive)) { + (!pthis->collapseSpawnerInactive)) { spawnerState = ENCOUNT2_ACTIVE_GANONS_TOWER; } } switch (spawnerState) { case ENCOUNT2_INACTIVE: - this->isQuaking = false; - this->envEffectsTimer--; - if (this->envEffectsTimer <= 0) { - this->envEffectsTimer = 0; + pthis->isQuaking = false; + pthis->envEffectsTimer--; + if (pthis->envEffectsTimer <= 0) { + pthis->envEffectsTimer = 0; } break; case ENCOUNT2_ACTIVE_DEATH_MOUNTAIN: - if ((this->deathMountainSpawnerTimer == 1) || (!this->isQuaking)) { + if ((pthis->deathMountainSpawnerTimer == 1) || (!pthis->isQuaking)) { quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); Quake_SetSpeed(quakeIndex, 0x7FFF); Quake_SetQuakeValues(quakeIndex, 50, 0, 0, 0); Quake_SetCountdown(quakeIndex, 300); - this->isQuaking = true; + pthis->isQuaking = true; } case ENCOUNT2_ACTIVE_GANONS_TOWER: - this->envEffectsTimer++; - if (this->envEffectsTimer > 60) { - this->envEffectsTimer = 60; + pthis->envEffectsTimer++; + if (pthis->envEffectsTimer > 60) { + pthis->envEffectsTimer = 60; } - if (this->deathMountainSpawnerTimer == 0) { - this->deathMountainSpawnerTimer = 200; - this->numSpawnedRocks = 0; - this->actionFunc = EnEncount2_SpawnRocks; + if (pthis->deathMountainSpawnerTimer == 0) { + pthis->deathMountainSpawnerTimer = 200; + pthis->numSpawnedRocks = 0; + pthis->actionFunc = EnEncount2_SpawnRocks; } break; } return; } -void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_SpawnRocks(EnEncount2* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnFireRock* spawnedRock; f32 tempVec1X; @@ -138,18 +138,18 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { s16 spawnerState; s16 maxRocks; - this->envEffectsTimer++; + pthis->envEffectsTimer++; - if (this->envEffectsTimer > 60) { - this->envEffectsTimer = 60; + if (pthis->envEffectsTimer > 60) { + pthis->envEffectsTimer = 60; } spawnerState = ENCOUNT2_INACTIVE; - if (!this->isNotDeathMountain) { - if (this->deathMountainSpawnerTimer == 0) { - this->deathMountainSpawnerTimer = 100; - this->actionFunc = EnEncount2_Wait; + if (!pthis->isNotDeathMountain) { + if (pthis->deathMountainSpawnerTimer == 0) { + pthis->deathMountainSpawnerTimer = 100; + pthis->actionFunc = EnEncount2_Wait; return; } @@ -160,13 +160,13 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { spawnerState = ENCOUNT2_ACTIVE_DEATH_MOUNTAIN; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_VOLCANO - SFX_FLAG); - } else if ((this->actor.xzDistToPlayer < 700.0f) && (Flags_GetSwitch(globalCtx, 0x37) != 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_VOLCANO - SFX_FLAG); + } else if ((pthis->actor.xzDistToPlayer < 700.0f) && (Flags_GetSwitch(globalCtx, 0x37) != 0)) { s16 scene = globalCtx->sceneNum; if (((scene == SCENE_GANON_DEMO) || (scene == SCENE_GANON_FINAL) || (scene == SCENE_GANON_SONOGO) || (scene == SCENE_GANONTIKA_SONOGO)) && - (!this->collapseSpawnerInactive)) { + (!pthis->collapseSpawnerInactive)) { maxRocks = 1; spawnerState = ENCOUNT2_ACTIVE_GANONS_TOWER; } @@ -196,15 +196,15 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { particleScale = Rand_CenteredFloat(0.005f) + 0.007f; if (spawnerState == ENCOUNT2_ACTIVE_DEATH_MOUNTAIN) { - EnEncount2_ParticleInit(this, &particlePos, particleScale); - } else if (this->particleSpawnTimer == 0) { - EnEncount2_ParticleInit(this, &particlePos, particleScale); - this->particleSpawnTimer = 5; + EnEncount2_ParticleInit(pthis, &particlePos, particleScale); + } else if (pthis->particleSpawnTimer == 0) { + EnEncount2_ParticleInit(pthis, &particlePos, particleScale); + pthis->particleSpawnTimer = 5; } - if ((this->numSpawnedRocks < maxRocks) && (this->timerBetweenRockSpawns == 0)) { + if ((pthis->numSpawnedRocks < maxRocks) && (pthis->timerBetweenRockSpawns == 0)) { if (spawnerState == ENCOUNT2_ACTIVE_DEATH_MOUNTAIN) { - this->timerBetweenRockSpawns = 4; + pthis->timerBetweenRockSpawns = 4; spawnedRockType = FIRE_ROCK_SPAWNED_FALLING1; if ((Rand_ZeroFloat(1.99f) < 1.0f) && !LINK_IS_ADULT) { // rock spawn pos X, Z near player @@ -224,7 +224,7 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { spawnedRockType = FIRE_ROCK_SPAWNED_FALLING2; } } else { - this->timerBetweenRockSpawns = 50; + pthis->timerBetweenRockSpawns = 50; spawnedRockType = FIRE_ROCK_SPAWNED_FALLING2; // rock spawn pos X,Z at a random position roughly 300 units ahead of camera tempVec2X = Rand_CenteredFloat(100.0f) + tempVec1X; @@ -237,11 +237,11 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { } } spawnedRock = - (EnFireRock*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FIRE_ROCK, + (EnFireRock*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FIRE_ROCK, tempVec2X, tempVec1Y, tempVec2Z, 0, 0, 0, spawnedRockType); if (spawnedRock != NULL) { - spawnedRock->spawner = this; - this->numSpawnedRocks++; + spawnedRock->spawner = pthis; + pthis->numSpawnedRocks++; return; } // "☆☆☆☆☆ Can't occur! ☆☆☆☆☆" @@ -255,52 +255,52 @@ void EnEncount2_SpawnRocks(EnEncount2* this, GlobalContext* globalCtx) { } void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnEncount2* this = (EnEncount2*)thisx; + EnEncount2* pthis = (EnEncount2*)thisx; GlobalContext* globalCtx = globalCtx2; - if (this->deathMountainSpawnerTimer != 0) { - this->deathMountainSpawnerTimer--; + if (pthis->deathMountainSpawnerTimer != 0) { + pthis->deathMountainSpawnerTimer--; } - if (this->timerBetweenRockSpawns != 0) { - this->timerBetweenRockSpawns--; + if (pthis->timerBetweenRockSpawns != 0) { + pthis->timerBetweenRockSpawns--; } - if (this->particleSpawnTimer != 0) { - this->particleSpawnTimer--; + if (pthis->particleSpawnTimer != 0) { + pthis->particleSpawnTimer--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - EnEncount2_ParticleUpdate(this, globalCtx); + EnEncount2_ParticleUpdate(pthis, globalCtx); - if (!this->isNotDeathMountain) { - this->unk17C = this->envEffectsTimer / 60.0f; - this->unk160 = this->unk17C * -50.0f; - globalCtx->envCtx.adjAmbientColor[0] = (s16)this->unk160 * -1.5f; - globalCtx->envCtx.adjAmbientColor[1] = globalCtx->envCtx.adjAmbientColor[2] = this->unk160; - this->unk168 = this->unk17C * -20.0f; - globalCtx->envCtx.adjLight1Color[0] = (s16)this->unk168 * -1.5f; - globalCtx->envCtx.adjLight1Color[1] = globalCtx->envCtx.adjLight1Color[2] = this->unk168; - this->unk170 = this->unk17C * -50.0f; - globalCtx->envCtx.adjFogNear = this->unk170; - globalCtx->envCtx.adjFogColor[0] = (u8)((160.0f - globalCtx->envCtx.lightSettings.fogColor[0]) * this->unk17C); - globalCtx->envCtx.adjFogColor[1] = (u8)((160.0f - globalCtx->envCtx.lightSettings.fogColor[1]) * this->unk17C); - globalCtx->envCtx.adjFogColor[2] = (u8)((150.0f - globalCtx->envCtx.lightSettings.fogColor[2]) * this->unk17C); + if (!pthis->isNotDeathMountain) { + pthis->unk17C = pthis->envEffectsTimer / 60.0f; + pthis->unk160 = pthis->unk17C * -50.0f; + globalCtx->envCtx.adjAmbientColor[0] = (s16)pthis->unk160 * -1.5f; + globalCtx->envCtx.adjAmbientColor[1] = globalCtx->envCtx.adjAmbientColor[2] = pthis->unk160; + pthis->unk168 = pthis->unk17C * -20.0f; + globalCtx->envCtx.adjLight1Color[0] = (s16)pthis->unk168 * -1.5f; + globalCtx->envCtx.adjLight1Color[1] = globalCtx->envCtx.adjLight1Color[2] = pthis->unk168; + pthis->unk170 = pthis->unk17C * -50.0f; + globalCtx->envCtx.adjFogNear = pthis->unk170; + globalCtx->envCtx.adjFogColor[0] = (u8)((160.0f - globalCtx->envCtx.lightSettings.fogColor[0]) * pthis->unk17C); + globalCtx->envCtx.adjFogColor[1] = (u8)((160.0f - globalCtx->envCtx.lightSettings.fogColor[1]) * pthis->unk17C); + globalCtx->envCtx.adjFogColor[2] = (u8)((150.0f - globalCtx->envCtx.lightSettings.fogColor[2]) * pthis->unk17C); } } void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnEncount2* this = (EnEncount2*)thisx; + EnEncount2* pthis = (EnEncount2*)thisx; - EnEncount2_ParticleDraw(&this->actor, globalCtx); + EnEncount2_ParticleDraw(&pthis->actor, globalCtx); } -void EnEncount2_ParticleInit(EnEncount2* this, Vec3f* particlePos, f32 scale) { - EnEncount2Particle* particle = this->particles; +void EnEncount2_ParticleInit(EnEncount2* pthis, Vec3f* particlePos, f32 scale) { + EnEncount2Particle* particle = pthis->particles; s16 i; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + for (i = 0; i < ARRAY_COUNT(pthis->particles); i++, particle++) { if (!particle->isAlive) { particle->pos = *particlePos; particle->scale = scale; @@ -316,13 +316,13 @@ void EnEncount2_ParticleInit(EnEncount2* this, Vec3f* particlePos, f32 scale) { } } -void EnEncount2_ParticleUpdate(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_ParticleUpdate(EnEncount2* pthis, GlobalContext* globalCtx) { s16 i; - EnEncount2Particle* particle = this->particles; + EnEncount2Particle* particle = pthis->particles; Player* player = GET_PLAYER(globalCtx); Vec3f targetPos; - for (i = 0; i < ARRAY_COUNT(this->particles); particle++, i++) { + for (i = 0; i < ARRAY_COUNT(pthis->particles); particle++, i++) { if (particle->isAlive) { particle->rot.x += Rand_ZeroOne() * 500.0f; particle->rot.y += Rand_ZeroOne() * 500.0f; @@ -347,8 +347,8 @@ void EnEncount2_ParticleUpdate(EnEncount2* this, GlobalContext* globalCtx) { } void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx) { - EnEncount2* this = (EnEncount2*)thisx; - EnEncount2Particle* particle = this->particles; + EnEncount2* pthis = (EnEncount2*)thisx; + EnEncount2Particle* particle = pthis->particles; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; s32 objBankIndex; @@ -359,9 +359,9 @@ void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx) { if (objBankIndex >= 0) { gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[objBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[objBankIndex].vromStart.get()); - for (i = 0; i < ARRAY_COUNT(this->particles); particle++, i++) { + for (i = 0; i < ARRAY_COUNT(pthis->particles); particle++, i++) { if (particle->isAlive) { Matrix_Translate(particle->pos.x, particle->pos.y, particle->pos.z, MTXMODE_NEW); Matrix_RotateX(particle->rot.x * (M_PI / 180.0f), MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c deleted file mode 100644 index 3eb3d34fa..000000000 --- a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c +++ /dev/null @@ -1,529 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_EX_ITEM_Z_EN_EX_ITEM_C -#include "actor_common.h" -/* - * File: z_en_ex_item.c - * Overlay: ovl_En_Ex_Item - * Description: Minigame prize items - */ - -#include "z_en_ex_item.h" -#include "overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "vt.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_draw.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnExItem_Init(Actor* thisx, GlobalContext* globalCtx); -void EnExItem_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnExItem_Update(Actor* thisx, GlobalContext* globalCtx); -void EnExItem_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnExItem_DrawItems(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_DrawHeartPiece(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_DrawRupee(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_DrawKey(EnExItem* this, GlobalContext* globalCtx, s32 index); -void EnExItem_DrawMagic(EnExItem* this, GlobalContext* globalCtx, s16 magicIndex); - -void EnExItem_WaitForObject(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_BowlPrize(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_SetupBowlCounter(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_BowlCounter(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_ExitChest(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_FairyMagic(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_TargetPrizeApproach(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_TargetPrizeGive(EnExItem* this, GlobalContext* globalCtx); -void EnExItem_TargetPrizeFinish(EnExItem* this, GlobalContext* globalCtx); - -const ActorInit En_Ex_Item_InitVars = { - ACTOR_EN_EX_ITEM, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnExItem), - (ActorFunc)EnExItem_Init, - (ActorFunc)EnExItem_Destroy, - (ActorFunc)EnExItem_Update, - (ActorFunc)EnExItem_Draw, -}; - -void EnExItem_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnExItem_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnExItem* this = (EnExItem*)thisx; - - this->actor.flags &= ~ACTOR_FLAG_0; - this->type = this->actor.params & 0xFF; - this->unusedParam = (this->actor.params >> 8) & 0xFF; - osSyncPrintf("\n\n"); - // "What will come out?" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ なにがでるかな? ☆☆☆☆☆ %d\n" VT_RST, this->type); - // "What will come out?" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ なにがでるかな? ☆☆☆☆☆ %d\n" VT_RST, this->unusedParam); - this->initPos = this->actor.world.pos; - this->getItemObjId = -1; - switch (this->type) { - case EXITEM_BOMB_BAG_BOWLING: - case EXITEM_BOMB_BAG_COUNTER: - this->getItemObjId = OBJECT_GI_BOMBPOUCH; - break; - case EXITEM_HEART_PIECE_BOWLING: - case EXITEM_HEART_PIECE_COUNTER: - this->getItemObjId = OBJECT_GI_HEARTS; - break; - case EXITEM_BOMBCHUS_BOWLING: - case EXITEM_BOMBCHUS_COUNTER: - this->getItemObjId = OBJECT_GI_BOMB_2; - break; - case EXITEM_BOMBS_BOWLING: - case EXITEM_BOMBS_COUNTER: - this->getItemObjId = OBJECT_GI_BOMB_1; - break; - case EXITEM_PURPLE_RUPEE_BOWLING: - case EXITEM_PURPLE_RUPEE_COUNTER: - case EXITEM_GREEN_RUPEE_CHEST: - case EXITEM_BLUE_RUPEE_CHEST: - case EXITEM_RED_RUPEE_CHEST: - case EXITEM_13: - case EXITEM_14: - this->getItemObjId = OBJECT_GI_RUPY; - break; - case EXITEM_SMALL_KEY_CHEST: - this->scale = 0.05f; - this->actor.velocity.y = 10.0f; - this->timer = 7; - this->actionFunc = EnExItem_ExitChest; - break; - case EXITEM_MAGIC_FIRE: - case EXITEM_MAGIC_WIND: - case EXITEM_MAGIC_DARK: - this->getItemObjId = OBJECT_GI_GODDESS; - break; - case EXITEM_BULLET_BAG: - this->getItemObjId = OBJECT_GI_DEKUPOUCH; - } - - if (this->getItemObjId >= 0) { - this->objectIdx = Object_GetIndex(&globalCtx->objectCtx, this->getItemObjId); - this->actor.draw = NULL; - if (this->objectIdx < 0) { - Actor_Kill(&this->actor); - // "What?" - osSyncPrintf("なにみの? %d\n", this->actor.params); - // "bank is funny" - osSyncPrintf(VT_FGCOL(PURPLE) " バンクおかしいしぞ!%d\n" VT_RST "\n", this->actor.params); - return; - } - this->actionFunc = EnExItem_WaitForObject; - } -} - -void EnExItem_WaitForObject(EnExItem* this, GlobalContext* globalCtx) { - s32 onCounter; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->objectIdx)) { - // "End of transfer" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); - osSyncPrintf(VT_FGCOL(BLUE) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params, this); - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n\n" VT_RST, this->actor.params, this); - this->actor.objBankIndex = this->objectIdx; - this->actor.draw = EnExItem_Draw; - this->stopRotate = false; - onCounter = false; - switch (this->type) { - case EXITEM_BOMB_BAG_COUNTER: - onCounter = true; - case EXITEM_BOMB_BAG_BOWLING: - this->unk_17C = func_8002EBCC; - this->giDrawId = GID_BOMB_BAG_30; - this->timer = 65; - this->prizeRotateTimer = 35; - this->scale = 0.5f; - if (onCounter == 0) { - this->actionFunc = EnExItem_BowlPrize; - } else { - this->actionFunc = EnExItem_SetupBowlCounter; - this->actor.shape.yOffset = -18.0f; - } - break; - case EXITEM_HEART_PIECE_COUNTER: - onCounter = true; - case EXITEM_HEART_PIECE_BOWLING: - this->unk_17C = func_8002ED80; - this->timer = 65; - this->prizeRotateTimer = 35; - this->scale = 0.5f; - if (!onCounter) { - func_80078884(NA_SE_SY_PIECE_OF_HEART); - this->actionFunc = EnExItem_BowlPrize; - } else { - this->actionFunc = EnExItem_SetupBowlCounter; - this->actor.shape.yOffset = -10.0f; - } - break; - case EXITEM_BOMBCHUS_COUNTER: - onCounter = true; - case EXITEM_BOMBCHUS_BOWLING: - this->unk_17C = func_8002EBCC; - this->giDrawId = GID_BOMBCHU; - this->timer = 65; - this->prizeRotateTimer = 35; - this->scale = 0.5f; - if (!onCounter) { - this->actionFunc = EnExItem_BowlPrize; - } else { - this->actionFunc = EnExItem_SetupBowlCounter; - } - break; - case EXITEM_BOMBS_BOWLING: - case EXITEM_BOMBS_COUNTER: - this->unk_17C = func_8002EBCC; - this->giDrawId = GID_BOMB; - this->timer = 65; - this->prizeRotateTimer = 35; - this->scale = 0.5f; - this->unkFloat = 0.5f; - if (this->type == EXITEM_BOMBS_BOWLING) { - this->actionFunc = EnExItem_BowlPrize; - } else { - this->actionFunc = EnExItem_SetupBowlCounter; - this->actor.shape.yOffset = 10.0f; - } - break; - case EXITEM_PURPLE_RUPEE_BOWLING: - case EXITEM_PURPLE_RUPEE_COUNTER: - this->unk_17C = func_8002EBCC; - this->unk_180 = func_8002ED80; - this->giDrawId = GID_RUPEE_PURPLE; - this->timer = 65; - this->prizeRotateTimer = 35; - this->scale = 0.5f; - this->unkFloat = 0.5f; - if (this->type == EXITEM_PURPLE_RUPEE_BOWLING) { - this->actionFunc = EnExItem_BowlPrize; - } else { - this->actionFunc = EnExItem_SetupBowlCounter; - this->actor.shape.yOffset = 40.0f; - } - break; - case EXITEM_GREEN_RUPEE_CHEST: - case EXITEM_BLUE_RUPEE_CHEST: - case EXITEM_RED_RUPEE_CHEST: - case EXITEM_13: - case EXITEM_14: - this->unk_17C = func_8002EBCC; - this->unk_180 = func_8002ED80; - this->timer = 7; - this->scale = 0.5f; - this->unkFloat = 0.5f; - this->actor.velocity.y = 10.0f; - switch (this->type) { - case EXITEM_GREEN_RUPEE_CHEST: - this->giDrawId = GID_RUPEE_GREEN; - break; - case EXITEM_BLUE_RUPEE_CHEST: - this->giDrawId = GID_RUPEE_BLUE; - break; - case EXITEM_RED_RUPEE_CHEST: - this->giDrawId = GID_RUPEE_RED; - break; - case EXITEM_14: - this->giDrawId = GID_RUPEE_PURPLE; - break; - } - this->actionFunc = EnExItem_ExitChest; - break; - case EXITEM_MAGIC_FIRE: - case EXITEM_MAGIC_WIND: - case EXITEM_MAGIC_DARK: - this->scale = 0.35f; - this->actionFunc = EnExItem_FairyMagic; - break; - case EXITEM_BULLET_BAG: - this->unk_17C = func_8002EBCC; - this->giDrawId = GID_BULLET_BAG; - this->scale = 0.1f; - this->timer = 80; - this->prizeRotateTimer = 35; - this->actionFunc = EnExItem_TargetPrizeApproach; - break; - case EXITEM_SMALL_KEY_CHEST: - break; - } - } -} - -void EnExItem_BowlPrize(EnExItem* this, GlobalContext* globalCtx) { - s32 pad; - f32 tmpf1; - f32 tmpf2; - f32 tmpf3; - f32 tmpf4; - f32 tmpf5; - f32 tmpf6; - f32 tmpf7; - f32 sp3C; - - if (!this->stopRotate) { - this->actor.shape.rot.y += 0x1000; - if ((this->prizeRotateTimer == 0) && ((this->actor.shape.rot.y & 0xFFFF) == 0x9000)) { - this->stopRotate++; - } - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 5, 0x1000, 0); - } - if (this->timer != 0) { - if (this->prizeRotateTimer != 0) { - sp3C = 250.0f; - if (this->type == EXITEM_BOMBCHUS_BOWLING) { - sp3C = 220.0f; - } - tmpf1 = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - tmpf2 = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - tmpf3 = globalCtx->view.lookAt.z + sp3C - globalCtx->view.eye.z; - tmpf4 = sqrtf(SQ(tmpf1) + SQ(tmpf2) + SQ(tmpf3)); - - tmpf5 = (tmpf1 / tmpf4) * 5.0f; - tmpf6 = (tmpf2 / tmpf4) * 5.0f; - tmpf7 = (tmpf3 / tmpf4) * 5.0f; - - tmpf1 = globalCtx->view.eye.x + tmpf5 - this->actor.world.pos.x; - tmpf2 = globalCtx->view.eye.y + tmpf6 - this->actor.world.pos.y; - tmpf3 = globalCtx->view.eye.z + tmpf7 - this->actor.world.pos.z; - - this->actor.world.pos.x += (tmpf1 / tmpf4) * 5.0f; - this->actor.world.pos.y += (tmpf2 / tmpf4) * 5.0f; - this->actor.world.pos.z += (tmpf3 / tmpf4) * 5.0f; - } - } else { - // "parent" - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 母親ー? ☆☆☆☆☆ %x\n" VT_RST, this->actor.parent); - // "Can it move?" - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 動いてねー? ☆☆☆☆☆ %x\n" VT_RST, this->actor.parent->update); - if ((this->actor.parent != NULL) && (this->actor.parent->update != NULL)) { - ((EnBomBowlPit*)this->actor.parent)->exItemDone = 1; - // "It can't move!" - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ さぁきえるぞ! ☆☆☆☆☆ \n" VT_RST); - } - Actor_Kill(&this->actor); - } -} - -void EnExItem_SetupBowlCounter(EnExItem* this, GlobalContext* globalCtx) { - this->actor.world.rot.y = this->actor.shape.rot.y = 0x4268; - this->actionFunc = EnExItem_BowlCounter; -} - -void EnExItem_BowlCounter(EnExItem* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 0x800; - if (this->killItem) { - Actor_Kill(&this->actor); - } -} - -void EnExItem_ExitChest(EnExItem* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 0x1000; - if (this->timer != 0) { - if (this->timer == 1) { - this->chestKillTimer = 20; - } - } else { - this->actor.velocity.y = 0.0f; - if (this->chestKillTimer == 0) { - Actor_Kill(&this->actor); - } - } - Actor_MoveForward(&this->actor); -} - -void EnExItem_FairyMagic(EnExItem* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 0x800; -} - -void EnExItem_TargetPrizeApproach(EnExItem* this, GlobalContext* globalCtx) { - f32 tmpf1; - f32 tmpf2; - f32 tmpf3; - f32 tmpf4; - f32 tmpf5; - f32 tmpf6; - f32 tmpf7; - - Math_ApproachF(&this->scale, 0.8f, 0.1f, 0.02f); - if (!this->stopRotate) { - this->actor.shape.rot.y += 0x1000; - if ((this->prizeRotateTimer == 0) && ((this->actor.shape.rot.y & 0xFFFF) == 0x9000)) { - this->stopRotate++; - } - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, -0x4000, 5, 0x1000, 0); - } - - if (this->timer != 0) { - if (this->prizeRotateTimer != 0) { - tmpf1 = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - tmpf2 = globalCtx->view.lookAt.y - 10.0f - globalCtx->view.eye.y; - tmpf3 = globalCtx->view.lookAt.z + 10.0f - globalCtx->view.eye.z; - tmpf4 = sqrtf(SQ(tmpf1) + SQ(tmpf2) + SQ(tmpf3)); - - tmpf5 = (tmpf1 / tmpf4) * 5.0f; - tmpf6 = (tmpf2 / tmpf4) * 5.0f; - tmpf7 = (tmpf3 / tmpf4) * 5.0f; - - tmpf1 = globalCtx->view.eye.x + tmpf5 - this->actor.world.pos.x; - tmpf2 = globalCtx->view.eye.y - 10.0f + tmpf6 - this->actor.world.pos.y; - tmpf3 = globalCtx->view.eye.z + 10.0f + tmpf7 - this->actor.world.pos.z; - - this->actor.world.pos.x += (tmpf1 / tmpf4) * 5.0f; - this->actor.world.pos.y += (tmpf2 / tmpf4) * 5.0f; - this->actor.world.pos.z += (tmpf3 / tmpf4) * 5.0f; - } - } else { - s32 getItemId; - - this->actor.draw = NULL; - func_8002DF54(globalCtx, NULL, 7); - this->actor.parent = NULL; - if (CUR_UPG_VALUE(UPG_BULLET_BAG) == 1) { - getItemId = GI_BULLET_BAG_40; - } else { - getItemId = GI_BULLET_BAG_50; - } - func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); - this->actionFunc = EnExItem_TargetPrizeGive; - } -} - -void EnExItem_TargetPrizeGive(EnExItem* this, GlobalContext* globalCtx) { - s32 getItemId; - - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = EnExItem_TargetPrizeFinish; - } else { - getItemId = (CUR_UPG_VALUE(UPG_BULLET_BAG) == 2) ? GI_BULLET_BAG_50 : GI_BULLET_BAG_40; - - func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); - } -} - -void EnExItem_TargetPrizeFinish(EnExItem* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - // "Successful completion" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); - gSaveContext.itemGetInf[1] |= 0x2000; - Actor_Kill(&this->actor); - } -} - -void EnExItem_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnExItem* this = (EnExItem*)thisx; - - if (this->timer != 0) { - this->timer--; - } - if (this->chestKillTimer != 0) { - this->chestKillTimer--; - } - if (this->prizeRotateTimer != 0) { - this->prizeRotateTimer--; - } - this->actionFunc(this, globalCtx); -} - -void EnExItem_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnExItem* this = (EnExItem*)thisx; - s32 magicType; - - Actor_SetScale(&this->actor, this->scale); - switch (this->type) { - case EXITEM_BOMB_BAG_BOWLING: - case EXITEM_BOMBCHUS_BOWLING: - case EXITEM_BOMBS_BOWLING: - case EXITEM_BOMB_BAG_COUNTER: - case EXITEM_BOMBCHUS_COUNTER: - case EXITEM_BOMBS_COUNTER: - case EXITEM_BULLET_BAG: - EnExItem_DrawItems(this, globalCtx); - break; - case EXITEM_HEART_PIECE_BOWLING: - case EXITEM_HEART_PIECE_COUNTER: - EnExItem_DrawHeartPiece(this, globalCtx); - break; - case EXITEM_PURPLE_RUPEE_BOWLING: - case EXITEM_PURPLE_RUPEE_COUNTER: - case EXITEM_GREEN_RUPEE_CHEST: - case EXITEM_BLUE_RUPEE_CHEST: - case EXITEM_RED_RUPEE_CHEST: - case EXITEM_13: - case EXITEM_14: - EnExItem_DrawRupee(this, globalCtx); - break; - case EXITEM_SMALL_KEY_CHEST: - EnExItem_DrawKey(this, globalCtx, 0); - break; - case EXITEM_MAGIC_FIRE: - case EXITEM_MAGIC_WIND: - case EXITEM_MAGIC_DARK: - magicType = this->type - EXITEM_MAGIC_FIRE; - EnExItem_DrawMagic(this, globalCtx, magicType); - break; - } -} - -void EnExItem_DrawItems(EnExItem* this, GlobalContext* globalCtx) { - if (this->unk_17C != NULL) { - this->unk_17C(&this->actor, globalCtx, 0); - } - if (this) {} - func_8002ED80(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, this->giDrawId); -} - -void EnExItem_DrawHeartPiece(EnExItem* this, GlobalContext* globalCtx) { - func_8002ED80(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, GID_HEART_PIECE); -} - -void EnExItem_DrawMagic(EnExItem* this, GlobalContext* globalCtx, s16 magicIndex) { - static s16 sgiDrawIds[] = { GID_DINS_FIRE, GID_FARORES_WIND, GID_NAYRUS_LOVE }; - - func_8002ED80(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, sgiDrawIds[magicIndex]); -} - -void EnExItem_DrawKey(EnExItem* this, GlobalContext* globalCtx, s32 index) { - static void* keySegments[] = { gDropKeySmallTex }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_item.c", 880); - - func_8009460C(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ex_item.c", 887), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(keySegments[index])); - gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_item.c", 893); -} - -void EnExItem_DrawRupee(EnExItem* this, GlobalContext* globalCtx) { - if (this->unk_17C != NULL) { - this->unk_17C(&this->actor, globalCtx, 0); - } - if (this->unk_180 != NULL) { - this->unk_180(&this->actor, globalCtx, 0); - } - GetItem_Draw(globalCtx, this->giDrawId); -} diff --git a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.cpp b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.cpp new file mode 100644 index 000000000..674b299aa --- /dev/null +++ b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.cpp @@ -0,0 +1,529 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_EX_ITEM_Z_EN_EX_ITEM_C +#include "actor_common.h" +/* + * File: z_en_ex_item.c + * Overlay: ovl_En_Ex_Item + * Description: Minigame prize items + */ + +#include "z_en_ex_item.h" +#include "overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "vt.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_draw.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnExItem_Init(Actor* thisx, GlobalContext* globalCtx); +void EnExItem_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnExItem_Update(Actor* thisx, GlobalContext* globalCtx); +void EnExItem_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnExItem_DrawItems(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_DrawHeartPiece(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_DrawRupee(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_DrawKey(EnExItem* pthis, GlobalContext* globalCtx, s32 index); +void EnExItem_DrawMagic(EnExItem* pthis, GlobalContext* globalCtx, s16 magicIndex); + +void EnExItem_WaitForObject(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_BowlPrize(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_SetupBowlCounter(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_BowlCounter(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_ExitChest(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_FairyMagic(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_TargetPrizeApproach(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_TargetPrizeGive(EnExItem* pthis, GlobalContext* globalCtx); +void EnExItem_TargetPrizeFinish(EnExItem* pthis, GlobalContext* globalCtx); + +ActorInit En_Ex_Item_InitVars = { + ACTOR_EN_EX_ITEM, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnExItem), + (ActorFunc)EnExItem_Init, + (ActorFunc)EnExItem_Destroy, + (ActorFunc)EnExItem_Update, + (ActorFunc)EnExItem_Draw, +}; + +void EnExItem_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnExItem_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnExItem* pthis = (EnExItem*)thisx; + + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->type = pthis->actor.params & 0xFF; + pthis->unusedParam = (pthis->actor.params >> 8) & 0xFF; + osSyncPrintf("\n\n"); + // "What will come out?" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ なにがでるかな? ☆☆☆☆☆ %d\n" VT_RST, pthis->type); + // "What will come out?" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ なにがでるかな? ☆☆☆☆☆ %d\n" VT_RST, pthis->unusedParam); + pthis->initPos = pthis->actor.world.pos; + pthis->getItemObjId = -1; + switch (pthis->type) { + case EXITEM_BOMB_BAG_BOWLING: + case EXITEM_BOMB_BAG_COUNTER: + pthis->getItemObjId = OBJECT_GI_BOMBPOUCH; + break; + case EXITEM_HEART_PIECE_BOWLING: + case EXITEM_HEART_PIECE_COUNTER: + pthis->getItemObjId = OBJECT_GI_HEARTS; + break; + case EXITEM_BOMBCHUS_BOWLING: + case EXITEM_BOMBCHUS_COUNTER: + pthis->getItemObjId = OBJECT_GI_BOMB_2; + break; + case EXITEM_BOMBS_BOWLING: + case EXITEM_BOMBS_COUNTER: + pthis->getItemObjId = OBJECT_GI_BOMB_1; + break; + case EXITEM_PURPLE_RUPEE_BOWLING: + case EXITEM_PURPLE_RUPEE_COUNTER: + case EXITEM_GREEN_RUPEE_CHEST: + case EXITEM_BLUE_RUPEE_CHEST: + case EXITEM_RED_RUPEE_CHEST: + case EXITEM_13: + case EXITEM_14: + pthis->getItemObjId = OBJECT_GI_RUPY; + break; + case EXITEM_SMALL_KEY_CHEST: + pthis->scale = 0.05f; + pthis->actor.velocity.y = 10.0f; + pthis->timer = 7; + pthis->actionFunc = EnExItem_ExitChest; + break; + case EXITEM_MAGIC_FIRE: + case EXITEM_MAGIC_WIND: + case EXITEM_MAGIC_DARK: + pthis->getItemObjId = OBJECT_GI_GODDESS; + break; + case EXITEM_BULLET_BAG: + pthis->getItemObjId = OBJECT_GI_DEKUPOUCH; + } + + if (pthis->getItemObjId >= 0) { + pthis->objectIdx = Object_GetIndex(&globalCtx->objectCtx, pthis->getItemObjId); + pthis->actor.draw = NULL; + if (pthis->objectIdx < 0) { + Actor_Kill(&pthis->actor); + // "What?" + osSyncPrintf("なにみの? %d\n", pthis->actor.params); + // "bank is funny" + osSyncPrintf(VT_FGCOL(PURPLE) " バンクおかしいしぞ!%d\n" VT_RST "\n", pthis->actor.params); + return; + } + pthis->actionFunc = EnExItem_WaitForObject; + } +} + +void EnExItem_WaitForObject(EnExItem* pthis, GlobalContext* globalCtx) { + s32 onCounter; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objectIdx)) { + // "End of transfer" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params, pthis); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params, pthis); + osSyncPrintf(VT_FGCOL(BLUE) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params, pthis); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params, pthis); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 転送終了 ☆☆☆☆☆ %d\n\n" VT_RST, pthis->actor.params, pthis); + pthis->actor.objBankIndex = pthis->objectIdx; + pthis->actor.draw = EnExItem_Draw; + pthis->stopRotate = false; + onCounter = false; + switch (pthis->type) { + case EXITEM_BOMB_BAG_COUNTER: + onCounter = true; + case EXITEM_BOMB_BAG_BOWLING: + pthis->unk_17C = func_8002EBCC; + pthis->giDrawId = GID_BOMB_BAG_30; + pthis->timer = 65; + pthis->prizeRotateTimer = 35; + pthis->scale = 0.5f; + if (onCounter == 0) { + pthis->actionFunc = EnExItem_BowlPrize; + } else { + pthis->actionFunc = EnExItem_SetupBowlCounter; + pthis->actor.shape.yOffset = -18.0f; + } + break; + case EXITEM_HEART_PIECE_COUNTER: + onCounter = true; + case EXITEM_HEART_PIECE_BOWLING: + pthis->unk_17C = func_8002ED80; + pthis->timer = 65; + pthis->prizeRotateTimer = 35; + pthis->scale = 0.5f; + if (!onCounter) { + func_80078884(NA_SE_SY_PIECE_OF_HEART); + pthis->actionFunc = EnExItem_BowlPrize; + } else { + pthis->actionFunc = EnExItem_SetupBowlCounter; + pthis->actor.shape.yOffset = -10.0f; + } + break; + case EXITEM_BOMBCHUS_COUNTER: + onCounter = true; + case EXITEM_BOMBCHUS_BOWLING: + pthis->unk_17C = func_8002EBCC; + pthis->giDrawId = GID_BOMBCHU; + pthis->timer = 65; + pthis->prizeRotateTimer = 35; + pthis->scale = 0.5f; + if (!onCounter) { + pthis->actionFunc = EnExItem_BowlPrize; + } else { + pthis->actionFunc = EnExItem_SetupBowlCounter; + } + break; + case EXITEM_BOMBS_BOWLING: + case EXITEM_BOMBS_COUNTER: + pthis->unk_17C = func_8002EBCC; + pthis->giDrawId = GID_BOMB; + pthis->timer = 65; + pthis->prizeRotateTimer = 35; + pthis->scale = 0.5f; + pthis->unkFloat = 0.5f; + if (pthis->type == EXITEM_BOMBS_BOWLING) { + pthis->actionFunc = EnExItem_BowlPrize; + } else { + pthis->actionFunc = EnExItem_SetupBowlCounter; + pthis->actor.shape.yOffset = 10.0f; + } + break; + case EXITEM_PURPLE_RUPEE_BOWLING: + case EXITEM_PURPLE_RUPEE_COUNTER: + pthis->unk_17C = func_8002EBCC; + pthis->unk_180 = func_8002ED80; + pthis->giDrawId = GID_RUPEE_PURPLE; + pthis->timer = 65; + pthis->prizeRotateTimer = 35; + pthis->scale = 0.5f; + pthis->unkFloat = 0.5f; + if (pthis->type == EXITEM_PURPLE_RUPEE_BOWLING) { + pthis->actionFunc = EnExItem_BowlPrize; + } else { + pthis->actionFunc = EnExItem_SetupBowlCounter; + pthis->actor.shape.yOffset = 40.0f; + } + break; + case EXITEM_GREEN_RUPEE_CHEST: + case EXITEM_BLUE_RUPEE_CHEST: + case EXITEM_RED_RUPEE_CHEST: + case EXITEM_13: + case EXITEM_14: + pthis->unk_17C = func_8002EBCC; + pthis->unk_180 = func_8002ED80; + pthis->timer = 7; + pthis->scale = 0.5f; + pthis->unkFloat = 0.5f; + pthis->actor.velocity.y = 10.0f; + switch (pthis->type) { + case EXITEM_GREEN_RUPEE_CHEST: + pthis->giDrawId = GID_RUPEE_GREEN; + break; + case EXITEM_BLUE_RUPEE_CHEST: + pthis->giDrawId = GID_RUPEE_BLUE; + break; + case EXITEM_RED_RUPEE_CHEST: + pthis->giDrawId = GID_RUPEE_RED; + break; + case EXITEM_14: + pthis->giDrawId = GID_RUPEE_PURPLE; + break; + } + pthis->actionFunc = EnExItem_ExitChest; + break; + case EXITEM_MAGIC_FIRE: + case EXITEM_MAGIC_WIND: + case EXITEM_MAGIC_DARK: + pthis->scale = 0.35f; + pthis->actionFunc = EnExItem_FairyMagic; + break; + case EXITEM_BULLET_BAG: + pthis->unk_17C = func_8002EBCC; + pthis->giDrawId = GID_BULLET_BAG; + pthis->scale = 0.1f; + pthis->timer = 80; + pthis->prizeRotateTimer = 35; + pthis->actionFunc = EnExItem_TargetPrizeApproach; + break; + case EXITEM_SMALL_KEY_CHEST: + break; + } + } +} + +void EnExItem_BowlPrize(EnExItem* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 tmpf1; + f32 tmpf2; + f32 tmpf3; + f32 tmpf4; + f32 tmpf5; + f32 tmpf6; + f32 tmpf7; + f32 sp3C; + + if (!pthis->stopRotate) { + pthis->actor.shape.rot.y += 0x1000; + if ((pthis->prizeRotateTimer == 0) && ((pthis->actor.shape.rot.y & 0xFFFF) == 0x9000)) { + pthis->stopRotate++; + } + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, 0, 5, 0x1000, 0); + } + if (pthis->timer != 0) { + if (pthis->prizeRotateTimer != 0) { + sp3C = 250.0f; + if (pthis->type == EXITEM_BOMBCHUS_BOWLING) { + sp3C = 220.0f; + } + tmpf1 = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + tmpf2 = globalCtx->view.lookAt.y - globalCtx->view.eye.y; + tmpf3 = globalCtx->view.lookAt.z + sp3C - globalCtx->view.eye.z; + tmpf4 = sqrtf(SQ(tmpf1) + SQ(tmpf2) + SQ(tmpf3)); + + tmpf5 = (tmpf1 / tmpf4) * 5.0f; + tmpf6 = (tmpf2 / tmpf4) * 5.0f; + tmpf7 = (tmpf3 / tmpf4) * 5.0f; + + tmpf1 = globalCtx->view.eye.x + tmpf5 - pthis->actor.world.pos.x; + tmpf2 = globalCtx->view.eye.y + tmpf6 - pthis->actor.world.pos.y; + tmpf3 = globalCtx->view.eye.z + tmpf7 - pthis->actor.world.pos.z; + + pthis->actor.world.pos.x += (tmpf1 / tmpf4) * 5.0f; + pthis->actor.world.pos.y += (tmpf2 / tmpf4) * 5.0f; + pthis->actor.world.pos.z += (tmpf3 / tmpf4) * 5.0f; + } + } else { + // "parent" + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 母親ー? ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.parent); + // "Can it move?" + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 動いてねー? ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.parent->update); + if ((pthis->actor.parent != NULL) && (pthis->actor.parent->update != NULL)) { + ((EnBomBowlPit*)pthis->actor.parent)->exItemDone = 1; + // "It can't move!" + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ さぁきえるぞ! ☆☆☆☆☆ \n" VT_RST); + } + Actor_Kill(&pthis->actor); + } +} + +void EnExItem_SetupBowlCounter(EnExItem* pthis, GlobalContext* globalCtx) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = 0x4268; + pthis->actionFunc = EnExItem_BowlCounter; +} + +void EnExItem_BowlCounter(EnExItem* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.y += 0x800; + if (pthis->killItem) { + Actor_Kill(&pthis->actor); + } +} + +void EnExItem_ExitChest(EnExItem* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.y += 0x1000; + if (pthis->timer != 0) { + if (pthis->timer == 1) { + pthis->chestKillTimer = 20; + } + } else { + pthis->actor.velocity.y = 0.0f; + if (pthis->chestKillTimer == 0) { + Actor_Kill(&pthis->actor); + } + } + Actor_MoveForward(&pthis->actor); +} + +void EnExItem_FairyMagic(EnExItem* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.y += 0x800; +} + +void EnExItem_TargetPrizeApproach(EnExItem* pthis, GlobalContext* globalCtx) { + f32 tmpf1; + f32 tmpf2; + f32 tmpf3; + f32 tmpf4; + f32 tmpf5; + f32 tmpf6; + f32 tmpf7; + + Math_ApproachF(&pthis->scale, 0.8f, 0.1f, 0.02f); + if (!pthis->stopRotate) { + pthis->actor.shape.rot.y += 0x1000; + if ((pthis->prizeRotateTimer == 0) && ((pthis->actor.shape.rot.y & 0xFFFF) == 0x9000)) { + pthis->stopRotate++; + } + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, -0x4000, 5, 0x1000, 0); + } + + if (pthis->timer != 0) { + if (pthis->prizeRotateTimer != 0) { + tmpf1 = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + tmpf2 = globalCtx->view.lookAt.y - 10.0f - globalCtx->view.eye.y; + tmpf3 = globalCtx->view.lookAt.z + 10.0f - globalCtx->view.eye.z; + tmpf4 = sqrtf(SQ(tmpf1) + SQ(tmpf2) + SQ(tmpf3)); + + tmpf5 = (tmpf1 / tmpf4) * 5.0f; + tmpf6 = (tmpf2 / tmpf4) * 5.0f; + tmpf7 = (tmpf3 / tmpf4) * 5.0f; + + tmpf1 = globalCtx->view.eye.x + tmpf5 - pthis->actor.world.pos.x; + tmpf2 = globalCtx->view.eye.y - 10.0f + tmpf6 - pthis->actor.world.pos.y; + tmpf3 = globalCtx->view.eye.z + 10.0f + tmpf7 - pthis->actor.world.pos.z; + + pthis->actor.world.pos.x += (tmpf1 / tmpf4) * 5.0f; + pthis->actor.world.pos.y += (tmpf2 / tmpf4) * 5.0f; + pthis->actor.world.pos.z += (tmpf3 / tmpf4) * 5.0f; + } + } else { + s32 getItemId; + + pthis->actor.draw = NULL; + func_8002DF54(globalCtx, NULL, 7); + pthis->actor.parent = NULL; + if (CUR_UPG_VALUE(UPG_BULLET_BAG) == 1) { + getItemId = GI_BULLET_BAG_40; + } else { + getItemId = GI_BULLET_BAG_50; + } + func_8002F434(&pthis->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + pthis->actionFunc = EnExItem_TargetPrizeGive; + } +} + +void EnExItem_TargetPrizeGive(EnExItem* pthis, GlobalContext* globalCtx) { + s32 getItemId; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnExItem_TargetPrizeFinish; + } else { + getItemId = (CUR_UPG_VALUE(UPG_BULLET_BAG) == 2) ? GI_BULLET_BAG_50 : GI_BULLET_BAG_40; + + func_8002F434(&pthis->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + } +} + +void EnExItem_TargetPrizeFinish(EnExItem* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + // "Successful completion" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); + gSaveContext.itemGetInf[1] |= 0x2000; + Actor_Kill(&pthis->actor); + } +} + +void EnExItem_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnExItem* pthis = (EnExItem*)thisx; + + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->chestKillTimer != 0) { + pthis->chestKillTimer--; + } + if (pthis->prizeRotateTimer != 0) { + pthis->prizeRotateTimer--; + } + pthis->actionFunc(pthis, globalCtx); +} + +void EnExItem_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnExItem* pthis = (EnExItem*)thisx; + s32 magicType; + + Actor_SetScale(&pthis->actor, pthis->scale); + switch (pthis->type) { + case EXITEM_BOMB_BAG_BOWLING: + case EXITEM_BOMBCHUS_BOWLING: + case EXITEM_BOMBS_BOWLING: + case EXITEM_BOMB_BAG_COUNTER: + case EXITEM_BOMBCHUS_COUNTER: + case EXITEM_BOMBS_COUNTER: + case EXITEM_BULLET_BAG: + EnExItem_DrawItems(pthis, globalCtx); + break; + case EXITEM_HEART_PIECE_BOWLING: + case EXITEM_HEART_PIECE_COUNTER: + EnExItem_DrawHeartPiece(pthis, globalCtx); + break; + case EXITEM_PURPLE_RUPEE_BOWLING: + case EXITEM_PURPLE_RUPEE_COUNTER: + case EXITEM_GREEN_RUPEE_CHEST: + case EXITEM_BLUE_RUPEE_CHEST: + case EXITEM_RED_RUPEE_CHEST: + case EXITEM_13: + case EXITEM_14: + EnExItem_DrawRupee(pthis, globalCtx); + break; + case EXITEM_SMALL_KEY_CHEST: + EnExItem_DrawKey(pthis, globalCtx, 0); + break; + case EXITEM_MAGIC_FIRE: + case EXITEM_MAGIC_WIND: + case EXITEM_MAGIC_DARK: + magicType = pthis->type - EXITEM_MAGIC_FIRE; + EnExItem_DrawMagic(pthis, globalCtx, magicType); + break; + } +} + +void EnExItem_DrawItems(EnExItem* pthis, GlobalContext* globalCtx) { + if (pthis->unk_17C != NULL) { + pthis->unk_17C(&pthis->actor, globalCtx, 0); + } + if (pthis) {} + func_8002ED80(&pthis->actor, globalCtx, 0); + GetItem_Draw(globalCtx, pthis->giDrawId); +} + +void EnExItem_DrawHeartPiece(EnExItem* pthis, GlobalContext* globalCtx) { + func_8002ED80(&pthis->actor, globalCtx, 0); + GetItem_Draw(globalCtx, GID_HEART_PIECE); +} + +void EnExItem_DrawMagic(EnExItem* pthis, GlobalContext* globalCtx, s16 magicIndex) { + static s16 sgiDrawIds[] = { GID_DINS_FIRE, GID_FARORES_WIND, GID_NAYRUS_LOVE }; + + func_8002ED80(&pthis->actor, globalCtx, 0); + GetItem_Draw(globalCtx, sgiDrawIds[magicIndex]); +} + +void EnExItem_DrawKey(EnExItem* pthis, GlobalContext* globalCtx, s32 index) { + static void* keySegments[] = { gDropKeySmallTex }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_item.c", 880); + + func_8009460C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ex_item.c", 887), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(keySegments[index])); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_item.c", 893); +} + +void EnExItem_DrawRupee(EnExItem* pthis, GlobalContext* globalCtx) { + if (pthis->unk_17C != NULL) { + pthis->unk_17C(&pthis->actor, globalCtx, 0); + } + if (pthis->unk_180 != NULL) { + pthis->unk_180(&pthis->actor, globalCtx, 0); + } + GetItem_Draw(globalCtx, pthis->giDrawId); +} diff --git a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h index ca054dddf..c110baf28 100644 --- a/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h +++ b/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h @@ -6,7 +6,7 @@ struct EnExItem; -typedef void (*EnExItemActionFunc)(struct EnExItem* this, GlobalContext* globalCtx); +typedef void (*EnExItemActionFunc)(struct EnExItem* pthis, GlobalContext* globalCtx); typedef void (*EnExItemLightFunc)(Actor*, GlobalContext*, s32); typedef struct EnExItem { diff --git a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c deleted file mode 100644 index 8317e0ee7..000000000 --- a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c +++ /dev/null @@ -1,407 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_EX_RUPPY_Z_EN_EX_RUPPY_C -#include "actor_common.h" -#include "z_en_ex_ruppy.h" -#include "vt.h" -#include "../ovl_En_Diving_Game/z_en_diving_game.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnExRuppy_Init(Actor* thisx, GlobalContext* globalCtx); -void EnExRuppy_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnExRuppy_Update(Actor* thisx, GlobalContext* globalCtx); -void EnExRuppy_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnExRuppy_DropIntoWater(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_WaitToBlowUp(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_WaitAsCollectible(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_GalleryTarget(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_EnterWater(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_Sink(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_WaitInGame(EnExRuppy* this, GlobalContext* globalCtx); -void EnExRuppy_Kill(EnExRuppy* this, GlobalContext* globalCtx); - -static s16 sEnExRuppyCollectibleTypes[] = { - ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_ORANGE, ITEM00_RUPEE_PURPLE, -}; - -// Unused, as the function sets these directly -static s16 sRupeeValues[] = { - 1, 5, 20, 500, 50, -}; - -const ActorInit En_Ex_Ruppy_InitVars = { - ACTOR_EN_EX_RUPPY, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnExRuppy), - (ActorFunc)EnExRuppy_Init, - (ActorFunc)EnExRuppy_Destroy, - (ActorFunc)EnExRuppy_Update, - (ActorFunc)EnExRuppy_Draw, -}; - -void EnExRuppy_Init(Actor* thisx, GlobalContext* globalCtx) { - EnExRuppy* this = (EnExRuppy*)thisx; - EnDivingGame* divingGame; - f32 temp1; - f32 temp2; - s16 temp3; - - this->type = this->actor.params; - // "Index" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ インデックス ☆☆☆☆☆ %x\n" VT_RST, this->type); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - - switch (this->type) { - case 0: - this->unk_160 = 0.01f; - Actor_SetScale(&this->actor, this->unk_160); - this->actor.room = -1; - this->actor.gravity = 0.0f; - - // If you haven't won the diving game before, you will always get 5 rupees - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - this->rupeeValue = 5; - this->colorIdx = 1; - } else { - temp1 = 200.99f; - if (this->actor.parent != NULL) { - divingGame = (EnDivingGame*)this->actor.parent; - if (divingGame->actor.update != NULL) { - temp2 = divingGame->extraWinCount * 10.0f; - temp1 += temp2; - } - } - - temp3 = Rand_ZeroFloat(temp1); - if ((temp3 >= 0) && (temp3 < 40)) { - this->rupeeValue = 1; - this->colorIdx = 0; - } else if ((temp3 >= 40) && (temp3 < 170)) { - this->rupeeValue = 5; - this->colorIdx = 1; - } else if ((temp3 >= 170) && (temp3 < 190)) { - this->rupeeValue = 20; - this->colorIdx = 2; - } else if ((temp3 >= 190) && (temp3 < 200)) { - this->rupeeValue = 50; - this->colorIdx = 4; - } else { - this->unk_160 = 0.02f; - Actor_SetScale(&this->actor, this->unk_160); - this->rupeeValue = 500; - this->colorIdx = 3; - if (this->actor.parent != NULL) { - divingGame = (EnDivingGame*)this->actor.parent; - if (divingGame->actor.update != NULL) { - divingGame->extraWinCount = 0; - } - } - } - } - - this->actor.shape.shadowScale = 7.0f; - this->actor.shape.yOffset = 700.0f; - this->unk_15A = this->actor.world.rot.z; - this->actor.world.rot.z = 0; - this->timer = 30; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnExRuppy_DropIntoWater; - break; - - case 1: - case 2: // Giant pink ruppe that explodes when you touch it - if (this->type == 1) { - Actor_SetScale(&this->actor, 0.1f); - this->colorIdx = 4; - } else { - Actor_SetScale(thisx, 0.02f); - this->colorIdx = (s16)Rand_ZeroFloat(3.99f) + 1; - } - this->actor.gravity = -3.0f; - // "Wow Coin" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わーなーコイン ☆☆☆☆☆ \n" VT_RST); - this->actor.shape.shadowScale = 6.0f; - this->actor.shape.yOffset = 700.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnExRuppy_WaitToBlowUp; - break; - - case 3: // Spawned by the guard in Hyrule courtyard - Actor_SetScale(&this->actor, 0.02f); - this->colorIdx = 0; - switch ((s16)Rand_ZeroFloat(30.99f)) { - case 0: - this->colorIdx = 2; - break; - case 10: - case 20: - case 30: - this->colorIdx = 1; - break; - } - this->actor.gravity = -3.0f; - // "Normal rupee" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ノーマルルピー ☆☆☆☆☆ \n" VT_RST); - this->actor.shape.shadowScale = 6.0f; - this->actor.shape.yOffset = 700.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnExRuppy_WaitAsCollectible; - break; - - case 4: // Progress markers in the shooting gallery - this->actor.gravity = -3.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - Actor_SetScale(&this->actor, 0.01f); - this->actor.shape.shadowScale = 6.0f; - this->actor.shape.yOffset = -700.0f; - this->actionFunc = EnExRuppy_GalleryTarget; - break; - } -} - -void EnExRuppy_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnExRuppy_SpawnSparkles(EnExRuppy* this, GlobalContext* globalCtx, s16 numSparkles, s32 movementType) { - static Vec3f velocities[] = { { 0.0f, 0.1f, 0.0f }, { 0.0f, 0.0f, 0.0f } }; - static Vec3f accelerations[] = { { 0.0f, 0.01f, 0.0f }, { 0.0f, 0.0f, 0.0f } }; - Vec3f pos; - Vec3f velocity; - Vec3f accel; - Color_RGBA8 primColor; - Color_RGBA8 envColor; - s32 i; - s16 scale; - s16 life; - - if (numSparkles < 1) { - numSparkles = 1; - } - - primColor.r = 255; - primColor.g = 255; - primColor.b = 0; - envColor.r = 255; - envColor.g = 255; - envColor.b = 255; - velocity = velocities[movementType]; - accel = accelerations[movementType]; - scale = 3000; - life = 16; - - for (i = 0; i < numSparkles; i++) { - if (movementType == 1) { - accel.x = Rand_CenteredFloat(20.0f); - accel.z = Rand_CenteredFloat(20.0f); - scale = 5000; - life = 20; - } - pos.x = (Rand_ZeroOne() - 0.5f) * 10.0f + this->actor.world.pos.x; - pos.y = (Rand_ZeroOne() - 0.5f) * 10.0f + (this->actor.world.pos.y + this->unk_160 * 600.0f); - pos.z = (Rand_ZeroOne() - 0.5f) * 10.0f + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, scale, life); - } -} - -void EnExRuppy_DropIntoWater(EnExRuppy* this, GlobalContext* globalCtx) { - EnDivingGame* divingGame; - - this->actor.shape.rot.y += 0x7A8; - Math_ApproachF(&this->actor.gravity, -2.0f, 0.3f, 1.0f); - EnExRuppy_SpawnSparkles(this, globalCtx, 2, 0); - func_80078884(NA_SE_EV_RAINBOW_SHOWER - SFX_FLAG); - divingGame = (EnDivingGame*)this->actor.parent; - if ((divingGame != NULL) && (divingGame->actor.update != NULL) && - ((divingGame->unk_296 == 0) || (this->actor.bgCheckFlags & 0x20) || (this->timer == 0))) { - this->invisible = true; - this->actor.speedXZ = 0.0f; - this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - this->actor.gravity = 0.0f; - func_80078914(&this->actor.projectedPos, NA_SE_EV_BOMB_DROP_WATER); - this->actionFunc = EnExRuppy_EnterWater; - } -} - -void EnExRuppy_EnterWater(EnExRuppy* this, GlobalContext* globalCtx) { - EnDivingGame* divingGame = (EnDivingGame*)this->actor.parent; - f32 temp_f2; - - if ((divingGame != NULL) && (divingGame->actor.update != NULL) && (divingGame->unk_2A2 == 2)) { - this->invisible = false; - this->actor.world.pos.x = ((Rand_ZeroOne() - 0.5f) * 300.0f) + -260.0f; - this->actor.world.pos.y = ((Rand_ZeroOne() - 0.5f) * 200.0f) + 370.0f; - temp_f2 = this->unk_15A * -50.0f; - if (!(gSaveContext.eventChkInf[3] & 0x100)) { - temp_f2 += -500.0f; - this->actor.world.pos.z = ((Rand_ZeroOne() - 0.5f) * 80.0f) + temp_f2; - } else { - temp_f2 += -300.0f; - this->actor.world.pos.z = ((Rand_ZeroOne() - 0.5f) * 60.0f) + temp_f2; - } - this->actionFunc = EnExRuppy_Sink; - this->actor.gravity = -1.0f; - } -} - -void EnExRuppy_Sink(EnExRuppy* this, GlobalContext* globalCtx) { - EnDivingGame* divingGame; - Vec3f pos; - s32 pad; - - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f)) { - pos = this->actor.world.pos; - pos.y += this->actor.yDistToWater; - this->actor.velocity.y = -1.0f; - this->actor.gravity = -0.2f; - EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 800); - func_80078914(&this->actor.projectedPos, NA_SE_EV_BOMB_DROP_WATER); - this->actionFunc = EnExRuppy_WaitInGame; - } - divingGame = (EnDivingGame*)this->actor.parent; - if ((divingGame != NULL) && (divingGame->actor.update != NULL) && (divingGame->phase == ENDIVINGGAME_PHASE_ENDED)) { - this->timer = 20; - this->actionFunc = EnExRuppy_Kill; - } -} - -void EnExRuppy_WaitInGame(EnExRuppy* this, GlobalContext* globalCtx) { - EnDivingGame* divingGame; - Vec3f D_80A0B388 = { 0.0f, 0.1f, 0.0f }; - Vec3f D_80A0B394 = { 0.0f, 0.0f, 0.0f }; - f32 localConst = 30.0f; - - if (this->timer == 0) { - this->timer = 10; - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); - } - if (this->actor.parent != NULL) { - divingGame = (EnDivingGame*)this->actor.parent; - if (divingGame->actor.update != NULL) { - if (divingGame->phase == ENDIVINGGAME_PHASE_ENDED) { - this->timer = 20; - this->actionFunc = EnExRuppy_Kill; - if (1) {} - } else if (this->actor.xyzDistToPlayerSq < SQ(localConst)) { - Rupees_ChangeBy(this->rupeeValue); - func_80078884(NA_SE_SY_GET_RUPY); - divingGame->grabbedRupeesCounter++; - Actor_Kill(&this->actor); - } - } else { - Actor_Kill(&this->actor); - } - } -} - -void EnExRuppy_Kill(EnExRuppy* this, GlobalContext* globalCtx) { - this->invisible += 1; - this->invisible &= 1; // Net effect is this->invisible = !this->invisible; - if (this->timer == 0) { - Actor_Kill(&this->actor); - } -} - -typedef struct { - /* 0x000 */ Actor actor; - /* 0x14C */ char unk_14C[0x11A]; - /* 0x226 */ s16 unk_226; -} EnExRuppyParentActor; // Unclear what actor was intended to spawn this. - -void EnExRuppy_WaitToBlowUp(EnExRuppy* this, GlobalContext* globalCtx) { - EnExRuppyParentActor* parent; - Vec3f accel = { 0.0f, 0.1f, 0.0f }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - f32 distToBlowUp = 50.0f; - s16 explosionScale; - s16 explosionScaleStep; - - if (this->type == 2) { - distToBlowUp = 30.0f; - } - if (this->actor.xyzDistToPlayerSq < SQ(distToBlowUp)) { - parent = (EnExRuppyParentActor*)this->actor.parent; - if (parent != NULL) { - if (parent->actor.update != NULL) { - parent->unk_226 = 1; - } - } else { - // "That idiot! error" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ そ、そんなばかな!エラー!!!!! ☆☆☆☆☆ \n" VT_RST); - } - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ バカめ! ☆☆☆☆☆ \n" VT_RST); // "Stupid!" - explosionScale = 100; - explosionScaleStep = 30; - if (this->type == 2) { - explosionScale = 20; - explosionScaleStep = 6; - } - EffectSsBomb2_SpawnLayered(globalCtx, &this->actor.world.pos, &velocity, &accel, explosionScale, - explosionScaleStep); - func_8002F71C(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Actor_Kill(&this->actor); - } -} - -void EnExRuppy_WaitAsCollectible(EnExRuppy* this, GlobalContext* globalCtx) { - f32 localConst = 30.0f; - - if (this->actor.xyzDistToPlayerSq < SQ(localConst)) { - func_80078884(NA_SE_SY_GET_RUPY); - Item_DropCollectible(globalCtx, &this->actor.world.pos, (sEnExRuppyCollectibleTypes[this->colorIdx] | 0x8000)); - Actor_Kill(&this->actor); - } -} - -void EnExRuppy_GalleryTarget(EnExRuppy* this, GlobalContext* globalCtx) { - if (this->galleryFlag) { - Math_ApproachF(&this->actor.shape.yOffset, 700.0f, 0.5f, 200.0f); - } else { - Math_ApproachF(&this->actor.shape.yOffset, -700.0f, 0.5f, 200.0f); - } -} - -void EnExRuppy_Update(Actor* thisx, GlobalContext* globalCtx) { - EnExRuppy* this = (EnExRuppy*)thisx; - - this->actor.shape.rot.y += 1960; - this->actionFunc(this, globalCtx); - if (this->timer != 0) { - this->timer--; - } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1C); -} - -void EnExRuppy_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* rupeeTextures[] = { - gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeePinkTex, gRupeeOrangeTex, - }; - s32 pad; - EnExRuppy* this = (EnExRuppy*)thisx; - - if (!this->invisible) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_ruppy.c", 774); - - func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(thisx, globalCtx, 0); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ex_ruppy.c", 780), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(rupeeTextures[this->colorIdx])); - gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_ruppy.c", 784); - } -} diff --git a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.cpp b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.cpp new file mode 100644 index 000000000..64a0dd115 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.cpp @@ -0,0 +1,407 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_EX_RUPPY_Z_EN_EX_RUPPY_C +#include "actor_common.h" +#include "z_en_ex_ruppy.h" +#include "vt.h" +#include "../ovl_En_Diving_Game/z_en_diving_game.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnExRuppy_Init(Actor* thisx, GlobalContext* globalCtx); +void EnExRuppy_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnExRuppy_Update(Actor* thisx, GlobalContext* globalCtx); +void EnExRuppy_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnExRuppy_DropIntoWater(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_WaitToBlowUp(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_WaitAsCollectible(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_GalleryTarget(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_EnterWater(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_Sink(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_WaitInGame(EnExRuppy* pthis, GlobalContext* globalCtx); +void EnExRuppy_Kill(EnExRuppy* pthis, GlobalContext* globalCtx); + +static s16 sEnExRuppyCollectibleTypes[] = { + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_ORANGE, ITEM00_RUPEE_PURPLE, +}; + +// Unused, as the function sets these directly +static s16 sRupeeValues[] = { + 1, 5, 20, 500, 50, +}; + +ActorInit En_Ex_Ruppy_InitVars = { + ACTOR_EN_EX_RUPPY, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnExRuppy), + (ActorFunc)EnExRuppy_Init, + (ActorFunc)EnExRuppy_Destroy, + (ActorFunc)EnExRuppy_Update, + (ActorFunc)EnExRuppy_Draw, +}; + +void EnExRuppy_Init(Actor* thisx, GlobalContext* globalCtx) { + EnExRuppy* pthis = (EnExRuppy*)thisx; + EnDivingGame* divingGame; + f32 temp1; + f32 temp2; + s16 temp3; + + pthis->type = pthis->actor.params; + // "Index" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ インデックス ☆☆☆☆☆ %x\n" VT_RST, pthis->type); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + + switch (pthis->type) { + case 0: + pthis->unk_160 = 0.01f; + Actor_SetScale(&pthis->actor, pthis->unk_160); + pthis->actor.room = -1; + pthis->actor.gravity = 0.0f; + + // If you haven't won the diving game before, you will always get 5 rupees + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + pthis->rupeeValue = 5; + pthis->colorIdx = 1; + } else { + temp1 = 200.99f; + if (pthis->actor.parent != NULL) { + divingGame = (EnDivingGame*)pthis->actor.parent; + if (divingGame->actor.update != NULL) { + temp2 = divingGame->extraWinCount * 10.0f; + temp1 += temp2; + } + } + + temp3 = Rand_ZeroFloat(temp1); + if ((temp3 >= 0) && (temp3 < 40)) { + pthis->rupeeValue = 1; + pthis->colorIdx = 0; + } else if ((temp3 >= 40) && (temp3 < 170)) { + pthis->rupeeValue = 5; + pthis->colorIdx = 1; + } else if ((temp3 >= 170) && (temp3 < 190)) { + pthis->rupeeValue = 20; + pthis->colorIdx = 2; + } else if ((temp3 >= 190) && (temp3 < 200)) { + pthis->rupeeValue = 50; + pthis->colorIdx = 4; + } else { + pthis->unk_160 = 0.02f; + Actor_SetScale(&pthis->actor, pthis->unk_160); + pthis->rupeeValue = 500; + pthis->colorIdx = 3; + if (pthis->actor.parent != NULL) { + divingGame = (EnDivingGame*)pthis->actor.parent; + if (divingGame->actor.update != NULL) { + divingGame->extraWinCount = 0; + } + } + } + } + + pthis->actor.shape.shadowScale = 7.0f; + pthis->actor.shape.yOffset = 700.0f; + pthis->unk_15A = pthis->actor.world.rot.z; + pthis->actor.world.rot.z = 0; + pthis->timer = 30; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnExRuppy_DropIntoWater; + break; + + case 1: + case 2: // Giant pink ruppe that explodes when you touch it + if (pthis->type == 1) { + Actor_SetScale(&pthis->actor, 0.1f); + pthis->colorIdx = 4; + } else { + Actor_SetScale(thisx, 0.02f); + pthis->colorIdx = (s16)Rand_ZeroFloat(3.99f) + 1; + } + pthis->actor.gravity = -3.0f; + // "Wow Coin" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わーなーコイン ☆☆☆☆☆ \n" VT_RST); + pthis->actor.shape.shadowScale = 6.0f; + pthis->actor.shape.yOffset = 700.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnExRuppy_WaitToBlowUp; + break; + + case 3: // Spawned by the guard in Hyrule courtyard + Actor_SetScale(&pthis->actor, 0.02f); + pthis->colorIdx = 0; + switch ((s16)Rand_ZeroFloat(30.99f)) { + case 0: + pthis->colorIdx = 2; + break; + case 10: + case 20: + case 30: + pthis->colorIdx = 1; + break; + } + pthis->actor.gravity = -3.0f; + // "Normal rupee" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ノーマルルピー ☆☆☆☆☆ \n" VT_RST); + pthis->actor.shape.shadowScale = 6.0f; + pthis->actor.shape.yOffset = 700.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnExRuppy_WaitAsCollectible; + break; + + case 4: // Progress markers in the shooting gallery + pthis->actor.gravity = -3.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.shape.shadowScale = 6.0f; + pthis->actor.shape.yOffset = -700.0f; + pthis->actionFunc = EnExRuppy_GalleryTarget; + break; + } +} + +void EnExRuppy_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnExRuppy_SpawnSparkles(EnExRuppy* pthis, GlobalContext* globalCtx, s16 numSparkles, s32 movementType) { + static Vec3f velocities[] = { { 0.0f, 0.1f, 0.0f }, { 0.0f, 0.0f, 0.0f } }; + static Vec3f accelerations[] = { { 0.0f, 0.01f, 0.0f }, { 0.0f, 0.0f, 0.0f } }; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + s32 i; + s16 scale; + s16 life; + + if (numSparkles < 1) { + numSparkles = 1; + } + + primColor.r = 255; + primColor.g = 255; + primColor.b = 0; + envColor.r = 255; + envColor.g = 255; + envColor.b = 255; + velocity = velocities[movementType]; + accel = accelerations[movementType]; + scale = 3000; + life = 16; + + for (i = 0; i < numSparkles; i++) { + if (movementType == 1) { + accel.x = Rand_CenteredFloat(20.0f); + accel.z = Rand_CenteredFloat(20.0f); + scale = 5000; + life = 20; + } + pos.x = (Rand_ZeroOne() - 0.5f) * 10.0f + pthis->actor.world.pos.x; + pos.y = (Rand_ZeroOne() - 0.5f) * 10.0f + (pthis->actor.world.pos.y + pthis->unk_160 * 600.0f); + pos.z = (Rand_ZeroOne() - 0.5f) * 10.0f + pthis->actor.world.pos.z; + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, scale, life); + } +} + +void EnExRuppy_DropIntoWater(EnExRuppy* pthis, GlobalContext* globalCtx) { + EnDivingGame* divingGame; + + pthis->actor.shape.rot.y += 0x7A8; + Math_ApproachF(&pthis->actor.gravity, -2.0f, 0.3f, 1.0f); + EnExRuppy_SpawnSparkles(pthis, globalCtx, 2, 0); + func_80078884(NA_SE_EV_RAINBOW_SHOWER - SFX_FLAG); + divingGame = (EnDivingGame*)pthis->actor.parent; + if ((divingGame != NULL) && (divingGame->actor.update != NULL) && + ((divingGame->unk_296 == 0) || (pthis->actor.bgCheckFlags & 0x20) || (pthis->timer == 0))) { + pthis->invisible = true; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.x = pthis->actor.velocity.y = pthis->actor.velocity.z = 0.0f; + pthis->actor.gravity = 0.0f; + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_BOMB_DROP_WATER); + pthis->actionFunc = EnExRuppy_EnterWater; + } +} + +void EnExRuppy_EnterWater(EnExRuppy* pthis, GlobalContext* globalCtx) { + EnDivingGame* divingGame = (EnDivingGame*)pthis->actor.parent; + f32 temp_f2; + + if ((divingGame != NULL) && (divingGame->actor.update != NULL) && (divingGame->unk_2A2 == 2)) { + pthis->invisible = false; + pthis->actor.world.pos.x = ((Rand_ZeroOne() - 0.5f) * 300.0f) + -260.0f; + pthis->actor.world.pos.y = ((Rand_ZeroOne() - 0.5f) * 200.0f) + 370.0f; + temp_f2 = pthis->unk_15A * -50.0f; + if (!(gSaveContext.eventChkInf[3] & 0x100)) { + temp_f2 += -500.0f; + pthis->actor.world.pos.z = ((Rand_ZeroOne() - 0.5f) * 80.0f) + temp_f2; + } else { + temp_f2 += -300.0f; + pthis->actor.world.pos.z = ((Rand_ZeroOne() - 0.5f) * 60.0f) + temp_f2; + } + pthis->actionFunc = EnExRuppy_Sink; + pthis->actor.gravity = -1.0f; + } +} + +void EnExRuppy_Sink(EnExRuppy* pthis, GlobalContext* globalCtx) { + EnDivingGame* divingGame; + Vec3f pos; + s32 pad; + + if ((pthis->actor.bgCheckFlags & 0x20) && (pthis->actor.yDistToWater > 15.0f)) { + pos = pthis->actor.world.pos; + pos.y += pthis->actor.yDistToWater; + pthis->actor.velocity.y = -1.0f; + pthis->actor.gravity = -0.2f; + EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 800); + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_BOMB_DROP_WATER); + pthis->actionFunc = EnExRuppy_WaitInGame; + } + divingGame = (EnDivingGame*)pthis->actor.parent; + if ((divingGame != NULL) && (divingGame->actor.update != NULL) && (divingGame->phase == ENDIVINGGAME_PHASE_ENDED)) { + pthis->timer = 20; + pthis->actionFunc = EnExRuppy_Kill; + } +} + +void EnExRuppy_WaitInGame(EnExRuppy* pthis, GlobalContext* globalCtx) { + EnDivingGame* divingGame; + Vec3f D_80A0B388 = { 0.0f, 0.1f, 0.0f }; + Vec3f D_80A0B394 = { 0.0f, 0.0f, 0.0f }; + f32 localConst = 30.0f; + + if (pthis->timer == 0) { + pthis->timer = 10; + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + if (pthis->actor.parent != NULL) { + divingGame = (EnDivingGame*)pthis->actor.parent; + if (divingGame->actor.update != NULL) { + if (divingGame->phase == ENDIVINGGAME_PHASE_ENDED) { + pthis->timer = 20; + pthis->actionFunc = EnExRuppy_Kill; + if (1) {} + } else if (pthis->actor.xyzDistToPlayerSq < SQ(localConst)) { + Rupees_ChangeBy(pthis->rupeeValue); + func_80078884(NA_SE_SY_GET_RUPY); + divingGame->grabbedRupeesCounter++; + Actor_Kill(&pthis->actor); + } + } else { + Actor_Kill(&pthis->actor); + } + } +} + +void EnExRuppy_Kill(EnExRuppy* pthis, GlobalContext* globalCtx) { + pthis->invisible += 1; + pthis->invisible &= 1; // Net effect is pthis->invisible = !pthis->invisible; + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); + } +} + +typedef struct { + /* 0x000 */ Actor actor; + /* 0x14C */ char unk_14C[0x11A]; + /* 0x226 */ s16 unk_226; +} EnExRuppyParentActor; // Unclear what actor was intended to spawn pthis. + +void EnExRuppy_WaitToBlowUp(EnExRuppy* pthis, GlobalContext* globalCtx) { + EnExRuppyParentActor* parent; + Vec3f accel = { 0.0f, 0.1f, 0.0f }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + f32 distToBlowUp = 50.0f; + s16 explosionScale; + s16 explosionScaleStep; + + if (pthis->type == 2) { + distToBlowUp = 30.0f; + } + if (pthis->actor.xyzDistToPlayerSq < SQ(distToBlowUp)) { + parent = (EnExRuppyParentActor*)pthis->actor.parent; + if (parent != NULL) { + if (parent->actor.update != NULL) { + parent->unk_226 = 1; + } + } else { + // "That idiot! error" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ そ、そんなばかな!エラー!!!!! ☆☆☆☆☆ \n" VT_RST); + } + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ バカめ! ☆☆☆☆☆ \n" VT_RST); // "Stupid!" + explosionScale = 100; + explosionScaleStep = 30; + if (pthis->type == 2) { + explosionScale = 20; + explosionScaleStep = 6; + } + EffectSsBomb2_SpawnLayered(globalCtx, &pthis->actor.world.pos, &velocity, &accel, explosionScale, + explosionScaleStep); + func_8002F71C(globalCtx, &pthis->actor, 2.0f, pthis->actor.yawTowardsPlayer, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_Kill(&pthis->actor); + } +} + +void EnExRuppy_WaitAsCollectible(EnExRuppy* pthis, GlobalContext* globalCtx) { + f32 localConst = 30.0f; + + if (pthis->actor.xyzDistToPlayerSq < SQ(localConst)) { + func_80078884(NA_SE_SY_GET_RUPY); + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, (sEnExRuppyCollectibleTypes[pthis->colorIdx] | 0x8000)); + Actor_Kill(&pthis->actor); + } +} + +void EnExRuppy_GalleryTarget(EnExRuppy* pthis, GlobalContext* globalCtx) { + if (pthis->galleryFlag) { + Math_ApproachF(&pthis->actor.shape.yOffset, 700.0f, 0.5f, 200.0f); + } else { + Math_ApproachF(&pthis->actor.shape.yOffset, -700.0f, 0.5f, 200.0f); + } +} + +void EnExRuppy_Update(Actor* thisx, GlobalContext* globalCtx) { + EnExRuppy* pthis = (EnExRuppy*)thisx; + + pthis->actor.shape.rot.y += 1960; + pthis->actionFunc(pthis, globalCtx); + if (pthis->timer != 0) { + pthis->timer--; + } + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 50.0f, 0x1C); +} + +void EnExRuppy_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* rupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeePinkTex, gRupeeOrangeTex, + }; + s32 pad; + EnExRuppy* pthis = (EnExRuppy*)thisx; + + if (!pthis->invisible) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_ruppy.c", 774); + + func_80093D18(globalCtx->state.gfxCtx); + func_8002EBCC(thisx, globalCtx, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ex_ruppy.c", 780), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(rupeeTextures[pthis->colorIdx])); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ex_ruppy.c", 784); + } +} diff --git a/src/overlays/actors/ovl_En_Fd/z_en_fd.c b/src/overlays/actors/ovl_En_Fd/z_en_fd.cpp similarity index 51% rename from src/overlays/actors/ovl_En_Fd/z_en_fd.c rename to src/overlays/actors/ovl_En_Fd/z_en_fd.cpp index 901a9766e..a8399c8d1 100644 --- a/src/overlays/actors/ovl_En_Fd/z_en_fd.c +++ b/src/overlays/actors/ovl_En_Fd/z_en_fd.cpp @@ -30,20 +30,20 @@ void EnFd_Init(Actor* thisx, GlobalContext* globalCtx); void EnFd_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFd_Update(Actor* thisx, GlobalContext* globalCtx); void EnFd_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFd_Run(EnFd* this, GlobalContext* globalCtx); -void EnFd_SpinAndSpawnFire(EnFd* this, GlobalContext* globalCtx); -void EnFd_Reappear(EnFd* this, GlobalContext* globalCtx); -void EnFd_SpinAndGrow(EnFd* this, GlobalContext* globalCtx); -void EnFd_JumpToGround(EnFd* this, GlobalContext* globalCtx); -void EnFd_WaitForCore(EnFd* this, GlobalContext* globalCtx); -void EnFd_UpdateFlames(EnFd* this); -void EnFd_UpdateDots(EnFd* this); +void EnFd_Run(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_SpinAndSpawnFire(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_Reappear(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_SpinAndGrow(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_JumpToGround(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_WaitForCore(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_UpdateFlames(EnFd* pthis); +void EnFd_UpdateDots(EnFd* pthis); void EnFd_AddEffect(EnFd*, u8, Vec3f*, Vec3f*, Vec3f*, u8, f32, f32); -void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx); -void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx); -void EnFd_Land(EnFd* this, GlobalContext* globalCtx); +void EnFd_DrawDots(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_DrawFlames(EnFd* pthis, GlobalContext* globalCtx); +void EnFd_Land(EnFd* pthis, GlobalContext* globalCtx); -const ActorInit En_Fd_InitVars = { +ActorInit En_Fd_InitVars = { ACTOR_EN_FD, ACTORCAT_ENEMY, FLAGS, @@ -213,135 +213,135 @@ static struct_80034EC0_Entry sAnimations[] = { { &gFlareDancerTwirlAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -10.0f }, }; -s32 EnFd_SpawnCore(EnFd* this, GlobalContext* globalCtx) { - if (this->invincibilityTimer != 0) { +s32 EnFd_SpawnCore(EnFd* pthis, GlobalContext* globalCtx) { + if (pthis->invincibilityTimer != 0) { return false; } - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FW, this->corePos.x, this->corePos.y, - this->corePos.z, 0, this->actor.shape.rot.y, 0, this->runDir) == NULL) { + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FW, pthis->corePos.x, pthis->corePos.y, + pthis->corePos.z, 0, pthis->actor.shape.rot.y, 0, pthis->runDir) == NULL) { return false; } - this->actor.child->colChkInfo.health = this->actor.colChkInfo.health % 8; + pthis->actor.child->colChkInfo.health = pthis->actor.colChkInfo.health % 8; - if (this->actor.child->colChkInfo.health == 0) { - this->actor.child->colChkInfo.health = 8; + if (pthis->actor.child->colChkInfo.health == 0) { + pthis->actor.child->colChkInfo.health = 8; } - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { - func_8002DE04(globalCtx, &this->actor, this->actor.child); + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_13)) { + func_8002DE04(globalCtx, &pthis->actor, pthis->actor.child); } - this->coreActive = true; + pthis->coreActive = true; return true; } -void EnFd_SpawnChildFire(EnFd* this, GlobalContext* globalCtx, s16 fireCnt, s16 color) { +void EnFd_SpawnChildFire(EnFd* pthis, GlobalContext* globalCtx, s16 fireCnt, s16 color) { s32 i; for (i = 0; i < fireCnt; i++) { - s16 angle = (s16)((((i * 360.0f) / fireCnt) * (0x10000 / 360.0f))) + this->actor.yawTowardsPlayer; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FD_FIRE, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, angle, 0, (color << 0xF) | i); + s16 angle = (s16)((((i * 360.0f) / fireCnt) * (0x10000 / 360.0f))) + pthis->actor.yawTowardsPlayer; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FD_FIRE, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, angle, 0, (color << 0xF) | i); } } -void EnFd_SpawnDot(EnFd* this, GlobalContext* globalCtx) { +void EnFd_SpawnDot(EnFd* pthis, GlobalContext* globalCtx) { Vec3f pos = { 0.0f, 0.0f, 0.0f }; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.0f, 0.0f }; - if (this->actionFunc == EnFd_Run || this->actionFunc == EnFd_SpinAndSpawnFire) { - pos.x = this->actor.world.pos.x; - pos.y = this->actor.floorHeight + 4.0f; - pos.z = this->actor.world.pos.z; + if (pthis->actionFunc == EnFd_Run || pthis->actionFunc == EnFd_SpinAndSpawnFire) { + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.floorHeight + 4.0f; + pos.z = pthis->actor.world.pos.z; accel.x = (Rand_ZeroOne() - 0.5f) * 2.0f; accel.y = ((Rand_ZeroOne() - 0.5f) * 0.2f) + 0.3f; accel.z = (Rand_ZeroOne() - 0.5f) * 2.0f; - EnFd_AddEffect(this, FD_EFFECT_FLAME, &pos, &velocity, &accel, 8, 0.6f, 0.2f); + EnFd_AddEffect(pthis, FD_EFFECT_FLAME, &pos, &velocity, &accel, 8, 0.6f, 0.2f); } } /** * Checks to see if the hammer effect is active, and if it should be applied */ -s32 EnFd_CheckHammer(EnFd* this, GlobalContext* globalCtx) { - if (this->actionFunc == EnFd_Reappear || this->actionFunc == EnFd_SpinAndGrow || - this->actionFunc == EnFd_JumpToGround || this->actionFunc == EnFd_WaitForCore) { +s32 EnFd_CheckHammer(EnFd* pthis, GlobalContext* globalCtx) { + if (pthis->actionFunc == EnFd_Reappear || pthis->actionFunc == EnFd_SpinAndGrow || + pthis->actionFunc == EnFd_JumpToGround || pthis->actionFunc == EnFd_WaitForCore) { return false; - } else if (globalCtx->actorCtx.unk_02 != 0 && this->actor.xzDistToPlayer < 300.0f && - this->actor.yDistToPlayer < 60.0f) { + } else if (globalCtx->actorCtx.unk_02 != 0 && pthis->actor.xzDistToPlayer < 300.0f && + pthis->actor.yDistToPlayer < 60.0f) { return true; } else { return false; } } -s32 EnFd_ColliderCheck(EnFd* this, GlobalContext* globalCtx) { +s32 EnFd_ColliderCheck(EnFd* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); ColliderInfo* info; - if (this->collider.base.acFlags & AC_HIT || EnFd_CheckHammer(this, globalCtx)) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->invincibilityTimer != 0) { + if (pthis->collider.base.acFlags & AC_HIT || EnFd_CheckHammer(pthis, globalCtx)) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (pthis->invincibilityTimer != 0) { return false; } - info = &this->collider.elements[0].info; + info = &pthis->collider.elements[0].info; if (info->acHitInfo != NULL && (info->acHitInfo->toucher.dmgFlags & 0x80)) { return false; } - if (!EnFd_SpawnCore(this, globalCtx)) { + if (!EnFd_SpawnCore(pthis, globalCtx)) { return false; } - this->invincibilityTimer = 30; - this->actor.flags &= ~ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_DAMAGE); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + pthis->invincibilityTimer = 30; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_DAMAGE); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); return true; - } else if (DECR(this->attackTimer) == 0 && this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - if (this->invincibilityTimer != 0) { + } else if (DECR(pthis->attackTimer) == 0 && pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + if (pthis->invincibilityTimer != 0) { return false; } - if (this->collider.base.atFlags & AT_BOUNCED) { + if (pthis->collider.base.atFlags & AT_BOUNCED) { return false; } - this->attackTimer = 30; + pthis->attackTimer = 30; Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - func_8002F71C(globalCtx, &this->actor, this->actor.speedXZ + 2.0f, this->actor.yawTowardsPlayer, 6.0f); + func_8002F71C(globalCtx, &pthis->actor, pthis->actor.speedXZ + 2.0f, pthis->actor.yawTowardsPlayer, 6.0f); } return false; } /** - * Determines if `actor` is within an acceptable range for `this` to be able to "see" `actor` - * `actor` must be within 400 units of `this`, `actor` must be within +/- 40 degrees facing angle - * towards `actor`, and there must not be a collision poly between `this` and `actor` + * Determines if `actor` is within an acceptable range for `pthis` to be able to "see" `actor` + * `actor` must be within 400 units of `pthis`, `actor` must be within +/- 40 degrees facing angle + * towards `actor`, and there must not be a collision poly between `pthis` and `actor` */ -s32 EnFd_CanSeeActor(EnFd* this, Actor* actor, GlobalContext* globalCtx) { +s32 EnFd_CanSeeActor(EnFd* pthis, Actor* actor, GlobalContext* globalCtx) { CollisionPoly* colPoly; s32 bgId; Vec3f colPoint; s16 angle; s32 pad; - // Check to see if `actor` is within 400 units of `this` - if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &actor->world.pos) > 400.0f) { + // Check to see if `actor` is within 400 units of `pthis` + if (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &actor->world.pos) > 400.0f) { return false; } - // Check to see if the angle between this facing angle and `actor` is withing ~40 degrees - angle = (f32)Math_Vec3f_Yaw(&this->actor.world.pos, &actor->world.pos) - this->actor.shape.rot.y; + // Check to see if the angle between pthis facing angle and `actor` is withing ~40 degrees + angle = (f32)Math_Vec3f_Yaw(&pthis->actor.world.pos, &actor->world.pos) - pthis->actor.shape.rot.y; if (ABS(angle) > 0x1C70) { return false; } - // check to see if the line between `this` and `actor` does not intersect a collision poly - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &actor->world.pos, &colPoint, &colPoly, + // check to see if the line between `pthis` and `actor` does not intersect a collision poly + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &actor->world.pos, &colPoint, &colPoly, true, false, false, true, &bgId)) { return false; } @@ -349,7 +349,7 @@ s32 EnFd_CanSeeActor(EnFd* this, Actor* actor, GlobalContext* globalCtx) { return true; } -Actor* EnFd_FindBomb(EnFd* this, GlobalContext* globalCtx) { +Actor* EnFd_FindBomb(EnFd* pthis, GlobalContext* globalCtx) { Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; while (actor != NULL) { @@ -363,7 +363,7 @@ Actor* EnFd_FindBomb(EnFd* this, GlobalContext* globalCtx) { continue; } - if (EnFd_CanSeeActor(this, actor, globalCtx) != 1) { + if (EnFd_CanSeeActor(pthis, actor, globalCtx) != 1) { actor = actor->next; continue; } @@ -373,20 +373,20 @@ Actor* EnFd_FindBomb(EnFd* this, GlobalContext* globalCtx) { return NULL; } -Actor* EnFd_FindPotentialTheat(EnFd* this, GlobalContext* globalCtx) { +Actor* EnFd_FindPotentialTheat(EnFd* pthis, GlobalContext* globalCtx) { Player* player; - Actor* bomb = EnFd_FindBomb(this, globalCtx); + Actor* bomb = EnFd_FindBomb(pthis, globalCtx); if (bomb != NULL) { return bomb; } - if (this->attackTimer != 0) { + if (pthis->attackTimer != 0) { return NULL; } player = GET_PLAYER(globalCtx); - if (!EnFd_CanSeeActor(this, &player->actor, globalCtx)) { + if (!EnFd_CanSeeActor(pthis, &player->actor, globalCtx)) { return NULL; } @@ -394,23 +394,23 @@ Actor* EnFd_FindPotentialTheat(EnFd* this, GlobalContext* globalCtx) { } /** - * Creates a delta in `dst` for the position from `this`'s current position to the next - * position in a circle formed by `radius` with center at `this`'s initial position. + * Creates a delta in `dst` for the position from `pthis`'s current position to the next + * position in a circle formed by `radius` with center at `pthis`'s initial position. */ -Vec3f* EnFd_GetPosAdjAroundCircle(Vec3f* dst, EnFd* this, f32 radius, s16 dir) { +Vec3f* EnFd_GetPosAdjAroundCircle(Vec3f* dst, EnFd* pthis, f32 radius, s16 dir) { s16 angle; Vec3f newPos; - angle = Math_Vec3f_Yaw(&this->actor.home.pos, &this->actor.world.pos) + (dir * 0x1554); // ~30 degrees - newPos.x = (Math_SinS(angle) * radius) + this->actor.home.pos.x; - newPos.z = (Math_CosS(angle) * radius) + this->actor.home.pos.z; - newPos.x -= this->actor.world.pos.x; - newPos.z -= this->actor.world.pos.z; + angle = Math_Vec3f_Yaw(&pthis->actor.home.pos, &pthis->actor.world.pos) + (dir * 0x1554); // ~30 degrees + newPos.x = (Math_SinS(angle) * radius) + pthis->actor.home.pos.x; + newPos.z = (Math_CosS(angle) * radius) + pthis->actor.home.pos.z; + newPos.x -= pthis->actor.world.pos.x; + newPos.z -= pthis->actor.world.pos.z; *dst = newPos; return dst; } -s32 EnFd_ShouldStopRunning(EnFd* this, GlobalContext* globalCtx, f32 radius, s16* runDir) { +s32 EnFd_ShouldStopRunning(EnFd* pthis, GlobalContext* globalCtx, f32 radius, s16* runDir) { CollisionPoly* poly; s32 bgId; Vec3f colPoint; @@ -418,19 +418,19 @@ s32 EnFd_ShouldStopRunning(EnFd* this, GlobalContext* globalCtx, f32 radius, s16 // Check to see if the next position on the rotation around the circle // will result in a background collision - EnFd_GetPosAdjAroundCircle(&pos, this, radius, *runDir); + EnFd_GetPosAdjAroundCircle(&pos, pthis, radius, *runDir); - pos.x += this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z += this->actor.world.pos.z; + pos.x += pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z += pthis->actor.world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &pos, &colPoint, &poly, true, false, false, + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &pos, &colPoint, &poly, true, false, false, true, &bgId)) { *runDir = -*runDir; return true; } - if (this->circlesToComplete != 0 || DECR(this->spinTimer) != 0) { + if (pthis->circlesToComplete != 0 || DECR(pthis->spinTimer) != 0) { return false; } @@ -440,140 +440,140 @@ s32 EnFd_ShouldStopRunning(EnFd* this, GlobalContext* globalCtx, f32 radius, s16 return true; } -void EnFd_Fade(EnFd* this, GlobalContext* globalCtx) { - if (this->invincibilityTimer != 0) { - Math_SmoothStepToF(&this->fadeAlpha, 0.0f, 0.3f, 10.0f, 0.0f); - this->actor.shape.shadowAlpha = this->fadeAlpha; - if (!(this->fadeAlpha >= 0.9f)) { - this->invincibilityTimer = 0; - this->spinTimer = 0; - this->actionFunc = EnFd_WaitForCore; - this->actor.speedXZ = 0.0f; +void EnFd_Fade(EnFd* pthis, GlobalContext* globalCtx) { + if (pthis->invincibilityTimer != 0) { + Math_SmoothStepToF(&pthis->fadeAlpha, 0.0f, 0.3f, 10.0f, 0.0f); + pthis->actor.shape.shadowAlpha = pthis->fadeAlpha; + if (!(pthis->fadeAlpha >= 0.9f)) { + pthis->invincibilityTimer = 0; + pthis->spinTimer = 0; + pthis->actionFunc = EnFd_WaitForCore; + pthis->actor.speedXZ = 0.0f; } } } void EnFd_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFd* this = (EnFd*)thisx; + EnFd* pthis = (EnFd*)thisx; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFlareDancerSkel, NULL, this->jointTable, this->morphTable, 27); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 32.0f); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colSphs); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xF), &sColChkInit); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.flags |= ACTOR_FLAG_24; - Actor_SetScale(&this->actor, 0.01f); - this->firstUpdateFlag = true; - this->actor.gravity = -1.0f; - this->runDir = Rand_ZeroOne() < 0.5f ? -1 : 1; - this->actor.naviEnemyId = 0x22; - this->actionFunc = EnFd_Reappear; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFlareDancerSkel, NULL, pthis->jointTable, pthis->morphTable, 27); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 32.0f); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colSphs); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(0xF), &sColChkInit); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags |= ACTOR_FLAG_24; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->firstUpdateFlag = true; + pthis->actor.gravity = -1.0f; + pthis->runDir = Rand_ZeroOne() < 0.5f ? -1 : 1; + pthis->actor.naviEnemyId = 0x22; + pthis->actionFunc = EnFd_Reappear; } void EnFd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFd* this = (EnFd*)thisx; + EnFd* pthis = (EnFd*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void EnFd_Reappear(EnFd* this, GlobalContext* globalCtx) { - this->actor.world.pos = this->actor.home.pos; - this->actor.params = 0; - this->actor.shape.shadowAlpha = 0xFF; - this->coreActive = false; - this->actor.scale.y = 0.0f; - this->fadeAlpha = 255.0f; - func_80034EC0(&this->skelAnime, sAnimations, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_LAUGH); - this->actionFunc = EnFd_SpinAndGrow; +void EnFd_Reappear(EnFd* pthis, GlobalContext* globalCtx) { + pthis->actor.world.pos = pthis->actor.home.pos; + pthis->actor.params = 0; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->coreActive = false; + pthis->actor.scale.y = 0.0f; + pthis->fadeAlpha = 255.0f; + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_LAUGH); + pthis->actionFunc = EnFd_SpinAndGrow; } -void EnFd_SpinAndGrow(EnFd* this, GlobalContext* globalCtx) { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->actor.velocity.y = 6.0f; - this->actor.scale.y = 0.01f; - this->actor.world.rot.y ^= 0x8000; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.speedXZ = 8.0f; - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->actionFunc = EnFd_JumpToGround; +void EnFd_SpinAndGrow(EnFd* pthis, GlobalContext* globalCtx) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + pthis->actor.velocity.y = 6.0f; + pthis->actor.scale.y = 0.01f; + pthis->actor.world.rot.y ^= 0x8000; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.speedXZ = 8.0f; + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->actionFunc = EnFd_JumpToGround; } else { - this->actor.scale.y = this->skelAnime.curFrame * (0.01f / this->skelAnime.animLength); - this->actor.shape.rot.y += 0x2000; - this->actor.world.rot.y = this->actor.shape.rot.y; + pthis->actor.scale.y = pthis->skelAnime.curFrame * (0.01f / pthis->skelAnime.animLength); + pthis->actor.shape.rot.y += 0x2000; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; } } -void EnFd_JumpToGround(EnFd* this, GlobalContext* globalCtx) { - if ((this->actor.bgCheckFlags & 1) && !(this->actor.velocity.y > 0.0f)) { - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80034EC0(&this->skelAnime, sAnimations, 2); - this->actionFunc = EnFd_Land; +void EnFd_JumpToGround(EnFd* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.bgCheckFlags & 1) && !(pthis->actor.velocity.y > 0.0f)) { + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + pthis->actionFunc = EnFd_Land; } } -void EnFd_Land(EnFd* this, GlobalContext* globalCtx) { +void EnFd_Land(EnFd* pthis, GlobalContext* globalCtx) { Vec3f adjPos; - Math_SmoothStepToF(&this->skelAnime.playSpeed, 1.0f, 0.1f, 1.0f, 0.0f); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->spinTimer = Rand_S16Offset(60, 90); - this->runRadius = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos); - EnFd_GetPosAdjAroundCircle(&adjPos, this, this->runRadius, this->runDir); - this->actor.world.rot.y = Math_FAtan2F(adjPos.x, adjPos.z) * (0x8000 / M_PI); - func_80034EC0(&this->skelAnime, sAnimations, 4); - this->actionFunc = EnFd_SpinAndSpawnFire; + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 1.0f, 0.1f, 1.0f, 0.0f); + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + pthis->spinTimer = Rand_S16Offset(60, 90); + pthis->runRadius = Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->actor.home.pos); + EnFd_GetPosAdjAroundCircle(&adjPos, pthis, pthis->runRadius, pthis->runDir); + pthis->actor.world.rot.y = Math_FAtan2F(adjPos.x, adjPos.z) * (0x8000 / M_PI); + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + pthis->actionFunc = EnFd_SpinAndSpawnFire; } } -void EnFd_SpinAndSpawnFire(EnFd* this, GlobalContext* globalCtx) { +void EnFd_SpinAndSpawnFire(EnFd* pthis, GlobalContext* globalCtx) { f32 deceleration; f32 tgtSpeed; f32 rotSpeed; - if ((this->spinTimer < 31) && (this->invincibilityTimer == 0)) { - func_8002F974(&this->actor, NA_SE_EN_FLAME_FIRE_ATTACK - SFX_FLAG); + if ((pthis->spinTimer < 31) && (pthis->invincibilityTimer == 0)) { + func_8002F974(&pthis->actor, NA_SE_EN_FLAME_FIRE_ATTACK - SFX_FLAG); } else { - func_8002F974(&this->actor, NA_SE_EN_FLAME_ROLL - SFX_FLAG); + func_8002F974(&pthis->actor, NA_SE_EN_FLAME_ROLL - SFX_FLAG); } - if (DECR(this->spinTimer) != 0) { - this->actor.shape.rot.y += (this->runDir * 0x2000); - if (this->spinTimer == 30 && this->invincibilityTimer == 0) { - if (this->actor.xzDistToPlayer > 160.0f) { + if (DECR(pthis->spinTimer) != 0) { + pthis->actor.shape.rot.y += (pthis->runDir * 0x2000); + if (pthis->spinTimer == 30 && pthis->invincibilityTimer == 0) { + if (pthis->actor.xzDistToPlayer > 160.0f) { // orange flames - EnFd_SpawnChildFire(this, globalCtx, 8, 0); + EnFd_SpawnChildFire(pthis, globalCtx, 8, 0); } else { // blue flames - EnFd_SpawnChildFire(this, globalCtx, 8, 1); + EnFd_SpawnChildFire(pthis, globalCtx, 8, 1); } } } else { - // slow shape rotation down to meet `this` rotation within ~1.66 degrees - deceleration = this->actor.world.rot.y; - deceleration -= this->actor.shape.rot.y; + // slow shape rotation down to meet `pthis` rotation within ~1.66 degrees + deceleration = pthis->actor.world.rot.y; + deceleration -= pthis->actor.shape.rot.y; rotSpeed = 0.0f; tgtSpeed = fabsf(deceleration); deceleration /= tgtSpeed; Math_ApproachF(&rotSpeed, tgtSpeed, 0.6f, 0x2000); rotSpeed *= deceleration; - this->actor.shape.rot.y += (s16)rotSpeed; + pthis->actor.shape.rot.y += (s16)rotSpeed; rotSpeed = fabsf(rotSpeed); if ((s32)rotSpeed <= 300) { // ~1.6 degrees - this->actor.shape.rot.y = this->actor.world.rot.y; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; } - if (this->actor.shape.rot.y == this->actor.world.rot.y) { - this->initYawToInitPos = Math_Vec3f_Yaw(&this->actor.home.pos, &this->actor.world.pos); - this->curYawToInitPos = this->runDir < 0 ? 0xFFFF : 0; - this->circlesToComplete = (globalCtx->state.frames & 7) + 2; - this->spinTimer = Rand_S16Offset(30, 120); - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->actionFunc = EnFd_Run; + if (pthis->actor.shape.rot.y == pthis->actor.world.rot.y) { + pthis->initYawToInitPos = Math_Vec3f_Yaw(&pthis->actor.home.pos, &pthis->actor.world.pos); + pthis->curYawToInitPos = pthis->runDir < 0 ? 0xFFFF : 0; + pthis->circlesToComplete = (globalCtx->state.frames & 7) + 2; + pthis->spinTimer = Rand_S16Offset(30, 120); + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->actionFunc = EnFd_Run; } } } @@ -583,126 +583,126 @@ void EnFd_SpinAndSpawnFire(EnFd* this, GlobalContext* globalCtx) { * the radius being the distance from the initial postion to the nearest * threat (bomb or player). */ -void EnFd_Run(EnFd* this, GlobalContext* globalCtx) { +void EnFd_Run(EnFd* pthis, GlobalContext* globalCtx) { Actor* potentialThreat; s16 yawToYawTarget; f32 runRadiusTarget; Vec3f adjPos; - if (EnFd_ShouldStopRunning(this, globalCtx, this->runRadius, &this->runDir)) { - if (this->invincibilityTimer == 0) { - this->actor.world.rot.y ^= 0x8000; - this->actor.velocity.y = 6.0f; - this->actor.speedXZ = 0.0f; - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->actionFunc = EnFd_JumpToGround; + if (EnFd_ShouldStopRunning(pthis, globalCtx, pthis->runRadius, &pthis->runDir)) { + if (pthis->invincibilityTimer == 0) { + pthis->actor.world.rot.y ^= 0x8000; + pthis->actor.velocity.y = 6.0f; + pthis->actor.speedXZ = 0.0f; + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->actionFunc = EnFd_JumpToGround; return; } } - yawToYawTarget = Math_Vec3f_Yaw(&this->actor.home.pos, &this->actor.world.pos) - this->initYawToInitPos; - if (this->runDir > 0) { - if ((u16)this->curYawToInitPos > (u16)(yawToYawTarget)) { - this->circlesToComplete--; + yawToYawTarget = Math_Vec3f_Yaw(&pthis->actor.home.pos, &pthis->actor.world.pos) - pthis->initYawToInitPos; + if (pthis->runDir > 0) { + if ((u16)pthis->curYawToInitPos > (u16)(yawToYawTarget)) { + pthis->circlesToComplete--; } - } else if ((u16)this->curYawToInitPos < (u16)(yawToYawTarget)) { - this->circlesToComplete--; + } else if ((u16)pthis->curYawToInitPos < (u16)(yawToYawTarget)) { + pthis->circlesToComplete--; } - if (this->circlesToComplete < 0) { - this->circlesToComplete = 0; + if (pthis->circlesToComplete < 0) { + pthis->circlesToComplete = 0; } - this->curYawToInitPos = yawToYawTarget; + pthis->curYawToInitPos = yawToYawTarget; // If there is a bomb out, or if the player exists, set radius to // the distance to that threat, otherwise default to 200. - potentialThreat = EnFd_FindPotentialTheat(this, globalCtx); - if ((potentialThreat != NULL) && (this->invincibilityTimer == 0)) { - runRadiusTarget = Math_Vec3f_DistXYZ(&this->actor.home.pos, &potentialThreat->world.pos); + potentialThreat = EnFd_FindPotentialTheat(pthis, globalCtx); + if ((potentialThreat != NULL) && (pthis->invincibilityTimer == 0)) { + runRadiusTarget = Math_Vec3f_DistXYZ(&pthis->actor.home.pos, &potentialThreat->world.pos); } else { runRadiusTarget = 200.0f; } - Math_SmoothStepToF(&this->runRadius, runRadiusTarget, 0.3f, 100.0f, 0.0f); - EnFd_GetPosAdjAroundCircle(&adjPos, this, this->runRadius, this->runDir); - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(adjPos.x, adjPos.z) * (0x8000 / M_PI), 4, 0xFA0, 1); - this->actor.world.rot = this->actor.shape.rot; - func_8002F974(&this->actor, NA_SE_EN_FLAME_RUN - SFX_FLAG); - if (this->skelAnime.curFrame == 6.0f || this->skelAnime.curFrame == 13.0f || this->skelAnime.curFrame == 28.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_KICK); + Math_SmoothStepToF(&pthis->runRadius, runRadiusTarget, 0.3f, 100.0f, 0.0f); + EnFd_GetPosAdjAroundCircle(&adjPos, pthis, pthis->runRadius, pthis->runDir); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(adjPos.x, adjPos.z) * (0x8000 / M_PI), 4, 0xFA0, 1); + pthis->actor.world.rot = pthis->actor.shape.rot; + func_8002F974(&pthis->actor, NA_SE_EN_FLAME_RUN - SFX_FLAG); + if (pthis->skelAnime.curFrame == 6.0f || pthis->skelAnime.curFrame == 13.0f || pthis->skelAnime.curFrame == 28.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_KICK); } - Math_SmoothStepToF(&this->actor.speedXZ, 8.0f, 0.1f, 1.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, 8.0f, 0.1f, 1.0f, 0.0f); } /** - * En_Fw will set `this` params when it is done with its action. - * It will set FLG_COREDONE when the core has returned to `this`'s initial + * En_Fw will set `pthis` params when it is done with its action. + * It will set FLG_COREDONE when the core has returned to `pthis`'s initial * position, and FLG_COREDEAD when there is no health left */ -void EnFd_WaitForCore(EnFd* this, GlobalContext* globalCtx) { - if (this->spinTimer != 0) { - this->spinTimer--; - if (this->spinTimer == 0) { - Actor_Kill(&this->actor); +void EnFd_WaitForCore(EnFd* pthis, GlobalContext* globalCtx) { + if (pthis->spinTimer != 0) { + pthis->spinTimer--; + if (pthis->spinTimer == 0) { + Actor_Kill(&pthis->actor); } - } else if (this->actor.params & FLG_COREDONE) { - this->actionFunc = EnFd_Reappear; - } else if (this->actor.params & FLG_COREDEAD) { - this->actor.params = 0; - this->spinTimer = 30; + } else if (pthis->actor.params & FLG_COREDONE) { + pthis->actionFunc = EnFd_Reappear; + } else if (pthis->actor.params & FLG_COREDEAD) { + pthis->actor.params = 0; + pthis->spinTimer = 30; } } void EnFd_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFd* this = (EnFd*)thisx; + EnFd* pthis = (EnFd*)thisx; s32 pad; - if (this->firstUpdateFlag) { + if (pthis->firstUpdateFlag) { func_800F5ACC(NA_BGM_MINI_BOSS); - this->firstUpdateFlag = false; + pthis->firstUpdateFlag = false; } - if (this->actionFunc != EnFd_Reappear) { - SkelAnime_Update(&this->skelAnime); - EnFd_SpawnDot(this, globalCtx); + if (pthis->actionFunc != EnFd_Reappear) { + SkelAnime_Update(&pthis->skelAnime); + EnFd_SpawnDot(pthis, globalCtx); } - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_13)) { // has been hookshoted - if (EnFd_SpawnCore(this, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->invincibilityTimer = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_DAMAGE); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + if (EnFd_SpawnCore(pthis, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->invincibilityTimer = 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_DAMAGE); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); } else { - this->actor.flags &= ~ACTOR_FLAG_13; + pthis->actor.flags &= ~ACTOR_FLAG_13; } - } else if (this->actionFunc != EnFd_WaitForCore) { - EnFd_ColliderCheck(this, globalCtx); + } else if (pthis->actionFunc != EnFd_WaitForCore) { + EnFd_ColliderCheck(pthis, globalCtx); } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - EnFd_Fade(this, globalCtx); - this->actionFunc(this, globalCtx); - EnFd_UpdateDots(this); - EnFd_UpdateFlames(this); - if (this->actionFunc != EnFd_Reappear && this->actionFunc != EnFd_SpinAndGrow && - this->actionFunc != EnFd_WaitForCore) { - if (this->attackTimer == 0 && this->invincibilityTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + EnFd_Fade(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + EnFd_UpdateDots(pthis); + EnFd_UpdateFlames(pthis); + if (pthis->actionFunc != EnFd_Reappear && pthis->actionFunc != EnFd_SpinAndGrow && + pthis->actionFunc != EnFd_WaitForCore) { + if (pthis->attackTimer == 0 && pthis->invincibilityTimer == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - if ((this->actionFunc == EnFd_Run) || (this->actionFunc == EnFd_SpinAndSpawnFire)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((pthis->actionFunc == EnFd_Run) || (pthis->actionFunc == EnFd_SpinAndSpawnFire)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } s32 EnFd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfxP) { - EnFd* this = (EnFd*)thisx; + EnFd* pthis = (EnFd*)thisx; - if (this->invincibilityTimer != 0) { + if (pthis->invincibilityTimer != 0) { switch (limbIndex) { case 13: case 21: @@ -715,7 +715,7 @@ s32 EnFd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnFd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfxP) { - EnFd* this = (EnFd*)thisx; + EnFd* pthis = (EnFd*)thisx; Vec3f unused0 = { 6800.0f, 0.0f, 0.0f }; Vec3f unused1 = { 6800.0f, 0.0f, 0.0f }; Vec3f initialPos = { 0.0f, 0.0f, 0.0f }; @@ -725,11 +725,11 @@ void EnFd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 i; if (limbIndex == 21) { - Matrix_MultVec3f(&initialPos, &this->corePos); + Matrix_MultVec3f(&initialPos, &pthis->corePos); } if (limbIndex == 13) { - Matrix_MultVec3f(&initialPos, &this->actor.focus.pos); + Matrix_MultVec3f(&initialPos, &pthis->actor.focus.pos); } if (limbIndex == 3 || limbIndex == 6 || limbIndex == 7 || limbIndex == 10 || limbIndex == 14 || limbIndex == 15 || @@ -744,16 +744,16 @@ void EnFd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec accel.x = (Rand_ZeroOne() - 0.5f) * 0.4f; accel.y = ((Rand_ZeroOne() - 0.5f) * 0.2f) + 0.6f; accel.z = (Rand_ZeroOne() - 0.5f) * 0.4f; - EnFd_AddEffect(this, FD_EFFECT_DOT, &pos, &velocity, &accel, 0, 0.006f, 0.0f); + EnFd_AddEffect(pthis, FD_EFFECT_DOT, &pos, &velocity, &accel, 0, 0.006f, 0.0f); } } } - Collider_UpdateSpheres(limbIndex, &this->collider); + Collider_UpdateSpheres(limbIndex, &pthis->collider); } void EnFd_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnFd* this = (EnFd*)thisx; + EnFd* pthis = (EnFd*)thisx; s32 clampedHealth; Color_RGBA8 primColors[] = { { 255, 255, 200, 255 }, @@ -773,36 +773,36 @@ void EnFd_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 1751); Matrix_Push(); - EnFd_DrawDots(this, globalCtx); - EnFd_DrawFlames(this, globalCtx); + EnFd_DrawDots(pthis, globalCtx); + EnFd_DrawFlames(pthis, globalCtx); Matrix_Pop(); - if (this->actionFunc != EnFd_Reappear && !(this->fadeAlpha < 0.9f)) { + if (pthis->actionFunc != EnFd_Reappear && !(pthis->fadeAlpha < 0.9f)) { if (1) {} func_80093D84(globalCtx->state.gfxCtx); clampedHealth = CLAMP(thisx->colChkInfo.health - 1, 0, 23); gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, primColors[clampedHealth / 8].r, primColors[clampedHealth / 8].g, - primColors[clampedHealth / 8].b, (u8)this->fadeAlpha); + primColors[clampedHealth / 8].b, (u8)pthis->fadeAlpha); gDPSetEnvColor(POLY_XLU_DISP++, envColors[clampedHealth / 8].r, envColors[clampedHealth / 8].g, - envColors[clampedHealth / 8].b, (u8)this->fadeAlpha); + envColors[clampedHealth / 8].b, (u8)pthis->fadeAlpha); gSPSegment( POLY_XLU_DISP++, 0x8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, 0xFF - (u8)(frames * 6), 8, 0x40)); gDPPipeSync(POLY_XLU_DISP++); gSPSegment(POLY_XLU_DISP++, 0x9, D_80116280); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnFd_OverrideLimbDraw, EnFd_PostLimbDraw, this, + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnFd_OverrideLimbDraw, EnFd_PostLimbDraw, pthis, POLY_XLU_DISP); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 1822); } -void EnFd_AddEffect(EnFd* this, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 timer, f32 scale, +void EnFd_AddEffect(EnFd* pthis, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 timer, f32 scale, f32 scaleStep) { - EnFdEffect* eff = this->effects; + EnFdEffect* eff = pthis->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { if (eff->type != FD_EFFECT_NONE) { continue; } @@ -821,11 +821,11 @@ void EnFd_AddEffect(EnFd* this, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* acc } } -void EnFd_UpdateFlames(EnFd* this) { +void EnFd_UpdateFlames(EnFd* pthis) { s16 i; - EnFdEffect* eff = this->effects; + EnFdEffect* eff = pthis->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { if (eff->type == FD_EFFECT_FLAME) { eff->timer--; if (eff->timer == 0) { @@ -844,8 +844,8 @@ void EnFd_UpdateFlames(EnFd* this) { } } -void EnFd_UpdateDots(EnFd* this) { - EnFdEffect* eff = this->effects; +void EnFd_UpdateDots(EnFd* pthis) { + EnFdEffect* eff = pthis->effects; s16 i; Color_RGBA8 dotColors[] = { { 255, 128, 0, 0 }, @@ -854,7 +854,7 @@ void EnFd_UpdateDots(EnFd* this) { { 255, 0, 0, 0 }, }; - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { if (eff->type == FD_EFFECT_DOT) { eff->pos.x += eff->velocity.x; eff->pos.y += eff->velocity.y; @@ -877,28 +877,28 @@ void EnFd_UpdateDots(EnFd* this) { } } -void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx) { +void EnFd_DrawFlames(EnFd* pthis, GlobalContext* globalCtx) { static void* dustTextures[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; s32 firstDone; s16 i; s16 idx; - EnFdEffect* eff = this->effects; + EnFdEffect* eff = pthis->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 1969); firstDone = false; if (1) {} func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { if (eff->type == FD_EFFECT_FLAME) { if (!firstDone) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_7928); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, (u8)((this->fadeAlpha / 255.0f) * 255)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, (u8)((pthis->fadeAlpha / 255.0f) * 255)); firstDone = true; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (u8)((this->fadeAlpha / 255.0f) * 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 0, (u8)((pthis->fadeAlpha / 255.0f) * 255)); gDPPipeSync(POLY_XLU_DISP++); Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); func_800D1FD4(&globalCtx->billboardMtxF); @@ -913,17 +913,17 @@ void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 2020); } -void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx) { +void EnFd_DrawDots(EnFd* pthis, GlobalContext* globalCtx) { s16 i; s16 firstDone; - EnFdEffect* eff = this->effects; + EnFdEffect* eff = pthis->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd.c", 2034); firstDone = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { if (eff->type == FD_EFFECT_DOT) { if (!firstDone) { func_80093D84(globalCtx->state.gfxCtx); @@ -931,7 +931,7 @@ void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx) { firstDone = true; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, - (u8)(eff->color.a * (this->fadeAlpha / 255.0f))); + (u8)(eff->color.a * (pthis->fadeAlpha / 255.0f))); gDPPipeSync(POLY_XLU_DISP++); if (1) {} Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_En_Fd/z_en_fd.h b/src/overlays/actors/ovl_En_Fd/z_en_fd.h index a00b622c9..a70da0741 100644 --- a/src/overlays/actors/ovl_En_Fd/z_en_fd.h +++ b/src/overlays/actors/ovl_En_Fd/z_en_fd.h @@ -5,8 +5,9 @@ #include "global.h" struct EnFd; +struct GlobalContext; -typedef void (*EnFdActionFunc)(struct EnFd* this, GlobalContext* globalCtx); +typedef void (*EnFdActionFunc)(struct EnFd* pthis, GlobalContext* globalCtx); typedef enum { FD_EFFECT_NONE, diff --git a/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.c b/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.c deleted file mode 100644 index 9eed26609..000000000 --- a/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.c +++ /dev/null @@ -1,296 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FD_FIRE_Z_EN_FD_FIRE_C -#include "actor_common.h" -#include "z_en_fd_fire.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnFdFire_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFdFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFdFire_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFdFire_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFdFire_Disappear(EnFdFire* this, GlobalContext* globalCtx); -void func_80A0E70C(EnFdFire* this, GlobalContext* globalCtx); -void EnFdFire_DanceTowardsPlayer(EnFdFire* this, GlobalContext* globalCtx); -void EnFdFire_WaitToDie(EnFdFire* this, GlobalContext* globalCtx); - -const ActorInit En_Fd_Fire_InitVars = { - ACTOR_EN_FD_FIRE, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_GAMEPLAY_DANGEON_KEEP, - sizeof(EnFdFire), - (ActorFunc)EnFdFire_Init, - (ActorFunc)EnFdFire_Destroy, - (ActorFunc)EnFdFire_Update, - (ActorFunc)EnFdFire_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x08 }, - { 0x0D840008, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 12, 46, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Kokiri sword */ DMG_ENTRY(0, 0x0), - /* Master sword */ DMG_ENTRY(0, 0x0), - /* Giant's Knife */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(4, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(0, 0x0), - /* Giant spin */ DMG_ENTRY(0, 0x0), - /* Master spin */ DMG_ENTRY(0, 0x0), - /* Kokiri jump */ DMG_ENTRY(0, 0x0), - /* Giant jump */ DMG_ENTRY(0, 0x0), - /* Master jump */ DMG_ENTRY(0, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -void EnFdFire_UpdatePos(EnFdFire* this, Vec3f* targetPos) { - f32 dist; - f32 xDiff = targetPos->x - this->actor.world.pos.x; - f32 yDiff = targetPos->y - this->actor.world.pos.y; - f32 zDiff = targetPos->z - this->actor.world.pos.z; - - dist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); - if (fabsf(dist) > fabsf(this->actor.speedXZ)) { - this->actor.velocity.x = (xDiff / dist) * this->actor.speedXZ; - this->actor.velocity.z = (zDiff / dist) * this->actor.speedXZ; - } else { - this->actor.velocity.x = 0.0f; - this->actor.velocity.z = 0.0f; - } - - this->actor.velocity.y += this->actor.gravity; - if (!(this->actor.minVelocityY <= this->actor.velocity.y)) { - this->actor.velocity.y = this->actor.minVelocityY; - } -} - -s32 EnFdFire_CheckCollider(EnFdFire* this, GlobalContext* globalCtx) { - if (this->actionFunc == EnFdFire_Disappear) { - return false; - } - - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - return true; - } - - if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - return true; - } - return false; -} - -void EnFdFire_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFdFire* this = (EnFdFire*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInit); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.gravity = -0.6f; - this->actor.speedXZ = 5.0f; - this->actor.velocity.y = 12.0f; - this->spawnRadius = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos); - this->scale = 3.0f; - this->tile2Y = (s16)Rand_ZeroFloat(5.0f) - 25; - this->actionFunc = func_80A0E70C; -} - -void EnFdFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFdFire* this = (EnFdFire*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80A0E70C(EnFdFire* this, GlobalContext* globalCtx) { - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f targetPos = this->actor.parent->world.pos; - - targetPos.x += this->spawnRadius * Math_SinS(this->actor.world.rot.y); - targetPos.z += this->spawnRadius * Math_CosS(this->actor.world.rot.y); - EnFdFire_UpdatePos(this, &targetPos); - if (this->actor.bgCheckFlags & 1 && (!(this->actor.velocity.y > 0.0f))) { - this->actor.velocity = velocity; - this->actor.speedXZ = 0.0f; - this->actor.bgCheckFlags &= ~1; - if (this->actor.params & 0x8000) { - this->deathTimer = 200; - this->actionFunc = EnFdFire_DanceTowardsPlayer; - } else { - this->deathTimer = 300; - this->actionFunc = EnFdFire_WaitToDie; - } - } -} - -void EnFdFire_WaitToDie(EnFdFire* this, GlobalContext* globalCtx) { - if (DECR(this->deathTimer) == 0) { - this->actionFunc = EnFdFire_Disappear; - } -} - -void EnFdFire_DanceTowardsPlayer(EnFdFire* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 angles[] = { - 0.0f, 210.0f, 60.0f, 270.0f, 120.0f, 330.0f, 180.0f, 30.0f, 240.0f, 90.0f, 300.0f, 150.0f, - }; - Vec3f pos; - s16 idx; - - idx = ((globalCtx->state.frames / 10) + (this->actor.params & 0x7FFF)) % ARRAY_COUNT(angles); - pos = player->actor.world.pos; - pos.x += 120.0f * sinf(angles[idx]); - pos.z += 120.0f * cosf(angles[idx]); - - if (DECR(this->deathTimer) == 0) { - this->actionFunc = EnFdFire_Disappear; - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &pos), 8, 0xFA0, 1); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.4f, 1.0f, 0.0f); - if (this->actor.speedXZ < 0.1f) { - this->actor.speedXZ = 5.0f; - } - func_8002D868(&this->actor); - } -} - -void EnFdFire_Disappear(EnFdFire* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.6f, 9.0f, 0.0f); - func_8002D868(&this->actor); - Math_SmoothStepToF(&this->scale, 0.0f, 0.3f, 0.1f, 0.0f); - this->actor.shape.shadowScale = 20.0f; - this->actor.shape.shadowScale *= (this->scale / 3.0f); - if (!(this->scale > 0.01f)) { - Actor_Kill(&this->actor); - } -} - -void EnFdFire_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFdFire* this = (EnFdFire*)thisx; - s32 pad; - - if (this->actionFunc != EnFdFire_Disappear) { - if ((this->actor.parent->update == NULL) || EnFdFire_CheckCollider(this, globalCtx)) { - this->actionFunc = EnFdFire_Disappear; - } - } - - func_8002D7EC(&this->actor); - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 10.0f, 0.0f, 5); - - if (this->actionFunc != EnFdFire_Disappear) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void EnFdFire_Draw(Actor* thisx, GlobalContext* globalCtx) { - Color_RGBA8 primColors[] = { - { 255, 255, 0, 255 }, - { 255, 255, 255, 255 }, - }; - Color_RGBA8 envColors[] = { - { 255, 10, 0, 255 }, - { 0, 10, 255, 255 }, - }; - s32 pad; - EnFdFire* this = (EnFdFire*)thisx; - Vec3f scale = { 0.0f, 0.0f, 0.0f }; - Vec3f sp90 = { 0.0f, 0.0f, 0.0f }; - s16 sp8E; - f32 sp88; - f32 sp84; - f32 sp80; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd_fire.c", 572); - - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - sp8E = Math_Vec3f_Yaw(&scale, &this->actor.velocity) - Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); - sp84 = fabsf(Math_CosS(sp8E)); - sp88 = Math_SinS(sp8E); - sp80 = Math_Vec3f_DistXZ(&scale, &this->actor.velocity) / 1.5f; - if (1) {} - if (1) {} - if (1) {} - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(((sp88 * -10.0f) * sp80) * (M_PI / 180.0f), MTXMODE_APPLY); - scale.x = scale.y = scale.z = this->scale * 0.001f; - Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); - sp84 = sp80 * ((0.01f * -15.0f) * sp84) + 1.0f; - if (sp84 < 0.1f) { - sp84 = 0.1f; - } - Matrix_Scale(1.0f, sp84, 1.0f / sp84, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fd_fire.c", 623), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x8, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - globalCtx->state.frames * this->tile2Y, 0x20, 0x80)); - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, primColors[((this->actor.params & 0x8000) >> 0xF)].r, - primColors[((this->actor.params & 0x8000) >> 0xF)].g, - primColors[((this->actor.params & 0x8000) >> 0xF)].b, - primColors[((this->actor.params & 0x8000) >> 0xF)].a); - gDPSetEnvColor(POLY_XLU_DISP++, envColors[((this->actor.params & 0x8000) >> 0xF)].r, - envColors[((this->actor.params & 0x8000) >> 0xF)].g, - envColors[((this->actor.params & 0x8000) >> 0xF)].b, - envColors[((this->actor.params & 0x8000) >> 0xF)].a); - gDPPipeSync(POLY_XLU_DISP++); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fd_fire.c", 672); -} diff --git a/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.cpp b/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.cpp new file mode 100644 index 000000000..90bfa3eab --- /dev/null +++ b/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.cpp @@ -0,0 +1,296 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FD_FIRE_Z_EN_FD_FIRE_C +#include "actor_common.h" +#include "z_en_fd_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnFdFire_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFdFire_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFdFire_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFdFire_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFdFire_Disappear(EnFdFire* pthis, GlobalContext* globalCtx); +void func_80A0E70C(EnFdFire* pthis, GlobalContext* globalCtx); +void EnFdFire_DanceTowardsPlayer(EnFdFire* pthis, GlobalContext* globalCtx); +void EnFdFire_WaitToDie(EnFdFire* pthis, GlobalContext* globalCtx); + +ActorInit En_Fd_Fire_InitVars = { + ACTOR_EN_FD_FIRE, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_GAMEPLAY_DANGEON_KEEP, + sizeof(EnFdFire), + (ActorFunc)EnFdFire_Init, + (ActorFunc)EnFdFire_Destroy, + (ActorFunc)EnFdFire_Update, + (ActorFunc)EnFdFire_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x08 }, + { 0x0D840008, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 12, 46, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(0, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x0), + /* Kokiri sword */ DMG_ENTRY(0, 0x0), + /* Master sword */ DMG_ENTRY(0, 0x0), + /* Giant's Knife */ DMG_ENTRY(0, 0x0), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(4, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0x0), + /* Giant spin */ DMG_ENTRY(0, 0x0), + /* Master spin */ DMG_ENTRY(0, 0x0), + /* Kokiri jump */ DMG_ENTRY(0, 0x0), + /* Giant jump */ DMG_ENTRY(0, 0x0), + /* Master jump */ DMG_ENTRY(0, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +void EnFdFire_UpdatePos(EnFdFire* pthis, Vec3f* targetPos) { + f32 dist; + f32 xDiff = targetPos->x - pthis->actor.world.pos.x; + f32 yDiff = targetPos->y - pthis->actor.world.pos.y; + f32 zDiff = targetPos->z - pthis->actor.world.pos.z; + + dist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + if (fabsf(dist) > fabsf(pthis->actor.speedXZ)) { + pthis->actor.velocity.x = (xDiff / dist) * pthis->actor.speedXZ; + pthis->actor.velocity.z = (zDiff / dist) * pthis->actor.speedXZ; + } else { + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.z = 0.0f; + } + + pthis->actor.velocity.y += pthis->actor.gravity; + if (!(pthis->actor.minVelocityY <= pthis->actor.velocity.y)) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } +} + +s32 EnFdFire_CheckCollider(EnFdFire* pthis, GlobalContext* globalCtx) { + if (pthis->actionFunc == EnFdFire_Disappear) { + return false; + } + + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + return true; + } + + if (pthis->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + pthis->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + return true; + } + return false; +} + +void EnFdFire_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFdFire* pthis = (EnFdFire*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInit); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.gravity = -0.6f; + pthis->actor.speedXZ = 5.0f; + pthis->actor.velocity.y = 12.0f; + pthis->spawnRadius = Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &player->actor.world.pos); + pthis->scale = 3.0f; + pthis->tile2Y = (s16)Rand_ZeroFloat(5.0f) - 25; + pthis->actionFunc = func_80A0E70C; +} + +void EnFdFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFdFire* pthis = (EnFdFire*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80A0E70C(EnFdFire* pthis, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f targetPos = pthis->actor.parent->world.pos; + + targetPos.x += pthis->spawnRadius * Math_SinS(pthis->actor.world.rot.y); + targetPos.z += pthis->spawnRadius * Math_CosS(pthis->actor.world.rot.y); + EnFdFire_UpdatePos(pthis, &targetPos); + if (pthis->actor.bgCheckFlags & 1 && (!(pthis->actor.velocity.y > 0.0f))) { + pthis->actor.velocity = velocity; + pthis->actor.speedXZ = 0.0f; + pthis->actor.bgCheckFlags &= ~1; + if (pthis->actor.params & 0x8000) { + pthis->deathTimer = 200; + pthis->actionFunc = EnFdFire_DanceTowardsPlayer; + } else { + pthis->deathTimer = 300; + pthis->actionFunc = EnFdFire_WaitToDie; + } + } +} + +void EnFdFire_WaitToDie(EnFdFire* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->deathTimer) == 0) { + pthis->actionFunc = EnFdFire_Disappear; + } +} + +void EnFdFire_DanceTowardsPlayer(EnFdFire* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 angles[] = { + 0.0f, 210.0f, 60.0f, 270.0f, 120.0f, 330.0f, 180.0f, 30.0f, 240.0f, 90.0f, 300.0f, 150.0f, + }; + Vec3f pos; + s16 idx; + + idx = ((globalCtx->state.frames / 10) + (pthis->actor.params & 0x7FFF)) % ARRAY_COUNT(angles); + pos = player->actor.world.pos; + pos.x += 120.0f * sinf(angles[idx]); + pos.z += 120.0f * cosf(angles[idx]); + + if (DECR(pthis->deathTimer) == 0) { + pthis->actionFunc = EnFdFire_Disappear; + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pos), 8, 0xFA0, 1); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.4f, 1.0f, 0.0f); + if (pthis->actor.speedXZ < 0.1f) { + pthis->actor.speedXZ = 5.0f; + } + func_8002D868(&pthis->actor); + } +} + +void EnFdFire_Disappear(EnFdFire* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.6f, 9.0f, 0.0f); + func_8002D868(&pthis->actor); + Math_SmoothStepToF(&pthis->scale, 0.0f, 0.3f, 0.1f, 0.0f); + pthis->actor.shape.shadowScale = 20.0f; + pthis->actor.shape.shadowScale *= (pthis->scale / 3.0f); + if (!(pthis->scale > 0.01f)) { + Actor_Kill(&pthis->actor); + } +} + +void EnFdFire_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFdFire* pthis = (EnFdFire*)thisx; + s32 pad; + + if (pthis->actionFunc != EnFdFire_Disappear) { + if ((pthis->actor.parent->update == NULL) || EnFdFire_CheckCollider(pthis, globalCtx)) { + pthis->actionFunc = EnFdFire_Disappear; + } + } + + func_8002D7EC(&pthis->actor); + pthis->actionFunc(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 12.0f, 10.0f, 0.0f, 5); + + if (pthis->actionFunc != EnFdFire_Disappear) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void EnFdFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + Color_RGBA8 primColors[] = { + { 255, 255, 0, 255 }, + { 255, 255, 255, 255 }, + }; + Color_RGBA8 envColors[] = { + { 255, 10, 0, 255 }, + { 0, 10, 255, 255 }, + }; + s32 pad; + EnFdFire* pthis = (EnFdFire*)thisx; + Vec3f scale = { 0.0f, 0.0f, 0.0f }; + Vec3f sp90 = { 0.0f, 0.0f, 0.0f }; + s16 sp8E; + f32 sp88; + f32 sp84; + f32 sp80; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fd_fire.c", 572); + + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + sp8E = Math_Vec3f_Yaw(&scale, &pthis->actor.velocity) - Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + sp84 = fabsf(Math_CosS(sp8E)); + sp88 = Math_SinS(sp8E); + sp80 = Math_Vec3f_DistXZ(&scale, &pthis->actor.velocity) / 1.5f; + if (1) {} + if (1) {} + if (1) {} + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(((sp88 * -10.0f) * sp80) * (M_PI / 180.0f), MTXMODE_APPLY); + scale.x = scale.y = scale.z = pthis->scale * 0.001f; + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + sp84 = sp80 * ((0.01f * -15.0f) * sp84) + 1.0f; + if (sp84 < 0.1f) { + sp84 = 0.1f; + } + Matrix_Scale(1.0f, sp84, 1.0f / sp84, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fd_fire.c", 623), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x8, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + globalCtx->state.frames * pthis->tile2Y, 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, primColors[((pthis->actor.params & 0x8000) >> 0xF)].r, + primColors[((pthis->actor.params & 0x8000) >> 0xF)].g, + primColors[((pthis->actor.params & 0x8000) >> 0xF)].b, + primColors[((pthis->actor.params & 0x8000) >> 0xF)].a); + gDPSetEnvColor(POLY_XLU_DISP++, envColors[((pthis->actor.params & 0x8000) >> 0xF)].r, + envColors[((pthis->actor.params & 0x8000) >> 0xF)].g, + envColors[((pthis->actor.params & 0x8000) >> 0xF)].b, + envColors[((pthis->actor.params & 0x8000) >> 0xF)].a); + gDPPipeSync(POLY_XLU_DISP++); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fd_fire.c", 672); +} diff --git a/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.h b/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.h index 7de1c53fe..5efa9b9b7 100644 --- a/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.h +++ b/src/overlays/actors/ovl_En_Fd_Fire/z_en_fd_fire.h @@ -6,7 +6,7 @@ struct EnFdFire; -typedef void (*EnFdFireActionFunc)(struct EnFdFire* this, GlobalContext* globalCtx); +typedef void (*EnFdFireActionFunc)(struct EnFdFire* pthis, GlobalContext* globalCtx); typedef struct EnFdFire { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c deleted file mode 100644 index 157fde76d..000000000 --- a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c +++ /dev/null @@ -1,773 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FHG_FIRE_Z_EN_FHG_FIRE_C -#include "actor_common.h" -#include "z_kankyo.h" -/* - * File: z_en_fhg_fire.c - * Overlay: ovl_En_Fhg_Fire - * Description: Phantom Ganon's Lighting Attack - */ - -#include "z_en_fhg_fire.h" -#include "objects/object_fhg/object_fhg.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h" -#include "overlays/actors/ovl_En_fHG/z_en_fhg.h" -#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_play.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -typedef enum { - /* 0 */ STRIKE_INIT, - /* 10 */ STRIKE_BURST = 10, - /* 11 */ STRIKE_TRAILS -} StrikeMode; - -typedef enum { - /* 0 */ TRAIL_INIT, - /* 1 */ TRAIL_APPEAR, - /* 2 */ TRAIL_DISSIPATE -} TrailMode; - -typedef enum { - /* 0 */ BALL_FIZZLE, - /* 1 */ BALL_BURST, - /* 2 */ BALL_IMPACT -} BallKillMode; - -void EnFhgFire_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFhgFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFhgFire_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFhgFire_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnFhgFire_LightningStrike(EnFhgFire* this, GlobalContext* globalCtx); -void EnFhgFire_LightningTrail(EnFhgFire* this, GlobalContext* globalCtx); -void EnFhgFire_LightningShock(EnFhgFire* this, GlobalContext* globalCtx); -void EnFhgFire_LightningBurst(EnFhgFire* this, GlobalContext* globalCtx); -void EnFhgFire_SpearLight(EnFhgFire* this, GlobalContext* globalCtx); -void EnFhgFire_EnergyBall(EnFhgFire* this, GlobalContext* globalCtx); -void EnFhgFire_PhantomWarp(EnFhgFire* this, GlobalContext* globalCtx); - -const ActorInit En_Fhg_Fire_InitVars = { - 0, - ACTORCAT_BOSS, - FLAGS, - OBJECT_FHG, - sizeof(EnFhgFire), - (ActorFunc)EnFhgFire_Init, - (ActorFunc)EnFhgFire_Destroy, - (ActorFunc)EnFhgFire_Update, - (ActorFunc)EnFhgFire_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK6, - { 0x00100700, 0x03, 0x20 }, - { 0x0D900700, 0x00, 0x00 }, - TOUCH_ON, - BUMP_ON, - OCELEM_ON, - }, - { 20, 30, 10, { 0, 0, 0 } }, -}; - -void EnFhgFire_SetUpdate(EnFhgFire* this, EnFhgFireUpdateFunc updateFunc) { - this->updateFunc = updateFunc; -} - -void EnFhgFire_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnFhgFire* this = (EnFhgFire*)thisx; - Player* player = GET_PLAYER(globalCtx); - - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - if ((this->actor.params == FHGFIRE_LIGHTNING_SHOCK) || (this->actor.params == FHGFIRE_LIGHTNING_BURST) || - (this->actor.params == FHGFIRE_ENERGY_BALL)) { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - } - this->fwork[FHGFIRE_ALPHA] = 200.0f; - Actor_SetScale(&this->actor, 0.0f); - - if (this->actor.params == FHGFIRE_LIGHTNING_STRIKE) { - EnFhgFire_SetUpdate(this, EnFhgFire_LightningStrike); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_THUNDER); - } else if (this->actor.params >= FHGFIRE_LIGHTNING_TRAIL) { - EnFhgFire_SetUpdate(this, EnFhgFire_LightningTrail); - this->actor.shape.rot = this->actor.world.rot; - } - if (this->actor.params == FHGFIRE_LIGHTNING_SHOCK) { - this->actor.draw = NULL; - EnFhgFire_SetUpdate(this, EnFhgFire_LightningShock); - this->actor.speedXZ = 30.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_SPARK); - } else if (this->actor.params == FHGFIRE_LIGHTNING_BURST) { - EnFhgFire_SetUpdate(this, EnFhgFire_LightningBurst); - this->fwork[FHGFIRE_ALPHA] = 255.0f; - this->work[FHGFIRE_TIMER] = 32; - this->work[FHGFIRE_FX_TIMER] = 50; - this->lensFlareTimer = 10; - - this->fwork[FHGFIRE_BURST_SCALE] = this->actor.world.rot.x / 100.0f; - this->collider.dim.radius = this->actor.world.rot.x * 0.13f; - this->collider.dim.height = this->actor.world.rot.x * 0.13f; - this->collider.dim.yShift = 0; - } else if (this->actor.params == FHGFIRE_SPEAR_LIGHT) { - osSyncPrintf("yari hikari ct 1\n"); // "light spear" - EnFhgFire_SetUpdate(this, EnFhgFire_SpearLight); - osSyncPrintf("yari hikari ct 2\n"); - this->work[FHGFIRE_TIMER] = this->actor.world.rot.x; - this->work[FHGFIRE_FIRE_MODE] = this->actor.world.rot.y; - } else if ((this->actor.params == FHGFIRE_WARP_EMERGE) || (this->actor.params == FHGFIRE_WARP_RETREAT) || - (this->actor.params == FHGFIRE_WARP_DEATH)) { - Actor_SetScale(&this->actor, 7.0f); - EnFhgFire_SetUpdate(this, EnFhgFire_PhantomWarp); - if (this->actor.params == FHGFIRE_WARP_DEATH) { - this->work[FHGFIRE_TIMER] = 440; - this->actor.scale.z = 1.0f; - } else { - this->work[FHGFIRE_TIMER] = 76; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FANTOM_WARP_S); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FANTOM_WARP_S2); - } - } else if (this->actor.params == FHGFIRE_ENERGY_BALL) { - f32 dxL; - f32 dyL; - f32 dzL; - f32 dxzL; - - this->actor.speedXZ = (this->actor.world.rot.x == 0) ? 8.0f : 3.0f; - EnFhgFire_SetUpdate(this, EnFhgFire_EnergyBall); - - this->work[FHGFIRE_TIMER] = 70; - this->work[FHGFIRE_FX_TIMER] = 2; - - dxL = player->actor.world.pos.x - this->actor.world.pos.x; - dyL = player->actor.world.pos.y + 30.0f - this->actor.world.pos.y; - dzL = player->actor.world.pos.z - this->actor.world.pos.z; - this->actor.world.rot.y = Math_FAtan2F(dxL, dzL) * (0x8000 / M_PI); - dxzL = sqrtf(SQ(dxL) + SQ(dzL)); - this->actor.world.rot.x = Math_FAtan2F(dyL, dxzL) * (0x8000 / M_PI); - this->collider.dim.radius = 40; - this->collider.dim.height = 50; - this->collider.dim.yShift = -25; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, 255); - } -} - -void EnFhgFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnFhgFire* this = (EnFhgFire*)thisx; - - if ((this->actor.params == FHGFIRE_LIGHTNING_SHOCK) || (this->actor.params == FHGFIRE_LIGHTNING_BURST) || - (this->actor.params == FHGFIRE_ENERGY_BALL)) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } - - if (this->actor.params == FHGFIRE_ENERGY_BALL) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - } -} - -void EnFhgFire_LightningStrike(EnFhgFire* this, GlobalContext* globalCtx) { - Camera* camera = Gameplay_GetCamera(globalCtx, 0); - s16 i; - - switch (this->work[FHGFIRE_FIRE_MODE]) { - case STRIKE_INIT: - this->work[FHGFIRE_FIRE_MODE] = STRIKE_BURST; - this->work[FHGFIRE_TIMER] = 7; - break; - case STRIKE_BURST: - this->actor.shape.rot.y = - Camera_GetInputDirYaw(camera) + 0x8000 * (this->work[FHGFIRE_VARIANCE_TIMER] & 0xFF); - Math_ApproachF(&this->fwork[FHGFIRE_SCALE], 1.0f, 1.0f, 0.2f); - - if (this->work[FHGFIRE_TIMER] == 0) { - this->work[FHGFIRE_FIRE_MODE] = STRIKE_TRAILS; - this->actor.shape.rot.z += 0x8000; - this->work[FHGFIRE_TIMER] = 37; - this->actor.world.pos.y -= 200.0f; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 500, 0, 0, - FHGFIRE_LIGHTNING_BURST); - { - Vec3f sp7C; - Vec3f sp70 = { 0.0f, -1.0f, 0.0f }; - - for (i = 0; i < 35; i++) { - sp7C.x = Rand_CenteredFloat(30.f); - sp7C.y = Rand_ZeroFloat(5.0f) + 3.0f; - sp7C.z = Rand_CenteredFloat(30.f); - sp70.y = -0.2f; - EffectSsFhgFlash_SpawnLightBall(globalCtx, &this->actor.world.pos, &sp7C, &sp70, - (s16)(Rand_ZeroOne() * 100.0f) + 240, FHGFLASH_LIGHTBALL_GREEN); - } - } - func_80033E88(&this->actor, globalCtx, 4, 10); - } - - break; - case STRIKE_TRAILS: - this->actor.shape.rot.y = - Camera_GetInputDirYaw(camera) + (this->work[FHGFIRE_VARIANCE_TIMER] & 0xFF) * 0x8000; - - Math_ApproachF(&this->fwork[FHGFIRE_SCALE], 0.0f, 1.0f, 0.2f); - if (this->work[FHGFIRE_TIMER] == 30) { - s16 randY = (Rand_ZeroOne() < 0.5f) ? 0x1000 : 0; - - for (i = 0; i < 8; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, - (i * 0x2000) + randY, 0x4000, FHGFIRE_LIGHTNING_TRAIL + i); - } - - for (i = 0; i < 8; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, - (i * 0x2000) + randY, 0, FHGFIRE_LIGHTNING_SHOCK); - } - } - - if (this->work[FHGFIRE_TIMER] == 0) { - Actor_Kill(&this->actor); - } - } - - Actor_SetScale(&this->actor, this->fwork[FHGFIRE_SCALE]); -} - -void EnFhgFire_LightningTrail(EnFhgFire* this, GlobalContext* globalCtx) { - osSyncPrintf("FF MOVE 1\n"); - this->actor.shape.rot.x += (s16)(Rand_ZeroOne() * 4000.0f) + 0x4000; - - switch (this->work[FHGFIRE_FIRE_MODE]) { - case TRAIL_INIT: - this->work[FHGFIRE_FIRE_MODE] = TRAIL_APPEAR; - this->work[FHGFIRE_TIMER] = (s16)(Rand_ZeroOne() * 7.0f) + 7; - case TRAIL_APPEAR: - Math_ApproachF(&this->fwork[FHGFIRE_SCALE], 1.7f, 1.0f, 0.34f); - - if (this->work[FHGFIRE_TIMER] == 0) { - this->work[FHGFIRE_FIRE_MODE] = TRAIL_DISSIPATE; - this->work[FHGFIRE_TIMER] = 10; - this->actor.world.pos.z += Math_SinS(this->actor.shape.rot.y) * -200.0f * this->fwork[FHGFIRE_SCALE]; - this->actor.world.pos.x += Math_CosS(this->actor.shape.rot.y) * 200.0f * this->fwork[FHGFIRE_SCALE]; - this->actor.shape.rot.y += 0x8000; - } - break; - case TRAIL_DISSIPATE: - Math_ApproachZeroF(&this->fwork[FHGFIRE_SCALE], 1.0f, 0.34f); - if (this->work[FHGFIRE_TIMER] == 0) { - Actor_Kill(&this->actor); - } - break; - } - - Actor_SetScale(&this->actor, this->fwork[FHGFIRE_SCALE]); - if (this->actor.scale.x > 1.0f) { - this->actor.scale.x = 1.0f; - } - - osSyncPrintf("FF MOVE 2\n"); -} - -void EnFhgFire_LightningShock(EnFhgFire* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f pos; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_HIT_THUNDER); - } - - if (Rand_ZeroOne() < 0.5f) { - pos = this->actor.world.pos; - pos.y -= 20.0f; - EffectSsFhgFlash_SpawnShock(globalCtx, &this->actor, &pos, 200, FHGFLASH_SHOCK_NO_ACTOR); - } - - Actor_MoveForward(&this->actor); - Collider_UpdateCylinder(&this->actor, &this->collider); - if (player->invincibilityTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 1); - if (this->actor.bgCheckFlags & 8) { - Actor_Kill(&this->actor); - } -} - -void EnFhgFire_LightningBurst(EnFhgFire* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - globalCtx->envCtx.fillScreen = true; - this->actor.shape.rot.y += 0x1000; - - if (this->work[FHGFIRE_FX_TIMER] == 49) { - globalCtx->envCtx.unk_BF = 1; - globalCtx->envCtx.unk_D6 = 0xFF; - } - if (this->work[FHGFIRE_FX_TIMER] == 31) { - globalCtx->envCtx.unk_BF = 0x00; - globalCtx->envCtx.unk_D6 = 0x14; - } - if (this->work[FHGFIRE_FX_TIMER] >= 48) { - globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = - globalCtx->envCtx.screenFillColor[2] = 255; - - if ((this->work[FHGFIRE_TIMER] % 2) != 0) { - globalCtx->envCtx.screenFillColor[3] = 70; - } else { - globalCtx->envCtx.screenFillColor[3] = 0; - } - } else { - globalCtx->envCtx.screenFillColor[3] = 0; - } - - if (this->work[FHGFIRE_TIMER] <= 20) { - Math_ApproachZeroF(&this->fwork[FHGFIRE_ALPHA], 1.0f, 45.0f); - Math_ApproachZeroF(&this->fwork[FHGFIRE_SCALE], 1.0f, 0.5f); - } else { - Math_ApproachF(&this->fwork[FHGFIRE_SCALE], this->fwork[FHGFIRE_BURST_SCALE], 0.5f, 3.0f); - } - - Actor_SetScale(&this->actor, this->fwork[FHGFIRE_SCALE]); - if (this->fwork[FHGFIRE_BURST_SCALE] > 3.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - if (player->invincibilityTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - if (this->work[FHGFIRE_TIMER] == 0) { - Actor_Kill(&this->actor); - globalCtx->envCtx.fillScreen = false; - } - - if (this->lensFlareTimer != 0) { - this->lensFlareTimer--; - this->lensFlareOn = true; - Math_ApproachF(&this->lensFlareScale, 40.0f, 0.3f, 10.0f); - } else { - Math_ApproachZeroF(&this->lensFlareScale, 1.0f, 5.0f); - if (this->lensFlareScale == 0.0f) { - this->lensFlareOn = false; - } - } - - gCustomLensFlareOn = this->lensFlareOn; - gCustomLensFlarePos = this->actor.world.pos; - gLensFlareScale = this->lensFlareScale; - gLensFlareColorIntensity = 10.0f; - gLensFlareScreenFillAlpha = 0; -} - -void EnFhgFire_SpearLight(EnFhgFire* this, GlobalContext* globalCtx) { - BossGanondrof* bossGnd; - s16 i; - - osSyncPrintf("yari hikari 1\n"); - bossGnd = (BossGanondrof*)this->actor.parent; - if ((this->work[FHGFIRE_VARIANCE_TIMER] % 2) != 0) { - Actor_SetScale(&this->actor, 6.0f); - } else { - Actor_SetScale(&this->actor, 5.25f); - } - - this->actor.world.pos = bossGnd->spearTip; - this->actor.shape.rot.z += (s16)(Rand_ZeroOne() * 0x4E20) + 0x4000; - - osSyncPrintf("yari hikari 2\n"); - if (this->work[FHGFIRE_FIRE_MODE] == FHGFIRE_LIGHT_GREEN) { - Vec3f ballPos; - Vec3f ballVel = { 0.0f, 0.0f, 0.0f }; - Vec3f ballAccel = { 0.0f, 0.0f, 0.0f }; - - osSyncPrintf("FLASH !!\n"); - - for (i = 0; i < 2; i++) { - ballPos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - ballPos.y = Rand_CenteredFloat(20.0f) + this->actor.world.pos.y; - ballPos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - ballAccel.y = -0.08f; - - EffectSsFhgFlash_SpawnLightBall(globalCtx, &ballPos, &ballVel, &ballAccel, - (s16)(Rand_ZeroOne() * 80.0f) + 150, FHGFLASH_LIGHTBALL_GREEN); - } - } - - if (this->work[FHGFIRE_TIMER] == 0) { - Actor_Kill(&this->actor); - } -} - -void EnFhgFire_EnergyBall(EnFhgFire* this, GlobalContext* globalCtx) { - f32 dxL; - f32 dyL; - f32 dzL; - f32 dxzL; - f32 dxPG; - f32 dyPG; - f32 dzPG; - u8 killMode = BALL_FIZZLE; - u8 canBottleReflect1; - Player* player = GET_PLAYER(globalCtx); - - if (this->work[FHGFIRE_KILL_TIMER] != 0) { - this->work[FHGFIRE_KILL_TIMER]--; - if (this->work[FHGFIRE_KILL_TIMER] == 0) { - Actor_Kill(&this->actor); - return; - } - } else { - s32 canBottleReflect2; - BossGanondrof* bossGnd = (BossGanondrof*)this->actor.parent; - - dxPG = bossGnd->targetPos.x - this->actor.world.pos.x; - dyPG = bossGnd->targetPos.y - this->actor.world.pos.y; - dzPG = bossGnd->targetPos.z - this->actor.world.pos.z; - dxL = player->actor.world.pos.x - this->actor.world.pos.x; - dyL = player->actor.world.pos.y + 40.0f - this->actor.world.pos.y; - dzL = player->actor.world.pos.z - this->actor.world.pos.z; - func_8002D908(&this->actor); - func_8002D7EC(&this->actor); - if (this->work[FHGFIRE_VARIANCE_TIMER] & 1) { - Actor_SetScale(&this->actor, 6.0f); - } else { - Actor_SetScale(&this->actor, 5.25f); - } - this->actor.shape.rot.z += (s16)(Rand_ZeroOne() * 0x4E20) + 0x4000; - { - u8 lightBallColor1 = FHGFLASH_LIGHTBALL_GREEN; - s16 i1; - Vec3f spD4; - Vec3f spC8 = { 0.0f, 0.0f, 0.0f }; - Vec3f spBC = { 0.0f, 0.0f, 0.0f }; - - if (this->work[FHGFIRE_FIRE_MODE] >= FHGFIRE_LIGHT_BLUE) { - lightBallColor1 = FHGFLASH_LIGHTBALL_LIGHTBLUE; - } - for (i1 = 0; i1 < 3; i1++) { - spD4.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - spD4.y = Rand_CenteredFloat(20.0f) + this->actor.world.pos.y; - spD4.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - spBC.y = -0.08f; - EffectSsFhgFlash_SpawnLightBall(globalCtx, &spD4, &spC8, &spBC, (s16)(Rand_ZeroOne() * 80.0f) + 150, - lightBallColor1); - } - } - switch (this->work[FHGFIRE_FIRE_MODE]) { - case FHGFIRE_LIGHT_GREEN: - canBottleReflect1 = - ((player->stateFlags1 & 2) && - (ABS((s16)(player->actor.shape.rot.y - (s16)(bossGnd->actor.yawTowardsPlayer + 0x8000))) < - 0x2000) && - (sqrtf(SQ(dxL) + SQ(dyL) + SQ(dzL)) <= 25.0f)) - ? true - : false; - if ((this->collider.base.acFlags & AC_HIT) || canBottleReflect1) { - ColliderInfo* hurtbox = this->collider.info.acHitInfo; - s16 i2; - Vec3f spA8; - Vec3f sp9C = { 0.0f, -0.5f, 0.0f }; - s16 angleModX; - s16 angleModY; - - for (i2 = 0; i2 < 30; i2++) { - spA8.x = Rand_CenteredFloat(20.0f); - spA8.y = Rand_CenteredFloat(20.0f); - spA8.z = Rand_CenteredFloat(20.0f); - EffectSsFhgFlash_SpawnLightBall(globalCtx, &this->actor.world.pos, &spA8, &sp9C, - (s16)(Rand_ZeroOne() * 25.0f) + 50, FHGFLASH_LIGHTBALL_GREEN); - } - canBottleReflect2 = canBottleReflect1; - if (!canBottleReflect2 && (hurtbox->toucher.dmgFlags & 0x00100000)) { - killMode = BALL_IMPACT; - Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - func_800AA000(this->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); - } else { - if (bossGnd->flyMode == GND_FLY_NEUTRAL) { - angleModX = Rand_CenteredFloat(0x2000); - angleModY = Rand_CenteredFloat(0x2000); - this->actor.speedXZ = 15.0f; - } else { - angleModX = 0; - angleModY = 0; - this->work[FHGFIRE_RETURN_COUNT]++; - if ((this->work[FHGFIRE_RETURN_COUNT] > 3) && (Rand_ZeroOne() < 0.5f)) { - this->work[FHGFIRE_RETURN_COUNT] = 100; - } - - if (!canBottleReflect2 && (player->swordAnimation >= 24)) { - this->actor.speedXZ = 20.0f; - this->work[FHGFIRE_RETURN_COUNT] = 4; - } else { - this->actor.speedXZ += 1.0f; - } - } - this->actor.world.rot.y = (s16)(Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI)) + angleModY; - this->actor.world.rot.x = - (s16)(Math_FAtan2F(dyPG, sqrtf((dxPG * dxPG) + (dzPG * dzPG))) * (0x8000 / M_PI)) + - angleModX; - this->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_BLUE; - this->work[FHGFIRE_FX_TIMER] = 2; - Audio_PlaySoundGeneral(NA_SE_IT_SWORD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - func_800AA000(this->actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); - } - } else if (sqrtf(SQ(dxL) + SQ(dyL) + SQ(dzL)) <= 25.0f) { - killMode = BALL_BURST; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_HIT_THUNDER); - if ((bossGnd->flyMode >= GND_FLY_VOLLEY) && (this->work[FHGFIRE_RETURN_COUNT] >= 2)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_LAUGH); - } - func_8002F698(globalCtx, &this->actor, 3.0f, this->actor.world.rot.y, 0.0f, 3, 0x10); - } - break; - case FHGFIRE_LIGHT_BLUE: - if ((bossGnd->flyMode == GND_FLY_RETURN) && (this->work[FHGFIRE_RETURN_COUNT] < 100)) { - this->actor.world.rot.y = Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI); - if ((sqrtf(SQ(dxPG) + SQ(dzPG)) < (150.0f + (this->actor.speedXZ * 8.0f)))) { - this->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_REFLECT; - bossGnd->returnSuccess = true; - this->work[FHGFIRE_TIMER] = 8; - } - } else { - if (this->work[FHGFIRE_RETURN_COUNT] >= 100) { - if ((sqrtf(SQ(dxPG) + SQ(dyPG) + SQ(dzPG)) < 100.0f)) { - bossGnd->returnSuccess = true; - } - this->actor.world.rot.y = Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI); - this->actor.world.rot.x = Math_FAtan2F(dyPG, sqrtf(SQ(dxPG) + SQ(dzPG))) * (0x8000 / M_PI); - } - if ((fabsf(dxPG) < 30.0f) && (fabsf(dzPG) < 30.0f) && (fabsf(dyPG) < 45.0f)) { - killMode = BALL_IMPACT; - bossGnd->returnCount = this->work[FHGFIRE_RETURN_COUNT] + 1; - Audio_PlaySoundGeneral(NA_SE_EN_FANTOM_HIT_THUNDER, &bossGnd->actor.projectedPos, 4, - &D_801333E0, &D_801333E0, &D_801333E8); - Audio_PlaySoundGeneral(NA_SE_EN_FANTOM_DAMAGE, &bossGnd->actor.projectedPos, 4, &D_801333E0, - &D_801333E0, &D_801333E8); - } - } - break; - case FHGFIRE_LIGHT_REFLECT: - if (this->work[FHGFIRE_TIMER] == 0) { - s16 i3; - Vec3f sp88; - Vec3f sp7C = { 0.0f, -0.5f, 0.0f }; - - for (i3 = 0; i3 < 30; i3++) { - sp88.x = Rand_CenteredFloat(20.0f); - sp88.y = Rand_CenteredFloat(20.0f); - sp88.z = Rand_CenteredFloat(20.0f); - EffectSsFhgFlash_SpawnLightBall(globalCtx, &this->actor.world.pos, &sp88, &sp7C, - (s16)(Rand_ZeroOne() * 40.0f) + 80, FHGFLASH_LIGHTBALL_GREEN); - } - this->actor.world.rot.y = Math_FAtan2F(dxL, dzL) * (0x8000 / M_PI); - dxzL = sqrtf(SQ(dxL) + SQ(dzL)); - this->actor.world.rot.x = Math_FAtan2F(dyL, dxzL) * (0x8000 / M_PI); - this->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_GREEN; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SWORD_REFLECT_MG); - this->actor.speedXZ += 2.0f; - } - break; - } - - osSyncPrintf("F_FIRE_MODE %d\n", this->work[FHGFIRE_FIRE_MODE]); - osSyncPrintf("fly_mode %d\n", bossGnd->flyMode); - if (this->work[FHGFIRE_FX_TIMER] == 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 7); - if ((this->actor.bgCheckFlags & 0x19) || killMode) { - u8 lightBallColor2 = FHGFLASH_LIGHTBALL_GREEN; - s16 i4; - Vec3f sp6C; - Vec3f sp60 = { 0.0f, -1.0f, 0.0f }; - - if (this->work[FHGFIRE_FIRE_MODE] > FHGFIRE_LIGHT_GREEN) { - lightBallColor2 = FHGFLASH_LIGHTBALL_LIGHTBLUE; - } - for (i4 = 0; i4 < 30; i4++) { - sp6C.x = Rand_CenteredFloat(20.0f); - sp6C.y = Rand_CenteredFloat(20.0f); - sp6C.z = Rand_CenteredFloat(20.0f); - sp60.y = -0.1f; - EffectSsFhgFlash_SpawnLightBall(globalCtx, &this->actor.world.pos, &sp6C, &sp60, - (s16)(Rand_ZeroOne() * 50.0f) + 100, lightBallColor2); - } - if (killMode == BALL_BURST) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - this->actor.world.pos.x, player->actor.world.pos.y + 20.0f, - this->actor.world.pos.z, 0xC8, 0, 0, FHGFIRE_LIGHTNING_BURST); - } - bossGnd->flyMode = GND_FLY_NEUTRAL; - this->work[FHGFIRE_KILL_TIMER] = 30; - this->actor.draw = NULL; - if (killMode == BALL_FIZZLE) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_THUNDER_GND); - } - return; - } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - osSyncPrintf("BEFORE setAC %d\n", this->collider.base.shape); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - osSyncPrintf("AFTER setAC\n"); - } - } - Lights_PointNoGlowSetInfo(&this->lightInfo, (s16)this->actor.world.pos.x, (s16)this->actor.world.pos.y, - (s16)this->actor.world.pos.z, 255, 255, 255, 200); - if (this->actor.speedXZ > 20.0f) { - this->actor.speedXZ = 20.0f; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_FIRE - SFX_FLAG); - // "Why ah ah ah ah" - osSyncPrintf("なぜだああああああああ %d\n", this->work[FHGFIRE_VARIANCE_TIMER]); - } -} - -void EnFhgFire_PhantomWarp(EnFhgFire* this, GlobalContext* globalCtx) { - EnfHG* horse = (EnfHG*)this->actor.parent; - f32 scrollDirection; - - this->fwork[FHGFIRE_WARP_TEX_1_X] += 25.0f * this->fwork[FHGFIRE_WARP_TEX_SPEED]; - this->fwork[FHGFIRE_WARP_TEX_1_Y] -= 40.0f * this->fwork[FHGFIRE_WARP_TEX_SPEED]; - this->fwork[FHGFIRE_WARP_TEX_2_X] += 5.0f * this->fwork[FHGFIRE_WARP_TEX_SPEED]; - this->fwork[FHGFIRE_WARP_TEX_2_Y] -= 30.0f * this->fwork[FHGFIRE_WARP_TEX_SPEED]; - - if (this->actor.params == FHGFIRE_WARP_DEATH) { - if (this->work[FHGFIRE_TIMER] > 70) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FANTOM_WARP_L - SFX_FLAG); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FANTOM_WARP_L2 - SFX_FLAG); - } - - if (this->work[FHGFIRE_TIMER] == 70) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FANTOM_WARP_S); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FANTOM_WARP_S2); - } - } - - if (this->work[FHGFIRE_TIMER] > 50) { - scrollDirection = 1.0f; - if (this->actor.params > FHGFIRE_WARP_EMERGE) { - scrollDirection = -1.0f; - } - Math_ApproachF(&this->fwork[FHGFIRE_WARP_TEX_SPEED], scrollDirection, 1.0f, 0.04f); - Math_ApproachF(&this->fwork[FHGFIRE_WARP_ALPHA], 255.0f, 1.0f, 10.2f); - } else if (this->work[FHGFIRE_TIMER] <= 25) { - Math_ApproachZeroF(&this->fwork[FHGFIRE_WARP_TEX_SPEED], 1.0f, 0.04f); - Math_ApproachZeroF(&this->fwork[FHGFIRE_WARP_ALPHA], 1.0f, 10.2f); - } - - osSyncPrintf("EFC 1\n"); - if ((this->work[FHGFIRE_TIMER] == 0) || ((this->actor.params == FHGFIRE_WARP_EMERGE) && horse->fhgFireKillWarp)) { - Actor_Kill(&this->actor); - } - osSyncPrintf("EFC 2\n"); -} - -void EnFhgFire_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnFhgFire* this = (EnFhgFire*)thisx; - - this->work[FHGFIRE_VARIANCE_TIMER]++; - - if (this->work[FHGFIRE_TIMER] != 0) { - this->work[FHGFIRE_TIMER]--; - } - if (this->work[FHGFIRE_FX_TIMER] != 0) { - this->work[FHGFIRE_FX_TIMER]--; - } - - this->updateFunc(this, globalCtx); -} - -static void* sDustTextures[] = { - gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, -}; - -void EnFhgFire_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnFhgFire* this = (EnFhgFire*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1723); - - if (this->actor.params == FHGFIRE_LIGHTNING_BURST) { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->fwork[FHGFIRE_ALPHA]); - gDPSetEnvColor(POLY_XLU_DISP++, 165, 255, 75, 0); - gDPPipeSync(POLY_XLU_DISP++); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1745), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gPhantomLightningBlastDL)); - } else if ((this->actor.params == FHGFIRE_SPEAR_LIGHT) || (this->actor.params == FHGFIRE_ENERGY_BALL)) { - osSyncPrintf("yari hikari draw 1\n"); - func_800D1FD4(&globalCtx->billboardMtxF); - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->fwork[FHGFIRE_ALPHA]); - - if (this->work[FHGFIRE_FIRE_MODE] > FHGFIRE_LIGHT_GREEN) { - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 165, 255, 75, 0); - } - gDPPipeSync(POLY_XLU_DISP++); - Matrix_RotateZ((this->actor.shape.rot.z / (f32)0x8000) * 3.1416f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1801), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gPhantomEnergyBallDL); - } else if ((this->actor.params == FHGFIRE_WARP_EMERGE) || (this->actor.params == FHGFIRE_WARP_RETREAT) || - (this->actor.params == FHGFIRE_WARP_DEATH)) { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (u8)this->fwork[FHGFIRE_WARP_ALPHA]); - gDPSetEnvColor(POLY_XLU_DISP++, 90, 50, 95, (s8)(this->fwork[FHGFIRE_WARP_ALPHA] * 0.5f)); - gDPPipeSync(POLY_XLU_DISP++); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1833), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)this->fwork[FHGFIRE_WARP_TEX_1_X], - (s16)this->fwork[FHGFIRE_WARP_TEX_1_Y], 0x40, 0x40, 1, - (s16)this->fwork[FHGFIRE_WARP_TEX_2_X], (s16)this->fwork[FHGFIRE_WARP_TEX_2_Y], - 0x40, 0x40)); - gSPDisplayList(POLY_XLU_DISP++, gPhantomWarpDL); - } else { - osSyncPrintf("FF DRAW 1\n"); - Matrix_Translate(0.0f, -100.0f, 0.0f, MTXMODE_APPLY); - func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->fwork[FHGFIRE_ALPHA]); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 30, 0); - gDPPipeSync(POLY_XLU_DISP++); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1892), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gPhantomLightningDL); - osSyncPrintf("FF DRAW 2\n"); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1900); -} diff --git a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.cpp b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.cpp new file mode 100644 index 000000000..a3727cff2 --- /dev/null +++ b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.cpp @@ -0,0 +1,773 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FHG_FIRE_Z_EN_FHG_FIRE_C +#include "actor_common.h" +#include "z_kankyo.h" +/* + * File: z_en_fhg_fire.c + * Overlay: ovl_En_Fhg_Fire + * Description: Phantom Ganon's Lighting Attack + */ + +#include "z_en_fhg_fire.h" +#include "objects/object_fhg/object_fhg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h" +#include "overlays/actors/ovl_En_fHG/z_en_fhg.h" +#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_play.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +typedef enum { + /* 0 */ STRIKE_INIT, + /* 10 */ STRIKE_BURST = 10, + /* 11 */ STRIKE_TRAILS +} StrikeMode; + +typedef enum { + /* 0 */ TRAIL_INIT, + /* 1 */ TRAIL_APPEAR, + /* 2 */ TRAIL_DISSIPATE +} TrailMode; + +typedef enum { + /* 0 */ BALL_FIZZLE, + /* 1 */ BALL_BURST, + /* 2 */ BALL_IMPACT +} BallKillMode; + +void EnFhgFire_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFhgFire_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFhgFire_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFhgFire_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnFhgFire_LightningStrike(EnFhgFire* pthis, GlobalContext* globalCtx); +void EnFhgFire_LightningTrail(EnFhgFire* pthis, GlobalContext* globalCtx); +void EnFhgFire_LightningShock(EnFhgFire* pthis, GlobalContext* globalCtx); +void EnFhgFire_LightningBurst(EnFhgFire* pthis, GlobalContext* globalCtx); +void EnFhgFire_SpearLight(EnFhgFire* pthis, GlobalContext* globalCtx); +void EnFhgFire_EnergyBall(EnFhgFire* pthis, GlobalContext* globalCtx); +void EnFhgFire_PhantomWarp(EnFhgFire* pthis, GlobalContext* globalCtx); + +ActorInit En_Fhg_Fire_InitVars = { + 0, + ACTORCAT_BOSS, + FLAGS, + OBJECT_FHG, + sizeof(EnFhgFire), + (ActorFunc)EnFhgFire_Init, + (ActorFunc)EnFhgFire_Destroy, + (ActorFunc)EnFhgFire_Update, + (ActorFunc)EnFhgFire_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK6, + { 0x00100700, 0x03, 0x20 }, + { 0x0D900700, 0x00, 0x00 }, + TOUCH_ON, + BUMP_ON, + OCELEM_ON, + }, + { 20, 30, 10, { 0, 0, 0 } }, +}; + +void EnFhgFire_SetUpdate(EnFhgFire* pthis, EnFhgFireUpdateFunc updateFunc) { + pthis->updateFunc = updateFunc; +} + +void EnFhgFire_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFhgFire* pthis = (EnFhgFire*)thisx; + Player* player = GET_PLAYER(globalCtx); + + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + if ((pthis->actor.params == FHGFIRE_LIGHTNING_SHOCK) || (pthis->actor.params == FHGFIRE_LIGHTNING_BURST) || + (pthis->actor.params == FHGFIRE_ENERGY_BALL)) { + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + } + pthis->fwork[FHGFIRE_ALPHA] = 200.0f; + Actor_SetScale(&pthis->actor, 0.0f); + + if (pthis->actor.params == FHGFIRE_LIGHTNING_STRIKE) { + EnFhgFire_SetUpdate(pthis, EnFhgFire_LightningStrike); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_THUNDER); + } else if (pthis->actor.params >= FHGFIRE_LIGHTNING_TRAIL) { + EnFhgFire_SetUpdate(pthis, EnFhgFire_LightningTrail); + pthis->actor.shape.rot = pthis->actor.world.rot; + } + if (pthis->actor.params == FHGFIRE_LIGHTNING_SHOCK) { + pthis->actor.draw = NULL; + EnFhgFire_SetUpdate(pthis, EnFhgFire_LightningShock); + pthis->actor.speedXZ = 30.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_SPARK); + } else if (pthis->actor.params == FHGFIRE_LIGHTNING_BURST) { + EnFhgFire_SetUpdate(pthis, EnFhgFire_LightningBurst); + pthis->fwork[FHGFIRE_ALPHA] = 255.0f; + pthis->work[FHGFIRE_TIMER] = 32; + pthis->work[FHGFIRE_FX_TIMER] = 50; + pthis->lensFlareTimer = 10; + + pthis->fwork[FHGFIRE_BURST_SCALE] = pthis->actor.world.rot.x / 100.0f; + pthis->collider.dim.radius = pthis->actor.world.rot.x * 0.13f; + pthis->collider.dim.height = pthis->actor.world.rot.x * 0.13f; + pthis->collider.dim.yShift = 0; + } else if (pthis->actor.params == FHGFIRE_SPEAR_LIGHT) { + osSyncPrintf("yari hikari ct 1\n"); // "light spear" + EnFhgFire_SetUpdate(pthis, EnFhgFire_SpearLight); + osSyncPrintf("yari hikari ct 2\n"); + pthis->work[FHGFIRE_TIMER] = pthis->actor.world.rot.x; + pthis->work[FHGFIRE_FIRE_MODE] = pthis->actor.world.rot.y; + } else if ((pthis->actor.params == FHGFIRE_WARP_EMERGE) || (pthis->actor.params == FHGFIRE_WARP_RETREAT) || + (pthis->actor.params == FHGFIRE_WARP_DEATH)) { + Actor_SetScale(&pthis->actor, 7.0f); + EnFhgFire_SetUpdate(pthis, EnFhgFire_PhantomWarp); + if (pthis->actor.params == FHGFIRE_WARP_DEATH) { + pthis->work[FHGFIRE_TIMER] = 440; + pthis->actor.scale.z = 1.0f; + } else { + pthis->work[FHGFIRE_TIMER] = 76; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FANTOM_WARP_S); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FANTOM_WARP_S2); + } + } else if (pthis->actor.params == FHGFIRE_ENERGY_BALL) { + f32 dxL; + f32 dyL; + f32 dzL; + f32 dxzL; + + pthis->actor.speedXZ = (pthis->actor.world.rot.x == 0) ? 8.0f : 3.0f; + EnFhgFire_SetUpdate(pthis, EnFhgFire_EnergyBall); + + pthis->work[FHGFIRE_TIMER] = 70; + pthis->work[FHGFIRE_FX_TIMER] = 2; + + dxL = player->actor.world.pos.x - pthis->actor.world.pos.x; + dyL = player->actor.world.pos.y + 30.0f - pthis->actor.world.pos.y; + dzL = player->actor.world.pos.z - pthis->actor.world.pos.z; + pthis->actor.world.rot.y = Math_FAtan2F(dxL, dzL) * (0x8000 / M_PI); + dxzL = sqrtf(SQ(dxL) + SQ(dzL)); + pthis->actor.world.rot.x = Math_FAtan2F(dyL, dxzL) * (0x8000 / M_PI); + pthis->collider.dim.radius = 40; + pthis->collider.dim.height = 50; + pthis->collider.dim.yShift = -25; + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, 255); + } +} + +void EnFhgFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFhgFire* pthis = (EnFhgFire*)thisx; + + if ((pthis->actor.params == FHGFIRE_LIGHTNING_SHOCK) || (pthis->actor.params == FHGFIRE_LIGHTNING_BURST) || + (pthis->actor.params == FHGFIRE_ENERGY_BALL)) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } + + if (pthis->actor.params == FHGFIRE_ENERGY_BALL) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + } +} + +void EnFhgFire_LightningStrike(EnFhgFire* pthis, GlobalContext* globalCtx) { + Camera* camera = Gameplay_GetCamera(globalCtx, 0); + s16 i; + + switch (pthis->work[FHGFIRE_FIRE_MODE]) { + case STRIKE_INIT: + pthis->work[FHGFIRE_FIRE_MODE] = STRIKE_BURST; + pthis->work[FHGFIRE_TIMER] = 7; + break; + case STRIKE_BURST: + pthis->actor.shape.rot.y = + Camera_GetInputDirYaw(camera) + 0x8000 * (pthis->work[FHGFIRE_VARIANCE_TIMER] & 0xFF); + Math_ApproachF(&pthis->fwork[FHGFIRE_SCALE], 1.0f, 1.0f, 0.2f); + + if (pthis->work[FHGFIRE_TIMER] == 0) { + pthis->work[FHGFIRE_FIRE_MODE] = STRIKE_TRAILS; + pthis->actor.shape.rot.z += 0x8000; + pthis->work[FHGFIRE_TIMER] = 37; + pthis->actor.world.pos.y -= 200.0f; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 500, 0, 0, + FHGFIRE_LIGHTNING_BURST); + { + Vec3f sp7C; + Vec3f sp70 = { 0.0f, -1.0f, 0.0f }; + + for (i = 0; i < 35; i++) { + sp7C.x = Rand_CenteredFloat(30.f); + sp7C.y = Rand_ZeroFloat(5.0f) + 3.0f; + sp7C.z = Rand_CenteredFloat(30.f); + sp70.y = -0.2f; + EffectSsFhgFlash_SpawnLightBall(globalCtx, &pthis->actor.world.pos, &sp7C, &sp70, + (s16)(Rand_ZeroOne() * 100.0f) + 240, FHGFLASH_LIGHTBALL_GREEN); + } + } + func_80033E88(&pthis->actor, globalCtx, 4, 10); + } + + break; + case STRIKE_TRAILS: + pthis->actor.shape.rot.y = + Camera_GetInputDirYaw(camera) + (pthis->work[FHGFIRE_VARIANCE_TIMER] & 0xFF) * 0x8000; + + Math_ApproachF(&pthis->fwork[FHGFIRE_SCALE], 0.0f, 1.0f, 0.2f); + if (pthis->work[FHGFIRE_TIMER] == 30) { + s16 randY = (Rand_ZeroOne() < 0.5f) ? 0x1000 : 0; + + for (i = 0; i < 8; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, + (i * 0x2000) + randY, 0x4000, FHGFIRE_LIGHTNING_TRAIL + i); + } + + for (i = 0; i < 8; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, + (i * 0x2000) + randY, 0, FHGFIRE_LIGHTNING_SHOCK); + } + } + + if (pthis->work[FHGFIRE_TIMER] == 0) { + Actor_Kill(&pthis->actor); + } + } + + Actor_SetScale(&pthis->actor, pthis->fwork[FHGFIRE_SCALE]); +} + +void EnFhgFire_LightningTrail(EnFhgFire* pthis, GlobalContext* globalCtx) { + osSyncPrintf("FF MOVE 1\n"); + pthis->actor.shape.rot.x += (s16)(Rand_ZeroOne() * 4000.0f) + 0x4000; + + switch (pthis->work[FHGFIRE_FIRE_MODE]) { + case TRAIL_INIT: + pthis->work[FHGFIRE_FIRE_MODE] = TRAIL_APPEAR; + pthis->work[FHGFIRE_TIMER] = (s16)(Rand_ZeroOne() * 7.0f) + 7; + case TRAIL_APPEAR: + Math_ApproachF(&pthis->fwork[FHGFIRE_SCALE], 1.7f, 1.0f, 0.34f); + + if (pthis->work[FHGFIRE_TIMER] == 0) { + pthis->work[FHGFIRE_FIRE_MODE] = TRAIL_DISSIPATE; + pthis->work[FHGFIRE_TIMER] = 10; + pthis->actor.world.pos.z += Math_SinS(pthis->actor.shape.rot.y) * -200.0f * pthis->fwork[FHGFIRE_SCALE]; + pthis->actor.world.pos.x += Math_CosS(pthis->actor.shape.rot.y) * 200.0f * pthis->fwork[FHGFIRE_SCALE]; + pthis->actor.shape.rot.y += 0x8000; + } + break; + case TRAIL_DISSIPATE: + Math_ApproachZeroF(&pthis->fwork[FHGFIRE_SCALE], 1.0f, 0.34f); + if (pthis->work[FHGFIRE_TIMER] == 0) { + Actor_Kill(&pthis->actor); + } + break; + } + + Actor_SetScale(&pthis->actor, pthis->fwork[FHGFIRE_SCALE]); + if (pthis->actor.scale.x > 1.0f) { + pthis->actor.scale.x = 1.0f; + } + + osSyncPrintf("FF MOVE 2\n"); +} + +void EnFhgFire_LightningShock(EnFhgFire* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f pos; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_HIT_THUNDER); + } + + if (Rand_ZeroOne() < 0.5f) { + pos = pthis->actor.world.pos; + pos.y -= 20.0f; + EffectSsFhgFlash_SpawnShock(globalCtx, &pthis->actor, &pos, 200, FHGFLASH_SHOCK_NO_ACTOR); + } + + Actor_MoveForward(&pthis->actor); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (player->invincibilityTimer == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 1); + if (pthis->actor.bgCheckFlags & 8) { + Actor_Kill(&pthis->actor); + } +} + +void EnFhgFire_LightningBurst(EnFhgFire* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + globalCtx->envCtx.fillScreen = true; + pthis->actor.shape.rot.y += 0x1000; + + if (pthis->work[FHGFIRE_FX_TIMER] == 49) { + globalCtx->envCtx.unk_BF = 1; + globalCtx->envCtx.unk_D6 = 0xFF; + } + if (pthis->work[FHGFIRE_FX_TIMER] == 31) { + globalCtx->envCtx.unk_BF = 0x00; + globalCtx->envCtx.unk_D6 = 0x14; + } + if (pthis->work[FHGFIRE_FX_TIMER] >= 48) { + globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = + globalCtx->envCtx.screenFillColor[2] = 255; + + if ((pthis->work[FHGFIRE_TIMER] % 2) != 0) { + globalCtx->envCtx.screenFillColor[3] = 70; + } else { + globalCtx->envCtx.screenFillColor[3] = 0; + } + } else { + globalCtx->envCtx.screenFillColor[3] = 0; + } + + if (pthis->work[FHGFIRE_TIMER] <= 20) { + Math_ApproachZeroF(&pthis->fwork[FHGFIRE_ALPHA], 1.0f, 45.0f); + Math_ApproachZeroF(&pthis->fwork[FHGFIRE_SCALE], 1.0f, 0.5f); + } else { + Math_ApproachF(&pthis->fwork[FHGFIRE_SCALE], pthis->fwork[FHGFIRE_BURST_SCALE], 0.5f, 3.0f); + } + + Actor_SetScale(&pthis->actor, pthis->fwork[FHGFIRE_SCALE]); + if (pthis->fwork[FHGFIRE_BURST_SCALE] > 3.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (player->invincibilityTimer == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + if (pthis->work[FHGFIRE_TIMER] == 0) { + Actor_Kill(&pthis->actor); + globalCtx->envCtx.fillScreen = false; + } + + if (pthis->lensFlareTimer != 0) { + pthis->lensFlareTimer--; + pthis->lensFlareOn = true; + Math_ApproachF(&pthis->lensFlareScale, 40.0f, 0.3f, 10.0f); + } else { + Math_ApproachZeroF(&pthis->lensFlareScale, 1.0f, 5.0f); + if (pthis->lensFlareScale == 0.0f) { + pthis->lensFlareOn = false; + } + } + + gCustomLensFlareOn = pthis->lensFlareOn; + gCustomLensFlarePos = pthis->actor.world.pos; + gLensFlareScale = pthis->lensFlareScale; + gLensFlareColorIntensity = 10.0f; + gLensFlareScreenFillAlpha = 0; +} + +void EnFhgFire_SpearLight(EnFhgFire* pthis, GlobalContext* globalCtx) { + BossGanondrof* bossGnd; + s16 i; + + osSyncPrintf("yari hikari 1\n"); + bossGnd = (BossGanondrof*)pthis->actor.parent; + if ((pthis->work[FHGFIRE_VARIANCE_TIMER] % 2) != 0) { + Actor_SetScale(&pthis->actor, 6.0f); + } else { + Actor_SetScale(&pthis->actor, 5.25f); + } + + pthis->actor.world.pos = bossGnd->spearTip; + pthis->actor.shape.rot.z += (s16)(Rand_ZeroOne() * 0x4E20) + 0x4000; + + osSyncPrintf("yari hikari 2\n"); + if (pthis->work[FHGFIRE_FIRE_MODE] == FHGFIRE_LIGHT_GREEN) { + Vec3f ballPos; + Vec3f ballVel = { 0.0f, 0.0f, 0.0f }; + Vec3f ballAccel = { 0.0f, 0.0f, 0.0f }; + + osSyncPrintf("FLASH !!\n"); + + for (i = 0; i < 2; i++) { + ballPos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + ballPos.y = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.y; + ballPos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + ballAccel.y = -0.08f; + + EffectSsFhgFlash_SpawnLightBall(globalCtx, &ballPos, &ballVel, &ballAccel, + (s16)(Rand_ZeroOne() * 80.0f) + 150, FHGFLASH_LIGHTBALL_GREEN); + } + } + + if (pthis->work[FHGFIRE_TIMER] == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnFhgFire_EnergyBall(EnFhgFire* pthis, GlobalContext* globalCtx) { + f32 dxL; + f32 dyL; + f32 dzL; + f32 dxzL; + f32 dxPG; + f32 dyPG; + f32 dzPG; + u8 killMode = BALL_FIZZLE; + u8 canBottleReflect1; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->work[FHGFIRE_KILL_TIMER] != 0) { + pthis->work[FHGFIRE_KILL_TIMER]--; + if (pthis->work[FHGFIRE_KILL_TIMER] == 0) { + Actor_Kill(&pthis->actor); + return; + } + } else { + s32 canBottleReflect2; + BossGanondrof* bossGnd = (BossGanondrof*)pthis->actor.parent; + + dxPG = bossGnd->targetPos.x - pthis->actor.world.pos.x; + dyPG = bossGnd->targetPos.y - pthis->actor.world.pos.y; + dzPG = bossGnd->targetPos.z - pthis->actor.world.pos.z; + dxL = player->actor.world.pos.x - pthis->actor.world.pos.x; + dyL = player->actor.world.pos.y + 40.0f - pthis->actor.world.pos.y; + dzL = player->actor.world.pos.z - pthis->actor.world.pos.z; + func_8002D908(&pthis->actor); + func_8002D7EC(&pthis->actor); + if (pthis->work[FHGFIRE_VARIANCE_TIMER] & 1) { + Actor_SetScale(&pthis->actor, 6.0f); + } else { + Actor_SetScale(&pthis->actor, 5.25f); + } + pthis->actor.shape.rot.z += (s16)(Rand_ZeroOne() * 0x4E20) + 0x4000; + { + u8 lightBallColor1 = FHGFLASH_LIGHTBALL_GREEN; + s16 i1; + Vec3f spD4; + Vec3f spC8 = { 0.0f, 0.0f, 0.0f }; + Vec3f spBC = { 0.0f, 0.0f, 0.0f }; + + if (pthis->work[FHGFIRE_FIRE_MODE] >= FHGFIRE_LIGHT_BLUE) { + lightBallColor1 = FHGFLASH_LIGHTBALL_LIGHTBLUE; + } + for (i1 = 0; i1 < 3; i1++) { + spD4.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + spD4.y = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.y; + spD4.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + spBC.y = -0.08f; + EffectSsFhgFlash_SpawnLightBall(globalCtx, &spD4, &spC8, &spBC, (s16)(Rand_ZeroOne() * 80.0f) + 150, + lightBallColor1); + } + } + switch (pthis->work[FHGFIRE_FIRE_MODE]) { + case FHGFIRE_LIGHT_GREEN: + canBottleReflect1 = + ((player->stateFlags1 & 2) && + (ABS((s16)(player->actor.shape.rot.y - (s16)(bossGnd->actor.yawTowardsPlayer + 0x8000))) < + 0x2000) && + (sqrtf(SQ(dxL) + SQ(dyL) + SQ(dzL)) <= 25.0f)) + ? true + : false; + if ((pthis->collider.base.acFlags & AC_HIT) || canBottleReflect1) { + ColliderInfo* hurtbox = pthis->collider.info.acHitInfo; + s16 i2; + Vec3f spA8; + Vec3f sp9C = { 0.0f, -0.5f, 0.0f }; + s16 angleModX; + s16 angleModY; + + for (i2 = 0; i2 < 30; i2++) { + spA8.x = Rand_CenteredFloat(20.0f); + spA8.y = Rand_CenteredFloat(20.0f); + spA8.z = Rand_CenteredFloat(20.0f); + EffectSsFhgFlash_SpawnLightBall(globalCtx, &pthis->actor.world.pos, &spA8, &sp9C, + (s16)(Rand_ZeroOne() * 25.0f) + 50, FHGFLASH_LIGHTBALL_GREEN); + } + canBottleReflect2 = canBottleReflect1; + if (!canBottleReflect2 && (hurtbox->toucher.dmgFlags & 0x00100000)) { + killMode = BALL_IMPACT; + Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); + } else { + if (bossGnd->flyMode == GND_FLY_NEUTRAL) { + angleModX = Rand_CenteredFloat(0x2000); + angleModY = Rand_CenteredFloat(0x2000); + pthis->actor.speedXZ = 15.0f; + } else { + angleModX = 0; + angleModY = 0; + pthis->work[FHGFIRE_RETURN_COUNT]++; + if ((pthis->work[FHGFIRE_RETURN_COUNT] > 3) && (Rand_ZeroOne() < 0.5f)) { + pthis->work[FHGFIRE_RETURN_COUNT] = 100; + } + + if (!canBottleReflect2 && (player->swordAnimation >= 24)) { + pthis->actor.speedXZ = 20.0f; + pthis->work[FHGFIRE_RETURN_COUNT] = 4; + } else { + pthis->actor.speedXZ += 1.0f; + } + } + pthis->actor.world.rot.y = (s16)(Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI)) + angleModY; + pthis->actor.world.rot.x = + (s16)(Math_FAtan2F(dyPG, sqrtf((dxPG * dxPG) + (dzPG * dzPG))) * (0x8000 / M_PI)) + + angleModX; + pthis->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_BLUE; + pthis->work[FHGFIRE_FX_TIMER] = 2; + Audio_PlaySoundGeneral(NA_SE_IT_SWORD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xB4, 0x14, 0x64); + } + } else if (sqrtf(SQ(dxL) + SQ(dyL) + SQ(dzL)) <= 25.0f) { + killMode = BALL_BURST; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_HIT_THUNDER); + if ((bossGnd->flyMode >= GND_FLY_VOLLEY) && (pthis->work[FHGFIRE_RETURN_COUNT] >= 2)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_LAUGH); + } + func_8002F698(globalCtx, &pthis->actor, 3.0f, pthis->actor.world.rot.y, 0.0f, 3, 0x10); + } + break; + case FHGFIRE_LIGHT_BLUE: + if ((bossGnd->flyMode == GND_FLY_RETURN) && (pthis->work[FHGFIRE_RETURN_COUNT] < 100)) { + pthis->actor.world.rot.y = Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI); + if ((sqrtf(SQ(dxPG) + SQ(dzPG)) < (150.0f + (pthis->actor.speedXZ * 8.0f)))) { + pthis->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_REFLECT; + bossGnd->returnSuccess = true; + pthis->work[FHGFIRE_TIMER] = 8; + } + } else { + if (pthis->work[FHGFIRE_RETURN_COUNT] >= 100) { + if ((sqrtf(SQ(dxPG) + SQ(dyPG) + SQ(dzPG)) < 100.0f)) { + bossGnd->returnSuccess = true; + } + pthis->actor.world.rot.y = Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI); + pthis->actor.world.rot.x = Math_FAtan2F(dyPG, sqrtf(SQ(dxPG) + SQ(dzPG))) * (0x8000 / M_PI); + } + if ((fabsf(dxPG) < 30.0f) && (fabsf(dzPG) < 30.0f) && (fabsf(dyPG) < 45.0f)) { + killMode = BALL_IMPACT; + bossGnd->returnCount = pthis->work[FHGFIRE_RETURN_COUNT] + 1; + Audio_PlaySoundGeneral(NA_SE_EN_FANTOM_HIT_THUNDER, &bossGnd->actor.projectedPos, 4, + &D_801333E0, &D_801333E0, &D_801333E8); + Audio_PlaySoundGeneral(NA_SE_EN_FANTOM_DAMAGE, &bossGnd->actor.projectedPos, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + } + } + break; + case FHGFIRE_LIGHT_REFLECT: + if (pthis->work[FHGFIRE_TIMER] == 0) { + s16 i3; + Vec3f sp88; + Vec3f sp7C = { 0.0f, -0.5f, 0.0f }; + + for (i3 = 0; i3 < 30; i3++) { + sp88.x = Rand_CenteredFloat(20.0f); + sp88.y = Rand_CenteredFloat(20.0f); + sp88.z = Rand_CenteredFloat(20.0f); + EffectSsFhgFlash_SpawnLightBall(globalCtx, &pthis->actor.world.pos, &sp88, &sp7C, + (s16)(Rand_ZeroOne() * 40.0f) + 80, FHGFLASH_LIGHTBALL_GREEN); + } + pthis->actor.world.rot.y = Math_FAtan2F(dxL, dzL) * (0x8000 / M_PI); + dxzL = sqrtf(SQ(dxL) + SQ(dzL)); + pthis->actor.world.rot.x = Math_FAtan2F(dyL, dxzL) * (0x8000 / M_PI); + pthis->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_GREEN; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SWORD_REFLECT_MG); + pthis->actor.speedXZ += 2.0f; + } + break; + } + + osSyncPrintf("F_FIRE_MODE %d\n", pthis->work[FHGFIRE_FIRE_MODE]); + osSyncPrintf("fly_mode %d\n", bossGnd->flyMode); + if (pthis->work[FHGFIRE_FX_TIMER] == 0) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 7); + if ((pthis->actor.bgCheckFlags & 0x19) || killMode) { + u8 lightBallColor2 = FHGFLASH_LIGHTBALL_GREEN; + s16 i4; + Vec3f sp6C; + Vec3f sp60 = { 0.0f, -1.0f, 0.0f }; + + if (pthis->work[FHGFIRE_FIRE_MODE] > FHGFIRE_LIGHT_GREEN) { + lightBallColor2 = FHGFLASH_LIGHTBALL_LIGHTBLUE; + } + for (i4 = 0; i4 < 30; i4++) { + sp6C.x = Rand_CenteredFloat(20.0f); + sp6C.y = Rand_CenteredFloat(20.0f); + sp6C.z = Rand_CenteredFloat(20.0f); + sp60.y = -0.1f; + EffectSsFhgFlash_SpawnLightBall(globalCtx, &pthis->actor.world.pos, &sp6C, &sp60, + (s16)(Rand_ZeroOne() * 50.0f) + 100, lightBallColor2); + } + if (killMode == BALL_BURST) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + pthis->actor.world.pos.x, player->actor.world.pos.y + 20.0f, + pthis->actor.world.pos.z, 0xC8, 0, 0, FHGFIRE_LIGHTNING_BURST); + } + bossGnd->flyMode = GND_FLY_NEUTRAL; + pthis->work[FHGFIRE_KILL_TIMER] = 30; + pthis->actor.draw = NULL; + if (killMode == BALL_FIZZLE) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_THUNDER_GND); + } + return; + } else { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + osSyncPrintf("BEFORE setAC %d\n", pthis->collider.base.shape); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + osSyncPrintf("AFTER setAC\n"); + } + } + Lights_PointNoGlowSetInfo(&pthis->lightInfo, (s16)pthis->actor.world.pos.x, (s16)pthis->actor.world.pos.y, + (s16)pthis->actor.world.pos.z, 255, 255, 255, 200); + if (pthis->actor.speedXZ > 20.0f) { + pthis->actor.speedXZ = 20.0f; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_FIRE - SFX_FLAG); + // "Why ah ah ah ah" + osSyncPrintf("なぜだああああああああ %d\n", pthis->work[FHGFIRE_VARIANCE_TIMER]); + } +} + +void EnFhgFire_PhantomWarp(EnFhgFire* pthis, GlobalContext* globalCtx) { + EnfHG* horse = (EnfHG*)pthis->actor.parent; + f32 scrollDirection; + + pthis->fwork[FHGFIRE_WARP_TEX_1_X] += 25.0f * pthis->fwork[FHGFIRE_WARP_TEX_SPEED]; + pthis->fwork[FHGFIRE_WARP_TEX_1_Y] -= 40.0f * pthis->fwork[FHGFIRE_WARP_TEX_SPEED]; + pthis->fwork[FHGFIRE_WARP_TEX_2_X] += 5.0f * pthis->fwork[FHGFIRE_WARP_TEX_SPEED]; + pthis->fwork[FHGFIRE_WARP_TEX_2_Y] -= 30.0f * pthis->fwork[FHGFIRE_WARP_TEX_SPEED]; + + if (pthis->actor.params == FHGFIRE_WARP_DEATH) { + if (pthis->work[FHGFIRE_TIMER] > 70) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FANTOM_WARP_L - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FANTOM_WARP_L2 - SFX_FLAG); + } + + if (pthis->work[FHGFIRE_TIMER] == 70) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FANTOM_WARP_S); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FANTOM_WARP_S2); + } + } + + if (pthis->work[FHGFIRE_TIMER] > 50) { + scrollDirection = 1.0f; + if (pthis->actor.params > FHGFIRE_WARP_EMERGE) { + scrollDirection = -1.0f; + } + Math_ApproachF(&pthis->fwork[FHGFIRE_WARP_TEX_SPEED], scrollDirection, 1.0f, 0.04f); + Math_ApproachF(&pthis->fwork[FHGFIRE_WARP_ALPHA], 255.0f, 1.0f, 10.2f); + } else if (pthis->work[FHGFIRE_TIMER] <= 25) { + Math_ApproachZeroF(&pthis->fwork[FHGFIRE_WARP_TEX_SPEED], 1.0f, 0.04f); + Math_ApproachZeroF(&pthis->fwork[FHGFIRE_WARP_ALPHA], 1.0f, 10.2f); + } + + osSyncPrintf("EFC 1\n"); + if ((pthis->work[FHGFIRE_TIMER] == 0) || ((pthis->actor.params == FHGFIRE_WARP_EMERGE) && horse->fhgFireKillWarp)) { + Actor_Kill(&pthis->actor); + } + osSyncPrintf("EFC 2\n"); +} + +void EnFhgFire_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFhgFire* pthis = (EnFhgFire*)thisx; + + pthis->work[FHGFIRE_VARIANCE_TIMER]++; + + if (pthis->work[FHGFIRE_TIMER] != 0) { + pthis->work[FHGFIRE_TIMER]--; + } + if (pthis->work[FHGFIRE_FX_TIMER] != 0) { + pthis->work[FHGFIRE_FX_TIMER]--; + } + + pthis->updateFunc(pthis, globalCtx); +} + +static void* sDustTextures[] = { + gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, +}; + +void EnFhgFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFhgFire* pthis = (EnFhgFire*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1723); + + if (pthis->actor.params == FHGFIRE_LIGHTNING_BURST) { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)pthis->fwork[FHGFIRE_ALPHA]); + gDPSetEnvColor(POLY_XLU_DISP++, 165, 255, 75, 0); + gDPPipeSync(POLY_XLU_DISP++); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1745), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gPhantomLightningBlastDL)); + } else if ((pthis->actor.params == FHGFIRE_SPEAR_LIGHT) || (pthis->actor.params == FHGFIRE_ENERGY_BALL)) { + osSyncPrintf("yari hikari draw 1\n"); + func_800D1FD4(&globalCtx->billboardMtxF); + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)pthis->fwork[FHGFIRE_ALPHA]); + + if (pthis->work[FHGFIRE_FIRE_MODE] > FHGFIRE_LIGHT_GREEN) { + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 165, 255, 75, 0); + } + gDPPipeSync(POLY_XLU_DISP++); + Matrix_RotateZ((pthis->actor.shape.rot.z / (f32)0x8000) * 3.1416f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1801), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gPhantomEnergyBallDL); + } else if ((pthis->actor.params == FHGFIRE_WARP_EMERGE) || (pthis->actor.params == FHGFIRE_WARP_RETREAT) || + (pthis->actor.params == FHGFIRE_WARP_DEATH)) { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (u8)pthis->fwork[FHGFIRE_WARP_ALPHA]); + gDPSetEnvColor(POLY_XLU_DISP++, 90, 50, 95, (s8)(pthis->fwork[FHGFIRE_WARP_ALPHA] * 0.5f)); + gDPPipeSync(POLY_XLU_DISP++); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1833), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (s16)pthis->fwork[FHGFIRE_WARP_TEX_1_X], + (s16)pthis->fwork[FHGFIRE_WARP_TEX_1_Y], 0x40, 0x40, 1, + (s16)pthis->fwork[FHGFIRE_WARP_TEX_2_X], (s16)pthis->fwork[FHGFIRE_WARP_TEX_2_Y], + 0x40, 0x40)); + gSPDisplayList(POLY_XLU_DISP++, gPhantomWarpDL); + } else { + osSyncPrintf("FF DRAW 1\n"); + Matrix_Translate(0.0f, -100.0f, 0.0f, MTXMODE_APPLY); + func_80093D84(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)pthis->fwork[FHGFIRE_ALPHA]); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 30, 0); + gDPPipeSync(POLY_XLU_DISP++); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1892), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gPhantomLightningDL); + osSyncPrintf("FF DRAW 2\n"); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg_fire.c", 1900); +} diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c deleted file mode 100644 index 08ebff79a..000000000 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ /dev/null @@ -1,402 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FIRE_ROCK_Z_EN_FIRE_ROCK_C -#include "actor_common.h" -#include "z_en_fire_rock.h" -#include "overlays/actors/ovl_En_Encount2/z_en_encount2.h" -#include "vt.h" -#include "objects/object_efc_star_field/object_efc_star_field.h" -#include "def/code_8006BA00.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnFireRock_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFireRock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFireRock_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFireRock_Draw(Actor* thisx, GlobalContext* globalCtx); - -void FireRock_WaitSpawnRocksFromCeiling(EnFireRock* this, GlobalContext* globalCtx); -void FireRock_WaitOnFloor(EnFireRock* this, GlobalContext* globalCtx); -void EnFireRock_Fall(EnFireRock* this, GlobalContext* globalCtx); -void EnFireRock_SpawnMoreBrokenPieces(EnFireRock* this, GlobalContext* globalCtx); - -const ActorInit En_Fire_Rock_InitVars = { - ACTOR_EN_FIRE_ROCK, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_EFC_STAR_FIELD, - sizeof(EnFireRock), - (ActorFunc)EnFireRock_Init, - (ActorFunc)EnFireRock_Destroy, - (ActorFunc)EnFireRock_Update, - (ActorFunc)EnFireRock_Draw, -}; - -static ColliderCylinderInit D_80A12CA0 = { - { - COLTYPE_HARD, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x09, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 30, 30, -10, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit D_80A12CCC = { - { - COLTYPE_HARD, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 30, 30, -10, { 0, 0, 0 } }, -}; - -void EnFireRock_Init(Actor* thisx, GlobalContext* globalCtx) { - GlobalContext* globalCtx2 = globalCtx; - Player* player = GET_PLAYER(globalCtx); - EnFireRock* this = (EnFireRock*)thisx; - s16 temp; - - this->type = this->actor.params; - if (this->type != FIRE_ROCK_CEILING_SPOT_SPAWNER) { - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 15.0f); - if (this->type != FIRE_ROCK_ON_FLOOR) { - this->angularVelocity.x = (Rand_ZeroFloat(10.0f) + 15.0f); - this->angularVelocity.y = (Rand_ZeroFloat(10.0f) + 15.0f); - this->angularVelocity.z = (Rand_ZeroFloat(10.0f) + 15.0f); - } - } - switch (this->type) { - case FIRE_ROCK_CEILING_SPOT_SPAWNER: - this->actor.draw = NULL; - // "☆☆☆☆☆ ceiling waiting rock ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 天井待ち岩 ☆☆☆☆☆ \n" VT_RST); - this->actionFunc = FireRock_WaitSpawnRocksFromCeiling; - break; - case FIRE_ROCK_ON_FLOOR: - Actor_SetScale(&this->actor, 0.03f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80A12CCC); - // "☆☆☆☆☆ floor rock ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 床岩 ☆☆☆☆☆ \n" VT_RST); - this->collider.dim.radius = 23; - this->collider.dim.height = 37; - this->collider.dim.yShift = -10; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actionFunc = FireRock_WaitOnFloor; - break; - case FIRE_ROCK_SPAWNED_FALLING1: // spawned by encount2 - // sets unused vars? - this->unk17C.x = (f32)(Rand_CenteredFloat(50.0f) + player->actor.world.pos.x); - this->unk17C.z = (f32)(Rand_CenteredFloat(50.0f) + player->actor.world.pos.z); - case FIRE_ROCK_SPAWNED_FALLING2: // spawned by encount2 and by the ceilling spawner - this->scale = (Rand_ZeroFloat(2.0f) / 100.0f) + 0.02f; - Actor_SetScale(&this->actor, this->scale); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80A12CA0); - this->actor.world.rot.y = this->actor.shape.rot.y = Rand_CenteredFloat(65535.0f); - this->actionFunc = EnFireRock_Fall; - this->actor.shape.shadowScale = 15.0f; - break; - case FIRE_ROCK_BROKEN_PIECE1: - this->actor.velocity.y = Rand_ZeroFloat(3.0f) + 4.0f; - this->actor.speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; - this->scale = (Rand_ZeroFloat(1.0f) / 100.0f) + 0.02f; - Actor_SetScale(&this->actor, this->scale); - this->actor.gravity = -1.5f; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80A12CA0); - this->actor.shape.shadowScale = 10.0f; - this->actor.world.rot.y = this->actor.shape.rot.y = Rand_CenteredFloat(65535.0f); - this->actionFunc = EnFireRock_Fall; - break; - case FIRE_ROCK_BROKEN_PIECE2: - this->actor.velocity.y = Rand_ZeroFloat(3.0f) + 4.0f; - this->actor.speedXZ = Rand_ZeroFloat(3.0f) + 2.0f; - this->scale = (Rand_ZeroFloat(1.0f) / 500.0f) + 0.01f; - Actor_SetScale(&this->actor, this->scale); - this->actor.gravity = -1.2f; - this->actor.shape.shadowScale = 5.0f; - this->actor.world.rot.y = this->actor.shape.rot.y = Rand_CenteredFloat(65535.0f); - this->actionFunc = EnFireRock_Fall; - break; - default: - // "☆☆☆☆☆ No such rock! ERR !!!!!! ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ そんな岩はねぇ!ERR!!!!!! ☆☆☆☆☆ \n" VT_RST); - Actor_Kill(&this->actor); - break; - } -} - -void EnFireRock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFireRock* this = (EnFireRock*)thisx; - - if ((this->actor.parent != NULL) && (this->actor.parent == &this->spawner->actor)) { - EnEncount2* spawner = (EnEncount2*)this->actor.parent; - if ((spawner->actor.update != NULL) && (spawner->numSpawnedRocks > 0)) { - spawner->numSpawnedRocks--; - osSyncPrintf("\n\n"); - // "☆☆☆☆☆ Number of spawned instances recovery ☆☆☆☆☆%d" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生数回復 ☆☆☆☆☆%d\n" VT_RST, spawner->numSpawnedRocks); - osSyncPrintf("\n\n"); - } - } - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnFireRock_Fall(EnFireRock* this, GlobalContext* globalCtx) { - Player* player; - Vec3f flamePos; - s32 i; - - player = GET_PLAYER(globalCtx); - if ((this->actor.floorHeight == -10000.0f) || (this->actor.world.pos.y < (player->actor.world.pos.y - 200.0f))) { - Actor_Kill(&this->actor); - return; - } - switch (this->type) { - case FIRE_ROCK_SPAWNED_FALLING1: - if (player->actor.world.pos.y < this->actor.world.pos.y) { - if ((player->actor.world.pos.x > -700.0f) || (player->actor.world.pos.x < 100.0f) || - (player->actor.world.pos.z > -1290.0f) || (player->actor.world.pos.z < -3880.0f)) { - Math_ApproachF(&this->actor.world.pos.x, player->actor.world.pos.x, 1.0f, 10.0f); - Math_ApproachF(&this->actor.world.pos.z, player->actor.world.pos.z, 1.0f, 10.0f); - } - } - case FIRE_ROCK_SPAWNED_FALLING2: - flamePos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - flamePos.y = Rand_CenteredFloat(20.0f) + this->actor.world.pos.y; - flamePos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &flamePos, 100, 0, 0, -1); - break; - case FIRE_ROCK_BROKEN_PIECE1: - if ((globalCtx->gameplayFrames & 3) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_ROCK); - } - break; - } - if ((this->actor.bgCheckFlags & 1) && (this->timer == 0)) { - switch (this->type) { - case FIRE_ROCK_SPAWNED_FALLING1: - case FIRE_ROCK_SPAWNED_FALLING2: - func_80033E88(&this->actor, globalCtx, 5, 2); - case FIRE_ROCK_BROKEN_PIECE1: - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, - 1, 8.0f, 500, 10, 0); - for (i = 0; i < 5; i++) { - flamePos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - flamePos.y = this->actor.floorHeight; - flamePos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &flamePos, 300, 0, 0, -1); - } - this->actionFunc = EnFireRock_SpawnMoreBrokenPieces; - break; - default: - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, - 3, 8.0f, 200, 10, 0); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_EXPLOSION); - Actor_Kill(&this->actor); - break; - } - } -} - -/** - * After the rock has already hit the ground and started rolling, spawn two more, giving the illusion of breaking into - * two pieces. - */ -void EnFireRock_SpawnMoreBrokenPieces(EnFireRock* this, GlobalContext* globalCtx) { - EnFireRock* spawnedFireRock; - s32 nextRockType; - s32 i; - s32 temp; - - nextRockType = FIRE_ROCK_SPAWNED_FALLING1; - switch (this->type) { - case FIRE_ROCK_SPAWNED_FALLING1: - case FIRE_ROCK_SPAWNED_FALLING2: - nextRockType = FIRE_ROCK_BROKEN_PIECE1; - break; - case FIRE_ROCK_BROKEN_PIECE1: - nextRockType = FIRE_ROCK_BROKEN_PIECE2; - } - - if (nextRockType != FIRE_ROCK_SPAWNED_FALLING1) { - for (i = 0; i < 2; i++) { - spawnedFireRock = (EnFireRock*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_FIRE_ROCK, Rand_CenteredFloat(3.0f) + this->actor.world.pos.x, - Rand_CenteredFloat(3.0f) + (this->actor.world.pos.y + 10.0f), - Rand_CenteredFloat(3.0f) + this->actor.world.pos.z, 0, 0, 0, nextRockType); - if (spawnedFireRock != NULL) { - spawnedFireRock->actor.world.rot.y = this->actor.world.rot.y; - if (i == 0) { - spawnedFireRock->actor.shape.rot.y = this->actor.shape.rot.y; - } - spawnedFireRock->scale = this->scale - 0.01f; - } else { - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ イッパイデッス ☆☆☆☆☆ \n" VT_RST); - } - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_VALVAISA_ROCK); - } - Actor_Kill(&this->actor); -} - -void FireRock_WaitSpawnRocksFromCeiling(EnFireRock* this, GlobalContext* globalCtx) { - EnFireRock* spawnedFireRock; - - if (this->actor.xzDistToPlayer < 200.0f) { - if ((this->playerNearby == 0) && (this->timer2 == 0)) { - this->timer2 = 30; - spawnedFireRock = (EnFireRock*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_FIRE_ROCK, Rand_CenteredFloat(3.0f) + this->actor.world.pos.x, - this->actor.world.pos.y + 10.0f, Rand_CenteredFloat(3.0f) + this->actor.world.pos.z, 0, 0, 0, - FIRE_ROCK_SPAWNED_FALLING2); - if (spawnedFireRock != NULL) { - spawnedFireRock->timer = 10; - } else { - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ イッパイデッス ☆☆☆☆☆ \n" VT_RST); - } - } - this->playerNearby = 1; - } else { - this->playerNearby = 0; - } -} - -void FireRock_WaitOnFloor(EnFireRock* this, GlobalContext* globalCtx) { - Vec3f flamePos; - s16 scale; - - if (this->timer2 == 0) { - flamePos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - flamePos.y = Rand_CenteredFloat(20.0f) + this->actor.world.pos.y; - flamePos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - scale = 130 + (s16)Rand_CenteredFloat(60.0f); - this->timer2 = 3 + (s16)Rand_ZeroFloat(3.0f); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &flamePos, scale, 0, 0, -1); - } -} - -void EnFireRock_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFireRock* this = (EnFireRock*)thisx; - s16 setCollision; - Player* player = GET_PLAYER(globalCtx); - Actor* playerActor = &GET_PLAYER(globalCtx)->actor; - - if (this->timer2 != 0) { - this->timer2--; - } - if (this->timer != 0) { - this->timer--; - } - this->actionFunc(this, globalCtx); - - if (this->type != FIRE_ROCK_CEILING_SPOT_SPAWNER) { - f32 temp; - - this->rockRotation.x += this->angularVelocity.x; - this->rockRotation.y += this->angularVelocity.y; - this->rockRotation.z += this->angularVelocity.z; - this->relativePos.y = 3.0f; - - temp = 10.0f + (this->scale * 300.0f); - thisx->shape.shadowScale = temp; - if (thisx->shape.shadowScale < 10.0f) { - thisx->shape.shadowScale = 10.0f; - } - if (thisx->shape.shadowScale > 20.0f) { - thisx->shape.shadowScale = 20.0f; - } - - if ((this->type == FIRE_ROCK_SPAWNED_FALLING1) || (this->type == FIRE_ROCK_SPAWNED_FALLING2)) { - thisx->gravity = -0.3f - (this->scale * 7.0f); - } - if (this->type != FIRE_ROCK_ON_FLOOR) { - Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 50.0f, 50.0f, 100.0f, 0x1C); - } - - setCollision = false; - if (this->actionFunc != EnFireRock_SpawnMoreBrokenPieces) { - if ((this->type == FIRE_ROCK_SPAWNED_FALLING1) || (this->type == FIRE_ROCK_SPAWNED_FALLING2) || - (this->type == FIRE_ROCK_BROKEN_PIECE1)) { - if (this->collider.base.atFlags & 4) { - this->collider.base.atFlags &= ~4; - Audio_PlayActorSound2(thisx, NA_SE_EV_BRIDGE_OPEN_STOP); - thisx->velocity.y = 0.0f; - thisx->speedXZ = 0.0f; - this->actionFunc = EnFireRock_SpawnMoreBrokenPieces; - // "☆☆☆☆☆ Shield Defense Lv1 ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ シールド防御 Lv1 ☆☆☆☆☆ \n" VT_RST); - return; - } - setCollision = true; - } - } - - if (this->type == FIRE_ROCK_ON_FLOOR) { - if (this->collider.base.atFlags & 2) { - this->collider.base.atFlags &= ~2; - if (this->collider.base.at == playerActor) { - if (!(player->stateFlags1 & 0x04000000)) { - func_8002F758(globalCtx, thisx, 2.0f, -player->actor.world.rot.y, 3.0f, 4); - } - return; - } - } - setCollision = true; - } - if (setCollision) { - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -void EnFireRock_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnFireRock* this = (EnFireRock*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fire_rock.c", 747); - Matrix_Translate(thisx->world.pos.x + this->relativePos.x, thisx->world.pos.y + this->relativePos.y, - thisx->world.pos.z + this->relativePos.z, MTXMODE_NEW); - Matrix_RotateX(DEG_TO_RAD(this->rockRotation.x), MTXMODE_APPLY); - Matrix_RotateY(DEG_TO_RAD(this->rockRotation.y), MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(this->rockRotation.z), MTXMODE_APPLY); - Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - func_80093D18(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 55, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 155, 255, 55, 255); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fire_rock.c", 768), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_efc_star_field_DL_000DE0); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fire_rock.c", 773); -} diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.cpp b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.cpp new file mode 100644 index 000000000..4c209e4ca --- /dev/null +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.cpp @@ -0,0 +1,402 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FIRE_ROCK_Z_EN_FIRE_ROCK_C +#include "actor_common.h" +#include "z_en_fire_rock.h" +#include "overlays/actors/ovl_En_Encount2/z_en_encount2.h" +#include "vt.h" +#include "objects/object_efc_star_field/object_efc_star_field.h" +#include "def/code_8006BA00.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnFireRock_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFireRock_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFireRock_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFireRock_Draw(Actor* thisx, GlobalContext* globalCtx); + +void FireRock_WaitSpawnRocksFromCeiling(EnFireRock* pthis, GlobalContext* globalCtx); +void FireRock_WaitOnFloor(EnFireRock* pthis, GlobalContext* globalCtx); +void EnFireRock_Fall(EnFireRock* pthis, GlobalContext* globalCtx); +void EnFireRock_SpawnMoreBrokenPieces(EnFireRock* pthis, GlobalContext* globalCtx); + +ActorInit En_Fire_Rock_InitVars = { + ACTOR_EN_FIRE_ROCK, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_EFC_STAR_FIELD, + sizeof(EnFireRock), + (ActorFunc)EnFireRock_Init, + (ActorFunc)EnFireRock_Destroy, + (ActorFunc)EnFireRock_Update, + (ActorFunc)EnFireRock_Draw, +}; + +static ColliderCylinderInit D_80A12CA0 = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x09, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 30, 30, -10, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit D_80A12CCC = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 30, 30, -10, { 0, 0, 0 } }, +}; + +void EnFireRock_Init(Actor* thisx, GlobalContext* globalCtx) { + GlobalContext* globalCtx2 = globalCtx; + Player* player = GET_PLAYER(globalCtx); + EnFireRock* pthis = (EnFireRock*)thisx; + s16 temp; + + pthis->type = pthis->actor.params; + if (pthis->type != FIRE_ROCK_CEILING_SPOT_SPAWNER) { + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 15.0f); + if (pthis->type != FIRE_ROCK_ON_FLOOR) { + pthis->angularVelocity.x = (Rand_ZeroFloat(10.0f) + 15.0f); + pthis->angularVelocity.y = (Rand_ZeroFloat(10.0f) + 15.0f); + pthis->angularVelocity.z = (Rand_ZeroFloat(10.0f) + 15.0f); + } + } + switch (pthis->type) { + case FIRE_ROCK_CEILING_SPOT_SPAWNER: + pthis->actor.draw = NULL; + // "☆☆☆☆☆ ceiling waiting rock ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 天井待ち岩 ☆☆☆☆☆ \n" VT_RST); + pthis->actionFunc = FireRock_WaitSpawnRocksFromCeiling; + break; + case FIRE_ROCK_ON_FLOOR: + Actor_SetScale(&pthis->actor, 0.03f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &D_80A12CCC); + // "☆☆☆☆☆ floor rock ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 床岩 ☆☆☆☆☆ \n" VT_RST); + pthis->collider.dim.radius = 23; + pthis->collider.dim.height = 37; + pthis->collider.dim.yShift = -10; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actionFunc = FireRock_WaitOnFloor; + break; + case FIRE_ROCK_SPAWNED_FALLING1: // spawned by encount2 + // sets unused vars? + pthis->unk17C.x = (f32)(Rand_CenteredFloat(50.0f) + player->actor.world.pos.x); + pthis->unk17C.z = (f32)(Rand_CenteredFloat(50.0f) + player->actor.world.pos.z); + case FIRE_ROCK_SPAWNED_FALLING2: // spawned by encount2 and by the ceilling spawner + pthis->scale = (Rand_ZeroFloat(2.0f) / 100.0f) + 0.02f; + Actor_SetScale(&pthis->actor, pthis->scale); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &D_80A12CA0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = Rand_CenteredFloat(65535.0f); + pthis->actionFunc = EnFireRock_Fall; + pthis->actor.shape.shadowScale = 15.0f; + break; + case FIRE_ROCK_BROKEN_PIECE1: + pthis->actor.velocity.y = Rand_ZeroFloat(3.0f) + 4.0f; + pthis->actor.speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; + pthis->scale = (Rand_ZeroFloat(1.0f) / 100.0f) + 0.02f; + Actor_SetScale(&pthis->actor, pthis->scale); + pthis->actor.gravity = -1.5f; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &D_80A12CA0); + pthis->actor.shape.shadowScale = 10.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = Rand_CenteredFloat(65535.0f); + pthis->actionFunc = EnFireRock_Fall; + break; + case FIRE_ROCK_BROKEN_PIECE2: + pthis->actor.velocity.y = Rand_ZeroFloat(3.0f) + 4.0f; + pthis->actor.speedXZ = Rand_ZeroFloat(3.0f) + 2.0f; + pthis->scale = (Rand_ZeroFloat(1.0f) / 500.0f) + 0.01f; + Actor_SetScale(&pthis->actor, pthis->scale); + pthis->actor.gravity = -1.2f; + pthis->actor.shape.shadowScale = 5.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = Rand_CenteredFloat(65535.0f); + pthis->actionFunc = EnFireRock_Fall; + break; + default: + // "☆☆☆☆☆ No such rock! ERR !!!!!! ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ そんな岩はねぇ!ERR!!!!!! ☆☆☆☆☆ \n" VT_RST); + Actor_Kill(&pthis->actor); + break; + } +} + +void EnFireRock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFireRock* pthis = (EnFireRock*)thisx; + + if ((pthis->actor.parent != NULL) && (pthis->actor.parent == &pthis->spawner->actor)) { + EnEncount2* spawner = (EnEncount2*)pthis->actor.parent; + if ((spawner->actor.update != NULL) && (spawner->numSpawnedRocks > 0)) { + spawner->numSpawnedRocks--; + osSyncPrintf("\n\n"); + // "☆☆☆☆☆ Number of spawned instances recovery ☆☆☆☆☆%d" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発生数回復 ☆☆☆☆☆%d\n" VT_RST, spawner->numSpawnedRocks); + osSyncPrintf("\n\n"); + } + } + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnFireRock_Fall(EnFireRock* pthis, GlobalContext* globalCtx) { + Player* player; + Vec3f flamePos; + s32 i; + + player = GET_PLAYER(globalCtx); + if ((pthis->actor.floorHeight == -10000.0f) || (pthis->actor.world.pos.y < (player->actor.world.pos.y - 200.0f))) { + Actor_Kill(&pthis->actor); + return; + } + switch (pthis->type) { + case FIRE_ROCK_SPAWNED_FALLING1: + if (player->actor.world.pos.y < pthis->actor.world.pos.y) { + if ((player->actor.world.pos.x > -700.0f) || (player->actor.world.pos.x < 100.0f) || + (player->actor.world.pos.z > -1290.0f) || (player->actor.world.pos.z < -3880.0f)) { + Math_ApproachF(&pthis->actor.world.pos.x, player->actor.world.pos.x, 1.0f, 10.0f); + Math_ApproachF(&pthis->actor.world.pos.z, player->actor.world.pos.z, 1.0f, 10.0f); + } + } + case FIRE_ROCK_SPAWNED_FALLING2: + flamePos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + flamePos.y = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.y; + flamePos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &flamePos, 100, 0, 0, -1); + break; + case FIRE_ROCK_BROKEN_PIECE1: + if ((globalCtx->gameplayFrames & 3) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_ROCK); + } + break; + } + if ((pthis->actor.bgCheckFlags & 1) && (pthis->timer == 0)) { + switch (pthis->type) { + case FIRE_ROCK_SPAWNED_FALLING1: + case FIRE_ROCK_SPAWNED_FALLING2: + func_80033E88(&pthis->actor, globalCtx, 5, 2); + case FIRE_ROCK_BROKEN_PIECE1: + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, pthis->actor.shape.shadowScale, + 1, 8.0f, 500, 10, 0); + for (i = 0; i < 5; i++) { + flamePos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + flamePos.y = pthis->actor.floorHeight; + flamePos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &flamePos, 300, 0, 0, -1); + } + pthis->actionFunc = EnFireRock_SpawnMoreBrokenPieces; + break; + default: + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, pthis->actor.shape.shadowScale, + 3, 8.0f, 200, 10, 0); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_EXPLOSION); + Actor_Kill(&pthis->actor); + break; + } + } +} + +/** + * After the rock has already hit the ground and started rolling, spawn two more, giving the illusion of breaking into + * two pieces. + */ +void EnFireRock_SpawnMoreBrokenPieces(EnFireRock* pthis, GlobalContext* globalCtx) { + EnFireRock* spawnedFireRock; + s32 nextRockType; + s32 i; + s32 temp; + + nextRockType = FIRE_ROCK_SPAWNED_FALLING1; + switch (pthis->type) { + case FIRE_ROCK_SPAWNED_FALLING1: + case FIRE_ROCK_SPAWNED_FALLING2: + nextRockType = FIRE_ROCK_BROKEN_PIECE1; + break; + case FIRE_ROCK_BROKEN_PIECE1: + nextRockType = FIRE_ROCK_BROKEN_PIECE2; + } + + if (nextRockType != FIRE_ROCK_SPAWNED_FALLING1) { + for (i = 0; i < 2; i++) { + spawnedFireRock = (EnFireRock*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_FIRE_ROCK, Rand_CenteredFloat(3.0f) + pthis->actor.world.pos.x, + Rand_CenteredFloat(3.0f) + (pthis->actor.world.pos.y + 10.0f), + Rand_CenteredFloat(3.0f) + pthis->actor.world.pos.z, 0, 0, 0, nextRockType); + if (spawnedFireRock != NULL) { + spawnedFireRock->actor.world.rot.y = pthis->actor.world.rot.y; + if (i == 0) { + spawnedFireRock->actor.shape.rot.y = pthis->actor.shape.rot.y; + } + spawnedFireRock->scale = pthis->scale - 0.01f; + } else { + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ イッパイデッス ☆☆☆☆☆ \n" VT_RST); + } + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_VALVAISA_ROCK); + } + Actor_Kill(&pthis->actor); +} + +void FireRock_WaitSpawnRocksFromCeiling(EnFireRock* pthis, GlobalContext* globalCtx) { + EnFireRock* spawnedFireRock; + + if (pthis->actor.xzDistToPlayer < 200.0f) { + if ((pthis->playerNearby == 0) && (pthis->timer2 == 0)) { + pthis->timer2 = 30; + spawnedFireRock = (EnFireRock*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_FIRE_ROCK, Rand_CenteredFloat(3.0f) + pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 10.0f, Rand_CenteredFloat(3.0f) + pthis->actor.world.pos.z, 0, 0, 0, + FIRE_ROCK_SPAWNED_FALLING2); + if (spawnedFireRock != NULL) { + spawnedFireRock->timer = 10; + } else { + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ イッパイデッス ☆☆☆☆☆ \n" VT_RST); + } + } + pthis->playerNearby = 1; + } else { + pthis->playerNearby = 0; + } +} + +void FireRock_WaitOnFloor(EnFireRock* pthis, GlobalContext* globalCtx) { + Vec3f flamePos; + s16 scale; + + if (pthis->timer2 == 0) { + flamePos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + flamePos.y = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.y; + flamePos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + scale = 130 + (s16)Rand_CenteredFloat(60.0f); + pthis->timer2 = 3 + (s16)Rand_ZeroFloat(3.0f); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &flamePos, scale, 0, 0, -1); + } +} + +void EnFireRock_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFireRock* pthis = (EnFireRock*)thisx; + s16 setCollision; + Player* player = GET_PLAYER(globalCtx); + Actor* playerActor = &GET_PLAYER(globalCtx)->actor; + + if (pthis->timer2 != 0) { + pthis->timer2--; + } + if (pthis->timer != 0) { + pthis->timer--; + } + pthis->actionFunc(pthis, globalCtx); + + if (pthis->type != FIRE_ROCK_CEILING_SPOT_SPAWNER) { + f32 temp; + + pthis->rockRotation.x += pthis->angularVelocity.x; + pthis->rockRotation.y += pthis->angularVelocity.y; + pthis->rockRotation.z += pthis->angularVelocity.z; + pthis->relativePos.y = 3.0f; + + temp = 10.0f + (pthis->scale * 300.0f); + thisx->shape.shadowScale = temp; + if (thisx->shape.shadowScale < 10.0f) { + thisx->shape.shadowScale = 10.0f; + } + if (thisx->shape.shadowScale > 20.0f) { + thisx->shape.shadowScale = 20.0f; + } + + if ((pthis->type == FIRE_ROCK_SPAWNED_FALLING1) || (pthis->type == FIRE_ROCK_SPAWNED_FALLING2)) { + thisx->gravity = -0.3f - (pthis->scale * 7.0f); + } + if (pthis->type != FIRE_ROCK_ON_FLOOR) { + Actor_MoveForward(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 50.0f, 50.0f, 100.0f, 0x1C); + } + + setCollision = false; + if (pthis->actionFunc != EnFireRock_SpawnMoreBrokenPieces) { + if ((pthis->type == FIRE_ROCK_SPAWNED_FALLING1) || (pthis->type == FIRE_ROCK_SPAWNED_FALLING2) || + (pthis->type == FIRE_ROCK_BROKEN_PIECE1)) { + if (pthis->collider.base.atFlags & 4) { + pthis->collider.base.atFlags &= ~4; + Audio_PlayActorSound2(thisx, NA_SE_EV_BRIDGE_OPEN_STOP); + thisx->velocity.y = 0.0f; + thisx->speedXZ = 0.0f; + pthis->actionFunc = EnFireRock_SpawnMoreBrokenPieces; + // "☆☆☆☆☆ Shield Defense Lv1 ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ シールド防御 Lv1 ☆☆☆☆☆ \n" VT_RST); + return; + } + setCollision = true; + } + } + + if (pthis->type == FIRE_ROCK_ON_FLOOR) { + if (pthis->collider.base.atFlags & 2) { + pthis->collider.base.atFlags &= ~2; + if (pthis->collider.base.at == playerActor) { + if (!(player->stateFlags1 & 0x04000000)) { + func_8002F758(globalCtx, thisx, 2.0f, -player->actor.world.rot.y, 3.0f, 4); + } + return; + } + } + setCollision = true; + } + if (setCollision) { + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +void EnFireRock_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFireRock* pthis = (EnFireRock*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fire_rock.c", 747); + Matrix_Translate(thisx->world.pos.x + pthis->relativePos.x, thisx->world.pos.y + pthis->relativePos.y, + thisx->world.pos.z + pthis->relativePos.z, MTXMODE_NEW); + Matrix_RotateX(DEG_TO_RAD(pthis->rockRotation.x), MTXMODE_APPLY); + Matrix_RotateY(DEG_TO_RAD(pthis->rockRotation.y), MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(pthis->rockRotation.z), MTXMODE_APPLY); + Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); + func_80093D18(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 55, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 155, 255, 55, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fire_rock.c", 768), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_efc_star_field_DL_000DE0); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fire_rock.c", 773); +} diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c deleted file mode 100644 index c89cf41b3..000000000 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ /dev/null @@ -1,847 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FIREFLY_Z_EN_FIREFLY_C -#include "actor_common.h" -/* - * File: z_en_firefly.c - * Overlay: ovl_En_Firefly - * Description: Keese (Normal, Fire, Ice) - */ - -#include "z_en_firefly.h" -#include "objects/object_firefly/object_firefly.h" -#include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) - -void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnFirefly_DrawInvisible(Actor* thisx, GlobalContext* globalCtx); - -void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_FrozenFall(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx); - -typedef enum { - /* 0 */ KEESE_AURA_NONE, - /* 1 */ KEESE_AURA_FIRE, - /* 2 */ KEESE_AURA_ICE -} KeeseAuraType; - -const ActorInit En_Firefly_InitVars = { - ACTOR_EN_FIREFLY, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_FIREFLY, - sizeof(EnFirefly), - (ActorFunc)EnFirefly_Init, - (ActorFunc)EnFirefly_Destroy, - (ActorFunc)EnFirefly_Update, - (ActorFunc)EnFirefly_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 1, { { 0, 1000, 0 }, 15 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 1, 10, 10, 30 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0xF), - /* Ice arrow */ DMG_ENTRY(4, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x2), - /* Ice magic */ DMG_ENTRY(4, 0x3), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 5, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -4, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 4000, ICHAIN_STOP), -}; - -void EnFirefly_Extinguish(EnFirefly* this) { - this->actor.params += 2; - this->collider.elements[0].info.toucher.effect = 0; // None - this->auraType = KEESE_AURA_NONE; - this->onFire = false; - this->actor.naviEnemyId = 0x12; // Keese -} - -void EnFirefly_Ignite(EnFirefly* this) { - if (this->actor.params == KEESE_ICE_FLY) { - this->actor.params = KEESE_FIRE_FLY; - } else { - this->actor.params -= 2; - } - this->collider.elements[0].info.toucher.effect = 1; // Fire - this->auraType = KEESE_AURA_FIRE; - this->onFire = true; - this->actor.naviEnemyId = 0x11; // Fire Keese -} - -void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFirefly* this = (EnFirefly*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gKeeseSkeleton, &gKeeseFlyAnim, this->jointTable, this->morphTable, - 28); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - - if ((this->actor.params & 0x8000) != 0) { - this->actor.flags |= ACTOR_FLAG_7; - if (1) {} - this->actor.draw = EnFirefly_DrawInvisible; - this->actor.params &= 0x7FFF; - } - - if (this->actor.params <= KEESE_FIRE_PERCH) { - this->onFire = true; - } else { - this->onFire = false; - } - - if (this->onFire) { - this->actionFunc = EnFirefly_FlyIdle; - this->timer = Rand_S16Offset(20, 60); - this->actor.shape.rot.x = 0x1554; - this->auraType = KEESE_AURA_FIRE; - this->actor.naviEnemyId = 0x11; // Fire Keese - this->maxAltitude = this->actor.home.pos.y; - } else { - if (this->actor.params == KEESE_NORMAL_PERCH) { - this->actionFunc = EnFirefly_Perch; - } else { - this->actionFunc = EnFirefly_FlyIdle; - } - - if (this->actor.params == KEESE_ICE_FLY) { - this->collider.elements[0].info.toucher.effect = 2; // Ice - this->actor.naviEnemyId = 0x56; // Ice Keese - } else { - this->collider.elements[0].info.toucher.effect = 0; // Nothing - this->actor.naviEnemyId = 0x12; // Keese - } - - this->maxAltitude = this->actor.home.pos.y + 100.0f; - - if (this->actor.params == KEESE_ICE_FLY) { - this->auraType = KEESE_AURA_ICE; - } else { - this->auraType = KEESE_AURA_NONE; - } - } - - this->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; -} - -void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFirefly* this = (EnFirefly*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnFirefly_SetupFlyIdle(EnFirefly* this) { - this->timer = Rand_S16Offset(70, 100); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), 0x300); - this->targetPitch = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; - this->skelAnime.playSpeed = 1.0f; - this->actionFunc = EnFirefly_FlyIdle; -} - -void EnFirefly_SetupFall(EnFirefly* this) { - this->timer = 40; - this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &gKeeseFlyAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_DEAD); - this->actor.flags |= ACTOR_FLAG_4; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 40); - this->actionFunc = EnFirefly_Fall; -} - -void EnFirefly_SetupDie(EnFirefly* this) { - this->timer = 15; - this->actor.speedXZ = 0.0f; - this->actionFunc = EnFirefly_Die; -} - -void EnFirefly_SetupRebound(EnFirefly* this) { - this->actor.world.rot.x = 0x7000; - this->timer = 18; - this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 2.5f; - this->actionFunc = EnFirefly_Rebound; -} - -void EnFirefly_SetupDiveAttack(EnFirefly* this) { - this->timer = Rand_S16Offset(70, 100); - this->skelAnime.playSpeed = 1.0f; - this->targetPitch = ((this->actor.yDistToPlayer > 0.0f) ? -0xC00 : 0xC00) + 0x1554; - this->actionFunc = EnFirefly_DiveAttack; -} - -void EnFirefly_SetupFlyAway(EnFirefly* this) { - this->timer = 150; - this->skelAnime.playSpeed = 1.0f; - this->targetPitch = 0x954; - this->actionFunc = EnFirefly_FlyAway; -} - -void EnFirefly_SetupStunned(EnFirefly* this) { - this->timer = 80; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 80); - this->auraType = KEESE_AURA_NONE; - this->actor.velocity.y = 0.0f; - this->skelAnime.playSpeed = 3.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionFunc = EnFirefly_Stunned; -} - -void EnFirefly_SetupFrozenFall(EnFirefly* this, GlobalContext* globalCtx) { - s32 i; - Vec3f iceParticlePos; - - this->actor.flags |= ACTOR_FLAG_4; - this->auraType = KEESE_AURA_NONE; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0xFF); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_DEAD); - - for (i = 0; i <= 7; i++) { - iceParticlePos.x = (i & 1 ? 7.0f : -7.0f) + this->actor.world.pos.x; - iceParticlePos.y = (i & 2 ? 7.0f : -7.0f) + this->actor.world.pos.y; - iceParticlePos.z = (i & 4 ? 7.0f : -7.0f) + this->actor.world.pos.z; - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &iceParticlePos, 150, 150, 150, 250, 235, 245, 255, - (Rand_ZeroOne() * 0.15f) + 0.85f); - } - - this->actionFunc = EnFirefly_FrozenFall; -} - -void EnFirefly_SetupPerch(EnFirefly* this) { - this->timer = 1; - this->actor.speedXZ = 0.0f; - this->actionFunc = EnFirefly_Perch; -} - -void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this) { - this->skelAnime.playSpeed = 3.0f; - this->actor.shape.rot.x = 0x1554; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = 3.0f; - this->timer = 50; - this->actionFunc = EnFirefly_DisturbDiveAttack; -} - -s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 distFromHome; - - if (this->actor.params != KEESE_NORMAL_PERCH) { - return 0; - } - - if (Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos) > 300.0f) { - distFromHome = Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos); - - if (distFromHome < 5.0f) { - EnFirefly_SetupPerch(this); - return 1; - } - - distFromHome *= 0.05f; - - if (distFromHome < 1.0f) { - this->actor.speedXZ *= distFromHome; - } - - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), - 0x300); - Math_ScaledStepToS(&this->actor.shape.rot.x, - Actor_WorldPitchTowardPoint(&this->actor, &this->actor.home.pos) + 0x1554, 0x100); - return 1; - } - - return 0; -} - -s32 EnFirefly_SeekTorch(EnFirefly* this, GlobalContext* globalCtx) { - ObjSyokudai* findTorch; - ObjSyokudai* closestTorch; - f32 torchDist; - f32 currentMinDist; - Vec3f flamePos; - - findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - closestTorch = NULL; - currentMinDist = 35000.0f; - - while (findTorch != NULL) { - if ((findTorch->actor.id == ACTOR_OBJ_SYOKUDAI) && (findTorch->litTimer != 0)) { - torchDist = Actor_WorldDistXYZToActor(&this->actor, &findTorch->actor); - if (torchDist < currentMinDist) { - currentMinDist = torchDist; - closestTorch = findTorch; - } - } - findTorch = (ObjSyokudai*)findTorch->actor.next; - } - - if (closestTorch != NULL) { - flamePos.x = closestTorch->actor.world.pos.x; - flamePos.y = closestTorch->actor.world.pos.y + 52.0f + 15.0f; - flamePos.z = closestTorch->actor.world.pos.z; - if (Actor_WorldDistXYZToPoint(&this->actor, &flamePos) < 15.0f) { - EnFirefly_Ignite(this); - return 1; - } else { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, &closestTorch->actor), - 0x300); - Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &flamePos) + 0x1554, - 0x100); - return 1; - } - } - return 0; -} - -void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) { - s32 skelanimeUpdated; - f32 rand; - - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - skelanimeUpdated = Animation_OnFrame(&this->skelAnime, 0.0f); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; - if (this->onFire || (this->actor.params == KEESE_ICE_FLY) || - ((EnFirefly_ReturnToPerch(this, globalCtx) == 0) && (EnFirefly_SeekTorch(this, globalCtx) == 0))) { - if (skelanimeUpdated) { - rand = Rand_ZeroOne(); - if (rand < 0.5f) { - Math_ScaledStepToS(&this->actor.shape.rot.y, - Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), 0x300); - } else if (rand < 0.8f) { - this->actor.shape.rot.y += Rand_CenteredFloat(1536.0f); - } - // Climb if too close to ground - if (this->actor.world.pos.y < (this->actor.floorHeight + 20.0f)) { - this->targetPitch = 0x954; - // Descend if above maxAltitude - } else if (this->maxAltitude < this->actor.world.pos.y) { - this->targetPitch = 0x2154; - // Otherwise ascend or descend at random, biased towards ascending - } else if (0.35f < Rand_ZeroOne()) { - this->targetPitch = 0x954; - } else { - this->targetPitch = 0x2154; - } - } else { - if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; - } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; - } - } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); - } - if (this->actor.bgCheckFlags & 8) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); - } - if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f) && - (Player_GetMask(globalCtx) != PLAYER_MASK_SKULL)) { - EnFirefly_SetupDiveAttack(this); - } -} - -// Fall to the ground after being hit -void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { - if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - this->skelAnime.playSpeed = 0.0f; - } - this->actor.colorFilterTimer = 40; - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (this->actor.flags & ACTOR_FLAG_15) { - this->actor.colorFilterTimer = 40; - } else { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200); - this->actor.shape.rot.y = this->actor.shape.rot.y - 0x300; - if (this->timer != 0) { - this->timer--; - } - if ((this->actor.bgCheckFlags & 1) || (this->timer == 0)) { - EnFirefly_SetupDie(this); - } - } -} - -// Hit the ground or burn up, spawn drops -void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - Math_StepToF(&this->actor.scale.x, 0.0f, 0.00034f); - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; - if (this->timer == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); - Actor_Kill(&this->actor); - } -} - -void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f preyPos; - - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - Math_StepToF(&this->actor.speedXZ, 4.0f, 0.5f); - if (this->actor.bgCheckFlags & 8) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); - } else if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { - if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - this->skelAnime.playSpeed = 0.0f; - this->skelAnime.curFrame = 4.0f; - } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300); - preyPos.x = player->actor.world.pos.x; - preyPos.y = player->actor.world.pos.y + 20.0f; - preyPos.z = player->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &preyPos) + 0x1554, 2, - 0x400, 0x100); - } else { - this->skelAnime.playSpeed = 1.5f; - if (this->actor.xzDistToPlayer > 80.0f) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300); - } - if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; - } - if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; - } else { - this->targetPitch = 0x954; - } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); - } - if ((this->timer == 0) || (Player_GetMask(globalCtx) == PLAYER_MASK_SKULL)) { - EnFirefly_SetupFlyAway(this); - } -} - -// Knockback after hitting player -void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); - Math_StepToF(&this->actor.velocity.y, 0.0f, 0.4f); - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.15f)) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - EnFirefly_SetupFlyAway(this); - } - } -} - -void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - if (((fabsf(this->actor.world.pos.y - this->maxAltitude) < 10.0f) && - (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) < 20.0f)) || - (this->timer == 0)) { - EnFirefly_SetupFlyIdle(this); - return; - } - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); - if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; - } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; - } else { - this->targetPitch = 0x954; - } - if (this->actor.bgCheckFlags & 8) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); - } else { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), - 0x300); - } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); -} - -void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1554, 0x100); - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - if (this->onFire) { - this->auraType = KEESE_AURA_FIRE; - } else if (this->actor.params == KEESE_ICE_FLY) { - this->auraType = KEESE_AURA_ICE; - } - EnFirefly_SetupFlyIdle(this); - } -} - -void EnFirefly_FrozenFall(EnFirefly* this, GlobalContext* globalCtx) { - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - this->actor.colorFilterTimer = 0; - EnFirefly_SetupDie(this); - } else { - this->actor.colorFilterTimer = 255; - } -} - -// When perching, sit on collision and flap at random intervals -void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx) { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); - - if (this->timer != 0) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - this->timer--; - } - } else if (Rand_ZeroOne() < 0.02f) { - this->timer = 1; - } - - if (this->actor.xzDistToPlayer < 120.0f) { - EnFirefly_SetupDisturbDiveAttack(this); - } -} - -void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f preyPos; - - SkelAnime_Update(&this->skelAnime); - - if (this->timer != 0) { - this->timer--; - } - - if (this->timer < 40) { - Math_ScaledStepToS(&this->actor.shape.rot.x, -0xAAC, 0x100); - } else { - preyPos.x = player->actor.world.pos.x; - preyPos.y = player->actor.world.pos.y + 20.0f; - preyPos.z = player->actor.world.pos.z; - Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &preyPos) + 0x1554, - 0x100); - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x300); - } - - if (this->timer == 0) { - EnFirefly_SetupFlyIdle(this); - } -} - -void EnFirefly_Combust(EnFirefly* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i <= 2; i++) { - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &this->actor.world.pos, 40, 0, 0, i); - } - - this->auraType = KEESE_AURA_NONE; -} - -void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { - u8 damageEffect; - - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.elements[0].info, 1); - - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~ACTOR_FLAG_0; - } - - damageEffect = this->actor.colChkInfo.damageEffect; - - if (damageEffect == 2) { // Din's Fire - if (this->actor.params == KEESE_ICE_FLY) { - this->actor.colChkInfo.health = 0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - EnFirefly_Combust(this, globalCtx); - EnFirefly_SetupFall(this); - } else if (!this->onFire) { - EnFirefly_Ignite(this); - if (this->actionFunc == EnFirefly_Perch) { - EnFirefly_SetupFlyIdle(this); - } - } - } else if (damageEffect == 3) { // Ice Arrows or Ice Magic - if (this->actor.params == KEESE_ICE_FLY) { - EnFirefly_SetupFall(this); - } else { - EnFirefly_SetupFrozenFall(this, globalCtx); - } - } else if (damageEffect == 1) { // Deku Nuts - if (this->actionFunc != EnFirefly_Stunned) { - EnFirefly_SetupStunned(this); - } - } else { // Fire Arrows - if ((damageEffect == 0xF) && (this->actor.params == KEESE_ICE_FLY)) { - EnFirefly_Combust(this, globalCtx); - } - EnFirefly_SetupFall(this); - } - } - } -} - -void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnFirefly* this = (EnFirefly*)thisx; - GlobalContext* globalCtx = globalCtx2; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_ATTACK); - if (this->onFire) { - EnFirefly_Extinguish(this); - } - if (this->actionFunc != EnFirefly_DisturbDiveAttack) { - EnFirefly_SetupRebound(this); - } - } - - EnFirefly_UpdateDamage(this, globalCtx); - - this->actionFunc(this, globalCtx); - - if (!(this->actor.flags & ACTOR_FLAG_15)) { - if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { - Actor_MoveForward(&this->actor); - } else { - if (this->actionFunc != EnFirefly_Rebound) { - this->actor.world.rot.x = 0x1554 - this->actor.shape.rot.x; - } - func_8002D97C(&this->actor); - } - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 15.0f, 7); - this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + 10.0f; - this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - - if ((this->actionFunc == EnFirefly_DiveAttack) || (this->actionFunc == EnFirefly_DisturbDiveAttack)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (this->actor.colChkInfo.health != 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - this->actor.world.rot.y = this->actor.shape.rot.y; - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_FLY); - } - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - this->actor.focus.pos.x = - (10.0f * Math_SinS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y)) + this->actor.world.pos.x; - this->actor.focus.pos.y = (10.0f * Math_CosS(this->actor.shape.rot.x)) + this->actor.world.pos.y; - this->actor.focus.pos.z = - (10.0f * Math_SinS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y)) + this->actor.world.pos.z; -} - -s32 EnFirefly_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx, Gfx** gfx) { - EnFirefly* this = (EnFirefly*)thisx; - - if ((this->actor.draw == EnFirefly_DrawInvisible) && (globalCtx->actorCtx.unk_03 == 0)) { - *dList = NULL; - } else if (limbIndex == 1) { - pos->y += 2300.0f; - } - return false; -} - -void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - static Color_RGBA8 fireAuraPrimColor = { 255, 255, 100, 255 }; - static Color_RGBA8 fireAuraEnvColor = { 255, 50, 0, 0 }; - static Color_RGBA8 iceAuraPrimColor = { 100, 200, 255, 255 }; - static Color_RGBA8 iceAuraEnvColor = { 0, 0, 255, 0 }; - static Vec3f effVelocity = { 0.0f, 0.5f, 0.0f }; - static Vec3f effAccel = { 0.0f, 0.5f, 0.0f }; - static Vec3f limbSrc = { 0.0f, 0.0f, 0.0f }; - Vec3f effPos; - Vec3f* limbDest; - Color_RGBA8* effPrimColor; - Color_RGBA8* effEnvColor; - MtxF mtx; - s16 effScaleStep; - s16 effLife; - EnFirefly* this = (EnFirefly*)thisx; - - if (!this->onFire && (limbIndex == 27)) { - gSPDisplayList((*gfx)++, gKeeseEyesDL); - } else { - if ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) { - if ((limbIndex == 15) || (limbIndex == 21)) { - if (this->actionFunc != EnFirefly_Die) { - Matrix_Get(&mtx); - effPos.x = (Rand_ZeroOne() * 5.0f) + mtx.xw; - effPos.y = (Rand_ZeroOne() * 5.0f) + mtx.yw; - effPos.z = (Rand_ZeroOne() * 5.0f) + mtx.zw; - effScaleStep = -40; - effLife = 3; - } else { - if (limbIndex == 15) { - effPos.x = (Math_SinS(9100 * this->timer) * this->timer) + this->actor.world.pos.x; - effPos.z = (Math_CosS(9100 * this->timer) * this->timer) + this->actor.world.pos.z; - } else { - effPos.x = this->actor.world.pos.x - (Math_SinS(9100 * this->timer) * this->timer); - effPos.z = this->actor.world.pos.z - (Math_CosS(9100 * this->timer) * this->timer); - } - - effPos.y = this->actor.world.pos.y + ((15 - this->timer) * 1.5f); - effScaleStep = -5; - effLife = 10; - } - - if (this->auraType == KEESE_AURA_FIRE) { - effPrimColor = &fireAuraPrimColor; - effEnvColor = &fireAuraEnvColor; - } else { - effPrimColor = &iceAuraPrimColor; - effEnvColor = &iceAuraEnvColor; - } - - func_8002843C(globalCtx, &effPos, &effVelocity, &effAccel, effPrimColor, effEnvColor, 250, effScaleStep, - effLife); - } - } - } - if ((limbIndex == 15) || (limbIndex == 21) || (limbIndex == 10)) { - if (limbIndex == 15) { - limbDest = &this->bodyPartsPos[0]; - } else if (limbIndex == 21) { - limbDest = &this->bodyPartsPos[1]; - } else { - limbDest = &this->bodyPartsPos[2]; - } - - Matrix_MultVec3f(&limbSrc, limbDest); - limbDest->y -= 5.0f; - } -} - -void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnFirefly* this = (EnFirefly*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1733); - func_80093D18(globalCtx->state.gfxCtx); - - if (this->onFire) { - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - } else { - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - } - - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, &this->actor, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1763); -} - -void EnFirefly_DrawInvisible(Actor* thisx, GlobalContext* globalCtx) { - EnFirefly* this = (EnFirefly*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1775); - func_80093D84(globalCtx->state.gfxCtx); - - if (this->onFire) { - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 255); - } - - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, this, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1805); -} diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.cpp b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.cpp new file mode 100644 index 000000000..5cb8cd778 --- /dev/null +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.cpp @@ -0,0 +1,847 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FIREFLY_Z_EN_FIREFLY_C +#include "actor_common.h" +/* + * File: z_en_firefly.c + * Overlay: ovl_En_Firefly + * Description: Keese (Normal, Fire, Ice) + */ + +#include "z_en_firefly.h" +#include "objects/object_firefly/object_firefly.h" +#include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12 | ACTOR_FLAG_14) + +void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnFirefly_DrawInvisible(Actor* thisx, GlobalContext* globalCtx); + +void EnFirefly_FlyIdle(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_Fall(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_Die(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_DiveAttack(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_Rebound(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_FlyAway(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_Stunned(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_FrozenFall(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_Perch(EnFirefly* pthis, GlobalContext* globalCtx); +void EnFirefly_DisturbDiveAttack(EnFirefly* pthis, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ KEESE_AURA_NONE, + /* 1 */ KEESE_AURA_FIRE, + /* 2 */ KEESE_AURA_ICE +} KeeseAuraType; + +ActorInit En_Firefly_InitVars = { + ACTOR_EN_FIREFLY, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_FIREFLY, + sizeof(EnFirefly), + (ActorFunc)EnFirefly_Init, + (ActorFunc)EnFirefly_Destroy, + (ActorFunc)EnFirefly_Update, + (ActorFunc)EnFirefly_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 1, { { 0, 1000, 0 }, 15 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 1, 10, 10, 30 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(1, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0xF), + /* Ice arrow */ DMG_ENTRY(4, 0x3), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x2), + /* Ice magic */ DMG_ENTRY(4, 0x3), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 5, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), + ICHAIN_F32(minVelocityY, -4, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 4000, ICHAIN_STOP), +}; + +void EnFirefly_Extinguish(EnFirefly* pthis) { + pthis->actor.params += 2; + pthis->collider.elements[0].info.toucher.effect = 0; // None + pthis->auraType = KEESE_AURA_NONE; + pthis->onFire = false; + pthis->actor.naviEnemyId = 0x12; // Keese +} + +void EnFirefly_Ignite(EnFirefly* pthis) { + if (pthis->actor.params == KEESE_ICE_FLY) { + pthis->actor.params = KEESE_FIRE_FLY; + } else { + pthis->actor.params -= 2; + } + pthis->collider.elements[0].info.toucher.effect = 1; // Fire + pthis->auraType = KEESE_AURA_FIRE; + pthis->onFire = true; + pthis->actor.naviEnemyId = 0x11; // Fire Keese +} + +void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFirefly* pthis = (EnFirefly*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gKeeseSkeleton, &gKeeseFlyAnim, pthis->jointTable, pthis->morphTable, + 28); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + if ((pthis->actor.params & 0x8000) != 0) { + pthis->actor.flags |= ACTOR_FLAG_7; + if (1) {} + pthis->actor.draw = EnFirefly_DrawInvisible; + pthis->actor.params &= 0x7FFF; + } + + if (pthis->actor.params <= KEESE_FIRE_PERCH) { + pthis->onFire = true; + } else { + pthis->onFire = false; + } + + if (pthis->onFire) { + pthis->actionFunc = EnFirefly_FlyIdle; + pthis->timer = Rand_S16Offset(20, 60); + pthis->actor.shape.rot.x = 0x1554; + pthis->auraType = KEESE_AURA_FIRE; + pthis->actor.naviEnemyId = 0x11; // Fire Keese + pthis->maxAltitude = pthis->actor.home.pos.y; + } else { + if (pthis->actor.params == KEESE_NORMAL_PERCH) { + pthis->actionFunc = EnFirefly_Perch; + } else { + pthis->actionFunc = EnFirefly_FlyIdle; + } + + if (pthis->actor.params == KEESE_ICE_FLY) { + pthis->collider.elements[0].info.toucher.effect = 2; // Ice + pthis->actor.naviEnemyId = 0x56; // Ice Keese + } else { + pthis->collider.elements[0].info.toucher.effect = 0; // Nothing + pthis->actor.naviEnemyId = 0x12; // Keese + } + + pthis->maxAltitude = pthis->actor.home.pos.y + 100.0f; + + if (pthis->actor.params == KEESE_ICE_FLY) { + pthis->auraType = KEESE_AURA_ICE; + } else { + pthis->auraType = KEESE_AURA_NONE; + } + } + + pthis->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; +} + +void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFirefly* pthis = (EnFirefly*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnFirefly_SetupFlyIdle(EnFirefly* pthis) { + pthis->timer = Rand_S16Offset(70, 100); + pthis->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; + Math_ScaledStepToS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), 0x300); + pthis->targetPitch = ((pthis->maxAltitude < pthis->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; + pthis->skelAnime.playSpeed = 1.0f; + pthis->actionFunc = EnFirefly_FlyIdle; +} + +void EnFirefly_SetupFall(EnFirefly* pthis) { + pthis->timer = 40; + pthis->actor.velocity.y = 0.0f; + Animation_Change(&pthis->skelAnime, &gKeeseFlyAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FFLY_DEAD); + pthis->actor.flags |= ACTOR_FLAG_4; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 40); + pthis->actionFunc = EnFirefly_Fall; +} + +void EnFirefly_SetupDie(EnFirefly* pthis) { + pthis->timer = 15; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnFirefly_Die; +} + +void EnFirefly_SetupRebound(EnFirefly* pthis) { + pthis->actor.world.rot.x = 0x7000; + pthis->timer = 18; + pthis->skelAnime.playSpeed = 1.0f; + pthis->actor.speedXZ = 2.5f; + pthis->actionFunc = EnFirefly_Rebound; +} + +void EnFirefly_SetupDiveAttack(EnFirefly* pthis) { + pthis->timer = Rand_S16Offset(70, 100); + pthis->skelAnime.playSpeed = 1.0f; + pthis->targetPitch = ((pthis->actor.yDistToPlayer > 0.0f) ? -0xC00 : 0xC00) + 0x1554; + pthis->actionFunc = EnFirefly_DiveAttack; +} + +void EnFirefly_SetupFlyAway(EnFirefly* pthis) { + pthis->timer = 150; + pthis->skelAnime.playSpeed = 1.0f; + pthis->targetPitch = 0x954; + pthis->actionFunc = EnFirefly_FlyAway; +} + +void EnFirefly_SetupStunned(EnFirefly* pthis) { + pthis->timer = 80; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 80); + pthis->auraType = KEESE_AURA_NONE; + pthis->actor.velocity.y = 0.0f; + pthis->skelAnime.playSpeed = 3.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actionFunc = EnFirefly_Stunned; +} + +void EnFirefly_SetupFrozenFall(EnFirefly* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f iceParticlePos; + + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->auraType = KEESE_AURA_NONE; + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0xFF); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FFLY_DEAD); + + for (i = 0; i <= 7; i++) { + iceParticlePos.x = (i & 1 ? 7.0f : -7.0f) + pthis->actor.world.pos.x; + iceParticlePos.y = (i & 2 ? 7.0f : -7.0f) + pthis->actor.world.pos.y; + iceParticlePos.z = (i & 4 ? 7.0f : -7.0f) + pthis->actor.world.pos.z; + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &iceParticlePos, 150, 150, 150, 250, 235, 245, 255, + (Rand_ZeroOne() * 0.15f) + 0.85f); + } + + pthis->actionFunc = EnFirefly_FrozenFall; +} + +void EnFirefly_SetupPerch(EnFirefly* pthis) { + pthis->timer = 1; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnFirefly_Perch; +} + +void EnFirefly_SetupDisturbDiveAttack(EnFirefly* pthis) { + pthis->skelAnime.playSpeed = 3.0f; + pthis->actor.shape.rot.x = 0x1554; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = 3.0f; + pthis->timer = 50; + pthis->actionFunc = EnFirefly_DisturbDiveAttack; +} + +s32 EnFirefly_ReturnToPerch(EnFirefly* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distFromHome; + + if (pthis->actor.params != KEESE_NORMAL_PERCH) { + return 0; + } + + if (Actor_WorldDistXZToPoint(&player->actor, &pthis->actor.home.pos) > 300.0f) { + distFromHome = Actor_WorldDistXYZToPoint(&pthis->actor, &pthis->actor.home.pos); + + if (distFromHome < 5.0f) { + EnFirefly_SetupPerch(pthis); + return 1; + } + + distFromHome *= 0.05f; + + if (distFromHome < 1.0f) { + pthis->actor.speedXZ *= distFromHome; + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), + 0x300); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, + Actor_WorldPitchTowardPoint(&pthis->actor, &pthis->actor.home.pos) + 0x1554, 0x100); + return 1; + } + + return 0; +} + +s32 EnFirefly_SeekTorch(EnFirefly* pthis, GlobalContext* globalCtx) { + ObjSyokudai* findTorch; + ObjSyokudai* closestTorch; + f32 torchDist; + f32 currentMinDist; + Vec3f flamePos; + + findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + closestTorch = NULL; + currentMinDist = 35000.0f; + + while (findTorch != NULL) { + if ((findTorch->actor.id == ACTOR_OBJ_SYOKUDAI) && (findTorch->litTimer != 0)) { + torchDist = Actor_WorldDistXYZToActor(&pthis->actor, &findTorch->actor); + if (torchDist < currentMinDist) { + currentMinDist = torchDist; + closestTorch = findTorch; + } + } + findTorch = (ObjSyokudai*)findTorch->actor.next; + } + + if (closestTorch != NULL) { + flamePos.x = closestTorch->actor.world.pos.x; + flamePos.y = closestTorch->actor.world.pos.y + 52.0f + 15.0f; + flamePos.z = closestTorch->actor.world.pos.z; + if (Actor_WorldDistXYZToPoint(&pthis->actor, &flamePos) < 15.0f) { + EnFirefly_Ignite(pthis); + return 1; + } else { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardActor(&pthis->actor, &closestTorch->actor), + 0x300); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&pthis->actor, &flamePos) + 0x1554, + 0x100); + return 1; + } + } + return 0; +} + +void EnFirefly_FlyIdle(EnFirefly* pthis, GlobalContext* globalCtx) { + s32 skelanimeUpdated; + f32 rand; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + skelanimeUpdated = Animation_OnFrame(&pthis->skelAnime, 0.0f); + pthis->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; + if (pthis->onFire || (pthis->actor.params == KEESE_ICE_FLY) || + ((EnFirefly_ReturnToPerch(pthis, globalCtx) == 0) && (EnFirefly_SeekTorch(pthis, globalCtx) == 0))) { + if (skelanimeUpdated) { + rand = Rand_ZeroOne(); + if (rand < 0.5f) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, + Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), 0x300); + } else if (rand < 0.8f) { + pthis->actor.shape.rot.y += Rand_CenteredFloat(1536.0f); + } + // Climb if too close to ground + if (pthis->actor.world.pos.y < (pthis->actor.floorHeight + 20.0f)) { + pthis->targetPitch = 0x954; + // Descend if above maxAltitude + } else if (pthis->maxAltitude < pthis->actor.world.pos.y) { + pthis->targetPitch = 0x2154; + // Otherwise ascend or descend at random, biased towards ascending + } else if (0.35f < Rand_ZeroOne()) { + pthis->targetPitch = 0x954; + } else { + pthis->targetPitch = 0x2154; + } + } else { + if (pthis->actor.bgCheckFlags & 1) { + pthis->targetPitch = 0x954; + } else if ((pthis->actor.bgCheckFlags & 0x10) || (pthis->maxAltitude < pthis->actor.world.pos.y)) { + pthis->targetPitch = 0x2154; + } + } + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->targetPitch, 0x100); + } + if (pthis->actor.bgCheckFlags & 8) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.wallYaw, 2, 0xC00, 0x300); + } + if ((pthis->timer == 0) && (pthis->actor.xzDistToPlayer < 200.0f) && + (Player_GetMask(globalCtx) != PLAYER_MASK_SKULL)) { + EnFirefly_SetupDiveAttack(pthis); + } +} + +// Fall to the ground after being hit +void EnFirefly_Fall(EnFirefly* pthis, GlobalContext* globalCtx) { + if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + pthis->skelAnime.playSpeed = 0.0f; + } + pthis->actor.colorFilterTimer = 40; + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + if (pthis->actor.flags & ACTOR_FLAG_15) { + pthis->actor.colorFilterTimer = 40; + } else { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x6800, 0x200); + pthis->actor.shape.rot.y = pthis->actor.shape.rot.y - 0x300; + if (pthis->timer != 0) { + pthis->timer--; + } + if ((pthis->actor.bgCheckFlags & 1) || (pthis->timer == 0)) { + EnFirefly_SetupDie(pthis); + } + } +} + +// Hit the ground or burn up, spawn drops +void EnFirefly_Die(EnFirefly* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + Math_StepToF(&pthis->actor.scale.x, 0.0f, 0.00034f); + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; + if (pthis->timer == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xE0); + Actor_Kill(&pthis->actor); + } +} + +void EnFirefly_DiveAttack(EnFirefly* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f preyPos; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + Math_StepToF(&pthis->actor.speedXZ, 4.0f, 0.5f); + if (pthis->actor.bgCheckFlags & 8) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.wallYaw, 2, 0xC00, 0x300); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->targetPitch, 0x100); + } else if (Actor_IsFacingPlayer(&pthis->actor, 0x2800)) { + if (Animation_OnFrame(&pthis->skelAnime, 4.0f)) { + pthis->skelAnime.playSpeed = 0.0f; + pthis->skelAnime.curFrame = 4.0f; + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xC00, 0x300); + preyPos.x = player->actor.world.pos.x; + preyPos.y = player->actor.world.pos.y + 20.0f; + preyPos.z = player->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&pthis->actor, &preyPos) + 0x1554, 2, + 0x400, 0x100); + } else { + pthis->skelAnime.playSpeed = 1.5f; + if (pthis->actor.xzDistToPlayer > 80.0f) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xC00, 0x300); + } + if (pthis->actor.bgCheckFlags & 1) { + pthis->targetPitch = 0x954; + } + if ((pthis->actor.bgCheckFlags & 0x10) || (pthis->maxAltitude < pthis->actor.world.pos.y)) { + pthis->targetPitch = 0x2154; + } else { + pthis->targetPitch = 0x954; + } + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->targetPitch, 0x100); + } + if ((pthis->timer == 0) || (Player_GetMask(globalCtx) == PLAYER_MASK_SKULL)) { + EnFirefly_SetupFlyAway(pthis); + } +} + +// Knockback after hitting player +void EnFirefly_Rebound(EnFirefly* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x100); + Math_StepToF(&pthis->actor.velocity.y, 0.0f, 0.4f); + if (Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.15f)) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + EnFirefly_SetupFlyAway(pthis); + } + } +} + +void EnFirefly_FlyAway(EnFirefly* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + if (((fabsf(pthis->actor.world.pos.y - pthis->maxAltitude) < 10.0f) && + (Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) < 20.0f)) || + (pthis->timer == 0)) { + EnFirefly_SetupFlyIdle(pthis); + return; + } + Math_StepToF(&pthis->actor.speedXZ, 3.0f, 0.3f); + if (pthis->actor.bgCheckFlags & 1) { + pthis->targetPitch = 0x954; + } else if ((pthis->actor.bgCheckFlags & 0x10) || (pthis->maxAltitude < pthis->actor.world.pos.y)) { + pthis->targetPitch = 0x2154; + } else { + pthis->targetPitch = 0x954; + } + if (pthis->actor.bgCheckFlags & 8) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.wallYaw, 2, 0xC00, 0x300); + } else { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), + 0x300); + } + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->targetPitch, 0x100); +} + +void EnFirefly_Stunned(EnFirefly* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x1554, 0x100); + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + if (pthis->onFire) { + pthis->auraType = KEESE_AURA_FIRE; + } else if (pthis->actor.params == KEESE_ICE_FLY) { + pthis->auraType = KEESE_AURA_ICE; + } + EnFirefly_SetupFlyIdle(pthis); + } +} + +void EnFirefly_FrozenFall(EnFirefly* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.bgCheckFlags & 1) || (pthis->actor.floorHeight == BGCHECK_Y_MIN)) { + pthis->actor.colorFilterTimer = 0; + EnFirefly_SetupDie(pthis); + } else { + pthis->actor.colorFilterTimer = 255; + } +} + +// When perching, sit on collision and flap at random intervals +void EnFirefly_Perch(EnFirefly* pthis, GlobalContext* globalCtx) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x100); + + if (pthis->timer != 0) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + pthis->timer--; + } + } else if (Rand_ZeroOne() < 0.02f) { + pthis->timer = 1; + } + + if (pthis->actor.xzDistToPlayer < 120.0f) { + EnFirefly_SetupDisturbDiveAttack(pthis); + } +} + +void EnFirefly_DisturbDiveAttack(EnFirefly* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f preyPos; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer < 40) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0xAAC, 0x100); + } else { + preyPos.x = player->actor.world.pos.x; + preyPos.y = player->actor.world.pos.y + 20.0f; + preyPos.z = player->actor.world.pos.z; + Math_ScaledStepToS(&pthis->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&pthis->actor, &preyPos) + 0x1554, + 0x100); + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0x300); + } + + if (pthis->timer == 0) { + EnFirefly_SetupFlyIdle(pthis); + } +} + +void EnFirefly_Combust(EnFirefly* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i <= 2; i++) { + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40, 0, 0, i); + } + + pthis->auraType = KEESE_AURA_NONE; +} + +void EnFirefly_UpdateDamage(EnFirefly* pthis, GlobalContext* globalCtx) { + u8 damageEffect; + + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.elements[0].info, 1); + + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + + damageEffect = pthis->actor.colChkInfo.damageEffect; + + if (damageEffect == 2) { // Din's Fire + if (pthis->actor.params == KEESE_ICE_FLY) { + pthis->actor.colChkInfo.health = 0; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + EnFirefly_Combust(pthis, globalCtx); + EnFirefly_SetupFall(pthis); + } else if (!pthis->onFire) { + EnFirefly_Ignite(pthis); + if (pthis->actionFunc == EnFirefly_Perch) { + EnFirefly_SetupFlyIdle(pthis); + } + } + } else if (damageEffect == 3) { // Ice Arrows or Ice Magic + if (pthis->actor.params == KEESE_ICE_FLY) { + EnFirefly_SetupFall(pthis); + } else { + EnFirefly_SetupFrozenFall(pthis, globalCtx); + } + } else if (damageEffect == 1) { // Deku Nuts + if (pthis->actionFunc != EnFirefly_Stunned) { + EnFirefly_SetupStunned(pthis); + } + } else { // Fire Arrows + if ((damageEffect == 0xF) && (pthis->actor.params == KEESE_ICE_FLY)) { + EnFirefly_Combust(pthis, globalCtx); + } + EnFirefly_SetupFall(pthis); + } + } + } +} + +void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnFirefly* pthis = (EnFirefly*)thisx; + GlobalContext* globalCtx = globalCtx2; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FFLY_ATTACK); + if (pthis->onFire) { + EnFirefly_Extinguish(pthis); + } + if (pthis->actionFunc != EnFirefly_DisturbDiveAttack) { + EnFirefly_SetupRebound(pthis); + } + } + + EnFirefly_UpdateDamage(pthis, globalCtx); + + pthis->actionFunc(pthis, globalCtx); + + if (!(pthis->actor.flags & ACTOR_FLAG_15)) { + if ((pthis->actor.colChkInfo.health == 0) || (pthis->actionFunc == EnFirefly_Stunned)) { + Actor_MoveForward(&pthis->actor); + } else { + if (pthis->actionFunc != EnFirefly_Rebound) { + pthis->actor.world.rot.x = 0x1554 - pthis->actor.shape.rot.x; + } + func_8002D97C(&pthis->actor); + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 15.0f, 7); + pthis->collider.elements[0].dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->collider.elements[0].dim.worldSphere.center.y = pthis->actor.world.pos.y + 10.0f; + pthis->collider.elements[0].dim.worldSphere.center.z = pthis->actor.world.pos.z; + + if ((pthis->actionFunc == EnFirefly_DiveAttack) || (pthis->actionFunc == EnFirefly_DisturbDiveAttack)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (pthis->actor.colChkInfo.health != 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FFLY_FLY); + } + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + pthis->actor.focus.pos.x = + (10.0f * Math_SinS(pthis->actor.shape.rot.x) * Math_SinS(pthis->actor.shape.rot.y)) + pthis->actor.world.pos.x; + pthis->actor.focus.pos.y = (10.0f * Math_CosS(pthis->actor.shape.rot.x)) + pthis->actor.world.pos.y; + pthis->actor.focus.pos.z = + (10.0f * Math_SinS(pthis->actor.shape.rot.x) * Math_CosS(pthis->actor.shape.rot.y)) + pthis->actor.world.pos.z; +} + +s32 EnFirefly_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx, Gfx** gfx) { + EnFirefly* pthis = (EnFirefly*)thisx; + + if ((pthis->actor.draw == EnFirefly_DrawInvisible) && (globalCtx->actorCtx.unk_03 == 0)) { + *dList = NULL; + } else if (limbIndex == 1) { + pos->y += 2300.0f; + } + return false; +} + +void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + static Color_RGBA8 fireAuraPrimColor = { 255, 255, 100, 255 }; + static Color_RGBA8 fireAuraEnvColor = { 255, 50, 0, 0 }; + static Color_RGBA8 iceAuraPrimColor = { 100, 200, 255, 255 }; + static Color_RGBA8 iceAuraEnvColor = { 0, 0, 255, 0 }; + static Vec3f effVelocity = { 0.0f, 0.5f, 0.0f }; + static Vec3f effAccel = { 0.0f, 0.5f, 0.0f }; + static Vec3f limbSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f effPos; + Vec3f* limbDest; + Color_RGBA8* effPrimColor; + Color_RGBA8* effEnvColor; + MtxF mtx; + s16 effScaleStep; + s16 effLife; + EnFirefly* pthis = (EnFirefly*)thisx; + + if (!pthis->onFire && (limbIndex == 27)) { + gSPDisplayList((*gfx)++, gKeeseEyesDL); + } else { + if ((pthis->auraType == KEESE_AURA_FIRE) || (pthis->auraType == KEESE_AURA_ICE)) { + if ((limbIndex == 15) || (limbIndex == 21)) { + if (pthis->actionFunc != EnFirefly_Die) { + Matrix_Get(&mtx); + effPos.x = (Rand_ZeroOne() * 5.0f) + mtx.xw; + effPos.y = (Rand_ZeroOne() * 5.0f) + mtx.yw; + effPos.z = (Rand_ZeroOne() * 5.0f) + mtx.zw; + effScaleStep = -40; + effLife = 3; + } else { + if (limbIndex == 15) { + effPos.x = (Math_SinS(9100 * pthis->timer) * pthis->timer) + pthis->actor.world.pos.x; + effPos.z = (Math_CosS(9100 * pthis->timer) * pthis->timer) + pthis->actor.world.pos.z; + } else { + effPos.x = pthis->actor.world.pos.x - (Math_SinS(9100 * pthis->timer) * pthis->timer); + effPos.z = pthis->actor.world.pos.z - (Math_CosS(9100 * pthis->timer) * pthis->timer); + } + + effPos.y = pthis->actor.world.pos.y + ((15 - pthis->timer) * 1.5f); + effScaleStep = -5; + effLife = 10; + } + + if (pthis->auraType == KEESE_AURA_FIRE) { + effPrimColor = &fireAuraPrimColor; + effEnvColor = &fireAuraEnvColor; + } else { + effPrimColor = &iceAuraPrimColor; + effEnvColor = &iceAuraEnvColor; + } + + func_8002843C(globalCtx, &effPos, &effVelocity, &effAccel, effPrimColor, effEnvColor, 250, effScaleStep, + effLife); + } + } + } + if ((limbIndex == 15) || (limbIndex == 21) || (limbIndex == 10)) { + if (limbIndex == 15) { + limbDest = &pthis->bodyPartsPos[0]; + } else if (limbIndex == 21) { + limbDest = &pthis->bodyPartsPos[1]; + } else { + limbDest = &pthis->bodyPartsPos[2]; + } + + Matrix_MultVec3f(&limbSrc, limbDest); + limbDest->y -= 5.0f; + } +} + +void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFirefly* pthis = (EnFirefly*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1733); + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->onFire) { + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + } else { + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + } + + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, &pthis->actor, POLY_OPA_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1763); +} + +void EnFirefly_DrawInvisible(Actor* thisx, GlobalContext* globalCtx) { + EnFirefly* pthis = (EnFirefly*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1775); + func_80093D84(globalCtx->state.gfxCtx); + + if (pthis->onFire) { + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 255); + } + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, pthis, POLY_XLU_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_firefly.c", 1805); +} diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c deleted file mode 100644 index f4c7eeeef..000000000 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ /dev/null @@ -1,777 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FISH_Z_EN_FISH_C -#include "actor_common.h" -/* - * File: z_en_fish.c - * Overlay: ovl_En_Fish - * Description: Fish - */ - -#include "z_en_fish.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "vt.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void EnFish_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFish_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnFish_Respawning_SetupSlowDown(EnFish* this); -void EnFish_Respawning_SlowDown(EnFish* this, GlobalContext* globalCtx); -void EnFish_Respawning_SetupFollowChild(EnFish* this); -void EnFish_Respawning_FollowChild(EnFish* this, GlobalContext* globalCtx); -void EnFish_Respawning_SetupFleePlayer(EnFish* this); -void EnFish_Respawning_FleePlayer(EnFish* this, GlobalContext* globalCtx); -void EnFish_Respawning_SetupApproachPlayer(EnFish* this); -void EnFish_Respawning_ApproachPlayer(EnFish* this, GlobalContext* globalCtx); -void EnFish_Dropped_SetupFall(EnFish* this); -void EnFish_Dropped_Fall(EnFish* this, GlobalContext* globalCtx); -void EnFish_Dropped_SetupFlopOnGround(EnFish* this); -void EnFish_Dropped_FlopOnGround(EnFish* this, GlobalContext* globalCtx); -void EnFish_Dropped_SetupSwimAway(EnFish* this); -void EnFish_Dropped_SwimAway(EnFish* this, GlobalContext* globalCtx); -void EnFish_Unique_SetupSwimIdle(EnFish* this); -void EnFish_Unique_SwimIdle(EnFish* this, GlobalContext* globalCtx); - -// Used in the cutscene functions -static Actor* D_80A17010 = NULL; -static f32 D_80A17014 = 0.0f; -static f32 D_80A17018 = 0.0f; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 5 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -const ActorInit En_Fish_InitVars = { - ACTOR_EN_FISH, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnFish), - (ActorFunc)EnFish_Init, - (ActorFunc)EnFish_Destroy, - (ActorFunc)EnFish_Update, - (ActorFunc)EnFish_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 900, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 700, ICHAIN_STOP), -}; - -f32 EnFish_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { - return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); -} - -void EnFish_SetInWaterAnimation(EnFish* this) { - Animation_Change(&this->skelAnime, &gFishInWaterAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gFishInWaterAnim), - ANIMMODE_LOOP_INTERP, 2.0f); -} - -void EnFish_SetOutOfWaterAnimation(EnFish* this) { - Animation_Change(&this->skelAnime, &gFishOutOfWaterAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gFishOutOfWaterAnim), - ANIMMODE_LOOP_INTERP, 2.0f); -} - -void EnFish_BeginRespawn(EnFish* this) { - this->respawnTimer = 400; - Actor_SetScale(&this->actor, 0.001f); - this->actor.draw = NULL; -} - -void EnFish_SetCutsceneData(EnFish* this) { - Actor* thisx = &this->actor; - - if (D_80A17010 == NULL) { - D_80A17010 = thisx; - Actor_SetScale(thisx, 0.01f); - thisx->draw = EnFish_Draw; - thisx->shape.rot.x = 0; - thisx->shape.rot.y = -0x6410; - thisx->shape.rot.z = 0x4000; - thisx->shape.yOffset = 600.0f; - D_80A17014 = 10.0f; - D_80A17018 = 0.0f; - thisx->flags |= ACTOR_FLAG_4; - EnFish_SetOutOfWaterAnimation(this); - } -} - -void EnFish_ClearCutsceneData(EnFish* this) { - D_80A17010 = NULL; - D_80A17014 = 0.0f; - D_80A17018 = 0.0f; -} - -void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFish* this = (EnFish*)thisx; - s16 params = this->actor.params; - - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishSkel, &gFishInWaterAnim, this->jointTable, this->morphTable, - 7); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - this->actor.colChkInfo.mass = 50; - this->slowPhase = Rand_ZeroOne() * (0xFFFF + 0.5f); - this->fastPhase = Rand_ZeroOne() * (0xFFFF + 0.5f); - - if (params == FISH_DROPPED) { - this->actor.flags |= ACTOR_FLAG_4; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); - EnFish_Dropped_SetupFall(this); - } else if (params == FISH_SWIMMING_UNIQUE) { - EnFish_Unique_SetupSwimIdle(this); - } else { - EnFish_Respawning_SetupSlowDown(this); - } -} - -void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnFish* this = (EnFish*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnFish_SetYOffset(EnFish* this) { - this->actor.shape.yOffset += (Math_SinS(this->slowPhase) * 10.0f + Math_SinS(this->fastPhase) * 5.0f); - this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -200.0f, 200.0f); -} - -s32 EnFish_InBottleRange(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - Vec3f sp1C; - - if (this->actor.xzDistToPlayer < 32.0f) { - sp1C.x = (Math_SinS(this->actor.yawTowardsPlayer + 0x8000) * 16.0f) + player->actor.world.pos.x; - sp1C.y = player->actor.world.pos.y; - sp1C.z = (Math_CosS(this->actor.yawTowardsPlayer + 0x8000) * 16.0f) + player->actor.world.pos.z; - - //! @bug: this check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have - //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's - //! world rotation. - if (EnFish_XZDistanceSquared(&sp1C, &this->actor.world.pos) <= SQ(20.0f)) { - return true; - } - } - - return false; -} - -s32 EnFish_CheckXZDistanceToPlayer(EnFish* this, GlobalContext* globalCtx) { - return (this->actor.xzDistToPlayer < 60.0f); -} - -// Respawning type functions - -void EnFish_Respawning_SetupSlowDown(EnFish* this) { - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - this->timer = Rand_S16Offset(5, 35); - this->unk_250 = 0; - EnFish_SetInWaterAnimation(this); - this->actionFunc = EnFish_Respawning_SlowDown; -} - -void EnFish_Respawning_SlowDown(EnFish* this, GlobalContext* globalCtx) { - EnFish_SetYOffset(this); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.05f, 0.3f, 0.0f); - this->skelAnime.playSpeed = CLAMP_MAX(this->actor.speedXZ * 1.4f + 0.8f, 2.0f); - SkelAnime_Update(&this->skelAnime); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->timer <= 0) { - EnFish_Respawning_SetupFollowChild(this); - } else if (&this->actor == this->actor.child) { - EnFish_Respawning_SetupApproachPlayer(this); - } else if (EnFish_CheckXZDistanceToPlayer(this, globalCtx)) { - EnFish_Respawning_SetupFleePlayer(this); - } -} - -// The three following actionfunctions also turn the yaw to home if the fish is too far from it. - -void EnFish_Respawning_SetupFollowChild(EnFish* this) { - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - this->timer = Rand_S16Offset(15, 45); - this->unk_250 = 0; - EnFish_SetInWaterAnimation(this); - this->actionFunc = EnFish_Respawning_FollowChild; -} - -void EnFish_Respawning_FollowChild(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - - EnFish_SetYOffset(this); - Math_SmoothStepToF(&this->actor.speedXZ, 1.8f, 0.08f, 0.4f, 0.0f); - - if ((EnFish_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(80.0f)) || (this->timer < 4)) { - Math_StepToAngleS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), - 3000); - } else if ((this->actor.child != NULL) && (&this->actor != this->actor.child)) { - Math_StepToAngleS(&this->actor.world.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos), 3000); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - this->skelAnime.playSpeed = CLAMP_MAX(this->actor.speedXZ * 1.5f + 0.8f, 4.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - EnFish_Respawning_SetupSlowDown(this); - } else if (&this->actor == this->actor.child) { - EnFish_Respawning_SetupApproachPlayer(this); - } else if (EnFish_CheckXZDistanceToPlayer(this, globalCtx)) { - EnFish_Respawning_SetupFleePlayer(this); - } -} - -void EnFish_Respawning_SetupFleePlayer(EnFish* this) { - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - this->timer = Rand_S16Offset(10, 40); - this->unk_250 = 0; - EnFish_SetInWaterAnimation(this); - this->actionFunc = EnFish_Respawning_FleePlayer; -} - -void EnFish_Respawning_FleePlayer(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - s16 pad2; - s16 frames; - s16 yaw; - s16 playerClose; - - EnFish_SetYOffset(this); - playerClose = EnFish_CheckXZDistanceToPlayer(this, globalCtx); - Math_SmoothStepToF(&this->actor.speedXZ, 4.2f, 0.08f, 1.4f, 0.0f); - - if (EnFish_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(160.0f)) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_StepToAngleS(&this->actor.world.rot.y, yaw, 3000); - } else if ((this->actor.child != NULL) && (&this->actor != this->actor.child)) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); - Math_StepToAngleS(&this->actor.world.rot.y, yaw, 2000); - } else if (playerClose) { - yaw = this->actor.yawTowardsPlayer + 0x8000; - frames = globalCtx->state.frames; - - if (frames & 0x10) { - if (frames & 0x20) { - yaw += 0x2000; - } - } else { - if (frames & 0x20) { - yaw -= 0x2000; - } - } - if (globalCtx) {} - Math_StepToAngleS(&this->actor.world.rot.y, yaw, 2000); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - this->skelAnime.playSpeed = CLAMP_MAX(this->actor.speedXZ * 1.5f + 0.8f, 4.0f); - - SkelAnime_Update(&this->skelAnime); - - if ((this->timer <= 0) || !playerClose) { - EnFish_Respawning_SetupSlowDown(this); - } else if (&this->actor == this->actor.child) { - EnFish_Respawning_SetupApproachPlayer(this); - } -} - -void EnFish_Respawning_SetupApproachPlayer(EnFish* this) { - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - EnFish_SetInWaterAnimation(this); - this->timer = Rand_S16Offset(10, 40); - this->unk_250 = 0; - this->actionFunc = EnFish_Respawning_ApproachPlayer; -} - -void EnFish_Respawning_ApproachPlayer(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 pad2; - Vec3f sp38; - s16 yaw; - s16 temp_a0_2; - - EnFish_SetYOffset(this); - Math_SmoothStepToF(&this->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); - - if (EnFish_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(80.0f)) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_StepToAngleS(&this->actor.world.rot.y, yaw, 3000); - } else { - if ((s16)globalCtx->state.frames & 0x40) { - temp_a0_2 = (this->actor.yawTowardsPlayer + 0x9000); - } else { - temp_a0_2 = (this->actor.yawTowardsPlayer + 0x7000); - } - - sp38.x = player->actor.world.pos.x + (Math_SinS(temp_a0_2) * 20.0f); - sp38.y = player->actor.world.pos.y; - sp38.z = player->actor.world.pos.z + (Math_CosS(temp_a0_2) * 20.0f); - - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &sp38); - Math_StepToAngleS(&this->actor.world.rot.y, yaw, 3000); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - this->skelAnime.playSpeed = CLAMP_MAX((this->actor.speedXZ * 1.5f) + 0.8f, 4.0f); - - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - EnFish_Respawning_SetupSlowDown(this); - } -} - -// Dropped type functions - -void EnFish_Dropped_SetupFall(EnFish* this) { - this->actor.gravity = -1.0f; - this->actor.minVelocityY = -10.0f; - this->actor.shape.yOffset = 0.0f; - EnFish_SetOutOfWaterAnimation(this); - this->unk_250 = 5; - this->actionFunc = EnFish_Dropped_Fall; - this->timer = 300; -} - -void EnFish_Dropped_Fall(EnFish* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.1f, 0.0f); - Math_StepToAngleS(&this->actor.world.rot.x, 0x4000, 100); - Math_StepToAngleS(&this->actor.world.rot.z, -0x4000, 100); - this->actor.shape.rot.x = this->actor.world.rot.x; - this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.shape.rot.z = this->actor.world.rot.z; - SkelAnime_Update(&this->skelAnime); - - if (this->actor.bgCheckFlags & 1) { // On floor - this->timer = 400; - EnFish_Dropped_SetupFlopOnGround(this); - } else if (this->actor.bgCheckFlags & 0x20) { // In water - EnFish_Dropped_SetupSwimAway(this); - } else if ((this->timer <= 0) && (this->actor.params == FISH_DROPPED) && - (this->actor.floorHeight < BGCHECK_Y_MIN + 10.0f)) { - osSyncPrintf(VT_COL(YELLOW, BLACK)); - // "BG missing? Running Actor_delete" - osSyncPrintf("BG 抜け? Actor_delete します(%s %d)\n", "../z_en_sakana.c", 822); - osSyncPrintf(VT_RST); - Actor_Kill(&this->actor); - } -} - -/** - * If the fish is on a floor, this function is looped back to by EnFish_Dropped_FlopOnGround to set a new flopping - * height and whether the sound should play again. - */ -void EnFish_Dropped_SetupFlopOnGround(EnFish* this) { - s32 pad; - f32 randomFloat; - s32 playSound; - - this->actor.gravity = -1.0f; - this->actor.minVelocityY = -10.0f; - randomFloat = Rand_ZeroOne(); - - if (randomFloat < 0.1f) { - this->actor.velocity.y = (Rand_ZeroOne() * 3.0f) + 2.5f; - playSound = true; - } else if (randomFloat < 0.2f) { - this->actor.velocity.y = (Rand_ZeroOne() * 1.2f) + 0.2f; - playSound = true; - } else { - this->actor.velocity.y = 0.0f; - - if (Rand_ZeroOne() < 0.2f) { - playSound = true; - } else { - playSound = false; - } - } - - this->actor.shape.yOffset = 300.0f; - EnFish_SetOutOfWaterAnimation(this); - this->actionFunc = EnFish_Dropped_FlopOnGround; - this->unk_250 = 5; - - if (playSound && (this->actor.draw != NULL)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FISH_LEAP); - } -} - -void EnFish_Dropped_FlopOnGround(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - s16 frames = globalCtx->state.frames; - s16 targetXRot; - - Math_SmoothStepToF(&this->actor.speedXZ, Rand_ZeroOne() * 0.2f, 0.1f, 0.1f, 0.0f); - - targetXRot = (s16)((((frames >> 5) & 2) | ((frames >> 2) & 1)) << 0xB) * 0.3f; - - if (frames & 4) { - targetXRot = -targetXRot; - } - - Math_StepToAngleS(&this->actor.world.rot.x, targetXRot, 4000); - Math_StepToAngleS(&this->actor.world.rot.z, 0x4000, 1000); - this->actor.world.rot.y += - (s16)(((Math_SinS(this->slowPhase) * 2000.0f) + (Math_SinS(this->fastPhase) * 1000.0f)) * Rand_ZeroOne()); - this->actor.shape.rot = this->actor.world.rot; - - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - Actor_Kill(&this->actor); - return; - } - - if (this->timer <= 60) { - // Blink when about to disappear - if (frames & 4) { - this->actor.draw = EnFish_Draw; - } else { - this->actor.draw = NULL; - } - } else if (this->actor.bgCheckFlags & 0x20) { // In water - EnFish_Dropped_SetupSwimAway(this); - } else if (this->actor.bgCheckFlags & 1) { // On floor - EnFish_Dropped_SetupFlopOnGround(this); - } -} - -void EnFish_Dropped_SetupSwimAway(EnFish* this) { - this->actor.home.pos = this->actor.world.pos; - this->actor.flags |= ACTOR_FLAG_4; - this->timer = 200; - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - this->actor.shape.yOffset = 0.0f; - EnFish_SetInWaterAnimation(this); - this->actionFunc = EnFish_Dropped_SwimAway; - this->unk_250 = 5; -} - -void EnFish_Dropped_SwimAway(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - - Math_SmoothStepToF(&this->actor.speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); - - // If touching wall or not in water, turn back and slow down for one frame. - if ((this->actor.bgCheckFlags & 8) || !(this->actor.bgCheckFlags & 0x20)) { - this->actor.home.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - this->actor.speedXZ *= 0.5f; - } - - Math_StepToAngleS(&this->actor.world.rot.x, 0, 1500); - Math_StepToAngleS(&this->actor.world.rot.y, this->actor.home.rot.y, 3000); - Math_StepToAngleS(&this->actor.world.rot.z, 0, 1000); - - this->actor.shape.rot = this->actor.world.rot; - - // Raise if on a floor. - if (this->actor.bgCheckFlags & 1) { - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 4.0f, 2.0f); - } else { - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 10.0f, 2.0f); - } - - // Shrink when close to disappearing. - if (this->timer < 100) { - Actor_SetScale(&this->actor, this->actor.scale.x * 0.982f); - } - - this->skelAnime.playSpeed = CLAMP_MAX((this->actor.speedXZ * 1.5f) + 1.0f, 4.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - Actor_Kill(&this->actor); - } -} - -// Unique type functions - -void EnFish_Unique_SetupSwimIdle(EnFish* this) { - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - this->timer = Rand_S16Offset(5, 35); - this->unk_250 = 0; - EnFish_SetInWaterAnimation(this); - this->actionFunc = EnFish_Unique_SwimIdle; -} - -void EnFish_Unique_SwimIdle(EnFish* this, GlobalContext* globalCtx) { - static f32 speedStopping[] = { 0.0f, 0.04f, 0.09f }; - static f32 speedMoving[] = { 0.5f, 0.1f, 0.15f }; - f32 playSpeed; - u32 frames = globalCtx->gameplayFrames; - f32* speed; - s32 pad2; - f32 extraPlaySpeed; - s32 pad3; - - if (this->actor.xzDistToPlayer < 60.0f) { - if (this->timer < 12) { - speed = speedMoving; - } else { - speed = speedStopping; - } - } else { - if (this->timer < 4) { - speed = speedMoving; - } else { - speed = speedStopping; - } - } - - EnFish_SetYOffset(this); - Math_SmoothStepToF(&this->actor.speedXZ, speed[0], speed[1], speed[2], 0.0f); - - extraPlaySpeed = 0.0f; - - if ((EnFish_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(15.0f))) { - if (!Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), - 200)) { - extraPlaySpeed = 0.5f; - } - } else if ((this->timer < 4) && !Math_ScaledStepToS(&this->actor.world.rot.y, frames * 0x80, 100)) { - extraPlaySpeed = 0.5f; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - playSpeed = (this->actor.speedXZ * 1.2f) + 0.2f + extraPlaySpeed; - this->skelAnime.playSpeed = CLAMP(playSpeed, 1.5f, 0.5); - SkelAnime_Update(&this->skelAnime); - - if (this->timer <= 0) { - this->timer = Rand_S16Offset(5, 80); - } -} - -// Cutscene functions - -void EnFish_Cutscene_FlopOnGround(EnFish* this, GlobalContext* globalCtx) { - f32 sp24 = Math_SinS(this->slowPhase); - f32 sp20 = Math_SinS(this->fastPhase); - - D_80A17014 += D_80A17018; - - if (D_80A17014 <= 1.0f) { - D_80A17014 = 1.0f; - - if (Rand_ZeroOne() < 0.1f) { - D_80A17018 = (Rand_ZeroOne() * 3.0f) + 2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FISH_LEAP); - } else { - D_80A17018 = 0.0f; - } - } else { - D_80A17018 -= 0.4f; - } - - this->skelAnime.playSpeed = ((sp24 + sp20) * 0.5f) + 2.0f; - SkelAnime_Update(&this->skelAnime); -} - -void EnFish_Cutscene_WiggleFlyingThroughAir(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - f32 sp28 = Math_SinS(this->slowPhase); - f32 sp24 = Math_SinS(this->fastPhase); - - this->actor.shape.rot.x -= 500; - this->actor.shape.rot.z += 100; - Math_StepToF(&D_80A17014, 0.0f, 1.0f); - this->skelAnime.playSpeed = ((sp28 + sp24) * 0.5f) + 2.0f; - SkelAnime_Update(&this->skelAnime); -} - -void EnFish_UpdateCutscene(EnFish* this, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; - CsCmdActorAction* csAction = globalCtx->csCtx.npcActions[1]; - Vec3f startPos; - Vec3f endPos; - f32 progress; - s32 bgId; - - if (csAction == NULL) { - // "Warning : DEMO ended without dousa (action) 3 termination being called" - osSyncPrintf("Warning : dousa 3 消滅 が呼ばれずにデモが終了した(%s %d)(arg_data 0x%04x)\n", "../z_en_sakana.c", - 1169, this->actor.params); - EnFish_ClearCutsceneData(this); - Actor_Kill(&this->actor); - return; - } - - this->slowPhase += 0x111; - this->fastPhase += 0x500; - - switch (csAction->action) { - case 1: - EnFish_Cutscene_FlopOnGround(this, globalCtx); - break; - case 2: - EnFish_Cutscene_WiggleFlyingThroughAir(this, globalCtx); - break; - case 3: - // "DEMO fish termination" - osSyncPrintf("デモ魚消滅\n"); - EnFish_ClearCutsceneData(this); - Actor_Kill(&this->actor); - return; - default: - // "Improper DEMO action" - osSyncPrintf("不正なデモ動作(%s %d)(arg_data 0x%04x)\n", "../z_en_sakana.c", 1200, this->actor.params); - break; - } - - startPos.x = csAction->startPos.x; - startPos.y = csAction->startPos.y; - startPos.z = csAction->startPos.z; - endPos.x = csAction->endPos.x; - endPos.y = csAction->endPos.y; - endPos.z = csAction->endPos.z; - - progress = Environment_LerpWeight(csAction->endFrame, csAction->startFrame, globalCtx->csCtx.frames); - - this->actor.world.pos.x = (endPos.x - startPos.x) * progress + startPos.x; - this->actor.world.pos.y = (endPos.y - startPos.y) * progress + startPos.y + D_80A17014; - this->actor.world.pos.z = (endPos.z - startPos.z) * progress + startPos.z; - - this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); -} - -// Update functions and Draw - -void EnFish_OrdinaryUpdate(EnFish* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; - } - - this->slowPhase += 0x111; - this->fastPhase += 0x500; - - if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { - this->actor.child = NULL; - } - - if ((this->actionFunc == NULL) || (this->actionFunc(this, globalCtx), (this->actor.update != NULL))) { - Actor_MoveForward(&this->actor); - - if (this->unk_250 != 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 17.5f, 4.0f, 0.0f, this->unk_250); - } - - if (this->actor.xzDistToPlayer < 70.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.01f); - - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - - if (this->actor.params == FISH_DROPPED) { - Actor_Kill(&this->actor); - return; - } - - EnFish_BeginRespawn(this); - } else if (EnFish_InBottleRange(this, globalCtx)) { - // GI_MAX in this case allows the player to catch the actor in a bottle - func_8002F434(&this->actor, globalCtx, GI_MAX, 80.0f, 20.0f); - } - } -} - -void EnFish_RespawningUpdate(EnFish* this, GlobalContext* globalCtx) { - if (this->actor.params == FISH_SWIMMING_UNIQUE) { - Actor_Kill(&this->actor); - return; - } - - if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { - this->actor.child = NULL; - } - - if ((this->actionFunc == NULL) || (this->actionFunc(this, globalCtx), (this->actor.update != NULL))) { - Actor_MoveForward(&this->actor); - - if (this->respawnTimer == 20) { - this->actor.draw = EnFish_Draw; - } else if (this->respawnTimer == 0) { - Actor_SetScale(&this->actor, 0.01f); - } else if (this->respawnTimer < 20) { - Actor_SetScale(&this->actor, CLAMP_MAX(this->actor.scale.x + 0.001f, 0.01f)); - } - } -} - -void EnFish_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFish* this = (EnFish*)thisx; - - if ((D_80A17010 == NULL) && (this->actor.params == FISH_DROPPED) && (globalCtx->csCtx.state != 0) && - (globalCtx->csCtx.npcActions[1] != NULL)) { - EnFish_SetCutsceneData(this); - } - - if ((D_80A17010 != NULL) && (&this->actor == D_80A17010)) { - EnFish_UpdateCutscene(this, globalCtx); - } else if (this->respawnTimer > 0) { - this->respawnTimer--; - EnFish_RespawningUpdate(this, globalCtx); - } else { - EnFish_OrdinaryUpdate(this, globalCtx); - } -} - -void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnFish* this = (EnFish*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, NULL); - Collider_UpdateSpheres(0, &this->collider); -} diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.cpp b/src/overlays/actors/ovl_En_Fish/z_en_fish.cpp new file mode 100644 index 000000000..d5cc44d65 --- /dev/null +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.cpp @@ -0,0 +1,777 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FISH_Z_EN_FISH_C +#include "actor_common.h" +/* + * File: z_en_fish.c + * Overlay: ovl_En_Fish + * Description: Fish + */ + +#include "z_en_fish.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "vt.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void EnFish_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFish_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnFish_Respawning_SetupSlowDown(EnFish* pthis); +void EnFish_Respawning_SlowDown(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Respawning_SetupFollowChild(EnFish* pthis); +void EnFish_Respawning_FollowChild(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Respawning_SetupFleePlayer(EnFish* pthis); +void EnFish_Respawning_FleePlayer(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Respawning_SetupApproachPlayer(EnFish* pthis); +void EnFish_Respawning_ApproachPlayer(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Dropped_SetupFall(EnFish* pthis); +void EnFish_Dropped_Fall(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Dropped_SetupFlopOnGround(EnFish* pthis); +void EnFish_Dropped_FlopOnGround(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Dropped_SetupSwimAway(EnFish* pthis); +void EnFish_Dropped_SwimAway(EnFish* pthis, GlobalContext* globalCtx); +void EnFish_Unique_SetupSwimIdle(EnFish* pthis); +void EnFish_Unique_SwimIdle(EnFish* pthis, GlobalContext* globalCtx); + +// Used in the cutscene functions +static Actor* D_80A17010 = NULL; +static f32 D_80A17014 = 0.0f; +static f32 D_80A17018 = 0.0f; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 5 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +ActorInit En_Fish_InitVars = { + ACTOR_EN_FISH, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnFish), + (ActorFunc)EnFish_Init, + (ActorFunc)EnFish_Destroy, + (ActorFunc)EnFish_Update, + (ActorFunc)EnFish_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 900, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 700, ICHAIN_STOP), +}; + +f32 EnFish_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { + return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); +} + +void EnFish_SetInWaterAnimation(EnFish* pthis) { + Animation_Change(&pthis->skelAnime, &gFishInWaterAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gFishInWaterAnim), + ANIMMODE_LOOP_INTERP, 2.0f); +} + +void EnFish_SetOutOfWaterAnimation(EnFish* pthis) { + Animation_Change(&pthis->skelAnime, &gFishOutOfWaterAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gFishOutOfWaterAnim), + ANIMMODE_LOOP_INTERP, 2.0f); +} + +void EnFish_BeginRespawn(EnFish* pthis) { + pthis->respawnTimer = 400; + Actor_SetScale(&pthis->actor, 0.001f); + pthis->actor.draw = NULL; +} + +void EnFish_SetCutsceneData(EnFish* pthis) { + Actor* thisx = &pthis->actor; + + if (D_80A17010 == NULL) { + D_80A17010 = thisx; + Actor_SetScale(thisx, 0.01f); + thisx->draw = EnFish_Draw; + thisx->shape.rot.x = 0; + thisx->shape.rot.y = -0x6410; + thisx->shape.rot.z = 0x4000; + thisx->shape.yOffset = 600.0f; + D_80A17014 = 10.0f; + D_80A17018 = 0.0f; + thisx->flags |= ACTOR_FLAG_4; + EnFish_SetOutOfWaterAnimation(pthis); + } +} + +void EnFish_ClearCutsceneData(EnFish* pthis) { + D_80A17010 = NULL; + D_80A17014 = 0.0f; + D_80A17018 = 0.0f; +} + +void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFish* pthis = (EnFish*)thisx; + s16 params = pthis->actor.params; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFishSkel, &gFishInWaterAnim, pthis->jointTable, pthis->morphTable, + 7); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + pthis->actor.colChkInfo.mass = 50; + pthis->slowPhase = Rand_ZeroOne() * (0xFFFF + 0.5f); + pthis->fastPhase = Rand_ZeroOne() * (0xFFFF + 0.5f); + + if (params == FISH_DROPPED) { + pthis->actor.flags |= ACTOR_FLAG_4; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); + EnFish_Dropped_SetupFall(pthis); + } else if (params == FISH_SWIMMING_UNIQUE) { + EnFish_Unique_SetupSwimIdle(pthis); + } else { + EnFish_Respawning_SetupSlowDown(pthis); + } +} + +void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFish* pthis = (EnFish*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnFish_SetYOffset(EnFish* pthis) { + pthis->actor.shape.yOffset += (Math_SinS(pthis->slowPhase) * 10.0f + Math_SinS(pthis->fastPhase) * 5.0f); + pthis->actor.shape.yOffset = CLAMP(pthis->actor.shape.yOffset, -200.0f, 200.0f); +} + +s32 EnFish_InBottleRange(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp1C; + + if (pthis->actor.xzDistToPlayer < 32.0f) { + sp1C.x = (Math_SinS(pthis->actor.yawTowardsPlayer + 0x8000) * 16.0f) + player->actor.world.pos.x; + sp1C.y = player->actor.world.pos.y; + sp1C.z = (Math_CosS(pthis->actor.yawTowardsPlayer + 0x8000) * 16.0f) + player->actor.world.pos.z; + + //! @bug: pthis check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have + //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's + //! world rotation. + if (EnFish_XZDistanceSquared(&sp1C, &pthis->actor.world.pos) <= SQ(20.0f)) { + return true; + } + } + + return false; +} + +s32 EnFish_CheckXZDistanceToPlayer(EnFish* pthis, GlobalContext* globalCtx) { + return (pthis->actor.xzDistToPlayer < 60.0f); +} + +// Respawning type functions + +void EnFish_Respawning_SetupSlowDown(EnFish* pthis) { + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + pthis->timer = Rand_S16Offset(5, 35); + pthis->unk_250 = 0; + EnFish_SetInWaterAnimation(pthis); + pthis->actionFunc = EnFish_Respawning_SlowDown; +} + +void EnFish_Respawning_SlowDown(EnFish* pthis, GlobalContext* globalCtx) { + EnFish_SetYOffset(pthis); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.05f, 0.3f, 0.0f); + pthis->skelAnime.playSpeed = CLAMP_MAX(pthis->actor.speedXZ * 1.4f + 0.8f, 2.0f); + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->timer <= 0) { + EnFish_Respawning_SetupFollowChild(pthis); + } else if (&pthis->actor == pthis->actor.child) { + EnFish_Respawning_SetupApproachPlayer(pthis); + } else if (EnFish_CheckXZDistanceToPlayer(pthis, globalCtx)) { + EnFish_Respawning_SetupFleePlayer(pthis); + } +} + +// The three following actionfunctions also turn the yaw to home if the fish is too far from it. + +void EnFish_Respawning_SetupFollowChild(EnFish* pthis) { + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + pthis->timer = Rand_S16Offset(15, 45); + pthis->unk_250 = 0; + EnFish_SetInWaterAnimation(pthis); + pthis->actionFunc = EnFish_Respawning_FollowChild; +} + +void EnFish_Respawning_FollowChild(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + + EnFish_SetYOffset(pthis); + Math_SmoothStepToF(&pthis->actor.speedXZ, 1.8f, 0.08f, 0.4f, 0.0f); + + if ((EnFish_XZDistanceSquared(&pthis->actor.world.pos, &pthis->actor.home.pos) > SQ(80.0f)) || (pthis->timer < 4)) { + Math_StepToAngleS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos), + 3000); + } else if ((pthis->actor.child != NULL) && (&pthis->actor != pthis->actor.child)) { + Math_StepToAngleS(&pthis->actor.world.rot.y, + Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.child->world.pos), 3000); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->skelAnime.playSpeed = CLAMP_MAX(pthis->actor.speedXZ * 1.5f + 0.8f, 4.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + EnFish_Respawning_SetupSlowDown(pthis); + } else if (&pthis->actor == pthis->actor.child) { + EnFish_Respawning_SetupApproachPlayer(pthis); + } else if (EnFish_CheckXZDistanceToPlayer(pthis, globalCtx)) { + EnFish_Respawning_SetupFleePlayer(pthis); + } +} + +void EnFish_Respawning_SetupFleePlayer(EnFish* pthis) { + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + pthis->timer = Rand_S16Offset(10, 40); + pthis->unk_250 = 0; + EnFish_SetInWaterAnimation(pthis); + pthis->actionFunc = EnFish_Respawning_FleePlayer; +} + +void EnFish_Respawning_FleePlayer(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 pad2; + s16 frames; + s16 yaw; + s16 playerClose; + + EnFish_SetYOffset(pthis); + playerClose = EnFish_CheckXZDistanceToPlayer(pthis, globalCtx); + Math_SmoothStepToF(&pthis->actor.speedXZ, 4.2f, 0.08f, 1.4f, 0.0f); + + if (EnFish_XZDistanceSquared(&pthis->actor.world.pos, &pthis->actor.home.pos) > SQ(160.0f)) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_StepToAngleS(&pthis->actor.world.rot.y, yaw, 3000); + } else if ((pthis->actor.child != NULL) && (&pthis->actor != pthis->actor.child)) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.child->world.pos); + Math_StepToAngleS(&pthis->actor.world.rot.y, yaw, 2000); + } else if (playerClose) { + yaw = pthis->actor.yawTowardsPlayer + 0x8000; + frames = globalCtx->state.frames; + + if (frames & 0x10) { + if (frames & 0x20) { + yaw += 0x2000; + } + } else { + if (frames & 0x20) { + yaw -= 0x2000; + } + } + if (globalCtx) {} + Math_StepToAngleS(&pthis->actor.world.rot.y, yaw, 2000); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->skelAnime.playSpeed = CLAMP_MAX(pthis->actor.speedXZ * 1.5f + 0.8f, 4.0f); + + SkelAnime_Update(&pthis->skelAnime); + + if ((pthis->timer <= 0) || !playerClose) { + EnFish_Respawning_SetupSlowDown(pthis); + } else if (&pthis->actor == pthis->actor.child) { + EnFish_Respawning_SetupApproachPlayer(pthis); + } +} + +void EnFish_Respawning_SetupApproachPlayer(EnFish* pthis) { + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + EnFish_SetInWaterAnimation(pthis); + pthis->timer = Rand_S16Offset(10, 40); + pthis->unk_250 = 0; + pthis->actionFunc = EnFish_Respawning_ApproachPlayer; +} + +void EnFish_Respawning_ApproachPlayer(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + Vec3f sp38; + s16 yaw; + s16 temp_a0_2; + + EnFish_SetYOffset(pthis); + Math_SmoothStepToF(&pthis->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + + if (EnFish_XZDistanceSquared(&pthis->actor.world.pos, &pthis->actor.home.pos) > SQ(80.0f)) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_StepToAngleS(&pthis->actor.world.rot.y, yaw, 3000); + } else { + if ((s16)globalCtx->state.frames & 0x40) { + temp_a0_2 = (pthis->actor.yawTowardsPlayer + 0x9000); + } else { + temp_a0_2 = (pthis->actor.yawTowardsPlayer + 0x7000); + } + + sp38.x = player->actor.world.pos.x + (Math_SinS(temp_a0_2) * 20.0f); + sp38.y = player->actor.world.pos.y; + sp38.z = player->actor.world.pos.z + (Math_CosS(temp_a0_2) * 20.0f); + + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &sp38); + Math_StepToAngleS(&pthis->actor.world.rot.y, yaw, 3000); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->skelAnime.playSpeed = CLAMP_MAX((pthis->actor.speedXZ * 1.5f) + 0.8f, 4.0f); + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + EnFish_Respawning_SetupSlowDown(pthis); + } +} + +// Dropped type functions + +void EnFish_Dropped_SetupFall(EnFish* pthis) { + pthis->actor.gravity = -1.0f; + pthis->actor.minVelocityY = -10.0f; + pthis->actor.shape.yOffset = 0.0f; + EnFish_SetOutOfWaterAnimation(pthis); + pthis->unk_250 = 5; + pthis->actionFunc = EnFish_Dropped_Fall; + pthis->timer = 300; +} + +void EnFish_Dropped_Fall(EnFish* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 0.1f, 0.0f); + Math_StepToAngleS(&pthis->actor.world.rot.x, 0x4000, 100); + Math_StepToAngleS(&pthis->actor.world.rot.z, -0x4000, 100); + pthis->actor.shape.rot.x = pthis->actor.world.rot.x; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->actor.shape.rot.z = pthis->actor.world.rot.z; + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.bgCheckFlags & 1) { // On floor + pthis->timer = 400; + EnFish_Dropped_SetupFlopOnGround(pthis); + } else if (pthis->actor.bgCheckFlags & 0x20) { // In water + EnFish_Dropped_SetupSwimAway(pthis); + } else if ((pthis->timer <= 0) && (pthis->actor.params == FISH_DROPPED) && + (pthis->actor.floorHeight < BGCHECK_Y_MIN + 10.0f)) { + osSyncPrintf(VT_COL(YELLOW, BLACK)); + // "BG missing? Running Actor_delete" + osSyncPrintf("BG 抜け? Actor_delete します(%s %d)\n", "../z_en_sakana.c", 822); + osSyncPrintf(VT_RST); + Actor_Kill(&pthis->actor); + } +} + +/** + * If the fish is on a floor, pthis function is looped back to by EnFish_Dropped_FlopOnGround to set a new flopping + * height and whether the sound should play again. + */ +void EnFish_Dropped_SetupFlopOnGround(EnFish* pthis) { + s32 pad; + f32 randomFloat; + s32 playSound; + + pthis->actor.gravity = -1.0f; + pthis->actor.minVelocityY = -10.0f; + randomFloat = Rand_ZeroOne(); + + if (randomFloat < 0.1f) { + pthis->actor.velocity.y = (Rand_ZeroOne() * 3.0f) + 2.5f; + playSound = true; + } else if (randomFloat < 0.2f) { + pthis->actor.velocity.y = (Rand_ZeroOne() * 1.2f) + 0.2f; + playSound = true; + } else { + pthis->actor.velocity.y = 0.0f; + + if (Rand_ZeroOne() < 0.2f) { + playSound = true; + } else { + playSound = false; + } + } + + pthis->actor.shape.yOffset = 300.0f; + EnFish_SetOutOfWaterAnimation(pthis); + pthis->actionFunc = EnFish_Dropped_FlopOnGround; + pthis->unk_250 = 5; + + if (playSound && (pthis->actor.draw != NULL)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FISH_LEAP); + } +} + +void EnFish_Dropped_FlopOnGround(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 frames = globalCtx->state.frames; + s16 targetXRot; + + Math_SmoothStepToF(&pthis->actor.speedXZ, Rand_ZeroOne() * 0.2f, 0.1f, 0.1f, 0.0f); + + targetXRot = (s16)((((frames >> 5) & 2) | ((frames >> 2) & 1)) << 0xB) * 0.3f; + + if (frames & 4) { + targetXRot = -targetXRot; + } + + Math_StepToAngleS(&pthis->actor.world.rot.x, targetXRot, 4000); + Math_StepToAngleS(&pthis->actor.world.rot.z, 0x4000, 1000); + pthis->actor.world.rot.y += + (s16)(((Math_SinS(pthis->slowPhase) * 2000.0f) + (Math_SinS(pthis->fastPhase) * 1000.0f)) * Rand_ZeroOne()); + pthis->actor.shape.rot = pthis->actor.world.rot; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->timer <= 60) { + // Blink when about to disappear + if (frames & 4) { + pthis->actor.draw = EnFish_Draw; + } else { + pthis->actor.draw = NULL; + } + } else if (pthis->actor.bgCheckFlags & 0x20) { // In water + EnFish_Dropped_SetupSwimAway(pthis); + } else if (pthis->actor.bgCheckFlags & 1) { // On floor + EnFish_Dropped_SetupFlopOnGround(pthis); + } +} + +void EnFish_Dropped_SetupSwimAway(EnFish* pthis) { + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->timer = 200; + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + pthis->actor.shape.yOffset = 0.0f; + EnFish_SetInWaterAnimation(pthis); + pthis->actionFunc = EnFish_Dropped_SwimAway; + pthis->unk_250 = 5; +} + +void EnFish_Dropped_SwimAway(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + + // If touching wall or not in water, turn back and slow down for one frame. + if ((pthis->actor.bgCheckFlags & 8) || !(pthis->actor.bgCheckFlags & 0x20)) { + pthis->actor.home.rot.y = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->actor.speedXZ *= 0.5f; + } + + Math_StepToAngleS(&pthis->actor.world.rot.x, 0, 1500); + Math_StepToAngleS(&pthis->actor.world.rot.y, pthis->actor.home.rot.y, 3000); + Math_StepToAngleS(&pthis->actor.world.rot.z, 0, 1000); + + pthis->actor.shape.rot = pthis->actor.world.rot; + + // Raise if on a floor. + if (pthis->actor.bgCheckFlags & 1) { + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - 4.0f, 2.0f); + } else { + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - 10.0f, 2.0f); + } + + // Shrink when close to disappearing. + if (pthis->timer < 100) { + Actor_SetScale(&pthis->actor, pthis->actor.scale.x * 0.982f); + } + + pthis->skelAnime.playSpeed = CLAMP_MAX((pthis->actor.speedXZ * 1.5f) + 1.0f, 4.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + Actor_Kill(&pthis->actor); + } +} + +// Unique type functions + +void EnFish_Unique_SetupSwimIdle(EnFish* pthis) { + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + pthis->timer = Rand_S16Offset(5, 35); + pthis->unk_250 = 0; + EnFish_SetInWaterAnimation(pthis); + pthis->actionFunc = EnFish_Unique_SwimIdle; +} + +void EnFish_Unique_SwimIdle(EnFish* pthis, GlobalContext* globalCtx) { + static f32 speedStopping[] = { 0.0f, 0.04f, 0.09f }; + static f32 speedMoving[] = { 0.5f, 0.1f, 0.15f }; + f32 playSpeed; + u32 frames = globalCtx->gameplayFrames; + f32* speed; + s32 pad2; + f32 extraPlaySpeed; + s32 pad3; + + if (pthis->actor.xzDistToPlayer < 60.0f) { + if (pthis->timer < 12) { + speed = speedMoving; + } else { + speed = speedStopping; + } + } else { + if (pthis->timer < 4) { + speed = speedMoving; + } else { + speed = speedStopping; + } + } + + EnFish_SetYOffset(pthis); + Math_SmoothStepToF(&pthis->actor.speedXZ, speed[0], speed[1], speed[2], 0.0f); + + extraPlaySpeed = 0.0f; + + if ((EnFish_XZDistanceSquared(&pthis->actor.world.pos, &pthis->actor.home.pos) > SQ(15.0f))) { + if (!Math_ScaledStepToS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos), + 200)) { + extraPlaySpeed = 0.5f; + } + } else if ((pthis->timer < 4) && !Math_ScaledStepToS(&pthis->actor.world.rot.y, frames * 0x80, 100)) { + extraPlaySpeed = 0.5f; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + playSpeed = (pthis->actor.speedXZ * 1.2f) + 0.2f + extraPlaySpeed; + pthis->skelAnime.playSpeed = CLAMP(playSpeed, 1.5f, 0.5); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer <= 0) { + pthis->timer = Rand_S16Offset(5, 80); + } +} + +// Cutscene functions + +void EnFish_Cutscene_FlopOnGround(EnFish* pthis, GlobalContext* globalCtx) { + f32 sp24 = Math_SinS(pthis->slowPhase); + f32 sp20 = Math_SinS(pthis->fastPhase); + + D_80A17014 += D_80A17018; + + if (D_80A17014 <= 1.0f) { + D_80A17014 = 1.0f; + + if (Rand_ZeroOne() < 0.1f) { + D_80A17018 = (Rand_ZeroOne() * 3.0f) + 2.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FISH_LEAP); + } else { + D_80A17018 = 0.0f; + } + } else { + D_80A17018 -= 0.4f; + } + + pthis->skelAnime.playSpeed = ((sp24 + sp20) * 0.5f) + 2.0f; + SkelAnime_Update(&pthis->skelAnime); +} + +void EnFish_Cutscene_WiggleFlyingThroughAir(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 sp28 = Math_SinS(pthis->slowPhase); + f32 sp24 = Math_SinS(pthis->fastPhase); + + pthis->actor.shape.rot.x -= 500; + pthis->actor.shape.rot.z += 100; + Math_StepToF(&D_80A17014, 0.0f, 1.0f); + pthis->skelAnime.playSpeed = ((sp28 + sp24) * 0.5f) + 2.0f; + SkelAnime_Update(&pthis->skelAnime); +} + +void EnFish_UpdateCutscene(EnFish* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + CsCmdActorAction* csAction = globalCtx->csCtx.npcActions[1]; + Vec3f startPos; + Vec3f endPos; + f32 progress; + s32 bgId; + + if (csAction == NULL) { + // "Warning : DEMO ended without dousa (action) 3 termination being called" + osSyncPrintf("Warning : dousa 3 消滅 が呼ばれずにデモが終了した(%s %d)(arg_data 0x%04x)\n", "../z_en_sakana.c", + 1169, pthis->actor.params); + EnFish_ClearCutsceneData(pthis); + Actor_Kill(&pthis->actor); + return; + } + + pthis->slowPhase += 0x111; + pthis->fastPhase += 0x500; + + switch (csAction->action) { + case 1: + EnFish_Cutscene_FlopOnGround(pthis, globalCtx); + break; + case 2: + EnFish_Cutscene_WiggleFlyingThroughAir(pthis, globalCtx); + break; + case 3: + // "DEMO fish termination" + osSyncPrintf("デモ魚消滅\n"); + EnFish_ClearCutsceneData(pthis); + Actor_Kill(&pthis->actor); + return; + default: + // "Improper DEMO action" + osSyncPrintf("不正なデモ動作(%s %d)(arg_data 0x%04x)\n", "../z_en_sakana.c", 1200, pthis->actor.params); + break; + } + + startPos.x = csAction->startPos.x; + startPos.y = csAction->startPos.y; + startPos.z = csAction->startPos.z; + endPos.x = csAction->endPos.x; + endPos.y = csAction->endPos.y; + endPos.z = csAction->endPos.z; + + progress = Environment_LerpWeight(csAction->endFrame, csAction->startFrame, globalCtx->csCtx.frames); + + pthis->actor.world.pos.x = (endPos.x - startPos.x) * progress + startPos.x; + pthis->actor.world.pos.y = (endPos.y - startPos.y) * progress + startPos.y + D_80A17014; + pthis->actor.world.pos.z = (endPos.z - startPos.z) * progress + startPos.z; + + pthis->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, + &pthis->actor, &pthis->actor.world.pos); +} + +// Update functions and Draw + +void EnFish_OrdinaryUpdate(EnFish* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; + } + + pthis->slowPhase += 0x111; + pthis->fastPhase += 0x500; + + if ((pthis->actor.child != NULL) && (pthis->actor.child->update == NULL) && (&pthis->actor != pthis->actor.child)) { + pthis->actor.child = NULL; + } + + if ((pthis->actionFunc == NULL) || (pthis->actionFunc(pthis, globalCtx), (pthis->actor.update != NULL))) { + Actor_MoveForward(&pthis->actor); + + if (pthis->unk_250 != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 17.5f, 4.0f, 0.0f, pthis->unk_250); + } + + if (pthis->actor.xzDistToPlayer < 70.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + Actor_SetFocus(&pthis->actor, pthis->actor.shape.yOffset * 0.01f); + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + + if (pthis->actor.params == FISH_DROPPED) { + Actor_Kill(&pthis->actor); + return; + } + + EnFish_BeginRespawn(pthis); + } else if (EnFish_InBottleRange(pthis, globalCtx)) { + // GI_MAX in pthis case allows the player to catch the actor in a bottle + func_8002F434(&pthis->actor, globalCtx, GI_MAX, 80.0f, 20.0f); + } + } +} + +void EnFish_RespawningUpdate(EnFish* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == FISH_SWIMMING_UNIQUE) { + Actor_Kill(&pthis->actor); + return; + } + + if ((pthis->actor.child != NULL) && (pthis->actor.child->update == NULL) && (&pthis->actor != pthis->actor.child)) { + pthis->actor.child = NULL; + } + + if ((pthis->actionFunc == NULL) || (pthis->actionFunc(pthis, globalCtx), (pthis->actor.update != NULL))) { + Actor_MoveForward(&pthis->actor); + + if (pthis->respawnTimer == 20) { + pthis->actor.draw = EnFish_Draw; + } else if (pthis->respawnTimer == 0) { + Actor_SetScale(&pthis->actor, 0.01f); + } else if (pthis->respawnTimer < 20) { + Actor_SetScale(&pthis->actor, CLAMP_MAX(pthis->actor.scale.x + 0.001f, 0.01f)); + } + } +} + +void EnFish_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFish* pthis = (EnFish*)thisx; + + if ((D_80A17010 == NULL) && (pthis->actor.params == FISH_DROPPED) && (globalCtx->csCtx.state != 0) && + (globalCtx->csCtx.npcActions[1] != NULL)) { + EnFish_SetCutsceneData(pthis); + } + + if ((D_80A17010 != NULL) && (&pthis->actor == D_80A17010)) { + EnFish_UpdateCutscene(pthis, globalCtx); + } else if (pthis->respawnTimer > 0) { + pthis->respawnTimer--; + EnFish_RespawningUpdate(pthis, globalCtx); + } else { + EnFish_OrdinaryUpdate(pthis, globalCtx); + } +} + +void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFish* pthis = (EnFish*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, NULL); + Collider_UpdateSpheres(0, &pthis->collider); +} diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c deleted file mode 100644 index 39765b494..000000000 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ /dev/null @@ -1,1155 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FLOORMAS_Z_EN_FLOORMAS_C -#include "actor_common.h" -/* - * File: z_en_floormas - * Overlay: En_Floormas - * Description: Floormaster - */ - -#include "z_en_floormas.h" -#include "objects/object_wallmaster/object_wallmaster.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_eff_ss_dead.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_10) - -#define SPAWN_INVISIBLE 0x8000 -#define SPAWN_SMALL 0x10 - -#define MERGE_MASTER 0x40 -#define MERGE_SLAVE 0x20 - -void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnFloormas_GrabLink(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Split(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Recover(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_DrawHighlighted(Actor* this, GlobalContext* globalCtx); -void EnFloormas_SmWait(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_SetupBigDecideAction(EnFloormas* this); -void EnFloormas_Freeze(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_TakeDamage(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Merge(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_JumpAtLink(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_SmSlaveJumpAtMaster(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_SmShrink(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_SmDecideAction(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_SmWalk(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Land(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Hover(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Turn(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Run(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_BigStopWalk(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_BigWalk(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Stand(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_BigDecideAction(EnFloormas* this, GlobalContext* globalCtx); -void EnFloormas_Charge(EnFloormas* this, GlobalContext* globalCtx); - -const ActorInit En_Floormas_InitVars = { - ACTOR_EN_FLOORMAS, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_WALLMASTER, - sizeof(EnFloormas), - (ActorFunc)EnFloormas_Init, - (ActorFunc)EnFloormas_Destroy, - (ActorFunc)EnFloormas_Update, - (ActorFunc)EnFloormas_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x04, 0x10 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 25, 40, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 4, 30, 40, 150 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(4, 0x4), - /* Unk arrow 1 */ DMG_ENTRY(4, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(4, 0x4), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x31, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), -}; - -void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnFloormas* this = (EnFloormas*)thisx; - GlobalContext* globalCtx = globalCtx2; - s32 invisble; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterWaitAnim, this->jointTable, - this->morphTable, 25); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->zOffset = -1600; - invisble = this->actor.params & SPAWN_INVISIBLE; - - // s16 cast needed - this->actor.params &= (s16) ~(SPAWN_INVISIBLE); - if (invisble) { - this->actor.flags |= ACTOR_FLAG_7; - this->actor.draw = EnFloormas_DrawHighlighted; - } - - if (this->actor.params == SPAWN_SMALL) { - this->actor.draw = NULL; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnFloormas_SmWait; - } else { - // spawn first small floormaster - this->actor.parent = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, invisble + SPAWN_SMALL); - if (this->actor.parent == NULL) { - Actor_Kill(&this->actor); - return; - } - // spawn 2nd small floormaster - this->actor.child = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, invisble + SPAWN_SMALL); - if (this->actor.child == NULL) { - Actor_Kill(this->actor.parent); - Actor_Kill(&this->actor); - return; - } - - // link floormasters together - this->actor.parent->child = &this->actor; - this->actor.parent->parent = this->actor.child; - this->actor.child->parent = &this->actor; - this->actor.child->child = this->actor.parent; - EnFloormas_SetupBigDecideAction(this); - } -} - -void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFloormas* this = (EnFloormas*)thisx; - ColliderCylinder* col = &this->collider; - Collider_DestroyCylinder(globalCtx, col); -} - -void EnFloormas_MakeInvulnerable(EnFloormas* this) { - this->collider.base.colType = COLTYPE_HARD; - this->collider.base.acFlags |= AC_HARD; - this->actionTarget = 0x28; -} - -void EnFloormas_MakeVulnerable(EnFloormas* this) { - this->collider.base.colType = COLTYPE_HIT0; - this->actionTarget = 0; - this->collider.base.acFlags &= ~AC_HARD; -} - -void EnFloormas_SetupBigDecideAction(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterWaitAnim); - this->actionFunc = EnFloormas_BigDecideAction; - this->actor.speedXZ = 0.0f; -} - -void EnFloormas_SetupStand(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterStandUpAnim, -3.0f); - this->actionFunc = EnFloormas_Stand; -} - -void EnFloormas_SetupBigWalk(EnFloormas* this) { - if (this->actionFunc != EnFloormas_Run) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 1.5f); - } else { - this->skelAnime.playSpeed = 1.5f; - } - - this->actionTimer = Rand_S16Offset(2, 4); - this->actionFunc = EnFloormas_BigWalk; - this->actor.speedXZ = 1.5f; -} - -void EnFloormas_SetupBigStopWalk(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); - this->actionFunc = EnFloormas_BigStopWalk; - this->actor.speedXZ = 0.0f; -} - -void EnFloormas_SetupRun(EnFloormas* this) { - this->actionTimer = 0; - this->actionFunc = EnFloormas_Run; - this->actor.speedXZ = 5.0f; - this->skelAnime.playSpeed = 3.0f; -} - -void EnFloormas_SetupTurn(EnFloormas* this) { - s16 rotDelta = this->actionTarget - this->actor.shape.rot.y; - - this->actor.speedXZ = 0.0f; - if (rotDelta > 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); - } else { - Animation_Change(&this->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), - 0.0f, ANIMMODE_ONCE, -3.0f); - } - - if (this->actor.scale.x > 0.004f) { - this->actionTarget = (rotDelta * (2.0f / 30.0f)); - } else { - this->skelAnime.playSpeed = this->skelAnime.playSpeed + this->skelAnime.playSpeed; - this->actionTarget = rotDelta * (2.0f / 15.0f); - } - this->actionFunc = EnFloormas_Turn; -} - -void EnFloormas_SetupHover(EnFloormas* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0, Animation_GetLastFrame(&gWallmasterHoverAnim), - ANIMMODE_ONCE, -3.0f); - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - EnFloormas_MakeInvulnerable(this); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 0x12C, 0x64, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); - this->actionFunc = EnFloormas_Hover; -} - -void EnFloormas_SetupCharge(EnFloormas* this) { - this->actionTimer = 25; - this->actor.gravity = -0.15f; - this->actionFunc = EnFloormas_Charge; - this->actor.speedXZ = 0.5f; -} - -void EnFloormas_SetupLand(EnFloormas* this) { - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); - if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != EnFloormas_Charge)) { - this->actionTimer = 30; - } else { - this->actionTimer = 45; - } - this->actor.gravity = -1.0f; - this->actionFunc = EnFloormas_Land; -} - -void EnFloormas_SetupSplit(EnFloormas* this) { - - Actor_SetScale(&this->actor, 0.004f); - this->actor.flags |= ACTOR_FLAG_4; - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { - this->actor.draw = EnFloormas_DrawHighlighted; - } else { - this->actor.draw = EnFloormas_Draw; - } - this->actor.shape.rot.y = this->actor.parent->shape.rot.y + 0x5555; - this->actor.world.pos = this->actor.parent->world.pos; - this->actor.params = 0x10; - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), - ANIMMODE_ONCE, 0.0f); - this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; - this->collider.dim.height = sCylinderInit.dim.height * 0.6f; - this->collider.info.bumperFlags &= ~BUMP_HOOKABLE; - this->actor.speedXZ = 4.0f; - this->actor.velocity.y = 7.0f; - // using div creates a signed check. - this->actor.colChkInfo.health = sColChkInfoInit.health >> 1; - this->actionFunc = EnFloormas_Split; -} - -void EnFloormas_SetupSmWalk(EnFloormas* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); - this->actionFunc = EnFloormas_SmWalk; - this->actor.speedXZ = 5.0f; -} - -void EnFloormas_SetupSmDecideAction(EnFloormas* this) { - if (this->actionFunc != EnFloormas_SmWalk) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); - } - this->actionFunc = EnFloormas_SmDecideAction; - this->actor.speedXZ = 5.0f; -} - -void EnFloormas_SetupSmShrink(EnFloormas* this, GlobalContext* globalCtx) { - static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 15.0f; - pos.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &pos, &velocity, &accel, 150, -10, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); - this->actionFunc = EnFloormas_SmShrink; -} - -void EnFloormas_SetupSlaveJumpAtMaster(EnFloormas* this) { - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnFloormas_SmSlaveJumpAtMaster; - this->actor.speedXZ = 0.0f; -} - -void EnFloormas_SetupJumpAtLink(EnFloormas* this) { - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnFloormas_JumpAtLink; - this->actor.speedXZ = 0.0f; -} - -void EnFloormas_SetupGrabLink(EnFloormas* this, Player* player) { - f32 yDelta; - f32 xzDelta; - - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - EnFloormas_MakeInvulnerable(this); - if (!LINK_IS_ADULT) { - yDelta = CLAMP(-this->actor.yDistToPlayer, 20.0f, 30.0f); - xzDelta = -10.0f; - } else { - yDelta = CLAMP(-this->actor.yDistToPlayer, 25.0f, 45.0f); - xzDelta = -70.0f; - } - this->actor.world.pos.y = player->actor.world.pos.y + yDelta; - this->actor.world.pos.x = Math_SinS(this->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.x; - this->actor.world.pos.z = Math_CosS(this->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.z; - this->actor.shape.rot.x = -0x4CE0; - this->actionFunc = EnFloormas_GrabLink; -} - -void EnFloormas_SetupMerge(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterWaitAnim); - this->actionTimer = 0; - this->smActionTimer += 1500; - EnFloormas_MakeInvulnerable(this); - this->actionFunc = EnFloormas_Merge; -} - -void EnFloormas_SetupSmWait(EnFloormas* this) { - EnFloormas* parent = (EnFloormas*)this->actor.parent; - EnFloormas* child = (EnFloormas*)this->actor.child; - - // if this is the last remaining small floor master, kill all. - if ((parent->actionFunc == EnFloormas_SmWait) && (child->actionFunc == EnFloormas_SmWait)) { - Actor_Kill(&parent->actor); - Actor_Kill(&child->actor); - Actor_Kill(&this->actor); - return; - } - this->actor.draw = NULL; - this->actionFunc = EnFloormas_SmWait; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_4); -} - -void EnFloormas_SetupTakeDamage(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); - if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) { - this->actor.world.rot.y = this->collider.base.ac->world.rot.y; - } else { - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac) + 0x8000; - } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x14); - this->actionFunc = EnFloormas_TakeDamage; - this->actor.speedXZ = 5.0f; - this->actor.velocity.y = 5.5f; -} - -void EnFloormas_SetupRecover(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); - this->actor.velocity.y = this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = EnFloormas_Recover; -} - -void EnFloormas_SetupFreeze(EnFloormas* this) { - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.5f, 0, 20.0f, ANIMMODE_ONCE, -3.0f); - this->actor.speedXZ = 0.0f; - if (this->actor.colChkInfo.damageEffect == 4) { - Actor_SetColorFilter(&this->actor, -0x8000, 0xFF, 0, 0x50); - } else { - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); - if (this->actor.scale.x > 0.004f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - } - } - this->actionTimer = 80; - this->actionFunc = EnFloormas_Freeze; -} - -void EnFloormas_Die(EnFloormas* this, GlobalContext* globalCtx) { - if (this->actor.scale.x > 0.004f) { - // split - this->actor.shape.rot.y = this->actor.yawTowardsPlayer + 0x8000; - EnFloormas_SetupSplit((EnFloormas*)this->actor.child); - EnFloormas_SetupSplit((EnFloormas*)this->actor.parent); - EnFloormas_SetupSplit(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SPLIT); - } else { - // Die - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); - EnFloormas_SetupSmShrink(this, globalCtx); - } -} - -void EnFloormas_BigDecideAction(EnFloormas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - // within 400 units of link and within 90 degrees rotation of him - if (this->actor.xzDistToPlayer < 400.0f && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { - this->actionTarget = this->actor.yawTowardsPlayer; - EnFloormas_SetupTurn(this); - // within 280 units of link and within 45 degrees rotation of him - } else if (this->actor.xzDistToPlayer < 280.0f && Actor_IsFacingPlayer(&this->actor, 0x2000)) { - EnFloormas_SetupHover(this, globalCtx); - } else { - EnFloormas_SetupStand(this); - } - } -} - -void EnFloormas_Stand(EnFloormas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.scale.x > 0.004f) { - EnFloormas_SetupBigWalk(this); - } else if (this->actor.params == MERGE_SLAVE) { - EnFloormas_SetupSmDecideAction(this); - } else { - EnFloormas_SetupSmWalk(this); - } - } -} - -void EnFloormas_BigWalk(EnFloormas* this, GlobalContext* globalCtx) { - s32 animPastFrame; - - SkelAnime_Update(&this->skelAnime); - animPastFrame = Animation_OnFrame(&this->skelAnime, 0.0f); - if (animPastFrame) { - if (this->actionTimer != 0) { - this->actionTimer--; - } - } - if (((animPastFrame || (Animation_OnFrame(&this->skelAnime, 12.0f))) || - (Animation_OnFrame(&this->skelAnime, 24.0f) != 0)) || - (Animation_OnFrame(&this->skelAnime, 36.0f) != 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); - } - - if ((this->actor.xzDistToPlayer < 320.0f) && (Actor_IsFacingPlayer(&this->actor, 0x4000))) { - EnFloormas_SetupRun(this); - } else if (this->actor.bgCheckFlags & 8) { - // set target rotation to the colliding wall's rotation - this->actionTarget = this->actor.wallYaw; - EnFloormas_SetupTurn(this); - } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { - // set target rotation to link. - this->actionTarget = this->actor.yawTowardsPlayer; - EnFloormas_SetupTurn(this); - } else if (this->actionTimer == 0) { - EnFloormas_SetupBigStopWalk(this); - } -} - -void EnFloormas_BigStopWalk(EnFloormas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnFloormas_SetupBigDecideAction(this); - } -} - -void EnFloormas_Run(EnFloormas* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || - Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); - } - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); - - if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000) && - !(this->actor.bgCheckFlags & 8)) { - EnFloormas_SetupHover(this, globalCtx); - } else if (this->actor.xzDistToPlayer > 400.0f) { - EnFloormas_SetupBigWalk(this); - } -} - -void EnFloormas_Turn(EnFloormas* this, GlobalContext* globalCtx) { - char pad[4]; - f32 sp30; - f32 sp2C; - - if (SkelAnime_Update(&this->skelAnime)) { - EnFloormas_SetupStand(this); - } - - if (((this->skelAnime.playSpeed > 0.0f) && Animation_OnFrame(&this->skelAnime, 21.0f)) || - ((this->skelAnime.playSpeed < 0.0f) && Animation_OnFrame(&this->skelAnime, 6.0f))) { - if (this->actor.scale.x > 0.004f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); - } - } - // Needed to match - if (!this->skelAnime.curFrame) {} - if (this->skelAnime.curFrame >= 7.0f && this->skelAnime.curFrame < 22.0f) { - sp30 = Math_SinS(this->actor.shape.rot.y + 0x4268); - sp2C = Math_CosS(this->actor.shape.rot.y + 0x4268); - this->actor.shape.rot.y += this->actionTarget; - this->actor.world.pos.x -= - (this->actor.scale.x * 2700.0f) * (Math_SinS(this->actor.shape.rot.y + 0x4268) - sp30); - this->actor.world.pos.z -= - (this->actor.scale.x * 2700.0f) * (Math_CosS(this->actor.shape.rot.y + 0x4268) - sp2C); - } -} - -void EnFloormas_Hover(EnFloormas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnFloormas_SetupCharge(this); - } - this->actor.shape.rot.x += 0x140; - this->actor.world.pos.y += 10.0f; - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 2730); - Math_StepToS(&this->zOffset, 1200, 100); -} - -void EnFloormas_Slide(EnFloormas* this, GlobalContext* globalCtx) { - static Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - Vec3f velocity; - - pos.x = this->actor.world.pos.x; - pos.z = this->actor.world.pos.z; - pos.y = this->actor.floorHeight; - - velocity.y = 2.0f; - velocity.x = Math_SinS(this->actor.shape.rot.y + 0x6000) * 7.0f; - velocity.z = Math_CosS(this->actor.shape.rot.y + 0x6000) * 7.0f; - - func_800286CC(globalCtx, &pos, &velocity, &accel, 450, 100); - - velocity.x = Math_SinS(this->actor.shape.rot.y - 0x6000) * 7.0f; - velocity.z = Math_CosS(this->actor.shape.rot.y - 0x6000) * 7.0f; - - func_800286CC(globalCtx, &pos, &velocity, &accel, 450, 100); - - func_8002F974(&this->actor, NA_SE_EN_FLOORMASTER_SLIDING); -} - -void EnFloormas_Charge(EnFloormas* this, GlobalContext* globalCtx) { - f32 distFromGround; - - if (this->actionTimer != 0) { - this->actionTimer--; - } - - Math_StepToF(&this->actor.speedXZ, 15.0f, SQ(this->actor.speedXZ) * (1.0f / 3.0f)); - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x1680, 0x140); - - distFromGround = this->actor.world.pos.y - this->actor.floorHeight; - if (distFromGround < 10.0f) { - this->actor.world.pos.y = this->actor.floorHeight + 10.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - } - - if (distFromGround < 12.0f) { - EnFloormas_Slide(this, globalCtx); - } - - if ((this->actor.bgCheckFlags & 8) || (this->actionTimer == 0)) { - EnFloormas_SetupLand(this); - } -} - -void EnFloormas_Land(EnFloormas* this, GlobalContext* globalCtx) { - s32 isOnGround; - - isOnGround = this->actor.bgCheckFlags & 1; - if (this->actor.bgCheckFlags & 2) { - if (this->actor.params != MERGE_MASTER) { - EnFloormas_MakeVulnerable(this); - } - - if (this->actor.velocity.y < -4.0f) { - if (this->actor.scale.x > 0.004f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_LAND); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); - } - } - } - if (this->actor.bgCheckFlags & 8) { - this->actor.speedXZ = 0.0f; - } - - if (isOnGround) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); - } - - if ((this->actor.speedXZ > 0.0f) && ((this->actor.world.pos.y - this->actor.floorHeight) < 12.0f)) { - EnFloormas_Slide(this, globalCtx); - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actionTimer != 0) { - this->actionTimer--; - } - - if (this->actionTimer == 0 && isOnGround) { - if (this->skelAnime.endFrame < 45.0f) { - this->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); - } else if (this->actor.params == MERGE_MASTER) { - EnFloormas_SetupMerge(this); - } else { - EnFloormas_SetupStand(this); - this->smActionTimer = 50; - } - } - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x140); - Math_StepToS(&this->zOffset, -1600, 100); -} - -void EnFloormas_Split(EnFloormas* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.flags |= ACTOR_FLAG_0; - this->smActionTimer = 50; - EnFloormas_SetupStand(this); - } - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); - } - - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); - } -} - -void EnFloormas_SmWalk(EnFloormas* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - DECR(this->smActionTimer); - - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); - } - - if (this->smActionTimer == 0) { - EnFloormas_SetupSmDecideAction(this); - } else if (this->actor.bgCheckFlags & 8) { - this->actionTarget = this->actor.wallYaw; - EnFloormas_SetupTurn(this); - } else if (this->actor.xzDistToPlayer < 120.0f) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0x38E); - } -} - -void EnFloormas_SmDecideAction(EnFloormas* this, GlobalContext* globalCtx) { - Actor* primaryFloormas; - s32 isAgainstWall; - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); - } - isAgainstWall = this->actor.bgCheckFlags & 8; - if (isAgainstWall) { - this->actionTarget = this->actor.wallYaw; - EnFloormas_SetupTurn(this); - return; - } - - if (this->actor.params == MERGE_SLAVE) { - if (this->actor.parent->params == MERGE_MASTER) { - primaryFloormas = this->actor.parent; - } else if (this->actor.child->params == MERGE_MASTER) { - primaryFloormas = this->actor.child; - } else { - this->actor.params = 0x10; - return; - } - - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, primaryFloormas), 0x38E); - if (Actor_WorldDistXZToActor(&this->actor, primaryFloormas) < 80.0f) { - EnFloormas_SetupSlaveJumpAtMaster(this); - } - } else { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); - if (this->actor.xzDistToPlayer < 80.0f) { - EnFloormas_SetupJumpAtLink(this); - } - } -} - -void EnFloormas_SmShrink(EnFloormas* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { - EnFloormas_SetupSmWait(this); - } - this->actor.scale.z = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.x; -} - -void EnFloormas_JumpAtLink(EnFloormas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - if (this->skelAnime.curFrame < 20.0f) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - } else if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - this->actor.speedXZ = 5.0f; - this->actor.velocity.y = 7.0f; - } else if (this->actor.bgCheckFlags & 2) { - this->actionTimer = 0x32; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); - EnFloormas_SetupLand(this); - } else if ((this->actor.yDistToPlayer < -10.0f) && (this->collider.base.ocFlags1 & OC1_HIT) && - (&player->actor == this->collider.base.oc)) { - globalCtx->grabPlayer(globalCtx, player); - EnFloormas_SetupGrabLink(this, player); - } -} - -void EnFloormas_GrabLink(EnFloormas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - EnFloormas* parent; - EnFloormas* child; - f32 yDelta; - f32 xzDelta; - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.playSpeed > 0.0f) { - this->skelAnime.playSpeed = -1.0f; - this->skelAnime.endFrame = 36.0f; - this->skelAnime.startFrame = 45.0f; - } else { - this->skelAnime.playSpeed = 1.0f; - this->skelAnime.endFrame = 45.0f; - this->skelAnime.startFrame = 36.0f; - } - } - - if (!LINK_IS_ADULT) { - yDelta = CLAMP(-this->actor.yDistToPlayer, 20.0f, 30.0f); - xzDelta = -10.0f; - } else { - yDelta = CLAMP(-this->actor.yDistToPlayer, 25.0f, 45.0f); - xzDelta = -30.0f; - } - - this->actor.world.pos.y = player->actor.world.pos.y + yDelta; - this->actor.world.pos.x = Math_SinS(this->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.x; - this->actor.world.pos.z = Math_CosS(this->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.z; - - // let go - if (!(player->stateFlags2 & 0x80) || (player->invincibilityTimer < 0)) { - parent = (EnFloormas*)this->actor.parent; - child = (EnFloormas*)this->actor.child; - - if (((parent->actionFunc == EnFloormas_GrabLink) || parent->actionFunc == EnFloormas_SmWait) && - (child->actionFunc == EnFloormas_GrabLink || child->actionFunc == EnFloormas_SmWait)) { - - parent->actor.params = MERGE_SLAVE; - child->actor.params = MERGE_SLAVE; - this->actor.params = MERGE_MASTER; - } - - this->actor.shape.rot.x = 0; - this->actor.velocity.y = 6.0f; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.speedXZ = -3.0f; - EnFloormas_SetupLand(this); - } else { - // Damage link every 20 frames - if ((this->actionTarget % 20) == 0) { - if (!LINK_IS_ADULT) { - func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S_KID); - } else { - func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S); - } - globalCtx->damagePlayer(globalCtx, -8); - } - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK); -} - -void EnFloormas_SmSlaveJumpAtMaster(EnFloormas* this, GlobalContext* globalCtx) { - Actor* primFloormas; - - SkelAnime_Update(&this->skelAnime); - if (this->actor.parent->params == MERGE_MASTER) { - primFloormas = this->actor.parent; - } else if (this->actor.child->params == MERGE_MASTER) { - primFloormas = this->actor.child; - } else { - if (this->actor.bgCheckFlags & 2) { - this->actor.params = 0x10; - EnFloormas_SetupLand(this); - } - return; - } - if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - this->actor.speedXZ = 5.0f; - this->actor.velocity.y = 7.0f; - } else if (this->skelAnime.curFrame < 20.0f) { - Math_ApproachS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, primFloormas), 2, 0xE38); - } else if ((((primFloormas->world.pos.y - this->actor.world.pos.y) < -10.0f) && - (fabsf(this->actor.world.pos.x - primFloormas->world.pos.x) < 10.0f)) && - (fabsf(this->actor.world.pos.z - primFloormas->world.pos.z) < 10.0f)) { - EnFloormas_SetupSmWait(this); - this->collider.base.ocFlags1 |= OC1_ON; - } else if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); - EnFloormas_SetupLand(this); - } - - if (fabsf(this->actor.world.pos.x - primFloormas->world.pos.x) < 5.0f && - fabsf(this->actor.world.pos.z - primFloormas->world.pos.z) < 5.0f) { - Math_StepToF(&this->actor.speedXZ, 0, 2.0f); - } -} - -void EnFloormas_Merge(EnFloormas* this, GlobalContext* globalCtx) { - EnFloormas* parent; - EnFloormas* child; - s32 mergeCnt; - f32 prevScale; - f32 curScale; - - mergeCnt = 0; - - DECR(this->smActionTimer); - - parent = (EnFloormas*)this->actor.parent; - child = (EnFloormas*)this->actor.child; - - if (this->smActionTimer == 0) { - if (parent->actionFunc != EnFloormas_SmWait) { - EnFloormas_SetupSmShrink(parent, globalCtx); - } - - if (child->actionFunc != EnFloormas_SmWait) { - EnFloormas_SetupSmShrink(child, globalCtx); - } - } else { - if ((parent->actionFunc != EnFloormas_SmWait) && (parent->actionFunc != EnFloormas_SmShrink)) { - mergeCnt++; - } - - if ((child->actionFunc != EnFloormas_SmWait) && (child->actionFunc != EnFloormas_SmShrink)) { - mergeCnt++; - } - } - - prevScale = this->actor.scale.x; - - if (mergeCnt == 1) { - Math_StepToF(&this->actor.scale.x, 0.007f, 0.0005f); - } else if (mergeCnt == 0) { - Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f); - } - - curScale = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.z = curScale; - - if (((prevScale == 0.007f) || (prevScale == 0.004f)) && (prevScale != this->actor.scale.x)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); - } - - this->collider.dim.radius = (sCylinderInit.dim.radius * 100.0f) * this->actor.scale.x; - this->collider.dim.height = (sCylinderInit.dim.height * 100.0f) * this->actor.scale.x; - - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->actor.scale.x >= 0.01f) { - this->actor.flags &= ~ACTOR_FLAG_4; - EnFloormas_MakeVulnerable(this); - this->actor.params = 0; - this->collider.info.bumperFlags |= BUMP_HOOKABLE; - this->actor.colChkInfo.health = sColChkInfoInit.health; - EnFloormas_SetupStand(this); - } else { - if (this->actionTimer == 0) { - Animation_PlayOnce(&this->skelAnime, &gFloormasterTapFingerAnim); - this->actionTimer = 1; - } else { - Animation_PlayOnce(&this->skelAnime, &gWallmasterWaitAnim); - this->actionTimer = 0; - } - } - } - func_8002F974(&this->actor, NA_SE_EN_FLOORMASTER_RESTORE - SFX_FLAG); -} - -void EnFloormas_SmWait(EnFloormas* this, GlobalContext* globalCtx) { -} - -void EnFloormas_TakeDamage(EnFloormas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->actor.colChkInfo.health == 0) { - EnFloormas_Die(this, globalCtx); - } else { - EnFloormas_SetupRecover(this); - } - } - - if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - if (this->actor.scale.x > 0.004f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - } - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); -} - -void EnFloormas_Recover(EnFloormas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnFloormas_SetupStand(this); - } -} - -void EnFloormas_Freeze(EnFloormas* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (this->actionTimer == 0) { - if (this->actor.colChkInfo.health == 0) { - EnFloormas_Die(this, globalCtx); - return; - } - EnFloormas_SetupStand(this); - } -} - -void EnFloormas_ColliderCheck(EnFloormas* this, GlobalContext* globalCtx) { - s32 pad; - s32 isSmall; - - if ((this->collider.base.acFlags & AC_HIT) != 0) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (this->collider.base.colType != COLTYPE_HARD) { - isSmall = 0; - if (this->actor.scale.x < 0.01f) { - isSmall = 1; - } - if (isSmall && this->collider.info.acHitInfo->toucher.dmgFlags & 0x80) { - this->actor.colChkInfo.damage = 2; - this->actor.colChkInfo.damageEffect = 0; - } - if (Actor_ApplyDamage(&this->actor) == 0) { - if (isSmall) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DEAD); - } - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~ACTOR_FLAG_0; - } else if (this->actor.colChkInfo.damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DAMAGE); - } - - if ((this->actor.colChkInfo.damageEffect == 4) || (this->actor.colChkInfo.damageEffect == 1)) { - if (this->actionFunc != EnFloormas_Freeze) { - EnFloormas_SetupFreeze(this); - } - } else { - if (this->actor.colChkInfo.damageEffect == 2) { - EffectSsFCircle_Spawn(globalCtx, &this->actor, &this->actor.world.pos, - this->actor.scale.x * 4000.0f, this->actor.scale.x * 4000.0f); - } - EnFloormas_SetupTakeDamage(this); - } - } - } - } -} - -void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFloormas* this = (EnFloormas*)thisx; - s32 pad; - - if (this->actionFunc != EnFloormas_SmWait) { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - this->actor.speedXZ *= -0.5f; - - if (-5.0f < this->actor.speedXZ) { - this->actor.speedXZ = -5.0f; - } else { - this->actor.speedXZ = this->actor.speedXZ; - } - - this->actor.velocity.y = 5.0f; - - EnFloormas_SetupLand(this); - } - EnFloormas_ColliderCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - - if (this->actionFunc != EnFloormas_TakeDamage) { - this->actor.world.rot.y = this->actor.shape.rot.y; - } - - if (this->actionFunc != EnFloormas_GrabLink) { - Actor_MoveForward(&this->actor); - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->actionFunc == EnFloormas_Charge) { - this->actor.flags |= ACTOR_FLAG_24; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->actionFunc != EnFloormas_GrabLink) { - if (this->actionFunc != EnFloormas_Split && this->actionFunc != EnFloormas_TakeDamage && - this->actor.freezeTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if ((this->actionFunc != EnFloormas_SmSlaveJumpAtMaster) || (this->skelAnime.curFrame < 20.0f)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - Actor_SetFocus(&this->actor, this->actor.scale.x * 2500.0f); - - if (this->collider.base.colType == COLTYPE_HARD) { - if (this->actionTarget != 0) { - this->actionTarget--; - } - - if (this->actionTarget == 0) { - this->actionTarget = 0x28; - } - } - } -} - -s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx, Gfx** gfx) { - EnFloormas* this = (EnFloormas*)thisx; - - if (limbIndex == 1) { - pos->z += this->zOffset; - } - return false; -} - -void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - if (limbIndex == 2) { - Matrix_Push(); - Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_RotateY(DEGTORAD(60.0f), MTXMODE_APPLY); - Matrix_RotateZ(DEGTORAD(15.0f), MTXMODE_APPLY); - Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2299), G_MTX_LOAD); - gSPDisplayList((*gfx)++, gWallmasterFingerDL); - Matrix_Pop(); - } -} - -static Color_RGBA8 sMergeColor = { 0, 255, 0, 0 }; - -void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnFloormas* this = (EnFloormas*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2318); - - func_80093D18(globalCtx->state.gfxCtx); - if (this->collider.base.colType == COLTYPE_HARD) { - func_80026230(globalCtx, &sMergeColor, this->actionTarget % 0x28, 0x28); - } - - POLY_OPA_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, this, POLY_OPA_DISP); - if (this->collider.base.colType == COLTYPE_HARD) { - func_80026608(globalCtx); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2340); -} - -void EnFloormas_DrawHighlighted(Actor* thisx, GlobalContext* globalCtx) { - EnFloormas* this = (EnFloormas*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2352); - - func_80093D84(globalCtx->state.gfxCtx); - if (this->collider.base.colType == COLTYPE_HARD) { - func_80026690(globalCtx, &sMergeColor, this->actionTarget % 0x28, 0x28); - } - POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, this, POLY_XLU_DISP); - if (this->collider.base.colType == COLTYPE_HARD) { - func_80026A6C(globalCtx); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2374); -} diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.cpp b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.cpp new file mode 100644 index 000000000..17ac4d7c4 --- /dev/null +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.cpp @@ -0,0 +1,1155 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FLOORMAS_Z_EN_FLOORMAS_C +#include "actor_common.h" +/* + * File: z_en_floormas + * Overlay: En_Floormas + * Description: Floormaster + */ + +#include "z_en_floormas.h" +#include "objects/object_wallmaster/object_wallmaster.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_eff_ss_dead.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_10) + +#define SPAWN_INVISIBLE 0x8000 +#define SPAWN_SMALL 0x10 + +#define MERGE_MASTER 0x40 +#define MERGE_SLAVE 0x20 + +void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnFloormas_GrabLink(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Split(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Recover(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_DrawHighlighted(Actor* pthis, GlobalContext* globalCtx); +void EnFloormas_SmWait(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_SetupBigDecideAction(EnFloormas* pthis); +void EnFloormas_Freeze(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_TakeDamage(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Merge(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_JumpAtLink(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_SmSlaveJumpAtMaster(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_SmShrink(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_SmDecideAction(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_SmWalk(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Land(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Hover(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Turn(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Run(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_BigStopWalk(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_BigWalk(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Stand(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_BigDecideAction(EnFloormas* pthis, GlobalContext* globalCtx); +void EnFloormas_Charge(EnFloormas* pthis, GlobalContext* globalCtx); + +ActorInit En_Floormas_InitVars = { + ACTOR_EN_FLOORMAS, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_WALLMASTER, + sizeof(EnFloormas), + (ActorFunc)EnFloormas_Init, + (ActorFunc)EnFloormas_Destroy, + (ActorFunc)EnFloormas_Update, + (ActorFunc)EnFloormas_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x04, 0x10 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 25, 40, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 4, 30, 40, 150 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(4, 0x4), + /* Unk arrow 1 */ DMG_ENTRY(4, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(4, 0x4), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x31, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), +}; + +void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnFloormas* pthis = (EnFloormas*)thisx; + GlobalContext* globalCtx = globalCtx2; + s32 invisble; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gWallmasterSkel, &gWallmasterWaitAnim, pthis->jointTable, + pthis->morphTable, 25); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->zOffset = -1600; + invisble = pthis->actor.params & SPAWN_INVISIBLE; + + // s16 cast needed + pthis->actor.params &= (s16) ~(SPAWN_INVISIBLE); + if (invisble) { + pthis->actor.flags |= ACTOR_FLAG_7; + pthis->actor.draw = EnFloormas_DrawHighlighted; + } + + if (pthis->actor.params == SPAWN_SMALL) { + pthis->actor.draw = NULL; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnFloormas_SmWait; + } else { + // spawn first small floormaster + pthis->actor.parent = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, invisble + SPAWN_SMALL); + if (pthis->actor.parent == NULL) { + Actor_Kill(&pthis->actor); + return; + } + // spawn 2nd small floormaster + pthis->actor.child = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, invisble + SPAWN_SMALL); + if (pthis->actor.child == NULL) { + Actor_Kill(pthis->actor.parent); + Actor_Kill(&pthis->actor); + return; + } + + // link floormasters together + pthis->actor.parent->child = &pthis->actor; + pthis->actor.parent->parent = pthis->actor.child; + pthis->actor.child->parent = &pthis->actor; + pthis->actor.child->child = pthis->actor.parent; + EnFloormas_SetupBigDecideAction(pthis); + } +} + +void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* pthis = (EnFloormas*)thisx; + ColliderCylinder* col = &pthis->collider; + Collider_DestroyCylinder(globalCtx, col); +} + +void EnFloormas_MakeInvulnerable(EnFloormas* pthis) { + pthis->collider.base.colType = COLTYPE_HARD; + pthis->collider.base.acFlags |= AC_HARD; + pthis->actionTarget = 0x28; +} + +void EnFloormas_MakeVulnerable(EnFloormas* pthis) { + pthis->collider.base.colType = COLTYPE_HIT0; + pthis->actionTarget = 0; + pthis->collider.base.acFlags &= ~AC_HARD; +} + +void EnFloormas_SetupBigDecideAction(EnFloormas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterWaitAnim); + pthis->actionFunc = EnFloormas_BigDecideAction; + pthis->actor.speedXZ = 0.0f; +} + +void EnFloormas_SetupStand(EnFloormas* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWallmasterStandUpAnim, -3.0f); + pthis->actionFunc = EnFloormas_Stand; +} + +void EnFloormas_SetupBigWalk(EnFloormas* pthis) { + if (pthis->actionFunc != EnFloormas_Run) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gWallmasterWalkAnim, 1.5f); + } else { + pthis->skelAnime.playSpeed = 1.5f; + } + + pthis->actionTimer = Rand_S16Offset(2, 4); + pthis->actionFunc = EnFloormas_BigWalk; + pthis->actor.speedXZ = 1.5f; +} + +void EnFloormas_SetupBigStopWalk(EnFloormas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterStopWalkAnim); + pthis->actionFunc = EnFloormas_BigStopWalk; + pthis->actor.speedXZ = 0.0f; +} + +void EnFloormas_SetupRun(EnFloormas* pthis) { + pthis->actionTimer = 0; + pthis->actionFunc = EnFloormas_Run; + pthis->actor.speedXZ = 5.0f; + pthis->skelAnime.playSpeed = 3.0f; +} + +void EnFloormas_SetupTurn(EnFloormas* pthis) { + s16 rotDelta = pthis->actionTarget - pthis->actor.shape.rot.y; + + pthis->actor.speedXZ = 0.0f; + if (rotDelta > 0) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gFloormasterTurnAnim, -3.0f); + } else { + Animation_Change(&pthis->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); + } + + if (pthis->actor.scale.x > 0.004f) { + pthis->actionTarget = (rotDelta * (2.0f / 30.0f)); + } else { + pthis->skelAnime.playSpeed = pthis->skelAnime.playSpeed + pthis->skelAnime.playSpeed; + pthis->actionTarget = rotDelta * (2.0f / 15.0f); + } + pthis->actionFunc = EnFloormas_Turn; +} + +void EnFloormas_SetupHover(EnFloormas* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gWallmasterHoverAnim, 3.0f, 0, Animation_GetLastFrame(&gWallmasterHoverAnim), + ANIMMODE_ONCE, -3.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + EnFloormas_MakeInvulnerable(pthis); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 15.0f, 6, 20.0f, 0x12C, 0x64, 1); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_ATTACK); + pthis->actionFunc = EnFloormas_Hover; +} + +void EnFloormas_SetupCharge(EnFloormas* pthis) { + pthis->actionTimer = 25; + pthis->actor.gravity = -0.15f; + pthis->actionFunc = EnFloormas_Charge; + pthis->actor.speedXZ = 0.5f; +} + +void EnFloormas_SetupLand(EnFloormas* pthis) { + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); + if ((pthis->actor.speedXZ < 0.0f) || (pthis->actionFunc != EnFloormas_Charge)) { + pthis->actionTimer = 30; + } else { + pthis->actionTimer = 45; + } + pthis->actor.gravity = -1.0f; + pthis->actionFunc = EnFloormas_Land; +} + +void EnFloormas_SetupSplit(EnFloormas* pthis) { + + Actor_SetScale(&pthis->actor, 0.004f); + pthis->actor.flags |= ACTOR_FLAG_4; + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { + pthis->actor.draw = EnFloormas_DrawHighlighted; + } else { + pthis->actor.draw = EnFloormas_Draw; + } + pthis->actor.shape.rot.y = pthis->actor.parent->shape.rot.y + 0x5555; + pthis->actor.world.pos = pthis->actor.parent->world.pos; + pthis->actor.params = 0x10; + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, 0.0f); + pthis->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; + pthis->collider.dim.height = sCylinderInit.dim.height * 0.6f; + pthis->collider.info.bumperFlags &= ~BUMP_HOOKABLE; + pthis->actor.speedXZ = 4.0f; + pthis->actor.velocity.y = 7.0f; + // using div creates a signed check. + pthis->actor.colChkInfo.health = sColChkInfoInit.health >> 1; + pthis->actionFunc = EnFloormas_Split; +} + +void EnFloormas_SetupSmWalk(EnFloormas* pthis) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gWallmasterWalkAnim, 4.5f); + pthis->actionFunc = EnFloormas_SmWalk; + pthis->actor.speedXZ = 5.0f; +} + +void EnFloormas_SetupSmDecideAction(EnFloormas* pthis) { + if (pthis->actionFunc != EnFloormas_SmWalk) { + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &gWallmasterWalkAnim, 4.5f); + } + pthis->actionFunc = EnFloormas_SmDecideAction; + pthis->actor.speedXZ = 5.0f; +} + +void EnFloormas_SetupSmShrink(EnFloormas* pthis, GlobalContext* globalCtx) { + static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 15.0f; + pos.z = pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &pos, &velocity, &accel, 150, -10, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); + pthis->actionFunc = EnFloormas_SmShrink; +} + +void EnFloormas_SetupSlaveJumpAtMaster(EnFloormas* pthis) { + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnFloormas_SmSlaveJumpAtMaster; + pthis->actor.speedXZ = 0.0f; +} + +void EnFloormas_SetupJumpAtLink(EnFloormas* pthis) { + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnFloormas_JumpAtLink; + pthis->actor.speedXZ = 0.0f; +} + +void EnFloormas_SetupGrabLink(EnFloormas* pthis, Player* player) { + f32 yDelta; + f32 xzDelta; + + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + EnFloormas_MakeInvulnerable(pthis); + if (!LINK_IS_ADULT) { + yDelta = CLAMP(-pthis->actor.yDistToPlayer, 20.0f, 30.0f); + xzDelta = -10.0f; + } else { + yDelta = CLAMP(-pthis->actor.yDistToPlayer, 25.0f, 45.0f); + xzDelta = -70.0f; + } + pthis->actor.world.pos.y = player->actor.world.pos.y + yDelta; + pthis->actor.world.pos.x = Math_SinS(pthis->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.x; + pthis->actor.world.pos.z = Math_CosS(pthis->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.z; + pthis->actor.shape.rot.x = -0x4CE0; + pthis->actionFunc = EnFloormas_GrabLink; +} + +void EnFloormas_SetupMerge(EnFloormas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterWaitAnim); + pthis->actionTimer = 0; + pthis->smActionTimer += 1500; + EnFloormas_MakeInvulnerable(pthis); + pthis->actionFunc = EnFloormas_Merge; +} + +void EnFloormas_SetupSmWait(EnFloormas* pthis) { + EnFloormas* parent = (EnFloormas*)pthis->actor.parent; + EnFloormas* child = (EnFloormas*)pthis->actor.child; + + // if pthis is the last remaining small floor master, kill all. + if ((parent->actionFunc == EnFloormas_SmWait) && (child->actionFunc == EnFloormas_SmWait)) { + Actor_Kill(&parent->actor); + Actor_Kill(&child->actor); + Actor_Kill(&pthis->actor); + return; + } + pthis->actor.draw = NULL; + pthis->actionFunc = EnFloormas_SmWait; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_4); +} + +void EnFloormas_SetupTakeDamage(EnFloormas* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWallmasterDamageAnim, -3.0f); + if (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) { + pthis->actor.world.rot.y = pthis->collider.base.ac->world.rot.y; + } else { + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0x14); + pthis->actionFunc = EnFloormas_TakeDamage; + pthis->actor.speedXZ = 5.0f; + pthis->actor.velocity.y = 5.5f; +} + +void EnFloormas_SetupRecover(EnFloormas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterRecoverFromDamageAnim); + pthis->actor.velocity.y = pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actionFunc = EnFloormas_Recover; +} + +void EnFloormas_SetupFreeze(EnFloormas* pthis) { + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 1.5f, 0, 20.0f, ANIMMODE_ONCE, -3.0f); + pthis->actor.speedXZ = 0.0f; + if (pthis->actor.colChkInfo.damageEffect == 4) { + Actor_SetColorFilter(&pthis->actor, -0x8000, 0xFF, 0, 0x50); + } else { + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); + if (pthis->actor.scale.x > 0.004f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + } + } + pthis->actionTimer = 80; + pthis->actionFunc = EnFloormas_Freeze; +} + +void EnFloormas_Die(EnFloormas* pthis, GlobalContext* globalCtx) { + if (pthis->actor.scale.x > 0.004f) { + // split + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + EnFloormas_SetupSplit((EnFloormas*)pthis->actor.child); + EnFloormas_SetupSplit((EnFloormas*)pthis->actor.parent); + EnFloormas_SetupSplit(pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SPLIT); + } else { + // Die + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x90); + EnFloormas_SetupSmShrink(pthis, globalCtx); + } +} + +void EnFloormas_BigDecideAction(EnFloormas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + // within 400 units of link and within 90 degrees rotation of him + if (pthis->actor.xzDistToPlayer < 400.0f && !Actor_IsFacingPlayer(&pthis->actor, 0x4000)) { + pthis->actionTarget = pthis->actor.yawTowardsPlayer; + EnFloormas_SetupTurn(pthis); + // within 280 units of link and within 45 degrees rotation of him + } else if (pthis->actor.xzDistToPlayer < 280.0f && Actor_IsFacingPlayer(&pthis->actor, 0x2000)) { + EnFloormas_SetupHover(pthis, globalCtx); + } else { + EnFloormas_SetupStand(pthis); + } + } +} + +void EnFloormas_Stand(EnFloormas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.scale.x > 0.004f) { + EnFloormas_SetupBigWalk(pthis); + } else if (pthis->actor.params == MERGE_SLAVE) { + EnFloormas_SetupSmDecideAction(pthis); + } else { + EnFloormas_SetupSmWalk(pthis); + } + } +} + +void EnFloormas_BigWalk(EnFloormas* pthis, GlobalContext* globalCtx) { + s32 animPastFrame; + + SkelAnime_Update(&pthis->skelAnime); + animPastFrame = Animation_OnFrame(&pthis->skelAnime, 0.0f); + if (animPastFrame) { + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + } + if (((animPastFrame || (Animation_OnFrame(&pthis->skelAnime, 12.0f))) || + (Animation_OnFrame(&pthis->skelAnime, 24.0f) != 0)) || + (Animation_OnFrame(&pthis->skelAnime, 36.0f) != 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_WALK); + } + + if ((pthis->actor.xzDistToPlayer < 320.0f) && (Actor_IsFacingPlayer(&pthis->actor, 0x4000))) { + EnFloormas_SetupRun(pthis); + } else if (pthis->actor.bgCheckFlags & 8) { + // set target rotation to the colliding wall's rotation + pthis->actionTarget = pthis->actor.wallYaw; + EnFloormas_SetupTurn(pthis); + } else if ((pthis->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&pthis->actor, 0x4000)) { + // set target rotation to link. + pthis->actionTarget = pthis->actor.yawTowardsPlayer; + EnFloormas_SetupTurn(pthis); + } else if (pthis->actionTimer == 0) { + EnFloormas_SetupBigStopWalk(pthis); + } +} + +void EnFloormas_BigStopWalk(EnFloormas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnFloormas_SetupBigDecideAction(pthis); + } +} + +void EnFloormas_Run(EnFloormas* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 12.0f) || + Animation_OnFrame(&pthis->skelAnime, 24.0f) || Animation_OnFrame(&pthis->skelAnime, 36.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_WALK); + } + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x71C); + + if ((pthis->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&pthis->actor, 0x2000) && + !(pthis->actor.bgCheckFlags & 8)) { + EnFloormas_SetupHover(pthis, globalCtx); + } else if (pthis->actor.xzDistToPlayer > 400.0f) { + EnFloormas_SetupBigWalk(pthis); + } +} + +void EnFloormas_Turn(EnFloormas* pthis, GlobalContext* globalCtx) { + char pad[4]; + f32 sp30; + f32 sp2C; + + if (SkelAnime_Update(&pthis->skelAnime)) { + EnFloormas_SetupStand(pthis); + } + + if (((pthis->skelAnime.playSpeed > 0.0f) && Animation_OnFrame(&pthis->skelAnime, 21.0f)) || + ((pthis->skelAnime.playSpeed < 0.0f) && Animation_OnFrame(&pthis->skelAnime, 6.0f))) { + if (pthis->actor.scale.x > 0.004f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_WALK); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + } + } + // Needed to match + if (!pthis->skelAnime.curFrame) {} + if (pthis->skelAnime.curFrame >= 7.0f && pthis->skelAnime.curFrame < 22.0f) { + sp30 = Math_SinS(pthis->actor.shape.rot.y + 0x4268); + sp2C = Math_CosS(pthis->actor.shape.rot.y + 0x4268); + pthis->actor.shape.rot.y += pthis->actionTarget; + pthis->actor.world.pos.x -= + (pthis->actor.scale.x * 2700.0f) * (Math_SinS(pthis->actor.shape.rot.y + 0x4268) - sp30); + pthis->actor.world.pos.z -= + (pthis->actor.scale.x * 2700.0f) * (Math_CosS(pthis->actor.shape.rot.y + 0x4268) - sp2C); + } +} + +void EnFloormas_Hover(EnFloormas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnFloormas_SetupCharge(pthis); + } + pthis->actor.shape.rot.x += 0x140; + pthis->actor.world.pos.y += 10.0f; + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 2730); + Math_StepToS(&pthis->zOffset, 1200, 100); +} + +void EnFloormas_Slide(EnFloormas* pthis, GlobalContext* globalCtx) { + static Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + Vec3f velocity; + + pos.x = pthis->actor.world.pos.x; + pos.z = pthis->actor.world.pos.z; + pos.y = pthis->actor.floorHeight; + + velocity.y = 2.0f; + velocity.x = Math_SinS(pthis->actor.shape.rot.y + 0x6000) * 7.0f; + velocity.z = Math_CosS(pthis->actor.shape.rot.y + 0x6000) * 7.0f; + + func_800286CC(globalCtx, &pos, &velocity, &accel, 450, 100); + + velocity.x = Math_SinS(pthis->actor.shape.rot.y - 0x6000) * 7.0f; + velocity.z = Math_CosS(pthis->actor.shape.rot.y - 0x6000) * 7.0f; + + func_800286CC(globalCtx, &pos, &velocity, &accel, 450, 100); + + func_8002F974(&pthis->actor, NA_SE_EN_FLOORMASTER_SLIDING); +} + +void EnFloormas_Charge(EnFloormas* pthis, GlobalContext* globalCtx) { + f32 distFromGround; + + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + + Math_StepToF(&pthis->actor.speedXZ, 15.0f, SQ(pthis->actor.speedXZ) * (1.0f / 3.0f)); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x1680, 0x140); + + distFromGround = pthis->actor.world.pos.y - pthis->actor.floorHeight; + if (distFromGround < 10.0f) { + pthis->actor.world.pos.y = pthis->actor.floorHeight + 10.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + } + + if (distFromGround < 12.0f) { + EnFloormas_Slide(pthis, globalCtx); + } + + if ((pthis->actor.bgCheckFlags & 8) || (pthis->actionTimer == 0)) { + EnFloormas_SetupLand(pthis); + } +} + +void EnFloormas_Land(EnFloormas* pthis, GlobalContext* globalCtx) { + s32 isOnGround; + + isOnGround = pthis->actor.bgCheckFlags & 1; + if (pthis->actor.bgCheckFlags & 2) { + if (pthis->actor.params != MERGE_MASTER) { + EnFloormas_MakeVulnerable(pthis); + } + + if (pthis->actor.velocity.y < -4.0f) { + if (pthis->actor.scale.x > 0.004f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_LAND); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + } + } + } + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.speedXZ = 0.0f; + } + + if (isOnGround) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 2.0f); + } + + if ((pthis->actor.speedXZ > 0.0f) && ((pthis->actor.world.pos.y - pthis->actor.floorHeight) < 12.0f)) { + EnFloormas_Slide(pthis, globalCtx); + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + + if (pthis->actionTimer == 0 && isOnGround) { + if (pthis->skelAnime.endFrame < 45.0f) { + pthis->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); + } else if (pthis->actor.params == MERGE_MASTER) { + EnFloormas_SetupMerge(pthis); + } else { + EnFloormas_SetupStand(pthis); + pthis->smActionTimer = 50; + } + } + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x140); + Math_StepToS(&pthis->zOffset, -1600, 100); +} + +void EnFloormas_Split(EnFloormas* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->smActionTimer = 50; + EnFloormas_SetupStand(pthis); + } + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 1.0f); + } + + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + } +} + +void EnFloormas_SmWalk(EnFloormas* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + DECR(pthis->smActionTimer); + + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 18.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + } + + if (pthis->smActionTimer == 0) { + EnFloormas_SetupSmDecideAction(pthis); + } else if (pthis->actor.bgCheckFlags & 8) { + pthis->actionTarget = pthis->actor.wallYaw; + EnFloormas_SetupTurn(pthis); + } else if (pthis->actor.xzDistToPlayer < 120.0f) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 0x38E); + } +} + +void EnFloormas_SmDecideAction(EnFloormas* pthis, GlobalContext* globalCtx) { + Actor* primaryFloormas; + s32 isAgainstWall; + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 18.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + } + isAgainstWall = pthis->actor.bgCheckFlags & 8; + if (isAgainstWall) { + pthis->actionTarget = pthis->actor.wallYaw; + EnFloormas_SetupTurn(pthis); + return; + } + + if (pthis->actor.params == MERGE_SLAVE) { + if (pthis->actor.parent->params == MERGE_MASTER) { + primaryFloormas = pthis->actor.parent; + } else if (pthis->actor.child->params == MERGE_MASTER) { + primaryFloormas = pthis->actor.child; + } else { + pthis->actor.params = 0x10; + return; + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardActor(&pthis->actor, primaryFloormas), 0x38E); + if (Actor_WorldDistXZToActor(&pthis->actor, primaryFloormas) < 80.0f) { + EnFloormas_SetupSlaveJumpAtMaster(pthis); + } + } else { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x71C); + if (pthis->actor.xzDistToPlayer < 80.0f) { + EnFloormas_SetupJumpAtLink(pthis); + } + } +} + +void EnFloormas_SmShrink(EnFloormas* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->actor.scale.x, 0.0f, 0.0015f)) { + EnFloormas_SetupSmWait(pthis); + } + pthis->actor.scale.z = pthis->actor.scale.x; + pthis->actor.scale.y = pthis->actor.scale.x; +} + +void EnFloormas_JumpAtLink(EnFloormas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->skelAnime.curFrame < 20.0f) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + } else if (Animation_OnFrame(&pthis->skelAnime, 20.0f)) { + pthis->actor.speedXZ = 5.0f; + pthis->actor.velocity.y = 7.0f; + } else if (pthis->actor.bgCheckFlags & 2) { + pthis->actionTimer = 0x32; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + EnFloormas_SetupLand(pthis); + } else if ((pthis->actor.yDistToPlayer < -10.0f) && (pthis->collider.base.ocFlags1 & OC1_HIT) && + (&player->actor == pthis->collider.base.oc)) { + globalCtx->grabPlayer(globalCtx, player); + EnFloormas_SetupGrabLink(pthis, player); + } +} + +void EnFloormas_GrabLink(EnFloormas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnFloormas* parent; + EnFloormas* child; + f32 yDelta; + f32 xzDelta; + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->skelAnime.playSpeed > 0.0f) { + pthis->skelAnime.playSpeed = -1.0f; + pthis->skelAnime.endFrame = 36.0f; + pthis->skelAnime.startFrame = 45.0f; + } else { + pthis->skelAnime.playSpeed = 1.0f; + pthis->skelAnime.endFrame = 45.0f; + pthis->skelAnime.startFrame = 36.0f; + } + } + + if (!LINK_IS_ADULT) { + yDelta = CLAMP(-pthis->actor.yDistToPlayer, 20.0f, 30.0f); + xzDelta = -10.0f; + } else { + yDelta = CLAMP(-pthis->actor.yDistToPlayer, 25.0f, 45.0f); + xzDelta = -30.0f; + } + + pthis->actor.world.pos.y = player->actor.world.pos.y + yDelta; + pthis->actor.world.pos.x = Math_SinS(pthis->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.x; + pthis->actor.world.pos.z = Math_CosS(pthis->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.z; + + // let go + if (!(player->stateFlags2 & 0x80) || (player->invincibilityTimer < 0)) { + parent = (EnFloormas*)pthis->actor.parent; + child = (EnFloormas*)pthis->actor.child; + + if (((parent->actionFunc == EnFloormas_GrabLink) || parent->actionFunc == EnFloormas_SmWait) && + (child->actionFunc == EnFloormas_GrabLink || child->actionFunc == EnFloormas_SmWait)) { + + parent->actor.params = MERGE_SLAVE; + child->actor.params = MERGE_SLAVE; + pthis->actor.params = MERGE_MASTER; + } + + pthis->actor.shape.rot.x = 0; + pthis->actor.velocity.y = 6.0f; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.speedXZ = -3.0f; + EnFloormas_SetupLand(pthis); + } else { + // Damage link every 20 frames + if ((pthis->actionTarget % 20) == 0) { + if (!LINK_IS_ADULT) { + func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S_KID); + } else { + func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S); + } + globalCtx->damagePlayer(globalCtx, -8); + } + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_STICK); +} + +void EnFloormas_SmSlaveJumpAtMaster(EnFloormas* pthis, GlobalContext* globalCtx) { + Actor* primFloormas; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.parent->params == MERGE_MASTER) { + primFloormas = pthis->actor.parent; + } else if (pthis->actor.child->params == MERGE_MASTER) { + primFloormas = pthis->actor.child; + } else { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.params = 0x10; + EnFloormas_SetupLand(pthis); + } + return; + } + if (Animation_OnFrame(&pthis->skelAnime, 20.0f)) { + pthis->actor.speedXZ = 5.0f; + pthis->actor.velocity.y = 7.0f; + } else if (pthis->skelAnime.curFrame < 20.0f) { + Math_ApproachS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardActor(&pthis->actor, primFloormas), 2, 0xE38); + } else if ((((primFloormas->world.pos.y - pthis->actor.world.pos.y) < -10.0f) && + (fabsf(pthis->actor.world.pos.x - primFloormas->world.pos.x) < 10.0f)) && + (fabsf(pthis->actor.world.pos.z - primFloormas->world.pos.z) < 10.0f)) { + EnFloormas_SetupSmWait(pthis); + pthis->collider.base.ocFlags1 |= OC1_ON; + } else if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + EnFloormas_SetupLand(pthis); + } + + if (fabsf(pthis->actor.world.pos.x - primFloormas->world.pos.x) < 5.0f && + fabsf(pthis->actor.world.pos.z - primFloormas->world.pos.z) < 5.0f) { + Math_StepToF(&pthis->actor.speedXZ, 0, 2.0f); + } +} + +void EnFloormas_Merge(EnFloormas* pthis, GlobalContext* globalCtx) { + EnFloormas* parent; + EnFloormas* child; + s32 mergeCnt; + f32 prevScale; + f32 curScale; + + mergeCnt = 0; + + DECR(pthis->smActionTimer); + + parent = (EnFloormas*)pthis->actor.parent; + child = (EnFloormas*)pthis->actor.child; + + if (pthis->smActionTimer == 0) { + if (parent->actionFunc != EnFloormas_SmWait) { + EnFloormas_SetupSmShrink(parent, globalCtx); + } + + if (child->actionFunc != EnFloormas_SmWait) { + EnFloormas_SetupSmShrink(child, globalCtx); + } + } else { + if ((parent->actionFunc != EnFloormas_SmWait) && (parent->actionFunc != EnFloormas_SmShrink)) { + mergeCnt++; + } + + if ((child->actionFunc != EnFloormas_SmWait) && (child->actionFunc != EnFloormas_SmShrink)) { + mergeCnt++; + } + } + + prevScale = pthis->actor.scale.x; + + if (mergeCnt == 1) { + Math_StepToF(&pthis->actor.scale.x, 0.007f, 0.0005f); + } else if (mergeCnt == 0) { + Math_StepToF(&pthis->actor.scale.x, 0.01f, 0.0005f); + } + + curScale = pthis->actor.scale.x; + pthis->actor.scale.y = pthis->actor.scale.z = curScale; + + if (((prevScale == 0.007f) || (prevScale == 0.004f)) && (prevScale != pthis->actor.scale.x)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_EXPAND); + } + + pthis->collider.dim.radius = (sCylinderInit.dim.radius * 100.0f) * pthis->actor.scale.x; + pthis->collider.dim.height = (sCylinderInit.dim.height * 100.0f) * pthis->actor.scale.x; + + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->actor.scale.x >= 0.01f) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + EnFloormas_MakeVulnerable(pthis); + pthis->actor.params = 0; + pthis->collider.info.bumperFlags |= BUMP_HOOKABLE; + pthis->actor.colChkInfo.health = sColChkInfoInit.health; + EnFloormas_SetupStand(pthis); + } else { + if (pthis->actionTimer == 0) { + Animation_PlayOnce(&pthis->skelAnime, &gFloormasterTapFingerAnim); + pthis->actionTimer = 1; + } else { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterWaitAnim); + pthis->actionTimer = 0; + } + } + } + func_8002F974(&pthis->actor, NA_SE_EN_FLOORMASTER_RESTORE - SFX_FLAG); +} + +void EnFloormas_SmWait(EnFloormas* pthis, GlobalContext* globalCtx) { +} + +void EnFloormas_TakeDamage(EnFloormas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->actor.colChkInfo.health == 0) { + EnFloormas_Die(pthis, globalCtx); + } else { + EnFloormas_SetupRecover(pthis); + } + } + + if (Animation_OnFrame(&pthis->skelAnime, 13.0f)) { + if (pthis->actor.scale.x > 0.004f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + } + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.2f); +} + +void EnFloormas_Recover(EnFloormas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnFloormas_SetupStand(pthis); + } +} + +void EnFloormas_Freeze(EnFloormas* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (pthis->actionTimer == 0) { + if (pthis->actor.colChkInfo.health == 0) { + EnFloormas_Die(pthis, globalCtx); + return; + } + EnFloormas_SetupStand(pthis); + } +} + +void EnFloormas_ColliderCheck(EnFloormas* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 isSmall; + + if ((pthis->collider.base.acFlags & AC_HIT) != 0) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (pthis->collider.base.colType != COLTYPE_HARD) { + isSmall = 0; + if (pthis->actor.scale.x < 0.01f) { + isSmall = 1; + } + if (isSmall && pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x80) { + pthis->actor.colChkInfo.damage = 2; + pthis->actor.colChkInfo.damageEffect = 0; + } + if (Actor_ApplyDamage(&pthis->actor) == 0) { + if (isSmall) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_DEAD); + } + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else if (pthis->actor.colChkInfo.damage != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_DAMAGE); + } + + if ((pthis->actor.colChkInfo.damageEffect == 4) || (pthis->actor.colChkInfo.damageEffect == 1)) { + if (pthis->actionFunc != EnFloormas_Freeze) { + EnFloormas_SetupFreeze(pthis); + } + } else { + if (pthis->actor.colChkInfo.damageEffect == 2) { + EffectSsFCircle_Spawn(globalCtx, &pthis->actor, &pthis->actor.world.pos, + pthis->actor.scale.x * 4000.0f, pthis->actor.scale.x * 4000.0f); + } + EnFloormas_SetupTakeDamage(pthis); + } + } + } + } +} + +void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* pthis = (EnFloormas*)thisx; + s32 pad; + + if (pthis->actionFunc != EnFloormas_SmWait) { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->actor.speedXZ *= -0.5f; + + if (-5.0f < pthis->actor.speedXZ) { + pthis->actor.speedXZ = -5.0f; + } else { + pthis->actor.speedXZ = pthis->actor.speedXZ; + } + + pthis->actor.velocity.y = 5.0f; + + EnFloormas_SetupLand(pthis); + } + EnFloormas_ColliderCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actionFunc != EnFloormas_TakeDamage) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } + + if (pthis->actionFunc != EnFloormas_GrabLink) { + Actor_MoveForward(&pthis->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, pthis->actor.scale.x * 3000.0f, 0.0f, 0x1D); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (pthis->actionFunc == EnFloormas_Charge) { + pthis->actor.flags |= ACTOR_FLAG_24; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->actionFunc != EnFloormas_GrabLink) { + if (pthis->actionFunc != EnFloormas_Split && pthis->actionFunc != EnFloormas_TakeDamage && + pthis->actor.freezeTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if ((pthis->actionFunc != EnFloormas_SmSlaveJumpAtMaster) || (pthis->skelAnime.curFrame < 20.0f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + Actor_SetFocus(&pthis->actor, pthis->actor.scale.x * 2500.0f); + + if (pthis->collider.base.colType == COLTYPE_HARD) { + if (pthis->actionTarget != 0) { + pthis->actionTarget--; + } + + if (pthis->actionTarget == 0) { + pthis->actionTarget = 0x28; + } + } + } +} + +s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx, Gfx** gfx) { + EnFloormas* pthis = (EnFloormas*)thisx; + + if (limbIndex == 1) { + pos->z += pthis->zOffset; + } + return false; +} + +void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + if (limbIndex == 2) { + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateY(DEGTORAD(60.0f), MTXMODE_APPLY); + Matrix_RotateZ(DEGTORAD(15.0f), MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2299), G_MTX_LOAD); + gSPDisplayList((*gfx)++, gWallmasterFingerDL); + Matrix_Pop(); + } +} + +static Color_RGBA8 sMergeColor = { 0, 255, 0, 0 }; + +void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* pthis = (EnFloormas*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2318); + + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->collider.base.colType == COLTYPE_HARD) { + func_80026230(globalCtx, &sMergeColor, pthis->actionTarget % 0x28, 0x28); + } + + POLY_OPA_DISP = + SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, pthis, POLY_OPA_DISP); + if (pthis->collider.base.colType == COLTYPE_HARD) { + func_80026608(globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2340); +} + +void EnFloormas_DrawHighlighted(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* pthis = (EnFloormas*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2352); + + func_80093D84(globalCtx->state.gfxCtx); + if (pthis->collider.base.colType == COLTYPE_HARD) { + func_80026690(globalCtx, &sMergeColor, pthis->actionTarget % 0x28, 0x28); + } + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, pthis, POLY_XLU_DISP); + if (pthis->collider.base.colType == COLTYPE_HARD) { + func_80026A6C(globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_floormas.c", 2374); +} diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index 52f98fc9f..df0438a2e 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -4,9 +4,10 @@ #include "ultra64.h" #include "global.h" -typedef struct EnFloormas EnFloormas; +struct EnFloormas; +struct GlobalContext; -typedef void (*EnFloormasActionFunc)(EnFloormas* this, GlobalContext* globalCtx); +typedef void (*EnFloormasActionFunc)(EnFloormas* pthis, GlobalContext* globalCtx); struct EnFloormas{ /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c deleted file mode 100644 index efee313cb..000000000 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ /dev/null @@ -1,1099 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FR_Z_EN_FR_C -#include "actor_common.h" -#include "z_en_fr.h" -#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#include "vt.h" -#include "objects/object_fr/object_fr.h" -#include "def/code_800EC960.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25) - -void EnFr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFr_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFr_UpdateIdle(Actor* thisx, GlobalContext* globalCtx); -void EnFr_UpdateActive(Actor* thisx, GlobalContext* globalCtx); -void EnFr_Draw(Actor* thisx, GlobalContext* globalCtx); - -// Animation Functions -void EnFr_SetupJumpingOutOfWater(EnFr* this, GlobalContext* globalCtx); -void EnFr_JumpingOutOfWater(EnFr* this, GlobalContext* globalCtx); -void EnFr_OrientOnLogSpot(EnFr* this, GlobalContext* globalCtx); -void EnFr_ChooseJumpFromLogSpot(EnFr* this, GlobalContext* globalCtx); -void EnFr_JumpingUp(EnFr* this, GlobalContext* globalCtx); -void EnFr_JumpingBackIntoWater(EnFr* this, GlobalContext* globalCtx); -void EnFr_DecrementBlinkTimerUpdate(EnFr* this); - -// Activation -void EnFr_Idle(EnFr* this, GlobalContext* globalCtx); -void EnFr_Activate(EnFr* this, GlobalContext* globalCtx); -void EnFr_ActivateCheckFrogSong(EnFr* this, GlobalContext* globalCtx); - -// Listening for Child Songs -void func_80A1BE98(EnFr* this, GlobalContext* globalCtx); -void EnFr_ListeningToOcarinaNotes(EnFr* this, GlobalContext* globalCtx); -void EnFr_ChildSong(EnFr* this, GlobalContext* globalCtx); -void EnFr_ChildSongFirstTime(EnFr* this, GlobalContext* globalCtx); - -// Frog Song for HP Functions -void EnFr_TalkBeforeFrogSong(EnFr* this, GlobalContext* globalCtx); -void EnFr_SetupFrogSong(EnFr* this, GlobalContext* globalCtx); -void EnFr_ContinueFrogSong(EnFr* this, GlobalContext* globalCtx); -void EnFr_OcarinaMistake(EnFr* this, GlobalContext* globalCtx); - -// Reward Functions -void EnFr_SetupReward(EnFr* this, GlobalContext* globalCtx, u8 unkCondition); -void EnFr_PrintTextBox(EnFr* this, GlobalContext* globalCtx); -void EnFr_TalkBeforeReward(EnFr* this, GlobalContext* globalCtx); -void EnFr_SetReward(EnFr* this, GlobalContext* globalCtx); - -// Deactivate -void EnFr_Deactivate(EnFr* this, GlobalContext* globalCtx); -void EnFr_GiveReward(EnFr* this, GlobalContext* globalCtx); -void EnFr_SetIdle(EnFr* this, GlobalContext* globalCtx); - -/* -Frogs params WIP docs - -Represents 6 Actor Instances for frogs: - - 1 Prop actor instance set to where Link plays Ocarina, manages 5 frogs - - 5 NPC actor instances for the frogs themselves - -0: Prop Actor Instance (located where link detects ocarina, interacts with Link) -1: Frog 0 (Yellow) -2: Frog 1 (Blue) -3: Frog 2 (Red) -4: Frog 3 (Purple) -5: Frog 4 (White) - -Note that because of the Prop Actor, actor.params is 1 shifted from frogIndex -Therefore, frogIndex = actor.params - 1 - - -sEnFrPointers.flags = 1 - - Activate frogs, frogs will jump out of the water - -sEnFrPointers.flags = 1 to 11: - - Counter: Frogs will sequentially jump out based on counter: - - 1: Frog 1 (Blue) - - 3: frog 3 (Purple) - - 5: frog 0 (Yellow) - - 7: frog 2 (Red) - - 9: frog 4 (White) - - Will proceed when counter reachers 11 - -sEnFrPointers.flags = 12 - - Deactivate frogs, frogs will jump back into the water -*/ - -typedef struct { - u8 flags; - EnFr* frogs[5]; -} EnFrPointers; - -typedef struct { - f32 xzDist; - f32 yaw; - f32 yDist; -} LogSpotToFromWater; - -static EnFrPointers sEnFrPointers = { - 0x00, - { - NULL, - NULL, - NULL, - NULL, - NULL, - }, -}; - -// Flags for gSaveContext.eventChkInf[13] -static u16 sSongIndex[] = { - 0x0002, 0x0004, 0x0010, 0x0008, 0x0020, 0x0040, 0x0001, 0x0000, -}; - -// Frog to Index for Song Flag (sSongIndex) Mapping -static u8 sFrogToSongIndex[] = { - FROG_SARIA, FROG_SUNS, FROG_SOT, FROG_ZL, FROG_EPONA, -}; - -// Song to Frog Index Mapping -static s32 sSongToFrog[] = { - FROG_PURPLE, FROG_WHITE, FROG_YELLOW, FROG_BLUE, FROG_RED, -}; - -const ActorInit En_Fr_InitVars = { - ACTOR_EN_FR, - ACTORCAT_NPC, - FLAGS, - OBJECT_FR, - sizeof(EnFr), - (ActorFunc)EnFr_Init, - (ActorFunc)EnFr_Destroy, - (ActorFunc)EnFr_Update, - NULL, -}; - -static Color_RGBA8 sEnFrColor[] = { - { 200, 170, 0, 255 }, { 0, 170, 200, 255 }, { 210, 120, 100, 255 }, { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, -}; - -// Jumping back into water frog animation -// sLogSpotToFromWater[frog].xzDist is magnitude of xz distance frog travels -// sLogSpotToFromWater[frog].yaw is rot around y-axis of jumping back into water -// sLogSpotToFromWater[frog].yDist is change in y distance frog travels -static LogSpotToFromWater sLogSpotToFromWater[] = { - { 0.0f, 0.0f, 0.0f }, // Prop (Where link pulls ocarina) - { 80.0f, -0.375f * M_PI, -80.0f }, // FROG_YELLOW - { 80.0f, -0.5f * M_PI, -80.0f }, // FROG_BLUE - { 80.0f, -0.25f * M_PI, -80.0f }, // FROG_RED - { 80.0f, 0.875f * M_PI, -80.0f }, // FROG_PURPLE - { 80.0f, 0.5f * M_PI, -80.0f }, // FROG_WHITE -}; - -// Timer values for the frog choir song -static s16 sTimerFrogSong[] = { - 40, 20, 15, 12, 12, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -// Counter to Coordinate Frog jumping out of water one at a time -// Used as part of sEnFrPointers.flags -static u8 sTimerJumpingOutOfWater[] = { - 5, 1, 7, 3, 9, -}; - -// targetScale (default = 150.0) Actor scale target for Math_ApproachF -// Used as a frog grows from hearing a new child song -static f32 sGrowingScale[] = { - 180.0f, - 210.0f, - 240.0f, - 270.0f, -}; - -static u8 sSmallFrogNotes[] = { - 5, // C-Down Ocarina - 2, // A Button Ocarina - 9, // C-Right Ocarina - 11, // C-Left Ocarina - 14, // C Up Ocarina -}; - -static s8 sLargeFrogNotes[] = { - -7, // C-Down Ocarina - -10, // A Button Ocarina - -3, // C-Right Ocarina - -1, // C-Left Ocarina - 2, // C Up Ocarina -}; - -static u8 sJumpOrder[] = { - FROG_BLUE, FROG_YELLOW, FROG_RED, FROG_PURPLE, FROG_WHITE, FROG_BLUE, FROG_YELLOW, FROG_RED, -}; - -static u8 sOcarinaNotes[] = { - OCARINA_NOTE_A, OCARINA_NOTE_C_DOWN, OCARINA_NOTE_C_RIGHT, OCARINA_NOTE_C_LEFT, OCARINA_NOTE_C_UP, -}; - -void EnFr_OrientUnderwater(EnFr* this) { - Vec3f vec1; - Vec3f vec2; - - vec1.x = vec1.y = 0.0f; - vec1.z = this->xzDistToLogSpot = sLogSpotToFromWater[this->actor.params].xzDist; - Matrix_RotateY(sLogSpotToFromWater[this->actor.params].yaw, MTXMODE_NEW); - Matrix_MultVec3f(&vec1, &vec2); - this->actor.world.pos.x = this->posLogSpot.x + vec2.x; - this->actor.world.pos.z = this->posLogSpot.z + vec2.z; - this->actor.world.pos.y = sLogSpotToFromWater[this->actor.params].yDist + this->posLogSpot.y; - this->actor.world.rot.y = this->actor.shape.rot.y = - (s16)(sLogSpotToFromWater[this->actor.params].yaw * ((f32)0x8000 / M_PI)) + 0x8000; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; -} - -void EnFr_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFr* this = (EnFr*)thisx; - - if (this->actor.params == 0) { - this->actor.destroy = NULL; - this->actor.draw = NULL; - this->actor.update = EnFr_UpdateIdle; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_4); - this->actor.flags &= ~0; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - this->actor.textId = 0x40AC; - this->actionFunc = EnFr_Idle; - } else { - if ((this->actor.params >= 6) || (this->actor.params < 0)) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "The argument is wrong!!" - osSyncPrintf("%s[%d] : 引数が間違っている!!(%d)\n", "../z_en_fr.c", 370, this->actor.params); - osSyncPrintf(VT_RST); - ASSERT(0, "0", "../z_en_fr.c", 372); - } - - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP); - if (this->objBankIndex < 0) { - Actor_Kill(&this->actor); - osSyncPrintf(VT_COL(RED, WHITE)); - // "There is no bank!!" - osSyncPrintf("%s[%d] : バンクが無いよ!!\n", "../z_en_fr.c", 380); - osSyncPrintf(VT_RST); - ASSERT(0, "0", "../z_en_fr.c", 382); - } - } -} - -// Draw only the purple frog when ocarina is not pulled out on the log spot -void EnFr_DrawIdle(EnFr* this) { - this->actor.draw = (this->actor.params - 1) != FROG_PURPLE ? NULL : EnFr_Draw; -} - -void EnFr_DrawActive(EnFr* this) { - this->actor.draw = EnFr_Draw; -} - -void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFr* this = (EnFr*)thisx; - s32 pad; - s32 frogIndex; - s32 pad2; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->actor.flags &= ~ACTOR_FLAG_4; - frogIndex = this->actor.params - 1; - sEnFrPointers.frogs[frogIndex] = this; - Actor_ProcessInitChain(&this->actor, sInitChain); - // frog - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fr_Skel_00B498, &object_fr_Anim_001534, - this->jointTable, this->morphTable, 24); - // butterfly - SkelAnime_Init(globalCtx, &this->skelAnimeButterfly, &gButterflySkel, &gButterflyAnim, - this->jointTableButterfly, this->morphTableButterfly, 8); - // When playing the song for the HP, the frog with the next note and the butterfly turns on its lightsource - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, - this->actor.home.pos.z, 255, 255, 255, -1); - // Check to see if the song for a particular frog has been played. - // If it has, the frog is larger. If not, the frog is smaller - this->scale = gSaveContext.eventChkInf[13] & sSongIndex[sFrogToSongIndex[frogIndex]] ? 270.0f : 150.0f; - // When the frogs are not active (link doesn't have his ocarina out), - // Then shrink the frogs down by a factor of 10,000 - Actor_SetScale(&this->actor, this->scale * 0.0001f); - this->actor.minVelocityY = -9999.0f; - Actor_SetFocus(&this->actor, 10.0f); - this->eyeTexIndex = 1; - this->blinkTimer = (s16)(Rand_ZeroFloat(60.0f) + 20.0f); - this->blinkFunc = EnFr_DecrementBlinkTimerUpdate; - this->isBelowWaterSurfacePrevious = this->isBelowWaterSurfaceCurrent = false; - this->isJumpingUp = false; - this->posLogSpot = this->actor.world.pos; - this->actionFunc = EnFr_SetupJumpingOutOfWater; - this->isDeactivating = false; - this->growingScaleIndex = 0; - this->isActive = false; - this->isJumpingToFrogSong = false; - this->songIndex = FROG_NO_SONG; - this->unusedButterflyActor = NULL; - EnFr_OrientUnderwater(this); - EnFr_DrawIdle(this); - this->actor.update = EnFr_UpdateActive; - this->isButterflyDrawn = false; - this->xyAngleButterfly = 0x1000 * (s16)Rand_ZeroFloat(255.0f); - this->posButterflyLight.x = this->posButterfly.x = this->posLogSpot.x; - this->posButterflyLight.y = this->posButterfly.y = this->posLogSpot.y + 50.0f; - this->posButterflyLight.z = this->posButterfly.z = this->posLogSpot.z; - this->actor.flags &= ~ACTOR_FLAG_0; - } -} - -void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFr* this = (EnFr*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); -} - -void EnFr_IsDivingIntoWater(EnFr* this, GlobalContext* globalCtx) { - WaterBox* waterBox; - f32 waterSurface; - - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterSurface, &waterBox)) { - this->isBelowWaterSurfacePrevious = this->isBelowWaterSurfaceCurrent; - this->isBelowWaterSurfaceCurrent = this->actor.world.pos.y <= waterSurface ? true : false; - } -} - -void EnFr_DivingIntoWater(EnFr* this, GlobalContext* globalCtx) { - Vec3f vec; - - // Jumping into or out of water - if (this->isBelowWaterSurfaceCurrent != this->isBelowWaterSurfacePrevious) { - vec.x = this->actor.world.pos.x; - vec.y = this->actor.world.pos.y - 10.0f; - vec.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &vec, NULL, NULL, 1, 1); - - if (this->isBelowWaterSurfaceCurrent == false) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER); - } - } -} - -s32 EnFr_IsBelowLogSpot(EnFr* this, f32* yDistToLogSpot) { - yDistToLogSpot[0] = this->actor.world.pos.y - this->posLogSpot.y; - if ((this->actor.velocity.y < 0.0f) && (yDistToLogSpot[0] <= 0.0f)) { - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = this->posLogSpot.y; - return true; - } else { - return false; - } -} - -s32 EnFr_IsAboveAndWithin30DistXZ(Player* player, EnFr* this) { - f32 xDistToPlayer = player->actor.world.pos.x - this->actor.world.pos.x; - f32 zDistToPlayer = player->actor.world.pos.z - this->actor.world.pos.z; - f32 yDistToPlayer = player->actor.world.pos.y - this->actor.world.pos.y; - - return ((SQ(xDistToPlayer) + SQ(zDistToPlayer)) <= SQ(30.0f)) && (yDistToPlayer >= 0.0f); -} - -void EnFr_DecrementBlinkTimer(EnFr* this) { - if (this->blinkTimer != 0) { - this->blinkTimer--; - } else { - this->blinkFunc = EnFr_DecrementBlinkTimerUpdate; - } -} - -void EnFr_DecrementBlinkTimerUpdate(EnFr* this) { - if (this->blinkTimer != 0) { - this->blinkTimer--; - } else if (this->eyeTexIndex) { - this->eyeTexIndex = 0; - this->blinkTimer = (s16)(Rand_ZeroFloat(60.0f) + 20.0f); - this->blinkFunc = EnFr_DecrementBlinkTimer; - } else { - this->eyeTexIndex = 1; - this->blinkTimer = 1; - } -} - -void EnFr_SetupJumpingOutOfWater(EnFr* this, GlobalContext* globalCtx) { - if (sEnFrPointers.flags == sTimerJumpingOutOfWater[this->actor.params - 1]) { - Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); - EnFr_DrawActive(this); - this->actionFunc = EnFr_JumpingOutOfWater; - } -} - -void EnFr_JumpingOutOfWater(EnFr* this, GlobalContext* globalCtx) { - Vec3f vec1; - Vec3f vec2; - - if (this->skelAnime.curFrame == 6.0f) { - sEnFrPointers.flags++; - this->skelAnime.playSpeed = 0.0f; - } else if (this->skelAnime.curFrame == 3.0f) { - this->actor.gravity = -10.0f; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 47.0f; - } - - vec1.x = vec1.y = 0.0f; - vec1.z = this->xzDistToLogSpot; - Matrix_RotateY(((this->actor.world.rot.y + 0x8000) / (f32)0x8000) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&vec1, &vec2); - this->actor.world.pos.x = this->posLogSpot.x + vec2.x; - this->actor.world.pos.z = this->posLogSpot.z + vec2.z; - if (this->skelAnime.curFrame >= 3.0f) { - Math_ApproachF(&this->xzDistToLogSpot, 0.0f, 1.0f, 10.0f); - } - - if (EnFr_IsBelowLogSpot(this, &vec2.y)) { - this->actor.gravity = 0.0f; - this->actionFunc = EnFr_OrientOnLogSpot; - this->unusedFloat = 0.0f; - } - - if ((this->actor.velocity.y <= 0.0f) && (vec2.y < 40.0f)) { - this->skelAnime.playSpeed = 1.0f; - } -} - -void EnFr_OrientOnLogSpot(EnFr* this, GlobalContext* globalCtx) { - s16 rotYRemaining = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 10000, 100); - - this->actor.world.rot.y = this->actor.shape.rot.y; - - if ((rotYRemaining == 0) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - sEnFrPointers.flags++; - this->actionFunc = EnFr_ChooseJumpFromLogSpot; - Animation_Change(&this->skelAnime, &object_fr_Anim_001534, 1.0f, 0.0f, - Animation_GetLastFrame(&object_fr_Anim_001534), ANIMMODE_LOOP, 0.0f); - } -} - -void EnFr_ChooseJumpFromLogSpot(EnFr* this, GlobalContext* globalCtx) { - if (sEnFrPointers.flags == 12) { - this->actor.world.rot.y = ((f32)0x8000 / M_PI) * sLogSpotToFromWater[this->actor.params].yaw; - Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnFr_JumpingBackIntoWater; - } else if (this->isJumpingUp) { - Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnFr_JumpingUp; - } -} - -void EnFr_JumpingUp(EnFr* this, GlobalContext* globalCtx) { - f32 yDistToLogSpot; - - if (this->skelAnime.curFrame == 6.0f) { - this->skelAnime.playSpeed = 0.0f; - } else if (this->skelAnime.curFrame == 3.0f) { - this->actor.gravity = -10.0f; - this->actor.velocity.y = 25.0f; - if (this->isJumpingToFrogSong) { - this->isJumpingToFrogSong = false; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_EAT); - } - } - - if (EnFr_IsBelowLogSpot(this, &yDistToLogSpot)) { - this->isJumpingUp = false; - this->actor.gravity = 0.0f; - Animation_Change(&this->skelAnime, &object_fr_Anim_0011C0, 1.0f, 0.0f, - Animation_GetLastFrame(&object_fr_Anim_0011C0), ANIMMODE_LOOP, 0.0f); - this->actionFunc = EnFr_ChooseJumpFromLogSpot; - } else if ((this->actor.velocity.y <= 0.0f) && (yDistToLogSpot < 40.0f)) { - this->skelAnime.playSpeed = 1.0f; - } -} - -void EnFr_JumpingBackIntoWater(EnFr* this, GlobalContext* globalCtx) { - f32 yUnderwater = sLogSpotToFromWater[this->actor.params].yDist + this->posLogSpot.y; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 10000, 100); - if (this->skelAnime.curFrame == 6.0f) { - this->skelAnime.playSpeed = 0.0f; - } else if (this->skelAnime.curFrame == 3.0f) { - this->actor.speedXZ = 6.0f; - this->actor.gravity = -10.0f; - this->actor.velocity.y = 25.0f; - } - - // Final Spot Reached - if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < yUnderwater)) { - Animation_Change(&this->skelAnime, &object_fr_Anim_001534, 1.0f, 0.0f, - Animation_GetLastFrame(&object_fr_Anim_001534), ANIMMODE_LOOP, 0.0f); - this->actionFunc = EnFr_SetupJumpingOutOfWater; - EnFr_DrawIdle(this); - this->isDeactivating = true; - EnFr_OrientUnderwater(this); - } -} - -void EnFr_SetScaleActive(EnFr* this, GlobalContext* globalCtx) { - switch (this->isGrowing) { - case false: - Math_ApproachF(&this->scale, sGrowingScale[this->growingScaleIndex], 2.0f, 25.0f); - if (this->scale >= sGrowingScale[this->growingScaleIndex]) { - this->scale = sGrowingScale[this->growingScaleIndex]; - if (this->growingScaleIndex < 3) { - this->isGrowing = true; - } else { - this->isJumpingUp = false; - this->isActive = false; - } - } - break; - case true: - Math_ApproachF(&this->scale, 150.0f, 2.0f, 25.0f); - if (this->scale <= 150.0f) { - this->scale = 150.0f; - this->growingScaleIndex++; - if (this->growingScaleIndex >= 4) { - this->growingScaleIndex = 3; - } - this->isGrowing = false; - } - break; - } -} - -void EnFr_ButterflyPath(EnFr* this, GlobalContext* globalCtx) { - s16 rotY = this->actor.shape.rot.y; - f32 sin; - Vec3f vec1; - Vec3f vec2; - - this->xyAngleButterfly += 0x1000; - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, MTXMODE_APPLY); - vec1.x = vec1.y = 0.0f; - vec1.z = 25.0f; - Matrix_MultVec3f(&vec1, &vec2); - sin = Math_SinS(this->xyAngleButterfly * 2) * 5.0f; - this->posButterfly.x = (Math_SinS(rotY) * sin) + vec2.x; - this->posButterfly.y = (2.0f * Math_CosS(this->xyAngleButterfly)) + (this->posLogSpot.y + 50.0f); - this->posButterfly.z = (Math_CosS(rotY) * sin) + vec2.z; - Matrix_Translate(this->posButterfly.x, this->posButterfly.y, this->posButterfly.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, MTXMODE_APPLY); - vec1.x = 0.0f; - vec1.y = -15.0f; - vec1.z = 20.0f; - Matrix_MultVec3f(&vec1, &this->posButterflyLight); -} - -void EnFr_UpdateActive(Actor* thisx, GlobalContext* globalCtx) { - EnFr* this = (EnFr*)thisx; - - this->jumpCounter++; - Actor_SetScale(&this->actor, this->scale * 0.0001f); - - if (this->isActive) { - EnFr_SetScaleActive(this, globalCtx); - } else { - Actor_SetFocus(&this->actor, 10.0f); - this->blinkFunc(this); - this->actionFunc(this, globalCtx); - EnFr_IsDivingIntoWater(this, globalCtx); - EnFr_DivingIntoWater(this, globalCtx); - SkelAnime_Update(&this->skelAnime); - SkelAnime_Update(&this->skelAnimeButterfly); - EnFr_ButterflyPath(this, globalCtx); - Actor_MoveForward(&this->actor); - } -} - -s32 EnFr_SetupJumpingUp(EnFr* this, s32 frogIndex) { - EnFr* frog = sEnFrPointers.frogs[frogIndex]; - u8 semitone; - - if (frog != NULL && frog->isJumpingUp == false) { - semitone = frog->growingScaleIndex == 3 ? sLargeFrogNotes[frogIndex] : sSmallFrogNotes[frogIndex]; - if (this->songIndex == FROG_CHOIR_SONG) { - frog->isJumpingToFrogSong = true; - } - frog->isJumpingUp = true; - Audio_PlaySoundTransposed(&frog->actor.projectedPos, NA_SE_EV_FROG_JUMP, semitone); - return true; - } else { - return false; - } -} - -void EnFr_Idle(EnFr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (player->stateFlags2 & 0x2000000) { - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; - } - - OnePointCutscene_Init(globalCtx, 4110, ~0x62, &this->actor, MAIN_CAM); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - player->actor.world.pos.x = this->actor.world.pos.x; // x = 990.0f - player->actor.world.pos.y = this->actor.world.pos.y; // y = 205.0f - player->actor.world.pos.z = this->actor.world.pos.z; // z = -1220.0f - player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; - this->reward = GI_NONE; - this->actionFunc = EnFr_Activate; - } else if (EnFr_IsAboveAndWithin30DistXZ(player, this)) { - player->unk_6A8 = &this->actor; - } -} - -void EnFr_Activate(EnFr* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_PLAYING) { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - sEnFrPointers.flags = 1; - this->actionFunc = EnFr_ActivateCheckFrogSong; - } else if (globalCtx->msgCtx.msgMode == MSGMODE_PAUSED) { // Goes to Frogs 2 Song - sEnFrPointers.flags = 1; - this->actionFunc = EnFr_ActivateCheckFrogSong; - } -} - -void EnFr_ActivateCheckFrogSong(EnFr* this, GlobalContext* globalCtx) { - if (sEnFrPointers.flags == 11) { - // Check if all 6 child songs have been played for the frogs - if ((gSaveContext.eventChkInf[13] & 0x2) // ZL - && (gSaveContext.eventChkInf[13] & 0x4) // Epona - && (gSaveContext.eventChkInf[13] & 0x10) // Saria - && (gSaveContext.eventChkInf[13] & 0x8) // Suns - && (gSaveContext.eventChkInf[13] & 0x20) // SoT - && (gSaveContext.eventChkInf[13] & 0x40)) { // SoS - this->actionFunc = EnFr_TalkBeforeFrogSong; - this->songIndex = FROG_CHOIR_SONG; - Message_StartTextbox(globalCtx, 0x40AB, &this->actor); - } else { - this->songIndex = FROG_ZL; - this->actionFunc = func_80A1BE98; - } - } -} - -void func_80A1BE98(EnFr* this, GlobalContext* globalCtx) { - EnFr* frog; - s32 frogIndex; - - for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { - frog = sEnFrPointers.frogs[frogIndex]; - if (frog != NULL && frog->actionFunc == EnFr_ChooseJumpFromLogSpot) { - continue; - } else { - return; - } - } - - func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_NOWARP); - this->actionFunc = EnFr_ListeningToOcarinaNotes; -} - -void EnFr_ListeningToOcarinaNotes(EnFr* this, GlobalContext* globalCtx) { - this->songIndex = FROG_NO_SONG; - switch (globalCtx->msgCtx.ocarinaMode) { // Ocarina Song played - case OCARINA_MODE_07: - this->songIndex = FROG_ZL; - break; - case OCARINA_MODE_06: - this->songIndex = FROG_EPONA; - break; - case OCARINA_MODE_05: - this->songIndex = FROG_SARIA; - break; - case OCARINA_MODE_08: - this->songIndex = FROG_SUNS; - break; - case OCARINA_MODE_09: - this->songIndex = FROG_SOT; - break; - case OCARINA_MODE_0A: - this->songIndex = FROG_STORMS; - break; - case OCARINA_MODE_04: - EnFr_OcarinaMistake(this, globalCtx); - break; - case OCARINA_MODE_01: // Ocarina note played, but no song played - switch (globalCtx->msgCtx.lastOcaNoteIdx) { // Jumping frogs in open ocarina based on ocarina note played - case OCARINA_NOTE_A: - EnFr_SetupJumpingUp(this, FROG_BLUE); - break; - case OCARINA_NOTE_C_DOWN: - EnFr_SetupJumpingUp(this, FROG_YELLOW); - break; - case OCARINA_NOTE_C_RIGHT: - EnFr_SetupJumpingUp(this, FROG_RED); - break; - case OCARINA_NOTE_C_LEFT: - EnFr_SetupJumpingUp(this, FROG_PURPLE); - break; - case OCARINA_NOTE_C_UP: - EnFr_SetupJumpingUp(this, FROG_WHITE); - break; - } - } - if (this->songIndex != FROG_NO_SONG) { - this->jumpCounter = 0; - this->actionFunc = EnFr_ChildSong; - } -} - -void EnFr_ChildSong(EnFr* this, GlobalContext* globalCtx) { - EnFr* frog; - u8 songIndex; - - if (this->jumpCounter < 48) { - if (this->jumpCounter % 4 == 0) { - EnFr_SetupJumpingUp(this, sJumpOrder[(this->jumpCounter >> 2) & 7]); - } - } else { - songIndex = this->songIndex; - if (songIndex == FROG_STORMS) { - this->actor.textId = 0x40AA; - EnFr_SetupReward(this, globalCtx, false); - } else if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { - frog = sEnFrPointers.frogs[sSongToFrog[songIndex]]; - func_80078884(NA_SE_SY_CORRECT_CHIME); - if (frog->actionFunc == EnFr_ChooseJumpFromLogSpot) { - frog->isJumpingUp = true; - frog->isActive = true; - Audio_PlayActorSound2(&frog->actor, NA_SE_EV_FROG_GROW_UP); - this->actionFunc = EnFr_ChildSongFirstTime; - } else { - this->jumpCounter = 48; - } - } else { - this->actor.textId = 0x40A9; - EnFr_SetupReward(this, globalCtx, true); - } - } -} - -void EnFr_ChildSongFirstTime(EnFr* this, GlobalContext* globalCtx) { - EnFr* frog = sEnFrPointers.frogs[sSongToFrog[this->songIndex]]; - - if (frog->isActive == false) { - this->actor.textId = 0x40A9; - EnFr_SetupReward(this, globalCtx, true); - } -} - -void EnFr_TalkBeforeFrogSong(EnFr* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->frogSongTimer = 2; - this->actionFunc = EnFr_SetupFrogSong; - } -} - -void EnFr_CheckOcarinaInputFrogSong(u8 ocarinaNote) { - EnFr* frog; - s32 frogIndexButterfly; - s32 frogIndex; - - switch (ocarinaNote) { - case 0: - frogIndexButterfly = FROG_BLUE; - break; - case 1: - frogIndexButterfly = FROG_YELLOW; - break; - case 2: - frogIndexButterfly = FROG_RED; - break; - case 3: - frogIndexButterfly = FROG_PURPLE; - break; - case 4: - frogIndexButterfly = FROG_WHITE; - } - // Turn on or off butterfly above frog - for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { - frog = sEnFrPointers.frogs[frogIndex]; - frog->isButterflyDrawn = frogIndex == frogIndexButterfly ? true : false; - } -} - -void EnFr_DeactivateButterfly() { - s32 frogIndex; - EnFr* frog; - - for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { - frog = sEnFrPointers.frogs[frogIndex]; - frog->isButterflyDrawn = false; - } -} - -u8 EnFr_GetNextNoteFrogSong(u8 ocarinaNoteIndex) { - if (!(gSaveContext.eventChkInf[13] & 1)) { - return gFrogsSongPtr[ocarinaNoteIndex]; - } else { - return sOcarinaNotes[(s32)Rand_ZeroFloat(60.0f) % 5]; - } -} - -void EnFr_SetupFrogSong(EnFr* this, GlobalContext* globalCtx) { - if (this->frogSongTimer != 0) { - this->frogSongTimer--; - } else { - this->frogSongTimer = 40; - this->ocarinaNoteIndex = 0; - func_8010BD58(globalCtx, OCARINA_ACTION_FROGS); - this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex); - EnFr_CheckOcarinaInputFrogSong(this->ocarinaNote); - this->actionFunc = EnFr_ContinueFrogSong; - } -} - -s32 EnFr_IsFrogSongComplete(EnFr* this, GlobalContext* globalCtx) { - u8 index; - u8 ocarinaNote; - MessageContext* msgCtx = &globalCtx->msgCtx; - u8 ocarinaNoteIndex; - - if (this->ocarinaNote == (*msgCtx).lastOcaNoteIdx) { // required to match, possibly an array? - this->ocarinaNoteIndex++; - ocarinaNoteIndex = this->ocarinaNoteIndex; - if (1) {} - if (ocarinaNoteIndex >= 14) { // Frog Song is completed - this->ocarinaNoteIndex = 13; - return true; - } - // The first four notes have more frames to receive an input - index = ocarinaNoteIndex < 4 ? (s32)ocarinaNoteIndex : 4; - ocarinaNote = EnFr_GetNextNoteFrogSong(ocarinaNoteIndex); - this->ocarinaNote = ocarinaNote; - EnFr_CheckOcarinaInputFrogSong(ocarinaNote); - this->frogSongTimer = sTimerFrogSong[index]; - } - return false; -} - -void EnFr_OcarinaMistake(EnFr* this, GlobalContext* globalCtx) { - Message_CloseTextbox(globalCtx); - this->reward = GI_NONE; - func_80078884(NA_SE_SY_OCARINA_ERROR); - Audio_OcaSetInstrument(0); - sEnFrPointers.flags = 12; - EnFr_DeactivateButterfly(); - this->actionFunc = EnFr_Deactivate; -} - -void EnFr_ContinueFrogSong(EnFr* this, GlobalContext* globalCtx) { - s32 counter; - EnFr* frog; - s32 i; - - if (this->frogSongTimer == 0) { - EnFr_OcarinaMistake(this, globalCtx); - } else { - this->frogSongTimer--; - if (globalCtx->msgCtx.msgMode == MSGMODE_FROGS_PLAYING) { - counter = 0; - for (i = 0; i < ARRAY_COUNT(sEnFrPointers.frogs); i++) { - frog = sEnFrPointers.frogs[i]; - if (frog != NULL && frog->actionFunc == EnFr_ChooseJumpFromLogSpot) { - continue; - } else { - counter++; - } - } - if (counter == 0 && CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B)) { - EnFr_OcarinaMistake(this, globalCtx); - return; - } - } - - if (globalCtx->msgCtx.msgMode == MSGMODE_FROGS_WAITING) { - globalCtx->msgCtx.msgMode = MSGMODE_FROGS_START; - switch (globalCtx->msgCtx.lastOcaNoteIdx) { - case OCARINA_NOTE_A: - EnFr_SetupJumpingUp(this, FROG_BLUE); - break; - case OCARINA_NOTE_C_DOWN: - EnFr_SetupJumpingUp(this, FROG_YELLOW); - break; - case OCARINA_NOTE_C_RIGHT: - EnFr_SetupJumpingUp(this, FROG_RED); - break; - case OCARINA_NOTE_C_LEFT: - EnFr_SetupJumpingUp(this, FROG_PURPLE); - break; - case OCARINA_NOTE_C_UP: - EnFr_SetupJumpingUp(this, FROG_WHITE); - } - if (EnFr_IsFrogSongComplete(this, globalCtx)) { - this->actor.textId = 0x40AC; - EnFr_SetupReward(this, globalCtx, false); - } - } - } -} - -void EnFr_SetupReward(EnFr* this, GlobalContext* globalCtx, u8 unkCondition) { - EnFr_DeactivateButterfly(); - if (unkCondition) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } else { - func_80078884(NA_SE_SY_CORRECT_CHIME); - } - - Audio_OcaSetInstrument(0); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actionFunc = EnFr_PrintTextBox; -} - -void EnFr_PrintTextBox(EnFr* this, GlobalContext* globalCtx) { - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - this->actionFunc = EnFr_TalkBeforeReward; -} - -void EnFr_TalkBeforeReward(EnFr* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->frogSongTimer = 100; - Message_CloseTextbox(globalCtx); - this->actionFunc = EnFr_SetReward; - } -} - -void EnFr_SetReward(EnFr* this, GlobalContext* globalCtx) { - u16 songIndex; - - sEnFrPointers.flags = 12; - songIndex = this->songIndex; - this->actionFunc = EnFr_Deactivate; - this->reward = GI_NONE; - if ((songIndex >= FROG_ZL) && (songIndex <= FROG_SOT)) { - if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { - gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; - this->reward = GI_RUPEE_PURPLE; - } else { - this->reward = GI_RUPEE_BLUE; - } - } else if (songIndex == FROG_STORMS) { - if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { - gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; - this->reward = GI_HEART_PIECE; - } else { - this->reward = GI_RUPEE_BLUE; - } - } else if (songIndex == FROG_CHOIR_SONG) { - if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { - gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; - this->reward = GI_HEART_PIECE; - } else { - this->reward = GI_RUPEE_PURPLE; - } - } -} - -void EnFr_Deactivate(EnFr* this, GlobalContext* globalCtx) { - EnFr* frogLoop1; - EnFr* frogLoop2; - s32 frogIndex; - - // Originally was going to have separate butterfly actor - // Changed to include butterfly as part of frog actor - // This unused code would have frozen the butterfly actor above frog - if (this->unusedButterflyActor != NULL) { - this->unusedButterflyActor->freezeTimer = 10; - } - - for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { - frogLoop1 = sEnFrPointers.frogs[frogIndex]; - if (frogLoop1 == NULL) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "There are no frogs!?" - osSyncPrintf("%s[%d]カエルがいない!?\n", "../z_en_fr.c", 1604); - osSyncPrintf(VT_RST); - return; - } else if (frogLoop1->isDeactivating != true) { - return; - } - } - - for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { - frogLoop2 = sEnFrPointers.frogs[frogIndex]; - if (frogLoop2 == NULL) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "There are no frogs!?" - osSyncPrintf("%s[%d]カエルがいない!?\n", "../z_en_fr.c", 1618); - osSyncPrintf(VT_RST); - return; - } - frogLoop2->isDeactivating = false; - } - - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); - if (this->reward == GI_NONE) { - this->actionFunc = EnFr_Idle; - } else { - this->actionFunc = EnFr_GiveReward; - func_8002F434(&this->actor, globalCtx, this->reward, 30.0f, 100.0f); - } -} - -void EnFr_GiveReward(EnFr* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnFr_SetIdle; - } else { - func_8002F434(&this->actor, globalCtx, this->reward, 30.0f, 100.0f); - } -} - -void EnFr_SetIdle(EnFr* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = EnFr_Idle; - } -} - -void EnFr_UpdateIdle(Actor* thisx, GlobalContext* globalCtx) { - EnFr* this = (EnFr*)thisx; - - this->jumpCounter++; - this->actionFunc(this, globalCtx); -} - -s32 EnFr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - if ((limbIndex == 7) || (limbIndex == 8)) { - *dList = NULL; - } - return 0; -} - -void EnFr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnFr* this = (EnFr*)thisx; - - if ((limbIndex == 7) || (limbIndex == 8)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1735); - Matrix_Push(); - func_800D1FD4(&globalCtx->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fr.c", 1738), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1741); - } -} - -void EnFr_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { - object_fr_Tex_0059A0, - object_fr_Tex_005BA0, - }; - s16 lightRadius; - EnFr* this = (EnFr*)thisx; - s16 frogIndex = this->actor.params - 1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1754); - func_80093D18(globalCtx->state.gfxCtx); - // For the frogs 2 HP, the frog with the next note and the butterfly lights up - lightRadius = this->isButterflyDrawn ? 95 : -1; - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->posButterflyLight.x, this->posButterflyLight.y, - this->posButterflyLight.z, 255, 255, 255, lightRadius); - gDPSetEnvColor(POLY_OPA_DISP++, sEnFrColor[frogIndex].r, sEnFrColor[frogIndex].g, sEnFrColor[frogIndex].b, 255); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexIndex])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnFr_OverrideLimbDraw, EnFr_PostLimbDraw, this); - if (this->isButterflyDrawn) { - Matrix_Translate(this->posButterfly.x, this->posButterfly.y, this->posButterfly.z, MTXMODE_NEW); - Matrix_Scale(0.015f, 0.015f, 0.015f, MTXMODE_APPLY); - Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnimeButterfly.skeleton, this->skelAnimeButterfly.jointTable, NULL, NULL, - NULL); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1816); -} diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.cpp b/src/overlays/actors/ovl_En_Fr/z_en_fr.cpp new file mode 100644 index 000000000..51a01d4e7 --- /dev/null +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.cpp @@ -0,0 +1,1099 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FR_Z_EN_FR_C +#include "actor_common.h" +#include "z_en_fr.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "vt.h" +#include "objects/object_fr/object_fr.h" +#include "def/code_800EC960.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25) + +void EnFr_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFr_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFr_UpdateIdle(Actor* thisx, GlobalContext* globalCtx); +void EnFr_UpdateActive(Actor* thisx, GlobalContext* globalCtx); +void EnFr_Draw(Actor* thisx, GlobalContext* globalCtx); + +// Animation Functions +void EnFr_SetupJumpingOutOfWater(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_JumpingOutOfWater(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_OrientOnLogSpot(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_ChooseJumpFromLogSpot(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_JumpingUp(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_JumpingBackIntoWater(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_DecrementBlinkTimerUpdate(EnFr* pthis); + +// Activation +void EnFr_Idle(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_Activate(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_ActivateCheckFrogSong(EnFr* pthis, GlobalContext* globalCtx); + +// Listening for Child Songs +void func_80A1BE98(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_ListeningToOcarinaNotes(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_ChildSong(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_ChildSongFirstTime(EnFr* pthis, GlobalContext* globalCtx); + +// Frog Song for HP Functions +void EnFr_TalkBeforeFrogSong(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_SetupFrogSong(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_ContinueFrogSong(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_OcarinaMistake(EnFr* pthis, GlobalContext* globalCtx); + +// Reward Functions +void EnFr_SetupReward(EnFr* pthis, GlobalContext* globalCtx, u8 unkCondition); +void EnFr_PrintTextBox(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_TalkBeforeReward(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_SetReward(EnFr* pthis, GlobalContext* globalCtx); + +// Deactivate +void EnFr_Deactivate(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_GiveReward(EnFr* pthis, GlobalContext* globalCtx); +void EnFr_SetIdle(EnFr* pthis, GlobalContext* globalCtx); + +/* +Frogs params WIP docs + +Represents 6 Actor Instances for frogs: + - 1 Prop actor instance set to where Link plays Ocarina, manages 5 frogs + - 5 NPC actor instances for the frogs themselves + +0: Prop Actor Instance (located where link detects ocarina, interacts with Link) +1: Frog 0 (Yellow) +2: Frog 1 (Blue) +3: Frog 2 (Red) +4: Frog 3 (Purple) +5: Frog 4 (White) + +Note that because of the Prop Actor, actor.params is 1 shifted from frogIndex +Therefore, frogIndex = actor.params - 1 + + +sEnFrPointers.flags = 1 + - Activate frogs, frogs will jump out of the water + +sEnFrPointers.flags = 1 to 11: + - Counter: Frogs will sequentially jump out based on counter: + - 1: Frog 1 (Blue) + - 3: frog 3 (Purple) + - 5: frog 0 (Yellow) + - 7: frog 2 (Red) + - 9: frog 4 (White) + - Will proceed when counter reachers 11 + +sEnFrPointers.flags = 12 + - Deactivate frogs, frogs will jump back into the water +*/ + +typedef struct { + u8 flags; + EnFr* frogs[5]; +} EnFrPointers; + +typedef struct { + f32 xzDist; + f32 yaw; + f32 yDist; +} LogSpotToFromWater; + +static EnFrPointers sEnFrPointers = { + 0x00, + { + NULL, + NULL, + NULL, + NULL, + NULL, + }, +}; + +// Flags for gSaveContext.eventChkInf[13] +static u16 sSongIndex[] = { + 0x0002, 0x0004, 0x0010, 0x0008, 0x0020, 0x0040, 0x0001, 0x0000, +}; + +// Frog to Index for Song Flag (sSongIndex) Mapping +static u8 sFrogToSongIndex[] = { + FROG_SARIA, FROG_SUNS, FROG_SOT, FROG_ZL, FROG_EPONA, +}; + +// Song to Frog Index Mapping +static s32 sSongToFrog[] = { + FROG_PURPLE, FROG_WHITE, FROG_YELLOW, FROG_BLUE, FROG_RED, +}; + +ActorInit En_Fr_InitVars = { + ACTOR_EN_FR, + ACTORCAT_NPC, + FLAGS, + OBJECT_FR, + sizeof(EnFr), + (ActorFunc)EnFr_Init, + (ActorFunc)EnFr_Destroy, + (ActorFunc)EnFr_Update, + NULL, +}; + +static Color_RGBA8 sEnFrColor[] = { + { 200, 170, 0, 255 }, { 0, 170, 200, 255 }, { 210, 120, 100, 255 }, { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, +}; + +// Jumping back into water frog animation +// sLogSpotToFromWater[frog].xzDist is magnitude of xz distance frog travels +// sLogSpotToFromWater[frog].yaw is rot around y-axis of jumping back into water +// sLogSpotToFromWater[frog].yDist is change in y distance frog travels +static LogSpotToFromWater sLogSpotToFromWater[] = { + { 0.0f, 0.0f, 0.0f }, // Prop (Where link pulls ocarina) + { 80.0f, -0.375f * M_PI, -80.0f }, // FROG_YELLOW + { 80.0f, -0.5f * M_PI, -80.0f }, // FROG_BLUE + { 80.0f, -0.25f * M_PI, -80.0f }, // FROG_RED + { 80.0f, 0.875f * M_PI, -80.0f }, // FROG_PURPLE + { 80.0f, 0.5f * M_PI, -80.0f }, // FROG_WHITE +}; + +// Timer values for the frog choir song +static s16 sTimerFrogSong[] = { + 40, 20, 15, 12, 12, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +// Counter to Coordinate Frog jumping out of water one at a time +// Used as part of sEnFrPointers.flags +static u8 sTimerJumpingOutOfWater[] = { + 5, 1, 7, 3, 9, +}; + +// targetScale (default = 150.0) Actor scale target for Math_ApproachF +// Used as a frog grows from hearing a new child song +static f32 sGrowingScale[] = { + 180.0f, + 210.0f, + 240.0f, + 270.0f, +}; + +static u8 sSmallFrogNotes[] = { + 5, // C-Down Ocarina + 2, // A Button Ocarina + 9, // C-Right Ocarina + 11, // C-Left Ocarina + 14, // C Up Ocarina +}; + +static s8 sLargeFrogNotes[] = { + -7, // C-Down Ocarina + -10, // A Button Ocarina + -3, // C-Right Ocarina + -1, // C-Left Ocarina + 2, // C Up Ocarina +}; + +static u8 sJumpOrder[] = { + FROG_BLUE, FROG_YELLOW, FROG_RED, FROG_PURPLE, FROG_WHITE, FROG_BLUE, FROG_YELLOW, FROG_RED, +}; + +static u8 sOcarinaNotes[] = { + OCARINA_NOTE_A, OCARINA_NOTE_C_DOWN, OCARINA_NOTE_C_RIGHT, OCARINA_NOTE_C_LEFT, OCARINA_NOTE_C_UP, +}; + +void EnFr_OrientUnderwater(EnFr* pthis) { + Vec3f vec1; + Vec3f vec2; + + vec1.x = vec1.y = 0.0f; + vec1.z = pthis->xzDistToLogSpot = sLogSpotToFromWater[pthis->actor.params].xzDist; + Matrix_RotateY(sLogSpotToFromWater[pthis->actor.params].yaw, MTXMODE_NEW); + Matrix_MultVec3f(&vec1, &vec2); + pthis->actor.world.pos.x = pthis->posLogSpot.x + vec2.x; + pthis->actor.world.pos.z = pthis->posLogSpot.z + vec2.z; + pthis->actor.world.pos.y = sLogSpotToFromWater[pthis->actor.params].yDist + pthis->posLogSpot.y; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = + (s16)(sLogSpotToFromWater[pthis->actor.params].yaw * ((f32)0x8000 / M_PI)) + 0x8000; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; +} + +void EnFr_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFr* pthis = (EnFr*)thisx; + + if (pthis->actor.params == 0) { + pthis->actor.destroy = NULL; + pthis->actor.draw = NULL; + pthis->actor.update = EnFr_UpdateIdle; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_4); + pthis->actor.flags &= ~0; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + pthis->actor.textId = 0x40AC; + pthis->actionFunc = EnFr_Idle; + } else { + if ((pthis->actor.params >= 6) || (pthis->actor.params < 0)) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "The argument is wrong!!" + osSyncPrintf("%s[%d] : 引数が間違っている!!(%d)\n", "../z_en_fr.c", 370, pthis->actor.params); + osSyncPrintf(VT_RST); + ASSERT(0, "0", "../z_en_fr.c", 372); + } + + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP); + if (pthis->objBankIndex < 0) { + Actor_Kill(&pthis->actor); + osSyncPrintf(VT_COL(RED, WHITE)); + // "There is no bank!!" + osSyncPrintf("%s[%d] : バンクが無いよ!!\n", "../z_en_fr.c", 380); + osSyncPrintf(VT_RST); + ASSERT(0, "0", "../z_en_fr.c", 382); + } + } +} + +// Draw only the purple frog when ocarina is not pulled out on the log spot +void EnFr_DrawIdle(EnFr* pthis) { + pthis->actor.draw = (pthis->actor.params - 1) != FROG_PURPLE ? NULL : EnFr_Draw; +} + +void EnFr_DrawActive(EnFr* pthis) { + pthis->actor.draw = EnFr_Draw; +} + +void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFr* pthis = (EnFr*)thisx; + s32 pad; + s32 frogIndex; + s32 pad2; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + frogIndex = pthis->actor.params - 1; + sEnFrPointers.frogs[frogIndex] = pthis; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + // frog + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_fr_Skel_00B498, &object_fr_Anim_001534, + pthis->jointTable, pthis->morphTable, 24); + // butterfly + SkelAnime_Init(globalCtx, &pthis->skelAnimeButterfly, &gButterflySkel, &gButterflyAnim, + pthis->jointTableButterfly, pthis->morphTableButterfly, 8); + // When playing the song for the HP, the frog with the next note and the butterfly turns on its lightsource + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.home.pos.x, pthis->actor.home.pos.y, + pthis->actor.home.pos.z, 255, 255, 255, -1); + // Check to see if the song for a particular frog has been played. + // If it has, the frog is larger. If not, the frog is smaller + pthis->scale = gSaveContext.eventChkInf[13] & sSongIndex[sFrogToSongIndex[frogIndex]] ? 270.0f : 150.0f; + // When the frogs are not active (link doesn't have his ocarina out), + // Then shrink the frogs down by a factor of 10,000 + Actor_SetScale(&pthis->actor, pthis->scale * 0.0001f); + pthis->actor.minVelocityY = -9999.0f; + Actor_SetFocus(&pthis->actor, 10.0f); + pthis->eyeTexIndex = 1; + pthis->blinkTimer = (s16)(Rand_ZeroFloat(60.0f) + 20.0f); + pthis->blinkFunc = EnFr_DecrementBlinkTimerUpdate; + pthis->isBelowWaterSurfacePrevious = pthis->isBelowWaterSurfaceCurrent = false; + pthis->isJumpingUp = false; + pthis->posLogSpot = pthis->actor.world.pos; + pthis->actionFunc = EnFr_SetupJumpingOutOfWater; + pthis->isDeactivating = false; + pthis->growingScaleIndex = 0; + pthis->isActive = false; + pthis->isJumpingToFrogSong = false; + pthis->songIndex = FROG_NO_SONG; + pthis->unusedButterflyActor = NULL; + EnFr_OrientUnderwater(pthis); + EnFr_DrawIdle(pthis); + pthis->actor.update = EnFr_UpdateActive; + pthis->isButterflyDrawn = false; + pthis->xyAngleButterfly = 0x1000 * (s16)Rand_ZeroFloat(255.0f); + pthis->posButterflyLight.x = pthis->posButterfly.x = pthis->posLogSpot.x; + pthis->posButterflyLight.y = pthis->posButterfly.y = pthis->posLogSpot.y + 50.0f; + pthis->posButterflyLight.z = pthis->posButterfly.z = pthis->posLogSpot.z; + pthis->actor.flags &= ~ACTOR_FLAG_0; + } +} + +void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFr* pthis = (EnFr*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); +} + +void EnFr_IsDivingIntoWater(EnFr* pthis, GlobalContext* globalCtx) { + WaterBox* waterBox; + f32 waterSurface; + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, + &waterSurface, &waterBox)) { + pthis->isBelowWaterSurfacePrevious = pthis->isBelowWaterSurfaceCurrent; + pthis->isBelowWaterSurfaceCurrent = pthis->actor.world.pos.y <= waterSurface ? true : false; + } +} + +void EnFr_DivingIntoWater(EnFr* pthis, GlobalContext* globalCtx) { + Vec3f vec; + + // Jumping into or out of water + if (pthis->isBelowWaterSurfaceCurrent != pthis->isBelowWaterSurfacePrevious) { + vec.x = pthis->actor.world.pos.x; + vec.y = pthis->actor.world.pos.y - 10.0f; + vec.z = pthis->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &vec, NULL, NULL, 1, 1); + + if (pthis->isBelowWaterSurfaceCurrent == false) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_DIVE_INTO_WATER_L); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } +} + +s32 EnFr_IsBelowLogSpot(EnFr* pthis, f32* yDistToLogSpot) { + yDistToLogSpot[0] = pthis->actor.world.pos.y - pthis->posLogSpot.y; + if ((pthis->actor.velocity.y < 0.0f) && (yDistToLogSpot[0] <= 0.0f)) { + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = pthis->posLogSpot.y; + return true; + } else { + return false; + } +} + +s32 EnFr_IsAboveAndWithin30DistXZ(Player* player, EnFr* pthis) { + f32 xDistToPlayer = player->actor.world.pos.x - pthis->actor.world.pos.x; + f32 zDistToPlayer = player->actor.world.pos.z - pthis->actor.world.pos.z; + f32 yDistToPlayer = player->actor.world.pos.y - pthis->actor.world.pos.y; + + return ((SQ(xDistToPlayer) + SQ(zDistToPlayer)) <= SQ(30.0f)) && (yDistToPlayer >= 0.0f); +} + +void EnFr_DecrementBlinkTimer(EnFr* pthis) { + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + } else { + pthis->blinkFunc = EnFr_DecrementBlinkTimerUpdate; + } +} + +void EnFr_DecrementBlinkTimerUpdate(EnFr* pthis) { + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + } else if (pthis->eyeTexIndex) { + pthis->eyeTexIndex = 0; + pthis->blinkTimer = (s16)(Rand_ZeroFloat(60.0f) + 20.0f); + pthis->blinkFunc = EnFr_DecrementBlinkTimer; + } else { + pthis->eyeTexIndex = 1; + pthis->blinkTimer = 1; + } +} + +void EnFr_SetupJumpingOutOfWater(EnFr* pthis, GlobalContext* globalCtx) { + if (sEnFrPointers.flags == sTimerJumpingOutOfWater[pthis->actor.params - 1]) { + Animation_Change(&pthis->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); + EnFr_DrawActive(pthis); + pthis->actionFunc = EnFr_JumpingOutOfWater; + } +} + +void EnFr_JumpingOutOfWater(EnFr* pthis, GlobalContext* globalCtx) { + Vec3f vec1; + Vec3f vec2; + + if (pthis->skelAnime.curFrame == 6.0f) { + sEnFrPointers.flags++; + pthis->skelAnime.playSpeed = 0.0f; + } else if (pthis->skelAnime.curFrame == 3.0f) { + pthis->actor.gravity = -10.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 47.0f; + } + + vec1.x = vec1.y = 0.0f; + vec1.z = pthis->xzDistToLogSpot; + Matrix_RotateY(((pthis->actor.world.rot.y + 0x8000) / (f32)0x8000) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&vec1, &vec2); + pthis->actor.world.pos.x = pthis->posLogSpot.x + vec2.x; + pthis->actor.world.pos.z = pthis->posLogSpot.z + vec2.z; + if (pthis->skelAnime.curFrame >= 3.0f) { + Math_ApproachF(&pthis->xzDistToLogSpot, 0.0f, 1.0f, 10.0f); + } + + if (EnFr_IsBelowLogSpot(pthis, &vec2.y)) { + pthis->actor.gravity = 0.0f; + pthis->actionFunc = EnFr_OrientOnLogSpot; + pthis->unusedFloat = 0.0f; + } + + if ((pthis->actor.velocity.y <= 0.0f) && (vec2.y < 40.0f)) { + pthis->skelAnime.playSpeed = 1.0f; + } +} + +void EnFr_OrientOnLogSpot(EnFr* pthis, GlobalContext* globalCtx) { + s16 rotYRemaining = Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 10000, 100); + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if ((rotYRemaining == 0) && (pthis->skelAnime.curFrame == pthis->skelAnime.endFrame)) { + sEnFrPointers.flags++; + pthis->actionFunc = EnFr_ChooseJumpFromLogSpot; + Animation_Change(&pthis->skelAnime, &object_fr_Anim_001534, 1.0f, 0.0f, + Animation_GetLastFrame(&object_fr_Anim_001534), ANIMMODE_LOOP, 0.0f); + } +} + +void EnFr_ChooseJumpFromLogSpot(EnFr* pthis, GlobalContext* globalCtx) { + if (sEnFrPointers.flags == 12) { + pthis->actor.world.rot.y = ((f32)0x8000 / M_PI) * sLogSpotToFromWater[pthis->actor.params].yaw; + Animation_Change(&pthis->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnFr_JumpingBackIntoWater; + } else if (pthis->isJumpingUp) { + Animation_Change(&pthis->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnFr_JumpingUp; + } +} + +void EnFr_JumpingUp(EnFr* pthis, GlobalContext* globalCtx) { + f32 yDistToLogSpot; + + if (pthis->skelAnime.curFrame == 6.0f) { + pthis->skelAnime.playSpeed = 0.0f; + } else if (pthis->skelAnime.curFrame == 3.0f) { + pthis->actor.gravity = -10.0f; + pthis->actor.velocity.y = 25.0f; + if (pthis->isJumpingToFrogSong) { + pthis->isJumpingToFrogSong = false; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_EAT); + } + } + + if (EnFr_IsBelowLogSpot(pthis, &yDistToLogSpot)) { + pthis->isJumpingUp = false; + pthis->actor.gravity = 0.0f; + Animation_Change(&pthis->skelAnime, &object_fr_Anim_0011C0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_fr_Anim_0011C0), ANIMMODE_LOOP, 0.0f); + pthis->actionFunc = EnFr_ChooseJumpFromLogSpot; + } else if ((pthis->actor.velocity.y <= 0.0f) && (yDistToLogSpot < 40.0f)) { + pthis->skelAnime.playSpeed = 1.0f; + } +} + +void EnFr_JumpingBackIntoWater(EnFr* pthis, GlobalContext* globalCtx) { + f32 yUnderwater = sLogSpotToFromWater[pthis->actor.params].yDist + pthis->posLogSpot.y; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 2, 10000, 100); + if (pthis->skelAnime.curFrame == 6.0f) { + pthis->skelAnime.playSpeed = 0.0f; + } else if (pthis->skelAnime.curFrame == 3.0f) { + pthis->actor.speedXZ = 6.0f; + pthis->actor.gravity = -10.0f; + pthis->actor.velocity.y = 25.0f; + } + + // Final Spot Reached + if ((pthis->actor.velocity.y < 0.0f) && (pthis->actor.world.pos.y < yUnderwater)) { + Animation_Change(&pthis->skelAnime, &object_fr_Anim_001534, 1.0f, 0.0f, + Animation_GetLastFrame(&object_fr_Anim_001534), ANIMMODE_LOOP, 0.0f); + pthis->actionFunc = EnFr_SetupJumpingOutOfWater; + EnFr_DrawIdle(pthis); + pthis->isDeactivating = true; + EnFr_OrientUnderwater(pthis); + } +} + +void EnFr_SetScaleActive(EnFr* pthis, GlobalContext* globalCtx) { + switch (pthis->isGrowing) { + case false: + Math_ApproachF(&pthis->scale, sGrowingScale[pthis->growingScaleIndex], 2.0f, 25.0f); + if (pthis->scale >= sGrowingScale[pthis->growingScaleIndex]) { + pthis->scale = sGrowingScale[pthis->growingScaleIndex]; + if (pthis->growingScaleIndex < 3) { + pthis->isGrowing = true; + } else { + pthis->isJumpingUp = false; + pthis->isActive = false; + } + } + break; + case true: + Math_ApproachF(&pthis->scale, 150.0f, 2.0f, 25.0f); + if (pthis->scale <= 150.0f) { + pthis->scale = 150.0f; + pthis->growingScaleIndex++; + if (pthis->growingScaleIndex >= 4) { + pthis->growingScaleIndex = 3; + } + pthis->isGrowing = false; + } + break; + } +} + +void EnFr_ButterflyPath(EnFr* pthis, GlobalContext* globalCtx) { + s16 rotY = pthis->actor.shape.rot.y; + f32 sin; + Vec3f vec1; + Vec3f vec2; + + pthis->xyAngleButterfly += 0x1000; + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, pthis->actor.world.rot.z, MTXMODE_APPLY); + vec1.x = vec1.y = 0.0f; + vec1.z = 25.0f; + Matrix_MultVec3f(&vec1, &vec2); + sin = Math_SinS(pthis->xyAngleButterfly * 2) * 5.0f; + pthis->posButterfly.x = (Math_SinS(rotY) * sin) + vec2.x; + pthis->posButterfly.y = (2.0f * Math_CosS(pthis->xyAngleButterfly)) + (pthis->posLogSpot.y + 50.0f); + pthis->posButterfly.z = (Math_CosS(rotY) * sin) + vec2.z; + Matrix_Translate(pthis->posButterfly.x, pthis->posButterfly.y, pthis->posButterfly.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, pthis->actor.world.rot.z, MTXMODE_APPLY); + vec1.x = 0.0f; + vec1.y = -15.0f; + vec1.z = 20.0f; + Matrix_MultVec3f(&vec1, &pthis->posButterflyLight); +} + +void EnFr_UpdateActive(Actor* thisx, GlobalContext* globalCtx) { + EnFr* pthis = (EnFr*)thisx; + + pthis->jumpCounter++; + Actor_SetScale(&pthis->actor, pthis->scale * 0.0001f); + + if (pthis->isActive) { + EnFr_SetScaleActive(pthis, globalCtx); + } else { + Actor_SetFocus(&pthis->actor, 10.0f); + pthis->blinkFunc(pthis); + pthis->actionFunc(pthis, globalCtx); + EnFr_IsDivingIntoWater(pthis, globalCtx); + EnFr_DivingIntoWater(pthis, globalCtx); + SkelAnime_Update(&pthis->skelAnime); + SkelAnime_Update(&pthis->skelAnimeButterfly); + EnFr_ButterflyPath(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + } +} + +s32 EnFr_SetupJumpingUp(EnFr* pthis, s32 frogIndex) { + EnFr* frog = sEnFrPointers.frogs[frogIndex]; + u8 semitone; + + if (frog != NULL && frog->isJumpingUp == false) { + semitone = frog->growingScaleIndex == 3 ? sLargeFrogNotes[frogIndex] : sSmallFrogNotes[frogIndex]; + if (pthis->songIndex == FROG_CHOIR_SONG) { + frog->isJumpingToFrogSong = true; + } + frog->isJumpingUp = true; + Audio_PlaySoundTransposed(&frog->actor.projectedPos, NA_SE_EV_FROG_JUMP, semitone); + return true; + } else { + return false; + } +} + +void EnFr_Idle(EnFr* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->stateFlags2 & 0x2000000) { + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; + } + + OnePointCutscene_Init(globalCtx, 4110, ~0x62, &pthis->actor, MAIN_CAM); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + player->actor.world.pos.x = pthis->actor.world.pos.x; // x = 990.0f + player->actor.world.pos.y = pthis->actor.world.pos.y; // y = 205.0f + player->actor.world.pos.z = pthis->actor.world.pos.z; // z = -1220.0f + player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->reward = GI_NONE; + pthis->actionFunc = EnFr_Activate; + } else if (EnFr_IsAboveAndWithin30DistXZ(player, pthis)) { + player->unk_6A8 = &pthis->actor; + } +} + +void EnFr_Activate(EnFr* pthis, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_PLAYING) { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + sEnFrPointers.flags = 1; + pthis->actionFunc = EnFr_ActivateCheckFrogSong; + } else if (globalCtx->msgCtx.msgMode == MSGMODE_PAUSED) { // Goes to Frogs 2 Song + sEnFrPointers.flags = 1; + pthis->actionFunc = EnFr_ActivateCheckFrogSong; + } +} + +void EnFr_ActivateCheckFrogSong(EnFr* pthis, GlobalContext* globalCtx) { + if (sEnFrPointers.flags == 11) { + // Check if all 6 child songs have been played for the frogs + if ((gSaveContext.eventChkInf[13] & 0x2) // ZL + && (gSaveContext.eventChkInf[13] & 0x4) // Epona + && (gSaveContext.eventChkInf[13] & 0x10) // Saria + && (gSaveContext.eventChkInf[13] & 0x8) // Suns + && (gSaveContext.eventChkInf[13] & 0x20) // SoT + && (gSaveContext.eventChkInf[13] & 0x40)) { // SoS + pthis->actionFunc = EnFr_TalkBeforeFrogSong; + pthis->songIndex = FROG_CHOIR_SONG; + Message_StartTextbox(globalCtx, 0x40AB, &pthis->actor); + } else { + pthis->songIndex = FROG_ZL; + pthis->actionFunc = func_80A1BE98; + } + } +} + +void func_80A1BE98(EnFr* pthis, GlobalContext* globalCtx) { + EnFr* frog; + s32 frogIndex; + + for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { + frog = sEnFrPointers.frogs[frogIndex]; + if (frog != NULL && frog->actionFunc == EnFr_ChooseJumpFromLogSpot) { + continue; + } else { + return; + } + } + + func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_NOWARP); + pthis->actionFunc = EnFr_ListeningToOcarinaNotes; +} + +void EnFr_ListeningToOcarinaNotes(EnFr* pthis, GlobalContext* globalCtx) { + pthis->songIndex = FROG_NO_SONG; + switch (globalCtx->msgCtx.ocarinaMode) { // Ocarina Song played + case OCARINA_MODE_07: + pthis->songIndex = FROG_ZL; + break; + case OCARINA_MODE_06: + pthis->songIndex = FROG_EPONA; + break; + case OCARINA_MODE_05: + pthis->songIndex = FROG_SARIA; + break; + case OCARINA_MODE_08: + pthis->songIndex = FROG_SUNS; + break; + case OCARINA_MODE_09: + pthis->songIndex = FROG_SOT; + break; + case OCARINA_MODE_0A: + pthis->songIndex = FROG_STORMS; + break; + case OCARINA_MODE_04: + EnFr_OcarinaMistake(pthis, globalCtx); + break; + case OCARINA_MODE_01: // Ocarina note played, but no song played + switch (globalCtx->msgCtx.lastOcaNoteIdx) { // Jumping frogs in open ocarina based on ocarina note played + case OCARINA_NOTE_A: + EnFr_SetupJumpingUp(pthis, FROG_BLUE); + break; + case OCARINA_NOTE_C_DOWN: + EnFr_SetupJumpingUp(pthis, FROG_YELLOW); + break; + case OCARINA_NOTE_C_RIGHT: + EnFr_SetupJumpingUp(pthis, FROG_RED); + break; + case OCARINA_NOTE_C_LEFT: + EnFr_SetupJumpingUp(pthis, FROG_PURPLE); + break; + case OCARINA_NOTE_C_UP: + EnFr_SetupJumpingUp(pthis, FROG_WHITE); + break; + } + } + if (pthis->songIndex != FROG_NO_SONG) { + pthis->jumpCounter = 0; + pthis->actionFunc = EnFr_ChildSong; + } +} + +void EnFr_ChildSong(EnFr* pthis, GlobalContext* globalCtx) { + EnFr* frog; + u8 songIndex; + + if (pthis->jumpCounter < 48) { + if (pthis->jumpCounter % 4 == 0) { + EnFr_SetupJumpingUp(pthis, sJumpOrder[(pthis->jumpCounter >> 2) & 7]); + } + } else { + songIndex = pthis->songIndex; + if (songIndex == FROG_STORMS) { + pthis->actor.textId = 0x40AA; + EnFr_SetupReward(pthis, globalCtx, false); + } else if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { + frog = sEnFrPointers.frogs[sSongToFrog[songIndex]]; + func_80078884(NA_SE_SY_CORRECT_CHIME); + if (frog->actionFunc == EnFr_ChooseJumpFromLogSpot) { + frog->isJumpingUp = true; + frog->isActive = true; + Audio_PlayActorSound2(&frog->actor, NA_SE_EV_FROG_GROW_UP); + pthis->actionFunc = EnFr_ChildSongFirstTime; + } else { + pthis->jumpCounter = 48; + } + } else { + pthis->actor.textId = 0x40A9; + EnFr_SetupReward(pthis, globalCtx, true); + } + } +} + +void EnFr_ChildSongFirstTime(EnFr* pthis, GlobalContext* globalCtx) { + EnFr* frog = sEnFrPointers.frogs[sSongToFrog[pthis->songIndex]]; + + if (frog->isActive == false) { + pthis->actor.textId = 0x40A9; + EnFr_SetupReward(pthis, globalCtx, true); + } +} + +void EnFr_TalkBeforeFrogSong(EnFr* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->frogSongTimer = 2; + pthis->actionFunc = EnFr_SetupFrogSong; + } +} + +void EnFr_CheckOcarinaInputFrogSong(u8 ocarinaNote) { + EnFr* frog; + s32 frogIndexButterfly; + s32 frogIndex; + + switch (ocarinaNote) { + case 0: + frogIndexButterfly = FROG_BLUE; + break; + case 1: + frogIndexButterfly = FROG_YELLOW; + break; + case 2: + frogIndexButterfly = FROG_RED; + break; + case 3: + frogIndexButterfly = FROG_PURPLE; + break; + case 4: + frogIndexButterfly = FROG_WHITE; + } + // Turn on or off butterfly above frog + for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { + frog = sEnFrPointers.frogs[frogIndex]; + frog->isButterflyDrawn = frogIndex == frogIndexButterfly ? true : false; + } +} + +void EnFr_DeactivateButterfly() { + s32 frogIndex; + EnFr* frog; + + for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { + frog = sEnFrPointers.frogs[frogIndex]; + frog->isButterflyDrawn = false; + } +} + +u8 EnFr_GetNextNoteFrogSong(u8 ocarinaNoteIndex) { + if (!(gSaveContext.eventChkInf[13] & 1)) { + return gFrogsSongPtr[ocarinaNoteIndex]; + } else { + return sOcarinaNotes[(s32)Rand_ZeroFloat(60.0f) % 5]; + } +} + +void EnFr_SetupFrogSong(EnFr* pthis, GlobalContext* globalCtx) { + if (pthis->frogSongTimer != 0) { + pthis->frogSongTimer--; + } else { + pthis->frogSongTimer = 40; + pthis->ocarinaNoteIndex = 0; + func_8010BD58(globalCtx, OCARINA_ACTION_FROGS); + pthis->ocarinaNote = EnFr_GetNextNoteFrogSong(pthis->ocarinaNoteIndex); + EnFr_CheckOcarinaInputFrogSong(pthis->ocarinaNote); + pthis->actionFunc = EnFr_ContinueFrogSong; + } +} + +s32 EnFr_IsFrogSongComplete(EnFr* pthis, GlobalContext* globalCtx) { + u8 index; + u8 ocarinaNote; + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 ocarinaNoteIndex; + + if (pthis->ocarinaNote == (*msgCtx).lastOcaNoteIdx) { // required to match, possibly an array? + pthis->ocarinaNoteIndex++; + ocarinaNoteIndex = pthis->ocarinaNoteIndex; + if (1) {} + if (ocarinaNoteIndex >= 14) { // Frog Song is completed + pthis->ocarinaNoteIndex = 13; + return true; + } + // The first four notes have more frames to receive an input + index = ocarinaNoteIndex < 4 ? (s32)ocarinaNoteIndex : 4; + ocarinaNote = EnFr_GetNextNoteFrogSong(ocarinaNoteIndex); + pthis->ocarinaNote = ocarinaNote; + EnFr_CheckOcarinaInputFrogSong(ocarinaNote); + pthis->frogSongTimer = sTimerFrogSong[index]; + } + return false; +} + +void EnFr_OcarinaMistake(EnFr* pthis, GlobalContext* globalCtx) { + Message_CloseTextbox(globalCtx); + pthis->reward = GI_NONE; + func_80078884(NA_SE_SY_OCARINA_ERROR); + Audio_OcaSetInstrument(0); + sEnFrPointers.flags = 12; + EnFr_DeactivateButterfly(); + pthis->actionFunc = EnFr_Deactivate; +} + +void EnFr_ContinueFrogSong(EnFr* pthis, GlobalContext* globalCtx) { + s32 counter; + EnFr* frog; + s32 i; + + if (pthis->frogSongTimer == 0) { + EnFr_OcarinaMistake(pthis, globalCtx); + } else { + pthis->frogSongTimer--; + if (globalCtx->msgCtx.msgMode == MSGMODE_FROGS_PLAYING) { + counter = 0; + for (i = 0; i < ARRAY_COUNT(sEnFrPointers.frogs); i++) { + frog = sEnFrPointers.frogs[i]; + if (frog != NULL && frog->actionFunc == EnFr_ChooseJumpFromLogSpot) { + continue; + } else { + counter++; + } + } + if (counter == 0 && CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B)) { + EnFr_OcarinaMistake(pthis, globalCtx); + return; + } + } + + if (globalCtx->msgCtx.msgMode == MSGMODE_FROGS_WAITING) { + globalCtx->msgCtx.msgMode = MSGMODE_FROGS_START; + switch (globalCtx->msgCtx.lastOcaNoteIdx) { + case OCARINA_NOTE_A: + EnFr_SetupJumpingUp(pthis, FROG_BLUE); + break; + case OCARINA_NOTE_C_DOWN: + EnFr_SetupJumpingUp(pthis, FROG_YELLOW); + break; + case OCARINA_NOTE_C_RIGHT: + EnFr_SetupJumpingUp(pthis, FROG_RED); + break; + case OCARINA_NOTE_C_LEFT: + EnFr_SetupJumpingUp(pthis, FROG_PURPLE); + break; + case OCARINA_NOTE_C_UP: + EnFr_SetupJumpingUp(pthis, FROG_WHITE); + } + if (EnFr_IsFrogSongComplete(pthis, globalCtx)) { + pthis->actor.textId = 0x40AC; + EnFr_SetupReward(pthis, globalCtx, false); + } + } + } +} + +void EnFr_SetupReward(EnFr* pthis, GlobalContext* globalCtx, u8 unkCondition) { + EnFr_DeactivateButterfly(); + if (unkCondition) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } else { + func_80078884(NA_SE_SY_CORRECT_CHIME); + } + + Audio_OcaSetInstrument(0); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->actionFunc = EnFr_PrintTextBox; +} + +void EnFr_PrintTextBox(EnFr* pthis, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, pthis->actor.textId, &pthis->actor); + pthis->actionFunc = EnFr_TalkBeforeReward; +} + +void EnFr_TalkBeforeReward(EnFr* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->frogSongTimer = 100; + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnFr_SetReward; + } +} + +void EnFr_SetReward(EnFr* pthis, GlobalContext* globalCtx) { + u16 songIndex; + + sEnFrPointers.flags = 12; + songIndex = pthis->songIndex; + pthis->actionFunc = EnFr_Deactivate; + pthis->reward = GI_NONE; + if ((songIndex >= FROG_ZL) && (songIndex <= FROG_SOT)) { + if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { + gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; + pthis->reward = GI_RUPEE_PURPLE; + } else { + pthis->reward = GI_RUPEE_BLUE; + } + } else if (songIndex == FROG_STORMS) { + if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { + gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; + pthis->reward = GI_HEART_PIECE; + } else { + pthis->reward = GI_RUPEE_BLUE; + } + } else if (songIndex == FROG_CHOIR_SONG) { + if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { + gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; + pthis->reward = GI_HEART_PIECE; + } else { + pthis->reward = GI_RUPEE_PURPLE; + } + } +} + +void EnFr_Deactivate(EnFr* pthis, GlobalContext* globalCtx) { + EnFr* frogLoop1; + EnFr* frogLoop2; + s32 frogIndex; + + // Originally was going to have separate butterfly actor + // Changed to include butterfly as part of frog actor + // This unused code would have frozen the butterfly actor above frog + if (pthis->unusedButterflyActor != NULL) { + pthis->unusedButterflyActor->freezeTimer = 10; + } + + for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { + frogLoop1 = sEnFrPointers.frogs[frogIndex]; + if (frogLoop1 == NULL) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "There are no frogs!?" + osSyncPrintf("%s[%d]カエルがいない!?\n", "../z_en_fr.c", 1604); + osSyncPrintf(VT_RST); + return; + } else if (frogLoop1->isDeactivating != true) { + return; + } + } + + for (frogIndex = 0; frogIndex < ARRAY_COUNT(sEnFrPointers.frogs); frogIndex++) { + frogLoop2 = sEnFrPointers.frogs[frogIndex]; + if (frogLoop2 == NULL) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "There are no frogs!?" + osSyncPrintf("%s[%d]カエルがいない!?\n", "../z_en_fr.c", 1618); + osSyncPrintf(VT_RST); + return; + } + frogLoop2->isDeactivating = false; + } + + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FROG_CRY_0); + if (pthis->reward == GI_NONE) { + pthis->actionFunc = EnFr_Idle; + } else { + pthis->actionFunc = EnFr_GiveReward; + func_8002F434(&pthis->actor, globalCtx, pthis->reward, 30.0f, 100.0f); + } +} + +void EnFr_GiveReward(EnFr* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnFr_SetIdle; + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->reward, 30.0f, 100.0f); + } +} + +void EnFr_SetIdle(EnFr* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + pthis->actionFunc = EnFr_Idle; + } +} + +void EnFr_UpdateIdle(Actor* thisx, GlobalContext* globalCtx) { + EnFr* pthis = (EnFr*)thisx; + + pthis->jumpCounter++; + pthis->actionFunc(pthis, globalCtx); +} + +s32 EnFr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + if ((limbIndex == 7) || (limbIndex == 8)) { + *dList = NULL; + } + return 0; +} + +void EnFr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnFr* pthis = (EnFr*)thisx; + + if ((limbIndex == 7) || (limbIndex == 8)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1735); + Matrix_Push(); + func_800D1FD4(&globalCtx->billboardMtxF); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fr.c", 1738), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1741); + } +} + +void EnFr_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { + object_fr_Tex_0059A0, + object_fr_Tex_005BA0, + }; + s16 lightRadius; + EnFr* pthis = (EnFr*)thisx; + s16 frogIndex = pthis->actor.params - 1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1754); + func_80093D18(globalCtx->state.gfxCtx); + // For the frogs 2 HP, the frog with the next note and the butterfly lights up + lightRadius = pthis->isButterflyDrawn ? 95 : -1; + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->posButterflyLight.x, pthis->posButterflyLight.y, + pthis->posButterflyLight.z, 255, 255, 255, lightRadius); + gDPSetEnvColor(POLY_OPA_DISP++, sEnFrColor[frogIndex].r, sEnFrColor[frogIndex].g, sEnFrColor[frogIndex].b, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnFr_OverrideLimbDraw, EnFr_PostLimbDraw, pthis); + if (pthis->isButterflyDrawn) { + Matrix_Translate(pthis->posButterfly.x, pthis->posButterfly.y, pthis->posButterfly.z, MTXMODE_NEW); + Matrix_Scale(0.015f, 0.015f, 0.015f, MTXMODE_APPLY); + Matrix_RotateZYX(pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, MTXMODE_APPLY); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnimeButterfly.skeleton, pthis->skelAnimeButterfly.jointTable, NULL, NULL, + NULL); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fr.c", 1816); +} diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.cpp similarity index 51% rename from src/overlays/actors/ovl_En_Fu/z_en_fu.c rename to src/overlays/actors/ovl_En_Fu/z_en_fu.cpp index 7704286f6..6bb0e6f7a 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.cpp @@ -31,17 +31,17 @@ void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFu_Update(Actor* thisx, GlobalContext* globalCtx); void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFu_WaitChild(EnFu* this, GlobalContext* globalCtx); -void func_80A1DA04(EnFu* this, GlobalContext* globalCtx); +void EnFu_WaitChild(EnFu* pthis, GlobalContext* globalCtx); +void func_80A1DA04(EnFu* pthis, GlobalContext* globalCtx); -void EnFu_WaitAdult(EnFu* this, GlobalContext* globalCtx); -void EnFu_TeachSong(EnFu* this, GlobalContext* globalCtx); -void EnFu_WaitForPlayback(EnFu* this, GlobalContext* globalCtx); -void func_80A1DBA0(EnFu* this, GlobalContext* globalCtx); -void func_80A1DBD4(EnFu* this, GlobalContext* globalCtx); -void func_80A1DB60(EnFu* this, GlobalContext* globalCtx); +void EnFu_WaitAdult(EnFu* pthis, GlobalContext* globalCtx); +void EnFu_TeachSong(EnFu* pthis, GlobalContext* globalCtx); +void EnFu_WaitForPlayback(EnFu* pthis, GlobalContext* globalCtx); +void func_80A1DBA0(EnFu* pthis, GlobalContext* globalCtx); +void func_80A1DBD4(EnFu* pthis, GlobalContext* globalCtx); +void func_80A1DB60(EnFu* pthis, GlobalContext* globalCtx); -const ActorInit En_Fu_InitVars = { +ActorInit En_Fu_InitVars = { ACTOR_EN_FU, ACTORCAT_NPC, FLAGS, @@ -86,64 +86,64 @@ typedef enum { void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnFu* this = (EnFu*)thisx; + EnFu* pthis = (EnFu*)thisx; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelanime, &gWindmillManSkel, &gWindmillManPlayStillAnim, this->jointTable, - this->morphTable, FU_LIMB_MAX); - Animation_PlayLoop(&this->skelanime, &gWindmillManPlayStillAnim); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelanime, &gWindmillManSkel, &gWindmillManPlayStillAnim, pthis->jointTable, + pthis->morphTable, FU_LIMB_MAX); + Animation_PlayLoop(&pthis->skelanime, &gWindmillManPlayStillAnim); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); if (!LINK_IS_ADULT) { - this->actionFunc = EnFu_WaitChild; - this->facialExpression = FU_FACE_CALM; + pthis->actionFunc = EnFu_WaitChild; + pthis->facialExpression = FU_FACE_CALM; } else { - this->actionFunc = EnFu_WaitAdult; - this->facialExpression = FU_FACE_MAD; - this->skelanime.playSpeed = 2.0f; + pthis->actionFunc = EnFu_WaitAdult; + pthis->facialExpression = FU_FACE_MAD; + pthis->skelanime.playSpeed = 2.0f; } - this->behaviorFlags = 0; - this->actor.targetMode = 6; + pthis->behaviorFlags = 0; + pthis->actor.targetMode = 6; } void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFu* this = (EnFu*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + EnFu* pthis = (EnFu*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 func_80A1D94C(EnFu* this, GlobalContext* globalCtx, u16 textID, EnFuActionFunc actionFunc) { +s32 func_80A1D94C(EnFu* pthis, GlobalContext* globalCtx, u16 textID, EnFuActionFunc actionFunc) { s16 yawDiff; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = actionFunc; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = actionFunc; return true; } - this->actor.textId = textID; - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + pthis->actor.textId = textID; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; - if ((ABS(yawDiff) < 0x2301) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); + if ((ABS(yawDiff) < 0x2301) && (pthis->actor.xzDistToPlayer < 100.0f)) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); } else { - this->behaviorFlags |= FU_RESET_LOOK_ANGLE; + pthis->behaviorFlags |= FU_RESET_LOOK_ANGLE; } return false; } -void func_80A1DA04(EnFu* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->behaviorFlags &= ~FU_WAIT; - this->actionFunc = EnFu_WaitChild; +void func_80A1DA04(EnFu* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->behaviorFlags &= ~FU_WAIT; + pthis->actionFunc = EnFu_WaitChild; - if (this->skelanime.animation == &gWindmillManPlayAndMoveHeadAnim) { - Animation_Change(&this->skelanime, &gWindmillManPlayStillAnim, 1.0f, 0.0f, + if (pthis->skelanime.animation == &gWindmillManPlayAndMoveHeadAnim) { + Animation_Change(&pthis->skelanime, &gWindmillManPlayStillAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gWindmillManPlayStillAnim), ANIMMODE_ONCE, -4.0f); } } } -void EnFu_WaitChild(EnFu* this, GlobalContext* globalCtx) { +void EnFu_WaitChild(EnFu* pthis, GlobalContext* globalCtx) { u16 textID = Text_GetFaceReaction(globalCtx, 0xB); if (textID == 0) { @@ -152,39 +152,39 @@ void EnFu_WaitChild(EnFu* this, GlobalContext* globalCtx) { // if ACTOR_FLAG_8 is set and textID is 0x5033, change animation // if func_80A1D94C returns 1, actionFunc is set to func_80A1DA04 - if (func_80A1D94C(this, globalCtx, textID, func_80A1DA04)) { + if (func_80A1D94C(pthis, globalCtx, textID, func_80A1DA04)) { if (textID == 0x5033) { - Animation_Change(&this->skelanime, &gWindmillManPlayAndMoveHeadAnim, 1.0f, 0.0f, + Animation_Change(&pthis->skelanime, &gWindmillManPlayAndMoveHeadAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gWindmillManPlayAndMoveHeadAnim), ANIMMODE_ONCE, -4.0f); } } } -void func_80A1DB60(EnFu* this, GlobalContext* globalCtx) { +void func_80A1DB60(EnFu* pthis, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == CS_STATE_IDLE) { - this->actionFunc = EnFu_WaitAdult; + pthis->actionFunc = EnFu_WaitAdult; gSaveContext.eventChkInf[5] |= 0x800; globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } } -void func_80A1DBA0(EnFu* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnFu_WaitAdult; +void func_80A1DBA0(EnFu* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnFu_WaitAdult; } } -void func_80A1DBD4(EnFu* this, GlobalContext* globalCtx) { +void func_80A1DBD4(EnFu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_04) { - this->actionFunc = EnFu_WaitAdult; + pthis->actionFunc = EnFu_WaitAdult; globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - this->actor.flags &= ~ACTOR_FLAG_16; + pthis->actor.flags &= ~ACTOR_FLAG_16; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { func_80078884(NA_SE_SY_CORRECT_CHIME); - this->actionFunc = func_80A1DB60; - this->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = func_80A1DB60; + pthis->actor.flags &= ~ACTOR_FLAG_16; globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gSongOfStormsCs); gSaveContext.cutsceneTrigger = 1; Item_Give(globalCtx, ITEM_SONG_STORMS); @@ -192,54 +192,54 @@ void func_80A1DBD4(EnFu* this, GlobalContext* globalCtx) { gSaveContext.eventChkInf[6] |= 0x20; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_02) { player->stateFlags2 &= ~0x1000000; - this->actionFunc = EnFu_WaitAdult; + pthis->actionFunc = EnFu_WaitAdult; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { player->stateFlags2 |= 0x800000; } } -void EnFu_WaitForPlayback(EnFu* this, GlobalContext* globalCtx) { +void EnFu_WaitForPlayback(EnFu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); player->stateFlags2 |= 0x800000; // if dialog state is 7, player has played back the song if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_SONG_DEMO_DONE) { func_8010BD58(globalCtx, OCARINA_ACTION_PLAYBACK_STORMS); - this->actionFunc = func_80A1DBD4; + pthis->actionFunc = func_80A1DBD4; } } -void EnFu_TeachSong(EnFu* this, GlobalContext* globalCtx) { +void EnFu_TeachSong(EnFu* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); player->stateFlags2 |= 0x800000; // if dialog state is 2, start song demonstration if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->behaviorFlags &= ~FU_WAIT; + pthis->behaviorFlags &= ~FU_WAIT; Audio_OcaSetInstrument(4); // seems to be related to setting instrument type func_8010BD58(globalCtx, OCARINA_ACTION_TEACH_STORMS); - this->actionFunc = EnFu_WaitForPlayback; + pthis->actionFunc = EnFu_WaitForPlayback; } } -void EnFu_WaitAdult(EnFu* this, GlobalContext* globalCtx) { +void EnFu_WaitAdult(EnFu* pthis, GlobalContext* globalCtx) { static s16 yawDiff; Player* player = GET_PLAYER(globalCtx); - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; if ((gSaveContext.eventChkInf[5] & 0x800)) { - func_80A1D94C(this, globalCtx, 0x508E, func_80A1DBA0); + func_80A1D94C(pthis, globalCtx, 0x508E, func_80A1DBA0); } else if (player->stateFlags2 & 0x1000000) { - this->actor.textId = 0x5035; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->actionFunc = EnFu_TeachSong; - this->behaviorFlags |= FU_WAIT; - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_80A1DBA0; + pthis->actor.textId = 0x5035; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->actionFunc = EnFu_TeachSong; + pthis->behaviorFlags |= FU_WAIT; + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80A1DBA0; } else if (ABS(yawDiff) < 0x2301) { - if (this->actor.xzDistToPlayer < 100.0f) { - this->actor.textId = 0x5034; - func_8002F2CC(&this->actor, globalCtx, 100.0f); + if (pthis->actor.xzDistToPlayer < 100.0f) { + pthis->actor.textId = 0x5034; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); player->stateFlags2 |= 0x800000; } } @@ -247,30 +247,30 @@ void EnFu_WaitAdult(EnFu* this, GlobalContext* globalCtx) { void EnFu_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnFu* this = (EnFu*)thisx; + EnFu* pthis = (EnFu*)thisx; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if ((!(this->behaviorFlags & FU_WAIT)) && (SkelAnime_Update(&this->skelanime) != 0)) { - Animation_Change(&this->skelanime, this->skelanime.animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->skelanime.animation), ANIMMODE_ONCE, 0.0f); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if ((!(pthis->behaviorFlags & FU_WAIT)) && (SkelAnime_Update(&pthis->skelanime) != 0)) { + Animation_Change(&pthis->skelanime, (AnimationHeader*)pthis->skelanime.animation, 1.0f, 0.0f, + Animation_GetLastFrame(pthis->skelanime.animation), ANIMMODE_ONCE, 0.0f); } - this->actionFunc(this, globalCtx); - if ((this->behaviorFlags & FU_RESET_LOOK_ANGLE)) { - Math_SmoothStepToS(&this->lookAngleOffset.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->lookAngleOffset.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.y, 0, 6, 6200, 100); - this->behaviorFlags &= ~FU_RESET_LOOK_ANGLE; + pthis->actionFunc(pthis, globalCtx); + if ((pthis->behaviorFlags & FU_RESET_LOOK_ANGLE)) { + Math_SmoothStepToS(&pthis->lookAngleOffset.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->lookAngleOffset.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.y, 0, 6, 6200, 100); + pthis->behaviorFlags &= ~FU_RESET_LOOK_ANGLE; } else { - func_80038290(globalCtx, &this->actor, &this->lookAngleOffset, &this->unk_2A2, this->actor.focus.pos); + func_80038290(globalCtx, &pthis->actor, &pthis->lookAngleOffset, &pthis->unk_2A2, pthis->actor.focus.pos); } } s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnFu* this = (EnFu*)thisx; + EnFu* pthis = (EnFu*)thisx; s32 pad; if (limbIndex == FU_LIMB_UNK) { @@ -278,14 +278,14 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } switch (limbIndex) { case FU_LIMB_HEAD: - rot->x += this->lookAngleOffset.y; - rot->z += this->lookAngleOffset.x; + rot->x += pthis->lookAngleOffset.y; + rot->z += pthis->lookAngleOffset.x; break; case FU_LIMB_CHEST_MUSIC_BOX: break; } - if (!(this->behaviorFlags & FU_WAIT)) { + if (!(pthis->behaviorFlags & FU_WAIT)) { return false; } @@ -297,10 +297,10 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnFu* this = (EnFu*)thisx; + EnFu* pthis = (EnFu*)thisx; if (limbIndex == FU_LIMB_HEAD) { - Matrix_MultVec3f(&sMtxSrc, &this->actor.focus.pos); + Matrix_MultVec3f(&sMtxSrc, &pthis->actor.focus.pos); } } @@ -308,15 +308,15 @@ void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { static void* sEyesSegments[] = { gWindmillManEyeClosedTex, gWindmillManEyeAngryTex }; static void* sMouthSegments[] = { gWindmillManMouthOpenTex, gWindmillManMouthAngryTex }; s32 pad; - EnFu* this = (EnFu*)thisx; + EnFu* pthis = (EnFu*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fu.c", 773); func_800943C8(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyesSegments[this->facialExpression])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthSegments[this->facialExpression])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, - EnFu_OverrideLimbDraw, EnFu_PostLimbDraw, this); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyesSegments[pthis->facialExpression])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthSegments[pthis->facialExpression])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, pthis->skelanime.dListCount, + EnFu_OverrideLimbDraw, EnFu_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fu.c", 791); } diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.c b/src/overlays/actors/ovl_En_Fw/z_en_fw.c deleted file mode 100644 index b03d4f3e0..000000000 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.c +++ /dev/null @@ -1,497 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FW_Z_EN_FW_C -#include "actor_common.h" -/* - * File: z_en_fw.c - * Overlay: ovl_En_Fw - * Description: Flare Dancer Core - */ - -#include "z_en_fw.h" -#include "objects/object_fw/object_fw.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9) - -void EnFw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFw_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFw_UpdateDust(EnFw* this); -void EnFw_DrawDust(EnFw* this, GlobalContext* globalCtx); -void EnFw_AddDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, - f32 scaleStep); -void EnFw_Bounce(EnFw* this, GlobalContext* globalCtx); -void EnFw_Run(EnFw* this, GlobalContext* globalCtx); -void EnFw_JumpToParentInitPos(EnFw* this, GlobalContext* globalCtx); -void EnFw_TurnToParentInitPos(EnFw* this, GlobalContext* globalCtx); - -const ActorInit En_Fw_InitVars = { - ACTOR_EN_FW, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_FW, - sizeof(EnFw), - (ActorFunc)EnFw_Init, - (ActorFunc)EnFw_Destroy, - (ActorFunc)EnFw_Update, - (ActorFunc)EnFw_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x04 }, - { 0xFFCFFFFE, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 2, { { 1200, 0, 0 }, 16 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit2 D_80A1FB94 = { 8, 2, 25, 25, MASS_IMMOVABLE }; - -static struct_80034EC0_Entry D_80A1FBA0[] = { - { &gFlareDancerCoreInitRunCycleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, 0.0f }, - { &gFlareDancerCoreRunCycleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, - { &gFlareDancerCoreEndRunCycleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, -}; - -s32 EnFw_DoBounce(EnFw* this, s32 totalBounces, f32 yVelocity) { - s16 temp_v1; - - if (!(this->actor.bgCheckFlags & 1) || (this->actor.velocity.y > 0.0f)) { - // not on the ground or moving upwards. - return false; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - this->bounceCnt--; - if (this->bounceCnt <= 0) { - if (this->bounceCnt == 0) { - this->bounceCnt = 0; - this->actor.velocity.y = 0.0f; - return true; - } - this->bounceCnt = totalBounces; - } - this->actor.velocity.y = yVelocity; - this->actor.velocity.y *= ((f32)this->bounceCnt / totalBounces); - return 1; -} - -s32 EnFw_PlayerInRange(EnFw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - CollisionPoly* poly; - s32 bgId; - Vec3f collisionPos; - - if (this->actor.xzDistToPlayer > 300.0f) { - return false; - } - - if (ABS((s16)((f32)this->actor.yawTowardsPlayer - (f32)this->actor.shape.rot.y)) > 0x1C70) { - return false; - } - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &player->actor.world.pos, &collisionPos, - &poly, true, false, false, true, &bgId)) { - return false; - } - - return true; -} - -Vec3f* EnFw_GetPosAdjAroundCircle(Vec3f* dst, EnFw* this, f32 radius, s16 dir) { - s16 angle; - Vec3f posAdj; - - // increase rotation around circle ~30 degrees. - angle = Math_Vec3f_Yaw(&this->actor.parent->home.pos, &this->actor.world.pos) + (dir * 0x1554); - posAdj.x = (Math_SinS(angle) * radius) + this->actor.parent->home.pos.x; - posAdj.z = (Math_CosS(angle) * radius) + this->actor.parent->home.pos.z; - posAdj.x -= this->actor.world.pos.x; - posAdj.z -= this->actor.world.pos.z; - *dst = posAdj; - return dst; -} - -s32 EnFw_CheckCollider(EnFw* this, GlobalContext* globalCtx) { - ColliderInfo* info; - s32 phi_return; - - if (this->collider.base.acFlags & AC_HIT) { - info = &this->collider.elements[0].info; - if (info->acHitInfo->toucher.dmgFlags & 0x80) { - this->lastDmgHook = true; - } else { - this->lastDmgHook = false; - } - this->collider.base.acFlags &= ~AC_HIT; - if (Actor_ApplyDamage(&this->actor) <= 0) { - if (this->actor.parent->colChkInfo.health <= 8) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.parent->colChkInfo.health = 0; - } else { - this->actor.parent->colChkInfo.health -= 8; - } - this->returnToParentTimer = 0; - } - return true; - } else { - return false; - } -} - -s32 EnFw_SpawnDust(EnFw* this, u8 timer, f32 scale, f32 scaleStep, s32 dustCnt, f32 radius, f32 xzAccel, f32 yAccel) { - Vec3f pos = { 0.0f, 0.0f, 0.0f }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - s16 angle; - s32 i; - - pos = this->actor.world.pos; - pos.y = this->actor.floorHeight + 2.0f; - angle = ((Rand_ZeroOne() - 0.5f) * 0x10000); - i = dustCnt; - while (i >= 0) { - accel.x = (Rand_ZeroOne() - 0.5f) * xzAccel; - accel.y = yAccel; - accel.z = (Rand_ZeroOne() - 0.5f) * xzAccel; - pos.x = (Math_SinS(angle) * radius) + this->actor.world.pos.x; - pos.z = (Math_CosS(angle) * radius) + this->actor.world.pos.z; - EnFw_AddDust(this, &pos, &velocity, &accel, timer, scale, scaleStep); - angle += (s16)(0x10000 / dustCnt); - i--; - } - return 0; -} - -void EnFw_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFw* this = (EnFw*)thisx; - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFlareDancerCoreSkel, NULL, this->jointTable, this->morphTable, - 11); - func_80034EC0(&this->skelAnime, D_80A1FBA0, 0); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->sphs); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x10), &D_80A1FB94); - Actor_SetScale(&this->actor, 0.01f); - this->runDirection = -this->actor.params; - this->actionFunc = EnFw_Bounce; - this->actor.gravity = -1.0f; -} - -void EnFw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFw* this = (EnFw*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnFw_Bounce(EnFw* this, GlobalContext* globalCtx) { - if (EnFw_DoBounce(this, 3, 8.0f) && this->bounceCnt == 0) { - this->returnToParentTimer = Rand_S16Offset(300, 150); - this->actionFunc = EnFw_Run; - } -} - -void EnFw_Run(EnFw* this, GlobalContext* globalCtx) { - f32 tmpAngle; - s16 phi_v0; - f32 facingDir; - EnBom* bomb; - Actor* flareDancer; - - Math_SmoothStepToF(&this->skelAnime.playSpeed, 1.0f, 0.1f, 1.0f, 0.0f); - if (this->skelAnime.animation == &gFlareDancerCoreInitRunCycleAnim) { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 0) { - this->runRadius = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.parent->world.pos); - func_80034EC0(&this->skelAnime, D_80A1FBA0, 2); - } - return; - } - - if (this->damageTimer == 0 && this->explosionTimer == 0 && EnFw_CheckCollider(this, globalCtx)) { - if (this->actor.parent->colChkInfo.health > 0) { - if (!this->lastDmgHook) { - this->actor.velocity.y = 6.0f; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_MAN_DAMAGE); - this->damageTimer = 20; - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_MAN_DAMAGE); - this->explosionTimer = 6; - } - this->actor.speedXZ = 0.0f; - } - - if (this->explosionTimer != 0) { - this->skelAnime.playSpeed = 0.0f; - Math_SmoothStepToF(&this->actor.scale.x, 0.024999999f, 0.08f, 0.6f, 0.0f); - Actor_SetScale(&this->actor, this->actor.scale.x); - if (this->actor.colorFilterTimer == 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, this->explosionTimer); - this->explosionTimer--; - } - - if (this->explosionTimer == 0) { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->bompPos.x, this->bompPos.y, - this->bompPos.z, 0, 0, 0x600, 0); - if (bomb != NULL) { - bomb->timer = 0; - } - flareDancer = this->actor.parent; - flareDancer->params |= 0x4000; - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0xA0); - Actor_Kill(&this->actor); - return; - } - } else { - if (!(this->actor.bgCheckFlags & 1) || this->actor.velocity.y > 0.0f) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, this->damageTimer); - return; - } - DECR(this->damageTimer); - if ((200.0f - this->runRadius) < 0.9f) { - if (DECR(this->returnToParentTimer) == 0) { - this->actor.speedXZ = 0.0f; - this->actionFunc = EnFw_TurnToParentInitPos; - return; - } - } - - // Run outwards until the radius of the run circle is 200 - Math_SmoothStepToF(&this->runRadius, 200.0f, 0.3f, 100.0f, 0.0f); - - if (this->turnAround) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); - tmpAngle = (s16)(this->actor.world.rot.y ^ 0x8000); - facingDir = this->actor.shape.rot.y; - tmpAngle = Math_SmoothStepToF(&facingDir, tmpAngle, 0.1f, 10000.0f, 0.0f); - this->actor.shape.rot.y = facingDir; - if (tmpAngle > 0x1554) { - return; - } - this->turnAround = false; - } else { - Vec3f sp48; - EnFw_GetPosAdjAroundCircle(&sp48, this, this->runRadius, this->runDirection); - Math_SmoothStepToS(&this->actor.shape.rot.y, (Math_FAtan2F(sp48.x, sp48.z) * (0x8000 / M_PI)), 4, 0xFA0, 1); - } - - this->actor.world.rot = this->actor.shape.rot; - - if (this->slideTimer == 0 && EnFw_PlayerInRange(this, globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_MAN_SURP); - this->slideSfxTimer = 8; - this->slideTimer = 8; - } - - if (this->slideTimer != 0) { - if (DECR(this->slideSfxTimer) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_MAN_SLIDE); - this->slideSfxTimer = 4; - } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); - this->skelAnime.playSpeed = 0.0f; - EnFw_SpawnDust(this, 8, 0.16f, 0.2f, 3, 8.0f, 20.0f, ((Rand_ZeroOne() - 0.5f) * 0.2f) + 0.3f); - this->slideTimer--; - if (this->slideTimer == 0) { - this->turnAround = true; - this->runDirection = -this->runDirection; - } - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.1f, 1.0f, 0.0f); - phi_v0 = this->skelAnime.curFrame; - if (phi_v0 == 1 || phi_v0 == 4) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_MAN_RUN); - EnFw_SpawnDust(this, 8, 0.16f, 0.1f, 1, 0.0f, 20.0f, 0.0f); - } - } - } -} - -void EnFw_TurnToParentInitPos(EnFw* this, GlobalContext* globalCtx) { - s16 angleToParentInit; - - angleToParentInit = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.parent->home.pos); - Math_SmoothStepToS(&this->actor.shape.rot.y, angleToParentInit, 4, 0xFA0, 1); - if (ABS(angleToParentInit - this->actor.shape.rot.y) < 0x65) { - // angle to parent init pos is ~0.5 degrees - this->actor.world.rot = this->actor.shape.rot; - this->actor.velocity.y = 14.0f; - this->actor.home.pos = this->actor.world.pos; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - func_80034EC0(&this->skelAnime, D_80A1FBA0, 1); - this->actionFunc = EnFw_JumpToParentInitPos; - } -} - -void EnFw_JumpToParentInitPos(EnFw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1 && this->actor.velocity.y <= 0.0f) { - this->actor.parent->params |= 0x8000; - Actor_Kill(&this->actor); - } else { - Math_SmoothStepToF(&this->actor.world.pos.x, this->actor.parent->home.pos.x, 0.6f, 8.0f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, this->actor.parent->home.pos.z, 0.6f, 8.0f, 0.0f); - } -} - -void EnFw_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFw* this = (EnFw*)thisx; - SkelAnime_Update(&this->skelAnime); - if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { - // not attached to hookshot. - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 20.0f, 0.0f, 5); - this->actionFunc(this, globalCtx); - if (this->damageTimer == 0 && this->explosionTimer == 0 && this->actionFunc == EnFw_Run) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -s32 EnFw_OverrideLimbDraw(GlobalContext* globalContext, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - return false; -} - -void EnFw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnFw* this = (EnFw*)thisx; - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - - if (limbIndex == 2) { - // body - Matrix_MultVec3f(&zeroVec, &this->bompPos); - } - - if (limbIndex == 3) { - // head - Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); - } - - Collider_UpdateSpheres(limbIndex, &this->collider); -} - -void EnFw_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnFw* this = (EnFw*)thisx; - - EnFw_UpdateDust(this); - Matrix_Push(); - EnFw_DrawDust(this, globalCtx); - Matrix_Pop(); - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnFw_OverrideLimbDraw, EnFw_PostLimbDraw, this); -} - -void EnFw_AddDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, - f32 scaleStep) { - EnFwEffect* eff = this->effects; - s16 i; - - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { - if (eff->type != 1) { - eff->scale = scale; - eff->scaleStep = scaleStep; - eff->initialTimer = eff->timer = initialTimer; - eff->type = 1; - eff->pos = *initialPos; - eff->accel = *accel; - eff->velocity = *initialSpeed; - return; - } - } -} - -void EnFw_UpdateDust(EnFw* this) { - EnFwEffect* eff = this->effects; - s16 i; - - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { - if (eff->type != 0) { - if ((--eff->timer) == 0) { - eff->type = 0; - } - eff->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; - eff->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; - eff->pos.x += eff->velocity.x; - eff->pos.y += eff->velocity.y; - eff->pos.z += eff->velocity.z; - eff->velocity.x += eff->accel.x; - eff->velocity.y += eff->accel.y; - eff->velocity.z += eff->accel.z; - eff->scale += eff->scaleStep; - } - } -} - -void EnFw_DrawDust(EnFw* this, GlobalContext* globalCtx) { - static void* dustTextures[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, - }; - EnFwEffect* eff = this->effects; - s16 firstDone; - s16 alpha; - s16 i; - s16 idx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fw.c", 1191); - - firstDone = false; - func_80093D84(globalCtx->state.gfxCtx); - if (1) {} - - for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { - if (eff->type != 0) { - if (!firstDone) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0U); - gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_7928); - gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); - firstDone = true; - } - - alpha = eff->timer * (255.0f / eff->initialTimer); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); - gDPPipeSync(POLY_XLU_DISP++); - Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fw.c", 1229), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - idx = eff->timer * (8.0f / eff->initialTimer); - gSPSegment(POLY_XLU_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(dustTextures[idx])); - gSPDisplayList(POLY_XLU_DISP++, gFlareDancerSquareParticleDL); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fw.c", 1243); -} diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.cpp b/src/overlays/actors/ovl_En_Fw/z_en_fw.cpp new file mode 100644 index 000000000..36ead6061 --- /dev/null +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.cpp @@ -0,0 +1,497 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FW_Z_EN_FW_C +#include "actor_common.h" +/* + * File: z_en_fw.c + * Overlay: ovl_En_Fw + * Description: Flare Dancer Core + */ + +#include "z_en_fw.h" +#include "objects/object_fw/object_fw.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9) + +void EnFw_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFw_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFw_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFw_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFw_UpdateDust(EnFw* pthis); +void EnFw_DrawDust(EnFw* pthis, GlobalContext* globalCtx); +void EnFw_AddDust(EnFw* pthis, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep); +void EnFw_Bounce(EnFw* pthis, GlobalContext* globalCtx); +void EnFw_Run(EnFw* pthis, GlobalContext* globalCtx); +void EnFw_JumpToParentInitPos(EnFw* pthis, GlobalContext* globalCtx); +void EnFw_TurnToParentInitPos(EnFw* pthis, GlobalContext* globalCtx); + +ActorInit En_Fw_InitVars = { + ACTOR_EN_FW, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_FW, + sizeof(EnFw), + (ActorFunc)EnFw_Init, + (ActorFunc)EnFw_Destroy, + (ActorFunc)EnFw_Update, + (ActorFunc)EnFw_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x04 }, + { 0xFFCFFFFE, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 2, { { 1200, 0, 0 }, 16 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit2 D_80A1FB94 = { 8, 2, 25, 25, MASS_IMMOVABLE }; + +static struct_80034EC0_Entry D_80A1FBA0[] = { + { &gFlareDancerCoreInitRunCycleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gFlareDancerCoreRunCycleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, + { &gFlareDancerCoreEndRunCycleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, +}; + +s32 EnFw_DoBounce(EnFw* pthis, s32 totalBounces, f32 yVelocity) { + s16 temp_v1; + + if (!(pthis->actor.bgCheckFlags & 1) || (pthis->actor.velocity.y > 0.0f)) { + // not on the ground or moving upwards. + return false; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + pthis->bounceCnt--; + if (pthis->bounceCnt <= 0) { + if (pthis->bounceCnt == 0) { + pthis->bounceCnt = 0; + pthis->actor.velocity.y = 0.0f; + return true; + } + pthis->bounceCnt = totalBounces; + } + pthis->actor.velocity.y = yVelocity; + pthis->actor.velocity.y *= ((f32)pthis->bounceCnt / totalBounces); + return 1; +} + +s32 EnFw_PlayerInRange(EnFw* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + CollisionPoly* poly; + s32 bgId; + Vec3f collisionPos; + + if (pthis->actor.xzDistToPlayer > 300.0f) { + return false; + } + + if (ABS((s16)((f32)pthis->actor.yawTowardsPlayer - (f32)pthis->actor.shape.rot.y)) > 0x1C70) { + return false; + } + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &player->actor.world.pos, &collisionPos, + &poly, true, false, false, true, &bgId)) { + return false; + } + + return true; +} + +Vec3f* EnFw_GetPosAdjAroundCircle(Vec3f* dst, EnFw* pthis, f32 radius, s16 dir) { + s16 angle; + Vec3f posAdj; + + // increase rotation around circle ~30 degrees. + angle = Math_Vec3f_Yaw(&pthis->actor.parent->home.pos, &pthis->actor.world.pos) + (dir * 0x1554); + posAdj.x = (Math_SinS(angle) * radius) + pthis->actor.parent->home.pos.x; + posAdj.z = (Math_CosS(angle) * radius) + pthis->actor.parent->home.pos.z; + posAdj.x -= pthis->actor.world.pos.x; + posAdj.z -= pthis->actor.world.pos.z; + *dst = posAdj; + return dst; +} + +s32 EnFw_CheckCollider(EnFw* pthis, GlobalContext* globalCtx) { + ColliderInfo* info; + s32 phi_return; + + if (pthis->collider.base.acFlags & AC_HIT) { + info = &pthis->collider.elements[0].info; + if (info->acHitInfo->toucher.dmgFlags & 0x80) { + pthis->lastDmgHook = true; + } else { + pthis->lastDmgHook = false; + } + pthis->collider.base.acFlags &= ~AC_HIT; + if (Actor_ApplyDamage(&pthis->actor) <= 0) { + if (pthis->actor.parent->colChkInfo.health <= 8) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.parent->colChkInfo.health = 0; + } else { + pthis->actor.parent->colChkInfo.health -= 8; + } + pthis->returnToParentTimer = 0; + } + return true; + } else { + return false; + } +} + +s32 EnFw_SpawnDust(EnFw* pthis, u8 timer, f32 scale, f32 scaleStep, s32 dustCnt, f32 radius, f32 xzAccel, f32 yAccel) { + Vec3f pos = { 0.0f, 0.0f, 0.0f }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + s16 angle; + s32 i; + + pos = pthis->actor.world.pos; + pos.y = pthis->actor.floorHeight + 2.0f; + angle = ((Rand_ZeroOne() - 0.5f) * 0x10000); + i = dustCnt; + while (i >= 0) { + accel.x = (Rand_ZeroOne() - 0.5f) * xzAccel; + accel.y = yAccel; + accel.z = (Rand_ZeroOne() - 0.5f) * xzAccel; + pos.x = (Math_SinS(angle) * radius) + pthis->actor.world.pos.x; + pos.z = (Math_CosS(angle) * radius) + pthis->actor.world.pos.z; + EnFw_AddDust(pthis, &pos, &velocity, &accel, timer, scale, scaleStep); + angle += (s16)(0x10000 / dustCnt); + i--; + } + return 0; +} + +void EnFw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFw* pthis = (EnFw*)thisx; + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFlareDancerCoreSkel, NULL, pthis->jointTable, pthis->morphTable, + 11); + func_80034EC0(&pthis->skelAnime, D_80A1FBA0, 0); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->sphs); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(0x10), &D_80A1FB94); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->runDirection = -pthis->actor.params; + pthis->actionFunc = EnFw_Bounce; + pthis->actor.gravity = -1.0f; +} + +void EnFw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFw* pthis = (EnFw*)thisx; + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnFw_Bounce(EnFw* pthis, GlobalContext* globalCtx) { + if (EnFw_DoBounce(pthis, 3, 8.0f) && pthis->bounceCnt == 0) { + pthis->returnToParentTimer = Rand_S16Offset(300, 150); + pthis->actionFunc = EnFw_Run; + } +} + +void EnFw_Run(EnFw* pthis, GlobalContext* globalCtx) { + f32 tmpAngle; + s16 phi_v0; + f32 facingDir; + EnBom* bomb; + Actor* flareDancer; + + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 1.0f, 0.1f, 1.0f, 0.0f); + if (pthis->skelAnime.animation == &gFlareDancerCoreInitRunCycleAnim) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame) == 0) { + pthis->runRadius = Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->actor.parent->world.pos); + func_80034EC0(&pthis->skelAnime, D_80A1FBA0, 2); + } + return; + } + + if (pthis->damageTimer == 0 && pthis->explosionTimer == 0 && EnFw_CheckCollider(pthis, globalCtx)) { + if (pthis->actor.parent->colChkInfo.health > 0) { + if (!pthis->lastDmgHook) { + pthis->actor.velocity.y = 6.0f; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_MAN_DAMAGE); + pthis->damageTimer = 20; + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_MAN_DAMAGE); + pthis->explosionTimer = 6; + } + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->explosionTimer != 0) { + pthis->skelAnime.playSpeed = 0.0f; + Math_SmoothStepToF(&pthis->actor.scale.x, 0.024999999f, 0.08f, 0.6f, 0.0f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + if (pthis->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0, pthis->explosionTimer); + pthis->explosionTimer--; + } + + if (pthis->explosionTimer == 0) { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->bompPos.x, pthis->bompPos.y, + pthis->bompPos.z, 0, 0, 0x600, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + flareDancer = pthis->actor.parent; + flareDancer->params |= 0x4000; + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, 0xA0); + Actor_Kill(&pthis->actor); + return; + } + } else { + if (!(pthis->actor.bgCheckFlags & 1) || pthis->actor.velocity.y > 0.0f) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0, pthis->damageTimer); + return; + } + DECR(pthis->damageTimer); + if ((200.0f - pthis->runRadius) < 0.9f) { + if (DECR(pthis->returnToParentTimer) == 0) { + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnFw_TurnToParentInitPos; + return; + } + } + + // Run outwards until the radius of the run circle is 200 + Math_SmoothStepToF(&pthis->runRadius, 200.0f, 0.3f, 100.0f, 0.0f); + + if (pthis->turnAround) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); + tmpAngle = (s16)(pthis->actor.world.rot.y ^ 0x8000); + facingDir = pthis->actor.shape.rot.y; + tmpAngle = Math_SmoothStepToF(&facingDir, tmpAngle, 0.1f, 10000.0f, 0.0f); + pthis->actor.shape.rot.y = facingDir; + if (tmpAngle > 0x1554) { + return; + } + pthis->turnAround = false; + } else { + Vec3f sp48; + EnFw_GetPosAdjAroundCircle(&sp48, pthis, pthis->runRadius, pthis->runDirection); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, (Math_FAtan2F(sp48.x, sp48.z) * (0x8000 / M_PI)), 4, 0xFA0, 1); + } + + pthis->actor.world.rot = pthis->actor.shape.rot; + + if (pthis->slideTimer == 0 && EnFw_PlayerInRange(pthis, globalCtx)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_MAN_SURP); + pthis->slideSfxTimer = 8; + pthis->slideTimer = 8; + } + + if (pthis->slideTimer != 0) { + if (DECR(pthis->slideSfxTimer) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_MAN_SLIDE); + pthis->slideSfxTimer = 4; + } + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); + pthis->skelAnime.playSpeed = 0.0f; + EnFw_SpawnDust(pthis, 8, 0.16f, 0.2f, 3, 8.0f, 20.0f, ((Rand_ZeroOne() - 0.5f) * 0.2f) + 0.3f); + pthis->slideTimer--; + if (pthis->slideTimer == 0) { + pthis->turnAround = true; + pthis->runDirection = -pthis->runDirection; + } + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 6.0f, 0.1f, 1.0f, 0.0f); + phi_v0 = pthis->skelAnime.curFrame; + if (phi_v0 == 1 || phi_v0 == 4) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FLAME_MAN_RUN); + EnFw_SpawnDust(pthis, 8, 0.16f, 0.1f, 1, 0.0f, 20.0f, 0.0f); + } + } + } +} + +void EnFw_TurnToParentInitPos(EnFw* pthis, GlobalContext* globalCtx) { + s16 angleToParentInit; + + angleToParentInit = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.parent->home.pos); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, angleToParentInit, 4, 0xFA0, 1); + if (ABS(angleToParentInit - pthis->actor.shape.rot.y) < 0x65) { + // angle to parent init pos is ~0.5 degrees + pthis->actor.world.rot = pthis->actor.shape.rot; + pthis->actor.velocity.y = 14.0f; + pthis->actor.home.pos = pthis->actor.world.pos; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + func_80034EC0(&pthis->skelAnime, D_80A1FBA0, 1); + pthis->actionFunc = EnFw_JumpToParentInitPos; + } +} + +void EnFw_JumpToParentInitPos(EnFw* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1 && pthis->actor.velocity.y <= 0.0f) { + pthis->actor.parent->params |= 0x8000; + Actor_Kill(&pthis->actor); + } else { + Math_SmoothStepToF(&pthis->actor.world.pos.x, pthis->actor.parent->home.pos.x, 0.6f, 8.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, pthis->actor.parent->home.pos.z, 0.6f, 8.0f, 0.0f); + } +} + +void EnFw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFw* pthis = (EnFw*)thisx; + SkelAnime_Update(&pthis->skelAnime); + if (!CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_13)) { + // not attached to hookshot. + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 20.0f, 0.0f, 5); + pthis->actionFunc(pthis, globalCtx); + if (pthis->damageTimer == 0 && pthis->explosionTimer == 0 && pthis->actionFunc == EnFw_Run) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +s32 EnFw_OverrideLimbDraw(GlobalContext* globalContext, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + return false; +} + +void EnFw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnFw* pthis = (EnFw*)thisx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 2) { + // body + Matrix_MultVec3f(&zeroVec, &pthis->bompPos); + } + + if (limbIndex == 3) { + // head + Matrix_MultVec3f(&zeroVec, &pthis->actor.focus.pos); + } + + Collider_UpdateSpheres(limbIndex, &pthis->collider); +} + +void EnFw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFw* pthis = (EnFw*)thisx; + + EnFw_UpdateDust(pthis); + Matrix_Push(); + EnFw_DrawDust(pthis, globalCtx); + Matrix_Pop(); + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnFw_OverrideLimbDraw, EnFw_PostLimbDraw, pthis); +} + +void EnFw_AddDust(EnFw* pthis, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* accel, u8 initialTimer, f32 scale, + f32 scaleStep) { + EnFwEffect* eff = pthis->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { + if (eff->type != 1) { + eff->scale = scale; + eff->scaleStep = scaleStep; + eff->initialTimer = eff->timer = initialTimer; + eff->type = 1; + eff->pos = *initialPos; + eff->accel = *accel; + eff->velocity = *initialSpeed; + return; + } + } +} + +void EnFw_UpdateDust(EnFw* pthis) { + EnFwEffect* eff = pthis->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { + if (eff->type != 0) { + if ((--eff->timer) == 0) { + eff->type = 0; + } + eff->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + eff->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + eff->pos.x += eff->velocity.x; + eff->pos.y += eff->velocity.y; + eff->pos.z += eff->velocity.z; + eff->velocity.x += eff->accel.x; + eff->velocity.y += eff->accel.y; + eff->velocity.z += eff->accel.z; + eff->scale += eff->scaleStep; + } + } +} + +void EnFw_DrawDust(EnFw* pthis, GlobalContext* globalCtx) { + static void* dustTextures[] = { + gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, + }; + EnFwEffect* eff = pthis->effects; + s16 firstDone; + s16 alpha; + s16 i; + s16 idx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fw.c", 1191); + + firstDone = false; + func_80093D84(globalCtx->state.gfxCtx); + if (1) {} + + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++, eff++) { + if (eff->type != 0) { + if (!firstDone) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0U); + gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_7928); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); + firstDone = true; + } + + alpha = eff->timer * (255.0f / eff->initialTimer); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); + gDPPipeSync(POLY_XLU_DISP++); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(eff->scale, eff->scale, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fw.c", 1229), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + idx = eff->timer * (8.0f / eff->initialTimer); + gSPSegment(POLY_XLU_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(dustTextures[idx])); + gSPDisplayList(POLY_XLU_DISP++, gFlareDancerSquareParticleDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fw.c", 1243); +} diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.h b/src/overlays/actors/ovl_En_Fw/z_en_fw.h index f7d245e5e..241a26543 100644 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.h +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.h @@ -6,7 +6,7 @@ struct EnFw; -typedef void (*EnFwActionFunc)(struct EnFw* this, GlobalContext* globalCtx); +typedef void (*EnFwActionFunc)(struct EnFw* pthis, GlobalContext* globalCtx); typedef struct { /* 0x0000 */ u8 type; diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c deleted file mode 100644 index 0558babe1..000000000 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ /dev/null @@ -1,902 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FZ_Z_EN_FZ_C -#include "actor_common.h" -#include "z_en_fz.h" -#include "objects/object_fz/object_fz.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) - -void EnFz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnFz_UpdateTargetPos(EnFz* this, GlobalContext* globalCtx); - -// Stationary Freezard -void EnFz_SetupBlowSmokeStationary(EnFz* this); -void EnFz_BlowSmokeStationary(EnFz* this, GlobalContext* globalCtx); - -// Moving Freezard that can vanish and reappear -void EnFz_Wait(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupAppear(EnFz* this); -void EnFz_Appear(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupAimForMove(EnFz* this); -void EnFz_AimForMove(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupMoveTowardsPlayer(EnFz* this); -void EnFz_MoveTowardsPlayer(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupAimForFreeze(EnFz* this); -void EnFz_AimForFreeze(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupBlowSmoke(EnFz* this, GlobalContext* globalCtx); -void EnFz_BlowSmoke(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupDisappear(EnFz* this); -void EnFz_Disappear(EnFz* this, GlobalContext* globalCtx); -void EnFz_SetupWait(EnFz* this); - -// Killed with fire source -void EnFz_SetupMelt(EnFz* this); -void EnFz_Melt(EnFz* this, GlobalContext* globalCtx); - -// Death -void EnFz_SetupDespawn(EnFz* this, GlobalContext* globalCtx); -void EnFz_Despawn(EnFz* this, GlobalContext* globalCtx); - -// Ice Smoke Effects -void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale); -void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, - s16 primAlpha, u8 isTimerMod8); -void EnFz_UpdateIceSmoke(EnFz* this, GlobalContext* globalCtx); -void EnFz_DrawIceSmoke(EnFz* this, GlobalContext* globalCtx); - -const ActorInit En_Fz_InitVars = { - ACTOR_EN_FZ, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_FZ, - sizeof(EnFz), - (ActorFunc)EnFz_Init, - (ActorFunc)EnFz_Destroy, - (ActorFunc)EnFz_Update, - (ActorFunc)EnFz_Draw, -}; - -static ColliderCylinderInitType1 sCylinderInit1 = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0xFFCE0FDB, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 30, 80, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInitType1 sCylinderInit2 = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0x0001F024, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 35, 80, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInitType1 sCylinderInit3 = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x02, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { 20, 30, -15, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0xF), - /* Slingshot */ DMG_ENTRY(0, 0xF), - /* Explosive */ DMG_ENTRY(2, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(2, 0xF), - /* Kokiri sword */ DMG_ENTRY(0, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(0, 0xF), - /* Unk arrow 1 */ DMG_ENTRY(0, 0xF), - /* Unk arrow 2 */ DMG_ENTRY(0, 0xF), - /* Unk arrow 3 */ DMG_ENTRY(0, 0xF), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(0, 0xF), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(0, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x3B, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFz* this = (EnFz*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.health = 6; - - Collider_InitCylinder(globalCtx, &this->collider1); - Collider_SetCylinderType1(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - - Collider_InitCylinder(globalCtx, &this->collider2); - Collider_SetCylinderType1(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); - - Collider_InitCylinder(globalCtx, &this->collider3); - Collider_SetCylinderType1(globalCtx, &this->collider3, &this->actor, &sCylinderInit3); - - Actor_SetScale(&this->actor, 0.008f); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~ACTOR_FLAG_0; - this->unusedTimer1 = 0; - this->unusedCounter = 0; - this->updateBgInfo = true; - this->isMoving = false; - this->isFreezing = false; - this->isActive = true; - this->isDespawning = false; - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->posOrigin.y = this->actor.world.pos.y; - this->iceSmokeFreezingSpawnHeight = this->actor.world.pos.y; - this->posOrigin.x = this->actor.world.pos.x; - this->posOrigin.z = this->actor.world.pos.z; - this->unusedFloat = 135.0f; - - if (this->actor.params < 0) { - this->envAlpha = 0; - this->actor.scale.y = 0.0f; - EnFz_SetupWait(this); - } else { - this->envAlpha = 255; - EnFz_SetupBlowSmokeStationary(this); - } - - EnFz_UpdateTargetPos(this, globalCtx); -} - -void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnFz* this = (EnFz*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); - Collider_DestroyCylinder(globalCtx, &this->collider3); -} - -void EnFz_UpdateTargetPos(EnFz* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f hitPos; - Vec3f vec1; - s32 bgId; - CollisionPoly* hitPoly; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 20.0f; - pos.z = this->actor.world.pos.z; - - Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); - vec1.x = vec1.y = 0.0f; - vec1.z = 220.0f; - Matrix_MultVec3f(&vec1, &this->wallHitPos); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pos, &this->wallHitPos, &hitPos, &hitPoly, true, false, false, - true, &bgId)) { - Math_Vec3f_Copy(&this->wallHitPos, &hitPos); - } - - pos.x = this->actor.world.pos.x - this->wallHitPos.x; - pos.z = this->actor.world.pos.z - this->wallHitPos.z; - - this->distToTargetSq = SQ(pos.x) + SQ(pos.z); -} - -s32 EnFz_ReachedTarget(EnFz* this, Vec3f* vec) { - if (this->distToTargetSq <= (SQ(this->actor.world.pos.x - vec->x) + SQ(this->actor.world.pos.z - vec->z))) { - return true; - } else { - return false; - } -} - -void EnFz_Damaged(EnFz* this, GlobalContext* globalCtx, Vec3f* vec, s32 numEffects, f32 unkFloat) { - s32 i; - Vec3f pos; - Vec3f vel; - Vec3f accel; - Color_RGBA8 primColor; - Color_RGBA8 envColor; - f32 scale; - s32 life; - - primColor.r = 155; - primColor.g = 255; - primColor.b = 255; - primColor.a = 255; - envColor.r = 200; - envColor.g = 200; - envColor.b = 200; - accel.x = accel.z = 0.0f; - accel.y = -1.0f; - - for (i = 0; i < numEffects; i++) { - scale = Rand_CenteredFloat(0.3f) + 0.6f; - life = (s32)Rand_CenteredFloat(5.0f) + 12; - pos.x = Rand_CenteredFloat(unkFloat) + vec->x; - pos.y = Rand_ZeroFloat(unkFloat) + vec->y; - pos.z = Rand_CenteredFloat(unkFloat) + vec->z; - vel.x = Rand_CenteredFloat(10.0f); - vel.y = Rand_ZeroFloat(10.0f) + 2.0f; - vel.z = Rand_CenteredFloat(10.0f); - EffectSsEnIce_Spawn(globalCtx, &pos, scale, &vel, &accel, &primColor, &envColor, life); - } - - CollisionCheck_SpawnShieldParticles(globalCtx, vec); -} - -void EnFz_SpawnIceSmokeHiddenState(EnFz* this) { -} - -// Fully grown -void EnFz_SpawnIceSmokeGrowingState(EnFz* this) { - Vec3f pos; - Vec3f velocity; - Vec3f accel; - - if ((this->counter % 16) == 0) { - pos.x = Rand_CenteredFloat(40.0f) + this->actor.world.pos.x; - pos.y = Rand_CenteredFloat(40.0f) + this->actor.world.pos.y + 30.0f; - pos.z = Rand_CenteredFloat(40.0f) + this->actor.world.pos.z; - accel.x = accel.z = 0.0f; - accel.y = 0.1f; - velocity.x = velocity.y = velocity.z = 0.0f; - EnFz_SpawnIceSmokeNoFreeze(this, &pos, &velocity, &accel, Rand_ZeroFloat(7.5f) + 15.0f); - } -} - -// (2) Growing or Shrinking to/from hiding or (3) melting from fire -void EnFz_SpawnIceSmokeActiveState(EnFz* this) { - Vec3f pos; - Vec3f velocity; - Vec3f accel; - - if ((this->counter % 4) == 0) { - pos.x = Rand_CenteredFloat(40.0f) + this->actor.world.pos.x; - pos.y = this->iceSmokeFreezingSpawnHeight; - pos.z = Rand_CenteredFloat(40.0f) + this->actor.world.pos.z; - accel.x = accel.z = 0.0f; - accel.y = 0.1f; - velocity.x = velocity.y = velocity.z = 0.0f; - EnFz_SpawnIceSmokeNoFreeze(this, &pos, &velocity, &accel, Rand_ZeroFloat(7.5f) + 15.0f); - } -} - -void EnFz_ApplyDamage(EnFz* this, GlobalContext* globalCtx) { - Vec3f vec; - - if (this->isMoving && - ((this->actor.bgCheckFlags & 8) || - (Actor_TestFloorInDirection(&this->actor, globalCtx, 60.0f, this->actor.world.rot.y) == 0))) { - this->actor.bgCheckFlags &= ~8; - this->isMoving = false; - this->speedXZ = 0.0f; - this->actor.speedXZ = 0.0f; - } - - if (this->isFreezing) { - if ((this->actor.params < 0) && (this->collider1.base.atFlags & 2)) { - this->isMoving = false; - this->collider1.base.acFlags &= ~2; - this->actor.speedXZ = this->speedXZ = 0.0f; - this->timer = 10; - EnFz_SetupDisappear(this); - } else if (this->collider2.base.acFlags & 0x80) { - this->collider2.base.acFlags &= ~0x80; - this->collider1.base.acFlags &= ~2; - } else if (this->collider1.base.acFlags & 2) { - this->collider1.base.acFlags &= ~2; - if (this->actor.colChkInfo.damageEffect != 2) { - if (this->actor.colChkInfo.damageEffect == 0xF) { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 8); - if (this->actor.colChkInfo.health) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); - vec.x = this->actor.world.pos.x; - vec.y = this->actor.world.pos.y; - vec.z = this->actor.world.pos.z; - EnFz_Damaged(this, globalCtx, &vec, 10, 0.0f); - this->unusedCounter++; - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); - vec.x = this->actor.world.pos.x; - vec.y = this->actor.world.pos.y; - vec.z = this->actor.world.pos.z; - EnFz_Damaged(this, globalCtx, &vec, 30, 10.0f); - EnFz_SetupDespawn(this, globalCtx); - } - } - } else { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 8); - if (this->actor.colChkInfo.health == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DEAD); - EnFz_SetupMelt(this); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); - } - } - } - } -} - -void EnFz_SetYawTowardsPlayer(EnFz* this) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 2000, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; -} - -void EnFz_SetupDisappear(EnFz* this) { - this->state = 2; - this->isFreezing = false; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnFz_Disappear; -} - -void EnFz_Disappear(EnFz* this, GlobalContext* globalCtx) { - this->envAlpha -= 16; - - if (this->envAlpha > 255) { - this->envAlpha = 0; - } - - if (Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 1.0f, 0.0005f, 0) == 0.0f) { - EnFz_SetupWait(this); - } -} - -void EnFz_SetupWait(EnFz* this) { - this->state = 0; - this->unusedNum2 = 0; - this->unusedNum1 = 0; - this->timer = 100; - this->actionFunc = EnFz_Wait; - this->actor.world.pos.x = this->posOrigin.x; - this->actor.world.pos.y = this->posOrigin.y; - this->actor.world.pos.z = this->posOrigin.z; -} - -void EnFz_Wait(EnFz* this, GlobalContext* globalCtx) { - if ((this->timer == 0) && (this->actor.xzDistToPlayer < 400.0f)) { - EnFz_SetupAppear(this); - } -} - -void EnFz_SetupAppear(EnFz* this) { - this->state = 2; - this->timer = 20; - this->unusedNum2 = 4000; - this->actionFunc = EnFz_Appear; -} - -void EnFz_Appear(EnFz* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - this->envAlpha += 8; - if (this->envAlpha > 255) { - this->envAlpha = 255; - } - - if (Math_SmoothStepToF(&this->actor.scale.y, 0.008f, 1.0f, 0.0005f, 0.0f) == 0.0f) { - EnFz_SetupAimForMove(this); - } - } -} - -void EnFz_SetupAimForMove(EnFz* this) { - this->state = 1; - this->timer = 40; - this->updateBgInfo = true; - this->isFreezing = true; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = EnFz_AimForMove; - this->actor.gravity = -1.0f; -} - -void EnFz_AimForMove(EnFz* this, GlobalContext* globalCtx) { - EnFz_SetYawTowardsPlayer(this); - - if (this->timer == 0) { - EnFz_SetupMoveTowardsPlayer(this); - } -} - -void EnFz_SetupMoveTowardsPlayer(EnFz* this) { - this->state = 1; - this->isMoving = true; - this->timer = 100; - this->actionFunc = EnFz_MoveTowardsPlayer; - this->speedXZ = 4.0f; -} - -void EnFz_MoveTowardsPlayer(EnFz* this, GlobalContext* globalCtx) { - if ((this->timer == 0) || !this->isMoving) { - EnFz_SetupAimForFreeze(this); - } -} - -void EnFz_SetupAimForFreeze(EnFz* this) { - this->state = 1; - this->timer = 40; - this->actionFunc = EnFz_AimForFreeze; - this->speedXZ = 0.0f; - this->actor.speedXZ = 0.0f; -} - -void EnFz_AimForFreeze(EnFz* this, GlobalContext* globalCtx) { - EnFz_SetYawTowardsPlayer(this); - - if (this->timer == 0) { - EnFz_SetupBlowSmoke(this, globalCtx); - } -} - -void EnFz_SetupBlowSmoke(EnFz* this, GlobalContext* globalCtx) { - this->state = 1; - this->timer = 80; - this->actionFunc = EnFz_BlowSmoke; - EnFz_UpdateTargetPos(this, globalCtx); -} - -void EnFz_BlowSmoke(EnFz* this, GlobalContext* globalCtx) { - Vec3f vec1; - Vec3f pos; - Vec3f velocity; - Vec3f accel; - u8 isTimerMod8; - s16 primAlpha; - - if (this->timer == 0) { - EnFz_SetupDisappear(this); - } else if (this->timer >= 11) { - isTimerMod8 = false; - primAlpha = 150; - func_8002F974(&this->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); - - if ((this->timer - 10) < 16) { // t < 26 - primAlpha = (this->timer * 10) - 100; - } - - accel.x = accel.z = 0.0f; - accel.y = 0.6f; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 20.0f; - pos.z = this->actor.world.pos.z; - - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); - - vec1.x = 0.0f; - vec1.y = -2.0f; - vec1.z = 20.0f; // xz velocity - - Matrix_MultVec3f(&vec1, &velocity); - - if ((this->timer % 8) == 0) { - isTimerMod8 = true; - } - - EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, isTimerMod8); - - pos.x += (velocity.x * 0.5f); - pos.y += (velocity.y * 0.5f); - pos.z += (velocity.z * 0.5f); - - EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, false); - } -} - -void EnFz_SetupDespawn(EnFz* this, GlobalContext* globalCtx) { - this->state = 0; - this->updateBgInfo = true; - this->isFreezing = false; - this->isDespawning = true; - this->actor.flags &= ~ACTOR_FLAG_0; - this->isActive = false; - this->timer = 60; - this->speedXZ = 0.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); - this->actionFunc = EnFz_Despawn; -} - -void EnFz_Despawn(EnFz* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - Actor_Kill(&this->actor); - } -} - -void EnFz_SetupMelt(EnFz* this) { - this->state = 3; - this->isFreezing = false; - this->isDespawning = true; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnFz_Melt; - this->actor.speedXZ = 0.0f; - this->speedXZ = 0.0f; -} - -void EnFz_Melt(EnFz* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.scale.y, 0.0006f, 0.0002f); - - if (this->actor.scale.y < 0.006f) { - this->actor.scale.x += 0.0004f; - this->actor.scale.z += 0.0004f; - } - - if (this->actor.scale.y < 0.004f) { - this->envAlpha -= 8; - if (this->envAlpha > 255) { - this->envAlpha = 0; - } - } - - if (this->envAlpha == 0) { - EnFz_SetupDespawn(this, globalCtx); - } -} - -void EnFz_SetupBlowSmokeStationary(EnFz* this) { - this->state = 1; - this->timer = 40; - this->updateBgInfo = true; - this->isFreezing = true; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = EnFz_BlowSmokeStationary; - this->actor.gravity = -1.0f; -} - -void EnFz_BlowSmokeStationary(EnFz* this, GlobalContext* globalCtx) { - Vec3f vec1; - Vec3f pos; - Vec3f velocity; - Vec3f accel; - u8 isTimerMod8; - s16 primAlpha; - - if (this->counter & 0xC0) { - EnFz_SetYawTowardsPlayer(this); - EnFz_UpdateTargetPos(this, globalCtx); - } else { - isTimerMod8 = false; - primAlpha = 150; - func_8002F974(&this->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); - - if ((this->counter & 0x3F) >= 48) { - primAlpha = 630 - ((this->counter & 0x3F) * 10); - } - - accel.x = accel.z = 0.0f; - accel.y = 0.6f; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 20.0f; - pos.z = this->actor.world.pos.z; - - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); - - vec1.x = 0.0f; - vec1.y = -2.0f; - vec1.z = 20.0f; - - Matrix_MultVec3f(&vec1, &velocity); - - if ((this->counter % 8) == 0) { - isTimerMod8 = true; - } - - EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, isTimerMod8); - - pos.x += (velocity.x * 0.5f); - pos.y += (velocity.y * 0.5f); - pos.z += (velocity.z * 0.5f); - - EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, false); - } -} - -static EnFzSpawnIceSmokeFunc iceSmokeSpawnFuncs[] = { - EnFz_SpawnIceSmokeHiddenState, - EnFz_SpawnIceSmokeGrowingState, - EnFz_SpawnIceSmokeActiveState, - EnFz_SpawnIceSmokeActiveState, -}; - -void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { - EnFz* this = (EnFz*)thisx; - s32 pad; - - this->counter++; - - if (this->unusedTimer1 != 0) { - this->unusedTimer1--; - } - - if (this->timer != 0) { - this->timer--; - } - - if (this->unusedTimer2 != 0) { - this->unusedTimer2--; - } - - Actor_SetFocus(&this->actor, 50.0f); - EnFz_ApplyDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - if (this->isDespawning == false) { - Collider_UpdateCylinder(&this->actor, &this->collider1); - Collider_UpdateCylinder(&this->actor, &this->collider2); - if (this->isFreezing) { - if (this->actor.colorFilterTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - } - } - - Math_StepToF(&this->actor.speedXZ, this->speedXZ, 0.2f); - Actor_MoveForward(&this->actor); - - if (this->updateBgInfo) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); - } - - iceSmokeSpawnFuncs[this->state](this); - EnFz_UpdateIceSmoke(this, globalCtx); -} - -void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Gfx* displayLists[] = { - gFreezardIntactDL, // Body fully intact (5 or 6 health) - gFreezardTopRightHornChippedDL, // Top right horn chipped off (from Freezards perspective) (3 or 4 health) - gFreezardHeadChippedDL, // Entire head chipped off (1 or 2 health) - }; - EnFz* this = (EnFz*)thisx; - s32 pad; - s32 index; - - index = (6 - this->actor.colChkInfo.health) >> 1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fz.c", 1167); - - if (1) {} - - if (this->actor.colChkInfo.health == 0) { - index = 2; - } - - if (this->isActive) { - func_8002ED80(&this->actor, globalCtx, 0); - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->state.frames & 0x7F, 32, 32, 1, 0, - (2 * globalCtx->state.frames) & 0x7F, 32, 32)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fz.c", 1183), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, - PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, ENVIRONMENT, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, 155, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, this->envAlpha); - gSPDisplayList(POLY_XLU_DISP++, displayLists[index]); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fz.c", 1200); - EnFz_DrawIceSmoke(this, globalCtx); -} - -void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; - s16 i; - - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type == 0) { - iceSmoke->type = 1; - iceSmoke->pos = *pos; - iceSmoke->velocity = *velocity; - iceSmoke->accel = *accel; - iceSmoke->primAlphaState = 0; - iceSmoke->xyScale = xyScale / 1000.0f; - iceSmoke->primAlpha = 0; - iceSmoke->timer = 0; - break; - } - - iceSmoke++; - } -} - -void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, - s16 primAlpha, u8 isTimerMod8) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; - s16 i; - - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type == 0) { - iceSmoke->type = 2; - iceSmoke->pos = *pos; - iceSmoke->velocity = *velocity; - iceSmoke->accel = *accel; - iceSmoke->primAlphaState = 0; - iceSmoke->xyScale = xyScale / 1000.0f; - iceSmoke->xyScaleTarget = xyScaleTarget / 1000.0f; - iceSmoke->primAlpha = primAlpha; - iceSmoke->timer = 0; - iceSmoke->isTimerMod8 = isTimerMod8; - break; - } - - iceSmoke++; - } -} - -void EnFz_UpdateIceSmoke(EnFz* this, GlobalContext* globalCtx) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; - s16 i; - Vec3f pos; - - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type) { - iceSmoke->pos.x += iceSmoke->velocity.x; - iceSmoke->pos.y += iceSmoke->velocity.y; - iceSmoke->pos.z += iceSmoke->velocity.z; - iceSmoke->timer++; - iceSmoke->velocity.x += iceSmoke->accel.x; - iceSmoke->velocity.y += iceSmoke->accel.y; - iceSmoke->velocity.z += iceSmoke->accel.z; - if (iceSmoke->type == 1) { - if (iceSmoke->primAlphaState == 0) { // Becoming more opaque - iceSmoke->primAlpha += 10; - if (iceSmoke->primAlpha >= 100) { - iceSmoke->primAlphaState++; - } - } else { // Becoming more transparent - iceSmoke->primAlpha -= 3; - if (iceSmoke->primAlpha <= 0) { - iceSmoke->primAlpha = 0; - iceSmoke->type = 0; - } - } - } else if (iceSmoke->type == 2) { // Freezing - Math_ApproachF(&iceSmoke->xyScale, iceSmoke->xyScaleTarget, 0.1f, iceSmoke->xyScaleTarget / 10.0f); - if (iceSmoke->primAlphaState == 0) { // Becoming more opaque - if (iceSmoke->timer >= 7) { - iceSmoke->primAlphaState++; - } - } else { // Becoming more transparent, slows down - iceSmoke->accel.y = 2.0f; - iceSmoke->primAlpha -= 17; - iceSmoke->velocity.x *= 0.75f; - iceSmoke->velocity.z *= 0.75f; - if (iceSmoke->primAlpha <= 0) { - iceSmoke->primAlpha = 0; - iceSmoke->type = 0; - } - } - - if ((this->unusedTimer2 == 0) && (iceSmoke->primAlpha >= 101) && iceSmoke->isTimerMod8) { - this->collider3.dim.pos.x = (s16)iceSmoke->pos.x; - this->collider3.dim.pos.y = (s16)iceSmoke->pos.y; - this->collider3.dim.pos.z = (s16)iceSmoke->pos.z; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); - } - - pos.x = iceSmoke->pos.x; - pos.y = iceSmoke->pos.y + 10.0f; - pos.z = iceSmoke->pos.z; - - if ((iceSmoke->primAlphaState != 2) && EnFz_ReachedTarget(this, &pos)) { - iceSmoke->primAlphaState = 2; - iceSmoke->velocity.x = 0.0f; - iceSmoke->velocity.z = 0.0f; - } - } - } - iceSmoke++; - } -} - -void EnFz_DrawIceSmoke(EnFz* this, GlobalContext* globalCtx) { - EnFzEffectSsIceSmoke* iceSmoke = this->iceSmoke; - s16 i; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 texLoaded = false; - - OPEN_DISPS(gfxCtx, "../z_en_fz.c", 1384); - - func_80093D84(globalCtx->state.gfxCtx); - - for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { - if (iceSmoke->type > 0) { - gDPPipeSync(POLY_XLU_DISP++); - - if (!texLoaded) { - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamStartDL)); - texLoaded++; - } - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, iceSmoke->primAlpha); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 3 * (iceSmoke->timer + (3 * i)), - 15 * (iceSmoke->timer + (3 * i)), 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(iceSmoke->pos.x, iceSmoke->pos.y, iceSmoke->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(iceSmoke->xyScale, iceSmoke->xyScale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_fz.c", 1424), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamDL)); - } - - iceSmoke++; - } - - CLOSE_DISPS(gfxCtx, "../z_en_fz.c", 1430); -} diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.cpp b/src/overlays/actors/ovl_En_Fz/z_en_fz.cpp new file mode 100644 index 000000000..3f029c946 --- /dev/null +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.cpp @@ -0,0 +1,902 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FZ_Z_EN_FZ_C +#include "actor_common.h" +#include "z_en_fz.h" +#include "objects/object_fz/object_fz.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) + +void EnFz_Init(Actor* thisx, GlobalContext* globalCtx); +void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnFz_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnFz_UpdateTargetPos(EnFz* pthis, GlobalContext* globalCtx); + +// Stationary Freezard +void EnFz_SetupBlowSmokeStationary(EnFz* pthis); +void EnFz_BlowSmokeStationary(EnFz* pthis, GlobalContext* globalCtx); + +// Moving Freezard that can vanish and reappear +void EnFz_Wait(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupAppear(EnFz* pthis); +void EnFz_Appear(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupAimForMove(EnFz* pthis); +void EnFz_AimForMove(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupMoveTowardsPlayer(EnFz* pthis); +void EnFz_MoveTowardsPlayer(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupAimForFreeze(EnFz* pthis); +void EnFz_AimForFreeze(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupBlowSmoke(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_BlowSmoke(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupDisappear(EnFz* pthis); +void EnFz_Disappear(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_SetupWait(EnFz* pthis); + +// Killed with fire source +void EnFz_SetupMelt(EnFz* pthis); +void EnFz_Melt(EnFz* pthis, GlobalContext* globalCtx); + +// Death +void EnFz_SetupDespawn(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_Despawn(EnFz* pthis, GlobalContext* globalCtx); + +// Ice Smoke Effects +void EnFz_SpawnIceSmokeNoFreeze(EnFz* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale); +void EnFz_SpawnIceSmokeFreeze(EnFz* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, + s16 primAlpha, u8 isTimerMod8); +void EnFz_UpdateIceSmoke(EnFz* pthis, GlobalContext* globalCtx); +void EnFz_DrawIceSmoke(EnFz* pthis, GlobalContext* globalCtx); + +ActorInit En_Fz_InitVars = { + ACTOR_EN_FZ, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_FZ, + sizeof(EnFz), + (ActorFunc)EnFz_Init, + (ActorFunc)EnFz_Destroy, + (ActorFunc)EnFz_Update, + (ActorFunc)EnFz_Draw, +}; + +static ColliderCylinderInitType1 sCylinderInit1 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0xFFCE0FDB, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 30, 80, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInitType1 sCylinderInit2 = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0x0001F024, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 35, 80, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInitType1 sCylinderInit3 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x02, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { 20, 30, -15, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0xF), + /* Slingshot */ DMG_ENTRY(0, 0xF), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0xF), + /* Normal arrow */ DMG_ENTRY(0, 0xF), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(2, 0xF), + /* Kokiri sword */ DMG_ENTRY(0, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(0, 0xF), + /* Light arrow */ DMG_ENTRY(0, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(0, 0xF), + /* Unk arrow 2 */ DMG_ENTRY(0, 0xF), + /* Unk arrow 3 */ DMG_ENTRY(0, 0xF), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(0, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x3B, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFz* pthis = (EnFz*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.colChkInfo.health = 6; + + Collider_InitCylinder(globalCtx, &pthis->collider1); + Collider_SetCylinderType1(globalCtx, &pthis->collider1, &pthis->actor, &sCylinderInit1); + + Collider_InitCylinder(globalCtx, &pthis->collider2); + Collider_SetCylinderType1(globalCtx, &pthis->collider2, &pthis->actor, &sCylinderInit2); + + Collider_InitCylinder(globalCtx, &pthis->collider3); + Collider_SetCylinderType1(globalCtx, &pthis->collider3, &pthis->actor, &sCylinderInit3); + + Actor_SetScale(&pthis->actor, 0.008f); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unusedTimer1 = 0; + pthis->unusedCounter = 0; + pthis->updateBgInfo = true; + pthis->isMoving = false; + pthis->isFreezing = false; + pthis->isActive = true; + pthis->isDespawning = false; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->posOrigin.y = pthis->actor.world.pos.y; + pthis->iceSmokeFreezingSpawnHeight = pthis->actor.world.pos.y; + pthis->posOrigin.x = pthis->actor.world.pos.x; + pthis->posOrigin.z = pthis->actor.world.pos.z; + pthis->unusedFloat = 135.0f; + + if (pthis->actor.params < 0) { + pthis->envAlpha = 0; + pthis->actor.scale.y = 0.0f; + EnFz_SetupWait(pthis); + } else { + pthis->envAlpha = 255; + EnFz_SetupBlowSmokeStationary(pthis); + } + + EnFz_UpdateTargetPos(pthis, globalCtx); +} + +void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFz* pthis = (EnFz*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider1); + Collider_DestroyCylinder(globalCtx, &pthis->collider2); + Collider_DestroyCylinder(globalCtx, &pthis->collider3); +} + +void EnFz_UpdateTargetPos(EnFz* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f hitPos; + Vec3f vec1; + s32 bgId; + CollisionPoly* hitPoly; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 20.0f; + pos.z = pthis->actor.world.pos.z; + + Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, MTXMODE_APPLY); + vec1.x = vec1.y = 0.0f; + vec1.z = 220.0f; + Matrix_MultVec3f(&vec1, &pthis->wallHitPos); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pos, &pthis->wallHitPos, &hitPos, &hitPoly, true, false, false, + true, &bgId)) { + Math_Vec3f_Copy(&pthis->wallHitPos, &hitPos); + } + + pos.x = pthis->actor.world.pos.x - pthis->wallHitPos.x; + pos.z = pthis->actor.world.pos.z - pthis->wallHitPos.z; + + pthis->distToTargetSq = SQ(pos.x) + SQ(pos.z); +} + +s32 EnFz_ReachedTarget(EnFz* pthis, Vec3f* vec) { + if (pthis->distToTargetSq <= (SQ(pthis->actor.world.pos.x - vec->x) + SQ(pthis->actor.world.pos.z - vec->z))) { + return true; + } else { + return false; + } +} + +void EnFz_Damaged(EnFz* pthis, GlobalContext* globalCtx, Vec3f* vec, s32 numEffects, f32 unkFloat) { + s32 i; + Vec3f pos; + Vec3f vel; + Vec3f accel; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + f32 scale; + s32 life; + + primColor.r = 155; + primColor.g = 255; + primColor.b = 255; + primColor.a = 255; + envColor.r = 200; + envColor.g = 200; + envColor.b = 200; + accel.x = accel.z = 0.0f; + accel.y = -1.0f; + + for (i = 0; i < numEffects; i++) { + scale = Rand_CenteredFloat(0.3f) + 0.6f; + life = (s32)Rand_CenteredFloat(5.0f) + 12; + pos.x = Rand_CenteredFloat(unkFloat) + vec->x; + pos.y = Rand_ZeroFloat(unkFloat) + vec->y; + pos.z = Rand_CenteredFloat(unkFloat) + vec->z; + vel.x = Rand_CenteredFloat(10.0f); + vel.y = Rand_ZeroFloat(10.0f) + 2.0f; + vel.z = Rand_CenteredFloat(10.0f); + EffectSsEnIce_Spawn(globalCtx, &pos, scale, &vel, &accel, &primColor, &envColor, life); + } + + CollisionCheck_SpawnShieldParticles(globalCtx, vec); +} + +void EnFz_SpawnIceSmokeHiddenState(EnFz* pthis) { +} + +// Fully grown +void EnFz_SpawnIceSmokeGrowingState(EnFz* pthis) { + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + if ((pthis->counter % 16) == 0) { + pos.x = Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.x; + pos.y = Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.y + 30.0f; + pos.z = Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.z; + accel.x = accel.z = 0.0f; + accel.y = 0.1f; + velocity.x = velocity.y = velocity.z = 0.0f; + EnFz_SpawnIceSmokeNoFreeze(pthis, &pos, &velocity, &accel, Rand_ZeroFloat(7.5f) + 15.0f); + } +} + +// (2) Growing or Shrinking to/from hiding or (3) melting from fire +void EnFz_SpawnIceSmokeActiveState(EnFz* pthis) { + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + if ((pthis->counter % 4) == 0) { + pos.x = Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.x; + pos.y = pthis->iceSmokeFreezingSpawnHeight; + pos.z = Rand_CenteredFloat(40.0f) + pthis->actor.world.pos.z; + accel.x = accel.z = 0.0f; + accel.y = 0.1f; + velocity.x = velocity.y = velocity.z = 0.0f; + EnFz_SpawnIceSmokeNoFreeze(pthis, &pos, &velocity, &accel, Rand_ZeroFloat(7.5f) + 15.0f); + } +} + +void EnFz_ApplyDamage(EnFz* pthis, GlobalContext* globalCtx) { + Vec3f vec; + + if (pthis->isMoving && + ((pthis->actor.bgCheckFlags & 8) || + (Actor_TestFloorInDirection(&pthis->actor, globalCtx, 60.0f, pthis->actor.world.rot.y) == 0))) { + pthis->actor.bgCheckFlags &= ~8; + pthis->isMoving = false; + pthis->speedXZ = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->isFreezing) { + if ((pthis->actor.params < 0) && (pthis->collider1.base.atFlags & 2)) { + pthis->isMoving = false; + pthis->collider1.base.acFlags &= ~2; + pthis->actor.speedXZ = pthis->speedXZ = 0.0f; + pthis->timer = 10; + EnFz_SetupDisappear(pthis); + } else if (pthis->collider2.base.acFlags & 0x80) { + pthis->collider2.base.acFlags &= ~0x80; + pthis->collider1.base.acFlags &= ~2; + } else if (pthis->collider1.base.acFlags & 2) { + pthis->collider1.base.acFlags &= ~2; + if (pthis->actor.colChkInfo.damageEffect != 2) { + if (pthis->actor.colChkInfo.damageEffect == 0xF) { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 8); + if (pthis->actor.colChkInfo.health) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FREEZAD_DAMAGE); + vec.x = pthis->actor.world.pos.x; + vec.y = pthis->actor.world.pos.y; + vec.z = pthis->actor.world.pos.z; + EnFz_Damaged(pthis, globalCtx, &vec, 10, 0.0f); + pthis->unusedCounter++; + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FREEZAD_DEAD); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_ICE_BROKEN); + vec.x = pthis->actor.world.pos.x; + vec.y = pthis->actor.world.pos.y; + vec.z = pthis->actor.world.pos.z; + EnFz_Damaged(pthis, globalCtx, &vec, 30, 10.0f); + EnFz_SetupDespawn(pthis, globalCtx); + } + } + } else { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 8); + if (pthis->actor.colChkInfo.health == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FREEZAD_DEAD); + EnFz_SetupMelt(pthis); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FREEZAD_DAMAGE); + } + } + } + } +} + +void EnFz_SetYawTowardsPlayer(EnFz* pthis) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 10, 2000, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; +} + +void EnFz_SetupDisappear(EnFz* pthis) { + pthis->state = 2; + pthis->isFreezing = false; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnFz_Disappear; +} + +void EnFz_Disappear(EnFz* pthis, GlobalContext* globalCtx) { + pthis->envAlpha -= 16; + + if (pthis->envAlpha > 255) { + pthis->envAlpha = 0; + } + + if (Math_SmoothStepToF(&pthis->actor.scale.y, 0.0f, 1.0f, 0.0005f, 0) == 0.0f) { + EnFz_SetupWait(pthis); + } +} + +void EnFz_SetupWait(EnFz* pthis) { + pthis->state = 0; + pthis->unusedNum2 = 0; + pthis->unusedNum1 = 0; + pthis->timer = 100; + pthis->actionFunc = EnFz_Wait; + pthis->actor.world.pos.x = pthis->posOrigin.x; + pthis->actor.world.pos.y = pthis->posOrigin.y; + pthis->actor.world.pos.z = pthis->posOrigin.z; +} + +void EnFz_Wait(EnFz* pthis, GlobalContext* globalCtx) { + if ((pthis->timer == 0) && (pthis->actor.xzDistToPlayer < 400.0f)) { + EnFz_SetupAppear(pthis); + } +} + +void EnFz_SetupAppear(EnFz* pthis) { + pthis->state = 2; + pthis->timer = 20; + pthis->unusedNum2 = 4000; + pthis->actionFunc = EnFz_Appear; +} + +void EnFz_Appear(EnFz* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + pthis->envAlpha += 8; + if (pthis->envAlpha > 255) { + pthis->envAlpha = 255; + } + + if (Math_SmoothStepToF(&pthis->actor.scale.y, 0.008f, 1.0f, 0.0005f, 0.0f) == 0.0f) { + EnFz_SetupAimForMove(pthis); + } + } +} + +void EnFz_SetupAimForMove(EnFz* pthis) { + pthis->state = 1; + pthis->timer = 40; + pthis->updateBgInfo = true; + pthis->isFreezing = true; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = EnFz_AimForMove; + pthis->actor.gravity = -1.0f; +} + +void EnFz_AimForMove(EnFz* pthis, GlobalContext* globalCtx) { + EnFz_SetYawTowardsPlayer(pthis); + + if (pthis->timer == 0) { + EnFz_SetupMoveTowardsPlayer(pthis); + } +} + +void EnFz_SetupMoveTowardsPlayer(EnFz* pthis) { + pthis->state = 1; + pthis->isMoving = true; + pthis->timer = 100; + pthis->actionFunc = EnFz_MoveTowardsPlayer; + pthis->speedXZ = 4.0f; +} + +void EnFz_MoveTowardsPlayer(EnFz* pthis, GlobalContext* globalCtx) { + if ((pthis->timer == 0) || !pthis->isMoving) { + EnFz_SetupAimForFreeze(pthis); + } +} + +void EnFz_SetupAimForFreeze(EnFz* pthis) { + pthis->state = 1; + pthis->timer = 40; + pthis->actionFunc = EnFz_AimForFreeze; + pthis->speedXZ = 0.0f; + pthis->actor.speedXZ = 0.0f; +} + +void EnFz_AimForFreeze(EnFz* pthis, GlobalContext* globalCtx) { + EnFz_SetYawTowardsPlayer(pthis); + + if (pthis->timer == 0) { + EnFz_SetupBlowSmoke(pthis, globalCtx); + } +} + +void EnFz_SetupBlowSmoke(EnFz* pthis, GlobalContext* globalCtx) { + pthis->state = 1; + pthis->timer = 80; + pthis->actionFunc = EnFz_BlowSmoke; + EnFz_UpdateTargetPos(pthis, globalCtx); +} + +void EnFz_BlowSmoke(EnFz* pthis, GlobalContext* globalCtx) { + Vec3f vec1; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + u8 isTimerMod8; + s16 primAlpha; + + if (pthis->timer == 0) { + EnFz_SetupDisappear(pthis); + } else if (pthis->timer >= 11) { + isTimerMod8 = false; + primAlpha = 150; + func_8002F974(&pthis->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); + + if ((pthis->timer - 10) < 16) { // t < 26 + primAlpha = (pthis->timer * 10) - 100; + } + + accel.x = accel.z = 0.0f; + accel.y = 0.6f; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 20.0f; + pos.z = pthis->actor.world.pos.z; + + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); + + vec1.x = 0.0f; + vec1.y = -2.0f; + vec1.z = 20.0f; // xz velocity + + Matrix_MultVec3f(&vec1, &velocity); + + if ((pthis->timer % 8) == 0) { + isTimerMod8 = true; + } + + EnFz_SpawnIceSmokeFreeze(pthis, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, isTimerMod8); + + pos.x += (velocity.x * 0.5f); + pos.y += (velocity.y * 0.5f); + pos.z += (velocity.z * 0.5f); + + EnFz_SpawnIceSmokeFreeze(pthis, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, false); + } +} + +void EnFz_SetupDespawn(EnFz* pthis, GlobalContext* globalCtx) { + pthis->state = 0; + pthis->updateBgInfo = true; + pthis->isFreezing = false; + pthis->isDespawning = true; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->isActive = false; + pthis->timer = 60; + pthis->speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x60); + pthis->actionFunc = EnFz_Despawn; +} + +void EnFz_Despawn(EnFz* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnFz_SetupMelt(EnFz* pthis) { + pthis->state = 3; + pthis->isFreezing = false; + pthis->isDespawning = true; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnFz_Melt; + pthis->actor.speedXZ = 0.0f; + pthis->speedXZ = 0.0f; +} + +void EnFz_Melt(EnFz* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.scale.y, 0.0006f, 0.0002f); + + if (pthis->actor.scale.y < 0.006f) { + pthis->actor.scale.x += 0.0004f; + pthis->actor.scale.z += 0.0004f; + } + + if (pthis->actor.scale.y < 0.004f) { + pthis->envAlpha -= 8; + if (pthis->envAlpha > 255) { + pthis->envAlpha = 0; + } + } + + if (pthis->envAlpha == 0) { + EnFz_SetupDespawn(pthis, globalCtx); + } +} + +void EnFz_SetupBlowSmokeStationary(EnFz* pthis) { + pthis->state = 1; + pthis->timer = 40; + pthis->updateBgInfo = true; + pthis->isFreezing = true; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = EnFz_BlowSmokeStationary; + pthis->actor.gravity = -1.0f; +} + +void EnFz_BlowSmokeStationary(EnFz* pthis, GlobalContext* globalCtx) { + Vec3f vec1; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + u8 isTimerMod8; + s16 primAlpha; + + if (pthis->counter & 0xC0) { + EnFz_SetYawTowardsPlayer(pthis); + EnFz_UpdateTargetPos(pthis, globalCtx); + } else { + isTimerMod8 = false; + primAlpha = 150; + func_8002F974(&pthis->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); + + if ((pthis->counter & 0x3F) >= 48) { + primAlpha = 630 - ((pthis->counter & 0x3F) * 10); + } + + accel.x = accel.z = 0.0f; + accel.y = 0.6f; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 20.0f; + pos.z = pthis->actor.world.pos.z; + + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); + + vec1.x = 0.0f; + vec1.y = -2.0f; + vec1.z = 20.0f; + + Matrix_MultVec3f(&vec1, &velocity); + + if ((pthis->counter % 8) == 0) { + isTimerMod8 = true; + } + + EnFz_SpawnIceSmokeFreeze(pthis, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, isTimerMod8); + + pos.x += (velocity.x * 0.5f); + pos.y += (velocity.y * 0.5f); + pos.z += (velocity.z * 0.5f); + + EnFz_SpawnIceSmokeFreeze(pthis, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, false); + } +} + +static EnFzSpawnIceSmokeFunc iceSmokeSpawnFuncs[] = { + EnFz_SpawnIceSmokeHiddenState, + EnFz_SpawnIceSmokeGrowingState, + EnFz_SpawnIceSmokeActiveState, + EnFz_SpawnIceSmokeActiveState, +}; + +void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFz* pthis = (EnFz*)thisx; + s32 pad; + + pthis->counter++; + + if (pthis->unusedTimer1 != 0) { + pthis->unusedTimer1--; + } + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->unusedTimer2 != 0) { + pthis->unusedTimer2--; + } + + Actor_SetFocus(&pthis->actor, 50.0f); + EnFz_ApplyDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + if (pthis->isDespawning == false) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider1); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider2); + if (pthis->isFreezing) { + if (pthis->actor.colorFilterTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + } + } + + Math_StepToF(&pthis->actor.speedXZ, pthis->speedXZ, 0.2f); + Actor_MoveForward(&pthis->actor); + + if (pthis->updateBgInfo) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 20.0f, 5); + } + + iceSmokeSpawnFuncs[pthis->state](pthis); + EnFz_UpdateIceSmoke(pthis, globalCtx); +} + +void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* displayLists[] = { + gFreezardIntactDL, // Body fully intact (5 or 6 health) + gFreezardTopRightHornChippedDL, // Top right horn chipped off (from Freezards perspective) (3 or 4 health) + gFreezardHeadChippedDL, // Entire head chipped off (1 or 2 health) + }; + EnFz* pthis = (EnFz*)thisx; + s32 pad; + s32 index; + + index = (6 - pthis->actor.colChkInfo.health) >> 1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fz.c", 1167); + + if (1) {} + + if (pthis->actor.colChkInfo.health == 0) { + index = 2; + } + + if (pthis->isActive) { + func_8002ED80(&pthis->actor, globalCtx, 0); + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->state.frames & 0x7F, 32, 32, 1, 0, + (2 * globalCtx->state.frames) & 0x7F, 32, 32)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_fz.c", 1183), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, + PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, ENVIRONMENT, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, 155, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, pthis->envAlpha); + gSPDisplayList(POLY_XLU_DISP++, displayLists[index]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fz.c", 1200); + EnFz_DrawIceSmoke(pthis, globalCtx); +} + +void EnFz_SpawnIceSmokeNoFreeze(EnFz* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale) { + EnFzEffectSsIceSmoke* iceSmoke = pthis->iceSmoke; + s16 i; + + for (i = 0; i < ARRAY_COUNT(pthis->iceSmoke); i++) { + if (iceSmoke->type == 0) { + iceSmoke->type = 1; + iceSmoke->pos = *pos; + iceSmoke->velocity = *velocity; + iceSmoke->accel = *accel; + iceSmoke->primAlphaState = 0; + iceSmoke->xyScale = xyScale / 1000.0f; + iceSmoke->primAlpha = 0; + iceSmoke->timer = 0; + break; + } + + iceSmoke++; + } +} + +void EnFz_SpawnIceSmokeFreeze(EnFz* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, + s16 primAlpha, u8 isTimerMod8) { + EnFzEffectSsIceSmoke* iceSmoke = pthis->iceSmoke; + s16 i; + + for (i = 0; i < ARRAY_COUNT(pthis->iceSmoke); i++) { + if (iceSmoke->type == 0) { + iceSmoke->type = 2; + iceSmoke->pos = *pos; + iceSmoke->velocity = *velocity; + iceSmoke->accel = *accel; + iceSmoke->primAlphaState = 0; + iceSmoke->xyScale = xyScale / 1000.0f; + iceSmoke->xyScaleTarget = xyScaleTarget / 1000.0f; + iceSmoke->primAlpha = primAlpha; + iceSmoke->timer = 0; + iceSmoke->isTimerMod8 = isTimerMod8; + break; + } + + iceSmoke++; + } +} + +void EnFz_UpdateIceSmoke(EnFz* pthis, GlobalContext* globalCtx) { + EnFzEffectSsIceSmoke* iceSmoke = pthis->iceSmoke; + s16 i; + Vec3f pos; + + for (i = 0; i < ARRAY_COUNT(pthis->iceSmoke); i++) { + if (iceSmoke->type) { + iceSmoke->pos.x += iceSmoke->velocity.x; + iceSmoke->pos.y += iceSmoke->velocity.y; + iceSmoke->pos.z += iceSmoke->velocity.z; + iceSmoke->timer++; + iceSmoke->velocity.x += iceSmoke->accel.x; + iceSmoke->velocity.y += iceSmoke->accel.y; + iceSmoke->velocity.z += iceSmoke->accel.z; + if (iceSmoke->type == 1) { + if (iceSmoke->primAlphaState == 0) { // Becoming more opaque + iceSmoke->primAlpha += 10; + if (iceSmoke->primAlpha >= 100) { + iceSmoke->primAlphaState++; + } + } else { // Becoming more transparent + iceSmoke->primAlpha -= 3; + if (iceSmoke->primAlpha <= 0) { + iceSmoke->primAlpha = 0; + iceSmoke->type = 0; + } + } + } else if (iceSmoke->type == 2) { // Freezing + Math_ApproachF(&iceSmoke->xyScale, iceSmoke->xyScaleTarget, 0.1f, iceSmoke->xyScaleTarget / 10.0f); + if (iceSmoke->primAlphaState == 0) { // Becoming more opaque + if (iceSmoke->timer >= 7) { + iceSmoke->primAlphaState++; + } + } else { // Becoming more transparent, slows down + iceSmoke->accel.y = 2.0f; + iceSmoke->primAlpha -= 17; + iceSmoke->velocity.x *= 0.75f; + iceSmoke->velocity.z *= 0.75f; + if (iceSmoke->primAlpha <= 0) { + iceSmoke->primAlpha = 0; + iceSmoke->type = 0; + } + } + + if ((pthis->unusedTimer2 == 0) && (iceSmoke->primAlpha >= 101) && iceSmoke->isTimerMod8) { + pthis->collider3.dim.pos.x = (s16)iceSmoke->pos.x; + pthis->collider3.dim.pos.y = (s16)iceSmoke->pos.y; + pthis->collider3.dim.pos.z = (s16)iceSmoke->pos.z; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider3.base); + } + + pos.x = iceSmoke->pos.x; + pos.y = iceSmoke->pos.y + 10.0f; + pos.z = iceSmoke->pos.z; + + if ((iceSmoke->primAlphaState != 2) && EnFz_ReachedTarget(pthis, &pos)) { + iceSmoke->primAlphaState = 2; + iceSmoke->velocity.x = 0.0f; + iceSmoke->velocity.z = 0.0f; + } + } + } + iceSmoke++; + } +} + +void EnFz_DrawIceSmoke(EnFz* pthis, GlobalContext* globalCtx) { + EnFzEffectSsIceSmoke* iceSmoke = pthis->iceSmoke; + s16 i; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + u8 texLoaded = false; + + OPEN_DISPS(gfxCtx, "../z_en_fz.c", 1384); + + func_80093D84(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->iceSmoke); i++) { + if (iceSmoke->type > 0) { + gDPPipeSync(POLY_XLU_DISP++); + + if (!texLoaded) { + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamStartDL)); + texLoaded++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, iceSmoke->primAlpha); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 3 * (iceSmoke->timer + (3 * i)), + 15 * (iceSmoke->timer + (3 * i)), 32, 64, 1, 0, 0, 32, 32)); + Matrix_Translate(iceSmoke->pos.x, iceSmoke->pos.y, iceSmoke->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(iceSmoke->xyScale, iceSmoke->xyScale, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_fz.c", 1424), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamDL)); + } + + iceSmoke++; + } + + CLOSE_DISPS(gfxCtx, "../z_en_fz.c", 1430); +} diff --git a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.cpp similarity index 51% rename from src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c rename to src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.cpp index ce4b43065..109e90280 100644 --- a/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c +++ b/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.cpp @@ -39,17 +39,17 @@ void EnGSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void EnGSwitch_DrawRupee(Actor* thisx, GlobalContext* globalCtx); void EnGSwitch_DrawPot(Actor* thisx, GlobalContext* globalCtx); -void EnGSwitch_SilverRupeeTracker(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_SilverRupeeIdle(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_WaitForObject(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_SilverRupeeCollected(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_GalleryRupee(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_ArcheryPot(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_Kill(EnGSwitch* this, GlobalContext* globalCtx); +void EnGSwitch_SilverRupeeTracker(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_SilverRupeeIdle(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_WaitForObject(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_SilverRupeeCollected(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_GalleryRupee(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_ArcheryPot(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_Kill(EnGSwitch* pthis, GlobalContext* globalCtx); -void EnGSwitch_SpawnEffects(EnGSwitch* this, Vec3f* pos, s16 scale, s16 colorIdx); -void EnGSwitch_UpdateEffects(EnGSwitch* this, GlobalContext* globalCtx); -void EnGSwitch_DrawEffects(EnGSwitch* this, GlobalContext* globalCtx); +void EnGSwitch_SpawnEffects(EnGSwitch* pthis, Vec3f* pos, s16 scale, s16 colorIdx); +void EnGSwitch_UpdateEffects(EnGSwitch* pthis, GlobalContext* globalCtx); +void EnGSwitch_DrawEffects(EnGSwitch* pthis, GlobalContext* globalCtx); static s16 sCollectedCount = 0; @@ -78,7 +78,7 @@ static s16 sRupeeTypes[] = { ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_ORANGE, ITEM00_RUPEE_PURPLE, }; -const ActorInit En_G_Switch_InitVars = { +ActorInit En_G_Switch_InitVars = { ACTOR_EN_G_SWITCH, ACTORCAT_PROP, FLAGS, @@ -92,291 +92,291 @@ const ActorInit En_G_Switch_InitVars = { void EnGSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnGSwitch* this = (EnGSwitch*)thisx; + EnGSwitch* pthis = (EnGSwitch*)thisx; - this->type = (this->actor.params >> 0xC) & 0xF; - this->switchFlag = this->actor.params & 0x3F; - this->numEffects = ARRAY_COUNT(this->effects); + pthis->type = (pthis->actor.params >> 0xC) & 0xF; + pthis->switchFlag = pthis->actor.params & 0x3F; + pthis->numEffects = ARRAY_COUNT(pthis->effects); // "index" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ インデックス ☆☆☆☆☆ %x\n" VT_RST, this->type); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ インデックス ☆☆☆☆☆ %x\n" VT_RST, pthis->type); // "save" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ\t ☆☆☆☆☆ %x\n" VT_RST, this->switchFlag); - switch (this->type) { + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ\t ☆☆☆☆☆ %x\n" VT_RST, pthis->switchFlag); + switch (pthis->type) { case ENGSWITCH_SILVER_TRACKER: osSyncPrintf("\n\n"); // "parent switch spawn" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 親スイッチ発生 ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 親スイッチ発生 ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); sCollectedCount = 0; - this->silverCount = this->actor.params >> 6; - this->silverCount &= 0x3F; + pthis->silverCount = pthis->actor.params >> 6; + pthis->silverCount &= 0x3F; // "maximum number of checks" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 最大チェック数 ☆☆☆☆☆ %d\n" VT_RST, this->silverCount); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 最大チェック数 ☆☆☆☆☆ %d\n" VT_RST, pthis->silverCount); osSyncPrintf("\n\n"); - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { // This is a reference to Hokuto no Ken - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - Actor_Kill(&this->actor); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + Actor_Kill(&pthis->actor); } else { - this->actionFunc = EnGSwitch_SilverRupeeTracker; + pthis->actionFunc = EnGSwitch_SilverRupeeTracker; } break; case ENGSWITCH_SILVER_RUPEE: osSyncPrintf("\n\n"); // "child switch spawn" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 子スイッチ発生 ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); - this->colorIdx = 5; - this->numEffects = 20; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.draw = EnGSwitch_DrawRupee; - this->actor.shape.yOffset = 700.0f; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - Actor_Kill(&this->actor); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 子スイッチ発生 ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); + pthis->colorIdx = 5; + pthis->numEffects = 20; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.draw = EnGSwitch_DrawRupee; + pthis->actor.shape.yOffset = 700.0f; + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + Actor_Kill(&pthis->actor); } else { - Actor_SetScale(&this->actor, 0.03f); - this->actionFunc = EnGSwitch_SilverRupeeIdle; + Actor_SetScale(&pthis->actor, 0.03f); + pthis->actionFunc = EnGSwitch_SilverRupeeIdle; } break; case ENGSWITCH_ARCHERY_POT: osSyncPrintf("\n\n"); // "Horseback archery destructible pot" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ やぶさめぶち抜き壷 ☆☆☆☆☆ \n" VT_RST); - this->actor.gravity = -3.0f; - this->colorIdx = Rand_ZeroFloat(2.99f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.scale.x = 0.25f; - this->actor.scale.y = 0.45f; - this->actor.scale.z = 0.25f; - this->collider.info.bumper.dmgFlags = 0x1F820; - this->objId = OBJECT_TSUBO; - this->objIndex = Object_GetIndex(&globalCtx->objectCtx, this->objId); - if (this->objIndex < 0) { - Actor_Kill(&this->actor); + pthis->actor.gravity = -3.0f; + pthis->colorIdx = Rand_ZeroFloat(2.99f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.scale.x = 0.25f; + pthis->actor.scale.y = 0.45f; + pthis->actor.scale.z = 0.25f; + pthis->collider.info.bumper.dmgFlags = 0x1F820; + pthis->objId = OBJECT_TSUBO; + pthis->objIndex = Object_GetIndex(&globalCtx->objectCtx, pthis->objId); + if (pthis->objIndex < 0) { + Actor_Kill(&pthis->actor); // "what?" - osSyncPrintf(VT_FGCOL(PURPLE) " なにみの? %d\n" VT_RST "\n", this->objIndex); + osSyncPrintf(VT_FGCOL(PURPLE) " なにみの? %d\n" VT_RST "\n", pthis->objIndex); // "bank is funny" - osSyncPrintf(VT_FGCOL(CYAN) " バンクおかしいしぞ!%d\n" VT_RST "\n", this->actor.params); + osSyncPrintf(VT_FGCOL(CYAN) " バンクおかしいしぞ!%d\n" VT_RST "\n", pthis->actor.params); } - this->collider.dim.radius = 24; - this->collider.dim.height = 74; - this->collider.dim.yShift = 0; - this->actionFunc = EnGSwitch_WaitForObject; + pthis->collider.dim.radius = 24; + pthis->collider.dim.height = 74; + pthis->collider.dim.yShift = 0; + pthis->actionFunc = EnGSwitch_WaitForObject; break; case ENGSWITCH_TARGET_RUPEE: - this->actor.shape.yOffset = 700.0f; - Actor_SetScale(&this->actor, 0.05f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.draw = EnGSwitch_DrawRupee; - this->collider.dim.radius = 20; - this->collider.dim.height = 60; - this->collider.dim.yShift = 5; - this->actionFunc = EnGSwitch_GalleryRupee; + pthis->actor.shape.yOffset = 700.0f; + Actor_SetScale(&pthis->actor, 0.05f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.draw = EnGSwitch_DrawRupee; + pthis->collider.dim.radius = 20; + pthis->collider.dim.height = 60; + pthis->collider.dim.yShift = 5; + pthis->actionFunc = EnGSwitch_GalleryRupee; break; } } void EnGSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnGSwitch* this = (EnGSwitch*)thisx; + EnGSwitch* pthis = (EnGSwitch*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void EnGSwitch_Break(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_Break(EnGSwitch* pthis, GlobalContext* globalCtx) { Vec3f randPos; Vec3f hitPos; Vec3f accel = { 0.0f, 0.0f, 0.0f }; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; s32 i; - randPos.x = this->actor.world.pos.x + Rand_CenteredFloat(40.0f); - randPos.y = this->actor.world.pos.y + 30.0f + Rand_CenteredFloat(35.0f); - randPos.z = this->actor.world.pos.z + Rand_CenteredFloat(40.0f); - hitPos.x = this->collider.info.bumper.hitPos.x; - hitPos.y = this->collider.info.bumper.hitPos.y; - hitPos.z = this->collider.info.bumper.hitPos.z; + randPos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(40.0f); + randPos.y = pthis->actor.world.pos.y + 30.0f + Rand_CenteredFloat(35.0f); + randPos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(40.0f); + hitPos.x = pthis->collider.info.bumper.hitPos.x; + hitPos.y = pthis->collider.info.bumper.hitPos.y; + hitPos.z = pthis->collider.info.bumper.hitPos.z; EffectSsHitMark_SpawnCustomScale(globalCtx, EFFECT_HITMARK_WHITE, 700, &hitPos); - if (this->type == ENGSWITCH_ARCHERY_POT) { + if (pthis->type == ENGSWITCH_ARCHERY_POT) { velocity.y = 15.0f; EffectSsExtra_Spawn(globalCtx, &hitPos, &velocity, &accel, 5, 2); } - if (this->type == ENGSWITCH_TARGET_RUPEE) { - for (i = 0; i < this->numEffects; i++) { - EnGSwitch_SpawnEffects(this, &randPos, 100, this->colorIdx); + if (pthis->type == ENGSWITCH_TARGET_RUPEE) { + for (i = 0; i < pthis->numEffects; i++) { + EnGSwitch_SpawnEffects(pthis, &randPos, 100, pthis->colorIdx); } } } -void EnGSwitch_WaitForObject(EnGSwitch* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objIndex].vromStart); - this->actor.objBankIndex = this->objIndex; - this->actor.draw = EnGSwitch_DrawPot; - this->actionFunc = EnGSwitch_ArcheryPot; +void EnGSwitch_WaitForObject(EnGSwitch* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objIndex)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objIndex].vromStart.get()); + pthis->actor.objBankIndex = pthis->objIndex; + pthis->actor.draw = EnGSwitch_DrawPot; + pthis->actionFunc = EnGSwitch_ArcheryPot; } } -void EnGSwitch_SilverRupeeTracker(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_SilverRupeeTracker(EnGSwitch* pthis, GlobalContext* globalCtx) { static s8 majorScale[] = { 0, 2, 4, 5, 7 }; - if (this->noteIndex < sCollectedCount) { + if (pthis->noteIndex < sCollectedCount) { if (sCollectedCount < 5) { // "sound?" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 音? ☆☆☆☆☆ %d\n" VT_RST, this->noteIndex); - Audio_PlaySoundTransposed(&D_801333D4, NA_SE_EV_FIVE_COUNT_LUPY, majorScale[this->noteIndex]); - this->noteIndex = sCollectedCount; + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 音? ☆☆☆☆☆ %d\n" VT_RST, pthis->noteIndex); + Audio_PlaySoundTransposed(&D_801333D4, NA_SE_EV_FIVE_COUNT_LUPY, majorScale[pthis->noteIndex]); + pthis->noteIndex = sCollectedCount; } } - if (sCollectedCount >= this->silverCount) { + if (sCollectedCount >= pthis->silverCount) { // "It is now the end of the century." // This another reference to Hokuto no Ken. - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 時はまさに世紀末〜 ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 時はまさに世紀末〜 ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); // "Last!" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ らすとぉ! ☆☆☆☆☆ \n" VT_RST); - if ((globalCtx->sceneNum == SCENE_MEN) && (this->actor.room == 2)) { - Flags_SetTempClear(globalCtx, this->actor.room); + if ((globalCtx->sceneNum == SCENE_MEN) && (pthis->actor.room == 2)) { + Flags_SetTempClear(globalCtx, pthis->actor.room); } else { func_80078884(NA_SE_SY_CORRECT_CHIME); - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, pthis->switchFlag); } func_80078884(NA_SE_SY_GET_RUPY); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void EnGSwitch_SilverRupeeIdle(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_SilverRupeeIdle(EnGSwitch* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->actor.shape.rot.y += 0x800; - if (this->actor.xyzDistToPlayerSq < 900.0f) { + pthis->actor.shape.rot.y += 0x800; + if (pthis->actor.xyzDistToPlayerSq < 900.0f) { Rupees_ChangeBy(5); sCollectedCount++; func_80078884(NA_SE_SY_GET_RUPY); - this->actor.world.pos = player->actor.world.pos; - this->actor.world.pos.y += 40.0f; + pthis->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos.y += 40.0f; if (LINK_IS_ADULT) { - this->actor.world.pos.y += 20.0f; + pthis->actor.world.pos.y += 20.0f; } - this->actor.gravity = 0.0f; - this->killTimer = 15; - this->actionFunc = EnGSwitch_SilverRupeeCollected; + pthis->actor.gravity = 0.0f; + pthis->killTimer = 15; + pthis->actionFunc = EnGSwitch_SilverRupeeCollected; } } -void EnGSwitch_SilverRupeeCollected(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_SilverRupeeCollected(EnGSwitch* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->actor.shape.rot.y += 0x3C0; - if (this->killTimer == 0) { - Actor_Kill(&this->actor); + pthis->actor.shape.rot.y += 0x3C0; + if (pthis->killTimer == 0) { + Actor_Kill(&pthis->actor); return; } - this->actor.world.pos = player->actor.world.pos; - this->actor.world.pos.y = - player->actor.world.pos.y + 40.0f + (this->killTimer * 0.3f) * Math_SinS(this->killTimer * 0x3A98); + pthis->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos.y = + player->actor.world.pos.y + 40.0f + (pthis->killTimer * 0.3f) * Math_SinS(pthis->killTimer * 0x3A98); if (LINK_IS_ADULT) { - this->actor.world.pos.y += 20.0f; + pthis->actor.world.pos.y += 20.0f; } } -void EnGSwitch_GalleryRupee(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_GalleryRupee(EnGSwitch* pthis, GlobalContext* globalCtx) { EnSyatekiItm* gallery; - this->actor.shape.rot.y += 0x3C0; - if (this->delayTimer == 0) { - switch (this->moveMode) { + pthis->actor.shape.rot.y += 0x3C0; + if (pthis->delayTimer == 0) { + switch (pthis->moveMode) { case GSWITCH_THROW: - Actor_MoveForward(&this->actor); - if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f))) { - gallery = ((EnSyatekiItm*)this->actor.parent); - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; + Actor_MoveForward(&pthis->actor); + if ((pthis->actor.velocity.y < 0.0f) && (pthis->actor.world.pos.y < (pthis->actor.home.pos.y - 50.0f))) { + gallery = ((EnSyatekiItm*)pthis->actor.parent); + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; if (gallery->actor.update != NULL) { - gallery->targetState[this->index] = ENSYATEKIHIT_MISS; + gallery->targetState[pthis->index] = ENSYATEKIHIT_MISS; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; case GSWITCH_LEFT: - func_8002D7EC(&this->actor); - if ((this->actor.velocity.x < 0.0f) && (this->actor.world.pos.x < this->targetPos.x)) { - gallery = ((EnSyatekiItm*)this->actor.parent); + func_8002D7EC(&pthis->actor); + if ((pthis->actor.velocity.x < 0.0f) && (pthis->actor.world.pos.x < pthis->targetPos.x)) { + gallery = ((EnSyatekiItm*)pthis->actor.parent); if (gallery->actor.update != NULL) { - gallery->targetState[this->index] = ENSYATEKIHIT_MISS; + gallery->targetState[pthis->index] = ENSYATEKIHIT_MISS; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; case GSWITCH_RIGHT: - func_8002D7EC(&this->actor); - if (this->actor.world.pos.x > this->targetPos.x) { - gallery = ((EnSyatekiItm*)this->actor.parent); + func_8002D7EC(&pthis->actor); + if (pthis->actor.world.pos.x > pthis->targetPos.x) { + gallery = ((EnSyatekiItm*)pthis->actor.parent); if (gallery->actor.update != NULL) { - gallery->targetState[this->index] = ENSYATEKIHIT_MISS; + gallery->targetState[pthis->index] = ENSYATEKIHIT_MISS; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; default: - switch (this->moveState) { + switch (pthis->moveState) { case MOVE_TARGET: - if ((fabsf(this->actor.world.pos.x - this->targetPos.x) > 5.0f) || - (fabsf(this->actor.world.pos.y - this->targetPos.y) > 5.0f)) { - Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.3f, 30.0f); - Math_ApproachF(&this->actor.world.pos.y, this->targetPos.y, 0.3f, 30.0f); + if ((fabsf(pthis->actor.world.pos.x - pthis->targetPos.x) > 5.0f) || + (fabsf(pthis->actor.world.pos.y - pthis->targetPos.y) > 5.0f)) { + Math_ApproachF(&pthis->actor.world.pos.x, pthis->targetPos.x, 0.3f, 30.0f); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetPos.y, 0.3f, 30.0f); } else { - this->moveState = MOVE_HOME; - this->waitTimer = 60; + pthis->moveState = MOVE_HOME; + pthis->waitTimer = 60; } break; case MOVE_HOME: - if (this->waitTimer == 0) { - if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 5.0f) || - (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) > 5.0f)) { - Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 30.0f); - Math_ApproachF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 30.0f); + if (pthis->waitTimer == 0) { + if ((fabsf(pthis->actor.world.pos.x - pthis->actor.home.pos.x) > 5.0f) || + (fabsf(pthis->actor.world.pos.y - pthis->actor.home.pos.y) > 5.0f)) { + Math_ApproachF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 0.3f, 30.0f); + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.3f, 30.0f); } else { - gallery = ((EnSyatekiItm*)this->actor.parent); + gallery = ((EnSyatekiItm*)pthis->actor.parent); if (gallery->actor.update != NULL) { - gallery->targetState[this->index] = ENSYATEKIHIT_MISS; + gallery->targetState[pthis->index] = ENSYATEKIHIT_MISS; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } break; } break; } - if ((this->collider.base.acFlags & AC_HIT) || BREG(8)) { - gallery = ((EnSyatekiItm*)this->actor.parent); - this->collider.base.acFlags &= ~AC_HIT; + if ((pthis->collider.base.acFlags & AC_HIT) || BREG(8)) { + gallery = ((EnSyatekiItm*)pthis->actor.parent); + pthis->collider.base.acFlags &= ~AC_HIT; if (gallery->actor.update != NULL) { gallery->hitCount++; - gallery->targetState[this->index] = ENSYATEKIHIT_HIT; + gallery->targetState[pthis->index] = ENSYATEKIHIT_HIT; func_80078884(NA_SE_EV_HIT_SOUND); func_80078884(NA_SE_SY_GET_RUPY); // "Yeah !" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ いぇぇーす!HIT!! ☆☆☆☆☆ %d\n" VT_RST, gallery->hitCount); - EnGSwitch_Break(this, globalCtx); - this->killTimer = 50; - this->broken = true; - this->actionFunc = EnGSwitch_Kill; + EnGSwitch_Break(pthis, globalCtx); + pthis->killTimer = 50; + pthis->broken = true; + pthis->actionFunc = EnGSwitch_Kill; } } } } -void EnGSwitch_ArcheryPot(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_ArcheryPot(EnGSwitch* pthis, GlobalContext* globalCtx) { s32 i; s16 angle; - Vec3f* thisPos = &this->actor.world.pos; + Vec3f* thisPos = &pthis->actor.world.pos; - this->actor.shape.rot.y += 0x3C0; - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; + pthis->actor.shape.rot.y += 0x3C0; + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; for (i = 0, angle = 0; i < 30; i++, angle += 0x4E20) { Vec3f pos; Vec3f vel; @@ -415,54 +415,54 @@ void EnGSwitch_ArcheryPot(EnGSwitch* this, GlobalContext* globalCtx) { } func_80033480(globalCtx, thisPos, 30.0f, 4, 20, 50, 0); Audio_PlaySoundAtPosition(globalCtx, thisPos, 40, NA_SE_EV_POT_BROKEN); - EnGSwitch_Break(this, globalCtx); - this->killTimer = 50; - this->broken = true; - this->actionFunc = EnGSwitch_Kill; + EnGSwitch_Break(pthis, globalCtx); + pthis->killTimer = 50; + pthis->broken = true; + pthis->actionFunc = EnGSwitch_Kill; } } -void EnGSwitch_Kill(EnGSwitch* this, GlobalContext* globalCtx) { - if (this->killTimer == 0) { - Actor_Kill(&this->actor); +void EnGSwitch_Kill(EnGSwitch* pthis, GlobalContext* globalCtx) { + if (pthis->killTimer == 0) { + Actor_Kill(&pthis->actor); } } void EnGSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnGSwitch* this = (EnGSwitch*)thisx; + EnGSwitch* pthis = (EnGSwitch*)thisx; - this->actionFunc(this, globalCtx); - if (this->killTimer != 0) { - this->killTimer--; + pthis->actionFunc(pthis, globalCtx); + if (pthis->killTimer != 0) { + pthis->killTimer--; } - if (this->waitTimer != 0) { - this->waitTimer--; + if (pthis->waitTimer != 0) { + pthis->waitTimer--; } - if (this->delayTimer != 0) { - this->delayTimer--; + if (pthis->delayTimer != 0) { + pthis->delayTimer--; } - if ((this->type != ENGSWITCH_SILVER_TRACKER) && (this->type != ENGSWITCH_SILVER_RUPEE) && - (this->type != ENGSWITCH_TARGET_RUPEE)) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); + if ((pthis->type != ENGSWITCH_SILVER_TRACKER) && (pthis->type != ENGSWITCH_SILVER_RUPEE) && + (pthis->type != ENGSWITCH_TARGET_RUPEE)) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 0x1C); } - if (this->actor.draw != NULL) { - if (this->type == ENGSWITCH_TARGET_RUPEE) { - EnGSwitch_UpdateEffects(this, globalCtx); + if (pthis->actor.draw != NULL) { + if (pthis->type == ENGSWITCH_TARGET_RUPEE) { + EnGSwitch_UpdateEffects(pthis, globalCtx); } - if ((this->actionFunc != EnGSwitch_Kill) && (this->actionFunc != EnGSwitch_SilverRupeeIdle)) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((pthis->actionFunc != EnGSwitch_Kill) && (pthis->actionFunc != EnGSwitch_SilverRupeeIdle)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } } void EnGSwitch_DrawPot(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnGSwitch* this = (EnGSwitch*)thisx; + EnGSwitch* pthis = (EnGSwitch*)thisx; - if (!this->broken) { + if (!pthis->broken) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_g_switch.c", 918); func_80093D18(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_g_switch.c", 925), @@ -478,29 +478,29 @@ static void* sRupeeTextures[] = { void EnGSwitch_DrawRupee(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnGSwitch* this = (EnGSwitch*)thisx; + EnGSwitch* pthis = (EnGSwitch*)thisx; if (1) {} - if (!this->broken) { + if (!pthis->broken) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_g_switch.c", 951); func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_g_switch.c", 957), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sRupeeTextures[this->colorIdx])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sRupeeTextures[pthis->colorIdx])); gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_g_switch.c", 961); } - if (this->type == ENGSWITCH_TARGET_RUPEE) { - EnGSwitch_DrawEffects(this, globalCtx); + if (pthis->type == ENGSWITCH_TARGET_RUPEE) { + EnGSwitch_DrawEffects(pthis, globalCtx); } } -void EnGSwitch_SpawnEffects(EnGSwitch* this, Vec3f* pos, s16 scale, s16 colorIdx) { - EnGSwitchEffect* effect = this->effects; +void EnGSwitch_SpawnEffects(EnGSwitch* pthis, Vec3f* pos, s16 scale, s16 colorIdx) { + EnGSwitchEffect* effect = pthis->effects; s16 i; - for (i = 0; i < this->numEffects; i++, effect++) { + for (i = 0; i < pthis->numEffects; i++, effect++) { if (!effect->flag) { Vec3f baseVel; f32 pitch; @@ -524,12 +524,12 @@ void EnGSwitch_SpawnEffects(EnGSwitch* this, Vec3f* pos, s16 scale, s16 colorIdx } } -void EnGSwitch_UpdateEffects(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_UpdateEffects(EnGSwitch* pthis, GlobalContext* globalCtx) { Vec3f temp; s16 i; - EnGSwitchEffect* effect = this->effects; + EnGSwitchEffect* effect = pthis->effects; - for (i = 0; i < this->numEffects; i++, effect++) { + for (i = 0; i < pthis->numEffects; i++, effect++) { if (effect->flag) { effect->rot.x += Rand_ZeroOne() * 10.0f + 15.0f; effect->rot.y += Rand_ZeroOne() * 10.0f + 15.0f; @@ -552,16 +552,16 @@ void EnGSwitch_UpdateEffects(EnGSwitch* this, GlobalContext* globalCtx) { } } -void EnGSwitch_DrawEffects(EnGSwitch* this, GlobalContext* globalCtx) { +void EnGSwitch_DrawEffects(EnGSwitch* pthis, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnGSwitchEffect* effect = this->effects; + EnGSwitchEffect* effect = pthis->effects; s16 i; f32 scale; s32 pad; OPEN_DISPS(gfxCtx, "../z_en_g_switch.c", 1073); func_80093D18(globalCtx->state.gfxCtx); - for (i = 0; i < this->numEffects; i++, effect++) { + for (i = 0; i < pthis->numEffects; i++, effect++) { if (effect->flag) { scale = effect->scale / 10000.0f; Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.c b/src/overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.cpp similarity index 78% rename from src/overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.c rename to src/overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.cpp index f80c1cd19..1a7755574 100644 --- a/src/overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.c +++ b/src/overlays/actors/ovl_En_Ganon_Mant/z_en_ganon_mant.cpp @@ -22,7 +22,7 @@ void EnGanonMant_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGanonMant_Update(Actor* thisx, GlobalContext* globalCtx); void EnGanonMant_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Ganon_Mant_InitVars = { +ActorInit En_Ganon_Mant_InitVars = { ACTOR_EN_GANON_MANT, ACTORCAT_BOSS, FLAGS, @@ -52,7 +52,7 @@ typedef struct { } TearShape; // size = 0x8 /** - * The arrays pointed to by this table describe how many pixels should + * The arrays pointed to by pthis table describe how many pixels should * be removed from the cloak texture in a single pass */ static TearShape sTearShapes[] = { @@ -105,12 +105,12 @@ static u16 sVerticesMap[GANON_MANT_NUM_STRANDS * GANON_MANT_NUM_JOINTS] = { static u64 sForceAlignment = 0; -#include "overlays/ovl_En_Ganon_Mant/ovl_En_Ganon_Mant.c" +#include "overlays/ovl_En_Ganon_Mant/ovl_En_Ganon_Mant.cpp" void EnGanonMant_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGanonMant* this = (EnGanonMant*)thisx; + EnGanonMant* pthis = (EnGanonMant*)thisx; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } void EnGanonMant_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -119,7 +119,7 @@ void EnGanonMant_Destroy(Actor* thisx, GlobalContext* globalCtx) { /** * Randomly zeros portions of the cloak texture */ -void EnGanonMant_Tear(EnGanonMant* this) { +void EnGanonMant_Tear(EnGanonMant* pthis) { s32 pad; s16 i; s16 areaX; @@ -152,7 +152,7 @@ void EnGanonMant_Tear(EnGanonMant* this) { } for (i = 0; i < 4; i++) { - this->strands[(s16)Rand_ZeroFloat(GANON_MANT_NUM_STRANDS - 0.1f)] + pthis->strands[(s16)Rand_ZeroFloat(GANON_MANT_NUM_STRANDS - 0.1f)] .torn[(s16)Rand_ZeroFloat(GANON_MANT_NUM_JOINTS - 0.1f)] = true; } } @@ -160,7 +160,7 @@ void EnGanonMant_Tear(EnGanonMant* this) { /** * Updates the dynamic strands that control the shape and motion of the cloak */ -void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* this, Vec3f* root, Vec3f* pos, Vec3f* nextPos, +void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* pthis, Vec3f* root, Vec3f* pos, Vec3f* nextPos, Vec3f* rot, Vec3f* vel, s16 strandNum) { f32 xDiff; f32 zDiff; @@ -178,11 +178,11 @@ void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* this, Vec3f Vec3f sideSwayOffset; delta.y = 0; - if (this->actor.params == 0x23) { + if (pthis->actor.params == 0x23) { // Pushes all the strands away from the actor delta.x = 0.0f; delta.z = -30.0f; - Matrix_RotateY(BINANG_TO_RAD(this->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateY(BINANG_TO_RAD(pthis->actor.shape.rot.y), MTXMODE_NEW); Matrix_MultVec3f(&delta, &posStep); for (i = 0; i < GANON_MANT_NUM_JOINTS; i++) { (pos + i)->x += posStep.x; @@ -208,19 +208,19 @@ void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* this, Vec3f // Push the cloak away from attached actor, plus oscillations delta.x = 0; - delta.z = (this->backPush + (sinf((strandNum * (2 * M_PI)) / 2.1f) * this->backSwayMagnitude)) * + delta.z = (pthis->backPush + (sinf((strandNum * (2 * M_PI)) / 2.1f) * pthis->backSwayMagnitude)) * sBackSwayCoefficients[i]; - Matrix_RotateY(this->baseYaw, MTXMODE_NEW); + Matrix_RotateY(pthis->baseYaw, MTXMODE_NEW); Matrix_MultVec3f(&delta, &backSwayOffset); // Push the cloak out to either side, in a swaying manner - delta.x = cosf((strandNum * M_PI) / (GANON_MANT_NUM_STRANDS - 1.0f)) * this->sideSwayMagnitude * + delta.x = cosf((strandNum * M_PI) / (GANON_MANT_NUM_STRANDS - 1.0f)) * pthis->sideSwayMagnitude * sSideSwayCoefficients[i]; delta.z = 0; Matrix_MultVec3f(&delta, &sideSwayOffset); // Calculate position difference - gravity = this->gravity; + gravity = pthis->gravity; x = ((pos->x + vel->x) - (pos - 1)->x) + (backSwayOffset.x + sideSwayOffset.x); y = ((pos->y + vel->y) - (pos - 1)->y) + gravity; z = ((pos->z + vel->z) - (pos - 1)->z) + (backSwayOffset.z + sideSwayOffset.z); @@ -248,20 +248,20 @@ void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* this, Vec3f pos->z = (pos - 1)->z + posStep.z; // Pushes the cloak away from the actor if it is too close - xDiff = pos->x - this->actor.world.pos.x; - zDiff = pos->z - this->actor.world.pos.z; - if (sqrtf(SQ(xDiff) + SQ(zDiff)) < (sDistMultipliers[i] * this->minDist)) { + xDiff = pos->x - pthis->actor.world.pos.x; + zDiff = pos->z - pthis->actor.world.pos.z; + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < (sDistMultipliers[i] * pthis->minDist)) { yaw = Math_Atan2F(zDiff, xDiff); - delta.z = this->minDist * sDistMultipliers[i]; + delta.z = pthis->minDist * sDistMultipliers[i]; Matrix_RotateY(yaw, MTXMODE_NEW); Matrix_MultVec3f(&delta, &posStep); - pos->x = this->actor.world.pos.x + posStep.x; - pos->z = this->actor.world.pos.z + posStep.z; + pos->x = pthis->actor.world.pos.x + posStep.x; + pos->z = pthis->actor.world.pos.z + posStep.z; } // Enforces minY constraint - if (pos->y < this->minY) { - pos->y = this->minY; + if (pos->y < pthis->minY) { + pos->y = pthis->minY; } // Calculate next velocity @@ -269,7 +269,7 @@ void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* this, Vec3f vel->y = (pos->y - y) * 80.0f / 100.0f; vel->z = (pos->z - z) * 80.0f / 100.0f; - if (this->actor.params != 0x23) { + if (pthis->actor.params != 0x23) { // Clamp elements of vel into [-5.0, 5.0] if (vel->x > 5.0f) { vel->x = 5.0f; @@ -301,7 +301,7 @@ void EnGanonMant_UpdateStrand(GlobalContext* globalCtx, EnGanonMant* this, Vec3f /** * Update the cloak vertices using the current state of the strands */ -void EnGanonMant_UpdateVertices(EnGanonMant* this) { +void EnGanonMant_UpdateVertices(EnGanonMant* pthis) { s16 i; Vtx* vtx; Vtx* vertices; @@ -311,7 +311,7 @@ void EnGanonMant_UpdateVertices(EnGanonMant* this) { Vec3f up; Vec3f normal; - if (this->frameTimer % 2 != 0) { + if (pthis->frameTimer % 2 != 0) { vertices = SEGMENTED_TO_VIRTUAL(gMant1Vtx); } else { vertices = SEGMENTED_TO_VIRTUAL(gMant2Vtx); @@ -320,7 +320,7 @@ void EnGanonMant_UpdateVertices(EnGanonMant* this) { up.y = 30.0f; up.z = 0.0f; - strand = &this->strands[0]; + strand = &pthis->strands[0]; for (i = 0; i < GANON_MANT_NUM_STRANDS; i++, strand++) { for (j = 0, k = 0; j < GANON_MANT_NUM_JOINTS; j++, k += GANON_MANT_NUM_JOINTS) { vtx = &vertices[sVerticesMap[i + k]]; @@ -338,32 +338,32 @@ void EnGanonMant_UpdateVertices(EnGanonMant* this) { } void EnGanonMant_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGanonMant* this = (EnGanonMant*)thisx; - BossGanon* ganon = (BossGanon*)this->actor.parent; + EnGanonMant* pthis = (EnGanonMant*)thisx; + BossGanon* ganon = (BossGanon*)pthis->actor.parent; - this->updateHasRun = true; - this->frameTimer++; + pthis->updateHasRun = true; + pthis->frameTimer++; - if (this->attachLeftArmTimer == 0.0f) { + if (pthis->attachLeftArmTimer == 0.0f) { } else { - this->attachLeftArmTimer -= 1.0f; + pthis->attachLeftArmTimer -= 1.0f; } - if (this->attachRightArmTimer != 0.0f) { - this->attachRightArmTimer -= 1.0f; + if (pthis->attachRightArmTimer != 0.0f) { + pthis->attachRightArmTimer -= 1.0f; } - if (this->attachShouldersTimer != 0.0f) { - this->attachShouldersTimer -= 1.0f; + if (pthis->attachShouldersTimer != 0.0f) { + pthis->attachShouldersTimer -= 1.0f; } - this->actor.shape.rot.y = ganon->actor.shape.rot.y; + pthis->actor.shape.rot.y = ganon->actor.shape.rot.y; - if (this->tearTimer != 0) { - this->tearTimer--; - EnGanonMant_Tear(this); + if (pthis->tearTimer != 0) { + pthis->tearTimer--; + EnGanonMant_Tear(pthis); } } -void EnGanonMant_DrawCloak(GlobalContext* globalCtx, EnGanonMant* this) { +void EnGanonMant_DrawCloak(GlobalContext* globalCtx, EnGanonMant* pthis) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ganon_mant.c", 564); @@ -378,7 +378,7 @@ void EnGanonMant_DrawCloak(GlobalContext* globalCtx, EnGanonMant* this) { // set vertices, vertices are double buffered to prevent // modification of vertices as they are being drawn - if (this->frameTimer % 2 != 0) { + if (pthis->frameTimer % 2 != 0) { gSPSegment(POLY_OPA_DISP++, 0x0C, gMant1Vtx); } else { gSPSegment(POLY_OPA_DISP++, 0x0C, gMant2Vtx); @@ -391,7 +391,7 @@ void EnGanonMant_DrawCloak(GlobalContext* globalCtx, EnGanonMant* this) { } void EnGanonMant_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGanonMant* this = (EnGanonMant*)thisx; + EnGanonMant* pthis = (EnGanonMant*)thisx; f32 xDiff; f32 pitch; Vec3f strandOffset; @@ -406,25 +406,25 @@ void EnGanonMant_Draw(Actor* thisx, GlobalContext* globalCtx) { Vec3f midpoint; s16 nextStrandIdx; - if (this->updateHasRun) { - // Only run this if update has run since last draw + if (pthis->updateHasRun) { + // Only run pthis if update has run since last draw // Choose endpoints - if (this->attachRightArmTimer != 0.0f) { - rightPos = &this->rightForearmPos; - leftPos = &this->leftShoulderPos; - this->gravity = -13.0f; - } else if (this->attachLeftArmTimer != 0.0f) { - rightPos = &this->rightShoulderPos; - leftPos = &this->leftForearmPos; - this->gravity = -13.0f; - } else if (this->attachShouldersTimer != 0.0f) { - rightPos = &this->rightShoulderPos; - leftPos = &this->leftShoulderPos; - this->gravity = -3.0f; + if (pthis->attachRightArmTimer != 0.0f) { + rightPos = &pthis->rightForearmPos; + leftPos = &pthis->leftShoulderPos; + pthis->gravity = -13.0f; + } else if (pthis->attachLeftArmTimer != 0.0f) { + rightPos = &pthis->rightShoulderPos; + leftPos = &pthis->leftForearmPos; + pthis->gravity = -13.0f; + } else if (pthis->attachShouldersTimer != 0.0f) { + rightPos = &pthis->rightShoulderPos; + leftPos = &pthis->leftShoulderPos; + pthis->gravity = -3.0f; } else { - rightPos = &this->rightForearmPos; - leftPos = &this->leftForearmPos; + rightPos = &pthis->rightForearmPos; + leftPos = &pthis->leftForearmPos; } xDiff = leftPos->x - rightPos->x; @@ -442,7 +442,7 @@ void EnGanonMant_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateY(yaw, MTXMODE_NEW); Matrix_RotateX(pitch, MTXMODE_APPLY); - this->baseYaw = yaw - M_PI / 2.0f; + pthis->baseYaw = yaw - M_PI / 2.0f; for (strandIdx = 0; strandIdx < GANON_MANT_NUM_STRANDS; strandIdx++) { Matrix_Push(); @@ -452,9 +452,9 @@ void EnGanonMant_Draw(Actor* thisx, GlobalContext* globalCtx) { strandOffset.y = 0; strandOffset.z = -cosf((strandIdx * M_PI) / (GANON_MANT_NUM_STRANDS - 1)) * diffHalfDist; Matrix_MultVec3f(&strandOffset, &strandDivPos); - this->strands[strandIdx].root.x = midpoint.x + strandDivPos.x; - this->strands[strandIdx].root.y = midpoint.y + strandDivPos.y; - this->strands[strandIdx].root.z = midpoint.z + strandDivPos.z; + pthis->strands[strandIdx].root.x = midpoint.x + strandDivPos.x; + pthis->strands[strandIdx].root.y = midpoint.y + strandDivPos.y; + pthis->strands[strandIdx].root.z = midpoint.z + strandDivPos.z; nextStrandIdx = strandIdx + 1; if (nextStrandIdx >= GANON_MANT_NUM_STRANDS) { @@ -462,14 +462,14 @@ void EnGanonMant_Draw(Actor* thisx, GlobalContext* globalCtx) { } // Update the strand joints - EnGanonMant_UpdateStrand(globalCtx, this, &this->strands[strandIdx].root, this->strands[strandIdx].joints, - this->strands[nextStrandIdx].joints, this->strands[strandIdx].rotations, - this->strands[strandIdx].velocities, strandIdx); + EnGanonMant_UpdateStrand(globalCtx, pthis, &pthis->strands[strandIdx].root, pthis->strands[strandIdx].joints, + pthis->strands[nextStrandIdx].joints, pthis->strands[strandIdx].rotations, + pthis->strands[strandIdx].velocities, strandIdx); Matrix_Pop(); } - EnGanonMant_UpdateVertices(this); - this->updateHasRun = false; + EnGanonMant_UpdateVertices(pthis); + pthis->updateHasRun = false; } - EnGanonMant_DrawCloak(globalCtx, this); + EnGanonMant_DrawCloak(globalCtx, pthis); } diff --git a/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c b/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.cpp similarity index 92% rename from src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c rename to src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.cpp index 7d111c1c7..7ceb824f2 100644 --- a/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c +++ b/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.cpp @@ -20,7 +20,7 @@ void EnGanonOrgan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGanonOrgan_Update(Actor* thisx, GlobalContext* globalCtx); void EnGanonOrgan_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Ganon_Organ_InitVars = { +ActorInit En_Ganon_Organ_InitVars = { ACTOR_EN_GANON_ORGAN, ACTORCAT_BOSS, FLAGS, @@ -34,7 +34,7 @@ const ActorInit En_Ganon_Organ_InitVars = { static u64 sForceAlignment = 0; -#include "overlays/ovl_En_Ganon_Organ/ovl_En_Ganon_Organ.c" +#include "overlays/ovl_En_Ganon_Organ/ovl_En_Ganon_Organ.cpp" void EnGanonOrgan_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->flags &= ~ACTOR_FLAG_0; @@ -59,7 +59,7 @@ void EnGanonOrgan_Update(Actor* thisx, GlobalContext* globalCtx) { Gfx* EnGanonOrgan_EmptyDList(GraphicsContext* gfxCtx) { Gfx* displayList; - displayList = Graph_Alloc(gfxCtx, sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); gSPEndDisplayList(displayList); return displayList; } @@ -68,7 +68,7 @@ Gfx* func_80A280BC(GraphicsContext* gfxCtx, BossGanon* dorf) { Gfx* displayList; Gfx* displayListHead; - displayList = Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); displayListHead = displayList; gDPPipeSync(displayListHead++); if (1) {} @@ -83,7 +83,7 @@ Gfx* func_80A28148(GraphicsContext* gfxCtx, BossGanon* dorf) { Gfx* displayList; Gfx* displayListHead; - displayList = Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); + displayList = (Gfx*)Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); displayListHead = displayList; gDPPipeSync(displayListHead++); diff --git a/src/overlays/actors/ovl_En_Gb/z_en_gb.c b/src/overlays/actors/ovl_En_Gb/z_en_gb.c deleted file mode 100644 index 20f91f08f..000000000 --- a/src/overlays/actors/ovl_En_Gb/z_en_gb.c +++ /dev/null @@ -1,569 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GB_Z_EN_GB_C -#include "actor_common.h" -/* - * File: z_en_gb.c - * Overlay: ovl_En_Gb - * Description: Poe Seller - */ - -#include "z_en_gb.h" -#include "objects/object_ps/object_ps.h" -#include "def/code_80043480.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnGb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGb_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A2F83C(EnGb* this, GlobalContext* globalCtx); -void func_80A2FC70(EnGb* this, GlobalContext* globalCtx); -void func_80A2FA50(EnGb* this, GlobalContext* globalCtx); -void func_80A2F9C0(EnGb* this, GlobalContext* globalCtx); -void func_80A2F94C(EnGb* this, GlobalContext* globalCtx); -void func_80A2FB40(EnGb* this, GlobalContext* globalCtx); -void func_80A2FBB0(EnGb* this, GlobalContext* globalCtx); -void func_80A2FC0C(EnGb* this, GlobalContext* globalCtx); - -void EnGb_DrawCagedSouls(EnGb* this, GlobalContext* globalCtx); -void EnGb_UpdateCagedSouls(EnGb* this, GlobalContext* globalCtx); - -const ActorInit En_Gb_InitVars = { - ACTOR_EN_GB, - ACTORCAT_NPC, - FLAGS, - OBJECT_PS, - sizeof(EnGb), - (ActorFunc)EnGb_Init, - (ActorFunc)EnGb_Destroy, - (ActorFunc)EnGb_Update, - (ActorFunc)EnGb_Draw, -}; - -static EnGbCagedSoulInfo sCagedSoulInfo[] = { - { { 255, 255, 170, 255 }, { 255, 200, 0, 255 }, gPoeSellerAngrySoulTex, -15 }, - { { 255, 255, 170, 255 }, { 0, 150, 0, 255 }, gPoeSellerHappySoulTex, -12 }, - { { 255, 170, 255, 255 }, { 100, 0, 150, 255 }, gPoeSellerSadSoulTex, -8 }, -}; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 40, 75, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInitType1 sBottlesCylindersInit[] = { - { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 4, 20, 0, { 0, 0, 0 } }, - }, - { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 4, 20, 0, { 0, 0, 0 } }, - }, - { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 10, 20, 0, { 0, 0, 0 } }, - }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2200, ICHAIN_STOP), -}; - -// relative positions of poe souls -static Vec3f sCagedSoulPositions[] = { - { -8.0f, 112.0f, -8.0f }, - { -3.0f, 112.0f, 29.0f }, - { 31.0f, 112.0f, 29.0f }, - { 31.0f, 112.0f, -8.0f }, -}; - -// relative positions of bottles -static Vec3f sBottlesPositions[] = { - { -48.0f, 0.0f, 34.0f }, - { -55.0f, 0.0f, 49.0f }, - { -48.0f, 0.0f, 60.0f }, -}; - -void func_80A2F180(EnGb* this) { - if (gSaveContext.infTable[0xB] & 0x40) { - this->textId = 0x70F5; - } else { - this->textId = 0x70F4; - } -} - -void EnGb_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGb* this = (EnGb*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - s32 i; - f32 rand; - Vec3f focusOffset; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&gPoeSellerCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gPoeSellerSkel, &gPoeSellerIdleAnim, this->jointTable, - this->morphTable, 12); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - - for (i = 0; i < ARRAY_COUNT(sBottlesCylindersInit); i++) { - Collider_InitCylinder(globalCtx, &this->bottlesColliders[i]); - Collider_SetCylinderType1(globalCtx, &this->bottlesColliders[i], &this->dyna.actor, &sBottlesCylindersInit[i]); - } - - this->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, - this->dyna.actor.home.pos.z, 255, 255, 255, 200); - - ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - Actor_SetScale(&this->dyna.actor, 0.01f); - this->dyna.actor.colChkInfo.mass = 0xFF; - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.gravity = -1.0f; - this->actionTimer = (s16)Rand_ZeroFloat(100.0f) + 100; - - for (i = 0; i < ARRAY_COUNT(sCagedSoulPositions); i++) { - this->cagedSouls[i].infoIdx = (s32)Rand_ZeroFloat(30.0f) % 3; - this->cagedSouls[i].unk_14.x = this->cagedSouls[i].translation.x = - sCagedSoulPositions[i].x + this->dyna.actor.world.pos.x; - this->cagedSouls[i].unk_14.y = this->cagedSouls[i].translation.y = - sCagedSoulPositions[i].y + this->dyna.actor.world.pos.y; - this->cagedSouls[i].unk_14.z = this->cagedSouls[i].translation.z = - sCagedSoulPositions[i].z + this->dyna.actor.world.pos.z; - this->cagedSouls[i].unk_1 = 1; - this->cagedSouls[i].unk_3 = this->cagedSouls[i].unk_2 = 0; - this->cagedSouls[i].unk_20 = this->cagedSouls[i].unk_24 = 0.0f; - this->cagedSouls[i].unk_6 = Rand_ZeroFloat(40.0f); - this->cagedSouls[i].rotate180 = this->cagedSouls[i].unk_6 & 1; - this->cagedSouls[i].unk_28 = 0.2f; - } - - rand = Rand_ZeroOne(); - this->lightColor.r = (s8)(rand * 30.0f) + 225; - this->lightColor.g = (s8)(rand * 100.0f) + 155; - this->lightColor.b = (s8)(rand * 160.0f) + 95; - this->lightColor.a = 200; - Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateZYX(this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, - MTXMODE_APPLY); - focusOffset.x = focusOffset.y = 0.0f; - focusOffset.z = 44.0f; - Matrix_MultVec3f(&focusOffset, &this->dyna.actor.focus.pos); - this->dyna.actor.focus.pos.y += 62.5f; - func_80A2F180(this); - this->actionFunc = func_80A2F83C; -} - -void EnGb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGb* this = (EnGb*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->light); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80A2F608(EnGb* this) { - s32 i; - Vec3f sp48; - Vec3f sp3C; - - Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateZYX(this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, - MTXMODE_APPLY); - sp48.x = sp48.y = 0.0f; - sp48.z = 25.0f; - Matrix_MultVec3f(&sp48, &sp3C); - this->collider.dim.pos.x = sp3C.x; - this->collider.dim.pos.y = sp3C.y; - this->collider.dim.pos.z = sp3C.z; - - for (i = 0; i < ARRAY_COUNT(sBottlesPositions); i++) { - Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateZYX(this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, - MTXMODE_APPLY); - Matrix_MultVec3f(&sBottlesPositions[i], &sp3C); - this->bottlesColliders[i].dim.pos.x = sp3C.x; - this->bottlesColliders[i].dim.pos.y = sp3C.y; - this->bottlesColliders[i].dim.pos.z = sp3C.z; - } -} - -s32 func_80A2F760(EnGb* this) { - s32 i; - for (i = 0; i < ARRAY_COUNT(this->cagedSouls); i++) { - if (this->cagedSouls[i].unk_3) { - return 1; - } - } - return 0; -} - -void func_80A2F7C0(EnGb* this) { - Animation_Change(&this->skelAnime, &gPoeSellerSwingStickAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gPoeSellerSwingStickAnim), ANIMMODE_ONCE, 0.0f); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_NALE_MAGIC); - this->actionFunc = func_80A2FC70; -} - -void func_80A2F83C(EnGb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (!func_80A2F760(this)) { - if (this->actionTimer != 0) { - this->actionTimer--; - } else { - func_80A2F7C0(this); - return; - } - } - if (Actor_ProcessTalkRequest(&this->dyna.actor, globalCtx)) { - switch (func_8002F368(globalCtx)) { - case EXCH_ITEM_NONE: - func_80A2F180(this); - this->actionFunc = func_80A2F94C; - break; - case EXCH_ITEM_POE: - player->actor.textId = 0x70F6; - this->actionFunc = func_80A2F9C0; - break; - case EXCH_ITEM_BIG_POE: - player->actor.textId = 0x70F7; - this->actionFunc = func_80A2FA50; - break; - } - return; - } - if (this->dyna.actor.xzDistToPlayer < 100.0f) { - func_8002F298(&this->dyna.actor, globalCtx, 100.0f, EXCH_ITEM_POE); - } -} - -void func_80A2F94C(EnGb* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - if (!(gSaveContext.infTable[0xB] & 0x40)) { - gSaveContext.infTable[0xB] |= 0x40; - } - func_80A2F180(this); - this->actionFunc = func_80A2F83C; - } -} - -void func_80A2F9C0(EnGb* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - if (!(gSaveContext.infTable[0xB] & 0x40)) { - gSaveContext.infTable[0xB] |= 0x40; - } - func_80A2F180(this); - Player_UpdateBottleHeld(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); - Rupees_ChangeBy(10); - this->actionFunc = func_80A2F83C; - } -} - -void func_80A2FA50(EnGb* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - if (!(gSaveContext.infTable[0xB] & 0x40)) { - gSaveContext.infTable[0xB] |= 0x40; - } - func_80A2F180(this); - Player_UpdateBottleHeld(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); - Rupees_ChangeBy(50); - HIGH_SCORE(HS_POE_POINTS) += 100; - if (HIGH_SCORE(HS_POE_POINTS) != 1000) { - if (HIGH_SCORE(HS_POE_POINTS) > 1100) { - HIGH_SCORE(HS_POE_POINTS) = 1100; - } - this->actionFunc = func_80A2F83C; - } else { - Player* player = GET_PLAYER(globalCtx); - - player->exchangeItemId = EXCH_ITEM_NONE; - this->textId = 0x70F8; - Message_ContinueTextbox(globalCtx, this->textId); - this->actionFunc = func_80A2FB40; - } - } -} - -void func_80A2FB40(EnGb* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - func_8002F434(&this->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); - this->actionFunc = func_80A2FBB0; - } -} - -void func_80A2FBB0(EnGb* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->dyna.actor, globalCtx)) { - this->dyna.actor.parent = NULL; - this->actionFunc = func_80A2FC0C; - } else { - func_8002F434(&this->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); - } -} - -void func_80A2FC0C(EnGb* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - Actor_ProcessTalkRequest(&this->dyna.actor, globalCtx); - func_80A2F180(this); - this->actionFunc = func_80A2F83C; - } -} - -void func_80A2FC70(EnGb* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame == Animation_GetLastFrame(&gPoeSellerSwingStickAnim)) { - Animation_Change(&this->skelAnime, &gPoeSellerIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gPoeSellerIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->actionFunc = func_80A2F83C; - } else if (this->skelAnime.curFrame == 18.0f) { - this->cagedSouls[1].unk_1 = 3; - this->cagedSouls[1].unk_3 = 1; - this->cagedSouls[2].unk_1 = 3; - this->cagedSouls[2].unk_3 = 1; - this->cagedSouls[3].unk_1 = 3; - this->cagedSouls[3].unk_3 = 1; - if (this->actionFunc) {} // these ifs cannot just contain a constant - this->cagedSouls[0].unk_1 = 3; - this->cagedSouls[0].unk_3 = 1; - if (this->actionFunc) {} - this->actionTimer = (s16)Rand_ZeroFloat(600.0f) + 600; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WOOD_HIT); - } -} - -void EnGb_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnGb* this = (EnGb*)thisx; - GlobalContext* globalCtx = globalCtx2; - s32 i; - f32 rand; - - this->frameTimer++; - SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); - this->dyna.actor.textId = this->textId; - func_80A2F608(this); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - for (i = 0; i < ARRAY_COUNT(this->bottlesColliders); i++) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bottlesColliders[i].base); - } - - rand = Rand_ZeroOne(); - this->lightColor.r = (s8)(rand * 30.0f) + 225; - this->lightColor.g = (s8)(rand * 100.0f) + 155; - this->lightColor.b = (s8)(rand * 160.0f) + 95; - this->lightColor.a = 200; - EnGb_UpdateCagedSouls(this, globalCtx); -} - -void EnGb_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGb* this = (EnGb*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 763); - - func_80093D18(globalCtx->state.gfxCtx); - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, this->lightColor.r, this->lightColor.g, this->lightColor.b, 255); - - Lights_PointNoGlowSetInfo(&this->lightInfo, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, this->lightColor.r, this->lightColor.g, this->lightColor.b, - this->lightColor.a); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->dyna.actor); - EnGb_DrawCagedSouls(this, globalCtx); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 796); -} - -void EnGb_UpdateCagedSouls(EnGb* this, GlobalContext* globalCtx) { - f32 temp_f20; - s16 rot; - s32 i; - - for (i = 0; i < 4; i++) { - switch (this->cagedSouls[i].unk_1) { - case 0: - Math_ApproachF(&this->cagedSouls[i].unk_20, 1.0f, 0.02f, this->cagedSouls[i].unk_24); - Math_ApproachF(&this->cagedSouls[i].unk_24, 1.0f, 0.001f, 1.0f); - if ((this->cagedSouls[i].unk_28 - .01f) <= this->cagedSouls[i].unk_20) { - this->cagedSouls[i].unk_20 = this->cagedSouls[i].unk_28; - this->cagedSouls[i].unk_24 = 0.0f; - this->cagedSouls[i].unk_1 = 1; - this->cagedSouls[i].unk_2 = 2; - this->cagedSouls[i].unk_6 = 0; - } - break; - case 1: - if (this->cagedSouls[i].unk_6 != 0) { - this->cagedSouls[i].unk_6--; - } else { - this->cagedSouls[i].unk_3 = 0; - this->cagedSouls[i].unk_24 = 0.0f; - this->cagedSouls[i].unk_1 = this->cagedSouls[i].unk_2; - } - break; - case 2: - Math_ApproachF(&this->cagedSouls[i].unk_20, 0.0f, 0.02f, this->cagedSouls[i].unk_24); - Math_ApproachF(&this->cagedSouls[i].unk_24, 1.0f, 0.001f, 1.0f); - if (this->cagedSouls[i].unk_20 <= 0.01f) { - this->cagedSouls[i].unk_28 = this->cagedSouls[i].unk_28 + 0.2f; - if (this->cagedSouls[i].unk_28 > 1.0f) { - this->cagedSouls[i].unk_28 = 1.0f; - } - this->cagedSouls[i].unk_20 = 0.0f; - this->cagedSouls[i].unk_24 = 0.0f; - this->cagedSouls[i].unk_1 = 1; - this->cagedSouls[i].unk_2 = 0; - this->cagedSouls[i].unk_6 = 0; - } - break; - case 3: - Math_ApproachF(&this->cagedSouls[i].unk_20, 0.0f, 0.5f, 1.0f); - if (this->cagedSouls[i].unk_20 <= 0.01f) { - this->cagedSouls[i].unk_28 = 0.2f; - this->cagedSouls[i].unk_20 = 0.0f; - this->cagedSouls[i].unk_24 = 0.0f; - this->cagedSouls[i].unk_1 = 1; - this->cagedSouls[i].unk_2 = 0; - this->cagedSouls[i].unk_6 = (s16)Rand_ZeroFloat(60.0f) + 60; - } - break; - } - - temp_f20 = this->cagedSouls[i].unk_20 * 60.0f; - if ((i == 0) || (i == 3)) { - this->cagedSouls[i].translation.x = this->cagedSouls[i].unk_14.x; - this->cagedSouls[i].translation.y = this->cagedSouls[i].unk_14.y + temp_f20; - this->cagedSouls[i].translation.z = this->cagedSouls[i].unk_14.z; - } else if (i == 1) { - rot = this->dyna.actor.world.rot.y - 0x4000; - this->cagedSouls[i].translation.x = this->cagedSouls[i].unk_14.x + Math_SinS(rot) * temp_f20; - this->cagedSouls[i].translation.z = this->cagedSouls[i].unk_14.z + Math_CosS(rot) * temp_f20; - this->cagedSouls[i].translation.y = this->cagedSouls[i].unk_14.y; - } else { - rot = this->dyna.actor.world.rot.y + 0x4000; - this->cagedSouls[i].translation.x = this->cagedSouls[i].unk_14.x + Math_SinS(rot) * temp_f20; - this->cagedSouls[i].translation.z = this->cagedSouls[i].unk_14.z + Math_CosS(rot) * temp_f20; - this->cagedSouls[i].translation.y = this->cagedSouls[i].unk_14.y; - } - } -} - -void EnGb_DrawCagedSouls(EnGb* this, GlobalContext* globalCtx) { - s32 pad; - s32 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 914); - - func_80093D84(globalCtx->state.gfxCtx); - - for (i = 0; i < 4; i++) { - s32 idx = this->cagedSouls[i].infoIdx; - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - (u32)(sCagedSoulInfo[idx].timerMultiplier * this->frameTimer) % 512, 32, 128)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sCagedSoulInfo[idx].texture)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sCagedSoulInfo[idx].prim.r, sCagedSoulInfo[idx].prim.g, - sCagedSoulInfo[idx].prim.b, sCagedSoulInfo[idx].prim.a); - gDPSetEnvColor(POLY_XLU_DISP++, sCagedSoulInfo[idx].env.r, sCagedSoulInfo[idx].env.g, sCagedSoulInfo[idx].env.b, - sCagedSoulInfo[idx].env.a); - - Matrix_Push(); - Matrix_Translate(this->cagedSouls[i].translation.x, this->cagedSouls[i].translation.y, - this->cagedSouls[i].translation.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - - if (this->cagedSouls[i].rotate180) { - Matrix_RotateZYX(0, -0x8000, 0, MTXMODE_APPLY); - } - Matrix_Scale(0.007f, 0.007f, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_gb.c", 955), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gPoeSellerCagedSoulDL); - - Matrix_Pop(); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 962); -} diff --git a/src/overlays/actors/ovl_En_Gb/z_en_gb.cpp b/src/overlays/actors/ovl_En_Gb/z_en_gb.cpp new file mode 100644 index 000000000..b929e30f0 --- /dev/null +++ b/src/overlays/actors/ovl_En_Gb/z_en_gb.cpp @@ -0,0 +1,569 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GB_Z_EN_GB_C +#include "actor_common.h" +/* + * File: z_en_gb.c + * Overlay: ovl_En_Gb + * Description: Poe Seller + */ + +#include "z_en_gb.h" +#include "objects/object_ps/object_ps.h" +#include "def/code_80043480.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnGb_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGb_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGb_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGb_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A2F83C(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2FC70(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2FA50(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2F9C0(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2F94C(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2FB40(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2FBB0(EnGb* pthis, GlobalContext* globalCtx); +void func_80A2FC0C(EnGb* pthis, GlobalContext* globalCtx); + +void EnGb_DrawCagedSouls(EnGb* pthis, GlobalContext* globalCtx); +void EnGb_UpdateCagedSouls(EnGb* pthis, GlobalContext* globalCtx); + +ActorInit En_Gb_InitVars = { + ACTOR_EN_GB, + ACTORCAT_NPC, + FLAGS, + OBJECT_PS, + sizeof(EnGb), + (ActorFunc)EnGb_Init, + (ActorFunc)EnGb_Destroy, + (ActorFunc)EnGb_Update, + (ActorFunc)EnGb_Draw, +}; + +static EnGbCagedSoulInfo sCagedSoulInfo[] = { + { { 255, 255, 170, 255 }, { 255, 200, 0, 255 }, gPoeSellerAngrySoulTex, -15 }, + { { 255, 255, 170, 255 }, { 0, 150, 0, 255 }, gPoeSellerHappySoulTex, -12 }, + { { 255, 170, 255, 255 }, { 100, 0, 150, 255 }, gPoeSellerSadSoulTex, -8 }, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 40, 75, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInitType1 sBottlesCylindersInit[] = { + { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 4, 20, 0, { 0, 0, 0 } }, + }, + { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 4, 20, 0, { 0, 0, 0 } }, + }, + { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 10, 20, 0, { 0, 0, 0 } }, + }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2200, ICHAIN_STOP), +}; + +// relative positions of poe souls +static Vec3f sCagedSoulPositions[] = { + { -8.0f, 112.0f, -8.0f }, + { -3.0f, 112.0f, 29.0f }, + { 31.0f, 112.0f, 29.0f }, + { 31.0f, 112.0f, -8.0f }, +}; + +// relative positions of bottles +static Vec3f sBottlesPositions[] = { + { -48.0f, 0.0f, 34.0f }, + { -55.0f, 0.0f, 49.0f }, + { -48.0f, 0.0f, 60.0f }, +}; + +void func_80A2F180(EnGb* pthis) { + if (gSaveContext.infTable[0xB] & 0x40) { + pthis->textId = 0x70F5; + } else { + pthis->textId = 0x70F4; + } +} + +void EnGb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGb* pthis = (EnGb*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + s32 i; + f32 rand; + Vec3f focusOffset; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + CollisionHeader_GetVirtual(&gPoeSellerCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gPoeSellerSkel, &gPoeSellerIdleAnim, pthis->jointTable, + pthis->morphTable, 12); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + + for (i = 0; i < ARRAY_COUNT(sBottlesCylindersInit); i++) { + Collider_InitCylinder(globalCtx, &pthis->bottlesColliders[i]); + Collider_SetCylinderType1(globalCtx, &pthis->bottlesColliders[i], &pthis->dyna.actor, &sBottlesCylindersInit[i]); + } + + pthis->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->dyna.actor.home.pos.x, pthis->dyna.actor.home.pos.y, + pthis->dyna.actor.home.pos.z, 255, 255, 255, 200); + + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + Actor_SetScale(&pthis->dyna.actor, 0.01f); + pthis->dyna.actor.colChkInfo.mass = 0xFF; + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.gravity = -1.0f; + pthis->actionTimer = (s16)Rand_ZeroFloat(100.0f) + 100; + + for (i = 0; i < ARRAY_COUNT(sCagedSoulPositions); i++) { + pthis->cagedSouls[i].infoIdx = (s32)Rand_ZeroFloat(30.0f) % 3; + pthis->cagedSouls[i].unk_14.x = pthis->cagedSouls[i].translation.x = + sCagedSoulPositions[i].x + pthis->dyna.actor.world.pos.x; + pthis->cagedSouls[i].unk_14.y = pthis->cagedSouls[i].translation.y = + sCagedSoulPositions[i].y + pthis->dyna.actor.world.pos.y; + pthis->cagedSouls[i].unk_14.z = pthis->cagedSouls[i].translation.z = + sCagedSoulPositions[i].z + pthis->dyna.actor.world.pos.z; + pthis->cagedSouls[i].unk_1 = 1; + pthis->cagedSouls[i].unk_3 = pthis->cagedSouls[i].unk_2 = 0; + pthis->cagedSouls[i].unk_20 = pthis->cagedSouls[i].unk_24 = 0.0f; + pthis->cagedSouls[i].unk_6 = Rand_ZeroFloat(40.0f); + pthis->cagedSouls[i].rotate180 = pthis->cagedSouls[i].unk_6 & 1; + pthis->cagedSouls[i].unk_28 = 0.2f; + } + + rand = Rand_ZeroOne(); + pthis->lightColor.r = (s8)(rand * 30.0f) + 225; + pthis->lightColor.g = (s8)(rand * 100.0f) + 155; + pthis->lightColor.b = (s8)(rand * 160.0f) + 95; + pthis->lightColor.a = 200; + Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateZYX(pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, + MTXMODE_APPLY); + focusOffset.x = focusOffset.y = 0.0f; + focusOffset.z = 44.0f; + Matrix_MultVec3f(&focusOffset, &pthis->dyna.actor.focus.pos); + pthis->dyna.actor.focus.pos.y += 62.5f; + func_80A2F180(pthis); + pthis->actionFunc = func_80A2F83C; +} + +void EnGb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGb* pthis = (EnGb*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->light); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80A2F608(EnGb* pthis) { + s32 i; + Vec3f sp48; + Vec3f sp3C; + + Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateZYX(pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, + MTXMODE_APPLY); + sp48.x = sp48.y = 0.0f; + sp48.z = 25.0f; + Matrix_MultVec3f(&sp48, &sp3C); + pthis->collider.dim.pos.x = sp3C.x; + pthis->collider.dim.pos.y = sp3C.y; + pthis->collider.dim.pos.z = sp3C.z; + + for (i = 0; i < ARRAY_COUNT(sBottlesPositions); i++) { + Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateZYX(pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, + MTXMODE_APPLY); + Matrix_MultVec3f(&sBottlesPositions[i], &sp3C); + pthis->bottlesColliders[i].dim.pos.x = sp3C.x; + pthis->bottlesColliders[i].dim.pos.y = sp3C.y; + pthis->bottlesColliders[i].dim.pos.z = sp3C.z; + } +} + +s32 func_80A2F760(EnGb* pthis) { + s32 i; + for (i = 0; i < ARRAY_COUNT(pthis->cagedSouls); i++) { + if (pthis->cagedSouls[i].unk_3) { + return 1; + } + } + return 0; +} + +void func_80A2F7C0(EnGb* pthis) { + Animation_Change(&pthis->skelAnime, &gPoeSellerSwingStickAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gPoeSellerSwingStickAnim), ANIMMODE_ONCE, 0.0f); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_NALE_MAGIC); + pthis->actionFunc = func_80A2FC70; +} + +void func_80A2F83C(EnGb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!func_80A2F760(pthis)) { + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } else { + func_80A2F7C0(pthis); + return; + } + } + if (Actor_ProcessTalkRequest(&pthis->dyna.actor, globalCtx)) { + switch (func_8002F368(globalCtx)) { + case EXCH_ITEM_NONE: + func_80A2F180(pthis); + pthis->actionFunc = func_80A2F94C; + break; + case EXCH_ITEM_POE: + player->actor.textId = 0x70F6; + pthis->actionFunc = func_80A2F9C0; + break; + case EXCH_ITEM_BIG_POE: + player->actor.textId = 0x70F7; + pthis->actionFunc = func_80A2FA50; + break; + } + return; + } + if (pthis->dyna.actor.xzDistToPlayer < 100.0f) { + func_8002F298(&pthis->dyna.actor, globalCtx, 100.0f, EXCH_ITEM_POE); + } +} + +void func_80A2F94C(EnGb* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + if (!(gSaveContext.infTable[0xB] & 0x40)) { + gSaveContext.infTable[0xB] |= 0x40; + } + func_80A2F180(pthis); + pthis->actionFunc = func_80A2F83C; + } +} + +void func_80A2F9C0(EnGb* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + if (!(gSaveContext.infTable[0xB] & 0x40)) { + gSaveContext.infTable[0xB] |= 0x40; + } + func_80A2F180(pthis); + Player_UpdateBottleHeld(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + Rupees_ChangeBy(10); + pthis->actionFunc = func_80A2F83C; + } +} + +void func_80A2FA50(EnGb* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + if (!(gSaveContext.infTable[0xB] & 0x40)) { + gSaveContext.infTable[0xB] |= 0x40; + } + func_80A2F180(pthis); + Player_UpdateBottleHeld(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + Rupees_ChangeBy(50); + HIGH_SCORE(HS_POE_POINTS) += 100; + if (HIGH_SCORE(HS_POE_POINTS) != 1000) { + if (HIGH_SCORE(HS_POE_POINTS) > 1100) { + HIGH_SCORE(HS_POE_POINTS) = 1100; + } + pthis->actionFunc = func_80A2F83C; + } else { + Player* player = GET_PLAYER(globalCtx); + + player->exchangeItemId = EXCH_ITEM_NONE; + pthis->textId = 0x70F8; + Message_ContinueTextbox(globalCtx, pthis->textId); + pthis->actionFunc = func_80A2FB40; + } + } +} + +void func_80A2FB40(EnGb* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + func_8002F434(&pthis->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); + pthis->actionFunc = func_80A2FBB0; + } +} + +void func_80A2FBB0(EnGb* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->dyna.actor, globalCtx)) { + pthis->dyna.actor.parent = NULL; + pthis->actionFunc = func_80A2FC0C; + } else { + func_8002F434(&pthis->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); + } +} + +void func_80A2FC0C(EnGb* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + Actor_ProcessTalkRequest(&pthis->dyna.actor, globalCtx); + func_80A2F180(pthis); + pthis->actionFunc = func_80A2F83C; + } +} + +void func_80A2FC70(EnGb* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame == Animation_GetLastFrame(&gPoeSellerSwingStickAnim)) { + Animation_Change(&pthis->skelAnime, &gPoeSellerIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gPoeSellerIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->actionFunc = func_80A2F83C; + } else if (pthis->skelAnime.curFrame == 18.0f) { + pthis->cagedSouls[1].unk_1 = 3; + pthis->cagedSouls[1].unk_3 = 1; + pthis->cagedSouls[2].unk_1 = 3; + pthis->cagedSouls[2].unk_3 = 1; + pthis->cagedSouls[3].unk_1 = 3; + pthis->cagedSouls[3].unk_3 = 1; + if (pthis->actionFunc) {} // these ifs cannot just contain a constant + pthis->cagedSouls[0].unk_1 = 3; + pthis->cagedSouls[0].unk_3 = 1; + if (pthis->actionFunc) {} + pthis->actionTimer = (s16)Rand_ZeroFloat(600.0f) + 600; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_WOOD_HIT); + } +} + +void EnGb_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnGb* pthis = (EnGb*)thisx; + GlobalContext* globalCtx = globalCtx2; + s32 i; + f32 rand; + + pthis->frameTimer++; + SkelAnime_Update(&pthis->skelAnime); + pthis->actionFunc(pthis, globalCtx); + pthis->dyna.actor.textId = pthis->textId; + func_80A2F608(pthis); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + for (i = 0; i < ARRAY_COUNT(pthis->bottlesColliders); i++) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bottlesColliders[i].base); + } + + rand = Rand_ZeroOne(); + pthis->lightColor.r = (s8)(rand * 30.0f) + 225; + pthis->lightColor.g = (s8)(rand * 100.0f) + 155; + pthis->lightColor.b = (s8)(rand * 160.0f) + 95; + pthis->lightColor.a = 200; + EnGb_UpdateCagedSouls(pthis, globalCtx); +} + +void EnGb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGb* pthis = (EnGb*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 763); + + func_80093D18(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, 255); + + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, + pthis->dyna.actor.world.pos.z, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, + pthis->lightColor.a); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, &pthis->dyna.actor); + EnGb_DrawCagedSouls(pthis, globalCtx); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 796); +} + +void EnGb_UpdateCagedSouls(EnGb* pthis, GlobalContext* globalCtx) { + f32 temp_f20; + s16 rot; + s32 i; + + for (i = 0; i < 4; i++) { + switch (pthis->cagedSouls[i].unk_1) { + case 0: + Math_ApproachF(&pthis->cagedSouls[i].unk_20, 1.0f, 0.02f, pthis->cagedSouls[i].unk_24); + Math_ApproachF(&pthis->cagedSouls[i].unk_24, 1.0f, 0.001f, 1.0f); + if ((pthis->cagedSouls[i].unk_28 - .01f) <= pthis->cagedSouls[i].unk_20) { + pthis->cagedSouls[i].unk_20 = pthis->cagedSouls[i].unk_28; + pthis->cagedSouls[i].unk_24 = 0.0f; + pthis->cagedSouls[i].unk_1 = 1; + pthis->cagedSouls[i].unk_2 = 2; + pthis->cagedSouls[i].unk_6 = 0; + } + break; + case 1: + if (pthis->cagedSouls[i].unk_6 != 0) { + pthis->cagedSouls[i].unk_6--; + } else { + pthis->cagedSouls[i].unk_3 = 0; + pthis->cagedSouls[i].unk_24 = 0.0f; + pthis->cagedSouls[i].unk_1 = pthis->cagedSouls[i].unk_2; + } + break; + case 2: + Math_ApproachF(&pthis->cagedSouls[i].unk_20, 0.0f, 0.02f, pthis->cagedSouls[i].unk_24); + Math_ApproachF(&pthis->cagedSouls[i].unk_24, 1.0f, 0.001f, 1.0f); + if (pthis->cagedSouls[i].unk_20 <= 0.01f) { + pthis->cagedSouls[i].unk_28 = pthis->cagedSouls[i].unk_28 + 0.2f; + if (pthis->cagedSouls[i].unk_28 > 1.0f) { + pthis->cagedSouls[i].unk_28 = 1.0f; + } + pthis->cagedSouls[i].unk_20 = 0.0f; + pthis->cagedSouls[i].unk_24 = 0.0f; + pthis->cagedSouls[i].unk_1 = 1; + pthis->cagedSouls[i].unk_2 = 0; + pthis->cagedSouls[i].unk_6 = 0; + } + break; + case 3: + Math_ApproachF(&pthis->cagedSouls[i].unk_20, 0.0f, 0.5f, 1.0f); + if (pthis->cagedSouls[i].unk_20 <= 0.01f) { + pthis->cagedSouls[i].unk_28 = 0.2f; + pthis->cagedSouls[i].unk_20 = 0.0f; + pthis->cagedSouls[i].unk_24 = 0.0f; + pthis->cagedSouls[i].unk_1 = 1; + pthis->cagedSouls[i].unk_2 = 0; + pthis->cagedSouls[i].unk_6 = (s16)Rand_ZeroFloat(60.0f) + 60; + } + break; + } + + temp_f20 = pthis->cagedSouls[i].unk_20 * 60.0f; + if ((i == 0) || (i == 3)) { + pthis->cagedSouls[i].translation.x = pthis->cagedSouls[i].unk_14.x; + pthis->cagedSouls[i].translation.y = pthis->cagedSouls[i].unk_14.y + temp_f20; + pthis->cagedSouls[i].translation.z = pthis->cagedSouls[i].unk_14.z; + } else if (i == 1) { + rot = pthis->dyna.actor.world.rot.y - 0x4000; + pthis->cagedSouls[i].translation.x = pthis->cagedSouls[i].unk_14.x + Math_SinS(rot) * temp_f20; + pthis->cagedSouls[i].translation.z = pthis->cagedSouls[i].unk_14.z + Math_CosS(rot) * temp_f20; + pthis->cagedSouls[i].translation.y = pthis->cagedSouls[i].unk_14.y; + } else { + rot = pthis->dyna.actor.world.rot.y + 0x4000; + pthis->cagedSouls[i].translation.x = pthis->cagedSouls[i].unk_14.x + Math_SinS(rot) * temp_f20; + pthis->cagedSouls[i].translation.z = pthis->cagedSouls[i].unk_14.z + Math_CosS(rot) * temp_f20; + pthis->cagedSouls[i].translation.y = pthis->cagedSouls[i].unk_14.y; + } + } +} + +void EnGb_DrawCagedSouls(EnGb* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 914); + + func_80093D84(globalCtx->state.gfxCtx); + + for (i = 0; i < 4; i++) { + s32 idx = pthis->cagedSouls[i].infoIdx; + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (u32)(sCagedSoulInfo[idx].timerMultiplier * pthis->frameTimer) % 512, 32, 128)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sCagedSoulInfo[idx].texture)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sCagedSoulInfo[idx].prim.r, sCagedSoulInfo[idx].prim.g, + sCagedSoulInfo[idx].prim.b, sCagedSoulInfo[idx].prim.a); + gDPSetEnvColor(POLY_XLU_DISP++, sCagedSoulInfo[idx].env.r, sCagedSoulInfo[idx].env.g, sCagedSoulInfo[idx].env.b, + sCagedSoulInfo[idx].env.a); + + Matrix_Push(); + Matrix_Translate(pthis->cagedSouls[i].translation.x, pthis->cagedSouls[i].translation.y, + pthis->cagedSouls[i].translation.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + + if (pthis->cagedSouls[i].rotate180) { + Matrix_RotateZYX(0, -0x8000, 0, MTXMODE_APPLY); + } + Matrix_Scale(0.007f, 0.007f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_gb.c", 955), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gPoeSellerCagedSoulDL); + + Matrix_Pop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gb.c", 962); +} diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c deleted file mode 100644 index 6e1ec968c..000000000 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ /dev/null @@ -1,826 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GE1_Z_EN_GE1_C -#include "actor_common.h" -/* - * File: z_en_ge1.c - * Overlay: ovl_En_Ge1 - * Description: White-clothed Gerudo - */ - -#include "z_en_ge1.h" -#include "vt.h" -#include "objects/object_ge1/object_ge1.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_horse.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -#define GE1_STATE_TALKING (1 << 0) -#define GE1_STATE_GIVE_QUIVER (1 << 1) -#define GE1_STATE_IDLE_ANIM (1 << 2) -#define GE1_STATE_STOP_FIDGET (1 << 3) - -typedef enum { - /* 00 */ GE1_HAIR_BOB, - /* 01 */ GE1_HAIR_STRAIGHT, - /* 02 */ GE1_HAIR_SPIKY -} EnGe1Hairstyle; - -void EnGe1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGe1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGe1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGe1_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 EnGe1_CheckCarpentersFreed(void); -void EnGe1_WatchForPlayerFrontOnly(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_SetNormalText(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_WatchForAndSensePlayer(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_GetReaction_ValleyFloor(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_CheckForCard_GTGGuard(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_CheckGate_GateOp(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_GetReaction_GateGuard(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_TalkAfterGame_Archery(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_Wait_Archery(EnGe1* this, GlobalContext* globalCtx); -void EnGe1_CueUpAnimation(EnGe1* this); -void EnGe1_StopFidget(EnGe1* this); - -const ActorInit En_Ge1_InitVars = { - ACTOR_EN_GE1, - ACTORCAT_NPC, - FLAGS, - OBJECT_GE1, - sizeof(EnGe1), - (ActorFunc)EnGe1_Init, - (ActorFunc)EnGe1_Destroy, - (ActorFunc)EnGe1_Update, - (ActorFunc)EnGe1_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000702, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 40, 0, { 0, 0, 0 } }, -}; - -static Gfx* sHairstyleDLists[] = { - gGerudoWhiteHairstyleBobDL, - gGerudoWhiteHairstyleStraightFringeDL, - gGerudoWhiteHairstyleSpikyDL, -}; - -static Vec3f D_80A327A8 = { 600.0f, 700.0f, 0.0f }; - -static void* sEyeTextures[] = { - gGerudoWhiteEyeOpenTex, - gGerudoWhiteEyeHalfTex, - gGerudoWhiteEyeClosedTex, -}; - -void EnGe1_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnGe1* this = (EnGe1*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGerudoWhiteSkel, &gGerudoWhiteIdleAnim, this->jointTable, - this->morphTable, GE1_LIMB_MAX); - Animation_PlayOnce(&this->skelAnime, &gGerudoWhiteIdleAnim); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->animation = &gGerudoWhiteIdleAnim; - this->animFunc = EnGe1_CueUpAnimation; - this->actor.targetMode = 6; - Actor_SetScale(&this->actor, 0.01f); - - // In Gerudo Valley - this->actor.uncullZoneForward = ((globalCtx->sceneNum == SCENE_SPOT09) ? 1000.0f : 1200.0f); - - switch (this->actor.params & 0xFF) { - - case GE1_TYPE_GATE_GUARD: - this->hairstyle = GE1_HAIR_SPIKY; - this->actionFunc = EnGe1_GetReaction_GateGuard; - break; - - case GE1_TYPE_GATE_OPERATOR: - this->hairstyle = GE1_HAIR_STRAIGHT; - - if (EnGe1_CheckCarpentersFreed()) { - this->actionFunc = EnGe1_CheckGate_GateOp; - } else { - this->actionFunc = EnGe1_WatchForPlayerFrontOnly; - } - break; - - case GE1_TYPE_NORMAL: - this->hairstyle = GE1_HAIR_STRAIGHT; - - if (EnGe1_CheckCarpentersFreed()) { - this->actionFunc = EnGe1_SetNormalText; - } else { - this->actionFunc = EnGe1_WatchForAndSensePlayer; - } - break; - - case GE1_TYPE_VALLEY_FLOOR: - if (LINK_IS_ADULT) { - // "Valley floor Gerudo withdrawal" - osSyncPrintf(VT_FGCOL(CYAN) "谷底 ゲルド 撤退 \n" VT_RST); - Actor_Kill(&this->actor); - return; - } - this->hairstyle = GE1_HAIR_BOB; - this->actionFunc = EnGe1_GetReaction_ValleyFloor; - break; - - case GE1_TYPE_HORSEBACK_ARCHERY: - if (INV_CONTENT(SLOT_BOW) == ITEM_NONE) { - Actor_Kill(&this->actor); - return; - } - this->actor.targetMode = 3; - this->hairstyle = GE1_HAIR_BOB; - // "Horseback archery Gerudo EVENT_INF(0) =" - osSyncPrintf(VT_FGCOL(CYAN) "やぶさめ ゲルド EVENT_INF(0) = %x\n" VT_RST, gSaveContext.eventInf[0]); - - if (gSaveContext.eventInf[0] & 0x100) { - this->actionFunc = EnGe1_TalkAfterGame_Archery; - } else if (EnGe1_CheckCarpentersFreed()) { - this->actionFunc = EnGe1_Wait_Archery; - } else { - this->actionFunc = EnGe1_WatchForPlayerFrontOnly; - } - break; - - case GE1_TYPE_TRAINING_GROUNDS_GUARD: - this->hairstyle = GE1_HAIR_STRAIGHT; - - if (EnGe1_CheckCarpentersFreed()) { - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - } else { - this->actionFunc = EnGe1_WatchForPlayerFrontOnly; - } - break; - } - - this->stateFlags = 0; -} - -void EnGe1_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGe1* this = (EnGe1*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 EnGe1_SetTalkAction(EnGe1* this, GlobalContext* globalCtx, u16 textId, f32 arg3, EnGe1ActionFunc actionFunc) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = actionFunc; - this->animFunc = EnGe1_StopFidget; - this->stateFlags &= ~GE1_STATE_IDLE_ANIM; - this->animation = &gGerudoWhiteIdleAnim; - Animation_Change(&this->skelAnime, &gGerudoWhiteIdleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteIdleAnim), ANIMMODE_ONCE, -8.0f); - return true; - } - - this->actor.textId = textId; - - if (this->actor.xzDistToPlayer < arg3) { - func_8002F2CC(&this->actor, globalCtx, arg3); - } - - return false; -} - -void EnGe1_SetAnimationIdle(EnGe1* this) { - Animation_Change(&this->skelAnime, &gGerudoWhiteIdleAnim, -1.0f, Animation_GetLastFrame(&gGerudoWhiteIdleAnim), - 0.0f, ANIMMODE_ONCE, 8.0f); - this->animation = &gGerudoWhiteIdleAnim; - this->animFunc = EnGe1_CueUpAnimation; -} - -s32 EnGe1_CheckCarpentersFreed(void) { - u16 carpenterFlags = gSaveContext.eventChkInf[9]; - - if (!((carpenterFlags & 1) && (carpenterFlags & 2) && (carpenterFlags & 4) && (carpenterFlags & 8))) { - return 0; - } - return 1; -} - -/** - * Sends player to different places depending on if has hookshot, and if this is the first time captured - */ -void EnGe1_KickPlayer(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - - if (this->cutsceneTimer > 0) { - this->cutsceneTimer--; - } else { - func_8006D074(globalCtx); - - if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { - globalCtx->nextEntranceIndex = 0x1A5; - } else if (gSaveContext.eventChkInf[12] & 0x80) { // Caught previously - globalCtx->nextEntranceIndex = 0x5F8; - } else { - globalCtx->nextEntranceIndex = 0x3B4; - } - - globalCtx->fadeTransition = 0x26; - globalCtx->sceneLoadFlag = 0x14; - } -} - -void EnGe1_SpotPlayer(EnGe1* this, GlobalContext* globalCtx) { - this->cutsceneTimer = 30; - this->actionFunc = EnGe1_KickPlayer; - func_8002DF54(globalCtx, &this->actor, 0x5F); - func_80078884(NA_SE_SY_FOUND); - Message_StartTextbox(globalCtx, 0x6000, &this->actor); -} - -void EnGe1_WatchForPlayerFrontOnly(EnGe1* this, GlobalContext* globalCtx) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(angleDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { - EnGe1_SpotPlayer(this, globalCtx); - } - - if (this->collider.base.acFlags & AC_HIT) { - EnGe1_SpotPlayer(this, globalCtx); - } - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnGe1_ChooseActionFromTextId(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - switch (this->actor.textId) { - case 0x6001: - this->actionFunc = EnGe1_SetNormalText; - break; - - case 0x601A: - case 0x6019: - this->actionFunc = EnGe1_GetReaction_ValleyFloor; - break; - - case 0x6018: - this->actionFunc = EnGe1_CheckGate_GateOp; - break; - - default: - this->actionFunc = EnGe1_GetReaction_ValleyFloor; - break; - } - } -} - -void EnGe1_SetNormalText(EnGe1* this, GlobalContext* globalCtx) { - EnGe1_SetTalkAction(this, globalCtx, 0x6001, 100.0f, EnGe1_ChooseActionFromTextId); -} - -void EnGe1_WatchForAndSensePlayer(EnGe1* this, GlobalContext* globalCtx) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((this->actor.xzDistToPlayer < 50.0f) || ((ABS(angleDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 400.0f))) { - EnGe1_SpotPlayer(this, globalCtx); - } - - if (this->collider.base.acFlags & AC_HIT) { - EnGe1_SpotPlayer(this, globalCtx); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnGe1_GetReaction_ValleyFloor(EnGe1* this, GlobalContext* globalCtx) { - u16 reactionText = Text_GetFaceReaction(globalCtx, 0x22); - - if (reactionText == 0) { - reactionText = 0x6019; - } - - EnGe1_SetTalkAction(this, globalCtx, reactionText, 100.0f, EnGe1_ChooseActionFromTextId); -} - -// Gerudo Training Ground Guard functions - -void EnGe1_WaitTillOpened_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - if (this->cutsceneTimer > 0) { - this->cutsceneTimer--; - } else { - EnGe1_SetAnimationIdle(this); - this->actionFunc = EnGe1_SetNormalText; - } - - this->stateFlags |= GE1_STATE_STOP_FIDGET; -} - -void EnGe1_Open_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - if (this->stateFlags & GE1_STATE_IDLE_ANIM) { - this->actionFunc = EnGe1_WaitTillOpened_GTGGuard; - Flags_SetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F); - this->cutsceneTimer = 50; - Message_CloseTextbox(globalCtx); - } else if ((this->skelAnime.curFrame == 15.0f) || (this->skelAnime.curFrame == 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_HAND_CLAP); - } -} - -void EnGe1_SetupOpen_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = EnGe1_Open_GTGGuard; - Animation_Change(&this->skelAnime, &gGerudoWhiteClapAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteClapAnim), ANIMMODE_ONCE, -3.0f); - this->animation = &gGerudoWhiteClapAnim; - this->animFunc = EnGe1_StopFidget; - this->stateFlags &= ~GE1_STATE_IDLE_ANIM; - } -} - -void EnGe1_RefuseEntryTooPoor_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_OfferOpen_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - if (gSaveContext.rupees < 10) { - Message_ContinueTextbox(globalCtx, 0x6016); - this->actionFunc = EnGe1_RefuseEntryTooPoor_GTGGuard; - } else { - Rupees_ChangeBy(-10); - Message_ContinueTextbox(globalCtx, 0x6015); - this->actionFunc = EnGe1_SetupOpen_GTGGuard; - } - break; - case 1: - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - EnGe1_SetAnimationIdle(this); - break; - } - } -} - -void EnGe1_RefuseOpenNoCard_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_CheckForCard_GTGGuard(EnGe1* this, GlobalContext* globalCtx) { - if (CHECK_QUEST_ITEM(QUEST_GERUDO_CARD)) { - EnGe1_SetTalkAction(this, globalCtx, 0x6014, 100.0f, EnGe1_OfferOpen_GTGGuard); - } else { - //! @bug This outcome is inaccessible in normal gameplay since this function it is unreachable without - //! obtaining the card in the first place. - EnGe1_SetTalkAction(this, globalCtx, 0x6013, 100.0f, EnGe1_RefuseOpenNoCard_GTGGuard); - } -} - -// Gate Operator functions - -void EnGe1_WaitGateOpen_GateOp(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = EnGe1_CheckGate_GateOp; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_WaitUntilGateOpened_GateOp(EnGe1* this, GlobalContext* globalCtx) { - if (this->cutsceneTimer > 0) { - this->cutsceneTimer--; - } else { - EnGe1_SetAnimationIdle(this); - this->actionFunc = EnGe1_CheckGate_GateOp; - } - this->stateFlags |= GE1_STATE_STOP_FIDGET; -} - -void EnGe1_OpenGate_GateOp(EnGe1* this, GlobalContext* globalCtx) { - if (this->stateFlags & GE1_STATE_IDLE_ANIM) { - this->actionFunc = EnGe1_WaitUntilGateOpened_GateOp; - Flags_SetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F); - this->cutsceneTimer = 50; - Message_CloseTextbox(globalCtx); - } else if ((this->skelAnime.curFrame == 15.0f) || (this->skelAnime.curFrame == 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_HAND_CLAP); - } -} - -void EnGe1_SetupOpenGate_GateOp(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = EnGe1_OpenGate_GateOp; - Animation_Change(&this->skelAnime, &gGerudoWhiteClapAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteClapAnim), ANIMMODE_ONCE, -3.0f); - this->animation = &gGerudoWhiteClapAnim; - this->animFunc = EnGe1_StopFidget; - this->stateFlags &= ~GE1_STATE_IDLE_ANIM; - } -} - -void EnGe1_CheckGate_GateOp(EnGe1* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { - EnGe1_SetTalkAction(this, globalCtx, 0x6018, 100.0f, EnGe1_WaitGateOpen_GateOp); - } else { - EnGe1_SetTalkAction(this, globalCtx, 0x6017, 100.0f, EnGe1_SetupOpenGate_GateOp); - } -} - -// Gate guard functions - -void EnGe1_Talk_GateGuard(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_GetReaction_GateGuard; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_GetReaction_GateGuard(EnGe1* this, GlobalContext* globalCtx) { - u16 reactionText; - - reactionText = Text_GetFaceReaction(globalCtx, 0x22); - - if (reactionText == 0) { - reactionText = 0x6069; - } - - if (EnGe1_SetTalkAction(this, globalCtx, reactionText, 100.0f, EnGe1_Talk_GateGuard)) { - this->animFunc = EnGe1_CueUpAnimation; - this->animation = &gGerudoWhiteDismissiveAnim; - Animation_Change(&this->skelAnime, &gGerudoWhiteDismissiveAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteDismissiveAnim), ANIMMODE_ONCE, -8.0f); - } -} - -// Archery functions - -void EnGe1_SetupWait_Archery(EnGe1* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_Wait_Archery; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_WaitTillItemGiven_Archery(EnGe1* this, GlobalContext* globalCtx) { - s32 getItemId; - - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_SetupWait_Archery; - if (this->stateFlags & GE1_STATE_GIVE_QUIVER) { - gSaveContext.itemGetInf[0] |= 0x8000; - } else { - gSaveContext.infTable[25] |= 1; - } - } else { - if (this->stateFlags & GE1_STATE_GIVE_QUIVER) { - switch (CUR_UPG_VALUE(UPG_QUIVER)) { - //! @bug Asschest. See next function for details - case 1: - getItemId = GI_QUIVER_40; - break; - case 2: - getItemId = GI_QUIVER_50; - break; - } - } else { - getItemId = GI_HEART_PIECE; - } - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); - } -} - -void EnGe1_BeginGiveItem_Archery(EnGe1* this, GlobalContext* globalCtx) { - s32 getItemId; - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = EnGe1_WaitTillItemGiven_Archery; - } - - if (this->stateFlags & GE1_STATE_GIVE_QUIVER) { - switch (CUR_UPG_VALUE(UPG_QUIVER)) { - //! @bug Asschest: the compiler inserts a default assigning *(sp+0x24) to getItemId, which is junk data left - //! over from the previous function run in EnGe1_Update, namely EnGe1_CueUpAnimation. The top stack variable - //! in that function is &this->skelAnime = thisx + 198, and depending on where this loads in memory, the - //! getItemId changes. - case 1: - getItemId = GI_QUIVER_40; - break; - case 2: - getItemId = GI_QUIVER_50; - break; - } - } else { - getItemId = GI_HEART_PIECE; - } - - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); -} - -void EnGe1_TalkWinPrize_Archery(EnGe1* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_BeginGiveItem_Archery; - this->actor.flags &= ~ACTOR_FLAG_16; - } else { - func_8002F2CC(&this->actor, globalCtx, 200.0f); - } -} - -void EnGe1_TalkTooPoor_Archery(EnGe1* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = EnGe1_Wait_Archery; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_WaitDoNothing(EnGe1* this, GlobalContext* globalCtx) { -} - -void EnGe1_BeginGame_Archery(EnGe1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Actor* horse; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - if (gSaveContext.rupees < 20) { - Message_ContinueTextbox(globalCtx, 0x85); - this->actionFunc = EnGe1_TalkTooPoor_Archery; - } else { - Rupees_ChangeBy(-20); - globalCtx->nextEntranceIndex = 0x129; - gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 0x26; - globalCtx->sceneLoadFlag = 0x14; - gSaveContext.eventInf[0] |= 0x100; - gSaveContext.eventChkInf[6] |= 0x100; - - if (!(player->stateFlags1 & 0x800000)) { - func_8002DF54(globalCtx, &this->actor, 1); - } else { - horse = Actor_FindNearby(globalCtx, &player->actor, ACTOR_EN_HORSE, ACTORCAT_BG, 1200.0f); - player->actor.freezeTimer = 1200; - - if (horse != NULL) { - horse->freezeTimer = 1200; - } - } - - this->actionFunc = EnGe1_WaitDoNothing; - } - break; - - case 1: - this->actionFunc = EnGe1_Wait_Archery; - Message_CloseTextbox(globalCtx); - break; - } - } -} - -void EnGe1_TalkOfferPlay_Archery(EnGe1* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x6041); - this->actionFunc = EnGe1_BeginGame_Archery; - } -} - -void EnGe1_TalkNoPrize_Archery(EnGe1* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_TalkOfferPlay_Archery; - } else { - func_8002F2CC(&this->actor, globalCtx, 300.0f); - } -} - -void EnGe1_TalkAfterGame_Archery(EnGe1* this, GlobalContext* globalCtx) { - gSaveContext.eventInf[0] &= ~0x100; - LOG_NUM("z_common_data.yabusame_total", gSaveContext.minigameScore, "../z_en_ge1.c", 1110); - LOG_NUM("z_common_data.memory.information.room_inf[127][ 0 ]", HIGH_SCORE(HS_HBA), "../z_en_ge1.c", 1111); - this->actor.flags |= ACTOR_FLAG_16; - - if (HIGH_SCORE(HS_HBA) < gSaveContext.minigameScore) { - HIGH_SCORE(HS_HBA) = gSaveContext.minigameScore; - } - - if (gSaveContext.minigameScore < 1000) { - this->actor.textId = 0x6045; - this->actionFunc = EnGe1_TalkNoPrize_Archery; - } else if (!(gSaveContext.infTable[25] & 1)) { - this->actor.textId = 0x6046; - this->actionFunc = EnGe1_TalkWinPrize_Archery; - this->stateFlags &= ~GE1_STATE_GIVE_QUIVER; - } else if (gSaveContext.minigameScore < 1500) { - this->actor.textId = 0x6047; - this->actionFunc = EnGe1_TalkNoPrize_Archery; - } else if (gSaveContext.itemGetInf[0] & 0x8000) { - this->actor.textId = 0x6047; - this->actionFunc = EnGe1_TalkNoPrize_Archery; - } else { - this->actor.textId = 0x6044; - this->actionFunc = EnGe1_TalkWinPrize_Archery; - this->stateFlags |= GE1_STATE_GIVE_QUIVER; - } -} - -void EnGe1_TalkNoHorse_Archery(EnGe1* this, GlobalContext* globalCtx) { - this->stateFlags |= GE1_STATE_TALKING; - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnGe1_Wait_Archery; - EnGe1_SetAnimationIdle(this); - } -} - -void EnGe1_Wait_Archery(EnGe1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 textId; - - if (!(player->stateFlags1 & 0x800000)) { - EnGe1_SetTalkAction(this, globalCtx, 0x603F, 100.0f, EnGe1_TalkNoHorse_Archery); - } else { - if (gSaveContext.eventChkInf[6] & 0x100) { - if (gSaveContext.infTable[25] & 1) { - textId = 0x6042; - } else { - textId = 0x6043; - } - } else { - textId = 0x6040; - } - EnGe1_SetTalkAction(this, globalCtx, textId, 200.0f, EnGe1_TalkOfferPlay_Archery); - } -} - -// General functions - -void EnGe1_TurnToFacePlayer(EnGe1* this, GlobalContext* globalCtx) { - s32 pad; - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(angleDiff) <= 0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 4000, 100); - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_2A2, this->actor.focus.pos); - } else { - if (angleDiff < 0) { - Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 6200, 0x100); - } else { - Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 6200, 0x100); - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 1000, 100); - this->actor.world.rot.y = this->actor.shape.rot.y; - } -} - -void EnGe1_LookAtPlayer(EnGe1* this, GlobalContext* globalCtx) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(angleDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_2A2, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->headRot.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->headRot.y, 0, 6, 6200, 100); - } -} - -void EnGe1_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnGe1* this = (EnGe1*)thisx; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); - this->animFunc(this); - this->actionFunc(this, globalCtx); - - if (this->stateFlags & GE1_STATE_TALKING) { - EnGe1_TurnToFacePlayer(this, globalCtx); - this->stateFlags &= ~GE1_STATE_TALKING; - } else { - EnGe1_LookAtPlayer(this, globalCtx); - } - this->unk_2A2.x = this->unk_2A2.y = this->unk_2A2.z = 0; - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - this->eyeIndex = this->blinkTimer; - - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; - } -} - -// Animation functions - -void EnGe1_CueUpAnimation(EnGe1* this) { - if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayOnce(&this->skelAnime, this->animation); - } -} - -void EnGe1_StopFidget(EnGe1* this) { - if (!(this->stateFlags & GE1_STATE_IDLE_ANIM)) { - if (SkelAnime_Update(&this->skelAnime)) { - this->stateFlags |= GE1_STATE_IDLE_ANIM; - } - this->stateFlags |= GE1_STATE_STOP_FIDGET; - } -} - -s32 EnGe1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - s32 pad; - EnGe1* this = (EnGe1*)thisx; - - if (limbIndex == GE1_LIMB_HEAD) { - rot->x += this->headRot.y; - rot->z += this->headRot.x; - } - - if (this->stateFlags & GE1_STATE_STOP_FIDGET) { - this->stateFlags &= ~GE1_STATE_STOP_FIDGET; - return 0; - } - - // The purpose of the state flag GE1_STATE_STOP_FIDGET is to skip this code, which this actor has in lieu of an idle - // animation. - if ((limbIndex == GE1_LIMB_TORSO) || (limbIndex == GE1_LIMB_L_FOREARM) || (limbIndex == GE1_LIMB_R_FOREARM)) { - rot->y += Math_SinS(globalCtx->state.frames * (limbIndex * 50 + 0x814)) * 200.0f; - rot->z += Math_CosS(globalCtx->state.frames * (limbIndex * 50 + 0x940)) * 200.0f; - } - return 0; -} - -void EnGe1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnGe1* this = (EnGe1*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1419); - - if (limbIndex == GE1_LIMB_HEAD) { - gSPDisplayList(POLY_OPA_DISP++, sHairstyleDLists[this->hairstyle]); - Matrix_MultVec3f(&D_80A327A8, &this->actor.focus.pos); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1427); -} - -void EnGe1_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnGe1* this = (EnGe1*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1442); - - func_800943C8(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnGe1_OverrideLimbDraw, EnGe1_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1459); -} diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.cpp b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.cpp new file mode 100644 index 000000000..b607e6e6d --- /dev/null +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.cpp @@ -0,0 +1,826 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GE1_Z_EN_GE1_C +#include "actor_common.h" +/* + * File: z_en_ge1.c + * Overlay: ovl_En_Ge1 + * Description: White-clothed Gerudo + */ + +#include "z_en_ge1.h" +#include "vt.h" +#include "objects/object_ge1/object_ge1.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_horse.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +#define GE1_STATE_TALKING (1 << 0) +#define GE1_STATE_GIVE_QUIVER (1 << 1) +#define GE1_STATE_IDLE_ANIM (1 << 2) +#define GE1_STATE_STOP_FIDGET (1 << 3) + +typedef enum { + /* 00 */ GE1_HAIR_BOB, + /* 01 */ GE1_HAIR_STRAIGHT, + /* 02 */ GE1_HAIR_SPIKY +} EnGe1Hairstyle; + +void EnGe1_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGe1_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGe1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGe1_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 EnGe1_CheckCarpentersFreed(void); +void EnGe1_WatchForPlayerFrontOnly(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_SetNormalText(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_WatchForAndSensePlayer(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_GetReaction_ValleyFloor(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_CheckForCard_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_CheckGate_GateOp(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_GetReaction_GateGuard(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_TalkAfterGame_Archery(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_Wait_Archery(EnGe1* pthis, GlobalContext* globalCtx); +void EnGe1_CueUpAnimation(EnGe1* pthis); +void EnGe1_StopFidget(EnGe1* pthis); + +ActorInit En_Ge1_InitVars = { + ACTOR_EN_GE1, + ACTORCAT_NPC, + FLAGS, + OBJECT_GE1, + sizeof(EnGe1), + (ActorFunc)EnGe1_Init, + (ActorFunc)EnGe1_Destroy, + (ActorFunc)EnGe1_Update, + (ActorFunc)EnGe1_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000702, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 40, 0, { 0, 0, 0 } }, +}; + +static Gfx* sHairstyleDLists[] = { + gGerudoWhiteHairstyleBobDL, + gGerudoWhiteHairstyleStraightFringeDL, + gGerudoWhiteHairstyleSpikyDL, +}; + +static Vec3f D_80A327A8 = { 600.0f, 700.0f, 0.0f }; + +static void* sEyeTextures[] = { + gGerudoWhiteEyeOpenTex, + gGerudoWhiteEyeHalfTex, + gGerudoWhiteEyeClosedTex, +}; + +void EnGe1_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGe1* pthis = (EnGe1*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGerudoWhiteSkel, &gGerudoWhiteIdleAnim, pthis->jointTable, + pthis->morphTable, GE1_LIMB_MAX); + Animation_PlayOnce(&pthis->skelAnime, &gGerudoWhiteIdleAnim); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->animation = &gGerudoWhiteIdleAnim; + pthis->animFunc = EnGe1_CueUpAnimation; + pthis->actor.targetMode = 6; + Actor_SetScale(&pthis->actor, 0.01f); + + // In Gerudo Valley + pthis->actor.uncullZoneForward = ((globalCtx->sceneNum == SCENE_SPOT09) ? 1000.0f : 1200.0f); + + switch (pthis->actor.params & 0xFF) { + + case GE1_TYPE_GATE_GUARD: + pthis->hairstyle = GE1_HAIR_SPIKY; + pthis->actionFunc = EnGe1_GetReaction_GateGuard; + break; + + case GE1_TYPE_GATE_OPERATOR: + pthis->hairstyle = GE1_HAIR_STRAIGHT; + + if (EnGe1_CheckCarpentersFreed()) { + pthis->actionFunc = EnGe1_CheckGate_GateOp; + } else { + pthis->actionFunc = EnGe1_WatchForPlayerFrontOnly; + } + break; + + case GE1_TYPE_NORMAL: + pthis->hairstyle = GE1_HAIR_STRAIGHT; + + if (EnGe1_CheckCarpentersFreed()) { + pthis->actionFunc = EnGe1_SetNormalText; + } else { + pthis->actionFunc = EnGe1_WatchForAndSensePlayer; + } + break; + + case GE1_TYPE_VALLEY_FLOOR: + if (LINK_IS_ADULT) { + // "Valley floor Gerudo withdrawal" + osSyncPrintf(VT_FGCOL(CYAN) "谷底 ゲルド 撤退 \n" VT_RST); + Actor_Kill(&pthis->actor); + return; + } + pthis->hairstyle = GE1_HAIR_BOB; + pthis->actionFunc = EnGe1_GetReaction_ValleyFloor; + break; + + case GE1_TYPE_HORSEBACK_ARCHERY: + if (INV_CONTENT(SLOT_BOW) == ITEM_NONE) { + Actor_Kill(&pthis->actor); + return; + } + pthis->actor.targetMode = 3; + pthis->hairstyle = GE1_HAIR_BOB; + // "Horseback archery Gerudo EVENT_INF(0) =" + osSyncPrintf(VT_FGCOL(CYAN) "やぶさめ ゲルド EVENT_INF(0) = %x\n" VT_RST, gSaveContext.eventInf[0]); + + if (gSaveContext.eventInf[0] & 0x100) { + pthis->actionFunc = EnGe1_TalkAfterGame_Archery; + } else if (EnGe1_CheckCarpentersFreed()) { + pthis->actionFunc = EnGe1_Wait_Archery; + } else { + pthis->actionFunc = EnGe1_WatchForPlayerFrontOnly; + } + break; + + case GE1_TYPE_TRAINING_GROUNDS_GUARD: + pthis->hairstyle = GE1_HAIR_STRAIGHT; + + if (EnGe1_CheckCarpentersFreed()) { + pthis->actionFunc = EnGe1_CheckForCard_GTGGuard; + } else { + pthis->actionFunc = EnGe1_WatchForPlayerFrontOnly; + } + break; + } + + pthis->stateFlags = 0; +} + +void EnGe1_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGe1* pthis = (EnGe1*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 EnGe1_SetTalkAction(EnGe1* pthis, GlobalContext* globalCtx, u16 textId, f32 arg3, EnGe1ActionFunc actionFunc) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = actionFunc; + pthis->animFunc = EnGe1_StopFidget; + pthis->stateFlags &= ~GE1_STATE_IDLE_ANIM; + pthis->animation = &gGerudoWhiteIdleAnim; + Animation_Change(&pthis->skelAnime, &gGerudoWhiteIdleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoWhiteIdleAnim), ANIMMODE_ONCE, -8.0f); + return true; + } + + pthis->actor.textId = textId; + + if (pthis->actor.xzDistToPlayer < arg3) { + func_8002F2CC(&pthis->actor, globalCtx, arg3); + } + + return false; +} + +void EnGe1_SetAnimationIdle(EnGe1* pthis) { + Animation_Change(&pthis->skelAnime, &gGerudoWhiteIdleAnim, -1.0f, Animation_GetLastFrame(&gGerudoWhiteIdleAnim), + 0.0f, ANIMMODE_ONCE, 8.0f); + pthis->animation = &gGerudoWhiteIdleAnim; + pthis->animFunc = EnGe1_CueUpAnimation; +} + +s32 EnGe1_CheckCarpentersFreed(void) { + u16 carpenterFlags = gSaveContext.eventChkInf[9]; + + if (!((carpenterFlags & 1) && (carpenterFlags & 2) && (carpenterFlags & 4) && (carpenterFlags & 8))) { + return 0; + } + return 1; +} + +/** + * Sends player to different places depending on if has hookshot, and if pthis is the first time captured + */ +void EnGe1_KickPlayer(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + + if (pthis->cutsceneTimer > 0) { + pthis->cutsceneTimer--; + } else { + func_8006D074(globalCtx); + + if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { + globalCtx->nextEntranceIndex = 0x1A5; + } else if (gSaveContext.eventChkInf[12] & 0x80) { // Caught previously + globalCtx->nextEntranceIndex = 0x5F8; + } else { + globalCtx->nextEntranceIndex = 0x3B4; + } + + globalCtx->fadeTransition = 0x26; + globalCtx->sceneLoadFlag = 0x14; + } +} + +void EnGe1_SpotPlayer(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->cutsceneTimer = 30; + pthis->actionFunc = EnGe1_KickPlayer; + func_8002DF54(globalCtx, &pthis->actor, 0x5F); + func_80078884(NA_SE_SY_FOUND); + Message_StartTextbox(globalCtx, 0x6000, &pthis->actor); +} + +void EnGe1_WatchForPlayerFrontOnly(EnGe1* pthis, GlobalContext* globalCtx) { + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(angleDiff) <= 0x4300) && (pthis->actor.xzDistToPlayer < 100.0f)) { + EnGe1_SpotPlayer(pthis, globalCtx); + } + + if (pthis->collider.base.acFlags & AC_HIT) { + EnGe1_SpotPlayer(pthis, globalCtx); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnGe1_ChooseActionFromTextId(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + switch (pthis->actor.textId) { + case 0x6001: + pthis->actionFunc = EnGe1_SetNormalText; + break; + + case 0x601A: + case 0x6019: + pthis->actionFunc = EnGe1_GetReaction_ValleyFloor; + break; + + case 0x6018: + pthis->actionFunc = EnGe1_CheckGate_GateOp; + break; + + default: + pthis->actionFunc = EnGe1_GetReaction_ValleyFloor; + break; + } + } +} + +void EnGe1_SetNormalText(EnGe1* pthis, GlobalContext* globalCtx) { + EnGe1_SetTalkAction(pthis, globalCtx, 0x6001, 100.0f, EnGe1_ChooseActionFromTextId); +} + +void EnGe1_WatchForAndSensePlayer(EnGe1* pthis, GlobalContext* globalCtx) { + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((pthis->actor.xzDistToPlayer < 50.0f) || ((ABS(angleDiff) <= 0x4300) && (pthis->actor.xzDistToPlayer < 400.0f))) { + EnGe1_SpotPlayer(pthis, globalCtx); + } + + if (pthis->collider.base.acFlags & AC_HIT) { + EnGe1_SpotPlayer(pthis, globalCtx); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnGe1_GetReaction_ValleyFloor(EnGe1* pthis, GlobalContext* globalCtx) { + u16 reactionText = Text_GetFaceReaction(globalCtx, 0x22); + + if (reactionText == 0) { + reactionText = 0x6019; + } + + EnGe1_SetTalkAction(pthis, globalCtx, reactionText, 100.0f, EnGe1_ChooseActionFromTextId); +} + +// Gerudo Training Ground Guard functions + +void EnGe1_WaitTillOpened_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + if (pthis->cutsceneTimer > 0) { + pthis->cutsceneTimer--; + } else { + EnGe1_SetAnimationIdle(pthis); + pthis->actionFunc = EnGe1_SetNormalText; + } + + pthis->stateFlags |= GE1_STATE_STOP_FIDGET; +} + +void EnGe1_Open_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + if (pthis->stateFlags & GE1_STATE_IDLE_ANIM) { + pthis->actionFunc = EnGe1_WaitTillOpened_GTGGuard; + Flags_SetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F); + pthis->cutsceneTimer = 50; + Message_CloseTextbox(globalCtx); + } else if ((pthis->skelAnime.curFrame == 15.0f) || (pthis->skelAnime.curFrame == 19.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_HAND_CLAP); + } +} + +void EnGe1_SetupOpen_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actionFunc = EnGe1_Open_GTGGuard; + Animation_Change(&pthis->skelAnime, &gGerudoWhiteClapAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoWhiteClapAnim), ANIMMODE_ONCE, -3.0f); + pthis->animation = &gGerudoWhiteClapAnim; + pthis->animFunc = EnGe1_StopFidget; + pthis->stateFlags &= ~GE1_STATE_IDLE_ANIM; + } +} + +void EnGe1_RefuseEntryTooPoor_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actionFunc = EnGe1_CheckForCard_GTGGuard; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_OfferOpen_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < 10) { + Message_ContinueTextbox(globalCtx, 0x6016); + pthis->actionFunc = EnGe1_RefuseEntryTooPoor_GTGGuard; + } else { + Rupees_ChangeBy(-10); + Message_ContinueTextbox(globalCtx, 0x6015); + pthis->actionFunc = EnGe1_SetupOpen_GTGGuard; + } + break; + case 1: + pthis->actionFunc = EnGe1_CheckForCard_GTGGuard; + EnGe1_SetAnimationIdle(pthis); + break; + } + } +} + +void EnGe1_RefuseOpenNoCard_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_CheckForCard_GTGGuard; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_CheckForCard_GTGGuard(EnGe1* pthis, GlobalContext* globalCtx) { + if (CHECK_QUEST_ITEM(QUEST_GERUDO_CARD)) { + EnGe1_SetTalkAction(pthis, globalCtx, 0x6014, 100.0f, EnGe1_OfferOpen_GTGGuard); + } else { + //! @bug This outcome is inaccessible in normal gameplay since pthis function it is unreachable without + //! obtaining the card in the first place. + EnGe1_SetTalkAction(pthis, globalCtx, 0x6013, 100.0f, EnGe1_RefuseOpenNoCard_GTGGuard); + } +} + +// Gate Operator functions + +void EnGe1_WaitGateOpen_GateOp(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnGe1_CheckGate_GateOp; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_WaitUntilGateOpened_GateOp(EnGe1* pthis, GlobalContext* globalCtx) { + if (pthis->cutsceneTimer > 0) { + pthis->cutsceneTimer--; + } else { + EnGe1_SetAnimationIdle(pthis); + pthis->actionFunc = EnGe1_CheckGate_GateOp; + } + pthis->stateFlags |= GE1_STATE_STOP_FIDGET; +} + +void EnGe1_OpenGate_GateOp(EnGe1* pthis, GlobalContext* globalCtx) { + if (pthis->stateFlags & GE1_STATE_IDLE_ANIM) { + pthis->actionFunc = EnGe1_WaitUntilGateOpened_GateOp; + Flags_SetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F); + pthis->cutsceneTimer = 50; + Message_CloseTextbox(globalCtx); + } else if ((pthis->skelAnime.curFrame == 15.0f) || (pthis->skelAnime.curFrame == 19.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_HAND_CLAP); + } +} + +void EnGe1_SetupOpenGate_GateOp(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actionFunc = EnGe1_OpenGate_GateOp; + Animation_Change(&pthis->skelAnime, &gGerudoWhiteClapAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoWhiteClapAnim), ANIMMODE_ONCE, -3.0f); + pthis->animation = &gGerudoWhiteClapAnim; + pthis->animFunc = EnGe1_StopFidget; + pthis->stateFlags &= ~GE1_STATE_IDLE_ANIM; + } +} + +void EnGe1_CheckGate_GateOp(EnGe1* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { + EnGe1_SetTalkAction(pthis, globalCtx, 0x6018, 100.0f, EnGe1_WaitGateOpen_GateOp); + } else { + EnGe1_SetTalkAction(pthis, globalCtx, 0x6017, 100.0f, EnGe1_SetupOpenGate_GateOp); + } +} + +// Gate guard functions + +void EnGe1_Talk_GateGuard(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_GetReaction_GateGuard; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_GetReaction_GateGuard(EnGe1* pthis, GlobalContext* globalCtx) { + u16 reactionText; + + reactionText = Text_GetFaceReaction(globalCtx, 0x22); + + if (reactionText == 0) { + reactionText = 0x6069; + } + + if (EnGe1_SetTalkAction(pthis, globalCtx, reactionText, 100.0f, EnGe1_Talk_GateGuard)) { + pthis->animFunc = EnGe1_CueUpAnimation; + pthis->animation = &gGerudoWhiteDismissiveAnim; + Animation_Change(&pthis->skelAnime, &gGerudoWhiteDismissiveAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoWhiteDismissiveAnim), ANIMMODE_ONCE, -8.0f); + } +} + +// Archery functions + +void EnGe1_SetupWait_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_Wait_Archery; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_WaitTillItemGiven_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + s32 getItemId; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_SetupWait_Archery; + if (pthis->stateFlags & GE1_STATE_GIVE_QUIVER) { + gSaveContext.itemGetInf[0] |= 0x8000; + } else { + gSaveContext.infTable[25] |= 1; + } + } else { + if (pthis->stateFlags & GE1_STATE_GIVE_QUIVER) { + switch (CUR_UPG_VALUE(UPG_QUIVER)) { + //! @bug Asschest. See next function for details + case 1: + getItemId = GI_QUIVER_40; + break; + case 2: + getItemId = GI_QUIVER_50; + break; + } + } else { + getItemId = GI_HEART_PIECE; + } + func_8002F434(&pthis->actor, globalCtx, getItemId, 10000.0f, 50.0f); + } +} + +void EnGe1_BeginGiveItem_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + s32 getItemId; + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = EnGe1_WaitTillItemGiven_Archery; + } + + if (pthis->stateFlags & GE1_STATE_GIVE_QUIVER) { + switch (CUR_UPG_VALUE(UPG_QUIVER)) { + //! @bug Asschest: the compiler inserts a default assigning *(sp+0x24) to getItemId, which is junk data left + //! over from the previous function run in EnGe1_Update, namely EnGe1_CueUpAnimation. The top stack variable + //! in that function is &pthis->skelAnime = thisx + 198, and depending on where pthis loads in memory, the + //! getItemId changes. + case 1: + getItemId = GI_QUIVER_40; + break; + case 2: + getItemId = GI_QUIVER_50; + break; + } + } else { + getItemId = GI_HEART_PIECE; + } + + func_8002F434(&pthis->actor, globalCtx, getItemId, 10000.0f, 50.0f); +} + +void EnGe1_TalkWinPrize_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_BeginGiveItem_Archery; + pthis->actor.flags &= ~ACTOR_FLAG_16; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 200.0f); + } +} + +void EnGe1_TalkTooPoor_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnGe1_Wait_Archery; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_WaitDoNothing(EnGe1* pthis, GlobalContext* globalCtx) { +} + +void EnGe1_BeginGame_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* horse; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < 20) { + Message_ContinueTextbox(globalCtx, 0x85); + pthis->actionFunc = EnGe1_TalkTooPoor_Archery; + } else { + Rupees_ChangeBy(-20); + globalCtx->nextEntranceIndex = 0x129; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->fadeTransition = 0x26; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.eventInf[0] |= 0x100; + gSaveContext.eventChkInf[6] |= 0x100; + + if (!(player->stateFlags1 & 0x800000)) { + func_8002DF54(globalCtx, &pthis->actor, 1); + } else { + horse = Actor_FindNearby(globalCtx, &player->actor, ACTOR_EN_HORSE, ACTORCAT_BG, 1200.0f); + player->actor.freezeTimer = 1200; + + if (horse != NULL) { + horse->freezeTimer = 1200; + } + } + + pthis->actionFunc = EnGe1_WaitDoNothing; + } + break; + + case 1: + pthis->actionFunc = EnGe1_Wait_Archery; + Message_CloseTextbox(globalCtx); + break; + } + } +} + +void EnGe1_TalkOfferPlay_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x6041); + pthis->actionFunc = EnGe1_BeginGame_Archery; + } +} + +void EnGe1_TalkNoPrize_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_TalkOfferPlay_Archery; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 300.0f); + } +} + +void EnGe1_TalkAfterGame_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + gSaveContext.eventInf[0] &= ~0x100; + LOG_NUM("z_common_data.yabusame_total", gSaveContext.minigameScore, "../z_en_ge1.c", 1110); + LOG_NUM("z_common_data.memory.information.room_inf[127][ 0 ]", HIGH_SCORE(HS_HBA), "../z_en_ge1.c", 1111); + pthis->actor.flags |= ACTOR_FLAG_16; + + if (HIGH_SCORE(HS_HBA) < gSaveContext.minigameScore) { + HIGH_SCORE(HS_HBA) = gSaveContext.minigameScore; + } + + if (gSaveContext.minigameScore < 1000) { + pthis->actor.textId = 0x6045; + pthis->actionFunc = EnGe1_TalkNoPrize_Archery; + } else if (!(gSaveContext.infTable[25] & 1)) { + pthis->actor.textId = 0x6046; + pthis->actionFunc = EnGe1_TalkWinPrize_Archery; + pthis->stateFlags &= ~GE1_STATE_GIVE_QUIVER; + } else if (gSaveContext.minigameScore < 1500) { + pthis->actor.textId = 0x6047; + pthis->actionFunc = EnGe1_TalkNoPrize_Archery; + } else if (gSaveContext.itemGetInf[0] & 0x8000) { + pthis->actor.textId = 0x6047; + pthis->actionFunc = EnGe1_TalkNoPrize_Archery; + } else { + pthis->actor.textId = 0x6044; + pthis->actionFunc = EnGe1_TalkWinPrize_Archery; + pthis->stateFlags |= GE1_STATE_GIVE_QUIVER; + } +} + +void EnGe1_TalkNoHorse_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE1_STATE_TALKING; + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe1_Wait_Archery; + EnGe1_SetAnimationIdle(pthis); + } +} + +void EnGe1_Wait_Archery(EnGe1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 textId; + + if (!(player->stateFlags1 & 0x800000)) { + EnGe1_SetTalkAction(pthis, globalCtx, 0x603F, 100.0f, EnGe1_TalkNoHorse_Archery); + } else { + if (gSaveContext.eventChkInf[6] & 0x100) { + if (gSaveContext.infTable[25] & 1) { + textId = 0x6042; + } else { + textId = 0x6043; + } + } else { + textId = 0x6040; + } + EnGe1_SetTalkAction(pthis, globalCtx, textId, 200.0f, EnGe1_TalkOfferPlay_Archery); + } +} + +// General functions + +void EnGe1_TurnToFacePlayer(EnGe1* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(angleDiff) <= 0x4000) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 6, 4000, 100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_2A2, pthis->actor.focus.pos); + } else { + if (angleDiff < 0) { + Math_SmoothStepToS(&pthis->headRot.y, -0x2000, 6, 6200, 0x100); + } else { + Math_SmoothStepToS(&pthis->headRot.y, 0x2000, 6, 6200, 0x100); + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 12, 1000, 100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } +} + +void EnGe1_LookAtPlayer(EnGe1* pthis, GlobalContext* globalCtx) { + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(angleDiff) <= 0x4300) && (pthis->actor.xzDistToPlayer < 100.0f)) { + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_2A2, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->headRot.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->headRot.y, 0, 6, 6200, 100); + } +} + +void EnGe1_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGe1* pthis = (EnGe1*)thisx; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 40.0f, 25.0f, 40.0f, 5); + pthis->animFunc(pthis); + pthis->actionFunc(pthis, globalCtx); + + if (pthis->stateFlags & GE1_STATE_TALKING) { + EnGe1_TurnToFacePlayer(pthis, globalCtx); + pthis->stateFlags &= ~GE1_STATE_TALKING; + } else { + EnGe1_LookAtPlayer(pthis, globalCtx); + } + pthis->unk_2A2.x = pthis->unk_2A2.y = pthis->unk_2A2.z = 0; + + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + pthis->eyeIndex = pthis->blinkTimer; + + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; + } +} + +// Animation functions + +void EnGe1_CueUpAnimation(EnGe1* pthis) { + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_PlayOnce(&pthis->skelAnime, pthis->animation); + } +} + +void EnGe1_StopFidget(EnGe1* pthis) { + if (!(pthis->stateFlags & GE1_STATE_IDLE_ANIM)) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->stateFlags |= GE1_STATE_IDLE_ANIM; + } + pthis->stateFlags |= GE1_STATE_STOP_FIDGET; + } +} + +s32 EnGe1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + s32 pad; + EnGe1* pthis = (EnGe1*)thisx; + + if (limbIndex == GE1_LIMB_HEAD) { + rot->x += pthis->headRot.y; + rot->z += pthis->headRot.x; + } + + if (pthis->stateFlags & GE1_STATE_STOP_FIDGET) { + pthis->stateFlags &= ~GE1_STATE_STOP_FIDGET; + return 0; + } + + // The purpose of the state flag GE1_STATE_STOP_FIDGET is to skip pthis code, which pthis actor has in lieu of an idle + // animation. + if ((limbIndex == GE1_LIMB_TORSO) || (limbIndex == GE1_LIMB_L_FOREARM) || (limbIndex == GE1_LIMB_R_FOREARM)) { + rot->y += Math_SinS(globalCtx->state.frames * (limbIndex * 50 + 0x814)) * 200.0f; + rot->z += Math_CosS(globalCtx->state.frames * (limbIndex * 50 + 0x940)) * 200.0f; + } + return 0; +} + +void EnGe1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnGe1* pthis = (EnGe1*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1419); + + if (limbIndex == GE1_LIMB_HEAD) { + gSPDisplayList(POLY_OPA_DISP++, sHairstyleDLists[pthis->hairstyle]); + Matrix_MultVec3f(&D_80A327A8, &pthis->actor.focus.pos); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1427); +} + +void EnGe1_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGe1* pthis = (EnGe1*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1442); + + func_800943C8(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnGe1_OverrideLimbDraw, EnGe1_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge1.c", 1459); +} diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c deleted file mode 100644 index f1def496a..000000000 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ /dev/null @@ -1,670 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GE2_Z_EN_GE2_C -#include "actor_common.h" -/* - * File: z_en_ge2.c - * Overlay: ovl_En_Ge2 - * Description: Purple-clothed Gerudo - */ - -#include "z_en_ge2.h" -#include "vt.h" -#include "objects/object_gla/object_gla.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_horse.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -#define GE2_STATE_ANIMCOMPLETE (1 << 1) -#define GE2_STATE_KO (1 << 2) -#define GE2_STATE_CAPTURING (1 << 3) -#define GE2_STATE_TALKED (1 << 4) - -typedef enum { - /* 0 */ GE2_TYPE_PATROLLING, - /* 1 */ GE2_TYPE_STATIONARY, - /* 2 */ GE2_TYPE_GERUDO_CARD_GIVER -} EnGe2Type; - -typedef enum { - /* 0 */ GE2_ACTION_WALK, - /* 1 */ GE2_ACTION_ABOUTTURN, - /* 2 */ GE2_ACTION_TURNPLAYERSPOTTED, - /* 3 */ GE2_ACTION_KNOCKEDOUT, - /* 4 */ GE2_ACTION_CAPTURETURN, - /* 5 */ GE2_ACTION_CAPTURECHARGE, - /* 6 */ GE2_ACTION_CAPTURECLOSE, - /* 7 */ GE2_ACTION_STAND, - /* 8 */ GE2_ACTION_WAITLOOKATPLAYER -} EnGe2Action; - -void EnGe2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 EnGe2_CheckCarpentersFreed(void); -void EnGe2_CaptureClose(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_CaptureCharge(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_CaptureTurn(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_KnockedOut(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_TurnPlayerSpotted(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_AboutTurn(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_Walk(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_Stand(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_WaitLookAtPlayer(EnGe2* this, GlobalContext* globalCtx); -void EnGe2_ForceTalk(EnGe2* this, GlobalContext* globalCtx); - -// Update functions -void EnGe2_UpdateFriendly(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_UpdateAfterTalk(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_UpdateStunned(Actor* thisx, GlobalContext* globalCtx); - -const ActorInit En_Ge2_InitVars = { - ACTOR_EN_GE2, - ACTORCAT_NPC, - FLAGS, - OBJECT_GLA, - sizeof(EnGe2), - (ActorFunc)EnGe2_Init, - (ActorFunc)EnGe2_Destroy, - (ActorFunc)EnGe2_Update, - (ActorFunc)EnGe2_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x000007A2, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 60, 0, { 0, 0, 0 } }, -}; - -static EnGe2ActionFunc sActionFuncs[] = { - EnGe2_Walk, EnGe2_AboutTurn, EnGe2_TurnPlayerSpotted, - EnGe2_KnockedOut, EnGe2_CaptureTurn, EnGe2_CaptureCharge, - EnGe2_CaptureClose, EnGe2_Stand, EnGe2_WaitLookAtPlayer, -}; - -static AnimationHeader* sAnimations[] = { - &gGerudoPurpleWalkingAnim, &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleLookingAboutAnim, - &gGerudoPurpleFallingToGroundAnim, &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleChargingAnim, - &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleLookingAboutAnim, -}; - -static u8 sAnimModes[] = { - ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, -}; - -void EnGe2_ChangeAction(EnGe2* this, s32 i) { - this->actionFunc = sActionFuncs[i]; - Animation_Change(&this->skelAnime, sAnimations[i], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[i]), - sAnimModes[i], -8.0f); - this->stateFlags &= ~GE2_STATE_ANIMCOMPLETE; -} - -void EnGe2_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnGe2* this = (EnGe2*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGerudoPurpleSkel, NULL, this->jointTable, this->morphTable, 22); - Animation_PlayLoop(&this->skelAnime, &gGerudoPurpleWalkingAnim); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - - if (globalCtx->sceneNum == SCENE_SPOT09) { - this->actor.uncullZoneForward = 1000.0f; - } else { - this->actor.uncullZoneForward = 1200.0f; - } - - this->yDetectRange = (this->actor.world.rot.z + 1) * 40.0f; - this->actor.world.rot.z = 0; - this->actor.shape.rot.z = 0; - - switch (this->actor.params & 0xFF) { - case GE2_TYPE_PATROLLING: - EnGe2_ChangeAction(this, GE2_ACTION_WALK); - if (EnGe2_CheckCarpentersFreed()) { - this->actor.update = EnGe2_UpdateFriendly; - this->actor.targetMode = 6; - } - break; - case GE2_TYPE_STATIONARY: - EnGe2_ChangeAction(this, GE2_ACTION_STAND); - if (EnGe2_CheckCarpentersFreed()) { - this->actor.update = EnGe2_UpdateFriendly; - this->actor.targetMode = 6; - } - break; - case GE2_TYPE_GERUDO_CARD_GIVER: - EnGe2_ChangeAction(this, GE2_ACTION_WAITLOOKATPLAYER); - this->actor.update = EnGe2_UpdateAfterTalk; - this->actionFunc = EnGe2_ForceTalk; - this->actor.targetMode = 6; - break; - default: - ASSERT(0, "0", "../z_en_ge2.c", 418); - } - - this->stateFlags = 0; - this->unk_304 = 0; // Set and not used - this->walkTimer = 0; - this->playerSpottedParam = 0; - this->actor.minVelocityY = -4.0f; - this->actor.gravity = -1.0f; - this->walkDirection = this->actor.world.rot.y; - this->walkDuration = ((this->actor.params & 0xFF00) >> 8) * 10; -} - -void EnGe2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGe2* this = (EnGe2*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -// Detection/check functions - -s32 Ge2_DetectPlayerInAction(GlobalContext* globalCtx, EnGe2* this) { - f32 visionScale; - - visionScale = (!IS_DAY ? 0.75f : 1.5f); - - if ((250.0f * visionScale) < this->actor.xzDistToPlayer) { - return 0; - } - - if (this->actor.xzDistToPlayer < 50.0f) { - return 2; - } - - if (func_8002DDE4(globalCtx)) { - return 1; - } - return 0; -} - -s32 Ge2_DetectPlayerInUpdate(GlobalContext* globalCtx, EnGe2* this, Vec3f* pos, s16 yRot, f32 yDetectRange) { - Player* player = GET_PLAYER(globalCtx); - Vec3f posResult; - CollisionPoly* outPoly; - f32 visionScale; - - visionScale = (!IS_DAY ? 0.75f : 1.5f); - - if ((250.0f * visionScale) < this->actor.xzDistToPlayer) { - return 0; - } - - if (yDetectRange < ABS(this->actor.yDistToPlayer)) { - return 0; - } - - if (ABS((s16)(this->actor.yawTowardsPlayer - yRot)) > 0x2000) { - return 0; - } - - if (BgCheck_AnyLineTest1(&globalCtx->colCtx, pos, &player->bodyPartsPos[7], &posResult, &outPoly, 0)) { - return 0; - } - return 1; -} - -s32 EnGe2_CheckCarpentersFreed(void) { - if ((u8)(gSaveContext.eventChkInf[9] & 0xF) == 0xF) { - return 1; - } - return 0; -} - -// Actions - -void EnGe2_CaptureClose(EnGe2* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; - } else { - func_8006D074(globalCtx); - - if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { - globalCtx->nextEntranceIndex = 0x1A5; - } else if (gSaveContext.eventChkInf[12] & 0x80) { - globalCtx->nextEntranceIndex = 0x5F8; - } else { - globalCtx->nextEntranceIndex = 0x3B4; - } - - globalCtx->fadeTransition = 0x26; - globalCtx->sceneLoadFlag = 0x14; - } -} - -void EnGe2_CaptureCharge(EnGe2* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 0x400, 0x100); - this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->actor.xzDistToPlayer < 50.0f) { - EnGe2_ChangeAction(this, GE2_ACTION_CAPTURECLOSE); - this->actor.speedXZ = 0.0f; - } - - if (this->timer > 0) { - this->timer--; - } else { - func_8006D074(globalCtx); - - if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { - globalCtx->nextEntranceIndex = 0x1A5; - } else if (gSaveContext.eventChkInf[12] & 0x80) { - globalCtx->nextEntranceIndex = 0x5F8; - } else { - globalCtx->nextEntranceIndex = 0x3B4; - } - - globalCtx->fadeTransition = 0x26; - globalCtx->sceneLoadFlag = 0x14; - } -} - -void EnGe2_CaptureTurn(EnGe2* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 0x400, 0x100); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->actor.world.rot.y == this->actor.yawTowardsPlayer) { - EnGe2_ChangeAction(this, GE2_ACTION_CAPTURECHARGE); - this->timer = 50; - this->actor.speedXZ = 4.0f; - } -} - -void EnGe2_KnockedOut(EnGe2* this, GlobalContext* globalCtx) { - static Vec3f effectVelocity = { 0.0f, -0.05f, 0.0f }; - static Vec3f effectAccel = { 0.0f, -0.025f, 0.0f }; - static Color_RGBA8 effectPrimColor = { 255, 255, 255, 0 }; - static Color_RGBA8 effectEnvColor = { 255, 150, 0, 0 }; - s32 effectAngle; - Vec3f effectPos; - - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->stateFlags & GE2_STATE_ANIMCOMPLETE) { - effectAngle = (globalCtx->state.frames) * 0x2800; - effectPos.x = this->actor.focus.pos.x + (Math_CosS(effectAngle) * 5.0f); - effectPos.y = this->actor.focus.pos.y + 10.0f; - effectPos.z = this->actor.focus.pos.z + (Math_SinS(effectAngle) * 5.0f); - EffectSsKiraKira_SpawnDispersed(globalCtx, &effectPos, &effectVelocity, &effectAccel, &effectPrimColor, - &effectEnvColor, 1000, 16); - } -} - -void EnGe2_TurnPlayerSpotted(EnGe2* this, GlobalContext* globalCtx) { - s32 playerSpotted; - - this->actor.speedXZ = 0.0f; - - if (this->stateFlags & GE2_STATE_TALKED) { - this->stateFlags &= ~GE2_STATE_TALKED; - } else { - playerSpotted = Ge2_DetectPlayerInAction(globalCtx, this); - - if (playerSpotted != 0) { - this->timer = 100; - this->yawTowardsPlayer = this->actor.yawTowardsPlayer; - - if (this->playerSpottedParam < playerSpotted) { - this->playerSpottedParam = playerSpotted; - } - } else if (this->actor.world.rot.y == this->yawTowardsPlayer) { - this->playerSpottedParam = 0; - EnGe2_ChangeAction(this, GE2_ACTION_ABOUTTURN); - return; - } - } - - switch (this->playerSpottedParam) { - case 1: - Math_SmoothStepToS(&this->actor.world.rot.y, this->yawTowardsPlayer, 2, 0x200, 0x100); - break; - case 2: - Math_SmoothStepToS(&this->actor.world.rot.y, this->yawTowardsPlayer, 2, 0x600, 0x180); - break; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnGe2_AboutTurn(EnGe2* this, GlobalContext* globalCtx) { - s32 playerSpotted; - - this->actor.speedXZ = 0.0f; - playerSpotted = Ge2_DetectPlayerInAction(globalCtx, this); - - if (playerSpotted != 0) { - EnGe2_ChangeAction(this, GE2_ACTION_TURNPLAYERSPOTTED); - this->timer = 100; - this->playerSpottedParam = playerSpotted; - this->yawTowardsPlayer = this->actor.yawTowardsPlayer; - } else if (this->stateFlags & GE2_STATE_ANIMCOMPLETE) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->walkDirection, 2, 0x400, 0x200); - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - if (this->actor.shape.rot.y == this->walkDirection) { - EnGe2_ChangeAction(this, GE2_ACTION_WALK); - } -} - -void EnGe2_Walk(EnGe2* this, GlobalContext* globalCtx) { - u8 playerSpotted; - - playerSpotted = Ge2_DetectPlayerInAction(globalCtx, this); - if (playerSpotted != 0) { - this->actor.speedXZ = 0.0f; - EnGe2_ChangeAction(this, GE2_ACTION_TURNPLAYERSPOTTED); - this->timer = 100; - this->playerSpottedParam = playerSpotted; - this->yawTowardsPlayer = this->actor.yawTowardsPlayer; - } else if (this->walkTimer >= this->walkDuration) { - this->walkTimer = 0; - this->walkDirection += 0x8000; - EnGe2_ChangeAction(this, GE2_ACTION_ABOUTTURN); - this->actor.speedXZ = 0.0f; - } else { - this->walkTimer++; - this->actor.speedXZ = 2.0f; - } -} - -void EnGe2_Stand(EnGe2* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->walkDirection, 2, 0x400, 0x200); -} - -void EnGe2_TurnToFacePlayer(EnGe2* this, GlobalContext* globalCtx) { - s32 pad; - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(angleDiff) <= 0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 4000, 100); - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_2EE, this->actor.focus.pos); - } else { - if (angleDiff < 0) { - Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 6200, 0x100); - } else { - Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 6200, 0x100); - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 1000, 100); - this->actor.world.rot.y = this->actor.shape.rot.y; - } -} - -void EnGe2_LookAtPlayer(EnGe2* this, GlobalContext* globalCtx) { - if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4300) && - (this->actor.xzDistToPlayer < 200.0f)) { - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_2EE, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->headRot.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->headRot.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2EE.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2EE.y, 0, 6, 6200, 100); - } -} - -void EnGe2_SetActionAfterTalk(EnGe2* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - - switch (this->actor.params & 0xFF) { - case GE2_TYPE_PATROLLING: - EnGe2_ChangeAction(this, GE2_ACTION_ABOUTTURN); - break; - case GE2_TYPE_STATIONARY: - EnGe2_ChangeAction(this, GE2_ACTION_STAND); - break; - case GE2_TYPE_GERUDO_CARD_GIVER: - this->actionFunc = EnGe2_WaitLookAtPlayer; - break; - } - this->actor.update = EnGe2_UpdateFriendly; - this->actor.flags &= ~ACTOR_FLAG_16; - } - EnGe2_TurnToFacePlayer(this, globalCtx); -} - -void EnGe2_WaitLookAtPlayer(EnGe2* this, GlobalContext* globalCtx) { - EnGe2_LookAtPlayer(this, globalCtx); -} - -void EnGe2_WaitTillCardGiven(EnGe2* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnGe2_SetActionAfterTalk; - } else { - func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); - } -} - -void EnGe2_GiveCard(EnGe2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = EnGe2_WaitTillCardGiven; - func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); - } -} - -void EnGe2_ForceTalk(EnGe2* this, GlobalContext* globalCtx) { - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnGe2_GiveCard; - } else { - this->actor.textId = 0x6004; - this->actor.flags |= ACTOR_FLAG_16; - func_8002F1C4(&this->actor, globalCtx, 300.0f, 300.0f, 0); - } - EnGe2_LookAtPlayer(this, globalCtx); -} - -void EnGe2_SetupCapturePlayer(EnGe2* this, GlobalContext* globalCtx) { - this->stateFlags |= GE2_STATE_CAPTURING; - this->actor.speedXZ = 0.0f; - EnGe2_ChangeAction(this, GE2_ACTION_CAPTURETURN); - func_8002DF54(globalCtx, &this->actor, 95); - func_80078884(NA_SE_SY_FOUND); - Message_StartTextbox(globalCtx, 0x6000, &this->actor); -} - -void EnGe2_MaintainColliderAndSetAnimState(EnGe2* this, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); - - if (!(this->stateFlags & GE2_STATE_ANIMCOMPLETE) && SkelAnime_Update(&this->skelAnime)) { - this->stateFlags |= GE2_STATE_ANIMCOMPLETE; - } -} - -void EnGe2_MoveAndBlink(EnGe2* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->actor); - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - this->eyeIndex = this->blinkTimer; - - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; - } -} - -// Update functions - -void EnGe2_UpdateFriendly(Actor* thisx, GlobalContext* globalCtx) { - EnGe2* this = (EnGe2*)thisx; - - EnGe2_MaintainColliderAndSetAnimState(this, globalCtx); - this->actionFunc(this, globalCtx); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if ((this->actor.params & 0xFF) == GE2_TYPE_PATROLLING) { - this->actor.speedXZ = 0.0f; - EnGe2_ChangeAction(this, GE2_ACTION_WAITLOOKATPLAYER); - } - this->actionFunc = EnGe2_SetActionAfterTalk; - this->actor.update = EnGe2_UpdateAfterTalk; - } else { - this->actor.textId = 0x6005; - - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - EnGe2_MoveAndBlink(this, globalCtx); -} - -void EnGe2_UpdateAfterTalk(Actor* thisx, GlobalContext* globalCtx) { - EnGe2* this = (EnGe2*)thisx; - - this->stateFlags |= GE2_STATE_TALKED; - EnGe2_MaintainColliderAndSetAnimState(this, globalCtx); - this->actionFunc(this, globalCtx); - EnGe2_MoveAndBlink(this, globalCtx); -} - -void EnGe2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGe2* this = (EnGe2*)thisx; - s32 paramsType; - - EnGe2_MaintainColliderAndSetAnimState(this, globalCtx); - - if ((this->stateFlags & GE2_STATE_KO) || (this->stateFlags & GE2_STATE_CAPTURING)) { - this->actionFunc(this, globalCtx); - } else if (this->collider.base.acFlags & 2) { - if ((this->collider.info.acHitInfo != NULL) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80)) { - Actor_SetColorFilter(&this->actor, 0, 120, 0, 400); - this->actor.update = EnGe2_UpdateStunned; - return; - } - - EnGe2_ChangeAction(this, GE2_ACTION_KNOCKEDOUT); - this->timer = 100; - this->stateFlags |= GE2_STATE_KO; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_SK_CRASH); - } else { - this->actionFunc(this, globalCtx); - - if (Ge2_DetectPlayerInUpdate(globalCtx, this, &this->actor.focus.pos, this->actor.shape.rot.y, - this->yDetectRange)) { - // "Discovered!" - osSyncPrintf(VT_FGCOL(GREEN) "発見!!!!!!!!!!!!\n" VT_RST); - EnGe2_SetupCapturePlayer(this, globalCtx); - } - - if (((this->actor.params & 0xFF) == GE2_TYPE_STATIONARY) && (this->actor.xzDistToPlayer < 100.0f)) { - // "Discovered!" - osSyncPrintf(VT_FGCOL(GREEN) "発見!!!!!!!!!!!!\n" VT_RST); - EnGe2_SetupCapturePlayer(this, globalCtx); - } - } - - if (!(this->stateFlags & GE2_STATE_KO)) { - paramsType = this->actor.params & 0xFF; // Not necessary, but looks a bit nicer - if ((paramsType == GE2_TYPE_PATROLLING) || (paramsType == GE2_TYPE_STATIONARY)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - EnGe2_MoveAndBlink(this, globalCtx); - - if (EnGe2_CheckCarpentersFreed() && !(this->stateFlags & GE2_STATE_KO)) { - this->actor.update = EnGe2_UpdateFriendly; - this->actor.targetMode = 6; - } -} - -void EnGe2_UpdateStunned(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnGe2* this = (EnGe2*)thisx; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); - - if ((this->collider.base.acFlags & 2) && - ((this->collider.info.acHitInfo == NULL) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0x80))) { - this->actor.colorFilterTimer = 0; - EnGe2_ChangeAction(this, GE2_ACTION_KNOCKEDOUT); - this->timer = 100; - this->stateFlags |= GE2_STATE_KO; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_SK_CRASH); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (EnGe2_CheckCarpentersFreed()) { - this->actor.update = EnGe2_UpdateFriendly; - this->actor.targetMode = 6; - this->actor.colorFilterTimer = 0; - } else if (this->actor.colorFilterTimer == 0) { - this->actor.update = EnGe2_Update; - } -} - -s32 EnGe2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnGe2* this = (EnGe2*)thisx; - - if (limbIndex == 3) { - rot->x += this->headRot.y; - rot->z += this->headRot.x; - } - return 0; -} - -void EnGe2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_80A343B0 = { 600.0f, 700.0f, 0.0f }; - EnGe2* this = (EnGe2*)thisx; - - if (limbIndex == 6) { - Matrix_MultVec3f(&D_80A343B0, &this->actor.focus.pos); - } -} - -void EnGe2_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gGerudoPurpleEyeOpenTex, gGerudoPurpleEyeHalfTex, gGerudoPurpleEyeClosedTex }; - s32 pad; - EnGe2* this = (EnGe2*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge2.c", 1274); - - func_800943C8(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); - func_8002EBCC(&this->actor, globalCtx, 0); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnGe2_OverrideLimbDraw, EnGe2_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge2.c", 1291); -} diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.cpp b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.cpp new file mode 100644 index 000000000..40de9b6fa --- /dev/null +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.cpp @@ -0,0 +1,670 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GE2_Z_EN_GE2_C +#include "actor_common.h" +/* + * File: z_en_ge2.c + * Overlay: ovl_En_Ge2 + * Description: Purple-clothed Gerudo + */ + +#include "z_en_ge2.h" +#include "vt.h" +#include "objects/object_gla/object_gla.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_horse.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +#define GE2_STATE_ANIMCOMPLETE (1 << 1) +#define GE2_STATE_KO (1 << 2) +#define GE2_STATE_CAPTURING (1 << 3) +#define GE2_STATE_TALKED (1 << 4) + +typedef enum { + /* 0 */ GE2_TYPE_PATROLLING, + /* 1 */ GE2_TYPE_STATIONARY, + /* 2 */ GE2_TYPE_GERUDO_CARD_GIVER +} EnGe2Type; + +typedef enum { + /* 0 */ GE2_ACTION_WALK, + /* 1 */ GE2_ACTION_ABOUTTURN, + /* 2 */ GE2_ACTION_TURNPLAYERSPOTTED, + /* 3 */ GE2_ACTION_KNOCKEDOUT, + /* 4 */ GE2_ACTION_CAPTURETURN, + /* 5 */ GE2_ACTION_CAPTURECHARGE, + /* 6 */ GE2_ACTION_CAPTURECLOSE, + /* 7 */ GE2_ACTION_STAND, + /* 8 */ GE2_ACTION_WAITLOOKATPLAYER +} EnGe2Action; + +void EnGe2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGe2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGe2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGe2_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 EnGe2_CheckCarpentersFreed(void); +void EnGe2_CaptureClose(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_CaptureCharge(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_CaptureTurn(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_KnockedOut(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_TurnPlayerSpotted(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_AboutTurn(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_Walk(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_Stand(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_WaitLookAtPlayer(EnGe2* pthis, GlobalContext* globalCtx); +void EnGe2_ForceTalk(EnGe2* pthis, GlobalContext* globalCtx); + +// Update functions +void EnGe2_UpdateFriendly(Actor* thisx, GlobalContext* globalCtx); +void EnGe2_UpdateAfterTalk(Actor* thisx, GlobalContext* globalCtx); +void EnGe2_UpdateStunned(Actor* thisx, GlobalContext* globalCtx); + +ActorInit En_Ge2_InitVars = { + ACTOR_EN_GE2, + ACTORCAT_NPC, + FLAGS, + OBJECT_GLA, + sizeof(EnGe2), + (ActorFunc)EnGe2_Init, + (ActorFunc)EnGe2_Destroy, + (ActorFunc)EnGe2_Update, + (ActorFunc)EnGe2_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x000007A2, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 60, 0, { 0, 0, 0 } }, +}; + +static EnGe2ActionFunc sActionFuncs[] = { + EnGe2_Walk, EnGe2_AboutTurn, EnGe2_TurnPlayerSpotted, + EnGe2_KnockedOut, EnGe2_CaptureTurn, EnGe2_CaptureCharge, + EnGe2_CaptureClose, EnGe2_Stand, EnGe2_WaitLookAtPlayer, +}; + +static AnimationHeader* sAnimations[] = { + &gGerudoPurpleWalkingAnim, &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleLookingAboutAnim, + &gGerudoPurpleFallingToGroundAnim, &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleChargingAnim, + &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleLookingAboutAnim, &gGerudoPurpleLookingAboutAnim, +}; + +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, +}; + +void EnGe2_ChangeAction(EnGe2* pthis, s32 i) { + pthis->actionFunc = sActionFuncs[i]; + Animation_Change(&pthis->skelAnime, sAnimations[i], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[i]), + sAnimModes[i], -8.0f); + pthis->stateFlags &= ~GE2_STATE_ANIMCOMPLETE; +} + +void EnGe2_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGe2* pthis = (EnGe2*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGerudoPurpleSkel, NULL, pthis->jointTable, pthis->morphTable, 22); + Animation_PlayLoop(&pthis->skelAnime, &gGerudoPurpleWalkingAnim); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + + if (globalCtx->sceneNum == SCENE_SPOT09) { + pthis->actor.uncullZoneForward = 1000.0f; + } else { + pthis->actor.uncullZoneForward = 1200.0f; + } + + pthis->yDetectRange = (pthis->actor.world.rot.z + 1) * 40.0f; + pthis->actor.world.rot.z = 0; + pthis->actor.shape.rot.z = 0; + + switch (pthis->actor.params & 0xFF) { + case GE2_TYPE_PATROLLING: + EnGe2_ChangeAction(pthis, GE2_ACTION_WALK); + if (EnGe2_CheckCarpentersFreed()) { + pthis->actor.update = EnGe2_UpdateFriendly; + pthis->actor.targetMode = 6; + } + break; + case GE2_TYPE_STATIONARY: + EnGe2_ChangeAction(pthis, GE2_ACTION_STAND); + if (EnGe2_CheckCarpentersFreed()) { + pthis->actor.update = EnGe2_UpdateFriendly; + pthis->actor.targetMode = 6; + } + break; + case GE2_TYPE_GERUDO_CARD_GIVER: + EnGe2_ChangeAction(pthis, GE2_ACTION_WAITLOOKATPLAYER); + pthis->actor.update = EnGe2_UpdateAfterTalk; + pthis->actionFunc = EnGe2_ForceTalk; + pthis->actor.targetMode = 6; + break; + default: + ASSERT(0, "0", "../z_en_ge2.c", 418); + } + + pthis->stateFlags = 0; + pthis->unk_304 = 0; // Set and not used + pthis->walkTimer = 0; + pthis->playerSpottedParam = 0; + pthis->actor.minVelocityY = -4.0f; + pthis->actor.gravity = -1.0f; + pthis->walkDirection = pthis->actor.world.rot.y; + pthis->walkDuration = ((pthis->actor.params & 0xFF00) >> 8) * 10; +} + +void EnGe2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGe2* pthis = (EnGe2*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +// Detection/check functions + +s32 Ge2_DetectPlayerInAction(GlobalContext* globalCtx, EnGe2* pthis) { + f32 visionScale; + + visionScale = (!IS_DAY ? 0.75f : 1.5f); + + if ((250.0f * visionScale) < pthis->actor.xzDistToPlayer) { + return 0; + } + + if (pthis->actor.xzDistToPlayer < 50.0f) { + return 2; + } + + if (func_8002DDE4(globalCtx)) { + return 1; + } + return 0; +} + +s32 Ge2_DetectPlayerInUpdate(GlobalContext* globalCtx, EnGe2* pthis, Vec3f* pos, s16 yRot, f32 yDetectRange) { + Player* player = GET_PLAYER(globalCtx); + Vec3f posResult; + CollisionPoly* outPoly; + f32 visionScale; + + visionScale = (!IS_DAY ? 0.75f : 1.5f); + + if ((250.0f * visionScale) < pthis->actor.xzDistToPlayer) { + return 0; + } + + if (yDetectRange < ABS(pthis->actor.yDistToPlayer)) { + return 0; + } + + if (ABS((s16)(pthis->actor.yawTowardsPlayer - yRot)) > 0x2000) { + return 0; + } + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, pos, &player->bodyPartsPos[7], &posResult, &outPoly, 0)) { + return 0; + } + return 1; +} + +s32 EnGe2_CheckCarpentersFreed(void) { + if ((u8)(gSaveContext.eventChkInf[9] & 0xF) == 0xF) { + return 1; + } + return 0; +} + +// Actions + +void EnGe2_CaptureClose(EnGe2* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; + } else { + func_8006D074(globalCtx); + + if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { + globalCtx->nextEntranceIndex = 0x1A5; + } else if (gSaveContext.eventChkInf[12] & 0x80) { + globalCtx->nextEntranceIndex = 0x5F8; + } else { + globalCtx->nextEntranceIndex = 0x3B4; + } + + globalCtx->fadeTransition = 0x26; + globalCtx->sceneLoadFlag = 0x14; + } +} + +void EnGe2_CaptureCharge(EnGe2* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 2, 0x400, 0x100); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (pthis->actor.xzDistToPlayer < 50.0f) { + EnGe2_ChangeAction(pthis, GE2_ACTION_CAPTURECLOSE); + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->timer > 0) { + pthis->timer--; + } else { + func_8006D074(globalCtx); + + if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { + globalCtx->nextEntranceIndex = 0x1A5; + } else if (gSaveContext.eventChkInf[12] & 0x80) { + globalCtx->nextEntranceIndex = 0x5F8; + } else { + globalCtx->nextEntranceIndex = 0x3B4; + } + + globalCtx->fadeTransition = 0x26; + globalCtx->sceneLoadFlag = 0x14; + } +} + +void EnGe2_CaptureTurn(EnGe2* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 2, 0x400, 0x100); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->actor.world.rot.y == pthis->actor.yawTowardsPlayer) { + EnGe2_ChangeAction(pthis, GE2_ACTION_CAPTURECHARGE); + pthis->timer = 50; + pthis->actor.speedXZ = 4.0f; + } +} + +void EnGe2_KnockedOut(EnGe2* pthis, GlobalContext* globalCtx) { + static Vec3f effectVelocity = { 0.0f, -0.05f, 0.0f }; + static Vec3f effectAccel = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 effectPrimColor = { 255, 255, 255, 0 }; + static Color_RGBA8 effectEnvColor = { 255, 150, 0, 0 }; + s32 effectAngle; + Vec3f effectPos; + + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->stateFlags & GE2_STATE_ANIMCOMPLETE) { + effectAngle = (globalCtx->state.frames) * 0x2800; + effectPos.x = pthis->actor.focus.pos.x + (Math_CosS(effectAngle) * 5.0f); + effectPos.y = pthis->actor.focus.pos.y + 10.0f; + effectPos.z = pthis->actor.focus.pos.z + (Math_SinS(effectAngle) * 5.0f); + EffectSsKiraKira_SpawnDispersed(globalCtx, &effectPos, &effectVelocity, &effectAccel, &effectPrimColor, + &effectEnvColor, 1000, 16); + } +} + +void EnGe2_TurnPlayerSpotted(EnGe2* pthis, GlobalContext* globalCtx) { + s32 playerSpotted; + + pthis->actor.speedXZ = 0.0f; + + if (pthis->stateFlags & GE2_STATE_TALKED) { + pthis->stateFlags &= ~GE2_STATE_TALKED; + } else { + playerSpotted = Ge2_DetectPlayerInAction(globalCtx, pthis); + + if (playerSpotted != 0) { + pthis->timer = 100; + pthis->yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + + if (pthis->playerSpottedParam < playerSpotted) { + pthis->playerSpottedParam = playerSpotted; + } + } else if (pthis->actor.world.rot.y == pthis->yawTowardsPlayer) { + pthis->playerSpottedParam = 0; + EnGe2_ChangeAction(pthis, GE2_ACTION_ABOUTTURN); + return; + } + } + + switch (pthis->playerSpottedParam) { + case 1: + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->yawTowardsPlayer, 2, 0x200, 0x100); + break; + case 2: + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->yawTowardsPlayer, 2, 0x600, 0x180); + break; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnGe2_AboutTurn(EnGe2* pthis, GlobalContext* globalCtx) { + s32 playerSpotted; + + pthis->actor.speedXZ = 0.0f; + playerSpotted = Ge2_DetectPlayerInAction(globalCtx, pthis); + + if (playerSpotted != 0) { + EnGe2_ChangeAction(pthis, GE2_ACTION_TURNPLAYERSPOTTED); + pthis->timer = 100; + pthis->playerSpottedParam = playerSpotted; + pthis->yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + } else if (pthis->stateFlags & GE2_STATE_ANIMCOMPLETE) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->walkDirection, 2, 0x400, 0x200); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + if (pthis->actor.shape.rot.y == pthis->walkDirection) { + EnGe2_ChangeAction(pthis, GE2_ACTION_WALK); + } +} + +void EnGe2_Walk(EnGe2* pthis, GlobalContext* globalCtx) { + u8 playerSpotted; + + playerSpotted = Ge2_DetectPlayerInAction(globalCtx, pthis); + if (playerSpotted != 0) { + pthis->actor.speedXZ = 0.0f; + EnGe2_ChangeAction(pthis, GE2_ACTION_TURNPLAYERSPOTTED); + pthis->timer = 100; + pthis->playerSpottedParam = playerSpotted; + pthis->yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + } else if (pthis->walkTimer >= pthis->walkDuration) { + pthis->walkTimer = 0; + pthis->walkDirection += 0x8000; + EnGe2_ChangeAction(pthis, GE2_ACTION_ABOUTTURN); + pthis->actor.speedXZ = 0.0f; + } else { + pthis->walkTimer++; + pthis->actor.speedXZ = 2.0f; + } +} + +void EnGe2_Stand(EnGe2* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->walkDirection, 2, 0x400, 0x200); +} + +void EnGe2_TurnToFacePlayer(EnGe2* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(angleDiff) <= 0x4000) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 6, 4000, 100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_2EE, pthis->actor.focus.pos); + } else { + if (angleDiff < 0) { + Math_SmoothStepToS(&pthis->headRot.y, -0x2000, 6, 6200, 0x100); + } else { + Math_SmoothStepToS(&pthis->headRot.y, 0x2000, 6, 6200, 0x100); + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 12, 1000, 100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } +} + +void EnGe2_LookAtPlayer(EnGe2* pthis, GlobalContext* globalCtx) { + if ((ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4300) && + (pthis->actor.xzDistToPlayer < 200.0f)) { + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_2EE, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->headRot.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->headRot.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2EE.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2EE.y, 0, 6, 6200, 100); + } +} + +void EnGe2_SetActionAfterTalk(EnGe2* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + + switch (pthis->actor.params & 0xFF) { + case GE2_TYPE_PATROLLING: + EnGe2_ChangeAction(pthis, GE2_ACTION_ABOUTTURN); + break; + case GE2_TYPE_STATIONARY: + EnGe2_ChangeAction(pthis, GE2_ACTION_STAND); + break; + case GE2_TYPE_GERUDO_CARD_GIVER: + pthis->actionFunc = EnGe2_WaitLookAtPlayer; + break; + } + pthis->actor.update = EnGe2_UpdateFriendly; + pthis->actor.flags &= ~ACTOR_FLAG_16; + } + EnGe2_TurnToFacePlayer(pthis, globalCtx); +} + +void EnGe2_WaitLookAtPlayer(EnGe2* pthis, GlobalContext* globalCtx) { + EnGe2_LookAtPlayer(pthis, globalCtx); +} + +void EnGe2_WaitTillCardGiven(EnGe2* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnGe2_SetActionAfterTalk; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } +} + +void EnGe2_GiveCard(EnGe2* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = EnGe2_WaitTillCardGiven; + func_8002F434(&pthis->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } +} + +void EnGe2_ForceTalk(EnGe2* pthis, GlobalContext* globalCtx) { + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe2_GiveCard; + } else { + pthis->actor.textId = 0x6004; + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F1C4(&pthis->actor, globalCtx, 300.0f, 300.0f, 0); + } + EnGe2_LookAtPlayer(pthis, globalCtx); +} + +void EnGe2_SetupCapturePlayer(EnGe2* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= GE2_STATE_CAPTURING; + pthis->actor.speedXZ = 0.0f; + EnGe2_ChangeAction(pthis, GE2_ACTION_CAPTURETURN); + func_8002DF54(globalCtx, &pthis->actor, 95); + func_80078884(NA_SE_SY_FOUND); + Message_StartTextbox(globalCtx, 0x6000, &pthis->actor); +} + +void EnGe2_MaintainColliderAndSetAnimState(EnGe2* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 40.0f, 25.0f, 40.0f, 5); + + if (!(pthis->stateFlags & GE2_STATE_ANIMCOMPLETE) && SkelAnime_Update(&pthis->skelAnime)) { + pthis->stateFlags |= GE2_STATE_ANIMCOMPLETE; + } +} + +void EnGe2_MoveAndBlink(EnGe2* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->actor); + + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + pthis->eyeIndex = pthis->blinkTimer; + + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; + } +} + +// Update functions + +void EnGe2_UpdateFriendly(Actor* thisx, GlobalContext* globalCtx) { + EnGe2* pthis = (EnGe2*)thisx; + + EnGe2_MaintainColliderAndSetAnimState(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if ((pthis->actor.params & 0xFF) == GE2_TYPE_PATROLLING) { + pthis->actor.speedXZ = 0.0f; + EnGe2_ChangeAction(pthis, GE2_ACTION_WAITLOOKATPLAYER); + } + pthis->actionFunc = EnGe2_SetActionAfterTalk; + pthis->actor.update = EnGe2_UpdateAfterTalk; + } else { + pthis->actor.textId = 0x6005; + + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + EnGe2_MoveAndBlink(pthis, globalCtx); +} + +void EnGe2_UpdateAfterTalk(Actor* thisx, GlobalContext* globalCtx) { + EnGe2* pthis = (EnGe2*)thisx; + + pthis->stateFlags |= GE2_STATE_TALKED; + EnGe2_MaintainColliderAndSetAnimState(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + EnGe2_MoveAndBlink(pthis, globalCtx); +} + +void EnGe2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGe2* pthis = (EnGe2*)thisx; + s32 paramsType; + + EnGe2_MaintainColliderAndSetAnimState(pthis, globalCtx); + + if ((pthis->stateFlags & GE2_STATE_KO) || (pthis->stateFlags & GE2_STATE_CAPTURING)) { + pthis->actionFunc(pthis, globalCtx); + } else if (pthis->collider.base.acFlags & 2) { + if ((pthis->collider.info.acHitInfo != NULL) && (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x80)) { + Actor_SetColorFilter(&pthis->actor, 0, 120, 0, 400); + pthis->actor.update = EnGe2_UpdateStunned; + return; + } + + EnGe2_ChangeAction(pthis, GE2_ACTION_KNOCKEDOUT); + pthis->timer = 100; + pthis->stateFlags |= GE2_STATE_KO; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_SK_CRASH); + } else { + pthis->actionFunc(pthis, globalCtx); + + if (Ge2_DetectPlayerInUpdate(globalCtx, pthis, &pthis->actor.focus.pos, pthis->actor.shape.rot.y, + pthis->yDetectRange)) { + // "Discovered!" + osSyncPrintf(VT_FGCOL(GREEN) "発見!!!!!!!!!!!!\n" VT_RST); + EnGe2_SetupCapturePlayer(pthis, globalCtx); + } + + if (((pthis->actor.params & 0xFF) == GE2_TYPE_STATIONARY) && (pthis->actor.xzDistToPlayer < 100.0f)) { + // "Discovered!" + osSyncPrintf(VT_FGCOL(GREEN) "発見!!!!!!!!!!!!\n" VT_RST); + EnGe2_SetupCapturePlayer(pthis, globalCtx); + } + } + + if (!(pthis->stateFlags & GE2_STATE_KO)) { + paramsType = pthis->actor.params & 0xFF; // Not necessary, but looks a bit nicer + if ((paramsType == GE2_TYPE_PATROLLING) || (paramsType == GE2_TYPE_STATIONARY)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + EnGe2_MoveAndBlink(pthis, globalCtx); + + if (EnGe2_CheckCarpentersFreed() && !(pthis->stateFlags & GE2_STATE_KO)) { + pthis->actor.update = EnGe2_UpdateFriendly; + pthis->actor.targetMode = 6; + } +} + +void EnGe2_UpdateStunned(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGe2* pthis = (EnGe2*)thisx; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 40.0f, 25.0f, 40.0f, 5); + + if ((pthis->collider.base.acFlags & 2) && + ((pthis->collider.info.acHitInfo == NULL) || !(pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x80))) { + pthis->actor.colorFilterTimer = 0; + EnGe2_ChangeAction(pthis, GE2_ACTION_KNOCKEDOUT); + pthis->timer = 100; + pthis->stateFlags |= GE2_STATE_KO; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_SK_CRASH); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (EnGe2_CheckCarpentersFreed()) { + pthis->actor.update = EnGe2_UpdateFriendly; + pthis->actor.targetMode = 6; + pthis->actor.colorFilterTimer = 0; + } else if (pthis->actor.colorFilterTimer == 0) { + pthis->actor.update = EnGe2_Update; + } +} + +s32 EnGe2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnGe2* pthis = (EnGe2*)thisx; + + if (limbIndex == 3) { + rot->x += pthis->headRot.y; + rot->z += pthis->headRot.x; + } + return 0; +} + +void EnGe2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_80A343B0 = { 600.0f, 700.0f, 0.0f }; + EnGe2* pthis = (EnGe2*)thisx; + + if (limbIndex == 6) { + Matrix_MultVec3f(&D_80A343B0, &pthis->actor.focus.pos); + } +} + +void EnGe2_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gGerudoPurpleEyeOpenTex, gGerudoPurpleEyeHalfTex, gGerudoPurpleEyeClosedTex }; + s32 pad; + EnGe2* pthis = (EnGe2*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge2.c", 1274); + + func_800943C8(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); + func_8002EBCC(&pthis->actor, globalCtx, 0); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnGe2_OverrideLimbDraw, EnGe2_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge2.c", 1291); +} diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c deleted file mode 100644 index 3ac86329e..000000000 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ /dev/null @@ -1,304 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GE3_Z_EN_GE3_C -#include "actor_common.h" -/* - * File: z_en_ge3.c - * Overlay: ovl_En_Ge3 - * Description: Gerudo giving you membership card - */ - -#include "z_en_ge3.h" -#include "objects/object_geldb/object_geldb.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnGe3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGe3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGe3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGe3_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnGe3_WaitLookAtPlayer(EnGe3* this, GlobalContext* globalCtx); -void EnGe3_ForceTalk(EnGe3* this, GlobalContext* globalCtx); -void EnGe3_UpdateWhenNotTalking(Actor* thisx, GlobalContext* globalCtx); - -const ActorInit En_Ge3_InitVars = { - ACTOR_EN_GE3, - ACTORCAT_NPC, - FLAGS, - OBJECT_GELDB, - sizeof(EnGe3), - (ActorFunc)EnGe3_Init, - (ActorFunc)EnGe3_Destroy, - (ActorFunc)EnGe3_Update, - (ActorFunc)EnGe3_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000722, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 50, 0, { 0, 0, 0 } }, -}; - -static EnGe3ActionFunc sActionFuncs[] = { EnGe3_WaitLookAtPlayer }; -static AnimationHeader* sAnimations[] = { &gGerudoRedStandAnim }; // Idle with right hand on hip and left over mouth -static u8 sAnimationModes[] = { ANIMMODE_LOOP }; - -void EnGe3_ChangeAction(EnGe3* this, s32 i) { - this->actionFunc = sActionFuncs[i]; - - Animation_Change(&this->skelAnime, sAnimations[i], 1.0f, 0.0f, (f32)Animation_GetLastFrame(sAnimations[i]), - sAnimationModes[i], -8.0f); - - this->unk_30C &= ~2; -} - -void EnGe3_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnGe3* this = (EnGe3*)thisx; - GlobalContext* globalCtx = globalCtx2; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGerudoRedSkel, NULL, this->jointTable, this->morphTable, - GELDB_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gGerudoRedStandAnim); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - this->actor.world.rot.z = 0; - this->actor.shape.rot.z = 0; - EnGe3_ChangeAction(this, 0); - this->actionFunc = EnGe3_ForceTalk; - this->unk_30C = 0; - this->actor.targetMode = 6; - this->actor.minVelocityY = -4.0f; - this->actor.gravity = -1.0f; -} - -void EnGe3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGe3* this = (EnGe3*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnGe3_TurnToFacePlayer(EnGe3* this, GlobalContext* globalCtx) { - s32 pad; - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(angleDiff) <= 0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 4000, 100); - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_306, this->actor.focus.pos); - } else { - if (angleDiff < 0) { - Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 6200, 0x100); - } else { - Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 6200, 0x100); - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 1000, 100); - this->actor.world.rot.y = this->actor.shape.rot.y; - } -} - -void EnGe3_LookAtPlayer(EnGe3* this, GlobalContext* globalCtx) { - if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x2300) && - (this->actor.xzDistToPlayer < 100.0f)) { - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_306, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->headRot.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->headRot.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_306.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_306.y, 0, 6, 6200, 100); - } -} - -void EnGe3_Wait(EnGe3* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnGe3_WaitLookAtPlayer; - this->actor.update = EnGe3_UpdateWhenNotTalking; - this->actor.flags &= ~ACTOR_FLAG_16; - } - EnGe3_TurnToFacePlayer(this, globalCtx); -} - -void EnGe3_WaitLookAtPlayer(EnGe3* this, GlobalContext* globalCtx) { - EnGe3_LookAtPlayer(this, globalCtx); -} - -void EnGe3_WaitTillCardGiven(EnGe3* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnGe3_Wait; - } else { - func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); - } -} - -void EnGe3_GiveCard(EnGe3* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = EnGe3_WaitTillCardGiven; - func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); - } -} - -void EnGe3_ForceTalk(EnGe3* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnGe3_GiveCard; - } else { - if (!(this->unk_30C & 4)) { - func_8002DF54(globalCtx, &this->actor, 7); - this->unk_30C |= 4; - } - this->actor.textId = 0x6004; - this->actor.flags |= ACTOR_FLAG_16; - func_8002F1C4(&this->actor, globalCtx, 300.0f, 300.0f, 0); - } - EnGe3_LookAtPlayer(this, globalCtx); -} - -void EnGe3_UpdateCollision(EnGe3* this, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); - - if (!(this->unk_30C & 2) && SkelAnime_Update(&this->skelAnime)) { - this->unk_30C |= 2; - } -} - -void EnGe3_MoveAndBlink(EnGe3* this, GlobalContext* globalCtx) { - - Actor_MoveForward(&this->actor); - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - - this->eyeIndex = this->blinkTimer; - - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; - } -} - -void EnGe3_UpdateWhenNotTalking(Actor* thisx, GlobalContext* globalCtx) { - EnGe3* this = (EnGe3*)thisx; - - EnGe3_UpdateCollision(this, globalCtx); - this->actionFunc(this, globalCtx); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnGe3_Wait; - this->actor.update = EnGe3_Update; - } else { - this->actor.textId = 0x6005; - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - - EnGe3_MoveAndBlink(this, globalCtx); -} - -void EnGe3_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGe3* this = (EnGe3*)thisx; - - EnGe3_UpdateCollision(this, globalCtx); - this->actionFunc(this, globalCtx); - EnGe3_MoveAndBlink(this, globalCtx); -} - -s32 EnGe3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnGe3* this = (EnGe3*)thisx; - - switch (limbIndex) { - // Hide swords and veil from object_geldb - case GELDB_LIMB_VEIL: - case GELDB_LIMB_R_SWORD: - case GELDB_LIMB_L_SWORD: - *dList = NULL; - return false; - // Turn head - case GELDB_LIMB_HEAD: - rot->x += this->headRot.y; - - // This is a hack to fix the color-changing clothes this Gerudo has on N64 versions - default: - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 547); - switch (limbIndex) { - case GELDB_LIMB_NECK: - break; - case GELDB_LIMB_HEAD: - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 80, 60, 10, 255); - break; - case GELDB_LIMB_R_SWORD: - case GELDB_LIMB_L_SWORD: - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 140, 170, 230, 255); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - break; - default: - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 140, 0, 0, 255); - break; - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 566); - break; - } - return false; -} - -void EnGe3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnGe3* this = (EnGe3*)thisx; - Vec3f D_80A351C8 = { 600.0f, 700.0f, 0.0f }; - - if (limbIndex == GELDB_LIMB_HEAD) { - Matrix_MultVec3f(&D_80A351C8, &this->actor.focus.pos); - } -} - -void EnGe3_Draw(Actor* thisx, GlobalContext* globalCtx2) { - static void* eyeTextures[] = { - gGerudoRedEyeOpenTex, - gGerudoRedEyeHalfTex, - gGerudoRedEyeShutTex, - }; - EnGe3* this = (EnGe3*)thisx; - GlobalContext* globalCtx = globalCtx2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 614); - - func_800943C8(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); - func_8002EBCC(&this->actor, globalCtx, 0); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnGe3_OverrideLimbDraw, EnGe3_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 631); -} diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.cpp b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.cpp new file mode 100644 index 000000000..c90db6fa0 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.cpp @@ -0,0 +1,304 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GE3_Z_EN_GE3_C +#include "actor_common.h" +/* + * File: z_en_ge3.c + * Overlay: ovl_En_Ge3 + * Description: Gerudo giving you membership card + */ + +#include "z_en_ge3.h" +#include "objects/object_geldb/object_geldb.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnGe3_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGe3_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGe3_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGe3_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnGe3_WaitLookAtPlayer(EnGe3* pthis, GlobalContext* globalCtx); +void EnGe3_ForceTalk(EnGe3* pthis, GlobalContext* globalCtx); +void EnGe3_UpdateWhenNotTalking(Actor* thisx, GlobalContext* globalCtx); + +ActorInit En_Ge3_InitVars = { + ACTOR_EN_GE3, + ACTORCAT_NPC, + FLAGS, + OBJECT_GELDB, + sizeof(EnGe3), + (ActorFunc)EnGe3_Init, + (ActorFunc)EnGe3_Destroy, + (ActorFunc)EnGe3_Update, + (ActorFunc)EnGe3_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000722, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 50, 0, { 0, 0, 0 } }, +}; + +static EnGe3ActionFunc sActionFuncs[] = { EnGe3_WaitLookAtPlayer }; +static AnimationHeader* sAnimations[] = { &gGerudoRedStandAnim }; // Idle with right hand on hip and left over mouth +static u8 sAnimationModes[] = { ANIMMODE_LOOP }; + +void EnGe3_ChangeAction(EnGe3* pthis, s32 i) { + pthis->actionFunc = sActionFuncs[i]; + + Animation_Change(&pthis->skelAnime, sAnimations[i], 1.0f, 0.0f, (f32)Animation_GetLastFrame(sAnimations[i]), + sAnimationModes[i], -8.0f); + + pthis->unk_30C &= ~2; +} + +void EnGe3_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnGe3* pthis = (EnGe3*)thisx; + GlobalContext* globalCtx = globalCtx2; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGerudoRedSkel, NULL, pthis->jointTable, pthis->morphTable, + GELDB_LIMB_MAX); + Animation_PlayLoop(&pthis->skelAnime, &gGerudoRedStandAnim); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.world.rot.z = 0; + pthis->actor.shape.rot.z = 0; + EnGe3_ChangeAction(pthis, 0); + pthis->actionFunc = EnGe3_ForceTalk; + pthis->unk_30C = 0; + pthis->actor.targetMode = 6; + pthis->actor.minVelocityY = -4.0f; + pthis->actor.gravity = -1.0f; +} + +void EnGe3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGe3* pthis = (EnGe3*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnGe3_TurnToFacePlayer(EnGe3* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(angleDiff) <= 0x4000) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 6, 4000, 100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_306, pthis->actor.focus.pos); + } else { + if (angleDiff < 0) { + Math_SmoothStepToS(&pthis->headRot.y, -0x2000, 6, 6200, 0x100); + } else { + Math_SmoothStepToS(&pthis->headRot.y, 0x2000, 6, 6200, 0x100); + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 12, 1000, 100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } +} + +void EnGe3_LookAtPlayer(EnGe3* pthis, GlobalContext* globalCtx) { + if ((ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x2300) && + (pthis->actor.xzDistToPlayer < 100.0f)) { + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_306, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->headRot.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->headRot.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_306.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_306.y, 0, 6, 6200, 100); + } +} + +void EnGe3_Wait(EnGe3* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe3_WaitLookAtPlayer; + pthis->actor.update = EnGe3_UpdateWhenNotTalking; + pthis->actor.flags &= ~ACTOR_FLAG_16; + } + EnGe3_TurnToFacePlayer(pthis, globalCtx); +} + +void EnGe3_WaitLookAtPlayer(EnGe3* pthis, GlobalContext* globalCtx) { + EnGe3_LookAtPlayer(pthis, globalCtx); +} + +void EnGe3_WaitTillCardGiven(EnGe3* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnGe3_Wait; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } +} + +void EnGe3_GiveCard(EnGe3* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = EnGe3_WaitTillCardGiven; + func_8002F434(&pthis->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } +} + +void EnGe3_ForceTalk(EnGe3* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe3_GiveCard; + } else { + if (!(pthis->unk_30C & 4)) { + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->unk_30C |= 4; + } + pthis->actor.textId = 0x6004; + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F1C4(&pthis->actor, globalCtx, 300.0f, 300.0f, 0); + } + EnGe3_LookAtPlayer(pthis, globalCtx); +} + +void EnGe3_UpdateCollision(EnGe3* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 40.0f, 25.0f, 40.0f, 5); + + if (!(pthis->unk_30C & 2) && SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_30C |= 2; + } +} + +void EnGe3_MoveAndBlink(EnGe3* pthis, GlobalContext* globalCtx) { + + Actor_MoveForward(&pthis->actor); + + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + + pthis->eyeIndex = pthis->blinkTimer; + + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; + } +} + +void EnGe3_UpdateWhenNotTalking(Actor* thisx, GlobalContext* globalCtx) { + EnGe3* pthis = (EnGe3*)thisx; + + EnGe3_UpdateCollision(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnGe3_Wait; + pthis->actor.update = EnGe3_Update; + } else { + pthis->actor.textId = 0x6005; + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + + EnGe3_MoveAndBlink(pthis, globalCtx); +} + +void EnGe3_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGe3* pthis = (EnGe3*)thisx; + + EnGe3_UpdateCollision(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + EnGe3_MoveAndBlink(pthis, globalCtx); +} + +s32 EnGe3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnGe3* pthis = (EnGe3*)thisx; + + switch (limbIndex) { + // Hide swords and veil from object_geldb + case GELDB_LIMB_VEIL: + case GELDB_LIMB_R_SWORD: + case GELDB_LIMB_L_SWORD: + *dList = NULL; + return false; + // Turn head + case GELDB_LIMB_HEAD: + rot->x += pthis->headRot.y; + + // This is a hack to fix the color-changing clothes pthis Gerudo has on N64 versions + default: + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 547); + switch (limbIndex) { + case GELDB_LIMB_NECK: + break; + case GELDB_LIMB_HEAD: + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 80, 60, 10, 255); + break; + case GELDB_LIMB_R_SWORD: + case GELDB_LIMB_L_SWORD: + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 140, 170, 230, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + default: + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 140, 0, 0, 255); + break; + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 566); + break; + } + return false; +} + +void EnGe3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnGe3* pthis = (EnGe3*)thisx; + Vec3f D_80A351C8 = { 600.0f, 700.0f, 0.0f }; + + if (limbIndex == GELDB_LIMB_HEAD) { + Matrix_MultVec3f(&D_80A351C8, &pthis->actor.focus.pos); + } +} + +void EnGe3_Draw(Actor* thisx, GlobalContext* globalCtx2) { + static void* eyeTextures[] = { + gGerudoRedEyeOpenTex, + gGerudoRedEyeHalfTex, + gGerudoRedEyeShutTex, + }; + EnGe3* pthis = (EnGe3*)thisx; + GlobalContext* globalCtx = globalCtx2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 614); + + func_800943C8(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); + func_8002EBCC(&pthis->actor, globalCtx, 0); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnGe3_OverrideLimbDraw, EnGe3_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ge3.c", 631); +} diff --git a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c deleted file mode 100644 index 606df559c..000000000 --- a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c +++ /dev/null @@ -1,1659 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GELDB_Z_EN_GELDB_C -#include "actor_common.h" -/* - * File: z_en_geldb.c - * Overlay: ovl_En_GeldB - * Description: Gerudo fighter - */ - -#include "z_en_geldb.h" -#include "objects/object_geldb/object_geldb.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -typedef enum { - /* 0 */ GELDB_WAIT, - /* 1 */ GELDB_DEFEAT, - /* 2 */ GELDB_DAMAGED, - /* 3 */ GELDB_JUMP, - /* 4 */ GELDB_ROLL_BACK, - /* 5 */ GELDB_READY, - /* 6 */ GELDB_BLOCK, - /* 7 */ GELDB_SLASH, - /* 8 */ GELDB_ADVANCE, - /* 9 */ GELDB_PIVOT, - /* 10 */ GELDB_CIRCLE, - /* 11 */ GELDB_UNUSED, - /* 12 */ GELDB_SPIN_ATTACK, - /* 13 */ GELDB_SIDESTEP, - /* 14 */ GELDB_ROLL_FORWARD, - /* 15 */ GELDB_STUNNED, - /* 16 */ GELDB_SPIN_DODGE -} EnGeldBAction; - -void EnGeldB_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGeldB_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGeldB_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGeldB_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 EnGeldB_DodgeRanged(GlobalContext* globalCtx, EnGeldB* this); - -void EnGeldB_SetupWait(EnGeldB* this); -void EnGeldB_SetupReady(EnGeldB* this); -void EnGeldB_SetupAdvance(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_SetupPivot(EnGeldB* this); -void EnGeldB_SetupRollForward(EnGeldB* this); -void EnGeldB_SetupCircle(EnGeldB* this); -void EnGeldB_SetupSpinDodge(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_SetupSlash(EnGeldB* this); -void EnGeldB_SetupSpinAttack(EnGeldB* this); -void EnGeldB_SetupRollBack(EnGeldB* this); -void EnGeldB_SetupJump(EnGeldB* this); -void EnGeldB_SetupBlock(EnGeldB* this); -void EnGeldB_SetupSidestep(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_SetupDefeated(EnGeldB* this); - -void EnGeldB_Wait(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Flee(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Ready(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Advance(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_RollForward(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Pivot(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Circle(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_SpinDodge(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Slash(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_SpinAttack(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_RollBack(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Stunned(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Damaged(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Jump(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Block(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Sidestep(EnGeldB* this, GlobalContext* globalCtx); -void EnGeldB_Defeated(EnGeldB* this, GlobalContext* globalCtx); - -const ActorInit En_GeldB_InitVars = { - ACTOR_EN_GELDB, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_GELDB, - sizeof(EnGeldB), - (ActorFunc)EnGeldB_Init, - (ActorFunc)EnGeldB_Destroy, - (ActorFunc)EnGeldB_Update, - (ActorFunc)EnGeldB_Draw, -}; - -static ColliderCylinderInit sBodyCylInit = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 50, 0, { 0, 0, 0 } }, -}; - -static ColliderTrisElementInit sBlockTrisElementsInit[2] = { - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC1FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC1FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, -}; - -static ColliderTrisInit sBlockTrisInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 2, - sBlockTrisElementsInit, -}; - -static ColliderQuadInit sSwordQuadInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -typedef enum { - /* 0x0 */ GELDB_DMG_NORMAL, - /* 0x1 */ GELDB_DMG_STUN, - /* 0x6 */ GELDB_DMG_UNK_6 = 0x6, - /* 0xD */ GELDB_DMG_UNK_D = 0xD, - /* 0xE */ GELDB_DMG_UNK_E, - /* 0xF */ GELDB_DMG_FREEZE -} EnGeldBDamageEffects; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, GELDB_DMG_STUN), - /* Deku stick */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Slingshot */ DMG_ENTRY(1, GELDB_DMG_NORMAL), - /* Explosive */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Boomerang */ DMG_ENTRY(0, GELDB_DMG_STUN), - /* Normal arrow */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Hammer swing */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Hookshot */ DMG_ENTRY(0, GELDB_DMG_STUN), - /* Kokiri sword */ DMG_ENTRY(1, GELDB_DMG_NORMAL), - /* Master sword */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Giant's Knife */ DMG_ENTRY(4, GELDB_DMG_NORMAL), - /* Fire arrow */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Ice arrow */ DMG_ENTRY(2, GELDB_DMG_FREEZE), - /* Light arrow */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Unk arrow 1 */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Unk arrow 2 */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Unk arrow 3 */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Fire magic */ DMG_ENTRY(4, GELDB_DMG_UNK_E), - /* Ice magic */ DMG_ENTRY(0, GELDB_DMG_UNK_6), - /* Light magic */ DMG_ENTRY(3, GELDB_DMG_UNK_D), - /* Shield */ DMG_ENTRY(0, GELDB_DMG_NORMAL), - /* Mirror Ray */ DMG_ENTRY(0, GELDB_DMG_NORMAL), - /* Kokiri spin */ DMG_ENTRY(1, GELDB_DMG_NORMAL), - /* Giant spin */ DMG_ENTRY(4, GELDB_DMG_NORMAL), - /* Master spin */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Kokiri jump */ DMG_ENTRY(2, GELDB_DMG_NORMAL), - /* Giant jump */ DMG_ENTRY(8, GELDB_DMG_NORMAL), - /* Master jump */ DMG_ENTRY(4, GELDB_DMG_NORMAL), - /* Unknown 1 */ DMG_ENTRY(4, GELDB_DMG_NORMAL), - /* Unblockable */ DMG_ENTRY(0, GELDB_DMG_NORMAL), - /* Hammer jump */ DMG_ENTRY(4, GELDB_DMG_NORMAL), - /* Unknown 2 */ DMG_ENTRY(0, GELDB_DMG_NORMAL), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -3000, ICHAIN_STOP), -}; - -static Vec3f sUnusedOffset = { 1100.0f, -700.0f, 0.0f }; - -void EnGeldB_SetupAction(EnGeldB* this, EnGeldBActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnGeldB_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EffectBlureInit1 blureInit; - EnGeldB* this = (EnGeldB*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - thisx->colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawFeet, 0.0f); - this->actor.colChkInfo.mass = MASS_HEAVY; - thisx->colChkInfo.health = 20; - thisx->colChkInfo.cylRadius = 50; - thisx->colChkInfo.cylHeight = 100; - thisx->naviEnemyId = 0x54; - this->keyFlag = thisx->params & 0xFF00; - thisx->params &= 0xFF; - this->blinkState = 0; - this->unkFloat = 10.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGerudoRedSkel, &gGerudoRedNeutralAnim, this->jointTable, - this->morphTable, GELDB_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, thisx, &sBodyCylInit); - Collider_InitTris(globalCtx, &this->blockCollider); - Collider_SetTris(globalCtx, &this->blockCollider, thisx, &sBlockTrisInit, this->blockElements); - Collider_InitQuad(globalCtx, &this->swordCollider); - Collider_SetQuad(globalCtx, &this->swordCollider, thisx, &sSwordQuadInit); - blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = - blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = - blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = blureInit.p2EndColor[1] = - blureInit.p2EndColor[2] = 255; - blureInit.p2StartColor[3] = 64; - blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; - blureInit.elemDuration = 8; - blureInit.unkFlag = 0; - blureInit.calcMode = 2; - - Effect_Add(globalCtx, &this->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); - Actor_SetScale(thisx, 0.012499999f); - EnGeldB_SetupWait(this); - if ((this->keyFlag != 0) && Flags_GetCollectible(globalCtx, this->keyFlag >> 8)) { - Actor_Kill(thisx); - } -} - -void EnGeldB_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnGeldB* this = (EnGeldB*)thisx; - - func_800F5B58(); - Effect_Delete(globalCtx, this->blureIndex); - Collider_DestroyTris(globalCtx, &this->blockCollider); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyQuad(globalCtx, &this->swordCollider); -} - -s32 EnGeldB_ReactToPlayer(GlobalContext* globalCtx, EnGeldB* this, s16 arg2) { - Player* player = GET_PLAYER(globalCtx); - Actor* thisx = &this->actor; - s16 angleToWall; - s16 angleToLink; - Actor* bomb; - - angleToWall = thisx->wallYaw - thisx->shape.rot.y; - angleToWall = ABS(angleToWall); - angleToLink = thisx->yawTowardsPlayer - thisx->shape.rot.y; - angleToLink = ABS(angleToLink); - - if (func_800354B4(globalCtx, thisx, 100.0f, 0x2710, 0x3E80, thisx->shape.rot.y)) { - if (player->swordAnimation == 0x11) { - EnGeldB_SetupSpinDodge(this, globalCtx); - return true; - } else if (globalCtx->gameplayFrames & 1) { - EnGeldB_SetupBlock(this); - return true; - } - } - if (func_800354B4(globalCtx, thisx, 100.0f, 0x5DC0, 0x2AA8, thisx->shape.rot.y)) { - thisx->shape.rot.y = thisx->world.rot.y = thisx->yawTowardsPlayer; - if ((thisx->bgCheckFlags & 8) && (ABS(angleToWall) < 0x2EE0) && (thisx->xzDistToPlayer < 90.0f)) { - EnGeldB_SetupJump(this); - return true; - } else if (player->swordAnimation == 0x11) { - EnGeldB_SetupSpinDodge(this, globalCtx); - return true; - } else if ((thisx->xzDistToPlayer < 90.0f) && (globalCtx->gameplayFrames & 1)) { - EnGeldB_SetupBlock(this); - return true; - } else { - EnGeldB_SetupRollBack(this); - return true; - } - } else if ((bomb = Actor_FindNearby(globalCtx, thisx, -1, ACTORCAT_EXPLOSIVE, 80.0f)) != NULL) { - thisx->shape.rot.y = thisx->world.rot.y = thisx->yawTowardsPlayer; - if (((thisx->bgCheckFlags & 8) && (angleToWall < 0x2EE0)) || (bomb->id == ACTOR_EN_BOM_CHU)) { - if ((bomb->id == ACTOR_EN_BOM_CHU) && (Actor_WorldDistXYZToActor(thisx, bomb) < 80.0f) && - ((s16)(thisx->shape.rot.y - (bomb->world.rot.y - 0x8000)) < 0x3E80)) { - EnGeldB_SetupJump(this); - return true; - } else { - EnGeldB_SetupSidestep(this, globalCtx); - return true; - } - } else { - EnGeldB_SetupRollBack(this); - return true; - } - } else if (arg2) { - if (angleToLink >= 0x1B58) { - EnGeldB_SetupSidestep(this, globalCtx); - return true; - } else { - s16 angleToFacingLink = player->actor.shape.rot.y - thisx->shape.rot.y; - - if ((thisx->xzDistToPlayer <= 45.0f) && !Actor_OtherIsTargeted(globalCtx, thisx) && - ((globalCtx->gameplayFrames & 7) || (ABS(angleToFacingLink) < 0x38E0))) { - EnGeldB_SetupSlash(this); - return true; - } else { - EnGeldB_SetupCircle(this); - return true; - } - } - } - return false; -} - -void EnGeldB_SetupWait(EnGeldB* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gGerudoRedJumpAnim, 0.0f); - this->actor.world.pos.y = this->actor.home.pos.y + 120.0f; - this->timer = 10; - this->invisible = true; - this->action = GELDB_WAIT; - this->actor.bgCheckFlags &= ~3; - this->actor.gravity = -2.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - EnGeldB_SetupAction(this, EnGeldB_Wait); -} - -void EnGeldB_Wait(EnGeldB* this, GlobalContext* globalCtx) { - if ((this->invisible && !Flags_GetSwitch(globalCtx, this->actor.home.rot.z)) || - this->actor.xzDistToPlayer > 300.0f) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.world.pos.y = this->actor.floorHeight + 120.0f; - } else { - this->invisible = false; - this->actor.shape.shadowScale = 90.0f; - func_800F5ACC(NA_BGM_MINI_BOSS); - } - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - this->skelAnime.playSpeed = 1.0f; - this->actor.world.pos.y = this->actor.floorHeight; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.focus.pos = this->actor.world.pos; - this->actor.bgCheckFlags &= ~2; - this->actor.velocity.y = 0.0f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - } - if (SkelAnime_Update(&this->skelAnime)) { - EnGeldB_SetupReady(this); - } -} - -void EnGeldB_SetupFlee(EnGeldB* this) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedJumpAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedJumpAnim, -2.0f, lastFrame, 0.0f, ANIMMODE_ONCE_INTERP, -4.0f); - this->timer = 20; - this->invisible = false; - this->action = GELDB_WAIT; - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnGeldB_SetupAction(this, EnGeldB_Flee); -} - -void EnGeldB_Flee(EnGeldB* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame == 10.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - } - if (this->skelAnime.curFrame == 2.0f) { - this->actor.gravity = 0.0f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - } - if (SkelAnime_Update(&this->skelAnime)) { - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight + 300.0f, 1.0f, 20.5f, 0.0f); - this->timer--; - if (this->timer == 0) { - Actor_Kill(&this->actor); - } - } -} - -void EnGeldB_SetupReady(EnGeldB* this) { - Animation_MorphToLoop(&this->skelAnime, &gGerudoRedNeutralAnim, -4.0f); - this->action = GELDB_READY; - this->timer = Rand_ZeroOne() * 10.0f + 5.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnGeldB_SetupAction(this, EnGeldB_Ready); -} - -void EnGeldB_Ready(EnGeldB* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 angleToLink; - - SkelAnime_Update(&this->skelAnime); - if (this->lookTimer != 0) { - angleToLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y - this->headRot.y; - if (ABS(angleToLink) > 0x2000) { - this->lookTimer--; - return; - } - this->lookTimer = 0; - } - angleToLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (!EnGeldB_DodgeRanged(globalCtx, this)) { - if (this->unkTimer != 0) { - this->unkTimer--; - - if (ABS(angleToLink) >= 0x1FFE) { - return; - } - this->unkTimer = 0; - } else if (EnGeldB_ReactToPlayer(globalCtx, this, 0)) { - return; - } - angleToLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && (ABS(angleToLink) >= 0x1F40)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnGeldB_SetupCircle(this); - } else if (--this->timer == 0) { - if (Actor_IsFacingPlayer(&this->actor, 30 * 0x10000 / 360)) { - if ((210.0f > this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 150.0f) && - (Rand_ZeroOne() < 0.3f)) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor) || (Rand_ZeroOne() > 0.5f) || - (ABS(angleToLink) < 0x38E0)) { - EnGeldB_SetupRollForward(this); - } else { - EnGeldB_SetupSpinAttack(this); - } - } else if (Rand_ZeroOne() > 0.3f) { - EnGeldB_SetupAdvance(this, globalCtx); - } else { - EnGeldB_SetupCircle(this); - } - } else { - EnGeldB_SetupPivot(this); - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } - } - } -} - -void EnGeldB_SetupAdvance(EnGeldB* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedWalkAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedWalkAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); - this->action = GELDB_ADVANCE; - EnGeldB_SetupAction(this, EnGeldB_Advance); -} - -void EnGeldB_Advance(EnGeldB* this, GlobalContext* globalCtx) { - s32 thisKeyFrame; - s32 prevKeyFrame; - s32 playSpeed; - s16 facingAngletoLink; - Player* player = GET_PLAYER(globalCtx); - - if (!EnGeldB_DodgeRanged(globalCtx, this)) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x2EE, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->actor.xzDistToPlayer <= 40.0f) { - Math_SmoothStepToF(&this->actor.speedXZ, -8.0f, 1.0f, 1.5f, 0.0f); - } else if (this->actor.xzDistToPlayer > 55.0f) { - Math_SmoothStepToF(&this->actor.speedXZ, 8.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 6.65f, 0.0f); - } - this->skelAnime.playSpeed = this->actor.speedXZ / 8.0f; - facingAngletoLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - facingAngletoLink = ABS(facingAngletoLink); - if ((this->actor.xzDistToPlayer < 150.0f) && (player->swordState != 0) && (facingAngletoLink >= 0x1F40)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (Rand_ZeroOne() > 0.7f) { - EnGeldB_SetupCircle(this); - return; - } - } - thisKeyFrame = (s32)this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); - if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { - if (Rand_ZeroOne() > 0.5f) { - EnGeldB_SetupCircle(this); - } else { - EnGeldB_SetupReady(this); - } - } else if (this->actor.xzDistToPlayer < 90.0f) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && - (Rand_ZeroOne() > 0.03f || (this->actor.xzDistToPlayer <= 45.0f && facingAngletoLink < 0x38E0))) { - EnGeldB_SetupSlash(this); - } else if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { - EnGeldB_SetupRollBack(this); - } else { - EnGeldB_SetupCircle(this); - } - } - if (!EnGeldB_ReactToPlayer(globalCtx, this, 0)) { - if ((210.0f > this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 150.0f) && - Actor_IsFacingPlayer(&this->actor, 0x71C)) { - if (Actor_IsTargeted(globalCtx, &this->actor)) { - if (Rand_ZeroOne() > 0.5f) { - EnGeldB_SetupRollForward(this); - } else { - EnGeldB_SetupSpinAttack(this); - } - } else { - EnGeldB_SetupCircle(this); - return; - } - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } - if (thisKeyFrame != (s32)this->skelAnime.curFrame) { - s32 temp = playSpeed + thisKeyFrame; - - if (((prevKeyFrame < 0) && (temp > 0)) || ((prevKeyFrame < 4) && (temp > 4))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); - } - } - } - } -} - -void EnGeldB_SetupRollForward(EnGeldB* this) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedFlipAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedFlipAnim, -1.0f, lastFrame, 0.0f, ANIMMODE_ONCE, -3.0f); - this->timer = 0; - this->invisible = true; - this->action = GELDB_ROLL_FORWARD; - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - EnGeldB_SetupAction(this, EnGeldB_RollForward); -} - -void EnGeldB_RollForward(EnGeldB* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 facingAngleToLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if (SkelAnime_Update(&this->skelAnime)) { - this->invisible = false; - this->actor.speedXZ = 0.0f; - if (!Actor_IsFacingPlayer(&this->actor, 0x1554)) { - EnGeldB_SetupReady(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - if (ABS(facingAngleToLink) < 0x38E0) { - this->lookTimer = 20; - } - } else if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && - (Rand_ZeroOne() > 0.5f || (ABS(facingAngleToLink) < 0x3FFC))) { - EnGeldB_SetupSlash(this); - } else { - EnGeldB_SetupAdvance(this, globalCtx); - } - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } -} - -void EnGeldB_SetupPivot(EnGeldB* this) { - Animation_MorphToLoop(&this->skelAnime, &gGerudoRedSidestepAnim, -4.0f); - this->action = GELDB_PIVOT; - EnGeldB_SetupAction(this, EnGeldB_Pivot); -} - -void EnGeldB_Pivot(EnGeldB* this, GlobalContext* globalCtx) { - s16 angleToLink; - s16 turnRate; - f32 playSpeed; - - if (!EnGeldB_DodgeRanged(globalCtx, this) && !EnGeldB_ReactToPlayer(globalCtx, this, 0)) { - angleToLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - turnRate = (angleToLink > 0) ? ((angleToLink * 0.25f) + 2000.0f) : ((angleToLink * 0.25f) - 2000.0f); - this->actor.world.rot.y = this->actor.shape.rot.y += turnRate; - if (angleToLink > 0) { - playSpeed = turnRate * 0.5f; - playSpeed = CLAMP_MAX(playSpeed, 1.0f); - } else { - playSpeed = turnRate * 0.5f; - playSpeed = CLAMP_MIN(playSpeed, -1.0f); - } - this->skelAnime.playSpeed = -playSpeed; - SkelAnime_Update(&this->skelAnime); - if (Actor_IsFacingPlayer(&this->actor, 30 * 0x10000 / 360)) { - if (Rand_ZeroOne() > 0.8f) { - EnGeldB_SetupCircle(this); - } else { - EnGeldB_SetupAdvance(this, globalCtx); - } - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } - } -} - -void EnGeldB_SetupCircle(EnGeldB* this) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); - this->actor.speedXZ = Rand_CenteredFloat(12.0f); - this->actor.world.rot.y = this->actor.shape.rot.y; - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.5f; - this->timer = Rand_ZeroOne() * 30.0f + 30.0f; - this->action = GELDB_CIRCLE; - this->approachRate = 0.0f; - EnGeldB_SetupAction(this, EnGeldB_Circle); -} - -void EnGeldB_Circle(EnGeldB* this, GlobalContext* globalCtx) { - s16 angleBehindLink; - s16 phi_v1; - s32 nextKeyFrame; - s32 thisKeyFrame; - s32 pad; - s32 prevKeyFrame; - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - if (!EnGeldB_DodgeRanged(globalCtx, this) && !EnGeldB_ReactToPlayer(globalCtx, this, 0)) { - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3A98; - angleBehindLink = player->actor.shape.rot.y + 0x8000; - if (Math_SinS(angleBehindLink - this->actor.shape.rot.y) >= 0.0f) { - this->actor.speedXZ -= 0.25f; - if (this->actor.speedXZ < -8.0f) { - this->actor.speedXZ = -8.0f; - } - } else if (Math_SinS(angleBehindLink - this->actor.shape.rot.y) < 0.0f) { - this->actor.speedXZ += 0.25f; - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ = 8.0f; - } - } - if ((this->actor.bgCheckFlags & 8) || !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, - this->actor.shape.rot.y + 0x3E80)) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - phi_v1 = this->actor.shape.rot.y + 0x3E80; - } else { - phi_v1 = this->actor.shape.rot.y - 0x3E80; - } - phi_v1 = this->actor.wallYaw - phi_v1; - } else { - this->actor.speedXZ *= -0.8f; - phi_v1 = 0; - } - if (ABS(phi_v1) > 0x4000) { - this->actor.speedXZ *= -0.8f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ += 0.5f; - } - } - } - if (this->actor.xzDistToPlayer <= 45.0f) { - Math_SmoothStepToF(&this->approachRate, -4.0f, 1.0f, 1.5f, 0.0f); - } else if (this->actor.xzDistToPlayer > 40.0f) { - Math_SmoothStepToF(&this->approachRate, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->approachRate, 0.0f, 1.0f, 6.65f, 0.0f); - } - if (this->approachRate != 0.0f) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->approachRate; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->approachRate; - } - if (ABS(this->approachRate) < ABS(this->actor.speedXZ)) { - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.5f; - } else { - this->skelAnime.playSpeed = -this->approachRate * 0.5f; - } - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - - thisKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - nextKeyFrame = (s32)ABS(this->skelAnime.playSpeed) + thisKeyFrame; - if ((thisKeyFrame != (s32)this->skelAnime.curFrame) && - ((prevKeyFrame < 0 && 0 < nextKeyFrame) || (prevKeyFrame < 5 && 5 < nextKeyFrame))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } - if ((Math_CosS(angleBehindLink - this->actor.shape.rot.y) < -0.85f) && - !Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer <= 45.0f)) { - EnGeldB_SetupSlash(this); - } else if (--this->timer == 0) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { - EnGeldB_SetupRollBack(this); - } else { - EnGeldB_SetupReady(this); - } - } - } -} - -void EnGeldB_SetupSpinDodge(EnGeldB* this, GlobalContext* globalCtx) { - s16 sp3E; - Player* player = GET_PLAYER(globalCtx); - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); - sp3E = player->actor.shape.rot.y; - if (Math_SinS(sp3E - this->actor.shape.rot.y) > 0.0f) { - this->actor.speedXZ = -10.0f; - } else if (Math_SinS(sp3E - this->actor.shape.rot.y) < 0.0f) { - this->actor.speedXZ = 10.0f; - } else if (Rand_ZeroOne() > 0.5f) { - this->actor.speedXZ = 10.0f; - } else { - this->actor.speedXZ = -10.0f; - } - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.5f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->timer = 6; - this->approachRate = 0.0f; - this->unkFloat = 0.0f; - this->action = GELDB_SPIN_DODGE; - - EnGeldB_SetupAction(this, EnGeldB_SpinDodge); -} - -void EnGeldB_SpinDodge(EnGeldB* this, GlobalContext* globalCtx) { - s16 phi_v1; - s32 thisKeyFrame; - s32 pad; - s32 lastKeyFrame; - s32 nextKeyFrame; - - this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x3A98; - if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.shape.rot.y + 0x3E80)) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - phi_v1 = this->actor.shape.rot.y + 0x3E80; - } else { - phi_v1 = this->actor.shape.rot.y - 0x3E80; - } - phi_v1 = this->actor.wallYaw - phi_v1; - } else { - this->actor.speedXZ *= -0.8f; - phi_v1 = 0; - } - if (ABS(phi_v1) > 0x4000) { - EnGeldB_SetupJump(this); - return; - } - } - if (this->actor.xzDistToPlayer <= 45.0f) { - Math_SmoothStepToF(&this->approachRate, -4.0f, 1.0f, 1.5f, 0.0f); - } else if (this->actor.xzDistToPlayer > 40.0f) { - Math_SmoothStepToF(&this->approachRate, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->approachRate, 0.0f, 1.0f, 6.65f, 0.0f); - } - if (this->approachRate != 0.0f) { - this->actor.world.pos.x += Math_SinS(this->actor.yawTowardsPlayer) * this->approachRate; - this->actor.world.pos.z += Math_CosS(this->actor.yawTowardsPlayer) * this->approachRate; - } - if (ABS(this->approachRate) < ABS(this->actor.speedXZ)) { - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.5f; - } else { - this->skelAnime.playSpeed = -this->approachRate * 0.5f; - } - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - thisKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - lastKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - nextKeyFrame = (s32)ABS(this->skelAnime.playSpeed) + thisKeyFrame; - if ((thisKeyFrame != (s32)this->skelAnime.curFrame) && - ((lastKeyFrame < 0 && 0 < nextKeyFrame) || (lastKeyFrame < 5 && 5 < nextKeyFrame))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } - this->timer--; - if (this->timer == 0) { - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - if (!EnGeldB_DodgeRanged(globalCtx, this)) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer <= 70.0f)) { - EnGeldB_SetupSlash(this); - } else { - EnGeldB_SetupRollBack(this); - } - } - } else { - if (this->actor.speedXZ >= 0.0f) { - this->actor.shape.rot.y += 0x4000; - } else { - this->actor.shape.rot.y -= 0x4000; - } - } -} - -void EnGeldB_SetupSlash(EnGeldB* this) { - Animation_PlayOnce(&this->skelAnime, &gGerudoRedSlashAnim); - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - this->action = GELDB_SLASH; - this->spinAttackState = 0; - this->actor.speedXZ = 0.0f; - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_GERUDOFT_BREATH); - EnGeldB_SetupAction(this, EnGeldB_Slash); -} - -void EnGeldB_Slash(EnGeldB* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 angleFacingLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - s16 angleToLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - angleFacingLink = ABS(angleFacingLink); - angleToLink = ABS(angleToLink); - - this->actor.speedXZ = 0.0f; - if ((s32)this->skelAnime.curFrame == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_ATTACK); - this->swordState = 1; - } else if ((s32)this->skelAnime.curFrame == 6) { - this->swordState = -1; - } - if (this->swordCollider.base.atFlags & AT_BOUNCED) { - this->swordState = -1; - this->swordCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); - EnGeldB_SetupRollBack(this); - } else if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_IsFacingPlayer(&this->actor, 0x1554)) { - EnGeldB_SetupReady(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - if (angleToLink > 0x4000) { - this->lookTimer = 20; - } - } else if (Rand_ZeroOne() > 0.7f || (this->actor.xzDistToPlayer >= 120.0f)) { - EnGeldB_SetupReady(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } else { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (Rand_ZeroOne() > 0.7f) { - EnGeldB_SetupSidestep(this, globalCtx); - } else if (angleFacingLink <= 0x2710) { - if (angleToLink > 0x3E80) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnGeldB_SetupCircle(this); - } else { - EnGeldB_ReactToPlayer(globalCtx, this, 1); - } - } else { - EnGeldB_SetupCircle(this); - } - } - } -} - -void EnGeldB_SetupSpinAttack(EnGeldB* this) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSpinAttackAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedSpinAttackAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE_INTERP, 0.0f); - this->swordCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); - this->action = GELDB_SPIN_ATTACK; - this->spinAttackState = 0; - this->actor.speedXZ = 0.0f; - EnGeldB_SetupAction(this, EnGeldB_SpinAttack); -} - -void EnGeldB_SpinAttack(EnGeldB* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 angleFacingLink; - s16 angleToLink; - - if (this->spinAttackState < 2) { - if (this->swordCollider.base.atFlags & AT_BOUNCED) { - this->swordCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); - this->spinAttackState = 1; - this->skelAnime.playSpeed = 1.5f; - } else if (this->swordCollider.base.atFlags & AT_HIT) { - this->swordCollider.base.atFlags &= ~AT_HIT; - if (&player->actor == this->swordCollider.base.at) { - func_8002F71C(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f); - this->spinAttackState = 2; - func_8002DF54(globalCtx, &this->actor, 0x18); - Message_StartTextbox(globalCtx, 0x6003, &this->actor); - this->timer = 30; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_YOUNG_LAUGH); - return; - } - } - } - if ((s32)this->skelAnime.curFrame < 9) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - } else if ((s32)this->skelAnime.curFrame == 13) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - this->swordState = 1; - this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_ATTACK); - } else if ((s32)this->skelAnime.curFrame == 21) { - this->actor.speedXZ = 0.0f; - } else if ((s32)this->skelAnime.curFrame == 24) { - this->swordState = -1; - } - if (SkelAnime_Update(&this->skelAnime) && (this->spinAttackState < 2)) { - if (!Actor_IsFacingPlayer(&this->actor, 0x1554)) { - EnGeldB_SetupReady(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - this->lookTimer = 46; - } else if (this->spinAttackState != 0) { - EnGeldB_SetupRollBack(this); - } else if (Rand_ZeroOne() > 0.7f || (this->actor.xzDistToPlayer >= 120.0f)) { - EnGeldB_SetupReady(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } else { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (Rand_ZeroOne() > 0.7f) { - EnGeldB_SetupSidestep(this, globalCtx); - } else { - angleFacingLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - angleFacingLink = ABS(angleFacingLink); - if (angleFacingLink <= 0x2710) { - angleToLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - angleToLink = ABS(angleToLink); - if (angleToLink > 0x3E80) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnGeldB_SetupCircle(this); - } else { - EnGeldB_ReactToPlayer(globalCtx, this, 1); - } - } else { - EnGeldB_SetupCircle(this); - } - } - } - } -} - -void EnGeldB_SetupRollBack(EnGeldB* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gGerudoRedFlipAnim, -3.0f); - this->timer = 0; - this->invisible = true; - this->action = GELDB_ROLL_BACK; - this->actor.speedXZ = -8.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnGeldB_SetupAction(this, EnGeldB_RollBack); -} - -void EnGeldB_RollBack(EnGeldB* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && - (this->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { - EnGeldB_SetupSpinAttack(this); - } else if (globalCtx->gameplayFrames & 1) { - EnGeldB_SetupSidestep(this, globalCtx); - } else { - EnGeldB_SetupReady(this); - } - } - if ((globalCtx->state.frames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } -} - -void EnGeldB_SetupStunned(EnGeldB* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; - } - if ((this->damageEffect != GELDB_DMG_FREEZE) || (this->action == GELDB_SPIN_ATTACK)) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gGerudoRedDamageAnim, 0.0f); - } - if (this->damageEffect == GELDB_DMG_FREEZE) { - this->iceTimer = 36; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->action = GELDB_STUNNED; - EnGeldB_SetupAction(this, EnGeldB_Stunned); -} - -void EnGeldB_Stunned(EnGeldB* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - this->invisible = false; - } - if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { - if (this->actor.colChkInfo.health == 0) { - EnGeldB_SetupDefeated(this); - } else { - EnGeldB_ReactToPlayer(globalCtx, this, 1); - } - } -} - -void EnGeldB_SetupDamaged(EnGeldB* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gGerudoRedDamageAnim, -4.0f); - if (this->actor.bgCheckFlags & 1) { - this->invisible = false; - this->actor.speedXZ = -4.0f; - } else { - this->invisible = true; - } - this->lookTimer = 0; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DAMAGE); - this->action = GELDB_DAMAGED; - EnGeldB_SetupAction(this, EnGeldB_Damaged); -} - -void EnGeldB_Damaged(EnGeldB* this, GlobalContext* globalCtx) { - s16 angleToWall; - - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - this->invisible = false; - } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x1194, 0); - if (!EnGeldB_DodgeRanged(globalCtx, this) && !EnGeldB_ReactToPlayer(globalCtx, this, 0) && - SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { - angleToWall = this->actor.wallYaw - this->actor.shape.rot.y; - if ((this->actor.bgCheckFlags & 8) && (ABS(angleToWall) < 0x2EE0) && (this->actor.xzDistToPlayer < 90.0f)) { - EnGeldB_SetupJump(this); - } else if (!EnGeldB_DodgeRanged(globalCtx, this)) { - if ((this->actor.xzDistToPlayer <= 45.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - (globalCtx->gameplayFrames & 7)) { - EnGeldB_SetupSlash(this); - } else { - EnGeldB_SetupRollBack(this); - } - } - } -} - -void EnGeldB_SetupJump(EnGeldB* this) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedFlipAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedFlipAnim, -1.0f, lastFrame, 0.0f, ANIMMODE_ONCE, -3.0f); - this->timer = 0; - this->invisible = false; - this->action = GELDB_JUMP; - this->actor.speedXZ = 6.5f; - this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actor.world.rot.y = this->actor.shape.rot.y; - EnGeldB_SetupAction(this, EnGeldB_Jump); -} - -void EnGeldB_Jump(EnGeldB* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - if (this->actor.velocity.y >= 5.0f) { - func_800355B8(globalCtx, &this->leftFootPos); - func_800355B8(globalCtx, &this->rightFootPos); - } - if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 3)) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.x = 0; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = this->actor.floorHeight; - if (!Actor_OtherIsTargeted(globalCtx, &this->actor)) { - EnGeldB_SetupSlash(this); - } else { - EnGeldB_SetupReady(this); - } - } -} - -void EnGeldB_SetupBlock(EnGeldB* this) { - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedBlockAnim); - - if (this->swordState != 0) { - this->swordState = -1; - } - this->actor.speedXZ = 0.0f; - this->action = GELDB_BLOCK; - this->timer = (s32)Rand_CenteredFloat(10.0f) + 10; - Animation_Change(&this->skelAnime, &gGerudoRedBlockAnim, 0.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); - EnGeldB_SetupAction(this, EnGeldB_Block); -} - -void EnGeldB_Block(EnGeldB* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 angleToLink; - s16 angleFacingLink; - - if (this->timer != 0) { - this->timer--; - } else { - this->skelAnime.playSpeed = 1.0f; - } - if (SkelAnime_Update(&this->skelAnime)) { - angleToLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(angleToLink) <= 0x4000) && (this->actor.xzDistToPlayer < 40.0f) && - (ABS(this->actor.yDistToPlayer) < 50.0f)) { - if (func_800354B4(globalCtx, &this->actor, 100.0f, 0x2710, 0x4000, this->actor.shape.rot.y)) { - if (player->swordAnimation == 0x11) { - EnGeldB_SetupSpinDodge(this, globalCtx); - } else if (globalCtx->gameplayFrames & 1) { - EnGeldB_SetupBlock(this); - } else { - EnGeldB_SetupRollBack(this); - } - } else { - angleFacingLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && - ((globalCtx->gameplayFrames & 1) || (ABS(angleFacingLink) < 0x38E0))) { - EnGeldB_SetupSlash(this); - } else { - EnGeldB_SetupCircle(this); - } - } - } else { - EnGeldB_SetupCircle(this); - } - } else if ((this->timer == 0) && - func_800354B4(globalCtx, &this->actor, 100.0f, 0x2710, 0x4000, this->actor.shape.rot.y)) { - if (player->swordAnimation == 0x11) { - EnGeldB_SetupSpinDodge(this, globalCtx); - } else if (!EnGeldB_DodgeRanged(globalCtx, this)) { - if ((globalCtx->gameplayFrames & 1)) { - if ((this->actor.xzDistToPlayer < 100.0f) && (Rand_ZeroOne() > 0.7f)) { - EnGeldB_SetupJump(this); - } else { - EnGeldB_SetupRollBack(this); - } - } else { - EnGeldB_SetupBlock(this); - } - } - } -} - -void EnGeldB_SetupSidestep(EnGeldB* this, GlobalContext* globalCtx) { - s16 linkAngle; - Player* player; - f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); - - Animation_Change(&this->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); - player = GET_PLAYER(globalCtx); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - linkAngle = player->actor.shape.rot.y; - if (Math_SinS(linkAngle - this->actor.shape.rot.y) > 0.0f) { - this->actor.speedXZ = -6.0f; - } else if (Math_SinS(linkAngle - this->actor.shape.rot.y) < 0.0f) { - this->actor.speedXZ = 6.0f; - } else { - this->actor.speedXZ = Rand_CenteredFloat(12.0f); - } - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.5f; - this->approachRate = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - this->timer = Rand_ZeroOne() * 10.0f + 5.0f; - this->action = GELDB_SIDESTEP; - EnGeldB_SetupAction(this, EnGeldB_Sidestep); -} - -void EnGeldB_Sidestep(EnGeldB* this, GlobalContext* globalCtx) { - s16 behindLinkAngle; - s16 phi_v1; - Player* player = GET_PLAYER(globalCtx); - s32 thisKeyFrame; - s32 prevKeyFrame; - f32 playSpeed; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 1); - behindLinkAngle = player->actor.shape.rot.y + 0x8000; - if (Math_SinS(behindLinkAngle - this->actor.shape.rot.y) > 0.0f) { - this->actor.speedXZ += 0.125f; - } else if (Math_SinS(behindLinkAngle - this->actor.shape.rot.y) <= 0.0f) { - this->actor.speedXZ -= 0.125f; - } - - if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.shape.rot.y + 0x3E80)) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - phi_v1 = this->actor.shape.rot.y + 0x3E80; - } else { - phi_v1 = this->actor.shape.rot.y - 0x3E80; - } - phi_v1 = this->actor.wallYaw - phi_v1; - } else { - this->actor.speedXZ *= -0.8f; - phi_v1 = 0; - } - if (ABS(phi_v1) > 0x4000) { - this->actor.speedXZ *= -0.8f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ += 0.5f; - } - } - } - if (this->actor.speedXZ >= 0.0f) { - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3E80; - } else { - this->actor.world.rot.y = this->actor.shape.rot.y - 0x3E80; - } - if (this->actor.xzDistToPlayer <= 45.0f) { - Math_SmoothStepToF(&this->approachRate, -4.0f, 1.0f, 1.5f, 0.0f); - } else if (this->actor.xzDistToPlayer > 40.0f) { - Math_SmoothStepToF(&this->approachRate, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->approachRate, 0.0f, 1.0f, 6.65f, 0.0f); - } - if (this->approachRate != 0.0f) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->approachRate; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->approachRate; - } - if (ABS(this->approachRate) < ABS(this->actor.speedXZ)) { - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.5f; - } else { - this->skelAnime.playSpeed = -this->approachRate * 0.5f; - } - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - thisKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - - playSpeed = ((void)0, ABS(this->skelAnime.playSpeed)); // Needed to match for some reason - - if (!EnGeldB_DodgeRanged(globalCtx, this) && !EnGeldB_ReactToPlayer(globalCtx, this, 0)) { - if (--this->timer == 0) { - s16 angleFacingPlayer = player->actor.shape.rot.y - this->actor.shape.rot.y; - - angleFacingPlayer = ABS(angleFacingPlayer); - if (angleFacingPlayer >= 0x3A98) { - EnGeldB_SetupReady(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 1.0f; - } else { - Player* player2 = GET_PLAYER(globalCtx); - s16 angleFacingPlayer2 = player2->actor.shape.rot.y - this->actor.shape.rot.y; - - this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 45.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - (!(globalCtx->gameplayFrames & 3) || (ABS(angleFacingPlayer2) < 0x38E0))) { - EnGeldB_SetupSlash(this); - } else if ((210.0f > this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 150.0f) && - !(globalCtx->gameplayFrames & 1)) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor) || (Rand_ZeroOne() > 0.5f) || - (ABS(angleFacingPlayer2) < 0x38E0)) { - EnGeldB_SetupRollForward(this); - } else { - EnGeldB_SetupSpinAttack(this); - } - } else { - EnGeldB_SetupAdvance(this, globalCtx); - } - } - } - if ((thisKeyFrame != (s32)this->skelAnime.curFrame) && - (((prevKeyFrame < 0) && (((s32)playSpeed + thisKeyFrame) > 0)) || - ((prevKeyFrame < 5) && (((s32)playSpeed + thisKeyFrame) > 5)))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); - } - } -} - -void EnGeldB_SetupDefeated(EnGeldB* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gGerudoRedDefeatAnim, -4.0f); - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - if (this->actor.bgCheckFlags & 1) { - this->invisible = false; - this->actor.speedXZ = -6.0f; - } else { - this->invisible = true; - } - this->action = GELDB_DEFEAT; - this->actor.flags &= ~ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DEAD); - EnGeldB_SetupAction(this, EnGeldB_Defeated); -} - -void EnGeldB_Defeated(EnGeldB* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - if (this->actor.bgCheckFlags & 1) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - this->invisible = false; - } - if (SkelAnime_Update(&this->skelAnime)) { - EnGeldB_SetupFlee(this); - } else if ((s32)this->skelAnime.curFrame == 10) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - func_800F5B58(); - } -} - -void EnGeldB_TurnHead(EnGeldB* this, GlobalContext* globalCtx) { - if ((this->action == GELDB_READY) && (this->lookTimer != 0)) { - this->headRot.y = Math_SinS(this->lookTimer * 0x1068) * 8920.0f; - } else if (this->action != GELDB_STUNNED) { - if ((this->action != GELDB_SLASH) && (this->action != GELDB_SPIN_ATTACK)) { - Math_SmoothStepToS(&this->headRot.y, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 1, 0x1F4, 0); - this->headRot.y = CLAMP(this->headRot.y, -0x256F, 0x256F); - } else { - this->headRot.y = 0; - } - } -} - -void EnGeldB_CollisionCheck(EnGeldB* this, GlobalContext* globalCtx) { - s32 pad; - EnItem00* key; - - if (this->blockCollider.base.acFlags & AC_BOUNCED) { - this->blockCollider.base.acFlags &= ~AC_BOUNCED; - this->bodyCollider.base.acFlags &= ~AC_HIT; - } else if ((this->bodyCollider.base.acFlags & AC_HIT) && (this->action >= GELDB_READY) && - (this->spinAttackState < 2)) { - this->bodyCollider.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != GELDB_DMG_UNK_6) { - this->damageEffect = this->actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->actor, &this->bodyCollider.info, 1); - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_GERUDOFT_BREATH); - if ((this->actor.colChkInfo.damageEffect == GELDB_DMG_STUN) || - (this->actor.colChkInfo.damageEffect == GELDB_DMG_FREEZE)) { - if (this->action != GELDB_STUNNED) { - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); - Actor_ApplyDamage(&this->actor); - EnGeldB_SetupStunned(this); - } - } else { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - if (Actor_ApplyDamage(&this->actor) == 0) { - if (this->keyFlag != 0) { - key = Item_DropCollectible(globalCtx, &this->actor.world.pos, this->keyFlag | ITEM00_SMALL_KEY); - if (key != NULL) { - key->actor.world.rot.y = Math_Vec3f_Yaw(&key->actor.world.pos, &this->actor.home.pos); - key->actor.speedXZ = 6.0f; - Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - EnGeldB_SetupDefeated(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else { - EnGeldB_SetupDamaged(this); - } - } - } - } -} - -void EnGeldB_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnGeldB* this = (EnGeldB*)thisx; - - EnGeldB_CollisionCheck(this, globalCtx); - if (this->actor.colChkInfo.damageEffect != GELDB_DMG_UNK_6) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); - this->actionFunc(this, globalCtx); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 40.0f; - EnGeldB_TurnHead(this, globalCtx); - } - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - if ((this->action >= GELDB_READY) && (this->spinAttackState < 2) && - ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000))) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - if ((this->action == GELDB_BLOCK) && (this->skelAnime.curFrame == 0.0f)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->blockCollider.base); - } - if (this->swordState > 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->swordCollider.base); - } - if (this->blinkState == 0) { - if ((Rand_ZeroOne() < 0.1f) && ((globalCtx->gameplayFrames % 4) == 0)) { - this->blinkState++; - } - } else { - this->blinkState = (this->blinkState + 1) & 3; - } -} - -s32 EnGeldB_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnGeldB* this = (EnGeldB*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2507); - if (limbIndex == GELDB_LIMB_NECK) { - rot->z += this->headRot.x; - rot->x += this->headRot.y; - rot->y += this->headRot.z; - } else if (limbIndex == GELDB_LIMB_HEAD) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 80, 60, 10, 255); - } else if ((limbIndex == GELDB_LIMB_R_SWORD) || (limbIndex == GELDB_LIMB_L_SWORD)) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 140, 170, 230, 255); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - } else { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 140, 0, 0, 255); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2529); - return false; -} - -void EnGeldB_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f footOffset = { 300.0f, 0.0f, 0.0f }; - static Vec3f swordTipOffset = { 0.0f, -3000.0f, 0.0f }; - static Vec3f swordHiltOffset = { 400.0f, 0.0f, 0.0f }; - static Vec3f swordQuadOffset1 = { 1600.0f, -4000.0f, 0.0f }; - static Vec3f swordQuadOffset0 = { -3000.0f, -2000.0f, 1300.0f }; - static Vec3f swordQuadOffset3 = { -3000.0f, -2000.0f, -1300.0f }; - static Vec3f swordQuadOffset2 = { 1000.0f, 1000.0f, 0.0f }; - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f swordTip; - Vec3f swordHilt; - EnGeldB* this = (EnGeldB*)thisx; - s32 bodyPart = -1; - - if (limbIndex == GELDB_LIMB_R_SWORD) { - Matrix_MultVec3f(&swordQuadOffset1, &this->swordCollider.dim.quad[1]); - Matrix_MultVec3f(&swordQuadOffset0, &this->swordCollider.dim.quad[0]); - Matrix_MultVec3f(&swordQuadOffset3, &this->swordCollider.dim.quad[3]); - Matrix_MultVec3f(&swordQuadOffset2, &this->swordCollider.dim.quad[2]); - Collider_SetQuadVertices(&this->swordCollider, &this->swordCollider.dim.quad[0], - &this->swordCollider.dim.quad[1], &this->swordCollider.dim.quad[2], - &this->swordCollider.dim.quad[3]); - Matrix_MultVec3f(&swordTipOffset, &swordTip); - Matrix_MultVec3f(&swordHiltOffset, &swordHilt); - - if ((this->swordState < 0) || ((this->action != GELDB_SLASH) && (this->action != GELDB_SPIN_ATTACK))) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIndex)); - this->swordState = 0; - } else if (this->swordState > 0) { - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIndex), &swordTip, &swordHilt); - } - } else { - Actor_SetFeetPos(&this->actor, limbIndex, GELDB_LIMB_L_FOOT, &footOffset, GELDB_LIMB_R_FOOT, &footOffset); - } - - if (limbIndex == GELDB_LIMB_L_FOOT) { - Matrix_MultVec3f(&footOffset, &this->leftFootPos); - } else if (limbIndex == GELDB_LIMB_R_FOOT) { - Matrix_MultVec3f(&footOffset, &this->rightFootPos); - } - - if (this->iceTimer != 0) { - switch (limbIndex) { - case GELDB_LIMB_NECK: - bodyPart = 0; - break; - case GELDB_LIMB_L_SWORD: - bodyPart = 1; - break; - case GELDB_LIMB_R_SWORD: - bodyPart = 2; - break; - case GELDB_LIMB_L_UPPER_ARM: - bodyPart = 3; - break; - case GELDB_LIMB_R_UPPER_ARM: - bodyPart = 4; - break; - case GELDB_LIMB_TORSO: - bodyPart = 5; - break; - case GELDB_LIMB_WAIST: - bodyPart = 6; - break; - case GELDB_LIMB_L_FOOT: - bodyPart = 7; - break; - case GELDB_LIMB_R_FOOT: - bodyPart = 8; - break; - default: - break; - } - - if (bodyPart >= 0) { - Vec3f limbPos; - - Matrix_MultVec3f(&zeroVec, &limbPos); - this->bodyPartsPos[bodyPart].x = limbPos.x; - this->bodyPartsPos[bodyPart].y = limbPos.y; - this->bodyPartsPos[bodyPart].z = limbPos.z; - } - } -} - -void EnGeldB_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f blockTrisOffsets0[3] = { - { -3000.0f, 6000.0f, 1600.0f }, - { -3000.0f, 0.0f, 1600.0f }, - { 3000.0f, 6000.0f, 1600.0f }, - }; - static Vec3f blockTrisOffsets1[3] = { - { -3000.0f, 0.0f, 1600.0f }, - { 3000.0f, 0.0f, 1600.0f }, - { 3000.0f, 6000.0f, 1600.0f }, - }; - static void* eyeTextures[] = { gGerudoRedEyeOpenTex, gGerudoRedEyeHalfTex, gGerudoRedEyeShutTex, - gGerudoRedEyeHalfTex }; - s32 pad; - EnGeldB* this = (EnGeldB*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2672); - if (1) {} - - if ((this->spinAttackState >= 2) && SkelAnime_Update(&this->skelAnime)) { - if (this->spinAttackState == 2) { - Animation_Change(&this->skelAnime, &gGerudoRedSpinAttackAnim, 0.5f, 0.0f, 12.0f, ANIMMODE_ONCE_INTERP, - 4.0f); - this->spinAttackState++; - thisx->world.rot.y = thisx->shape.rot.y = thisx->yawTowardsPlayer; - } else { - this->timer--; - if (this->timer == 0) { - if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { - globalCtx->nextEntranceIndex = 0x1A5; - } else if (gSaveContext.eventChkInf[12] & 0x80) { - globalCtx->nextEntranceIndex = 0x5F8; - } else { - globalCtx->nextEntranceIndex = 0x3B4; - } - globalCtx->fadeTransition = 0x26; - globalCtx->sceneLoadFlag = 0x14; - } - } - } - - if ((this->action != GELDB_WAIT) || !this->invisible) { - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->blinkState])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnGeldB_OverrideLimbDraw, EnGeldB_PostLimbDraw, this); - if (this->action == GELDB_BLOCK) { - s32 i; - Vec3f blockTrisVtx0[3]; - Vec3f blockTrisVtx1[3]; - - for (i = 0; i < 3; i++) { - Matrix_MultVec3f(&blockTrisOffsets0[i], &blockTrisVtx0[i]); - Matrix_MultVec3f(&blockTrisOffsets1[i], &blockTrisVtx1[i]); - } - Collider_SetTrisVertices(&this->blockCollider, 0, &blockTrisVtx0[0], &blockTrisVtx0[1], &blockTrisVtx0[2]); - Collider_SetTrisVertices(&this->blockCollider, 1, &blockTrisVtx1[0], &blockTrisVtx1[1], &blockTrisVtx1[2]); - } - - if (this->iceTimer != 0) { - thisx->colorFilterTimer++; - this->iceTimer--; - if ((this->iceTimer % 4) == 0) { - s32 iceIndex = this->iceTimer >> 2; - - EffectSsEnIce_SpawnFlyingVec3s(globalCtx, thisx, &this->bodyPartsPos[iceIndex], 150, 150, 150, 250, 235, - 245, 255, 1.5f); - } - } - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2744); -} - -s32 EnGeldB_DodgeRanged(GlobalContext* globalCtx, EnGeldB* this) { - Actor* actor = Actor_GetProjectileActor(globalCtx, &this->actor, 800.0f); - - if (actor != NULL) { - s16 angleToFacing; - s16 pad18; - f32 dist; - - angleToFacing = Actor_WorldYawTowardActor(&this->actor, actor) - this->actor.shape.rot.y; - this->actor.world.rot.y = (u16)this->actor.shape.rot.y & 0xFFFF; - dist = Actor_WorldDistXYZToPoint(&this->actor, &actor->world.pos); - //! @bug - // Actor_WorldDistXYZToPoint already sqrtfs the distance, so this actually checks for a - // distance of 360000. Also it's a double calculation because no f on sqrt. - if ((ABS(angleToFacing) < 0x2EE0) && (sqrt(dist) < 600.0)) { - if (actor->id == ACTOR_ARMS_HOOK) { - EnGeldB_SetupJump(this); - } else { - EnGeldB_SetupBlock(this); - } - } else { - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - if ((ABS(angleToFacing) < 0x2000) || (ABS(angleToFacing) > 0x5FFF)) { - EnGeldB_SetupSidestep(this, globalCtx); - this->actor.speedXZ *= 3.0f; - } else if (ABS(angleToFacing) < 0x5FFF) { - EnGeldB_SetupRollBack(this); - } - } - return true; - } - return false; -} diff --git a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.cpp b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.cpp new file mode 100644 index 000000000..e6cef1bdf --- /dev/null +++ b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.cpp @@ -0,0 +1,1659 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GELDB_Z_EN_GELDB_C +#include "actor_common.h" +/* + * File: z_en_geldb.c + * Overlay: ovl_En_GeldB + * Description: Gerudo fighter + */ + +#include "z_en_geldb.h" +#include "objects/object_geldb/object_geldb.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +typedef enum { + /* 0 */ GELDB_WAIT, + /* 1 */ GELDB_DEFEAT, + /* 2 */ GELDB_DAMAGED, + /* 3 */ GELDB_JUMP, + /* 4 */ GELDB_ROLL_BACK, + /* 5 */ GELDB_READY, + /* 6 */ GELDB_BLOCK, + /* 7 */ GELDB_SLASH, + /* 8 */ GELDB_ADVANCE, + /* 9 */ GELDB_PIVOT, + /* 10 */ GELDB_CIRCLE, + /* 11 */ GELDB_UNUSED, + /* 12 */ GELDB_SPIN_ATTACK, + /* 13 */ GELDB_SIDESTEP, + /* 14 */ GELDB_ROLL_FORWARD, + /* 15 */ GELDB_STUNNED, + /* 16 */ GELDB_SPIN_DODGE +} EnGeldBAction; + +void EnGeldB_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGeldB_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGeldB_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGeldB_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 EnGeldB_DodgeRanged(GlobalContext* globalCtx, EnGeldB* pthis); + +void EnGeldB_SetupWait(EnGeldB* pthis); +void EnGeldB_SetupReady(EnGeldB* pthis); +void EnGeldB_SetupAdvance(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_SetupPivot(EnGeldB* pthis); +void EnGeldB_SetupRollForward(EnGeldB* pthis); +void EnGeldB_SetupCircle(EnGeldB* pthis); +void EnGeldB_SetupSpinDodge(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_SetupSlash(EnGeldB* pthis); +void EnGeldB_SetupSpinAttack(EnGeldB* pthis); +void EnGeldB_SetupRollBack(EnGeldB* pthis); +void EnGeldB_SetupJump(EnGeldB* pthis); +void EnGeldB_SetupBlock(EnGeldB* pthis); +void EnGeldB_SetupSidestep(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_SetupDefeated(EnGeldB* pthis); + +void EnGeldB_Wait(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Flee(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Ready(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Advance(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_RollForward(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Pivot(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Circle(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_SpinDodge(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Slash(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_SpinAttack(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_RollBack(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Stunned(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Damaged(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Jump(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Block(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Sidestep(EnGeldB* pthis, GlobalContext* globalCtx); +void EnGeldB_Defeated(EnGeldB* pthis, GlobalContext* globalCtx); + +ActorInit En_GeldB_InitVars = { + ACTOR_EN_GELDB, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_GELDB, + sizeof(EnGeldB), + (ActorFunc)EnGeldB_Init, + (ActorFunc)EnGeldB_Destroy, + (ActorFunc)EnGeldB_Update, + (ActorFunc)EnGeldB_Draw, +}; + +static ColliderCylinderInit sBodyCylInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 50, 0, { 0, 0, 0 } }, +}; + +static ColliderTrisElementInit sBlockTrisElementsInit[2] = { + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC1FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC1FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, +}; + +static ColliderTrisInit sBlockTrisInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sBlockTrisElementsInit, +}; + +static ColliderQuadInit sSwordQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +typedef enum { + /* 0x0 */ GELDB_DMG_NORMAL, + /* 0x1 */ GELDB_DMG_STUN, + /* 0x6 */ GELDB_DMG_UNK_6 = 0x6, + /* 0xD */ GELDB_DMG_UNK_D = 0xD, + /* 0xE */ GELDB_DMG_UNK_E, + /* 0xF */ GELDB_DMG_FREEZE +} EnGeldBDamageEffects; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, GELDB_DMG_STUN), + /* Deku stick */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Slingshot */ DMG_ENTRY(1, GELDB_DMG_NORMAL), + /* Explosive */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Boomerang */ DMG_ENTRY(0, GELDB_DMG_STUN), + /* Normal arrow */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Hammer swing */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Hookshot */ DMG_ENTRY(0, GELDB_DMG_STUN), + /* Kokiri sword */ DMG_ENTRY(1, GELDB_DMG_NORMAL), + /* Master sword */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Giant's Knife */ DMG_ENTRY(4, GELDB_DMG_NORMAL), + /* Fire arrow */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Ice arrow */ DMG_ENTRY(2, GELDB_DMG_FREEZE), + /* Light arrow */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Unk arrow 1 */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Unk arrow 2 */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Unk arrow 3 */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Fire magic */ DMG_ENTRY(4, GELDB_DMG_UNK_E), + /* Ice magic */ DMG_ENTRY(0, GELDB_DMG_UNK_6), + /* Light magic */ DMG_ENTRY(3, GELDB_DMG_UNK_D), + /* Shield */ DMG_ENTRY(0, GELDB_DMG_NORMAL), + /* Mirror Ray */ DMG_ENTRY(0, GELDB_DMG_NORMAL), + /* Kokiri spin */ DMG_ENTRY(1, GELDB_DMG_NORMAL), + /* Giant spin */ DMG_ENTRY(4, GELDB_DMG_NORMAL), + /* Master spin */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Kokiri jump */ DMG_ENTRY(2, GELDB_DMG_NORMAL), + /* Giant jump */ DMG_ENTRY(8, GELDB_DMG_NORMAL), + /* Master jump */ DMG_ENTRY(4, GELDB_DMG_NORMAL), + /* Unknown 1 */ DMG_ENTRY(4, GELDB_DMG_NORMAL), + /* Unblockable */ DMG_ENTRY(0, GELDB_DMG_NORMAL), + /* Hammer jump */ DMG_ENTRY(4, GELDB_DMG_NORMAL), + /* Unknown 2 */ DMG_ENTRY(0, GELDB_DMG_NORMAL), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -3000, ICHAIN_STOP), +}; + +static Vec3f sUnusedOffset = { 1100.0f, -700.0f, 0.0f }; + +void EnGeldB_SetupAction(EnGeldB* pthis, EnGeldBActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnGeldB_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EffectBlureInit1 blureInit; + EnGeldB* pthis = (EnGeldB*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + thisx->colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawFeet, 0.0f); + pthis->actor.colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.health = 20; + thisx->colChkInfo.cylRadius = 50; + thisx->colChkInfo.cylHeight = 100; + thisx->naviEnemyId = 0x54; + pthis->keyFlag = thisx->params & 0xFF00; + thisx->params &= 0xFF; + pthis->blinkState = 0; + pthis->unkFloat = 10.0f; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGerudoRedSkel, &gGerudoRedNeutralAnim, pthis->jointTable, + pthis->morphTable, GELDB_LIMB_MAX); + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, thisx, &sBodyCylInit); + Collider_InitTris(globalCtx, &pthis->blockCollider); + Collider_SetTris(globalCtx, &pthis->blockCollider, thisx, &sBlockTrisInit, pthis->blockElements); + Collider_InitQuad(globalCtx, &pthis->swordCollider); + Collider_SetQuad(globalCtx, &pthis->swordCollider, thisx, &sSwordQuadInit); + blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = + blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = + blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = blureInit.p2EndColor[1] = + blureInit.p2EndColor[2] = 255; + blureInit.p2StartColor[3] = 64; + blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; + blureInit.elemDuration = 8; + blureInit.unkFlag = 0; + blureInit.calcMode = 2; + + Effect_Add(globalCtx, &pthis->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); + Actor_SetScale(thisx, 0.012499999f); + EnGeldB_SetupWait(pthis); + if ((pthis->keyFlag != 0) && Flags_GetCollectible(globalCtx, pthis->keyFlag >> 8)) { + Actor_Kill(thisx); + } +} + +void EnGeldB_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGeldB* pthis = (EnGeldB*)thisx; + + func_800F5B58(); + Effect_Delete(globalCtx, pthis->blureIndex); + Collider_DestroyTris(globalCtx, &pthis->blockCollider); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyQuad(globalCtx, &pthis->swordCollider); +} + +s32 EnGeldB_ReactToPlayer(GlobalContext* globalCtx, EnGeldB* pthis, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + Actor* thisx = &pthis->actor; + s16 angleToWall; + s16 angleToLink; + Actor* bomb; + + angleToWall = thisx->wallYaw - thisx->shape.rot.y; + angleToWall = ABS(angleToWall); + angleToLink = thisx->yawTowardsPlayer - thisx->shape.rot.y; + angleToLink = ABS(angleToLink); + + if (func_800354B4(globalCtx, thisx, 100.0f, 0x2710, 0x3E80, thisx->shape.rot.y)) { + if (player->swordAnimation == 0x11) { + EnGeldB_SetupSpinDodge(pthis, globalCtx); + return true; + } else if (globalCtx->gameplayFrames & 1) { + EnGeldB_SetupBlock(pthis); + return true; + } + } + if (func_800354B4(globalCtx, thisx, 100.0f, 0x5DC0, 0x2AA8, thisx->shape.rot.y)) { + thisx->shape.rot.y = thisx->world.rot.y = thisx->yawTowardsPlayer; + if ((thisx->bgCheckFlags & 8) && (ABS(angleToWall) < 0x2EE0) && (thisx->xzDistToPlayer < 90.0f)) { + EnGeldB_SetupJump(pthis); + return true; + } else if (player->swordAnimation == 0x11) { + EnGeldB_SetupSpinDodge(pthis, globalCtx); + return true; + } else if ((thisx->xzDistToPlayer < 90.0f) && (globalCtx->gameplayFrames & 1)) { + EnGeldB_SetupBlock(pthis); + return true; + } else { + EnGeldB_SetupRollBack(pthis); + return true; + } + } else if ((bomb = Actor_FindNearby(globalCtx, thisx, -1, ACTORCAT_EXPLOSIVE, 80.0f)) != NULL) { + thisx->shape.rot.y = thisx->world.rot.y = thisx->yawTowardsPlayer; + if (((thisx->bgCheckFlags & 8) && (angleToWall < 0x2EE0)) || (bomb->id == ACTOR_EN_BOM_CHU)) { + if ((bomb->id == ACTOR_EN_BOM_CHU) && (Actor_WorldDistXYZToActor(thisx, bomb) < 80.0f) && + ((s16)(thisx->shape.rot.y - (bomb->world.rot.y - 0x8000)) < 0x3E80)) { + EnGeldB_SetupJump(pthis); + return true; + } else { + EnGeldB_SetupSidestep(pthis, globalCtx); + return true; + } + } else { + EnGeldB_SetupRollBack(pthis); + return true; + } + } else if (arg2) { + if (angleToLink >= 0x1B58) { + EnGeldB_SetupSidestep(pthis, globalCtx); + return true; + } else { + s16 angleToFacingLink = player->actor.shape.rot.y - thisx->shape.rot.y; + + if ((thisx->xzDistToPlayer <= 45.0f) && !Actor_OtherIsTargeted(globalCtx, thisx) && + ((globalCtx->gameplayFrames & 7) || (ABS(angleToFacingLink) < 0x38E0))) { + EnGeldB_SetupSlash(pthis); + return true; + } else { + EnGeldB_SetupCircle(pthis); + return true; + } + } + } + return false; +} + +void EnGeldB_SetupWait(EnGeldB* pthis) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gGerudoRedJumpAnim, 0.0f); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 120.0f; + pthis->timer = 10; + pthis->invisible = true; + pthis->action = GELDB_WAIT; + pthis->actor.bgCheckFlags &= ~3; + pthis->actor.gravity = -2.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnGeldB_SetupAction(pthis, EnGeldB_Wait); +} + +void EnGeldB_Wait(EnGeldB* pthis, GlobalContext* globalCtx) { + if ((pthis->invisible && !Flags_GetSwitch(globalCtx, pthis->actor.home.rot.z)) || + pthis->actor.xzDistToPlayer > 300.0f) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.world.pos.y = pthis->actor.floorHeight + 120.0f; + } else { + pthis->invisible = false; + pthis->actor.shape.shadowScale = 90.0f; + func_800F5ACC(NA_BGM_MINI_BOSS); + } + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + pthis->skelAnime.playSpeed = 1.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.bgCheckFlags &= ~2; + pthis->actor.velocity.y = 0.0f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + } + if (SkelAnime_Update(&pthis->skelAnime)) { + EnGeldB_SetupReady(pthis); + } +} + +void EnGeldB_SetupFlee(EnGeldB* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedJumpAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedJumpAnim, -2.0f, lastFrame, 0.0f, ANIMMODE_ONCE_INTERP, -4.0f); + pthis->timer = 20; + pthis->invisible = false; + pthis->action = GELDB_WAIT; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnGeldB_SetupAction(pthis, EnGeldB_Flee); +} + +void EnGeldB_Flee(EnGeldB* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame == 10.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + } + if (pthis->skelAnime.curFrame == 2.0f) { + pthis->actor.gravity = 0.0f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + } + if (SkelAnime_Update(&pthis->skelAnime)) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 300.0f, 1.0f, 20.5f, 0.0f); + pthis->timer--; + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); + } + } +} + +void EnGeldB_SetupReady(EnGeldB* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gGerudoRedNeutralAnim, -4.0f); + pthis->action = GELDB_READY; + pthis->timer = Rand_ZeroOne() * 10.0f + 5.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnGeldB_SetupAction(pthis, EnGeldB_Ready); +} + +void EnGeldB_Ready(EnGeldB* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 angleToLink; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->lookTimer != 0) { + angleToLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y - pthis->headRot.y; + if (ABS(angleToLink) > 0x2000) { + pthis->lookTimer--; + return; + } + pthis->lookTimer = 0; + } + angleToLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (!EnGeldB_DodgeRanged(globalCtx, pthis)) { + if (pthis->unkTimer != 0) { + pthis->unkTimer--; + + if (ABS(angleToLink) >= 0x1FFE) { + return; + } + pthis->unkTimer = 0; + } else if (EnGeldB_ReactToPlayer(globalCtx, pthis, 0)) { + return; + } + angleToLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + if ((pthis->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && (ABS(angleToLink) >= 0x1F40)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnGeldB_SetupCircle(pthis); + } else if (--pthis->timer == 0) { + if (Actor_IsFacingPlayer(&pthis->actor, 30 * 0x10000 / 360)) { + if ((210.0f > pthis->actor.xzDistToPlayer) && (pthis->actor.xzDistToPlayer > 150.0f) && + (Rand_ZeroOne() < 0.3f)) { + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor) || (Rand_ZeroOne() > 0.5f) || + (ABS(angleToLink) < 0x38E0)) { + EnGeldB_SetupRollForward(pthis); + } else { + EnGeldB_SetupSpinAttack(pthis); + } + } else if (Rand_ZeroOne() > 0.3f) { + EnGeldB_SetupAdvance(pthis, globalCtx); + } else { + EnGeldB_SetupCircle(pthis); + } + } else { + EnGeldB_SetupPivot(pthis); + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } + } + } +} + +void EnGeldB_SetupAdvance(EnGeldB* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedWalkAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedWalkAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); + pthis->action = GELDB_ADVANCE; + EnGeldB_SetupAction(pthis, EnGeldB_Advance); +} + +void EnGeldB_Advance(EnGeldB* pthis, GlobalContext* globalCtx) { + s32 thisKeyFrame; + s32 prevKeyFrame; + s32 playSpeed; + s16 facingAngletoLink; + Player* player = GET_PLAYER(globalCtx); + + if (!EnGeldB_DodgeRanged(globalCtx, pthis)) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x2EE, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->actor.xzDistToPlayer <= 40.0f) { + Math_SmoothStepToF(&pthis->actor.speedXZ, -8.0f, 1.0f, 1.5f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > 55.0f) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 8.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 6.65f, 0.0f); + } + pthis->skelAnime.playSpeed = pthis->actor.speedXZ / 8.0f; + facingAngletoLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + facingAngletoLink = ABS(facingAngletoLink); + if ((pthis->actor.xzDistToPlayer < 150.0f) && (player->swordState != 0) && (facingAngletoLink >= 0x1F40)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + EnGeldB_SetupCircle(pthis); + return; + } + } + thisKeyFrame = (s32)pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + prevKeyFrame = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + playSpeed = (f32)ABS(pthis->skelAnime.playSpeed); + if (!Actor_IsFacingPlayer(&pthis->actor, 0x11C7)) { + if (Rand_ZeroOne() > 0.5f) { + EnGeldB_SetupCircle(pthis); + } else { + EnGeldB_SetupReady(pthis); + } + } else if (pthis->actor.xzDistToPlayer < 90.0f) { + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (Rand_ZeroOne() > 0.03f || (pthis->actor.xzDistToPlayer <= 45.0f && facingAngletoLink < 0x38E0))) { + EnGeldB_SetupSlash(pthis); + } else if (Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (Rand_ZeroOne() > 0.5f)) { + EnGeldB_SetupRollBack(pthis); + } else { + EnGeldB_SetupCircle(pthis); + } + } + if (!EnGeldB_ReactToPlayer(globalCtx, pthis, 0)) { + if ((210.0f > pthis->actor.xzDistToPlayer) && (pthis->actor.xzDistToPlayer > 150.0f) && + Actor_IsFacingPlayer(&pthis->actor, 0x71C)) { + if (Actor_IsTargeted(globalCtx, &pthis->actor)) { + if (Rand_ZeroOne() > 0.5f) { + EnGeldB_SetupRollForward(pthis); + } else { + EnGeldB_SetupSpinAttack(pthis); + } + } else { + EnGeldB_SetupCircle(pthis); + return; + } + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } + if (thisKeyFrame != (s32)pthis->skelAnime.curFrame) { + s32 temp = playSpeed + thisKeyFrame; + + if (((prevKeyFrame < 0) && (temp > 0)) || ((prevKeyFrame < 4) && (temp > 4))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_LAND); + } + } + } + } +} + +void EnGeldB_SetupRollForward(EnGeldB* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedFlipAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedFlipAnim, -1.0f, lastFrame, 0.0f, ANIMMODE_ONCE, -3.0f); + pthis->timer = 0; + pthis->invisible = true; + pthis->action = GELDB_ROLL_FORWARD; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = 10.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + EnGeldB_SetupAction(pthis, EnGeldB_RollForward); +} + +void EnGeldB_RollForward(EnGeldB* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 facingAngleToLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->invisible = false; + pthis->actor.speedXZ = 0.0f; + if (!Actor_IsFacingPlayer(&pthis->actor, 0x1554)) { + EnGeldB_SetupReady(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + if (ABS(facingAngleToLink) < 0x38E0) { + pthis->lookTimer = 20; + } + } else if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (Rand_ZeroOne() > 0.5f || (ABS(facingAngleToLink) < 0x3FFC))) { + EnGeldB_SetupSlash(pthis); + } else { + EnGeldB_SetupAdvance(pthis, globalCtx); + } + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } +} + +void EnGeldB_SetupPivot(EnGeldB* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gGerudoRedSidestepAnim, -4.0f); + pthis->action = GELDB_PIVOT; + EnGeldB_SetupAction(pthis, EnGeldB_Pivot); +} + +void EnGeldB_Pivot(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 angleToLink; + s16 turnRate; + f32 playSpeed; + + if (!EnGeldB_DodgeRanged(globalCtx, pthis) && !EnGeldB_ReactToPlayer(globalCtx, pthis, 0)) { + angleToLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + turnRate = (angleToLink > 0) ? ((angleToLink * 0.25f) + 2000.0f) : ((angleToLink * 0.25f) - 2000.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y += turnRate; + if (angleToLink > 0) { + playSpeed = turnRate * 0.5f; + playSpeed = CLAMP_MAX(playSpeed, 1.0f); + } else { + playSpeed = turnRate * 0.5f; + playSpeed = CLAMP_MIN(playSpeed, -1.0f); + } + pthis->skelAnime.playSpeed = -playSpeed; + SkelAnime_Update(&pthis->skelAnime); + if (Actor_IsFacingPlayer(&pthis->actor, 30 * 0x10000 / 360)) { + if (Rand_ZeroOne() > 0.8f) { + EnGeldB_SetupCircle(pthis); + } else { + EnGeldB_SetupAdvance(pthis, globalCtx); + } + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } + } +} + +void EnGeldB_SetupCircle(EnGeldB* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); + pthis->actor.speedXZ = Rand_CenteredFloat(12.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.5f; + pthis->timer = Rand_ZeroOne() * 30.0f + 30.0f; + pthis->action = GELDB_CIRCLE; + pthis->approachRate = 0.0f; + EnGeldB_SetupAction(pthis, EnGeldB_Circle); +} + +void EnGeldB_Circle(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 angleBehindLink; + s16 phi_v1; + s32 nextKeyFrame; + s32 thisKeyFrame; + s32 pad; + s32 prevKeyFrame; + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + if (!EnGeldB_DodgeRanged(globalCtx, pthis) && !EnGeldB_ReactToPlayer(globalCtx, pthis, 0)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3A98; + angleBehindLink = player->actor.shape.rot.y + 0x8000; + if (Math_SinS(angleBehindLink - pthis->actor.shape.rot.y) >= 0.0f) { + pthis->actor.speedXZ -= 0.25f; + if (pthis->actor.speedXZ < -8.0f) { + pthis->actor.speedXZ = -8.0f; + } + } else if (Math_SinS(angleBehindLink - pthis->actor.shape.rot.y) < 0.0f) { + pthis->actor.speedXZ += 0.25f; + if (pthis->actor.speedXZ > 8.0f) { + pthis->actor.speedXZ = 8.0f; + } + } + if ((pthis->actor.bgCheckFlags & 8) || !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, + pthis->actor.shape.rot.y + 0x3E80)) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + phi_v1 = pthis->actor.shape.rot.y + 0x3E80; + } else { + phi_v1 = pthis->actor.shape.rot.y - 0x3E80; + } + phi_v1 = pthis->actor.wallYaw - phi_v1; + } else { + pthis->actor.speedXZ *= -0.8f; + phi_v1 = 0; + } + if (ABS(phi_v1) > 0x4000) { + pthis->actor.speedXZ *= -0.8f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ += 0.5f; + } + } + } + if (pthis->actor.xzDistToPlayer <= 45.0f) { + Math_SmoothStepToF(&pthis->approachRate, -4.0f, 1.0f, 1.5f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > 40.0f) { + Math_SmoothStepToF(&pthis->approachRate, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->approachRate, 0.0f, 1.0f, 6.65f, 0.0f); + } + if (pthis->approachRate != 0.0f) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->approachRate; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->approachRate; + } + if (ABS(pthis->approachRate) < ABS(pthis->actor.speedXZ)) { + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.5f; + } else { + pthis->skelAnime.playSpeed = -pthis->approachRate * 0.5f; + } + pthis->skelAnime.playSpeed = CLAMP(pthis->skelAnime.playSpeed, -3.0f, 3.0f); + + thisKeyFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + + prevKeyFrame = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + nextKeyFrame = (s32)ABS(pthis->skelAnime.playSpeed) + thisKeyFrame; + if ((thisKeyFrame != (s32)pthis->skelAnime.curFrame) && + ((prevKeyFrame < 0 && 0 < nextKeyFrame) || (prevKeyFrame < 5 && 5 < nextKeyFrame))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_LAND); + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } + if ((Math_CosS(angleBehindLink - pthis->actor.shape.rot.y) < -0.85f) && + !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (pthis->actor.xzDistToPlayer <= 45.0f)) { + EnGeldB_SetupSlash(pthis); + } else if (--pthis->timer == 0) { + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (Rand_ZeroOne() > 0.5f)) { + EnGeldB_SetupRollBack(pthis); + } else { + EnGeldB_SetupReady(pthis); + } + } + } +} + +void EnGeldB_SetupSpinDodge(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 sp3E; + Player* player = GET_PLAYER(globalCtx); + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); + sp3E = player->actor.shape.rot.y; + if (Math_SinS(sp3E - pthis->actor.shape.rot.y) > 0.0f) { + pthis->actor.speedXZ = -10.0f; + } else if (Math_SinS(sp3E - pthis->actor.shape.rot.y) < 0.0f) { + pthis->actor.speedXZ = 10.0f; + } else if (Rand_ZeroOne() > 0.5f) { + pthis->actor.speedXZ = 10.0f; + } else { + pthis->actor.speedXZ = -10.0f; + } + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.5f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->timer = 6; + pthis->approachRate = 0.0f; + pthis->unkFloat = 0.0f; + pthis->action = GELDB_SPIN_DODGE; + + EnGeldB_SetupAction(pthis, EnGeldB_SpinDodge); +} + +void EnGeldB_SpinDodge(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 phi_v1; + s32 thisKeyFrame; + s32 pad; + s32 lastKeyFrame; + s32 nextKeyFrame; + + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x3A98; + if ((pthis->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.shape.rot.y + 0x3E80)) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + phi_v1 = pthis->actor.shape.rot.y + 0x3E80; + } else { + phi_v1 = pthis->actor.shape.rot.y - 0x3E80; + } + phi_v1 = pthis->actor.wallYaw - phi_v1; + } else { + pthis->actor.speedXZ *= -0.8f; + phi_v1 = 0; + } + if (ABS(phi_v1) > 0x4000) { + EnGeldB_SetupJump(pthis); + return; + } + } + if (pthis->actor.xzDistToPlayer <= 45.0f) { + Math_SmoothStepToF(&pthis->approachRate, -4.0f, 1.0f, 1.5f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > 40.0f) { + Math_SmoothStepToF(&pthis->approachRate, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->approachRate, 0.0f, 1.0f, 6.65f, 0.0f); + } + if (pthis->approachRate != 0.0f) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.yawTowardsPlayer) * pthis->approachRate; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.yawTowardsPlayer) * pthis->approachRate; + } + if (ABS(pthis->approachRate) < ABS(pthis->actor.speedXZ)) { + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.5f; + } else { + pthis->skelAnime.playSpeed = -pthis->approachRate * 0.5f; + } + pthis->skelAnime.playSpeed = CLAMP(pthis->skelAnime.playSpeed, -3.0f, 3.0f); + thisKeyFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + lastKeyFrame = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + nextKeyFrame = (s32)ABS(pthis->skelAnime.playSpeed) + thisKeyFrame; + if ((thisKeyFrame != (s32)pthis->skelAnime.curFrame) && + ((lastKeyFrame < 0 && 0 < nextKeyFrame) || (lastKeyFrame < 5 && 5 < nextKeyFrame))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_LAND); + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } + pthis->timer--; + if (pthis->timer == 0) { + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + if (!EnGeldB_DodgeRanged(globalCtx, pthis)) { + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (pthis->actor.xzDistToPlayer <= 70.0f)) { + EnGeldB_SetupSlash(pthis); + } else { + EnGeldB_SetupRollBack(pthis); + } + } + } else { + if (pthis->actor.speedXZ >= 0.0f) { + pthis->actor.shape.rot.y += 0x4000; + } else { + pthis->actor.shape.rot.y -= 0x4000; + } + } +} + +void EnGeldB_SetupSlash(EnGeldB* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gGerudoRedSlashAnim); + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + pthis->action = GELDB_SLASH; + pthis->spinAttackState = 0; + pthis->actor.speedXZ = 0.0f; + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_GERUDOFT_BREATH); + EnGeldB_SetupAction(pthis, EnGeldB_Slash); +} + +void EnGeldB_Slash(EnGeldB* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angleFacingLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + s16 angleToLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + angleFacingLink = ABS(angleFacingLink); + angleToLink = ABS(angleToLink); + + pthis->actor.speedXZ = 0.0f; + if ((s32)pthis->skelAnime.curFrame == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_ATTACK); + pthis->swordState = 1; + } else if ((s32)pthis->skelAnime.curFrame == 6) { + pthis->swordState = -1; + } + if (pthis->swordCollider.base.atFlags & AT_BOUNCED) { + pthis->swordState = -1; + pthis->swordCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + EnGeldB_SetupRollBack(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime)) { + if (!Actor_IsFacingPlayer(&pthis->actor, 0x1554)) { + EnGeldB_SetupReady(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + if (angleToLink > 0x4000) { + pthis->lookTimer = 20; + } + } else if (Rand_ZeroOne() > 0.7f || (pthis->actor.xzDistToPlayer >= 120.0f)) { + EnGeldB_SetupReady(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } else { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + EnGeldB_SetupSidestep(pthis, globalCtx); + } else if (angleFacingLink <= 0x2710) { + if (angleToLink > 0x3E80) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnGeldB_SetupCircle(pthis); + } else { + EnGeldB_ReactToPlayer(globalCtx, pthis, 1); + } + } else { + EnGeldB_SetupCircle(pthis); + } + } + } +} + +void EnGeldB_SetupSpinAttack(EnGeldB* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSpinAttackAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedSpinAttackAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE_INTERP, 0.0f); + pthis->swordCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + pthis->action = GELDB_SPIN_ATTACK; + pthis->spinAttackState = 0; + pthis->actor.speedXZ = 0.0f; + EnGeldB_SetupAction(pthis, EnGeldB_SpinAttack); +} + +void EnGeldB_SpinAttack(EnGeldB* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angleFacingLink; + s16 angleToLink; + + if (pthis->spinAttackState < 2) { + if (pthis->swordCollider.base.atFlags & AT_BOUNCED) { + pthis->swordCollider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + pthis->spinAttackState = 1; + pthis->skelAnime.playSpeed = 1.5f; + } else if (pthis->swordCollider.base.atFlags & AT_HIT) { + pthis->swordCollider.base.atFlags &= ~AT_HIT; + if (&player->actor == pthis->swordCollider.base.at) { + func_8002F71C(globalCtx, &pthis->actor, 6.0f, pthis->actor.yawTowardsPlayer, 6.0f); + pthis->spinAttackState = 2; + func_8002DF54(globalCtx, &pthis->actor, 0x18); + Message_StartTextbox(globalCtx, 0x6003, &pthis->actor); + pthis->timer = 30; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_YOUNG_LAUGH); + return; + } + } + } + if ((s32)pthis->skelAnime.curFrame < 9) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + } else if ((s32)pthis->skelAnime.curFrame == 13) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + pthis->swordState = 1; + pthis->actor.speedXZ = 10.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_ATTACK); + } else if ((s32)pthis->skelAnime.curFrame == 21) { + pthis->actor.speedXZ = 0.0f; + } else if ((s32)pthis->skelAnime.curFrame == 24) { + pthis->swordState = -1; + } + if (SkelAnime_Update(&pthis->skelAnime) && (pthis->spinAttackState < 2)) { + if (!Actor_IsFacingPlayer(&pthis->actor, 0x1554)) { + EnGeldB_SetupReady(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + pthis->lookTimer = 46; + } else if (pthis->spinAttackState != 0) { + EnGeldB_SetupRollBack(pthis); + } else if (Rand_ZeroOne() > 0.7f || (pthis->actor.xzDistToPlayer >= 120.0f)) { + EnGeldB_SetupReady(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } else { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + EnGeldB_SetupSidestep(pthis, globalCtx); + } else { + angleFacingLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + angleFacingLink = ABS(angleFacingLink); + if (angleFacingLink <= 0x2710) { + angleToLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + angleToLink = ABS(angleToLink); + if (angleToLink > 0x3E80) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnGeldB_SetupCircle(pthis); + } else { + EnGeldB_ReactToPlayer(globalCtx, pthis, 1); + } + } else { + EnGeldB_SetupCircle(pthis); + } + } + } + } +} + +void EnGeldB_SetupRollBack(EnGeldB* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gGerudoRedFlipAnim, -3.0f); + pthis->timer = 0; + pthis->invisible = true; + pthis->action = GELDB_ROLL_BACK; + pthis->actor.speedXZ = -8.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnGeldB_SetupAction(pthis, EnGeldB_RollBack); +} + +void EnGeldB_RollBack(EnGeldB* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (pthis->actor.xzDistToPlayer < 170.0f) && + (pthis->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { + EnGeldB_SetupSpinAttack(pthis); + } else if (globalCtx->gameplayFrames & 1) { + EnGeldB_SetupSidestep(pthis, globalCtx); + } else { + EnGeldB_SetupReady(pthis); + } + } + if ((globalCtx->state.frames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } +} + +void EnGeldB_SetupStunned(EnGeldB* pthis) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = 0.0f; + } + if ((pthis->damageEffect != GELDB_DMG_FREEZE) || (pthis->action == GELDB_SPIN_ATTACK)) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gGerudoRedDamageAnim, 0.0f); + } + if (pthis->damageEffect == GELDB_DMG_FREEZE) { + pthis->iceTimer = 36; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->action = GELDB_STUNNED; + EnGeldB_SetupAction(pthis, EnGeldB_Stunned); +} + +void EnGeldB_Stunned(EnGeldB* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + pthis->invisible = false; + } + if ((pthis->actor.colorFilterTimer == 0) && (pthis->actor.bgCheckFlags & 1)) { + if (pthis->actor.colChkInfo.health == 0) { + EnGeldB_SetupDefeated(pthis); + } else { + EnGeldB_ReactToPlayer(globalCtx, pthis, 1); + } + } +} + +void EnGeldB_SetupDamaged(EnGeldB* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gGerudoRedDamageAnim, -4.0f); + if (pthis->actor.bgCheckFlags & 1) { + pthis->invisible = false; + pthis->actor.speedXZ = -4.0f; + } else { + pthis->invisible = true; + } + pthis->lookTimer = 0; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_DAMAGE); + pthis->action = GELDB_DAMAGED; + EnGeldB_SetupAction(pthis, EnGeldB_Damaged); +} + +void EnGeldB_Damaged(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 angleToWall; + + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + pthis->invisible = false; + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x1194, 0); + if (!EnGeldB_DodgeRanged(globalCtx, pthis) && !EnGeldB_ReactToPlayer(globalCtx, pthis, 0) && + SkelAnime_Update(&pthis->skelAnime) && (pthis->actor.bgCheckFlags & 1)) { + angleToWall = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + if ((pthis->actor.bgCheckFlags & 8) && (ABS(angleToWall) < 0x2EE0) && (pthis->actor.xzDistToPlayer < 90.0f)) { + EnGeldB_SetupJump(pthis); + } else if (!EnGeldB_DodgeRanged(globalCtx, pthis)) { + if ((pthis->actor.xzDistToPlayer <= 45.0f) && !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (globalCtx->gameplayFrames & 7)) { + EnGeldB_SetupSlash(pthis); + } else { + EnGeldB_SetupRollBack(pthis); + } + } + } +} + +void EnGeldB_SetupJump(EnGeldB* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedFlipAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedFlipAnim, -1.0f, lastFrame, 0.0f, ANIMMODE_ONCE, -3.0f); + pthis->timer = 0; + pthis->invisible = false; + pthis->action = GELDB_JUMP; + pthis->actor.speedXZ = 6.5f; + pthis->actor.velocity.y = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnGeldB_SetupAction(pthis, EnGeldB_Jump); +} + +void EnGeldB_Jump(EnGeldB* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + if (pthis->actor.velocity.y >= 5.0f) { + func_800355B8(globalCtx, &pthis->leftFootPos); + func_800355B8(globalCtx, &pthis->rightFootPos); + } + if (SkelAnime_Update(&pthis->skelAnime) && (pthis->actor.bgCheckFlags & 3)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.shape.rot.x = 0; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + EnGeldB_SetupSlash(pthis); + } else { + EnGeldB_SetupReady(pthis); + } + } +} + +void EnGeldB_SetupBlock(EnGeldB* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedBlockAnim); + + if (pthis->swordState != 0) { + pthis->swordState = -1; + } + pthis->actor.speedXZ = 0.0f; + pthis->action = GELDB_BLOCK; + pthis->timer = (s32)Rand_CenteredFloat(10.0f) + 10; + Animation_Change(&pthis->skelAnime, &gGerudoRedBlockAnim, 0.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + EnGeldB_SetupAction(pthis, EnGeldB_Block); +} + +void EnGeldB_Block(EnGeldB* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 angleToLink; + s16 angleFacingLink; + + if (pthis->timer != 0) { + pthis->timer--; + } else { + pthis->skelAnime.playSpeed = 1.0f; + } + if (SkelAnime_Update(&pthis->skelAnime)) { + angleToLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((ABS(angleToLink) <= 0x4000) && (pthis->actor.xzDistToPlayer < 40.0f) && + (ABS(pthis->actor.yDistToPlayer) < 50.0f)) { + if (func_800354B4(globalCtx, &pthis->actor, 100.0f, 0x2710, 0x4000, pthis->actor.shape.rot.y)) { + if (player->swordAnimation == 0x11) { + EnGeldB_SetupSpinDodge(pthis, globalCtx); + } else if (globalCtx->gameplayFrames & 1) { + EnGeldB_SetupBlock(pthis); + } else { + EnGeldB_SetupRollBack(pthis); + } + } else { + angleFacingLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + ((globalCtx->gameplayFrames & 1) || (ABS(angleFacingLink) < 0x38E0))) { + EnGeldB_SetupSlash(pthis); + } else { + EnGeldB_SetupCircle(pthis); + } + } + } else { + EnGeldB_SetupCircle(pthis); + } + } else if ((pthis->timer == 0) && + func_800354B4(globalCtx, &pthis->actor, 100.0f, 0x2710, 0x4000, pthis->actor.shape.rot.y)) { + if (player->swordAnimation == 0x11) { + EnGeldB_SetupSpinDodge(pthis, globalCtx); + } else if (!EnGeldB_DodgeRanged(globalCtx, pthis)) { + if ((globalCtx->gameplayFrames & 1)) { + if ((pthis->actor.xzDistToPlayer < 100.0f) && (Rand_ZeroOne() > 0.7f)) { + EnGeldB_SetupJump(pthis); + } else { + EnGeldB_SetupRollBack(pthis); + } + } else { + EnGeldB_SetupBlock(pthis); + } + } + } +} + +void EnGeldB_SetupSidestep(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 linkAngle; + Player* player; + f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); + + Animation_Change(&pthis->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); + player = GET_PLAYER(globalCtx); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + linkAngle = player->actor.shape.rot.y; + if (Math_SinS(linkAngle - pthis->actor.shape.rot.y) > 0.0f) { + pthis->actor.speedXZ = -6.0f; + } else if (Math_SinS(linkAngle - pthis->actor.shape.rot.y) < 0.0f) { + pthis->actor.speedXZ = 6.0f; + } else { + pthis->actor.speedXZ = Rand_CenteredFloat(12.0f); + } + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.5f; + pthis->approachRate = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + pthis->timer = Rand_ZeroOne() * 10.0f + 5.0f; + pthis->action = GELDB_SIDESTEP; + EnGeldB_SetupAction(pthis, EnGeldB_Sidestep); +} + +void EnGeldB_Sidestep(EnGeldB* pthis, GlobalContext* globalCtx) { + s16 behindLinkAngle; + s16 phi_v1; + Player* player = GET_PLAYER(globalCtx); + s32 thisKeyFrame; + s32 prevKeyFrame; + f32 playSpeed; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xBB8, 1); + behindLinkAngle = player->actor.shape.rot.y + 0x8000; + if (Math_SinS(behindLinkAngle - pthis->actor.shape.rot.y) > 0.0f) { + pthis->actor.speedXZ += 0.125f; + } else if (Math_SinS(behindLinkAngle - pthis->actor.shape.rot.y) <= 0.0f) { + pthis->actor.speedXZ -= 0.125f; + } + + if ((pthis->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.shape.rot.y + 0x3E80)) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + phi_v1 = pthis->actor.shape.rot.y + 0x3E80; + } else { + phi_v1 = pthis->actor.shape.rot.y - 0x3E80; + } + phi_v1 = pthis->actor.wallYaw - phi_v1; + } else { + pthis->actor.speedXZ *= -0.8f; + phi_v1 = 0; + } + if (ABS(phi_v1) > 0x4000) { + pthis->actor.speedXZ *= -0.8f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ += 0.5f; + } + } + } + if (pthis->actor.speedXZ >= 0.0f) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3E80; + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y - 0x3E80; + } + if (pthis->actor.xzDistToPlayer <= 45.0f) { + Math_SmoothStepToF(&pthis->approachRate, -4.0f, 1.0f, 1.5f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > 40.0f) { + Math_SmoothStepToF(&pthis->approachRate, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->approachRate, 0.0f, 1.0f, 6.65f, 0.0f); + } + if (pthis->approachRate != 0.0f) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->approachRate; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->approachRate; + } + if (ABS(pthis->approachRate) < ABS(pthis->actor.speedXZ)) { + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.5f; + } else { + pthis->skelAnime.playSpeed = -pthis->approachRate * 0.5f; + } + pthis->skelAnime.playSpeed = CLAMP(pthis->skelAnime.playSpeed, -3.0f, 3.0f); + thisKeyFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + prevKeyFrame = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + + playSpeed = ((void)0, ABS(pthis->skelAnime.playSpeed)); // Needed to match for some reason + + if (!EnGeldB_DodgeRanged(globalCtx, pthis) && !EnGeldB_ReactToPlayer(globalCtx, pthis, 0)) { + if (--pthis->timer == 0) { + s16 angleFacingPlayer = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + angleFacingPlayer = ABS(angleFacingPlayer); + if (angleFacingPlayer >= 0x3A98) { + EnGeldB_SetupReady(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 1.0f; + } else { + Player* player2 = GET_PLAYER(globalCtx); + s16 angleFacingPlayer2 = player2->actor.shape.rot.y - pthis->actor.shape.rot.y; + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if ((pthis->actor.xzDistToPlayer <= 45.0f) && !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (!(globalCtx->gameplayFrames & 3) || (ABS(angleFacingPlayer2) < 0x38E0))) { + EnGeldB_SetupSlash(pthis); + } else if ((210.0f > pthis->actor.xzDistToPlayer) && (pthis->actor.xzDistToPlayer > 150.0f) && + !(globalCtx->gameplayFrames & 1)) { + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor) || (Rand_ZeroOne() > 0.5f) || + (ABS(angleFacingPlayer2) < 0x38E0)) { + EnGeldB_SetupRollForward(pthis); + } else { + EnGeldB_SetupSpinAttack(pthis); + } + } else { + EnGeldB_SetupAdvance(pthis, globalCtx); + } + } + } + if ((thisKeyFrame != (s32)pthis->skelAnime.curFrame) && + (((prevKeyFrame < 0) && (((s32)playSpeed + thisKeyFrame) > 0)) || + ((prevKeyFrame < 5) && (((s32)playSpeed + thisKeyFrame) > 5)))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_LAND); + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_BREATH); + } + } +} + +void EnGeldB_SetupDefeated(EnGeldB* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gGerudoRedDefeatAnim, -4.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + if (pthis->actor.bgCheckFlags & 1) { + pthis->invisible = false; + pthis->actor.speedXZ = -6.0f; + } else { + pthis->invisible = true; + } + pthis->action = GELDB_DEFEAT; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GERUDOFT_DEAD); + EnGeldB_SetupAction(pthis, EnGeldB_Defeated); +} + +void EnGeldB_Defeated(EnGeldB* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + if (pthis->actor.bgCheckFlags & 1) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + pthis->invisible = false; + } + if (SkelAnime_Update(&pthis->skelAnime)) { + EnGeldB_SetupFlee(pthis); + } else if ((s32)pthis->skelAnime.curFrame == 10) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + func_800F5B58(); + } +} + +void EnGeldB_TurnHead(EnGeldB* pthis, GlobalContext* globalCtx) { + if ((pthis->action == GELDB_READY) && (pthis->lookTimer != 0)) { + pthis->headRot.y = Math_SinS(pthis->lookTimer * 0x1068) * 8920.0f; + } else if (pthis->action != GELDB_STUNNED) { + if ((pthis->action != GELDB_SLASH) && (pthis->action != GELDB_SPIN_ATTACK)) { + Math_SmoothStepToS(&pthis->headRot.y, pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y, 1, 0x1F4, 0); + pthis->headRot.y = CLAMP(pthis->headRot.y, -0x256F, 0x256F); + } else { + pthis->headRot.y = 0; + } + } +} + +void EnGeldB_CollisionCheck(EnGeldB* pthis, GlobalContext* globalCtx) { + s32 pad; + EnItem00* key; + + if (pthis->blockCollider.base.acFlags & AC_BOUNCED) { + pthis->blockCollider.base.acFlags &= ~AC_BOUNCED; + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + } else if ((pthis->bodyCollider.base.acFlags & AC_HIT) && (pthis->action >= GELDB_READY) && + (pthis->spinAttackState < 2)) { + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != GELDB_DMG_UNK_6) { + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->actor, &pthis->bodyCollider.info, 1); + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_GERUDOFT_BREATH); + if ((pthis->actor.colChkInfo.damageEffect == GELDB_DMG_STUN) || + (pthis->actor.colChkInfo.damageEffect == GELDB_DMG_FREEZE)) { + if (pthis->action != GELDB_STUNNED) { + Actor_SetColorFilter(&pthis->actor, 0, 0x78, 0, 0x50); + Actor_ApplyDamage(&pthis->actor); + EnGeldB_SetupStunned(pthis); + } + } else { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + if (Actor_ApplyDamage(&pthis->actor) == 0) { + if (pthis->keyFlag != 0) { + key = Item_DropCollectible(globalCtx, &pthis->actor.world.pos, pthis->keyFlag | ITEM00_SMALL_KEY); + if (key != NULL) { + key->actor.world.rot.y = Math_Vec3f_Yaw(&key->actor.world.pos, &pthis->actor.home.pos); + key->actor.speedXZ = 6.0f; + Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + EnGeldB_SetupDefeated(pthis); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else { + EnGeldB_SetupDamaged(pthis); + } + } + } + } +} + +void EnGeldB_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGeldB* pthis = (EnGeldB*)thisx; + + EnGeldB_CollisionCheck(pthis, globalCtx); + if (pthis->actor.colChkInfo.damageEffect != GELDB_DMG_UNK_6) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 15.0f, 30.0f, 60.0f, 0x1D); + pthis->actionFunc(pthis, globalCtx); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 40.0f; + EnGeldB_TurnHead(pthis, globalCtx); + } + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + if ((pthis->action >= GELDB_READY) && (pthis->spinAttackState < 2) && + ((pthis->actor.colorFilterTimer == 0) || !(pthis->actor.colorFilterParams & 0x4000))) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + if ((pthis->action == GELDB_BLOCK) && (pthis->skelAnime.curFrame == 0.0f)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->blockCollider.base); + } + if (pthis->swordState > 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->swordCollider.base); + } + if (pthis->blinkState == 0) { + if ((Rand_ZeroOne() < 0.1f) && ((globalCtx->gameplayFrames % 4) == 0)) { + pthis->blinkState++; + } + } else { + pthis->blinkState = (pthis->blinkState + 1) & 3; + } +} + +s32 EnGeldB_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnGeldB* pthis = (EnGeldB*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2507); + if (limbIndex == GELDB_LIMB_NECK) { + rot->z += pthis->headRot.x; + rot->x += pthis->headRot.y; + rot->y += pthis->headRot.z; + } else if (limbIndex == GELDB_LIMB_HEAD) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 80, 60, 10, 255); + } else if ((limbIndex == GELDB_LIMB_R_SWORD) || (limbIndex == GELDB_LIMB_L_SWORD)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 140, 170, 230, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + } else { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 140, 0, 0, 255); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2529); + return false; +} + +void EnGeldB_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f footOffset = { 300.0f, 0.0f, 0.0f }; + static Vec3f swordTipOffset = { 0.0f, -3000.0f, 0.0f }; + static Vec3f swordHiltOffset = { 400.0f, 0.0f, 0.0f }; + static Vec3f swordQuadOffset1 = { 1600.0f, -4000.0f, 0.0f }; + static Vec3f swordQuadOffset0 = { -3000.0f, -2000.0f, 1300.0f }; + static Vec3f swordQuadOffset3 = { -3000.0f, -2000.0f, -1300.0f }; + static Vec3f swordQuadOffset2 = { 1000.0f, 1000.0f, 0.0f }; + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f swordTip; + Vec3f swordHilt; + EnGeldB* pthis = (EnGeldB*)thisx; + s32 bodyPart = -1; + + if (limbIndex == GELDB_LIMB_R_SWORD) { + Matrix_MultVec3f(&swordQuadOffset1, &pthis->swordCollider.dim.quad[1]); + Matrix_MultVec3f(&swordQuadOffset0, &pthis->swordCollider.dim.quad[0]); + Matrix_MultVec3f(&swordQuadOffset3, &pthis->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&swordQuadOffset2, &pthis->swordCollider.dim.quad[2]); + Collider_SetQuadVertices(&pthis->swordCollider, &pthis->swordCollider.dim.quad[0], + &pthis->swordCollider.dim.quad[1], &pthis->swordCollider.dim.quad[2], + &pthis->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&swordTipOffset, &swordTip); + Matrix_MultVec3f(&swordHiltOffset, &swordHilt); + + if ((pthis->swordState < 0) || ((pthis->action != GELDB_SLASH) && (pthis->action != GELDB_SPIN_ATTACK))) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIndex)); + pthis->swordState = 0; + } else if (pthis->swordState > 0) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIndex), &swordTip, &swordHilt); + } + } else { + Actor_SetFeetPos(&pthis->actor, limbIndex, GELDB_LIMB_L_FOOT, &footOffset, GELDB_LIMB_R_FOOT, &footOffset); + } + + if (limbIndex == GELDB_LIMB_L_FOOT) { + Matrix_MultVec3f(&footOffset, &pthis->leftFootPos); + } else if (limbIndex == GELDB_LIMB_R_FOOT) { + Matrix_MultVec3f(&footOffset, &pthis->rightFootPos); + } + + if (pthis->iceTimer != 0) { + switch (limbIndex) { + case GELDB_LIMB_NECK: + bodyPart = 0; + break; + case GELDB_LIMB_L_SWORD: + bodyPart = 1; + break; + case GELDB_LIMB_R_SWORD: + bodyPart = 2; + break; + case GELDB_LIMB_L_UPPER_ARM: + bodyPart = 3; + break; + case GELDB_LIMB_R_UPPER_ARM: + bodyPart = 4; + break; + case GELDB_LIMB_TORSO: + bodyPart = 5; + break; + case GELDB_LIMB_WAIST: + bodyPart = 6; + break; + case GELDB_LIMB_L_FOOT: + bodyPart = 7; + break; + case GELDB_LIMB_R_FOOT: + bodyPart = 8; + break; + default: + break; + } + + if (bodyPart >= 0) { + Vec3f limbPos; + + Matrix_MultVec3f(&zeroVec, &limbPos); + pthis->bodyPartsPos[bodyPart].x = limbPos.x; + pthis->bodyPartsPos[bodyPart].y = limbPos.y; + pthis->bodyPartsPos[bodyPart].z = limbPos.z; + } + } +} + +void EnGeldB_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f blockTrisOffsets0[3] = { + { -3000.0f, 6000.0f, 1600.0f }, + { -3000.0f, 0.0f, 1600.0f }, + { 3000.0f, 6000.0f, 1600.0f }, + }; + static Vec3f blockTrisOffsets1[3] = { + { -3000.0f, 0.0f, 1600.0f }, + { 3000.0f, 0.0f, 1600.0f }, + { 3000.0f, 6000.0f, 1600.0f }, + }; + static void* eyeTextures[] = { gGerudoRedEyeOpenTex, gGerudoRedEyeHalfTex, gGerudoRedEyeShutTex, + gGerudoRedEyeHalfTex }; + s32 pad; + EnGeldB* pthis = (EnGeldB*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2672); + if (1) {} + + if ((pthis->spinAttackState >= 2) && SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->spinAttackState == 2) { + Animation_Change(&pthis->skelAnime, &gGerudoRedSpinAttackAnim, 0.5f, 0.0f, 12.0f, ANIMMODE_ONCE_INTERP, + 4.0f); + pthis->spinAttackState++; + thisx->world.rot.y = thisx->shape.rot.y = thisx->yawTowardsPlayer; + } else { + pthis->timer--; + if (pthis->timer == 0) { + if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { + globalCtx->nextEntranceIndex = 0x1A5; + } else if (gSaveContext.eventChkInf[12] & 0x80) { + globalCtx->nextEntranceIndex = 0x5F8; + } else { + globalCtx->nextEntranceIndex = 0x3B4; + } + globalCtx->fadeTransition = 0x26; + globalCtx->sceneLoadFlag = 0x14; + } + } + } + + if ((pthis->action != GELDB_WAIT) || !pthis->invisible) { + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->blinkState])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnGeldB_OverrideLimbDraw, EnGeldB_PostLimbDraw, pthis); + if (pthis->action == GELDB_BLOCK) { + s32 i; + Vec3f blockTrisVtx0[3]; + Vec3f blockTrisVtx1[3]; + + for (i = 0; i < 3; i++) { + Matrix_MultVec3f(&blockTrisOffsets0[i], &blockTrisVtx0[i]); + Matrix_MultVec3f(&blockTrisOffsets1[i], &blockTrisVtx1[i]); + } + Collider_SetTrisVertices(&pthis->blockCollider, 0, &blockTrisVtx0[0], &blockTrisVtx0[1], &blockTrisVtx0[2]); + Collider_SetTrisVertices(&pthis->blockCollider, 1, &blockTrisVtx1[0], &blockTrisVtx1[1], &blockTrisVtx1[2]); + } + + if (pthis->iceTimer != 0) { + thisx->colorFilterTimer++; + pthis->iceTimer--; + if ((pthis->iceTimer % 4) == 0) { + s32 iceIndex = pthis->iceTimer >> 2; + + EffectSsEnIce_SpawnFlyingVec3s(globalCtx, thisx, &pthis->bodyPartsPos[iceIndex], 150, 150, 150, 250, 235, + 245, 255, 1.5f); + } + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_geldB.c", 2744); +} + +s32 EnGeldB_DodgeRanged(GlobalContext* globalCtx, EnGeldB* pthis) { + Actor* actor = Actor_GetProjectileActor(globalCtx, &pthis->actor, 800.0f); + + if (actor != NULL) { + s16 angleToFacing; + s16 pad18; + f32 dist; + + angleToFacing = Actor_WorldYawTowardActor(&pthis->actor, actor) - pthis->actor.shape.rot.y; + pthis->actor.world.rot.y = (u16)pthis->actor.shape.rot.y & 0xFFFF; + dist = Actor_WorldDistXYZToPoint(&pthis->actor, &actor->world.pos); + //! @bug + // Actor_WorldDistXYZToPoint already sqrtfs the distance, so pthis actually checks for a + // distance of 360000. Also it's a double calculation because no f on sqrt. + if ((ABS(angleToFacing) < 0x2EE0) && (sqrt(dist) < 600.0)) { + if (actor->id == ACTOR_ARMS_HOOK) { + EnGeldB_SetupJump(pthis); + } else { + EnGeldB_SetupBlock(pthis); + } + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + if ((ABS(angleToFacing) < 0x2000) || (ABS(angleToFacing) > 0x5FFF)) { + EnGeldB_SetupSidestep(pthis, globalCtx); + pthis->actor.speedXZ *= 3.0f; + } else if (ABS(angleToFacing) < 0x5FFF) { + EnGeldB_SetupRollBack(pthis); + } + } + return true; + } + return false; +} diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.cpp similarity index 72% rename from src/overlays/actors/ovl_En_GirlA/z_en_girla.c rename to src/overlays/actors/ovl_En_GirlA/z_en_girla.cpp index 25c81218f..4a74f8b96 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.cpp @@ -24,61 +24,61 @@ void EnGirlA_Init(Actor* thisx, GlobalContext* globalCtx); void EnGirlA_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGirlA_SetItemOutOfStock(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_UpdateStockedItem(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_InitializeItemAction(EnGirlA* this, GlobalContext* globalCtx); -void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx); +void EnGirlA_SetItemOutOfStock(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_UpdateStockedItem(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_InitializeItemAction(EnGirlA* pthis, GlobalContext* globalCtx); +void EnGirlA_Update2(EnGirlA* pthis, GlobalContext* globalCtx); void func_80A3C498(Actor* thisx, GlobalContext* globalCtx, s32 flags); void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 EnGirlA_CanBuy_Arrows(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Bombs(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_DekuNuts(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_DekuSticks(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Fish(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_RedPotion(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_GreenPotion(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_BluePotion(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Longsword(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_HylianShield(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_DekuShield(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_GoronTunic(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Health(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_MilkBottle(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_WeirdEgg(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Unk19(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Unk20(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Bombchus(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_DekuSeeds(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_SoldOut(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_BlueFire(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Bugs(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Poe(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuy_Fairy(GlobalContext* globalCtx, EnGirlA* this); +s32 EnGirlA_CanBuy_Arrows(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Bombs(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_DekuNuts(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_DekuSticks(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Fish(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_RedPotion(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_GreenPotion(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_BluePotion(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Longsword(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_HylianShield(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_DekuShield(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_GoronTunic(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_ZoraTunic(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Health(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_MilkBottle(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_WeirdEgg(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Unk19(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Unk20(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Bombchus(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_DekuSeeds(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_SoldOut(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_BlueFire(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Bugs(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Poe(GlobalContext* globalCtx, EnGirlA* pthis); +s32 EnGirlA_CanBuy_Fairy(GlobalContext* globalCtx, EnGirlA* pthis); -void EnGirlA_ItemGive_DekuNuts(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_Arrows(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_Bombs(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_DekuSticks(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_BottledItem(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_Longsword(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_HylianShield(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_DekuShield(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_GoronTunic(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_Health(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_MilkBottle(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_WeirdEgg(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_Unk19(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_Unk20(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_ItemGive_DekuSeeds(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyEvent_ShieldDiscount(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyEvent_ObtainBombchuPack(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyEvent_GoronTunic(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyEvent_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this); +void EnGirlA_ItemGive_DekuNuts(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_Arrows(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_Bombs(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_DekuSticks(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_BottledItem(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_Longsword(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_HylianShield(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_DekuShield(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_GoronTunic(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_ZoraTunic(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_Health(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_MilkBottle(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_WeirdEgg(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_Unk19(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_Unk20(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_ItemGive_DekuSeeds(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_BuyEvent_ShieldDiscount(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_BuyEvent_ObtainBombchuPack(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_BuyEvent_GoronTunic(GlobalContext* globalCtx, EnGirlA* pthis); +void EnGirlA_BuyEvent_ZoraTunic(GlobalContext* globalCtx, EnGirlA* pthis); -const ActorInit En_GirlA_InitVars = { +ActorInit En_GirlA_InitVars = { ACTOR_EN_GIRLA, ACTORCAT_PROP, FLAGS, @@ -90,7 +90,7 @@ const ActorInit En_GirlA_InitVars = { NULL, }; -static char* sShopItemDescriptions[] = { +static const char* sShopItemDescriptions[] = { "デクの実×5 ", // "Deku nut x5" "矢×30 ", // "Arrow x30" "矢×50 ", // "Arrow x50" @@ -320,63 +320,63 @@ static ShopItemEntry shopItemEntries[] = { // Defines the Hylian Shield discount amount static s16 sShieldDiscounts[] = { 5, 10, 15, 20, 25, 30, 35, 40 }; -void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc func) { - this->actionFunc = func; +void EnGirlA_SetupAction(EnGirlA* pthis, EnGirlAActionFunc func) { + pthis->actionFunc = func; } -s32 EnGirlA_TryChangeShopItem(EnGirlA* this) { - switch (this->actor.params) { +s32 EnGirlA_TryChangeShopItem(EnGirlA* pthis) { + switch (pthis->actor.params) { case SI_MILK_BOTTLE: if (gSaveContext.itemGetInf[0] & 0x4) { - this->actor.params = SI_HEART; + pthis->actor.params = SI_HEART; return true; } break; case SI_BOMBCHU_10_2: if (gSaveContext.itemGetInf[0] & 0x40) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_10_3: if (gSaveContext.itemGetInf[0] & 0x80) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_20_3: if (gSaveContext.itemGetInf[0] & 0x100) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_20_4: if (gSaveContext.itemGetInf[0] & 0x200) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_10_4: if (gSaveContext.itemGetInf[0] & 0x400) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_10_1: if (gSaveContext.itemGetInf[0] & 0x8) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_20_1: if (gSaveContext.itemGetInf[0] & 0x10) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; case SI_BOMBCHU_20_2: if (gSaveContext.itemGetInf[0] & 0x20) { - this->actor.params = SI_SOLD_OUT; + pthis->actor.params = SI_SOLD_OUT; return true; } break; @@ -384,24 +384,24 @@ s32 EnGirlA_TryChangeShopItem(EnGirlA* this) { return false; } -void EnGirlA_InitItem(EnGirlA* this, GlobalContext* globalCtx) { - s16 params = this->actor.params; +void EnGirlA_InitItem(EnGirlA* pthis, GlobalContext* globalCtx) { + s16 params = pthis->actor.params; osSyncPrintf("%s(%2d)初期設定\n", sShopItemDescriptions[params], params); if ((params >= SI_MAX) && (params < 0)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); osSyncPrintf(VT_COL(RED, WHITE)); - osSyncPrintf("引数がおかしいよ(arg_data=%d)!!\n", this->actor.params); + osSyncPrintf("引数がおかしいよ(arg_data=%d)!!\n", pthis->actor.params); osSyncPrintf(VT_RST); ASSERT(0, "0", "../z_en_girlA.c", 1421); return; } - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, shopItemEntries[params].objID); + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, shopItemEntries[params].objID); - if (this->objBankIndex < 0) { - Actor_Kill(&this->actor); + if (pthis->objBankIndex < 0) { + Actor_Kill(&pthis->actor); osSyncPrintf(VT_COL(RED, WHITE)); osSyncPrintf("バンクが無いよ!!(%s)\n", sShopItemDescriptions[params]); osSyncPrintf(VT_RST); @@ -409,57 +409,57 @@ void EnGirlA_InitItem(EnGirlA* this, GlobalContext* globalCtx) { return; } - this->actor.params = params; - this->actionFunc2 = EnGirlA_InitializeItemAction; + pthis->actor.params = params; + pthis->actionFunc2 = EnGirlA_InitializeItemAction; } void EnGirlA_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGirlA* this = (EnGirlA*)thisx; + EnGirlA* pthis = (EnGirlA*)thisx; - EnGirlA_TryChangeShopItem(this); - EnGirlA_InitItem(this, globalCtx); - osSyncPrintf("%s(%2d)初期設定\n", sShopItemDescriptions[this->actor.params], this->actor.params); + EnGirlA_TryChangeShopItem(pthis); + EnGirlA_InitItem(pthis, globalCtx); + osSyncPrintf("%s(%2d)初期設定\n", sShopItemDescriptions[pthis->actor.params], pthis->actor.params); } void EnGirlA_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGirlA* this = (EnGirlA*)thisx; + EnGirlA* pthis = (EnGirlA*)thisx; - if (this->isInitialized) { - SkelAnime_Free(&this->skelAnime, globalCtx); + if (pthis->isInitialized) { + SkelAnime_Free(&pthis->skelAnime, globalCtx); } } -s32 EnGirlA_CanBuy_Arrows(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Arrows(GlobalContext* globalCtx, EnGirlA* pthis) { if (Item_CheckObtainability(ITEM_BOW) == ITEM_NONE) { return CANBUY_RESULT_CANT_GET_NOW_5; } if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Bombs(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Bombs(GlobalContext* globalCtx, EnGirlA* pthis) { if (!CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { return CANBUY_RESULT_CANT_GET_NOW; } if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_DekuNuts(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_DekuNuts(GlobalContext* globalCtx, EnGirlA* pthis) { if ((CUR_CAPACITY(UPG_NUTS) != 0) && (AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS))) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) { @@ -468,11 +468,11 @@ s32 EnGirlA_CanBuy_DekuNuts(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_DekuSticks(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_DekuSticks(GlobalContext* globalCtx, EnGirlA* pthis) { if ((CUR_CAPACITY(UPG_STICKS) != 0) && (AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS))) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) { @@ -481,11 +481,11 @@ s32 EnGirlA_CanBuy_DekuSticks(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Fish(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Fish(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_FISH) == ITEM_NONE) { @@ -494,11 +494,11 @@ s32 EnGirlA_CanBuy_Fish(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_RedPotion(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_RedPotion(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_POTION_RED) == ITEM_NONE) { @@ -507,11 +507,11 @@ s32 EnGirlA_CanBuy_RedPotion(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_GreenPotion(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_GreenPotion(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_POTION_GREEN) == ITEM_NONE) { @@ -520,11 +520,11 @@ s32 EnGirlA_CanBuy_GreenPotion(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_BluePotion(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_BluePotion(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_POTION_BLUE) == ITEM_NONE) { @@ -533,11 +533,11 @@ s32 EnGirlA_CanBuy_BluePotion(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Longsword(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Longsword(GlobalContext* globalCtx, EnGirlA* pthis) { if ((gBitFlags[2] & gSaveContext.inventory.equipment) && !(gBitFlags[3] & gSaveContext.inventory.equipment)) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_SWORD_BGS) == ITEM_NONE) { @@ -546,11 +546,11 @@ s32 EnGirlA_CanBuy_Longsword(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_HylianShield(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_HylianShield(GlobalContext* globalCtx, EnGirlA* pthis) { if (gBitFlags[5] & gSaveContext.inventory.equipment) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_SHIELD_HYLIAN) == ITEM_NONE) { @@ -559,11 +559,11 @@ s32 EnGirlA_CanBuy_HylianShield(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_DekuShield(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_DekuShield(GlobalContext* globalCtx, EnGirlA* pthis) { if (gBitFlags[4] & gSaveContext.inventory.equipment) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_SHIELD_DEKU) == ITEM_NONE) { @@ -572,14 +572,14 @@ s32 EnGirlA_CanBuy_DekuShield(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_GoronTunic(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_GoronTunic(GlobalContext* globalCtx, EnGirlA* pthis) { if (LINK_AGE_IN_YEARS == YEARS_CHILD) { return CANBUY_RESULT_CANT_GET_NOW; } if (gBitFlags[9] & gSaveContext.inventory.equipment) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_TUNIC_GORON) == ITEM_NONE) { @@ -588,14 +588,14 @@ s32 EnGirlA_CanBuy_GoronTunic(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_ZoraTunic(GlobalContext* globalCtx, EnGirlA* pthis) { if (LINK_AGE_IN_YEARS == YEARS_CHILD) { return CANBUY_RESULT_CANT_GET_NOW; } if (gBitFlags[10] & gSaveContext.inventory.equipment) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_TUNIC_ZORA) == ITEM_NONE) { @@ -604,18 +604,18 @@ s32 EnGirlA_CanBuy_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Health(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Health(GlobalContext* globalCtx, EnGirlA* pthis) { if (gSaveContext.healthCapacity == gSaveContext.health) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_MilkBottle(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < this->basePrice) { +s32 EnGirlA_CanBuy_MilkBottle(GlobalContext* globalCtx, EnGirlA* pthis) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_MILK_BOTTLE) == ITEM_NONE) { @@ -624,8 +624,8 @@ s32 EnGirlA_CanBuy_MilkBottle(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_WeirdEgg(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < this->basePrice) { +s32 EnGirlA_CanBuy_WeirdEgg(GlobalContext* globalCtx, EnGirlA* pthis) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_LETTER_ZELDA) == ITEM_NONE) { @@ -634,19 +634,19 @@ s32 EnGirlA_CanBuy_WeirdEgg(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Unk19(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Unk19(GlobalContext* globalCtx, EnGirlA* pthis) { return CANBUY_RESULT_NEED_RUPEES; } -s32 EnGirlA_CanBuy_Unk20(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Unk20(GlobalContext* globalCtx, EnGirlA* pthis) { return CANBUY_RESULT_NEED_RUPEES; } -s32 EnGirlA_CanBuy_Bombchus(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Bombchus(GlobalContext* globalCtx, EnGirlA* pthis) { if (AMMO(ITEM_BOMBCHU) >= 50) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_BOMBCHU) == ITEM_NONE) { @@ -655,11 +655,11 @@ s32 EnGirlA_CanBuy_Bombchus(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_DekuSeeds(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_DekuSeeds(GlobalContext* globalCtx, EnGirlA* pthis) { if (AMMO(ITEM_SLINGSHOT) >= CUR_CAPACITY(UPG_BULLET_BAG)) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_SEEDS) == ITEM_NONE) { @@ -668,15 +668,15 @@ s32 EnGirlA_CanBuy_DekuSeeds(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_SoldOut(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_SoldOut(GlobalContext* globalCtx, EnGirlA* pthis) { return CANBUY_RESULT_CANT_GET_NOW_5; } -s32 EnGirlA_CanBuy_BlueFire(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_BlueFire(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_BLUE_FIRE) == ITEM_NONE) { @@ -685,11 +685,11 @@ s32 EnGirlA_CanBuy_BlueFire(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Bugs(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Bugs(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_BUG) == ITEM_NONE) { @@ -698,11 +698,11 @@ s32 EnGirlA_CanBuy_Bugs(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Poe(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Poe(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_POE) == ITEM_NONE) { @@ -711,11 +711,11 @@ s32 EnGirlA_CanBuy_Poe(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -s32 EnGirlA_CanBuy_Fairy(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuy_Fairy(GlobalContext* globalCtx, EnGirlA* pthis) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_BOTTLE; } - if (gSaveContext.rupees < this->basePrice) { + if (gSaveContext.rupees < pthis->basePrice) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_FAIRY) == ITEM_NONE) { @@ -724,13 +724,13 @@ s32 EnGirlA_CanBuy_Fairy(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS; } -void EnGirlA_ItemGive_Arrows(GlobalContext* globalCtx, EnGirlA* this) { - Inventory_ChangeAmmo(ITEM_BOW, this->itemCount); - Rupees_ChangeBy(-this->basePrice); +void EnGirlA_ItemGive_Arrows(GlobalContext* globalCtx, EnGirlA* pthis) { + Inventory_ChangeAmmo(ITEM_BOW, pthis->itemCount); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_Bombs(GlobalContext* globalCtx, EnGirlA* this) { - switch (this->itemCount) { +void EnGirlA_ItemGive_Bombs(GlobalContext* globalCtx, EnGirlA* pthis) { + switch (pthis->itemCount) { case 5: Item_Give(globalCtx, ITEM_BOMBS_5); break; @@ -744,11 +744,11 @@ void EnGirlA_ItemGive_Bombs(GlobalContext* globalCtx, EnGirlA* this) { Item_Give(globalCtx, ITEM_BOMBS_30); break; } - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_DekuNuts(GlobalContext* globalCtx, EnGirlA* this) { - switch (this->itemCount) { +void EnGirlA_ItemGive_DekuNuts(GlobalContext* globalCtx, EnGirlA* pthis) { + switch (pthis->itemCount) { case 5: Item_Give(globalCtx, ITEM_NUTS_5); break; @@ -756,70 +756,70 @@ void EnGirlA_ItemGive_DekuNuts(GlobalContext* globalCtx, EnGirlA* this) { Item_Give(globalCtx, ITEM_NUTS_10); break; } - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_DekuSticks(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_DekuSticks(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_STICK); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_Longsword(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_Longsword(GlobalContext* globalCtx, EnGirlA* pthis) { func_800849EC(globalCtx); gSaveContext.swordHealth = 8; - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_HylianShield(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_HylianShield(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_SHIELD_HYLIAN); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_DekuShield(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_DekuShield(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_SHIELD_DEKU); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_GoronTunic(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_GoronTunic(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_TUNIC_GORON); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_ZoraTunic(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_TUNIC_ZORA); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_Health(GlobalContext* globalCtx, EnGirlA* this) { - Health_ChangeBy(globalCtx, this->itemCount); - Rupees_ChangeBy(-this->basePrice); +void EnGirlA_ItemGive_Health(GlobalContext* globalCtx, EnGirlA* pthis) { + Health_ChangeBy(globalCtx, pthis->itemCount); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_MilkBottle(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_MilkBottle(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_MILK_BOTTLE); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_WeirdEgg(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_WeirdEgg(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_WEIRD_EGG); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_Unk19(GlobalContext* globalCtx, EnGirlA* this) { - Rupees_ChangeBy(-this->basePrice); +void EnGirlA_ItemGive_Unk19(GlobalContext* globalCtx, EnGirlA* pthis) { + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_Unk20(GlobalContext* globalCtx, EnGirlA* this) { - Rupees_ChangeBy(-this->basePrice); +void EnGirlA_ItemGive_Unk20(GlobalContext* globalCtx, EnGirlA* pthis) { + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_DekuSeeds(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_ItemGive_DekuSeeds(GlobalContext* globalCtx, EnGirlA* pthis) { Item_Give(globalCtx, ITEM_SEEDS_30); - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_ItemGive_BottledItem(GlobalContext* globalCtx, EnGirlA* this) { - switch (this->actor.params) { +void EnGirlA_ItemGive_BottledItem(GlobalContext* globalCtx, EnGirlA* pthis) { + switch (pthis->actor.params) { case SI_FISH: Item_Give(globalCtx, ITEM_FISH); break; @@ -848,29 +848,29 @@ void EnGirlA_ItemGive_BottledItem(GlobalContext* globalCtx, EnGirlA* this) { Item_Give(globalCtx, ITEM_FAIRY); break; } - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_BuyEvent_ShieldDiscount(GlobalContext* globalCtx, EnGirlA* this) { - if (this->actor.params == SI_HYLIAN_SHIELD) { +void EnGirlA_BuyEvent_ShieldDiscount(GlobalContext* globalCtx, EnGirlA* pthis) { + if (pthis->actor.params == SI_HYLIAN_SHIELD) { if (gSaveContext.infTable[7] & 0x40) { - Rupees_ChangeBy(-(this->basePrice - sShieldDiscounts[(s32)Rand_ZeroFloat(7.9f)])); + Rupees_ChangeBy(-(pthis->basePrice - sShieldDiscounts[(s32)Rand_ZeroFloat(7.9f)])); return; } } - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_BuyEvent_GoronTunic(GlobalContext* globalCtx, EnGirlA* this) { - Rupees_ChangeBy(-this->basePrice); +void EnGirlA_BuyEvent_GoronTunic(GlobalContext* globalCtx, EnGirlA* pthis) { + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_BuyEvent_ZoraTunic(GlobalContext* globalCtx, EnGirlA* this) { - Rupees_ChangeBy(-this->basePrice); +void EnGirlA_BuyEvent_ZoraTunic(GlobalContext* globalCtx, EnGirlA* pthis) { + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_BuyEvent_ObtainBombchuPack(GlobalContext* globalCtx, EnGirlA* this) { - switch (this->actor.params) { +void EnGirlA_BuyEvent_ObtainBombchuPack(GlobalContext* globalCtx, EnGirlA* pthis) { + switch (pthis->actor.params) { case SI_BOMBCHU_10_2: gSaveContext.itemGetInf[0] |= 0x40; break; @@ -896,22 +896,22 @@ void EnGirlA_BuyEvent_ObtainBombchuPack(GlobalContext* globalCtx, EnGirlA* this) gSaveContext.itemGetInf[0] |= 0x20; break; } - Rupees_ChangeBy(-this->basePrice); + Rupees_ChangeBy(-pthis->basePrice); } -void EnGirlA_Noop(EnGirlA* this, GlobalContext* globalCtx) { +void EnGirlA_Noop(EnGirlA* pthis, GlobalContext* globalCtx) { } -void EnGirlA_SetItemDescription(GlobalContext* globalCtx, EnGirlA* this) { - ShopItemEntry* tmp = &shopItemEntries[this->actor.params]; - s32 params = this->actor.params; +void EnGirlA_SetItemDescription(GlobalContext* globalCtx, EnGirlA* pthis) { + ShopItemEntry* tmp = &shopItemEntries[pthis->actor.params]; + s32 params = pthis->actor.params; s32 maskId; s32 isMaskFreeToBorrow; - if ((this->actor.params >= SI_KEATON_MASK) && (this->actor.params <= SI_MASK_OF_TRUTH)) { - maskId = this->actor.params - SI_KEATON_MASK; + if ((pthis->actor.params >= SI_KEATON_MASK) && (pthis->actor.params <= SI_MASK_OF_TRUTH)) { + maskId = pthis->actor.params - SI_KEATON_MASK; isMaskFreeToBorrow = false; - switch (this->actor.params) { + switch (pthis->actor.params) { case SI_KEATON_MASK: if (gSaveContext.itemGetInf[3] & 0x100) { isMaskFreeToBorrow = true; @@ -939,170 +939,170 @@ void EnGirlA_SetItemDescription(GlobalContext* globalCtx, EnGirlA* this) { break; } if (isMaskFreeToBorrow) { - this->actor.textId = sMaskShopFreeToBorrowTextIds[maskId]; + pthis->actor.textId = sMaskShopFreeToBorrowTextIds[maskId]; } else { - this->actor.textId = tmp->itemDescTextId; + pthis->actor.textId = tmp->itemDescTextId; } } else { - this->actor.textId = tmp->itemDescTextId; + pthis->actor.textId = tmp->itemDescTextId; } - this->isInvisible = false; - this->actor.draw = EnGirlA_Draw; + pthis->isInvisible = false; + pthis->actor.draw = EnGirlA_Draw; } -void EnGirlA_SetItemOutOfStock(GlobalContext* globalCtx, EnGirlA* this) { - this->isInvisible = true; - this->actor.draw = NULL; - if ((this->actor.params >= SI_KEATON_MASK) && (this->actor.params <= SI_GERUDO_MASK)) { - this->actor.textId = 0xBD; +void EnGirlA_SetItemOutOfStock(GlobalContext* globalCtx, EnGirlA* pthis) { + pthis->isInvisible = true; + pthis->actor.draw = NULL; + if ((pthis->actor.params >= SI_KEATON_MASK) && (pthis->actor.params <= SI_GERUDO_MASK)) { + pthis->actor.textId = 0xBD; } } -void EnGirlA_UpdateStockedItem(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_UpdateStockedItem(GlobalContext* globalCtx, EnGirlA* pthis) { ShopItemEntry* itemEntry; - if (EnGirlA_TryChangeShopItem(this)) { - EnGirlA_InitItem(this, globalCtx); - itemEntry = &shopItemEntries[this->actor.params]; - this->actor.textId = itemEntry->itemDescTextId; + if (EnGirlA_TryChangeShopItem(pthis)) { + EnGirlA_InitItem(pthis, globalCtx); + itemEntry = &shopItemEntries[pthis->actor.params]; + pthis->actor.textId = itemEntry->itemDescTextId; } else { - this->isInvisible = false; - this->actor.draw = EnGirlA_Draw; + pthis->isInvisible = false; + pthis->actor.draw = EnGirlA_Draw; } } -s32 EnGirlA_TrySetMaskItemDescription(EnGirlA* this, GlobalContext* globalCtx) { +s32 EnGirlA_TrySetMaskItemDescription(EnGirlA* pthis, GlobalContext* globalCtx) { s32 params; - if ((this->actor.params >= SI_KEATON_MASK) && (this->actor.params <= SI_GERUDO_MASK)) { - params = this->actor.params - SI_KEATON_MASK; + if ((pthis->actor.params >= SI_KEATON_MASK) && (pthis->actor.params <= SI_GERUDO_MASK)) { + params = pthis->actor.params - SI_KEATON_MASK; if (INV_CONTENT(ITEM_TRADE_CHILD) == sMaskShopItems[params]) { - EnGirlA_SetItemOutOfStock(globalCtx, this); + EnGirlA_SetItemOutOfStock(globalCtx, pthis); } else { - EnGirlA_SetItemDescription(globalCtx, this); + EnGirlA_SetItemDescription(globalCtx, pthis); } return true; } return false; } -void EnGirlA_InitializeItemAction(EnGirlA* this, GlobalContext* globalCtx) { - s16 params = this->actor.params; +void EnGirlA_InitializeItemAction(EnGirlA* pthis, GlobalContext* globalCtx) { + s16 params = pthis->actor.params; ShopItemEntry* itemEntry = &shopItemEntries[params]; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->objBankIndex; - switch (this->actor.params) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.objBankIndex = pthis->objBankIndex; + switch (pthis->actor.params) { case SI_KEATON_MASK: if (gSaveContext.itemGetInf[3] & 0x100) { - this->actor.textId = 0x70B6; + pthis->actor.textId = 0x70B6; } else { - this->actor.textId = itemEntry->itemDescTextId; + pthis->actor.textId = itemEntry->itemDescTextId; } - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; case SI_SPOOKY_MASK: if (gSaveContext.itemGetInf[3] & 0x400) { - this->actor.textId = 0x70B5; + pthis->actor.textId = 0x70B5; } else { - this->actor.textId = itemEntry->itemDescTextId; + pthis->actor.textId = itemEntry->itemDescTextId; } - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; case SI_SKULL_MASK: if (gSaveContext.itemGetInf[3] & 0x200) { - this->actor.textId = 0x70B4; + pthis->actor.textId = 0x70B4; } else { - this->actor.textId = itemEntry->itemDescTextId; + pthis->actor.textId = itemEntry->itemDescTextId; } - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; case SI_BUNNY_HOOD: if (gSaveContext.itemGetInf[3] & 0x800) { - this->actor.textId = 0x70B7; + pthis->actor.textId = 0x70B7; } else { - this->actor.textId = itemEntry->itemDescTextId; + pthis->actor.textId = itemEntry->itemDescTextId; } - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; case SI_MASK_OF_TRUTH: if (gSaveContext.itemGetInf[3] & 0x800) { - this->actor.textId = 0x70BB; - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->actor.textId = 0x70BB; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; } else { - this->actor.textId = itemEntry->itemDescTextId; - this->itemBuyPromptTextId = 0xEB; + pthis->actor.textId = itemEntry->itemDescTextId; + pthis->itemBuyPromptTextId = 0xEB; } break; case SI_ZORA_MASK: - this->actor.textId = itemEntry->itemDescTextId; - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->actor.textId = itemEntry->itemDescTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; case SI_GORON_MASK: - this->actor.textId = itemEntry->itemDescTextId; - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->actor.textId = itemEntry->itemDescTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; case SI_GERUDO_MASK: - this->actor.textId = itemEntry->itemDescTextId; - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->actor.textId = itemEntry->itemDescTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; default: - this->actor.textId = itemEntry->itemDescTextId; - this->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; + pthis->actor.textId = itemEntry->itemDescTextId; + pthis->itemBuyPromptTextId = itemEntry->itemBuyPromptTextId; break; } - if (!EnGirlA_TrySetMaskItemDescription(this, globalCtx)) { - EnGirlA_SetItemDescription(globalCtx, this); + if (!EnGirlA_TrySetMaskItemDescription(pthis, globalCtx)) { + EnGirlA_SetItemDescription(globalCtx, pthis); } - this->setOutOfStockFunc = EnGirlA_SetItemOutOfStock; - this->updateStockedItemFunc = EnGirlA_UpdateStockedItem; - this->getItemId = itemEntry->getItemId; - this->canBuyFunc = itemEntry->canBuyFunc; - this->itemGiveFunc = itemEntry->itemGiveFunc; - this->buyEventFunc = itemEntry->buyEventFunc; - this->basePrice = itemEntry->price; - this->itemCount = itemEntry->count; - this->hiliteFunc = itemEntry->hiliteFunc; - this->giDrawId = itemEntry->giDrawId; + pthis->setOutOfStockFunc = EnGirlA_SetItemOutOfStock; + pthis->updateStockedItemFunc = EnGirlA_UpdateStockedItem; + pthis->getItemId = itemEntry->getItemId; + pthis->canBuyFunc = itemEntry->canBuyFunc; + pthis->itemGiveFunc = itemEntry->itemGiveFunc; + pthis->buyEventFunc = itemEntry->buyEventFunc; + pthis->basePrice = itemEntry->price; + pthis->itemCount = itemEntry->count; + pthis->hiliteFunc = itemEntry->hiliteFunc; + pthis->giDrawId = itemEntry->giDrawId; osSyncPrintf("%s(%2d)\n", sShopItemDescriptions[params], params); - this->actor.flags &= ~ACTOR_FLAG_0; - Actor_SetScale(&this->actor, 0.25f); - this->actor.shape.yOffset = 24.0f; - this->actor.shape.shadowScale = 4.0f; - this->actor.floorHeight = this->actor.home.pos.y; - this->actor.gravity = 0.0f; - EnGirlA_SetupAction(this, EnGirlA_Noop); - this->isInitialized = true; - this->actionFunc2 = EnGirlA_Update2; - this->isSelected = false; - this->yRotation = 0; - this->yRotationInit = this->actor.shape.rot.y; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Actor_SetScale(&pthis->actor, 0.25f); + pthis->actor.shape.yOffset = 24.0f; + pthis->actor.shape.shadowScale = 4.0f; + pthis->actor.floorHeight = pthis->actor.home.pos.y; + pthis->actor.gravity = 0.0f; + EnGirlA_SetupAction(pthis, EnGirlA_Noop); + pthis->isInitialized = true; + pthis->actionFunc2 = EnGirlA_Update2; + pthis->isSelected = false; + pthis->yRotation = 0; + pthis->yRotationInit = pthis->actor.shape.rot.y; } } -void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx) { - Actor_SetScale(&this->actor, 0.25f); - this->actor.shape.yOffset = 24.0f; - this->actor.shape.shadowScale = 4.0f; - EnGirlA_TrySetMaskItemDescription(this, globalCtx); - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, 5.0f); - this->actor.shape.rot.x = 0.0f; - if (this->actor.params != SI_SOLD_OUT) { - if (this->isSelected) { - this->yRotation += 0x1F4; +void EnGirlA_Update2(EnGirlA* pthis, GlobalContext* globalCtx) { + Actor_SetScale(&pthis->actor, 0.25f); + pthis->actor.shape.yOffset = 24.0f; + pthis->actor.shape.shadowScale = 4.0f; + EnGirlA_TrySetMaskItemDescription(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 5.0f); + pthis->actor.shape.rot.x = 0.0f; + if (pthis->actor.params != SI_SOLD_OUT) { + if (pthis->isSelected) { + pthis->yRotation += 0x1F4; } else { - Math_SmoothStepToS(&this->yRotation, 0, 10, 0x7D0, 0); + Math_SmoothStepToS(&pthis->yRotation, 0, 10, 0x7D0, 0); } } } void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGirlA* this = (EnGirlA*)thisx; + EnGirlA* pthis = (EnGirlA*)thisx; - this->actionFunc2(this, globalCtx); + pthis->actionFunc2(pthis, globalCtx); } void func_80A3C498(Actor* thisx, GlobalContext* globalCtx, s32 flags) { @@ -1111,11 +1111,11 @@ void func_80A3C498(Actor* thisx, GlobalContext* globalCtx, s32 flags) { } void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGirlA* this = (EnGirlA*)thisx; + EnGirlA* pthis = (EnGirlA*)thisx; - Matrix_RotateY(((this->yRotation * 360.0f) / 65536.0f) * (M_PI / 180.0f), MTXMODE_APPLY); - if (this->hiliteFunc != NULL) { - this->hiliteFunc(thisx, globalCtx, 0); + Matrix_RotateY(((pthis->yRotation * 360.0f) / 65536.0f) * (M_PI / 180.0f), MTXMODE_APPLY); + if (pthis->hiliteFunc != NULL) { + pthis->hiliteFunc(thisx, globalCtx, 0); } - GetItem_Draw(globalCtx, this->giDrawId); + GetItem_Draw(globalCtx, pthis->giDrawId); } diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c deleted file mode 100644 index 23171929e..000000000 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ /dev/null @@ -1,346 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GM_Z_EN_GM_C -#include "actor_common.h" -/* - * File: z_en_gm.c - * Overlay: ovl_En_Gm - * Description: Medi-Goron - */ - -#include "z_en_gm.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" -#include "objects/object_gm/object_gm.h" -#include "vt.h" -#include "def/code_80097A00.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnGm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A3D838(EnGm* this, GlobalContext* globalCtx); -void func_80A3DFBC(EnGm* this, GlobalContext* globalCtx); -void func_80A3DB04(EnGm* this, GlobalContext* globalCtx); -void func_80A3DC44(EnGm* this, GlobalContext* globalCtx); -void func_80A3DBF4(EnGm* this, GlobalContext* globalCtx); -void func_80A3DD7C(EnGm* this, GlobalContext* globalCtx); -void EnGm_ProcessChoiceIndex(EnGm* this, GlobalContext* globalCtx); -void func_80A3DF00(EnGm* this, GlobalContext* globalCtx); -void func_80A3DF60(EnGm* this, GlobalContext* globalCtx); - -const ActorInit En_Gm_InitVars = { - ACTOR_EN_GM, - ACTORCAT_NPC, - FLAGS, - OBJECT_OF1D_MAP, - sizeof(EnGm), - (ActorFunc)EnGm_Init, - (ActorFunc)EnGm_Destroy, - (ActorFunc)EnGm_Update, - NULL, -}; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 100, 120, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGm* this = (EnGm*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - - // "Medi Goron" - osSyncPrintf(VT_FGCOL(GREEN) "%s[%d] : 中ゴロン[%d]" VT_RST "\n", "../z_en_gm.c", 133, this->actor.params); - - this->objGmBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GM); - - if (this->objGmBankIndex < 0) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "There is no model bank! !! (Medi Goron)" - osSyncPrintf("モデル バンクが無いよ!!(中ゴロン)\n"); - osSyncPrintf(VT_RST); - ASSERT(0, "0", "../z_en_gm.c", 145); - } - - this->updateFunc = func_80A3D838; -} - -void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGm* this = (EnGm*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 func_80A3D7C8(void) { - if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - return 0; - } else if (!(gBitFlags[2] & gSaveContext.inventory.equipment)) { - return 1; - } else if (gBitFlags[3] & gSaveContext.inventory.equipment) { - return 2; - } else { - return 3; - } -} - -void func_80A3D838(EnGm* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objGmBankIndex)) { - this->actor.flags &= ~ACTOR_FLAG_4; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, 18); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objGmBankIndex].vromStart); - Animation_Change(&this->skelAnime, &object_gm_Anim_0002B8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_gm_Anim_0002B8), ANIMMODE_LOOP, 0.0f); - this->actor.draw = EnGm_Draw; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - Actor_SetScale(&this->actor, 0.05f); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->eyeTexIndex = 0; - this->blinkTimer = 20; - this->actor.textId = 0x3049; - this->updateFunc = func_80A3DFBC; - this->actionFunc = func_80A3DB04; - this->actor.speedXZ = 0.0f; - this->actor.gravity = -1.0f; - this->actor.velocity.y = 0.0f; - } -} - -void EnGm_UpdateEye(EnGm* this) { - if (this->blinkTimer != 0) { - this->blinkTimer--; - } else { - this->eyeTexIndex++; - - if (this->eyeTexIndex >= 3) { - this->eyeTexIndex = 0; - this->blinkTimer = Rand_ZeroFloat(60.0f) + 20.0f; - } - } -} - -void EnGm_SetTextID(EnGm* this) { - switch (func_80A3D7C8()) { - case 0: - if (gSaveContext.infTable[11] & 1) { - this->actor.textId = 0x304B; - } else { - this->actor.textId = 0x304A; - } - break; - case 1: - if (gSaveContext.infTable[11] & 2) { - this->actor.textId = 0x304F; - } else { - this->actor.textId = 0x304C; - } - break; - case 2: - this->actor.textId = 0x304E; - break; - case 3: - this->actor.textId = 0x304D; - break; - } -} - -void func_80A3DB04(EnGm* this, GlobalContext* globalCtx) { - f32 dx; - f32 dz; - Player* player = GET_PLAYER(globalCtx); - - dx = this->talkPos.x - player->actor.world.pos.x; - dz = this->talkPos.z - player->actor.world.pos.z; - - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - EnGm_SetTextID(this); - this->actionFunc = func_80A3DC44; - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_80A3DBF4; - } else if ((this->collider.base.ocFlags1 & OC1_HIT) || (SQ(dx) + SQ(dz)) < SQ(100.0f)) { - this->collider.base.acFlags &= ~AC_HIT; - func_8002F2CC(&this->actor, globalCtx, 415.0f); - } -} - -void func_80A3DBF4(EnGm* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = func_80A3DB04; - } -} - -void func_80A3DC44(EnGm* this, GlobalContext* globalCtx) { - f32 dx; - f32 dz; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - EnGm_SetTextID(this); - - dx = this->talkPos.x - player->actor.world.pos.x; - dz = this->talkPos.z - player->actor.world.pos.z; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - switch (func_80A3D7C8()) { - case 0: - gSaveContext.infTable[11] |= 1; - case 3: - this->actionFunc = func_80A3DD7C; - return; - case 1: - gSaveContext.infTable[11] |= 2; - case 2: - this->actionFunc = EnGm_ProcessChoiceIndex; - default: - return; - } - - this->actionFunc = EnGm_ProcessChoiceIndex; - } - if ((this->collider.base.ocFlags1 & OC1_HIT) || (SQ(dx) + SQ(dz)) < SQ(100.0f)) { - this->collider.base.acFlags &= ~AC_HIT; - func_8002F2CC(&this->actor, globalCtx, 415.0f); - } -} - -void func_80A3DD7C(EnGm* this, GlobalContext* globalCtx) { - u8 dialogState = Message_GetState(&globalCtx->msgCtx); - - if ((dialogState == TEXT_STATE_DONE || dialogState == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = func_80A3DC44; - if (dialogState == TEXT_STATE_EVENT) { - globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - globalCtx->msgCtx.stateTimer = 4; - } - } -} - -void EnGm_ProcessChoiceIndex(EnGm* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - if (gSaveContext.rupees < 200) { - Message_ContinueTextbox(globalCtx, 0xC8); - this->actionFunc = func_80A3DD7C; - } else { - func_8002F434(&this->actor, globalCtx, GI_SWORD_KNIFE, 415.0f, 10.0f); - this->actionFunc = func_80A3DF00; - } - break; - case 1: // no - Message_ContinueTextbox(globalCtx, 0x3050); - this->actionFunc = func_80A3DD7C; - break; - } - } -} - -void func_80A3DF00(EnGm* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_80A3DF60; - } else { - func_8002F434(&this->actor, globalCtx, GI_SWORD_KNIFE, 415.0f, 10.0f); - } -} - -void func_80A3DF60(EnGm* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - Rupees_ChangeBy(-200); - this->actionFunc = func_80A3DC44; - } -} - -void func_80A3DFBC(EnGm* this, GlobalContext* globalCtx) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objGmBankIndex].vromStart); - this->timer++; - this->actionFunc(this, globalCtx); - this->actor.focus.rot.x = this->actor.world.rot.x; - this->actor.focus.rot.y = this->actor.world.rot.y; - this->actor.focus.rot.z = this->actor.world.rot.z; - EnGm_UpdateEye(this); - SkelAnime_Update(&this->skelAnime); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGm* this = (EnGm*)thisx; - - this->updateFunc(this, globalCtx); -} - -void func_80A3E090(EnGm* this) { - Vec3f vec1; - Vec3f vec2; - - Matrix_Push(); - Matrix_Translate(0.0f, 0.0f, 2600.0f, MTXMODE_APPLY); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, MTXMODE_APPLY); - vec1.x = vec1.y = vec1.z = 0.0f; - Matrix_MultVec3f(&vec1, &vec2); - this->collider.dim.pos.x = vec2.x; - this->collider.dim.pos.y = vec2.y; - this->collider.dim.pos.z = vec2.z; - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(0.0f, 0.0f, 4300.0f, MTXMODE_APPLY); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, MTXMODE_APPLY); - vec1.x = vec1.y = vec1.z = 0.0f; - Matrix_MultVec3f(&vec1, &this->talkPos); - Matrix_Pop(); - Matrix_Translate(0.0f, 0.0f, 3800.0f, MTXMODE_APPLY); - Matrix_RotateZYX(this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, MTXMODE_APPLY); - vec1.x = vec1.y = vec1.z = 0.0f; - Matrix_MultVec3f(&vec1, &this->actor.focus.pos); - this->actor.focus.pos.y += 100.0f; -} - -void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; - EnGm* this = (EnGm*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gm.c", 613); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexIndex])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gGoronCsMouthNeutralTex)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gm.c", 629); - - func_80A3E090(this); -} diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.cpp b/src/overlays/actors/ovl_En_Gm/z_en_gm.cpp new file mode 100644 index 000000000..cf9e3c063 --- /dev/null +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.cpp @@ -0,0 +1,346 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GM_Z_EN_GM_C +#include "actor_common.h" +/* + * File: z_en_gm.c + * Overlay: ovl_En_Gm + * Description: Medi-Goron + */ + +#include "z_en_gm.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "objects/object_gm/object_gm.h" +#include "vt.h" +#include "def/code_80097A00.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnGm_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGm_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A3D838(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DFBC(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DB04(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DC44(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DBF4(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DD7C(EnGm* pthis, GlobalContext* globalCtx); +void EnGm_ProcessChoiceIndex(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DF00(EnGm* pthis, GlobalContext* globalCtx); +void func_80A3DF60(EnGm* pthis, GlobalContext* globalCtx); + +ActorInit En_Gm_InitVars = { + ACTOR_EN_GM, + ACTORCAT_NPC, + FLAGS, + OBJECT_OF1D_MAP, + sizeof(EnGm), + (ActorFunc)EnGm_Init, + (ActorFunc)EnGm_Destroy, + (ActorFunc)EnGm_Update, + NULL, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 100, 120, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGm* pthis = (EnGm*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + + // "Medi Goron" + osSyncPrintf(VT_FGCOL(GREEN) "%s[%d] : 中ゴロン[%d]" VT_RST "\n", "../z_en_gm.c", 133, pthis->actor.params); + + pthis->objGmBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GM); + + if (pthis->objGmBankIndex < 0) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "There is no model bank! !! (Medi Goron)" + osSyncPrintf("モデル バンクが無いよ!!(中ゴロン)\n"); + osSyncPrintf(VT_RST); + ASSERT(0, "0", "../z_en_gm.c", 145); + } + + pthis->updateFunc = func_80A3D838; +} + +void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGm* pthis = (EnGm*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 func_80A3D7C8(void) { + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + return 0; + } else if (!(gBitFlags[2] & gSaveContext.inventory.equipment)) { + return 1; + } else if (gBitFlags[3] & gSaveContext.inventory.equipment) { + return 2; + } else { + return 3; + } +} + +void func_80A3D838(EnGm* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objGmBankIndex)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGoronSkel, NULL, pthis->jointTable, pthis->morphTable, 18); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objGmBankIndex].vromStart.get()); + Animation_Change(&pthis->skelAnime, &object_gm_Anim_0002B8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_gm_Anim_0002B8), ANIMMODE_LOOP, 0.0f); + pthis->actor.draw = EnGm_Draw; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + Actor_SetScale(&pthis->actor, 0.05f); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->eyeTexIndex = 0; + pthis->blinkTimer = 20; + pthis->actor.textId = 0x3049; + pthis->updateFunc = func_80A3DFBC; + pthis->actionFunc = func_80A3DB04; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = -1.0f; + pthis->actor.velocity.y = 0.0f; + } +} + +void EnGm_UpdateEye(EnGm* pthis) { + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + } else { + pthis->eyeTexIndex++; + + if (pthis->eyeTexIndex >= 3) { + pthis->eyeTexIndex = 0; + pthis->blinkTimer = Rand_ZeroFloat(60.0f) + 20.0f; + } + } +} + +void EnGm_SetTextID(EnGm* pthis) { + switch (func_80A3D7C8()) { + case 0: + if (gSaveContext.infTable[11] & 1) { + pthis->actor.textId = 0x304B; + } else { + pthis->actor.textId = 0x304A; + } + break; + case 1: + if (gSaveContext.infTable[11] & 2) { + pthis->actor.textId = 0x304F; + } else { + pthis->actor.textId = 0x304C; + } + break; + case 2: + pthis->actor.textId = 0x304E; + break; + case 3: + pthis->actor.textId = 0x304D; + break; + } +} + +void func_80A3DB04(EnGm* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dz; + Player* player = GET_PLAYER(globalCtx); + + dx = pthis->talkPos.x - player->actor.world.pos.x; + dz = pthis->talkPos.z - player->actor.world.pos.z; + + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + EnGm_SetTextID(pthis); + pthis->actionFunc = func_80A3DC44; + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80A3DBF4; + } else if ((pthis->collider.base.ocFlags1 & OC1_HIT) || (SQ(dx) + SQ(dz)) < SQ(100.0f)) { + pthis->collider.base.acFlags &= ~AC_HIT; + func_8002F2CC(&pthis->actor, globalCtx, 415.0f); + } +} + +void func_80A3DBF4(EnGm* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + pthis->actionFunc = func_80A3DB04; + } +} + +void func_80A3DC44(EnGm* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dz; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + EnGm_SetTextID(pthis); + + dx = pthis->talkPos.x - player->actor.world.pos.x; + dz = pthis->talkPos.z - player->actor.world.pos.z; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + switch (func_80A3D7C8()) { + case 0: + gSaveContext.infTable[11] |= 1; + case 3: + pthis->actionFunc = func_80A3DD7C; + return; + case 1: + gSaveContext.infTable[11] |= 2; + case 2: + pthis->actionFunc = EnGm_ProcessChoiceIndex; + default: + return; + } + + pthis->actionFunc = EnGm_ProcessChoiceIndex; + } + if ((pthis->collider.base.ocFlags1 & OC1_HIT) || (SQ(dx) + SQ(dz)) < SQ(100.0f)) { + pthis->collider.base.acFlags &= ~AC_HIT; + func_8002F2CC(&pthis->actor, globalCtx, 415.0f); + } +} + +void func_80A3DD7C(EnGm* pthis, GlobalContext* globalCtx) { + u8 dialogState = Message_GetState(&globalCtx->msgCtx); + + if ((dialogState == TEXT_STATE_DONE || dialogState == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actionFunc = func_80A3DC44; + if (dialogState == TEXT_STATE_EVENT) { + globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; + globalCtx->msgCtx.stateTimer = 4; + } + } +} + +void EnGm_ProcessChoiceIndex(EnGm* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + if (gSaveContext.rupees < 200) { + Message_ContinueTextbox(globalCtx, 0xC8); + pthis->actionFunc = func_80A3DD7C; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_SWORD_KNIFE, 415.0f, 10.0f); + pthis->actionFunc = func_80A3DF00; + } + break; + case 1: // no + Message_ContinueTextbox(globalCtx, 0x3050); + pthis->actionFunc = func_80A3DD7C; + break; + } + } +} + +void func_80A3DF00(EnGm* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_80A3DF60; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_SWORD_KNIFE, 415.0f, 10.0f); + } +} + +void func_80A3DF60(EnGm* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + Rupees_ChangeBy(-200); + pthis->actionFunc = func_80A3DC44; + } +} + +void func_80A3DFBC(EnGm* pthis, GlobalContext* globalCtx) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objGmBankIndex].vromStart.get()); + pthis->timer++; + pthis->actionFunc(pthis, globalCtx); + pthis->actor.focus.rot.x = pthis->actor.world.rot.x; + pthis->actor.focus.rot.y = pthis->actor.world.rot.y; + pthis->actor.focus.rot.z = pthis->actor.world.rot.z; + EnGm_UpdateEye(pthis); + SkelAnime_Update(&pthis->skelAnime); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGm* pthis = (EnGm*)thisx; + + pthis->updateFunc(pthis, globalCtx); +} + +void func_80A3E090(EnGm* pthis) { + Vec3f vec1; + Vec3f vec2; + + Matrix_Push(); + Matrix_Translate(0.0f, 0.0f, 2600.0f, MTXMODE_APPLY); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, pthis->actor.world.rot.z, MTXMODE_APPLY); + vec1.x = vec1.y = vec1.z = 0.0f; + Matrix_MultVec3f(&vec1, &vec2); + pthis->collider.dim.pos.x = vec2.x; + pthis->collider.dim.pos.y = vec2.y; + pthis->collider.dim.pos.z = vec2.z; + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(0.0f, 0.0f, 4300.0f, MTXMODE_APPLY); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, pthis->actor.world.rot.z, MTXMODE_APPLY); + vec1.x = vec1.y = vec1.z = 0.0f; + Matrix_MultVec3f(&vec1, &pthis->talkPos); + Matrix_Pop(); + Matrix_Translate(0.0f, 0.0f, 3800.0f, MTXMODE_APPLY); + Matrix_RotateZYX(pthis->actor.world.rot.x, pthis->actor.world.rot.y, pthis->actor.world.rot.z, MTXMODE_APPLY); + vec1.x = vec1.y = vec1.z = 0.0f; + Matrix_MultVec3f(&vec1, &pthis->actor.focus.pos); + pthis->actor.focus.pos.y += 100.0f; +} + +void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; + EnGm* pthis = (EnGm*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gm.c", 613); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gGoronCsMouthNeutralTex)); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, &pthis->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gm.c", 629); + + func_80A3E090(pthis); +} diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.cpp similarity index 52% rename from src/overlays/actors/ovl_En_Go/z_en_go.c rename to src/overlays/actors/ovl_En_Go/z_en_go.cpp index d4df4a0c8..1ec7249a3 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.cpp @@ -27,30 +27,30 @@ void EnGo_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGo_Update(Actor* thisx, GlobalContext* globalCtx); void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A3FEB4(EnGo* this, GlobalContext* globalCtx); -void EnGo_StopRolling(EnGo* this, GlobalContext* globalCtx); -void func_80A4008C(EnGo* this, GlobalContext* globalCtx); -void EnGo_GoronLinkRolling(EnGo* this, GlobalContext* globalCtx); -void EnGo_FireGenericActionFunc(EnGo* this, GlobalContext* globalCtx); -void EnGo_CurledUp(EnGo* this, GlobalContext* globalCtx); -void EnGo_WakeUp(EnGo* this, GlobalContext* globalCtx); +void func_80A3FEB4(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_StopRolling(EnGo* pthis, GlobalContext* globalCtx); +void func_80A4008C(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_GoronLinkRolling(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_FireGenericActionFunc(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_CurledUp(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_WakeUp(EnGo* pthis, GlobalContext* globalCtx); -void func_80A40494(EnGo* this, GlobalContext* globalCtx); -void func_80A405CC(EnGo* this, GlobalContext* globalCtx); -void EnGo_BiggoronActionFunc(EnGo* this, GlobalContext* globalCtx); -void func_80A408D8(EnGo* this, GlobalContext* globalCtx); +void func_80A40494(EnGo* pthis, GlobalContext* globalCtx); +void func_80A405CC(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_BiggoronActionFunc(EnGo* pthis, GlobalContext* globalCtx); +void func_80A408D8(EnGo* pthis, GlobalContext* globalCtx); -void func_80A40B1C(EnGo* this, GlobalContext* globalCtx); -void EnGo_GetItem(EnGo* this, GlobalContext* globalCtx); -void func_80A40C78(EnGo* this, GlobalContext* globalCtx); -void EnGo_Eyedrops(EnGo* this, GlobalContext* globalCtx); -void func_80A40DCC(EnGo* this, GlobalContext* globalCtx); +void func_80A40B1C(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_GetItem(EnGo* pthis, GlobalContext* globalCtx); +void func_80A40C78(EnGo* pthis, GlobalContext* globalCtx); +void EnGo_Eyedrops(EnGo* pthis, GlobalContext* globalCtx); +void func_80A40DCC(EnGo* pthis, GlobalContext* globalCtx); -void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep); -void EnGo_UpdateDust(EnGo* this); -void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx); +void EnGo_AddDust(EnGo* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep); +void EnGo_UpdateDust(EnGo* pthis); +void EnGo_DrawDust(EnGo* pthis, GlobalContext* globalCtx); -const ActorInit En_Go_InitVars = { +ActorInit En_Go_InitVars = { ACTOR_EN_GO, ACTORCAT_NPC, FLAGS, @@ -100,8 +100,8 @@ static EnGoAnimation sAnimationEntries[] = { { &gGoronAnim_010590, 1.0f, ANIMMODE_LOOP_INTERP, -10.0f }, }; -void EnGo_SetupAction(EnGo* this, EnGoActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnGo_SetupAction(EnGo* pthis, EnGoActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } u16 EnGo_GetTextID(GlobalContext* globalCtx, Actor* thisx) { @@ -348,52 +348,52 @@ s16 EnGo_SetFlagsGetStates(GlobalContext* globalCtx, Actor* thisx) { return unkState; } -s32 func_80A3ED24(GlobalContext* globalCtx, EnGo* this, struct_80034A14_arg1* arg2, f32 arg3, +s32 func_80A3ED24(GlobalContext* globalCtx, EnGo* pthis, struct_80034A14_arg1* arg2, f32 arg3, u16 (*getTextId)(GlobalContext*, Actor*), s16 (*unkFunc2)(GlobalContext*, Actor*)) { if (arg2->unk_00) { - arg2->unk_00 = unkFunc2(globalCtx, &this->actor); + arg2->unk_00 = unkFunc2(globalCtx, &pthis->actor); return false; - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { arg2->unk_00 = 1; return true; - } else if (!func_8002F2CC(&this->actor, globalCtx, arg3)) { + } else if (!func_8002F2CC(&pthis->actor, globalCtx, arg3)) { return false; } else { - this->actor.textId = getTextId(globalCtx, &this->actor); + pthis->actor.textId = getTextId(globalCtx, &pthis->actor); return false; } } -void EnGo_ChangeAnimation(EnGo* this, s32 animIndex) { - Animation_Change(&this->skelAnime, sAnimationEntries[animIndex].animation, - sAnimationEntries[animIndex].playSpeed * ((this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f), 0.0f, +void EnGo_ChangeAnimation(EnGo* pthis, s32 animIndex) { + Animation_Change(&pthis->skelAnime, sAnimationEntries[animIndex].animation, + sAnimationEntries[animIndex].playSpeed * ((pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f), 0.0f, Animation_GetLastFrame(sAnimationEntries[animIndex].animation), sAnimationEntries[animIndex].mode, sAnimationEntries[animIndex].morphRate); } -s32 EnGo_IsActorSpawned(EnGo* this, GlobalContext* globalCtx) { - if (((this->actor.params) & 0xF0) == 0x90) { +s32 EnGo_IsActorSpawned(EnGo* pthis, GlobalContext* globalCtx) { + if (((pthis->actor.params) & 0xF0) == 0x90) { return true; - } else if (globalCtx->sceneNum == SCENE_HIDAN && !Flags_GetSwitch(globalCtx, (this->actor.params) >> 8) && - LINK_IS_ADULT && (this->actor.params & 0xF0) == 0x10) { + } else if (globalCtx->sceneNum == SCENE_HIDAN && !Flags_GetSwitch(globalCtx, (pthis->actor.params) >> 8) && + LINK_IS_ADULT && (pthis->actor.params & 0xF0) == 0x10) { return true; - } else if (globalCtx->sceneNum == SCENE_SPOT18 && LINK_IS_ADULT && (this->actor.params & 0xF0) == 0x00) { + } else if (globalCtx->sceneNum == SCENE_SPOT18 && LINK_IS_ADULT && (pthis->actor.params & 0xF0) == 0x00) { return true; } else if (globalCtx->sceneNum == SCENE_SPOT16 && LINK_IS_CHILD && - ((this->actor.params & 0xF0) == 0x20 || (this->actor.params & 0xF0) == 0x30 || - (this->actor.params & 0xF0) == 0x40)) { + ((pthis->actor.params & 0xF0) == 0x20 || (pthis->actor.params & 0xF0) == 0x30 || + (pthis->actor.params & 0xF0) == 0x40)) { return true; } else if (globalCtx->sceneNum == SCENE_SPOT18 && LINK_IS_CHILD && - ((this->actor.params & 0xF0) == 0x50 || (this->actor.params & 0xF0) == 0x60 || - (this->actor.params & 0xF0) == 0x70)) { + ((pthis->actor.params & 0xF0) == 0x50 || (pthis->actor.params & 0xF0) == 0x60 || + (pthis->actor.params & 0xF0) == 0x70)) { return true; } else { return false; } } -f32 EnGo_GetGoronSize(EnGo* this) { - switch (this->actor.params & 0xF0) { +f32 EnGo_GetGoronSize(EnGo* pthis) { + switch (pthis->actor.params & 0xF0) { case 0x00: return 10.0f; case 0x20: @@ -409,46 +409,46 @@ f32 EnGo_GetGoronSize(EnGo* this) { } } -void func_80A3F060(EnGo* this, GlobalContext* globalCtx) { +void func_80A3F060(EnGo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 unkVal; - if (this->actionFunc != EnGo_BiggoronActionFunc && this->actionFunc != EnGo_FireGenericActionFunc && - this->actionFunc != func_80A40B1C) { + if (pthis->actionFunc != EnGo_BiggoronActionFunc && pthis->actionFunc != EnGo_FireGenericActionFunc && + pthis->actionFunc != func_80A40B1C) { unkVal = 1; } - this->unk_1E0.unk_18 = player->actor.world.pos; - this->unk_1E0.unk_14 = EnGo_GetGoronSize(this); - func_80034A14(&this->actor, &this->unk_1E0, 4, unkVal); + pthis->unk_1E0.unk_18 = player->actor.world.pos; + pthis->unk_1E0.unk_14 = EnGo_GetGoronSize(pthis); + func_80034A14(&pthis->actor, &pthis->unk_1E0, 4, unkVal); } -void func_80A3F0E4(EnGo* this) { - if (DECR(this->unk_214) == 0) { - this->unk_216++; - if (this->unk_216 >= 3) { - this->unk_214 = Rand_S16Offset(30, 30); - this->unk_216 = 0; +void func_80A3F0E4(EnGo* pthis) { + if (DECR(pthis->unk_214) == 0) { + pthis->unk_216++; + if (pthis->unk_216 >= 3) { + pthis->unk_214 = Rand_S16Offset(30, 30); + pthis->unk_216 = 0; } } } -s32 EnGo_IsCameraModified(EnGo* this, GlobalContext* globalCtx) { +s32 EnGo_IsCameraModified(EnGo* pthis, GlobalContext* globalCtx) { f32 xyzDist; - s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + s16 yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; Camera* camera = globalCtx->cameraPtrs[MAIN_CAM]; if (fabsf(yawDiff) > 10920.0f) { return 0; } - xyzDist = (this->actor.scale.x / 0.01f) * 10000.0f; - if ((this->actor.params & 0xF0) == 0x90) { + xyzDist = (pthis->actor.scale.x / 0.01f) * 10000.0f; + if ((pthis->actor.params & 0xF0) == 0x90) { Camera_ChangeSetting(camera, CAM_SET_DIRECTED_YAW); xyzDist *= 4.8f; } - if (fabsf(this->actor.xyzDistToPlayerSq) > xyzDist) { + if (fabsf(pthis->actor.xyzDistToPlayerSq) > xyzDist) { if (camera->setting == CAM_SET_DIRECTED_YAW) { Camera_ChangeSetting(camera, CAM_SET_NORMAL0); } @@ -458,55 +458,55 @@ s32 EnGo_IsCameraModified(EnGo* this, GlobalContext* globalCtx) { } } -void EnGo_ReverseAnimation(EnGo* this) { - f32 startFrame = this->skelAnime.startFrame; +void EnGo_ReverseAnimation(EnGo* pthis) { + f32 startFrame = pthis->skelAnime.startFrame; - this->skelAnime.startFrame = this->skelAnime.endFrame; - this->skelAnime.endFrame = startFrame; + pthis->skelAnime.startFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.endFrame = startFrame; } -void EnGo_UpdateShadow(EnGo* this) { +void EnGo_UpdateShadow(EnGo* pthis) { s16 shadowAlpha; - f32 currentFrame = this->skelAnime.curFrame; - s16 shadowAlphaTarget = (this->skelAnime.animation == &gGoronAnim_004930 && currentFrame > 32.0f) || - this->skelAnime.animation != &gGoronAnim_004930 + f32 currentFrame = pthis->skelAnime.curFrame; + s16 shadowAlphaTarget = (pthis->skelAnime.animation == &gGoronAnim_004930 && currentFrame > 32.0f) || + pthis->skelAnime.animation != &gGoronAnim_004930 ? 255 : 0; - shadowAlpha = this->actor.shape.shadowAlpha; + shadowAlpha = pthis->actor.shape.shadowAlpha; Math_SmoothStepToS(&shadowAlpha, shadowAlphaTarget, 10, 60, 1); - this->actor.shape.shadowAlpha = shadowAlpha; + pthis->actor.shape.shadowAlpha = shadowAlpha; } -s32 EnGo_FollowPath(EnGo* this, GlobalContext* globalCtx) { +s32 EnGo_FollowPath(EnGo* pthis, GlobalContext* globalCtx) { Path* path; Vec3s* pointPos; f32 xDist; f32 zDist; - if ((this->actor.params & 0xF) == 15) { + if ((pthis->actor.params & 0xF) == 15) { return false; } - path = &globalCtx->setupPathList[this->actor.params & 0xF]; + path = &globalCtx->setupPathList[pthis->actor.params & 0xF]; pointPos = SEGMENTED_TO_VIRTUAL(path->points); - pointPos += this->unk_218; - xDist = pointPos->x - this->actor.world.pos.x; - zDist = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, (s16)(Math_FAtan2F(xDist, zDist) * ((f32)0x8000 / M_PI)), 10, 1000, 1); + pointPos += pthis->unk_218; + xDist = pointPos->x - pthis->actor.world.pos.x; + zDist = pointPos->z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.world.rot.y, (s16)(Math_FAtan2F(xDist, zDist) * ((f32)0x8000 / M_PI)), 10, 1000, 1); if ((SQ(xDist) + SQ(zDist)) < 600.0f) { - this->unk_218++; - if (this->unk_218 >= path->count) { - this->unk_218 = 0; + pthis->unk_218++; + if (pthis->unk_218 >= path->count) { + pthis->unk_218 = 0; } - if ((this->actor.params & 0xF0) != 0x00) { + if ((pthis->actor.params & 0xF0) != 0x00) { return true; - } else if (Flags_GetSwitch(globalCtx, this->actor.params >> 8)) { + } else if (Flags_GetSwitch(globalCtx, pthis->actor.params >> 8)) { return true; - } else if (this->unk_218 >= this->actor.shape.rot.z) { - this->unk_218 = 0; + } else if (pthis->unk_218 >= pthis->actor.shape.rot.z) { + pthis->unk_218 = 0; } return true; @@ -515,463 +515,463 @@ s32 EnGo_FollowPath(EnGo* this, GlobalContext* globalCtx) { return false; } -s32 EnGo_SetMovedPos(EnGo* this, GlobalContext* globalCtx) { +s32 EnGo_SetMovedPos(EnGo* pthis, GlobalContext* globalCtx) { Path* path; Vec3s* pointPos; - if ((this->actor.params & 0xF) == 0xF) { + if ((pthis->actor.params & 0xF) == 0xF) { return false; } else { - path = &globalCtx->setupPathList[this->actor.params & 0xF]; + path = &globalCtx->setupPathList[pthis->actor.params & 0xF]; pointPos = SEGMENTED_TO_VIRTUAL(path->points); pointPos += (path->count - 1); - this->actor.world.pos.x = pointPos->x; - this->actor.world.pos.y = pointPos->y; - this->actor.world.pos.z = pointPos->z; - this->actor.home.pos = this->actor.world.pos; + pthis->actor.world.pos.x = pointPos->x; + pthis->actor.world.pos.y = pointPos->y; + pthis->actor.world.pos.z = pointPos->z; + pthis->actor.home.pos = pthis->actor.world.pos; return true; } } -s32 EnGo_SpawnDust(EnGo* this, u8 initialTimer, f32 scale, f32 scaleStep, s32 numDustEffects, f32 radius, f32 xzAccel) { +s32 EnGo_SpawnDust(EnGo* pthis, u8 initialTimer, f32 scale, f32 scaleStep, s32 numDustEffects, f32 radius, f32 xzAccel) { Vec3f pos = { 0.0f, 0.0f, 0.0f }; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.3f, 0.0f }; s16 angle; s32 i; - pos = this->actor.world.pos; // Overwrites pos - pos.y = this->actor.floorHeight; + pos = pthis->actor.world.pos; // Overwrites pos + pos.y = pthis->actor.floorHeight; angle = (Rand_ZeroOne() - 0.5f) * 0x10000; i = numDustEffects; while (i >= 0) { accel.x = (Rand_ZeroOne() - 0.5f) * xzAccel; accel.z = (Rand_ZeroOne() - 0.5f) * xzAccel; - pos.x = (Math_SinS(angle) * radius) + this->actor.world.pos.x; - pos.z = (Math_CosS(angle) * radius) + this->actor.world.pos.z; - EnGo_AddDust(this, &pos, &velocity, &accel, initialTimer, scale, scaleStep); + pos.x = (Math_SinS(angle) * radius) + pthis->actor.world.pos.x; + pos.z = (Math_CosS(angle) * radius) + pthis->actor.world.pos.z; + EnGo_AddDust(pthis, &pos, &velocity, &accel, initialTimer, scale, scaleStep); angle += (s16)(0x10000 / numDustEffects); i--; } return 0; } -s32 EnGo_IsRollingOnGround(EnGo* this, s16 unkArg1, f32 unkArg2) { - if ((this->actor.bgCheckFlags & 1) == 0 || this->actor.velocity.y > 0.0f) { +s32 EnGo_IsRollingOnGround(EnGo* pthis, s16 unkArg1, f32 unkArg2) { + if ((pthis->actor.bgCheckFlags & 1) == 0 || pthis->actor.velocity.y > 0.0f) { return false; - } else if (this->unk_1E0.unk_00 != 0) { + } else if (pthis->unk_1E0.unk_00 != 0) { return true; - } else if (DECR(this->unk_21C)) { - if ((this->unk_21C & 1)) { - this->actor.world.pos.y += 1.5f; + } else if (DECR(pthis->unk_21C)) { + if ((pthis->unk_21C & 1)) { + pthis->actor.world.pos.y += 1.5f; } else { - this->actor.world.pos.y -= 1.5f; + pthis->actor.world.pos.y -= 1.5f; } return true; } else { - this->unk_21A--; - if (this->unk_21A <= 0) { - if (this->unk_21A == 0) { - this->unk_21C = Rand_S16Offset(60, 30); - this->unk_21A = 0; - this->actor.velocity.y = 0.0f; + pthis->unk_21A--; + if (pthis->unk_21A <= 0) { + if (pthis->unk_21A == 0) { + pthis->unk_21C = Rand_S16Offset(60, 30); + pthis->unk_21A = 0; + pthis->actor.velocity.y = 0.0f; return true; } - this->unk_21A = unkArg1; + pthis->unk_21A = unkArg1; } - this->actor.velocity.y = ((f32)this->unk_21A / (f32)unkArg1) * unkArg2; + pthis->actor.velocity.y = ((f32)pthis->unk_21A / (f32)unkArg1) * unkArg2; return true; } } -void func_80A3F908(EnGo* this, GlobalContext* globalCtx) { +void func_80A3F908(EnGo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 float1; s32 isUnkCondition; - if (this->actionFunc == EnGo_BiggoronActionFunc || this->actionFunc == EnGo_GoronLinkRolling || - this->actionFunc == EnGo_FireGenericActionFunc || this->actionFunc == EnGo_Eyedrops || - this->actionFunc == func_80A40DCC || this->actionFunc == EnGo_GetItem || this->actionFunc == func_80A40C78 || - this->actionFunc == func_80A40B1C) { + if (pthis->actionFunc == EnGo_BiggoronActionFunc || pthis->actionFunc == EnGo_GoronLinkRolling || + pthis->actionFunc == EnGo_FireGenericActionFunc || pthis->actionFunc == EnGo_Eyedrops || + pthis->actionFunc == func_80A40DCC || pthis->actionFunc == EnGo_GetItem || pthis->actionFunc == func_80A40C78 || + pthis->actionFunc == func_80A40B1C) { - float1 = (this->collider.dim.radius + 30.0f); - float1 *= (this->actor.scale.x / 0.01f); - if ((this->actor.params & 0xF0) == 0x90) { + float1 = (pthis->collider.dim.radius + 30.0f); + float1 *= (pthis->actor.scale.x / 0.01f); + if ((pthis->actor.params & 0xF0) == 0x90) { float1 *= 4.8f; } - if ((this->actor.params & 0xF0) == 0x90) { + if ((pthis->actor.params & 0xF0) == 0x90) { isUnkCondition = - func_80A3ED24(globalCtx, this, &this->unk_1E0, float1, EnGo_GetTextID, EnGo_SetFlagsGetStates); + func_80A3ED24(globalCtx, pthis, &pthis->unk_1E0, float1, EnGo_GetTextID, EnGo_SetFlagsGetStates); } else { - isUnkCondition = func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, float1, EnGo_GetTextID, + isUnkCondition = func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E0.unk_00, float1, EnGo_GetTextID, EnGo_SetFlagsGetStates); } - if (((this->actor.params & 0xF0) == 0x90) && (isUnkCondition == true)) { + if (((pthis->actor.params & 0xF0) == 0x90) && (isUnkCondition == true)) { if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_SWORD_BROKEN) { if (func_8002F368(globalCtx) == EXCH_ITEM_SWORD_BROKEN) { if (gSaveContext.infTable[11] & 0x10) { - this->actor.textId = 0x3055; + pthis->actor.textId = 0x3055; } else { - this->actor.textId = 0x3054; + pthis->actor.textId = 0x3054; } } else { - this->actor.textId = 0x3053; + pthis->actor.textId = 0x3053; } - player->actor.textId = this->actor.textId; + player->actor.textId = pthis->actor.textId; } if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_EYEDROPS) { if (func_8002F368(globalCtx) == EXCH_ITEM_EYEDROPS) { - this->actor.textId = 0x3059; + pthis->actor.textId = 0x3059; } else { - this->actor.textId = 0x3058; + pthis->actor.textId = 0x3058; } - player->actor.textId = this->actor.textId; + player->actor.textId = pthis->actor.textId; } } } } void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGo* this = (EnGo*)thisx; + EnGo* pthis = (EnGo*)thisx; s32 pad; Vec3f D_80A41B9C = { 0.0f, 0.0f, 0.0f }; // unused Vec3f D_80A41BA8 = { 0.0f, 0.0f, 0.0f }; // unused - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, 0, 0, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGoronSkel, NULL, 0, 0, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - if (!EnGo_IsActorSpawned(this, globalCtx)) { - Actor_Kill(&this->actor); + if (!EnGo_IsActorSpawned(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); return; } - if ((this->actor.params & 0xF0) && ((this->actor.params & 0xF0) != 0x90)) { - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.flags &= ~ACTOR_FLAG_5; + if ((pthis->actor.params & 0xF0) && ((pthis->actor.params & 0xF0) != 0x90)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.flags &= ~ACTOR_FLAG_5; } - EnGo_ChangeAnimation(this, 0); - this->actor.targetMode = 6; - this->unk_1E0.unk_00 = 0; - this->actor.gravity = -1.0f; + EnGo_ChangeAnimation(pthis, 0); + pthis->actor.targetMode = 6; + pthis->unk_1E0.unk_00 = 0; + pthis->actor.gravity = -1.0f; - switch (this->actor.params & 0xF0) { + switch (pthis->actor.params & 0xF0) { case 0x00: - Actor_SetScale(&this->actor, 0.008f); + Actor_SetScale(&pthis->actor, 0.008f); if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { - EnGo_SetMovedPos(this, globalCtx); - EnGo_SetupAction(this, EnGo_CurledUp); + EnGo_SetMovedPos(pthis, globalCtx); + EnGo_SetupAction(pthis, EnGo_CurledUp); } else { - this->actor.shape.yOffset = 1400.0f; - this->actor.speedXZ = 3.0f; - EnGo_SetupAction(this, EnGo_GoronLinkRolling); + pthis->actor.shape.yOffset = 1400.0f; + pthis->actor.speedXZ = 3.0f; + EnGo_SetupAction(pthis, EnGo_GoronLinkRolling); } break; case 0x10: - this->skelAnime.curFrame = Animation_GetLastFrame(&gGoronAnim_004930); - Actor_SetScale(&this->actor, 0.01f); - EnGo_SetupAction(this, EnGo_FireGenericActionFunc); + pthis->skelAnime.curFrame = Animation_GetLastFrame(&gGoronAnim_004930); + Actor_SetScale(&pthis->actor, 0.01f); + EnGo_SetupAction(pthis, EnGo_FireGenericActionFunc); break; case 0x40: if (gSaveContext.infTable[14] & 0x800) { - EnGo_SetMovedPos(this, globalCtx); + EnGo_SetMovedPos(pthis, globalCtx); } - Actor_SetScale(&this->actor, 0.015f); - EnGo_SetupAction(this, EnGo_CurledUp); + Actor_SetScale(&pthis->actor, 0.015f); + EnGo_SetupAction(pthis, EnGo_CurledUp); break; case 0x30: - this->actor.shape.yOffset = 1400.0f; - Actor_SetScale(&this->actor, 0.01f); - EnGo_SetupAction(this, func_80A3FEB4); + pthis->actor.shape.yOffset = 1400.0f; + Actor_SetScale(&pthis->actor, 0.01f); + EnGo_SetupAction(pthis, func_80A3FEB4); break; case 0x90: - this->actor.targetMode = 5; - Actor_SetScale(&this->actor, 0.16f); - EnGo_SetupAction(this, EnGo_CurledUp); + pthis->actor.targetMode = 5; + Actor_SetScale(&pthis->actor, 0.16f); + EnGo_SetupAction(pthis, EnGo_CurledUp); break; case 0x20: case 0x50: case 0x60: case 0x70: - Actor_SetScale(&this->actor, 0.01f); - EnGo_SetupAction(this, EnGo_CurledUp); + Actor_SetScale(&pthis->actor, 0.01f); + EnGo_SetupAction(pthis, EnGo_CurledUp); break; default: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void EnGo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGo* this = (EnGo*)thisx; + EnGo* pthis = (EnGo*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_80A3FEB4(EnGo* this, GlobalContext* globalCtx) { - if (!(this->actor.xyzDistToPlayerSq > SQ(1200.0f))) { - EnGo_SetupAction(this, EnGo_StopRolling); +void func_80A3FEB4(EnGo* pthis, GlobalContext* globalCtx) { + if (!(pthis->actor.xyzDistToPlayerSq > SQ(1200.0f))) { + EnGo_SetupAction(pthis, EnGo_StopRolling); } } -void EnGo_StopRolling(EnGo* this, GlobalContext* globalCtx) { +void EnGo_StopRolling(EnGo* pthis, GlobalContext* globalCtx) { EnBom* bomb; - if (DECR(this->unk_20E) == 0) { - if (this->collider.base.ocFlags2 & 1) { - this->collider.base.ocFlags2 &= ~1; + if (DECR(pthis->unk_20E) == 0) { + if (pthis->collider.base.ocFlags2 & 1) { + pthis->collider.base.ocFlags2 &= ~1; globalCtx->damagePlayer(globalCtx, -4); - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); - this->unk_20E = 0x10; + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.yawTowardsPlayer, 6.0f); + pthis->unk_20E = 0x10; } } - this->actor.speedXZ = 3.0f; - if ((EnGo_FollowPath(this, globalCtx) == true) && (this->unk_218 == 0)) { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + pthis->actor.speedXZ = 3.0f; + if ((EnGo_FollowPath(pthis, globalCtx) == true) && (pthis->unk_218 == 0)) { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); if (bomb != NULL) { bomb->timer = 0; } - this->actor.speedXZ = 0.0f; - EnGo_SetupAction(this, func_80A4008C); + pthis->actor.speedXZ = 0.0f; + EnGo_SetupAction(pthis, func_80A4008C); } - this->actor.shape.rot = this->actor.world.rot; + pthis->actor.shape.rot = pthis->actor.world.rot; - if (EnGo_IsRollingOnGround(this, 3, 6.0f)) { - EnGo_SpawnDust(this, 12, 0.16f, 0.1f, 1, 10.0f, 20.0f); + if (EnGo_IsRollingOnGround(pthis, 3, 6.0f)) { + EnGo_SpawnDust(pthis, 12, 0.16f, 0.1f, 1, 10.0f, 20.0f); } } -void func_80A4008C(EnGo* this, GlobalContext* globalCtx) { - if (EnGo_IsRollingOnGround(this, 3, 6.0f)) { - if (this->unk_21A == 0) { - this->actor.shape.yOffset = 0.0f; - EnGo_SetupAction(this, EnGo_CurledUp); +void func_80A4008C(EnGo* pthis, GlobalContext* globalCtx) { + if (EnGo_IsRollingOnGround(pthis, 3, 6.0f)) { + if (pthis->unk_21A == 0) { + pthis->actor.shape.yOffset = 0.0f; + EnGo_SetupAction(pthis, EnGo_CurledUp); } else { - EnGo_SpawnDust(this, 12, 0.16f, 0.1f, 1, 10.0f, 20.0f); + EnGo_SpawnDust(pthis, 12, 0.16f, 0.1f, 1, 10.0f, 20.0f); } } } -void EnGo_GoronLinkRolling(EnGo* this, GlobalContext* globalCtx) { - if ((EnGo_FollowPath(this, globalCtx) == true) && Flags_GetSwitch(globalCtx, this->actor.params >> 8) && - (this->unk_218 == 0)) { - this->actor.speedXZ = 0.0f; - EnGo_SetupAction(this, func_80A4008C); +void EnGo_GoronLinkRolling(EnGo* pthis, GlobalContext* globalCtx) { + if ((EnGo_FollowPath(pthis, globalCtx) == true) && Flags_GetSwitch(globalCtx, pthis->actor.params >> 8) && + (pthis->unk_218 == 0)) { + pthis->actor.speedXZ = 0.0f; + EnGo_SetupAction(pthis, func_80A4008C); gSaveContext.infTable[16] |= 0x200; } - this->actor.shape.rot = this->actor.world.rot; + pthis->actor.shape.rot = pthis->actor.world.rot; - if (EnGo_IsRollingOnGround(this, 3, 6.0f)) { - EnGo_SpawnDust(this, 12, 0.18f, 0.2f, 2, 13.0f, 20.0f); + if (EnGo_IsRollingOnGround(pthis, 3, 6.0f)) { + EnGo_SpawnDust(pthis, 12, 0.18f, 0.2f, 2, 13.0f, 20.0f); } } -void EnGo_FireGenericActionFunc(EnGo* this, GlobalContext* globalCtx) { +void EnGo_FireGenericActionFunc(EnGo* pthis, GlobalContext* globalCtx) { } -void EnGo_CurledUp(EnGo* this, GlobalContext* globalCtx) { - if ((DECR(this->unk_210) == 0) && EnGo_IsCameraModified(this, globalCtx)) { - Audio_PlaySoundGeneral(NA_SE_EN_GOLON_WAKE_UP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, +void EnGo_CurledUp(EnGo* pthis, GlobalContext* globalCtx) { + if ((DECR(pthis->unk_210) == 0) && EnGo_IsCameraModified(pthis, globalCtx)) { + Audio_PlaySoundGeneral(NA_SE_EN_GOLON_WAKE_UP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->skelAnime.playSpeed = 0.1f; - this->skelAnime.playSpeed *= (this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f; + pthis->skelAnime.playSpeed = 0.1f; + pthis->skelAnime.playSpeed *= (pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f; - EnGo_SetupAction(this, EnGo_WakeUp); - if ((this->actor.params & 0xF0) == 0x90) { - OnePointCutscene_Init(globalCtx, 4200, -99, &this->actor, MAIN_CAM); + EnGo_SetupAction(pthis, EnGo_WakeUp); + if ((pthis->actor.params & 0xF0) == 0x90) { + OnePointCutscene_Init(globalCtx, 4200, -99, &pthis->actor, MAIN_CAM); } } } -void EnGo_WakeUp(EnGo* this, GlobalContext* globalCtx) { +void EnGo_WakeUp(EnGo* pthis, GlobalContext* globalCtx) { f32 frame; - if (this->skelAnime.playSpeed != 0.0f) { - Math_SmoothStepToF(&this->skelAnime.playSpeed, ((this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f) * 0.5f, 0.1f, + if (pthis->skelAnime.playSpeed != 0.0f) { + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, ((pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f) * 0.5f, 0.1f, 1000.0f, 0.1f); - frame = this->skelAnime.curFrame; - frame += this->skelAnime.playSpeed; + frame = pthis->skelAnime.curFrame; + frame += pthis->skelAnime.playSpeed; if (frame <= 12.0f) { return; } else { - this->skelAnime.curFrame = 12.0f; - this->skelAnime.playSpeed = 0.0f; - if ((this->actor.params & 0xF0) != 0x90) { - this->unk_212 = 30; + pthis->skelAnime.curFrame = 12.0f; + pthis->skelAnime.playSpeed = 0.0f; + if ((pthis->actor.params & 0xF0) != 0x90) { + pthis->unk_212 = 30; return; } } } - if (DECR(this->unk_212) == 0) { - Audio_PlaySoundGeneral(NA_SE_EN_GOLON_SIT_DOWN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + if (DECR(pthis->unk_212) == 0) { + Audio_PlaySoundGeneral(NA_SE_EN_GOLON_SIT_DOWN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - EnGo_SetupAction(this, func_80A405CC); - } else if (!EnGo_IsCameraModified(this, globalCtx)) { - EnGo_ReverseAnimation(this); - this->skelAnime.playSpeed = 0.0f; - EnGo_SetupAction(this, func_80A40494); + EnGo_SetupAction(pthis, func_80A405CC); + } else if (!EnGo_IsCameraModified(pthis, globalCtx)) { + EnGo_ReverseAnimation(pthis); + pthis->skelAnime.playSpeed = 0.0f; + EnGo_SetupAction(pthis, func_80A40494); } } -void func_80A40494(EnGo* this, GlobalContext* globalCtx) { +void func_80A40494(EnGo* pthis, GlobalContext* globalCtx) { f32 frame; - Math_SmoothStepToF(&this->skelAnime.playSpeed, ((this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f) * -0.5f, 0.1f, + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, ((pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f) * -0.5f, 0.1f, 1000.0f, 0.1f); - frame = this->skelAnime.curFrame; - frame += this->skelAnime.playSpeed; + frame = pthis->skelAnime.curFrame; + frame += pthis->skelAnime.playSpeed; if (!(frame >= 0.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_DODO_M_GND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EN_DODO_M_GND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - EnGo_SpawnDust(this, 10, 0.4f, 0.1f, 16, 26.0f, 2.0f); - EnGo_ReverseAnimation(this); - this->skelAnime.playSpeed = 0.0f; - this->skelAnime.curFrame = 0.0f; - this->unk_210 = Rand_S16Offset(30, 30); - EnGo_SetupAction(this, EnGo_CurledUp); + EnGo_SpawnDust(pthis, 10, 0.4f, 0.1f, 16, 26.0f, 2.0f); + EnGo_ReverseAnimation(pthis); + pthis->skelAnime.playSpeed = 0.0f; + pthis->skelAnime.curFrame = 0.0f; + pthis->unk_210 = Rand_S16Offset(30, 30); + EnGo_SetupAction(pthis, EnGo_CurledUp); } } -void func_80A405CC(EnGo* this, GlobalContext* globalCtx) { +void func_80A405CC(EnGo* pthis, GlobalContext* globalCtx) { f32 lastFrame; f32 frame; lastFrame = Animation_GetLastFrame(&gGoronAnim_004930); - Math_SmoothStepToF(&this->skelAnime.playSpeed, (this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f, 0.1f, 1000.0f, + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, (pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f, 0.1f, 1000.0f, 0.1f); - frame = this->skelAnime.curFrame; - frame += this->skelAnime.playSpeed; + frame = pthis->skelAnime.curFrame; + frame += pthis->skelAnime.playSpeed; if (!(frame < lastFrame)) { - this->skelAnime.curFrame = lastFrame; - this->skelAnime.playSpeed = 0.0f; - this->unk_212 = Rand_S16Offset(30, 30); - if (((this->actor.params & 0xF0) == 0x40) && ((gSaveContext.infTable[14] & 0x800) == 0)) { - EnGo_SetupAction(this, func_80A40B1C); + pthis->skelAnime.curFrame = lastFrame; + pthis->skelAnime.playSpeed = 0.0f; + pthis->unk_212 = Rand_S16Offset(30, 30); + if (((pthis->actor.params & 0xF0) == 0x40) && ((gSaveContext.infTable[14] & 0x800) == 0)) { + EnGo_SetupAction(pthis, func_80A40B1C); } else { - EnGo_SetupAction(this, EnGo_BiggoronActionFunc); + EnGo_SetupAction(pthis, EnGo_BiggoronActionFunc); } } } -void EnGo_BiggoronActionFunc(EnGo* this, GlobalContext* globalCtx) { - if (((this->actor.params & 0xF0) == 0x90) && (this->unk_1E0.unk_00 == 2)) { +void EnGo_BiggoronActionFunc(EnGo* pthis, GlobalContext* globalCtx) { + if (((pthis->actor.params & 0xF0) == 0x90) && (pthis->unk_1E0.unk_00 == 2)) { if (gSaveContext.bgsFlag) { - this->unk_1E0.unk_00 = 0; + pthis->unk_1E0.unk_00 = 0; } else { if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_EYEDROPS) { - EnGo_ChangeAnimation(this, 2); - this->unk_21E = 100; - this->unk_1E0.unk_00 = 0; - EnGo_SetupAction(this, EnGo_Eyedrops); + EnGo_ChangeAnimation(pthis, 2); + pthis->unk_21E = 100; + pthis->unk_1E0.unk_00 = 0; + EnGo_SetupAction(pthis, EnGo_Eyedrops); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; gSaveContext.timer2State = 0; - OnePointCutscene_Init(globalCtx, 4190, -99, &this->actor, MAIN_CAM); + OnePointCutscene_Init(globalCtx, 4190, -99, &pthis->actor, MAIN_CAM); } else { - this->unk_1E0.unk_00 = 0; - EnGo_SetupAction(this, EnGo_GetItem); + pthis->unk_1E0.unk_00 = 0; + EnGo_SetupAction(pthis, EnGo_GetItem); Message_CloseTextbox(globalCtx); - EnGo_GetItem(this, globalCtx); + EnGo_GetItem(pthis, globalCtx); } } - } else if (((this->actor.params & 0xF0) == 0) && (this->unk_1E0.unk_00 == 2)) { - EnGo_SetupAction(this, EnGo_GetItem); + } else if (((pthis->actor.params & 0xF0) == 0) && (pthis->unk_1E0.unk_00 == 2)) { + EnGo_SetupAction(pthis, EnGo_GetItem); globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } else { - if ((DECR(this->unk_212) == 0) && !EnGo_IsCameraModified(this, globalCtx)) { - EnGo_ReverseAnimation(this); - this->skelAnime.playSpeed = -0.1f; - this->skelAnime.playSpeed *= (this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f; - EnGo_SetupAction(this, func_80A408D8); + if ((DECR(pthis->unk_212) == 0) && !EnGo_IsCameraModified(pthis, globalCtx)) { + EnGo_ReverseAnimation(pthis); + pthis->skelAnime.playSpeed = -0.1f; + pthis->skelAnime.playSpeed *= (pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f; + EnGo_SetupAction(pthis, func_80A408D8); } } } -void func_80A408D8(EnGo* this, GlobalContext* globalCtx) { +void func_80A408D8(EnGo* pthis, GlobalContext* globalCtx) { f32 frame; - if (this->skelAnime.playSpeed != 0.0f) { - Math_SmoothStepToF(&this->skelAnime.playSpeed, ((this->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f) * -1.0f, + if (pthis->skelAnime.playSpeed != 0.0f) { + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, ((pthis->actor.params & 0xF0) == 0x90 ? 0.5f : 1.0f) * -1.0f, 0.1f, 1000.0f, 0.1f); - frame = this->skelAnime.curFrame; - frame += this->skelAnime.playSpeed; + frame = pthis->skelAnime.curFrame; + frame += pthis->skelAnime.playSpeed; if (frame >= 12.0f) { return; } else { - this->skelAnime.curFrame = 12.0f; - this->skelAnime.playSpeed = 0.0f; - if ((this->actor.params & 0xF0) != 0x90) { - this->unk_212 = 30; + pthis->skelAnime.curFrame = 12.0f; + pthis->skelAnime.playSpeed = 0.0f; + if ((pthis->actor.params & 0xF0) != 0x90) { + pthis->unk_212 = 30; return; } } } - if (DECR(this->unk_212) == 0) { - EnGo_SetupAction(this, func_80A40494); - } else if (EnGo_IsCameraModified(this, globalCtx)) { - EnGo_ReverseAnimation(this); - Audio_PlaySoundGeneral(NA_SE_EN_GOLON_SIT_DOWN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + if (DECR(pthis->unk_212) == 0) { + EnGo_SetupAction(pthis, func_80A40494); + } else if (EnGo_IsCameraModified(pthis, globalCtx)) { + EnGo_ReverseAnimation(pthis); + Audio_PlaySoundGeneral(NA_SE_EN_GOLON_SIT_DOWN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->skelAnime.playSpeed = 0.0f; - EnGo_SetupAction(this, func_80A405CC); + pthis->skelAnime.playSpeed = 0.0f; + EnGo_SetupAction(pthis, func_80A405CC); } } -void func_80A40A54(EnGo* this, GlobalContext* globalCtx) { +void func_80A40A54(EnGo* pthis, GlobalContext* globalCtx) { f32 float1 = ((f32)0x8000 / Animation_GetLastFrame(&gGoronAnim_010590)); - f32 float2 = this->skelAnime.curFrame * float1; + f32 float2 = pthis->skelAnime.curFrame * float1; - this->actor.speedXZ = Math_SinS((s16)float2); - if (EnGo_FollowPath(this, globalCtx) && this->unk_218 == 0) { - EnGo_ChangeAnimation(this, 1); - this->skelAnime.curFrame = Animation_GetLastFrame(&gGoronAnim_004930); - this->actor.speedXZ = 0.0f; - EnGo_SetupAction(this, EnGo_BiggoronActionFunc); + pthis->actor.speedXZ = Math_SinS((s16)float2); + if (EnGo_FollowPath(pthis, globalCtx) && pthis->unk_218 == 0) { + EnGo_ChangeAnimation(pthis, 1); + pthis->skelAnime.curFrame = Animation_GetLastFrame(&gGoronAnim_004930); + pthis->actor.speedXZ = 0.0f; + EnGo_SetupAction(pthis, EnGo_BiggoronActionFunc); } } -void func_80A40B1C(EnGo* this, GlobalContext* globalCtx) { +void func_80A40B1C(EnGo* pthis, GlobalContext* globalCtx) { if (gSaveContext.infTable[14] & 0x800) { - EnGo_ChangeAnimation(this, 3); - EnGo_SetupAction(this, func_80A40A54); + EnGo_ChangeAnimation(pthis, 3); + EnGo_SetupAction(pthis, func_80A40A54); } else { - EnGo_BiggoronActionFunc(this, globalCtx); + EnGo_BiggoronActionFunc(pthis, globalCtx); } } -void EnGo_GetItem(EnGo* this, GlobalContext* globalCtx) { +void EnGo_GetItem(EnGo* pthis, GlobalContext* globalCtx) { f32 xzDist; f32 yDist; s32 getItemId; - if (Actor_HasParent(&this->actor, globalCtx)) { - this->unk_1E0.unk_00 = 2; - this->actor.parent = NULL; - EnGo_SetupAction(this, func_80A40C78); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->unk_1E0.unk_00 = 2; + pthis->actor.parent = NULL; + EnGo_SetupAction(pthis, func_80A40C78); } else { - this->unk_20C = 0; - if ((this->actor.params & 0xF0) == 0x90) { + pthis->unk_20C = 0; + if ((pthis->actor.params & 0xF0) == 0x90) { if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_CLAIM_CHECK) { getItemId = GI_SWORD_BGS; - this->unk_20C = 1; + pthis->unk_20C = 1; } if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_EYEDROPS) { getItemId = GI_CLAIM_CHECK; @@ -981,83 +981,83 @@ void EnGo_GetItem(EnGo* this, GlobalContext* globalCtx) { } } - if ((this->actor.params & 0xF0) == 0) { + if ((pthis->actor.params & 0xF0) == 0) { getItemId = GI_TUNIC_GORON; } - yDist = fabsf(this->actor.yDistToPlayer) + 1.0f; - xzDist = this->actor.xzDistToPlayer + 1.0f; - func_8002F434(&this->actor, globalCtx, getItemId, xzDist, yDist); + yDist = fabsf(pthis->actor.yDistToPlayer) + 1.0f; + xzDist = pthis->actor.xzDistToPlayer + 1.0f; + func_8002F434(&pthis->actor, globalCtx, getItemId, xzDist, yDist); } } -void func_80A40C78(EnGo* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 3) { - EnGo_SetupAction(this, EnGo_BiggoronActionFunc); - if ((this->actor.params & 0xF0) != 0x90) { - this->unk_1E0.unk_00 = 0; - } else if (this->unk_20C) { - this->unk_1E0.unk_00 = 0; +void func_80A40C78(EnGo* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 3) { + EnGo_SetupAction(pthis, EnGo_BiggoronActionFunc); + if ((pthis->actor.params & 0xF0) != 0x90) { + pthis->unk_1E0.unk_00 = 0; + } else if (pthis->unk_20C) { + pthis->unk_1E0.unk_00 = 0; gSaveContext.bgsFlag = true; } else if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_PRESCRIPTION) { - this->actor.textId = 0x3058; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E0.unk_00 = 1; + pthis->actor.textId = 0x3058; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E0.unk_00 = 1; } else if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_CLAIM_CHECK) { - this->actor.textId = 0x305C; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E0.unk_00 = 1; + pthis->actor.textId = 0x305C; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E0.unk_00 = 1; Environment_ClearBgsDayCount(); } } } -void EnGo_Eyedrops(EnGo* this, GlobalContext* globalCtx) { - if (DECR(this->unk_21E) == 0) { - this->actor.textId = 0x305A; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E0.unk_00 = 1; - EnGo_SetupAction(this, func_80A40DCC); +void EnGo_Eyedrops(EnGo* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->unk_21E) == 0) { + pthis->actor.textId = 0x305A; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E0.unk_00 = 1; + EnGo_SetupAction(pthis, func_80A40DCC); } } -void func_80A40DCC(EnGo* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 2) { - EnGo_ChangeAnimation(this, 1); - this->skelAnime.curFrame = Animation_GetLastFrame(&gGoronAnim_004930); +void func_80A40DCC(EnGo* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 2) { + EnGo_ChangeAnimation(pthis, 1); + pthis->skelAnime.curFrame = Animation_GetLastFrame(&gGoronAnim_004930); Message_CloseTextbox(globalCtx); - EnGo_SetupAction(this, EnGo_GetItem); - EnGo_GetItem(this, globalCtx); + EnGo_SetupAction(pthis, EnGo_GetItem); + EnGo_GetItem(pthis, globalCtx); } } void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnGo* this = (EnGo*)thisx; + EnGo* pthis = (EnGo*)thisx; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); - if (this->actionFunc == EnGo_BiggoronActionFunc || this->actionFunc == EnGo_FireGenericActionFunc || - this->actionFunc == func_80A40B1C) { - func_80034F54(globalCtx, this->jointTable, this->morphTable, 18); + if (pthis->actionFunc == EnGo_BiggoronActionFunc || pthis->actionFunc == EnGo_FireGenericActionFunc || + pthis->actionFunc == func_80A40B1C) { + func_80034F54(globalCtx, pthis->jointTable, pthis->morphTable, 18); } - EnGo_UpdateShadow(this); + EnGo_UpdateShadow(pthis); - if (this->unk_1E0.unk_00 == 0) { - Actor_MoveForward(&this->actor); + if (pthis->unk_1E0.unk_00 == 0) { + Actor_MoveForward(&pthis->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - func_80A3F0E4(this); - func_80A3F908(this, globalCtx); - this->actionFunc(this, globalCtx); - func_80A3F060(this, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + func_80A3F0E4(pthis); + func_80A3F908(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + func_80A3F060(pthis, globalCtx); } -void EnGo_DrawCurledUp(EnGo* this, GlobalContext* globalCtx) { +void EnGo_DrawCurledUp(EnGo* pthis, GlobalContext* globalCtx) { Vec3f D_80A41BB4 = { 0.0f, 0.0f, 0.0f }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2320); @@ -1070,38 +1070,38 @@ void EnGo_DrawCurledUp(EnGo* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gGoronDL_00BD80); - Matrix_MultVec3f(&D_80A41BB4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A41BB4, &pthis->actor.focus.pos); Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2341); } -void EnGo_DrawRolling(EnGo* this, GlobalContext* globalCtx) { +void EnGo_DrawRolling(EnGo* pthis, GlobalContext* globalCtx) { Vec3f D_80A41BC0 = { 0.0f, 0.0f, 0.0f }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2355); Matrix_Push(); func_80093D18(globalCtx->state.gfxCtx); - Matrix_RotateZYX((s16)(globalCtx->state.frames * ((s16)this->actor.speedXZ * 1400)), 0, this->actor.shape.rot.z, + Matrix_RotateZYX((s16)(globalCtx->state.frames * ((s16)pthis->actor.speedXZ * 1400)), 0, pthis->actor.shape.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go.c", 2368), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gGoronDL_00C140); - Matrix_MultVec3f(&D_80A41BC0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A41BC0, &pthis->actor.focus.pos); Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2383); } s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnGo* this = (EnGo*)thisx; + EnGo* pthis = (EnGo*)thisx; Vec3s vec1; f32 float1; if (limb == 17) { Matrix_Translate(2800.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec1 = this->unk_1E0.unk_08; + vec1 = pthis->unk_1E0.unk_08; float1 = (vec1.y / (f32)0x8000) * M_PI; Matrix_RotateX(float1, MTXMODE_APPLY); float1 = (vec1.x / (f32)0x8000) * M_PI; @@ -1110,7 +1110,7 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f } if (limb == 10) { - vec1 = this->unk_1E0.unk_0E; + vec1 = pthis->unk_1E0.unk_0E; float1 = (vec1.y / (f32)0x8000) * M_PI; Matrix_RotateY(float1, MTXMODE_APPLY); float1 = (vec1.x / (f32)0x8000) * M_PI; @@ -1118,9 +1118,9 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f } if ((limb == 10) || (limb == 11) || (limb == 14)) { - float1 = Math_SinS(this->jointTable[limb]); + float1 = Math_SinS(pthis->jointTable[limb]); rot->y += float1 * 200.0f; - float1 = Math_CosS(this->morphTable[limb]); + float1 = Math_CosS(pthis->morphTable[limb]); rot->z += float1 * 200.0f; } @@ -1128,30 +1128,30 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f } void EnGo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnGo* this = (EnGo*)thisx; + EnGo* pthis = (EnGo*)thisx; Vec3f D_80A41BCC = { 600.0f, 0.0f, 0.0f }; if (limbIndex == 17) { - Matrix_MultVec3f(&D_80A41BCC, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A41BCC, &pthis->actor.focus.pos); } } void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGo* this = (EnGo*)thisx; + EnGo* pthis = (EnGo*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2479); - EnGo_UpdateDust(this); + EnGo_UpdateDust(pthis); Matrix_Push(); - EnGo_DrawDust(this, globalCtx); + EnGo_DrawDust(pthis, globalCtx); Matrix_Pop(); - if (this->actionFunc == EnGo_CurledUp) { - EnGo_DrawCurledUp(this, globalCtx); + if (pthis->actionFunc == EnGo_CurledUp) { + EnGo_DrawCurledUp(pthis, globalCtx); return; // needed for match? - } else if (this->actionFunc == EnGo_GoronLinkRolling || this->actionFunc == func_80A3FEB4 || - this->actionFunc == EnGo_StopRolling || this->actionFunc == func_80A3FEB4) { - EnGo_DrawRolling(this, globalCtx); + } else if (pthis->actionFunc == EnGo_GoronLinkRolling || pthis->actionFunc == func_80A3FEB4 || + pthis->actionFunc == EnGo_StopRolling || pthis->actionFunc == func_80A3FEB4) { + EnGo_DrawRolling(pthis, globalCtx); return; // needed for match? } else { func_800943C8(globalCtx->state.gfxCtx); @@ -1159,19 +1159,19 @@ void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gGoronCsEyeOpenTex)); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gGoronCsMouthNeutralTex)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnGo_OverrideLimbDraw, EnGo_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnGo_OverrideLimbDraw, EnGo_PostLimbDraw, &pthis->actor); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go.c", 2525); - EnGo_DrawDust(this, globalCtx); + EnGo_DrawDust(pthis, globalCtx); } } -void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo_AddDust(EnGo* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { + EnGoEffect* dustEffect = pthis->dustEffects; s16 i; s16 timer; - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < ARRAY_COUNT(pthis->dustEffects); i++, dustEffect++) { if (dustEffect->type != 1) { dustEffect->scale = scale; dustEffect->scaleStep = scaleStep; @@ -1188,12 +1188,12 @@ void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 init } } -void EnGo_UpdateDust(EnGo* this) { - EnGoEffect* dustEffect = this->dustEffects; +void EnGo_UpdateDust(EnGo* pthis) { + EnGoEffect* dustEffect = pthis->dustEffects; f32 randomNumber; s16 i; - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < ARRAY_COUNT(pthis->dustEffects); i++, dustEffect++) { if (dustEffect->type) { dustEffect->timer--; if (dustEffect->timer == 0) { @@ -1214,9 +1214,9 @@ void EnGo_UpdateDust(EnGo* this) { } } -void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx) { +void EnGo_DrawDust(EnGo* pthis, GlobalContext* globalCtx) { static void* dustTex[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex }; - EnGoEffect* dustEffect = this->dustEffects; + EnGoEffect* dustEffect = pthis->dustEffects; s16 alpha; s16 firstDone; s16 index; @@ -1226,7 +1226,7 @@ void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx) { firstDone = false; func_80093D84(globalCtx->state.gfxCtx); if (1) {} - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { + for (i = 0; i < ARRAY_COUNT(pthis->dustEffects); i++, dustEffect++) { if (dustEffect->type) { if (!firstDone) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/src/overlays/actors/ovl_En_Go2/z_en_go2.c deleted file mode 100644 index 684dd8cd8..000000000 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ /dev/null @@ -1,2073 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GO2_Z_EN_GO2_C -#include "actor_common.h" -#include "z_en_go2.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" -#include "def/code_8006BA00.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_path.h" -#include "def/z_play.h" -#include "def/z_quake.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -/* -FLAGS - -gSaveContext.eventChkInf[2] & 0x8 - DC entrance boulder blown up as child - -InfTable - -gSaveContext.infTable[11] & 0x10 -gSaveContext.infTable[14] & 0x1 - Talked to DMT Goron at DC entrance (Before DC is opened as child) -gSaveContext.infTable[14] & 0x8 - Talked to GC Goron in bottom level stairwell -gSaveContext.infTable[14] & 0x40 - Talked to GC Goron at LW entrance (Before LW shortcut is opened) -gSaveContext.infTable[14] & 0x800 - Talked to DMT Goron at Bomb Flower with goron bracelet -gSaveContext.infTable[15] & 0x1 - Talked to Goron at GC Entrance (Before goron ruby is obtained) -gSaveContext.infTable[15] & 0x10 - Talked to Goron at GC Island (Before goron ruby is obtained) -gSaveContext.infTable[15] & 0x100 - (not on cloud modding) Talked to GC Goron outside Darunias door (after opening door, -before getting goron bracelet) gSaveContext.infTable[16] & 0x200 - Obtained Fire Tunic from Goron Link -gSaveContext.infTable[16] & 0x400 - (not on cloud modding) -gSaveContext.infTable[16] & 0x800 - Spoke to Goron Link About Volvagia -gSaveContext.infTable[16] & 0x1000 - Stopped Goron Link's Rolling -gSaveContext.infTable[16] & 0x2000 - EnGo Exclusive -gSaveContext.infTable[16] & 0x4000 - Spoke to Goron Link -gSaveContext.infTable[16] & 0x8000 - (not on cloud modding) - -gSaveContext.infTable[17] & 0x4000 - Bomb bag upgrade obtained from rolling Goron - -EnGo -pathIndex: this->actor.params & 0xF -Goron: this->actor.params & 0xF0 - -EnGo2 -(this->actor.params & 0x3E0) >> 5 -(this->actor.params & 0xFC00) >> 0xA - Gorons in Fire Temple -this->actor.params & 0x1F - -Gorons only move when this->unk_194.unk_00 == 0 -*/ - -void EnGo2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGo2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGo2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGo2_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnGo2_StopRolling(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_CurledUp(EnGo2* this, GlobalContext* globalCtx); - -void func_80A46B40(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_GoronDmtBombFlowerAnimation(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_GoronRollingBigContinueRolling(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_ContinueRolling(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_SlowRolling(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_GroundRolling(EnGo2* this, GlobalContext* globalCtx); - -void EnGo2_ReverseRolling(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_SetupGetItem(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_SetGetItem(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_BiggoronEyedrops(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_GoronLinkStopRolling(EnGo2* this, GlobalContext* globalCtx); -void EnGo2_GoronFireGenericAction(EnGo2* this, GlobalContext* globalCtx); - -static void* sDustTex[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex }; - -static Vec3f sPos = { 0.0f, 0.0f, 0.0f }; -static Vec3f sVelocity = { 0.0f, 0.0f, 0.0f }; -static Vec3f sAccel = { 0.0f, 0.3f, 0.0f }; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000008, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 40, 65, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { - 0, 0, 0, 0, MASS_IMMOVABLE, -}; - -const ActorInit En_Go2_InitVars = { - ACTOR_EN_GO2, - ACTORCAT_NPC, - FLAGS, - OBJECT_OF1D_MAP, - sizeof(EnGo2), - (ActorFunc)EnGo2_Init, - (ActorFunc)EnGo2_Destroy, - (ActorFunc)EnGo2_Update, - (ActorFunc)EnGo2_Draw, -}; - -static EnGo2DataStruct1 D_80A4816C[14] = { - { 0, 0, 0, 68, 148 }, { 0, 0, 0, 24, 52 }, { 0, 320, 380, 400, 120 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 46, 90 }, - { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, - { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, -}; - -static EnGo2DataStruct2 D_80A481F8[14] = { - { 30.0f, 0.026f, 6, 60.0f }, { 24.0f, 0.008f, 6, 30.0f }, { 28.0f, 0.16f, 5, 380.0f }, { 28.0f, 0.01f, 7, 40.0f }, - { 30.0f, 0.015f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, - { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, - { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, -}; - -static f32 D_80A482D8[14][2] = { - { 80.0f, 80.0f }, { -10.0f, -10.0f }, { 800.0f, 800.0f }, { 0.0f, 0.0f }, { 20.0f, 40.0f }, - { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, - { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, -}; - -static struct_80034EC0_Entry sAnimations[] = { - { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x00, 0.0f }, { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x00, -8.0f }, - { &gGoronAnim_0029A8, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_010590, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, - { &gGoronAnim_003768, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_0038E4, 1.0f, 0.0f, -1.0f, 0x02, -8.0f }, - { &gGoronAnim_002D80, 1.0f, 0.0f, -1.0f, 0x02, -8.0f }, { &gGoronAnim_00161C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, - { &gGoronAnim_001A00, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_0021D0, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, - { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x01, -8.0f }, { &gGoronAnim_000750, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, - { &gGoronAnim_000D5C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, -}; - -static EnGo2DustEffectData sDustEffectData[2][4] = { - { - { 12, 0.2f, 0.2f, 1, 18.0f, 0.0f }, - { 12, 0.1f, 0.2f, 12, 26.0f, 0.0f }, - { 12, 0.1f, 0.3f, 4, 10.0f, 0.0f }, - { 12, 0.2f, 0.2f, 1, 18.0f, 0.0f }, - }, - { - { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, - { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, - { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, - { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, - }, -}; - -static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; - -void EnGo2_AddDust(EnGo2* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { - EnGoEffect* dustEffect = this->dustEffects; - s16 i; - s16 timer; - - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { - if (dustEffect->type != 1) { - dustEffect->scale = scale; - dustEffect->scaleStep = scaleStep; - if (1) {} - timer = initialTimer; - dustEffect->timer = timer; - dustEffect->type = 1; - dustEffect->initialTimer = initialTimer; - dustEffect->pos = *pos; - dustEffect->accel = *accel; - dustEffect->velocity = *velocity; - return; - } - } -} - -void EnGo2_UpdateDust(EnGo2* this) { - EnGoEffect* dustEffect = this->dustEffects; - f32 randomNumber; - s16 i; - - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { - if (dustEffect->type) { - dustEffect->timer--; - if (dustEffect->timer == 0) { - dustEffect->type = 0; - } - dustEffect->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; - randomNumber = Rand_ZeroOne() * 0.4f; - dustEffect->accel.z = randomNumber - 0.2f; - dustEffect->pos.x += dustEffect->velocity.x; - dustEffect->pos.y += dustEffect->velocity.y; - dustEffect->pos.z += dustEffect->velocity.z; - dustEffect->velocity.x += dustEffect->accel.x; - dustEffect->velocity.y += dustEffect->accel.y; - dustEffect->velocity.z += randomNumber - 0.2f; - dustEffect->scale += dustEffect->scaleStep; - } - } -} - -void EnGo2_DrawDust(EnGo2* this, GlobalContext* globalCtx) { - EnGoEffect* dustEffect = this->dustEffects; - s16 alpha; - s16 firstDone; - s16 index; - s16 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 111); - - firstDone = false; - func_80093D84(globalCtx->state.gfxCtx); - if (1) {} - - for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { - if (dustEffect->type) { - if (!firstDone) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD40); - gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); - firstDone = true; - } - - alpha = dustEffect->timer * (255.0f / dustEffect->initialTimer); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); - gDPPipeSync(POLY_XLU_DISP++); - Matrix_Translate(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(dustEffect->scale, dustEffect->scale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 137), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - index = dustEffect->timer * (8.0f / dustEffect->initialTimer); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sDustTex[index])); - gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD50); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 151); -} - -s32 EnGo2_SpawnDust(EnGo2* this, u8 initialTimer, f32 scale, f32 scaleStep, s32 numDustEffects, f32 radius, - f32 yAccel) { - Vec3f pos = sPos; - Vec3f velocity = sVelocity; - Vec3f accel = sAccel; - s32 i; - s16 angle; - - pos = this->actor.world.pos; // overwrites sPos data - pos.y = this->actor.floorHeight; - angle = (Rand_ZeroOne() - 0.5f) * 0x10000; - i = numDustEffects; - while (i >= 0) { - accel.y += Rand_ZeroOne() * yAccel; - pos.x = (Math_SinS(angle) * radius) + this->actor.world.pos.x; - pos.z = (Math_CosS(angle) * radius) + this->actor.world.pos.z; - EnGo2_AddDust(this, &pos, &velocity, &accel, initialTimer, scale, scaleStep); - angle += (s16)(0x10000 / numDustEffects); - i--; - } - return 0; -} - -void EnGo2_GetItem(EnGo2* this, GlobalContext* globalCtx, s32 getItemId) { - this->getItemId = getItemId; - func_8002F434(&this->actor, globalCtx, getItemId, this->actor.xzDistToPlayer + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); -} - -s32 EnGo2_GetDialogState(EnGo2* this, GlobalContext* globalCtx) { - s16 dialogState = Message_GetState(&globalCtx->msgCtx); - - if ((this->dialogState == TEXT_STATE_AWAITING_NEXT) || (this->dialogState == TEXT_STATE_EVENT) || - (this->dialogState == TEXT_STATE_CLOSING) || (this->dialogState == TEXT_STATE_DONE_HAS_NEXT)) { - if (dialogState != this->dialogState) { - this->unk_20C++; - } - } - - this->dialogState = dialogState; - return dialogState; -} - -u16 EnGo2_GoronFireGenericGetTextId(EnGo2* this) { - switch ((this->actor.params & 0xFC00) >> 0xA) { - case 3: - return 0x3069; - case 5: - return 0x306A; - case 4: - return 0x306B; - case 2: - return 0x306C; - case 10: - return 0x306D; - case 8: - return 0x306E; - case 11: - return 0x306F; - case 1: - return 0x3070; - default: - return 0x3052; - } -} - -u16 EnGo2_GetTextIdGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* this) { - if (gSaveContext.infTable[17] & 0x4000) { - return 0x3013; - } else if (CUR_CAPACITY(UPG_BOMB_BAG) >= 20 && this->waypoint > 7 && this->waypoint < 12) { - return 0x3012; - } else { - return 0x3011; - } -} - -s16 EnGo2_GetStateGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* this) { - s32 bombBagUpgrade; - - switch (Message_GetState(&globalCtx->msgCtx)) { - case TEXT_STATE_CLOSING: - return 2; - case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx)) { - if (this->actor.textId == 0x3012) { - this->actionFunc = EnGo2_SetupGetItem; - bombBagUpgrade = CUR_CAPACITY(UPG_BOMB_BAG) == 30 ? GI_BOMB_BAG_40 : GI_BOMB_BAG_30; - EnGo2_GetItem(this, globalCtx, bombBagUpgrade); - Message_CloseTextbox(globalCtx); - gSaveContext.infTable[17] |= 0x4000; - return 2; - } else { - return 2; - } - } - default: - return 1; - } -} - -u16 EnGo2_GetTextIdGoronDmtBombFlower(GlobalContext* globalCtx, EnGo2* this) { - return CHECK_QUEST_ITEM(QUEST_GORON_RUBY) ? 0x3027 : 0x300A; -} - -// DMT Goron by Bomb Flower Choice -s16 EnGo2_GetStateGoronDmtBombFlower(GlobalContext* globalCtx, EnGo2* this) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case TEXT_STATE_CLOSING: - if ((this->actor.textId == 0x300B) && (gSaveContext.infTable[14] & 0x800) == 0) { - gSaveContext.infTable[14] |= 0x800; - return 2; - } else { - return 0; - } - case TEXT_STATE_CHOICE: - if (Message_ShouldAdvance(globalCtx)) { - // Ask question to DMT Goron by bomb flower - if (this->actor.textId == 0x300A) { - if (globalCtx->msgCtx.choiceIndex == 0) { - this->actor.textId = CUR_UPG_VALUE(UPG_STRENGTH) != 0 ? 0x300B : 0x300C; - } else { - this->actor.textId = 0x300D; - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - } - return 1; - } - default: - return 1; - } -} - -u16 EnGo2_GetTextIdGoronDmtRollingSmall(GlobalContext* globalCtx, EnGo2* this) { - if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - return 0x3027; - } else { - return (gSaveContext.eventChkInf[2] & 0x8) ? 0x3026 : 0x3009; - } -} - -s16 EnGo2_GetStateGoronDmtRollingSmall(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextIdGoronDmtDcEntrance(GlobalContext* globalCtx, EnGo2* this) { - if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { - return 0x3043; - } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - return 0x3027; - } else { - return gSaveContext.eventChkInf[2] & 0x8 ? 0x3021 : gSaveContext.infTable[14] & 0x1 ? 0x302A : 0x3008; - } -} - -s16 EnGo2_GetStateGoronDmtDcEntrance(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->actor.textId == 0x3008) { - gSaveContext.infTable[14] |= 0x1; - } - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextIdGoronCityEntrance(GlobalContext* globalCtx, EnGo2* this) { - if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { - return 0x3043; - } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - return 0x3027; - } else { - return gSaveContext.infTable[15] & 0x1 ? 0x3015 : 0x3014; - } -} - -s16 EnGo2_GetStateGoronCityEntrance(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->actor.textId == 0x3014) { - gSaveContext.infTable[15] |= 0x1; - } - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextIdGoronCityIsland(GlobalContext* globalCtx, EnGo2* this) { - if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { - return 0x3043; - } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - return 0x3067; - } else { - return gSaveContext.infTable[15] & 0x10 ? 0x3017 : 0x3016; - } -} - -s16 EnGo2_GetStateGoronCityIsland(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->actor.textId == 0x3016) { - gSaveContext.infTable[15] |= 0x10; - } - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextIdGoronCityLowestFloor(GlobalContext* globalCtx, EnGo2* this) { - if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { - return 0x3043; - } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - return 0x3027; - } else { - return CUR_UPG_VALUE(UPG_STRENGTH) != 0 ? 0x302C - : !Flags_GetSwitch(globalCtx, 0x1B) ? 0x3017 - : gSaveContext.infTable[15] & 0x100 ? 0x3019 - : 0x3018; - } -} - -s16 EnGo2_GetStateGoronCityLowestFloor(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->actor.textId == 0x3018) { - gSaveContext.infTable[15] |= 0x100; - } - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextIdGoronCityLink(GlobalContext* globalCtx, EnGo2* this) { - if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) { - return gSaveContext.infTable[16] & 0x8000 ? 0x3042 : 0x3041; - } else if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { - return gSaveContext.infTable[16] & 0x4000 ? 0x3038 : 0x3037; - } else if (gSaveContext.infTable[16] & 0x1000) { - this->unk_20C = 0; - this->dialogState = TEXT_STATE_NONE; - return gSaveContext.infTable[16] & 0x400 ? 0x3033 : 0x3032; - } else { - return 0x3030; - } -} - -s16 EnGo2_GetStateGoronCityLink(GlobalContext* globalCtx, EnGo2* this) { - switch (EnGo2_GetDialogState(this, globalCtx)) { - case TEXT_STATE_CLOSING: - switch (this->actor.textId) { - case 0x3036: - EnGo2_GetItem(this, globalCtx, GI_TUNIC_GORON); - this->actionFunc = EnGo2_SetupGetItem; - return 2; - case 0x3037: - gSaveContext.infTable[16] |= 0x4000; - default: - return 0; - } - case TEXT_STATE_CHOICE: - if (Message_ShouldAdvance(globalCtx)) { - if (this->actor.textId == 0x3034) { - if (globalCtx->msgCtx.choiceIndex == 0) { - this->actor.textId = gSaveContext.infTable[16] & 0x800 ? 0x3033 : 0x3035; - if (this->actor.textId == 0x3035) { - Audio_StopSfxById(NA_SE_EN_GOLON_CRY); - } - } else { - this->actor.textId = gSaveContext.infTable[16] & 0x800 ? 0x3036 : 0x3033; - if (this->actor.textId == 0x3036) { - Audio_StopSfxById(NA_SE_EN_GOLON_CRY); - } - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_20C = 0; - } - } else { - break; - } - return 1; - case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx)) { - switch (this->actor.textId) { - case 0x3035: - gSaveContext.infTable[16] |= 0x800; - case 0x3032: - case 0x3033: - this->actor.textId = 0x3034; - Message_ContinueTextbox(globalCtx, this->actor.textId); - return 1; - default: - return 2; - } - } - } - return 1; -} - -u16 EnGo2_GetTextIdGoronDmtBiggoron(GlobalContext* globalCtx, EnGo2* this) { - Player* player = GET_PLAYER(globalCtx); - - if (gSaveContext.bgsFlag) { - player->exchangeItemId = EXCH_ITEM_CLAIM_CHECK; - return 0x305E; - } else if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_CLAIM_CHECK) { - player->exchangeItemId = EXCH_ITEM_CLAIM_CHECK; - return 0x305E; - } else if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_PRESCRIPTION) { - player->exchangeItemId = EXCH_ITEM_EYEDROPS; - return 0x3058; - } else { - player->exchangeItemId = EXCH_ITEM_SWORD_BROKEN; - return 0x3053; - } -} - -s16 EnGo2_GetStateGoronDmtBiggoron(GlobalContext* globalCtx, EnGo2* this) { - s32 unusedPad; - u8 dialogState = this->dialogState; - - switch (EnGo2_GetDialogState(this, globalCtx)) { - case TEXT_STATE_DONE: - if (this->actor.textId == 0x305E) { - if (!gSaveContext.bgsFlag) { - EnGo2_GetItem(this, globalCtx, GI_SWORD_BGS); - this->actionFunc = EnGo2_SetupGetItem; - return 2; - } else { - return 0; - } - } else { - return 0; - } - case TEXT_STATE_DONE_FADING: - switch (this->actor.textId) { - case 0x305E: - if (func_8002F368(globalCtx) != EXCH_ITEM_CLAIM_CHECK) { - break; - } - case 0x3059: - if (dialogState == TEXT_STATE_NONE) { - func_800F4524(&D_801333D4, NA_SE_EN_GOLON_WAKE_UP, 60); - } - case 0x3054: - if (dialogState == TEXT_STATE_NONE) { - Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - return 1; - case TEXT_STATE_CHOICE: - if (Message_ShouldAdvance(globalCtx)) { - if ((this->actor.textId == 0x3054) || (this->actor.textId == 0x3055)) { - if (globalCtx->msgCtx.choiceIndex == 0) { - EnGo2_GetItem(this, globalCtx, GI_PRESCRIPTION); - this->actionFunc = EnGo2_SetupGetItem; - return 2; - } - this->actor.textId = 0x3056; - Message_ContinueTextbox(globalCtx, this->actor.textId); - } - return 1; - } - break; - case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx)) { - if (this->actor.textId == 0x3059) { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actionFunc = EnGo2_BiggoronEyedrops; - } - return 2; - } - } - return 1; -} - -u16 EnGo2_GetTextIdGoronFireGeneric(GlobalContext* globalCtx, EnGo2* this) { - if (Flags_GetSwitch(globalCtx, (this->actor.params & 0xFC00) >> 0xA)) { - return 0x3071; - } else { - return 0x3051; - } -} - -s16 EnGo2_GetStateGoronFireGeneric(GlobalContext* globalCtx, EnGo2* this) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case TEXT_STATE_CLOSING: - return 0; - case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx)) { - if (this->actor.textId == 0x3071) { - this->actor.textId = EnGo2_GoronFireGenericGetTextId(this); - Message_ContinueTextbox(globalCtx, this->actor.textId); - } - return 1; - } - default: - return 1; - } -} - -u16 EnGo2_GetTextIdGoronCityStairwell(GlobalContext* globalCtx, EnGo2* this) { - return !LINK_IS_ADULT ? gSaveContext.infTable[14] & 0x8 ? 0x3022 : 0x300E : 0x3043; -} - -s16 EnGo2_GetStateGoronCityStairwell(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->actor.textId == 0x300E) { - gSaveContext.infTable[14] |= 0x8; - } - return 0; - } else { - return 1; - } -} - -// Goron in child market bazaar after obtaining Goron Ruby -u16 EnGo2_GetTextIdGoronMarketBazaar(GlobalContext* globalCtx, EnGo2* this) { - return 0x7122; -} - -s16 EnGo2_GetStateGoronMarketBazaar(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextIdGoronCityLostWoods(GlobalContext* globalCtx, EnGo2* this) { - if (!LINK_IS_ADULT) { - if (Flags_GetSwitch(globalCtx, 0x1C)) { - return 0x302F; - } else { - return gSaveContext.infTable[14] & 0x40 ? 0x3025 : 0x3024; - } - } else { - return 0x3043; - } -} - -s16 EnGo2_GetStateGoronCityLostWoods(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->actor.textId == 0x3024) { - gSaveContext.infTable[14] |= 0x40; - } - return 0; - } else { - return 1; - } -} - -// Goron at base of DMT summit -u16 EnGo2_GetTextIdGoronDmtFairyHint(GlobalContext* globalCtx, EnGo2* this) { - if (!LINK_IS_ADULT) { - return CHECK_QUEST_ITEM(QUEST_GORON_RUBY) ? 0x3065 : 0x3064; - } else { - return 0x3043; - } -} - -s16 EnGo2_GetStateGoronDmtFairyHint(GlobalContext* globalCtx, EnGo2* this) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - return 0; - } else { - return 1; - } -} - -u16 EnGo2_GetTextId(GlobalContext* globalCtx, Actor* thisx) { - EnGo2* this = (EnGo2*)thisx; - u16 faceReaction = Text_GetFaceReaction(globalCtx, 0x20); - - if (faceReaction) { - return faceReaction; - } else { - switch (this->actor.params & 0x1F) { - case GORON_CITY_ROLLING_BIG: - return EnGo2_GetTextIdGoronCityRollingBig(globalCtx, this); - case GORON_CITY_LINK: - return EnGo2_GetTextIdGoronCityLink(globalCtx, this); - case GORON_DMT_BIGGORON: - return EnGo2_GetTextIdGoronDmtBiggoron(globalCtx, this); - case GORON_FIRE_GENERIC: - return EnGo2_GetTextIdGoronFireGeneric(globalCtx, this); - case GORON_DMT_BOMB_FLOWER: - return EnGo2_GetTextIdGoronDmtBombFlower(globalCtx, this); - case GORON_DMT_ROLLING_SMALL: - return EnGo2_GetTextIdGoronDmtRollingSmall(globalCtx, this); - case GORON_DMT_DC_ENTRANCE: - return EnGo2_GetTextIdGoronDmtDcEntrance(globalCtx, this); - case GORON_CITY_ENTRANCE: - return EnGo2_GetTextIdGoronCityEntrance(globalCtx, this); - case GORON_CITY_ISLAND: - return EnGo2_GetTextIdGoronCityIsland(globalCtx, this); - case GORON_CITY_LOWEST_FLOOR: - return EnGo2_GetTextIdGoronCityLowestFloor(globalCtx, this); - case GORON_CITY_STAIRWELL: - return EnGo2_GetTextIdGoronCityStairwell(globalCtx, this); - case GORON_CITY_LOST_WOODS: - return EnGo2_GetTextIdGoronCityLostWoods(globalCtx, this); - case GORON_DMT_FAIRY_HINT: - return EnGo2_GetTextIdGoronDmtFairyHint(globalCtx, this); - case GORON_MARKET_BAZAAR: - return EnGo2_GetTextIdGoronMarketBazaar(globalCtx, this); - } - } - return 0; -} - -s16 EnGo2_GetState(GlobalContext* globalCtx, Actor* thisx) { - EnGo2* this = (EnGo2*)thisx; - switch (this->actor.params & 0x1F) { - case GORON_CITY_ROLLING_BIG: - return EnGo2_GetStateGoronCityRollingBig(globalCtx, this); - case GORON_CITY_LINK: - return EnGo2_GetStateGoronCityLink(globalCtx, this); - case GORON_DMT_BIGGORON: - return EnGo2_GetStateGoronDmtBiggoron(globalCtx, this); - case GORON_FIRE_GENERIC: - return EnGo2_GetStateGoronFireGeneric(globalCtx, this); - case GORON_DMT_BOMB_FLOWER: - return EnGo2_GetStateGoronDmtBombFlower(globalCtx, this); - case GORON_DMT_ROLLING_SMALL: - return EnGo2_GetStateGoronDmtRollingSmall(globalCtx, this); - case GORON_DMT_DC_ENTRANCE: - return EnGo2_GetStateGoronDmtDcEntrance(globalCtx, this); - case GORON_CITY_ENTRANCE: - return EnGo2_GetStateGoronCityEntrance(globalCtx, this); - case GORON_CITY_ISLAND: - return EnGo2_GetStateGoronCityIsland(globalCtx, this); - case GORON_CITY_LOWEST_FLOOR: - return EnGo2_GetStateGoronCityLowestFloor(globalCtx, this); - case GORON_CITY_STAIRWELL: - return EnGo2_GetStateGoronCityStairwell(globalCtx, this); - case GORON_CITY_LOST_WOODS: - return EnGo2_GetStateGoronCityLostWoods(globalCtx, this); - case GORON_DMT_FAIRY_HINT: - return EnGo2_GetStateGoronDmtFairyHint(globalCtx, this); - case GORON_MARKET_BAZAAR: - return EnGo2_GetStateGoronMarketBazaar(globalCtx, this); - } - return 0; -} - -s32 func_80A44790(EnGo2* this, GlobalContext* globalCtx) { - if ((this->actor.params & 0x1F) != GORON_DMT_BIGGORON && (this->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG) { - return func_800343CC(globalCtx, &this->actor, &this->unk_194.unk_00, this->unk_218, EnGo2_GetTextId, - EnGo2_GetState); - } else if (((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) && ((this->collider.base.ocFlags2 & 1) == 0)) { - return false; - } else { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_194.unk_00 = 1; - return true; - } else if (this->unk_194.unk_00 != 0) { - this->unk_194.unk_00 = EnGo2_GetState(globalCtx, &this->actor); - return false; - } else if (func_8002F2CC(&this->actor, globalCtx, this->unk_218)) { - this->actor.textId = EnGo2_GetTextId(globalCtx, &this->actor); - } - return false; - } -} - -void EnGo2_SetColliderDim(EnGo2* this) { - u8 index = this->actor.params & 0x1F; - - this->collider.dim.radius = D_80A4816C[index].radius; - this->collider.dim.height = D_80A4816C[index].height; -} - -void EnGo2_SetShape(EnGo2* this) { - u8 index = this->actor.params & 0x1F; - - this->actor.shape.shadowScale = D_80A481F8[index].shape_unk_10; - Actor_SetScale(&this->actor, D_80A481F8[index].scale); - this->actor.targetMode = D_80A481F8[index].actor_unk_1F; - this->unk_218 = D_80A481F8[index].unk_218; - this->unk_218 += this->collider.dim.radius; -} - -void EnGo2_CheckCollision(EnGo2* this, GlobalContext* globalCtx) { - Vec3s pos; - f32 xzDist; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z; - xzDist = D_80A4816C[this->actor.params & 0x1F].xzDist; - pos.x += (s16)(xzDist * Math_SinS(this->actor.shape.rot.y)); - pos.z += (s16)(xzDist * Math_CosS(this->actor.shape.rot.y)); - pos.y += D_80A4816C[this->actor.params & 0x1F].yDist; - this->collider.dim.pos = pos; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnGo2_SwapInitialFrameAnimFrameCount(EnGo2* this) { - f32 initialFrame; - - initialFrame = this->skelAnime.startFrame; - this->skelAnime.startFrame = this->skelAnime.endFrame; - this->skelAnime.endFrame = initialFrame; -} - -s32 func_80A44AB0(EnGo2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 arg2; - - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - return false; - } else { - if ((this->actionFunc != EnGo2_SlowRolling) && (this->actionFunc != EnGo2_ReverseRolling) && - (this->actionFunc != EnGo2_ContinueRolling)) { - return false; - } else { - if (this->collider.base.acFlags & 2) { - Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->actor.flags &= ~ACTOR_FLAG_24; - this->collider.base.acFlags &= ~0x2; - EnGo2_StopRolling(this, globalCtx); - return true; - } - if (player->invincibilityTimer <= 0) { - this->collider.base.ocFlags1 |= 8; - } else { - return false; - } - if (this->collider.base.ocFlags2 & 1) { - this->collider.base.ocFlags2 &= ~1; - - arg2 = this->actionFunc == EnGo2_ContinueRolling ? 1.5f : this->actor.speedXZ * 1.5f; - - globalCtx->damagePlayer(globalCtx, -4); - func_8002F71C(globalCtx, &this->actor, arg2, this->actor.yawTowardsPlayer, 6.0f); - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - this->collider.base.ocFlags1 &= ~0x8; - } - } - } - return false; -} - -s32 EnGo2_UpdateWaypoint(EnGo2* this, GlobalContext* globalCtx) { - s32 change; - - if (this->path == NULL) { - return 0; - } - - change = (u8)(this->path->count - 1); - if (this->reverse) { - this->waypoint--; - if (this->waypoint < 0) { - this->waypoint = change - 1; - } - } else { - this->waypoint++; - if (this->waypoint >= change) { - this->waypoint = 0; - } - } - - return 1; -} - -s32 EnGo2_Orient(EnGo2* this, GlobalContext* globalCtx) { - s16 targetYaw; - f32 waypointDistSq = Path_OrientAndGetDistSq(&this->actor, this->path, this->waypoint, &targetYaw); - - Math_SmoothStepToS(&this->actor.world.rot.y, targetYaw, 6, 4000, 1); - if (waypointDistSq > 0.0f && waypointDistSq < SQ(30.0f)) { - return EnGo2_UpdateWaypoint(this, globalCtx); - } else { - return 0; - } -} - -s32 func_80A44D84(EnGo2* this) { - s16 targetYaw; - - Path_OrientAndGetDistSq(&this->actor, this->path, this->waypoint, &targetYaw); - this->actor.world.rot.y = targetYaw; - return 1; -} - -s32 EnGo2_IsWakingUp(EnGo2* this) { - s16 yawDiff; - f32 xyzDist = (this->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 800.0f : 200.0f; - f32 yDist = (this->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 400.0f : 60.0f; - s16 yawDiffAbs; - - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - if ((this->collider.base.ocFlags2 & 1) == 0) { - this->actor.flags &= ~ACTOR_FLAG_0; - return false; - } else { - this->actor.flags |= ACTOR_FLAG_0; - return true; - } - } - - xyzDist = SQ(xyzDist); - yawDiff = (f32)this->actor.yawTowardsPlayer - (f32)this->actor.shape.rot.y; - yawDiffAbs = ABS(yawDiff); - if (this->actor.xyzDistToPlayerSq <= xyzDist && fabsf(this->actor.yDistToPlayer) < yDist && yawDiffAbs < 0x2AA8) { - return true; - } else { - return false; - } -} - -s32 EnGo2_IsRollingOnGround(EnGo2* this, s16 arg1, f32 arg2, s16 arg3) { - if ((this->actor.bgCheckFlags & 1) == 0 || this->actor.velocity.y > 0.0f) { - return false; - } - - if (DECR(this->unk_590)) { - if (!arg3) { - return true; - } else { - this->actor.world.pos.y = - (this->unk_590 & 1) ? this->actor.world.pos.y + 1.5f : this->actor.world.pos.y - 1.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); - return true; - } - } - - if (this->unk_59C >= 2) { - Audio_PlayActorSound2(&this->actor, (this->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG - ? NA_SE_EN_GOLON_LAND_BIG - : NA_SE_EN_DODO_M_GND); - } - - this->unk_59C--; - if (this->unk_59C <= 0) { - if (this->unk_59C == 0) { - this->unk_590 = Rand_S16Offset(60, 30); - this->unk_59C = 0; - this->actor.velocity.y = 0.0f; - return true; - } else { - this->unk_59C = arg1; - } - } - - this->actor.velocity.y = ((f32)this->unk_59C / (f32)arg1) * arg2; - return true; -} - -void EnGo2_BiggoronSetTextId(EnGo2* this, GlobalContext* globalCtx, Player* player) { - u16 textId; - - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - if (gSaveContext.bgsFlag) { - if (func_8002F368(globalCtx) == EXCH_ITEM_CLAIM_CHECK) { - this->actor.textId = 0x3003; - } else { - this->actor.textId = 0x305E; - } - player->actor.textId = this->actor.textId; - - } else if (!gSaveContext.bgsFlag && (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_CLAIM_CHECK)) { - if (func_8002F368(globalCtx) == EXCH_ITEM_CLAIM_CHECK) { - if (Environment_GetBgsDayCount() >= 3) { - textId = 0x305E; - } else { - textId = 0x305D; - } - this->actor.textId = textId; - } else { - if (Environment_GetBgsDayCount() >= 3) { - textId = 0x3002; - } else { - textId = 0x305D; - } - this->actor.textId = textId; - } - player->actor.textId = this->actor.textId; - - } else if ((INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_PRESCRIPTION) && - (INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_CLAIM_CHECK)) { - if (func_8002F368(globalCtx) == EXCH_ITEM_EYEDROPS) { - this->actor.textId = 0x3059; - } else { - this->actor.textId = 0x3058; - } - if (this->actor.textId == 0x3059) { - gSaveContext.timer2State = 0; - } - player->actor.textId = this->actor.textId; - - } else if (INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_SWORD_BROKEN) { - if (func_8002F368(globalCtx) == EXCH_ITEM_SWORD_BROKEN) { - if (gSaveContext.infTable[11] & 0x10) { - textId = 0x3055; - } else { - textId = 0x3054; - } - this->actor.textId = textId; - } else { - this->actor.textId = 0x3053; - } - player->actor.textId = this->actor.textId; - } else { - this->actor.textId = 0x3053; - player->actor.textId = this->actor.textId; - } - } -} - -void func_80A45288(EnGo2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 linkAge; - - if (this->actionFunc != EnGo2_GoronFireGenericAction) { - this->unk_194.unk_18 = player->actor.world.pos; - linkAge = gSaveContext.linkAge; - this->unk_194.unk_14 = D_80A482D8[this->actor.params & 0x1F][linkAge]; - func_80034A14(&this->actor, &this->unk_194, 4, this->unk_26E); - } - if ((this->actionFunc != EnGo2_SetGetItem) && (this->isAwake == true)) { - if (func_80A44790(this, globalCtx)) { - EnGo2_BiggoronSetTextId(this, globalCtx, player); - } - } -} - -void func_80A45360(EnGo2* this, f32* alpha) { - f32 alphaTarget = - (this->skelAnime.animation == &gGoronAnim_004930) && (this->skelAnime.curFrame <= 32.0f) ? 0.0f : 255.0f; - - Math_ApproachF(alpha, alphaTarget, 0.4f, 100.0f); - this->actor.shape.shadowAlpha = (u8)(u32)*alpha; -} - -void EnGo2_RollForward(EnGo2* this) { - f32 speedXZ = this->actor.speedXZ; - - if (this->unk_194.unk_00 != 0) { - this->actor.speedXZ = 0.0f; - } - - if (this->actionFunc != EnGo2_ContinueRolling) { - Actor_MoveForward(&this->actor); - } - - this->actor.speedXZ = speedXZ; -} - -void func_80A454CC(EnGo2* this) { - switch (this->actor.params & 0x1F) { - case GORON_CITY_ROLLING_BIG: - case GORON_DMT_DC_ENTRANCE: - case GORON_CITY_ENTRANCE: - case GORON_CITY_STAIRWELL: - case GORON_DMT_FAIRY_HINT: - func_80034EC0(&this->skelAnime, sAnimations, 9); - break; - case GORON_DMT_BIGGORON: - if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_SWORD_BROKEN && INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_EYEDROPS) { - func_80034EC0(&this->skelAnime, sAnimations, 4); - break; - } - default: - this->skelAnime.playSpeed = 0.0f; - break; - } -} - -f32 EnGo2_GetTargetXZSpeed(EnGo2* this) { - f32 yDist = (this->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 400.0f : 60.0f; - s32 index = this->actor.params & 0x1F; - - if (index == GORON_CITY_LINK && (fabsf(this->actor.yDistToPlayer) < yDist) && - (this->actor.xzDistToPlayer < 400.0f)) { - return 9.0f; - } else { - return index == GORON_CITY_ROLLING_BIG ? 3.6000001f : 6.0f; - } -} - -s32 EnGo2_IsCameraModified(EnGo2* this, GlobalContext* globalCtx) { - Camera* camera = globalCtx->cameraPtrs[MAIN_CAM]; - - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - if (EnGo2_IsWakingUp(this)) { - Camera_ChangeSetting(camera, CAM_SET_DIRECTED_YAW); - func_8005AD1C(camera, 4); - } else if (!EnGo2_IsWakingUp(this) && (camera->setting == CAM_SET_DIRECTED_YAW)) { - Camera_ChangeSetting(camera, CAM_SET_DUNGEON1); - func_8005ACFC(camera, 4); - } - } - - if ((this->actor.params & 0x1F) == GORON_FIRE_GENERIC || (this->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG || - (this->actor.params & 0x1F) == GORON_CITY_STAIRWELL || (this->actor.params & 0x1F) == GORON_DMT_BIGGORON || - (this->actor.params & 0x1F) == GORON_MARKET_BAZAAR) { - return true; - } else if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { - return true; - } else { - return false; - } -} - -void EnGo2_DefaultWakingUp(EnGo2* this) { - if (EnGo2_IsWakingUp(this)) { - this->unk_26E = 2; - } else { - this->unk_26E = 1; - } - - if (this->unk_194.unk_00 != 0) { - this->unk_26E = 4; - } - - this->isAwake = true; -} - -void EnGo2_WakingUp(EnGo2* this) { - f32 xyzDist = (this->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 800.0f : 200.0f; - s32 isTrue = true; - - xyzDist = SQ(xyzDist); - this->unk_26E = 1; - if ((this->actor.xyzDistToPlayerSq <= xyzDist) || (this->unk_194.unk_00 != 0)) { - this->unk_26E = 4; - } - - this->isAwake = isTrue; -} - -void EnGo2_BiggoronWakingUp(EnGo2* this) { - if (EnGo2_IsWakingUp(this) || this->unk_194.unk_00 != 0) { - this->unk_26E = 2; - this->isAwake = true; - } else { - this->unk_26E = 1; - this->isAwake = false; - } -} - -void EnGo2_SelectGoronWakingUp(EnGo2* this) { - switch (this->actor.params & 0x1F) { - case GORON_DMT_BOMB_FLOWER: - this->isAwake = true; - this->unk_26E = EnGo2_IsWakingUp(this) ? 2 : 1; - break; - case GORON_FIRE_GENERIC: - EnGo2_WakingUp(this); - break; - case GORON_DMT_BIGGORON: - EnGo2_BiggoronWakingUp(this); - break; - case GORON_CITY_LINK: - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { - EnGo2_WakingUp(this); - break; - } - default: - EnGo2_DefaultWakingUp(this); - } -} - -void EnGo2_EyeMouthTexState(EnGo2* this) { - switch (this->eyeMouthTexState) { - case 1: - this->blinkTimer = 0; - this->eyeTexIndex = 0; - this->mouthTexIndex = 0; - break; - case 2: - this->blinkTimer = 0; - this->eyeTexIndex = 1; - this->mouthTexIndex = 0; - break; - // case 3 only when biggoron is given eyedrops. Biggoron smiles. (only use of second mouth texture) - case 3: - this->blinkTimer = 0; - this->eyeTexIndex = 0; - this->mouthTexIndex = 1; - break; - default: - if (DECR(this->blinkTimer) == 0) { - this->eyeTexIndex++; - if (this->eyeTexIndex >= 4) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeTexIndex = 1; - } - } - } -} - -void EnGo2_SitDownAnimation(EnGo2* this) { - if ((this->skelAnime.playSpeed != 0.0f) && (this->skelAnime.animation == &gGoronAnim_004930)) { - if (this->skelAnime.playSpeed > 0.0f && this->skelAnime.curFrame == 14.0f) { - if ((this->actor.params & 0x1F) != GORON_DMT_BIGGORON) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_SIT_DOWN); - } else { - func_800F4524(&D_801333D4, NA_SE_EN_GOLON_SIT_DOWN, 60); - } - } - if (this->skelAnime.playSpeed < 0.0f) { - if (this->skelAnime.curFrame == 1.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - if (this->skelAnime.curFrame == 40.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_SIT_DOWN); - } - } - } -} - -void EnGo2_GetDustData(EnGo2* this, s32 index2) { - s32 index1 = (this->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG ? 1 : 0; - EnGo2DustEffectData* dustEffectData = &sDustEffectData[index1][index2]; - - EnGo2_SpawnDust(this, dustEffectData->initialTimer, dustEffectData->scale, dustEffectData->scaleStep, - dustEffectData->numDustEffects, dustEffectData->radius, dustEffectData->yAccel); -} - -void EnGo2_RollingAnimation(EnGo2* this, GlobalContext* globalCtx) { - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - this->actor.flags &= ~ACTOR_FLAG_0; - func_80034EC0(&this->skelAnime, sAnimations, 10); - this->skelAnime.playSpeed = -0.5f; - } else { - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->skelAnime.playSpeed = -1.0f; - } - EnGo2_SwapInitialFrameAnimFrameCount(this); - this->unk_26E = 1; - this->unk_211 = false; - this->isAwake = false; - this->actionFunc = EnGo2_CurledUp; -} - -void EnGo2_WakeUp(EnGo2* this, GlobalContext* globalCtx) { - if (this->skelAnime.playSpeed == 0.0f) { - if ((this->actor.params & 0x1F) != GORON_DMT_BIGGORON) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WAKE_UP); - } else { - func_800F4524(&D_801333D4, NA_SE_EN_GOLON_WAKE_UP, 60); - } - } - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - OnePointCutscene_Init(globalCtx, 4200, -99, &this->actor, MAIN_CAM); - func_80034EC0(&this->skelAnime, sAnimations, 10); - this->skelAnime.playSpeed = 0.5f; - } else { - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->skelAnime.playSpeed = 1.0f; - } - this->actionFunc = func_80A46B40; -} - -void EnGo2_GetItemAnimation(EnGo2* this, GlobalContext* globalCtx) { - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->unk_211 = true; - this->actionFunc = func_80A46B40; - this->skelAnime.playSpeed = 0.0f; - this->actor.speedXZ = 0.0f; - this->skelAnime.curFrame = this->skelAnime.endFrame; -} - -void EnGo2_SetupRolling(EnGo2* this, GlobalContext* globalCtx) { - if ((this->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG || (this->actor.params & 0x1F) == GORON_CITY_LINK) { - this->collider.info.bumperFlags = 1; - this->actor.speedXZ = gSaveContext.infTable[17] & 0x4000 ? 6.0f : 3.6000001f; - } else { - this->actor.speedXZ = 6.0f; - } - this->actor.flags |= ACTOR_FLAG_24; - this->animTimer = 10; - this->actor.shape.yOffset = 1800.0f; - this->actor.speedXZ += this->actor.speedXZ; // Speeding up - this->actionFunc = EnGo2_ContinueRolling; -} - -void EnGo2_StopRolling(EnGo2* this, GlobalContext* globalCtx) { - EnBom* bomb; - - if (((this->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG) && ((this->actor.params & 0x1F) != GORON_CITY_LINK)) { - if ((this->actor.params & 0x1F) == GORON_DMT_ROLLING_SMALL) { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - if (bomb != NULL) { - bomb->timer = 0; - } - } - } else { - this->collider.info.bumperFlags = 0; - } - - this->actor.shape.rot = this->actor.world.rot; - this->unk_59C = 0; - this->unk_590 = 0; - this->actionFunc = EnGo2_GroundRolling; - this->actor.shape.yOffset = 0.0f; - this->actor.speedXZ = 0.0f; -} - -s32 EnGo2_IsFreeingGoronInFire(EnGo2* this, GlobalContext* globalCtx) { - if ((this->actor.params & 0x1F) != GORON_FIRE_GENERIC) { - return false; - } - - // shaking curled up - this->actor.world.pos.x += (globalCtx->state.frames & 1) ? 1.0f : -1.0f; - if (Flags_GetSwitch(globalCtx, (this->actor.params & 0xFC00) >> 0xA)) { - return true; - } - return false; -} - -s32 EnGo2_IsGoronDmtBombFlower(EnGo2* this) { - if ((this->actor.params & 0x1F) != GORON_DMT_BOMB_FLOWER || this->unk_194.unk_00 != 2) { - return false; - } - - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->unk_194.unk_00 = 0; - this->isAwake = false; - this->unk_26E = 1; - this->actionFunc = EnGo2_GoronDmtBombFlowerAnimation; - return true; -} - -s32 EnGo2_IsGoronRollingBig(EnGo2* this, GlobalContext* globalCtx) { - if ((this->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG || (this->unk_194.unk_00 != 2)) { - return false; - } - this->unk_194.unk_00 = 0; - EnGo2_RollingAnimation(this, globalCtx); - this->actionFunc = EnGo2_GoronRollingBigContinueRolling; - return true; -} - -s32 EnGo2_IsGoronFireGeneric(EnGo2* this) { - if ((this->actor.params & 0x1F) != GORON_FIRE_GENERIC || this->unk_194.unk_00 == 0) { - return false; - } - this->actionFunc = EnGo2_GoronFireGenericAction; - return true; -} - -s32 EnGo2_IsGoronLinkReversing(EnGo2* this) { - if ((this->actor.params & 0x1F) != GORON_CITY_LINK || (this->waypoint >= this->unk_216) || - !EnGo2_IsWakingUp(this)) { - return false; - } - return true; -} - -s32 EnGo2_IsRolling(EnGo2* this) { - if (this->unk_194.unk_00 == 0 || this->actor.speedXZ < 1.0f) { - return false; - } - if (EnGo2_IsRollingOnGround(this, 2, 20.0 / 3.0f, 0)) { - if ((this->unk_590 >= 9) && (this->unk_59C == 0)) { - this->unk_590 = 8; - } - EnGo2_GetDustData(this, 0); - } - return true; -} - -void EnGo2_GoronLinkAnimation(EnGo2* this, GlobalContext* globalCtx) { - s32 animation = 13; - - if ((this->actor.params & 0x1F) == GORON_CITY_LINK) { - if ((this->actor.textId == 0x3035 && this->unk_20C == 0) || - (this->actor.textId == 0x3036 && this->unk_20C == 0)) { - if (this->skelAnime.animation != &gGoronAnim_000D5C) { - animation = 12; - this->eyeMouthTexState = 0; - } - } - - if ((this->actor.textId == 0x3032 && this->unk_20C == 12) || (this->actor.textId == 0x3033) || - (this->actor.textId == 0x3035 && this->unk_20C == 6)) { - if (this->skelAnime.animation != &gGoronAnim_000750) { - animation = 11; - this->eyeMouthTexState = 1; - } - } - - if (this->skelAnime.animation == &gGoronAnim_000750) { - if (this->skelAnime.curFrame == 20.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_CRY); - } - } - - if (animation != 13) { - func_80034EC0(&this->skelAnime, sAnimations, animation); - } - } -} - -void EnGo2_GoronFireCamera(EnGo2* this, GlobalContext* globalCtx) { - s16 yaw; - - this->camId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->camId, CAM_STAT_ACTIVE); - Path_CopyLastPoint(this->path, &this->at); - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->at) + 0xE38; - this->eye.x = Math_SinS(yaw) * 100.0f + this->actor.world.pos.x; - this->eye.z = Math_CosS(yaw) * 100.0f + this->actor.world.pos.z; - this->eye.y = this->actor.world.pos.y + 20.0f; - this->at.x = this->actor.world.pos.x; - this->at.y = this->actor.world.pos.y + 40.0f; - this->at.z = this->actor.world.pos.z; - Gameplay_CameraSetAtEye(globalCtx, this->camId, &this->at, &this->eye); -} - -void EnGo2_GoronFireClearCamera(EnGo2* this, GlobalContext* globalCtx) { - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, this->camId); -} - -void EnGo2_BiggoronAnimation(EnGo2* this) { - if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_SWORD_BROKEN && INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_EYEDROPS && - (this->actor.params & 0x1F) == GORON_DMT_BIGGORON && this->unk_194.unk_00 == 0) { - if (DECR(this->animTimer) == 0) { - this->animTimer = Rand_S16Offset(30, 30); - func_800F4524(&D_801333D4, NA_SE_EN_GOLON_EYE_BIG, 60); - } - } -} - -void EnGo2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGo2* this = (EnGo2*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, 18); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - - // Not GORON_CITY_ROLLING_BIG, GORON_CITY_LINK, GORON_DMT_BIGGORON - switch (this->actor.params & 0x1F) { - case GORON_FIRE_GENERIC: - case GORON_DMT_BOMB_FLOWER: - case GORON_DMT_ROLLING_SMALL: - case GORON_DMT_DC_ENTRANCE: - case GORON_CITY_ENTRANCE: - case GORON_CITY_ISLAND: - case GORON_CITY_LOWEST_FLOOR: - case GORON_CITY_STAIRWELL: - case GORON_CITY_LOST_WOODS: - case GORON_DMT_FAIRY_HINT: - case GORON_MARKET_BAZAAR: - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.flags &= ~ACTOR_FLAG_5; - } - - EnGo2_SetColliderDim(this); - EnGo2_SetShape(this); - func_80034EC0(&this->skelAnime, sAnimations, 0); - this->actor.gravity = -1.0f; - this->alpha = this->actor.shape.shadowAlpha = 0; - this->reverse = 0; - this->isAwake = false; - this->unk_211 = false; - this->goronState = 0; - this->waypoint = 0; - this->unk_216 = this->actor.shape.rot.z; - this->unk_26E = 1; - this->path = Path_GetByIndex(globalCtx, (this->actor.params & 0x3E0) >> 5, 0x1F); - switch (this->actor.params & 0x1F) { - case GORON_CITY_ENTRANCE: - case GORON_CITY_ISLAND: - case GORON_CITY_LOWEST_FLOOR: - case GORON_CITY_STAIRWELL: - case GORON_CITY_LOST_WOODS: - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { - Actor_Kill(&this->actor); - } - this->actionFunc = EnGo2_CurledUp; - break; - case GORON_MARKET_BAZAAR: - if ((LINK_IS_ADULT) || !CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - Actor_Kill(&this->actor); - } - EnGo2_GetItemAnimation(this, globalCtx); - break; - case GORON_CITY_LINK: - if ((gSaveContext.infTable[16] & 0x200)) { - Path_CopyLastPoint(this->path, &this->actor.world.pos); - this->actor.home.pos = this->actor.world.pos; - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { - EnGo2_GetItemAnimation(this, globalCtx); - } else { - this->actionFunc = EnGo2_CurledUp; - } - } else { - gSaveContext.infTable[16] &= ~0x1000; - this->collider.dim.height = (D_80A4816C[this->actor.params & 0x1F].height * 0.6f); - EnGo2_SetupRolling(this, globalCtx); - this->isAwake = true; - } - break; - case GORON_CITY_ROLLING_BIG: - case GORON_DMT_ROLLING_SMALL: - this->collider.dim.height = (D_80A4816C[this->actor.params & 0x1F].height * 0.6f); - EnGo2_SetupRolling(this, globalCtx); - break; - case GORON_FIRE_GENERIC: - if (Flags_GetSwitch(globalCtx, (this->actor.params & 0xFC00) >> 0xA)) { - Actor_Kill(&this->actor); - } else { - this->isAwake = true; - this->actionFunc = EnGo2_CurledUp; - } - break; - case GORON_DMT_BIGGORON: - this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~ACTOR_FLAG_0; - if ((INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_SWORD_BROKEN) && - (INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_EYEDROPS)) { - this->eyeMouthTexState = 1; - } - this->collider.base.acFlags = 0; - this->collider.base.ocFlags1 = 0xD; // OC_PLAYER | OC_NO_PUSH | OC_ON - this->actionFunc = EnGo2_CurledUp; - break; - case GORON_DMT_BOMB_FLOWER: - if (gSaveContext.infTable[14] & 0x800) { - Path_CopyLastPoint(this->path, &this->actor.world.pos); - this->actor.home.pos = this->actor.world.pos; - } - case GORON_DMT_DC_ENTRANCE: - case GORON_DMT_FAIRY_HINT: - default: - this->actionFunc = EnGo2_CurledUp; - } -} - -void EnGo2_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnGo2_CurledUp(EnGo2* this, GlobalContext* globalCtx) { - u8 index = this->actor.params & 0x1F; - s16 height; - s32 quake; - - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quake, -0x3CB0); - Quake_SetQuakeValues(quake, 8, 0, 0, 0); - Quake_SetCountdown(quake, 16); - } else { - EnGo2_GetDustData(this, 1); - } - this->skelAnime.playSpeed = 0.0f; - } - - if ((s32)this->skelAnime.curFrame == 0) { - this->collider.dim.height = (D_80A4816C[index].height * 0.6f); - } else { - height = D_80A4816C[index].height; - this->collider.dim.height = - ((D_80A4816C[index].height * 0.4f * (this->skelAnime.curFrame / this->skelAnime.startFrame)) + - (height * 0.6f)); - } - if (EnGo2_IsFreeingGoronInFire(this, globalCtx)) { - this->isAwake = false; - EnGo2_WakeUp(this, globalCtx); - } - if (((this->actor.params & 0x1F) != GORON_FIRE_GENERIC) && EnGo2_IsWakingUp(this)) { - EnGo2_WakeUp(this, globalCtx); - } -} - -void func_80A46B40(EnGo2* this, GlobalContext* globalCtx) { - u8 index = (this->actor.params & 0x1F); - f32 height; - - if (this->unk_211 == true) { - EnGo2_BiggoronAnimation(this); - EnGo2_GoronLinkAnimation(this, globalCtx); - EnGo2_SelectGoronWakingUp(this); - - if (!EnGo2_IsGoronRollingBig(this, globalCtx) && !EnGo2_IsGoronFireGeneric(this)) { - if (EnGo2_IsGoronDmtBombFlower(this)) { - return; - } - } else { - return; - } - } else { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { - this->actor.flags |= ACTOR_FLAG_0; - } - func_80A454CC(this); - this->unk_211 = true; - this->collider.dim.height = D_80A4816C[index].height; - } else { - height = D_80A4816C[index].height; - this->collider.dim.height = - (s16)((height * 0.4f * (this->skelAnime.curFrame / this->skelAnime.endFrame)) + (height * 0.6f)); - } - } - if ((!EnGo2_IsCameraModified(this, globalCtx)) && (!EnGo2_IsWakingUp(this))) { - EnGo2_RollingAnimation(this, globalCtx); - } -} - -void EnGo2_GoronDmtBombFlowerAnimation(EnGo2* this, GlobalContext* globalCtx) { - f32 float1 = this->skelAnime.endFrame; - f32 float2 = this->skelAnime.curFrame * ((f32)0x8000 / float1); - - this->actor.speedXZ = Math_SinS(float2); - if ((EnGo2_Orient(this, globalCtx)) && (this->waypoint == 0)) { - EnGo2_GetItemAnimation(this, globalCtx); - } -} - -void EnGo2_GoronRollingBigContinueRolling(EnGo2* this, GlobalContext* globalCtx) { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - EnGo2_GetDustData(this, 1); - this->skelAnime.playSpeed = 0.0f; - EnGo2_SetupRolling(this, globalCtx); - } -} - -void EnGo2_ContinueRolling(EnGo2* this, GlobalContext* globalCtx) { - f32 float1 = 1000.0f; - - if (((this->actor.params & 0x1F) != GORON_DMT_ROLLING_SMALL || !(this->actor.xyzDistToPlayerSq > SQ(float1))) && - DECR(this->animTimer) == 0) { - this->actionFunc = EnGo2_SlowRolling; - this->actor.speedXZ *= 0.5f; // slowdown - } - EnGo2_GetDustData(this, 2); -} - -void EnGo2_SlowRolling(EnGo2* this, GlobalContext* globalCtx) { - s32 orientation; - s32 index; - - if (!EnGo2_IsRolling(this)) { - if (EnGo2_IsRollingOnGround(this, 4, 8.0f, 1) == true) { - if (EnGo2_IsGoronLinkReversing(this)) { - this->actionFunc = EnGo2_ReverseRolling; - return; - } - EnGo2_GetDustData(this, 3); - } - orientation = EnGo2_Orient(this, globalCtx); - index = this->actor.params & 0x1F; - if (index != GORON_CITY_LINK) { - if ((index == GORON_DMT_ROLLING_SMALL) && (orientation == 1) && (this->waypoint == 0)) { - EnGo2_StopRolling(this, globalCtx); - return; - } - } else if ((orientation == 2) && (this->waypoint == 1)) { - EnGo2_StopRolling(this, globalCtx); - return; - } - Math_ApproachF(&this->actor.speedXZ, EnGo2_GetTargetXZSpeed(this), 0.4f, 0.6f); - this->actor.shape.rot = this->actor.world.rot; - } -} - -void EnGo2_GroundRolling(EnGo2* this, GlobalContext* globalCtx) { - if (EnGo2_IsRollingOnGround(this, 4, 8.0f, 0)) { - EnGo2_GetDustData(this, 0); - if (this->unk_59C == 0) { - switch (this->actor.params & 0x1F) { - case GORON_CITY_LINK: - this->goronState = 0; - this->actionFunc = EnGo2_GoronLinkStopRolling; - break; - case GORON_CITY_ROLLING_BIG: - EnGo2_WakeUp(this, globalCtx); - break; - default: - this->actionFunc = EnGo2_CurledUp; - } - } - } -} - -void EnGo2_ReverseRolling(EnGo2* this, GlobalContext* globalCtx) { - if (!EnGo2_IsRolling(this)) { - Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.6f, 0.8f); - if (this->actor.speedXZ >= 1.0f) { - EnGo2_GetDustData(this, 3); - } - if ((s32)this->actor.speedXZ == 0) { - this->actor.world.rot.y ^= 0x8000; - this->actor.shape.rot.y = this->actor.world.rot.y; - this->reverse ^= 1; - EnGo2_UpdateWaypoint(this, globalCtx); - EnGo2_SetupRolling(this, globalCtx); - } - } -} - -void EnGo2_SetupGetItem(EnGo2* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnGo2_SetGetItem; - } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, this->actor.xzDistToPlayer + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); - } -} - -void EnGo2_SetGetItem(EnGo2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->unk_194.unk_00 = 0; - switch (this->getItemId) { - case GI_CLAIM_CHECK: - Environment_ClearBgsDayCount(); - EnGo2_GetItemAnimation(this, globalCtx); - return; - case GI_TUNIC_GORON: - gSaveContext.infTable[16] |= 0x200; - EnGo2_GetItemAnimation(this, globalCtx); - return; - case GI_SWORD_BGS: - gSaveContext.bgsFlag = true; - break; - case GI_BOMB_BAG_30: - case GI_BOMB_BAG_40: - EnGo2_RollingAnimation(this, globalCtx); - this->actionFunc = EnGo2_GoronRollingBigContinueRolling; - return; - } - this->actionFunc = func_80A46B40; - } -} - -void EnGo2_BiggoronEyedrops(EnGo2* this, GlobalContext* globalCtx) { - switch (this->goronState) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 5); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.shape.rot.y += 0x5B0; - this->unk_26E = 1; - this->animTimer = this->skelAnime.endFrame + 60.0f + 60.0f; // eyeDrops animation timer - this->eyeMouthTexState = 2; - this->unk_20C = 0; - this->goronState++; - func_800F483C(0x28, 5); - OnePointCutscene_Init(globalCtx, 4190, -99, &this->actor, MAIN_CAM); - break; - case 1: - if (DECR(this->animTimer)) { - if (this->animTimer == 60 || this->animTimer == 120) { - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - func_800F4524(&D_801333D4, NA_SE_EV_GORON_WATER_DROP, 60); - } - } else { - func_800F4524(&D_801333D4, NA_SE_EN_GOLON_GOOD_BIG, 60); - func_80034EC0(&this->skelAnime, sAnimations, 6); - Message_ContinueTextbox(globalCtx, 0x305A); - this->eyeMouthTexState = 3; - this->goronState++; - func_800F483C(0x7F, 5); - } - break; - case 2: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->eyeMouthTexState = 0; - } - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->actor.flags |= ACTOR_FLAG_0; - this->unk_26E = 2; - this->skelAnime.playSpeed = 0.0f; - this->skelAnime.curFrame = this->skelAnime.endFrame; - EnGo2_GetItem(this, globalCtx, GI_CLAIM_CHECK); - this->actionFunc = EnGo2_SetupGetItem; - this->goronState = 0; - } - break; - } -} - -void EnGo2_GoronLinkStopRolling(EnGo2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - switch (this->goronState) { - case 0: - if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { - return; - } else { - Message_StartTextbox(globalCtx, 0x3031, NULL); - player->actor.freezeTimer = 10; - this->goronState++; - } - case 1: - break; - default: - return; - } - - if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING) { - player->actor.freezeTimer = 10; - } else { - gSaveContext.infTable[16] |= 0x1000; - this->unk_26E = 1; - this->unk_211 = false; - this->isAwake = false; - this->actionFunc = EnGo2_CurledUp; - } -} - -void EnGo2_GoronFireGenericAction(EnGo2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3s D_80A4854C = { 0x00, 0x00, 0x00 }; - - switch (this->goronState) { - case 0: // Wake up - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - EnGo2_GoronFireCamera(this, globalCtx); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - func_80034EC0(&this->skelAnime, sAnimations, 2); - this->waypoint = 1; - this->skelAnime.playSpeed = 2.0f; - func_80A44D84(this); - this->actor.shape.rot = this->actor.world.rot; - this->animTimer = 60; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 2.0f; - this->unk_194.unk_08 = D_80A4854C; - this->unk_194.unk_0E = D_80A4854C; - this->goronState++; - this->goronState++; - player->actor.world.rot.y = this->actor.world.rot.y; - player->actor.shape.rot.y = this->actor.world.rot.y; - player->actor.world.pos.x = - (f32)((Math_SinS(this->actor.world.rot.y) * -30.0f) + this->actor.world.pos.x); - player->actor.world.pos.z = - (f32)((Math_CosS(this->actor.world.rot.y) * -30.0f) + this->actor.world.pos.z); - func_8002DF54(globalCtx, &this->actor, 8); - Audio_PlayFanfare(NA_BGM_APPEAR); - } - break; - case 2: // Walking away - if (DECR(this->animTimer)) { - if (!(this->animTimer % 8)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); - } - Actor_MoveForward(&this->actor); - } else { - this->animTimer = 0; - this->actor.speedXZ = 0.0f; - if ((((this->actor.params & 0xFC00) >> 0xA) != 1) && (((this->actor.params & 0xFC00) >> 0xA) != 2) && - (((this->actor.params & 0xFC00) >> 0xA) != 4) && (((this->actor.params & 0xFC00) >> 0xA) != 5) && - (((this->actor.params & 0xFC00) >> 0xA) != 9) && (((this->actor.params & 0xFC00) >> 0xA) != 11)) { - this->goronState++; - } - this->goronState++; - } - break; - case 3: // Walking away - this->animTimer++; - if (!(this->animTimer % 8) && (this->animTimer < 10)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); - } - if (this->animTimer == 10) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_IRON_DOOR_OPEN); - } - if (this->animTimer > 44) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_IRON_DOOR_CLOSE); - } else { - break; - } - case 4: // Finalize walking away - Message_CloseTextbox(globalCtx); - EnGo2_GoronFireClearCamera(this, globalCtx); - func_8002DF54(globalCtx, &this->actor, 7); - Actor_Kill(&this->actor); - break; - case 1: - break; - } -} - -void EnGo2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGo2* this = (EnGo2*)thisx; - - func_80A45360(this, &this->alpha); - EnGo2_SitDownAnimation(this); - SkelAnime_Update(&this->skelAnime); - EnGo2_RollForward(this); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, (f32)this->collider.dim.height * 0.5f, - (f32)this->collider.dim.radius * 0.6f, 0.0f, 5); - if (this->unk_194.unk_00 == 0) { - func_80A44AB0(this, globalCtx); - } - this->actionFunc(this, globalCtx); - if (this->unk_211 == true) { - func_80034F54(globalCtx, this->unk_226, this->unk_24A, 18); - } - func_80A45288(this, globalCtx); - EnGo2_EyeMouthTexState(this); - EnGo2_CheckCollision(this, globalCtx); -} - -s32 EnGo2_DrawCurledUp(EnGo2* this, GlobalContext* globalCtx) { - Vec3f D_80A48554 = { 0.0f, 0.0f, 0.0f }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2881); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go2.c", 2884), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gGoronDL_00BD80); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2889); - Matrix_MultVec3f(&D_80A48554, &this->actor.focus.pos); - - return 1; -} - -s32 EnGo2_DrawRolling(EnGo2* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f D_80A48560 = { 0.0f, 0.0f, 0.0f }; - f32 speedXZ; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2914); - func_80093D18(globalCtx->state.gfxCtx); - speedXZ = this->actionFunc == EnGo2_ReverseRolling ? 0.0f : this->actor.speedXZ; - Matrix_RotateZYX((globalCtx->state.frames * ((s16)speedXZ * 1400)), 0, this->actor.shape.rot.z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go2.c", 2926), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gGoronDL_00C140); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2930); - Matrix_MultVec3f(&D_80A48560, &this->actor.focus.pos); - return 1; -} - -s32 EnGo2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnGo2* this = (EnGo2*)thisx; - Vec3s vec1; - f32 float1; - - if (limb == 17) { - Matrix_Translate(2800.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec1 = this->unk_194.unk_08; - float1 = (vec1.y / (f32)0x8000) * M_PI; - Matrix_RotateX(float1, MTXMODE_APPLY); - float1 = (vec1.x / (f32)0x8000) * M_PI; - Matrix_RotateZ(float1, MTXMODE_APPLY); - Matrix_Translate(-2800.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } - if (limb == 10) { - vec1 = this->unk_194.unk_0E; - float1 = (vec1.y / (f32)0x8000) * M_PI; - Matrix_RotateY(float1, MTXMODE_APPLY); - float1 = (vec1.x / (f32)0x8000) * M_PI; - Matrix_RotateX(float1, MTXMODE_APPLY); - } - if ((limb == 10) || (limb == 11) || (limb == 14)) { - float1 = Math_SinS(this->unk_226[limb]); - rot->y += float1 * 200.0f; - float1 = Math_CosS(this->unk_24A[limb]); - rot->z += float1 * 200.0f; - } - return 0; -} - -void EnGo2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnGo2* this = (EnGo2*)thisx; - Vec3f D_80A4856C = { 600.0f, 0.0f, 0.0f }; - - if (limbIndex == 17) { - Matrix_MultVec3f(&D_80A4856C, &this->actor.focus.pos); - } -} - -void EnGo2_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGo2* this = (EnGo2*)thisx; - void* eyeTextures[] = { gGoronCsEyeClosed2Tex, gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; - void* mouthTextures[] = { gGoronCsMouthNeutralTex, gGoronCsMouthSmileTex }; - - EnGo2_UpdateDust(this); - Matrix_Push(); - EnGo2_DrawDust(this, globalCtx); - Matrix_Pop(); - - if ((this->actionFunc == EnGo2_CurledUp) && (this->skelAnime.playSpeed == 0.0f) && - (this->skelAnime.curFrame == 0.0f)) { - if (1) {} - EnGo2_DrawCurledUp(this, globalCtx); - } else if (this->actionFunc == EnGo2_SlowRolling || this->actionFunc == EnGo2_ReverseRolling || - this->actionFunc == EnGo2_ContinueRolling) { - EnGo2_DrawRolling(this, globalCtx); - } else { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 3063); - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexIndex])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTextures[this->mouthTexIndex])); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnGo2_OverrideLimbDraw, EnGo2_PostLimbDraw, this); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 3081); - } -} diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.cpp b/src/overlays/actors/ovl_En_Go2/z_en_go2.cpp new file mode 100644 index 000000000..204f9600b --- /dev/null +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.cpp @@ -0,0 +1,2073 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GO2_Z_EN_GO2_C +#include "actor_common.h" +#include "z_en_go2.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "def/code_8006BA00.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_path.h" +#include "def/z_play.h" +#include "def/z_quake.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +/* +FLAGS + +gSaveContext.eventChkInf[2] & 0x8 - DC entrance boulder blown up as child + +InfTable + +gSaveContext.infTable[11] & 0x10 +gSaveContext.infTable[14] & 0x1 - Talked to DMT Goron at DC entrance (Before DC is opened as child) +gSaveContext.infTable[14] & 0x8 - Talked to GC Goron in bottom level stairwell +gSaveContext.infTable[14] & 0x40 - Talked to GC Goron at LW entrance (Before LW shortcut is opened) +gSaveContext.infTable[14] & 0x800 - Talked to DMT Goron at Bomb Flower with goron bracelet +gSaveContext.infTable[15] & 0x1 - Talked to Goron at GC Entrance (Before goron ruby is obtained) +gSaveContext.infTable[15] & 0x10 - Talked to Goron at GC Island (Before goron ruby is obtained) +gSaveContext.infTable[15] & 0x100 - (not on cloud modding) Talked to GC Goron outside Darunias door (after opening door, +before getting goron bracelet) gSaveContext.infTable[16] & 0x200 - Obtained Fire Tunic from Goron Link +gSaveContext.infTable[16] & 0x400 - (not on cloud modding) +gSaveContext.infTable[16] & 0x800 - Spoke to Goron Link About Volvagia +gSaveContext.infTable[16] & 0x1000 - Stopped Goron Link's Rolling +gSaveContext.infTable[16] & 0x2000 - EnGo Exclusive +gSaveContext.infTable[16] & 0x4000 - Spoke to Goron Link +gSaveContext.infTable[16] & 0x8000 - (not on cloud modding) + +gSaveContext.infTable[17] & 0x4000 - Bomb bag upgrade obtained from rolling Goron + +EnGo +pathIndex: pthis->actor.params & 0xF +Goron: pthis->actor.params & 0xF0 + +EnGo2 +(pthis->actor.params & 0x3E0) >> 5 +(pthis->actor.params & 0xFC00) >> 0xA - Gorons in Fire Temple +this->actor.params & 0x1F + +Gorons only move when pthis->unk_194.unk_00 == 0 +*/ + +void EnGo2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGo2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGo2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGo2_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnGo2_StopRolling(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_CurledUp(EnGo2* pthis, GlobalContext* globalCtx); + +void func_80A46B40(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_GoronDmtBombFlowerAnimation(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_GoronRollingBigContinueRolling(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_ContinueRolling(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_SlowRolling(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_GroundRolling(EnGo2* pthis, GlobalContext* globalCtx); + +void EnGo2_ReverseRolling(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_SetupGetItem(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_SetGetItem(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_BiggoronEyedrops(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_GoronLinkStopRolling(EnGo2* pthis, GlobalContext* globalCtx); +void EnGo2_GoronFireGenericAction(EnGo2* pthis, GlobalContext* globalCtx); + +static void* sDustTex[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex }; + +static Vec3f sPos = { 0.0f, 0.0f, 0.0f }; +static Vec3f sVelocity = { 0.0f, 0.0f, 0.0f }; +static Vec3f sAccel = { 0.0f, 0.3f, 0.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 40, 65, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { + 0, 0, 0, 0, MASS_IMMOVABLE, +}; + +ActorInit En_Go2_InitVars = { + ACTOR_EN_GO2, + ACTORCAT_NPC, + FLAGS, + OBJECT_OF1D_MAP, + sizeof(EnGo2), + (ActorFunc)EnGo2_Init, + (ActorFunc)EnGo2_Destroy, + (ActorFunc)EnGo2_Update, + (ActorFunc)EnGo2_Draw, +}; + +static EnGo2DataStruct1 D_80A4816C[14] = { + { 0, 0, 0, 68, 148 }, { 0, 0, 0, 24, 52 }, { 0, 320, 380, 400, 120 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 46, 90 }, + { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, + { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, { 0, 0, 0, 30, 68 }, +}; + +static EnGo2DataStruct2 D_80A481F8[14] = { + { 30.0f, 0.026f, 6, 60.0f }, { 24.0f, 0.008f, 6, 30.0f }, { 28.0f, 0.16f, 5, 380.0f }, { 28.0f, 0.01f, 7, 40.0f }, + { 30.0f, 0.015f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, + { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, + { 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f }, +}; + +static f32 D_80A482D8[14][2] = { + { 80.0f, 80.0f }, { -10.0f, -10.0f }, { 800.0f, 800.0f }, { 0.0f, 0.0f }, { 20.0f, 40.0f }, + { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, + { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, +}; + +static struct_80034EC0_Entry sAnimations[] = { + { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x00, 0.0f }, { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x00, -8.0f }, + { &gGoronAnim_0029A8, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_010590, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, + { &gGoronAnim_003768, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_0038E4, 1.0f, 0.0f, -1.0f, 0x02, -8.0f }, + { &gGoronAnim_002D80, 1.0f, 0.0f, -1.0f, 0x02, -8.0f }, { &gGoronAnim_00161C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, + { &gGoronAnim_001A00, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_0021D0, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, + { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x01, -8.0f }, { &gGoronAnim_000750, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, + { &gGoronAnim_000D5C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, +}; + +static EnGo2DustEffectData sDustEffectData[2][4] = { + { + { 12, 0.2f, 0.2f, 1, 18.0f, 0.0f }, + { 12, 0.1f, 0.2f, 12, 26.0f, 0.0f }, + { 12, 0.1f, 0.3f, 4, 10.0f, 0.0f }, + { 12, 0.2f, 0.2f, 1, 18.0f, 0.0f }, + }, + { + { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, + { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, + { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, + { 12, 0.5f, 0.4f, 3, 42.0f, 0.0f }, + }, +}; + +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +void EnGo2_AddDust(EnGo2* pthis, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { + EnGoEffect* dustEffect = pthis->dustEffects; + s16 i; + s16 timer; + + for (i = 0; i < ARRAY_COUNT(pthis->dustEffects); i++, dustEffect++) { + if (dustEffect->type != 1) { + dustEffect->scale = scale; + dustEffect->scaleStep = scaleStep; + if (1) {} + timer = initialTimer; + dustEffect->timer = timer; + dustEffect->type = 1; + dustEffect->initialTimer = initialTimer; + dustEffect->pos = *pos; + dustEffect->accel = *accel; + dustEffect->velocity = *velocity; + return; + } + } +} + +void EnGo2_UpdateDust(EnGo2* pthis) { + EnGoEffect* dustEffect = pthis->dustEffects; + f32 randomNumber; + s16 i; + + for (i = 0; i < ARRAY_COUNT(pthis->dustEffects); i++, dustEffect++) { + if (dustEffect->type) { + dustEffect->timer--; + if (dustEffect->timer == 0) { + dustEffect->type = 0; + } + dustEffect->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + randomNumber = Rand_ZeroOne() * 0.4f; + dustEffect->accel.z = randomNumber - 0.2f; + dustEffect->pos.x += dustEffect->velocity.x; + dustEffect->pos.y += dustEffect->velocity.y; + dustEffect->pos.z += dustEffect->velocity.z; + dustEffect->velocity.x += dustEffect->accel.x; + dustEffect->velocity.y += dustEffect->accel.y; + dustEffect->velocity.z += randomNumber - 0.2f; + dustEffect->scale += dustEffect->scaleStep; + } + } +} + +void EnGo2_DrawDust(EnGo2* pthis, GlobalContext* globalCtx) { + EnGoEffect* dustEffect = pthis->dustEffects; + s16 alpha; + s16 firstDone; + s16 index; + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 111); + + firstDone = false; + func_80093D84(globalCtx->state.gfxCtx); + if (1) {} + + for (i = 0; i < ARRAY_COUNT(pthis->dustEffects); i++, dustEffect++) { + if (dustEffect->type) { + if (!firstDone) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD40); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 60, 20, 0); + firstDone = true; + } + + alpha = dustEffect->timer * (255.0f / dustEffect->initialTimer); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); + gDPPipeSync(POLY_XLU_DISP++); + Matrix_Translate(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(dustEffect->scale, dustEffect->scale, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 137), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + index = dustEffect->timer * (8.0f / dustEffect->initialTimer); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sDustTex[index])); + gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD50); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2_eff.c", 151); +} + +s32 EnGo2_SpawnDust(EnGo2* pthis, u8 initialTimer, f32 scale, f32 scaleStep, s32 numDustEffects, f32 radius, + f32 yAccel) { + Vec3f pos = sPos; + Vec3f velocity = sVelocity; + Vec3f accel = sAccel; + s32 i; + s16 angle; + + pos = pthis->actor.world.pos; // overwrites sPos data + pos.y = pthis->actor.floorHeight; + angle = (Rand_ZeroOne() - 0.5f) * 0x10000; + i = numDustEffects; + while (i >= 0) { + accel.y += Rand_ZeroOne() * yAccel; + pos.x = (Math_SinS(angle) * radius) + pthis->actor.world.pos.x; + pos.z = (Math_CosS(angle) * radius) + pthis->actor.world.pos.z; + EnGo2_AddDust(pthis, &pos, &velocity, &accel, initialTimer, scale, scaleStep); + angle += (s16)(0x10000 / numDustEffects); + i--; + } + return 0; +} + +void EnGo2_GetItem(EnGo2* pthis, GlobalContext* globalCtx, s32 getItemId) { + pthis->getItemId = getItemId; + func_8002F434(&pthis->actor, globalCtx, getItemId, pthis->actor.xzDistToPlayer + 1.0f, + fabsf(pthis->actor.yDistToPlayer) + 1.0f); +} + +s32 EnGo2_GetDialogState(EnGo2* pthis, GlobalContext* globalCtx) { + s16 dialogState = Message_GetState(&globalCtx->msgCtx); + + if ((pthis->dialogState == TEXT_STATE_AWAITING_NEXT) || (pthis->dialogState == TEXT_STATE_EVENT) || + (pthis->dialogState == TEXT_STATE_CLOSING) || (pthis->dialogState == TEXT_STATE_DONE_HAS_NEXT)) { + if (dialogState != pthis->dialogState) { + pthis->unk_20C++; + } + } + + pthis->dialogState = dialogState; + return dialogState; +} + +u16 EnGo2_GoronFireGenericGetTextId(EnGo2* pthis) { + switch ((pthis->actor.params & 0xFC00) >> 0xA) { + case 3: + return 0x3069; + case 5: + return 0x306A; + case 4: + return 0x306B; + case 2: + return 0x306C; + case 10: + return 0x306D; + case 8: + return 0x306E; + case 11: + return 0x306F; + case 1: + return 0x3070; + default: + return 0x3052; + } +} + +u16 EnGo2_GetTextIdGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* pthis) { + if (gSaveContext.infTable[17] & 0x4000) { + return 0x3013; + } else if (CUR_CAPACITY(UPG_BOMB_BAG) >= 20 && pthis->waypoint > 7 && pthis->waypoint < 12) { + return 0x3012; + } else { + return 0x3011; + } +} + +s16 EnGo2_GetStateGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* pthis) { + s32 bombBagUpgrade; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case TEXT_STATE_CLOSING: + return 2; + case TEXT_STATE_EVENT: + if (Message_ShouldAdvance(globalCtx)) { + if (pthis->actor.textId == 0x3012) { + pthis->actionFunc = EnGo2_SetupGetItem; + bombBagUpgrade = CUR_CAPACITY(UPG_BOMB_BAG) == 30 ? GI_BOMB_BAG_40 : GI_BOMB_BAG_30; + EnGo2_GetItem(pthis, globalCtx, bombBagUpgrade); + Message_CloseTextbox(globalCtx); + gSaveContext.infTable[17] |= 0x4000; + return 2; + } else { + return 2; + } + } + default: + return 1; + } +} + +u16 EnGo2_GetTextIdGoronDmtBombFlower(GlobalContext* globalCtx, EnGo2* pthis) { + return CHECK_QUEST_ITEM(QUEST_GORON_RUBY) ? 0x3027 : 0x300A; +} + +// DMT Goron by Bomb Flower Choice +s16 EnGo2_GetStateGoronDmtBombFlower(GlobalContext* globalCtx, EnGo2* pthis) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case TEXT_STATE_CLOSING: + if ((pthis->actor.textId == 0x300B) && (gSaveContext.infTable[14] & 0x800) == 0) { + gSaveContext.infTable[14] |= 0x800; + return 2; + } else { + return 0; + } + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(globalCtx)) { + // Ask question to DMT Goron by bomb flower + if (pthis->actor.textId == 0x300A) { + if (globalCtx->msgCtx.choiceIndex == 0) { + pthis->actor.textId = CUR_UPG_VALUE(UPG_STRENGTH) != 0 ? 0x300B : 0x300C; + } else { + pthis->actor.textId = 0x300D; + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } + return 1; + } + default: + return 1; + } +} + +u16 EnGo2_GetTextIdGoronDmtRollingSmall(GlobalContext* globalCtx, EnGo2* pthis) { + if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + return 0x3027; + } else { + return (gSaveContext.eventChkInf[2] & 0x8) ? 0x3026 : 0x3009; + } +} + +s16 EnGo2_GetStateGoronDmtRollingSmall(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextIdGoronDmtDcEntrance(GlobalContext* globalCtx, EnGo2* pthis) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { + return 0x3043; + } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + return 0x3027; + } else { + return gSaveContext.eventChkInf[2] & 0x8 ? 0x3021 : gSaveContext.infTable[14] & 0x1 ? 0x302A : 0x3008; + } +} + +s16 EnGo2_GetStateGoronDmtDcEntrance(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->actor.textId == 0x3008) { + gSaveContext.infTable[14] |= 0x1; + } + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextIdGoronCityEntrance(GlobalContext* globalCtx, EnGo2* pthis) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { + return 0x3043; + } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + return 0x3027; + } else { + return gSaveContext.infTable[15] & 0x1 ? 0x3015 : 0x3014; + } +} + +s16 EnGo2_GetStateGoronCityEntrance(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->actor.textId == 0x3014) { + gSaveContext.infTable[15] |= 0x1; + } + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextIdGoronCityIsland(GlobalContext* globalCtx, EnGo2* pthis) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { + return 0x3043; + } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + return 0x3067; + } else { + return gSaveContext.infTable[15] & 0x10 ? 0x3017 : 0x3016; + } +} + +s16 EnGo2_GetStateGoronCityIsland(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->actor.textId == 0x3016) { + gSaveContext.infTable[15] |= 0x10; + } + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextIdGoronCityLowestFloor(GlobalContext* globalCtx, EnGo2* pthis) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { + return 0x3043; + } else if (CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + return 0x3027; + } else { + return CUR_UPG_VALUE(UPG_STRENGTH) != 0 ? 0x302C + : !Flags_GetSwitch(globalCtx, 0x1B) ? 0x3017 + : gSaveContext.infTable[15] & 0x100 ? 0x3019 + : 0x3018; + } +} + +s16 EnGo2_GetStateGoronCityLowestFloor(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->actor.textId == 0x3018) { + gSaveContext.infTable[15] |= 0x100; + } + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextIdGoronCityLink(GlobalContext* globalCtx, EnGo2* pthis) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) { + return gSaveContext.infTable[16] & 0x8000 ? 0x3042 : 0x3041; + } else if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + return gSaveContext.infTable[16] & 0x4000 ? 0x3038 : 0x3037; + } else if (gSaveContext.infTable[16] & 0x1000) { + pthis->unk_20C = 0; + pthis->dialogState = TEXT_STATE_NONE; + return gSaveContext.infTable[16] & 0x400 ? 0x3033 : 0x3032; + } else { + return 0x3030; + } +} + +s16 EnGo2_GetStateGoronCityLink(GlobalContext* globalCtx, EnGo2* pthis) { + switch (EnGo2_GetDialogState(pthis, globalCtx)) { + case TEXT_STATE_CLOSING: + switch (pthis->actor.textId) { + case 0x3036: + EnGo2_GetItem(pthis, globalCtx, GI_TUNIC_GORON); + pthis->actionFunc = EnGo2_SetupGetItem; + return 2; + case 0x3037: + gSaveContext.infTable[16] |= 0x4000; + default: + return 0; + } + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(globalCtx)) { + if (pthis->actor.textId == 0x3034) { + if (globalCtx->msgCtx.choiceIndex == 0) { + pthis->actor.textId = gSaveContext.infTable[16] & 0x800 ? 0x3033 : 0x3035; + if (pthis->actor.textId == 0x3035) { + Audio_StopSfxById(NA_SE_EN_GOLON_CRY); + } + } else { + pthis->actor.textId = gSaveContext.infTable[16] & 0x800 ? 0x3036 : 0x3033; + if (pthis->actor.textId == 0x3036) { + Audio_StopSfxById(NA_SE_EN_GOLON_CRY); + } + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_20C = 0; + } + } else { + break; + } + return 1; + case TEXT_STATE_EVENT: + if (Message_ShouldAdvance(globalCtx)) { + switch (pthis->actor.textId) { + case 0x3035: + gSaveContext.infTable[16] |= 0x800; + case 0x3032: + case 0x3033: + pthis->actor.textId = 0x3034; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + return 1; + default: + return 2; + } + } + } + return 1; +} + +u16 EnGo2_GetTextIdGoronDmtBiggoron(GlobalContext* globalCtx, EnGo2* pthis) { + Player* player = GET_PLAYER(globalCtx); + + if (gSaveContext.bgsFlag) { + player->exchangeItemId = EXCH_ITEM_CLAIM_CHECK; + return 0x305E; + } else if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_CLAIM_CHECK) { + player->exchangeItemId = EXCH_ITEM_CLAIM_CHECK; + return 0x305E; + } else if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_PRESCRIPTION) { + player->exchangeItemId = EXCH_ITEM_EYEDROPS; + return 0x3058; + } else { + player->exchangeItemId = EXCH_ITEM_SWORD_BROKEN; + return 0x3053; + } +} + +s16 EnGo2_GetStateGoronDmtBiggoron(GlobalContext* globalCtx, EnGo2* pthis) { + s32 unusedPad; + u8 dialogState = pthis->dialogState; + + switch (EnGo2_GetDialogState(pthis, globalCtx)) { + case TEXT_STATE_DONE: + if (pthis->actor.textId == 0x305E) { + if (!gSaveContext.bgsFlag) { + EnGo2_GetItem(pthis, globalCtx, GI_SWORD_BGS); + pthis->actionFunc = EnGo2_SetupGetItem; + return 2; + } else { + return 0; + } + } else { + return 0; + } + case TEXT_STATE_DONE_FADING: + switch (pthis->actor.textId) { + case 0x305E: + if (func_8002F368(globalCtx) != EXCH_ITEM_CLAIM_CHECK) { + break; + } + case 0x3059: + if (dialogState == TEXT_STATE_NONE) { + func_800F4524(&D_801333D4, NA_SE_EN_GOLON_WAKE_UP, 60); + } + case 0x3054: + if (dialogState == TEXT_STATE_NONE) { + Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + return 1; + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(globalCtx)) { + if ((pthis->actor.textId == 0x3054) || (pthis->actor.textId == 0x3055)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + EnGo2_GetItem(pthis, globalCtx, GI_PRESCRIPTION); + pthis->actionFunc = EnGo2_SetupGetItem; + return 2; + } + pthis->actor.textId = 0x3056; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } + return 1; + } + break; + case TEXT_STATE_EVENT: + if (Message_ShouldAdvance(globalCtx)) { + if (pthis->actor.textId == 0x3059) { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->actionFunc = EnGo2_BiggoronEyedrops; + } + return 2; + } + } + return 1; +} + +u16 EnGo2_GetTextIdGoronFireGeneric(GlobalContext* globalCtx, EnGo2* pthis) { + if (Flags_GetSwitch(globalCtx, (pthis->actor.params & 0xFC00) >> 0xA)) { + return 0x3071; + } else { + return 0x3051; + } +} + +s16 EnGo2_GetStateGoronFireGeneric(GlobalContext* globalCtx, EnGo2* pthis) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case TEXT_STATE_CLOSING: + return 0; + case TEXT_STATE_EVENT: + if (Message_ShouldAdvance(globalCtx)) { + if (pthis->actor.textId == 0x3071) { + pthis->actor.textId = EnGo2_GoronFireGenericGetTextId(pthis); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } + return 1; + } + default: + return 1; + } +} + +u16 EnGo2_GetTextIdGoronCityStairwell(GlobalContext* globalCtx, EnGo2* pthis) { + return !LINK_IS_ADULT ? gSaveContext.infTable[14] & 0x8 ? 0x3022 : 0x300E : 0x3043; +} + +s16 EnGo2_GetStateGoronCityStairwell(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->actor.textId == 0x300E) { + gSaveContext.infTable[14] |= 0x8; + } + return 0; + } else { + return 1; + } +} + +// Goron in child market bazaar after obtaining Goron Ruby +u16 EnGo2_GetTextIdGoronMarketBazaar(GlobalContext* globalCtx, EnGo2* pthis) { + return 0x7122; +} + +s16 EnGo2_GetStateGoronMarketBazaar(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextIdGoronCityLostWoods(GlobalContext* globalCtx, EnGo2* pthis) { + if (!LINK_IS_ADULT) { + if (Flags_GetSwitch(globalCtx, 0x1C)) { + return 0x302F; + } else { + return gSaveContext.infTable[14] & 0x40 ? 0x3025 : 0x3024; + } + } else { + return 0x3043; + } +} + +s16 EnGo2_GetStateGoronCityLostWoods(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->actor.textId == 0x3024) { + gSaveContext.infTable[14] |= 0x40; + } + return 0; + } else { + return 1; + } +} + +// Goron at base of DMT summit +u16 EnGo2_GetTextIdGoronDmtFairyHint(GlobalContext* globalCtx, EnGo2* pthis) { + if (!LINK_IS_ADULT) { + return CHECK_QUEST_ITEM(QUEST_GORON_RUBY) ? 0x3065 : 0x3064; + } else { + return 0x3043; + } +} + +s16 EnGo2_GetStateGoronDmtFairyHint(GlobalContext* globalCtx, EnGo2* pthis) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + return 0; + } else { + return 1; + } +} + +u16 EnGo2_GetTextId(GlobalContext* globalCtx, Actor* thisx) { + EnGo2* pthis = (EnGo2*)thisx; + u16 faceReaction = Text_GetFaceReaction(globalCtx, 0x20); + + if (faceReaction) { + return faceReaction; + } else { + switch (pthis->actor.params & 0x1F) { + case GORON_CITY_ROLLING_BIG: + return EnGo2_GetTextIdGoronCityRollingBig(globalCtx, pthis); + case GORON_CITY_LINK: + return EnGo2_GetTextIdGoronCityLink(globalCtx, pthis); + case GORON_DMT_BIGGORON: + return EnGo2_GetTextIdGoronDmtBiggoron(globalCtx, pthis); + case GORON_FIRE_GENERIC: + return EnGo2_GetTextIdGoronFireGeneric(globalCtx, pthis); + case GORON_DMT_BOMB_FLOWER: + return EnGo2_GetTextIdGoronDmtBombFlower(globalCtx, pthis); + case GORON_DMT_ROLLING_SMALL: + return EnGo2_GetTextIdGoronDmtRollingSmall(globalCtx, pthis); + case GORON_DMT_DC_ENTRANCE: + return EnGo2_GetTextIdGoronDmtDcEntrance(globalCtx, pthis); + case GORON_CITY_ENTRANCE: + return EnGo2_GetTextIdGoronCityEntrance(globalCtx, pthis); + case GORON_CITY_ISLAND: + return EnGo2_GetTextIdGoronCityIsland(globalCtx, pthis); + case GORON_CITY_LOWEST_FLOOR: + return EnGo2_GetTextIdGoronCityLowestFloor(globalCtx, pthis); + case GORON_CITY_STAIRWELL: + return EnGo2_GetTextIdGoronCityStairwell(globalCtx, pthis); + case GORON_CITY_LOST_WOODS: + return EnGo2_GetTextIdGoronCityLostWoods(globalCtx, pthis); + case GORON_DMT_FAIRY_HINT: + return EnGo2_GetTextIdGoronDmtFairyHint(globalCtx, pthis); + case GORON_MARKET_BAZAAR: + return EnGo2_GetTextIdGoronMarketBazaar(globalCtx, pthis); + } + } + return 0; +} + +s16 EnGo2_GetState(GlobalContext* globalCtx, Actor* thisx) { + EnGo2* pthis = (EnGo2*)thisx; + switch (pthis->actor.params & 0x1F) { + case GORON_CITY_ROLLING_BIG: + return EnGo2_GetStateGoronCityRollingBig(globalCtx, pthis); + case GORON_CITY_LINK: + return EnGo2_GetStateGoronCityLink(globalCtx, pthis); + case GORON_DMT_BIGGORON: + return EnGo2_GetStateGoronDmtBiggoron(globalCtx, pthis); + case GORON_FIRE_GENERIC: + return EnGo2_GetStateGoronFireGeneric(globalCtx, pthis); + case GORON_DMT_BOMB_FLOWER: + return EnGo2_GetStateGoronDmtBombFlower(globalCtx, pthis); + case GORON_DMT_ROLLING_SMALL: + return EnGo2_GetStateGoronDmtRollingSmall(globalCtx, pthis); + case GORON_DMT_DC_ENTRANCE: + return EnGo2_GetStateGoronDmtDcEntrance(globalCtx, pthis); + case GORON_CITY_ENTRANCE: + return EnGo2_GetStateGoronCityEntrance(globalCtx, pthis); + case GORON_CITY_ISLAND: + return EnGo2_GetStateGoronCityIsland(globalCtx, pthis); + case GORON_CITY_LOWEST_FLOOR: + return EnGo2_GetStateGoronCityLowestFloor(globalCtx, pthis); + case GORON_CITY_STAIRWELL: + return EnGo2_GetStateGoronCityStairwell(globalCtx, pthis); + case GORON_CITY_LOST_WOODS: + return EnGo2_GetStateGoronCityLostWoods(globalCtx, pthis); + case GORON_DMT_FAIRY_HINT: + return EnGo2_GetStateGoronDmtFairyHint(globalCtx, pthis); + case GORON_MARKET_BAZAAR: + return EnGo2_GetStateGoronMarketBazaar(globalCtx, pthis); + } + return 0; +} + +s32 func_80A44790(EnGo2* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params & 0x1F) != GORON_DMT_BIGGORON && (pthis->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG) { + return func_800343CC(globalCtx, &pthis->actor, &pthis->unk_194.unk_00, pthis->unk_218, EnGo2_GetTextId, + EnGo2_GetState); + } else if (((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) && ((pthis->collider.base.ocFlags2 & 1) == 0)) { + return false; + } else { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_194.unk_00 = 1; + return true; + } else if (pthis->unk_194.unk_00 != 0) { + pthis->unk_194.unk_00 = EnGo2_GetState(globalCtx, &pthis->actor); + return false; + } else if (func_8002F2CC(&pthis->actor, globalCtx, pthis->unk_218)) { + pthis->actor.textId = EnGo2_GetTextId(globalCtx, &pthis->actor); + } + return false; + } +} + +void EnGo2_SetColliderDim(EnGo2* pthis) { + u8 index = pthis->actor.params & 0x1F; + + pthis->collider.dim.radius = D_80A4816C[index].radius; + pthis->collider.dim.height = D_80A4816C[index].height; +} + +void EnGo2_SetShape(EnGo2* pthis) { + u8 index = pthis->actor.params & 0x1F; + + pthis->actor.shape.shadowScale = D_80A481F8[index].shape_unk_10; + Actor_SetScale(&pthis->actor, D_80A481F8[index].scale); + pthis->actor.targetMode = D_80A481F8[index].actor_unk_1F; + pthis->unk_218 = D_80A481F8[index].unk_218; + pthis->unk_218 += pthis->collider.dim.radius; +} + +void EnGo2_CheckCollision(EnGo2* pthis, GlobalContext* globalCtx) { + Vec3s pos; + f32 xzDist; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z; + xzDist = D_80A4816C[pthis->actor.params & 0x1F].xzDist; + pos.x += (s16)(xzDist * Math_SinS(pthis->actor.shape.rot.y)); + pos.z += (s16)(xzDist * Math_CosS(pthis->actor.shape.rot.y)); + pos.y += D_80A4816C[pthis->actor.params & 0x1F].yDist; + pthis->collider.dim.pos = pos; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnGo2_SwapInitialFrameAnimFrameCount(EnGo2* pthis) { + f32 initialFrame; + + initialFrame = pthis->skelAnime.startFrame; + pthis->skelAnime.startFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.endFrame = initialFrame; +} + +s32 func_80A44AB0(EnGo2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 arg2; + + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + return false; + } else { + if ((pthis->actionFunc != EnGo2_SlowRolling) && (pthis->actionFunc != EnGo2_ReverseRolling) && + (pthis->actionFunc != EnGo2_ContinueRolling)) { + return false; + } else { + if (pthis->collider.base.acFlags & 2) { + Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->actor.flags &= ~ACTOR_FLAG_24; + pthis->collider.base.acFlags &= ~0x2; + EnGo2_StopRolling(pthis, globalCtx); + return true; + } + if (player->invincibilityTimer <= 0) { + pthis->collider.base.ocFlags1 |= 8; + } else { + return false; + } + if (pthis->collider.base.ocFlags2 & 1) { + pthis->collider.base.ocFlags2 &= ~1; + + arg2 = pthis->actionFunc == EnGo2_ContinueRolling ? 1.5f : pthis->actor.speedXZ * 1.5f; + + globalCtx->damagePlayer(globalCtx, -4); + func_8002F71C(globalCtx, &pthis->actor, arg2, pthis->actor.yawTowardsPlayer, 6.0f); + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + pthis->collider.base.ocFlags1 &= ~0x8; + } + } + } + return false; +} + +s32 EnGo2_UpdateWaypoint(EnGo2* pthis, GlobalContext* globalCtx) { + s32 change; + + if (pthis->path == NULL) { + return 0; + } + + change = (u8)(pthis->path->count - 1); + if (pthis->reverse) { + pthis->waypoint--; + if (pthis->waypoint < 0) { + pthis->waypoint = change - 1; + } + } else { + pthis->waypoint++; + if (pthis->waypoint >= change) { + pthis->waypoint = 0; + } + } + + return 1; +} + +s32 EnGo2_Orient(EnGo2* pthis, GlobalContext* globalCtx) { + s16 targetYaw; + f32 waypointDistSq = Path_OrientAndGetDistSq(&pthis->actor, pthis->path, pthis->waypoint, &targetYaw); + + Math_SmoothStepToS(&pthis->actor.world.rot.y, targetYaw, 6, 4000, 1); + if (waypointDistSq > 0.0f && waypointDistSq < SQ(30.0f)) { + return EnGo2_UpdateWaypoint(pthis, globalCtx); + } else { + return 0; + } +} + +s32 func_80A44D84(EnGo2* pthis) { + s16 targetYaw; + + Path_OrientAndGetDistSq(&pthis->actor, pthis->path, pthis->waypoint, &targetYaw); + pthis->actor.world.rot.y = targetYaw; + return 1; +} + +s32 EnGo2_IsWakingUp(EnGo2* pthis) { + s16 yawDiff; + f32 xyzDist = (pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 800.0f : 200.0f; + f32 yDist = (pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 400.0f : 60.0f; + s16 yawDiffAbs; + + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + if ((pthis->collider.base.ocFlags2 & 1) == 0) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + return false; + } else { + pthis->actor.flags |= ACTOR_FLAG_0; + return true; + } + } + + xyzDist = SQ(xyzDist); + yawDiff = (f32)pthis->actor.yawTowardsPlayer - (f32)pthis->actor.shape.rot.y; + yawDiffAbs = ABS(yawDiff); + if (pthis->actor.xyzDistToPlayerSq <= xyzDist && fabsf(pthis->actor.yDistToPlayer) < yDist && yawDiffAbs < 0x2AA8) { + return true; + } else { + return false; + } +} + +s32 EnGo2_IsRollingOnGround(EnGo2* pthis, s16 arg1, f32 arg2, s16 arg3) { + if ((pthis->actor.bgCheckFlags & 1) == 0 || pthis->actor.velocity.y > 0.0f) { + return false; + } + + if (DECR(pthis->unk_590)) { + if (!arg3) { + return true; + } else { + pthis->actor.world.pos.y = + (pthis->unk_590 & 1) ? pthis->actor.world.pos.y + 1.5f : pthis->actor.world.pos.y - 1.5f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); + return true; + } + } + + if (pthis->unk_59C >= 2) { + Audio_PlayActorSound2(&pthis->actor, (pthis->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG + ? NA_SE_EN_GOLON_LAND_BIG + : NA_SE_EN_DODO_M_GND); + } + + pthis->unk_59C--; + if (pthis->unk_59C <= 0) { + if (pthis->unk_59C == 0) { + pthis->unk_590 = Rand_S16Offset(60, 30); + pthis->unk_59C = 0; + pthis->actor.velocity.y = 0.0f; + return true; + } else { + pthis->unk_59C = arg1; + } + } + + pthis->actor.velocity.y = ((f32)pthis->unk_59C / (f32)arg1) * arg2; + return true; +} + +void EnGo2_BiggoronSetTextId(EnGo2* pthis, GlobalContext* globalCtx, Player* player) { + u16 textId; + + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + if (gSaveContext.bgsFlag) { + if (func_8002F368(globalCtx) == EXCH_ITEM_CLAIM_CHECK) { + pthis->actor.textId = 0x3003; + } else { + pthis->actor.textId = 0x305E; + } + player->actor.textId = pthis->actor.textId; + + } else if (!gSaveContext.bgsFlag && (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_CLAIM_CHECK)) { + if (func_8002F368(globalCtx) == EXCH_ITEM_CLAIM_CHECK) { + if (Environment_GetBgsDayCount() >= 3) { + textId = 0x305E; + } else { + textId = 0x305D; + } + pthis->actor.textId = textId; + } else { + if (Environment_GetBgsDayCount() >= 3) { + textId = 0x3002; + } else { + textId = 0x305D; + } + pthis->actor.textId = textId; + } + player->actor.textId = pthis->actor.textId; + + } else if ((INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_PRESCRIPTION) && + (INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_CLAIM_CHECK)) { + if (func_8002F368(globalCtx) == EXCH_ITEM_EYEDROPS) { + pthis->actor.textId = 0x3059; + } else { + pthis->actor.textId = 0x3058; + } + if (pthis->actor.textId == 0x3059) { + gSaveContext.timer2State = 0; + } + player->actor.textId = pthis->actor.textId; + + } else if (INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_SWORD_BROKEN) { + if (func_8002F368(globalCtx) == EXCH_ITEM_SWORD_BROKEN) { + if (gSaveContext.infTable[11] & 0x10) { + textId = 0x3055; + } else { + textId = 0x3054; + } + pthis->actor.textId = textId; + } else { + pthis->actor.textId = 0x3053; + } + player->actor.textId = pthis->actor.textId; + } else { + pthis->actor.textId = 0x3053; + player->actor.textId = pthis->actor.textId; + } + } +} + +void func_80A45288(EnGo2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 linkAge; + + if (pthis->actionFunc != EnGo2_GoronFireGenericAction) { + pthis->unk_194.unk_18 = player->actor.world.pos; + linkAge = gSaveContext.linkAge; + pthis->unk_194.unk_14 = D_80A482D8[pthis->actor.params & 0x1F][linkAge]; + func_80034A14(&pthis->actor, &pthis->unk_194, 4, pthis->unk_26E); + } + if ((pthis->actionFunc != EnGo2_SetGetItem) && (pthis->isAwake == true)) { + if (func_80A44790(pthis, globalCtx)) { + EnGo2_BiggoronSetTextId(pthis, globalCtx, player); + } + } +} + +void func_80A45360(EnGo2* pthis, f32* alpha) { + f32 alphaTarget = + (pthis->skelAnime.animation == &gGoronAnim_004930) && (pthis->skelAnime.curFrame <= 32.0f) ? 0.0f : 255.0f; + + Math_ApproachF(alpha, alphaTarget, 0.4f, 100.0f); + pthis->actor.shape.shadowAlpha = (u8)(u32)*alpha; +} + +void EnGo2_RollForward(EnGo2* pthis) { + f32 speedXZ = pthis->actor.speedXZ; + + if (pthis->unk_194.unk_00 != 0) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actionFunc != EnGo2_ContinueRolling) { + Actor_MoveForward(&pthis->actor); + } + + pthis->actor.speedXZ = speedXZ; +} + +void func_80A454CC(EnGo2* pthis) { + switch (pthis->actor.params & 0x1F) { + case GORON_CITY_ROLLING_BIG: + case GORON_DMT_DC_ENTRANCE: + case GORON_CITY_ENTRANCE: + case GORON_CITY_STAIRWELL: + case GORON_DMT_FAIRY_HINT: + func_80034EC0(&pthis->skelAnime, sAnimations, 9); + break; + case GORON_DMT_BIGGORON: + if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_SWORD_BROKEN && INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_EYEDROPS) { + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + break; + } + default: + pthis->skelAnime.playSpeed = 0.0f; + break; + } +} + +f32 EnGo2_GetTargetXZSpeed(EnGo2* pthis) { + f32 yDist = (pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 400.0f : 60.0f; + s32 index = pthis->actor.params & 0x1F; + + if (index == GORON_CITY_LINK && (fabsf(pthis->actor.yDistToPlayer) < yDist) && + (pthis->actor.xzDistToPlayer < 400.0f)) { + return 9.0f; + } else { + return index == GORON_CITY_ROLLING_BIG ? 3.6000001f : 6.0f; + } +} + +s32 EnGo2_IsCameraModified(EnGo2* pthis, GlobalContext* globalCtx) { + Camera* camera = globalCtx->cameraPtrs[MAIN_CAM]; + + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + if (EnGo2_IsWakingUp(pthis)) { + Camera_ChangeSetting(camera, CAM_SET_DIRECTED_YAW); + func_8005AD1C(camera, 4); + } else if (!EnGo2_IsWakingUp(pthis) && (camera->setting == CAM_SET_DIRECTED_YAW)) { + Camera_ChangeSetting(camera, CAM_SET_DUNGEON1); + func_8005ACFC(camera, 4); + } + } + + if ((pthis->actor.params & 0x1F) == GORON_FIRE_GENERIC || (pthis->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG || + (pthis->actor.params & 0x1F) == GORON_CITY_STAIRWELL || (pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON || + (pthis->actor.params & 0x1F) == GORON_MARKET_BAZAAR) { + return true; + } else if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + return true; + } else { + return false; + } +} + +void EnGo2_DefaultWakingUp(EnGo2* pthis) { + if (EnGo2_IsWakingUp(pthis)) { + pthis->unk_26E = 2; + } else { + pthis->unk_26E = 1; + } + + if (pthis->unk_194.unk_00 != 0) { + pthis->unk_26E = 4; + } + + pthis->isAwake = true; +} + +void EnGo2_WakingUp(EnGo2* pthis) { + f32 xyzDist = (pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON ? 800.0f : 200.0f; + s32 isTrue = true; + + xyzDist = SQ(xyzDist); + pthis->unk_26E = 1; + if ((pthis->actor.xyzDistToPlayerSq <= xyzDist) || (pthis->unk_194.unk_00 != 0)) { + pthis->unk_26E = 4; + } + + pthis->isAwake = isTrue; +} + +void EnGo2_BiggoronWakingUp(EnGo2* pthis) { + if (EnGo2_IsWakingUp(pthis) || pthis->unk_194.unk_00 != 0) { + pthis->unk_26E = 2; + pthis->isAwake = true; + } else { + pthis->unk_26E = 1; + pthis->isAwake = false; + } +} + +void EnGo2_SelectGoronWakingUp(EnGo2* pthis) { + switch (pthis->actor.params & 0x1F) { + case GORON_DMT_BOMB_FLOWER: + pthis->isAwake = true; + pthis->unk_26E = EnGo2_IsWakingUp(pthis) ? 2 : 1; + break; + case GORON_FIRE_GENERIC: + EnGo2_WakingUp(pthis); + break; + case GORON_DMT_BIGGORON: + EnGo2_BiggoronWakingUp(pthis); + break; + case GORON_CITY_LINK: + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + EnGo2_WakingUp(pthis); + break; + } + default: + EnGo2_DefaultWakingUp(pthis); + } +} + +void EnGo2_EyeMouthTexState(EnGo2* pthis) { + switch (pthis->eyeMouthTexState) { + case 1: + pthis->blinkTimer = 0; + pthis->eyeTexIndex = 0; + pthis->mouthTexIndex = 0; + break; + case 2: + pthis->blinkTimer = 0; + pthis->eyeTexIndex = 1; + pthis->mouthTexIndex = 0; + break; + // case 3 only when biggoron is given eyedrops. Biggoron smiles. (only use of second mouth texture) + case 3: + pthis->blinkTimer = 0; + pthis->eyeTexIndex = 0; + pthis->mouthTexIndex = 1; + break; + default: + if (DECR(pthis->blinkTimer) == 0) { + pthis->eyeTexIndex++; + if (pthis->eyeTexIndex >= 4) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeTexIndex = 1; + } + } + } +} + +void EnGo2_SitDownAnimation(EnGo2* pthis) { + if ((pthis->skelAnime.playSpeed != 0.0f) && (pthis->skelAnime.animation == &gGoronAnim_004930)) { + if (pthis->skelAnime.playSpeed > 0.0f && pthis->skelAnime.curFrame == 14.0f) { + if ((pthis->actor.params & 0x1F) != GORON_DMT_BIGGORON) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOLON_SIT_DOWN); + } else { + func_800F4524(&D_801333D4, NA_SE_EN_GOLON_SIT_DOWN, 60); + } + } + if (pthis->skelAnime.playSpeed < 0.0f) { + if (pthis->skelAnime.curFrame == 1.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + if (pthis->skelAnime.curFrame == 40.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOLON_SIT_DOWN); + } + } + } +} + +void EnGo2_GetDustData(EnGo2* pthis, s32 index2) { + s32 index1 = (pthis->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG ? 1 : 0; + EnGo2DustEffectData* dustEffectData = &sDustEffectData[index1][index2]; + + EnGo2_SpawnDust(pthis, dustEffectData->initialTimer, dustEffectData->scale, dustEffectData->scaleStep, + dustEffectData->numDustEffects, dustEffectData->radius, dustEffectData->yAccel); +} + +void EnGo2_RollingAnimation(EnGo2* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + pthis->skelAnime.playSpeed = -0.5f; + } else { + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->skelAnime.playSpeed = -1.0f; + } + EnGo2_SwapInitialFrameAnimFrameCount(pthis); + pthis->unk_26E = 1; + pthis->unk_211 = false; + pthis->isAwake = false; + pthis->actionFunc = EnGo2_CurledUp; +} + +void EnGo2_WakeUp(EnGo2* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.playSpeed == 0.0f) { + if ((pthis->actor.params & 0x1F) != GORON_DMT_BIGGORON) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOLON_WAKE_UP); + } else { + func_800F4524(&D_801333D4, NA_SE_EN_GOLON_WAKE_UP, 60); + } + } + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + OnePointCutscene_Init(globalCtx, 4200, -99, &pthis->actor, MAIN_CAM); + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + pthis->skelAnime.playSpeed = 0.5f; + } else { + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->skelAnime.playSpeed = 1.0f; + } + pthis->actionFunc = func_80A46B40; +} + +void EnGo2_GetItemAnimation(EnGo2* pthis, GlobalContext* globalCtx) { + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->unk_211 = true; + pthis->actionFunc = func_80A46B40; + pthis->skelAnime.playSpeed = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; +} + +void EnGo2_SetupRolling(EnGo2* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params & 0x1F) == GORON_CITY_ROLLING_BIG || (pthis->actor.params & 0x1F) == GORON_CITY_LINK) { + pthis->collider.info.bumperFlags = 1; + pthis->actor.speedXZ = gSaveContext.infTable[17] & 0x4000 ? 6.0f : 3.6000001f; + } else { + pthis->actor.speedXZ = 6.0f; + } + pthis->actor.flags |= ACTOR_FLAG_24; + pthis->animTimer = 10; + pthis->actor.shape.yOffset = 1800.0f; + pthis->actor.speedXZ += pthis->actor.speedXZ; // Speeding up + pthis->actionFunc = EnGo2_ContinueRolling; +} + +void EnGo2_StopRolling(EnGo2* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + + if (((pthis->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG) && ((pthis->actor.params & 0x1F) != GORON_CITY_LINK)) { + if ((pthis->actor.params & 0x1F) == GORON_DMT_ROLLING_SMALL) { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + } + } else { + pthis->collider.info.bumperFlags = 0; + } + + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->unk_59C = 0; + pthis->unk_590 = 0; + pthis->actionFunc = EnGo2_GroundRolling; + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.speedXZ = 0.0f; +} + +s32 EnGo2_IsFreeingGoronInFire(EnGo2* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params & 0x1F) != GORON_FIRE_GENERIC) { + return false; + } + + // shaking curled up + pthis->actor.world.pos.x += (globalCtx->state.frames & 1) ? 1.0f : -1.0f; + if (Flags_GetSwitch(globalCtx, (pthis->actor.params & 0xFC00) >> 0xA)) { + return true; + } + return false; +} + +s32 EnGo2_IsGoronDmtBombFlower(EnGo2* pthis) { + if ((pthis->actor.params & 0x1F) != GORON_DMT_BOMB_FLOWER || pthis->unk_194.unk_00 != 2) { + return false; + } + + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->unk_194.unk_00 = 0; + pthis->isAwake = false; + pthis->unk_26E = 1; + pthis->actionFunc = EnGo2_GoronDmtBombFlowerAnimation; + return true; +} + +s32 EnGo2_IsGoronRollingBig(EnGo2* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG || (pthis->unk_194.unk_00 != 2)) { + return false; + } + pthis->unk_194.unk_00 = 0; + EnGo2_RollingAnimation(pthis, globalCtx); + pthis->actionFunc = EnGo2_GoronRollingBigContinueRolling; + return true; +} + +s32 EnGo2_IsGoronFireGeneric(EnGo2* pthis) { + if ((pthis->actor.params & 0x1F) != GORON_FIRE_GENERIC || pthis->unk_194.unk_00 == 0) { + return false; + } + pthis->actionFunc = EnGo2_GoronFireGenericAction; + return true; +} + +s32 EnGo2_IsGoronLinkReversing(EnGo2* pthis) { + if ((pthis->actor.params & 0x1F) != GORON_CITY_LINK || (pthis->waypoint >= pthis->unk_216) || + !EnGo2_IsWakingUp(pthis)) { + return false; + } + return true; +} + +s32 EnGo2_IsRolling(EnGo2* pthis) { + if (pthis->unk_194.unk_00 == 0 || pthis->actor.speedXZ < 1.0f) { + return false; + } + if (EnGo2_IsRollingOnGround(pthis, 2, 20.0 / 3.0f, 0)) { + if ((pthis->unk_590 >= 9) && (pthis->unk_59C == 0)) { + pthis->unk_590 = 8; + } + EnGo2_GetDustData(pthis, 0); + } + return true; +} + +void EnGo2_GoronLinkAnimation(EnGo2* pthis, GlobalContext* globalCtx) { + s32 animation = 13; + + if ((pthis->actor.params & 0x1F) == GORON_CITY_LINK) { + if ((pthis->actor.textId == 0x3035 && pthis->unk_20C == 0) || + (pthis->actor.textId == 0x3036 && pthis->unk_20C == 0)) { + if (pthis->skelAnime.animation != &gGoronAnim_000D5C) { + animation = 12; + pthis->eyeMouthTexState = 0; + } + } + + if ((pthis->actor.textId == 0x3032 && pthis->unk_20C == 12) || (pthis->actor.textId == 0x3033) || + (pthis->actor.textId == 0x3035 && pthis->unk_20C == 6)) { + if (pthis->skelAnime.animation != &gGoronAnim_000750) { + animation = 11; + pthis->eyeMouthTexState = 1; + } + } + + if (pthis->skelAnime.animation == &gGoronAnim_000750) { + if (pthis->skelAnime.curFrame == 20.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOLON_CRY); + } + } + + if (animation != 13) { + func_80034EC0(&pthis->skelAnime, sAnimations, animation); + } + } +} + +void EnGo2_GoronFireCamera(EnGo2* pthis, GlobalContext* globalCtx) { + s16 yaw; + + pthis->camId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->camId, CAM_STAT_ACTIVE); + Path_CopyLastPoint(pthis->path, &pthis->at); + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->at) + 0xE38; + pthis->eye.x = Math_SinS(yaw) * 100.0f + pthis->actor.world.pos.x; + pthis->eye.z = Math_CosS(yaw) * 100.0f + pthis->actor.world.pos.z; + pthis->eye.y = pthis->actor.world.pos.y + 20.0f; + pthis->at.x = pthis->actor.world.pos.x; + pthis->at.y = pthis->actor.world.pos.y + 40.0f; + pthis->at.z = pthis->actor.world.pos.z; + Gameplay_CameraSetAtEye(globalCtx, pthis->camId, &pthis->at, &pthis->eye); +} + +void EnGo2_GoronFireClearCamera(EnGo2* pthis, GlobalContext* globalCtx) { + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, pthis->camId); +} + +void EnGo2_BiggoronAnimation(EnGo2* pthis) { + if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_SWORD_BROKEN && INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_EYEDROPS && + (pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON && pthis->unk_194.unk_00 == 0) { + if (DECR(pthis->animTimer) == 0) { + pthis->animTimer = Rand_S16Offset(30, 30); + func_800F4524(&D_801333D4, NA_SE_EN_GOLON_EYE_BIG, 60); + } + } +} + +void EnGo2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGo2* pthis = (EnGo2*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGoronSkel, NULL, pthis->jointTable, pthis->morphTable, 18); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + + // Not GORON_CITY_ROLLING_BIG, GORON_CITY_LINK, GORON_DMT_BIGGORON + switch (pthis->actor.params & 0x1F) { + case GORON_FIRE_GENERIC: + case GORON_DMT_BOMB_FLOWER: + case GORON_DMT_ROLLING_SMALL: + case GORON_DMT_DC_ENTRANCE: + case GORON_CITY_ENTRANCE: + case GORON_CITY_ISLAND: + case GORON_CITY_LOWEST_FLOOR: + case GORON_CITY_STAIRWELL: + case GORON_CITY_LOST_WOODS: + case GORON_DMT_FAIRY_HINT: + case GORON_MARKET_BAZAAR: + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.flags &= ~ACTOR_FLAG_5; + } + + EnGo2_SetColliderDim(pthis); + EnGo2_SetShape(pthis); + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + pthis->actor.gravity = -1.0f; + pthis->alpha = pthis->actor.shape.shadowAlpha = 0; + pthis->reverse = 0; + pthis->isAwake = false; + pthis->unk_211 = false; + pthis->goronState = 0; + pthis->waypoint = 0; + pthis->unk_216 = pthis->actor.shape.rot.z; + pthis->unk_26E = 1; + pthis->path = Path_GetByIndex(globalCtx, (pthis->actor.params & 0x3E0) >> 5, 0x1F); + switch (pthis->actor.params & 0x1F) { + case GORON_CITY_ENTRANCE: + case GORON_CITY_ISLAND: + case GORON_CITY_LOWEST_FLOOR: + case GORON_CITY_STAIRWELL: + case GORON_CITY_LOST_WOODS: + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && LINK_IS_ADULT) { + Actor_Kill(&pthis->actor); + } + pthis->actionFunc = EnGo2_CurledUp; + break; + case GORON_MARKET_BAZAAR: + if ((LINK_IS_ADULT) || !CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { + Actor_Kill(&pthis->actor); + } + EnGo2_GetItemAnimation(pthis, globalCtx); + break; + case GORON_CITY_LINK: + if ((gSaveContext.infTable[16] & 0x200)) { + Path_CopyLastPoint(pthis->path, &pthis->actor.world.pos); + pthis->actor.home.pos = pthis->actor.world.pos; + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + EnGo2_GetItemAnimation(pthis, globalCtx); + } else { + pthis->actionFunc = EnGo2_CurledUp; + } + } else { + gSaveContext.infTable[16] &= ~0x1000; + pthis->collider.dim.height = (D_80A4816C[pthis->actor.params & 0x1F].height * 0.6f); + EnGo2_SetupRolling(pthis, globalCtx); + pthis->isAwake = true; + } + break; + case GORON_CITY_ROLLING_BIG: + case GORON_DMT_ROLLING_SMALL: + pthis->collider.dim.height = (D_80A4816C[pthis->actor.params & 0x1F].height * 0.6f); + EnGo2_SetupRolling(pthis, globalCtx); + break; + case GORON_FIRE_GENERIC: + if (Flags_GetSwitch(globalCtx, (pthis->actor.params & 0xFC00) >> 0xA)) { + Actor_Kill(&pthis->actor); + } else { + pthis->isAwake = true; + pthis->actionFunc = EnGo2_CurledUp; + } + break; + case GORON_DMT_BIGGORON: + pthis->actor.shape.shadowDraw = NULL; + pthis->actor.flags &= ~ACTOR_FLAG_0; + if ((INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_SWORD_BROKEN) && + (INV_CONTENT(ITEM_TRADE_ADULT) <= ITEM_EYEDROPS)) { + pthis->eyeMouthTexState = 1; + } + pthis->collider.base.acFlags = 0; + pthis->collider.base.ocFlags1 = 0xD; // OC_PLAYER | OC_NO_PUSH | OC_ON + pthis->actionFunc = EnGo2_CurledUp; + break; + case GORON_DMT_BOMB_FLOWER: + if (gSaveContext.infTable[14] & 0x800) { + Path_CopyLastPoint(pthis->path, &pthis->actor.world.pos); + pthis->actor.home.pos = pthis->actor.world.pos; + } + case GORON_DMT_DC_ENTRANCE: + case GORON_DMT_FAIRY_HINT: + default: + pthis->actionFunc = EnGo2_CurledUp; + } +} + +void EnGo2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGo2_CurledUp(EnGo2* pthis, GlobalContext* globalCtx) { + u8 index = pthis->actor.params & 0x1F; + s16 height; + s32 quake; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(quake, -0x3CB0); + Quake_SetQuakeValues(quake, 8, 0, 0, 0); + Quake_SetCountdown(quake, 16); + } else { + EnGo2_GetDustData(pthis, 1); + } + pthis->skelAnime.playSpeed = 0.0f; + } + + if ((s32)pthis->skelAnime.curFrame == 0) { + pthis->collider.dim.height = (D_80A4816C[index].height * 0.6f); + } else { + height = D_80A4816C[index].height; + pthis->collider.dim.height = + ((D_80A4816C[index].height * 0.4f * (pthis->skelAnime.curFrame / pthis->skelAnime.startFrame)) + + (height * 0.6f)); + } + if (EnGo2_IsFreeingGoronInFire(pthis, globalCtx)) { + pthis->isAwake = false; + EnGo2_WakeUp(pthis, globalCtx); + } + if (((pthis->actor.params & 0x1F) != GORON_FIRE_GENERIC) && EnGo2_IsWakingUp(pthis)) { + EnGo2_WakeUp(pthis, globalCtx); + } +} + +void func_80A46B40(EnGo2* pthis, GlobalContext* globalCtx) { + u8 index = (pthis->actor.params & 0x1F); + f32 height; + + if (pthis->unk_211 == true) { + EnGo2_BiggoronAnimation(pthis); + EnGo2_GoronLinkAnimation(pthis, globalCtx); + EnGo2_SelectGoronWakingUp(pthis); + + if (!EnGo2_IsGoronRollingBig(pthis, globalCtx) && !EnGo2_IsGoronFireGeneric(pthis)) { + if (EnGo2_IsGoronDmtBombFlower(pthis)) { + return; + } + } else { + return; + } + } else { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + if ((pthis->actor.params & 0x1F) == GORON_DMT_BIGGORON) { + pthis->actor.flags |= ACTOR_FLAG_0; + } + func_80A454CC(pthis); + pthis->unk_211 = true; + pthis->collider.dim.height = D_80A4816C[index].height; + } else { + height = D_80A4816C[index].height; + pthis->collider.dim.height = + (s16)((height * 0.4f * (pthis->skelAnime.curFrame / pthis->skelAnime.endFrame)) + (height * 0.6f)); + } + } + if ((!EnGo2_IsCameraModified(pthis, globalCtx)) && (!EnGo2_IsWakingUp(pthis))) { + EnGo2_RollingAnimation(pthis, globalCtx); + } +} + +void EnGo2_GoronDmtBombFlowerAnimation(EnGo2* pthis, GlobalContext* globalCtx) { + f32 float1 = pthis->skelAnime.endFrame; + f32 float2 = pthis->skelAnime.curFrame * ((f32)0x8000 / float1); + + pthis->actor.speedXZ = Math_SinS(float2); + if ((EnGo2_Orient(pthis, globalCtx)) && (pthis->waypoint == 0)) { + EnGo2_GetItemAnimation(pthis, globalCtx); + } +} + +void EnGo2_GoronRollingBigContinueRolling(EnGo2* pthis, GlobalContext* globalCtx) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + EnGo2_GetDustData(pthis, 1); + pthis->skelAnime.playSpeed = 0.0f; + EnGo2_SetupRolling(pthis, globalCtx); + } +} + +void EnGo2_ContinueRolling(EnGo2* pthis, GlobalContext* globalCtx) { + f32 float1 = 1000.0f; + + if (((pthis->actor.params & 0x1F) != GORON_DMT_ROLLING_SMALL || !(pthis->actor.xyzDistToPlayerSq > SQ(float1))) && + DECR(pthis->animTimer) == 0) { + pthis->actionFunc = EnGo2_SlowRolling; + pthis->actor.speedXZ *= 0.5f; // slowdown + } + EnGo2_GetDustData(pthis, 2); +} + +void EnGo2_SlowRolling(EnGo2* pthis, GlobalContext* globalCtx) { + s32 orientation; + s32 index; + + if (!EnGo2_IsRolling(pthis)) { + if (EnGo2_IsRollingOnGround(pthis, 4, 8.0f, 1) == true) { + if (EnGo2_IsGoronLinkReversing(pthis)) { + pthis->actionFunc = EnGo2_ReverseRolling; + return; + } + EnGo2_GetDustData(pthis, 3); + } + orientation = EnGo2_Orient(pthis, globalCtx); + index = pthis->actor.params & 0x1F; + if (index != GORON_CITY_LINK) { + if ((index == GORON_DMT_ROLLING_SMALL) && (orientation == 1) && (pthis->waypoint == 0)) { + EnGo2_StopRolling(pthis, globalCtx); + return; + } + } else if ((orientation == 2) && (pthis->waypoint == 1)) { + EnGo2_StopRolling(pthis, globalCtx); + return; + } + Math_ApproachF(&pthis->actor.speedXZ, EnGo2_GetTargetXZSpeed(pthis), 0.4f, 0.6f); + pthis->actor.shape.rot = pthis->actor.world.rot; + } +} + +void EnGo2_GroundRolling(EnGo2* pthis, GlobalContext* globalCtx) { + if (EnGo2_IsRollingOnGround(pthis, 4, 8.0f, 0)) { + EnGo2_GetDustData(pthis, 0); + if (pthis->unk_59C == 0) { + switch (pthis->actor.params & 0x1F) { + case GORON_CITY_LINK: + pthis->goronState = 0; + pthis->actionFunc = EnGo2_GoronLinkStopRolling; + break; + case GORON_CITY_ROLLING_BIG: + EnGo2_WakeUp(pthis, globalCtx); + break; + default: + pthis->actionFunc = EnGo2_CurledUp; + } + } + } +} + +void EnGo2_ReverseRolling(EnGo2* pthis, GlobalContext* globalCtx) { + if (!EnGo2_IsRolling(pthis)) { + Math_ApproachF(&pthis->actor.speedXZ, 0.0f, 0.6f, 0.8f); + if (pthis->actor.speedXZ >= 1.0f) { + EnGo2_GetDustData(pthis, 3); + } + if ((s32)pthis->actor.speedXZ == 0) { + pthis->actor.world.rot.y ^= 0x8000; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->reverse ^= 1; + EnGo2_UpdateWaypoint(pthis, globalCtx); + EnGo2_SetupRolling(pthis, globalCtx); + } + } +} + +void EnGo2_SetupGetItem(EnGo2* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnGo2_SetGetItem; + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, pthis->actor.xzDistToPlayer + 1.0f, + fabsf(pthis->actor.yDistToPlayer) + 1.0f); + } +} + +void EnGo2_SetGetItem(EnGo2* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + pthis->unk_194.unk_00 = 0; + switch (pthis->getItemId) { + case GI_CLAIM_CHECK: + Environment_ClearBgsDayCount(); + EnGo2_GetItemAnimation(pthis, globalCtx); + return; + case GI_TUNIC_GORON: + gSaveContext.infTable[16] |= 0x200; + EnGo2_GetItemAnimation(pthis, globalCtx); + return; + case GI_SWORD_BGS: + gSaveContext.bgsFlag = true; + break; + case GI_BOMB_BAG_30: + case GI_BOMB_BAG_40: + EnGo2_RollingAnimation(pthis, globalCtx); + pthis->actionFunc = EnGo2_GoronRollingBigContinueRolling; + return; + } + pthis->actionFunc = func_80A46B40; + } +} + +void EnGo2_BiggoronEyedrops(EnGo2* pthis, GlobalContext* globalCtx) { + switch (pthis->goronState) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 5); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.shape.rot.y += 0x5B0; + pthis->unk_26E = 1; + pthis->animTimer = pthis->skelAnime.endFrame + 60.0f + 60.0f; // eyeDrops animation timer + pthis->eyeMouthTexState = 2; + pthis->unk_20C = 0; + pthis->goronState++; + func_800F483C(0x28, 5); + OnePointCutscene_Init(globalCtx, 4190, -99, &pthis->actor, MAIN_CAM); + break; + case 1: + if (DECR(pthis->animTimer)) { + if (pthis->animTimer == 60 || pthis->animTimer == 120) { + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + func_800F4524(&D_801333D4, NA_SE_EV_GORON_WATER_DROP, 60); + } + } else { + func_800F4524(&D_801333D4, NA_SE_EN_GOLON_GOOD_BIG, 60); + func_80034EC0(&pthis->skelAnime, sAnimations, 6); + Message_ContinueTextbox(globalCtx, 0x305A); + pthis->eyeMouthTexState = 3; + pthis->goronState++; + func_800F483C(0x7F, 5); + } + break; + case 2: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + pthis->eyeMouthTexState = 0; + } + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->unk_26E = 2; + pthis->skelAnime.playSpeed = 0.0f; + pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; + EnGo2_GetItem(pthis, globalCtx, GI_CLAIM_CHECK); + pthis->actionFunc = EnGo2_SetupGetItem; + pthis->goronState = 0; + } + break; + } +} + +void EnGo2_GoronLinkStopRolling(EnGo2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (pthis->goronState) { + case 0: + if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { + return; + } else { + Message_StartTextbox(globalCtx, 0x3031, NULL); + player->actor.freezeTimer = 10; + pthis->goronState++; + } + case 1: + break; + default: + return; + } + + if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING) { + player->actor.freezeTimer = 10; + } else { + gSaveContext.infTable[16] |= 0x1000; + pthis->unk_26E = 1; + pthis->unk_211 = false; + pthis->isAwake = false; + pthis->actionFunc = EnGo2_CurledUp; + } +} + +void EnGo2_GoronFireGenericAction(EnGo2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3s D_80A4854C = { 0x00, 0x00, 0x00 }; + + switch (pthis->goronState) { + case 0: // Wake up + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + EnGo2_GoronFireCamera(pthis, globalCtx); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + pthis->waypoint = 1; + pthis->skelAnime.playSpeed = 2.0f; + func_80A44D84(pthis); + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->animTimer = 60; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 2.0f; + pthis->unk_194.unk_08 = D_80A4854C; + pthis->unk_194.unk_0E = D_80A4854C; + pthis->goronState++; + pthis->goronState++; + player->actor.world.rot.y = pthis->actor.world.rot.y; + player->actor.shape.rot.y = pthis->actor.world.rot.y; + player->actor.world.pos.x = + (f32)((Math_SinS(pthis->actor.world.rot.y) * -30.0f) + pthis->actor.world.pos.x); + player->actor.world.pos.z = + (f32)((Math_CosS(pthis->actor.world.rot.y) * -30.0f) + pthis->actor.world.pos.z); + func_8002DF54(globalCtx, &pthis->actor, 8); + Audio_PlayFanfare(NA_BGM_APPEAR); + } + break; + case 2: // Walking away + if (DECR(pthis->animTimer)) { + if (!(pthis->animTimer % 8)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); + } + Actor_MoveForward(&pthis->actor); + } else { + pthis->animTimer = 0; + pthis->actor.speedXZ = 0.0f; + if ((((pthis->actor.params & 0xFC00) >> 0xA) != 1) && (((pthis->actor.params & 0xFC00) >> 0xA) != 2) && + (((pthis->actor.params & 0xFC00) >> 0xA) != 4) && (((pthis->actor.params & 0xFC00) >> 0xA) != 5) && + (((pthis->actor.params & 0xFC00) >> 0xA) != 9) && (((pthis->actor.params & 0xFC00) >> 0xA) != 11)) { + pthis->goronState++; + } + pthis->goronState++; + } + break; + case 3: // Walking away + pthis->animTimer++; + if (!(pthis->animTimer % 8) && (pthis->animTimer < 10)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); + } + if (pthis->animTimer == 10) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_IRON_DOOR_OPEN); + } + if (pthis->animTimer > 44) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_IRON_DOOR_CLOSE); + } else { + break; + } + case 4: // Finalize walking away + Message_CloseTextbox(globalCtx); + EnGo2_GoronFireClearCamera(pthis, globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + Actor_Kill(&pthis->actor); + break; + case 1: + break; + } +} + +void EnGo2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGo2* pthis = (EnGo2*)thisx; + + func_80A45360(pthis, &pthis->alpha); + EnGo2_SitDownAnimation(pthis); + SkelAnime_Update(&pthis->skelAnime); + EnGo2_RollForward(pthis); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, (f32)pthis->collider.dim.height * 0.5f, + (f32)pthis->collider.dim.radius * 0.6f, 0.0f, 5); + if (pthis->unk_194.unk_00 == 0) { + func_80A44AB0(pthis, globalCtx); + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_211 == true) { + func_80034F54(globalCtx, pthis->unk_226, pthis->unk_24A, 18); + } + func_80A45288(pthis, globalCtx); + EnGo2_EyeMouthTexState(pthis); + EnGo2_CheckCollision(pthis, globalCtx); +} + +s32 EnGo2_DrawCurledUp(EnGo2* pthis, GlobalContext* globalCtx) { + Vec3f D_80A48554 = { 0.0f, 0.0f, 0.0f }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2881); + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go2.c", 2884), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGoronDL_00BD80); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2889); + Matrix_MultVec3f(&D_80A48554, &pthis->actor.focus.pos); + + return 1; +} + +s32 EnGo2_DrawRolling(EnGo2* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f D_80A48560 = { 0.0f, 0.0f, 0.0f }; + f32 speedXZ; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2914); + func_80093D18(globalCtx->state.gfxCtx); + speedXZ = pthis->actionFunc == EnGo2_ReverseRolling ? 0.0f : pthis->actor.speedXZ; + Matrix_RotateZYX((globalCtx->state.frames * ((s16)speedXZ * 1400)), 0, pthis->actor.shape.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_go2.c", 2926), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGoronDL_00C140); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 2930); + Matrix_MultVec3f(&D_80A48560, &pthis->actor.focus.pos); + return 1; +} + +s32 EnGo2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnGo2* pthis = (EnGo2*)thisx; + Vec3s vec1; + f32 float1; + + if (limb == 17) { + Matrix_Translate(2800.0f, 0.0f, 0.0f, MTXMODE_APPLY); + vec1 = pthis->unk_194.unk_08; + float1 = (vec1.y / (f32)0x8000) * M_PI; + Matrix_RotateX(float1, MTXMODE_APPLY); + float1 = (vec1.x / (f32)0x8000) * M_PI; + Matrix_RotateZ(float1, MTXMODE_APPLY); + Matrix_Translate(-2800.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + if (limb == 10) { + vec1 = pthis->unk_194.unk_0E; + float1 = (vec1.y / (f32)0x8000) * M_PI; + Matrix_RotateY(float1, MTXMODE_APPLY); + float1 = (vec1.x / (f32)0x8000) * M_PI; + Matrix_RotateX(float1, MTXMODE_APPLY); + } + if ((limb == 10) || (limb == 11) || (limb == 14)) { + float1 = Math_SinS(pthis->unk_226[limb]); + rot->y += float1 * 200.0f; + float1 = Math_CosS(pthis->unk_24A[limb]); + rot->z += float1 * 200.0f; + } + return 0; +} + +void EnGo2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnGo2* pthis = (EnGo2*)thisx; + Vec3f D_80A4856C = { 600.0f, 0.0f, 0.0f }; + + if (limbIndex == 17) { + Matrix_MultVec3f(&D_80A4856C, &pthis->actor.focus.pos); + } +} + +void EnGo2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGo2* pthis = (EnGo2*)thisx; + void* eyeTextures[] = { gGoronCsEyeClosed2Tex, gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; + void* mouthTextures[] = { gGoronCsMouthNeutralTex, gGoronCsMouthSmileTex }; + + EnGo2_UpdateDust(pthis); + Matrix_Push(); + EnGo2_DrawDust(pthis, globalCtx); + Matrix_Pop(); + + if ((pthis->actionFunc == EnGo2_CurledUp) && (pthis->skelAnime.playSpeed == 0.0f) && + (pthis->skelAnime.curFrame == 0.0f)) { + if (1) {} + EnGo2_DrawCurledUp(pthis, globalCtx); + } else if (pthis->actionFunc == EnGo2_SlowRolling || pthis->actionFunc == EnGo2_ReverseRolling || + pthis->actionFunc == EnGo2_ContinueRolling) { + EnGo2_DrawRolling(pthis, globalCtx); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 3063); + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTextures[pthis->mouthTexIndex])); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnGo2_OverrideLimbDraw, EnGo2_PostLimbDraw, pthis); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_go2.c", 3081); + } +} diff --git a/src/overlays/actors/ovl_En_Goma/z_en_goma.c b/src/overlays/actors/ovl_En_Goma/z_en_goma.c deleted file mode 100644 index 98baaa4b3..000000000 --- a/src/overlays/actors/ovl_En_Goma/z_en_goma.c +++ /dev/null @@ -1,922 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GOMA_Z_EN_GOMA_C -#include "actor_common.h" -#include "z_en_goma.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "objects/object_gol/object_gol.h" -#include "overlays/actors/ovl_Boss_Goma/z_boss_goma.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "def/code_8006BA00.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnGoma_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGoma_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGoma_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGoma_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnGoma_Flee(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_EggFallToGround(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Egg(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Hatch(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Hurt(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Die(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Dead(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_PrepareJump(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Land(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Jump(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Stand(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_ChasePlayer(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Stunned(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_LookAtPlayer(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_UpdateHit(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_Debris(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_SpawnHatchDebris(EnGoma* this, GlobalContext* globalCtx2); -void EnGoma_BossLimb(EnGoma* this, GlobalContext* globalCtx); - -void EnGoma_SetupFlee(EnGoma* this); -void EnGoma_SetupHatch(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_SetupHurt(EnGoma* this, GlobalContext* globalCtx); -void EnGoma_SetupDie(EnGoma* this); -void EnGoma_SetupDead(EnGoma* this); -void EnGoma_SetupStand(EnGoma* this); -void EnGoma_SetupChasePlayer(EnGoma* this); -void EnGoma_SetupPrepareJump(EnGoma* this); -void EnGoma_SetupLand(EnGoma* this); -void EnGoma_SetupJump(EnGoma* this); -void EnGoma_SetupStunned(EnGoma* this, GlobalContext* globalCtx); - -const ActorInit En_Goma_InitVars = { - ACTOR_BOSS_GOMA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_GOL, - sizeof(EnGoma), - (ActorFunc)EnGoma_Init, - (ActorFunc)EnGoma_Destroy, - (ActorFunc)EnGoma_Update, - (ActorFunc)EnGoma_Draw, -}; - -static ColliderCylinderInit D_80A4B7A0 = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFDFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 15, 30, 10, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit D_80A4B7CC = { - { - COLTYPE_HIT3, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFDFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 15, 30, 10, { 0, 0, 0 } }, -}; - -static u8 sSpawnNum = 0; -static Vec3f sDeadEffectVel = { 0.0f, 0.0f, 0.0f }; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 3, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x03, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 20, ICHAIN_STOP), -}; - -void EnGoma_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGoma* this = (EnGoma*)thisx; - s16 params; - - this->eggTimer = Rand_ZeroOne() * 200.0f; - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.01f); - params = this->actor.params; - - if (params >= 100) { // piece of boss goma - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_BOSS); - this->actionFunc = EnGoma_BossLimb; - this->gomaType = ENGOMA_BOSSLIMB; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - this->actionTimer = this->actor.params + 150; - this->actor.flags &= ~ACTOR_FLAG_0; - } else if (params >= 10) { // Debris when hatching - this->actor.gravity = -1.3f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionTimer = 50; - this->gomaType = ENGOMA_HATCH_DEBRIS; - this->eggScale = 1.0f; - this->actor.velocity.y = Rand_ZeroOne() * 5.0f + 5.0f; - this->actionFunc = EnGoma_Debris; - this->actor.speedXZ = Rand_ZeroOne() * 2.3f + 1.5f; - this->actionTimer = 30; - this->actor.scale.x = Rand_ZeroOne() * 0.005f + 0.01f; - this->actor.scale.y = Rand_ZeroOne() * 0.005f + 0.01f; - this->actor.scale.z = Rand_ZeroOne() * 0.005f + 0.01f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - } else { // Egg - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - SkelAnime_Init(globalCtx, &this->skelanime, &gObjectGolSkel, &gObjectGolStandAnim, this->jointTable, - this->morphTable, GOMA_LIMB_MAX); - Animation_PlayLoop(&this->skelanime, &gObjectGolStandAnim); - this->actor.colChkInfo.health = 2; - - if (this->actor.params < 3) { // Spawned by boss - this->actionFunc = EnGoma_EggFallToGround; - this->invincibilityTimer = 10; - this->actor.speedXZ = 1.5f; - } else if (this->actor.params == 8 || this->actor.params == 6) { - this->actionFunc = EnGoma_Egg; - this->spawnNum = sSpawnNum++; - } else if (this->actor.params == 9 || this->actor.params == 7) { - this->actionFunc = EnGoma_Egg; - } - - if (this->actor.params >= 8) { // on ceiling - this->eggYOffset = -1500.0f; - } else { - this->eggYOffset = 1500.0f; - } - - this->gomaType = ENGOMA_EGG; - this->eggScale = 1.0f; - this->eggSquishAngle = Rand_ZeroOne() * 1000.0f; - this->actionTimer = 50; - Collider_InitCylinder(globalCtx, &this->colCyl1); - Collider_SetCylinder(globalCtx, &this->colCyl1, &this->actor, &D_80A4B7A0); - Collider_InitCylinder(globalCtx, &this->colCyl2); - Collider_SetCylinder(globalCtx, &this->colCyl2, &this->actor, &D_80A4B7CC); - } -} - -void EnGoma_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGoma* this = (EnGoma*)thisx; - - if (this->actor.params < 10) { - Collider_DestroyCylinder(globalCtx, &this->colCyl1); - Collider_DestroyCylinder(globalCtx, &this->colCyl2); - } -} - -void EnGoma_SetupFlee(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolRunningAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolRunningAnim), ANIMMODE_LOOP, -2.0f); - this->actionFunc = EnGoma_Flee; - this->actionTimer = 20; - - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_DAM2); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_DAM2); - } -} - -void EnGoma_Flee(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ApproachF(&this->actor.speedXZ, 20.0f / 3.0f, 0.5f, 2.0f); - Math_ApproachS(&this->actor.world.rot.y, - Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) + 0x8000, 3, 2000); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 3000); - - if (this->actionTimer == 0) { - EnGoma_SetupStand(this); - } -} - -void EnGoma_EggFallToGround(EnGoma* this, GlobalContext* globalCtx) { - this->actor.gravity = -1.3f; - this->eggSquishAccel += 0.03f; - this->eggSquishAngle += 1.0f + this->eggSquishAccel; - Math_ApproachZeroF(&this->eggSquishAmount, 1.0f, 0.005f); - Math_ApproachF(&this->eggYOffset, 1500.0f, 1.0f, 150.0f); - - switch (this->hatchState) { - case 0: - if (this->actor.bgCheckFlags & 1) { // floor - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_EGG1); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_EGG1); - } - - if (this->actor.params > 5) { - EnGoma_SetupHatch(this, globalCtx); - } else { - this->hatchState = 1; - this->actionTimer = 3; - Math_ApproachF(&this->eggScale, 1.5f, 0.5f, 1.0f); - } - } - break; - - case 1: - if (this->actionTimer == 0) { - this->hatchState = 2; - this->actionTimer = 3; - Math_ApproachF(&this->eggScale, 0.75f, 0.5f, 1.0f); - this->actor.velocity.y = 5.0f; - this->actor.speedXZ = 2.0f; - } else { - Math_ApproachF(&this->eggScale, 1.5f, 0.5f, 1.0f); - } - break; - - case 2: - if (this->actionTimer == 0) { - this->hatchState = 3; - this->actionTimer = 80; - } else { - Math_ApproachF(&this->eggScale, 0.75f, 0.5f, 1.0f); - } - break; - - case 3: - Math_ApproachF(&this->eggScale, 1.0f, 0.1f, 0.1f); - if (this->actionTimer == 0) { - EnGoma_SetupHatch(this, globalCtx); - } - break; - } - - if (this->actor.bgCheckFlags & 1) { - Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 0.05f); - } - this->eggPitch += (this->actor.speedXZ * 0.1f); - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnGoma_Egg(EnGoma* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 i; - - this->eggSquishAngle += 1.0f; - Math_ApproachF(&this->eggSquishAmount, 0.1f, 1.0f, 0.005f); - if (fabsf(this->actor.world.pos.x - player->actor.world.pos.x) < 100.0f && - fabsf(this->actor.world.pos.z - player->actor.world.pos.z) < 100.0f) { - if (++this->playerDetectionTimer > 9) { - this->actionFunc = EnGoma_EggFallToGround; - } - } else { - this->playerDetectionTimer = 0; - } - - if (!(this->eggTimer & 0xF) && Rand_ZeroOne() < 0.5f) { - for (i = 0; i < 2; i++) { - Vec3f vel = { 0.0f, 0.0f, 0.0f }; - Vec3f acc = { 0.0f, -0.5f, 0.0f }; - Vec3f pos; - - pos.x = Rand_CenteredFloat(30.0f) + this->actor.world.pos.x; - pos.y = Rand_ZeroFloat(30.0f) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(30.0f) + this->actor.world.pos.z; - EffectSsHahen_Spawn(globalCtx, &pos, &vel, &acc, 0, (s16)(Rand_ZeroOne() * 5.0f) + 10, HAHEN_OBJECT_DEFAULT, - 10, NULL); - } - } -} - -void EnGoma_SetupHatch(EnGoma* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelanime, &gObjectGolJumpHeadbuttAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolJumpHeadbuttAnim), ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnGoma_Hatch; - Actor_SetScale(&this->actor, 0.005f); - this->gomaType = ENGOMA_NORMAL; - this->actionTimer = 5; - this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - this->actor.world.rot.y = this->actor.shape.rot.y; - EnGoma_SpawnHatchDebris(this, globalCtx); - this->eggScale = 1.0f; - this->actor.speedXZ = 0.0f; -} - -void EnGoma_Hatch(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - if (this->actionTimer == 0) { - EnGoma_SetupStand(this); - } -} - -void EnGoma_SetupHurt(EnGoma* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelanime, &gObjectGolDamagedAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolDamagedAnim), ANIMMODE_ONCE, -2.0f); - this->actionFunc = EnGoma_Hurt; - - if ((s8)this->actor.colChkInfo.health <= 0) { - this->actionTimer = 5; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else { - this->actionTimer = 10; - } - - this->actor.speedXZ = 20.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_DAM1); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_DAM1); - } -} - -void EnGoma_Hurt(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->actor.bgCheckFlags & 1) { - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 2.0f); - } - - if (this->actionTimer == 0) { - if ((s8)this->actor.colChkInfo.health <= 0) { - EnGoma_SetupDie(this); - } else { - EnGoma_SetupFlee(this); - } - } -} - -void EnGoma_SetupDie(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolDeathAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gObjectGolDeathAnim), - ANIMMODE_ONCE, -2.0f); - this->actionFunc = EnGoma_Die; - this->actionTimer = 30; - - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_DEAD); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_DEAD); - } - - this->invincibilityTimer = 100; - this->actor.flags &= ~ACTOR_FLAG_0; -} - -void EnGoma_Die(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->actor.bgCheckFlags & 1) { - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 2.0f); - } - - if (this->actionTimer == 17) { - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_LAND); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_LAND); - } - } - - if (this->actionTimer == 0) { - EnGoma_SetupDead(this); - } -} - -void EnGoma_SetupDead(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolDeadTwitchingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolDeadTwitchingAnim), ANIMMODE_LOOP, -2.0f); - this->actionFunc = EnGoma_Dead; - this->actionTimer = 3; -} - -void EnGoma_Dead(EnGoma* this, GlobalContext* globalCtx) { - Vec3f accel; - Vec3f pos; - - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 2.0f); - - if (this->actionTimer == 2) { - pos.x = this->actor.world.pos.x; - pos.y = (this->actor.world.pos.y + 5.0f) - 10.0f; - pos.z = this->actor.world.pos.z; - accel = sDeadEffectVel; - accel.y = 0.03f; - EffectSsKFire_Spawn(globalCtx, &pos, &sDeadEffectVel, &accel, 40, 0); - } - - if (this->actionTimer == 0 && Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 0.5f, 0.00225f, 0.00001f) <= 0.001f) { - if (this->actor.params < 6) { - BossGoma* parent = (BossGoma*)this->actor.parent; - - parent->childrenGohmaState[this->actor.params] = -1; - } - Audio_PlaySoundGeneral(NA_SE_EN_EXTINCT, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Actor_Kill(&this->actor); - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x30); - } - this->visualState = 2; -} - -void EnGoma_SetupStand(EnGoma* this) { - f32 lastFrame; - - lastFrame = Animation_GetLastFrame(&gObjectGolStandAnim); - this->actionTimer = Rand_S16Offset(10, 30); - Animation_Change(&this->skelanime, &gObjectGolStandAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -5.0f); - this->actionFunc = EnGoma_Stand; - this->gomaType = ENGOMA_NORMAL; -} - -void EnGoma_SetupChasePlayer(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolRunningAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolRunningAnim), ANIMMODE_LOOP, -5.0f); - this->actionFunc = EnGoma_ChasePlayer; - this->actionTimer = Rand_S16Offset(70, 110); -} - -void EnGoma_SetupPrepareJump(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolPrepareJumpAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolPrepareJumpAnim), ANIMMODE_ONCE, -5.0f); - this->actionFunc = EnGoma_PrepareJump; - this->actionTimer = 30; -} - -void EnGoma_PrepareJump(EnGoma* this, GlobalContext* globalCtx) { - s16 targetAngle; - - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - - targetAngle = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - Math_ApproachS(&this->actor.world.rot.y, targetAngle, 2, 4000); - Math_ApproachS(&this->actor.shape.rot.y, targetAngle, 2, 3000); - - if (this->actionTimer == 0) { - EnGoma_SetupJump(this); - } - this->visualState = 0; -} - -void EnGoma_SetupLand(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolLandFromJumpAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolLandFromJumpAnim), ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnGoma_Land; - this->actionTimer = 10; -} - -void EnGoma_Land(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->actor.bgCheckFlags & 1) { - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 2.0f); - } - if (this->actionTimer == 0) { - EnGoma_SetupStand(this); - } -} - -void EnGoma_SetupJump(EnGoma* this) { - Animation_Change(&this->skelanime, &gObjectGolJumpHeadbuttAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gObjectGolJumpHeadbuttAnim), ANIMMODE_ONCE, 0.0f); - this->actionFunc = EnGoma_Jump; - this->actor.velocity.y = 8.0f; - - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_CRY); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_CRY); - } -} - -void EnGoma_Jump(EnGoma* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_24; - SkelAnime_Update(&this->skelanime); - Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.5f, 5.0f); - - if (this->actor.velocity.y <= 0.0f && (this->actor.bgCheckFlags & 1)) { - EnGoma_SetupLand(this); - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_LAND2); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_LAND2); - } - } - this->visualState = 0; -} - -void EnGoma_Stand(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - Math_ApproachS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor), 2, - 3000); - - if (this->actionTimer == 0) { - EnGoma_SetupChasePlayer(this); - } -} - -void EnGoma_ChasePlayer(EnGoma* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 5.0f)) { - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_WALK); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_WALK); - } - } - - Math_ApproachF(&this->actor.speedXZ, 10.0f / 3.0f, 0.5f, 2.0f); - Math_ApproachS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 3, 2000); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 3000); - - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 0.0f; - } - if (this->actor.xzDistToPlayer <= 150.0f) { - EnGoma_SetupPrepareJump(this); - } -} - -void EnGoma_SetupStunned(EnGoma* this, GlobalContext* globalCtx) { - this->actionFunc = EnGoma_Stunned; - this->stunTimer = 100; - Animation_MorphToLoop(&this->skelanime, &gObjectGolStandAnim, -5.0f); - this->actionTimer = (s16)Rand_ZeroFloat(15.0f) + 3; - - if (this->actor.params < 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_BJR_FREEZE); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - } -} - -void EnGoma_Stunned(EnGoma* this, GlobalContext* globalCtx) { - Actor_SetColorFilter(&this->actor, 0, 180, 0, 2); - this->visualState = 2; - - if (this->actionTimer != 0) { - SkelAnime_Update(&this->skelanime); - } - - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 0.0f; - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 2.0f); - } - - if (this->stunTimer == 0) { - EnGoma_SetupStand(this); - } else if (--this->stunTimer < 30) { - if (this->stunTimer & 1) { - this->actor.world.pos.x += 1.5f; - this->actor.world.pos.z += 1.5f; - } else { - this->actor.world.pos.x -= 1.5f; - this->actor.world.pos.z -= 1.5f; - } - } -} - -void EnGoma_LookAtPlayer(EnGoma* this, GlobalContext* globalCtx) { - s16 eyePitch; - s16 eyeYaw; - - eyeYaw = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.shape.rot.y; - eyePitch = Actor_WorldPitchTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.shape.rot.x; - - if (eyeYaw > 6000) { - eyeYaw = 6000; - } - if (eyeYaw < -6000) { - eyeYaw = -6000; - } - Math_ApproachS(&this->eyeYaw, eyeYaw, 3, 2000); - Math_ApproachS(&this->eyePitch, eyePitch, 3, 2000); -} - -void EnGoma_UpdateHit(EnGoma* this, GlobalContext* globalCtx) { - static Vec3f sShieldKnockbackVel = { 0.0f, 0.0f, 20.0f }; - Player* player = GET_PLAYER(globalCtx); - - if (this->hurtTimer != 0) { - this->hurtTimer--; - } else { - ColliderInfo* acHitInfo; - u8 swordDamage; - - if ((this->colCyl1.base.atFlags & 2) && this->actionFunc == EnGoma_Jump) { - EnGoma_SetupLand(this); - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - } - - if ((this->colCyl2.base.acFlags & AC_HIT) && (s8)this->actor.colChkInfo.health > 0) { - acHitInfo = this->colCyl2.info.acHitInfo; - this->colCyl2.base.acFlags &= ~AC_HIT; - - if (this->gomaType == ENGOMA_NORMAL) { - u32 dmgFlags = acHitInfo->toucher.dmgFlags; - - if (dmgFlags & 0x100000) { - if (this->actionFunc == EnGoma_Jump) { - EnGoma_SetupLand(this); - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = -5.0f; - } else { - Matrix_RotateY(player->actor.shape.rot.y / (f32)0x8000 * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&sShieldKnockbackVel, &this->shieldKnockbackVel); - this->invincibilityTimer = 5; - } - } else if (dmgFlags & 1) { // stun - if (this->actionFunc != EnGoma_Stunned) { - EnGoma_SetupStunned(this, globalCtx); - this->hurtTimer = 8; - } - } else { - swordDamage = CollisionCheck_GetSwordDamage(dmgFlags); - - if (swordDamage) { - EffectSsSibuki_SpawnBurst(globalCtx, &this->actor.focus.pos); - } else { - swordDamage = 1; - } - - this->actor.colChkInfo.health -= swordDamage; - EnGoma_SetupHurt(this, globalCtx); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 5); - this->hurtTimer = 13; - } - } else { - // die if still an egg - if (this->actor.params <= 5) { //! BossGoma only has 3 children - BossGoma* parent = (BossGoma*)this->actor.parent; - - parent->childrenGohmaState[this->actor.params] = -1; - } - - EnGoma_SpawnHatchDebris(this, globalCtx); - Actor_Kill(&this->actor); - } - } - } -} - -void EnGoma_UpdateEyeEnvColor(EnGoma* this) { - static f32 sTargetEyeEnvColors[][3] = { - { 255.0f, 0.0f, 50.0f }, - { 17.0f, 255.0f, 50.0f }, - { 0.0f, 170.0f, 50.0f }, - }; - - Math_ApproachF(&this->eyeEnvColor[0], sTargetEyeEnvColors[0][this->visualState], 0.5f, 20.0f); - Math_ApproachF(&this->eyeEnvColor[1], sTargetEyeEnvColors[1][this->visualState], 0.5f, 20.0f); - Math_ApproachF(&this->eyeEnvColor[2], sTargetEyeEnvColors[2][this->visualState], 0.5f, 20.0f); -} - -#include "hack.h" - -void EnGoma_SetFloorRot(EnGoma* this) { - f32 nx; - f32 ny; - f32 nz; - - if (this->actor.floorPoly != NULL) { - nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); - ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - Math_ApproachS(&this->slopePitch, -Math_FAtan2F(-nz * ny, 1.0f) * (0x8000 / M_PI), 1, 1000); - Math_ApproachS(&this->slopeRoll, Math_FAtan2F(-nx * ny, 1.0f) * (0x8000 / M_PI), 1, 1000); - } -} - -void EnGoma_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGoma* this = (EnGoma*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (this->invincibilityTimer != 0) { - this->invincibilityTimer--; - } - - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - this->actor.world.pos.x = this->actor.world.pos.x + this->shieldKnockbackVel.x; - this->actor.world.pos.z = this->actor.world.pos.z + this->shieldKnockbackVel.z; - Math_ApproachZeroF(&this->shieldKnockbackVel.x, 1.0f, 3.0f); - Math_ApproachZeroF(&this->shieldKnockbackVel.z, 1.0f, 3.0f); - - if (this->actor.params < 10) { - this->eggTimer++; - Math_SmoothStepToF(&this->actor.scale.x, 0.01f, 0.5f, 0.00075f, 0.000001f); - Math_SmoothStepToF(&this->actor.scale.y, 0.01f, 0.5f, 0.00075f, 0.000001f); - Math_SmoothStepToF(&this->actor.scale.z, 0.01f, 0.5f, 0.00075f, 0.000001f); - EnGoma_UpdateHit(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 5); - EnGoma_SetFloorRot(this); - Actor_SetFocus(&this->actor, 20.0f); - EnGoma_LookAtPlayer(this, globalCtx); - EnGoma_UpdateEyeEnvColor(this); - this->visualState = 1; - if (player->swordState != 0) { - this->colCyl2.dim.radius = 35; - this->colCyl2.dim.height = 35; - this->colCyl2.dim.yShift = 0; - } else { - this->colCyl2.dim.radius = 15; - this->colCyl2.dim.height = 30; - this->colCyl2.dim.yShift = 10; - } - if (this->invincibilityTimer == 0) { - Collider_UpdateCylinder(&this->actor, &this->colCyl1); - Collider_UpdateCylinder(&this->actor, &this->colCyl2); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colCyl1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCyl2.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colCyl1.base); - } - } -} - -s32 EnGoma_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnGoma* this = (EnGoma*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 1976); - gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->eyeEnvColor[0], (s16)this->eyeEnvColor[1], (s16)this->eyeEnvColor[2], - 255); - - if (limbIndex == GOMA_LIMB_EYE_IRIS_ROOT1) { - rot->x += this->eyePitch; - rot->y += this->eyeYaw; - } else if (limbIndex == GOMA_LIMB_BODY && this->hurtTimer != 0) { - gDPSetEnvColor(POLY_OPA_DISP++, (s16)(Rand_ZeroOne() * 255.0f), (s16)(Rand_ZeroOne() * 255.0f), - (s16)(Rand_ZeroOne() * 255.0f), 255); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 2011); - return 0; -} - -Gfx* EnGoma_NoBackfaceCullingDlist(GraphicsContext* gfxCtx) { - Gfx* dListHead; - Gfx* dList; - - dListHead = dList = Graph_Alloc(gfxCtx, sizeof(Gfx) * 4); - gDPPipeSync(dListHead++); - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2); - gSPClearGeometryMode(dListHead++, G_CULL_BACK); - gSPEndDisplayList(dListHead++); - return dList; -} - -void EnGoma_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGoma* this = (EnGoma*)thisx; - s32 y; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 2040); - func_80093D18(globalCtx->state.gfxCtx); - - switch (this->gomaType) { - case ENGOMA_NORMAL: - this->actor.naviEnemyId = 0x03; - Matrix_Translate(this->actor.world.pos.x, - this->actor.world.pos.y + ((this->actor.shape.yOffset * this->actor.scale.y) + - globalCtx->mainCamera.skyboxOffset.y), - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateX(this->slopePitch / (f32)0x8000 * M_PI, MTXMODE_APPLY); - Matrix_RotateZ(this->slopeRoll / (f32)0x8000 * M_PI, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y / (f32)0x8000 * M_PI, MTXMODE_APPLY); - Matrix_RotateX(this->actor.shape.rot.x / (f32)0x8000 * M_PI, MTXMODE_APPLY); - Matrix_RotateZ(this->actor.shape.rot.z / (f32)0x8000 * M_PI, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, EnGoma_OverrideLimbDraw, - NULL, this); - break; - - case ENGOMA_EGG: - this->actor.naviEnemyId = 0x02; - y = (s16)(sinf((this->eggTimer * 5.0f * 3.1415f) / 180.0f) * 31.9f); - y = (s16)(y + 31); - gSPSegment(POLY_OPA_DISP++, 0x08, func_80094E78(globalCtx->state.gfxCtx, 0, y)); - Matrix_Push(); - Matrix_Scale(this->eggScale, 1.0f / this->eggScale, this->eggScale, MTXMODE_APPLY); - Matrix_RotateY(this->eggSquishAngle * 0.15f, MTXMODE_APPLY); - Matrix_RotateZ(this->eggSquishAngle * 0.1f, MTXMODE_APPLY); - Matrix_Scale(0.95f - this->eggSquishAmount, this->eggSquishAmount + 1.05f, 0.95f - this->eggSquishAmount, - MTXMODE_APPLY); - Matrix_RotateZ(-(this->eggSquishAngle * 0.1f), MTXMODE_APPLY); - Matrix_RotateY(-(this->eggSquishAngle * 0.15f), MTXMODE_APPLY); - Matrix_Translate(0.0f, this->eggYOffset, 0.0f, MTXMODE_APPLY); - Matrix_RotateX(this->eggPitch, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_goma.c", 2101), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gObjectGolEggDL); - Matrix_Pop(); - break; - - case ENGOMA_HATCH_DEBRIS: - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_goma.c", 2107), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gBrownFragmentDL); - break; - - case ENGOMA_BOSSLIMB: - if (this->bossLimbDl != NULL) { - gSPSegment(POLY_OPA_DISP++, 0x08, EnGoma_NoBackfaceCullingDlist(globalCtx->state.gfxCtx)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_goma.c", 2114), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->bossLimbDl); - } - break; - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 2119); -} - -void EnGoma_Debris(EnGoma* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 2500; - this->actor.shape.rot.x += 3500; - if (this->actionTimer == 0) { - Actor_Kill(&this->actor); - } -} - -void EnGoma_SpawnHatchDebris(EnGoma* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - s16 i; - - if (this->actor.params < 6) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_GOMA_BJR_EGG2); - } else { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_GOMA_EGG2); - } - - for (i = 0; i < 15; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_GOMA, - Rand_CenteredFloat(10.0f) + this->actor.world.pos.x, - Rand_CenteredFloat(10.0f) + this->actor.world.pos.y + 15.0f, - Rand_CenteredFloat(10.0f) + this->actor.world.pos.z, 0, Rand_CenteredFloat(0x10000 - 0.01f), - 0, i + 10); - } -} - -void EnGoma_BossLimb(EnGoma* this, GlobalContext* globalCtx) { - Vec3f vel = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 1.0f, 0.0f }; - Color_RGBA8 primColor = { 255, 255, 255, 255 }; - Color_RGBA8 envColor = { 0, 100, 255, 255 }; - Vec3f pos; - - this->actor.world.pos.y -= 5.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 4); - this->actor.world.pos.y += 5.0f; - - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 0.0f; - } else if (this->actionTimer < 250) { - this->actor.shape.rot.y += 2000; - } - - if (this->actionTimer == 250) { - this->actor.gravity = -1.0f; - } - - if (this->actionTimer < 121) { - if (Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 1.0f, 0.00075f, 0) <= 0.001f) { - Actor_Kill(&this->actor); - } - this->actor.scale.x = this->actor.scale.z = this->actor.scale.y; - } - - if (this->actionTimer % 8 == 0 && this->actionTimer != 0) { - pos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - pos.y = Rand_CenteredFloat(10.0f) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - func_8002836C(globalCtx, &pos, &vel, &accel, &primColor, &envColor, 500, 10, 10); - } -} diff --git a/src/overlays/actors/ovl_En_Goma/z_en_goma.cpp b/src/overlays/actors/ovl_En_Goma/z_en_goma.cpp new file mode 100644 index 000000000..74f996a1e --- /dev/null +++ b/src/overlays/actors/ovl_En_Goma/z_en_goma.cpp @@ -0,0 +1,922 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GOMA_Z_EN_GOMA_C +#include "actor_common.h" +#include "z_en_goma.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_gol/object_gol.h" +#include "overlays/actors/ovl_Boss_Goma/z_boss_goma.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "def/code_8006BA00.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnGoma_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGoma_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGoma_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGoma_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnGoma_Flee(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_EggFallToGround(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Egg(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Hatch(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Hurt(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Die(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Dead(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_PrepareJump(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Land(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Jump(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Stand(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_ChasePlayer(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Stunned(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_LookAtPlayer(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_UpdateHit(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_Debris(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_SpawnHatchDebris(EnGoma* pthis, GlobalContext* globalCtx2); +void EnGoma_BossLimb(EnGoma* pthis, GlobalContext* globalCtx); + +void EnGoma_SetupFlee(EnGoma* pthis); +void EnGoma_SetupHatch(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_SetupHurt(EnGoma* pthis, GlobalContext* globalCtx); +void EnGoma_SetupDie(EnGoma* pthis); +void EnGoma_SetupDead(EnGoma* pthis); +void EnGoma_SetupStand(EnGoma* pthis); +void EnGoma_SetupChasePlayer(EnGoma* pthis); +void EnGoma_SetupPrepareJump(EnGoma* pthis); +void EnGoma_SetupLand(EnGoma* pthis); +void EnGoma_SetupJump(EnGoma* pthis); +void EnGoma_SetupStunned(EnGoma* pthis, GlobalContext* globalCtx); + +ActorInit En_Goma_InitVars = { + ACTOR_BOSS_GOMA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_GOL, + sizeof(EnGoma), + (ActorFunc)EnGoma_Init, + (ActorFunc)EnGoma_Destroy, + (ActorFunc)EnGoma_Update, + (ActorFunc)EnGoma_Draw, +}; + +static ColliderCylinderInit D_80A4B7A0 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFDFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 15, 30, 10, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit D_80A4B7CC = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFDFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 15, 30, 10, { 0, 0, 0 } }, +}; + +static u8 sSpawnNum = 0; +static Vec3f sDeadEffectVel = { 0.0f, 0.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 3, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x03, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, 0, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 20, ICHAIN_STOP), +}; + +void EnGoma_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGoma* pthis = (EnGoma*)thisx; + s16 params; + + pthis->eggTimer = Rand_ZeroOne() * 200.0f; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.01f); + params = pthis->actor.params; + + if (params >= 100) { // piece of boss goma + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_BOSS); + pthis->actionFunc = EnGoma_BossLimb; + pthis->gomaType = ENGOMA_BOSSLIMB; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + pthis->actionTimer = pthis->actor.params + 150; + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else if (params >= 10) { // Debris when hatching + pthis->actor.gravity = -1.3f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionTimer = 50; + pthis->gomaType = ENGOMA_HATCH_DEBRIS; + pthis->eggScale = 1.0f; + pthis->actor.velocity.y = Rand_ZeroOne() * 5.0f + 5.0f; + pthis->actionFunc = EnGoma_Debris; + pthis->actor.speedXZ = Rand_ZeroOne() * 2.3f + 1.5f; + pthis->actionTimer = 30; + pthis->actor.scale.x = Rand_ZeroOne() * 0.005f + 0.01f; + pthis->actor.scale.y = Rand_ZeroOne() * 0.005f + 0.01f; + pthis->actor.scale.z = Rand_ZeroOne() * 0.005f + 0.01f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + } else { // Egg + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); + SkelAnime_Init(globalCtx, &pthis->skelanime, &gObjectGolSkel, &gObjectGolStandAnim, pthis->jointTable, + pthis->morphTable, GOMA_LIMB_MAX); + Animation_PlayLoop(&pthis->skelanime, &gObjectGolStandAnim); + pthis->actor.colChkInfo.health = 2; + + if (pthis->actor.params < 3) { // Spawned by boss + pthis->actionFunc = EnGoma_EggFallToGround; + pthis->invincibilityTimer = 10; + pthis->actor.speedXZ = 1.5f; + } else if (pthis->actor.params == 8 || pthis->actor.params == 6) { + pthis->actionFunc = EnGoma_Egg; + pthis->spawnNum = sSpawnNum++; + } else if (pthis->actor.params == 9 || pthis->actor.params == 7) { + pthis->actionFunc = EnGoma_Egg; + } + + if (pthis->actor.params >= 8) { // on ceiling + pthis->eggYOffset = -1500.0f; + } else { + pthis->eggYOffset = 1500.0f; + } + + pthis->gomaType = ENGOMA_EGG; + pthis->eggScale = 1.0f; + pthis->eggSquishAngle = Rand_ZeroOne() * 1000.0f; + pthis->actionTimer = 50; + Collider_InitCylinder(globalCtx, &pthis->colCyl1); + Collider_SetCylinder(globalCtx, &pthis->colCyl1, &pthis->actor, &D_80A4B7A0); + Collider_InitCylinder(globalCtx, &pthis->colCyl2); + Collider_SetCylinder(globalCtx, &pthis->colCyl2, &pthis->actor, &D_80A4B7CC); + } +} + +void EnGoma_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGoma* pthis = (EnGoma*)thisx; + + if (pthis->actor.params < 10) { + Collider_DestroyCylinder(globalCtx, &pthis->colCyl1); + Collider_DestroyCylinder(globalCtx, &pthis->colCyl2); + } +} + +void EnGoma_SetupFlee(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolRunningAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolRunningAnim), ANIMMODE_LOOP, -2.0f); + pthis->actionFunc = EnGoma_Flee; + pthis->actionTimer = 20; + + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_DAM2); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_DAM2); + } +} + +void EnGoma_Flee(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachF(&pthis->actor.speedXZ, 20.0f / 3.0f, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.world.rot.y, + Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) + 0x8000, 3, 2000); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 2, 3000); + + if (pthis->actionTimer == 0) { + EnGoma_SetupStand(pthis); + } +} + +void EnGoma_EggFallToGround(EnGoma* pthis, GlobalContext* globalCtx) { + pthis->actor.gravity = -1.3f; + pthis->eggSquishAccel += 0.03f; + pthis->eggSquishAngle += 1.0f + pthis->eggSquishAccel; + Math_ApproachZeroF(&pthis->eggSquishAmount, 1.0f, 0.005f); + Math_ApproachF(&pthis->eggYOffset, 1500.0f, 1.0f, 150.0f); + + switch (pthis->hatchState) { + case 0: + if (pthis->actor.bgCheckFlags & 1) { // floor + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_EGG1); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_EGG1); + } + + if (pthis->actor.params > 5) { + EnGoma_SetupHatch(pthis, globalCtx); + } else { + pthis->hatchState = 1; + pthis->actionTimer = 3; + Math_ApproachF(&pthis->eggScale, 1.5f, 0.5f, 1.0f); + } + } + break; + + case 1: + if (pthis->actionTimer == 0) { + pthis->hatchState = 2; + pthis->actionTimer = 3; + Math_ApproachF(&pthis->eggScale, 0.75f, 0.5f, 1.0f); + pthis->actor.velocity.y = 5.0f; + pthis->actor.speedXZ = 2.0f; + } else { + Math_ApproachF(&pthis->eggScale, 1.5f, 0.5f, 1.0f); + } + break; + + case 2: + if (pthis->actionTimer == 0) { + pthis->hatchState = 3; + pthis->actionTimer = 80; + } else { + Math_ApproachF(&pthis->eggScale, 0.75f, 0.5f, 1.0f); + } + break; + + case 3: + Math_ApproachF(&pthis->eggScale, 1.0f, 0.1f, 0.1f); + if (pthis->actionTimer == 0) { + EnGoma_SetupHatch(pthis, globalCtx); + } + break; + } + + if (pthis->actor.bgCheckFlags & 1) { + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.2f, 0.05f); + } + pthis->eggPitch += (pthis->actor.speedXZ * 0.1f); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnGoma_Egg(EnGoma* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + + pthis->eggSquishAngle += 1.0f; + Math_ApproachF(&pthis->eggSquishAmount, 0.1f, 1.0f, 0.005f); + if (fabsf(pthis->actor.world.pos.x - player->actor.world.pos.x) < 100.0f && + fabsf(pthis->actor.world.pos.z - player->actor.world.pos.z) < 100.0f) { + if (++pthis->playerDetectionTimer > 9) { + pthis->actionFunc = EnGoma_EggFallToGround; + } + } else { + pthis->playerDetectionTimer = 0; + } + + if (!(pthis->eggTimer & 0xF) && Rand_ZeroOne() < 0.5f) { + for (i = 0; i < 2; i++) { + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f acc = { 0.0f, -0.5f, 0.0f }; + Vec3f pos; + + pos.x = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.x; + pos.y = Rand_ZeroFloat(30.0f) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &vel, &acc, 0, (s16)(Rand_ZeroOne() * 5.0f) + 10, HAHEN_OBJECT_DEFAULT, + 10, NULL); + } + } +} + +void EnGoma_SetupHatch(EnGoma* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelanime, &gObjectGolJumpHeadbuttAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolJumpHeadbuttAnim), ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnGoma_Hatch; + Actor_SetScale(&pthis->actor, 0.005f); + pthis->gomaType = ENGOMA_NORMAL; + pthis->actionTimer = 5; + pthis->actor.shape.rot.y = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnGoma_SpawnHatchDebris(pthis, globalCtx); + pthis->eggScale = 1.0f; + pthis->actor.speedXZ = 0.0f; +} + +void EnGoma_Hatch(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + if (pthis->actionTimer == 0) { + EnGoma_SetupStand(pthis); + } +} + +void EnGoma_SetupHurt(EnGoma* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelanime, &gObjectGolDamagedAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolDamagedAnim), ANIMMODE_ONCE, -2.0f); + pthis->actionFunc = EnGoma_Hurt; + + if ((s8)pthis->actor.colChkInfo.health <= 0) { + pthis->actionTimer = 5; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else { + pthis->actionTimer = 10; + } + + pthis->actor.speedXZ = 20.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_DAM1); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_DAM1); + } +} + +void EnGoma_Hurt(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.bgCheckFlags & 1) { + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 2.0f); + } + + if (pthis->actionTimer == 0) { + if ((s8)pthis->actor.colChkInfo.health <= 0) { + EnGoma_SetupDie(pthis); + } else { + EnGoma_SetupFlee(pthis); + } + } +} + +void EnGoma_SetupDie(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolDeathAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gObjectGolDeathAnim), + ANIMMODE_ONCE, -2.0f); + pthis->actionFunc = EnGoma_Die; + pthis->actionTimer = 30; + + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_DEAD); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_DEAD); + } + + pthis->invincibilityTimer = 100; + pthis->actor.flags &= ~ACTOR_FLAG_0; +} + +void EnGoma_Die(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.bgCheckFlags & 1) { + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 2.0f); + } + + if (pthis->actionTimer == 17) { + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_LAND); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_LAND); + } + } + + if (pthis->actionTimer == 0) { + EnGoma_SetupDead(pthis); + } +} + +void EnGoma_SetupDead(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolDeadTwitchingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolDeadTwitchingAnim), ANIMMODE_LOOP, -2.0f); + pthis->actionFunc = EnGoma_Dead; + pthis->actionTimer = 3; +} + +void EnGoma_Dead(EnGoma* pthis, GlobalContext* globalCtx) { + Vec3f accel; + Vec3f pos; + + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 2.0f); + + if (pthis->actionTimer == 2) { + pos.x = pthis->actor.world.pos.x; + pos.y = (pthis->actor.world.pos.y + 5.0f) - 10.0f; + pos.z = pthis->actor.world.pos.z; + accel = sDeadEffectVel; + accel.y = 0.03f; + EffectSsKFire_Spawn(globalCtx, &pos, &sDeadEffectVel, &accel, 40, 0); + } + + if (pthis->actionTimer == 0 && Math_SmoothStepToF(&pthis->actor.scale.y, 0.0f, 0.5f, 0.00225f, 0.00001f) <= 0.001f) { + if (pthis->actor.params < 6) { + BossGoma* parent = (BossGoma*)pthis->actor.parent; + + parent->childrenGohmaState[pthis->actor.params] = -1; + } + Audio_PlaySoundGeneral(NA_SE_EN_EXTINCT, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Actor_Kill(&pthis->actor); + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, 0x30); + } + pthis->visualState = 2; +} + +void EnGoma_SetupStand(EnGoma* pthis) { + f32 lastFrame; + + lastFrame = Animation_GetLastFrame(&gObjectGolStandAnim); + pthis->actionTimer = Rand_S16Offset(10, 30); + Animation_Change(&pthis->skelanime, &gObjectGolStandAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = EnGoma_Stand; + pthis->gomaType = ENGOMA_NORMAL; +} + +void EnGoma_SetupChasePlayer(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolRunningAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolRunningAnim), ANIMMODE_LOOP, -5.0f); + pthis->actionFunc = EnGoma_ChasePlayer; + pthis->actionTimer = Rand_S16Offset(70, 110); +} + +void EnGoma_SetupPrepareJump(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolPrepareJumpAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolPrepareJumpAnim), ANIMMODE_ONCE, -5.0f); + pthis->actionFunc = EnGoma_PrepareJump; + pthis->actionTimer = 30; +} + +void EnGoma_PrepareJump(EnGoma* pthis, GlobalContext* globalCtx) { + s16 targetAngle; + + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + + targetAngle = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + Math_ApproachS(&pthis->actor.world.rot.y, targetAngle, 2, 4000); + Math_ApproachS(&pthis->actor.shape.rot.y, targetAngle, 2, 3000); + + if (pthis->actionTimer == 0) { + EnGoma_SetupJump(pthis); + } + pthis->visualState = 0; +} + +void EnGoma_SetupLand(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolLandFromJumpAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolLandFromJumpAnim), ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnGoma_Land; + pthis->actionTimer = 10; +} + +void EnGoma_Land(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.bgCheckFlags & 1) { + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 2.0f); + } + if (pthis->actionTimer == 0) { + EnGoma_SetupStand(pthis); + } +} + +void EnGoma_SetupJump(EnGoma* pthis) { + Animation_Change(&pthis->skelanime, &gObjectGolJumpHeadbuttAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGolJumpHeadbuttAnim), ANIMMODE_ONCE, 0.0f); + pthis->actionFunc = EnGoma_Jump; + pthis->actor.velocity.y = 8.0f; + + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_CRY); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_CRY); + } +} + +void EnGoma_Jump(EnGoma* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_24; + SkelAnime_Update(&pthis->skelanime); + Math_ApproachF(&pthis->actor.speedXZ, 10.0f, 0.5f, 5.0f); + + if (pthis->actor.velocity.y <= 0.0f && (pthis->actor.bgCheckFlags & 1)) { + EnGoma_SetupLand(pthis); + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_LAND2); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_LAND2); + } + } + pthis->visualState = 0; +} + +void EnGoma_Stand(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.shape.rot.y, Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor), 2, + 3000); + + if (pthis->actionTimer == 0) { + EnGoma_SetupChasePlayer(pthis); + } +} + +void EnGoma_ChasePlayer(EnGoma* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (Animation_OnFrame(&pthis->skelanime, 1.0f) || Animation_OnFrame(&pthis->skelanime, 5.0f)) { + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_WALK); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_WALK); + } + } + + Math_ApproachF(&pthis->actor.speedXZ, 10.0f / 3.0f, 0.5f, 2.0f); + Math_ApproachS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 3, 2000); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 2, 3000); + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 0.0f; + } + if (pthis->actor.xzDistToPlayer <= 150.0f) { + EnGoma_SetupPrepareJump(pthis); + } +} + +void EnGoma_SetupStunned(EnGoma* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = EnGoma_Stunned; + pthis->stunTimer = 100; + Animation_MorphToLoop(&pthis->skelanime, &gObjectGolStandAnim, -5.0f); + pthis->actionTimer = (s16)Rand_ZeroFloat(15.0f) + 3; + + if (pthis->actor.params < 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_BJR_FREEZE); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + } +} + +void EnGoma_Stunned(EnGoma* pthis, GlobalContext* globalCtx) { + Actor_SetColorFilter(&pthis->actor, 0, 180, 0, 2); + pthis->visualState = 2; + + if (pthis->actionTimer != 0) { + SkelAnime_Update(&pthis->skelanime); + } + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 0.0f; + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f); + } + + if (pthis->stunTimer == 0) { + EnGoma_SetupStand(pthis); + } else if (--pthis->stunTimer < 30) { + if (pthis->stunTimer & 1) { + pthis->actor.world.pos.x += 1.5f; + pthis->actor.world.pos.z += 1.5f; + } else { + pthis->actor.world.pos.x -= 1.5f; + pthis->actor.world.pos.z -= 1.5f; + } + } +} + +void EnGoma_LookAtPlayer(EnGoma* pthis, GlobalContext* globalCtx) { + s16 eyePitch; + s16 eyeYaw; + + eyeYaw = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.shape.rot.y; + eyePitch = Actor_WorldPitchTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.shape.rot.x; + + if (eyeYaw > 6000) { + eyeYaw = 6000; + } + if (eyeYaw < -6000) { + eyeYaw = -6000; + } + Math_ApproachS(&pthis->eyeYaw, eyeYaw, 3, 2000); + Math_ApproachS(&pthis->eyePitch, eyePitch, 3, 2000); +} + +void EnGoma_UpdateHit(EnGoma* pthis, GlobalContext* globalCtx) { + static Vec3f sShieldKnockbackVel = { 0.0f, 0.0f, 20.0f }; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->hurtTimer != 0) { + pthis->hurtTimer--; + } else { + ColliderInfo* acHitInfo; + u8 swordDamage; + + if ((pthis->colCyl1.base.atFlags & 2) && pthis->actionFunc == EnGoma_Jump) { + EnGoma_SetupLand(pthis); + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + } + + if ((pthis->colCyl2.base.acFlags & AC_HIT) && (s8)pthis->actor.colChkInfo.health > 0) { + acHitInfo = pthis->colCyl2.info.acHitInfo; + pthis->colCyl2.base.acFlags &= ~AC_HIT; + + if (pthis->gomaType == ENGOMA_NORMAL) { + u32 dmgFlags = acHitInfo->toucher.dmgFlags; + + if (dmgFlags & 0x100000) { + if (pthis->actionFunc == EnGoma_Jump) { + EnGoma_SetupLand(pthis); + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = -5.0f; + } else { + Matrix_RotateY(player->actor.shape.rot.y / (f32)0x8000 * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sShieldKnockbackVel, &pthis->shieldKnockbackVel); + pthis->invincibilityTimer = 5; + } + } else if (dmgFlags & 1) { // stun + if (pthis->actionFunc != EnGoma_Stunned) { + EnGoma_SetupStunned(pthis, globalCtx); + pthis->hurtTimer = 8; + } + } else { + swordDamage = CollisionCheck_GetSwordDamage(dmgFlags); + + if (swordDamage) { + EffectSsSibuki_SpawnBurst(globalCtx, &pthis->actor.focus.pos); + } else { + swordDamage = 1; + } + + pthis->actor.colChkInfo.health -= swordDamage; + EnGoma_SetupHurt(pthis, globalCtx); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 5); + pthis->hurtTimer = 13; + } + } else { + // die if still an egg + if (pthis->actor.params <= 5) { //! BossGoma only has 3 children + BossGoma* parent = (BossGoma*)pthis->actor.parent; + + parent->childrenGohmaState[pthis->actor.params] = -1; + } + + EnGoma_SpawnHatchDebris(pthis, globalCtx); + Actor_Kill(&pthis->actor); + } + } + } +} + +void EnGoma_UpdateEyeEnvColor(EnGoma* pthis) { + static f32 sTargetEyeEnvColors[][3] = { + { 255.0f, 0.0f, 50.0f }, + { 17.0f, 255.0f, 50.0f }, + { 0.0f, 170.0f, 50.0f }, + }; + + Math_ApproachF(&pthis->eyeEnvColor[0], sTargetEyeEnvColors[0][pthis->visualState], 0.5f, 20.0f); + Math_ApproachF(&pthis->eyeEnvColor[1], sTargetEyeEnvColors[1][pthis->visualState], 0.5f, 20.0f); + Math_ApproachF(&pthis->eyeEnvColor[2], sTargetEyeEnvColors[2][pthis->visualState], 0.5f, 20.0f); +} + +#include "hack.h" + +void EnGoma_SetFloorRot(EnGoma* pthis) { + f32 nx; + f32 ny; + f32 nz; + + if (pthis->actor.floorPoly != NULL) { + nx = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.x); + ny = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.z); + Math_ApproachS(&pthis->slopePitch, -Math_FAtan2F(-nz * ny, 1.0f) * (0x8000 / M_PI), 1, 1000); + Math_ApproachS(&pthis->slopeRoll, Math_FAtan2F(-nx * ny, 1.0f) * (0x8000 / M_PI), 1, 1000); + } +} + +void EnGoma_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGoma* pthis = (EnGoma*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (pthis->invincibilityTimer != 0) { + pthis->invincibilityTimer--; + } + + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + pthis->actor.world.pos.x = pthis->actor.world.pos.x + pthis->shieldKnockbackVel.x; + pthis->actor.world.pos.z = pthis->actor.world.pos.z + pthis->shieldKnockbackVel.z; + Math_ApproachZeroF(&pthis->shieldKnockbackVel.x, 1.0f, 3.0f); + Math_ApproachZeroF(&pthis->shieldKnockbackVel.z, 1.0f, 3.0f); + + if (pthis->actor.params < 10) { + pthis->eggTimer++; + Math_SmoothStepToF(&pthis->actor.scale.x, 0.01f, 0.5f, 0.00075f, 0.000001f); + Math_SmoothStepToF(&pthis->actor.scale.y, 0.01f, 0.5f, 0.00075f, 0.000001f); + Math_SmoothStepToF(&pthis->actor.scale.z, 0.01f, 0.5f, 0.00075f, 0.000001f); + EnGoma_UpdateHit(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 5); + EnGoma_SetFloorRot(pthis); + Actor_SetFocus(&pthis->actor, 20.0f); + EnGoma_LookAtPlayer(pthis, globalCtx); + EnGoma_UpdateEyeEnvColor(pthis); + pthis->visualState = 1; + if (player->swordState != 0) { + pthis->colCyl2.dim.radius = 35; + pthis->colCyl2.dim.height = 35; + pthis->colCyl2.dim.yShift = 0; + } else { + pthis->colCyl2.dim.radius = 15; + pthis->colCyl2.dim.height = 30; + pthis->colCyl2.dim.yShift = 10; + } + if (pthis->invincibilityTimer == 0) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCyl1); + Collider_UpdateCylinder(&pthis->actor, &pthis->colCyl2); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colCyl1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCyl2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colCyl1.base); + } + } +} + +s32 EnGoma_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnGoma* pthis = (EnGoma*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 1976); + gDPSetEnvColor(POLY_OPA_DISP++, (s16)pthis->eyeEnvColor[0], (s16)pthis->eyeEnvColor[1], (s16)pthis->eyeEnvColor[2], + 255); + + if (limbIndex == GOMA_LIMB_EYE_IRIS_ROOT1) { + rot->x += pthis->eyePitch; + rot->y += pthis->eyeYaw; + } else if (limbIndex == GOMA_LIMB_BODY && pthis->hurtTimer != 0) { + gDPSetEnvColor(POLY_OPA_DISP++, (s16)(Rand_ZeroOne() * 255.0f), (s16)(Rand_ZeroOne() * 255.0f), + (s16)(Rand_ZeroOne() * 255.0f), 255); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 2011); + return 0; +} + +Gfx* EnGoma_NoBackfaceCullingDlist(GraphicsContext* gfxCtx) { + Gfx* dListHead; + Gfx* dList; + + dListHead = dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 4); + gDPPipeSync(dListHead++); + gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2); + gSPClearGeometryMode(dListHead++, G_CULL_BACK); + gSPEndDisplayList(dListHead++); + return dList; +} + +void EnGoma_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGoma* pthis = (EnGoma*)thisx; + s32 y; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 2040); + func_80093D18(globalCtx->state.gfxCtx); + + switch (pthis->gomaType) { + case ENGOMA_NORMAL: + pthis->actor.naviEnemyId = 0x03; + Matrix_Translate(pthis->actor.world.pos.x, + pthis->actor.world.pos.y + ((pthis->actor.shape.yOffset * pthis->actor.scale.y) + + globalCtx->mainCamera.skyboxOffset.y), + pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateX(pthis->slopePitch / (f32)0x8000 * M_PI, MTXMODE_APPLY); + Matrix_RotateZ(pthis->slopeRoll / (f32)0x8000 * M_PI, MTXMODE_APPLY); + Matrix_RotateY(pthis->actor.shape.rot.y / (f32)0x8000 * M_PI, MTXMODE_APPLY); + Matrix_RotateX(pthis->actor.shape.rot.x / (f32)0x8000 * M_PI, MTXMODE_APPLY); + Matrix_RotateZ(pthis->actor.shape.rot.z / (f32)0x8000 * M_PI, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + SkelAnime_DrawOpa(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, EnGoma_OverrideLimbDraw, + NULL, pthis); + break; + + case ENGOMA_EGG: + pthis->actor.naviEnemyId = 0x02; + y = (s16)(sinf((pthis->eggTimer * 5.0f * 3.1415f) / 180.0f) * 31.9f); + y = (s16)(y + 31); + gSPSegment(POLY_OPA_DISP++, 0x08, func_80094E78(globalCtx->state.gfxCtx, 0, y)); + Matrix_Push(); + Matrix_Scale(pthis->eggScale, 1.0f / pthis->eggScale, pthis->eggScale, MTXMODE_APPLY); + Matrix_RotateY(pthis->eggSquishAngle * 0.15f, MTXMODE_APPLY); + Matrix_RotateZ(pthis->eggSquishAngle * 0.1f, MTXMODE_APPLY); + Matrix_Scale(0.95f - pthis->eggSquishAmount, pthis->eggSquishAmount + 1.05f, 0.95f - pthis->eggSquishAmount, + MTXMODE_APPLY); + Matrix_RotateZ(-(pthis->eggSquishAngle * 0.1f), MTXMODE_APPLY); + Matrix_RotateY(-(pthis->eggSquishAngle * 0.15f), MTXMODE_APPLY); + Matrix_Translate(0.0f, pthis->eggYOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateX(pthis->eggPitch, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_goma.c", 2101), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gObjectGolEggDL); + Matrix_Pop(); + break; + + case ENGOMA_HATCH_DEBRIS: + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_goma.c", 2107), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBrownFragmentDL); + break; + + case ENGOMA_BOSSLIMB: + if (pthis->bossLimbDl != NULL) { + gSPSegment(POLY_OPA_DISP++, 0x08, EnGoma_NoBackfaceCullingDlist(globalCtx->state.gfxCtx)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_goma.c", 2114), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, pthis->bossLimbDl); + } + break; + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_goma.c", 2119); +} + +void EnGoma_Debris(EnGoma* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.y += 2500; + pthis->actor.shape.rot.x += 3500; + if (pthis->actionTimer == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnGoma_SpawnHatchDebris(EnGoma* pthis, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s16 i; + + if (pthis->actor.params < 6) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 0x28, NA_SE_EN_GOMA_BJR_EGG2); + } else { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 0x28, NA_SE_EN_GOMA_EGG2); + } + + for (i = 0; i < 15; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_GOMA, + Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.x, + Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y + 15.0f, + Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.z, 0, Rand_CenteredFloat(0x10000 - 0.01f), + 0, i + 10); + } +} + +void EnGoma_BossLimb(EnGoma* pthis, GlobalContext* globalCtx) { + Vec3f vel = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 1.0f, 0.0f }; + Color_RGBA8 primColor = { 255, 255, 255, 255 }; + Color_RGBA8 envColor = { 0, 100, 255, 255 }; + Vec3f pos; + + pthis->actor.world.pos.y -= 5.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 4); + pthis->actor.world.pos.y += 5.0f; + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 0.0f; + } else if (pthis->actionTimer < 250) { + pthis->actor.shape.rot.y += 2000; + } + + if (pthis->actionTimer == 250) { + pthis->actor.gravity = -1.0f; + } + + if (pthis->actionTimer < 121) { + if (Math_SmoothStepToF(&pthis->actor.scale.y, 0.0f, 1.0f, 0.00075f, 0) <= 0.001f) { + Actor_Kill(&pthis->actor); + } + pthis->actor.scale.x = pthis->actor.scale.z = pthis->actor.scale.y; + } + + if (pthis->actionTimer % 8 == 0 && pthis->actionTimer != 0) { + pos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + pos.y = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + func_8002836C(globalCtx, &pos, &vel, &accel, &primColor, &envColor, 500, 10, 10); + } +} diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c deleted file mode 100644 index de0b1abcd..000000000 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ /dev/null @@ -1,769 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GOROIWA_Z_EN_GOROIWA_C -#include "actor_common.h" -/* - * File: z_en_goroiwa.c - * Overlay: ovl_En_Goroiwa - * Description: Rolling boulders - */ - -#include "z_en_goroiwa.h" -#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_goroiwa/object_goroiwa.h" -#include "vt.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_quake.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef s32 (*EnGoroiwaUnkFunc1)(EnGoroiwa* this, GlobalContext* globalCtx); -typedef void (*EnGoroiwaUnkFunc2)(EnGoroiwa* this); - -#define ENGOROIWA_ENABLE_AT (1 << 0) -#define ENGOROIWA_ENABLE_OC (1 << 1) -#define ENGOROIWA_PLAYER_IN_THE_WAY (1 << 2) -#define ENGOROIWA_RETAIN_ROT_SPEED (1 << 3) -#define ENGOROIWA_IN_WATER (1 << 4) - -#define ENGOROIWA_LOOPMODE_ONEWAY 0 -/* same as ENGOROIWA_LOOPMODE_ONEWAY but display rock fragments as if the boulder broke at the end of the path*/ -#define ENGOROIWA_LOOPMODE_ONEWAY_BREAK 1 -#define ENGOROIWA_LOOPMODE_ROUNDTRIP 3 - -void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnGoroiwa_SetupRoll(EnGoroiwa* this); -void EnGoroiwa_Roll(EnGoroiwa* this, GlobalContext* globalCtx); -void EnGoroiwa_SetupMoveAndFallToGround(EnGoroiwa* this); -void EnGoroiwa_MoveAndFallToGround(EnGoroiwa* this, GlobalContext* globalCtx); -void EnGoroiwa_SetupWait(EnGoroiwa* this); -void EnGoroiwa_Wait(EnGoroiwa* this, GlobalContext* globalCtx); -void EnGoroiwa_SetupMoveUp(EnGoroiwa* this); -void EnGoroiwa_MoveUp(EnGoroiwa* this, GlobalContext* globalCtx); -void EnGoroiwa_SetupMoveDown(EnGoroiwa* this); -void EnGoroiwa_MoveDown(EnGoroiwa* this, GlobalContext* globalCtx); - -const ActorInit En_Goroiwa_InitVars = { - ACTOR_EN_GOROIWA, - ACTORCAT_PROP, - FLAGS, - OBJECT_GOROIWA, - sizeof(EnGoroiwa), - (ActorFunc)EnGoroiwa_Init, - (ActorFunc)EnGoroiwa_Destroy, - (ActorFunc)EnGoroiwa_Update, - (ActorFunc)EnGoroiwa_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x20000000, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 58 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_HEAVY }; - -static f32 sUnused[] = { 10.0f, 9.2f }; - -void EnGoroiwa_UpdateCollider(EnGoroiwa* this) { - static f32 yOffsets[] = { 0.0f, 59.5f }; - Sphere16* worldSphere = &this->collider.elements[0].dim.worldSphere; - - worldSphere->center.x = this->actor.world.pos.x; - worldSphere->center.y = this->actor.world.pos.y + yOffsets[(this->actor.params >> 10) & 1]; - worldSphere->center.z = this->actor.world.pos.z; -} - -void EnGoroiwa_InitCollider(EnGoroiwa* this, GlobalContext* globalCtx) { - s32 pad; - - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - EnGoroiwa_UpdateCollider(this); - this->collider.elements[0].dim.worldSphere.radius = 58; -} - -void EnGoroiwa_UpdateFlags(EnGoroiwa* this, u8 setFlags) { - this->stateFlags &= ~(ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); - this->stateFlags |= setFlags; -} - -s32 EnGoroiwa_Vec3fNormalize(Vec3f* ret, Vec3f* a) { - f32 magnitude = Math3D_Vec3fMagnitude(a); - f32 scale; - - if (magnitude < 0.001f) { - return false; - } - - scale = 1.0f / magnitude; - - ret->x = a->x * scale; - ret->y = a->y * scale; - ret->z = a->z * scale; - - return true; -} - -void EnGoroiwa_SetSpeed(EnGoroiwa* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SPOT04) { - this->isInKokiri = true; - R_EN_GOROIWA_SPEED = 920; - } else { - this->isInKokiri = false; - R_EN_GOROIWA_SPEED = 1000; - } -} - -void EnGoroiwa_FaceNextWaypoint(EnGoroiwa* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - Vec3s* nextPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->nextWaypoint; - Vec3f nextPosF; - - nextPosF.x = nextPos->x; - nextPosF.y = nextPos->y; - nextPosF.z = nextPos->z; - - this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &nextPosF); -} - -void EnGoroiwa_GetPrevWaypointDiff(EnGoroiwa* this, GlobalContext* globalCtx, Vec3f* dest) { - s16 loopMode = (this->actor.params >> 8) & 3; - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - s16 prevWaypoint = this->currentWaypoint - this->pathDirection; - Vec3s* prevPointPos; - Vec3s* currentPointPos; - - if (prevWaypoint < 0) { - if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { - prevWaypoint = this->endWaypoint; - } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { - prevWaypoint = 1; - } - } else if (prevWaypoint > this->endWaypoint) { - if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { - prevWaypoint = 0; - } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { - prevWaypoint = this->endWaypoint - 1; - } - } - - currentPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->currentWaypoint; - prevPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + prevWaypoint; - dest->x = currentPointPos->x - prevPointPos->x; - dest->y = currentPointPos->x - prevPointPos->y; - dest->z = currentPointPos->x - prevPointPos->z; -} - -void EnGoroiw_CheckEndOfPath(EnGoroiwa* this) { - s16 loopMode = (this->actor.params >> 8) & 3; - - if (this->nextWaypoint < 0) { - if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { - this->currentWaypoint = this->endWaypoint; - this->nextWaypoint = this->endWaypoint - 1; - this->pathDirection = -1; - } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { - this->currentWaypoint = 0; - this->nextWaypoint = 1; - this->pathDirection = 1; - } - } else if (this->nextWaypoint > this->endWaypoint) { - if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { - this->currentWaypoint = 0; - this->nextWaypoint = 1; - this->pathDirection = 1; - } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { - this->currentWaypoint = this->endWaypoint; - this->nextWaypoint = this->endWaypoint - 1; - this->pathDirection = -1; - } - } -} - -void EnGoroiwa_SetNextWaypoint(EnGoroiwa* this) { - this->currentWaypoint = this->nextWaypoint; - this->nextWaypoint += this->pathDirection; - EnGoroiw_CheckEndOfPath(this); -} - -void EnGoroiwa_ReverseDirection(EnGoroiwa* this) { - this->pathDirection *= -1; - this->currentWaypoint = this->nextWaypoint; - this->nextWaypoint += this->pathDirection; -} - -void EnGoroiwa_InitPath(EnGoroiwa* this, GlobalContext* globalCtx) { - this->endWaypoint = globalCtx->setupPathList[this->actor.params & 0xFF].count - 1; - this->currentWaypoint = 0; - this->nextWaypoint = 1; - this->pathDirection = 1; -} - -void EnGoroiwa_TeleportToWaypoint(EnGoroiwa* this, GlobalContext* globalCtx, s32 waypoint) { - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - Vec3s* pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + waypoint; - - this->actor.world.pos.x = pointPos->x; - this->actor.world.pos.y = pointPos->y; - this->actor.world.pos.z = pointPos->z; -} - -void EnGoroiwa_InitRotation(EnGoroiwa* this) { - this->prevUnitRollAxis.x = 1.0f; - this->rollRotSpeed = 1.0f; -} - -s32 EnGoroiwa_GetAscendDirection(EnGoroiwa* this, GlobalContext* globalCtx) { - s32 pad; - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->nextWaypoint; - Vec3s* currentPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->currentWaypoint; - - if (nextPointPos->x == currentPointPos->x && nextPointPos->z == currentPointPos->z) { - if (nextPointPos->y == currentPointPos->y) { - // "Error: Invalid path data (points overlap)" - osSyncPrintf("Error : レールデータ不正(点が重なっている)"); - osSyncPrintf("(%s %d)(arg_data 0x%04x)\n", "../z_en_gr.c", 559, this->actor.params); - } - - if (nextPointPos->y > currentPointPos->y) { - return 1; - } else { - return -1; - } - } - - return 0; -} - -void EnGoroiwa_SpawnDust(GlobalContext* globalCtx, Vec3f* pos) { - static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f accel = { 0.0f, 0.3f, 0.0f }; - Vec3f randPos; - s32 i; - s16 angle = 0; - - for (i = 0; i < 8; i++) { - angle += 0x4E20; - randPos.x = pos->x + (47.0f * (Rand_ZeroOne() * 0.5f + 0.5f)) * Math_SinS(angle); - randPos.y = pos->y + (Rand_ZeroOne() - 0.5f) * 40.0f; - randPos.z = pos->z + ((47.0f * (Rand_ZeroOne() * 0.5f + 0.5f))) * Math_CosS(angle); - func_800286CC(globalCtx, &randPos, &velocity, &accel, (s16)(Rand_ZeroOne() * 30.0f) + 100, 80); - func_800286CC(globalCtx, &randPos, &velocity, &accel, (s16)(Rand_ZeroOne() * 20.0f) + 80, 80); - } -} - -void EnGoroiwa_SpawnWaterEffects(GlobalContext* globalCtx, Vec3f* contactPos) { - Vec3f splashPos; - s32 i; - s16 angle = 0; - - for (i = 0; i < 11; i++) { - angle += 0x1746; - splashPos.x = contactPos->x + (Math_SinS(angle) * 55.0f); - splashPos.y = contactPos->y; - splashPos.z = contactPos->z + (Math_CosS(angle) * 55.0f); - EffectSsGSplash_Spawn(globalCtx, &splashPos, 0, 0, 0, 350); - } - - EffectSsGRipple_Spawn(globalCtx, contactPos, 300, 700, 0); - EffectSsGRipple_Spawn(globalCtx, contactPos, 500, 900, 4); - EffectSsGRipple_Spawn(globalCtx, contactPos, 500, 1300, 8); -} - -s32 EnGoroiwa_MoveAndFall(EnGoroiwa* this, GlobalContext* globalCtx) { - Path* path; - s32 result; - s32 pad; - Vec3s* nextPointPos; - - Math_StepToF(&this->actor.speedXZ, R_EN_GOROIWA_SPEED * 0.01f, 0.3f); - func_8002D868(&this->actor); - path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->nextWaypoint; - result = true; - result &= Math_StepToF(&this->actor.world.pos.x, nextPointPos->x, fabsf(this->actor.velocity.x)); - result &= Math_StepToF(&this->actor.world.pos.z, nextPointPos->z, fabsf(this->actor.velocity.z)); - this->actor.world.pos.y += this->actor.velocity.y; - return result; -} - -s32 EnGoroiwa_Move(EnGoroiwa* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - s32 pad; - Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->nextWaypoint; - Vec3s* currentPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->currentWaypoint; - s32 nextPointReached; - Vec3f posDiff; - Vec3f nextPointPosF; - - nextPointPosF.x = nextPointPos->x; - nextPointPosF.y = nextPointPos->y; - nextPointPosF.z = nextPointPos->z; - Math_StepToF(&this->actor.speedXZ, R_EN_GOROIWA_SPEED * 0.01f, 0.3f); - if (Math3D_Vec3fDistSq(&nextPointPosF, &this->actor.world.pos) < SQ(5.0f)) { - Math_Vec3f_Diff(&nextPointPosF, &this->actor.world.pos, &posDiff); - } else { - posDiff.x = nextPointPosF.x - currentPointPos->x; - posDiff.y = nextPointPosF.y - currentPointPos->y; - posDiff.z = nextPointPosF.z - currentPointPos->z; - } - EnGoroiwa_Vec3fNormalize(&this->actor.velocity, &posDiff); - this->actor.velocity.x *= this->actor.speedXZ; - this->actor.velocity.y *= this->actor.speedXZ; - this->actor.velocity.z *= this->actor.speedXZ; - nextPointReached = true; - nextPointReached &= Math_StepToF(&this->actor.world.pos.x, nextPointPosF.x, fabsf(this->actor.velocity.x)); - nextPointReached &= Math_StepToF(&this->actor.world.pos.y, nextPointPosF.y, fabsf(this->actor.velocity.y)); - nextPointReached &= Math_StepToF(&this->actor.world.pos.z, nextPointPosF.z, fabsf(this->actor.velocity.z)); - return nextPointReached; -} - -s32 EnGoroiwa_MoveUpToNextWaypoint(EnGoroiwa* this, GlobalContext* globalCtx) { - s32 pad; - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->nextWaypoint; - - Math_StepToF(&this->actor.velocity.y, (R_EN_GOROIWA_SPEED * 0.01f) * 0.5f, 0.18f); - this->actor.world.pos.x = nextPointPos->x; - this->actor.world.pos.z = nextPointPos->z; - return Math_StepToF(&this->actor.world.pos.y, nextPointPos->y, fabsf(this->actor.velocity.y)); -} - -s32 EnGoroiwa_MoveDownToNextWaypoint(EnGoroiwa* this, GlobalContext* globalCtx) { - s32 pad; - Path* path = &globalCtx->setupPathList[this->actor.params & 0xFF]; - Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->nextWaypoint; - f32 nextPointY; - f32 thisY; - f32 yDistToFloor; - s32 quakeIdx; - CollisionPoly* floorPoly; - Vec3f raycastFrom; - f32 floorY; - s32 pad2; - s32 floorBgId; - Vec3f dustPos; - WaterBox* waterBox; - f32 ySurface; - Vec3f waterHitPos; - - nextPointY = nextPointPos->y; - Math_StepToF(&this->actor.velocity.y, -14.0f, 1.0f); - this->actor.world.pos.x = nextPointPos->x; - this->actor.world.pos.z = nextPointPos->z; - thisY = this->actor.world.pos.y; - if (1) {} - this->actor.world.pos.y += this->actor.velocity.y; - if (this->actor.velocity.y < 0.0f && this->actor.world.pos.y <= nextPointY) { - if (this->bounceCount == 0) { - if (this->actor.xzDistToPlayer < 600.0f) { - quakeIdx = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quakeIdx, -0x3CB0); - Quake_SetQuakeValues(quakeIdx, 3, 0, 0, 0); - Quake_SetCountdown(quakeIdx, 7); - } - this->rollRotSpeed = 0.0f; - if (!(this->stateFlags & ENGOROIWA_IN_WATER)) { - raycastFrom.x = this->actor.world.pos.x; - raycastFrom.y = this->actor.world.pos.y + 50.0f; - raycastFrom.z = this->actor.world.pos.z; - floorY = BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &floorPoly, &floorBgId, - &this->actor, &raycastFrom); - yDistToFloor = floorY - (this->actor.world.pos.y - 59.5f); - if (fabsf(yDistToFloor) < 15.0f) { - dustPos.x = this->actor.world.pos.x; - dustPos.y = floorY + 10.0f; - dustPos.z = this->actor.world.pos.z; - EnGoroiwa_SpawnDust(globalCtx, &dustPos); - } - } - } - if (this->bounceCount >= 1) { - return true; - } - this->bounceCount++; - this->actor.velocity.y *= -0.3f; - this->actor.world.pos.y = nextPointY - ((this->actor.world.pos.y - nextPointY) * 0.3f); - } - if (this->bounceCount == 0 && - WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &ySurface, &waterBox) && - this->actor.world.pos.y <= ySurface) { - this->stateFlags |= ENGOROIWA_IN_WATER; - if (ySurface < thisY) { - waterHitPos.x = this->actor.world.pos.x; - waterHitPos.y = ySurface; - waterHitPos.z = this->actor.world.pos.z; - EnGoroiwa_SpawnWaterEffects(globalCtx, &waterHitPos); - this->actor.velocity.y *= 0.2f; - } - if (this->actor.velocity.y < -8.0f) { - this->actor.velocity.y = -8.0f; - } - } - return false; -} - -void EnGoroiwa_UpdateRotation(EnGoroiwa* this, GlobalContext* globalCtx) { - static Vec3f unitY = { 0.0f, 1.0f, 0.0f }; - s32 pad; - Vec3f* rollAxisPtr; - f32 rollAngleDiff; - Vec3f rollAxis; - Vec3f unitRollAxis; - MtxF mtx; - Vec3f unusedDiff; - - if (this->stateFlags & ENGOROIWA_RETAIN_ROT_SPEED) { - rollAngleDiff = this->prevRollAngleDiff; - } else { - this->prevRollAngleDiff = Math3D_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.prevPos) * (1.0f / 59.5f); - rollAngleDiff = this->prevRollAngleDiff; - } - rollAngleDiff *= this->rollRotSpeed; - rollAxisPtr = &rollAxis; - if (this->stateFlags & ENGOROIWA_RETAIN_ROT_SPEED) { - /* - * EnGoroiwa_GetPrevWaypointDiff has no side effects and its result goes unused, - * its result was probably meant to be used instead of the actor's velocity in the - * Math3D_Vec3f_Cross call. - */ - EnGoroiwa_GetPrevWaypointDiff(this, globalCtx, &unusedDiff); - Math3D_Vec3f_Cross(&unitY, &this->actor.velocity, rollAxisPtr); - } else { - Math3D_Vec3f_Cross(&unitY, &this->actor.velocity, rollAxisPtr); - } - - if (EnGoroiwa_Vec3fNormalize(&unitRollAxis, rollAxisPtr)) { - this->prevUnitRollAxis = unitRollAxis; - } else { - unitRollAxis = this->prevUnitRollAxis; - } - - Matrix_RotateAxis(rollAngleDiff, &unitRollAxis, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); - Matrix_RotateX(this->actor.shape.rot.x * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); - Matrix_RotateZ(this->actor.shape.rot.z * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); - Matrix_Get(&mtx); - Matrix_MtxFToYXZRotS(&mtx, &this->actor.shape.rot, 0); -} - -void EnGoroiwa_NextWaypoint(EnGoroiwa* this, GlobalContext* globalCtx) { - s16 loopMode = (this->actor.params >> 8) & 3; - - EnGoroiwa_SetNextWaypoint(this); - - if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { - if (this->currentWaypoint == 0 || this->currentWaypoint == this->endWaypoint) { - EnGoroiwa_TeleportToWaypoint(this, globalCtx, this->currentWaypoint); - } - } - - EnGoroiwa_FaceNextWaypoint(this, globalCtx); -} - -void EnGoroiwa_SpawnFragments(EnGoroiwa* this, GlobalContext* globalCtx) { - static f32 yOffsets[] = { 0.0f, 59.5f }; - s16 angle1; - s16 angle2; - s32 pad; - Vec3f* thisPos = &this->actor.world.pos; - Vec3f effectPos; - Vec3f fragmentVelocity; - f32 cos1; - f32 sin1; - f32 sin2; - s16 yOffsetIdx = (this->actor.params >> 10) & 1; - s32 i; - - for (i = 0, angle1 = 0; i < 16; i++, angle1 += 0x4E20) { - sin1 = Math_SinS(angle1); - cos1 = Math_CosS(angle1); - angle2 = Rand_ZeroOne() * 0xFFFF; - effectPos.x = Rand_ZeroOne() * 50.0f * sin1 * Math_SinS(angle2); - sin2 = Math_SinS(angle2); - effectPos.y = (Rand_ZeroOne() - 0.5f) * 100.0f * sin2 + yOffsets[yOffsetIdx]; - effectPos.z = Rand_ZeroOne() * 50.0f * cos1 * Math_SinS(angle2); - fragmentVelocity.x = effectPos.x * 0.2f; - fragmentVelocity.y = Rand_ZeroOne() * 15.0f + 2.0f; - fragmentVelocity.z = effectPos.z * 0.2f; - Math_Vec3f_Sum(&effectPos, thisPos, &effectPos); - EffectSsKakera_Spawn(globalCtx, &effectPos, &fragmentVelocity, &effectPos, -340, 33, 28, 2, 0, - Rand_ZeroOne() * 7.0f + 1.0f, 1, 0, 70, KAKERA_COLOR_NONE, 1, gBoulderFragmentsDL); - } - - effectPos.x = thisPos->x; - effectPos.y = thisPos->y + yOffsets[yOffsetIdx]; - effectPos.z = thisPos->z; - func_80033480(globalCtx, &effectPos, 80.0f, 5, 70, 110, 1); - func_80033480(globalCtx, &effectPos, 90.0f, 5, 110, 160, 1); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -860, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), -}; - -void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { - static f32 yOffsets[] = { 0.0f, 595.0f }; - EnGoroiwa* this = (EnGoroiwa*)thisx; - s32 pathIdx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - EnGoroiwa_InitCollider(this, globalCtx); - pathIdx = this->actor.params & 0xFF; - if (pathIdx == 0xFF) { - // "Error: Invalid arg_data" - osSyncPrintf("Error : arg_data が不正(%s %d)(arg_data 0x%04x)\n", "../z_en_gr.c", 1033, - this->actor.params); - Actor_Kill(&this->actor); - return; - } - if (globalCtx->setupPathList[pathIdx].count < 2) { - // "Error: Invalid Path Data" - osSyncPrintf("Error : レールデータ が不正(%s %d)\n", "../z_en_gr.c", 1043); - Actor_Kill(&this->actor); - return; - } - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, yOffsets[(this->actor.params >> 10) & 1], ActorShadow_DrawCircle, 9.4f); - this->actor.shape.shadowAlpha = 200; - EnGoroiwa_SetSpeed(this, globalCtx); - EnGoroiwa_InitPath(this, globalCtx); - EnGoroiwa_TeleportToWaypoint(this, globalCtx, 0); - EnGoroiwa_InitRotation(this); - EnGoroiwa_FaceNextWaypoint(this, globalCtx); - EnGoroiwa_SetupRoll(this); - // "(Goroiwa)" - osSyncPrintf("(ごろ岩)(arg 0x%04x)(rail %d)(end %d)(bgc %d)(hit %d)\n", this->actor.params, - this->actor.params & 0xFF, (this->actor.params >> 8) & 3, (this->actor.params >> 10) & 1, - this->actor.home.rot.z & 1); -} - -void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnGoroiwa* this = (EnGoroiwa*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnGoroiwa_SetupRoll(EnGoroiwa* this) { - this->actionFunc = EnGoroiwa_Roll; - EnGoroiwa_UpdateFlags(this, ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); - this->rollRotSpeed = 1.0f; -} - -void EnGoroiwa_Roll(EnGoroiwa* this, GlobalContext* globalCtx) { - static EnGoroiwaUnkFunc1 moveFuncs[] = { EnGoroiwa_Move, EnGoroiwa_MoveAndFall }; - static EnGoroiwaUnkFunc2 onHitSetupFuncs[] = { EnGoroiwa_SetupWait, EnGoroiwa_SetupMoveAndFallToGround }; - - s32 ascendDirection; - s16 yawDiff; - s16 loopMode; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - this->stateFlags &= ~ENGOROIWA_PLAYER_IN_THE_WAY; - yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - if (yawDiff > -0x4000 && yawDiff < 0x4000) { - this->stateFlags |= ENGOROIWA_PLAYER_IN_THE_WAY; - if (((this->actor.params >> 10) & 1) || (this->actor.home.rot.z & 1) != 1) { - EnGoroiwa_ReverseDirection(this); - EnGoroiwa_FaceNextWaypoint(this, globalCtx); - } - } - func_8002F6D4(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - osSyncPrintf(VT_FGCOL(CYAN)); - osSyncPrintf("Player ぶっ飛ばし\n"); // "Player knocked down" - osSyncPrintf(VT_RST); - onHitSetupFuncs[(this->actor.params >> 10) & 1](this); - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - if ((this->actor.home.rot.z & 1) == 1) { - this->collisionDisabledTimer = 50; - } - } else if (moveFuncs[(this->actor.params >> 10) & 1](this, globalCtx)) { - loopMode = (this->actor.params >> 8) & 3; - if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK && - (this->nextWaypoint == 0 || this->nextWaypoint == this->endWaypoint)) { - EnGoroiwa_SpawnFragments(this, globalCtx); - } - EnGoroiwa_NextWaypoint(this, globalCtx); - if ((loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) && - (this->currentWaypoint == 0 || this->currentWaypoint == this->endWaypoint)) { - EnGoroiwa_SetupWait(this); - } else if (!((this->actor.params >> 10) & 1) && this->currentWaypoint != 0 && - this->currentWaypoint != this->endWaypoint) { - ascendDirection = EnGoroiwa_GetAscendDirection(this, globalCtx); - if (ascendDirection > 0) { - EnGoroiwa_SetupMoveUp(this); - } else if (ascendDirection < 0) { - EnGoroiwa_SetupMoveDown(this); - } else { - EnGoroiwa_SetupRoll(this); - } - } else { - EnGoroiwa_SetupRoll(this); - } - } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); -} - -void EnGoroiwa_SetupMoveAndFallToGround(EnGoroiwa* this) { - this->actionFunc = EnGoroiwa_MoveAndFallToGround; - EnGoroiwa_UpdateFlags(this, ENGOROIWA_ENABLE_OC); - this->actor.gravity = -0.86f; - this->actor.minVelocityY = -15.0f; - this->actor.speedXZ *= 0.15f; - this->actor.velocity.y = 5.0f; - this->rollRotSpeed = 1.0f; -} - -void EnGoroiwa_MoveAndFallToGround(EnGoroiwa* this, GlobalContext* globalCtx) { - EnGoroiwa_MoveAndFall(this, globalCtx); - if ((this->actor.bgCheckFlags & 1) && this->actor.velocity.y < 0.0f) { - if ((this->stateFlags & ENGOROIWA_PLAYER_IN_THE_WAY) && (this->actor.home.rot.z & 1) == 1) { - EnGoroiwa_ReverseDirection(this); - EnGoroiwa_FaceNextWaypoint(this, globalCtx); - } - EnGoroiwa_SetupWait(this); - } -} - -void EnGoroiwa_SetupWait(EnGoroiwa* this) { - static s16 waitDurations[] = { 20, 6 }; - - this->actionFunc = EnGoroiwa_Wait; - this->actor.speedXZ = 0.0f; - EnGoroiwa_UpdateFlags(this, ENGOROIWA_ENABLE_OC); - this->waitTimer = waitDurations[this->actor.home.rot.z & 1]; - this->rollRotSpeed = 0.0f; -} - -void EnGoroiwa_Wait(EnGoroiwa* this, GlobalContext* globalCtx) { - if (this->waitTimer > 0) { - this->waitTimer--; - } else { - this->collider.base.atFlags &= ~AT_HIT; - EnGoroiwa_SetupRoll(this); - } -} - -void EnGoroiwa_SetupMoveUp(EnGoroiwa* this) { - this->actionFunc = EnGoroiwa_MoveUp; - EnGoroiwa_UpdateFlags(this, ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); - this->rollRotSpeed = 0.0f; - this->actor.velocity.y = fabsf(this->actor.speedXZ) * 0.1f; -} - -void EnGoroiwa_MoveUp(EnGoroiwa* this, GlobalContext* globalCtx) { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - func_8002F6D4(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 4); - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - if ((this->actor.home.rot.z & 1) == 1) { - this->collisionDisabledTimer = 50; - } - } else if (EnGoroiwa_MoveUpToNextWaypoint(this, globalCtx)) { - EnGoroiwa_NextWaypoint(this, globalCtx); - EnGoroiwa_SetupRoll(this); - this->actor.speedXZ = 0.0f; - } -} - -void EnGoroiwa_SetupMoveDown(EnGoroiwa* this) { - this->actionFunc = EnGoroiwa_MoveDown; - EnGoroiwa_UpdateFlags(this, ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); - this->rollRotSpeed = 0.3f; - this->bounceCount = 0; - this->actor.velocity.y = fabsf(this->actor.speedXZ) * -0.3f; - this->stateFlags |= ENGOROIWA_RETAIN_ROT_SPEED; - this->stateFlags &= ~ENGOROIWA_IN_WATER; -} - -void EnGoroiwa_MoveDown(EnGoroiwa* this, GlobalContext* globalCtx) { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - func_8002F6D4(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 4); - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); - if ((this->actor.home.rot.z & 1) == 1) { - this->collisionDisabledTimer = 50; - } - } else if (EnGoroiwa_MoveDownToNextWaypoint(this, globalCtx)) { - EnGoroiwa_NextWaypoint(this, globalCtx); - EnGoroiwa_SetupRoll(this); - this->stateFlags &= ~ENGOROIWA_RETAIN_ROT_SPEED; - this->actor.speedXZ = 0.0f; - } -} - -void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGoroiwa* this = (EnGoroiwa*)thisx; - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s32 sp30; - - if (!(player->stateFlags1 & 0x300000C0)) { - if (this->collisionDisabledTimer > 0) { - this->collisionDisabledTimer--; - } - this->actionFunc(this, globalCtx); - switch ((this->actor.params >> 10) & 1) { - case 1: - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); - break; - case 0: - this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &sp30, - &this->actor, &this->actor.world.pos); - break; - } - EnGoroiwa_UpdateRotation(this, globalCtx); - if (this->actor.xzDistToPlayer < 300.0f) { - EnGoroiwa_UpdateCollider(this); - if ((this->stateFlags & ENGOROIWA_ENABLE_AT) && this->collisionDisabledTimer <= 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if ((this->stateFlags & ENGOROIWA_ENABLE_OC) && this->collisionDisabledTimer <= 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - } -} - -void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gRollingRockDL); -} diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp new file mode 100644 index 000000000..7da004106 --- /dev/null +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp @@ -0,0 +1,769 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GOROIWA_Z_EN_GOROIWA_C +#include "actor_common.h" +/* + * File: z_en_goroiwa.c + * Overlay: ovl_En_Goroiwa + * Description: Rolling boulders + */ + +#include "z_en_goroiwa.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_goroiwa/object_goroiwa.h" +#include "vt.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_quake.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef s32 (*EnGoroiwaUnkFunc1)(EnGoroiwa* pthis, GlobalContext* globalCtx); +typedef void (*EnGoroiwaUnkFunc2)(EnGoroiwa* pthis); + +#define ENGOROIWA_ENABLE_AT (1 << 0) +#define ENGOROIWA_ENABLE_OC (1 << 1) +#define ENGOROIWA_PLAYER_IN_THE_WAY (1 << 2) +#define ENGOROIWA_RETAIN_ROT_SPEED (1 << 3) +#define ENGOROIWA_IN_WATER (1 << 4) + +#define ENGOROIWA_LOOPMODE_ONEWAY 0 +/* same as ENGOROIWA_LOOPMODE_ONEWAY but display rock fragments as if the boulder broke at the end of the path*/ +#define ENGOROIWA_LOOPMODE_ONEWAY_BREAK 1 +#define ENGOROIWA_LOOPMODE_ROUNDTRIP 3 + +void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnGoroiwa_SetupRoll(EnGoroiwa* pthis); +void EnGoroiwa_Roll(EnGoroiwa* pthis, GlobalContext* globalCtx); +void EnGoroiwa_SetupMoveAndFallToGround(EnGoroiwa* pthis); +void EnGoroiwa_MoveAndFallToGround(EnGoroiwa* pthis, GlobalContext* globalCtx); +void EnGoroiwa_SetupWait(EnGoroiwa* pthis); +void EnGoroiwa_Wait(EnGoroiwa* pthis, GlobalContext* globalCtx); +void EnGoroiwa_SetupMoveUp(EnGoroiwa* pthis); +void EnGoroiwa_MoveUp(EnGoroiwa* pthis, GlobalContext* globalCtx); +void EnGoroiwa_SetupMoveDown(EnGoroiwa* pthis); +void EnGoroiwa_MoveDown(EnGoroiwa* pthis, GlobalContext* globalCtx); + +ActorInit En_Goroiwa_InitVars = { + ACTOR_EN_GOROIWA, + ACTORCAT_PROP, + FLAGS, + OBJECT_GOROIWA, + sizeof(EnGoroiwa), + (ActorFunc)EnGoroiwa_Init, + (ActorFunc)EnGoroiwa_Destroy, + (ActorFunc)EnGoroiwa_Update, + (ActorFunc)EnGoroiwa_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 58 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_HEAVY }; + +static f32 sUnused[] = { 10.0f, 9.2f }; + +void EnGoroiwa_UpdateCollider(EnGoroiwa* pthis) { + static f32 yOffsets[] = { 0.0f, 59.5f }; + Sphere16* worldSphere = &pthis->collider.elements[0].dim.worldSphere; + + worldSphere->center.x = pthis->actor.world.pos.x; + worldSphere->center.y = pthis->actor.world.pos.y + yOffsets[(pthis->actor.params >> 10) & 1]; + worldSphere->center.z = pthis->actor.world.pos.z; +} + +void EnGoroiwa_InitCollider(EnGoroiwa* pthis, GlobalContext* globalCtx) { + s32 pad; + + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + EnGoroiwa_UpdateCollider(pthis); + pthis->collider.elements[0].dim.worldSphere.radius = 58; +} + +void EnGoroiwa_UpdateFlags(EnGoroiwa* pthis, u8 setFlags) { + pthis->stateFlags &= ~(ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); + pthis->stateFlags |= setFlags; +} + +s32 EnGoroiwa_Vec3fNormalize(Vec3f* ret, Vec3f* a) { + f32 magnitude = Math3D_Vec3fMagnitude(a); + f32 scale; + + if (magnitude < 0.001f) { + return false; + } + + scale = 1.0f / magnitude; + + ret->x = a->x * scale; + ret->y = a->y * scale; + ret->z = a->z * scale; + + return true; +} + +void EnGoroiwa_SetSpeed(EnGoroiwa* pthis, GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SPOT04) { + pthis->isInKokiri = true; + R_EN_GOROIWA_SPEED = 920; + } else { + pthis->isInKokiri = false; + R_EN_GOROIWA_SPEED = 1000; + } +} + +void EnGoroiwa_FaceNextWaypoint(EnGoroiwa* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + Vec3s* nextPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->nextWaypoint; + Vec3f nextPosF; + + nextPosF.x = nextPos->x; + nextPosF.y = nextPos->y; + nextPosF.z = nextPos->z; + + pthis->actor.world.rot.y = Math_Vec3f_Yaw(&pthis->actor.world.pos, &nextPosF); +} + +void EnGoroiwa_GetPrevWaypointDiff(EnGoroiwa* pthis, GlobalContext* globalCtx, Vec3f* dest) { + s16 loopMode = (pthis->actor.params >> 8) & 3; + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + s16 prevWaypoint = pthis->currentWaypoint - pthis->pathDirection; + Vec3s* prevPointPos; + Vec3s* currentPointPos; + + if (prevWaypoint < 0) { + if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { + prevWaypoint = pthis->endWaypoint; + } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { + prevWaypoint = 1; + } + } else if (prevWaypoint > pthis->endWaypoint) { + if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { + prevWaypoint = 0; + } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { + prevWaypoint = pthis->endWaypoint - 1; + } + } + + currentPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->currentWaypoint; + prevPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + prevWaypoint; + dest->x = currentPointPos->x - prevPointPos->x; + dest->y = currentPointPos->x - prevPointPos->y; + dest->z = currentPointPos->x - prevPointPos->z; +} + +void EnGoroiw_CheckEndOfPath(EnGoroiwa* pthis) { + s16 loopMode = (pthis->actor.params >> 8) & 3; + + if (pthis->nextWaypoint < 0) { + if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { + pthis->currentWaypoint = pthis->endWaypoint; + pthis->nextWaypoint = pthis->endWaypoint - 1; + pthis->pathDirection = -1; + } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { + pthis->currentWaypoint = 0; + pthis->nextWaypoint = 1; + pthis->pathDirection = 1; + } + } else if (pthis->nextWaypoint > pthis->endWaypoint) { + if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { + pthis->currentWaypoint = 0; + pthis->nextWaypoint = 1; + pthis->pathDirection = 1; + } else if (loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) { + pthis->currentWaypoint = pthis->endWaypoint; + pthis->nextWaypoint = pthis->endWaypoint - 1; + pthis->pathDirection = -1; + } + } +} + +void EnGoroiwa_SetNextWaypoint(EnGoroiwa* pthis) { + pthis->currentWaypoint = pthis->nextWaypoint; + pthis->nextWaypoint += pthis->pathDirection; + EnGoroiw_CheckEndOfPath(pthis); +} + +void EnGoroiwa_ReverseDirection(EnGoroiwa* pthis) { + pthis->pathDirection *= -1; + pthis->currentWaypoint = pthis->nextWaypoint; + pthis->nextWaypoint += pthis->pathDirection; +} + +void EnGoroiwa_InitPath(EnGoroiwa* pthis, GlobalContext* globalCtx) { + pthis->endWaypoint = globalCtx->setupPathList[pthis->actor.params & 0xFF].count - 1; + pthis->currentWaypoint = 0; + pthis->nextWaypoint = 1; + pthis->pathDirection = 1; +} + +void EnGoroiwa_TeleportToWaypoint(EnGoroiwa* pthis, GlobalContext* globalCtx, s32 waypoint) { + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + Vec3s* pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + waypoint; + + pthis->actor.world.pos.x = pointPos->x; + pthis->actor.world.pos.y = pointPos->y; + pthis->actor.world.pos.z = pointPos->z; +} + +void EnGoroiwa_InitRotation(EnGoroiwa* pthis) { + pthis->prevUnitRollAxis.x = 1.0f; + pthis->rollRotSpeed = 1.0f; +} + +s32 EnGoroiwa_GetAscendDirection(EnGoroiwa* pthis, GlobalContext* globalCtx) { + s32 pad; + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->nextWaypoint; + Vec3s* currentPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->currentWaypoint; + + if (nextPointPos->x == currentPointPos->x && nextPointPos->z == currentPointPos->z) { + if (nextPointPos->y == currentPointPos->y) { + // "Error: Invalid path data (points overlap)" + osSyncPrintf("Error : レールデータ不正(点が重なっている)"); + osSyncPrintf("(%s %d)(arg_data 0x%04x)\n", "../z_en_gr.c", 559, pthis->actor.params); + } + + if (nextPointPos->y > currentPointPos->y) { + return 1; + } else { + return -1; + } + } + + return 0; +} + +void EnGoroiwa_SpawnDust(GlobalContext* globalCtx, Vec3f* pos) { + static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f accel = { 0.0f, 0.3f, 0.0f }; + Vec3f randPos; + s32 i; + s16 angle = 0; + + for (i = 0; i < 8; i++) { + angle += 0x4E20; + randPos.x = pos->x + (47.0f * (Rand_ZeroOne() * 0.5f + 0.5f)) * Math_SinS(angle); + randPos.y = pos->y + (Rand_ZeroOne() - 0.5f) * 40.0f; + randPos.z = pos->z + ((47.0f * (Rand_ZeroOne() * 0.5f + 0.5f))) * Math_CosS(angle); + func_800286CC(globalCtx, &randPos, &velocity, &accel, (s16)(Rand_ZeroOne() * 30.0f) + 100, 80); + func_800286CC(globalCtx, &randPos, &velocity, &accel, (s16)(Rand_ZeroOne() * 20.0f) + 80, 80); + } +} + +void EnGoroiwa_SpawnWaterEffects(GlobalContext* globalCtx, Vec3f* contactPos) { + Vec3f splashPos; + s32 i; + s16 angle = 0; + + for (i = 0; i < 11; i++) { + angle += 0x1746; + splashPos.x = contactPos->x + (Math_SinS(angle) * 55.0f); + splashPos.y = contactPos->y; + splashPos.z = contactPos->z + (Math_CosS(angle) * 55.0f); + EffectSsGSplash_Spawn(globalCtx, &splashPos, 0, 0, 0, 350); + } + + EffectSsGRipple_Spawn(globalCtx, contactPos, 300, 700, 0); + EffectSsGRipple_Spawn(globalCtx, contactPos, 500, 900, 4); + EffectSsGRipple_Spawn(globalCtx, contactPos, 500, 1300, 8); +} + +s32 EnGoroiwa_MoveAndFall(EnGoroiwa* pthis, GlobalContext* globalCtx) { + Path* path; + s32 result; + s32 pad; + Vec3s* nextPointPos; + + Math_StepToF(&pthis->actor.speedXZ, R_EN_GOROIWA_SPEED * 0.01f, 0.3f); + func_8002D868(&pthis->actor); + path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->nextWaypoint; + result = true; + result &= Math_StepToF(&pthis->actor.world.pos.x, nextPointPos->x, fabsf(pthis->actor.velocity.x)); + result &= Math_StepToF(&pthis->actor.world.pos.z, nextPointPos->z, fabsf(pthis->actor.velocity.z)); + pthis->actor.world.pos.y += pthis->actor.velocity.y; + return result; +} + +s32 EnGoroiwa_Move(EnGoroiwa* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + s32 pad; + Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->nextWaypoint; + Vec3s* currentPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->currentWaypoint; + s32 nextPointReached; + Vec3f posDiff; + Vec3f nextPointPosF; + + nextPointPosF.x = nextPointPos->x; + nextPointPosF.y = nextPointPos->y; + nextPointPosF.z = nextPointPos->z; + Math_StepToF(&pthis->actor.speedXZ, R_EN_GOROIWA_SPEED * 0.01f, 0.3f); + if (Math3D_Vec3fDistSq(&nextPointPosF, &pthis->actor.world.pos) < SQ(5.0f)) { + Math_Vec3f_Diff(&nextPointPosF, &pthis->actor.world.pos, &posDiff); + } else { + posDiff.x = nextPointPosF.x - currentPointPos->x; + posDiff.y = nextPointPosF.y - currentPointPos->y; + posDiff.z = nextPointPosF.z - currentPointPos->z; + } + EnGoroiwa_Vec3fNormalize(&pthis->actor.velocity, &posDiff); + pthis->actor.velocity.x *= pthis->actor.speedXZ; + pthis->actor.velocity.y *= pthis->actor.speedXZ; + pthis->actor.velocity.z *= pthis->actor.speedXZ; + nextPointReached = true; + nextPointReached &= Math_StepToF(&pthis->actor.world.pos.x, nextPointPosF.x, fabsf(pthis->actor.velocity.x)); + nextPointReached &= Math_StepToF(&pthis->actor.world.pos.y, nextPointPosF.y, fabsf(pthis->actor.velocity.y)); + nextPointReached &= Math_StepToF(&pthis->actor.world.pos.z, nextPointPosF.z, fabsf(pthis->actor.velocity.z)); + return nextPointReached; +} + +s32 EnGoroiwa_MoveUpToNextWaypoint(EnGoroiwa* pthis, GlobalContext* globalCtx) { + s32 pad; + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->nextWaypoint; + + Math_StepToF(&pthis->actor.velocity.y, (R_EN_GOROIWA_SPEED * 0.01f) * 0.5f, 0.18f); + pthis->actor.world.pos.x = nextPointPos->x; + pthis->actor.world.pos.z = nextPointPos->z; + return Math_StepToF(&pthis->actor.world.pos.y, nextPointPos->y, fabsf(pthis->actor.velocity.y)); +} + +s32 EnGoroiwa_MoveDownToNextWaypoint(EnGoroiwa* pthis, GlobalContext* globalCtx) { + s32 pad; + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xFF]; + Vec3s* nextPointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->nextWaypoint; + f32 nextPointY; + f32 thisY; + f32 yDistToFloor; + s32 quakeIdx; + CollisionPoly* floorPoly; + Vec3f raycastFrom; + f32 floorY; + s32 pad2; + s32 floorBgId; + Vec3f dustPos; + WaterBox* waterBox; + f32 ySurface; + Vec3f waterHitPos; + + nextPointY = nextPointPos->y; + Math_StepToF(&pthis->actor.velocity.y, -14.0f, 1.0f); + pthis->actor.world.pos.x = nextPointPos->x; + pthis->actor.world.pos.z = nextPointPos->z; + thisY = pthis->actor.world.pos.y; + if (1) {} + pthis->actor.world.pos.y += pthis->actor.velocity.y; + if (pthis->actor.velocity.y < 0.0f && pthis->actor.world.pos.y <= nextPointY) { + if (pthis->bounceCount == 0) { + if (pthis->actor.xzDistToPlayer < 600.0f) { + quakeIdx = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(quakeIdx, -0x3CB0); + Quake_SetQuakeValues(quakeIdx, 3, 0, 0, 0); + Quake_SetCountdown(quakeIdx, 7); + } + pthis->rollRotSpeed = 0.0f; + if (!(pthis->stateFlags & ENGOROIWA_IN_WATER)) { + raycastFrom.x = pthis->actor.world.pos.x; + raycastFrom.y = pthis->actor.world.pos.y + 50.0f; + raycastFrom.z = pthis->actor.world.pos.z; + floorY = BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &floorPoly, &floorBgId, + &pthis->actor, &raycastFrom); + yDistToFloor = floorY - (pthis->actor.world.pos.y - 59.5f); + if (fabsf(yDistToFloor) < 15.0f) { + dustPos.x = pthis->actor.world.pos.x; + dustPos.y = floorY + 10.0f; + dustPos.z = pthis->actor.world.pos.z; + EnGoroiwa_SpawnDust(globalCtx, &dustPos); + } + } + } + if (pthis->bounceCount >= 1) { + return true; + } + pthis->bounceCount++; + pthis->actor.velocity.y *= -0.3f; + pthis->actor.world.pos.y = nextPointY - ((pthis->actor.world.pos.y - nextPointY) * 0.3f); + } + if (pthis->bounceCount == 0 && + WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, + &ySurface, &waterBox) && + pthis->actor.world.pos.y <= ySurface) { + pthis->stateFlags |= ENGOROIWA_IN_WATER; + if (ySurface < thisY) { + waterHitPos.x = pthis->actor.world.pos.x; + waterHitPos.y = ySurface; + waterHitPos.z = pthis->actor.world.pos.z; + EnGoroiwa_SpawnWaterEffects(globalCtx, &waterHitPos); + pthis->actor.velocity.y *= 0.2f; + } + if (pthis->actor.velocity.y < -8.0f) { + pthis->actor.velocity.y = -8.0f; + } + } + return false; +} + +void EnGoroiwa_UpdateRotation(EnGoroiwa* pthis, GlobalContext* globalCtx) { + static Vec3f unitY = { 0.0f, 1.0f, 0.0f }; + s32 pad; + Vec3f* rollAxisPtr; + f32 rollAngleDiff; + Vec3f rollAxis; + Vec3f unitRollAxis; + MtxF mtx; + Vec3f unusedDiff; + + if (pthis->stateFlags & ENGOROIWA_RETAIN_ROT_SPEED) { + rollAngleDiff = pthis->prevRollAngleDiff; + } else { + pthis->prevRollAngleDiff = Math3D_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->actor.prevPos) * (1.0f / 59.5f); + rollAngleDiff = pthis->prevRollAngleDiff; + } + rollAngleDiff *= pthis->rollRotSpeed; + rollAxisPtr = &rollAxis; + if (pthis->stateFlags & ENGOROIWA_RETAIN_ROT_SPEED) { + /* + * EnGoroiwa_GetPrevWaypointDiff has no side effects and its result goes unused, + * its result was probably meant to be used instead of the actor's velocity in the + * Math3D_Vec3f_Cross call. + */ + EnGoroiwa_GetPrevWaypointDiff(pthis, globalCtx, &unusedDiff); + Math3D_Vec3f_Cross(&unitY, &pthis->actor.velocity, rollAxisPtr); + } else { + Math3D_Vec3f_Cross(&unitY, &pthis->actor.velocity, rollAxisPtr); + } + + if (EnGoroiwa_Vec3fNormalize(&unitRollAxis, rollAxisPtr)) { + pthis->prevUnitRollAxis = unitRollAxis; + } else { + unitRollAxis = pthis->prevUnitRollAxis; + } + + Matrix_RotateAxis(rollAngleDiff, &unitRollAxis, MTXMODE_NEW); + Matrix_RotateY(pthis->actor.shape.rot.y * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); + Matrix_RotateX(pthis->actor.shape.rot.x * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->actor.shape.rot.z * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); + Matrix_Get(&mtx); + Matrix_MtxFToYXZRotS(&mtx, &pthis->actor.shape.rot, 0); +} + +void EnGoroiwa_NextWaypoint(EnGoroiwa* pthis, GlobalContext* globalCtx) { + s16 loopMode = (pthis->actor.params >> 8) & 3; + + EnGoroiwa_SetNextWaypoint(pthis); + + if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY || loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK) { + if (pthis->currentWaypoint == 0 || pthis->currentWaypoint == pthis->endWaypoint) { + EnGoroiwa_TeleportToWaypoint(pthis, globalCtx, pthis->currentWaypoint); + } + } + + EnGoroiwa_FaceNextWaypoint(pthis, globalCtx); +} + +void EnGoroiwa_SpawnFragments(EnGoroiwa* pthis, GlobalContext* globalCtx) { + static f32 yOffsets[] = { 0.0f, 59.5f }; + s16 angle1; + s16 angle2; + s32 pad; + Vec3f* thisPos = &pthis->actor.world.pos; + Vec3f effectPos; + Vec3f fragmentVelocity; + f32 cos1; + f32 sin1; + f32 sin2; + s16 yOffsetIdx = (pthis->actor.params >> 10) & 1; + s32 i; + + for (i = 0, angle1 = 0; i < 16; i++, angle1 += 0x4E20) { + sin1 = Math_SinS(angle1); + cos1 = Math_CosS(angle1); + angle2 = Rand_ZeroOne() * 0xFFFF; + effectPos.x = Rand_ZeroOne() * 50.0f * sin1 * Math_SinS(angle2); + sin2 = Math_SinS(angle2); + effectPos.y = (Rand_ZeroOne() - 0.5f) * 100.0f * sin2 + yOffsets[yOffsetIdx]; + effectPos.z = Rand_ZeroOne() * 50.0f * cos1 * Math_SinS(angle2); + fragmentVelocity.x = effectPos.x * 0.2f; + fragmentVelocity.y = Rand_ZeroOne() * 15.0f + 2.0f; + fragmentVelocity.z = effectPos.z * 0.2f; + Math_Vec3f_Sum(&effectPos, thisPos, &effectPos); + EffectSsKakera_Spawn(globalCtx, &effectPos, &fragmentVelocity, &effectPos, -340, 33, 28, 2, 0, + Rand_ZeroOne() * 7.0f + 1.0f, 1, 0, 70, KAKERA_COLOR_NONE, 1, gBoulderFragmentsDL); + } + + effectPos.x = thisPos->x; + effectPos.y = thisPos->y + yOffsets[yOffsetIdx]; + effectPos.z = thisPos->z; + func_80033480(globalCtx, &effectPos, 80.0f, 5, 70, 110, 1); + func_80033480(globalCtx, &effectPos, 90.0f, 5, 110, 160, 1); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -860, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), +}; + +void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + static f32 yOffsets[] = { 0.0f, 595.0f }; + EnGoroiwa* pthis = (EnGoroiwa*)thisx; + s32 pathIdx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + EnGoroiwa_InitCollider(pthis, globalCtx); + pathIdx = pthis->actor.params & 0xFF; + if (pathIdx == 0xFF) { + // "Error: Invalid arg_data" + osSyncPrintf("Error : arg_data が不正(%s %d)(arg_data 0x%04x)\n", "../z_en_gr.c", 1033, + pthis->actor.params); + Actor_Kill(&pthis->actor); + return; + } + if (globalCtx->setupPathList[pathIdx].count < 2) { + // "Error: Invalid Path Data" + osSyncPrintf("Error : レールデータ が不正(%s %d)\n", "../z_en_gr.c", 1043); + Actor_Kill(&pthis->actor); + return; + } + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, yOffsets[(pthis->actor.params >> 10) & 1], ActorShadow_DrawCircle, 9.4f); + pthis->actor.shape.shadowAlpha = 200; + EnGoroiwa_SetSpeed(pthis, globalCtx); + EnGoroiwa_InitPath(pthis, globalCtx); + EnGoroiwa_TeleportToWaypoint(pthis, globalCtx, 0); + EnGoroiwa_InitRotation(pthis); + EnGoroiwa_FaceNextWaypoint(pthis, globalCtx); + EnGoroiwa_SetupRoll(pthis); + // "(Goroiwa)" + osSyncPrintf("(ごろ岩)(arg 0x%04x)(rail %d)(end %d)(bgc %d)(hit %d)\n", pthis->actor.params, + pthis->actor.params & 0xFF, (pthis->actor.params >> 8) & 3, (pthis->actor.params >> 10) & 1, + pthis->actor.home.rot.z & 1); +} + +void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGoroiwa* pthis = (EnGoroiwa*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnGoroiwa_SetupRoll(EnGoroiwa* pthis) { + pthis->actionFunc = EnGoroiwa_Roll; + EnGoroiwa_UpdateFlags(pthis, ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); + pthis->rollRotSpeed = 1.0f; +} + +void EnGoroiwa_Roll(EnGoroiwa* pthis, GlobalContext* globalCtx) { + static EnGoroiwaUnkFunc1 moveFuncs[] = { EnGoroiwa_Move, EnGoroiwa_MoveAndFall }; + static EnGoroiwaUnkFunc2 onHitSetupFuncs[] = { EnGoroiwa_SetupWait, EnGoroiwa_SetupMoveAndFallToGround }; + + s32 ascendDirection; + s16 yawDiff; + s16 loopMode; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->stateFlags &= ~ENGOROIWA_PLAYER_IN_THE_WAY; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y; + if (yawDiff > -0x4000 && yawDiff < 0x4000) { + pthis->stateFlags |= ENGOROIWA_PLAYER_IN_THE_WAY; + if (((pthis->actor.params >> 10) & 1) || (pthis->actor.home.rot.z & 1) != 1) { + EnGoroiwa_ReverseDirection(pthis); + EnGoroiwa_FaceNextWaypoint(pthis, globalCtx); + } + } + func_8002F6D4(globalCtx, &pthis->actor, 2.0f, pthis->actor.yawTowardsPlayer, 0.0f, 0); + osSyncPrintf(VT_FGCOL(CYAN)); + osSyncPrintf("Player ぶっ飛ばし\n"); // "Player knocked down" + osSyncPrintf(VT_RST); + onHitSetupFuncs[(pthis->actor.params >> 10) & 1](pthis); + func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); + if ((pthis->actor.home.rot.z & 1) == 1) { + pthis->collisionDisabledTimer = 50; + } + } else if (moveFuncs[(pthis->actor.params >> 10) & 1](pthis, globalCtx)) { + loopMode = (pthis->actor.params >> 8) & 3; + if (loopMode == ENGOROIWA_LOOPMODE_ONEWAY_BREAK && + (pthis->nextWaypoint == 0 || pthis->nextWaypoint == pthis->endWaypoint)) { + EnGoroiwa_SpawnFragments(pthis, globalCtx); + } + EnGoroiwa_NextWaypoint(pthis, globalCtx); + if ((loopMode == ENGOROIWA_LOOPMODE_ROUNDTRIP) && + (pthis->currentWaypoint == 0 || pthis->currentWaypoint == pthis->endWaypoint)) { + EnGoroiwa_SetupWait(pthis); + } else if (!((pthis->actor.params >> 10) & 1) && pthis->currentWaypoint != 0 && + pthis->currentWaypoint != pthis->endWaypoint) { + ascendDirection = EnGoroiwa_GetAscendDirection(pthis, globalCtx); + if (ascendDirection > 0) { + EnGoroiwa_SetupMoveUp(pthis); + } else if (ascendDirection < 0) { + EnGoroiwa_SetupMoveDown(pthis); + } else { + EnGoroiwa_SetupRoll(pthis); + } + } else { + EnGoroiwa_SetupRoll(pthis); + } + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); +} + +void EnGoroiwa_SetupMoveAndFallToGround(EnGoroiwa* pthis) { + pthis->actionFunc = EnGoroiwa_MoveAndFallToGround; + EnGoroiwa_UpdateFlags(pthis, ENGOROIWA_ENABLE_OC); + pthis->actor.gravity = -0.86f; + pthis->actor.minVelocityY = -15.0f; + pthis->actor.speedXZ *= 0.15f; + pthis->actor.velocity.y = 5.0f; + pthis->rollRotSpeed = 1.0f; +} + +void EnGoroiwa_MoveAndFallToGround(EnGoroiwa* pthis, GlobalContext* globalCtx) { + EnGoroiwa_MoveAndFall(pthis, globalCtx); + if ((pthis->actor.bgCheckFlags & 1) && pthis->actor.velocity.y < 0.0f) { + if ((pthis->stateFlags & ENGOROIWA_PLAYER_IN_THE_WAY) && (pthis->actor.home.rot.z & 1) == 1) { + EnGoroiwa_ReverseDirection(pthis); + EnGoroiwa_FaceNextWaypoint(pthis, globalCtx); + } + EnGoroiwa_SetupWait(pthis); + } +} + +void EnGoroiwa_SetupWait(EnGoroiwa* pthis) { + static s16 waitDurations[] = { 20, 6 }; + + pthis->actionFunc = EnGoroiwa_Wait; + pthis->actor.speedXZ = 0.0f; + EnGoroiwa_UpdateFlags(pthis, ENGOROIWA_ENABLE_OC); + pthis->waitTimer = waitDurations[pthis->actor.home.rot.z & 1]; + pthis->rollRotSpeed = 0.0f; +} + +void EnGoroiwa_Wait(EnGoroiwa* pthis, GlobalContext* globalCtx) { + if (pthis->waitTimer > 0) { + pthis->waitTimer--; + } else { + pthis->collider.base.atFlags &= ~AT_HIT; + EnGoroiwa_SetupRoll(pthis); + } +} + +void EnGoroiwa_SetupMoveUp(EnGoroiwa* pthis) { + pthis->actionFunc = EnGoroiwa_MoveUp; + EnGoroiwa_UpdateFlags(pthis, ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); + pthis->rollRotSpeed = 0.0f; + pthis->actor.velocity.y = fabsf(pthis->actor.speedXZ) * 0.1f; +} + +void EnGoroiwa_MoveUp(EnGoroiwa* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + func_8002F6D4(globalCtx, &pthis->actor, 2.0f, pthis->actor.yawTowardsPlayer, 0.0f, 4); + func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); + if ((pthis->actor.home.rot.z & 1) == 1) { + pthis->collisionDisabledTimer = 50; + } + } else if (EnGoroiwa_MoveUpToNextWaypoint(pthis, globalCtx)) { + EnGoroiwa_NextWaypoint(pthis, globalCtx); + EnGoroiwa_SetupRoll(pthis); + pthis->actor.speedXZ = 0.0f; + } +} + +void EnGoroiwa_SetupMoveDown(EnGoroiwa* pthis) { + pthis->actionFunc = EnGoroiwa_MoveDown; + EnGoroiwa_UpdateFlags(pthis, ENGOROIWA_ENABLE_AT | ENGOROIWA_ENABLE_OC); + pthis->rollRotSpeed = 0.3f; + pthis->bounceCount = 0; + pthis->actor.velocity.y = fabsf(pthis->actor.speedXZ) * -0.3f; + pthis->stateFlags |= ENGOROIWA_RETAIN_ROT_SPEED; + pthis->stateFlags &= ~ENGOROIWA_IN_WATER; +} + +void EnGoroiwa_MoveDown(EnGoroiwa* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + func_8002F6D4(globalCtx, &pthis->actor, 2.0f, pthis->actor.yawTowardsPlayer, 0.0f, 4); + func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_PL_BODY_HIT); + if ((pthis->actor.home.rot.z & 1) == 1) { + pthis->collisionDisabledTimer = 50; + } + } else if (EnGoroiwa_MoveDownToNextWaypoint(pthis, globalCtx)) { + EnGoroiwa_NextWaypoint(pthis, globalCtx); + EnGoroiwa_SetupRoll(pthis); + pthis->stateFlags &= ~ENGOROIWA_RETAIN_ROT_SPEED; + pthis->actor.speedXZ = 0.0f; + } +} + +void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGoroiwa* pthis = (EnGoroiwa*)thisx; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 sp30; + + if (!(player->stateFlags1 & 0x300000C0)) { + if (pthis->collisionDisabledTimer > 0) { + pthis->collisionDisabledTimer--; + } + pthis->actionFunc(pthis, globalCtx); + switch ((pthis->actor.params >> 10) & 1) { + case 1: + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 0x1C); + break; + case 0: + pthis->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &sp30, + &pthis->actor, &pthis->actor.world.pos); + break; + } + EnGoroiwa_UpdateRotation(pthis, globalCtx); + if (pthis->actor.xzDistToPlayer < 300.0f) { + EnGoroiwa_UpdateCollider(pthis); + if ((pthis->stateFlags & ENGOROIWA_ENABLE_AT) && pthis->collisionDisabledTimer <= 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if ((pthis->stateFlags & ENGOROIWA_ENABLE_OC) && pthis->collisionDisabledTimer <= 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + } +} + +void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gRollingRockDL); +} diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c deleted file mode 100644 index afd2364d3..000000000 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ /dev/null @@ -1,628 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GS_Z_EN_GS_C -#include "actor_common.h" -/* - * File: z_en_gs.c - * Overlay: ovl_En_Gs - * Description: Gossip Stone - */ - -#include "z_en_gs.h" -#include "objects/object_gs/object_gs.h" -#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800F7260.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_25) - -void EnGs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A4F734(EnGs* this, GlobalContext* globalCtx); -void func_80A4F700(EnGs* this, GlobalContext* globalCtx); - -void func_80A4F77C(EnGs* this); - -const ActorInit En_Gs_InitVars = { - ACTOR_EN_GS, - ACTORCAT_PROP, - FLAGS, - OBJECT_GS, - sizeof(EnGs), - (ActorFunc)EnGs_Init, - (ActorFunc)EnGs_Destroy, - (ActorFunc)EnGs_Update, - (ActorFunc)EnGs_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HARD, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 21, 48, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0xE), - /* Explosive */ DMG_ENTRY(0, 0xC), - /* Boomerang */ DMG_ENTRY(0, 0xE), - /* Normal arrow */ DMG_ENTRY(0, 0xE), - /* Hammer swing */ DMG_ENTRY(0, 0xD), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Kokiri sword */ DMG_ENTRY(0, 0xF), - /* Master sword */ DMG_ENTRY(0, 0xF), - /* Giant's Knife */ DMG_ENTRY(0, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0xB), - /* Ice arrow */ DMG_ENTRY(0, 0xB), - /* Light arrow */ DMG_ENTRY(0, 0xB), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0xB), - /* Ice magic */ DMG_ENTRY(0, 0xB), - /* Light magic */ DMG_ENTRY(0, 0xB), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(0, 0x0), - /* Giant spin */ DMG_ENTRY(0, 0x0), - /* Master spin */ DMG_ENTRY(0, 0x0), - /* Kokiri jump */ DMG_ENTRY(0, 0x0), - /* Giant jump */ DMG_ENTRY(0, 0x0), - /* Master jump */ DMG_ENTRY(0, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGs* this = (EnGs*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - CollisionCheck_SetInfo2(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); - - thisx->targetMode = 6; - this->unk_1D8 = thisx->world.pos; - this->actionFunc = func_80A4F734; - this->unk_1B4[0].x = 1.0f; - this->unk_1B4[0].y = 1.0f; - this->unk_1B4[0].z = 1.0f; - this->unk_1B4[1].x = 1.0f; - this->unk_1B4[1].y = 1.0f; - this->unk_1B4[1].z = 1.0f; -} - -void EnGs_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -s32 func_80A4E3EC(EnGs* this, GlobalContext* globalCtx) { - s32 ret = 2; - switch (Message_GetState(&globalCtx->msgCtx)) { - case TEXT_STATE_DONE: - if (Message_ShouldAdvance(globalCtx)) { - switch (this->actor.textId) { - case 0x2054: - this->actor.textId = (this->actor.params & 0xFF) + 0x400; - ret = 1; - break; - default: - ret = 0; - break; - } - } - break; - } - return ret; -} - -void func_80A4E470(EnGs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - bREG(15) = 0; - if (this->actor.xzDistToPlayer <= 100.0f) { - bREG(15) = 1; - if (this->unk_19D == 0) { - player->stateFlags2 |= 0x800000; - if (player->stateFlags2 & 0x1000000) { - func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); - this->unk_19D |= 1; - } - - } else if (this->unk_19D & 1) { - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - if ((globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_SARIAS) || - (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_EPONAS) || - (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_LULLABY) || - (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_SUNS) || - (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_TIME)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, FAIRY_HEAL_TIMED); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - } else if (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_STORMS) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, FAIRY_HEAL_BIG); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - } - this->unk_19D = 0; - Flags_SetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F); - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; - } - } - } -} - -void func_80A4E648(EnGs* this, GlobalContext* globalCtx) { - s16 sp26; - s16 sp24; - - if (this->unk_19C == 1) { - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_19C = 2; - } else if (this->unk_19C == 2) { - this->unk_19C = func_80A4E3EC(this, globalCtx); - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_19C = 2; - } else { - Actor_GetScreenPos(globalCtx, &this->actor, &sp26, &sp24); - if ((sp26 >= 0) && (sp26 <= SCREEN_WIDTH) && (sp24 >= 0) && (sp24 <= SCREEN_HEIGHT) && (this->unk_19C != 3)) { - if (func_8002F2CC(&this->actor, globalCtx, 40.0f) == 1) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { - this->actor.textId = 0x2054; - } else { - this->actor.textId = 0x2053; - } - } - } - } -} - -f32 func_80A4E754(EnGs* this, GlobalContext* globalCtx, f32* arg2, f32* arg3, u16* arg4, f32 arg5, f32 arg6, f32 arg7, - s32 arg8, s32 arg9) { - f32 sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); - - if (arg9 == 0) { - sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); - this->unk_1B4[0].x = 1.0f + (sinf((((*arg4 % arg8) * (1.0f / arg8)) * 360.0f) * (M_PI / 180.0f)) * *arg2); - this->unk_1B4[0].y = 1.0f - (sinf((((*arg4 % arg8) * (1.0f / arg8)) * 360.0f) * (M_PI / 180.0f)) * *arg2); - *arg4 += 1; - } - return sp2C; -} - -void func_80A4E910(EnGs* this, GlobalContext* globalCtx) { - if (this->unk_19F == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - this->unk_200 = 0; - this->unk_19F = 1; - this->unk_1E8 = 0.5f; - this->unk_1EC = 0.0f; - } else if ((this->unk_19F == 1) && (func_80A4E754(this, globalCtx, &this->unk_1E8, &this->unk_1EC, &this->unk_200, - 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f)) { - if (!Gameplay_InCsMode(globalCtx)) { - Message_StartTextbox(globalCtx, 0x71B1, NULL); - } - this->unk_19C = 0; - this->actionFunc = func_80A4F734; - } -} - -void func_80A4EA08(EnGs* this, GlobalContext* globalCtx) { - if (this->unk_19F == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - this->unk_1E8 = 0.3f; - this->unk_1EC = 0.0f; - this->unk_200 = 0; - this->unk_19F = 1; - } else if (this->unk_19F == 1) { - this->unk_1A0[0].z = (((this->unk_200 % 8) / 8.0f) * 360.0f) * (0x10000 / 360.0f); - this->unk_1A0[1].z = -this->unk_1A0[0].z; - if (func_80A4E754(this, globalCtx, &this->unk_1E8, &this->unk_1EC, &this->unk_200, 0.8f, 0.005f, 0.001f, 7, - 0) == 0.0f) { - this->unk_19C = 0; - this->actionFunc = func_80A4F734; - } - } -} - -void func_80A4EB3C(EnGs* this, GlobalContext* globalCtx) { - f32 ret; - - if (this->unk_19F == 0) { - this->unk_1E8 = this->unk_1B4[0].y - 1.0f; - this->unk_1EC = -0.8f; - this->unk_19F++; - } else if (this->unk_19F == 1) { - ret = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 1.0f, 0.4f, 0.001f); - this->unk_1B4[0].y = this->unk_1E8 + 1.0f; - if (ret == 0.0f) { - this->unk_200 = 0; - this->unk_19F++; - } - } else if (this->unk_19F == 2) { - this->unk_200++; - if (this->unk_200 >= 100) { - this->unk_19F++; - this->unk_1E8 = this->unk_1B4[0].y - 1.0f; - this->unk_1EC = 0.0f; - } - } else if (this->unk_19F == 3) { - ret = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 1.0f, 0.5f, 0.001f); - this->unk_1B4[0].y = this->unk_1E8 + 1.0f; - if (ret == 0.0f) { - this->unk_1E8 = 0.5f; - this->unk_1EC = 0.0f; - this->unk_200 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - this->unk_19F++; - } - } else if (this->unk_19F == 4) { - if (func_80A4E754(this, globalCtx, &this->unk_1E8, &this->unk_1EC, &this->unk_200, 1.0f, 0.03f, 0.001f, 5, 0) == - 0.0f) { - this->unk_19C = 0; - this->actionFunc = func_80A4F734; - } - } -} - -void func_80A4ED34(EnGs* this, GlobalContext* globalCtx) { - static Color_RGBA8 flashRed = { 255, 50, 50, 0 }; - static Color_RGBA8 flashBlue = { 50, 50, 255, 0 }; - static Color_RGBA8 baseWhite = { 255, 255, 255, 0 }; - static Vec3f dustAccel = { 0.0f, -0.3f, 0.0f }; - static Color_RGBA8 dustPrim = { 200, 200, 200, 128 }; - static Color_RGBA8 dustEnv = { 100, 100, 100, 0 }; - static Vec3f bomb2Velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f bomb2Accel = { 0.0f, 0.0f, 0.0f }; - u8 i; - Vec3f dustPos; - Vec3f dustVelocity; - Vec3f bomb2Pos; - - if (this->unk_19F == 0) { - this->unk_200 = 40; - this->unk_19F++; - } - - if (this->unk_19F == 1) { - if ((u32)this->unk_200-- <= 0) { - this->unk_200 = 80; - this->unk_19E |= 4; - this->unk_19F++; - } - } - - if (this->unk_19F == 2) { - this->unk_200--; - Color_RGBA8_Copy(&this->flashColor, &baseWhite); - if ((this->unk_200 < 80) && ((this->unk_200 % 20) < 8)) { - if (this->unk_200 < 20) { - Color_RGBA8_Copy(&this->flashColor, &flashRed); - if ((this->unk_200 % 20) == 7) { - Audio_PlaySoundGeneral(NA_SE_SY_WARNING_COUNT_E, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } else { - Color_RGBA8_Copy(&this->flashColor, &flashBlue); - if ((this->unk_200 % 20) == 7) { - Audio_PlaySoundGeneral(NA_SE_SY_WARNING_COUNT_N, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - } - if (this->unk_200 <= 0) { - this->unk_200 = 0; - this->unk_19E &= ~4; - this->unk_19F++; - } - } - - if (this->unk_19F == 3) { - for (i = 0; i < 3; i++) { - dustVelocity.x = Rand_CenteredFloat(15.0f); - dustVelocity.y = Rand_ZeroFloat(-1.0f); - dustVelocity.z = Rand_CenteredFloat(15.0f); - dustPos.x = this->actor.world.pos.x + (dustVelocity.x + dustVelocity.x); - dustPos.y = this->actor.world.pos.y + 7.0f; - dustPos.z = this->actor.world.pos.z + (dustVelocity.z + dustVelocity.z); - func_8002836C(globalCtx, &dustPos, &dustVelocity, &dustAccel, &dustPrim, &dustEnv, - (s16)Rand_ZeroFloat(50.0f) + 200, 40, 15); - } - - func_8002F974(&this->actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); - if (this->unk_200++ >= 40) { - this->unk_19E |= 0x10; - this->actor.flags |= ACTOR_FLAG_4; - this->actor.uncullZoneForward = 12000.0f; - - this->actor.gravity = 0.3f; - this->unk_19F++; - } - } - - if (this->unk_19F == 4) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 3); - if (this->actor.bgCheckFlags & 0x18) { - bomb2Pos.x = this->actor.world.pos.x; - bomb2Pos.y = this->actor.world.pos.y; - bomb2Pos.z = this->actor.world.pos.z; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - EffectSsBomb2_SpawnLayered(globalCtx, &bomb2Pos, &bomb2Velocity, &bomb2Accel, 100, 20); - this->unk_200 = 10; - this->unk_19E |= 8; - this->actionFunc = func_80A4F700; - } else { - func_8002F974(&this->actor, NA_SE_EV_STONE_LAUNCH - SFX_FLAG); - } - - Actor_MoveForward(&this->actor); - if (this->actor.yDistToPlayer < -12000.0f) { - Actor_Kill(&this->actor); - } - } -} - -void func_80A4F13C(EnGs* this, GlobalContext* globalCtx) { - f32 tmpf1; - f32 tmpf2; - f32 tmpf3; - s32 tmp; - s16 tmp2 = this->unk_1A0[0].y; - - if (this->unk_19F == 0) { - this->unk_1E8 = 0.0f; - this->unk_1EC = 90.0f; - this->unk_1F0 = 0.1f; - this->unk_1F4 = 2.0f; - this->unk_1F8 = 0; - this->unk_19F = 1; - } - if (this->unk_19F == 1) { - Math_SmoothStepToF(&this->unk_1F0, this->unk_1F4, 1.0f, 0.1f, 0.001f); - tmpf1 = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 1.0f, this->unk_1F0, 0.001f); - this->unk_1A0[0].y += (s32)(this->unk_1E8 * (0x10000 / 360.0f)); - if (tmpf1 == 0.0f) { - this->unk_200 = 0; - this->unk_19F = 2; - } - } - if (this->unk_19F == 2) { - this->unk_1A0[0].y += (s32)(this->unk_1E8 * (0x10000 / 360.0f)); - if (this->unk_200++ > 40) { - this->unk_1E8 = this->unk_1B4[0].y - 1.0f; - this->unk_1EC = 1.5f; - this->unk_1F0 = this->unk_1B4[1].y - 1.0f; - this->unk_1F4 = -0.3f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_GROW_UP); - this->unk_19F = 3; - } - } - if (this->unk_19F == 3) { - this->unk_1A0[0].y += 0x4000; - tmpf1 = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 0.8f, 0.2f, 0.001f); - Math_SmoothStepToF(&this->unk_1F0, this->unk_1F4, 0.8f, 0.2f, 0.001f); - this->unk_1B4[0].x = this->unk_1F0 + 1.0f; - this->unk_1B4[0].y = this->unk_1E8 + 1.0f; - if (tmpf1 == 0.0f) { - this->unk_1E8 = 2.0f * M_PI / 9.0000002; - this->unk_1EC = M_PI / 9.0000002; - this->unk_19F = 4; - } - } - if (this->unk_19F == 4) { - tmpf1 = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 0.8f, 16384.0f, 3640.0f); - this->unk_1A0[0].y += (s16)this->unk_1E8; - if (tmpf1 == 0.0f) { - - tmp = this->unk_1A0[0].y; - if (tmp > 0) { - tmp += 0xFFFF0000; - } - this->unk_1E8 = tmp; - - this->unk_1EC = 0.0f; - this->unk_19F = 5; - } - } - if (this->unk_19F == 5) { - tmp = this->unk_1A0[0].y; - if (tmp > 0) { - tmp += 0xFFFF0001; - } - this->unk_1E8 = tmp; - tmpf1 = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 0.8f, 3640.0f, 0.001f); - this->unk_1A0[0].y = this->unk_1E8; - if (tmpf1 == 0.0f) { - this->unk_1E8 = this->unk_1B4[0].y - 1.0f; - this->unk_1EC = 0; - this->unk_1A0[0].y = 0; - this->unk_200 = 0; - this->unk_1F0 = this->unk_1B4[0].x - 1.0f; - this->unk_1F4 = 0; - this->unk_1F8 = 0.5f; - this->unk_1FC = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - this->unk_19F = 6; - } - } - if (this->unk_19F == 6) { - tmpf1 = Math_SmoothStepToF(&this->unk_1E8, this->unk_1EC, 0.8f, 0.1f, 0.001f); - tmpf2 = Math_SmoothStepToF(&this->unk_1F0, this->unk_1F4, 0.8f, 0.1f, 0.001f); - tmpf3 = Math_SmoothStepToF(&this->unk_1F8, this->unk_1FC, 0.8f, 0.02f, 0.001f); - this->unk_1B4[0].x = this->unk_1F0 + 1.0f; - this->unk_1B4[0].y = this->unk_1E8 + 1.0f; - this->unk_1B4[0].x += sinf((((this->unk_200 % 10) * 0.1f) * 360.0f) * (M_PI / 180.0f)) * this->unk_1F8; - this->unk_1B4[0].y += sinf((((this->unk_200 % 10) * 0.1f) * 360.0f) * (M_PI / 180.0f)) * this->unk_1F8; - this->unk_200++; - if ((tmpf1 == 0.0f) && (tmpf2 == 0.0f) && (tmpf3 == 0.0f)) { - this->unk_19C = 0; - this->actionFunc = func_80A4F734; - } - } - if ((u16)this->unk_1A0[0].y < (u16)tmp2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_ROLLING); - } -} - -void func_80A4F700(EnGs* this, GlobalContext* globalCtx) { - if (this->unk_200-- <= 0) { - Actor_Kill(&this->actor); - } -} - -void func_80A4F734(EnGs* this, GlobalContext* globalCtx) { - if (!Flags_GetSwitch(globalCtx, (this->actor.params >> 8) & 0x3F)) { - func_80A4E470(this, globalCtx); - } -} - -void func_80A4F77C(EnGs* this) { - static Vec3s D_80A4FE34 = { 0, 0, 0 }; - static Vec3f D_80A4FE3C = { 1.0f, 1.0f, 1.0f }; - s32 i; - - for (i = 0; i < 3; i++) { - this->unk_1A0[i] = D_80A4FE34; - } - - for (i = 0; i < 2; i++) { - this->unk_1B4[i] = D_80A4FE3C; - } - - this->unk_19C = 3; -} - -void EnGs_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnGs* this = (EnGs*)thisx; - - Actor_SetFocus(&this->actor, 23.0f); - if (!(this->unk_19E & 0x10)) { - if (this->collider.base.acFlags & AC_HIT) { - this->unk_19F = 0; - this->collider.base.acFlags &= ~AC_HIT; - - switch (this->actor.colChkInfo.damageEffect) { - case 15: - this->unk_19E |= 1; - func_80A4F77C(this); - this->actionFunc = func_80A4E910; - break; - case 14: - this->unk_19E |= 1; - func_80A4F77C(this); - this->actionFunc = func_80A4EA08; - break; - case 13: - this->unk_19E |= 1; - func_80A4F77C(this); - this->actionFunc = func_80A4EB3C; - break; - case 12: - this->unk_19E |= 2; - func_80A4F77C(this); - this->actionFunc = func_80A4ED34; - break; - case 11: - this->unk_19E |= 1; - func_80A4F77C(this); - this->actionFunc = func_80A4F13C; - break; - } - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - this->actionFunc(this, globalCtx); - func_80A4E648(this, globalCtx); -} - -void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnGs* this = (EnGs*)thisx; - s32 tmp; - u32 frames; - - if (!(this->unk_19E & 8)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gs.c", 1046); - - frames = globalCtx->gameplayFrames; - func_80093D18(globalCtx->state.gfxCtx); - Matrix_Push(); - if (this->unk_19E & 1) { - Matrix_RotateY(this->unk_1A0[0].y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX(this->unk_1A0[0].x * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(this->unk_1A0[0].z * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_Scale(this->unk_1B4[0].x, this->unk_1B4[0].y, this->unk_1B4[0].z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1A0[1].y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX(this->unk_1A0[1].x * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(this->unk_1A0[1].z * (M_PI / 0x8000), MTXMODE_APPLY); - } - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_gs.c", 1064), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gGossipStoneMaterialDL); - - if (this->unk_19E & 4) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->flashColor.r, this->flashColor.g, this->flashColor.b, - this->flashColor.a); - } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - } - - gSPDisplayList(POLY_OPA_DISP++, gGossipStoneDL); - gSPDisplayList(POLY_OPA_DISP++, gGossipStoneSquishedDL); - - Matrix_Pop(); - if (this->unk_19E & 2) { - func_80093D84(globalCtx->state.gfxCtx); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(0.05f, -0.05f, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_gs.c", 1087), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment( - POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 0x14, 0x20, 0x80)); - gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 0, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gs.c", 1101); - } -} diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.cpp b/src/overlays/actors/ovl_En_Gs/z_en_gs.cpp new file mode 100644 index 000000000..707b78a59 --- /dev/null +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.cpp @@ -0,0 +1,628 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_GS_Z_EN_GS_C +#include "actor_common.h" +/* + * File: z_en_gs.c + * Overlay: ovl_En_Gs + * Description: Gossip Stone + */ + +#include "z_en_gs.h" +#include "objects/object_gs/object_gs.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800F7260.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_25) + +void EnGs_Init(Actor* thisx, GlobalContext* globalCtx); +void EnGs_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnGs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A4F734(EnGs* pthis, GlobalContext* globalCtx); +void func_80A4F700(EnGs* pthis, GlobalContext* globalCtx); + +void func_80A4F77C(EnGs* pthis); + +ActorInit En_Gs_InitVars = { + ACTOR_EN_GS, + ACTORCAT_PROP, + FLAGS, + OBJECT_GS, + sizeof(EnGs), + (ActorFunc)EnGs_Init, + (ActorFunc)EnGs_Destroy, + (ActorFunc)EnGs_Update, + (ActorFunc)EnGs_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 21, 48, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0xE), + /* Explosive */ DMG_ENTRY(0, 0xC), + /* Boomerang */ DMG_ENTRY(0, 0xE), + /* Normal arrow */ DMG_ENTRY(0, 0xE), + /* Hammer swing */ DMG_ENTRY(0, 0xD), + /* Hookshot */ DMG_ENTRY(0, 0xE), + /* Kokiri sword */ DMG_ENTRY(0, 0xF), + /* Master sword */ DMG_ENTRY(0, 0xF), + /* Giant's Knife */ DMG_ENTRY(0, 0xF), + /* Fire arrow */ DMG_ENTRY(0, 0xB), + /* Ice arrow */ DMG_ENTRY(0, 0xB), + /* Light arrow */ DMG_ENTRY(0, 0xB), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0xB), + /* Ice magic */ DMG_ENTRY(0, 0xB), + /* Light magic */ DMG_ENTRY(0, 0xB), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0x0), + /* Giant spin */ DMG_ENTRY(0, 0x0), + /* Master spin */ DMG_ENTRY(0, 0x0), + /* Kokiri jump */ DMG_ENTRY(0, 0x0), + /* Giant jump */ DMG_ENTRY(0, 0x0), + /* Master jump */ DMG_ENTRY(0, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGs* pthis = (EnGs*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + CollisionCheck_SetInfo2(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + + thisx->targetMode = 6; + pthis->unk_1D8 = thisx->world.pos; + pthis->actionFunc = func_80A4F734; + pthis->unk_1B4[0].x = 1.0f; + pthis->unk_1B4[0].y = 1.0f; + pthis->unk_1B4[0].z = 1.0f; + pthis->unk_1B4[1].x = 1.0f; + pthis->unk_1B4[1].y = 1.0f; + pthis->unk_1B4[1].z = 1.0f; +} + +void EnGs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 func_80A4E3EC(EnGs* pthis, GlobalContext* globalCtx) { + s32 ret = 2; + switch (Message_GetState(&globalCtx->msgCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(globalCtx)) { + switch (pthis->actor.textId) { + case 0x2054: + pthis->actor.textId = (pthis->actor.params & 0xFF) + 0x400; + ret = 1; + break; + default: + ret = 0; + break; + } + } + break; + } + return ret; +} + +void func_80A4E470(EnGs* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + bREG(15) = 0; + if (pthis->actor.xzDistToPlayer <= 100.0f) { + bREG(15) = 1; + if (pthis->unk_19D == 0) { + player->stateFlags2 |= 0x800000; + if (player->stateFlags2 & 0x1000000) { + func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); + pthis->unk_19D |= 1; + } + + } else if (pthis->unk_19D & 1) { + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + if ((globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_SARIAS) || + (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_EPONAS) || + (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_LULLABY) || + (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_SUNS) || + (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_TIME)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 40.0f, pthis->actor.world.pos.z, 0, 0, 0, FAIRY_HEAL_TIMED); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + } else if (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_STORMS) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 40.0f, pthis->actor.world.pos.z, 0, 0, 0, FAIRY_HEAL_BIG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + } + pthis->unk_19D = 0; + Flags_SetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F); + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { + player->stateFlags2 |= 0x800000; + } + } + } +} + +void func_80A4E648(EnGs* pthis, GlobalContext* globalCtx) { + s16 sp26; + s16 sp24; + + if (pthis->unk_19C == 1) { + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_19C = 2; + } else if (pthis->unk_19C == 2) { + pthis->unk_19C = func_80A4E3EC(pthis, globalCtx); + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_19C = 2; + } else { + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp26, &sp24); + if ((sp26 >= 0) && (sp26 <= SCREEN_WIDTH) && (sp24 >= 0) && (sp24 <= SCREEN_HEIGHT) && (pthis->unk_19C != 3)) { + if (func_8002F2CC(&pthis->actor, globalCtx, 40.0f) == 1) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { + pthis->actor.textId = 0x2054; + } else { + pthis->actor.textId = 0x2053; + } + } + } + } +} + +f32 func_80A4E754(EnGs* pthis, GlobalContext* globalCtx, f32* arg2, f32* arg3, u16* arg4, f32 arg5, f32 arg6, f32 arg7, + s32 arg8, s32 arg9) { + f32 sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); + + if (arg9 == 0) { + sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); + pthis->unk_1B4[0].x = 1.0f + (sinf((((*arg4 % arg8) * (1.0f / arg8)) * 360.0f) * (M_PI / 180.0f)) * *arg2); + pthis->unk_1B4[0].y = 1.0f - (sinf((((*arg4 % arg8) * (1.0f / arg8)) * 360.0f) * (M_PI / 180.0f)) * *arg2); + *arg4 += 1; + } + return sp2C; +} + +void func_80A4E910(EnGs* pthis, GlobalContext* globalCtx) { + if (pthis->unk_19F == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_ATTACK); + pthis->unk_200 = 0; + pthis->unk_19F = 1; + pthis->unk_1E8 = 0.5f; + pthis->unk_1EC = 0.0f; + } else if ((pthis->unk_19F == 1) && (func_80A4E754(pthis, globalCtx, &pthis->unk_1E8, &pthis->unk_1EC, &pthis->unk_200, + 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f)) { + if (!Gameplay_InCsMode(globalCtx)) { + Message_StartTextbox(globalCtx, 0x71B1, NULL); + } + pthis->unk_19C = 0; + pthis->actionFunc = func_80A4F734; + } +} + +void func_80A4EA08(EnGs* pthis, GlobalContext* globalCtx) { + if (pthis->unk_19F == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_ATTACK); + pthis->unk_1E8 = 0.3f; + pthis->unk_1EC = 0.0f; + pthis->unk_200 = 0; + pthis->unk_19F = 1; + } else if (pthis->unk_19F == 1) { + pthis->unk_1A0[0].z = (((pthis->unk_200 % 8) / 8.0f) * 360.0f) * (0x10000 / 360.0f); + pthis->unk_1A0[1].z = -pthis->unk_1A0[0].z; + if (func_80A4E754(pthis, globalCtx, &pthis->unk_1E8, &pthis->unk_1EC, &pthis->unk_200, 0.8f, 0.005f, 0.001f, 7, + 0) == 0.0f) { + pthis->unk_19C = 0; + pthis->actionFunc = func_80A4F734; + } + } +} + +void func_80A4EB3C(EnGs* pthis, GlobalContext* globalCtx) { + f32 ret; + + if (pthis->unk_19F == 0) { + pthis->unk_1E8 = pthis->unk_1B4[0].y - 1.0f; + pthis->unk_1EC = -0.8f; + pthis->unk_19F++; + } else if (pthis->unk_19F == 1) { + ret = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 1.0f, 0.4f, 0.001f); + pthis->unk_1B4[0].y = pthis->unk_1E8 + 1.0f; + if (ret == 0.0f) { + pthis->unk_200 = 0; + pthis->unk_19F++; + } + } else if (pthis->unk_19F == 2) { + pthis->unk_200++; + if (pthis->unk_200 >= 100) { + pthis->unk_19F++; + pthis->unk_1E8 = pthis->unk_1B4[0].y - 1.0f; + pthis->unk_1EC = 0.0f; + } + } else if (pthis->unk_19F == 3) { + ret = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 1.0f, 0.5f, 0.001f); + pthis->unk_1B4[0].y = pthis->unk_1E8 + 1.0f; + if (ret == 0.0f) { + pthis->unk_1E8 = 0.5f; + pthis->unk_1EC = 0.0f; + pthis->unk_200 = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_ATTACK); + pthis->unk_19F++; + } + } else if (pthis->unk_19F == 4) { + if (func_80A4E754(pthis, globalCtx, &pthis->unk_1E8, &pthis->unk_1EC, &pthis->unk_200, 1.0f, 0.03f, 0.001f, 5, 0) == + 0.0f) { + pthis->unk_19C = 0; + pthis->actionFunc = func_80A4F734; + } + } +} + +void func_80A4ED34(EnGs* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 flashRed = { 255, 50, 50, 0 }; + static Color_RGBA8 flashBlue = { 50, 50, 255, 0 }; + static Color_RGBA8 baseWhite = { 255, 255, 255, 0 }; + static Vec3f dustAccel = { 0.0f, -0.3f, 0.0f }; + static Color_RGBA8 dustPrim = { 200, 200, 200, 128 }; + static Color_RGBA8 dustEnv = { 100, 100, 100, 0 }; + static Vec3f bomb2Velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f bomb2Accel = { 0.0f, 0.0f, 0.0f }; + u8 i; + Vec3f dustPos; + Vec3f dustVelocity; + Vec3f bomb2Pos; + + if (pthis->unk_19F == 0) { + pthis->unk_200 = 40; + pthis->unk_19F++; + } + + if (pthis->unk_19F == 1) { + if ((u32)pthis->unk_200-- <= 0) { + pthis->unk_200 = 80; + pthis->unk_19E |= 4; + pthis->unk_19F++; + } + } + + if (pthis->unk_19F == 2) { + pthis->unk_200--; + Color_RGBA8_Copy(&pthis->flashColor, &baseWhite); + if ((pthis->unk_200 < 80) && ((pthis->unk_200 % 20) < 8)) { + if (pthis->unk_200 < 20) { + Color_RGBA8_Copy(&pthis->flashColor, &flashRed); + if ((pthis->unk_200 % 20) == 7) { + Audio_PlaySoundGeneral(NA_SE_SY_WARNING_COUNT_E, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } else { + Color_RGBA8_Copy(&pthis->flashColor, &flashBlue); + if ((pthis->unk_200 % 20) == 7) { + Audio_PlaySoundGeneral(NA_SE_SY_WARNING_COUNT_N, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + } + if (pthis->unk_200 <= 0) { + pthis->unk_200 = 0; + pthis->unk_19E &= ~4; + pthis->unk_19F++; + } + } + + if (pthis->unk_19F == 3) { + for (i = 0; i < 3; i++) { + dustVelocity.x = Rand_CenteredFloat(15.0f); + dustVelocity.y = Rand_ZeroFloat(-1.0f); + dustVelocity.z = Rand_CenteredFloat(15.0f); + dustPos.x = pthis->actor.world.pos.x + (dustVelocity.x + dustVelocity.x); + dustPos.y = pthis->actor.world.pos.y + 7.0f; + dustPos.z = pthis->actor.world.pos.z + (dustVelocity.z + dustVelocity.z); + func_8002836C(globalCtx, &dustPos, &dustVelocity, &dustAccel, &dustPrim, &dustEnv, + (s16)Rand_ZeroFloat(50.0f) + 200, 40, 15); + } + + func_8002F974(&pthis->actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + if (pthis->unk_200++ >= 40) { + pthis->unk_19E |= 0x10; + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->actor.uncullZoneForward = 12000.0f; + + pthis->actor.gravity = 0.3f; + pthis->unk_19F++; + } + } + + if (pthis->unk_19F == 4) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 3); + if (pthis->actor.bgCheckFlags & 0x18) { + bomb2Pos.x = pthis->actor.world.pos.x; + bomb2Pos.y = pthis->actor.world.pos.y; + bomb2Pos.z = pthis->actor.world.pos.z; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_BOMB_EXPLOSION); + EffectSsBomb2_SpawnLayered(globalCtx, &bomb2Pos, &bomb2Velocity, &bomb2Accel, 100, 20); + pthis->unk_200 = 10; + pthis->unk_19E |= 8; + pthis->actionFunc = func_80A4F700; + } else { + func_8002F974(&pthis->actor, NA_SE_EV_STONE_LAUNCH - SFX_FLAG); + } + + Actor_MoveForward(&pthis->actor); + if (pthis->actor.yDistToPlayer < -12000.0f) { + Actor_Kill(&pthis->actor); + } + } +} + +void func_80A4F13C(EnGs* pthis, GlobalContext* globalCtx) { + f32 tmpf1; + f32 tmpf2; + f32 tmpf3; + s32 tmp; + s16 tmp2 = pthis->unk_1A0[0].y; + + if (pthis->unk_19F == 0) { + pthis->unk_1E8 = 0.0f; + pthis->unk_1EC = 90.0f; + pthis->unk_1F0 = 0.1f; + pthis->unk_1F4 = 2.0f; + pthis->unk_1F8 = 0; + pthis->unk_19F = 1; + } + if (pthis->unk_19F == 1) { + Math_SmoothStepToF(&pthis->unk_1F0, pthis->unk_1F4, 1.0f, 0.1f, 0.001f); + tmpf1 = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 1.0f, pthis->unk_1F0, 0.001f); + pthis->unk_1A0[0].y += (s32)(pthis->unk_1E8 * (0x10000 / 360.0f)); + if (tmpf1 == 0.0f) { + pthis->unk_200 = 0; + pthis->unk_19F = 2; + } + } + if (pthis->unk_19F == 2) { + pthis->unk_1A0[0].y += (s32)(pthis->unk_1E8 * (0x10000 / 360.0f)); + if (pthis->unk_200++ > 40) { + pthis->unk_1E8 = pthis->unk_1B4[0].y - 1.0f; + pthis->unk_1EC = 1.5f; + pthis->unk_1F0 = pthis->unk_1B4[1].y - 1.0f; + pthis->unk_1F4 = -0.3f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_STONE_GROW_UP); + pthis->unk_19F = 3; + } + } + if (pthis->unk_19F == 3) { + pthis->unk_1A0[0].y += 0x4000; + tmpf1 = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 0.8f, 0.2f, 0.001f); + Math_SmoothStepToF(&pthis->unk_1F0, pthis->unk_1F4, 0.8f, 0.2f, 0.001f); + pthis->unk_1B4[0].x = pthis->unk_1F0 + 1.0f; + pthis->unk_1B4[0].y = pthis->unk_1E8 + 1.0f; + if (tmpf1 == 0.0f) { + pthis->unk_1E8 = 2.0f * M_PI / 9.0000002; + pthis->unk_1EC = M_PI / 9.0000002; + pthis->unk_19F = 4; + } + } + if (pthis->unk_19F == 4) { + tmpf1 = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 0.8f, 16384.0f, 3640.0f); + pthis->unk_1A0[0].y += (s16)pthis->unk_1E8; + if (tmpf1 == 0.0f) { + + tmp = pthis->unk_1A0[0].y; + if (tmp > 0) { + tmp += 0xFFFF0000; + } + pthis->unk_1E8 = tmp; + + pthis->unk_1EC = 0.0f; + pthis->unk_19F = 5; + } + } + if (pthis->unk_19F == 5) { + tmp = pthis->unk_1A0[0].y; + if (tmp > 0) { + tmp += 0xFFFF0001; + } + pthis->unk_1E8 = tmp; + tmpf1 = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 0.8f, 3640.0f, 0.001f); + pthis->unk_1A0[0].y = pthis->unk_1E8; + if (tmpf1 == 0.0f) { + pthis->unk_1E8 = pthis->unk_1B4[0].y - 1.0f; + pthis->unk_1EC = 0; + pthis->unk_1A0[0].y = 0; + pthis->unk_200 = 0; + pthis->unk_1F0 = pthis->unk_1B4[0].x - 1.0f; + pthis->unk_1F4 = 0; + pthis->unk_1F8 = 0.5f; + pthis->unk_1FC = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_ATTACK); + pthis->unk_19F = 6; + } + } + if (pthis->unk_19F == 6) { + tmpf1 = Math_SmoothStepToF(&pthis->unk_1E8, pthis->unk_1EC, 0.8f, 0.1f, 0.001f); + tmpf2 = Math_SmoothStepToF(&pthis->unk_1F0, pthis->unk_1F4, 0.8f, 0.1f, 0.001f); + tmpf3 = Math_SmoothStepToF(&pthis->unk_1F8, pthis->unk_1FC, 0.8f, 0.02f, 0.001f); + pthis->unk_1B4[0].x = pthis->unk_1F0 + 1.0f; + pthis->unk_1B4[0].y = pthis->unk_1E8 + 1.0f; + pthis->unk_1B4[0].x += sinf((((pthis->unk_200 % 10) * 0.1f) * 360.0f) * (M_PI / 180.0f)) * pthis->unk_1F8; + pthis->unk_1B4[0].y += sinf((((pthis->unk_200 % 10) * 0.1f) * 360.0f) * (M_PI / 180.0f)) * pthis->unk_1F8; + pthis->unk_200++; + if ((tmpf1 == 0.0f) && (tmpf2 == 0.0f) && (tmpf3 == 0.0f)) { + pthis->unk_19C = 0; + pthis->actionFunc = func_80A4F734; + } + } + if ((u16)pthis->unk_1A0[0].y < (u16)tmp2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_STONE_ROLLING); + } +} + +void func_80A4F700(EnGs* pthis, GlobalContext* globalCtx) { + if (pthis->unk_200-- <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_80A4F734(EnGs* pthis, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { + func_80A4E470(pthis, globalCtx); + } +} + +void func_80A4F77C(EnGs* pthis) { + static Vec3s D_80A4FE34 = { 0, 0, 0 }; + static Vec3f D_80A4FE3C = { 1.0f, 1.0f, 1.0f }; + s32 i; + + for (i = 0; i < 3; i++) { + pthis->unk_1A0[i] = D_80A4FE34; + } + + for (i = 0; i < 2; i++) { + pthis->unk_1B4[i] = D_80A4FE3C; + } + + pthis->unk_19C = 3; +} + +void EnGs_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGs* pthis = (EnGs*)thisx; + + Actor_SetFocus(&pthis->actor, 23.0f); + if (!(pthis->unk_19E & 0x10)) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->unk_19F = 0; + pthis->collider.base.acFlags &= ~AC_HIT; + + switch (pthis->actor.colChkInfo.damageEffect) { + case 15: + pthis->unk_19E |= 1; + func_80A4F77C(pthis); + pthis->actionFunc = func_80A4E910; + break; + case 14: + pthis->unk_19E |= 1; + func_80A4F77C(pthis); + pthis->actionFunc = func_80A4EA08; + break; + case 13: + pthis->unk_19E |= 1; + func_80A4F77C(pthis); + pthis->actionFunc = func_80A4EB3C; + break; + case 12: + pthis->unk_19E |= 2; + func_80A4F77C(pthis); + pthis->actionFunc = func_80A4ED34; + break; + case 11: + pthis->unk_19E |= 1; + func_80A4F77C(pthis); + pthis->actionFunc = func_80A4F13C; + break; + } + } + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + pthis->actionFunc(pthis, globalCtx); + func_80A4E648(pthis, globalCtx); +} + +void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGs* pthis = (EnGs*)thisx; + s32 tmp; + u32 frames; + + if (!(pthis->unk_19E & 8)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_gs.c", 1046); + + frames = globalCtx->gameplayFrames; + func_80093D18(globalCtx->state.gfxCtx); + Matrix_Push(); + if (pthis->unk_19E & 1) { + Matrix_RotateY(pthis->unk_1A0[0].y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->unk_1A0[0].x * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_1A0[0].z * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Scale(pthis->unk_1B4[0].x, pthis->unk_1B4[0].y, pthis->unk_1B4[0].z, MTXMODE_APPLY); + Matrix_RotateY(pthis->unk_1A0[1].y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->unk_1A0[1].x * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->unk_1A0[1].z * (M_PI / 0x8000), MTXMODE_APPLY); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_gs.c", 1064), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneMaterialDL); + + if (pthis->unk_19E & 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->flashColor.r, pthis->flashColor.g, pthis->flashColor.b, + pthis->flashColor.a); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + } + + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneDL); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneSquishedDL); + + Matrix_Pop(); + if (pthis->unk_19E & 2) { + func_80093D84(globalCtx->state.gfxCtx); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(0.05f, -0.05f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_gs.c", 1087), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 0x14, 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_gs.c", 1101); + } +} diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.c b/src/overlays/actors/ovl_En_Guest/z_en_guest.cpp similarity index 54% rename from src/overlays/actors/ovl_En_Guest/z_en_guest.c rename to src/overlays/actors/ovl_En_Guest/z_en_guest.cpp index 797f0d91e..da693bcee 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.c +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.cpp @@ -28,11 +28,11 @@ void EnGuest_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGuest_Update(Actor* thisx, GlobalContext* globalCtx); void EnGuest_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A50518(EnGuest* this, GlobalContext* globalCtx); -void func_80A5057C(EnGuest* this, GlobalContext* globalCtx); +void func_80A50518(EnGuest* pthis, GlobalContext* globalCtx); +void func_80A5057C(EnGuest* pthis, GlobalContext* globalCtx); void func_80A505CC(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Guest_InitVars = { +ActorInit En_Guest_InitVars = { ACTOR_EN_GUEST, ACTORCAT_NPC, FLAGS, @@ -62,13 +62,13 @@ static InitChainEntry sInitChain[] = { }; void EnGuest_Init(Actor* thisx, GlobalContext* globalCtx) { - EnGuest* this = (EnGuest*)thisx; + EnGuest* pthis = (EnGuest*)thisx; if (gSaveContext.infTable[7] & 0x40) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - this->osAnimeBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); - if (this->osAnimeBankIndex < 0) { + pthis->osAnimeBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); + if (pthis->osAnimeBankIndex < 0) { osSyncPrintf(VT_COL(RED, WHITE)); // "No such bank!!" osSyncPrintf("%s[%d] : バンクが無いよ!!\n", "../z_en_guest.c", 129); @@ -79,112 +79,112 @@ void EnGuest_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnGuest_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnGuest* this = (EnGuest*)thisx; + EnGuest* pthis = (EnGuest*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void EnGuest_Update(Actor* thisx, GlobalContext* globalCtx) { - EnGuest* this = (EnGuest*)thisx; + EnGuest* pthis = (EnGuest*)thisx; s32 pad; - if (Object_IsLoaded(&globalCtx->objectCtx, this->osAnimeBankIndex) != 0) { - this->actor.flags &= ~ACTOR_FLAG_4; - Actor_ProcessInitChain(&this->actor, sInitChain); + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->osAnimeBankIndex) != 0) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + Actor_ProcessInitChain(&pthis->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_0000F0, NULL, this->jointTable, - this->morphTable, 16); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->osAnimeBankIndex].vromStart); - Animation_Change(&this->skelAnime, &gObjOsAnim_42AC, 1.0f, 0.0f, Animation_GetLastFrame(&gObjOsAnim_42AC), + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_boj_Skel_0000F0, NULL, pthis->jointTable, + pthis->morphTable, 16); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->osAnimeBankIndex].vromStart.get()); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_42AC, 1.0f, 0.0f, Animation_GetLastFrame(&gObjOsAnim_42AC), ANIMMODE_LOOP, 0.0f); - this->actor.draw = EnGuest_Draw; - this->actor.update = func_80A505CC; + pthis->actor.draw = EnGuest_Draw; + pthis->actor.update = func_80A505CC; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); - Actor_SetFocus(&this->actor, 60.0f); + Actor_SetFocus(&pthis->actor, 60.0f); - this->unk_30E = 0; - this->unk_30D = 0; - this->unk_2CA = 0; - this->actor.textId = 0x700D; - this->actionFunc = func_80A50518; + pthis->unk_30E = 0; + pthis->unk_30D = 0; + pthis->unk_2CA = 0; + pthis->actor.textId = 0x700D; + pthis->actionFunc = func_80A50518; } } -void func_80A5046C(EnGuest* this) { - if (this->unk_30D == 0) { - if (this->unk_2CA != 0) { - this->unk_2CA--; +void func_80A5046C(EnGuest* pthis) { + if (pthis->unk_30D == 0) { + if (pthis->unk_2CA != 0) { + pthis->unk_2CA--; } else { - this->unk_30D = 1; + pthis->unk_30D = 1; } } else { - if (this->unk_2CA != 0) { - this->unk_2CA--; + if (pthis->unk_2CA != 0) { + pthis->unk_2CA--; } else { - this->unk_30E += 1; - if (this->unk_30E >= 3) { - this->unk_30E = 0; - this->unk_30D = 0; - this->unk_2CA = (s32)Rand_ZeroFloat(60.0f) + 20; + pthis->unk_30E += 1; + if (pthis->unk_30E >= 3) { + pthis->unk_30E = 0; + pthis->unk_30D = 0; + pthis->unk_2CA = (s32)Rand_ZeroFloat(60.0f) + 20; } else { - this->unk_2CA = 1; + pthis->unk_2CA = 1; } } } } -void func_80A50518(EnGuest* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_80A5057C; - } else if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); +void func_80A50518(EnGuest* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80A5057C; + } else if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); } } -void func_80A5057C(EnGuest* this, GlobalContext* globalCtx) { +void func_80A5057C(EnGuest* pthis, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = func_80A50518; + pthis->actionFunc = func_80A50518; } } void func_80A505CC(Actor* thisx, GlobalContext* globalCtx) { - EnGuest* this = (EnGuest*)thisx; + EnGuest* pthis = (EnGuest*)thisx; s32 pad; Player* player; player = GET_PLAYER(globalCtx); - this->unk_2C8++; + pthis->unk_2C8++; - func_80A5046C(this); - this->actionFunc(this, globalCtx); + func_80A5046C(pthis); + pthis->actionFunc(pthis, globalCtx); - this->unk_2A0.unk_18 = player->actor.world.pos; + pthis->unk_2A0.unk_18 = player->actor.world.pos; if (LINK_IS_ADULT) { - this->unk_2A0.unk_14 = 10.0f; + pthis->unk_2A0.unk_14 = 10.0f; } else { - this->unk_2A0.unk_14 = 20.0f; + pthis->unk_2A0.unk_14 = 20.0f; } - func_80034A14(&this->actor, &this->unk_2A0, 6, 2); + func_80034A14(&pthis->actor, &pthis->unk_2A0, 6, 2); - func_80034F54(globalCtx, this->unk_2CC, this->unk_2EC, 16); + func_80034F54(globalCtx, pthis->unk_2CC, pthis->unk_2EC, 16); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->osAnimeBankIndex].vromStart); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->osAnimeBankIndex].vromStart.get()); - SkelAnime_Update(&this->skelAnime); - Actor_SetFocus(&this->actor, 60.0f); + SkelAnime_Update(&pthis->skelAnime); + Actor_SetFocus(&pthis->actor, 60.0f); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } Gfx* func_80A50708(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { Gfx* dlist; - dlist = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + dlist = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); gDPSetEnvColor(dlist, r, g, b, a); gSPEndDisplayList(dlist + 1); @@ -193,7 +193,7 @@ Gfx* func_80A50708(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { s32 EnGuest_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnGuest* this = (EnGuest*)thisx; + EnGuest* pthis = (EnGuest*)thisx; Vec3s sp3C; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_guest.c", 352); @@ -201,21 +201,21 @@ s32 EnGuest_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (limbIndex == 15) { *dList = object_boj_DL_0059B0; Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - sp3C = this->unk_2A0.unk_08; + sp3C = pthis->unk_2A0.unk_08; Matrix_RotateX((sp3C.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((sp3C.x / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - sp3C = this->unk_2A0.unk_0E; + sp3C = pthis->unk_2A0.unk_0E; Matrix_RotateX((-sp3C.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((sp3C.x / 32768.0f) * M_PI, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 12) { - rot->y += Math_SinS(this->unk_2CC[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->unk_2EC[limbIndex]) * 200.0f; + rot->y += Math_SinS(pthis->unk_2CC[limbIndex]) * 200.0f; + rot->z += Math_CosS(pthis->unk_2EC[limbIndex]) * 200.0f; } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_guest.c", 388); @@ -229,7 +229,7 @@ void EnGuest_Draw(Actor* thisx, GlobalContext* globalCtx) { object_boj_Tex_0006FC, object_boj_Tex_0007FC, }; - EnGuest* this = (EnGuest*)thisx; + EnGuest* pthis = (EnGuest*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_guest.c", 404); @@ -238,10 +238,10 @@ void EnGuest_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, func_80A50708(globalCtx->state.gfxCtx, 0xFF, 0xFF, 0xFF, 0xFF)); gSPSegment(POLY_OPA_DISP++, 0x09, func_80A50708(globalCtx->state.gfxCtx, 0xA0, 0x3C, 0xDC, 0xFF)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(D_80A50BA4[this->unk_30E])); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(D_80A50BA4[pthis->unk_30E])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnGuest_OverrideLimbDraw, NULL, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnGuest_OverrideLimbDraw, NULL, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_guest.c", 421); } diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.h b/src/overlays/actors/ovl_En_Guest/z_en_guest.h index ecf95cb18..9fa00ea0f 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.h +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.h @@ -6,7 +6,7 @@ struct EnGuest; -typedef void (*EnGuestActionFunc)(struct EnGuest* this, GlobalContext* globalCtx); +typedef void (*EnGuestActionFunc)(struct EnGuest* pthis, GlobalContext* globalCtx); typedef struct EnGuest { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.cpp similarity index 62% rename from src/overlays/actors/ovl_En_Hata/z_en_hata.c rename to src/overlays/actors/ovl_En_Hata/z_en_hata.cpp index 8644faf19..aa90537ad 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.cpp @@ -24,7 +24,7 @@ void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHata_Update(Actor* thisx, GlobalContext* globalCtx); void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Hata_InitVars = { +ActorInit En_Hata_InitVars = { ACTOR_EN_HATA, ACTORCAT_PROP, FLAGS, @@ -60,44 +60,44 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHata* this = (EnHata*)thisx; + EnHata* pthis = (EnHata*)thisx; s32 pad; CollisionHeader* colHeader = NULL; f32 frameCount = Animation_GetLastFrame(&gFlagpoleFlapAnim); - Actor_SetScale(&this->dyna.actor, 1.0f / 75.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gFlagpoleSkel, &gFlagpoleFlapAnim, NULL, NULL, 0); - Animation_Change(&this->skelAnime, &gFlagpoleFlapAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - DynaPolyActor_Init(&this->dyna, DPM_UNK); + Actor_SetScale(&pthis->dyna.actor, 1.0f / 75.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gFlagpoleSkel, &gFlagpoleFlapAnim, NULL, NULL, 0); + Animation_Change(&pthis->skelAnime, &gFlagpoleFlapAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&gFlagpoleCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->dyna.actor.uncullZoneScale = 500.0f; - this->dyna.actor.uncullZoneDownward = 550.0f; - this->dyna.actor.uncullZoneForward = 2200.0f; - this->invScale = 6; - this->maxStep = 1000; - this->minStep = 1; - this->unk_278 = Rand_ZeroOne() * 0xFFFF; + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->dyna.actor.uncullZoneScale = 500.0f; + pthis->dyna.actor.uncullZoneDownward = 550.0f; + pthis->dyna.actor.uncullZoneForward = 2200.0f; + pthis->invScale = 6; + pthis->maxStep = 1000; + pthis->minStep = 1; + pthis->unk_278 = Rand_ZeroOne() * 0xFFFF; } void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHata* this = (EnHata*)thisx; + EnHata* pthis = (EnHata*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnHata* this = (EnHata*)thisx; + EnHata* pthis = (EnHata*)thisx; s32 pitch; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f windVec; f32 sin; - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); // Rotate to hang down by default - this->limbs[FLAGPOLE_LIMB_FLAG_1_BASE].y = this->limbs[FLAGPOLE_LIMB_FLAG_2_BASE].y = -0x4000; + pthis->limbs[FLAGPOLE_LIMB_FLAG_1_BASE].y = pthis->limbs[FLAGPOLE_LIMB_FLAG_2_BASE].y = -0x4000; windVec.x = globalCtx->envCtx.windDirection.x; windVec.y = globalCtx->envCtx.windDirection.y; windVec.z = globalCtx->envCtx.windDirection.z; @@ -111,30 +111,30 @@ void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { } if (Rand_ZeroOne() > 0.5f) { - this->unk_278 += 6000; + pthis->unk_278 += 6000; } else { - this->unk_278 += 3000; + pthis->unk_278 += 3000; } // Mimic varying wind gusts - sin = Math_SinS(this->unk_278) * 80.0f; + sin = Math_SinS(pthis->unk_278) * 80.0f; pitch = -Math_Vec3f_Pitch(&zeroVec, &windVec); pitch = ((s32)((15000 - pitch) * (1.0f - (globalCtx->envCtx.windSpeed / (255.0f - sin))))) + pitch; - Math_SmoothStepToS(&this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y, pitch, this->invScale, this->maxStep, - this->minStep); - this->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].y = this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y; - this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z = -Math_Vec3f_Yaw(&zeroVec, &windVec); - this->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].z = this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z; - this->skelAnime.playSpeed = (Rand_ZeroFloat(1.25f) + 2.75f) * (globalCtx->envCtx.windSpeed / 255.0f); + Math_SmoothStepToS(&pthis->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y, pitch, pthis->invScale, pthis->maxStep, + pthis->minStep); + pthis->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].y = pthis->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y; + pthis->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z = -Math_Vec3f_Yaw(&zeroVec, &windVec); + pthis->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].z = pthis->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z; + pthis->skelAnime.playSpeed = (Rand_ZeroFloat(1.25f) + 2.75f) * (globalCtx->envCtx.windSpeed / 255.0f); } s32 EnHata_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnHata* this = (EnHata*)thisx; + EnHata* pthis = (EnHata*)thisx; Vec3s* limbs; if (limbIndex == FLAGPOLE_LIMB_FLAG_2_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_1_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE) { - limbs = this->limbs; + limbs = pthis->limbs; rot->x += limbs[limbIndex].x; rot->y += limbs[limbIndex].y; rot->z += limbs[limbIndex].z; @@ -146,10 +146,10 @@ void EnHata_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHata* this = (EnHata*)thisx; + EnHata* pthis = (EnHata*)thisx; func_800943C8(globalCtx->state.gfxCtx); Matrix_Scale(1.0f, 1.1f, 1.0f, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHata_OverrideLimbDraw, - EnHata_PostLimbDraw, this); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnHata_OverrideLimbDraw, + EnHata_PostLimbDraw, pthis); } diff --git a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c deleted file mode 100644 index 693488453..000000000 --- a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c +++ /dev/null @@ -1,506 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI1_Z_EN_HEISHI1_C -#include "actor_common.h" -/* - * File: z_en_heishi1.c - * Overlay: ovl_En_Heishi1 - * Description: Courtyard Guards - */ - -#include "z_en_heishi1.h" -#include "objects/object_sd/object_sd.h" -#include "vt.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi1_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnHeishi1_SetupWait(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_SetupWalk(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_SetupMoveToLink(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_SetupTurnTowardLink(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_SetupKick(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_SetupWaitNight(EnHeishi1* this, GlobalContext* globalCtx); - -void EnHeishi1_Wait(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_Walk(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_MoveToLink(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_TurnTowardLink(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_Kick(EnHeishi1* this, GlobalContext* globalCtx); -void EnHeishi1_WaitNight(EnHeishi1* this, GlobalContext* globalCtx); - -static s32 sPlayerIsCaught = false; - -const ActorInit En_Heishi1_InitVars = { - 0, - ACTORCAT_NPC, - FLAGS, - OBJECT_SD, - sizeof(EnHeishi1), - (ActorFunc)EnHeishi1_Init, - (ActorFunc)EnHeishi1_Destroy, - (ActorFunc)EnHeishi1_Update, - (ActorFunc)EnHeishi1_Draw, -}; - -static f32 sAnimParamsInit[][8] = { - { 1.0f, -10.0f, 3.0f, 0.5f, 1000.0f, 200.0f, 0.3f, 1000.0f }, - { 3.0f, -3.0f, 6.0f, 0.8f, 2000.0f, 400.0f, 0.5f, 2000.0f }, - { 1.0f, -10.0f, 3.0f, 0.5f, 1000.0f, 200.0f, 0.3f, 1000.0f }, - { 3.0f, -3.0f, 6.0f, 0.8f, 2000.0f, 400.0f, 0.5f, 2000.0f }, -}; - -static s16 sBaseHeadTimers[] = { 20, 10, 20, 10, 13, 0 }; - -static Vec3f sRupeePositions[] = { - { 0.0f, 0.0f, 90.0f }, { -55.0f, 0.0f, 90.0f }, { -55.0f, 0.0f, 30.0f }, { -55.0f, 0.0f, -30.0f }, - { 0.0f, 0.0f, -30.0f }, { 55.0f, 0.0f, -30.0f }, { 55.0f, 0.0f, 30.0f }, { 55.0f, 0.0f, 90.0f }, -}; - -static s32 sCamDataIdxs[] = { - 7, 7, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 4, 4, 5, 6, -}; - -static s16 sWaypoints[] = { 0, 4, 1, 5, 2, 6, 3, 7 }; - -void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHeishi1* this = (EnHeishi1*)thisx; - Vec3f rupeePos; - s32 i; - - Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, this->jointTable, this->morphTable, - 17); - - this->type = (this->actor.params >> 8) & 0xFF; - this->path = this->actor.params & 0xFF; - - for (i = 0; i < ARRAY_COUNT(sAnimParamsInit[0]); i++) { - this->animParams[i] = sAnimParamsInit[this->type][i]; - } - - // "type" - osSyncPrintf(VT_FGCOL(GREEN) " 種類☆☆☆☆☆☆☆☆☆☆☆☆☆ %d\n" VT_RST, this->type); - // "path data" - osSyncPrintf(VT_FGCOL(YELLOW) " れえるでぇたぁ☆☆☆☆☆☆☆☆ %d\n" VT_RST, this->path); - osSyncPrintf(VT_FGCOL(PURPLE) " anime_frame_speed ☆☆☆☆☆☆ %f\n" VT_RST, this->animSpeed); - // "interpolation frame" - osSyncPrintf(VT_FGCOL(PURPLE) " 補間フレーム☆☆☆☆☆☆☆☆☆ %f\n" VT_RST, this->transitionRate); - // "targeted movement speed value between points" - osSyncPrintf(VT_FGCOL(PURPLE) " point間の移動スピード目標値 ☆ %f\n" VT_RST, this->moveSpeedTarget); - // "maximum movement speed value between points" - osSyncPrintf(VT_FGCOL(PURPLE) " point間の移動スピード最大 ☆☆ %f\n" VT_RST, this->moveSpeedMax); - // "(body) targeted turning angle speed value" - osSyncPrintf(VT_FGCOL(PURPLE) " (体)反転アングルスピード目標値 %f\n" VT_RST, this->bodyTurnSpeedTarget); - // "(body) maximum turning angle speed" - osSyncPrintf(VT_FGCOL(PURPLE) " (体)反転アングルスピード最大☆ %f\n" VT_RST, this->bodyTurnSpeedMax); - // "(head) targeted turning angle speed value" - osSyncPrintf(VT_FGCOL(PURPLE) " (頭)反転アングルスピード加算値 %f\n" VT_RST, this->headTurnSpeedScale); - // "(head) maximum turning angle speed" - osSyncPrintf(VT_FGCOL(PURPLE) " (頭)反転アングルスピード最大☆ %f\n" VT_RST, this->headTurnSpeedMax); - osSyncPrintf(VT_FGCOL(GREEN) " 今時間 %d\n" VT_RST, ((void)0, gSaveContext.dayTime)); // "current time" - osSyncPrintf(VT_FGCOL(YELLOW) " チェック時間 %d\n" VT_RST, 0xBAAA); // "check time" - osSyncPrintf("\n\n"); - - if (this->path == 3) { - for (i = 0; i < ARRAY_COUNT(sRupeePositions); i++) { - rupeePos = sRupeePositions[i]; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_RUPPY, rupeePos.x, rupeePos.y, - rupeePos.z, 0, 0, 0, 3); - } - } - - if (this->type != 5) { - if (((gSaveContext.dayTime < 0xB888) || IS_DAY) && !(gSaveContext.eventChkInf[8] & 1)) { - this->actionFunc = EnHeishi1_SetupWalk; - } else { - Actor_Kill(&this->actor); - } - } else { - if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || (gSaveContext.eventChkInf[8] & 1)) { - this->actionFunc = EnHeishi1_SetupWaitNight; - } else { - Actor_Kill(&this->actor); - } - } -} - -void EnHeishi1_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnHeishi1_SetupWalk(EnHeishi1* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiWalkAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiWalkAnim, this->animSpeed, 0.0f, (s16)frameCount, ANIMMODE_LOOP, - this->transitionRate); - this->bodyTurnSpeed = 0.0f; - this->moveSpeed = 0.0f; - this->headDirection = Rand_ZeroFloat(1.99f); - this->actionFunc = EnHeishi1_Walk; -} - -void EnHeishi1_Walk(EnHeishi1* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* pointPos; - f32 pathDiffX; - f32 pathDiffZ; - s16 randOffset; - - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KNIGHT_WALK); - } - - if (!sPlayerIsCaught) { - path = &globalCtx->setupPathList[this->path]; - pointPos = SEGMENTED_TO_VIRTUAL(path->points); - pointPos += this->waypoint; - - Math_ApproachF(&this->actor.world.pos.x, pointPos->x, 1.0f, this->moveSpeed); - Math_ApproachF(&this->actor.world.pos.z, pointPos->z, 1.0f, this->moveSpeed); - - Math_ApproachF(&this->moveSpeed, this->moveSpeedTarget, 1.0f, this->moveSpeedMax); - - pathDiffX = pointPos->x - this->actor.world.pos.x; - pathDiffZ = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 3, - this->bodyTurnSpeed, 0); - - Math_ApproachF(&this->bodyTurnSpeed, this->bodyTurnSpeedTarget, 1.0f, this->bodyTurnSpeedMax); - - if (this->headTimer == 0) { - this->headDirection++; - this->headAngleTarget = 0x2000; - // if headDirection is odd, face 45 degrees left - if ((this->headDirection & 1) != 0) { - this->headAngleTarget *= -1; - } - randOffset = Rand_ZeroFloat(30.0f); - this->headTimer = sBaseHeadTimers[this->type] + randOffset; - } - - Math_ApproachF(&this->headAngle, this->headAngleTarget, this->headTurnSpeedScale, this->headTurnSpeedMax); - - if ((this->path == BREG(1)) && (BREG(0) != 0)) { - osSyncPrintf(VT_FGCOL(RED) " 種類 %d\n" VT_RST, this->path); - osSyncPrintf(VT_FGCOL(RED) " ぱす %d\n" VT_RST, this->waypoint); - osSyncPrintf(VT_FGCOL(RED) " 反転 %d\n" VT_RST, this->bodyTurnSpeed); - osSyncPrintf(VT_FGCOL(RED) " 時間 %d\n" VT_RST, this->waypointTimer); - osSyncPrintf(VT_FGCOL(RED) " 点座 %d\n" VT_RST, path->count); - osSyncPrintf("\n\n"); - } - - // when 20 units away from a middle waypoint, decide whether or not to skip it - if ((fabsf(pathDiffX) < 20.0f) && (fabsf(pathDiffZ) < 20.0f)) { - if (this->waypointTimer == 0) { - if (this->type >= 2) { - if ((this->waypoint >= 4) && (Rand_ZeroFloat(1.99f) > 1.0f)) { - if (this->waypoint == 7) { - this->waypoint = 0; - } - if (this->waypoint >= 4) { - this->waypoint -= 3; - } - this->waypointTimer = 5; - return; - } - } - this->actionFunc = EnHeishi1_SetupWait; - } - } - } -} - -void EnHeishi1_SetupMoveToLink(EnHeishi1* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiWalkAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiWalkAnim, 3.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -3.0f); - this->bodyTurnSpeed = 0.0f; - this->moveSpeed = 0.0f; - Message_StartTextbox(globalCtx, 0x702D, &this->actor); - Interface_SetDoAction(globalCtx, DO_ACTION_STOP); - this->actionFunc = EnHeishi1_MoveToLink; -} - -void EnHeishi1_MoveToLink(EnHeishi1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.world.pos.x, player->actor.world.pos.x, 1.0f, this->moveSpeed); - Math_ApproachF(&this->actor.world.pos.z, player->actor.world.pos.z, 1.0f, this->moveSpeed); - Math_ApproachF(&this->moveSpeed, 6.0f, 1.0f, 0.4f); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, this->bodyTurnSpeed, 0); - Math_ApproachF(&this->bodyTurnSpeed, 3000.0f, 1.0f, 300.0f); - Math_ApproachZeroF(&this->headAngle, 0.5f, 2000.0f); - - if (this->actor.xzDistToPlayer < 70.0f) { - this->actionFunc = EnHeishi1_SetupTurnTowardLink; - } -} - -void EnHeishi1_SetupWait(EnHeishi1* this, GlobalContext* globalCtx) { - s16 rand; - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, this->animSpeed, 0.0f, (s16)frameCount, ANIMMODE_LOOP, - this->transitionRate); - this->headBehaviorDecided = false; - this->headDirection = Rand_ZeroFloat(1.99f); - rand = Rand_ZeroFloat(50.0f); - this->waitTimer = rand + 50; - this->actionFunc = EnHeishi1_Wait; -} - -void EnHeishi1_Wait(EnHeishi1* this, GlobalContext* globalCtx) { - s16 randOffset; - s32 i; - - SkelAnime_Update(&this->skelAnime); - if (!sPlayerIsCaught) { - switch (this->headBehaviorDecided) { - case false: - this->headDirection++; - // if headDirection is odd, face 52 degrees left - this->headAngleTarget = (this->headDirection & 1) ? 0x2500 : -0x2500; - randOffset = Rand_ZeroFloat(30.0f); - this->headTimer = sBaseHeadTimers[this->type] + randOffset; - this->headBehaviorDecided = true; - break; - case true: - if (this->headTimer == 0) { - if (this->waitTimer == 0) { - if ((this->type == 0) || (this->type == 1)) { - this->waypoint++; - if (this->waypoint >= 4) { - this->waypoint = 0; - } - } else { - // waypoints are defined with corners as 0-3 and middle points as 4-7 - // to choose the next waypoint, the order "04152637" is hardcoded in an array - for (i = 0; i < ARRAY_COUNT(sWaypoints); i++) { - if (this->waypoint == sWaypoints[i]) { - i++; - if (i >= ARRAY_COUNT(sWaypoints)) { - i = 0; - } - this->waypoint = sWaypoints[i]; - break; - } - } - this->waypointTimer = 5; - } - this->actionFunc = EnHeishi1_SetupWalk; - } else { - this->headBehaviorDecided = false; - } - } - break; - } - Math_ApproachF(&this->headAngle, this->headAngleTarget, this->headTurnSpeedScale, - this->headTurnSpeedMax + this->headTurnSpeedMax); - - if ((this->path == BREG(1)) && (BREG(0) != 0)) { - osSyncPrintf(VT_FGCOL(GREEN) " 種類 %d\n" VT_RST, this->path); - osSyncPrintf(VT_FGCOL(GREEN) " ぱす %d\n" VT_RST, this->waypoint); - osSyncPrintf(VT_FGCOL(GREEN) " 反転 %d\n" VT_RST, this->bodyTurnSpeed); - osSyncPrintf(VT_FGCOL(GREEN) " 時間 %d\n" VT_RST, this->waypointTimer); - osSyncPrintf("\n\n"); - } - } -} - -void EnHeishi1_SetupTurnTowardLink(EnHeishi1* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->kickTimer = 30; - this->actionFunc = EnHeishi1_TurnTowardLink; -} - -void EnHeishi1_TurnTowardLink(EnHeishi1* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->type != 5) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, this->bodyTurnSpeed, 0); - Math_ApproachF(&this->bodyTurnSpeed, 3000.0f, 1.0f, 300.0f); - Math_ApproachZeroF(&this->headAngle, 0.5f, 2000.0f); - } - - if (this->kickTimer == 0) { - this->actionFunc = EnHeishi1_SetupKick; - } -} - -void EnHeishi1_SetupKick(EnHeishi1* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = EnHeishi1_Kick; -} - -void EnHeishi1_Kick(EnHeishi1* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (!this->loadStarted) { - // if dialog state is 5 and textbox has been advanced, kick player out - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - if (!this->loadStarted) { - gSaveContext.eventChkInf[4] |= 0x4000; - globalCtx->nextEntranceIndex = 0x4FA; - globalCtx->sceneLoadFlag = 0x14; - this->loadStarted = true; - sPlayerIsCaught = false; - globalCtx->fadeTransition = 0x2E; - gSaveContext.nextTransition = 0x2E; - } - } - } -} - -void EnHeishi1_SetupWaitNight(EnHeishi1* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = EnHeishi1_WaitNight; -} - -void EnHeishi1_WaitNight(EnHeishi1* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->actor.xzDistToPlayer < 100.0f) { - Message_StartTextbox(globalCtx, 0x702D, &this->actor); - func_80078884(NA_SE_SY_FOUND); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" - func_8002DF54(globalCtx, &this->actor, 1); - this->actionFunc = EnHeishi1_SetupKick; - } -} - -void EnHeishi1_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi1* this = (EnHeishi1*)thisx; - s16 path; - u8 i; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 pad2; - Camera* activeCam; - - this->activeTimer++; - - for (i = 0; i < ARRAY_COUNT(this->timers); i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - - if (this->waypointTimer != 0) { - this->waypointTimer--; - } - - activeCam = GET_ACTIVE_CAM(globalCtx); - - if (player->actor.freezeTimer == 0) { - - this->actionFunc(this, globalCtx); - - this->actor.uncullZoneForward = 550.0f; - this->actor.uncullZoneScale = 350.0f; - this->actor.uncullZoneDownward = 700.0f; - - if (this->type != 5) { - path = this->path * 2; - if ((sCamDataIdxs[path] == activeCam->camDataIdx) || (sCamDataIdxs[path + 1] == activeCam->camDataIdx)) { - if (!sPlayerIsCaught) { - if ((this->actionFunc == EnHeishi1_Walk) || (this->actionFunc == EnHeishi1_Wait)) { - Vec3f searchBallVel; - Vec3f searchBallAccel = { 0.0f, 0.0f, 0.0f }; - Vec3f searchBallMult = { 0.0f, 0.0f, 20.0f }; - Vec3f searchBallPos; - - searchBallPos.x = this->actor.world.pos.x; - searchBallPos.y = this->actor.world.pos.y + 60.0f; - searchBallPos.z = this->actor.world.pos.z; - - Matrix_Push(); - Matrix_RotateY(((this->actor.shape.rot.y + this->headAngle) / 32768.0f) * M_PI, MTXMODE_NEW); - searchBallMult.z = 30.0f; - Matrix_MultVec3f(&searchBallMult, &searchBallVel); - Matrix_Pop(); - - EffectSsSolderSrchBall_Spawn(globalCtx, &searchBallPos, &searchBallVel, &searchBallAccel, 2, - &this->linkDetected); - - if (this->actor.xzDistToPlayer < 60.0f) { - this->linkDetected = true; - } else if (this->actor.xzDistToPlayer < 70.0f) { - // this case probably exists to detect link making a jump sound - // from slightly further away than the previous 60 unit check - if (player->actor.velocity.y > -4.0f) { - this->linkDetected = true; - } - } - - if (this->linkDetected) { - //! @bug This appears to be a check to make sure that link is standing on the ground - // before getting caught. However this is an issue for two reasons: - // 1: When doing a backflip or falling from the upper path, links y velocity will reach - // less than -4.0 before even touching the ground. - // 2: There is one frame when landing from a sidehop where you can sidehop again without - // letting y velocity reach -4.0 or less. This enables the player to do frame perfect - // sidehops onto the next screen and prevent getting caught. - if (!(player->actor.velocity.y > -3.9f)) { - this->linkDetected = false; - // this 60 unit height check is so the player doesnt get caught when on the upper path - if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 60.0f) { - func_80078884(NA_SE_SY_FOUND); - // "Discovered!" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); - func_8002DF54(globalCtx, &this->actor, 1); - sPlayerIsCaught = true; - this->actionFunc = EnHeishi1_SetupMoveToLink; - } - } - } - } - } - } - } - } -} - -s32 EnHeishi1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnHeishi1* this = (EnHeishi1*)thisx; - - // turn the guards head to match the direction he is looking - if (limbIndex == 16) { - rot->x += (s16)this->headAngle; - } - - return false; -} - -void EnHeishi1_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHeishi1* this = (EnHeishi1*)thisx; - Vec3f matrixScale = { 0.3f, 0.3f, 0.3f }; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHeishi1_OverrideLimbDraw, NULL, - this); - func_80033C30(&this->actor.world.pos, &matrixScale, 0xFF, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.cpp b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.cpp new file mode 100644 index 000000000..895e58caa --- /dev/null +++ b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.cpp @@ -0,0 +1,506 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI1_Z_EN_HEISHI1_C +#include "actor_common.h" +/* + * File: z_en_heishi1.c + * Overlay: ovl_En_Heishi1 + * Description: Courtyard Guards + */ + +#include "z_en_heishi1.h" +#include "objects/object_sd/object_sd.h" +#include "vt.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi1_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi1_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnHeishi1_SetupWait(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_SetupWalk(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_SetupMoveToLink(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_SetupTurnTowardLink(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_SetupKick(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_SetupWaitNight(EnHeishi1* pthis, GlobalContext* globalCtx); + +void EnHeishi1_Wait(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_Walk(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_MoveToLink(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_TurnTowardLink(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_Kick(EnHeishi1* pthis, GlobalContext* globalCtx); +void EnHeishi1_WaitNight(EnHeishi1* pthis, GlobalContext* globalCtx); + +static s32 sPlayerIsCaught = false; + +ActorInit En_Heishi1_InitVars = { + 0, + ACTORCAT_NPC, + FLAGS, + OBJECT_SD, + sizeof(EnHeishi1), + (ActorFunc)EnHeishi1_Init, + (ActorFunc)EnHeishi1_Destroy, + (ActorFunc)EnHeishi1_Update, + (ActorFunc)EnHeishi1_Draw, +}; + +static f32 sAnimParamsInit[][8] = { + { 1.0f, -10.0f, 3.0f, 0.5f, 1000.0f, 200.0f, 0.3f, 1000.0f }, + { 3.0f, -3.0f, 6.0f, 0.8f, 2000.0f, 400.0f, 0.5f, 2000.0f }, + { 1.0f, -10.0f, 3.0f, 0.5f, 1000.0f, 200.0f, 0.3f, 1000.0f }, + { 3.0f, -3.0f, 6.0f, 0.8f, 2000.0f, 400.0f, 0.5f, 2000.0f }, +}; + +static s16 sBaseHeadTimers[] = { 20, 10, 20, 10, 13, 0 }; + +static Vec3f sRupeePositions[] = { + { 0.0f, 0.0f, 90.0f }, { -55.0f, 0.0f, 90.0f }, { -55.0f, 0.0f, 30.0f }, { -55.0f, 0.0f, -30.0f }, + { 0.0f, 0.0f, -30.0f }, { 55.0f, 0.0f, -30.0f }, { 55.0f, 0.0f, 30.0f }, { 55.0f, 0.0f, 90.0f }, +}; + +static s32 sCamDataIdxs[] = { + 7, 7, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 4, 4, 5, 6, +}; + +static s16 sWaypoints[] = { 0, 4, 1, 5, 2, 6, 3, 7 }; + +void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHeishi1* pthis = (EnHeishi1*)thisx; + Vec3f rupeePos; + s32 i; + + Actor_SetScale(&pthis->actor, 0.01f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, pthis->jointTable, pthis->morphTable, + 17); + + pthis->type = (pthis->actor.params >> 8) & 0xFF; + pthis->path = pthis->actor.params & 0xFF; + + for (i = 0; i < ARRAY_COUNT(sAnimParamsInit[0]); i++) { + pthis->animParams[i] = sAnimParamsInit[pthis->type][i]; + } + + // "type" + osSyncPrintf(VT_FGCOL(GREEN) " 種類☆☆☆☆☆☆☆☆☆☆☆☆☆ %d\n" VT_RST, pthis->type); + // "path data" + osSyncPrintf(VT_FGCOL(YELLOW) " れえるでぇたぁ☆☆☆☆☆☆☆☆ %d\n" VT_RST, pthis->path); + osSyncPrintf(VT_FGCOL(PURPLE) " anime_frame_speed ☆☆☆☆☆☆ %f\n" VT_RST, pthis->animSpeed); + // "interpolation frame" + osSyncPrintf(VT_FGCOL(PURPLE) " 補間フレーム☆☆☆☆☆☆☆☆☆ %f\n" VT_RST, pthis->transitionRate); + // "targeted movement speed value between points" + osSyncPrintf(VT_FGCOL(PURPLE) " point間の移動スピード目標値 ☆ %f\n" VT_RST, pthis->moveSpeedTarget); + // "maximum movement speed value between points" + osSyncPrintf(VT_FGCOL(PURPLE) " point間の移動スピード最大 ☆☆ %f\n" VT_RST, pthis->moveSpeedMax); + // "(body) targeted turning angle speed value" + osSyncPrintf(VT_FGCOL(PURPLE) " (体)反転アングルスピード目標値 %f\n" VT_RST, pthis->bodyTurnSpeedTarget); + // "(body) maximum turning angle speed" + osSyncPrintf(VT_FGCOL(PURPLE) " (体)反転アングルスピード最大☆ %f\n" VT_RST, pthis->bodyTurnSpeedMax); + // "(head) targeted turning angle speed value" + osSyncPrintf(VT_FGCOL(PURPLE) " (頭)反転アングルスピード加算値 %f\n" VT_RST, pthis->headTurnSpeedScale); + // "(head) maximum turning angle speed" + osSyncPrintf(VT_FGCOL(PURPLE) " (頭)反転アングルスピード最大☆ %f\n" VT_RST, pthis->headTurnSpeedMax); + osSyncPrintf(VT_FGCOL(GREEN) " 今時間 %d\n" VT_RST, ((void)0, gSaveContext.dayTime)); // "current time" + osSyncPrintf(VT_FGCOL(YELLOW) " チェック時間 %d\n" VT_RST, 0xBAAA); // "check time" + osSyncPrintf("\n\n"); + + if (pthis->path == 3) { + for (i = 0; i < ARRAY_COUNT(sRupeePositions); i++) { + rupeePos = sRupeePositions[i]; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_RUPPY, rupeePos.x, rupeePos.y, + rupeePos.z, 0, 0, 0, 3); + } + } + + if (pthis->type != 5) { + if (((gSaveContext.dayTime < 0xB888) || IS_DAY) && !(gSaveContext.eventChkInf[8] & 1)) { + pthis->actionFunc = EnHeishi1_SetupWalk; + } else { + Actor_Kill(&pthis->actor); + } + } else { + if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || (gSaveContext.eventChkInf[8] & 1)) { + pthis->actionFunc = EnHeishi1_SetupWaitNight; + } else { + Actor_Kill(&pthis->actor); + } + } +} + +void EnHeishi1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnHeishi1_SetupWalk(EnHeishi1* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiWalkAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiWalkAnim, pthis->animSpeed, 0.0f, (s16)frameCount, ANIMMODE_LOOP, + pthis->transitionRate); + pthis->bodyTurnSpeed = 0.0f; + pthis->moveSpeed = 0.0f; + pthis->headDirection = Rand_ZeroFloat(1.99f); + pthis->actionFunc = EnHeishi1_Walk; +} + +void EnHeishi1_Walk(EnHeishi1* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* pointPos; + f32 pathDiffX; + f32 pathDiffZ; + s16 randOffset; + + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, 1.0f) || Animation_OnFrame(&pthis->skelAnime, 17.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KNIGHT_WALK); + } + + if (!sPlayerIsCaught) { + path = &globalCtx->setupPathList[pthis->path]; + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos += pthis->waypoint; + + Math_ApproachF(&pthis->actor.world.pos.x, pointPos->x, 1.0f, pthis->moveSpeed); + Math_ApproachF(&pthis->actor.world.pos.z, pointPos->z, 1.0f, pthis->moveSpeed); + + Math_ApproachF(&pthis->moveSpeed, pthis->moveSpeedTarget, 1.0f, pthis->moveSpeedMax); + + pathDiffX = pointPos->x - pthis->actor.world.pos.x; + pathDiffZ = pointPos->z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 3, + pthis->bodyTurnSpeed, 0); + + Math_ApproachF(&pthis->bodyTurnSpeed, pthis->bodyTurnSpeedTarget, 1.0f, pthis->bodyTurnSpeedMax); + + if (pthis->headTimer == 0) { + pthis->headDirection++; + pthis->headAngleTarget = 0x2000; + // if headDirection is odd, face 45 degrees left + if ((pthis->headDirection & 1) != 0) { + pthis->headAngleTarget *= -1; + } + randOffset = Rand_ZeroFloat(30.0f); + pthis->headTimer = sBaseHeadTimers[pthis->type] + randOffset; + } + + Math_ApproachF(&pthis->headAngle, pthis->headAngleTarget, pthis->headTurnSpeedScale, pthis->headTurnSpeedMax); + + if ((pthis->path == BREG(1)) && (BREG(0) != 0)) { + osSyncPrintf(VT_FGCOL(RED) " 種類 %d\n" VT_RST, pthis->path); + osSyncPrintf(VT_FGCOL(RED) " ぱす %d\n" VT_RST, pthis->waypoint); + osSyncPrintf(VT_FGCOL(RED) " 反転 %d\n" VT_RST, pthis->bodyTurnSpeed); + osSyncPrintf(VT_FGCOL(RED) " 時間 %d\n" VT_RST, pthis->waypointTimer); + osSyncPrintf(VT_FGCOL(RED) " 点座 %d\n" VT_RST, path->count); + osSyncPrintf("\n\n"); + } + + // when 20 units away from a middle waypoint, decide whether or not to skip it + if ((fabsf(pathDiffX) < 20.0f) && (fabsf(pathDiffZ) < 20.0f)) { + if (pthis->waypointTimer == 0) { + if (pthis->type >= 2) { + if ((pthis->waypoint >= 4) && (Rand_ZeroFloat(1.99f) > 1.0f)) { + if (pthis->waypoint == 7) { + pthis->waypoint = 0; + } + if (pthis->waypoint >= 4) { + pthis->waypoint -= 3; + } + pthis->waypointTimer = 5; + return; + } + } + pthis->actionFunc = EnHeishi1_SetupWait; + } + } + } +} + +void EnHeishi1_SetupMoveToLink(EnHeishi1* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiWalkAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiWalkAnim, 3.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -3.0f); + pthis->bodyTurnSpeed = 0.0f; + pthis->moveSpeed = 0.0f; + Message_StartTextbox(globalCtx, 0x702D, &pthis->actor); + Interface_SetDoAction(globalCtx, DO_ACTION_STOP); + pthis->actionFunc = EnHeishi1_MoveToLink; +} + +void EnHeishi1_MoveToLink(EnHeishi1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.world.pos.x, player->actor.world.pos.x, 1.0f, pthis->moveSpeed); + Math_ApproachF(&pthis->actor.world.pos.z, player->actor.world.pos.z, 1.0f, pthis->moveSpeed); + Math_ApproachF(&pthis->moveSpeed, 6.0f, 1.0f, 0.4f); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, pthis->bodyTurnSpeed, 0); + Math_ApproachF(&pthis->bodyTurnSpeed, 3000.0f, 1.0f, 300.0f); + Math_ApproachZeroF(&pthis->headAngle, 0.5f, 2000.0f); + + if (pthis->actor.xzDistToPlayer < 70.0f) { + pthis->actionFunc = EnHeishi1_SetupTurnTowardLink; + } +} + +void EnHeishi1_SetupWait(EnHeishi1* pthis, GlobalContext* globalCtx) { + s16 rand; + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, pthis->animSpeed, 0.0f, (s16)frameCount, ANIMMODE_LOOP, + pthis->transitionRate); + pthis->headBehaviorDecided = false; + pthis->headDirection = Rand_ZeroFloat(1.99f); + rand = Rand_ZeroFloat(50.0f); + pthis->waitTimer = rand + 50; + pthis->actionFunc = EnHeishi1_Wait; +} + +void EnHeishi1_Wait(EnHeishi1* pthis, GlobalContext* globalCtx) { + s16 randOffset; + s32 i; + + SkelAnime_Update(&pthis->skelAnime); + if (!sPlayerIsCaught) { + switch (pthis->headBehaviorDecided) { + case false: + pthis->headDirection++; + // if headDirection is odd, face 52 degrees left + pthis->headAngleTarget = (pthis->headDirection & 1) ? 0x2500 : -0x2500; + randOffset = Rand_ZeroFloat(30.0f); + pthis->headTimer = sBaseHeadTimers[pthis->type] + randOffset; + pthis->headBehaviorDecided = true; + break; + case true: + if (pthis->headTimer == 0) { + if (pthis->waitTimer == 0) { + if ((pthis->type == 0) || (pthis->type == 1)) { + pthis->waypoint++; + if (pthis->waypoint >= 4) { + pthis->waypoint = 0; + } + } else { + // waypoints are defined with corners as 0-3 and middle points as 4-7 + // to choose the next waypoint, the order "04152637" is hardcoded in an array + for (i = 0; i < ARRAY_COUNT(sWaypoints); i++) { + if (pthis->waypoint == sWaypoints[i]) { + i++; + if (i >= ARRAY_COUNT(sWaypoints)) { + i = 0; + } + pthis->waypoint = sWaypoints[i]; + break; + } + } + pthis->waypointTimer = 5; + } + pthis->actionFunc = EnHeishi1_SetupWalk; + } else { + pthis->headBehaviorDecided = false; + } + } + break; + } + Math_ApproachF(&pthis->headAngle, pthis->headAngleTarget, pthis->headTurnSpeedScale, + pthis->headTurnSpeedMax + pthis->headTurnSpeedMax); + + if ((pthis->path == BREG(1)) && (BREG(0) != 0)) { + osSyncPrintf(VT_FGCOL(GREEN) " 種類 %d\n" VT_RST, pthis->path); + osSyncPrintf(VT_FGCOL(GREEN) " ぱす %d\n" VT_RST, pthis->waypoint); + osSyncPrintf(VT_FGCOL(GREEN) " 反転 %d\n" VT_RST, pthis->bodyTurnSpeed); + osSyncPrintf(VT_FGCOL(GREEN) " 時間 %d\n" VT_RST, pthis->waypointTimer); + osSyncPrintf("\n\n"); + } + } +} + +void EnHeishi1_SetupTurnTowardLink(EnHeishi1* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->kickTimer = 30; + pthis->actionFunc = EnHeishi1_TurnTowardLink; +} + +void EnHeishi1_TurnTowardLink(EnHeishi1* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->type != 5) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, pthis->bodyTurnSpeed, 0); + Math_ApproachF(&pthis->bodyTurnSpeed, 3000.0f, 1.0f, 300.0f); + Math_ApproachZeroF(&pthis->headAngle, 0.5f, 2000.0f); + } + + if (pthis->kickTimer == 0) { + pthis->actionFunc = EnHeishi1_SetupKick; + } +} + +void EnHeishi1_SetupKick(EnHeishi1* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = EnHeishi1_Kick; +} + +void EnHeishi1_Kick(EnHeishi1* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (!pthis->loadStarted) { + // if dialog state is 5 and textbox has been advanced, kick player out + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + if (!pthis->loadStarted) { + gSaveContext.eventChkInf[4] |= 0x4000; + globalCtx->nextEntranceIndex = 0x4FA; + globalCtx->sceneLoadFlag = 0x14; + pthis->loadStarted = true; + sPlayerIsCaught = false; + globalCtx->fadeTransition = 0x2E; + gSaveContext.nextTransition = 0x2E; + } + } + } +} + +void EnHeishi1_SetupWaitNight(EnHeishi1* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = EnHeishi1_WaitNight; +} + +void EnHeishi1_WaitNight(EnHeishi1* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.xzDistToPlayer < 100.0f) { + Message_StartTextbox(globalCtx, 0x702D, &pthis->actor); + func_80078884(NA_SE_SY_FOUND); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->actionFunc = EnHeishi1_SetupKick; + } +} + +void EnHeishi1_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi1* pthis = (EnHeishi1*)thisx; + s16 path; + u8 i; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + Camera* activeCam; + + pthis->activeTimer++; + + for (i = 0; i < ARRAY_COUNT(pthis->timers); i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + + if (pthis->waypointTimer != 0) { + pthis->waypointTimer--; + } + + activeCam = GET_ACTIVE_CAM(globalCtx); + + if (player->actor.freezeTimer == 0) { + + pthis->actionFunc(pthis, globalCtx); + + pthis->actor.uncullZoneForward = 550.0f; + pthis->actor.uncullZoneScale = 350.0f; + pthis->actor.uncullZoneDownward = 700.0f; + + if (pthis->type != 5) { + path = pthis->path * 2; + if ((sCamDataIdxs[path] == activeCam->camDataIdx) || (sCamDataIdxs[path + 1] == activeCam->camDataIdx)) { + if (!sPlayerIsCaught) { + if ((pthis->actionFunc == EnHeishi1_Walk) || (pthis->actionFunc == EnHeishi1_Wait)) { + Vec3f searchBallVel; + Vec3f searchBallAccel = { 0.0f, 0.0f, 0.0f }; + Vec3f searchBallMult = { 0.0f, 0.0f, 20.0f }; + Vec3f searchBallPos; + + searchBallPos.x = pthis->actor.world.pos.x; + searchBallPos.y = pthis->actor.world.pos.y + 60.0f; + searchBallPos.z = pthis->actor.world.pos.z; + + Matrix_Push(); + Matrix_RotateY(((pthis->actor.shape.rot.y + pthis->headAngle) / 32768.0f) * M_PI, MTXMODE_NEW); + searchBallMult.z = 30.0f; + Matrix_MultVec3f(&searchBallMult, &searchBallVel); + Matrix_Pop(); + + EffectSsSolderSrchBall_Spawn(globalCtx, &searchBallPos, &searchBallVel, &searchBallAccel, 2, + &pthis->linkDetected); + + if (pthis->actor.xzDistToPlayer < 60.0f) { + pthis->linkDetected = true; + } else if (pthis->actor.xzDistToPlayer < 70.0f) { + // pthis case probably exists to detect link making a jump sound + // from slightly further away than the previous 60 unit check + if (player->actor.velocity.y > -4.0f) { + pthis->linkDetected = true; + } + } + + if (pthis->linkDetected) { + //! @bug This appears to be a check to make sure that link is standing on the ground + // before getting caught. However pthis is an issue for two reasons: + // 1: When doing a backflip or falling from the upper path, links y velocity will reach + // less than -4.0 before even touching the ground. + // 2: There is one frame when landing from a sidehop where you can sidehop again without + // letting y velocity reach -4.0 or less. This enables the player to do frame perfect + // sidehops onto the next screen and prevent getting caught. + if (!(player->actor.velocity.y > -3.9f)) { + pthis->linkDetected = false; + // pthis 60 unit height check is so the player doesnt get caught when on the upper path + if (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 60.0f) { + func_80078884(NA_SE_SY_FOUND); + // "Discovered!" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); + func_8002DF54(globalCtx, &pthis->actor, 1); + sPlayerIsCaught = true; + pthis->actionFunc = EnHeishi1_SetupMoveToLink; + } + } + } + } + } + } + } + } +} + +s32 EnHeishi1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnHeishi1* pthis = (EnHeishi1*)thisx; + + // turn the guards head to match the direction he is looking + if (limbIndex == 16) { + rot->x += (s16)pthis->headAngle; + } + + return false; +} + +void EnHeishi1_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHeishi1* pthis = (EnHeishi1*)thisx; + Vec3f matrixScale = { 0.3f, 0.3f, 0.3f }; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnHeishi1_OverrideLimbDraw, NULL, + pthis); + func_80033C30(&pthis->actor.world.pos, &matrixScale, 0xFF, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c deleted file mode 100644 index 31f3d511f..000000000 --- a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c +++ /dev/null @@ -1,880 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI2_Z_EN_HEISHI2_C -#include -#include "actor_common.h" -/* - * File: z_en_heishi2.c - * Overlay: ovl_En_Heishi2 - * Description: Hyrulian Guards - */ - -#include "vt.h" -#include "z_en_heishi2.h" -#include "objects/object_sd/object_sd.h" -#include "objects/object_link_child/object_link_child.h" -#include "overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnHeishi2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi2_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnHeishi2_DrawKingGuard(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi2_DoNothing1(EnHeishi2* this, GlobalContext* globalCtx); -void EnHeishi_DoNothing2(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A531E4(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53278(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A5344C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A54954(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53538(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A535BC(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A5399C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53638(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A5372C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A5475C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53AD4(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53C0C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53C90(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53D0C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A544AC(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53908(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53F30(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A54038(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A5427C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A549E8(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53850(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A54320(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A543A0(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A5455C(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A546DC(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A541FC(EnHeishi2* this, GlobalContext* globalCtx); -void func_80A53DF8(EnHeishi2* this, GlobalContext* globalCtx); - -const ActorInit En_Heishi2_InitVars = { - ACTOR_EN_HEISHI2, - ACTORCAT_NPC, - FLAGS, - OBJECT_SD, - sizeof(EnHeishi2), - (ActorFunc)EnHeishi2_Init, - (ActorFunc)EnHeishi2_Destroy, - (ActorFunc)EnHeishi2_Update, - (ActorFunc)EnHeishi2_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 33, 40, 0, { 0, 0, 0 } }, -}; - -void EnHeishi2_Init(Actor* thisx, GlobalContext* globalCtx) { - ColliderCylinder* collider; - EnHeishi2* this = (EnHeishi2*)thisx; - - Actor_SetScale(&this->actor, 0.01f); - this->type = this->actor.params & 0xFF; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - - if ((this->type == 6) || (this->type == 9)) { - this->actor.draw = EnHeishi2_DrawKingGuard; - this->actor.flags &= ~ACTOR_FLAG_0; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, 6); - if (this->type == 6) { - this->actionFunc = EnHeishi2_DoNothing1; - - } else { - osSyncPrintf("\n\n"); - // "No, I'm completely disappointed" (message for when shooting guard window in courtyard) - osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ いやー ついうっかり ☆☆☆☆☆ \n" VT_RST); - - Actor_SetScale(&this->actor, 0.02f); - - this->unk_274 = this->actor.world.pos; - this->actor.world.rot.y = 0x7918; - this->actor.world.pos.x += 90.0f; - this->actor.world.pos.y -= 60.0f; - this->actor.world.pos.z += 90.0f; - this->actor.shape.rot.y = this->actor.world.rot.y; - Collider_DestroyCylinder(globalCtx, &this->collider); - func_8002DF54(globalCtx, 0, 8); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_4; - this->actionFunc = func_80A544AC; - } - } else { - this->unk_2E0 = 60.0f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, this->jointTable, - this->morphTable, 17); - collider = &this->collider; - Collider_InitCylinder(globalCtx, collider); - Collider_SetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); - this->collider.dim.yShift = 0; - this->collider.dim.radius = 15; - this->collider.dim.height = 70; - this->actor.targetMode = 6; - - switch (this->type) { - - case 2: - this->actionFunc = func_80A531E4; - this->actor.gravity = -1.0f; - break; - case 5: - this->actionFunc = func_80A53908; - this->actor.gravity = -1.0f; - break; - case 6: - osSyncPrintf("\n\n"); - // "Peep hole soldier!" - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 覗き穴奥兵士ふぃ〜 ☆☆☆☆☆ \n" VT_RST); - Collider_DestroyCylinder(globalCtx, collider); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actionFunc = EnHeishi_DoNothing2; - break; - } - - this->unk_2F0 = (this->actor.params >> 8) & 0xFF; - osSyncPrintf("\n\n"); - // "Soldier Set 2 Completed!" - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 兵士2セット完了! ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); - // "Identification Completed!" - osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 識別完了! ☆☆☆☆☆ %d\n" VT_RST, this->type); - // "Message completed!" - osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ メッセージ完了! ☆☆☆☆☆ %x\n\n" VT_RST, (this->actor.params >> 8) & 0xF); - } -} - -void EnHeishi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi2* this = (EnHeishi2*)thisx; - - if ((this->collider.dim.radius != 0) || (this->collider.dim.height != 0)) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void EnHeishi2_DoNothing1(EnHeishi2* this, GlobalContext* globalCtx) { -} - -void EnHeishi_DoNothing2(EnHeishi2* this, GlobalContext* globalCtx) { -} - -void func_80A531E4(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A53278; -} - -void func_80A53278(EnHeishi2* this, GlobalContext* globalCtx) { - this->unk_30B = 0; - this->unk_30E = 0; - if (Text_GetFaceReaction(globalCtx, 5) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 5); - this->unk_30B = 1; - this->unk_300 = TEXT_STATE_DONE; - this->actionFunc = func_80A5475C; - } else if ((gSaveContext.eventChkInf[0] & 0x200) && (gSaveContext.eventChkInf[2] & 0x20) && - (gSaveContext.eventChkInf[3] & 0x80)) { - // "Get all spiritual stones!" - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 全部の精霊石GET! ☆☆☆☆☆ \n" VT_RST); - this->unk_300 = TEXT_STATE_DONE; - this->actor.textId = 0x7006; - this->actionFunc = func_80A5475C; - } else if (!IS_DAY) { - // "Sleep early for children!" - osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 子供ははやくネロ! ☆☆☆☆☆ \n" VT_RST); - this->unk_300 = TEXT_STATE_DONE; - this->actor.textId = 0x7002; - this->actionFunc = func_80A5475C; - - } else if (this->unk_30C != 0) { - // "Anything passes" - osSyncPrintf(VT_FGCOL(BLUE) " ☆☆☆☆☆ なんでも通るよ ☆☆☆☆☆ \n" VT_RST); - this->unk_300 = TEXT_STATE_DONE; - this->actor.textId = 0x7099; - this->actionFunc = func_80A5475C; - } else if (gSaveContext.eventChkInf[1] & 4) { - if (this->unk_30E == 0) { - // "Start under the first sleeve!" - osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ 1回目袖の下開始! ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x7071; - this->unk_30E = 1; - } else { - // "Start under the second sleeve!" - osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ 2回目袖の下開始! ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x7072; - } - this->unk_300 = TEXT_STATE_CHOICE; - this->actionFunc = func_80A5475C; - - } else { - // "That's okay" - osSyncPrintf(VT_FGCOL(CYAN) " ☆☆☆☆☆ それはとおらんよぉ ☆☆☆☆☆ \n" VT_RST); - this->unk_300 = TEXT_STATE_DONE; - this->actor.textId = 0x7029; - this->actionFunc = func_80A5475C; - } -} - -void func_80A5344C(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - this->unk_300 = TEXT_STATE_EVENT; - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - if (gSaveContext.rupees >= 10) { - Rupees_ChangeBy(-10); - this->actor.textId = 0x7098; - this->actionFunc = func_80A53538; - break; - } else { - this->actor.textId = 0x7097; - this->actionFunc = func_80A54954; - break; - } - case 1: - this->actor.textId = 0x7096; - this->actionFunc = func_80A54954; - break; - - default: - break; - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - } -} - -void func_80A53538(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_300 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - func_8002DF54(globalCtx, NULL, 8); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actionFunc = func_80A535BC; - } -} - -void func_80A535BC(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiSlamSpearAnim); - - this->unk_2EC = frameCount; - Animation_Change(&this->skelAnime, &gEnHeishiSlamSpearAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -10.0f); - this->actionFunc = func_80A53638; -} - -void func_80A53638(EnHeishi2* this, GlobalContext* globalCtx) { - s32 pad; - f32 frameCount = this->skelAnime.curFrame; - - BgSpot15Saku* actor = (BgSpot15Saku*)globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; - - SkelAnime_Update(&this->skelAnime); - if ((frameCount >= 12.0f) && (!this->audioFlag)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SPEAR_HIT); - this->audioFlag = 1; - } - if (this->unk_2EC <= frameCount) { - while (actor != NULL) { - if (actor->dyna.actor.id != ACTOR_BG_SPOT15_SAKU) { - actor = (BgSpot15Saku*)(actor->dyna.actor.next); - } else { - this->gate = &actor->dyna.actor; - actor->unk_168 = 1; - break; - } - } - // "I've come!" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆ きたきたきたぁ! ☆☆☆ %x\n" VT_RST, actor->dyna.actor.next); - this->actionFunc = func_80A5372C; - } -} - -void func_80A5372C(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->unk_2F2[0] = 200; - this->cameraId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->cameraId, CAM_STAT_ACTIVE); - this->unk_280.x = 947.0f; - this->unk_280.y = 1195.0f; - this->unk_280.z = 2682.0f; - - this->unk_28C.x = 1164.0f; - this->unk_28C.y = 1145.0f; - this->unk_28C.z = 3014.0f; - - Gameplay_CameraSetAtEye(globalCtx, this->cameraId, &this->unk_280, &this->unk_28C); - this->actionFunc = func_80A53850; -} - -void func_80A53850(EnHeishi2* this, GlobalContext* globalCtx) { - BgSpot15Saku* gate; - - SkelAnime_Update(&this->skelAnime); - Gameplay_CameraSetAtEye(globalCtx, this->cameraId, &this->unk_280, &this->unk_28C); - gate = (BgSpot15Saku*)this->gate; - if ((this->unk_2F2[0] == 0) || (gate->unk_168 == 0)) { - Gameplay_ClearCamera(globalCtx, this->cameraId); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - Message_CloseTextbox(globalCtx); - this->unk_30C = 1; - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = func_80A531E4; - } -} - -void func_80A53908(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A5399C; -} - -void func_80A5399C(EnHeishi2* this, GlobalContext* globalCtx) { - s16 var; - - this->unk_30B = 0; - var = 0; - if (gSaveContext.infTable[7] & 0x40) { - if (!(gSaveContext.infTable[7] & 0x80)) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_KEATON) { - if (this->unk_309 == 0) { - this->actor.textId = 0x200A; - } else { - this->actor.textId = 0x200B; - } - this->unk_300 = TEXT_STATE_CHOICE; - this->unk_30B = 1; - var = 1; - } else { - this->actor.textId = 0x2016; - this->unk_300 = TEXT_STATE_DONE; - var = 1; - } - } else { - this->actor.textId = 0x2020; - this->unk_300 = TEXT_STATE_EVENT; - this->unk_30E = 0; - } - if (Text_GetFaceReaction(globalCtx, 5) != 0) { - if (var == 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 5); - this->unk_30B = 1; - this->unk_300 = TEXT_STATE_DONE; - this->unk_30E = 0; - } - } - this->actionFunc = func_80A5475C; - } else { - // "I don't know" - osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ とおしゃしねぇちゅーの ☆☆☆☆☆ \n" VT_RST); - this->actionFunc = func_80A53AD4; - } -} - -void func_80A53AD4(EnHeishi2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 exchangeItemId; - s16 yawDiffTemp; - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - if (Text_GetFaceReaction(globalCtx, 5) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 5); - } else { - this->actor.textId = 0x200E; - } - this->unk_300 = TEXT_STATE_DONE; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - exchangeItemId = func_8002F368(globalCtx); - if (exchangeItemId == EXCH_ITEM_LETTER_ZELDA) { - func_80078884(NA_SE_SY_CORRECT_CHIME); - player->actor.textId = 0x2010; - this->unk_300 = TEXT_STATE_EVENT; - this->actionFunc = func_80A53C0C; - } else if (exchangeItemId != EXCH_ITEM_NONE) { - player->actor.textId = 0x200F; - } - } else { - yawDiffTemp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - yawDiff = ABS(yawDiffTemp); - if (!(120.0f < this->actor.xzDistToPlayer) && (yawDiff < 0x4300)) { - func_8002F298(&this->actor, globalCtx, 100.0f, EXCH_ITEM_LETTER_ZELDA); - } - } -} - -void func_80A53C0C(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((this->unk_300 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - func_8002DF54(globalCtx, 0, 8); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actionFunc = func_80A53C90; - } -} - -void func_80A53C90(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiSlamSpearAnim); - - this->unk_2EC = frameCount; - Animation_Change(&this->skelAnime, &gEnHeishiSlamSpearAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -10.0f); - this->actionFunc = func_80A53D0C; -} - -void func_80A53D0C(EnHeishi2* this, GlobalContext* globalCtx) { - s32 pad; - f32 frameCount; - BgGateShutter* gate; - - frameCount = this->skelAnime.curFrame; - gate = (BgGateShutter*)globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; - SkelAnime_Update(&this->skelAnime); - if (12.0f <= frameCount) { - if (this->audioFlag == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SPEAR_HIT); - this->audioFlag = 1; - } - } - if (this->unk_2EC <= frameCount) { - while (gate != NULL) { - if (gate->dyna.actor.id != ACTOR_BG_GATE_SHUTTER) { - gate = (BgGateShutter*)gate->dyna.actor.next; - } else { - this->gate = &gate->dyna.actor; - gate->openingState = 1; - break; - } - } - // "I've come!" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆ きたきたきたぁ! ☆☆☆ %x\n" VT_RST, gate->dyna.actor.next); - this->actionFunc = func_80A53DF8; - } -} - -void func_80A53DF8(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->unk_2F2[0] = 200; - this->cameraId = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->cameraId, CAM_STAT_ACTIVE); - this->unk_2BC.x = -71.0f; - this->unk_280.x = -71.0f; - this->unk_2BC.y = 571.0f; - this->unk_280.y = 571.0f; - this->unk_2BC.z = -1487.0f; - this->unk_280.z = -1487.0f; - this->unk_298.x = 181.0f; - this->unk_28C.x = 181.0f; - this->unk_298.y = 417.0f; - this->unk_28C.y = 417.0f; - this->unk_298.z = -1079.0f; - this->unk_28C.z = -1079.0f; - Gameplay_CameraSetAtEye(globalCtx, this->cameraId, &this->unk_280, &this->unk_28C); - this->actionFunc = func_80A53F30; -} - -void func_80A53F30(EnHeishi2* this, GlobalContext* globalCtx) { - BgGateShutter* gate; - - SkelAnime_Update(&this->skelAnime); - Gameplay_CameraSetAtEye(globalCtx, this->cameraId, &this->unk_280, &this->unk_28C); - gate = (BgGateShutter*)this->gate; - if ((this->unk_2F2[0] == 0) || (gate->openingState == 0)) { - Gameplay_ClearCamera(globalCtx, this->cameraId); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - if ((this->unk_30A != 2)) { - if (this->unk_30A == 0) { - this->actor.textId = 0x2015; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->actionFunc = func_80A54038; - } else { - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = func_80A53908; - } - } else { - this->unk_30E = 0; - this->actor.textId = 0x2021; - Rupees_ChangeBy(15); - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->actionFunc = func_80A5427C; - } - } -} - -void func_80A54038(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - gSaveContext.infTable[7] |= 0x40; - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, 0, 7); - this->actionFunc = func_80A53908; - } -} - -void func_80A540C0(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - this->actor.textId = 0x2020; - Message_ContinueTextbox(globalCtx, this->actor.textId); - Player_UnsetMask(globalCtx); - gSaveContext.infTable[7] |= 0x80; - gSaveContext.itemGetInf[3] |= 0x100; - Item_Give(globalCtx, ITEM_SOLD_OUT); - if (this->unk_30A != 0) { - this->unk_30A = 2; - this->unk_30E = 1; - this->actionFunc = func_80A5427C; - } else { - this->unk_30E = 0; - this->actionFunc = func_80A541FC; - } - break; - case 1: - this->unk_30E = 1; - this->actor.textId = 0x200C; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_300 = TEXT_STATE_EVENT; - if (this->unk_30A == 0) { - this->actionFunc = func_80A5427C; - } else { - this->actionFunc = func_80A54954; - } - } - } -} - -void func_80A541FC(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actor.textId = 0x2021; - Rupees_ChangeBy(15); - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->actionFunc = func_80A5427C; - } -} - -void func_80A5427C(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - if (this->unk_30E == 0) { - this->unk_30E = 0; - this->unk_30A = this->unk_30E; - Message_CloseTextbox(globalCtx); - this->actionFunc = func_80A53908; - } else { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actionFunc = func_80A54320; - } - } -} - -void func_80A54320(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiSlamSpearAnim); - - this->unk_2EC = frameCount; - Animation_Change(&this->skelAnime, &gEnHeishiSlamSpearAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -10.0f); - this->audioFlag = 0; - this->actionFunc = func_80A543A0; -} - -void func_80A543A0(EnHeishi2* this, GlobalContext* globalCtx) { - s32 pad; - f32 frameCount = this->skelAnime.curFrame; - BgGateShutter* gate = (BgGateShutter*)(globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head); - SkelAnime_Update(&this->skelAnime); - - if ((frameCount >= 12.0f) && (!this->audioFlag)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SPEAR_HIT); - this->audioFlag = 1; - } - - if (this->unk_2EC <= frameCount) { - while (gate != NULL) { - if (ACTOR_BG_GATE_SHUTTER != gate->dyna.actor.id) { - gate = (BgGateShutter*)(gate->dyna.actor.next); - } else { - this->gate = &gate->dyna.actor; - if (this->unk_30A != 2) { - gate->openingState = -1; - break; - } else { - gate->openingState = 2; - break; - } - } - } - if (this->unk_30A == 0) { - this->unk_30A = 1; - } - this->actionFunc = func_80A53DF8; - } -} - -void func_80A544AC(EnHeishi2* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.z, -6100, 5, this->unk_2E4, 0); - Math_ApproachF(&this->unk_2E4, 3000.0f, 1.0f, 500.0f); - this->actor.world.rot.z = this->actor.shape.rot.z; - if (this->actor.shape.rot.z < -6000) { - Message_StartTextbox(globalCtx, 0x708F, NULL); - this->actor.flags |= ACTOR_FLAG_16; - this->actionFunc = func_80A5455C; - this->unk_2E4 = 0.0f; - } -} - -void func_80A5455C(EnHeishi2* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f pos; - f32 rotY; - EnBom* bomb; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_8002DF54(globalCtx, NULL, 7); - Message_CloseTextbox(globalCtx); - - pos.x = Rand_CenteredFloat(20.0f) + this->unk_274.x; - pos.y = Rand_CenteredFloat(20.0f) + (this->unk_274.y - 40.0f); - pos.z = Rand_CenteredFloat(20.0f) + (this->unk_274.z - 20.0f); - rotY = Rand_CenteredFloat(7000.0f) + this->actor.yawTowardsPlayer; - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pos.x, pos.y, pos.z, 0, rotY, 0, 0); - if (bomb != NULL) { - bomb->actor.speedXZ = Rand_CenteredFloat(5.0f) + 10.0f; - bomb->actor.velocity.y = Rand_CenteredFloat(5.0f) + 10.0f; - } - - // "This is down!" - osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ これでダウンだ! ☆☆☆☆☆ \n" VT_RST); - this->actionFunc = func_80A546DC; - } -} - -void func_80A546DC(EnHeishi2* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.z, 200, 5, this->unk_2E4, 0); - Math_ApproachF(&this->unk_2E4, 3000.0f, 1.0f, 500.0f); - this->actor.world.rot.z = this->actor.shape.rot.z; - if (this->actor.shape.rot.z > 0) { - Actor_Kill(&this->actor); - } -} - -void func_80A5475C(EnHeishi2* this, GlobalContext* globalCtx) { - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - - if (Text_GetFaceReaction(globalCtx, 5) != 0) { - if (this->unk_30B == 0) { - if (this->type == 2) { - this->actionFunc = func_80A53278; - return; - } - if (this->type == 5) { - this->actionFunc = func_80A5399C; - return; - } - } - } else if (this->unk_30B != 0) { - if (this->type == 2) { - this->actionFunc = func_80A53278; - return; - } - if (this->type == 5) { - this->actionFunc = func_80A5399C; - return; - } - } - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->type == 2) { - if (this->unk_30E == 1) { - this->actionFunc = func_80A5344C; - return; - } else { - this->actionFunc = func_80A53278; - return; - } - } else if (this->type == 5) { - if (this->unk_300 == TEXT_STATE_DONE) { - this->actionFunc = func_80A5399C; - } - - if (this->unk_300 == TEXT_STATE_EVENT) { - this->actionFunc = func_80A54954; - } - - if (this->unk_300 == TEXT_STATE_CHOICE) { - this->unk_309 = 1; - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - this->actionFunc = func_80A540C0; - } - return; - } - } - - if (((this->type != 2) && (this->type != 5)) || - ((yawDiff = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)), - !(this->actor.xzDistToPlayer > 120.0f)) && - (yawDiff < 0x4300))) { - func_8002F2F4(&this->actor, globalCtx); - } -} - -void func_80A54954(EnHeishi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A549E8; -} - -void func_80A549E8(EnHeishi2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_300 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - if (this->type == 2) { - this->actionFunc = func_80A531E4; - } - if (this->type == 5) { - this->actionFunc = func_80A53908; - } - } -} - -void EnHeishi2_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHeishi2* this = (EnHeishi2*)thisx; - s32 i; - - Actor_SetFocus(&this->actor, this->unk_2E0); - if ((this->type == 2) || (this->type == 5)) { - this->actor.focus.pos.y = 70.0f; - Actor_SetFocus(&this->actor, 70.0f); - func_80038290(globalCtx, &this->actor, &this->unk_260, &this->unk_26C, this->actor.focus.pos); - } - - this->unk_2FC++; - - for (i = 0; i != 5; i++) { - if (this->unk_2F2[i] != 0) { - this->unk_2F2[i]--; - } - } - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - switch (this->type) { - case 6: - break; - case 9: - break; - default: - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 30.0f, 0x1D); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - break; - } -} - -s32 EnHeishi2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnHeishi2* this = (EnHeishi2*)thisx; - - switch (this->type) { - case 1: - break; - case 7: - break; - default: - if (limbIndex == 9) { - rot->x = rot->x + this->unk_26C.y; - } - if (limbIndex == 16) { - rot->x = rot->x + this->unk_260.y; - rot->z = rot->z + this->unk_260.z; - } - } - - return false; -} - -void EnHeishi2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnHeishi2* this = (EnHeishi2*)thisx; - - if (limbIndex == 16) { - Matrix_Get(&this->mtxf_330); - } -} - -void EnHeishi2_DrawKingGuard(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1772); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1774), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gHeishiKingGuardDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1777); -} - -void EnHeishi2_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi2* this = (EnHeishi2*)thisx; - Mtx* mtx; - s32 linkObjBankIndex; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1792); - - func_80093D18(globalCtx->state.gfxCtx); - - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHeishi2_OverrideLimbDraw, - EnHeishi2_PostLimbDraw, this); - if ((this->type == 5) && (gSaveContext.infTable[7] & 0x80)) { - linkObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_LINK_CHILD); - if (linkObjBankIndex >= 0) { - Matrix_Put(&this->mtxf_330); - Matrix_Translate(-570.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateZ(DEGTORAD(70.0), MTXMODE_APPLY); - mtx = POINTER_SUB(Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1820), 7 * sizeof(float[4][4])); - - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[linkObjBankIndex].vromStart); - gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - gSPDisplayList(POLY_OPA_DISP++, gLinkChildKeatonMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->actor.objBankIndex].vromStart); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1834); -} diff --git a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.cpp b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.cpp new file mode 100644 index 000000000..92b6a7f0a --- /dev/null +++ b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.cpp @@ -0,0 +1,880 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI2_Z_EN_HEISHI2_C +#include +#include "actor_common.h" +/* + * File: z_en_heishi2.c + * Overlay: ovl_En_Heishi2 + * Description: Hyrulian Guards + */ + +#include "vt.h" +#include "z_en_heishi2.h" +#include "objects/object_sd/object_sd.h" +#include "objects/object_link_child/object_link_child.h" +#include "overlays/actors/ovl_Bg_Gate_Shutter/z_bg_gate_shutter.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnHeishi2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi2_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnHeishi2_DrawKingGuard(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi2_DoNothing1(EnHeishi2* pthis, GlobalContext* globalCtx); +void EnHeishi_DoNothing2(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A531E4(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53278(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A5344C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A54954(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53538(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A535BC(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A5399C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53638(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A5372C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A5475C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53AD4(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53C0C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53C90(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53D0C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A544AC(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53908(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53F30(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A54038(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A5427C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A549E8(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53850(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A54320(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A543A0(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A5455C(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A546DC(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A541FC(EnHeishi2* pthis, GlobalContext* globalCtx); +void func_80A53DF8(EnHeishi2* pthis, GlobalContext* globalCtx); + +ActorInit En_Heishi2_InitVars = { + ACTOR_EN_HEISHI2, + ACTORCAT_NPC, + FLAGS, + OBJECT_SD, + sizeof(EnHeishi2), + (ActorFunc)EnHeishi2_Init, + (ActorFunc)EnHeishi2_Destroy, + (ActorFunc)EnHeishi2_Update, + (ActorFunc)EnHeishi2_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 33, 40, 0, { 0, 0, 0 } }, +}; + +void EnHeishi2_Init(Actor* thisx, GlobalContext* globalCtx) { + ColliderCylinder* collider; + EnHeishi2* pthis = (EnHeishi2*)thisx; + + Actor_SetScale(&pthis->actor, 0.01f); + pthis->type = pthis->actor.params & 0xFF; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + + if ((pthis->type == 6) || (pthis->type == 9)) { + pthis->actor.draw = EnHeishi2_DrawKingGuard; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, 6); + if (pthis->type == 6) { + pthis->actionFunc = EnHeishi2_DoNothing1; + + } else { + osSyncPrintf("\n\n"); + // "No, I'm completely disappointed" (message for when shooting guard window in courtyard) + osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ いやー ついうっかり ☆☆☆☆☆ \n" VT_RST); + + Actor_SetScale(&pthis->actor, 0.02f); + + pthis->unk_274 = pthis->actor.world.pos; + pthis->actor.world.rot.y = 0x7918; + pthis->actor.world.pos.x += 90.0f; + pthis->actor.world.pos.y -= 60.0f; + pthis->actor.world.pos.z += 90.0f; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + Collider_DestroyCylinder(globalCtx, &pthis->collider); + func_8002DF54(globalCtx, 0, 8); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_4; + pthis->actionFunc = func_80A544AC; + } + } else { + pthis->unk_2E0 = 60.0f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, pthis->jointTable, + pthis->morphTable, 17); + collider = &pthis->collider; + Collider_InitCylinder(globalCtx, collider); + Collider_SetCylinder(globalCtx, collider, &pthis->actor, &sCylinderInit); + pthis->collider.dim.yShift = 0; + pthis->collider.dim.radius = 15; + pthis->collider.dim.height = 70; + pthis->actor.targetMode = 6; + + switch (pthis->type) { + + case 2: + pthis->actionFunc = func_80A531E4; + pthis->actor.gravity = -1.0f; + break; + case 5: + pthis->actionFunc = func_80A53908; + pthis->actor.gravity = -1.0f; + break; + case 6: + osSyncPrintf("\n\n"); + // "Peep hole soldier!" + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 覗き穴奥兵士ふぃ〜 ☆☆☆☆☆ \n" VT_RST); + Collider_DestroyCylinder(globalCtx, collider); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actionFunc = EnHeishi_DoNothing2; + break; + } + + pthis->unk_2F0 = (pthis->actor.params >> 8) & 0xFF; + osSyncPrintf("\n\n"); + // "Soldier Set 2 Completed!" + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 兵士2セット完了! ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params); + // "Identification Completed!" + osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 識別完了! ☆☆☆☆☆ %d\n" VT_RST, pthis->type); + // "Message completed!" + osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ メッセージ完了! ☆☆☆☆☆ %x\n\n" VT_RST, (pthis->actor.params >> 8) & 0xF); + } +} + +void EnHeishi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi2* pthis = (EnHeishi2*)thisx; + + if ((pthis->collider.dim.radius != 0) || (pthis->collider.dim.height != 0)) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void EnHeishi2_DoNothing1(EnHeishi2* pthis, GlobalContext* globalCtx) { +} + +void EnHeishi_DoNothing2(EnHeishi2* pthis, GlobalContext* globalCtx) { +} + +void func_80A531E4(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A53278; +} + +void func_80A53278(EnHeishi2* pthis, GlobalContext* globalCtx) { + pthis->unk_30B = 0; + pthis->unk_30E = 0; + if (Text_GetFaceReaction(globalCtx, 5) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 5); + pthis->unk_30B = 1; + pthis->unk_300 = TEXT_STATE_DONE; + pthis->actionFunc = func_80A5475C; + } else if ((gSaveContext.eventChkInf[0] & 0x200) && (gSaveContext.eventChkInf[2] & 0x20) && + (gSaveContext.eventChkInf[3] & 0x80)) { + // "Get all spiritual stones!" + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 全部の精霊石GET! ☆☆☆☆☆ \n" VT_RST); + pthis->unk_300 = TEXT_STATE_DONE; + pthis->actor.textId = 0x7006; + pthis->actionFunc = func_80A5475C; + } else if (!IS_DAY) { + // "Sleep early for children!" + osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 子供ははやくネロ! ☆☆☆☆☆ \n" VT_RST); + pthis->unk_300 = TEXT_STATE_DONE; + pthis->actor.textId = 0x7002; + pthis->actionFunc = func_80A5475C; + + } else if (pthis->unk_30C != 0) { + // "Anything passes" + osSyncPrintf(VT_FGCOL(BLUE) " ☆☆☆☆☆ なんでも通るよ ☆☆☆☆☆ \n" VT_RST); + pthis->unk_300 = TEXT_STATE_DONE; + pthis->actor.textId = 0x7099; + pthis->actionFunc = func_80A5475C; + } else if (gSaveContext.eventChkInf[1] & 4) { + if (pthis->unk_30E == 0) { + // "Start under the first sleeve!" + osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ 1回目袖の下開始! ☆☆☆☆☆ \n" VT_RST); + pthis->actor.textId = 0x7071; + pthis->unk_30E = 1; + } else { + // "Start under the second sleeve!" + osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ 2回目袖の下開始! ☆☆☆☆☆ \n" VT_RST); + pthis->actor.textId = 0x7072; + } + pthis->unk_300 = TEXT_STATE_CHOICE; + pthis->actionFunc = func_80A5475C; + + } else { + // "That's okay" + osSyncPrintf(VT_FGCOL(CYAN) " ☆☆☆☆☆ それはとおらんよぉ ☆☆☆☆☆ \n" VT_RST); + pthis->unk_300 = TEXT_STATE_DONE; + pthis->actor.textId = 0x7029; + pthis->actionFunc = func_80A5475C; + } +} + +void func_80A5344C(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + pthis->unk_300 = TEXT_STATE_EVENT; + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees >= 10) { + Rupees_ChangeBy(-10); + pthis->actor.textId = 0x7098; + pthis->actionFunc = func_80A53538; + break; + } else { + pthis->actor.textId = 0x7097; + pthis->actionFunc = func_80A54954; + break; + } + case 1: + pthis->actor.textId = 0x7096; + pthis->actionFunc = func_80A54954; + break; + + default: + break; + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } +} + +void func_80A53538(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_300 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + func_8002DF54(globalCtx, NULL, 8); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->actionFunc = func_80A535BC; + } +} + +void func_80A535BC(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiSlamSpearAnim); + + pthis->unk_2EC = frameCount; + Animation_Change(&pthis->skelAnime, &gEnHeishiSlamSpearAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = func_80A53638; +} + +void func_80A53638(EnHeishi2* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 frameCount = pthis->skelAnime.curFrame; + + BgSpot15Saku* actor = (BgSpot15Saku*)globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + + SkelAnime_Update(&pthis->skelAnime); + if ((frameCount >= 12.0f) && (!pthis->audioFlag)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SPEAR_HIT); + pthis->audioFlag = 1; + } + if (pthis->unk_2EC <= frameCount) { + while (actor != NULL) { + if (actor->dyna.actor.id != ACTOR_BG_SPOT15_SAKU) { + actor = (BgSpot15Saku*)(actor->dyna.actor.next); + } else { + pthis->gate = &actor->dyna.actor; + actor->unk_168 = 1; + break; + } + } + // "I've come!" + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆ きたきたきたぁ! ☆☆☆ %x\n" VT_RST, actor->dyna.actor.next); + pthis->actionFunc = func_80A5372C; + } +} + +void func_80A5372C(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->unk_2F2[0] = 200; + pthis->cameraId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cameraId, CAM_STAT_ACTIVE); + pthis->unk_280.x = 947.0f; + pthis->unk_280.y = 1195.0f; + pthis->unk_280.z = 2682.0f; + + pthis->unk_28C.x = 1164.0f; + pthis->unk_28C.y = 1145.0f; + pthis->unk_28C.z = 3014.0f; + + Gameplay_CameraSetAtEye(globalCtx, pthis->cameraId, &pthis->unk_280, &pthis->unk_28C); + pthis->actionFunc = func_80A53850; +} + +void func_80A53850(EnHeishi2* pthis, GlobalContext* globalCtx) { + BgSpot15Saku* gate; + + SkelAnime_Update(&pthis->skelAnime); + Gameplay_CameraSetAtEye(globalCtx, pthis->cameraId, &pthis->unk_280, &pthis->unk_28C); + gate = (BgSpot15Saku*)pthis->gate; + if ((pthis->unk_2F2[0] == 0) || (gate->unk_168 == 0)) { + Gameplay_ClearCamera(globalCtx, pthis->cameraId); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + Message_CloseTextbox(globalCtx); + pthis->unk_30C = 1; + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = func_80A531E4; + } +} + +void func_80A53908(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A5399C; +} + +void func_80A5399C(EnHeishi2* pthis, GlobalContext* globalCtx) { + s16 var; + + pthis->unk_30B = 0; + var = 0; + if (gSaveContext.infTable[7] & 0x40) { + if (!(gSaveContext.infTable[7] & 0x80)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_KEATON) { + if (pthis->unk_309 == 0) { + pthis->actor.textId = 0x200A; + } else { + pthis->actor.textId = 0x200B; + } + pthis->unk_300 = TEXT_STATE_CHOICE; + pthis->unk_30B = 1; + var = 1; + } else { + pthis->actor.textId = 0x2016; + pthis->unk_300 = TEXT_STATE_DONE; + var = 1; + } + } else { + pthis->actor.textId = 0x2020; + pthis->unk_300 = TEXT_STATE_EVENT; + pthis->unk_30E = 0; + } + if (Text_GetFaceReaction(globalCtx, 5) != 0) { + if (var == 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 5); + pthis->unk_30B = 1; + pthis->unk_300 = TEXT_STATE_DONE; + pthis->unk_30E = 0; + } + } + pthis->actionFunc = func_80A5475C; + } else { + // "I don't know" + osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ とおしゃしねぇちゅーの ☆☆☆☆☆ \n" VT_RST); + pthis->actionFunc = func_80A53AD4; + } +} + +void func_80A53AD4(EnHeishi2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 exchangeItemId; + s16 yawDiffTemp; + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + if (Text_GetFaceReaction(globalCtx, 5) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 5); + } else { + pthis->actor.textId = 0x200E; + } + pthis->unk_300 = TEXT_STATE_DONE; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + exchangeItemId = func_8002F368(globalCtx); + if (exchangeItemId == EXCH_ITEM_LETTER_ZELDA) { + func_80078884(NA_SE_SY_CORRECT_CHIME); + player->actor.textId = 0x2010; + pthis->unk_300 = TEXT_STATE_EVENT; + pthis->actionFunc = func_80A53C0C; + } else if (exchangeItemId != EXCH_ITEM_NONE) { + player->actor.textId = 0x200F; + } + } else { + yawDiffTemp = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + yawDiff = ABS(yawDiffTemp); + if (!(120.0f < pthis->actor.xzDistToPlayer) && (yawDiff < 0x4300)) { + func_8002F298(&pthis->actor, globalCtx, 100.0f, EXCH_ITEM_LETTER_ZELDA); + } + } +} + +void func_80A53C0C(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->unk_300 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + func_8002DF54(globalCtx, 0, 8); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->actionFunc = func_80A53C90; + } +} + +void func_80A53C90(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiSlamSpearAnim); + + pthis->unk_2EC = frameCount; + Animation_Change(&pthis->skelAnime, &gEnHeishiSlamSpearAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = func_80A53D0C; +} + +void func_80A53D0C(EnHeishi2* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 frameCount; + BgGateShutter* gate; + + frameCount = pthis->skelAnime.curFrame; + gate = (BgGateShutter*)globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + SkelAnime_Update(&pthis->skelAnime); + if (12.0f <= frameCount) { + if (pthis->audioFlag == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SPEAR_HIT); + pthis->audioFlag = 1; + } + } + if (pthis->unk_2EC <= frameCount) { + while (gate != NULL) { + if (gate->dyna.actor.id != ACTOR_BG_GATE_SHUTTER) { + gate = (BgGateShutter*)gate->dyna.actor.next; + } else { + pthis->gate = &gate->dyna.actor; + gate->openingState = 1; + break; + } + } + // "I've come!" + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆ きたきたきたぁ! ☆☆☆ %x\n" VT_RST, gate->dyna.actor.next); + pthis->actionFunc = func_80A53DF8; + } +} + +void func_80A53DF8(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->unk_2F2[0] = 200; + pthis->cameraId = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cameraId, CAM_STAT_ACTIVE); + pthis->unk_2BC.x = -71.0f; + pthis->unk_280.x = -71.0f; + pthis->unk_2BC.y = 571.0f; + pthis->unk_280.y = 571.0f; + pthis->unk_2BC.z = -1487.0f; + pthis->unk_280.z = -1487.0f; + pthis->unk_298.x = 181.0f; + pthis->unk_28C.x = 181.0f; + pthis->unk_298.y = 417.0f; + pthis->unk_28C.y = 417.0f; + pthis->unk_298.z = -1079.0f; + pthis->unk_28C.z = -1079.0f; + Gameplay_CameraSetAtEye(globalCtx, pthis->cameraId, &pthis->unk_280, &pthis->unk_28C); + pthis->actionFunc = func_80A53F30; +} + +void func_80A53F30(EnHeishi2* pthis, GlobalContext* globalCtx) { + BgGateShutter* gate; + + SkelAnime_Update(&pthis->skelAnime); + Gameplay_CameraSetAtEye(globalCtx, pthis->cameraId, &pthis->unk_280, &pthis->unk_28C); + gate = (BgGateShutter*)pthis->gate; + if ((pthis->unk_2F2[0] == 0) || (gate->openingState == 0)) { + Gameplay_ClearCamera(globalCtx, pthis->cameraId); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + if ((pthis->unk_30A != 2)) { + if (pthis->unk_30A == 0) { + pthis->actor.textId = 0x2015; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->actionFunc = func_80A54038; + } else { + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = func_80A53908; + } + } else { + pthis->unk_30E = 0; + pthis->actor.textId = 0x2021; + Rupees_ChangeBy(15); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->actionFunc = func_80A5427C; + } + } +} + +void func_80A54038(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + gSaveContext.infTable[7] |= 0x40; + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, 0, 7); + pthis->actionFunc = func_80A53908; + } +} + +void func_80A540C0(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + pthis->actor.textId = 0x2020; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + Player_UnsetMask(globalCtx); + gSaveContext.infTable[7] |= 0x80; + gSaveContext.itemGetInf[3] |= 0x100; + Item_Give(globalCtx, ITEM_SOLD_OUT); + if (pthis->unk_30A != 0) { + pthis->unk_30A = 2; + pthis->unk_30E = 1; + pthis->actionFunc = func_80A5427C; + } else { + pthis->unk_30E = 0; + pthis->actionFunc = func_80A541FC; + } + break; + case 1: + pthis->unk_30E = 1; + pthis->actor.textId = 0x200C; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_300 = TEXT_STATE_EVENT; + if (pthis->unk_30A == 0) { + pthis->actionFunc = func_80A5427C; + } else { + pthis->actionFunc = func_80A54954; + } + } + } +} + +void func_80A541FC(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.textId = 0x2021; + Rupees_ChangeBy(15); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->actionFunc = func_80A5427C; + } +} + +void func_80A5427C(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + if (pthis->unk_30E == 0) { + pthis->unk_30E = 0; + pthis->unk_30A = pthis->unk_30E; + Message_CloseTextbox(globalCtx); + pthis->actionFunc = func_80A53908; + } else { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->actionFunc = func_80A54320; + } + } +} + +void func_80A54320(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiSlamSpearAnim); + + pthis->unk_2EC = frameCount; + Animation_Change(&pthis->skelAnime, &gEnHeishiSlamSpearAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -10.0f); + pthis->audioFlag = 0; + pthis->actionFunc = func_80A543A0; +} + +void func_80A543A0(EnHeishi2* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 frameCount = pthis->skelAnime.curFrame; + BgGateShutter* gate = (BgGateShutter*)(globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head); + SkelAnime_Update(&pthis->skelAnime); + + if ((frameCount >= 12.0f) && (!pthis->audioFlag)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_SPEAR_HIT); + pthis->audioFlag = 1; + } + + if (pthis->unk_2EC <= frameCount) { + while (gate != NULL) { + if (ACTOR_BG_GATE_SHUTTER != gate->dyna.actor.id) { + gate = (BgGateShutter*)(gate->dyna.actor.next); + } else { + pthis->gate = &gate->dyna.actor; + if (pthis->unk_30A != 2) { + gate->openingState = -1; + break; + } else { + gate->openingState = 2; + break; + } + } + } + if (pthis->unk_30A == 0) { + pthis->unk_30A = 1; + } + pthis->actionFunc = func_80A53DF8; + } +} + +void func_80A544AC(EnHeishi2* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.z, -6100, 5, pthis->unk_2E4, 0); + Math_ApproachF(&pthis->unk_2E4, 3000.0f, 1.0f, 500.0f); + pthis->actor.world.rot.z = pthis->actor.shape.rot.z; + if (pthis->actor.shape.rot.z < -6000) { + Message_StartTextbox(globalCtx, 0x708F, NULL); + pthis->actor.flags |= ACTOR_FLAG_16; + pthis->actionFunc = func_80A5455C; + pthis->unk_2E4 = 0.0f; + } +} + +void func_80A5455C(EnHeishi2* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + f32 rotY; + EnBom* bomb; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + func_8002DF54(globalCtx, NULL, 7); + Message_CloseTextbox(globalCtx); + + pos.x = Rand_CenteredFloat(20.0f) + pthis->unk_274.x; + pos.y = Rand_CenteredFloat(20.0f) + (pthis->unk_274.y - 40.0f); + pos.z = Rand_CenteredFloat(20.0f) + (pthis->unk_274.z - 20.0f); + rotY = Rand_CenteredFloat(7000.0f) + pthis->actor.yawTowardsPlayer; + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pos.x, pos.y, pos.z, 0, rotY, 0, 0); + if (bomb != NULL) { + bomb->actor.speedXZ = Rand_CenteredFloat(5.0f) + 10.0f; + bomb->actor.velocity.y = Rand_CenteredFloat(5.0f) + 10.0f; + } + + // "This is down!" + osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ これでダウンだ! ☆☆☆☆☆ \n" VT_RST); + pthis->actionFunc = func_80A546DC; + } +} + +void func_80A546DC(EnHeishi2* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.z, 200, 5, pthis->unk_2E4, 0); + Math_ApproachF(&pthis->unk_2E4, 3000.0f, 1.0f, 500.0f); + pthis->actor.world.rot.z = pthis->actor.shape.rot.z; + if (pthis->actor.shape.rot.z > 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_80A5475C(EnHeishi2* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + + if (Text_GetFaceReaction(globalCtx, 5) != 0) { + if (pthis->unk_30B == 0) { + if (pthis->type == 2) { + pthis->actionFunc = func_80A53278; + return; + } + if (pthis->type == 5) { + pthis->actionFunc = func_80A5399C; + return; + } + } + } else if (pthis->unk_30B != 0) { + if (pthis->type == 2) { + pthis->actionFunc = func_80A53278; + return; + } + if (pthis->type == 5) { + pthis->actionFunc = func_80A5399C; + return; + } + } + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->type == 2) { + if (pthis->unk_30E == 1) { + pthis->actionFunc = func_80A5344C; + return; + } else { + pthis->actionFunc = func_80A53278; + return; + } + } else if (pthis->type == 5) { + if (pthis->unk_300 == TEXT_STATE_DONE) { + pthis->actionFunc = func_80A5399C; + } + + if (pthis->unk_300 == TEXT_STATE_EVENT) { + pthis->actionFunc = func_80A54954; + } + + if (pthis->unk_300 == TEXT_STATE_CHOICE) { + pthis->unk_309 = 1; + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + pthis->actionFunc = func_80A540C0; + } + return; + } + } + + if (((pthis->type != 2) && (pthis->type != 5)) || + ((yawDiff = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)), + !(pthis->actor.xzDistToPlayer > 120.0f)) && + (yawDiff < 0x4300))) { + func_8002F2F4(&pthis->actor, globalCtx); + } +} + +void func_80A54954(EnHeishi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A549E8; +} + +void func_80A549E8(EnHeishi2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_300 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + if (pthis->type == 2) { + pthis->actionFunc = func_80A531E4; + } + if (pthis->type == 5) { + pthis->actionFunc = func_80A53908; + } + } +} + +void EnHeishi2_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHeishi2* pthis = (EnHeishi2*)thisx; + s32 i; + + Actor_SetFocus(&pthis->actor, pthis->unk_2E0); + if ((pthis->type == 2) || (pthis->type == 5)) { + pthis->actor.focus.pos.y = 70.0f; + Actor_SetFocus(&pthis->actor, 70.0f); + func_80038290(globalCtx, &pthis->actor, &pthis->unk_260, &pthis->unk_26C, pthis->actor.focus.pos); + } + + pthis->unk_2FC++; + + for (i = 0; i != 5; i++) { + if (pthis->unk_2F2[i] != 0) { + pthis->unk_2F2[i]--; + } + } + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + switch (pthis->type) { + case 6: + break; + case 9: + break; + default: + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 30.0f, 0x1D); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + break; + } +} + +s32 EnHeishi2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnHeishi2* pthis = (EnHeishi2*)thisx; + + switch (pthis->type) { + case 1: + break; + case 7: + break; + default: + if (limbIndex == 9) { + rot->x = rot->x + pthis->unk_26C.y; + } + if (limbIndex == 16) { + rot->x = rot->x + pthis->unk_260.y; + rot->z = rot->z + pthis->unk_260.z; + } + } + + return false; +} + +void EnHeishi2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnHeishi2* pthis = (EnHeishi2*)thisx; + + if (limbIndex == 16) { + Matrix_Get(&pthis->mtxf_330); + } +} + +void EnHeishi2_DrawKingGuard(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1772); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1774), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHeishiKingGuardDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1777); +} + +void EnHeishi2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi2* pthis = (EnHeishi2*)thisx; + Mtx* mtx; + s32 linkObjBankIndex; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1792); + + func_80093D18(globalCtx->state.gfxCtx); + + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnHeishi2_OverrideLimbDraw, + EnHeishi2_PostLimbDraw, pthis); + if ((pthis->type == 5) && (gSaveContext.infTable[7] & 0x80)) { + linkObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_LINK_CHILD); + if (linkObjBankIndex >= 0) { + Matrix_Put(&pthis->mtxf_330); + Matrix_Translate(-570.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZ(DEGTORAD(70.0), MTXMODE_APPLY); + mtx = (Mtx*)POINTER_SUB(Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1820), 7 * sizeof(float[4][4])); + + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[linkObjBankIndex].vromStart.get()); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + gSPDisplayList(POLY_OPA_DISP++, gLinkChildKeatonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->actor.objBankIndex].vromStart.get()); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_heishi2.c", 1834); +} diff --git a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c deleted file mode 100644 index 7bed7b74e..000000000 --- a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c +++ /dev/null @@ -1,262 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI3_Z_EN_HEISHI3_C -#include "actor_common.h" -/* - * File: z_en_heishi3.c - * Overlay: ovl_En_Heishi3 - * Description: Hyrule Castle Guard - */ - -#include "z_en_heishi3.h" -#include "objects/object_sd/object_sd.h" -#include "vt.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void EnHeishi3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi3_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnHeishi3_SetupGuardType(EnHeishi3* this, GlobalContext* globalCtx); -void EnHeishi3_StandSentinelInGrounds(EnHeishi3* this, GlobalContext* globalCtx); -void EnHeishi3_StandSentinelInCastle(EnHeishi3* this, GlobalContext* globalCtx); -void EnHeishi3_CatchStart(EnHeishi3* this, GlobalContext* globalCtx); -void EnHeishi3_ResetAnimationToIdle(EnHeishi3* this, GlobalContext* globalCtx); -void func_80A55D00(EnHeishi3* this, GlobalContext* globalCtx); -void func_80A55BD4(EnHeishi3* this, GlobalContext* globalCtx); - -static s16 sPlayerCaught = 0; - -const ActorInit En_Heishi3_InitVars = { - ACTOR_EN_HEISHI3, - ACTORCAT_NPC, - FLAGS, - OBJECT_SD, - sizeof(EnHeishi3), - (ActorFunc)EnHeishi3_Init, - (ActorFunc)EnHeishi3_Destroy, - (ActorFunc)EnHeishi3_Update, - (ActorFunc)EnHeishi3_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 15, 70, 0, { 0, 0, 0 } }, -}; - -void EnHeishi3_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi3* this = (EnHeishi3*)thisx; - - sPlayerCaught = 0; - if (this->actor.params <= 0) { - this->unk_278 = 0; - } else { - this->unk_278 = 1; - if (this->actor.world.pos.x < -290.0f) { - this->unk_278 = 2; - } - } - Actor_SetScale(&this->actor, 0.01f); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, this->jointTable, this->morphTable, - 17); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.targetMode = 6; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - // "Castle Gate Soldier - Power Up" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 城門兵パワーアップ ☆☆☆☆☆ \n" VT_RST); - - this->actor.gravity = -3.0f; - this->actor.focus.pos = this->actor.world.pos; - this->actionFunc = EnHeishi3_SetupGuardType; -} - -void EnHeishi3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi3* this = (EnHeishi3*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnHeishi3_SetupGuardType(EnHeishi3* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - if (this->unk_278 == 0) { - this->actionFunc = EnHeishi3_StandSentinelInGrounds; - } else { - this->actionFunc = EnHeishi3_StandSentinelInCastle; - } -} - -/** - * Handles the guards standing on Hyrule Castle Grounds. - **/ -void EnHeishi3_StandSentinelInGrounds(EnHeishi3* this, GlobalContext* globalCtx) { - Player* player; - s16 yawDiff; - s16 yawDiffNew; - f32 sightRange; - - player = GET_PLAYER(globalCtx); - SkelAnime_Update(&this->skelAnime); - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - yawDiffNew = ABS(yawDiff); - if (yawDiffNew < 0x4300) { - if (IS_DAY) { - sightRange = 250.0f; - } else { - sightRange = 200.0f; - } - } else { - if (IS_DAY) { - sightRange = 150.0f; - } else { - sightRange = 100.0f; - } - } - if ((this->actor.xzDistToPlayer < sightRange) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) && (sPlayerCaught == 0)) { - sPlayerCaught = 1; - Message_StartTextbox(globalCtx, 0x702D, &this->actor); - func_80078884(NA_SE_SY_FOUND); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" - func_8002DF54(globalCtx, &this->actor, 1); - this->actionFunc = EnHeishi3_CatchStart; - } -} - -/** - * Handles the guards standing in front of Hyrule Castle. - **/ -void EnHeishi3_StandSentinelInCastle(EnHeishi3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - if ((player->actor.world.pos.x < -190.0f) && (player->actor.world.pos.x > -380.0f) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) && - (player->actor.world.pos.z < 1020.0f) && (player->actor.world.pos.z > 700.0f) && (sPlayerCaught == 0)) { - if (this->unk_278 == 1) { - if ((player->actor.world.pos.x < -290.0f)) { - return; - } - } else { - if (player->actor.world.pos.x > -290.0f) { - return; - } - } - sPlayerCaught = 1; - Message_StartTextbox(globalCtx, 0x702D, &this->actor); - func_80078884(NA_SE_SY_FOUND); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" - func_8002DF54(globalCtx, &this->actor, 1); - this->actionFunc = EnHeishi3_CatchStart; - } -} - -void EnHeishi3_CatchStart(EnHeishi3* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiWalkAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiWalkAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->caughtTimer = 20; - this->actionFunc = func_80A55BD4; - this->actor.speedXZ = 2.5f; -} - -void func_80A55BD4(EnHeishi3* this, GlobalContext* globalCtx) { - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KNIGHT_WALK); - } - if (this->caughtTimer == 0) { - this->actionFunc = EnHeishi3_ResetAnimationToIdle; - this->actor.speedXZ = 0.0f; - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 3000, 0); - } -} - -void EnHeishi3_ResetAnimationToIdle(EnHeishi3* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A55D00; -} - -// This function initiates the respawn after the player gets caught. -void func_80A55D00(EnHeishi3* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx) && - (this->respawnFlag == 0)) { - gSaveContext.eventChkInf[4] |= 0x4000; - globalCtx->nextEntranceIndex = 0x47E; // Hyrule Castle from Guard Capture (outside) - globalCtx->sceneLoadFlag = 0x14; - this->respawnFlag = 1; - globalCtx->fadeTransition = 0x2E; - gSaveContext.nextTransition = 0x2E; - } -} - -void EnHeishi3_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi3* this = (EnHeishi3*)thisx; - s32 pad; - - Actor_SetFocus(&this->actor, 60.0f); - this->unk_274 += 1; - if (this->caughtTimer != 0) { - this->caughtTimer -= 1; - } - this->actionFunc(this, globalCtx); - this->actor.shape.rot = this->actor.world.rot; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1C); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnHeishi3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnHeishi3* this = (EnHeishi3*)thisx; - - if (limbIndex == 9) { - rot->x += this->unk_26E; - } - - if (limbIndex == 16) { - rot->x += this->unk_262; - rot->z += this->unk_264; - } - - return false; -} - -void EnHeishi3_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi3* this = (EnHeishi3*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHeishi3_OverrideLimbDraw, NULL, - this); -} diff --git a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.cpp b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.cpp new file mode 100644 index 000000000..78a68cde4 --- /dev/null +++ b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.cpp @@ -0,0 +1,262 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI3_Z_EN_HEISHI3_C +#include "actor_common.h" +/* + * File: z_en_heishi3.c + * Overlay: ovl_En_Heishi3 + * Description: Hyrule Castle Guard + */ + +#include "z_en_heishi3.h" +#include "objects/object_sd/object_sd.h" +#include "vt.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void EnHeishi3_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi3_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi3_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi3_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnHeishi3_SetupGuardType(EnHeishi3* pthis, GlobalContext* globalCtx); +void EnHeishi3_StandSentinelInGrounds(EnHeishi3* pthis, GlobalContext* globalCtx); +void EnHeishi3_StandSentinelInCastle(EnHeishi3* pthis, GlobalContext* globalCtx); +void EnHeishi3_CatchStart(EnHeishi3* pthis, GlobalContext* globalCtx); +void EnHeishi3_ResetAnimationToIdle(EnHeishi3* pthis, GlobalContext* globalCtx); +void func_80A55D00(EnHeishi3* pthis, GlobalContext* globalCtx); +void func_80A55BD4(EnHeishi3* pthis, GlobalContext* globalCtx); + +static s16 sPlayerCaught = 0; + +ActorInit En_Heishi3_InitVars = { + ACTOR_EN_HEISHI3, + ACTORCAT_NPC, + FLAGS, + OBJECT_SD, + sizeof(EnHeishi3), + (ActorFunc)EnHeishi3_Init, + (ActorFunc)EnHeishi3_Destroy, + (ActorFunc)EnHeishi3_Update, + (ActorFunc)EnHeishi3_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 15, 70, 0, { 0, 0, 0 } }, +}; + +void EnHeishi3_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* pthis = (EnHeishi3*)thisx; + + sPlayerCaught = 0; + if (pthis->actor.params <= 0) { + pthis->unk_278 = 0; + } else { + pthis->unk_278 = 1; + if (pthis->actor.world.pos.x < -290.0f) { + pthis->unk_278 = 2; + } + } + Actor_SetScale(&pthis->actor, 0.01f); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, pthis->jointTable, pthis->morphTable, + 17); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.targetMode = 6; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + // "Castle Gate Soldier - Power Up" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 城門兵パワーアップ ☆☆☆☆☆ \n" VT_RST); + + pthis->actor.gravity = -3.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actionFunc = EnHeishi3_SetupGuardType; +} + +void EnHeishi3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* pthis = (EnHeishi3*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnHeishi3_SetupGuardType(EnHeishi3* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + if (pthis->unk_278 == 0) { + pthis->actionFunc = EnHeishi3_StandSentinelInGrounds; + } else { + pthis->actionFunc = EnHeishi3_StandSentinelInCastle; + } +} + +/** + * Handles the guards standing on Hyrule Castle Grounds. + **/ +void EnHeishi3_StandSentinelInGrounds(EnHeishi3* pthis, GlobalContext* globalCtx) { + Player* player; + s16 yawDiff; + s16 yawDiffNew; + f32 sightRange; + + player = GET_PLAYER(globalCtx); + SkelAnime_Update(&pthis->skelAnime); + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + yawDiffNew = ABS(yawDiff); + if (yawDiffNew < 0x4300) { + if (IS_DAY) { + sightRange = 250.0f; + } else { + sightRange = 200.0f; + } + } else { + if (IS_DAY) { + sightRange = 150.0f; + } else { + sightRange = 100.0f; + } + } + if ((pthis->actor.xzDistToPlayer < sightRange) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 100.0f) && (sPlayerCaught == 0)) { + sPlayerCaught = 1; + Message_StartTextbox(globalCtx, 0x702D, &pthis->actor); + func_80078884(NA_SE_SY_FOUND); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->actionFunc = EnHeishi3_CatchStart; + } +} + +/** + * Handles the guards standing in front of Hyrule Castle. + **/ +void EnHeishi3_StandSentinelInCastle(EnHeishi3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + if ((player->actor.world.pos.x < -190.0f) && (player->actor.world.pos.x > -380.0f) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 100.0f) && + (player->actor.world.pos.z < 1020.0f) && (player->actor.world.pos.z > 700.0f) && (sPlayerCaught == 0)) { + if (pthis->unk_278 == 1) { + if ((player->actor.world.pos.x < -290.0f)) { + return; + } + } else { + if (player->actor.world.pos.x > -290.0f) { + return; + } + } + sPlayerCaught = 1; + Message_StartTextbox(globalCtx, 0x702D, &pthis->actor); + func_80078884(NA_SE_SY_FOUND); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" + func_8002DF54(globalCtx, &pthis->actor, 1); + pthis->actionFunc = EnHeishi3_CatchStart; + } +} + +void EnHeishi3_CatchStart(EnHeishi3* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiWalkAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiWalkAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->caughtTimer = 20; + pthis->actionFunc = func_80A55BD4; + pthis->actor.speedXZ = 2.5f; +} + +void func_80A55BD4(EnHeishi3* pthis, GlobalContext* globalCtx) { + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 1.0f) || Animation_OnFrame(&pthis->skelAnime, 17.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KNIGHT_WALK); + } + if (pthis->caughtTimer == 0) { + pthis->actionFunc = EnHeishi3_ResetAnimationToIdle; + pthis->actor.speedXZ = 0.0f; + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 5, 3000, 0); + } +} + +void EnHeishi3_ResetAnimationToIdle(EnHeishi3* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A55D00; +} + +// This function initiates the respawn after the player gets caught. +void func_80A55D00(EnHeishi3* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx) && + (pthis->respawnFlag == 0)) { + gSaveContext.eventChkInf[4] |= 0x4000; + globalCtx->nextEntranceIndex = 0x47E; // Hyrule Castle from Guard Capture (outside) + globalCtx->sceneLoadFlag = 0x14; + pthis->respawnFlag = 1; + globalCtx->fadeTransition = 0x2E; + gSaveContext.nextTransition = 0x2E; + } +} + +void EnHeishi3_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* pthis = (EnHeishi3*)thisx; + s32 pad; + + Actor_SetFocus(&pthis->actor, 60.0f); + pthis->unk_274 += 1; + if (pthis->caughtTimer != 0) { + pthis->caughtTimer -= 1; + } + pthis->actionFunc(pthis, globalCtx); + pthis->actor.shape.rot = pthis->actor.world.rot; + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 50.0f, 0x1C); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnHeishi3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnHeishi3* pthis = (EnHeishi3*)thisx; + + if (limbIndex == 9) { + rot->x += pthis->unk_26E; + } + + if (limbIndex == 16) { + rot->x += pthis->unk_262; + rot->z += pthis->unk_264; + } + + return false; +} + +void EnHeishi3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* pthis = (EnHeishi3*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnHeishi3_OverrideLimbDraw, NULL, + pthis); +} diff --git a/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c b/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c deleted file mode 100644 index e99787e0d..000000000 --- a/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c +++ /dev/null @@ -1,395 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI4_Z_EN_HEISHI4_C -#include "actor_common.h" -#include "z_en_heishi4.h" -#include "objects/object_sd/object_sd.h" -#include "vt.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnHeishi4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi4_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi4_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A56544(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A5673C(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56328(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A563BC(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56B40(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56614(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56874(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56900(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56994(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56A50(EnHeishi4* this, GlobalContext* globalCtx); -void func_80A56ACC(EnHeishi4* this, GlobalContext* globalCtx); - -const ActorInit En_Heishi4_InitVars = { - ACTOR_EN_HEISHI4, - ACTORCAT_NPC, - FLAGS, - OBJECT_SD, - sizeof(EnHeishi4), - (ActorFunc)EnHeishi4_Init, - (ActorFunc)EnHeishi4_Destroy, - (ActorFunc)EnHeishi4_Update, - (ActorFunc)EnHeishi4_Draw, -}; - -static u32 sFaceReactionSets[] = { 6, 7 }; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 33, 40, 0, { 0, 0, 0 } }, -}; - -void EnHeishi4_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi4* this = (EnHeishi4*)thisx; - - Actor_SetScale(thisx, 0.01f); - this->type = thisx->params & 0xFF; - thisx->colChkInfo.mass = MASS_IMMOVABLE; - this->pos = thisx->world.pos; - thisx->targetMode = 6; - if (this->type == HEISHI4_AT_MARKET_DYING) { - this->height = 30.0f; - ActorShape_Init(&thisx->shape, 0.0f, NULL, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gEnHeishiSkel, &gEnHeishiDyingGuardAnim_00C444, this->jointTable, - this->morphTable, 17); - } else { - this->height = 60.0f; - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, this->jointTable, - this->morphTable, 17); - } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - this->collider.dim.yShift = 0; - this->collider.dim.radius = 15; - this->collider.dim.height = 70; - switch (this->type) { - case HEISHI4_AT_KAKRIKO_ENTRANCE: - case HEISHI4_AT_IMPAS_HOUSE: - this->actionFunc = func_80A56328; - break; - case HEISHI4_AT_MARKET_DYING: - this->collider.dim.radius = 28; - this->collider.dim.height = 5; - this->actionFunc = func_80A5673C; - break; - case HEISHI4_AT_MARKET_NIGHT: - this->actionFunc = func_80A56544; - break; - } - this->unk_27C = ((thisx->params >> 8) & 0xFF); - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 兵士2セット完了! ☆☆☆☆☆ %d\n" VT_RST, thisx->params); - osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 識別完了!\t ☆☆☆☆☆ %d\n" VT_RST, this->type); - osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ メッセージ完了! ☆☆☆☆☆ %x\n\n" VT_RST, (thisx->params >> 8) & 0xF); - osSyncPrintf("\n\n"); -} - -void EnHeishi4_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi4* this = (EnHeishi4*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80A56328(EnHeishi4* this, GlobalContext* globalCtx) { - f32 frames = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A563BC; -} - -void func_80A563BC(EnHeishi4* this, GlobalContext* globalCtx) { - s16 reactionOffset; - - this->unk_2B4 = 0; - reactionOffset = this->type - 4; - if (reactionOffset < 0) { - reactionOffset = 0; - } - if (reactionOffset >= 3) { - reactionOffset = 1; - } - if (Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]); - this->unk_2B4 = 1; - this->actionFunc = func_80A56B40; - } else { - if (gSaveContext.eventChkInf[8] & 1) { - this->actor.textId = 0x5065; - this->actionFunc = func_80A56B40; - return; - } - if (gSaveContext.eventChkInf[4] & 0x20) { - this->actor.textId = 0x5068; - this->actionFunc = func_80A56B40; - return; - } - if (this->type == HEISHI4_AT_IMPAS_HOUSE) { - if (this->unk_284 == 0) { - this->actor.textId = 0x5079; - } else { - this->actor.textId = 0x507A; - } - } else if (IS_DAY) { - if (this->unk_284 == 0) { - this->actor.textId = 0x5063; - } else { - this->actor.textId = 0x5064; - } - } else if (this->unk_284 == 0) { - this->actor.textId = 0x5066; - } else { - this->actor.textId = 0x5067; - } - - this->actionFunc = func_80A56B40; - } -} - -void func_80A56544(EnHeishi4* this, GlobalContext* globalCtx) { - f32 frames = Animation_GetLastFrame(&gEnHeishiIdleAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, -10.0f); - if (LINK_AGE_IN_YEARS != YEARS_CHILD) { - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ ぎゃぁ!オトナだー ☆☆☆☆☆ \n" VT_RST); - Actor_Kill(&this->actor); - } else { - this->actionFunc = func_80A56614; - } -} - -void func_80A56614(EnHeishi4* this, GlobalContext* globalCtx) { - s16 reactionOffset; - - reactionOffset = this->type - 4; - this->unk_2B4 = 0; - if (reactionOffset < 0) { - reactionOffset = 0; - } - if (reactionOffset >= 3) { - reactionOffset = 1; - } - if (Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]); - this->unk_2B4 = 1; - this->actionFunc = func_80A56B40; - return; - } - if (globalCtx->sceneNum == SCENE_MIHARIGOYA) { - if (IS_DAY) { - this->actor.textId = 0x7004; - } else { - this->actor.textId = 0x709A; - } - } else if (globalCtx->sceneNum != SCENE_MARKET_NIGHT) { - if (IS_DAY) { - this->actor.textId = 0x7002; - } else { - this->actor.textId = 0x7003; - } - } else { - this->actor.textId = 0x7003; - } - - this->actionFunc = func_80A56B40; -} - -void func_80A5673C(EnHeishi4* this, GlobalContext* globalCtx) { - if (gSaveContext.eventChkInf[4] & 0x20) { - osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ マスターソード祝入手! ☆☆☆☆☆ \n" VT_RST); - Actor_Kill(&this->actor); - return; - } - this->unk_284 = 0; - if (gSaveContext.eventChkInf[8] & 1) { - if (!(gSaveContext.infTable[6] & 0x1000)) { - f32 frames = Animation_GetLastFrame(&gEnHeishiDyingGuardAnim_00C444); - Animation_Change(&this->skelAnime, &gEnHeishiDyingGuardAnim_00C444, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, - -10.0f); - this->actor.textId = 0x7007; - this->unk_282 = TEXT_STATE_EVENT; - this->unk_284 = 1; - osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ デモ開始! ☆☆☆☆☆ \n" VT_RST); - } else { - this->actor.textId = 0x7008; - this->unk_282 = TEXT_STATE_DONE; - osSyncPrintf(VT_FGCOL(BLUE) " ☆☆☆☆☆ 返事なし ☆☆☆☆☆ \n" VT_RST); - } - this->actionFunc = func_80A56874; - } else { - Actor_Kill(&this->actor); - } -} - -void func_80A56874(EnHeishi4* this, GlobalContext* globalCtx) { - if (this->unk_284 != 0) { - SkelAnime_Update(&this->skelAnime); - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->unk_284 == 0) { - this->actionFunc = func_80A5673C; - - } else { - this->actionFunc = func_80A56900; - } - } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } -} - -void func_80A56900(EnHeishi4* this, GlobalContext* globalCtx) { - f32 frames = Animation_GetLastFrame(&gEnHeishiDyingGuardTalkAnim); - - Animation_Change(&this->skelAnime, &gEnHeishiDyingGuardTalkAnim, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A56994; -} - -void func_80A56994(EnHeishi4* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - func_80038290(globalCtx, &this->actor, &this->unk_260, &this->unk_266, this->actor.focus.pos); - if ((this->unk_282 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - gSaveContext.infTable[6] |= 0x1000; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_80A56A50; - } -} - -void func_80A56A50(EnHeishi4* this, GlobalContext* globalCtx) { - f32 frames = Animation_GetLastFrame(&gEnHeishiDyingGuardDieAnim); - - this->unk_288 = frames; - Animation_Change(&this->skelAnime, &gEnHeishiDyingGuardDieAnim, 1.0f, 0.0f, frames, ANIMMODE_ONCE, -10.0f); - this->actionFunc = func_80A56ACC; -} - -void func_80A56ACC(EnHeishi4* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.curFrame; - - SkelAnime_Update(&this->skelAnime); - if (this->unk_288 <= currentFrame) { - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = func_80A5673C; - } -} - -void func_80A56B40(EnHeishi4* this, GlobalContext* globalCtx) { - s16 reactionOffset; - - SkelAnime_Update(&this->skelAnime); - reactionOffset = (this->type - 4); - if (reactionOffset < 0) { - reactionOffset = 0; - } - if (reactionOffset >= 3) { - reactionOffset = 1; - } - if (Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]) != 0) { - if (this->unk_2B4 == 0) { - if ((this->type == HEISHI4_AT_KAKRIKO_ENTRANCE) || (this->type == HEISHI4_AT_IMPAS_HOUSE)) { - this->actionFunc = func_80A563BC; - return; - } - if (this->type == HEISHI4_AT_MARKET_NIGHT) { - this->actionFunc = func_80A56614; - return; - } - } - } else { - if (this->unk_2B4 != 0) { - if ((this->type == HEISHI4_AT_KAKRIKO_ENTRANCE) || (this->type == HEISHI4_AT_IMPAS_HOUSE)) { - this->actionFunc = func_80A563BC; - return; - } - if (this->type == HEISHI4_AT_MARKET_NIGHT) { - this->actionFunc = func_80A56614; - return; - } - } - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if ((this->type == HEISHI4_AT_KAKRIKO_ENTRANCE) || (this->type == HEISHI4_AT_IMPAS_HOUSE)) { - this->unk_284 = 1; - this->actionFunc = func_80A563BC; - return; - } - if (this->type == HEISHI4_AT_MARKET_NIGHT) { - this->actionFunc = func_80A56614; - return; - } - } - func_8002F2F4(&this->actor, globalCtx); -} - -void EnHeishi4_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi4* this = (EnHeishi4*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - thisx->world.pos.x = this->pos.x; - thisx->world.pos.y = this->pos.y; - thisx->world.pos.z = this->pos.z; - Actor_SetFocus(thisx, this->height); - if (this->type != HEISHI4_AT_MARKET_DYING) { - this->unk_28C.unk_18 = player->actor.world.pos; - if (!LINK_IS_ADULT) { - this->unk_28C.unk_18.y = (player->actor.world.pos.y - 10.0f); - } - func_80034A14(thisx, &this->unk_28C, 2, 4); - this->unk_260 = this->unk_28C.unk_08; - this->unk_266 = this->unk_28C.unk_0E; - } - this->unk_27E += 1; - this->actionFunc(this, globalCtx); - Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 10.0f, 10.0f, 30.0f, 0x1D); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnHeishi4* this = (EnHeishi4*)thisx; - - if (limbIndex == 9) { - rot->x += this->unk_266.y; - } - if (limbIndex == 16) { - rot->x += this->unk_260.y; - rot->z += this->unk_260.z; - } - return false; -} - -void EnHeishi4_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHeishi4* this = (EnHeishi4*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHeishi_OverrideLimbDraw, NULL, - this); -} diff --git a/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.cpp b/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.cpp new file mode 100644 index 000000000..a8a40b9dd --- /dev/null +++ b/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.cpp @@ -0,0 +1,395 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HEISHI4_Z_EN_HEISHI4_C +#include "actor_common.h" +#include "z_en_heishi4.h" +#include "objects/object_sd/object_sd.h" +#include "vt.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnHeishi4_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi4_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi4_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi4_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A56544(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A5673C(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56328(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A563BC(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56B40(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56614(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56874(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56900(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56994(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56A50(EnHeishi4* pthis, GlobalContext* globalCtx); +void func_80A56ACC(EnHeishi4* pthis, GlobalContext* globalCtx); + +ActorInit En_Heishi4_InitVars = { + ACTOR_EN_HEISHI4, + ACTORCAT_NPC, + FLAGS, + OBJECT_SD, + sizeof(EnHeishi4), + (ActorFunc)EnHeishi4_Init, + (ActorFunc)EnHeishi4_Destroy, + (ActorFunc)EnHeishi4_Update, + (ActorFunc)EnHeishi4_Draw, +}; + +static u32 sFaceReactionSets[] = { 6, 7 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 33, 40, 0, { 0, 0, 0 } }, +}; + +void EnHeishi4_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi4* pthis = (EnHeishi4*)thisx; + + Actor_SetScale(thisx, 0.01f); + pthis->type = thisx->params & 0xFF; + thisx->colChkInfo.mass = MASS_IMMOVABLE; + pthis->pos = thisx->world.pos; + thisx->targetMode = 6; + if (pthis->type == HEISHI4_AT_MARKET_DYING) { + pthis->height = 30.0f; + ActorShape_Init(&thisx->shape, 0.0f, NULL, 30.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gEnHeishiSkel, &gEnHeishiDyingGuardAnim_00C444, pthis->jointTable, + pthis->morphTable, 17); + } else { + pthis->height = 60.0f; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gEnHeishiSkel, &gEnHeishiIdleAnim, pthis->jointTable, + pthis->morphTable, 17); + } + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + pthis->collider.dim.yShift = 0; + pthis->collider.dim.radius = 15; + pthis->collider.dim.height = 70; + switch (pthis->type) { + case HEISHI4_AT_KAKRIKO_ENTRANCE: + case HEISHI4_AT_IMPAS_HOUSE: + pthis->actionFunc = func_80A56328; + break; + case HEISHI4_AT_MARKET_DYING: + pthis->collider.dim.radius = 28; + pthis->collider.dim.height = 5; + pthis->actionFunc = func_80A5673C; + break; + case HEISHI4_AT_MARKET_NIGHT: + pthis->actionFunc = func_80A56544; + break; + } + pthis->unk_27C = ((thisx->params >> 8) & 0xFF); + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 兵士2セット完了! ☆☆☆☆☆ %d\n" VT_RST, thisx->params); + osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ 識別完了!\t ☆☆☆☆☆ %d\n" VT_RST, pthis->type); + osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ メッセージ完了! ☆☆☆☆☆ %x\n\n" VT_RST, (thisx->params >> 8) & 0xF); + osSyncPrintf("\n\n"); +} + +void EnHeishi4_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi4* pthis = (EnHeishi4*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80A56328(EnHeishi4* pthis, GlobalContext* globalCtx) { + f32 frames = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A563BC; +} + +void func_80A563BC(EnHeishi4* pthis, GlobalContext* globalCtx) { + s16 reactionOffset; + + pthis->unk_2B4 = 0; + reactionOffset = pthis->type - 4; + if (reactionOffset < 0) { + reactionOffset = 0; + } + if (reactionOffset >= 3) { + reactionOffset = 1; + } + if (Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]); + pthis->unk_2B4 = 1; + pthis->actionFunc = func_80A56B40; + } else { + if (gSaveContext.eventChkInf[8] & 1) { + pthis->actor.textId = 0x5065; + pthis->actionFunc = func_80A56B40; + return; + } + if (gSaveContext.eventChkInf[4] & 0x20) { + pthis->actor.textId = 0x5068; + pthis->actionFunc = func_80A56B40; + return; + } + if (pthis->type == HEISHI4_AT_IMPAS_HOUSE) { + if (pthis->unk_284 == 0) { + pthis->actor.textId = 0x5079; + } else { + pthis->actor.textId = 0x507A; + } + } else if (IS_DAY) { + if (pthis->unk_284 == 0) { + pthis->actor.textId = 0x5063; + } else { + pthis->actor.textId = 0x5064; + } + } else if (pthis->unk_284 == 0) { + pthis->actor.textId = 0x5066; + } else { + pthis->actor.textId = 0x5067; + } + + pthis->actionFunc = func_80A56B40; + } +} + +void func_80A56544(EnHeishi4* pthis, GlobalContext* globalCtx) { + f32 frames = Animation_GetLastFrame(&gEnHeishiIdleAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, -10.0f); + if (LINK_AGE_IN_YEARS != YEARS_CHILD) { + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ ぎゃぁ!オトナだー ☆☆☆☆☆ \n" VT_RST); + Actor_Kill(&pthis->actor); + } else { + pthis->actionFunc = func_80A56614; + } +} + +void func_80A56614(EnHeishi4* pthis, GlobalContext* globalCtx) { + s16 reactionOffset; + + reactionOffset = pthis->type - 4; + pthis->unk_2B4 = 0; + if (reactionOffset < 0) { + reactionOffset = 0; + } + if (reactionOffset >= 3) { + reactionOffset = 1; + } + if (Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]); + pthis->unk_2B4 = 1; + pthis->actionFunc = func_80A56B40; + return; + } + if (globalCtx->sceneNum == SCENE_MIHARIGOYA) { + if (IS_DAY) { + pthis->actor.textId = 0x7004; + } else { + pthis->actor.textId = 0x709A; + } + } else if (globalCtx->sceneNum != SCENE_MARKET_NIGHT) { + if (IS_DAY) { + pthis->actor.textId = 0x7002; + } else { + pthis->actor.textId = 0x7003; + } + } else { + pthis->actor.textId = 0x7003; + } + + pthis->actionFunc = func_80A56B40; +} + +void func_80A5673C(EnHeishi4* pthis, GlobalContext* globalCtx) { + if (gSaveContext.eventChkInf[4] & 0x20) { + osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ マスターソード祝入手! ☆☆☆☆☆ \n" VT_RST); + Actor_Kill(&pthis->actor); + return; + } + pthis->unk_284 = 0; + if (gSaveContext.eventChkInf[8] & 1) { + if (!(gSaveContext.infTable[6] & 0x1000)) { + f32 frames = Animation_GetLastFrame(&gEnHeishiDyingGuardAnim_00C444); + Animation_Change(&pthis->skelAnime, &gEnHeishiDyingGuardAnim_00C444, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, + -10.0f); + pthis->actor.textId = 0x7007; + pthis->unk_282 = TEXT_STATE_EVENT; + pthis->unk_284 = 1; + osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ デモ開始! ☆☆☆☆☆ \n" VT_RST); + } else { + pthis->actor.textId = 0x7008; + pthis->unk_282 = TEXT_STATE_DONE; + osSyncPrintf(VT_FGCOL(BLUE) " ☆☆☆☆☆ 返事なし ☆☆☆☆☆ \n" VT_RST); + } + pthis->actionFunc = func_80A56874; + } else { + Actor_Kill(&pthis->actor); + } +} + +void func_80A56874(EnHeishi4* pthis, GlobalContext* globalCtx) { + if (pthis->unk_284 != 0) { + SkelAnime_Update(&pthis->skelAnime); + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->unk_284 == 0) { + pthis->actionFunc = func_80A5673C; + + } else { + pthis->actionFunc = func_80A56900; + } + } else { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } +} + +void func_80A56900(EnHeishi4* pthis, GlobalContext* globalCtx) { + f32 frames = Animation_GetLastFrame(&gEnHeishiDyingGuardTalkAnim); + + Animation_Change(&pthis->skelAnime, &gEnHeishiDyingGuardTalkAnim, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A56994; +} + +void func_80A56994(EnHeishi4* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + func_80038290(globalCtx, &pthis->actor, &pthis->unk_260, &pthis->unk_266, pthis->actor.focus.pos); + if ((pthis->unk_282 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + gSaveContext.infTable[6] |= 0x1000; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_80A56A50; + } +} + +void func_80A56A50(EnHeishi4* pthis, GlobalContext* globalCtx) { + f32 frames = Animation_GetLastFrame(&gEnHeishiDyingGuardDieAnim); + + pthis->unk_288 = frames; + Animation_Change(&pthis->skelAnime, &gEnHeishiDyingGuardDieAnim, 1.0f, 0.0f, frames, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = func_80A56ACC; +} + +void func_80A56ACC(EnHeishi4* pthis, GlobalContext* globalCtx) { + f32 currentFrame = pthis->skelAnime.curFrame; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_288 <= currentFrame) { + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = func_80A5673C; + } +} + +void func_80A56B40(EnHeishi4* pthis, GlobalContext* globalCtx) { + s16 reactionOffset; + + SkelAnime_Update(&pthis->skelAnime); + reactionOffset = (pthis->type - 4); + if (reactionOffset < 0) { + reactionOffset = 0; + } + if (reactionOffset >= 3) { + reactionOffset = 1; + } + if (Text_GetFaceReaction(globalCtx, sFaceReactionSets[reactionOffset]) != 0) { + if (pthis->unk_2B4 == 0) { + if ((pthis->type == HEISHI4_AT_KAKRIKO_ENTRANCE) || (pthis->type == HEISHI4_AT_IMPAS_HOUSE)) { + pthis->actionFunc = func_80A563BC; + return; + } + if (pthis->type == HEISHI4_AT_MARKET_NIGHT) { + pthis->actionFunc = func_80A56614; + return; + } + } + } else { + if (pthis->unk_2B4 != 0) { + if ((pthis->type == HEISHI4_AT_KAKRIKO_ENTRANCE) || (pthis->type == HEISHI4_AT_IMPAS_HOUSE)) { + pthis->actionFunc = func_80A563BC; + return; + } + if (pthis->type == HEISHI4_AT_MARKET_NIGHT) { + pthis->actionFunc = func_80A56614; + return; + } + } + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if ((pthis->type == HEISHI4_AT_KAKRIKO_ENTRANCE) || (pthis->type == HEISHI4_AT_IMPAS_HOUSE)) { + pthis->unk_284 = 1; + pthis->actionFunc = func_80A563BC; + return; + } + if (pthis->type == HEISHI4_AT_MARKET_NIGHT) { + pthis->actionFunc = func_80A56614; + return; + } + } + func_8002F2F4(&pthis->actor, globalCtx); +} + +void EnHeishi4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi4* pthis = (EnHeishi4*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + thisx->world.pos.x = pthis->pos.x; + thisx->world.pos.y = pthis->pos.y; + thisx->world.pos.z = pthis->pos.z; + Actor_SetFocus(thisx, pthis->height); + if (pthis->type != HEISHI4_AT_MARKET_DYING) { + pthis->unk_28C.unk_18 = player->actor.world.pos; + if (!LINK_IS_ADULT) { + pthis->unk_28C.unk_18.y = (player->actor.world.pos.y - 10.0f); + } + func_80034A14(thisx, &pthis->unk_28C, 2, 4); + pthis->unk_260 = pthis->unk_28C.unk_08; + pthis->unk_266 = pthis->unk_28C.unk_0E; + } + pthis->unk_27E += 1; + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 10.0f, 10.0f, 30.0f, 0x1D); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnHeishi4* pthis = (EnHeishi4*)thisx; + + if (limbIndex == 9) { + rot->x += pthis->unk_266.y; + } + if (limbIndex == 16) { + rot->x += pthis->unk_260.y; + rot->z += pthis->unk_260.z; + } + return false; +} + +void EnHeishi4_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi4* pthis = (EnHeishi4*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnHeishi_OverrideLimbDraw, NULL, + pthis); +} diff --git a/src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.c b/src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.c deleted file mode 100644 index 88711ea41..000000000 --- a/src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.c +++ /dev/null @@ -1,553 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HINTNUTS_Z_EN_HINTNUTS_C -#include "actor_common.h" -/* - * File: z_en_hintnuts.c - * Overlay: ovl_En_Hintnuts - * Description: Hint Deku Scrubs (Deku Tree) - */ - -#include "z_en_hintnuts.h" -#include "objects/object_hintnuts/object_hintnuts.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnHintnuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHintnuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHintnuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHintnuts_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnHintnuts_SetupWait(EnHintnuts* this); -void EnHintnuts_Wait(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_LookAround(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_Stand(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_ThrowNut(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_Burrow(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_BeginRun(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_BeginFreeze(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_Run(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_Talk(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_Leave(EnHintnuts* this, GlobalContext* globalCtx); -void EnHintnuts_Freeze(EnHintnuts* this, GlobalContext* globalCtx); - -const ActorInit En_Hintnuts_InitVars = { - ACTOR_EN_HINTNUTS, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_HINTNUTS, - sizeof(EnHintnuts), - (ActorFunc)EnHintnuts_Init, - (ActorFunc)EnHintnuts_Destroy, - (ActorFunc)EnHintnuts_Update, - (ActorFunc)EnHintnuts_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 18, 32, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 1, 18, 32, MASS_HEAVY }; - -static s16 sPuzzleCounter = 0; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x0A, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), -}; - -void EnHintnuts_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHintnuts* this = (EnHintnuts*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - if (this->actor.params == 0xA) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - } else { - ActorShape_Init(&this->actor.shape, 0x0, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gHintNutsSkel, &gHintNutsStandAnim, this->jointTable, - this->morphTable, 10); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Actor_SetTextWithPrefix(globalCtx, &this->actor, (this->actor.params >> 8) & 0xFF); - this->textIdCopy = this->actor.textId; - this->actor.params &= 0xFF; - sPuzzleCounter = 0; - if (this->actor.textId == 0x109B) { - if (Flags_GetClear(globalCtx, 0x9) != 0) { - Actor_Kill(&this->actor); - return; - } - } - EnHintnuts_SetupWait(this); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_HINTNUTS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0xA); - } -} - -void EnHintnuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHintnuts* this = (EnHintnuts*)thisx; - - if (this->actor.params != 0xA) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void EnHintnuts_HitByScrubProjectile1(EnHintnuts* this, GlobalContext* globalCtx) { - if (this->actor.textId != 0 && this->actor.category == ACTORCAT_ENEMY && - ((this->actor.params == 0) || (sPuzzleCounter == 2))) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_BG); - } -} - -void EnHintnuts_SetupWait(EnHintnuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gHintNutsUpAnim, 0.0f); - this->animFlagAndTimer = Rand_S16Offset(100, 50); - this->collider.dim.height = 5; - this->actor.world.pos = this->actor.home.pos; - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnHintnuts_Wait; -} - -void EnHintnuts_SetupLookAround(EnHintnuts* this) { - Animation_PlayLoop(&this->skelAnime, &gHintNutsLookAroundAnim); - this->animFlagAndTimer = 2; - this->actionFunc = EnHintnuts_LookAround; -} - -void EnHintnuts_SetupThrowScrubProjectile(EnHintnuts* this) { - Animation_PlayOnce(&this->skelAnime, &gHintNutsSpitAnim); - this->actionFunc = EnHintnuts_ThrowNut; -} - -void EnHintnuts_SetupStand(EnHintnuts* this) { - Animation_MorphToLoop(&this->skelAnime, &gHintNutsStandAnim, -3.0f); - if (this->actionFunc == EnHintnuts_ThrowNut) { - this->animFlagAndTimer = 2 | 0x1000; // sets timer and flag - } else { - this->animFlagAndTimer = 1; - } - this->actionFunc = EnHintnuts_Stand; -} - -void EnHintnuts_SetupBurrow(EnHintnuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gHintNutsBurrowAnim, -5.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); - this->actionFunc = EnHintnuts_Burrow; -} - -void EnHintnuts_HitByScrubProjectile2(EnHintnuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gHintNutsUnburrowAnim, -3.0f); - this->collider.dim.height = 37; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - this->collider.base.acFlags &= ~AC_ON; - - if (this->actor.params > 0 && this->actor.params < 4 && this->actor.category == ACTORCAT_ENEMY) { - if (sPuzzleCounter == -4) { - sPuzzleCounter = 0; - } - if (this->actor.params == sPuzzleCounter + 1) { - sPuzzleCounter++; - } else { - if (sPuzzleCounter > 0) { - sPuzzleCounter = -sPuzzleCounter; - } - sPuzzleCounter--; - } - this->actor.flags |= ACTOR_FLAG_4; - this->actionFunc = EnHintnuts_BeginFreeze; - } else { - this->actionFunc = EnHintnuts_BeginRun; - } -} - -void EnHintnuts_SetupRun(EnHintnuts* this) { - Animation_PlayLoop(&this->skelAnime, &gHintNutsRunAnim); - this->animFlagAndTimer = 5; - this->actionFunc = EnHintnuts_Run; -} - -void EnHintnuts_SetupTalk(EnHintnuts* this) { - Animation_MorphToLoop(&this->skelAnime, &gHintNutsTalkAnim, -5.0f); - this->actionFunc = EnHintnuts_Talk; - this->actor.speedXZ = 0.0f; -} - -void EnHintnuts_SetupLeave(EnHintnuts* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &gHintNutsRunAnim, -5.0f); - this->actor.speedXZ = 3.0f; - this->animFlagAndTimer = 100; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->collider.base.ocFlags1 &= ~OC1_ON; - this->actor.flags |= ACTOR_FLAG_4; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0x0, 0x0, 0x0, 0x3); // recovery heart - this->actionFunc = EnHintnuts_Leave; -} - -void EnHintnuts_SetupFreeze(EnHintnuts* this) { - Animation_PlayLoop(&this->skelAnime, &gHintNutsFreezeAnim); - this->actor.flags &= ~ACTOR_FLAG_0; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 100); - this->actor.colorFilterTimer = 1; - this->animFlagAndTimer = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_FAINT); - if (sPuzzleCounter == -3) { - func_80078884(NA_SE_SY_ERROR); - sPuzzleCounter = -4; - } - this->actionFunc = EnHintnuts_Freeze; -} - -void EnHintnuts_Wait(EnHintnuts* this, GlobalContext* globalCtx) { - s32 hasSlowPlaybackSpeed = false; - - if (this->skelAnime.playSpeed < 0.5f) { - hasSlowPlaybackSpeed = true; - } - if (hasSlowPlaybackSpeed && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - this->collider.base.acFlags |= AC_ON; - } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - } - - this->collider.dim.height = 5.0f + ((CLAMP(this->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f); - if (!hasSlowPlaybackSpeed && (this->actor.xzDistToPlayer < 120.0f)) { - EnHintnuts_SetupBurrow(this); - } else if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.xzDistToPlayer < 120.0f) { - EnHintnuts_SetupBurrow(this); - } else if ((this->animFlagAndTimer == 0) && (this->actor.xzDistToPlayer > 320.0f)) { - EnHintnuts_SetupLookAround(this); - } else { - EnHintnuts_SetupStand(this); - } - } - if (hasSlowPlaybackSpeed && 160.0f < this->actor.xzDistToPlayer && fabsf(this->actor.yDistToPlayer) < 120.0f && - ((this->animFlagAndTimer == 0) || (this->actor.xzDistToPlayer < 480.0f))) { - this->skelAnime.playSpeed = 1.0f; - } -} - -void EnHintnuts_LookAround(EnHintnuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->animFlagAndTimer != 0) { - this->animFlagAndTimer--; - } - if ((this->actor.xzDistToPlayer < 120.0f) || (this->animFlagAndTimer == 0)) { - EnHintnuts_SetupBurrow(this); - } -} - -void EnHintnuts_Stand(EnHintnuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->animFlagAndTimer != 0) { - this->animFlagAndTimer--; - } - if (!(this->animFlagAndTimer & 0x1000)) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - } - if (this->actor.xzDistToPlayer < 120.0f || this->animFlagAndTimer == 0x1000) { - EnHintnuts_SetupBurrow(this); - } else if (this->animFlagAndTimer == 0) { - EnHintnuts_SetupThrowScrubProjectile(this); - } -} - -void EnHintnuts_ThrowNut(EnHintnuts* this, GlobalContext* globalCtx) { - Vec3f nutPos; - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (this->actor.xzDistToPlayer < 120.0f) { - EnHintnuts_SetupBurrow(this); - } else if (SkelAnime_Update(&this->skelAnime)) { - EnHintnuts_SetupStand(this); - } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - nutPos.x = this->actor.world.pos.x + (Math_SinS(this->actor.shape.rot.y) * 23.0f); - nutPos.y = this->actor.world.pos.y + 12.0f; - nutPos.z = this->actor.world.pos.z + (Math_CosS(this->actor.shape.rot.y) * 23.0f); - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, nutPos.x, nutPos.y, nutPos.z, - this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 1) != NULL) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); - } - } -} - -void EnHintnuts_Burrow(EnHintnuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnHintnuts_SetupWait(this); - } else { - this->collider.dim.height = 5.0f + ((3.0f - CLAMP(this->skelAnime.curFrame, 1.0f, 3.0f)) * 12.0f); - } - if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - this->collider.base.acFlags &= ~AC_ON; - } - - Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.5f, 3.0f); - Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.5f, 3.0f); -} - -void EnHintnuts_BeginRun(EnHintnuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_196 = this->actor.yawTowardsPlayer + 0x8000; - EnHintnuts_SetupRun(this); - } - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); -} - -void EnHintnuts_BeginFreeze(EnHintnuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnHintnuts_SetupFreeze(this); - } -} - -void EnHintnuts_CheckProximity(EnHintnuts* this, GlobalContext* globalCtx) { - if (this->actor.category != ACTORCAT_ENEMY) { - if ((this->collider.base.ocFlags1 & OC1_HIT) || this->actor.isTargeted) { - this->actor.flags |= ACTOR_FLAG_16; - } else { - this->actor.flags &= ~ACTOR_FLAG_16; - } - if (this->actor.xzDistToPlayer < 130.0f) { - this->actor.textId = this->textIdCopy; - func_8002F2F4(&this->actor, globalCtx); - } - } -} - -void EnHintnuts_Run(EnHintnuts* this, GlobalContext* globalCtx) { - s32 temp_ret; - s16 diffRotInit; - s16 diffRot; - f32 phi_f0; - - SkelAnime_Update(&this->skelAnime); - temp_ret = Animation_OnFrame(&this->skelAnime, 0.0f); - if (temp_ret != 0 && this->animFlagAndTimer != 0) { - this->animFlagAndTimer--; - } - if ((temp_ret != 0) || (Animation_OnFrame(&this->skelAnime, 6.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - - Math_StepToF(&this->actor.speedXZ, 7.5f, 1.0f); - if (Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_196, 1, 0xE38, 0xB6) == 0) { - if (this->actor.bgCheckFlags & 0x20) { - this->unk_196 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - } else if (this->actor.bgCheckFlags & 8) { - this->unk_196 = this->actor.wallYaw; - } else if (this->animFlagAndTimer == 0) { - diffRotInit = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - diffRot = diffRotInit - this->actor.yawTowardsPlayer; - if (ABS(diffRot) >= 0x2001) { - this->unk_196 = diffRotInit; - } else { - phi_f0 = (0.0f <= (f32)diffRot) ? 1.0f : -1.0f; - this->unk_196 = (s16)((phi_f0 * -8192.0f) + (f32)this->actor.yawTowardsPlayer); - } - } else { - this->unk_196 = (s16)(this->actor.yawTowardsPlayer + 0x8000); - } - } - - this->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - EnHintnuts_SetupTalk(this); - } else if (this->animFlagAndTimer == 0 && Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 20.0f && - fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f) { - this->actor.speedXZ = 0.0f; - if (this->actor.category == ACTORCAT_BG) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_16); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - } - EnHintnuts_SetupBurrow(this); - } else { - EnHintnuts_CheckProximity(this, globalCtx); - } -} - -void EnHintnuts_Talk(EnHintnuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x3, 0x400, 0x100); - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { - EnHintnuts_SetupLeave(this, globalCtx); - } -} - -void EnHintnuts_Leave(EnHintnuts* this, GlobalContext* globalCtx) { - s16 temp_a1; - - SkelAnime_Update(&this->skelAnime); - if (this->animFlagAndTimer != 0) { - this->animFlagAndTimer--; - } - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); - } - if (this->actor.bgCheckFlags & 8) { - temp_a1 = this->actor.wallYaw; - } else { - temp_a1 = this->actor.yawTowardsPlayer - Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000; - if (ABS(temp_a1) >= 0x4001) { - temp_a1 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; - } else { - temp_a1 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - (temp_a1 >> 1) + 0x8000; - } - } - Math_ScaledStepToS(&this->actor.shape.rot.y, temp_a1, 0x800); - this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->animFlagAndTimer == 0) || (this->actor.projectedPos.z < 0.0f)) { - Message_CloseTextbox(globalCtx); - if (this->actor.params == 3) { - Flags_SetClear(globalCtx, this->actor.room); - sPuzzleCounter = 3; - } - if (this->actor.child != NULL) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, this->actor.child, ACTORCAT_PROP); - } - Actor_Kill(&this->actor); - } -} - -void EnHintnuts_Freeze(EnHintnuts* this, GlobalContext* globalCtx) { - this->actor.colorFilterTimer = 1; - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_FAINT); - } - if (this->animFlagAndTimer == 0) { - if (sPuzzleCounter == 3) { - if (this->actor.child != NULL) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, this->actor.child, ACTORCAT_PROP); - } - this->animFlagAndTimer = 1; - } else if (sPuzzleCounter == -4) { - this->animFlagAndTimer = 2; - } - } else if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 35.0f, 7.0f) != 0) { - if (this->animFlagAndTimer == 1) { - Actor_Kill(&this->actor); - } else { - this->actor.flags |= ACTOR_FLAG_0; - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.colChkInfo.health = sColChkInfoInit.health; - this->actor.colorFilterTimer = 0; - EnHintnuts_SetupWait(this); - } - } -} - -void EnHintnuts_ColliderCheck(EnHintnuts* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if (this->collider.base.ac->id != ACTOR_EN_NUTSBALL) { - EnHintnuts_SetupBurrow(this); - } else { - EnHintnuts_HitByScrubProjectile1(this, globalCtx); - EnHintnuts_HitByScrubProjectile2(this); - } - } else if (globalCtx->actorCtx.unk_02 != 0) { - EnHintnuts_HitByScrubProjectile1(this, globalCtx); - EnHintnuts_HitByScrubProjectile2(this); - } -} - -void EnHintnuts_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHintnuts* this = (EnHintnuts*)thisx; - s32 pad; - - if (this->actor.params != 0xA) { - EnHintnuts_ColliderCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - if (this->actionFunc != EnHintnuts_Freeze && this->actionFunc != EnHintnuts_BeginFreeze) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, - this->collider.dim.height, 0x1D); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actionFunc == EnHintnuts_Wait) { - Actor_SetFocus(&this->actor, this->skelAnime.curFrame); - } else if (this->actionFunc == EnHintnuts_Burrow) { - Actor_SetFocus(&this->actor, - 20.0f - ((this->skelAnime.curFrame * 20.0f) / Animation_GetLastFrame(&gHintNutsBurrowAnim))); - } else { - Actor_SetFocus(&this->actor, 20.0f); - } - } -} - -s32 EnHintnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - Vec3f vec; - f32 curFrame; - EnHintnuts* this = (EnHintnuts*)thisx; - - if (limbIndex == 5 && this->actionFunc == EnHintnuts_ThrowNut) { - curFrame = this->skelAnime.curFrame; - if (curFrame <= 6.0f) { - vec.y = 1.0f - (curFrame * 0.0833f); - vec.z = 1.0f + (curFrame * 0.1167f); - vec.x = 1.0f + (curFrame * 0.1167f); - } else if (curFrame <= 7.0f) { - curFrame -= 6.0f; - vec.y = 0.5f + curFrame; - vec.z = 1.7f - (curFrame * 0.7f); - vec.x = 1.7f - (curFrame * 0.7f); - } else if (curFrame <= 10.0f) { - vec.y = 1.5f - ((curFrame - 7.0f) * 0.1667f); - vec.z = 1.0f; - vec.x = 1.0f; - } else { - return false; - } - Matrix_Scale(vec.x, vec.y, vec.z, MTXMODE_APPLY); - } - return false; -} - -void EnHintnuts_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHintnuts* this = (EnHintnuts*)thisx; - - if (this->actor.params == 0xA) { - Gfx_DrawDListOpa(globalCtx, gHintNutsFlowerDL); - } else { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintnuts_OverrideLimbDraw, - NULL, this); - } -} diff --git a/src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.cpp b/src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.cpp new file mode 100644 index 000000000..be2f54522 --- /dev/null +++ b/src/overlays/actors/ovl_En_Hintnuts/z_en_hintnuts.cpp @@ -0,0 +1,553 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HINTNUTS_Z_EN_HINTNUTS_C +#include "actor_common.h" +/* + * File: z_en_hintnuts.c + * Overlay: ovl_En_Hintnuts + * Description: Hint Deku Scrubs (Deku Tree) + */ + +#include "z_en_hintnuts.h" +#include "objects/object_hintnuts/object_hintnuts.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnHintnuts_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHintnuts_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHintnuts_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHintnuts_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnHintnuts_SetupWait(EnHintnuts* pthis); +void EnHintnuts_Wait(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_LookAround(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_Stand(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_ThrowNut(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_Burrow(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_BeginRun(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_BeginFreeze(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_Run(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_Talk(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_Leave(EnHintnuts* pthis, GlobalContext* globalCtx); +void EnHintnuts_Freeze(EnHintnuts* pthis, GlobalContext* globalCtx); + +ActorInit En_Hintnuts_InitVars = { + ACTOR_EN_HINTNUTS, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_HINTNUTS, + sizeof(EnHintnuts), + (ActorFunc)EnHintnuts_Init, + (ActorFunc)EnHintnuts_Destroy, + (ActorFunc)EnHintnuts_Update, + (ActorFunc)EnHintnuts_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 18, 32, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 1, 18, 32, MASS_HEAVY }; + +static s16 sPuzzleCounter = 0; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x0A, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), +}; + +void EnHintnuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHintnuts* pthis = (EnHintnuts*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + if (pthis->actor.params == 0xA) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + } else { + ActorShape_Init(&pthis->actor.shape, 0x0, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gHintNutsSkel, &gHintNutsStandAnim, pthis->jointTable, + pthis->morphTable, 10); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + Actor_SetTextWithPrefix(globalCtx, &pthis->actor, (pthis->actor.params >> 8) & 0xFF); + pthis->textIdCopy = pthis->actor.textId; + pthis->actor.params &= 0xFF; + sPuzzleCounter = 0; + if (pthis->actor.textId == 0x109B) { + if (Flags_GetClear(globalCtx, 0x9) != 0) { + Actor_Kill(&pthis->actor); + return; + } + } + EnHintnuts_SetupWait(pthis); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_HINTNUTS, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, pthis->actor.world.rot.y, 0, 0xA); + } +} + +void EnHintnuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHintnuts* pthis = (EnHintnuts*)thisx; + + if (pthis->actor.params != 0xA) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void EnHintnuts_HitByScrubProjectile1(EnHintnuts* pthis, GlobalContext* globalCtx) { + if (pthis->actor.textId != 0 && pthis->actor.category == ACTORCAT_ENEMY && + ((pthis->actor.params == 0) || (sPuzzleCounter == 2))) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_BG); + } +} + +void EnHintnuts_SetupWait(EnHintnuts* pthis) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gHintNutsUpAnim, 0.0f); + pthis->animFlagAndTimer = Rand_S16Offset(100, 50); + pthis->collider.dim.height = 5; + pthis->actor.world.pos = pthis->actor.home.pos; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnHintnuts_Wait; +} + +void EnHintnuts_SetupLookAround(EnHintnuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gHintNutsLookAroundAnim); + pthis->animFlagAndTimer = 2; + pthis->actionFunc = EnHintnuts_LookAround; +} + +void EnHintnuts_SetupThrowScrubProjectile(EnHintnuts* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gHintNutsSpitAnim); + pthis->actionFunc = EnHintnuts_ThrowNut; +} + +void EnHintnuts_SetupStand(EnHintnuts* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gHintNutsStandAnim, -3.0f); + if (pthis->actionFunc == EnHintnuts_ThrowNut) { + pthis->animFlagAndTimer = 2 | 0x1000; // sets timer and flag + } else { + pthis->animFlagAndTimer = 1; + } + pthis->actionFunc = EnHintnuts_Stand; +} + +void EnHintnuts_SetupBurrow(EnHintnuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gHintNutsBurrowAnim, -5.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DOWN); + pthis->actionFunc = EnHintnuts_Burrow; +} + +void EnHintnuts_HitByScrubProjectile2(EnHintnuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gHintNutsUnburrowAnim, -3.0f); + pthis->collider.dim.height = 37; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DAMAGE); + pthis->collider.base.acFlags &= ~AC_ON; + + if (pthis->actor.params > 0 && pthis->actor.params < 4 && pthis->actor.category == ACTORCAT_ENEMY) { + if (sPuzzleCounter == -4) { + sPuzzleCounter = 0; + } + if (pthis->actor.params == sPuzzleCounter + 1) { + sPuzzleCounter++; + } else { + if (sPuzzleCounter > 0) { + sPuzzleCounter = -sPuzzleCounter; + } + sPuzzleCounter--; + } + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->actionFunc = EnHintnuts_BeginFreeze; + } else { + pthis->actionFunc = EnHintnuts_BeginRun; + } +} + +void EnHintnuts_SetupRun(EnHintnuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gHintNutsRunAnim); + pthis->animFlagAndTimer = 5; + pthis->actionFunc = EnHintnuts_Run; +} + +void EnHintnuts_SetupTalk(EnHintnuts* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gHintNutsTalkAnim, -5.0f); + pthis->actionFunc = EnHintnuts_Talk; + pthis->actor.speedXZ = 0.0f; +} + +void EnHintnuts_SetupLeave(EnHintnuts* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &gHintNutsRunAnim, -5.0f); + pthis->actor.speedXZ = 3.0f; + pthis->animFlagAndTimer = 100; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->collider.base.ocFlags1 &= ~OC1_ON; + pthis->actor.flags |= ACTOR_FLAG_4; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0x0, 0x0, 0x0, 0x3); // recovery heart + pthis->actionFunc = EnHintnuts_Leave; +} + +void EnHintnuts_SetupFreeze(EnHintnuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gHintNutsFreezeAnim); + pthis->actor.flags &= ~ACTOR_FLAG_0; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 100); + pthis->actor.colorFilterTimer = 1; + pthis->animFlagAndTimer = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_FAINT); + if (sPuzzleCounter == -3) { + func_80078884(NA_SE_SY_ERROR); + sPuzzleCounter = -4; + } + pthis->actionFunc = EnHintnuts_Freeze; +} + +void EnHintnuts_Wait(EnHintnuts* pthis, GlobalContext* globalCtx) { + s32 hasSlowPlaybackSpeed = false; + + if (pthis->skelAnime.playSpeed < 0.5f) { + hasSlowPlaybackSpeed = true; + } + if (hasSlowPlaybackSpeed && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + pthis->collider.base.acFlags |= AC_ON; + } else if (Animation_OnFrame(&pthis->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + } + + pthis->collider.dim.height = 5.0f + ((CLAMP(pthis->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f); + if (!hasSlowPlaybackSpeed && (pthis->actor.xzDistToPlayer < 120.0f)) { + EnHintnuts_SetupBurrow(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.xzDistToPlayer < 120.0f) { + EnHintnuts_SetupBurrow(pthis); + } else if ((pthis->animFlagAndTimer == 0) && (pthis->actor.xzDistToPlayer > 320.0f)) { + EnHintnuts_SetupLookAround(pthis); + } else { + EnHintnuts_SetupStand(pthis); + } + } + if (hasSlowPlaybackSpeed && 160.0f < pthis->actor.xzDistToPlayer && fabsf(pthis->actor.yDistToPlayer) < 120.0f && + ((pthis->animFlagAndTimer == 0) || (pthis->actor.xzDistToPlayer < 480.0f))) { + pthis->skelAnime.playSpeed = 1.0f; + } +} + +void EnHintnuts_LookAround(EnHintnuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->animFlagAndTimer != 0) { + pthis->animFlagAndTimer--; + } + if ((pthis->actor.xzDistToPlayer < 120.0f) || (pthis->animFlagAndTimer == 0)) { + EnHintnuts_SetupBurrow(pthis); + } +} + +void EnHintnuts_Stand(EnHintnuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->animFlagAndTimer != 0) { + pthis->animFlagAndTimer--; + } + if (!(pthis->animFlagAndTimer & 0x1000)) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + } + if (pthis->actor.xzDistToPlayer < 120.0f || pthis->animFlagAndTimer == 0x1000) { + EnHintnuts_SetupBurrow(pthis); + } else if (pthis->animFlagAndTimer == 0) { + EnHintnuts_SetupThrowScrubProjectile(pthis); + } +} + +void EnHintnuts_ThrowNut(EnHintnuts* pthis, GlobalContext* globalCtx) { + Vec3f nutPos; + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + if (pthis->actor.xzDistToPlayer < 120.0f) { + EnHintnuts_SetupBurrow(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime)) { + EnHintnuts_SetupStand(pthis); + } else if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + nutPos.x = pthis->actor.world.pos.x + (Math_SinS(pthis->actor.shape.rot.y) * 23.0f); + nutPos.y = pthis->actor.world.pos.y + 12.0f; + nutPos.z = pthis->actor.world.pos.z + (Math_CosS(pthis->actor.shape.rot.y) * 23.0f); + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, nutPos.x, nutPos.y, nutPos.z, + pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 1) != NULL) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_THROW); + } + } +} + +void EnHintnuts_Burrow(EnHintnuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnHintnuts_SetupWait(pthis); + } else { + pthis->collider.dim.height = 5.0f + ((3.0f - CLAMP(pthis->skelAnime.curFrame, 1.0f, 3.0f)) * 12.0f); + } + if (Animation_OnFrame(&pthis->skelAnime, 4.0f)) { + pthis->collider.base.acFlags &= ~AC_ON; + } + + Math_ApproachF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 0.5f, 3.0f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 0.5f, 3.0f); +} + +void EnHintnuts_BeginRun(EnHintnuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_196 = pthis->actor.yawTowardsPlayer + 0x8000; + EnHintnuts_SetupRun(pthis); + } + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); +} + +void EnHintnuts_BeginFreeze(EnHintnuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnHintnuts_SetupFreeze(pthis); + } +} + +void EnHintnuts_CheckProximity(EnHintnuts* pthis, GlobalContext* globalCtx) { + if (pthis->actor.category != ACTORCAT_ENEMY) { + if ((pthis->collider.base.ocFlags1 & OC1_HIT) || pthis->actor.isTargeted) { + pthis->actor.flags |= ACTOR_FLAG_16; + } else { + pthis->actor.flags &= ~ACTOR_FLAG_16; + } + if (pthis->actor.xzDistToPlayer < 130.0f) { + pthis->actor.textId = pthis->textIdCopy; + func_8002F2F4(&pthis->actor, globalCtx); + } + } +} + +void EnHintnuts_Run(EnHintnuts* pthis, GlobalContext* globalCtx) { + s32 temp_ret; + s16 diffRotInit; + s16 diffRot; + f32 phi_f0; + + SkelAnime_Update(&pthis->skelAnime); + temp_ret = Animation_OnFrame(&pthis->skelAnime, 0.0f); + if (temp_ret != 0 && pthis->animFlagAndTimer != 0) { + pthis->animFlagAndTimer--; + } + if ((temp_ret != 0) || (Animation_OnFrame(&pthis->skelAnime, 6.0f))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + + Math_StepToF(&pthis->actor.speedXZ, 7.5f, 1.0f); + if (Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_196, 1, 0xE38, 0xB6) == 0) { + if (pthis->actor.bgCheckFlags & 0x20) { + pthis->unk_196 = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + } else if (pthis->actor.bgCheckFlags & 8) { + pthis->unk_196 = pthis->actor.wallYaw; + } else if (pthis->animFlagAndTimer == 0) { + diffRotInit = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + diffRot = diffRotInit - pthis->actor.yawTowardsPlayer; + if (ABS(diffRot) >= 0x2001) { + pthis->unk_196 = diffRotInit; + } else { + phi_f0 = (0.0f <= (f32)diffRot) ? 1.0f : -1.0f; + pthis->unk_196 = (s16)((phi_f0 * -8192.0f) + (f32)pthis->actor.yawTowardsPlayer); + } + } else { + pthis->unk_196 = (s16)(pthis->actor.yawTowardsPlayer + 0x8000); + } + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + EnHintnuts_SetupTalk(pthis); + } else if (pthis->animFlagAndTimer == 0 && Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) < 20.0f && + fabsf(pthis->actor.world.pos.y - pthis->actor.home.pos.y) < 2.0f) { + pthis->actor.speedXZ = 0.0f; + if (pthis->actor.category == ACTORCAT_BG) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_16); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + } + EnHintnuts_SetupBurrow(pthis); + } else { + EnHintnuts_CheckProximity(pthis, globalCtx); + } +} + +void EnHintnuts_Talk(EnHintnuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0x3, 0x400, 0x100); + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { + EnHintnuts_SetupLeave(pthis, globalCtx); + } +} + +void EnHintnuts_Leave(EnHintnuts* pthis, GlobalContext* globalCtx) { + s16 temp_a1; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->animFlagAndTimer != 0) { + pthis->animFlagAndTimer--; + } + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_WALK); + } + if (pthis->actor.bgCheckFlags & 8) { + temp_a1 = pthis->actor.wallYaw; + } else { + temp_a1 = pthis->actor.yawTowardsPlayer - Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000; + if (ABS(temp_a1) >= 0x4001) { + temp_a1 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + } else { + temp_a1 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - (temp_a1 >> 1) + 0x8000; + } + } + Math_ScaledStepToS(&pthis->actor.shape.rot.y, temp_a1, 0x800); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if ((pthis->animFlagAndTimer == 0) || (pthis->actor.projectedPos.z < 0.0f)) { + Message_CloseTextbox(globalCtx); + if (pthis->actor.params == 3) { + Flags_SetClear(globalCtx, pthis->actor.room); + sPuzzleCounter = 3; + } + if (pthis->actor.child != NULL) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, pthis->actor.child, ACTORCAT_PROP); + } + Actor_Kill(&pthis->actor); + } +} + +void EnHintnuts_Freeze(EnHintnuts* pthis, GlobalContext* globalCtx) { + pthis->actor.colorFilterTimer = 1; + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_FAINT); + } + if (pthis->animFlagAndTimer == 0) { + if (sPuzzleCounter == 3) { + if (pthis->actor.child != NULL) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, pthis->actor.child, ACTORCAT_PROP); + } + pthis->animFlagAndTimer = 1; + } else if (sPuzzleCounter == -4) { + pthis->animFlagAndTimer = 2; + } + } else if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y - 35.0f, 7.0f) != 0) { + if (pthis->animFlagAndTimer == 1) { + Actor_Kill(&pthis->actor); + } else { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.colChkInfo.health = sColChkInfoInit.health; + pthis->actor.colorFilterTimer = 0; + EnHintnuts_SetupWait(pthis); + } + } +} + +void EnHintnuts_ColliderCheck(EnHintnuts* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if (pthis->collider.base.ac->id != ACTOR_EN_NUTSBALL) { + EnHintnuts_SetupBurrow(pthis); + } else { + EnHintnuts_HitByScrubProjectile1(pthis, globalCtx); + EnHintnuts_HitByScrubProjectile2(pthis); + } + } else if (globalCtx->actorCtx.unk_02 != 0) { + EnHintnuts_HitByScrubProjectile1(pthis, globalCtx); + EnHintnuts_HitByScrubProjectile2(pthis); + } +} + +void EnHintnuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHintnuts* pthis = (EnHintnuts*)thisx; + s32 pad; + + if (pthis->actor.params != 0xA) { + EnHintnuts_ColliderCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc != EnHintnuts_Freeze && pthis->actionFunc != EnHintnuts_BeginFreeze) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, pthis->collider.dim.radius, + pthis->collider.dim.height, 0x1D); + } + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actionFunc == EnHintnuts_Wait) { + Actor_SetFocus(&pthis->actor, pthis->skelAnime.curFrame); + } else if (pthis->actionFunc == EnHintnuts_Burrow) { + Actor_SetFocus(&pthis->actor, + 20.0f - ((pthis->skelAnime.curFrame * 20.0f) / Animation_GetLastFrame(&gHintNutsBurrowAnim))); + } else { + Actor_SetFocus(&pthis->actor, 20.0f); + } + } +} + +s32 EnHintnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + Vec3f vec; + f32 curFrame; + EnHintnuts* pthis = (EnHintnuts*)thisx; + + if (limbIndex == 5 && pthis->actionFunc == EnHintnuts_ThrowNut) { + curFrame = pthis->skelAnime.curFrame; + if (curFrame <= 6.0f) { + vec.y = 1.0f - (curFrame * 0.0833f); + vec.z = 1.0f + (curFrame * 0.1167f); + vec.x = 1.0f + (curFrame * 0.1167f); + } else if (curFrame <= 7.0f) { + curFrame -= 6.0f; + vec.y = 0.5f + curFrame; + vec.z = 1.7f - (curFrame * 0.7f); + vec.x = 1.7f - (curFrame * 0.7f); + } else if (curFrame <= 10.0f) { + vec.y = 1.5f - ((curFrame - 7.0f) * 0.1667f); + vec.z = 1.0f; + vec.x = 1.0f; + } else { + return false; + } + Matrix_Scale(vec.x, vec.y, vec.z, MTXMODE_APPLY); + } + return false; +} + +void EnHintnuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHintnuts* pthis = (EnHintnuts*)thisx; + + if (pthis->actor.params == 0xA) { + Gfx_DrawDListOpa(globalCtx, gHintNutsFlowerDL); + } else { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnHintnuts_OverrideLimbDraw, + NULL, pthis); + } +} diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.cpp similarity index 56% rename from src/overlays/actors/ovl_En_Holl/z_en_holl.c rename to src/overlays/actors/ovl_En_Holl/z_en_holl.cpp index 354206cb9..6ac87fd01 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.cpp @@ -24,15 +24,15 @@ void EnHoll_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHoll_Update(Actor* thisx, GlobalContext* globalCtx); void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnHoll_NextAction(EnHoll* this, GlobalContext* globalCtx); -void func_80A58DD4(EnHoll* this, GlobalContext* globalCtx); -void func_80A59014(EnHoll* this, GlobalContext* globalCtx); -void func_80A591C0(EnHoll* this, GlobalContext* globalCtx); -void func_80A593A4(EnHoll* this, GlobalContext* globalCtx); -void func_80A59520(EnHoll* this, GlobalContext* globalCtx); -void func_80A59618(EnHoll* this, GlobalContext* globalCtx); +void EnHoll_NextAction(EnHoll* pthis, GlobalContext* globalCtx); +void func_80A58DD4(EnHoll* pthis, GlobalContext* globalCtx); +void func_80A59014(EnHoll* pthis, GlobalContext* globalCtx); +void func_80A591C0(EnHoll* pthis, GlobalContext* globalCtx); +void func_80A593A4(EnHoll* pthis, GlobalContext* globalCtx); +void func_80A59520(EnHoll* pthis, GlobalContext* globalCtx); +void func_80A59618(EnHoll* pthis, GlobalContext* globalCtx); -const ActorInit En_Holl_InitVars = { +ActorInit En_Holl_InitVars = { ACTOR_EN_HOLL, ACTORCAT_DOOR, FLAGS, @@ -58,12 +58,12 @@ static InitChainEntry sInitChain[] = { * These are all absolute distances in the relative z direction. That is, moving * towards or away from the "face" of the loading plane regardless of orientation. * Moving within these distances of the load plane have the following effects: - * [0] : Load the room on this side of the loading plane if not already loaded + * [0] : Load the room on pthis side of the loading plane if not already loaded * [1] : Load the room on the other side of the loading plane * [2] : Fade Region (opaque -> transparent if approaching, transparent -> opaque if receding) * [3] : Transparent Region * - * When traversing a loading plane of this kind, it attempts to: + * When traversing a loading plane of pthis kind, it attempts to: * Load Current Room (fails as it is already loaded) * Load Next Room * Load Previous Room @@ -80,32 +80,32 @@ static f32 sHorizTriggerDists[2][4] = { { 100.0f, 75.0f, 50.0f, 25.0f }, }; -void EnHoll_SetupAction(EnHoll* this, EnHollActionFunc func) { - this->actionFunc = func; +void EnHoll_SetupAction(EnHoll* pthis, EnHollActionFunc func) { + pthis->actionFunc = func; } s32 EnHoll_IsKokiriSetup8() { return gSaveContext.entranceIndex == 0x00EE && gSaveContext.sceneSetupIndex == 8; } -void EnHoll_ChooseAction(EnHoll* this) { +void EnHoll_ChooseAction(EnHoll* pthis) { s32 action; - action = (this->actor.params >> 6) & 7; - EnHoll_SetupAction(this, sActionFuncs[action]); + action = (pthis->actor.params >> 6) & 7; + EnHoll_SetupAction(pthis, sActionFuncs[action]); if (action != 0) { - this->actor.draw = NULL; + pthis->actor.draw = NULL; } else { - this->planeAlpha = 255; + pthis->planeAlpha = 255; } } void EnHoll_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHoll* this = (EnHoll*)thisx; + EnHoll* pthis = (EnHoll*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - EnHoll_ChooseAction(this); - this->unk_14F = 0; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + EnHoll_ChooseAction(pthis); + pthis->unk_14F = 0; } void EnHoll_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -126,34 +126,34 @@ void EnHoll_SwapRooms(GlobalContext* globalCtx) { } // Horizontal Planes -void func_80A58DD4(EnHoll* this, GlobalContext* globalCtx) { +void func_80A58DD4(EnHoll* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 phi_t0 = ((globalCtx->sceneNum == SCENE_JYASINZOU) ? 1 : 0) & 0xFFFFFFFF; Vec3f vec; f32 absZ; s32 transitionActorIdx; - func_8002DBD0(&this->actor, &vec, &player->actor.world.pos); - this->side = (vec.z < 0.0f) ? 0 : 1; + func_8002DBD0(&pthis->actor, &vec, &player->actor.world.pos); + pthis->side = (vec.z < 0.0f) ? 0 : 1; absZ = fabsf(vec.z); if (vec.y > PLANE_Y_MIN && vec.y < PLANE_Y_MAX && fabsf(vec.x) < PLANE_HALFWIDTH && absZ < sHorizTriggerDists[phi_t0][0]) { - transitionActorIdx = (u16)this->actor.params >> 0xA; + transitionActorIdx = (u16)pthis->actor.params >> 0xA; if (absZ > sHorizTriggerDists[phi_t0][1]) { if (globalCtx->roomCtx.prevRoom.num >= 0 && globalCtx->roomCtx.status == 0) { - this->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[this->side].room; + pthis->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[pthis->side].room; EnHoll_SwapRooms(globalCtx); func_80097534(globalCtx, &globalCtx->roomCtx); } } else { - this->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[this->side ^ 1].room; + pthis->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[pthis->side ^ 1].room; if (globalCtx->roomCtx.prevRoom.num < 0) { - func_8009728C(globalCtx, &globalCtx->roomCtx, this->actor.room); + func_8009728C(globalCtx, &globalCtx->roomCtx, pthis->actor.room); } else { - this->planeAlpha = (255.0f / (sHorizTriggerDists[phi_t0][2] - sHorizTriggerDists[phi_t0][3])) * + pthis->planeAlpha = (255.0f / (sHorizTriggerDists[phi_t0][2] - sHorizTriggerDists[phi_t0][3])) * (absZ - sHorizTriggerDists[phi_t0][3]); - this->planeAlpha = CLAMP(this->planeAlpha, 0, 255); - if (globalCtx->roomCtx.curRoom.num != this->actor.room) { + pthis->planeAlpha = CLAMP(pthis->planeAlpha, 0, 255); + if (globalCtx->roomCtx.curRoom.num != pthis->actor.room) { EnHoll_SwapRooms(globalCtx); } } @@ -162,7 +162,7 @@ void func_80A58DD4(EnHoll* this, GlobalContext* globalCtx) { } // Horizontal Planes -void func_80A59014(EnHoll* this, GlobalContext* globalCtx) { +void func_80A59014(EnHoll* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 useViewEye = gDbgCamEnabled || globalCtx->csCtx.state != CS_STATE_IDLE; Vec3f vec; @@ -170,36 +170,36 @@ void func_80A59014(EnHoll* this, GlobalContext* globalCtx) { f32 planeHalfWidth; f32 absZ; - func_8002DBD0(&this->actor, &vec, (useViewEye) ? &globalCtx->view.eye : &player->actor.world.pos); - planeHalfWidth = (((this->actor.params >> 6) & 7) == 6) ? PLANE_HALFWIDTH : PLANE_HALFWIDTH_2; + func_8002DBD0(&pthis->actor, &vec, (useViewEye) ? &globalCtx->view.eye : &player->actor.world.pos); + planeHalfWidth = (((pthis->actor.params >> 6) & 7) == 6) ? PLANE_HALFWIDTH : PLANE_HALFWIDTH_2; temp = EnHoll_IsKokiriSetup8(); if (temp || (PLANE_Y_MIN < vec.y && vec.y < PLANE_Y_MAX && fabsf(vec.x) < planeHalfWidth && (absZ = fabsf(vec.z), 100.0f > absZ && absZ > 50.0f))) { - s32 transitionActorIdx = (u16)this->actor.params >> 0xA; + s32 transitionActorIdx = (u16)pthis->actor.params >> 0xA; s32 side = (vec.z < 0.0f) ? 0 : 1; TransitionActorEntry* transitionEntry = &globalCtx->transiActorCtx.list[transitionActorIdx]; s32 room = transitionEntry->sides[side].room; - this->actor.room = room; + pthis->actor.room = room; if (temp) {} - if (this->actor.room != globalCtx->roomCtx.curRoom.num) { + if (pthis->actor.room != globalCtx->roomCtx.curRoom.num) { if (room) {} - if (func_8009728C(globalCtx, &globalCtx->roomCtx, this->actor.room)) { - EnHoll_SetupAction(this, EnHoll_NextAction); + if (func_8009728C(globalCtx, &globalCtx->roomCtx, pthis->actor.room)) { + EnHoll_SetupAction(pthis, EnHoll_NextAction); } } } } // Vertical Planes -void func_80A591C0(EnHoll* this, GlobalContext* globalCtx) { +void func_80A591C0(EnHoll* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - f32 absY = fabsf(this->actor.yDistToPlayer); + f32 absY = fabsf(pthis->actor.yDistToPlayer); s32 transitionActorIdx; - if (this->actor.xzDistToPlayer < 500.0f && absY < 700.0f) { - transitionActorIdx = (u16)this->actor.params >> 0xA; + if (pthis->actor.xzDistToPlayer < 500.0f && absY < 700.0f) { + transitionActorIdx = (u16)pthis->actor.params >> 0xA; if (absY < 95.0f) { globalCtx->unk_11E18 = 0xFF; } else if (absY > 605.0f) { @@ -208,89 +208,89 @@ void func_80A591C0(EnHoll* this, GlobalContext* globalCtx) { globalCtx->unk_11E18 = (s16)(605.0f - absY) * 0.5f; } if (absY < 95.0f) { - this->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[1].room; - Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 1.0f, 50.0f, 10.0f); - Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 1.0f, 50.0f, 10.0f); - if (this->actor.room != globalCtx->roomCtx.curRoom.num && - func_8009728C(globalCtx, &globalCtx->roomCtx, this->actor.room) != 0) { - EnHoll_SetupAction(this, EnHoll_NextAction); - this->unk_14F = 1; + pthis->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[1].room; + Math_SmoothStepToF(&player->actor.world.pos.x, pthis->actor.world.pos.x, 1.0f, 50.0f, 10.0f); + Math_SmoothStepToF(&player->actor.world.pos.z, pthis->actor.world.pos.z, 1.0f, 50.0f, 10.0f); + if (pthis->actor.room != globalCtx->roomCtx.curRoom.num && + func_8009728C(globalCtx, &globalCtx->roomCtx, pthis->actor.room) != 0) { + EnHoll_SetupAction(pthis, EnHoll_NextAction); + pthis->unk_14F = 1; player->actor.speedXZ = 0.0f; } } - } else if (this->unk_14F != 0) { + } else if (pthis->unk_14F != 0) { globalCtx->unk_11E18 = 0; - this->unk_14F = 0; + pthis->unk_14F = 0; } } // Vertical Planes -void func_80A593A4(EnHoll* this, GlobalContext* globalCtx) { +void func_80A593A4(EnHoll* pthis, GlobalContext* globalCtx) { f32 absY; s32 side; s32 transitionActorIdx; - if ((this->actor.xzDistToPlayer < 120.0f) && (absY = fabsf(this->actor.yDistToPlayer), absY < 200.0f)) { + if ((pthis->actor.xzDistToPlayer < 120.0f) && (absY = fabsf(pthis->actor.yDistToPlayer), absY < 200.0f)) { if (absY < 50.0f) { globalCtx->unk_11E18 = 0xFF; } else { globalCtx->unk_11E18 = (200.0f - absY) * 1.7f; } if (absY > 50.0f) { - transitionActorIdx = (u16)this->actor.params >> 0xA; - side = (0.0f < this->actor.yDistToPlayer) ? 0 : 1; - this->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[side].room; - if (this->actor.room != globalCtx->roomCtx.curRoom.num && - func_8009728C(globalCtx, &globalCtx->roomCtx, this->actor.room) != 0) { - EnHoll_SetupAction(this, EnHoll_NextAction); - this->unk_14F = 1; + transitionActorIdx = (u16)pthis->actor.params >> 0xA; + side = (0.0f < pthis->actor.yDistToPlayer) ? 0 : 1; + pthis->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[side].room; + if (pthis->actor.room != globalCtx->roomCtx.curRoom.num && + func_8009728C(globalCtx, &globalCtx->roomCtx, pthis->actor.room) != 0) { + EnHoll_SetupAction(pthis, EnHoll_NextAction); + pthis->unk_14F = 1; } } - } else if (this->unk_14F != 0) { - this->unk_14F = 0; + } else if (pthis->unk_14F != 0) { + pthis->unk_14F = 0; globalCtx->unk_11E18 = 0; } } // Vertical Planes -void func_80A59520(EnHoll* this, GlobalContext* globalCtx) { +void func_80A59520(EnHoll* pthis, GlobalContext* globalCtx) { f32 absY; s8 side; s32 transitionActorIdx; - if (this->actor.xzDistToPlayer < 120.0f) { - absY = fabsf(this->actor.yDistToPlayer); + if (pthis->actor.xzDistToPlayer < 120.0f) { + absY = fabsf(pthis->actor.yDistToPlayer); if (absY < 200.0f && absY > 50.0f) { - transitionActorIdx = (u16)this->actor.params >> 0xA; - side = (0.0f < this->actor.yDistToPlayer) ? 0 : 1; - this->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[side].room; - if (this->actor.room != globalCtx->roomCtx.curRoom.num && - func_8009728C(globalCtx, &globalCtx->roomCtx, this->actor.room) != 0) { - EnHoll_SetupAction(this, EnHoll_NextAction); + transitionActorIdx = (u16)pthis->actor.params >> 0xA; + side = (0.0f < pthis->actor.yDistToPlayer) ? 0 : 1; + pthis->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[side].room; + if (pthis->actor.room != globalCtx->roomCtx.curRoom.num && + func_8009728C(globalCtx, &globalCtx->roomCtx, pthis->actor.room) != 0) { + EnHoll_SetupAction(pthis, EnHoll_NextAction); } } } } // Horizontal Planes -void func_80A59618(EnHoll* this, GlobalContext* globalCtx) { +void func_80A59618(EnHoll* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f vec; f32 absZ; s32 side; s32 transitionActorIdx; - if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x3F)) { - if (this->unk_14F != 0) { + if (!Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F)) { + if (pthis->unk_14F != 0) { globalCtx->unk_11E18 = 0; - this->unk_14F = 0; + pthis->unk_14F = 0; } } else { - func_8002DBD0(&this->actor, &vec, &player->actor.world.pos); + func_8002DBD0(&pthis->actor, &vec, &player->actor.world.pos); absZ = fabsf(vec.z); if (PLANE_Y_MIN < vec.y && vec.y < PLANE_Y_MAX && fabsf(vec.x) < PLANE_HALFWIDTH_2 && absZ < 100.0f) { - this->unk_14F = 1; - transitionActorIdx = (u16)this->actor.params >> 0xA; + pthis->unk_14F = 1; + transitionActorIdx = (u16)pthis->actor.params >> 0xA; globalCtx->unk_11E18 = 0xFF - (s32)((absZ - 50.0f) * 5.9f); if (globalCtx->unk_11E18 >= 0x100) { globalCtx->unk_11E18 = 0xFF; @@ -299,47 +299,47 @@ void func_80A59618(EnHoll* this, GlobalContext* globalCtx) { } if (absZ < 50.0f) { side = (vec.z < 0.0f) ? 0 : 1; - this->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[side].room; - if (this->actor.room != globalCtx->roomCtx.curRoom.num && - func_8009728C(globalCtx, &globalCtx->roomCtx, this->actor.room) != 0) { - EnHoll_SetupAction(this, EnHoll_NextAction); + pthis->actor.room = globalCtx->transiActorCtx.list[transitionActorIdx].sides[side].room; + if (pthis->actor.room != globalCtx->roomCtx.curRoom.num && + func_8009728C(globalCtx, &globalCtx->roomCtx, pthis->actor.room) != 0) { + EnHoll_SetupAction(pthis, EnHoll_NextAction); } } - } else if (this->unk_14F != 0) { + } else if (pthis->unk_14F != 0) { globalCtx->unk_11E18 = 0; - this->unk_14F = 0; + pthis->unk_14F = 0; } } } -void EnHoll_NextAction(EnHoll* this, GlobalContext* globalCtx) { +void EnHoll_NextAction(EnHoll* pthis, GlobalContext* globalCtx) { if (!EnHoll_IsKokiriSetup8() && globalCtx->roomCtx.status == 0) { func_80097534(globalCtx, &globalCtx->roomCtx); if (globalCtx->unk_11E18 == 0) { - this->unk_14F = 0; + pthis->unk_14F = 0; } - EnHoll_ChooseAction(this); + EnHoll_ChooseAction(pthis); } } void EnHoll_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHoll* this = (EnHoll*)thisx; + EnHoll* pthis = (EnHoll*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } -#include "overlays/ovl_En_Holl/ovl_En_Holl.c" +#include "overlays/ovl_En_Holl/ovl_En_Holl.cpp" void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHoll* this = (EnHoll*)thisx; + EnHoll* pthis = (EnHoll*)thisx; Gfx* gfxP; u32 setupDlIdx; // Only draw the plane if not invisible - if (this->planeAlpha != 0) { + if (pthis->planeAlpha != 0) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_holl.c", 805); - if (this->planeAlpha == 255) { + if (pthis->planeAlpha == 255) { gfxP = POLY_OPA_DISP; setupDlIdx = 37; } else { @@ -347,16 +347,16 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { setupDlIdx = 0; } gfxP = Gfx_CallSetupDL(gfxP, setupDlIdx); - if (this->side == 0) { + if (pthis->side == 0) { Matrix_RotateY(M_PI, MTXMODE_APPLY); } gSPMatrix(gfxP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_holl.c", 824), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(gfxP++, 0, 0, 0, 0, 0, (u8)this->planeAlpha); + gDPSetPrimColor(gfxP++, 0, 0, 0, 0, 0, (u8)pthis->planeAlpha); gSPDisplayList(gfxP++, sPlaneDL); - if (this->planeAlpha == 255) { + if (pthis->planeAlpha == 255) { POLY_OPA_DISP = gfxP; } else { POLY_XLU_DISP = gfxP; diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c deleted file mode 100644 index 57d3c5b3b..000000000 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ /dev/null @@ -1,553 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HONOTRAP_Z_EN_HONOTRAP_C -#include "actor_common.h" -/** - * File: z_en_honotrap.c - * Overlay: ovl_En_Honotrap - * Description: Fake eye switches and Dampe flames - */ - -#include "z_en_honotrap.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -#define HONOTRAP_AT_ACTIVE (1 << 0) -#define HONOTRAP_AC_ACTIVE (1 << 1) -#define HONOTRAP_OC_ACTIVE (1 << 2) - -typedef enum { - /* 0 */ HONOTRAP_EYE_OPEN, - /* 1 */ HONOTRAP_EYE_HALF, - /* 2 */ HONOTRAP_EYE_CLOSE, - /* 3 */ HONOTRAP_EYE_SHUT -} EnHonotrapEyeState; - -void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHonotrap_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHonotrap_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnHonotrap_SetupEyeIdle(EnHonotrap* this); -void EnHonotrap_EyeIdle(EnHonotrap* this, GlobalContext* globalCtx); -void EnHonotrap_SetupEyeOpen(EnHonotrap* this); -void EnHonotrap_EyeOpen(EnHonotrap* this, GlobalContext* globalCtx); -void EnHonotrap_SetupEyeAttack(EnHonotrap* this); -void EnHonotrap_EyeAttack(EnHonotrap* this, GlobalContext* globalCtx); -void EnHonotrap_SetupEyeClose(EnHonotrap* this); -void EnHonotrap_EyeClose(EnHonotrap* this, GlobalContext* globalCtx); - -void EnHonotrap_SetupFlame(EnHonotrap* this); -void EnHonotrap_Flame(EnHonotrap* this, GlobalContext* globalCtx); -void EnHonotrap_SetupFlameDrop(EnHonotrap* this); -void EnHonotrap_FlameDrop(EnHonotrap* this, GlobalContext* globalCtx); - -void EnHonotrap_SetupFlameMove(EnHonotrap* this); -void EnHonotrap_FlameMove(EnHonotrap* this, GlobalContext* globalCtx); -void EnHonotrap_SetupFlameChase(EnHonotrap* this); -void EnHonotrap_FlameChase(EnHonotrap* this, GlobalContext* globalCtx); -void EnHonotrap_SetupFlameVanish(EnHonotrap* this); -void EnHonotrap_FlameVanish(EnHonotrap* this, GlobalContext* globalCtx); - -const ActorInit En_Honotrap_InitVars = { - ACTOR_EN_HONOTRAP, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_DANGEON_KEEP, - sizeof(EnHonotrap), - (ActorFunc)EnHonotrap_Init, - (ActorFunc)EnHonotrap_Destroy, - (ActorFunc)EnHonotrap_Update, - (ActorFunc)EnHonotrap_Draw, -}; - -static ColliderTrisElementInit sTrisElementsInit[2] = { - { - { - ELEMTYPE_UNK4, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, - }, -}; - -static ColliderTrisInit sTrisInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 2, - sTrisElementsInit, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x04 }, - { 0x00100000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 10, 25, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0, 9, 23, 1 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void EnHonotrap_FlameCollisionCheck(EnHonotrap* this, GlobalContext* globalCtx) { - s32 pad[3]; - - Collider_UpdateCylinder(&this->actor, &this->collider.cyl); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.cyl.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.cyl.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.cyl.base); - this->colChkFlags |= HONOTRAP_AT_ACTIVE; - this->colChkFlags |= HONOTRAP_AC_ACTIVE; - this->colChkFlags |= HONOTRAP_OC_ACTIVE; -} - -void EnHonotrap_GetNormal(Vec3f* normal, Vec3f* vec) { - f32 mag = Math3D_Vec3fMagnitude(vec); - - if (mag < 0.001f) { - osSyncPrintf("Warning : vector size zero (%s %d)\n", "../z_en_honotrap.c", 328, normal); - - normal->x = normal->y = 0.0f; - normal->z = 1.0f; - } else { - normal->x = vec->x * (1.0f / mag); - normal->y = vec->y * (1.0f / mag); - normal->z = vec->z * (1.0f / mag); - } -} - -void EnHonotrap_InitEye(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHonotrap* this = (EnHonotrap*)thisx; - s32 i; - s32 j; - Vec3f* vtx; - Vec3f triangle[3]; - f32 cos; - f32 sin; - - Actor_SetScale(thisx, 0.1f); - sin = Math_SinS(thisx->home.rot.y); - cos = Math_CosS(thisx->home.rot.y); - Collider_InitTris(globalCtx, &this->collider.tris); - Collider_SetTris(globalCtx, &this->collider.tris, thisx, &sTrisInit, this->collider.elements); - - for (i = 0; i < 2; i++) { - for (j = 0, vtx = triangle; j < 3; j++, vtx++) { - Vec3f* baseVtx = &sTrisInit.elements[i].dim.vtx[j]; - - vtx->x = baseVtx->z * sin + baseVtx->x * cos; - vtx->y = baseVtx->y; - vtx->z = baseVtx->z * cos - baseVtx->x * sin; - Math_Vec3f_Sum(vtx, &thisx->world.pos, vtx); - } - Collider_SetTrisVertices(&this->collider.tris, i, &triangle[0], &triangle[1], &triangle[2]); - } - EnHonotrap_SetupEyeIdle(this); - Actor_SetFocus(thisx, 0.0f); -} - -void EnHonotrap_InitFlame(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHonotrap* this = (EnHonotrap*)thisx; - - Actor_SetScale(&this->actor, 0.0001f); - Collider_InitCylinder(globalCtx, &this->collider.cyl); - Collider_SetCylinder(globalCtx, &this->collider.cyl, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider.cyl); - this->actor.minVelocityY = -1.0f; - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->actor.shape.shadowAlpha = 128; - this->targetPos = GET_PLAYER(globalCtx)->actor.world.pos; - this->targetPos.y += 10.0f; - this->flameScroll = Rand_ZeroOne() * 511.0f; - EnHonotrap_SetupFlame(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FLAME_IGNITION); - if (this->actor.params == HONOTRAP_FLAME_DROP) { - this->actor.room = -1; - this->collider.cyl.dim.radius = 12; - this->collider.cyl.dim.height = 30; - this->actor.shape.yOffset = -1000.0f; - } -} - -void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx) { - Actor_ProcessInitChain(thisx, sInitChain); - if (thisx->params == HONOTRAP_EYE) { - EnHonotrap_InitEye(thisx, globalCtx); - } else { - EnHonotrap_InitFlame(thisx, globalCtx); - } -} - -void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHonotrap* this = (EnHonotrap*)thisx; - - if (this->actor.params == HONOTRAP_EYE) { - Collider_DestroyTris(globalCtx, &this->collider.tris); - } else { - Collider_DestroyCylinder(globalCtx, &this->collider.cyl); - } -} - -void EnHonotrap_SetupEyeIdle(EnHonotrap* this) { - this->actionFunc = EnHonotrap_EyeIdle; - this->eyeState = HONOTRAP_EYE_SHUT; -} - -void EnHonotrap_EyeIdle(EnHonotrap* this, GlobalContext* globalCtx) { - if (this->actor.child != NULL) { - this->timer = 200; - } else if ((this->timer <= 0) && (this->actor.xzDistToPlayer < 750.0f) && (0.0f > this->actor.yDistToPlayer) && - (this->actor.yDistToPlayer > -700.0f) && - (-0x4000 < (this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) && - ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) < 0x4000)) { - EnHonotrap_SetupEyeOpen(this); - } -} - -void EnHonotrap_SetupEyeOpen(EnHonotrap* this) { - this->actionFunc = EnHonotrap_EyeOpen; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x28); - this->timer = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_RED_EYE); -} - -void EnHonotrap_EyeOpen(EnHonotrap* this, GlobalContext* globalCtx) { - f32 cos; - f32 sin; - - this->eyeState--; - if (this->eyeState <= HONOTRAP_EYE_OPEN) { - EnHonotrap_SetupEyeAttack(this); - sin = Math_SinS(this->actor.shape.rot.y); - cos = Math_CosS(this->actor.shape.rot.y); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_HONOTRAP, - (sin * 12.0f) + this->actor.home.pos.x, this->actor.home.pos.y - 10.0f, - (cos * 12.0f) + this->actor.home.pos.z, this->actor.home.rot.x, this->actor.home.rot.y, - this->actor.home.rot.z, HONOTRAP_FLAME_MOVE); - } -} - -void EnHonotrap_SetupEyeAttack(EnHonotrap* this) { - this->actionFunc = EnHonotrap_EyeAttack; - this->eyeState = HONOTRAP_EYE_OPEN; -} - -void EnHonotrap_EyeAttack(EnHonotrap* this, GlobalContext* globalCtx) { - if (this->timer <= 0) { - EnHonotrap_SetupEyeClose(this); - } -} - -void EnHonotrap_SetupEyeClose(EnHonotrap* this) { - this->actionFunc = EnHonotrap_EyeClose; -} - -void EnHonotrap_EyeClose(EnHonotrap* this, GlobalContext* globalCtx) { - this->eyeState++; - if (this->eyeState >= HONOTRAP_EYE_SHUT) { - EnHonotrap_SetupEyeIdle(this); - this->timer = 200; - } -} - -void EnHonotrap_SetupFlame(EnHonotrap* this) { - this->actionFunc = EnHonotrap_Flame; -} - -void EnHonotrap_Flame(EnHonotrap* this, GlobalContext* globalCtx) { - s32 pad; - s32 ready = - Math_StepToF(&this->actor.scale.x, (this->actor.params == HONOTRAP_FLAME_MOVE) ? 0.004f : 0.0048f, 0.0006f); - - this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; - if (ready) { - if (this->actor.params == HONOTRAP_FLAME_MOVE) { - EnHonotrap_SetupFlameMove(this); - } else { - EnHonotrap_SetupFlameDrop(this); - } - } -} - -void EnHonotrap_SetupFlameDrop(EnHonotrap* this) { - this->timer = 40; - this->actor.velocity.y = 1.0f; - this->actor.velocity.x = 2.0f * Math_SinS(this->actor.world.rot.y); - this->actor.velocity.z = 2.0f * Math_CosS(this->actor.world.rot.y); - this->actionFunc = EnHonotrap_FlameDrop; -} - -void EnHonotrap_FlameDrop(EnHonotrap* this, GlobalContext* globalCtx) { - if ((this->collider.cyl.base.atFlags & AT_HIT) || (this->timer <= 0)) { - if ((this->collider.cyl.base.atFlags & AT_HIT) && !(this->collider.cyl.base.atFlags & AT_BOUNCED)) { - func_8002F71C(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 0.0f); - } - this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - EnHonotrap_SetupFlameVanish(this); - } else { - if (this->actor.velocity.y > 0.0f) { - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.z += this->actor.velocity.z; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.0f, 12.0f, 0.0f, 5); - } - if (!Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 1.0f, this->actor.velocity.y)) { - this->actor.velocity.y += 1.0f; - } else { - this->actor.velocity.y = 0.0f; - } - EnHonotrap_FlameCollisionCheck(this, globalCtx); - } -} - -void EnHonotrap_SetupFlameMove(EnHonotrap* this) { - f32 distFrac; - - this->actionFunc = EnHonotrap_FlameMove; - - distFrac = 1.0f / (Actor_WorldDistXYZToPoint(&this->actor, &this->targetPos) + 1.0f); - this->actor.velocity.x = (this->targetPos.x - this->actor.world.pos.x) * distFrac; - this->actor.velocity.y = (this->targetPos.y - this->actor.world.pos.y) * distFrac; - this->actor.velocity.z = (this->targetPos.z - this->actor.world.pos.z) * distFrac; - this->speedMod = 0.0f; - - this->timer = 160; -} - -void EnHonotrap_FlameMove(EnHonotrap* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f speed; - s32 ready; - - Math_StepToF(&this->speedMod, 13.0f, 0.5f); - speed.x = fabsf(this->speedMod * this->actor.velocity.x); - speed.y = fabsf(this->speedMod * this->actor.velocity.y); - speed.z = fabsf(this->speedMod * this->actor.velocity.z); - ready = true; - ready &= Math_StepToF(&this->actor.world.pos.x, this->targetPos.x, speed.x); - ready &= Math_StepToF(&this->actor.world.pos.y, this->targetPos.y, speed.y); - ready &= Math_StepToF(&this->actor.world.pos.z, this->targetPos.z, speed.z); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.0f, 10.0f, 0.0f, 0x1D); - - if (this->collider.tris.base.atFlags & AT_BOUNCED) { - Player* player = GET_PLAYER(globalCtx); - Vec3f shieldNorm; - Vec3f tempVel; - Vec3f shieldVec; - - shieldVec.x = -player->shieldMf.xz; - shieldVec.y = -player->shieldMf.yz; - shieldVec.z = -player->shieldMf.zz; - EnHonotrap_GetNormal(&shieldNorm, &shieldVec); - - tempVel = this->actor.velocity; - Math3D_Vec3fReflect(&tempVel, &shieldNorm, &this->actor.velocity); - this->actor.speedXZ = this->speedMod * 0.5f; - this->actor.world.rot.y = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - EnHonotrap_SetupFlameVanish(this); - } else if (this->collider.tris.base.atFlags & AT_HIT) { - this->actor.velocity.y = this->actor.speedXZ = 0.0f; - EnHonotrap_SetupFlameVanish(this); - } else if (this->timer <= 0) { - EnHonotrap_SetupFlameVanish(this); - } else { - EnHonotrap_FlameCollisionCheck(this, globalCtx); - if (ready) { - EnHonotrap_SetupFlameChase(this); - } - } -} - -void EnHonotrap_SetupFlameChase(EnHonotrap* this) { - this->actionFunc = EnHonotrap_FlameChase; - - this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = this->actor.speedXZ = 0.0f; - this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; - - this->timer = 100; -} - -void EnHonotrap_FlameChase(EnHonotrap* this, GlobalContext* globalCtx) { - s32 pad; - - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x300); - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.1f); - this->actor.gravity = (-this->actor.yDistToPlayer < 10.0f) ? 0.08f : -0.08f; - func_8002D868(&this->actor); - if (this->actor.velocity.y > 1.0f) { - this->actor.velocity.y = 1.0f; - } - this->actor.velocity.y *= 0.95f; - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.0f, 10.0f, 0.0f, 0x1D); - if (this->collider.cyl.base.atFlags & AT_BOUNCED) { - Player* player = GET_PLAYER(globalCtx); - Vec3s shieldRot; - - Matrix_MtxFToYXZRotS(&player->shieldMf, &shieldRot, false); - this->actor.world.rot.y = ((shieldRot.y * 2) - this->actor.world.rot.y) + 0x8000; - EnHonotrap_SetupFlameVanish(this); - } else if (this->collider.cyl.base.atFlags & AT_HIT) { - this->actor.speedXZ *= 0.1f; - this->actor.velocity.y *= 0.1f; - EnHonotrap_SetupFlameVanish(this); - } else if ((this->actor.bgCheckFlags & 8) || (this->timer <= 0)) { - EnHonotrap_SetupFlameVanish(this); - } else { - EnHonotrap_FlameCollisionCheck(this, globalCtx); - } -} - -void EnHonotrap_SetupFlameVanish(EnHonotrap* this) { - this->actionFunc = EnHonotrap_FlameVanish; -} - -void EnHonotrap_FlameVanish(EnHonotrap* this, GlobalContext* globalCtx) { - s32 pad; - s32 ready = Math_StepToF(&this->actor.scale.x, 0.0001f, 0.00015f); - - this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.0f, 10.0f, 0.0f, 0x1D); - if (ready) { - Actor_Kill(&this->actor); - } -} - -void EnHonotrap_Update(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f accel = { 0.0f, 0.1f, 0.0f }; - s32 pad; - EnHonotrap* this = (EnHonotrap*)thisx; - - if (this->timer > 0) { - this->timer--; - } - if (this->actor.params == HONOTRAP_EYE) { - if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { - this->actor.child = NULL; - } - } else { - this->colChkFlags = 0; - this->bobPhase += 0x640; - this->actor.shape.yOffset = (Math_SinS(this->bobPhase) * 1000.0f) + 600.0f; - Actor_SetFocus(&this->actor, 5.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - } - this->actionFunc(this, globalCtx); - if (this->actor.params == HONOTRAP_EYE) { - if (this->collider.tris.base.acFlags & AC_HIT) { - EffectSsBomb2_SpawnLayered(globalCtx, &this->actor.world.pos, &velocity, &accel, 15, 8); - Actor_Kill(&this->actor); - } else if (this->eyeState < HONOTRAP_EYE_SHUT) { - this->collider.tris.base.acFlags &= ~AC_HIT; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.tris.base); - } - } -} - -void EnHonotrap_DrawEye(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { - gEyeSwitchSilverOpenTex, - gEyeSwitchSilverHalfTex, - gEyeSwitchSilverClosedTex, - gEyeSwitchSilverClosedTex, - }; - EnHonotrap* this = (EnHonotrap*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 982); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeState])); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 987), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gEyeSwitch2DL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 991); -} - -void EnHonotrap_DrawFlame(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnHonotrap* this = (EnHonotrap*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 1000); - - func_80093D84(globalCtx->state.gfxCtx); - this->flameScroll -= 20; - this->flameScroll &= 0x1FF; - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, this->flameScroll, 0x20, 0x80)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y + 0x8000) * - (M_PI / 0x8000), - MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 1024), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 1028); -} - -void EnHonotrap_Draw(Actor* thisx, GlobalContext* globalCtx) { - switch (thisx->params) { - case HONOTRAP_EYE: - EnHonotrap_DrawEye(thisx, globalCtx); - break; - case HONOTRAP_FLAME_MOVE: - case HONOTRAP_FLAME_DROP: - EnHonotrap_DrawFlame(thisx, globalCtx); - break; - } -} diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.cpp b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.cpp new file mode 100644 index 000000000..4626f8406 --- /dev/null +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.cpp @@ -0,0 +1,553 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HONOTRAP_Z_EN_HONOTRAP_C +#include "actor_common.h" +/** + * File: z_en_honotrap.c + * Overlay: ovl_En_Honotrap + * Description: Fake eye switches and Dampe flames + */ + +#include "z_en_honotrap.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +#define HONOTRAP_AT_ACTIVE (1 << 0) +#define HONOTRAP_AC_ACTIVE (1 << 1) +#define HONOTRAP_OC_ACTIVE (1 << 2) + +typedef enum { + /* 0 */ HONOTRAP_EYE_OPEN, + /* 1 */ HONOTRAP_EYE_HALF, + /* 2 */ HONOTRAP_EYE_CLOSE, + /* 3 */ HONOTRAP_EYE_SHUT +} EnHonotrapEyeState; + +void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHonotrap_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHonotrap_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnHonotrap_SetupEyeIdle(EnHonotrap* pthis); +void EnHonotrap_EyeIdle(EnHonotrap* pthis, GlobalContext* globalCtx); +void EnHonotrap_SetupEyeOpen(EnHonotrap* pthis); +void EnHonotrap_EyeOpen(EnHonotrap* pthis, GlobalContext* globalCtx); +void EnHonotrap_SetupEyeAttack(EnHonotrap* pthis); +void EnHonotrap_EyeAttack(EnHonotrap* pthis, GlobalContext* globalCtx); +void EnHonotrap_SetupEyeClose(EnHonotrap* pthis); +void EnHonotrap_EyeClose(EnHonotrap* pthis, GlobalContext* globalCtx); + +void EnHonotrap_SetupFlame(EnHonotrap* pthis); +void EnHonotrap_Flame(EnHonotrap* pthis, GlobalContext* globalCtx); +void EnHonotrap_SetupFlameDrop(EnHonotrap* pthis); +void EnHonotrap_FlameDrop(EnHonotrap* pthis, GlobalContext* globalCtx); + +void EnHonotrap_SetupFlameMove(EnHonotrap* pthis); +void EnHonotrap_FlameMove(EnHonotrap* pthis, GlobalContext* globalCtx); +void EnHonotrap_SetupFlameChase(EnHonotrap* pthis); +void EnHonotrap_FlameChase(EnHonotrap* pthis, GlobalContext* globalCtx); +void EnHonotrap_SetupFlameVanish(EnHonotrap* pthis); +void EnHonotrap_FlameVanish(EnHonotrap* pthis, GlobalContext* globalCtx); + +ActorInit En_Honotrap_InitVars = { + ACTOR_EN_HONOTRAP, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_DANGEON_KEEP, + sizeof(EnHonotrap), + (ActorFunc)EnHonotrap_Init, + (ActorFunc)EnHonotrap_Destroy, + (ActorFunc)EnHonotrap_Update, + (ActorFunc)EnHonotrap_Draw, +}; + +static ColliderTrisElementInit sTrisElementsInit[2] = { + { + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, + }, +}; + +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x04 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 10, 25, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 9, 23, 1 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void EnHonotrap_FlameCollisionCheck(EnHonotrap* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider.cyl); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.cyl.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.cyl.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.cyl.base); + pthis->colChkFlags |= HONOTRAP_AT_ACTIVE; + pthis->colChkFlags |= HONOTRAP_AC_ACTIVE; + pthis->colChkFlags |= HONOTRAP_OC_ACTIVE; +} + +void EnHonotrap_GetNormal(Vec3f* normal, Vec3f* vec) { + f32 mag = Math3D_Vec3fMagnitude(vec); + + if (mag < 0.001f) { + osSyncPrintf("Warning : vector size zero (%s %d)\n", "../z_en_honotrap.c", 328, normal); + + normal->x = normal->y = 0.0f; + normal->z = 1.0f; + } else { + normal->x = vec->x * (1.0f / mag); + normal->y = vec->y * (1.0f / mag); + normal->z = vec->z * (1.0f / mag); + } +} + +void EnHonotrap_InitEye(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHonotrap* pthis = (EnHonotrap*)thisx; + s32 i; + s32 j; + Vec3f* vtx; + Vec3f triangle[3]; + f32 cos; + f32 sin; + + Actor_SetScale(thisx, 0.1f); + sin = Math_SinS(thisx->home.rot.y); + cos = Math_CosS(thisx->home.rot.y); + Collider_InitTris(globalCtx, &pthis->collider.tris); + Collider_SetTris(globalCtx, &pthis->collider.tris, thisx, &sTrisInit, pthis->collider.elements); + + for (i = 0; i < 2; i++) { + for (j = 0, vtx = triangle; j < 3; j++, vtx++) { + Vec3f* baseVtx = &sTrisInit.elements[i].dim.vtx[j]; + + vtx->x = baseVtx->z * sin + baseVtx->x * cos; + vtx->y = baseVtx->y; + vtx->z = baseVtx->z * cos - baseVtx->x * sin; + Math_Vec3f_Sum(vtx, &thisx->world.pos, vtx); + } + Collider_SetTrisVertices(&pthis->collider.tris, i, &triangle[0], &triangle[1], &triangle[2]); + } + EnHonotrap_SetupEyeIdle(pthis); + Actor_SetFocus(thisx, 0.0f); +} + +void EnHonotrap_InitFlame(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHonotrap* pthis = (EnHonotrap*)thisx; + + Actor_SetScale(&pthis->actor, 0.0001f); + Collider_InitCylinder(globalCtx, &pthis->collider.cyl); + Collider_SetCylinder(globalCtx, &pthis->collider.cyl, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider.cyl); + pthis->actor.minVelocityY = -1.0f; + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->actor.shape.shadowAlpha = 128; + pthis->targetPos = GET_PLAYER(globalCtx)->actor.world.pos; + pthis->targetPos.y += 10.0f; + pthis->flameScroll = Rand_ZeroOne() * 511.0f; + EnHonotrap_SetupFlame(pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FLAME_IGNITION); + if (pthis->actor.params == HONOTRAP_FLAME_DROP) { + pthis->actor.room = -1; + pthis->collider.cyl.dim.radius = 12; + pthis->collider.cyl.dim.height = 30; + pthis->actor.shape.yOffset = -1000.0f; + } +} + +void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx) { + Actor_ProcessInitChain(thisx, sInitChain); + if (thisx->params == HONOTRAP_EYE) { + EnHonotrap_InitEye(thisx, globalCtx); + } else { + EnHonotrap_InitFlame(thisx, globalCtx); + } +} + +void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHonotrap* pthis = (EnHonotrap*)thisx; + + if (pthis->actor.params == HONOTRAP_EYE) { + Collider_DestroyTris(globalCtx, &pthis->collider.tris); + } else { + Collider_DestroyCylinder(globalCtx, &pthis->collider.cyl); + } +} + +void EnHonotrap_SetupEyeIdle(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_EyeIdle; + pthis->eyeState = HONOTRAP_EYE_SHUT; +} + +void EnHonotrap_EyeIdle(EnHonotrap* pthis, GlobalContext* globalCtx) { + if (pthis->actor.child != NULL) { + pthis->timer = 200; + } else if ((pthis->timer <= 0) && (pthis->actor.xzDistToPlayer < 750.0f) && (0.0f > pthis->actor.yDistToPlayer) && + (pthis->actor.yDistToPlayer > -700.0f) && + (-0x4000 < (pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) && + ((pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) < 0x4000)) { + EnHonotrap_SetupEyeOpen(pthis); + } +} + +void EnHonotrap_SetupEyeOpen(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_EyeOpen; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0x28); + pthis->timer = 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_RED_EYE); +} + +void EnHonotrap_EyeOpen(EnHonotrap* pthis, GlobalContext* globalCtx) { + f32 cos; + f32 sin; + + pthis->eyeState--; + if (pthis->eyeState <= HONOTRAP_EYE_OPEN) { + EnHonotrap_SetupEyeAttack(pthis); + sin = Math_SinS(pthis->actor.shape.rot.y); + cos = Math_CosS(pthis->actor.shape.rot.y); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_HONOTRAP, + (sin * 12.0f) + pthis->actor.home.pos.x, pthis->actor.home.pos.y - 10.0f, + (cos * 12.0f) + pthis->actor.home.pos.z, pthis->actor.home.rot.x, pthis->actor.home.rot.y, + pthis->actor.home.rot.z, HONOTRAP_FLAME_MOVE); + } +} + +void EnHonotrap_SetupEyeAttack(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_EyeAttack; + pthis->eyeState = HONOTRAP_EYE_OPEN; +} + +void EnHonotrap_EyeAttack(EnHonotrap* pthis, GlobalContext* globalCtx) { + if (pthis->timer <= 0) { + EnHonotrap_SetupEyeClose(pthis); + } +} + +void EnHonotrap_SetupEyeClose(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_EyeClose; +} + +void EnHonotrap_EyeClose(EnHonotrap* pthis, GlobalContext* globalCtx) { + pthis->eyeState++; + if (pthis->eyeState >= HONOTRAP_EYE_SHUT) { + EnHonotrap_SetupEyeIdle(pthis); + pthis->timer = 200; + } +} + +void EnHonotrap_SetupFlame(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_Flame; +} + +void EnHonotrap_Flame(EnHonotrap* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 ready = + Math_StepToF(&pthis->actor.scale.x, (pthis->actor.params == HONOTRAP_FLAME_MOVE) ? 0.004f : 0.0048f, 0.0006f); + + pthis->actor.scale.z = pthis->actor.scale.y = pthis->actor.scale.x; + if (ready) { + if (pthis->actor.params == HONOTRAP_FLAME_MOVE) { + EnHonotrap_SetupFlameMove(pthis); + } else { + EnHonotrap_SetupFlameDrop(pthis); + } + } +} + +void EnHonotrap_SetupFlameDrop(EnHonotrap* pthis) { + pthis->timer = 40; + pthis->actor.velocity.y = 1.0f; + pthis->actor.velocity.x = 2.0f * Math_SinS(pthis->actor.world.rot.y); + pthis->actor.velocity.z = 2.0f * Math_CosS(pthis->actor.world.rot.y); + pthis->actionFunc = EnHonotrap_FlameDrop; +} + +void EnHonotrap_FlameDrop(EnHonotrap* pthis, GlobalContext* globalCtx) { + if ((pthis->collider.cyl.base.atFlags & AT_HIT) || (pthis->timer <= 0)) { + if ((pthis->collider.cyl.base.atFlags & AT_HIT) && !(pthis->collider.cyl.base.atFlags & AT_BOUNCED)) { + func_8002F71C(globalCtx, &pthis->actor, 5.0f, pthis->actor.yawTowardsPlayer, 0.0f); + } + pthis->actor.velocity.x = pthis->actor.velocity.y = pthis->actor.velocity.z = 0.0f; + EnHonotrap_SetupFlameVanish(pthis); + } else { + if (pthis->actor.velocity.y > 0.0f) { + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.0f, 12.0f, 0.0f, 5); + } + if (!Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 1.0f, pthis->actor.velocity.y)) { + pthis->actor.velocity.y += 1.0f; + } else { + pthis->actor.velocity.y = 0.0f; + } + EnHonotrap_FlameCollisionCheck(pthis, globalCtx); + } +} + +void EnHonotrap_SetupFlameMove(EnHonotrap* pthis) { + f32 distFrac; + + pthis->actionFunc = EnHonotrap_FlameMove; + + distFrac = 1.0f / (Actor_WorldDistXYZToPoint(&pthis->actor, &pthis->targetPos) + 1.0f); + pthis->actor.velocity.x = (pthis->targetPos.x - pthis->actor.world.pos.x) * distFrac; + pthis->actor.velocity.y = (pthis->targetPos.y - pthis->actor.world.pos.y) * distFrac; + pthis->actor.velocity.z = (pthis->targetPos.z - pthis->actor.world.pos.z) * distFrac; + pthis->speedMod = 0.0f; + + pthis->timer = 160; +} + +void EnHonotrap_FlameMove(EnHonotrap* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f speed; + s32 ready; + + Math_StepToF(&pthis->speedMod, 13.0f, 0.5f); + speed.x = fabsf(pthis->speedMod * pthis->actor.velocity.x); + speed.y = fabsf(pthis->speedMod * pthis->actor.velocity.y); + speed.z = fabsf(pthis->speedMod * pthis->actor.velocity.z); + ready = true; + ready &= Math_StepToF(&pthis->actor.world.pos.x, pthis->targetPos.x, speed.x); + ready &= Math_StepToF(&pthis->actor.world.pos.y, pthis->targetPos.y, speed.y); + ready &= Math_StepToF(&pthis->actor.world.pos.z, pthis->targetPos.z, speed.z); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.0f, 10.0f, 0.0f, 0x1D); + + if (pthis->collider.tris.base.atFlags & AT_BOUNCED) { + Player* player = GET_PLAYER(globalCtx); + Vec3f shieldNorm; + Vec3f tempVel; + Vec3f shieldVec; + + shieldVec.x = -player->shieldMf.xz; + shieldVec.y = -player->shieldMf.yz; + shieldVec.z = -player->shieldMf.zz; + EnHonotrap_GetNormal(&shieldNorm, &shieldVec); + + tempVel = pthis->actor.velocity; + Math3D_Vec3fReflect(&tempVel, &shieldNorm, &pthis->actor.velocity); + pthis->actor.speedXZ = pthis->speedMod * 0.5f; + pthis->actor.world.rot.y = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + EnHonotrap_SetupFlameVanish(pthis); + } else if (pthis->collider.tris.base.atFlags & AT_HIT) { + pthis->actor.velocity.y = pthis->actor.speedXZ = 0.0f; + EnHonotrap_SetupFlameVanish(pthis); + } else if (pthis->timer <= 0) { + EnHonotrap_SetupFlameVanish(pthis); + } else { + EnHonotrap_FlameCollisionCheck(pthis, globalCtx); + if (ready) { + EnHonotrap_SetupFlameChase(pthis); + } + } +} + +void EnHonotrap_SetupFlameChase(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_FlameChase; + + pthis->actor.velocity.x = pthis->actor.velocity.y = pthis->actor.velocity.z = pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.x = pthis->actor.world.rot.y = pthis->actor.world.rot.z = 0; + + pthis->timer = 100; +} + +void EnHonotrap_FlameChase(EnHonotrap* pthis, GlobalContext* globalCtx) { + s32 pad; + + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0x300); + Math_StepToF(&pthis->actor.speedXZ, 3.0f, 0.1f); + pthis->actor.gravity = (-pthis->actor.yDistToPlayer < 10.0f) ? 0.08f : -0.08f; + func_8002D868(&pthis->actor); + if (pthis->actor.velocity.y > 1.0f) { + pthis->actor.velocity.y = 1.0f; + } + pthis->actor.velocity.y *= 0.95f; + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.0f, 10.0f, 0.0f, 0x1D); + if (pthis->collider.cyl.base.atFlags & AT_BOUNCED) { + Player* player = GET_PLAYER(globalCtx); + Vec3s shieldRot; + + Matrix_MtxFToYXZRotS(&player->shieldMf, &shieldRot, false); + pthis->actor.world.rot.y = ((shieldRot.y * 2) - pthis->actor.world.rot.y) + 0x8000; + EnHonotrap_SetupFlameVanish(pthis); + } else if (pthis->collider.cyl.base.atFlags & AT_HIT) { + pthis->actor.speedXZ *= 0.1f; + pthis->actor.velocity.y *= 0.1f; + EnHonotrap_SetupFlameVanish(pthis); + } else if ((pthis->actor.bgCheckFlags & 8) || (pthis->timer <= 0)) { + EnHonotrap_SetupFlameVanish(pthis); + } else { + EnHonotrap_FlameCollisionCheck(pthis, globalCtx); + } +} + +void EnHonotrap_SetupFlameVanish(EnHonotrap* pthis) { + pthis->actionFunc = EnHonotrap_FlameVanish; +} + +void EnHonotrap_FlameVanish(EnHonotrap* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 ready = Math_StepToF(&pthis->actor.scale.x, 0.0001f, 0.00015f); + + pthis->actor.scale.z = pthis->actor.scale.y = pthis->actor.scale.x; + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.0f, 10.0f, 0.0f, 0x1D); + if (ready) { + Actor_Kill(&pthis->actor); + } +} + +void EnHonotrap_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f accel = { 0.0f, 0.1f, 0.0f }; + s32 pad; + EnHonotrap* pthis = (EnHonotrap*)thisx; + + if (pthis->timer > 0) { + pthis->timer--; + } + if (pthis->actor.params == HONOTRAP_EYE) { + if ((pthis->actor.child != NULL) && (pthis->actor.child->update == NULL)) { + pthis->actor.child = NULL; + } + } else { + pthis->colChkFlags = 0; + pthis->bobPhase += 0x640; + pthis->actor.shape.yOffset = (Math_SinS(pthis->bobPhase) * 1000.0f) + 600.0f; + Actor_SetFocus(&pthis->actor, 5.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->actor.params == HONOTRAP_EYE) { + if (pthis->collider.tris.base.acFlags & AC_HIT) { + EffectSsBomb2_SpawnLayered(globalCtx, &pthis->actor.world.pos, &velocity, &accel, 15, 8); + Actor_Kill(&pthis->actor); + } else if (pthis->eyeState < HONOTRAP_EYE_SHUT) { + pthis->collider.tris.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.tris.base); + } + } +} + +void EnHonotrap_DrawEye(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { + gEyeSwitchSilverOpenTex, + gEyeSwitchSilverHalfTex, + gEyeSwitchSilverClosedTex, + gEyeSwitchSilverClosedTex, + }; + EnHonotrap* pthis = (EnHonotrap*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 982); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeState])); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 987), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gEyeSwitch2DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 991); +} + +void EnHonotrap_DrawFlame(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHonotrap* pthis = (EnHonotrap*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 1000); + + func_80093D84(globalCtx->state.gfxCtx); + pthis->flameScroll -= 20; + pthis->flameScroll &= 0x1FF; + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, pthis->flameScroll, 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y + 0x8000) * + (M_PI / 0x8000), + MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 1024), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_honotrap.c", 1028); +} + +void EnHonotrap_Draw(Actor* thisx, GlobalContext* globalCtx) { + switch (thisx->params) { + case HONOTRAP_EYE: + EnHonotrap_DrawEye(thisx, globalCtx); + break; + case HONOTRAP_FLAME_MOVE: + case HONOTRAP_FLAME_DROP: + EnHonotrap_DrawFlame(thisx, globalCtx); + break; + } +} diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c deleted file mode 100644 index 3e9406375..000000000 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ /dev/null @@ -1,3867 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_Z_EN_HORSE_C -#include "actor_common.h" -/** - * File: z_en_horse.c - * Overlay: ovl_En_Horse - * Description: Rideable horses - */ - -#include "z_en_horse.h" -#include "overlays/actors/ovl_En_In/z_en_in.h" -#include "objects/object_horse/object_horse.h" -#include "objects/object_hni/object_hni.h" -#include "scenes/overworld/spot09/spot09_scene.h" - -#include "hack.h" -#include "def/assert.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_horse.h" -#include "def/z_lib.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" -#include "def/z_skin.h" -#include "def/z_skin_awb.h" -#include "def/z_skin_matrix.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef void (*EnHorseCsFunc)(EnHorse*, GlobalContext*, CsCmdActorAction*); -typedef void (*EnHorseActionFunc)(EnHorse*, GlobalContext*); - -void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_InitHorsebackArchery(EnHorse* this); -void EnHorse_InitFleePlayer(EnHorse* this); -void EnHorse_ResetIdleAnimation(EnHorse* this); -void EnHorse_StartIdleRidable(EnHorse* this); -void EnHorse_InitInactive(EnHorse* this); -void EnHorse_InitIngoHorse(EnHorse* this); - -void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_BridgeJump(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); - -static AnimationHeader* sEponaAnimHeaders[] = { - &gEponaIdleAnim, &gEponaWhinnyAnim, &gEponaRefuseAnim, &gEponaRearingAnim, &gEponaWalkingAnim, - &gEponaTrottingAnim, &gEponaGallopingAnim, &gEponaJumpingAnim, &gEponaJumpingHighAnim, -}; - -static AnimationHeader* sHniAnimHeaders[] = { - &gHorseIngoIdleAnim, &gHorseIngoWhinnyAnim, &gHorseIngoRefuseAnim, - &gHorseIngoRearingAnim, &gHorseIngoWalkingAnim, &gHorseIngoTrottingAnim, - &gHorseIngoGallopingAnim, &gHorseIngoJumpingAnim, &gHorseIngoJumpingHighAnim, -}; - -static AnimationHeader** sAnimationHeaders[] = { sEponaAnimHeaders, sHniAnimHeaders }; - -static f32 sPlaybackSpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f, 2.0f / 3.0f }; - -static SkeletonHeader* sSkeletonHeaders[] = { &gEponaSkel, &gHorseIngoSkel }; - -const ActorInit En_Horse_InitVars = { - ACTOR_EN_HORSE, - ACTORCAT_BG, - FLAGS, - OBJECT_HORSE, - sizeof(EnHorse), - (ActorFunc)EnHorse_Init, - (ActorFunc)EnHorse_Destroy, - (ActorFunc)EnHorse_Update, - (ActorFunc)EnHorse_Draw, -}; - -static ColliderCylinderInit sCylinderInit1 = { - { - COLTYPE_NONE, - AT_TYPE_PLAYER, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000400, 0x00, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInit2 = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphItemsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, - OCELEM_ON, - }, - { 13, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphItemsInit, -}; - -static CollisionCheckInfoInit D_80A65F38 = { 10, 35, 100, MASS_HEAVY }; - -typedef struct { - s16 scene; - Vec3s pos; - s16 angle; -} EnHorseSpawnpoint; - -static EnHorseSpawnpoint sHorseSpawns[] = { - // Hyrule Field - { SCENE_SPOT00, 16, 0, 1341, 0 }, - { SCENE_SPOT00, -1297, 0, 1459, 0 }, - { SCENE_SPOT00, -5416, -300, 1296, 0 }, - { SCENE_SPOT00, -4667, -300, 3620, 0 }, - { SCENE_SPOT00, -3837, 81, 5537, 0 }, - { SCENE_SPOT00, -5093, -226, 6661, 0 }, - { SCENE_SPOT00, -6588, -79, 5053, 0 }, - { SCENE_SPOT00, -7072, -500, 7538, 0 }, - { SCENE_SPOT00, -6139, -500, 8910, 0 }, - { SCENE_SPOT00, -8497, -300, 7802, 0 }, - { SCENE_SPOT00, -5481, -499, 12127, 0 }, - { SCENE_SPOT00, -4808, -700, 13583, 0 }, - { SCENE_SPOT00, -3416, -490, 12092, 0 }, - { SCENE_SPOT00, -2915, 100, 8339, 0 }, - { SCENE_SPOT00, -2277, -500, 13247, 0 }, - { SCENE_SPOT00, -1026, -500, 12101, 0 }, - { SCENE_SPOT00, 1427, -500, 13341, 0 }, - { SCENE_SPOT00, -200, -486, 10205, 0 }, - { SCENE_SPOT00, -1469, 100, 7496, 0 }, - { SCENE_SPOT00, -995, 168, 5652, 0 }, - { SCENE_SPOT00, 1938, 89, 6232, 0 }, - { SCENE_SPOT00, 1387, -105, 9206, 0 }, - { SCENE_SPOT00, 1571, -223, 7701, 0 }, - { SCENE_SPOT00, 3893, -121, 7068, 0 }, - { SCENE_SPOT00, 3179, 373, 5221, 0 }, - { SCENE_SPOT00, 4678, -20, 3869, 0 }, - { SCENE_SPOT00, 3460, 246, 4207, 0 }, - { SCENE_SPOT00, 3686, 128, 2366, 0 }, - { SCENE_SPOT00, 1791, 18, 152, 0 }, - { SCENE_SPOT00, 3667, -16, 1399, 0 }, - { SCENE_SPOT00, 1827, -15, 983, 0 }, - { SCENE_SPOT00, 1574, 399, 4318, 0 }, - { SCENE_SPOT00, 716, 95, 3391, 0 }, - { SCENE_SPOT00, -1189, -41, 4739, 0 }, - { SCENE_SPOT00, -1976, -171, 4172, 0 }, - { SCENE_SPOT00, 1314, 391, 5665, 0 }, - { SCENE_SPOT00, 112, 0, 1959, 0 }, - { SCENE_SPOT00, -3011, -111, 9397, 0 }, - { SCENE_SPOT00, -5674, -270, 8585, 0 }, - { SCENE_SPOT00, -8861, -300, 7836, 0 }, - { SCENE_SPOT00, -6056, -500, 7810, 0 }, - { SCENE_SPOT00, -7306, -500, 5994, 0 }, - { SCENE_SPOT00, -7305, -500, 7605, 0 }, - { SCENE_SPOT00, -7439, -300, 7600, 0 }, - { SCENE_SPOT00, -7464, -300, 6268, 0 }, - { SCENE_SPOT00, -8080, -300, 7553, 0 }, - { SCENE_SPOT00, -8091, -300, 7349, 0 }, - { SCENE_SPOT00, -8785, -300, 7383, 0 }, - { SCENE_SPOT00, -8745, -300, 7508, 0 }, - { SCENE_SPOT00, -8777, -300, 7788, 0 }, - { SCENE_SPOT00, -8048, -299, 7738, 0 }, - { SCENE_SPOT00, -7341, -184, 7730, 0 }, - { SCENE_SPOT00, -6410, -288, 7824, 0 }, - { SCENE_SPOT00, -6326, -290, 8205, 0 }, - { SCENE_SPOT00, -6546, -292, 8400, 0 }, - { SCENE_SPOT00, -7533, -180, 8459, 0 }, - { SCENE_SPOT00, -8024, -295, 7903, 0 }, - { SCENE_SPOT00, -8078, -308, 7994, 0 }, - { SCENE_SPOT00, -9425, -287, 7696, 0 }, - { SCENE_SPOT00, -9322, -292, 7577, 0 }, - { SCENE_SPOT00, -9602, -199, 7160, 0 }, - { SCENE_SPOT00, -9307, -300, 7758, 0 }, - { SCENE_SPOT00, -9230, -300, 7642, 0 }, - { SCENE_SPOT00, -7556, -499, 8695, 0 }, - { SCENE_SPOT00, -6438, -500, 8606, 0 }, - { SCENE_SPOT00, -6078, -500, 8258, 0 }, - { SCENE_SPOT00, -6233, -500, 7613, 0 }, - { SCENE_SPOT00, -5035, -205, 7814, 0 }, - { SCENE_SPOT00, -5971, -500, 8501, 0 }, - { SCENE_SPOT00, -5724, -498, 10123, 0 }, - { SCENE_SPOT00, -5094, -392, 11106, 0 }, - { SCENE_SPOT00, -5105, -393, 11312, 0 }, - { SCENE_SPOT00, -4477, -314, 11132, 0 }, - { SCENE_SPOT00, -3867, -380, 11419, 0 }, - { SCENE_SPOT00, -2952, -500, 11944, 0 }, - { SCENE_SPOT00, -2871, -488, 11743, 0 }, - { SCENE_SPOT00, -3829, -372, 11327, 0 }, - { SCENE_SPOT00, -4439, -293, 10989, 0 }, - { SCENE_SPOT00, -5014, -381, 11086, 0 }, - { SCENE_SPOT00, -5113, -188, 10968, 0 }, - { SCENE_SPOT00, -5269, -188, 11156, 0 }, - { SCENE_SPOT00, -5596, -178, 9972, 0 }, - { SCENE_SPOT00, -5801, -288, 8518, 0 }, - { SCENE_SPOT00, -4910, -178, 7931, 0 }, - { SCENE_SPOT00, -3586, 73, 8140, 0 }, - { SCENE_SPOT00, -4487, -106, 9362, 0 }, - { SCENE_SPOT00, -4339, -112, 6412, 0 }, - { SCENE_SPOT00, -3417, 105, 8194, 0 }, - { SCENE_SPOT00, -4505, -20, 6608, 0 }, - { SCENE_SPOT00, -5038, -199, 6603, 0 }, - { SCENE_SPOT00, -4481, 1, 6448, 0 }, - { SCENE_SPOT00, -5032, -168, 6418, 0 }, - { SCENE_SPOT00, -5256, -700, 14329, 0 }, - { SCENE_SPOT00, -5749, -820, 15380, 0 }, - { SCENE_SPOT00, -3122, -700, 13608, 0 }, - { SCENE_SPOT00, -3758, -525, 13228, 0 }, - { SCENE_SPOT00, -3670, -500, 13123, 0 }, - { SCENE_SPOT00, -2924, -500, 13526, 0 }, - { SCENE_SPOT00, 1389, -115, 9370, 0 }, - { SCENE_SPOT00, 548, -116, 8889, 0 }, - { SCENE_SPOT00, -106, -107, 8530, 0 }, - { SCENE_SPOT00, -1608, 85, 7646, 0 }, - { SCENE_SPOT00, -5300, -700, 13772, 0 }, - { SCENE_SPOT00, -5114, -700, 13400, 0 }, - { SCENE_SPOT00, -4561, -700, 13700, 0 }, - { SCENE_SPOT00, -4762, -700, 14084, 0 }, - { SCENE_SPOT00, -2954, 100, 8216, 0 }, - { SCENE_SPOT00, 1460, -104, 9246, 0 }, - { SCENE_SPOT00, 629, -105, 8791, 0 }, - { SCENE_SPOT00, -10, -90, 8419, 0 }, - { SCENE_SPOT00, -1462, 100, 7504, 0 }, - { SCENE_SPOT00, -3018, -500, 12493, 0 }, - { SCENE_SPOT00, -2994, -311, 10331, 0 }, - { SCENE_SPOT00, -4006, -700, 14152, 0 }, - { SCENE_SPOT00, -4341, -500, 12743, 0 }, - { SCENE_SPOT00, -5879, -497, 6799, 0 }, - { SCENE_SPOT00, 22, -473, 10103, 0 }, - { SCENE_SPOT00, -1389, -192, 8874, 0 }, - { SCENE_SPOT00, -4, 92, 6866, 0 }, - { SCENE_SPOT00, 483, 104, 6637, 0 }, - { SCENE_SPOT00, 1580, 183, 5987, 0 }, - { SCENE_SPOT00, 1548, 308, 5077, 0 }, - { SCENE_SPOT00, 1511, 399, 4267, 0 }, - { SCENE_SPOT00, 1358, 385, 4271, 0 }, - { SCENE_SPOT00, 1379, 395, 5063, 0 }, - { SCENE_SPOT00, 1360, 394, 5870, 0 }, - { SCENE_SPOT00, 813, 283, 6194, 0 }, - { SCENE_SPOT00, -57, 101, 6743, 0 }, - { SCENE_SPOT00, 91, 325, 5143, 0 }, - { SCENE_SPOT00, 1425, -214, 7659, 0 }, - { SCENE_SPOT00, 3487, -19, 880, 0 }, - { SCENE_SPOT00, 2933, 152, 2094, 0 }, - { SCENE_SPOT00, 2888, -145, 6862, 0 }, - { SCENE_SPOT00, 1511, 67, 6471, 0 }, - { SCENE_SPOT00, 4051, -47, 1722, 0 }, - { SCENE_SPOT00, -7335, -500, 8627, 0 }, - { SCENE_SPOT00, -7728, -462, 8498, 0 }, - { SCENE_SPOT00, -7791, -446, 8832, 0 }, - { SCENE_SPOT00, -2915, -435, 11334, 0 }, - { SCENE_SPOT00, 165, -278, 3352, 0 }, - - // Lake Hylia - { SCENE_SPOT06, -2109, -882, 1724, 0 }, - { SCENE_SPOT06, -328, -1238, 2705, 0 }, - { SCENE_SPOT06, -3092, -1033, 3527, 0 }, - - // Gerudo Valley - { SCENE_SPOT09, 2687, -269, 753, 0 }, - { SCENE_SPOT09, 2066, -132, 317, 0 }, - { SCENE_SPOT09, 523, -8, 635, 0 }, - { SCENE_SPOT09, 558, 36, -323, 0 }, - { SCENE_SPOT09, 615, 51, -839, 0 }, - { SCENE_SPOT09, -614, 32, 29, 0 }, - { SCENE_SPOT09, -639, -3, 553, 0 }, - { SCENE_SPOT09, -540, 10, -889, 0 }, - { SCENE_SPOT09, -1666, 58, 378, 0 }, - { SCENE_SPOT09, -3044, 210, -648, 0 }, - - // Gerudo's Fortress - { SCENE_SPOT12, -678, 21, -623, 0 }, - { SCENE_SPOT12, 149, 333, -2499, 0 }, - { SCENE_SPOT12, 499, 581, -547, 0 }, - { SCENE_SPOT12, 3187, 1413, -3775, 0 }, - { SCENE_SPOT12, 3198, 1413, 307, 0 }, - { SCENE_SPOT12, 3380, 1413, -1200, 0 }, - { SCENE_SPOT12, -966, 1, -56, 0 }, - { SCENE_SPOT12, -966, 24, -761, 0 }, - { SCENE_SPOT12, -694, 174, -2820, 0 }, - - // Lon Lon Ranch - { SCENE_SPOT20, 1039, 0, 2051, 0 }, - { SCENE_SPOT20, -1443, 0, 1429, 0 }, - { SCENE_SPOT20, 856, 0, -918, 0 }, // Hardcoded to always load in lon lon - { SCENE_SPOT20, 882, 0, -2256, 0 }, - { SCENE_SPOT20, -1003, 0, -755, 0 }, // Hardcoded to always load in lon lon - { SCENE_SPOT20, -2254, 0, -629, 0 }, - { SCENE_SPOT20, 907, 0, -2336, 0 }, -}; - -typedef struct { - s16 zMin; - s16 zMax; - - s16 xMin; - s16 xMax; - s16 xOffset; - - s16 angle; - s16 angleRange; - - Vec3s pos; -} BridgeJumpPoint; - -static BridgeJumpPoint sBridgeJumps[] = { - { -195, -40, 225, 120, 360, -0x4000, 0x7D0, -270, -52, -117 }, - { -195, -40, -240, -120, -360, 0x4000, 0x7D0, 270, -52, -117 }, -}; - -typedef struct { - s16 x; - s16 y; - s16 z; - s16 speed; - s16 angle; -} RaceWaypoint; - -typedef struct { - s32 numWaypoints; - RaceWaypoint* waypoints; -} RaceInfo; - -static RaceWaypoint sIngoRaceWaypoints[] = { - { 1056, 1, -1540, 11, 0x2A8D }, { 1593, 1, -985, 10, 0xFC27 }, { 1645, 1, -221, 11, 0xE891 }, - { 985, 1, 403, 10, 0xBB9C }, { -1023, 1, 354, 11, 0xA37D }, { -1679, 1, -213, 10, 0x889C }, - { -1552, 1, -1008, 11, 0x638D }, { -947, -1, -1604, 10, 0x4002 }, -}; - -static RaceInfo sIngoRace = { 8, sIngoRaceWaypoints }; -static s32 sAnimSoundFrames[] = { 0, 16 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 600, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), -}; - -static u8 sResetNoInput[] = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 }; - -static s32 sIdleAnimIds[] = { 1, 3, 0, 3, 1, 0 }; - -static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; - -void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); - -static EnHorseCsFunc sCutsceneInitFuncs[] = { - NULL, - EnHorse_CsMoveInit, - EnHorse_CsJumpInit, - EnHorse_CsRearingInit, - EnHorse_WarpMoveInit, - EnHorse_CsWarpRearingInit, -}; - -void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); -void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); - -static EnHorseCsFunc sCutsceneActionFuncs[] = { - NULL, EnHorse_CsMoveToPoint, EnHorse_CsJump, EnHorse_CsRearing, EnHorse_CsWarpMoveToPoint, EnHorse_CsWarpRearing, -}; - -typedef struct { - s32 csAction; - s32 csFuncIdx; -} CsActionEntry; - -static CsActionEntry sCsActionTable[] = { - { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, -}; - -static RaceWaypoint sHbaWaypoints[] = { - { 3600, 1413, -5055, 11, 0x8001 }, { 3360, 1413, -5220, 5, 0xC000 }, { 3100, 1413, -4900, 5, 0x0000 }, - { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, -}; - -static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; - -static EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_BridgeJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, -}; - -s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* this, GlobalContext* globalCtx) { - f32 xMin; - f32 xMax; - s32 i; - - if (globalCtx->sceneNum != SCENE_SPOT09) { - return false; - } - if (this->actor.speedXZ < 12.8f) { - return false; - } - if ((gSaveContext.eventChkInf[9] & 0xF) == 0xF) { - return false; - } - - for (i = 0; i < 2; i++) { - xMin = sBridgeJumps[i].xMin; - xMax = (xMin + sBridgeJumps[i].xMax) + sBridgeJumps[i].xOffset; - if (xMax < xMin) { - f32 temp = xMin; - - xMin = xMax; - xMax = temp; - } - if (sBridgeJumps[i].zMin < this->actor.world.pos.z && this->actor.world.pos.z < sBridgeJumps[i].zMax) { - if (xMin < this->actor.world.pos.x && this->actor.world.pos.x < xMax) { - if (sBridgeJumps[i].angle - sBridgeJumps[i].angleRange < this->actor.world.rot.y && - this->actor.world.rot.y < sBridgeJumps[i].angle + sBridgeJumps[i].angleRange) { - return true; - } - } - } - } - return false; -} - -void EnHorse_StartBridgeJump(EnHorse* this, GlobalContext* globalCtx); - -s32 EnHorse_CheckBridgeJumps(EnHorse* this, GlobalContext* globalCtx) { - f32 xMin; - f32 xMax; - s32 i; - - if (this->actor.speedXZ < 12.8f) { - return false; - } - - for (i = 0; i != 2; i++) { - xMin = sBridgeJumps[i].xMin; - xMax = sBridgeJumps[i].xMax + xMin; - - if (xMax < xMin) { - f32 temp = xMin; - - xMin = xMax; - xMax = temp; - } - - if (sBridgeJumps[i].zMin < this->actor.world.pos.z && this->actor.world.pos.z < sBridgeJumps[i].zMax) { - if (xMin < this->actor.world.pos.x && this->actor.world.pos.x < xMax) { - if (sBridgeJumps[i].angle - sBridgeJumps[i].angleRange < this->actor.world.rot.y && - this->actor.world.rot.y < sBridgeJumps[i].angle + sBridgeJumps[i].angleRange) { - this->bridgeJumpIdx = i; - EnHorse_StartBridgeJump(this, globalCtx); - return true; - } - } - } - } - - return false; -} - -void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { - pos->x = waypoints[idx].x; - pos->y = waypoints[idx].y; - pos->z = waypoints[idx].z; -} - -void EnHorse_RotateToPoint(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { - func_8006DD9C(&this->actor, pos, turnAmount); -} - -void EnHorse_UpdateIngoRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { - Vec3f curWaypointPos; - Vec3f prevWaypointPos; - f32 playerDist; - f32 sp50; - s16 relPlayerYaw; - f32 px; - f32 pz; - f32 d; - f32 dist; - s32 prevWaypoint; - - EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &curWaypointPos); - Math3D_RotateXZPlane(&curWaypointPos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d); - if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { - this->curRaceWaypoint++; - if (this->curRaceWaypoint >= raceInfo->numWaypoints) { - this->curRaceWaypoint = 0; - } - } - - EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &curWaypointPos); - - prevWaypoint = this->curRaceWaypoint - 1; - if (prevWaypoint < 0) { - prevWaypoint = raceInfo->numWaypoints - 1; - } - EnHorse_RaceWaypointPos(raceInfo->waypoints, prevWaypoint, &prevWaypointPos); - Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, prevWaypointPos.x, prevWaypointPos.z, - curWaypointPos.x, curWaypointPos.z, &dist); - EnHorse_RotateToPoint(this, globalCtx, &curWaypointPos, 400); - - if (dist < 90000.0f) { - playerDist = this->actor.xzDistToPlayer; - if (playerDist < 130.0f || this->jntSph.elements[0].info.ocElemFlags & 2) { - if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { - this->actor.world.rot.y = this->actor.world.rot.y - 280; - } else { - this->actor.world.rot.y = this->actor.world.rot.y + 280; - } - } else if (playerDist < 300.0f) { - if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { - this->actor.world.rot.y = this->actor.world.rot.y + 280; - } else { - this->actor.world.rot.y = this->actor.world.rot.y - 280; - } - } - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - sp50 = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - relPlayerYaw = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; - if (sp50 <= 200.0f || (fabsf(Math_SinS(relPlayerYaw)) < 0.8f && Math_CosS(relPlayerYaw) > 0.0f)) { - if (this->actor.speedXZ < this->ingoHorseMaxSpeed) { - this->actor.speedXZ += 0.47f; - } else { - this->actor.speedXZ -= 0.47f; - } - this->ingoRaceFlags |= 1; - return; - } - - if (this->actor.speedXZ < raceInfo->waypoints[this->curRaceWaypoint].speed) { - this->actor.speedXZ = this->actor.speedXZ + 0.4f; - } else { - this->actor.speedXZ = this->actor.speedXZ - 0.4f; - } - this->ingoRaceFlags &= ~0x1; -} - -void EnHorse_PlayWalkingSound(EnHorse* this) { - if (sAnimSoundFrames[this->soundTimer] < this->curFrame) { - if (this->soundTimer == 0 && (sAnimSoundFrames[1] < this->curFrame)) { - return; - } - - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_WALK, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - if (++this->soundTimer > 1) { - this->soundTimer = 0; - } - } -} - -void EnHorse_PlayTrottingSound(EnHorse* this) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); -} - -void EnHorse_PlayGallopingSound(EnHorse* this) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); -} - -f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { - f32 multiplier = 1.0f; - - if (Math_CosS(this->actor.shape.rot.x) < 0.939262f && Math_SinS(this->actor.shape.rot.x) < 0.0f) { - multiplier = 0.7f; - } - return multiplier; -} - -void func_80A5BB90(GlobalContext* globalCtx, Vec3f* vec, Vec3f* arg2, f32* arg3) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, vec, arg2, arg3); -} - -s32 func_80A5BBBC(GlobalContext* globalCtx, EnHorse* this, Vec3f* pos) { - Vec3f sp24; - f32 sp20; - f32 eyeDist; - - func_80A5BB90(globalCtx, pos, &sp24, &sp20); - if (fabsf(sp20) < 0.008f) { - return false; - } - eyeDist = Math3D_Vec3f_DistXYZ(pos, &globalCtx->view.eye); - return Actor_IsInUncullZone(globalCtx, &this->actor, &sp24, sp20) || eyeDist < 100.0f; -} - -void EnHorse_IdleAnimSounds(EnHorse* this, GlobalContext* globalCtx) { - if (this->animationIdx == ENHORSE_ANIM_IDLE && - ((this->curFrame > 35.0f && this->type == HORSE_EPONA) || - (this->curFrame > 28.0f && this->type == HORSE_HNI)) && - !(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { - this->stateFlags |= ENHORSE_SANDDUST_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (this->animationIdx == ENHORSE_ANIM_REARING && this->curFrame > 25.0f && - !(this->stateFlags & ENHORSE_LAND2_SOUND)) { - this->stateFlags |= ENHORSE_LAND2_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { - f32 minDist = 1e38f; - s32 spawn = false; - f32 dist; - s32 i; - Player* player; - Vec3f spawnPos; - - for (i = 0; i < 169; i++) { - if (sHorseSpawns[i].scene == globalCtx->sceneNum) { - player = GET_PLAYER(globalCtx); - if (globalCtx->sceneNum != SCENE_SPOT20 || - //! Same flag checked twice - (Flags_GetEventChkInf(0x18) && ((gSaveContext.eventInf[0] & 0xF) != 6 || Flags_GetEventChkInf(0x18))) || - // always load two spawns inside lon lon - ((sHorseSpawns[i].pos.x == 856 && sHorseSpawns[i].pos.y == 0 && sHorseSpawns[i].pos.z == -918) || - (sHorseSpawns[i].pos.x == -1003 && sHorseSpawns[i].pos.y == 0 && sHorseSpawns[i].pos.z == -755))) { - - spawnPos.x = sHorseSpawns[i].pos.x; - spawnPos.y = sHorseSpawns[i].pos.y; - spawnPos.z = sHorseSpawns[i].pos.z; - dist = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &spawnPos); - - if (globalCtx->sceneNum) {} - if (!(minDist < dist) && !func_80A5BBBC(globalCtx, this, &spawnPos)) { - minDist = dist; - this->actor.world.pos.x = sHorseSpawns[i].pos.x; - this->actor.world.pos.y = sHorseSpawns[i].pos.y; - this->actor.world.pos.z = sHorseSpawns[i].pos.z; - this->actor.prevPos = this->actor.world.pos; - this->actor.world.rot.y = sHorseSpawns[i].angle; - this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - spawn = true; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, - &this->actor.projectedPos, &this->actor.projectedW); - } - } - } - } - - return spawn; -} - -void EnHorse_ResetCutscene(EnHorse* this, GlobalContext* globalCtx) { - this->cutsceneAction = -1; - this->cutsceneFlags = 0; -} - -void EnHorse_ResetRace(EnHorse* this, GlobalContext* globalCtx) { - this->inRace = false; -} - -s32 EnHorse_PlayerCanMove(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((player->stateFlags1 & 1) || func_8002DD78(GET_PLAYER(globalCtx)) == 1 || (player->stateFlags1 & 0x100000) || - ((this->stateFlags & ENHORSE_FLAG_19) && !this->inRace) || this->action == ENHORSE_ACT_HBA || - player->actor.flags & ACTOR_FLAG_8 || globalCtx->csCtx.state != 0) { - return false; - } - return true; -} - -void EnHorse_ResetHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { - this->unk_39C = 0; - this->hbaStarted = 0; - this->hbaFlags = 0; -} - -void EnHorse_ClearDustFlags(u16* dustFlags) { - *dustFlags = 0; -} - -void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnHorse* this = (EnHorse*)thisx; - GlobalContext* globalCtx = globalCtx2; - - AREG(6) = 0; - Actor_ProcessInitChain(&this->actor, sInitChain); - EnHorse_ClearDustFlags(&this->dustFlags); - DREG(53) = 0; - this->riderPos = this->actor.world.pos; - this->noInputTimer = 0; - this->noInputTimerMax = 0; - this->riderPos.y = this->riderPos.y + 70.0f; - - if (DREG(4) == 0) { - DREG(4) = 70; - } - - if (this->actor.params & 0x8000) { - this->actor.params &= ~0x8000; - this->type = HORSE_HNI; - - if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HNI)) < 0) { - Actor_Kill(&this->actor); - return; - } - - do { - } while (!Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)); - - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); - this->boostSpeed = 12; - } else { - this->type = HORSE_EPONA; - this->boostSpeed = 14; - } - - // params was -1 - if (this->actor.params == 0x7FFF) { - this->actor.params = 1; - } - - if (globalCtx->sceneNum == SCENE_SOUKO) { - this->stateFlags = ENHORSE_UNRIDEABLE; - } else if (globalCtx->sceneNum == SCENE_SPOT12 && this->type == HORSE_HNI) { - this->stateFlags = ENHORSE_FLAG_18 | ENHORSE_UNRIDEABLE; - } else { - if (this->actor.params == 3) { - this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; - } else if (this->actor.params == 6) { - this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; - if (Flags_GetEventChkInf(0x18) || DREG(1) != 0) { - this->stateFlags &= ~ENHORSE_CANT_JUMP; - this->stateFlags |= ENHORSE_FLAG_26; - } else if (gSaveContext.eventInf[0] & 0x40 && this->type == HORSE_HNI) { - this->stateFlags |= ENHORSE_FLAG_21 | ENHORSE_FLAG_20; - } - } else if (this->actor.params == 1) { - this->stateFlags = ENHORSE_FLAG_7; - } else { - this->stateFlags = 0; - } - } - - if (globalCtx->sceneNum == SCENE_SPOT20 && (gSaveContext.eventInf[0] & 0xF) == 6 && - Flags_GetEventChkInf(0x18) == 0 && !DREG(1)) { - this->stateFlags |= ENHORSE_FLAG_25; - } - - Actor_SetScale(&this->actor, 0.01f); - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->action = ENHORSE_ACT_IDLE; - this->actor.speedXZ = 0.0f; - Collider_InitCylinder(globalCtx, &this->cyl1); - Collider_SetCylinder(globalCtx, &this->cyl1, &this->actor, &sCylinderInit1); - Collider_InitCylinder(globalCtx, &this->cyl2); - Collider_SetCylinder(globalCtx, &this->cyl2, &this->actor, &sCylinderInit2); - Collider_InitJntSph(globalCtx, &this->jntSph); - Collider_SetJntSph(globalCtx, &this->jntSph, &this->actor, &sJntSphInit, &this->jntSphList); - CollisionCheck_SetInfo(&this->actor.colChkInfo, DamageTable_Get(0xB), &D_80A65F38); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - this->playerControlled = false; - - if ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.sceneSetupIndex < 4)) { - if (this->type == HORSE_HNI) { - if (this->actor.world.rot.z == 0 || gSaveContext.nightFlag) { - Actor_Kill(&this->actor); - return; - } - if (Flags_GetEventChkInf(0x18)) { - Actor_Kill(&this->actor); - return; - } - if (this->actor.world.rot.z != 5) { - Actor_Kill(&this->actor); - return; - } - } else if (!Flags_GetEventChkInf(0x18) && !DREG(1) && gSaveContext.nightFlag) { - Actor_Kill(&this->actor); - return; - } - } else if (globalCtx->sceneNum == SCENE_MALON_STABLE) { - if (IS_DAY || Flags_GetEventChkInf(0x18) || DREG(1) != 0 || !LINK_IS_ADULT) { - Actor_Kill(&this->actor); - return; - } - this->stateFlags |= ENHORSE_UNRIDEABLE; - } - - func_800A663C(globalCtx, &this->skin, sSkeletonHeaders[this->type], - sAnimationHeaders[this->type][ENHORSE_ANIM_IDLE]); - this->animationIdx = ENHORSE_ANIM_IDLE; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); - this->numBoosts = 6; - this->blinkTimer = this->postDrawFunc = this->boostRegenTime = 0; - EnHorse_ResetCutscene(this, globalCtx); - EnHorse_ResetRace(this, globalCtx); - EnHorse_ResetHorsebackArchery(this, globalCtx); - - if (this->actor.params == 2) { - EnHorse_InitInactive(this); - } else if (this->actor.params == 3) { - EnHorse_InitIngoHorse(this); - this->rider = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, 1, 1); - if (this->rider == NULL) { - __assert("this->race.rider != NULL", "../z_en_horse.c", 3077); - } - if (!(gSaveContext.eventInf[0] & 0x40)) { - this->ingoHorseMaxSpeed = 12.07f; - } else { - this->ingoHorseMaxSpeed = 12.625f; - } - } else if (this->actor.params == 7) { - EnHorse_InitCutscene(this, globalCtx); - } else if (this->actor.params == 8) { - EnHorse_InitHorsebackArchery(this); - Interface_InitHorsebackArchery(globalCtx); - } else if (globalCtx->sceneNum == SCENE_SPOT20 && !Flags_GetEventChkInf(0x18) && !DREG(1)) { - EnHorse_InitFleePlayer(this); - } else { - if (globalCtx->sceneNum == SCENE_SOUKO) { - EnHorse_ResetIdleAnimation(this); - } else if (globalCtx->sceneNum == SCENE_SPOT12 && this->type == HORSE_HNI) { - EnHorse_ResetIdleAnimation(this); - } else { - EnHorse_StartIdleRidable(this); - } - } - this->actor.home.rot.z = this->actor.world.rot.z = this->actor.shape.rot.z = 0; -} - -void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHorse* this = (EnHorse*)thisx; - - if (this->stateFlags & ENHORSE_DRAW) { - Audio_StopSfxByPos(&this->unk_21C); - } - func_800A6888(globalCtx, &this->skin); - Collider_DestroyCylinder(globalCtx, &this->cyl1); - Collider_DestroyCylinder(globalCtx, &this->cyl2); - Collider_DestroyJntSph(globalCtx, &this->jntSph); -} - -void EnHorse_RotateToPlayer(EnHorse* this, GlobalContext* globalCtx) { - EnHorse_RotateToPoint(this, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 400); - if (this->stateFlags & ENHORSE_OBSTACLE) { - this->actor.world.rot.y += 800.0f; - } - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnHorse_Freeze(EnHorse* this) { - if (this->action != ENHORSE_ACT_CS_UPDATE && this->action != ENHORSE_ACT_HBA) { - if (sResetNoInput[this->actor.params] != 0 && this->actor.params != 4) { - this->noInputTimer = 0; - this->noInputTimerMax = 0; - } - this->prevAction = this->action; - this->action = ENHORSE_ACT_FROZEN; - this->cyl1.base.ocFlags1 &= ~OC1_ON; - this->cyl2.base.ocFlags1 &= ~OC1_ON; - this->jntSph.base.ocFlags1 &= ~OC1_ON; - this->animationIdx = ENHORSE_ANIM_IDLE; - } -} - -void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 arg1, f32 arg2); -void EnHorse_StartMountedIdleResetAnim(EnHorse* this); -void EnHorse_StartMountedIdle(EnHorse* this); -void EnHorse_StartGalloping(EnHorse* this); - -void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - this->noInputTimer--; - if (this->noInputTimer < 0) { - this->cyl1.base.ocFlags1 |= OC1_ON; - this->cyl2.base.ocFlags1 |= OC1_ON; - this->jntSph.base.ocFlags1 |= OC1_ON; - if (this->playerControlled == true) { - this->stateFlags &= ~ENHORSE_FLAG_7; - if (this->actor.params == 4) { - EnHorse_StartMountedIdleResetAnim(this); - } else if (this->actor.params == 9) { - this->actor.params = 5; - if (globalCtx->csCtx.state != 0) { - EnHorse_StartMountedIdle(this); - } else { - this->actor.speedXZ = 8.0f; - EnHorse_StartGalloping(this); - } - } else if (this->prevAction == 2) { - EnHorse_StartMountedIdle(this); - } else { - EnHorse_StartMountedIdleResetAnim(this); - } - if (this->actor.params != 0) { - this->actor.params = 0; - return; - } - } else { - if (this->prevAction == 5) { - EnHorse_ChangeIdleAnimation(this, 0, 0); - return; - } - if (this->prevAction == 6) { - EnHorse_ChangeIdleAnimation(this, 0, 0); - return; - } - EnHorse_ChangeIdleAnimation(this, 0, 0); - } - } -} - -void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); - -void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, - f32 decel, f32 baseSpeed, s16 turnSpeed) { - s16* stickAnglePtr; // probably fake - f32 stickMag; - s16 stickAngle; - f32 temp_f12; - f32 traction; - s16 turn; - - if (!EnHorse_PlayerCanMove(this, globalCtx)) { - if (this->actor.speedXZ > 8) { - this->actor.speedXZ -= decel; - } else if (this->actor.speedXZ < 0) { - this->actor.speedXZ = 0; - } - - return; - } - - stickAnglePtr = &stickAngle; - - baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, globalCtx); - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (Math_CosS(stickAngle) <= brakeAngle) { - this->actor.speedXZ -= brakeDecel; - this->actor.speedXZ = this->actor.speedXZ < 0.0f ? 0.0f : this->actor.speedXZ; - return; - } - - if (stickMag < minStickMag) { - this->stateFlags &= ~ENHORSE_BOOST; - this->stateFlags &= ~ENHORSE_BOOST_DECEL; - this->actor.speedXZ -= decel; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; - } - - return; - } - - if (this->stateFlags & ENHORSE_BOOST) { - if ((16 - this->boostTimer) > 0) { - this->actor.speedXZ = - (EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed - this->actor.speedXZ) / - (16 - this->boostTimer) + - this->actor.speedXZ; - } else { - this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed; - } - - if ((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) <= this->actor.speedXZ) { - this->stateFlags &= ~ENHORSE_BOOST; - this->stateFlags |= ENHORSE_BOOST_DECEL; - } - - } else if (this->stateFlags & ENHORSE_BOOST_DECEL) { - if (baseSpeed < this->actor.speedXZ) { - temp_f12 = this->actor.speedXZ; - this->actor.speedXZ = temp_f12 - 0.06f; - } else if (this->actor.speedXZ < baseSpeed) { - this->actor.speedXZ = baseSpeed; - this->stateFlags &= ~ENHORSE_BOOST_DECEL; - } - } else { - this->actor.speedXZ += - (this->actor.speedXZ <= baseSpeed * (1.0f / 54.0f) * stickMag ? 1.0f : -1.0f) * 50.0f * 0.01f; - if (baseSpeed < this->actor.speedXZ) { - this->actor.speedXZ = this->actor.speedXZ - decel; - if (this->actor.speedXZ < baseSpeed) { - this->actor.speedXZ = baseSpeed; - } - } - } - - temp_f12 = *stickAnglePtr * (1 / 32236.f); - traction = 2.2f - (this->actor.speedXZ * (1.0f / this->boostSpeed)); - turn = *stickAnglePtr * temp_f12 * temp_f12 * traction; - turn = CLAMP(turn, -turnSpeed * traction, turnSpeed * traction); - this->actor.world.rot.y += turn; - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnHorse_StartMountedIdleResetAnim(EnHorse* this) { - this->skin.skelAnime.curFrame = 0.0f; - EnHorse_StartMountedIdle(this); - this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; -} - -void EnHorse_StartMountedIdle(EnHorse* this) { - f32 curFrame; - - this->action = ENHORSE_ACT_MOUNTED_IDLE; - this->animationIdx = ENHORSE_ANIM_IDLE; - if ((this->curFrame > 35.0f && this->type == HORSE_EPONA) || (this->curFrame > 28.0f && this->type == HORSE_HNI)) { - if (!(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { - this->stateFlags |= ENHORSE_SANDDUST_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - curFrame = this->skin.skelAnime.curFrame; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_StartReversingInterruptable(EnHorse* this); -void EnHorse_StartTurning(EnHorse* this); -void EnHorse_StartWalkingFromIdle(EnHorse* this); -void EnHorse_MountedIdleAnim(EnHorse* this); -void EnHorse_StartReversing(EnHorse* this); -void EnHorse_StartWalkingInterruptable(EnHorse* this); -void EnHorse_MountedIdleWhinney(EnHorse* this); -void EnHorse_StartWalking(EnHorse* this); - -void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { - f32 mag; - s16 angle = 0; - - this->actor.speedXZ = 0; - EnHorse_StickDirection(&this->curStick, &mag, &angle); - if (mag > 10.0f && EnHorse_PlayerCanMove(this, globalCtx) == true) { - if (Math_CosS(angle) <= -0.5f) { - EnHorse_StartReversingInterruptable(this); - } else if (Math_CosS(angle) <= 0.7071) { // cos(45 degrees) - EnHorse_StartTurning(this); - } else { - EnHorse_StartWalkingFromIdle(this); - } - } - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorse_MountedIdleAnim(this); - } -} - -void EnHorse_MountedIdleAnim(EnHorse* this) { - this->skin.skelAnime.curFrame = 0.0f; - EnHorse_MountedIdleWhinney(this); -} - -void EnHorse_MountedIdleWhinney(EnHorse* this) { - f32 curFrame; - - this->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; - this->animationIdx = ENHORSE_ANIM_WHINNEY; - curFrame = this->skin.skelAnime.curFrame; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 stickAngle = 0; - - this->actor.speedXZ = 0; - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (stickMag > 10.0f && EnHorse_PlayerCanMove(this, globalCtx) == true) { - if (Math_CosS(stickAngle) <= -0.5f) { - EnHorse_StartReversingInterruptable(this); - } else if (Math_CosS(stickAngle) <= 0.7071) { // cos(45 degrees) - EnHorse_StartTurning(this); - } else { - EnHorse_StartWalkingFromIdle(this); - } - } - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorse_StartMountedIdleResetAnim(this); - } -} - -void EnHorse_StartTurning(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_TURN; - this->soundTimer = 0; - this->animationIdx = ENHORSE_ANIM_WALK; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 clampedYaw; - s16 stickAngle; - - this->actor.speedXZ = 0; - EnHorse_PlayWalkingSound(this); - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (stickMag > 10.0f) { - if (!EnHorse_PlayerCanMove(this, globalCtx)) { - EnHorse_StartMountedIdleResetAnim(this); - } else if (Math_CosS(stickAngle) <= -0.5f) { - EnHorse_StartReversingInterruptable(this); - } else if (Math_CosS(stickAngle) <= 0.7071) { // cos(45 degrees) - clampedYaw = CLAMP(stickAngle, -800.0f, 800.0f); - this->actor.world.rot.y = this->actor.world.rot.y + clampedYaw; - this->actor.shape.rot.y = this->actor.world.rot.y; - } else { - EnHorse_StartWalkingInterruptable(this); - } - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - if (Math_CosS(stickAngle) <= 0.7071) { // cos(45 degrees) - EnHorse_StartTurning(this); - } else { - EnHorse_StartMountedIdleResetAnim(this); - } - } -} - -void EnHorse_StartWalkingFromIdle(EnHorse* this) { - EnHorse_StartWalkingInterruptable(this); - - if (!(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { - this->stateFlags |= ENHORSE_FLAG_9; - this->waitTimer = 8; - return; - } - this->waitTimer = 0; -} - -void EnHorse_StartWalkingInterruptable(EnHorse* this) { - this->noInputTimer = 0; - this->noInputTimerMax = 0; - EnHorse_StartWalking(this); -} - -void EnHorse_StartWalking(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_WALK; - this->soundTimer = 0; - this->animationIdx = ENHORSE_ANIM_WALK; - this->waitTimer = 0; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_MountedWalkingReset(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_WALK; - this->soundTimer = 0; - this->animationIdx = ENHORSE_ANIM_WALK; - this->waitTimer = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); -} - -void EnHorse_StartTrotting(EnHorse* this); - -void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 stickAngle; - - EnHorse_PlayWalkingSound(this); - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (this->noInputTimerMax == 0.0f || - (this->noInputTimer > 0.0f && this->noInputTimer < this->noInputTimerMax - 20.0f)) { - EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 400); - } else { - this->actor.speedXZ = 3.0f; - } - - if (this->actor.speedXZ == 0.0f) { - this->stateFlags &= ~ENHORSE_FLAG_9; - EnHorse_StartMountedIdleResetAnim(this); - this->noInputTimer = 0; - this->noInputTimerMax = 0; - } else if (this->actor.speedXZ > 3.0f) { - this->stateFlags &= ~ENHORSE_FLAG_9; - EnHorse_StartTrotting(this); - this->noInputTimer = 0; - this->noInputTimerMax = 0; - } - - if (this->noInputTimer > 0.0f) { - this->noInputTimer--; - if (this->noInputTimer <= 0.0f) { - this->noInputTimerMax = 0; - } - } - - if (this->waitTimer <= 0) { - this->stateFlags &= ~ENHORSE_FLAG_9; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; - if (SkelAnime_Update(&this->skin.skelAnime) || this->actor.speedXZ == 0.0f) { - if (this->noInputTimer <= 0.0f) { - if (this->actor.speedXZ > 3.0f) { - EnHorse_StartTrotting(this); - this->noInputTimer = 0; - this->noInputTimerMax = 0; - } else if ((stickMag < 10.0f) || (Math_CosS(stickAngle) <= -0.5f)) { - EnHorse_StartMountedIdleResetAnim(this); - this->noInputTimer = 0; - this->noInputTimerMax = 0; - } else { - EnHorse_MountedWalkingReset(this); - } - } - } - } else { - this->actor.speedXZ = 0.0f; - this->waitTimer--; - } -} - -void EnHorse_StartTrotting(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_TROT; - this->animationIdx = ENHORSE_ANIM_TROT; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_MountedTrotReset(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_TROT; - this->animationIdx = ENHORSE_ANIM_TROT; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); -} - -void EnHorse_StartGallopingInterruptable(EnHorse* this); - -void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 stickAngle; - - EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 400); - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (this->actor.speedXZ < 3.0f) { - EnHorse_StartWalkingInterruptable(this); - } - - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorse_PlayTrottingSound(this); - func_800AA000(0.0f, 60, 8, 255); - if (this->actor.speedXZ >= 6.0f) { - EnHorse_StartGallopingInterruptable(this); - } else if (this->actor.speedXZ < 3.0f) { - EnHorse_StartWalkingInterruptable(this); - } else { - EnHorse_MountedTrotReset(this); - } - } -} - -void EnHorse_StartGallopingInterruptable(EnHorse* this) { - this->noInputTimerMax = 0; - this->noInputTimer = 0; - EnHorse_StartGalloping(this); -} - -void EnHorse_StartGalloping(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_GALLOP; - this->animationIdx = ENHORSE_ANIM_GALLOP; - this->unk_234 = 0; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_MountedGallopReset(EnHorse* this) { - this->noInputTimerMax = 0; - this->noInputTimer = 0; - this->action = ENHORSE_ACT_MOUNTED_GALLOP; - this->animationIdx = ENHORSE_ANIM_GALLOP; - this->unk_234 = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); -} - -void EnHorse_JumpLanding(EnHorse* this, GlobalContext* globalCtx) { - Vec3s* jointTable; - f32 y; - - this->action = ENHORSE_ACT_MOUNTED_GALLOP; - this->animationIdx = ENHORSE_ANIM_GALLOP; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->riderPos.y += y * 0.01f; - this->postDrawFunc = NULL; -} - -void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx); - -void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 stickAngle; - - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - - if (this->noInputTimer <= 0.0f) { - EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 0x190); - } else if (this->noInputTimer > 0.0f) { - this->noInputTimer -= 1; - this->actor.speedXZ = 8.0f; - } - if (this->actor.speedXZ < 6.0f) { - EnHorse_StartTrotting(this); - } - - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorse_PlayGallopingSound(this); - func_800AA000(0, 120, 8, 255); - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { - if (stickMag >= 10.0f && Math_CosS(stickAngle) <= -0.5f) { - EnHorse_StartBraking(this, globalCtx); - } else if (this->actor.speedXZ < 6.0f) { - EnHorse_StartTrotting(this); - } else { - EnHorse_MountedGallopReset(this); - } - return; - } - EnHorse_MountedGallopReset(this); - } -} - -void EnHorse_StartRearing(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_REARING; - this->animationIdx = ENHORSE_ANIM_REARING; - this->stateFlags &= ~ENHORSE_LAND2_SOUND; - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - func_800AA000(0.0f, 180, 20, 100); - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 stickAngle; - - this->actor.speedXZ = 0; - if (this->curFrame > 25.0f) { - if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { - this->stateFlags |= ENHORSE_LAND2_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_800AA000(0, 180, 20, 100); - } - } - - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (SkelAnime_Update(&this->skin.skelAnime)) { - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { - if (this->stateFlags & ENHORSE_FORCE_REVERSING) { - this->noInputTimer = 100; - this->noInputTimerMax = 100; - this->stateFlags &= ~ENHORSE_FORCE_REVERSING; - EnHorse_StartReversing(this); - } else if (this->stateFlags & ENHORSE_FORCE_WALKING) { - this->noInputTimer = 100; - this->noInputTimerMax = 100; - this->stateFlags &= ~ENHORSE_FORCE_WALKING; - EnHorse_StartWalking(this); - } else if (Math_CosS(stickAngle) <= -0.5f) { - EnHorse_StartReversingInterruptable(this); - } else { - EnHorse_StartMountedIdleResetAnim(this); - } - return; - } - EnHorse_StartMountedIdleResetAnim(this); - } -} - -void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx) { - this->action = ENHORSE_ACT_STOPPING; - this->animationIdx = ENHORSE_ANIM_STOPPING; - - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SLIP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); - - this->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; - this->stateFlags &= ~ENHORSE_BOOST; -} - -void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { - if (this->actor.speedXZ > 0.0f) { - this->actor.speedXZ = this->actor.speedXZ - 0.6f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; - } - } - - if (this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND && this->skin.skelAnime.curFrame > 29.0f) { - this->actor.speedXZ = 0.0f; - if (Rand_ZeroOne() > 0.5) { - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - func_800AA000(0.0f, 180, 20, 100); - this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; - } else { - EnHorse_StartMountedIdleResetAnim(this); - } - } - - if (this->skin.skelAnime.curFrame > 29.0f) { - this->actor.speedXZ = 0.0f; - } else if (this->actor.speedXZ > 3.0f && this->stateFlags & ENHORSE_FORCE_REVERSING) { - this->actor.speedXZ = 3.0f; - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - if (this->stateFlags & ENHORSE_FORCE_REVERSING) { - this->noInputTimer = 100; - this->noInputTimerMax = 100; - EnHorse_StartReversing(this); - this->stateFlags &= ~ENHORSE_FORCE_REVERSING; - } else { - EnHorse_StartMountedIdleResetAnim(this); - } - } -} - -void EnHorse_StartReversingInterruptable(EnHorse* this) { - this->noInputTimerMax = 0; - this->noInputTimer = 0; - EnHorse_StartReversing(this); -} - -void EnHorse_StartReversing(EnHorse* this) { - this->action = ENHORSE_ACT_REVERSE; - this->animationIdx = ENHORSE_ANIM_WALK; - this->soundTimer = 0; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, -3.0f); -} - -void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { - f32 stickMag; - s16 stickAngle; - s16 turnAmount; - Player* player = GET_PLAYER(globalCtx); - - EnHorse_PlayWalkingSound(this); - EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { - if (this->noInputTimerMax == 0.0f || - (this->noInputTimer > 0.0f && this->noInputTimer < this->noInputTimerMax - 20.0f)) { - if (stickMag < 10.0f && this->noInputTimer <= 0.0f) { - EnHorse_StartMountedIdleResetAnim(this); - this->actor.speedXZ = 0.0f; - return; - } - if (stickMag < 10.0f) { - stickAngle = -0x7FFF; - } else if (Math_CosS(stickAngle) > -0.5f) { - this->noInputTimerMax = 0; - EnHorse_StartMountedIdleResetAnim(this); - this->actor.speedXZ = 0.0f; - return; - } - } else if (stickMag < 10.0f) { - stickAngle = -0x7FFF; - } - } else if (player->actor.flags & ACTOR_FLAG_8) { - EnHorse_StartMountedIdleResetAnim(this); - this->actor.speedXZ = 0.0f; - return; - } else { - stickAngle = -0x7FFF; - } - - this->actor.speedXZ = -2.0f; - turnAmount = 0x7FFF - stickAngle; - turnAmount = CLAMP(turnAmount, -1200.0f, 1200.0f); - this->actor.world.rot.y += turnAmount; - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->noInputTimer > 0.0f) { - this->noInputTimer--; - if (this->noInputTimer <= 0.0f) { - this->noInputTimerMax = 0; - } - } - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.5f * 1.5f; - if (SkelAnime_Update(&this->skin.skelAnime) && (f32)this->noInputTimer <= 0.0f && - EnHorse_PlayerCanMove(this, globalCtx) == true) { - if (stickMag > 10.0f && Math_CosS(stickAngle) <= -0.5f) { - this->noInputTimerMax = 0; - EnHorse_StartReversingInterruptable(this); - } else if (stickMag < 10.0f) { - this->noInputTimerMax = 0; - EnHorse_StartMountedIdleResetAnim(this); - } else { - EnHorse_StartReversing(this); - } - } -} - -void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx); - -void EnHorse_LowJumpInit(EnHorse* this, GlobalContext* globalCtx) { - this->skin.skelAnime.curFrame = 0.0f; - EnHorse_StartLowJump(this, globalCtx); -} - -void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { - f32 curFrame; - Vec3s* jointTable; - f32 y; - - this->action = ENHORSE_ACT_LOW_JUMP; - this->animationIdx = ENHORSE_ANIM_LOW_JUMP; - curFrame = this->skin.skelAnime.curFrame; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); - - this->postDrawFunc = NULL; - this->jumpStartY = this->actor.world.pos.y; - - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0; - - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->riderPos.y -= y * 0.01f; - - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_800AA000(0.0f, 170, 10, 10); -} - -void EnHorse_Stub1(EnHorse* this) { -} - -void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { - Vec3f pad; - Vec3s* jointTable; - f32 curFrame; - f32 y; - - curFrame = this->skin.skelAnime.curFrame; - this->stateFlags |= ENHORSE_JUMPING; - this->actor.speedXZ = 12.0f; - if (curFrame > 17.0f) { - this->actor.gravity = -3.5f; - if (this->actor.velocity.y == 0) { - this->actor.velocity.y = -6.0f; - } - if (this->actor.world.pos.y < this->actor.floorHeight + 90.0f) { - this->skin.skelAnime.playSpeed = 1.5f; - } else { - this->skin.skelAnime.playSpeed = 0; - } - } else { - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->actor.world.pos.y = this->jumpStartY + y * 0.01f; - } - - if (SkelAnime_Update(&this->skin.skelAnime) || - (curFrame > 17.0f && this->actor.world.pos.y < this->actor.floorHeight - this->actor.velocity.y + 80.0f)) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_800AA000(0.0f, 255, 10, 80); - this->stateFlags &= ~ENHORSE_JUMPING; - this->actor.gravity = -3.5f; - this->actor.world.pos.y = this->actor.floorHeight; - func_80028A54(globalCtx, 25.0f, &this->actor.world.pos); - EnHorse_JumpLanding(this, globalCtx); - } -} - -void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx); - -void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx) { - this->skin.skelAnime.curFrame = 0.0f; - EnHorse_StartHighJump(this, globalCtx); -} - -void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { - f32 curFrame; - Vec3s* jointTable; - f32 y; - - this->action = ENHORSE_ACT_HIGH_JUMP; - this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; - curFrame = this->skin.skelAnime.curFrame; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); - - this->jumpStartY = this->actor.world.pos.y; - this->postDrawFunc = NULL; - - this->actor.gravity = 0; - this->actor.velocity.y = 0.0f; - - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->riderPos.y -= y * 0.01f; - - this->stateFlags |= ENHORSE_CALC_RIDER_POS; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_800AA000(0.0f, 170, 10, 10); -} - -void EnHorse_Stub2(EnHorse* this) { -} - -void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { - Vec3f pad; - Vec3s* jointTable; - f32 curFrame; - f32 y; - - curFrame = this->skin.skelAnime.curFrame; - this->stateFlags |= ENHORSE_JUMPING; - this->actor.speedXZ = 13.0f; - if (curFrame > 23.0f) { - this->actor.gravity = -3.5f; - if (this->actor.velocity.y == 0) { - this->actor.velocity.y = -10.5f; - } - - if (this->actor.world.pos.y < this->actor.floorHeight + 90.0f) { - this->skin.skelAnime.playSpeed = 1.5f; - } else { - this->skin.skelAnime.playSpeed = 0; - } - } else { - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->actor.world.pos.y = this->jumpStartY + y * 0.01f; - } - - if (SkelAnime_Update(&this->skin.skelAnime) || - (curFrame > 23.0f && this->actor.world.pos.y < this->actor.floorHeight - this->actor.velocity.y + 80.0f)) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_800AA000(0.0f, 255, 10, 80); - this->stateFlags &= ~ENHORSE_JUMPING; - this->actor.gravity = -3.5f; - this->actor.world.pos.y = this->actor.floorHeight; - func_80028A54(globalCtx, 25.0f, &this->actor.world.pos); - EnHorse_JumpLanding(this, globalCtx); - } -} - -void EnHorse_InitInactive(EnHorse* this) { - this->cyl1.base.ocFlags1 &= ~OC1_ON; - this->cyl2.base.ocFlags1 &= ~OC1_ON; - this->jntSph.base.ocFlags1 &= ~OC1_ON; - this->action = ENHORSE_ACT_INACTIVE; - this->animationIdx = ENHORSE_ANIM_WALK; - this->stateFlags |= ENHORSE_INACTIVE; - this->followTimer = 0; -} - -void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx); - -void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - - if (DREG(53) != 0 && this->type == HORSE_EPONA) { - DREG(53) = 0; - if (EnHorse_Spawn(this, globalCtx) != 0) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->stateFlags &= ~ENHORSE_INACTIVE; - gSaveContext.horseData.scene = globalCtx->sceneNum; - - // Focus the camera on Epona - Camera_SetParam(globalCtx->cameraPtrs[0], 8, this); - Camera_ChangeSetting(globalCtx->cameraPtrs[0], 0x38); - Camera_SetCameraData(globalCtx->cameraPtrs[0], 4, NULL, NULL, 0x51, 0, 0); - } - } - if (!(this->stateFlags & ENHORSE_INACTIVE)) { - this->followTimer = 0; - EnHorse_SetFollowAnimation(this, globalCtx); - this->actor.params = 0; - this->cyl1.base.ocFlags1 |= OC1_ON; - this->cyl2.base.ocFlags1 |= OC1_ON; - this->jntSph.base.ocFlags1 |= OC1_ON; - } -} - -void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrame) { - this->action = ENHORSE_ACT_IDLE; - this->actor.speedXZ = 0.0f; - if (anim != ENHORSE_ANIM_IDLE && anim != ENHORSE_ANIM_WHINNEY && anim != ENHORSE_ANIM_REARING) { - anim = ENHORSE_ANIM_IDLE; - } - if (anim != this->animationIdx) { - this->animationIdx = anim; - if (this->animationIdx == ENHORSE_ANIM_IDLE) { - this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; - } else if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } else if (this->animationIdx == ENHORSE_ANIM_REARING) { - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - this->stateFlags &= ~ENHORSE_LAND2_SOUND; - } - - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - morphFrames); - } -} - -void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { - EnHorse_PlayIdleAnimation(this, anim, morphFrames, this->curFrame); -} - -void EnHorse_ResetIdleAnimation(EnHorse* this) { - this->animationIdx = ENHORSE_ANIM_WALK; // this forces anim 0 to play from the beginning - EnHorse_PlayIdleAnimation(this, this->animationIdx, 0, 0); -} - -void EnHorse_StartIdleRidable(EnHorse* this) { - EnHorse_ResetIdleAnimation(this); - this->stateFlags &= ~ENHORSE_UNRIDEABLE; -} - -void EnHorse_StartMovingAnimation(EnHorse* this, s32 arg1, f32 arg2, f32 arg3); - -void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - EnHorse_IdleAnimSounds(this, globalCtx); - - if (DREG(53) && this->type == HORSE_EPONA) { - DREG(53) = 0; - if (!func_80A5BBBC(globalCtx, this, &this->actor.world.pos)) { - if (EnHorse_Spawn(this, globalCtx)) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->followTimer = 0; - EnHorse_SetFollowAnimation(this, globalCtx); - Camera_SetParam(globalCtx->cameraPtrs[0], 8, this); - Camera_ChangeSetting(globalCtx->cameraPtrs[0], 0x38); - Camera_SetCameraData(globalCtx->cameraPtrs[0], 4, NULL, NULL, 0x51, 0, 0); - } - } else { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->followTimer = 0; - EnHorse_StartMovingAnimation(this, 6, -3.0f, 0.0f); - } - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - s32 idleAnimIdx = 0; - - if (this->animationIdx != ENHORSE_ANIM_IDLE) { - if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { - idleAnimIdx = 1; - } else if (this->animationIdx == ENHORSE_ANIM_REARING) { - idleAnimIdx = 2; - } - } - - // Play one of the two other idle animations - EnHorse_PlayIdleAnimation(this, sIdleAnimIds[(Rand_ZeroOne() > 0.5f ? 0 : 1) + idleAnimIdx * 2], 0.0f, 0.0f); - } -} - -void EnHorse_StartMovingAnimation(EnHorse* this, s32 animId, f32 morphFrames, f32 startFrame) { - this->action = ENHORSE_ACT_FOLLOW_PLAYER; - this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; - if (animId != ENHORSE_ANIM_TROT && animId != ENHORSE_ANIM_GALLOP && animId != ENHORSE_ANIM_WALK) { - animId = ENHORSE_ANIM_WALK; - } - if (this->animationIdx != animId) { - this->animationIdx = animId; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - morphFrames); - } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - 0.0f); - } -} - -void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { - s32 animId = ENHORSE_ANIM_WALK; - f32 distToPlayer; - - distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - if (distToPlayer > 400.0f) { - animId = ENHORSE_ANIM_GALLOP; - } else if (!(distToPlayer <= 300.0f)) { - if (distToPlayer <= 400.0f) { - animId = ENHORSE_ANIM_TROT; - } - } - - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - if (distToPlayer > 400.0f) { - animId = ENHORSE_ANIM_GALLOP; - } else { - animId = ENHORSE_ANIM_TROT; - } - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - if (distToPlayer > 400.0f) { - animId = ENHORSE_ANIM_GALLOP; - } else if (distToPlayer < 300.0f) { - animId = ENHORSE_ANIM_WALK; - } else { - animId = ENHORSE_ANIM_TROT; - } - } else if (this->animationIdx == ENHORSE_ANIM_WALK) { - if (distToPlayer > 300.0f) { - animId = ENHORSE_ANIM_TROT; - } else { - animId = ENHORSE_ANIM_WALK; - } - } - EnHorse_StartMovingAnimation(this, animId, -3.0f, 0.0f); -} - -void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { - f32 distToPlayer; - f32 angleDiff; - - DREG(53) = 0; - distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - - // First rotate if the player is behind - if ((this->playerDir == PLAYER_DIR_BACK_R || this->playerDir == PLAYER_DIR_BACK_L) && - (distToPlayer > 300.0f && !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER))) { - this->animationIdx = ENHORSE_ANIM_REARING; - this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; - this->angleToPlayer = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - angleDiff = (f32)this->angleToPlayer - (f32)this->actor.world.rot.y; - if (angleDiff > 32767.f) { - angleDiff -= 32767.0f; - } else if (angleDiff < -32767) { - angleDiff += 32767; - } - - this->followPlayerTurnSpeed = - angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]); - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); - this->skin.skelAnime.playSpeed = 1.0f; - this->stateFlags &= ~ENHORSE_LAND2_SOUND; - this->unk_21C = this->unk_228; - } else if (this->stateFlags & ENHORSE_TURNING_TO_PLAYER) { - this->actor.world.rot.y = this->actor.world.rot.y + this->followPlayerTurnSpeed; - this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->curFrame > 25.0f) { - if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { - this->stateFlags |= ENHORSE_LAND2_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - } else { - EnHorse_RotateToPlayer(this, globalCtx); - } - - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - this->actor.speedXZ = 8; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - this->actor.speedXZ = 6; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; - } else if (this->animationIdx == ENHORSE_ANIM_WALK) { - this->actor.speedXZ = 3; - EnHorse_PlayWalkingSound(this); - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; - } else { - this->actor.speedXZ = 0; - this->skin.skelAnime.playSpeed = 1.0f; - } - - if (!(this->stateFlags & ENHORSE_TURNING_TO_PLAYER) && ++this->followTimer > 300) { - EnHorse_StartIdleRidable(this); - this->unk_21C = this->unk_228; - - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - EnHorse_PlayGallopingSound(this); - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - EnHorse_PlayTrottingSound(this); - } - this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; - if (distToPlayer < 100.0f) { - EnHorse_StartIdleRidable(this); - } else { - EnHorse_SetFollowAnimation(this, globalCtx); - } - } -} - -void EnHorse_UpdateIngoHorseAnim(EnHorse* this); - -void EnHorse_InitIngoHorse(EnHorse* this) { - this->curRaceWaypoint = 0; - this->soundTimer = 0; - this->actor.speedXZ = 0.0f; - EnHorse_UpdateIngoHorseAnim(this); - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_IT_INGO_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -void EnHorse_SetIngoAnimation(s32 idx, f32 curFrame, s32 arg2, s16* animIdxOut, f32* curFrameOut) { - *animIdxOut = sIngoAnimations[idx]; - *curFrameOut = curFrame; - if (idx == 3 || idx == 7 || idx == 8 || idx == 4) { - *curFrameOut = 0.0f; - } - if (arg2 == 1) { - if (idx == 5) { - *animIdxOut = 4; - *curFrameOut = curFrame; - } else if (idx == 6) { - *animIdxOut = 3; - *curFrameOut = curFrame; - } - } -} - -void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { - s32 animChanged = 0; - f32 animSpeed; - - this->action = ENHORSE_ACT_INGO_RACE; - this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; - if (this->actor.speedXZ == 0.0f) { - if (this->animationIdx != ENHORSE_ANIM_IDLE) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_IDLE; - } else if (this->actor.speedXZ <= 3.0f) { - if (this->animationIdx != ENHORSE_ANIM_WALK) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_WALK; - } else if (this->actor.speedXZ <= 6.0f) { - if (this->animationIdx != ENHORSE_ANIM_TROT) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_TROT; - } else { - if (this->animationIdx != ENHORSE_ANIM_GALLOP) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_GALLOP; - } - - if (this->animationIdx == ENHORSE_ANIM_WALK) { - animSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - animSpeed = this->actor.speedXZ * 0.25f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - animSpeed = this->actor.speedXZ * 0.2f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - animSpeed = 1.0f; - } - - if (animChanged == true) { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3); - } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0); - } -} - -void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { - f32 playSpeed; - - if (this->animationIdx == ENHORSE_ANIM_IDLE || this->animationIdx == ENHORSE_ANIM_WHINNEY) { - EnHorse_IdleAnimSounds(this, globalCtx); - } else if (this->animationIdx == ENHORSE_ANIM_WALK) { - EnHorse_PlayWalkingSound(this); - } - - EnHorse_UpdateIngoRaceInfo(this, globalCtx, &sIngoRace); - if (!this->inRace) { - this->actor.speedXZ = 0.0f; - this->rider->speedXZ = 0.0f; - if (this->animationIdx != ENHORSE_ANIM_IDLE) { - EnHorse_UpdateIngoHorseAnim(this); - } - } - - if (this->animationIdx == ENHORSE_ANIM_WALK) { - playSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - playSpeed = this->actor.speedXZ * 0.25f; - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - playSpeed = this->actor.speedXZ * 0.2f; - } else { - playSpeed = 1.0f; - } - this->skin.skelAnime.playSpeed = playSpeed; - if (SkelAnime_Update(&this->skin.skelAnime) || - (this->animationIdx == ENHORSE_ANIM_IDLE && this->actor.speedXZ != 0.0f)) { - EnHorse_UpdateIngoHorseAnim(this); - } - - if (this->stateFlags & ENHORSE_INGO_WON) { - ((EnIn*)this->rider)->animationIdx = 7; - ((EnIn*)this->rider)->unk_1E0 = 0; - return; - } - - EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->ingoRaceFlags & 1, - &((EnIn*)this->rider)->animationIdx, &((EnIn*)this->rider)->unk_1E0); -} - -void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->animationIdx = ENHORSE_ANIM_GALLOP; - this->cutsceneAction = 1; - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - this->actor.speedXZ * 0.3f); -} - -void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx); - -void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - Vec3f endPos; - f32 speed = 8.0f; - - endPos.x = action->endPos.x; - endPos.y = action->endPos.y; - endPos.z = action->endPos.z; - if (Math3D_Vec3f_DistXYZ(&endPos, &this->actor.world.pos) > speed) { - EnHorse_RotateToPoint(this, globalCtx, &endPos, 400); - this->actor.speedXZ = speed; - this->skin.skelAnime.playSpeed = speed * 0.3f; - } else { - this->actor.world.pos = endPos; - this->actor.speedXZ = 0.0f; - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorse_PlayGallopingSound(this); - func_800AA000(0.0f, 120, 8, 255); - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - this->actor.speedXZ * 0.3f); - } -} - -void EnHorse_CsSetAnimHighJump(EnHorse* this, GlobalContext* globalCtx) { - this->skin.skelAnime.curFrame = 0.0f; - EnHorse_CsPlayHighJumpAnim(this, globalCtx); -} - -void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { - f32 curFrame; - f32 y; - Vec3s* jointTable; - - this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; - curFrame = this->skin.skelAnime.curFrame; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); - this->postDrawFunc = NULL; - this->jumpStartY = this->actor.world.pos.y; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0; - - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->riderPos.y -= y * 0.01f; - - this->stateFlags |= ENHORSE_CALC_RIDER_POS; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_800AA000(0.0f, 170, 10, 10); -} - -void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - EnHorse_CsSetAnimHighJump(this, globalCtx); - this->cutsceneAction = 2; - this->cutsceneFlags &= ~1; -} - -void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - f32 temp_f2; - - if (this->cutsceneFlags & 1) { - EnHorse_CsMoveToPoint(this, globalCtx, action); - return; - } - temp_f2 = this->skin.skelAnime.curFrame; - this->stateFlags |= ENHORSE_JUMPING; - this->actor.speedXZ = 13.0f; - if (temp_f2 > 19.0f) { - this->actor.gravity = -3.5f; - if (this->actor.velocity.y == 0.0f) { - this->actor.velocity.y = -10.5f; - } - if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { - this->skin.skelAnime.playSpeed = 1.5f; - } else { - this->skin.skelAnime.playSpeed = 0.0f; - } - } else { - Vec3s* jointTable; - f32 y; - - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->actor.world.pos.y = this->jumpStartY + y * 0.01f; - } - if (SkelAnime_Update(&this->skin.skelAnime) || - (temp_f2 > 19.0f && this->actor.world.pos.y < (this->actor.floorHeight - this->actor.velocity.y) + 80.0f)) { - Vec3s* jointTable; - f32 y; - - this->cutsceneFlags |= 1; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_800AA000(0.0f, 255, 10, 80); - this->stateFlags &= ~ENHORSE_JUMPING; - this->actor.gravity = -3.5f; - this->actor.velocity.y = 0; - this->actor.world.pos.y = this->actor.floorHeight; - func_80028A54(globalCtx, 25.0f, &this->actor.world.pos); - this->animationIdx = ENHORSE_ANIM_GALLOP; - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - sPlaybackSpeeds[6]); - jointTable = this->skin.skelAnime.jointTable; - y = jointTable->y; - this->riderPos.y += y * 0.01f; - this->postDrawFunc = NULL; - } -} - -void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->animationIdx = ENHORSE_ANIM_REARING; - this->cutsceneAction = 3; - this->cutsceneFlags &= ~4; - this->stateFlags &= ~ENHORSE_LAND2_SOUND; - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->actor.speedXZ = 0.0f; - if (this->curFrame > 25.0f) { - if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { - this->stateFlags |= ENHORSE_LAND2_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - if (SkelAnime_Update(&this->skin.skelAnime)) { - this->animationIdx = ENHORSE_ANIM_IDLE; - if (!(this->cutsceneFlags & 4)) { - this->cutsceneFlags |= 4; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), 0, 0.0f); - } - } -} - -void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->actor.world.pos.x = action->startPos.x; - this->actor.world.pos.y = action->startPos.y; - this->actor.world.pos.z = action->startPos.z; - this->actor.prevPos = this->actor.world.pos; - this->actor.world.rot.y = action->urot.y; - this->actor.shape.rot = this->actor.world.rot; - this->animationIdx = ENHORSE_ANIM_GALLOP; - this->cutsceneAction = 4; - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - this->actor.speedXZ * 0.3f); -} - -void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - Vec3f endPos; - f32 speed = 8.0f; - - endPos.x = action->endPos.x; - endPos.y = action->endPos.y; - endPos.z = action->endPos.z; - if (Math3D_Vec3f_DistXYZ(&endPos, &this->actor.world.pos) > speed) { - EnHorse_RotateToPoint(this, globalCtx, &endPos, 400); - this->actor.speedXZ = speed; - this->skin.skelAnime.playSpeed = speed * 0.3f; - } else { - this->actor.world.pos = endPos; - this->actor.speedXZ = 0.0f; - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorse_PlayGallopingSound(this); - func_800AA000(0.0f, 120, 8, 255); - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - this->actor.speedXZ * 0.3f); - } -} - -void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->actor.world.pos.x = action->startPos.x; - this->actor.world.pos.y = action->startPos.y; - this->actor.world.pos.z = action->startPos.z; - this->actor.prevPos = this->actor.world.pos; - this->actor.world.rot.y = action->urot.y; - this->actor.shape.rot = this->actor.world.rot; - this->animationIdx = ENHORSE_ANIM_REARING; - this->cutsceneAction = 5; - this->cutsceneFlags &= ~4; - this->stateFlags &= ~ENHORSE_LAND2_SOUND; - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); -} - -void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->actor.speedXZ = 0.0f; - if (this->curFrame > 25.0f) { - if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { - this->stateFlags |= ENHORSE_LAND2_SOUND; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - if (SkelAnime_Update(&this->skin.skelAnime)) { - this->animationIdx = ENHORSE_ANIM_IDLE; - if (!(this->cutsceneFlags & 4)) { - this->cutsceneFlags |= 4; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), 0, 0.0f); - } - } -} - -void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx) { - this->playerControlled = false; - this->action = ENHORSE_ACT_CS_UPDATE; - this->cutsceneAction = 0; - this->actor.speedXZ = 0.0f; -} - -s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { - s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling - s32 i; - - for (i = 0; i < numActions; i++) { - if (csAction == sCsActionTable[i].csAction) { - return sCsActionTable[i].csFuncIdx; - } - if (csAction < sCsActionTable[i].csAction) { - return 0; - } - } - return 0; -} - -void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { - s32 csFunctionIdx; - CsCmdActorAction* linkCsAction = globalCtx->csCtx.linkAction; - - if (globalCtx->csCtx.state == 3) { - this->playerControlled = 1; - this->actor.params = 10; - this->action = ENHORSE_ACT_IDLE; - EnHorse_Freeze(this); - return; - } - - if (linkCsAction != 0) { - csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(linkCsAction->action); - if (csFunctionIdx != 0) { - if (this->cutsceneAction != csFunctionIdx) { - if (this->cutsceneAction == 0) { - this->actor.world.pos.x = linkCsAction->startPos.x; - this->actor.world.pos.y = linkCsAction->startPos.y; - this->actor.world.pos.z = linkCsAction->startPos.z; - this->actor.world.rot.y = linkCsAction->urot.y; - this->actor.shape.rot = this->actor.world.rot; - this->actor.prevPos = this->actor.world.pos; - } - this->cutsceneAction = csFunctionIdx; - sCutsceneInitFuncs[this->cutsceneAction](this, globalCtx, linkCsAction); - } - sCutsceneActionFuncs[this->cutsceneAction](this, globalCtx, linkCsAction); - } - } -} - -s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { - Vec3f pos; - f32 px; - f32 pz; - f32 d; - - EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &pos); - Math3D_RotateXZPlane(&pos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d); - - if (this->curRaceWaypoint >= raceInfo->numWaypoints - 1 && - Math3D_Vec3f_DistXYZ(&pos, &this->actor.world.pos) < DREG(8)) { - this->hbaFlags |= 2; - } - - if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { - this->curRaceWaypoint++; - if (this->curRaceWaypoint >= raceInfo->numWaypoints) { - this->hbaFlags |= 1; - return 1; - } - } - - if (!(this->hbaFlags & 1)) { - EnHorse_RotateToPoint(this, globalCtx, &pos, 800); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->actor.speedXZ < raceInfo->waypoints[this->curRaceWaypoint].speed && !(this->hbaFlags & 1)) { - this->actor.speedXZ += 0.4f; - } else { - this->actor.speedXZ -= 0.4f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; - } - } - return 0; -} - -void EnHorse_UpdateHbaAnim(EnHorse* this); - -void EnHorse_InitHorsebackArchery(EnHorse* this) { - this->hbaStarted = 0; - this->soundTimer = 0; - this->curRaceWaypoint = 0; - this->hbaTimer = 0; - this->actor.speedXZ = 0.0f; - EnHorse_UpdateHbaAnim(this); -} - -void EnHorse_UpdateHbaAnim(EnHorse* this) { - s32 animChanged = 0; - f32 animSpeed; - - this->action = ENHORSE_ACT_HBA; - if (this->actor.speedXZ == 0.0f) { - if (this->animationIdx != ENHORSE_ANIM_IDLE) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_IDLE; - } else if (this->actor.speedXZ <= 3.0f) { - if (this->animationIdx != ENHORSE_ANIM_WALK) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_WALK; - } else if (this->actor.speedXZ <= 6.0f) { - if (this->animationIdx != ENHORSE_ANIM_TROT) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_TROT; - } else { - if (this->animationIdx != ENHORSE_ANIM_GALLOP) { - animChanged = true; - } - this->animationIdx = ENHORSE_ANIM_GALLOP; - } - - if (this->animationIdx == ENHORSE_ANIM_WALK) { - animSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - animSpeed = this->actor.speedXZ * 0.25f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_800AA000(0.0f, 60, 8, 255); - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - animSpeed = this->actor.speedXZ * 0.2f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_800AA000(0.0f, 120, 8, 255); - } else { - animSpeed = 1.0f; - } - - if (animChanged == true) { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0); - } -} - -void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { - f32 playSpeed; - s32 sp20; - - if (this->animationIdx == ENHORSE_ANIM_WALK) { - EnHorse_PlayWalkingSound(this); - } - if (globalCtx->interfaceCtx.hbaAmmo == 0) { - this->hbaTimer++; - } - - sp20 = func_800F5A58(NA_BGM_HORSE_GOAL); - EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); - if (this->hbaFlags & 1 || this->hbaTimer >= 46) { - if (sp20 != 1 && gSaveContext.minigameState != 3) { - gSaveContext.cutsceneIndex = 0; - globalCtx->nextEntranceIndex = 0x3B0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 0x20; - } - } - - if (globalCtx->interfaceCtx.hbaAmmo != 0) { - if (!(this->hbaFlags & 2)) { - if (gSaveContext.infTable[25] & 1) { - if ((s32)gSaveContext.minigameScore >= 1500) { - this->hbaFlags |= 4; - } - } else { - if ((s32)gSaveContext.minigameScore >= 1000) { - this->hbaFlags |= 4; - } - } - } - } - - if ((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) { - if (this->hbaFlags & 4) { - this->hbaFlags &= ~4; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); - } - } - - if (!this->hbaStarted) { - this->actor.speedXZ = 0.0f; - if (this->animationIdx != ENHORSE_ANIM_IDLE) { - EnHorse_UpdateHbaAnim(this); - } - } - - if (this->animationIdx == ENHORSE_ANIM_WALK) { - playSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - playSpeed = this->actor.speedXZ * 0.25f; - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - playSpeed = this->actor.speedXZ * 0.2f; - } else { - playSpeed = 1.0f; - } - - this->skin.skelAnime.playSpeed = playSpeed; - if (SkelAnime_Update(&this->skin.skelAnime) || - (this->animationIdx == ENHORSE_ANIM_IDLE && this->actor.speedXZ != 0.0f)) { - EnHorse_UpdateHbaAnim(this); - } -} - -void EnHorse_InitFleePlayer(EnHorse* this) { - this->action = ENHORSE_ACT_FLEE_PLAYER; - this->stateFlags |= ENHORSE_UNRIDEABLE; - this->actor.speedXZ = 0.0f; -} - -void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 distToHome; - f32 playerDistToHome; - f32 distToPlayer; - s32 nextAnim = this->animationIdx; - s32 animFinished; - s16 yaw; - - if (DREG(53) || this->type == HORSE_HNI) { - EnHorse_StartIdleRidable(this); - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - - distToHome = Math3D_Vec3f_DistXYZ(&this->actor.home.pos, &this->actor.world.pos); - playerDistToHome = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &this->actor.home.pos); - distToPlayer = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &this->actor.world.pos); - - // Run home - if (playerDistToHome > 300.0f) { - if (distToHome > 150.0f) { - this->actor.speedXZ += 0.4f; - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ = 8.0f; - } - } else { - this->actor.speedXZ -= 0.47f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; - } - } - } else { - // Run away from Link - if (distToPlayer < 300.0f) { - this->actor.speedXZ += 0.4f; - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ = 8.0f; - } - } else { - this->actor.speedXZ -= 0.47f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; - } - } - } - - if (this->actor.speedXZ >= 6.0f) { // hoof it - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; - nextAnim = ENHORSE_ANIM_GALLOP; - } else if (this->actor.speedXZ >= 3.0f) { // trot - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; - nextAnim = ENHORSE_ANIM_TROT; - } else if (this->actor.speedXZ > 0.1f) { // walk - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; - nextAnim = ENHORSE_ANIM_WALK; - EnHorse_PlayWalkingSound(this); - } else { // idle - nextAnim = Rand_ZeroOne() > 0.5f ? 1 : 0; - EnHorse_IdleAnimSounds(this, globalCtx); - this->skin.skelAnime.playSpeed = 1.0f; - } - - // Turn away from Link, or towards home - if (nextAnim == ENHORSE_ANIM_GALLOP || nextAnim == ENHORSE_ANIM_TROT || nextAnim == ENHORSE_ANIM_WALK) { - if (playerDistToHome < 300.0f) { - yaw = player->actor.shape.rot.y; - yaw += (Actor_WorldYawTowardActor(&this->actor, &player->actor) > 0 ? 1 : -1) * 0x3FFF; - } else { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; - } - - if (yaw > 400) { - this->actor.world.rot.y += 400; - } else if (yaw < -400) { - this->actor.world.rot.y -= 400; - } else { - this->actor.world.rot.y += yaw; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - animFinished = SkelAnime_Update(&this->skin.skelAnime); - - if (this->animationIdx == ENHORSE_ANIM_IDLE || this->animationIdx == ENHORSE_ANIM_WHINNEY) { - if (nextAnim == ENHORSE_ANIM_GALLOP || nextAnim == ENHORSE_ANIM_TROT || nextAnim == ENHORSE_ANIM_WALK) { - this->animationIdx = nextAnim; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - EnHorse_PlayGallopingSound(this); - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { - EnHorse_PlayTrottingSound(this); - } - return; - } - } - - if (animFinished) { - if (nextAnim == ENHORSE_ANIM_GALLOP) { - EnHorse_PlayGallopingSound(this); - } else if (nextAnim == ENHORSE_ANIM_TROT) { - EnHorse_PlayTrottingSound(this); - } - - if (this->animationIdx == ENHORSE_ANIM_IDLE || this->animationIdx == ENHORSE_ANIM_WHINNEY) { - if (nextAnim != this->animationIdx) { - this->animationIdx = nextAnim; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), - ANIMMODE_ONCE, -3.0f); - return; - } else { - if (Rand_ZeroOne() > 0.5f) { - this->animationIdx = ENHORSE_ANIM_IDLE; - this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; - } else { - this->animationIdx = ENHORSE_ANIM_WHINNEY; - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_21C, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), - ANIMMODE_ONCE, -3.0f); - return; - } - } - - if (nextAnim != this->animationIdx) { - this->animationIdx = nextAnim; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - 0.0f); - } - return; - } - - if (this->animationIdx == ENHORSE_ANIM_WALK) { - if (nextAnim == ENHORSE_ANIM_IDLE || nextAnim == ENHORSE_ANIM_WHINNEY) { - this->animationIdx = nextAnim; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); - } - } -} - -void EnHorse_BridgeJumpInit(EnHorse* this, GlobalContext* globalCtx) { - f32 y; - - func_80028A54(globalCtx, 25.0f, &this->actor.world.pos); - this->action = ENHORSE_ACT_BRIDGE_JUMP; - this->stateFlags |= ENHORSE_JUMPING; - this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; - y = this->skin.skelAnime.jointTable->y; - y = y * 0.01f; - this->bridgeJumpStart = this->actor.world.pos; - this->bridgeJumpStart.y += y; - this->bridgeJumpYVel = - (((sBridgeJumps[this->bridgeJumpIdx].pos.y + 48.7f) - this->bridgeJumpStart.y) - -360.0f) / 30.0f; - this->riderPos.y -= y; - this->stateFlags |= ENHORSE_CALC_RIDER_POS; - this->bridgeJumpRelAngle = this->actor.world.rot.y - sBridgeJumps[this->bridgeJumpIdx].angle; - this->bridgeJumpTimer = 0; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 0; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_800AA000(0.0f, 170, 10, 10); - this->postDrawFunc = NULL; -} - -void EnHorse_StartBridgeJump(EnHorse* this, GlobalContext* globalCtx) { - this->postDrawFunc = EnHorse_BridgeJumpInit; - if (this->bridgeJumpIdx == 0) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGerudoValleyBridgeJumpFieldFortressCs); - gSaveContext.cutsceneTrigger = 1; - } else { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGerudoValleyBridgeJumpFortressToFieldCs); - gSaveContext.cutsceneTrigger = 1; - } -} - -void EnHorse_BridgeJumpMove(EnHorse* this, GlobalContext* globalCtx) { - f32 interp; - f32 timeSq; - - interp = this->bridgeJumpTimer / 30.0f; - timeSq = (this->bridgeJumpTimer * this->bridgeJumpTimer); - - this->actor.world.pos.x = - ((sBridgeJumps[this->bridgeJumpIdx].pos.x - this->bridgeJumpStart.x) * interp) + this->bridgeJumpStart.x; - this->actor.world.pos.z = - ((sBridgeJumps[this->bridgeJumpIdx].pos.z - this->bridgeJumpStart.z) * interp) + this->bridgeJumpStart.z; - - this->actor.world.pos.y = - (this->bridgeJumpStart.y + (this->bridgeJumpYVel * this->bridgeJumpTimer) + (-0.4f * timeSq)); - - this->actor.world.rot.y = this->actor.shape.rot.y = - (sBridgeJumps[this->bridgeJumpIdx].angle + ((1.0f - interp) * this->bridgeJumpRelAngle)); - this->skin.skelAnime.curFrame = 23.0f * interp; - SkelAnime_Update(&this->skin.skelAnime); - if (this->bridgeJumpTimer < 30) { - this->stateFlags |= ENHORSE_FLAG_24; - } -} - -void EnHorse_CheckBridgeJumpLanding(EnHorse* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 8.0f; - this->skin.skelAnime.playSpeed = 1.5f; - if (SkelAnime_Update(&this->skin.skelAnime)) { - this->stateFlags &= ~ENHORSE_JUMPING; - this->actor.gravity = -3.5f; - this->actor.world.pos.y = sBridgeJumps[this->bridgeJumpIdx].pos.y; - func_80028A54(globalCtx, 25.0f, &this->actor.world.pos); - EnHorse_JumpLanding(this, globalCtx); - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_800AA000(0.0f, 255, 10, 80); - } -} - -void EnHorse_BridgeJump(EnHorse* this, GlobalContext* globalCtx) { - this->bridgeJumpTimer++; - if (this->bridgeJumpTimer < 30) { - EnHorse_BridgeJumpMove(this, globalCtx); - return; - } - EnHorse_CheckBridgeJumpLanding(this, globalCtx); -} - -void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) { - dst->x = src->x + Math_SinS(yaw) * dist; - dst->y = src->y + height; - dst->z = src->z + Math_CosS(yaw) * dist; -} - -s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** floorPoly, - f32* floorHeight) { - s32 bgId; - f32 waterY; - WaterBox* waterBox; - - *floorPoly = NULL; - *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, floorPoly, &bgId, pos); - - if (*floorHeight == BGCHECK_Y_MIN) { - return 1; // No floor - } - - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pos->x, pos->z, &waterY, &waterBox) == 1 && - *floorHeight < waterY) { - return 2; // Water - } - - if ((*floorPoly)->normal.y * COLPOLY_NORMAL_FRAC < 0.81915206f || // cos(35 degrees) - SurfaceType_IsHorseBlocked(&globalCtx->colCtx, *floorPoly, bgId) || - func_80041D4C(&globalCtx->colCtx, *floorPoly, bgId) == 7) { - return 3; // Horse blocked surface - } - return 0; -} - -/** - * obstacleType: - * 1: Water in front - * 2: Water behind? - * 3: ? - * 4: Obstructed in front - * 5: Obstructed behind - */ -void EnHorse_ObstructMovement(EnHorse* this, GlobalContext* globalCtx, s32 obstacleType, s32 galloping) { - if (this->action == ENHORSE_ACT_CS_UPDATE || EnHorse_BgCheckBridgeJumpPoint(this, globalCtx)) { - return; - } - - this->actor.world.pos = this->lastPos; - this->actor.shape.rot.y = this->lastYaw; - this->actor.world.rot.y = this->lastYaw; - this->stateFlags |= ENHORSE_OBSTACLE; - - if (!this->playerControlled) { - if (this->animationIdx != ENHORSE_ANIM_REARING) { - return; - } - } else if (this->action != ENHORSE_ACT_MOUNTED_REARING) { - if (this->stateFlags & ENHORSE_JUMPING) { - this->stateFlags &= ~ENHORSE_JUMPING; - this->actor.gravity = -3.5f; - this->actor.world.pos.y = this->actor.floorHeight; - } - if (obstacleType == 1 || obstacleType == 4) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - } else if (obstacleType == 2 || obstacleType == 5) { - this->stateFlags |= ENHORSE_FORCE_WALKING; - } - if (galloping == true) { - EnHorse_StartRearing(this); - } - } -} - -void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { - s32 status; - CollisionPoly* frontFloor; - CollisionPoly* backFloor; - s16 floorSlope; - Vec3f frontPos; - Vec3f backPos; - Vec3f pos; - f32 nx; - f32 ny; - f32 nz; - s32 galloping = this->actor.speedXZ > 8; - f32 dist; - f32 waterHeight; - WaterBox* waterBox; - s32 pad; - - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterHeight, &waterBox) == 1 && - this->actor.floorHeight < waterHeight) { - EnHorse_ObstructMovement(this, globalCtx, 1, galloping); - return; - } - - EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 30.0f, 60.0f, &frontPos); - status = EnHorse_CalcFloorHeight(this, globalCtx, &frontPos, &frontFloor, &this->yFront); - if (status == 1) { - this->actor.shape.rot.x = 0; - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); - return; - } - if (status == 2) { - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); - return; - } - if (status == 3) { - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); - return; - } - - EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -30.0f, 60.0f, &backPos); - status = EnHorse_CalcFloorHeight(this, globalCtx, &backPos, &backFloor, &this->yBack); - if (status == 1) { - this->actor.shape.rot.x = 0; - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); - return; - } - if (status == 2) { - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); - return; - } - if (status == 3) { - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); - return; - } - - floorSlope = Math_FAtan2F(this->yBack - this->yFront, 60.0f) * (0x8000 / M_PI); - if (this->actor.floorPoly != 0) { - nx = this->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC; - ny = this->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC; - nz = this->actor.floorPoly->normal.z * COLPOLY_NORMAL_FRAC; - pos = frontPos; - pos.y = this->yFront; - dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); - if ((frontFloor != this->actor.floorPoly) && (this->actor.speedXZ >= 0.0f)) { - if ((!(this->stateFlags & ENHORSE_JUMPING) && dist < -40.0f) || - (this->stateFlags & ENHORSE_JUMPING && dist < -200.0f)) { - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); - return; - } - } - - pos = backPos; - pos.y = this->yBack; - dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); - if (((backFloor != this->actor.floorPoly) && (this->actor.speedXZ <= 0.0f) && - !(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || - (this->stateFlags & ENHORSE_JUMPING && dist < -200.0f)) { - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); - return; - } - - if (ny < 0.81915206f || // cos(35 degrees) - SurfaceType_IsHorseBlocked(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) || - func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7) { - if ((this->actor.speedXZ >= 0.0f)) { - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); - } else { - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); - } - return; - } - - if (this->stateFlags & ENHORSE_JUMPING) { - this->actor.shape.rot.x = 0; - return; - } - - if (this->actor.floorHeight + 4.0f < this->actor.world.pos.y) { - this->actor.shape.rot.x = 0; - return; - } - - if (fabsf(floorSlope) > 8191.0f) { - return; - } - - this->actor.shape.rot.x = floorSlope; - this->actor.shape.yOffset = - (this->yFront + (((this->yBack - this->yFront) * 20.0f) / 45.0f)) - this->actor.floorHeight; - } -} - -s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx); - -void EnHorse_MountDismount(EnHorse* this, GlobalContext* globalCtx) { - s32 pad[2]; - s32 mountSide; - Player* player = GET_PLAYER(globalCtx); - - mountSide = EnHorse_GetMountSide(this, globalCtx); - if (mountSide != 0 && !(this->stateFlags & ENHORSE_UNRIDEABLE) && player->rideActor == NULL) { - Actor_SetRideActor(globalCtx, &this->actor, mountSide); - } - - if (this->playerControlled == false && Actor_IsMounted(globalCtx, &this->actor) == true) { - this->noInputTimer = 55; - this->noInputTimerMax = 55; - this->playerControlled = 1; - EnHorse_Freeze(this); - } else if (this->playerControlled == true && Actor_NotMounted(globalCtx, &this->actor) == true) { - this->noInputTimer = 35; - this->noInputTimerMax = 35; - this->stateFlags &= ~ENHORSE_UNRIDEABLE; - this->playerControlled = 0; - EnHorse_Freeze(this); - } -} - -void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { - f32 dist; - f32 y; - f32 x; - - x = curStick->x; - y = curStick->y; - dist = sqrtf(SQ(x) + SQ(y)); - - *stickMag = dist; - if (dist > 60.0f) { - *stickMag = 60.0f; - } else { - *stickMag = *stickMag; - } - - *angle = Math_FAtan2F(-curStick->x, curStick->y) * (32768.0f / M_PI); -} - -void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { - this->lastStick = this->curStick; - this->curStick.x = globalCtx->state.input[0].rel.stick_x; - this->curStick.y = globalCtx->state.input[0].rel.stick_y; -} - -void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, CollisionPoly* colPoly) { - f32 dist; - f32 nx; - f32 ny; - f32 nz; - f32 offset; - - nx = COLPOLY_GET_NORMAL(colPoly->normal.x); - ny = COLPOLY_GET_NORMAL(colPoly->normal.y); - nz = COLPOLY_GET_NORMAL(colPoly->normal.z); - if (!(Math_CosS(this->actor.world.rot.y - - (s16)(Math_FAtan2F(colPoly->normal.x, colPoly->normal.z) * (0x8000 / M_PI)) - 0x7FFF) < - 0.7071f)) { // cos(45 degrees) - dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &this->actor.world.pos); - offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); - offset = (30.0f - dist) * offset; - this->actor.world.pos.x += offset * nx; - this->actor.world.pos.z += offset * nz; - } -} - -void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { - f32 yOffset; - Vec3f start; - Vec3f end; - Vec3f intersect; - CollisionPoly* colPoly; - s32 bgId; - - if (globalCtx->sceneNum == SCENE_SPOT20) { - yOffset = 19.0f; - } else { - yOffset = 40.0f; - } - Math_Vec3f_Copy(&start, &this->actor.world.pos); - start.y = start.y + yOffset; - - Math_Vec3f_Copy(&end, &start); - end.x += 30.0f * Math_SinS(this->actor.world.rot.y); - end.y += 30.0f * Math_SinS(-this->actor.shape.rot.x); - end.z += 30.0f * Math_CosS(this->actor.world.rot.y); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &start, &end, &intersect, &colPoly, 1, 0, 0, 1, &bgId) != 0) { - EnHorse_ResolveCollision(this, globalCtx, colPoly); - } -} - -void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx); -void EnHorse_Stub2(EnHorse* this); -void EnHorse_Stub1(EnHorse* this); - -void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; - Vec3f startPos; - Vec3f endPos; - Vec3f obstaclePos; - f32 pad3; - f32 intersectDist; - CollisionPoly* wall = NULL; - CollisionPoly* obstacleFloor = NULL; - s32 bgId; - f32 obstacleHeight; - f32 behindObstacleHeight; - f32 ny; - s32 movingFast; - s32 pad5; - DynaPolyActor* dynaPoly; - Vec3f intersect; - Vec3f obstacleTop; - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, globalCtx->sceneNum == SCENE_SPOT20 ? 19.0f : 40.0f, 35.0f, 100.0f, - 29); - - if (EnHorse_BgCheckBridgeJumpPoint(this, globalCtx)) { - return; - } - - // void 0 trick required to match, but is surely not real. revisit at a later time - if (this->actor.bgCheckFlags & 8 && Math_CosS(this->actor.wallYaw - ((void)0, this->actor.world).rot.y) < -0.3f) { - if (this->actor.speedXZ > 4.0f) { - this->actor.speedXZ -= 1.0f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - - if (this->stateFlags & ENHORSE_JUMPING || !this->playerControlled) { - return; - } - - if (this->actor.speedXZ < 0.0f) { - return; - } - - // Braking or rearing from obstacle - if (this->action == ENHORSE_ACT_STOPPING || this->action == ENHORSE_ACT_MOUNTED_REARING) { - return; - } - - if (this->actor.speedXZ > 8.0f) { - if (this->actor.speedXZ < 12.8f) { - intersectDist = 160.0f; - movingFast = 0; - } else { - intersectDist = 230.0f; - movingFast = 1; - } - } else { - EnHorse_BgCheckSlowMoving(this, globalCtx); - return; - } - - startPos = this->actor.world.pos; - startPos.y += 19.0f; - endPos = startPos; - endPos.x += (intersectDist * Math_SinS(this->actor.world.rot.y)); - endPos.y += (intersectDist * Math_SinS(-this->actor.shape.rot.x)); - endPos.z += (intersectDist * Math_CosS(this->actor.world.rot.y)); - intersect = endPos; - wall = NULL; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, 1, 0, 0, 1, &bgId) == 1) { - intersectDist = sqrt(Math3D_Vec3fDistSq(&startPos, &intersect)); - this->stateFlags |= ENHORSE_OBSTACLE; - } - - if (wall != NULL) { - if (intersectDist < 30.0f) { - EnHorse_ResolveCollision(this, globalCtx, wall); - } - if ((Math_CosS(this->actor.world.rot.y - (s16)(Math_FAtan2F(wall->normal.x, wall->normal.z) * (0x8000 / M_PI)) - - 0x7FFF) < 0.5f) || - SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId) != 0) { - return; - } - - // too close to jump - if ((movingFast == false && intersectDist < 80.0f) || (movingFast == true && intersectDist < 150.0f)) { - if (movingFast == false) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - } else if (movingFast == true) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); - } - return; - } - - dynaPoly = DynaPoly_GetActor(&globalCtx->colCtx, bgId); - if ((this->stateFlags & ENHORSE_FLAG_26) && ((dynaPoly && dynaPoly->actor.id != 0x108) || dynaPoly == 0)) { - if (movingFast == false) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - } else if (movingFast == true) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); - } - return; - } - } - - // Get obstacle's height - intersectDist += 5.0f; - obstaclePos = startPos; - obstaclePos.x += intersectDist * Math_SinS(this->actor.world.rot.y); - obstaclePos.y = this->actor.world.pos.y + 120.0f; - obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); - obstacleTop = obstaclePos; - obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); - if (obstacleTop.y == BGCHECK_Y_MIN) { - return; - } - obstacleHeight = obstacleTop.y - this->actor.world.pos.y; - if (this->actor.floorPoly == NULL || obstacleFloor == NULL) { - return; - } - - if (Math3D_DistPlaneToPos(this->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC, - this->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC, - this->actor.floorPoly->normal.z * COLPOLY_NORMAL_FRAC, this->actor.floorPoly->dist, - &obstacleTop) < -40.0f && - Math3D_DistPlaneToPos( - obstacleFloor->normal.x * COLPOLY_NORMAL_FRAC, obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC, - obstacleFloor->normal.z * COLPOLY_NORMAL_FRAC, obstacleFloor->dist, &this->actor.world.pos) > 40.0f) { - if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); - } - this->stateFlags |= ENHORSE_OBSTACLE; - return; - } - - ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; - if (ny < 0.81915206f || // cos(35 degrees) - (SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) != 0) || - (func_80041D4C(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { - if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); - } - return; - } - - if (wall == NULL || obstacleTop.y < intersect.y || (this->stateFlags & ENHORSE_CANT_JUMP)) { - return; - } - - obstaclePos = startPos; - obstaclePos.y = this->actor.world.pos.y + 120.0f; - if (movingFast == false) { - obstaclePos.x += (276.0f * Math_SinS(this->actor.world.rot.y)); - obstaclePos.z += (276.0f * Math_CosS(this->actor.world.rot.y)); - } else { - obstaclePos.x += (390.0f * Math_SinS(this->actor.world.rot.y)); - obstaclePos.z += (390.0f * Math_CosS(this->actor.world.rot.y)); - } - - obstacleTop = obstaclePos; - obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); - if (obstacleTop.y == BGCHECK_Y_MIN) { - return; - } - - behindObstacleHeight = obstacleTop.y - this->actor.world.pos.y; - - if (obstacleFloor == NULL) { - return; - } - - ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; - if (ny < 0.81915206f || // cos(35 degrees) - SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || - func_80041D4C(&globalCtx->colCtx, obstacleFloor, bgId) == 7) { - if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); - } - } else if (behindObstacleHeight < -DREG(4)) { // -70 - if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { - this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); - } - } else if (movingFast == false && obstacleHeight > 19.0f && obstacleHeight <= 40.0f) { - EnHorse_Stub1(this); - this->postDrawFunc = EnHorse_LowJumpInit; - } else if ((movingFast == true && this->actor.speedXZ < 13.8f && obstacleHeight > 19.0f && - obstacleHeight <= 72.0f) || - (this->actor.speedXZ > 13.8f && obstacleHeight <= 112.0f)) { - - EnHorse_Stub2(this); - this->postDrawFunc = EnHorse_HighJumpInit; - } -} - -void EnHorse_CheckBoost(EnHorse* thisx, GlobalContext* globalCtx2) { - EnHorse* this = (EnHorse*)thisx; - GlobalContext* globalCtx = globalCtx2; - s32 pad; - - if (this->action == ENHORSE_ACT_MOUNTED_WALK || this->action == ENHORSE_ACT_MOUNTED_TROT || - this->action == ENHORSE_ACT_MOUNTED_GALLOP) { - if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) && (globalCtx->interfaceCtx.unk_1EE == 8)) { - if (!(this->stateFlags & ENHORSE_BOOST) && !(this->stateFlags & ENHORSE_FLAG_8) && - !(this->stateFlags & ENHORSE_FLAG_9)) { - if (this->numBoosts > 0) { - func_800AA000(0.0f, 180, 20, 100); - this->stateFlags |= ENHORSE_BOOST; - this->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; - this->stateFlags |= ENHORSE_FLAG_8; - this->numBoosts--; - this->boostTimer = 0; - if (this->numBoosts == 0) { - this->boostRegenTime = 140; - return; - } - if (this->type == HORSE_EPONA) { - if (this->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { - this->boostRegenTime = 60; - this->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; - } else { - this->boostRegenTime = 8; // Never happens - } - } else { - this->boostRegenTime = 70; - } - return; - } - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - if (Rand_ZeroOne() < 0.1f) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - } - } - } -} - -void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { - if (this->numBoosts < 6 && this->numBoosts > 0) { - this->boostRegenTime--; - this->boostTimer++; - - if (this->boostRegenTime <= 0) { - this->numBoosts = this->numBoosts + 1; - - if (!EN_HORSE_CHECK_4(this)) { - Audio_PlaySoundGeneral(NA_SE_SY_CARROT_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - - if (this->numBoosts < 6) { - this->boostRegenTime = 11; - } - } - } else if (this->numBoosts == 0) { - this->boostRegenTime--; - this->boostTimer++; - - if (this->boostRegenTime <= 0) { - this->boostRegenTime = 0; - this->numBoosts = 6; - - if (!EN_HORSE_CHECK_4(this)) { - Audio_PlaySoundGeneral(NA_SE_SY_CARROT_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - } - - if (this->boostTimer == 8 && Rand_ZeroOne() < 0.25f) { - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - globalCtx->interfaceCtx.numHorseBoosts = this->numBoosts; -} - -void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { - EnHorse* pad; - s16 angle; - f32 s; - f32 c; - - angle = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; - s = Math_SinS(angle); - c = Math_CosS(angle); - if (s > 0.8660254f) { // sin(60 degrees) - this->playerDir = PLAYER_DIR_SIDE_L; - } else if (s < -0.8660254f) { // -sin(60 degrees) - this->playerDir = PLAYER_DIR_SIDE_R; - } else { - if (c > 0.0f) { - if (s > 0) { - this->playerDir = PLAYER_DIR_FRONT_L; - } else { - this->playerDir = PLAYER_DIR_FRONT_R; - } - } else { - if (s > 0) { - this->playerDir = PLAYER_DIR_BACK_L; - } else { - this->playerDir = PLAYER_DIR_BACK_R; - } - } - } -} - -void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { - f32 speed; - f32 rollDiff; - s32 targetRoll; - s16 turnVel; - - speed = this->actor.speedXZ / this->boostSpeed; - turnVel = this->actor.shape.rot.y - this->lastYaw; - targetRoll = -((s16)((1820.0f * speed) * (turnVel / 480.00003f))); - rollDiff = targetRoll - this->actor.world.rot.z; - - if (fabsf(targetRoll) < 100.0f) { - this->actor.world.rot.z = 0; - } else if (fabsf(rollDiff) < 100.0f) { - this->actor.world.rot.z = targetRoll; - } else if (rollDiff > 0.0f) { - this->actor.world.rot.z += 100; - } else { - this->actor.world.rot.z -= 100; - } - - this->actor.shape.rot.z = this->actor.world.rot.z; -} - -s32 EnHorse_UpdateConveyors(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 conveyorDir; - - if ((this->actor.floorPoly == NULL) && (this != (EnHorse*)player->rideActor)) { - return 0; - } - conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - conveyorDir = (conveyorDir << 10) - this->actor.world.rot.y; - if (conveyorDir > 800.0f) { - this->actor.world.rot.y += 800.0f; - } else if (conveyorDir < -800.0f) { - this->actor.world.rot.y -= 800.0f; - } else { - this->actor.world.rot.y += conveyorDir; - } - this->actor.shape.rot.y = this->actor.world.rot.y; - - return 1; -} - -s32 EnHorse_RandInt(f32 range) { - return Rand_ZeroOne() * range; -} - -void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnHorse* this = (EnHorse*)thisx; - GlobalContext* globalCtx = globalCtx2; - Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; - Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; - Player* player = GET_PLAYER(globalCtx); - - this->lastYaw = thisx->shape.rot.y; - EnHorse_UpdateStick(this, globalCtx); - EnHorse_UpdatePlayerDir(this, globalCtx); - - if (!(this->stateFlags & ENHORSE_INACTIVE)) { - EnHorse_MountDismount(this, globalCtx); - } - - if (this->stateFlags & ENHORSE_FLAG_19) { - if (this->stateFlags & ENHORSE_FLAG_20 && this->inRace == true) { - this->stateFlags &= ~ENHORSE_FLAG_20; - EnHorse_StartRearing(this); - } else if (!(this->stateFlags & ENHORSE_FLAG_20) && this->stateFlags & ENHORSE_FLAG_21 && - this->action != ENHORSE_ACT_MOUNTED_REARING && this->inRace == true) { - this->stateFlags &= ~ENHORSE_FLAG_21; - EnHorse_StartRearing(this); - } - } - - sActionFuncs[this->action](this, globalCtx); - this->stateFlags &= ~ENHORSE_OBSTACLE; - this->curFrame = this->skin.skelAnime.curFrame; - this->lastPos = thisx->world.pos; - if (!(this->stateFlags & ENHORSE_INACTIVE)) { - if (this->action == ENHORSE_ACT_MOUNTED_GALLOP || this->action == ENHORSE_ACT_MOUNTED_TROT || - this->action == ENHORSE_ACT_MOUNTED_WALK) { - EnHorse_CheckBoost(this, globalCtx); - } - if (this->playerControlled == true) { - EnHorse_RegenBoost(this, globalCtx); - } - Actor_MoveForward(thisx); - if (this->action == ENHORSE_ACT_INGO_RACE) { - if (this->rider != NULL) { - this->rider->world.pos.x = thisx->world.pos.x; - this->rider->world.pos.y = thisx->world.pos.y + 10.0f; - this->rider->world.pos.z = thisx->world.pos.z; - this->rider->shape.rot.x = thisx->shape.rot.x; - this->rider->shape.rot.y = thisx->shape.rot.y; - } - } - if (this->jntSph.elements[0].info.ocElemFlags & 2) { - if (thisx->speedXZ > 6.0f) { - thisx->speedXZ -= 1.0f; - } - } - if (this->jntSph.base.acFlags & 2) { - this->unk_21C = this->unk_228; - if (this->stateFlags & ENHORSE_DRAW) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - if (this->action != ENHORSE_ACT_INGO_RACE) { - EnHorse_TiltBody(this, globalCtx); - } - Collider_UpdateCylinder(thisx, &this->cyl1); - Collider_UpdateCylinder(thisx, &this->cyl2); - - // Required to match - this->cyl1.dim.pos.x = this->cyl1.dim.pos.x + (s16)(Math_SinS(thisx->shape.rot.y) * 11.0f); - this->cyl1.dim.pos.z = this->cyl1.dim.pos.z + (s16)(Math_CosS(thisx->shape.rot.y) * 11.0f); - this->cyl2.dim.pos.x = this->cyl2.dim.pos.x + (s16)(Math_SinS(thisx->shape.rot.y) * -18.0f); - this->cyl2.dim.pos.z = this->cyl2.dim.pos.z + (s16)(Math_CosS(thisx->shape.rot.y) * -18.0f); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->cyl1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cyl1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cyl2.base); - if ((player->stateFlags1 & 1) && player->rideActor != NULL) { - if (globalCtx->sceneNum != SCENE_SPOT20 || - (globalCtx->sceneNum == SCENE_SPOT20 && (thisx->world.pos.z < -2400.0f))) { - EnHorse_UpdateConveyors(this, globalCtx); - } - } - if (!(this->stateFlags & ENHORSE_FLAG_24)) { - EnHorse_UpdateBgCheckInfo(this, globalCtx); - EnHorse_CheckFloors(this, globalCtx); - if (thisx->world.pos.y < this->yFront && thisx->world.pos.y < this->yBack) { - if (this->yBack < this->yFront) { - thisx->world.pos.y = this->yBack; - } else { - thisx->world.pos.y = this->yFront; - } - } - - } else { - this->stateFlags &= ~ENHORSE_FLAG_24; - } - - if (globalCtx->sceneNum == SCENE_SPOT09 && (gSaveContext.eventChkInf[9] & 0xF) != 0xF) { - EnHorse_CheckBridgeJumps(this, globalCtx); - } - - thisx->focus.pos = thisx->world.pos; - thisx->focus.pos.y += 70.0f; - if ((Rand_ZeroOne() < 0.025f) && this->blinkTimer == 0) { - this->blinkTimer++; - } else if (this->blinkTimer > 0) { - this->blinkTimer++; - if (this->blinkTimer >= 4) { - this->blinkTimer = 0; - } - } - - if (thisx->speedXZ == 0.0f && !(this->stateFlags & ENHORSE_FLAG_19)) { - thisx->colChkInfo.mass = 0xFF; - } else { - thisx->colChkInfo.mass = 0xFE; - } - - if (thisx->speedXZ >= 5.0f) { - this->cyl1.base.atFlags |= 1; - } else { - this->cyl1.base.atFlags &= ~1; - } - - if (gSaveContext.entranceIndex != 343 || gSaveContext.sceneSetupIndex != 9) { - if (this->dustFlags & 1) { - this->dustFlags &= ~1; - func_800287AC(globalCtx, &this->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, - EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); - } else if (this->dustFlags & 2) { - this->dustFlags &= ~2; - func_800287AC(globalCtx, &this->frontLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, - EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); - } else if (this->dustFlags & 4) { - this->dustFlags &= ~4; - func_800287AC(globalCtx, &this->backRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, - EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); - } else if (this->dustFlags & 8) { - this->dustFlags &= ~8; - func_800287AC(globalCtx, &this->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, - EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); - } - } - this->stateFlags &= ~ENHORSE_DRAW; - } -} - -s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { - if (this->playerDir == PLAYER_DIR_SIDE_L) { - return -1; - } - if (this->playerDir == PLAYER_DIR_SIDE_R) { - return 1; - } - return 0; -} - -s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* player) { - s32 mountSide; - - if (Actor_WorldDistXZToActor(&this->actor, &player->actor) > 75.0f) { - return 0; - } else if (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) > 30.0f) { - return 0; - } else if (Math_CosS(Actor_WorldYawTowardActor(&player->actor, &this->actor) - player->actor.world.rot.y) < - 0.17364818f) { // cos(80 degrees) - return 0; - } else { - mountSide = EnHorse_PlayerDirToMountSide(this, globalCtx, player); - if (mountSide == -1) { - return -1; - } - if (mountSide == 1) { - return 1; - } - } - return 0; -} - -s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx) { - if (this->action != ENHORSE_ACT_IDLE) { - return 0; - } - if ((this->animationIdx != ENHORSE_ANIM_IDLE) && (this->animationIdx != ENHORSE_ANIM_WHINNEY)) { - return 0; - } - return EnHorse_MountSideCheck(this, globalCtx, GET_PLAYER(globalCtx)); -} - -void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { - dst->x = (Rand_ZeroOne() * (dist * 2.0f) + src->x) - dist; - dst->y = (Rand_ZeroOne() * (dist * 2.0f) + src->y) - dist; - dst->z = (Rand_ZeroOne() * (dist * 2.0f) + src->z) - dist; -} - -void EnHorse_SkinCallback1(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { - EnHorse* this = (EnHorse*)thisx; - s32 pad; - Vec3f sp94 = { 0.0f, 0.0f, 0.0f }; - Vec3f hoofOffset = { 5.0f, -4.0f, 5.0f }; - Vec3f riderOffset = { 600.0f, -1670.0f, 0.0f }; - Vec3f sp70; - Vec3f sp64 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp58 = { 0.0f, -1.0f, 0.0f }; - - f32 frame = this->skin.skelAnime.curFrame; - Vec3f center; - Vec3f newCenter; - s32 i; - Vec3f sp2C; - f32 sp28; - - if (!(this->stateFlags & ENHORSE_CALC_RIDER_POS)) { - func_800A6408(skin, 30, &riderOffset, &this->riderPos); - this->riderPos.x = this->riderPos.x - this->actor.world.pos.x; - this->riderPos.y = this->riderPos.y - this->actor.world.pos.y; - this->riderPos.z = this->riderPos.z - this->actor.world.pos.z; - } else { - this->stateFlags &= ~ENHORSE_CALC_RIDER_POS; - } - - func_800A6408(skin, 13, &sp94, &sp2C); - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp2C, &this->unk_228, &sp28); - if ((this->animationIdx == ENHORSE_ANIM_IDLE && this->action != ENHORSE_ACT_FROZEN) && - ((frame > 40.0f && frame < 45.0f && this->type == HORSE_EPONA) || - (frame > 28.0f && frame < 33.0f && this->type == HORSE_HNI))) { - if (Rand_ZeroOne() < 0.6f) { - this->dustFlags |= 1; - func_800A6408(skin, 28, &hoofOffset, &this->frontRightHoof); - this->frontRightHoof.y = this->frontRightHoof.y - 5.0f; - } - } else { - if (this->action == ENHORSE_ACT_STOPPING) { - if ((frame > 10.0f && frame < 13.0f) || (frame > 25.0f && frame < 33.0f)) { - if (Rand_ZeroOne() < 0.7f) { - this->dustFlags |= 2; - func_800A6408(skin, 20, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->frontLeftHoof); - } - if (Rand_ZeroOne() < 0.7f) { - this->dustFlags |= 1; - func_800A6408(skin, 28, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->frontRightHoof); - } - } - - if ((frame > 6.0f && frame < 10.0f) || (frame > 23.0f && frame < 29.0f)) { - if (Rand_ZeroOne() < 0.7f) { - this->dustFlags |= 8; - func_800A6408(skin, 37, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backLeftHoof); - } - } - - if ((frame > 7.0f && frame < 14.0f) || (frame > 26.0f && frame < 30.0f)) { - if (Rand_ZeroOne() < 0.7f) { - this->dustFlags |= 4; - func_800A6408(skin, 45, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backRightHoof); - } - } - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { - if ((frame > 14.0f) && (frame < 16.0f)) { - this->dustFlags |= 1; - func_800A6408(skin, 28, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 5.0f, &this->frontRightHoof); - } else if (frame > 8.0f && frame < 10.0f) { - this->dustFlags |= 2; - func_800A6408(skin, 20, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->frontLeftHoof); - } else if (frame > 1.0f && frame < 3.0f) { - this->dustFlags |= 4; - func_800A6408(skin, 45, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backRightHoof); - } else if ((frame > 26.0f) && (frame < 28.0f)) { - this->dustFlags |= 8; - func_800A6408(skin, 37, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backLeftHoof); - } - } else if (this->action == ENHORSE_ACT_LOW_JUMP && frame > 6.0f && - Rand_ZeroOne() < 1.0f - (frame - 6.0f) * (1.0f / 17.0f)) { - if (Rand_ZeroOne() < 0.5f) { - this->dustFlags |= 8; - func_800A6408(skin, 37, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backLeftHoof); - } - if (Rand_ZeroOne() < 0.5f) { - this->dustFlags |= 4; - func_800A6408(skin, 45, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backRightHoof); - } - } else if (this->action == ENHORSE_ACT_HIGH_JUMP && frame > 5.0f && - Rand_ZeroOne() < 1.0f - (frame - 5.0f) * (1.0f / 25.0f)) { - if (Rand_ZeroOne() < 0.5f) { - this->dustFlags |= 8; - func_800A6408(skin, 37, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backLeftHoof); - } - if (Rand_ZeroOne() < 0.5f) { - this->dustFlags |= 4; - func_800A6408(skin, 45, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backRightHoof); - } - } else if (this->action == ENHORSE_ACT_BRIDGE_JUMP && Rand_ZeroOne() < 0.5f) { - if (Rand_ZeroOne() < 0.5f) { - this->dustFlags |= 8; - func_800A6408(skin, 37, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backLeftHoof); - } else { - this->dustFlags |= 4; - func_800A6408(skin, 45, &hoofOffset, &sp70); - EnHorse_RandomOffset(&sp70, 10.0f, &this->backRightHoof); - } - } - } - - for (i = 0; i < this->jntSph.count; i++) { - center.x = this->jntSph.elements[i].dim.modelSphere.center.x; - center.y = this->jntSph.elements[i].dim.modelSphere.center.y; - center.z = this->jntSph.elements[i].dim.modelSphere.center.z; - - func_800A6408(skin, this->jntSph.elements[i].dim.limb, ¢er, &newCenter); - this->jntSph.elements[i].dim.worldSphere.center.x = newCenter.x; - this->jntSph.elements[i].dim.worldSphere.center.y = newCenter.y; - this->jntSph.elements[i].dim.worldSphere.center.z = newCenter.z; - this->jntSph.elements[i].dim.worldSphere.radius = - this->jntSph.elements[i].dim.modelSphere.radius * this->jntSph.elements[i].dim.scale; - } - - //! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists - //! under certain conditions, like when pausing and unpausing the game. - //! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur. - //! In the case of OC, this can cause unwanted effects such as a very large amount of displacement being applied to - //! a colliding actor. - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->jntSph.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->jntSph.base); -} - -// unused -static s32 D_80A667DC[] = { 0, 3, 7, 14 }; - -s32 EnHorse_SkinCallback2(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, PSkinAwb* arg3) { - static void* eyeTextures[] = { - gEponaEyeOpenTex, - gEponaEyeHalfTex, - gEponaEyeClosedTex, - }; - static u8 eyeBlinkIndexes[] = { 0, 1, 2, 1 }; - EnHorse* this = (EnHorse*)thisx; - s32 drawOriginalLimb = true; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse.c", 8582); - if (limbIndex == 13 && this->type == HORSE_EPONA) { - u8 index = eyeBlinkIndexes[this->blinkTimer]; - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[index])); - } else if (this->type == HORSE_HNI && this->stateFlags & ENHORSE_FLAG_18 && limbIndex == 30) { - func_800A5F60(globalCtx->state.gfxCtx, &this->skin, limbIndex, gHorseIngoGerudoSaddleDL, 0); - drawOriginalLimb = false; - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_horse.c", 8601); - return drawOriginalLimb; -} - -void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHorse* this = (EnHorse*)thisx; - - if (!(this->stateFlags & ENHORSE_INACTIVE)) { - func_80093D18(globalCtx->state.gfxCtx); - this->stateFlags |= ENHORSE_DRAW; - if (this->stateFlags & ENHORSE_JUMPING) { - func_800A6360(thisx, globalCtx, &this->skin, EnHorse_SkinCallback1, EnHorse_SkinCallback2, 0); - } else { - func_800A6360(thisx, globalCtx, &this->skin, EnHorse_SkinCallback1, EnHorse_SkinCallback2, 1); - } - if (this->postDrawFunc != NULL) { - this->postDrawFunc(this, globalCtx); - } - } -} diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.cpp b/src/overlays/actors/ovl_En_Horse/z_en_horse.cpp new file mode 100644 index 000000000..6ebbf7090 --- /dev/null +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.cpp @@ -0,0 +1,3869 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_Z_EN_HORSE_C +#include "actor_common.h" +/** + * File: z_en_horse.c + * Overlay: ovl_En_Horse + * Description: Rideable horses + */ + +#include "z_en_horse.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "objects/object_horse/object_horse.h" +#include "objects/object_hni/object_hni.h" +#include "scenes/overworld/spot09/spot09_scene.h" + +#include "hack.h" +#include "def/assert.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_horse.h" +#include "def/z_lib.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" +#include "def/z_skin.h" +#include "def/z_skin_awb.h" +#include "def/z_skin_matrix.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef void (*EnHorseCsFunc)(EnHorse*, GlobalContext*, CsCmdActorAction*); +typedef void (*EnHorseActionFunc)(EnHorse*, GlobalContext*); + +void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnHorse_InitCutscene(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_InitHorsebackArchery(EnHorse* pthis); +void EnHorse_InitFleePlayer(EnHorse* pthis); +void EnHorse_ResetIdleAnimation(EnHorse* pthis); +void EnHorse_StartIdleRidable(EnHorse* pthis); +void EnHorse_InitInactive(EnHorse* pthis); +void EnHorse_InitIngoHorse(EnHorse* pthis); + +void EnHorse_Frozen(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_Inactive(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_Idle(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_FollowPlayer(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_UpdateIngoRace(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedIdle(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedIdleWhinneying(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedTurn(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedWalk(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedTrot(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedGallop(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_MountedRearing(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_Stopping(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_Reverse(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_LowJump(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_HighJump(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_BridgeJump(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_CutsceneUpdate(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_UpdateHorsebackArchery(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_FleePlayer(EnHorse* pthis, GlobalContext* globalCtx); + +static AnimationHeader* sEponaAnimHeaders[] = { + &gEponaIdleAnim, &gEponaWhinnyAnim, &gEponaRefuseAnim, &gEponaRearingAnim, &gEponaWalkingAnim, + &gEponaTrottingAnim, &gEponaGallopingAnim, &gEponaJumpingAnim, &gEponaJumpingHighAnim, +}; + +static AnimationHeader* sHniAnimHeaders[] = { + &gHorseIngoIdleAnim, &gHorseIngoWhinnyAnim, &gHorseIngoRefuseAnim, + &gHorseIngoRearingAnim, &gHorseIngoWalkingAnim, &gHorseIngoTrottingAnim, + &gHorseIngoGallopingAnim, &gHorseIngoJumpingAnim, &gHorseIngoJumpingHighAnim, +}; + +static AnimationHeader** sAnimationHeaders[] = { sEponaAnimHeaders, sHniAnimHeaders }; + +static f32 sPlaybackSpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f, 2.0f / 3.0f }; + +static SkeletonHeader* sSkeletonHeaders[] = { &gEponaSkel, &gHorseIngoSkel }; + +ActorInit En_Horse_InitVars = { + ACTOR_EN_HORSE, + ACTORCAT_BG, + FLAGS, + OBJECT_HORSE, + sizeof(EnHorse), + (ActorFunc)EnHorse_Init, + (ActorFunc)EnHorse_Destroy, + (ActorFunc)EnHorse_Update, + (ActorFunc)EnHorse_Draw, +}; + +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_NONE, + AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000400, 0x00, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphItemsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_ON, + }, + { 13, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphItemsInit, +}; + +static CollisionCheckInfoInit D_80A65F38 = { 10, 35, 100, MASS_HEAVY }; + +typedef struct { + s16 scene; + Vec3s pos; + s16 angle; +} EnHorseSpawnpoint; + +static EnHorseSpawnpoint sHorseSpawns[] = { + // Hyrule Field + { SCENE_SPOT00, 16, 0, 1341, 0 }, + { SCENE_SPOT00, -1297, 0, 1459, 0 }, + { SCENE_SPOT00, -5416, -300, 1296, 0 }, + { SCENE_SPOT00, -4667, -300, 3620, 0 }, + { SCENE_SPOT00, -3837, 81, 5537, 0 }, + { SCENE_SPOT00, -5093, -226, 6661, 0 }, + { SCENE_SPOT00, -6588, -79, 5053, 0 }, + { SCENE_SPOT00, -7072, -500, 7538, 0 }, + { SCENE_SPOT00, -6139, -500, 8910, 0 }, + { SCENE_SPOT00, -8497, -300, 7802, 0 }, + { SCENE_SPOT00, -5481, -499, 12127, 0 }, + { SCENE_SPOT00, -4808, -700, 13583, 0 }, + { SCENE_SPOT00, -3416, -490, 12092, 0 }, + { SCENE_SPOT00, -2915, 100, 8339, 0 }, + { SCENE_SPOT00, -2277, -500, 13247, 0 }, + { SCENE_SPOT00, -1026, -500, 12101, 0 }, + { SCENE_SPOT00, 1427, -500, 13341, 0 }, + { SCENE_SPOT00, -200, -486, 10205, 0 }, + { SCENE_SPOT00, -1469, 100, 7496, 0 }, + { SCENE_SPOT00, -995, 168, 5652, 0 }, + { SCENE_SPOT00, 1938, 89, 6232, 0 }, + { SCENE_SPOT00, 1387, -105, 9206, 0 }, + { SCENE_SPOT00, 1571, -223, 7701, 0 }, + { SCENE_SPOT00, 3893, -121, 7068, 0 }, + { SCENE_SPOT00, 3179, 373, 5221, 0 }, + { SCENE_SPOT00, 4678, -20, 3869, 0 }, + { SCENE_SPOT00, 3460, 246, 4207, 0 }, + { SCENE_SPOT00, 3686, 128, 2366, 0 }, + { SCENE_SPOT00, 1791, 18, 152, 0 }, + { SCENE_SPOT00, 3667, -16, 1399, 0 }, + { SCENE_SPOT00, 1827, -15, 983, 0 }, + { SCENE_SPOT00, 1574, 399, 4318, 0 }, + { SCENE_SPOT00, 716, 95, 3391, 0 }, + { SCENE_SPOT00, -1189, -41, 4739, 0 }, + { SCENE_SPOT00, -1976, -171, 4172, 0 }, + { SCENE_SPOT00, 1314, 391, 5665, 0 }, + { SCENE_SPOT00, 112, 0, 1959, 0 }, + { SCENE_SPOT00, -3011, -111, 9397, 0 }, + { SCENE_SPOT00, -5674, -270, 8585, 0 }, + { SCENE_SPOT00, -8861, -300, 7836, 0 }, + { SCENE_SPOT00, -6056, -500, 7810, 0 }, + { SCENE_SPOT00, -7306, -500, 5994, 0 }, + { SCENE_SPOT00, -7305, -500, 7605, 0 }, + { SCENE_SPOT00, -7439, -300, 7600, 0 }, + { SCENE_SPOT00, -7464, -300, 6268, 0 }, + { SCENE_SPOT00, -8080, -300, 7553, 0 }, + { SCENE_SPOT00, -8091, -300, 7349, 0 }, + { SCENE_SPOT00, -8785, -300, 7383, 0 }, + { SCENE_SPOT00, -8745, -300, 7508, 0 }, + { SCENE_SPOT00, -8777, -300, 7788, 0 }, + { SCENE_SPOT00, -8048, -299, 7738, 0 }, + { SCENE_SPOT00, -7341, -184, 7730, 0 }, + { SCENE_SPOT00, -6410, -288, 7824, 0 }, + { SCENE_SPOT00, -6326, -290, 8205, 0 }, + { SCENE_SPOT00, -6546, -292, 8400, 0 }, + { SCENE_SPOT00, -7533, -180, 8459, 0 }, + { SCENE_SPOT00, -8024, -295, 7903, 0 }, + { SCENE_SPOT00, -8078, -308, 7994, 0 }, + { SCENE_SPOT00, -9425, -287, 7696, 0 }, + { SCENE_SPOT00, -9322, -292, 7577, 0 }, + { SCENE_SPOT00, -9602, -199, 7160, 0 }, + { SCENE_SPOT00, -9307, -300, 7758, 0 }, + { SCENE_SPOT00, -9230, -300, 7642, 0 }, + { SCENE_SPOT00, -7556, -499, 8695, 0 }, + { SCENE_SPOT00, -6438, -500, 8606, 0 }, + { SCENE_SPOT00, -6078, -500, 8258, 0 }, + { SCENE_SPOT00, -6233, -500, 7613, 0 }, + { SCENE_SPOT00, -5035, -205, 7814, 0 }, + { SCENE_SPOT00, -5971, -500, 8501, 0 }, + { SCENE_SPOT00, -5724, -498, 10123, 0 }, + { SCENE_SPOT00, -5094, -392, 11106, 0 }, + { SCENE_SPOT00, -5105, -393, 11312, 0 }, + { SCENE_SPOT00, -4477, -314, 11132, 0 }, + { SCENE_SPOT00, -3867, -380, 11419, 0 }, + { SCENE_SPOT00, -2952, -500, 11944, 0 }, + { SCENE_SPOT00, -2871, -488, 11743, 0 }, + { SCENE_SPOT00, -3829, -372, 11327, 0 }, + { SCENE_SPOT00, -4439, -293, 10989, 0 }, + { SCENE_SPOT00, -5014, -381, 11086, 0 }, + { SCENE_SPOT00, -5113, -188, 10968, 0 }, + { SCENE_SPOT00, -5269, -188, 11156, 0 }, + { SCENE_SPOT00, -5596, -178, 9972, 0 }, + { SCENE_SPOT00, -5801, -288, 8518, 0 }, + { SCENE_SPOT00, -4910, -178, 7931, 0 }, + { SCENE_SPOT00, -3586, 73, 8140, 0 }, + { SCENE_SPOT00, -4487, -106, 9362, 0 }, + { SCENE_SPOT00, -4339, -112, 6412, 0 }, + { SCENE_SPOT00, -3417, 105, 8194, 0 }, + { SCENE_SPOT00, -4505, -20, 6608, 0 }, + { SCENE_SPOT00, -5038, -199, 6603, 0 }, + { SCENE_SPOT00, -4481, 1, 6448, 0 }, + { SCENE_SPOT00, -5032, -168, 6418, 0 }, + { SCENE_SPOT00, -5256, -700, 14329, 0 }, + { SCENE_SPOT00, -5749, -820, 15380, 0 }, + { SCENE_SPOT00, -3122, -700, 13608, 0 }, + { SCENE_SPOT00, -3758, -525, 13228, 0 }, + { SCENE_SPOT00, -3670, -500, 13123, 0 }, + { SCENE_SPOT00, -2924, -500, 13526, 0 }, + { SCENE_SPOT00, 1389, -115, 9370, 0 }, + { SCENE_SPOT00, 548, -116, 8889, 0 }, + { SCENE_SPOT00, -106, -107, 8530, 0 }, + { SCENE_SPOT00, -1608, 85, 7646, 0 }, + { SCENE_SPOT00, -5300, -700, 13772, 0 }, + { SCENE_SPOT00, -5114, -700, 13400, 0 }, + { SCENE_SPOT00, -4561, -700, 13700, 0 }, + { SCENE_SPOT00, -4762, -700, 14084, 0 }, + { SCENE_SPOT00, -2954, 100, 8216, 0 }, + { SCENE_SPOT00, 1460, -104, 9246, 0 }, + { SCENE_SPOT00, 629, -105, 8791, 0 }, + { SCENE_SPOT00, -10, -90, 8419, 0 }, + { SCENE_SPOT00, -1462, 100, 7504, 0 }, + { SCENE_SPOT00, -3018, -500, 12493, 0 }, + { SCENE_SPOT00, -2994, -311, 10331, 0 }, + { SCENE_SPOT00, -4006, -700, 14152, 0 }, + { SCENE_SPOT00, -4341, -500, 12743, 0 }, + { SCENE_SPOT00, -5879, -497, 6799, 0 }, + { SCENE_SPOT00, 22, -473, 10103, 0 }, + { SCENE_SPOT00, -1389, -192, 8874, 0 }, + { SCENE_SPOT00, -4, 92, 6866, 0 }, + { SCENE_SPOT00, 483, 104, 6637, 0 }, + { SCENE_SPOT00, 1580, 183, 5987, 0 }, + { SCENE_SPOT00, 1548, 308, 5077, 0 }, + { SCENE_SPOT00, 1511, 399, 4267, 0 }, + { SCENE_SPOT00, 1358, 385, 4271, 0 }, + { SCENE_SPOT00, 1379, 395, 5063, 0 }, + { SCENE_SPOT00, 1360, 394, 5870, 0 }, + { SCENE_SPOT00, 813, 283, 6194, 0 }, + { SCENE_SPOT00, -57, 101, 6743, 0 }, + { SCENE_SPOT00, 91, 325, 5143, 0 }, + { SCENE_SPOT00, 1425, -214, 7659, 0 }, + { SCENE_SPOT00, 3487, -19, 880, 0 }, + { SCENE_SPOT00, 2933, 152, 2094, 0 }, + { SCENE_SPOT00, 2888, -145, 6862, 0 }, + { SCENE_SPOT00, 1511, 67, 6471, 0 }, + { SCENE_SPOT00, 4051, -47, 1722, 0 }, + { SCENE_SPOT00, -7335, -500, 8627, 0 }, + { SCENE_SPOT00, -7728, -462, 8498, 0 }, + { SCENE_SPOT00, -7791, -446, 8832, 0 }, + { SCENE_SPOT00, -2915, -435, 11334, 0 }, + { SCENE_SPOT00, 165, -278, 3352, 0 }, + + // Lake Hylia + { SCENE_SPOT06, -2109, -882, 1724, 0 }, + { SCENE_SPOT06, -328, -1238, 2705, 0 }, + { SCENE_SPOT06, -3092, -1033, 3527, 0 }, + + // Gerudo Valley + { SCENE_SPOT09, 2687, -269, 753, 0 }, + { SCENE_SPOT09, 2066, -132, 317, 0 }, + { SCENE_SPOT09, 523, -8, 635, 0 }, + { SCENE_SPOT09, 558, 36, -323, 0 }, + { SCENE_SPOT09, 615, 51, -839, 0 }, + { SCENE_SPOT09, -614, 32, 29, 0 }, + { SCENE_SPOT09, -639, -3, 553, 0 }, + { SCENE_SPOT09, -540, 10, -889, 0 }, + { SCENE_SPOT09, -1666, 58, 378, 0 }, + { SCENE_SPOT09, -3044, 210, -648, 0 }, + + // Gerudo's Fortress + { SCENE_SPOT12, -678, 21, -623, 0 }, + { SCENE_SPOT12, 149, 333, -2499, 0 }, + { SCENE_SPOT12, 499, 581, -547, 0 }, + { SCENE_SPOT12, 3187, 1413, -3775, 0 }, + { SCENE_SPOT12, 3198, 1413, 307, 0 }, + { SCENE_SPOT12, 3380, 1413, -1200, 0 }, + { SCENE_SPOT12, -966, 1, -56, 0 }, + { SCENE_SPOT12, -966, 24, -761, 0 }, + { SCENE_SPOT12, -694, 174, -2820, 0 }, + + // Lon Lon Ranch + { SCENE_SPOT20, 1039, 0, 2051, 0 }, + { SCENE_SPOT20, -1443, 0, 1429, 0 }, + { SCENE_SPOT20, 856, 0, -918, 0 }, // Hardcoded to always load in lon lon + { SCENE_SPOT20, 882, 0, -2256, 0 }, + { SCENE_SPOT20, -1003, 0, -755, 0 }, // Hardcoded to always load in lon lon + { SCENE_SPOT20, -2254, 0, -629, 0 }, + { SCENE_SPOT20, 907, 0, -2336, 0 }, +}; + +typedef struct { + s16 zMin; + s16 zMax; + + s16 xMin; + s16 xMax; + s16 xOffset; + + s16 angle; + s16 angleRange; + + Vec3s pos; +} BridgeJumpPoint; + +static BridgeJumpPoint sBridgeJumps[] = { + { -195, -40, 225, 120, 360, -0x4000, 0x7D0, -270, -52, -117 }, + { -195, -40, -240, -120, -360, 0x4000, 0x7D0, 270, -52, -117 }, +}; + +typedef struct { + s16 x; + s16 y; + s16 z; + s16 speed; + s16 angle; +} RaceWaypoint; + +typedef struct { + s32 numWaypoints; + RaceWaypoint* waypoints; +} RaceInfo; + +static RaceWaypoint sIngoRaceWaypoints[] = { + { 1056, 1, -1540, 11, 0x2A8D }, { 1593, 1, -985, 10, 0xFC27 }, { 1645, 1, -221, 11, 0xE891 }, + { 985, 1, 403, 10, 0xBB9C }, { -1023, 1, 354, 11, 0xA37D }, { -1679, 1, -213, 10, 0x889C }, + { -1552, 1, -1008, 11, 0x638D }, { -947, -1, -1604, 10, 0x4002 }, +}; + +static RaceInfo sIngoRace = { 8, sIngoRaceWaypoints }; +static s32 sAnimSoundFrames[] = { 0, 16 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 600, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), +}; + +static u8 sResetNoInput[] = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 }; + +static s32 sIdleAnimIds[] = { 1, 3, 0, 3, 1, 0 }; + +static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; + +void EnHorse_CsMoveInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsJumpInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearingInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_WarpMoveInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearingInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); + +static EnHorseCsFunc sCutsceneInitFuncs[] = { + NULL, + EnHorse_CsMoveInit, + EnHorse_CsJumpInit, + EnHorse_CsRearingInit, + EnHorse_WarpMoveInit, + EnHorse_CsWarpRearingInit, +}; + +void EnHorse_CsMoveToPoint(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsJump(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearing(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpMoveToPoint(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearing(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action); + +static EnHorseCsFunc sCutsceneActionFuncs[] = { + NULL, EnHorse_CsMoveToPoint, EnHorse_CsJump, EnHorse_CsRearing, EnHorse_CsWarpMoveToPoint, EnHorse_CsWarpRearing, +}; + +typedef struct { + s32 csAction; + s32 csFuncIdx; +} CsActionEntry; + +static CsActionEntry sCsActionTable[] = { + { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, +}; + +static RaceWaypoint sHbaWaypoints[] = { + { 3600, 1413, -5055, 11, 0x8001 }, { 3360, 1413, -5220, 5, 0xC000 }, { 3100, 1413, -4900, 5, 0x0000 }, + { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, +}; + +static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; + +static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_BridgeJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, +}; + +s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* pthis, GlobalContext* globalCtx) { + f32 xMin; + f32 xMax; + s32 i; + + if (globalCtx->sceneNum != SCENE_SPOT09) { + return false; + } + if (pthis->actor.speedXZ < 12.8f) { + return false; + } + if ((gSaveContext.eventChkInf[9] & 0xF) == 0xF) { + return false; + } + + for (i = 0; i < 2; i++) { + xMin = sBridgeJumps[i].xMin; + xMax = (xMin + sBridgeJumps[i].xMax) + sBridgeJumps[i].xOffset; + if (xMax < xMin) { + f32 temp = xMin; + + xMin = xMax; + xMax = temp; + } + if (sBridgeJumps[i].zMin < pthis->actor.world.pos.z && pthis->actor.world.pos.z < sBridgeJumps[i].zMax) { + if (xMin < pthis->actor.world.pos.x && pthis->actor.world.pos.x < xMax) { + if (sBridgeJumps[i].angle - sBridgeJumps[i].angleRange < pthis->actor.world.rot.y && + pthis->actor.world.rot.y < sBridgeJumps[i].angle + sBridgeJumps[i].angleRange) { + return true; + } + } + } + } + return false; +} + +void EnHorse_StartBridgeJump(EnHorse* pthis, GlobalContext* globalCtx); + +s32 EnHorse_CheckBridgeJumps(EnHorse* pthis, GlobalContext* globalCtx) { + f32 xMin; + f32 xMax; + s32 i; + + if (pthis->actor.speedXZ < 12.8f) { + return false; + } + + for (i = 0; i != 2; i++) { + xMin = sBridgeJumps[i].xMin; + xMax = sBridgeJumps[i].xMax + xMin; + + if (xMax < xMin) { + f32 temp = xMin; + + xMin = xMax; + xMax = temp; + } + + if (sBridgeJumps[i].zMin < pthis->actor.world.pos.z && pthis->actor.world.pos.z < sBridgeJumps[i].zMax) { + if (xMin < pthis->actor.world.pos.x && pthis->actor.world.pos.x < xMax) { + if (sBridgeJumps[i].angle - sBridgeJumps[i].angleRange < pthis->actor.world.rot.y && + pthis->actor.world.rot.y < sBridgeJumps[i].angle + sBridgeJumps[i].angleRange) { + pthis->bridgeJumpIdx = i; + EnHorse_StartBridgeJump(pthis, globalCtx); + return true; + } + } + } + } + + return false; +} + +void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { + pos->x = waypoints[idx].x; + pos->y = waypoints[idx].y; + pos->z = waypoints[idx].z; +} + +void EnHorse_RotateToPoint(EnHorse* pthis, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { + func_8006DD9C(&pthis->actor, pos, turnAmount); +} + +void EnHorse_UpdateIngoRaceInfo(EnHorse* pthis, GlobalContext* globalCtx, RaceInfo* raceInfo) { + Vec3f curWaypointPos; + Vec3f prevWaypointPos; + f32 playerDist; + f32 sp50; + s16 relPlayerYaw; + f32 px; + f32 pz; + f32 d; + f32 dist; + s32 prevWaypoint; + + EnHorse_RaceWaypointPos(raceInfo->waypoints, pthis->curRaceWaypoint, &curWaypointPos); + Math3D_RotateXZPlane(&curWaypointPos, raceInfo->waypoints[pthis->curRaceWaypoint].angle, &px, &pz, &d); + if (((pthis->actor.world.pos.x * px) + (pz * pthis->actor.world.pos.z) + d) > 0.0f) { + pthis->curRaceWaypoint++; + if (pthis->curRaceWaypoint >= raceInfo->numWaypoints) { + pthis->curRaceWaypoint = 0; + } + } + + EnHorse_RaceWaypointPos(raceInfo->waypoints, pthis->curRaceWaypoint, &curWaypointPos); + + prevWaypoint = pthis->curRaceWaypoint - 1; + if (prevWaypoint < 0) { + prevWaypoint = raceInfo->numWaypoints - 1; + } + EnHorse_RaceWaypointPos(raceInfo->waypoints, prevWaypoint, &prevWaypointPos); + Math3D_PointDistToLine2D(pthis->actor.world.pos.x, pthis->actor.world.pos.z, prevWaypointPos.x, prevWaypointPos.z, + curWaypointPos.x, curWaypointPos.z, &dist); + EnHorse_RotateToPoint(pthis, globalCtx, &curWaypointPos, 400); + + if (dist < 90000.0f) { + playerDist = pthis->actor.xzDistToPlayer; + if (playerDist < 130.0f || pthis->jntSph.elements[0].info.ocElemFlags & 2) { + if (Math_SinS(pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y) > 0.0f) { + pthis->actor.world.rot.y = pthis->actor.world.rot.y - 280; + } else { + pthis->actor.world.rot.y = pthis->actor.world.rot.y + 280; + } + } else if (playerDist < 300.0f) { + if (Math_SinS(pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y) > 0.0f) { + pthis->actor.world.rot.y = pthis->actor.world.rot.y + 280; + } else { + pthis->actor.world.rot.y = pthis->actor.world.rot.y - 280; + } + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + sp50 = Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + relPlayerYaw = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.world.rot.y; + if (sp50 <= 200.0f || (fabsf(Math_SinS(relPlayerYaw)) < 0.8f && Math_CosS(relPlayerYaw) > 0.0f)) { + if (pthis->actor.speedXZ < pthis->ingoHorseMaxSpeed) { + pthis->actor.speedXZ += 0.47f; + } else { + pthis->actor.speedXZ -= 0.47f; + } + pthis->ingoRaceFlags |= 1; + return; + } + + if (pthis->actor.speedXZ < raceInfo->waypoints[pthis->curRaceWaypoint].speed) { + pthis->actor.speedXZ = pthis->actor.speedXZ + 0.4f; + } else { + pthis->actor.speedXZ = pthis->actor.speedXZ - 0.4f; + } + pthis->ingoRaceFlags &= ~0x1; +} + +void EnHorse_PlayWalkingSound(EnHorse* pthis) { + if (sAnimSoundFrames[pthis->soundTimer] < pthis->curFrame) { + if (pthis->soundTimer == 0 && (sAnimSoundFrames[1] < pthis->curFrame)) { + return; + } + + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_WALK, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + if (++pthis->soundTimer > 1) { + pthis->soundTimer = 0; + } + } +} + +void EnHorse_PlayTrottingSound(EnHorse* pthis) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); +} + +void EnHorse_PlayGallopingSound(EnHorse* pthis) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); +} + +f32 EnHorse_SlopeSpeedMultiplier(EnHorse* pthis, GlobalContext* globalCtx) { + f32 multiplier = 1.0f; + + if (Math_CosS(pthis->actor.shape.rot.x) < 0.939262f && Math_SinS(pthis->actor.shape.rot.x) < 0.0f) { + multiplier = 0.7f; + } + return multiplier; +} + +void func_80A5BB90(GlobalContext* globalCtx, Vec3f* vec, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, vec, arg2, arg3); +} + +s32 func_80A5BBBC(GlobalContext* globalCtx, EnHorse* pthis, Vec3f* pos) { + Vec3f sp24; + f32 sp20; + f32 eyeDist; + + func_80A5BB90(globalCtx, pos, &sp24, &sp20); + if (fabsf(sp20) < 0.008f) { + return false; + } + eyeDist = Math3D_Vec3f_DistXYZ(pos, &globalCtx->view.eye); + return Actor_IsInUncullZone(globalCtx, &pthis->actor, &sp24, sp20) || eyeDist < 100.0f; +} + +void EnHorse_IdleAnimSounds(EnHorse* pthis, GlobalContext* globalCtx) { + if (pthis->animationIdx == ENHORSE_ANIM_IDLE && + ((pthis->curFrame > 35.0f && pthis->type == HORSE_EPONA) || + (pthis->curFrame > 28.0f && pthis->type == HORSE_HNI)) && + !(pthis->stateFlags & ENHORSE_SANDDUST_SOUND)) { + pthis->stateFlags |= ENHORSE_SANDDUST_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (pthis->animationIdx == ENHORSE_ANIM_REARING && pthis->curFrame > 25.0f && + !(pthis->stateFlags & ENHORSE_LAND2_SOUND)) { + pthis->stateFlags |= ENHORSE_LAND2_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +s32 EnHorse_Spawn(EnHorse* pthis, GlobalContext* globalCtx) { + f32 minDist = 1e38f; + s32 spawn = false; + f32 dist; + s32 i; + Player* player; + Vec3f spawnPos; + + for (i = 0; i < 169; i++) { + if (sHorseSpawns[i].scene == globalCtx->sceneNum) { + player = GET_PLAYER(globalCtx); + if (globalCtx->sceneNum != SCENE_SPOT20 || + //! Same flag checked twice + (Flags_GetEventChkInf(0x18) && ((gSaveContext.eventInf[0] & 0xF) != 6 || Flags_GetEventChkInf(0x18))) || + // always load two spawns inside lon lon + ((sHorseSpawns[i].pos.x == 856 && sHorseSpawns[i].pos.y == 0 && sHorseSpawns[i].pos.z == -918) || + (sHorseSpawns[i].pos.x == -1003 && sHorseSpawns[i].pos.y == 0 && sHorseSpawns[i].pos.z == -755))) { + + spawnPos.x = sHorseSpawns[i].pos.x; + spawnPos.y = sHorseSpawns[i].pos.y; + spawnPos.z = sHorseSpawns[i].pos.z; + dist = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &spawnPos); + + if (globalCtx->sceneNum) {} + if (!(minDist < dist) && !func_80A5BBBC(globalCtx, pthis, &spawnPos)) { + minDist = dist; + pthis->actor.world.pos.x = sHorseSpawns[i].pos.x; + pthis->actor.world.pos.y = sHorseSpawns[i].pos.y; + pthis->actor.world.pos.z = sHorseSpawns[i].pos.z; + pthis->actor.prevPos = pthis->actor.world.pos; + pthis->actor.world.rot.y = sHorseSpawns[i].angle; + pthis->actor.shape.rot.y = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->actor.world.pos, + &pthis->actor.projectedPos, &pthis->actor.projectedW); + } + } + } + } + + return spawn; +} + +void EnHorse_ResetCutscene(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->cutsceneAction = -1; + pthis->cutsceneFlags = 0; +} + +void EnHorse_ResetRace(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->inRace = false; +} + +s32 EnHorse_PlayerCanMove(EnHorse* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 1) || func_8002DD78(GET_PLAYER(globalCtx)) == 1 || (player->stateFlags1 & 0x100000) || + ((pthis->stateFlags & ENHORSE_FLAG_19) && !pthis->inRace) || pthis->action == ENHORSE_ACT_HBA || + player->actor.flags & ACTOR_FLAG_8 || globalCtx->csCtx.state != 0) { + return false; + } + return true; +} + +void EnHorse_ResetHorsebackArchery(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->unk_39C = 0; + pthis->hbaStarted = 0; + pthis->hbaFlags = 0; +} + +void EnHorse_ClearDustFlags(u16* dustFlags) { + *dustFlags = 0; +} + +void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnHorse* pthis = (EnHorse*)thisx; + GlobalContext* globalCtx = globalCtx2; + + AREG(6) = 0; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + EnHorse_ClearDustFlags(&pthis->dustFlags); + DREG(53) = 0; + pthis->riderPos = pthis->actor.world.pos; + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + pthis->riderPos.y = pthis->riderPos.y + 70.0f; + + if (DREG(4) == 0) { + DREG(4) = 70; + } + + if (pthis->actor.params & 0x8000) { + pthis->actor.params &= ~0x8000; + pthis->type = HORSE_HNI; + + if ((pthis->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HNI)) < 0) { + Actor_Kill(&pthis->actor); + return; + } + + do { + } while (!Object_IsLoaded(&globalCtx->objectCtx, pthis->bankIndex)); + + pthis->actor.objBankIndex = pthis->bankIndex; + Actor_SetObjectDependency(globalCtx, &pthis->actor); + pthis->boostSpeed = 12; + } else { + pthis->type = HORSE_EPONA; + pthis->boostSpeed = 14; + } + + // params was -1 + if (pthis->actor.params == 0x7FFF) { + pthis->actor.params = 1; + } + + if (globalCtx->sceneNum == SCENE_SOUKO) { + pthis->stateFlags = ENHORSE_UNRIDEABLE; + } else if (globalCtx->sceneNum == SCENE_SPOT12 && pthis->type == HORSE_HNI) { + pthis->stateFlags = ENHORSE_FLAG_18 | ENHORSE_UNRIDEABLE; + } else { + if (pthis->actor.params == 3) { + pthis->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else if (pthis->actor.params == 6) { + pthis->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; + if (Flags_GetEventChkInf(0x18) || DREG(1) != 0) { + pthis->stateFlags &= ~ENHORSE_CANT_JUMP; + pthis->stateFlags |= ENHORSE_FLAG_26; + } else if (gSaveContext.eventInf[0] & 0x40 && pthis->type == HORSE_HNI) { + pthis->stateFlags |= ENHORSE_FLAG_21 | ENHORSE_FLAG_20; + } + } else if (pthis->actor.params == 1) { + pthis->stateFlags = ENHORSE_FLAG_7; + } else { + pthis->stateFlags = 0; + } + } + + if (globalCtx->sceneNum == SCENE_SPOT20 && (gSaveContext.eventInf[0] & 0xF) == 6 && + Flags_GetEventChkInf(0x18) == 0 && !DREG(1)) { + pthis->stateFlags |= ENHORSE_FLAG_25; + } + + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.gravity = -3.5f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + pthis->action = ENHORSE_ACT_IDLE; + pthis->actor.speedXZ = 0.0f; + Collider_InitCylinder(globalCtx, &pthis->cyl1); + Collider_SetCylinder(globalCtx, &pthis->cyl1, &pthis->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &pthis->cyl2); + Collider_SetCylinder(globalCtx, &pthis->cyl2, &pthis->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &pthis->jntSph); + Collider_SetJntSph(globalCtx, &pthis->jntSph, &pthis->actor, &sJntSphInit, &pthis->jntSphList); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, DamageTable_Get(0xB), &D_80A65F38); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + pthis->playerControlled = false; + + if ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.sceneSetupIndex < 4)) { + if (pthis->type == HORSE_HNI) { + if (pthis->actor.world.rot.z == 0 || gSaveContext.nightFlag) { + Actor_Kill(&pthis->actor); + return; + } + if (Flags_GetEventChkInf(0x18)) { + Actor_Kill(&pthis->actor); + return; + } + if (pthis->actor.world.rot.z != 5) { + Actor_Kill(&pthis->actor); + return; + } + } else if (!Flags_GetEventChkInf(0x18) && !DREG(1) && gSaveContext.nightFlag) { + Actor_Kill(&pthis->actor); + return; + } + } else if (globalCtx->sceneNum == SCENE_MALON_STABLE) { + if (IS_DAY || Flags_GetEventChkInf(0x18) || DREG(1) != 0 || !LINK_IS_ADULT) { + Actor_Kill(&pthis->actor); + return; + } + pthis->stateFlags |= ENHORSE_UNRIDEABLE; + } + + func_800A663C(globalCtx, &pthis->skin, sSkeletonHeaders[pthis->type], + sAnimationHeaders[pthis->type][ENHORSE_ANIM_IDLE]); + pthis->animationIdx = ENHORSE_ANIM_IDLE; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx]); + pthis->numBoosts = 6; + pthis->blinkTimer = 0; + pthis->postDrawFunc = nullptr; + pthis->boostRegenTime = 0; + EnHorse_ResetCutscene(pthis, globalCtx); + EnHorse_ResetRace(pthis, globalCtx); + EnHorse_ResetHorsebackArchery(pthis, globalCtx); + + if (pthis->actor.params == 2) { + EnHorse_InitInactive(pthis); + } else if (pthis->actor.params == 3) { + EnHorse_InitIngoHorse(pthis); + pthis->rider = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, 1, 1); + if (pthis->rider == NULL) { + __assert("pthis->race.rider != NULL", "../z_en_horse.c", 3077); + } + if (!(gSaveContext.eventInf[0] & 0x40)) { + pthis->ingoHorseMaxSpeed = 12.07f; + } else { + pthis->ingoHorseMaxSpeed = 12.625f; + } + } else if (pthis->actor.params == 7) { + EnHorse_InitCutscene(pthis, globalCtx); + } else if (pthis->actor.params == 8) { + EnHorse_InitHorsebackArchery(pthis); + Interface_InitHorsebackArchery(globalCtx); + } else if (globalCtx->sceneNum == SCENE_SPOT20 && !Flags_GetEventChkInf(0x18) && !DREG(1)) { + EnHorse_InitFleePlayer(pthis); + } else { + if (globalCtx->sceneNum == SCENE_SOUKO) { + EnHorse_ResetIdleAnimation(pthis); + } else if (globalCtx->sceneNum == SCENE_SPOT12 && pthis->type == HORSE_HNI) { + EnHorse_ResetIdleAnimation(pthis); + } else { + EnHorse_StartIdleRidable(pthis); + } + } + pthis->actor.home.rot.z = pthis->actor.world.rot.z = pthis->actor.shape.rot.z = 0; +} + +void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* pthis = (EnHorse*)thisx; + + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_StopSfxByPos(&pthis->unk_21C); + } + func_800A6888(globalCtx, &pthis->skin); + Collider_DestroyCylinder(globalCtx, &pthis->cyl1); + Collider_DestroyCylinder(globalCtx, &pthis->cyl2); + Collider_DestroyJntSph(globalCtx, &pthis->jntSph); +} + +void EnHorse_RotateToPlayer(EnHorse* pthis, GlobalContext* globalCtx) { + EnHorse_RotateToPoint(pthis, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 400); + if (pthis->stateFlags & ENHORSE_OBSTACLE) { + pthis->actor.world.rot.y += 800.0f; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnHorse_Freeze(EnHorse* pthis) { + if (pthis->action != ENHORSE_ACT_CS_UPDATE && pthis->action != ENHORSE_ACT_HBA) { + if (sResetNoInput[pthis->actor.params] != 0 && pthis->actor.params != 4) { + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + } + pthis->prevAction = pthis->action; + pthis->action = ENHORSE_ACT_FROZEN; + pthis->cyl1.base.ocFlags1 &= ~OC1_ON; + pthis->cyl2.base.ocFlags1 &= ~OC1_ON; + pthis->jntSph.base.ocFlags1 &= ~OC1_ON; + pthis->animationIdx = ENHORSE_ANIM_IDLE; + } +} + +void EnHorse_ChangeIdleAnimation(EnHorse* pthis, s32 arg1, f32 arg2); +void EnHorse_StartMountedIdleResetAnim(EnHorse* pthis); +void EnHorse_StartMountedIdle(EnHorse* pthis); +void EnHorse_StartGalloping(EnHorse* pthis); + +void EnHorse_Frozen(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + pthis->noInputTimer--; + if (pthis->noInputTimer < 0) { + pthis->cyl1.base.ocFlags1 |= OC1_ON; + pthis->cyl2.base.ocFlags1 |= OC1_ON; + pthis->jntSph.base.ocFlags1 |= OC1_ON; + if (pthis->playerControlled == true) { + pthis->stateFlags &= ~ENHORSE_FLAG_7; + if (pthis->actor.params == 4) { + EnHorse_StartMountedIdleResetAnim(pthis); + } else if (pthis->actor.params == 9) { + pthis->actor.params = 5; + if (globalCtx->csCtx.state != 0) { + EnHorse_StartMountedIdle(pthis); + } else { + pthis->actor.speedXZ = 8.0f; + EnHorse_StartGalloping(pthis); + } + } else if (pthis->prevAction == 2) { + EnHorse_StartMountedIdle(pthis); + } else { + EnHorse_StartMountedIdleResetAnim(pthis); + } + if (pthis->actor.params != 0) { + pthis->actor.params = 0; + return; + } + } else { + if (pthis->prevAction == 5) { + EnHorse_ChangeIdleAnimation(pthis, 0, 0); + return; + } + if (pthis->prevAction == 6) { + EnHorse_ChangeIdleAnimation(pthis, 0, 0); + return; + } + EnHorse_ChangeIdleAnimation(pthis, 0, 0); + } + } +} + +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); + +void EnHorse_UpdateSpeed(EnHorse* pthis, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, + f32 decel, f32 baseSpeed, s16 turnSpeed) { + s16* stickAnglePtr; // probably fake + f32 stickMag; + s16 stickAngle; + f32 temp_f12; + f32 traction; + s16 turn; + + if (!EnHorse_PlayerCanMove(pthis, globalCtx)) { + if (pthis->actor.speedXZ > 8) { + pthis->actor.speedXZ -= decel; + } else if (pthis->actor.speedXZ < 0) { + pthis->actor.speedXZ = 0; + } + + return; + } + + stickAnglePtr = &stickAngle; + + baseSpeed *= EnHorse_SlopeSpeedMultiplier(pthis, globalCtx); + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (Math_CosS(stickAngle) <= brakeAngle) { + pthis->actor.speedXZ -= brakeDecel; + pthis->actor.speedXZ = pthis->actor.speedXZ < 0.0f ? 0.0f : pthis->actor.speedXZ; + return; + } + + if (stickMag < minStickMag) { + pthis->stateFlags &= ~ENHORSE_BOOST; + pthis->stateFlags &= ~ENHORSE_BOOST_DECEL; + pthis->actor.speedXZ -= decel; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ = 0.0f; + } + + return; + } + + if (pthis->stateFlags & ENHORSE_BOOST) { + if ((16 - pthis->boostTimer) > 0) { + pthis->actor.speedXZ = + (EnHorse_SlopeSpeedMultiplier(pthis, globalCtx) * pthis->boostSpeed - pthis->actor.speedXZ) / + (16 - pthis->boostTimer) + + pthis->actor.speedXZ; + } else { + pthis->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(pthis, globalCtx) * pthis->boostSpeed; + } + + if ((EnHorse_SlopeSpeedMultiplier(pthis, globalCtx) * pthis->boostSpeed) <= pthis->actor.speedXZ) { + pthis->stateFlags &= ~ENHORSE_BOOST; + pthis->stateFlags |= ENHORSE_BOOST_DECEL; + } + + } else if (pthis->stateFlags & ENHORSE_BOOST_DECEL) { + if (baseSpeed < pthis->actor.speedXZ) { + temp_f12 = pthis->actor.speedXZ; + pthis->actor.speedXZ = temp_f12 - 0.06f; + } else if (pthis->actor.speedXZ < baseSpeed) { + pthis->actor.speedXZ = baseSpeed; + pthis->stateFlags &= ~ENHORSE_BOOST_DECEL; + } + } else { + pthis->actor.speedXZ += + (pthis->actor.speedXZ <= baseSpeed * (1.0f / 54.0f) * stickMag ? 1.0f : -1.0f) * 50.0f * 0.01f; + if (baseSpeed < pthis->actor.speedXZ) { + pthis->actor.speedXZ = pthis->actor.speedXZ - decel; + if (pthis->actor.speedXZ < baseSpeed) { + pthis->actor.speedXZ = baseSpeed; + } + } + } + + temp_f12 = *stickAnglePtr * (1 / 32236.f); + traction = 2.2f - (pthis->actor.speedXZ * (1.0f / pthis->boostSpeed)); + turn = *stickAnglePtr * temp_f12 * temp_f12 * traction; + turn = CLAMP(turn, -turnSpeed * traction, turnSpeed * traction); + pthis->actor.world.rot.y += turn; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnHorse_StartMountedIdleResetAnim(EnHorse* pthis) { + pthis->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartMountedIdle(pthis); + pthis->stateFlags &= ~ENHORSE_SANDDUST_SOUND; +} + +void EnHorse_StartMountedIdle(EnHorse* pthis) { + f32 curFrame; + + pthis->action = ENHORSE_ACT_MOUNTED_IDLE; + pthis->animationIdx = ENHORSE_ANIM_IDLE; + if ((pthis->curFrame > 35.0f && pthis->type == HORSE_EPONA) || (pthis->curFrame > 28.0f && pthis->type == HORSE_HNI)) { + if (!(pthis->stateFlags & ENHORSE_SANDDUST_SOUND)) { + pthis->stateFlags |= ENHORSE_SANDDUST_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + curFrame = pthis->skin.skelAnime.curFrame; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_StartReversingInterruptable(EnHorse* pthis); +void EnHorse_StartTurning(EnHorse* pthis); +void EnHorse_StartWalkingFromIdle(EnHorse* pthis); +void EnHorse_MountedIdleAnim(EnHorse* pthis); +void EnHorse_StartReversing(EnHorse* pthis); +void EnHorse_StartWalkingInterruptable(EnHorse* pthis); +void EnHorse_MountedIdleWhinney(EnHorse* pthis); +void EnHorse_StartWalking(EnHorse* pthis); + +void EnHorse_MountedIdle(EnHorse* pthis, GlobalContext* globalCtx) { + f32 mag; + s16 angle = 0; + + pthis->actor.speedXZ = 0; + EnHorse_StickDirection(&pthis->curStick, &mag, &angle); + if (mag > 10.0f && EnHorse_PlayerCanMove(pthis, globalCtx) == true) { + if (Math_CosS(angle) <= -0.5f) { + EnHorse_StartReversingInterruptable(pthis); + } else if (Math_CosS(angle) <= 0.7071) { // cos(45 degrees) + EnHorse_StartTurning(pthis); + } else { + EnHorse_StartWalkingFromIdle(pthis); + } + } + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorse_MountedIdleAnim(pthis); + } +} + +void EnHorse_MountedIdleAnim(EnHorse* pthis) { + pthis->skin.skelAnime.curFrame = 0.0f; + EnHorse_MountedIdleWhinney(pthis); +} + +void EnHorse_MountedIdleWhinney(EnHorse* pthis) { + f32 curFrame; + + pthis->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; + pthis->animationIdx = ENHORSE_ANIM_WHINNEY; + curFrame = pthis->skin.skelAnime.curFrame; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +void EnHorse_MountedIdleWhinneying(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle = 0; + + pthis->actor.speedXZ = 0; + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f && EnHorse_PlayerCanMove(pthis, globalCtx) == true) { + if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(pthis); + } else if (Math_CosS(stickAngle) <= 0.7071) { // cos(45 degrees) + EnHorse_StartTurning(pthis); + } else { + EnHorse_StartWalkingFromIdle(pthis); + } + } + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorse_StartMountedIdleResetAnim(pthis); + } +} + +void EnHorse_StartTurning(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_TURN; + pthis->soundTimer = 0; + pthis->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTurn(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 clampedYaw; + s16 stickAngle; + + pthis->actor.speedXZ = 0; + EnHorse_PlayWalkingSound(pthis); + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (!EnHorse_PlayerCanMove(pthis, globalCtx)) { + EnHorse_StartMountedIdleResetAnim(pthis); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(pthis); + } else if (Math_CosS(stickAngle) <= 0.7071) { // cos(45 degrees) + clampedYaw = CLAMP(stickAngle, -800.0f, 800.0f); + pthis->actor.world.rot.y = pthis->actor.world.rot.y + clampedYaw; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } else { + EnHorse_StartWalkingInterruptable(pthis); + } + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if (Math_CosS(stickAngle) <= 0.7071) { // cos(45 degrees) + EnHorse_StartTurning(pthis); + } else { + EnHorse_StartMountedIdleResetAnim(pthis); + } + } +} + +void EnHorse_StartWalkingFromIdle(EnHorse* pthis) { + EnHorse_StartWalkingInterruptable(pthis); + + if (!(pthis->stateFlags & ENHORSE_FLAG_8) && !(pthis->stateFlags & ENHORSE_FLAG_9)) { + pthis->stateFlags |= ENHORSE_FLAG_9; + pthis->waitTimer = 8; + return; + } + pthis->waitTimer = 0; +} + +void EnHorse_StartWalkingInterruptable(EnHorse* pthis) { + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + EnHorse_StartWalking(pthis); +} + +void EnHorse_StartWalking(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_WALK; + pthis->soundTimer = 0; + pthis->animationIdx = ENHORSE_ANIM_WALK; + pthis->waitTimer = 0; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedWalkingReset(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_WALK; + pthis->soundTimer = 0; + pthis->animationIdx = ENHORSE_ANIM_WALK; + pthis->waitTimer = 0; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx]); +} + +void EnHorse_StartTrotting(EnHorse* pthis); + +void EnHorse_MountedWalk(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_PlayWalkingSound(pthis); + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (pthis->noInputTimerMax == 0.0f || + (pthis->noInputTimer > 0.0f && pthis->noInputTimer < pthis->noInputTimerMax - 20.0f)) { + EnHorse_UpdateSpeed(pthis, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 400); + } else { + pthis->actor.speedXZ = 3.0f; + } + + if (pthis->actor.speedXZ == 0.0f) { + pthis->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartMountedIdleResetAnim(pthis); + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + } else if (pthis->actor.speedXZ > 3.0f) { + pthis->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartTrotting(pthis); + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + } + + if (pthis->noInputTimer > 0.0f) { + pthis->noInputTimer--; + if (pthis->noInputTimer <= 0.0f) { + pthis->noInputTimerMax = 0; + } + } + + if (pthis->waitTimer <= 0) { + pthis->stateFlags &= ~ENHORSE_FLAG_9; + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.75f; + if (SkelAnime_Update(&pthis->skin.skelAnime) || pthis->actor.speedXZ == 0.0f) { + if (pthis->noInputTimer <= 0.0f) { + if (pthis->actor.speedXZ > 3.0f) { + EnHorse_StartTrotting(pthis); + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + } else if ((stickMag < 10.0f) || (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartMountedIdleResetAnim(pthis); + pthis->noInputTimer = 0; + pthis->noInputTimerMax = 0; + } else { + EnHorse_MountedWalkingReset(pthis); + } + } + } + } else { + pthis->actor.speedXZ = 0.0f; + pthis->waitTimer--; + } +} + +void EnHorse_StartTrotting(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_TROT; + pthis->animationIdx = ENHORSE_ANIM_TROT; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTrotReset(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_TROT; + pthis->animationIdx = ENHORSE_ANIM_TROT; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx]); +} + +void EnHorse_StartGallopingInterruptable(EnHorse* pthis); + +void EnHorse_MountedTrot(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_UpdateSpeed(pthis, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 400); + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (pthis->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(pthis); + } + + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.375f; + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorse_PlayTrottingSound(pthis); + func_800AA000(0.0f, 60, 8, 255); + if (pthis->actor.speedXZ >= 6.0f) { + EnHorse_StartGallopingInterruptable(pthis); + } else if (pthis->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(pthis); + } else { + EnHorse_MountedTrotReset(pthis); + } + } +} + +void EnHorse_StartGallopingInterruptable(EnHorse* pthis) { + pthis->noInputTimerMax = 0; + pthis->noInputTimer = 0; + EnHorse_StartGalloping(pthis); +} + +void EnHorse_StartGalloping(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_GALLOP; + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + pthis->unk_234 = 0; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedGallopReset(EnHorse* pthis) { + pthis->noInputTimerMax = 0; + pthis->noInputTimer = 0; + pthis->action = ENHORSE_ACT_MOUNTED_GALLOP; + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + pthis->unk_234 = 0; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx]); +} + +void EnHorse_JumpLanding(EnHorse* pthis, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + pthis->action = ENHORSE_ACT_MOUNTED_GALLOP; + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx]); + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->riderPos.y += y * 0.01f; + pthis->postDrawFunc = NULL; +} + +void EnHorse_StartBraking(EnHorse* pthis, GlobalContext* globalCtx); + +void EnHorse_MountedGallop(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + + if (pthis->noInputTimer <= 0.0f) { + EnHorse_UpdateSpeed(pthis, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 0x190); + } else if (pthis->noInputTimer > 0.0f) { + pthis->noInputTimer -= 1; + pthis->actor.speedXZ = 8.0f; + } + if (pthis->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(pthis); + } + + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.3f; + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorse_PlayGallopingSound(pthis); + func_800AA000(0, 120, 8, 255); + if (EnHorse_PlayerCanMove(pthis, globalCtx) == true) { + if (stickMag >= 10.0f && Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartBraking(pthis, globalCtx); + } else if (pthis->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(pthis); + } else { + EnHorse_MountedGallopReset(pthis); + } + return; + } + EnHorse_MountedGallopReset(pthis); + } +} + +void EnHorse_StartRearing(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_MOUNTED_REARING; + pthis->animationIdx = ENHORSE_ANIM_REARING; + pthis->stateFlags &= ~ENHORSE_LAND2_SOUND; + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + func_800AA000(0.0f, 180, 20, 100); + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedRearing(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + pthis->actor.speedXZ = 0; + if (pthis->curFrame > 25.0f) { + if (!(pthis->stateFlags & ENHORSE_LAND2_SOUND)) { + pthis->stateFlags |= ENHORSE_LAND2_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_800AA000(0, 180, 20, 100); + } + } + + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(pthis, globalCtx) == true) { + if (pthis->stateFlags & ENHORSE_FORCE_REVERSING) { + pthis->noInputTimer = 100; + pthis->noInputTimerMax = 100; + pthis->stateFlags &= ~ENHORSE_FORCE_REVERSING; + EnHorse_StartReversing(pthis); + } else if (pthis->stateFlags & ENHORSE_FORCE_WALKING) { + pthis->noInputTimer = 100; + pthis->noInputTimerMax = 100; + pthis->stateFlags &= ~ENHORSE_FORCE_WALKING; + EnHorse_StartWalking(pthis); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(pthis); + } else { + EnHorse_StartMountedIdleResetAnim(pthis); + } + return; + } + EnHorse_StartMountedIdleResetAnim(pthis); + } +} + +void EnHorse_StartBraking(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->action = ENHORSE_ACT_STOPPING; + pthis->animationIdx = ENHORSE_ANIM_STOPPING; + + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SLIP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + + pthis->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; + pthis->stateFlags &= ~ENHORSE_BOOST; +} + +void EnHorse_Stopping(EnHorse* pthis, GlobalContext* globalCtx) { + if (pthis->actor.speedXZ > 0.0f) { + pthis->actor.speedXZ = pthis->actor.speedXZ - 0.6f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ = 0.0f; + } + } + + if (pthis->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND && pthis->skin.skelAnime.curFrame > 29.0f) { + pthis->actor.speedXZ = 0.0f; + if (Rand_ZeroOne() > 0.5) { + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + func_800AA000(0.0f, 180, 20, 100); + pthis->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } else { + EnHorse_StartMountedIdleResetAnim(pthis); + } + } + + if (pthis->skin.skelAnime.curFrame > 29.0f) { + pthis->actor.speedXZ = 0.0f; + } else if (pthis->actor.speedXZ > 3.0f && pthis->stateFlags & ENHORSE_FORCE_REVERSING) { + pthis->actor.speedXZ = 3.0f; + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if (pthis->stateFlags & ENHORSE_FORCE_REVERSING) { + pthis->noInputTimer = 100; + pthis->noInputTimerMax = 100; + EnHorse_StartReversing(pthis); + pthis->stateFlags &= ~ENHORSE_FORCE_REVERSING; + } else { + EnHorse_StartMountedIdleResetAnim(pthis); + } + } +} + +void EnHorse_StartReversingInterruptable(EnHorse* pthis) { + pthis->noInputTimerMax = 0; + pthis->noInputTimer = 0; + EnHorse_StartReversing(pthis); +} + +void EnHorse_StartReversing(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_REVERSE; + pthis->animationIdx = ENHORSE_ANIM_WALK; + pthis->soundTimer = 0; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_LOOP, -3.0f); +} + +void EnHorse_Reverse(EnHorse* pthis, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + s16 turnAmount; + Player* player = GET_PLAYER(globalCtx); + + EnHorse_PlayWalkingSound(pthis); + EnHorse_StickDirection(&pthis->curStick, &stickMag, &stickAngle); + if (EnHorse_PlayerCanMove(pthis, globalCtx) == true) { + if (pthis->noInputTimerMax == 0.0f || + (pthis->noInputTimer > 0.0f && pthis->noInputTimer < pthis->noInputTimerMax - 20.0f)) { + if (stickMag < 10.0f && pthis->noInputTimer <= 0.0f) { + EnHorse_StartMountedIdleResetAnim(pthis); + pthis->actor.speedXZ = 0.0f; + return; + } + if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } else if (Math_CosS(stickAngle) > -0.5f) { + pthis->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(pthis); + pthis->actor.speedXZ = 0.0f; + return; + } + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } + } else if (player->actor.flags & ACTOR_FLAG_8) { + EnHorse_StartMountedIdleResetAnim(pthis); + pthis->actor.speedXZ = 0.0f; + return; + } else { + stickAngle = -0x7FFF; + } + + pthis->actor.speedXZ = -2.0f; + turnAmount = 0x7FFF - stickAngle; + turnAmount = CLAMP(turnAmount, -1200.0f, 1200.0f); + pthis->actor.world.rot.y += turnAmount; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->noInputTimer > 0.0f) { + pthis->noInputTimer--; + if (pthis->noInputTimer <= 0.0f) { + pthis->noInputTimerMax = 0; + } + } + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.5f * 1.5f; + if (SkelAnime_Update(&pthis->skin.skelAnime) && (f32)pthis->noInputTimer <= 0.0f && + EnHorse_PlayerCanMove(pthis, globalCtx) == true) { + if (stickMag > 10.0f && Math_CosS(stickAngle) <= -0.5f) { + pthis->noInputTimerMax = 0; + EnHorse_StartReversingInterruptable(pthis); + } else if (stickMag < 10.0f) { + pthis->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(pthis); + } else { + EnHorse_StartReversing(pthis); + } + } +} + +void EnHorse_StartLowJump(EnHorse* pthis, GlobalContext* globalCtx); + +void EnHorse_LowJumpInit(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartLowJump(pthis, globalCtx); +} + +void EnHorse_StartLowJump(EnHorse* pthis, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + pthis->action = ENHORSE_ACT_LOW_JUMP; + pthis->animationIdx = ENHORSE_ANIM_LOW_JUMP; + curFrame = pthis->skin.skelAnime.curFrame; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + + pthis->postDrawFunc = NULL; + pthis->jumpStartY = pthis->actor.world.pos.y; + + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0; + + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->riderPos.y -= y * 0.01f; + + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + func_800AA000(0.0f, 170, 10, 10); +} + +void EnHorse_Stub1(EnHorse* pthis) { +} + +void EnHorse_LowJump(EnHorse* pthis, GlobalContext* globalCtx) { + Vec3f pad; + Vec3s* jointTable; + f32 curFrame; + f32 y; + + curFrame = pthis->skin.skelAnime.curFrame; + pthis->stateFlags |= ENHORSE_JUMPING; + pthis->actor.speedXZ = 12.0f; + if (curFrame > 17.0f) { + pthis->actor.gravity = -3.5f; + if (pthis->actor.velocity.y == 0) { + pthis->actor.velocity.y = -6.0f; + } + if (pthis->actor.world.pos.y < pthis->actor.floorHeight + 90.0f) { + pthis->skin.skelAnime.playSpeed = 1.5f; + } else { + pthis->skin.skelAnime.playSpeed = 0; + } + } else { + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->actor.world.pos.y = pthis->jumpStartY + y * 0.01f; + } + + if (SkelAnime_Update(&pthis->skin.skelAnime) || + (curFrame > 17.0f && pthis->actor.world.pos.y < pthis->actor.floorHeight - pthis->actor.velocity.y + 80.0f)) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_800AA000(0.0f, 255, 10, 80); + pthis->stateFlags &= ~ENHORSE_JUMPING; + pthis->actor.gravity = -3.5f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + func_80028A54(globalCtx, 25.0f, &pthis->actor.world.pos); + EnHorse_JumpLanding(pthis, globalCtx); + } +} + +void EnHorse_StartHighJump(EnHorse* pthis, GlobalContext* globalCtx); + +void EnHorse_HighJumpInit(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartHighJump(pthis, globalCtx); +} + +void EnHorse_StartHighJump(EnHorse* pthis, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + pthis->action = ENHORSE_ACT_HIGH_JUMP; + pthis->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = pthis->skin.skelAnime.curFrame; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + + pthis->jumpStartY = pthis->actor.world.pos.y; + pthis->postDrawFunc = NULL; + + pthis->actor.gravity = 0; + pthis->actor.velocity.y = 0.0f; + + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->riderPos.y -= y * 0.01f; + + pthis->stateFlags |= ENHORSE_CALC_RIDER_POS; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + func_800AA000(0.0f, 170, 10, 10); +} + +void EnHorse_Stub2(EnHorse* pthis) { +} + +void EnHorse_HighJump(EnHorse* pthis, GlobalContext* globalCtx) { + Vec3f pad; + Vec3s* jointTable; + f32 curFrame; + f32 y; + + curFrame = pthis->skin.skelAnime.curFrame; + pthis->stateFlags |= ENHORSE_JUMPING; + pthis->actor.speedXZ = 13.0f; + if (curFrame > 23.0f) { + pthis->actor.gravity = -3.5f; + if (pthis->actor.velocity.y == 0) { + pthis->actor.velocity.y = -10.5f; + } + + if (pthis->actor.world.pos.y < pthis->actor.floorHeight + 90.0f) { + pthis->skin.skelAnime.playSpeed = 1.5f; + } else { + pthis->skin.skelAnime.playSpeed = 0; + } + } else { + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->actor.world.pos.y = pthis->jumpStartY + y * 0.01f; + } + + if (SkelAnime_Update(&pthis->skin.skelAnime) || + (curFrame > 23.0f && pthis->actor.world.pos.y < pthis->actor.floorHeight - pthis->actor.velocity.y + 80.0f)) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_800AA000(0.0f, 255, 10, 80); + pthis->stateFlags &= ~ENHORSE_JUMPING; + pthis->actor.gravity = -3.5f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + func_80028A54(globalCtx, 25.0f, &pthis->actor.world.pos); + EnHorse_JumpLanding(pthis, globalCtx); + } +} + +void EnHorse_InitInactive(EnHorse* pthis) { + pthis->cyl1.base.ocFlags1 &= ~OC1_ON; + pthis->cyl2.base.ocFlags1 &= ~OC1_ON; + pthis->jntSph.base.ocFlags1 &= ~OC1_ON; + pthis->action = ENHORSE_ACT_INACTIVE; + pthis->animationIdx = ENHORSE_ANIM_WALK; + pthis->stateFlags |= ENHORSE_INACTIVE; + pthis->followTimer = 0; +} + +void EnHorse_SetFollowAnimation(EnHorse* pthis, GlobalContext* globalCtx); + +void EnHorse_Inactive(EnHorse* pthis, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + + if (DREG(53) != 0 && pthis->type == HORSE_EPONA) { + DREG(53) = 0; + if (EnHorse_Spawn(pthis, globalCtx) != 0) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->stateFlags &= ~ENHORSE_INACTIVE; + gSaveContext.horseData.scene = globalCtx->sceneNum; + + // Focus the camera on Epona + Camera_SetParam(globalCtx->cameraPtrs[0], 8, pthis); + Camera_ChangeSetting(globalCtx->cameraPtrs[0], 0x38); + Camera_SetCameraData(globalCtx->cameraPtrs[0], 4, NULL, NULL, 0x51, 0, 0); + } + } + if (!(pthis->stateFlags & ENHORSE_INACTIVE)) { + pthis->followTimer = 0; + EnHorse_SetFollowAnimation(pthis, globalCtx); + pthis->actor.params = 0; + pthis->cyl1.base.ocFlags1 |= OC1_ON; + pthis->cyl2.base.ocFlags1 |= OC1_ON; + pthis->jntSph.base.ocFlags1 |= OC1_ON; + } +} + +void EnHorse_PlayIdleAnimation(EnHorse* pthis, s32 anim, f32 morphFrames, f32 startFrame) { + pthis->action = ENHORSE_ACT_IDLE; + pthis->actor.speedXZ = 0.0f; + if (anim != ENHORSE_ANIM_IDLE && anim != ENHORSE_ANIM_WHINNEY && anim != ENHORSE_ANIM_REARING) { + anim = ENHORSE_ANIM_IDLE; + } + if (anim != pthis->animationIdx) { + pthis->animationIdx = anim; + if (pthis->animationIdx == ENHORSE_ANIM_IDLE) { + pthis->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else if (pthis->animationIdx == ENHORSE_ANIM_WHINNEY) { + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else if (pthis->animationIdx == ENHORSE_ANIM_REARING) { + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + pthis->stateFlags &= ~ENHORSE_LAND2_SOUND; + } + + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, startFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } +} + +void EnHorse_ChangeIdleAnimation(EnHorse* pthis, s32 anim, f32 morphFrames) { + EnHorse_PlayIdleAnimation(pthis, anim, morphFrames, pthis->curFrame); +} + +void EnHorse_ResetIdleAnimation(EnHorse* pthis) { + pthis->animationIdx = ENHORSE_ANIM_WALK; // pthis forces anim 0 to play from the beginning + EnHorse_PlayIdleAnimation(pthis, pthis->animationIdx, 0, 0); +} + +void EnHorse_StartIdleRidable(EnHorse* pthis) { + EnHorse_ResetIdleAnimation(pthis); + pthis->stateFlags &= ~ENHORSE_UNRIDEABLE; +} + +void EnHorse_StartMovingAnimation(EnHorse* pthis, s32 arg1, f32 arg2, f32 arg3); + +void EnHorse_Idle(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + EnHorse_IdleAnimSounds(pthis, globalCtx); + + if (DREG(53) && pthis->type == HORSE_EPONA) { + DREG(53) = 0; + if (!func_80A5BBBC(globalCtx, pthis, &pthis->actor.world.pos)) { + if (EnHorse_Spawn(pthis, globalCtx)) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->followTimer = 0; + EnHorse_SetFollowAnimation(pthis, globalCtx); + Camera_SetParam(globalCtx->cameraPtrs[0], 8, pthis); + Camera_ChangeSetting(globalCtx->cameraPtrs[0], 0x38); + Camera_SetCameraData(globalCtx->cameraPtrs[0], 4, NULL, NULL, 0x51, 0, 0); + } + } else { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->followTimer = 0; + EnHorse_StartMovingAnimation(pthis, 6, -3.0f, 0.0f); + } + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + s32 idleAnimIdx = 0; + + if (pthis->animationIdx != ENHORSE_ANIM_IDLE) { + if (pthis->animationIdx == ENHORSE_ANIM_WHINNEY) { + idleAnimIdx = 1; + } else if (pthis->animationIdx == ENHORSE_ANIM_REARING) { + idleAnimIdx = 2; + } + } + + // Play one of the two other idle animations + EnHorse_PlayIdleAnimation(pthis, sIdleAnimIds[(Rand_ZeroOne() > 0.5f ? 0 : 1) + idleAnimIdx * 2], 0.0f, 0.0f); + } +} + +void EnHorse_StartMovingAnimation(EnHorse* pthis, s32 animId, f32 morphFrames, f32 startFrame) { + pthis->action = ENHORSE_ACT_FOLLOW_PLAYER; + pthis->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + if (animId != ENHORSE_ANIM_TROT && animId != ENHORSE_ANIM_GALLOP && animId != ENHORSE_ANIM_WALK) { + animId = ENHORSE_ANIM_WALK; + } + if (pthis->animationIdx != animId) { + pthis->animationIdx = animId; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, startFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, startFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_SetFollowAnimation(EnHorse* pthis, GlobalContext* globalCtx) { + s32 animId = ENHORSE_ANIM_WALK; + f32 distToPlayer; + + distToPlayer = Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + if (distToPlayer > 400.0f) { + animId = ENHORSE_ANIM_GALLOP; + } else if (!(distToPlayer <= 300.0f)) { + if (distToPlayer <= 400.0f) { + animId = ENHORSE_ANIM_TROT; + } + } + + if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + if (distToPlayer > 400.0f) { + animId = ENHORSE_ANIM_GALLOP; + } else { + animId = ENHORSE_ANIM_TROT; + } + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + if (distToPlayer > 400.0f) { + animId = ENHORSE_ANIM_GALLOP; + } else if (distToPlayer < 300.0f) { + animId = ENHORSE_ANIM_WALK; + } else { + animId = ENHORSE_ANIM_TROT; + } + } else if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + if (distToPlayer > 300.0f) { + animId = ENHORSE_ANIM_TROT; + } else { + animId = ENHORSE_ANIM_WALK; + } + } + EnHorse_StartMovingAnimation(pthis, animId, -3.0f, 0.0f); +} + +void EnHorse_FollowPlayer(EnHorse* pthis, GlobalContext* globalCtx) { + f32 distToPlayer; + f32 angleDiff; + + DREG(53) = 0; + distToPlayer = Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + + // First rotate if the player is behind + if ((pthis->playerDir == PLAYER_DIR_BACK_R || pthis->playerDir == PLAYER_DIR_BACK_L) && + (distToPlayer > 300.0f && !(pthis->stateFlags & ENHORSE_TURNING_TO_PLAYER))) { + pthis->animationIdx = ENHORSE_ANIM_REARING; + pthis->stateFlags |= ENHORSE_TURNING_TO_PLAYER; + pthis->angleToPlayer = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + angleDiff = (f32)pthis->angleToPlayer - (f32)pthis->actor.world.rot.y; + if (angleDiff > 32767.f) { + angleDiff -= 32767.0f; + } else if (angleDiff < -32767) { + angleDiff += 32767; + } + + pthis->followPlayerTurnSpeed = + angleDiff / Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]); + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx]); + pthis->skin.skelAnime.playSpeed = 1.0f; + pthis->stateFlags &= ~ENHORSE_LAND2_SOUND; + pthis->unk_21C = pthis->unk_228; + } else if (pthis->stateFlags & ENHORSE_TURNING_TO_PLAYER) { + pthis->actor.world.rot.y = pthis->actor.world.rot.y + pthis->followPlayerTurnSpeed; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (pthis->curFrame > 25.0f) { + if (!(pthis->stateFlags & ENHORSE_LAND2_SOUND)) { + pthis->stateFlags |= ENHORSE_LAND2_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + } else { + EnHorse_RotateToPlayer(pthis, globalCtx); + } + + if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + pthis->actor.speedXZ = 8; + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.3f; + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + pthis->actor.speedXZ = 6; + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.375f; + } else if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + pthis->actor.speedXZ = 3; + EnHorse_PlayWalkingSound(pthis); + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.75f; + } else { + pthis->actor.speedXZ = 0; + pthis->skin.skelAnime.playSpeed = 1.0f; + } + + if (!(pthis->stateFlags & ENHORSE_TURNING_TO_PLAYER) && ++pthis->followTimer > 300) { + EnHorse_StartIdleRidable(pthis); + pthis->unk_21C = pthis->unk_228; + + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + EnHorse_PlayGallopingSound(pthis); + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + EnHorse_PlayTrottingSound(pthis); + } + pthis->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + if (distToPlayer < 100.0f) { + EnHorse_StartIdleRidable(pthis); + } else { + EnHorse_SetFollowAnimation(pthis, globalCtx); + } + } +} + +void EnHorse_UpdateIngoHorseAnim(EnHorse* pthis); + +void EnHorse_InitIngoHorse(EnHorse* pthis) { + pthis->curRaceWaypoint = 0; + pthis->soundTimer = 0; + pthis->actor.speedXZ = 0.0f; + EnHorse_UpdateIngoHorseAnim(pthis); + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_IT_INGO_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +void EnHorse_SetIngoAnimation(s32 idx, f32 curFrame, s32 arg2, s16* animIdxOut, f32* curFrameOut) { + *animIdxOut = sIngoAnimations[idx]; + *curFrameOut = curFrame; + if (idx == 3 || idx == 7 || idx == 8 || idx == 4) { + *curFrameOut = 0.0f; + } + if (arg2 == 1) { + if (idx == 5) { + *animIdxOut = 4; + *curFrameOut = curFrame; + } else if (idx == 6) { + *animIdxOut = 3; + *curFrameOut = curFrame; + } + } +} + +void EnHorse_UpdateIngoHorseAnim(EnHorse* pthis) { + s32 animChanged = 0; + f32 animSpeed; + + pthis->action = ENHORSE_ACT_INGO_RACE; + pthis->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + if (pthis->actor.speedXZ == 0.0f) { + if (pthis->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_IDLE; + } else if (pthis->actor.speedXZ <= 3.0f) { + if (pthis->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_WALK; + } else if (pthis->actor.speedXZ <= 6.0f) { + if (pthis->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (pthis->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = pthis->actor.speedXZ * 0.5f; + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = pthis->actor.speedXZ * 0.25f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = pthis->actor.speedXZ * 0.2f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + sPlaybackSpeeds[pthis->animationIdx] * animSpeed * 1.5f, 0, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + sPlaybackSpeeds[pthis->animationIdx] * animSpeed * 1.5f, 0, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, 0); + } +} + +void EnHorse_UpdateIngoRace(EnHorse* pthis, GlobalContext* globalCtx) { + f32 playSpeed; + + if (pthis->animationIdx == ENHORSE_ANIM_IDLE || pthis->animationIdx == ENHORSE_ANIM_WHINNEY) { + EnHorse_IdleAnimSounds(pthis, globalCtx); + } else if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(pthis); + } + + EnHorse_UpdateIngoRaceInfo(pthis, globalCtx, &sIngoRace); + if (!pthis->inRace) { + pthis->actor.speedXZ = 0.0f; + pthis->rider->speedXZ = 0.0f; + if (pthis->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(pthis); + } + } + + if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = pthis->actor.speedXZ * 0.5f; + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + playSpeed = pthis->actor.speedXZ * 0.25f; + } else if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + playSpeed = pthis->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + pthis->skin.skelAnime.playSpeed = playSpeed; + if (SkelAnime_Update(&pthis->skin.skelAnime) || + (pthis->animationIdx == ENHORSE_ANIM_IDLE && pthis->actor.speedXZ != 0.0f)) { + EnHorse_UpdateIngoHorseAnim(pthis); + } + + if (pthis->stateFlags & ENHORSE_INGO_WON) { + ((EnIn*)pthis->rider)->animationIdx = 7; + ((EnIn*)pthis->rider)->unk_1E0 = 0; + return; + } + + EnHorse_SetIngoAnimation(pthis->animationIdx, pthis->skin.skelAnime.curFrame, pthis->ingoRaceFlags & 1, + &((EnIn*)pthis->rider)->animationIdx, &((EnIn*)pthis->rider)->unk_1E0); +} + +void EnHorse_CsMoveInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + pthis->cutsceneAction = 1; + Animation_PlayOnceSetSpeed(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + pthis->actor.speedXZ * 0.3f); +} + +void EnHorse_CsPlayHighJumpAnim(EnHorse* pthis, GlobalContext* globalCtx); + +void EnHorse_CsMoveToPoint(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + f32 speed = 8.0f; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + if (Math3D_Vec3f_DistXYZ(&endPos, &pthis->actor.world.pos) > speed) { + EnHorse_RotateToPoint(pthis, globalCtx, &endPos, 400); + pthis->actor.speedXZ = speed; + pthis->skin.skelAnime.playSpeed = speed * 0.3f; + } else { + pthis->actor.world.pos = endPos; + pthis->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorse_PlayGallopingSound(pthis); + func_800AA000(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + pthis->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsSetAnimHighJump(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->skin.skelAnime.curFrame = 0.0f; + EnHorse_CsPlayHighJumpAnim(pthis, globalCtx); +} + +void EnHorse_CsPlayHighJumpAnim(EnHorse* pthis, GlobalContext* globalCtx) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + + pthis->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = pthis->skin.skelAnime.curFrame; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + pthis->postDrawFunc = NULL; + pthis->jumpStartY = pthis->actor.world.pos.y; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0; + + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->riderPos.y -= y * 0.01f; + + pthis->stateFlags |= ENHORSE_CALC_RIDER_POS; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + func_800AA000(0.0f, 170, 10, 10); +} + +void EnHorse_CsJumpInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_CsSetAnimHighJump(pthis, globalCtx); + pthis->cutsceneAction = 2; + pthis->cutsceneFlags &= ~1; +} + +void EnHorse_CsJump(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + f32 temp_f2; + + if (pthis->cutsceneFlags & 1) { + EnHorse_CsMoveToPoint(pthis, globalCtx, action); + return; + } + temp_f2 = pthis->skin.skelAnime.curFrame; + pthis->stateFlags |= ENHORSE_JUMPING; + pthis->actor.speedXZ = 13.0f; + if (temp_f2 > 19.0f) { + pthis->actor.gravity = -3.5f; + if (pthis->actor.velocity.y == 0.0f) { + pthis->actor.velocity.y = -10.5f; + } + if (pthis->actor.world.pos.y < (pthis->actor.floorHeight + 90.0f)) { + pthis->skin.skelAnime.playSpeed = 1.5f; + } else { + pthis->skin.skelAnime.playSpeed = 0.0f; + } + } else { + Vec3s* jointTable; + f32 y; + + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->actor.world.pos.y = pthis->jumpStartY + y * 0.01f; + } + if (SkelAnime_Update(&pthis->skin.skelAnime) || + (temp_f2 > 19.0f && pthis->actor.world.pos.y < (pthis->actor.floorHeight - pthis->actor.velocity.y) + 80.0f)) { + Vec3s* jointTable; + f32 y; + + pthis->cutsceneFlags |= 1; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_800AA000(0.0f, 255, 10, 80); + pthis->stateFlags &= ~ENHORSE_JUMPING; + pthis->actor.gravity = -3.5f; + pthis->actor.velocity.y = 0; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + func_80028A54(globalCtx, 25.0f, &pthis->actor.world.pos); + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnceSetSpeed(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + sPlaybackSpeeds[6]); + jointTable = pthis->skin.skelAnime.jointTable; + y = jointTable->y; + pthis->riderPos.y += y * 0.01f; + pthis->postDrawFunc = NULL; + } +} + +void EnHorse_CsRearingInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + pthis->animationIdx = ENHORSE_ANIM_REARING; + pthis->cutsceneAction = 3; + pthis->cutsceneFlags &= ~4; + pthis->stateFlags &= ~ENHORSE_LAND2_SOUND; + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsRearing(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + pthis->actor.speedXZ = 0.0f; + if (pthis->curFrame > 25.0f) { + if (!(pthis->stateFlags & ENHORSE_LAND2_SOUND)) { + pthis->stateFlags |= ENHORSE_LAND2_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + pthis->animationIdx = ENHORSE_ANIM_IDLE; + if (!(pthis->cutsceneFlags & 4)) { + pthis->cutsceneFlags |= 4; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), 0, 0.0f); + } + } +} + +void EnHorse_WarpMoveInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + pthis->actor.world.pos.x = action->startPos.x; + pthis->actor.world.pos.y = action->startPos.y; + pthis->actor.world.pos.z = action->startPos.z; + pthis->actor.prevPos = pthis->actor.world.pos; + pthis->actor.world.rot.y = action->urot.y; + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + pthis->cutsceneAction = 4; + Animation_PlayOnceSetSpeed(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + pthis->actor.speedXZ * 0.3f); +} + +void EnHorse_CsWarpMoveToPoint(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + f32 speed = 8.0f; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + if (Math3D_Vec3f_DistXYZ(&endPos, &pthis->actor.world.pos) > speed) { + EnHorse_RotateToPoint(pthis, globalCtx, &endPos, 400); + pthis->actor.speedXZ = speed; + pthis->skin.skelAnime.playSpeed = speed * 0.3f; + } else { + pthis->actor.world.pos = endPos; + pthis->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorse_PlayGallopingSound(pthis); + func_800AA000(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + pthis->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsWarpRearingInit(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + pthis->actor.world.pos.x = action->startPos.x; + pthis->actor.world.pos.y = action->startPos.y; + pthis->actor.world.pos.z = action->startPos.z; + pthis->actor.prevPos = pthis->actor.world.pos; + pthis->actor.world.rot.y = action->urot.y; + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->animationIdx = ENHORSE_ANIM_REARING; + pthis->cutsceneAction = 5; + pthis->cutsceneFlags &= ~4; + pthis->stateFlags &= ~ENHORSE_LAND2_SOUND; + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsWarpRearing(EnHorse* pthis, GlobalContext* globalCtx, CsCmdActorAction* action) { + pthis->actor.speedXZ = 0.0f; + if (pthis->curFrame > 25.0f) { + if (!(pthis->stateFlags & ENHORSE_LAND2_SOUND)) { + pthis->stateFlags |= ENHORSE_LAND2_SOUND; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + pthis->animationIdx = ENHORSE_ANIM_IDLE; + if (!(pthis->cutsceneFlags & 4)) { + pthis->cutsceneFlags |= 4; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), 0, 0.0f); + } + } +} + +void EnHorse_InitCutscene(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->playerControlled = false; + pthis->action = ENHORSE_ACT_CS_UPDATE; + pthis->cutsceneAction = 0; + pthis->actor.speedXZ = 0.0f; +} + +s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { + s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling + s32 i; + + for (i = 0; i < numActions; i++) { + if (csAction == sCsActionTable[i].csAction) { + return sCsActionTable[i].csFuncIdx; + } + if (csAction < sCsActionTable[i].csAction) { + return 0; + } + } + return 0; +} + +void EnHorse_CutsceneUpdate(EnHorse* pthis, GlobalContext* globalCtx) { + s32 csFunctionIdx; + CsCmdActorAction* linkCsAction = globalCtx->csCtx.linkAction; + + if (globalCtx->csCtx.state == 3) { + pthis->playerControlled = 1; + pthis->actor.params = 10; + pthis->action = ENHORSE_ACT_IDLE; + EnHorse_Freeze(pthis); + return; + } + + if (linkCsAction != 0) { + csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(linkCsAction->action); + if (csFunctionIdx != 0) { + if (pthis->cutsceneAction != csFunctionIdx) { + if (pthis->cutsceneAction == 0) { + pthis->actor.world.pos.x = linkCsAction->startPos.x; + pthis->actor.world.pos.y = linkCsAction->startPos.y; + pthis->actor.world.pos.z = linkCsAction->startPos.z; + pthis->actor.world.rot.y = linkCsAction->urot.y; + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->actor.prevPos = pthis->actor.world.pos; + } + pthis->cutsceneAction = csFunctionIdx; + sCutsceneInitFuncs[pthis->cutsceneAction](pthis, globalCtx, linkCsAction); + } + sCutsceneActionFuncs[pthis->cutsceneAction](pthis, globalCtx, linkCsAction); + } + } +} + +s32 EnHorse_UpdateHbaRaceInfo(EnHorse* pthis, GlobalContext* globalCtx, RaceInfo* raceInfo) { + Vec3f pos; + f32 px; + f32 pz; + f32 d; + + EnHorse_RaceWaypointPos(raceInfo->waypoints, pthis->curRaceWaypoint, &pos); + Math3D_RotateXZPlane(&pos, raceInfo->waypoints[pthis->curRaceWaypoint].angle, &px, &pz, &d); + + if (pthis->curRaceWaypoint >= raceInfo->numWaypoints - 1 && + Math3D_Vec3f_DistXYZ(&pos, &pthis->actor.world.pos) < DREG(8)) { + pthis->hbaFlags |= 2; + } + + if (((pthis->actor.world.pos.x * px) + (pz * pthis->actor.world.pos.z) + d) > 0.0f) { + pthis->curRaceWaypoint++; + if (pthis->curRaceWaypoint >= raceInfo->numWaypoints) { + pthis->hbaFlags |= 1; + return 1; + } + } + + if (!(pthis->hbaFlags & 1)) { + EnHorse_RotateToPoint(pthis, globalCtx, &pos, 800); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (pthis->actor.speedXZ < raceInfo->waypoints[pthis->curRaceWaypoint].speed && !(pthis->hbaFlags & 1)) { + pthis->actor.speedXZ += 0.4f; + } else { + pthis->actor.speedXZ -= 0.4f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ = 0.0f; + } + } + return 0; +} + +void EnHorse_UpdateHbaAnim(EnHorse* pthis); + +void EnHorse_InitHorsebackArchery(EnHorse* pthis) { + pthis->hbaStarted = 0; + pthis->soundTimer = 0; + pthis->curRaceWaypoint = 0; + pthis->hbaTimer = 0; + pthis->actor.speedXZ = 0.0f; + EnHorse_UpdateHbaAnim(pthis); +} + +void EnHorse_UpdateHbaAnim(EnHorse* pthis) { + s32 animChanged = 0; + f32 animSpeed; + + pthis->action = ENHORSE_ACT_HBA; + if (pthis->actor.speedXZ == 0.0f) { + if (pthis->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_IDLE; + } else if (pthis->actor.speedXZ <= 3.0f) { + if (pthis->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_WALK; + } else if (pthis->actor.speedXZ <= 6.0f) { + if (pthis->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (pthis->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + pthis->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = pthis->actor.speedXZ * 0.5f; + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = pthis->actor.speedXZ * 0.25f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + func_800AA000(0.0f, 60, 8, 255); + } else if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = pthis->actor.speedXZ * 0.2f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + func_800AA000(0.0f, 120, 8, 255); + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + sPlaybackSpeeds[pthis->animationIdx] * animSpeed * 1.5f, 0, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], + sPlaybackSpeeds[pthis->animationIdx] * animSpeed * 1.5f, 0, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, 0); + } +} + +void EnHorse_UpdateHorsebackArchery(EnHorse* pthis, GlobalContext* globalCtx) { + f32 playSpeed; + s32 sp20; + + if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(pthis); + } + if (globalCtx->interfaceCtx.hbaAmmo == 0) { + pthis->hbaTimer++; + } + + sp20 = func_800F5A58(NA_BGM_HORSE_GOAL); + EnHorse_UpdateHbaRaceInfo(pthis, globalCtx, &sHbaInfo); + if (pthis->hbaFlags & 1 || pthis->hbaTimer >= 46) { + if (sp20 != 1 && gSaveContext.minigameState != 3) { + gSaveContext.cutsceneIndex = 0; + globalCtx->nextEntranceIndex = 0x3B0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 0x20; + } + } + + if (globalCtx->interfaceCtx.hbaAmmo != 0) { + if (!(pthis->hbaFlags & 2)) { + if (gSaveContext.infTable[25] & 1) { + if ((s32)gSaveContext.minigameScore >= 1500) { + pthis->hbaFlags |= 4; + } + } else { + if ((s32)gSaveContext.minigameScore >= 1000) { + pthis->hbaFlags |= 4; + } + } + } + } + + if ((globalCtx->interfaceCtx.hbaAmmo == 0) || (pthis->hbaFlags & 2)) { + if (pthis->hbaFlags & 4) { + pthis->hbaFlags &= ~4; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + } + } + + if (!pthis->hbaStarted) { + pthis->actor.speedXZ = 0.0f; + if (pthis->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateHbaAnim(pthis); + } + } + + if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = pthis->actor.speedXZ * 0.5f; + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + playSpeed = pthis->actor.speedXZ * 0.25f; + } else if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + playSpeed = pthis->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + + pthis->skin.skelAnime.playSpeed = playSpeed; + if (SkelAnime_Update(&pthis->skin.skelAnime) || + (pthis->animationIdx == ENHORSE_ANIM_IDLE && pthis->actor.speedXZ != 0.0f)) { + EnHorse_UpdateHbaAnim(pthis); + } +} + +void EnHorse_InitFleePlayer(EnHorse* pthis) { + pthis->action = ENHORSE_ACT_FLEE_PLAYER; + pthis->stateFlags |= ENHORSE_UNRIDEABLE; + pthis->actor.speedXZ = 0.0f; +} + +void EnHorse_FleePlayer(EnHorse* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToHome; + f32 playerDistToHome; + f32 distToPlayer; + s32 nextAnim = pthis->animationIdx; + s32 animFinished; + s16 yaw; + + if (DREG(53) || pthis->type == HORSE_HNI) { + EnHorse_StartIdleRidable(pthis); + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + + distToHome = Math3D_Vec3f_DistXYZ(&pthis->actor.home.pos, &pthis->actor.world.pos); + playerDistToHome = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &pthis->actor.home.pos); + distToPlayer = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &pthis->actor.world.pos); + + // Run home + if (playerDistToHome > 300.0f) { + if (distToHome > 150.0f) { + pthis->actor.speedXZ += 0.4f; + if (pthis->actor.speedXZ > 8.0f) { + pthis->actor.speedXZ = 8.0f; + } + } else { + pthis->actor.speedXZ -= 0.47f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ = 0.0f; + } + } + } else { + // Run away from Link + if (distToPlayer < 300.0f) { + pthis->actor.speedXZ += 0.4f; + if (pthis->actor.speedXZ > 8.0f) { + pthis->actor.speedXZ = 8.0f; + } + } else { + pthis->actor.speedXZ -= 0.47f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ = 0.0f; + } + } + } + + if (pthis->actor.speedXZ >= 6.0f) { // hoof it + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.3f; + nextAnim = ENHORSE_ANIM_GALLOP; + } else if (pthis->actor.speedXZ >= 3.0f) { // trot + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.375f; + nextAnim = ENHORSE_ANIM_TROT; + } else if (pthis->actor.speedXZ > 0.1f) { // walk + pthis->skin.skelAnime.playSpeed = pthis->actor.speedXZ * 0.75f; + nextAnim = ENHORSE_ANIM_WALK; + EnHorse_PlayWalkingSound(pthis); + } else { // idle + nextAnim = Rand_ZeroOne() > 0.5f ? 1 : 0; + EnHorse_IdleAnimSounds(pthis, globalCtx); + pthis->skin.skelAnime.playSpeed = 1.0f; + } + + // Turn away from Link, or towards home + if (nextAnim == ENHORSE_ANIM_GALLOP || nextAnim == ENHORSE_ANIM_TROT || nextAnim == ENHORSE_ANIM_WALK) { + if (playerDistToHome < 300.0f) { + yaw = player->actor.shape.rot.y; + yaw += (Actor_WorldYawTowardActor(&pthis->actor, &player->actor) > 0 ? 1 : -1) * 0x3FFF; + } else { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos) - pthis->actor.world.rot.y; + } + + if (yaw > 400) { + pthis->actor.world.rot.y += 400; + } else if (yaw < -400) { + pthis->actor.world.rot.y -= 400; + } else { + pthis->actor.world.rot.y += yaw; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + animFinished = SkelAnime_Update(&pthis->skin.skelAnime); + + if (pthis->animationIdx == ENHORSE_ANIM_IDLE || pthis->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (nextAnim == ENHORSE_ANIM_GALLOP || nextAnim == ENHORSE_ANIM_TROT || nextAnim == ENHORSE_ANIM_WALK) { + pthis->animationIdx = nextAnim; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + -3.0f); + if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + EnHorse_PlayGallopingSound(pthis); + } else if (pthis->animationIdx == ENHORSE_ANIM_TROT) { + EnHorse_PlayTrottingSound(pthis); + } + return; + } + } + + if (animFinished) { + if (nextAnim == ENHORSE_ANIM_GALLOP) { + EnHorse_PlayGallopingSound(pthis); + } else if (nextAnim == ENHORSE_ANIM_TROT) { + EnHorse_PlayTrottingSound(pthis); + } + + if (pthis->animationIdx == ENHORSE_ANIM_IDLE || pthis->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (nextAnim != pthis->animationIdx) { + pthis->animationIdx = nextAnim; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), + ANIMMODE_ONCE, -3.0f); + return; + } else { + if (Rand_ZeroOne() > 0.5f) { + pthis->animationIdx = ENHORSE_ANIM_IDLE; + pthis->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + pthis->animationIdx = ENHORSE_ANIM_WHINNEY; + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), + ANIMMODE_ONCE, -3.0f); + return; + } + } + + if (nextAnim != pthis->animationIdx) { + pthis->animationIdx = nextAnim; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + return; + } + + if (pthis->animationIdx == ENHORSE_ANIM_WALK) { + if (nextAnim == ENHORSE_ANIM_IDLE || nextAnim == ENHORSE_ANIM_WHINNEY) { + pthis->animationIdx = nextAnim; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } + } +} + +void EnHorse_BridgeJumpInit(EnHorse* pthis, GlobalContext* globalCtx) { + f32 y; + + func_80028A54(globalCtx, 25.0f, &pthis->actor.world.pos); + pthis->action = ENHORSE_ACT_BRIDGE_JUMP; + pthis->stateFlags |= ENHORSE_JUMPING; + pthis->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + y = pthis->skin.skelAnime.jointTable->y; + y = y * 0.01f; + pthis->bridgeJumpStart = pthis->actor.world.pos; + pthis->bridgeJumpStart.y += y; + pthis->bridgeJumpYVel = + (((sBridgeJumps[pthis->bridgeJumpIdx].pos.y + 48.7f) - pthis->bridgeJumpStart.y) - -360.0f) / 30.0f; + pthis->riderPos.y -= y; + pthis->stateFlags |= ENHORSE_CALC_RIDER_POS; + pthis->bridgeJumpRelAngle = pthis->actor.world.rot.y - sBridgeJumps[pthis->bridgeJumpIdx].angle; + pthis->bridgeJumpTimer = 0; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 0; + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->type][pthis->animationIdx], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->type][pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_JUMP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + func_800AA000(0.0f, 170, 10, 10); + pthis->postDrawFunc = NULL; +} + +void EnHorse_StartBridgeJump(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->postDrawFunc = EnHorse_BridgeJumpInit; + if (pthis->bridgeJumpIdx == 0) { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGerudoValleyBridgeJumpFieldFortressCs); + gSaveContext.cutsceneTrigger = 1; + } else { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gGerudoValleyBridgeJumpFortressToFieldCs); + gSaveContext.cutsceneTrigger = 1; + } +} + +void EnHorse_BridgeJumpMove(EnHorse* pthis, GlobalContext* globalCtx) { + f32 interp; + f32 timeSq; + + interp = pthis->bridgeJumpTimer / 30.0f; + timeSq = (pthis->bridgeJumpTimer * pthis->bridgeJumpTimer); + + pthis->actor.world.pos.x = + ((sBridgeJumps[pthis->bridgeJumpIdx].pos.x - pthis->bridgeJumpStart.x) * interp) + pthis->bridgeJumpStart.x; + pthis->actor.world.pos.z = + ((sBridgeJumps[pthis->bridgeJumpIdx].pos.z - pthis->bridgeJumpStart.z) * interp) + pthis->bridgeJumpStart.z; + + pthis->actor.world.pos.y = + (pthis->bridgeJumpStart.y + (pthis->bridgeJumpYVel * pthis->bridgeJumpTimer) + (-0.4f * timeSq)); + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = + (sBridgeJumps[pthis->bridgeJumpIdx].angle + ((1.0f - interp) * pthis->bridgeJumpRelAngle)); + pthis->skin.skelAnime.curFrame = 23.0f * interp; + SkelAnime_Update(&pthis->skin.skelAnime); + if (pthis->bridgeJumpTimer < 30) { + pthis->stateFlags |= ENHORSE_FLAG_24; + } +} + +void EnHorse_CheckBridgeJumpLanding(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 8.0f; + pthis->skin.skelAnime.playSpeed = 1.5f; + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + pthis->stateFlags &= ~ENHORSE_JUMPING; + pthis->actor.gravity = -3.5f; + pthis->actor.world.pos.y = sBridgeJumps[pthis->bridgeJumpIdx].pos.y; + func_80028A54(globalCtx, 25.0f, &pthis->actor.world.pos); + EnHorse_JumpLanding(pthis, globalCtx); + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_800AA000(0.0f, 255, 10, 80); + } +} + +void EnHorse_BridgeJump(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->bridgeJumpTimer++; + if (pthis->bridgeJumpTimer < 30) { + EnHorse_BridgeJumpMove(pthis, globalCtx); + return; + } + EnHorse_CheckBridgeJumpLanding(pthis, globalCtx); +} + +void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) { + dst->x = src->x + Math_SinS(yaw) * dist; + dst->y = src->y + height; + dst->z = src->z + Math_CosS(yaw) * dist; +} + +s32 EnHorse_CalcFloorHeight(EnHorse* pthis, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** floorPoly, + f32* floorHeight) { + s32 bgId; + f32 waterY; + WaterBox* waterBox; + + *floorPoly = NULL; + *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, floorPoly, &bgId, pos); + + if (*floorHeight == BGCHECK_Y_MIN) { + return 1; // No floor + } + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pos->x, pos->z, &waterY, &waterBox) == 1 && + *floorHeight < waterY) { + return 2; // Water + } + + if ((*floorPoly)->normal.y * COLPOLY_NORMAL_FRAC < 0.81915206f || // cos(35 degrees) + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, *floorPoly, bgId) || + func_80041D4C(&globalCtx->colCtx, *floorPoly, bgId) == 7) { + return 3; // Horse blocked surface + } + return 0; +} + +/** + * obstacleType: + * 1: Water in front + * 2: Water behind? + * 3: ? + * 4: Obstructed in front + * 5: Obstructed behind + */ +void EnHorse_ObstructMovement(EnHorse* pthis, GlobalContext* globalCtx, s32 obstacleType, s32 galloping) { + if (pthis->action == ENHORSE_ACT_CS_UPDATE || EnHorse_BgCheckBridgeJumpPoint(pthis, globalCtx)) { + return; + } + + pthis->actor.world.pos = pthis->lastPos; + pthis->actor.shape.rot.y = pthis->lastYaw; + pthis->actor.world.rot.y = pthis->lastYaw; + pthis->stateFlags |= ENHORSE_OBSTACLE; + + if (!pthis->playerControlled) { + if (pthis->animationIdx != ENHORSE_ANIM_REARING) { + return; + } + } else if (pthis->action != ENHORSE_ACT_MOUNTED_REARING) { + if (pthis->stateFlags & ENHORSE_JUMPING) { + pthis->stateFlags &= ~ENHORSE_JUMPING; + pthis->actor.gravity = -3.5f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } + if (obstacleType == 1 || obstacleType == 4) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (obstacleType == 2 || obstacleType == 5) { + pthis->stateFlags |= ENHORSE_FORCE_WALKING; + } + if (galloping == true) { + EnHorse_StartRearing(pthis); + } + } +} + +void EnHorse_CheckFloors(EnHorse* pthis, GlobalContext* globalCtx) { + s32 status; + CollisionPoly* frontFloor; + CollisionPoly* backFloor; + s16 floorSlope; + Vec3f frontPos; + Vec3f backPos; + Vec3f pos; + f32 nx; + f32 ny; + f32 nz; + s32 galloping = pthis->actor.speedXZ > 8; + f32 dist; + f32 waterHeight; + WaterBox* waterBox; + s32 pad; + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, + &waterHeight, &waterBox) == 1 && + pthis->actor.floorHeight < waterHeight) { + EnHorse_ObstructMovement(pthis, globalCtx, 1, galloping); + return; + } + + EnHorse_Vec3fOffset(&pthis->actor.world.pos, pthis->actor.shape.rot.y, 30.0f, 60.0f, &frontPos); + status = EnHorse_CalcFloorHeight(pthis, globalCtx, &frontPos, &frontFloor, &pthis->yFront); + if (status == 1) { + pthis->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(pthis, globalCtx, 4, galloping); + return; + } + if (status == 2) { + EnHorse_ObstructMovement(pthis, globalCtx, 4, galloping); + return; + } + if (status == 3) { + EnHorse_ObstructMovement(pthis, globalCtx, 4, galloping); + return; + } + + EnHorse_Vec3fOffset(&pthis->actor.world.pos, pthis->actor.shape.rot.y, -30.0f, 60.0f, &backPos); + status = EnHorse_CalcFloorHeight(pthis, globalCtx, &backPos, &backFloor, &pthis->yBack); + if (status == 1) { + pthis->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(pthis, globalCtx, 5, galloping); + return; + } + if (status == 2) { + EnHorse_ObstructMovement(pthis, globalCtx, 5, galloping); + return; + } + if (status == 3) { + EnHorse_ObstructMovement(pthis, globalCtx, 5, galloping); + return; + } + + floorSlope = Math_FAtan2F(pthis->yBack - pthis->yFront, 60.0f) * (0x8000 / M_PI); + if (pthis->actor.floorPoly != 0) { + nx = pthis->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC; + ny = pthis->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC; + nz = pthis->actor.floorPoly->normal.z * COLPOLY_NORMAL_FRAC; + pos = frontPos; + pos.y = pthis->yFront; + dist = Math3D_DistPlaneToPos(nx, ny, nz, pthis->actor.floorPoly->dist, &pos); + if ((frontFloor != pthis->actor.floorPoly) && (pthis->actor.speedXZ >= 0.0f)) { + if ((!(pthis->stateFlags & ENHORSE_JUMPING) && dist < -40.0f) || + (pthis->stateFlags & ENHORSE_JUMPING && dist < -200.0f)) { + EnHorse_ObstructMovement(pthis, globalCtx, 4, galloping); + return; + } + } + + pos = backPos; + pos.y = pthis->yBack; + dist = Math3D_DistPlaneToPos(nx, ny, nz, pthis->actor.floorPoly->dist, &pos); + if (((backFloor != pthis->actor.floorPoly) && (pthis->actor.speedXZ <= 0.0f) && + !(pthis->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + (pthis->stateFlags & ENHORSE_JUMPING && dist < -200.0f)) { + EnHorse_ObstructMovement(pthis, globalCtx, 5, galloping); + return; + } + + if (ny < 0.81915206f || // cos(35 degrees) + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId) || + func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId) == 7) { + if ((pthis->actor.speedXZ >= 0.0f)) { + EnHorse_ObstructMovement(pthis, globalCtx, 4, galloping); + } else { + EnHorse_ObstructMovement(pthis, globalCtx, 5, galloping); + } + return; + } + + if (pthis->stateFlags & ENHORSE_JUMPING) { + pthis->actor.shape.rot.x = 0; + return; + } + + if (pthis->actor.floorHeight + 4.0f < pthis->actor.world.pos.y) { + pthis->actor.shape.rot.x = 0; + return; + } + + if (fabsf(floorSlope) > 8191.0f) { + return; + } + + pthis->actor.shape.rot.x = floorSlope; + pthis->actor.shape.yOffset = + (pthis->yFront + (((pthis->yBack - pthis->yFront) * 20.0f) / 45.0f)) - pthis->actor.floorHeight; + } +} + +s32 EnHorse_GetMountSide(EnHorse* pthis, GlobalContext* globalCtx); + +void EnHorse_MountDismount(EnHorse* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s32 mountSide; + Player* player = GET_PLAYER(globalCtx); + + mountSide = EnHorse_GetMountSide(pthis, globalCtx); + if (mountSide != 0 && !(pthis->stateFlags & ENHORSE_UNRIDEABLE) && player->rideActor == NULL) { + Actor_SetRideActor(globalCtx, &pthis->actor, mountSide); + } + + if (pthis->playerControlled == false && Actor_IsMounted(globalCtx, &pthis->actor) == true) { + pthis->noInputTimer = 55; + pthis->noInputTimerMax = 55; + pthis->playerControlled = 1; + EnHorse_Freeze(pthis); + } else if (pthis->playerControlled == true && Actor_NotMounted(globalCtx, &pthis->actor) == true) { + pthis->noInputTimer = 35; + pthis->noInputTimerMax = 35; + pthis->stateFlags &= ~ENHORSE_UNRIDEABLE; + pthis->playerControlled = 0; + EnHorse_Freeze(pthis); + } +} + +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { + f32 dist; + f32 y; + f32 x; + + x = curStick->x; + y = curStick->y; + dist = sqrtf(SQ(x) + SQ(y)); + + *stickMag = dist; + if (dist > 60.0f) { + *stickMag = 60.0f; + } else { + *stickMag = *stickMag; + } + + *angle = Math_FAtan2F(-curStick->x, curStick->y) * (32768.0f / M_PI); +} + +void EnHorse_UpdateStick(EnHorse* pthis, GlobalContext* globalCtx) { + pthis->lastStick = pthis->curStick; + pthis->curStick.x = globalCtx->state.input[0].rel.stick_x; + pthis->curStick.y = globalCtx->state.input[0].rel.stick_y; +} + +void EnHorse_ResolveCollision(EnHorse* pthis, GlobalContext* globalCtx, CollisionPoly* colPoly) { + f32 dist; + f32 nx; + f32 ny; + f32 nz; + f32 offset; + + nx = COLPOLY_GET_NORMAL(colPoly->normal.x); + ny = COLPOLY_GET_NORMAL(colPoly->normal.y); + nz = COLPOLY_GET_NORMAL(colPoly->normal.z); + if (!(Math_CosS(pthis->actor.world.rot.y - + (s16)(Math_FAtan2F(colPoly->normal.x, colPoly->normal.z) * (0x8000 / M_PI)) - 0x7FFF) < + 0.7071f)) { // cos(45 degrees) + dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &pthis->actor.world.pos); + offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); + offset = (30.0f - dist) * offset; + pthis->actor.world.pos.x += offset * nx; + pthis->actor.world.pos.z += offset * nz; + } +} + +void EnHorse_BgCheckSlowMoving(EnHorse* pthis, GlobalContext* globalCtx) { + f32 yOffset; + Vec3f start; + Vec3f end; + Vec3f intersect; + CollisionPoly* colPoly; + s32 bgId; + + if (globalCtx->sceneNum == SCENE_SPOT20) { + yOffset = 19.0f; + } else { + yOffset = 40.0f; + } + Math_Vec3f_Copy(&start, &pthis->actor.world.pos); + start.y = start.y + yOffset; + + Math_Vec3f_Copy(&end, &start); + end.x += 30.0f * Math_SinS(pthis->actor.world.rot.y); + end.y += 30.0f * Math_SinS(-pthis->actor.shape.rot.x); + end.z += 30.0f * Math_CosS(pthis->actor.world.rot.y); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &start, &end, &intersect, &colPoly, 1, 0, 0, 1, &bgId) != 0) { + EnHorse_ResolveCollision(pthis, globalCtx, colPoly); + } +} + +void EnHorse_HighJumpInit(EnHorse* pthis, GlobalContext* globalCtx); +void EnHorse_Stub2(EnHorse* pthis); +void EnHorse_Stub1(EnHorse* pthis); + +void EnHorse_UpdateBgCheckInfo(EnHorse* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + Vec3f startPos; + Vec3f endPos; + Vec3f obstaclePos; + f32 pad3; + f32 intersectDist; + CollisionPoly* wall = NULL; + CollisionPoly* obstacleFloor = NULL; + s32 bgId; + f32 obstacleHeight; + f32 behindObstacleHeight; + f32 ny; + s32 movingFast; + s32 pad5; + DynaPolyActor* dynaPoly; + Vec3f intersect; + Vec3f obstacleTop; + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, globalCtx->sceneNum == SCENE_SPOT20 ? 19.0f : 40.0f, 35.0f, 100.0f, + 29); + + if (EnHorse_BgCheckBridgeJumpPoint(pthis, globalCtx)) { + return; + } + + // void 0 trick required to match, but is surely not real. revisit at a later time + if (pthis->actor.bgCheckFlags & 8 && Math_CosS(pthis->actor.wallYaw - ((void)0, pthis->actor.world).rot.y) < -0.3f) { + if (pthis->actor.speedXZ > 4.0f) { + pthis->actor.speedXZ -= 1.0f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + + if (pthis->stateFlags & ENHORSE_JUMPING || !pthis->playerControlled) { + return; + } + + if (pthis->actor.speedXZ < 0.0f) { + return; + } + + // Braking or rearing from obstacle + if (pthis->action == ENHORSE_ACT_STOPPING || pthis->action == ENHORSE_ACT_MOUNTED_REARING) { + return; + } + + if (pthis->actor.speedXZ > 8.0f) { + if (pthis->actor.speedXZ < 12.8f) { + intersectDist = 160.0f; + movingFast = 0; + } else { + intersectDist = 230.0f; + movingFast = 1; + } + } else { + EnHorse_BgCheckSlowMoving(pthis, globalCtx); + return; + } + + startPos = pthis->actor.world.pos; + startPos.y += 19.0f; + endPos = startPos; + endPos.x += (intersectDist * Math_SinS(pthis->actor.world.rot.y)); + endPos.y += (intersectDist * Math_SinS(-pthis->actor.shape.rot.x)); + endPos.z += (intersectDist * Math_CosS(pthis->actor.world.rot.y)); + intersect = endPos; + wall = NULL; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, 1, 0, 0, 1, &bgId) == 1) { + intersectDist = sqrt(Math3D_Vec3fDistSq(&startPos, &intersect)); + pthis->stateFlags |= ENHORSE_OBSTACLE; + } + + if (wall != NULL) { + if (intersectDist < 30.0f) { + EnHorse_ResolveCollision(pthis, globalCtx, wall); + } + if ((Math_CosS(pthis->actor.world.rot.y - (s16)(Math_FAtan2F(wall->normal.x, wall->normal.z) * (0x8000 / M_PI)) - + 0x7FFF) < 0.5f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId) != 0) { + return; + } + + // too close to jump + if ((movingFast == false && intersectDist < 80.0f) || (movingFast == true && intersectDist < 150.0f)) { + if (movingFast == false) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(pthis, globalCtx); + } + return; + } + + dynaPoly = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((pthis->stateFlags & ENHORSE_FLAG_26) && ((dynaPoly && dynaPoly->actor.id != 0x108) || dynaPoly == 0)) { + if (movingFast == false) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(pthis, globalCtx); + } + return; + } + } + + // Get obstacle's height + intersectDist += 5.0f; + obstaclePos = startPos; + obstaclePos.x += intersectDist * Math_SinS(pthis->actor.world.rot.y); + obstaclePos.y = pthis->actor.world.pos.y + 120.0f; + obstaclePos.z += intersectDist * Math_CosS(pthis->actor.world.rot.y); + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + obstacleHeight = obstacleTop.y - pthis->actor.world.pos.y; + if (pthis->actor.floorPoly == NULL || obstacleFloor == NULL) { + return; + } + + if (Math3D_DistPlaneToPos(pthis->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC, + pthis->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC, + pthis->actor.floorPoly->normal.z * COLPOLY_NORMAL_FRAC, pthis->actor.floorPoly->dist, + &obstacleTop) < -40.0f && + Math3D_DistPlaneToPos( + obstacleFloor->normal.x * COLPOLY_NORMAL_FRAC, obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC, + obstacleFloor->normal.z * COLPOLY_NORMAL_FRAC, obstacleFloor->dist, &pthis->actor.world.pos) > 40.0f) { + if (movingFast == true && pthis->action != ENHORSE_ACT_STOPPING) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(pthis, globalCtx); + } + pthis->stateFlags |= ENHORSE_OBSTACLE; + return; + } + + ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; + if (ny < 0.81915206f || // cos(35 degrees) + (SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) != 0) || + (func_80041D4C(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if (movingFast == true && pthis->action != ENHORSE_ACT_STOPPING) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(pthis, globalCtx); + } + return; + } + + if (wall == NULL || obstacleTop.y < intersect.y || (pthis->stateFlags & ENHORSE_CANT_JUMP)) { + return; + } + + obstaclePos = startPos; + obstaclePos.y = pthis->actor.world.pos.y + 120.0f; + if (movingFast == false) { + obstaclePos.x += (276.0f * Math_SinS(pthis->actor.world.rot.y)); + obstaclePos.z += (276.0f * Math_CosS(pthis->actor.world.rot.y)); + } else { + obstaclePos.x += (390.0f * Math_SinS(pthis->actor.world.rot.y)); + obstaclePos.z += (390.0f * Math_CosS(pthis->actor.world.rot.y)); + } + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + behindObstacleHeight = obstacleTop.y - pthis->actor.world.pos.y; + + if (obstacleFloor == NULL) { + return; + } + + ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; + if (ny < 0.81915206f || // cos(35 degrees) + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + func_80041D4C(&globalCtx->colCtx, obstacleFloor, bgId) == 7) { + if (movingFast == true && pthis->action != ENHORSE_ACT_STOPPING) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(pthis, globalCtx); + } + } else if (behindObstacleHeight < -DREG(4)) { // -70 + if (movingFast == true && pthis->action != ENHORSE_ACT_STOPPING) { + pthis->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(pthis, globalCtx); + } + } else if (movingFast == false && obstacleHeight > 19.0f && obstacleHeight <= 40.0f) { + EnHorse_Stub1(pthis); + pthis->postDrawFunc = EnHorse_LowJumpInit; + } else if ((movingFast == true && pthis->actor.speedXZ < 13.8f && obstacleHeight > 19.0f && + obstacleHeight <= 72.0f) || + (pthis->actor.speedXZ > 13.8f && obstacleHeight <= 112.0f)) { + + EnHorse_Stub2(pthis); + pthis->postDrawFunc = EnHorse_HighJumpInit; + } +} + +void EnHorse_CheckBoost(EnHorse* thisx, GlobalContext* globalCtx2) { + EnHorse* pthis = (EnHorse*)thisx; + GlobalContext* globalCtx = globalCtx2; + s32 pad; + + if (pthis->action == ENHORSE_ACT_MOUNTED_WALK || pthis->action == ENHORSE_ACT_MOUNTED_TROT || + pthis->action == ENHORSE_ACT_MOUNTED_GALLOP) { + if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) && (globalCtx->interfaceCtx.unk_1EE == 8)) { + if (!(pthis->stateFlags & ENHORSE_BOOST) && !(pthis->stateFlags & ENHORSE_FLAG_8) && + !(pthis->stateFlags & ENHORSE_FLAG_9)) { + if (pthis->numBoosts > 0) { + func_800AA000(0.0f, 180, 20, 100); + pthis->stateFlags |= ENHORSE_BOOST; + pthis->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; + pthis->stateFlags |= ENHORSE_FLAG_8; + pthis->numBoosts--; + pthis->boostTimer = 0; + if (pthis->numBoosts == 0) { + pthis->boostRegenTime = 140; + return; + } + if (pthis->type == HORSE_EPONA) { + if (pthis->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { + pthis->boostRegenTime = 60; + pthis->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; + } else { + pthis->boostRegenTime = 8; // Never happens + } + } else { + pthis->boostRegenTime = 70; + } + return; + } + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + if (Rand_ZeroOne() < 0.1f) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + } + } + } +} + +void EnHorse_RegenBoost(EnHorse* pthis, GlobalContext* globalCtx) { + if (pthis->numBoosts < 6 && pthis->numBoosts > 0) { + pthis->boostRegenTime--; + pthis->boostTimer++; + + if (pthis->boostRegenTime <= 0) { + pthis->numBoosts = pthis->numBoosts + 1; + + if (!EN_HORSE_CHECK_4(pthis)) { + Audio_PlaySoundGeneral(NA_SE_SY_CARROT_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + if (pthis->numBoosts < 6) { + pthis->boostRegenTime = 11; + } + } + } else if (pthis->numBoosts == 0) { + pthis->boostRegenTime--; + pthis->boostTimer++; + + if (pthis->boostRegenTime <= 0) { + pthis->boostRegenTime = 0; + pthis->numBoosts = 6; + + if (!EN_HORSE_CHECK_4(pthis)) { + Audio_PlaySoundGeneral(NA_SE_SY_CARROT_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + } + + if (pthis->boostTimer == 8 && Rand_ZeroOne() < 0.25f) { + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + globalCtx->interfaceCtx.numHorseBoosts = pthis->numBoosts; +} + +void EnHorse_UpdatePlayerDir(EnHorse* pthis, GlobalContext* globalCtx) { + EnHorse* pad; + s16 angle; + f32 s; + f32 c; + + angle = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.world.rot.y; + s = Math_SinS(angle); + c = Math_CosS(angle); + if (s > 0.8660254f) { // sin(60 degrees) + pthis->playerDir = PLAYER_DIR_SIDE_L; + } else if (s < -0.8660254f) { // -sin(60 degrees) + pthis->playerDir = PLAYER_DIR_SIDE_R; + } else { + if (c > 0.0f) { + if (s > 0) { + pthis->playerDir = PLAYER_DIR_FRONT_L; + } else { + pthis->playerDir = PLAYER_DIR_FRONT_R; + } + } else { + if (s > 0) { + pthis->playerDir = PLAYER_DIR_BACK_L; + } else { + pthis->playerDir = PLAYER_DIR_BACK_R; + } + } + } +} + +void EnHorse_TiltBody(EnHorse* pthis, GlobalContext* globalCtx) { + f32 speed; + f32 rollDiff; + s32 targetRoll; + s16 turnVel; + + speed = pthis->actor.speedXZ / pthis->boostSpeed; + turnVel = pthis->actor.shape.rot.y - pthis->lastYaw; + targetRoll = -((s16)((1820.0f * speed) * (turnVel / 480.00003f))); + rollDiff = targetRoll - pthis->actor.world.rot.z; + + if (fabsf(targetRoll) < 100.0f) { + pthis->actor.world.rot.z = 0; + } else if (fabsf(rollDiff) < 100.0f) { + pthis->actor.world.rot.z = targetRoll; + } else if (rollDiff > 0.0f) { + pthis->actor.world.rot.z += 100; + } else { + pthis->actor.world.rot.z -= 100; + } + + pthis->actor.shape.rot.z = pthis->actor.world.rot.z; +} + +s32 EnHorse_UpdateConveyors(EnHorse* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 conveyorDir; + + if ((pthis->actor.floorPoly == NULL) && (pthis != (EnHorse*)player->rideActor)) { + return 0; + } + conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + conveyorDir = (conveyorDir << 10) - pthis->actor.world.rot.y; + if (conveyorDir > 800.0f) { + pthis->actor.world.rot.y += 800.0f; + } else if (conveyorDir < -800.0f) { + pthis->actor.world.rot.y -= 800.0f; + } else { + pthis->actor.world.rot.y += conveyorDir; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + return 1; +} + +s32 EnHorse_RandInt(f32 range) { + return Rand_ZeroOne() * range; +} + +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnHorse* pthis = (EnHorse*)thisx; + GlobalContext* globalCtx = globalCtx2; + Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; + Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; + Player* player = GET_PLAYER(globalCtx); + + pthis->lastYaw = thisx->shape.rot.y; + EnHorse_UpdateStick(pthis, globalCtx); + EnHorse_UpdatePlayerDir(pthis, globalCtx); + + if (!(pthis->stateFlags & ENHORSE_INACTIVE)) { + EnHorse_MountDismount(pthis, globalCtx); + } + + if (pthis->stateFlags & ENHORSE_FLAG_19) { + if (pthis->stateFlags & ENHORSE_FLAG_20 && pthis->inRace == true) { + pthis->stateFlags &= ~ENHORSE_FLAG_20; + EnHorse_StartRearing(pthis); + } else if (!(pthis->stateFlags & ENHORSE_FLAG_20) && pthis->stateFlags & ENHORSE_FLAG_21 && + pthis->action != ENHORSE_ACT_MOUNTED_REARING && pthis->inRace == true) { + pthis->stateFlags &= ~ENHORSE_FLAG_21; + EnHorse_StartRearing(pthis); + } + } + + sActionFuncs[pthis->action](pthis, globalCtx); + pthis->stateFlags &= ~ENHORSE_OBSTACLE; + pthis->curFrame = pthis->skin.skelAnime.curFrame; + pthis->lastPos = thisx->world.pos; + if (!(pthis->stateFlags & ENHORSE_INACTIVE)) { + if (pthis->action == ENHORSE_ACT_MOUNTED_GALLOP || pthis->action == ENHORSE_ACT_MOUNTED_TROT || + pthis->action == ENHORSE_ACT_MOUNTED_WALK) { + EnHorse_CheckBoost(pthis, globalCtx); + } + if (pthis->playerControlled == true) { + EnHorse_RegenBoost(pthis, globalCtx); + } + Actor_MoveForward(thisx); + if (pthis->action == ENHORSE_ACT_INGO_RACE) { + if (pthis->rider != NULL) { + pthis->rider->world.pos.x = thisx->world.pos.x; + pthis->rider->world.pos.y = thisx->world.pos.y + 10.0f; + pthis->rider->world.pos.z = thisx->world.pos.z; + pthis->rider->shape.rot.x = thisx->shape.rot.x; + pthis->rider->shape.rot.y = thisx->shape.rot.y; + } + } + if (pthis->jntSph.elements[0].info.ocElemFlags & 2) { + if (thisx->speedXZ > 6.0f) { + thisx->speedXZ -= 1.0f; + } + } + if (pthis->jntSph.base.acFlags & 2) { + pthis->unk_21C = pthis->unk_228; + if (pthis->stateFlags & ENHORSE_DRAW) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_21C, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + if (pthis->action != ENHORSE_ACT_INGO_RACE) { + EnHorse_TiltBody(pthis, globalCtx); + } + Collider_UpdateCylinder(thisx, &pthis->cyl1); + Collider_UpdateCylinder(thisx, &pthis->cyl2); + + // Required to match + pthis->cyl1.dim.pos.x = pthis->cyl1.dim.pos.x + (s16)(Math_SinS(thisx->shape.rot.y) * 11.0f); + pthis->cyl1.dim.pos.z = pthis->cyl1.dim.pos.z + (s16)(Math_CosS(thisx->shape.rot.y) * 11.0f); + pthis->cyl2.dim.pos.x = pthis->cyl2.dim.pos.x + (s16)(Math_SinS(thisx->shape.rot.y) * -18.0f); + pthis->cyl2.dim.pos.z = pthis->cyl2.dim.pos.z + (s16)(Math_CosS(thisx->shape.rot.y) * -18.0f); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->cyl1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cyl1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cyl2.base); + if ((player->stateFlags1 & 1) && player->rideActor != NULL) { + if (globalCtx->sceneNum != SCENE_SPOT20 || + (globalCtx->sceneNum == SCENE_SPOT20 && (thisx->world.pos.z < -2400.0f))) { + EnHorse_UpdateConveyors(pthis, globalCtx); + } + } + if (!(pthis->stateFlags & ENHORSE_FLAG_24)) { + EnHorse_UpdateBgCheckInfo(pthis, globalCtx); + EnHorse_CheckFloors(pthis, globalCtx); + if (thisx->world.pos.y < pthis->yFront && thisx->world.pos.y < pthis->yBack) { + if (pthis->yBack < pthis->yFront) { + thisx->world.pos.y = pthis->yBack; + } else { + thisx->world.pos.y = pthis->yFront; + } + } + + } else { + pthis->stateFlags &= ~ENHORSE_FLAG_24; + } + + if (globalCtx->sceneNum == SCENE_SPOT09 && (gSaveContext.eventChkInf[9] & 0xF) != 0xF) { + EnHorse_CheckBridgeJumps(pthis, globalCtx); + } + + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 70.0f; + if ((Rand_ZeroOne() < 0.025f) && pthis->blinkTimer == 0) { + pthis->blinkTimer++; + } else if (pthis->blinkTimer > 0) { + pthis->blinkTimer++; + if (pthis->blinkTimer >= 4) { + pthis->blinkTimer = 0; + } + } + + if (thisx->speedXZ == 0.0f && !(pthis->stateFlags & ENHORSE_FLAG_19)) { + thisx->colChkInfo.mass = 0xFF; + } else { + thisx->colChkInfo.mass = 0xFE; + } + + if (thisx->speedXZ >= 5.0f) { + pthis->cyl1.base.atFlags |= 1; + } else { + pthis->cyl1.base.atFlags &= ~1; + } + + if (gSaveContext.entranceIndex != 343 || gSaveContext.sceneSetupIndex != 9) { + if (pthis->dustFlags & 1) { + pthis->dustFlags &= ~1; + func_800287AC(globalCtx, &pthis->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, + EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); + } else if (pthis->dustFlags & 2) { + pthis->dustFlags &= ~2; + func_800287AC(globalCtx, &pthis->frontLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, + EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); + } else if (pthis->dustFlags & 4) { + pthis->dustFlags &= ~4; + func_800287AC(globalCtx, &pthis->backRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, + EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); + } else if (pthis->dustFlags & 8) { + pthis->dustFlags &= ~8; + func_800287AC(globalCtx, &pthis->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100) + 200, + EnHorse_RandInt(10) + 30, EnHorse_RandInt(20) + 30); + } + } + pthis->stateFlags &= ~ENHORSE_DRAW; + } +} + +s32 EnHorse_PlayerDirToMountSide(EnHorse* pthis, GlobalContext* globalCtx, Player* player) { + if (pthis->playerDir == PLAYER_DIR_SIDE_L) { + return -1; + } + if (pthis->playerDir == PLAYER_DIR_SIDE_R) { + return 1; + } + return 0; +} + +s32 EnHorse_MountSideCheck(EnHorse* pthis, GlobalContext* globalCtx, Player* player) { + s32 mountSide; + + if (Actor_WorldDistXZToActor(&pthis->actor, &player->actor) > 75.0f) { + return 0; + } else if (fabsf(pthis->actor.world.pos.y - player->actor.world.pos.y) > 30.0f) { + return 0; + } else if (Math_CosS(Actor_WorldYawTowardActor(&player->actor, &pthis->actor) - player->actor.world.rot.y) < + 0.17364818f) { // cos(80 degrees) + return 0; + } else { + mountSide = EnHorse_PlayerDirToMountSide(pthis, globalCtx, player); + if (mountSide == -1) { + return -1; + } + if (mountSide == 1) { + return 1; + } + } + return 0; +} + +s32 EnHorse_GetMountSide(EnHorse* pthis, GlobalContext* globalCtx) { + if (pthis->action != ENHORSE_ACT_IDLE) { + return 0; + } + if ((pthis->animationIdx != ENHORSE_ANIM_IDLE) && (pthis->animationIdx != ENHORSE_ANIM_WHINNEY)) { + return 0; + } + return EnHorse_MountSideCheck(pthis, globalCtx, GET_PLAYER(globalCtx)); +} + +void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { + dst->x = (Rand_ZeroOne() * (dist * 2.0f) + src->x) - dist; + dst->y = (Rand_ZeroOne() * (dist * 2.0f) + src->y) - dist; + dst->z = (Rand_ZeroOne() * (dist * 2.0f) + src->z) - dist; +} + +void EnHorse_SkinCallback1(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { + EnHorse* pthis = (EnHorse*)thisx; + s32 pad; + Vec3f sp94 = { 0.0f, 0.0f, 0.0f }; + Vec3f hoofOffset = { 5.0f, -4.0f, 5.0f }; + Vec3f riderOffset = { 600.0f, -1670.0f, 0.0f }; + Vec3f sp70; + Vec3f sp64 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp58 = { 0.0f, -1.0f, 0.0f }; + + f32 frame = pthis->skin.skelAnime.curFrame; + Vec3f center; + Vec3f newCenter; + s32 i; + Vec3f sp2C; + f32 sp28; + + if (!(pthis->stateFlags & ENHORSE_CALC_RIDER_POS)) { + func_800A6408(skin, 30, &riderOffset, &pthis->riderPos); + pthis->riderPos.x = pthis->riderPos.x - pthis->actor.world.pos.x; + pthis->riderPos.y = pthis->riderPos.y - pthis->actor.world.pos.y; + pthis->riderPos.z = pthis->riderPos.z - pthis->actor.world.pos.z; + } else { + pthis->stateFlags &= ~ENHORSE_CALC_RIDER_POS; + } + + func_800A6408(skin, 13, &sp94, &sp2C); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp2C, &pthis->unk_228, &sp28); + if ((pthis->animationIdx == ENHORSE_ANIM_IDLE && pthis->action != ENHORSE_ACT_FROZEN) && + ((frame > 40.0f && frame < 45.0f && pthis->type == HORSE_EPONA) || + (frame > 28.0f && frame < 33.0f && pthis->type == HORSE_HNI))) { + if (Rand_ZeroOne() < 0.6f) { + pthis->dustFlags |= 1; + func_800A6408(skin, 28, &hoofOffset, &pthis->frontRightHoof); + pthis->frontRightHoof.y = pthis->frontRightHoof.y - 5.0f; + } + } else { + if (pthis->action == ENHORSE_ACT_STOPPING) { + if ((frame > 10.0f && frame < 13.0f) || (frame > 25.0f && frame < 33.0f)) { + if (Rand_ZeroOne() < 0.7f) { + pthis->dustFlags |= 2; + func_800A6408(skin, 20, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->frontLeftHoof); + } + if (Rand_ZeroOne() < 0.7f) { + pthis->dustFlags |= 1; + func_800A6408(skin, 28, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->frontRightHoof); + } + } + + if ((frame > 6.0f && frame < 10.0f) || (frame > 23.0f && frame < 29.0f)) { + if (Rand_ZeroOne() < 0.7f) { + pthis->dustFlags |= 8; + func_800A6408(skin, 37, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backLeftHoof); + } + } + + if ((frame > 7.0f && frame < 14.0f) || (frame > 26.0f && frame < 30.0f)) { + if (Rand_ZeroOne() < 0.7f) { + pthis->dustFlags |= 4; + func_800A6408(skin, 45, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backRightHoof); + } + } + } else if (pthis->animationIdx == ENHORSE_ANIM_GALLOP) { + if ((frame > 14.0f) && (frame < 16.0f)) { + pthis->dustFlags |= 1; + func_800A6408(skin, 28, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 5.0f, &pthis->frontRightHoof); + } else if (frame > 8.0f && frame < 10.0f) { + pthis->dustFlags |= 2; + func_800A6408(skin, 20, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->frontLeftHoof); + } else if (frame > 1.0f && frame < 3.0f) { + pthis->dustFlags |= 4; + func_800A6408(skin, 45, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backRightHoof); + } else if ((frame > 26.0f) && (frame < 28.0f)) { + pthis->dustFlags |= 8; + func_800A6408(skin, 37, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backLeftHoof); + } + } else if (pthis->action == ENHORSE_ACT_LOW_JUMP && frame > 6.0f && + Rand_ZeroOne() < 1.0f - (frame - 6.0f) * (1.0f / 17.0f)) { + if (Rand_ZeroOne() < 0.5f) { + pthis->dustFlags |= 8; + func_800A6408(skin, 37, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backLeftHoof); + } + if (Rand_ZeroOne() < 0.5f) { + pthis->dustFlags |= 4; + func_800A6408(skin, 45, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backRightHoof); + } + } else if (pthis->action == ENHORSE_ACT_HIGH_JUMP && frame > 5.0f && + Rand_ZeroOne() < 1.0f - (frame - 5.0f) * (1.0f / 25.0f)) { + if (Rand_ZeroOne() < 0.5f) { + pthis->dustFlags |= 8; + func_800A6408(skin, 37, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backLeftHoof); + } + if (Rand_ZeroOne() < 0.5f) { + pthis->dustFlags |= 4; + func_800A6408(skin, 45, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backRightHoof); + } + } else if (pthis->action == ENHORSE_ACT_BRIDGE_JUMP && Rand_ZeroOne() < 0.5f) { + if (Rand_ZeroOne() < 0.5f) { + pthis->dustFlags |= 8; + func_800A6408(skin, 37, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backLeftHoof); + } else { + pthis->dustFlags |= 4; + func_800A6408(skin, 45, &hoofOffset, &sp70); + EnHorse_RandomOffset(&sp70, 10.0f, &pthis->backRightHoof); + } + } + } + + for (i = 0; i < pthis->jntSph.count; i++) { + center.x = pthis->jntSph.elements[i].dim.modelSphere.center.x; + center.y = pthis->jntSph.elements[i].dim.modelSphere.center.y; + center.z = pthis->jntSph.elements[i].dim.modelSphere.center.z; + + func_800A6408(skin, pthis->jntSph.elements[i].dim.limb, ¢er, &newCenter); + pthis->jntSph.elements[i].dim.worldSphere.center.x = newCenter.x; + pthis->jntSph.elements[i].dim.worldSphere.center.y = newCenter.y; + pthis->jntSph.elements[i].dim.worldSphere.center.z = newCenter.z; + pthis->jntSph.elements[i].dim.worldSphere.radius = + pthis->jntSph.elements[i].dim.modelSphere.radius * pthis->jntSph.elements[i].dim.scale; + } + + //! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists + //! under certain conditions, like when pausing and unpausing the game. + //! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur. + //! In the case of OC, pthis can cause unwanted effects such as a very large amount of displacement being applied to + //! a colliding actor. + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->jntSph.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->jntSph.base); +} + +// unused +static s32 D_80A667DC[] = { 0, 3, 7, 14 }; + +s32 EnHorse_SkinCallback2(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, PSkinAwb* arg3) { + static void* eyeTextures[] = { + gEponaEyeOpenTex, + gEponaEyeHalfTex, + gEponaEyeClosedTex, + }; + static u8 eyeBlinkIndexes[] = { 0, 1, 2, 1 }; + EnHorse* pthis = (EnHorse*)thisx; + s32 drawOriginalLimb = true; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse.c", 8582); + if (limbIndex == 13 && pthis->type == HORSE_EPONA) { + u8 index = eyeBlinkIndexes[pthis->blinkTimer]; + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[index])); + } else if (pthis->type == HORSE_HNI && pthis->stateFlags & ENHORSE_FLAG_18 && limbIndex == 30) { + func_800A5F60(globalCtx->state.gfxCtx, &pthis->skin, limbIndex, gHorseIngoGerudoSaddleDL, 0); + drawOriginalLimb = false; + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_horse.c", 8601); + return drawOriginalLimb; +} + +void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* pthis = (EnHorse*)thisx; + + if (!(pthis->stateFlags & ENHORSE_INACTIVE)) { + func_80093D18(globalCtx->state.gfxCtx); + pthis->stateFlags |= ENHORSE_DRAW; + if (pthis->stateFlags & ENHORSE_JUMPING) { + func_800A6360(thisx, globalCtx, &pthis->skin, EnHorse_SkinCallback1, EnHorse_SkinCallback2, 0); + } else { + func_800A6360(thisx, globalCtx, &pthis->skin, EnHorse_SkinCallback1, EnHorse_SkinCallback2, 1); + } + if (pthis->postDrawFunc != NULL) { + pthis->postDrawFunc(pthis, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.cpp similarity index 61% rename from src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c rename to src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.cpp index b5b9c96ea..a568feafa 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.cpp @@ -60,7 +60,7 @@ void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Horse_Game_Check_InitVars = { +ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, ACTORCAT_BG, FLAGS, @@ -91,25 +91,25 @@ static Vec3f sFencePos[] = { }; s32 EnHorseGameCheck_InitIngoRace(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheckIngoRace* this = (EnHorseGameCheckIngoRace*)base; + EnHorseGameCheckIngoRace* pthis = (EnHorseGameCheckIngoRace*)base; s32 i; - this->base.type = HORSEGAME_INGO_RACE; - this->startFlags = 0; + pthis->base.type = HORSEGAME_INGO_RACE; + pthis->startFlags = 0; for (i = 0; i < 3; i++) { - this->playerCheck[i] = 0; + pthis->playerCheck[i] = 0; } - this->ingoHorse = + pthis->ingoHorse = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -250.0f, 1.0f, -1650.0f, 0, 0x4000, 0, 0x8003); - if (this->ingoHorse == NULL) { + if (pthis->ingoHorse == NULL) { LogUtils_HungupThread("../z_en_horse_game_check.c", 385); } - this->startTimer = 0; - this->finishTimer = 0; - this->result = INGORACE_NO_RESULT; - this->playerFinish = 0; - this->ingoFinish = 0; + pthis->startTimer = 0; + pthis->finishTimer = 0; + pthis->result = INGORACE_NO_RESULT; + pthis->playerFinish = 0; + pthis->ingoFinish = 0; return true; } @@ -118,9 +118,9 @@ s32 EnHorseGameCheck_DestroyIngoRace(EnHorseGameCheckBase* base, GlobalContext* return true; } -void EnHorseGameCheck_FinishIngoRace(EnHorseGameCheckIngoRace* this, GlobalContext* globalCtx) { +void EnHorseGameCheck_FinishIngoRace(EnHorseGameCheckIngoRace* pthis, GlobalContext* globalCtx) { gSaveContext.cutsceneIndex = 0; - if (this->result == INGORACE_PLAYER_WIN) { + if (pthis->result == INGORACE_PLAYER_WIN) { globalCtx->nextEntranceIndex = 0x4CE; if (gSaveContext.eventInf[0] & 0x40) { gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0xF) | 6; @@ -145,103 +145,103 @@ void EnHorseGameCheck_FinishIngoRace(EnHorseGameCheckIngoRace* this, GlobalConte } s32 EnHorseGameCheck_UpdateIngoRace(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheckIngoRace* this = (EnHorseGameCheckIngoRace*)base; + EnHorseGameCheckIngoRace* pthis = (EnHorseGameCheckIngoRace*)base; Player* player = GET_PLAYER(globalCtx); s32 i; EnHorse* ingoHorse; EnHorse* horse; - if ((this->startTimer > 50) && !(this->startFlags & INGORACE_SET_TIMER)) { - this->startFlags |= INGORACE_SET_TIMER; + if ((pthis->startTimer > 50) && !(pthis->startFlags & INGORACE_SET_TIMER)) { + pthis->startFlags |= INGORACE_SET_TIMER; func_80088B34(0); - } else if ((this->startTimer > 80) && (player->rideActor != NULL) && !(this->startFlags & INGORACE_PLAYER_MOVE)) { - this->startFlags |= INGORACE_PLAYER_MOVE; + } else if ((pthis->startTimer > 80) && (player->rideActor != NULL) && !(pthis->startFlags & INGORACE_PLAYER_MOVE)) { + pthis->startFlags |= INGORACE_PLAYER_MOVE; horse = (EnHorse*)player->rideActor; horse->inRace = 1; - } else if ((this->startTimer > 81) && !(this->startFlags & INGORACE_INGO_MOVE)) { - ingoHorse = (EnHorse*)this->ingoHorse; + } else if ((pthis->startTimer > 81) && !(pthis->startFlags & INGORACE_INGO_MOVE)) { + ingoHorse = (EnHorse*)pthis->ingoHorse; ingoHorse->inRace = 1; - this->startFlags |= INGORACE_INGO_MOVE; + pthis->startFlags |= INGORACE_INGO_MOVE; Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - this->startTimer++; + pthis->startTimer++; for (i = 0; i < 3; i++) { if ((player->rideActor != NULL) && (Math3D_Vec3f_DistXYZ(&sIngoRaceCheckpoints[i], &player->rideActor->world.pos) < 400.0f)) { - if ((i > 0) && (this->playerCheck[i - 1] == 1)) { - this->playerCheck[i] = 1; + if ((i > 0) && (pthis->playerCheck[i - 1] == 1)) { + pthis->playerCheck[i] = 1; } else if (i == 0) { - this->playerCheck[i] = 1; + pthis->playerCheck[i] = 1; } } - if (Math3D_Vec3f_DistXYZ(&sIngoRaceCheckpoints[i], &this->ingoHorse->world.pos) < 400.0f) { - if ((i > 0) && (this->ingoCheck[i - 1] == 1)) { - this->ingoCheck[i] = 1; + if (Math3D_Vec3f_DistXYZ(&sIngoRaceCheckpoints[i], &pthis->ingoHorse->world.pos) < 400.0f) { + if ((i > 0) && (pthis->ingoCheck[i - 1] == 1)) { + pthis->ingoCheck[i] = 1; } else if (i == 0) { - this->ingoCheck[i] = 1; + pthis->ingoCheck[i] = 1; } } } - if (this->result == INGORACE_NO_RESULT) { + if (pthis->result == INGORACE_NO_RESULT) { Player* player2 = player; - if ((player2->rideActor != NULL) && (this->playerCheck[2] == 1) && AT_FINISH_LINE(player2->rideActor)) { - this->playerFinish++; - if (this->playerFinish > 0) { - this->result = INGORACE_PLAYER_WIN; - this->finishTimer = 55; + if ((player2->rideActor != NULL) && (pthis->playerCheck[2] == 1) && AT_FINISH_LINE(player2->rideActor)) { + pthis->playerFinish++; + if (pthis->playerFinish > 0) { + pthis->result = INGORACE_PLAYER_WIN; + pthis->finishTimer = 55; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } for (i = 0; i < 3; i++) { - this->playerCheck[i] = 0; + pthis->playerCheck[i] = 0; } } - if ((this->ingoHorse != NULL) && (this->ingoCheck[2] == 1) && AT_FINISH_LINE(this->ingoHorse)) { - this->ingoFinish++; - if (this->ingoFinish > 0) { - ingoHorse = (EnHorse*)this->ingoHorse; + if ((pthis->ingoHorse != NULL) && (pthis->ingoCheck[2] == 1) && AT_FINISH_LINE(pthis->ingoHorse)) { + pthis->ingoFinish++; + if (pthis->ingoFinish > 0) { + ingoHorse = (EnHorse*)pthis->ingoHorse; - this->result = INGORACE_INGO_WIN; - this->finishTimer = 70; + pthis->result = INGORACE_INGO_WIN; + pthis->finishTimer = 70; ingoHorse->stateFlags |= ENHORSE_INGO_WON; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } for (i = 0; i < 3; i++) { - this->ingoCheck[i] = 0; + pthis->ingoCheck[i] = 0; } } if (((player2->rideActor != NULL) && AT_RANCH_EXIT(player2->rideActor)) || AT_RANCH_EXIT(&player2->actor)) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); - this->result = INGORACE_INGO_WIN; - this->finishTimer = 20; + pthis->result = INGORACE_INGO_WIN; + pthis->finishTimer = 20; } - if ((gSaveContext.timer1Value >= 180) && (this->startFlags & 2)) { + if ((gSaveContext.timer1Value >= 180) && (pthis->startFlags & 2)) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); - this->result = INGORACE_TIME_UP; - this->finishTimer = 20; + pthis->result = INGORACE_TIME_UP; + pthis->finishTimer = 20; } } else { - if (this->finishTimer > 0) { - this->finishTimer--; + if (pthis->finishTimer > 0) { + pthis->finishTimer--; } else { - EnHorseGameCheck_FinishIngoRace(this, globalCtx); + EnHorseGameCheck_FinishIngoRace(pthis, globalCtx); } } return true; } s32 EnHorseGameCheck_InitGerudoArchery(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheckGerudoArchery* this = (EnHorseGameCheckGerudoArchery*)base; + EnHorseGameCheckGerudoArchery* pthis = (EnHorseGameCheckGerudoArchery*)base; - this->base.type = HORSEGAME_GERUDO_ARCHERY; - this->unk_150 = 0; - this->startTimer = 0; + pthis->base.type = HORSEGAME_GERUDO_ARCHERY; + pthis->unk_150 = 0; + pthis->startTimer = 0; return true; } @@ -250,7 +250,7 @@ s32 EnHorseGameCheck_DestroyGerudoArchery(EnHorseGameCheckBase* base, GlobalCont } s32 EnHorseGameCheck_UpdateGerudoArchery(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheckGerudoArchery* this = (EnHorseGameCheckGerudoArchery*)base; + EnHorseGameCheckGerudoArchery* pthis = (EnHorseGameCheckGerudoArchery*)base; Player* player = GET_PLAYER(globalCtx); EnHorse* horse = (EnHorse*)player->rideActor; @@ -258,19 +258,19 @@ s32 EnHorseGameCheck_UpdateGerudoArchery(EnHorseGameCheckBase* base, GlobalConte return true; } - if (this->startTimer > 90) { + if (pthis->startTimer > 90) { if (globalCtx) {} horse->hbaStarted = 1; } - this->startTimer++; + pthis->startTimer++; return true; } s32 EnHorseGameCheck_InitType3(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheck3* this = (EnHorseGameCheck3*)base; + EnHorseGameCheck3* pthis = (EnHorseGameCheck3*)base; - this->base.type = HORSEGAME_TYPE3; - this->unk_150 = 0; + pthis->base.type = HORSEGAME_TYPE3; + pthis->unk_150 = 0; return true; } @@ -283,17 +283,17 @@ s32 EnHorseGameCheck_UpdateType3(EnHorseGameCheckBase* base, GlobalContext* glob } s32 EnHorseGameCheck_InitMalonRace(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheckMalonRace* this = (EnHorseGameCheckMalonRace*)base; + EnHorseGameCheckMalonRace* pthis = (EnHorseGameCheckMalonRace*)base; s32 i; - this->base.type = HORSEGAME_MALON_RACE; - this->raceFlags = 0; - this->finishTimer = 0; - this->result = MALONRACE_NO_RESULT; + pthis->base.type = HORSEGAME_MALON_RACE; + pthis->raceFlags = 0; + pthis->finishTimer = 0; + pthis->result = MALONRACE_NO_RESULT; for (i = 0; i < 16; i++) { - this->fenceCheck[i] = 0; + pthis->fenceCheck[i] = 0; } - this->lapCount = 0; + pthis->lapCount = 0; return true; } @@ -301,13 +301,13 @@ s32 EnHorseGameCheck_DestroyMalonRace(EnHorseGameCheckBase* base, GlobalContext* return true; } -void EnHorseGameCheck_FinishMalonRace(EnHorseGameCheckMalonRace* this, GlobalContext* globalCtx) { - if ((this->result == MALONRACE_SUCCESS) || (this->result == MALONRACE_TIME_UP)) { +void EnHorseGameCheck_FinishMalonRace(EnHorseGameCheckMalonRace* pthis, GlobalContext* globalCtx) { + if ((pthis->result == MALONRACE_SUCCESS) || (pthis->result == MALONRACE_TIME_UP)) { gSaveContext.cutsceneIndex = 0; globalCtx->nextEntranceIndex = 0x4CE; globalCtx->fadeTransition = 0x2E; globalCtx->sceneLoadFlag = 0x14; - } else if (this->result == MALONRACE_FAILURE) { + } else if (pthis->result == MALONRACE_FAILURE) { gSaveContext.timer1Value = 240; gSaveContext.timer1State = 0xF; gSaveContext.cutsceneIndex = 0; @@ -325,37 +325,37 @@ void EnHorseGameCheck_FinishMalonRace(EnHorseGameCheckMalonRace* this, GlobalCon } s32 EnHorseGameCheck_UpdateMalonRace(EnHorseGameCheckBase* base, GlobalContext* globalCtx) { - EnHorseGameCheckMalonRace* this = (EnHorseGameCheckMalonRace*)base; + EnHorseGameCheckMalonRace* pthis = (EnHorseGameCheckMalonRace*)base; s32 i; Player* player = GET_PLAYER(globalCtx); EnHorse* horse; - if (!(this->raceFlags & MALONRACE_PLAYER_ON_MARK) && AT_FINISH_LINE(player->rideActor)) { - this->raceFlags |= MALONRACE_PLAYER_ON_MARK; - } else if ((this->raceFlags & MALONRACE_PLAYER_ON_MARK) && !(this->raceFlags & MALONRACE_PLAYER_START) && + if (!(pthis->raceFlags & MALONRACE_PLAYER_ON_MARK) && AT_FINISH_LINE(player->rideActor)) { + pthis->raceFlags |= MALONRACE_PLAYER_ON_MARK; + } else if ((pthis->raceFlags & MALONRACE_PLAYER_ON_MARK) && !(pthis->raceFlags & MALONRACE_PLAYER_START) && !AT_FINISH_LINE(player->rideActor)) { - this->raceFlags |= MALONRACE_PLAYER_START; + pthis->raceFlags |= MALONRACE_PLAYER_START; } - if ((this->startTimer > 50) && !(this->raceFlags & MALONRACE_SET_TIMER)) { - this->raceFlags |= MALONRACE_SET_TIMER; + if ((pthis->startTimer > 50) && !(pthis->raceFlags & MALONRACE_SET_TIMER)) { + pthis->raceFlags |= MALONRACE_SET_TIMER; func_80088B34(0); - } else if ((this->startTimer > 80) && (player->rideActor != NULL) && !(this->raceFlags & MALONRACE_PLAYER_MOVE)) { - this->raceFlags |= MALONRACE_PLAYER_MOVE; + } else if ((pthis->startTimer > 80) && (player->rideActor != NULL) && !(pthis->raceFlags & MALONRACE_PLAYER_MOVE)) { + pthis->raceFlags |= MALONRACE_PLAYER_MOVE; horse = (EnHorse*)player->rideActor; horse->inRace = 1; - } else if ((this->startTimer > 81) && !(this->raceFlags & MALONRACE_START_SFX)) { - this->raceFlags |= MALONRACE_START_SFX; + } else if ((pthis->startTimer > 81) && !(pthis->raceFlags & MALONRACE_START_SFX)) { + pthis->raceFlags |= MALONRACE_START_SFX; Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - this->startTimer++; - if (this->result == MALONRACE_NO_RESULT) { + pthis->startTimer++; + if (pthis->result == MALONRACE_NO_RESULT) { Player* player2 = player; f32 dist; for (i = 0; i < 16; i++) { - if ((this->lapCount == 0) && (i >= 8)) { + if ((pthis->lapCount == 0) && (i >= 8)) { break; } dist = Math_Vec3f_DistXZ(&sFencePos[i % 8], &player2->rideActor->world.pos); @@ -363,62 +363,62 @@ s32 EnHorseGameCheck_UpdateMalonRace(EnHorseGameCheckBase* base, GlobalContext* horse = (EnHorse*)player2->rideActor; if (horse->stateFlags & ENHORSE_JUMPING) { - if ((i > 0) && (this->fenceCheck[i - 1] == 1)) { - this->fenceCheck[i] = 1; + if ((i > 0) && (pthis->fenceCheck[i - 1] == 1)) { + pthis->fenceCheck[i] = 1; } else if (i == 0) { - this->fenceCheck[i] = 1; + pthis->fenceCheck[i] = 1; } - if ((this->fenceCheck[i - 1] == 0) && !(this->raceFlags & MALONRACE_BROKE_RULE)) { - this->raceFlags |= MALONRACE_BROKE_RULE; + if ((pthis->fenceCheck[i - 1] == 0) && !(pthis->raceFlags & MALONRACE_BROKE_RULE)) { + pthis->raceFlags |= MALONRACE_BROKE_RULE; Message_StartTextbox(globalCtx, 0x208C, NULL); - this->result = 4; - this->finishTimer = 30; + pthis->result = 4; + pthis->finishTimer = 30; } } } } - if ((player2->rideActor != NULL) && (this->raceFlags & MALONRACE_PLAYER_START) && + if ((player2->rideActor != NULL) && (pthis->raceFlags & MALONRACE_PLAYER_START) && AT_FINISH_LINE(player2->rideActor)) { - if ((this->lapCount == 1) && (this->fenceCheck[15] == 0) && (player2->rideActor->prevPos.x < -200.0f)) { - this->raceFlags |= MALONRACE_BROKE_RULE; + if ((pthis->lapCount == 1) && (pthis->fenceCheck[15] == 0) && (player2->rideActor->prevPos.x < -200.0f)) { + pthis->raceFlags |= MALONRACE_BROKE_RULE; Message_StartTextbox(globalCtx, 0x208C, NULL); - this->result = MALONRACE_FAILURE; - this->finishTimer = 30; - } else if (this->fenceCheck[15] == 1) { - this->lapCount = 2; + pthis->result = MALONRACE_FAILURE; + pthis->finishTimer = 30; + } else if (pthis->fenceCheck[15] == 1) { + pthis->lapCount = 2; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->result = MALONRACE_SUCCESS; - this->finishTimer = 70; + pthis->result = MALONRACE_SUCCESS; + pthis->finishTimer = 70; gSaveContext.timer1State = 0xF; - } else if ((this->fenceCheck[7] == 1) && !(this->raceFlags & MALONRACE_SECOND_LAP)) { - this->lapCount = 1; - this->raceFlags |= MALONRACE_SECOND_LAP; + } else if ((pthis->fenceCheck[7] == 1) && !(pthis->raceFlags & MALONRACE_SECOND_LAP)) { + pthis->lapCount = 1; + pthis->raceFlags |= MALONRACE_SECOND_LAP; Message_StartTextbox(globalCtx, 0x208D, NULL); - } else if (this->fenceCheck[7] == 0) { - this->raceFlags |= MALONRACE_BROKE_RULE; + } else if (pthis->fenceCheck[7] == 0) { + pthis->raceFlags |= MALONRACE_BROKE_RULE; Message_StartTextbox(globalCtx, 0x208C, NULL); - this->result = MALONRACE_FAILURE; - this->finishTimer = 30; + pthis->result = MALONRACE_FAILURE; + pthis->finishTimer = 30; } else if (player2->rideActor->prevPos.x > 80.0f) { - this->raceFlags |= MALONRACE_BROKE_RULE; + pthis->raceFlags |= MALONRACE_BROKE_RULE; Message_StartTextbox(globalCtx, 0x208C, NULL); - this->result = MALONRACE_FAILURE; - this->finishTimer = 30; + pthis->result = MALONRACE_FAILURE; + pthis->finishTimer = 30; } } - if ((gSaveContext.timer1Value >= 180) && (this->raceFlags & MALONRACE_SET_TIMER)) { + if ((gSaveContext.timer1Value >= 180) && (pthis->raceFlags & MALONRACE_SET_TIMER)) { gSaveContext.timer1Value = 240; - this->result = MALONRACE_TIME_UP; - this->finishTimer = 30; + pthis->result = MALONRACE_TIME_UP; + pthis->finishTimer = 30; gSaveContext.timer1State = 0; } } else { - if (this->finishTimer > 0) { - this->finishTimer--; + if (pthis->finishTimer > 0) { + pthis->finishTimer--; } else { - EnHorseGameCheck_FinishMalonRace(this, globalCtx); + EnHorseGameCheck_FinishMalonRace(pthis, globalCtx); } } return true; @@ -450,31 +450,31 @@ static EnHorseGameCheckFunc sUpdateFuncs[] = { void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnHorseGameCheckBase* this = (EnHorseGameCheckBase*)thisx; + EnHorseGameCheckBase* pthis = (EnHorseGameCheckBase*)thisx; if ((globalCtx->sceneNum == SCENE_SPOT20) && (Flags_GetEventChkInf(0x18) || DREG(1))) { - this->actor.params = HORSEGAME_MALON_RACE; + pthis->actor.params = HORSEGAME_MALON_RACE; } - if (sInitFuncs[this->actor.params] != NULL) { - sInitFuncs[this->actor.params](this, globalCtx); + if (sInitFuncs[pthis->actor.params] != NULL) { + sInitFuncs[pthis->actor.params](pthis, globalCtx); } } void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnHorseGameCheckBase* this = (EnHorseGameCheckBase*)thisx; + EnHorseGameCheckBase* pthis = (EnHorseGameCheckBase*)thisx; - if (sDestroyFuncs[this->actor.params] != NULL) { - sDestroyFuncs[this->actor.params](this, globalCtx); + if (sDestroyFuncs[pthis->actor.params] != NULL) { + sDestroyFuncs[pthis->actor.params](pthis, globalCtx); } } void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnHorseGameCheckBase* this = (EnHorseGameCheckBase*)thisx; + EnHorseGameCheckBase* pthis = (EnHorseGameCheckBase*)thisx; - if (sUpdateFuncs[this->type] != NULL) { - sUpdateFuncs[this->type](this, globalCtx); + if (sUpdateFuncs[pthis->type] != NULL) { + sUpdateFuncs[pthis->type](pthis, globalCtx); } } diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 0828d2705..f70dd66aa 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -6,7 +6,7 @@ struct EnHorseGameCheckBase; -typedef s32 (*EnHorseGameCheckFunc)(struct EnHorseGameCheckBase* this, GlobalContext* globalCtx); +typedef s32 (*EnHorseGameCheckFunc)(struct EnHorseGameCheckBase* pthis, GlobalContext* globalCtx); typedef struct EnHorseGameCheckBase { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c b/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c deleted file mode 100644 index de38ffaf3..000000000 --- a/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c +++ /dev/null @@ -1,343 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_GANON_Z_EN_HORSE_GANON_C -#include "actor_common.h" -/* - * File: z_en_horse_ganon.c - * Overlay: ovl_En_Horse_Ganon - * Description: Ganondorf's Horse - */ - -#include "z_en_horse_ganon.h" -#include "objects/object_horse_ganon/object_horse_ganon.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin.h" -#include "def/z_skin_awb.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef struct { - /* 0x0 */ Vec3s unk_0; - /* 0x6 */ u8 unk_6; -} unk_D_80A69248; // size = 0x8 - -void EnHorseGanon_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorseGanon_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorseGanon_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorseGanon_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A68AC4(EnHorseGanon* this); -void func_80A68AF0(EnHorseGanon* this, GlobalContext* globalCtx); -void func_80A68DB0(EnHorseGanon* this, GlobalContext* globalCtx); - -const ActorInit En_Horse_Ganon_InitVars = { - ACTOR_EN_HORSE_GANON, - ACTORCAT_BG, - FLAGS, - OBJECT_HORSE_GANON, - sizeof(EnHorseGanon), - (ActorFunc)EnHorseGanon_Init, - (ActorFunc)EnHorseGanon_Destroy, - (ActorFunc)EnHorseGanon_Update, - (ActorFunc)EnHorseGanon_Draw, -}; - -static AnimationHeader* sAnimations[] = { - &gHorseGanonIdleAnim, &gHorseGanonWhinnyAnim, &gHorseGanonWalkingAnim, - &gHorseGanonTrottingAnim, &gHorseGanonGallopingAnim, &gHorseGanonRearingAnim, -}; - -static f32 splaySpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f }; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 40, 100, 0, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 13, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; - -static unk_D_80A69248 D_80A69248[] = { - { 0x09B8, 0x0126, 0x0E2C, 0x07 }, { 0x0C11, 0x017A, 0x1269, 0x07 }, { 0x064E, 0xFEFB, 0x1DAC, 0x07 }, - { 0x02F2, 0xFF45, 0x244F, 0x07 }, { 0xF96E, 0xFE0C, 0x3122, 0x07 }, { 0xF328, 0xFE0C, 0x32D5, 0x07 }, - { 0xEBEA, 0xFE5F, 0x2D6E, 0x07 }, { 0xE95E, 0xFE27, 0x2565, 0x07 }, { 0xE593, 0xFE0C, 0x20AC, 0x07 }, - { 0xE625, 0xFE77, 0x1B07, 0x07 }, { 0xEBB7, 0x007C, 0x1539, 0x07 }, { 0xF466, 0x0002, 0x11B9, 0x07 }, - { 0xF47B, 0xFFDD, 0x11AF, 0x07 }, { 0xF88D, 0xFFD1, 0x0BA2, 0x07 }, -}; - -static s32 D_80A692B8[] = { 0, 16 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), -}; - -static EnHorseGanonActionFunc sActionFuncs[] = { func_80A68AF0, func_80A68DB0 }; - -void func_80A68660(unk_D_80A69248* data, s32 index, Vec3f* vec) { - vec->x = data[index].unk_0.x; - vec->y = data[index].unk_0.y; - vec->z = data[index].unk_0.z; -} - -void func_80A686A8(EnHorseGanon* this, GlobalContext* globalCtx) { - Vec3f* tempPos; - Vec3f vec; - s16 y; - - func_80A68660(D_80A69248, this->unk_1EC, &vec); - if (Math3D_Vec3f_DistXYZ(&vec, &this->actor.world.pos) <= 400.0f) { - this->unk_1EC += 1; - if (this->unk_1EC >= 14) { - this->unk_1EC = 0; - func_80A68660(D_80A69248, 0, &vec); - } - } - - tempPos = &this->actor.world.pos; - y = Math_Vec3f_Yaw(tempPos, &vec) - this->actor.world.rot.y; - if (y >= 301) { - this->actor.world.rot.y += 300; - } else if (y < -300) { - this->actor.world.rot.y -= 300; - } else { - this->actor.world.rot.y += y; - } - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor) <= 300.0f) { - if (this->actor.speedXZ < 12.0f) { - this->actor.speedXZ += 1.0f; - } else { - this->actor.speedXZ -= 1.0f; - } - } else if (this->actor.speedXZ < D_80A69248[this->unk_1EC].unk_6) { - this->actor.speedXZ += 0.5f; - } else { - this->actor.speedXZ -= 0.5f; - } -} - -void func_80A68870(EnHorseGanon* this) { - if ((this->skin.skelAnime.curFrame > D_80A692B8[this->soundCount]) && - (this->soundCount != 0 || !(this->skin.skelAnime.curFrame > D_80A692B8[1]))) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_WALK, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - - this->soundCount++; - if (this->soundCount >= 2) { - this->soundCount = 0; - } - } -} - -void EnHorseGanon_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHorseGanon* this = (EnHorseGanon*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.0115f); - - this->actor.gravity = -3.5f; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->actor.speedXZ = 0.0f; - this->actor.focus.pos = this->actor.world.pos; - this->action = 0; - this->actor.focus.pos.y += 70.0f; - func_800A663C(globalCtx, &this->skin, &gHorseGanonSkel, &gHorseGanonIdleAnim); - this->currentAnimation = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[0]); - - Collider_InitCylinder(globalCtx, &this->colliderBody); - Collider_SetCylinder(globalCtx, &this->colliderBody, &this->actor, &sCylinderInit); - Collider_InitJntSph(globalCtx, &this->colliderHead); - Collider_SetJntSph(globalCtx, &this->colliderHead, &this->actor, &sJntSphInit, this->headElements); - - CollisionCheck_SetInfo(&this->actor.colChkInfo, 0, &sColChkInfoInit); - func_80A68AC4(this); -} - -void EnHorseGanon_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHorseGanon* this = (EnHorseGanon*)thisx; - - func_800A6888(globalCtx, &this->skin); - Collider_DestroyCylinder(globalCtx, &this->colliderBody); - Collider_DestroyJntSph(globalCtx, &this->colliderHead); -} - -void func_80A68AC4(EnHorseGanon* this) { - this->action = 0; - Animation_PlayLoop(&this->skin.skelAnime, sAnimations[4]); -} - -void func_80A68AF0(EnHorseGanon* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - SkelAnime_Update(&this->skin.skelAnime); -} - -void func_80A68B20(EnHorseGanon* this) { - s32 animationChanged; - f32 sp30; - - animationChanged = 0; - this->action = 1; - if (this->actor.speedXZ <= 3.0f) { - if (this->currentAnimation != 2) { - animationChanged = 1; - } - this->currentAnimation = 2; - } else if (this->actor.speedXZ <= 6.0f) { - if (this->currentAnimation != 3) { - animationChanged = 1; - } - this->currentAnimation = 3; - } else { - if (this->currentAnimation != 4) { - animationChanged = 1; - } - this->currentAnimation = 4; - } - - if (this->currentAnimation == 2) { - sp30 = this->actor.speedXZ / 3.0f; - } else if (this->currentAnimation == 3) { - sp30 = this->actor.speedXZ / 5.0f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (this->currentAnimation == 4) { - sp30 = this->actor.speedXZ / 7.0f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - sp30 = 1.0f; - } - - if (animationChanged == 1) { - Animation_Change(&this->skin.skelAnime, sAnimations[this->currentAnimation], - splaySpeeds[this->currentAnimation] * sp30 * 1.5f, 0.0f, - Animation_GetLastFrame(sAnimations[this->currentAnimation]), ANIMMODE_ONCE, -3.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimations[this->currentAnimation], - splaySpeeds[this->currentAnimation] * sp30 * 1.5f, 0.0f, - Animation_GetLastFrame(sAnimations[this->currentAnimation]), ANIMMODE_ONCE, 0.0f); - } -} - -void func_80A68DB0(EnHorseGanon* this, GlobalContext* globalCtx) { - if (this->currentAnimation == 2) { - func_80A68870(this); - } - - func_80A686A8(this, globalCtx); - - if (SkelAnime_Update(&this->skin.skelAnime) != 0) { - func_80A68B20(this); - } -} - -void func_80A68E14(EnHorseGanon* this, GlobalContext* globalCtx) { - s32 pad; - CollisionPoly* col; - f32 temp_ret; - Vec3f v; - s32 temp1; - - v.x = Math_SinS(this->actor.shape.rot.y) * 30.0f + this->actor.world.pos.x; - v.y = this->actor.world.pos.y + 60.0f; - v.z = Math_CosS(this->actor.shape.rot.y) * 30.0f + this->actor.world.pos.z; - - temp_ret = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &col, &temp1, &v); - - this->unk_1F4 = temp_ret; - this->actor.shape.rot.x = (0x8000 / M_PI) * Math_FAtan2F(this->actor.world.pos.y - temp_ret, 30.0f); -} - -void EnHorseGanon_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHorseGanon* this = (EnHorseGanon*)thisx; - s32 pad; - - sActionFuncs[this->action](this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 29); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - Collider_UpdateCylinder(&this->actor, &this->colliderBody); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderBody.base); -} - -void func_80A68FA8(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { - Vec3f sp4C; - Vec3f sp40; - EnHorseGanon* this = (EnHorseGanon*)thisx; - s32 index; - - for (index = 0; index < this->colliderHead.count; index++) { - sp4C.x = this->colliderHead.elements[index].dim.modelSphere.center.x; - sp4C.y = this->colliderHead.elements[index].dim.modelSphere.center.y; - sp4C.z = this->colliderHead.elements[index].dim.modelSphere.center.z; - - func_800A6408(skin, this->colliderHead.elements[index].dim.limb, &sp4C, &sp40); - - this->colliderHead.elements[index].dim.worldSphere.center.x = sp40.x; - this->colliderHead.elements[index].dim.worldSphere.center.y = sp40.y; - this->colliderHead.elements[index].dim.worldSphere.center.z = sp40.z; - - this->colliderHead.elements[index].dim.worldSphere.radius = - this->colliderHead.elements[index].dim.modelSphere.radius * this->colliderHead.elements[index].dim.scale; - } - - //! @bug see relevant comment in `EnHorse_SkinCallback1` - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderHead.base); -} - -void EnHorseGanon_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHorseGanon* this = (EnHorseGanon*)thisx; - - func_80A68E14(this, globalCtx); - func_80093D18(globalCtx->state.gfxCtx); - func_800A6330(&this->actor, globalCtx, &this->skin, func_80A68FA8, 1); -} diff --git a/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.cpp b/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.cpp new file mode 100644 index 000000000..be0d2c8a3 --- /dev/null +++ b/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.cpp @@ -0,0 +1,343 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_GANON_Z_EN_HORSE_GANON_C +#include "actor_common.h" +/* + * File: z_en_horse_ganon.c + * Overlay: ovl_En_Horse_Ganon + * Description: Ganondorf's Horse + */ + +#include "z_en_horse_ganon.h" +#include "objects/object_horse_ganon/object_horse_ganon.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin.h" +#include "def/z_skin_awb.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef struct { + /* 0x0 */ Vec3s unk_0; + /* 0x6 */ u8 unk_6; +} unk_D_80A69248; // size = 0x8 + +void EnHorseGanon_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHorseGanon_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHorseGanon_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHorseGanon_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A68AC4(EnHorseGanon* pthis); +void func_80A68AF0(EnHorseGanon* pthis, GlobalContext* globalCtx); +void func_80A68DB0(EnHorseGanon* pthis, GlobalContext* globalCtx); + +ActorInit En_Horse_Ganon_InitVars = { + ACTOR_EN_HORSE_GANON, + ACTORCAT_BG, + FLAGS, + OBJECT_HORSE_GANON, + sizeof(EnHorseGanon), + (ActorFunc)EnHorseGanon_Init, + (ActorFunc)EnHorseGanon_Destroy, + (ActorFunc)EnHorseGanon_Update, + (ActorFunc)EnHorseGanon_Draw, +}; + +static AnimationHeader* sAnimations[] = { + &gHorseGanonIdleAnim, &gHorseGanonWhinnyAnim, &gHorseGanonWalkingAnim, + &gHorseGanonTrottingAnim, &gHorseGanonGallopingAnim, &gHorseGanonRearingAnim, +}; + +static f32 splaySpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 40, 100, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 13, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; + +static unk_D_80A69248 D_80A69248[] = { + { 0x09B8, 0x0126, 0x0E2C, 0x07 }, { 0x0C11, 0x017A, 0x1269, 0x07 }, { 0x064E, 0xFEFB, 0x1DAC, 0x07 }, + { 0x02F2, 0xFF45, 0x244F, 0x07 }, { 0xF96E, 0xFE0C, 0x3122, 0x07 }, { 0xF328, 0xFE0C, 0x32D5, 0x07 }, + { 0xEBEA, 0xFE5F, 0x2D6E, 0x07 }, { 0xE95E, 0xFE27, 0x2565, 0x07 }, { 0xE593, 0xFE0C, 0x20AC, 0x07 }, + { 0xE625, 0xFE77, 0x1B07, 0x07 }, { 0xEBB7, 0x007C, 0x1539, 0x07 }, { 0xF466, 0x0002, 0x11B9, 0x07 }, + { 0xF47B, 0xFFDD, 0x11AF, 0x07 }, { 0xF88D, 0xFFD1, 0x0BA2, 0x07 }, +}; + +static s32 D_80A692B8[] = { 0, 16 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), +}; + +static EnHorseGanonActionFunc sActionFuncs[] = { func_80A68AF0, func_80A68DB0 }; + +void func_80A68660(unk_D_80A69248* data, s32 index, Vec3f* vec) { + vec->x = data[index].unk_0.x; + vec->y = data[index].unk_0.y; + vec->z = data[index].unk_0.z; +} + +void func_80A686A8(EnHorseGanon* pthis, GlobalContext* globalCtx) { + Vec3f* tempPos; + Vec3f vec; + s16 y; + + func_80A68660(D_80A69248, pthis->unk_1EC, &vec); + if (Math3D_Vec3f_DistXYZ(&vec, &pthis->actor.world.pos) <= 400.0f) { + pthis->unk_1EC += 1; + if (pthis->unk_1EC >= 14) { + pthis->unk_1EC = 0; + func_80A68660(D_80A69248, 0, &vec); + } + } + + tempPos = &pthis->actor.world.pos; + y = Math_Vec3f_Yaw(tempPos, &vec) - pthis->actor.world.rot.y; + if (y >= 301) { + pthis->actor.world.rot.y += 300; + } else if (y < -300) { + pthis->actor.world.rot.y -= 300; + } else { + pthis->actor.world.rot.y += y; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) <= 300.0f) { + if (pthis->actor.speedXZ < 12.0f) { + pthis->actor.speedXZ += 1.0f; + } else { + pthis->actor.speedXZ -= 1.0f; + } + } else if (pthis->actor.speedXZ < D_80A69248[pthis->unk_1EC].unk_6) { + pthis->actor.speedXZ += 0.5f; + } else { + pthis->actor.speedXZ -= 0.5f; + } +} + +void func_80A68870(EnHorseGanon* pthis) { + if ((pthis->skin.skelAnime.curFrame > D_80A692B8[pthis->soundCount]) && + (pthis->soundCount != 0 || !(pthis->skin.skelAnime.curFrame > D_80A692B8[1]))) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_WALK, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + + pthis->soundCount++; + if (pthis->soundCount >= 2) { + pthis->soundCount = 0; + } + } +} + +void EnHorseGanon_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGanon* pthis = (EnHorseGanon*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.0115f); + + pthis->actor.gravity = -3.5f; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->action = 0; + pthis->actor.focus.pos.y += 70.0f; + func_800A663C(globalCtx, &pthis->skin, &gHorseGanonSkel, &gHorseGanonIdleAnim); + pthis->currentAnimation = 0; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[0]); + + Collider_InitCylinder(globalCtx, &pthis->colliderBody); + Collider_SetCylinder(globalCtx, &pthis->colliderBody, &pthis->actor, &sCylinderInit); + Collider_InitJntSph(globalCtx, &pthis->colliderHead); + Collider_SetJntSph(globalCtx, &pthis->colliderHead, &pthis->actor, &sJntSphInit, pthis->headElements); + + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, 0, &sColChkInfoInit); + func_80A68AC4(pthis); +} + +void EnHorseGanon_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGanon* pthis = (EnHorseGanon*)thisx; + + func_800A6888(globalCtx, &pthis->skin); + Collider_DestroyCylinder(globalCtx, &pthis->colliderBody); + Collider_DestroyJntSph(globalCtx, &pthis->colliderHead); +} + +void func_80A68AC4(EnHorseGanon* pthis) { + pthis->action = 0; + Animation_PlayLoop(&pthis->skin.skelAnime, sAnimations[4]); +} + +void func_80A68AF0(EnHorseGanon* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + SkelAnime_Update(&pthis->skin.skelAnime); +} + +void func_80A68B20(EnHorseGanon* pthis) { + s32 animationChanged; + f32 sp30; + + animationChanged = 0; + pthis->action = 1; + if (pthis->actor.speedXZ <= 3.0f) { + if (pthis->currentAnimation != 2) { + animationChanged = 1; + } + pthis->currentAnimation = 2; + } else if (pthis->actor.speedXZ <= 6.0f) { + if (pthis->currentAnimation != 3) { + animationChanged = 1; + } + pthis->currentAnimation = 3; + } else { + if (pthis->currentAnimation != 4) { + animationChanged = 1; + } + pthis->currentAnimation = 4; + } + + if (pthis->currentAnimation == 2) { + sp30 = pthis->actor.speedXZ / 3.0f; + } else if (pthis->currentAnimation == 3) { + sp30 = pthis->actor.speedXZ / 5.0f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (pthis->currentAnimation == 4) { + sp30 = pthis->actor.speedXZ / 7.0f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + sp30 = 1.0f; + } + + if (animationChanged == 1) { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->currentAnimation], + splaySpeeds[pthis->currentAnimation] * sp30 * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimations[pthis->currentAnimation]), ANIMMODE_ONCE, -3.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->currentAnimation], + splaySpeeds[pthis->currentAnimation] * sp30 * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimations[pthis->currentAnimation]), ANIMMODE_ONCE, 0.0f); + } +} + +void func_80A68DB0(EnHorseGanon* pthis, GlobalContext* globalCtx) { + if (pthis->currentAnimation == 2) { + func_80A68870(pthis); + } + + func_80A686A8(pthis, globalCtx); + + if (SkelAnime_Update(&pthis->skin.skelAnime) != 0) { + func_80A68B20(pthis); + } +} + +void func_80A68E14(EnHorseGanon* pthis, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* col; + f32 temp_ret; + Vec3f v; + s32 temp1; + + v.x = Math_SinS(pthis->actor.shape.rot.y) * 30.0f + pthis->actor.world.pos.x; + v.y = pthis->actor.world.pos.y + 60.0f; + v.z = Math_CosS(pthis->actor.shape.rot.y) * 30.0f + pthis->actor.world.pos.z; + + temp_ret = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &col, &temp1, &v); + + pthis->unk_1F4 = temp_ret; + pthis->actor.shape.rot.x = (0x8000 / M_PI) * Math_FAtan2F(pthis->actor.world.pos.y - temp_ret, 30.0f); +} + +void EnHorseGanon_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGanon* pthis = (EnHorseGanon*)thisx; + s32 pad; + + sActionFuncs[pthis->action](pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 55.0f, 100.0f, 29); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderBody); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderBody.base); +} + +void func_80A68FA8(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { + Vec3f sp4C; + Vec3f sp40; + EnHorseGanon* pthis = (EnHorseGanon*)thisx; + s32 index; + + for (index = 0; index < pthis->colliderHead.count; index++) { + sp4C.x = pthis->colliderHead.elements[index].dim.modelSphere.center.x; + sp4C.y = pthis->colliderHead.elements[index].dim.modelSphere.center.y; + sp4C.z = pthis->colliderHead.elements[index].dim.modelSphere.center.z; + + func_800A6408(skin, pthis->colliderHead.elements[index].dim.limb, &sp4C, &sp40); + + pthis->colliderHead.elements[index].dim.worldSphere.center.x = sp40.x; + pthis->colliderHead.elements[index].dim.worldSphere.center.y = sp40.y; + pthis->colliderHead.elements[index].dim.worldSphere.center.z = sp40.z; + + pthis->colliderHead.elements[index].dim.worldSphere.radius = + pthis->colliderHead.elements[index].dim.modelSphere.radius * pthis->colliderHead.elements[index].dim.scale; + } + + //! @bug see relevant comment in `EnHorse_SkinCallback1` + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderHead.base); +} + +void EnHorseGanon_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGanon* pthis = (EnHorseGanon*)thisx; + + func_80A68E14(pthis, globalCtx); + func_80093D18(globalCtx->state.gfxCtx); + func_800A6330(&pthis->actor, globalCtx, &pthis->skin, func_80A68FA8, 1); +} diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c deleted file mode 100644 index 99b552523..000000000 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ /dev/null @@ -1,638 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_LINK_CHILD_Z_EN_HORSE_LINK_CHILD_C -#include "actor_common.h" -/* - * File: z_en_horse_link_child.c - * Overlay: ovl_En_Horse_Link_Child - * Description: Young Epona - */ - -#include "z_en_horse_link_child.h" -#include "objects/object_horse_link_child/object_horse_link_child.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_horse.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin.h" -#include "def/z_skin_awb.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_25) - -void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A69B7C(EnHorseLinkChild* this); -void func_80A69EC0(EnHorseLinkChild* this); -void func_80A6A4DC(EnHorseLinkChild* this); -void func_80A6A724(EnHorseLinkChild* this); - -const ActorInit En_Horse_Link_Child_InitVars = { - ACTOR_EN_HORSE_LINK_CHILD, - ACTORCAT_BG, - FLAGS, - OBJECT_HORSE_LINK_CHILD, - sizeof(EnHorseLinkChild), - (ActorFunc)EnHorseLinkChild_Init, - (ActorFunc)EnHorseLinkChild_Destroy, - (ActorFunc)EnHorseLinkChild_Update, - (ActorFunc)EnHorseLinkChild_Draw, -}; - -static AnimationHeader* sAnimations[] = { - &gChildEponaIdleAnim, &gChildEponaWhinnyAnim, &gChildEponaWalkingAnim, - &gChildEponaTrottingAnim, &gChildEponaGallopingAnim, -}; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 100, 0, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 13, { { 0, 0, 0 }, 10 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementInit, -}; - -static CollisionCheckInfoInit sColCheckInfoInit = { 10, 35, 100, MASS_HEAVY }; - -void func_80A693D0(EnHorseLinkChild* this) { - static s32 D_80A6AF5C[] = { 1, 19 }; - - if ((this->skin.skelAnime.curFrame > D_80A6AF5C[this->unk_1F0]) && - !((this->unk_1F0 == 0) && (this->skin.skelAnime.curFrame > D_80A6AF5C[1]))) { - Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_WALK, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->unk_1F0++; - if (this->unk_1F0 >= ARRAY_COUNT(D_80A6AF5C)) { - this->unk_1F0 = 0; - } - } -} - -void func_80A6948C(EnHorseLinkChild* this) { - if (this->animationIdx == 2) { - func_80A693D0(this); - } else if (this->skin.skelAnime.curFrame == 0.0f) { - if ((this->animationIdx == 3) || (this->animationIdx == 4)) { - Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (this->animationIdx == 1) { - if (Rand_ZeroOne() > 0.5f) { - Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_GROAN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else { - Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - } -} - -static f32 D_80A6AF64[] = { 1.0f, 1.0f, 1.5f, 1.5f, 1.5f }; - -f32 func_80A695A4(EnHorseLinkChild* this) { - f32 result; - - if (this->animationIdx == 2) { - result = D_80A6AF64[this->animationIdx] * this->actor.speedXZ * (1.0f / 2.0f); - } else if (this->animationIdx == 3) { - result = D_80A6AF64[this->animationIdx] * this->actor.speedXZ * (1.0f / 3.0f); - } else if (this->animationIdx == 4) { - result = D_80A6AF64[this->animationIdx] * this->actor.speedXZ * (1.0f / 5.0f); - } else { - result = D_80A6AF64[this->animationIdx]; - } - - return result; -} - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), -}; - -void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHorseLinkChild* this = (EnHorseLinkChild*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.005f); - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->actor.speedXZ = 0.0f; - this->action = 1; - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - func_800A663C(globalCtx, &this->skin, &gChildEponaSkel, &gChildEponaGallopingAnim); - this->animationIdx = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[0]); - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinderType1(globalCtx, &this->bodyCollider, &this->actor, &sCylinderInit); - Collider_InitJntSph(globalCtx, &this->headCollider); - Collider_SetJntSph(globalCtx, &this->headCollider, &this->actor, &sJntSphInit, this->headElements); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColCheckInfoInit); - this->unk_1F0 = 0; - this->eyeTexIndex = 0; - - if (gSaveContext.sceneSetupIndex > 3) { - func_80A69EC0(this); - } else if (globalCtx->sceneNum == SCENE_SPOT20) { - if (!Flags_GetEventChkInf(0x14)) { - Actor_Kill(&this->actor); - return; - } - this->unk_2A0 = gSaveContext.eventChkInf[1] & 0x40; - func_80A69EC0(this); - } else { - func_80A69EC0(this); - } - - this->actor.home.rot.z = this->actor.world.rot.z = this->actor.shape.rot.z = 0; -} - -void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHorseLinkChild* this = (EnHorseLinkChild*)thisx; - - func_800A6888(globalCtx, &this->skin); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyJntSph(globalCtx, &this->headCollider); -} - -void func_80A6988C(EnHorseLinkChild* this) { - this->action = 0; - this->animationIdx++; - if (this->animationIdx >= ARRAY_COUNT(sAnimations)) { - this->animationIdx = 0; - } - - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); - this->skin.skelAnime.playSpeed = func_80A695A4(this); -} - -void func_80A698F4(EnHorseLinkChild* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - if (SkelAnime_Update(&this->skin.skelAnime)) { - func_80A6988C(this); - } -} - -void func_80A6993C(EnHorseLinkChild* this, s32 newAnimationIdx) { - this->action = 2; - this->actor.speedXZ = 0.0f; - - if (!((newAnimationIdx == 0) || (newAnimationIdx == 1))) { - newAnimationIdx = 0; - } - - if (this->animationIdx != newAnimationIdx) { - this->animationIdx = newAnimationIdx; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); - } -} - -void func_80A699FC(EnHorseLinkChild* this, GlobalContext* globalCtx) { - f32 distFromLink; - s32 newAnimationIdx; - - distFromLink = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - - if (SkelAnime_Update(&this->skin.skelAnime)) { - if ((distFromLink < 1000.0f) && (distFromLink > 70.0f)) { - func_80A69B7C(this); - } else { - newAnimationIdx = this->animationIdx == 1 ? 0 : 1; - if (this->animationIdx != newAnimationIdx) { - this->animationIdx = newAnimationIdx; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0); - } - } - } -} - -void func_80A69B7C(EnHorseLinkChild* this) { - this->action = 1; - this->animationIdx = 0; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); -} - -void func_80A69C18(EnHorseLinkChild* this, GlobalContext* globalCtx) { - s16 yawDiff; - f32 distFromLink; - s32 newAnimationIdx; - - if ((this->animationIdx == 4) || (this->animationIdx == 3) || (this->animationIdx == 2)) { - yawDiff = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; - - if (yawDiff > 0x12C) { - this->actor.world.rot.y += 0x12C; - } else if (yawDiff < -0x12C) { - this->actor.world.rot.y -= 0x12C; - } else { - this->actor.world.rot.y += yawDiff; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - distFromLink = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - - if (distFromLink > 1000.0f) { - func_80A6993C(this, 0); - return; - } else if ((distFromLink < 1000.0f) && (distFromLink >= 300.0f)) { - newAnimationIdx = 4; - this->actor.speedXZ = 6.0f; - } else if ((distFromLink < 300.0f) && (distFromLink >= 150.0f)) { - newAnimationIdx = 3; - this->actor.speedXZ = 4.0f; - } else if ((distFromLink < 150.0f) && (distFromLink >= 70.0f)) { - newAnimationIdx = 2; - this->actor.speedXZ = 2.0f; - this->unk_1F0 = 0; - } else { - func_80A6993C(this, 1); - return; - } - - if (this->animationIdx != newAnimationIdx) { - this->animationIdx = newAnimationIdx; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); - } - } -} - -void func_80A69EC0(EnHorseLinkChild* this) { - this->action = 3; - this->animationIdx = 0; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); -} - -void func_80A69F5C(EnHorseLinkChild* this, GlobalContext* globalCtx) { - Player* player; - s16 yawDiff; - s32 yawSign; - s32 yawOffset; - - if ((this->animationIdx == 4) || (this->animationIdx == 3) || (this->animationIdx == 2)) { - player = GET_PLAYER(globalCtx); - - if (Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &this->actor.home.pos) < 250.0f) { - yawDiff = player->actor.shape.rot.y; - yawSign = Actor_WorldYawTowardActor(&this->actor, &player->actor) > 0 ? 1 : -1; - yawOffset = yawSign << 0xE; - yawDiff += yawOffset; - } else { - yawDiff = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; - } - - if (yawDiff > 0x12C) { - this->actor.world.rot.y += 0x12C; - } else if (yawDiff < -0x12C) { - this->actor.world.rot.y -= 0x12C; - } else { - this->actor.world.rot.y += yawDiff; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - } -} - -void func_80A6A068(EnHorseLinkChild* this, GlobalContext* globalCtx) { - Player* player; - f32 distFromLink; - s32 animationEnded; - s32 newAnimationIdx; - f32 distFromHome; - f32 distLinkFromHome; - - func_80A69F5C(this, globalCtx); - player = GET_PLAYER(globalCtx); - distFromLink = Actor_WorldDistXZToActor(&this->actor, &player->actor); - - if (gSaveContext.entranceIndex == 0x2AE) { - Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_80A6A724(this); - return; - } - - if (((gSaveContext.eventChkInf[1] & 0x40) && (DREG(53) != 0)) || - ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.cutsceneIndex == 0xFFF1))) { - func_80A6A4DC(this); - } else { - this->unk_2A0 = gSaveContext.eventChkInf[1] & 0x40; - } - - newAnimationIdx = this->animationIdx; - animationEnded = SkelAnime_Update(&this->skin.skelAnime); - if (animationEnded || (this->animationIdx == 1) || (this->animationIdx == 0)) { - if (gSaveContext.eventChkInf[1] & 0x20) { - distFromHome = Math3D_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos); - distLinkFromHome = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &this->actor.home.pos); - if (distLinkFromHome > 250.0f) { - if (distFromHome >= 300.0f) { - newAnimationIdx = 4; - this->actor.speedXZ = 6.0f; - } else if ((distFromHome < 300.0f) && (distFromHome >= 150.0f)) { - newAnimationIdx = 3; - this->actor.speedXZ = 4.0f; - } else if ((distFromHome < 150.0f) && (distFromHome >= 70.0f)) { - newAnimationIdx = 2; - this->actor.speedXZ = 2.0f; - this->unk_1F0 = 0; - } else { - this->actor.speedXZ = 0.0f; - if (this->animationIdx == 0) { - newAnimationIdx = animationEnded == true ? 1 : 0; - } else { - newAnimationIdx = animationEnded == true ? 0 : 1; - } - } - } else { - if (distFromLink < 200.0f) { - newAnimationIdx = 4; - this->actor.speedXZ = 6.0f; - } else if (distFromLink < 300.0f) { - newAnimationIdx = 3; - this->actor.speedXZ = 4.0f; - } else if (distFromLink < 400.0f) { - newAnimationIdx = 2; - this->actor.speedXZ = 2.0f; - this->unk_1F0 = 0; - } else { - this->actor.speedXZ = 0.0f; - if (this->animationIdx == 0) { - newAnimationIdx = animationEnded == true ? 1 : 0; - } else { - newAnimationIdx = animationEnded == true ? 0 : 1; - } - } - } - } else { - this->actor.speedXZ = 0.0f; - if (this->animationIdx == 0) { - newAnimationIdx = animationEnded == true ? 1 : 0; - } else { - newAnimationIdx = animationEnded == true ? 0 : 1; - } - } - } - - if ((this->animationIdx != newAnimationIdx) || (animationEnded == true)) { - this->animationIdx = newAnimationIdx; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), - this->skin.skelAnime.curFrame, Animation_GetLastFrame(sAnimations[this->animationIdx]), 2, - 0.0f); - } -} - -void func_80A6A4DC(EnHorseLinkChild* this) { - this->action = 5; - this->animationIdx = Rand_ZeroOne() > 0.5f ? 0 : 1; - DREG(53) = 0; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); -} - -void func_80A6A5A4(EnHorseLinkChild* this, GlobalContext* globalCtx) { - s16 yawDiff; - - if (DREG(53) != 0) { - DREG(53) = 0; - Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_80A6A724(this); - } else { - this->actor.speedXZ = 0.0f; - yawDiff = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; - // 0.7071 = cos(pi/4) - if ((Math_CosS(yawDiff) < 0.7071f) && (this->animationIdx == 2)) { - func_8006DD9C(&this->actor, &GET_PLAYER(globalCtx)->actor.world.pos, 300); - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - if (Math_CosS(yawDiff) < 0.0f) { - this->animationIdx = 2; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], D_80A6AF64[this->animationIdx], - 0.0f, Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); - } else { - func_80A6A4DC(this); - } - } - } -} - -void func_80A6A724(EnHorseLinkChild* this) { - this->timer = 0; - this->action = 4; - this->animationIdx = 2; - this->unk_1E8 = false; - this->actor.speedXZ = 2.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); -} - -void func_80A6A7D0(EnHorseLinkChild* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 dist; - s32 newAnimationIdx; - - this->timer++; - if (this->timer > 300) { - this->unk_1E8 = true; - } - - if ((this->animationIdx == 4) || (this->animationIdx == 3) || (this->animationIdx == 2)) { - if (!this->unk_1E8) { - func_8006DD9C(&this->actor, &player->actor.world.pos, 300); - } else { - func_8006DD9C(&this->actor, &this->actor.home.pos, 300); - } - } - - if (SkelAnime_Update(&this->skin.skelAnime)) { - if (!this->unk_1E8) { - dist = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor); - } else { - dist = Math3D_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos); - } - - if (!this->unk_1E8) { - if (dist >= 300.0f) { - newAnimationIdx = 4; - this->actor.speedXZ = 6.0f; - } else if (dist >= 150.0f) { - newAnimationIdx = 3; - this->actor.speedXZ = 4.0f; - } else { - newAnimationIdx = 2; - this->actor.speedXZ = 2.0f; - this->unk_1F0 = 0; - } - } else { - if (dist >= 300.0f) { - newAnimationIdx = 4; - this->actor.speedXZ = 6.0f; - } else if (dist >= 150.0f) { - newAnimationIdx = 3; - this->actor.speedXZ = 4.0f; - } else if (dist >= 70.0f) { - newAnimationIdx = 2; - this->actor.speedXZ = 2.0f; - this->unk_1F0 = 0; - } else { - func_80A6A4DC(this); - return; - } - } - - if (this->animationIdx != newAnimationIdx) { - this->animationIdx = newAnimationIdx; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -5.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A695A4(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); - } - } -} - -static EnHorseLinkChildActionFunc sActionFuncs[] = { - func_80A698F4, func_80A69C18, func_80A699FC, func_80A6A068, func_80A6A7D0, func_80A6A5A4, -}; - -static void* sEyeTextures[] = { gChildEponaEyeOpenTex, gChildEponaEyeHalfTex, gChildEponaEyeCloseTex }; -static u8 sEyeIndexOrder[] = { 0, 1, 2, 1 }; - -void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHorseLinkChild* this = (EnHorseLinkChild*)thisx; - s32 pad; - - sActionFuncs[this->action](this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D); - - if ((globalCtx->sceneNum == SCENE_SPOT20) && (this->actor.world.pos.z < -2400.0f)) { - this->actor.world.pos.z = -2400.0f; - } - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - - if ((Rand_ZeroOne() < 0.025f) && (this->eyeTexIndex == 0)) { - this->eyeTexIndex++; - } else if (this->eyeTexIndex > 0) { - this->eyeTexIndex++; - if (this->eyeTexIndex >= ARRAY_COUNT(sEyeIndexOrder)) { - this->eyeTexIndex = 0; - } - } - - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - func_80A6948C(this); -} - -void func_80A6ABF8(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { - Vec3f center; - Vec3f newCenter; - EnHorseLinkChild* this = (EnHorseLinkChild*)thisx; - s32 i; - - for (i = 0; i < this->headCollider.count; i++) { - center.x = this->headCollider.elements[i].dim.modelSphere.center.x; - center.y = this->headCollider.elements[i].dim.modelSphere.center.y; - center.z = this->headCollider.elements[i].dim.modelSphere.center.z; - func_800A6408(skin, this->headCollider.elements[i].dim.limb, ¢er, &newCenter); - this->headCollider.elements[i].dim.worldSphere.center.x = newCenter.x; - this->headCollider.elements[i].dim.worldSphere.center.y = newCenter.y; - this->headCollider.elements[i].dim.worldSphere.center.z = newCenter.z; - this->headCollider.elements[i].dim.worldSphere.radius = - this->headCollider.elements[i].dim.modelSphere.radius * this->headCollider.elements[i].dim.scale; - } - - //! @bug see relevant comment in `EnHorse_SkinCallback1` - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); -} - -s32 func_80A6AD84(Actor* thisx, GlobalContext* globalCtx, s32 arg2, PSkinAwb* arg3) { - EnHorseLinkChild* this = (EnHorseLinkChild*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_link_child.c", 1467); - - if (arg2 == 0xD) { - u8 index = sEyeIndexOrder[this->eyeTexIndex]; - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[index])); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_link_child.c", 1479); - - return 1; -} - -void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHorseLinkChild* this = (EnHorseLinkChild*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - func_800A6360(&this->actor, globalCtx, &this->skin, func_80A6ABF8, func_80A6AD84, 1); -} diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.cpp b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.cpp new file mode 100644 index 000000000..926959eb4 --- /dev/null +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.cpp @@ -0,0 +1,638 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_LINK_CHILD_Z_EN_HORSE_LINK_CHILD_C +#include "actor_common.h" +/* + * File: z_en_horse_link_child.c + * Overlay: ovl_En_Horse_Link_Child + * Description: Young Epona + */ + +#include "z_en_horse_link_child.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_horse.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin.h" +#include "def/z_skin_awb.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_25) + +void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A69B7C(EnHorseLinkChild* pthis); +void func_80A69EC0(EnHorseLinkChild* pthis); +void func_80A6A4DC(EnHorseLinkChild* pthis); +void func_80A6A724(EnHorseLinkChild* pthis); + +ActorInit En_Horse_Link_Child_InitVars = { + ACTOR_EN_HORSE_LINK_CHILD, + ACTORCAT_BG, + FLAGS, + OBJECT_HORSE_LINK_CHILD, + sizeof(EnHorseLinkChild), + (ActorFunc)EnHorseLinkChild_Init, + (ActorFunc)EnHorseLinkChild_Destroy, + (ActorFunc)EnHorseLinkChild_Update, + (ActorFunc)EnHorseLinkChild_Draw, +}; + +static AnimationHeader* sAnimations[] = { + &gChildEponaIdleAnim, &gChildEponaWhinnyAnim, &gChildEponaWalkingAnim, + &gChildEponaTrottingAnim, &gChildEponaGallopingAnim, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 100, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 13, { { 0, 0, 0 }, 10 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementInit, +}; + +static CollisionCheckInfoInit sColCheckInfoInit = { 10, 35, 100, MASS_HEAVY }; + +void func_80A693D0(EnHorseLinkChild* pthis) { + static s32 D_80A6AF5C[] = { 1, 19 }; + + if ((pthis->skin.skelAnime.curFrame > D_80A6AF5C[pthis->unk_1F0]) && + !((pthis->unk_1F0 == 0) && (pthis->skin.skelAnime.curFrame > D_80A6AF5C[1]))) { + Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_WALK, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->unk_1F0++; + if (pthis->unk_1F0 >= ARRAY_COUNT(D_80A6AF5C)) { + pthis->unk_1F0 = 0; + } + } +} + +void func_80A6948C(EnHorseLinkChild* pthis) { + if (pthis->animationIdx == 2) { + func_80A693D0(pthis); + } else if (pthis->skin.skelAnime.curFrame == 0.0f) { + if ((pthis->animationIdx == 3) || (pthis->animationIdx == 4)) { + Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (pthis->animationIdx == 1) { + if (Rand_ZeroOne() > 0.5f) { + Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_GROAN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else { + Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + } +} + +static f32 D_80A6AF64[] = { 1.0f, 1.0f, 1.5f, 1.5f, 1.5f }; + +f32 func_80A695A4(EnHorseLinkChild* pthis) { + f32 result; + + if (pthis->animationIdx == 2) { + result = D_80A6AF64[pthis->animationIdx] * pthis->actor.speedXZ * (1.0f / 2.0f); + } else if (pthis->animationIdx == 3) { + result = D_80A6AF64[pthis->animationIdx] * pthis->actor.speedXZ * (1.0f / 3.0f); + } else if (pthis->animationIdx == 4) { + result = D_80A6AF64[pthis->animationIdx] * pthis->actor.speedXZ * (1.0f / 5.0f); + } else { + result = D_80A6AF64[pthis->animationIdx]; + } + + return result; +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), +}; + +void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* pthis = (EnHorseLinkChild*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.005f); + pthis->actor.gravity = -3.5f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + pthis->actor.speedXZ = 0.0f; + pthis->action = 1; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + func_800A663C(globalCtx, &pthis->skin, &gChildEponaSkel, &gChildEponaGallopingAnim); + pthis->animationIdx = 0; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[0]); + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinderType1(globalCtx, &pthis->bodyCollider, &pthis->actor, &sCylinderInit); + Collider_InitJntSph(globalCtx, &pthis->headCollider); + Collider_SetJntSph(globalCtx, &pthis->headCollider, &pthis->actor, &sJntSphInit, pthis->headElements); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColCheckInfoInit); + pthis->unk_1F0 = 0; + pthis->eyeTexIndex = 0; + + if (gSaveContext.sceneSetupIndex > 3) { + func_80A69EC0(pthis); + } else if (globalCtx->sceneNum == SCENE_SPOT20) { + if (!Flags_GetEventChkInf(0x14)) { + Actor_Kill(&pthis->actor); + return; + } + pthis->unk_2A0 = gSaveContext.eventChkInf[1] & 0x40; + func_80A69EC0(pthis); + } else { + func_80A69EC0(pthis); + } + + pthis->actor.home.rot.z = pthis->actor.world.rot.z = pthis->actor.shape.rot.z = 0; +} + +void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* pthis = (EnHorseLinkChild*)thisx; + + func_800A6888(globalCtx, &pthis->skin); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyJntSph(globalCtx, &pthis->headCollider); +} + +void func_80A6988C(EnHorseLinkChild* pthis) { + pthis->action = 0; + pthis->animationIdx++; + if (pthis->animationIdx >= ARRAY_COUNT(sAnimations)) { + pthis->animationIdx = 0; + } + + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); + pthis->skin.skelAnime.playSpeed = func_80A695A4(pthis); +} + +void func_80A698F4(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + func_80A6988C(pthis); + } +} + +void func_80A6993C(EnHorseLinkChild* pthis, s32 newAnimationIdx) { + pthis->action = 2; + pthis->actor.speedXZ = 0.0f; + + if (!((newAnimationIdx == 0) || (newAnimationIdx == 1))) { + newAnimationIdx = 0; + } + + if (pthis->animationIdx != newAnimationIdx) { + pthis->animationIdx = newAnimationIdx; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); + } +} + +void func_80A699FC(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + f32 distFromLink; + s32 newAnimationIdx; + + distFromLink = Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if ((distFromLink < 1000.0f) && (distFromLink > 70.0f)) { + func_80A69B7C(pthis); + } else { + newAnimationIdx = pthis->animationIdx == 1 ? 0 : 1; + if (pthis->animationIdx != newAnimationIdx) { + pthis->animationIdx = newAnimationIdx; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0); + } + } + } +} + +void func_80A69B7C(EnHorseLinkChild* pthis) { + pthis->action = 1; + pthis->animationIdx = 0; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); +} + +void func_80A69C18(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + f32 distFromLink; + s32 newAnimationIdx; + + if ((pthis->animationIdx == 4) || (pthis->animationIdx == 3) || (pthis->animationIdx == 2)) { + yawDiff = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.world.rot.y; + + if (yawDiff > 0x12C) { + pthis->actor.world.rot.y += 0x12C; + } else if (yawDiff < -0x12C) { + pthis->actor.world.rot.y -= 0x12C; + } else { + pthis->actor.world.rot.y += yawDiff; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + distFromLink = Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + + if (distFromLink > 1000.0f) { + func_80A6993C(pthis, 0); + return; + } else if ((distFromLink < 1000.0f) && (distFromLink >= 300.0f)) { + newAnimationIdx = 4; + pthis->actor.speedXZ = 6.0f; + } else if ((distFromLink < 300.0f) && (distFromLink >= 150.0f)) { + newAnimationIdx = 3; + pthis->actor.speedXZ = 4.0f; + } else if ((distFromLink < 150.0f) && (distFromLink >= 70.0f)) { + newAnimationIdx = 2; + pthis->actor.speedXZ = 2.0f; + pthis->unk_1F0 = 0; + } else { + func_80A6993C(pthis, 1); + return; + } + + if (pthis->animationIdx != newAnimationIdx) { + pthis->animationIdx = newAnimationIdx; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_80A69EC0(EnHorseLinkChild* pthis) { + pthis->action = 3; + pthis->animationIdx = 0; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); +} + +void func_80A69F5C(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + Player* player; + s16 yawDiff; + s32 yawSign; + s32 yawOffset; + + if ((pthis->animationIdx == 4) || (pthis->animationIdx == 3) || (pthis->animationIdx == 2)) { + player = GET_PLAYER(globalCtx); + + if (Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &pthis->actor.home.pos) < 250.0f) { + yawDiff = player->actor.shape.rot.y; + yawSign = Actor_WorldYawTowardActor(&pthis->actor, &player->actor) > 0 ? 1 : -1; + yawOffset = yawSign << 0xE; + yawDiff += yawOffset; + } else { + yawDiff = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos) - pthis->actor.world.rot.y; + } + + if (yawDiff > 0x12C) { + pthis->actor.world.rot.y += 0x12C; + } else if (yawDiff < -0x12C) { + pthis->actor.world.rot.y -= 0x12C; + } else { + pthis->actor.world.rot.y += yawDiff; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } +} + +void func_80A6A068(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + Player* player; + f32 distFromLink; + s32 animationEnded; + s32 newAnimationIdx; + f32 distFromHome; + f32 distLinkFromHome; + + func_80A69F5C(pthis, globalCtx); + player = GET_PLAYER(globalCtx); + distFromLink = Actor_WorldDistXZToActor(&pthis->actor, &player->actor); + + if (gSaveContext.entranceIndex == 0x2AE) { + Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_80A6A724(pthis); + return; + } + + if (((gSaveContext.eventChkInf[1] & 0x40) && (DREG(53) != 0)) || + ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.cutsceneIndex == 0xFFF1))) { + func_80A6A4DC(pthis); + } else { + pthis->unk_2A0 = gSaveContext.eventChkInf[1] & 0x40; + } + + newAnimationIdx = pthis->animationIdx; + animationEnded = SkelAnime_Update(&pthis->skin.skelAnime); + if (animationEnded || (pthis->animationIdx == 1) || (pthis->animationIdx == 0)) { + if (gSaveContext.eventChkInf[1] & 0x20) { + distFromHome = Math3D_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->actor.home.pos); + distLinkFromHome = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &pthis->actor.home.pos); + if (distLinkFromHome > 250.0f) { + if (distFromHome >= 300.0f) { + newAnimationIdx = 4; + pthis->actor.speedXZ = 6.0f; + } else if ((distFromHome < 300.0f) && (distFromHome >= 150.0f)) { + newAnimationIdx = 3; + pthis->actor.speedXZ = 4.0f; + } else if ((distFromHome < 150.0f) && (distFromHome >= 70.0f)) { + newAnimationIdx = 2; + pthis->actor.speedXZ = 2.0f; + pthis->unk_1F0 = 0; + } else { + pthis->actor.speedXZ = 0.0f; + if (pthis->animationIdx == 0) { + newAnimationIdx = animationEnded == true ? 1 : 0; + } else { + newAnimationIdx = animationEnded == true ? 0 : 1; + } + } + } else { + if (distFromLink < 200.0f) { + newAnimationIdx = 4; + pthis->actor.speedXZ = 6.0f; + } else if (distFromLink < 300.0f) { + newAnimationIdx = 3; + pthis->actor.speedXZ = 4.0f; + } else if (distFromLink < 400.0f) { + newAnimationIdx = 2; + pthis->actor.speedXZ = 2.0f; + pthis->unk_1F0 = 0; + } else { + pthis->actor.speedXZ = 0.0f; + if (pthis->animationIdx == 0) { + newAnimationIdx = animationEnded == true ? 1 : 0; + } else { + newAnimationIdx = animationEnded == true ? 0 : 1; + } + } + } + } else { + pthis->actor.speedXZ = 0.0f; + if (pthis->animationIdx == 0) { + newAnimationIdx = animationEnded == true ? 1 : 0; + } else { + newAnimationIdx = animationEnded == true ? 0 : 1; + } + } + } + + if ((pthis->animationIdx != newAnimationIdx) || (animationEnded == true)) { + pthis->animationIdx = newAnimationIdx; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), + pthis->skin.skelAnime.curFrame, Animation_GetLastFrame(sAnimations[pthis->animationIdx]), 2, + 0.0f); + } +} + +void func_80A6A4DC(EnHorseLinkChild* pthis) { + pthis->action = 5; + pthis->animationIdx = Rand_ZeroOne() > 0.5f ? 0 : 1; + DREG(53) = 0; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void func_80A6A5A4(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + + if (DREG(53) != 0) { + DREG(53) = 0; + Audio_PlaySoundGeneral(NA_SE_EV_KID_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_80A6A724(pthis); + } else { + pthis->actor.speedXZ = 0.0f; + yawDiff = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.world.rot.y; + // 0.7071 = cos(pi/4) + if ((Math_CosS(yawDiff) < 0.7071f) && (pthis->animationIdx == 2)) { + func_8006DD9C(&pthis->actor, &GET_PLAYER(globalCtx)->actor.world.pos, 300); + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if (Math_CosS(yawDiff) < 0.0f) { + pthis->animationIdx = 2; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], D_80A6AF64[pthis->animationIdx], + 0.0f, Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); + } else { + func_80A6A4DC(pthis); + } + } + } +} + +void func_80A6A724(EnHorseLinkChild* pthis) { + pthis->timer = 0; + pthis->action = 4; + pthis->animationIdx = 2; + pthis->unk_1E8 = false; + pthis->actor.speedXZ = 2.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); +} + +void func_80A6A7D0(EnHorseLinkChild* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dist; + s32 newAnimationIdx; + + pthis->timer++; + if (pthis->timer > 300) { + pthis->unk_1E8 = true; + } + + if ((pthis->animationIdx == 4) || (pthis->animationIdx == 3) || (pthis->animationIdx == 2)) { + if (!pthis->unk_1E8) { + func_8006DD9C(&pthis->actor, &player->actor.world.pos, 300); + } else { + func_8006DD9C(&pthis->actor, &pthis->actor.home.pos, 300); + } + } + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + if (!pthis->unk_1E8) { + dist = Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor); + } else { + dist = Math3D_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->actor.home.pos); + } + + if (!pthis->unk_1E8) { + if (dist >= 300.0f) { + newAnimationIdx = 4; + pthis->actor.speedXZ = 6.0f; + } else if (dist >= 150.0f) { + newAnimationIdx = 3; + pthis->actor.speedXZ = 4.0f; + } else { + newAnimationIdx = 2; + pthis->actor.speedXZ = 2.0f; + pthis->unk_1F0 = 0; + } + } else { + if (dist >= 300.0f) { + newAnimationIdx = 4; + pthis->actor.speedXZ = 6.0f; + } else if (dist >= 150.0f) { + newAnimationIdx = 3; + pthis->actor.speedXZ = 4.0f; + } else if (dist >= 70.0f) { + newAnimationIdx = 2; + pthis->actor.speedXZ = 2.0f; + pthis->unk_1F0 = 0; + } else { + func_80A6A4DC(pthis); + return; + } + } + + if (pthis->animationIdx != newAnimationIdx) { + pthis->animationIdx = newAnimationIdx; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A695A4(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); + } + } +} + +static EnHorseLinkChildActionFunc sActionFuncs[] = { + func_80A698F4, func_80A69C18, func_80A699FC, func_80A6A068, func_80A6A7D0, func_80A6A5A4, +}; + +static void* sEyeTextures[] = { gChildEponaEyeOpenTex, gChildEponaEyeHalfTex, gChildEponaEyeCloseTex }; +static u8 sEyeIndexOrder[] = { 0, 1, 2, 1 }; + +void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* pthis = (EnHorseLinkChild*)thisx; + s32 pad; + + sActionFuncs[pthis->action](pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 55.0f, 100.0f, 0x1D); + + if ((globalCtx->sceneNum == SCENE_SPOT20) && (pthis->actor.world.pos.z < -2400.0f)) { + pthis->actor.world.pos.z = -2400.0f; + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (pthis->eyeTexIndex == 0)) { + pthis->eyeTexIndex++; + } else if (pthis->eyeTexIndex > 0) { + pthis->eyeTexIndex++; + if (pthis->eyeTexIndex >= ARRAY_COUNT(sEyeIndexOrder)) { + pthis->eyeTexIndex = 0; + } + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + func_80A6948C(pthis); +} + +void func_80A6ABF8(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { + Vec3f center; + Vec3f newCenter; + EnHorseLinkChild* pthis = (EnHorseLinkChild*)thisx; + s32 i; + + for (i = 0; i < pthis->headCollider.count; i++) { + center.x = pthis->headCollider.elements[i].dim.modelSphere.center.x; + center.y = pthis->headCollider.elements[i].dim.modelSphere.center.y; + center.z = pthis->headCollider.elements[i].dim.modelSphere.center.z; + func_800A6408(skin, pthis->headCollider.elements[i].dim.limb, ¢er, &newCenter); + pthis->headCollider.elements[i].dim.worldSphere.center.x = newCenter.x; + pthis->headCollider.elements[i].dim.worldSphere.center.y = newCenter.y; + pthis->headCollider.elements[i].dim.worldSphere.center.z = newCenter.z; + pthis->headCollider.elements[i].dim.worldSphere.radius = + pthis->headCollider.elements[i].dim.modelSphere.radius * pthis->headCollider.elements[i].dim.scale; + } + + //! @bug see relevant comment in `EnHorse_SkinCallback1` + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->headCollider.base); +} + +s32 func_80A6AD84(Actor* thisx, GlobalContext* globalCtx, s32 arg2, PSkinAwb* arg3) { + EnHorseLinkChild* pthis = (EnHorseLinkChild*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_link_child.c", 1467); + + if (arg2 == 0xD) { + u8 index = sEyeIndexOrder[pthis->eyeTexIndex]; + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[index])); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_link_child.c", 1479); + + return 1; +} + +void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* pthis = (EnHorseLinkChild*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + func_800A6360(&pthis->actor, globalCtx, &pthis->skin, func_80A6ABF8, func_80A6AD84, 1); +} diff --git a/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c b/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c deleted file mode 100644 index b1bc22dee..000000000 --- a/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c +++ /dev/null @@ -1,730 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_NORMAL_Z_EN_HORSE_NORMAL_C -#include "actor_common.h" -/* - * File: z_en_horse_normal.c - * Overlay: ovl_En_Horse_Normal - * Description: Non-rideable horses (Lon Lon Ranch and Stable) - */ - -#include "z_en_horse_normal.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_horse_normal/object_horse_normal.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin.h" -#include "def/z_skin_awb.h" -#include "def/z_skin_matrix.h" - -#define FLAGS 0 - -typedef struct { - Vec3s pos; - u8 unk_06; // this may be a s16 if the always-0 following byte is actually not padding -} EnHorseNormalUnkStruct1; - -typedef struct { - s32 len; - EnHorseNormalUnkStruct1* items; -} EnHorseNormalUnkStruct2; - -typedef enum { - /* 0x00 */ HORSE_CYCLE_ANIMATIONS, - /* 0x01 */ HORSE_WANDER, - /* 0x02 */ HORSE_WAIT, - /* 0x03 */ HORSE_WAIT_CLONE, - /* 0x04 */ HORSE_FOLLOW_PATH -} EnHorseNormalAction; - -void EnHorseNormal_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorseNormal_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorseNormal_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorseNormal_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A6B91C(EnHorseNormal* this, GlobalContext* globalCtx); -void func_80A6BC48(EnHorseNormal* this); -void func_80A6BCEC(EnHorseNormal* this); -void func_80A6C4CC(EnHorseNormal* this); -void func_80A6C6B0(EnHorseNormal* this); - -const ActorInit En_Horse_Normal_InitVars = { - ACTOR_EN_HORSE_NORMAL, - ACTORCAT_BG, - FLAGS, - OBJECT_HORSE_NORMAL, - sizeof(EnHorseNormal), - (ActorFunc)EnHorseNormal_Init, - (ActorFunc)EnHorseNormal_Destroy, - (ActorFunc)EnHorseNormal_Update, - (ActorFunc)EnHorseNormal_Draw, -}; - -static AnimationHeader* sAnimations[] = { - &gHorseNormalIdleAnim, &gHorseNormalWhinnyAnim, &gHorseNormalRefuseAnim, - &gHorseNormalRearingAnim, &gHorseNormalWalkingAnim, &gHorseNormalTrottingAnim, - &gHorseNormalGallopingAnim, &gHorseNormalJumpingAnim, &gHorseNormalJumpingHighAnim, -}; - -static ColliderCylinderInit sCylinderInit1 = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 40, 100, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInit2 = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 60, 100, 0, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 11, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphElementsInit), - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; - -// Unused -static EnHorseNormalUnkStruct1 D_80A6D428[] = { - { { 1058, 1, 384 }, 7 }, { { 1653, 39, -381 }, 6 }, { { 1606, 1, -1048 }, 6 }, { { 1053, 1, -1620 }, 6 }, - { { -1012, 1, -1633 }, 7 }, { { -1655, 1, -918 }, 6 }, { { -1586, 1, -134 }, 6 }, { { -961, 1, 403 }, 7 }, -}; - -// Unused -static EnHorseNormalUnkStruct2 D_80A6D468 = { ARRAY_COUNT(D_80A6D428), D_80A6D428 }; - -// Unused -static EnHorseNormalUnkStruct1 D_80A6D470[] = { - { { 88, 0, 2078 }, 10 }, { { 2482, 376, 4631 }, 7 }, { { 2228, -28, 6605 }, 12 }, - { { 654, -100, 8864 }, 7 }, { { -297, -500, 10667 }, 12 }, { { -5303, -420, 10640 }, 10 }, - { { -6686, -500, 7760 }, 10 }, { { -5260, 100, 5411 }, 7 }, { { -3573, -269, 3893 }, 10 }, -}; - -// Unused -static EnHorseNormalUnkStruct2 D_80A6D4B8 = { ARRAY_COUNT(D_80A6D470), D_80A6D470 }; - -void func_80A6B250(EnHorseNormal* this) { - static s32 D_80A6D4C0[] = { 0, 16 }; - - if (D_80A6D4C0[this->unk_200] < this->skin.skelAnime.curFrame && - ((this->unk_200 != 0) || !(D_80A6D4C0[1] < this->skin.skelAnime.curFrame))) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_WALK, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->unk_200++; - if (this->unk_200 >= ARRAY_COUNT(D_80A6D4C0)) { - this->unk_200 = 0; - } - } -} - -f32 func_80A6B30C(EnHorseNormal* this) { - static f32 D_80A6D4C8[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.5f, 1.5f, 1.5f, 1.5f, 1.0f }; - f32 result; - - if (this->animationIdx == 4) { - result = D_80A6D4C8[this->animationIdx] * this->actor.speedXZ * (1 / 2.0f); - } else if (this->animationIdx == 5) { - result = D_80A6D4C8[this->animationIdx] * this->actor.speedXZ * (1 / 3.0f); - } else if (this->animationIdx == 6) { - result = D_80A6D4C8[this->animationIdx] * this->actor.speedXZ * (1 / 5.0f); - } else { - result = D_80A6D4C8[this->animationIdx]; - } - - return result; -} - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), -}; - -void EnHorseNormal_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHorseNormal* this = (EnHorseNormal*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.01f); - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->actor.speedXZ = 0.0f; - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - this->action = HORSE_CYCLE_ANIMATIONS; - this->animationIdx = 0; - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, &this->actor, &sCylinderInit1); - Collider_InitJntSph(globalCtx, &this->headCollider); - Collider_SetJntSph(globalCtx, &this->headCollider, &this->actor, &sJntSphInit, this->headElements); - Collider_InitCylinder(globalCtx, &this->cloneCollider); - Collider_SetCylinder(globalCtx, &this->cloneCollider, &this->actor, &sCylinderInit2); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (globalCtx->sceneNum == SCENE_SPOT20) { - if (this->actor.world.rot.z == 0 || gSaveContext.nightFlag) { - Actor_Kill(&this->actor); - return; - } - if (!LINK_IS_ADULT) { - if (Flags_GetEventChkInf(0x14)) { - if (this->actor.world.rot.z != 3) { - Actor_Kill(&this->actor); - return; - } - } else if (this->actor.world.rot.z != 1) { - Actor_Kill(&this->actor); - return; - } - } else if (Flags_GetEventChkInf(0x18) || (DREG(1) != 0)) { - if (this->actor.world.rot.z != 7) { - Actor_Kill(&this->actor); - return; - } - } else if (this->actor.world.rot.z != 5) { - Actor_Kill(&this->actor); - return; - } - this->actor.home.rot.z = this->actor.world.rot.z = this->actor.shape.rot.z = 0; - func_800A663C(globalCtx, &this->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); - if ((this->actor.world.pos.x == -730.0f && this->actor.world.pos.y == 0.0f && - this->actor.world.pos.z == -1100.0f) || - (this->actor.world.pos.x == 880.0f && this->actor.world.pos.y == 0.0f && - this->actor.world.pos.z == -1170.0f)) { - func_80A6C6B0(this); - return; - } - } else if (globalCtx->sceneNum == SCENE_MALON_STABLE) { - if (IS_DAY) { - Actor_Kill(&this->actor); - return; - } else { - func_800A663C(globalCtx, &this->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); - func_80A6C6B0(this); - return; - } - } else if (globalCtx->sceneNum == SCENE_SPOT12) { - if (this->actor.world.pos.x == 3707.0f && this->actor.world.pos.y == 1413.0f && - this->actor.world.pos.z == -665.0f) { - func_800A663C(globalCtx, &this->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); - func_80A6C4CC(this); - return; - } - func_800A663C(globalCtx, &this->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); - } else { - func_800A663C(globalCtx, &this->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); - } - if ((this->actor.params & 0xF0) == 0x10 && (this->actor.params & 0xF) != 0xF) { - func_80A6B91C(this, globalCtx); - } else { - func_80A6BC48(this); - } -} - -void EnHorseNormal_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHorseNormal* this = (EnHorseNormal*)thisx; - - func_800A6888(globalCtx, &this->skin); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyCylinder(globalCtx, &this->cloneCollider); - Collider_DestroyJntSph(globalCtx, &this->headCollider); -} - -void func_80A6B91C(EnHorseNormal* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_4; - this->action = HORSE_FOLLOW_PATH; - this->animationIdx = 6; - this->waypoint = 0; - this->actor.speedXZ = 7.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); -} - -void EnHorseNormal_FollowPath(EnHorseNormal* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->actor.params & 0xF]; - Vec3s* pointPos = SEGMENTED_TO_VIRTUAL(path->points); - f32 dx; - f32 dz; - s32 pad; - - pointPos += this->waypoint; - dx = pointPos->x - this->actor.world.pos.x; - dz = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 0xA, 0x7D0, 1); - this->actor.shape.rot.y = this->actor.world.rot.y; - if (SQ(dx) + SQ(dz) < 600.0f) { - this->waypoint++; - if (this->waypoint >= path->count) { - this->waypoint = 0; - } - } - this->skin.skelAnime.playSpeed = func_80A6B30C(this); - if (SkelAnime_Update(&this->skin.skelAnime)) { - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); - func_80A6BCEC(this); - } -} - -void EnHorseNormal_NextAnimation(EnHorseNormal* this) { - this->action = HORSE_CYCLE_ANIMATIONS; - this->animationIdx++; - - if (this->animationIdx >= ARRAY_COUNT(sAnimations)) { - this->animationIdx = 0; - } - - Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animationIdx]); -} - -void EnHorseNormal_CycleAnimations(EnHorseNormal* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - - if (SkelAnime_Update(&this->skin.skelAnime)) { - EnHorseNormal_NextAnimation(this); - } -} - -void func_80A6BC48(EnHorseNormal* this) { - this->action = HORSE_WANDER; - this->animationIdx = 0; - this->unk_21C = 0; - this->unk_21E = 0; - this->actor.speedXZ = 0.0f; - this->unk_218 = 0.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); -} - -void func_80A6BCEC(EnHorseNormal* this) { - if (this->animationIdx == 5) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (this->animationIdx == 6) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -void func_80A6BD7C(EnHorseNormal* this) { - f32 frame = this->skin.skelAnime.curFrame; - - if (this->animationIdx == 0 && frame > 28.0f && !(this->unk_1E4 & 1)) { - this->unk_1E4 |= 1; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (this->animationIdx == 3 && frame > 25.0f && !(this->unk_1E4 & 2)) { - this->unk_1E4 |= 2; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void EnHorseNormal_Wander(EnHorseNormal* this, GlobalContext* globalCtx) { - static s32 D_80A6D4F4[] = { 0, 1, 4, 5, 6, 2, 3 }; - static s32 D_80A6D510[] = { 0, 0, 2, 2, 1, 1, 1, 3, 3 }; - s32 phi_t0 = this->animationIdx; - s32 pad; - - switch (D_80A6D510[this->animationIdx]) { - case 0: - func_80A6BD7C(this); - this->actor.speedXZ = 0.0f; - this->unk_218 = 0.0f; - break; - case 1: - if (Rand_ZeroOne() < 0.1f) { - this->unk_218 = 2.0f * Rand_ZeroOne() - 1.0f; - } - this->actor.speedXZ += this->unk_218; - if (this->actor.speedXZ <= 0.0f) { - this->actor.speedXZ = 0.0f; - this->unk_218 = 0.0f; - phi_t0 = 0; - } else if (this->actor.speedXZ < 3.0f) { - func_80A6B250(this); - phi_t0 = 4; - } else if (this->actor.speedXZ < 6.0f) { - phi_t0 = 5; - } else if (this->actor.speedXZ < 8.0f) { - phi_t0 = 6; - } else { - this->actor.speedXZ = 8.0f; - phi_t0 = 6; - } - if (Rand_ZeroOne() < 0.1f || (this->unk_21E == 0 && ((this->actor.bgCheckFlags & 8) || - (this->bodyCollider.base.ocFlags1 & OC1_HIT) || - (this->headCollider.base.ocFlags1 & OC1_HIT)))) { - this->unk_21E += (Rand_ZeroOne() * 30.0f) - 15.0f; - if (this->unk_21E > 50) { - this->unk_21E = 50; - } else if (this->unk_21E < -50) { - this->unk_21E = -50; - } - } - this->unk_21C += this->unk_21E; - if (this->unk_21C < -300) { - this->unk_21C = -300; - } else if (this->unk_21C > 300) { - this->unk_21C = 300; - } else if (Rand_ZeroOne() < 0.25f && fabsf(this->unk_21C) < 100.0f) { - this->unk_21C = 0; - this->unk_21E = 0; - } - this->actor.world.rot.y += this->unk_21C; - this->actor.shape.rot.y = this->actor.world.rot.y; - break; - case 2: - case 3: - break; - } - - if (phi_t0 != this->animationIdx || SkelAnime_Update(&this->skin.skelAnime)) { - if (phi_t0 != this->animationIdx) { - this->animationIdx = phi_t0; - this->unk_1E4 &= ~1; - this->unk_1E4 &= ~2; - if (phi_t0 == 1) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (phi_t0 == 3) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - func_80A6BCEC(this); - } - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -3.0f); - } else { - switch (D_80A6D510[this->animationIdx]) { - case 0: - if (Rand_ZeroOne() < 0.25f) { - this->unk_218 = 1.0f; - phi_t0 = 4; - } else { - phi_t0 = D_80A6D4F4[(s32)(Rand_ZeroOne() * 2)]; - this->actor.speedXZ = 0.0f; - this->unk_218 = 0.0f; - } - break; - case 1: - case 2: - case 3: - break; - } - - this->unk_1E4 &= ~1; - this->unk_1E4 &= ~2; - if (phi_t0 == 1) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (phi_t0 == 3) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - func_80A6BCEC(this); - } - if (phi_t0 != this->animationIdx) { - this->animationIdx = phi_t0; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, -3.0f); - } else { - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); - } - } - } -} - -void func_80A6C4CC(EnHorseNormal* this) { - this->action = HORSE_WAIT; - this->animationIdx = 0; - this->unk_21C = 0; - this->unk_21E = 0; - this->actor.speedXZ = 0.0f; - this->unk_218 = 0.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); -} - -void EnHorseNormal_Wait(EnHorseNormal* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skin.skelAnime)) { - f32 rand = Rand_ZeroOne(); - - if (rand < 0.4f) { - this->animationIdx = 0; - } else if (rand < 0.8f) { - this->animationIdx = 1; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - this->animationIdx = 3; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); - } -} - -void func_80A6C6B0(EnHorseNormal* this) { - this->action = HORSE_WAIT_CLONE; - this->animationIdx = 0; - this->unk_21C = 0; - this->unk_21E = 0; - this->actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - this->actor.speedXZ = 0.0f; - this->unk_218 = 0.0f; - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); -} - -void EnHorseNormal_WaitClone(EnHorseNormal* this, GlobalContext* globalCtx) { - func_80A6BD7C(this); - - if (SkelAnime_Update(&this->skin.skelAnime)) { - f32 rand = Rand_ZeroOne(); - - if (rand < 0.4f) { - this->animationIdx = 0; - } else if (rand < 0.8f) { - this->animationIdx = 1; - this->unk_1E4 |= 0x20; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - this->animationIdx = 3; - this->unk_1E4 |= 0x20; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - - Animation_Change(&this->skin.skelAnime, sAnimations[this->animationIdx], func_80A6B30C(this), 0.0f, - Animation_GetLastFrame(sAnimations[this->animationIdx]), ANIMMODE_ONCE, 0.0f); - - this->unk_1E4 &= ~1; - this->unk_1E4 &= ~2; - this->unk_1E4 &= ~8; - this->unk_1E4 &= ~0x10; - } -} - -void func_80A6C8E0(EnHorseNormal* this, GlobalContext* globalCtx) { - s32 pad; - CollisionPoly* sp38; - s32 pad2; - Vec3f sp28; - s32 sp24; - - sp28.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x; - sp28.y = this->actor.world.pos.y + 60.0f; - sp28.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; - this->unk_220 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp38, &sp24, &sp28); - this->actor.shape.rot.x = Math_FAtan2F(this->actor.world.pos.y - this->unk_220, 30.0f) * (0x8000 / M_PI); -} - -static EnHorseNormalActionFunc sActionFuncs[] = { - EnHorseNormal_CycleAnimations, EnHorseNormal_Wander, EnHorseNormal_Wait, - EnHorseNormal_WaitClone, EnHorseNormal_FollowPath, -}; - -void EnHorseNormal_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHorseNormal* this = (EnHorseNormal*)thisx; - s32 pad; - - sActionFuncs[this->action](this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 35.0f, 100.0f, 0x1D); - if (globalCtx->sceneNum == SCENE_SPOT20 && this->actor.world.pos.z < -2400.0f) { - this->actor.world.pos.z = -2400.0f; - } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - this->unk_204 = this->actor.projectedPos; - this->unk_204.y += 120.0f; - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - if (this->actor.speedXZ == 0.0f) { - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - } else { - this->actor.colChkInfo.mass = MASS_HEAVY; - } -} - -void func_80A6CAFC(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { - Vec3f sp4C; - Vec3f sp40; - EnHorseNormal* this = (EnHorseNormal*)thisx; - s32 i; - - for (i = 0; i < this->headCollider.count; i++) { - sp4C.x = this->headCollider.elements[i].dim.modelSphere.center.x; - sp4C.y = this->headCollider.elements[i].dim.modelSphere.center.y; - sp4C.z = this->headCollider.elements[i].dim.modelSphere.center.z; - func_800A6408(skin, this->headCollider.elements[i].dim.limb, &sp4C, &sp40); - this->headCollider.elements[i].dim.worldSphere.center.x = sp40.x; - this->headCollider.elements[i].dim.worldSphere.center.y = sp40.y; - this->headCollider.elements[i].dim.worldSphere.center.z = sp40.z; - this->headCollider.elements[i].dim.worldSphere.radius = - this->headCollider.elements[i].dim.modelSphere.radius * this->headCollider.elements[i].dim.scale; - } - - //! @bug see relevant comment in `EnHorse_SkinCallback1` - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); -} - -void func_80A6CC88(GlobalContext* globalCtx, EnHorseNormal* this, Vec3f* arg2) { - f32 curFrame = this->skin.skelAnime.curFrame; - f32 wDest; - - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &this->unk_1E8, &wDest); - this->unk_1F4 = this->unk_1E8; - this->unk_1F4.y += 120.0f; - - if (this->animationIdx == 0 && curFrame > 28.0f && !(this->unk_1E4 & 8)) { - this->unk_1E4 |= 8; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &this->unk_1E8, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (this->animationIdx == 3 && curFrame > 25.0f && !(this->unk_1E4 & 0x10)) { - this->unk_1E4 |= 0x10; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &this->unk_1E8, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (this->animationIdx == 3 && this->unk_1E4 & 0x20) { - this->unk_1E4 &= ~0x20; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->unk_1F4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (this->animationIdx == 1 && this->unk_1E4 & 0x20) { - this->unk_1E4 &= ~0x20; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->unk_1F4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -void EnHorseNormal_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHorseNormal* this = (EnHorseNormal*)thisx; - Mtx* mtx2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_normal.c", 2224); - - if (globalCtx->sceneNum != SCENE_SPOT20 || globalCtx->sceneNum != SCENE_MALON_STABLE) { - func_80A6C8E0(this, globalCtx); - } - func_80093D18(globalCtx->state.gfxCtx); - func_800A6330(&this->actor, globalCtx, &this->skin, func_80A6CAFC, 1); - - if (this->action == HORSE_WAIT_CLONE) { - MtxF skinMtx; - Mtx* mtx1; - Vec3f clonePos = { 0.0f, 0.0f, 0.0f }; - s16 cloneRotY; - f32 distFromGround = this->actor.world.pos.y - this->actor.floorHeight; - f32 temp_f0_4; - - if (globalCtx->sceneNum == SCENE_MALON_STABLE) { - if (this->actor.world.pos.x == 355.0f && this->actor.world.pos.y == 0.0f && - this->actor.world.pos.z == -245.0f) { - clonePos.x = 235.0f; - clonePos.y = 0.0f; - clonePos.z = 100.0f; - cloneRotY = 0x7FFF; - } else if (this->actor.world.pos.x == 238.0f && this->actor.world.pos.y == 0.0f && - this->actor.world.pos.z == -245.0f) { - clonePos.x = 478.0f; - clonePos.y = 0.0f; - clonePos.z = 100.0f; - cloneRotY = 0x7FFF; - } - } else if (globalCtx->sceneNum == SCENE_SPOT20) { - if (this->actor.world.pos.x == -730.0f && this->actor.world.pos.y == 0.0f && - this->actor.world.pos.z == -1100.0f) { - clonePos.x = 780.0f; - clonePos.y = 0.0f; - clonePos.z = -80.0f; - cloneRotY = 0; - } else if (this->actor.world.pos.x == 880.0f && this->actor.world.pos.y == 0.0f && - this->actor.world.pos.z == -1170.0f) { - clonePos.x = -1000.0f; - clonePos.y = 0.0f; - clonePos.z = -70.0f; - cloneRotY = 0; - } - } - func_80A6CC88(globalCtx, this, &clonePos); - SkinMatrix_SetTranslateRotateYXZScale(&skinMtx, this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, - this->actor.shape.rot.x, cloneRotY, this->actor.shape.rot.z, clonePos.x, - (this->actor.shape.yOffset * this->actor.scale.y) + clonePos.y, - clonePos.z); - mtx1 = SkinMatrix_MtxFToNewMtx(globalCtx->state.gfxCtx, &skinMtx); - if (mtx1 == NULL) { - return; - } - gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPMatrix(POLY_OPA_DISP++, mtx1, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_800A63CC(&this->actor, globalCtx, &this->skin, NULL, NULL, 1, 0, 3); - this->cloneCollider.dim.pos.x = clonePos.x; - this->cloneCollider.dim.pos.y = clonePos.y; - this->cloneCollider.dim.pos.z = clonePos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cloneCollider.base); - func_80094044(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); - Matrix_Translate(clonePos.x, clonePos.y, clonePos.z, MTXMODE_NEW); - temp_f0_4 = (1.0f - (distFromGround * 0.01f)) * this->actor.shape.shadowScale; - Matrix_Scale(this->actor.scale.x * temp_f0_4, 1.0f, this->actor.scale.z * temp_f0_4, MTXMODE_APPLY); - Matrix_RotateY(cloneRotY * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); - mtx2 = Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_horse_normal.c", 2329); - if (mtx2 != NULL) { - gSPMatrix(POLY_XLU_DISP++, mtx2, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gHorseShadowDL); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_normal.c", 2339); -} diff --git a/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.cpp b/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.cpp new file mode 100644 index 000000000..fd95900c6 --- /dev/null +++ b/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.cpp @@ -0,0 +1,730 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_NORMAL_Z_EN_HORSE_NORMAL_C +#include "actor_common.h" +/* + * File: z_en_horse_normal.c + * Overlay: ovl_En_Horse_Normal + * Description: Non-rideable horses (Lon Lon Ranch and Stable) + */ + +#include "z_en_horse_normal.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_horse_normal/object_horse_normal.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin.h" +#include "def/z_skin_awb.h" +#include "def/z_skin_matrix.h" + +#define FLAGS 0 + +typedef struct { + Vec3s pos; + u8 unk_06; // pthis may be a s16 if the always-0 following byte is actually not padding +} EnHorseNormalUnkStruct1; + +typedef struct { + s32 len; + EnHorseNormalUnkStruct1* items; +} EnHorseNormalUnkStruct2; + +typedef enum { + /* 0x00 */ HORSE_CYCLE_ANIMATIONS, + /* 0x01 */ HORSE_WANDER, + /* 0x02 */ HORSE_WAIT, + /* 0x03 */ HORSE_WAIT_CLONE, + /* 0x04 */ HORSE_FOLLOW_PATH +} EnHorseNormalAction; + +void EnHorseNormal_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHorseNormal_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHorseNormal_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHorseNormal_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A6B91C(EnHorseNormal* pthis, GlobalContext* globalCtx); +void func_80A6BC48(EnHorseNormal* pthis); +void func_80A6BCEC(EnHorseNormal* pthis); +void func_80A6C4CC(EnHorseNormal* pthis); +void func_80A6C6B0(EnHorseNormal* pthis); + +ActorInit En_Horse_Normal_InitVars = { + ACTOR_EN_HORSE_NORMAL, + ACTORCAT_BG, + FLAGS, + OBJECT_HORSE_NORMAL, + sizeof(EnHorseNormal), + (ActorFunc)EnHorseNormal_Init, + (ActorFunc)EnHorseNormal_Destroy, + (ActorFunc)EnHorseNormal_Update, + (ActorFunc)EnHorseNormal_Draw, +}; + +static AnimationHeader* sAnimations[] = { + &gHorseNormalIdleAnim, &gHorseNormalWhinnyAnim, &gHorseNormalRefuseAnim, + &gHorseNormalRearingAnim, &gHorseNormalWalkingAnim, &gHorseNormalTrottingAnim, + &gHorseNormalGallopingAnim, &gHorseNormalJumpingAnim, &gHorseNormalJumpingHighAnim, +}; + +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 40, 100, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 60, 100, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 11, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; + +// Unused +static EnHorseNormalUnkStruct1 D_80A6D428[] = { + { { 1058, 1, 384 }, 7 }, { { 1653, 39, -381 }, 6 }, { { 1606, 1, -1048 }, 6 }, { { 1053, 1, -1620 }, 6 }, + { { -1012, 1, -1633 }, 7 }, { { -1655, 1, -918 }, 6 }, { { -1586, 1, -134 }, 6 }, { { -961, 1, 403 }, 7 }, +}; + +// Unused +static EnHorseNormalUnkStruct2 D_80A6D468 = { ARRAY_COUNT(D_80A6D428), D_80A6D428 }; + +// Unused +static EnHorseNormalUnkStruct1 D_80A6D470[] = { + { { 88, 0, 2078 }, 10 }, { { 2482, 376, 4631 }, 7 }, { { 2228, -28, 6605 }, 12 }, + { { 654, -100, 8864 }, 7 }, { { -297, -500, 10667 }, 12 }, { { -5303, -420, 10640 }, 10 }, + { { -6686, -500, 7760 }, 10 }, { { -5260, 100, 5411 }, 7 }, { { -3573, -269, 3893 }, 10 }, +}; + +// Unused +static EnHorseNormalUnkStruct2 D_80A6D4B8 = { ARRAY_COUNT(D_80A6D470), D_80A6D470 }; + +void func_80A6B250(EnHorseNormal* pthis) { + static s32 D_80A6D4C0[] = { 0, 16 }; + + if (D_80A6D4C0[pthis->unk_200] < pthis->skin.skelAnime.curFrame && + ((pthis->unk_200 != 0) || !(D_80A6D4C0[1] < pthis->skin.skelAnime.curFrame))) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_WALK, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->unk_200++; + if (pthis->unk_200 >= ARRAY_COUNT(D_80A6D4C0)) { + pthis->unk_200 = 0; + } + } +} + +f32 func_80A6B30C(EnHorseNormal* pthis) { + static f32 D_80A6D4C8[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.5f, 1.5f, 1.5f, 1.5f, 1.0f }; + f32 result; + + if (pthis->animationIdx == 4) { + result = D_80A6D4C8[pthis->animationIdx] * pthis->actor.speedXZ * (1 / 2.0f); + } else if (pthis->animationIdx == 5) { + result = D_80A6D4C8[pthis->animationIdx] * pthis->actor.speedXZ * (1 / 3.0f); + } else if (pthis->animationIdx == 6) { + result = D_80A6D4C8[pthis->animationIdx] * pthis->actor.speedXZ * (1 / 5.0f); + } else { + result = D_80A6D4C8[pthis->animationIdx]; + } + + return result; +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), +}; + +void EnHorseNormal_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseNormal* pthis = (EnHorseNormal*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.gravity = -3.5f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + pthis->action = HORSE_CYCLE_ANIMATIONS; + pthis->animationIdx = 0; + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, &pthis->actor, &sCylinderInit1); + Collider_InitJntSph(globalCtx, &pthis->headCollider); + Collider_SetJntSph(globalCtx, &pthis->headCollider, &pthis->actor, &sJntSphInit, pthis->headElements); + Collider_InitCylinder(globalCtx, &pthis->cloneCollider); + Collider_SetCylinder(globalCtx, &pthis->cloneCollider, &pthis->actor, &sCylinderInit2); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + if (globalCtx->sceneNum == SCENE_SPOT20) { + if (pthis->actor.world.rot.z == 0 || gSaveContext.nightFlag) { + Actor_Kill(&pthis->actor); + return; + } + if (!LINK_IS_ADULT) { + if (Flags_GetEventChkInf(0x14)) { + if (pthis->actor.world.rot.z != 3) { + Actor_Kill(&pthis->actor); + return; + } + } else if (pthis->actor.world.rot.z != 1) { + Actor_Kill(&pthis->actor); + return; + } + } else if (Flags_GetEventChkInf(0x18) || (DREG(1) != 0)) { + if (pthis->actor.world.rot.z != 7) { + Actor_Kill(&pthis->actor); + return; + } + } else if (pthis->actor.world.rot.z != 5) { + Actor_Kill(&pthis->actor); + return; + } + pthis->actor.home.rot.z = pthis->actor.world.rot.z = pthis->actor.shape.rot.z = 0; + func_800A663C(globalCtx, &pthis->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); + if ((pthis->actor.world.pos.x == -730.0f && pthis->actor.world.pos.y == 0.0f && + pthis->actor.world.pos.z == -1100.0f) || + (pthis->actor.world.pos.x == 880.0f && pthis->actor.world.pos.y == 0.0f && + pthis->actor.world.pos.z == -1170.0f)) { + func_80A6C6B0(pthis); + return; + } + } else if (globalCtx->sceneNum == SCENE_MALON_STABLE) { + if (IS_DAY) { + Actor_Kill(&pthis->actor); + return; + } else { + func_800A663C(globalCtx, &pthis->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); + func_80A6C6B0(pthis); + return; + } + } else if (globalCtx->sceneNum == SCENE_SPOT12) { + if (pthis->actor.world.pos.x == 3707.0f && pthis->actor.world.pos.y == 1413.0f && + pthis->actor.world.pos.z == -665.0f) { + func_800A663C(globalCtx, &pthis->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); + func_80A6C4CC(pthis); + return; + } + func_800A663C(globalCtx, &pthis->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); + } else { + func_800A663C(globalCtx, &pthis->skin, &gHorseNormalSkel, &gHorseNormalIdleAnim); + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); + } + if ((pthis->actor.params & 0xF0) == 0x10 && (pthis->actor.params & 0xF) != 0xF) { + func_80A6B91C(pthis, globalCtx); + } else { + func_80A6BC48(pthis); + } +} + +void EnHorseNormal_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseNormal* pthis = (EnHorseNormal*)thisx; + + func_800A6888(globalCtx, &pthis->skin); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyCylinder(globalCtx, &pthis->cloneCollider); + Collider_DestroyJntSph(globalCtx, &pthis->headCollider); +} + +void func_80A6B91C(EnHorseNormal* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->action = HORSE_FOLLOW_PATH; + pthis->animationIdx = 6; + pthis->waypoint = 0; + pthis->actor.speedXZ = 7.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void EnHorseNormal_FollowPath(EnHorseNormal* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->actor.params & 0xF]; + Vec3s* pointPos = SEGMENTED_TO_VIRTUAL(path->points); + f32 dx; + f32 dz; + s32 pad; + + pointPos += pthis->waypoint; + dx = pointPos->x - pthis->actor.world.pos.x; + dz = pointPos->z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 0xA, 0x7D0, 1); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (SQ(dx) + SQ(dz) < 600.0f) { + pthis->waypoint++; + if (pthis->waypoint >= path->count) { + pthis->waypoint = 0; + } + } + pthis->skin.skelAnime.playSpeed = func_80A6B30C(pthis); + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); + func_80A6BCEC(pthis); + } +} + +void EnHorseNormal_NextAnimation(EnHorseNormal* pthis) { + pthis->action = HORSE_CYCLE_ANIMATIONS; + pthis->animationIdx++; + + if (pthis->animationIdx >= ARRAY_COUNT(sAnimations)) { + pthis->animationIdx = 0; + } + + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx]); +} + +void EnHorseNormal_CycleAnimations(EnHorseNormal* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + EnHorseNormal_NextAnimation(pthis); + } +} + +void func_80A6BC48(EnHorseNormal* pthis) { + pthis->action = HORSE_WANDER; + pthis->animationIdx = 0; + pthis->unk_21C = 0; + pthis->unk_21E = 0; + pthis->actor.speedXZ = 0.0f; + pthis->unk_218 = 0.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void func_80A6BCEC(EnHorseNormal* pthis) { + if (pthis->animationIdx == 5) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (pthis->animationIdx == 6) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +void func_80A6BD7C(EnHorseNormal* pthis) { + f32 frame = pthis->skin.skelAnime.curFrame; + + if (pthis->animationIdx == 0 && frame > 28.0f && !(pthis->unk_1E4 & 1)) { + pthis->unk_1E4 |= 1; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (pthis->animationIdx == 3 && frame > 25.0f && !(pthis->unk_1E4 & 2)) { + pthis->unk_1E4 |= 2; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void EnHorseNormal_Wander(EnHorseNormal* pthis, GlobalContext* globalCtx) { + static s32 D_80A6D4F4[] = { 0, 1, 4, 5, 6, 2, 3 }; + static s32 D_80A6D510[] = { 0, 0, 2, 2, 1, 1, 1, 3, 3 }; + s32 phi_t0 = pthis->animationIdx; + s32 pad; + + switch (D_80A6D510[pthis->animationIdx]) { + case 0: + func_80A6BD7C(pthis); + pthis->actor.speedXZ = 0.0f; + pthis->unk_218 = 0.0f; + break; + case 1: + if (Rand_ZeroOne() < 0.1f) { + pthis->unk_218 = 2.0f * Rand_ZeroOne() - 1.0f; + } + pthis->actor.speedXZ += pthis->unk_218; + if (pthis->actor.speedXZ <= 0.0f) { + pthis->actor.speedXZ = 0.0f; + pthis->unk_218 = 0.0f; + phi_t0 = 0; + } else if (pthis->actor.speedXZ < 3.0f) { + func_80A6B250(pthis); + phi_t0 = 4; + } else if (pthis->actor.speedXZ < 6.0f) { + phi_t0 = 5; + } else if (pthis->actor.speedXZ < 8.0f) { + phi_t0 = 6; + } else { + pthis->actor.speedXZ = 8.0f; + phi_t0 = 6; + } + if (Rand_ZeroOne() < 0.1f || (pthis->unk_21E == 0 && ((pthis->actor.bgCheckFlags & 8) || + (pthis->bodyCollider.base.ocFlags1 & OC1_HIT) || + (pthis->headCollider.base.ocFlags1 & OC1_HIT)))) { + pthis->unk_21E += (Rand_ZeroOne() * 30.0f) - 15.0f; + if (pthis->unk_21E > 50) { + pthis->unk_21E = 50; + } else if (pthis->unk_21E < -50) { + pthis->unk_21E = -50; + } + } + pthis->unk_21C += pthis->unk_21E; + if (pthis->unk_21C < -300) { + pthis->unk_21C = -300; + } else if (pthis->unk_21C > 300) { + pthis->unk_21C = 300; + } else if (Rand_ZeroOne() < 0.25f && fabsf(pthis->unk_21C) < 100.0f) { + pthis->unk_21C = 0; + pthis->unk_21E = 0; + } + pthis->actor.world.rot.y += pthis->unk_21C; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + break; + case 2: + case 3: + break; + } + + if (phi_t0 != pthis->animationIdx || SkelAnime_Update(&pthis->skin.skelAnime)) { + if (phi_t0 != pthis->animationIdx) { + pthis->animationIdx = phi_t0; + pthis->unk_1E4 &= ~1; + pthis->unk_1E4 &= ~2; + if (phi_t0 == 1) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (phi_t0 == 3) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + func_80A6BCEC(pthis); + } + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + } else { + switch (D_80A6D510[pthis->animationIdx]) { + case 0: + if (Rand_ZeroOne() < 0.25f) { + pthis->unk_218 = 1.0f; + phi_t0 = 4; + } else { + phi_t0 = D_80A6D4F4[(s32)(Rand_ZeroOne() * 2)]; + pthis->actor.speedXZ = 0.0f; + pthis->unk_218 = 0.0f; + } + break; + case 1: + case 2: + case 3: + break; + } + + pthis->unk_1E4 &= ~1; + pthis->unk_1E4 &= ~2; + if (phi_t0 == 1) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (phi_t0 == 3) { + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + func_80A6BCEC(pthis); + } + if (phi_t0 != pthis->animationIdx) { + pthis->animationIdx = phi_t0; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, -3.0f); + } else { + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); + } + } + } +} + +void func_80A6C4CC(EnHorseNormal* pthis) { + pthis->action = HORSE_WAIT; + pthis->animationIdx = 0; + pthis->unk_21C = 0; + pthis->unk_21E = 0; + pthis->actor.speedXZ = 0.0f; + pthis->unk_218 = 0.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void EnHorseNormal_Wait(EnHorseNormal* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + f32 rand = Rand_ZeroOne(); + + if (rand < 0.4f) { + pthis->animationIdx = 0; + } else if (rand < 0.8f) { + pthis->animationIdx = 1; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + pthis->animationIdx = 3; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); + } +} + +void func_80A6C6B0(EnHorseNormal* pthis) { + pthis->action = HORSE_WAIT_CLONE; + pthis->animationIdx = 0; + pthis->unk_21C = 0; + pthis->unk_21E = 0; + pthis->actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + pthis->actor.speedXZ = 0.0f; + pthis->unk_218 = 0.0f; + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void EnHorseNormal_WaitClone(EnHorseNormal* pthis, GlobalContext* globalCtx) { + func_80A6BD7C(pthis); + + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + f32 rand = Rand_ZeroOne(); + + if (rand < 0.4f) { + pthis->animationIdx = 0; + } else if (rand < 0.8f) { + pthis->animationIdx = 1; + pthis->unk_1E4 |= 0x20; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + pthis->animationIdx = 3; + pthis->unk_1E4 |= 0x20; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_204, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + Animation_Change(&pthis->skin.skelAnime, sAnimations[pthis->animationIdx], func_80A6B30C(pthis), 0.0f, + Animation_GetLastFrame(sAnimations[pthis->animationIdx]), ANIMMODE_ONCE, 0.0f); + + pthis->unk_1E4 &= ~1; + pthis->unk_1E4 &= ~2; + pthis->unk_1E4 &= ~8; + pthis->unk_1E4 &= ~0x10; + } +} + +void func_80A6C8E0(EnHorseNormal* pthis, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* sp38; + s32 pad2; + Vec3f sp28; + s32 sp24; + + sp28.x = (Math_SinS(pthis->actor.shape.rot.y) * 30.0f) + pthis->actor.world.pos.x; + sp28.y = pthis->actor.world.pos.y + 60.0f; + sp28.z = (Math_CosS(pthis->actor.shape.rot.y) * 30.0f) + pthis->actor.world.pos.z; + pthis->unk_220 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp38, &sp24, &sp28); + pthis->actor.shape.rot.x = Math_FAtan2F(pthis->actor.world.pos.y - pthis->unk_220, 30.0f) * (0x8000 / M_PI); +} + +static EnHorseNormalActionFunc sActionFuncs[] = { + EnHorseNormal_CycleAnimations, EnHorseNormal_Wander, EnHorseNormal_Wait, + EnHorseNormal_WaitClone, EnHorseNormal_FollowPath, +}; + +void EnHorseNormal_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseNormal* pthis = (EnHorseNormal*)thisx; + s32 pad; + + sActionFuncs[pthis->action](pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 35.0f, 100.0f, 0x1D); + if (globalCtx->sceneNum == SCENE_SPOT20 && pthis->actor.world.pos.z < -2400.0f) { + pthis->actor.world.pos.z = -2400.0f; + } + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + pthis->unk_204 = pthis->actor.projectedPos; + pthis->unk_204.y += 120.0f; + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + if (pthis->actor.speedXZ == 0.0f) { + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + pthis->actor.colChkInfo.mass = MASS_HEAVY; + } +} + +void func_80A6CAFC(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { + Vec3f sp4C; + Vec3f sp40; + EnHorseNormal* pthis = (EnHorseNormal*)thisx; + s32 i; + + for (i = 0; i < pthis->headCollider.count; i++) { + sp4C.x = pthis->headCollider.elements[i].dim.modelSphere.center.x; + sp4C.y = pthis->headCollider.elements[i].dim.modelSphere.center.y; + sp4C.z = pthis->headCollider.elements[i].dim.modelSphere.center.z; + func_800A6408(skin, pthis->headCollider.elements[i].dim.limb, &sp4C, &sp40); + pthis->headCollider.elements[i].dim.worldSphere.center.x = sp40.x; + pthis->headCollider.elements[i].dim.worldSphere.center.y = sp40.y; + pthis->headCollider.elements[i].dim.worldSphere.center.z = sp40.z; + pthis->headCollider.elements[i].dim.worldSphere.radius = + pthis->headCollider.elements[i].dim.modelSphere.radius * pthis->headCollider.elements[i].dim.scale; + } + + //! @bug see relevant comment in `EnHorse_SkinCallback1` + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->headCollider.base); +} + +void func_80A6CC88(GlobalContext* globalCtx, EnHorseNormal* pthis, Vec3f* arg2) { + f32 curFrame = pthis->skin.skelAnime.curFrame; + f32 wDest; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &pthis->unk_1E8, &wDest); + pthis->unk_1F4 = pthis->unk_1E8; + pthis->unk_1F4.y += 120.0f; + + if (pthis->animationIdx == 0 && curFrame > 28.0f && !(pthis->unk_1E4 & 8)) { + pthis->unk_1E4 |= 8; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_SANDDUST, &pthis->unk_1E8, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (pthis->animationIdx == 3 && curFrame > 25.0f && !(pthis->unk_1E4 & 0x10)) { + pthis->unk_1E4 |= 0x10; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_LAND2, &pthis->unk_1E8, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (pthis->animationIdx == 3 && pthis->unk_1E4 & 0x20) { + pthis->unk_1E4 &= ~0x20; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->unk_1F4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (pthis->animationIdx == 1 && pthis->unk_1E4 & 0x20) { + pthis->unk_1E4 &= ~0x20; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->unk_1F4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +void EnHorseNormal_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseNormal* pthis = (EnHorseNormal*)thisx; + Mtx* mtx2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_normal.c", 2224); + + if (globalCtx->sceneNum != SCENE_SPOT20 || globalCtx->sceneNum != SCENE_MALON_STABLE) { + func_80A6C8E0(pthis, globalCtx); + } + func_80093D18(globalCtx->state.gfxCtx); + func_800A6330(&pthis->actor, globalCtx, &pthis->skin, func_80A6CAFC, 1); + + if (pthis->action == HORSE_WAIT_CLONE) { + MtxF skinMtx; + Mtx* mtx1; + Vec3f clonePos = { 0.0f, 0.0f, 0.0f }; + s16 cloneRotY; + f32 distFromGround = pthis->actor.world.pos.y - pthis->actor.floorHeight; + f32 temp_f0_4; + + if (globalCtx->sceneNum == SCENE_MALON_STABLE) { + if (pthis->actor.world.pos.x == 355.0f && pthis->actor.world.pos.y == 0.0f && + pthis->actor.world.pos.z == -245.0f) { + clonePos.x = 235.0f; + clonePos.y = 0.0f; + clonePos.z = 100.0f; + cloneRotY = 0x7FFF; + } else if (pthis->actor.world.pos.x == 238.0f && pthis->actor.world.pos.y == 0.0f && + pthis->actor.world.pos.z == -245.0f) { + clonePos.x = 478.0f; + clonePos.y = 0.0f; + clonePos.z = 100.0f; + cloneRotY = 0x7FFF; + } + } else if (globalCtx->sceneNum == SCENE_SPOT20) { + if (pthis->actor.world.pos.x == -730.0f && pthis->actor.world.pos.y == 0.0f && + pthis->actor.world.pos.z == -1100.0f) { + clonePos.x = 780.0f; + clonePos.y = 0.0f; + clonePos.z = -80.0f; + cloneRotY = 0; + } else if (pthis->actor.world.pos.x == 880.0f && pthis->actor.world.pos.y == 0.0f && + pthis->actor.world.pos.z == -1170.0f) { + clonePos.x = -1000.0f; + clonePos.y = 0.0f; + clonePos.z = -70.0f; + cloneRotY = 0; + } + } + func_80A6CC88(globalCtx, pthis, &clonePos); + SkinMatrix_SetTranslateRotateYXZScale(&skinMtx, pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, + pthis->actor.shape.rot.x, cloneRotY, pthis->actor.shape.rot.z, clonePos.x, + (pthis->actor.shape.yOffset * pthis->actor.scale.y) + clonePos.y, + clonePos.z); + mtx1 = SkinMatrix_MtxFToNewMtx(globalCtx->state.gfxCtx, &skinMtx); + if (mtx1 == NULL) { + return; + } + gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtx1, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_800A63CC(&pthis->actor, globalCtx, &pthis->skin, NULL, NULL, 1, 0, 3); + pthis->cloneCollider.dim.pos.x = clonePos.x; + pthis->cloneCollider.dim.pos.y = clonePos.y; + pthis->cloneCollider.dim.pos.z = clonePos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cloneCollider.base); + func_80094044(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + Matrix_Translate(clonePos.x, clonePos.y, clonePos.z, MTXMODE_NEW); + temp_f0_4 = (1.0f - (distFromGround * 0.01f)) * pthis->actor.shape.shadowScale; + Matrix_Scale(pthis->actor.scale.x * temp_f0_4, 1.0f, pthis->actor.scale.z * temp_f0_4, MTXMODE_APPLY); + Matrix_RotateY(cloneRotY * (2.0f * M_PI / 0x10000), MTXMODE_APPLY); + mtx2 = Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_horse_normal.c", 2329); + if (mtx2 != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx2, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gHorseShadowDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_horse_normal.c", 2339); +} diff --git a/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c b/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c deleted file mode 100644 index 60171d4b9..000000000 --- a/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c +++ /dev/null @@ -1,287 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_ZELDA_Z_EN_HORSE_ZELDA_C -#include "actor_common.h" -/* - * File: z_en_horse_zelda.c - * Overlay: ovl_En_Horse_Zelda - * Description: Zelda's Horse - */ - -#include "z_en_horse_zelda.h" -#include "objects/object_horse_zelda/object_horse_zelda.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin.h" -#include "def/z_skin_awb.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnHorseZelda_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorseZelda_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorseZelda_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A6DCCC(EnHorseZelda* this, GlobalContext* globalCtx); -void func_80A6DDFC(EnHorseZelda* this, GlobalContext* globalCtx); -void func_80A6DC7C(EnHorseZelda* this); - -const ActorInit En_Horse_Zelda_InitVars = { - ACTOR_EN_HORSE_ZELDA, - ACTORCAT_BG, - FLAGS, - OBJECT_HORSE_ZELDA, - sizeof(EnHorseZelda), - (ActorFunc)EnHorseZelda_Init, - (ActorFunc)EnHorseZelda_Destroy, - (ActorFunc)EnHorseZelda_Update, - (ActorFunc)EnHorseZelda_Draw, -}; - -static AnimationHeader* sAnimationHeaders[] = { &gHorseZeldaGallopingAnim }; - -static f32 splaySpeeds[] = { 2.0f / 3.0f }; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 40, 100, 0, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 13, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1 | OC2_UNK1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; - -typedef struct { - /* 0x0 */ Vec3s unk_0; - /* 0x6 */ u8 unk_6; -} unknownStruct; // size = 0x8 - -static unknownStruct D_80A6E240[] = { - { -1682, -500, 12578, 0x07 }, { -3288, -500, 13013, 0x07 }, { -5142, -417, 11630, 0x07 }, - { -5794, -473, 9573, 0x07 }, { -6765, -500, 8364, 0x07 }, { -6619, -393, 6919, 0x07 }, - { -5193, 124, 5433, 0x07 }, { -2970, 2, 4537, 0x07 }, { -2949, -35, 4527, 0x07 }, - { -1907, -47, 2978, 0x07 }, { 2488, 294, 3628, 0x07 }, { 3089, 378, 4713, 0x07 }, - { 1614, -261, 7596, 0x07 }, { 754, -187, 9295, 0x07 }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), -}; - -static EnHorseZeldaActionFunc sActionFuncs[] = { - func_80A6DCCC, - func_80A6DDFC, -}; - -void func_80A6D8D0(unknownStruct* data, s32 index, Vec3f* vec) { - vec->x = data[index].unk_0.x; - vec->y = data[index].unk_0.y; - vec->z = data[index].unk_0.z; -} - -void func_80A6D918(EnHorseZelda* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f sp28; - s16 yawDiff; - - func_80A6D8D0(D_80A6E240, this->unk_1EC, &sp28); - if (Math3D_Vec3f_DistXYZ(&sp28, &this->actor.world.pos) <= 400.0f) { - this->unk_1EC++; - if (this->unk_1EC >= 14) { - this->unk_1EC = 0; - func_80A6D8D0(D_80A6E240, 0, &sp28); - } - } - yawDiff = Math_Vec3f_Yaw(&this->actor.world.pos, &sp28) - this->actor.world.rot.y; - if (yawDiff >= 0x12D) { - this->actor.world.rot.y += 0x12C; - } else if (yawDiff < -0x12C) { - this->actor.world.rot.y -= 0x12C; - } else { - this->actor.world.rot.y += yawDiff; - } - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(globalCtx)->actor) <= 300.0f) { - if (this->actor.speedXZ < 12.0f) { - this->actor.speedXZ += 1.0f; - } else { - this->actor.speedXZ -= 1.0f; - } - } else if (this->actor.speedXZ < D_80A6E240[this->unk_1EC].unk_6) { - this->actor.speedXZ += 0.5f; - } else { - this->actor.speedXZ -= 0.5f; - } -} - -void EnHorseZelda_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHorseZelda* this = (EnHorseZelda*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.0115f); - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->actor.speedXZ = 0.0f; - this->actor.focus.pos = this->actor.world.pos; - this->action = 0; - this->actor.focus.pos.y += 70.0f; - func_800A663C(globalCtx, &this->skin, &gHorseZeldaSkel, &gHorseZeldaGallopingAnim); - this->animationIndex = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[0]); - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinderType1(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - Collider_InitJntSph(globalCtx, &this->colliderSphere); - Collider_SetJntSph(globalCtx, &this->colliderSphere, &this->actor, &sJntSphInit, &this->colliderSphereItem); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - this->animationIndex = 0; - func_80A6DC7C(this); -} - -void EnHorseZelda_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHorseZelda* this = (EnHorseZelda*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroyJntSph(globalCtx, &this->colliderSphere); - func_800A6888(globalCtx, &this->skin); -} - -void func_80A6DC7C(EnHorseZelda* this) { - this->action = 0; - this->animationIndex++; - if (this->animationIndex > 0) { - this->animationIndex = 0; - } - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex]); -} - -void func_80A6DCCC(EnHorseZelda* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - if (SkelAnime_Update(&this->skin.skelAnime)) { - func_80A6DC7C(this); - } -} - -void func_80A6DD14(EnHorseZelda* this) { - f32 sp34; - - this->action = 1; - this->animationIndex = 0; - sp34 = this->actor.speedXZ / 6.0f; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex], - splaySpeeds[this->animationIndex] * sp34 * 1.5f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->animationIndex]), ANIMMODE_ONCE, 0.0f); -} - -void func_80A6DDFC(EnHorseZelda* this, GlobalContext* globalCtx) { - func_80A6D918(this, globalCtx); - if (SkelAnime_Update(&this->skin.skelAnime)) { - func_80A6DD14(this); - } -} - -void func_80A6DE38(EnHorseZelda* this, GlobalContext* globalCtx) { - s32 pad; - CollisionPoly* poly; - s32 pad2; - Vec3f pos; - s32 bgId; - - pos.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 60.0f; - pos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; - this->unk_1F4 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &pos); - this->actor.shape.rot.x = Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f) * (0x8000 / M_PI); -} - -void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHorseZelda* this = (EnHorseZelda*)thisx; - s32 pad; - - sActionFuncs[this->action](this, globalCtx); - this->actor.speedXZ = 0.0f; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); -} - -void func_80A6DFD4(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { - Vec3f sp4C; - Vec3f sp40; - EnHorseZelda* this = (EnHorseZelda*)thisx; - s32 i; - - for (i = 0; i < this->colliderSphere.count; i++) { - sp4C.x = this->colliderSphere.elements[i].dim.modelSphere.center.x; - sp4C.y = this->colliderSphere.elements[i].dim.modelSphere.center.y; - sp4C.z = this->colliderSphere.elements[i].dim.modelSphere.center.z; - - func_800A6408(skin, this->colliderSphere.elements[i].dim.limb, &sp4C, &sp40); - - this->colliderSphere.elements[i].dim.worldSphere.center.x = sp40.x; - this->colliderSphere.elements[i].dim.worldSphere.center.y = sp40.y; - this->colliderSphere.elements[i].dim.worldSphere.center.z = sp40.z; - - this->colliderSphere.elements[i].dim.worldSphere.radius = - this->colliderSphere.elements[i].dim.modelSphere.radius * this->colliderSphere.elements[i].dim.scale; - } - - //! @bug see relevant comment in `EnHorse_SkinCallback1` - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); -} - -void EnHorseZelda_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHorseZelda* this = (EnHorseZelda*)thisx; - - func_80A6DE38(this, globalCtx); - func_80093D18(globalCtx->state.gfxCtx); - func_800A6330(&this->actor, globalCtx, &this->skin, func_80A6DFD4, 1); -} diff --git a/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.cpp b/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.cpp new file mode 100644 index 000000000..30911a382 --- /dev/null +++ b/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.cpp @@ -0,0 +1,287 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HORSE_ZELDA_Z_EN_HORSE_ZELDA_C +#include "actor_common.h" +/* + * File: z_en_horse_zelda.c + * Overlay: ovl_En_Horse_Zelda + * Description: Zelda's Horse + */ + +#include "z_en_horse_zelda.h" +#include "objects/object_horse_zelda/object_horse_zelda.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin.h" +#include "def/z_skin_awb.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnHorseZelda_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHorseZelda_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHorseZelda_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A6DCCC(EnHorseZelda* pthis, GlobalContext* globalCtx); +void func_80A6DDFC(EnHorseZelda* pthis, GlobalContext* globalCtx); +void func_80A6DC7C(EnHorseZelda* pthis); + +ActorInit En_Horse_Zelda_InitVars = { + ACTOR_EN_HORSE_ZELDA, + ACTORCAT_BG, + FLAGS, + OBJECT_HORSE_ZELDA, + sizeof(EnHorseZelda), + (ActorFunc)EnHorseZelda_Init, + (ActorFunc)EnHorseZelda_Destroy, + (ActorFunc)EnHorseZelda_Update, + (ActorFunc)EnHorseZelda_Draw, +}; + +static AnimationHeader* sAnimationHeaders[] = { &gHorseZeldaGallopingAnim }; + +static f32 splaySpeeds[] = { 2.0f / 3.0f }; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 40, 100, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 13, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; + +typedef struct { + /* 0x0 */ Vec3s unk_0; + /* 0x6 */ u8 unk_6; +} unknownStruct; // size = 0x8 + +static unknownStruct D_80A6E240[] = { + { -1682, -500, 12578, 0x07 }, { -3288, -500, 13013, 0x07 }, { -5142, -417, 11630, 0x07 }, + { -5794, -473, 9573, 0x07 }, { -6765, -500, 8364, 0x07 }, { -6619, -393, 6919, 0x07 }, + { -5193, 124, 5433, 0x07 }, { -2970, 2, 4537, 0x07 }, { -2949, -35, 4527, 0x07 }, + { -1907, -47, 2978, 0x07 }, { 2488, 294, 3628, 0x07 }, { 3089, 378, 4713, 0x07 }, + { 1614, -261, 7596, 0x07 }, { 754, -187, 9295, 0x07 }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), +}; + +static EnHorseZeldaActionFunc sActionFuncs[] = { + func_80A6DCCC, + func_80A6DDFC, +}; + +void func_80A6D8D0(unknownStruct* data, s32 index, Vec3f* vec) { + vec->x = data[index].unk_0.x; + vec->y = data[index].unk_0.y; + vec->z = data[index].unk_0.z; +} + +void func_80A6D918(EnHorseZelda* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s16 yawDiff; + + func_80A6D8D0(D_80A6E240, pthis->unk_1EC, &sp28); + if (Math3D_Vec3f_DistXYZ(&sp28, &pthis->actor.world.pos) <= 400.0f) { + pthis->unk_1EC++; + if (pthis->unk_1EC >= 14) { + pthis->unk_1EC = 0; + func_80A6D8D0(D_80A6E240, 0, &sp28); + } + } + yawDiff = Math_Vec3f_Yaw(&pthis->actor.world.pos, &sp28) - pthis->actor.world.rot.y; + if (yawDiff >= 0x12D) { + pthis->actor.world.rot.y += 0x12C; + } else if (yawDiff < -0x12C) { + pthis->actor.world.rot.y -= 0x12C; + } else { + pthis->actor.world.rot.y += yawDiff; + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (Actor_WorldDistXZToActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) <= 300.0f) { + if (pthis->actor.speedXZ < 12.0f) { + pthis->actor.speedXZ += 1.0f; + } else { + pthis->actor.speedXZ -= 1.0f; + } + } else if (pthis->actor.speedXZ < D_80A6E240[pthis->unk_1EC].unk_6) { + pthis->actor.speedXZ += 0.5f; + } else { + pthis->actor.speedXZ -= 0.5f; + } +} + +void EnHorseZelda_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseZelda* pthis = (EnHorseZelda*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 0.0115f); + pthis->actor.gravity = -3.5f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->action = 0; + pthis->actor.focus.pos.y += 70.0f; + func_800A663C(globalCtx, &pthis->skin, &gHorseZeldaSkel, &gHorseZeldaGallopingAnim); + pthis->animationIndex = 0; + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[0]); + Collider_InitCylinder(globalCtx, &pthis->colliderCylinder); + Collider_SetCylinderType1(globalCtx, &pthis->colliderCylinder, &pthis->actor, &sCylinderInit); + Collider_InitJntSph(globalCtx, &pthis->colliderSphere); + Collider_SetJntSph(globalCtx, &pthis->colliderSphere, &pthis->actor, &sJntSphInit, &pthis->colliderSphereItem); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + pthis->animationIndex = 0; + func_80A6DC7C(pthis); +} + +void EnHorseZelda_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseZelda* pthis = (EnHorseZelda*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &pthis->colliderSphere); + func_800A6888(globalCtx, &pthis->skin); +} + +void func_80A6DC7C(EnHorseZelda* pthis) { + pthis->action = 0; + pthis->animationIndex++; + if (pthis->animationIndex > 0) { + pthis->animationIndex = 0; + } + Animation_PlayOnce(&pthis->skin.skelAnime, sAnimationHeaders[pthis->animationIndex]); +} + +void func_80A6DCCC(EnHorseZelda* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + func_80A6DC7C(pthis); + } +} + +void func_80A6DD14(EnHorseZelda* pthis) { + f32 sp34; + + pthis->action = 1; + pthis->animationIndex = 0; + sp34 = pthis->actor.speedXZ / 6.0f; + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Animation_Change(&pthis->skin.skelAnime, sAnimationHeaders[pthis->animationIndex], + splaySpeeds[pthis->animationIndex] * sp34 * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[pthis->animationIndex]), ANIMMODE_ONCE, 0.0f); +} + +void func_80A6DDFC(EnHorseZelda* pthis, GlobalContext* globalCtx) { + func_80A6D918(pthis, globalCtx); + if (SkelAnime_Update(&pthis->skin.skelAnime)) { + func_80A6DD14(pthis); + } +} + +void func_80A6DE38(EnHorseZelda* pthis, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* poly; + s32 pad2; + Vec3f pos; + s32 bgId; + + pos.x = (Math_SinS(pthis->actor.shape.rot.y) * 30.0f) + pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 60.0f; + pos.z = (Math_CosS(pthis->actor.shape.rot.y) * 30.0f) + pthis->actor.world.pos.z; + pthis->unk_1F4 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &pos); + pthis->actor.shape.rot.x = Math_FAtan2F(pthis->actor.world.pos.y - pthis->unk_1F4, 30.0f) * (0x8000 / M_PI); +} + +void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseZelda* pthis = (EnHorseZelda*)thisx; + s32 pad; + + sActionFuncs[pthis->action](pthis, globalCtx); + pthis->actor.speedXZ = 0.0f; + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 55.0f, 100.0f, 0x1D); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinder.base); +} + +void func_80A6DFD4(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { + Vec3f sp4C; + Vec3f sp40; + EnHorseZelda* pthis = (EnHorseZelda*)thisx; + s32 i; + + for (i = 0; i < pthis->colliderSphere.count; i++) { + sp4C.x = pthis->colliderSphere.elements[i].dim.modelSphere.center.x; + sp4C.y = pthis->colliderSphere.elements[i].dim.modelSphere.center.y; + sp4C.z = pthis->colliderSphere.elements[i].dim.modelSphere.center.z; + + func_800A6408(skin, pthis->colliderSphere.elements[i].dim.limb, &sp4C, &sp40); + + pthis->colliderSphere.elements[i].dim.worldSphere.center.x = sp40.x; + pthis->colliderSphere.elements[i].dim.worldSphere.center.y = sp40.y; + pthis->colliderSphere.elements[i].dim.worldSphere.center.z = sp40.z; + + pthis->colliderSphere.elements[i].dim.worldSphere.radius = + pthis->colliderSphere.elements[i].dim.modelSphere.radius * pthis->colliderSphere.elements[i].dim.scale; + } + + //! @bug see relevant comment in `EnHorse_SkinCallback1` + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSphere.base); +} + +void EnHorseZelda_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseZelda* pthis = (EnHorseZelda*)thisx; + + func_80A6DE38(pthis, globalCtx); + func_80093D18(globalCtx->state.gfxCtx); + func_800A6330(&pthis->actor, globalCtx, &pthis->skin, func_80A6DFD4, 1); +} diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c deleted file mode 100644 index 718ca28c4..000000000 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ /dev/null @@ -1,310 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HS_Z_EN_HS_C -#include "actor_common.h" -/* - * File: z_en_hs.c - * Overlay: ovl_En_Hs - * Description: Carpenter's Son - */ - -#include "z_en_hs.h" -#include "vt.h" -#include "objects/object_hs/object_hs.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnHs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A6E9AC(EnHs* this, GlobalContext* globalCtx); -void func_80A6E6B0(EnHs* this, GlobalContext* globalCtx); - -const ActorInit En_Hs_InitVars = { - ACTOR_EN_HS, - ACTORCAT_NPC, - FLAGS, - OBJECT_HS, - sizeof(EnHs), - (ActorFunc)EnHs_Init, - (ActorFunc)EnHs_Destroy, - (ActorFunc)EnHs_Update, - (ActorFunc)EnHs_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 40, 40, 0, { 0, 0, 0 } }, -}; - -void func_80A6E3A0(EnHs* this, EnHsActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHs* this = (EnHs*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, - this->morphTable, 16); - Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - - if (!LINK_IS_ADULT) { - this->actor.params = 0; - } else { - this->actor.params = 1; - } - - if (this->actor.params == 1) { - // "chicken shop (adult era)" - osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコの店(大人の時) \n" VT_RST); - func_80A6E3A0(this, func_80A6E9AC); - if (gSaveContext.itemGetInf[3] & 1) { - // "chicken shop closed" - osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコ屋閉店 \n" VT_RST); - Actor_Kill(&this->actor); - } - } else { - // "chicken shop (child era)" - osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコの店(子人の時) \n" VT_RST); - func_80A6E3A0(this, func_80A6E9AC); - } - - this->unk_2A8 = 0; - this->actor.targetMode = 6; -} - -void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHs* this = (EnHs*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 func_80A6E53C(EnHs* this, GlobalContext* globalCtx, u16 textId, EnHsActionFunc actionFunc) { - s16 yawDiff; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - func_80A6E3A0(this, actionFunc); - return 1; - } - - this->actor.textId = textId; - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(yawDiff) <= 0x2150) && (this->actor.xzDistToPlayer < 100.0f)) { - this->unk_2A8 |= 1; - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - - return 0; -} - -void func_80A6E5EC(EnHs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80A6E3A0(this, func_80A6E6B0); - } - - this->unk_2A8 |= 1; -} - -void func_80A6E630(EnHs* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - func_80088AA0(180); - func_80A6E3A0(this, func_80A6E6B0); - gSaveContext.eventInf[1] &= ~1; - } - - this->unk_2A8 |= 1; -} - -void func_80A6E6B0(EnHs* this, GlobalContext* globalCtx) { - func_80A6E53C(this, globalCtx, 0x10B6, func_80A6E5EC); -} - -void func_80A6E6D8(EnHs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80A6E3A0(this, func_80A6E9AC); - } -} - -void func_80A6E70C(EnHs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80A6E3A0(this, func_80A6E9AC); - } -} - -void func_80A6E740(EnHs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - func_80A6E3A0(this, func_80A6E630); - } else { - func_8002F434(&this->actor, globalCtx, GI_ODD_MUSHROOM, 10000.0f, 50.0f); - } - - this->unk_2A8 |= 1; -} - -void func_80A6E7BC(EnHs* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - func_80A6E3A0(this, func_80A6E740); - func_8002F434(&this->actor, globalCtx, GI_ODD_MUSHROOM, 10000.0f, 50.0f); - break; - case 1: - Message_ContinueTextbox(globalCtx, 0x10B4); - func_80A6E3A0(this, func_80A6E70C); - break; - } - - Animation_Change(&this->skelAnime, &object_hs_Anim_0005C0, 1.0f, 0.0f, - Animation_GetLastFrame(&object_hs_Anim_0005C0), ANIMMODE_LOOP, 8.0f); - } - - this->unk_2A8 |= 1; -} - -void func_80A6E8CC(EnHs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x10B3); - func_80A6E3A0(this, func_80A6E7BC); - Animation_Change(&this->skelAnime, &object_hs_Anim_000528, 1.0f, 0.0f, - Animation_GetLastFrame(&object_hs_Anim_000528), ANIMMODE_LOOP, 8.0f); - } - - if (this->unk_2AA > 0) { - this->unk_2AA--; - if (this->unk_2AA == 0) { - func_8002F7DC(&player->actor, NA_SE_EV_CHICKEN_CRY_M); - } - } - - this->unk_2A8 |= 1; -} - -void func_80A6E9AC(EnHs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (func_8002F368(globalCtx) == 7) { - player->actor.textId = 0x10B2; - func_80A6E3A0(this, func_80A6E8CC); - Animation_Change(&this->skelAnime, &object_hs_Anim_000304, 1.0f, 0.0f, - Animation_GetLastFrame(&object_hs_Anim_000304), ANIMMODE_LOOP, 8.0f); - this->unk_2AA = 40; - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } else { - player->actor.textId = 0x10B1; - func_80A6E3A0(this, func_80A6E6D8); - } - } else { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - this->actor.textId = 0x10B1; - if ((ABS(yawDiff) <= 0x2150) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8002F298(&this->actor, globalCtx, 100.0f, 7); - } - } -} - -void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHs* this = (EnHs*)thisx; - s32 pad; - - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (SkelAnime_Update(&this->skelAnime)) { - this->skelAnime.curFrame = 0.0f; - } - - this->actionFunc(this, globalCtx); - - if (this->unk_2A8 & 1) { - func_80038290(globalCtx, &this->actor, &this->unk_29C, &this->unk_2A2, this->actor.focus.pos); - this->unk_2A8 &= ~1; - } else { - Math_SmoothStepToS(&this->unk_29C.x, 12800, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_29C.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.y, 0, 6, 6200, 100); - } -} - -s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnHs* this = (EnHs*)thisx; - - switch (limbIndex) { - case 9: - rot->x += this->unk_29C.y; - rot->z += this->unk_29C.x; - break; - case 10: - *dList = NULL; - return false; - case 11: - *dList = NULL; - return false; - case 12: - if (this->actor.params == 1) { - *dList = NULL; - return false; - } - break; - case 13: - if (this->actor.params == 1) { - *dList = NULL; - return false; - } - break; - } - return false; -} - -void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_80A6EDFC = { 300.0f, 1000.0f, 0.0f }; - EnHs* this = (EnHs*)thisx; - - if (limbIndex == 9) { - Matrix_MultVec3f(&D_80A6EDFC, &this->actor.focus.pos); - } -} - -void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHs* this = (EnHs*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.cpp b/src/overlays/actors/ovl_En_Hs/z_en_hs.cpp new file mode 100644 index 000000000..0cf9f028c --- /dev/null +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.cpp @@ -0,0 +1,310 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HS_Z_EN_HS_C +#include "actor_common.h" +/* + * File: z_en_hs.c + * Overlay: ovl_En_Hs + * Description: Carpenter's Son + */ + +#include "z_en_hs.h" +#include "vt.h" +#include "objects/object_hs/object_hs.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnHs_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A6E9AC(EnHs* pthis, GlobalContext* globalCtx); +void func_80A6E6B0(EnHs* pthis, GlobalContext* globalCtx); + +ActorInit En_Hs_InitVars = { + ACTOR_EN_HS, + ACTORCAT_NPC, + FLAGS, + OBJECT_HS, + sizeof(EnHs), + (ActorFunc)EnHs_Init, + (ActorFunc)EnHs_Destroy, + (ActorFunc)EnHs_Update, + (ActorFunc)EnHs_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 40, 40, 0, { 0, 0, 0 } }, +}; + +void func_80A6E3A0(EnHs* pthis, EnHsActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHs* pthis = (EnHs*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, pthis->jointTable, + pthis->morphTable, 16); + Animation_PlayLoop(&pthis->skelAnime, &object_hs_Anim_0005C0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + + if (!LINK_IS_ADULT) { + pthis->actor.params = 0; + } else { + pthis->actor.params = 1; + } + + if (pthis->actor.params == 1) { + // "chicken shop (adult era)" + osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコの店(大人の時) \n" VT_RST); + func_80A6E3A0(pthis, func_80A6E9AC); + if (gSaveContext.itemGetInf[3] & 1) { + // "chicken shop closed" + osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコ屋閉店 \n" VT_RST); + Actor_Kill(&pthis->actor); + } + } else { + // "chicken shop (child era)" + osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコの店(子人の時) \n" VT_RST); + func_80A6E3A0(pthis, func_80A6E9AC); + } + + pthis->unk_2A8 = 0; + pthis->actor.targetMode = 6; +} + +void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHs* pthis = (EnHs*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 func_80A6E53C(EnHs* pthis, GlobalContext* globalCtx, u16 textId, EnHsActionFunc actionFunc) { + s16 yawDiff; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + func_80A6E3A0(pthis, actionFunc); + return 1; + } + + pthis->actor.textId = textId; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((ABS(yawDiff) <= 0x2150) && (pthis->actor.xzDistToPlayer < 100.0f)) { + pthis->unk_2A8 |= 1; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + + return 0; +} + +void func_80A6E5EC(EnHs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80A6E3A0(pthis, func_80A6E6B0); + } + + pthis->unk_2A8 |= 1; +} + +void func_80A6E630(EnHs* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + func_80088AA0(180); + func_80A6E3A0(pthis, func_80A6E6B0); + gSaveContext.eventInf[1] &= ~1; + } + + pthis->unk_2A8 |= 1; +} + +void func_80A6E6B0(EnHs* pthis, GlobalContext* globalCtx) { + func_80A6E53C(pthis, globalCtx, 0x10B6, func_80A6E5EC); +} + +void func_80A6E6D8(EnHs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80A6E3A0(pthis, func_80A6E9AC); + } +} + +void func_80A6E70C(EnHs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80A6E3A0(pthis, func_80A6E9AC); + } +} + +void func_80A6E740(EnHs* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + func_80A6E3A0(pthis, func_80A6E630); + } else { + func_8002F434(&pthis->actor, globalCtx, GI_ODD_MUSHROOM, 10000.0f, 50.0f); + } + + pthis->unk_2A8 |= 1; +} + +void func_80A6E7BC(EnHs* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_80A6E3A0(pthis, func_80A6E740); + func_8002F434(&pthis->actor, globalCtx, GI_ODD_MUSHROOM, 10000.0f, 50.0f); + break; + case 1: + Message_ContinueTextbox(globalCtx, 0x10B4); + func_80A6E3A0(pthis, func_80A6E70C); + break; + } + + Animation_Change(&pthis->skelAnime, &object_hs_Anim_0005C0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_hs_Anim_0005C0), ANIMMODE_LOOP, 8.0f); + } + + pthis->unk_2A8 |= 1; +} + +void func_80A6E8CC(EnHs* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x10B3); + func_80A6E3A0(pthis, func_80A6E7BC); + Animation_Change(&pthis->skelAnime, &object_hs_Anim_000528, 1.0f, 0.0f, + Animation_GetLastFrame(&object_hs_Anim_000528), ANIMMODE_LOOP, 8.0f); + } + + if (pthis->unk_2AA > 0) { + pthis->unk_2AA--; + if (pthis->unk_2AA == 0) { + func_8002F7DC(&player->actor, NA_SE_EV_CHICKEN_CRY_M); + } + } + + pthis->unk_2A8 |= 1; +} + +void func_80A6E9AC(EnHs* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (func_8002F368(globalCtx) == 7) { + player->actor.textId = 0x10B2; + func_80A6E3A0(pthis, func_80A6E8CC); + Animation_Change(&pthis->skelAnime, &object_hs_Anim_000304, 1.0f, 0.0f, + Animation_GetLastFrame(&object_hs_Anim_000304), ANIMMODE_LOOP, 8.0f); + pthis->unk_2AA = 40; + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } else { + player->actor.textId = 0x10B1; + func_80A6E3A0(pthis, func_80A6E6D8); + } + } else { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + pthis->actor.textId = 0x10B1; + if ((ABS(yawDiff) <= 0x2150) && (pthis->actor.xzDistToPlayer < 100.0f)) { + func_8002F298(&pthis->actor, globalCtx, 100.0f, 7); + } + } +} + +void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHs* pthis = (EnHs*)thisx; + s32 pad; + + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->skelAnime.curFrame = 0.0f; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->unk_2A8 & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_29C, &pthis->unk_2A2, pthis->actor.focus.pos); + pthis->unk_2A8 &= ~1; + } else { + Math_SmoothStepToS(&pthis->unk_29C.x, 12800, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_29C.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.y, 0, 6, 6200, 100); + } +} + +s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnHs* pthis = (EnHs*)thisx; + + switch (limbIndex) { + case 9: + rot->x += pthis->unk_29C.y; + rot->z += pthis->unk_29C.x; + break; + case 10: + *dList = NULL; + return false; + case 11: + *dList = NULL; + return false; + case 12: + if (pthis->actor.params == 1) { + *dList = NULL; + return false; + } + break; + case 13: + if (pthis->actor.params == 1) { + *dList = NULL; + return false; + } + break; + } + return false; +} + +void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_80A6EDFC = { 300.0f, 1000.0f, 0.0f }; + EnHs* pthis = (EnHs*)thisx; + + if (limbIndex == 9) { + Matrix_MultVec3f(&D_80A6EDFC, &pthis->actor.focus.pos); + } +} + +void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHs* pthis = (EnHs*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c deleted file mode 100644 index a6c9c0b1e..000000000 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ /dev/null @@ -1,177 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HS2_Z_EN_HS2_C -#include "actor_common.h" -/* - * File: z_en_hs2.c - * Overlay: ovl_En_Hs2 - * Description: Carpenter's Son (Child Link version) - */ - -#include "z_en_hs2.h" -#include "vt.h" -#include "objects/object_hs/object_hs.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnHs2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHs2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHs2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHs2_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A6F1A4(EnHs2* this, GlobalContext* globalCtx); - -const ActorInit En_Hs2_InitVars = { - ACTOR_EN_HS2, - ACTORCAT_NPC, - FLAGS, - OBJECT_HS, - sizeof(EnHs2), - (ActorFunc)EnHs2_Init, - (ActorFunc)EnHs2_Destroy, - (ActorFunc)EnHs2_Update, - (ActorFunc)EnHs2_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 40, 40, 0, { 0, 0, 0 } }, -}; - -void EnHs2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHs2* this = (EnHs2*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, - this->morphTable, 16); - Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコの店(子人の時) \n" VT_RST); - this->actionFunc = func_80A6F1A4; - this->unk_2A8 = 0; - this->actor.targetMode = 6; -} - -void EnHs2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHs2* this = (EnHs2*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 func_80A6F0B4(EnHs2* this, GlobalContext* globalCtx, u16 textId, EnHs2ActionFunc actionFunc) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = actionFunc; - return 1; - } - - this->actor.textId = textId; - if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x2151 && - this->actor.xzDistToPlayer < 100.0f) { - this->unk_2A8 |= 0x1; - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - return 0; -} - -void func_80A6F164(EnHs2* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = func_80A6F1A4; - } - this->unk_2A8 |= 0x1; -} - -void func_80A6F1A4(EnHs2* this, GlobalContext* globalCtx) { - u16 textId; - - textId = Text_GetFaceReaction(globalCtx, 9); - if (textId == 0) { - textId = 0x5069; - } - - func_80A6F0B4(this, globalCtx, textId, func_80A6F164); -} - -void EnHs2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHs2* this = (EnHs2*)thisx; - s32 pad; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (SkelAnime_Update(&this->skelAnime) != 0) { - this->skelAnime.curFrame = 0.0f; - } - this->actionFunc(this, globalCtx); - if (this->unk_2A8 & 0x1) { - func_80038290(globalCtx, &this->actor, &this->unk_29C, &this->unk_2A2, this->actor.focus.pos); - this->unk_2A8 &= ~1; - } else { - Math_SmoothStepToS(&this->unk_29C.x, 12800, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_29C.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2A2.y, 0, 6, 6200, 100); - } -} - -s32 EnHs2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnHs2* this = (EnHs2*)thisx; - - switch (limbIndex) { - case 12: - case 13: - *dList = NULL; - return false; - case 9: - rot->x += this->unk_29C.y; - rot->z += this->unk_29C.x; - break; - case 10: - *dList = NULL; - return false; - case 11: - *dList = NULL; - return false; - } - return false; -} - -void EnHs2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_80A6F4CC = { 300.0f, 1000.0f, 0.0f }; - EnHs2* this = (EnHs2*)thisx; - - if (limbIndex == 9) { - Matrix_MultVec3f(&D_80A6F4CC, &this->actor.focus.pos); - } -} - -void EnHs2_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHs2* this = (EnHs2*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnHs2_OverrideLimbDraw, EnHs2_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.cpp b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.cpp new file mode 100644 index 000000000..736331fbb --- /dev/null +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.cpp @@ -0,0 +1,177 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_HS2_Z_EN_HS2_C +#include "actor_common.h" +/* + * File: z_en_hs2.c + * Overlay: ovl_En_Hs2 + * Description: Carpenter's Son (Child Link version) + */ + +#include "z_en_hs2.h" +#include "vt.h" +#include "objects/object_hs/object_hs.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnHs2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnHs2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnHs2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHs2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A6F1A4(EnHs2* pthis, GlobalContext* globalCtx); + +ActorInit En_Hs2_InitVars = { + ACTOR_EN_HS2, + ACTORCAT_NPC, + FLAGS, + OBJECT_HS, + sizeof(EnHs2), + (ActorFunc)EnHs2_Init, + (ActorFunc)EnHs2_Destroy, + (ActorFunc)EnHs2_Update, + (ActorFunc)EnHs2_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 40, 40, 0, { 0, 0, 0 } }, +}; + +void EnHs2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHs2* pthis = (EnHs2*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, pthis->jointTable, + pthis->morphTable, 16); + Animation_PlayLoop(&pthis->skelAnime, &object_hs_Anim_0005C0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + osSyncPrintf(VT_FGCOL(CYAN) " ヒヨコの店(子人の時) \n" VT_RST); + pthis->actionFunc = func_80A6F1A4; + pthis->unk_2A8 = 0; + pthis->actor.targetMode = 6; +} + +void EnHs2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHs2* pthis = (EnHs2*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 func_80A6F0B4(EnHs2* pthis, GlobalContext* globalCtx, u16 textId, EnHs2ActionFunc actionFunc) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = actionFunc; + return 1; + } + + pthis->actor.textId = textId; + if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) < 0x2151 && + pthis->actor.xzDistToPlayer < 100.0f) { + pthis->unk_2A8 |= 0x1; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + return 0; +} + +void func_80A6F164(EnHs2* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80A6F1A4; + } + pthis->unk_2A8 |= 0x1; +} + +void func_80A6F1A4(EnHs2* pthis, GlobalContext* globalCtx) { + u16 textId; + + textId = Text_GetFaceReaction(globalCtx, 9); + if (textId == 0) { + textId = 0x5069; + } + + func_80A6F0B4(pthis, globalCtx, textId, func_80A6F164); +} + +void EnHs2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHs2* pthis = (EnHs2*)thisx; + s32 pad; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + pthis->skelAnime.curFrame = 0.0f; + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_2A8 & 0x1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_29C, &pthis->unk_2A2, pthis->actor.focus.pos); + pthis->unk_2A8 &= ~1; + } else { + Math_SmoothStepToS(&pthis->unk_29C.x, 12800, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_29C.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2A2.y, 0, 6, 6200, 100); + } +} + +s32 EnHs2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnHs2* pthis = (EnHs2*)thisx; + + switch (limbIndex) { + case 12: + case 13: + *dList = NULL; + return false; + case 9: + rot->x += pthis->unk_29C.y; + rot->z += pthis->unk_29C.x; + break; + case 10: + *dList = NULL; + return false; + case 11: + *dList = NULL; + return false; + } + return false; +} + +void EnHs2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_80A6F4CC = { 300.0f, 1000.0f, 0.0f }; + EnHs2* pthis = (EnHs2*)thisx; + + if (limbIndex == 9) { + Matrix_MultVec3f(&D_80A6F4CC, &pthis->actor.focus.pos); + } +} + +void EnHs2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHs2* pthis = (EnHs2*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnHs2_OverrideLimbDraw, EnHs2_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.c b/src/overlays/actors/ovl_En_Hy/z_en_hy.cpp similarity index 69% rename from src/overlays/actors/ovl_En_Hy/z_en_hy.c rename to src/overlays/actors/ovl_En_Hy/z_en_hy.cpp index 6c6550ad0..27e11affe 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.c +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.cpp @@ -41,17 +41,17 @@ void EnHy_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHy_Update(Actor* thisx, GlobalContext* globalCtx); void EnHy_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnHy_InitImpl(EnHy* this, GlobalContext* globalCtx); -void func_80A7134C(EnHy* this, GlobalContext* globalCtx); -void func_80A71530(EnHy* this, GlobalContext* globalCtx); -void func_80A711B4(EnHy* this, GlobalContext* globalCtx); -void func_80A712C0(EnHy* this, GlobalContext* globalCtx); -void func_80A710F8(EnHy* this, GlobalContext* globalCtx); -void func_80A7127C(EnHy* this, GlobalContext* globalCtx); -void EnHy_DoNothing(EnHy* this, GlobalContext* globalCtx); -void func_80A714C4(EnHy* this, GlobalContext* globalCtx); +void EnHy_InitImpl(EnHy* pthis, GlobalContext* globalCtx); +void func_80A7134C(EnHy* pthis, GlobalContext* globalCtx); +void func_80A71530(EnHy* pthis, GlobalContext* globalCtx); +void func_80A711B4(EnHy* pthis, GlobalContext* globalCtx); +void func_80A712C0(EnHy* pthis, GlobalContext* globalCtx); +void func_80A710F8(EnHy* pthis, GlobalContext* globalCtx); +void func_80A7127C(EnHy* pthis, GlobalContext* globalCtx); +void EnHy_DoNothing(EnHy* pthis, GlobalContext* globalCtx); +void func_80A714C4(EnHy* pthis, GlobalContext* globalCtx); -const ActorInit En_Hy_InitVars = { +ActorInit En_Hy_InitVars = { ACTOR_EN_HY, ACTORCAT_NPC, FLAGS, @@ -370,92 +370,92 @@ static EnHyInit2Info sInit2Info[] = { /* ENHY_TYPE_AHG_20 */ { 20.0f, { 0.0f, 0.0f, -200.0f }, 0.01f, 0x06, 30.0f }, }; -s32 EnHy_FindSkelAndHeadObjects(EnHy* this, GlobalContext* globalCtx) { - u8 headInfoIndex = sModelInfo[this->actor.params & 0x7F].headInfoIndex; - u8 skelInfoIndex2 = sModelInfo[this->actor.params & 0x7F].skelInfoIndex2; - u8 skelInfoIndex1 = sModelInfo[this->actor.params & 0x7F].skelInfoIndex1; +s32 EnHy_FindSkelAndHeadObjects(EnHy* pthis, GlobalContext* globalCtx) { + u8 headInfoIndex = sModelInfo[pthis->actor.params & 0x7F].headInfoIndex; + u8 skelInfoIndex2 = sModelInfo[pthis->actor.params & 0x7F].skelInfoIndex2; + u8 skelInfoIndex1 = sModelInfo[pthis->actor.params & 0x7F].skelInfoIndex1; - this->objBankIndexSkel1 = Object_GetIndex(&globalCtx->objectCtx, sSkeletonInfo[skelInfoIndex1].objectId); - if (this->objBankIndexSkel1 < 0) { + pthis->objBankIndexSkel1 = Object_GetIndex(&globalCtx->objectCtx, sSkeletonInfo[skelInfoIndex1].objectId); + if (pthis->objBankIndexSkel1 < 0) { return false; } - this->objBankIndexSkel2 = Object_GetIndex(&globalCtx->objectCtx, sSkeletonInfo[skelInfoIndex2].objectId); - if (this->objBankIndexSkel2 < 0) { + pthis->objBankIndexSkel2 = Object_GetIndex(&globalCtx->objectCtx, sSkeletonInfo[skelInfoIndex2].objectId); + if (pthis->objBankIndexSkel2 < 0) { return false; } - this->objBankIndexHead = Object_GetIndex(&globalCtx->objectCtx, sHeadInfo[headInfoIndex].objectId); - if (this->objBankIndexHead < 0) { + pthis->objBankIndexHead = Object_GetIndex(&globalCtx->objectCtx, sHeadInfo[headInfoIndex].objectId); + if (pthis->objBankIndexHead < 0) { return false; } return true; } -s32 EnHy_AreSkelAndHeadObjectsLoaded(EnHy* this, GlobalContext* globalCtx) { - if (!Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndexSkel1)) { +s32 EnHy_AreSkelAndHeadObjectsLoaded(EnHy* pthis, GlobalContext* globalCtx) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndexSkel1)) { return false; } - if (!Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndexSkel2)) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndexSkel2)) { return false; } - if (!Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndexHead)) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndexHead)) { return false; } return true; } -s32 EnHy_FindOsAnimeObject(EnHy* this, GlobalContext* globalCtx) { - this->objBankIndexOsAnime = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); +s32 EnHy_FindOsAnimeObject(EnHy* pthis, GlobalContext* globalCtx) { + pthis->objBankIndexOsAnime = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); - if (this->objBankIndexOsAnime < 0) { + if (pthis->objBankIndexOsAnime < 0) { return false; } return true; } -s32 EnHy_IsOsAnimeObjectLoaded(EnHy* this, GlobalContext* globalCtx) { - if (!Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndexOsAnime)) { +s32 EnHy_IsOsAnimeObjectLoaded(EnHy* pthis, GlobalContext* globalCtx) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndexOsAnime)) { return false; } return true; } -void func_80A6F7CC(EnHy* this, GlobalContext* globalCtx, s32 getItemId) { - this->unkGetItemId = getItemId; - func_8002F434(&this->actor, globalCtx, getItemId, this->actor.xzDistToPlayer + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); +void func_80A6F7CC(EnHy* pthis, GlobalContext* globalCtx, s32 getItemId) { + pthis->unkGetItemId = getItemId; + func_8002F434(&pthis->actor, globalCtx, getItemId, pthis->actor.xzDistToPlayer + 1.0f, + fabsf(pthis->actor.yDistToPlayer) + 1.0f); } u16 func_80A6F810(GlobalContext* globalCtx, Actor* thisx) { Player* player = GET_PLAYER(globalCtx); - EnHy* this = (EnHy*)thisx; - u16 textId = Text_GetFaceReaction(globalCtx, (this->actor.params & 0x7F) + 37); + EnHy* pthis = (EnHy*)thisx; + u16 textId = Text_GetFaceReaction(globalCtx, (pthis->actor.params & 0x7F) + 37); if (textId != 0) { - if ((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_5) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_5) { player->exchangeItemId = EXCH_ITEM_BLUE_FIRE; } return textId; } - switch (this->actor.params & 0x7F) { + switch (pthis->actor.params & 0x7F) { case ENHY_TYPE_AOB: if (globalCtx->sceneNum == SCENE_KAKARIKO) { - return (this->unk_330 & 0x800) ? 0x508D : ((gSaveContext.infTable[12] & 0x800) ? 0x508C : 0x508B); + return (pthis->unk_330 & 0x800) ? 0x508D : ((gSaveContext.infTable[12] & 0x800) ? 0x508C : 0x508B); } else if (globalCtx->sceneNum == SCENE_MARKET_DAY) { return (gSaveContext.eventInf[3] & 1) ? 0x709B : 0x709C; } else if (gSaveContext.dogIsLost) { s16 followingDog = (gSaveContext.dogParams & 0xF00) >> 8; if (followingDog != 0) { - this->unk_215 = false; + pthis->unk_215 = false; return (followingDog == 1) ? 0x709F : 0x709E; } else { return 0x709D; @@ -560,7 +560,7 @@ u16 func_80A6F810(GlobalContext* globalCtx, Actor* thisx) { if (!LINK_IS_ADULT) { return (gSaveContext.eventChkInf[8] & 1) ? 0x505F : ((gSaveContext.infTable[22] & 8) ? 0x505E : 0x505D); } else { - return (this->unk_330 & 0x800) ? 0x5062 : ((gSaveContext.infTable[22] & 0x10) ? 0x5061 : 0x5060); + return (pthis->unk_330 & 0x800) ? 0x5062 : ((gSaveContext.infTable[22] & 0x10) ? 0x5061 : 0x5060); } case ENHY_TYPE_BJI_19: return 0x7120; @@ -572,7 +572,7 @@ u16 func_80A6F810(GlobalContext* globalCtx, Actor* thisx) { } s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; s16 beggarItems[] = { ITEM_BLUE_FIRE, ITEM_FISH, ITEM_BUG, ITEM_FAIRY }; s16 beggarRewards[] = { 150, 100, 50, 25 }; @@ -586,34 +586,34 @@ s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) { case TEXT_STATE_9: return 1; case TEXT_STATE_DONE_FADING: - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x709E: case 0x709F: - if (!this->unk_215) { - Audio_PlaySoundGeneral(this->actor.textId == 0x709F ? NA_SE_SY_CORRECT_CHIME : NA_SE_SY_ERROR, + if (!pthis->unk_215) { + Audio_PlaySoundGeneral(pthis->actor.textId == 0x709F ? NA_SE_SY_CORRECT_CHIME : NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_215 = true; + pthis->unk_215 = true; } break; case 0x70F0: case 0x70F1: case 0x70F2: case 0x70F3: - if (this->skelAnime.animation != &gObjOsAnim_33B4) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_23); + if (pthis->skelAnime.animation != &gObjOsAnim_33B4) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_23); Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); } break; } return 1; case TEXT_STATE_CLOSING: - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x70F0: case 0x70F1: case 0x70F2: case 0x70F3: - Rupees_ChangeBy(beggarRewards[this->actor.textId - 0x70F0]); - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_17); + Rupees_ChangeBy(beggarRewards[pthis->actor.textId - 0x70F0]); + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_17); Player_UpdateBottleHeld(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x7016: @@ -677,8 +677,8 @@ s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) { gSaveContext.dogParams = 0; break; case 0x709F: - func_80A6F7CC(this, globalCtx, (gSaveContext.infTable[25] & 2) ? GI_RUPEE_BLUE : GI_HEART_PIECE); - this->actionFunc = func_80A714C4; + func_80A6F7CC(pthis, globalCtx, (gSaveContext.infTable[25] & 2) ? GI_RUPEE_BLUE : GI_HEART_PIECE); + pthis->actionFunc = func_80A714C4; break; } return 0; @@ -693,101 +693,101 @@ s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) { return 1; } -void EnHy_UpdateEyes(EnHy* this) { - if (DECR(this->nextEyeIndexTimer) == 0) { - u8 headInfoIndex = sModelInfo[this->actor.params & 0x7F].headInfoIndex; +void EnHy_UpdateEyes(EnHy* pthis) { + if (DECR(pthis->nextEyeIndexTimer) == 0) { + u8 headInfoIndex = sModelInfo[pthis->actor.params & 0x7F].headInfoIndex; - this->curEyeIndex++; + pthis->curEyeIndex++; if ((sHeadInfo[headInfoIndex].eyeTextures != NULL) && - (sHeadInfo[headInfoIndex].eyeTextures[this->curEyeIndex] == NULL)) { - this->nextEyeIndexTimer = Rand_S16Offset(30, 30); - this->curEyeIndex = 0; + (sHeadInfo[headInfoIndex].eyeTextures[pthis->curEyeIndex] == NULL)) { + pthis->nextEyeIndexTimer = Rand_S16Offset(30, 30); + pthis->curEyeIndex = 0; } } } -void EnHy_InitCollider(EnHy* this) { - u8 type = this->actor.params & 0x7F; +void EnHy_InitCollider(EnHy* pthis) { + u8 type = pthis->actor.params & 0x7F; - this->collider.dim.radius = sColliderInfo[type].radius; - this->collider.dim.height = sColliderInfo[type].height; + pthis->collider.dim.radius = sColliderInfo[type].radius; + pthis->collider.dim.height = sColliderInfo[type].height; } -void EnHy_InitSetProperties(EnHy* this) { - u8 type = this->actor.params & 0x7F; +void EnHy_InitSetProperties(EnHy* pthis) { + u8 type = pthis->actor.params & 0x7F; - this->actor.shape.shadowScale = sInit2Info[type].shadowScale; - Actor_SetScale(&this->actor, sInit2Info[type].scale); - this->actor.targetMode = sInit2Info[type].targetMode; - this->modelOffset = sInit2Info[type].modelOffset; - this->unkRange = sInit2Info[type].unkRange; - this->unkRange += this->collider.dim.radius; + pthis->actor.shape.shadowScale = sInit2Info[type].shadowScale; + Actor_SetScale(&pthis->actor, sInit2Info[type].scale); + pthis->actor.targetMode = sInit2Info[type].targetMode; + pthis->modelOffset = sInit2Info[type].modelOffset; + pthis->unkRange = sInit2Info[type].unkRange; + pthis->unkRange += pthis->collider.dim.radius; } -void EnHy_UpdateCollider(EnHy* this, GlobalContext* globalCtx) { +void EnHy_UpdateCollider(EnHy* pthis, GlobalContext* globalCtx) { Vec3s pos; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z; - pos.x += sColliderInfo[this->actor.params & 0x7F].offset.x; - pos.y += sColliderInfo[this->actor.params & 0x7F].offset.y; - pos.z += sColliderInfo[this->actor.params & 0x7F].offset.z; - this->collider.dim.pos = pos; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z; + pos.x += sColliderInfo[pthis->actor.params & 0x7F].offset.x; + pos.y += sColliderInfo[pthis->actor.params & 0x7F].offset.y; + pos.z += sColliderInfo[pthis->actor.params & 0x7F].offset.z; + pthis->collider.dim.pos = pos; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } -void func_80A70834(EnHy* this, GlobalContext* globalCtx) { +void func_80A70834(EnHy* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_5) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_5) { if (!Inventory_HasSpecificBottle(ITEM_BLUE_FIRE) && !Inventory_HasSpecificBottle(ITEM_BUG) && !Inventory_HasSpecificBottle(ITEM_FISH)) { switch (func_8002F368(globalCtx)) { case EXCH_ITEM_POE: case EXCH_ITEM_BIG_POE: case EXCH_ITEM_LETTER_RUTO: - this->actor.textId = 0x70EF; + pthis->actor.textId = 0x70EF; break; default: if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { - this->actor.textId = 0x70ED; + pthis->actor.textId = 0x70ED; } break; } } else { switch (func_8002F368(globalCtx)) { case EXCH_ITEM_BLUE_FIRE: - this->actor.textId = 0x70F0; + pthis->actor.textId = 0x70F0; break; case EXCH_ITEM_FISH: - this->actor.textId = 0x70F1; + pthis->actor.textId = 0x70F1; break; case EXCH_ITEM_BUG: - this->actor.textId = 0x70F2; + pthis->actor.textId = 0x70F2; break; default: if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { - this->actor.textId = 0x700C; + pthis->actor.textId = 0x700C; } break; } } - player->actor.textId = this->actor.textId; + player->actor.textId = pthis->actor.textId; } } -void func_80A70978(EnHy* this, GlobalContext* globalCtx) { +void func_80A70978(EnHy* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 phi_a3; - switch (this->actor.params & 0x7F) { + switch (pthis->actor.params & 0x7F) { case ENHY_TYPE_BOJ_3: case ENHY_TYPE_BJI_7: case ENHY_TYPE_BOJ_9: case ENHY_TYPE_BOJ_10: - phi_a3 = (this->unk_1E8.unk_00 == 0) ? 1 : 2; + phi_a3 = (pthis->unk_1E8.unk_00 == 0) ? 1 : 2; break; case ENHY_TYPE_BOJ_12: phi_a3 = 1; @@ -798,54 +798,54 @@ void func_80A70978(EnHy* this, GlobalContext* globalCtx) { break; case ENHY_TYPE_AOB: case ENHY_TYPE_BOB_18: - phi_a3 = (this->unk_1E8.unk_00 == 0) ? 2 : 4; + phi_a3 = (pthis->unk_1E8.unk_00 == 0) ? 2 : 4; break; default: phi_a3 = 2; break; } - this->unk_1E8.unk_18 = player->actor.world.pos; + pthis->unk_1E8.unk_18 = player->actor.world.pos; if (LINK_IS_ADULT) { - this->unk_1E8.unk_14 = sInit1Info[this->actor.params & 0x7F].unkValueAdult; + pthis->unk_1E8.unk_14 = sInit1Info[pthis->actor.params & 0x7F].unkValueAdult; } else { - this->unk_1E8.unk_14 = sInit1Info[this->actor.params & 0x7F].unkValueChild; + pthis->unk_1E8.unk_14 = sInit1Info[pthis->actor.params & 0x7F].unkValueChild; } - func_80034A14(&this->actor, &this->unk_1E8, sInit1Info[this->actor.params & 0x7F].unkPresetIndex, phi_a3); + func_80034A14(&pthis->actor, &pthis->unk_1E8, sInit1Info[pthis->actor.params & 0x7F].unkPresetIndex, phi_a3); - if (func_800343CC(globalCtx, &this->actor, &this->unk_1E8.unk_00, this->unkRange, func_80A6F810, func_80A70058)) { - func_80A70834(this, globalCtx); + if (func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E8.unk_00, pthis->unkRange, func_80A6F810, func_80A70058)) { + func_80A70834(pthis, globalCtx); } } -s32 EnHy_ShouldSpawn(EnHy* this, GlobalContext* globalCtx) { +s32 EnHy_ShouldSpawn(EnHy* pthis, GlobalContext* globalCtx) { switch (globalCtx->sceneNum) { case SCENE_SPOT01: - if (!((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_9 || (this->actor.params & 0x7F) == ENHY_TYPE_BOJ_10 || - (this->actor.params & 0x7F) == ENHY_TYPE_BOJ_12 || (this->actor.params & 0x7F) == ENHY_TYPE_AHG_2 || - (this->actor.params & 0x7F) == ENHY_TYPE_BJI_7)) { + if (!((pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_9 || (pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_10 || + (pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_12 || (pthis->actor.params & 0x7F) == ENHY_TYPE_AHG_2 || + (pthis->actor.params & 0x7F) == ENHY_TYPE_BJI_7)) { return true; } else if (!LINK_IS_ADULT) { return true; - } else if ((this->actor.params & 0x7F) != ENHY_TYPE_BOJ_12 && IS_NIGHT) { + } else if ((pthis->actor.params & 0x7F) != ENHY_TYPE_BOJ_12 && IS_NIGHT) { return false; } else { return true; } case SCENE_LABO: - if ((this->actor.params & 0x7F) != ENHY_TYPE_BOJ_10) { + if ((pthis->actor.params & 0x7F) != ENHY_TYPE_BOJ_10) { return true; } else if (LINK_IS_CHILD) { return false; - } else if ((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_10 && IS_DAY) { + } else if ((pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_10 && IS_DAY) { return false; } else { return true; } case SCENE_IMPA: - if ((this->actor.params & 0x7F) != ENHY_TYPE_AOB) { + if ((pthis->actor.params & 0x7F) != ENHY_TYPE_AOB) { return true; } else if (IS_DAY) { return false; @@ -853,11 +853,11 @@ s32 EnHy_ShouldSpawn(EnHy* this, GlobalContext* globalCtx) { return true; } case SCENE_KAKARIKO: - if ((this->actor.params & 0x7F) == ENHY_TYPE_AOB) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_AOB) { return !LINK_IS_ADULT ? false : true; - } else if (!((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_9 || - (this->actor.params & 0x7F) == ENHY_TYPE_AHG_2 || - (this->actor.params & 0x7F) == ENHY_TYPE_BJI_7)) { + } else if (!((pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_9 || + (pthis->actor.params & 0x7F) == ENHY_TYPE_AHG_2 || + (pthis->actor.params & 0x7F) == ENHY_TYPE_BJI_7)) { return true; } else if (IS_DAY) { return false; @@ -868,7 +868,7 @@ s32 EnHy_ShouldSpawn(EnHy* this, GlobalContext* globalCtx) { } case SCENE_MARKET_ALLEY: case SCENE_MARKET_ALLEY_N: - if ((this->actor.params & 0x7F) != ENHY_TYPE_BOJ_14) { + if ((pthis->actor.params & 0x7F) != ENHY_TYPE_BOJ_14) { return true; } else if (IS_NIGHT) { return false; @@ -878,7 +878,7 @@ s32 EnHy_ShouldSpawn(EnHy* this, GlobalContext* globalCtx) { return true; } default: - switch (this->actor.params & 0x7F) { + switch (pthis->actor.params & 0x7F) { case ENHY_TYPE_BJI_19: case ENHY_TYPE_AHG_20: if (LINK_IS_ADULT) { @@ -890,67 +890,67 @@ s32 EnHy_ShouldSpawn(EnHy* this, GlobalContext* globalCtx) { } void EnHy_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; - if ((this->actor.params & 0x7F) >= ENHY_TYPE_MAX || !EnHy_FindOsAnimeObject(this, globalCtx) || - !EnHy_FindSkelAndHeadObjects(this, globalCtx)) { - Actor_Kill(&this->actor); + if ((pthis->actor.params & 0x7F) >= ENHY_TYPE_MAX || !EnHy_FindOsAnimeObject(pthis, globalCtx) || + !EnHy_FindSkelAndHeadObjects(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); } - if (!EnHy_ShouldSpawn(this, globalCtx)) { - Actor_Kill(&this->actor); + if (!EnHy_ShouldSpawn(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); } - this->actionFunc = EnHy_InitImpl; + pthis->actionFunc = EnHy_InitImpl; } void EnHy_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void EnHy_InitImpl(EnHy* this, GlobalContext* globalCtx) { - if (EnHy_IsOsAnimeObjectLoaded(this, globalCtx) && EnHy_AreSkelAndHeadObjectsLoaded(this, globalCtx)) { - this->actor.objBankIndex = this->objBankIndexSkel1; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->actor.objBankIndex].vromStart); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, - sSkeletonInfo[sModelInfo[this->actor.params & 0x7F].skelInfoIndex1].skeleton, NULL, - this->jointTable, this->morphTable, 16); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndexOsAnime].vromStart); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sColCylInit); - EnHy_InitCollider(this); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - func_80034EC0(&this->skelAnime, sAnimationInfo, sModelInfo[this->actor.params & 0x7F].animInfoIndex); +void EnHy_InitImpl(EnHy* pthis, GlobalContext* globalCtx) { + if (EnHy_IsOsAnimeObjectLoaded(pthis, globalCtx) && EnHy_AreSkelAndHeadObjectsLoaded(pthis, globalCtx)) { + pthis->actor.objBankIndex = pthis->objBankIndexSkel1; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->actor.objBankIndex].vromStart.get()); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, + sSkeletonInfo[sModelInfo[pthis->actor.params & 0x7F].skelInfoIndex1].skeleton, NULL, + pthis->jointTable, pthis->morphTable, 16); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndexOsAnime].vromStart.get()); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sColCylInit); + EnHy_InitCollider(pthis); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + func_80034EC0(&pthis->skelAnime, sAnimationInfo, sModelInfo[pthis->actor.params & 0x7F].animInfoIndex); if ((globalCtx->sceneNum == SCENE_MARKET_ALLEY) || (globalCtx->sceneNum == SCENE_MARKET_DAY)) { - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.uncullZoneScale = 0.0f; + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.uncullZoneScale = 0.0f; } if (globalCtx->sceneNum == SCENE_KAKARIKO) { - this->unk_330 = gSaveContext.eventChkInf[6]; + pthis->unk_330 = gSaveContext.eventChkInf[6]; } - EnHy_InitSetProperties(this); - this->path = Path_GetByIndex(globalCtx, (this->actor.params & 0x780) >> 7, 15); + EnHy_InitSetProperties(pthis); + pthis->path = Path_GetByIndex(globalCtx, (pthis->actor.params & 0x780) >> 7, 15); - switch (this->actor.params & 0x7F) { + switch (pthis->actor.params & 0x7F) { case ENHY_TYPE_BOJ_3: - if (this->path != NULL) { - this->actor.speedXZ = 3.0f; + if (pthis->path != NULL) { + pthis->actor.speedXZ = 3.0f; } - this->actionFunc = func_80A711B4; + pthis->actionFunc = func_80A711B4; break; case ENHY_TYPE_BJI_7: - this->pathReverse = false; - this->actionFunc = func_80A712C0; + pthis->pathReverse = false; + pthis->actionFunc = func_80A712C0; break; case ENHY_TYPE_AOB: if (globalCtx->sceneNum == SCENE_MARKET_DAY) { - this->actionFunc = func_80A710F8; + pthis->actionFunc = func_80A710F8; break; } // fall-through @@ -967,115 +967,115 @@ void EnHy_InitImpl(EnHy* this, GlobalContext* globalCtx) { case ENHY_TYPE_BOB_18: case ENHY_TYPE_BJI_19: case ENHY_TYPE_AHG_20: - this->actionFunc = func_80A7127C; + pthis->actionFunc = func_80A7127C; break; case ENHY_TYPE_BOJ_5: case ENHY_TYPE_BOJ_9: case ENHY_TYPE_BOJ_10: case ENHY_TYPE_CNE_11: case ENHY_TYPE_BOJ_12: - this->actionFunc = EnHy_DoNothing; + pthis->actionFunc = EnHy_DoNothing; break; default: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; } } } -void func_80A710F8(EnHy* this, GlobalContext* globalCtx) { - if (this->unk_1E8.unk_00 != 0) { - if (this->skelAnime.animation != &gObjOsAnim_0BFC) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_26); +void func_80A710F8(EnHy* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E8.unk_00 != 0) { + if (pthis->skelAnime.animation != &gObjOsAnim_0BFC) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_26); } } else if (gSaveContext.eventInf[3] & 1) { - if (this->skelAnime.animation != &gObjOsAnim_0FE4) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_25); + if (pthis->skelAnime.animation != &gObjOsAnim_0FE4) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_25); } - } else if (this->skelAnime.animation != &gObjOsAnim_12E8) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_24); + } else if (pthis->skelAnime.animation != &gObjOsAnim_12E8) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_24); } } -void func_80A711B4(EnHy* this, GlobalContext* globalCtx) { +void func_80A711B4(EnHy* pthis, GlobalContext* globalCtx) { s16 yaw; f32 distSq; - distSq = Path_OrientAndGetDistSq(&this->actor, this->path, this->waypoint, &yaw); - Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 10, 1000, 1); - this->actor.shape.rot = this->actor.world.rot; + distSq = Path_OrientAndGetDistSq(&pthis->actor, pthis->path, pthis->waypoint, &yaw); + Math_SmoothStepToS(&pthis->actor.world.rot.y, yaw, 10, 1000, 1); + pthis->actor.shape.rot = pthis->actor.world.rot; if ((distSq > 0.0f) && (distSq < 1000.0f)) { - this->waypoint++; - if (this->waypoint > (this->path->count - 1)) { - this->waypoint = 0; + pthis->waypoint++; + if (pthis->waypoint > (pthis->path->count - 1)) { + pthis->waypoint = 0; } } } -void func_80A7127C(EnHy* this, GlobalContext* globalCtx) { - func_80034F54(globalCtx, this->unk_21C, this->unk_23C, 16); +void func_80A7127C(EnHy* pthis, GlobalContext* globalCtx) { + func_80034F54(globalCtx, pthis->unk_21C, pthis->unk_23C, 16); } -void EnHy_DoNothing(EnHy* this, GlobalContext* globalCtx) { +void EnHy_DoNothing(EnHy* pthis, GlobalContext* globalCtx) { } -void func_80A712C0(EnHy* this, GlobalContext* globalCtx) { - if ((this->actor.xzDistToPlayer <= 100.0f) && (this->path != NULL)) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_7); - this->actor.speedXZ = 0.4f; - this->actionFunc = func_80A7134C; +void func_80A712C0(EnHy* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.xzDistToPlayer <= 100.0f) && (pthis->path != NULL)) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_7); + pthis->actor.speedXZ = 0.4f; + pthis->actionFunc = func_80A7134C; } - func_80034F54(globalCtx, this->unk_21C, this->unk_23C, 16); + func_80034F54(globalCtx, pthis->unk_21C, pthis->unk_23C, 16); } -void func_80A7134C(EnHy* this, GlobalContext* globalCtx) { +void func_80A7134C(EnHy* pthis, GlobalContext* globalCtx) { s16 yaw; f32 distSq; - if ((this->skelAnime.animation == &gObjOsAnim_2160) && (this->unk_1E8.unk_00 != 0)) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_8); + if ((pthis->skelAnime.animation == &gObjOsAnim_2160) && (pthis->unk_1E8.unk_00 != 0)) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_8); } - if ((this->skelAnime.animation == &gObjOsAnim_265C) && (this->unk_1E8.unk_00 == 0)) { - func_80034EC0(&this->skelAnime, sAnimationInfo, ENHY_ANIM_7); + if ((pthis->skelAnime.animation == &gObjOsAnim_265C) && (pthis->unk_1E8.unk_00 == 0)) { + func_80034EC0(&pthis->skelAnime, sAnimationInfo, ENHY_ANIM_7); } - this->actor.speedXZ = 0.4f; - distSq = Path_OrientAndGetDistSq(&this->actor, this->path, this->waypoint, &yaw); - Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 10, 1000, 1); - this->actor.shape.rot = this->actor.world.rot; + pthis->actor.speedXZ = 0.4f; + distSq = Path_OrientAndGetDistSq(&pthis->actor, pthis->path, pthis->waypoint, &yaw); + Math_SmoothStepToS(&pthis->actor.world.rot.y, yaw, 10, 1000, 1); + pthis->actor.shape.rot = pthis->actor.world.rot; if (!(distSq <= 0.0f) && !(distSq >= 1000.0f)) { - if (!this->pathReverse) { - this->waypoint++; - if (this->waypoint > (this->path->count - 1)) { - this->pathReverse = true; - this->waypoint = this->path->count - 2; + if (!pthis->pathReverse) { + pthis->waypoint++; + if (pthis->waypoint > (pthis->path->count - 1)) { + pthis->pathReverse = true; + pthis->waypoint = pthis->path->count - 2; } } else { - this->waypoint--; - if (this->waypoint < 0) { - this->pathReverse = false; - this->waypoint = 1; + pthis->waypoint--; + if (pthis->waypoint < 0) { + pthis->pathReverse = false; + pthis->waypoint = 1; } } } } -void func_80A714C4(EnHy* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = func_80A71530; +void func_80A714C4(EnHy* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80A71530; } else { - func_8002F434(&this->actor, globalCtx, this->unkGetItemId, this->actor.xzDistToPlayer + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); + func_8002F434(&pthis->actor, globalCtx, pthis->unkGetItemId, pthis->actor.xzDistToPlayer + 1.0f, + fabsf(pthis->actor.yDistToPlayer) + 1.0f); } } -void func_80A71530(EnHy* this, GlobalContext* globalCtx) { +void func_80A71530(EnHy* pthis, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - switch (this->unkGetItemId) { + switch (pthis->unkGetItemId) { case GI_HEART_PIECE: gSaveContext.dogParams = 0; gSaveContext.dogIsLost = false; @@ -1088,32 +1088,32 @@ void func_80A71530(EnHy* this, GlobalContext* globalCtx) { break; } - this->actionFunc = func_80A7127C; + pthis->actionFunc = func_80A7127C; } } void EnHy_Update(Actor* thisx, GlobalContext* globalCtx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; - if (this->actionFunc != EnHy_InitImpl) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndexOsAnime].vromStart); - SkelAnime_Update(&this->skelAnime); - EnHy_UpdateEyes(this); + if (pthis->actionFunc != EnHy_InitImpl) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndexOsAnime].vromStart.get()); + SkelAnime_Update(&pthis->skelAnime); + EnHy_UpdateEyes(pthis); - if (this->unk_1E8.unk_00 == 0) { - Actor_MoveForward(&this->actor); + if (pthis->unk_1E8.unk_00 == 0) { + Actor_MoveForward(&pthis->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); } - this->actionFunc(this, globalCtx); - func_80A70978(this, globalCtx); - EnHy_UpdateCollider(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); + func_80A70978(pthis, globalCtx); + EnHy_UpdateCollider(pthis, globalCtx); } s32 EnHy_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; s32 pad; Vec3s sp48; u8 i; @@ -1124,36 +1124,36 @@ s32 EnHy_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_hy.c", 2170); if (limbIndex == 15) { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->objBankIndexHead].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndexHead].vromStart); - i = sModelInfo[this->actor.params & 0x7F].headInfoIndex; + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->objBankIndexHead].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndexHead].vromStart.get()); + i = sModelInfo[pthis->actor.params & 0x7F].headInfoIndex; *dList = sHeadInfo[i].headDList; if (sHeadInfo[i].eyeTextures != NULL) { - ptr = sHeadInfo[i].eyeTextures[this->curEyeIndex]; + ptr = sHeadInfo[i].eyeTextures[pthis->curEyeIndex]; gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(ptr)); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndexSkel1].vromStart); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndexSkel1].vromStart.get()); } if (limbIndex == 15) { Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - sp48 = this->unk_1E8.unk_08; + sp48 = pthis->unk_1E8.unk_08; Matrix_RotateX((sp48.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((sp48.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - sp48 = this->unk_1E8.unk_0E; + sp48 = pthis->unk_1E8.unk_0E; Matrix_RotateX((-sp48.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((sp48.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); } if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { - rot->y += Math_SinS(this->unk_21C[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->unk_23C[limbIndex]) * 200.0f; + rot->y += Math_SinS(pthis->unk_21C[limbIndex]) * 200.0f; + rot->z += Math_CosS(pthis->unk_23C[limbIndex]) * 200.0f; } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_hy.c", 2228); @@ -1162,32 +1162,30 @@ s32 EnHy_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnHy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; s32 pad; Vec3f sp3C = { 400.0f, 0.0f, 0.0f }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_hy.c", 2255); if (limbIndex == 7) { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->objBankIndexSkel2].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndexSkel2].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->objBankIndexSkel2].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndexSkel2].vromStart.get()); } - if ((this->actor.params & 0x7F) == ENHY_TYPE_BOJ_3 && limbIndex == 8) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_BOJ_3 && limbIndex == 8) { gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_005BC8); } if (limbIndex == 15) { - Matrix_MultVec3f(&sp3C, &this->actor.focus.pos); + Matrix_MultVec3f(&sp3C, &pthis->actor.focus.pos); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_hy.c", 2281); } Gfx* EnHy_SetEnvColor(GraphicsContext* globalCtx, u8 envR, u8 envG, u8 envB, u8 envA) { - Gfx* dList; - - dList = Graph_Alloc(globalCtx, 2 * sizeof(Gfx)); + Gfx* dList = (Gfx*)Graph_Alloc(globalCtx, 2 * sizeof(Gfx)); gDPSetEnvColor(dList, envR, envG, envB, envA); gSPEndDisplayList(dList + 1); @@ -1195,20 +1193,20 @@ Gfx* EnHy_SetEnvColor(GraphicsContext* globalCtx, u8 envR, u8 envG, u8 envB, u8 } void EnHy_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnHy* this = (EnHy*)thisx; + EnHy* pthis = (EnHy*)thisx; Color_RGBA8 envColorSeg8; Color_RGBA8 envColorSeg9; Color_RGBA8 envColorSeg10; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_hy.c", 2318); - if (this->actionFunc != EnHy_InitImpl) { + if (pthis->actionFunc != EnHy_InitImpl) { func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(this->modelOffset.x, this->modelOffset.y, this->modelOffset.z, MTXMODE_APPLY); - envColorSeg8 = sModelInfo[this->actor.params & 0x7F].envColorSeg8; - envColorSeg9 = sModelInfo[this->actor.params & 0x7F].envColorSeg9; + Matrix_Translate(pthis->modelOffset.x, pthis->modelOffset.y, pthis->modelOffset.z, MTXMODE_APPLY); + envColorSeg8 = sModelInfo[pthis->actor.params & 0x7F].envColorSeg8; + envColorSeg9 = sModelInfo[pthis->actor.params & 0x7F].envColorSeg9; - switch (this->actor.params & 0x7F) { + switch (pthis->actor.params & 0x7F) { // ENHY_TYPE_AOB // ENHY_TYPE_COB case ENHY_TYPE_AHG_2: @@ -1237,11 +1235,11 @@ void EnHy_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHy_SetEnvColor(globalCtx->state.gfxCtx, envColorSeg9.r, envColorSeg9.g, envColorSeg9.b, envColorSeg9.a)); - if ((this->actor.params & 0x7F) == ENHY_TYPE_CNE_8 || (this->actor.params & 0x7F) == ENHY_TYPE_CNE_11) { - if ((this->actor.params & 0x7F) == ENHY_TYPE_CNE_8) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_CNE_8 || (pthis->actor.params & 0x7F) == ENHY_TYPE_CNE_11) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_CNE_8) { envColorSeg10 = envColorSeg8; } - if ((this->actor.params & 0x7F) == ENHY_TYPE_CNE_11) { + if ((pthis->actor.params & 0x7F) == ENHY_TYPE_CNE_11) { envColorSeg10.r = envColorSeg10.g = envColorSeg10.b = 255; envColorSeg10.a = 0; } @@ -1252,8 +1250,8 @@ void EnHy_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnHy_OverrideLimbDraw, EnHy_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnHy_OverrideLimbDraw, EnHy_PostLimbDraw, &pthis->actor); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_hy.c", 2388); diff --git a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c deleted file mode 100644 index 0a9092552..000000000 --- a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c +++ /dev/null @@ -1,407 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ICE_HONO_Z_EN_ICE_HONO_C -#include "actor_common.h" -/* - * File: z_en_ice_hono.c - * Overlay: ovl_En_Ice_Hono - * Description: The various types of Blue Fire - */ - -#include "z_en_ice_hono.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void EnIceHono_Init(Actor* thisx, GlobalContext* globalCtx); -void EnIceHono_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnIceHono_Update(Actor* thisx, GlobalContext* globalCtx); -void EnIceHono_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnIceHono_CapturableFlame(EnIceHono* this, GlobalContext* globalCtx); -void EnIceHono_DropFlame(EnIceHono* this, GlobalContext* globalCtx); -void EnIceHono_SpreadFlames(EnIceHono* this, GlobalContext* globalCtx); -void EnIceHono_SmallFlameMove(EnIceHono* this, GlobalContext* globalCtx); - -void EnIceHono_SetupActionCapturableFlame(EnIceHono* this); -void EnIceHono_SetupActionDroppedFlame(EnIceHono* this); -void EnIceHono_SetupActionSpreadFlames(EnIceHono* this); -void EnIceHono_SetupActionSmallFlame(EnIceHono* this); - -const ActorInit En_Ice_Hono_InitVars = { - ACTOR_EN_ICE_HONO, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnIceHono), - (ActorFunc)EnIceHono_Init, - (ActorFunc)EnIceHono_Destroy, - (ActorFunc)EnIceHono_Update, - (ActorFunc)EnIceHono_Draw, -}; - -static ColliderCylinderInit sCylinderInitCapturableFlame = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 25, 80, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInitDroppedFlame = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_OTHER, - AC_NONE, - OC1_ON | OC1_TYPE_2, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 12, 60, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChainCapturableFlame[] = { - ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 60, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainDroppedFlame[] = { - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainSmallFlame[] = { - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -f32 EnIceHono_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { - return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); -} - -void EnIceHono_InitCapturableFlame(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChainCapturableFlame); - Actor_SetScale(&this->actor, 0.0074f); - this->actor.flags |= ACTOR_FLAG_0; - Actor_SetFocus(&this->actor, 10.0f); - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitCapturableFlame); - Collider_UpdateCylinder(&this->actor, &this->collider); - - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - EnIceHono_SetupActionCapturableFlame(this); -} - -void EnIceHono_InitDroppedFlame(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChainDroppedFlame); - this->actor.scale.x = this->actor.scale.z = this->actor.scale.y = 0.00002f; - this->actor.gravity = -0.3f; - this->actor.minVelocityY = -4.0f; - this->actor.shape.yOffset = 0.0f; - this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = this->actor.world.rot.x = - this->actor.world.rot.y = this->actor.world.rot.z = 0; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDroppedFlame); - Collider_UpdateCylinder(&this->actor, &this->collider); - - this->collider.dim.radius = this->actor.scale.x * 4000.4f; - this->collider.dim.height = this->actor.scale.y * 8000.2f; - this->actor.colChkInfo.mass = 253; - EnIceHono_SetupActionDroppedFlame(this); -} - -void EnIceHono_InitSmallFlame(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChainSmallFlame); - this->actor.scale.x = this->actor.scale.z = this->actor.scale.y = 0.0008f; - this->actor.gravity = -0.3f; - this->actor.minVelocityY = -4.0f; - this->actor.shape.yOffset = 0.0f; - - EnIceHono_SetupActionSmallFlame(this); -} - -void EnIceHono_Init(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - s16 params = this->actor.params; - - switch (this->actor.params) { - case -1: - EnIceHono_InitCapturableFlame(&this->actor, globalCtx); - break; - case 0: - EnIceHono_InitDroppedFlame(&this->actor, globalCtx); - break; - case 1: - case 2: - EnIceHono_InitSmallFlame(&this->actor, globalCtx); - break; - } - - if ((this->actor.params == -1) || (this->actor.params == 0)) { - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, (s16)this->actor.world.pos.y + 10, - this->actor.world.pos.z, 155, 210, 255, 0); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - this->unk_154 = Rand_ZeroOne() * (0x1FFFF / 2.0f); - this->unk_156 = Rand_ZeroOne() * (0x1FFFF / 2.0f); - osSyncPrintf("(ice 炎)(arg_data 0x%04x)\n", this->actor.params); // "(ice flame)" - } -} - -void EnIceHono_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - - if ((this->actor.params == -1) || (this->actor.params == 0)) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -u32 EnIceHono_InBottleRange(EnIceHono* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->actor.xzDistToPlayer < 60.0f) { - Vec3f tempPos; - tempPos.x = Math_SinS(this->actor.yawTowardsPlayer + 0x8000) * 40.0f + player->actor.world.pos.x; - tempPos.y = player->actor.world.pos.y; - tempPos.z = Math_CosS(this->actor.yawTowardsPlayer + 0x8000) * 40.0f + player->actor.world.pos.z; - - //! @bug: this check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have - //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's - //! world rotation. - if (EnIceHono_XZDistanceSquared(&tempPos, &this->actor.world.pos) <= SQ(40.0f)) { - return true; - } - } - return false; -} - -void EnIceHono_SetupActionCapturableFlame(EnIceHono* this) { - this->actionFunc = EnIceHono_CapturableFlame; - this->alpha = 255; - this->actor.shape.yOffset = -1000.0f; -} - -void EnIceHono_CapturableFlame(EnIceHono* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - } else if (EnIceHono_InBottleRange(this, globalCtx)) { - // GI_MAX in this case allows the player to catch the actor in a bottle - func_8002F434(&this->actor, globalCtx, GI_MAX, 60.0f, 100.0f); - } - - if (this->actor.xzDistToPlayer < 200.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - func_8002F8F0(&this->actor, NA_SE_EV_FIRE_PILLAR_S - SFX_FLAG); -} - -void EnIceHono_SetupActionDroppedFlame(EnIceHono* this) { - this->actionFunc = EnIceHono_DropFlame; - this->timer = 200; - this->alpha = 255; -} - -void EnIceHono_DropFlame(EnIceHono* this, GlobalContext* globalCtx) { - u32 bgFlag = this->actor.bgCheckFlags & 1; - - Math_StepToF(&this->actor.scale.x, 0.0017f, 0.00008f); - this->actor.scale.z = this->actor.scale.x; - Math_StepToF(&this->actor.scale.y, 0.0017f, 0.00008f); - - if (bgFlag != 0) { - s32 i; - for (i = 0; i < 8; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ICE_HONO, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, - ((s32)(Rand_ZeroOne() * 1000.0f) + i * 0x2000) - 0x1F4, 0, 1); - } - EnIceHono_SetupActionSpreadFlames(this); - } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, this->actor.scale.x * 3500.0f, 0.0f, 5); - - Collider_UpdateCylinder(&this->actor, &this->collider); - this->collider.dim.radius = this->actor.scale.x * 4000.0f; - this->collider.dim.height = this->actor.scale.y * 8000.0f; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->timer <= 0) { - Actor_Kill(&this->actor); - } -} - -void EnIceHono_SetupActionSpreadFlames(EnIceHono* this) { - this->actionFunc = EnIceHono_SpreadFlames; - this->timer = 60; - this->alpha = 255; -} - -void EnIceHono_SpreadFlames(EnIceHono* this, GlobalContext* globalCtx) { - if (this->timer > 20) { - Math_StepToF(&this->actor.scale.x, 0.011f, 0.00014f); - Math_StepToF(&this->actor.scale.y, 0.006f, 0.00012f); - } else { - Math_StepToF(&this->actor.scale.x, 0.0001f, 0.00015f); - Math_StepToF(&this->actor.scale.y, 0.0001f, 0.00015f); - } - this->actor.scale.z = this->actor.scale.x; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, this->actor.scale.x * 3500.0f, 0.0f, 4); - if (this->timer < 25) { - this->alpha -= 10; - this->alpha = CLAMP(this->alpha, 0, 255); - } - - if ((this->alpha > 100) && (this->timer < 40)) { - Collider_UpdateCylinder(&this->actor, &this->collider); - this->collider.dim.radius = this->actor.scale.x * 6000.0f; - this->collider.dim.height = this->actor.scale.y * 8000.0f; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->timer == 46) { - s32 i; - for (i = 0; i < 10; i++) { - s32 rot = i * 0x1999; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ICE_HONO, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, - ((s32)(Rand_ZeroOne() * 1000.0f) + rot) - 0x1F4, 0, 2); - } - } - - if (this->timer <= 0) { - Actor_Kill(&this->actor); - } -} - -void EnIceHono_SetupActionSmallFlame(EnIceHono* this) { - this->actionFunc = EnIceHono_SmallFlameMove; - this->timer = 44; - this->alpha = 255; - if (this->actor.params == 1) { - this->smallFlameTargetYScale = (Rand_ZeroOne() * 0.005f) + 0.004f; - this->actor.speedXZ = (Rand_ZeroOne() * 1.6f) + 0.5f; - } else { - this->smallFlameTargetYScale = (Rand_ZeroOne() * 0.005f) + 0.003f; - this->actor.speedXZ = (Rand_ZeroOne() * 2.0f) + 0.5f; - } -} - -void EnIceHono_SmallFlameMove(EnIceHono* this, GlobalContext* globalCtx) { - if (this->timer > 20) { - Math_StepToF(&this->actor.scale.x, 0.006f, 0.00016f); - Math_StepToF(&this->actor.scale.y, this->smallFlameTargetYScale * 0.667f, 0.00014f); - } else { - Math_StepToF(&this->actor.scale.x, 0.0001f, 0.00015f); - Math_StepToF(&this->actor.scale.y, 0.0001f, 0.00015f); - } - this->actor.scale.z = this->actor.scale.x; - Math_StepToF(&this->actor.speedXZ, 0, 0.06f); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); - - if (this->timer < 25) { - this->alpha -= 10; - this->alpha = CLAMP(this->alpha, 0, 255); - } - if (this->timer <= 0) { - Actor_Kill(&this->actor); - } -} - -void EnIceHono_Update(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - s32 pad1; - f32 intensity; - s32 pad2; - f32 sin154; - f32 sin156; - - if (this->timer > 0) { - this->timer--; - } - if (this->actor.params == 0) { - func_8002F8F0(&this->actor, NA_SE_IT_FLAME - SFX_FLAG); - } - if ((this->actor.params == -1) || (this->actor.params == 0)) { - this->unk_154 += 0x1111; - this->unk_156 += 0x4000; - sin156 = Math_SinS(this->unk_156); - sin154 = Math_SinS(this->unk_154); - intensity = (Rand_ZeroOne() * 0.05f) + ((sin154 * 0.125f) + (sin156 * 0.1f)) + 0.425f; - if ((intensity > 0.7f) || (intensity < 0.2f)) { - osSyncPrintf("ありえない値(ratio = %f)\n", intensity); // "impossible value(ratio = %f)" - } - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, (s16)this->actor.world.pos.y + 10, - this->actor.world.pos.z, (s32)(155.0f * intensity), (s32)(210.0f * intensity), - (s32)(255.0f * intensity), 1400); - } - - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } -} - -void EnIceHono_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnIceHono* this = (EnIceHono*)thisx; - u32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ice_hono.c", 695); - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (globalCtx->state.frames * -20) % 512, - 32, 128)); - - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, this->alpha); - - gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 0); - - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y + 0x8000) * - (M_PI / 0x8000), - MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ice_hono.c", 718), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ice_hono.c", 722); -} diff --git a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.cpp b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.cpp new file mode 100644 index 000000000..fe061ba2a --- /dev/null +++ b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.cpp @@ -0,0 +1,407 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ICE_HONO_Z_EN_ICE_HONO_C +#include "actor_common.h" +/* + * File: z_en_ice_hono.c + * Overlay: ovl_En_Ice_Hono + * Description: The various types of Blue Fire + */ + +#include "z_en_ice_hono.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void EnIceHono_Init(Actor* thisx, GlobalContext* globalCtx); +void EnIceHono_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnIceHono_Update(Actor* thisx, GlobalContext* globalCtx); +void EnIceHono_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnIceHono_CapturableFlame(EnIceHono* pthis, GlobalContext* globalCtx); +void EnIceHono_DropFlame(EnIceHono* pthis, GlobalContext* globalCtx); +void EnIceHono_SpreadFlames(EnIceHono* pthis, GlobalContext* globalCtx); +void EnIceHono_SmallFlameMove(EnIceHono* pthis, GlobalContext* globalCtx); + +void EnIceHono_SetupActionCapturableFlame(EnIceHono* pthis); +void EnIceHono_SetupActionDroppedFlame(EnIceHono* pthis); +void EnIceHono_SetupActionSpreadFlames(EnIceHono* pthis); +void EnIceHono_SetupActionSmallFlame(EnIceHono* pthis); + +ActorInit En_Ice_Hono_InitVars = { + ACTOR_EN_ICE_HONO, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnIceHono), + (ActorFunc)EnIceHono_Init, + (ActorFunc)EnIceHono_Destroy, + (ActorFunc)EnIceHono_Update, + (ActorFunc)EnIceHono_Draw, +}; + +static ColliderCylinderInit sCylinderInitCapturableFlame = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 25, 80, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInitDroppedFlame = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_ON | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 12, 60, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChainCapturableFlame[] = { + ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 60, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +static InitChainEntry sInitChainDroppedFlame[] = { + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +static InitChainEntry sInitChainSmallFlame[] = { + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +f32 EnIceHono_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { + return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); +} + +void EnIceHono_InitCapturableFlame(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChainCapturableFlame); + Actor_SetScale(&pthis->actor, 0.0074f); + pthis->actor.flags |= ACTOR_FLAG_0; + Actor_SetFocus(&pthis->actor, 10.0f); + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInitCapturableFlame); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + EnIceHono_SetupActionCapturableFlame(pthis); +} + +void EnIceHono_InitDroppedFlame(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChainDroppedFlame); + pthis->actor.scale.x = pthis->actor.scale.z = pthis->actor.scale.y = 0.00002f; + pthis->actor.gravity = -0.3f; + pthis->actor.minVelocityY = -4.0f; + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.shape.rot.x = pthis->actor.shape.rot.y = pthis->actor.shape.rot.z = pthis->actor.world.rot.x = + pthis->actor.world.rot.y = pthis->actor.world.rot.z = 0; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInitDroppedFlame); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + pthis->collider.dim.radius = pthis->actor.scale.x * 4000.4f; + pthis->collider.dim.height = pthis->actor.scale.y * 8000.2f; + pthis->actor.colChkInfo.mass = 253; + EnIceHono_SetupActionDroppedFlame(pthis); +} + +void EnIceHono_InitSmallFlame(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChainSmallFlame); + pthis->actor.scale.x = pthis->actor.scale.z = pthis->actor.scale.y = 0.0008f; + pthis->actor.gravity = -0.3f; + pthis->actor.minVelocityY = -4.0f; + pthis->actor.shape.yOffset = 0.0f; + + EnIceHono_SetupActionSmallFlame(pthis); +} + +void EnIceHono_Init(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + s16 params = pthis->actor.params; + + switch (pthis->actor.params) { + case -1: + EnIceHono_InitCapturableFlame(&pthis->actor, globalCtx); + break; + case 0: + EnIceHono_InitDroppedFlame(&pthis->actor, globalCtx); + break; + case 1: + case 2: + EnIceHono_InitSmallFlame(&pthis->actor, globalCtx); + break; + } + + if ((pthis->actor.params == -1) || (pthis->actor.params == 0)) { + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, (s16)pthis->actor.world.pos.y + 10, + pthis->actor.world.pos.z, 155, 210, 255, 0); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + pthis->unk_154 = Rand_ZeroOne() * (0x1FFFF / 2.0f); + pthis->unk_156 = Rand_ZeroOne() * (0x1FFFF / 2.0f); + osSyncPrintf("(ice 炎)(arg_data 0x%04x)\n", pthis->actor.params); // "(ice flame)" + } +} + +void EnIceHono_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + + if ((pthis->actor.params == -1) || (pthis->actor.params == 0)) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +u32 EnIceHono_InBottleRange(EnIceHono* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actor.xzDistToPlayer < 60.0f) { + Vec3f tempPos; + tempPos.x = Math_SinS(pthis->actor.yawTowardsPlayer + 0x8000) * 40.0f + player->actor.world.pos.x; + tempPos.y = player->actor.world.pos.y; + tempPos.z = Math_CosS(pthis->actor.yawTowardsPlayer + 0x8000) * 40.0f + player->actor.world.pos.z; + + //! @bug: pthis check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have + //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's + //! world rotation. + if (EnIceHono_XZDistanceSquared(&tempPos, &pthis->actor.world.pos) <= SQ(40.0f)) { + return true; + } + } + return false; +} + +void EnIceHono_SetupActionCapturableFlame(EnIceHono* pthis) { + pthis->actionFunc = EnIceHono_CapturableFlame; + pthis->alpha = 255; + pthis->actor.shape.yOffset = -1000.0f; +} + +void EnIceHono_CapturableFlame(EnIceHono* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + } else if (EnIceHono_InBottleRange(pthis, globalCtx)) { + // GI_MAX in pthis case allows the player to catch the actor in a bottle + func_8002F434(&pthis->actor, globalCtx, GI_MAX, 60.0f, 100.0f); + } + + if (pthis->actor.xzDistToPlayer < 200.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + func_8002F8F0(&pthis->actor, NA_SE_EV_FIRE_PILLAR_S - SFX_FLAG); +} + +void EnIceHono_SetupActionDroppedFlame(EnIceHono* pthis) { + pthis->actionFunc = EnIceHono_DropFlame; + pthis->timer = 200; + pthis->alpha = 255; +} + +void EnIceHono_DropFlame(EnIceHono* pthis, GlobalContext* globalCtx) { + u32 bgFlag = pthis->actor.bgCheckFlags & 1; + + Math_StepToF(&pthis->actor.scale.x, 0.0017f, 0.00008f); + pthis->actor.scale.z = pthis->actor.scale.x; + Math_StepToF(&pthis->actor.scale.y, 0.0017f, 0.00008f); + + if (bgFlag != 0) { + s32 i; + for (i = 0; i < 8; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ICE_HONO, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, + ((s32)(Rand_ZeroOne() * 1000.0f) + i * 0x2000) - 0x1F4, 0, 1); + } + EnIceHono_SetupActionSpreadFlames(pthis); + } + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, pthis->actor.scale.x * 3500.0f, 0.0f, 5); + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->collider.dim.radius = pthis->actor.scale.x * 4000.0f; + pthis->collider.dim.height = pthis->actor.scale.y * 8000.0f; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->timer <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnIceHono_SetupActionSpreadFlames(EnIceHono* pthis) { + pthis->actionFunc = EnIceHono_SpreadFlames; + pthis->timer = 60; + pthis->alpha = 255; +} + +void EnIceHono_SpreadFlames(EnIceHono* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 20) { + Math_StepToF(&pthis->actor.scale.x, 0.011f, 0.00014f); + Math_StepToF(&pthis->actor.scale.y, 0.006f, 0.00012f); + } else { + Math_StepToF(&pthis->actor.scale.x, 0.0001f, 0.00015f); + Math_StepToF(&pthis->actor.scale.y, 0.0001f, 0.00015f); + } + pthis->actor.scale.z = pthis->actor.scale.x; + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, pthis->actor.scale.x * 3500.0f, 0.0f, 4); + if (pthis->timer < 25) { + pthis->alpha -= 10; + pthis->alpha = CLAMP(pthis->alpha, 0, 255); + } + + if ((pthis->alpha > 100) && (pthis->timer < 40)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->collider.dim.radius = pthis->actor.scale.x * 6000.0f; + pthis->collider.dim.height = pthis->actor.scale.y * 8000.0f; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->timer == 46) { + s32 i; + for (i = 0; i < 10; i++) { + s32 rot = i * 0x1999; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ICE_HONO, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, + ((s32)(Rand_ZeroOne() * 1000.0f) + rot) - 0x1F4, 0, 2); + } + } + + if (pthis->timer <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnIceHono_SetupActionSmallFlame(EnIceHono* pthis) { + pthis->actionFunc = EnIceHono_SmallFlameMove; + pthis->timer = 44; + pthis->alpha = 255; + if (pthis->actor.params == 1) { + pthis->smallFlameTargetYScale = (Rand_ZeroOne() * 0.005f) + 0.004f; + pthis->actor.speedXZ = (Rand_ZeroOne() * 1.6f) + 0.5f; + } else { + pthis->smallFlameTargetYScale = (Rand_ZeroOne() * 0.005f) + 0.003f; + pthis->actor.speedXZ = (Rand_ZeroOne() * 2.0f) + 0.5f; + } +} + +void EnIceHono_SmallFlameMove(EnIceHono* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 20) { + Math_StepToF(&pthis->actor.scale.x, 0.006f, 0.00016f); + Math_StepToF(&pthis->actor.scale.y, pthis->smallFlameTargetYScale * 0.667f, 0.00014f); + } else { + Math_StepToF(&pthis->actor.scale.x, 0.0001f, 0.00015f); + Math_StepToF(&pthis->actor.scale.y, 0.0001f, 0.00015f); + } + pthis->actor.scale.z = pthis->actor.scale.x; + Math_StepToF(&pthis->actor.speedXZ, 0, 0.06f); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 0.0f, 5); + + if (pthis->timer < 25) { + pthis->alpha -= 10; + pthis->alpha = CLAMP(pthis->alpha, 0, 255); + } + if (pthis->timer <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnIceHono_Update(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + s32 pad1; + f32 intensity; + s32 pad2; + f32 sin154; + f32 sin156; + + if (pthis->timer > 0) { + pthis->timer--; + } + if (pthis->actor.params == 0) { + func_8002F8F0(&pthis->actor, NA_SE_IT_FLAME - SFX_FLAG); + } + if ((pthis->actor.params == -1) || (pthis->actor.params == 0)) { + pthis->unk_154 += 0x1111; + pthis->unk_156 += 0x4000; + sin156 = Math_SinS(pthis->unk_156); + sin154 = Math_SinS(pthis->unk_154); + intensity = (Rand_ZeroOne() * 0.05f) + ((sin154 * 0.125f) + (sin156 * 0.1f)) + 0.425f; + if ((intensity > 0.7f) || (intensity < 0.2f)) { + osSyncPrintf("ありえない値(ratio = %f)\n", intensity); // "impossible value(ratio = %f)" + } + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, (s16)pthis->actor.world.pos.y + 10, + pthis->actor.world.pos.z, (s32)(155.0f * intensity), (s32)(210.0f * intensity), + (s32)(255.0f * intensity), 1400); + } + + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } +} + +void EnIceHono_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnIceHono* pthis = (EnIceHono*)thisx; + u32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ice_hono.c", 695); + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (globalCtx->state.frames * -20) % 512, + 32, 128)); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, pthis->alpha); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 0); + + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y + 0x8000) * + (M_PI / 0x8000), + MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ice_hono.c", 718), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ice_hono.c", 722); +} diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c deleted file mode 100644 index 64be13bd6..000000000 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ /dev/null @@ -1,1483 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_IK_Z_EN_IK_C -#include "actor_common.h" -/* - * File: z_en_ik.c - * Overlay: ovl_En_Ik - * Description: Iron Knuckle - */ - -#include "z_en_ik.h" -#include "scenes/dungeons/jyasinboss/jyasinboss_scene.h" -#include "objects/object_ik/object_ik.h" -#include "vt.h" -#include "def/code_8006BA00.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin_matrix.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef void (*EnIkDrawFunc)(struct EnIk*, GlobalContext*); - -void EnIk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnIk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnIk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnIk_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A74714(EnIk* this); -void func_80A747C0(EnIk* this, GlobalContext* globalCtx); -void func_80A7492C(EnIk* this, GlobalContext* globalCtx); -void func_80A74AAC(EnIk* this); -void func_80A74BA4(EnIk* this, GlobalContext* globalCtx); -void func_80A74E2C(EnIk* this); -void func_80A74EBC(EnIk* this, GlobalContext* globalCtx); -void func_80A7506C(EnIk* this); -void func_80A7510C(EnIk* this, GlobalContext* globalCtx); -void func_80A751C8(EnIk* this); -void func_80A75260(EnIk* this, GlobalContext* globalCtx); -void func_80A753D0(EnIk* this); -void func_80A7545C(EnIk* this, GlobalContext* globalCtx); -void func_80A754A0(EnIk* this); -void func_80A75530(EnIk* this, GlobalContext* globalCtx); -void func_80A755F0(EnIk* this); -void func_80A7567C(EnIk* this, GlobalContext* globalCtx); -void func_80A758B0(EnIk* this, GlobalContext* globalCtx); -void func_80A75A38(EnIk* this, GlobalContext* globalCtx); -void func_80A75FA0(Actor* thisx, GlobalContext* globalCtx); -void func_80A76798(Actor* thisx, GlobalContext* globalCtx); -void func_80A7748C(EnIk* this, GlobalContext* globalCtx); -void func_80A774BC(EnIk* this, GlobalContext* globalCtx); -void func_80A774F8(EnIk* this, GlobalContext* globalCtx); -void func_80A77844(EnIk* this, GlobalContext* globalCtx); -void func_80A779DC(EnIk* this, GlobalContext* globalCtx); -void func_80A77AEC(EnIk* this, GlobalContext* globalCtx); -void func_80A77B0C(EnIk* this, GlobalContext* globalCtx); -void func_80A77B3C(EnIk* this, GlobalContext* globalCtx); -void func_80A77ED0(EnIk* this, GlobalContext* globalCtx); -void func_80A77EDC(EnIk* this, GlobalContext* globalCtx); -void func_80A78160(EnIk* this, GlobalContext* globalCtx); -void func_80A781CC(Actor* thisx, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 25, 80, 0, { 0, 0, 0 } }, -}; - -static ColliderTrisElementInit sTrisElementsInit[2] = { - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC3FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC3FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, -}; - -static ColliderTrisInit sTrisInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 2, - sTrisElementsInit, -}; - -static ColliderQuadInit sQuadInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0x20000000, 0x00, 0x40 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0xD), - /* Deku stick */ DMG_ENTRY(2, 0xF), - /* Slingshot */ DMG_ENTRY(1, 0xE), - /* Explosive */ DMG_ENTRY(2, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(2, 0xE), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Kokiri sword */ DMG_ENTRY(1, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0xE), - /* Ice arrow */ DMG_ENTRY(2, 0xE), - /* Light arrow */ DMG_ENTRY(2, 0xE), - /* Unk arrow 1 */ DMG_ENTRY(2, 0xE), - /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), - /* Unk arrow 3 */ DMG_ENTRY(15, 0xE), - /* Fire magic */ DMG_ENTRY(0, 0x6), - /* Ice magic */ DMG_ENTRY(0, 0x6), - /* Light magic */ DMG_ENTRY(0, 0x6), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0xF), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(2, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(10, 0xF), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xF), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -void EnIk_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - - if (Actor_FindNearby(globalCtx, &this->actor, ACTOR_EN_IK, ACTORCAT_ENEMY, 8000.0f) == NULL) { - func_800F5B58(); - } - - Collider_DestroyTris(globalCtx, &this->shieldCollider); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyQuad(globalCtx, &this->axeCollider); -} - -void EnIk_SetupAction(EnIk* this, EnIkActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void func_80A74398(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - s32 pad; - EffectBlureInit1 blureInit; - - thisx->update = func_80A75FA0; - thisx->draw = func_80A76798; - thisx->flags |= ACTOR_FLAG_10; - - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, thisx, &sCylinderInit); - Collider_InitTris(globalCtx, &this->shieldCollider); - Collider_SetTris(globalCtx, &this->shieldCollider, thisx, &sTrisInit, this->shieldColliderItems); - Collider_InitQuad(globalCtx, &this->axeCollider); - Collider_SetQuad(globalCtx, &this->axeCollider, thisx, &sQuadInit); - - thisx->colChkInfo.damageTable = &sDamageTable; - thisx->colChkInfo.mass = MASS_HEAVY; - this->unk_2FC = 0; - thisx->colChkInfo.health = 30; - thisx->gravity = -1.0f; - this->switchFlags = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - - if (thisx->params == 0) { - thisx->colChkInfo.health += 20; - thisx->naviEnemyId = 0x34; - } else { - Actor_SetScale(thisx, 0.012f); - thisx->naviEnemyId = 0x35; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_ENEMY); - } - - blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = - blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = blureInit.p1EndColor[1] = blureInit.p2EndColor[0] = - blureInit.p2EndColor[1] = blureInit.p2EndColor[2] = 255; - - blureInit.p2StartColor[3] = 64; - blureInit.p1StartColor[3] = 200; - blureInit.p1StartColor[2] = blureInit.p1EndColor[2] = 150; - blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; - - blureInit.elemDuration = 8; - blureInit.unkFlag = 0; - blureInit.calcMode = 2; - - Effect_Add(globalCtx, &this->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); - func_80A74714(this); - - if (this->switchFlags != 0xFF) { - if (Flags_GetSwitch(globalCtx, this->switchFlags)) { - Actor_Kill(thisx); - } - } else if (thisx->params != 0 && Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { - Actor_Kill(thisx); - } -} - -s32 func_80A745E4(EnIk* this, GlobalContext* globalCtx) { - if (((this->unk_2FB != 0) || (this->actor.params == 0)) && - (func_800354B4(globalCtx, &this->actor, 100.0f, 0x2710, 0x4000, this->actor.shape.rot.y) != 0) && - (globalCtx->gameplayFrames & 1)) { - func_80A755F0(this); - return true; - } else { - return false; - } -} - -Actor* func_80A74674(GlobalContext* globalCtx, Actor* actor) { - Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - - while (prop != NULL) { - if ((prop == actor) || (prop->id != ACTOR_BG_JYA_IRONOBJ)) { - prop = prop->next; - continue; - } else if (Actor_ActorAIsFacingAndNearActorB(actor, prop, 80.0f, 0x2710)) { - return prop; - } - - prop = prop->next; - } - - return NULL; -} - -void func_80A74714(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_00CD70); - f32 frame; - - if (this->actor.params >= 2) { - frame = frames - 1.0f; - } else { - frame = 0.0f; - } - - Animation_Change(&this->skelAnime, &object_ik_Anim_00CD70, 0.0f, frame, frames, ANIMMODE_ONCE, 0.0f); - this->unk_2F8 = 3; - this->actor.speedXZ = 0.0f; - EnIk_SetupAction(this, func_80A747C0); -} - -void func_80A747C0(EnIk* this, GlobalContext* globalCtx) { - Vec3f sp24; - - if (this->bodyCollider.base.acFlags & AC_HIT) { - sp24 = this->actor.world.pos; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - sp24.y += 30.0f; - func_8003424C(globalCtx, &sp24); - this->skelAnime.playSpeed = 1.0f; - func_800F5ACC(NA_BGM_MINI_BOSS); - } - if (this->skelAnime.curFrame == 5.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_WAKEUP); - } - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; - func_80A74AAC(this); - } -} - -void func_80A7489C(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_00DD50); - - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; - this->unk_2F8 = 4; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_00DD50, 0.0f, 0.0f, frames, ANIMMODE_LOOP, 4.0f); - EnIk_SetupAction(this, func_80A7492C); -} - -void func_80A7492C(EnIk* this, GlobalContext* globalCtx) { - s32 phi_a0 = (this->unk_2FB == 0) ? 0xAAA : 0x3FFC; - s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(yawDiff) <= phi_a0) && (this->actor.xzDistToPlayer < 100.0f) && - (ABS(this->actor.yDistToPlayer) < 150.0f)) { - if ((globalCtx->gameplayFrames & 1)) { - func_80A74E2C(this); - } else { - func_80A751C8(this); - } - } else if ((ABS(yawDiff) <= 0x4000) && (ABS(this->actor.yDistToPlayer) < 150.0f)) { - func_80A74AAC(this); - } else { - func_80A74AAC(this); - } - func_80A745E4(this, globalCtx); - SkelAnime_Update(&this->skelAnime); -} - -void func_80A74AAC(EnIk* this) { - this->unk_2F8 = 5; - if (this->unk_2FB == 0) { - Animation_Change(&this->skelAnime, &object_ik_Anim_00ED24, 1.0f, 0.0f, - Animation_GetLastFrame(&object_ik_Anim_00ED24), ANIMMODE_LOOP, -4.0f); - this->actor.speedXZ = 0.9f; - } else { - Animation_Change(&this->skelAnime, &object_ik_Anim_006734, 1.0f, 0.0f, - Animation_GetLastFrame(&object_ik_Anim_006734), ANIMMODE_LOOP, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_DASH); - this->actor.speedXZ = 2.5f; - } - this->actor.world.rot.y = this->actor.shape.rot.y; - EnIk_SetupAction(this, func_80A74BA4); -} - -void func_80A74BA4(EnIk* this, GlobalContext* globalCtx) { - s16 temp_t0; - s16 temp_a1; - s16 yawDiff; - s16 sp30; - s16 sp2E; - s16 phi_a3; - - if (this->unk_2FB == 0) { - temp_t0 = 0xAAA; - phi_a3 = 0x320; - sp30 = 0; - sp2E = 0x10; - } else { - temp_t0 = 0x3FFC; - phi_a3 = 0x4B0; - sp30 = 2; - sp2E = 9; - } - temp_a1 = this->actor.wallYaw - this->actor.shape.rot.y; - if ((this->actor.bgCheckFlags & 8) && (ABS(temp_a1) >= 0x4000)) { - temp_a1 = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; - Math_SmoothStepToS(&this->actor.world.rot.y, temp_a1, 1, phi_a3, 0); - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, phi_a3, 0); - } - this->actor.shape.rot.y = this->actor.world.rot.y; - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(yawDiff) <= temp_t0) && (this->actor.xzDistToPlayer < 100.0f)) { - if (ABS(this->actor.yDistToPlayer) < 150.0f) { - if ((globalCtx->gameplayFrames & 1)) { - func_80A74E2C(this); - } else { - func_80A751C8(this); - } - } - } - if (func_80A74674(globalCtx, &this->actor) != NULL) { - func_80A751C8(this); - this->unk_2FC = 1; - } else { - temp_t0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (ABS(temp_t0) > 0x4000) { - this->unk_300--; - if (this->unk_300 == 0) { - func_80A754A0(this); - } - } else { - this->unk_300 = 0x28; - } - } - func_80A745E4(this, globalCtx); - SkelAnime_Update(&this->skelAnime); - if ((sp30 == (s16)this->skelAnime.curFrame) || (sp2E == (s16)this->skelAnime.curFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_WALK); - } -} - -void func_80A74E2C(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_001C28); - - this->unk_2FF = 1; - this->unk_2F8 = 6; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_001C28, 1.5f, 0.0f, frames, ANIMMODE_ONCE, -4.0f); - EnIk_SetupAction(this, func_80A74EBC); -} - -void func_80A74EBC(EnIk* this, GlobalContext* globalCtx) { - Vec3f sp2C; - - if (this->skelAnime.curFrame == 15.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); - } else if (this->skelAnime.curFrame == 21.0f) { - sp2C.x = this->actor.world.pos.x + Math_SinS(this->actor.shape.rot.y + 0x6A4) * 70.0f; - sp2C.z = this->actor.world.pos.z + Math_CosS(this->actor.shape.rot.y + 0x6A4) * 70.0f; - sp2C.y = this->actor.world.pos.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); - Camera_AddQuake(&globalCtx->mainCamera, 2, 0x19, 5); - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); - CollisionCheck_SpawnShieldParticles(globalCtx, &sp2C); - } - - if ((this->skelAnime.curFrame > 17.0f) && (this->skelAnime.curFrame < 23.0f)) { - this->unk_2FE = 1; - } else { - if ((this->unk_2FB != 0) && (this->skelAnime.curFrame < 10.0f)) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x5DC, 0); - this->actor.shape.rot.y = this->actor.world.rot.y; - } - this->unk_2FE = 0; - } - - if (SkelAnime_Update(&this->skelAnime)) { - func_80A7506C(this); - } -} - -void func_80A7506C(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_0029FC); - - this->unk_2FE = 0; - this->unk_2F9 = (s8)frames; - this->unk_2F8 = 7; - this->unk_2FF = this->unk_2FE; - Animation_Change(&this->skelAnime, &object_ik_Anim_0029FC, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_PULLOUT); - EnIk_SetupAction(this, func_80A7510C); -} - -void func_80A7510C(EnIk* this, GlobalContext* globalCtx) { - f32 frames; - - if (SkelAnime_Update(&this->skelAnime) || (--this->unk_2F9 == 0)) { - if (this->unk_2F8 == 8) { - func_80A7489C(this); - } else { - frames = Animation_GetLastFrame(&object_ik_Anim_002538); - this->unk_2F8 = 8; - Animation_Change(&this->skelAnime, &object_ik_Anim_002538, 1.5f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); - } - } -} - -void func_80A751C8(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_0033C4); - - this->unk_2FF = 2; - this->unk_300 = 0; - this->unk_2F8 = 6; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_0033C4, 0.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -6.0f); - this->unk_2FC = 0; - EnIk_SetupAction(this, func_80A75260); -} - -void func_80A75260(EnIk* this, GlobalContext* globalCtx) { - f32 temp_f0; - - this->unk_300 += 0x1C2; - temp_f0 = Math_SinS(this->unk_300); - this->skelAnime.playSpeed = ABS(temp_f0); - - if (this->skelAnime.curFrame > 11.0f) { - this->unk_2FF = 3; - } - if (((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 9.0f)) || - ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 18.0f))) { - if ((this->unk_2FC == 0) && (this->unk_2FB != 0) && (this->skelAnime.curFrame < 10.0f)) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x5DC, 0); - this->actor.shape.rot.y = this->actor.world.rot.y; - } - if (this->unk_2FE < 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); - } - this->unk_2FE = 1; - } else { - this->unk_2FE = 0; - } - if (SkelAnime_Update(&this->skelAnime)) { - func_80A753D0(this); - } -} - -void func_80A753D0(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_003DBC); - - this->unk_2FF = this->unk_2FE = 0; - this->unk_2F8 = 8; - Animation_Change(&this->skelAnime, &object_ik_Anim_003DBC, 1.5f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); - EnIk_SetupAction(this, func_80A7545C); -} - -void func_80A7545C(EnIk* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - func_80A7489C(this); - func_80A745E4(this, globalCtx); - } -} - -void func_80A754A0(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_0033C4); - - this->unk_2F8 = 1; - this->unk_2FF = 3; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_0033C4, 0.5f, 13.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); - EnIk_SetupAction(this, func_80A75530); -} - -void func_80A75530(EnIk* this, GlobalContext* globalCtx) { - Math_StepUntilS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x7D0); - this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 18.0f)) { - if (this->unk_2FE < 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); - } - this->unk_2FE = 1; - } else { - this->unk_2FE = 0; - } - if (SkelAnime_Update(&this->skelAnime)) { - func_80A753D0(this); - func_80A745E4(this, globalCtx); - } -} - -void func_80A755F0(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_00485C); - - this->unk_2FE = 0; - this->unk_2F8 = 9; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_00485C, 1.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); - EnIk_SetupAction(this, func_80A7567C); -} - -void func_80A7567C(EnIk* this, GlobalContext* globalCtx) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->shieldCollider.base); - if (SkelAnime_Update(&this->skelAnime)) { - if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4000) && - (this->actor.xzDistToPlayer < 100.0f) && (ABS(this->actor.yDistToPlayer) < 150.0f)) { - if ((globalCtx->gameplayFrames & 1)) { - func_80A74E2C(this); - } else { - func_80A751C8(this); - } - } else { - func_80A7489C(this); - } - } -} - -void func_80A75790(EnIk* this) { - s16 yaw; - s16 yawDiff; - - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bodyCollider.base.ac->world.pos); - this->unk_2F8 = 0; - yawDiff = yaw - this->actor.shape.rot.y; - if (ABS(yawDiff) <= 0x4000) { - Animation_Change(&this->skelAnime, &object_ik_Anim_006194, 1.0f, 0.0f, - Animation_GetLastFrame(&object_ik_Anim_006194), ANIMMODE_ONCE, -4.0f); - this->actor.speedXZ = -6.0f; - } else { - Animation_Change(&this->skelAnime, &object_ik_Anim_0045BC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_ik_Anim_0045BC), ANIMMODE_ONCE, -4.0f); - this->actor.speedXZ = 6.0f; - } - this->unk_2FE = 0; - EnIk_SetupAction(this, func_80A758B0); -} - -void func_80A758B0(EnIk* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params + 4)) { - this->bodyBreak.val = BODYBREAK_STATUS_FINISHED; - } - if (SkelAnime_Update(&this->skelAnime)) { - if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4000) { - func_80A7489C(this); - func_80A745E4(this, globalCtx); - } else { - func_80A754A0(this); - } - } -} - -void func_80A7598C(EnIk* this) { - f32 frames = Animation_GetLastFrame(&object_ik_Anim_005944); - - this->unk_2FE = 0; - this->unk_2F8 = 2; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_005944, 1.0f, 0.0f, frames, ANIMMODE_ONCE, -4.0f); - this->unk_2F9 = 0x18; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_DEAD); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_CUTBODY); - EnIk_SetupAction(this, func_80A75A38); -} - -void func_80A75A38(EnIk* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if ((this->actor.colChkInfo.health == 0) && (this->unk_2F9 != 0)) { - s32 i; - Vec3f pos; - Vec3f sp7C = { 0.0f, 0.5f, 0.0f }; - - this->unk_2F9--; - - for (i = 0xC - (this->unk_2F9 >> 1); i >= 0; i--) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(120.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(120.0f); - pos.y = this->actor.world.pos.y + 20.0f + Rand_CenteredFloat(50.0f); - EffectSsDeadDb_Spawn(globalCtx, &pos, &sp7C, &sp7C, 100, 0, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); - } - if (this->unk_2F9 == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); - if (this->switchFlags != 0xFF) { - Flags_SetSwitch(globalCtx, this->switchFlags); - } - Actor_Kill(&this->actor); - } - } - } else if (this->skelAnime.curFrame == 23.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_WALK); - } -} - -void func_80A75C38(EnIk* this, GlobalContext* globalCtx) { - f32 temp_f0; - u8 pad; - u8 pad2; - u8 prevHealth; - s32 temp_v0_3; - Vec3f sp38; - - if ((this->unk_2F8 == 3) || (this->unk_2F8 == 2)) { - return; - } - if (this->shieldCollider.base.acFlags & AC_BOUNCED) { - temp_f0 = Animation_GetLastFrame(&object_ik_Anim_00485C) - 2.0f; - if (this->skelAnime.curFrame < temp_f0) { - this->skelAnime.curFrame = temp_f0; - } - this->shieldCollider.base.acFlags &= ~AC_BOUNCED; - this->bodyCollider.base.acFlags &= ~AC_HIT; - return; - } - if (!(this->bodyCollider.base.acFlags & AC_HIT)) { - return; - } - sp38 = this->actor.world.pos; - sp38.y += 50.0f; - Actor_SetDropFlag(&this->actor, &this->bodyCollider.info, 1); - temp_v0_3 = this->actor.colChkInfo.damageEffect; - this->unk_2FD = temp_v0_3 & 0xFF; - this->bodyCollider.base.acFlags &= ~AC_HIT; - - if (1) {} - - if ((this->unk_2FD == 0) || (this->unk_2FD == 0xD) || ((this->unk_2FB == 0) && (this->unk_2FD == 0xE))) { - if (this->unk_2FD != 0) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp38); - } - return; - } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0xC); - prevHealth = this->actor.colChkInfo.health; - Actor_ApplyDamage(&this->actor); - if (this->actor.params != 0) { - if ((prevHealth > 10) && (this->actor.colChkInfo.health <= 10)) { - this->unk_2FB = 1; - BodyBreak_Alloc(&this->bodyBreak, 3, globalCtx); - } - } else if (this->actor.colChkInfo.health <= 10) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_BOSS); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_LAST_DAMAGE); - if (this->switchFlags != 0xFF) { - Flags_SetSwitch(globalCtx, this->switchFlags); - } - return; - } else if (prevHealth == 50) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - } - - if (this->actor.colChkInfo.health == 0) { - func_80A7598C(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - return; - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x7D0, 0); - if ((this->actor.params == 0) && (Rand_ZeroOne() < 0.5f)) { - if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 0x4000) { - func_80A754A0(this); - } - } - if ((this->actor.params != 0) && (this->unk_2FB != 0)) { - if ((prevHealth > 10) && (this->actor.colChkInfo.health <= 10)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_CUTBODY); - } - func_80A75790(this); - return; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); - CollisionCheck_SpawnShieldParticles(globalCtx, &sp38); -} - -void func_80A75FA0(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - u8 prevInvincibilityTimer; - - this->unk_2FA = this->unk_2FB; - func_80A75C38(this, globalCtx); - if ((this->actor.params == 0) && (this->actor.colChkInfo.health <= 10)) { - func_80A781CC(&this->actor, globalCtx); - return; - } - this->actionFunc(this, globalCtx); - if (this->axeCollider.base.atFlags & AT_HIT) { - this->axeCollider.base.atFlags &= ~AT_HIT; - if (&player->actor == this->axeCollider.base.at) { - prevInvincibilityTimer = player->invincibilityTimer; - if (player->invincibilityTimer <= 0) { - if (player->invincibilityTimer < -39) { - player->invincibilityTimer = 0; - } else { - player->invincibilityTimer = 0; - globalCtx->damagePlayer(globalCtx, -64); - this->unk_2FE = 0; - } - } - func_8002F71C(globalCtx, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); - player->invincibilityTimer = prevInvincibilityTimer; - } - } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 0x1D); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 45.0f; - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - if ((this->actor.colChkInfo.health > 0) && (this->actor.colorFilterTimer == 0) && (this->unk_2F8 >= 2)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - if (this->unk_2FE > 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->axeCollider.base); - } - if (this->unk_2F8 == 9) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->shieldCollider.base); - } -} - -Gfx* func_80A761B0(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { - Gfx* displayList; - Gfx* displayListHead; - - displayList = Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); - displayListHead = displayList; - - gDPPipeSync(displayListHead++); - gDPSetPrimColor(displayListHead++, 0, 0, primR, primG, primB, 255); - gDPSetEnvColor(displayListHead++, envR, envG, envB, 255); - gSPEndDisplayList(displayListHead++); - - return displayList; -} - -s32 EnIk_OverrideLimbDraw3(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnIk* this = (EnIk*)thisx; - - if (limbIndex == 12) { - if (this->actor.params != 0) { - *dList = object_ik_DL_018E78; - } - } else if (limbIndex == 13) { - if (this->actor.params != 0) { - *dList = object_ik_DL_019100; - } - } else if ((limbIndex == 26) || (limbIndex == 27)) { - if ((this->unk_2FA & 1)) { - *dList = NULL; - } - } else if ((limbIndex == 28) || (limbIndex == 29)) { - if (!(this->unk_2FA & 1)) { - *dList = NULL; - } - } - return false; -} - -// unused -static Vec3f D_80A78470 = { 300.0f, 0.0f, 0.0f }; - -static Vec3f D_80A7847C[] = { - { 800.0f, -200.0f, -5200.0f }, - { 0.0f, 0.0f, 0.0f }, - { -200.0f, -2200.0f, -200.0f }, - { -6000.0f, 2000.0f, -3000.0f }, -}; - -static Vec3f D_80A784AC[] = { - { -3000.0, -700.0, -5000.0 }, - { -3000.0, -700.0, 2000.0 }, - { 4000.0, -700.0, 2000.0 }, -}; - -static Vec3f D_80A784D0[] = { - { 4000.0, -700.0, 2000.0 }, - { 4000.0, -700.0, -5000.0 }, - { -3000.0, -700.0, -5000.0 }, -}; - -void EnIk_PostLimbDraw3(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - Vec3f spF4; - Vec3f spE8; - EnIk* this = (EnIk*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1201); - - if (this->unk_2FB & 1) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 26, 27, 28, dList, BODYBREAK_OBJECT_DEFAULT); - } - if (limbIndex == 12) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1217), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->actor.params != 0) { - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_019E08); - } else { - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); - } - } else if (limbIndex == 17) { - s32 i; - Vec3f sp9C[3]; - Vec3f sp78[3]; - - Matrix_MultVec3f(&D_80A7847C[0], &this->axeCollider.dim.quad[1]); - Matrix_MultVec3f(&D_80A7847C[1], &this->axeCollider.dim.quad[0]); - Matrix_MultVec3f(&D_80A7847C[2], &this->axeCollider.dim.quad[3]); - Matrix_MultVec3f(&D_80A7847C[3], &this->axeCollider.dim.quad[2]); - Collider_SetQuadVertices(&this->axeCollider, &this->axeCollider.dim.quad[0], &this->axeCollider.dim.quad[1], - &this->axeCollider.dim.quad[2], &this->axeCollider.dim.quad[3]); - Matrix_MultVec3f(&D_80A7847C[0], &spF4); - Matrix_MultVec3f(&D_80A7847C[1], &spE8); - if (this->unk_2FE > 0) { - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &spF4, &spE8); - } else if (this->unk_2FE == 0) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); - this->unk_2FE = -1; - } - if (this->unk_2F8 == 9) { - for (i = 0; i < ARRAY_COUNT(sp78); i++) { - Matrix_MultVec3f(&D_80A784AC[i], &sp9C[i]); - Matrix_MultVec3f(&D_80A784D0[i], &sp78[i]); - } - - Collider_SetTrisVertices(&this->shieldCollider, 0, &sp9C[0], &sp9C[1], &sp9C[2]); - Collider_SetTrisVertices(&this->shieldCollider, 1, &sp78[0], &sp78[1], &sp78[2]); - } - } - - switch (limbIndex) { - case 22: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1270), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); - break; - case 24: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1275), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); - break; - case 26: - if (!(this->unk_2FA & 1)) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1281), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); - } - break; - case 27: - if (!(this->unk_2FA & 1)) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1288), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); - } - break; - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1294); -} - -void func_80A76798(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1309); - - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - - if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 245, 225, 155, 30, 30, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 255, 40, 0, 40, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 255, 255, 255, 20, 40, 30)); - } else if (this->actor.params == 1) { - gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 245, 255, 205, 30, 35, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 185, 135, 25, 20, 20, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 255, 255, 255, 30, 40, 20)); - } else if (this->actor.params == 2) { - gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 55, 65, 55, 0, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 205, 165, 75, 25, 20, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 205, 165, 75, 25, 20, 0)); - } else { - gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 255, 255, 255, 180, 180, 180)); - gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 225, 205, 115, 25, 20, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 225, 205, 115, 25, 20, 0)); - } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnIk_OverrideLimbDraw3, EnIk_PostLimbDraw3, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1351); -} - -void EnIk_StartMusic(void) { - func_800F5ACC(NA_BGM_MINI_BOSS); -} - -void func_80A76C14(EnIk* this) { - if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_WAKEUP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (Animation_OnFrame(&this->skelAnime, 33.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_WALK, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (Animation_OnFrame(&this->skelAnime, 68.0f) || Animation_OnFrame(&this->skelAnime, 80.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_DEMO, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (Animation_OnFrame(&this->skelAnime, 107.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_FINGER_DEMO, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (Animation_OnFrame(&this->skelAnime, 156.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_DEMO, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else if (Animation_OnFrame(&this->skelAnime, 188.0f)) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_WAVE_DEMO, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void func_80A76DDC(EnIk* this, GlobalContext* globalCtx, Vec3f* pos) { - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_TRANSFORM, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); -} - -void func_80A76E2C(EnIk* this, GlobalContext* globalCtx, Vec3f* pos) { - static Vec3f D_80A78514[] = { - { 1000.0, -1000.0, 1000.0 }, { 0.0, -1000.0, 0.0 }, { -1000.0, -5000.0, -4000.0 }, - { 1000.0, -5000.0, -3000.0 }, { -1000.0, 1000.0, -6000.0 }, { -1000.0, 3000.0, -5000.0 }, - { -800.0, 1000.0, -3000.0 }, { 0.0, -4000.0, -2000.0 }, { -1000.0, -2000.0, -6000.0 }, - { 1000.0, -3000.0, 0.0 }, { 2000.0, -2000.0, -4000.0 }, { -1000.0, 0.0, -6000.0 }, - { 1000.0, -2000.0, -2000.0 }, { 0.0, -2000.0, 2100.0 }, { 0.0, 0.0, 0.0 }, - { 1000.0, -1000.0, -6000.0 }, { 2000.0, 0.0, -3000.0 }, { -1000.0, -1000.0, -4000.0 }, - { 900.0, -800.0, 2700.0 }, { 720.0f, 900.0f, 2500.0f }, - }; - - if (this->unk_4D4 == 0) { - s32 pad; - Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; - Vec3f effectAccel = { 0.0f, 0.3f, 0.0f }; - s32 i; - - for (i = ARRAY_COUNT(D_80A78514) - 1; i >= 0; i--) { - Color_RGBA8 primColor = { 200, 200, 200, 255 }; - Color_RGBA8 envColor = { 150, 150, 150, 0 }; - s32 temp_v0; - Vec3f effectPos; - - Matrix_MultVec3f(&D_80A78514[i], &effectPos); - temp_v0 = (Rand_ZeroOne() * 20.0f) - 10.0f; - primColor.r += temp_v0; - primColor.g += temp_v0; - primColor.b += temp_v0; - envColor.r += temp_v0; - envColor.g += temp_v0; - envColor.b += temp_v0; - func_8002829C(globalCtx, &effectPos, &effectVelocity, &effectAccel, &primColor, &envColor, - (Rand_ZeroOne() * 60.0f) + 300.0f, 0); - } - - this->unk_4D4 = 1; - func_80A76DDC(this, globalCtx, pos); - } -} - -void func_80A77034(EnIk* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -s32 func_80A7707C(EnIk* this) { - return SkelAnime_Update(&this->skelAnime); -} - -CsCmdActorAction* EnIk_GetNpcAction(GlobalContext* globalCtx, s32 actionIdx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[actionIdx]; - } else { - return NULL; - } -} - -void func_80A770C0(EnIk* this, GlobalContext* globalCtx, s32 actionIdx) { - CsCmdActorAction* npcAction = EnIk_GetNpcAction(globalCtx, actionIdx); - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -f32 EnIk_curFrame(Actor* thisx) { - EnIk* this = (EnIk*)thisx; - - return this->skelAnime.curFrame; -} - -void func_80A77148(EnIk* this) { - this->action = 0; - this->drawMode = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80A77158(EnIk* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_ik_Anim_00C114, 1.0f, 0.0f, - Animation_GetLastFrame(&object_ik_Anim_00C114), ANIMMODE_ONCE, 0.0f); - func_80A770C0(this, globalCtx, 4); - this->action = 1; - this->drawMode = 1; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80A771E4(EnIk* this) { - Animation_Change(&this->skelAnime, &object_ik_Anim_00C114, 1.0f, 0.0f, - Animation_GetLastFrame(&object_ik_Anim_00C114), ANIMMODE_ONCE, 0.0f); - this->action = 2; - this->drawMode = 1; - this->unk_4D4 = 0; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80A77264(EnIk* this, GlobalContext* globalCtx, s32 arg2) { - if ((arg2 != 0) && (EnIk_GetNpcAction(globalCtx, 4) != NULL)) { - func_80A78160(this, globalCtx); - } -} - -void func_80A772A4(EnIk* this) { - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_STAGGER_DEMO, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); -} - -void func_80A772EC(EnIk* this, GlobalContext* globalCtx) { - static Vec3f D_80A78FA0; - s32 pad[2]; - f32 wDest; - - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &D_80A78FA0, &wDest); - Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_DEAD, &D_80A78FA0, 4, &D_801333E0, &D_801333E0, &D_801333E8); -} - -void func_80A7735C(EnIk* this, GlobalContext* globalCtx) { - s32 pad[3]; - f32 frames = Animation_GetLastFrame(&object_ik_Anim_0203D8); - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ik_Skel_0205C0, NULL, this->jointTable, this->morphTable, - 30); - Animation_Change(&this->skelAnime, &object_ik_Anim_0203D8, 1.0f, 0.0f, frames, ANIMMODE_ONCE, 0.0f); - this->action = 3; - this->drawMode = 2; - func_80A770C0(this, globalCtx, 4); - func_80A772EC(this, globalCtx); - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80A77434(EnIk* this, GlobalContext* globalCtx) { - this->action = 4; - this->drawMode = 2; - func_80A772A4(this); - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80A77474(EnIk* this, GlobalContext* globalCtx) { - this->action = 5; - this->drawMode = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80A7748C(EnIk* this, GlobalContext* globalCtx) { - func_80A77034(this, globalCtx); - func_80A779DC(this, globalCtx); -} - -void func_80A774BC(EnIk* this, GlobalContext* globalCtx) { - func_80A7707C(this); - func_80A77034(this, globalCtx); - func_80A779DC(this, globalCtx); -} - -void func_80A774F8(EnIk* this, GlobalContext* globalCtx) { - if (EnIk_GetNpcAction(globalCtx, 4) == NULL) { - Actor_Kill(&this->actor); - } -} - -s32 EnIk_OverrideLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnIk* this = (EnIk*)thisx; - - if ((limbIndex == 13) || (limbIndex == 26) || (limbIndex == 27)) { - if (EnIk_curFrame(&this->actor) >= 30.0f) { - *dList = NULL; - } - } - - return 0; -} - -void EnIk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 207); - - switch (limbIndex) { - case 13: { - EnIk* this = (EnIk*)thisx; - - if (EnIk_curFrame(&this->actor) < 30.0f) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 267), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); - } - } break; - case 22: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 274), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); - break; - case 24: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 280), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); - break; - case 26: { - EnIk* this = (EnIk*)thisx; - - if (EnIk_curFrame(&this->actor) < 30.0f) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 288), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); - } - } break; - case 27: { - EnIk* this = (EnIk*)thisx; - - if (EnIk_curFrame(&this->actor) < 30.0f) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 297), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); - } - } break; - } - CLOSE_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 304); -} - -void func_80A77844(EnIk* this, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - SkelAnime* skelAnime = &this->skelAnime; - s32 pad[2]; - - OPEN_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 322); - - func_8002EBCC(&this->actor, globalCtx, 0); - func_80093D18(gfxCtx); - func_80093D84(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(gfxCtx, 245, 225, 155, 30, 30, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(gfxCtx, 255, 40, 0, 40, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(gfxCtx, 255, 255, 255, 20, 40, 30)); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnIk_OverrideLimbDraw2, EnIk_PostLimbDraw2, this); - - CLOSE_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 345); -} - -void func_80A779DC(EnIk* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnIk_GetNpcAction(globalCtx, 4); - u32 action; - u32 currentNpcAction; - - if (npcAction != NULL) { - action = npcAction->action; - currentNpcAction = this->npcAction; - if (action != currentNpcAction) { - switch (action) { - case 1: - func_80A77148(this); - break; - case 2: - func_80A77158(this, globalCtx); - break; - case 3: - func_80A771E4(this); - break; - case 4: - func_80A78160(this, globalCtx); - break; - case 5: - func_80A7735C(this, globalCtx); - break; - case 6: - func_80A77434(this, globalCtx); - break; - case 7: - func_80A77474(this, globalCtx); - break; - default: - osSyncPrintf("En_Ik_inConfrontion_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - - this->npcAction = action; - } - } -} - -void func_80A77AEC(EnIk* this, GlobalContext* globalCtx) { - func_80A779DC(this, globalCtx); -} - -void func_80A77B0C(EnIk* this, GlobalContext* globalCtx) { - func_80A77034(this, globalCtx); - func_80A779DC(this, globalCtx); -} - -void func_80A77B3C(EnIk* this, GlobalContext* globalCtx) { - s32 sp24; - - sp24 = func_80A7707C(this); - func_80A76C14(this); - func_80A77034(this, globalCtx); - func_80A779DC(this, globalCtx); - func_80A77264(this, globalCtx, sp24); -} - -static EnIkActionFunc sActionFuncs[] = { - func_80A77AEC, func_80A77B0C, func_80A77B3C, func_80A7748C, func_80A774BC, func_80A774F8, -}; - -void EnIk_Update(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - - if (this->action < 0 || this->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[this->action] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sActionFuncs[this->action](this, globalCtx); -} - -s32 EnIk_OverrideLimbDraw1(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnIk* this = (EnIk*)thisx; - f32 curFrame; - - switch (limbIndex) { - case 17: - curFrame = this->skelAnime.curFrame; - if (curFrame < 120.0f) { - *dList = NULL; - } else { - func_80A76E2C(this, globalCtx, pos); - } - break; - case 29: - case 30: - *dList = NULL; - break; - } - - return 0; -} - -void EnIk_PostLimbDraw1(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 571); - - switch (limbIndex) { - case 12: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 575), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); - break; - case 22: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 581), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); - break; - case 24: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 587), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); - break; - case 26: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 593), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); - break; - case 27: - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 599), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); - break; - } - - CLOSE_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 604); -} - -void func_80A77ED0(EnIk* this, GlobalContext* globalCtx) { -} - -void func_80A77EDC(EnIk* this, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - SkelAnime* skelAnime = &this->skelAnime; - s32 pad[2]; - - OPEN_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 630); - - func_8002EBCC(&this->actor, globalCtx, 0); - func_80093D18(gfxCtx); - func_80093D84(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(gfxCtx, 245, 225, 155, 30, 30, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(gfxCtx, 255, 40, 0, 40, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(gfxCtx, 255, 255, 255, 20, 40, 30)); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnIk_OverrideLimbDraw1, EnIk_PostLimbDraw1, this); - - CLOSE_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 653); -} - -static EnIkDrawFunc sDrawFuncs[] = { func_80A77ED0, func_80A77EDC, func_80A77844 }; - -void EnIk_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - - if (this->drawMode < 0 || this->drawMode >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[this->drawMode] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sDrawFuncs[this->drawMode](this, globalCtx); -} - -void func_80A780D0(EnIk* this, GlobalContext* globalCtx) { - if (this->actor.params == 0) { - if (!(gSaveContext.eventChkInf[3] & 0x800)) { - this->actor.update = EnIk_Update; - this->actor.draw = EnIk_Draw; - Actor_SetScale(&this->actor, 0.01f); - } else { - func_80A78160(this, globalCtx); - EnIk_StartMusic(); - } - } - osSyncPrintf("En_Ik_inConfrontion_Init : %d !!!!!!!!!!!!!!!!\n", this->actor.params); -} - -void func_80A78160(EnIk* this, GlobalContext* globalCtx) { - this->actor.update = func_80A75FA0; - this->actor.draw = func_80A76798; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; - gSaveContext.eventChkInf[3] |= 0x800; - Actor_SetScale(&this->actor, 0.012f); - func_80A7489C(this); -} - -void func_80A781CC(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - - if (!Gameplay_InCsMode(globalCtx)) { - this->actor.update = EnIk_Update; - this->actor.draw = EnIk_Draw; - Cutscene_SetSegment(globalCtx, gSpiritBossNabooruKnuckleDefeatCs); - gSaveContext.cutsceneTrigger = 1; - Actor_SetScale(&this->actor, 0.01f); - gSaveContext.eventChkInf[3] |= 0x1000; - func_80A7735C(this, globalCtx); - } -} - -void EnIk_Init(Actor* thisx, GlobalContext* globalCtx) { - EnIk* this = (EnIk*)thisx; - s32 flag = this->actor.params & 0xFF00; - - if (((this->actor.params & 0xFF) == 0 && (gSaveContext.eventChkInf[3] & 0x1000)) || - (flag != 0 && Flags_GetSwitch(globalCtx, flag >> 8))) { - Actor_Kill(&this->actor); - } else { - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ik_Skel_01E178, &object_ik_Anim_00C114, - this->jointTable, this->morphTable, 30); - func_80A74398(&this->actor, globalCtx); - func_80A780D0(this, globalCtx); - } -} - -const ActorInit En_Ik_InitVars = { - ACTOR_EN_IK, - ACTORCAT_BOSS, - FLAGS, - OBJECT_IK, - sizeof(EnIk), - (ActorFunc)EnIk_Init, - (ActorFunc)EnIk_Destroy, - (ActorFunc)EnIk_Update, - (ActorFunc)EnIk_Draw, -}; diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.cpp b/src/overlays/actors/ovl_En_Ik/z_en_ik.cpp new file mode 100644 index 000000000..251fd4eea --- /dev/null +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.cpp @@ -0,0 +1,1483 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_IK_Z_EN_IK_C +#include "actor_common.h" +/* + * File: z_en_ik.c + * Overlay: ovl_En_Ik + * Description: Iron Knuckle + */ + +#include "z_en_ik.h" +#include "scenes/dungeons/jyasinboss/jyasinboss_scene.h" +#include "objects/object_ik/object_ik.h" +#include "vt.h" +#include "def/code_8006BA00.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin_matrix.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef void (*EnIkDrawFunc)(struct EnIk*, GlobalContext*); + +void EnIk_Init(Actor* thisx, GlobalContext* globalCtx); +void EnIk_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnIk_Update(Actor* thisx, GlobalContext* globalCtx); +void EnIk_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A74714(EnIk* pthis); +void func_80A747C0(EnIk* pthis, GlobalContext* globalCtx); +void func_80A7492C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A74AAC(EnIk* pthis); +void func_80A74BA4(EnIk* pthis, GlobalContext* globalCtx); +void func_80A74E2C(EnIk* pthis); +void func_80A74EBC(EnIk* pthis, GlobalContext* globalCtx); +void func_80A7506C(EnIk* pthis); +void func_80A7510C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A751C8(EnIk* pthis); +void func_80A75260(EnIk* pthis, GlobalContext* globalCtx); +void func_80A753D0(EnIk* pthis); +void func_80A7545C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A754A0(EnIk* pthis); +void func_80A75530(EnIk* pthis, GlobalContext* globalCtx); +void func_80A755F0(EnIk* pthis); +void func_80A7567C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A758B0(EnIk* pthis, GlobalContext* globalCtx); +void func_80A75A38(EnIk* pthis, GlobalContext* globalCtx); +void func_80A75FA0(Actor* thisx, GlobalContext* globalCtx); +void func_80A76798(Actor* thisx, GlobalContext* globalCtx); +void func_80A7748C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A774BC(EnIk* pthis, GlobalContext* globalCtx); +void func_80A774F8(EnIk* pthis, GlobalContext* globalCtx); +void func_80A77844(EnIk* pthis, GlobalContext* globalCtx); +void func_80A779DC(EnIk* pthis, GlobalContext* globalCtx); +void func_80A77AEC(EnIk* pthis, GlobalContext* globalCtx); +void func_80A77B0C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A77B3C(EnIk* pthis, GlobalContext* globalCtx); +void func_80A77ED0(EnIk* pthis, GlobalContext* globalCtx); +void func_80A77EDC(EnIk* pthis, GlobalContext* globalCtx); +void func_80A78160(EnIk* pthis, GlobalContext* globalCtx); +void func_80A781CC(Actor* thisx, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 25, 80, 0, { 0, 0, 0 } }, +}; + +static ColliderTrisElementInit sTrisElementsInit[2] = { + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC3FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC3FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, +}; + +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, +}; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x40 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0xD), + /* Deku stick */ DMG_ENTRY(2, 0xF), + /* Slingshot */ DMG_ENTRY(1, 0xE), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0xD), + /* Normal arrow */ DMG_ENTRY(2, 0xE), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(0, 0xD), + /* Kokiri sword */ DMG_ENTRY(1, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(2, 0xE), + /* Ice arrow */ DMG_ENTRY(2, 0xE), + /* Light arrow */ DMG_ENTRY(2, 0xE), + /* Unk arrow 1 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 3 */ DMG_ENTRY(15, 0xE), + /* Fire magic */ DMG_ENTRY(0, 0x6), + /* Ice magic */ DMG_ENTRY(0, 0x6), + /* Light magic */ DMG_ENTRY(0, 0x6), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(2, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(10, 0xF), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +void EnIk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + + if (Actor_FindNearby(globalCtx, &pthis->actor, ACTOR_EN_IK, ACTORCAT_ENEMY, 8000.0f) == NULL) { + func_800F5B58(); + } + + Collider_DestroyTris(globalCtx, &pthis->shieldCollider); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyQuad(globalCtx, &pthis->axeCollider); +} + +void EnIk_SetupAction(EnIk* pthis, EnIkActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void func_80A74398(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + s32 pad; + EffectBlureInit1 blureInit; + + thisx->update = func_80A75FA0; + thisx->draw = func_80A76798; + thisx->flags |= ACTOR_FLAG_10; + + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, thisx, &sCylinderInit); + Collider_InitTris(globalCtx, &pthis->shieldCollider); + Collider_SetTris(globalCtx, &pthis->shieldCollider, thisx, &sTrisInit, pthis->shieldColliderItems); + Collider_InitQuad(globalCtx, &pthis->axeCollider); + Collider_SetQuad(globalCtx, &pthis->axeCollider, thisx, &sQuadInit); + + thisx->colChkInfo.damageTable = &sDamageTable; + thisx->colChkInfo.mass = MASS_HEAVY; + pthis->unk_2FC = 0; + thisx->colChkInfo.health = 30; + thisx->gravity = -1.0f; + pthis->switchFlags = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + + if (thisx->params == 0) { + thisx->colChkInfo.health += 20; + thisx->naviEnemyId = 0x34; + } else { + Actor_SetScale(thisx, 0.012f); + thisx->naviEnemyId = 0x35; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_ENEMY); + } + + blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = + blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = blureInit.p1EndColor[1] = blureInit.p2EndColor[0] = + blureInit.p2EndColor[1] = blureInit.p2EndColor[2] = 255; + + blureInit.p2StartColor[3] = 64; + blureInit.p1StartColor[3] = 200; + blureInit.p1StartColor[2] = blureInit.p1EndColor[2] = 150; + blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; + + blureInit.elemDuration = 8; + blureInit.unkFlag = 0; + blureInit.calcMode = 2; + + Effect_Add(globalCtx, &pthis->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); + func_80A74714(pthis); + + if (pthis->switchFlags != 0xFF) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlags)) { + Actor_Kill(thisx); + } + } else if (thisx->params != 0 && Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { + Actor_Kill(thisx); + } +} + +s32 func_80A745E4(EnIk* pthis, GlobalContext* globalCtx) { + if (((pthis->unk_2FB != 0) || (pthis->actor.params == 0)) && + (func_800354B4(globalCtx, &pthis->actor, 100.0f, 0x2710, 0x4000, pthis->actor.shape.rot.y) != 0) && + (globalCtx->gameplayFrames & 1)) { + func_80A755F0(pthis); + return true; + } else { + return false; + } +} + +Actor* func_80A74674(GlobalContext* globalCtx, Actor* actor) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + + while (prop != NULL) { + if ((prop == actor) || (prop->id != ACTOR_BG_JYA_IRONOBJ)) { + prop = prop->next; + continue; + } else if (Actor_ActorAIsFacingAndNearActorB(actor, prop, 80.0f, 0x2710)) { + return prop; + } + + prop = prop->next; + } + + return NULL; +} + +void func_80A74714(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_00CD70); + f32 frame; + + if (pthis->actor.params >= 2) { + frame = frames - 1.0f; + } else { + frame = 0.0f; + } + + Animation_Change(&pthis->skelAnime, &object_ik_Anim_00CD70, 0.0f, frame, frames, ANIMMODE_ONCE, 0.0f); + pthis->unk_2F8 = 3; + pthis->actor.speedXZ = 0.0f; + EnIk_SetupAction(pthis, func_80A747C0); +} + +void func_80A747C0(EnIk* pthis, GlobalContext* globalCtx) { + Vec3f sp24; + + if (pthis->bodyCollider.base.acFlags & AC_HIT) { + sp24 = pthis->actor.world.pos; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + sp24.y += 30.0f; + func_8003424C(globalCtx, &sp24); + pthis->skelAnime.playSpeed = 1.0f; + func_800F5ACC(NA_BGM_MINI_BOSS); + } + if (pthis->skelAnime.curFrame == 5.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_WAKEUP); + } + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; + func_80A74AAC(pthis); + } +} + +void func_80A7489C(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_00DD50); + + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; + pthis->unk_2F8 = 4; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_00DD50, 0.0f, 0.0f, frames, ANIMMODE_LOOP, 4.0f); + EnIk_SetupAction(pthis, func_80A7492C); +} + +void func_80A7492C(EnIk* pthis, GlobalContext* globalCtx) { + s32 phi_a0 = (pthis->unk_2FB == 0) ? 0xAAA : 0x3FFC; + s16 yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(yawDiff) <= phi_a0) && (pthis->actor.xzDistToPlayer < 100.0f) && + (ABS(pthis->actor.yDistToPlayer) < 150.0f)) { + if ((globalCtx->gameplayFrames & 1)) { + func_80A74E2C(pthis); + } else { + func_80A751C8(pthis); + } + } else if ((ABS(yawDiff) <= 0x4000) && (ABS(pthis->actor.yDistToPlayer) < 150.0f)) { + func_80A74AAC(pthis); + } else { + func_80A74AAC(pthis); + } + func_80A745E4(pthis, globalCtx); + SkelAnime_Update(&pthis->skelAnime); +} + +void func_80A74AAC(EnIk* pthis) { + pthis->unk_2F8 = 5; + if (pthis->unk_2FB == 0) { + Animation_Change(&pthis->skelAnime, &object_ik_Anim_00ED24, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_00ED24), ANIMMODE_LOOP, -4.0f); + pthis->actor.speedXZ = 0.9f; + } else { + Animation_Change(&pthis->skelAnime, &object_ik_Anim_006734, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_006734), ANIMMODE_LOOP, -4.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_DASH); + pthis->actor.speedXZ = 2.5f; + } + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnIk_SetupAction(pthis, func_80A74BA4); +} + +void func_80A74BA4(EnIk* pthis, GlobalContext* globalCtx) { + s16 temp_t0; + s16 temp_a1; + s16 yawDiff; + s16 sp30; + s16 sp2E; + s16 phi_a3; + + if (pthis->unk_2FB == 0) { + temp_t0 = 0xAAA; + phi_a3 = 0x320; + sp30 = 0; + sp2E = 0x10; + } else { + temp_t0 = 0x3FFC; + phi_a3 = 0x4B0; + sp30 = 2; + sp2E = 9; + } + temp_a1 = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + if ((pthis->actor.bgCheckFlags & 8) && (ABS(temp_a1) >= 0x4000)) { + temp_a1 = (pthis->actor.yawTowardsPlayer > 0) ? pthis->actor.wallYaw - 0x4000 : pthis->actor.wallYaw + 0x4000; + Math_SmoothStepToS(&pthis->actor.world.rot.y, temp_a1, 1, phi_a3, 0); + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, phi_a3, 0); + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((ABS(yawDiff) <= temp_t0) && (pthis->actor.xzDistToPlayer < 100.0f)) { + if (ABS(pthis->actor.yDistToPlayer) < 150.0f) { + if ((globalCtx->gameplayFrames & 1)) { + func_80A74E2C(pthis); + } else { + func_80A751C8(pthis); + } + } + } + if (func_80A74674(globalCtx, &pthis->actor) != NULL) { + func_80A751C8(pthis); + pthis->unk_2FC = 1; + } else { + temp_t0 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (ABS(temp_t0) > 0x4000) { + pthis->unk_300--; + if (pthis->unk_300 == 0) { + func_80A754A0(pthis); + } + } else { + pthis->unk_300 = 0x28; + } + } + func_80A745E4(pthis, globalCtx); + SkelAnime_Update(&pthis->skelAnime); + if ((sp30 == (s16)pthis->skelAnime.curFrame) || (sp2E == (s16)pthis->skelAnime.curFrame)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_WALK); + } +} + +void func_80A74E2C(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_001C28); + + pthis->unk_2FF = 1; + pthis->unk_2F8 = 6; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_001C28, 1.5f, 0.0f, frames, ANIMMODE_ONCE, -4.0f); + EnIk_SetupAction(pthis, func_80A74EBC); +} + +void func_80A74EBC(EnIk* pthis, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (pthis->skelAnime.curFrame == 15.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } else if (pthis->skelAnime.curFrame == 21.0f) { + sp2C.x = pthis->actor.world.pos.x + Math_SinS(pthis->actor.shape.rot.y + 0x6A4) * 70.0f; + sp2C.z = pthis->actor.world.pos.z + Math_CosS(pthis->actor.shape.rot.y + 0x6A4) * 70.0f; + sp2C.y = pthis->actor.world.pos.y; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_HIT_GND); + Camera_AddQuake(&globalCtx->mainCamera, 2, 0x19, 5); + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + CollisionCheck_SpawnShieldParticles(globalCtx, &sp2C); + } + + if ((pthis->skelAnime.curFrame > 17.0f) && (pthis->skelAnime.curFrame < 23.0f)) { + pthis->unk_2FE = 1; + } else { + if ((pthis->unk_2FB != 0) && (pthis->skelAnime.curFrame < 10.0f)) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x5DC, 0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + pthis->unk_2FE = 0; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + func_80A7506C(pthis); + } +} + +void func_80A7506C(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0029FC); + + pthis->unk_2FE = 0; + pthis->unk_2F9 = (s8)frames; + pthis->unk_2F8 = 7; + pthis->unk_2FF = pthis->unk_2FE; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_0029FC, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -4.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_PULLOUT); + EnIk_SetupAction(pthis, func_80A7510C); +} + +void func_80A7510C(EnIk* pthis, GlobalContext* globalCtx) { + f32 frames; + + if (SkelAnime_Update(&pthis->skelAnime) || (--pthis->unk_2F9 == 0)) { + if (pthis->unk_2F8 == 8) { + func_80A7489C(pthis); + } else { + frames = Animation_GetLastFrame(&object_ik_Anim_002538); + pthis->unk_2F8 = 8; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_002538, 1.5f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + } + } +} + +void func_80A751C8(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0033C4); + + pthis->unk_2FF = 2; + pthis->unk_300 = 0; + pthis->unk_2F8 = 6; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_0033C4, 0.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -6.0f); + pthis->unk_2FC = 0; + EnIk_SetupAction(pthis, func_80A75260); +} + +void func_80A75260(EnIk* pthis, GlobalContext* globalCtx) { + f32 temp_f0; + + pthis->unk_300 += 0x1C2; + temp_f0 = Math_SinS(pthis->unk_300); + pthis->skelAnime.playSpeed = ABS(temp_f0); + + if (pthis->skelAnime.curFrame > 11.0f) { + pthis->unk_2FF = 3; + } + if (((pthis->skelAnime.curFrame > 1.0f) && (pthis->skelAnime.curFrame < 9.0f)) || + ((pthis->skelAnime.curFrame > 13.0f) && (pthis->skelAnime.curFrame < 18.0f))) { + if ((pthis->unk_2FC == 0) && (pthis->unk_2FB != 0) && (pthis->skelAnime.curFrame < 10.0f)) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x5DC, 0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + if (pthis->unk_2FE < 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } + pthis->unk_2FE = 1; + } else { + pthis->unk_2FE = 0; + } + if (SkelAnime_Update(&pthis->skelAnime)) { + func_80A753D0(pthis); + } +} + +void func_80A753D0(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_003DBC); + + pthis->unk_2FF = pthis->unk_2FE = 0; + pthis->unk_2F8 = 8; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_003DBC, 1.5f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + EnIk_SetupAction(pthis, func_80A7545C); +} + +void func_80A7545C(EnIk* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + func_80A7489C(pthis); + func_80A745E4(pthis, globalCtx); + } +} + +void func_80A754A0(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0033C4); + + pthis->unk_2F8 = 1; + pthis->unk_2FF = 3; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_0033C4, 0.5f, 13.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + EnIk_SetupAction(pthis, func_80A75530); +} + +void func_80A75530(EnIk* pthis, GlobalContext* globalCtx) { + Math_StepUntilS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0x7D0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if ((pthis->skelAnime.curFrame > 13.0f) && (pthis->skelAnime.curFrame < 18.0f)) { + if (pthis->unk_2FE < 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } + pthis->unk_2FE = 1; + } else { + pthis->unk_2FE = 0; + } + if (SkelAnime_Update(&pthis->skelAnime)) { + func_80A753D0(pthis); + func_80A745E4(pthis, globalCtx); + } +} + +void func_80A755F0(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_00485C); + + pthis->unk_2FE = 0; + pthis->unk_2F8 = 9; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_00485C, 1.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + EnIk_SetupAction(pthis, func_80A7567C); +} + +void func_80A7567C(EnIk* pthis, GlobalContext* globalCtx) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->shieldCollider.base); + if (SkelAnime_Update(&pthis->skelAnime)) { + if ((ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4000) && + (pthis->actor.xzDistToPlayer < 100.0f) && (ABS(pthis->actor.yDistToPlayer) < 150.0f)) { + if ((globalCtx->gameplayFrames & 1)) { + func_80A74E2C(pthis); + } else { + func_80A751C8(pthis); + } + } else { + func_80A7489C(pthis); + } + } +} + +void func_80A75790(EnIk* pthis) { + s16 yaw; + s16 yawDiff; + + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->bodyCollider.base.ac->world.pos); + pthis->unk_2F8 = 0; + yawDiff = yaw - pthis->actor.shape.rot.y; + if (ABS(yawDiff) <= 0x4000) { + Animation_Change(&pthis->skelAnime, &object_ik_Anim_006194, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_006194), ANIMMODE_ONCE, -4.0f); + pthis->actor.speedXZ = -6.0f; + } else { + Animation_Change(&pthis->skelAnime, &object_ik_Anim_0045BC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_0045BC), ANIMMODE_ONCE, -4.0f); + pthis->actor.speedXZ = 6.0f; + } + pthis->unk_2FE = 0; + EnIk_SetupAction(pthis, func_80A758B0); +} + +void func_80A758B0(EnIk* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + if (BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, pthis->actor.params + 4)) { + pthis->bodyBreak.val = BODYBREAK_STATUS_FINISHED; + } + if (SkelAnime_Update(&pthis->skelAnime)) { + if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4000) { + func_80A7489C(pthis); + func_80A745E4(pthis, globalCtx); + } else { + func_80A754A0(pthis); + } + } +} + +void func_80A7598C(EnIk* pthis) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_005944); + + pthis->unk_2FE = 0; + pthis->unk_2F8 = 2; + pthis->actor.speedXZ = 0.0f; + Animation_Change(&pthis->skelAnime, &object_ik_Anim_005944, 1.0f, 0.0f, frames, ANIMMODE_ONCE, -4.0f); + pthis->unk_2F9 = 0x18; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_DEAD); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_CUTBODY); + EnIk_SetupAction(pthis, func_80A75A38); +} + +void func_80A75A38(EnIk* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if ((pthis->actor.colChkInfo.health == 0) && (pthis->unk_2F9 != 0)) { + s32 i; + Vec3f pos; + Vec3f sp7C = { 0.0f, 0.5f, 0.0f }; + + pthis->unk_2F9--; + + for (i = 0xC - (pthis->unk_2F9 >> 1); i >= 0; i--) { + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(120.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(120.0f); + pos.y = pthis->actor.world.pos.y + 20.0f + Rand_CenteredFloat(50.0f); + EffectSsDeadDb_Spawn(globalCtx, &pos, &sp7C, &sp7C, 100, 0, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); + } + if (pthis->unk_2F9 == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xB0); + if (pthis->switchFlags != 0xFF) { + Flags_SetSwitch(globalCtx, pthis->switchFlags); + } + Actor_Kill(&pthis->actor); + } + } + } else if (pthis->skelAnime.curFrame == 23.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_WALK); + } +} + +void func_80A75C38(EnIk* pthis, GlobalContext* globalCtx) { + f32 temp_f0; + u8 pad; + u8 pad2; + u8 prevHealth; + s32 temp_v0_3; + Vec3f sp38; + + if ((pthis->unk_2F8 == 3) || (pthis->unk_2F8 == 2)) { + return; + } + if (pthis->shieldCollider.base.acFlags & AC_BOUNCED) { + temp_f0 = Animation_GetLastFrame(&object_ik_Anim_00485C) - 2.0f; + if (pthis->skelAnime.curFrame < temp_f0) { + pthis->skelAnime.curFrame = temp_f0; + } + pthis->shieldCollider.base.acFlags &= ~AC_BOUNCED; + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + return; + } + if (!(pthis->bodyCollider.base.acFlags & AC_HIT)) { + return; + } + sp38 = pthis->actor.world.pos; + sp38.y += 50.0f; + Actor_SetDropFlag(&pthis->actor, &pthis->bodyCollider.info, 1); + temp_v0_3 = pthis->actor.colChkInfo.damageEffect; + pthis->unk_2FD = temp_v0_3 & 0xFF; + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + + if (1) {} + + if ((pthis->unk_2FD == 0) || (pthis->unk_2FD == 0xD) || ((pthis->unk_2FB == 0) && (pthis->unk_2FD == 0xE))) { + if (pthis->unk_2FD != 0) { + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp38); + } + return; + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0xC); + prevHealth = pthis->actor.colChkInfo.health; + Actor_ApplyDamage(&pthis->actor); + if (pthis->actor.params != 0) { + if ((prevHealth > 10) && (pthis->actor.colChkInfo.health <= 10)) { + pthis->unk_2FB = 1; + BodyBreak_Alloc(&pthis->bodyBreak, 3, globalCtx); + } + } else if (pthis->actor.colChkInfo.health <= 10) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_BOSS); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EN_LAST_DAMAGE); + if (pthis->switchFlags != 0xFF) { + Flags_SetSwitch(globalCtx, pthis->switchFlags); + } + return; + } else if (prevHealth == 50) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + } + + if (pthis->actor.colChkInfo.health == 0) { + func_80A7598C(pthis); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + return; + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x7D0, 0); + if ((pthis->actor.params == 0) && (Rand_ZeroOne() < 0.5f)) { + if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) > 0x4000) { + func_80A754A0(pthis); + } + } + if ((pthis->actor.params != 0) && (pthis->unk_2FB != 0)) { + if ((prevHealth > 10) && (pthis->actor.colChkInfo.health <= 10)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_DAMAGE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_CUTBODY); + } + func_80A75790(pthis); + return; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_IRONNACK_DAMAGE); + CollisionCheck_SpawnShieldParticles(globalCtx, &sp38); +} + +void func_80A75FA0(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + u8 prevInvincibilityTimer; + + pthis->unk_2FA = pthis->unk_2FB; + func_80A75C38(pthis, globalCtx); + if ((pthis->actor.params == 0) && (pthis->actor.colChkInfo.health <= 10)) { + func_80A781CC(&pthis->actor, globalCtx); + return; + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->axeCollider.base.atFlags & AT_HIT) { + pthis->axeCollider.base.atFlags &= ~AT_HIT; + if (&player->actor == pthis->axeCollider.base.at) { + prevInvincibilityTimer = player->invincibilityTimer; + if (player->invincibilityTimer <= 0) { + if (player->invincibilityTimer < -39) { + player->invincibilityTimer = 0; + } else { + player->invincibilityTimer = 0; + globalCtx->damagePlayer(globalCtx, -64); + pthis->unk_2FE = 0; + } + } + func_8002F71C(globalCtx, &pthis->actor, 8.0f, pthis->actor.yawTowardsPlayer, 8.0f); + player->invincibilityTimer = prevInvincibilityTimer; + } + } + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 0x1D); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 45.0f; + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + if ((pthis->actor.colChkInfo.health > 0) && (pthis->actor.colorFilterTimer == 0) && (pthis->unk_2F8 >= 2)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + if (pthis->unk_2FE > 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->axeCollider.base); + } + if (pthis->unk_2F8 == 9) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->shieldCollider.base); + } +} + +Gfx* func_80A761B0(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { + Gfx* displayList; + Gfx* displayListHead; + + displayList = (Gfx*)Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); + displayListHead = displayList; + + gDPPipeSync(displayListHead++); + gDPSetPrimColor(displayListHead++, 0, 0, primR, primG, primB, 255); + gDPSetEnvColor(displayListHead++, envR, envG, envB, 255); + gSPEndDisplayList(displayListHead++); + + return displayList; +} + +s32 EnIk_OverrideLimbDraw3(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnIk* pthis = (EnIk*)thisx; + + if (limbIndex == 12) { + if (pthis->actor.params != 0) { + *dList = object_ik_DL_018E78; + } + } else if (limbIndex == 13) { + if (pthis->actor.params != 0) { + *dList = object_ik_DL_019100; + } + } else if ((limbIndex == 26) || (limbIndex == 27)) { + if ((pthis->unk_2FA & 1)) { + *dList = NULL; + } + } else if ((limbIndex == 28) || (limbIndex == 29)) { + if (!(pthis->unk_2FA & 1)) { + *dList = NULL; + } + } + return false; +} + +// unused +static Vec3f D_80A78470 = { 300.0f, 0.0f, 0.0f }; + +static Vec3f D_80A7847C[] = { + { 800.0f, -200.0f, -5200.0f }, + { 0.0f, 0.0f, 0.0f }, + { -200.0f, -2200.0f, -200.0f }, + { -6000.0f, 2000.0f, -3000.0f }, +}; + +static Vec3f D_80A784AC[] = { + { -3000.0, -700.0, -5000.0 }, + { -3000.0, -700.0, 2000.0 }, + { 4000.0, -700.0, 2000.0 }, +}; + +static Vec3f D_80A784D0[] = { + { 4000.0, -700.0, 2000.0 }, + { 4000.0, -700.0, -5000.0 }, + { -3000.0, -700.0, -5000.0 }, +}; + +void EnIk_PostLimbDraw3(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + Vec3f spF4; + Vec3f spE8; + EnIk* pthis = (EnIk*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1201); + + if (pthis->unk_2FB & 1) { + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 26, 27, 28, dList, BODYBREAK_OBJECT_DEFAULT); + } + if (limbIndex == 12) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1217), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (pthis->actor.params != 0) { + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_019E08); + } else { + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); + } + } else if (limbIndex == 17) { + s32 i; + Vec3f sp9C[3]; + Vec3f sp78[3]; + + Matrix_MultVec3f(&D_80A7847C[0], &pthis->axeCollider.dim.quad[1]); + Matrix_MultVec3f(&D_80A7847C[1], &pthis->axeCollider.dim.quad[0]); + Matrix_MultVec3f(&D_80A7847C[2], &pthis->axeCollider.dim.quad[3]); + Matrix_MultVec3f(&D_80A7847C[3], &pthis->axeCollider.dim.quad[2]); + Collider_SetQuadVertices(&pthis->axeCollider, &pthis->axeCollider.dim.quad[0], &pthis->axeCollider.dim.quad[1], + &pthis->axeCollider.dim.quad[2], &pthis->axeCollider.dim.quad[3]); + Matrix_MultVec3f(&D_80A7847C[0], &spF4); + Matrix_MultVec3f(&D_80A7847C[1], &spE8); + if (pthis->unk_2FE > 0) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIdx), &spF4, &spE8); + } else if (pthis->unk_2FE == 0) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIdx)); + pthis->unk_2FE = -1; + } + if (pthis->unk_2F8 == 9) { + for (i = 0; i < ARRAY_COUNT(sp78); i++) { + Matrix_MultVec3f(&D_80A784AC[i], &sp9C[i]); + Matrix_MultVec3f(&D_80A784D0[i], &sp78[i]); + } + + Collider_SetTrisVertices(&pthis->shieldCollider, 0, &sp9C[0], &sp9C[1], &sp9C[2]); + Collider_SetTrisVertices(&pthis->shieldCollider, 1, &sp78[0], &sp78[1], &sp78[2]); + } + } + + switch (limbIndex) { + case 22: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1270), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); + break; + case 24: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1275), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); + break; + case 26: + if (!(pthis->unk_2FA & 1)) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1281), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); + } + break; + case 27: + if (!(pthis->unk_2FA & 1)) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1288), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); + } + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1294); +} + +void func_80A76798(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1309); + + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + + if (pthis->actor.params == 0) { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 245, 225, 155, 30, 30, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 255, 40, 0, 40, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 255, 255, 255, 20, 40, 30)); + } else if (pthis->actor.params == 1) { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 245, 255, 205, 30, 35, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 185, 135, 25, 20, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 255, 255, 255, 30, 40, 20)); + } else if (pthis->actor.params == 2) { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 55, 65, 55, 0, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 205, 165, 75, 25, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 205, 165, 75, 25, 20, 0)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(globalCtx->state.gfxCtx, 255, 255, 255, 180, 180, 180)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(globalCtx->state.gfxCtx, 225, 205, 115, 25, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(globalCtx->state.gfxCtx, 225, 205, 115, 25, 20, 0)); + } + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnIk_OverrideLimbDraw3, EnIk_PostLimbDraw3, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1351); +} + +void EnIk_StartMusic(void) { + func_800F5ACC(NA_BGM_MINI_BOSS); +} + +void func_80A76C14(EnIk* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 1.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_WAKEUP, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (Animation_OnFrame(&pthis->skelAnime, 33.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_WALK, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (Animation_OnFrame(&pthis->skelAnime, 68.0f) || Animation_OnFrame(&pthis->skelAnime, 80.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (Animation_OnFrame(&pthis->skelAnime, 107.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_FINGER_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (Animation_OnFrame(&pthis->skelAnime, 156.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_ARMOR_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else if (Animation_OnFrame(&pthis->skelAnime, 188.0f)) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_WAVE_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void func_80A76DDC(EnIk* pthis, GlobalContext* globalCtx, Vec3f* pos) { + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_TRANSFORM, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); +} + +void func_80A76E2C(EnIk* pthis, GlobalContext* globalCtx, Vec3f* pos) { + static Vec3f D_80A78514[] = { + { 1000.0, -1000.0, 1000.0 }, { 0.0, -1000.0, 0.0 }, { -1000.0, -5000.0, -4000.0 }, + { 1000.0, -5000.0, -3000.0 }, { -1000.0, 1000.0, -6000.0 }, { -1000.0, 3000.0, -5000.0 }, + { -800.0, 1000.0, -3000.0 }, { 0.0, -4000.0, -2000.0 }, { -1000.0, -2000.0, -6000.0 }, + { 1000.0, -3000.0, 0.0 }, { 2000.0, -2000.0, -4000.0 }, { -1000.0, 0.0, -6000.0 }, + { 1000.0, -2000.0, -2000.0 }, { 0.0, -2000.0, 2100.0 }, { 0.0, 0.0, 0.0 }, + { 1000.0, -1000.0, -6000.0 }, { 2000.0, 0.0, -3000.0 }, { -1000.0, -1000.0, -4000.0 }, + { 900.0, -800.0, 2700.0 }, { 720.0f, 900.0f, 2500.0f }, + }; + + if (pthis->unk_4D4 == 0) { + s32 pad; + Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; + Vec3f effectAccel = { 0.0f, 0.3f, 0.0f }; + s32 i; + + for (i = ARRAY_COUNT(D_80A78514) - 1; i >= 0; i--) { + Color_RGBA8 primColor = { 200, 200, 200, 255 }; + Color_RGBA8 envColor = { 150, 150, 150, 0 }; + s32 temp_v0; + Vec3f effectPos; + + Matrix_MultVec3f(&D_80A78514[i], &effectPos); + temp_v0 = (Rand_ZeroOne() * 20.0f) - 10.0f; + primColor.r += temp_v0; + primColor.g += temp_v0; + primColor.b += temp_v0; + envColor.r += temp_v0; + envColor.g += temp_v0; + envColor.b += temp_v0; + func_8002829C(globalCtx, &effectPos, &effectVelocity, &effectAccel, &primColor, &envColor, + (Rand_ZeroOne() * 60.0f) + 300.0f, 0); + } + + pthis->unk_4D4 = 1; + func_80A76DDC(pthis, globalCtx, pos); + } +} + +void func_80A77034(EnIk* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +s32 func_80A7707C(EnIk* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +CsCmdActorAction* EnIk_GetNpcAction(GlobalContext* globalCtx, s32 actionIdx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[actionIdx]; + } else { + return NULL; + } +} + +void func_80A770C0(EnIk* pthis, GlobalContext* globalCtx, s32 actionIdx) { + CsCmdActorAction* npcAction = EnIk_GetNpcAction(globalCtx, actionIdx); + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +f32 EnIk_curFrame(Actor* thisx) { + EnIk* pthis = (EnIk*)thisx; + + return pthis->skelAnime.curFrame; +} + +void func_80A77148(EnIk* pthis) { + pthis->action = 0; + pthis->drawMode = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80A77158(EnIk* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &object_ik_Anim_00C114, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_00C114), ANIMMODE_ONCE, 0.0f); + func_80A770C0(pthis, globalCtx, 4); + pthis->action = 1; + pthis->drawMode = 1; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80A771E4(EnIk* pthis) { + Animation_Change(&pthis->skelAnime, &object_ik_Anim_00C114, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_00C114), ANIMMODE_ONCE, 0.0f); + pthis->action = 2; + pthis->drawMode = 1; + pthis->unk_4D4 = 0; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80A77264(EnIk* pthis, GlobalContext* globalCtx, s32 arg2) { + if ((arg2 != 0) && (EnIk_GetNpcAction(globalCtx, 4) != NULL)) { + func_80A78160(pthis, globalCtx); + } +} + +void func_80A772A4(EnIk* pthis) { + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_STAGGER_DEMO, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); +} + +void func_80A772EC(EnIk* pthis, GlobalContext* globalCtx) { + static Vec3f D_80A78FA0; + s32 pad[2]; + f32 wDest; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->actor.world.pos, &D_80A78FA0, &wDest); + Audio_PlaySoundGeneral(NA_SE_EN_IRONNACK_DEAD, &D_80A78FA0, 4, &D_801333E0, &D_801333E0, &D_801333E8); +} + +void func_80A7735C(EnIk* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0203D8); + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ik_Skel_0205C0, NULL, pthis->jointTable, pthis->morphTable, + 30); + Animation_Change(&pthis->skelAnime, &object_ik_Anim_0203D8, 1.0f, 0.0f, frames, ANIMMODE_ONCE, 0.0f); + pthis->action = 3; + pthis->drawMode = 2; + func_80A770C0(pthis, globalCtx, 4); + func_80A772EC(pthis, globalCtx); + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80A77434(EnIk* pthis, GlobalContext* globalCtx) { + pthis->action = 4; + pthis->drawMode = 2; + func_80A772A4(pthis); + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80A77474(EnIk* pthis, GlobalContext* globalCtx) { + pthis->action = 5; + pthis->drawMode = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80A7748C(EnIk* pthis, GlobalContext* globalCtx) { + func_80A77034(pthis, globalCtx); + func_80A779DC(pthis, globalCtx); +} + +void func_80A774BC(EnIk* pthis, GlobalContext* globalCtx) { + func_80A7707C(pthis); + func_80A77034(pthis, globalCtx); + func_80A779DC(pthis, globalCtx); +} + +void func_80A774F8(EnIk* pthis, GlobalContext* globalCtx) { + if (EnIk_GetNpcAction(globalCtx, 4) == NULL) { + Actor_Kill(&pthis->actor); + } +} + +s32 EnIk_OverrideLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnIk* pthis = (EnIk*)thisx; + + if ((limbIndex == 13) || (limbIndex == 26) || (limbIndex == 27)) { + if (EnIk_curFrame(&pthis->actor) >= 30.0f) { + *dList = NULL; + } + } + + return 0; +} + +void EnIk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 207); + + switch (limbIndex) { + case 13: { + EnIk* pthis = (EnIk*)thisx; + + if (EnIk_curFrame(&pthis->actor) < 30.0f) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 267), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); + } + } break; + case 22: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 274), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); + break; + case 24: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 280), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); + break; + case 26: { + EnIk* pthis = (EnIk*)thisx; + + if (EnIk_curFrame(&pthis->actor) < 30.0f) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 288), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); + } + } break; + case 27: { + EnIk* pthis = (EnIk*)thisx; + + if (EnIk_curFrame(&pthis->actor) < 30.0f) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inAwake.c", 297), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); + } + } break; + } + CLOSE_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 304); +} + +void func_80A77844(EnIk* pthis, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + SkelAnime* skelAnime = &pthis->skelAnime; + s32 pad[2]; + + OPEN_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 322); + + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_80093D18(gfxCtx); + func_80093D84(gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(gfxCtx, 245, 225, 155, 30, 30, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(gfxCtx, 255, 40, 0, 40, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(gfxCtx, 255, 255, 255, 20, 40, 30)); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnIk_OverrideLimbDraw2, EnIk_PostLimbDraw2, pthis); + + CLOSE_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 345); +} + +void func_80A779DC(EnIk* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnIk_GetNpcAction(globalCtx, 4); + u32 action; + u32 currentNpcAction; + + if (npcAction != NULL) { + action = npcAction->action; + currentNpcAction = pthis->npcAction; + if (action != currentNpcAction) { + switch (action) { + case 1: + func_80A77148(pthis); + break; + case 2: + func_80A77158(pthis, globalCtx); + break; + case 3: + func_80A771E4(pthis); + break; + case 4: + func_80A78160(pthis, globalCtx); + break; + case 5: + func_80A7735C(pthis, globalCtx); + break; + case 6: + func_80A77434(pthis, globalCtx); + break; + case 7: + func_80A77474(pthis, globalCtx); + break; + default: + osSyncPrintf("En_Ik_inConfrontion_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + + pthis->npcAction = action; + } + } +} + +void func_80A77AEC(EnIk* pthis, GlobalContext* globalCtx) { + func_80A779DC(pthis, globalCtx); +} + +void func_80A77B0C(EnIk* pthis, GlobalContext* globalCtx) { + func_80A77034(pthis, globalCtx); + func_80A779DC(pthis, globalCtx); +} + +void func_80A77B3C(EnIk* pthis, GlobalContext* globalCtx) { + s32 sp24; + + sp24 = func_80A7707C(pthis); + func_80A76C14(pthis); + func_80A77034(pthis, globalCtx); + func_80A779DC(pthis, globalCtx); + func_80A77264(pthis, globalCtx, sp24); +} + +static EnIkActionFunc sActionFuncs[] = { + func_80A77AEC, func_80A77B0C, func_80A77B3C, func_80A7748C, func_80A774BC, func_80A774F8, +}; + +void EnIk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + + if (pthis->action < 0 || pthis->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[pthis->action] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sActionFuncs[pthis->action](pthis, globalCtx); +} + +s32 EnIk_OverrideLimbDraw1(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnIk* pthis = (EnIk*)thisx; + f32 curFrame; + + switch (limbIndex) { + case 17: + curFrame = pthis->skelAnime.curFrame; + if (curFrame < 120.0f) { + *dList = NULL; + } else { + func_80A76E2C(pthis, globalCtx, pos); + } + break; + case 29: + case 30: + *dList = NULL; + break; + } + + return 0; +} + +void EnIk_PostLimbDraw1(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 571); + + switch (limbIndex) { + case 12: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 575), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); + break; + case 22: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 581), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); + break; + case 24: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 587), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); + break; + case 26: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 593), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); + break; + case 27: + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_ik_inConfrontion.c", 599), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); + break; + } + + CLOSE_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 604); +} + +void func_80A77ED0(EnIk* pthis, GlobalContext* globalCtx) { +} + +void func_80A77EDC(EnIk* pthis, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + SkelAnime* skelAnime = &pthis->skelAnime; + s32 pad[2]; + + OPEN_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 630); + + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_80093D18(gfxCtx); + func_80093D84(gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(gfxCtx, 245, 225, 155, 30, 30, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(gfxCtx, 255, 40, 0, 40, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(gfxCtx, 255, 255, 255, 20, 40, 30)); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnIk_OverrideLimbDraw1, EnIk_PostLimbDraw1, pthis); + + CLOSE_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 653); +} + +static EnIkDrawFunc sDrawFuncs[] = { func_80A77ED0, func_80A77EDC, func_80A77844 }; + +void EnIk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + + if (pthis->drawMode < 0 || pthis->drawMode >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[pthis->drawMode] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sDrawFuncs[pthis->drawMode](pthis, globalCtx); +} + +void func_80A780D0(EnIk* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == 0) { + if (!(gSaveContext.eventChkInf[3] & 0x800)) { + pthis->actor.update = EnIk_Update; + pthis->actor.draw = EnIk_Draw; + Actor_SetScale(&pthis->actor, 0.01f); + } else { + func_80A78160(pthis, globalCtx); + EnIk_StartMusic(); + } + } + osSyncPrintf("En_Ik_inConfrontion_Init : %d !!!!!!!!!!!!!!!!\n", pthis->actor.params); +} + +void func_80A78160(EnIk* pthis, GlobalContext* globalCtx) { + pthis->actor.update = func_80A75FA0; + pthis->actor.draw = func_80A76798; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; + gSaveContext.eventChkInf[3] |= 0x800; + Actor_SetScale(&pthis->actor, 0.012f); + func_80A7489C(pthis); +} + +void func_80A781CC(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + + if (!Gameplay_InCsMode(globalCtx)) { + pthis->actor.update = EnIk_Update; + pthis->actor.draw = EnIk_Draw; + Cutscene_SetSegment(globalCtx, gSpiritBossNabooruKnuckleDefeatCs); + gSaveContext.cutsceneTrigger = 1; + Actor_SetScale(&pthis->actor, 0.01f); + gSaveContext.eventChkInf[3] |= 0x1000; + func_80A7735C(pthis, globalCtx); + } +} + +void EnIk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnIk* pthis = (EnIk*)thisx; + s32 flag = pthis->actor.params & 0xFF00; + + if (((pthis->actor.params & 0xFF) == 0 && (gSaveContext.eventChkInf[3] & 0x1000)) || + (flag != 0 && Flags_GetSwitch(globalCtx, flag >> 8))) { + Actor_Kill(&pthis->actor); + } else { + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ik_Skel_01E178, &object_ik_Anim_00C114, + pthis->jointTable, pthis->morphTable, 30); + func_80A74398(&pthis->actor, globalCtx); + func_80A780D0(pthis, globalCtx); + } +} + +ActorInit En_Ik_InitVars = { + ACTOR_EN_IK, + ACTORCAT_BOSS, + FLAGS, + OBJECT_IK, + sizeof(EnIk), + (ActorFunc)EnIk_Init, + (ActorFunc)EnIk_Destroy, + (ActorFunc)EnIk_Update, + (ActorFunc)EnIk_Draw, +}; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.cpp similarity index 55% rename from src/overlays/actors/ovl_En_In/z_en_in.c rename to src/overlays/actors/ovl_En_In/z_en_in.cpp index 2d333f46e..dddbc997d 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.cpp @@ -28,22 +28,22 @@ void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A79FB0(EnIn* this, GlobalContext* globalCtx); -void func_80A7A304(EnIn* this, GlobalContext* globalCtx); -void func_80A7A4C8(EnIn* this, GlobalContext* globalCtx); -void func_80A7A568(EnIn* this, GlobalContext* globalCtx); -void func_80A7A848(EnIn* this, GlobalContext* globalCtx); -void func_80A7ABD4(EnIn* this, GlobalContext* globalCtx); -void func_80A7AEF0(EnIn* this, GlobalContext* globalCtx); -void func_80A7B018(EnIn* this, GlobalContext* globalCtx); -void func_80A7B024(EnIn* this, GlobalContext* globalCtx); -void func_80A7AE84(EnIn* this, GlobalContext* globalCtx); -void func_80A7A770(EnIn* this, GlobalContext* globalCtx); -void func_80A7A940(EnIn* this, GlobalContext* globalCtx); -void func_80A7AA40(EnIn* this, GlobalContext* globalCtx); -void func_80A7A4BC(EnIn* this, GlobalContext* globalCtx); +void func_80A79FB0(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A304(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A4C8(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A568(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A848(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7ABD4(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7AEF0(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7B018(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7B024(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7AE84(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A770(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A940(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7AA40(EnIn* pthis, GlobalContext* globalCtx); +void func_80A7A4BC(EnIn* pthis, GlobalContext* globalCtx); -const ActorInit En_In_InitVars = { +ActorInit En_In_InitVars = { ACTOR_EN_IN, ACTORCAT_NPC, FLAGS, @@ -215,46 +215,46 @@ s16 func_80A791CC(GlobalContext* globalCtx, Actor* thisx) { } s16 func_80A7924C(GlobalContext* globalCtx, Actor* thisx) { - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; s32 sp18 = 1; - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x2030: case 0x2031: if (globalCtx->msgCtx.choiceIndex == 1) { - this->actor.textId = 0x2032; + pthis->actor.textId = 0x2032; } else if (gSaveContext.rupees < 10) { - this->actor.textId = 0x2033; + pthis->actor.textId = 0x2033; } else { - this->actor.textId = 0x2034; + pthis->actor.textId = 0x2034; } - Message_ContinueTextbox(globalCtx, this->actor.textId); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); gSaveContext.infTable[9] |= 0x400; break; case 0x2034: if (globalCtx->msgCtx.choiceIndex == 1) { Rupees_ChangeBy(-10); - this->actor.textId = 0x205C; + pthis->actor.textId = 0x205C; } else { - this->actor.textId = 0x2035; + pthis->actor.textId = 0x2035; } - Message_ContinueTextbox(globalCtx, this->actor.textId); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); break; case 0x2036: case 0x2037: if (globalCtx->msgCtx.choiceIndex == 1) { sp18 = 2; } else { - this->actor.textId = 0x201F; - Message_ContinueTextbox(globalCtx, this->actor.textId); + pthis->actor.textId = 0x201F; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); } break; case 0x2038: if (globalCtx->msgCtx.choiceIndex == 0 && gSaveContext.rupees >= 50) { sp18 = 2; } else { - this->actor.textId = 0x2039; - Message_ContinueTextbox(globalCtx, this->actor.textId); + pthis->actor.textId = 0x2039; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); gSaveContext.infTable[10] |= 4; } break; @@ -262,11 +262,11 @@ s16 func_80A7924C(GlobalContext* globalCtx, Actor* thisx) { if (globalCtx->msgCtx.choiceIndex == 0 && gSaveContext.rupees >= 50) { sp18 = 2; } else { - Message_ContinueTextbox(globalCtx, this->actor.textId = 0x2039); + Message_ContinueTextbox(globalCtx, pthis->actor.textId = 0x2039); gSaveContext.eventInf[0] &= ~0xF; gSaveContext.eventInf[0] &= ~0x20; gSaveContext.eventInf[0] &= ~0x40; - this->actionFunc = func_80A7A4C8; + pthis->actionFunc = func_80A7A4C8; } break; } @@ -320,116 +320,116 @@ s16 func_80A79500(GlobalContext* globalCtx, Actor* thisx) { return sp1E; } -void func_80A795C8(EnIn* this, GlobalContext* globalCtx) { +void func_80A795C8(EnIn* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 phi_a3; - if (this->skelAnime.animation == &object_in_Anim_0003B4 || this->skelAnime.animation == &object_in_Anim_001BE0 || - this->skelAnime.animation == &object_in_Anim_013D60) { + if (pthis->skelAnime.animation == &object_in_Anim_0003B4 || pthis->skelAnime.animation == &object_in_Anim_001BE0 || + pthis->skelAnime.animation == &object_in_Anim_013D60) { phi_a3 = 1; } else { phi_a3 = 0; } - if (this->actionFunc == func_80A7A568) { + if (pthis->actionFunc == func_80A7A568) { phi_a3 = 4; } - if (this->actionFunc == func_80A7B024) { - this->unk_308.unk_18 = globalCtx->view.eye; - this->unk_308.unk_14 = 60.0f; + if (pthis->actionFunc == func_80A7B024) { + pthis->unk_308.unk_18 = globalCtx->view.eye; + pthis->unk_308.unk_14 = 60.0f; } else { - this->unk_308.unk_18 = player->actor.world.pos; - this->unk_308.unk_14 = 16.0f; + pthis->unk_308.unk_18 = player->actor.world.pos; + pthis->unk_308.unk_14 = 16.0f; } - func_80034A14(&this->actor, &this->unk_308, 1, phi_a3); + func_80034A14(&pthis->actor, &pthis->unk_308, 1, phi_a3); } -void func_80A79690(SkelAnime* skelAnime, EnIn* this, GlobalContext* globalCtx) { +void func_80A79690(SkelAnime* skelAnime, EnIn* pthis, GlobalContext* globalCtx) { if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { skelAnime->moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, skelAnime, 1.0f); + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, skelAnime, 1.0f); } } -void func_80A796EC(EnIn* this, s32 arg1) { - Animation_Change(&this->skelAnime, sAnimationInfo[arg1].animation, 1.0f, 0.0f, +void func_80A796EC(EnIn* pthis, s32 arg1) { + Animation_Change(&pthis->skelAnime, sAnimationInfo[arg1].animation, 1.0f, 0.0f, Animation_GetLastFrame(sAnimationInfo[arg1].animation), sAnimationInfo[arg1].mode, sAnimationInfo[arg1].transitionRate); } -s32 func_80A7975C(EnIn* this, GlobalContext* globalCtx) { - if (this->actor.params != 1 || this->actor.shape.rot.z != 1 || !LINK_IS_ADULT) { +s32 func_80A7975C(EnIn* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params != 1 || pthis->actor.shape.rot.z != 1 || !LINK_IS_ADULT) { return 0; } - this->animationIdx = 1; - this->collider.base.ocFlags1 &= ~OC1_ON; - Animation_Change(&this->skelAnime, D_80A7B918[this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(D_80A7B918[this->animationIdx]), 2, 0.0f); - this->actionFunc = func_80A7A304; + pthis->animationIdx = 1; + pthis->collider.base.ocFlags1 &= ~OC1_ON; + Animation_Change(&pthis->skelAnime, D_80A7B918[pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(D_80A7B918[pthis->animationIdx]), 2, 0.0f); + pthis->actionFunc = func_80A7A304; return 1; } -s32 func_80A79830(EnIn* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SPOT20 && LINK_IS_CHILD && IS_DAY && this->actor.shape.rot.z == 1 && +s32 func_80A79830(EnIn* pthis, GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SPOT20 && LINK_IS_CHILD && IS_DAY && pthis->actor.shape.rot.z == 1 && !(gSaveContext.eventChkInf[1] & 0x10)) { return 1; } - if (globalCtx->sceneNum == SCENE_MALON_STABLE && LINK_IS_CHILD && IS_DAY && this->actor.shape.rot.z == 3 && + if (globalCtx->sceneNum == SCENE_MALON_STABLE && LINK_IS_CHILD && IS_DAY && pthis->actor.shape.rot.z == 3 && (gSaveContext.eventChkInf[1] & 0x10)) { return 1; } if (globalCtx->sceneNum == SCENE_MALON_STABLE && LINK_IS_CHILD && IS_NIGHT) { - if ((this->actor.shape.rot.z == 2) && !(gSaveContext.eventChkInf[1] & 0x10)) { + if ((pthis->actor.shape.rot.z == 2) && !(gSaveContext.eventChkInf[1] & 0x10)) { return 1; } - if ((this->actor.shape.rot.z == 4) && (gSaveContext.eventChkInf[1] & 0x10)) { + if ((pthis->actor.shape.rot.z == 4) && (gSaveContext.eventChkInf[1] & 0x10)) { return 1; } } if (globalCtx->sceneNum == SCENE_SPOT20 && LINK_IS_ADULT && IS_DAY) { - if ((this->actor.shape.rot.z == 5) && !(gSaveContext.eventChkInf[1] & 0x100)) { + if ((pthis->actor.shape.rot.z == 5) && !(gSaveContext.eventChkInf[1] & 0x100)) { return 2; } - if ((this->actor.shape.rot.z == 7) && (gSaveContext.eventChkInf[1] & 0x100)) { + if ((pthis->actor.shape.rot.z == 7) && (gSaveContext.eventChkInf[1] & 0x100)) { return 4; } } if (globalCtx->sceneNum == SCENE_SOUKO && LINK_IS_ADULT && IS_NIGHT) { - if (this->actor.shape.rot.z == 6 && !(gSaveContext.eventChkInf[1] & 0x100)) { + if (pthis->actor.shape.rot.z == 6 && !(gSaveContext.eventChkInf[1] & 0x100)) { return 3; } - if (this->actor.shape.rot.z == 8 && (gSaveContext.eventChkInf[1] & 0x100)) { + if (pthis->actor.shape.rot.z == 8 && (gSaveContext.eventChkInf[1] & 0x100)) { return 3; } } return 0; } -void EnIn_UpdateEyes(EnIn* this) { - if (this->eyeIndex != 3) { - if (DECR(this->blinkTimer) == 0) { - this->eyeIndex++; - if (this->eyeIndex >= 3) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeIndex = 0; +void EnIn_UpdateEyes(EnIn* pthis) { + if (pthis->eyeIndex != 3) { + if (DECR(pthis->blinkTimer) == 0) { + pthis->eyeIndex++; + if (pthis->eyeIndex >= 3) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeIndex = 0; } } } } -void func_80A79AB4(EnIn* this, GlobalContext* globalCtx) { +void func_80A79AB4(EnIn* pthis, GlobalContext* globalCtx) { s32 i; u32 f = 0; - if (this->skelAnime.animation != &object_in_Anim_014CA8) { + if (pthis->skelAnime.animation != &object_in_Anim_014CA8) { f = globalCtx->gameplayFrames; } - for (i = 0; i < ARRAY_COUNT(this->unk_330); i++) { - this->unk_330[i].y = (2068 + 50 * i) * f; - this->unk_330[i].z = (2368 + 50 * i) * f; + for (i = 0; i < ARRAY_COUNT(pthis->unk_330); i++) { + pthis->unk_330[i].y = (2068 + 50 * i) * f; + pthis->unk_330[i].z = (2368 + 50 * i) * f; } } -void func_80A79BAC(EnIn* this, GlobalContext* globalCtx, s32 index, u32 arg3) { +void func_80A79BAC(EnIn* pthis, GlobalContext* globalCtx, s32 index, u32 arg3) { s16 entrances[] = { 0x0558, 0x04CA, 0x0157 }; globalCtx->nextEntranceIndex = entrances[index]; @@ -438,7 +438,7 @@ void func_80A79BAC(EnIn* this, GlobalContext* globalCtx, s32 index, u32 arg3) { } globalCtx->fadeTransition = arg3; globalCtx->sceneLoadFlag = 0x14; - func_8002DF54(globalCtx, &this->actor, 8); + func_8002DF54(globalCtx, &pthis->actor, 8); Interface_ChangeAlpha(1); if (index == 0) { AREG(6) = 0; @@ -446,36 +446,36 @@ void func_80A79BAC(EnIn* this, GlobalContext* globalCtx, s32 index, u32 arg3) { gSaveContext.timer1State = 0; } -void func_80A79C78(EnIn* this, GlobalContext* globalCtx) { +void func_80A79C78(EnIn* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f sp48; Vec3f sp3C; Vec3s zeroVec = { 0, 0, 0 }; - this->camId = Gameplay_CreateSubCamera(globalCtx); + pthis->camId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->camId, CAM_STAT_ACTIVE); - sp48.x = this->actor.world.pos.x; - sp48.y = this->actor.world.pos.y + 60.0f; - sp48.z = this->actor.world.pos.z; + Gameplay_ChangeCameraStatus(globalCtx, pthis->camId, CAM_STAT_ACTIVE); + sp48.x = pthis->actor.world.pos.x; + sp48.y = pthis->actor.world.pos.y + 60.0f; + sp48.z = pthis->actor.world.pos.z; sp3C.x = sp48.x; sp3C.y = sp48.y - 22.0f; sp3C.z = sp48.z + 40.0f; - Gameplay_CameraSetAtEye(globalCtx, this->camId, &sp48, &sp3C); - this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp3C); - this->unk_308.unk_08 = zeroVec; - this->unk_308.unk_0E = zeroVec; + Gameplay_CameraSetAtEye(globalCtx, pthis->camId, &sp48, &sp3C); + pthis->actor.shape.rot.y = Math_Vec3f_Yaw(&pthis->actor.world.pos, &sp3C); + pthis->unk_308.unk_08 = zeroVec; + pthis->unk_308.unk_0E = zeroVec; Message_StartTextbox(globalCtx, 0x2025, NULL); - this->unk_308.unk_00 = 1; - player->actor.world.pos = this->actor.world.pos; - player->actor.world.pos.x += 100.0f * Math_SinS(this->actor.shape.rot.y); - player->actor.world.pos.z += 100.0f * Math_CosS(this->actor.shape.rot.y); + pthis->unk_308.unk_00 = 1; + player->actor.world.pos = pthis->actor.world.pos; + player->actor.world.pos.x += 100.0f * Math_SinS(pthis->actor.shape.rot.y); + player->actor.world.pos.z += 100.0f * Math_CosS(pthis->actor.shape.rot.y); if (player->rideActor != NULL) { player->rideActor->world.pos = player->actor.world.pos; player->rideActor->freezeTimer = 10; } player->actor.freezeTimer = 10; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; ShrinkWindow_SetVal(0x20); Interface_ChangeAlpha(2); } @@ -483,14 +483,14 @@ void func_80A79C78(EnIn* this, GlobalContext* globalCtx) { static s32 D_80A7B998 = 0; void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; RespawnData* respawn = &gSaveContext.respawn[RESPAWN_MODE_DOWN]; Vec3f respawnPos; - this->ingoObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_IN); - if (this->ingoObjBankIndex < 0 && this->actor.params > 0) { - this->actionFunc = NULL; - Actor_Kill(&this->actor); + pthis->ingoObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_IN); + if (pthis->ingoObjBankIndex < 0 && pthis->actor.params > 0) { + pthis->actionFunc = NULL; + Actor_Kill(&pthis->actor); return; } respawnPos = respawn->pos; @@ -499,54 +499,54 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.eventInf[0] = 0; D_80A7B998 = 1; } - this->actionFunc = func_80A79FB0; + pthis->actionFunc = func_80A79FB0; } void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; - if (this->actionFunc != NULL && this->actionFunc != func_80A79FB0) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if (pthis->actionFunc != NULL && pthis->actionFunc != func_80A79FB0) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } -void func_80A79FB0(EnIn* this, GlobalContext* globalCtx) { +void func_80A79FB0(EnIn* pthis, GlobalContext* globalCtx) { s32 sp3C = 0; - if (Object_IsLoaded(&globalCtx->objectCtx, this->ingoObjBankIndex) || this->actor.params <= 0) { - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gIngoSkel, NULL, this->jointTable, this->morphTable, 20); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (func_80A7975C(this, globalCtx)) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->ingoObjBankIndex) || pthis->actor.params <= 0) { + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gIngoSkel, NULL, pthis->jointTable, pthis->morphTable, 20); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + if (func_80A7975C(pthis, globalCtx)) { gSaveContext.eventInf[0] &= ~0x8000; return; } - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->unk_308.unk_00 = 0; - this->actionFunc = func_80A7A4BC; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->unk_308.unk_00 = 0; + pthis->actionFunc = func_80A7A4BC; - switch (func_80A79830(this, globalCtx)) { + switch (func_80A79830(pthis, globalCtx)) { case 1: - func_80A796EC(this, 9); - this->actionFunc = func_80A7A4BC; + func_80A796EC(pthis, 9); + pthis->actionFunc = func_80A7A4BC; break; case 3: - func_80A796EC(this, 7); - this->actionFunc = func_80A7A4BC; + func_80A796EC(pthis, 7); + pthis->actionFunc = func_80A7A4BC; if (!(gSaveContext.eventChkInf[1] & 0x100)) { - this->actor.params = 5; + pthis->actor.params = 5; } break; case 4: - func_80A796EC(this, 8); - this->eyeIndex = 3; - this->actionFunc = func_80A7A4BC; + func_80A796EC(pthis, 8); + pthis->eyeIndex = 3; + pthis->actionFunc = func_80A7A4BC; break; case 0: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; default: switch (gSaveContext.eventInf[0] & 0xF) { @@ -555,106 +555,106 @@ void func_80A79FB0(EnIn* this, GlobalContext* globalCtx) { case 3: case 4: case 7: - if (this->actor.params == 2) { + if (pthis->actor.params == 2) { sp3C = 1; } break; case 1: - if (this->actor.params == 3) { + if (pthis->actor.params == 3) { sp3C = 1; } break; case 5: case 6: - if (this->actor.params == 4) { + if (pthis->actor.params == 4) { sp3C = 1; } break; } if (sp3C != 1) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } switch (gSaveContext.eventInf[0] & 0xF) { case 0: case 2: - func_80A796EC(this, 2); - this->actionFunc = func_80A7A4C8; + func_80A796EC(pthis, 2); + pthis->actionFunc = func_80A7A4C8; gSaveContext.eventInf[0] = 0; break; case 1: - this->actor.targetMode = 3; - func_80A796EC(this, 2); - this->actionFunc = func_80A7A568; + pthis->actor.targetMode = 3; + func_80A796EC(pthis, 2); + pthis->actionFunc = func_80A7A568; func_80088B34(0x3C); break; case 3: - func_80A796EC(this, 4); - this->actionFunc = func_80A7A770; + func_80A796EC(pthis, 4); + pthis->actionFunc = func_80A7A770; break; case 4: - func_80A796EC(this, 6); - this->unk_1EC = 8; - this->actionFunc = func_80A7A940; + func_80A796EC(pthis, 6); + pthis->unk_1EC = 8; + pthis->actionFunc = func_80A7A940; break; case 5: case 6: - this->actor.targetMode = 3; - func_80A796EC(this, 6); - this->unk_1EC = 8; - this->actionFunc = func_80A7AA40; + pthis->actor.targetMode = 3; + func_80A796EC(pthis, 6); + pthis->unk_1EC = 8; + pthis->actionFunc = func_80A7AA40; break; case 7: - func_80A796EC(this, 2); - this->actionFunc = func_80A7A848; + func_80A796EC(pthis, 2); + pthis->actionFunc = func_80A7A848; break; } } } } -void func_80A7A304(EnIn* this, GlobalContext* globalCtx) { - if (this->skelAnime.animation == &object_in_Anim_015814 || this->skelAnime.animation == &object_in_Anim_01646C) { - if (this->skelAnime.curFrame == 8.0f) { - Audio_PlaySoundRandom(&this->actor.projectedPos, NA_SE_VO_IN_LASH_0, +void func_80A7A304(EnIn* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.animation == &object_in_Anim_015814 || pthis->skelAnime.animation == &object_in_Anim_01646C) { + if (pthis->skelAnime.curFrame == 8.0f) { + Audio_PlaySoundRandom(&pthis->actor.projectedPos, NA_SE_VO_IN_LASH_0, NA_SE_VO_IN_LASH_1 - NA_SE_VO_IN_LASH_0 + 1); } } - if (this->skelAnime.animation == &object_in_Anim_018C38 && this->skelAnime.curFrame == 20.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_CRY_0); + if (pthis->skelAnime.animation == &object_in_Anim_018C38 && pthis->skelAnime.curFrame == 20.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_IN_CRY_0); } - if (SkelAnime_Update(&this->skelAnime) != 0) { - this->animationIdx %= 8; - this->unk_1E8 = this->animationIdx; - if (this->animationIdx == 3 || this->animationIdx == 4) { - Audio_PlaySoundGeneral(NA_SE_IT_LASH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + pthis->animationIdx %= 8; + pthis->unk_1E8 = pthis->animationIdx; + if (pthis->animationIdx == 3 || pthis->animationIdx == 4) { + Audio_PlaySoundGeneral(NA_SE_IT_LASH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (Rand_ZeroOne() < 0.3f) { - Audio_PlaySoundGeneral(NA_SE_IT_INGO_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_IT_INGO_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } - Animation_Change(&this->skelAnime, D_80A7B918[this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(D_80A7B918[this->animationIdx]), 2, -10.0f); + Animation_Change(&pthis->skelAnime, D_80A7B918[pthis->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(D_80A7B918[pthis->animationIdx]), 2, -10.0f); } } -void func_80A7A4BC(EnIn* this, GlobalContext* globalCtx) { +void func_80A7A4BC(EnIn* pthis, GlobalContext* globalCtx) { } -void func_80A7A4C8(EnIn* this, GlobalContext* globalCtx) { - if (this->unk_308.unk_00 == 2) { - func_80A79BAC(this, globalCtx, 1, 0x20); +void func_80A7A4C8(EnIn* pthis, GlobalContext* globalCtx) { + if (pthis->unk_308.unk_00 == 2) { + func_80A79BAC(pthis, globalCtx, 1, 0x20); gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x000F) | 0x0001; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x8000) | 0x8000; gSaveContext.infTable[10] &= ~4; Environment_ForcePlaySequence(NA_BGM_HORSE); globalCtx->msgCtx.stateTimer = 0; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; } } -void func_80A7A568(EnIn* this, GlobalContext* globalCtx) { +void func_80A7A568(EnIn* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 phi_a2; s32 phi_a3; @@ -664,15 +664,15 @@ void func_80A7A568(EnIn* this, GlobalContext* globalCtx) { } if (gSaveContext.timer1State == 10) { Audio_PlaySoundGeneral(NA_SE_SY_FOUND, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - func_80A79C78(this, globalCtx); - this->actionFunc = func_80A7B024; + func_80A79C78(pthis, globalCtx); + pthis->actionFunc = func_80A7B024; gSaveContext.timer1State = 0; - } else if (this->unk_308.unk_00 == 2) { + } else if (pthis->unk_308.unk_00 == 2) { if (globalCtx->msgCtx.choiceIndex == 0) { if (gSaveContext.rupees < 50) { globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; return; } gSaveContext.eventInf[0] = @@ -692,24 +692,24 @@ void func_80A7A568(EnIn* this, GlobalContext* globalCtx) { phi_a2 = 0; phi_a3 = 0x20; } - func_80A79BAC(this, globalCtx, phi_a2, phi_a3); + func_80A79BAC(pthis, globalCtx, phi_a2, phi_a3); globalCtx->msgCtx.stateTimer = 0; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x8000) | 0x8000; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; } } -void func_80A7A770(EnIn* this, GlobalContext* globalCtx) { - if (this->unk_308.unk_00 == 0) { - this->actor.flags |= ACTOR_FLAG_16; - } else if (this->unk_308.unk_00 == 2) { +void func_80A7A770(EnIn* pthis, GlobalContext* globalCtx) { + if (pthis->unk_308.unk_00 == 0) { + pthis->actor.flags |= ACTOR_FLAG_16; + } else if (pthis->unk_308.unk_00 == 2) { Rupees_ChangeBy(-50); - this->actor.flags &= ~ACTOR_FLAG_16; - func_80A796EC(this, 3); - this->actionFunc = func_80A7A848; + pthis->actor.flags &= ~ACTOR_FLAG_16; + func_80A796EC(pthis, 3); + pthis->actionFunc = func_80A7A848; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x0F) | 7; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 0xFFFF) | 0x20; if (!(gSaveContext.eventInf[0] & 0x40)) { globalCtx->msgCtx.stateTimer = 4; @@ -718,87 +718,87 @@ void func_80A7A770(EnIn* this, GlobalContext* globalCtx) { } } -void func_80A7A848(EnIn* this, GlobalContext* globalCtx) { - if (this->unk_308.unk_00 == 2) { +void func_80A7A848(EnIn* pthis, GlobalContext* globalCtx) { + if (pthis->unk_308.unk_00 == 2) { if ((globalCtx->msgCtx.choiceIndex == 0 && gSaveContext.rupees < 50) || globalCtx->msgCtx.choiceIndex == 1) { gSaveContext.eventInf[0] &= ~0xF; - this->actionFunc = func_80A7A4C8; + pthis->actionFunc = func_80A7A4C8; } else { - func_80A79BAC(this, globalCtx, 2, 0x26); + func_80A79BAC(pthis, globalCtx, 2, 0x26); gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0xF) | 2; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x8000) | 0x8000; globalCtx->msgCtx.stateTimer = 0; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; gSaveContext.eventInf[0] &= ~0x20; gSaveContext.eventInf[0] &= ~0x40; } } -void func_80A7A940(EnIn* this, GlobalContext* globalCtx) { - if (this->unk_308.unk_00 == 0) { - this->actor.flags |= ACTOR_FLAG_16; +void func_80A7A940(EnIn* pthis, GlobalContext* globalCtx) { + if (pthis->unk_308.unk_00 == 0) { + pthis->actor.flags |= ACTOR_FLAG_16; return; } - if (this->unk_1EC != 0) { - this->unk_1EC--; - if (this->unk_1EC == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_LOST); + if (pthis->unk_1EC != 0) { + pthis->unk_1EC--; + if (pthis->unk_1EC == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_IN_LOST); } } - if (this->unk_308.unk_00 == 2) { - this->actor.flags &= ~ACTOR_FLAG_16; - func_80A79BAC(this, globalCtx, 2, 0x26); + if (pthis->unk_308.unk_00 == 2) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + func_80A79BAC(pthis, globalCtx, 2, 0x26); gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x000F) | 0x0002; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x8000) | 0x8000; globalCtx->msgCtx.stateTimer = 0; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 0xFFFF) | 0x40; } } -void func_80A7AA40(EnIn* this, GlobalContext* globalCtx) { +void func_80A7AA40(EnIn* pthis, GlobalContext* globalCtx) { Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f sp30; Vec3f sp24; - this->camId = Gameplay_CreateSubCamera(globalCtx); - this->activeCamId = globalCtx->activeCamera; - Gameplay_ChangeCameraStatus(globalCtx, this->activeCamId, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->camId, CAM_STAT_ACTIVE); + pthis->camId = Gameplay_CreateSubCamera(globalCtx); + pthis->activeCamId = globalCtx->activeCamera; + Gameplay_ChangeCameraStatus(globalCtx, pthis->activeCamId, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->camId, CAM_STAT_ACTIVE); - this->unk_2F0 = 0.0f; - this->unk_2F4 = 50.0f; - this->unk_2F8 = 0.0f; - this->unk_2FC = 0.0f; - this->unk_300 = 50.0f; - this->unk_304 = 50.0f; + pthis->unk_2F0 = 0.0f; + pthis->unk_2F4 = 50.0f; + pthis->unk_2F8 = 0.0f; + pthis->unk_2FC = 0.0f; + pthis->unk_300 = 50.0f; + pthis->unk_304 = 50.0f; - sp30 = this->actor.world.pos; - sp24 = this->actor.world.pos; + sp30 = pthis->actor.world.pos; + sp24 = pthis->actor.world.pos; - sp30.x += this->unk_2F0; - sp30.y += this->unk_2F4; - sp30.z += this->unk_2F8; + sp30.x += pthis->unk_2F0; + sp30.y += pthis->unk_2F4; + sp30.z += pthis->unk_2F8; - sp24.x += this->unk_2FC; - sp24.y += this->unk_300; - sp24.z += this->unk_304; + sp24.x += pthis->unk_2FC; + sp24.y += pthis->unk_300; + sp24.z += pthis->unk_304; - Gameplay_CameraSetAtEye(globalCtx, this->camId, &sp30, &sp24); - this->actor.textId = 0x203B; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_308.unk_00 = 1; - this->unk_1FC = 0; + Gameplay_CameraSetAtEye(globalCtx, pthis->camId, &sp30, &sp24); + pthis->actor.textId = 0x203B; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_308.unk_00 = 1; + pthis->unk_1FC = 0; globalCtx->csCtx.frames = 0; ShrinkWindow_SetVal(0x20); Interface_ChangeAlpha(2); - this->actionFunc = func_80A7ABD4; + pthis->actionFunc = func_80A7ABD4; } -void func_80A7ABD4(EnIn* this, GlobalContext* globalCtx) { +void func_80A7ABD4(EnIn* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f sp48; Vec3f sp3C; @@ -807,186 +807,186 @@ void func_80A7ABD4(EnIn* this, GlobalContext* globalCtx) { player->rideActor->freezeTimer = 10; } player->actor.freezeTimer = 10; - if (this->actor.textId == 0x203B) { - if (this->unk_1EC != 0) { - this->unk_1EC--; - if (this->unk_1EC == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_LOST); + if (pthis->actor.textId == 0x203B) { + if (pthis->unk_1EC != 0) { + pthis->unk_1EC--; + if (pthis->unk_1EC == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_IN_LOST); } } } - if (this->unk_308.unk_00 != 0) { - if (this->unk_308.unk_00 == 2) { - if (this->actor.textId == 0x203B) { - this->actor.textId = 0x203C; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_308.unk_00 = 1; - func_80A796EC(this, 3); + if (pthis->unk_308.unk_00 != 0) { + if (pthis->unk_308.unk_00 == 2) { + if (pthis->actor.textId == 0x203B) { + pthis->actor.textId = 0x203C; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_308.unk_00 = 1; + func_80A796EC(pthis, 3); } else { globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; } } } else { if (globalCtx->csCtx.frames++ >= 50) { - this->actionFunc = func_80A7AE84; + pthis->actionFunc = func_80A7AE84; return; } if (globalCtx->csCtx.frames == 44) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_RONRON_DOOR_CLOSE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_RONRON_DOOR_CLOSE); } - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.06f, 10000.0f, 0.0f); - Math_SmoothStepToF(&this->unk_2F4, 50.0f, 0.06f, 10000.0f, 0.0f); - Math_SmoothStepToF(&this->unk_2F8, 0.0f, 0.06f, 10000.0f, 0.0f); - Math_SmoothStepToF(&this->unk_2FC, 0.0f, 0.06f, 10000.0f, 0.0f); - Math_SmoothStepToF(&this->unk_300, 150.0f, 0.06f, 10000.0f, 0.0f); - Math_SmoothStepToF(&this->unk_304, 300.0f, 0.06f, 10000.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_2F0, 0.0f, 0.06f, 10000.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_2F4, 50.0f, 0.06f, 10000.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_2F8, 0.0f, 0.06f, 10000.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_2FC, 0.0f, 0.06f, 10000.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_300, 150.0f, 0.06f, 10000.0f, 0.0f); + Math_SmoothStepToF(&pthis->unk_304, 300.0f, 0.06f, 10000.0f, 0.0f); - sp48 = this->actor.world.pos; - sp3C = this->actor.world.pos; + sp48 = pthis->actor.world.pos; + sp3C = pthis->actor.world.pos; - sp48.x += this->unk_2F0; - sp48.y += this->unk_2F4; - sp48.z += this->unk_2F8; - sp3C.x += this->unk_2FC; - sp3C.y += this->unk_300; - sp3C.z += this->unk_304; - Gameplay_CameraSetAtEye(globalCtx, this->camId, &sp48, &sp3C); + sp48.x += pthis->unk_2F0; + sp48.y += pthis->unk_2F4; + sp48.z += pthis->unk_2F8; + sp3C.x += pthis->unk_2FC; + sp3C.y += pthis->unk_300; + sp3C.z += pthis->unk_304; + Gameplay_CameraSetAtEye(globalCtx, pthis->camId, &sp48, &sp3C); } } -void func_80A7AE84(EnIn* this, GlobalContext* globalCtx) { - Gameplay_ChangeCameraStatus(globalCtx, this->activeCamId, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, this->camId); - func_8002DF54(globalCtx, &this->actor, 7); +void func_80A7AE84(EnIn* pthis, GlobalContext* globalCtx) { + Gameplay_ChangeCameraStatus(globalCtx, pthis->activeCamId, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, pthis->camId); + func_8002DF54(globalCtx, &pthis->actor, 7); Interface_ChangeAlpha(0x32); - this->actionFunc = func_80A7AEF0; + pthis->actionFunc = func_80A7AEF0; } -void func_80A7AEF0(EnIn* this, GlobalContext* globalCtx) { +void func_80A7AEF0(EnIn* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 yaw; - Vec3f pos = this->actor.world.pos; + Vec3f pos = pthis->actor.world.pos; - pos.x += 90.0f * Math_SinS(this->actor.shape.rot.y); - pos.z += 90.0f * Math_CosS(this->actor.shape.rot.y); + pos.x += 90.0f * Math_SinS(pthis->actor.shape.rot.y); + pos.z += 90.0f * Math_CosS(pthis->actor.shape.rot.y); yaw = Math_Vec3f_Yaw(&pos, &player->actor.world.pos); if (ABS(yaw) > 0x4000) { globalCtx->nextEntranceIndex = 0x0476; globalCtx->sceneLoadFlag = 0x14; globalCtx->fadeTransition = 5; - this->actionFunc = func_80A7B018; - } else if (this->unk_308.unk_00 == 2) { + pthis->actionFunc = func_80A7B018; + } else if (pthis->unk_308.unk_00 == 2) { globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; } } -void func_80A7B018(EnIn* this, GlobalContext* globalCtx) { +void func_80A7B018(EnIn* pthis, GlobalContext* globalCtx) { } -void func_80A7B024(EnIn* this, GlobalContext* globalCtx) { +void func_80A7B024(EnIn* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->rideActor != NULL) { player->rideActor->freezeTimer = 10; } player->actor.freezeTimer = 10; - if (this->unk_308.unk_00 == 2) { + if (pthis->unk_308.unk_00 == 2) { if (1) {} if (!(gSaveContext.eventChkInf[1] & 0x800) && (gSaveContext.infTable[10] & 0x800)) { gSaveContext.eventChkInf[1] |= 0x800; gSaveContext.infTable[10] |= 0x800; } - func_80A79BAC(this, globalCtx, 0, 0x26); + func_80A79BAC(pthis, globalCtx, 0, 0x26); gSaveContext.eventInf[0] = gSaveContext.eventInf[0] & ~0xF; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0x8000) | 0x8000; globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - this->unk_308.unk_00 = 0; + pthis->unk_308.unk_00 = 0; } } void EnIn_Update(Actor* thisx, GlobalContext* globalCtx) { ColliderCylinder* collider; - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; - if (this->actionFunc == func_80A79FB0) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc == func_80A79FB0) { + pthis->actionFunc(pthis, globalCtx); return; } - collider = &this->collider; - Collider_UpdateCylinder(&this->actor, collider); + collider = &pthis->collider; + Collider_UpdateCylinder(&pthis->actor, collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); - if (this->actionFunc != func_80A7A304) { - SkelAnime_Update(&this->skelAnime); - if (this->skelAnime.animation == &object_in_Anim_001BE0 && ((gSaveContext.eventInf[0] & 0xF) != 6)) { - func_80A79690(&this->skelAnime, this, globalCtx); + if (pthis->actionFunc != func_80A7A304) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->skelAnime.animation == &object_in_Anim_001BE0 && ((gSaveContext.eventInf[0] & 0xF) != 6)) { + func_80A79690(&pthis->skelAnime, pthis, globalCtx); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); } - EnIn_UpdateEyes(this); - this->actionFunc(this, globalCtx); - if (this->actionFunc != func_80A7A304) { - func_80A79AB4(this, globalCtx); - if (gSaveContext.timer2Value < 6 && gSaveContext.timer2State != 0 && this->unk_308.unk_00 == 0) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) {} + EnIn_UpdateEyes(pthis); + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc != func_80A7A304) { + func_80A79AB4(pthis, globalCtx); + if (gSaveContext.timer2Value < 6 && gSaveContext.timer2State != 0 && pthis->unk_308.unk_00 == 0) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) {} } else { - func_800343CC(globalCtx, &this->actor, &this->unk_308.unk_00, - ((this->actor.targetMode == 6) ? 80.0f : 320.0f) + this->collider.dim.radius, func_80A79168, + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_308.unk_00, + ((pthis->actor.targetMode == 6) ? 80.0f : 320.0f) + pthis->collider.dim.radius, func_80A79168, func_80A79500); - if (this->unk_308.unk_00 != 0) { - this->unk_1FA = this->unk_1F8; - this->unk_1F8 = Message_GetState(&globalCtx->msgCtx); + if (pthis->unk_308.unk_00 != 0) { + pthis->unk_1FA = pthis->unk_1F8; + pthis->unk_1F8 = Message_GetState(&globalCtx->msgCtx); } } - func_80A795C8(this, globalCtx); + func_80A795C8(pthis, globalCtx); } } s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; Vec3s sp2C; - if (this->actor.params > 0 && limbIndex != INGO_HEAD_LIMB) { + if (pthis->actor.params > 0 && limbIndex != INGO_HEAD_LIMB) { if (sAdultEraDLs[limbIndex] != NULL) { *dList = sAdultEraDLs[limbIndex]; } } if (limbIndex == INGO_HEAD_LIMB) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - sp2C = this->unk_308.unk_08; + sp2C = pthis->unk_308.unk_08; Matrix_RotateZ(BINANG_TO_RAD(sp2C.x), MTXMODE_APPLY); Matrix_RotateX(BINANG_TO_RAD(sp2C.y), MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == INGO_CHEST_LIMB) { - sp2C = this->unk_308.unk_0E; + sp2C = pthis->unk_308.unk_0E; Matrix_RotateX(BINANG_TO_RAD(sp2C.x), MTXMODE_APPLY); Matrix_RotateY(BINANG_TO_RAD(sp2C.y), MTXMODE_APPLY); } if (limbIndex == INGO_CHEST_LIMB || limbIndex == INGO_LEFT_SHOULDER_LIMB || limbIndex == INGO_RIGHT_SHOULDER_LIMB) { - rot->y += Math_SinS(this->unk_330[limbIndex].y) * 200.0f; - rot->z += Math_CosS(this->unk_330[limbIndex].z) * 200.0f; + rot->y += Math_SinS(pthis->unk_330[limbIndex].y) * 200.0f; + rot->z += Math_CosS(pthis->unk_330[limbIndex].z) * 200.0f; } return 0; } void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; Vec3f D_80A7B9A8 = { 1600.0, 0.0f, 0.0f }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_in.c", 2335); if (limbIndex == INGO_HEAD_LIMB) { - Matrix_MultVec3f(&D_80A7B9A8, &this->actor.focus.pos); - this->actor.focus.rot = this->actor.world.rot; + Matrix_MultVec3f(&D_80A7B9A8, &pthis->actor.focus.pos); + pthis->actor.focus.rot = pthis->actor.world.rot; } - if (limbIndex == INGO_LEFT_HAND_LIMB && this->skelAnime.animation == &object_in_Anim_014CA8) { + if (limbIndex == INGO_LEFT_HAND_LIMB && pthis->skelAnime.animation == &object_in_Anim_014CA8) { gSPDisplayList(POLY_OPA_DISP++, gIngoChildEraBasketDL); } - if (limbIndex == INGO_RIGHT_HAND_LIMB && this->skelAnime.animation == &object_in_Anim_014CA8) { + if (limbIndex == INGO_RIGHT_HAND_LIMB && pthis->skelAnime.animation == &object_in_Anim_014CA8) { gSPDisplayList(POLY_OPA_DISP++, gIngoChildEraPitchForkDL); } @@ -996,15 +996,15 @@ void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx) { static void* eyeTextures[] = { gIngoEyeOpenTex, gIngoEyeHalfTex, gIngoEyeClosedTex, gIngoEyeClosed2Tex }; - EnIn* this = (EnIn*)thisx; + EnIn* pthis = (EnIn*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_in.c", 2384); - if (this->actionFunc != func_80A79FB0) { + if (pthis->actionFunc != func_80A79FB0) { func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gIngoHeadGradient2Tex)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnIn_OverrideLimbDraw, EnIn_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnIn_OverrideLimbDraw, EnIn_PostLimbDraw, &pthis->actor); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_in.c", 2416); } diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c deleted file mode 100644 index d8b47e051..000000000 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ /dev/null @@ -1,805 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_INSECT_Z_EN_INSECT_C -#include "actor_common.h" -#include "kaleido.h" -/* - * File: z_en_insect.c - * Overlay: ovl_En_Insect - * Description: Bugs - */ - -#include "z_en_insect.h" -#include "vt.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS 0 - -void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx); -void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx); -void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A7C3A0(EnInsect* this); -void func_80A7C3F4(EnInsect* this, GlobalContext* globalCtx); -void func_80A7C598(EnInsect* this); -void func_80A7C5EC(EnInsect* this, GlobalContext* globalCtx); -void func_80A7C818(EnInsect* this); -void func_80A7C86C(EnInsect* this, GlobalContext* globalCtx); -void func_80A7CAD0(EnInsect* this, GlobalContext* globalCtx); -void func_80A7CBC8(EnInsect* this); -void func_80A7CC3C(EnInsect* this, GlobalContext* globalCtx); -void func_80A7CE60(EnInsect* this); -void func_80A7CEC0(EnInsect* this, GlobalContext* globalCtx); -void func_80A7D1F4(EnInsect* this); -void func_80A7D26C(EnInsect* this, GlobalContext* globalCtx); -void func_80A7D39C(EnInsect* this); -void func_80A7D460(EnInsect* this, GlobalContext* globalCtx); - -static f32 D_80A7DEB0 = 0.0f; -static s16 D_80A7DEB4 = 0; -static s16 D_80A7DEB8 = 0; - -const ActorInit En_Insect_InitVars = { - ACTOR_EN_INSECT, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnInsect), - (ActorFunc)EnInsect_Init, - (ActorFunc)EnInsect_Destroy, - (ActorFunc)EnInsect_Update, - (ActorFunc)EnInsect_Draw, -}; - -static ColliderJntSphElementInit sColliderItemInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 5 }, 100 }, - }, -}; - -static ColliderJntSphInit sColliderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sColliderItemInit, -}; - -static u16 D_80A7DF10[] = { 0, 5, 7, 7 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), -}; - -void func_80A7BE20(EnInsect* this) { - this->unk_314 = D_80A7DF10[this->actor.params & 3]; -} - -f32 EnInsect_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { - return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); -} - -s32 EnInsect_InBottleRange(EnInsect* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - Vec3f pos; - - if (this->actor.xzDistToPlayer < 32.0f) { - pos.x = Math_SinS(this->actor.yawTowardsPlayer + 0x8000) * 16.0f + player->actor.world.pos.x; - pos.y = player->actor.world.pos.y; - pos.z = Math_CosS(this->actor.yawTowardsPlayer + 0x8000) * 16.0f + player->actor.world.pos.z; - - //! @bug: this check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have - //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's - //! world rotation. - if (EnInsect_XZDistanceSquared(&pos, &this->actor.world.pos) <= SQ(20.0f)) { - return true; - } - } - - return false; -} - -void func_80A7BF58(EnInsect* this) { - Animation_Change(&this->skelAnime, &gBugCrawlAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); -} - -/** - * Find the nearest soft dirt patch within 6400 units in the xz plane and the current room - * - * @return 1 if one was found, 0 otherwise - */ -s32 EnInsect_FoundNearbySoil(EnInsect* this, GlobalContext* globalCtx) { - Actor* currentActor; - f32 currentDistance; - f32 bestDistance; - s32 ret; - - ret = 0; - currentActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; - bestDistance = 6400.0f; - this->soilActor = NULL; - - while (currentActor != NULL) { - if (currentActor->id == ACTOR_OBJ_MAKEKINSUTA) { - currentDistance = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z, - currentActor->world.pos.x, currentActor->world.pos.z); - - if (currentDistance < bestDistance && currentActor->room == this->actor.room) { - ret = 1; - bestDistance = currentDistance; - this->soilActor = (ObjMakekinsuta*)currentActor; - } - } - currentActor = currentActor->next; - } - return ret; -} - -void func_80A7C058(EnInsect* this) { - if (this->unk_31E > 0) { - this->unk_31E--; - return; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_WALK); - - this->unk_31E = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); - if (this->unk_31E < 2) { - this->unk_31E = 2; - } -} - -void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnInsect* this = (EnInsect*)thisx; - GlobalContext* globalCtx = globalCtx2; - f32 rand; - s16 temp_s2; - s32 count; - - Actor_ProcessInitChain(&this->actor, sInitChain); - func_80A7BE20(this); - - temp_s2 = this->actor.params & 3; - - SkelAnime_Init(globalCtx, &this->skelAnime, &gBugSkel, &gBugCrawlAnim, this->jointTable, this->morphTable, 24); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderInit, &this->colliderItem); - - this->actor.colChkInfo.mass = 30; - - if (this->unk_314 & 1) { - this->actor.gravity = -0.2f; - this->actor.minVelocityY = -2.0f; - } - - if (this->unk_314 & 4) { - this->unk_31C = Rand_S16Offset(200, 40); - this->actor.flags |= ACTOR_FLAG_4; - } - - if (temp_s2 == 2 || temp_s2 == 3) { - if (EnInsect_FoundNearbySoil(this, globalCtx)) { - this->unk_314 |= 0x10; - D_80A7DEB0 = 0.0f; - } - - if (temp_s2 == 2) { - this->actor.world.rot.z = 0; - this->actor.shape.rot.z = this->actor.world.rot.z; - - for (count = 0; count < 2; count++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, this->actor.shape.rot.z, 3); - } - } - - func_80A7D39C(this); - - D_80A7DEB8++; - } else { - rand = Rand_ZeroOne(); - - if (rand < 0.3f) { - func_80A7C3A0(this); - } else if (rand < 0.4f) { - func_80A7C598(this); - } else { - func_80A7C818(this); - } - } -} - -void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s16 temp_v0; - EnInsect* this = (EnInsect*)thisx; - - temp_v0 = this->actor.params & 3; - Collider_DestroyJntSph(globalCtx, &this->collider); - if ((temp_v0 == 2 || temp_v0 == 3) && D_80A7DEB8 > 0) { - D_80A7DEB8--; - } -} - -void func_80A7C3A0(EnInsect* this) { - this->unk_31A = Rand_S16Offset(5, 35); - func_80A7BF58(this); - this->actionFunc = func_80A7C3F4; - this->unk_314 |= 0x100; -} - -void func_80A7C3F4(EnInsect* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 sp2E; - f32 playSpeed; - - sp2E = this->actor.params & 3; - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); - - playSpeed = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); - this->skelAnime.playSpeed = CLAMP(playSpeed, 0.0f, 1.9f); - - SkelAnime_Update(&this->skelAnime); - this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_31A <= 0) { - func_80A7C598(this); - } - - if (((this->unk_314 & 4) && this->unk_31C <= 0) || - ((sp2E == 2 || sp2E == 3) && (this->unk_314 & 1) && (this->actor.bgCheckFlags & 1) && D_80A7DEB8 >= 4)) { - func_80A7CBC8(this); - } else if ((this->unk_314 & 1) && (this->actor.bgCheckFlags & 0x40)) { - func_80A7CE60(this); - } else if (this->actor.xzDistToPlayer < 40.0f) { - func_80A7C818(this); - } -} - -void func_80A7C598(EnInsect* this) { - this->unk_31A = Rand_S16Offset(10, 45); - func_80A7BF58(this); - this->actionFunc = func_80A7C5EC; - this->unk_314 |= 0x100; -} - -void func_80A7C5EC(EnInsect* this, GlobalContext* globalCtx) { - s32 pad1; - s32 pad2; - s16 yaw; - s16 sp34 = this->actor.params & 3; - - Math_SmoothStepToF(&this->actor.speedXZ, 1.5f, 0.1f, 0.5f, 0.0f); - - if (EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > 1600.0f || (this->unk_31A < 4)) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); - } else if (this->actor.child != NULL && &this->actor != this->actor.child) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); - Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - this->skelAnime.playSpeed = CLAMP(this->actor.speedXZ * 1.4f, 0.7f, 1.9f); - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_31A <= 0) { - func_80A7C3A0(this); - } - - if (((this->unk_314 & 4) && this->unk_31C <= 0) || - ((sp34 == 2 || sp34 == 3) && (this->unk_314 & 1) && (this->actor.bgCheckFlags & 1) && D_80A7DEB8 >= 4)) { - func_80A7CBC8(this); - } else if ((this->unk_314 & 1) && (this->actor.bgCheckFlags & 0x40)) { - func_80A7CE60(this); - } else if (this->actor.xzDistToPlayer < 40.0f) { - func_80A7C818(this); - } -} - -void func_80A7C818(EnInsect* this) { - this->unk_31A = Rand_S16Offset(10, 40); - func_80A7BF58(this); - this->actionFunc = func_80A7C86C; - this->unk_314 |= 0x100; -} - -void func_80A7C86C(EnInsect* this, GlobalContext* globalCtx) { - s32 pad1; - s32 pad2; - s16 pad3; - s16 frames; - s16 yaw; - s16 sp38 = this->actor.xzDistToPlayer < 40.0f; - - Math_SmoothStepToF(&this->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); - - if (EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > 25600.0f || this->unk_31A < 4) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); - } else if (sp38 != 0) { - frames = globalCtx->state.frames; - yaw = this->actor.yawTowardsPlayer + 0x8000; - - if (frames & 0x10) { - if (frames & 0x20) { - yaw += 0x2000; - } - } else { - if (frames & 0x20) { - yaw -= 0x2000; - } - } - if (globalCtx) {} // Must be 'globalCtx' - Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); - } - this->actor.shape.rot.y = this->actor.world.rot.y; - this->skelAnime.playSpeed = CLAMP(this->actor.speedXZ * 1.6f, 0.8f, 1.9f); - SkelAnime_Update(&this->skelAnime); - - if (this->unk_31A <= 0 || !sp38) { - func_80A7C3A0(this); - } else if ((this->unk_314 & 1) && (this->actor.bgCheckFlags & 0x40)) { - func_80A7CE60(this); - } -} - -void func_80A7CA64(EnInsect* this) { - this->unk_31A = 200; - - Actor_SetScale(&this->actor, 0.001f); - - this->actor.draw = NULL; - this->actor.speedXZ = 0.0f; - - func_80A7BF58(this); - - this->skelAnime.playSpeed = 0.3f; - this->actionFunc = func_80A7CAD0; - this->unk_314 &= ~0x100; -} - -void func_80A7CAD0(EnInsect* this, GlobalContext* globalCtx) { - if (this->unk_31A == 20 && !(this->unk_314 & 4)) { - this->actor.draw = EnInsect_Draw; - } else if (this->unk_31A == 0) { - if (this->unk_314 & 4) { - Actor_Kill(&this->actor); - } else { - Actor_SetScale(&this->actor, 0.01f); - func_80A7C3A0(this); - } - } else if (this->unk_31A < 20) { - Actor_SetScale(&this->actor, CLAMP_MAX(this->actor.scale.x + 0.001f, 0.01f)); - SkelAnime_Update(&this->skelAnime); - } -} - -void func_80A7CBC8(EnInsect* this) { - this->unk_31A = 60; - func_80A7BF58(this); - this->skelAnime.playSpeed = 1.9f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_SINK); - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - this->actionFunc = func_80A7CC3C; - this->unk_314 &= ~0x100; - this->unk_314 |= 0x8; -} - -void func_80A7CC3C(EnInsect* this, GlobalContext* globalCtx) { - static Vec3f accel = { 0.0f, 0.0f, 0.0f }; - static Vec3f unused = { 0.0f, 0.0f, 0.0f }; - s32 pad[2]; - Vec3f velocity; - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); - Math_StepToS(&this->actor.shape.rot.x, 10922, 352); - - Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.0002f, 0.001f)); - - this->actor.shape.yOffset -= 0.8f; - this->actor.world.pos.x = Rand_ZeroOne() + this->actor.home.pos.x - 0.5f; - this->actor.world.pos.z = Rand_ZeroOne() + this->actor.home.pos.z - 0.5f; - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_31A > 20 && Rand_ZeroOne() < 0.1f) { - velocity.x = Math_SinS(this->actor.shape.rot.y) * -0.6f; - velocity.y = Math_SinS(this->actor.shape.rot.x) * 0.6f; - velocity.z = Math_CosS(this->actor.shape.rot.y) * -0.6f; - func_800286CC(globalCtx, &this->actor.world.pos, &velocity, &accel, Rand_ZeroOne() * 5.0f + 8.0f, - Rand_ZeroOne() * 5.0f + 8.0f); - } - - if (this->unk_31A <= 0) { - if ((this->unk_314 & 0x10) && this->soilActor != NULL && - Math3D_Vec3fDistSq(&this->soilActor->actor.world.pos, &this->actor.world.pos) < 64.0f) { - this->soilActor->unk_152 = 1; - } - Actor_Kill(&this->actor); - } -} - -void func_80A7CE60(EnInsect* this) { - this->unk_31A = Rand_S16Offset(120, 50); - func_80A7BF58(this); - this->unk_316 = this->unk_318 = 0; - this->actionFunc = func_80A7CEC0; - this->unk_314 &= ~0x100; -} - -void func_80A7CEC0(EnInsect* this, GlobalContext* globalCtx) { - f32 temp_f0; - s16 temp_v1; - s16 pad; - s16 sp4E; - Vec3f sp40; - s32 phi_v0; - s32 phi_v0_2; - - sp4E = this->actor.params & 3; - - if (this->unk_31A >= 81) { - Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); - } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); - } - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y += this->actor.yDistToWater; - this->skelAnime.playSpeed = CLAMP(this->unk_31A * 0.018f, 0.1f, 1.9f); - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_31A >= 81) { - this->unk_316 += Rand_S16Offset(-50, 100); - this->unk_318 += Rand_S16Offset(-300, 600); - } - - temp_v1 = this->skelAnime.playSpeed * 200.0f; - - if (this->unk_316 < -temp_v1) { - this->unk_316 = -temp_v1; - } else { - if (temp_v1 < this->unk_316) { - phi_v0 = temp_v1; - } else { - phi_v0 = this->unk_316; - } - this->unk_316 = phi_v0; - } - this->actor.world.rot.y += this->unk_316; - - temp_v1 = this->skelAnime.playSpeed * 1000.0f; - if (this->unk_318 < -temp_v1) { - this->unk_318 = -temp_v1; - } else { - if (temp_v1 < this->unk_318) { - phi_v0_2 = temp_v1; - } else { - phi_v0_2 = this->unk_318; - } - this->unk_318 = phi_v0_2; - } - this->actor.shape.rot.y += this->unk_318; - - Math_ScaledStepToS(&this->actor.world.rot.x, 0, 3000); - this->actor.shape.rot.x = this->actor.world.rot.x; - - if (Rand_ZeroOne() < 0.03f) { - sp40.x = this->actor.world.pos.x; - sp40.y = this->actor.world.pos.y + this->actor.yDistToWater; - sp40.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp40, 20, 100, 4); - EffectSsGRipple_Spawn(globalCtx, &sp40, 40, 200, 8); - } - - if (this->unk_31A <= 0 || ((this->unk_314 & 4) && this->unk_31C <= 0) || - ((sp4E == 2 || sp4E == 3) && (this->unk_314 & 1) && D_80A7DEB8 >= 4)) { - func_80A7D1F4(this); - } else if (!(this->actor.bgCheckFlags & 0x40)) { - if (this->unk_314 & 0x10) { - func_80A7D39C(this); - } else { - func_80A7C3A0(this); - } - } -} - -void func_80A7D1F4(EnInsect* this) { - this->unk_31A = 100; - func_80A7BF58(this); - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.minVelocityY = -0.8f; - this->actor.gravity = -0.04f; - this->unk_314 &= ~0x3; - this->actionFunc = func_80A7D26C; - this->unk_314 &= ~0x100; - this->unk_314 |= 8; -} - -void func_80A7D26C(EnInsect* this, GlobalContext* globalCtx) { - this->actor.shape.rot.x -= 500; - this->actor.shape.rot.y += 200; - Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.00005f, 0.001f)); - - if (this->actor.yDistToWater > 5.0f && this->actor.yDistToWater < 30.0f && Rand_ZeroOne() < 0.3f) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); - } - - if (this->unk_31A <= 0) { - Actor_Kill(&this->actor); - } -} - -void func_80A7D39C(EnInsect* this) { - func_80A7BF58(this); - this->unk_31A = 100; - this->unk_324 = 1.5f; - this->unk_328 = Rand_ZeroOne() * (0xFFFF + 0.5f); - this->unk_316 = (Rand_ZeroOne() - 0.5f) * 1500.0f; - this->actor.world.rot.y = Rand_ZeroOne() * (0xFFFF + 0.5f); - Actor_SetScale(&this->actor, 0.003f); - this->actionFunc = func_80A7D460; - this->unk_314 |= 0x100; -} - -void func_80A7D460(EnInsect* this, GlobalContext* globalCtx) { - s32 temp_a0; - s32 sp50; - f32 phi_f0; - EnInsect* thisTemp = this; - s32 temp_a1; - f32 sp40; - f32 phi_f2; - s16 sp3A; - s16 sp38; - f32 sp34; - - sp50 = 0; - sp3A = this->actor.params & 3; - - if (this->soilActor != NULL) { - sp40 = Math3D_Vec3fDistSq(&this->actor.world.pos, &this->soilActor->actor.world.pos); - } else { - if (this->unk_314 & 0x10) { - osSyncPrintf(VT_COL(YELLOW, BLACK)); - // "warning: target Actor is NULL" - osSyncPrintf("warning:目標 Actor が NULL (%s %d)\n", "../z_en_mushi.c", 1046); - osSyncPrintf(VT_RST); - } - sp40 = 40.0f; - } - - D_80A7DEB0 += 0.99999994f / 300.0f; - if (D_80A7DEB0 > 1.0f) { - D_80A7DEB0 = 1.0f; - } - - if (D_80A7DEB0 > 0.999f) { - phi_f2 = 0.0f; - } else { - if (sp40 > 900.0f) { - phi_f2 = ((1.1f - D_80A7DEB0) * 100.0f) + 20.0f; - } else { - phi_f2 = (1.0f - D_80A7DEB0) * 10.0f; - } - } - - if (this->soilActor != NULL && Rand_ZeroOne() < 0.07f) { - this->actor.home.pos.x = (Rand_ZeroOne() - 0.5f) * phi_f2 + thisTemp->soilActor->actor.world.pos.x; - this->actor.home.pos.y = thisTemp->soilActor->actor.world.pos.y; - this->actor.home.pos.z = (Rand_ZeroOne() - 0.5f) * phi_f2 + thisTemp->soilActor->actor.world.pos.z; - } - - if (D_80A7DEB0 > 0.999f) { - this->unk_328 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - this->unk_324 = Rand_ZeroOne() * 0.6f + 0.6f; - } else if (Rand_ZeroOne() < 0.07f) { - if (this->unk_324 > 1.0f) { - this->unk_324 = 0.1f; - } else { - this->unk_324 = Rand_ZeroOne() * 0.8f + 1.0f; - } - - sp34 = 1.3f - D_80A7DEB0; - if (sp34 < 0.0f) { - sp34 = 0.0f; - } else { - if (sp34 > 1.0f) { - phi_f0 = 1.0f; - } else { - phi_f0 = sp34; - } - sp34 = phi_f0; - } - - sp38 = (Rand_ZeroOne() - 0.5f) * 65535.0f * sp34; - this->unk_328 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) + sp38; - } - - Actor_SetScale(&this->actor, CLAMP_MAX(thisTemp->actor.scale.x + 0.0008f, 0.01f)); - - if (this->actor.bgCheckFlags & 1) { - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_324, 0.1f, 0.5f, 0.0f); - Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_328, 2000); - sp50 = Math_ScaledStepToS(&this->actor.world.rot.x, 0, 2000); - this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.shape.rot.x = this->actor.world.rot.x; - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); - this->actor.speedXZ += (Rand_ZeroOne() - 0.5f) * 0.14f; - this->actor.velocity.y += Rand_ZeroOne() * 0.12f; - this->actor.world.rot.y += this->unk_316; - this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.shape.rot.x -= 2000; - } - - phi_f2 = Rand_ZeroOne() * 0.5f + this->actor.speedXZ * 1.3f; - if (phi_f2 < 0.0f) { - this->skelAnime.playSpeed = 0.0f; - } else { - if (phi_f2 > 1.9f) { - phi_f0 = 1.9f; - } else { - phi_f0 = phi_f2; - } - this->skelAnime.playSpeed = phi_f0; - } - - SkelAnime_Update(&this->skelAnime); - if (!(this->unk_314 & 0x40) && (this->unk_314 & 1) && (this->actor.bgCheckFlags & 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); - this->unk_314 |= 0x40; - } - - if (sp3A == 2 && (this->unk_314 & 0x10) && !(this->unk_314 & 0x80)) { - if (this->unk_32A >= 15) { - if (this->soilActor != NULL) { - if (!(GET_GS_FLAGS(((this->soilActor->actor.params >> 8) & 0x1F) - 1) & - (this->soilActor->actor.params & 0xFF))) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - } - this->unk_314 |= 0x80; - } else { - this->unk_32A++; - } - } - - if ((this->unk_314 & 1) && (this->actor.bgCheckFlags & 0x40)) { - func_80A7CE60(this); - } else if (this->unk_314 & 0x10) { - if (sp40 < 9.0f) { - func_80A7CBC8(this); - } else if (this->unk_31A <= 0 || this->unk_31C <= 0 || - ((this->unk_314 & 1) && (this->actor.bgCheckFlags & 1) && D_80A7DEB8 >= 4 && - (sp3A == 2 || sp3A == 3))) { - func_80A7CBC8(this); - } else { - if (sp40 < 900.0f) { - this->unk_31C++; - this->unk_314 |= 0x20; - } else { - this->unk_31A = 100; - } - } - } else if (sp50 != 0) { - func_80A7C3A0(this); - } else if ((sp3A == 2 || sp3A == 3) && (this->unk_314 & 1) && this->unk_31C <= 0 && this->unk_31A <= 0 && - this->actor.floorHeight < BGCHECK_Y_MIN + 10.0f) { - osSyncPrintf(VT_COL(YELLOW, BLACK)); - // "BG missing? To do Actor_delete" - osSyncPrintf("BG 抜け? Actor_delete します(%s %d)\n", "../z_en_mushi.c", 1197); - osSyncPrintf(VT_RST); - Actor_Kill(&this->actor); - } -} - -void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { - EnInsect* this = (EnInsect*)thisx; - s32 phi_v0; - - if (this->actor.child != NULL) { - if (this->actor.child->update == NULL) { - if (&this->actor != this->actor.child) { - this->actor.child = NULL; - } - } - } - - if (this->unk_31A > 0) { - this->unk_31A--; - } - - if (this->unk_31C > 0) { - this->unk_31C--; - } - - this->actionFunc(this, globalCtx); - - if (this->actor.update != NULL) { - Actor_MoveForward(&this->actor); - if (this->unk_314 & 0x100) { - if (this->unk_314 & 1) { - if (this->actor.bgCheckFlags & 1) { - func_80A7C058(this); - } - } else { - func_80A7C058(this); - } - } - - phi_v0 = 0; - - if (this->unk_314 & 1) { - phi_v0 = 4; - } - - if (this->unk_314 & 2) { - phi_v0 |= 1; - } - - if (phi_v0 != 0) { - phi_v0 |= 0x40; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); - } - - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - phi_v0 = this->actor.params & 3; - - if (phi_v0 == 2 || phi_v0 == 3) { - Actor_Kill(&this->actor); - } else { - func_80A7CA64(this); - } - } else if (this->actor.xzDistToPlayer < 50.0f && this->actionFunc != func_80A7CAD0) { - if (!(this->unk_314 & 0x20) && this->unk_31C < 180) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (!(this->unk_314 & 8) && D_80A7DEB4 < 4 && EnInsect_InBottleRange(this, globalCtx) && - // GI_MAX in this case allows the player to catch the actor in a bottle - func_8002F434(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f)) { - D_80A7DEB4++; - } - } - - Actor_SetFocus(&this->actor, 0.0f); - } -} - -void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnInsect* this = (EnInsect*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - Collider_UpdateSpheres(0, &this->collider); - D_80A7DEB4 = 0; -} diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.cpp b/src/overlays/actors/ovl_En_Insect/z_en_insect.cpp new file mode 100644 index 000000000..a645b49dc --- /dev/null +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.cpp @@ -0,0 +1,805 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_INSECT_Z_EN_INSECT_C +#include "actor_common.h" +#include "kaleido.h" +/* + * File: z_en_insect.c + * Overlay: ovl_En_Insect + * Description: Bugs + */ + +#include "z_en_insect.h" +#include "vt.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS 0 + +void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx); +void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx); +void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A7C3A0(EnInsect* pthis); +void func_80A7C3F4(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7C598(EnInsect* pthis); +void func_80A7C5EC(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7C818(EnInsect* pthis); +void func_80A7C86C(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7CAD0(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7CBC8(EnInsect* pthis); +void func_80A7CC3C(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7CE60(EnInsect* pthis); +void func_80A7CEC0(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7D1F4(EnInsect* pthis); +void func_80A7D26C(EnInsect* pthis, GlobalContext* globalCtx); +void func_80A7D39C(EnInsect* pthis); +void func_80A7D460(EnInsect* pthis, GlobalContext* globalCtx); + +static f32 D_80A7DEB0 = 0.0f; +static s16 D_80A7DEB4 = 0; +static s16 D_80A7DEB8 = 0; + +ActorInit En_Insect_InitVars = { + ACTOR_EN_INSECT, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnInsect), + (ActorFunc)EnInsect_Init, + (ActorFunc)EnInsect_Destroy, + (ActorFunc)EnInsect_Update, + (ActorFunc)EnInsect_Draw, +}; + +static ColliderJntSphElementInit sColliderItemInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 5 }, 100 }, + }, +}; + +static ColliderJntSphInit sColliderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sColliderItemInit, +}; + +static u16 D_80A7DF10[] = { 0, 5, 7, 7 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), +}; + +void func_80A7BE20(EnInsect* pthis) { + pthis->unk_314 = D_80A7DF10[pthis->actor.params & 3]; +} + +f32 EnInsect_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { + return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); +} + +s32 EnInsect_InBottleRange(EnInsect* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f pos; + + if (pthis->actor.xzDistToPlayer < 32.0f) { + pos.x = Math_SinS(pthis->actor.yawTowardsPlayer + 0x8000) * 16.0f + player->actor.world.pos.x; + pos.y = player->actor.world.pos.y; + pos.z = Math_CosS(pthis->actor.yawTowardsPlayer + 0x8000) * 16.0f + player->actor.world.pos.z; + + //! @bug: pthis check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have + //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's + //! world rotation. + if (EnInsect_XZDistanceSquared(&pos, &pthis->actor.world.pos) <= SQ(20.0f)) { + return true; + } + } + + return false; +} + +void func_80A7BF58(EnInsect* pthis) { + Animation_Change(&pthis->skelAnime, &gBugCrawlAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); +} + +/** + * Find the nearest soft dirt patch within 6400 units in the xz plane and the current room + * + * @return 1 if one was found, 0 otherwise + */ +s32 EnInsect_FoundNearbySoil(EnInsect* pthis, GlobalContext* globalCtx) { + Actor* currentActor; + f32 currentDistance; + f32 bestDistance; + s32 ret; + + ret = 0; + currentActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + bestDistance = 6400.0f; + pthis->soilActor = NULL; + + while (currentActor != NULL) { + if (currentActor->id == ACTOR_OBJ_MAKEKINSUTA) { + currentDistance = Math3D_Dist2DSq(pthis->actor.world.pos.x, pthis->actor.world.pos.z, + currentActor->world.pos.x, currentActor->world.pos.z); + + if (currentDistance < bestDistance && currentActor->room == pthis->actor.room) { + ret = 1; + bestDistance = currentDistance; + pthis->soilActor = (ObjMakekinsuta*)currentActor; + } + } + currentActor = currentActor->next; + } + return ret; +} + +void func_80A7C058(EnInsect* pthis) { + if (pthis->unk_31E > 0) { + pthis->unk_31E--; + return; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_WALK); + + pthis->unk_31E = 3.0f / CLAMP_MIN(pthis->skelAnime.playSpeed, 0.1f); + if (pthis->unk_31E < 2) { + pthis->unk_31E = 2; + } +} + +void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnInsect* pthis = (EnInsect*)thisx; + GlobalContext* globalCtx = globalCtx2; + f32 rand; + s16 temp_s2; + s32 count; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + func_80A7BE20(pthis); + + temp_s2 = pthis->actor.params & 3; + + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBugSkel, &gBugCrawlAnim, pthis->jointTable, pthis->morphTable, 24); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sColliderInit, &pthis->colliderItem); + + pthis->actor.colChkInfo.mass = 30; + + if (pthis->unk_314 & 1) { + pthis->actor.gravity = -0.2f; + pthis->actor.minVelocityY = -2.0f; + } + + if (pthis->unk_314 & 4) { + pthis->unk_31C = Rand_S16Offset(200, 40); + pthis->actor.flags |= ACTOR_FLAG_4; + } + + if (temp_s2 == 2 || temp_s2 == 3) { + if (EnInsect_FoundNearbySoil(pthis, globalCtx)) { + pthis->unk_314 |= 0x10; + D_80A7DEB0 = 0.0f; + } + + if (temp_s2 == 2) { + pthis->actor.world.rot.z = 0; + pthis->actor.shape.rot.z = pthis->actor.world.rot.z; + + for (count = 0; count < 2; count++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, pthis->actor.shape.rot.x, + pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 3); + } + } + + func_80A7D39C(pthis); + + D_80A7DEB8++; + } else { + rand = Rand_ZeroOne(); + + if (rand < 0.3f) { + func_80A7C3A0(pthis); + } else if (rand < 0.4f) { + func_80A7C598(pthis); + } else { + func_80A7C818(pthis); + } + } +} + +void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s16 temp_v0; + EnInsect* pthis = (EnInsect*)thisx; + + temp_v0 = pthis->actor.params & 3; + Collider_DestroyJntSph(globalCtx, &pthis->collider); + if ((temp_v0 == 2 || temp_v0 == 3) && D_80A7DEB8 > 0) { + D_80A7DEB8--; + } +} + +void func_80A7C3A0(EnInsect* pthis) { + pthis->unk_31A = Rand_S16Offset(5, 35); + func_80A7BF58(pthis); + pthis->actionFunc = func_80A7C3F4; + pthis->unk_314 |= 0x100; +} + +void func_80A7C3F4(EnInsect* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 sp2E; + f32 playSpeed; + + sp2E = pthis->actor.params & 3; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + + playSpeed = (Rand_ZeroOne() * 0.8f) + (pthis->actor.speedXZ * 1.2f); + pthis->skelAnime.playSpeed = CLAMP(playSpeed, 0.0f, 1.9f); + + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (pthis->unk_31A <= 0) { + func_80A7C598(pthis); + } + + if (((pthis->unk_314 & 4) && pthis->unk_31C <= 0) || + ((sp2E == 2 || sp2E == 3) && (pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 1) && D_80A7DEB8 >= 4)) { + func_80A7CBC8(pthis); + } else if ((pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 0x40)) { + func_80A7CE60(pthis); + } else if (pthis->actor.xzDistToPlayer < 40.0f) { + func_80A7C818(pthis); + } +} + +void func_80A7C598(EnInsect* pthis) { + pthis->unk_31A = Rand_S16Offset(10, 45); + func_80A7BF58(pthis); + pthis->actionFunc = func_80A7C5EC; + pthis->unk_314 |= 0x100; +} + +void func_80A7C5EC(EnInsect* pthis, GlobalContext* globalCtx) { + s32 pad1; + s32 pad2; + s16 yaw; + s16 sp34 = pthis->actor.params & 3; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 1.5f, 0.1f, 0.5f, 0.0f); + + if (EnInsect_XZDistanceSquared(&pthis->actor.world.pos, &pthis->actor.home.pos) > 1600.0f || (pthis->unk_31A < 4)) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, 2000); + } else if (pthis->actor.child != NULL && &pthis->actor != pthis->actor.child) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.child->world.pos); + Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, 2000); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->skelAnime.playSpeed = CLAMP(pthis->actor.speedXZ * 1.4f, 0.7f, 1.9f); + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_31A <= 0) { + func_80A7C3A0(pthis); + } + + if (((pthis->unk_314 & 4) && pthis->unk_31C <= 0) || + ((sp34 == 2 || sp34 == 3) && (pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 1) && D_80A7DEB8 >= 4)) { + func_80A7CBC8(pthis); + } else if ((pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 0x40)) { + func_80A7CE60(pthis); + } else if (pthis->actor.xzDistToPlayer < 40.0f) { + func_80A7C818(pthis); + } +} + +void func_80A7C818(EnInsect* pthis) { + pthis->unk_31A = Rand_S16Offset(10, 40); + func_80A7BF58(pthis); + pthis->actionFunc = func_80A7C86C; + pthis->unk_314 |= 0x100; +} + +void func_80A7C86C(EnInsect* pthis, GlobalContext* globalCtx) { + s32 pad1; + s32 pad2; + s16 pad3; + s16 frames; + s16 yaw; + s16 sp38 = pthis->actor.xzDistToPlayer < 40.0f; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + + if (EnInsect_XZDistanceSquared(&pthis->actor.world.pos, &pthis->actor.home.pos) > 25600.0f || pthis->unk_31A < 4) { + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, 2000); + } else if (sp38 != 0) { + frames = globalCtx->state.frames; + yaw = pthis->actor.yawTowardsPlayer + 0x8000; + + if (frames & 0x10) { + if (frames & 0x20) { + yaw += 0x2000; + } + } else { + if (frames & 0x20) { + yaw -= 0x2000; + } + } + if (globalCtx) {} // Must be 'globalCtx' + Math_ScaledStepToS(&pthis->actor.world.rot.y, yaw, 2000); + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->skelAnime.playSpeed = CLAMP(pthis->actor.speedXZ * 1.6f, 0.8f, 1.9f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_31A <= 0 || !sp38) { + func_80A7C3A0(pthis); + } else if ((pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 0x40)) { + func_80A7CE60(pthis); + } +} + +void func_80A7CA64(EnInsect* pthis) { + pthis->unk_31A = 200; + + Actor_SetScale(&pthis->actor, 0.001f); + + pthis->actor.draw = NULL; + pthis->actor.speedXZ = 0.0f; + + func_80A7BF58(pthis); + + pthis->skelAnime.playSpeed = 0.3f; + pthis->actionFunc = func_80A7CAD0; + pthis->unk_314 &= ~0x100; +} + +void func_80A7CAD0(EnInsect* pthis, GlobalContext* globalCtx) { + if (pthis->unk_31A == 20 && !(pthis->unk_314 & 4)) { + pthis->actor.draw = EnInsect_Draw; + } else if (pthis->unk_31A == 0) { + if (pthis->unk_314 & 4) { + Actor_Kill(&pthis->actor); + } else { + Actor_SetScale(&pthis->actor, 0.01f); + func_80A7C3A0(pthis); + } + } else if (pthis->unk_31A < 20) { + Actor_SetScale(&pthis->actor, CLAMP_MAX(pthis->actor.scale.x + 0.001f, 0.01f)); + SkelAnime_Update(&pthis->skelAnime); + } +} + +void func_80A7CBC8(EnInsect* pthis) { + pthis->unk_31A = 60; + func_80A7BF58(pthis); + pthis->skelAnime.playSpeed = 1.9f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_SINK); + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); + pthis->actionFunc = func_80A7CC3C; + pthis->unk_314 &= ~0x100; + pthis->unk_314 |= 0x8; +} + +void func_80A7CC3C(EnInsect* pthis, GlobalContext* globalCtx) { + static Vec3f accel = { 0.0f, 0.0f, 0.0f }; + static Vec3f unused = { 0.0f, 0.0f, 0.0f }; + s32 pad[2]; + Vec3f velocity; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + Math_StepToS(&pthis->actor.shape.rot.x, 10922, 352); + + Actor_SetScale(&pthis->actor, CLAMP_MIN(pthis->actor.scale.x - 0.0002f, 0.001f)); + + pthis->actor.shape.yOffset -= 0.8f; + pthis->actor.world.pos.x = Rand_ZeroOne() + pthis->actor.home.pos.x - 0.5f; + pthis->actor.world.pos.z = Rand_ZeroOne() + pthis->actor.home.pos.z - 0.5f; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_31A > 20 && Rand_ZeroOne() < 0.1f) { + velocity.x = Math_SinS(pthis->actor.shape.rot.y) * -0.6f; + velocity.y = Math_SinS(pthis->actor.shape.rot.x) * 0.6f; + velocity.z = Math_CosS(pthis->actor.shape.rot.y) * -0.6f; + func_800286CC(globalCtx, &pthis->actor.world.pos, &velocity, &accel, Rand_ZeroOne() * 5.0f + 8.0f, + Rand_ZeroOne() * 5.0f + 8.0f); + } + + if (pthis->unk_31A <= 0) { + if ((pthis->unk_314 & 0x10) && pthis->soilActor != NULL && + Math3D_Vec3fDistSq(&pthis->soilActor->actor.world.pos, &pthis->actor.world.pos) < 64.0f) { + pthis->soilActor->unk_152 = 1; + } + Actor_Kill(&pthis->actor); + } +} + +void func_80A7CE60(EnInsect* pthis) { + pthis->unk_31A = Rand_S16Offset(120, 50); + func_80A7BF58(pthis); + pthis->unk_316 = pthis->unk_318 = 0; + pthis->actionFunc = func_80A7CEC0; + pthis->unk_314 &= ~0x100; +} + +void func_80A7CEC0(EnInsect* pthis, GlobalContext* globalCtx) { + f32 temp_f0; + s16 temp_v1; + s16 pad; + s16 sp4E; + Vec3f sp40; + s32 phi_v0; + s32 phi_v0_2; + + sp4E = pthis->actor.params & 3; + + if (pthis->unk_31A >= 81) { + Math_StepToF(&pthis->actor.speedXZ, 0.6f, 0.08f); + } else { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.02f); + } + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y += pthis->actor.yDistToWater; + pthis->skelAnime.playSpeed = CLAMP(pthis->unk_31A * 0.018f, 0.1f, 1.9f); + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_31A >= 81) { + pthis->unk_316 += Rand_S16Offset(-50, 100); + pthis->unk_318 += Rand_S16Offset(-300, 600); + } + + temp_v1 = pthis->skelAnime.playSpeed * 200.0f; + + if (pthis->unk_316 < -temp_v1) { + pthis->unk_316 = -temp_v1; + } else { + if (temp_v1 < pthis->unk_316) { + phi_v0 = temp_v1; + } else { + phi_v0 = pthis->unk_316; + } + pthis->unk_316 = phi_v0; + } + pthis->actor.world.rot.y += pthis->unk_316; + + temp_v1 = pthis->skelAnime.playSpeed * 1000.0f; + if (pthis->unk_318 < -temp_v1) { + pthis->unk_318 = -temp_v1; + } else { + if (temp_v1 < pthis->unk_318) { + phi_v0_2 = temp_v1; + } else { + phi_v0_2 = pthis->unk_318; + } + pthis->unk_318 = phi_v0_2; + } + pthis->actor.shape.rot.y += pthis->unk_318; + + Math_ScaledStepToS(&pthis->actor.world.rot.x, 0, 3000); + pthis->actor.shape.rot.x = pthis->actor.world.rot.x; + + if (Rand_ZeroOne() < 0.03f) { + sp40.x = pthis->actor.world.pos.x; + sp40.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + sp40.z = pthis->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp40, 20, 100, 4); + EffectSsGRipple_Spawn(globalCtx, &sp40, 40, 200, 8); + } + + if (pthis->unk_31A <= 0 || ((pthis->unk_314 & 4) && pthis->unk_31C <= 0) || + ((sp4E == 2 || sp4E == 3) && (pthis->unk_314 & 1) && D_80A7DEB8 >= 4)) { + func_80A7D1F4(pthis); + } else if (!(pthis->actor.bgCheckFlags & 0x40)) { + if (pthis->unk_314 & 0x10) { + func_80A7D39C(pthis); + } else { + func_80A7C3A0(pthis); + } + } +} + +void func_80A7D1F4(EnInsect* pthis) { + pthis->unk_31A = 100; + func_80A7BF58(pthis); + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.minVelocityY = -0.8f; + pthis->actor.gravity = -0.04f; + pthis->unk_314 &= ~0x3; + pthis->actionFunc = func_80A7D26C; + pthis->unk_314 &= ~0x100; + pthis->unk_314 |= 8; +} + +void func_80A7D26C(EnInsect* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.x -= 500; + pthis->actor.shape.rot.y += 200; + Actor_SetScale(&pthis->actor, CLAMP_MIN(pthis->actor.scale.x - 0.00005f, 0.001f)); + + if (pthis->actor.yDistToWater > 5.0f && pthis->actor.yDistToWater < 30.0f && Rand_ZeroOne() < 0.3f) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); + } + + if (pthis->unk_31A <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_80A7D39C(EnInsect* pthis) { + func_80A7BF58(pthis); + pthis->unk_31A = 100; + pthis->unk_324 = 1.5f; + pthis->unk_328 = Rand_ZeroOne() * (0xFFFF + 0.5f); + pthis->unk_316 = (Rand_ZeroOne() - 0.5f) * 1500.0f; + pthis->actor.world.rot.y = Rand_ZeroOne() * (0xFFFF + 0.5f); + Actor_SetScale(&pthis->actor, 0.003f); + pthis->actionFunc = func_80A7D460; + pthis->unk_314 |= 0x100; +} + +void func_80A7D460(EnInsect* pthis, GlobalContext* globalCtx) { + s32 temp_a0; + s32 sp50; + f32 phi_f0; + EnInsect* thisTemp = pthis; + s32 temp_a1; + f32 sp40; + f32 phi_f2; + s16 sp3A; + s16 sp38; + f32 sp34; + + sp50 = 0; + sp3A = pthis->actor.params & 3; + + if (pthis->soilActor != NULL) { + sp40 = Math3D_Vec3fDistSq(&pthis->actor.world.pos, &pthis->soilActor->actor.world.pos); + } else { + if (pthis->unk_314 & 0x10) { + osSyncPrintf(VT_COL(YELLOW, BLACK)); + // "warning: target Actor is NULL" + osSyncPrintf("warning:目標 Actor が NULL (%s %d)\n", "../z_en_mushi.c", 1046); + osSyncPrintf(VT_RST); + } + sp40 = 40.0f; + } + + D_80A7DEB0 += 0.99999994f / 300.0f; + if (D_80A7DEB0 > 1.0f) { + D_80A7DEB0 = 1.0f; + } + + if (D_80A7DEB0 > 0.999f) { + phi_f2 = 0.0f; + } else { + if (sp40 > 900.0f) { + phi_f2 = ((1.1f - D_80A7DEB0) * 100.0f) + 20.0f; + } else { + phi_f2 = (1.0f - D_80A7DEB0) * 10.0f; + } + } + + if (pthis->soilActor != NULL && Rand_ZeroOne() < 0.07f) { + pthis->actor.home.pos.x = (Rand_ZeroOne() - 0.5f) * phi_f2 + thisTemp->soilActor->actor.world.pos.x; + pthis->actor.home.pos.y = thisTemp->soilActor->actor.world.pos.y; + pthis->actor.home.pos.z = (Rand_ZeroOne() - 0.5f) * phi_f2 + thisTemp->soilActor->actor.world.pos.z; + } + + if (D_80A7DEB0 > 0.999f) { + pthis->unk_328 = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->unk_324 = Rand_ZeroOne() * 0.6f + 0.6f; + } else if (Rand_ZeroOne() < 0.07f) { + if (pthis->unk_324 > 1.0f) { + pthis->unk_324 = 0.1f; + } else { + pthis->unk_324 = Rand_ZeroOne() * 0.8f + 1.0f; + } + + sp34 = 1.3f - D_80A7DEB0; + if (sp34 < 0.0f) { + sp34 = 0.0f; + } else { + if (sp34 > 1.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = sp34; + } + sp34 = phi_f0; + } + + sp38 = (Rand_ZeroOne() - 0.5f) * 65535.0f * sp34; + pthis->unk_328 = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos) + sp38; + } + + Actor_SetScale(&pthis->actor, CLAMP_MAX(thisTemp->actor.scale.x + 0.0008f, 0.01f)); + + if (pthis->actor.bgCheckFlags & 1) { + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->unk_324, 0.1f, 0.5f, 0.0f); + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->unk_328, 2000); + sp50 = Math_ScaledStepToS(&pthis->actor.world.rot.x, 0, 2000); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->actor.shape.rot.x = pthis->actor.world.rot.x; + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + pthis->actor.speedXZ += (Rand_ZeroOne() - 0.5f) * 0.14f; + pthis->actor.velocity.y += Rand_ZeroOne() * 0.12f; + pthis->actor.world.rot.y += pthis->unk_316; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + pthis->actor.shape.rot.x -= 2000; + } + + phi_f2 = Rand_ZeroOne() * 0.5f + pthis->actor.speedXZ * 1.3f; + if (phi_f2 < 0.0f) { + pthis->skelAnime.playSpeed = 0.0f; + } else { + if (phi_f2 > 1.9f) { + phi_f0 = 1.9f; + } else { + phi_f0 = phi_f2; + } + pthis->skelAnime.playSpeed = phi_f0; + } + + SkelAnime_Update(&pthis->skelAnime); + if (!(pthis->unk_314 & 0x40) && (pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 1)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MUSI_LAND); + pthis->unk_314 |= 0x40; + } + + if (sp3A == 2 && (pthis->unk_314 & 0x10) && !(pthis->unk_314 & 0x80)) { + if (pthis->unk_32A >= 15) { + if (pthis->soilActor != NULL) { + if (!(GET_GS_FLAGS(((pthis->soilActor->actor.params >> 8) & 0x1F) - 1) & + (pthis->soilActor->actor.params & 0xFF))) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + } + pthis->unk_314 |= 0x80; + } else { + pthis->unk_32A++; + } + } + + if ((pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 0x40)) { + func_80A7CE60(pthis); + } else if (pthis->unk_314 & 0x10) { + if (sp40 < 9.0f) { + func_80A7CBC8(pthis); + } else if (pthis->unk_31A <= 0 || pthis->unk_31C <= 0 || + ((pthis->unk_314 & 1) && (pthis->actor.bgCheckFlags & 1) && D_80A7DEB8 >= 4 && + (sp3A == 2 || sp3A == 3))) { + func_80A7CBC8(pthis); + } else { + if (sp40 < 900.0f) { + pthis->unk_31C++; + pthis->unk_314 |= 0x20; + } else { + pthis->unk_31A = 100; + } + } + } else if (sp50 != 0) { + func_80A7C3A0(pthis); + } else if ((sp3A == 2 || sp3A == 3) && (pthis->unk_314 & 1) && pthis->unk_31C <= 0 && pthis->unk_31A <= 0 && + pthis->actor.floorHeight < BGCHECK_Y_MIN + 10.0f) { + osSyncPrintf(VT_COL(YELLOW, BLACK)); + // "BG missing? To do Actor_delete" + osSyncPrintf("BG 抜け? Actor_delete します(%s %d)\n", "../z_en_mushi.c", 1197); + osSyncPrintf(VT_RST); + Actor_Kill(&pthis->actor); + } +} + +void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* pthis = (EnInsect*)thisx; + s32 phi_v0; + + if (pthis->actor.child != NULL) { + if (pthis->actor.child->update == NULL) { + if (&pthis->actor != pthis->actor.child) { + pthis->actor.child = NULL; + } + } + } + + if (pthis->unk_31A > 0) { + pthis->unk_31A--; + } + + if (pthis->unk_31C > 0) { + pthis->unk_31C--; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.update != NULL) { + Actor_MoveForward(&pthis->actor); + if (pthis->unk_314 & 0x100) { + if (pthis->unk_314 & 1) { + if (pthis->actor.bgCheckFlags & 1) { + func_80A7C058(pthis); + } + } else { + func_80A7C058(pthis); + } + } + + phi_v0 = 0; + + if (pthis->unk_314 & 1) { + phi_v0 = 4; + } + + if (pthis->unk_314 & 2) { + phi_v0 |= 1; + } + + if (phi_v0 != 0) { + phi_v0 |= 0x40; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 8.0f, 5.0f, 0.0f, phi_v0); + } + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + phi_v0 = pthis->actor.params & 3; + + if (phi_v0 == 2 || phi_v0 == 3) { + Actor_Kill(&pthis->actor); + } else { + func_80A7CA64(pthis); + } + } else if (pthis->actor.xzDistToPlayer < 50.0f && pthis->actionFunc != func_80A7CAD0) { + if (!(pthis->unk_314 & 0x20) && pthis->unk_31C < 180) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (!(pthis->unk_314 & 8) && D_80A7DEB4 < 4 && EnInsect_InBottleRange(pthis, globalCtx) && + // GI_MAX in pthis case allows the player to catch the actor in a bottle + func_8002F434(&pthis->actor, globalCtx, GI_MAX, 60.0f, 30.0f)) { + D_80A7DEB4++; + } + } + + Actor_SetFocus(&pthis->actor, 0.0f); + } +} + +void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* pthis = (EnInsect*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, NULL); + Collider_UpdateSpheres(0, &pthis->collider); + D_80A7DEB4 = 0; +} diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.cpp similarity index 51% rename from src/overlays/actors/ovl_En_Ishi/z_en_ishi.c rename to src/overlays/actors/ovl_En_Ishi/z_en_ishi.cpp index d60088e7e..daacffe8e 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.cpp @@ -32,21 +32,21 @@ void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx); void EnIshi_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnIshi_SetupWait(EnIshi* this); -void EnIshi_Wait(EnIshi* this, GlobalContext* globalCtx); -void EnIshi_SetupLiftedUp(EnIshi* this); -void EnIshi_LiftedUp(EnIshi* this, GlobalContext* globalCtx); -void EnIshi_SetupFly(EnIshi* this); -void EnIshi_Fly(EnIshi* this, GlobalContext* globalCtx); -void EnIshi_SpawnFragmentsSmall(EnIshi* this, GlobalContext* globalCtx); -void EnIshi_SpawnFragmentsLarge(EnIshi* this, GlobalContext* globalCtx); -void EnIshi_SpawnDustSmall(EnIshi* this, GlobalContext* globalCtx); -void EnIshi_SpawnDustLarge(EnIshi* this, GlobalContext* globalCtx); +void EnIshi_SetupWait(EnIshi* pthis); +void EnIshi_Wait(EnIshi* pthis, GlobalContext* globalCtx); +void EnIshi_SetupLiftedUp(EnIshi* pthis); +void EnIshi_LiftedUp(EnIshi* pthis, GlobalContext* globalCtx); +void EnIshi_SetupFly(EnIshi* pthis); +void EnIshi_Fly(EnIshi* pthis, GlobalContext* globalCtx); +void EnIshi_SpawnFragmentsSmall(EnIshi* pthis, GlobalContext* globalCtx); +void EnIshi_SpawnFragmentsLarge(EnIshi* pthis, GlobalContext* globalCtx); +void EnIshi_SpawnDustSmall(EnIshi* pthis, GlobalContext* globalCtx); +void EnIshi_SpawnDustLarge(EnIshi* pthis, GlobalContext* globalCtx); static s16 sRotSpeedX = 0; static s16 sRotSpeedY = 0; -const ActorInit En_Ishi_InitVars = { +ActorInit En_Ishi_InitVars = { ACTOR_EN_ISHI, ACTORCAT_PROP, FLAGS, @@ -117,26 +117,26 @@ static ColliderCylinderInit sCylinderInits[] = { static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; void EnIshi_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - EnIshi* this = (EnIshi*)thisx; + EnIshi* pthis = (EnIshi*)thisx; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInits[this->actor.params & 1]); - Collider_UpdateCylinder(&this->actor, &this->collider); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInits[pthis->actor.params & 1]); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); } -s32 EnIshi_SnapToFloor(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { +s32 EnIshi_SnapToFloor(EnIshi* pthis, GlobalContext* globalCtx, f32 arg2) { CollisionPoly* poly; Vec3f pos; s32 bgId; f32 floorY; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 30.0f; - pos.z = this->actor.world.pos.z; - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 30.0f; + pos.z = pthis->actor.world.pos.z; + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &poly, &bgId, &pthis->actor, &pos); if (floorY > BGCHECK_Y_MIN) { - this->actor.world.pos.y = floorY + arg2; - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + pthis->actor.world.pos.y = floorY + arg2; + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); return true; } else { osSyncPrintf(VT_COL(YELLOW, BLACK)); @@ -147,7 +147,7 @@ s32 EnIshi_SnapToFloor(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { } } -void EnIshi_SpawnFragmentsSmall(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_SpawnFragmentsSmall(EnIshi* pthis, GlobalContext* globalCtx) { static s16 scales[] = { 16, 13, 11, 9, 7, 5 }; s32 pad; Vec3f velocity; @@ -156,15 +156,15 @@ void EnIshi_SpawnFragmentsSmall(EnIshi* this, GlobalContext* globalCtx) { s32 i; for (i = 0; i < ARRAY_COUNT(scales); i++) { - pos.x = this->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * 8.0f; - pos.y = this->actor.world.pos.y + (Rand_ZeroOne() * 5.0f) + 5.0f; - pos.z = this->actor.world.pos.z + (Rand_ZeroOne() - 0.5f) * 8.0f; - Math_Vec3f_Copy(&velocity, &this->actor.velocity); - if (this->actor.bgCheckFlags & 1) { + pos.x = pthis->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * 8.0f; + pos.y = pthis->actor.world.pos.y + (Rand_ZeroOne() * 5.0f) + 5.0f; + pos.z = pthis->actor.world.pos.z + (Rand_ZeroOne() - 0.5f) * 8.0f; + Math_Vec3f_Copy(&velocity, &pthis->actor.velocity); + if (pthis->actor.bgCheckFlags & 1) { velocity.x *= 0.8f; velocity.y *= -0.8f; velocity.z *= 0.8f; - } else if (this->actor.bgCheckFlags & 8) { + } else if (pthis->actor.bgCheckFlags & 8) { velocity.x *= -0.8f; velocity.y *= 0.8f; velocity.z *= -0.8f; @@ -182,9 +182,9 @@ void EnIshi_SpawnFragmentsSmall(EnIshi* this, GlobalContext* globalCtx) { } } -void EnIshi_SpawnFragmentsLarge(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_SpawnFragmentsLarge(EnIshi* pthis, GlobalContext* globalCtx) { static s16 scales[] = { 145, 135, 120, 100, 70, 50, 45, 40, 35 }; - Actor* thisx = &this->actor; + Actor* thisx = &pthis->actor; Vec3f velocity; Vec3f pos; s16 angle = 0x1000; @@ -196,9 +196,9 @@ void EnIshi_SpawnFragmentsLarge(EnIshi* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(scales); i++) { angle += 0x4E20; rand = Rand_ZeroOne() * 10.0f; - pos.x = this->actor.world.pos.x + (Math_SinS(angle) * rand); - pos.y = this->actor.world.pos.y + (Rand_ZeroOne() * 40.0f) + 5.0f; - pos.z = this->actor.world.pos.z + (Math_CosS(angle) * rand); + pos.x = pthis->actor.world.pos.x + (Math_SinS(angle) * rand); + pos.y = pthis->actor.world.pos.y + (Rand_ZeroOne() * 40.0f) + 5.0f; + pos.z = pthis->actor.world.pos.z + (Math_CosS(angle) * rand); Math_Vec3f_Copy(&velocity, &thisx->velocity); if (thisx->bgCheckFlags & 1) { velocity.x *= 0.9f; @@ -223,62 +223,62 @@ void EnIshi_SpawnFragmentsLarge(EnIshi* this, GlobalContext* globalCtx) { phi_v0 = 69; phi_v1 = -320; } - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, scales[i], 5, + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pthis->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, scales[i], 5, 2, 70, KAKERA_COLOR_WHITE, OBJECT_GAMEPLAY_FIELD_KEEP, gSilverRockFragmentsDL); } } -void EnIshi_SpawnDustSmall(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_SpawnDustSmall(EnIshi* pthis, GlobalContext* globalCtx) { Vec3f pos; - Math_Vec3f_Copy(&pos, &this->actor.world.pos); - if (this->actor.bgCheckFlags & 1) { - pos.x += 2.0f * this->actor.velocity.x; - pos.y -= 2.0f * this->actor.velocity.y; - pos.z += 2.0f * this->actor.velocity.z; - } else if (this->actor.bgCheckFlags & 8) { - pos.x -= 2.0f * this->actor.velocity.x; - pos.y += 2.0f * this->actor.velocity.y; - pos.z -= 2.0f * this->actor.velocity.z; + Math_Vec3f_Copy(&pos, &pthis->actor.world.pos); + if (pthis->actor.bgCheckFlags & 1) { + pos.x += 2.0f * pthis->actor.velocity.x; + pos.y -= 2.0f * pthis->actor.velocity.y; + pos.z += 2.0f * pthis->actor.velocity.z; + } else if (pthis->actor.bgCheckFlags & 8) { + pos.x -= 2.0f * pthis->actor.velocity.x; + pos.y += 2.0f * pthis->actor.velocity.y; + pos.z -= 2.0f * pthis->actor.velocity.z; } func_80033480(globalCtx, &pos, 60.0f, 3, 0x50, 0x3C, 1); } -void EnIshi_SpawnDustLarge(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_SpawnDustLarge(EnIshi* pthis, GlobalContext* globalCtx) { Vec3f pos; - Math_Vec3f_Copy(&pos, &this->actor.world.pos); - if (this->actor.bgCheckFlags & 1) { - pos.x += 2.0f * this->actor.velocity.x; - pos.y -= 2.0f * this->actor.velocity.y; - pos.z += 2.0f * this->actor.velocity.z; - } else if (this->actor.bgCheckFlags & 8) { - pos.x -= 2.0f * this->actor.velocity.x; - pos.y += 2.0f * this->actor.velocity.y; - pos.z -= 2.0f * this->actor.velocity.z; + Math_Vec3f_Copy(&pos, &pthis->actor.world.pos); + if (pthis->actor.bgCheckFlags & 1) { + pos.x += 2.0f * pthis->actor.velocity.x; + pos.y -= 2.0f * pthis->actor.velocity.y; + pos.z += 2.0f * pthis->actor.velocity.z; + } else if (pthis->actor.bgCheckFlags & 8) { + pos.x -= 2.0f * pthis->actor.velocity.x; + pos.y += 2.0f * pthis->actor.velocity.y; + pos.z -= 2.0f * pthis->actor.velocity.z; } func_80033480(globalCtx, &pos, 140.0f, 0xA, 0xB4, 0x5A, 1); } -void EnIshi_DropCollectible(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_DropCollectible(EnIshi* pthis, GlobalContext* globalCtx) { s16 dropParams; - if ((this->actor.params & 1) == ROCK_SMALL) { - dropParams = (this->actor.params >> 8) & 0xF; + if ((pthis->actor.params & 1) == ROCK_SMALL) { + dropParams = (pthis->actor.params >> 8) & 0xF; if (dropParams >= 0xD) { dropParams = 0; } - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, dropParams << 4); + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, dropParams << 4); } } -void EnIshi_Fall(EnIshi* this) { - this->actor.velocity.y += this->actor.gravity; +void EnIshi_Fall(EnIshi* pthis) { + pthis->actor.velocity.y += pthis->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; } } @@ -289,12 +289,12 @@ void func_80A7ED94(Vec3f* arg0, f32 arg1) { arg0->z -= arg0->z * arg1; } -void EnIshi_SpawnBugs(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_SpawnBugs(EnIshi* pthis, GlobalContext* globalCtx) { s32 i; for (i = 0; i < 3; i++) { - Actor* bug = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, Rand_ZeroOne() * 0xFFFF, 0, 1); + Actor* bug = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, Rand_ZeroOne() * 0xFFFF, 0, 1); if (bug == NULL) { break; @@ -320,142 +320,142 @@ static InitChainEntry sInitChains[][5] = { }; void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { - EnIshi* this = (EnIshi*)thisx; - s16 type = this->actor.params & 1; + EnIshi* pthis = (EnIshi*)thisx; + s16 type = pthis->actor.params & 1; - Actor_ProcessInitChain(&this->actor, sInitChains[type]); + Actor_ProcessInitChain(&pthis->actor, sInitChains[type]); if (globalCtx->csCtx.state != CS_STATE_IDLE) { - this->actor.uncullZoneForward += 1000.0f; + pthis->actor.uncullZoneForward += 1000.0f; } - if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = Rand_ZeroFloat(0x10000); + if (pthis->actor.shape.rot.y == 0) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = Rand_ZeroFloat(0x10000); } - Actor_SetScale(&this->actor, sRockScales[type]); - EnIshi_InitCollider(&this->actor, globalCtx); + Actor_SetScale(&pthis->actor, sRockScales[type]); + EnIshi_InitCollider(&pthis->actor, globalCtx); if ((type == ROCK_LARGE) && - Flags_GetSwitch(globalCtx, ((this->actor.params >> 0xA) & 0x3C) | ((this->actor.params >> 6) & 3))) { - Actor_Kill(&this->actor); + Flags_GetSwitch(globalCtx, ((pthis->actor.params >> 0xA) & 0x3C) | ((pthis->actor.params >> 6) & 3))) { + Actor_Kill(&pthis->actor); return; } - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - this->actor.shape.yOffset = D_80A7FA20[type]; - if (!((this->actor.params >> 5) & 1) && !EnIshi_SnapToFloor(this, globalCtx, 0.0f)) { - Actor_Kill(&this->actor); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + pthis->actor.shape.yOffset = D_80A7FA20[type]; + if (!((pthis->actor.params >> 5) & 1) && !EnIshi_SnapToFloor(pthis, globalCtx, 0.0f)) { + Actor_Kill(&pthis->actor); return; } - EnIshi_SetupWait(this); + EnIshi_SetupWait(pthis); } void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnIshi* this = (EnIshi*)thisx; + EnIshi* pthis = (EnIshi*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void EnIshi_SetupWait(EnIshi* this) { - this->actionFunc = EnIshi_Wait; +void EnIshi_SetupWait(EnIshi* pthis) { + pthis->actionFunc = EnIshi_Wait; } -void EnIshi_Wait(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_Wait(EnIshi* pthis, GlobalContext* globalCtx) { static u16 liftSounds[] = { NA_SE_PL_PULL_UP_ROCK, NA_SE_PL_PULL_UP_BIGROCK }; s32 pad; - s16 type = this->actor.params & 1; + s16 type = pthis->actor.params & 1; - if (Actor_HasParent(&this->actor, globalCtx)) { - EnIshi_SetupLiftedUp(this); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, liftSounds[type]); - if ((this->actor.params >> 4) & 1) { - EnIshi_SpawnBugs(this, globalCtx); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + EnIshi_SetupLiftedUp(pthis); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, liftSounds[type]); + if ((pthis->actor.params >> 4) & 1) { + EnIshi_SpawnBugs(pthis, globalCtx); } - } else if ((this->collider.base.acFlags & AC_HIT) && (type == ROCK_SMALL) && - this->collider.info.acHitInfo->toucher.dmgFlags & 0x40000048) { - EnIshi_DropCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, sBreakSoundDurations[type], sBreakSounds[type]); - sFragmentSpawnFuncs[type](this, globalCtx); - sDustSpawnFuncs[type](this, globalCtx); - Actor_Kill(&this->actor); - } else if (this->actor.xzDistToPlayer < 600.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - this->collider.base.acFlags &= ~AC_HIT; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer < 400.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer < 90.0f) { + } else if ((pthis->collider.base.acFlags & AC_HIT) && (type == ROCK_SMALL) && + pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x40000048) { + EnIshi_DropCollectible(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, sBreakSoundDurations[type], sBreakSounds[type]); + sFragmentSpawnFuncs[type](pthis, globalCtx); + sDustSpawnFuncs[type](pthis, globalCtx); + Actor_Kill(&pthis->actor); + } else if (pthis->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actor.xzDistToPlayer < 90.0f) { // GI_NONE in these cases allows the player to lift the actor if (type == ROCK_LARGE) { - func_8002F434(&this->actor, globalCtx, GI_NONE, 80.0f, 20.0f); + func_8002F434(&pthis->actor, globalCtx, GI_NONE, 80.0f, 20.0f); } else { - func_8002F434(&this->actor, globalCtx, GI_NONE, 50.0f, 10.0f); + func_8002F434(&pthis->actor, globalCtx, GI_NONE, 50.0f, 10.0f); } } } } } -void EnIshi_SetupLiftedUp(EnIshi* this) { - this->actionFunc = EnIshi_LiftedUp; - this->actor.room = -1; - this->actor.flags |= ACTOR_FLAG_4; +void EnIshi_SetupLiftedUp(EnIshi* pthis) { + pthis->actionFunc = EnIshi_LiftedUp; + pthis->actor.room = -1; + pthis->actor.flags |= ACTOR_FLAG_4; } -void EnIshi_LiftedUp(EnIshi* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.curRoom.num; - if ((this->actor.params & 1) == ROCK_LARGE) { - Flags_SetSwitch(globalCtx, ((this->actor.params >> 0xA) & 0x3C) | ((this->actor.params >> 6) & 3)); +void EnIshi_LiftedUp(EnIshi* pthis, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + pthis->actor.room = globalCtx->roomCtx.curRoom.num; + if ((pthis->actor.params & 1) == ROCK_LARGE) { + Flags_SetSwitch(globalCtx, ((pthis->actor.params >> 0xA) & 0x3C) | ((pthis->actor.params >> 6) & 3)); } - EnIshi_SetupFly(this); - EnIshi_Fall(this); - func_80A7ED94(&this->actor.velocity, D_80A7FA28[this->actor.params & 1]); - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + EnIshi_SetupFly(pthis); + EnIshi_Fall(pthis); + func_80A7ED94(&pthis->actor.velocity, D_80A7FA28[pthis->actor.params & 1]); + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.5f, 35.0f, 0.0f, 0xC5); } } -void EnIshi_SetupFly(EnIshi* this) { - this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - if ((this->actor.params & 1) == ROCK_SMALL) { +void EnIshi_SetupFly(EnIshi* pthis) { + pthis->actor.velocity.x = Math_SinS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.velocity.z = Math_CosS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + if ((pthis->actor.params & 1) == ROCK_SMALL) { sRotSpeedX = (Rand_ZeroOne() - 0.5f) * 16000.0f; sRotSpeedY = (Rand_ZeroOne() - 0.5f) * 2400.0f; } else { sRotSpeedX = (Rand_ZeroOne() - 0.5f) * 8000.0f; sRotSpeedY = (Rand_ZeroOne() - 0.5f) * 1600.0f; } - this->actor.colChkInfo.mass = 240; - this->actionFunc = EnIshi_Fly; + pthis->actor.colChkInfo.mass = 240; + pthis->actionFunc = EnIshi_Fly; } -void EnIshi_Fly(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_Fly(EnIshi* pthis, GlobalContext* globalCtx) { s32 pad; - s16 type = this->actor.params & 1; + s16 type = pthis->actor.params & 1; s32 pad2; s32 quakeIdx; Vec3f contactPos; - if (this->actor.bgCheckFlags & 9) { - EnIshi_DropCollectible(this, globalCtx); - sFragmentSpawnFuncs[type](this, globalCtx); - if (!(this->actor.bgCheckFlags & 0x20)) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, sBreakSoundDurations[type], + if (pthis->actor.bgCheckFlags & 9) { + EnIshi_DropCollectible(pthis, globalCtx); + sFragmentSpawnFuncs[type](pthis, globalCtx); + if (!(pthis->actor.bgCheckFlags & 0x20)) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, sBreakSoundDurations[type], sBreakSounds[type]); - sDustSpawnFuncs[type](this, globalCtx); + sDustSpawnFuncs[type](pthis, globalCtx); } if (type == ROCK_LARGE) { quakeIdx = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quakeIdx, -0x3CB0); Quake_SetQuakeValues(quakeIdx, 3, 0, 0, 0); Quake_SetCountdown(quakeIdx, 7); - func_800AA000(this->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); + func_800AA000(pthis->actor.xyzDistToPlayerSq, 0xFF, 0x14, 0x96); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->actor.bgCheckFlags & 0x40) { - contactPos.x = this->actor.world.pos.x; - contactPos.y = this->actor.world.pos.y + this->actor.yDistToWater; - contactPos.z = this->actor.world.pos.z; + if (pthis->actor.bgCheckFlags & 0x40) { + contactPos.x = pthis->actor.world.pos.x; + contactPos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + contactPos.z = pthis->actor.world.pos.z; EffectSsGSplash_Spawn(globalCtx, &contactPos, 0, 0, 0, 350); if (type == ROCK_SMALL) { EffectSsGRipple_Spawn(globalCtx, &contactPos, 150, 650, 0); @@ -466,34 +466,34 @@ void EnIshi_Fly(EnIshi* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &contactPos, 500, 900, 4); EffectSsGRipple_Spawn(globalCtx, &contactPos, 500, 1300, 8); } - this->actor.minVelocityY = -6.0f; + pthis->actor.minVelocityY = -6.0f; sRotSpeedX >>= 2; sRotSpeedY >>= 2; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); - this->actor.bgCheckFlags &= ~0x40; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + pthis->actor.bgCheckFlags &= ~0x40; } - Math_StepToF(&this->actor.shape.yOffset, 0.0f, 2.0f); - EnIshi_Fall(this); - func_80A7ED94(&this->actor.velocity, D_80A7FA28[type]); - func_8002D7EC(&this->actor); - this->actor.shape.rot.x += sRotSpeedX; - this->actor.shape.rot.y += sRotSpeedY; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Math_StepToF(&pthis->actor.shape.yOffset, 0.0f, 2.0f); + EnIshi_Fall(pthis); + func_80A7ED94(&pthis->actor.velocity, D_80A7FA28[type]); + func_8002D7EC(&pthis->actor); + pthis->actor.shape.rot.x += sRotSpeedX; + pthis->actor.shape.rot.y += sRotSpeedY; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx) { - EnIshi* this = (EnIshi*)thisx; + EnIshi* pthis = (EnIshi*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } -void EnIshi_DrawSmall(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_DrawSmall(EnIshi* pthis, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, gFieldKakeraDL); } -void EnIshi_DrawLarge(EnIshi* this, GlobalContext* globalCtx) { +void EnIshi_DrawLarge(EnIshi* pthis, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ishi.c", 1050); func_80093D18(globalCtx->state.gfxCtx); @@ -508,7 +508,7 @@ void EnIshi_DrawLarge(EnIshi* this, GlobalContext* globalCtx) { static EnIshiDrawFunc sDrawFuncs[] = { EnIshi_DrawSmall, EnIshi_DrawLarge }; void EnIshi_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnIshi* this = (EnIshi*)thisx; + EnIshi* pthis = (EnIshi*)thisx; - sDrawFuncs[this->actor.params & 1](this, globalCtx); + sDrawFuncs[pthis->actor.params & 1](pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_It/z_en_it.c b/src/overlays/actors/ovl_En_It/z_en_it.cpp similarity index 69% rename from src/overlays/actors/ovl_En_It/z_en_it.c rename to src/overlays/actors/ovl_En_It/z_en_it.cpp index 52657f203..30b392e44 100644 --- a/src/overlays/actors/ovl_En_It/z_en_it.c +++ b/src/overlays/actors/ovl_En_It/z_en_it.cpp @@ -37,7 +37,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -const ActorInit En_It_InitVars = { +ActorInit En_It_InitVars = { ACTOR_EN_IT, ACTORCAT_PROP, FLAGS, @@ -50,24 +50,24 @@ const ActorInit En_It_InitVars = { }; void EnIt_Init(Actor* thisx, GlobalContext* globalCtx) { - EnIt* this = (EnIt*)thisx; + EnIt* pthis = (EnIt*)thisx; - this->actor.params = 0x0D05; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, 0, &sColChkInfoInit); + pthis->actor.params = 0x0D05; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, 0, &sColChkInfoInit); } void EnIt_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnIt* this = (EnIt*)thisx; + EnIt* pthis = (EnIt*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void EnIt_Update(Actor* thisx, GlobalContext* globalCtx) { - EnIt* this = (EnIt*)thisx; + EnIt* pthis = (EnIt*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } diff --git a/src/overlays/actors/ovl_En_Jj/z_en_jj.c b/src/overlays/actors/ovl_En_Jj/z_en_jj.c deleted file mode 100644 index 0573cfa8d..000000000 --- a/src/overlays/actors/ovl_En_Jj/z_en_jj.c +++ /dev/null @@ -1,335 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_JJ_Z_EN_JJ_C -#include "actor_common.h" -/* - * File: z_en_jj.c - * Overlay: ovl_En_Jj - * Description: Lord Jabu-Jabu - */ - -#include "z_en_jj.h" -#include "objects/object_jj/object_jj.h" -#include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" -#include "def/code_80043480.h" -#include "def/cosf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -typedef enum { - /* 0 */ JABUJABU_EYE_OPEN, - /* 1 */ JABUJABU_EYE_HALF, - /* 2 */ JABUJABU_EYE_CLOSED, - /* 3 */ JABUJABU_EYE_MAX -} EnJjEyeState; - -void EnJj_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJj_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJj_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnJj_UpdateStaticCollision(Actor* thisx, GlobalContext* globalCtx); -void EnJj_WaitToOpenMouth(EnJj* this, GlobalContext* globalCtx); -void EnJj_WaitForFish(EnJj* this, GlobalContext* globalCtx); -void EnJj_BeginCutscene(EnJj* this, GlobalContext* globalCtx); -void EnJj_RemoveDust(EnJj* this, GlobalContext* globalCtx); - -const ActorInit En_Jj_InitVars = { - ACTOR_EN_JJ, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_JJ, - sizeof(EnJj), - (ActorFunc)EnJj_Init, - (ActorFunc)EnJj_Destroy, - (ActorFunc)EnJj_Update, - (ActorFunc)EnJj_Draw, -}; - -static s32 sUnused = 0; - -#include "z_en_jj_cutscene_data.c" EARLY - -static s32 sUnused2[] = { 0, 0 }; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000004, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 170, 150, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 87, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 3300, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_STOP), -}; - -void EnJj_SetupAction(EnJj* this, EnJjActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnJj_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnJj* this = (EnJj*)thisx; - CollisionHeader* colHeader = NULL; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); - - switch (this->dyna.actor.params) { - case JABUJABU_MAIN: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gJabuJabuSkel, &gJabuJabuAnim, this->jointTable, - this->morphTable, 22); - Animation_PlayLoop(&this->skelAnime, &gJabuJabuAnim); - this->unk_30A = 0; - this->eyeIndex = 0; - this->blinkTimer = 0; - this->extraBlinkCounter = 0; - this->extraBlinkTotal = 0; - - if (gSaveContext.eventChkInf[3] & 0x400) { // Fish given - EnJj_SetupAction(this, EnJj_WaitToOpenMouth); - } else { - EnJj_SetupAction(this, EnJj_WaitForFish); - } - - this->bodyCollisionActor = (DynaPolyActor*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_JJ, this->dyna.actor.world.pos.x - 10.0f, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, this->dyna.actor.world.rot.y, 0, - JABUJABU_COLLISION); - DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&gJabuJabuHeadCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - break; - - case JABUJABU_COLLISION: - DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&gJabuJabuBodyCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - func_8003ECA8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dyna.actor.update = EnJj_UpdateStaticCollision; - this->dyna.actor.draw = NULL; - Actor_SetScale(&this->dyna.actor, 0.087f); - break; - - case JABUJABU_UNUSED_COLLISION: - DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&gJabuJabuUnusedCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->dyna.actor.update = EnJj_UpdateStaticCollision; - this->dyna.actor.draw = NULL; - Actor_SetScale(&this->dyna.actor, 0.087f); - break; - } -} - -void EnJj_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnJj* this = (EnJj*)thisx; - - switch (this->dyna.actor.params) { - case JABUJABU_MAIN: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); - break; - - case JABUJABU_COLLISION: - case JABUJABU_UNUSED_COLLISION: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - break; - } -} - -/** - * Blink routine. Blinks at the end of each randomised blinkTimer cycle. If extraBlinkCounter is not zero, blink that - * many more times before resuming random blinkTimer cycles. extraBlinkTotal can be set to a positive number to blink - * that many extra times at the end of every blinkTimer cycle, but the actor always sets it to zero, so only one - * multiblink happens when extraBlinkCounter is nonzero. - */ -void EnJj_Blink(EnJj* this) { - if (this->blinkTimer > 0) { - this->blinkTimer--; - } else { - this->eyeIndex++; - if (this->eyeIndex >= JABUJABU_EYE_MAX) { - this->eyeIndex = JABUJABU_EYE_OPEN; - if (this->extraBlinkCounter > 0) { - this->extraBlinkCounter--; - } else { - this->blinkTimer = Rand_S16Offset(20, 20); - this->extraBlinkCounter = this->extraBlinkTotal; - } - } - } -} - -void EnJj_OpenMouth(EnJj* this, GlobalContext* globalCtx) { - DynaPolyActor* bodyCollisionActor = this->bodyCollisionActor; - - if (this->mouthOpenAngle >= -5200) { - this->mouthOpenAngle -= 102; - - if (this->mouthOpenAngle < -2600) { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, bodyCollisionActor->bgId); - } - } -} - -void EnJj_WaitToOpenMouth(EnJj* this, GlobalContext* globalCtx) { - if (this->dyna.actor.xzDistToPlayer < 300.0f) { - EnJj_SetupAction(this, EnJj_OpenMouth); - } -} - -void EnJj_WaitForFish(EnJj* this, GlobalContext* globalCtx) { - static Vec3f feedingSpot = { -1589.0f, 53.0f, -43.0f }; - Player* player = GET_PLAYER(globalCtx); - - if ((Math_Vec3f_DistXZ(&feedingSpot, &player->actor.world.pos) < 300.0f) && - globalCtx->isPlayerDroppingFish(globalCtx)) { - this->cutsceneCountdownTimer = 100; - EnJj_SetupAction(this, EnJj_BeginCutscene); - } - - this->collider.dim.pos.x = -1245; - this->collider.dim.pos.y = 20; - this->collider.dim.pos.z = -48; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnJj_BeginCutscene(EnJj* this, GlobalContext* globalCtx) { - DynaPolyActor* bodyCollisionActor = this->bodyCollisionActor; - - if (this->cutsceneCountdownTimer > 0) { - this->cutsceneCountdownTimer--; - } else { - EnJj_SetupAction(this, EnJj_RemoveDust); - globalCtx->csCtx.segment = &D_80A88164; - gSaveContext.cutsceneTrigger = 1; - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, bodyCollisionActor->bgId); - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - gSaveContext.eventChkInf[3] |= 0x400; - func_80078884(NA_SE_SY_CORRECT_CHIME); - } -} - -void EnJj_CutsceneUpdate(EnJj* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.npcActions[2]->action) { - case 1: - if (this->unk_30A & 2) { - this->eyeIndex = 0; - this->blinkTimer = Rand_S16Offset(20, 20); - this->extraBlinkCounter = 0; - this->extraBlinkTotal = 0; - this->unk_30A ^= 2; - } - break; - - case 2: - this->unk_30A |= 1; - - if (!(this->unk_30A & 8)) { - this->dust = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EFF_DUST, - -1100.0f, 105.0f, -27.0f, 0, 0, 0, EFF_DUST_TYPE_0); - this->unk_30A |= 8; - } - break; - - case 3: - if (!(this->unk_30A & 2)) { - this->eyeIndex = 0; - this->blinkTimer = 0; - this->extraBlinkCounter = 1; - this->extraBlinkTotal = 0; - this->unk_30A |= 2; - } - break; - } - - if (this->unk_30A & 1) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_JABJAB_BREATHE - SFX_FLAG); - - if (this->mouthOpenAngle >= -5200) { - this->mouthOpenAngle -= 102; - } - } -} - -void EnJj_RemoveDust(EnJj* this, GlobalContext* globalCtx) { - Actor* dust; - - if (!(this->unk_30A & 4)) { - this->unk_30A |= 4; - dust = this->dust; - - if (dust != NULL) { - Actor_Kill(dust); - this->dyna.actor.child = NULL; - } - } -} - -void EnJj_UpdateStaticCollision(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnJj_Update(Actor* thisx, GlobalContext* globalCtx) { - EnJj* this = (EnJj*)thisx; - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[2] != NULL)) { - EnJj_CutsceneUpdate(this, globalCtx); - } else { - this->actionFunc(this, globalCtx); - - if (this->skelAnime.curFrame == 41.0f) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_JABJAB_GROAN); - } - } - - EnJj_Blink(this); - SkelAnime_Update(&this->skelAnime); - Actor_SetScale(&this->dyna.actor, 0.087f); - - // Head - this->skelAnime.jointTable[10].z = this->mouthOpenAngle; -} - -void EnJj_Draw(Actor* thisx, GlobalContext* globalCtx2) { - static void* eyeTextures[] = { gJabuJabuEyeOpenTex, gJabuJabuEyeHalfTex, gJabuJabuEyeClosedTex }; - GlobalContext* globalCtx = globalCtx2; - EnJj* this = (EnJj*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_jj.c", 879); - - func_800943C8(globalCtx->state.gfxCtx); - Matrix_Translate(0.0f, (cosf(this->skelAnime.curFrame * (M_PI / 41.0f)) * 10.0f) - 10.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(10.0f, 10.0f, 10.0f, MTXMODE_APPLY); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_jj.c", 898); -} diff --git a/src/overlays/actors/ovl_En_Jj/z_en_jj.cpp b/src/overlays/actors/ovl_En_Jj/z_en_jj.cpp new file mode 100644 index 000000000..31939c4bf --- /dev/null +++ b/src/overlays/actors/ovl_En_Jj/z_en_jj.cpp @@ -0,0 +1,335 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_JJ_Z_EN_JJ_C +#include "actor_common.h" +/* + * File: z_en_jj.c + * Overlay: ovl_En_Jj + * Description: Lord Jabu-Jabu + */ + +#include "z_en_jj.h" +#include "objects/object_jj/object_jj.h" +#include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" +#include "def/code_80043480.h" +#include "def/cosf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +typedef enum { + /* 0 */ JABUJABU_EYE_OPEN, + /* 1 */ JABUJABU_EYE_HALF, + /* 2 */ JABUJABU_EYE_CLOSED, + /* 3 */ JABUJABU_EYE_MAX +} EnJjEyeState; + +void EnJj_Init(Actor* thisx, GlobalContext* globalCtx); +void EnJj_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnJj_Update(Actor* thisx, GlobalContext* globalCtx); +void EnJj_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnJj_UpdateStaticCollision(Actor* thisx, GlobalContext* globalCtx); +void EnJj_WaitToOpenMouth(EnJj* pthis, GlobalContext* globalCtx); +void EnJj_WaitForFish(EnJj* pthis, GlobalContext* globalCtx); +void EnJj_BeginCutscene(EnJj* pthis, GlobalContext* globalCtx); +void EnJj_RemoveDust(EnJj* pthis, GlobalContext* globalCtx); + +ActorInit En_Jj_InitVars = { + ACTOR_EN_JJ, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_JJ, + sizeof(EnJj), + (ActorFunc)EnJj_Init, + (ActorFunc)EnJj_Destroy, + (ActorFunc)EnJj_Update, + (ActorFunc)EnJj_Draw, +}; + +static s32 sUnused = 0; + +#include "z_en_jj_cutscene_data.cpp" EARLY + +static s32 sUnused2[] = { 0, 0 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000004, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 170, 150, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 87, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 3300, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_STOP), +}; + +void EnJj_SetupAction(EnJj* pthis, EnJjActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnJj_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnJj* pthis = (EnJj*)thisx; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, NULL, 0.0f); + + switch (pthis->dyna.actor.params) { + case JABUJABU_MAIN: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gJabuJabuSkel, &gJabuJabuAnim, pthis->jointTable, + pthis->morphTable, 22); + Animation_PlayLoop(&pthis->skelAnime, &gJabuJabuAnim); + pthis->unk_30A = 0; + pthis->eyeIndex = 0; + pthis->blinkTimer = 0; + pthis->extraBlinkCounter = 0; + pthis->extraBlinkTotal = 0; + + if (gSaveContext.eventChkInf[3] & 0x400) { // Fish given + EnJj_SetupAction(pthis, EnJj_WaitToOpenMouth); + } else { + EnJj_SetupAction(pthis, EnJj_WaitForFish); + } + + pthis->bodyCollisionActor = (DynaPolyActor*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EN_JJ, pthis->dyna.actor.world.pos.x - 10.0f, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, pthis->dyna.actor.world.rot.y, 0, + JABUJABU_COLLISION); + DynaPolyActor_Init(&pthis->dyna, 0); + CollisionHeader_GetVirtual(&gJabuJabuHeadCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + pthis->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + break; + + case JABUJABU_COLLISION: + DynaPolyActor_Init(&pthis->dyna, 0); + CollisionHeader_GetVirtual(&gJabuJabuBodyCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + func_8003ECA8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dyna.actor.update = EnJj_UpdateStaticCollision; + pthis->dyna.actor.draw = NULL; + Actor_SetScale(&pthis->dyna.actor, 0.087f); + break; + + case JABUJABU_UNUSED_COLLISION: + DynaPolyActor_Init(&pthis->dyna, 0); + CollisionHeader_GetVirtual(&gJabuJabuUnusedCol, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->dyna.actor.update = EnJj_UpdateStaticCollision; + pthis->dyna.actor.draw = NULL; + Actor_SetScale(&pthis->dyna.actor, 0.087f); + break; + } +} + +void EnJj_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJj* pthis = (EnJj*)thisx; + + switch (pthis->dyna.actor.params) { + case JABUJABU_MAIN: + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + break; + + case JABUJABU_COLLISION: + case JABUJABU_UNUSED_COLLISION: + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + break; + } +} + +/** + * Blink routine. Blinks at the end of each randomised blinkTimer cycle. If extraBlinkCounter is not zero, blink that + * many more times before resuming random blinkTimer cycles. extraBlinkTotal can be set to a positive number to blink + * that many extra times at the end of every blinkTimer cycle, but the actor always sets it to zero, so only one + * multiblink happens when extraBlinkCounter is nonzero. + */ +void EnJj_Blink(EnJj* pthis) { + if (pthis->blinkTimer > 0) { + pthis->blinkTimer--; + } else { + pthis->eyeIndex++; + if (pthis->eyeIndex >= JABUJABU_EYE_MAX) { + pthis->eyeIndex = JABUJABU_EYE_OPEN; + if (pthis->extraBlinkCounter > 0) { + pthis->extraBlinkCounter--; + } else { + pthis->blinkTimer = Rand_S16Offset(20, 20); + pthis->extraBlinkCounter = pthis->extraBlinkTotal; + } + } + } +} + +void EnJj_OpenMouth(EnJj* pthis, GlobalContext* globalCtx) { + DynaPolyActor* bodyCollisionActor = pthis->bodyCollisionActor; + + if (pthis->mouthOpenAngle >= -5200) { + pthis->mouthOpenAngle -= 102; + + if (pthis->mouthOpenAngle < -2600) { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, bodyCollisionActor->bgId); + } + } +} + +void EnJj_WaitToOpenMouth(EnJj* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.xzDistToPlayer < 300.0f) { + EnJj_SetupAction(pthis, EnJj_OpenMouth); + } +} + +void EnJj_WaitForFish(EnJj* pthis, GlobalContext* globalCtx) { + static Vec3f feedingSpot = { -1589.0f, 53.0f, -43.0f }; + Player* player = GET_PLAYER(globalCtx); + + if ((Math_Vec3f_DistXZ(&feedingSpot, &player->actor.world.pos) < 300.0f) && + globalCtx->isPlayerDroppingFish(globalCtx)) { + pthis->cutsceneCountdownTimer = 100; + EnJj_SetupAction(pthis, EnJj_BeginCutscene); + } + + pthis->collider.dim.pos.x = -1245; + pthis->collider.dim.pos.y = 20; + pthis->collider.dim.pos.z = -48; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnJj_BeginCutscene(EnJj* pthis, GlobalContext* globalCtx) { + DynaPolyActor* bodyCollisionActor = pthis->bodyCollisionActor; + + if (pthis->cutsceneCountdownTimer > 0) { + pthis->cutsceneCountdownTimer--; + } else { + EnJj_SetupAction(pthis, EnJj_RemoveDust); + globalCtx->csCtx.segment = &D_80A88164; + gSaveContext.cutsceneTrigger = 1; + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, bodyCollisionActor->bgId); + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + gSaveContext.eventChkInf[3] |= 0x400; + func_80078884(NA_SE_SY_CORRECT_CHIME); + } +} + +void EnJj_CutsceneUpdate(EnJj* pthis, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.npcActions[2]->action) { + case 1: + if (pthis->unk_30A & 2) { + pthis->eyeIndex = 0; + pthis->blinkTimer = Rand_S16Offset(20, 20); + pthis->extraBlinkCounter = 0; + pthis->extraBlinkTotal = 0; + pthis->unk_30A ^= 2; + } + break; + + case 2: + pthis->unk_30A |= 1; + + if (!(pthis->unk_30A & 8)) { + pthis->dust = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_EFF_DUST, + -1100.0f, 105.0f, -27.0f, 0, 0, 0, EFF_DUST_TYPE_0); + pthis->unk_30A |= 8; + } + break; + + case 3: + if (!(pthis->unk_30A & 2)) { + pthis->eyeIndex = 0; + pthis->blinkTimer = 0; + pthis->extraBlinkCounter = 1; + pthis->extraBlinkTotal = 0; + pthis->unk_30A |= 2; + } + break; + } + + if (pthis->unk_30A & 1) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_JABJAB_BREATHE - SFX_FLAG); + + if (pthis->mouthOpenAngle >= -5200) { + pthis->mouthOpenAngle -= 102; + } + } +} + +void EnJj_RemoveDust(EnJj* pthis, GlobalContext* globalCtx) { + Actor* dust; + + if (!(pthis->unk_30A & 4)) { + pthis->unk_30A |= 4; + dust = pthis->dust; + + if (dust != NULL) { + Actor_Kill(dust); + pthis->dyna.actor.child = NULL; + } + } +} + +void EnJj_UpdateStaticCollision(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnJj_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJj* pthis = (EnJj*)thisx; + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[2] != NULL)) { + EnJj_CutsceneUpdate(pthis, globalCtx); + } else { + pthis->actionFunc(pthis, globalCtx); + + if (pthis->skelAnime.curFrame == 41.0f) { + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_JABJAB_GROAN); + } + } + + EnJj_Blink(pthis); + SkelAnime_Update(&pthis->skelAnime); + Actor_SetScale(&pthis->dyna.actor, 0.087f); + + // Head + pthis->skelAnime.jointTable[10].z = pthis->mouthOpenAngle; +} + +void EnJj_Draw(Actor* thisx, GlobalContext* globalCtx2) { + static void* eyeTextures[] = { gJabuJabuEyeOpenTex, gJabuJabuEyeHalfTex, gJabuJabuEyeClosedTex }; + GlobalContext* globalCtx = globalCtx2; + EnJj* pthis = (EnJj*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_jj.c", 879); + + func_800943C8(globalCtx->state.gfxCtx); + Matrix_Translate(0.0f, (cosf(pthis->skelAnime.curFrame * (M_PI / 41.0f)) * 10.0f) - 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(10.0f, 10.0f, 10.0f, MTXMODE_APPLY); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_jj.c", 898); +} diff --git a/src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.c b/src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.c rename to src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c deleted file mode 100644 index 2815d37c5..000000000 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ /dev/null @@ -1,243 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_JS_Z_EN_JS_C -#include "actor_common.h" -/* - * File: z_en_js.c - * Overlay: ovl_En_Js - * Description: Magic Carpet Salesman - */ - -#include "z_en_js.h" -#include "objects/object_js/object_js.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnJs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJs_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A89304(EnJs* this, GlobalContext* globalCtx); - -const ActorInit En_Js_InitVars = { - ACTOR_EN_JS, - ACTORCAT_NPC, - FLAGS, - OBJECT_JS, - sizeof(EnJs), - (ActorFunc)EnJs_Init, - (ActorFunc)EnJs_Destroy, - (ActorFunc)EnJs_Update, - (ActorFunc)EnJs_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -void En_Js_SetupAction(EnJs* this, EnJsActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnJs_Init(Actor* thisx, GlobalContext* globalCtx) { - EnJs* this = (EnJs*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCarpetMerchantSkel, &gCarpetMerchantSlappingKneeAnim, - this->jointTable, this->morphTable, 13); - Animation_PlayOnce(&this->skelAnime, &gCarpetMerchantSlappingKneeAnim); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - En_Js_SetupAction(this, func_80A89304); - this->unk_284 = 0; - this->actor.gravity = -1.0f; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JSJUTAN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); -} - -void EnJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnJs* this = (EnJs*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -u8 func_80A88F64(EnJs* this, GlobalContext* globalCtx, u16 textId) { - s16 yawDiff; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - return 1; - } else { - this->actor.textId = textId; - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(yawDiff) <= 0x1800 && this->actor.xzDistToPlayer < 100.0f) { - this->unk_284 |= 1; - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - return 0; - } -} - -void func_80A89008(EnJs* this) { - En_Js_SetupAction(this, func_80A89304); - Animation_Change(&this->skelAnime, &gCarpetMerchantSlappingKneeAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCarpetMerchantSlappingKneeAnim), ANIMMODE_ONCE, -4.0f); -} - -void func_80A89078(EnJs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80A89008(this); - this->actor.flags &= ~ACTOR_FLAG_16; - } -} - -void func_80A890C0(EnJs* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - En_Js_SetupAction(this, func_80A89078); - } else { - func_8002F2CC(&this->actor, globalCtx, 1000.0f); - } -} - -void func_80A8910C(EnJs* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.textId = 0x6078; - En_Js_SetupAction(this, func_80A890C0); - this->actor.flags |= ACTOR_FLAG_16; - } -} - -void func_80A89160(EnJs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - En_Js_SetupAction(this, func_80A8910C); - } else { - func_8002F434(&this->actor, globalCtx, GI_BOMBCHUS_10, 10000.0f, 50.0f); - } -} - -void func_80A891C4(EnJs* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - if (gSaveContext.rupees < 200) { - Message_ContinueTextbox(globalCtx, 0x6075); - func_80A89008(this); - } else { - Rupees_ChangeBy(-200); - En_Js_SetupAction(this, func_80A89160); - } - break; - case 1: // no - Message_ContinueTextbox(globalCtx, 0x6074); - func_80A89008(this); - } - } -} - -void func_80A89294(EnJs* this) { - En_Js_SetupAction(this, func_80A891C4); - Animation_Change(&this->skelAnime, &gCarpetMerchantIdleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCarpetMerchantIdleAnim), ANIMMODE_ONCE, -4.0f); -} - -void func_80A89304(EnJs* this, GlobalContext* globalCtx) { - if (func_80A88F64(this, globalCtx, 0x6077)) { - func_80A89294(this); - } -} - -void EnJs_Update(Actor* thisx, GlobalContext* globalCtx) { - EnJs* this = (EnJs*)thisx; - s32 pad; - s32 pad2; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - - if (this->actor.bgCheckFlags & 1) { - if (SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1) { - Math_ApproachF(&this->actor.shape.yOffset, sREG(80) + -2000.0f, 1.0f, (sREG(81) / 10.0f) + 50.0f); - } - } else { - Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, (sREG(81) / 10.0f) + 50.0f); - } - if (SkelAnime_Update(&this->skelAnime)) { - this->skelAnime.curFrame = 0.0f; - } - this->actionFunc(this, globalCtx); - if (this->unk_284 & 1) { - func_80038290(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->unk_278.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_278.y, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_27E.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_27E.y, 0, 6, 0x1838, 0x64); - } - this->unk_284 &= ~0x1; - - if (DECR(this->unk_288) == 0) { - this->unk_288 = Rand_S16Offset(0x3C, 0x3C); - } - - this->unk_286 = this->unk_288; - - if (this->unk_286 >= 3) { - this->unk_286 = 0; - } -} - -s32 EnJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnJs* this = (EnJs*)thisx; - - if (limbIndex == 12) { - rot->y -= this->unk_278.y; - } - return false; -} - -void EnJs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_80A896DC = { 0.0f, 0.0f, 0.0f }; - EnJs* this = (EnJs*)thisx; - - if (limbIndex == 12) { - Matrix_MultVec3f(&D_80A896DC, &this->actor.focus.pos); - } -} -void EnJs_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnJs* this = (EnJs*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnJs_OverrideLimbDraw, EnJs_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.cpp b/src/overlays/actors/ovl_En_Js/z_en_js.cpp new file mode 100644 index 000000000..b5a956828 --- /dev/null +++ b/src/overlays/actors/ovl_En_Js/z_en_js.cpp @@ -0,0 +1,243 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_JS_Z_EN_JS_C +#include "actor_common.h" +/* + * File: z_en_js.c + * Overlay: ovl_En_Js + * Description: Magic Carpet Salesman + */ + +#include "z_en_js.h" +#include "objects/object_js/object_js.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnJs_Init(Actor* thisx, GlobalContext* globalCtx); +void EnJs_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnJs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnJs_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A89304(EnJs* pthis, GlobalContext* globalCtx); + +ActorInit En_Js_InitVars = { + ACTOR_EN_JS, + ACTORCAT_NPC, + FLAGS, + OBJECT_JS, + sizeof(EnJs), + (ActorFunc)EnJs_Init, + (ActorFunc)EnJs_Destroy, + (ActorFunc)EnJs_Update, + (ActorFunc)EnJs_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +void En_Js_SetupAction(EnJs* pthis, EnJsActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnJs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnJs* pthis = (EnJs*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCarpetMerchantSkel, &gCarpetMerchantSlappingKneeAnim, + pthis->jointTable, pthis->morphTable, 13); + Animation_PlayOnce(&pthis->skelAnime, &gCarpetMerchantSlappingKneeAnim); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + En_Js_SetupAction(pthis, func_80A89304); + pthis->unk_284 = 0; + pthis->actor.gravity = -1.0f; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_JSJUTAN, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); +} + +void EnJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJs* pthis = (EnJs*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +u8 func_80A88F64(EnJs* pthis, GlobalContext* globalCtx, u16 textId) { + s16 yawDiff; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + return 1; + } else { + pthis->actor.textId = textId; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(yawDiff) <= 0x1800 && pthis->actor.xzDistToPlayer < 100.0f) { + pthis->unk_284 |= 1; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + return 0; + } +} + +void func_80A89008(EnJs* pthis) { + En_Js_SetupAction(pthis, func_80A89304); + Animation_Change(&pthis->skelAnime, &gCarpetMerchantSlappingKneeAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gCarpetMerchantSlappingKneeAnim), ANIMMODE_ONCE, -4.0f); +} + +void func_80A89078(EnJs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80A89008(pthis); + pthis->actor.flags &= ~ACTOR_FLAG_16; + } +} + +void func_80A890C0(EnJs* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + En_Js_SetupAction(pthis, func_80A89078); + } else { + func_8002F2CC(&pthis->actor, globalCtx, 1000.0f); + } +} + +void func_80A8910C(EnJs* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actor.textId = 0x6078; + En_Js_SetupAction(pthis, func_80A890C0); + pthis->actor.flags |= ACTOR_FLAG_16; + } +} + +void func_80A89160(EnJs* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + En_Js_SetupAction(pthis, func_80A8910C); + } else { + func_8002F434(&pthis->actor, globalCtx, GI_BOMBCHUS_10, 10000.0f, 50.0f); + } +} + +void func_80A891C4(EnJs* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + if (gSaveContext.rupees < 200) { + Message_ContinueTextbox(globalCtx, 0x6075); + func_80A89008(pthis); + } else { + Rupees_ChangeBy(-200); + En_Js_SetupAction(pthis, func_80A89160); + } + break; + case 1: // no + Message_ContinueTextbox(globalCtx, 0x6074); + func_80A89008(pthis); + } + } +} + +void func_80A89294(EnJs* pthis) { + En_Js_SetupAction(pthis, func_80A891C4); + Animation_Change(&pthis->skelAnime, &gCarpetMerchantIdleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gCarpetMerchantIdleAnim), ANIMMODE_ONCE, -4.0f); +} + +void func_80A89304(EnJs* pthis, GlobalContext* globalCtx) { + if (func_80A88F64(pthis, globalCtx, 0x6077)) { + func_80A89294(pthis); + } +} + +void EnJs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJs* pthis = (EnJs*)thisx; + s32 pad; + s32 pad2; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + + if (pthis->actor.bgCheckFlags & 1) { + if (SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId) == 1) { + Math_ApproachF(&pthis->actor.shape.yOffset, sREG(80) + -2000.0f, 1.0f, (sREG(81) / 10.0f) + 50.0f); + } + } else { + Math_ApproachZeroF(&pthis->actor.shape.yOffset, 1.0f, (sREG(81) / 10.0f) + 50.0f); + } + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->skelAnime.curFrame = 0.0f; + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_284 & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_278, &pthis->unk_27E, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->unk_278.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&pthis->unk_278.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&pthis->unk_27E.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&pthis->unk_27E.y, 0, 6, 0x1838, 0x64); + } + pthis->unk_284 &= ~0x1; + + if (DECR(pthis->unk_288) == 0) { + pthis->unk_288 = Rand_S16Offset(0x3C, 0x3C); + } + + pthis->unk_286 = pthis->unk_288; + + if (pthis->unk_286 >= 3) { + pthis->unk_286 = 0; + } +} + +s32 EnJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnJs* pthis = (EnJs*)thisx; + + if (limbIndex == 12) { + rot->y -= pthis->unk_278.y; + } + return false; +} + +void EnJs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_80A896DC = { 0.0f, 0.0f, 0.0f }; + EnJs* pthis = (EnJs*)thisx; + + if (limbIndex == 12) { + Matrix_MultVec3f(&D_80A896DC, &pthis->actor.focus.pos); + } +} +void EnJs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJs* pthis = (EnJs*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnJs_OverrideLimbDraw, EnJs_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c b/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.cpp similarity index 73% rename from src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c rename to src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.cpp index c439ade7b..765b37468 100644 --- a/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c +++ b/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.cpp @@ -24,7 +24,7 @@ void EnJsjutan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJsjutan_Update(Actor* thisx, GlobalContext* globalCtx); void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Jsjutan_InitVars = { +ActorInit En_Jsjutan_InitVars = { ACTOR_EN_JSJUTAN, ACTORCAT_NPC, FLAGS, @@ -43,33 +43,33 @@ static Vec3s D_80A8EE10[0x90]; static s32 sUnused[2] = { 0, 0 }; -#include "overlays/ovl_En_Jsjutan/ovl_En_Jsjutan.c" +#include "overlays/ovl_En_Jsjutan/ovl_En_Jsjutan.cpp" void EnJsjutan_Init(Actor* thisx, GlobalContext* globalCtx) { - EnJsjutan* this = (EnJsjutan*)thisx; + EnJsjutan* pthis = (EnJsjutan*)thisx; s32 pad; CollisionHeader* header = NULL; - this->dyna.actor.flags &= ~ACTOR_FLAG_0; - DynaPolyActor_Init(&this->dyna, DPM_UNK); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_0; + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); CollisionHeader_GetVirtual(&sCol, &header); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, header); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, header); Actor_SetScale(thisx, 0.02f); - this->unk_164 = true; - this->shadowAlpha = 100.0f; + pthis->unk_164 = true; + pthis->shadowAlpha = 100.0f; } void EnJsjutan_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnJsjutan* this = (EnJsjutan*)thisx; + EnJsjutan* pthis = (EnJsjutan*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_80A89860(EnJsjutan* this, GlobalContext* globalCtx) { +void func_80A89860(EnJsjutan* pthis, GlobalContext* globalCtx) { s16 i; Vtx* oddVtx; Vtx* evenVtx; - Vec3f actorPos = this->dyna.actor.world.pos; + Vec3f actorPos = pthis->dyna.actor.world.pos; oddVtx = SEGMENTED_TO_VIRTUAL(gShadowOddVtx); evenVtx = SEGMENTED_TO_VIRTUAL(sShadowEvenVtx); @@ -77,19 +77,19 @@ void func_80A89860(EnJsjutan* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_80A8EE10); i++, oddVtx++, evenVtx++) { D_80A8EE10[i].x = oddVtx->v.ob[0]; D_80A8EE10[i].z = oddVtx->v.ob[2]; - if (this->dyna.actor.params == ENJSJUTAN_TYPE_01) { + if (pthis->dyna.actor.params == ENJSJUTAN_TYPE_01) { oddVtx->v.ob[1] = evenVtx->v.ob[1] = 0x585; } else { - this->dyna.actor.world.pos.x = oddVtx->v.ob[0] * 0.02f + actorPos.x; - this->dyna.actor.world.pos.z = oddVtx->v.ob[2] * 0.02f + actorPos.z; - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 10.0f, 10.0f, 10.0f, 4); - oddVtx->v.ob[1] = evenVtx->v.ob[1] = this->dyna.actor.floorHeight; - this->dyna.actor.world.pos = actorPos; + pthis->dyna.actor.world.pos.x = oddVtx->v.ob[0] * 0.02f + actorPos.x; + pthis->dyna.actor.world.pos.z = oddVtx->v.ob[2] * 0.02f + actorPos.z; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->dyna.actor, 10.0f, 10.0f, 10.0f, 4); + oddVtx->v.ob[1] = evenVtx->v.ob[1] = pthis->dyna.actor.floorHeight; + pthis->dyna.actor.world.pos = actorPos; } } } -void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { +void func_80A89A6C(EnJsjutan* pthis, GlobalContext* globalCtx) { u8 isPlayerOnTop = false; // sp127 s16 i; s16 j; @@ -122,7 +122,7 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { f32 maxAmp; f32 waveform; Player* player = GET_PLAYER(globalCtx); - Actor* parent = this->dyna.actor.parent; + Actor* parent = pthis->dyna.actor.parent; Actor* actorExplosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; u8 isInCreditsScene = false; // sp8B @@ -135,9 +135,9 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { } // Distance of player to carpet. - spB8 = (player->actor.world.pos.x - this->dyna.actor.world.pos.x) * 50.0f; - spB4 = (player->actor.world.pos.y - this->unk_168) * 50.0f; - spB0 = (player->actor.world.pos.z - this->dyna.actor.world.pos.z) * 50.0f; + spB8 = (player->actor.world.pos.x - pthis->dyna.actor.world.pos.x) * 50.0f; + spB4 = (player->actor.world.pos.y - pthis->unk_168) * 50.0f; + spB0 = (player->actor.world.pos.z - pthis->dyna.actor.world.pos.z) * 50.0f; phi_s0_2 = carpetVtx; if ((fabsf(spB8) < 5500.0f) && (fabsf(spB4) < 3000.0f) && (fabsf(spB0) < 5500.0f)) { @@ -145,9 +145,9 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { } // Distance of Magic Carpet Salesman to carpet. - spD4[0] = (parent->world.pos.x - this->dyna.actor.world.pos.x) * 50.0f; - spC8[0] = ((parent->world.pos.y - 8.0f) - this->unk_168) * 50.0f; - spBC[0] = (parent->world.pos.z - this->dyna.actor.world.pos.z) * 50.0f; + spD4[0] = (parent->world.pos.x - pthis->dyna.actor.world.pos.x) * 50.0f; + spC8[0] = ((parent->world.pos.y - 8.0f) - pthis->unk_168) * 50.0f; + spBC[0] = (parent->world.pos.z - pthis->dyna.actor.world.pos.z) * 50.0f; spE0[0] = 1; for (i = 1; i < 3; i++) { @@ -176,26 +176,26 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { actorBeanGuy = actorBeanGuy->next; } - spD4[1] = 50.0f * (actorProfessor->world.pos.x - this->dyna.actor.world.pos.x); - spC8[1] = 50.0f * (actorProfessor->world.pos.y - this->unk_168); - spBC[1] = 50.0f * (actorProfessor->world.pos.z - this->dyna.actor.world.pos.z); + spD4[1] = 50.0f * (actorProfessor->world.pos.x - pthis->dyna.actor.world.pos.x); + spC8[1] = 50.0f * (actorProfessor->world.pos.y - pthis->unk_168); + spBC[1] = 50.0f * (actorProfessor->world.pos.z - pthis->dyna.actor.world.pos.z); spE0[1] = 1; - spD4[2] = 50.0f * (actorBeanGuy->world.pos.x - this->dyna.actor.world.pos.x); - spC8[2] = 50.0f * (actorBeanGuy->world.pos.y - this->unk_168); - spBC[2] = 50.0f * (actorBeanGuy->world.pos.z - this->dyna.actor.world.pos.z); + spD4[2] = 50.0f * (actorBeanGuy->world.pos.x - pthis->dyna.actor.world.pos.x); + spC8[2] = 50.0f * (actorBeanGuy->world.pos.y - pthis->unk_168); + spBC[2] = 50.0f * (actorBeanGuy->world.pos.z - pthis->dyna.actor.world.pos.z); spE0[2] = 1; } else { // Player can place bombs in carpet and it will react to it. while (actorExplosive != NULL) { if (i < 3) { - spD4[i] = (actorExplosive->world.pos.x - this->dyna.actor.world.pos.x) * 50.0f; - spC8[i] = (actorExplosive->world.pos.y - this->unk_168) * 50.0f; - spBC[i] = (actorExplosive->world.pos.z - this->dyna.actor.world.pos.z) * 50.0f; + spD4[i] = (actorExplosive->world.pos.x - pthis->dyna.actor.world.pos.x) * 50.0f; + spC8[i] = (actorExplosive->world.pos.y - pthis->unk_168) * 50.0f; + spBC[i] = (actorExplosive->world.pos.z - pthis->dyna.actor.world.pos.z) * 50.0f; if ((fabsf(spD4[i]) < 5500.0f) && (fabsf(spC8[i]) < 3000.0f) && (fabsf(spBC[i]) < 5500.0f)) { if (actorExplosive->params == BOMB_EXPLOSION) { - spE0[i] = 35; // Code never checks this, so it goes unused. Maybe it was planned to damage the + spE0[i] = 35; // Code never checks pthis, so it goes unused. Maybe it was planned to damage the // carpet with explosions (?) } else { spE0[i] = 1; @@ -215,12 +215,12 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { dzVtx = carpetVtx->n.ob[2] - spB0; distVtx = sqrtf(SQ(dxVtx) + SQ(dzVtx)); - // Distance percentage. 0.0f to 1.0f. 2500.0f is the max distance to an actor that this wave will consider. + // Distance percentage. 0.0f to 1.0f. 2500.0f is the max distance to an actor that pthis wave will consider. weight = (2500.0f - distVtx) / 2500.0f; if (weight < 0.0f) { weight = 0.0f; } - offset = (spB4 * weight) + ((this->unk_170 - (this->unk_170 * weight)) - 200.0f); + offset = (spB4 * weight) + ((pthis->unk_170 - (pthis->unk_170 * weight)) - 200.0f); distVtx -= 1500.0f; if (distVtx < 0.0f) { @@ -231,7 +231,7 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { spA8 = CLAMP_MAX(spA8, 100.0f); } else { - offset = this->unk_170 - 200.f; + offset = pthis->unk_170 - 200.f; spA8 = 100.0f; } @@ -252,9 +252,9 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { } // should be the following, but doesn't match that way. - // maxoffset = (spC8[i] * weight) + ((this->unk_170 - (this->unk_170 * weight)) - 200.0f); + // maxoffset = (spC8[i] * weight) + ((pthis->unk_170 - (pthis->unk_170 * weight)) - 200.0f); maxOffset = (spC8[j] * weight); - maxOffset += ((this->unk_170 - (this->unk_170 * weight)) - 200.0f); + maxOffset += ((pthis->unk_170 - (pthis->unk_170 * weight)) - 200.0f); distVtx -= 1500.0f; if (distVtx < 0.0f) { @@ -281,9 +281,9 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { */ waveform = spA8 * Math_SinS(globalCtx->gameplayFrames * 4000 + i * 10000); - if (this->unk_174) { + if (pthis->unk_174) { s16 phi_v1_4 = offset + waveform; - s16 temp_a0_3 = (shadowVtx->n.ob[1] - this->unk_168) * 50.0f; + s16 temp_a0_3 = (shadowVtx->n.ob[1] - pthis->unk_168) * 50.0f; if (phi_v1_4 < temp_a0_3) { phi_v1_4 = temp_a0_3; @@ -301,24 +301,24 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) { } } - if (!this->unk_174) { + if (!pthis->unk_174) { u16 dayTime; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.world.pos.y = this->unk_168; + pthis->dyna.actor.velocity.y = 0.0f; + pthis->dyna.actor.world.pos.y = pthis->unk_168; dayTime = gSaveContext.dayTime; if (dayTime >= 0x8000) { dayTime = 0xFFFF - dayTime; } - this->shadowAlpha = (dayTime * 0.00275f) + 10.0f; // (1.0f / 364.0f) ? - this->unk_170 = 1000.0f; + pthis->shadowAlpha = (dayTime * 0.00275f) + 10.0f; // (1.0f / 364.0f) ? + pthis->unk_170 = 1000.0f; } else { - Math_ApproachF(&this->dyna.actor.world.pos.y, this->unk_168 - 1000.0f, 1.0f, this->dyna.actor.velocity.y); - Math_ApproachF(&this->dyna.actor.velocity.y, 5.0f, 1.0f, 0.5f); - Math_ApproachF(&this->shadowAlpha, 0.0f, 1.0f, 3.0f); - Math_ApproachF(&this->unk_170, -5000.0f, 1.0f, 100.0f); + Math_ApproachF(&pthis->dyna.actor.world.pos.y, pthis->unk_168 - 1000.0f, 1.0f, pthis->dyna.actor.velocity.y); + Math_ApproachF(&pthis->dyna.actor.velocity.y, 5.0f, 1.0f, 0.5f); + Math_ApproachF(&pthis->shadowAlpha, 0.0f, 1.0f, 3.0f); + Math_ApproachF(&pthis->unk_170, -5000.0f, 1.0f, 100.0f); } carpetVtx = phi_s0_2; @@ -374,7 +374,7 @@ void EnJsjutan_Update(Actor* thisx, GlobalContext* globalCtx2) { } void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) { - EnJsjutan* this = (EnJsjutan*)thisx; + EnJsjutan* pthis = (EnJsjutan*)thisx; GlobalContext* globalCtx = globalCtx2; s16 i; Actor* parent = thisx->parent; @@ -385,23 +385,23 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) { thisx->world.pos.x = parent->world.pos.x; thisx->world.pos.y = parent->world.pos.y; thisx->world.pos.z = parent->world.pos.z; - this->unk_168 = thisx->world.pos.y; - if (!this->unk_175) { - this->unk_175 = true; - func_80A89860(this, globalCtx); + pthis->unk_168 = thisx->world.pos.y; + if (!pthis->unk_175) { + pthis->unk_175 = true; + func_80A89860(pthis, globalCtx); } - } else if (!this->unk_175) { - this->unk_175 = true; + } else if (!pthis->unk_175) { + pthis->unk_175 = true; thisx->world.pos.x = Math_SinS(parent->shape.rot.y) * 60.0f + parent->world.pos.x; thisx->world.pos.y = (parent->world.pos.y + 5.0f) - 10.0f; thisx->world.pos.z = Math_CosS(parent->shape.rot.y) * 60.0f + parent->world.pos.z; - this->unk_168 = thisx->world.pos.y; - func_80A89860(this, globalCtx); + pthis->unk_168 = thisx->world.pos.y; + func_80A89860(pthis, globalCtx); } - func_80A89A6C(this, globalCtx); - if (this->unk_164) { - this->unk_164 = false; + func_80A89A6C(pthis, globalCtx); + if (pthis->unk_164) { + pthis->unk_164 = false; for (i = 0; i < ARRAY_COUNT(sShadowTex); i++) { if (((u16*)sCarpetTex)[i] != 0) { // Hack to bypass ZAPD exporting textures as u64. sShadowTex[i] = 0xFF; @@ -412,7 +412,7 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) { } func_80093D18(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (s16)this->shadowAlpha); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (s16)pthis->shadowAlpha); Matrix_Translate(thisx->world.pos.x, 3.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, 1.0f, thisx->scale.z, MTXMODE_APPLY); @@ -433,7 +433,7 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_OPA_DISP++, sModelDL); func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(thisx->world.pos.x, this->unk_168 + 3.0f, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, pthis->unk_168 + 3.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_jsjutan.c", 805), diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c deleted file mode 100644 index 08747e8ba..000000000 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ /dev/null @@ -1,359 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAKASI_Z_EN_KAKASI_C -#include "actor_common.h" -/* - * File: z_en_kakasi.c - * Overlay: ovl_En_Kakasi - * Description: Pierre the Scarecrow - */ - -#include "z_en_kakasi.h" -#include "vt.h" -#include "objects/object_ka/object_ka.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_25) - -void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A8F660(EnKakasi* this, GlobalContext* globalCtx); -void func_80A8F75C(EnKakasi* this, GlobalContext* globalCtx); -void func_80A8F8D0(EnKakasi* this, GlobalContext* globalCtx); -void func_80A8F9C8(EnKakasi* this, GlobalContext* globalCtx); -void func_80A8FBB8(EnKakasi* this, GlobalContext* globalCtx); -void func_80A8FAA4(EnKakasi* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -const ActorInit En_Kakasi_InitVars = { - ACTOR_EN_KAKASI, - ACTORCAT_NPC, - FLAGS, - OBJECT_KA, - sizeof(EnKakasi), - (ActorFunc)EnKakasi_Init, - (ActorFunc)EnKakasi_Destroy, - (ActorFunc)EnKakasi_Update, - (ActorFunc)EnKakasi_Draw, -}; - -void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi* this = (EnKakasi*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); - //! @bug SkelAnime_Free is not called -} - -void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi* this = (EnKakasi*)thisx; - - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ Let’s DANCE! ☆☆☆☆☆ %f\n" VT_RST, this->actor.world.pos.y); - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.targetMode = 6; - SkelAnime_InitFlex(globalCtx, &this->skelanime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); - - this->rot = this->actor.world.rot; - this->actor.flags |= ACTOR_FLAG_10; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - - Actor_SetScale(&this->actor, 0.01f); - this->actionFunc = func_80A8F660; -} - -void func_80A8F28C(EnKakasi* this) { - this->unk_1A4 = 0; - this->skelanime.playSpeed = 0.0f; - this->unk_1A8 = this->unk_1AC = 0; - - Math_ApproachZeroF(&this->skelanime.curFrame, 0.5f, 1.0f); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->rot.x, 5, 0x2710, 0); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->rot.y, 5, 0x2710, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->rot.z, 5, 0x2710, 0); -} - -void func_80A8F320(EnKakasi* this, GlobalContext* globalCtx, s16 arg) { - s16 ocarinaNote = globalCtx->msgCtx.lastOcaNoteIdx; - s16 currentFrame; - - if (arg != 0) { - if (this->unk_19C[3] == 0) { - this->unk_19C[3] = (s16)Rand_ZeroFloat(10.99f) + 30; - this->unk_1A6 = (s16)Rand_ZeroFloat(4.99f); - } - - this->unk_19A = (s16)Rand_ZeroFloat(2.99f) + 5; - ocarinaNote = this->unk_1A6; - } - switch (ocarinaNote) { - case OCARINA_NOTE_A: - this->unk_19A++; - if (this->unk_1A4 == 0) { - this->unk_1A4 = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_ROLL); - } - break; - case OCARINA_NOTE_C_DOWN: - this->unk_19A++; - this->unk_1B8 = 1.0f; - break; - case OCARINA_NOTE_C_RIGHT: - this->unk_19A++; - if (this->unk_1AC == 0) { - this->unk_1AC = 0x1388; - } - break; - case OCARINA_NOTE_C_LEFT: - this->unk_19A++; - if (this->unk_1A8 == 0) { - this->unk_1A8 = 0x1388; - } - break; - case OCARINA_NOTE_C_UP: - this->unk_19A++; - this->unk_1B8 = 2.0f; - break; - } - - if (this->unk_19A > 8) { - this->unk_19A = 8; - } - - if (this->unk_19A != 0) { - this->actor.gravity = -1.0f; - if (this->unk_19A == 8 && (this->actor.bgCheckFlags & 1)) { - this->actor.velocity.y = 3.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_KAKASHI_JUMP); - } - Math_ApproachF(&this->skelanime.playSpeed, this->unk_1B8, 0.1f, 0.2f); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_1A8, 5, 0x3E8, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1AC, 5, 0x3E8, 0); - - if (this->unk_1A8 != 0 && fabsf(this->actor.shape.rot.x - this->unk_1A8) < 50.0f) { - this->unk_1A8 *= -1.0f; - } - if (this->unk_1AC != 0 && fabsf(this->actor.shape.rot.z - this->unk_1AC) < 50.0f) { - this->unk_1AC *= -1.0f; - } - - if (this->unk_1A4 != 0) { - this->actor.shape.rot.y += 0x1000; - if (this->actor.shape.rot.y == 0) { - this->unk_1A4 = 0; - } - } - currentFrame = this->skelanime.curFrame; - if (currentFrame == 11 || currentFrame == 17) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); - } - SkelAnime_Update(&this->skelanime); - } -} - -void func_80A8F660(EnKakasi* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); - - Animation_Change(&this->skelanime, &object_ka_Anim_000214, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - - this->actor.textId = 0x4076; - this->unk_196 = TEXT_STATE_DONE; - if (!LINK_IS_ADULT) { - this->unk_194 = false; - if (gSaveContext.scarecrowCustomSongSet) { - this->actor.textId = 0x407A; - this->unk_196 = TEXT_STATE_EVENT; - } - } else { - this->unk_194 = true; - if (gSaveContext.scarecrowCustomSongSet) { - this->actor.textId = 0x4079; - this->unk_196 = TEXT_STATE_EVENT; - } - } - this->actionFunc = func_80A8F75C; -} - -void func_80A8F75C(EnKakasi* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - func_80A8F28C(this); - SkelAnime_Update(&this->skelanime); - this->camId = SUBCAM_NONE; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->unk_196 == TEXT_STATE_EVENT) { - this->actionFunc = func_80A8F9C8; - } else { - this->actionFunc = func_80A8F660; - } - } else { - s16 yawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (!(this->actor.xzDistToPlayer > 120.0f)) { - s16 absyawTowardsPlayer = ABS(yawTowardsPlayer); - - if (absyawTowardsPlayer < 0x4300) { - if (!this->unk_194) { - if (player->stateFlags2 & 0x1000000) { - this->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &this->actor, MAIN_CAM); - - func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_LONG_RECORDING); - this->unk_19A = 0; - this->unk_1B8 = 0.0; - player->stateFlags2 |= 0x800000; - this->actionFunc = func_80A8F8D0; - return; - } - if (this->actor.xzDistToPlayer < 80.0f) { - player->stateFlags2 |= 0x800000; - } - } - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - } -} - -void func_80A8F8D0(EnKakasi* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04 && globalCtx->msgCtx.msgMode == MSGMODE_NONE) { - // "end?" - osSyncPrintf(VT_FGCOL(BLUE) "☆☆☆☆☆ 終り? ☆☆☆☆☆ \n" VT_RST); - - if (this->unk_19A != 0) { - Message_CloseTextbox(globalCtx); - this->actor.textId = 0x4077; - this->unk_196 = TEXT_STATE_EVENT; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->actionFunc = func_80A8F9C8; - } else { - OnePointCutscene_EndCutscene(globalCtx, this->camId); - this->camId = SUBCAM_NONE; - this->actionFunc = func_80A8F660; - } - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - func_80A8F320(this, globalCtx, 0); - player->stateFlags2 |= 0x800000; - } -} - -void func_80A8F9C8(EnKakasi* this, GlobalContext* globalCtx) { - func_80A8F28C(this); - SkelAnime_Update(&this->skelanime); - func_8002DF54(globalCtx, NULL, 8); - - if (this->unk_196 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - - if (this->camId != SUBCAM_NONE) { - func_8005B1A4(globalCtx->cameraPtrs[this->camId]); - } - this->camId = OnePointCutscene_Init(globalCtx, 2270, -99, &this->actor, MAIN_CAM); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - func_8002DF54(globalCtx, NULL, 8); - func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_LONG_PLAYBACK); - this->actionFunc = func_80A8FAA4; - } -} - -void func_80A8FAA4(EnKakasi* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.ocarinaMode != OCARINA_MODE_0F) { - func_80A8F320(this, globalCtx, 1); - return; - } - - osSyncPrintf("game_play->message.msg_mode=%d\n", globalCtx->msgCtx.msgMode); - - if (globalCtx->msgCtx.msgMode == MSGMODE_NONE) { - if (this->unk_194) { - this->actor.textId = 0x4077; - this->unk_196 = TEXT_STATE_EVENT; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - } else { - this->actor.textId = 0x4078; - this->unk_196 = TEXT_STATE_EVENT; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - } - this->actionFunc = func_80A8FBB8; - OnePointCutscene_EndCutscene(globalCtx, this->camId); - this->camId = SUBCAM_NONE; - this->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &this->actor, MAIN_CAM); - func_8005B1A4(globalCtx->cameraPtrs[this->camId]); - } -} - -void func_80A8FBB8(EnKakasi* this, GlobalContext* globalCtx) { - func_80A8F28C(this); - SkelAnime_Update(&this->skelanime); - - if (this->unk_196 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - func_8005B1A4(globalCtx->cameraPtrs[this->camId]); - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = func_80A8F660; - } -} - -void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi* this = (EnKakasi*)thisx; - s32 pad; - s32 i; - - this->unk_198++; - this->actor.world.rot = this->actor.shape.rot; - for (i = 0; i < ARRAY_COUNT(this->unk_19C); i++) { - if (this->unk_19C[i] != 0) { - this->unk_19C[i]--; - } - } - - this->height = 60.0f; - Actor_SetFocus(&this->actor, this->height); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 28); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi* this = (EnKakasi*)thisx; - - if (BREG(3) != 0) { - osSyncPrintf("\n\n"); - // "flag!" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.scarecrowCustomSongSet); - } - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, - NULL, NULL, this); -} diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.cpp b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.cpp new file mode 100644 index 000000000..a4e18fe61 --- /dev/null +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.cpp @@ -0,0 +1,359 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAKASI_Z_EN_KAKASI_C +#include "actor_common.h" +/* + * File: z_en_kakasi.c + * Overlay: ovl_En_Kakasi + * Description: Pierre the Scarecrow + */ + +#include "z_en_kakasi.h" +#include "vt.h" +#include "objects/object_ka/object_ka.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_25) + +void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A8F660(EnKakasi* pthis, GlobalContext* globalCtx); +void func_80A8F75C(EnKakasi* pthis, GlobalContext* globalCtx); +void func_80A8F8D0(EnKakasi* pthis, GlobalContext* globalCtx); +void func_80A8F9C8(EnKakasi* pthis, GlobalContext* globalCtx); +void func_80A8FBB8(EnKakasi* pthis, GlobalContext* globalCtx); +void func_80A8FAA4(EnKakasi* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +ActorInit En_Kakasi_InitVars = { + ACTOR_EN_KAKASI, + ACTORCAT_NPC, + FLAGS, + OBJECT_KA, + sizeof(EnKakasi), + (ActorFunc)EnKakasi_Init, + (ActorFunc)EnKakasi_Destroy, + (ActorFunc)EnKakasi_Update, + (ActorFunc)EnKakasi_Draw, +}; + +void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* pthis = (EnKakasi*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); + //! @bug SkelAnime_Free is not called +} + +void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* pthis = (EnKakasi*)thisx; + + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ Let’s DANCE! ☆☆☆☆☆ %f\n" VT_RST, pthis->actor.world.pos.y); + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.targetMode = 6; + SkelAnime_InitFlex(globalCtx, &pthis->skelanime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); + + pthis->rot = pthis->actor.world.rot; + pthis->actor.flags |= ACTOR_FLAG_10; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actionFunc = func_80A8F660; +} + +void func_80A8F28C(EnKakasi* pthis) { + pthis->unk_1A4 = 0; + pthis->skelanime.playSpeed = 0.0f; + pthis->unk_1A8 = pthis->unk_1AC = 0; + + Math_ApproachZeroF(&pthis->skelanime.curFrame, 0.5f, 1.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->rot.x, 5, 0x2710, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->rot.y, 5, 0x2710, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->rot.z, 5, 0x2710, 0); +} + +void func_80A8F320(EnKakasi* pthis, GlobalContext* globalCtx, s16 arg) { + s16 ocarinaNote = globalCtx->msgCtx.lastOcaNoteIdx; + s16 currentFrame; + + if (arg != 0) { + if (pthis->unk_19C[3] == 0) { + pthis->unk_19C[3] = (s16)Rand_ZeroFloat(10.99f) + 30; + pthis->unk_1A6 = (s16)Rand_ZeroFloat(4.99f); + } + + pthis->unk_19A = (s16)Rand_ZeroFloat(2.99f) + 5; + ocarinaNote = pthis->unk_1A6; + } + switch (ocarinaNote) { + case OCARINA_NOTE_A: + pthis->unk_19A++; + if (pthis->unk_1A4 == 0) { + pthis->unk_1A4 = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KAKASHI_ROLL); + } + break; + case OCARINA_NOTE_C_DOWN: + pthis->unk_19A++; + pthis->unk_1B8 = 1.0f; + break; + case OCARINA_NOTE_C_RIGHT: + pthis->unk_19A++; + if (pthis->unk_1AC == 0) { + pthis->unk_1AC = 0x1388; + } + break; + case OCARINA_NOTE_C_LEFT: + pthis->unk_19A++; + if (pthis->unk_1A8 == 0) { + pthis->unk_1A8 = 0x1388; + } + break; + case OCARINA_NOTE_C_UP: + pthis->unk_19A++; + pthis->unk_1B8 = 2.0f; + break; + } + + if (pthis->unk_19A > 8) { + pthis->unk_19A = 8; + } + + if (pthis->unk_19A != 0) { + pthis->actor.gravity = -1.0f; + if (pthis->unk_19A == 8 && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.velocity.y = 3.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_KAKASHI_JUMP); + } + Math_ApproachF(&pthis->skelanime.playSpeed, pthis->unk_1B8, 0.1f, 0.2f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->unk_1A8, 5, 0x3E8, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->unk_1AC, 5, 0x3E8, 0); + + if (pthis->unk_1A8 != 0 && fabsf(pthis->actor.shape.rot.x - pthis->unk_1A8) < 50.0f) { + pthis->unk_1A8 *= -1.0f; + } + if (pthis->unk_1AC != 0 && fabsf(pthis->actor.shape.rot.z - pthis->unk_1AC) < 50.0f) { + pthis->unk_1AC *= -1.0f; + } + + if (pthis->unk_1A4 != 0) { + pthis->actor.shape.rot.y += 0x1000; + if (pthis->actor.shape.rot.y == 0) { + pthis->unk_1A4 = 0; + } + } + currentFrame = pthis->skelanime.curFrame; + if (currentFrame == 11 || currentFrame == 17) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KAKASHI_SWING); + } + SkelAnime_Update(&pthis->skelanime); + } +} + +void func_80A8F660(EnKakasi* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); + + Animation_Change(&pthis->skelanime, &object_ka_Anim_000214, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + + pthis->actor.textId = 0x4076; + pthis->unk_196 = TEXT_STATE_DONE; + if (!LINK_IS_ADULT) { + pthis->unk_194 = false; + if (gSaveContext.scarecrowCustomSongSet) { + pthis->actor.textId = 0x407A; + pthis->unk_196 = TEXT_STATE_EVENT; + } + } else { + pthis->unk_194 = true; + if (gSaveContext.scarecrowCustomSongSet) { + pthis->actor.textId = 0x4079; + pthis->unk_196 = TEXT_STATE_EVENT; + } + } + pthis->actionFunc = func_80A8F75C; +} + +void func_80A8F75C(EnKakasi* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80A8F28C(pthis); + SkelAnime_Update(&pthis->skelanime); + pthis->camId = SUBCAM_NONE; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->unk_196 == TEXT_STATE_EVENT) { + pthis->actionFunc = func_80A8F9C8; + } else { + pthis->actionFunc = func_80A8F660; + } + } else { + s16 yawTowardsPlayer = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (!(pthis->actor.xzDistToPlayer > 120.0f)) { + s16 absyawTowardsPlayer = ABS(yawTowardsPlayer); + + if (absyawTowardsPlayer < 0x4300) { + if (!pthis->unk_194) { + if (player->stateFlags2 & 0x1000000) { + pthis->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &pthis->actor, MAIN_CAM); + + func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_LONG_RECORDING); + pthis->unk_19A = 0; + pthis->unk_1B8 = 0.0; + player->stateFlags2 |= 0x800000; + pthis->actionFunc = func_80A8F8D0; + return; + } + if (pthis->actor.xzDistToPlayer < 80.0f) { + player->stateFlags2 |= 0x800000; + } + } + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + } +} + +void func_80A8F8D0(EnKakasi* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04 && globalCtx->msgCtx.msgMode == MSGMODE_NONE) { + // "end?" + osSyncPrintf(VT_FGCOL(BLUE) "☆☆☆☆☆ 終り? ☆☆☆☆☆ \n" VT_RST); + + if (pthis->unk_19A != 0) { + Message_CloseTextbox(globalCtx); + pthis->actor.textId = 0x4077; + pthis->unk_196 = TEXT_STATE_EVENT; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->actionFunc = func_80A8F9C8; + } else { + OnePointCutscene_EndCutscene(globalCtx, pthis->camId); + pthis->camId = SUBCAM_NONE; + pthis->actionFunc = func_80A8F660; + } + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { + func_80A8F320(pthis, globalCtx, 0); + player->stateFlags2 |= 0x800000; + } +} + +void func_80A8F9C8(EnKakasi* pthis, GlobalContext* globalCtx) { + func_80A8F28C(pthis); + SkelAnime_Update(&pthis->skelanime); + func_8002DF54(globalCtx, NULL, 8); + + if (pthis->unk_196 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + + if (pthis->camId != SUBCAM_NONE) { + func_8005B1A4(globalCtx->cameraPtrs[pthis->camId]); + } + pthis->camId = OnePointCutscene_Init(globalCtx, 2270, -99, &pthis->actor, MAIN_CAM); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + func_8002DF54(globalCtx, NULL, 8); + func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_LONG_PLAYBACK); + pthis->actionFunc = func_80A8FAA4; + } +} + +void func_80A8FAA4(EnKakasi* pthis, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode != OCARINA_MODE_0F) { + func_80A8F320(pthis, globalCtx, 1); + return; + } + + osSyncPrintf("game_play->message.msg_mode=%d\n", globalCtx->msgCtx.msgMode); + + if (globalCtx->msgCtx.msgMode == MSGMODE_NONE) { + if (pthis->unk_194) { + pthis->actor.textId = 0x4077; + pthis->unk_196 = TEXT_STATE_EVENT; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + } else { + pthis->actor.textId = 0x4078; + pthis->unk_196 = TEXT_STATE_EVENT; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + } + pthis->actionFunc = func_80A8FBB8; + OnePointCutscene_EndCutscene(globalCtx, pthis->camId); + pthis->camId = SUBCAM_NONE; + pthis->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &pthis->actor, MAIN_CAM); + func_8005B1A4(globalCtx->cameraPtrs[pthis->camId]); + } +} + +void func_80A8FBB8(EnKakasi* pthis, GlobalContext* globalCtx) { + func_80A8F28C(pthis); + SkelAnime_Update(&pthis->skelanime); + + if (pthis->unk_196 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + func_8005B1A4(globalCtx->cameraPtrs[pthis->camId]); + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = func_80A8F660; + } +} + +void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* pthis = (EnKakasi*)thisx; + s32 pad; + s32 i; + + pthis->unk_198++; + pthis->actor.world.rot = pthis->actor.shape.rot; + for (i = 0; i < ARRAY_COUNT(pthis->unk_19C); i++) { + if (pthis->unk_19C[i] != 0) { + pthis->unk_19C[i]--; + } + } + + pthis->height = 60.0f; + Actor_SetFocus(&pthis->actor, pthis->height); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 28); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* pthis = (EnKakasi*)thisx; + + if (BREG(3) != 0) { + osSyncPrintf("\n\n"); + // "flag!" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.scarecrowCustomSongSet); + } + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, pthis->skelanime.dListCount, + NULL, NULL, pthis); +} diff --git a/src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.c b/src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.c deleted file mode 100644 index 5d3c8e722..000000000 --- a/src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.c +++ /dev/null @@ -1,234 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAKASI2_Z_EN_KAKASI2_C -#include "actor_common.h" -/* - * File: z_en_kakasi2.c - * Overlay: ovl_En_Kakasi2 - * Description: Pierre the Scarecrow Spawn - */ - -#include "z_en_kakasi2.h" -#include "vt.h" -#include "objects/object_ka/object_ka.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25 | ACTOR_FLAG_27) - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -void EnKakasi2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi2_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80A90948(Actor* thisx, GlobalContext* globalCtx); - -void func_80A9062C(EnKakasi2* this, GlobalContext* globalCtx); -void func_80A90264(EnKakasi2* this, GlobalContext* globalCtx); -void func_80A904D8(EnKakasi2* this, GlobalContext* globalCtx); -void func_80A90578(EnKakasi2* this, GlobalContext* globalCtx); -void func_80A906C4(EnKakasi2* this, GlobalContext* globalCtx); - -const ActorInit En_Kakasi2_InitVars = { - ACTOR_EN_KAKASI2, - ACTORCAT_PROP, - FLAGS, - OBJECT_KA, - sizeof(EnKakasi2), - (ActorFunc)EnKakasi2_Init, - (ActorFunc)EnKakasi2_Destroy, - (ActorFunc)EnKakasi2_Update, - NULL, -}; - -void EnKakasi2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi2* this = (EnKakasi2*)thisx; - s32 pad; - f32 spawnRangeY; - f32 spawnRangeXZ; - - osSyncPrintf("\n\n"); - // "Visit Umeda" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 梅田参号見参! ☆☆☆☆☆ \n" VT_RST); - - this->switchFlag = this->actor.params & 0x3F; - spawnRangeY = (this->actor.params >> 6) & 0xFF; - spawnRangeXZ = this->actor.world.rot.z; - if (this->switchFlag == 0x3F) { - this->switchFlag = -1; - } - this->actor.targetMode = 4; - this->maxSpawnDistance.x = (spawnRangeY * 40.0f) + 40.0f; - this->maxSpawnDistance.y = (spawnRangeXZ * 40.0f) + 40.0f; - - // "Former? (Argument 0)" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 元?(引数0) ☆☆☆☆ %f\n" VT_RST, spawnRangeY); - // "Former? (Z angle)" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 元?(Zアングル) ☆☆ %f\n" VT_RST, spawnRangeXZ); - // "Correction coordinates X" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 補正座標X ☆☆☆☆☆ %f\n" VT_RST, this->maxSpawnDistance.x); - // "Correction coordinates Y" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 補正座標Y ☆☆☆☆☆ %f\n" VT_RST, this->maxSpawnDistance.y); - // "Correction coordinates Z" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 補正座標Z ☆☆☆☆☆ %f\n" VT_RST, this->maxSpawnDistance.z); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ SAVE ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - osSyncPrintf("\n\n"); - - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->height = 60.0f; - Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= ACTOR_FLAG_10; - this->unk_198 = this->actor.shape.rot.y; - - if (this->switchFlag >= 0 && Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actor.draw = func_80A90948; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); - this->actionFunc = func_80A9062C; - } else { - this->actionFunc = func_80A90264; - this->actor.shape.yOffset = -8000.0f; - } -} - -void EnKakasi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi2* this = (EnKakasi2*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); - //! @bug SkelAnime_Free is not called -} - -void func_80A90264(EnKakasi2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_194++; - - if ((BREG(1) != 0) && (this->actor.xzDistToPlayer < this->maxSpawnDistance.x) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < this->maxSpawnDistance.y)) { - - this->actor.draw = func_80A90948; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); - OnePointCutscene_Attention(globalCtx, &this->actor); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_27; - - func_80078884(NA_SE_SY_CORRECT_CHIME); - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ SAVE 終了 ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - this->actionFunc = func_80A904D8; - } else if ((this->actor.xzDistToPlayer < this->maxSpawnDistance.x) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < this->maxSpawnDistance.y) && - (gSaveContext.eventChkInf[9] & 0x1000)) { - - this->unk_194 = 0; - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0B) { - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ SAVE 終了 ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - this->actor.draw = func_80A90948; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, - 0); - OnePointCutscene_Attention(globalCtx, &this->actor); - func_80078884(NA_SE_SY_CORRECT_CHIME); - - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_27; - this->actionFunc = func_80A904D8; - } - } -} - -void func_80A904D8(EnKakasi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); - - Animation_Change(&this->skelAnime, &object_ka_Anim_000214, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_COME_UP_DEKU_JR); - this->actionFunc = func_80A90578; -} - -void func_80A90578(EnKakasi2* this, GlobalContext* globalCtx) { - s16 currentFrame; - - SkelAnime_Update(&this->skelAnime); - - currentFrame = this->skelAnime.curFrame; - if (currentFrame == 11 || currentFrame == 17) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); - } - - this->actor.shape.rot.y += 0x800; - Math_ApproachZeroF(&this->actor.shape.yOffset, 0.5f, 500.0f); - - if (this->actor.shape.yOffset > -100.0f) { - this->actionFunc = func_80A9062C; - this->actor.shape.yOffset = 0.0f; - } -} - -void func_80A9062C(EnKakasi2* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); - - Animation_Change(&this->skelAnime, &object_ka_Anim_000214, 0.0f, 0.0f, (s16)frameCount, ANIMMODE_ONCE, -10.0f); - this->actionFunc = func_80A906C4; -} - -void func_80A906C4(EnKakasi2* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame != 0) { - Math_ApproachZeroF(&this->skelAnime.curFrame, 0.5f, 1.0f); - } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_198, 5, 0xBB8, 0); - SkelAnime_Update(&this->skelAnime); -} - -void EnKakasi2_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnKakasi2* this = (EnKakasi2*)thisx; - GlobalContext* globalCtx = globalCtx2; - - this->actor.world.rot = this->actor.shape.rot; - Actor_SetFocus(&this->actor, this->height); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - - if (this->actor.shape.yOffset == 0.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void func_80A90948(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi2* this = (EnKakasi2*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); -} diff --git a/src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.cpp b/src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.cpp new file mode 100644 index 000000000..5403f1e09 --- /dev/null +++ b/src/overlays/actors/ovl_En_Kakasi2/z_en_kakasi2.cpp @@ -0,0 +1,234 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAKASI2_Z_EN_KAKASI2_C +#include "actor_common.h" +/* + * File: z_en_kakasi2.c + * Overlay: ovl_En_Kakasi2 + * Description: Pierre the Scarecrow Spawn + */ + +#include "z_en_kakasi2.h" +#include "vt.h" +#include "objects/object_ka/object_ka.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25 | ACTOR_FLAG_27) + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +void EnKakasi2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi2_Update(Actor* thisx, GlobalContext* globalCtx); +void func_80A90948(Actor* thisx, GlobalContext* globalCtx); + +void func_80A9062C(EnKakasi2* pthis, GlobalContext* globalCtx); +void func_80A90264(EnKakasi2* pthis, GlobalContext* globalCtx); +void func_80A904D8(EnKakasi2* pthis, GlobalContext* globalCtx); +void func_80A90578(EnKakasi2* pthis, GlobalContext* globalCtx); +void func_80A906C4(EnKakasi2* pthis, GlobalContext* globalCtx); + +ActorInit En_Kakasi2_InitVars = { + ACTOR_EN_KAKASI2, + ACTORCAT_PROP, + FLAGS, + OBJECT_KA, + sizeof(EnKakasi2), + (ActorFunc)EnKakasi2_Init, + (ActorFunc)EnKakasi2_Destroy, + (ActorFunc)EnKakasi2_Update, + NULL, +}; + +void EnKakasi2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi2* pthis = (EnKakasi2*)thisx; + s32 pad; + f32 spawnRangeY; + f32 spawnRangeXZ; + + osSyncPrintf("\n\n"); + // "Visit Umeda" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 梅田参号見参! ☆☆☆☆☆ \n" VT_RST); + + pthis->switchFlag = pthis->actor.params & 0x3F; + spawnRangeY = (pthis->actor.params >> 6) & 0xFF; + spawnRangeXZ = pthis->actor.world.rot.z; + if (pthis->switchFlag == 0x3F) { + pthis->switchFlag = -1; + } + pthis->actor.targetMode = 4; + pthis->maxSpawnDistance.x = (spawnRangeY * 40.0f) + 40.0f; + pthis->maxSpawnDistance.y = (spawnRangeXZ * 40.0f) + 40.0f; + + // "Former? (Argument 0)" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 元?(引数0) ☆☆☆☆ %f\n" VT_RST, spawnRangeY); + // "Former? (Z angle)" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 元?(Zアングル) ☆☆ %f\n" VT_RST, spawnRangeXZ); + // "Correction coordinates X" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 補正座標X ☆☆☆☆☆ %f\n" VT_RST, pthis->maxSpawnDistance.x); + // "Correction coordinates Y" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 補正座標Y ☆☆☆☆☆ %f\n" VT_RST, pthis->maxSpawnDistance.y); + // "Correction coordinates Z" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 補正座標Z ☆☆☆☆☆ %f\n" VT_RST, pthis->maxSpawnDistance.z); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ SAVE ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + osSyncPrintf("\n\n"); + + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->height = 60.0f; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.flags |= ACTOR_FLAG_10; + pthis->unk_198 = pthis->actor.shape.rot.y; + + if (pthis->switchFlag >= 0 && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actor.draw = func_80A90948; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); + pthis->actionFunc = func_80A9062C; + } else { + pthis->actionFunc = func_80A90264; + pthis->actor.shape.yOffset = -8000.0f; + } +} + +void EnKakasi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi2* pthis = (EnKakasi2*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); + //! @bug SkelAnime_Free is not called +} + +void func_80A90264(EnKakasi2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_194++; + + if ((BREG(1) != 0) && (pthis->actor.xzDistToPlayer < pthis->maxSpawnDistance.x) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < pthis->maxSpawnDistance.y)) { + + pthis->actor.draw = func_80A90948; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); + OnePointCutscene_Attention(globalCtx, &pthis->actor); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_27; + + func_80078884(NA_SE_SY_CORRECT_CHIME); + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ SAVE 終了 ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + pthis->actionFunc = func_80A904D8; + } else if ((pthis->actor.xzDistToPlayer < pthis->maxSpawnDistance.x) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < pthis->maxSpawnDistance.y) && + (gSaveContext.eventChkInf[9] & 0x1000)) { + + pthis->unk_194 = 0; + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0B) { + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ SAVE 終了 ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + pthis->actor.draw = func_80A90948; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, + 0); + OnePointCutscene_Attention(globalCtx, &pthis->actor); + func_80078884(NA_SE_SY_CORRECT_CHIME); + + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_27; + pthis->actionFunc = func_80A904D8; + } + } +} + +void func_80A904D8(EnKakasi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); + + Animation_Change(&pthis->skelAnime, &object_ka_Anim_000214, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_COME_UP_DEKU_JR); + pthis->actionFunc = func_80A90578; +} + +void func_80A90578(EnKakasi2* pthis, GlobalContext* globalCtx) { + s16 currentFrame; + + SkelAnime_Update(&pthis->skelAnime); + + currentFrame = pthis->skelAnime.curFrame; + if (currentFrame == 11 || currentFrame == 17) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KAKASHI_SWING); + } + + pthis->actor.shape.rot.y += 0x800; + Math_ApproachZeroF(&pthis->actor.shape.yOffset, 0.5f, 500.0f); + + if (pthis->actor.shape.yOffset > -100.0f) { + pthis->actionFunc = func_80A9062C; + pthis->actor.shape.yOffset = 0.0f; + } +} + +void func_80A9062C(EnKakasi2* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); + + Animation_Change(&pthis->skelAnime, &object_ka_Anim_000214, 0.0f, 0.0f, (s16)frameCount, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = func_80A906C4; +} + +void func_80A906C4(EnKakasi2* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame != 0) { + Math_ApproachZeroF(&pthis->skelAnime.curFrame, 0.5f, 1.0f); + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->unk_198, 5, 0xBB8, 0); + SkelAnime_Update(&pthis->skelAnime); +} + +void EnKakasi2_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnKakasi2* pthis = (EnKakasi2*)thisx; + GlobalContext* globalCtx = globalCtx2; + + pthis->actor.world.rot = pthis->actor.shape.rot; + Actor_SetFocus(&pthis->actor, pthis->height); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + + if (pthis->actor.shape.yOffset == 0.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void func_80A90948(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi2* pthis = (EnKakasi2*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); +} diff --git a/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c b/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c deleted file mode 100644 index 74ae99827..000000000 --- a/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c +++ /dev/null @@ -1,451 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAKASI3_Z_EN_KAKASI3_C -#include "actor_common.h" -/* - * File: z_en_kakasi3.c - * Overlay: ovl_En_Kakasi3 - * Description: Bonooru the Scarecrow - */ - -#include "z_en_kakasi3.h" -#include "vt.h" -#include "objects/object_ka/object_ka.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_25) - -void EnKakasi3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi3_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80A911F0(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A91284(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A91348(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A915B8(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A91620(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A91760(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A917FC(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A9187C(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A918E4(EnKakasi3* this, GlobalContext* globalCtx); -void func_80A91A90(EnKakasi3* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -const ActorInit En_Kakasi3_InitVars = { - ACTOR_EN_KAKASI3, - ACTORCAT_NPC, - FLAGS, - OBJECT_KA, - sizeof(EnKakasi3), - (ActorFunc)EnKakasi3_Init, - (ActorFunc)EnKakasi3_Destroy, - (ActorFunc)EnKakasi3_Update, - (ActorFunc)EnKakasi3_Draw, -}; - -void EnKakasi3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi3* this = (EnKakasi3*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); - //! @bug SkelAnime_Free is not called -} - -void EnKakasi3_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi3* this = (EnKakasi3*)thisx; - - osSyncPrintf("\n\n"); - // "Obonur" -- Related to the name of the scarecrow (Bonooru) - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ おーボヌール ☆☆☆☆☆ \n" VT_RST); - this->actor.targetMode = 6; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); - this->actor.flags |= ACTOR_FLAG_10; - this->rot = this->actor.world.rot; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - this->actionFunc = func_80A911F0; -} - -void func_80A90E28(EnKakasi3* this) { - this->unk_1A4 = 0; - this->skelAnime.playSpeed = 0.0f; - this->unk_1AA = this->unk_1AE = 0x0; - - Math_ApproachZeroF(&this->skelAnime.curFrame, 0.5f, 1.0f); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->rot.x, 5, 0x2710, 0); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->rot.y, 5, 0x2710, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->rot.z, 5, 0x2710, 0); -} - -void func_80A90EBC(EnKakasi3* this, GlobalContext* globalCtx, s32 arg) { - s16 currentFrame; - s16 ocarinaNote = globalCtx->msgCtx.lastOcaNoteIdx; - - if (arg != 0) { - if (this->unk_19C[3] == 0) { - this->unk_19C[3] = (s16)Rand_ZeroFloat(10.99f) + 30; - this->unk_1A6 = (s16)Rand_ZeroFloat(4.99f); - } - - this->unk_19A = (s16)Rand_ZeroFloat(2.99f) + 5; - ocarinaNote = this->unk_1A6; - } - switch (ocarinaNote) { - case OCARINA_NOTE_A: - this->unk_19A++; - if (this->unk_1A4 == 0) { - this->unk_1A4 = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_ROLL); - } - break; - case OCARINA_NOTE_C_DOWN: - this->unk_19A++; - this->unk_1B8 = 1.0f; - break; - case OCARINA_NOTE_C_RIGHT: - this->unk_19A++; - if (this->unk_1AE == 0x0) { - this->unk_1AE = 0x1388; - } - break; - case OCARINA_NOTE_C_LEFT: - this->unk_19A++; - if (this->unk_1AA == 0x0) { - this->unk_1AA = 0x1388; - } - break; - case OCARINA_NOTE_C_UP: - this->unk_19A++; - this->unk_1B8 = 2.0f; - break; - } - - if (this->unk_19A > 8) { - this->unk_19A = 8; - } - - if (this->unk_19A != 0) { - this->actor.gravity = -1.0f; - if (this->unk_19A == 8 && (this->actor.bgCheckFlags & 1)) { - this->actor.velocity.y = 3.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_KAKASHI_JUMP); - } - Math_ApproachF(&this->skelAnime.playSpeed, this->unk_1B8, 0.1f, 0.2f); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_1AA, 0x5, 0x3E8, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1AE, 0x5, 0x3E8, 0); - - if (this->unk_1AA != 0x0 && fabsf(this->actor.shape.rot.x - this->unk_1AA) < 50.0f) { - this->unk_1AA *= -1.0f; - } - if (this->unk_1AE != 0x0 && fabsf(this->actor.shape.rot.z - this->unk_1AE) < 50.0f) { - this->unk_1AE *= -1.0f; - } - - if (this->unk_1A4 != 0) { - this->actor.shape.rot.y += 0x1000; - if (this->actor.shape.rot.y == 0) { - this->unk_1A4 = 0; - } - } - currentFrame = this->skelAnime.curFrame; - if (currentFrame == 11 || currentFrame == 17) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); - } - SkelAnime_Update(&this->skelAnime); - } -} - -void func_80A911F0(EnKakasi3* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); - - Animation_Change(&this->skelAnime, &object_ka_Anim_000214, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->actionFunc = func_80A91284; -} - -void func_80A91284(EnKakasi3* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - this->actor.textId = 0x40A1; - this->dialogState = TEXT_STATE_DONE; - this->unk_19A = 0; - - if (!LINK_IS_ADULT) { - this->unk_194 = false; - if (gSaveContext.scarecrowSpawnSongSet) { - this->actor.textId = 0x40A0; - this->dialogState = TEXT_STATE_EVENT; - this->unk_1A8 = 1; - } - } else { - this->unk_194 = true; - if (gSaveContext.scarecrowSpawnSongSet) { - if (this->unk_195) { - this->actor.textId = 0x40A2; - } else { - this->actor.textId = 0x40A3; - } - } - } - this->actionFunc = func_80A91348; -} - -void func_80A91348(EnKakasi3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - func_80A90E28(this); - SkelAnime_Update(&this->skelAnime); - this->camId = SUBCAM_NONE; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (!this->unk_194) { - if (this->unk_1A8 == 0) { - this->actionFunc = func_80A91284; - } else { - this->actionFunc = func_80A91760; - } - } else { - this->actionFunc = func_80A91284; - } - } else { - s16 angleTowardsLink = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (!(this->actor.xzDistToPlayer > 120.0f)) { - s16 absAngleTowardsLink = ABS(angleTowardsLink); - - if (absAngleTowardsLink < 0x4300) { - if (!this->unk_194) { - - if (player->stateFlags2 & 0x1000000) { - this->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &this->actor, MAIN_CAM); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->dialogState = TEXT_STATE_EVENT; - this->unk_1B8 = 0.0f; - Message_StartTextbox(globalCtx, 0x40A4, NULL); - player->stateFlags2 |= 0x800000; - this->actionFunc = func_80A915B8; - return; - } - if (this->actor.xzDistToPlayer < 80.0f) { - player->stateFlags2 |= 0x800000; - } - } else if (gSaveContext.scarecrowSpawnSongSet && !this->unk_195) { - - if (player->stateFlags2 & 0x1000000) { - this->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &this->actor, MAIN_CAM); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->dialogState = TEXT_STATE_EVENT; - this->unk_1B8 = 0.0f; - Message_StartTextbox(globalCtx, 0x40A8, NULL); - player->stateFlags2 |= 0x800000; - this->actionFunc = func_80A9187C; - return; - } - if (this->actor.xzDistToPlayer < 80.0f) { - player->stateFlags2 |= 0x800000; - } - } - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - } -} - -void func_80A915B8(EnKakasi3* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_RECORDING); - this->actionFunc = func_80A91620; - } -} - -void func_80A91620(EnKakasi3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04 || - (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05 && globalCtx->msgCtx.ocarinaMode < OCARINA_MODE_0B)) && - (globalCtx->msgCtx.msgMode == MSGMODE_NONE)) { - - OnePointCutscene_EndCutscene(globalCtx, this->camId); - if (globalCtx->cameraPtrs[this->camId] == NULL) { - this->camId = SUBCAM_NONE; - } - if (this->camId != SUBCAM_NONE) { - func_8005B1A4(globalCtx->cameraPtrs[this->camId]); - } - this->actionFunc = func_80A911F0; - return; - } - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03 && globalCtx->msgCtx.msgMode == MSGMODE_NONE) { - this->dialogState = TEXT_STATE_EVENT; - Message_StartTextbox(globalCtx, 0x40A5, NULL); - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_80A91A90; - return; - } - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - func_80A90EBC(this, globalCtx, 0); - player->stateFlags2 |= 0x800000; - } -} - -void func_80A91760(EnKakasi3* this, GlobalContext* globalCtx) { - - func_80A90E28(this); - SkelAnime_Update(&this->skelAnime); - if (this->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_PLAYBACK); - this->actionFunc = func_80A917FC; - this->camId = OnePointCutscene_Init(globalCtx, 2280, -99, &this->actor, MAIN_CAM); - } -} - -void func_80A917FC(EnKakasi3* this, GlobalContext* globalCtx) { - - if (globalCtx->msgCtx.ocarinaMode != OCARINA_MODE_0F) { - func_80A90EBC(this, globalCtx, 1); - } else { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - Message_CloseTextbox(globalCtx); - OnePointCutscene_EndCutscene(globalCtx, this->camId); - this->actionFunc = func_80A911F0; - } -} - -void func_80A9187C(EnKakasi3* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_SCARECROW); - this->actionFunc = func_80A918E4; - } -} - -void func_80A918E4(EnKakasi3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (BREG(3) != 0) { - // "No way!" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ まさか! ☆☆☆☆☆ %d\n" VT_RST, globalCtx->msgCtx.ocarinaMode); - } - if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04 || - (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05 && globalCtx->msgCtx.ocarinaMode < OCARINA_MODE_0B)) && - globalCtx->msgCtx.msgMode == MSGMODE_NONE) { - - Message_StartTextbox(globalCtx, 0x40A6, NULL); - this->dialogState = TEXT_STATE_EVENT; - OnePointCutscene_EndCutscene(globalCtx, this->camId); - this->camId = SUBCAM_NONE; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_80A91A90; - return; - } - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03 && globalCtx->msgCtx.msgMode == MSGMODE_NONE) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - if (BREG(3) != 0) { - osSyncPrintf("\n\n"); - // "With this, other guys are OK! That's it!" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ これで、他の奴もOK!だ! ☆☆☆☆☆ %d\n" VT_RST, - globalCtx->msgCtx.ocarinaMode); - } - this->unk_195 = true; - Message_StartTextbox(globalCtx, 0x40A7, NULL); - this->dialogState = TEXT_STATE_EVENT; - func_8002DF54(globalCtx, NULL, 8); - this->actionFunc = func_80A91A90; - return; - } - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - func_80A90EBC(this, globalCtx, 0); - player->stateFlags2 |= 0x800000; - } -} - -void func_80A91A90(EnKakasi3* this, GlobalContext* globalCtx) { - func_80A90E28(this); - SkelAnime_Update(&this->skelAnime); - func_8002DF54(globalCtx, NULL, 8); - - if (this->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - if (this->unk_195) { - if (!(gSaveContext.eventChkInf[9] & 0x1000)) { - gSaveContext.eventChkInf[9] |= 0x1000; - } - } - if (globalCtx->cameraPtrs[this->camId] == NULL) { - this->camId = SUBCAM_NONE; - } - if (this->camId != SUBCAM_NONE) { - func_8005B1A4(globalCtx->cameraPtrs[this->camId]); - } - Message_CloseTextbox(globalCtx); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - func_8002DF54(globalCtx, NULL, 7); - this->actionFunc = func_80A911F0; - } -} - -void EnKakasi3_Update(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi3* this = (EnKakasi3*)thisx; - s32 pad; - s32 i; - - if (BREG(2) != 0) { - osSyncPrintf("\n\n"); - // "flag!" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.scarecrowSpawnSongSet); - } - - this->unk_198++; - this->actor.world.rot = this->actor.shape.rot; - for (i = 0; i < ARRAY_COUNT(this->unk_19C); i++) { - if (this->unk_19C[i] != 0) { - this->unk_19C[i]--; - } - } - - Actor_SetFocus(&this->actor, 60.0f); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 28); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnKakasi3_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnKakasi3* this = (EnKakasi3*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); -} diff --git a/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.cpp b/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.cpp new file mode 100644 index 000000000..7c0155790 --- /dev/null +++ b/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.cpp @@ -0,0 +1,451 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAKASI3_Z_EN_KAKASI3_C +#include "actor_common.h" +/* + * File: z_en_kakasi3.c + * Overlay: ovl_En_Kakasi3 + * Description: Bonooru the Scarecrow + */ + +#include "z_en_kakasi3.h" +#include "vt.h" +#include "objects/object_ka/object_ka.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_25) + +void EnKakasi3_Init(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi3_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi3_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi3_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80A911F0(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A91284(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A91348(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A915B8(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A91620(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A91760(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A917FC(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A9187C(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A918E4(EnKakasi3* pthis, GlobalContext* globalCtx); +void func_80A91A90(EnKakasi3* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +ActorInit En_Kakasi3_InitVars = { + ACTOR_EN_KAKASI3, + ACTORCAT_NPC, + FLAGS, + OBJECT_KA, + sizeof(EnKakasi3), + (ActorFunc)EnKakasi3_Init, + (ActorFunc)EnKakasi3_Destroy, + (ActorFunc)EnKakasi3_Update, + (ActorFunc)EnKakasi3_Draw, +}; + +void EnKakasi3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi3* pthis = (EnKakasi3*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); + //! @bug SkelAnime_Free is not called +} + +void EnKakasi3_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi3* pthis = (EnKakasi3*)thisx; + + osSyncPrintf("\n\n"); + // "Obonur" -- Related to the name of the scarecrow (Bonooru) + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ おーボヌール ☆☆☆☆☆ \n" VT_RST); + pthis->actor.targetMode = 6; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); + pthis->actor.flags |= ACTOR_FLAG_10; + pthis->rot = pthis->actor.world.rot; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actionFunc = func_80A911F0; +} + +void func_80A90E28(EnKakasi3* pthis) { + pthis->unk_1A4 = 0; + pthis->skelAnime.playSpeed = 0.0f; + pthis->unk_1AA = pthis->unk_1AE = 0x0; + + Math_ApproachZeroF(&pthis->skelAnime.curFrame, 0.5f, 1.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->rot.x, 5, 0x2710, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->rot.y, 5, 0x2710, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->rot.z, 5, 0x2710, 0); +} + +void func_80A90EBC(EnKakasi3* pthis, GlobalContext* globalCtx, s32 arg) { + s16 currentFrame; + s16 ocarinaNote = globalCtx->msgCtx.lastOcaNoteIdx; + + if (arg != 0) { + if (pthis->unk_19C[3] == 0) { + pthis->unk_19C[3] = (s16)Rand_ZeroFloat(10.99f) + 30; + pthis->unk_1A6 = (s16)Rand_ZeroFloat(4.99f); + } + + pthis->unk_19A = (s16)Rand_ZeroFloat(2.99f) + 5; + ocarinaNote = pthis->unk_1A6; + } + switch (ocarinaNote) { + case OCARINA_NOTE_A: + pthis->unk_19A++; + if (pthis->unk_1A4 == 0) { + pthis->unk_1A4 = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KAKASHI_ROLL); + } + break; + case OCARINA_NOTE_C_DOWN: + pthis->unk_19A++; + pthis->unk_1B8 = 1.0f; + break; + case OCARINA_NOTE_C_RIGHT: + pthis->unk_19A++; + if (pthis->unk_1AE == 0x0) { + pthis->unk_1AE = 0x1388; + } + break; + case OCARINA_NOTE_C_LEFT: + pthis->unk_19A++; + if (pthis->unk_1AA == 0x0) { + pthis->unk_1AA = 0x1388; + } + break; + case OCARINA_NOTE_C_UP: + pthis->unk_19A++; + pthis->unk_1B8 = 2.0f; + break; + } + + if (pthis->unk_19A > 8) { + pthis->unk_19A = 8; + } + + if (pthis->unk_19A != 0) { + pthis->actor.gravity = -1.0f; + if (pthis->unk_19A == 8 && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.velocity.y = 3.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_KAKASHI_JUMP); + } + Math_ApproachF(&pthis->skelAnime.playSpeed, pthis->unk_1B8, 0.1f, 0.2f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->unk_1AA, 0x5, 0x3E8, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->unk_1AE, 0x5, 0x3E8, 0); + + if (pthis->unk_1AA != 0x0 && fabsf(pthis->actor.shape.rot.x - pthis->unk_1AA) < 50.0f) { + pthis->unk_1AA *= -1.0f; + } + if (pthis->unk_1AE != 0x0 && fabsf(pthis->actor.shape.rot.z - pthis->unk_1AE) < 50.0f) { + pthis->unk_1AE *= -1.0f; + } + + if (pthis->unk_1A4 != 0) { + pthis->actor.shape.rot.y += 0x1000; + if (pthis->actor.shape.rot.y == 0) { + pthis->unk_1A4 = 0; + } + } + currentFrame = pthis->skelAnime.curFrame; + if (currentFrame == 11 || currentFrame == 17) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_KAKASHI_SWING); + } + SkelAnime_Update(&pthis->skelAnime); + } +} + +void func_80A911F0(EnKakasi3* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&object_ka_Anim_000214); + + Animation_Change(&pthis->skelAnime, &object_ka_Anim_000214, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = func_80A91284; +} + +void func_80A91284(EnKakasi3* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + pthis->actor.textId = 0x40A1; + pthis->dialogState = TEXT_STATE_DONE; + pthis->unk_19A = 0; + + if (!LINK_IS_ADULT) { + pthis->unk_194 = false; + if (gSaveContext.scarecrowSpawnSongSet) { + pthis->actor.textId = 0x40A0; + pthis->dialogState = TEXT_STATE_EVENT; + pthis->unk_1A8 = 1; + } + } else { + pthis->unk_194 = true; + if (gSaveContext.scarecrowSpawnSongSet) { + if (pthis->unk_195) { + pthis->actor.textId = 0x40A2; + } else { + pthis->actor.textId = 0x40A3; + } + } + } + pthis->actionFunc = func_80A91348; +} + +void func_80A91348(EnKakasi3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80A90E28(pthis); + SkelAnime_Update(&pthis->skelAnime); + pthis->camId = SUBCAM_NONE; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (!pthis->unk_194) { + if (pthis->unk_1A8 == 0) { + pthis->actionFunc = func_80A91284; + } else { + pthis->actionFunc = func_80A91760; + } + } else { + pthis->actionFunc = func_80A91284; + } + } else { + s16 angleTowardsLink = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (!(pthis->actor.xzDistToPlayer > 120.0f)) { + s16 absAngleTowardsLink = ABS(angleTowardsLink); + + if (absAngleTowardsLink < 0x4300) { + if (!pthis->unk_194) { + + if (player->stateFlags2 & 0x1000000) { + pthis->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &pthis->actor, MAIN_CAM); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->dialogState = TEXT_STATE_EVENT; + pthis->unk_1B8 = 0.0f; + Message_StartTextbox(globalCtx, 0x40A4, NULL); + player->stateFlags2 |= 0x800000; + pthis->actionFunc = func_80A915B8; + return; + } + if (pthis->actor.xzDistToPlayer < 80.0f) { + player->stateFlags2 |= 0x800000; + } + } else if (gSaveContext.scarecrowSpawnSongSet && !pthis->unk_195) { + + if (player->stateFlags2 & 0x1000000) { + pthis->camId = OnePointCutscene_Init(globalCtx, 2260, -99, &pthis->actor, MAIN_CAM); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->dialogState = TEXT_STATE_EVENT; + pthis->unk_1B8 = 0.0f; + Message_StartTextbox(globalCtx, 0x40A8, NULL); + player->stateFlags2 |= 0x800000; + pthis->actionFunc = func_80A9187C; + return; + } + if (pthis->actor.xzDistToPlayer < 80.0f) { + player->stateFlags2 |= 0x800000; + } + } + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + } +} + +void func_80A915B8(EnKakasi3* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_RECORDING); + pthis->actionFunc = func_80A91620; + } +} + +void func_80A91620(EnKakasi3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04 || + (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05 && globalCtx->msgCtx.ocarinaMode < OCARINA_MODE_0B)) && + (globalCtx->msgCtx.msgMode == MSGMODE_NONE)) { + + OnePointCutscene_EndCutscene(globalCtx, pthis->camId); + if (globalCtx->cameraPtrs[pthis->camId] == NULL) { + pthis->camId = SUBCAM_NONE; + } + if (pthis->camId != SUBCAM_NONE) { + func_8005B1A4(globalCtx->cameraPtrs[pthis->camId]); + } + pthis->actionFunc = func_80A911F0; + return; + } + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03 && globalCtx->msgCtx.msgMode == MSGMODE_NONE) { + pthis->dialogState = TEXT_STATE_EVENT; + Message_StartTextbox(globalCtx, 0x40A5, NULL); + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_80A91A90; + return; + } + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { + func_80A90EBC(pthis, globalCtx, 0); + player->stateFlags2 |= 0x800000; + } +} + +void func_80A91760(EnKakasi3* pthis, GlobalContext* globalCtx) { + + func_80A90E28(pthis); + SkelAnime_Update(&pthis->skelAnime); + if (pthis->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + func_8010BD58(globalCtx, OCARINA_ACTION_SCARECROW_PLAYBACK); + pthis->actionFunc = func_80A917FC; + pthis->camId = OnePointCutscene_Init(globalCtx, 2280, -99, &pthis->actor, MAIN_CAM); + } +} + +void func_80A917FC(EnKakasi3* pthis, GlobalContext* globalCtx) { + + if (globalCtx->msgCtx.ocarinaMode != OCARINA_MODE_0F) { + func_80A90EBC(pthis, globalCtx, 1); + } else { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_CloseTextbox(globalCtx); + OnePointCutscene_EndCutscene(globalCtx, pthis->camId); + pthis->actionFunc = func_80A911F0; + } +} + +void func_80A9187C(EnKakasi3* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_SCARECROW); + pthis->actionFunc = func_80A918E4; + } +} + +void func_80A918E4(EnKakasi3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (BREG(3) != 0) { + // "No way!" + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ まさか! ☆☆☆☆☆ %d\n" VT_RST, globalCtx->msgCtx.ocarinaMode); + } + if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04 || + (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05 && globalCtx->msgCtx.ocarinaMode < OCARINA_MODE_0B)) && + globalCtx->msgCtx.msgMode == MSGMODE_NONE) { + + Message_StartTextbox(globalCtx, 0x40A6, NULL); + pthis->dialogState = TEXT_STATE_EVENT; + OnePointCutscene_EndCutscene(globalCtx, pthis->camId); + pthis->camId = SUBCAM_NONE; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_80A91A90; + return; + } + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03 && globalCtx->msgCtx.msgMode == MSGMODE_NONE) { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + if (BREG(3) != 0) { + osSyncPrintf("\n\n"); + // "With pthis, other guys are OK! That's it!" + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ これで、他の奴もOK!だ! ☆☆☆☆☆ %d\n" VT_RST, + globalCtx->msgCtx.ocarinaMode); + } + pthis->unk_195 = true; + Message_StartTextbox(globalCtx, 0x40A7, NULL); + pthis->dialogState = TEXT_STATE_EVENT; + func_8002DF54(globalCtx, NULL, 8); + pthis->actionFunc = func_80A91A90; + return; + } + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { + func_80A90EBC(pthis, globalCtx, 0); + player->stateFlags2 |= 0x800000; + } +} + +void func_80A91A90(EnKakasi3* pthis, GlobalContext* globalCtx) { + func_80A90E28(pthis); + SkelAnime_Update(&pthis->skelAnime); + func_8002DF54(globalCtx, NULL, 8); + + if (pthis->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + if (pthis->unk_195) { + if (!(gSaveContext.eventChkInf[9] & 0x1000)) { + gSaveContext.eventChkInf[9] |= 0x1000; + } + } + if (globalCtx->cameraPtrs[pthis->camId] == NULL) { + pthis->camId = SUBCAM_NONE; + } + if (pthis->camId != SUBCAM_NONE) { + func_8005B1A4(globalCtx->cameraPtrs[pthis->camId]); + } + Message_CloseTextbox(globalCtx); + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + func_8002DF54(globalCtx, NULL, 7); + pthis->actionFunc = func_80A911F0; + } +} + +void EnKakasi3_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi3* pthis = (EnKakasi3*)thisx; + s32 pad; + s32 i; + + if (BREG(2) != 0) { + osSyncPrintf("\n\n"); + // "flag!" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.scarecrowSpawnSongSet); + } + + pthis->unk_198++; + pthis->actor.world.rot = pthis->actor.shape.rot; + for (i = 0; i < ARRAY_COUNT(pthis->unk_19C); i++) { + if (pthis->unk_19C[i] != 0) { + pthis->unk_19C[i]--; + } + } + + Actor_SetFocus(&pthis->actor, 60.0f); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 28); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnKakasi3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi3* pthis = (EnKakasi3*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); +} diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.cpp similarity index 51% rename from src/overlays/actors/ovl_En_Kanban/z_en_kanban.c rename to src/overlays/actors/ovl_En_Kanban/z_en_kanban.cpp index b4478577f..c05ae2434 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.cpp @@ -89,7 +89,7 @@ void EnKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx); void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Kanban_InitVars = { +ActorInit En_Kanban_InitVars = { ACTOR_EN_KANBAN, ACTORCAT_PROP, FLAGS, @@ -193,72 +193,72 @@ static u16 sCutFlags[] = { /* CUT_DIAG_R */ UPPERRIGHT_HALF, /* CUT_VERT_R */ RIGHT_HALF, }; -void EnKanban_SetFloorRot(EnKanban* this) { - if (this->actor.floorPoly != NULL) { - f32 nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); - f32 ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - f32 nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); +void EnKanban_SetFloorRot(EnKanban* pthis) { + if (pthis->actor.floorPoly != NULL) { + f32 nx = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.x); + f32 ny = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.y); + f32 nz = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.z); - this->floorRot.x = -Math_FAtan2F(-nz * ny, 1.0f); - this->floorRot.z = Math_FAtan2F(-nx * ny, 1.0f); + pthis->floorRot.x = -Math_FAtan2F(-nz * ny, 1.0f); + pthis->floorRot.z = Math_FAtan2F(-nx * ny, 1.0f); } } void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKanban* this = (EnKanban*)thisx; + EnKanban* pthis = (EnKanban*)thisx; - Actor_SetScale(&this->actor, 0.01f); - if (this->actor.params != ENKANBAN_PIECE) { - this->actor.targetMode = 0; - this->actor.flags |= ACTOR_FLAG_0; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - osSyncPrintf("KANBAN ARG %x\n", this->actor.params); - if (this->actor.params == ENKANBAN_FISHING) { + Actor_SetScale(&pthis->actor, 0.01f); + if (pthis->actor.params != ENKANBAN_PIECE) { + pthis->actor.targetMode = 0; + pthis->actor.flags |= ACTOR_FLAG_0; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + osSyncPrintf("KANBAN ARG %x\n", pthis->actor.params); + if (pthis->actor.params == ENKANBAN_FISHING) { if (LINK_IS_CHILD) { - this->actor.textId = 0x409D; + pthis->actor.textId = 0x409D; } else { - this->actor.textId = 0x4090; + pthis->actor.textId = 0x4090; } } else { - this->actor.textId = this->actor.params | 0x300; + pthis->actor.textId = pthis->actor.params | 0x300; } - this->bounceX = 1; - this->partFlags = 0xFFFF; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 4); - EnKanban_SetFloorRot(this); + pthis->bounceX = 1; + pthis->partFlags = 0xFFFF; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 50.0f, 4); + EnKanban_SetFloorRot(pthis); if (LINK_IS_CHILD) { - this->actor.world.pos.y -= 15.0f; + pthis->actor.world.pos.y -= 15.0f; } } } void EnKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnKanban* this = (EnKanban*)thisx; + EnKanban* pthis = (EnKanban*)thisx; - if (this->actionState == ENKANBAN_SIGN) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if (pthis->actionState == ENKANBAN_SIGN) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } -void EnKanban_Message(EnKanban* this, GlobalContext* globalCtx) { - if (!this->msgFlag) { - if (this->msgTimer == 0) { - if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x2800) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->msgFlag = true; +void EnKanban_Message(EnKanban* pthis, GlobalContext* globalCtx) { + if (!pthis->msgFlag) { + if (pthis->msgTimer == 0) { + if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) < 0x2800) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->msgFlag = true; } else { - func_8002F2CC(&this->actor, globalCtx, 68.0f); + func_8002F2CC(&pthis->actor, globalCtx, 68.0f); } } } else { - this->msgTimer--; + pthis->msgTimer--; } } else { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->msgFlag = false; - this->msgTimer = 20; + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->msgFlag = false; + pthis->msgTimer = 20; } } } @@ -266,52 +266,52 @@ void EnKanban_Message(EnKanban* this, GlobalContext* globalCtx) { void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { u8 bounced = false; GlobalContext* globalCtx = globalCtx2; - EnKanban* this = (EnKanban*)thisx; + EnKanban* pthis = (EnKanban*)thisx; EnKanban* signpost; EnKanban* piece; Player* player = GET_PLAYER(globalCtx); Vec3f offset; - this->frameCount++; - switch (this->actionState) { + pthis->frameCount++; + switch (pthis->actionState) { case ENKANBAN_SIGN: - if (this->invincibilityTimer != 0) { - this->invincibilityTimer--; + if (pthis->invincibilityTimer != 0) { + pthis->invincibilityTimer--; } - if (this->zTargetTimer != 0) { - this->zTargetTimer--; + if (pthis->zTargetTimer != 0) { + pthis->zTargetTimer--; } - if (this->zTargetTimer == 1) { - this->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->zTargetTimer == 1) { + pthis->actor.flags &= ~ACTOR_FLAG_0; } - if (this->partFlags == 0xFFFF) { - EnKanban_Message(this, globalCtx); + if (pthis->partFlags == 0xFFFF) { + EnKanban_Message(pthis, globalCtx); } - if ((this->invincibilityTimer == 0) && (this->collider.base.acFlags & AC_HIT)) { - this->collider.base.acFlags &= ~AC_HIT; - this->invincibilityTimer = 6; - piece = (EnKanban*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_KANBAN, - this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, this->actor.shape.rot.z, ENKANBAN_PIECE); + if ((pthis->invincibilityTimer == 0) && (pthis->collider.base.acFlags & AC_HIT)) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->invincibilityTimer = 6; + piece = (EnKanban*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_KANBAN, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->actor.shape.rot.x, + pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, ENKANBAN_PIECE); if (piece != NULL) { - ColliderInfo* hitItem = this->collider.info.acHitInfo; - s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + ColliderInfo* hitItem = pthis->collider.info.acHitInfo; + s16 yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; u8 i; if (hitItem->toucher.dmgFlags & 0x700) { - this->cutType = sCutTypes[player->swordAnimation]; + pthis->cutType = sCutTypes[player->swordAnimation]; } else { - this->cutType = CUT_POST; + pthis->cutType = CUT_POST; } if (ABS(yawDiff) > 0x4000) { - if (this->cutType == CUT_DIAG_R) { - this->cutType = CUT_DIAG_L; - } else if (this->cutType == CUT_VERT_L) { - this->cutType = CUT_VERT_R; + if (pthis->cutType == CUT_DIAG_R) { + pthis->cutType = CUT_DIAG_L; + } else if (pthis->cutType == CUT_VERT_L) { + pthis->cutType = CUT_VERT_R; } } - piece->partFlags = sCutFlags[this->cutType] & this->partFlags; + piece->partFlags = sCutFlags[pthis->cutType] & pthis->partFlags; if (piece->partFlags == 0) { Actor_Kill(&piece->actor); return; @@ -322,9 +322,9 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { piece->partCount++; } } - this->partFlags &= ~sCutFlags[this->cutType]; - if (!(this->partFlags & ALL_PARTS)) { - this->zTargetTimer = 10; + pthis->partFlags &= ~sCutFlags[pthis->cutType]; + if (!(pthis->partFlags & ALL_PARTS)) { + pthis->zTargetTimer = 10; } if ((piece->partFlags & PART_UPPER_LEFT) && (piece->partFlags & PART_LOWER_RIGHT)) { piece->pieceType = PIECE_WHOLE_SIGN; @@ -371,19 +371,19 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { piece->pieceType = PIECE_WHOLE_SIGN; } - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); Matrix_MultVec3f(&sPieceOffsets[piece->pieceType], &offset); piece->actor.world.pos.x += offset.x; piece->actor.world.pos.y += offset.y; piece->actor.world.pos.z += offset.z; - piece->offset.x = -sPieceOffsets[piece->pieceType].x / this->actor.scale.x; - piece->offset.y = -sPieceOffsets[piece->pieceType].y / this->actor.scale.x; - piece->offset.z = -sPieceOffsets[piece->pieceType].z / this->actor.scale.x; + piece->offset.x = -sPieceOffsets[piece->pieceType].x / pthis->actor.scale.x; + piece->offset.y = -sPieceOffsets[piece->pieceType].y / pthis->actor.scale.x; + piece->offset.z = -sPieceOffsets[piece->pieceType].z / pthis->actor.scale.x; piece->pieceWidth = sPieceSizes[piece->pieceType].x; piece->pieceHeight = sPieceSizes[piece->pieceType].y; piece->actor.gravity = -1.0f; piece->actionState = ENKANBAN_AIR; - piece->actor.world.rot.y = (s16)Rand_CenteredFloat(0x3000) + this->actor.yawTowardsPlayer + 0x8000; + piece->actor.world.rot.y = (s16)Rand_CenteredFloat(0x3000) + pthis->actor.yawTowardsPlayer + 0x8000; piece->actor.velocity.y = Rand_ZeroFloat(2.0f) + 3.0f; piece->actor.speedXZ = Rand_ZeroFloat(2.0f) + 3.0f; if (piece->partCount >= 4) { @@ -402,32 +402,32 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { piece->airTimer = 100; piece->actor.flags &= ~ACTOR_FLAG_0; piece->actor.flags |= ACTOR_FLAG_25; - this->cutMarkTimer = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_SWORD_STRIKE); + pthis->cutMarkTimer = 5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_SWORD_STRIKE); } } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 44.0f; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer > 500.0f) { - this->actor.flags |= ACTOR_FLAG_0; - this->partFlags = 0xFFFF; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 44.0f; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actor.xzDistToPlayer > 500.0f) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->partFlags = 0xFFFF; } - if (this->cutMarkTimer != 0) { - if (this->cutMarkTimer >= 5) { - this->cutMarkAlpha += 255; - if (this->cutMarkAlpha > 255) { - this->cutMarkAlpha = 255; + if (pthis->cutMarkTimer != 0) { + if (pthis->cutMarkTimer >= 5) { + pthis->cutMarkAlpha += 255; + if (pthis->cutMarkAlpha > 255) { + pthis->cutMarkAlpha = 255; } } else { - this->cutMarkAlpha -= 65; - if (this->cutMarkAlpha < 0) { - this->cutMarkAlpha = 0; + pthis->cutMarkAlpha -= 65; + if (pthis->cutMarkAlpha < 0) { + pthis->cutMarkAlpha = 0; } } - this->cutMarkTimer--; + pthis->cutMarkTimer--; } break; case ENKANBAN_AIR: @@ -439,126 +439,126 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { f32 tempYDistToWater; u8 onGround; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 50.0f, 5); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 30.0f, 50.0f, 5); - tempX = this->actor.world.pos.x; - tempY = this->actor.world.pos.y; - tempZ = this->actor.world.pos.z; - tempBgFlags = this->actor.bgCheckFlags; - tempYDistToWater = this->actor.yDistToWater; + tempX = pthis->actor.world.pos.x; + tempY = pthis->actor.world.pos.y; + tempZ = pthis->actor.world.pos.z; + tempBgFlags = pthis->actor.bgCheckFlags; + tempYDistToWater = pthis->actor.yDistToWater; - this->actor.world.pos.z += ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 4); - EnKanban_SetFloorRot(this); + pthis->actor.world.pos.z += ((pthis->actor.world.pos.y - pthis->actor.floorHeight) * -50.0f) / 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 50.0f, 4); + EnKanban_SetFloorRot(pthis); - this->actor.world.pos.x = tempX; - this->actor.world.pos.y = tempY; - this->actor.world.pos.z = tempZ; - this->actor.bgCheckFlags = tempBgFlags; - this->actor.yDistToWater = tempYDistToWater; + pthis->actor.world.pos.x = tempX; + pthis->actor.world.pos.y = tempY; + pthis->actor.world.pos.z = tempZ; + pthis->actor.bgCheckFlags = tempBgFlags; + pthis->actor.yDistToWater = tempYDistToWater; osSyncPrintf(VT_RST); - onGround = (this->actor.bgCheckFlags & 1); - if (this->spinXFlag) { - this->spinRot.x += this->spinVel.x; - this->spinVel.x -= 0x800; - if ((this->spinRot.x <= 0) && onGround) { - this->spinRot.x = 0; - this->spinVel.x = 0; + onGround = (pthis->actor.bgCheckFlags & 1); + if (pthis->spinXFlag) { + pthis->spinRot.x += pthis->spinVel.x; + pthis->spinVel.x -= 0x800; + if ((pthis->spinRot.x <= 0) && onGround) { + pthis->spinRot.x = 0; + pthis->spinVel.x = 0; } } else { - this->spinRot.x -= this->spinVel.x; - this->spinVel.x -= 0x800; - if ((this->spinRot.x >= 0) && onGround) { - this->spinRot.x = 0; - this->spinVel.x = 0; + pthis->spinRot.x -= pthis->spinVel.x; + pthis->spinVel.x -= 0x800; + if ((pthis->spinRot.x >= 0) && onGround) { + pthis->spinRot.x = 0; + pthis->spinVel.x = 0; } } - if (this->spinVel.x < -0xC00) { - this->spinVel.x = -0xC00; + if (pthis->spinVel.x < -0xC00) { + pthis->spinVel.x = -0xC00; } - if (this->spinZFlag) { - this->spinRot.z += this->spinVel.z; - this->spinVel.z -= 0x800; - if ((this->spinRot.z <= 0) && onGround) { - this->spinRot.z = 0; - this->spinVel.z = 0; + if (pthis->spinZFlag) { + pthis->spinRot.z += pthis->spinVel.z; + pthis->spinVel.z -= 0x800; + if ((pthis->spinRot.z <= 0) && onGround) { + pthis->spinRot.z = 0; + pthis->spinVel.z = 0; } } else { - this->spinRot.z -= this->spinVel.z; - this->spinVel.z -= 0x800; - if ((this->spinRot.z >= 0) && onGround) { - this->spinRot.z = 0; - this->spinVel.z = 0; + pthis->spinRot.z -= pthis->spinVel.z; + pthis->spinVel.z -= 0x800; + if ((pthis->spinRot.z >= 0) && onGround) { + pthis->spinRot.z = 0; + pthis->spinVel.z = 0; } } - if (this->spinVel.z < -0xC00) { - this->spinVel.z = -0xC00; + if (pthis->spinVel.z < -0xC00) { + pthis->spinVel.z = -0xC00; } - if (this->actor.bgCheckFlags & 8) { - this->actor.speedXZ *= -0.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.speedXZ *= -0.5f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WOODPLATE_BOUND); } - if (this->actor.bgCheckFlags & 0x40) { - this->actionState = ENKANBAN_WATER; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER); - this->bounceX = this->bounceZ = 0; - this->actor.world.pos.y += this->actor.yDistToWater; - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 0, (this->partCount * 20) + 300); - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 150, 650, 0); - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 300, 800, 5); - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - osSyncPrintf(" WAT Y = %f\n", this->actor.yDistToWater); - osSyncPrintf(" POS Y = %f\n", this->actor.world.pos.y); - osSyncPrintf(" GROUND Y = %f\n", this->actor.floorHeight); + if (pthis->actor.bgCheckFlags & 0x40) { + pthis->actionState = ENKANBAN_WATER; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BOMB_DROP_WATER); + pthis->bounceX = pthis->bounceZ = 0; + pthis->actor.world.pos.y += pthis->actor.yDistToWater; + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, NULL, NULL, 0, (pthis->partCount * 20) + 300); + EffectSsGRipple_Spawn(globalCtx, &pthis->actor.world.pos, 150, 650, 0); + EffectSsGRipple_Spawn(globalCtx, &pthis->actor.world.pos, 300, 800, 5); + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + osSyncPrintf(" WAT Y = %f\n", pthis->actor.yDistToWater); + osSyncPrintf(" POS Y = %f\n", pthis->actor.world.pos.y); + osSyncPrintf(" GROUND Y = %f\n", pthis->actor.floorHeight); break; } if (onGround) { - if (this->bounceCount <= 0) { - this->bounceCount++; - this->actor.velocity.y *= -0.3f; - this->actor.world.rot.y += (s16)Rand_CenteredFloat(16384.0f); + if (pthis->bounceCount <= 0) { + pthis->bounceCount++; + pthis->actor.velocity.y *= -0.3f; + pthis->actor.world.rot.y += (s16)Rand_CenteredFloat(16384.0f); } else { - this->actor.velocity.y = 0.0f; + pthis->actor.velocity.y = 0.0f; } - this->actor.speedXZ *= 0.7f; - if ((this->spinRot.x == 0) && (this->bounceX != 0)) { - this->spinVel.x = this->bounceX * 0x200; - if (this->bounceX != 0) { - this->bounceX -= 5; - if (this->bounceX <= 0) { - this->bounceX = 0; + pthis->actor.speedXZ *= 0.7f; + if ((pthis->spinRot.x == 0) && (pthis->bounceX != 0)) { + pthis->spinVel.x = pthis->bounceX * 0x200; + if (pthis->bounceX != 0) { + pthis->bounceX -= 5; + if (pthis->bounceX <= 0) { + pthis->bounceX = 0; } } if (Rand_ZeroOne() < 0.5f) { - this->spinXFlag = true; + pthis->spinXFlag = true; } else { - this->spinXFlag = false; + pthis->spinXFlag = false; } bounced = true; } - if ((this->spinRot.z == 0) && (this->bounceZ != 0)) { - this->spinVel.z = this->bounceZ * 0x200; - if (this->bounceZ != 0) { - this->bounceZ -= 5; - if (this->bounceZ <= 0) { - this->bounceZ = 0; + if ((pthis->spinRot.z == 0) && (pthis->bounceZ != 0)) { + pthis->spinVel.z = pthis->bounceZ * 0x200; + if (pthis->bounceZ != 0) { + pthis->bounceZ -= 5; + if (pthis->bounceZ <= 0) { + pthis->bounceZ = 0; } } if (Rand_ZeroOne() < 0.5f) { - this->spinZFlag = true; + pthis->spinZFlag = true; } else { - this->spinZFlag = false; + pthis->spinZFlag = false; } bounced = true; } - Math_ApproachS(&this->actor.shape.rot.x, this->direction * 0x4000, 1, 0x2000); + Math_ApproachS(&pthis->actor.shape.rot.x, pthis->direction * 0x4000, 1, 0x2000); } else { - this->actor.shape.rot.y += this->spinVel.y; - this->actor.shape.rot.x += this->direction * 0x7D0; + pthis->actor.shape.rot.y += pthis->spinVel.y; + pthis->actor.shape.rot.x += pthis->direction * 0x7D0; } if (bounced) { s16 dustCount; @@ -567,113 +567,113 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { Vec3f accel; Vec3f pos; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_WOODPLATE_BOUND); accel.x = 0.0f; accel.y = 0.1f; accel.z = 0.0f; - pos.y = this->actor.floorHeight + 3.0f; - dustCount = this->partCount * 0.5f; + pos.y = pthis->actor.floorHeight + 3.0f; + dustCount = pthis->partCount * 0.5f; for (j = 0; j < dustCount + 3; j++) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat((this->partCount * 0.5f) + 20.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat((this->partCount * 0.5f) + 20.0f); + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat((pthis->partCount * 0.5f) + 20.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat((pthis->partCount * 0.5f) + 20.0f); func_800286CC(globalCtx, &pos, &velocity, &accel, 100, 5); } } - if (DECR(this->airTimer) == 0) { - this->actionState = ENKANBAN_GROUND; + if (DECR(pthis->airTimer) == 0) { + pthis->actionState = ENKANBAN_GROUND; } } case ENKANBAN_GROUND: case ENKANBAN_WATER: - signpost = (EnKanban*)this->actor.parent; + signpost = (EnKanban*)pthis->actor.parent; if (signpost->partFlags == 0xFFFF) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - Math_ApproachF(&this->actor.shape.yOffset, 100.0f, 1.0f, 5.0f); - if (this->actionState == ENKANBAN_WATER) { + Math_ApproachF(&pthis->actor.shape.yOffset, 100.0f, 1.0f, 5.0f); + if (pthis->actionState == ENKANBAN_WATER) { s32 rippleDelay; s32 rippleScale; - if ((player->actor.speedXZ > 0.0f) && (player->actor.world.pos.y < this->actor.world.pos.y) && - (this->actor.xyzDistToPlayerSq < 2500.0f)) { - Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 1.0f, 0.2f); - if (this->actor.speedXZ > 1.0f) { - this->actor.speedXZ = 1.0f; + if ((player->actor.speedXZ > 0.0f) && (player->actor.world.pos.y < pthis->actor.world.pos.y) && + (pthis->actor.xyzDistToPlayerSq < 2500.0f)) { + Math_ApproachF(&pthis->actor.speedXZ, player->actor.speedXZ, 1.0f, 0.2f); + if (pthis->actor.speedXZ > 1.0f) { + pthis->actor.speedXZ = 1.0f; } - if (Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x8000, 1, 0x1000, + if (Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 1, 0x1000, 0) > 0) { - this->spinVel.y = this->actor.speedXZ * 1000.0f; + pthis->spinVel.y = pthis->actor.speedXZ * 1000.0f; } else { - this->spinVel.y = this->actor.speedXZ * -1000.0f; + pthis->spinVel.y = pthis->actor.speedXZ * -1000.0f; } } - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = 0.0f; } - Actor_MoveForward(&this->actor); - if (this->actor.speedXZ != 0.0f) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 5); - if (this->actor.bgCheckFlags & 8) { - this->actor.speedXZ *= -0.5f; - if (this->spinVel.y > 0) { - this->spinVel.y = -0x7D0; + Actor_MoveForward(&pthis->actor); + if (pthis->actor.speedXZ != 0.0f) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 50.0f, 5); + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.speedXZ *= -0.5f; + if (pthis->spinVel.y > 0) { + pthis->spinVel.y = -0x7D0; } else { - this->spinVel.y = 0x7D0; + pthis->spinVel.y = 0x7D0; } } - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.15f); + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 0.15f); } - this->actor.shape.rot.y += this->spinVel.y; - Math_ApproachS(&this->spinVel.y, 0, 1, 0x3A); - Math_ApproachS(&this->actor.shape.rot.x, this->direction * 0x4000, 2, 0x1000); - Math_ApproachS(&this->spinRot.x, Math_SinS(2500 * this->frameCount) * 500.0f, 2, 0x1000); - Math_ApproachS(&this->spinRot.z, Math_CosS(3000 * this->frameCount) * 500.0f, 2, 0x1000); - Math_ApproachZeroF(&this->floorRot.x, 0.5f, 0.2f); - Math_ApproachZeroF(&this->floorRot.z, 0.5f, 0.2f); - if (fabsf(this->actor.speedXZ) > 1.0f) { + pthis->actor.shape.rot.y += pthis->spinVel.y; + Math_ApproachS(&pthis->spinVel.y, 0, 1, 0x3A); + Math_ApproachS(&pthis->actor.shape.rot.x, pthis->direction * 0x4000, 2, 0x1000); + Math_ApproachS(&pthis->spinRot.x, Math_SinS(2500 * pthis->frameCount) * 500.0f, 2, 0x1000); + Math_ApproachS(&pthis->spinRot.z, Math_CosS(3000 * pthis->frameCount) * 500.0f, 2, 0x1000); + Math_ApproachZeroF(&pthis->floorRot.x, 0.5f, 0.2f); + Math_ApproachZeroF(&pthis->floorRot.z, 0.5f, 0.2f); + if (fabsf(pthis->actor.speedXZ) > 1.0f) { rippleDelay = 0; - } else if (fabsf(this->actor.speedXZ) > 0.5f) { + } else if (fabsf(pthis->actor.speedXZ) > 0.5f) { rippleDelay = 3; } else { rippleDelay = 7; } - if (!(this->frameCount & rippleDelay)) { - if (this->partCount < 3) { + if (!(pthis->frameCount & rippleDelay)) { + if (pthis->partCount < 3) { rippleScale = 0; - } else if (this->partCount < 6) { + } else if (pthis->partCount < 6) { rippleScale = 100; } else { rippleScale = 200; } - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, rippleScale, rippleScale + 500, 0); + EffectSsGRipple_Spawn(globalCtx, &pthis->actor.world.pos, rippleScale, rippleScale + 500, 0); } - } else if ((globalCtx->actorCtx.unk_02 != 0) && (this->actor.xyzDistToPlayerSq < SQ(100.0f))) { - f32 hammerStrength = (100.0f - sqrtf(this->actor.xyzDistToPlayerSq)) * 0.05f; + } else if ((globalCtx->actorCtx.unk_02 != 0) && (pthis->actor.xyzDistToPlayerSq < SQ(100.0f))) { + f32 hammerStrength = (100.0f - sqrtf(pthis->actor.xyzDistToPlayerSq)) * 0.05f; - this->actionState = ENKANBAN_AIR; - this->actor.gravity = -1.0f; - this->actor.world.rot.y = Rand_CenteredFloat(0x10000); - if (this->partCount >= 4) { - this->bounceX = (s16)Rand_ZeroFloat(10.0f) + 6; - this->bounceZ = (s16)Rand_ZeroFloat(10.0f) + 6; - this->actor.velocity.y = 2.0f + hammerStrength; - this->actor.speedXZ = Rand_ZeroFloat(1.0f); + pthis->actionState = ENKANBAN_AIR; + pthis->actor.gravity = -1.0f; + pthis->actor.world.rot.y = Rand_CenteredFloat(0x10000); + if (pthis->partCount >= 4) { + pthis->bounceX = (s16)Rand_ZeroFloat(10.0f) + 6; + pthis->bounceZ = (s16)Rand_ZeroFloat(10.0f) + 6; + pthis->actor.velocity.y = 2.0f + hammerStrength; + pthis->actor.speedXZ = Rand_ZeroFloat(1.0f); } else { - this->bounceX = (s16)Rand_ZeroFloat(7.0f) + 3; - this->bounceZ = (s16)Rand_ZeroFloat(7.0f) + 3; - this->actor.velocity.y = 3.0f + hammerStrength; - this->actor.speedXZ = Rand_ZeroFloat(1.5f); + pthis->bounceX = (s16)Rand_ZeroFloat(7.0f) + 3; + pthis->bounceZ = (s16)Rand_ZeroFloat(7.0f) + 3; + pthis->actor.velocity.y = 3.0f + hammerStrength; + pthis->actor.speedXZ = Rand_ZeroFloat(1.5f); } - this->spinVel.y = Rand_CenteredFloat(0x1800); + pthis->spinVel.y = Rand_CenteredFloat(0x1800); if (Rand_ZeroOne() < 0.5f) { - this->direction = 1; + pthis->direction = 1; } else { - this->direction = -1; + pthis->direction = -1; } - this->airTimer = 70; + pthis->airTimer = 70; } - if (this->bounceX == 0) { + if (pthis->bounceX == 0) { Actor* bomb = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; f32 dx; f32 dy; @@ -684,33 +684,33 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { bomb = bomb->next; continue; } - dx = this->actor.world.pos.x - bomb->world.pos.x; - dy = this->actor.world.pos.y - bomb->world.pos.y; - dz = this->actor.world.pos.z - bomb->world.pos.z; + dx = pthis->actor.world.pos.x - bomb->world.pos.x; + dy = pthis->actor.world.pos.y - bomb->world.pos.y; + dz = pthis->actor.world.pos.z - bomb->world.pos.z; if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 100.0f) { f32 bombStrength = (100.0f - sqrtf(SQ(dx) + SQ(dy) + SQ(dz))) * 0.05f; - this->actionState = ENKANBAN_AIR; - this->actor.gravity = -1.0f; - this->actor.world.rot.y = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); - if (this->partCount >= 4) { - this->bounceX = (s16)Rand_ZeroFloat(10.0f) + 6; - this->bounceZ = (s16)Rand_ZeroFloat(10.0f) + 6; - this->actor.velocity.y = 2.5f + bombStrength; - this->actor.speedXZ = 3.0f + bombStrength; + pthis->actionState = ENKANBAN_AIR; + pthis->actor.gravity = -1.0f; + pthis->actor.world.rot.y = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); + if (pthis->partCount >= 4) { + pthis->bounceX = (s16)Rand_ZeroFloat(10.0f) + 6; + pthis->bounceZ = (s16)Rand_ZeroFloat(10.0f) + 6; + pthis->actor.velocity.y = 2.5f + bombStrength; + pthis->actor.speedXZ = 3.0f + bombStrength; } else { - this->bounceX = (s16)Rand_ZeroFloat(7.0f) + 3; - this->bounceZ = (s16)Rand_ZeroFloat(7.0f) + 3; - this->actor.velocity.y = 5.0f + bombStrength; - this->actor.speedXZ = 4.0f + bombStrength; + pthis->bounceX = (s16)Rand_ZeroFloat(7.0f) + 3; + pthis->bounceZ = (s16)Rand_ZeroFloat(7.0f) + 3; + pthis->actor.velocity.y = 5.0f + bombStrength; + pthis->actor.speedXZ = 4.0f + bombStrength; } - this->spinVel.y = Rand_CenteredFloat(0x1800); + pthis->spinVel.y = Rand_CenteredFloat(0x1800); if (Rand_ZeroOne() < 0.5f) { - this->direction = 1; + pthis->direction = 1; } else { - this->direction = -1; + pthis->direction = -1; } - this->airTimer = 70; + pthis->airTimer = 70; } bomb = bomb->next; } @@ -718,17 +718,17 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("OCARINA_MODE %d\n", globalCtx->msgCtx.ocarinaMode); osSyncPrintf(VT_RST); - switch (this->ocarinaFlag) { + switch (pthis->ocarinaFlag) { case 0: if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - this->ocarinaFlag = 1; + pthis->ocarinaFlag = 1; } break; case 1: if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) && (globalCtx->msgCtx.unk_E3F2 == OCARINA_SONG_LULLABY)) { - this->actionState = ENKANBAN_REPAIR; - this->bounceX = 1; + pthis->actionState = ENKANBAN_REPAIR; + pthis->bounceX = 1; Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } @@ -742,34 +742,34 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { s16 pDiff; s16 yDiff; s16 rDiff; - signpost = (EnKanban*)this->actor.parent; + signpost = (EnKanban*)pthis->actor.parent; if (signpost->partFlags == 0xFFFF) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } Matrix_RotateY((signpost->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&sPieceOffsets[this->pieceType], &offset); + Matrix_MultVec3f(&sPieceOffsets[pthis->pieceType], &offset); distX = - Math_SmoothStepToF(&this->actor.world.pos.x, signpost->actor.world.pos.x + offset.x, 1.0f, 3.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.x, signpost->actor.world.pos.x + offset.x, 1.0f, 3.0f, 0.0f); distY = - Math_SmoothStepToF(&this->actor.world.pos.y, signpost->actor.world.pos.y + offset.y, 1.0f, 3.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, signpost->actor.world.pos.y + offset.y, 1.0f, 3.0f, 0.0f); distZ = - Math_SmoothStepToF(&this->actor.world.pos.z, signpost->actor.world.pos.z + offset.z, 1.0f, 3.0f, 0.0f); - pDiff = Math_SmoothStepToS(&this->actor.shape.rot.x, signpost->actor.shape.rot.x, 1, 0x200, 0); - yDiff = Math_SmoothStepToS(&this->actor.shape.rot.y, signpost->actor.shape.rot.y, 1, 0x200, 0); - rDiff = Math_SmoothStepToS(&this->actor.shape.rot.z, signpost->actor.shape.rot.z, 1, 0x200, 0); - Math_ApproachS(&this->spinRot.x, 0, 1, 0x200); - Math_ApproachS(&this->spinRot.z, 0, 1, 0x200); - Math_ApproachZeroF(&this->floorRot.x, 1.0f, 0.05f); - Math_ApproachZeroF(&this->floorRot.z, 1.0f, 0.05f); - Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, 2.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, signpost->actor.world.pos.z + offset.z, 1.0f, 3.0f, 0.0f); + pDiff = Math_SmoothStepToS(&pthis->actor.shape.rot.x, signpost->actor.shape.rot.x, 1, 0x200, 0); + yDiff = Math_SmoothStepToS(&pthis->actor.shape.rot.y, signpost->actor.shape.rot.y, 1, 0x200, 0); + rDiff = Math_SmoothStepToS(&pthis->actor.shape.rot.z, signpost->actor.shape.rot.z, 1, 0x200, 0); + Math_ApproachS(&pthis->spinRot.x, 0, 1, 0x200); + Math_ApproachS(&pthis->spinRot.z, 0, 1, 0x200); + Math_ApproachZeroF(&pthis->floorRot.x, 1.0f, 0.05f); + Math_ApproachZeroF(&pthis->floorRot.z, 1.0f, 0.05f); + Math_ApproachZeroF(&pthis->actor.shape.yOffset, 1.0f, 2.0f); if (((distX + distY + distZ) == 0.0f) && - ((pDiff + yDiff + rDiff + this->spinRot.x + this->spinRot.z) == 0) && (this->floorRot.x == 0.0f) && - (this->floorRot.z == 0.0f)) { - signpost->partFlags |= this->partFlags; + ((pDiff + yDiff + rDiff + pthis->spinRot.x + pthis->spinRot.z) == 0) && (pthis->floorRot.x == 0.0f) && + (pthis->floorRot.z == 0.0f)) { + signpost->partFlags |= pthis->partFlags; signpost->actor.flags |= ACTOR_FLAG_0; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } break; } @@ -781,7 +781,7 @@ static Gfx* sDisplayLists[] = { object_kanban_DL_0013D0, object_kanban_DL_001488, object_kanban_DL_001540, }; -#include "z_en_kanban_gfx.c" +#include "z_en_kanban_gfx.cpp" static f32 sCutAngles[] = { /* CUT_POST */ 0.50f * M_PI, @@ -794,39 +794,39 @@ static f32 sCutAngles[] = { static s32 sUnused[] = { 0, 0, 0 }; // Unused zero vector? -#include "overlays/ovl_En_Kanban/ovl_En_Kanban.c" +#include "overlays/ovl_En_Kanban/ovl_En_Kanban.cpp" void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnKanban* this = (EnKanban*)thisx; + EnKanban* pthis = (EnKanban*)thisx; f32 zShift; f32 zShift2; s16 i; - u8* shadowTex = Graph_Alloc(globalCtx->state.gfxCtx, 0x400); + u8* shadowTex = (u8*)Graph_Alloc(globalCtx->state.gfxCtx, 0x400); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_kanban.c", 1659); func_80093D18(globalCtx->state.gfxCtx); func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_kanban_DL_000C30); - if (this->actionState != ENKANBAN_SIGN) { - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateX(this->floorRot.x, MTXMODE_APPLY); - Matrix_RotateZ(this->floorRot.z, MTXMODE_APPLY); - Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateX((this->actor.shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); - zShift = fabsf(Math_SinS(this->spinRot.x) * this->pieceHeight); - zShift2 = fabsf(Math_SinS(this->spinRot.z) * this->pieceWidth); + if (pthis->actionState != ENKANBAN_SIGN) { + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateX(pthis->floorRot.x, MTXMODE_APPLY); + Matrix_RotateZ(pthis->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, pthis->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateX((pthis->actor.shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + zShift = fabsf(Math_SinS(pthis->spinRot.x) * pthis->pieceHeight); + zShift2 = fabsf(Math_SinS(pthis->spinRot.z) * pthis->pieceWidth); zShift = MAX(zShift2, zShift); - zShift *= -(f32)this->direction; + zShift *= -(f32)pthis->direction; Matrix_Translate(0.0f, 0.0f, zShift, MTXMODE_APPLY); - Matrix_RotateX((this->spinRot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateY((this->spinRot.z / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_Translate(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); + Matrix_RotateX((pthis->spinRot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateY((pthis->spinRot.z / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_Translate(pthis->offset.x, pthis->offset.y, pthis->offset.z - 100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_kanban.c", 1715), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { - if (sPartFlags[i] & this->partFlags) { + if (sPartFlags[i] & pthis->partFlags) { gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[i]); } } @@ -834,32 +834,32 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Translate(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_kanban.c", 1725), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->partFlags == 0xFFFF) { + if (pthis->partFlags == 0xFFFF) { gSPDisplayList(POLY_OPA_DISP++, gSignRectangularDL); } else { for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { - if (sPartFlags[i] & this->partFlags) { + if (sPartFlags[i] & pthis->partFlags) { gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[i]); } } } - if (this->cutMarkAlpha != 0) { - f32 cutOffset = (this->cutType == CUT_POST) ? -1200.0f : 0.0f; + if (pthis->cutMarkAlpha != 0) { + f32 cutOffset = (pthis->cutType == CUT_POST) ? -1200.0f : 0.0f; Matrix_Translate(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); - Matrix_RotateZ(sCutAngles[this->cutType], MTXMODE_APPLY); + Matrix_RotateZ(sCutAngles[pthis->cutType], MTXMODE_APPLY); Matrix_Scale(0.0f, 10.0f, 2.0f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 255, this->cutMarkAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 255, pthis->cutMarkAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 150, 0); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_kanban.c", 1773), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_kanban_DL_001630); } } - if ((this->actor.projectedPos.z <= 400.0f) && (this->actor.projectedPos.z > 0.0f) && - (this->actor.floorHeight > -3000.0f)) { - if ((this->bounceX != 0) || (this->bounceZ != 0)) { + if ((pthis->actor.projectedPos.z <= 400.0f) && (pthis->actor.projectedPos.z > 0.0f) && + (pthis->actor.floorHeight > -3000.0f)) { + if ((pthis->bounceX != 0) || (pthis->bounceZ != 0)) { u16 dayTime = gSaveContext.dayTime; f32 shadowAlpha; @@ -867,35 +867,35 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { dayTime = 0xFFFF - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; - if (this->actor.projectedPos.z > 300.0f) { - shadowAlpha *= ((400.0f - this->actor.projectedPos.z) * 0.01f); + if (pthis->actor.projectedPos.z > 300.0f) { + shadowAlpha *= ((400.0f - pthis->actor.projectedPos.z) * 0.01f); } gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (s8)shadowAlpha); - if ((this->actionState == ENKANBAN_SIGN) && LINK_IS_CHILD) { + if ((pthis->actionState == ENKANBAN_SIGN) && LINK_IS_CHILD) { zShift = 0.0f; } else { - zShift = ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; + zShift = ((pthis->actor.world.pos.y - pthis->actor.floorHeight) * -50.0f) / 100.0f; } - Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.floorHeight, pthis->actor.world.pos.z + zShift, MTXMODE_NEW); - Matrix_RotateX(this->floorRot.x, MTXMODE_APPLY); - Matrix_RotateZ(this->floorRot.z, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, 0.0f, this->actor.scale.z, MTXMODE_APPLY); - if (this->actionState == ENKANBAN_SIGN) { + Matrix_RotateX(pthis->floorRot.x, MTXMODE_APPLY); + Matrix_RotateZ(pthis->floorRot.z, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, 0.0f, pthis->actor.scale.z, MTXMODE_APPLY); + if (pthis->actionState == ENKANBAN_SIGN) { Matrix_RotateX(-M_PI / 5, MTXMODE_APPLY); } - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateX((this->actor.shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateX((this->spinRot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_RotateY((this->spinRot.z / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_Translate(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateX((pthis->actor.shape.rot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateX((pthis->spinRot.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_RotateY((pthis->spinRot.z / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_Translate(pthis->offset.x, pthis->offset.y, pthis->offset.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_kanban.c", 1833), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < 0x400; i++) { - if (sShadowTexFlags[i] & this->partFlags) { + if (sShadowTexFlags[i] & pthis->partFlags) { shadowTex[i] = 0xFF; } else { shadowTex[i] = 0; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.c rename to src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.cpp diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c deleted file mode 100644 index 58b595283..000000000 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ /dev/null @@ -1,553 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAREBABA_Z_EN_KAREBABA_C -#include "actor_common.h" -/** - * File: z_en_karebaba.c - * Overlay: ovl_En_Karebaba - * Description: Withered Deku Baba - */ - -#include "z_en_karebaba.h" -#include "objects/object_dekubaba/object_dekubaba.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_eff_ss_dead.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnKarebaba_SetupGrow(EnKarebaba* this); -void EnKarebaba_SetupIdle(EnKarebaba* this); -void EnKarebaba_Grow(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Idle(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Awaken(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Spin(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Dying(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_DeadItemDrop(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Retract(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Dead(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Regrow(EnKarebaba* this, GlobalContext* globalCtx); -void EnKarebaba_Upright(EnKarebaba* this, GlobalContext* globalCtx); - -const ActorInit En_Karebaba_InitVars = { - ACTOR_EN_KAREBABA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_DEKUBABA, - sizeof(EnKarebaba), - (ActorFunc)EnKarebaba_Init, - (ActorFunc)EnKarebaba_Destroy, - (ActorFunc)EnKarebaba_Update, - (ActorFunc)EnKarebaba_Draw, -}; - -static ColliderCylinderInit sBodyColliderInit = { - { - COLTYPE_HARD, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 7, 25, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sHeadColliderInit = { - { - COLTYPE_HARD, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_NONE, - OCELEM_ON, - }, - { 4, 25, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColCheckInfoInit = { 1, 15, 80, MASS_HEAVY }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), - ICHAIN_S8(naviEnemyId, 0x09, ICHAIN_STOP), -}; - -void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKarebaba* this = (EnKarebaba*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuBabaSkel, &gDekuBabaFastChompAnim, this->jointTable, - this->morphTable, 8); - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, &this->actor, &sBodyColliderInit); - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - Collider_InitCylinder(globalCtx, &this->headCollider); - Collider_SetCylinder(globalCtx, &this->headCollider, &this->actor, &sHeadColliderInit); - Collider_UpdateCylinder(&this->actor, &this->headCollider); - CollisionCheck_SetInfo(&this->actor.colChkInfo, DamageTable_Get(1), &sColCheckInfoInit); - - this->boundFloor = NULL; - - if (this->actor.params == 0) { - EnKarebaba_SetupGrow(this); - } else { - EnKarebaba_SetupIdle(this); - } -} - -void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnKarebaba* this = (EnKarebaba*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyCylinder(globalCtx, &this->headCollider); -} - -void EnKarebaba_ResetCollider(EnKarebaba* this) { - this->bodyCollider.dim.radius = 7; - this->bodyCollider.dim.height = 25; - this->bodyCollider.base.colType = COLTYPE_HARD; - this->bodyCollider.base.acFlags |= AC_HARD; - this->bodyCollider.info.bumper.dmgFlags = ~0x00300000; - this->headCollider.dim.height = 25; -} - -void EnKarebaba_SetupGrow(EnKarebaba* this) { - Actor_SetScale(&this->actor, 0.0f); - this->actor.shape.rot.x = -0x4000; - this->actionFunc = EnKarebaba_Grow; - this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; -} - -void EnKarebaba_SetupIdle(EnKarebaba* this) { - Actor_SetScale(&this->actor, 0.005f); - this->actor.shape.rot.x = -0x4000; - this->actionFunc = EnKarebaba_Idle; - this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; -} - -void EnKarebaba_SetupAwaken(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 4.0f, 0.0f, - Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DUMMY482); - this->actionFunc = EnKarebaba_Awaken; -} - -void EnKarebaba_SetupUpright(EnKarebaba* this) { - if (this->actionFunc != EnKarebaba_Spin) { - Actor_SetScale(&this->actor, 0.01f); - this->bodyCollider.base.colType = COLTYPE_HIT6; - this->bodyCollider.base.acFlags &= ~AC_HARD; - this->bodyCollider.info.bumper.dmgFlags = !LINK_IS_ADULT ? 0x07C00710 : 0x0FC00710; - this->bodyCollider.dim.radius = 15; - this->bodyCollider.dim.height = 80; - this->headCollider.dim.height = 80; - } - - this->actor.params = 40; - this->actionFunc = EnKarebaba_Upright; -} - -void EnKarebaba_SetupSpin(EnKarebaba* this) { - this->actor.params = 40; - this->actionFunc = EnKarebaba_Spin; -} - -void EnKarebaba_SetupDying(EnKarebaba* this) { - this->actor.params = 0; - this->actor.gravity = -0.8f; - this->actor.velocity.y = 4.0f; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; - this->actor.speedXZ = 3.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_DEAD); - this->actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; - this->actionFunc = EnKarebaba_Dying; -} - -void EnKarebaba_SetupDeadItemDrop(EnKarebaba* this, GlobalContext* globalCtx) { - Actor_SetScale(&this->actor, 0.03f); - this->actor.shape.rot.x -= 0x4000; - this->actor.shape.yOffset = 1000.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.shape.shadowScale = 3.0f; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); - this->actor.params = 200; - this->actor.flags &= ~ACTOR_FLAG_5; - this->actionFunc = EnKarebaba_DeadItemDrop; -} - -void EnKarebaba_SetupRetract(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, -3.0f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), - 0.0f, ANIMMODE_ONCE, -3.0f); - EnKarebaba_ResetCollider(this); - this->actionFunc = EnKarebaba_Retract; -} - -void EnKarebaba_SetupDead(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); - EnKarebaba_ResetCollider(this); - this->actor.shape.rot.x = -0x4000; - this->actor.params = 200; - this->actor.parent = NULL; - this->actor.shape.shadowScale = 0.0f; - Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - this->actionFunc = EnKarebaba_Dead; -} - -void EnKarebaba_SetupRegrow(EnKarebaba* this) { - this->actor.shape.yOffset = 0.0f; - this->actor.shape.shadowScale = 22.0f; - this->headCollider.dim.radius = sHeadColliderInit.dim.radius; - Actor_SetScale(&this->actor, 0.0f); - this->actionFunc = EnKarebaba_Regrow; -} - -void EnKarebaba_Grow(EnKarebaba* this, GlobalContext* globalCtx) { - f32 scale; - - this->actor.params++; - scale = this->actor.params * 0.05f; - Actor_SetScale(&this->actor, 0.005f * scale); - this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * scale); - if (this->actor.params == 20) { - EnKarebaba_SetupIdle(this); - } -} - -void EnKarebaba_Idle(EnKarebaba* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < 200.0f && fabsf(this->actor.yDistToPlayer) < 30.0f) { - EnKarebaba_SetupAwaken(this); - } -} - -void EnKarebaba_Awaken(EnKarebaba* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f); - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 60.0f, 5.0f)) { - EnKarebaba_SetupUpright(this); - } - this->actor.shape.rot.y += 0x1999; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); -} - -void EnKarebaba_Upright(EnKarebaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - - if (this->actor.params != 0) { - this->actor.params--; - } - - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_MOUTH); - } - - if (this->bodyCollider.base.acFlags & AC_HIT) { - EnKarebaba_SetupDying(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 240.0f) { - EnKarebaba_SetupRetract(this); - } else if (this->actor.params == 0) { - EnKarebaba_SetupSpin(this); - } -} - -void EnKarebaba_Spin(EnKarebaba* this, GlobalContext* globalCtx) { - s32 value; - f32 cos60; - - if (this->actor.params != 0) { - this->actor.params--; - } - - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { - if (1) {} // Here for matching purposes only. - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_JR_MOUTH); - } - - value = 20 - this->actor.params; - value = 20 - ABS(value); - - if (value > 10) { - value = 10; - } - - this->headCollider.dim.radius = sHeadColliderInit.dim.radius + (value * 2); - this->actor.shape.rot.x = 0xC000 - (value * 0x100); - this->actor.shape.rot.y += value * 0x2C0; - this->actor.world.pos.y = (Math_SinS(this->actor.shape.rot.x) * -60.0f) + this->actor.home.pos.y; - - cos60 = Math_CosS(this->actor.shape.rot.x) * 60.0f; - - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * cos60) + this->actor.home.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * cos60) + this->actor.home.pos.z; - - if (this->bodyCollider.base.acFlags & AC_HIT) { - EnKarebaba_SetupDying(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else if (this->actor.params == 0) { - EnKarebaba_SetupUpright(this); - } -} - -void EnKarebaba_Dying(EnKarebaba* this, GlobalContext* globalCtx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - s32 i; - Vec3f position; - Vec3f rotation; - - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); - - if (this->actor.params == 0) { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); - - if (this->actor.scale.x > 0.005f && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, HAHEN_OBJECT_DEFAULT, 10, - NULL); - } - - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - this->actor.params = 1; - } - } else if (this->actor.params == 1) { - Math_Vec3f_Copy(&position, &this->actor.world.pos); - rotation.z = Math_SinS(this->actor.shape.rot.x) * 20.0f; - rotation.x = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y); - rotation.y = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y); - - for (i = 0; i < 4; i++) { - func_800286CC(globalCtx, &position, &zeroVec, &zeroVec, 500, 50); - position.x += rotation.x; - position.y += rotation.z; - position.z += rotation.y; - } - - func_800286CC(globalCtx, &this->actor.home.pos, &zeroVec, &zeroVec, 500, 100); - EnKarebaba_SetupDeadItemDrop(this, globalCtx); - } -} - -void EnKarebaba_DeadItemDrop(EnKarebaba* this, GlobalContext* globalCtx) { - if (this->actor.params != 0) { - this->actor.params--; - } - - if (Actor_HasParent(&this->actor, globalCtx) || this->actor.params == 0) { - EnKarebaba_SetupDead(this); - } else { - func_8002F554(&this->actor, globalCtx, GI_STICKS_1); - } -} - -void EnKarebaba_Retract(EnKarebaba* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f); - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; - - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 14.0f, 5.0f)) { - EnKarebaba_SetupIdle(this); - } - - this->actor.shape.rot.y += 0x1999; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); -} - -void EnKarebaba_Dead(EnKarebaba* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->actor.params != 0) { - this->actor.params--; - } - if (this->actor.params == 0) { - EnKarebaba_SetupRegrow(this); - } -} - -void EnKarebaba_Regrow(EnKarebaba* this, GlobalContext* globalCtx) { - f32 scaleFactor; - - this->actor.params++; - scaleFactor = this->actor.params * 0.05f; - Actor_SetScale(&this->actor, 0.005f * scaleFactor); - this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * scaleFactor); - - if (this->actor.params == 20) { - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - EnKarebaba_SetupIdle(this); - } -} - -void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnKarebaba* this = (EnKarebaba*)thisx; - f32 height; - - this->actionFunc(this, globalCtx); - - if (this->actionFunc != EnKarebaba_Dead) { - if (this->actionFunc == EnKarebaba_Dying) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 10.0f, 5); - } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (this->boundFloor == NULL) { - this->boundFloor = this->actor.floorPoly; - } - } - if (this->actionFunc != EnKarebaba_Dying && this->actionFunc != EnKarebaba_DeadItemDrop) { - if (this->actionFunc != EnKarebaba_Regrow && this->actionFunc != EnKarebaba_Grow) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); - Actor_SetFocus(&this->actor, (this->actor.scale.x * 10.0f) / 0.01f); - height = this->actor.home.pos.y + 40.0f; - this->actor.focus.pos.x = this->actor.home.pos.x; - this->actor.focus.pos.y = CLAMP_MAX(this->actor.focus.pos.y, height); - this->actor.focus.pos.z = this->actor.home.pos.z; - } - } -} - -void EnKarebaba_DrawBaseShadow(EnKarebaba* this, GlobalContext* globalCtx) { - MtxF mf; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1013); - - func_80094044(globalCtx->state.gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); - func_80038A28(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &mf); - Matrix_Mult(&mf, MTXMODE_NEW); - Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1029), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1034); -} - -void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Color_RGBA8 black = { 0, 0, 0, 0 }; - static Gfx* stemDLists[] = { gDekuBabaStemTopDL, gDekuBabaStemMiddleDL, gDekuBabaStemBaseDL }; - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - EnKarebaba* this = (EnKarebaba*)thisx; - s32 i; - s32 stemSections; - f32 scale; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1056); - - func_80093D18(globalCtx->state.gfxCtx); - - if (this->actionFunc == EnKarebaba_DeadItemDrop) { - if (this->actor.params > 40 || (this->actor.params & 1)) { - Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1066), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStickDropDL); - } - } else if (this->actionFunc != EnKarebaba_Dead) { - func_80026230(globalCtx, &black, 1, 2); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - - if ((this->actionFunc == EnKarebaba_Regrow) || (this->actionFunc == EnKarebaba_Grow)) { - scale = this->actor.params * 0.0005f; - } else { - scale = 0.01f; - } - - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - - if (this->actionFunc == EnKarebaba_Dying) { - stemSections = 2; - } else { - stemSections = 3; - } - - for (i = 0; i < stemSections; i++) { - Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1116), - G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, stemDLists[i]); - - if (i == 0 && this->actionFunc == EnKarebaba_Dying) { - Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); - } - } - - func_80026608(globalCtx); - } - - func_80026230(globalCtx, &black, 1, 2); - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); - - if (this->actionFunc != EnKarebaba_Grow) { - scale = 0.01f; - } - - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_RotateY(this->actor.home.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1144), - G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaBaseLeavesDL); - - if (this->actionFunc == EnKarebaba_Dying) { - Matrix_RotateZYX(-0x4000, (s16)(this->actor.shape.rot.y - this->actor.home.rot.y), 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1155), - G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemBaseDL); - } - - func_80026608(globalCtx); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1163); - - if (this->boundFloor != NULL) { - EnKarebaba_DrawBaseShadow(this, globalCtx); - } -} diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.cpp b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.cpp new file mode 100644 index 000000000..71832cfee --- /dev/null +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.cpp @@ -0,0 +1,553 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KAREBABA_Z_EN_KAREBABA_C +#include "actor_common.h" +/** + * File: z_en_karebaba.c + * Overlay: ovl_En_Karebaba + * Description: Withered Deku Baba + */ + +#include "z_en_karebaba.h" +#include "objects/object_dekubaba/object_dekubaba.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_eff_ss_dead.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx); +void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnKarebaba_SetupGrow(EnKarebaba* pthis); +void EnKarebaba_SetupIdle(EnKarebaba* pthis); +void EnKarebaba_Grow(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Idle(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Awaken(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Spin(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Dying(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_DeadItemDrop(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Retract(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Dead(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Regrow(EnKarebaba* pthis, GlobalContext* globalCtx); +void EnKarebaba_Upright(EnKarebaba* pthis, GlobalContext* globalCtx); + +ActorInit En_Karebaba_InitVars = { + ACTOR_EN_KAREBABA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_DEKUBABA, + sizeof(EnKarebaba), + (ActorFunc)EnKarebaba_Init, + (ActorFunc)EnKarebaba_Destroy, + (ActorFunc)EnKarebaba_Update, + (ActorFunc)EnKarebaba_Draw, +}; + +static ColliderCylinderInit sBodyColliderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 7, 25, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sHeadColliderInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_ON, + }, + { 4, 25, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColCheckInfoInit = { 1, 15, 80, MASS_HEAVY }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), + ICHAIN_S8(naviEnemyId, 0x09, ICHAIN_STOP), +}; + +void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* pthis = (EnKarebaba*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gDekuBabaSkel, &gDekuBabaFastChompAnim, pthis->jointTable, + pthis->morphTable, 8); + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, &pthis->actor, &sBodyColliderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + Collider_InitCylinder(globalCtx, &pthis->headCollider); + Collider_SetCylinder(globalCtx, &pthis->headCollider, &pthis->actor, &sHeadColliderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->headCollider); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, DamageTable_Get(1), &sColCheckInfoInit); + + pthis->boundFloor = NULL; + + if (pthis->actor.params == 0) { + EnKarebaba_SetupGrow(pthis); + } else { + EnKarebaba_SetupIdle(pthis); + } +} + +void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* pthis = (EnKarebaba*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyCylinder(globalCtx, &pthis->headCollider); +} + +void EnKarebaba_ResetCollider(EnKarebaba* pthis) { + pthis->bodyCollider.dim.radius = 7; + pthis->bodyCollider.dim.height = 25; + pthis->bodyCollider.base.colType = COLTYPE_HARD; + pthis->bodyCollider.base.acFlags |= AC_HARD; + pthis->bodyCollider.info.bumper.dmgFlags = ~0x00300000; + pthis->headCollider.dim.height = 25; +} + +void EnKarebaba_SetupGrow(EnKarebaba* pthis) { + Actor_SetScale(&pthis->actor, 0.0f); + pthis->actor.shape.rot.x = -0x4000; + pthis->actionFunc = EnKarebaba_Grow; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 14.0f; +} + +void EnKarebaba_SetupIdle(EnKarebaba* pthis) { + Actor_SetScale(&pthis->actor, 0.005f); + pthis->actor.shape.rot.x = -0x4000; + pthis->actionFunc = EnKarebaba_Idle; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 14.0f; +} + +void EnKarebaba_SetupAwaken(EnKarebaba* pthis) { + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, 4.0f, 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DUMMY482); + pthis->actionFunc = EnKarebaba_Awaken; +} + +void EnKarebaba_SetupUpright(EnKarebaba* pthis) { + if (pthis->actionFunc != EnKarebaba_Spin) { + Actor_SetScale(&pthis->actor, 0.01f); + pthis->bodyCollider.base.colType = COLTYPE_HIT6; + pthis->bodyCollider.base.acFlags &= ~AC_HARD; + pthis->bodyCollider.info.bumper.dmgFlags = !LINK_IS_ADULT ? 0x07C00710 : 0x0FC00710; + pthis->bodyCollider.dim.radius = 15; + pthis->bodyCollider.dim.height = 80; + pthis->headCollider.dim.height = 80; + } + + pthis->actor.params = 40; + pthis->actionFunc = EnKarebaba_Upright; +} + +void EnKarebaba_SetupSpin(EnKarebaba* pthis) { + pthis->actor.params = 40; + pthis->actionFunc = EnKarebaba_Spin; +} + +void EnKarebaba_SetupDying(EnKarebaba* pthis) { + pthis->actor.params = 0; + pthis->actor.gravity = -0.8f; + pthis->actor.velocity.y = 4.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x8000; + pthis->actor.speedXZ = 3.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_DEAD); + pthis->actor.flags |= ACTOR_FLAG_4 | ACTOR_FLAG_5; + pthis->actionFunc = EnKarebaba_Dying; +} + +void EnKarebaba_SetupDeadItemDrop(EnKarebaba* pthis, GlobalContext* globalCtx) { + Actor_SetScale(&pthis->actor, 0.03f); + pthis->actor.shape.rot.x -= 0x4000; + pthis->actor.shape.yOffset = 1000.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.shape.shadowScale = 3.0f; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_MISC); + pthis->actor.params = 200; + pthis->actor.flags &= ~ACTOR_FLAG_5; + pthis->actionFunc = EnKarebaba_DeadItemDrop; +} + +void EnKarebaba_SetupRetract(EnKarebaba* pthis) { + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, -3.0f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); + EnKarebaba_ResetCollider(pthis); + pthis->actionFunc = EnKarebaba_Retract; +} + +void EnKarebaba_SetupDead(EnKarebaba* pthis) { + Animation_Change(&pthis->skelAnime, &gDekuBabaFastChompAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); + EnKarebaba_ResetCollider(pthis); + pthis->actor.shape.rot.x = -0x4000; + pthis->actor.params = 200; + pthis->actor.parent = NULL; + pthis->actor.shape.shadowScale = 0.0f; + Math_Vec3f_Copy(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->actionFunc = EnKarebaba_Dead; +} + +void EnKarebaba_SetupRegrow(EnKarebaba* pthis) { + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.shape.shadowScale = 22.0f; + pthis->headCollider.dim.radius = sHeadColliderInit.dim.radius; + Actor_SetScale(&pthis->actor, 0.0f); + pthis->actionFunc = EnKarebaba_Regrow; +} + +void EnKarebaba_Grow(EnKarebaba* pthis, GlobalContext* globalCtx) { + f32 scale; + + pthis->actor.params++; + scale = pthis->actor.params * 0.05f; + Actor_SetScale(&pthis->actor, 0.005f * scale); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (14.0f * scale); + if (pthis->actor.params == 20) { + EnKarebaba_SetupIdle(pthis); + } +} + +void EnKarebaba_Idle(EnKarebaba* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer < 200.0f && fabsf(pthis->actor.yDistToPlayer) < 30.0f) { + EnKarebaba_SetupAwaken(pthis); + } +} + +void EnKarebaba_Awaken(EnKarebaba* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.scale.x, 0.01f, 0.0005f); + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 60.0f, 5.0f)) { + EnKarebaba_SetupUpright(pthis); + } + pthis->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); +} + +void EnKarebaba_Upright(EnKarebaba* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.params != 0) { + pthis->actor.params--; + } + + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_MOUTH); + } + + if (pthis->bodyCollider.base.acFlags & AC_HIT) { + EnKarebaba_SetupDying(pthis); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else if (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) > 240.0f) { + EnKarebaba_SetupRetract(pthis); + } else if (pthis->actor.params == 0) { + EnKarebaba_SetupSpin(pthis); + } +} + +void EnKarebaba_Spin(EnKarebaba* pthis, GlobalContext* globalCtx) { + s32 value; + f32 cos60; + + if (pthis->actor.params != 0) { + pthis->actor.params--; + } + + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + if (1) {} // Here for matching purposes only. + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_JR_MOUTH); + } + + value = 20 - pthis->actor.params; + value = 20 - ABS(value); + + if (value > 10) { + value = 10; + } + + pthis->headCollider.dim.radius = sHeadColliderInit.dim.radius + (value * 2); + pthis->actor.shape.rot.x = 0xC000 - (value * 0x100); + pthis->actor.shape.rot.y += value * 0x2C0; + pthis->actor.world.pos.y = (Math_SinS(pthis->actor.shape.rot.x) * -60.0f) + pthis->actor.home.pos.y; + + cos60 = Math_CosS(pthis->actor.shape.rot.x) * 60.0f; + + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y) * cos60) + pthis->actor.home.pos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y) * cos60) + pthis->actor.home.pos.z; + + if (pthis->bodyCollider.base.acFlags & AC_HIT) { + EnKarebaba_SetupDying(pthis); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else if (pthis->actor.params == 0) { + EnKarebaba_SetupUpright(pthis); + } +} + +void EnKarebaba_Dying(EnKarebaba* pthis, GlobalContext* globalCtx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 i; + Vec3f position; + Vec3f rotation; + + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.1f); + + if (pthis->actor.params == 0) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x4800, 0x71C); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if (pthis->actor.scale.x > 0.005f && ((pthis->actor.bgCheckFlags & 2) || (pthis->actor.bgCheckFlags & 8))) { + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 3.0f, 0, 12, 5, 15, HAHEN_OBJECT_DEFAULT, 10, + NULL); + } + + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + pthis->actor.params = 1; + } + } else if (pthis->actor.params == 1) { + Math_Vec3f_Copy(&position, &pthis->actor.world.pos); + rotation.z = Math_SinS(pthis->actor.shape.rot.x) * 20.0f; + rotation.x = -20.0f * Math_CosS(pthis->actor.shape.rot.x) * Math_SinS(pthis->actor.shape.rot.y); + rotation.y = -20.0f * Math_CosS(pthis->actor.shape.rot.x) * Math_CosS(pthis->actor.shape.rot.y); + + for (i = 0; i < 4; i++) { + func_800286CC(globalCtx, &position, &zeroVec, &zeroVec, 500, 50); + position.x += rotation.x; + position.y += rotation.z; + position.z += rotation.y; + } + + func_800286CC(globalCtx, &pthis->actor.home.pos, &zeroVec, &zeroVec, 500, 100); + EnKarebaba_SetupDeadItemDrop(pthis, globalCtx); + } +} + +void EnKarebaba_DeadItemDrop(EnKarebaba* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params != 0) { + pthis->actor.params--; + } + + if (Actor_HasParent(&pthis->actor, globalCtx) || pthis->actor.params == 0) { + EnKarebaba_SetupDead(pthis); + } else { + func_8002F554(&pthis->actor, globalCtx, GI_STICKS_1); + } +} + +void EnKarebaba_Retract(EnKarebaba* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.scale.x, 0.005f, 0.0005f); + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; + + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 14.0f, 5.0f)) { + EnKarebaba_SetupIdle(pthis); + } + + pthis->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); +} + +void EnKarebaba_Dead(EnKarebaba* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.params != 0) { + pthis->actor.params--; + } + if (pthis->actor.params == 0) { + EnKarebaba_SetupRegrow(pthis); + } +} + +void EnKarebaba_Regrow(EnKarebaba* pthis, GlobalContext* globalCtx) { + f32 scaleFactor; + + pthis->actor.params++; + scaleFactor = pthis->actor.params * 0.05f; + Actor_SetScale(&pthis->actor, 0.005f * scaleFactor); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (14.0f * scaleFactor); + + if (pthis->actor.params == 20) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + EnKarebaba_SetupIdle(pthis); + } +} + +void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKarebaba* pthis = (EnKarebaba*)thisx; + f32 height; + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actionFunc != EnKarebaba_Dead) { + if (pthis->actionFunc == EnKarebaba_Dying) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 15.0f, 10.0f, 5); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if (pthis->boundFloor == NULL) { + pthis->boundFloor = pthis->actor.floorPoly; + } + } + if (pthis->actionFunc != EnKarebaba_Dying && pthis->actionFunc != EnKarebaba_DeadItemDrop) { + if (pthis->actionFunc != EnKarebaba_Regrow && pthis->actionFunc != EnKarebaba_Grow) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->headCollider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->headCollider.base); + Actor_SetFocus(&pthis->actor, (pthis->actor.scale.x * 10.0f) / 0.01f); + height = pthis->actor.home.pos.y + 40.0f; + pthis->actor.focus.pos.x = pthis->actor.home.pos.x; + pthis->actor.focus.pos.y = CLAMP_MAX(pthis->actor.focus.pos.y, height); + pthis->actor.focus.pos.z = pthis->actor.home.pos.z; + } + } +} + +void EnKarebaba_DrawBaseShadow(EnKarebaba* pthis, GlobalContext* globalCtx) { + MtxF mf; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1013); + + func_80094044(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + func_80038A28(pthis->boundFloor, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, &mf); + Matrix_Mult(&mf, MTXMODE_NEW); + Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1029), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1034); +} + +void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Color_RGBA8 black = { 0, 0, 0, 0 }; + static Gfx* stemDLists[] = { gDekuBabaStemTopDL, gDekuBabaStemMiddleDL, gDekuBabaStemBaseDL }; + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + EnKarebaba* pthis = (EnKarebaba*)thisx; + s32 i; + s32 stemSections; + f32 scale; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1056); + + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->actionFunc == EnKarebaba_DeadItemDrop) { + if (pthis->actor.params > 40 || (pthis->actor.params & 1)) { + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1066), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStickDropDL); + } + } else if (pthis->actionFunc != EnKarebaba_Dead) { + func_80026230(globalCtx, &black, 1, 2); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, NULL, NULL); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + + if ((pthis->actionFunc == EnKarebaba_Regrow) || (pthis->actionFunc == EnKarebaba_Grow)) { + scale = pthis->actor.params * 0.0005f; + } else { + scale = 0.01f; + } + + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateZYX(pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, 0, MTXMODE_APPLY); + + if (pthis->actionFunc == EnKarebaba_Dying) { + stemSections = 2; + } else { + stemSections = 3; + } + + for (i = 0; i < stemSections; i++) { + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1116), + G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, stemDLists[i]); + + if (i == 0 && pthis->actionFunc == EnKarebaba_Dying) { + Matrix_MultVec3f(&zeroVec, &pthis->actor.focus.pos); + } + } + + func_80026608(globalCtx); + } + + func_80026230(globalCtx, &black, 1, 2); + Matrix_Translate(pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, MTXMODE_NEW); + + if (pthis->actionFunc != EnKarebaba_Grow) { + scale = 0.01f; + } + + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateY(pthis->actor.home.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1144), + G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaBaseLeavesDL); + + if (pthis->actionFunc == EnKarebaba_Dying) { + Matrix_RotateZYX(-0x4000, (s16)(pthis->actor.shape.rot.y - pthis->actor.home.rot.y), 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1155), + G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemBaseDL); + } + + func_80026608(globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_karebaba.c", 1163); + + if (pthis->boundFloor != NULL) { + EnKarebaba_DrawBaseShadow(pthis, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.c b/src/overlays/actors/ovl_En_Ko/z_en_ko.cpp similarity index 62% rename from src/overlays/actors/ovl_En_Ko/z_en_ko.c rename to src/overlays/actors/ovl_En_Ko/z_en_ko.cpp index b8c91c836..86fc44ee5 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.c +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.cpp @@ -30,24 +30,24 @@ #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) -#define ENKO_TYPE (this->actor.params & 0xFF) -#define ENKO_PATH ((this->actor.params & 0xFF00) >> 8) +#define ENKO_TYPE (pthis->actor.params & 0xFF) +#define ENKO_PATH ((pthis->actor.params & 0xFF00) >> 8) void EnKo_Init(Actor* thisx, GlobalContext* globalCtx); void EnKo_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKo_Update(Actor* thisx, GlobalContext* globalCtx); void EnKo_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A99048(EnKo* this, GlobalContext* globalCtx); -void func_80A995CC(EnKo* this, GlobalContext* globalCtx); -void func_80A99384(EnKo* this, GlobalContext* globalCtx); -void func_80A99438(EnKo* this, GlobalContext* globalCtx); -void func_80A99504(EnKo* this, GlobalContext* globalCtx); -void func_80A99560(EnKo* this, GlobalContext* globalCtx); +void func_80A99048(EnKo* pthis, GlobalContext* globalCtx); +void func_80A995CC(EnKo* pthis, GlobalContext* globalCtx); +void func_80A99384(EnKo* pthis, GlobalContext* globalCtx); +void func_80A99438(EnKo* pthis, GlobalContext* globalCtx); +void func_80A99504(EnKo* pthis, GlobalContext* globalCtx); +void func_80A99560(EnKo* pthis, GlobalContext* globalCtx); -s32 func_80A98ECC(EnKo* this, GlobalContext* globalCtx); +s32 func_80A98ECC(EnKo* pthis, GlobalContext* globalCtx); -const ActorInit En_Ko_InitVars = { +ActorInit En_Ko_InitVars = { ACTOR_EN_KO, ACTORCAT_NPC, FLAGS, @@ -211,58 +211,58 @@ static EnKoInteractInfo sInteractInfo[] = { /* ENKO_TYPE_CHILD_FADO */ { 6, 30.0f, 180.0f }, }; -s32 EnKo_AreObjectsAvailable(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_AreObjectsAvailable(EnKo* pthis, GlobalContext* globalCtx) { u8 headId = sModelInfo[ENKO_TYPE].headId; u8 bodyId = sModelInfo[ENKO_TYPE].bodyId; u8 legsId = sModelInfo[ENKO_TYPE].legsId; - this->legsObjectBankIdx = Object_GetIndex(&globalCtx->objectCtx, sSkeleton[legsId].objectId); - if (this->legsObjectBankIdx < 0) { + pthis->legsObjectBankIdx = Object_GetIndex(&globalCtx->objectCtx, sSkeleton[legsId].objectId); + if (pthis->legsObjectBankIdx < 0) { return false; } - this->bodyObjectBankIdx = Object_GetIndex(&globalCtx->objectCtx, sSkeleton[bodyId].objectId); - if (this->bodyObjectBankIdx < 0) { + pthis->bodyObjectBankIdx = Object_GetIndex(&globalCtx->objectCtx, sSkeleton[bodyId].objectId); + if (pthis->bodyObjectBankIdx < 0) { return false; } - this->headObjectBankIdx = Object_GetIndex(&globalCtx->objectCtx, sHead[headId].objectId); - if (this->headObjectBankIdx < 0) { + pthis->headObjectBankIdx = Object_GetIndex(&globalCtx->objectCtx, sHead[headId].objectId); + if (pthis->headObjectBankIdx < 0) { return false; } return true; } -s32 EnKo_AreObjectsLoaded(EnKo* this, GlobalContext* globalCtx) { - if (!Object_IsLoaded(&globalCtx->objectCtx, this->legsObjectBankIdx)) { +s32 EnKo_AreObjectsLoaded(EnKo* pthis, GlobalContext* globalCtx) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->legsObjectBankIdx)) { return false; } - if (!Object_IsLoaded(&globalCtx->objectCtx, this->bodyObjectBankIdx)) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->bodyObjectBankIdx)) { return false; } - if (!Object_IsLoaded(&globalCtx->objectCtx, this->headObjectBankIdx)) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->headObjectBankIdx)) { return false; } return true; } -s32 EnKo_IsOsAnimeAvailable(EnKo* this, GlobalContext* globalCtx) { - this->osAnimeBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); - if (this->osAnimeBankIndex < 0) { +s32 EnKo_IsOsAnimeAvailable(EnKo* pthis, GlobalContext* globalCtx) { + pthis->osAnimeBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); + if (pthis->osAnimeBankIndex < 0) { return false; } return true; } -s32 EnKo_IsOsAnimeLoaded(EnKo* this, GlobalContext* globalCtx) { - if (!Object_IsLoaded(&globalCtx->objectCtx, this->osAnimeBankIndex)) { +s32 EnKo_IsOsAnimeLoaded(EnKo* pthis, GlobalContext* globalCtx) { + if (!Object_IsLoaded(&globalCtx->objectCtx, pthis->osAnimeBankIndex)) { return false; } return true; } u16 func_80A96FD0(GlobalContext* globalCtx, Actor* thisx) { - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_FADO: if (gSaveContext.eventChkInf[4] & 1) { @@ -362,7 +362,7 @@ u16 func_80A96FD0(GlobalContext* globalCtx, Actor* thisx) { u16 func_80A97338(GlobalContext* globalCtx, Actor* thisx) { Player* player = GET_PLAYER(globalCtx); - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_FADO: @@ -447,7 +447,7 @@ u16 func_80A97338(GlobalContext* globalCtx, Actor* thisx) { u16 func_80A97610(GlobalContext* globalCtx, Actor* thisx) { u16 faceReaction; - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; if (ENKO_TYPE == ENKO_TYPE_CHILD_0 || ENKO_TYPE == ENKO_TYPE_CHILD_2 || ENKO_TYPE == ENKO_TYPE_CHILD_3 || ENKO_TYPE == ENKO_TYPE_CHILD_4 || ENKO_TYPE == ENKO_TYPE_CHILD_7 || ENKO_TYPE == ENKO_TYPE_CHILD_8 || @@ -471,11 +471,11 @@ u16 func_80A97610(GlobalContext* globalCtx, Actor* thisx) { } s16 func_80A97738(GlobalContext* globalCtx, Actor* thisx) { - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; switch (Message_GetState(&globalCtx->msgCtx)) { case TEXT_STATE_CLOSING: - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x1005: gSaveContext.infTable[1] |= 0x4000; break; @@ -514,38 +514,38 @@ s16 func_80A97738(GlobalContext* globalCtx, Actor* thisx) { } return 0; case TEXT_STATE_DONE_FADING: - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x10B7: case 0x10B8: - if (this->unk_210 == 0) { + if (pthis->unk_210 == 0) { Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_210 = 1; + pthis->unk_210 = 1; } } return 1; case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(globalCtx)) { - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x1035: - this->actor.textId = (globalCtx->msgCtx.choiceIndex == 0) ? 0x1036 : 0x1037; - Message_ContinueTextbox(globalCtx, this->actor.textId); + pthis->actor.textId = (globalCtx->msgCtx.choiceIndex == 0) ? 0x1036 : 0x1037; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); break; case 0x1038: - this->actor.textId = (globalCtx->msgCtx.choiceIndex != 0) + pthis->actor.textId = (globalCtx->msgCtx.choiceIndex != 0) ? (globalCtx->msgCtx.choiceIndex == 1) ? 0x103A : 0x103B : 0x1039; - Message_ContinueTextbox(globalCtx, this->actor.textId); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); break; case 0x103E: - this->actor.textId = (globalCtx->msgCtx.choiceIndex == 0) ? 0x103F : 0x1040; - Message_ContinueTextbox(globalCtx, this->actor.textId); + pthis->actor.textId = (globalCtx->msgCtx.choiceIndex == 0) ? 0x103F : 0x1040; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); break; case 0x10B7: gSaveContext.infTable[11] |= 0x1000; case 0x10B8: - this->actor.textId = (globalCtx->msgCtx.choiceIndex == 0) ? 0x10BA : 0x10B9; + pthis->actor.textId = (globalCtx->msgCtx.choiceIndex == 0) ? 0x10BA : 0x10B9; return (globalCtx->msgCtx.choiceIndex == 0) ? 2 : 1; } return 1; @@ -559,7 +559,7 @@ s16 func_80A97738(GlobalContext* globalCtx, Actor* thisx) { return 1; } -s32 EnKo_GetForestQuestState(EnKo* this) { +s32 EnKo_GetForestQuestState(EnKo* pthis) { s32 result; if (!LINK_IS_ADULT) { @@ -581,7 +581,7 @@ s32 EnKo_GetForestQuestState(EnKo* this) { return result; } -f32 func_80A97BC0(EnKo* this) { +f32 func_80A97BC0(EnKo* pthis) { f32 D_80A9A62C[13][5] = { /* ENKO_TYPE_CHILD_0 */ { 0.0f, 0.0f, 0.0f, -30.0f, -20.0f }, /* ENKO_TYPE_CHILD_1 */ { 0.0f, 0.0f, 0.0f, -20.0f, -10.0f }, @@ -601,10 +601,10 @@ f32 func_80A97BC0(EnKo* this) { if (LINK_IS_ADULT && ENKO_TYPE == ENKO_TYPE_CHILD_FADO) { return -20.0f; } - return D_80A9A62C[ENKO_TYPE][EnKo_GetForestQuestState(this)]; + return D_80A9A62C[ENKO_TYPE][EnKo_GetForestQuestState(pthis)]; } -u8 func_80A97C7C(EnKo* this) { +u8 func_80A97C7C(EnKo* pthis) { u8 D_80A9A730[13][5] = { /* ENKO_TYPE_CHILD_0 */ { 1, 1, 1, 0, 1 }, /* ENKO_TYPE_CHILD_1 */ { 1, 1, 1, 1, 1 }, @@ -621,15 +621,15 @@ u8 func_80A97C7C(EnKo* this) { /* ENKO_TYPE_CHILD_FADO */ { 1, 1, 1, 1, 1 }, }; - return D_80A9A730[ENKO_TYPE][EnKo_GetForestQuestState(this)]; + return D_80A9A730[ENKO_TYPE][EnKo_GetForestQuestState(pthis)]; } -s32 EnKo_IsWithinTalkAngle(EnKo* this) { +s32 EnKo_IsWithinTalkAngle(EnKo* pthis) { s16 yawDiff; s16 yawDiffAbs; s32 result; - yawDiff = this->actor.yawTowardsPlayer - (f32)this->actor.shape.rot.y; + yawDiff = pthis->actor.yawTowardsPlayer - (f32)pthis->actor.shape.rot.y; yawDiffAbs = ABS(yawDiff); if (yawDiffAbs < 0x3FFC) { @@ -640,311 +640,311 @@ s32 EnKo_IsWithinTalkAngle(EnKo* this) { return result; } -s32 func_80A97D68(EnKo* this, GlobalContext* globalCtx) { +s32 func_80A97D68(EnKo* pthis, GlobalContext* globalCtx) { s16 arg3; - if (this->unk_1E8.unk_00 != 0) { - if ((this->skelAnime.animation == &gObjOsAnim_6A60) == false) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 0x20); + if (pthis->unk_1E8.unk_00 != 0) { + if ((pthis->skelAnime.animation == &gObjOsAnim_6A60) == false) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 0x20); } arg3 = 2; } else { - if ((this->skelAnime.animation == &gObjOsAnim_7830) == false) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 0x21); + if ((pthis->skelAnime.animation == &gObjOsAnim_7830) == false) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 0x21); } arg3 = 1; } - func_80034A14(&this->actor, &this->unk_1E8, 2, arg3); - return EnKo_IsWithinTalkAngle(this); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, arg3); + return EnKo_IsWithinTalkAngle(pthis); } -s32 func_80A97E18(EnKo* this, GlobalContext* globalCtx) { +s32 func_80A97E18(EnKo* pthis, GlobalContext* globalCtx) { s16 arg3; - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); - if (EnKo_IsWithinTalkAngle(this) == true) { + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); + if (EnKo_IsWithinTalkAngle(pthis) == true) { arg3 = 2; } else { arg3 = 1; } - if (this->unk_1E8.unk_00 != 0) { + if (pthis->unk_1E8.unk_00 != 0) { arg3 = 4; - } else if (this->lookDist < this->actor.xzDistToPlayer) { + } else if (pthis->lookDist < pthis->actor.xzDistToPlayer) { arg3 = 1; } - func_80034A14(&this->actor, &this->unk_1E8, 2, arg3); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, arg3); return 1; } -s32 func_80A97EB0(EnKo* this, GlobalContext* globalCtx) { +s32 func_80A97EB0(EnKo* pthis, GlobalContext* globalCtx) { s16 arg3; s32 result; - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); - result = EnKo_IsWithinTalkAngle(this); + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); + result = EnKo_IsWithinTalkAngle(pthis); arg3 = (result == true) ? 2 : 1; - func_80034A14(&this->actor, &this->unk_1E8, 2, arg3); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, arg3); return result; } -s32 func_80A97F20(EnKo* this, GlobalContext* globalCtx) { - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); - func_80034A14(&this->actor, &this->unk_1E8, 2, 4); +s32 func_80A97F20(EnKo* pthis, GlobalContext* globalCtx) { + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, 4); return 1; } -s32 func_80A97F70(EnKo* this, GlobalContext* globalCtx) { +s32 func_80A97F70(EnKo* pthis, GlobalContext* globalCtx) { s16 arg3; - if (this->unk_1E8.unk_00 != 0) { - if ((this->skelAnime.animation == &gObjOsAnim_8F6C) == false) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 0x1D); + if (pthis->unk_1E8.unk_00 != 0) { + if ((pthis->skelAnime.animation == &gObjOsAnim_8F6C) == false) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 0x1D); } - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); arg3 = 2; } else { - if ((this->skelAnime.animation == &gObjOsAnim_7D94) == false) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 0x1E); + if ((pthis->skelAnime.animation == &gObjOsAnim_7D94) == false) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 0x1E); } arg3 = 1; } - func_80034A14(&this->actor, &this->unk_1E8, 5, arg3); - return EnKo_IsWithinTalkAngle(this); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 5, arg3); + return EnKo_IsWithinTalkAngle(pthis); } -s32 func_80A98034(EnKo* this, GlobalContext* globalCtx) { +s32 func_80A98034(EnKo* pthis, GlobalContext* globalCtx) { s16 arg3; s32 result; - if (this->unk_1E8.unk_00 != 0) { - if ((this->skelAnime.animation == &gObjOsAnim_8F6C) == false) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 0x1D); + if (pthis->unk_1E8.unk_00 != 0) { + if ((pthis->skelAnime.animation == &gObjOsAnim_8F6C) == false) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 0x1D); } - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); - result = EnKo_IsWithinTalkAngle(this); + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); + result = EnKo_IsWithinTalkAngle(pthis); arg3 = (result == true) ? 2 : 1; } else { - if ((this->skelAnime.animation == &gObjOsAnim_879C) == false) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 0x1F); + if ((pthis->skelAnime.animation == &gObjOsAnim_879C) == false) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 0x1F); } arg3 = 1; - result = EnKo_IsWithinTalkAngle(this); + result = EnKo_IsWithinTalkAngle(pthis); } - func_80034A14(&this->actor, &this->unk_1E8, 5, arg3); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 5, arg3); return result; } // Same as func_80A97F20 -s32 func_80A98124(EnKo* this, GlobalContext* globalCtx) { - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); - func_80034A14(&this->actor, &this->unk_1E8, 2, 4); +s32 func_80A98124(EnKo* pthis, GlobalContext* globalCtx) { + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, 4); return 1; } -s32 func_80A98174(EnKo* this, GlobalContext* globalCtx) { - if (this->unk_1E8.unk_00 != 0) { - if (Animation_OnFrame(&this->skelAnime, 18.0f)) { - this->skelAnime.playSpeed = 0.0f; +s32 func_80A98174(EnKo* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E8.unk_00 != 0) { + if (Animation_OnFrame(&pthis->skelAnime, 18.0f)) { + pthis->skelAnime.playSpeed = 0.0f; } - } else if (this->skelAnime.playSpeed != 1.0f) { - this->skelAnime.playSpeed = 1.0f; + } else if (pthis->skelAnime.playSpeed != 1.0f) { + pthis->skelAnime.playSpeed = 1.0f; } - if (this->skelAnime.playSpeed == 0.0f) { - func_80034F54(globalCtx, this->unk_2E4, this->unk_304, 16); + if (pthis->skelAnime.playSpeed == 0.0f) { + func_80034F54(globalCtx, pthis->unk_2E4, pthis->unk_304, 16); } - func_80034A14(&this->actor, &this->unk_1E8, 2, (this->skelAnime.playSpeed == 0.0f) ? 2 : 1); - return EnKo_IsWithinTalkAngle(this); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, (pthis->skelAnime.playSpeed == 0.0f) ? 2 : 1); + return EnKo_IsWithinTalkAngle(pthis); } -s32 EnKo_ChildStart(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_ChildStart(EnKo* pthis, GlobalContext* globalCtx) { switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_0: - return func_80A97D68(this, globalCtx); + return func_80A97D68(pthis, globalCtx); case ENKO_TYPE_CHILD_1: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_2: - return func_80A98034(this, globalCtx); + return func_80A98034(pthis, globalCtx); case ENKO_TYPE_CHILD_3: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_4: - return func_80A97F70(this, globalCtx); + return func_80A97F70(pthis, globalCtx); case ENKO_TYPE_CHILD_5: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_6: - return func_80A97F20(this, globalCtx); + return func_80A97F20(pthis, globalCtx); case ENKO_TYPE_CHILD_7: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_8: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_9: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_10: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_11: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_FADO: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); } return 0; } -s32 EnKo_ChildStone(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_ChildStone(EnKo* pthis, GlobalContext* globalCtx) { switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_0: - return func_80A98124(this, globalCtx); + return func_80A98124(pthis, globalCtx); case ENKO_TYPE_CHILD_1: - return func_80A98124(this, globalCtx); + return func_80A98124(pthis, globalCtx); case ENKO_TYPE_CHILD_2: - return func_80A98034(this, globalCtx); + return func_80A98034(pthis, globalCtx); case ENKO_TYPE_CHILD_3: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_4: - return func_80A97F70(this, globalCtx); + return func_80A97F70(pthis, globalCtx); case ENKO_TYPE_CHILD_5: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_6: - return func_80A97F20(this, globalCtx); + return func_80A97F20(pthis, globalCtx); case ENKO_TYPE_CHILD_7: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_8: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_9: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_10: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_11: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_FADO: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); } return 0; } -s32 EnKo_ChildSaria(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_ChildSaria(EnKo* pthis, GlobalContext* globalCtx) { switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_0: - return func_80A98124(this, globalCtx); + return func_80A98124(pthis, globalCtx); case ENKO_TYPE_CHILD_1: - return func_80A98124(this, globalCtx); + return func_80A98124(pthis, globalCtx); case ENKO_TYPE_CHILD_2: - return func_80A98034(this, globalCtx); + return func_80A98034(pthis, globalCtx); case ENKO_TYPE_CHILD_3: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_4: - return func_80A98174(this, globalCtx); + return func_80A98174(pthis, globalCtx); case ENKO_TYPE_CHILD_5: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_6: - return func_80A97F20(this, globalCtx); + return func_80A97F20(pthis, globalCtx); case ENKO_TYPE_CHILD_7: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_8: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_9: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_10: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_11: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_FADO: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); } return 0; } -s32 EnKo_AdultEnemy(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_AdultEnemy(EnKo* pthis, GlobalContext* globalCtx) { switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_0: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_1: - return func_80A98124(this, globalCtx); + return func_80A98124(pthis, globalCtx); case ENKO_TYPE_CHILD_2: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_3: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_4: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_5: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_6: - return func_80A97F20(this, globalCtx); + return func_80A97F20(pthis, globalCtx); case ENKO_TYPE_CHILD_7: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_8: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_9: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_10: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_11: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_FADO: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); } return 0; } -s32 EnKo_AdultSaved(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_AdultSaved(EnKo* pthis, GlobalContext* globalCtx) { switch (ENKO_TYPE) { case ENKO_TYPE_CHILD_0: - return func_80A98034(this, globalCtx); + return func_80A98034(pthis, globalCtx); case ENKO_TYPE_CHILD_1: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_2: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_3: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_4: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_5: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_6: - return func_80A97F20(this, globalCtx); + return func_80A97F20(pthis, globalCtx); case ENKO_TYPE_CHILD_7: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_8: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_9: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_10: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); case ENKO_TYPE_CHILD_11: - return func_80A97EB0(this, globalCtx); + return func_80A97EB0(pthis, globalCtx); case ENKO_TYPE_CHILD_FADO: - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); } return 0; } -void func_80A9877C(EnKo* this, GlobalContext* globalCtx) { +void func_80A9877C(EnKo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((globalCtx->csCtx.state != 0) || (gDbgCamEnabled != 0)) { - this->unk_1E8.unk_18 = globalCtx->view.eye; - this->unk_1E8.unk_14 = 40.0f; + pthis->unk_1E8.unk_18 = globalCtx->view.eye; + pthis->unk_1E8.unk_14 = 40.0f; if (ENKO_TYPE != ENKO_TYPE_CHILD_0) { - func_80034A14(&this->actor, &this->unk_1E8, 2, 2); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 2, 2); } } else { - this->unk_1E8.unk_18 = player->actor.world.pos; - this->unk_1E8.unk_14 = func_80A97BC0(this); - if ((func_80A98ECC(this, globalCtx) == 0) && (this->unk_1E8.unk_00 == 0)) { + pthis->unk_1E8.unk_18 = player->actor.world.pos; + pthis->unk_1E8.unk_14 = func_80A97BC0(pthis); + if ((func_80A98ECC(pthis, globalCtx) == 0) && (pthis->unk_1E8.unk_00 == 0)) { return; } } - if (func_800343CC(globalCtx, &this->actor, &this->unk_1E8.unk_00, this->lookDist, func_80A97610, func_80A97738) && + if (func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E8.unk_00, pthis->lookDist, func_80A97610, func_80A97738) && ENKO_TYPE == ENKO_TYPE_CHILD_FADO && globalCtx->sceneNum == SCENE_SPOT10) { - this->actor.textId = INV_CONTENT(ITEM_TRADE_ADULT) > ITEM_ODD_POTION ? 0x10B9 : 0x10DF; + pthis->actor.textId = INV_CONTENT(ITEM_TRADE_ADULT) > ITEM_ODD_POTION ? 0x10B9 : 0x10DF; if (func_8002F368(globalCtx) == ENKO_TYPE_CHILD_9) { - this->actor.textId = (gSaveContext.infTable[11] & 0x1000) ? 0x10B8 : 0x10B7; - this->unk_210 = 0; + pthis->actor.textId = (gSaveContext.infTable[11] & 0x1000) ? 0x10B8 : 0x10B7; + pthis->unk_210 = 0; } - player->actor.textId = this->actor.textId; + player->actor.textId = pthis->actor.textId; } } // Checks if the Kokiri should spawn based on quest progress -s32 EnKo_CanSpawn(EnKo* this, GlobalContext* globalCtx) { +s32 EnKo_CanSpawn(EnKo* pthis, GlobalContext* globalCtx) { switch (globalCtx->sceneNum) { case SCENE_SPOT04: if (ENKO_TYPE >= ENKO_TYPE_CHILD_7 && ENKO_TYPE != ENKO_TYPE_CHILD_FADO) { @@ -1014,33 +1014,33 @@ s32 EnKo_CanSpawn(EnKo* this, GlobalContext* globalCtx) { } } -void EnKo_Blink(EnKo* this) { +void EnKo_Blink(EnKo* pthis) { void** eyeTextures; s32 headId; - if (DECR(this->blinkTimer) == 0) { + if (DECR(pthis->blinkTimer) == 0) { headId = sModelInfo[ENKO_TYPE].headId; - this->eyeTextureIndex++; + pthis->eyeTextureIndex++; eyeTextures = sHead[headId].eyeTextures; - if (eyeTextures != NULL && eyeTextures[this->eyeTextureIndex] == NULL) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeTextureIndex = 0; + if (eyeTextures != NULL && eyeTextures[pthis->eyeTextureIndex] == NULL) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeTextureIndex = 0; } } } -void func_80A98CD8(EnKo* this) { +void func_80A98CD8(EnKo* pthis) { s32 type = ENKO_TYPE; EnKoInteractInfo* info = &sInteractInfo[type]; - this->actor.targetMode = info->targetMode; - this->lookDist = info->lookDist; - this->lookDist += this->collider.dim.radius; - this->appearDist = info->appearDist; + pthis->actor.targetMode = info->targetMode; + pthis->lookDist = info->lookDist; + pthis->lookDist += pthis->collider.dim.radius; + pthis->appearDist = info->appearDist; } // Used to fetch actor animation? -s32 EnKo_GetForestQuestState2(EnKo* this) { +s32 EnKo_GetForestQuestState2(EnKo* pthis) { if (LINK_IS_ADULT) { return CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST) ? ENKO_FQS_ADULT_SAVED : ENKO_FQS_ADULT_ENEMY; } @@ -1050,265 +1050,265 @@ s32 EnKo_GetForestQuestState2(EnKo* this) { return ENKO_FQS_CHILD_START; } -void func_80A98DB4(EnKo* this, GlobalContext* globalCtx) { +void func_80A98DB4(EnKo* pthis, GlobalContext* globalCtx) { f32 dist; if (globalCtx->sceneNum != SCENE_SPOT10 && globalCtx->sceneNum != SCENE_SPOT04) { - this->modelAlpha = 255.0f; + pthis->modelAlpha = 255.0f; return; } if (globalCtx->csCtx.state != 0 || gDbgCamEnabled != 0) { - dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &globalCtx->view.eye) * 0.25f; + dist = Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &globalCtx->view.eye) * 0.25f; } else { - dist = this->actor.xzDistToPlayer; + dist = pthis->actor.xzDistToPlayer; } - Math_SmoothStepToF(&this->modelAlpha, (this->appearDist < dist) ? 0.0f : 255.0f, 0.3f, 40.0f, 1.0f); - if (this->modelAlpha < 10.0f) { - this->actor.flags &= ~ACTOR_FLAG_0; + Math_SmoothStepToF(&pthis->modelAlpha, (pthis->appearDist < dist) ? 0.0f : 255.0f, 0.3f, 40.0f, 1.0f); + if (pthis->modelAlpha < 10.0f) { + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { - this->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags |= ACTOR_FLAG_0; } } -s32 func_80A98ECC(EnKo* this, GlobalContext* globalCtx) { +s32 func_80A98ECC(EnKo* pthis, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_SPOT10 && ENKO_TYPE == ENKO_TYPE_CHILD_FADO) { - return func_80A97E18(this, globalCtx); + return func_80A97E18(pthis, globalCtx); } - switch (EnKo_GetForestQuestState(this)) { + switch (EnKo_GetForestQuestState(pthis)) { case ENKO_FQS_CHILD_START: - return EnKo_ChildStart(this, globalCtx); + return EnKo_ChildStart(pthis, globalCtx); case ENKO_FQS_CHILD_STONE: - return EnKo_ChildStone(this, globalCtx); + return EnKo_ChildStone(pthis, globalCtx); case ENKO_FQS_CHILD_SARIA: - return EnKo_ChildSaria(this, globalCtx); + return EnKo_ChildSaria(pthis, globalCtx); case ENKO_FQS_ADULT_ENEMY: - return EnKo_AdultEnemy(this, globalCtx); + return EnKo_AdultEnemy(pthis, globalCtx); case ENKO_FQS_ADULT_SAVED: - return EnKo_AdultSaved(this, globalCtx); + return EnKo_AdultSaved(pthis, globalCtx); } return 0; } void EnKo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; - if (ENKO_TYPE >= ENKO_TYPE_CHILD_MAX /*|| !EnKo_IsOsAnimeAvailable(this, globalCtx) || - !EnKo_AreObjectsAvailable(this, globalCtx)*/) { + if (ENKO_TYPE >= ENKO_TYPE_CHILD_MAX /*|| !EnKo_IsOsAnimeAvailable(pthis, globalCtx) || + !EnKo_AreObjectsAvailable(pthis, globalCtx)*/) { Actor_Kill(thisx); } - if (!EnKo_CanSpawn(this, globalCtx)) { + if (!EnKo_CanSpawn(pthis, globalCtx)) { Actor_Kill(thisx); } - this->actionFunc = func_80A99048; + pthis->actionFunc = func_80A99048; } void EnKo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnKo* this = (EnKo*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + EnKo* pthis = (EnKo*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_80A99048(EnKo* this, GlobalContext* globalCtx) { - if (EnKo_IsOsAnimeLoaded(this, globalCtx) && EnKo_AreObjectsLoaded(this, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->legsObjectBankIdx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->actor.objBankIndex].vromStart); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, sSkeleton[sModelInfo[ENKO_TYPE].legsId].flexSkeletonHeader, - NULL, this->jointTable, this->morphTable, 16); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->osAnimeBankIndex].vromStart); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); +void func_80A99048(EnKo* pthis, GlobalContext* globalCtx) { + if (EnKo_IsOsAnimeLoaded(pthis, globalCtx) && EnKo_AreObjectsLoaded(pthis, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.objBankIndex = pthis->legsObjectBankIdx; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->actor.objBankIndex].vromStart.get()); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, sSkeleton[sModelInfo[ENKO_TYPE].legsId].flexSkeletonHeader, + NULL, pthis->jointTable, pthis->morphTable, 16); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->osAnimeBankIndex].vromStart.get()); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); if (ENKO_TYPE == ENKO_TYPE_CHILD_7) { // "Angle Z" - osSyncPrintf(VT_BGCOL(BLUE) " アングルZ->(%d)\n" VT_RST, this->actor.shape.rot.z); + osSyncPrintf(VT_BGCOL(BLUE) " アングルZ->(%d)\n" VT_RST, pthis->actor.shape.rot.z); if (LINK_IS_ADULT && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST)) { - if (this->actor.shape.rot.z != 1) { - Actor_Kill(&this->actor); + if (pthis->actor.shape.rot.z != 1) { + Actor_Kill(&pthis->actor); return; } - } else if (this->actor.shape.rot.z != 0) { - Actor_Kill(&this->actor); + } else if (pthis->actor.shape.rot.z != 0) { + Actor_Kill(&pthis->actor); return; } } if (ENKO_TYPE == ENKO_TYPE_CHILD_5) { - this->collider.base.ocFlags1 |= 0x40; + pthis->collider.base.ocFlags1 |= 0x40; } - this->forestQuestState = EnKo_GetForestQuestState2(this); - func_80034EC0(&this->skelAnime, sOsAnimeTable, sOsAnimeLookup[ENKO_TYPE][this->forestQuestState]); - Actor_SetScale(&this->actor, 0.01f); - func_80A98CD8(this); - this->modelAlpha = 0.0f; - this->path = Path_GetByIndex(globalCtx, ENKO_PATH, 0xFF); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 3); + pthis->forestQuestState = EnKo_GetForestQuestState2(pthis); + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, sOsAnimeLookup[ENKO_TYPE][pthis->forestQuestState]); + Actor_SetScale(&pthis->actor, 0.01f); + func_80A98CD8(pthis); + pthis->modelAlpha = 0.0f; + pthis->path = Path_GetByIndex(globalCtx, ENKO_PATH, 0xFF); + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 3); if (ENKO_TYPE == ENKO_TYPE_CHILD_3) { if (!CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { - this->collider.dim.height += 200; - this->actionFunc = func_80A995CC; + pthis->collider.dim.height += 200; + pthis->actionFunc = func_80A995CC; return; } - Path_CopyLastPoint(this->path, &this->actor.world.pos); + Path_CopyLastPoint(pthis->path, &pthis->actor.world.pos); } - this->actionFunc = func_80A99384; + pthis->actionFunc = func_80A99384; } } -void func_80A99384(EnKo* this, GlobalContext* globalCtx) { - if (ENKO_TYPE == ENKO_TYPE_CHILD_FADO && this->unk_1E8.unk_00 != 0 && this->actor.textId == 0x10B9) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 7); - this->actionFunc = func_80A99438; - } else if (ENKO_TYPE == ENKO_TYPE_CHILD_FADO && this->unk_1E8.unk_00 == 2) { - this->actionFunc = func_80A99504; +void func_80A99384(EnKo* pthis, GlobalContext* globalCtx) { + if (ENKO_TYPE == ENKO_TYPE_CHILD_FADO && pthis->unk_1E8.unk_00 != 0 && pthis->actor.textId == 0x10B9) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 7); + pthis->actionFunc = func_80A99438; + } else if (ENKO_TYPE == ENKO_TYPE_CHILD_FADO && pthis->unk_1E8.unk_00 == 2) { + pthis->actionFunc = func_80A99504; globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } } -void func_80A99438(EnKo* this, GlobalContext* globalCtx) { - if (ENKO_TYPE == ENKO_TYPE_CHILD_FADO && this->unk_1E8.unk_00 == 2) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 6); - this->actionFunc = func_80A99504; +void func_80A99438(EnKo* pthis, GlobalContext* globalCtx) { + if (ENKO_TYPE == ENKO_TYPE_CHILD_FADO && pthis->unk_1E8.unk_00 == 2) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 6); + pthis->actionFunc = func_80A99504; globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - } else if (this->unk_1E8.unk_00 == 0 || this->actor.textId != 0x10B9) { - func_80034EC0(&this->skelAnime, sOsAnimeTable, 6); - this->actionFunc = func_80A99384; + } else if (pthis->unk_1E8.unk_00 == 0 || pthis->actor.textId != 0x10B9) { + func_80034EC0(&pthis->skelAnime, sOsAnimeTable, 6); + pthis->actionFunc = func_80A99384; } } -void func_80A99504(EnKo* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_80A99560; +void func_80A99504(EnKo* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_80A99560; } else { - func_8002F434(&this->actor, globalCtx, GI_SAW, 120.0f, 10.0f); + func_8002F434(&pthis->actor, globalCtx, GI_SAW, 120.0f, 10.0f); } } -void func_80A99560(EnKo* this, GlobalContext* globalCtx) { - if (this->unk_1E8.unk_00 == 3) { - this->actor.textId = 0x10B9; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E8.unk_00 = 1; +void func_80A99560(EnKo* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E8.unk_00 == 3) { + pthis->actor.textId = 0x10B9; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E8.unk_00 = 1; gSaveContext.itemGetInf[3] |= 2; - this->actionFunc = func_80A99384; + pthis->actionFunc = func_80A99384; } } -void func_80A995CC(EnKo* this, GlobalContext* globalCtx) { +void func_80A995CC(EnKo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 temp_f2; f32 phi_f0; - s16 homeYawToPlayer = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); + s16 homeYawToPlayer = Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos); - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.x += 80.0f * Math_SinS(homeYawToPlayer); - this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.z += 80.0f * Math_CosS(homeYawToPlayer); - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.x += 80.0f * Math_SinS(homeYawToPlayer); + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + pthis->actor.world.pos.z += 80.0f * Math_CosS(homeYawToPlayer); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; - if (this->unk_1E8.unk_00 == 0 || !this->actor.isTargeted) { - temp_f2 = fabsf((f32)this->actor.yawTowardsPlayer - homeYawToPlayer) * 0.001f * 3.0f; + if (pthis->unk_1E8.unk_00 == 0 || !pthis->actor.isTargeted) { + temp_f2 = fabsf((f32)pthis->actor.yawTowardsPlayer - homeYawToPlayer) * 0.001f * 3.0f; if (temp_f2 < 1.0f) { - this->skelAnime.playSpeed = 1.0f; + pthis->skelAnime.playSpeed = 1.0f; } else { phi_f0 = CLAMP_MAX(temp_f2, 3.0f); - this->skelAnime.playSpeed = phi_f0; + pthis->skelAnime.playSpeed = phi_f0; } } else { - this->skelAnime.playSpeed = 1.0f; + pthis->skelAnime.playSpeed = 1.0f; } } void EnKo_Update(Actor* thisx, GlobalContext* globalCtx) { ColliderCylinder* collider; - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; s32 pad; - if (this->actionFunc != func_80A99048) { - if ((s32)this->modelAlpha != 0) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->osAnimeBankIndex].vromStart); - SkelAnime_Update(&this->skelAnime); - func_80A98DB4(this, globalCtx); - EnKo_Blink(this); + if (pthis->actionFunc != func_80A99048) { + if ((s32)pthis->modelAlpha != 0) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->osAnimeBankIndex].vromStart.get()); + SkelAnime_Update(&pthis->skelAnime); + func_80A98DB4(pthis, globalCtx); + EnKo_Blink(pthis); } else { - func_80A98DB4(this, globalCtx); + func_80A98DB4(pthis, globalCtx); } } - if (this->unk_1E8.unk_00 == 0) { - Actor_MoveForward(&this->actor); + if (pthis->unk_1E8.unk_00 == 0) { + Actor_MoveForward(&pthis->actor); } - if (func_80A97C7C(this)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actor.gravity = -1.0f; + if (func_80A97C7C(pthis)) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actor.gravity = -1.0f; } else { - this->actor.gravity = 0.0f; + pthis->actor.gravity = 0.0f; } - this->actionFunc(this, globalCtx); - func_80A9877C(this, globalCtx); - collider = &this->collider; - Collider_UpdateCylinder(&this->actor, collider); + pthis->actionFunc(pthis, globalCtx); + func_80A9877C(pthis, globalCtx); + collider = &pthis->collider; + Collider_UpdateCylinder(&pthis->actor, collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); } s32 EnKo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx) { - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; void* eyeTexture; Vec3s sp40; u8 headId; s32 pad; if (limbIndex == 15) { - gSPSegment((*gfx)++, 0x06, gObjectTable[this->headObjectBankIdx].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->headObjectBankIdx].vromStart); + gSPSegment((*gfx)++, 0x06, gObjectTable[pthis->headObjectBankIdx].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->headObjectBankIdx].vromStart.get()); headId = sModelInfo[ENKO_TYPE].headId; *dList = sHead[headId].dList; if (sHead[headId].eyeTextures != NULL) { - eyeTexture = sHead[headId].eyeTextures[this->eyeTextureIndex]; + eyeTexture = sHead[headId].eyeTextures[pthis->eyeTextureIndex]; gSPSegment((*gfx)++, 0x0A, SEGMENTED_TO_VIRTUAL(eyeTexture)); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->legsObjectBankIdx].vromStart); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->legsObjectBankIdx].vromStart.get()); } if (limbIndex == 8) { - sp40 = this->unk_1E8.unk_0E; + sp40 = pthis->unk_1E8.unk_0E; Matrix_RotateX(BINANG_TO_RAD(-sp40.y), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD(sp40.x), MTXMODE_APPLY); } if (limbIndex == 15) { Matrix_Translate(1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); - sp40 = this->unk_1E8.unk_08; + sp40 = pthis->unk_1E8.unk_08; Matrix_RotateX(BINANG_TO_RAD(sp40.y), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD(sp40.x), MTXMODE_APPLY); Matrix_Translate(-1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 12) { - rot->y += Math_SinS(this->unk_2E4[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->unk_304[limbIndex]) * 200.0f; + rot->y += Math_SinS(pthis->unk_2E4[limbIndex]) * 200.0f; + rot->z += Math_CosS(pthis->unk_304[limbIndex]) * 200.0f; } return false; } void EnKo_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { GlobalContext* globalCtx = globalCtx2; - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; Vec3f D_80A9A774 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 7) { - gSPSegment((*gfx)++, 0x06, gObjectTable[this->bodyObjectBankIdx].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->bodyObjectBankIdx].vromStart); + gSPSegment((*gfx)++, 0x06, gObjectTable[pthis->bodyObjectBankIdx].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->bodyObjectBankIdx].vromStart.get()); } if (limbIndex == 15) { - Matrix_MultVec3f(&D_80A9A774, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A9A774, &pthis->actor.focus.pos); } } Gfx* EnKo_SetEnvColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { - Gfx* dList = Graph_Alloc(gfxCtx, sizeof(Gfx) * 2); + Gfx* dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 2); gDPSetEnvColor(dList, r, g, b, a); gSPEndDisplayList(dList + 1); @@ -1316,29 +1316,29 @@ Gfx* EnKo_SetEnvColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { } void EnKo_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnKo* this = (EnKo*)thisx; + EnKo* pthis = (EnKo*)thisx; Color_RGBA8 tunicColor = sModelInfo[ENKO_TYPE].tunicColor; Color_RGBA8 bootsColor = sModelInfo[ENKO_TYPE].bootsColor; - this->actor.shape.shadowAlpha = this->modelAlpha; + pthis->actor.shape.shadowAlpha = pthis->modelAlpha; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ko.c", 2095); - if ((s16)this->modelAlpha == 255) { + if ((s16)pthis->modelAlpha == 255) { gSPSegment(POLY_OPA_DISP++, 0x08, EnKo_SetEnvColor(globalCtx->state.gfxCtx, tunicColor.r, tunicColor.g, tunicColor.b, 255)); gSPSegment(POLY_OPA_DISP++, 0x09, EnKo_SetEnvColor(globalCtx->state.gfxCtx, bootsColor.r, bootsColor.g, bootsColor.b, 255)); - func_80034BA0(globalCtx, &this->skelAnime, EnKo_OverrideLimbDraw, EnKo_PostLimbDraw, &this->actor, - this->modelAlpha); - } else if ((s16)this->modelAlpha != 0) { - tunicColor.a = this->modelAlpha; - bootsColor.a = this->modelAlpha; + func_80034BA0(globalCtx, &pthis->skelAnime, EnKo_OverrideLimbDraw, EnKo_PostLimbDraw, &pthis->actor, + pthis->modelAlpha); + } else if ((s16)pthis->modelAlpha != 0) { + tunicColor.a = pthis->modelAlpha; + bootsColor.a = pthis->modelAlpha; gSPSegment(POLY_XLU_DISP++, 0x08, EnKo_SetEnvColor(globalCtx->state.gfxCtx, tunicColor.r, tunicColor.g, tunicColor.b, tunicColor.a)); gSPSegment(POLY_XLU_DISP++, 0x09, EnKo_SetEnvColor(globalCtx->state.gfxCtx, bootsColor.r, bootsColor.g, bootsColor.b, bootsColor.a)); - func_80034CC4(globalCtx, &this->skelAnime, EnKo_OverrideLimbDraw, EnKo_PostLimbDraw, &this->actor, - this->modelAlpha); + func_80034CC4(globalCtx, &pthis->skelAnime, EnKo_OverrideLimbDraw, EnKo_PostLimbDraw, &pthis->actor, + pthis->modelAlpha); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ko.c", 2136); } diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c deleted file mode 100644 index 8d70ca3f4..000000000 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ /dev/null @@ -1,515 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KUSA_Z_EN_KUSA_C -#include "actor_common.h" -/* - * File: z_en_kusa.c - * Overlay: ovl_en_kusa - * Description: Bush - */ - -#include "z_en_kusa.h" -#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#include "objects/object_kusa/object_kusa.h" -#include "vt.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_scene.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) - -void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKusa_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnKusa_SetupLiftedUp(EnKusa* this); -void EnKusa_SetupWaitObject(EnKusa* this); -void EnKusa_SetupMain(EnKusa* this); -void EnKusa_SetupFall(EnKusa* this); -void EnKusa_SetupCut(EnKusa* this); -void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); -void EnKusa_SetupRegrow(EnKusa* this); - -void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_Main(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx); - -static s16 rotSpeedXtarget = 0; -static s16 rotSpeedX = 0; -static s16 rotSpeedYtarget = 0; -static s16 rotSpeedY = 0; - -const ActorInit En_Kusa_InitVars = { - ACTOR_EN_KUSA, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnKusa), - (ActorFunc)EnKusa_Init, - (ActorFunc)EnKusa_Destroy, - (ActorFunc)EnKusa_Update, - NULL, -}; - -static s16 sObjectIds[] = { OBJECT_GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA }; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x4FC00758, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 12, 44, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; - -static Vec3f sUnitDirections[] = { - { 0.0f, 0.7071f, 0.7071f }, - { 0.7071f, 0.7071f, 0.0f }, - { 0.0f, 0.7071f, -0.7071f }, - { -0.7071f, 0.7071f, 0.0f }, -}; - -static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 120, ICHAIN_STOP), -}; - -void EnKusa_SetupAction(EnKusa* this, EnKusaActionFunc actionFunc) { - this->timer = 0; - this->actionFunc = actionFunc; -} - -s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { - s32 pad; - CollisionPoly* poly; - Vec3f pos; - s32 bgId; - f32 floorY; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 30.0f; - pos.z = this->actor.world.pos.z; - - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); - - if (floorY > BGCHECK_Y_MIN) { - this->actor.world.pos.y = floorY + yOffset; - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - return true; - } else { - osSyncPrintf(VT_COL(YELLOW, BLACK)); - // "Failure attaching to ground" - osSyncPrintf("地面に付着失敗(%s %d)\n", "../z_en_kusa.c", 323); - osSyncPrintf(VT_RST); - return false; - } -} - -void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx) { - s16 dropParams; - - switch (this->actor.params & 3) { - case ENKUSA_TYPE_0: - case ENKUSA_TYPE_2: - dropParams = (this->actor.params >> 8) & 0xF; - - if (dropParams >= 0xD) { - dropParams = 0; - } - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, dropParams << 4); - break; - case ENKUSA_TYPE_1: - if (Rand_ZeroOne() < 0.5f) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_SEEDS); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_HEART); - } - break; - } -} - -void EnKusa_UpdateVelY(EnKusa* this) { - this->actor.velocity.y += this->actor.gravity; - - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } -} - -void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scale) { - scale += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scale; - vec->x -= vec->x * scale; - vec->y -= vec->y * scale; - vec->z -= vec->z * scale; -} - -void EnKusa_SetScaleSmall(EnKusa* this) { - this->actor.scale.y = 0.16000001f; - this->actor.scale.x = 0.120000005f; - this->actor.scale.z = 0.120000005f; -} - -void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { - Vec3f velocity; - Vec3f pos; - s32 i; - s32 scaleIndex; - Vec3f* dir; - s32 pad; - - for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { - dir = &sUnitDirections[i]; - - pos.x = this->actor.world.pos.x + (dir->x * this->actor.scale.x * 20.0f); - pos.y = this->actor.world.pos.y + (dir->y * this->actor.scale.y * 20.0f) + 10.0f; - pos.z = this->actor.world.pos.z + (dir->z * this->actor.scale.z * 20.0f); - - velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; - velocity.y = Rand_ZeroOne() * 10.0f; - velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; - - scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; - - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, - 80, KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_KEEP, gCuttableShrubStalkDL); - - pos.x = this->actor.world.pos.x + (dir->x * this->actor.scale.x * 40.0f); - pos.y = this->actor.world.pos.y + (dir->y * this->actor.scale.y * 40.0f) + 10.0f; - pos.z = this->actor.world.pos.z + (dir->z * this->actor.scale.z * 40.0f); - - velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; - velocity.y = Rand_ZeroOne() * 10.0f; - velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; - - scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; - - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, - 80, KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_KEEP, gCuttableShrubTipDL); - } -} - -void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < 3; i++) { - Actor* bug = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, Rand_ZeroOne() * 0xFFFF, 0, 1); - - if (bug == NULL) { - break; - } - } -} - -void EnKusa_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - EnKusa* this = (EnKusa*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); -} - -void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKusa* this = (EnKusa*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - this->actor.uncullZoneForward += 1000.0f; - } - - EnKusa_InitCollider(thisx, globalCtx); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - - if (this->actor.shape.rot.y == 0) { - s16 rand = Rand_ZeroFloat(0x10000); - - this->actor.world.rot.y = rand; - this->actor.home.rot.y = rand; - this->actor.shape.rot.y = rand; - } - - if (!EnKusa_SnapToFloor(this, globalCtx, 0.0f)) { - Actor_Kill(&this->actor); - return; - } - - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[thisx->params & 3]); - - if (this->objBankIndex < 0) { - // "Bank danger!" - osSyncPrintf("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", thisx->params, "../z_en_kusa.c", 561); - Actor_Kill(&this->actor); - return; - } - - EnKusa_SetupWaitObject(this); -} - -void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnKusa* this = (EnKusa*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnKusa_SetupWaitObject(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_WaitObject); -} - -void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - if (this->actor.flags & ACTOR_FLAG_11) { - EnKusa_SetupCut(this); - } else { - EnKusa_SetupMain(this); - } - - this->actor.draw = EnKusa_Draw; - this->actor.objBankIndex = this->objBankIndex; - this->actor.flags &= ~ACTOR_FLAG_4; - } -} - -void EnKusa_SetupMain(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_Main); - this->actor.flags &= ~ACTOR_FLAG_4; -} - -void EnKusa_Main(EnKusa* this, GlobalContext* globalCtx) { - s32 pad; - - if (Actor_HasParent(&this->actor, globalCtx)) { - EnKusa_SetupLiftedUp(this); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); - } else if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - EnKusa_SpawnFragments(this, globalCtx); - EnKusa_DropCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); - - if ((this->actor.params >> 4) & 1) { - EnKusa_SpawnBugs(this, globalCtx); - } - - if ((this->actor.params & 3) == ENKUSA_TYPE_0) { - Actor_Kill(&this->actor); - return; - } - - EnKusa_SetupCut(this); - this->actor.flags |= ACTOR_FLAG_11; - } else { - if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { - this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; - } - - if (this->actor.xzDistToPlayer < 600.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->actor.xzDistToPlayer < 400.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F580(&this->actor, globalCtx); - } - } - } - } -} - -void EnKusa_SetupLiftedUp(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_LiftedUp); - this->actor.room = -1; - this->actor.flags |= ACTOR_FLAG_4; -} - -void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.curRoom.num; - EnKusa_SetupFall(this); - this->actor.velocity.x = this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); - this->actor.velocity.z = this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); - this->actor.colChkInfo.mass = 240; - this->actor.gravity = -0.1f; - EnKusa_UpdateVelY(this); - EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.005f); - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); - this->actor.gravity = -3.2f; - } -} - -void EnKusa_SetupFall(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_Fall); - rotSpeedXtarget = -0xBB8; - rotSpeedYtarget = (Rand_ZeroOne() - 0.5f) * 1600.0f; - rotSpeedX = 0; - rotSpeedY = 0; -} - -void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f contactPos; - - if (this->actor.bgCheckFlags & 0xB) { - if (!(this->actor.bgCheckFlags & 0x20)) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); - } - EnKusa_SpawnFragments(this, globalCtx); - EnKusa_DropCollectible(this, globalCtx); - switch (this->actor.params & 3) { - case ENKUSA_TYPE_0: - case ENKUSA_TYPE_2: - Actor_Kill(&this->actor); - break; - - case ENKUSA_TYPE_1: - EnKusa_SetupUprootedWaitRegrow(this); - break; - } - return; - } - - if (this->actor.bgCheckFlags & 0x40) { - contactPos.x = this->actor.world.pos.x; - contactPos.y = this->actor.world.pos.y + this->actor.yDistToWater; - contactPos.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 400); - EffectSsGRipple_Spawn(globalCtx, &contactPos, 150, 650, 0); - EffectSsGRipple_Spawn(globalCtx, &contactPos, 400, 800, 4); - EffectSsGRipple_Spawn(globalCtx, &contactPos, 500, 1100, 8); - this->actor.minVelocityY = -3.0f; - rotSpeedX >>= 1; - rotSpeedXtarget >>= 1; - rotSpeedY >>= 1; - rotSpeedYtarget >>= 1; - this->actor.bgCheckFlags &= ~0x40; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); - } - - EnKusa_UpdateVelY(this); - Math_StepToS(&rotSpeedX, rotSpeedXtarget, 0x1F4); - Math_StepToS(&rotSpeedY, rotSpeedYtarget, 0xAA); - this->actor.shape.rot.x += rotSpeedX; - this->actor.shape.rot.y += rotSpeedY; - EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.05f); - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnKusa_SetupCut(EnKusa* this) { - switch (this->actor.params & 3) { - case ENKUSA_TYPE_2: - EnKusa_SetupAction(this, EnKusa_DoNothing); - break; - case ENKUSA_TYPE_1: - EnKusa_SetupAction(this, EnKusa_CutWaitRegrow); - break; - } -} - -void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { - if (this->timer >= 120) { - EnKusa_SetupRegrow(this); - } -} - -void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx) { -} - -void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.y = this->actor.home.pos.y - 9.0f; - this->actor.world.pos.z = this->actor.home.pos.z; - EnKusa_SetScaleSmall(this); - this->actor.shape.rot = this->actor.home.rot; - EnKusa_SetupAction(this, EnKusa_UprootedWaitRegrow); -} - -void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { - if (this->timer > 120) { - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f)) { - if (this->timer >= 170) { - EnKusa_SetupRegrow(this); - } - } - } -} - -void EnKusa_SetupRegrow(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_Regrow); - EnKusa_SetScaleSmall(this); - this->actor.shape.rot = this->actor.home.rot; - this->actor.flags &= ~ACTOR_FLAG_11; -} - -void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { - s32 isFullyGrown = true; - - isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); - isFullyGrown &= Math_StepToF(&this->actor.scale.x, 0.4f, 0.011f); - this->actor.scale.z = this->actor.scale.x; - - if (isFullyGrown) { - Actor_SetScale(&this->actor, 0.4f); - EnKusa_SetupMain(this); - this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - } -} - -void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx) { - EnKusa* this = (EnKusa*)thisx; - - this->timer++; - - this->actionFunc(this, globalCtx); - - if (this->actor.flags & ACTOR_FLAG_11) { - this->actor.shape.yOffset = -6.25f; - } else { - this->actor.shape.yOffset = 0.0f; - } -} - -void EnKusa_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Gfx* dLists[] = { gFieldBushDL, object_kusa_DL_000140, object_kusa_DL_000140 }; - EnKusa* this = (EnKusa*)thisx; - - if (this->actor.flags & ACTOR_FLAG_11) { - Gfx_DrawDListOpa(globalCtx, object_kusa_DL_0002E0); - } else { - Gfx_DrawDListOpa(globalCtx, dLists[thisx->params & 3]); - } -} diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.cpp b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.cpp new file mode 100644 index 000000000..0ae5f41ca --- /dev/null +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.cpp @@ -0,0 +1,515 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KUSA_Z_EN_KUSA_C +#include "actor_common.h" +/* + * File: z_en_kusa.c + * Overlay: ovl_en_kusa + * Description: Bush + */ + +#include "z_en_kusa.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/object_kusa/object_kusa.h" +#include "vt.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_scene.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) + +void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKusa_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnKusa_SetupLiftedUp(EnKusa* pthis); +void EnKusa_SetupWaitObject(EnKusa* pthis); +void EnKusa_SetupMain(EnKusa* pthis); +void EnKusa_SetupFall(EnKusa* pthis); +void EnKusa_SetupCut(EnKusa* pthis); +void EnKusa_SetupUprootedWaitRegrow(EnKusa* pthis); +void EnKusa_SetupRegrow(EnKusa* pthis); + +void EnKusa_Fall(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_WaitObject(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_Main(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_LiftedUp(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_CutWaitRegrow(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_DoNothing(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_UprootedWaitRegrow(EnKusa* pthis, GlobalContext* globalCtx); +void EnKusa_Regrow(EnKusa* pthis, GlobalContext* globalCtx); + +static s16 rotSpeedXtarget = 0; +static s16 rotSpeedX = 0; +static s16 rotSpeedYtarget = 0; +static s16 rotSpeedY = 0; + +ActorInit En_Kusa_InitVars = { + ACTOR_EN_KUSA, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnKusa), + (ActorFunc)EnKusa_Init, + (ActorFunc)EnKusa_Destroy, + (ActorFunc)EnKusa_Update, + NULL, +}; + +static s16 sObjectIds[] = { OBJECT_GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x4FC00758, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 12, 44, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; + +static Vec3f sUnitDirections[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 120, ICHAIN_STOP), +}; + +void EnKusa_SetupAction(EnKusa* pthis, EnKusaActionFunc actionFunc) { + pthis->timer = 0; + pthis->actionFunc = actionFunc; +} + +s32 EnKusa_SnapToFloor(EnKusa* pthis, GlobalContext* globalCtx, f32 yOffset) { + s32 pad; + CollisionPoly* poly; + Vec3f pos; + s32 bgId; + f32 floorY; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 30.0f; + pos.z = pthis->actor.world.pos.z; + + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &poly, &bgId, &pthis->actor, &pos); + + if (floorY > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = floorY + yOffset; + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); + return true; + } else { + osSyncPrintf(VT_COL(YELLOW, BLACK)); + // "Failure attaching to ground" + osSyncPrintf("地面に付着失敗(%s %d)\n", "../z_en_kusa.c", 323); + osSyncPrintf(VT_RST); + return false; + } +} + +void EnKusa_DropCollectible(EnKusa* pthis, GlobalContext* globalCtx) { + s16 dropParams; + + switch (pthis->actor.params & 3) { + case ENKUSA_TYPE_0: + case ENKUSA_TYPE_2: + dropParams = (pthis->actor.params >> 8) & 0xF; + + if (dropParams >= 0xD) { + dropParams = 0; + } + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, dropParams << 4); + break; + case ENKUSA_TYPE_1: + if (Rand_ZeroOne() < 0.5f) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_SEEDS); + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_HEART); + } + break; + } +} + +void EnKusa_UpdateVelY(EnKusa* pthis) { + pthis->actor.velocity.y += pthis->actor.gravity; + + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } +} + +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scale) { + scale += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scale; + vec->x -= vec->x * scale; + vec->y -= vec->y * scale; + vec->z -= vec->z * scale; +} + +void EnKusa_SetScaleSmall(EnKusa* pthis) { + pthis->actor.scale.y = 0.16000001f; + pthis->actor.scale.x = 0.120000005f; + pthis->actor.scale.z = 0.120000005f; +} + +void EnKusa_SpawnFragments(EnKusa* pthis, GlobalContext* globalCtx) { + Vec3f velocity; + Vec3f pos; + s32 i; + s32 scaleIndex; + Vec3f* dir; + s32 pad; + + for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { + dir = &sUnitDirections[i]; + + pos.x = pthis->actor.world.pos.x + (dir->x * pthis->actor.scale.x * 20.0f); + pos.y = pthis->actor.world.pos.y + (dir->y * pthis->actor.scale.y * 20.0f) + 10.0f; + pos.z = pthis->actor.world.pos.z + (dir->z * pthis->actor.scale.z * 20.0f); + + velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; + + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; + + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 80, KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_KEEP, gCuttableShrubStalkDL); + + pos.x = pthis->actor.world.pos.x + (dir->x * pthis->actor.scale.x * 40.0f); + pos.y = pthis->actor.world.pos.y + (dir->y * pthis->actor.scale.y * 40.0f) + 10.0f; + pos.z = pthis->actor.world.pos.z + (dir->z * pthis->actor.scale.z * 40.0f); + + velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; + + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; + + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 80, KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_KEEP, gCuttableShrubTipDL); + } +} + +void EnKusa_SpawnBugs(EnKusa* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < 3; i++) { + Actor* bug = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, Rand_ZeroOne() * 0xFFFF, 0, 1); + + if (bug == NULL) { + break; + } + } +} + +void EnKusa_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* pthis = (EnKusa*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); +} + +void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* pthis = (EnKusa*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + pthis->actor.uncullZoneForward += 1000.0f; + } + + EnKusa_InitCollider(thisx, globalCtx); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (pthis->actor.shape.rot.y == 0) { + s16 rand = Rand_ZeroFloat(0x10000); + + pthis->actor.world.rot.y = rand; + pthis->actor.home.rot.y = rand; + pthis->actor.shape.rot.y = rand; + } + + if (!EnKusa_SnapToFloor(pthis, globalCtx, 0.0f)) { + Actor_Kill(&pthis->actor); + return; + } + + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[thisx->params & 3]); + + if (pthis->objBankIndex < 0) { + // "Bank danger!" + osSyncPrintf("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", thisx->params, "../z_en_kusa.c", 561); + Actor_Kill(&pthis->actor); + return; + } + + EnKusa_SetupWaitObject(pthis); +} + +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* pthis = (EnKusa*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnKusa_SetupWaitObject(EnKusa* pthis) { + EnKusa_SetupAction(pthis, EnKusa_WaitObject); +} + +void EnKusa_WaitObject(EnKusa* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + if (pthis->actor.flags & ACTOR_FLAG_11) { + EnKusa_SetupCut(pthis); + } else { + EnKusa_SetupMain(pthis); + } + + pthis->actor.draw = EnKusa_Draw; + pthis->actor.objBankIndex = pthis->objBankIndex; + pthis->actor.flags &= ~ACTOR_FLAG_4; + } +} + +void EnKusa_SetupMain(EnKusa* pthis) { + EnKusa_SetupAction(pthis, EnKusa_Main); + pthis->actor.flags &= ~ACTOR_FLAG_4; +} + +void EnKusa_Main(EnKusa* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + EnKusa_SetupLiftedUp(pthis); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + } else if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + EnKusa_SpawnFragments(pthis, globalCtx); + EnKusa_DropCollectible(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + + if ((pthis->actor.params >> 4) & 1) { + EnKusa_SpawnBugs(pthis, globalCtx); + } + + if ((pthis->actor.params & 3) == ENKUSA_TYPE_0) { + Actor_Kill(&pthis->actor); + return; + } + + EnKusa_SetupCut(pthis); + pthis->actor.flags |= ACTOR_FLAG_11; + } else { + if (!(pthis->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (pthis->actor.xzDistToPlayer > 12.0f)) { + pthis->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + if (pthis->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F580(&pthis->actor, globalCtx); + } + } + } + } +} + +void EnKusa_SetupLiftedUp(EnKusa* pthis) { + EnKusa_SetupAction(pthis, EnKusa_LiftedUp); + pthis->actor.room = -1; + pthis->actor.flags |= ACTOR_FLAG_4; +} + +void EnKusa_LiftedUp(EnKusa* pthis, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + pthis->actor.room = globalCtx->roomCtx.curRoom.num; + EnKusa_SetupFall(pthis); + pthis->actor.velocity.x = pthis->actor.speedXZ * Math_SinS(pthis->actor.world.rot.y); + pthis->actor.velocity.z = pthis->actor.speedXZ * Math_CosS(pthis->actor.world.rot.y); + pthis->actor.colChkInfo.mass = 240; + pthis->actor.gravity = -0.1f; + EnKusa_UpdateVelY(pthis); + EnKusa_RandScaleVecToZero(&pthis->actor.velocity, 0.005f); + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.5f, 35.0f, 0.0f, 0xC5); + pthis->actor.gravity = -3.2f; + } +} + +void EnKusa_SetupFall(EnKusa* pthis) { + EnKusa_SetupAction(pthis, EnKusa_Fall); + rotSpeedXtarget = -0xBB8; + rotSpeedYtarget = (Rand_ZeroOne() - 0.5f) * 1600.0f; + rotSpeedX = 0; + rotSpeedY = 0; +} + +void EnKusa_Fall(EnKusa* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f contactPos; + + if (pthis->actor.bgCheckFlags & 0xB) { + if (!(pthis->actor.bgCheckFlags & 0x20)) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + EnKusa_SpawnFragments(pthis, globalCtx); + EnKusa_DropCollectible(pthis, globalCtx); + switch (pthis->actor.params & 3) { + case ENKUSA_TYPE_0: + case ENKUSA_TYPE_2: + Actor_Kill(&pthis->actor); + break; + + case ENKUSA_TYPE_1: + EnKusa_SetupUprootedWaitRegrow(pthis); + break; + } + return; + } + + if (pthis->actor.bgCheckFlags & 0x40) { + contactPos.x = pthis->actor.world.pos.x; + contactPos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + contactPos.z = pthis->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 400); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 150, 650, 0); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 400, 800, 4); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 500, 1100, 8); + pthis->actor.minVelocityY = -3.0f; + rotSpeedX >>= 1; + rotSpeedXtarget >>= 1; + rotSpeedY >>= 1; + rotSpeedYtarget >>= 1; + pthis->actor.bgCheckFlags &= ~0x40; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + + EnKusa_UpdateVelY(pthis); + Math_StepToS(&rotSpeedX, rotSpeedXtarget, 0x1F4); + Math_StepToS(&rotSpeedY, rotSpeedYtarget, 0xAA); + pthis->actor.shape.rot.x += rotSpeedX; + pthis->actor.shape.rot.y += rotSpeedY; + EnKusa_RandScaleVecToZero(&pthis->actor.velocity, 0.05f); + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnKusa_SetupCut(EnKusa* pthis) { + switch (pthis->actor.params & 3) { + case ENKUSA_TYPE_2: + EnKusa_SetupAction(pthis, EnKusa_DoNothing); + break; + case ENKUSA_TYPE_1: + EnKusa_SetupAction(pthis, EnKusa_CutWaitRegrow); + break; + } +} + +void EnKusa_CutWaitRegrow(EnKusa* pthis, GlobalContext* globalCtx) { + if (pthis->timer >= 120) { + EnKusa_SetupRegrow(pthis); + } +} + +void EnKusa_DoNothing(EnKusa* pthis, GlobalContext* globalCtx) { +} + +void EnKusa_SetupUprootedWaitRegrow(EnKusa* pthis) { + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 9.0f; + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + EnKusa_SetScaleSmall(pthis); + pthis->actor.shape.rot = pthis->actor.home.rot; + EnKusa_SetupAction(pthis, EnKusa_UprootedWaitRegrow); +} + +void EnKusa_UprootedWaitRegrow(EnKusa* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 120) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.6f)) { + if (pthis->timer >= 170) { + EnKusa_SetupRegrow(pthis); + } + } + } +} + +void EnKusa_SetupRegrow(EnKusa* pthis) { + EnKusa_SetupAction(pthis, EnKusa_Regrow); + EnKusa_SetScaleSmall(pthis); + pthis->actor.shape.rot = pthis->actor.home.rot; + pthis->actor.flags &= ~ACTOR_FLAG_11; +} + +void EnKusa_Regrow(EnKusa* pthis, GlobalContext* globalCtx) { + s32 isFullyGrown = true; + + isFullyGrown &= Math_StepToF(&pthis->actor.scale.y, 0.4f, 0.014f); + isFullyGrown &= Math_StepToF(&pthis->actor.scale.x, 0.4f, 0.011f); + pthis->actor.scale.z = pthis->actor.scale.x; + + if (isFullyGrown) { + Actor_SetScale(&pthis->actor, 0.4f); + EnKusa_SetupMain(pthis); + pthis->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } +} + +void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* pthis = (EnKusa*)thisx; + + pthis->timer++; + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.flags & ACTOR_FLAG_11) { + pthis->actor.shape.yOffset = -6.25f; + } else { + pthis->actor.shape.yOffset = 0.0f; + } +} + +void EnKusa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* dLists[] = { gFieldBushDL, object_kusa_DL_000140, object_kusa_DL_000140 }; + EnKusa* pthis = (EnKusa*)thisx; + + if (pthis->actor.flags & ACTOR_FLAG_11) { + Gfx_DrawDListOpa(globalCtx, object_kusa_DL_0002E0); + } else { + Gfx_DrawDListOpa(globalCtx, dLists[thisx->params & 3]); + } +} diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/src/overlays/actors/ovl_En_Kz/z_en_kz.c deleted file mode 100644 index be4e6be47..000000000 --- a/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ /dev/null @@ -1,516 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KZ_Z_EN_KZ_C -#include "actor_common.h" -/* - * File: z_en_kz.c - * Overlay: ovl_En_Kz - * Description: King Zora - */ - -#include "z_en_kz.h" -#include "objects/object_kz/object_kz.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnKz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKz_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnKz_PreMweepWait(EnKz* this, GlobalContext* globalCtx); -void EnKz_SetupMweep(EnKz* this, GlobalContext* globalCtx); -void EnKz_Mweep(EnKz* this, GlobalContext* globalCtx); -void EnKz_StopMweep(EnKz* this, GlobalContext* globalCtx); -void EnKz_Wait(EnKz* this, GlobalContext* globalCtx); -void EnKz_SetupGetItem(EnKz* this, GlobalContext* globalCtx); -void EnKz_StartTimer(EnKz* this, GlobalContext* globalCtx); - -const ActorInit En_Kz_InitVars = { - ACTOR_EN_KZ, - ACTORCAT_NPC, - FLAGS, - OBJECT_KZ, - sizeof(EnKz), - (ActorFunc)EnKz_Init, - (ActorFunc)EnKz_Destroy, - (ActorFunc)EnKz_Update, - (ActorFunc)EnKz_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 80, 120, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; - -static struct_80034EC0_Entry sAnimations[] = { - { &gKzIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &gKzIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, - { &gKzMweepAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, -}; - -u16 EnKz_GetTextNoMaskChild(GlobalContext* globalCtx, EnKz* this) { - Player* player = GET_PLAYER(globalCtx); - - if (CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE)) { - return 0x402B; - } else if (gSaveContext.eventChkInf[3] & 8) { - return 0x401C; - } else { - player->exchangeItemId = EXCH_ITEM_LETTER_RUTO; - return 0x401A; - } -} - -u16 EnKz_GetTextNoMaskAdult(GlobalContext* globalCtx, EnKz* this) { - Player* player = GET_PLAYER(globalCtx); - - if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_FROG) { - if (!(gSaveContext.infTable[19] & 0x200)) { - if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 2)) { - return 0x401F; - } else { - return 0x4012; - } - } else { - return CHECK_QUEST_ITEM(QUEST_SONG_SERENADE) ? 0x4045 : 0x401A; - } - } else { - player->exchangeItemId = EXCH_ITEM_PRESCRIPTION; - return 0x4012; - } -} - -u16 EnKz_GetText(GlobalContext* globalCtx, Actor* thisx) { - EnKz* this = (EnKz*)thisx; - u16 reactionText = Text_GetFaceReaction(globalCtx, 0x1E); - - if (reactionText != 0) { - return reactionText; - } - - if (LINK_IS_ADULT) { - return EnKz_GetTextNoMaskAdult(globalCtx, this); - } else { - return EnKz_GetTextNoMaskChild(globalCtx, this); - } -} - -s16 func_80A9C6C0(GlobalContext* globalCtx, Actor* thisx) { - EnKz* this = (EnKz*)thisx; - s16 ret = 1; - - switch (Message_GetState(&globalCtx->msgCtx)) { - case TEXT_STATE_DONE: - ret = 0; - switch (this->actor.textId) { - case 0x4012: - gSaveContext.infTable[19] |= 0x200; - ret = 2; - break; - case 0x401B: - ret = !Message_ShouldAdvance(globalCtx) ? 1 : 2; - break; - case 0x401F: - gSaveContext.infTable[19] |= 0x200; - break; - } - break; - case TEXT_STATE_DONE_FADING: - if (this->actor.textId != 0x4014) { - if (this->actor.textId == 0x401B && !this->sfxPlayed) { - Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->sfxPlayed = true; - } - } else if (!this->sfxPlayed) { - Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->sfxPlayed = true; - } - break; - case TEXT_STATE_CHOICE: - if (!Message_ShouldAdvance(globalCtx)) { - break; - } - if (this->actor.textId == 0x4014) { - if (globalCtx->msgCtx.choiceIndex == 0) { - EnKz_SetupGetItem(this, globalCtx); - ret = 2; - } else { - this->actor.textId = 0x4016; - Message_ContinueTextbox(globalCtx, this->actor.textId); - } - } - break; - case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx)) { - ret = 2; - } - break; - case TEXT_STATE_NONE: - case TEXT_STATE_DONE_HAS_NEXT: - case TEXT_STATE_CLOSING: - case TEXT_STATE_SONG_DEMO_DONE: - case TEXT_STATE_8: - case TEXT_STATE_9: - break; - } - return ret; -} - -void EnKz_UpdateEyes(EnKz* this) { - if (DECR(this->blinkTimer) == 0) { - this->eyeIdx += 1; - if (this->eyeIdx >= 3) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeIdx = 0; - } - } -} - -s32 func_80A9C95C(GlobalContext* globalCtx, EnKz* this, s16* arg2, f32 unkf, callback1_800343CC callback1, - callback2_800343CC callback2) { - Player* player = GET_PLAYER(globalCtx); - s16 sp32; - s16 sp30; - f32 xzDistToPlayer; - f32 yaw; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - *arg2 = 1; - return 1; - } - - if (*arg2 != 0) { - *arg2 = callback2(globalCtx, &this->actor); - return 0; - } - - yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); - yaw -= this->actor.shape.rot.y; - if ((fabsf(yaw) > 1638.0f) || (this->actor.xzDistToPlayer < 265.0f)) { - this->actor.flags &= ~ACTOR_FLAG_0; - return 0; - } - - this->actor.flags |= ACTOR_FLAG_0; - - Actor_GetScreenPos(globalCtx, &this->actor, &sp32, &sp30); - if (!((sp32 >= -30) && (sp32 < 361) && (sp30 >= -10) && (sp30 < 241))) { - return 0; - } - - xzDistToPlayer = this->actor.xzDistToPlayer; - this->actor.xzDistToPlayer = Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos); - if (func_8002F2CC(&this->actor, globalCtx, unkf) == 0) { - this->actor.xzDistToPlayer = xzDistToPlayer; - return 0; - } - this->actor.xzDistToPlayer = xzDistToPlayer; - this->actor.textId = callback1(globalCtx, &this->actor); - - return 0; -} - -void func_80A9CB18(EnKz* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (func_80A9C95C(globalCtx, this, &this->unk_1E0.unk_00, 340.0f, EnKz_GetText, func_80A9C6C0)) { - if ((this->actor.textId == 0x401A) && !(gSaveContext.eventChkInf[3] & 8)) { - if (func_8002F368(globalCtx) == EXCH_ITEM_LETTER_RUTO) { - this->actor.textId = 0x401B; - this->sfxPlayed = false; - } else { - this->actor.textId = 0x401A; - } - player->actor.textId = this->actor.textId; - return; - } - - if (LINK_IS_ADULT) { - if ((INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_PRESCRIPTION) && - (func_8002F368(globalCtx) == EXCH_ITEM_PRESCRIPTION)) { - this->actor.textId = 0x4014; - this->sfxPlayed = false; - player->actor.textId = this->actor.textId; - this->isTrading = true; - return; - } - - this->isTrading = false; - if (gSaveContext.infTable[19] & 0x200) { - this->actor.textId = CHECK_QUEST_ITEM(QUEST_SONG_SERENADE) ? 0x4045 : 0x401A; - player->actor.textId = this->actor.textId; - } else { - this->actor.textId = CHECK_OWNED_EQUIP(EQUIP_TUNIC, 2) ? 0x401F : 0x4012; - player->actor.textId = this->actor.textId; - } - } - } -} - -s32 EnKz_FollowPath(EnKz* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* pointPos; - f32 pathDiffX; - f32 pathDiffZ; - - if ((this->actor.params & 0xFF00) == 0xFF00) { - return 0; - } - - path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8]; - pointPos = SEGMENTED_TO_VIRTUAL(path->points); - pointPos += this->waypoint; - - pathDiffX = pointPos->x - this->actor.world.pos.x; - pathDiffZ = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 0xA, 0x3E8, 1); - - if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 10.0f) { - this->waypoint++; - if (this->waypoint >= path->count) { - this->waypoint = 0; - } - return 1; - } - return 0; -} - -s32 EnKz_SetMovedPos(EnKz* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* lastPointPos; - - if ((this->actor.params & 0xFF00) == 0xFF00) { - return 0; - } - - path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8]; - lastPointPos = SEGMENTED_TO_VIRTUAL(path->points); - lastPointPos += path->count - 1; - - this->actor.world.pos.x = lastPointPos->x; - this->actor.world.pos.y = lastPointPos->y; - this->actor.world.pos.z = lastPointPos->z; - - return 1; -} - -void EnKz_Init(Actor* thisx, GlobalContext* globalCtx) { - EnKz* this = (EnKz*)thisx; - s32 pad; - - SkelAnime_InitFlex(globalCtx, &this->skelanime, &gKzSkel, NULL, this->jointTable, this->morphTable, - 12); - ActorShape_Init(&this->actor.shape, 0.0, NULL, 0.0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Actor_SetScale(&this->actor, 0.01); - this->actor.targetMode = 3; - this->unk_1E0.unk_00 = 0; - func_80034EC0(&this->skelanime, sAnimations, 0); - - if (gSaveContext.eventChkInf[3] & 8) { - EnKz_SetMovedPos(this, globalCtx); - } - - if (LINK_IS_ADULT) { - if (!(gSaveContext.infTable[19] & 0x100)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BG_ICE_SHELTER, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, - 0x04FF); - } - this->actionFunc = EnKz_Wait; - } else { - this->actionFunc = EnKz_PreMweepWait; - } -} - -void EnKz_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnKz* this = (EnKz*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnKz_PreMweepWait(EnKz* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 2) { - func_80034EC0(&this->skelanime, sAnimations, 2); - this->unk_1E0.unk_00 = 0; - this->actionFunc = EnKz_SetupMweep; - } else { - func_80034F54(globalCtx, this->unk_2A6, this->unk_2BE, 12); - } -} - -void EnKz_SetupMweep(EnKz* this, GlobalContext* globalCtx) { - Vec3f unused = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - Vec3f initPos; - - this->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); - this->gameplayCamera = globalCtx->activeCamera; - Gameplay_ChangeCameraStatus(globalCtx, this->gameplayCamera, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->cutsceneCamera, CAM_STAT_ACTIVE); - pos = this->actor.world.pos; - initPos = this->actor.home.pos; - pos.y += 60.0f; - initPos.y += -100.0f; - initPos.z += 260.0f; - Gameplay_CameraSetAtEye(globalCtx, this->cutsceneCamera, &pos, &initPos); - func_8002DF54(globalCtx, &this->actor, 8); - this->actor.speedXZ = 0.1f; - this->actionFunc = EnKz_Mweep; -} - -void EnKz_Mweep(EnKz* this, GlobalContext* globalCtx) { - Vec3f unused = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - Vec3f initPos; - - pos = this->actor.world.pos; - initPos = this->actor.home.pos; - pos.y += 60.0f; - initPos.y += -100.0f; - initPos.z += 260.0f; - Gameplay_CameraSetAtEye(globalCtx, this->cutsceneCamera, &pos, &initPos); - if ((EnKz_FollowPath(this, globalCtx) == 1) && (this->waypoint == 0)) { - func_80034EC0(&this->skelanime, sAnimations, 1); - Inventory_ReplaceItem(globalCtx, ITEM_LETTER_RUTO, ITEM_BOTTLE); - EnKz_SetMovedPos(this, globalCtx); - gSaveContext.eventChkInf[3] |= 8; - this->actor.speedXZ = 0.0; - this->actionFunc = EnKz_StopMweep; - } - if (this->skelanime.curFrame == 13.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_KZ_MOVE); - } -} - -void EnKz_StopMweep(EnKz* this, GlobalContext* globalCtx) { - Gameplay_ChangeCameraStatus(globalCtx, this->gameplayCamera, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, this->cutsceneCamera); - func_8002DF54(globalCtx, &this->actor, 7); - this->actionFunc = EnKz_Wait; -} - -void EnKz_Wait(EnKz* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 2) { - this->actionFunc = EnKz_SetupGetItem; - EnKz_SetupGetItem(this, globalCtx); - } else { - func_80034F54(globalCtx, this->unk_2A6, this->unk_2BE, 12); - } -} - -void EnKz_SetupGetItem(EnKz* this, GlobalContext* globalCtx) { - s32 getItemId; - f32 xzRange; - f32 yRange; - - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->unk_1E0.unk_00 = 1; - this->actionFunc = EnKz_StartTimer; - } else { - getItemId = this->isTrading == true ? GI_FROG : GI_TUNIC_ZORA; - yRange = fabsf(this->actor.yDistToPlayer) + 1.0f; - xzRange = this->actor.xzDistToPlayer + 1.0f; - func_8002F434(&this->actor, globalCtx, getItemId, xzRange, yRange); - } -} - -void EnKz_StartTimer(EnKz* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_FROG) { - func_80088AA0(180); // start timer2 with 3 minutes - gSaveContext.eventInf[1] &= ~1; - } - this->unk_1E0.unk_00 = 0; - this->actionFunc = EnKz_Wait; - } -} - -void EnKz_Update(Actor* thisx, GlobalContext* globalCtx) { - EnKz* this = (EnKz*)thisx; - s32 pad; - - if (LINK_IS_ADULT && !(gSaveContext.infTable[19] & 0x100)) { - gSaveContext.infTable[19] |= 0x100; - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelanime); - EnKz_UpdateEyes(this); - Actor_MoveForward(&this->actor); - if (this->actionFunc != EnKz_StartTimer) { - func_80A9CB18(this, globalCtx); - } - this->actionFunc(this, globalCtx); -} - -s32 EnKz_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnKz* this = (EnKz*)thisx; - - if (limbIndex == 8 || limbIndex == 9 || limbIndex == 10) { - rot->y += Math_SinS(this->unk_2A6[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->unk_2BE[limbIndex]) * 200.0f; - } - if (limbIndex) {} - return false; -} - -void EnKz_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnKz* this = (EnKz*)thisx; - Vec3f mult = { 2600.0f, 0.0f, 0.0f }; - - if (limbIndex == 11) { - Matrix_MultVec3f(&mult, &this->actor.focus.pos); - } -} - -void EnKz_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* sEyeSegments[] = { - gKzEyeOpenTex, - gKzEyeHalfTex, - gKzEyeClosedTex, - }; - EnKz* this = (EnKz*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_kz.c", 1259); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeSegments[this->eyeIdx])); - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, - EnKz_OverrideLimbDraw, EnKz_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_kz.c", 1281); -} diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.cpp b/src/overlays/actors/ovl_En_Kz/z_en_kz.cpp new file mode 100644 index 000000000..232355888 --- /dev/null +++ b/src/overlays/actors/ovl_En_Kz/z_en_kz.cpp @@ -0,0 +1,516 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_KZ_Z_EN_KZ_C +#include "actor_common.h" +/* + * File: z_en_kz.c + * Overlay: ovl_En_Kz + * Description: King Zora + */ + +#include "z_en_kz.h" +#include "objects/object_kz/object_kz.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnKz_Init(Actor* thisx, GlobalContext* globalCtx); +void EnKz_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnKz_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKz_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnKz_PreMweepWait(EnKz* pthis, GlobalContext* globalCtx); +void EnKz_SetupMweep(EnKz* pthis, GlobalContext* globalCtx); +void EnKz_Mweep(EnKz* pthis, GlobalContext* globalCtx); +void EnKz_StopMweep(EnKz* pthis, GlobalContext* globalCtx); +void EnKz_Wait(EnKz* pthis, GlobalContext* globalCtx); +void EnKz_SetupGetItem(EnKz* pthis, GlobalContext* globalCtx); +void EnKz_StartTimer(EnKz* pthis, GlobalContext* globalCtx); + +ActorInit En_Kz_InitVars = { + ACTOR_EN_KZ, + ACTORCAT_NPC, + FLAGS, + OBJECT_KZ, + sizeof(EnKz), + (ActorFunc)EnKz_Init, + (ActorFunc)EnKz_Destroy, + (ActorFunc)EnKz_Update, + (ActorFunc)EnKz_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 80, 120, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; + +static struct_80034EC0_Entry sAnimations[] = { + { &gKzIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gKzIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gKzMweepAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, +}; + +u16 EnKz_GetTextNoMaskChild(GlobalContext* globalCtx, EnKz* pthis) { + Player* player = GET_PLAYER(globalCtx); + + if (CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE)) { + return 0x402B; + } else if (gSaveContext.eventChkInf[3] & 8) { + return 0x401C; + } else { + player->exchangeItemId = EXCH_ITEM_LETTER_RUTO; + return 0x401A; + } +} + +u16 EnKz_GetTextNoMaskAdult(GlobalContext* globalCtx, EnKz* pthis) { + Player* player = GET_PLAYER(globalCtx); + + if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_FROG) { + if (!(gSaveContext.infTable[19] & 0x200)) { + if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 2)) { + return 0x401F; + } else { + return 0x4012; + } + } else { + return CHECK_QUEST_ITEM(QUEST_SONG_SERENADE) ? 0x4045 : 0x401A; + } + } else { + player->exchangeItemId = EXCH_ITEM_PRESCRIPTION; + return 0x4012; + } +} + +u16 EnKz_GetText(GlobalContext* globalCtx, Actor* thisx) { + EnKz* pthis = (EnKz*)thisx; + u16 reactionText = Text_GetFaceReaction(globalCtx, 0x1E); + + if (reactionText != 0) { + return reactionText; + } + + if (LINK_IS_ADULT) { + return EnKz_GetTextNoMaskAdult(globalCtx, pthis); + } else { + return EnKz_GetTextNoMaskChild(globalCtx, pthis); + } +} + +s16 func_80A9C6C0(GlobalContext* globalCtx, Actor* thisx) { + EnKz* pthis = (EnKz*)thisx; + s16 ret = 1; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case TEXT_STATE_DONE: + ret = 0; + switch (pthis->actor.textId) { + case 0x4012: + gSaveContext.infTable[19] |= 0x200; + ret = 2; + break; + case 0x401B: + ret = !Message_ShouldAdvance(globalCtx) ? 1 : 2; + break; + case 0x401F: + gSaveContext.infTable[19] |= 0x200; + break; + } + break; + case TEXT_STATE_DONE_FADING: + if (pthis->actor.textId != 0x4014) { + if (pthis->actor.textId == 0x401B && !pthis->sfxPlayed) { + Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->sfxPlayed = true; + } + } else if (!pthis->sfxPlayed) { + Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->sfxPlayed = true; + } + break; + case TEXT_STATE_CHOICE: + if (!Message_ShouldAdvance(globalCtx)) { + break; + } + if (pthis->actor.textId == 0x4014) { + if (globalCtx->msgCtx.choiceIndex == 0) { + EnKz_SetupGetItem(pthis, globalCtx); + ret = 2; + } else { + pthis->actor.textId = 0x4016; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } + } + break; + case TEXT_STATE_EVENT: + if (Message_ShouldAdvance(globalCtx)) { + ret = 2; + } + break; + case TEXT_STATE_NONE: + case TEXT_STATE_DONE_HAS_NEXT: + case TEXT_STATE_CLOSING: + case TEXT_STATE_SONG_DEMO_DONE: + case TEXT_STATE_8: + case TEXT_STATE_9: + break; + } + return ret; +} + +void EnKz_UpdateEyes(EnKz* pthis) { + if (DECR(pthis->blinkTimer) == 0) { + pthis->eyeIdx += 1; + if (pthis->eyeIdx >= 3) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeIdx = 0; + } + } +} + +s32 func_80A9C95C(GlobalContext* globalCtx, EnKz* pthis, s16* arg2, f32 unkf, callback1_800343CC callback1, + callback2_800343CC callback2) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + s16 sp30; + f32 xzDistToPlayer; + f32 yaw; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + *arg2 = 1; + return 1; + } + + if (*arg2 != 0) { + *arg2 = callback2(globalCtx, &pthis->actor); + return 0; + } + + yaw = Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos); + yaw -= pthis->actor.shape.rot.y; + if ((fabsf(yaw) > 1638.0f) || (pthis->actor.xzDistToPlayer < 265.0f)) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + return 0; + } + + pthis->actor.flags |= ACTOR_FLAG_0; + + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp32, &sp30); + if (!((sp32 >= -30) && (sp32 < 361) && (sp30 >= -10) && (sp30 < 241))) { + return 0; + } + + xzDistToPlayer = pthis->actor.xzDistToPlayer; + pthis->actor.xzDistToPlayer = Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos); + if (func_8002F2CC(&pthis->actor, globalCtx, unkf) == 0) { + pthis->actor.xzDistToPlayer = xzDistToPlayer; + return 0; + } + pthis->actor.xzDistToPlayer = xzDistToPlayer; + pthis->actor.textId = callback1(globalCtx, &pthis->actor); + + return 0; +} + +void func_80A9CB18(EnKz* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80A9C95C(globalCtx, pthis, &pthis->unk_1E0.unk_00, 340.0f, EnKz_GetText, func_80A9C6C0)) { + if ((pthis->actor.textId == 0x401A) && !(gSaveContext.eventChkInf[3] & 8)) { + if (func_8002F368(globalCtx) == EXCH_ITEM_LETTER_RUTO) { + pthis->actor.textId = 0x401B; + pthis->sfxPlayed = false; + } else { + pthis->actor.textId = 0x401A; + } + player->actor.textId = pthis->actor.textId; + return; + } + + if (LINK_IS_ADULT) { + if ((INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_PRESCRIPTION) && + (func_8002F368(globalCtx) == EXCH_ITEM_PRESCRIPTION)) { + pthis->actor.textId = 0x4014; + pthis->sfxPlayed = false; + player->actor.textId = pthis->actor.textId; + pthis->isTrading = true; + return; + } + + pthis->isTrading = false; + if (gSaveContext.infTable[19] & 0x200) { + pthis->actor.textId = CHECK_QUEST_ITEM(QUEST_SONG_SERENADE) ? 0x4045 : 0x401A; + player->actor.textId = pthis->actor.textId; + } else { + pthis->actor.textId = CHECK_OWNED_EQUIP(EQUIP_TUNIC, 2) ? 0x401F : 0x4012; + player->actor.textId = pthis->actor.textId; + } + } + } +} + +s32 EnKz_FollowPath(EnKz* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* pointPos; + f32 pathDiffX; + f32 pathDiffZ; + + if ((pthis->actor.params & 0xFF00) == 0xFF00) { + return 0; + } + + path = &globalCtx->setupPathList[(pthis->actor.params & 0xFF00) >> 8]; + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos += pthis->waypoint; + + pathDiffX = pointPos->x - pthis->actor.world.pos.x; + pathDiffZ = pointPos->z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.world.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 0xA, 0x3E8, 1); + + if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 10.0f) { + pthis->waypoint++; + if (pthis->waypoint >= path->count) { + pthis->waypoint = 0; + } + return 1; + } + return 0; +} + +s32 EnKz_SetMovedPos(EnKz* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* lastPointPos; + + if ((pthis->actor.params & 0xFF00) == 0xFF00) { + return 0; + } + + path = &globalCtx->setupPathList[(pthis->actor.params & 0xFF00) >> 8]; + lastPointPos = SEGMENTED_TO_VIRTUAL(path->points); + lastPointPos += path->count - 1; + + pthis->actor.world.pos.x = lastPointPos->x; + pthis->actor.world.pos.y = lastPointPos->y; + pthis->actor.world.pos.z = lastPointPos->z; + + return 1; +} + +void EnKz_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKz* pthis = (EnKz*)thisx; + s32 pad; + + SkelAnime_InitFlex(globalCtx, &pthis->skelanime, &gKzSkel, NULL, pthis->jointTable, pthis->morphTable, + 12); + ActorShape_Init(&pthis->actor.shape, 0.0, NULL, 0.0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + Actor_SetScale(&pthis->actor, 0.01); + pthis->actor.targetMode = 3; + pthis->unk_1E0.unk_00 = 0; + func_80034EC0(&pthis->skelanime, sAnimations, 0); + + if (gSaveContext.eventChkInf[3] & 8) { + EnKz_SetMovedPos(pthis, globalCtx); + } + + if (LINK_IS_ADULT) { + if (!(gSaveContext.infTable[19] & 0x100)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BG_ICE_SHELTER, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, + 0x04FF); + } + pthis->actionFunc = EnKz_Wait; + } else { + pthis->actionFunc = EnKz_PreMweepWait; + } +} + +void EnKz_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKz* pthis = (EnKz*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnKz_PreMweepWait(EnKz* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 2) { + func_80034EC0(&pthis->skelanime, sAnimations, 2); + pthis->unk_1E0.unk_00 = 0; + pthis->actionFunc = EnKz_SetupMweep; + } else { + func_80034F54(globalCtx, pthis->unk_2A6, pthis->unk_2BE, 12); + } +} + +void EnKz_SetupMweep(EnKz* pthis, GlobalContext* globalCtx) { + Vec3f unused = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + Vec3f initPos; + + pthis->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); + pthis->gameplayCamera = globalCtx->activeCamera; + Gameplay_ChangeCameraStatus(globalCtx, pthis->gameplayCamera, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cutsceneCamera, CAM_STAT_ACTIVE); + pos = pthis->actor.world.pos; + initPos = pthis->actor.home.pos; + pos.y += 60.0f; + initPos.y += -100.0f; + initPos.z += 260.0f; + Gameplay_CameraSetAtEye(globalCtx, pthis->cutsceneCamera, &pos, &initPos); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->actor.speedXZ = 0.1f; + pthis->actionFunc = EnKz_Mweep; +} + +void EnKz_Mweep(EnKz* pthis, GlobalContext* globalCtx) { + Vec3f unused = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + Vec3f initPos; + + pos = pthis->actor.world.pos; + initPos = pthis->actor.home.pos; + pos.y += 60.0f; + initPos.y += -100.0f; + initPos.z += 260.0f; + Gameplay_CameraSetAtEye(globalCtx, pthis->cutsceneCamera, &pos, &initPos); + if ((EnKz_FollowPath(pthis, globalCtx) == 1) && (pthis->waypoint == 0)) { + func_80034EC0(&pthis->skelanime, sAnimations, 1); + Inventory_ReplaceItem(globalCtx, ITEM_LETTER_RUTO, ITEM_BOTTLE); + EnKz_SetMovedPos(pthis, globalCtx); + gSaveContext.eventChkInf[3] |= 8; + pthis->actor.speedXZ = 0.0; + pthis->actionFunc = EnKz_StopMweep; + } + if (pthis->skelanime.curFrame == 13.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_KZ_MOVE); + } +} + +void EnKz_StopMweep(EnKz* pthis, GlobalContext* globalCtx) { + Gameplay_ChangeCameraStatus(globalCtx, pthis->gameplayCamera, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, pthis->cutsceneCamera); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->actionFunc = EnKz_Wait; +} + +void EnKz_Wait(EnKz* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 2) { + pthis->actionFunc = EnKz_SetupGetItem; + EnKz_SetupGetItem(pthis, globalCtx); + } else { + func_80034F54(globalCtx, pthis->unk_2A6, pthis->unk_2BE, 12); + } +} + +void EnKz_SetupGetItem(EnKz* pthis, GlobalContext* globalCtx) { + s32 getItemId; + f32 xzRange; + f32 yRange; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->unk_1E0.unk_00 = 1; + pthis->actionFunc = EnKz_StartTimer; + } else { + getItemId = pthis->isTrading == true ? GI_FROG : GI_TUNIC_ZORA; + yRange = fabsf(pthis->actor.yDistToPlayer) + 1.0f; + xzRange = pthis->actor.xzDistToPlayer + 1.0f; + func_8002F434(&pthis->actor, globalCtx, getItemId, xzRange, yRange); + } +} + +void EnKz_StartTimer(EnKz* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_FROG) { + func_80088AA0(180); // start timer2 with 3 minutes + gSaveContext.eventInf[1] &= ~1; + } + pthis->unk_1E0.unk_00 = 0; + pthis->actionFunc = EnKz_Wait; + } +} + +void EnKz_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKz* pthis = (EnKz*)thisx; + s32 pad; + + if (LINK_IS_ADULT && !(gSaveContext.infTable[19] & 0x100)) { + gSaveContext.infTable[19] |= 0x100; + } + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelanime); + EnKz_UpdateEyes(pthis); + Actor_MoveForward(&pthis->actor); + if (pthis->actionFunc != EnKz_StartTimer) { + func_80A9CB18(pthis, globalCtx); + } + pthis->actionFunc(pthis, globalCtx); +} + +s32 EnKz_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnKz* pthis = (EnKz*)thisx; + + if (limbIndex == 8 || limbIndex == 9 || limbIndex == 10) { + rot->y += Math_SinS(pthis->unk_2A6[limbIndex]) * 200.0f; + rot->z += Math_CosS(pthis->unk_2BE[limbIndex]) * 200.0f; + } + if (limbIndex) {} + return false; +} + +void EnKz_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnKz* pthis = (EnKz*)thisx; + Vec3f mult = { 2600.0f, 0.0f, 0.0f }; + + if (limbIndex == 11) { + Matrix_MultVec3f(&mult, &pthis->actor.focus.pos); + } +} + +void EnKz_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* sEyeSegments[] = { + gKzEyeOpenTex, + gKzEyeHalfTex, + gKzEyeClosedTex, + }; + EnKz* pthis = (EnKz*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_kz.c", 1259); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeSegments[pthis->eyeIdx])); + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, pthis->skelanime.dListCount, + EnKz_OverrideLimbDraw, EnKz_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_kz.c", 1281); +} diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.cpp similarity index 62% rename from src/overlays/actors/ovl_En_Light/z_en_light.c rename to src/overlays/actors/ovl_En_Light/z_en_light.cpp index 24374e244..c1f0c51bc 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.cpp @@ -26,7 +26,7 @@ void EnLight_Update(Actor* thisx, GlobalContext* globalCtx); void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx); void EnLight_UpdateSwitch(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Light_InitVars = { +ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, ACTORCAT_ITEMACTION, FLAGS, @@ -56,89 +56,89 @@ static FlameParams D_80A9E840[] = { }; void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { - EnLight* this = (EnLight*)thisx; + EnLight* pthis = (EnLight*)thisx; s16 yOffset; if (gSaveContext.gameMode == 3) { // special case for the credits - yOffset = (this->actor.params < 0) ? 1 : 40; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, yOffset + (s16)this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 180, -1); + yOffset = (pthis->actor.params < 0) ? 1 : 40; + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, yOffset + (s16)pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 180, -1); } else { - yOffset = (this->actor.params < 0) ? 1 : 40; - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, yOffset + (s16)this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 180, -1); + yOffset = (pthis->actor.params < 0) ? 1 : 40; + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, yOffset + (s16)pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 180, -1); } - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Actor_SetScale(&this->actor, D_80A9E840[this->actor.params & 0xF].scale * 0.0001f); - this->timer = (s32)(Rand_ZeroOne() * 255.0f); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Actor_SetScale(&pthis->actor, D_80A9E840[pthis->actor.params & 0xF].scale * 0.0001f); + pthis->timer = (s32)(Rand_ZeroOne() * 255.0f); - if ((this->actor.params & 0x400) != 0) { - this->actor.update = EnLight_UpdateSwitch; + if ((pthis->actor.params & 0x400) != 0) { + pthis->actor.update = EnLight_UpdateSwitch; } } void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnLight* this = (EnLight*)thisx; + EnLight* pthis = (EnLight*)thisx; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); } -void EnLight_UpdatePosRot(EnLight* this, GlobalContext* globalCtx) { +void EnLight_UpdatePosRot(EnLight* pthis, GlobalContext* globalCtx) { // update yaw for billboard effect - this->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + pthis->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; - if (this->actor.parent != NULL) { - Math_Vec3f_Copy(&this->actor.world.pos, &(this->actor.parent)->world.pos); - this->actor.world.pos.y += 17.0f; + if (pthis->actor.parent != NULL) { + Math_Vec3f_Copy(&pthis->actor.world.pos, &(pthis->actor.parent)->world.pos); + pthis->actor.world.pos.y += 17.0f; } - this->timer++; + pthis->timer++; } void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { f32 intensity; FlameParams* flameParams; s16 radius; - EnLight* this = (EnLight*)thisx; + EnLight* pthis = (EnLight*)thisx; - flameParams = &D_80A9E840[this->actor.params & 0xF]; + flameParams = &D_80A9E840[pthis->actor.params & 0xF]; intensity = (Rand_ZeroOne() * 0.5f) + 0.5f; - radius = (this->actor.params < 0) ? 100 : 300; - Lights_PointSetColorAndRadius(&this->lightInfo, (flameParams->primColor.r * intensity), + radius = (pthis->actor.params < 0) ? 100 : 300; + Lights_PointSetColorAndRadius(&pthis->lightInfo, (flameParams->primColor.r * intensity), (flameParams->primColor.g * intensity), (flameParams->primColor.b * intensity), radius); - EnLight_UpdatePosRot(this, globalCtx); + EnLight_UpdatePosRot(pthis, globalCtx); - if (this->actor.params >= 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + if (pthis->actor.params >= 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_TORCH - SFX_FLAG); } } void EnLight_UpdateSwitch(Actor* thisx, GlobalContext* globalCtx) { f32 intensity; FlameParams* flameParams; - EnLight* this = (EnLight*)thisx; + EnLight* pthis = (EnLight*)thisx; f32 scale; - flameParams = &D_80A9E840[this->actor.params & 0xF]; - scale = this->actor.scale.x / ((f32)flameParams->scale * 0.0001); + flameParams = &D_80A9E840[pthis->actor.params & 0xF]; + scale = pthis->actor.scale.x / ((f32)flameParams->scale * 0.0001); - if ((this->actor.params & 0x800) != 0) { - if (Flags_GetSwitch(globalCtx, (this->actor.params & 0x3F0) >> 4)) { + if ((pthis->actor.params & 0x800) != 0) { + if (Flags_GetSwitch(globalCtx, (pthis->actor.params & 0x3F0) >> 4)) { Math_StepToF(&scale, 1.0f, 0.05f); } else { if (scale < 0.1f) { - Actor_SetScale(&this->actor, 0.0f); + Actor_SetScale(&pthis->actor, 0.0f); return; } Math_StepToF(&scale, 0.0f, 0.05f); } } else { - if (Flags_GetSwitch(globalCtx, (this->actor.params & 0x3F0) >> 4)) { + if (Flags_GetSwitch(globalCtx, (pthis->actor.params & 0x3F0) >> 4)) { if (scale < 0.1f) { - Actor_SetScale(&this->actor, 0.0f); + Actor_SetScale(&pthis->actor, 0.0f); return; } Math_StepToF(&scale, 0.0f, 0.05f); @@ -147,36 +147,36 @@ void EnLight_UpdateSwitch(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetScale(&this->actor, ((f32)flameParams->scale * 0.0001) * scale); + Actor_SetScale(&pthis->actor, ((f32)flameParams->scale * 0.0001) * scale); intensity = (Rand_ZeroOne() * 0.5f) + 0.5f; - Lights_PointSetColorAndRadius(&this->lightInfo, (flameParams->primColor.r * intensity), + Lights_PointSetColorAndRadius(&pthis->lightInfo, (flameParams->primColor.r * intensity), (flameParams->primColor.g * intensity), (flameParams->primColor.b * intensity), 300.0f * scale); - EnLight_UpdatePosRot(this, globalCtx); + EnLight_UpdatePosRot(pthis, globalCtx); - if (this->actor.params >= 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + if (pthis->actor.params >= 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_TORCH - SFX_FLAG); } } void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnLight* this = (EnLight*)thisx; + EnLight* pthis = (EnLight*)thisx; s32 pad; FlameParams* flameParams; Gfx* dList; if (1) {} - flameParams = &D_80A9E840[this->actor.params & 0xF]; + flameParams = &D_80A9E840[pthis->actor.params & 0xF]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_light.c", 441); func_80093D84(globalCtx->state.gfxCtx); - if (this->actor.params >= 0) { + if (pthis->actor.params >= 0) { gSPSegment( POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (this->timer * -20) & 511, 32, 128)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (pthis->timer * -20) & 511, 32, 128)); dList = gEffFire1DL; gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, flameParams->primColor.r, flameParams->primColor.g, @@ -184,19 +184,19 @@ void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, flameParams->envColor.r, flameParams->envColor.g, flameParams->envColor.b, 0); } else { gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 32, 1, ((this->timer * 2) & 63), - (this->timer * -6) & 127 * 1, 16, 32)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 32, 1, ((pthis->timer * 2) & 63), + (pthis->timer * -6) & 127 * 1, 16, 32)); dList = gUnusedCandleDL; gDPSetPrimColor(POLY_XLU_DISP++, 0xC0, 0xC0, 255, 200, 0, 0); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); } - Matrix_RotateY((s16)((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y) + 0x8000) * + Matrix_RotateY((s16)((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y) + 0x8000) * (M_PI / 32768.0f), MTXMODE_APPLY); - if (this->actor.params & 1) { + if (pthis->actor.params & 1) { Matrix_RotateY(M_PI, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Lightbox/z_en_lightbox.c b/src/overlays/actors/ovl_En_Lightbox/z_en_lightbox.cpp similarity index 87% rename from src/overlays/actors/ovl_En_Lightbox/z_en_lightbox.c rename to src/overlays/actors/ovl_En_Lightbox/z_en_lightbox.cpp index 228300dfd..fecedd9e4 100644 --- a/src/overlays/actors/ovl_En_Lightbox/z_en_lightbox.c +++ b/src/overlays/actors/ovl_En_Lightbox/z_en_lightbox.cpp @@ -21,7 +21,7 @@ void EnLightbox_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLightbox_Update(Actor* thisx, GlobalContext* globalCtx); void EnLightbox_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Lightbox_InitVars = { +ActorInit En_Lightbox_InitVars = { ACTOR_EN_LIGHTBOX, ACTORCAT_PROP, FLAGS, @@ -35,7 +35,7 @@ const ActorInit En_Lightbox_InitVars = { void EnLightbox_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionHeader* colHeader = NULL; - EnLightbox* this = (EnLightbox*)thisx; + EnLightbox* pthis = (EnLightbox*)thisx; s32 pad[4]; switch (thisx->params) { @@ -58,30 +58,30 @@ void EnLightbox_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->colChkInfo.cylRadius = 30; thisx->colChkInfo.cylHeight = 50; ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 6.0f); - this->dyna.unk_160 = 0; - this->dyna.unk_15C = 0; + pthis->dyna.unk_160 = 0; + pthis->dyna.unk_15C = 0; thisx->targetMode = 0; thisx->gravity = -2.0f; CollisionHeader_GetVirtual(&object_lightbox_Col_001F10, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); } void EnLightbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnLightbox* this = (EnLightbox*)thisx; + EnLightbox* pthis = (EnLightbox*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void EnLightbox_Update(Actor* thisx, GlobalContext* globalCtx) { - EnLightbox* this = (EnLightbox*)thisx; + EnLightbox* pthis = (EnLightbox*)thisx; - if (this->dyna.unk_162 != 0) { + if (pthis->dyna.unk_162 != 0) { if (Actor_HasNoParent(thisx, globalCtx)) { - this->dyna.unk_162 = 0; + pthis->dyna.unk_162 = 0; } } else { if (Actor_HasParent(thisx, globalCtx)) { - this->dyna.unk_162++; + pthis->dyna.unk_162++; } else { if (thisx->speedXZ) { if (thisx->bgCheckFlags & 8) { diff --git a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.cpp similarity index 68% rename from src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c rename to src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.cpp index fdef04780..c698550d9 100644 --- a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c +++ b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.cpp @@ -17,7 +17,7 @@ void EnMFire1_Init(Actor* thisx, GlobalContext* globalCtx); void EnMFire1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMFire1_Update(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_M_Fire1_InitVars = { +ActorInit En_M_Fire1_InitVars = { ACTOR_EN_M_FIRE1, ACTORCAT_MISC, FLAGS, @@ -50,31 +50,31 @@ static ColliderCylinderInit sCylinderInit = { }; void EnMFire1_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMFire1* this = (EnMFire1*)thisx; + EnMFire1* pthis = (EnMFire1*)thisx; s32 pad; - if (this->actor.params < 0) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ITEMACTION); + if (pthis->actor.params < 0) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ITEMACTION); } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); } void EnMFire1_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMFire1* this = (EnMFire1*)thisx; + EnMFire1* pthis = (EnMFire1*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void EnMFire1_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMFire1* this = (EnMFire1*)thisx; + EnMFire1* pthis = (EnMFire1*)thisx; s32 pad; - if (Math_StepToF(&this->timer, 1.0f, 0.2f)) { - Actor_Kill(&this->actor); + if (Math_StepToF(&pthis->timer, 1.0f, 0.2f)) { + Actor_Kill(&pthis->actor); } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.cpp similarity index 58% rename from src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c rename to src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.cpp index 199e0bf45..3ff9df95e 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.cpp @@ -24,10 +24,10 @@ void EnMThunder_Update(Actor* thisx, GlobalContext* globalCtx); void EnMThunder_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80A9F314(GlobalContext* globalCtx, f32 arg1); -void func_80A9F408(EnMThunder* this, GlobalContext* globalCtx); -void func_80A9F9B4(EnMThunder* this, GlobalContext* globalCtx); +void func_80A9F408(EnMThunder* pthis, GlobalContext* globalCtx); +void func_80A9F9B4(EnMThunder* pthis, GlobalContext* globalCtx); -const ActorInit En_M_Thunder_InitVars = { +ActorInit En_M_Thunder_InitVars = { ACTOR_EN_M_THUNDER, ACTORCAT_ITEMACTION, FLAGS, @@ -70,79 +70,79 @@ static u16 sSfxIds[] = { }; // Setup action -void func_80A9EFE0(EnMThunder* this, EnMThunderActionFunc actionFunc) { - this->actionFunc = actionFunc; +void func_80A9EFE0(EnMThunder* pthis, EnMThunderActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnMThunder_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnMThunder* this = (EnMThunder*)thisx; + EnMThunder* pthis = (EnMThunder*)thisx; Player* player = GET_PLAYER(globalCtx); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80AA0420); - this->unk_1C7 = (this->actor.params & 0xFF) - 1; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 255, 255, 255, 0); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - this->collider.dim.radius = 0; - this->collider.dim.height = 40; - this->collider.dim.yShift = -20; - this->unk_1C4 = 8; - this->unk_1B4 = 0.0f; - this->actor.world.pos = player->bodyPartsPos[0]; - this->unk_1AC = 0.0f; - this->unk_1BC = 0.0f; - this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; - this->actor.room = -1; - Actor_SetScale(&this->actor, 0.1f); - this->unk_1CA = 0; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &D_80AA0420); + pthis->unk_1C7 = (pthis->actor.params & 0xFF) - 1; + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 255, 255, 255, 0); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + pthis->collider.dim.radius = 0; + pthis->collider.dim.height = 40; + pthis->collider.dim.yShift = -20; + pthis->unk_1C4 = 8; + pthis->unk_1B4 = 0.0f; + pthis->actor.world.pos = player->bodyPartsPos[0]; + pthis->unk_1AC = 0.0f; + pthis->unk_1BC = 0.0f; + pthis->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + pthis->actor.room = -1; + Actor_SetScale(&pthis->actor, 0.1f); + pthis->unk_1CA = 0; if (player->stateFlags2 & 0x20000) { if (!gSaveContext.magicAcquired || gSaveContext.unk_13F0 || - (((this->actor.params & 0xFF00) >> 8) && - !(func_80087708(globalCtx, (this->actor.params & 0xFF00) >> 8, 0)))) { + (((pthis->actor.params & 0xFF00) >> 8) && + !(func_80087708(globalCtx, (pthis->actor.params & 0xFF00) >> 8, 0)))) { Audio_PlaySoundGeneral(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } player->stateFlags2 &= ~0x20000; - this->unk_1CA = 1; - this->collider.info.toucher.dmgFlags = D_80AA044C[this->unk_1C7]; - this->unk_1C6 = 1; - this->unk_1C9 = ((this->unk_1C7 == 1) ? 2 : 4); - func_80A9EFE0(this, func_80A9F9B4); - this->unk_1C4 = 8; + pthis->unk_1CA = 1; + pthis->collider.info.toucher.dmgFlags = D_80AA044C[pthis->unk_1C7]; + pthis->unk_1C6 = 1; + pthis->unk_1C9 = ((pthis->unk_1C7 == 1) ? 2 : 4); + func_80A9EFE0(pthis, func_80A9F9B4); + pthis->unk_1C4 = 8; Audio_PlaySoundGeneral(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_1AC = 1.0f; + pthis->unk_1AC = 1.0f; } else { - func_80A9EFE0(this, func_80A9F408); + func_80A9EFE0(pthis, func_80A9F408); } - this->actor.child = NULL; + pthis->actor.child = NULL; } void EnMThunder_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMThunder* this = (EnMThunder*)thisx; + EnMThunder* pthis = (EnMThunder*)thisx; - if (this->unk_1CA != 0) { + if (pthis->unk_1CA != 0) { func_800876C8(globalCtx); } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); func_80A9F314(globalCtx, 0.0f); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); } void func_80A9F314(GlobalContext* globalCtx, f32 arg1) { Environment_AdjustLights(globalCtx, arg1, 850.0f, 0.2f, 0.0f); } -void func_80A9F350(EnMThunder* this, GlobalContext* globalCtx) { +void func_80A9F350(EnMThunder* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->stateFlags2 & 0x20000) { @@ -153,36 +153,36 @@ void func_80A9F350(EnMThunder* this, GlobalContext* globalCtx) { &D_801333E8); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } if (!(player->stateFlags1 & 0x1000)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void func_80A9F408(EnMThunder* this, GlobalContext* globalCtx) { +void func_80A9F408(EnMThunder* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* child = this->actor.child; + Actor* child = pthis->actor.child; - this->unk_1B8 = player->unk_858; - this->actor.world.pos = player->bodyPartsPos[0]; - this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + pthis->unk_1B8 = player->unk_858; + pthis->actor.world.pos = player->bodyPartsPos[0]; + pthis->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; - if (this->unk_1CA == 0) { + if (pthis->unk_1CA == 0) { if (player->unk_858 >= 0.1f) { - if ((gSaveContext.unk_13F0) || (((this->actor.params & 0xFF00) >> 8) && - !(func_80087708(globalCtx, (this->actor.params & 0xFF00) >> 8, 4)))) { - func_80A9F350(this, globalCtx); - func_80A9EFE0(this, func_80A9F350); - this->unk_1C8 = 0; - this->unk_1BC = 0.0; - this->unk_1AC = 0.0f; + if ((gSaveContext.unk_13F0) || (((pthis->actor.params & 0xFF00) >> 8) && + !(func_80087708(globalCtx, (pthis->actor.params & 0xFF00) >> 8, 4)))) { + func_80A9F350(pthis, globalCtx); + func_80A9EFE0(pthis, func_80A9F350); + pthis->unk_1C8 = 0; + pthis->unk_1BC = 0.0; + pthis->unk_1AC = 0.0f; return; } - this->unk_1CA = 1; + pthis->unk_1CA = 1; } } @@ -202,54 +202,54 @@ void func_80A9F408(EnMThunder* this, GlobalContext* globalCtx) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } else { player->stateFlags2 &= ~0x20000; - if ((this->actor.params & 0xFF00) >> 8) { + if ((pthis->actor.params & 0xFF00) >> 8) { gSaveContext.unk_13F0 = 1; } if (player->unk_858 < 0.85f) { - this->collider.info.toucher.dmgFlags = D_80AA044C[this->unk_1C7]; - this->unk_1C6 = 1; - this->unk_1C9 = ((this->unk_1C7 == 1) ? 2 : 4); + pthis->collider.info.toucher.dmgFlags = D_80AA044C[pthis->unk_1C7]; + pthis->unk_1C6 = 1; + pthis->unk_1C9 = ((pthis->unk_1C7 == 1) ? 2 : 4); } else { - this->collider.info.toucher.dmgFlags = D_80AA0458[this->unk_1C7]; - this->unk_1C6 = 0; - this->unk_1C9 = ((this->unk_1C7 == 1) ? 4 : 8); + pthis->collider.info.toucher.dmgFlags = D_80AA0458[pthis->unk_1C7]; + pthis->unk_1C6 = 0; + pthis->unk_1C9 = ((pthis->unk_1C7 == 1) ? 4 : 8); } - func_80A9EFE0(this, func_80A9F9B4); - this->unk_1C4 = 8; - Audio_PlaySoundGeneral(sSfxIds[this->unk_1C6], &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + func_80A9EFE0(pthis, func_80A9F9B4); + pthis->unk_1C4 = 8; + Audio_PlaySoundGeneral(sSfxIds[pthis->unk_1C6], &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_1AC = 1.0f; + pthis->unk_1AC = 1.0f; return; } } if (!(player->stateFlags1 & 0x1000)) { - if (this->actor.child != NULL) { - this->actor.child->parent = NULL; + if (pthis->actor.child != NULL) { + pthis->actor.child->parent = NULL; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } if (player->unk_858 > 0.15f) { - this->unk_1C8 = 255; - if (this->actor.child == NULL) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EFF_DUST, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, - this->unk_1C7 + 2); + pthis->unk_1C8 = 255; + if (pthis->actor.child == NULL) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EFF_DUST, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, pthis->actor.shape.rot.y, 0, + pthis->unk_1C7 + 2); } - this->unk_1BC += ((((player->unk_858 - 0.15f) * 1.5f) - this->unk_1BC) * 0.5f); + pthis->unk_1BC += ((((player->unk_858 - 0.15f) * 1.5f) - pthis->unk_1BC) * 0.5f); } else if (player->unk_858 > .1f) { - this->unk_1C8 = (s32)((player->unk_858 - .1f) * 255.0f * 20.0f); - this->unk_1AC = (player->unk_858 - .1f) * 10.0f; + pthis->unk_1C8 = (s32)((player->unk_858 - .1f) * 255.0f * 20.0f); + pthis->unk_1AC = (player->unk_858 - .1f) * 10.0f; } else { - this->unk_1C8 = 0; + pthis->unk_1C8 = 0; } if (player->unk_858 > 0.85f) { @@ -261,78 +261,78 @@ void func_80A9F408(EnMThunder* this, GlobalContext* globalCtx) { } if (Gameplay_InCsMode(globalCtx)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void func_80A9F938(EnMThunder* this, GlobalContext* globalCtx) { - if (this->unk_1C4 < 2) { - if (this->unk_1C8 < 40) { - this->unk_1C8 = 0; +void func_80A9F938(EnMThunder* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1C4 < 2) { + if (pthis->unk_1C8 < 40) { + pthis->unk_1C8 = 0; } else { - this->unk_1C8 -= 40; + pthis->unk_1C8 -= 40; } } - this->unk_1B4 += 2.0f * this->unk_1B0; + pthis->unk_1B4 += 2.0f * pthis->unk_1B0; - if (this->unk_1BC < this->unk_1AC) { - this->unk_1BC += ((this->unk_1AC - this->unk_1BC) * 0.1f); + if (pthis->unk_1BC < pthis->unk_1AC) { + pthis->unk_1BC += ((pthis->unk_1AC - pthis->unk_1BC) * 0.1f); } else { - this->unk_1BC = this->unk_1AC; + pthis->unk_1BC = pthis->unk_1AC; } } -void func_80A9F9B4(EnMThunder* this, GlobalContext* globalCtx) { +void func_80A9F9B4(EnMThunder* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (Math_StepToF(&this->unk_1AC, 0.0f, 1 / 16.0f)) { - Actor_Kill(&this->actor); + if (Math_StepToF(&pthis->unk_1AC, 0.0f, 1 / 16.0f)) { + Actor_Kill(&pthis->actor); } else { - Math_SmoothStepToF(&this->actor.scale.x, (s32)this->unk_1C9, 0.6f, 0.8f, 0.0f); - Actor_SetScale(&this->actor, this->actor.scale.x); - this->collider.dim.radius = (this->actor.scale.x * 25.0f); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Math_SmoothStepToF(&pthis->actor.scale.x, (s32)pthis->unk_1C9, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + pthis->collider.dim.radius = (pthis->actor.scale.x * 25.0f); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - if (this->unk_1C4 > 0) { - this->actor.world.pos.x = player->bodyPartsPos[0].x; - this->actor.world.pos.z = player->bodyPartsPos[0].z; - this->unk_1C4--; + if (pthis->unk_1C4 > 0) { + pthis->actor.world.pos.x = player->bodyPartsPos[0].x; + pthis->actor.world.pos.z = player->bodyPartsPos[0].z; + pthis->unk_1C4--; } - if (this->unk_1AC > 0.6f) { - this->unk_1B0 = 1.0f; + if (pthis->unk_1AC > 0.6f) { + pthis->unk_1B0 = 1.0f; } else { - this->unk_1B0 = this->unk_1AC * (5.0f / 3.0f); + pthis->unk_1B0 = pthis->unk_1AC * (5.0f / 3.0f); } - func_80A9F938(this, globalCtx); + func_80A9F938(pthis, globalCtx); if (Gameplay_InCsMode(globalCtx)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void EnMThunder_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMThunder* this = (EnMThunder*)thisx; + EnMThunder* pthis = (EnMThunder*)thisx; f32 blueRadius; s32 redGreen; - this->actionFunc(this, globalCtx); - func_80A9F314(globalCtx, this->unk_1BC); - blueRadius = this->unk_1AC; + pthis->actionFunc(pthis, globalCtx); + func_80A9F314(globalCtx, pthis->unk_1BC); + blueRadius = pthis->unk_1AC; redGreen = (u32)(blueRadius * 255.0f) & 0xFF; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, redGreen, redGreen, (u32)(blueRadius * 100.0f), + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, redGreen, redGreen, (u32)(blueRadius * 100.0f), (s32)(blueRadius * 800.0f)); } void EnMThunder_Draw(Actor* thisx, GlobalContext* globalCtx2) { static f32 D_80AA046C[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f }; GlobalContext* globalCtx = globalCtx2; - EnMThunder* this = (EnMThunder*)thisx; + EnMThunder* pthis = (EnMThunder*)thisx; Player* player = GET_PLAYER(globalCtx); f32 phi_f14; s32 phi_t1; @@ -343,23 +343,23 @@ void EnMThunder_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_m_thunder.c", 853), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - switch (this->unk_1C6) { + switch (pthis->unk_1C6) { case 0: case 1: gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0xFF - ((u8)(s32)(this->unk_1B4 * 30) & 0xFF), 0, - 0x40, 0x20, 1, 0xFF - ((u8)(s32)(this->unk_1B4 * 20) & 0xFF), 0, 8, 8)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0xFF - ((u8)(s32)(pthis->unk_1B4 * 30) & 0xFF), 0, + 0x40, 0x20, 1, 0xFF - ((u8)(s32)(pthis->unk_1B4 * 20) & 0xFF), 0, 8, 8)); break; } - switch (this->unk_1C6) { + switch (pthis->unk_1C6) { case 0: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u8)(this->unk_1B0 * 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u8)(pthis->unk_1B0 * 255)); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack3DL); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack4DL); break; case 1: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(this->unk_1B0 * 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(pthis->unk_1B0 * 255)); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack1DL); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack2DL); break; @@ -367,7 +367,7 @@ void EnMThunder_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); - switch (this->unk_1C7) { + switch (pthis->unk_1C7) { case 1: Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(-0.7f, -0.6f, -0.4f, MTXMODE_APPLY); @@ -385,14 +385,14 @@ void EnMThunder_Draw(Actor* thisx, GlobalContext* globalCtx2) { break; } - if (this->unk_1B8 >= 0.85f) { + if (pthis->unk_1B8 >= 0.85f) { phi_f14 = (D_80AA046C[(globalCtx->gameplayFrames & 7)] * 6.0f) + 1.0f; - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->unk_1C8); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, pthis->unk_1C8); gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); phi_t1 = 0x28; } else { phi_f14 = (D_80AA046C[globalCtx->gameplayFrames & 7] * 2.0f) + 1.0f; - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, this->unk_1C8); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, pthis->unk_1C8); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); phi_t1 = 0x14; } diff --git a/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c b/src/overlays/actors/ovl_En_Ma1/z_en_ma1.cpp similarity index 60% rename from src/overlays/actors/ovl_En_Ma1/z_en_ma1.c rename to src/overlays/actors/ovl_En_Ma1/z_en_ma1.cpp index 2b8d2f58c..24622fd70 100644 --- a/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c +++ b/src/overlays/actors/ovl_En_Ma1/z_en_ma1.cpp @@ -27,19 +27,19 @@ void EnMa1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMa1_Update(Actor* thisx, GlobalContext* globalCtx); void EnMa1_Draw(Actor* thisx, GlobalContext* globalCtx); -u16 EnMa1_GetText(GlobalContext* globalCtx, Actor* this); -s16 func_80AA0778(GlobalContext* globalCtx, Actor* this); +u16 EnMa1_GetText(GlobalContext* globalCtx, Actor* pthis); +s16 func_80AA0778(GlobalContext* globalCtx, Actor* pthis); -void func_80AA0D88(EnMa1* this, GlobalContext* globalCtx); -void func_80AA0EA0(EnMa1* this, GlobalContext* globalCtx); -void func_80AA0EFC(EnMa1* this, GlobalContext* globalCtx); -void func_80AA0F44(EnMa1* this, GlobalContext* globalCtx); -void func_80AA106C(EnMa1* this, GlobalContext* globalCtx); -void func_80AA10EC(EnMa1* this, GlobalContext* globalCtx); -void func_80AA1150(EnMa1* this, GlobalContext* globalCtx); -void EnMa1_DoNothing(EnMa1* this, GlobalContext* globalCtx); +void func_80AA0D88(EnMa1* pthis, GlobalContext* globalCtx); +void func_80AA0EA0(EnMa1* pthis, GlobalContext* globalCtx); +void func_80AA0EFC(EnMa1* pthis, GlobalContext* globalCtx); +void func_80AA0F44(EnMa1* pthis, GlobalContext* globalCtx); +void func_80AA106C(EnMa1* pthis, GlobalContext* globalCtx); +void func_80AA10EC(EnMa1* pthis, GlobalContext* globalCtx); +void func_80AA1150(EnMa1* pthis, GlobalContext* globalCtx); +void EnMa1_DoNothing(EnMa1* pthis, GlobalContext* globalCtx); -const ActorInit En_Ma1_InitVars = { +ActorInit En_Ma1_InitVars = { ACTOR_EN_MA1, ACTORCAT_NPC, FLAGS, @@ -186,8 +186,8 @@ s16 func_80AA0778(GlobalContext* globalCtx, Actor* thisx) { return ret; } -s32 func_80AA08C4(EnMa1* this, GlobalContext* globalCtx) { - if ((this->actor.shape.rot.z == 3) && (gSaveContext.sceneSetupIndex == 5)) { +s32 func_80AA08C4(EnMa1* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.shape.rot.z == 3) && (gSaveContext.sceneSetupIndex == 5)) { return 1; } if (!LINK_IS_CHILD) { @@ -211,55 +211,55 @@ s32 func_80AA08C4(EnMa1* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum != SCENE_SPOT20) { return 0; } - if ((this->actor.shape.rot.z == 3) && IS_DAY && (gSaveContext.eventChkInf[1] & 0x10)) { + if ((pthis->actor.shape.rot.z == 3) && IS_DAY && (gSaveContext.eventChkInf[1] & 0x10)) { return 1; } return 0; } -void EnMa1_UpdateEyes(EnMa1* this) { - if (DECR(this->blinkTimer) == 0) { - this->eyeIndex += 1; - if (this->eyeIndex >= 3) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeIndex = 0; +void EnMa1_UpdateEyes(EnMa1* pthis) { + if (DECR(pthis->blinkTimer) == 0) { + pthis->eyeIndex += 1; + if (pthis->eyeIndex >= 3) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeIndex = 0; } } } -void EnMa1_ChangeAnimation(EnMa1* this, UNK_TYPE idx) { +void EnMa1_ChangeAnimation(EnMa1* pthis, UNK_TYPE idx) { f32 frameCount = Animation_GetLastFrame(sAnimationInfo[idx].animation); - Animation_Change(&this->skelAnime, sAnimationInfo[idx].animation, 1.0f, 0.0f, frameCount, sAnimationInfo[idx].mode, + Animation_Change(&pthis->skelAnime, sAnimationInfo[idx].animation, 1.0f, 0.0f, frameCount, sAnimationInfo[idx].mode, sAnimationInfo[idx].transitionRate); } -void func_80AA0AF4(EnMa1* this, GlobalContext* globalCtx) { +void func_80AA0AF4(EnMa1* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 phi_a3; - if ((this->unk_1E8.unk_00 == 0) && (this->skelAnime.animation == &gMalonChildSingAnim)) { + if ((pthis->unk_1E8.unk_00 == 0) && (pthis->skelAnime.animation == &gMalonChildSingAnim)) { phi_a3 = 1; } else { phi_a3 = 0; } - this->unk_1E8.unk_18 = player->actor.world.pos; - this->unk_1E8.unk_18.y -= -10.0f; + pthis->unk_1E8.unk_18 = player->actor.world.pos; + pthis->unk_1E8.unk_18.y -= -10.0f; - func_80034A14(&this->actor, &this->unk_1E8, 0, phi_a3); + func_80034A14(&pthis->actor, &pthis->unk_1E8, 0, phi_a3); } -void func_80AA0B74(EnMa1* this) { - if (this->skelAnime.animation == &gMalonChildSingAnim) { - if (this->unk_1E8.unk_00 == 0) { - if (this->unk_1E0 != 0) { - this->unk_1E0 = 0; +void func_80AA0B74(EnMa1* pthis) { + if (pthis->skelAnime.animation == &gMalonChildSingAnim) { + if (pthis->unk_1E8.unk_00 == 0) { + if (pthis->unk_1E0 != 0) { + pthis->unk_1E0 = 0; func_800F6584(0); } } else { - if (this->unk_1E0 == 0) { - this->unk_1E0 = 1; + if (pthis->unk_1E0 == 0) { + pthis->unk_1E0 = 1; func_800F6584(1); } } @@ -267,160 +267,160 @@ void func_80AA0B74(EnMa1* this) { } void EnMa1_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMa1* this = (EnMa1*)thisx; + EnMa1* pthis = (EnMa1*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMalonChildSkel, NULL, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(22), &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gMalonChildSkel, NULL, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(22), &sColChkInfoInit); - if (!func_80AA08C4(this, globalCtx)) { - Actor_Kill(&this->actor); + if (!func_80AA08C4(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); return; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->unk_1E8.unk_00 = 0; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->unk_1E8.unk_00 = 0; if (!(gSaveContext.eventChkInf[1] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - this->actionFunc = func_80AA0D88; - EnMa1_ChangeAnimation(this, 2); + pthis->actionFunc = func_80AA0D88; + EnMa1_ChangeAnimation(pthis, 2); } else { - this->actionFunc = func_80AA0F44; - EnMa1_ChangeAnimation(this, 2); + pthis->actionFunc = func_80AA0F44; + EnMa1_ChangeAnimation(pthis, 2); } } void EnMa1_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMa1* this = (EnMa1*)thisx; + EnMa1* pthis = (EnMa1*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_80AA0D88(EnMa1* this, GlobalContext* globalCtx) { - if (this->unk_1E8.unk_00 != 0) { - if (this->skelAnime.animation != &gMalonChildIdleAnim) { - EnMa1_ChangeAnimation(this, 1); +void func_80AA0D88(EnMa1* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E8.unk_00 != 0) { + if (pthis->skelAnime.animation != &gMalonChildIdleAnim) { + EnMa1_ChangeAnimation(pthis, 1); } } else { - if (this->skelAnime.animation != &gMalonChildSingAnim) { - EnMa1_ChangeAnimation(this, 3); + if (pthis->skelAnime.animation != &gMalonChildSingAnim) { + EnMa1_ChangeAnimation(pthis, 3); } } if ((globalCtx->sceneNum == SCENE_SPOT15) && (gSaveContext.eventChkInf[1] & 0x10)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else if (!(gSaveContext.eventChkInf[1] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - if (this->unk_1E8.unk_00 == 2) { - this->actionFunc = func_80AA0EA0; + if (pthis->unk_1E8.unk_00 == 2) { + pthis->actionFunc = func_80AA0EA0; globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } } } -void func_80AA0EA0(EnMa1* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_80AA0EFC; +void func_80AA0EA0(EnMa1* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_80AA0EFC; } else { - func_8002F434(&this->actor, globalCtx, GI_WEIRD_EGG, 120.0f, 10.0f); + func_8002F434(&pthis->actor, globalCtx, GI_WEIRD_EGG, 120.0f, 10.0f); } } -void func_80AA0EFC(EnMa1* this, GlobalContext* globalCtx) { - if (this->unk_1E8.unk_00 == 3) { - this->unk_1E8.unk_00 = 0; - this->actionFunc = func_80AA0D88; +void func_80AA0EFC(EnMa1* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E8.unk_00 == 3) { + pthis->unk_1E8.unk_00 = 0; + pthis->actionFunc = func_80AA0D88; gSaveContext.eventChkInf[1] |= 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } } -void func_80AA0F44(EnMa1* this, GlobalContext* globalCtx) { +void func_80AA0F44(EnMa1* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->unk_1E8.unk_00 != 0) { - if (this->skelAnime.animation != &gMalonChildIdleAnim) { - EnMa1_ChangeAnimation(this, 1); + if (pthis->unk_1E8.unk_00 != 0) { + if (pthis->skelAnime.animation != &gMalonChildIdleAnim) { + EnMa1_ChangeAnimation(pthis, 1); } } else { - if (this->skelAnime.animation != &gMalonChildSingAnim) { - EnMa1_ChangeAnimation(this, 3); + if (pthis->skelAnime.animation != &gMalonChildSingAnim) { + EnMa1_ChangeAnimation(pthis, 3); } } if (gSaveContext.eventChkInf[1] & 0x40) { if (player->stateFlags2 & 0x1000000) { player->stateFlags2 |= 0x2000000; - player->unk_6A8 = &this->actor; - this->actor.textId = 0x2061; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_1E8.unk_00 = 1; - this->actor.flags |= ACTOR_FLAG_16; - this->actionFunc = func_80AA106C; - } else if (this->actor.xzDistToPlayer < 30.0f + (f32)this->collider.dim.radius) { + player->unk_6A8 = &pthis->actor; + pthis->actor.textId = 0x2061; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_1E8.unk_00 = 1; + pthis->actor.flags |= ACTOR_FLAG_16; + pthis->actionFunc = func_80AA106C; + } else if (pthis->actor.xzDistToPlayer < 30.0f + (f32)pthis->collider.dim.radius) { player->stateFlags2 |= 0x800000; } } } -void func_80AA106C(EnMa1* this, GlobalContext* globalCtx) { +void func_80AA106C(EnMa1* pthis, GlobalContext* globalCtx) { GET_PLAYER(globalCtx)->stateFlags2 |= 0x800000; - if (this->unk_1E8.unk_00 == 2) { + if (pthis->unk_1E8.unk_00 == 2) { Audio_OcaSetInstrument(2); func_8010BD58(globalCtx, OCARINA_ACTION_TEACH_EPONA); - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = func_80AA10EC; + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = func_80AA10EC; } } -void func_80AA10EC(EnMa1* this, GlobalContext* globalCtx) { +void func_80AA10EC(EnMa1* pthis, GlobalContext* globalCtx) { GET_PLAYER(globalCtx)->stateFlags2 |= 0x800000; if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_SONG_DEMO_DONE) { func_8010BD58(globalCtx, OCARINA_ACTION_PLAYBACK_EPONA); - this->actionFunc = func_80AA1150; + pthis->actionFunc = func_80AA1150; } } -void func_80AA1150(EnMa1* this, GlobalContext* globalCtx) { +void func_80AA1150(EnMa1* pthis, GlobalContext* globalCtx) { GET_PLAYER(globalCtx)->stateFlags2 |= 0x800000; if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { globalCtx->nextEntranceIndex = 0x157; gSaveContext.nextCutsceneIndex = 0xFFF1; globalCtx->fadeTransition = 42; globalCtx->sceneLoadFlag = 0x14; - this->actionFunc = EnMa1_DoNothing; + pthis->actionFunc = EnMa1_DoNothing; } } -void EnMa1_DoNothing(EnMa1* this, GlobalContext* globalCtx) { +void EnMa1_DoNothing(EnMa1* pthis, GlobalContext* globalCtx) { } void EnMa1_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMa1* this = (EnMa1*)thisx; + EnMa1* pthis = (EnMa1*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - EnMa1_UpdateEyes(this); - this->actionFunc(this, globalCtx); - if (this->actionFunc != EnMa1_DoNothing) { - func_800343CC(globalCtx, &this->actor, &this->unk_1E8.unk_00, (f32)this->collider.dim.radius + 30.0f, + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + EnMa1_UpdateEyes(pthis); + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc != EnMa1_DoNothing) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E8.unk_00, (f32)pthis->collider.dim.radius + 30.0f, EnMa1_GetText, func_80AA0778); } - func_80AA0B74(this); - func_80AA0AF4(this, globalCtx); + func_80AA0B74(pthis); + func_80AA0AF4(pthis, globalCtx); } s32 EnMa1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMa1* this = (EnMa1*)thisx; + EnMa1* pthis = (EnMa1*)thisx; Vec3s vec; if ((limbIndex == 2) || (limbIndex == 5)) { @@ -428,13 +428,13 @@ s32 EnMa1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 15) { Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec = this->unk_1E8.unk_08; + vec = pthis->unk_1E8.unk_08; Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - vec = this->unk_1E8.unk_0E; + vec = pthis->unk_1E8.unk_0E; Matrix_RotateX((-vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((-vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); } @@ -442,16 +442,16 @@ s32 EnMa1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnMa1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnMa1* this = (EnMa1*)thisx; + EnMa1* pthis = (EnMa1*)thisx; Vec3f vec = D_80AA16B8; if (limbIndex == 15) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); } } void EnMa1_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnMa1* this = (EnMa1*)thisx; + EnMa1* pthis = (EnMa1*)thisx; Camera* camera; f32 distFromCamera; s32 pad; @@ -459,15 +459,15 @@ void EnMa1_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ma1.c", 1226); camera = GET_ACTIVE_CAM(globalCtx); - distFromCamera = Math_Vec3f_DistXZ(&this->actor.world.pos, &camera->eye); + distFromCamera = Math_Vec3f_DistXZ(&pthis->actor.world.pos, &camera->eye); func_800F6268(distFromCamera, NA_BGM_LONLON); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthIndex])); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[pthis->mouthIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMa1_OverrideLimbDraw, EnMa1_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMa1_OverrideLimbDraw, EnMa1_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ma1.c", 1261); } diff --git a/src/overlays/actors/ovl_En_Ma2/z_en_ma2.c b/src/overlays/actors/ovl_En_Ma2/z_en_ma2.cpp similarity index 59% rename from src/overlays/actors/ovl_En_Ma2/z_en_ma2.c rename to src/overlays/actors/ovl_En_Ma2/z_en_ma2.cpp index 77c3fe0be..54f610a24 100644 --- a/src/overlays/actors/ovl_En_Ma2/z_en_ma2.c +++ b/src/overlays/actors/ovl_En_Ma2/z_en_ma2.cpp @@ -22,19 +22,19 @@ void EnMa2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMa2_Update(Actor* thisx, GlobalContext* globalCtx); void EnMa2_Draw(Actor* thisx, GlobalContext* globalCtx); -u16 func_80AA19A0(GlobalContext* globalCtx, Actor* this); -s16 func_80AA1A38(GlobalContext* globalCtx, Actor* this); +u16 func_80AA19A0(GlobalContext* globalCtx, Actor* pthis); +s16 func_80AA1A38(GlobalContext* globalCtx, Actor* pthis); -void func_80AA1AE4(EnMa2* this, GlobalContext* globalCtx); -s32 func_80AA1C68(EnMa2* this); -void EnMa2_UpdateEyes(EnMa2* this); -void func_80AA1DB4(EnMa2* this, GlobalContext* globalCtx); -void func_80AA2018(EnMa2* this, GlobalContext* globalCtx); -void func_80AA204C(EnMa2* this, GlobalContext* globalCtx); -void func_80AA20E4(EnMa2* this, GlobalContext* globalCtx); -void func_80AA21C8(EnMa2* this, GlobalContext* globalCtx); +void func_80AA1AE4(EnMa2* pthis, GlobalContext* globalCtx); +s32 func_80AA1C68(EnMa2* pthis); +void EnMa2_UpdateEyes(EnMa2* pthis); +void func_80AA1DB4(EnMa2* pthis, GlobalContext* globalCtx); +void func_80AA2018(EnMa2* pthis, GlobalContext* globalCtx); +void func_80AA204C(EnMa2* pthis, GlobalContext* globalCtx); +void func_80AA20E4(EnMa2* pthis, GlobalContext* globalCtx); +void func_80AA21C8(EnMa2* pthis, GlobalContext* globalCtx); -const ActorInit En_Ma2_InitVars = { +ActorInit En_Ma2_InitVars = { ACTOR_EN_MA2, ACTORCAT_NPC, FLAGS, @@ -127,211 +127,211 @@ s16 func_80AA1A38(GlobalContext* globalCtx, Actor* thisx) { return ret; } -void func_80AA1AE4(EnMa2* this, GlobalContext* globalCtx) { +void func_80AA1AE4(EnMa2* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 phi_a3; - if ((this->unk_1E0.unk_00 == 0) && (this->skelAnime.animation == &gMalonAdultSingAnim)) { + if ((pthis->unk_1E0.unk_00 == 0) && (pthis->skelAnime.animation == &gMalonAdultSingAnim)) { phi_a3 = 1; } else { phi_a3 = 0; } - this->unk_1E0.unk_18 = player->actor.world.pos; - this->unk_1E0.unk_14 = 0.0f; + pthis->unk_1E0.unk_18 = player->actor.world.pos; + pthis->unk_1E0.unk_14 = 0.0f; - func_80034A14(&this->actor, &this->unk_1E0, 0, phi_a3); + func_80034A14(&pthis->actor, &pthis->unk_1E0, 0, phi_a3); } -u16 func_80AA1B58(EnMa2* this, GlobalContext* globalCtx) { +u16 func_80AA1B58(EnMa2* pthis, GlobalContext* globalCtx) { if (LINK_IS_CHILD) { return 0; } if (!(gSaveContext.eventChkInf[1] & 0x100) && (globalCtx->sceneNum == SCENE_MALON_STABLE) && IS_DAY && - (this->actor.shape.rot.z == 5)) { + (pthis->actor.shape.rot.z == 5)) { return 1; } if (!(gSaveContext.eventChkInf[1] & 0x100) && (globalCtx->sceneNum == SCENE_SPOT20) && IS_NIGHT && - (this->actor.shape.rot.z == 6)) { + (pthis->actor.shape.rot.z == 6)) { return 2; } if (!(gSaveContext.eventChkInf[1] & 0x100) || (globalCtx->sceneNum != SCENE_SPOT20)) { return 0; } - if ((this->actor.shape.rot.z == 7) && IS_DAY) { + if ((pthis->actor.shape.rot.z == 7) && IS_DAY) { return 3; } - if ((this->actor.shape.rot.z == 8) && IS_NIGHT) { + if ((pthis->actor.shape.rot.z == 8) && IS_NIGHT) { return 3; } return 0; } -s32 func_80AA1C68(EnMa2* this) { - if (this->skelAnime.animation != &gMalonAdultSingAnim) { +s32 func_80AA1C68(EnMa2* pthis) { + if (pthis->skelAnime.animation != &gMalonAdultSingAnim) { return 0; } - if (this->unk_1E0.unk_00 != 0) { + if (pthis->unk_1E0.unk_00 != 0) { return 0; } - this->blinkTimer = 0; - if (this->eyeIndex != 2) { + pthis->blinkTimer = 0; + if (pthis->eyeIndex != 2) { return 0; } - this->mouthIndex = 2; + pthis->mouthIndex = 2; return 1; } -void EnMa2_UpdateEyes(EnMa2* this) { - if ((!func_80AA1C68(this)) && (DECR(this->blinkTimer) == 0)) { - this->eyeIndex += 1; - if (this->eyeIndex >= 3) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeIndex = 0; +void EnMa2_UpdateEyes(EnMa2* pthis) { + if ((!func_80AA1C68(pthis)) && (DECR(pthis->blinkTimer) == 0)) { + pthis->eyeIndex += 1; + if (pthis->eyeIndex >= 3) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeIndex = 0; } } } -void EnMa2_ChangeAnim(EnMa2* this, s32 idx) { +void EnMa2_ChangeAnim(EnMa2* pthis, s32 idx) { f32 frameCount = Animation_GetLastFrame(sAnimationInfo[idx].animation); - Animation_Change(&this->skelAnime, sAnimationInfo[idx].animation, 1.0f, 0.0f, frameCount, sAnimationInfo[idx].mode, + Animation_Change(&pthis->skelAnime, sAnimationInfo[idx].animation, 1.0f, 0.0f, frameCount, sAnimationInfo[idx].mode, sAnimationInfo[idx].transitionRate); } -void func_80AA1DB4(EnMa2* this, GlobalContext* globalCtx) { - if (this->skelAnime.animation == &gMalonAdultSingAnim) { - if (this->unk_1E0.unk_00 == 0) { - if (this->unk_20A != 0) { +void func_80AA1DB4(EnMa2* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.animation == &gMalonAdultSingAnim) { + if (pthis->unk_1E0.unk_00 == 0) { + if (pthis->unk_20A != 0) { func_800F6584(0); - this->unk_20A = 0; + pthis->unk_20A = 0; } } else { - if (this->unk_20A == 0) { + if (pthis->unk_20A == 0) { func_800F6584(1); - this->unk_20A = 1; + pthis->unk_20A = 1; } } } } void EnMa2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMa2* this = (EnMa2*)thisx; + EnMa2* pthis = (EnMa2*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMalonAdultSkel, NULL, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(22), &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gMalonAdultSkel, NULL, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(22), &sColChkInfoInit); - switch (func_80AA1B58(this, globalCtx)) { + switch (func_80AA1B58(pthis, globalCtx)) { case 1: - EnMa2_ChangeAnim(this, 2); - this->actionFunc = func_80AA2018; + EnMa2_ChangeAnim(pthis, 2); + pthis->actionFunc = func_80AA2018; break; case 2: - EnMa2_ChangeAnim(this, 3); - this->actionFunc = func_80AA204C; + EnMa2_ChangeAnim(pthis, 3); + pthis->actionFunc = func_80AA204C; break; case 3: if (gSaveContext.infTable[8] & 0x2000) { - EnMa2_ChangeAnim(this, 0); + EnMa2_ChangeAnim(pthis, 0); } else { - EnMa2_ChangeAnim(this, 3); + EnMa2_ChangeAnim(pthis, 3); } - this->actionFunc = func_80AA2018; + pthis->actionFunc = func_80AA2018; break; case 0: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->unk_1E0.unk_00 = 0; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->unk_1E0.unk_00 = 0; } void EnMa2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMa2* this = (EnMa2*)thisx; + EnMa2* pthis = (EnMa2*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_80AA2018(EnMa2* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 2) { - this->actor.flags &= ~ACTOR_FLAG_16; - this->unk_1E0.unk_00 = 0; +void func_80AA2018(EnMa2* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 2) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->unk_1E0.unk_00 = 0; } } -void func_80AA204C(EnMa2* this, GlobalContext* globalCtx) { +void func_80AA204C(EnMa2* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->stateFlags2 & 0x1000000) { - player->unk_6A8 = &this->actor; + player->unk_6A8 = &pthis->actor; player->stateFlags2 |= 0x2000000; func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_EPONA); - this->actionFunc = func_80AA20E4; - } else if (this->actor.xzDistToPlayer < 30.0f + (f32)this->collider.dim.radius) { + pthis->actionFunc = func_80AA20E4; + } else if (pthis->actor.xzDistToPlayer < 30.0f + (f32)pthis->collider.dim.radius) { player->stateFlags2 |= 0x800000; } } -void func_80AA20E4(EnMa2* this, GlobalContext* globalCtx) { +void func_80AA20E4(EnMa2* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_04) { - this->actionFunc = func_80AA204C; + pthis->actionFunc = func_80AA204C; globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_208 = 0x1E; + pthis->unk_208 = 0x1E; gSaveContext.infTable[8] |= 0x4000; - this->actionFunc = func_80AA21C8; + pthis->actionFunc = func_80AA21C8; globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } else { player->stateFlags2 |= 0x800000; } } -void func_80AA21C8(EnMa2* this, GlobalContext* globalCtx) { +void func_80AA21C8(EnMa2* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (DECR(this->unk_208)) { + if (DECR(pthis->unk_208)) { player->stateFlags2 |= 0x800000; } else { - if (this->unk_1E0.unk_00 == 0) { - this->actor.flags |= ACTOR_FLAG_16; + if (pthis->unk_1E0.unk_00 == 0) { + pthis->actor.flags |= ACTOR_FLAG_16; Message_CloseTextbox(globalCtx); } else { - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = func_80AA2018; + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = func_80AA2018; } } } void EnMa2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMa2* this = (EnMa2*)thisx; + EnMa2* pthis = (EnMa2*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - EnMa2_UpdateEyes(this); - this->actionFunc(this, globalCtx); - func_80AA1DB4(this, globalCtx); - func_80AA1AE4(this, globalCtx); - if (this->actionFunc != func_80AA20E4) { - func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, (f32)this->collider.dim.radius + 30.0f, + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + EnMa2_UpdateEyes(pthis); + pthis->actionFunc(pthis, globalCtx); + func_80AA1DB4(pthis, globalCtx); + func_80AA1AE4(pthis, globalCtx); + if (pthis->actionFunc != func_80AA20E4) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E0.unk_00, (f32)pthis->collider.dim.radius + 30.0f, func_80AA19A0, func_80AA1A38); } } s32 EnMa2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMa2* this = (EnMa2*)thisx; + EnMa2* pthis = (EnMa2*)thisx; Vec3s vec; if ((limbIndex == MALON_ADULT_LEFT_THIGH_LIMB) || (limbIndex == MALON_ADULT_RIGHT_THIGH_LIMB)) { @@ -339,34 +339,34 @@ s32 EnMa2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == MALON_ADULT_HEAD_LIMB) { Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec = this->unk_1E0.unk_08; + vec = pthis->unk_1E0.unk_08; Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == MALON_ADULT_CHEST_AND_NECK_LIMB) { - vec = this->unk_1E0.unk_0E; + vec = pthis->unk_1E0.unk_0E; Matrix_RotateY((-vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateX((-vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); } if ((limbIndex == MALON_ADULT_CHEST_AND_NECK_LIMB) || (limbIndex == MALON_ADULT_LEFT_SHOULDER_LIMB) || (limbIndex == MALON_ADULT_RIGHT_SHOULDER_LIMB)) { - rot->y += Math_SinS(this->unk_212[limbIndex].y) * 200.0f; - rot->z += Math_CosS(this->unk_212[limbIndex].z) * 200.0f; + rot->y += Math_SinS(pthis->unk_212[limbIndex].y) * 200.0f; + rot->z += Math_CosS(pthis->unk_212[limbIndex].z) * 200.0f; } return false; } void EnMa2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnMa2* this = (EnMa2*)thisx; + EnMa2* pthis = (EnMa2*)thisx; Vec3f vec = { 900.0f, 0.0f, 0.0f }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ma2.c", 904); if (limbIndex == MALON_ADULT_HEAD_LIMB) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); } - if ((limbIndex == MALON_ADULT_LEFT_HAND_LIMB) && (this->skelAnime.animation == &gMalonAdultStandStillAnim)) { + if ((limbIndex == MALON_ADULT_LEFT_HAND_LIMB) && (pthis->skelAnime.animation == &gMalonAdultStandStillAnim)) { gSPDisplayList(POLY_OPA_DISP++, gMalonAdultBasketDL); } @@ -377,7 +377,7 @@ void EnMa2_Draw(Actor* thisx, GlobalContext* globalCtx) { static void* sMouthTextures[] = { gMalonAdultMouthNeutralTex, gMalonAdultMouthSadTex, gMalonAdultMouthHappyTex }; static void* sEyeTextures[] = { gMalonAdultEyeOpenTex, gMalonAdultEyeHalfTex, gMalonAdultEyeClosedTex }; - EnMa2* this = (EnMa2*)thisx; + EnMa2* pthis = (EnMa2*)thisx; Camera* camera; f32 someFloat; s32 pad; @@ -385,15 +385,15 @@ void EnMa2_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ma2.c", 955); camera = GET_ACTIVE_CAM(globalCtx); - someFloat = Math_Vec3f_DistXZ(&this->actor.world.pos, &camera->eye); + someFloat = Math_Vec3f_DistXZ(&pthis->actor.world.pos, &camera->eye); func_800F6268(someFloat, NA_BGM_LONLON); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthIndex])); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[pthis->mouthIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMa2_OverrideLimbDraw, EnMa2_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMa2_OverrideLimbDraw, EnMa2_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ma2.c", 990); } diff --git a/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c b/src/overlays/actors/ovl_En_Ma3/z_en_ma3.cpp similarity index 68% rename from src/overlays/actors/ovl_En_Ma3/z_en_ma3.c rename to src/overlays/actors/ovl_En_Ma3/z_en_ma3.cpp index 29a79d25f..23144fd09 100644 --- a/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c +++ b/src/overlays/actors/ovl_En_Ma3/z_en_ma3.cpp @@ -26,17 +26,17 @@ void EnMa3_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMa3_Update(Actor* thisx, GlobalContext* globalCtx); void EnMa3_Draw(Actor* thisx, GlobalContext* globalCtx); -u16 func_80AA2AA0(GlobalContext* globalCtx, Actor* this); -s16 func_80AA2BD4(GlobalContext* globalCtx, Actor* this); +u16 func_80AA2AA0(GlobalContext* globalCtx, Actor* pthis); +s16 func_80AA2BD4(GlobalContext* globalCtx, Actor* pthis); -void func_80AA2E54(EnMa3* this, GlobalContext* globalCtx); -s32 func_80AA2EC8(EnMa3* this, GlobalContext* globalCtx); -s32 func_80AA2F28(EnMa3* this); -void EnMa3_UpdateEyes(EnMa3* this); -void EnMa3_ChangeAnim(EnMa3* this, s32 arg1); -void func_80AA3200(EnMa3* this, GlobalContext* globalCtx); +void func_80AA2E54(EnMa3* pthis, GlobalContext* globalCtx); +s32 func_80AA2EC8(EnMa3* pthis, GlobalContext* globalCtx); +s32 func_80AA2F28(EnMa3* pthis); +void EnMa3_UpdateEyes(EnMa3* pthis); +void EnMa3_ChangeAnim(EnMa3* pthis, s32 arg1); +void func_80AA3200(EnMa3* pthis, GlobalContext* globalCtx); -const ActorInit En_Ma3_InitVars = { +ActorInit En_Ma3_InitVars = { ACTOR_EN_MA3, ACTORCAT_NPC, FLAGS, @@ -78,7 +78,7 @@ static struct_D_80AA1678 sAnimationInfo[] = { u16 func_80AA2AA0(GlobalContext* globalCtx, Actor* thisx) { Player* player = GET_PLAYER(globalCtx); - s16* timer1ValuePtr; // weirdness with this necessary to match + s16* timer1ValuePtr; // weirdness with pthis necessary to match if (!(gSaveContext.infTable[11] & 0x100)) { return 0x2000; @@ -183,22 +183,22 @@ s16 func_80AA2BD4(GlobalContext* globalCtx, Actor* thisx) { return ret; } -void func_80AA2E54(EnMa3* this, GlobalContext* globalCtx) { +void func_80AA2E54(EnMa3* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 phi_a3; - if ((this->unk_1E0.unk_00 == 0) && (this->skelAnime.animation == &gMalonAdultSingAnim)) { + if ((pthis->unk_1E0.unk_00 == 0) && (pthis->skelAnime.animation == &gMalonAdultSingAnim)) { phi_a3 = 1; } else { phi_a3 = 0; } - this->unk_1E0.unk_18 = player->actor.world.pos; - this->unk_1E0.unk_14 = 0.0f; - func_80034A14(&this->actor, &this->unk_1E0, 0, phi_a3); + pthis->unk_1E0.unk_18 = player->actor.world.pos; + pthis->unk_1E0.unk_14 = 0.0f; + func_80034A14(&pthis->actor, &pthis->unk_1E0, 0, phi_a3); } -s32 func_80AA2EC8(EnMa3* this, GlobalContext* globalCtx) { +s32 func_80AA2EC8(EnMa3* pthis, GlobalContext* globalCtx) { if (LINK_IS_CHILD) { return 2; } @@ -211,106 +211,106 @@ s32 func_80AA2EC8(EnMa3* this, GlobalContext* globalCtx) { return 0; } -s32 func_80AA2F28(EnMa3* this) { - if (this->skelAnime.animation != &gMalonAdultSingAnim) { +s32 func_80AA2F28(EnMa3* pthis) { + if (pthis->skelAnime.animation != &gMalonAdultSingAnim) { return 0; } - if (this->unk_1E0.unk_00 != 0) { + if (pthis->unk_1E0.unk_00 != 0) { return 0; } - this->blinkTimer = 0; - if (this->eyeIndex != 2) { + pthis->blinkTimer = 0; + if (pthis->eyeIndex != 2) { return 0; } - this->mouthIndex = 2; + pthis->mouthIndex = 2; return 1; } -void EnMa3_UpdateEyes(EnMa3* this) { - if ((!func_80AA2F28(this)) && (DECR(this->blinkTimer) == 0)) { - this->eyeIndex += 1; - if (this->eyeIndex >= 3) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeIndex = 0; +void EnMa3_UpdateEyes(EnMa3* pthis) { + if ((!func_80AA2F28(pthis)) && (DECR(pthis->blinkTimer) == 0)) { + pthis->eyeIndex += 1; + if (pthis->eyeIndex >= 3) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeIndex = 0; } } } -void EnMa3_ChangeAnim(EnMa3* this, s32 idx) { +void EnMa3_ChangeAnim(EnMa3* pthis, s32 idx) { f32 frameCount = Animation_GetLastFrame(sAnimationInfo[idx].animation); - Animation_Change(&this->skelAnime, sAnimationInfo[idx].animation, 1.0f, 0.0f, frameCount, sAnimationInfo[idx].mode, + Animation_Change(&pthis->skelAnime, sAnimationInfo[idx].animation, 1.0f, 0.0f, frameCount, sAnimationInfo[idx].mode, sAnimationInfo[idx].transitionRate); } void EnMa3_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMa3* this = (EnMa3*)thisx; + EnMa3* pthis = (EnMa3*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMalonAdultSkel, NULL, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(22), &sColChkInfoInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gMalonAdultSkel, NULL, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(22), &sColChkInfoInit); - switch (func_80AA2EC8(this, globalCtx)) { + switch (func_80AA2EC8(pthis, globalCtx)) { case 0: - EnMa3_ChangeAnim(this, 0); - this->actionFunc = func_80AA3200; + EnMa3_ChangeAnim(pthis, 0); + pthis->actionFunc = func_80AA3200; break; case 1: - EnMa3_ChangeAnim(this, 0); - this->actionFunc = func_80AA3200; + EnMa3_ChangeAnim(pthis, 0); + pthis->actionFunc = func_80AA3200; break; case 2: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Actor_SetScale(&this->actor, 0.01f); - this->unk_1E0.unk_00 = (u16)0; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->unk_1E0.unk_00 = (u16)0; } void EnMa3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMa3* this = (EnMa3*)thisx; + EnMa3* pthis = (EnMa3*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_80AA3200(EnMa3* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 2) { - this->actor.flags &= ~ACTOR_FLAG_16; - this->unk_1E0.unk_00 = 0; +void func_80AA3200(EnMa3* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 2) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->unk_1E0.unk_00 = 0; } } void EnMa3_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMa3* this = (EnMa3*)thisx; + EnMa3* pthis = (EnMa3*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - EnMa3_UpdateEyes(this); - this->actionFunc(this, globalCtx); - func_80AA2E54(this, globalCtx); - func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, (f32)this->collider.dim.radius + 150.0f, + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + EnMa3_UpdateEyes(pthis); + pthis->actionFunc(pthis, globalCtx); + func_80AA2E54(pthis, globalCtx); + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E0.unk_00, (f32)pthis->collider.dim.radius + 150.0f, func_80AA2AA0, func_80AA2BD4); - if (this->unk_1E0.unk_00 == 0) { - if (this->unk_20A != 0) { + if (pthis->unk_1E0.unk_00 == 0) { + if (pthis->unk_20A != 0) { func_800F6584(0); - this->unk_20A = 0; + pthis->unk_20A = 0; } - } else if (this->unk_20A == 0) { + } else if (pthis->unk_20A == 0) { func_800F6584(1); - this->unk_20A = 1; + pthis->unk_20A = 1; } } s32 EnMa3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMa3* this = (EnMa3*)thisx; + EnMa3* pthis = (EnMa3*)thisx; Vec3s vec; if ((limbIndex == MALON_ADULT_LIMB_LEFT_THIGH) || (limbIndex == MALON_ADULT_LIMB_RIGHT_THIGH)) { @@ -318,35 +318,35 @@ s32 EnMa3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == MALON_ADULT_LIMB_HEAD) { Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec = this->unk_1E0.unk_08; + vec = pthis->unk_1E0.unk_08; Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == MALON_ADULT_LIMB_CHEST_AND_NECK) { - vec = this->unk_1E0.unk_0E; + vec = pthis->unk_1E0.unk_0E; Matrix_RotateY((-vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateX((-vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); } if ((limbIndex == MALON_ADULT_LIMB_CHEST_AND_NECK) || (limbIndex == MALON_ADULT_LIMB_LEFT_SHOULDER) || (limbIndex == MALON_ADULT_LIMB_RIGHT_SHOULDER)) { - rot->y += Math_SinS(this->unk_212[limbIndex].y) * 200.0f; - rot->z += Math_CosS(this->unk_212[limbIndex].z) * 200.0f; + rot->y += Math_SinS(pthis->unk_212[limbIndex].y) * 200.0f; + rot->z += Math_CosS(pthis->unk_212[limbIndex].z) * 200.0f; } return false; } void EnMa3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnMa3* this = (EnMa3*)thisx; + EnMa3* pthis = (EnMa3*)thisx; Vec3f vec = { 900.0f, 0.0f, 0.0f }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ma3.c", 927); if (limbIndex == MALON_ADULT_LIMB_HEAD) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); } - if ((limbIndex == MALON_ADULT_LIMB_LEFT_HAND) && (this->skelAnime.animation == &gMalonAdultStandStillAnim)) { + if ((limbIndex == MALON_ADULT_LIMB_LEFT_HAND) && (pthis->skelAnime.animation == &gMalonAdultStandStillAnim)) { gSPDisplayList(POLY_OPA_DISP++, gMalonAdultBasketDL); } @@ -356,7 +356,7 @@ void EnMa3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnMa3_Draw(Actor* thisx, GlobalContext* globalCtx) { static void* sMouthTextures[] = { gMalonAdultMouthNeutralTex, gMalonAdultMouthSadTex, gMalonAdultMouthHappyTex }; static void* sEyeTextures[] = { gMalonAdultEyeOpenTex, gMalonAdultEyeHalfTex, gMalonAdultEyeClosedTex }; - EnMa3* this = (EnMa3*)thisx; + EnMa3* pthis = (EnMa3*)thisx; Camera* camera; f32 someFloat; s32 pad; @@ -364,15 +364,15 @@ void EnMa3_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ma3.c", 978); camera = GET_ACTIVE_CAM(globalCtx); - someFloat = Math_Vec3f_DistXZ(&this->actor.world.pos, &camera->eye); + someFloat = Math_Vec3f_DistXZ(&pthis->actor.world.pos, &camera->eye); func_800F6268(someFloat, NA_BGM_LONLON); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthIndex])); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[pthis->mouthIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMa3_OverrideLimbDraw, EnMa3_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMa3_OverrideLimbDraw, EnMa3_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ma3.c", 1013); } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.cpp similarity index 68% rename from src/overlays/actors/ovl_En_Mag/z_en_mag.c rename to src/overlays/actors/ovl_En_Mag/z_en_mag.cpp index a4028e847..a381017a5 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.cpp @@ -23,7 +23,7 @@ void EnMag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMag_Update(Actor* thisx, GlobalContext* globalCtx); void EnMag_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Mag_InitVars = { +ActorInit En_Mag_InitVars = { ACTOR_EN_MAG, ACTORCAT_PROP, FLAGS, @@ -38,7 +38,7 @@ const ActorInit En_Mag_InitVars = { static s16 sDelayTimer = 0; void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMag* this = (EnMag*)thisx; + EnMag* pthis = (EnMag*)thisx; YREG(1) = 63; YREG(3) = 80; @@ -54,57 +54,57 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { VREG(5) = 6; VREG(6) = 2; - this->copyrightAlphaStep = 6; - this->fadeOutAlphaStep = 10; + pthis->copyrightAlphaStep = 6; + pthis->fadeOutAlphaStep = 10; VREG(19) = 99; VREG(21) = 9; VREG(23) = 10; VREG(24) = 8; - this->effectScroll = 0; - this->unk_E30C = 0; + pthis->effectScroll = 0; + pthis->unk_E30C = 0; - this->effectPrimColor[0] = 0.0f; - this->effectPrimColor[1] = 100.0f; - this->effectPrimColor[2] = 170.0f; - this->effectEnvColor[0] = 0.0f; - this->effectEnvColor[1] = 100.0f; - this->effectEnvColor[2] = 0.0f; + pthis->effectPrimColor[0] = 0.0f; + pthis->effectPrimColor[1] = 100.0f; + pthis->effectPrimColor[2] = 170.0f; + pthis->effectEnvColor[0] = 0.0f; + pthis->effectEnvColor[1] = 100.0f; + pthis->effectEnvColor[2] = 0.0f; - this->effectFadeInTimer = 40; + pthis->effectFadeInTimer = 40; - this->effectFadeInState = this->effectPrimLodFrac = this->globalState = this->effectAlpha = this->mainAlpha = - this->subAlpha = this->copyrightAlpha = 0.0f; + pthis->effectFadeInState = pthis->effectPrimLodFrac = pthis->globalState = pthis->effectAlpha = pthis->mainAlpha = + pthis->subAlpha = pthis->copyrightAlpha = 0.0f; if (gSaveContext.unk_13E7 != 0) { - this->mainAlpha = 210; - this->subAlpha = 255; - this->copyrightAlpha = 255; + pthis->mainAlpha = 210; + pthis->subAlpha = 255; + pthis->copyrightAlpha = 255; - this->effectPrimLodFrac = 128.0f; - this->effectAlpha = 255.0f; + pthis->effectPrimLodFrac = 128.0f; + pthis->effectAlpha = 255.0f; - this->effectPrimColor[0] = 170; - this->effectPrimColor[1] = 255.0f; - this->effectPrimColor[2] = 255.0f; - this->effectEnvColor[0] = 200.0f; - this->effectEnvColor[1] = 255.0f; - this->effectEnvColor[2] = 0; + pthis->effectPrimColor[0] = 170; + pthis->effectPrimColor[1] = 255.0f; + pthis->effectPrimColor[2] = 255.0f; + pthis->effectEnvColor[0] = 200.0f; + pthis->effectEnvColor[1] = 255.0f; + pthis->effectEnvColor[2] = 0; gSaveContext.unk_13E7 = 0; - this->globalState = MAG_STATE_DISPLAY; + pthis->globalState = MAG_STATE_DISPLAY; sDelayTimer = 20; gSaveContext.fadeDuration = 1; gSaveContext.unk_1419 = 255; } - Font_LoadOrderedFont(&this->font); + Font_LoadOrderedFont(&pthis->font); - this->unk_E316 = 0; - this->unk_E318 = 0; - this->unk_E31C = 0; - this->unk_E320 = 0; + pthis->unk_E316 = 0; + pthis->unk_E318 = 0; + pthis->unk_E31C = 0; + pthis->unk_E320 = 0; } void EnMag_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -112,36 +112,36 @@ void EnMag_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; - EnMag* this = (EnMag*)thisx; + EnMag* pthis = (EnMag*)thisx; if (gSaveContext.fileNum != 0xFEDC) { - if (this->globalState < MAG_STATE_DISPLAY) { + if (pthis->globalState < MAG_STATE_DISPLAY) { if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) || CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) || CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->mainAlpha = 210; - this->subAlpha = 255; - this->copyrightAlpha = 255; + pthis->mainAlpha = 210; + pthis->subAlpha = 255; + pthis->copyrightAlpha = 255; - this->effectPrimLodFrac = 128.0f; - this->effectAlpha = 255.0f; + pthis->effectPrimLodFrac = 128.0f; + pthis->effectAlpha = 255.0f; - this->effectPrimColor[0] = 170; - this->effectPrimColor[1] = 255.0f; - this->effectPrimColor[2] = 255.0f; - this->effectEnvColor[0] = 200.0f; - this->effectEnvColor[1] = 255.0f; - this->effectEnvColor[2] = 0; + pthis->effectPrimColor[0] = 170; + pthis->effectPrimColor[1] = 255.0f; + pthis->effectPrimColor[2] = 255.0f; + pthis->effectEnvColor[0] = 200.0f; + pthis->effectEnvColor[1] = 255.0f; + pthis->effectEnvColor[2] = 0; - this->globalState = MAG_STATE_DISPLAY; + pthis->globalState = MAG_STATE_DISPLAY; sDelayTimer = 20; gSaveContext.fadeDuration = 1; gSaveContext.unk_1419 = 255; } - } else if (this->globalState >= MAG_STATE_DISPLAY) { + } else if (pthis->globalState >= MAG_STATE_DISPLAY) { if (sDelayTimer == 0) { if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) || CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) || @@ -158,9 +158,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->fadeTransition = 2; } - this->copyrightAlphaStep = 15; - this->fadeOutAlphaStep = 25; - this->globalState = MAG_STATE_FADE_OUT; + pthis->copyrightAlphaStep = 15; + pthis->fadeOutAlphaStep = 25; + pthis->globalState = MAG_STATE_FADE_OUT; } } else { sDelayTimer--; @@ -168,104 +168,104 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if (this->globalState == MAG_STATE_FADE_IN) { - if (this->effectFadeInState == 0) { - this->effectAlpha += 6.375f; - this->effectPrimLodFrac += 0.8f; + if (pthis->globalState == MAG_STATE_FADE_IN) { + if (pthis->effectFadeInState == 0) { + pthis->effectAlpha += 6.375f; + pthis->effectPrimLodFrac += 0.8f; - this->effectPrimColor[0] += 6.375f; - this->effectPrimColor[1] += 3.875f; - this->effectPrimColor[2] += 2.125f; - this->effectEnvColor[0] += 6.375f; - this->effectEnvColor[1] += 3.875f; + pthis->effectPrimColor[0] += 6.375f; + pthis->effectPrimColor[1] += 3.875f; + pthis->effectPrimColor[2] += 2.125f; + pthis->effectEnvColor[0] += 6.375f; + pthis->effectEnvColor[1] += 3.875f; - this->effectFadeInTimer--; + pthis->effectFadeInTimer--; - if (this->effectFadeInTimer == 0) { - this->effectPrimLodFrac = 32.0f; - this->effectAlpha = 255.0f; + if (pthis->effectFadeInTimer == 0) { + pthis->effectPrimLodFrac = 32.0f; + pthis->effectAlpha = 255.0f; - this->effectPrimColor[0] = 255.0f; - this->effectPrimColor[1] = 255.0f; - this->effectPrimColor[2] = 255.0f; - this->effectEnvColor[0] = 255.0f; - this->effectEnvColor[1] = 255.0f; + pthis->effectPrimColor[0] = 255.0f; + pthis->effectPrimColor[1] = 255.0f; + pthis->effectPrimColor[2] = 255.0f; + pthis->effectEnvColor[0] = 255.0f; + pthis->effectEnvColor[1] = 255.0f; - this->effectFadeInTimer = 40; - this->effectFadeInState = 1; + pthis->effectFadeInTimer = 40; + pthis->effectFadeInState = 1; } - } else if (this->effectFadeInState == 1) { - this->effectPrimColor[0] += -2.125f; - this->effectEnvColor[0] += -1.375f; + } else if (pthis->effectFadeInState == 1) { + pthis->effectPrimColor[0] += -2.125f; + pthis->effectEnvColor[0] += -1.375f; - this->effectPrimLodFrac += 2.4f; + pthis->effectPrimLodFrac += 2.4f; - this->effectFadeInTimer--; + pthis->effectFadeInTimer--; - if (this->effectFadeInTimer == 0) { - this->effectPrimLodFrac = 128.0f; + if (pthis->effectFadeInTimer == 0) { + pthis->effectPrimLodFrac = 128.0f; - this->effectPrimColor[0] = 170.0f; - this->effectEnvColor[0] = 200.0f; + pthis->effectPrimColor[0] = 170.0f; + pthis->effectEnvColor[0] = 200.0f; - this->effectFadeInTimer = 32; - this->effectFadeInState = 2; + pthis->effectFadeInTimer = 32; + pthis->effectFadeInState = 2; } } - if (this->effectAlpha > 160) { - this->mainAlpha += VREG(5); - if (this->mainAlpha >= 210.0f) { - this->mainAlpha = 210.0f; + if (pthis->effectAlpha > 160) { + pthis->mainAlpha += VREG(5); + if (pthis->mainAlpha >= 210.0f) { + pthis->mainAlpha = 210.0f; } - if (this->mainAlpha >= 210) { - this->subAlpha += VREG(6); - if (this->subAlpha >= 255.0f) { - this->subAlpha = 255.0f; + if (pthis->mainAlpha >= 210) { + pthis->subAlpha += VREG(6); + if (pthis->subAlpha >= 255.0f) { + pthis->subAlpha = 255.0f; } - if (this->subAlpha >= 200) { - this->copyrightAlpha += this->copyrightAlphaStep; - if (this->copyrightAlpha >= 255.0f) { - this->copyrightAlpha = 255.0f; - this->globalState = MAG_STATE_DISPLAY; + if (pthis->subAlpha >= 200) { + pthis->copyrightAlpha += pthis->copyrightAlphaStep; + if (pthis->copyrightAlpha >= 255.0f) { + pthis->copyrightAlpha = 255.0f; + pthis->globalState = MAG_STATE_DISPLAY; sDelayTimer = 20; } } } } - } else if (this->globalState == MAG_STATE_FADE_OUT) { - this->effectAlpha -= this->fadeOutAlphaStep; - if (this->effectAlpha < 0.0f) { - this->effectAlpha = 0.0f; + } else if (pthis->globalState == MAG_STATE_FADE_OUT) { + pthis->effectAlpha -= pthis->fadeOutAlphaStep; + if (pthis->effectAlpha < 0.0f) { + pthis->effectAlpha = 0.0f; } - this->mainAlpha -= this->fadeOutAlphaStep; - if (this->mainAlpha < 0.0f) { - this->mainAlpha = 0.0f; + pthis->mainAlpha -= pthis->fadeOutAlphaStep; + if (pthis->mainAlpha < 0.0f) { + pthis->mainAlpha = 0.0f; } - this->subAlpha -= this->fadeOutAlphaStep; - if (this->subAlpha < 0.0f) { - this->subAlpha = 0.0f; + pthis->subAlpha -= pthis->fadeOutAlphaStep; + if (pthis->subAlpha < 0.0f) { + pthis->subAlpha = 0.0f; } - this->copyrightAlpha -= this->copyrightAlphaStep; - if (this->copyrightAlpha < 0.0f) { - this->copyrightAlpha = 0.0f; - this->globalState = MAG_STATE_POST_DISPLAY; + pthis->copyrightAlpha -= pthis->copyrightAlphaStep; + if (pthis->copyrightAlpha < 0.0f) { + pthis->copyrightAlpha = 0.0f; + pthis->globalState = MAG_STATE_POST_DISPLAY; } } - if (this->globalState == MAG_STATE_INITIAL) { + if (pthis->globalState == MAG_STATE_INITIAL) { if (Flags_GetEnv(globalCtx, 3)) { - this->effectFadeInTimer = 40; - this->globalState = MAG_STATE_FADE_IN; + pthis->effectFadeInTimer = 40; + pthis->globalState = MAG_STATE_FADE_IN; } - } else if (this->globalState == MAG_STATE_DISPLAY) { + } else if (pthis->globalState == MAG_STATE_DISPLAY) { if (Flags_GetEnv(globalCtx, 4)) { - this->globalState = MAG_STATE_FADE_OUT; + pthis->globalState = MAG_STATE_FADE_OUT; } } } @@ -285,7 +285,7 @@ void EnMag_DrawTextureI8(Gfx** gfxp, void* texture, s16 texWidth, s16 texHeight, void EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, s16 effectWidth, s16 effectHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, - s16 rectHeight, u16 dsdx, u16 dtdy, u16 shifts, u16 shiftt, u16 flag, EnMag* this) { + s16 rectHeight, u16 dsdx, u16 dtdy, u16 shifts, u16 shiftt, u16 flag, EnMag* pthis) { Gfx* gfx = *gfxp; gDPLoadMultiBlock_4b(gfx++, maskTex, 0x0000, 0, G_IM_FMT_I, maskWidth, maskHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, @@ -295,7 +295,7 @@ void EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 ma gDPLoadMultiBlock(gfx++, effectTex, 0x0100, 1, G_IM_FMT_I, G_IM_SIZ_8b, effectWidth, effectHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, 5, shifts, shiftt); - gDPSetTileSize(gfx++, 1, 0, this->effectScroll & 0x7F, 0x7C, (this->effectScroll & 0x7F) + 0x7C); + gDPSetTileSize(gfx++, 1, 0, pthis->effectScroll & 0x7F, 0x7C, (pthis->effectScroll & 0x7F) + 0x7C); } gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, @@ -393,19 +393,19 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gTitleEffectMask10Tex, gTitleEffectMask11Tex, gTitleEffectMask12Tex, gTitleEffectMask20Tex, gTitleEffectMask21Tex, gTitleEffectMask22Tex, }; - EnMag* this = (EnMag*)thisx; - Font* font = &this->font; + EnMag* pthis = (EnMag*)thisx; + Font* font = &pthis->font; s32 pad; Gfx* gfx = *gfxp; u16 i, j, k; u16 rectLeft; u16 rectTop; - gSPSegment(gfx++, 0x06, gObjectTable[this->actor.objBankIndex].vromStart); + gSPSegment(gfx++, 0x06, gObjectTable[pthis->actor.objBankIndex].vromStart.get()); func_8009457C(&gfx); - this->effectScroll -= 2; + pthis->effectScroll -= 2; gDPSetCycleType(gfx++, G_CYC_2CYCLE); gDPSetAlphaCompare(gfx++, G_AC_THRESHOLD); @@ -413,23 +413,23 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetCombineLERP(gfx++, TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL1, 1, PRIM_LOD_FRAC, TEXEL0, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0); - gDPSetPrimColor(gfx++, 0, (s16)this->effectPrimLodFrac, (s16)this->effectPrimColor[0], - (s16)this->effectPrimColor[1], (s16)this->effectPrimColor[2], (s16)this->effectAlpha); - gDPSetEnvColor(gfx++, (s16)this->effectEnvColor[0], (s16)this->effectEnvColor[1], (s16)this->effectEnvColor[2], + gDPSetPrimColor(gfx++, 0, (s16)pthis->effectPrimLodFrac, (s16)pthis->effectPrimColor[0], + (s16)pthis->effectPrimColor[1], (s16)pthis->effectPrimColor[2], (s16)pthis->effectAlpha); + gDPSetEnvColor(gfx++, (s16)pthis->effectEnvColor[0], (s16)pthis->effectEnvColor[1], (s16)pthis->effectEnvColor[2], 255); - if ((s16)this->effectPrimLodFrac != 0) { + if ((s16)pthis->effectPrimLodFrac != 0) { for (k = 0, i = 0, rectTop = 0; i < 3; i++, rectTop += 64) { for (j = 0, rectLeft = 56; j < 3; j++, k++, rectLeft += 64) { EnMag_DrawEffectTextures(&gfx, effectMaskTextures[k], gTitleFlameEffectTex, 64, 64, 32, 32, rectLeft, - rectTop, 64, 64, 1024, 1024, 1, 1, k, this); + rectTop, 64, 64, 1024, 1024, 1, 1, k, pthis); } } } - gDPSetPrimColor(gfx++, 0, 0, 255, 255, 255, (s16)this->mainAlpha); + gDPSetPrimColor(gfx++, 0, 0, 255, 255, 255, (s16)pthis->mainAlpha); - if ((s16)this->mainAlpha != 0) { + if ((s16)pthis->mainAlpha != 0) { EnMag_DrawImageRGBA32(&gfx, 152, 100, (u8*)gTitleZeldaShieldLogoMQTex, 160, 160); } @@ -440,28 +440,28 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - if ((s16)this->mainAlpha < 100) { + if ((s16)pthis->mainAlpha < 100) { gDPSetRenderMode(gfx++, G_RM_CLD_SURF, G_RM_CLD_SURF2); } else { gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); } - gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, (s16)this->mainAlpha); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, (s16)pthis->mainAlpha); gDPSetEnvColor(gfx++, 0, 0, 100, 255); - if ((s16)this->mainAlpha != 0) { + if ((s16)pthis->mainAlpha != 0) { EnMag_DrawTextureI8(&gfx, gTitleTheLegendOfTextTex, 72, 8, 146, 73, 72, 8, 1024, 1024); EnMag_DrawTextureI8(&gfx, gTitleOcarinaOfTimeTMTextTex, 96, 8, 144, 127, 96, 8, 1024, 1024); gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, 100, 150, 255, (s16)this->mainAlpha); + gDPSetPrimColor(gfx++, 0, 0, 100, 150, 255, (s16)pthis->mainAlpha); gDPSetEnvColor(gfx++, 20, 80, 160, 255); EnMag_DrawTextureI8(&gfx, gTitleTheLegendOfTextTex, 72, 8, 145, 72, 72, 8, 1024, 1024); EnMag_DrawTextureI8(&gfx, gTitleOcarinaOfTimeTMTextTex, 96, 8, 143, 126, 96, 8, 1024, 1024); gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, 255, 255, 255, (s16)this->subAlpha); + gDPSetPrimColor(gfx++, 0, 0, 255, 255, 255, (s16)pthis->subAlpha); EnMag_DrawImageRGBA32(&gfx, 174, 145, (u8*)gTitleMasterQuestSubtitleTex, 128, 32); } @@ -471,10 +471,10 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetAlphaCompare(gfx++, G_AC_NONE); gDPSetCombineMode(gfx++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetPrimColor(gfx++, 0, 0, (s16)this->copyrightAlpha, (s16)this->copyrightAlpha, (s16)this->copyrightAlpha, - (s16)this->copyrightAlpha); + gDPSetPrimColor(gfx++, 0, 0, (s16)pthis->copyrightAlpha, (s16)pthis->copyrightAlpha, (s16)pthis->copyrightAlpha, + (s16)pthis->copyrightAlpha); - if ((s16)this->copyrightAlpha != 0) { + if ((s16)pthis->copyrightAlpha != 0) { gDPLoadTextureBlock(gfx++, gTitleCopyright19982003Tex, G_IM_FMT_IA, G_IM_SIZ_8b, 160, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -518,7 +518,7 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { rectLeft += VREG(23); } } - } else if (this->copyrightAlpha >= 200.0f) { + } else if (pthis->copyrightAlpha >= 200.0f) { // Draw "PRESS START" Text textAlpha = textFadeTimer * 10; if (textAlpha >= 255) { diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/src/overlays/actors/ovl_En_Mb/z_en_mb.c deleted file mode 100644 index e3ab3f7df..000000000 --- a/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ /dev/null @@ -1,1571 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MB_Z_EN_MB_C -#include "actor_common.h" -/* - * File: z_en_mb.c - * Overlay: ovl_En_Mb - * Description: Moblins - */ - -#include "z_en_mb.h" -#include "objects/object_mb/object_mb.h" -#include "def/code_800A9F30.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -/* - * This actor can have three behaviors: - * - "Spear Guard" (variable -1): uses a spear, walks around home point, charges player if too close - * - "Club" (variable 0): uses a club, stands still and smashes its club on the ground when the player approaches - * - "Spear Patrol" (variable 0xPP00 PP=pathId): uses a spear, patrols following a path, charges - */ - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -typedef enum { - /* -1 */ ENMB_TYPE_SPEAR_GUARD = -1, - /* 0 */ ENMB_TYPE_CLUB, - /* 1 */ ENMB_TYPE_SPEAR_PATROL -} EnMbType; - -#define ENMB_ATTACK_NONE 0 -#define ENMB_ATTACK_SPEAR 1 -#define ENMB_ATTACK_CLUB_RIGHT 1 -#define ENMB_ATTACK_CLUB_MIDDLE 2 -#define ENMB_ATTACK_CLUB_LEFT 3 - -/* Spear and Club moblins use a different skeleton but the limbs are organized the same */ -typedef enum { - /* 1 */ ENMB_LIMB_ROOT = 1, - /* 3 */ ENMB_LIMB_WAIST = 3, - /* 6 */ ENMB_LIMB_CHEST = 6, - /* 7 */ ENMB_LIMB_HEAD, - /* 9 */ ENMB_LIMB_LSHOULDER = 9, - /* 11 */ ENMB_LIMB_LFOREARM = 11, - /* 12 */ ENMB_LIMB_LHAND, - /* 14 */ ENMB_LIMB_RSHOULDER = 14, - /* 16 */ ENMB_LIMB_RFOREARM = 16, - /* 17 */ ENMB_LIMB_RHAND, - /* 20 */ ENMB_LIMB_LTHIGH = 20, - /* 21 */ ENMB_LIMB_LSHIN, - /* 22 */ ENMB_LIMB_LFOOT, - /* 25 */ ENMB_LIMB_RTHIGH = 25, - /* 26 */ ENMB_LIMB_RSHIN, - /* 27 */ ENMB_LIMB_RFOOT -} EnMbLimb; - -void EnMb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMb_Draw(Actor* thisx, GlobalContext* globalCtx); - -const ActorInit En_Mb_InitVars = { - ACTOR_EN_MB, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_MB, - sizeof(EnMb), - (ActorFunc)EnMb_Init, - (ActorFunc)EnMb_Destroy, - (ActorFunc)EnMb_Update, - (ActorFunc)EnMb_Draw, -}; - -void EnMb_SetupSpearPatrolTurnTowardsWaypoint(EnMb* this, GlobalContext* globalCtx); -void EnMb_SetupClubWaitPlayerNear(EnMb* this); -void EnMb_SpearGuardLookAround(EnMb* this, GlobalContext* globalCtx); -void EnMb_SetupSpearGuardLookAround(EnMb* this); -void EnMb_SetupSpearDamaged(EnMb* this); -void EnMb_SpearGuardWalk(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearGuardPrepareAndCharge(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearPatrolPrepareAndCharge(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearEndChargeQuick(EnMb* this, GlobalContext* globalCtx); -void EnMb_Stunned(EnMb* this, GlobalContext* globalCtx); -void EnMb_ClubDead(EnMb* this, GlobalContext* globalCtx); -void EnMb_ClubDamagedWhileKneeling(EnMb* this, GlobalContext* globalCtx); -void EnMb_ClubWaitPlayerNear(EnMb* this, GlobalContext* globalCtx); -void EnMb_ClubAttack(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearDead(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearDamaged(EnMb* this, GlobalContext* globalCtx); -void EnMb_SetupSpearDead(EnMb* this); -void EnMb_SpearPatrolTurnTowardsWaypoint(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearPatrolWalkTowardsWaypoint(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearPatrolEndCharge(EnMb* this, GlobalContext* globalCtx); -void EnMb_SpearPatrolImmediateCharge(EnMb* this, GlobalContext* globalCtx); -void EnMb_ClubWaitAfterAttack(EnMb* this, GlobalContext* globalCtx); -void EnMb_ClubDamaged(EnMb* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sHitboxInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderTrisElementInit sFrontShieldingTrisInit[2] = { - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, - { - { - ELEMTYPE_UNK2, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, - OCELEM_NONE, - }, - { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, - }, -}; - -static ColliderTrisInit sFrontShieldingInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 2, - sFrontShieldingTrisInit, -}; - -static ColliderQuadInit sAttackColliderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -typedef enum { - /* 0x0 */ ENMB_DMGEFF_IGNORE, - /* 0x1 */ ENMB_DMGEFF_STUN, - /* 0x5 */ ENMB_DMGEFF_FREEZE = 0x5, - /* 0x6 */ ENMB_DMGEFF_STUN_ICE, - /* 0xF */ ENMB_DMGEFF_DEFAULT = 0xF -} EnMbDamageEffect; - -static DamageTable sSpearMoblinDamageTable = { - /* Deku nut */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Deku stick */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Slingshot */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), - /* Explosive */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Boomerang */ DMG_ENTRY(0, ENMB_DMGEFF_STUN), - /* Normal arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Hammer swing */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Hookshot */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Kokiri sword */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), - /* Master sword */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Giant's Knife */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Fire arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Ice arrow */ DMG_ENTRY(4, ENMB_DMGEFF_STUN_ICE), - /* Light arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Unk arrow 1 */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Unk arrow 2 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Unk arrow 3 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Fire magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Ice magic */ DMG_ENTRY(3, ENMB_DMGEFF_STUN_ICE), - /* Light magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Shield */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Mirror Ray */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Kokiri spin */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), - /* Giant spin */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Master spin */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Kokiri jump */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Giant jump */ DMG_ENTRY(8, ENMB_DMGEFF_DEFAULT), - /* Master jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Unknown 1 */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Unblockable */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Hammer jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Unknown 2 */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), -}; - -static DamageTable sClubMoblinDamageTable = { - /* Deku nut */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Deku stick */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Slingshot */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Explosive */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Boomerang */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Normal arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Hammer swing */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Hookshot */ DMG_ENTRY(0, ENMB_DMGEFF_STUN), - /* Kokiri sword */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), - /* Master sword */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Giant's Knife */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Fire arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Ice arrow */ DMG_ENTRY(4, ENMB_DMGEFF_STUN_ICE), - /* Light arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Unk arrow 1 */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Unk arrow 2 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Unk arrow 3 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Fire magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Ice magic */ DMG_ENTRY(3, ENMB_DMGEFF_STUN_ICE), - /* Light magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Shield */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Mirror Ray */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Kokiri spin */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), - /* Giant spin */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Master spin */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Kokiri jump */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), - /* Giant jump */ DMG_ENTRY(8, ENMB_DMGEFF_DEFAULT), - /* Master jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Unknown 1 */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), - /* Unblockable */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), - /* Hammer jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), - /* Unknown 2 */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x4A, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 5300, ICHAIN_STOP), -}; - -void EnMb_SetupAction(EnMb* this, EnMbActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnMb_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMb* this = (EnMb*)thisx; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s16 relYawFromPlayer; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 46.0f); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.colChkInfo.damageTable = &sSpearMoblinDamageTable; - Collider_InitCylinder(globalCtx, &this->hitbox); - Collider_SetCylinder(globalCtx, &this->hitbox, &this->actor, &sHitboxInit); - Collider_InitTris(globalCtx, &this->frontShielding); - Collider_SetTris(globalCtx, &this->frontShielding, &this->actor, &sFrontShieldingInit, this->frontShieldingTris); - Collider_InitQuad(globalCtx, &this->attackCollider); - Collider_SetQuad(globalCtx, &this->attackCollider, &this->actor, &sAttackColliderInit); - - switch (this->actor.params) { - case ENMB_TYPE_SPEAR_GUARD: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEnMbSpearSkel, &gEnMbSpearStandStillAnim, - this->jointTable, this->morphTable, 28); - this->actor.colChkInfo.health = 2; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->maxHomeDist = 1000.0f; - this->playerDetectionRange = 1750.0f; - EnMb_SetupSpearGuardLookAround(this); - break; - case ENMB_TYPE_CLUB: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEnMbClubSkel, &gEnMbClubStandStillClubDownAnim, - this->jointTable, this->morphTable, 28); - - this->actor.colChkInfo.health = 6; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.colChkInfo.damageTable = &sClubMoblinDamageTable; - Actor_SetScale(&this->actor, 0.02f); - this->hitbox.dim.height = 170; - this->hitbox.dim.radius = 45; - this->actor.uncullZoneForward = 4000.0f; - this->actor.uncullZoneScale = 800.0f; - this->actor.uncullZoneDownward = 1800.0f; - this->playerDetectionRange = 710.0f; - this->attackCollider.info.toucher.dmgFlags = 0x20000000; - - relYawFromPlayer = - this->actor.world.rot.y - Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); - if (ABS(relYawFromPlayer) > 0x4000) { - this->actor.world.rot.y = thisx->world.rot.y + 0x8000; - this->actor.shape.rot.y = thisx->world.rot.y; - this->actor.world.pos.z = thisx->world.pos.z + 600.0f; - } - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.naviEnemyId += 1; - EnMb_SetupClubWaitPlayerNear(this); - break; - default: /* Spear Patrol */ - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEnMbSpearSkel, &gEnMbSpearStandStillAnim, - this->jointTable, this->morphTable, 28); - - Actor_SetScale(&this->actor, 0.014f); - this->path = (thisx->params & 0xFF00) >> 8; - this->actor.params = ENMB_TYPE_SPEAR_PATROL; - this->waypoint = 0; - this->actor.colChkInfo.health = 1; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->maxHomeDist = 350.0f; - this->playerDetectionRange = 1750.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - EnMb_SetupSpearPatrolTurnTowardsWaypoint(this, globalCtx); - break; - } -} - -void EnMb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMb* this = (EnMb*)thisx; - - Collider_DestroyTris(globalCtx, &this->frontShielding); - Collider_DestroyCylinder(globalCtx, &this->hitbox); - Collider_DestroyQuad(globalCtx, &this->attackCollider); -} - -void EnMb_FaceWaypoint(EnMb* this, GlobalContext* globalCtx) { - s16 yawToWaypoint = Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos); - - this->actor.shape.rot.y = yawToWaypoint; - this->actor.world.rot.y = yawToWaypoint; -} - -void EnMb_NextWaypoint(EnMb* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* waypointPos; - - path = &globalCtx->setupPathList[this->path]; - - if (this->waypoint == 0) { - this->direction = 1; - } else if (this->waypoint == (s8)(path->count - 1)) { - this->direction = -1; - } - - this->waypoint += this->direction; - waypointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; - this->waypointPos.x = waypointPos->x; - this->waypointPos.y = waypointPos->y; - this->waypointPos.z = waypointPos->z; -} - -/** - * Checks if the player is in a 800*74 units XZ area centered on this actor, - * the area being directed along its line of sight snapped to a cardinal angle. - * Note: the longest corridor in Sacred Forest Meadows is 800 units long, - * and they all are 100 units wide. - */ -s32 EnMb_IsPlayerInCorridor(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 xFromPlayer; - f32 zFromPlayer; - f32 cos; - f32 sin; - f32 xFromPlayerAbs; - f32 zFromPlayerAbs; - s16 alignedYaw = 0; - - if ((this->actor.world.rot.y < -0x62A2) || (this->actor.world.rot.y > 0x62A2)) { - alignedYaw = -0x8000; - } else if (this->actor.world.rot.y < -0x20E0) { - alignedYaw = -0x4000; - } else if (this->actor.world.rot.y > 0x20E0) { - alignedYaw = 0x4000; - } - - cos = Math_CosS(alignedYaw); - sin = Math_SinS(alignedYaw); - cos = ABS(cos); - sin = ABS(sin); - xFromPlayer = this->actor.world.pos.x - player->actor.world.pos.x; - zFromPlayer = this->actor.world.pos.z - player->actor.world.pos.z; - xFromPlayerAbs = ABS(xFromPlayer); - if (xFromPlayerAbs < (cos * 37.0f + sin * 400.0f)) { - zFromPlayerAbs = ABS(zFromPlayer); - if (zFromPlayerAbs < (sin * 37.0f + cos * 400.0f)) { - return true; - } - } - return false; -} - -void EnMb_FindWaypointTowardsPlayer(EnMb* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->path]; - s16 yawToWaypoint; - Vec3f waypointPosF; - Vec3s* waypointPosS; - s16 yawPlayerToWaypoint; - s32 i; - s32 waypoint; - - for (waypoint = 0, i = path->count - 1; i >= 0; i--, waypoint++) { - waypointPosS = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + waypoint; - waypointPosF.x = waypointPosS->x; - waypointPosF.y = waypointPosS->y; - waypointPosF.z = waypointPosS->z; - yawToWaypoint = Math_Vec3f_Yaw(&this->actor.world.pos, &waypointPosF); - yawPlayerToWaypoint = yawToWaypoint - this->actor.yawTowardsPlayer; - if (ABS(yawPlayerToWaypoint) <= 0x1770) { - this->actor.world.rot.y = yawToWaypoint; - if (waypoint == this->waypoint) { - this->direction = -this->direction; - } - this->waypointPos = waypointPosF; - this->waypoint = waypoint; - break; - } - } -} - -void EnMb_SetupSpearGuardLookAround(EnMb* this) { - Animation_MorphToLoop(&this->skelAnime, &gEnMbSpearLookLeftAndRightAnim, -4.0f); - this->actor.speedXZ = 0.0f; - this->timer1 = Rand_S16Offset(30, 50); - this->state = ENMB_STATE_IDLE; - EnMb_SetupAction(this, EnMb_SpearGuardLookAround); -} - -void EnMb_SetupClubWaitPlayerNear(EnMb* this) { - Animation_PlayLoop(&this->skelAnime, &gEnMbClubStandStillClubDownAnim); - this->actor.speedXZ = 0.0f; - this->timer1 = Rand_S16Offset(30, 50); - this->state = ENMB_STATE_IDLE; - EnMb_SetupAction(this, EnMb_ClubWaitPlayerNear); -} - -void EnMb_SetupSpearPatrolTurnTowardsWaypoint(EnMb* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &gEnMbSpearLookLeftAndRightAnim, -4.0f); - this->actor.speedXZ = 0.0f; - this->timer1 = Rand_S16Offset(40, 80); - this->state = ENMB_STATE_IDLE; - EnMb_NextWaypoint(this, globalCtx); - EnMb_SetupAction(this, EnMb_SpearPatrolTurnTowardsWaypoint); -} - -void EnMb_SetupSpearGuardWalk(EnMb* this) { - Animation_Change(&this->skelAnime, &gEnMbSpearWalkAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gEnMbSpearWalkAnim), - ANIMMODE_LOOP, -4.0f); - this->actor.speedXZ = 0.59999996f; - this->timer1 = Rand_S16Offset(50, 70); - this->unk_332 = 1; - this->state = ENMB_STATE_WALK; - EnMb_SetupAction(this, EnMb_SpearGuardWalk); -} - -void EnMb_SetupSpearPatrolWalkTowardsWaypoint(EnMb* this) { - f32 frameCount = Animation_GetLastFrame(&gEnMbSpearWalkAnim); - - this->actor.speedXZ = 0.59999996f; - this->timer1 = Rand_S16Offset(50, 70); - this->unk_332 = 1; - this->state = ENMB_STATE_WALK; - Animation_Change(&this->skelAnime, &gEnMbSpearWalkAnim, 0.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); - EnMb_SetupAction(this, EnMb_SpearPatrolWalkTowardsWaypoint); -} - -void EnMb_SetupSpearPrepareAndCharge(EnMb* this) { - f32 frameCount = Animation_GetLastFrame(&gEnMbSpearPrepareChargeAnim); - - Animation_MorphToPlayOnce(&this->skelAnime, &gEnMbSpearPrepareChargeAnim, -4.0f); - this->state = ENMB_STATE_ATTACK; - this->actor.speedXZ = 0.0f; - this->timer3 = (s16)frameCount + 6; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_SPEAR_AT); - if (this->actor.params == ENMB_TYPE_SPEAR_GUARD) { - EnMb_SetupAction(this, EnMb_SpearGuardPrepareAndCharge); - } else { - EnMb_SetupAction(this, EnMb_SpearPatrolPrepareAndCharge); - } -} - -void EnMb_SetupSpearPatrolImmediateCharge(EnMb* this) { - Animation_PlayLoop(&this->skelAnime, &gEnMbSpearChargeAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_ATTACK); - this->attack = ENMB_ATTACK_SPEAR; - this->state = ENMB_STATE_ATTACK; - this->timer3 = 3; - this->actor.speedXZ = 10.0f; - EnMb_SetupAction(this, EnMb_SpearPatrolImmediateCharge); -} - -void EnMb_SetupClubAttack(EnMb* this) { - f32 frames = Animation_GetLastFrame(&gEnMbClubLiftClubAnim); - s16 relYawFromPlayer; - - this->state = ENMB_STATE_ATTACK; - Animation_Change(&this->skelAnime, &gEnMbClubLiftClubAnim, 3.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, 0.0f); - this->timer3 = 1; - relYawFromPlayer = this->actor.world.rot.y - this->actor.yawTowardsPlayer; - - if (ABS(relYawFromPlayer) <= 0x258) { - this->attack = ENMB_ATTACK_CLUB_MIDDLE; - } else if (relYawFromPlayer >= 0) { - this->attack = ENMB_ATTACK_CLUB_RIGHT; - } else { - this->attack = ENMB_ATTACK_CLUB_LEFT; - } - - EnMb_SetupAction(this, EnMb_ClubAttack); -} - -void EnMb_SetupSpearEndChargeQuick(EnMb* this) { - Animation_PlayOnce(&this->skelAnime, &gEnMbSpearSlowDownAnim); - this->state = ENMB_STATE_ATTACK_END; - this->timer1 = 0; - this->timer3 = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_SLIDE); - EnMb_SetupAction(this, EnMb_SpearEndChargeQuick); -} - -void EnMb_SetupSpearPatrolEndCharge(EnMb* this) { - Animation_PlayOnce(&this->skelAnime, &gEnMbSpearSlowDownAnim); - this->state = ENMB_STATE_ATTACK_END; - this->actor.bgCheckFlags &= ~1; - this->timer1 = 0; - this->timer3 = 50; - this->actor.speedXZ = -8.0f; - this->actor.velocity.y = 6.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_SLIDE); - EnMb_SetupAction(this, EnMb_SpearPatrolEndCharge); -} - -void EnMb_SetupClubWaitAfterAttack(EnMb* this) { - f32 frameCount = Animation_GetLastFrame(&gEnMbClubStandStillClubDownAnim); - - this->state = ENMB_STATE_ATTACK_END; - Animation_Change(&this->skelAnime, &gEnMbClubStandStillClubDownAnim, 5.0f, 0.0f, frameCount, ANIMMODE_ONCE_INTERP, - 0.0f); - EnMb_SetupAction(this, EnMb_ClubWaitAfterAttack); -} - -void EnMb_SetupClubDamaged(EnMb* this) { - Animation_PlayOnce(&this->skelAnime, &gEnMbClubDamagedKneelAnim); - this->state = ENMB_STATE_CLUB_KNEELING; - this->timer1 = 0; - this->timer3 = 20; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DEAD); - EnMb_SetupAction(this, EnMb_ClubDamaged); -} - -void EnMb_SetupClubDamagedWhileKneeling(EnMb* this) { - f32 frames = Animation_GetLastFrame(&gEnMbClubBeatenKneelingAnim); - - this->state = ENMB_STATE_CLUB_KNEELING_DAMAGED; - this->timer1 = 0; - this->timer3 = 6; - Animation_Change(&this->skelAnime, &gEnMbClubBeatenKneelingAnim, 1.0f, 4.0f, frames, ANIMMODE_ONCE_INTERP, 0.0f); - EnMb_SetupAction(this, EnMb_ClubDamagedWhileKneeling); -} - -void EnMb_SetupClubDead(EnMb* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gEnMbClubFallOnItsBackAnim, -4.0f); - this->state = ENMB_STATE_CLUB_DEAD; - this->actor.flags &= ~ACTOR_FLAG_0; - this->hitbox.dim.height = 80; - this->hitbox.dim.radius = 95; - this->timer1 = 30; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DEAD); - EnMb_SetupAction(this, EnMb_ClubDead); -} - -void EnMb_SetupStunned(EnMb* this) { - this->state = ENMB_STATE_STUNNED; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); - if (this->damageEffect == ENMB_DMGEFF_STUN_ICE) { - this->iceEffectTimer = 40; - } else { - if (this->actor.params != ENMB_TYPE_CLUB) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gEnMbSpearDamagedFromFrontAnim, 0.0f); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - } - EnMb_SetupAction(this, EnMb_Stunned); -} - -void EnMb_Stunned(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); - this->attack = ENMB_ATTACK_NONE; - } - - if (this->actor.colorFilterTimer == 0) { - if (this->actor.params == ENMB_TYPE_CLUB) { - if (this->actor.colChkInfo.health == 0) { - EnMb_SetupClubDead(this); - } else if (this->state == ENMB_STATE_CLUB_KNEELING) { - /* dead code: the setup for this action sets state to something else */ - EnMb_SetupClubDamagedWhileKneeling(this); - } else { - EnMb_SetupClubWaitPlayerNear(this); - } - } else { - if (this->actor.colChkInfo.health == 0) { - EnMb_SetupSpearDead(this); - } else { - EnMb_SetupSpearDamaged(this); - } - } - } -} - -void EnMb_SpearGuardLookAround(EnMb* this, GlobalContext* globalCtx) { - s16 timer1; - - SkelAnime_Update(&this->skelAnime); - if (this->timer1 == 0) { - timer1 = 0; - } else { - this->timer1--; - timer1 = this->timer1; - } - if (timer1 == 0 && Animation_OnFrame(&this->skelAnime, 0.0f)) { - EnMb_SetupSpearGuardWalk(this); - } -} - -void EnMb_SpearPatrolTurnTowardsWaypoint(EnMb* this, GlobalContext* globalCtx) { - s16 relYawFromPlayer; - - SkelAnime_Update(&this->skelAnime); - - if (this->timer1 == 0) { - this->yawToWaypoint = Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos); - if (Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawToWaypoint, 1, 0x3E8, 0) == 0) { - this->actor.world.rot.y = this->actor.shape.rot.y; - EnMb_SetupSpearPatrolWalkTowardsWaypoint(this); - } - } else { - this->timer1--; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 0x3E8, 0); - } - - if (ABS(this->actor.yDistToPlayer) <= 20.0f && EnMb_IsPlayerInCorridor(this, globalCtx)) { - relYawFromPlayer = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (ABS(relYawFromPlayer) <= 0x4000 || (func_8002DDE4(globalCtx) && this->actor.xzDistToPlayer < 160.0f)) { - EnMb_FindWaypointTowardsPlayer(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_VOICE); - EnMb_SetupSpearPrepareAndCharge(this); - } - } -} - -/** - * Slow down and resume walking. - */ -void EnMb_SpearEndChargeQuick(EnMb* this, GlobalContext* globalCtx) { - s32 pad; - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.5f, 1.0f, 0.0f); - if (this->actor.speedXZ > 1.0f) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); - } - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer1 == 0) { - this->timer3--; - if (this->timer3 == 0) { - /* Play the charge animation in reverse: let go of the spear and stand normally */ - Animation_Change(&this->skelAnime, &gEnMbSpearPrepareChargeAnim, -1.0f, - Animation_GetLastFrame(&gEnMbSpearPrepareChargeAnim), 0.0f, ANIMMODE_ONCE, 0.0f); - this->timer1 = 1; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_SPEAR_NORM); - } - } else { - if (this->actor.params <= ENMB_TYPE_SPEAR_GUARD) { - EnMb_SetupSpearGuardWalk(this); - this->timer1 = this->timer2 = this->timer3 = 80; - } else { - EnMb_SetupSpearPatrolTurnTowardsWaypoint(this, globalCtx); - } - } - } -} - -void EnMb_ClubWaitAfterAttack(EnMb* this, GlobalContext* globalCtx) { - this->attack = ENMB_ATTACK_NONE; - if (SkelAnime_Update(&this->skelAnime)) { - EnMb_SetupClubWaitPlayerNear(this); - } -} - -/** - * Slow down, charge again if the player is near, or resume walking. - */ -void EnMb_SpearPatrolEndCharge(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 lastFrame; - s16 relYawFromPlayer; - s16 yawPlayerToWaypoint; - - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); - } - - if (this->actor.bgCheckFlags & 1) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); - - if (this->actor.speedXZ > 1.0f) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); - } - - if (this->timer1 != 0) { - this->timer3--; - if (this->timer3 == 0) { - relYawFromPlayer = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - - if (ABS(this->actor.yDistToPlayer) <= 20.0f && EnMb_IsPlayerInCorridor(this, globalCtx) && - ABS(relYawFromPlayer) <= 0x4000 && this->actor.xzDistToPlayer <= 200.0f) { - EnMb_SetupSpearPrepareAndCharge(this); - } else { - lastFrame = Animation_GetLastFrame(&gEnMbSpearPrepareChargeAnim); - /* Play the charge animation in reverse: let go of the spear and stand normally */ - Animation_Change(&this->skelAnime, &gEnMbSpearPrepareChargeAnim, -1.0f, lastFrame, 0.0f, - ANIMMODE_ONCE, 0.0f); - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_SPEAR_NORM); - } - } else { - if (this->actor.xzDistToPlayer <= 160.0f) { - this->actor.speedXZ = -5.0f; - } else { - this->actor.speedXZ = 0.0f; - } - } - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer1 == 0) { - lastFrame = Animation_GetLastFrame(&gEnMbSpearChargeAnim); - Animation_Change(&this->skelAnime, &gEnMbSpearChargeAnim, 0.5f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, - 0.0f); - this->timer1 = 1; - } else { - yawPlayerToWaypoint = - Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos) - this->actor.yawTowardsPlayer; - - if (ABS(yawPlayerToWaypoint) <= 0x4000) { - EnMb_SetupSpearPatrolTurnTowardsWaypoint(this, globalCtx); - } else { - EnMb_SetupSpearPatrolWalkTowardsWaypoint(this); - } - } - } - } -} - -/** - * Prepare charge (animation), then charge until the player isn't in front. - */ -void EnMb_SpearGuardPrepareAndCharge(EnMb* this, GlobalContext* globalCtx) { - s32 prevFrame; - s16 relYawTowardsPlayerAbs = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (relYawTowardsPlayerAbs < 0) { - relYawTowardsPlayerAbs = -relYawTowardsPlayerAbs; - } - - prevFrame = this->skelAnime.curFrame; - - if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayLoop(&this->skelAnime, &gEnMbSpearChargeAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_ATTACK); - } - - if (this->timer3 != 0) { - this->timer3--; - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - } else { - this->actor.speedXZ = 10.0f; - this->attack = ENMB_ATTACK_SPEAR; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); - if (prevFrame != (s32)this->skelAnime.curFrame && - ((s32)this->skelAnime.curFrame == 2 || (s32)this->skelAnime.curFrame == 6)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DASH); - } - } - - if (relYawTowardsPlayerAbs > 0x1388) { - this->attack = ENMB_ATTACK_NONE; - EnMb_SetupSpearEndChargeQuick(this); - } -} - -void EnMb_ClubAttack(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - Vec3f effSpawnPos; - Vec3f effWhiteShockwaveDynamics = { 0.0f, 0.0f, 0.0f }; - f32 flamesParams[] = { 18.0f, 18.0f, 0.0f }; - s16 flamesUnused[] = { 20, 40, 0 }; - s16 relYawTarget[] = { -0x9C4, 0, 0xDAC }; - - Math_SmoothStepToS(&this->actor.shape.rot.y, relYawTarget[this->attack - 1] + this->actor.world.rot.y, 1, 0x2EE, 0); - - if (this->attackCollider.base.atFlags & AT_HIT) { - this->attackCollider.base.atFlags &= ~AT_HIT; - if (this->attackCollider.base.at == &player->actor) { - u8 prevPlayerInvincibilityTimer = player->invincibilityTimer; - - if (player->invincibilityTimer < 0) { - if (player->invincibilityTimer <= -40) { - player->invincibilityTimer = 0; - } else { - player->invincibilityTimer = 0; - globalCtx->damagePlayer(globalCtx, -8); - } - } - - func_8002F71C(globalCtx, &this->actor, (650.0f - this->actor.xzDistToPlayer) * 0.04f + 4.0f, - this->actor.world.rot.y, 8.0f); - - player->invincibilityTimer = prevPlayerInvincibilityTimer; - } - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer3 != 0) { - this->timer3--; - if (this->timer3 == 0) { - f32 lastAnimFrame = Animation_GetLastFrame(&gEnMbClubStrikeDownAnim); - Animation_Change(&this->skelAnime, &gEnMbClubStrikeDownAnim, 1.5f, 0.0f, lastAnimFrame, - ANIMMODE_ONCE_INTERP, 0.0f); - } - } else { - effSpawnPos = this->effSpawnPos; - effSpawnPos.y = this->actor.floorHeight; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MONBLIN_HAM_LAND); - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); - EffectSsBlast_SpawnWhiteShockwave(globalCtx, &effSpawnPos, &effWhiteShockwaveDynamics, - &effWhiteShockwaveDynamics); - func_80033480(globalCtx, &effSpawnPos, 2.0f, 3, 0x12C, 0xB4, 1); - Camera_AddQuake(&globalCtx->mainCamera, 2, 0x19, 5); - func_800358DC(&this->actor, &effSpawnPos, &this->actor.world.rot, flamesParams, 20, flamesUnused, globalCtx, - -1, 0); - EnMb_SetupClubWaitAfterAttack(this); - } - } else { - if (this->timer3 != 0 && this->skelAnime.curFrame == 6.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MONBLIN_HAM_UP); - - } else if (this->timer3 == 0 && this->skelAnime.curFrame == 3.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MONBLIN_HAM_DOWN); - } - } -} - -/** - * Prepare charge (animation), then charge to the end of the floor collision. - */ -void EnMb_SpearPatrolPrepareAndCharge(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 prevFrame; - s32 hasHitPlayer = false; - s32 endCharge = !Actor_TestFloorInDirection(&this->actor, globalCtx, 110.0f, this->actor.world.rot.y); - - prevFrame = (s32)this->skelAnime.curFrame; - if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayLoop(&this->skelAnime, &gEnMbSpearChargeAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_ATTACK); - } - - if (this->timer3 != 0) { - this->timer3--; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x1F40, 0); - endCharge = false; - } else { - this->actor.speedXZ = 10.0f; - this->attack = ENMB_ATTACK_SPEAR; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); - if (prevFrame != (s32)this->skelAnime.curFrame && - ((s32)this->skelAnime.curFrame == 2 || (s32)this->skelAnime.curFrame == 6)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DASH); - } - } - - if (this->attackCollider.base.atFlags & AT_HIT) { - if (this->attackCollider.base.at == &player->actor) { - if (!endCharge && !(player->stateFlags2 & 0x80)) { - if (player->invincibilityTimer < 0) { - if (player->invincibilityTimer < -39) { - player->invincibilityTimer = 0; - } else { - player->invincibilityTimer = 0; - globalCtx->damagePlayer(globalCtx, -8); - } - } - if (!(this->attackCollider.base.atFlags & AT_BOUNCED)) { - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - if (globalCtx->grabPlayer(globalCtx, player)) { - player->actor.parent = &this->actor; - } - } - hasHitPlayer = true; - } else { - this->attackCollider.base.atFlags &= ~AT_HIT; - } - } - - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->actor.world.pos.x = this->actor.world.pos.x + Math_CosS(this->actor.shape.rot.y) * 10.0f + - Math_SinS(this->actor.shape.rot.y) * 89.0f; - hasHitPlayer = true; - player->actor.world.pos.z = this->actor.world.pos.z + Math_SinS(this->actor.shape.rot.y) * 10.0f + - Math_CosS(this->actor.shape.rot.y) * 89.0f; - player->unk_850 = 0; - player->actor.speedXZ = 0.0f; - player->actor.velocity.y = 0.0f; - } - - if (endCharge) { - if (hasHitPlayer || (player->stateFlags2 & 0x80)) { - this->attackCollider.base.atFlags &= ~AT_HIT; - if (player->stateFlags2 & 0x80) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); - } - } - this->attack = ENMB_ATTACK_NONE; - this->actor.speedXZ = -10.0f; - EnMb_SetupSpearPatrolEndCharge(this); - } -} - -/** - * Charge and follow the path, until hitting the player or, after some time, reaching home. - */ -void EnMb_SpearPatrolImmediateCharge(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 prevFrame; - s32 hasHitPlayer = false; - s32 endCharge = !Actor_TestFloorInDirection(&this->actor, globalCtx, 110.0f, this->actor.world.rot.y); - - prevFrame = (s32)this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); - if (prevFrame != (s32)this->skelAnime.curFrame && - ((s32)this->skelAnime.curFrame == 2 || (s32)this->skelAnime.curFrame == 6)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DASH); - } - - if (this->attackCollider.base.atFlags & AT_HIT) { - if (this->attackCollider.base.at == &player->actor) { - if (!endCharge && !(player->stateFlags2 & 0x80)) { - if (player->invincibilityTimer < 0) { - if (player->invincibilityTimer <= -40) { - player->invincibilityTimer = 0; - } else { - player->invincibilityTimer = 0; - globalCtx->damagePlayer(globalCtx, -8); - } - } - if (!(this->attackCollider.base.atFlags & AT_BOUNCED)) { - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - if (globalCtx->grabPlayer(globalCtx, player)) { - player->actor.parent = &this->actor; - } - } - hasHitPlayer = true; - } else { - this->attackCollider.base.atFlags &= ~AT_HIT; - } - } - - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->actor.world.pos.x = this->actor.world.pos.x + Math_CosS(this->actor.shape.rot.y) * 10.0f + - Math_SinS(this->actor.shape.rot.y) * 89.0f; - hasHitPlayer = true; - player->actor.world.pos.z = this->actor.world.pos.z + Math_SinS(this->actor.shape.rot.y) * 10.0f + - Math_CosS(this->actor.shape.rot.y) * 89.0f; - player->unk_850 = 0; - player->actor.speedXZ = 0.0f; - player->actor.velocity.y = 0.0f; - } - - if (endCharge) { - if (hasHitPlayer || (player->stateFlags2 & 0x80)) { - this->attackCollider.base.atFlags &= ~AT_HIT; - if (player->stateFlags2 & 0x80) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); - } - this->attack = ENMB_ATTACK_NONE; - this->actor.speedXZ = -10.0f; - EnMb_SetupSpearPatrolEndCharge(this); - this->timer3 = 1; - } else { - this->timer3--; - EnMb_NextWaypoint(this, globalCtx); - } - } - - EnMb_FaceWaypoint(this, globalCtx); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->timer3 == 0 && Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) < 80.0f) { - this->attack = ENMB_ATTACK_NONE; - EnMb_SetupSpearEndChargeQuick(this); - } -} - -void EnMb_ClubDamaged(EnMb* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer3 != 0) { - Animation_PlayOnce(&this->skelAnime, &gEnMbClubStandUpAnim); - this->timer3 = 0; - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); - Camera_AddQuake(&globalCtx->mainCamera, 2, 25, 5); - } else { - EnMb_SetupClubWaitPlayerNear(this); - } - } -} - -void EnMb_ClubDamagedWhileKneeling(EnMb* this, GlobalContext* globalCtx) { - s32 pad; - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer3 != 0) { - this->timer3--; - if (this->timer3 == 0) { - if (this->timer1 == 0) { - Animation_Change(&this->skelAnime, &gEnMbClubStandUpAnim, 3.0f, 0.0f, - Animation_GetLastFrame(&gEnMbClubStandUpAnim), ANIMMODE_ONCE_INTERP, 0.0f); - this->timer1 = 1; - this->timer3 = 6; - } else { - Animation_Change(&this->skelAnime, &gEnMbClubStandUpAnim, 3.0f, 0.0f, - Animation_GetLastFrame(&gEnMbClubStandUpAnim), ANIMMODE_ONCE_INTERP, 0.0f); - } - } - } else { - EnMb_SetupClubWaitPlayerNear(this); - } - } -} - -void EnMb_ClubDead(EnMb* this, GlobalContext* globalCtx) { - Vec3f effPos; - Vec3f effPosBase; - - effPos = this->actor.world.pos; - effPos.x += Math_SinS(this->actor.shape.rot.y) * -70.0f; - effPos.z += Math_CosS(this->actor.shape.rot.y) * -70.0f; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - effPosBase = effPos; - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer1 > 0) { - Vec3f effZeroVec = { 0.0f, 0.0f, 0.0f }; - s32 i; - - this->timer1--; - for (i = 4; i >= 0; i--) { - effPos.x = Rand_CenteredFloat(240.0f) + effPosBase.x; - effPos.y = Rand_CenteredFloat(15.0f) + (effPosBase.y + 20.0f); - effPos.z = Rand_CenteredFloat(240.0f) + effPosBase.z; - EffectSsDeadDb_Spawn(globalCtx, &effPos, &effZeroVec, &effZeroVec, 230, 7, 255, 255, 255, 255, 0, 255, - 0, 1, 9, true); - } - } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &effPos, 0xC0); - Actor_Kill(&this->actor); - } - } else if ((s32)this->skelAnime.curFrame == 15 || (s32)this->skelAnime.curFrame == 22) { - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &effPos, 50.0f, 10, 3.0f, 400, 60, false); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - Camera_AddQuake(&globalCtx->mainCamera, 2, 25, 5); - } -} - -/** - * Walk around the home point, face and charge the player if close. - */ -void EnMb_SpearGuardWalk(EnMb* this, GlobalContext* globalCtx) { - s32 prevFrame; - s32 beforeCurFrame; - s32 pad1; - s32 pad2; - Player* player = GET_PLAYER(globalCtx); - s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - s16 yawTowardsHome; - f32 playSpeedAbs; - - relYawTowardsPlayer = ABS(relYawTowardsPlayer); - Math_SmoothStepToF(&this->actor.speedXZ, 0.59999996f, 0.1f, 1.0f, 0.0f); - this->skelAnime.playSpeed = this->actor.speedXZ; - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - - playSpeedAbs = ABS(this->skelAnime.playSpeed); - beforeCurFrame = this->skelAnime.curFrame - playSpeedAbs; - playSpeedAbs = ABS(this->skelAnime.playSpeed); - if (this->timer3 == 0 && - Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->playerDetectionRange) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x2EE, 0); - this->actor.flags |= ACTOR_FLAG_0; - if (this->actor.xzDistToPlayer < 500.0f && relYawTowardsPlayer < 0x1388) { - EnMb_SetupSpearPrepareAndCharge(this); - } - } else { - this->actor.flags &= ~ACTOR_FLAG_0; - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) > this->maxHomeDist || this->timer2 != 0) { - yawTowardsHome = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_SmoothStepToS(&this->actor.world.rot.y, yawTowardsHome, 1, 0x2EE, 0); - } - if (this->timer2 != 0) { - this->timer2--; - } - if (this->timer3 != 0) { - this->timer3--; - } - if (this->timer2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_VOICE); - } - this->timer1--; - if (this->timer1 == 0) { - if (Rand_ZeroOne() > 0.7f) { - this->timer1 = Rand_S16Offset(50, 70); - this->timer2 = Rand_S16Offset(15, 40); - } else { - EnMb_SetupSpearGuardLookAround(this); - } - } - } - - if (prevFrame != (s32)this->skelAnime.curFrame) { - if ((beforeCurFrame <= 1 && prevFrame + (s32)playSpeedAbs >= 1) || - (beforeCurFrame <= 20 && prevFrame + (s32)playSpeedAbs >= 20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); - } - } - - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnMb_SpearPatrolWalkTowardsWaypoint(EnMb* this, GlobalContext* globalCtx) { - s32 prevFrame; - s32 beforeCurFrame; - s16 relYawTowardsPlayer; - f32 yDistToPlayerAbs; - f32 playSpeedABS; - - if (Math_Vec3f_DistXZ(&this->waypointPos, &this->actor.world.pos) <= 8.0f || - (Rand_ZeroOne() < 0.1f && Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) <= 4.0f)) { - EnMb_SetupSpearPatrolTurnTowardsWaypoint(this, globalCtx); - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 0.59999996f, 0.1f, 1.0f, 0.0f); - this->skelAnime.playSpeed = 2.0f * this->actor.speedXZ; - } - - this->yawToWaypoint = Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos); - Math_SmoothStepToS(&this->actor.world.rot.y, this->yawToWaypoint, 1, 0x5DC, 0); - - yDistToPlayerAbs = (this->actor.yDistToPlayer >= 0.0f) ? this->actor.yDistToPlayer : -this->actor.yDistToPlayer; - if (yDistToPlayerAbs <= 20.0f && EnMb_IsPlayerInCorridor(this, globalCtx)) { - relYawTowardsPlayer = (this->actor.shape.rot.y - this->actor.yawTowardsPlayer); - if (ABS(relYawTowardsPlayer) <= 0x4000 || (func_8002DDE4(globalCtx) && this->actor.xzDistToPlayer < 160.0f)) { - EnMb_FindWaypointTowardsPlayer(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_VOICE); - EnMb_SetupSpearPrepareAndCharge(this); - return; - } - } - - if (this->timer2 != 0) { - this->timer2--; - } - if (this->timer3 != 0) { - this->timer3--; - } - if (this->timer2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_VOICE); - this->timer2 = Rand_S16Offset(30, 70); - } - - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - playSpeedABS = ABS(this->skelAnime.playSpeed); - beforeCurFrame = this->skelAnime.curFrame - playSpeedABS; - playSpeedABS = (this->skelAnime.playSpeed >= 0.0f) ? this->skelAnime.playSpeed : -this->skelAnime.playSpeed; - if (prevFrame != (s32)this->skelAnime.curFrame) { - if ((beforeCurFrame <= 1 && (s32)playSpeedABS + prevFrame >= 1) || - (beforeCurFrame <= 20 && (s32)playSpeedABS + prevFrame >= 20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); - } - } - - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnMb_ClubWaitPlayerNear(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 relYawFromPlayer = this->actor.world.rot.y - this->actor.yawTowardsPlayer; - - SkelAnime_Update(&this->skelAnime); - if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->playerDetectionRange && - !(player->stateFlags1 & 0x4000000) && ABS(relYawFromPlayer) < 0x3E80) { - EnMb_SetupClubAttack(this); - } -} - -void EnMb_SetupSpearDamaged(EnMb* this) { - s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(relYawTowardsPlayer) <= 0x4000) { - Animation_MorphToPlayOnce(&this->skelAnime, &gEnMbSpearDamagedFromFrontAnim, -4.0f); - this->actor.speedXZ = -8.0f; - } else { - Animation_MorphToPlayOnce(&this->skelAnime, &gEnMbSpearDamagedFromBehindAnim, -4.0f); - this->actor.speedXZ = 8.0f; - } - - this->timer1 = 30; - this->state = ENMB_STATE_SPEAR_SPEARPATH_DAMAGED; - this->actor.shape.rot.y = this->actor.world.rot.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DEAD); - EnMb_SetupAction(this, EnMb_SpearDamaged); -} - -void EnMb_SpearDamaged(EnMb* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.params <= ENMB_TYPE_SPEAR_GUARD) { - EnMb_SetupSpearGuardLookAround(this); - } else { - EnMb_SetupSpearPatrolImmediateCharge(this); - } - } -} - -void EnMb_SetupSpearDead(EnMb* this) { - s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(relYawTowardsPlayer) <= 0x4000) { - Animation_MorphToPlayOnce(&this->skelAnime, &gEnMbSpearFallOnItsBackAnim, -4.0f); - this->actor.speedXZ = -8.0f; - } else { - /* The gEnMbSpearFallFaceDownAnim animation was probably meant to be used here */ - Animation_MorphToPlayOnce(&this->skelAnime, &gEnMbSpearFallOnItsBackAnim, -4.0f); - this->actor.speedXZ = 8.0f; - } - - this->actor.world.rot.y = this->actor.shape.rot.y; - this->timer1 = 30; - this->state = ENMB_STATE_SPEAR_SPEARPATH_DAMAGED; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_DEAD); - this->actor.flags &= ~ACTOR_FLAG_0; - EnMb_SetupAction(this, EnMb_SpearDead); -} - -void EnMb_SpearDead(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); - this->attack = ENMB_ATTACK_NONE; - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer1 > 0) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - s32 i; - Vec3f effPos; - - this->actor.shape.shadowScale = 0.0f; - this->timer1--; - for (i = 4; i >= 0; i--) { - effPos.x = Rand_CenteredFloat(110.0f) + this->actor.world.pos.x; - effPos.y = Rand_CenteredFloat(15.0f) + (this->actor.world.pos.y + 20.0f); - effPos.z = Rand_CenteredFloat(110.0f) + this->actor.world.pos.z; - - EffectSsDeadDb_Spawn(globalCtx, &effPos, &zeroVec, &zeroVec, 100, 7, 255, 255, 255, 255, 0, 255, 0, 1, - 9, true); - } - } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); - Actor_Kill(&this->actor); - } - } -} - -void EnMb_SpearUpdateAttackCollider(Actor* thisx, GlobalContext* globalCtx) { - Vec3f quadModel0 = { 1000.0f, 1500.0f, 0.0f }; - Vec3f quadModel1 = { -1000.0f, 1500.0f, 0.0f }; - Vec3f quadModel2 = { 1000.0f, 1500.0f, 4500.0f }; - Vec3f quadModel3 = { -1000.0f, 1500.0f, 4500.0f }; - EnMb* this = (EnMb*)thisx; - - if (this->actor.params >= ENMB_TYPE_SPEAR_PATROL) { - quadModel0.x += 2000.0f; - quadModel0.z = -4000.0f; - quadModel1.z = -4000.0f; - quadModel2.x += 2000.0f; - quadModel1.x -= 2000.0f; - quadModel3.x -= 2000.0f; - quadModel2.z += 4000.0f; - quadModel3.z += 4000.0f; - } - Matrix_MultVec3f(&quadModel0, &this->attackCollider.dim.quad[1]); - Matrix_MultVec3f(&quadModel1, &this->attackCollider.dim.quad[0]); - Matrix_MultVec3f(&quadModel2, &this->attackCollider.dim.quad[3]); - Matrix_MultVec3f(&quadModel3, &this->attackCollider.dim.quad[2]); - Collider_SetQuadVertices(&this->attackCollider, &this->attackCollider.dim.quad[0], - &this->attackCollider.dim.quad[1], &this->attackCollider.dim.quad[2], - &this->attackCollider.dim.quad[3]); -} - -void EnMb_ClubUpdateAttackCollider(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f quadModel[] = { { 1000.0f, 0.0f, 0.0f }, - { 1000.0f, 0.0f, 0.0f }, - { 1000.0f, -8000.0f, -1500.0f }, - { 1000.0f, -9000.0f, 2000.0f } }; - EnMb* this = (EnMb*)thisx; - - Matrix_MultVec3f(&quadModel[0], &this->attackCollider.dim.quad[1]); - Matrix_MultVec3f(&quadModel[1], &this->attackCollider.dim.quad[0]); - Matrix_MultVec3f(&quadModel[2], &this->attackCollider.dim.quad[3]); - Matrix_MultVec3f(&quadModel[3], &this->attackCollider.dim.quad[2]); - Collider_SetQuadVertices(&this->attackCollider, &this->attackCollider.dim.quad[0], - &this->attackCollider.dim.quad[1], &this->attackCollider.dim.quad[2], - &this->attackCollider.dim.quad[3]); -} - -void EnMb_CheckColliding(EnMb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->frontShielding.base.acFlags & AC_HIT) { - this->frontShielding.base.acFlags &= ~(AC_HIT | AC_BOUNCED); - this->hitbox.base.acFlags &= ~AC_HIT; - } else if ((this->hitbox.base.acFlags & AC_HIT) && this->state >= ENMB_STATE_STUNNED) { - this->hitbox.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != ENMB_DMGEFF_IGNORE && - this->actor.colChkInfo.damageEffect != ENMB_DMGEFF_FREEZE) { - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; - player->actor.parent = NULL; - player->unk_850 = 200; - func_8002F71C(globalCtx, &this->actor, 6.0f, this->actor.world.rot.y, 6.0f); - } - this->damageEffect = this->actor.colChkInfo.damageEffect; - this->attack = ENMB_ATTACK_NONE; - Actor_SetDropFlag(&this->actor, &this->hitbox.info, false); - if (this->actor.colChkInfo.damageEffect == ENMB_DMGEFF_STUN || - this->actor.colChkInfo.damageEffect == ENMB_DMGEFF_STUN_ICE) { - if (this->state != ENMB_STATE_STUNNED) { - Actor_ApplyDamage(&this->actor); - EnMb_SetupStunned(this); - } - } else { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFA, 0, 0xC); - if (this->actor.params == ENMB_TYPE_CLUB) { - if (this->actor.colChkInfo.health == 0) { - EnMb_SetupClubDead(this); - } else if (this->state != ENMB_STATE_CLUB_KNEELING) { - EnMb_SetupClubDamaged(this); - } - } else { - if (this->actor.colChkInfo.health == 0) { - EnMb_SetupSpearDead(this); - } else { - EnMb_SetupSpearDamaged(this); - } - } - } - } - } -} - -void EnMb_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMb* this = (EnMb*)thisx; - s32 pad; - - EnMb_CheckColliding(this, globalCtx); - if (thisx->colChkInfo.damageEffect != ENMB_DMGEFF_FREEZE) { - this->actionFunc(this, globalCtx); - Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 40.0f, 40.0f, 70.0f, 0x1D); - Actor_SetFocus(thisx, thisx->scale.x * 4500.0f); - Collider_UpdateCylinder(thisx, &this->hitbox); - if (thisx->colChkInfo.health <= 0) { - this->hitbox.dim.pos.x += Math_SinS(thisx->shape.rot.y) * (-4400.0f * thisx->scale.y); - this->hitbox.dim.pos.z += Math_CosS(thisx->shape.rot.y) * (-4400.0f * thisx->scale.y); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->hitbox.base); - if (this->state >= ENMB_STATE_STUNNED && - (thisx->params == ENMB_TYPE_CLUB || this->state != ENMB_STATE_ATTACK)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->hitbox.base); - } - if (this->state >= ENMB_STATE_IDLE) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->frontShielding.base); - } - if (this->attack > ENMB_ATTACK_NONE) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->attackCollider.base); - } - } -} - -void EnMb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f unused = { 1100.0f, -700.0f, 0.0f }; - static Vec3f feetPos = { 0.0f, 0.0f, 0.0f }; - static Vec3f effSpawnPosModel = { 0.0f, -8000.0f, 0.0f }; - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - s32 bodyPart = -1; - EnMb* this = (EnMb*)thisx; - Vec3f bodyPartPos; - - if (this->actor.params == ENMB_TYPE_CLUB) { - if (limbIndex == ENMB_LIMB_LHAND) { - Matrix_MultVec3f(&effSpawnPosModel, &this->effSpawnPos); - if (this->attack > ENMB_ATTACK_NONE) { - EnMb_ClubUpdateAttackCollider(&this->actor, globalCtx); - } - } - Actor_SetFeetPos(&this->actor, limbIndex, ENMB_LIMB_LFOOT, &feetPos, ENMB_LIMB_RFOOT, &feetPos); - } - - if (this->iceEffectTimer != 0) { - switch (limbIndex) { - case ENMB_LIMB_HEAD: - bodyPart = 0; - break; - case ENMB_LIMB_LHAND: - bodyPart = 1; - break; - case ENMB_LIMB_RHAND: - bodyPart = 2; - break; - case ENMB_LIMB_LSHOULDER: - bodyPart = 3; - break; - case ENMB_LIMB_RSHOULDER: - bodyPart = 4; - break; - case ENMB_LIMB_CHEST: - bodyPart = 5; - break; - case ENMB_LIMB_LTHIGH: - bodyPart = 6; - break; - case ENMB_LIMB_RTHIGH: - bodyPart = 7; - break; - case ENMB_LIMB_LFOOT: - bodyPart = 8; - break; - case ENMB_LIMB_RFOOT: - bodyPart = 9; - break; - } - if (bodyPart >= 0) { - Matrix_MultVec3f(&zeroVec, &bodyPartPos); - this->bodyPartsPos[bodyPart].x = bodyPartPos.x; - this->bodyPartsPos[bodyPart].y = bodyPartPos.y; - this->bodyPartsPos[bodyPart].z = bodyPartPos.z; - } - } -} - -void EnMb_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f frontShieldingTriModel0[] = { - { 4000.0f, 7000.0f, 3500.0f }, - { 4000.0f, 0.0f, 3500.0f }, - { -4000.0f, 7000.0f, 3500.0f }, - }; - static Vec3f frontShieldingTriModel1[] = { - { -4000.0f, 7000.0f, 3500.0f }, - { -4000.0f, 0.0f, 3500.0f }, - { 4000.0f, 0.0f, 3500.0f }, - }; - s32 i; - f32 scale; - Vec3f frontShieldingTri0[3]; - Vec3f frontShieldingTri1[3]; - s32 bodyPartIdx; - EnMb* this = (EnMb*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnMb_PostLimbDraw, thisx); - - if (thisx->params != ENMB_TYPE_CLUB) { - if (this->attack > ENMB_ATTACK_NONE) { - EnMb_SpearUpdateAttackCollider(thisx, globalCtx); - } - for (i = 0; i < 3; i++) { - Matrix_MultVec3f(&frontShieldingTriModel0[i], &frontShieldingTri0[i]); - Matrix_MultVec3f(&frontShieldingTriModel1[i], &frontShieldingTri1[i]); - } - Collider_SetTrisVertices(&this->frontShielding, 0, &frontShieldingTri0[0], &frontShieldingTri0[1], - &frontShieldingTri0[2]); - Collider_SetTrisVertices(&this->frontShielding, 1, &frontShieldingTri1[0], &frontShieldingTri1[1], - &frontShieldingTri1[2]); - } - - if (this->iceEffectTimer != 0) { - thisx->colorFilterTimer++; - if (this->iceEffectTimer >= 0) { - this->iceEffectTimer--; - } - if ((this->iceEffectTimer % 4) == 0) { - scale = 2.5f; - if (thisx->params == ENMB_TYPE_CLUB) { - scale = 4.0f; - } - bodyPartIdx = this->iceEffectTimer >> 2; - EffectSsEnIce_SpawnFlyingVec3s(globalCtx, thisx, &this->bodyPartsPos[bodyPartIdx], 150, 150, 150, 250, 235, - 245, 255, scale); - } - } -} diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.cpp b/src/overlays/actors/ovl_En_Mb/z_en_mb.cpp new file mode 100644 index 000000000..f64eab092 --- /dev/null +++ b/src/overlays/actors/ovl_En_Mb/z_en_mb.cpp @@ -0,0 +1,1571 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MB_Z_EN_MB_C +#include "actor_common.h" +/* + * File: z_en_mb.c + * Overlay: ovl_En_Mb + * Description: Moblins + */ + +#include "z_en_mb.h" +#include "objects/object_mb/object_mb.h" +#include "def/code_800A9F30.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +/* + * This actor can have three behaviors: + * - "Spear Guard" (variable -1): uses a spear, walks around home point, charges player if too close + * - "Club" (variable 0): uses a club, stands still and smashes its club on the ground when the player approaches + * - "Spear Patrol" (variable 0xPP00 PP=pathId): uses a spear, patrols following a path, charges + */ + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +typedef enum { + /* -1 */ ENMB_TYPE_SPEAR_GUARD = -1, + /* 0 */ ENMB_TYPE_CLUB, + /* 1 */ ENMB_TYPE_SPEAR_PATROL +} EnMbType; + +#define ENMB_ATTACK_NONE 0 +#define ENMB_ATTACK_SPEAR 1 +#define ENMB_ATTACK_CLUB_RIGHT 1 +#define ENMB_ATTACK_CLUB_MIDDLE 2 +#define ENMB_ATTACK_CLUB_LEFT 3 + +/* Spear and Club moblins use a different skeleton but the limbs are organized the same */ +typedef enum { + /* 1 */ ENMB_LIMB_ROOT = 1, + /* 3 */ ENMB_LIMB_WAIST = 3, + /* 6 */ ENMB_LIMB_CHEST = 6, + /* 7 */ ENMB_LIMB_HEAD, + /* 9 */ ENMB_LIMB_LSHOULDER = 9, + /* 11 */ ENMB_LIMB_LFOREARM = 11, + /* 12 */ ENMB_LIMB_LHAND, + /* 14 */ ENMB_LIMB_RSHOULDER = 14, + /* 16 */ ENMB_LIMB_RFOREARM = 16, + /* 17 */ ENMB_LIMB_RHAND, + /* 20 */ ENMB_LIMB_LTHIGH = 20, + /* 21 */ ENMB_LIMB_LSHIN, + /* 22 */ ENMB_LIMB_LFOOT, + /* 25 */ ENMB_LIMB_RTHIGH = 25, + /* 26 */ ENMB_LIMB_RSHIN, + /* 27 */ ENMB_LIMB_RFOOT +} EnMbLimb; + +void EnMb_Init(Actor* thisx, GlobalContext* globalCtx); +void EnMb_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnMb_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMb_Draw(Actor* thisx, GlobalContext* globalCtx); + +ActorInit En_Mb_InitVars = { + ACTOR_EN_MB, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_MB, + sizeof(EnMb), + (ActorFunc)EnMb_Init, + (ActorFunc)EnMb_Destroy, + (ActorFunc)EnMb_Update, + (ActorFunc)EnMb_Draw, +}; + +void EnMb_SetupSpearPatrolTurnTowardsWaypoint(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SetupClubWaitPlayerNear(EnMb* pthis); +void EnMb_SpearGuardLookAround(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SetupSpearGuardLookAround(EnMb* pthis); +void EnMb_SetupSpearDamaged(EnMb* pthis); +void EnMb_SpearGuardWalk(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearGuardPrepareAndCharge(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearPatrolPrepareAndCharge(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearEndChargeQuick(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_Stunned(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_ClubDead(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_ClubDamagedWhileKneeling(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_ClubWaitPlayerNear(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_ClubAttack(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearDead(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearDamaged(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SetupSpearDead(EnMb* pthis); +void EnMb_SpearPatrolTurnTowardsWaypoint(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearPatrolWalkTowardsWaypoint(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearPatrolEndCharge(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_SpearPatrolImmediateCharge(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_ClubWaitAfterAttack(EnMb* pthis, GlobalContext* globalCtx); +void EnMb_ClubDamaged(EnMb* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sHitboxInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderTrisElementInit sFrontShieldingTrisInit[2] = { + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, + { + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO, + OCELEM_NONE, + }, + { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, + }, +}; + +static ColliderTrisInit sFrontShieldingInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sFrontShieldingTrisInit, +}; + +static ColliderQuadInit sAttackColliderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +typedef enum { + /* 0x0 */ ENMB_DMGEFF_IGNORE, + /* 0x1 */ ENMB_DMGEFF_STUN, + /* 0x5 */ ENMB_DMGEFF_FREEZE = 0x5, + /* 0x6 */ ENMB_DMGEFF_STUN_ICE, + /* 0xF */ ENMB_DMGEFF_DEFAULT = 0xF +} EnMbDamageEffect; + +static DamageTable sSpearMoblinDamageTable = { + /* Deku nut */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Deku stick */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Slingshot */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), + /* Explosive */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Boomerang */ DMG_ENTRY(0, ENMB_DMGEFF_STUN), + /* Normal arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Hammer swing */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Hookshot */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Kokiri sword */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), + /* Master sword */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Giant's Knife */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Fire arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Ice arrow */ DMG_ENTRY(4, ENMB_DMGEFF_STUN_ICE), + /* Light arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Unk arrow 1 */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Unk arrow 2 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Unk arrow 3 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Fire magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Ice magic */ DMG_ENTRY(3, ENMB_DMGEFF_STUN_ICE), + /* Light magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Shield */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Mirror Ray */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Kokiri spin */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), + /* Giant spin */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Master spin */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Kokiri jump */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Giant jump */ DMG_ENTRY(8, ENMB_DMGEFF_DEFAULT), + /* Master jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Unknown 1 */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Unblockable */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Hammer jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Unknown 2 */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), +}; + +static DamageTable sClubMoblinDamageTable = { + /* Deku nut */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Deku stick */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Slingshot */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Explosive */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Boomerang */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Normal arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Hammer swing */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Hookshot */ DMG_ENTRY(0, ENMB_DMGEFF_STUN), + /* Kokiri sword */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), + /* Master sword */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Giant's Knife */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Fire arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Ice arrow */ DMG_ENTRY(4, ENMB_DMGEFF_STUN_ICE), + /* Light arrow */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Unk arrow 1 */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Unk arrow 2 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Unk arrow 3 */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Fire magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Ice magic */ DMG_ENTRY(3, ENMB_DMGEFF_STUN_ICE), + /* Light magic */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Shield */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Mirror Ray */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Kokiri spin */ DMG_ENTRY(1, ENMB_DMGEFF_DEFAULT), + /* Giant spin */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Master spin */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Kokiri jump */ DMG_ENTRY(2, ENMB_DMGEFF_DEFAULT), + /* Giant jump */ DMG_ENTRY(8, ENMB_DMGEFF_DEFAULT), + /* Master jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Unknown 1 */ DMG_ENTRY(0, ENMB_DMGEFF_FREEZE), + /* Unblockable */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), + /* Hammer jump */ DMG_ENTRY(4, ENMB_DMGEFF_DEFAULT), + /* Unknown 2 */ DMG_ENTRY(0, ENMB_DMGEFF_IGNORE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x4A, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 5300, ICHAIN_STOP), +}; + +void EnMb_SetupAction(EnMb* pthis, EnMbActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnMb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMb* pthis = (EnMb*)thisx; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s16 relYawFromPlayer; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 46.0f); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.colChkInfo.damageTable = &sSpearMoblinDamageTable; + Collider_InitCylinder(globalCtx, &pthis->hitbox); + Collider_SetCylinder(globalCtx, &pthis->hitbox, &pthis->actor, &sHitboxInit); + Collider_InitTris(globalCtx, &pthis->frontShielding); + Collider_SetTris(globalCtx, &pthis->frontShielding, &pthis->actor, &sFrontShieldingInit, pthis->frontShieldingTris); + Collider_InitQuad(globalCtx, &pthis->attackCollider); + Collider_SetQuad(globalCtx, &pthis->attackCollider, &pthis->actor, &sAttackColliderInit); + + switch (pthis->actor.params) { + case ENMB_TYPE_SPEAR_GUARD: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gEnMbSpearSkel, &gEnMbSpearStandStillAnim, + pthis->jointTable, pthis->morphTable, 28); + pthis->actor.colChkInfo.health = 2; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->maxHomeDist = 1000.0f; + pthis->playerDetectionRange = 1750.0f; + EnMb_SetupSpearGuardLookAround(pthis); + break; + case ENMB_TYPE_CLUB: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gEnMbClubSkel, &gEnMbClubStandStillClubDownAnim, + pthis->jointTable, pthis->morphTable, 28); + + pthis->actor.colChkInfo.health = 6; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.colChkInfo.damageTable = &sClubMoblinDamageTable; + Actor_SetScale(&pthis->actor, 0.02f); + pthis->hitbox.dim.height = 170; + pthis->hitbox.dim.radius = 45; + pthis->actor.uncullZoneForward = 4000.0f; + pthis->actor.uncullZoneScale = 800.0f; + pthis->actor.uncullZoneDownward = 1800.0f; + pthis->playerDetectionRange = 710.0f; + pthis->attackCollider.info.toucher.dmgFlags = 0x20000000; + + relYawFromPlayer = + pthis->actor.world.rot.y - Math_Vec3f_Yaw(&pthis->actor.world.pos, &player->actor.world.pos); + if (ABS(relYawFromPlayer) > 0x4000) { + pthis->actor.world.rot.y = thisx->world.rot.y + 0x8000; + pthis->actor.shape.rot.y = thisx->world.rot.y; + pthis->actor.world.pos.z = thisx->world.pos.z + 600.0f; + } + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.naviEnemyId += 1; + EnMb_SetupClubWaitPlayerNear(pthis); + break; + default: /* Spear Patrol */ + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gEnMbSpearSkel, &gEnMbSpearStandStillAnim, + pthis->jointTable, pthis->morphTable, 28); + + Actor_SetScale(&pthis->actor, 0.014f); + pthis->path = (thisx->params & 0xFF00) >> 8; + pthis->actor.params = ENMB_TYPE_SPEAR_PATROL; + pthis->waypoint = 0; + pthis->actor.colChkInfo.health = 1; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->maxHomeDist = 350.0f; + pthis->playerDetectionRange = 1750.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnMb_SetupSpearPatrolTurnTowardsWaypoint(pthis, globalCtx); + break; + } +} + +void EnMb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMb* pthis = (EnMb*)thisx; + + Collider_DestroyTris(globalCtx, &pthis->frontShielding); + Collider_DestroyCylinder(globalCtx, &pthis->hitbox); + Collider_DestroyQuad(globalCtx, &pthis->attackCollider); +} + +void EnMb_FaceWaypoint(EnMb* pthis, GlobalContext* globalCtx) { + s16 yawToWaypoint = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->waypointPos); + + pthis->actor.shape.rot.y = yawToWaypoint; + pthis->actor.world.rot.y = yawToWaypoint; +} + +void EnMb_NextWaypoint(EnMb* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* waypointPos; + + path = &globalCtx->setupPathList[pthis->path]; + + if (pthis->waypoint == 0) { + pthis->direction = 1; + } else if (pthis->waypoint == (s8)(path->count - 1)) { + pthis->direction = -1; + } + + pthis->waypoint += pthis->direction; + waypointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + pthis->waypoint; + pthis->waypointPos.x = waypointPos->x; + pthis->waypointPos.y = waypointPos->y; + pthis->waypointPos.z = waypointPos->z; +} + +/** + * Checks if the player is in a 800*74 units XZ area centered on pthis actor, + * the area being directed along its line of sight snapped to a cardinal angle. + * Note: the longest corridor in Sacred Forest Meadows is 800 units long, + * and they all are 100 units wide. + */ +s32 EnMb_IsPlayerInCorridor(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xFromPlayer; + f32 zFromPlayer; + f32 cos; + f32 sin; + f32 xFromPlayerAbs; + f32 zFromPlayerAbs; + s16 alignedYaw = 0; + + if ((pthis->actor.world.rot.y < -0x62A2) || (pthis->actor.world.rot.y > 0x62A2)) { + alignedYaw = -0x8000; + } else if (pthis->actor.world.rot.y < -0x20E0) { + alignedYaw = -0x4000; + } else if (pthis->actor.world.rot.y > 0x20E0) { + alignedYaw = 0x4000; + } + + cos = Math_CosS(alignedYaw); + sin = Math_SinS(alignedYaw); + cos = ABS(cos); + sin = ABS(sin); + xFromPlayer = pthis->actor.world.pos.x - player->actor.world.pos.x; + zFromPlayer = pthis->actor.world.pos.z - player->actor.world.pos.z; + xFromPlayerAbs = ABS(xFromPlayer); + if (xFromPlayerAbs < (cos * 37.0f + sin * 400.0f)) { + zFromPlayerAbs = ABS(zFromPlayer); + if (zFromPlayerAbs < (sin * 37.0f + cos * 400.0f)) { + return true; + } + } + return false; +} + +void EnMb_FindWaypointTowardsPlayer(EnMb* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->path]; + s16 yawToWaypoint; + Vec3f waypointPosF; + Vec3s* waypointPosS; + s16 yawPlayerToWaypoint; + s32 i; + s32 waypoint; + + for (waypoint = 0, i = path->count - 1; i >= 0; i--, waypoint++) { + waypointPosS = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + waypoint; + waypointPosF.x = waypointPosS->x; + waypointPosF.y = waypointPosS->y; + waypointPosF.z = waypointPosS->z; + yawToWaypoint = Math_Vec3f_Yaw(&pthis->actor.world.pos, &waypointPosF); + yawPlayerToWaypoint = yawToWaypoint - pthis->actor.yawTowardsPlayer; + if (ABS(yawPlayerToWaypoint) <= 0x1770) { + pthis->actor.world.rot.y = yawToWaypoint; + if (waypoint == pthis->waypoint) { + pthis->direction = -pthis->direction; + } + pthis->waypointPos = waypointPosF; + pthis->waypoint = waypoint; + break; + } + } +} + +void EnMb_SetupSpearGuardLookAround(EnMb* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gEnMbSpearLookLeftAndRightAnim, -4.0f); + pthis->actor.speedXZ = 0.0f; + pthis->timer1 = Rand_S16Offset(30, 50); + pthis->state = ENMB_STATE_IDLE; + EnMb_SetupAction(pthis, EnMb_SpearGuardLookAround); +} + +void EnMb_SetupClubWaitPlayerNear(EnMb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gEnMbClubStandStillClubDownAnim); + pthis->actor.speedXZ = 0.0f; + pthis->timer1 = Rand_S16Offset(30, 50); + pthis->state = ENMB_STATE_IDLE; + EnMb_SetupAction(pthis, EnMb_ClubWaitPlayerNear); +} + +void EnMb_SetupSpearPatrolTurnTowardsWaypoint(EnMb* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &gEnMbSpearLookLeftAndRightAnim, -4.0f); + pthis->actor.speedXZ = 0.0f; + pthis->timer1 = Rand_S16Offset(40, 80); + pthis->state = ENMB_STATE_IDLE; + EnMb_NextWaypoint(pthis, globalCtx); + EnMb_SetupAction(pthis, EnMb_SpearPatrolTurnTowardsWaypoint); +} + +void EnMb_SetupSpearGuardWalk(EnMb* pthis) { + Animation_Change(&pthis->skelAnime, &gEnMbSpearWalkAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gEnMbSpearWalkAnim), + ANIMMODE_LOOP, -4.0f); + pthis->actor.speedXZ = 0.59999996f; + pthis->timer1 = Rand_S16Offset(50, 70); + pthis->unk_332 = 1; + pthis->state = ENMB_STATE_WALK; + EnMb_SetupAction(pthis, EnMb_SpearGuardWalk); +} + +void EnMb_SetupSpearPatrolWalkTowardsWaypoint(EnMb* pthis) { + f32 frameCount = Animation_GetLastFrame(&gEnMbSpearWalkAnim); + + pthis->actor.speedXZ = 0.59999996f; + pthis->timer1 = Rand_S16Offset(50, 70); + pthis->unk_332 = 1; + pthis->state = ENMB_STATE_WALK; + Animation_Change(&pthis->skelAnime, &gEnMbSpearWalkAnim, 0.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); + EnMb_SetupAction(pthis, EnMb_SpearPatrolWalkTowardsWaypoint); +} + +void EnMb_SetupSpearPrepareAndCharge(EnMb* pthis) { + f32 frameCount = Animation_GetLastFrame(&gEnMbSpearPrepareChargeAnim); + + Animation_MorphToPlayOnce(&pthis->skelAnime, &gEnMbSpearPrepareChargeAnim, -4.0f); + pthis->state = ENMB_STATE_ATTACK; + pthis->actor.speedXZ = 0.0f; + pthis->timer3 = (s16)frameCount + 6; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_SPEAR_AT); + if (pthis->actor.params == ENMB_TYPE_SPEAR_GUARD) { + EnMb_SetupAction(pthis, EnMb_SpearGuardPrepareAndCharge); + } else { + EnMb_SetupAction(pthis, EnMb_SpearPatrolPrepareAndCharge); + } +} + +void EnMb_SetupSpearPatrolImmediateCharge(EnMb* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gEnMbSpearChargeAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_ATTACK); + pthis->attack = ENMB_ATTACK_SPEAR; + pthis->state = ENMB_STATE_ATTACK; + pthis->timer3 = 3; + pthis->actor.speedXZ = 10.0f; + EnMb_SetupAction(pthis, EnMb_SpearPatrolImmediateCharge); +} + +void EnMb_SetupClubAttack(EnMb* pthis) { + f32 frames = Animation_GetLastFrame(&gEnMbClubLiftClubAnim); + s16 relYawFromPlayer; + + pthis->state = ENMB_STATE_ATTACK; + Animation_Change(&pthis->skelAnime, &gEnMbClubLiftClubAnim, 3.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, 0.0f); + pthis->timer3 = 1; + relYawFromPlayer = pthis->actor.world.rot.y - pthis->actor.yawTowardsPlayer; + + if (ABS(relYawFromPlayer) <= 0x258) { + pthis->attack = ENMB_ATTACK_CLUB_MIDDLE; + } else if (relYawFromPlayer >= 0) { + pthis->attack = ENMB_ATTACK_CLUB_RIGHT; + } else { + pthis->attack = ENMB_ATTACK_CLUB_LEFT; + } + + EnMb_SetupAction(pthis, EnMb_ClubAttack); +} + +void EnMb_SetupSpearEndChargeQuick(EnMb* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gEnMbSpearSlowDownAnim); + pthis->state = ENMB_STATE_ATTACK_END; + pthis->timer1 = 0; + pthis->timer3 = 5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_SLIDE); + EnMb_SetupAction(pthis, EnMb_SpearEndChargeQuick); +} + +void EnMb_SetupSpearPatrolEndCharge(EnMb* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gEnMbSpearSlowDownAnim); + pthis->state = ENMB_STATE_ATTACK_END; + pthis->actor.bgCheckFlags &= ~1; + pthis->timer1 = 0; + pthis->timer3 = 50; + pthis->actor.speedXZ = -8.0f; + pthis->actor.velocity.y = 6.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_SLIDE); + EnMb_SetupAction(pthis, EnMb_SpearPatrolEndCharge); +} + +void EnMb_SetupClubWaitAfterAttack(EnMb* pthis) { + f32 frameCount = Animation_GetLastFrame(&gEnMbClubStandStillClubDownAnim); + + pthis->state = ENMB_STATE_ATTACK_END; + Animation_Change(&pthis->skelAnime, &gEnMbClubStandStillClubDownAnim, 5.0f, 0.0f, frameCount, ANIMMODE_ONCE_INTERP, + 0.0f); + EnMb_SetupAction(pthis, EnMb_ClubWaitAfterAttack); +} + +void EnMb_SetupClubDamaged(EnMb* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gEnMbClubDamagedKneelAnim); + pthis->state = ENMB_STATE_CLUB_KNEELING; + pthis->timer1 = 0; + pthis->timer3 = 20; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DEAD); + EnMb_SetupAction(pthis, EnMb_ClubDamaged); +} + +void EnMb_SetupClubDamagedWhileKneeling(EnMb* pthis) { + f32 frames = Animation_GetLastFrame(&gEnMbClubBeatenKneelingAnim); + + pthis->state = ENMB_STATE_CLUB_KNEELING_DAMAGED; + pthis->timer1 = 0; + pthis->timer3 = 6; + Animation_Change(&pthis->skelAnime, &gEnMbClubBeatenKneelingAnim, 1.0f, 4.0f, frames, ANIMMODE_ONCE_INTERP, 0.0f); + EnMb_SetupAction(pthis, EnMb_ClubDamagedWhileKneeling); +} + +void EnMb_SetupClubDead(EnMb* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gEnMbClubFallOnItsBackAnim, -4.0f); + pthis->state = ENMB_STATE_CLUB_DEAD; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->hitbox.dim.height = 80; + pthis->hitbox.dim.radius = 95; + pthis->timer1 = 30; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DEAD); + EnMb_SetupAction(pthis, EnMb_ClubDead); +} + +void EnMb_SetupStunned(EnMb* pthis) { + pthis->state = ENMB_STATE_STUNNED; + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 0x78, 0, 0x50); + if (pthis->damageEffect == ENMB_DMGEFF_STUN_ICE) { + pthis->iceEffectTimer = 40; + } else { + if (pthis->actor.params != ENMB_TYPE_CLUB) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gEnMbSpearDamagedFromFrontAnim, 0.0f); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + } + EnMb_SetupAction(pthis, EnMb_Stunned); +} + +void EnMb_Stunned(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags2 & 0x80) && player->actor.parent == &pthis->actor) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.world.rot.y, 4.0f); + pthis->attack = ENMB_ATTACK_NONE; + } + + if (pthis->actor.colorFilterTimer == 0) { + if (pthis->actor.params == ENMB_TYPE_CLUB) { + if (pthis->actor.colChkInfo.health == 0) { + EnMb_SetupClubDead(pthis); + } else if (pthis->state == ENMB_STATE_CLUB_KNEELING) { + /* dead code: the setup for pthis action sets state to something else */ + EnMb_SetupClubDamagedWhileKneeling(pthis); + } else { + EnMb_SetupClubWaitPlayerNear(pthis); + } + } else { + if (pthis->actor.colChkInfo.health == 0) { + EnMb_SetupSpearDead(pthis); + } else { + EnMb_SetupSpearDamaged(pthis); + } + } + } +} + +void EnMb_SpearGuardLookAround(EnMb* pthis, GlobalContext* globalCtx) { + s16 timer1; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer1 == 0) { + timer1 = 0; + } else { + pthis->timer1--; + timer1 = pthis->timer1; + } + if (timer1 == 0 && Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + EnMb_SetupSpearGuardWalk(pthis); + } +} + +void EnMb_SpearPatrolTurnTowardsWaypoint(EnMb* pthis, GlobalContext* globalCtx) { + s16 relYawFromPlayer; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer1 == 0) { + pthis->yawToWaypoint = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->waypointPos); + if (Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->yawToWaypoint, 1, 0x3E8, 0) == 0) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnMb_SetupSpearPatrolWalkTowardsWaypoint(pthis); + } + } else { + pthis->timer1--; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, 1, 0x3E8, 0); + } + + if (ABS(pthis->actor.yDistToPlayer) <= 20.0f && EnMb_IsPlayerInCorridor(pthis, globalCtx)) { + relYawFromPlayer = pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer; + if (ABS(relYawFromPlayer) <= 0x4000 || (func_8002DDE4(globalCtx) && pthis->actor.xzDistToPlayer < 160.0f)) { + EnMb_FindWaypointTowardsPlayer(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_VOICE); + EnMb_SetupSpearPrepareAndCharge(pthis); + } + } +} + +/** + * Slow down and resume walking. + */ +void EnMb_SpearEndChargeQuick(EnMb* pthis, GlobalContext* globalCtx) { + s32 pad; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.5f, 1.0f, 0.0f); + if (pthis->actor.speedXZ > 1.0f) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); + } + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer1 == 0) { + pthis->timer3--; + if (pthis->timer3 == 0) { + /* Play the charge animation in reverse: let go of the spear and stand normally */ + Animation_Change(&pthis->skelAnime, &gEnMbSpearPrepareChargeAnim, -1.0f, + Animation_GetLastFrame(&gEnMbSpearPrepareChargeAnim), 0.0f, ANIMMODE_ONCE, 0.0f); + pthis->timer1 = 1; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_SPEAR_NORM); + } + } else { + if (pthis->actor.params <= ENMB_TYPE_SPEAR_GUARD) { + EnMb_SetupSpearGuardWalk(pthis); + pthis->timer1 = pthis->timer2 = pthis->timer3 = 80; + } else { + EnMb_SetupSpearPatrolTurnTowardsWaypoint(pthis, globalCtx); + } + } + } +} + +void EnMb_ClubWaitAfterAttack(EnMb* pthis, GlobalContext* globalCtx) { + pthis->attack = ENMB_ATTACK_NONE; + if (SkelAnime_Update(&pthis->skelAnime)) { + EnMb_SetupClubWaitPlayerNear(pthis); + } +} + +/** + * Slow down, charge again if the player is near, or resume walking. + */ +void EnMb_SpearPatrolEndCharge(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 lastFrame; + s16 relYawFromPlayer; + s16 yawPlayerToWaypoint; + + if ((player->stateFlags2 & 0x80) && player->actor.parent == &pthis->actor) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.world.rot.y, 4.0f); + } + + if (pthis->actor.bgCheckFlags & 1) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); + + if (pthis->actor.speedXZ > 1.0f) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); + } + + if (pthis->timer1 != 0) { + pthis->timer3--; + if (pthis->timer3 == 0) { + relYawFromPlayer = pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer; + + if (ABS(pthis->actor.yDistToPlayer) <= 20.0f && EnMb_IsPlayerInCorridor(pthis, globalCtx) && + ABS(relYawFromPlayer) <= 0x4000 && pthis->actor.xzDistToPlayer <= 200.0f) { + EnMb_SetupSpearPrepareAndCharge(pthis); + } else { + lastFrame = Animation_GetLastFrame(&gEnMbSpearPrepareChargeAnim); + /* Play the charge animation in reverse: let go of the spear and stand normally */ + Animation_Change(&pthis->skelAnime, &gEnMbSpearPrepareChargeAnim, -1.0f, lastFrame, 0.0f, + ANIMMODE_ONCE, 0.0f); + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_SPEAR_NORM); + } + } else { + if (pthis->actor.xzDistToPlayer <= 160.0f) { + pthis->actor.speedXZ = -5.0f; + } else { + pthis->actor.speedXZ = 0.0f; + } + } + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer1 == 0) { + lastFrame = Animation_GetLastFrame(&gEnMbSpearChargeAnim); + Animation_Change(&pthis->skelAnime, &gEnMbSpearChargeAnim, 0.5f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, + 0.0f); + pthis->timer1 = 1; + } else { + yawPlayerToWaypoint = + Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->waypointPos) - pthis->actor.yawTowardsPlayer; + + if (ABS(yawPlayerToWaypoint) <= 0x4000) { + EnMb_SetupSpearPatrolTurnTowardsWaypoint(pthis, globalCtx); + } else { + EnMb_SetupSpearPatrolWalkTowardsWaypoint(pthis); + } + } + } + } +} + +/** + * Prepare charge (animation), then charge until the player isn't in front. + */ +void EnMb_SpearGuardPrepareAndCharge(EnMb* pthis, GlobalContext* globalCtx) { + s32 prevFrame; + s16 relYawTowardsPlayerAbs = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (relYawTowardsPlayerAbs < 0) { + relYawTowardsPlayerAbs = -relYawTowardsPlayerAbs; + } + + prevFrame = pthis->skelAnime.curFrame; + + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_PlayLoop(&pthis->skelAnime, &gEnMbSpearChargeAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_ATTACK); + } + + if (pthis->timer3 != 0) { + pthis->timer3--; + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xBB8, 0); + } else { + pthis->actor.speedXZ = 10.0f; + pthis->attack = ENMB_ATTACK_SPEAR; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); + if (prevFrame != (s32)pthis->skelAnime.curFrame && + ((s32)pthis->skelAnime.curFrame == 2 || (s32)pthis->skelAnime.curFrame == 6)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DASH); + } + } + + if (relYawTowardsPlayerAbs > 0x1388) { + pthis->attack = ENMB_ATTACK_NONE; + EnMb_SetupSpearEndChargeQuick(pthis); + } +} + +void EnMb_ClubAttack(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + Vec3f effSpawnPos; + Vec3f effWhiteShockwaveDynamics = { 0.0f, 0.0f, 0.0f }; + f32 flamesParams[] = { 18.0f, 18.0f, 0.0f }; + s16 flamesUnused[] = { 20, 40, 0 }; + s16 relYawTarget[] = { -0x9C4, 0, 0xDAC }; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, relYawTarget[pthis->attack - 1] + pthis->actor.world.rot.y, 1, 0x2EE, 0); + + if (pthis->attackCollider.base.atFlags & AT_HIT) { + pthis->attackCollider.base.atFlags &= ~AT_HIT; + if (pthis->attackCollider.base.at == &player->actor) { + u8 prevPlayerInvincibilityTimer = player->invincibilityTimer; + + if (player->invincibilityTimer < 0) { + if (player->invincibilityTimer <= -40) { + player->invincibilityTimer = 0; + } else { + player->invincibilityTimer = 0; + globalCtx->damagePlayer(globalCtx, -8); + } + } + + func_8002F71C(globalCtx, &pthis->actor, (650.0f - pthis->actor.xzDistToPlayer) * 0.04f + 4.0f, + pthis->actor.world.rot.y, 8.0f); + + player->invincibilityTimer = prevPlayerInvincibilityTimer; + } + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer3 != 0) { + pthis->timer3--; + if (pthis->timer3 == 0) { + f32 lastAnimFrame = Animation_GetLastFrame(&gEnMbClubStrikeDownAnim); + Animation_Change(&pthis->skelAnime, &gEnMbClubStrikeDownAnim, 1.5f, 0.0f, lastAnimFrame, + ANIMMODE_ONCE_INTERP, 0.0f); + } + } else { + effSpawnPos = pthis->effSpawnPos; + effSpawnPos.y = pthis->actor.floorHeight; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MONBLIN_HAM_LAND); + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + EffectSsBlast_SpawnWhiteShockwave(globalCtx, &effSpawnPos, &effWhiteShockwaveDynamics, + &effWhiteShockwaveDynamics); + func_80033480(globalCtx, &effSpawnPos, 2.0f, 3, 0x12C, 0xB4, 1); + Camera_AddQuake(&globalCtx->mainCamera, 2, 0x19, 5); + func_800358DC(&pthis->actor, &effSpawnPos, &pthis->actor.world.rot, flamesParams, 20, flamesUnused, globalCtx, + -1, 0); + EnMb_SetupClubWaitAfterAttack(pthis); + } + } else { + if (pthis->timer3 != 0 && pthis->skelAnime.curFrame == 6.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MONBLIN_HAM_UP); + + } else if (pthis->timer3 == 0 && pthis->skelAnime.curFrame == 3.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MONBLIN_HAM_DOWN); + } + } +} + +/** + * Prepare charge (animation), then charge to the end of the floor collision. + */ +void EnMb_SpearPatrolPrepareAndCharge(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 prevFrame; + s32 hasHitPlayer = false; + s32 endCharge = !Actor_TestFloorInDirection(&pthis->actor, globalCtx, 110.0f, pthis->actor.world.rot.y); + + prevFrame = (s32)pthis->skelAnime.curFrame; + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_PlayLoop(&pthis->skelAnime, &gEnMbSpearChargeAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_ATTACK); + } + + if (pthis->timer3 != 0) { + pthis->timer3--; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 1, 0x1F40, 0); + endCharge = false; + } else { + pthis->actor.speedXZ = 10.0f; + pthis->attack = ENMB_ATTACK_SPEAR; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); + if (prevFrame != (s32)pthis->skelAnime.curFrame && + ((s32)pthis->skelAnime.curFrame == 2 || (s32)pthis->skelAnime.curFrame == 6)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DASH); + } + } + + if (pthis->attackCollider.base.atFlags & AT_HIT) { + if (pthis->attackCollider.base.at == &player->actor) { + if (!endCharge && !(player->stateFlags2 & 0x80)) { + if (player->invincibilityTimer < 0) { + if (player->invincibilityTimer < -39) { + player->invincibilityTimer = 0; + } else { + player->invincibilityTimer = 0; + globalCtx->damagePlayer(globalCtx, -8); + } + } + if (!(pthis->attackCollider.base.atFlags & AT_BOUNCED)) { + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + if (globalCtx->grabPlayer(globalCtx, player)) { + player->actor.parent = &pthis->actor; + } + } + hasHitPlayer = true; + } else { + pthis->attackCollider.base.atFlags &= ~AT_HIT; + } + } + + if ((player->stateFlags2 & 0x80) && player->actor.parent == &pthis->actor) { + player->actor.world.pos.x = pthis->actor.world.pos.x + Math_CosS(pthis->actor.shape.rot.y) * 10.0f + + Math_SinS(pthis->actor.shape.rot.y) * 89.0f; + hasHitPlayer = true; + player->actor.world.pos.z = pthis->actor.world.pos.z + Math_SinS(pthis->actor.shape.rot.y) * 10.0f + + Math_CosS(pthis->actor.shape.rot.y) * 89.0f; + player->unk_850 = 0; + player->actor.speedXZ = 0.0f; + player->actor.velocity.y = 0.0f; + } + + if (endCharge) { + if (hasHitPlayer || (player->stateFlags2 & 0x80)) { + pthis->attackCollider.base.atFlags &= ~AT_HIT; + if (player->stateFlags2 & 0x80) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.world.rot.y, 4.0f); + } + } + pthis->attack = ENMB_ATTACK_NONE; + pthis->actor.speedXZ = -10.0f; + EnMb_SetupSpearPatrolEndCharge(pthis); + } +} + +/** + * Charge and follow the path, until hitting the player or, after some time, reaching home. + */ +void EnMb_SpearPatrolImmediateCharge(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 prevFrame; + s32 hasHitPlayer = false; + s32 endCharge = !Actor_TestFloorInDirection(&pthis->actor, globalCtx, 110.0f, pthis->actor.world.rot.y); + + prevFrame = (s32)pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 5.0f, 3, 4.0f, 100, 15, false); + if (prevFrame != (s32)pthis->skelAnime.curFrame && + ((s32)pthis->skelAnime.curFrame == 2 || (s32)pthis->skelAnime.curFrame == 6)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DASH); + } + + if (pthis->attackCollider.base.atFlags & AT_HIT) { + if (pthis->attackCollider.base.at == &player->actor) { + if (!endCharge && !(player->stateFlags2 & 0x80)) { + if (player->invincibilityTimer < 0) { + if (player->invincibilityTimer <= -40) { + player->invincibilityTimer = 0; + } else { + player->invincibilityTimer = 0; + globalCtx->damagePlayer(globalCtx, -8); + } + } + if (!(pthis->attackCollider.base.atFlags & AT_BOUNCED)) { + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + if (globalCtx->grabPlayer(globalCtx, player)) { + player->actor.parent = &pthis->actor; + } + } + hasHitPlayer = true; + } else { + pthis->attackCollider.base.atFlags &= ~AT_HIT; + } + } + + if ((player->stateFlags2 & 0x80) && player->actor.parent == &pthis->actor) { + player->actor.world.pos.x = pthis->actor.world.pos.x + Math_CosS(pthis->actor.shape.rot.y) * 10.0f + + Math_SinS(pthis->actor.shape.rot.y) * 89.0f; + hasHitPlayer = true; + player->actor.world.pos.z = pthis->actor.world.pos.z + Math_SinS(pthis->actor.shape.rot.y) * 10.0f + + Math_CosS(pthis->actor.shape.rot.y) * 89.0f; + player->unk_850 = 0; + player->actor.speedXZ = 0.0f; + player->actor.velocity.y = 0.0f; + } + + if (endCharge) { + if (hasHitPlayer || (player->stateFlags2 & 0x80)) { + pthis->attackCollider.base.atFlags &= ~AT_HIT; + if (player->stateFlags2 & 0x80) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.world.rot.y, 4.0f); + } + pthis->attack = ENMB_ATTACK_NONE; + pthis->actor.speedXZ = -10.0f; + EnMb_SetupSpearPatrolEndCharge(pthis); + pthis->timer3 = 1; + } else { + pthis->timer3--; + EnMb_NextWaypoint(pthis, globalCtx); + } + } + + EnMb_FaceWaypoint(pthis, globalCtx); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->timer3 == 0 && Math_Vec3f_DistXZ(&pthis->actor.home.pos, &pthis->actor.world.pos) < 80.0f) { + pthis->attack = ENMB_ATTACK_NONE; + EnMb_SetupSpearEndChargeQuick(pthis); + } +} + +void EnMb_ClubDamaged(EnMb* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer3 != 0) { + Animation_PlayOnce(&pthis->skelAnime, &gEnMbClubStandUpAnim); + pthis->timer3 = 0; + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + Camera_AddQuake(&globalCtx->mainCamera, 2, 25, 5); + } else { + EnMb_SetupClubWaitPlayerNear(pthis); + } + } +} + +void EnMb_ClubDamagedWhileKneeling(EnMb* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer3 != 0) { + pthis->timer3--; + if (pthis->timer3 == 0) { + if (pthis->timer1 == 0) { + Animation_Change(&pthis->skelAnime, &gEnMbClubStandUpAnim, 3.0f, 0.0f, + Animation_GetLastFrame(&gEnMbClubStandUpAnim), ANIMMODE_ONCE_INTERP, 0.0f); + pthis->timer1 = 1; + pthis->timer3 = 6; + } else { + Animation_Change(&pthis->skelAnime, &gEnMbClubStandUpAnim, 3.0f, 0.0f, + Animation_GetLastFrame(&gEnMbClubStandUpAnim), ANIMMODE_ONCE_INTERP, 0.0f); + } + } + } else { + EnMb_SetupClubWaitPlayerNear(pthis); + } + } +} + +void EnMb_ClubDead(EnMb* pthis, GlobalContext* globalCtx) { + Vec3f effPos; + Vec3f effPosBase; + + effPos = pthis->actor.world.pos; + effPos.x += Math_SinS(pthis->actor.shape.rot.y) * -70.0f; + effPos.z += Math_CosS(pthis->actor.shape.rot.y) * -70.0f; + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + effPosBase = effPos; + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer1 > 0) { + Vec3f effZeroVec = { 0.0f, 0.0f, 0.0f }; + s32 i; + + pthis->timer1--; + for (i = 4; i >= 0; i--) { + effPos.x = Rand_CenteredFloat(240.0f) + effPosBase.x; + effPos.y = Rand_CenteredFloat(15.0f) + (effPosBase.y + 20.0f); + effPos.z = Rand_CenteredFloat(240.0f) + effPosBase.z; + EffectSsDeadDb_Spawn(globalCtx, &effPos, &effZeroVec, &effZeroVec, 230, 7, 255, 255, 255, 255, 0, 255, + 0, 1, 9, true); + } + } else { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &effPos, 0xC0); + Actor_Kill(&pthis->actor); + } + } else if ((s32)pthis->skelAnime.curFrame == 15 || (s32)pthis->skelAnime.curFrame == 22) { + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &effPos, 50.0f, 10, 3.0f, 400, 60, false); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + Camera_AddQuake(&globalCtx->mainCamera, 2, 25, 5); + } +} + +/** + * Walk around the home point, face and charge the player if close. + */ +void EnMb_SpearGuardWalk(EnMb* pthis, GlobalContext* globalCtx) { + s32 prevFrame; + s32 beforeCurFrame; + s32 pad1; + s32 pad2; + Player* player = GET_PLAYER(globalCtx); + s16 relYawTowardsPlayer = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + s16 yawTowardsHome; + f32 playSpeedAbs; + + relYawTowardsPlayer = ABS(relYawTowardsPlayer); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.59999996f, 0.1f, 1.0f, 0.0f); + pthis->skelAnime.playSpeed = pthis->actor.speedXZ; + prevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + + playSpeedAbs = ABS(pthis->skelAnime.playSpeed); + beforeCurFrame = pthis->skelAnime.curFrame - playSpeedAbs; + playSpeedAbs = ABS(pthis->skelAnime.playSpeed); + if (pthis->timer3 == 0 && + Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < pthis->playerDetectionRange) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x2EE, 0); + pthis->actor.flags |= ACTOR_FLAG_0; + if (pthis->actor.xzDistToPlayer < 500.0f && relYawTowardsPlayer < 0x1388) { + EnMb_SetupSpearPrepareAndCharge(pthis); + } + } else { + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) > pthis->maxHomeDist || pthis->timer2 != 0) { + yawTowardsHome = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_SmoothStepToS(&pthis->actor.world.rot.y, yawTowardsHome, 1, 0x2EE, 0); + } + if (pthis->timer2 != 0) { + pthis->timer2--; + } + if (pthis->timer3 != 0) { + pthis->timer3--; + } + if (pthis->timer2 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_VOICE); + } + pthis->timer1--; + if (pthis->timer1 == 0) { + if (Rand_ZeroOne() > 0.7f) { + pthis->timer1 = Rand_S16Offset(50, 70); + pthis->timer2 = Rand_S16Offset(15, 40); + } else { + EnMb_SetupSpearGuardLookAround(pthis); + } + } + } + + if (prevFrame != (s32)pthis->skelAnime.curFrame) { + if ((beforeCurFrame <= 1 && prevFrame + (s32)playSpeedAbs >= 1) || + (beforeCurFrame <= 20 && prevFrame + (s32)playSpeedAbs >= 20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); + } + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnMb_SpearPatrolWalkTowardsWaypoint(EnMb* pthis, GlobalContext* globalCtx) { + s32 prevFrame; + s32 beforeCurFrame; + s16 relYawTowardsPlayer; + f32 yDistToPlayerAbs; + f32 playSpeedABS; + + if (Math_Vec3f_DistXZ(&pthis->waypointPos, &pthis->actor.world.pos) <= 8.0f || + (Rand_ZeroOne() < 0.1f && Math_Vec3f_DistXZ(&pthis->actor.home.pos, &pthis->actor.world.pos) <= 4.0f)) { + EnMb_SetupSpearPatrolTurnTowardsWaypoint(pthis, globalCtx); + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.59999996f, 0.1f, 1.0f, 0.0f); + pthis->skelAnime.playSpeed = 2.0f * pthis->actor.speedXZ; + } + + pthis->yawToWaypoint = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->waypointPos); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->yawToWaypoint, 1, 0x5DC, 0); + + yDistToPlayerAbs = (pthis->actor.yDistToPlayer >= 0.0f) ? pthis->actor.yDistToPlayer : -pthis->actor.yDistToPlayer; + if (yDistToPlayerAbs <= 20.0f && EnMb_IsPlayerInCorridor(pthis, globalCtx)) { + relYawTowardsPlayer = (pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer); + if (ABS(relYawTowardsPlayer) <= 0x4000 || (func_8002DDE4(globalCtx) && pthis->actor.xzDistToPlayer < 160.0f)) { + EnMb_FindWaypointTowardsPlayer(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_VOICE); + EnMb_SetupSpearPrepareAndCharge(pthis); + return; + } + } + + if (pthis->timer2 != 0) { + pthis->timer2--; + } + if (pthis->timer3 != 0) { + pthis->timer3--; + } + if (pthis->timer2 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_VOICE); + pthis->timer2 = Rand_S16Offset(30, 70); + } + + prevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + playSpeedABS = ABS(pthis->skelAnime.playSpeed); + beforeCurFrame = pthis->skelAnime.curFrame - playSpeedABS; + playSpeedABS = (pthis->skelAnime.playSpeed >= 0.0f) ? pthis->skelAnime.playSpeed : -pthis->skelAnime.playSpeed; + if (prevFrame != (s32)pthis->skelAnime.curFrame) { + if ((beforeCurFrame <= 1 && (s32)playSpeedABS + prevFrame >= 1) || + (beforeCurFrame <= 20 && (s32)playSpeedABS + prevFrame >= 20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); + } + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnMb_ClubWaitPlayerNear(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 relYawFromPlayer = pthis->actor.world.rot.y - pthis->actor.yawTowardsPlayer; + + SkelAnime_Update(&pthis->skelAnime); + if (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < pthis->playerDetectionRange && + !(player->stateFlags1 & 0x4000000) && ABS(relYawFromPlayer) < 0x3E80) { + EnMb_SetupClubAttack(pthis); + } +} + +void EnMb_SetupSpearDamaged(EnMb* pthis) { + s16 relYawTowardsPlayer = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(relYawTowardsPlayer) <= 0x4000) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gEnMbSpearDamagedFromFrontAnim, -4.0f); + pthis->actor.speedXZ = -8.0f; + } else { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gEnMbSpearDamagedFromBehindAnim, -4.0f); + pthis->actor.speedXZ = 8.0f; + } + + pthis->timer1 = 30; + pthis->state = ENMB_STATE_SPEAR_SPEARPATH_DAMAGED; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DEAD); + EnMb_SetupAction(pthis, EnMb_SpearDamaged); +} + +void EnMb_SpearDamaged(EnMb* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.params <= ENMB_TYPE_SPEAR_GUARD) { + EnMb_SetupSpearGuardLookAround(pthis); + } else { + EnMb_SetupSpearPatrolImmediateCharge(pthis); + } + } +} + +void EnMb_SetupSpearDead(EnMb* pthis) { + s16 relYawTowardsPlayer = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(relYawTowardsPlayer) <= 0x4000) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gEnMbSpearFallOnItsBackAnim, -4.0f); + pthis->actor.speedXZ = -8.0f; + } else { + /* The gEnMbSpearFallFaceDownAnim animation was probably meant to be used here */ + Animation_MorphToPlayOnce(&pthis->skelAnime, &gEnMbSpearFallOnItsBackAnim, -4.0f); + pthis->actor.speedXZ = 8.0f; + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->timer1 = 30; + pthis->state = ENMB_STATE_SPEAR_SPEARPATH_DAMAGED; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_DEAD); + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnMb_SetupAction(pthis, EnMb_SpearDead); +} + +void EnMb_SpearDead(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + + if ((player->stateFlags2 & 0x80) && player->actor.parent == &pthis->actor) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.world.rot.y, 4.0f); + pthis->attack = ENMB_ATTACK_NONE; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer1 > 0) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 i; + Vec3f effPos; + + pthis->actor.shape.shadowScale = 0.0f; + pthis->timer1--; + for (i = 4; i >= 0; i--) { + effPos.x = Rand_CenteredFloat(110.0f) + pthis->actor.world.pos.x; + effPos.y = Rand_CenteredFloat(15.0f) + (pthis->actor.world.pos.y + 20.0f); + effPos.z = Rand_CenteredFloat(110.0f) + pthis->actor.world.pos.z; + + EffectSsDeadDb_Spawn(globalCtx, &effPos, &zeroVec, &zeroVec, 100, 7, 255, 255, 255, 255, 0, 255, 0, 1, + 9, true); + } + } else { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xE0); + Actor_Kill(&pthis->actor); + } + } +} + +void EnMb_SpearUpdateAttackCollider(Actor* thisx, GlobalContext* globalCtx) { + Vec3f quadModel0 = { 1000.0f, 1500.0f, 0.0f }; + Vec3f quadModel1 = { -1000.0f, 1500.0f, 0.0f }; + Vec3f quadModel2 = { 1000.0f, 1500.0f, 4500.0f }; + Vec3f quadModel3 = { -1000.0f, 1500.0f, 4500.0f }; + EnMb* pthis = (EnMb*)thisx; + + if (pthis->actor.params >= ENMB_TYPE_SPEAR_PATROL) { + quadModel0.x += 2000.0f; + quadModel0.z = -4000.0f; + quadModel1.z = -4000.0f; + quadModel2.x += 2000.0f; + quadModel1.x -= 2000.0f; + quadModel3.x -= 2000.0f; + quadModel2.z += 4000.0f; + quadModel3.z += 4000.0f; + } + Matrix_MultVec3f(&quadModel0, &pthis->attackCollider.dim.quad[1]); + Matrix_MultVec3f(&quadModel1, &pthis->attackCollider.dim.quad[0]); + Matrix_MultVec3f(&quadModel2, &pthis->attackCollider.dim.quad[3]); + Matrix_MultVec3f(&quadModel3, &pthis->attackCollider.dim.quad[2]); + Collider_SetQuadVertices(&pthis->attackCollider, &pthis->attackCollider.dim.quad[0], + &pthis->attackCollider.dim.quad[1], &pthis->attackCollider.dim.quad[2], + &pthis->attackCollider.dim.quad[3]); +} + +void EnMb_ClubUpdateAttackCollider(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f quadModel[] = { { 1000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 0.0f }, + { 1000.0f, -8000.0f, -1500.0f }, + { 1000.0f, -9000.0f, 2000.0f } }; + EnMb* pthis = (EnMb*)thisx; + + Matrix_MultVec3f(&quadModel[0], &pthis->attackCollider.dim.quad[1]); + Matrix_MultVec3f(&quadModel[1], &pthis->attackCollider.dim.quad[0]); + Matrix_MultVec3f(&quadModel[2], &pthis->attackCollider.dim.quad[3]); + Matrix_MultVec3f(&quadModel[3], &pthis->attackCollider.dim.quad[2]); + Collider_SetQuadVertices(&pthis->attackCollider, &pthis->attackCollider.dim.quad[0], + &pthis->attackCollider.dim.quad[1], &pthis->attackCollider.dim.quad[2], + &pthis->attackCollider.dim.quad[3]); +} + +void EnMb_CheckColliding(EnMb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->frontShielding.base.acFlags & AC_HIT) { + pthis->frontShielding.base.acFlags &= ~(AC_HIT | AC_BOUNCED); + pthis->hitbox.base.acFlags &= ~AC_HIT; + } else if ((pthis->hitbox.base.acFlags & AC_HIT) && pthis->state >= ENMB_STATE_STUNNED) { + pthis->hitbox.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != ENMB_DMGEFF_IGNORE && + pthis->actor.colChkInfo.damageEffect != ENMB_DMGEFF_FREEZE) { + if ((player->stateFlags2 & 0x80) && player->actor.parent == &pthis->actor) { + player->stateFlags2 &= ~0x80; + player->actor.parent = NULL; + player->unk_850 = 200; + func_8002F71C(globalCtx, &pthis->actor, 6.0f, pthis->actor.world.rot.y, 6.0f); + } + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + pthis->attack = ENMB_ATTACK_NONE; + Actor_SetDropFlag(&pthis->actor, &pthis->hitbox.info, false); + if (pthis->actor.colChkInfo.damageEffect == ENMB_DMGEFF_STUN || + pthis->actor.colChkInfo.damageEffect == ENMB_DMGEFF_STUN_ICE) { + if (pthis->state != ENMB_STATE_STUNNED) { + Actor_ApplyDamage(&pthis->actor); + EnMb_SetupStunned(pthis); + } + } else { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFA, 0, 0xC); + if (pthis->actor.params == ENMB_TYPE_CLUB) { + if (pthis->actor.colChkInfo.health == 0) { + EnMb_SetupClubDead(pthis); + } else if (pthis->state != ENMB_STATE_CLUB_KNEELING) { + EnMb_SetupClubDamaged(pthis); + } + } else { + if (pthis->actor.colChkInfo.health == 0) { + EnMb_SetupSpearDead(pthis); + } else { + EnMb_SetupSpearDamaged(pthis); + } + } + } + } + } +} + +void EnMb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMb* pthis = (EnMb*)thisx; + s32 pad; + + EnMb_CheckColliding(pthis, globalCtx); + if (thisx->colChkInfo.damageEffect != ENMB_DMGEFF_FREEZE) { + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 40.0f, 40.0f, 70.0f, 0x1D); + Actor_SetFocus(thisx, thisx->scale.x * 4500.0f); + Collider_UpdateCylinder(thisx, &pthis->hitbox); + if (thisx->colChkInfo.health <= 0) { + pthis->hitbox.dim.pos.x += Math_SinS(thisx->shape.rot.y) * (-4400.0f * thisx->scale.y); + pthis->hitbox.dim.pos.z += Math_CosS(thisx->shape.rot.y) * (-4400.0f * thisx->scale.y); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->hitbox.base); + if (pthis->state >= ENMB_STATE_STUNNED && + (thisx->params == ENMB_TYPE_CLUB || pthis->state != ENMB_STATE_ATTACK)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->hitbox.base); + } + if (pthis->state >= ENMB_STATE_IDLE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->frontShielding.base); + } + if (pthis->attack > ENMB_ATTACK_NONE) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->attackCollider.base); + } + } +} + +void EnMb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f unused = { 1100.0f, -700.0f, 0.0f }; + static Vec3f feetPos = { 0.0f, 0.0f, 0.0f }; + static Vec3f effSpawnPosModel = { 0.0f, -8000.0f, 0.0f }; + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 bodyPart = -1; + EnMb* pthis = (EnMb*)thisx; + Vec3f bodyPartPos; + + if (pthis->actor.params == ENMB_TYPE_CLUB) { + if (limbIndex == ENMB_LIMB_LHAND) { + Matrix_MultVec3f(&effSpawnPosModel, &pthis->effSpawnPos); + if (pthis->attack > ENMB_ATTACK_NONE) { + EnMb_ClubUpdateAttackCollider(&pthis->actor, globalCtx); + } + } + Actor_SetFeetPos(&pthis->actor, limbIndex, ENMB_LIMB_LFOOT, &feetPos, ENMB_LIMB_RFOOT, &feetPos); + } + + if (pthis->iceEffectTimer != 0) { + switch (limbIndex) { + case ENMB_LIMB_HEAD: + bodyPart = 0; + break; + case ENMB_LIMB_LHAND: + bodyPart = 1; + break; + case ENMB_LIMB_RHAND: + bodyPart = 2; + break; + case ENMB_LIMB_LSHOULDER: + bodyPart = 3; + break; + case ENMB_LIMB_RSHOULDER: + bodyPart = 4; + break; + case ENMB_LIMB_CHEST: + bodyPart = 5; + break; + case ENMB_LIMB_LTHIGH: + bodyPart = 6; + break; + case ENMB_LIMB_RTHIGH: + bodyPart = 7; + break; + case ENMB_LIMB_LFOOT: + bodyPart = 8; + break; + case ENMB_LIMB_RFOOT: + bodyPart = 9; + break; + } + if (bodyPart >= 0) { + Matrix_MultVec3f(&zeroVec, &bodyPartPos); + pthis->bodyPartsPos[bodyPart].x = bodyPartPos.x; + pthis->bodyPartsPos[bodyPart].y = bodyPartPos.y; + pthis->bodyPartsPos[bodyPart].z = bodyPartPos.z; + } + } +} + +void EnMb_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f frontShieldingTriModel0[] = { + { 4000.0f, 7000.0f, 3500.0f }, + { 4000.0f, 0.0f, 3500.0f }, + { -4000.0f, 7000.0f, 3500.0f }, + }; + static Vec3f frontShieldingTriModel1[] = { + { -4000.0f, 7000.0f, 3500.0f }, + { -4000.0f, 0.0f, 3500.0f }, + { 4000.0f, 0.0f, 3500.0f }, + }; + s32 i; + f32 scale; + Vec3f frontShieldingTri0[3]; + Vec3f frontShieldingTri1[3]; + s32 bodyPartIdx; + EnMb* pthis = (EnMb*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, EnMb_PostLimbDraw, thisx); + + if (thisx->params != ENMB_TYPE_CLUB) { + if (pthis->attack > ENMB_ATTACK_NONE) { + EnMb_SpearUpdateAttackCollider(thisx, globalCtx); + } + for (i = 0; i < 3; i++) { + Matrix_MultVec3f(&frontShieldingTriModel0[i], &frontShieldingTri0[i]); + Matrix_MultVec3f(&frontShieldingTriModel1[i], &frontShieldingTri1[i]); + } + Collider_SetTrisVertices(&pthis->frontShielding, 0, &frontShieldingTri0[0], &frontShieldingTri0[1], + &frontShieldingTri0[2]); + Collider_SetTrisVertices(&pthis->frontShielding, 1, &frontShieldingTri1[0], &frontShieldingTri1[1], + &frontShieldingTri1[2]); + } + + if (pthis->iceEffectTimer != 0) { + thisx->colorFilterTimer++; + if (pthis->iceEffectTimer >= 0) { + pthis->iceEffectTimer--; + } + if ((pthis->iceEffectTimer % 4) == 0) { + scale = 2.5f; + if (thisx->params == ENMB_TYPE_CLUB) { + scale = 4.0f; + } + bodyPartIdx = pthis->iceEffectTimer >> 2; + EffectSsEnIce_SpawnFlyingVec3s(globalCtx, thisx, &pthis->bodyPartsPos[bodyPartIdx], 150, 150, 150, 250, 235, + 245, 255, scale); + } + } +} diff --git a/src/overlays/actors/ovl_En_Md/z_en_md.c b/src/overlays/actors/ovl_En_Md/z_en_md.c deleted file mode 100644 index 23050c8b3..000000000 --- a/src/overlays/actors/ovl_En_Md/z_en_md.c +++ /dev/null @@ -1,860 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MD_Z_EN_MD_C -#include "actor_common.h" -/* - * File: z_en_md.c - * Overlay: ovl_En_Md - * Description: Mido - */ - -#include "z_en_md.h" -#include "objects/object_md/object_md.h" -#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera_data.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25) - -void EnMd_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMd_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMd_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AAB874(EnMd* this, GlobalContext* globalCtx); -void func_80AAB8F8(EnMd* this, GlobalContext* globalCtx); -void func_80AAB948(EnMd* this, GlobalContext* globalCtx); -void func_80AABC10(EnMd* this, GlobalContext* globalCtx); -void func_80AABD0C(EnMd* this, GlobalContext* globalCtx); - -const ActorInit En_Md_InitVars = { - ACTOR_EN_MD, - ACTORCAT_NPC, - FLAGS, - OBJECT_MD, - sizeof(EnMd), - (ActorFunc)EnMd_Init, - (ActorFunc)EnMd_Destroy, - (ActorFunc)EnMd_Update, - (ActorFunc)EnMd_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 36, 46, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; - -static struct_80034EC0_Entry sAnimations[] = { - { &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, - { &gMidoRaiseHand1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gMidoHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gMidoPutHandDownAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gMidoAnnoyedPointedHeadIdle1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gMidoAnnoyedPointedHeadIdle2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gMidoAnim_92B0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gMidoWalkingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gMidoHandsOnHipsTransitionAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, - { &gMidoSlamAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gMidoRaiseHand2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gMidoAngryHeadTurnAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, -}; - -void func_80AAA250(EnMd* this) { - f32 startFrame; - - startFrame = this->skelAnime.startFrame; - this->skelAnime.startFrame = this->skelAnime.endFrame; - this->skelAnime.curFrame = this->skelAnime.endFrame; - this->skelAnime.endFrame = startFrame; - this->skelAnime.playSpeed = -1.0f; -} - -void func_80AAA274(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 2); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->unk_20A++; - } - } -} - -void func_80AAA308(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 4); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 5); - this->unk_20A++; - } - } -} - -void func_80AAA39C(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 2); - func_80AAA250(this); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 7); - this->unk_20A++; - } else { - break; - } - case 2: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 8); - this->unk_20A++; - } - } -} - -void func_80AAA474(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 7); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 10); - this->unk_20A++; - } - } -} - -void func_80AAA508(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 2); - func_80AAA250(this); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 10); - this->unk_20A++; - } - } -} - -void func_80AAA5A4(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 9); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 6); - this->unk_20A++; - } - } -} - -void func_80AAA638(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 9); - func_80AAA250(this); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 10); - this->unk_20A++; - } - } -} - -void func_80AAA6D4(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 11); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 6); - this->unk_20A++; - } - } -} - -void func_80AAA768(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 12); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->unk_20A++; - } - } -} - -void func_80AAA7FC(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 13); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 6); - this->unk_20A++; - } - } -} - -void func_80AAA890(EnMd* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 7); - func_80AAA250(this); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 10); - this->unk_20A++; - } - } -} - -void func_80AAA92C(EnMd* this, u8 arg1) { - this->unk_20B = arg1; - this->unk_20A = 0; -} - -void func_80AAA93C(EnMd* this) { - switch (this->unk_20B) { - case 1: - func_80AAA274(this); - break; - case 2: - func_80AAA308(this); - break; - case 3: - func_80AAA39C(this); - break; - case 4: - func_80AAA474(this); - break; - case 5: - func_80AAA508(this); - break; - case 6: - func_80AAA5A4(this); - break; - case 7: - func_80AAA638(this); - break; - case 8: - func_80AAA6D4(this); - break; - case 9: - func_80AAA768(this); - break; - case 10: - func_80AAA7FC(this); - break; - case 11: - func_80AAA890(this); - } -} - -void func_80AAAA24(EnMd* this) { - if (this->unk_1E0.unk_00 != 0) { - switch (this->actor.textId) { - case 0x102F: - if ((this->unk_208 == 0) && (this->unk_20B != 1)) { - func_80AAA92C(this, 1); - } - if ((this->unk_208 == 2) && (this->unk_20B != 2)) { - func_80AAA92C(this, 2); - } - if ((this->unk_208 == 5) && (this->unk_20B != 8)) { - func_80AAA92C(this, 8); - } - if ((this->unk_208 == 11) && (this->unk_20B != 9)) { - func_80AAA92C(this, 9); - } - break; - case 0x1033: - if ((this->unk_208 == 0) && (this->unk_20B != 1)) { - func_80AAA92C(this, 1); - } - if ((this->unk_208 == 1) && (this->unk_20B != 2)) { - func_80AAA92C(this, 2); - } - if ((this->unk_208 == 5) && (this->unk_20B != 10)) { - func_80AAA92C(this, 10); - } - if ((this->unk_208 == 7) && (this->unk_20B != 9)) { - func_80AAA92C(this, 9); - } - break; - case 0x1030: - case 0x1034: - case 0x1045: - if ((this->unk_208 == 0) && (this->unk_20B != 1)) { - func_80AAA92C(this, 1); - } - break; - case 0x1046: - if ((this->unk_208 == 0) && (this->unk_20B != 6)) { - func_80AAA92C(this, 6); - } - break; - } - } else if (this->skelAnime.animation != &gMidoHandsOnHipsIdleAnim) { - func_80034EC0(&this->skelAnime, sAnimations, 10); - func_80AAA92C(this, 0); - } - - func_80AAA93C(this); -} - -s16 func_80AAAC78(EnMd* this, GlobalContext* globalCtx) { - s16 dialogState = Message_GetState(&globalCtx->msgCtx); - - if ((this->unk_209 == TEXT_STATE_AWAITING_NEXT) || (this->unk_209 == TEXT_STATE_EVENT) || - (this->unk_209 == TEXT_STATE_CLOSING) || (this->unk_209 == TEXT_STATE_DONE_HAS_NEXT)) { - if (this->unk_209 != dialogState) { - this->unk_208++; - } - } - - this->unk_209 = dialogState; - return dialogState; -} - -u16 EnMd_GetTextKokiriForest(GlobalContext* globalCtx, EnMd* this) { - u16 reactionText = Text_GetFaceReaction(globalCtx, 0x11); - - if (reactionText != 0) { - return reactionText; - } - - this->unk_208 = 0; - this->unk_209 = TEXT_STATE_NONE; - - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { - return 0x1045; - } - - if (gSaveContext.eventChkInf[0] & 0x10) { - return 0x1034; - } - - if ((CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1) && (CUR_EQUIP_VALUE(EQUIP_SWORD) == 1)) { - return 0x1033; - } - - if (gSaveContext.infTable[0] & 0x1000) { - return 0x1030; - } - - return 0x102F; -} - -u16 EnMd_GetTextKokiriHome(GlobalContext* globalCtx, EnMd* this) { - this->unk_208 = 0; - this->unk_209 = TEXT_STATE_NONE; - - if (gSaveContext.eventChkInf[4] & 1) { - return 0x1028; - } - - return 0x1046; -} - -u16 EnMd_GetTextLostWoods(GlobalContext* globalCtx, EnMd* this) { - this->unk_208 = 0; - this->unk_209 = TEXT_STATE_NONE; - - if (gSaveContext.eventChkInf[4] & 0x100) { - if (gSaveContext.infTable[1] & 0x200) { - return 0x1071; - } - return 0x1070; - } - - if (gSaveContext.eventChkInf[0] & 0x400) { - return 0x1068; - } - - if (gSaveContext.infTable[1] & 0x20) { - return 0x1061; - } - - return 0x1060; -} - -u16 EnMd_GetText(GlobalContext* globalCtx, Actor* thisx) { - EnMd* this = (EnMd*)thisx; - - switch (globalCtx->sceneNum) { - case SCENE_SPOT04: - return EnMd_GetTextKokiriForest(globalCtx, this); - case SCENE_KOKIRI_HOME4: - return EnMd_GetTextKokiriHome(globalCtx, this); - case SCENE_SPOT10: - return EnMd_GetTextLostWoods(globalCtx, this); - default: - return 0; - } -} - -s16 func_80AAAF04(GlobalContext* globalCtx, Actor* thisx) { - EnMd* this = (EnMd*)thisx; - switch (func_80AAAC78(this, globalCtx)) { - case TEXT_STATE_NONE: - case TEXT_STATE_DONE_HAS_NEXT: - case TEXT_STATE_DONE_FADING: - case TEXT_STATE_CHOICE: - case TEXT_STATE_DONE: - case TEXT_STATE_SONG_DEMO_DONE: - case TEXT_STATE_8: - case TEXT_STATE_9: - return 1; - case TEXT_STATE_CLOSING: - switch (this->actor.textId) { - case 0x1028: - gSaveContext.eventChkInf[0] |= 0x8000; - break; - case 0x102F: - gSaveContext.eventChkInf[0] |= 4; - gSaveContext.infTable[0] |= 0x1000; - break; - case 0x1060: - gSaveContext.infTable[1] |= 0x20; - break; - case 0x1070: - gSaveContext.infTable[1] |= 0x200; - break; - case 0x1033: - case 0x1067: - return 2; - } - return 0; - case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx)) { - return 2; - } - default: - return 1; - } -} - -u8 EnMd_ShouldSpawn(EnMd* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SPOT04) { - if (!(gSaveContext.eventChkInf[1] & 0x1000) && !(gSaveContext.eventChkInf[4] & 1)) { - return 1; - } - } - - if (globalCtx->sceneNum == SCENE_KOKIRI_HOME4) { - if (((gSaveContext.eventChkInf[1] & 0x1000) != 0) || ((gSaveContext.eventChkInf[4] & 1) != 0)) { - if (!LINK_IS_ADULT) { - return 1; - } - } - } - - if (globalCtx->sceneNum == SCENE_SPOT10) { - return 1; - } - - return 0; -} - -void EnMd_UpdateEyes(EnMd* this) { - if (DECR(this->blinkTimer) == 0) { - this->eyeIdx++; - if (this->eyeIdx > 2) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeIdx = 0; - } - } -} - -void func_80AAB158(EnMd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 absYawDiff; - s16 temp; - s16 temp2; - s16 yawDiff; - - if (this->actor.xzDistToPlayer < 170.0f) { - yawDiff = (f32)this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - absYawDiff = ABS(yawDiff); - - temp = (absYawDiff <= func_800347E8(2)) ? 2 : 1; - temp2 = 1; - } else { - temp = 1; - temp2 = 0; - } - - if (this->unk_1E0.unk_00 != 0) { - temp = 4; - } - - if (this->actionFunc == func_80AABD0C) { - temp = 1; - temp2 = 0; - } - if (this->actionFunc == func_80AAB8F8) { - temp = 4; - temp2 = 1; - } - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) { - this->unk_1E0.unk_18 = globalCtx->view.eye; - this->unk_1E0.unk_14 = 40.0f; - temp = 2; - } else { - this->unk_1E0.unk_18 = player->actor.world.pos; - this->unk_1E0.unk_14 = (gSaveContext.linkAge > 0) ? 0.0f : -18.0f; - } - - func_80034A14(&this->actor, &this->unk_1E0, 2, temp); - if (this->actionFunc != func_80AABC10) { - if (temp2) { - func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, this->collider.dim.radius + 30.0f, - EnMd_GetText, func_80AAAF04); - } - } -} - -u8 EnMd_FollowPath(EnMd* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* pointPos; - f32 pathDiffX; - f32 pathDiffZ; - - if ((this->actor.params & 0xFF00) == 0xFF00) { - return 0; - } - - path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8]; - pointPos = SEGMENTED_TO_VIRTUAL(path->points); - pointPos += this->waypoint; - - pathDiffX = pointPos->x - this->actor.world.pos.x; - pathDiffZ = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(pathDiffX, pathDiffZ) * (65536.0f / (2 * M_PI)), 4, 4000, - 1); - - if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 100.0f) { - this->waypoint++; - if (this->waypoint >= path->count) { - this->waypoint = 0; - } - return 1; - } - return 0; -} - -u8 EnMd_SetMovedPos(EnMd* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* lastPointPos; - - if ((this->actor.params & 0xFF00) == 0xFF00) { - return 0; - } - - path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8]; - lastPointPos = SEGMENTED_TO_VIRTUAL(path->points); - lastPointPos += path->count - 1; - - this->actor.world.pos.x = lastPointPos->x; - this->actor.world.pos.y = lastPointPos->y; - this->actor.world.pos.z = lastPointPos->z; - - return 1; -} - -void func_80AAB5A4(EnMd* this, GlobalContext* globalCtx) { - f32 temp; - - if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) { - temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) && - (globalCtx->sceneNum == SCENE_SPOT04)) - ? 100.0f - : 400.0f; - this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, temp); - this->actor.shape.shadowAlpha = this->alpha; - } else { - this->alpha = 255; - this->actor.shape.shadowAlpha = this->alpha; - } -} - -void EnMd_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMd* this = (EnMd*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMidoSkel, NULL, this->jointTable, this->morphTable, 17); - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (!EnMd_ShouldSpawn(this, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - - func_80034EC0(&this->skelAnime, sAnimations, 0); - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->alpha = 255; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); - - if (((globalCtx->sceneNum == SCENE_SPOT04) && !(gSaveContext.eventChkInf[0] & 0x10)) || - ((globalCtx->sceneNum == SCENE_SPOT04) && (gSaveContext.eventChkInf[0] & 0x10) && - CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) || - ((globalCtx->sceneNum == SCENE_SPOT10) && !(gSaveContext.eventChkInf[0] & 0x400))) { - this->actor.home.pos = this->actor.world.pos; - this->actionFunc = func_80AAB948; - return; - } - - if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) { - EnMd_SetMovedPos(this, globalCtx); - } - - this->actionFunc = func_80AAB874; -} - -void EnMd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMd* this = (EnMd*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AAB874(EnMd* this, GlobalContext* globalCtx) { - if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { - func_80034F54(globalCtx, this->unk_214, this->unk_236, 17); - } else if ((this->unk_1E0.unk_00 == 0) && (this->unk_20B != 7)) { - func_80AAA92C(this, 7); - } - - func_80AAAA24(this); -} - -void func_80AAB8F8(EnMd* this, GlobalContext* globalCtx) { - if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { - func_80034F54(globalCtx, this->unk_214, this->unk_236, 17); - } - func_80AAA93C(this); -} - -void func_80AAB948(EnMd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 temp; - Actor* actorToBlock = &GET_PLAYER(globalCtx)->actor; - s16 yaw; - - func_80AAAA24(this); - - if (this->unk_1E0.unk_00 == 0) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - - yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &actorToBlock->world.pos); - - this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.x += 60.0f * Math_SinS(yaw); - - this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.z += 60.0f * Math_CosS(yaw); - - temp = fabsf((f32)this->actor.yawTowardsPlayer - yaw) * 0.001f * 3.0f; - this->skelAnime.playSpeed = CLAMP(temp, 1.0f, 3.0f); - } - - if (this->unk_1E0.unk_00 == 2) { - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) && - (globalCtx->sceneNum == SCENE_SPOT04)) { - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - } - - if (globalCtx->sceneNum == SCENE_SPOT04) { - gSaveContext.eventChkInf[0] |= 0x10; - } - if (globalCtx->sceneNum == SCENE_SPOT10) { - gSaveContext.eventChkInf[0] |= 0x400; - } - - func_80AAA92C(this, 3); - func_80AAA93C(this); - this->waypoint = 1; - this->unk_1E0.unk_00 = 0; - this->actionFunc = func_80AABD0C; - this->actor.speedXZ = 1.5f; - return; - } - - if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { - func_80034F54(globalCtx, this->unk_214, this->unk_236, 17); - } - - if ((this->unk_1E0.unk_00 == 0) && (globalCtx->sceneNum == SCENE_SPOT10)) { - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; - player->unk_6A8 = &this->actor; - func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_SARIA); - this->actionFunc = func_80AABC10; - return; - } - - if (this->actor.xzDistToPlayer < (30.0f + this->collider.dim.radius)) { - player->stateFlags2 |= 0x800000; - } - } -} - -void func_80AABC10(EnMd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_04) { - this->actionFunc = func_80AAB948; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { - Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->actor.textId = 0x1067; - func_8002F2CC(&this->actor, globalCtx, this->collider.dim.radius + 30.0f); - - this->actionFunc = func_80AAB948; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - } else { - player->stateFlags2 |= 0x800000; - } -} - -void func_80AABD0C(EnMd* this, GlobalContext* globalCtx) { - func_80034F54(globalCtx, this->unk_214, this->unk_236, 17); - func_80AAA93C(this); - - if (!(EnMd_FollowPath(this, globalCtx)) || (this->waypoint != 0)) { - this->actor.shape.rot = this->actor.world.rot; - return; - } - - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) && - (globalCtx->sceneNum == SCENE_SPOT04)) { - Message_CloseTextbox(globalCtx); - gSaveContext.eventChkInf[1] |= 0x1000; - Actor_Kill(&this->actor); - return; - } - - func_80AAA92C(this, 11); - - this->skelAnime.playSpeed = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.home.pos = this->actor.world.pos; - this->actionFunc = func_80AAB8F8; -} - -void EnMd_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMd* this = (EnMd*)thisx; - s32 pad; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - EnMd_UpdateEyes(this); - func_80AAB5A4(this, globalCtx); - Actor_MoveForward(&this->actor); - func_80AAB158(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); -} - -s32 EnMd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnMd* this = (EnMd*)thisx; - Vec3s vec; - - if (limbIndex == 16) { - Matrix_Translate(1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec = this->unk_1E0.unk_08; - Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_Translate(-1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } - if (limbIndex == 9) { - vec = this->unk_1E0.unk_0E; - Matrix_RotateX((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateY((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); - } - - if (((limbIndex == 9) || (limbIndex == 10)) || (limbIndex == 13)) { - rot->y += Math_SinS(this->unk_214[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->unk_236[limbIndex]) * 200.0f; - } - - return false; -} - -void EnMd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnMd* this = (EnMd*)thisx; - Vec3f vec = { 400.0f, 0.0f, 0.0f }; - - if (limbIndex == 16) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); - } -} - -void EnMd_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* sEyeTextures[] = { - gMidoEyeOpenTex, - gMidoEyeHalfTex, - gMidoEyeClosedTex, - }; - EnMd* this = (EnMd*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_md.c", 1280); - - if (this->alpha == 255) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIdx])); - func_80034BA0(globalCtx, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha); - } else if (this->alpha != 0) { - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIdx])); - func_80034CC4(globalCtx, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_md.c", 1317); -} diff --git a/src/overlays/actors/ovl_En_Md/z_en_md.cpp b/src/overlays/actors/ovl_En_Md/z_en_md.cpp new file mode 100644 index 000000000..b9eda415c --- /dev/null +++ b/src/overlays/actors/ovl_En_Md/z_en_md.cpp @@ -0,0 +1,860 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MD_Z_EN_MD_C +#include "actor_common.h" +/* + * File: z_en_md.c + * Overlay: ovl_En_Md + * Description: Mido + */ + +#include "z_en_md.h" +#include "objects/object_md/object_md.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera_data.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25) + +void EnMd_Init(Actor* thisx, GlobalContext* globalCtx); +void EnMd_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnMd_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMd_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AAB874(EnMd* pthis, GlobalContext* globalCtx); +void func_80AAB8F8(EnMd* pthis, GlobalContext* globalCtx); +void func_80AAB948(EnMd* pthis, GlobalContext* globalCtx); +void func_80AABC10(EnMd* pthis, GlobalContext* globalCtx); +void func_80AABD0C(EnMd* pthis, GlobalContext* globalCtx); + +ActorInit En_Md_InitVars = { + ACTOR_EN_MD, + ACTORCAT_NPC, + FLAGS, + OBJECT_MD, + sizeof(EnMd), + (ActorFunc)EnMd_Init, + (ActorFunc)EnMd_Destroy, + (ActorFunc)EnMd_Update, + (ActorFunc)EnMd_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 36, 46, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; + +static struct_80034EC0_Entry sAnimations[] = { + { &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gMidoRaiseHand1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gMidoHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gMidoPutHandDownAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gMidoAnnoyedPointedHeadIdle1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gMidoAnnoyedPointedHeadIdle2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gMidoAnim_92B0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gMidoWalkingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gMidoHandsOnHipsTransitionAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, + { &gMidoSlamAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gMidoRaiseHand2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gMidoAngryHeadTurnAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, +}; + +void func_80AAA250(EnMd* pthis) { + f32 startFrame; + + startFrame = pthis->skelAnime.startFrame; + pthis->skelAnime.startFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.endFrame = startFrame; + pthis->skelAnime.playSpeed = -1.0f; +} + +void func_80AAA274(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->unk_20A++; + } + } +} + +void func_80AAA308(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 5); + pthis->unk_20A++; + } + } +} + +void func_80AAA39C(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + func_80AAA250(pthis); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 7); + pthis->unk_20A++; + } else { + break; + } + case 2: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 8); + pthis->unk_20A++; + } + } +} + +void func_80AAA474(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 7); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + pthis->unk_20A++; + } + } +} + +void func_80AAA508(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + func_80AAA250(pthis); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + pthis->unk_20A++; + } + } +} + +void func_80AAA5A4(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 9); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 6); + pthis->unk_20A++; + } + } +} + +void func_80AAA638(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 9); + func_80AAA250(pthis); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + pthis->unk_20A++; + } + } +} + +void func_80AAA6D4(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 11); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 6); + pthis->unk_20A++; + } + } +} + +void func_80AAA768(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 12); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->unk_20A++; + } + } +} + +void func_80AAA7FC(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 13); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 6); + pthis->unk_20A++; + } + } +} + +void func_80AAA890(EnMd* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 7); + func_80AAA250(pthis); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + pthis->unk_20A++; + } + } +} + +void func_80AAA92C(EnMd* pthis, u8 arg1) { + pthis->unk_20B = arg1; + pthis->unk_20A = 0; +} + +void func_80AAA93C(EnMd* pthis) { + switch (pthis->unk_20B) { + case 1: + func_80AAA274(pthis); + break; + case 2: + func_80AAA308(pthis); + break; + case 3: + func_80AAA39C(pthis); + break; + case 4: + func_80AAA474(pthis); + break; + case 5: + func_80AAA508(pthis); + break; + case 6: + func_80AAA5A4(pthis); + break; + case 7: + func_80AAA638(pthis); + break; + case 8: + func_80AAA6D4(pthis); + break; + case 9: + func_80AAA768(pthis); + break; + case 10: + func_80AAA7FC(pthis); + break; + case 11: + func_80AAA890(pthis); + } +} + +void func_80AAAA24(EnMd* pthis) { + if (pthis->unk_1E0.unk_00 != 0) { + switch (pthis->actor.textId) { + case 0x102F: + if ((pthis->unk_208 == 0) && (pthis->unk_20B != 1)) { + func_80AAA92C(pthis, 1); + } + if ((pthis->unk_208 == 2) && (pthis->unk_20B != 2)) { + func_80AAA92C(pthis, 2); + } + if ((pthis->unk_208 == 5) && (pthis->unk_20B != 8)) { + func_80AAA92C(pthis, 8); + } + if ((pthis->unk_208 == 11) && (pthis->unk_20B != 9)) { + func_80AAA92C(pthis, 9); + } + break; + case 0x1033: + if ((pthis->unk_208 == 0) && (pthis->unk_20B != 1)) { + func_80AAA92C(pthis, 1); + } + if ((pthis->unk_208 == 1) && (pthis->unk_20B != 2)) { + func_80AAA92C(pthis, 2); + } + if ((pthis->unk_208 == 5) && (pthis->unk_20B != 10)) { + func_80AAA92C(pthis, 10); + } + if ((pthis->unk_208 == 7) && (pthis->unk_20B != 9)) { + func_80AAA92C(pthis, 9); + } + break; + case 0x1030: + case 0x1034: + case 0x1045: + if ((pthis->unk_208 == 0) && (pthis->unk_20B != 1)) { + func_80AAA92C(pthis, 1); + } + break; + case 0x1046: + if ((pthis->unk_208 == 0) && (pthis->unk_20B != 6)) { + func_80AAA92C(pthis, 6); + } + break; + } + } else if (pthis->skelAnime.animation != &gMidoHandsOnHipsIdleAnim) { + func_80034EC0(&pthis->skelAnime, sAnimations, 10); + func_80AAA92C(pthis, 0); + } + + func_80AAA93C(pthis); +} + +s16 func_80AAAC78(EnMd* pthis, GlobalContext* globalCtx) { + s16 dialogState = Message_GetState(&globalCtx->msgCtx); + + if ((pthis->unk_209 == TEXT_STATE_AWAITING_NEXT) || (pthis->unk_209 == TEXT_STATE_EVENT) || + (pthis->unk_209 == TEXT_STATE_CLOSING) || (pthis->unk_209 == TEXT_STATE_DONE_HAS_NEXT)) { + if (pthis->unk_209 != dialogState) { + pthis->unk_208++; + } + } + + pthis->unk_209 = dialogState; + return dialogState; +} + +u16 EnMd_GetTextKokiriForest(GlobalContext* globalCtx, EnMd* pthis) { + u16 reactionText = Text_GetFaceReaction(globalCtx, 0x11); + + if (reactionText != 0) { + return reactionText; + } + + pthis->unk_208 = 0; + pthis->unk_209 = TEXT_STATE_NONE; + + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { + return 0x1045; + } + + if (gSaveContext.eventChkInf[0] & 0x10) { + return 0x1034; + } + + if ((CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1) && (CUR_EQUIP_VALUE(EQUIP_SWORD) == 1)) { + return 0x1033; + } + + if (gSaveContext.infTable[0] & 0x1000) { + return 0x1030; + } + + return 0x102F; +} + +u16 EnMd_GetTextKokiriHome(GlobalContext* globalCtx, EnMd* pthis) { + pthis->unk_208 = 0; + pthis->unk_209 = TEXT_STATE_NONE; + + if (gSaveContext.eventChkInf[4] & 1) { + return 0x1028; + } + + return 0x1046; +} + +u16 EnMd_GetTextLostWoods(GlobalContext* globalCtx, EnMd* pthis) { + pthis->unk_208 = 0; + pthis->unk_209 = TEXT_STATE_NONE; + + if (gSaveContext.eventChkInf[4] & 0x100) { + if (gSaveContext.infTable[1] & 0x200) { + return 0x1071; + } + return 0x1070; + } + + if (gSaveContext.eventChkInf[0] & 0x400) { + return 0x1068; + } + + if (gSaveContext.infTable[1] & 0x20) { + return 0x1061; + } + + return 0x1060; +} + +u16 EnMd_GetText(GlobalContext* globalCtx, Actor* thisx) { + EnMd* pthis = (EnMd*)thisx; + + switch (globalCtx->sceneNum) { + case SCENE_SPOT04: + return EnMd_GetTextKokiriForest(globalCtx, pthis); + case SCENE_KOKIRI_HOME4: + return EnMd_GetTextKokiriHome(globalCtx, pthis); + case SCENE_SPOT10: + return EnMd_GetTextLostWoods(globalCtx, pthis); + default: + return 0; + } +} + +s16 func_80AAAF04(GlobalContext* globalCtx, Actor* thisx) { + EnMd* pthis = (EnMd*)thisx; + switch (func_80AAAC78(pthis, globalCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_DONE_HAS_NEXT: + case TEXT_STATE_DONE_FADING: + case TEXT_STATE_CHOICE: + case TEXT_STATE_DONE: + case TEXT_STATE_SONG_DEMO_DONE: + case TEXT_STATE_8: + case TEXT_STATE_9: + return 1; + case TEXT_STATE_CLOSING: + switch (pthis->actor.textId) { + case 0x1028: + gSaveContext.eventChkInf[0] |= 0x8000; + break; + case 0x102F: + gSaveContext.eventChkInf[0] |= 4; + gSaveContext.infTable[0] |= 0x1000; + break; + case 0x1060: + gSaveContext.infTable[1] |= 0x20; + break; + case 0x1070: + gSaveContext.infTable[1] |= 0x200; + break; + case 0x1033: + case 0x1067: + return 2; + } + return 0; + case TEXT_STATE_EVENT: + if (Message_ShouldAdvance(globalCtx)) { + return 2; + } + default: + return 1; + } +} + +u8 EnMd_ShouldSpawn(EnMd* pthis, GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SPOT04) { + if (!(gSaveContext.eventChkInf[1] & 0x1000) && !(gSaveContext.eventChkInf[4] & 1)) { + return 1; + } + } + + if (globalCtx->sceneNum == SCENE_KOKIRI_HOME4) { + if (((gSaveContext.eventChkInf[1] & 0x1000) != 0) || ((gSaveContext.eventChkInf[4] & 1) != 0)) { + if (!LINK_IS_ADULT) { + return 1; + } + } + } + + if (globalCtx->sceneNum == SCENE_SPOT10) { + return 1; + } + + return 0; +} + +void EnMd_UpdateEyes(EnMd* pthis) { + if (DECR(pthis->blinkTimer) == 0) { + pthis->eyeIdx++; + if (pthis->eyeIdx > 2) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeIdx = 0; + } + } +} + +void func_80AAB158(EnMd* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 absYawDiff; + s16 temp; + s16 temp2; + s16 yawDiff; + + if (pthis->actor.xzDistToPlayer < 170.0f) { + yawDiff = (f32)pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + absYawDiff = ABS(yawDiff); + + temp = (absYawDiff <= func_800347E8(2)) ? 2 : 1; + temp2 = 1; + } else { + temp = 1; + temp2 = 0; + } + + if (pthis->unk_1E0.unk_00 != 0) { + temp = 4; + } + + if (pthis->actionFunc == func_80AABD0C) { + temp = 1; + temp2 = 0; + } + if (pthis->actionFunc == func_80AAB8F8) { + temp = 4; + temp2 = 1; + } + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) { + pthis->unk_1E0.unk_18 = globalCtx->view.eye; + pthis->unk_1E0.unk_14 = 40.0f; + temp = 2; + } else { + pthis->unk_1E0.unk_18 = player->actor.world.pos; + pthis->unk_1E0.unk_14 = (gSaveContext.linkAge > 0) ? 0.0f : -18.0f; + } + + func_80034A14(&pthis->actor, &pthis->unk_1E0, 2, temp); + if (pthis->actionFunc != func_80AABC10) { + if (temp2) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E0.unk_00, pthis->collider.dim.radius + 30.0f, + EnMd_GetText, func_80AAAF04); + } + } +} + +u8 EnMd_FollowPath(EnMd* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* pointPos; + f32 pathDiffX; + f32 pathDiffZ; + + if ((pthis->actor.params & 0xFF00) == 0xFF00) { + return 0; + } + + path = &globalCtx->setupPathList[(pthis->actor.params & 0xFF00) >> 8]; + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos += pthis->waypoint; + + pathDiffX = pointPos->x - pthis->actor.world.pos.x; + pathDiffZ = pointPos->z - pthis->actor.world.pos.z; + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_FAtan2F(pathDiffX, pathDiffZ) * (65536.0f / (2 * M_PI)), 4, 4000, + 1); + + if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 100.0f) { + pthis->waypoint++; + if (pthis->waypoint >= path->count) { + pthis->waypoint = 0; + } + return 1; + } + return 0; +} + +u8 EnMd_SetMovedPos(EnMd* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* lastPointPos; + + if ((pthis->actor.params & 0xFF00) == 0xFF00) { + return 0; + } + + path = &globalCtx->setupPathList[(pthis->actor.params & 0xFF00) >> 8]; + lastPointPos = SEGMENTED_TO_VIRTUAL(path->points); + lastPointPos += path->count - 1; + + pthis->actor.world.pos.x = lastPointPos->x; + pthis->actor.world.pos.y = lastPointPos->y; + pthis->actor.world.pos.z = lastPointPos->z; + + return 1; +} + +void func_80AAB5A4(EnMd* pthis, GlobalContext* globalCtx) { + f32 temp; + + if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) { + temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) && + (globalCtx->sceneNum == SCENE_SPOT04)) + ? 100.0f + : 400.0f; + pthis->alpha = func_80034DD4(&pthis->actor, globalCtx, pthis->alpha, temp); + pthis->actor.shape.shadowAlpha = pthis->alpha; + } else { + pthis->alpha = 255; + pthis->actor.shape.shadowAlpha = pthis->alpha; + } +} + +void EnMd_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMd* pthis = (EnMd*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gMidoSkel, NULL, pthis->jointTable, pthis->morphTable, 17); + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + if (!EnMd_ShouldSpawn(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->alpha = 255; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); + + if (((globalCtx->sceneNum == SCENE_SPOT04) && !(gSaveContext.eventChkInf[0] & 0x10)) || + ((globalCtx->sceneNum == SCENE_SPOT04) && (gSaveContext.eventChkInf[0] & 0x10) && + CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) || + ((globalCtx->sceneNum == SCENE_SPOT10) && !(gSaveContext.eventChkInf[0] & 0x400))) { + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actionFunc = func_80AAB948; + return; + } + + if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) { + EnMd_SetMovedPos(pthis, globalCtx); + } + + pthis->actionFunc = func_80AAB874; +} + +void EnMd_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMd* pthis = (EnMd*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AAB874(EnMd* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { + func_80034F54(globalCtx, pthis->unk_214, pthis->unk_236, 17); + } else if ((pthis->unk_1E0.unk_00 == 0) && (pthis->unk_20B != 7)) { + func_80AAA92C(pthis, 7); + } + + func_80AAAA24(pthis); +} + +void func_80AAB8F8(EnMd* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { + func_80034F54(globalCtx, pthis->unk_214, pthis->unk_236, 17); + } + func_80AAA93C(pthis); +} + +void func_80AAB948(EnMd* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp; + Actor* actorToBlock = &GET_PLAYER(globalCtx)->actor; + s16 yaw; + + func_80AAAA24(pthis); + + if (pthis->unk_1E0.unk_00 == 0) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + + yaw = Math_Vec3f_Yaw(&pthis->actor.home.pos, &actorToBlock->world.pos); + + pthis->actor.world.pos.x = pthis->actor.home.pos.x; + pthis->actor.world.pos.x += 60.0f * Math_SinS(yaw); + + pthis->actor.world.pos.z = pthis->actor.home.pos.z; + pthis->actor.world.pos.z += 60.0f * Math_CosS(yaw); + + temp = fabsf((f32)pthis->actor.yawTowardsPlayer - yaw) * 0.001f * 3.0f; + pthis->skelAnime.playSpeed = CLAMP(temp, 1.0f, 3.0f); + } + + if (pthis->unk_1E0.unk_00 == 2) { + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) && + (globalCtx->sceneNum == SCENE_SPOT04)) { + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + } + + if (globalCtx->sceneNum == SCENE_SPOT04) { + gSaveContext.eventChkInf[0] |= 0x10; + } + if (globalCtx->sceneNum == SCENE_SPOT10) { + gSaveContext.eventChkInf[0] |= 0x400; + } + + func_80AAA92C(pthis, 3); + func_80AAA93C(pthis); + pthis->waypoint = 1; + pthis->unk_1E0.unk_00 = 0; + pthis->actionFunc = func_80AABD0C; + pthis->actor.speedXZ = 1.5f; + return; + } + + if (pthis->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { + func_80034F54(globalCtx, pthis->unk_214, pthis->unk_236, 17); + } + + if ((pthis->unk_1E0.unk_00 == 0) && (globalCtx->sceneNum == SCENE_SPOT10)) { + if (player->stateFlags2 & 0x1000000) { + player->stateFlags2 |= 0x2000000; + player->unk_6A8 = &pthis->actor; + func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_SARIA); + pthis->actionFunc = func_80AABC10; + return; + } + + if (pthis->actor.xzDistToPlayer < (30.0f + pthis->collider.dim.radius)) { + player->stateFlags2 |= 0x800000; + } + } +} + +void func_80AABC10(EnMd* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_04) { + pthis->actionFunc = func_80AAB948; + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { + Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->actor.textId = 0x1067; + func_8002F2CC(&pthis->actor, globalCtx, pthis->collider.dim.radius + 30.0f); + + pthis->actionFunc = func_80AAB948; + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + } else { + player->stateFlags2 |= 0x800000; + } +} + +void func_80AABD0C(EnMd* pthis, GlobalContext* globalCtx) { + func_80034F54(globalCtx, pthis->unk_214, pthis->unk_236, 17); + func_80AAA93C(pthis); + + if (!(EnMd_FollowPath(pthis, globalCtx)) || (pthis->waypoint != 0)) { + pthis->actor.shape.rot = pthis->actor.world.rot; + return; + } + + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) && + (globalCtx->sceneNum == SCENE_SPOT04)) { + Message_CloseTextbox(globalCtx); + gSaveContext.eventChkInf[1] |= 0x1000; + Actor_Kill(&pthis->actor); + return; + } + + func_80AAA92C(pthis, 11); + + pthis->skelAnime.playSpeed = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actionFunc = func_80AAB8F8; +} + +void EnMd_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMd* pthis = (EnMd*)thisx; + s32 pad; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + EnMd_UpdateEyes(pthis); + func_80AAB5A4(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + func_80AAB158(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); +} + +s32 EnMd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnMd* pthis = (EnMd*)thisx; + Vec3s vec; + + if (limbIndex == 16) { + Matrix_Translate(1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); + vec = pthis->unk_1E0.unk_08; + Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Translate(-1200.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + if (limbIndex == 9) { + vec = pthis->unk_1E0.unk_0E; + Matrix_RotateX((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateY((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); + } + + if (((limbIndex == 9) || (limbIndex == 10)) || (limbIndex == 13)) { + rot->y += Math_SinS(pthis->unk_214[limbIndex]) * 200.0f; + rot->z += Math_CosS(pthis->unk_236[limbIndex]) * 200.0f; + } + + return false; +} + +void EnMd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + EnMd* pthis = (EnMd*)thisx; + Vec3f vec = { 400.0f, 0.0f, 0.0f }; + + if (limbIndex == 16) { + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); + } +} + +void EnMd_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* sEyeTextures[] = { + gMidoEyeOpenTex, + gMidoEyeHalfTex, + gMidoEyeClosedTex, + }; + EnMd* pthis = (EnMd*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_md.c", 1280); + + if (pthis->alpha == 255) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIdx])); + func_80034BA0(globalCtx, &pthis->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &pthis->actor, pthis->alpha); + } else if (pthis->alpha != 0) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIdx])); + func_80034CC4(globalCtx, &pthis->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &pthis->actor, pthis->alpha); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_md.c", 1317); +} diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c deleted file mode 100644 index 90030bea6..000000000 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ /dev/null @@ -1,383 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MK_Z_EN_MK_C -#include "actor_common.h" -/* - * File: z_en_mk.c - * Overlay: ovl_En_Mk - * Description: Lakeside Professor - */ - -#include "z_en_mk.h" -#include "objects/object_mk/object_mk.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnMk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnMk_Wait(EnMk* this, GlobalContext* globalCtx); - -const ActorInit En_Mk_InitVars = { - ACTOR_EN_MK, - ACTORCAT_NPC, - FLAGS, - OBJECT_MK, - sizeof(EnMk), - (ActorFunc)EnMk_Init, - (ActorFunc)EnMk_Destroy, - (ActorFunc)EnMk_Update, - (ActorFunc)EnMk_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMk* this = (EnMk*)thisx; - s32 swimFlag; - - this->actor.minVelocityY = -4.0f; - this->actor.gravity = -1.0f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mk_Skel_005DF0, &object_mk_Anim_000D88, this->jointTable, - this->morphTable, 13); - Animation_PlayLoop(&this->skelAnime, &object_mk_Anim_000D88); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = 0xFF; - Actor_SetScale(&this->actor, 0.01f); - - this->actionFunc = EnMk_Wait; - this->flags = 0; - this->swimFlag = 0; - this->actor.targetMode = 6; - - if (gSaveContext.itemGetInf[1] & 1) { - this->flags |= 4; - } -} - -void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMk* this = (EnMk*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AACA40(EnMk* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = EnMk_Wait; - } - - this->flags |= 1; -} - -void func_80AACA94(EnMk* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx) != 0) { - this->actor.parent = NULL; - this->actionFunc = func_80AACA40; - func_80088AA0(240); - gSaveContext.eventInf[1] &= ~1; - } else { - func_8002F434(&this->actor, globalCtx, GI_EYEDROPS, 10000.0f, 50.0f); - } -} - -void func_80AACB14(EnMk* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = func_80AACA94; - func_8002F434(&this->actor, globalCtx, GI_EYEDROPS, 10000.0f, 50.0f); - } -} - -void func_80AACB6C(EnMk* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_80AACB14; - } - - this->flags |= 1; -} - -void func_80AACBAC(EnMk* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; - this->actor.shape.rot.y -= 0x800; - } else { - this->actionFunc = func_80AACB6C; - Message_ContinueTextbox(globalCtx, 0x4030); - } -} - -void func_80AACC04(EnMk* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; - } else { - this->timer = 16; - this->actionFunc = func_80AACBAC; - Animation_Change(&this->skelAnime, &object_mk_Anim_000D88, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mk_Anim_000D88), ANIMMODE_LOOP, -4.0f); - this->flags &= ~2; - } -} - -void func_80AACCA0(EnMk* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; - this->actor.shape.rot.y += 0x800; - } else { - this->timer = 120; - this->actionFunc = func_80AACC04; - Animation_Change(&this->skelAnime, &object_mk_Anim_000724, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mk_Anim_000724), ANIMMODE_LOOP, -4.0f); - this->flags &= ~2; - } -} - -void func_80AACD48(EnMk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = func_80AACCA0; - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - player->exchangeItemId = EXCH_ITEM_NONE; - this->timer = 16; - Animation_Change(&this->skelAnime, &object_mk_Anim_000D88, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mk_Anim_000D88), ANIMMODE_LOOP, -4.0f); - this->flags &= ~2; - } - - this->flags |= 1; -} - -void func_80AACE2C(EnMk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x4001); - Animation_Change(&this->skelAnime, &object_mk_Anim_000AC0, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mk_Anim_000AC0), ANIMMODE_ONCE, -4.0f); - this->flags &= ~2; - this->actionFunc = func_80AACD48; - } - - this->flags |= 1; -} - -void func_80AACEE8(EnMk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x4000); - Animation_Change(&this->skelAnime, &object_mk_Anim_000AC0, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mk_Anim_000AC0), ANIMMODE_LOOP, -4.0f); - this->flags &= ~2; - this->actionFunc = func_80AACE2C; - } - - this->flags |= 1; -} - -void func_80AACFA0(EnMk* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_80AACA40; - gSaveContext.itemGetInf[1] |= 1; - } else { - func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); - } -} - -void func_80AAD014(EnMk* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = func_80AACFA0; - func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); - } - - this->flags |= 1; -} - -void EnMk_Wait(EnMk* this, GlobalContext* globalCtx) { - s16 angle; - s32 swimFlag; - Player* player = GET_PLAYER(globalCtx); - s32 playerExchangeItem; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - playerExchangeItem = func_8002F368(globalCtx); - - if (this->actor.textId != 0x4018) { - player->actor.textId = this->actor.textId; - this->actionFunc = func_80AACA40; - } else { - if (INV_CONTENT(ITEM_ODD_MUSHROOM) == ITEM_EYEDROPS) { - player->actor.textId = 0x4032; - this->actionFunc = func_80AACA40; - } else { - switch (playerExchangeItem) { - case EXCH_ITEM_NONE: - if (this->swimFlag >= 8) { - if (gSaveContext.itemGetInf[1] & 1) { - player->actor.textId = 0x4075; - this->actionFunc = func_80AACA40; - } else { - player->actor.textId = 0x4074; - this->actionFunc = func_80AAD014; - this->swimFlag = 0; - } - } else { - if (this->swimFlag == 0) { - player->actor.textId = 0x4018; - this->actionFunc = func_80AACA40; - } else { - player->actor.textId = 0x406C + this->swimFlag; - this->actionFunc = func_80AACA40; - } - } - break; - case EXCH_ITEM_FROG: - player->actor.textId = 0x4019; - this->actionFunc = func_80AACEE8; - Animation_Change(&this->skelAnime, &object_mk_Anim_000368, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mk_Anim_000368), ANIMMODE_ONCE, -4.0f); - this->flags &= ~2; - gSaveContext.timer2State = 0; - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - break; - default: - player->actor.textId = 0x4018; - this->actionFunc = func_80AACA40; - break; - } - } - } - } else { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x1A); - - if (this->actor.textId == 0) { - this->actor.textId = 0x4018; - } - - angle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(angle) < 0x2151) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8002F298(&this->actor, globalCtx, 100.0f, EXCH_ITEM_FROG); - this->flags |= 1; - } - } -} - -void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMk* this = (EnMk*)thisx; - s32 pad; - Vec3s vec; - Player* player; - s16 swimFlag; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - - if ((!(this->flags & 2)) && (SkelAnime_Update(&this->skelAnime))) { - this->flags |= 2; - } - - this->actionFunc(this, globalCtx); - - if (this->flags & 1) { - func_80038290(globalCtx, &this->actor, &this->headRotation, &vec, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->headRotation.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->headRotation.y, 0, 6, 6200, 100); - } - - player = GET_PLAYER(globalCtx); - - if (this->flags & 8) { - if (!(player->stateFlags2 & 0x400)) { - this->flags &= ~8; - } - } else { - if (player->currentBoots == PLAYER_BOOTS_IRON) { - this->flags |= 8; - } else if (player->stateFlags2 & 0x400) { - swimFlag = player->actor.yDistToWater; - - if (swimFlag > 0) { - if (swimFlag >= 320) { - if (swimFlag >= 355) { - swimFlag = 8; - } else { - swimFlag = 7; - } - } else if (swimFlag < 80) { - swimFlag = 1; - } else { - swimFlag *= 0.025f; - } - - if (this->swimFlag < swimFlag) { - this->swimFlag = swimFlag; - - if ((!(this->flags & 4)) && (this->swimFlag >= 8)) { - this->flags |= 4; - func_80078884(NA_SE_SY_CORRECT_CHIME); - } - } - } - } - } -} - -s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMk* this = (EnMk*)thisx; - - if (limbIndex == 11) { - rot->y -= this->headRotation.y; - rot->z += this->headRotation.x; - } - - return false; -} - -void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_80AAD64C = { 1000.0f, -100.0f, 0.0f }; - EnMk* this = (EnMk*)thisx; - - if (limbIndex == 11) { - Matrix_MultVec3f(&D_80AAD64C, &this->actor.focus.pos); - } -} - -void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnMk* this = (EnMk*)thisx; - - func_800943C8(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor); -} diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.cpp b/src/overlays/actors/ovl_En_Mk/z_en_mk.cpp new file mode 100644 index 000000000..e2c8bbca6 --- /dev/null +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.cpp @@ -0,0 +1,383 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MK_Z_EN_MK_C +#include "actor_common.h" +/* + * File: z_en_mk.c + * Overlay: ovl_En_Mk + * Description: Lakeside Professor + */ + +#include "z_en_mk.h" +#include "objects/object_mk/object_mk.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx); +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnMk_Wait(EnMk* pthis, GlobalContext* globalCtx); + +ActorInit En_Mk_InitVars = { + ACTOR_EN_MK, + ACTORCAT_NPC, + FLAGS, + OBJECT_MK, + sizeof(EnMk), + (ActorFunc)EnMk_Init, + (ActorFunc)EnMk_Destroy, + (ActorFunc)EnMk_Update, + (ActorFunc)EnMk_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMk* pthis = (EnMk*)thisx; + s32 swimFlag; + + pthis->actor.minVelocityY = -4.0f; + pthis->actor.gravity = -1.0f; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_mk_Skel_005DF0, &object_mk_Anim_000D88, pthis->jointTable, + pthis->morphTable, 13); + Animation_PlayLoop(&pthis->skelAnime, &object_mk_Anim_000D88); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = 0xFF; + Actor_SetScale(&pthis->actor, 0.01f); + + pthis->actionFunc = EnMk_Wait; + pthis->flags = 0; + pthis->swimFlag = 0; + pthis->actor.targetMode = 6; + + if (gSaveContext.itemGetInf[1] & 1) { + pthis->flags |= 4; + } +} + +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMk* pthis = (EnMk*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AACA40(EnMk* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = EnMk_Wait; + } + + pthis->flags |= 1; +} + +void func_80AACA94(EnMk* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx) != 0) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_80AACA40; + func_80088AA0(240); + gSaveContext.eventInf[1] &= ~1; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_EYEDROPS, 10000.0f, 50.0f); + } +} + +void func_80AACB14(EnMk* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80AACA94; + func_8002F434(&pthis->actor, globalCtx, GI_EYEDROPS, 10000.0f, 50.0f); + } +} + +void func_80AACB6C(EnMk* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80AACB14; + } + + pthis->flags |= 1; +} + +void func_80AACBAC(EnMk* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; + pthis->actor.shape.rot.y -= 0x800; + } else { + pthis->actionFunc = func_80AACB6C; + Message_ContinueTextbox(globalCtx, 0x4030); + } +} + +void func_80AACC04(EnMk* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; + } else { + pthis->timer = 16; + pthis->actionFunc = func_80AACBAC; + Animation_Change(&pthis->skelAnime, &object_mk_Anim_000D88, 1.0f, 0.0f, + Animation_GetLastFrame(&object_mk_Anim_000D88), ANIMMODE_LOOP, -4.0f); + pthis->flags &= ~2; + } +} + +void func_80AACCA0(EnMk* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; + pthis->actor.shape.rot.y += 0x800; + } else { + pthis->timer = 120; + pthis->actionFunc = func_80AACC04; + Animation_Change(&pthis->skelAnime, &object_mk_Anim_000724, 1.0f, 0.0f, + Animation_GetLastFrame(&object_mk_Anim_000724), ANIMMODE_LOOP, -4.0f); + pthis->flags &= ~2; + } +} + +void func_80AACD48(EnMk* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = func_80AACCA0; + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + player->exchangeItemId = EXCH_ITEM_NONE; + pthis->timer = 16; + Animation_Change(&pthis->skelAnime, &object_mk_Anim_000D88, 1.0f, 0.0f, + Animation_GetLastFrame(&object_mk_Anim_000D88), ANIMMODE_LOOP, -4.0f); + pthis->flags &= ~2; + } + + pthis->flags |= 1; +} + +void func_80AACE2C(EnMk* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x4001); + Animation_Change(&pthis->skelAnime, &object_mk_Anim_000AC0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_mk_Anim_000AC0), ANIMMODE_ONCE, -4.0f); + pthis->flags &= ~2; + pthis->actionFunc = func_80AACD48; + } + + pthis->flags |= 1; +} + +void func_80AACEE8(EnMk* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x4000); + Animation_Change(&pthis->skelAnime, &object_mk_Anim_000AC0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_mk_Anim_000AC0), ANIMMODE_LOOP, -4.0f); + pthis->flags &= ~2; + pthis->actionFunc = func_80AACE2C; + } + + pthis->flags |= 1; +} + +void func_80AACFA0(EnMk* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_80AACA40; + gSaveContext.itemGetInf[1] |= 1; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + } +} + +void func_80AAD014(EnMk* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80AACFA0; + func_8002F434(&pthis->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + } + + pthis->flags |= 1; +} + +void EnMk_Wait(EnMk* pthis, GlobalContext* globalCtx) { + s16 angle; + s32 swimFlag; + Player* player = GET_PLAYER(globalCtx); + s32 playerExchangeItem; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + playerExchangeItem = func_8002F368(globalCtx); + + if (pthis->actor.textId != 0x4018) { + player->actor.textId = pthis->actor.textId; + pthis->actionFunc = func_80AACA40; + } else { + if (INV_CONTENT(ITEM_ODD_MUSHROOM) == ITEM_EYEDROPS) { + player->actor.textId = 0x4032; + pthis->actionFunc = func_80AACA40; + } else { + switch (playerExchangeItem) { + case EXCH_ITEM_NONE: + if (pthis->swimFlag >= 8) { + if (gSaveContext.itemGetInf[1] & 1) { + player->actor.textId = 0x4075; + pthis->actionFunc = func_80AACA40; + } else { + player->actor.textId = 0x4074; + pthis->actionFunc = func_80AAD014; + pthis->swimFlag = 0; + } + } else { + if (pthis->swimFlag == 0) { + player->actor.textId = 0x4018; + pthis->actionFunc = func_80AACA40; + } else { + player->actor.textId = 0x406C + pthis->swimFlag; + pthis->actionFunc = func_80AACA40; + } + } + break; + case EXCH_ITEM_FROG: + player->actor.textId = 0x4019; + pthis->actionFunc = func_80AACEE8; + Animation_Change(&pthis->skelAnime, &object_mk_Anim_000368, 1.0f, 0.0f, + Animation_GetLastFrame(&object_mk_Anim_000368), ANIMMODE_ONCE, -4.0f); + pthis->flags &= ~2; + gSaveContext.timer2State = 0; + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + break; + default: + player->actor.textId = 0x4018; + pthis->actionFunc = func_80AACA40; + break; + } + } + } + } else { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 0x1A); + + if (pthis->actor.textId == 0) { + pthis->actor.textId = 0x4018; + } + + angle = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(angle) < 0x2151) && (pthis->actor.xzDistToPlayer < 100.0f)) { + func_8002F298(&pthis->actor, globalCtx, 100.0f, EXCH_ITEM_FROG); + pthis->flags |= 1; + } + } +} + +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMk* pthis = (EnMk*)thisx; + s32 pad; + Vec3s vec; + Player* player; + s16 swimFlag; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + + if ((!(pthis->flags & 2)) && (SkelAnime_Update(&pthis->skelAnime))) { + pthis->flags |= 2; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->flags & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->headRotation, &vec, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->headRotation.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->headRotation.y, 0, 6, 6200, 100); + } + + player = GET_PLAYER(globalCtx); + + if (pthis->flags & 8) { + if (!(player->stateFlags2 & 0x400)) { + pthis->flags &= ~8; + } + } else { + if (player->currentBoots == PLAYER_BOOTS_IRON) { + pthis->flags |= 8; + } else if (player->stateFlags2 & 0x400) { + swimFlag = player->actor.yDistToWater; + + if (swimFlag > 0) { + if (swimFlag >= 320) { + if (swimFlag >= 355) { + swimFlag = 8; + } else { + swimFlag = 7; + } + } else if (swimFlag < 80) { + swimFlag = 1; + } else { + swimFlag *= 0.025f; + } + + if (pthis->swimFlag < swimFlag) { + pthis->swimFlag = swimFlag; + + if ((!(pthis->flags & 4)) && (pthis->swimFlag >= 8)) { + pthis->flags |= 4; + func_80078884(NA_SE_SY_CORRECT_CHIME); + } + } + } + } + } +} + +s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnMk* pthis = (EnMk*)thisx; + + if (limbIndex == 11) { + rot->y -= pthis->headRotation.y; + rot->z += pthis->headRotation.x; + } + + return false; +} + +void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_80AAD64C = { 1000.0f, -100.0f, 0.0f }; + EnMk* pthis = (EnMk*)thisx; + + if (limbIndex == 11) { + Matrix_MultVec3f(&D_80AAD64C, &pthis->actor.focus.pos); + } +} + +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMk* pthis = (EnMk*)thisx; + + func_800943C8(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &pthis->actor); +} diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.cpp similarity index 58% rename from src/overlays/actors/ovl_En_Mm/z_en_mm.c rename to src/overlays/actors/ovl_En_Mm/z_en_mm.cpp index dfc5f7bca..1ad19c188 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.cpp @@ -47,16 +47,16 @@ void EnMm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AAE598(EnMm* this, GlobalContext* globalCtx); -void func_80AAE294(EnMm* this, GlobalContext* globalCtx); -void func_80AAE50C(EnMm* this, GlobalContext* globalCtx); -void func_80AAE224(EnMm* this, GlobalContext* globalCtx); +void func_80AAE598(EnMm* pthis, GlobalContext* globalCtx); +void func_80AAE294(EnMm* pthis, GlobalContext* globalCtx); +void func_80AAE50C(EnMm* pthis, GlobalContext* globalCtx); +void func_80AAE224(EnMm* pthis, GlobalContext* globalCtx); s32 func_80AADA70(void); s32 EnMm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); void EnMm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void*); -const ActorInit En_Mm_InitVars = { +ActorInit En_Mm_InitVars = { ACTOR_EN_MM, ACTORCAT_NPC, FLAGS, @@ -157,7 +157,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -void EnMm_ChangeAnimation(EnMm* this, s32 newAnimIndex, s32* curAnimIndex) { +void EnMm_ChangeAnimation(EnMm* pthis, s32 newAnimIndex, s32* curAnimIndex) { f32 morphFrames; if ((*curAnimIndex < 0) || (newAnimIndex == *curAnimIndex)) { @@ -167,12 +167,12 @@ void EnMm_ChangeAnimation(EnMm* this, s32 newAnimIndex, s32* curAnimIndex) { } if (sAnimationEntries[newAnimIndex].playSpeed >= 0.0f) { - Animation_Change(&this->skelAnime, sAnimationEntries[newAnimIndex].animation, + Animation_Change(&pthis->skelAnime, sAnimationEntries[newAnimIndex].animation, sAnimationEntries[newAnimIndex].playSpeed, 0.0f, Animation_GetLastFrame(sAnimationEntries[newAnimIndex].animation), sAnimationEntries[newAnimIndex].mode, morphFrames); } else { - Animation_Change(&this->skelAnime, sAnimationEntries[newAnimIndex].animation, + Animation_Change(&pthis->skelAnime, sAnimationEntries[newAnimIndex].animation, sAnimationEntries[newAnimIndex].playSpeed, Animation_GetLastFrame(sAnimationEntries[newAnimIndex].animation), 0.0f, sAnimationEntries[newAnimIndex].mode, morphFrames); @@ -183,46 +183,46 @@ void EnMm_ChangeAnimation(EnMm* this, s32 newAnimIndex, s32* curAnimIndex) { void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnMm* this = (EnMm*)thisx; + EnMm* pthis = (EnMm*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRunningManSkel, NULL, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gRunningManSkel, NULL, pthis->jointTable, pthis->morphTable, 16); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, sColChkInfoInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, &sDamageTable, sColChkInfoInit); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimationEntries[RM_ANIM_RUN].animation, 1.0f, 0.0f, + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + Animation_Change(&pthis->skelAnime, sAnimationEntries[RM_ANIM_RUN].animation, 1.0f, 0.0f, Animation_GetLastFrame(sAnimationEntries[RM_ANIM_RUN].animation), sAnimationEntries[RM_ANIM_RUN].mode, sAnimationEntries[RM_ANIM_RUN].morphFrames); - this->path = this->actor.params & 0xFF; - this->unk_1F0 = 2; - this->unk_1E8 = 0; - this->actor.targetMode = 2; - this->actor.gravity = -1.0f; - this->speedXZ = 3.0f; - this->unk_204 = this->actor.objBankIndex; + pthis->path = pthis->actor.params & 0xFF; + pthis->unk_1F0 = 2; + pthis->unk_1E8 = 0; + pthis->actor.targetMode = 2; + pthis->actor.gravity = -1.0f; + pthis->speedXZ = 3.0f; + pthis->unk_204 = pthis->actor.objBankIndex; if (func_80AADA70() == 1) { - this->mouthTexIndex = RM_MOUTH_OPEN; - EnMm_ChangeAnimation(this, RM_ANIM_RUN, &this->curAnimIndex); - this->actionFunc = func_80AAE598; + pthis->mouthTexIndex = RM_MOUTH_OPEN; + EnMm_ChangeAnimation(pthis, RM_ANIM_RUN, &pthis->curAnimIndex); + pthis->actionFunc = func_80AAE598; } else { - this->mouthTexIndex = RM_MOUTH_CLOSED; - EnMm_ChangeAnimation(this, RM_ANIM_SIT_WAIT, &this->curAnimIndex); - this->actionFunc = func_80AAE294; + pthis->mouthTexIndex = RM_MOUTH_CLOSED; + EnMm_ChangeAnimation(pthis, RM_ANIM_SIT_WAIT, &pthis->curAnimIndex); + pthis->actionFunc = func_80AAE294; } } void EnMm_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnMm* this = (EnMm*)thisx; + EnMm* pthis = (EnMm*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } s32 func_80AADA70(void) { @@ -235,7 +235,7 @@ s32 func_80AADA70(void) { return isDay; } -s32 func_80AADAA0(EnMm* this, GlobalContext* globalCtx) { +s32 func_80AADAA0(EnMm* pthis, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); s32 sp1C = 1; @@ -250,8 +250,8 @@ s32 func_80AADAA0(EnMm* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { player->actor.textId = 0x202D; - this->unk_254 &= ~1; - EnMm_ChangeAnimation(this, RM_ANIM_HAPPY, &this->curAnimIndex); + pthis->unk_254 &= ~1; + EnMm_ChangeAnimation(pthis, RM_ANIM_HAPPY, &pthis->curAnimIndex); } else { player->actor.textId = 0x202C; gSaveContext.infTable[23] |= 0x1000; @@ -272,8 +272,8 @@ s32 func_80AADAA0(EnMm* this, GlobalContext* globalCtx) { case TEXT_STATE_DONE: if (Message_ShouldAdvance(globalCtx)) { if ((player->actor.textId == 0x202E) || (player->actor.textId == 0x202C)) { - this->unk_254 |= 1; - EnMm_ChangeAnimation(this, RM_ANIM_SIT_WAIT, &this->curAnimIndex); + pthis->unk_254 |= 1; + EnMm_ChangeAnimation(pthis, RM_ANIM_SIT_WAIT, &pthis->curAnimIndex); } sp1C = 0; } @@ -283,7 +283,7 @@ s32 func_80AADAA0(EnMm* this, GlobalContext* globalCtx) { return sp1C; } -s32 EnMm_GetTextId(EnMm* this, GlobalContext* globalCtx) { +s32 EnMm_GetTextId(EnMm* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 textId; @@ -302,34 +302,34 @@ s32 EnMm_GetTextId(EnMm* this, GlobalContext* globalCtx) { return textId; } -void func_80AADCD0(EnMm* this, GlobalContext* globalCtx) { +void func_80AADCD0(EnMm* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 yawDiff; s16 sp26; s16 sp24; - if (this->unk_1E0 == 2) { + if (pthis->unk_1E0 == 2) { Message_ContinueTextbox(globalCtx, player->actor.textId); - this->unk_1E0 = 1; - } else if (this->unk_1E0 == 1) { - this->unk_1E0 = func_80AADAA0(this, globalCtx); + pthis->unk_1E0 = 1; + } else if (pthis->unk_1E0 == 1) { + pthis->unk_1E0 = func_80AADAA0(pthis, globalCtx); } else { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_1E0 = 1; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_1E0 = 1; - if (this->curAnimIndex != 5) { - if ((this->actor.textId == 0x202A) || (this->actor.textId == 0x202B)) { - EnMm_ChangeAnimation(this, RM_ANIM_EXCITED, &this->curAnimIndex); + if (pthis->curAnimIndex != 5) { + if ((pthis->actor.textId == 0x202A) || (pthis->actor.textId == 0x202B)) { + EnMm_ChangeAnimation(pthis, RM_ANIM_EXCITED, &pthis->curAnimIndex); func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } } } else { - Actor_GetScreenPos(globalCtx, &this->actor, &sp26, &sp24); - yawDiff = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp26, &sp24); + yawDiff = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)); if ((sp26 >= 0) && (sp26 <= 0x140) && (sp24 >= 0) && (sp24 <= 0xF0) && (yawDiff <= 17152.0f) && - (this->unk_1E0 != 3) && func_8002F2CC(&this->actor, globalCtx, 100.0f)) { - this->actor.textId = EnMm_GetTextId(this, globalCtx); + (pthis->unk_1E0 != 3) && func_8002F2CC(&pthis->actor, globalCtx, 100.0f)) { + pthis->actor.textId = EnMm_GetTextId(pthis, globalCtx); } } } @@ -350,204 +350,204 @@ s32 func_80AADE60(Path* pathList, Vec3f* pos, s32 pathNum, s32 waypoint) { return 0; } -s32 func_80AADEF0(EnMm* this, GlobalContext* globalCtx) { +s32 func_80AADEF0(EnMm* pthis, GlobalContext* globalCtx) { f32 xDiff; f32 zDiff; Vec3f waypointPos; s32 phi_a2; s32 phi_v1; - func_80AADE60(globalCtx->setupPathList, &waypointPos, this->path, this->waypoint); + func_80AADE60(globalCtx->setupPathList, &waypointPos, pthis->path, pthis->waypoint); - xDiff = waypointPos.x - this->actor.world.pos.x; - zDiff = waypointPos.z - this->actor.world.pos.z; + xDiff = waypointPos.x - pthis->actor.world.pos.x; + zDiff = waypointPos.z - pthis->actor.world.pos.z; - this->yawToWaypoint = (s32)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); - this->distToWaypoint = sqrtf(SQ(xDiff) + SQ(zDiff)); + pthis->yawToWaypoint = (s32)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); + pthis->distToWaypoint = sqrtf(SQ(xDiff) + SQ(zDiff)); - while ((this->distToWaypoint <= 10.44f) && (this->unk_1E8 != 0)) { - this->waypoint += sPathInfo[this->unk_1E8].unk_00; + while ((pthis->distToWaypoint <= 10.44f) && (pthis->unk_1E8 != 0)) { + pthis->waypoint += sPathInfo[pthis->unk_1E8].unk_00; - phi_a2 = sPathInfo[this->unk_1E8].unk_08; + phi_a2 = sPathInfo[pthis->unk_1E8].unk_08; switch (phi_a2) { case 0: phi_a2 = 0; break; case 1: - phi_a2 = EnMm_GetPointCount(globalCtx->setupPathList, this->path) - 1; + phi_a2 = EnMm_GetPointCount(globalCtx->setupPathList, pthis->path) - 1; break; case 2: - phi_a2 = this->unk_1F0; + phi_a2 = pthis->unk_1F0; break; } - phi_v1 = sPathInfo[this->unk_1E8].unk_0C; + phi_v1 = sPathInfo[pthis->unk_1E8].unk_0C; switch (phi_v1) { case 0: phi_v1 = 0; break; case 1: - phi_v1 = EnMm_GetPointCount(globalCtx->setupPathList, this->path) - 1; + phi_v1 = EnMm_GetPointCount(globalCtx->setupPathList, pthis->path) - 1; break; case 2: - phi_v1 = this->unk_1F0; + phi_v1 = pthis->unk_1F0; break; } - if ((sPathInfo[this->unk_1E8].unk_00 >= 0 && (this->waypoint < phi_a2 || phi_v1 < this->waypoint)) || - (sPathInfo[this->unk_1E8].unk_00 < 0 && (phi_a2 < this->waypoint || this->waypoint < phi_v1))) { - this->unk_1E8 = sPathInfo[this->unk_1E8].unk_04; - this->waypoint = sPathInfo[this->unk_1E8].unk_08; + if ((sPathInfo[pthis->unk_1E8].unk_00 >= 0 && (pthis->waypoint < phi_a2 || phi_v1 < pthis->waypoint)) || + (sPathInfo[pthis->unk_1E8].unk_00 < 0 && (phi_a2 < pthis->waypoint || pthis->waypoint < phi_v1))) { + pthis->unk_1E8 = sPathInfo[pthis->unk_1E8].unk_04; + pthis->waypoint = sPathInfo[pthis->unk_1E8].unk_08; } - func_80AADE60(globalCtx->setupPathList, &waypointPos, this->path, this->waypoint); + func_80AADE60(globalCtx->setupPathList, &waypointPos, pthis->path, pthis->waypoint); - xDiff = waypointPos.x - this->actor.world.pos.x; - zDiff = waypointPos.z - this->actor.world.pos.z; + xDiff = waypointPos.x - pthis->actor.world.pos.x; + zDiff = waypointPos.z - pthis->actor.world.pos.z; - this->yawToWaypoint = (s32)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); - this->distToWaypoint = sqrtf(SQ(xDiff) + SQ(zDiff)); + pthis->yawToWaypoint = (s32)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); + pthis->distToWaypoint = sqrtf(SQ(xDiff) + SQ(zDiff)); } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawToWaypoint, 1, 2500, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - Math_SmoothStepToF(&this->actor.speedXZ, this->speedXZ, 0.6f, this->distToWaypoint, 0.0f); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->yawToWaypoint, 1, 2500, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + Math_SmoothStepToF(&pthis->actor.speedXZ, pthis->speedXZ, 0.6f, pthis->distToWaypoint, 0.0f); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); return 0; } -void func_80AAE224(EnMm* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->actionFunc = func_80AAE598; - this->unk_1E8 = 0; - this->mouthTexIndex = RM_MOUTH_CLOSED; - this->unk_254 |= 1; - this->unk_1E0 = 0; - this->actor.speedXZ = 0.0f; - EnMm_ChangeAnimation(this, RM_ANIM_SIT_WAIT, &this->curAnimIndex); +void func_80AAE224(EnMm* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actionFunc = func_80AAE598; + pthis->unk_1E8 = 0; + pthis->mouthTexIndex = RM_MOUTH_CLOSED; + pthis->unk_254 |= 1; + pthis->unk_1E0 = 0; + pthis->actor.speedXZ = 0.0f; + EnMm_ChangeAnimation(pthis, RM_ANIM_SIT_WAIT, &pthis->curAnimIndex); } } -void func_80AAE294(EnMm* this, GlobalContext* globalCtx) { +void func_80AAE294(EnMm* pthis, GlobalContext* globalCtx) { f32 floorYNorm; Vec3f dustPos; if (!Player_InCsMode(globalCtx)) { - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - if (this->curAnimIndex == 0) { - if (((s32)this->skelAnime.curFrame == 1) || ((s32)this->skelAnime.curFrame == 6)) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_GROUND); + if (pthis->curAnimIndex == 0) { + if (((s32)pthis->skelAnime.curFrame == 1) || ((s32)pthis->skelAnime.curFrame == 6)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_WALK_GROUND); } } - if (this->curAnimIndex == 4) { - if (((this->skelAnime.curFrame - this->skelAnime.playSpeed < 9.0f) && (this->skelAnime.curFrame >= 9.0f)) || - ((this->skelAnime.curFrame - this->skelAnime.playSpeed < 19.0f) && - (this->skelAnime.curFrame >= 19.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); + if (pthis->curAnimIndex == 4) { + if (((pthis->skelAnime.curFrame - pthis->skelAnime.playSpeed < 9.0f) && (pthis->skelAnime.curFrame >= 9.0f)) || + ((pthis->skelAnime.curFrame - pthis->skelAnime.playSpeed < 19.0f) && + (pthis->skelAnime.curFrame >= 19.0f))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); } } if (gSaveContext.itemGetInf[3] & 0x800) { - this->speedXZ = 10.0f; - this->skelAnime.playSpeed = 2.0f; + pthis->speedXZ = 10.0f; + pthis->skelAnime.playSpeed = 2.0f; } else { - this->speedXZ = 3.0f; - this->skelAnime.playSpeed = 1.0f; + pthis->speedXZ = 3.0f; + pthis->skelAnime.playSpeed = 1.0f; } - func_80AADEF0(this, globalCtx); + func_80AADEF0(pthis, globalCtx); if (func_80AADA70() == 0) { - if (this->actor.floorPoly != NULL) { - floorYNorm = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + if (pthis->actor.floorPoly != NULL) { + floorYNorm = COLPOLY_GET_NORMAL(pthis->actor.floorPoly->normal.y); if ((floorYNorm > 0.9848f) || (floorYNorm < -0.9848f)) { - if (this->sitTimer > 30) { - EnMm_ChangeAnimation(this, RM_ANIM_SIT, &this->curAnimIndex); - this->actionFunc = func_80AAE224; + if (pthis->sitTimer > 30) { + EnMm_ChangeAnimation(pthis, RM_ANIM_SIT, &pthis->curAnimIndex); + pthis->actionFunc = func_80AAE224; } else { - this->sitTimer++; + pthis->sitTimer++; } } else { - this->sitTimer = 0; + pthis->sitTimer = 0; } } } if (gSaveContext.itemGetInf[3] & 0x800) { - dustPos.x = this->actor.world.pos.x; - dustPos.y = this->actor.world.pos.y; - dustPos.z = this->actor.world.pos.z; + dustPos.x = pthis->actor.world.pos.x; + dustPos.y = pthis->actor.world.pos.y; + dustPos.z = pthis->actor.world.pos.z; if (gSaveContext.gameMode != 3) { func_80033480(globalCtx, &dustPos, 50.0f, 2, 350, 20, 0); } - if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - func_8002F71C(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 4.0f); + if (pthis->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + func_8002F71C(globalCtx, &pthis->actor, 3.0f, pthis->actor.yawTowardsPlayer, 4.0f); } } } } -void func_80AAE50C(EnMm* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->sitTimer = 0; - this->actionFunc = func_80AAE294; +void func_80AAE50C(EnMm* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->sitTimer = 0; + pthis->actionFunc = func_80AAE294; if (gSaveContext.itemGetInf[3] & 0x800) { - EnMm_ChangeAnimation(this, RM_ANIM_SPRINT, &this->curAnimIndex); - this->mouthTexIndex = RM_MOUTH_CLOSED; + EnMm_ChangeAnimation(pthis, RM_ANIM_SPRINT, &pthis->curAnimIndex); + pthis->mouthTexIndex = RM_MOUTH_CLOSED; } else { - EnMm_ChangeAnimation(this, RM_ANIM_RUN, &this->curAnimIndex); - this->mouthTexIndex = RM_MOUTH_OPEN; + EnMm_ChangeAnimation(pthis, RM_ANIM_RUN, &pthis->curAnimIndex); + pthis->mouthTexIndex = RM_MOUTH_OPEN; } - this->unk_1E8 = 1; + pthis->unk_1E8 = 1; } } -void func_80AAE598(EnMm* this, GlobalContext* globalCtx) { - func_80038290(globalCtx, &this->actor, &this->unk_248, &this->unk_24E, this->actor.focus.pos); - SkelAnime_Update(&this->skelAnime); +void func_80AAE598(EnMm* pthis, GlobalContext* globalCtx) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_248, &pthis->unk_24E, pthis->actor.focus.pos); + SkelAnime_Update(&pthis->skelAnime); - if ((func_80AADA70() != 0) && (this->unk_1E0 == 0)) { - this->unk_1E0 = 3; - this->actionFunc = func_80AAE50C; - this->unk_254 &= ~1; - EnMm_ChangeAnimation(this, RM_ANIM_STAND, &this->curAnimIndex); + if ((func_80AADA70() != 0) && (pthis->unk_1E0 == 0)) { + pthis->unk_1E0 = 3; + pthis->actionFunc = func_80AAE50C; + pthis->unk_254 &= ~1; + EnMm_ChangeAnimation(pthis, RM_ANIM_STAND, &pthis->curAnimIndex); } } void EnMm_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnMm* this = (EnMm*)thisx; + EnMm* pthis = (EnMm*)thisx; - this->actionFunc(this, globalCtx); - func_80AADCD0(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->actionFunc(pthis, globalCtx); + func_80AADCD0(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { static void* mouthTextures[] = { gRunningManMouthOpenTex, gRunningManMouthClosedTex }; s32 pad; - EnMm* this = (EnMm*)thisx; + EnMm* pthis = (EnMm*)thisx; if (0) {} OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_mm.c", 1065); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(mouthTextures[this->mouthTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMm_OverrideLimbDraw, EnMm_PostLimbDraw, this); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(mouthTextures[pthis->mouthTexIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMm_OverrideLimbDraw, EnMm_PostLimbDraw, pthis); if (gSaveContext.itemGetInf[3] & 0x800) { s32 linkChildObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_LINK_CHILD); @@ -557,12 +557,12 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { Vec3s sp50; Mtx* mtx2; - mtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 2); + mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 2); - Matrix_Put(&this->unk_208); + Matrix_Put(&pthis->unk_208); mtx2 = Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_mm.c", 1111); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[linkChildObjBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[linkChildObjBankIndex].vromStart.get()); gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx2 - 7); @@ -581,7 +581,7 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_ToMtx(mtx, "../z_en_mm.c", 1131); gSPDisplayList(POLY_OPA_DISP++, gLinkChildBunnyHoodDL); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->actor.objBankIndex].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->actor.objBankIndex].vromStart.get()); } } @@ -589,17 +589,17 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { } s32 EnMm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMm* this = (EnMm*)thisx; + EnMm* pthis = (EnMm*)thisx; - if (this->unk_254 & 1) { + if (pthis->unk_254 & 1) { switch (limbIndex) { case 8: - rot->x += this->unk_24E.y; - rot->y -= this->unk_24E.x; + rot->x += pthis->unk_24E.y; + rot->y -= pthis->unk_24E.x; break; case 15: - rot->x += this->unk_248.y; - rot->z += (this->unk_248.x + 0xFA0); + rot->x += pthis->unk_248.y; + rot->z += (pthis->unk_248.x + 0xFA0); break; default: break; @@ -611,15 +611,15 @@ s32 EnMm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnMm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f headOffset = { 200.0f, 800.0f, 0.0f }; - EnMm* this = (EnMm*)thisx; + EnMm* pthis = (EnMm*)thisx; if (limbIndex == 15) { - Matrix_MultVec3f(&headOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&headOffset, &pthis->actor.focus.pos); Matrix_Translate(260.0f, 20.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateY(0.0f, MTXMODE_APPLY); Matrix_RotateX(0.0f, MTXMODE_APPLY); Matrix_RotateZ(4.0f * M_PI / 5.0f, MTXMODE_APPLY); Matrix_Translate(-260.0f, 58.0f, 10.0f, MTXMODE_APPLY); - Matrix_Get(&this->unk_208); + Matrix_Get(&pthis->unk_208); } } diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.cpp similarity index 56% rename from src/overlays/actors/ovl_En_Mm2/z_en_mm2.c rename to src/overlays/actors/ovl_En_Mm2/z_en_mm2.cpp index e3784ac64..4a4e167cb 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.cpp @@ -40,13 +40,13 @@ void EnMm2_Init(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AAF3C0(EnMm2* this, GlobalContext* globalCtx); -void func_80AAF57C(EnMm2* this, GlobalContext* globalCtx); -void func_80AAF668(EnMm2* this, GlobalContext* globalCtx); +void func_80AAF3C0(EnMm2* pthis, GlobalContext* globalCtx); +void func_80AAF57C(EnMm2* pthis, GlobalContext* globalCtx); +void func_80AAF668(EnMm2* pthis, GlobalContext* globalCtx); s32 EnMm2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); void EnMm2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); -const ActorInit En_Mm2_InitVars = { +ActorInit En_Mm2_InitVars = { ACTOR_EN_MM2, ACTORCAT_NPC, FLAGS, @@ -96,7 +96,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -void EnMm2_ChangeAnimation(EnMm2* this, s32 animationIndex, s32* previousAnimation) { +void EnMm2_ChangeAnimation(EnMm2* pthis, s32 animationIndex, s32* previousAnimation) { f32 phi_f0; if ((*previousAnimation < 0) || (animationIndex == *previousAnimation)) { @@ -106,12 +106,12 @@ void EnMm2_ChangeAnimation(EnMm2* this, s32 animationIndex, s32* previousAnimati } if (sAnimationEntries[animationIndex].playSpeed >= 0.0f) { - Animation_Change(&this->skelAnime, sAnimationEntries[animationIndex].animation, + Animation_Change(&pthis->skelAnime, sAnimationEntries[animationIndex].animation, sAnimationEntries[animationIndex].playSpeed, 0.0f, (f32)Animation_GetLastFrame(sAnimationEntries[animationIndex].animation), sAnimationEntries[animationIndex].mode, phi_f0); } else { - Animation_Change(&this->skelAnime, sAnimationEntries[animationIndex].animation, + Animation_Change(&pthis->skelAnime, sAnimationEntries[animationIndex].animation, sAnimationEntries[animationIndex].playSpeed, (f32)Animation_GetLastFrame(sAnimationEntries[animationIndex].animation), 0.0f, sAnimationEntries[animationIndex].mode, phi_f0); @@ -119,98 +119,98 @@ void EnMm2_ChangeAnimation(EnMm2* this, s32 animationIndex, s32* previousAnimati *previousAnimation = animationIndex; } -void func_80AAEF70(EnMm2* this, GlobalContext* globalCtx) { +void func_80AAEF70(EnMm2* pthis, GlobalContext* globalCtx) { if ((gSaveContext.eventChkInf[9] & 0xF) != 0xF) { - this->actor.textId = 0x6086; + pthis->actor.textId = 0x6086; } else if (gSaveContext.infTable[23] & 0x8000) { if (gSaveContext.eventInf[1] & 1) { - this->actor.textId = 0x6082; + pthis->actor.textId = 0x6082; } else if (gSaveContext.timer2State != 0) { - this->actor.textId = 0x6076; + pthis->actor.textId = 0x6076; } else if (HIGH_SCORE(HS_MARATHON) == 158) { - this->actor.textId = 0x607E; + pthis->actor.textId = 0x607E; } else { - this->actor.textId = 0x6081; + pthis->actor.textId = 0x6081; } } else if (gSaveContext.timer2State) { - this->actor.textId = 0x6076; + pthis->actor.textId = 0x6076; } else { - this->actor.textId = 0x607D; + pthis->actor.textId = 0x607D; gSaveContext.eventInf[1] &= ~1; HIGH_SCORE(HS_MARATHON) = 158; } } void EnMm2_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnMm2* this = (EnMm2*)thisx; + EnMm2* pthis = (EnMm2*)thisx; GlobalContext* globalCtx = globalCtx2; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRunningManSkel, NULL, this->jointTable, this->morphTable, 16); - Animation_Change(&this->skelAnime, sAnimationEntries[RM2_ANIM_SIT_WAIT].animation, 1.0f, 0.0f, + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gRunningManSkel, NULL, pthis->jointTable, pthis->morphTable, 16); + Animation_Change(&pthis->skelAnime, sAnimationEntries[RM2_ANIM_SIT_WAIT].animation, 1.0f, 0.0f, Animation_GetLastFrame(sAnimationEntries[RM2_ANIM_SIT_WAIT].animation), sAnimationEntries[RM2_ANIM_SIT_WAIT].mode, sAnimationEntries[RM2_ANIM_SIT_WAIT].morphFrames); - this->previousAnimation = RM2_ANIM_SIT_WAIT; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->mouthTexIndex = RM2_MOUTH_CLOSED; - this->actor.targetMode = 6; - this->unk_1F4 |= 1; - this->actor.gravity = -1.0f; - if (this->actor.params == 1) { - this->actionFunc = func_80AAF668; + pthis->previousAnimation = RM2_ANIM_SIT_WAIT; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->mouthTexIndex = RM2_MOUTH_CLOSED; + pthis->actor.targetMode = 6; + pthis->unk_1F4 |= 1; + pthis->actor.gravity = -1.0f; + if (pthis->actor.params == 1) { + pthis->actionFunc = func_80AAF668; } else { - func_80AAEF70(this, globalCtx); - this->actionFunc = func_80AAF57C; + func_80AAEF70(pthis, globalCtx); + pthis->actionFunc = func_80AAF57C; } if (!LINK_IS_ADULT) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - if (this->actor.params == 1) { + if (pthis->actor.params == 1) { if (!(gSaveContext.infTable[23] & 0x8000) || !(gSaveContext.eventInf[1] & 1)) { osSyncPrintf(VT_FGCOL(CYAN) " マラソン 開始されていない \n" VT_RST "\n"); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } } void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMm2* this = (EnMm2*)thisx; + EnMm2* pthis = (EnMm2*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 func_80AAF224(EnMm2* this, GlobalContext* globalCtx, EnMm2ActionFunc actionFunc) { +s32 func_80AAF224(EnMm2* pthis, GlobalContext* globalCtx, EnMm2ActionFunc actionFunc) { s16 yawDiff; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = actionFunc; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = actionFunc; return 1; } - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(yawDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((ABS(yawDiff) <= 0x4300) && (pthis->actor.xzDistToPlayer < 100.0f)) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); } return 0; } -void func_80AAF2BC(EnMm2* this, GlobalContext* globalCtx) { - if (this->unk_1F6 > 60) { - Actor_Kill(&this->actor); +void func_80AAF2BC(EnMm2* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1F6 > 60) { + Actor_Kill(&pthis->actor); } - SkelAnime_Update(&this->skelAnime); - this->unk_1F6++; - Math_SmoothStepToF(&this->actor.speedXZ, 10.0f, 0.6f, 2.0f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_1F6++; + Math_SmoothStepToF(&pthis->actor.speedXZ, 10.0f, 0.6f, 2.0f, 0.0f); } -void func_80AAF330(EnMm2* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->actionFunc = func_80AAF2BC; - EnMm2_ChangeAnimation(this, 0, &this->previousAnimation); - this->mouthTexIndex = RM2_MOUTH_OPEN; - if (!(this->unk_1F4 & 2)) { +void func_80AAF330(EnMm2* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actionFunc = func_80AAF2BC; + EnMm2_ChangeAnimation(pthis, 0, &pthis->previousAnimation); + pthis->mouthTexIndex = RM2_MOUTH_OPEN; + if (!(pthis->unk_1F4 & 2)) { Message_CloseTextbox(globalCtx); } gSaveContext.timer2State = 0; @@ -218,137 +218,137 @@ void func_80AAF330(EnMm2* this, GlobalContext* globalCtx) { } } -void func_80AAF3C0(EnMm2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void func_80AAF3C0(EnMm2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x607D: case 0x607E: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: Message_ContinueTextbox(globalCtx, 0x607F); - this->actor.textId = 0x607F; + pthis->actor.textId = 0x607F; gSaveContext.eventInf[1] |= 1; break; case 1: Message_ContinueTextbox(globalCtx, 0x6080); - this->actor.textId = 0x6080; + pthis->actor.textId = 0x6080; break; }; - if (this->unk_1F4 & 4) { + if (pthis->unk_1F4 & 4) { if (1) {} - this->unk_1F4 &= ~4; + pthis->unk_1F4 &= ~4; HIGH_SCORE(HS_MARATHON) += 1; } } return; case 0x6081: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->unk_1F4 |= 4; + pthis->unk_1F4 |= 4; HIGH_SCORE(HS_MARATHON) -= 1; Message_ContinueTextbox(globalCtx, 0x607E); - this->actor.textId = 0x607E; + pthis->actor.textId = 0x607E; } return; } - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - if (this->actor.textId == 0x607F) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + if (pthis->actor.textId == 0x607F) { func_80088AA0(0); - this->actionFunc = func_80AAF57C; + pthis->actionFunc = func_80AAF57C; } else { - this->actionFunc = func_80AAF57C; + pthis->actionFunc = func_80AAF57C; } - this->actionFunc = func_80AAF57C; - func_80AAEF70(this, globalCtx); + pthis->actionFunc = func_80AAF57C; + func_80AAEF70(pthis, globalCtx); } } -void func_80AAF57C(EnMm2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - func_80AAEF70(this, globalCtx); - if ((func_80AAF224(this, globalCtx, func_80AAF3C0)) && (this->actor.textId == 0x607D)) { +void func_80AAF57C(EnMm2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + func_80AAEF70(pthis, globalCtx); + if ((func_80AAF224(pthis, globalCtx, func_80AAF3C0)) && (pthis->actor.textId == 0x607D)) { gSaveContext.infTable[23] |= 0x8000; } } -void func_80AAF5EC(EnMm2* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); +void func_80AAF5EC(EnMm2* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->unk_1F4 &= ~1; - EnMm2_ChangeAnimation(this, 3, &this->previousAnimation); - this->actionFunc = func_80AAF330; + pthis->unk_1F4 &= ~1; + EnMm2_ChangeAnimation(pthis, 3, &pthis->previousAnimation); + pthis->actionFunc = func_80AAF330; } } -void func_80AAF668(EnMm2* this, GlobalContext* globalCtx) { - this->actor.world.rot.y = -0x3E80; - this->actor.shape.rot.y = this->actor.world.rot.y; - SkelAnime_Update(&this->skelAnime); +void func_80AAF668(EnMm2* pthis, GlobalContext* globalCtx) { + pthis->actor.world.rot.y = -0x3E80; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + SkelAnime_Update(&pthis->skelAnime); if (((void)0, gSaveContext.timer2Value) < HIGH_SCORE(HS_MARATHON)) { - this->actor.textId = 0x6085; + pthis->actor.textId = 0x6085; } else { - this->actor.textId = 0x6084; + pthis->actor.textId = 0x6084; } - if (func_80AAF224(this, globalCtx, func_80AAF5EC)) { - this->unk_1F6 = 0; + if (func_80AAF224(pthis, globalCtx, func_80AAF5EC)) { + pthis->unk_1F6 = 0; if (((void)0, gSaveContext.timer2Value) < HIGH_SCORE(HS_MARATHON)) { HIGH_SCORE(HS_MARATHON) = gSaveContext.timer2Value; } } else { LOG_HEX("((z_common_data.event_inf[1]) & (0x0001))", gSaveContext.eventInf[1] & 1, "../z_en_mm2.c", 541); if (!(gSaveContext.eventInf[1] & 1)) { - this->unk_1F4 |= 2; - this->unk_1F4 &= ~1; - EnMm2_ChangeAnimation(this, 3, &this->previousAnimation); - this->actionFunc = func_80AAF330; + pthis->unk_1F4 |= 2; + pthis->unk_1F4 &= ~1; + EnMm2_ChangeAnimation(pthis, 3, &pthis->previousAnimation); + pthis->actionFunc = func_80AAF330; } } } void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMm2* this = (EnMm2*)thisx; + EnMm2* pthis = (EnMm2*)thisx; s32 pad; - if (this->unk_1F4 & 1) { - func_80038290(globalCtx, &this->actor, &this->unk_1E8, &this->unk_1EE, this->actor.focus.pos); + if (pthis->unk_1F4 & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_1E8, &pthis->unk_1EE, pthis->actor.focus.pos); } else { - Math_SmoothStepToS(&this->unk_1E8.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_1E8.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_1EE.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_1EE.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_1E8.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_1E8.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_1EE.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_1EE.y, 0, 6, 6200, 100); } - this->actionFunc(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); } void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx) { static void* mouthTextures[] = { gRunningManMouthOpenTex, gRunningManMouthClosedTex }; - EnMm2* this = (EnMm2*)thisx; + EnMm2* pthis = (EnMm2*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_mm2.c", 634); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(mouthTextures[this->mouthTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMm2_OverrideLimbDraw, EnMm2_PostLimbDraw, this); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(mouthTextures[pthis->mouthTexIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMm2_OverrideLimbDraw, EnMm2_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_mm2.c", 654); } s32 EnMm2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMm2* this = (EnMm2*)thisx; + EnMm2* pthis = (EnMm2*)thisx; switch (limbIndex) { case 8: - rot->x += this->unk_1EE.y; - rot->y -= this->unk_1EE.x; + rot->x += pthis->unk_1EE.y; + rot->y -= pthis->unk_1EE.x; break; case 15: - rot->x += this->unk_1E8.y; - rot->z += this->unk_1E8.x + 0xFA0; + rot->x += pthis->unk_1E8.y; + rot->z += pthis->unk_1E8.x + 0xFA0; break; } @@ -357,9 +357,9 @@ s32 EnMm2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnMm2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f headOffset = { 200.0f, 800.0f, 0.0f }; - EnMm2* this = (EnMm2*)thisx; + EnMm2* pthis = (EnMm2*)thisx; if (limbIndex == 15) { - Matrix_MultVec3f(&headOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&headOffset, &pthis->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c deleted file mode 100644 index e854a2f65..000000000 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ /dev/null @@ -1,197 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MS_Z_EN_MS_C -#include "actor_common.h" -/* - * File: z_en_ms.c - * Overlay: ovl_En_Ms - * Description: Magic Bean Salesman - */ - -#include "z_en_ms.h" -#include "objects/object_ms/object_ms.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnMs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnMs_SetOfferText(EnMs* this, GlobalContext* globalCtx); -void EnMs_Wait(EnMs* this, GlobalContext* globalCtx); -void EnMs_Talk(EnMs* this, GlobalContext* globalCtx); -void EnMs_Sell(EnMs* this, GlobalContext* globalCtx); -void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx); - -const ActorInit En_Ms_InitVars = { - ACTOR_EN_MS, - ACTORCAT_NPC, - FLAGS, - OBJECT_MS, - sizeof(EnMs), - (ActorFunc)EnMs_Init, - (ActorFunc)EnMs_Destroy, - (ActorFunc)EnMs_Update, - (ActorFunc)EnMs_Draw, -}; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { 0x00, { 0x00000000, 0x00, 0x00 }, { 0xFFCFFFFF, 0x00, 0x00 }, 0x00, 0x01, 0x01 }, - { 22, 37, 0, { 0 } }, -}; - -static s16 sPrices[] = { - 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -}; - -static u16 sOfferTextIDs[] = { - 0x405E, 0x405F, 0x4060, 0x4061, 0x4062, 0x4063, 0x4064, 0x4065, 0x4066, 0x4067, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), -}; - -void EnMs_SetOfferText(EnMs* this, GlobalContext* globalCtx) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x1B); - if (this->actor.textId == 0) { - if (BEANS_BOUGHT >= 10) { - this->actor.textId = 0x406B; - } else { - this->actor.textId = sOfferTextIDs[BEANS_BOUGHT]; - } - } -} - -void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMs* this = (EnMs*)thisx; - s32 pad; - - if (LINK_AGE_IN_YEARS != YEARS_CHILD) { - Actor_Kill(&this->actor); - return; - } - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBeanSalesmanSkel, &gBeanSalesmanEatingAnim, this->jointTable, - this->morphTable, 9); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - Actor_SetScale(&this->actor, 0.015f); - - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -1.0f; - - EnMs_SetOfferText(this, globalCtx); - - this->actionFunc = EnMs_Wait; -} - -void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMs* this = (EnMs*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { - s16 yawDiff; - - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - EnMs_SetOfferText(this, globalCtx); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { // if talk is initiated - this->actionFunc = EnMs_Talk; - } else if ((this->actor.xzDistToPlayer < 90.0f) && (ABS(yawDiff) < 0x2000)) { // talk range - func_8002F2CC(&this->actor, globalCtx, 90.0f); - } -} - -void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { - u8 dialogState; - - dialogState = Message_GetState(&globalCtx->msgCtx); - if (dialogState != TEXT_STATE_CHOICE) { - if ((dialogState == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { // advanced final textbox - this->actionFunc = EnMs_Wait; - } - } else if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - if (gSaveContext.rupees < sPrices[BEANS_BOUGHT]) { - Message_ContinueTextbox(globalCtx, 0x4069); // not enough rupees text - return; - } - func_8002F434(&this->actor, globalCtx, GI_BEAN, 90.0f, 10.0f); - this->actionFunc = EnMs_Sell; - return; - case 1: // no - Message_ContinueTextbox(globalCtx, 0x4068); - default: - return; - } - } -} - -void EnMs_Sell(EnMs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Rupees_ChangeBy(-sPrices[BEANS_BOUGHT]); - this->actor.parent = NULL; - this->actionFunc = EnMs_TalkAfterPurchase; - } else { - func_8002F434(&this->actor, globalCtx, GI_BEAN, 90.0f, 10.0f); - } -} - -void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx) { - // if dialog state is 6 and player responded to textbox - if ((Message_GetState(&globalCtx->msgCtx)) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x406C); - this->actionFunc = EnMs_Talk; - } -} - -void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMs* this = (EnMs*)thisx; - s32 pad; - - this->activeTimer += 1; - Actor_SetFocus(&this->actor, 20.0f); - this->actor.targetArrowOffset = 500.0f; - Actor_SetScale(&this->actor, 0.015f); - SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); - - if (gSaveContext.entranceIndex == 0x157 && gSaveContext.sceneSetupIndex == 8) { // ride carpet if in credits - Actor_MoveForward(&this->actor); - osSyncPrintf("OOOHHHHHH %f\n", this->actor.velocity.y); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnMs* this = (EnMs*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); -} diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.cpp b/src/overlays/actors/ovl_En_Ms/z_en_ms.cpp new file mode 100644 index 000000000..95ebcccdf --- /dev/null +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.cpp @@ -0,0 +1,197 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_MS_Z_EN_MS_C +#include "actor_common.h" +/* + * File: z_en_ms.c + * Overlay: ovl_En_Ms + * Description: Magic Bean Salesman + */ + +#include "z_en_ms.h" +#include "objects/object_ms/object_ms.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnMs_Init(Actor* thisx, GlobalContext* globalCtx); +void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnMs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnMs_SetOfferText(EnMs* pthis, GlobalContext* globalCtx); +void EnMs_Wait(EnMs* pthis, GlobalContext* globalCtx); +void EnMs_Talk(EnMs* pthis, GlobalContext* globalCtx); +void EnMs_Sell(EnMs* pthis, GlobalContext* globalCtx); +void EnMs_TalkAfterPurchase(EnMs* pthis, GlobalContext* globalCtx); + +ActorInit En_Ms_InitVars = { + ACTOR_EN_MS, + ACTORCAT_NPC, + FLAGS, + OBJECT_MS, + sizeof(EnMs), + (ActorFunc)EnMs_Init, + (ActorFunc)EnMs_Destroy, + (ActorFunc)EnMs_Update, + (ActorFunc)EnMs_Draw, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { 0x00, { 0x00000000, 0x00, 0x00 }, { 0xFFCFFFFF, 0x00, 0x00 }, 0x00, 0x01, 0x01 }, + { 22, 37, 0, { 0 } }, +}; + +static s16 sPrices[] = { + 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, +}; + +static u16 sOfferTextIDs[] = { + 0x405E, 0x405F, 0x4060, 0x4061, 0x4062, 0x4063, 0x4064, 0x4065, 0x4066, 0x4067, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), +}; + +void EnMs_SetOfferText(EnMs* pthis, GlobalContext* globalCtx) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 0x1B); + if (pthis->actor.textId == 0) { + if (BEANS_BOUGHT >= 10) { + pthis->actor.textId = 0x406B; + } else { + pthis->actor.textId = sOfferTextIDs[BEANS_BOUGHT]; + } + } +} + +void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMs* pthis = (EnMs*)thisx; + s32 pad; + + if (LINK_AGE_IN_YEARS != YEARS_CHILD) { + Actor_Kill(&pthis->actor); + return; + } + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBeanSalesmanSkel, &gBeanSalesmanEatingAnim, pthis->jointTable, + pthis->morphTable, 9); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + Actor_SetScale(&pthis->actor, 0.015f); + + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -1.0f; + + EnMs_SetOfferText(pthis, globalCtx); + + pthis->actionFunc = EnMs_Wait; +} + +void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMs* pthis = (EnMs*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnMs_Wait(EnMs* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + EnMs_SetOfferText(pthis, globalCtx); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { // if talk is initiated + pthis->actionFunc = EnMs_Talk; + } else if ((pthis->actor.xzDistToPlayer < 90.0f) && (ABS(yawDiff) < 0x2000)) { // talk range + func_8002F2CC(&pthis->actor, globalCtx, 90.0f); + } +} + +void EnMs_Talk(EnMs* pthis, GlobalContext* globalCtx) { + u8 dialogState; + + dialogState = Message_GetState(&globalCtx->msgCtx); + if (dialogState != TEXT_STATE_CHOICE) { + if ((dialogState == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { // advanced final textbox + pthis->actionFunc = EnMs_Wait; + } + } else if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + if (gSaveContext.rupees < sPrices[BEANS_BOUGHT]) { + Message_ContinueTextbox(globalCtx, 0x4069); // not enough rupees text + return; + } + func_8002F434(&pthis->actor, globalCtx, GI_BEAN, 90.0f, 10.0f); + pthis->actionFunc = EnMs_Sell; + return; + case 1: // no + Message_ContinueTextbox(globalCtx, 0x4068); + default: + return; + } + } +} + +void EnMs_Sell(EnMs* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Rupees_ChangeBy(-sPrices[BEANS_BOUGHT]); + pthis->actor.parent = NULL; + pthis->actionFunc = EnMs_TalkAfterPurchase; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_BEAN, 90.0f, 10.0f); + } +} + +void EnMs_TalkAfterPurchase(EnMs* pthis, GlobalContext* globalCtx) { + // if dialog state is 6 and player responded to textbox + if ((Message_GetState(&globalCtx->msgCtx)) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x406C); + pthis->actionFunc = EnMs_Talk; + } +} + +void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMs* pthis = (EnMs*)thisx; + s32 pad; + + pthis->activeTimer += 1; + Actor_SetFocus(&pthis->actor, 20.0f); + pthis->actor.targetArrowOffset = 500.0f; + Actor_SetScale(&pthis->actor, 0.015f); + SkelAnime_Update(&pthis->skelAnime); + pthis->actionFunc(pthis, globalCtx); + + if (gSaveContext.entranceIndex == 0x157 && gSaveContext.sceneSetupIndex == 8) { // ride carpet if in credits + Actor_MoveForward(&pthis->actor); + osSyncPrintf("OOOHHHHHH %f\n", pthis->actor.velocity.y); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + } + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMs* pthis = (EnMs*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); +} diff --git a/src/overlays/actors/ovl_En_Mu/z_en_mu.c b/src/overlays/actors/ovl_En_Mu/z_en_mu.cpp similarity index 63% rename from src/overlays/actors/ovl_En_Mu/z_en_mu.c rename to src/overlays/actors/ovl_En_Mu/z_en_mu.cpp index e9c18373c..dc506f7c6 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.c +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.cpp @@ -26,7 +26,7 @@ void EnMu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMu_Update(Actor* thisx, GlobalContext* globalCtx); void EnMu_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnMu_Pose(EnMu* this, GlobalContext* globalCtx); +void EnMu_Pose(EnMu* pthis, GlobalContext* globalCtx); s16 EnMu_CheckDialogState(GlobalContext* globalCtx, Actor* thisx); static ColliderCylinderInit D_80AB0BD0 = { @@ -51,7 +51,7 @@ static ColliderCylinderInit D_80AB0BD0 = { static CollisionCheckInfoInit2 D_80AB0BFC = { 0, 0, 0, 0, MASS_IMMOVABLE }; -const ActorInit En_Mu_InitVars = { +ActorInit En_Mu_InitVars = { ACTOR_EN_MU, ACTORCAT_NPC, FLAGS, @@ -63,11 +63,11 @@ const ActorInit En_Mu_InitVars = { (ActorFunc)EnMu_Draw, }; -void EnMu_SetupAction(EnMu* this, EnMuActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnMu_SetupAction(EnMu* pthis, EnMuActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void EnMu_Interact(EnMu* this, GlobalContext* globalCtx) { +void EnMu_Interact(EnMu* pthis, GlobalContext* globalCtx) { u8 textIdOffset[] = { 0x42, 0x43, 0x3F, 0x41, 0x3E }; u8 bitmask[] = { 0x01, 0x02, 0x04, 0x08, 0x10 }; u8 textFlags; @@ -91,7 +91,7 @@ void EnMu_Interact(EnMu* this, GlobalContext* globalCtx) { } if (i == 5) { - if (this->defFaceReaction == (textIdOffset[randomIndex] | 0x7000)) { + if (pthis->defFaceReaction == (textIdOffset[randomIndex] | 0x7000)) { randomIndex++; if (randomIndex >= 5) { randomIndex = 0; @@ -101,23 +101,23 @@ void EnMu_Interact(EnMu* this, GlobalContext* globalCtx) { } textFlags |= bitmask[randomIndex]; - this->defFaceReaction = textIdOffset[randomIndex] | 0x7000; + pthis->defFaceReaction = textIdOffset[randomIndex] | 0x7000; textFlags &= 0xFF; gSaveContext.eventInf[2] |= textFlags; } u16 EnMu_GetFaceReaction(GlobalContext* globalCtx, Actor* thisx) { - EnMu* this = (EnMu*)thisx; - u16 faceReaction = Text_GetFaceReaction(globalCtx, this->actor.params + 0x3A); + EnMu* pthis = (EnMu*)thisx; + u16 faceReaction = Text_GetFaceReaction(globalCtx, pthis->actor.params + 0x3A); if (faceReaction != 0) { return faceReaction; } - return this->defFaceReaction; + return pthis->defFaceReaction; } s16 EnMu_CheckDialogState(GlobalContext* globalCtx, Actor* thisx) { - EnMu* this = (EnMu*)thisx; + EnMu* pthis = (EnMu*)thisx; switch (Message_GetState(&globalCtx->msgCtx)) { case TEXT_STATE_NONE: @@ -131,7 +131,7 @@ s16 EnMu_CheckDialogState(GlobalContext* globalCtx, Actor* thisx) { case TEXT_STATE_9: return 1; case TEXT_STATE_CLOSING: - EnMu_Interact(this, globalCtx); + EnMu_Interact(pthis, globalCtx); return 0; default: return 1; @@ -139,61 +139,61 @@ s16 EnMu_CheckDialogState(GlobalContext* globalCtx, Actor* thisx) { } void EnMu_Init(Actor* thisx, GlobalContext* globalCtx) { - EnMu* this = (EnMu*)thisx; + EnMu* pthis = (EnMu*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 160.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mu_Skel_004F70, &object_mu_Anim_0003F4, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80AB0BD0); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &D_80AB0BFC); - this->actor.targetMode = 6; - Actor_SetScale(&this->actor, 0.01f); - EnMu_Interact(this, globalCtx); - EnMu_SetupAction(this, EnMu_Pose); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 160.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_mu_Skel_004F70, &object_mu_Anim_0003F4, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &D_80AB0BD0); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &D_80AB0BFC); + pthis->actor.targetMode = 6; + Actor_SetScale(&pthis->actor, 0.01f); + EnMu_Interact(pthis, globalCtx); + EnMu_SetupAction(pthis, EnMu_Pose); } void EnMu_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnMu* this = (EnMu*)thisx; + EnMu* pthis = (EnMu*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); + SkelAnime_Free(&pthis->skelAnime, globalCtx); } -void EnMu_Pose(EnMu* this, GlobalContext* globalCtx) { - func_80034F54(globalCtx, this->unk_20A, this->unk_22A, 16); +void EnMu_Pose(EnMu* pthis, GlobalContext* globalCtx) { + func_80034F54(globalCtx, pthis->unk_20A, pthis->unk_22A, 16); } void EnMu_Update(Actor* thisx, GlobalContext* globalCtx) { - EnMu* this = (EnMu*)thisx; + EnMu* pthis = (EnMu*)thisx; s32 pad; f32 talkDist; Vec3s pos; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z; + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z; - this->collider.dim.pos = pos; + pthis->collider.dim.pos = pos; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); - talkDist = this->collider.dim.radius + 30.0f; - func_800343CC(globalCtx, &this->actor, &this->npcInfo.unk_00, talkDist, EnMu_GetFaceReaction, + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); + talkDist = pthis->collider.dim.radius + 30.0f; + func_800343CC(globalCtx, &pthis->actor, &pthis->npcInfo.unk_00, talkDist, EnMu_GetFaceReaction, EnMu_CheckDialogState); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 60.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 60.0f; } s32 EnMu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnMu* this = (EnMu*)thisx; + EnMu* pthis = (EnMu*)thisx; if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 11) || (limbIndex == 12) || (limbIndex == 13) || (limbIndex == 14)) { - rot->y += Math_SinS(this->unk_20A[limbIndex]) * 200.0f; - rot->z += Math_CosS(this->unk_22A[limbIndex]) * 200.0f; + rot->y += Math_SinS(pthis->unk_20A[limbIndex]) * 200.0f; + rot->z += Math_CosS(pthis->unk_22A[limbIndex]) * 200.0f; } return false; } @@ -202,16 +202,14 @@ void EnMu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } Gfx* EnMu_DisplayListSetColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { - Gfx* dlist; - - dlist = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + Gfx* dlist = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); gDPSetEnvColor(dlist, r, g, b, a); gSPEndDisplayList(dlist + 1); return dlist; } void EnMu_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnMu* this = (EnMu*)thisx; + EnMu* pthis = (EnMu*)thisx; Color_RGBA8 colors[2][5] = { { { 100, 130, 235, 0 }, { 160, 250, 60, 0 }, { 90, 60, 20, 0 }, { 30, 240, 200, 0 }, { 140, 70, 20, 0 } }, { { 140, 70, 20, 0 }, { 30, 240, 200, 0 }, { 90, 60, 20, 0 }, { 160, 250, 60, 0 }, { 100, 130, 235, 0 } } @@ -223,11 +221,11 @@ void EnMu_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Translate(-1200.0f, 0.0f, -1400.0f, MTXMODE_APPLY); for (i = 0; i < 5; i++) { gSPSegment(POLY_OPA_DISP++, segmentId[i], - EnMu_DisplayListSetColor(globalCtx->state.gfxCtx, colors[this->actor.params][i].r, - colors[this->actor.params][i].g, colors[this->actor.params][i].b, - colors[this->actor.params][i].a)); + EnMu_DisplayListSetColor(globalCtx->state.gfxCtx, colors[pthis->actor.params][i].r, + colors[pthis->actor.params][i].g, colors[pthis->actor.params][i].b, + colors[pthis->actor.params][i].a)); } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnMu_OverrideLimbDraw, EnMu_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnMu_OverrideLimbDraw, EnMu_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_mu.c", 534); } diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c deleted file mode 100644 index ddd54d12d..000000000 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ /dev/null @@ -1,1555 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NB_Z_EN_NB_C -#include "actor_common.h" -/* - * File: z_en_nb.c - * Overlay: ovl_En_Nb - * Description: Nabooru - */ - -#include "z_en_nb.h" -#include "vt.h" -#include "objects/object_nb/object_nb.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef enum { - /* 0x00 */ NB_CHAMBER_INIT, - /* 0x01 */ NB_CHAMBER_UNDERGROUND, - /* 0x02 */ NB_CHAMBER_APPEAR, - /* 0x03 */ NB_CHAMBER_IDLE, - /* 0x04 */ NB_CHAMBER_RAISE_ARM, - /* 0x05 */ NB_CHAMBER_RAISE_ARM_TRANSITION, - /* 0x06 */ NB_GIVE_MEDALLION, - /* 0x07 */ NB_ACTION_7, - /* 0x08 */ NB_SEAL_HIDE, - /* 0x09 */ NB_ACTION_9, - /* 0x0A */ NB_KIDNAPPED, - /* 0x0B */ NB_KIDNAPPED_LOOK_AROUND, - /* 0x0C */ NB_PORTAL_FALLTHROUGH, - /* 0x0D */ NB_IN_CONFRONTATION, - /* 0x0E */ NB_ACTION_14, - /* 0x0F */ NB_KNEEL, - /* 0x10 */ NB_LOOK_RIGHT, - /* 0x11 */ NB_LOOK_LEFT, - /* 0x12 */ NB_RUN, - /* 0x13 */ NB_CONFRONTATION_DESTROYED, - /* 0x14 */ NB_CREDITS_INIT, - /* 0x15 */ NB_CREDITS_FADEIN, - /* 0x16 */ NB_CREDITS_SIT, - /* 0x17 */ NB_CREDITS_HEAD_TURN, - /* 0x18 */ NB_CROUCH_CRAWLSPACE, - /* 0x19 */ NB_NOTICE_PLAYER, - /* 0x1A */ NB_IDLE_CRAWLSPACE, - /* 0x1B */ NB_IN_DIALOG, - /* 0x1C */ NB_IN_PATH, - /* 0x1D */ NB_IDLE_AFTER_TALK, - /* 0x1E */ NB_ACTION_30 -} EnNbAction; - -typedef enum { - /* 0x00 */ NB_DRAW_NOTHING, - /* 0x01 */ NB_DRAW_DEFAULT, - /* 0x02 */ NB_DRAW_HIDE, - /* 0x03 */ NB_DRAW_KNEEL, - /* 0x04 */ NB_DRAW_LOOK_DIRECTION -} EnNbDrawMode; - -void EnNb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNb_Draw(Actor* thisx, GlobalContext* globalCtx); - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 25, 80, 0, { 0, 0, 0 } }, -}; - -static void* sEyeTextures[] = { - gNabooruEyeOpenTex, - gNabooruEyeHalfTex, - gNabooruEyeClosedTex, -}; - -static s32 D_80AB4318 = 0; - -#include "z_en_nb_cutscene_data.c" EARLY - -s32 EnNb_GetPath(EnNb* this) { - s32 path = this->actor.params >> 8; - - return path & 0xFF; -} - -s32 EnNb_GetType(EnNb* this) { - s32 type = this->actor.params; - - return type & 0xFF; -} - -void EnNb_UpdatePath(EnNb* this, GlobalContext* globalCtx) { - Vec3s* pointPos; - Path* pathList; - s32 pad; - s32 path; - - pathList = globalCtx->setupPathList; - - if (pathList != NULL) { - path = EnNb_GetPath(this); - pathList += path; - pointPos = SEGMENTED_TO_VIRTUAL(pathList->points); - this->initialPos.x = pointPos[0].x; - this->initialPos.y = pointPos[0].y; - this->initialPos.z = pointPos[0].z; - this->finalPos.x = pointPos[1].x; - this->finalPos.y = pointPos[1].y; - this->finalPos.z = pointPos[1].z; - this->pathYaw = (Math_FAtan2F(this->finalPos.x - this->initialPos.x, this->finalPos.z - this->initialPos.z) * - (0x8000 / M_PI)); - // "En_Nb_Get_path_info Rail Data Get! = %d!!!!!!!!!!!!!!" - osSyncPrintf("En_Nb_Get_path_info レールデータをゲットだぜ = %d!!!!!!!!!!!!!!\n", path); - } else { - // "En_Nb_Get_path_info Rail Data Doesn't Exist!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf("En_Nb_Get_path_info レールデータが無い!!!!!!!!!!!!!!!!!!!!\n"); - } -} - -void EnNb_SetupCollider(Actor* thisx, GlobalContext* globalCtx) { - EnNb* this = (EnNb*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, thisx, &sCylinderInit); -} - -void EnNb_UpdateCollider(EnNb* this, GlobalContext* globalCtx) { - s32 pad[4]; - ColliderCylinder* collider = &this->collider; - - Collider_UpdateCylinder(&this->actor, collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); -} - -void EnNb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnNb* this = (EnNb*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AB0FBC(EnNb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_300.unk_18 = player->actor.world.pos; - this->unk_300.unk_14 = kREG(16) + 9.0f; - func_80034A14(&this->actor, &this->unk_300, kREG(17) + 0xC, 2); -} - -void func_80AB1040(EnNb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_300.unk_18 = player->actor.world.pos; - this->unk_300.unk_14 = kREG(16) + 9.0f; - func_80034A14(&this->actor, &this->unk_300, kREG(17) + 0xC, 4); -} - -void func_80AB10C4(EnNb* this) { - s32 pad2[2]; - Vec3s* tempPtr; - Vec3s* tempPtr2; - - tempPtr = &this->unk_300.unk_08; - Math_SmoothStepToS(&tempPtr->x, 0, 20, 6200, 100); - Math_SmoothStepToS(&tempPtr->y, 0, 20, 6200, 100); - tempPtr2 = &this->unk_300.unk_0E; - Math_SmoothStepToS(&tempPtr2->x, 0, 20, 6200, 100); - Math_SmoothStepToS(&tempPtr2->y, 0, 20, 6200, 100); -} - -void EnNb_UpdateEyes(EnNb* this) { - s32 pad[3]; - s16* blinkTimer = &this->blinkTimer; - s16* eyeIdx = &this->eyeIdx; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - - *eyeIdx = *blinkTimer; - if (*eyeIdx >= ARRAY_COUNT(sEyeTextures)) { - *eyeIdx = 0; - } -} - -void func_80AB11EC(EnNb* this) { - this->action = NB_ACTION_7; - this->drawMode = NB_DRAW_NOTHING; - this->alpha = 0; - this->flag = 0; - this->actor.shape.shadowAlpha = 0; - this->alphaTimer = 0.0f; -} - -void func_80AB1210(EnNb* this, GlobalContext* globalCtx) { - s32 one; // required to match - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - if (D_80AB4318) { - if (this->actor.params == NB_TYPE_DEMO02) { - func_80AB11EC(this); - } - - D_80AB4318 = 0; - } - } else { - one = 1; - if (!D_80AB4318) { - D_80AB4318 = one; - } - } -} - -void func_80AB1284(EnNb* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 4); -} - -s32 EnNb_UpdateSkelAnime(EnNb* this) { - return SkelAnime_Update(&this->skelAnime); -} - -CsCmdActorAction* EnNb_GetNpcCsAction(GlobalContext* globalCtx, s32 npcActionIdx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[npcActionIdx]; - } - return NULL; -} - -void EnNb_SetupCsPosRot(EnNb* this, GlobalContext* globalCtx, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, npcActionIdx); - s16 newRotY; - Actor* thisx = &this->actor; - - if (csCmdNPCAction != NULL) { - thisx->world.pos.x = csCmdNPCAction->startPos.x; - thisx->world.pos.y = csCmdNPCAction->startPos.y; - thisx->world.pos.z = csCmdNPCAction->startPos.z; - thisx->world.rot.y = thisx->shape.rot.y = csCmdNPCAction->rot.y; - } -} - -s32 func_80AB1390(EnNb* this, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction; - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && - (csCmdNPCAction = globalCtx->csCtx.npcActions[npcActionIdx], csCmdNPCAction != NULL) && - (csCmdNPCAction->action == arg2)) { - return true; - } - return false; -} - -s32 func_80AB13D8(EnNb* this, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction; - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && - (csCmdNPCAction = globalCtx->csCtx.npcActions[npcActionIdx], csCmdNPCAction != NULL) && - (csCmdNPCAction->action != arg2)) { - return true; - } - return false; -} - -void EnNb_SetInitialCsPosRot(EnNb* this, GlobalContext* globalCtx, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, npcActionIdx); - Actor* thisx = &this->actor; - - if (csCmdNPCAction != NULL) { - thisx->world.pos.x = csCmdNPCAction->startPos.x; - thisx->world.pos.y = csCmdNPCAction->startPos.y; - thisx->world.pos.z = csCmdNPCAction->startPos.z; - thisx->world.rot.y = thisx->shape.rot.y = csCmdNPCAction->rot.y; - } -} - -void EnNb_SetCurrentAnim(EnNb* this, AnimationHeader* animation, u8 mode, f32 transitionRate, s32 arg4) { - f32 frameCount = Animation_GetLastFrame(animation); - f32 playbackSpeed; - f32 unk0; - f32 fc; - - if (!arg4) { - unk0 = 0.0f; - fc = frameCount; - playbackSpeed = 1.0f; - } else { - unk0 = frameCount; - fc = 0.0f; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animation, playbackSpeed, unk0, fc, mode, transitionRate); -} - -void EnNb_SetChamberAnim(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetCurrentAnim(this, &gNabooruStandingHandsOnHipsChamberOfSagesAnim, 0, 0, 0); - this->actor.shape.yOffset = -10000.0f; -} - -void EnNb_SpawnBlueWarp(EnNb* this, GlobalContext* globalCtx) { - f32 posX = this->actor.world.pos.x; - f32 posY = this->actor.world.pos.y; - f32 posZ = this->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, - WARP_SAGES); -} - -void EnNb_GiveMedallion(EnNb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 posX = player->actor.world.pos.x; - f32 posY = player->actor.world.pos.y + 50.0f; - f32 posZ = player->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, - 0xC); - Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); -} - -void EnNb_ComeUpImpl(EnNb* this, GlobalContext* globalCtx) { - this->actor.shape.yOffset += 250.0f / 3.0f; -} - -void EnNb_SetupChamberCsImpl(EnNb* this, GlobalContext* globalCtx) { - s32 pad[2]; - Player* player; - - if ((gSaveContext.chamberCutsceneNum == 3) && (gSaveContext.sceneSetupIndex < 4)) { - player = GET_PLAYER(globalCtx); - this->action = NB_CHAMBER_UNDERGROUND; - globalCtx->csCtx.segment = &D_80AB431C; - gSaveContext.cutsceneTrigger = 2; - Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); - player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - } -} - -void EnNb_SetupChamberWarpImpl(EnNb* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - CsCmdActorAction* csCmdNPCAction; - - if (csCtx->state != CS_STATE_IDLE) { - csCmdNPCAction = csCtx->npcActions[1]; - if (csCmdNPCAction != NULL && csCmdNPCAction->action == 2) { - this->action = NB_CHAMBER_APPEAR; - this->drawMode = NB_DRAW_DEFAULT; - EnNb_SpawnBlueWarp(this, globalCtx); - } - } -} - -void EnNb_SetupDefaultChamberIdle(EnNb* this) { - if (this->actor.shape.yOffset >= 0.0f) { - this->action = NB_CHAMBER_IDLE; - this->actor.shape.yOffset = 0.0f; - } -} - -void EnNb_SetupArmRaise(EnNb* this, GlobalContext* globalCtx) { - AnimationHeader* animation = &gNabooruRaisingArmsGivingMedallionAnim; - CsCmdActorAction* csCmdNPCAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdNPCAction = globalCtx->csCtx.npcActions[1]; - if (csCmdNPCAction != NULL && csCmdNPCAction->action == 3) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, - 0.0f); - this->action = NB_CHAMBER_RAISE_ARM; - } - } -} - -void EnNb_SetupRaisedArmTransition(EnNb* this, s32 animFinished) { - AnimationHeader* animation = &gNabooruArmsRaisedGivingMedallionAnim; - - if (animFinished) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, - 0.0f); - this->action = NB_CHAMBER_RAISE_ARM_TRANSITION; - } -} - -void EnNb_SetupMedallion(EnNb* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdNPCAction = globalCtx->csCtx.npcActions[6]; - if (csCmdNPCAction != NULL && csCmdNPCAction->action == 2) { - this->action = NB_GIVE_MEDALLION; - EnNb_GiveMedallion(this, globalCtx); - } - } -} - -// Action func is never explicitly set to this, but it runs when the memory gets zero cleared -void EnNb_SetupChamberCs(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetupChamberCsImpl(this, globalCtx); -} - -void EnNb_SetupChamberWarp(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetupChamberWarpImpl(this, globalCtx); -} - -void EnNb_ComeUp(EnNb* this, GlobalContext* globalCtx) { - EnNb_ComeUpImpl(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetupDefaultChamberIdle(this); -} - -void func_80AB193C(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetupArmRaise(this, globalCtx); -} - -void EnNb_RaiseArm(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - func_80AB1284(this, globalCtx); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetupRaisedArmTransition(this, animFinished); -} - -void func_80AB19BC(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetupMedallion(this, globalCtx); -} - -void func_80AB19FC(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); -} - -void EnNb_SetupLightArrowOrSealingCs(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetCurrentAnim(this, &gNabooruPuttingHandsTogetherCastingMagicAnim, 2, 0.0f, 0); - this->action = NB_ACTION_7; - this->actor.shape.shadowAlpha = 0; -} - -void EnNb_PlaySealingSound(void) { - func_800788CC(NA_SE_SY_WHITE_OUT_T); -} - -void EnNb_InitializeDemo6K(EnNb* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - kREG(21) + 22.0f + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 7); -} - -void EnNb_SetupHide(EnNb* this, GlobalContext* globalCtx) { - if (func_80AB1390(this, globalCtx, 4, 1)) { - this->action = NB_SEAL_HIDE; - this->drawMode = NB_DRAW_HIDE; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - this->alphaTimer = 0.0f; - EnNb_PlaySealingSound(); - } -} - -void EnNb_CheckToFade(EnNb* this, GlobalContext* globalCtx) { - f32* alphaTimer = &this->alphaTimer; - s32 alpha; - - if (func_80AB1390(this, globalCtx, 4, 1)) { - *alphaTimer += 1.0f; - if (*alphaTimer >= kREG(5) + 10.0f) { - this->action = NB_ACTION_9; - this->drawMode = NB_DRAW_DEFAULT; - *alphaTimer = kREG(5) + 10.0f; - this->alpha = 255; - this->actor.shape.shadowAlpha = 0xFF; - return; - } - } else { - *alphaTimer -= 1.0f; - if (*alphaTimer <= 0.0f) { - this->action = NB_ACTION_7; - this->drawMode = NB_DRAW_NOTHING; - *alphaTimer = 0.0f; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - return; - } - } - - alpha = (*alphaTimer / (kREG(5) + 10.0f)) * 255.0f; - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; -} - -void EnNb_SetupLightOrb(EnNb* this, GlobalContext* globalCtx) { - if (func_80AB13D8(this, globalCtx, 4, 1)) { - this->action = NB_SEAL_HIDE; - this->drawMode = NB_DRAW_HIDE; - this->alphaTimer = kREG(5) + 10.0f; - this->alpha = 255; - - if (this->flag == 0) { - EnNb_InitializeDemo6K(this, globalCtx); - this->flag = 1; - } - - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void EnNb_Hide(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetupHide(this, globalCtx); - func_80AB1210(this, globalCtx); -} - -void EnNb_Fade(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_CheckToFade(this, globalCtx); - func_80AB1210(this, globalCtx); -} - -void EnNb_CreateLightOrb(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetupLightOrb(this, globalCtx); - func_80AB1210(this, globalCtx); -} - -void EnNb_DrawTransparency(EnNb* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeSegIdx = this->eyeIdx; - void* eyeTex = sEyeTextures[eyeSegIdx]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inKenjyanomaDemo02.c", 263); - - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - NULL, NULL, NULL, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inKenjyanomaDemo02.c", 290); -} - -void EnNb_InitKidnap(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetCurrentAnim(this, &gNabooruTrappedInVortexPushingGroundAnim, 0, 0.0f, 0); - this->action = NB_KIDNAPPED; - this->actor.shape.shadowAlpha = 0; - gSaveContext.eventChkInf[9] |= 0x20; -} - -void EnNb_PlayCrySFX(EnNb* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 3) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_NB_CRY_0); - } -} - -void EnNb_PlayAgonySFX(EnNb* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 420) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_NB_AGONY); - } -} - -void EnNb_SetPosInPortal(EnNb* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); - Vec3f* pos = &this->actor.world.pos; - f32 f0; - s32 pad; - Vec3f startPos; - Vec3f endPos; - - if (csCmdNPCAction != NULL) { - f0 = Environment_LerpWeightAccelDecel(csCmdNPCAction->endFrame, csCmdNPCAction->startFrame, - globalCtx->csCtx.frames, 4, 4); - startPos.x = csCmdNPCAction->startPos.x; - startPos.y = csCmdNPCAction->startPos.y; - startPos.z = csCmdNPCAction->startPos.z; - endPos.x = csCmdNPCAction->endPos.x; - endPos.y = csCmdNPCAction->endPos.y; - endPos.z = csCmdNPCAction->endPos.z; - pos->x = ((endPos.x - startPos.x) * f0) + startPos.x; - pos->y = ((endPos.y - startPos.y) * f0) + startPos.y; - pos->z = ((endPos.z - startPos.z) * f0) + startPos.z; - } -} - -void EnNb_SetupCaptureCutsceneState(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetupCsPosRot(this, globalCtx, 1); - this->action = NB_KIDNAPPED; - this->drawMode = NB_DRAW_NOTHING; - this->actor.shape.shadowAlpha = 0; -} - -void EnNb_SetRaisedArmCaptureAnim(EnNb* this, s32 animFinished) { - AnimationHeader* animation = &gNabooruSuckedByVortexAnim; - - if (animFinished) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, - 0.0f); - } -} - -void EnNb_SetupLookAroundInKidnap(EnNb* this) { - AnimationHeader* animation = &gNabooruTrappedInVortexPushingGroundAnim; - - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, -8.0f); - this->action = NB_KIDNAPPED_LOOK_AROUND; - this->drawMode = NB_DRAW_DEFAULT; -} - -void EnNb_SetupKidnap(EnNb* this) { - AnimationHeader* animation = &gNabooruTrappedInVortexRaisingArmAnim; - - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, -8.0f); - this->action = NB_PORTAL_FALLTHROUGH; - this->drawMode = NB_DRAW_DEFAULT; -} - -void EnNb_CheckKidnapCsMode(EnNb* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); - s32 action; - s32 previousCsAction; - - if (csCmdNPCAction != NULL) { - action = csCmdNPCAction->action; - previousCsAction = this->previousCsAction; - if (action != previousCsAction) { - switch (action) { - case 1: - EnNb_SetupCaptureCutsceneState(this, globalCtx); - break; - case 7: - EnNb_SetupLookAroundInKidnap(this); - break; - case 8: - EnNb_SetupKidnap(this); - break; - case 9: - Actor_Kill(&this->actor); - break; - default: - // "Operation Doesn't Exist!!!!!!!!" - osSyncPrintf("En_Nb_Kidnap_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - this->previousCsAction = action; - } - } -} - -void func_80AB23A8(EnNb* this, GlobalContext* globalCtx) { - EnNb_PlayCrySFX(this, globalCtx); - EnNb_CheckKidnapCsMode(this, globalCtx); -} - -void EnNb_MovingInPortal(EnNb* this, GlobalContext* globalCtx) { - EnNb_PlayCrySFX(this, globalCtx); - EnNb_PlayAgonySFX(this, globalCtx); - EnNb_UpdateEyes(this); - EnNb_UpdateSkelAnime(this); - EnNb_CheckKidnapCsMode(this, globalCtx); -} - -void EnNb_SuckedInByPortal(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - EnNb_UpdateEyes(this); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_SetRaisedArmCaptureAnim(this, animFinished); - EnNb_SetPosInPortal(this, globalCtx); - EnNb_CheckKidnapCsMode(this, globalCtx); -} - -void EnNb_SetupConfrontation(EnNb* this, GlobalContext* globalCtx) { - AnimationHeader* animation = &gNabooruCollapseFromStandingToKneelingTransitionAnim; - - EnNb_SetCurrentAnim(this, animation, 0, 0.0f, 0); - this->action = NB_IN_CONFRONTATION; - this->actor.shape.shadowAlpha = 0; -} - -void EnNb_PlayKnuckleDefeatSFX(EnNb* this, GlobalContext* globalCtx) { - s32 pad[2]; - - if (globalCtx->csCtx.frames == 548) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_NB_CRY_0); - func_80078914(&this->actor.projectedPos, NA_SE_EN_FANTOM_HIT_THUNDER); - } -} - -void EnNb_PlayKneelingOnGroundSFX(EnNb* this) { - s32 pad[2]; - - if ((this->skelAnime.mode == 2) && - (Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 25.0f))) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_HUMAN_BOUND); - } -} - -void EnNb_PlayLookRightSFX(EnNb* this) { - s32 pad[2]; - - if ((this->skelAnime.mode == 2) && Animation_OnFrame(&this->skelAnime, 9.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_CONCRETE); - } -} - -void EnNb_PlayLookLeftSFX(EnNb* this) { - s32 pad[2]; - - if (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_CONCRETE); - } -} - -void EnNb_InitDemo6KInConfrontation(EnNb* this, GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - kREG(21) + 22.0f + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0xB); -} - -void func_80AB2688(EnNb* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 1; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_80AB26C8(EnNb* this) { - this->action = NB_IN_CONFRONTATION; - this->drawMode = NB_DRAW_NOTHING; - this->actor.shape.shadowAlpha = 0; -} - -void func_80AB26DC(EnNb* this, GlobalContext* globalCtx) { - s32 pad; - AnimationHeader* animation = &gNabooruCollapseFromStandingToKneelingTransitionAnim; - f32 lastFrame = Animation_GetLastFrame(animation); - - EnNb_SetupCsPosRot(this, globalCtx, 1); - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); - this->action = NB_ACTION_14; - this->drawMode = NB_DRAW_KNEEL; - this->actor.shape.shadowAlpha = 0xFF; -} - -void EnNb_SetupKneel(EnNb* this) { - AnimationHeader* animation = &gNabooruCollapseFromStandingToKneelingTransitionAnim; - f32 lastFrame = Animation_GetLastFrame(animation); - - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); - this->action = NB_KNEEL; - this->drawMode = NB_DRAW_KNEEL; - this->actor.shape.shadowAlpha = 0xFF; -} - -void EnNb_CheckIfKneeling(EnNb* this, s32 animFinished) { - AnimationHeader* animation = &gNabooruOnAllFoursAnim; - - if (animFinished) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, - 0.0f); - this->drawMode = NB_DRAW_KNEEL; - } -} - -void EnNb_SetupLookRight(EnNb* this) { - AnimationHeader* animation = &gNabooruOnAllFoursToOnOneKneeLookingRightTransitionAnim; - f32 lastFrame = Animation_GetLastFrame(animation); - - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -8.0f); - this->action = NB_LOOK_RIGHT; - this->drawMode = NB_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 0xFF; -} - -void EnNb_CheckIfLookingRight(EnNb* this, s32 animFinished) { - AnimationHeader* animation = &gNabooruOnOneKneeLookingRightAnim; - - if (animFinished) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, - 0.0f); - this->drawMode = NB_DRAW_LOOK_DIRECTION; - } -} - -void EnNb_SetupLookLeft(EnNb* this) { - AnimationHeader* animation = &gNabooruOnOneKneeTurningHeadRightToLeftTransitionAnim; - f32 lastFrame = Animation_GetLastFrame(animation); - - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -8.0f); - this->action = NB_LOOK_LEFT; - this->drawMode = NB_DRAW_LOOK_DIRECTION; - this->actor.shape.shadowAlpha = 0xFF; -} - -void EnNb_CheckIfLookLeft(EnNb* this, s32 animFinished) { - AnimationHeader* animation = &gNabooruOnOneKneeLookingLeftAnim; - - if (animFinished) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, - 0.0f); - } -} - -void EnNb_SetupDemo6KInConfrontation(EnNb* this, GlobalContext* globalCtx, s32 animFinished) { - if (!this->flag && animFinished) { - EnNb_InitDemo6KInConfrontation(this, globalCtx); - this->flag = 1; - } -} - -void EnNb_SetupRun(EnNb* this) { - AnimationHeader* animation = &gNabooruKneeingToRunningToHitAnim; - f32 lastFrame = Animation_GetLastFrame(animation); - - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -8.0f); - this->action = NB_RUN; - this->drawMode = NB_DRAW_LOOK_DIRECTION; - this->actor.shape.shadowAlpha = 0xFF; -} - -void EnNb_SetupConfrontationDestroy(EnNb* this) { - this->action = NB_CONFRONTATION_DESTROYED; - this->drawMode = NB_DRAW_NOTHING; - this->actor.shape.shadowAlpha = 0; -} - -void EnNb_CheckConfrontationCsMode(EnNb* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction; - s32 csAction; - s32 previousCsAction; - - csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); - if (csCmdNPCAction != NULL) { - csAction = csCmdNPCAction->action; - previousCsAction = this->previousCsAction; - - if (csAction != previousCsAction) { - switch (csAction) { - case 1: - func_80AB26C8(this); - break; - case 10: - func_80AB26DC(this, globalCtx); - break; - case 11: - EnNb_SetupKneel(this); - break; - case 12: - EnNb_SetupLookRight(this); - break; - case 13: - EnNb_SetupLookLeft(this); - break; - case 14: - EnNb_SetupRun(this); - break; - case 9: - EnNb_SetupConfrontationDestroy(this); - break; - default: - // "En_Nb_Confrontion_Check_DemoMode: Operation doesn't exist!!!!!!!!" - osSyncPrintf("En_Nb_Confrontion_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - this->previousCsAction = csAction; - } - } -} - -void EnNb_CheckConfrontationCsModeWrapper(EnNb* this, GlobalContext* globalCtx) { - EnNb_CheckConfrontationCsMode(this, globalCtx); -} - -void func_80AB2C18(EnNb* this, GlobalContext* globalCtx) { - EnNb_UpdateEyes(this); - func_80AB2688(this, globalCtx); - func_80AB1284(this, globalCtx); - EnNb_CheckConfrontationCsMode(this, globalCtx); -} - -void EnNb_Kneel(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - EnNb_UpdateEyes(this); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_CheckIfKneeling(this, animFinished); - EnNb_PlayKneelingOnGroundSFX(this); - func_80AB2688(this, globalCtx); - func_80AB1284(this, globalCtx); - EnNb_CheckConfrontationCsMode(this, globalCtx); -} - -void EnNb_LookRight(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - EnNb_UpdateEyes(this); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_CheckIfLookingRight(this, animFinished); - EnNb_PlayLookRightSFX(this); - func_80AB2688(this, globalCtx); - func_80AB1284(this, globalCtx); - EnNb_CheckConfrontationCsMode(this, globalCtx); -} - -void EnNb_LookLeft(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - EnNb_UpdateEyes(this); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_CheckIfLookLeft(this, animFinished); - func_80AB2688(this, globalCtx); - func_80AB1284(this, globalCtx); - EnNb_CheckConfrontationCsMode(this, globalCtx); -} - -void EnNb_Run(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - EnNb_PlayKnuckleDefeatSFX(this, globalCtx); - EnNb_UpdateEyes(this); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_PlayLookLeftSFX(this); - func_80AB2688(this, globalCtx); - func_80AB1284(this, globalCtx); - EnNb_SetupDemo6KInConfrontation(this, globalCtx, animFinished); - EnNb_CheckConfrontationCsMode(this, globalCtx); -} - -void EnNb_ConfrontationDestroy(EnNb* this, GlobalContext* globalCtx) { - this->timer++; - - if (this->timer > 60.0f) { - Actor_Kill(&this->actor); - } -} - -void func_80AB2E70(EnNb* this, GlobalContext* globalCtx) { - s32 pad; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 572); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gNabooruEyeWideTex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gNabooruEyeWideTex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, - &this->actor); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 593); -} - -s32 func_80AB2FC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnNb* this = (EnNb*)thisx; - - if (limbIndex == NB_LIMB_HEAD) { - *dList = gNabooruHeadMouthOpenDL; - } - - return 0; -} - -void func_80AB2FE4(EnNb* this, GlobalContext* globalCtx) { - s32 pad; - s16 eyeIdx = this->eyeIdx; - SkelAnime* skelAnime = &this->skelAnime; - void* eyeTexture = sEyeTextures[eyeIdx]; - s32 pad1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 623); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, func_80AB2FC0, - NULL, &this->actor); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 644); -} - -void EnNb_SetupCreditsSpawn(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetCurrentAnim(this, &gNabooruSittingCrossLeggedAnim, 0, 0.0f, 0); - this->action = NB_CREDITS_INIT; - this->drawMode = NB_DRAW_NOTHING; - this->actor.shape.shadowAlpha = 0; -} - -void EnNb_SetAlphaInCredits(EnNb* this) { - f32* alphaTimer = &this->alphaTimer; - s32 alpha; - - this->alphaTimer++; - - if ((kREG(17) + 10.0f) <= this->alphaTimer) { - this->alpha = 255; - this->actor.shape.shadowAlpha = 255; - } else { - alpha = (*alphaTimer / (kREG(17) + 10.0f)) * 255.0f; - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; - } -} - -void EnNb_SetupCreditsFadeIn(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetInitialCsPosRot(this, globalCtx, 1); - this->action = NB_CREDITS_FADEIN; - this->drawMode = NB_DRAW_HIDE; -} - -void EnNb_SetupCreditsSit(EnNb* this) { - if (this->alphaTimer >= kREG(17) + 10.0f) { - this->action = NB_CREDITS_SIT; - this->drawMode = NB_DRAW_DEFAULT; - } -} - -void EnNb_SetupCreditsHeadTurn(EnNb* this) { - EnNb_SetCurrentAnim(this, &gNabooruSittingCrossLeggedTurningToLookUpRightTransitionAnim, 2, -8.0f, 0); - this->action = NB_CREDITS_HEAD_TURN; -} - -void EnNb_CheckIfLookingUp(EnNb* this, s32 animFinished) { - if (animFinished) { - EnNb_SetCurrentAnim(this, &gNabooruSittingCrossLeggedLookingUpRightAnim, 0, 0.0f, 0); - } -} - -void EnNb_CheckCreditsCsModeImpl(EnNb* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); - s32 action; - s32 previousCsAction; - - if (csCmdNPCAction != NULL) { - action = csCmdNPCAction->action; - previousCsAction = this->previousCsAction; - if (action != previousCsAction) { - switch (action) { - case 15: - EnNb_SetupCreditsFadeIn(this, globalCtx); - break; - case 16: - EnNb_SetupCreditsHeadTurn(this); - break; - default: - // "En_Nb_inEnding_Check_DemoMode: Operation doesn't exist!!!!!!!!" - osSyncPrintf("En_Nb_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - this->previousCsAction = action; - } - } -} - -void EnNb_CheckCreditsCsMode(EnNb* this, GlobalContext* globalCtx) { - EnNb_CheckCreditsCsModeImpl(this, globalCtx); -} - -void EnNb_CreditsFade(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetAlphaInCredits(this); - EnNb_SetupCreditsSit(this); -} - -void func_80AB3428(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_CheckCreditsCsModeImpl(this, globalCtx); -} - -void EnNb_LookUp(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - func_80AB1284(this, globalCtx); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_CheckIfLookingUp(this, animFinished); -} - -void EnNb_CrawlspaceSpawnCheck(EnNb* this, GlobalContext* globalCtx) { - if (!(gSaveContext.eventChkInf[9] & 0x20) && LINK_IS_CHILD) { - EnNb_UpdatePath(this, globalCtx); - - // looking into crawlspace - if (!(gSaveContext.eventChkInf[9] & 0x10)) { - EnNb_SetCurrentAnim(this, &gNabooruKneeingAtCrawlspaceAnim, 0, 0.0f, 0); - this->action = NB_CROUCH_CRAWLSPACE; - this->drawMode = NB_DRAW_DEFAULT; - } else { - EnNb_SetCurrentAnim(this, &gNabooruStandingHandsOnHipsAnim, 0, 0.0f, 0); - this->headTurnFlag = 1; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.world.pos = this->finalPos; - this->action = NB_IDLE_AFTER_TALK; - this->drawMode = NB_DRAW_DEFAULT; - } - } else { - Actor_Kill(&this->actor); - } -} - -void func_80AB359C(EnNb* this) { - PosRot* world = &this->actor.world; - Vec3f* initialPos = &this->initialPos; - Vec3f* finalPos = &this->finalPos; - f32 f0; - u16 temp_t1; - s16 temp_2; - - this->movementTimer++; - temp_2 = kREG(17); - temp_t1 = temp_2; - temp_t1 += 25; - - if (temp_t1 >= this->movementTimer) { - f0 = Environment_LerpWeightAccelDecel(temp_t1, 0, this->movementTimer, 3, 3); - world->pos.x = initialPos->x + (f0 * (finalPos->x - initialPos->x)); - world->pos.y = initialPos->y + (f0 * (finalPos->y - initialPos->y)); - world->pos.z = initialPos->z + (f0 * (finalPos->z - initialPos->z)); - } -} - -void EnNb_SetNoticeSFX(EnNb* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_NB_NOTICE); -} - -s32 EnNb_GetNoticedStatus(EnNb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 playerX = player->actor.world.pos.x; - f32 playerZ = player->actor.world.pos.z; - f32 thisX = this->actor.world.pos.x; - f32 thisZ = this->actor.world.pos.z; - - if (SQ(playerX - thisX) + SQ(playerZ - thisZ) < SQ(80.0f)) { - return true; - } else { - return false; - } -} - -void func_80AB36DC(EnNb* this, GlobalContext* globalCtx) { - u16 moveTime = this->movementTimer; - - if ((((u16)((u16)(kREG(17) + 25) - 4))) > moveTime) { - s16 invScale = 4 - moveTime; - - if (invScale > 0) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->pathYaw, invScale, 6200, 100); - } - } else { - s16 invScale = (u16)(kREG(17) + 25) - moveTime; - - if (invScale > 0) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, invScale, 6200, 100); - } - } -} - -void EnNb_CheckNoticed(EnNb* this, GlobalContext* globalCtx) { - if (EnNb_GetNoticedStatus(this, globalCtx)) { - EnNb_SetCurrentAnim(this, &gNabooruStandingToWalkingTransitionAnim, 2, -8.0f, 0); - this->action = NB_NOTICE_PLAYER; - EnNb_SetNoticeSFX(this); - } -} - -void EnNb_SetupIdleCrawlspace(EnNb* this, s32 animFinished) { - if (animFinished) { - EnNb_SetCurrentAnim(this, &gNabooruStandingHandsOnHipsAnim, 0, -8.0f, 0); - this->headTurnFlag = 1; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->action = NB_IDLE_CRAWLSPACE; - } -} - -void func_80AB3838(EnNb* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->action = NB_IN_DIALOG; - } else { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - - if (!(gSaveContext.infTable[22] & 0x1000)) { - this->actor.textId = 0x601D; - } else { - this->actor.textId = 0x6024; - } - - func_8002F2F4(&this->actor, globalCtx); - } -} - -void EnNb_SetupPathMovement(EnNb* this, GlobalContext* globalCtx) { - EnNb_SetCurrentAnim(this, &gNabooruStandingToWalkingTransitionAnim, 2, -8.0f, 0); - gSaveContext.eventChkInf[9] |= 0x10; - this->action = NB_IN_PATH; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); -} - -void EnNb_SetTextIdAsChild(EnNb* this, GlobalContext* globalCtx) { - s32 pad; - u8 choiceIndex; - s32 pad1; - u16 textId; - - textId = this->actor.textId; - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (textId == 0x6025) { - EnNb_SetupPathMovement(this, globalCtx); - } else { - if (textId == 0x6027) { - gSaveContext.infTable[22] |= 0x1000; - } - this->action = NB_IDLE_CRAWLSPACE; - } - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - } else if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - choiceIndex = globalCtx->msgCtx.choiceIndex; - - if (textId == 0x601D) { - switch (choiceIndex) { - case 0: - this->actor.textId = 0x601E; - break; - case 1: - this->actor.textId = 0x601F; - break; - default: - this->actor.textId = 0x6020; - } - } else if (textId == 0x6020) { - switch (choiceIndex) { - case 0: - this->actor.textId = 0x6021; - break; - default: - this->actor.textId = 0x6022; - break; - } - } else { - switch (choiceIndex) { - case 0: - this->actor.textId = 0x6025; - break; - default: - this->actor.textId = 0x6027; - break; - } - } - - Message_ContinueTextbox(globalCtx, this->actor.textId); - } -} - -void func_80AB3A7C(EnNb* this, GlobalContext* globalCtx, s32 animFinished) { - u16 movementTimer = this->movementTimer; - - if ((u16)(kREG(17) + 25) > movementTimer) { - if (animFinished) { - EnNb_SetCurrentAnim(this, &gNabooruWalkingAnim, 0, 0.0f, 0); - } - } else { - EnNb_SetCurrentAnim(this, &gNabooruStandingHandsOnHipsAnim, 0, -8.0f, 0); - this->action = NB_IDLE_AFTER_TALK; - } -} - -void func_80AB3B04(EnNb* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->action = NB_ACTION_30; - } else { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x23); - - if ((this->actor.textId) == 0) { - this->actor.textId = 0x6026; - } - - func_8002F2F4(&this->actor, globalCtx); - } -} - -void func_80AB3B7C(EnNb* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->action = NB_IDLE_AFTER_TALK; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - } -} - -void EnNb_WaitForNotice(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_CheckNoticed(this, globalCtx); -} - -void EnNb_StandUpAfterNotice(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetupIdleCrawlspace(this, animFinished); -} - -void EnNb_BlockCrawlspace(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - func_80AB0FBC(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - func_80AB3838(this, globalCtx); -} - -void EnNb_InitCrawlspaceDialogue(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - func_80AB0FBC(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - EnNb_SetTextIdAsChild(this, globalCtx); -} - -void EnNb_FollowPath(EnNb* this, GlobalContext* globalCtx) { - s32 animFinished; - - func_80AB359C(this); - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - func_80AB36DC(this, globalCtx); - func_80AB10C4(this); - animFinished = EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - func_80AB3A7C(this, globalCtx, animFinished); -} - -void func_80AB3DB0(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - func_80AB0FBC(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - func_80AB3B04(this, globalCtx); -} - -void func_80AB3E10(EnNb* this, GlobalContext* globalCtx) { - func_80AB1284(this, globalCtx); - EnNb_UpdateCollider(this, globalCtx); - func_80AB1040(this, globalCtx); - EnNb_UpdateSkelAnime(this); - EnNb_UpdateEyes(this); - func_80AB3B7C(this, globalCtx); -} - -static EnNbActionFunc sActionFuncs[] = { - EnNb_SetupChamberCs, - EnNb_SetupChamberWarp, - EnNb_ComeUp, - func_80AB193C, - EnNb_RaiseArm, - func_80AB19BC, - func_80AB19FC, - EnNb_Hide, - EnNb_Fade, - EnNb_CreateLightOrb, - func_80AB23A8, - EnNb_MovingInPortal, - EnNb_SuckedInByPortal, - EnNb_CheckConfrontationCsModeWrapper, - func_80AB2C18, - EnNb_Kneel, - EnNb_LookRight, - EnNb_LookLeft, - EnNb_Run, - EnNb_ConfrontationDestroy, - EnNb_CheckCreditsCsMode, - EnNb_CreditsFade, - func_80AB3428, - EnNb_LookUp, - EnNb_WaitForNotice, - EnNb_StandUpAfterNotice, - EnNb_BlockCrawlspace, - EnNb_InitCrawlspaceDialogue, - EnNb_FollowPath, - func_80AB3DB0, - func_80AB3E10, -}; - -void EnNb_Update(Actor* thisx, GlobalContext* globalCtx) { - EnNb* this = (EnNb*)thisx; - - if (this->action < 0 || this->action > 30 || sActionFuncs[this->action] == NULL) { - // "Main mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sActionFuncs[this->action](this, globalCtx); -} - -void EnNb_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnNb* this = (EnNb*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - EnNb_SetupCollider(thisx, globalCtx); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gNabooruSkel, NULL, this->jointTable, this->morphTable, - NB_LIMB_MAX); - - switch (EnNb_GetType(this)) { - case NB_TYPE_DEMO02: - EnNb_SetupLightArrowOrSealingCs(this, globalCtx); - break; - case NB_TYPE_KIDNAPPED: - EnNb_InitKidnap(this, globalCtx); - break; - case NB_TYPE_KNUCKLE: - EnNb_SetupConfrontation(this, globalCtx); - break; - case NB_TYPE_CREDITS: - EnNb_SetupCreditsSpawn(this, globalCtx); - break; - case NB_TYPE_CRAWLSPACE: - EnNb_CrawlspaceSpawnCheck(this, globalCtx); - break; - default: // giving medallion - EnNb_SetChamberAnim(this, globalCtx); - break; - } -} - -s32 EnNb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnNb* this = (EnNb*)thisx; - struct_80034A14_arg1* unk_300 = &this->unk_300; - s32 ret = false; - - if (this->headTurnFlag != 0) { - if (limbIndex == NB_LIMB_TORSO) { - rot->x += unk_300->unk_0E.y; - rot->y -= unk_300->unk_0E.x; - ret = false; - } else if (limbIndex == NB_LIMB_HEAD) { - rot->x += unk_300->unk_08.y; - rot->z += unk_300->unk_08.x; - ret = false; - } - } - - return ret; -} - -void EnNb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnNb* this = (EnNb*)thisx; - - if (limbIndex == NB_LIMB_HEAD) { - Vec3f vec1 = { 0.0f, 10.0f, 0.0f }; - Vec3f vec2; - - Matrix_MultVec3f(&vec1, &vec2); - this->actor.focus.pos.x = vec2.x; - this->actor.focus.pos.y = vec2.y; - this->actor.focus.pos.z = vec2.z; - this->actor.focus.rot.x = this->actor.world.rot.x; - this->actor.focus.rot.y = this->actor.world.rot.y; - this->actor.focus.rot.z = this->actor.world.rot.z; - } -} - -void EnNb_DrawNothing(EnNb* this, GlobalContext* globalCtx) { -} - -void EnNb_DrawDefault(EnNb* this, GlobalContext* globalCtx) { - s32 pad; - s16 eyeIdx = this->eyeIdx; - SkelAnime* skelAnime = &this->skelAnime; - void* eyeTexture = sEyeTextures[eyeIdx]; - s32 pad1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb.c", 992); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnNb_OverrideLimbDraw, EnNb_PostLimbDraw, &this->actor); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb.c", 1013); -} - -static EnNbDrawFunc sDrawFuncs[] = { - EnNb_DrawNothing, EnNb_DrawDefault, EnNb_DrawTransparency, func_80AB2E70, func_80AB2FE4, -}; - -void EnNb_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnNb* this = (EnNb*)thisx; - - if (this->drawMode < 0 || this->drawMode >= 5 || sDrawFuncs[this->drawMode] == NULL) { - // "Draw mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sDrawFuncs[this->drawMode](this, globalCtx); -} - -const ActorInit En_Nb_InitVars = { - ACTOR_EN_NB, - ACTORCAT_NPC, - FLAGS, - OBJECT_NB, - sizeof(EnNb), - (ActorFunc)EnNb_Init, - (ActorFunc)EnNb_Destroy, - (ActorFunc)EnNb_Update, - (ActorFunc)EnNb_Draw, -}; diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.cpp b/src/overlays/actors/ovl_En_Nb/z_en_nb.cpp new file mode 100644 index 000000000..f47b35598 --- /dev/null +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.cpp @@ -0,0 +1,1555 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NB_Z_EN_NB_C +#include "actor_common.h" +/* + * File: z_en_nb.c + * Overlay: ovl_En_Nb + * Description: Nabooru + */ + +#include "z_en_nb.h" +#include "vt.h" +#include "objects/object_nb/object_nb.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef enum { + /* 0x00 */ NB_CHAMBER_INIT, + /* 0x01 */ NB_CHAMBER_UNDERGROUND, + /* 0x02 */ NB_CHAMBER_APPEAR, + /* 0x03 */ NB_CHAMBER_IDLE, + /* 0x04 */ NB_CHAMBER_RAISE_ARM, + /* 0x05 */ NB_CHAMBER_RAISE_ARM_TRANSITION, + /* 0x06 */ NB_GIVE_MEDALLION, + /* 0x07 */ NB_ACTION_7, + /* 0x08 */ NB_SEAL_HIDE, + /* 0x09 */ NB_ACTION_9, + /* 0x0A */ NB_KIDNAPPED, + /* 0x0B */ NB_KIDNAPPED_LOOK_AROUND, + /* 0x0C */ NB_PORTAL_FALLTHROUGH, + /* 0x0D */ NB_IN_CONFRONTATION, + /* 0x0E */ NB_ACTION_14, + /* 0x0F */ NB_KNEEL, + /* 0x10 */ NB_LOOK_RIGHT, + /* 0x11 */ NB_LOOK_LEFT, + /* 0x12 */ NB_RUN, + /* 0x13 */ NB_CONFRONTATION_DESTROYED, + /* 0x14 */ NB_CREDITS_INIT, + /* 0x15 */ NB_CREDITS_FADEIN, + /* 0x16 */ NB_CREDITS_SIT, + /* 0x17 */ NB_CREDITS_HEAD_TURN, + /* 0x18 */ NB_CROUCH_CRAWLSPACE, + /* 0x19 */ NB_NOTICE_PLAYER, + /* 0x1A */ NB_IDLE_CRAWLSPACE, + /* 0x1B */ NB_IN_DIALOG, + /* 0x1C */ NB_IN_PATH, + /* 0x1D */ NB_IDLE_AFTER_TALK, + /* 0x1E */ NB_ACTION_30 +} EnNbAction; + +typedef enum { + /* 0x00 */ NB_DRAW_NOTHING, + /* 0x01 */ NB_DRAW_DEFAULT, + /* 0x02 */ NB_DRAW_HIDE, + /* 0x03 */ NB_DRAW_KNEEL, + /* 0x04 */ NB_DRAW_LOOK_DIRECTION +} EnNbDrawMode; + +void EnNb_Init(Actor* thisx, GlobalContext* globalCtx); +void EnNb_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnNb_Update(Actor* thisx, GlobalContext* globalCtx); +void EnNb_Draw(Actor* thisx, GlobalContext* globalCtx); + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 25, 80, 0, { 0, 0, 0 } }, +}; + +static void* sEyeTextures[] = { + gNabooruEyeOpenTex, + gNabooruEyeHalfTex, + gNabooruEyeClosedTex, +}; + +static s32 D_80AB4318 = 0; + +#include "z_en_nb_cutscene_data.cpp" EARLY + +s32 EnNb_GetPath(EnNb* pthis) { + s32 path = pthis->actor.params >> 8; + + return path & 0xFF; +} + +s32 EnNb_GetType(EnNb* pthis) { + s32 type = pthis->actor.params; + + return type & 0xFF; +} + +void EnNb_UpdatePath(EnNb* pthis, GlobalContext* globalCtx) { + Vec3s* pointPos; + Path* pathList; + s32 pad; + s32 path; + + pathList = globalCtx->setupPathList; + + if (pathList != NULL) { + path = EnNb_GetPath(pthis); + pathList += path; + pointPos = SEGMENTED_TO_VIRTUAL(pathList->points); + pthis->initialPos.x = pointPos[0].x; + pthis->initialPos.y = pointPos[0].y; + pthis->initialPos.z = pointPos[0].z; + pthis->finalPos.x = pointPos[1].x; + pthis->finalPos.y = pointPos[1].y; + pthis->finalPos.z = pointPos[1].z; + pthis->pathYaw = (Math_FAtan2F(pthis->finalPos.x - pthis->initialPos.x, pthis->finalPos.z - pthis->initialPos.z) * + (0x8000 / M_PI)); + // "En_Nb_Get_path_info Rail Data Get! = %d!!!!!!!!!!!!!!" + osSyncPrintf("En_Nb_Get_path_info レールデータをゲットだぜ = %d!!!!!!!!!!!!!!\n", path); + } else { + // "En_Nb_Get_path_info Rail Data Doesn't Exist!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf("En_Nb_Get_path_info レールデータが無い!!!!!!!!!!!!!!!!!!!!\n"); + } +} + +void EnNb_SetupCollider(Actor* thisx, GlobalContext* globalCtx) { + EnNb* pthis = (EnNb*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, thisx, &sCylinderInit); +} + +void EnNb_UpdateCollider(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad[4]; + ColliderCylinder* collider = &pthis->collider; + + Collider_UpdateCylinder(&pthis->actor, collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); +} + +void EnNb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNb* pthis = (EnNb*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AB0FBC(EnNb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_300.unk_18 = player->actor.world.pos; + pthis->unk_300.unk_14 = kREG(16) + 9.0f; + func_80034A14(&pthis->actor, &pthis->unk_300, kREG(17) + 0xC, 2); +} + +void func_80AB1040(EnNb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_300.unk_18 = player->actor.world.pos; + pthis->unk_300.unk_14 = kREG(16) + 9.0f; + func_80034A14(&pthis->actor, &pthis->unk_300, kREG(17) + 0xC, 4); +} + +void func_80AB10C4(EnNb* pthis) { + s32 pad2[2]; + Vec3s* tempPtr; + Vec3s* tempPtr2; + + tempPtr = &pthis->unk_300.unk_08; + Math_SmoothStepToS(&tempPtr->x, 0, 20, 6200, 100); + Math_SmoothStepToS(&tempPtr->y, 0, 20, 6200, 100); + tempPtr2 = &pthis->unk_300.unk_0E; + Math_SmoothStepToS(&tempPtr2->x, 0, 20, 6200, 100); + Math_SmoothStepToS(&tempPtr2->y, 0, 20, 6200, 100); +} + +void EnNb_UpdateEyes(EnNb* pthis) { + s32 pad[3]; + s16* blinkTimer = &pthis->blinkTimer; + s16* eyeIdx = &pthis->eyeIdx; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + + *eyeIdx = *blinkTimer; + if (*eyeIdx >= ARRAY_COUNT(sEyeTextures)) { + *eyeIdx = 0; + } +} + +void func_80AB11EC(EnNb* pthis) { + pthis->action = NB_ACTION_7; + pthis->drawMode = NB_DRAW_NOTHING; + pthis->alpha = 0; + pthis->flag = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->alphaTimer = 0.0f; +} + +void func_80AB1210(EnNb* pthis, GlobalContext* globalCtx) { + s32 one; // required to match + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + if (D_80AB4318) { + if (pthis->actor.params == NB_TYPE_DEMO02) { + func_80AB11EC(pthis); + } + + D_80AB4318 = 0; + } + } else { + one = 1; + if (!D_80AB4318) { + D_80AB4318 = one; + } + } +} + +void func_80AB1284(EnNb* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 4); +} + +s32 EnNb_UpdateSkelAnime(EnNb* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +CsCmdActorAction* EnNb_GetNpcCsAction(GlobalContext* globalCtx, s32 npcActionIdx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[npcActionIdx]; + } + return NULL; +} + +void EnNb_SetupCsPosRot(EnNb* pthis, GlobalContext* globalCtx, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, npcActionIdx); + s16 newRotY; + Actor* thisx = &pthis->actor; + + if (csCmdNPCAction != NULL) { + thisx->world.pos.x = csCmdNPCAction->startPos.x; + thisx->world.pos.y = csCmdNPCAction->startPos.y; + thisx->world.pos.z = csCmdNPCAction->startPos.z; + thisx->world.rot.y = thisx->shape.rot.y = csCmdNPCAction->rot.y; + } +} + +s32 func_80AB1390(EnNb* pthis, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction; + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && + (csCmdNPCAction = globalCtx->csCtx.npcActions[npcActionIdx], csCmdNPCAction != NULL) && + (csCmdNPCAction->action == arg2)) { + return true; + } + return false; +} + +s32 func_80AB13D8(EnNb* pthis, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction; + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && + (csCmdNPCAction = globalCtx->csCtx.npcActions[npcActionIdx], csCmdNPCAction != NULL) && + (csCmdNPCAction->action != arg2)) { + return true; + } + return false; +} + +void EnNb_SetInitialCsPosRot(EnNb* pthis, GlobalContext* globalCtx, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, npcActionIdx); + Actor* thisx = &pthis->actor; + + if (csCmdNPCAction != NULL) { + thisx->world.pos.x = csCmdNPCAction->startPos.x; + thisx->world.pos.y = csCmdNPCAction->startPos.y; + thisx->world.pos.z = csCmdNPCAction->startPos.z; + thisx->world.rot.y = thisx->shape.rot.y = csCmdNPCAction->rot.y; + } +} + +void EnNb_SetCurrentAnim(EnNb* pthis, AnimationHeader* animation, u8 mode, f32 transitionRate, s32 arg4) { + f32 frameCount = Animation_GetLastFrame(animation); + f32 playbackSpeed; + f32 unk0; + f32 fc; + + if (!arg4) { + unk0 = 0.0f; + fc = frameCount; + playbackSpeed = 1.0f; + } else { + unk0 = frameCount; + fc = 0.0f; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animation, playbackSpeed, unk0, fc, mode, transitionRate); +} + +void EnNb_SetChamberAnim(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetCurrentAnim(pthis, &gNabooruStandingHandsOnHipsChamberOfSagesAnim, 0, 0, 0); + pthis->actor.shape.yOffset = -10000.0f; +} + +void EnNb_SpawnBlueWarp(EnNb* pthis, GlobalContext* globalCtx) { + f32 posX = pthis->actor.world.pos.x; + f32 posY = pthis->actor.world.pos.y; + f32 posZ = pthis->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, + WARP_SAGES); +} + +void EnNb_GiveMedallion(EnNb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 posX = player->actor.world.pos.x; + f32 posY = player->actor.world.pos.y + 50.0f; + f32 posZ = player->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, + 0xC); + Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); +} + +void EnNb_ComeUpImpl(EnNb* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.yOffset += 250.0f / 3.0f; +} + +void EnNb_SetupChamberCsImpl(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + + if ((gSaveContext.chamberCutsceneNum == 3) && (gSaveContext.sceneSetupIndex < 4)) { + player = GET_PLAYER(globalCtx); + pthis->action = NB_CHAMBER_UNDERGROUND; + globalCtx->csCtx.segment = &D_80AB431C; + gSaveContext.cutsceneTrigger = 2; + Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); + player->actor.world.rot.y = player->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + } +} + +void EnNb_SetupChamberWarpImpl(EnNb* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + CsCmdActorAction* csCmdNPCAction; + + if (csCtx->state != CS_STATE_IDLE) { + csCmdNPCAction = csCtx->npcActions[1]; + if (csCmdNPCAction != NULL && csCmdNPCAction->action == 2) { + pthis->action = NB_CHAMBER_APPEAR; + pthis->drawMode = NB_DRAW_DEFAULT; + EnNb_SpawnBlueWarp(pthis, globalCtx); + } + } +} + +void EnNb_SetupDefaultChamberIdle(EnNb* pthis) { + if (pthis->actor.shape.yOffset >= 0.0f) { + pthis->action = NB_CHAMBER_IDLE; + pthis->actor.shape.yOffset = 0.0f; + } +} + +void EnNb_SetupArmRaise(EnNb* pthis, GlobalContext* globalCtx) { + AnimationHeader* animation = &gNabooruRaisingArmsGivingMedallionAnim; + CsCmdActorAction* csCmdNPCAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdNPCAction = globalCtx->csCtx.npcActions[1]; + if (csCmdNPCAction != NULL && csCmdNPCAction->action == 3) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, + 0.0f); + pthis->action = NB_CHAMBER_RAISE_ARM; + } + } +} + +void EnNb_SetupRaisedArmTransition(EnNb* pthis, s32 animFinished) { + AnimationHeader* animation = &gNabooruArmsRaisedGivingMedallionAnim; + + if (animFinished) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, + 0.0f); + pthis->action = NB_CHAMBER_RAISE_ARM_TRANSITION; + } +} + +void EnNb_SetupMedallion(EnNb* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdNPCAction = globalCtx->csCtx.npcActions[6]; + if (csCmdNPCAction != NULL && csCmdNPCAction->action == 2) { + pthis->action = NB_GIVE_MEDALLION; + EnNb_GiveMedallion(pthis, globalCtx); + } + } +} + +// Action func is never explicitly set to pthis, but it runs when the memory gets zero cleared +void EnNb_SetupChamberCs(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetupChamberCsImpl(pthis, globalCtx); +} + +void EnNb_SetupChamberWarp(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetupChamberWarpImpl(pthis, globalCtx); +} + +void EnNb_ComeUp(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_ComeUpImpl(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetupDefaultChamberIdle(pthis); +} + +void func_80AB193C(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetupArmRaise(pthis, globalCtx); +} + +void EnNb_RaiseArm(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + func_80AB1284(pthis, globalCtx); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetupRaisedArmTransition(pthis, animFinished); +} + +void func_80AB19BC(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetupMedallion(pthis, globalCtx); +} + +void func_80AB19FC(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); +} + +void EnNb_SetupLightArrowOrSealingCs(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetCurrentAnim(pthis, &gNabooruPuttingHandsTogetherCastingMagicAnim, 2, 0.0f, 0); + pthis->action = NB_ACTION_7; + pthis->actor.shape.shadowAlpha = 0; +} + +void EnNb_PlaySealingSound(void) { + func_800788CC(NA_SE_SY_WHITE_OUT_T); +} + +void EnNb_InitializeDemo6K(EnNb* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + kREG(21) + 22.0f + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 7); +} + +void EnNb_SetupHide(EnNb* pthis, GlobalContext* globalCtx) { + if (func_80AB1390(pthis, globalCtx, 4, 1)) { + pthis->action = NB_SEAL_HIDE; + pthis->drawMode = NB_DRAW_HIDE; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->alphaTimer = 0.0f; + EnNb_PlaySealingSound(); + } +} + +void EnNb_CheckToFade(EnNb* pthis, GlobalContext* globalCtx) { + f32* alphaTimer = &pthis->alphaTimer; + s32 alpha; + + if (func_80AB1390(pthis, globalCtx, 4, 1)) { + *alphaTimer += 1.0f; + if (*alphaTimer >= kREG(5) + 10.0f) { + pthis->action = NB_ACTION_9; + pthis->drawMode = NB_DRAW_DEFAULT; + *alphaTimer = kREG(5) + 10.0f; + pthis->alpha = 255; + pthis->actor.shape.shadowAlpha = 0xFF; + return; + } + } else { + *alphaTimer -= 1.0f; + if (*alphaTimer <= 0.0f) { + pthis->action = NB_ACTION_7; + pthis->drawMode = NB_DRAW_NOTHING; + *alphaTimer = 0.0f; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + return; + } + } + + alpha = (*alphaTimer / (kREG(5) + 10.0f)) * 255.0f; + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; +} + +void EnNb_SetupLightOrb(EnNb* pthis, GlobalContext* globalCtx) { + if (func_80AB13D8(pthis, globalCtx, 4, 1)) { + pthis->action = NB_SEAL_HIDE; + pthis->drawMode = NB_DRAW_HIDE; + pthis->alphaTimer = kREG(5) + 10.0f; + pthis->alpha = 255; + + if (pthis->flag == 0) { + EnNb_InitializeDemo6K(pthis, globalCtx); + pthis->flag = 1; + } + + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void EnNb_Hide(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetupHide(pthis, globalCtx); + func_80AB1210(pthis, globalCtx); +} + +void EnNb_Fade(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_CheckToFade(pthis, globalCtx); + func_80AB1210(pthis, globalCtx); +} + +void EnNb_CreateLightOrb(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetupLightOrb(pthis, globalCtx); + func_80AB1210(pthis, globalCtx); +} + +void EnNb_DrawTransparency(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeSegIdx = pthis->eyeIdx; + void* eyeTex = sEyeTextures[eyeSegIdx]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inKenjyanomaDemo02.c", 263); + + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + NULL, NULL, NULL, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inKenjyanomaDemo02.c", 290); +} + +void EnNb_InitKidnap(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetCurrentAnim(pthis, &gNabooruTrappedInVortexPushingGroundAnim, 0, 0.0f, 0); + pthis->action = NB_KIDNAPPED; + pthis->actor.shape.shadowAlpha = 0; + gSaveContext.eventChkInf[9] |= 0x20; +} + +void EnNb_PlayCrySFX(EnNb* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 3) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_NB_CRY_0); + } +} + +void EnNb_PlayAgonySFX(EnNb* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 420) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_NB_AGONY); + } +} + +void EnNb_SetPosInPortal(EnNb* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); + Vec3f* pos = &pthis->actor.world.pos; + f32 f0; + s32 pad; + Vec3f startPos; + Vec3f endPos; + + if (csCmdNPCAction != NULL) { + f0 = Environment_LerpWeightAccelDecel(csCmdNPCAction->endFrame, csCmdNPCAction->startFrame, + globalCtx->csCtx.frames, 4, 4); + startPos.x = csCmdNPCAction->startPos.x; + startPos.y = csCmdNPCAction->startPos.y; + startPos.z = csCmdNPCAction->startPos.z; + endPos.x = csCmdNPCAction->endPos.x; + endPos.y = csCmdNPCAction->endPos.y; + endPos.z = csCmdNPCAction->endPos.z; + pos->x = ((endPos.x - startPos.x) * f0) + startPos.x; + pos->y = ((endPos.y - startPos.y) * f0) + startPos.y; + pos->z = ((endPos.z - startPos.z) * f0) + startPos.z; + } +} + +void EnNb_SetupCaptureCutsceneState(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetupCsPosRot(pthis, globalCtx, 1); + pthis->action = NB_KIDNAPPED; + pthis->drawMode = NB_DRAW_NOTHING; + pthis->actor.shape.shadowAlpha = 0; +} + +void EnNb_SetRaisedArmCaptureAnim(EnNb* pthis, s32 animFinished) { + AnimationHeader* animation = &gNabooruSuckedByVortexAnim; + + if (animFinished) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, + 0.0f); + } +} + +void EnNb_SetupLookAroundInKidnap(EnNb* pthis) { + AnimationHeader* animation = &gNabooruTrappedInVortexPushingGroundAnim; + + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, -8.0f); + pthis->action = NB_KIDNAPPED_LOOK_AROUND; + pthis->drawMode = NB_DRAW_DEFAULT; +} + +void EnNb_SetupKidnap(EnNb* pthis) { + AnimationHeader* animation = &gNabooruTrappedInVortexRaisingArmAnim; + + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, -8.0f); + pthis->action = NB_PORTAL_FALLTHROUGH; + pthis->drawMode = NB_DRAW_DEFAULT; +} + +void EnNb_CheckKidnapCsMode(EnNb* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); + s32 action; + s32 previousCsAction; + + if (csCmdNPCAction != NULL) { + action = csCmdNPCAction->action; + previousCsAction = pthis->previousCsAction; + if (action != previousCsAction) { + switch (action) { + case 1: + EnNb_SetupCaptureCutsceneState(pthis, globalCtx); + break; + case 7: + EnNb_SetupLookAroundInKidnap(pthis); + break; + case 8: + EnNb_SetupKidnap(pthis); + break; + case 9: + Actor_Kill(&pthis->actor); + break; + default: + // "Operation Doesn't Exist!!!!!!!!" + osSyncPrintf("En_Nb_Kidnap_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + pthis->previousCsAction = action; + } + } +} + +void func_80AB23A8(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_PlayCrySFX(pthis, globalCtx); + EnNb_CheckKidnapCsMode(pthis, globalCtx); +} + +void EnNb_MovingInPortal(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_PlayCrySFX(pthis, globalCtx); + EnNb_PlayAgonySFX(pthis, globalCtx); + EnNb_UpdateEyes(pthis); + EnNb_UpdateSkelAnime(pthis); + EnNb_CheckKidnapCsMode(pthis, globalCtx); +} + +void EnNb_SuckedInByPortal(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + EnNb_UpdateEyes(pthis); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_SetRaisedArmCaptureAnim(pthis, animFinished); + EnNb_SetPosInPortal(pthis, globalCtx); + EnNb_CheckKidnapCsMode(pthis, globalCtx); +} + +void EnNb_SetupConfrontation(EnNb* pthis, GlobalContext* globalCtx) { + AnimationHeader* animation = &gNabooruCollapseFromStandingToKneelingTransitionAnim; + + EnNb_SetCurrentAnim(pthis, animation, 0, 0.0f, 0); + pthis->action = NB_IN_CONFRONTATION; + pthis->actor.shape.shadowAlpha = 0; +} + +void EnNb_PlayKnuckleDefeatSFX(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + + if (globalCtx->csCtx.frames == 548) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_NB_CRY_0); + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_FANTOM_HIT_THUNDER); + } +} + +void EnNb_PlayKneelingOnGroundSFX(EnNb* pthis) { + s32 pad[2]; + + if ((pthis->skelAnime.mode == 2) && + (Animation_OnFrame(&pthis->skelAnime, 18.0f) || Animation_OnFrame(&pthis->skelAnime, 25.0f))) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_HUMAN_BOUND); + } +} + +void EnNb_PlayLookRightSFX(EnNb* pthis) { + s32 pad[2]; + + if ((pthis->skelAnime.mode == 2) && Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_CONCRETE); + } +} + +void EnNb_PlayLookLeftSFX(EnNb* pthis) { + s32 pad[2]; + + if (Animation_OnFrame(&pthis->skelAnime, 9.0f) || Animation_OnFrame(&pthis->skelAnime, 13.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_CONCRETE); + } +} + +void EnNb_InitDemo6KInConfrontation(EnNb* pthis, GlobalContext* globalCtx) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + kREG(21) + 22.0f + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0xB); +} + +void func_80AB2688(EnNb* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 1; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_80AB26C8(EnNb* pthis) { + pthis->action = NB_IN_CONFRONTATION; + pthis->drawMode = NB_DRAW_NOTHING; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80AB26DC(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad; + AnimationHeader* animation = &gNabooruCollapseFromStandingToKneelingTransitionAnim; + f32 lastFrame = Animation_GetLastFrame(animation); + + EnNb_SetupCsPosRot(pthis, globalCtx, 1); + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + pthis->action = NB_ACTION_14; + pthis->drawMode = NB_DRAW_KNEEL; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void EnNb_SetupKneel(EnNb* pthis) { + AnimationHeader* animation = &gNabooruCollapseFromStandingToKneelingTransitionAnim; + f32 lastFrame = Animation_GetLastFrame(animation); + + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + pthis->action = NB_KNEEL; + pthis->drawMode = NB_DRAW_KNEEL; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void EnNb_CheckIfKneeling(EnNb* pthis, s32 animFinished) { + AnimationHeader* animation = &gNabooruOnAllFoursAnim; + + if (animFinished) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, + 0.0f); + pthis->drawMode = NB_DRAW_KNEEL; + } +} + +void EnNb_SetupLookRight(EnNb* pthis) { + AnimationHeader* animation = &gNabooruOnAllFoursToOnOneKneeLookingRightTransitionAnim; + f32 lastFrame = Animation_GetLastFrame(animation); + + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -8.0f); + pthis->action = NB_LOOK_RIGHT; + pthis->drawMode = NB_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void EnNb_CheckIfLookingRight(EnNb* pthis, s32 animFinished) { + AnimationHeader* animation = &gNabooruOnOneKneeLookingRightAnim; + + if (animFinished) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, + 0.0f); + pthis->drawMode = NB_DRAW_LOOK_DIRECTION; + } +} + +void EnNb_SetupLookLeft(EnNb* pthis) { + AnimationHeader* animation = &gNabooruOnOneKneeTurningHeadRightToLeftTransitionAnim; + f32 lastFrame = Animation_GetLastFrame(animation); + + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -8.0f); + pthis->action = NB_LOOK_LEFT; + pthis->drawMode = NB_DRAW_LOOK_DIRECTION; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void EnNb_CheckIfLookLeft(EnNb* pthis, s32 animFinished) { + AnimationHeader* animation = &gNabooruOnOneKneeLookingLeftAnim; + + if (animFinished) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, + 0.0f); + } +} + +void EnNb_SetupDemo6KInConfrontation(EnNb* pthis, GlobalContext* globalCtx, s32 animFinished) { + if (!pthis->flag && animFinished) { + EnNb_InitDemo6KInConfrontation(pthis, globalCtx); + pthis->flag = 1; + } +} + +void EnNb_SetupRun(EnNb* pthis) { + AnimationHeader* animation = &gNabooruKneeingToRunningToHitAnim; + f32 lastFrame = Animation_GetLastFrame(animation); + + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -8.0f); + pthis->action = NB_RUN; + pthis->drawMode = NB_DRAW_LOOK_DIRECTION; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void EnNb_SetupConfrontationDestroy(EnNb* pthis) { + pthis->action = NB_CONFRONTATION_DESTROYED; + pthis->drawMode = NB_DRAW_NOTHING; + pthis->actor.shape.shadowAlpha = 0; +} + +void EnNb_CheckConfrontationCsMode(EnNb* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction; + s32 csAction; + s32 previousCsAction; + + csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); + if (csCmdNPCAction != NULL) { + csAction = csCmdNPCAction->action; + previousCsAction = pthis->previousCsAction; + + if (csAction != previousCsAction) { + switch (csAction) { + case 1: + func_80AB26C8(pthis); + break; + case 10: + func_80AB26DC(pthis, globalCtx); + break; + case 11: + EnNb_SetupKneel(pthis); + break; + case 12: + EnNb_SetupLookRight(pthis); + break; + case 13: + EnNb_SetupLookLeft(pthis); + break; + case 14: + EnNb_SetupRun(pthis); + break; + case 9: + EnNb_SetupConfrontationDestroy(pthis); + break; + default: + // "En_Nb_Confrontion_Check_DemoMode: Operation doesn't exist!!!!!!!!" + osSyncPrintf("En_Nb_Confrontion_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + pthis->previousCsAction = csAction; + } + } +} + +void EnNb_CheckConfrontationCsModeWrapper(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_CheckConfrontationCsMode(pthis, globalCtx); +} + +void func_80AB2C18(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_UpdateEyes(pthis); + func_80AB2688(pthis, globalCtx); + func_80AB1284(pthis, globalCtx); + EnNb_CheckConfrontationCsMode(pthis, globalCtx); +} + +void EnNb_Kneel(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + EnNb_UpdateEyes(pthis); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_CheckIfKneeling(pthis, animFinished); + EnNb_PlayKneelingOnGroundSFX(pthis); + func_80AB2688(pthis, globalCtx); + func_80AB1284(pthis, globalCtx); + EnNb_CheckConfrontationCsMode(pthis, globalCtx); +} + +void EnNb_LookRight(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + EnNb_UpdateEyes(pthis); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_CheckIfLookingRight(pthis, animFinished); + EnNb_PlayLookRightSFX(pthis); + func_80AB2688(pthis, globalCtx); + func_80AB1284(pthis, globalCtx); + EnNb_CheckConfrontationCsMode(pthis, globalCtx); +} + +void EnNb_LookLeft(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + EnNb_UpdateEyes(pthis); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_CheckIfLookLeft(pthis, animFinished); + func_80AB2688(pthis, globalCtx); + func_80AB1284(pthis, globalCtx); + EnNb_CheckConfrontationCsMode(pthis, globalCtx); +} + +void EnNb_Run(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + EnNb_PlayKnuckleDefeatSFX(pthis, globalCtx); + EnNb_UpdateEyes(pthis); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_PlayLookLeftSFX(pthis); + func_80AB2688(pthis, globalCtx); + func_80AB1284(pthis, globalCtx); + EnNb_SetupDemo6KInConfrontation(pthis, globalCtx, animFinished); + EnNb_CheckConfrontationCsMode(pthis, globalCtx); +} + +void EnNb_ConfrontationDestroy(EnNb* pthis, GlobalContext* globalCtx) { + pthis->timer++; + + if (pthis->timer > 60.0f) { + Actor_Kill(&pthis->actor); + } +} + +void func_80AB2E70(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 572); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gNabooruEyeWideTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gNabooruEyeWideTex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, + &pthis->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 593); +} + +s32 func_80AB2FC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnNb* pthis = (EnNb*)thisx; + + if (limbIndex == NB_LIMB_HEAD) { + *dList = gNabooruHeadMouthOpenDL; + } + + return 0; +} + +void func_80AB2FE4(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 eyeIdx = pthis->eyeIdx; + SkelAnime* skelAnime = &pthis->skelAnime; + void* eyeTexture = sEyeTextures[eyeIdx]; + s32 pad1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 623); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, func_80AB2FC0, + NULL, &pthis->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb_inConfrontion.c", 644); +} + +void EnNb_SetupCreditsSpawn(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetCurrentAnim(pthis, &gNabooruSittingCrossLeggedAnim, 0, 0.0f, 0); + pthis->action = NB_CREDITS_INIT; + pthis->drawMode = NB_DRAW_NOTHING; + pthis->actor.shape.shadowAlpha = 0; +} + +void EnNb_SetAlphaInCredits(EnNb* pthis) { + f32* alphaTimer = &pthis->alphaTimer; + s32 alpha; + + pthis->alphaTimer++; + + if ((kREG(17) + 10.0f) <= pthis->alphaTimer) { + pthis->alpha = 255; + pthis->actor.shape.shadowAlpha = 255; + } else { + alpha = (*alphaTimer / (kREG(17) + 10.0f)) * 255.0f; + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; + } +} + +void EnNb_SetupCreditsFadeIn(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetInitialCsPosRot(pthis, globalCtx, 1); + pthis->action = NB_CREDITS_FADEIN; + pthis->drawMode = NB_DRAW_HIDE; +} + +void EnNb_SetupCreditsSit(EnNb* pthis) { + if (pthis->alphaTimer >= kREG(17) + 10.0f) { + pthis->action = NB_CREDITS_SIT; + pthis->drawMode = NB_DRAW_DEFAULT; + } +} + +void EnNb_SetupCreditsHeadTurn(EnNb* pthis) { + EnNb_SetCurrentAnim(pthis, &gNabooruSittingCrossLeggedTurningToLookUpRightTransitionAnim, 2, -8.0f, 0); + pthis->action = NB_CREDITS_HEAD_TURN; +} + +void EnNb_CheckIfLookingUp(EnNb* pthis, s32 animFinished) { + if (animFinished) { + EnNb_SetCurrentAnim(pthis, &gNabooruSittingCrossLeggedLookingUpRightAnim, 0, 0.0f, 0); + } +} + +void EnNb_CheckCreditsCsModeImpl(EnNb* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction = EnNb_GetNpcCsAction(globalCtx, 1); + s32 action; + s32 previousCsAction; + + if (csCmdNPCAction != NULL) { + action = csCmdNPCAction->action; + previousCsAction = pthis->previousCsAction; + if (action != previousCsAction) { + switch (action) { + case 15: + EnNb_SetupCreditsFadeIn(pthis, globalCtx); + break; + case 16: + EnNb_SetupCreditsHeadTurn(pthis); + break; + default: + // "En_Nb_inEnding_Check_DemoMode: Operation doesn't exist!!!!!!!!" + osSyncPrintf("En_Nb_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + pthis->previousCsAction = action; + } + } +} + +void EnNb_CheckCreditsCsMode(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_CheckCreditsCsModeImpl(pthis, globalCtx); +} + +void EnNb_CreditsFade(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetAlphaInCredits(pthis); + EnNb_SetupCreditsSit(pthis); +} + +void func_80AB3428(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_CheckCreditsCsModeImpl(pthis, globalCtx); +} + +void EnNb_LookUp(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + func_80AB1284(pthis, globalCtx); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_CheckIfLookingUp(pthis, animFinished); +} + +void EnNb_CrawlspaceSpawnCheck(EnNb* pthis, GlobalContext* globalCtx) { + if (!(gSaveContext.eventChkInf[9] & 0x20) && LINK_IS_CHILD) { + EnNb_UpdatePath(pthis, globalCtx); + + // looking into crawlspace + if (!(gSaveContext.eventChkInf[9] & 0x10)) { + EnNb_SetCurrentAnim(pthis, &gNabooruKneeingAtCrawlspaceAnim, 0, 0.0f, 0); + pthis->action = NB_CROUCH_CRAWLSPACE; + pthis->drawMode = NB_DRAW_DEFAULT; + } else { + EnNb_SetCurrentAnim(pthis, &gNabooruStandingHandsOnHipsAnim, 0, 0.0f, 0); + pthis->headTurnFlag = 1; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.world.pos = pthis->finalPos; + pthis->action = NB_IDLE_AFTER_TALK; + pthis->drawMode = NB_DRAW_DEFAULT; + } + } else { + Actor_Kill(&pthis->actor); + } +} + +void func_80AB359C(EnNb* pthis) { + PosRot* world = &pthis->actor.world; + Vec3f* initialPos = &pthis->initialPos; + Vec3f* finalPos = &pthis->finalPos; + f32 f0; + u16 temp_t1; + s16 temp_2; + + pthis->movementTimer++; + temp_2 = kREG(17); + temp_t1 = temp_2; + temp_t1 += 25; + + if (temp_t1 >= pthis->movementTimer) { + f0 = Environment_LerpWeightAccelDecel(temp_t1, 0, pthis->movementTimer, 3, 3); + world->pos.x = initialPos->x + (f0 * (finalPos->x - initialPos->x)); + world->pos.y = initialPos->y + (f0 * (finalPos->y - initialPos->y)); + world->pos.z = initialPos->z + (f0 * (finalPos->z - initialPos->z)); + } +} + +void EnNb_SetNoticeSFX(EnNb* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_NB_NOTICE); +} + +s32 EnNb_GetNoticedStatus(EnNb* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 playerX = player->actor.world.pos.x; + f32 playerZ = player->actor.world.pos.z; + f32 thisX = pthis->actor.world.pos.x; + f32 thisZ = pthis->actor.world.pos.z; + + if (SQ(playerX - thisX) + SQ(playerZ - thisZ) < SQ(80.0f)) { + return true; + } else { + return false; + } +} + +void func_80AB36DC(EnNb* pthis, GlobalContext* globalCtx) { + u16 moveTime = pthis->movementTimer; + + if ((((u16)((u16)(kREG(17) + 25) - 4))) > moveTime) { + s16 invScale = 4 - moveTime; + + if (invScale > 0) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->pathYaw, invScale, 6200, 100); + } + } else { + s16 invScale = (u16)(kREG(17) + 25) - moveTime; + + if (invScale > 0) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, invScale, 6200, 100); + } + } +} + +void EnNb_CheckNoticed(EnNb* pthis, GlobalContext* globalCtx) { + if (EnNb_GetNoticedStatus(pthis, globalCtx)) { + EnNb_SetCurrentAnim(pthis, &gNabooruStandingToWalkingTransitionAnim, 2, -8.0f, 0); + pthis->action = NB_NOTICE_PLAYER; + EnNb_SetNoticeSFX(pthis); + } +} + +void EnNb_SetupIdleCrawlspace(EnNb* pthis, s32 animFinished) { + if (animFinished) { + EnNb_SetCurrentAnim(pthis, &gNabooruStandingHandsOnHipsAnim, 0, -8.0f, 0); + pthis->headTurnFlag = 1; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->action = NB_IDLE_CRAWLSPACE; + } +} + +void func_80AB3838(EnNb* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->action = NB_IN_DIALOG; + } else { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + + if (!(gSaveContext.infTable[22] & 0x1000)) { + pthis->actor.textId = 0x601D; + } else { + pthis->actor.textId = 0x6024; + } + + func_8002F2F4(&pthis->actor, globalCtx); + } +} + +void EnNb_SetupPathMovement(EnNb* pthis, GlobalContext* globalCtx) { + EnNb_SetCurrentAnim(pthis, &gNabooruStandingToWalkingTransitionAnim, 2, -8.0f, 0); + gSaveContext.eventChkInf[9] |= 0x10; + pthis->action = NB_IN_PATH; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); +} + +void EnNb_SetTextIdAsChild(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad; + u8 choiceIndex; + s32 pad1; + u16 textId; + + textId = pthis->actor.textId; + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (textId == 0x6025) { + EnNb_SetupPathMovement(pthis, globalCtx); + } else { + if (textId == 0x6027) { + gSaveContext.infTable[22] |= 0x1000; + } + pthis->action = NB_IDLE_CRAWLSPACE; + } + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + } else if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + choiceIndex = globalCtx->msgCtx.choiceIndex; + + if (textId == 0x601D) { + switch (choiceIndex) { + case 0: + pthis->actor.textId = 0x601E; + break; + case 1: + pthis->actor.textId = 0x601F; + break; + default: + pthis->actor.textId = 0x6020; + } + } else if (textId == 0x6020) { + switch (choiceIndex) { + case 0: + pthis->actor.textId = 0x6021; + break; + default: + pthis->actor.textId = 0x6022; + break; + } + } else { + switch (choiceIndex) { + case 0: + pthis->actor.textId = 0x6025; + break; + default: + pthis->actor.textId = 0x6027; + break; + } + } + + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } +} + +void func_80AB3A7C(EnNb* pthis, GlobalContext* globalCtx, s32 animFinished) { + u16 movementTimer = pthis->movementTimer; + + if ((u16)(kREG(17) + 25) > movementTimer) { + if (animFinished) { + EnNb_SetCurrentAnim(pthis, &gNabooruWalkingAnim, 0, 0.0f, 0); + } + } else { + EnNb_SetCurrentAnim(pthis, &gNabooruStandingHandsOnHipsAnim, 0, -8.0f, 0); + pthis->action = NB_IDLE_AFTER_TALK; + } +} + +void func_80AB3B04(EnNb* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->action = NB_ACTION_30; + } else { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 0x23); + + if ((pthis->actor.textId) == 0) { + pthis->actor.textId = 0x6026; + } + + func_8002F2F4(&pthis->actor, globalCtx); + } +} + +void func_80AB3B7C(EnNb* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->action = NB_IDLE_AFTER_TALK; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + } +} + +void EnNb_WaitForNotice(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_CheckNoticed(pthis, globalCtx); +} + +void EnNb_StandUpAfterNotice(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetupIdleCrawlspace(pthis, animFinished); +} + +void EnNb_BlockCrawlspace(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + func_80AB0FBC(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + func_80AB3838(pthis, globalCtx); +} + +void EnNb_InitCrawlspaceDialogue(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + func_80AB0FBC(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + EnNb_SetTextIdAsChild(pthis, globalCtx); +} + +void EnNb_FollowPath(EnNb* pthis, GlobalContext* globalCtx) { + s32 animFinished; + + func_80AB359C(pthis); + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + func_80AB36DC(pthis, globalCtx); + func_80AB10C4(pthis); + animFinished = EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + func_80AB3A7C(pthis, globalCtx, animFinished); +} + +void func_80AB3DB0(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + func_80AB0FBC(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + func_80AB3B04(pthis, globalCtx); +} + +void func_80AB3E10(EnNb* pthis, GlobalContext* globalCtx) { + func_80AB1284(pthis, globalCtx); + EnNb_UpdateCollider(pthis, globalCtx); + func_80AB1040(pthis, globalCtx); + EnNb_UpdateSkelAnime(pthis); + EnNb_UpdateEyes(pthis); + func_80AB3B7C(pthis, globalCtx); +} + +static EnNbActionFunc sActionFuncs[] = { + EnNb_SetupChamberCs, + EnNb_SetupChamberWarp, + EnNb_ComeUp, + func_80AB193C, + EnNb_RaiseArm, + func_80AB19BC, + func_80AB19FC, + EnNb_Hide, + EnNb_Fade, + EnNb_CreateLightOrb, + func_80AB23A8, + EnNb_MovingInPortal, + EnNb_SuckedInByPortal, + EnNb_CheckConfrontationCsModeWrapper, + func_80AB2C18, + EnNb_Kneel, + EnNb_LookRight, + EnNb_LookLeft, + EnNb_Run, + EnNb_ConfrontationDestroy, + EnNb_CheckCreditsCsMode, + EnNb_CreditsFade, + func_80AB3428, + EnNb_LookUp, + EnNb_WaitForNotice, + EnNb_StandUpAfterNotice, + EnNb_BlockCrawlspace, + EnNb_InitCrawlspaceDialogue, + EnNb_FollowPath, + func_80AB3DB0, + func_80AB3E10, +}; + +void EnNb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNb* pthis = (EnNb*)thisx; + + if (pthis->action < 0 || pthis->action > 30 || sActionFuncs[pthis->action] == NULL) { + // "Main mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void EnNb_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnNb* pthis = (EnNb*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + EnNb_SetupCollider(thisx, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gNabooruSkel, NULL, pthis->jointTable, pthis->morphTable, + NB_LIMB_MAX); + + switch (EnNb_GetType(pthis)) { + case NB_TYPE_DEMO02: + EnNb_SetupLightArrowOrSealingCs(pthis, globalCtx); + break; + case NB_TYPE_KIDNAPPED: + EnNb_InitKidnap(pthis, globalCtx); + break; + case NB_TYPE_KNUCKLE: + EnNb_SetupConfrontation(pthis, globalCtx); + break; + case NB_TYPE_CREDITS: + EnNb_SetupCreditsSpawn(pthis, globalCtx); + break; + case NB_TYPE_CRAWLSPACE: + EnNb_CrawlspaceSpawnCheck(pthis, globalCtx); + break; + default: // giving medallion + EnNb_SetChamberAnim(pthis, globalCtx); + break; + } +} + +s32 EnNb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnNb* pthis = (EnNb*)thisx; + struct_80034A14_arg1* unk_300 = &pthis->unk_300; + s32 ret = false; + + if (pthis->headTurnFlag != 0) { + if (limbIndex == NB_LIMB_TORSO) { + rot->x += unk_300->unk_0E.y; + rot->y -= unk_300->unk_0E.x; + ret = false; + } else if (limbIndex == NB_LIMB_HEAD) { + rot->x += unk_300->unk_08.y; + rot->z += unk_300->unk_08.x; + ret = false; + } + } + + return ret; +} + +void EnNb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnNb* pthis = (EnNb*)thisx; + + if (limbIndex == NB_LIMB_HEAD) { + Vec3f vec1 = { 0.0f, 10.0f, 0.0f }; + Vec3f vec2; + + Matrix_MultVec3f(&vec1, &vec2); + pthis->actor.focus.pos.x = vec2.x; + pthis->actor.focus.pos.y = vec2.y; + pthis->actor.focus.pos.z = vec2.z; + pthis->actor.focus.rot.x = pthis->actor.world.rot.x; + pthis->actor.focus.rot.y = pthis->actor.world.rot.y; + pthis->actor.focus.rot.z = pthis->actor.world.rot.z; + } +} + +void EnNb_DrawNothing(EnNb* pthis, GlobalContext* globalCtx) { +} + +void EnNb_DrawDefault(EnNb* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 eyeIdx = pthis->eyeIdx; + SkelAnime* skelAnime = &pthis->skelAnime; + void* eyeTexture = sEyeTextures[eyeIdx]; + s32 pad1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_nb.c", 992); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnNb_OverrideLimbDraw, EnNb_PostLimbDraw, &pthis->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_nb.c", 1013); +} + +static EnNbDrawFunc sDrawFuncs[] = { + EnNb_DrawNothing, EnNb_DrawDefault, EnNb_DrawTransparency, func_80AB2E70, func_80AB2FE4, +}; + +void EnNb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNb* pthis = (EnNb*)thisx; + + if (pthis->drawMode < 0 || pthis->drawMode >= 5 || sDrawFuncs[pthis->drawMode] == NULL) { + // "Draw mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sDrawFuncs[pthis->drawMode](pthis, globalCtx); +} + +ActorInit En_Nb_InitVars = { + ACTOR_EN_NB, + ACTORCAT_NPC, + FLAGS, + OBJECT_NB, + sizeof(EnNb), + (ActorFunc)EnNb_Init, + (ActorFunc)EnNb_Destroy, + (ActorFunc)EnNb_Update, + (ActorFunc)EnNb_Draw, +}; diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb_cutscene_data.c b/src/overlays/actors/ovl_En_Nb/z_en_nb_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Nb/z_en_nb_cutscene_data.c rename to src/overlays/actors/ovl_En_Nb/z_en_nb_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c deleted file mode 100644 index d2bcfaca5..000000000 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ /dev/null @@ -1,1240 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NIW_Z_EN_NIW_C -#include "actor_common.h" -/* - * File: z_en_niw.c - * Overlay: ovl_En_Niw - * Description: Cucco - */ - -#include "z_en_niw.h" -#include "objects/object_niw/object_niw.h" -#include "overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h" -#include "vt.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) - -void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnNiw_ResetAction(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6324(EnNiw* this, GlobalContext* globalCtx); -void func_80AB63A8(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6450(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6570(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6A38(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6BF8(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6D08(EnNiw* this, GlobalContext* globalCtx); -void func_80AB6EB4(EnNiw* this, GlobalContext* globalCtx); -void func_80AB70F8(EnNiw* this, GlobalContext* globalCtx); -void func_80AB714C(EnNiw* this, GlobalContext* globalCtx); -void func_80AB7204(EnNiw* this, GlobalContext* globalCtx); -void func_80AB7290(EnNiw* this, GlobalContext* globalCtx); -void func_80AB7328(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_FeatherSpawn(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); -void EnNiw_FeatherUpdate(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx); - -static s16 D_80AB85E0 = 0; - -const ActorInit En_Niw_InitVars = { - ACTOR_EN_NIW, - ACTORCAT_PROP, - FLAGS, - OBJECT_NIW, - sizeof(EnNiw), - (ActorFunc)EnNiw_Init, - (ActorFunc)EnNiw_Destroy, - (ActorFunc)EnNiw_Update, - (ActorFunc)EnNiw_Draw, -}; - -static f32 D_80AB8604[] = { - 5000.0f, - -5000.0f, -}; - -static f32 D_80AB860C[] = { - 5000.0f, - 3000.0f, - 4000.0f, -}; - -static Vec3f sKakarikoPosList[] = { - { -1697.0f, 80.0f, 870.0f }, { 57.0f, 320.0f, -673.0f }, { 796.0f, 80.0f, 1639.0f }, { 1417.0f, 465.0f, 169.0f }, - { -60.0f, 0.0f, -46.0f }, { -247.0f, 80.0f, 854.0f }, { 1079.0f, 80.0f, -47.0f }, -}; - -static s16 sKakarikoFlagList[] = { - 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, -}; - -static u8 sLowerRiverSpawned = false; - -static u8 sUpperRiverSpawned = false; - -static ColliderCylinderInit sCylinderInit1 = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 15, 25, 4, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInit2 = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 15, 25, 4, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { - EnNiw* this = (EnNiw*)thisx; - s32 pad; - s32 i; - - if (this->actor.params < 0) { - this->actor.params = 0; - } - - // Cucco at at the very beginning of Zora's River - if (this->actor.params == 0xB) { - if (sLowerRiverSpawned) { - Actor_Kill(&this->actor); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ もういてる原 Ver.1 ☆☆☆☆☆ \n" VT_RST); - return; - } - sLowerRiverSpawned = true; - this->actor.room = -1; - } - - // Cucco at tall platform in the first room of Zora's River - if (this->actor.params == 0xC) { - if (sUpperRiverSpawned) { - Actor_Kill(&this->actor); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ もういてる原 Ver.2 ☆☆☆☆☆ \n" VT_RST); - return; - } - sUpperRiverSpawned = true; - this->actor.room = -1; - } - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.flags |= ACTOR_FLAG_0; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCuccoSkel, &gCuccoAnim, this->jointTable, this->morphTable, 16); - - if (globalCtx->sceneNum == SCENE_SPOT01) { - for (i = 0; i < ARRAY_COUNT(sKakarikoPosList); i++) { - if (fabsf(this->actor.world.pos.x - sKakarikoPosList[i].x) < 40.0f && - fabsf(this->actor.world.pos.z - sKakarikoPosList[i].z) < 40.0f) { - this->unk_2AA = i; - osSyncPrintf(VT_FGCOL(YELLOW) " 通常鶏index %d\n" VT_RST, this->unk_2AA); - if (gSaveContext.infTable[25] & sKakarikoFlagList[i]) { - this->actor.world.pos.x = 300.0f; - this->actor.world.pos.y = 100.0f; - this->actor.world.pos.z = 1530.0f; - this->actor.params = 0; - } - } - } - } - - Math_Vec3f_Copy(&this->unk_2AC, &this->actor.world.pos); - Math_Vec3f_Copy(&this->unk_2B8, &this->actor.world.pos); - this->unk_304 = 10.0f; - Actor_SetScale(&this->actor, 0.01f); - this->unk_2A4 = (s16)Rand_ZeroFloat(3.99f) + 5; - - if (this->unk_2A4 < 0) { - this->unk_2A4 = 1; - } - - switch (this->actor.params) { - case 2: - if (IS_DAY) { - Actor_Kill(&this->actor); - } - break; - case 1: - if (gSaveContext.eventChkInf[1] & 0x10) { - Actor_Kill(&this->actor); - } - break; - case 3: - if (!(gSaveContext.eventChkInf[1] & 0x10)) { - Actor_Kill(&this->actor); - } - break; - case 5: - if (gSaveContext.eventChkInf[1] & 0x100) { - Actor_Kill(&this->actor); - } - break; - case 7: - if (!(gSaveContext.eventChkInf[1] & 0x100)) { - Actor_Kill(&this->actor); - } - break; - case 0xD: - this->actor.gravity = 0.0f; - case 0xE: - this->actor.colChkInfo.mass = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - break; - case 4: - this->actor.gravity = 0.0f; - break; - } - - Collider_InitCylinder(globalCtx, &this->collider); - - switch (this->actor.params) { - case 0xA: - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - case 0xD: - case 0xE: - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit2); - if (globalCtx->sceneNum == SCENE_LINK_HOME && !(gSaveContext.eventChkInf[1] & 0x4000)) { - Actor_Kill(&this->actor); - } - break; - default: - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit1); - break; - } - - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ どんな奴? ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); - osSyncPrintf("\n\n"); - this->actionFunc = EnNiw_ResetAction; -} - -void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnNiw* this = (EnNiw*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AB5BF8(EnNiw* this, GlobalContext* globalCtx, s16 arg2) { - f32 factor = 1.0f; - - if (this->actor.params == 0xD) { - factor = 2.0f; - } - if (this->timer1 == 0) { - if (arg2 == 0) { - this->unk_26C[0] = 0.0f; - } else { - this->unk_26C[0] = -10000.0f * factor; - } - this->unk_298++; - this->timer1 = 3; - if (!(this->unk_298 & 1)) { - this->unk_26C[0] = 0.0f; - - if (arg2 == 0) { - this->timer1 = Rand_ZeroFloat(30.0f); - } - } - } - if (this->timer2 == 0) { - this->unk_29C++; - this->unk_29C &= 1; - - switch (arg2) { - case 0: - this->unk_26C[1] = this->unk_26C[2] = 0.0f; - break; - case 1: - this->timer2 = 3; - this->unk_26C[1] = this->unk_26C[2] = 7000.0f * factor; - - if (this->unk_29C == 0) { - this->unk_26C[1] = this->unk_26C[2] = 0.0f; - } - break; - case 2: - this->timer2 = 2; - this->unk_26C[1] = this->unk_26C[2] = -10000.0f; - this->unk_26C[7] = this->unk_26C[5] = 25000.0f; - this->unk_26C[8] = this->unk_26C[6] = 6000.0f; - - if (this->unk_29C == 0) { - this->unk_26C[5] = this->unk_26C[7] = 8000.0f; - } - break; - case 3: - this->timer2 = 2; - this->unk_26C[7] = this->unk_26C[5] = 10000.0f; - - if (this->unk_29C == 0) { - this->unk_26C[7] = this->unk_26C[5] = 3000.0f; - } - break; - case 4: - this->timer1 = 5; - break; - case 5: - this->timer2 = 5; - this->unk_26C[7] = this->unk_26C[5] = 14000.0f; - if (this->unk_29C == 0) { - this->unk_26C[7] = this->unk_26C[5] = 10000.0f; - } - break; - } - } - if (this->unk_2E0 != this->unk_26C[9]) { - Math_ApproachF(&this->unk_2E0, this->unk_26C[9], 0.5f, 4000.0f); - } - if (this->unk_2DC != this->unk_26C[0]) { - Math_ApproachF(&this->unk_2DC, this->unk_26C[0], 0.5f, 4000.0f); - } - if (this->unk_2C4 != this->unk_26C[2]) { - Math_ApproachF(&this->unk_2C4, this->unk_26C[2], 0.8f, 7000.0f); - } - if (this->unk_2C8 != this->unk_26C[7]) { - Math_ApproachF(&this->unk_2C8, this->unk_26C[7], 0.8f, 7000.0f); - } - if (this->unk_2CC != this->unk_26C[8]) { - Math_ApproachF(&this->unk_2CC, this->unk_26C[8], 0.8f, 7000.0f); - } - if (this->unk_2D0 != this->unk_26C[1]) { - Math_ApproachF(&this->unk_2D0, this->unk_26C[1], 0.8f, 7000.0f); - } - if (this->unk_2D4 != this->unk_26C[5]) { - Math_ApproachF(&this->unk_2D4, this->unk_26C[5], 0.8f, 7000.0f); - } - if (this->unk_2D8 != this->unk_26C[6]) { - Math_ApproachF(&this->unk_2D8, this->unk_26C[6], 0.8f, 7000.0f); - } -} - -void EnNiw_SpawnAttackCucco(EnNiw* this, GlobalContext* globalCtx) { - f32 viewX; - f32 viewY; - f32 viewZ; - Vec3f attackCuccoPos; - Actor* attackCucco; - - if ((this->timer5 == 0) && (this->unk_296 < 7)) { - viewX = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - viewY = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - viewZ = globalCtx->view.lookAt.z - globalCtx->view.eye.z; - attackCuccoPos.x = ((Rand_ZeroOne() - 0.5f) * viewX) + globalCtx->view.eye.x; - attackCuccoPos.y = Rand_CenteredFloat(0.3f) + ((globalCtx->view.eye.y + 50.0f) + (viewY * 0.5f)); - attackCuccoPos.z = ((Rand_ZeroOne() - 0.5f) * viewZ) + globalCtx->view.eye.z; - attackCucco = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ATTACK_NIW, - attackCuccoPos.x, attackCuccoPos.y, attackCuccoPos.z, 0, 0, 0, 0); - - if (attackCucco != NULL) { - this->unk_296++; - this->timer5 = 10; - } else { - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 発生できず ☆☆☆☆☆ \n" VT_RST); - } - } -} - -void func_80AB6100(EnNiw* this, GlobalContext* globalCtx, s32 arg2) { - f32 factor; - f32 targetRotY; - - if (this->timer4 == 0) { - this->timer4 = 3; - - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 3.5f; - } - } - if (this->timer3 == 0) { - this->unk_2A0++; - this->unk_2A0 &= 1; - this->timer3 = 5; - } - if (this->unk_2A0 == 0) { - factor = D_80AB860C[arg2]; - } else { - factor = -D_80AB860C[arg2]; - } - if (arg2 == 1) { - if (this->timer6 == 0 || this->actor.bgCheckFlags & 8) { - this->timer6 = 150; - if (this->timer8 == 0) { - this->timer8 = 70; - this->unk_2E4 = this->actor.yawTowardsPlayer; - } - } - } - targetRotY = this->unk_2E4 + factor; - Math_SmoothStepToS(&this->actor.world.rot.y, targetRotY, 3, this->unk_2FC, 0); - Math_ApproachF(&this->unk_2FC, 3000.0f, 1.0f, 500.0f); - func_80AB5BF8(this, globalCtx, 5); -} - -void EnNiw_ResetAction(EnNiw* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, - -10.0f); - - switch (this->actor.params) { - case 4: - this->actionFunc = func_80AB6450; - break; - case 0xD: - this->actionFunc = func_80AB6324; - break; - default: - this->actionFunc = func_80AB6570; - break; - } -} - -void func_80AB6324(EnNiw* this, GlobalContext* globalCtx) { - if (this->unk_308 != 0) { - this->actor.velocity.y = Rand_ZeroFloat(2.0f) + 4.0f; - this->actor.speedXZ = Rand_ZeroFloat(2.0f) + 3.0f; - this->actionFunc = func_80AB63A8; - } - func_80AB5BF8(this, globalCtx, 1); -} - -void func_80AB63A8(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1 && this->actor.velocity.y < 0.0f) { - this->unk_2AC.x = this->unk_2B8.x = this->actor.world.pos.x; - this->unk_2AC.y = this->unk_2B8.y = this->actor.world.pos.y; - this->unk_2AC.z = this->unk_2B8.z = this->actor.world.pos.z; - this->timer5 = this->timer4 = this->unk_29E = 0; - - this->unk_26C[7] = this->unk_26C[5] = this->unk_26C[6] = this->unk_26C[8] = this->actor.speedXZ = - this->unk_2FC = this->unk_300 = 0.0f; - - this->actionFunc = func_80AB6570; - } else { - func_80AB5BF8(this, globalCtx, 2); - } -} - -void func_80AB6450(EnNiw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->actor.xzDistToPlayer < 30.0f && fabsf(this->actor.world.pos.y - player->actor.world.pos.y) < 5.0f) { - this->timer6 = 100; - this->actor.gravity = -2.0f; - this->actionFunc = func_80AB7290; - } else if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.gravity = -2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->sfxTimer1 = 30; - this->path = 0; - this->timer4 = 30; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - this->actionFunc = func_80AB6BF8; - } else { - // GI_NONE in this case allows the player to lift the actor - func_8002F434(&this->actor, globalCtx, GI_NONE, 25.0f, 10.0f); - func_80AB5BF8(this, globalCtx, 1); - } -} - -void func_80AB6570(EnNiw* this, GlobalContext* globalCtx) { - s32 pad[2]; - f32 posY = Rand_CenteredFloat(100.0f); - f32 posZ = Rand_CenteredFloat(100.0f); - s16 tmp; - - if (this->actor.params != 0xA) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->sfxTimer1 = 30; - this->path = 0; - this->timer4 = 30; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - this->actionFunc = func_80AB6BF8; - return; - } - func_8002F580(&this->actor, globalCtx); - } else { - if (this->path != 0) { - this->unk_2A6 = 1; - if (this->sfxTimer3 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->sfxTimer3 = 100; - } - this->unk_2A0 = Rand_ZeroFloat(1.99f); - this->actor.speedXZ = 4.0f; - this->unk_300 = 0.0f; - this->unk_2FC = 0.0f; - this->actionFunc = func_80AB6A38; - return; - } - } - - tmp = 0; - - if (this->timer5 != 0) { - if (Rand_ZeroFloat(3.99f) < 1.0f) { - this->unk_2E6++; - this->unk_2E6 &= 1; - } - Math_ApproachF(&this->unk_26C[9], D_80AB8604[this->unk_2E6], 0.5f, 4000.0f); - } - - if (this->timer5 == 0 && this->timer4 == 0) { - this->unk_29E++; - - if (this->unk_29E >= 8) { - this->timer5 = Rand_ZeroFloat(30.0f); - this->unk_29E = Rand_ZeroFloat(3.99f); - if (this->actor.params != 0xA && this->actor.params != 8) { - if (posY < 0.0f) { - posY -= 100.0f; - } else { - posY += 100.0f; - } - if (posZ < 0.0f) { - posZ -= 100.0f; - } else { - posZ += 100.0f; - } - } else { - posY = Rand_CenteredFloat(30.0f); - posZ = Rand_CenteredFloat(30.0f); - if (posY < 0.0f) { - posY -= 20.0f; - } else { - posY += 20.0f; - } - if (posZ < 0.0f) { - if (1) {} // Required to match - if (1) {} - if (1) {} - if (1) {} - posZ -= 20.0f; - } else { - posZ += 20.0f; - } - } - this->unk_2B8.x = this->unk_2AC.x + posY; - this->unk_2B8.z = this->unk_2AC.z + posZ; - } else { - this->timer4 = 4; - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 3.5f; - } - } - } - - if (this->timer4 != 0) { - Math_ApproachZeroF(&this->unk_26C[9], 0.5f, 4000.0f); - tmp = 1; - Math_ApproachF(&this->actor.world.pos.x, this->unk_2B8.x, 1.0f, this->unk_2FC); - Math_ApproachF(&this->actor.world.pos.z, this->unk_2B8.z, 1.0f, this->unk_2FC); - Math_ApproachF(&this->unk_2FC, 3.0f, 1.0f, 0.3f); - posY = this->unk_2B8.x - this->actor.world.pos.x; - posZ = this->unk_2B8.z - this->actor.world.pos.z; - - if (fabsf(posY) < 10.0f) { - posY = 0.0; - } - if (fabsf(posZ) < 10.0f) { - posZ = 0.0; - } - if (posY == 0.0f && posZ == 0.0f) { - this->timer4 = 0; - this->unk_29E = 7; - } - - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(posY, posZ) * (0x8000 / M_PI), 3, this->unk_300, 0); - Math_ApproachF(&this->unk_300, 10000.0f, 1.0f, 1000.0f); - } - - func_80AB5BF8(this, globalCtx, tmp); -} - -void func_80AB6A38(EnNiw* this, GlobalContext* globalCtx) { - Path* path; - Vec3s* pointPos; - f32 pathDiffX; - f32 pathDiffZ; - s16 pathIndex = this->path - 1; - - if (this->path == 0) { - this->unk_2AC.x = this->unk_2B8.x = this->actor.world.pos.x; - this->unk_2AC.y = this->unk_2B8.y = this->actor.world.pos.y; - this->unk_2AC.z = this->unk_2B8.z = this->actor.world.pos.z; - this->timer5 = this->timer4 = this->unk_29E = 0; - this->unk_26C[7] = this->unk_26C[5] = this->unk_26C[6] = this->unk_26C[8] = this->actor.speedXZ = - this->unk_2FC = this->unk_300 = 0.0f; - this->actionFunc = EnNiw_ResetAction; - } else { - path = &globalCtx->setupPathList[pathIndex]; - pointPos = SEGMENTED_TO_VIRTUAL(path->points); - pointPos += this->waypoint; - pathDiffX = pointPos->x - this->actor.world.pos.x; - pathDiffZ = pointPos->z - this->actor.world.pos.z; - this->unk_2E4 = Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI); - func_80AB6100(this, globalCtx, 2); - - if (fabsf(pathDiffX) < 30.0f && fabsf(pathDiffZ) < 30.0f) { - this->waypoint++; - if (this->waypoint >= this->unk_2EC) { - this->waypoint = 0; - } - } - - func_80AB5BF8(this, globalCtx, 2); - } -} - -void func_80AB6BF8(EnNiw* this, GlobalContext* globalCtx) { - if (this->timer4 == 0) { - this->unk_2A6 = 2; - this->timer4 = 10; - } - - this->actor.shape.rot.x = Rand_CenteredFloat(5000.0f); - this->actor.shape.rot.y = Rand_CenteredFloat(5000.0f); - this->actor.shape.rot.z = Rand_CenteredFloat(5000.0f); - - if (Actor_HasNoParent(&this->actor, globalCtx)) { - if (this->actor.params == 0xD) { - this->sfxTimer1 = 0; - this->unk_2A6 = 1; - this->actionFunc = func_80AB6EB4; - this->actor.velocity.y = 4.0f; - return; - } - this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = this->actor.shape.rot.z; - this->actor.shape.rot.x = this->actor.shape.rot.z; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = func_80AB6D08; - } - func_80AB5BF8(this, globalCtx, 2); -} - -void func_80AB6D08(EnNiw* this, GlobalContext* globalCtx) { - if (this->path == 0) { - if (!(this->actor.bgCheckFlags & 1)) { - return; - } - if (this->actor.params == 0xE) { - this->unk_2AC.x = this->unk_2B8.x = this->actor.world.pos.x; - this->unk_2AC.y = this->unk_2B8.y = this->actor.world.pos.y; - this->unk_2AC.z = this->unk_2B8.z = this->actor.world.pos.z; - this->timer5 = this->timer4 = this->unk_29E = 0; - - this->unk_26C[7] = this->unk_26C[5] = this->unk_26C[6] = this->unk_26C[8] = this->actor.speedXZ = - this->unk_2FC = this->unk_300 = 0.0f; - - this->actionFunc = EnNiw_ResetAction; - return; - } - - this->path = 1; - this->timer5 = 80; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 4.0f; - } else { - if (this->actor.bgCheckFlags & 1) { - this->sfxTimer1 = 0; - this->actor.velocity.y = 4.0f; - this->unk_2A6 = 1; - } - if (this->timer5 == 0) { - this->timer6 = 100; - this->timer4 = 0; - this->path = 0; - this->actionFunc = func_80AB7290; - return; - } - } - - if (Actor_HasParent(&this->actor, globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->sfxTimer1 = 30; - this->path = 0; - this->timer4 = 30; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - this->actionFunc = func_80AB6BF8; - } else { - if (this->timer5 >= 6) { - func_8002F580(&this->actor, globalCtx); - } - func_80AB5BF8(this, globalCtx, 2); - } -} - -void func_80AB6EB4(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.world.pos.y > 400.0f) { - Actor_Kill(&this->actor); - } - - func_80AB5BF8(this, globalCtx, 2); -} - -void func_80AB6F04(EnNiw* this, GlobalContext* globalCtx) { - Vec3f pos; - - if (this->unk_2A8 != 0) { - EnNiw_SpawnAttackCucco(this, globalCtx); - } - - this->actor.speedXZ = 2.0f; - - if (this->actor.bgCheckFlags & 0x20) { - this->actor.gravity = 0.0f; - - if (this->actor.yDistToWater > 15.0f) { - this->actor.world.pos.y += 2.0f; - } - if (this->timer4 == 0) { - this->timer4 = 30; - Math_Vec3f_Copy(&pos, &this->actor.world.pos); - pos.y += this->actor.yDistToWater; - EffectSsGRipple_Spawn(globalCtx, &pos, 100, 500, 30); - } - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 1.0f; - } - } else { - this->actor.gravity = -2.0f; - - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 1.0f; - this->actor.gravity = 0.0f; - } else { - this->actor.speedXZ = 4.0f; - } - if (this->actor.bgCheckFlags & 1) { - this->actor.gravity = -2.0f; - this->timer6 = 100; - this->timer4 = 0; - this->actor.velocity.y = 0.0f; - if (this->unk_2A8 == 0) { - this->actionFunc = func_80AB7290; - } else { - this->actionFunc = func_80AB7204; - } - } - } - - func_80AB5BF8(this, globalCtx, 2); -} - -void func_80AB70A0(EnNiw* this, GlobalContext* globalCtx) { - OnePointCutscene_Init(globalCtx, 2290, -99, &this->actor, MAIN_CAM); - this->timer5 = 100; - this->unk_2A2 = 1; - this->actionFunc = func_80AB70F8; -} - -void func_80AB70F8(EnNiw* this, GlobalContext* globalCtx) { - this->sfxTimer1 = 100; - - if (this->timer5 == 0) { - this->timer5 = 60; - this->timer1 = 10; - this->unk_2A2 = 4; - this->actionFunc = func_80AB714C; - } - - func_80AB5BF8(this, globalCtx, this->unk_2A2); -} - -void func_80AB714C(EnNiw* this, GlobalContext* globalCtx) { - this->sfxTimer1 = 100; - - if (this->timer5 == 40) { - this->unk_26C[0] = 10000.0f; - this->unk_26C[7] = 14000.0f; - this->unk_26C[5] = 14000.0f; - this->unk_26C[6] = 0.0f; - this->unk_26C[8] = 0.0f; - this->unk_26C[1] = 0.0f; - this->unk_26C[2] = 0.0f; - this->timer1 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - } - if (this->timer5 == 0) { - this->timer7 = 10; - this->unk_2E4 = this->actor.yawTowardsPlayer; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = func_80AB7204; - } - - func_80AB5BF8(this, globalCtx, this->unk_2A2); -} - -void func_80AB7204(EnNiw* this, GlobalContext* globalCtx) { - EnNiw_SpawnAttackCucco(this, globalCtx); - - if (this->timer7 < 2) { - if (this->timer7 == 1) { - this->actor.speedXZ = 3.0f; - this->unk_2A0 = Rand_ZeroFloat(1.99f); - this->timer1 = this->timer2 = this->timer3 = this->timer4 = 0; - } else { - func_80AB6100(this, globalCtx, 1); - } - } -} - -void func_80AB7290(EnNiw* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, - -10.0f); - this->unk_2A0 = Rand_ZeroFloat(1.99f); - this->actor.speedXZ = 4.0f; - this->actionFunc = func_80AB7328; -} - -void func_80AB7328(EnNiw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->timer6 == 0) { - this->unk_2AC.x = this->unk_2B8.x = this->actor.world.pos.x; - this->unk_2AC.y = this->unk_2B8.y = this->actor.world.pos.y; - this->unk_2AC.z = this->unk_2B8.z = this->actor.world.pos.z; - this->timer5 = this->timer4 = this->unk_29E = 0; - this->unk_26C[7] = this->unk_26C[5] = this->unk_26C[6] = this->unk_26C[8] = this->actor.speedXZ = - this->unk_2FC = this->unk_300 = 0.0f; - if (this->actor.params == 4) { - this->actor.params = 0; - } - this->actionFunc = EnNiw_ResetAction; - } else { - this->unk_2E4 = Math_FAtan2F(this->actor.world.pos.x - player->actor.world.pos.x, - this->actor.world.pos.z - player->actor.world.pos.z) * - (0x8000 / M_PI); - func_80AB6100(this, globalCtx, 0); - func_80AB5BF8(this, globalCtx, 2); - } -} - -void func_80AB7420(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { - this->unk_2A4 = (s16)Rand_ZeroFloat(3.99f) + 5; - this->actionFunc = EnNiw_ResetAction; - } -} - -void func_80AB747C(EnNiw* this, GlobalContext* globalCtx) { - if (this->unk_2A8 == 0 && this->actor.params != 0xA && this->actionFunc != func_80AB6450 && - this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - this->sfxTimer1 = 30; - if (this->unk_2A4 > 0 && D_80AB85E0 == 0) { - this->unk_2A4--; - } - this->unk_2A6 = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->timer6 = 100; - this->path = 0; - this->actionFunc = func_80AB7290; - } -} - -void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad1; - EnNiw* this = (EnNiw*)thisx; - Player* player = GET_PLAYER(globalCtx); - s16 i; - s16 featherCount; - Vec3f zeroVec1 = { 0.0f, 0.0f, 0.0f }; - Vec3f zeroVec2 = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - Vec3f vel; - Vec3f accel; - s32 pad2; - f32 scale; - Vec3f cam; - f32 dist; - f32 camResult; - s32 pad3[10]; - - if (1) {} // Required to match - if (1) {} - if (1) {} - - this->unk_294++; - - if (this->actionFunc != func_80AB6570) { - this->unk_26C[9] = 0.0f; - } - if (this->unk_2A6) { - featherCount = 20; - - if (this->unk_2A6 == 2) { - featherCount = 4; - } - - for (i = 0; i < featherCount; i++) { - pos.x = Rand_CenteredFloat(10.0f) + thisx->world.pos.x; - pos.y = Rand_CenteredFloat(10.0f) + (thisx->world.pos.y + this->unk_304); - pos.z = Rand_CenteredFloat(10.0f) + thisx->world.pos.z; - scale = Rand_ZeroFloat(6.0f) + 6.0f; - - if (this->unk_2A6 == 2 && this->unk_304 != 0) { - pos.y += 10; - } - if (this->unk_304 == 0) { - scale = Rand_ZeroFloat(2.0f) + 2; - } - - vel.x = Rand_CenteredFloat(3.0f); - vel.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; - vel.z = Rand_CenteredFloat(3.0f); - accel.x = 0.0f; - accel.y = -0.15f; - accel.z = 0.0f; - EnNiw_FeatherSpawn(this, &pos, &vel, &accel, scale); - } - - this->unk_2A6 = 0; - } - - EnNiw_FeatherUpdate(this, globalCtx); - if (this->timer1 != 0) { - this->timer1--; - } - if (this->timer2 != 0) { - this->timer2--; - } - if (this->timer3 != 0) { - this->timer3--; - } - if (this->timer4 != 0) { - this->timer4--; - } - if (this->timer5 != 0) { - this->timer5--; - } - if (this->timer7 != 0) { - this->timer7--; - } - if (this->timer6 != 0) { - this->timer6--; - } - if (this->sfxTimer1 != 0) { - this->sfxTimer1--; - } - if (this->sfxTimer2 != 0) { - this->sfxTimer2--; - } - if (this->sfxTimer3 != 0) { - this->sfxTimer3--; - } - if (this->timer8 != 0) { - this->timer8--; - } - if (this->timer9 != 0) { - this->timer9--; - } - thisx->shape.rot = thisx->world.rot; - thisx->shape.shadowScale = 15.0f; - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, this->unk_304); - Actor_MoveForward(&this->actor); - - if (this->actionFunc != func_80AB6EB4 && this->actionFunc != func_80AB6450 && globalCtx->sceneNum != SCENE_SPOT03) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 31); - } - if (globalCtx->sceneNum == SCENE_SPOT03) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 29); - } - if (thisx->floorHeight <= BGCHECK_Y_MIN || thisx->floorHeight >= 32000.0f) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 上下? ☆☆☆☆☆ %f\n" VT_RST, thisx->floorHeight); - cam.x = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - cam.y = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - cam.z = globalCtx->view.lookAt.z - globalCtx->view.eye.z; - camResult = cam.y / sqrtf(SQ(cam.x) + SQ(cam.y) + SQ(cam.z)); - osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外X! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.x); - osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外Y! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.y); - osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外Z! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.z); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セットX! ☆☆☆☆☆ %f\n" VT_RST, thisx->home.pos.x); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セットY! ☆☆☆☆☆ %f\n" VT_RST, thisx->home.pos.y); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セットZ! ☆☆☆☆☆ %f\n" VT_RST, thisx->home.pos.z); - thisx->world.pos.x = thisx->home.pos.x; - thisx->world.pos.z = thisx->home.pos.z; - thisx->world.pos.y = ((thisx->home.pos.y + globalCtx->view.eye.y) + (camResult * 160.0f)); - - if (thisx->world.pos.y < thisx->home.pos.y) { - thisx->world.pos.y = thisx->home.pos.y + 300.0f; - } - - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 修整後X! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.x); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 修整後Y! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.y); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 修整後Z! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.z); - osSyncPrintf("\n\n"); - thisx->speedXZ = 0.0f; - thisx->gravity = -2.0f; - Math_Vec3f_Copy(&this->unk_2AC, &thisx->home.pos); - Math_Vec3f_Copy(&this->unk_2B8, &thisx->home.pos); - this->unk_300 = 0.0f; - this->unk_2FC = 0.0f; - this->unk_2F0.z = 0.0f; - this->unk_2F0.y = 0.0f; - this->unk_2F0.x = 0.0f; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; - this->unk_2D0 = 0.0f; - this->unk_2CC = 0.0f; - this->unk_2C8 = 0.0f; - this->unk_2C4 = 0.0f; - this->unk_2DC = 0.0f; - this->unk_2E0 = 0.0f; - this->unk_2A8 = this->unk_294 = this->unk_298 = this->unk_2A6 = this->unk_29E = this->unk_2A0 = this->unk_2A2 = - 0; - - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - this->unk_26C[i] = 0; - } - - this->unk_2A8 = 0; - this->actionFunc = func_80AB7420; - return; - } - - if (thisx->bgCheckFlags & 0x20 && thisx->yDistToWater > 15.0f && this->actionFunc != func_80AB6F04 && - thisx->params != 0xD && thisx->params != 0xE && thisx->params != 0xA) { - thisx->velocity.y = 0.0f; - thisx->gravity = 0.0f; - Math_Vec3f_Copy(&pos, &thisx->world.pos); - pos.y += thisx->yDistToWater; - this->timer4 = 30; - EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); - this->timer5 = 0; - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ぶくぶく ☆☆☆☆☆ \n" VT_RST); - osSyncPrintf("\n\n"); - this->actionFunc = func_80AB6F04; - return; - } - - if (D_80AB85E0 == 0 && this->unk_2A4 <= 0 && thisx->params != 0xD && thisx->params != 0xE && thisx->params != 0xA) { - this->timer6 = 100; - - if (thisx->xzDistToPlayer > 10.0f) { - D_80AB85E0 = 1; - this->timer5 = this->timer4 = this->unk_29E = 0; - thisx->speedXZ = 0.0f; - this->unk_2FC = 0.0f; - this->unk_300 = 0.0f; - this->unk_26C[7] = 0.0f; - this->unk_26C[5] = 0.0f; - this->unk_26C[6] = 0.0f; - this->unk_26C[8] = 0.0f; - this->sfxTimer1 = 10000; - this->unk_2A8 = 1; - this->unk_2AC.x = this->unk_2B8.x = thisx->world.pos.x; - this->unk_2AC.y = this->unk_2B8.y = thisx->world.pos.y; - this->unk_2AC.z = this->unk_2B8.z = thisx->world.pos.z; - this->actionFunc = func_80AB70A0; - return; - } - } - - dist = 20.0f; - - if (this->unk_2A8 != 0 && thisx->xyzDistToPlayerSq < SQ(dist) && player->invincibilityTimer == 0) { - func_8002F6D4(globalCtx, &this->actor, 2.0f, thisx->world.rot.y, 0.0f, 0x10); - } - - func_80AB747C(this, globalCtx); - - if (this->sfxTimer2 == 0 && this->actionFunc == func_80AB6BF8) { - this->sfxTimer2 = 7; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKU_WAKEUP); - } - if (this->sfxTimer1 == 0) { - if (this->actionFunc != func_80AB6570) { - this->sfxTimer1 = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - } else { - this->sfxTimer1 = 300; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_N); - } - } - if (this->unk_2A8 == 0) { - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (thisx->params != 0xA && thisx->params != 0xD && thisx->params != 0xE && thisx->params != 4) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->actionFunc != func_80AB6BF8 && this->actionFunc != func_80AB6D08 && - this->actionFunc != func_80AB6324 && this->actionFunc != func_80AB63A8 && - this->actionFunc != func_80AB6450) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnNiw* this = (EnNiw*)thisx; - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - - if (limbIndex == 13) { - rot->y += (s16)this->unk_2DC; - } - if (limbIndex == 15) { - rot->y += (s16)this->unk_2E0; - } - if (limbIndex == 11) { - rot->x += (s16)this->unk_2D8; - rot->y += (s16)this->unk_2D4; - rot->z += (s16)this->unk_2D0; - } - if (limbIndex == 7) { - rot->x += (s16)this->unk_2CC; - rot->y += (s16)this->unk_2C8; - rot->z += (s16)this->unk_2C4; - } - - return false; -} - -void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnNiw* this = (EnNiw*)thisx; - Vec3f scale = { 0.15f, 0.15f, 0.15f }; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnNiw_OverrideLimbDraw, NULL, this); - - if (this->actionFunc == func_80AB6450) { - func_80033C30(&this->actor.world.pos, &scale, 255, globalCtx); - } - - EnNiw_FeatherDraw(this, globalCtx); -} - -void EnNiw_FeatherSpawn(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { - s16 i; - EnNiwFeather* feather = this->feathers; - - for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { - if (feather->type == 0) { - feather->type = 1; - feather->pos = *pos; - feather->vel = *vel; - feather->accel = *accel; - feather->timer = 0; - feather->scale = scale / 1000.0f; - feather->life = (s16)Rand_ZeroFloat(20.0f) + 40; - feather->unk_2A = Rand_ZeroFloat(1000.0f); - break; - } - } -} - -void EnNiw_FeatherUpdate(EnNiw* this, GlobalContext* globalCtx) { - s16 i; - EnNiwFeather* feather = this->feathers; - - for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { - if (feather->type != 0) { - feather->timer++; - feather->pos.x += feather->vel.x; - feather->pos.y += feather->vel.y; - feather->pos.z += feather->vel.z; - feather->vel.x += feather->accel.x; - feather->vel.y += feather->accel.y; - feather->vel.z += feather->accel.z; - if (feather->type == 1) { - feather->unk_2A++; - Math_ApproachF(&feather->vel.x, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&feather->vel.z, 0.0f, 1.0f, 0.05f); - if (feather->vel.y < -0.5f) { - feather->vel.y = -0.5f; - } - - feather->unk_30 = Math_SinS(feather->unk_2A * 0xBB8) * M_PI * 0.2f; - - if (feather->life < feather->timer) { - feather->type = 0; - } - } - } - } -} - -void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx) { - u8 flag = 0; - s16 i; - s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnNiwFeather* feather = &this->feathers[0]; - - OPEN_DISPS(gfxCtx, "../z_en_niw.c", 1897); - - func_80093D84(globalCtx->state.gfxCtx); - - for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { - if (feather->type == 1) { - if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); - flag++; - } - Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(feather->unk_30, MTXMODE_APPLY); - Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_niw.c", 1913), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); - } - } - - CLOSE_DISPS(gfxCtx, "../z_en_niw.c", 1919); -} diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.cpp b/src/overlays/actors/ovl_En_Niw/z_en_niw.cpp new file mode 100644 index 000000000..f09d6e979 --- /dev/null +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.cpp @@ -0,0 +1,1240 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NIW_Z_EN_NIW_C +#include "actor_common.h" +/* + * File: z_en_niw.c + * Overlay: ovl_En_Niw + * Description: Cucco + */ + +#include "z_en_niw.h" +#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h" +#include "vt.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) + +void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx); +void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx); +void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnNiw_ResetAction(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6324(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB63A8(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6450(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6570(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6A38(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6BF8(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6D08(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB6EB4(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB70F8(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB714C(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB7204(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB7290(EnNiw* pthis, GlobalContext* globalCtx); +void func_80AB7328(EnNiw* pthis, GlobalContext* globalCtx); +void EnNiw_FeatherSpawn(EnNiw* pthis, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); +void EnNiw_FeatherUpdate(EnNiw* pthis, GlobalContext* globalCtx); +void EnNiw_FeatherDraw(EnNiw* pthis, GlobalContext* globalCtx); + +static s16 D_80AB85E0 = 0; + +ActorInit En_Niw_InitVars = { + ACTOR_EN_NIW, + ACTORCAT_PROP, + FLAGS, + OBJECT_NIW, + sizeof(EnNiw), + (ActorFunc)EnNiw_Init, + (ActorFunc)EnNiw_Destroy, + (ActorFunc)EnNiw_Update, + (ActorFunc)EnNiw_Draw, +}; + +static f32 D_80AB8604[] = { + 5000.0f, + -5000.0f, +}; + +static f32 D_80AB860C[] = { + 5000.0f, + 3000.0f, + 4000.0f, +}; + +static Vec3f sKakarikoPosList[] = { + { -1697.0f, 80.0f, 870.0f }, { 57.0f, 320.0f, -673.0f }, { 796.0f, 80.0f, 1639.0f }, { 1417.0f, 465.0f, 169.0f }, + { -60.0f, 0.0f, -46.0f }, { -247.0f, 80.0f, 854.0f }, { 1079.0f, 80.0f, -47.0f }, +}; + +static s16 sKakarikoFlagList[] = { + 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, +}; + +static u8 sLowerRiverSpawned = false; + +static u8 sUpperRiverSpawned = false; + +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 15, 25, 4, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 15, 25, 4, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* pthis = (EnNiw*)thisx; + s32 pad; + s32 i; + + if (pthis->actor.params < 0) { + pthis->actor.params = 0; + } + + // Cucco at at the very beginning of Zora's River + if (pthis->actor.params == 0xB) { + if (sLowerRiverSpawned) { + Actor_Kill(&pthis->actor); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ もういてる原 Ver.1 ☆☆☆☆☆ \n" VT_RST); + return; + } + sLowerRiverSpawned = true; + pthis->actor.room = -1; + } + + // Cucco at tall platform in the first room of Zora's River + if (pthis->actor.params == 0xC) { + if (sUpperRiverSpawned) { + Actor_Kill(&pthis->actor); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ もういてる原 Ver.2 ☆☆☆☆☆ \n" VT_RST); + return; + } + sUpperRiverSpawned = true; + pthis->actor.room = -1; + } + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.flags |= ACTOR_FLAG_0; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCuccoSkel, &gCuccoAnim, pthis->jointTable, pthis->morphTable, 16); + + if (globalCtx->sceneNum == SCENE_SPOT01) { + for (i = 0; i < ARRAY_COUNT(sKakarikoPosList); i++) { + if (fabsf(pthis->actor.world.pos.x - sKakarikoPosList[i].x) < 40.0f && + fabsf(pthis->actor.world.pos.z - sKakarikoPosList[i].z) < 40.0f) { + pthis->unk_2AA = i; + osSyncPrintf(VT_FGCOL(YELLOW) " 通常鶏index %d\n" VT_RST, pthis->unk_2AA); + if (gSaveContext.infTable[25] & sKakarikoFlagList[i]) { + pthis->actor.world.pos.x = 300.0f; + pthis->actor.world.pos.y = 100.0f; + pthis->actor.world.pos.z = 1530.0f; + pthis->actor.params = 0; + } + } + } + } + + Math_Vec3f_Copy(&pthis->unk_2AC, &pthis->actor.world.pos); + Math_Vec3f_Copy(&pthis->unk_2B8, &pthis->actor.world.pos); + pthis->unk_304 = 10.0f; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->unk_2A4 = (s16)Rand_ZeroFloat(3.99f) + 5; + + if (pthis->unk_2A4 < 0) { + pthis->unk_2A4 = 1; + } + + switch (pthis->actor.params) { + case 2: + if (IS_DAY) { + Actor_Kill(&pthis->actor); + } + break; + case 1: + if (gSaveContext.eventChkInf[1] & 0x10) { + Actor_Kill(&pthis->actor); + } + break; + case 3: + if (!(gSaveContext.eventChkInf[1] & 0x10)) { + Actor_Kill(&pthis->actor); + } + break; + case 5: + if (gSaveContext.eventChkInf[1] & 0x100) { + Actor_Kill(&pthis->actor); + } + break; + case 7: + if (!(gSaveContext.eventChkInf[1] & 0x100)) { + Actor_Kill(&pthis->actor); + } + break; + case 0xD: + pthis->actor.gravity = 0.0f; + case 0xE: + pthis->actor.colChkInfo.mass = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + break; + case 4: + pthis->actor.gravity = 0.0f; + break; + } + + Collider_InitCylinder(globalCtx, &pthis->collider); + + switch (pthis->actor.params) { + case 0xA: + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + case 0xD: + case 0xE: + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit2); + if (globalCtx->sceneNum == SCENE_LINK_HOME && !(gSaveContext.eventChkInf[1] & 0x4000)) { + Actor_Kill(&pthis->actor); + } + break; + default: + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit1); + break; + } + + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ どんな奴? ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params); + osSyncPrintf("\n\n"); + pthis->actionFunc = EnNiw_ResetAction; +} + +void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* pthis = (EnNiw*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AB5BF8(EnNiw* pthis, GlobalContext* globalCtx, s16 arg2) { + f32 factor = 1.0f; + + if (pthis->actor.params == 0xD) { + factor = 2.0f; + } + if (pthis->timer1 == 0) { + if (arg2 == 0) { + pthis->unk_26C[0] = 0.0f; + } else { + pthis->unk_26C[0] = -10000.0f * factor; + } + pthis->unk_298++; + pthis->timer1 = 3; + if (!(pthis->unk_298 & 1)) { + pthis->unk_26C[0] = 0.0f; + + if (arg2 == 0) { + pthis->timer1 = Rand_ZeroFloat(30.0f); + } + } + } + if (pthis->timer2 == 0) { + pthis->unk_29C++; + pthis->unk_29C &= 1; + + switch (arg2) { + case 0: + pthis->unk_26C[1] = pthis->unk_26C[2] = 0.0f; + break; + case 1: + pthis->timer2 = 3; + pthis->unk_26C[1] = pthis->unk_26C[2] = 7000.0f * factor; + + if (pthis->unk_29C == 0) { + pthis->unk_26C[1] = pthis->unk_26C[2] = 0.0f; + } + break; + case 2: + pthis->timer2 = 2; + pthis->unk_26C[1] = pthis->unk_26C[2] = -10000.0f; + pthis->unk_26C[7] = pthis->unk_26C[5] = 25000.0f; + pthis->unk_26C[8] = pthis->unk_26C[6] = 6000.0f; + + if (pthis->unk_29C == 0) { + pthis->unk_26C[5] = pthis->unk_26C[7] = 8000.0f; + } + break; + case 3: + pthis->timer2 = 2; + pthis->unk_26C[7] = pthis->unk_26C[5] = 10000.0f; + + if (pthis->unk_29C == 0) { + pthis->unk_26C[7] = pthis->unk_26C[5] = 3000.0f; + } + break; + case 4: + pthis->timer1 = 5; + break; + case 5: + pthis->timer2 = 5; + pthis->unk_26C[7] = pthis->unk_26C[5] = 14000.0f; + if (pthis->unk_29C == 0) { + pthis->unk_26C[7] = pthis->unk_26C[5] = 10000.0f; + } + break; + } + } + if (pthis->unk_2E0 != pthis->unk_26C[9]) { + Math_ApproachF(&pthis->unk_2E0, pthis->unk_26C[9], 0.5f, 4000.0f); + } + if (pthis->unk_2DC != pthis->unk_26C[0]) { + Math_ApproachF(&pthis->unk_2DC, pthis->unk_26C[0], 0.5f, 4000.0f); + } + if (pthis->unk_2C4 != pthis->unk_26C[2]) { + Math_ApproachF(&pthis->unk_2C4, pthis->unk_26C[2], 0.8f, 7000.0f); + } + if (pthis->unk_2C8 != pthis->unk_26C[7]) { + Math_ApproachF(&pthis->unk_2C8, pthis->unk_26C[7], 0.8f, 7000.0f); + } + if (pthis->unk_2CC != pthis->unk_26C[8]) { + Math_ApproachF(&pthis->unk_2CC, pthis->unk_26C[8], 0.8f, 7000.0f); + } + if (pthis->unk_2D0 != pthis->unk_26C[1]) { + Math_ApproachF(&pthis->unk_2D0, pthis->unk_26C[1], 0.8f, 7000.0f); + } + if (pthis->unk_2D4 != pthis->unk_26C[5]) { + Math_ApproachF(&pthis->unk_2D4, pthis->unk_26C[5], 0.8f, 7000.0f); + } + if (pthis->unk_2D8 != pthis->unk_26C[6]) { + Math_ApproachF(&pthis->unk_2D8, pthis->unk_26C[6], 0.8f, 7000.0f); + } +} + +void EnNiw_SpawnAttackCucco(EnNiw* pthis, GlobalContext* globalCtx) { + f32 viewX; + f32 viewY; + f32 viewZ; + Vec3f attackCuccoPos; + Actor* attackCucco; + + if ((pthis->timer5 == 0) && (pthis->unk_296 < 7)) { + viewX = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + viewY = globalCtx->view.lookAt.y - globalCtx->view.eye.y; + viewZ = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + attackCuccoPos.x = ((Rand_ZeroOne() - 0.5f) * viewX) + globalCtx->view.eye.x; + attackCuccoPos.y = Rand_CenteredFloat(0.3f) + ((globalCtx->view.eye.y + 50.0f) + (viewY * 0.5f)); + attackCuccoPos.z = ((Rand_ZeroOne() - 0.5f) * viewZ) + globalCtx->view.eye.z; + attackCucco = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ATTACK_NIW, + attackCuccoPos.x, attackCuccoPos.y, attackCuccoPos.z, 0, 0, 0, 0); + + if (attackCucco != NULL) { + pthis->unk_296++; + pthis->timer5 = 10; + } else { + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 発生できず ☆☆☆☆☆ \n" VT_RST); + } + } +} + +void func_80AB6100(EnNiw* pthis, GlobalContext* globalCtx, s32 arg2) { + f32 factor; + f32 targetRotY; + + if (pthis->timer4 == 0) { + pthis->timer4 = 3; + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 3.5f; + } + } + if (pthis->timer3 == 0) { + pthis->unk_2A0++; + pthis->unk_2A0 &= 1; + pthis->timer3 = 5; + } + if (pthis->unk_2A0 == 0) { + factor = D_80AB860C[arg2]; + } else { + factor = -D_80AB860C[arg2]; + } + if (arg2 == 1) { + if (pthis->timer6 == 0 || pthis->actor.bgCheckFlags & 8) { + pthis->timer6 = 150; + if (pthis->timer8 == 0) { + pthis->timer8 = 70; + pthis->unk_2E4 = pthis->actor.yawTowardsPlayer; + } + } + } + targetRotY = pthis->unk_2E4 + factor; + Math_SmoothStepToS(&pthis->actor.world.rot.y, targetRotY, 3, pthis->unk_2FC, 0); + Math_ApproachF(&pthis->unk_2FC, 3000.0f, 1.0f, 500.0f); + func_80AB5BF8(pthis, globalCtx, 5); +} + +void EnNiw_ResetAction(EnNiw* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, + -10.0f); + + switch (pthis->actor.params) { + case 4: + pthis->actionFunc = func_80AB6450; + break; + case 0xD: + pthis->actionFunc = func_80AB6324; + break; + default: + pthis->actionFunc = func_80AB6570; + break; + } +} + +void func_80AB6324(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->unk_308 != 0) { + pthis->actor.velocity.y = Rand_ZeroFloat(2.0f) + 4.0f; + pthis->actor.speedXZ = Rand_ZeroFloat(2.0f) + 3.0f; + pthis->actionFunc = func_80AB63A8; + } + func_80AB5BF8(pthis, globalCtx, 1); +} + +void func_80AB63A8(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1 && pthis->actor.velocity.y < 0.0f) { + pthis->unk_2AC.x = pthis->unk_2B8.x = pthis->actor.world.pos.x; + pthis->unk_2AC.y = pthis->unk_2B8.y = pthis->actor.world.pos.y; + pthis->unk_2AC.z = pthis->unk_2B8.z = pthis->actor.world.pos.z; + pthis->timer5 = pthis->timer4 = pthis->unk_29E = 0; + + pthis->unk_26C[7] = pthis->unk_26C[5] = pthis->unk_26C[6] = pthis->unk_26C[8] = pthis->actor.speedXZ = + pthis->unk_2FC = pthis->unk_300 = 0.0f; + + pthis->actionFunc = func_80AB6570; + } else { + func_80AB5BF8(pthis, globalCtx, 2); + } +} + +void func_80AB6450(EnNiw* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actor.xzDistToPlayer < 30.0f && fabsf(pthis->actor.world.pos.y - player->actor.world.pos.y) < 5.0f) { + pthis->timer6 = 100; + pthis->actor.gravity = -2.0f; + pthis->actionFunc = func_80AB7290; + } else if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.gravity = -2.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + pthis->sfxTimer1 = 30; + pthis->path = 0; + pthis->timer4 = 30; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = func_80AB6BF8; + } else { + // GI_NONE in pthis case allows the player to lift the actor + func_8002F434(&pthis->actor, globalCtx, GI_NONE, 25.0f, 10.0f); + func_80AB5BF8(pthis, globalCtx, 1); + } +} + +void func_80AB6570(EnNiw* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + f32 posY = Rand_CenteredFloat(100.0f); + f32 posZ = Rand_CenteredFloat(100.0f); + s16 tmp; + + if (pthis->actor.params != 0xA) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + pthis->sfxTimer1 = 30; + pthis->path = 0; + pthis->timer4 = 30; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = func_80AB6BF8; + return; + } + func_8002F580(&pthis->actor, globalCtx); + } else { + if (pthis->path != 0) { + pthis->unk_2A6 = 1; + if (pthis->sfxTimer3 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + pthis->sfxTimer3 = 100; + } + pthis->unk_2A0 = Rand_ZeroFloat(1.99f); + pthis->actor.speedXZ = 4.0f; + pthis->unk_300 = 0.0f; + pthis->unk_2FC = 0.0f; + pthis->actionFunc = func_80AB6A38; + return; + } + } + + tmp = 0; + + if (pthis->timer5 != 0) { + if (Rand_ZeroFloat(3.99f) < 1.0f) { + pthis->unk_2E6++; + pthis->unk_2E6 &= 1; + } + Math_ApproachF(&pthis->unk_26C[9], D_80AB8604[pthis->unk_2E6], 0.5f, 4000.0f); + } + + if (pthis->timer5 == 0 && pthis->timer4 == 0) { + pthis->unk_29E++; + + if (pthis->unk_29E >= 8) { + pthis->timer5 = Rand_ZeroFloat(30.0f); + pthis->unk_29E = Rand_ZeroFloat(3.99f); + if (pthis->actor.params != 0xA && pthis->actor.params != 8) { + if (posY < 0.0f) { + posY -= 100.0f; + } else { + posY += 100.0f; + } + if (posZ < 0.0f) { + posZ -= 100.0f; + } else { + posZ += 100.0f; + } + } else { + posY = Rand_CenteredFloat(30.0f); + posZ = Rand_CenteredFloat(30.0f); + if (posY < 0.0f) { + posY -= 20.0f; + } else { + posY += 20.0f; + } + if (posZ < 0.0f) { + if (1) {} // Required to match + if (1) {} + if (1) {} + if (1) {} + posZ -= 20.0f; + } else { + posZ += 20.0f; + } + } + pthis->unk_2B8.x = pthis->unk_2AC.x + posY; + pthis->unk_2B8.z = pthis->unk_2AC.z + posZ; + } else { + pthis->timer4 = 4; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 3.5f; + } + } + } + + if (pthis->timer4 != 0) { + Math_ApproachZeroF(&pthis->unk_26C[9], 0.5f, 4000.0f); + tmp = 1; + Math_ApproachF(&pthis->actor.world.pos.x, pthis->unk_2B8.x, 1.0f, pthis->unk_2FC); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->unk_2B8.z, 1.0f, pthis->unk_2FC); + Math_ApproachF(&pthis->unk_2FC, 3.0f, 1.0f, 0.3f); + posY = pthis->unk_2B8.x - pthis->actor.world.pos.x; + posZ = pthis->unk_2B8.z - pthis->actor.world.pos.z; + + if (fabsf(posY) < 10.0f) { + posY = 0.0; + } + if (fabsf(posZ) < 10.0f) { + posZ = 0.0; + } + if (posY == 0.0f && posZ == 0.0f) { + pthis->timer4 = 0; + pthis->unk_29E = 7; + } + + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_FAtan2F(posY, posZ) * (0x8000 / M_PI), 3, pthis->unk_300, 0); + Math_ApproachF(&pthis->unk_300, 10000.0f, 1.0f, 1000.0f); + } + + func_80AB5BF8(pthis, globalCtx, tmp); +} + +void func_80AB6A38(EnNiw* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3s* pointPos; + f32 pathDiffX; + f32 pathDiffZ; + s16 pathIndex = pthis->path - 1; + + if (pthis->path == 0) { + pthis->unk_2AC.x = pthis->unk_2B8.x = pthis->actor.world.pos.x; + pthis->unk_2AC.y = pthis->unk_2B8.y = pthis->actor.world.pos.y; + pthis->unk_2AC.z = pthis->unk_2B8.z = pthis->actor.world.pos.z; + pthis->timer5 = pthis->timer4 = pthis->unk_29E = 0; + pthis->unk_26C[7] = pthis->unk_26C[5] = pthis->unk_26C[6] = pthis->unk_26C[8] = pthis->actor.speedXZ = + pthis->unk_2FC = pthis->unk_300 = 0.0f; + pthis->actionFunc = EnNiw_ResetAction; + } else { + path = &globalCtx->setupPathList[pathIndex]; + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos += pthis->waypoint; + pathDiffX = pointPos->x - pthis->actor.world.pos.x; + pathDiffZ = pointPos->z - pthis->actor.world.pos.z; + pthis->unk_2E4 = Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI); + func_80AB6100(pthis, globalCtx, 2); + + if (fabsf(pathDiffX) < 30.0f && fabsf(pathDiffZ) < 30.0f) { + pthis->waypoint++; + if (pthis->waypoint >= pthis->unk_2EC) { + pthis->waypoint = 0; + } + } + + func_80AB5BF8(pthis, globalCtx, 2); + } +} + +void func_80AB6BF8(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->timer4 == 0) { + pthis->unk_2A6 = 2; + pthis->timer4 = 10; + } + + pthis->actor.shape.rot.x = Rand_CenteredFloat(5000.0f); + pthis->actor.shape.rot.y = Rand_CenteredFloat(5000.0f); + pthis->actor.shape.rot.z = Rand_CenteredFloat(5000.0f); + + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + if (pthis->actor.params == 0xD) { + pthis->sfxTimer1 = 0; + pthis->unk_2A6 = 1; + pthis->actionFunc = func_80AB6EB4; + pthis->actor.velocity.y = 4.0f; + return; + } + pthis->actor.shape.rot.z = 0; + pthis->actor.shape.rot.y = pthis->actor.shape.rot.z; + pthis->actor.shape.rot.x = pthis->actor.shape.rot.z; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = func_80AB6D08; + } + func_80AB5BF8(pthis, globalCtx, 2); +} + +void func_80AB6D08(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->path == 0) { + if (!(pthis->actor.bgCheckFlags & 1)) { + return; + } + if (pthis->actor.params == 0xE) { + pthis->unk_2AC.x = pthis->unk_2B8.x = pthis->actor.world.pos.x; + pthis->unk_2AC.y = pthis->unk_2B8.y = pthis->actor.world.pos.y; + pthis->unk_2AC.z = pthis->unk_2B8.z = pthis->actor.world.pos.z; + pthis->timer5 = pthis->timer4 = pthis->unk_29E = 0; + + pthis->unk_26C[7] = pthis->unk_26C[5] = pthis->unk_26C[6] = pthis->unk_26C[8] = pthis->actor.speedXZ = + pthis->unk_2FC = pthis->unk_300 = 0.0f; + + pthis->actionFunc = EnNiw_ResetAction; + return; + } + + pthis->path = 1; + pthis->timer5 = 80; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 4.0f; + } else { + if (pthis->actor.bgCheckFlags & 1) { + pthis->sfxTimer1 = 0; + pthis->actor.velocity.y = 4.0f; + pthis->unk_2A6 = 1; + } + if (pthis->timer5 == 0) { + pthis->timer6 = 100; + pthis->timer4 = 0; + pthis->path = 0; + pthis->actionFunc = func_80AB7290; + return; + } + } + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + pthis->sfxTimer1 = 30; + pthis->path = 0; + pthis->timer4 = 30; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = func_80AB6BF8; + } else { + if (pthis->timer5 >= 6) { + func_8002F580(&pthis->actor, globalCtx); + } + func_80AB5BF8(pthis, globalCtx, 2); + } +} + +void func_80AB6EB4(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->actor.world.pos.y > 400.0f) { + Actor_Kill(&pthis->actor); + } + + func_80AB5BF8(pthis, globalCtx, 2); +} + +void func_80AB6F04(EnNiw* pthis, GlobalContext* globalCtx) { + Vec3f pos; + + if (pthis->unk_2A8 != 0) { + EnNiw_SpawnAttackCucco(pthis, globalCtx); + } + + pthis->actor.speedXZ = 2.0f; + + if (pthis->actor.bgCheckFlags & 0x20) { + pthis->actor.gravity = 0.0f; + + if (pthis->actor.yDistToWater > 15.0f) { + pthis->actor.world.pos.y += 2.0f; + } + if (pthis->timer4 == 0) { + pthis->timer4 = 30; + Math_Vec3f_Copy(&pos, &pthis->actor.world.pos); + pos.y += pthis->actor.yDistToWater; + EffectSsGRipple_Spawn(globalCtx, &pos, 100, 500, 30); + } + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.velocity.y = 10.0f; + pthis->actor.speedXZ = 1.0f; + } + } else { + pthis->actor.gravity = -2.0f; + + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.velocity.y = 10.0f; + pthis->actor.speedXZ = 1.0f; + pthis->actor.gravity = 0.0f; + } else { + pthis->actor.speedXZ = 4.0f; + } + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.gravity = -2.0f; + pthis->timer6 = 100; + pthis->timer4 = 0; + pthis->actor.velocity.y = 0.0f; + if (pthis->unk_2A8 == 0) { + pthis->actionFunc = func_80AB7290; + } else { + pthis->actionFunc = func_80AB7204; + } + } + } + + func_80AB5BF8(pthis, globalCtx, 2); +} + +void func_80AB70A0(EnNiw* pthis, GlobalContext* globalCtx) { + OnePointCutscene_Init(globalCtx, 2290, -99, &pthis->actor, MAIN_CAM); + pthis->timer5 = 100; + pthis->unk_2A2 = 1; + pthis->actionFunc = func_80AB70F8; +} + +void func_80AB70F8(EnNiw* pthis, GlobalContext* globalCtx) { + pthis->sfxTimer1 = 100; + + if (pthis->timer5 == 0) { + pthis->timer5 = 60; + pthis->timer1 = 10; + pthis->unk_2A2 = 4; + pthis->actionFunc = func_80AB714C; + } + + func_80AB5BF8(pthis, globalCtx, pthis->unk_2A2); +} + +void func_80AB714C(EnNiw* pthis, GlobalContext* globalCtx) { + pthis->sfxTimer1 = 100; + + if (pthis->timer5 == 40) { + pthis->unk_26C[0] = 10000.0f; + pthis->unk_26C[7] = 14000.0f; + pthis->unk_26C[5] = 14000.0f; + pthis->unk_26C[6] = 0.0f; + pthis->unk_26C[8] = 0.0f; + pthis->unk_26C[1] = 0.0f; + pthis->unk_26C[2] = 0.0f; + pthis->timer1 = 10; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + } + if (pthis->timer5 == 0) { + pthis->timer7 = 10; + pthis->unk_2E4 = pthis->actor.yawTowardsPlayer; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = func_80AB7204; + } + + func_80AB5BF8(pthis, globalCtx, pthis->unk_2A2); +} + +void func_80AB7204(EnNiw* pthis, GlobalContext* globalCtx) { + EnNiw_SpawnAttackCucco(pthis, globalCtx); + + if (pthis->timer7 < 2) { + if (pthis->timer7 == 1) { + pthis->actor.speedXZ = 3.0f; + pthis->unk_2A0 = Rand_ZeroFloat(1.99f); + pthis->timer1 = pthis->timer2 = pthis->timer3 = pthis->timer4 = 0; + } else { + func_80AB6100(pthis, globalCtx, 1); + } + } +} + +void func_80AB7290(EnNiw* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, + -10.0f); + pthis->unk_2A0 = Rand_ZeroFloat(1.99f); + pthis->actor.speedXZ = 4.0f; + pthis->actionFunc = func_80AB7328; +} + +void func_80AB7328(EnNiw* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->timer6 == 0) { + pthis->unk_2AC.x = pthis->unk_2B8.x = pthis->actor.world.pos.x; + pthis->unk_2AC.y = pthis->unk_2B8.y = pthis->actor.world.pos.y; + pthis->unk_2AC.z = pthis->unk_2B8.z = pthis->actor.world.pos.z; + pthis->timer5 = pthis->timer4 = pthis->unk_29E = 0; + pthis->unk_26C[7] = pthis->unk_26C[5] = pthis->unk_26C[6] = pthis->unk_26C[8] = pthis->actor.speedXZ = + pthis->unk_2FC = pthis->unk_300 = 0.0f; + if (pthis->actor.params == 4) { + pthis->actor.params = 0; + } + pthis->actionFunc = EnNiw_ResetAction; + } else { + pthis->unk_2E4 = Math_FAtan2F(pthis->actor.world.pos.x - player->actor.world.pos.x, + pthis->actor.world.pos.z - player->actor.world.pos.z) * + (0x8000 / M_PI); + func_80AB6100(pthis, globalCtx, 0); + func_80AB5BF8(pthis, globalCtx, 2); + } +} + +void func_80AB7420(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->unk_2A4 = (s16)Rand_ZeroFloat(3.99f) + 5; + pthis->actionFunc = EnNiw_ResetAction; + } +} + +void func_80AB747C(EnNiw* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2A8 == 0 && pthis->actor.params != 0xA && pthis->actionFunc != func_80AB6450 && + pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->sfxTimer1 = 30; + if (pthis->unk_2A4 > 0 && D_80AB85E0 == 0) { + pthis->unk_2A4--; + } + pthis->unk_2A6 = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + pthis->timer6 = 100; + pthis->path = 0; + pthis->actionFunc = func_80AB7290; + } +} + +void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad1; + EnNiw* pthis = (EnNiw*)thisx; + Player* player = GET_PLAYER(globalCtx); + s16 i; + s16 featherCount; + Vec3f zeroVec1 = { 0.0f, 0.0f, 0.0f }; + Vec3f zeroVec2 = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + Vec3f vel; + Vec3f accel; + s32 pad2; + f32 scale; + Vec3f cam; + f32 dist; + f32 camResult; + s32 pad3[10]; + + if (1) {} // Required to match + if (1) {} + if (1) {} + + pthis->unk_294++; + + if (pthis->actionFunc != func_80AB6570) { + pthis->unk_26C[9] = 0.0f; + } + if (pthis->unk_2A6) { + featherCount = 20; + + if (pthis->unk_2A6 == 2) { + featherCount = 4; + } + + for (i = 0; i < featherCount; i++) { + pos.x = Rand_CenteredFloat(10.0f) + thisx->world.pos.x; + pos.y = Rand_CenteredFloat(10.0f) + (thisx->world.pos.y + pthis->unk_304); + pos.z = Rand_CenteredFloat(10.0f) + thisx->world.pos.z; + scale = Rand_ZeroFloat(6.0f) + 6.0f; + + if (pthis->unk_2A6 == 2 && pthis->unk_304 != 0) { + pos.y += 10; + } + if (pthis->unk_304 == 0) { + scale = Rand_ZeroFloat(2.0f) + 2; + } + + vel.x = Rand_CenteredFloat(3.0f); + vel.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; + vel.z = Rand_CenteredFloat(3.0f); + accel.x = 0.0f; + accel.y = -0.15f; + accel.z = 0.0f; + EnNiw_FeatherSpawn(pthis, &pos, &vel, &accel, scale); + } + + pthis->unk_2A6 = 0; + } + + EnNiw_FeatherUpdate(pthis, globalCtx); + if (pthis->timer1 != 0) { + pthis->timer1--; + } + if (pthis->timer2 != 0) { + pthis->timer2--; + } + if (pthis->timer3 != 0) { + pthis->timer3--; + } + if (pthis->timer4 != 0) { + pthis->timer4--; + } + if (pthis->timer5 != 0) { + pthis->timer5--; + } + if (pthis->timer7 != 0) { + pthis->timer7--; + } + if (pthis->timer6 != 0) { + pthis->timer6--; + } + if (pthis->sfxTimer1 != 0) { + pthis->sfxTimer1--; + } + if (pthis->sfxTimer2 != 0) { + pthis->sfxTimer2--; + } + if (pthis->sfxTimer3 != 0) { + pthis->sfxTimer3--; + } + if (pthis->timer8 != 0) { + pthis->timer8--; + } + if (pthis->timer9 != 0) { + pthis->timer9--; + } + thisx->shape.rot = thisx->world.rot; + thisx->shape.shadowScale = 15.0f; + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, pthis->unk_304); + Actor_MoveForward(&pthis->actor); + + if (pthis->actionFunc != func_80AB6EB4 && pthis->actionFunc != func_80AB6450 && globalCtx->sceneNum != SCENE_SPOT03) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 31); + } + if (globalCtx->sceneNum == SCENE_SPOT03) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 29); + } + if (thisx->floorHeight <= BGCHECK_Y_MIN || thisx->floorHeight >= 32000.0f) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 上下? ☆☆☆☆☆ %f\n" VT_RST, thisx->floorHeight); + cam.x = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + cam.y = globalCtx->view.lookAt.y - globalCtx->view.eye.y; + cam.z = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + camResult = cam.y / sqrtf(SQ(cam.x) + SQ(cam.y) + SQ(cam.z)); + osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外X! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.x); + osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外Y! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.y); + osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 範囲外Z! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.z); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セットX! ☆☆☆☆☆ %f\n" VT_RST, thisx->home.pos.x); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セットY! ☆☆☆☆☆ %f\n" VT_RST, thisx->home.pos.y); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セットZ! ☆☆☆☆☆ %f\n" VT_RST, thisx->home.pos.z); + thisx->world.pos.x = thisx->home.pos.x; + thisx->world.pos.z = thisx->home.pos.z; + thisx->world.pos.y = ((thisx->home.pos.y + globalCtx->view.eye.y) + (camResult * 160.0f)); + + if (thisx->world.pos.y < thisx->home.pos.y) { + thisx->world.pos.y = thisx->home.pos.y + 300.0f; + } + + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 修整後X! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.x); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 修整後Y! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.y); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 修整後Z! ☆☆☆☆☆ %f\n" VT_RST, thisx->world.pos.z); + osSyncPrintf("\n\n"); + thisx->speedXZ = 0.0f; + thisx->gravity = -2.0f; + Math_Vec3f_Copy(&pthis->unk_2AC, &thisx->home.pos); + Math_Vec3f_Copy(&pthis->unk_2B8, &thisx->home.pos); + pthis->unk_300 = 0.0f; + pthis->unk_2FC = 0.0f; + pthis->unk_2F0.z = 0.0f; + pthis->unk_2F0.y = 0.0f; + pthis->unk_2F0.x = 0.0f; + pthis->unk_2D8 = 0.0f; + pthis->unk_2D4 = 0.0f; + pthis->unk_2D0 = 0.0f; + pthis->unk_2CC = 0.0f; + pthis->unk_2C8 = 0.0f; + pthis->unk_2C4 = 0.0f; + pthis->unk_2DC = 0.0f; + pthis->unk_2E0 = 0.0f; + pthis->unk_2A8 = pthis->unk_294 = pthis->unk_298 = pthis->unk_2A6 = pthis->unk_29E = pthis->unk_2A0 = pthis->unk_2A2 = + 0; + + for (i = 0; i < ARRAY_COUNT(pthis->unk_26C); i++) { + pthis->unk_26C[i] = 0; + } + + pthis->unk_2A8 = 0; + pthis->actionFunc = func_80AB7420; + return; + } + + if (thisx->bgCheckFlags & 0x20 && thisx->yDistToWater > 15.0f && pthis->actionFunc != func_80AB6F04 && + thisx->params != 0xD && thisx->params != 0xE && thisx->params != 0xA) { + thisx->velocity.y = 0.0f; + thisx->gravity = 0.0f; + Math_Vec3f_Copy(&pos, &thisx->world.pos); + pos.y += thisx->yDistToWater; + pthis->timer4 = 30; + EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); + pthis->timer5 = 0; + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ぶくぶく ☆☆☆☆☆ \n" VT_RST); + osSyncPrintf("\n\n"); + pthis->actionFunc = func_80AB6F04; + return; + } + + if (D_80AB85E0 == 0 && pthis->unk_2A4 <= 0 && thisx->params != 0xD && thisx->params != 0xE && thisx->params != 0xA) { + pthis->timer6 = 100; + + if (thisx->xzDistToPlayer > 10.0f) { + D_80AB85E0 = 1; + pthis->timer5 = pthis->timer4 = pthis->unk_29E = 0; + thisx->speedXZ = 0.0f; + pthis->unk_2FC = 0.0f; + pthis->unk_300 = 0.0f; + pthis->unk_26C[7] = 0.0f; + pthis->unk_26C[5] = 0.0f; + pthis->unk_26C[6] = 0.0f; + pthis->unk_26C[8] = 0.0f; + pthis->sfxTimer1 = 10000; + pthis->unk_2A8 = 1; + pthis->unk_2AC.x = pthis->unk_2B8.x = thisx->world.pos.x; + pthis->unk_2AC.y = pthis->unk_2B8.y = thisx->world.pos.y; + pthis->unk_2AC.z = pthis->unk_2B8.z = thisx->world.pos.z; + pthis->actionFunc = func_80AB70A0; + return; + } + } + + dist = 20.0f; + + if (pthis->unk_2A8 != 0 && thisx->xyzDistToPlayerSq < SQ(dist) && player->invincibilityTimer == 0) { + func_8002F6D4(globalCtx, &pthis->actor, 2.0f, thisx->world.rot.y, 0.0f, 0x10); + } + + func_80AB747C(pthis, globalCtx); + + if (pthis->sfxTimer2 == 0 && pthis->actionFunc == func_80AB6BF8) { + pthis->sfxTimer2 = 7; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DEKU_WAKEUP); + } + if (pthis->sfxTimer1 == 0) { + if (pthis->actionFunc != func_80AB6570) { + pthis->sfxTimer1 = 30; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_A); + } else { + pthis->sfxTimer1 = 300; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_N); + } + } + if (pthis->unk_2A8 == 0) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (thisx->params != 0xA && thisx->params != 0xD && thisx->params != 0xE && thisx->params != 4) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->actionFunc != func_80AB6BF8 && pthis->actionFunc != func_80AB6D08 && + pthis->actionFunc != func_80AB6324 && pthis->actionFunc != func_80AB63A8 && + pthis->actionFunc != func_80AB6450) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnNiw* pthis = (EnNiw*)thisx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 13) { + rot->y += (s16)pthis->unk_2DC; + } + if (limbIndex == 15) { + rot->y += (s16)pthis->unk_2E0; + } + if (limbIndex == 11) { + rot->x += (s16)pthis->unk_2D8; + rot->y += (s16)pthis->unk_2D4; + rot->z += (s16)pthis->unk_2D0; + } + if (limbIndex == 7) { + rot->x += (s16)pthis->unk_2CC; + rot->y += (s16)pthis->unk_2C8; + rot->z += (s16)pthis->unk_2C4; + } + + return false; +} + +void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* pthis = (EnNiw*)thisx; + Vec3f scale = { 0.15f, 0.15f, 0.15f }; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnNiw_OverrideLimbDraw, NULL, pthis); + + if (pthis->actionFunc == func_80AB6450) { + func_80033C30(&pthis->actor.world.pos, &scale, 255, globalCtx); + } + + EnNiw_FeatherDraw(pthis, globalCtx); +} + +void EnNiw_FeatherSpawn(EnNiw* pthis, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { + s16 i; + EnNiwFeather* feather = pthis->feathers; + + for (i = 0; i < ARRAY_COUNT(pthis->feathers); i++, feather++) { + if (feather->type == 0) { + feather->type = 1; + feather->pos = *pos; + feather->vel = *vel; + feather->accel = *accel; + feather->timer = 0; + feather->scale = scale / 1000.0f; + feather->life = (s16)Rand_ZeroFloat(20.0f) + 40; + feather->unk_2A = Rand_ZeroFloat(1000.0f); + break; + } + } +} + +void EnNiw_FeatherUpdate(EnNiw* pthis, GlobalContext* globalCtx) { + s16 i; + EnNiwFeather* feather = pthis->feathers; + + for (i = 0; i < ARRAY_COUNT(pthis->feathers); i++, feather++) { + if (feather->type != 0) { + feather->timer++; + feather->pos.x += feather->vel.x; + feather->pos.y += feather->vel.y; + feather->pos.z += feather->vel.z; + feather->vel.x += feather->accel.x; + feather->vel.y += feather->accel.y; + feather->vel.z += feather->accel.z; + if (feather->type == 1) { + feather->unk_2A++; + Math_ApproachF(&feather->vel.x, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&feather->vel.z, 0.0f, 1.0f, 0.05f); + if (feather->vel.y < -0.5f) { + feather->vel.y = -0.5f; + } + + feather->unk_30 = Math_SinS(feather->unk_2A * 0xBB8) * M_PI * 0.2f; + + if (feather->life < feather->timer) { + feather->type = 0; + } + } + } + } +} + +void EnNiw_FeatherDraw(EnNiw* pthis, GlobalContext* globalCtx) { + u8 flag = 0; + s16 i; + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnNiwFeather* feather = &pthis->feathers[0]; + + OPEN_DISPS(gfxCtx, "../z_en_niw.c", 1897); + + func_80093D84(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(pthis->feathers); i++, feather++) { + if (feather->type == 1) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); + flag++; + } + Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(feather->unk_30, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_niw.c", 1913), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); + } + } + + CLOSE_DISPS(gfxCtx, "../z_en_niw.c", 1919); +} diff --git a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c deleted file mode 100644 index a0b8f4747..000000000 --- a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c +++ /dev/null @@ -1,274 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NIW_GIRL_Z_EN_NIW_GIRL_C -#include "actor_common.h" -/* - * File: z_en_niw_girl.c - * Overlay: ovl_En_Niw_Girl - * Description: Girl that chases a cuckoo around in Hyrule Market and Kakariko Village - */ - -#include "z_en_niw_girl.h" -#include "objects/object_gr/object_gr.h" -#include "vt.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnNiwGirl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNiwGirl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNiwGirl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNiwGirl_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnNiwGirl_Talk(EnNiwGirl* this, GlobalContext* globalCtx); -void func_80AB94D0(EnNiwGirl* this, GlobalContext* globalCtx); -void func_80AB9210(EnNiwGirl* this, GlobalContext* globalCtx); - -const ActorInit En_Niw_Girl_InitVars = { - ACTOR_EN_NIW_GIRL, - ACTORCAT_NPC, - FLAGS, - OBJECT_GR, - sizeof(EnNiwGirl), - (ActorFunc)EnNiwGirl_Init, - (ActorFunc)EnNiwGirl_Destroy, - (ActorFunc)EnNiwGirl_Update, - (ActorFunc)EnNiwGirl_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 10, 30, 0, { 0, 0, 0 } }, -}; - -void EnNiwGirl_Init(Actor* thisx, GlobalContext* globalCtx) { - EnNiwGirl* this = (EnNiwGirl*)thisx; - s32 pad; - Vec3f vec1; - Vec3f vec2; - s32 pad2; - - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gNiwGirlSkel, &gNiwGirlRunAnim, this->jointTable, this->morphTable, - 17); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.targetMode = 6; - if (this->actor.params < 0) { - this->actor.params = 0; - } - this->path = ((this->actor.params >> 8) & 0xFF); - this->actor.gravity = -3.0f; - Matrix_RotateY((this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - vec2.x = vec2.y = vec2.z = 0.0f; - vec1.x = vec1.y = 0.0f; - vec1.z = 50.0; - Matrix_MultVec3f(&vec1, &vec2); - this->chasedEnNiw = (EnNiw*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x + vec2.x, - this->actor.world.pos.y + vec2.y, this->actor.world.pos.z + vec2.z, 0, this->actor.world.rot.y, 0, 0xA); - if (this->chasedEnNiw != NULL) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ シツレイしちゃうわね!プンプン ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ きゃははははは、まてー ☆☆☆☆☆ %d\n" VT_RST, this->path); - osSyncPrintf("\n\n"); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actionFunc = EnNiwGirl_Talk; - } else { - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ なぜか、セットできむぅあせん ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ んんがくく ☆☆☆☆☆ %d\n" VT_RST, this->path); - osSyncPrintf("\n\n"); - Actor_Kill(&this->actor); - } -} - -void EnNiwGirl_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnNiwGirl_Jump(EnNiwGirl* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&gNiwGirlRunAnim); - Animation_Change(&this->skelAnime, &gNiwGirlRunAnim, 1.0f, 0.0f, frameCount, 0, -10.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = func_80AB9210; -} - -void func_80AB9210(EnNiwGirl* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->path]; - f32 xDistBetween; - f32 zDistBetween; - - SkelAnime_Update(&this->skelAnime); - Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.2f, 0.4f); - - // Find the X and Z distance between the girl and the cuckoo she is chasing - xDistBetween = this->chasedEnNiw->actor.world.pos.x - this->actor.world.pos.x; - zDistBetween = this->chasedEnNiw->actor.world.pos.z - this->actor.world.pos.z; - if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { - this->chasedEnNiw->path = 0; - } - if (sqrtf(SQ(xDistBetween) + SQ(zDistBetween)) < 70.0f) { - this->chasedEnNiw->path = (this->path + 1); - this->chasedEnNiw->unk_2EC = path->count; - } else if (sqrtf(SQ(xDistBetween) + SQ(zDistBetween)) > 150.0f) { - this->chasedEnNiw->path = 0; - } - - // Change her angle so that she is always facing the cuckoo - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(xDistBetween, zDistBetween) * (0x8000 / M_PI), 3, - this->unk_27C, 0); - Math_ApproachF(&this->unk_27C, 5000.0f, 30.0f, 150.0f); - this->actor.world.rot.y = this->actor.shape.rot.y; - - // Only allow Link to talk to her when she is playing the jumping animation - if ((this->jumpTimer == 0) || (Player_GetMask(globalCtx) != PLAYER_MASK_NONE)) { - this->jumpTimer = 60; - this->actionFunc = EnNiwGirl_Talk; - } -} - -void EnNiwGirl_Talk(EnNiwGirl* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gNiwGirlJumpAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwGirlJumpAnim), 0, - -10.0f); - this->actor.flags |= ACTOR_FLAG_0; - this->actor.textId = 0x7000; - if ((gSaveContext.eventChkInf[8] & 1) && (this->unk_27A == 0)) { - this->actor.textId = 0x70EA; - } - switch (Player_GetMask(globalCtx)) { - case PLAYER_MASK_KEATON: - this->actor.textId = 0x7118; - break; - case PLAYER_MASK_SPOOKY: - this->actor.textId = 0x7119; - break; - case PLAYER_MASK_BUNNY: - case PLAYER_MASK_ZORA: - case PLAYER_MASK_GERUDO: - this->actor.textId = 0x711A; - break; - case PLAYER_MASK_SKULL: - case PLAYER_MASK_GORON: - case PLAYER_MASK_TRUTH: - this->actor.textId = 0x711B; - break; - } - this->unk_270 = 6; - this->actionFunc = func_80AB94D0; -} - -void func_80AB94D0(EnNiwGirl* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { - this->chasedEnNiw->path = 0; - } - Math_ApproachZeroF(&this->actor.speedXZ, 0.8f, 0.2f); - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->actor.textId == 0x70EA) { - this->unk_27A = 1; - } - } else { - if ((this->jumpTimer == 0) && Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { - this->jumpTimer = Rand_ZeroFloat(100.0f) + 250.0f; - this->actionFunc = EnNiwGirl_Jump; - } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } -} - -void EnNiwGirl_Update(Actor* thisx, GlobalContext* globalCtx) { - EnNiwGirl* this = (EnNiwGirl*)thisx; - EnNiwGirlActionFunc tempActionFunc; - Player* player = GET_PLAYER(globalCtx); - - Actor_SetScale(&this->actor, 0.013f); - this->unkUpTimer++; - tempActionFunc = func_80AB94D0; - if (this->blinkTimer == 0) { - this->eyeIndex++; - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; - this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - } - } - this->unk_280 = 30.0f; - Actor_SetFocus(&this->actor, 30.0f); - if (tempActionFunc == this->actionFunc) { - this->unk_2D4.unk_18 = player->actor.world.pos; - if (!LINK_IS_ADULT) { - this->unk_2D4.unk_18.y = player->actor.world.pos.y - 10.0f; - } - func_80034A14(&this->actor, &this->unk_2D4, 2, 4); - this->unk_260 = this->unk_2D4.unk_08; - this->unk_266 = this->unk_2D4.unk_0E; - } else { - Math_SmoothStepToS(&this->unk_266.y, 0, 5, 3000, 0); - Math_SmoothStepToS(&this->unk_260.y, 0, 5, 3000, 0); - Math_SmoothStepToS(&this->unk_260.z, 0, 5, 3000, 0); - } - if (this->blinkTimer != 0) { - this->blinkTimer--; - } - if (this->jumpTimer != 0) { - this->jumpTimer--; - } - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 100.0f, 100.0f, 200.0f, 0x1C); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnNiwGirlOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnNiwGirl* this = (EnNiwGirl*)thisx; - - if (limbIndex == 3) { - rot->x += this->unk_266.y; - } - if (limbIndex == 4) { - rot->x += this->unk_260.y; - rot->z += this->unk_260.z; - } - return false; -} - -static Vec3f sConstVec3f = { 0.2f, 0.2f, 0.2f }; - -void EnNiwGirl_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gNiwGirlEyeOpenTex, gNiwGirlEyeHalfTex, gNiwGirlEyeClosedTex }; - EnNiwGirl* this = (EnNiwGirl*)thisx; - s32 pad; - Vec3f sp4C = sConstVec3f; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_girl.c", 573); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnNiwGirlOverrideLimbDraw, NULL, this); - func_80033C30(&this->actor.world.pos, &sp4C, 255, globalCtx); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_girl.c", 592); -} diff --git a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.cpp b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.cpp new file mode 100644 index 000000000..40024831d --- /dev/null +++ b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.cpp @@ -0,0 +1,274 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NIW_GIRL_Z_EN_NIW_GIRL_C +#include "actor_common.h" +/* + * File: z_en_niw_girl.c + * Overlay: ovl_En_Niw_Girl + * Description: Girl that chases a cuckoo around in Hyrule Market and Kakariko Village + */ + +#include "z_en_niw_girl.h" +#include "objects/object_gr/object_gr.h" +#include "vt.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnNiwGirl_Init(Actor* thisx, GlobalContext* globalCtx); +void EnNiwGirl_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnNiwGirl_Update(Actor* thisx, GlobalContext* globalCtx); +void EnNiwGirl_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnNiwGirl_Talk(EnNiwGirl* pthis, GlobalContext* globalCtx); +void func_80AB94D0(EnNiwGirl* pthis, GlobalContext* globalCtx); +void func_80AB9210(EnNiwGirl* pthis, GlobalContext* globalCtx); + +ActorInit En_Niw_Girl_InitVars = { + ACTOR_EN_NIW_GIRL, + ACTORCAT_NPC, + FLAGS, + OBJECT_GR, + sizeof(EnNiwGirl), + (ActorFunc)EnNiwGirl_Init, + (ActorFunc)EnNiwGirl_Destroy, + (ActorFunc)EnNiwGirl_Update, + (ActorFunc)EnNiwGirl_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 10, 30, 0, { 0, 0, 0 } }, +}; + +void EnNiwGirl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNiwGirl* pthis = (EnNiwGirl*)thisx; + s32 pad; + Vec3f vec1; + Vec3f vec2; + s32 pad2; + + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gNiwGirlSkel, &gNiwGirlRunAnim, pthis->jointTable, pthis->morphTable, + 17); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.targetMode = 6; + if (pthis->actor.params < 0) { + pthis->actor.params = 0; + } + pthis->path = ((pthis->actor.params >> 8) & 0xFF); + pthis->actor.gravity = -3.0f; + Matrix_RotateY((pthis->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + vec2.x = vec2.y = vec2.z = 0.0f; + vec1.x = vec1.y = 0.0f; + vec1.z = 50.0; + Matrix_MultVec3f(&vec1, &vec2); + pthis->chasedEnNiw = (EnNiw*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_NIW, pthis->actor.world.pos.x + vec2.x, + pthis->actor.world.pos.y + vec2.y, pthis->actor.world.pos.z + vec2.z, 0, pthis->actor.world.rot.y, 0, 0xA); + if (pthis->chasedEnNiw != NULL) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ シツレイしちゃうわね!プンプン ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ きゃははははは、まてー ☆☆☆☆☆ %d\n" VT_RST, pthis->path); + osSyncPrintf("\n\n"); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actionFunc = EnNiwGirl_Talk; + } else { + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ なぜか、セットできむぅあせん ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.params); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ んんがくく ☆☆☆☆☆ %d\n" VT_RST, pthis->path); + osSyncPrintf("\n\n"); + Actor_Kill(&pthis->actor); + } +} + +void EnNiwGirl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnNiwGirl_Jump(EnNiwGirl* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gNiwGirlRunAnim); + Animation_Change(&pthis->skelAnime, &gNiwGirlRunAnim, 1.0f, 0.0f, frameCount, 0, -10.0f); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = func_80AB9210; +} + +void func_80AB9210(EnNiwGirl* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->path]; + f32 xDistBetween; + f32 zDistBetween; + + SkelAnime_Update(&pthis->skelAnime); + Math_ApproachF(&pthis->actor.speedXZ, 3.0f, 0.2f, 0.4f); + + // Find the X and Z distance between the girl and the cuckoo she is chasing + xDistBetween = pthis->chasedEnNiw->actor.world.pos.x - pthis->actor.world.pos.x; + zDistBetween = pthis->chasedEnNiw->actor.world.pos.z - pthis->actor.world.pos.z; + if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { + pthis->chasedEnNiw->path = 0; + } + if (sqrtf(SQ(xDistBetween) + SQ(zDistBetween)) < 70.0f) { + pthis->chasedEnNiw->path = (pthis->path + 1); + pthis->chasedEnNiw->unk_2EC = path->count; + } else if (sqrtf(SQ(xDistBetween) + SQ(zDistBetween)) > 150.0f) { + pthis->chasedEnNiw->path = 0; + } + + // Change her angle so that she is always facing the cuckoo + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(xDistBetween, zDistBetween) * (0x8000 / M_PI), 3, + pthis->unk_27C, 0); + Math_ApproachF(&pthis->unk_27C, 5000.0f, 30.0f, 150.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + // Only allow Link to talk to her when she is playing the jumping animation + if ((pthis->jumpTimer == 0) || (Player_GetMask(globalCtx) != PLAYER_MASK_NONE)) { + pthis->jumpTimer = 60; + pthis->actionFunc = EnNiwGirl_Talk; + } +} + +void EnNiwGirl_Talk(EnNiwGirl* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gNiwGirlJumpAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwGirlJumpAnim), 0, + -10.0f); + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.textId = 0x7000; + if ((gSaveContext.eventChkInf[8] & 1) && (pthis->unk_27A == 0)) { + pthis->actor.textId = 0x70EA; + } + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_KEATON: + pthis->actor.textId = 0x7118; + break; + case PLAYER_MASK_SPOOKY: + pthis->actor.textId = 0x7119; + break; + case PLAYER_MASK_BUNNY: + case PLAYER_MASK_ZORA: + case PLAYER_MASK_GERUDO: + pthis->actor.textId = 0x711A; + break; + case PLAYER_MASK_SKULL: + case PLAYER_MASK_GORON: + case PLAYER_MASK_TRUTH: + pthis->actor.textId = 0x711B; + break; + } + pthis->unk_270 = 6; + pthis->actionFunc = func_80AB94D0; +} + +void func_80AB94D0(EnNiwGirl* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { + pthis->chasedEnNiw->path = 0; + } + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.8f, 0.2f); + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->actor.textId == 0x70EA) { + pthis->unk_27A = 1; + } + } else { + if ((pthis->jumpTimer == 0) && Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { + pthis->jumpTimer = Rand_ZeroFloat(100.0f) + 250.0f; + pthis->actionFunc = EnNiwGirl_Jump; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } +} + +void EnNiwGirl_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNiwGirl* pthis = (EnNiwGirl*)thisx; + EnNiwGirlActionFunc tempActionFunc; + Player* player = GET_PLAYER(globalCtx); + + Actor_SetScale(&pthis->actor, 0.013f); + pthis->unkUpTimer++; + tempActionFunc = func_80AB94D0; + if (pthis->blinkTimer == 0) { + pthis->eyeIndex++; + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; + pthis->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + pthis->unk_280 = 30.0f; + Actor_SetFocus(&pthis->actor, 30.0f); + if (tempActionFunc == pthis->actionFunc) { + pthis->unk_2D4.unk_18 = player->actor.world.pos; + if (!LINK_IS_ADULT) { + pthis->unk_2D4.unk_18.y = player->actor.world.pos.y - 10.0f; + } + func_80034A14(&pthis->actor, &pthis->unk_2D4, 2, 4); + pthis->unk_260 = pthis->unk_2D4.unk_08; + pthis->unk_266 = pthis->unk_2D4.unk_0E; + } else { + Math_SmoothStepToS(&pthis->unk_266.y, 0, 5, 3000, 0); + Math_SmoothStepToS(&pthis->unk_260.y, 0, 5, 3000, 0); + Math_SmoothStepToS(&pthis->unk_260.z, 0, 5, 3000, 0); + } + if (pthis->blinkTimer != 0) { + pthis->blinkTimer--; + } + if (pthis->jumpTimer != 0) { + pthis->jumpTimer--; + } + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 100.0f, 100.0f, 200.0f, 0x1C); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnNiwGirlOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnNiwGirl* pthis = (EnNiwGirl*)thisx; + + if (limbIndex == 3) { + rot->x += pthis->unk_266.y; + } + if (limbIndex == 4) { + rot->x += pthis->unk_260.y; + rot->z += pthis->unk_260.z; + } + return false; +} + +static Vec3f sConstVec3f = { 0.2f, 0.2f, 0.2f }; + +void EnNiwGirl_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gNiwGirlEyeOpenTex, gNiwGirlEyeHalfTex, gNiwGirlEyeClosedTex }; + EnNiwGirl* pthis = (EnNiwGirl*)thisx; + s32 pad; + Vec3f sp4C = sConstVec3f; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_girl.c", 573); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnNiwGirlOverrideLimbDraw, NULL, pthis); + func_80033C30(&pthis->actor.world.pos, &sp4C, 255, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_girl.c", 592); +} diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c deleted file mode 100644 index b91f2c97c..000000000 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ /dev/null @@ -1,596 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NIW_LADY_Z_EN_NIW_LADY_C -#include "actor_common.h" -#include "z_en_niw_lady.h" -#include "objects/object_ane/object_ane.h" -#include "objects/object_os_anime/object_os_anime.h" -#include "overlays/actors/ovl_En_Niw/z_en_niw.h" -#include "vt.h" -#include "def/graph.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnNiwLady_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNiwLady_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNiwLady_Update(Actor* thisx, GlobalContext* globalCtx); - -void func_80AB9F24(EnNiwLady* this, GlobalContext* globalCtx); -void EnNiwLady_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80ABA21C(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABAD38(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABA778(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABA878(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABA9B8(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABAB08(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABAC00(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABAA9C(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABAC84(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABA244(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABA654(EnNiwLady* this, GlobalContext* globalCtx); -void func_80ABAD7C(EnNiwLady* this, GlobalContext* globalCtx); - -const ActorInit En_Niw_Lady_InitVars = { - ACTOR_EN_NIW_LADY, - ACTORCAT_NPC, - FLAGS, - OBJECT_ANE, - sizeof(EnNiwLady), - (ActorFunc)EnNiwLady_Init, - (ActorFunc)EnNiwLady_Destroy, - (ActorFunc)EnNiwLady_Update, - NULL, -}; - -static s16 sMissingCuccoTextIds[] = { - 0x5036, 0x5070, 0x5072, 0x5037, 0x5038, 0x5039, 0x503A, 0x503B, 0x503D, 0x503C, -}; - -static s16 D_80ABB3B4[] = { - 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 10, 10, 0, { 0, 0, 0 } }, -}; - -void EnNiwLady_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnNiwLady* this = (EnNiwLady*)thisx; - - this->objectAneIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ANE); - this->objectOsAnimeIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); - if ((this->objectOsAnimeIndex < 0) || (this->objectAneIndex < 0)) { - Actor_Kill(thisx); - return; - } - this->unk_278 = 0; - if (globalCtx->sceneNum == SCENE_LABO) { - this->unk_278 = 1; - } - if ((this->unk_278 != 0) && IS_DAY) { - Actor_Kill(thisx); - return; - } - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ねぇちゃんうっふん ☆☆☆☆☆ %d\n" VT_RST, this->unk_278); - osSyncPrintf("\n\n"); - this->actionFunc = func_80AB9F24; - thisx->uncullZoneForward = 600.0f; -} - -void EnNiwLady_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnNiwLady* this = (EnNiwLady*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnNiwLady_ChoseAnimation(EnNiwLady* this, GlobalContext* globalCtx, s32 arg2) { - f32 frames; - - if (Text_GetFaceReaction(globalCtx, 8) != 0) { - arg2 = 8; - } - if (arg2 != this->unk_270) { - this->unk_275 = 0; - this->unk_276 = 1; - this->unk_270 = arg2; - switch (arg2) { - case 10: - this->unk_275 = 1; - case 9: - frames = Animation_GetLastFrame(&gObjOsAnim_07D0); - Animation_Change(&this->skelAnime, &gObjOsAnim_07D0, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); - break; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 8: - case 21: - case 22: - case 24: - case 29: - frames = Animation_GetLastFrame(&gObjOsAnim_9F94); - Animation_Change(&this->skelAnime, &gObjOsAnim_9F94, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); - break; - case 7: - case 20: - case 23: - case 25: - case 26: - case 27: - case 28: - frames = Animation_GetLastFrame(&gObjOsAnim_0718); - Animation_Change(&this->skelAnime, &gObjOsAnim_0718, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); - break; - case 100: - frames = Animation_GetLastFrame(&gObjOsAnim_A630); - Animation_Change(&this->skelAnime, &gObjOsAnim_A630, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); - this->unk_276 = 0; - break; - } - return; - } -} - -void func_80AB9F24(EnNiwLady* this, GlobalContext* globalCtx) { - f32 frames; - s32 pad; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->objectAneIndex) && - Object_IsLoaded(&globalCtx->objectCtx, this->objectOsAnimeIndex)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objectAneIndex].vromStart); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCuccoLadySkel, NULL, this->jointTable, this->morphTable, 16); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objectOsAnimeIndex].vromStart); - this->unk_27E = 1; - this->actor.gravity = -3.0f; - Actor_SetScale(&this->actor, 0.01f); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->unk_272 = 0; - this->actor.targetMode = 6; - this->actor.draw = EnNiwLady_Draw; - switch (this->unk_278) { - case 0: - if (!(gSaveContext.itemGetInf[0] & 0x1000) && !LINK_IS_ADULT) { - frames = Animation_GetLastFrame(&gObjOsAnim_A630); - Animation_Change(&this->skelAnime, &gObjOsAnim_A630, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, 0.0f); - } else { - frames = Animation_GetLastFrame(&gObjOsAnim_07D0); - Animation_Change(&this->skelAnime, &gObjOsAnim_07D0, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, 0.0f); - } - if (LINK_IS_ADULT) { - this->actionFunc = func_80ABA778; - } else { - this->actionFunc = func_80ABA21C; - } - return; - case 1: - frames = Animation_GetLastFrame(&gObjOsAnim_07D0); - Animation_Change(&this->skelAnime, &gObjOsAnim_07D0, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, 0.0f); - this->actionFunc = func_80ABAD38; - return; - } - } -} - -void func_80ABA21C(EnNiwLady* this, GlobalContext* globalCtx) { - this->actor.textId = sMissingCuccoTextIds[0]; - this->unk_262 = TEXT_STATE_DONE; - this->actionFunc = func_80ABA244; -} - -void func_80ABA244(EnNiwLady* this, GlobalContext* globalCtx) { - EnNiw* currentCucco; - s32 phi_s1; - - this->cuccosInPen = 0; - currentCucco = (EnNiw*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - while (currentCucco != NULL) { - if (currentCucco->actor.id == ACTOR_EN_NIW) { - if ((fabsf(currentCucco->actor.world.pos.x - 330.0f) < 90.0f) && - (fabsf(currentCucco->actor.world.pos.z - 1610.0f) < 190.0f)) { - if (this->unk_26C == 0) { - gSaveContext.infTable[25] |= D_80ABB3B4[currentCucco->unk_2AA]; - if (BREG(1) != 0) { - // "GET inside the chicken fence!" - osSyncPrintf(VT_FGCOL(GREEN) "☆ 鶏柵内GET!☆ %x\n" VT_RST, - D_80ABB3B4[currentCucco->unk_2AA]); - } - } - this->cuccosInPen++; - } else if (this->unk_26C == 0) { - gSaveContext.infTable[25] &= ~D_80ABB3B4[currentCucco->unk_2AA]; - } - } - currentCucco = (EnNiw*)currentCucco->actor.next; - } - if (BREG(7) != 0) { - this->cuccosInPen = BREG(7) - 1; - } - phi_s1 = this->cuccosInPen; - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) || - (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE)) { - this->unk_26E = 101; - } - if (this->cuccosInPen >= 7) { - phi_s1 = 8; - if ((this->unk_26C < 2) && (this->unk_26C == 0)) { - phi_s1 = 7; - } - } - if ((this->unk_26C != 0) && (phi_s1 < 7)) { - phi_s1 = 9; - } - this->actor.textId = sMissingCuccoTextIds[phi_s1]; - if (Text_GetFaceReaction(globalCtx, 8) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 8); - this->unk_262 = TEXT_STATE_DONE; - } - if ((this->unk_26C != 0) && (phi_s1 != 9)) { - phi_s1 = 10; - this->unk_26E = 11; - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃん選択\t ☆☆☆☆ %d\n" VT_RST, phi_s1); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃんハート ☆☆☆☆ %d\n" VT_RST, this->unk_26C); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃん保存 ☆☆☆☆ %d\n" VT_RST, this->unk_26A); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃん今\t ☆☆☆☆ %d\n" VT_RST, this->cuccosInPen); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ this->actor.talk_message ☆☆ %x\n" VT_RST, this->actor.textId); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ this->message_end_code ☆☆ %d\n" VT_RST, this->unk_262); - osSyncPrintf("\n\n"); - if (Text_GetFaceReaction(globalCtx, 8) == 0) { - if (this->actor.textId == 0x503C) { - func_80078884(NA_SE_SY_ERROR); - this->unk_26C = 2; - this->unk_262 = TEXT_STATE_EVENT; - this->actionFunc = func_80ABA654; - return; - } - this->unk_26E = phi_s1 + 1; - if (phi_s1 == 7) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - this->unk_26C = 1; - this->unk_262 = TEXT_STATE_EVENT; - this->unk_26A = this->cuccosInPen; - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更前 ☆☆ %x\n" VT_RST, gSaveContext.infTable[25]); - gSaveContext.infTable[25] &= 0x1FF; - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更後 ☆☆ %x\n" VT_RST, gSaveContext.infTable[25]); - osSyncPrintf("\n\n"); - this->actionFunc = func_80ABA654; - return; - } - if (this->unk_26A != this->cuccosInPen) { - if (this->cuccosInPen < this->unk_26A) { - func_80078884(NA_SE_SY_ERROR); - } else if (phi_s1 + 1 < 9) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - } - if (this->unk_26A < this->cuccosInPen) { - this->unk_26A = this->cuccosInPen; - return; - } - } - } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } -} - -void func_80ABA654(EnNiwLady* this, GlobalContext* globalCtx) { - if (this->unk_262 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ハート ☆☆☆☆☆ %d\n" VT_RST, this->unk_26C); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 爆弾 ☆☆☆☆☆ %d\n" VT_RST, this->unk_272); - osSyncPrintf("\n\n"); - this->unk_26E = 0xB; - if (!(gSaveContext.itemGetInf[0] & 0x1000)) { - this->actor.parent = NULL; - this->getItemId = GI_BOTTLE; - func_8002F434(&this->actor, globalCtx, GI_BOTTLE, 100.0f, 50.0f); - this->actionFunc = func_80ABAC00; - return; - } - if (this->unk_26C == 1) { - this->getItemId = GI_RUPEE_PURPLE; - func_8002F434(&this->actor, globalCtx, GI_RUPEE_PURPLE, 100.0f, 50.0f); - this->actionFunc = func_80ABAC00; - } - this->actionFunc = func_80ABA244; - } -} - -static s16 sTradeItemTextIds[] = { 0x503E, 0x503F, 0x5047, 0x5040, 0x5042, 0x5043, - 0x5044, 0x00CF, 0x5045, 0x5042, 0x5027 }; - -void func_80ABA778(EnNiwLady* this, GlobalContext* globalCtx) { - // "☆☆☆☆☆ Adult message check ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ アダルトメッセージチェック ☆☆☆☆☆ \n" VT_RST); - this->unk_262 = TEXT_STATE_DONE; - this->unk_273 = 0; - if (!(gSaveContext.itemGetInf[2] & 0x1000)) { - if (this->unk_274 != 0) { - this->unk_27A = 1; - } else { - this->unk_27A = 0; - } - this->unk_273 = 1; - this->unk_262 = TEXT_STATE_CHOICE; - } else { - this->unk_27A = 2; - if (!(gSaveContext.itemGetInf[2] & 0x4000)) { - this->unk_27A = 3; - if (gSaveContext.eventChkInf[6] & 0x400) { - this->unk_27A = 9; - if (this->unk_277 != 0) { - this->unk_27A = 10; - } - } else { - this->unk_27A = 4; - } - } - } - this->actor.textId = sTradeItemTextIds[this->unk_27A]; - this->actionFunc = func_80ABA878; -} - -void func_80ABA878(EnNiwLady* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s8 playerExchangeItemId; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) || - (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE)) { - this->unk_26E = 11; - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - playerExchangeItemId = func_8002F368(globalCtx); - if ((playerExchangeItemId == 6) && (gSaveContext.eventChkInf[6] & 0x400)) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - player->actor.textId = sTradeItemTextIds[5]; - this->unk_26E = this->unk_27A + 21; - this->unk_262 = TEXT_STATE_CHOICE; - this->actionFunc = func_80ABAB08; - } else if (playerExchangeItemId != 0) { - player->actor.textId = sTradeItemTextIds[7]; - this->unk_26E = this->unk_27A + 21; - } else { - this->unk_274 = 1; - this->unk_26E = this->unk_27A + 21; - this->actionFunc = !this->unk_273 ? func_80ABA778 : func_80ABA9B8; - } - } else { - func_8002F298(&this->actor, globalCtx, 50.0f, 6); - } -} - -void func_80ABA9B8(EnNiwLady* this, GlobalContext* globalCtx) { - if ((this->unk_262 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - Message_CloseTextbox(globalCtx); - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, GI_POCKET_EGG, 200.0f, 100.0f); - this->actionFunc = func_80ABAC00; - break; - case 1: - this->actor.textId = sTradeItemTextIds[3]; - this->unk_26E = this->unk_27A + 21; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_262 = TEXT_STATE_EVENT; - this->actionFunc = func_80ABAA9C; - break; - } - } -} - -void func_80ABAA9C(EnNiwLady* this, GlobalContext* globalCtx) { - this->unk_26E = 11; - if ((this->unk_262 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = func_80ABA778; - } -} - -void func_80ABAB08(EnNiwLady* this, GlobalContext* globalCtx) { - if ((this->unk_262 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - Message_CloseTextbox(globalCtx); - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, GI_COJIRO, 200.0f, 100.0f); - this->actionFunc = func_80ABAC00; - break; - case 1: - Message_CloseTextbox(globalCtx); - this->unk_277 = 1; - this->actor.textId = sTradeItemTextIds[8]; - this->unk_26E = this->unk_27A + 21; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_262 = TEXT_STATE_EVENT; - this->actionFunc = func_80ABAA9C; - break; - } - } -} - -void func_80ABAC00(EnNiwLady* this, GlobalContext* globalCtx) { - s32 getItemId; - - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = func_80ABAC84; - } else { - getItemId = this->getItemId; - if (LINK_IS_ADULT) { - getItemId = !(gSaveContext.itemGetInf[2] & 0x1000) ? GI_POCKET_EGG : GI_COJIRO; - } - func_8002F434(&this->actor, globalCtx, getItemId, 200.0f, 100.0f); - } -} - -void func_80ABAC84(EnNiwLady* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_DONE) || !Message_ShouldAdvance(globalCtx)) { - return; - } - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); - if (LINK_IS_ADULT) { - if (!(gSaveContext.itemGetInf[2] & 0x1000)) { - gSaveContext.itemGetInf[2] |= 0x1000; - } else { - gSaveContext.itemGetInf[2] |= 0x4000; - } - this->actionFunc = func_80ABA778; - } else { - gSaveContext.itemGetInf[0] |= 0x1000; - this->unk_262 = TEXT_STATE_DONE; - this->actionFunc = func_80ABA244; - } -} - -void func_80ABAD38(EnNiwLady* this, GlobalContext* globalCtx) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 通常メッセージチェック ☆☆☆☆☆ \n" VT_RST); - this->unk_262 = TEXT_STATE_DONE; - this->actionFunc = func_80ABAD7C; -} - -void func_80ABAD7C(EnNiwLady* this, GlobalContext* globalCtx) { - this->actor.textId = 0x503D; - if (Text_GetFaceReaction(globalCtx, 8) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 8); - } - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) || - (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE)) { - this->unk_26E = 8; - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_274 = 1; - this->unk_26E = this->unk_27A + 9; - this->actionFunc = func_80ABAD38; - } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } -} - -void EnNiwLady_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnNiwLady* this = (EnNiwLady*)thisx; - Player* player = GET_PLAYER(globalCtx); - - Actor_SetFocus(thisx, 60.0f); - this->unk_288.unk_18 = player->actor.world.pos; - if (!LINK_IS_ADULT) { - this->unk_288.unk_18.y = player->actor.world.pos.y - 10.0f; - } - func_80034A14(thisx, &this->unk_288, 2, 4); - this->unk_254 = this->unk_288.unk_08; - this->unk_25A = this->unk_288.unk_0E; - if (this->unk_276 == 0) { - Math_SmoothStepToS(&this->unk_254.y, 0, 5, 3000, 0); - } - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objectOsAnimeIndex].vromStart); - if (this->objectOsAnimeIndex >= 0) { - if (this->unk_27E != 0) { - if (this->unk_26E != 0) { - this->unk_26E--; - EnNiwLady_ChoseAnimation(this, globalCtx, this->unk_26E); - this->unk_26E = 0; - } - SkelAnime_Update(&this->skelAnime); - } - this->objectAneIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ANE); - if (this->objectAneIndex >= 0) { - this->actionFunc(this, globalCtx); - if (this->unusedTimer2 != 0) { - this->unusedTimer2--; - } - if (this->unusedRandomTimer != 0) { - this->unusedRandomTimer--; - } - this->unusedTimer++; - if (this->unusedRandomTimer == 0) { - this->faceState++; - if (this->faceState >= 3) { - this->faceState = 0; - this->unusedRandomTimer = ((s16)Rand_ZeroFloat(60.0f) + 0x14); - } - } - Actor_UpdateBgCheckInfo(globalCtx, thisx, 20.0f, 20.0f, 60.0f, 0x1D); - Collider_UpdateCylinder(thisx, &this->collider); - if (1) {} - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -Gfx* func_80ABB0A0(GraphicsContext* gfxCtx) { - Gfx* dList; - - dList = Graph_Alloc(gfxCtx, sizeof(Gfx)); - gSPEndDisplayList(dList); - return dList; -} - -s32 EnNiwLady_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnNiwLady* this = (EnNiwLady*)thisx; - s32 pad; - - if (limbIndex == 15) { - rot->x += this->unk_254.y; - rot->z += this->unk_254.x; - } - if (limbIndex == 8) { - rot->x += this->unk_25A.y; - } - if (this->unk_275 != 0) { - if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { - rot->y += (Math_SinS((globalCtx->state.frames * ((limbIndex * 0x32) + 0x814))) * 200.0f); - rot->z += (Math_CosS((globalCtx->state.frames * ((limbIndex * 0x32) + 0x940))) * 200.0f); - } - } - return false; -} - -void EnNiwLady_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* sEyeTextures[] = { gCuccoLadyEyeOpenTex, gCuccoLadyEyeHalfTex, gCuccoLadyEyeClosedTex }; - EnNiwLady* this = (EnNiwLady*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_lady.c", 1347); - if (this->unk_27E != 0) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->faceState])); - gSPSegment(POLY_OPA_DISP++, 0x0C, func_80ABB0A0(globalCtx->state.gfxCtx)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnNiwLady_OverrideLimbDraw, NULL, this); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_lady.c", 1370); -} diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.cpp b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.cpp new file mode 100644 index 000000000..406380326 --- /dev/null +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.cpp @@ -0,0 +1,594 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NIW_LADY_Z_EN_NIW_LADY_C +#include "actor_common.h" +#include "z_en_niw_lady.h" +#include "objects/object_ane/object_ane.h" +#include "objects/object_os_anime/object_os_anime.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" +#include "vt.h" +#include "def/graph.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnNiwLady_Init(Actor* thisx, GlobalContext* globalCtx); +void EnNiwLady_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnNiwLady_Update(Actor* thisx, GlobalContext* globalCtx); + +void func_80AB9F24(EnNiwLady* pthis, GlobalContext* globalCtx); +void EnNiwLady_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80ABA21C(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABAD38(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABA778(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABA878(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABA9B8(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABAB08(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABAC00(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABAA9C(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABAC84(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABA244(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABA654(EnNiwLady* pthis, GlobalContext* globalCtx); +void func_80ABAD7C(EnNiwLady* pthis, GlobalContext* globalCtx); + +ActorInit En_Niw_Lady_InitVars = { + ACTOR_EN_NIW_LADY, + ACTORCAT_NPC, + FLAGS, + OBJECT_ANE, + sizeof(EnNiwLady), + (ActorFunc)EnNiwLady_Init, + (ActorFunc)EnNiwLady_Destroy, + (ActorFunc)EnNiwLady_Update, + NULL, +}; + +static s16 sMissingCuccoTextIds[] = { + 0x5036, 0x5070, 0x5072, 0x5037, 0x5038, 0x5039, 0x503A, 0x503B, 0x503D, 0x503C, +}; + +static s16 D_80ABB3B4[] = { + 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 10, 10, 0, { 0, 0, 0 } }, +}; + +void EnNiwLady_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnNiwLady* pthis = (EnNiwLady*)thisx; + + pthis->objectAneIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ANE); + pthis->objectOsAnimeIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OS_ANIME); + if ((pthis->objectOsAnimeIndex < 0) || (pthis->objectAneIndex < 0)) { + Actor_Kill(thisx); + return; + } + pthis->unk_278 = 0; + if (globalCtx->sceneNum == SCENE_LABO) { + pthis->unk_278 = 1; + } + if ((pthis->unk_278 != 0) && IS_DAY) { + Actor_Kill(thisx); + return; + } + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ねぇちゃんうっふん ☆☆☆☆☆ %d\n" VT_RST, pthis->unk_278); + osSyncPrintf("\n\n"); + pthis->actionFunc = func_80AB9F24; + thisx->uncullZoneForward = 600.0f; +} + +void EnNiwLady_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNiwLady* pthis = (EnNiwLady*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnNiwLady_ChoseAnimation(EnNiwLady* pthis, GlobalContext* globalCtx, s32 arg2) { + f32 frames; + + if (Text_GetFaceReaction(globalCtx, 8) != 0) { + arg2 = 8; + } + if (arg2 != pthis->unk_270) { + pthis->unk_275 = 0; + pthis->unk_276 = 1; + pthis->unk_270 = arg2; + switch (arg2) { + case 10: + pthis->unk_275 = 1; + case 9: + frames = Animation_GetLastFrame(&gObjOsAnim_07D0); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_07D0, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); + break; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 8: + case 21: + case 22: + case 24: + case 29: + frames = Animation_GetLastFrame(&gObjOsAnim_9F94); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_9F94, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); + break; + case 7: + case 20: + case 23: + case 25: + case 26: + case 27: + case 28: + frames = Animation_GetLastFrame(&gObjOsAnim_0718); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_0718, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); + break; + case 100: + frames = Animation_GetLastFrame(&gObjOsAnim_A630); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_A630, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); + pthis->unk_276 = 0; + break; + } + return; + } +} + +void func_80AB9F24(EnNiwLady* pthis, GlobalContext* globalCtx) { + f32 frames; + s32 pad; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objectAneIndex) && + Object_IsLoaded(&globalCtx->objectCtx, pthis->objectOsAnimeIndex)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objectAneIndex].vromStart.get()); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCuccoLadySkel, NULL, pthis->jointTable, pthis->morphTable, 16); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objectOsAnimeIndex].vromStart.get()); + pthis->unk_27E = 1; + pthis->actor.gravity = -3.0f; + Actor_SetScale(&pthis->actor, 0.01f); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->unk_272 = 0; + pthis->actor.targetMode = 6; + pthis->actor.draw = EnNiwLady_Draw; + switch (pthis->unk_278) { + case 0: + if (!(gSaveContext.itemGetInf[0] & 0x1000) && !LINK_IS_ADULT) { + frames = Animation_GetLastFrame(&gObjOsAnim_A630); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_A630, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, 0.0f); + } else { + frames = Animation_GetLastFrame(&gObjOsAnim_07D0); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_07D0, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, 0.0f); + } + if (LINK_IS_ADULT) { + pthis->actionFunc = func_80ABA778; + } else { + pthis->actionFunc = func_80ABA21C; + } + return; + case 1: + frames = Animation_GetLastFrame(&gObjOsAnim_07D0); + Animation_Change(&pthis->skelAnime, &gObjOsAnim_07D0, 1.0f, 0.0f, (s16)frames, ANIMMODE_LOOP, 0.0f); + pthis->actionFunc = func_80ABAD38; + return; + } + } +} + +void func_80ABA21C(EnNiwLady* pthis, GlobalContext* globalCtx) { + pthis->actor.textId = sMissingCuccoTextIds[0]; + pthis->unk_262 = TEXT_STATE_DONE; + pthis->actionFunc = func_80ABA244; +} + +void func_80ABA244(EnNiwLady* pthis, GlobalContext* globalCtx) { + EnNiw* currentCucco; + s32 phi_s1; + + pthis->cuccosInPen = 0; + currentCucco = (EnNiw*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + while (currentCucco != NULL) { + if (currentCucco->actor.id == ACTOR_EN_NIW) { + if ((fabsf(currentCucco->actor.world.pos.x - 330.0f) < 90.0f) && + (fabsf(currentCucco->actor.world.pos.z - 1610.0f) < 190.0f)) { + if (pthis->unk_26C == 0) { + gSaveContext.infTable[25] |= D_80ABB3B4[currentCucco->unk_2AA]; + if (BREG(1) != 0) { + // "GET inside the chicken fence!" + osSyncPrintf(VT_FGCOL(GREEN) "☆ 鶏柵内GET!☆ %x\n" VT_RST, + D_80ABB3B4[currentCucco->unk_2AA]); + } + } + pthis->cuccosInPen++; + } else if (pthis->unk_26C == 0) { + gSaveContext.infTable[25] &= ~D_80ABB3B4[currentCucco->unk_2AA]; + } + } + currentCucco = (EnNiw*)currentCucco->actor.next; + } + if (BREG(7) != 0) { + pthis->cuccosInPen = BREG(7) - 1; + } + phi_s1 = pthis->cuccosInPen; + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) || + (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE)) { + pthis->unk_26E = 101; + } + if (pthis->cuccosInPen >= 7) { + phi_s1 = 8; + if ((pthis->unk_26C < 2) && (pthis->unk_26C == 0)) { + phi_s1 = 7; + } + } + if ((pthis->unk_26C != 0) && (phi_s1 < 7)) { + phi_s1 = 9; + } + pthis->actor.textId = sMissingCuccoTextIds[phi_s1]; + if (Text_GetFaceReaction(globalCtx, 8) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 8); + pthis->unk_262 = TEXT_STATE_DONE; + } + if ((pthis->unk_26C != 0) && (phi_s1 != 9)) { + phi_s1 = 10; + pthis->unk_26E = 11; + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃん選択\t ☆☆☆☆ %d\n" VT_RST, phi_s1); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃんハート ☆☆☆☆ %d\n" VT_RST, pthis->unk_26C); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃん保存 ☆☆☆☆ %d\n" VT_RST, pthis->unk_26A); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ねぇちゃん今\t ☆☆☆☆ %d\n" VT_RST, pthis->cuccosInPen); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ pthis->actor.talk_message ☆☆ %x\n" VT_RST, pthis->actor.textId); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ pthis->message_end_code ☆☆ %d\n" VT_RST, pthis->unk_262); + osSyncPrintf("\n\n"); + if (Text_GetFaceReaction(globalCtx, 8) == 0) { + if (pthis->actor.textId == 0x503C) { + func_80078884(NA_SE_SY_ERROR); + pthis->unk_26C = 2; + pthis->unk_262 = TEXT_STATE_EVENT; + pthis->actionFunc = func_80ABA654; + return; + } + pthis->unk_26E = phi_s1 + 1; + if (phi_s1 == 7) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + pthis->unk_26C = 1; + pthis->unk_262 = TEXT_STATE_EVENT; + pthis->unk_26A = pthis->cuccosInPen; + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更前 ☆☆ %x\n" VT_RST, gSaveContext.infTable[25]); + gSaveContext.infTable[25] &= 0x1FF; + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更後 ☆☆ %x\n" VT_RST, gSaveContext.infTable[25]); + osSyncPrintf("\n\n"); + pthis->actionFunc = func_80ABA654; + return; + } + if (pthis->unk_26A != pthis->cuccosInPen) { + if (pthis->cuccosInPen < pthis->unk_26A) { + func_80078884(NA_SE_SY_ERROR); + } else if (phi_s1 + 1 < 9) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + } + if (pthis->unk_26A < pthis->cuccosInPen) { + pthis->unk_26A = pthis->cuccosInPen; + return; + } + } + } else { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } +} + +void func_80ABA654(EnNiwLady* pthis, GlobalContext* globalCtx) { + if (pthis->unk_262 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ハート ☆☆☆☆☆ %d\n" VT_RST, pthis->unk_26C); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 爆弾 ☆☆☆☆☆ %d\n" VT_RST, pthis->unk_272); + osSyncPrintf("\n\n"); + pthis->unk_26E = 0xB; + if (!(gSaveContext.itemGetInf[0] & 0x1000)) { + pthis->actor.parent = NULL; + pthis->getItemId = GI_BOTTLE; + func_8002F434(&pthis->actor, globalCtx, GI_BOTTLE, 100.0f, 50.0f); + pthis->actionFunc = func_80ABAC00; + return; + } + if (pthis->unk_26C == 1) { + pthis->getItemId = GI_RUPEE_PURPLE; + func_8002F434(&pthis->actor, globalCtx, GI_RUPEE_PURPLE, 100.0f, 50.0f); + pthis->actionFunc = func_80ABAC00; + } + pthis->actionFunc = func_80ABA244; + } +} + +static s16 sTradeItemTextIds[] = { 0x503E, 0x503F, 0x5047, 0x5040, 0x5042, 0x5043, + 0x5044, 0x00CF, 0x5045, 0x5042, 0x5027 }; + +void func_80ABA778(EnNiwLady* pthis, GlobalContext* globalCtx) { + // "☆☆☆☆☆ Adult message check ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ アダルトメッセージチェック ☆☆☆☆☆ \n" VT_RST); + pthis->unk_262 = TEXT_STATE_DONE; + pthis->unk_273 = 0; + if (!(gSaveContext.itemGetInf[2] & 0x1000)) { + if (pthis->unk_274 != 0) { + pthis->unk_27A = 1; + } else { + pthis->unk_27A = 0; + } + pthis->unk_273 = 1; + pthis->unk_262 = TEXT_STATE_CHOICE; + } else { + pthis->unk_27A = 2; + if (!(gSaveContext.itemGetInf[2] & 0x4000)) { + pthis->unk_27A = 3; + if (gSaveContext.eventChkInf[6] & 0x400) { + pthis->unk_27A = 9; + if (pthis->unk_277 != 0) { + pthis->unk_27A = 10; + } + } else { + pthis->unk_27A = 4; + } + } + } + pthis->actor.textId = sTradeItemTextIds[pthis->unk_27A]; + pthis->actionFunc = func_80ABA878; +} + +void func_80ABA878(EnNiwLady* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s8 playerExchangeItemId; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) || + (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE)) { + pthis->unk_26E = 11; + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + playerExchangeItemId = func_8002F368(globalCtx); + if ((playerExchangeItemId == 6) && (gSaveContext.eventChkInf[6] & 0x400)) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + player->actor.textId = sTradeItemTextIds[5]; + pthis->unk_26E = pthis->unk_27A + 21; + pthis->unk_262 = TEXT_STATE_CHOICE; + pthis->actionFunc = func_80ABAB08; + } else if (playerExchangeItemId != 0) { + player->actor.textId = sTradeItemTextIds[7]; + pthis->unk_26E = pthis->unk_27A + 21; + } else { + pthis->unk_274 = 1; + pthis->unk_26E = pthis->unk_27A + 21; + pthis->actionFunc = !pthis->unk_273 ? func_80ABA778 : func_80ABA9B8; + } + } else { + func_8002F298(&pthis->actor, globalCtx, 50.0f, 6); + } +} + +void func_80ABA9B8(EnNiwLady* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_262 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + Message_CloseTextbox(globalCtx); + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, GI_POCKET_EGG, 200.0f, 100.0f); + pthis->actionFunc = func_80ABAC00; + break; + case 1: + pthis->actor.textId = sTradeItemTextIds[3]; + pthis->unk_26E = pthis->unk_27A + 21; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_262 = TEXT_STATE_EVENT; + pthis->actionFunc = func_80ABAA9C; + break; + } + } +} + +void func_80ABAA9C(EnNiwLady* pthis, GlobalContext* globalCtx) { + pthis->unk_26E = 11; + if ((pthis->unk_262 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = func_80ABA778; + } +} + +void func_80ABAB08(EnNiwLady* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_262 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + Message_CloseTextbox(globalCtx); + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, GI_COJIRO, 200.0f, 100.0f); + pthis->actionFunc = func_80ABAC00; + break; + case 1: + Message_CloseTextbox(globalCtx); + pthis->unk_277 = 1; + pthis->actor.textId = sTradeItemTextIds[8]; + pthis->unk_26E = pthis->unk_27A + 21; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_262 = TEXT_STATE_EVENT; + pthis->actionFunc = func_80ABAA9C; + break; + } + } +} + +void func_80ABAC00(EnNiwLady* pthis, GlobalContext* globalCtx) { + s32 getItemId; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80ABAC84; + } else { + getItemId = pthis->getItemId; + if (LINK_IS_ADULT) { + getItemId = !(gSaveContext.itemGetInf[2] & 0x1000) ? GI_POCKET_EGG : GI_COJIRO; + } + func_8002F434(&pthis->actor, globalCtx, getItemId, 200.0f, 100.0f); + } +} + +void func_80ABAC84(EnNiwLady* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_DONE) || !Message_ShouldAdvance(globalCtx)) { + return; + } + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); + if (LINK_IS_ADULT) { + if (!(gSaveContext.itemGetInf[2] & 0x1000)) { + gSaveContext.itemGetInf[2] |= 0x1000; + } else { + gSaveContext.itemGetInf[2] |= 0x4000; + } + pthis->actionFunc = func_80ABA778; + } else { + gSaveContext.itemGetInf[0] |= 0x1000; + pthis->unk_262 = TEXT_STATE_DONE; + pthis->actionFunc = func_80ABA244; + } +} + +void func_80ABAD38(EnNiwLady* pthis, GlobalContext* globalCtx) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 通常メッセージチェック ☆☆☆☆☆ \n" VT_RST); + pthis->unk_262 = TEXT_STATE_DONE; + pthis->actionFunc = func_80ABAD7C; +} + +void func_80ABAD7C(EnNiwLady* pthis, GlobalContext* globalCtx) { + pthis->actor.textId = 0x503D; + if (Text_GetFaceReaction(globalCtx, 8) != 0) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 8); + } + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) || + (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE)) { + pthis->unk_26E = 8; + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_274 = 1; + pthis->unk_26E = pthis->unk_27A + 9; + pthis->actionFunc = func_80ABAD38; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } +} + +void EnNiwLady_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnNiwLady* pthis = (EnNiwLady*)thisx; + Player* player = GET_PLAYER(globalCtx); + + Actor_SetFocus(thisx, 60.0f); + pthis->unk_288.unk_18 = player->actor.world.pos; + if (!LINK_IS_ADULT) { + pthis->unk_288.unk_18.y = player->actor.world.pos.y - 10.0f; + } + func_80034A14(thisx, &pthis->unk_288, 2, 4); + pthis->unk_254 = pthis->unk_288.unk_08; + pthis->unk_25A = pthis->unk_288.unk_0E; + if (pthis->unk_276 == 0) { + Math_SmoothStepToS(&pthis->unk_254.y, 0, 5, 3000, 0); + } + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objectOsAnimeIndex].vromStart.get()); + if (pthis->objectOsAnimeIndex >= 0) { + if (pthis->unk_27E != 0) { + if (pthis->unk_26E != 0) { + pthis->unk_26E--; + EnNiwLady_ChoseAnimation(pthis, globalCtx, pthis->unk_26E); + pthis->unk_26E = 0; + } + SkelAnime_Update(&pthis->skelAnime); + } + pthis->objectAneIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ANE); + if (pthis->objectAneIndex >= 0) { + pthis->actionFunc(pthis, globalCtx); + if (pthis->unusedTimer2 != 0) { + pthis->unusedTimer2--; + } + if (pthis->unusedRandomTimer != 0) { + pthis->unusedRandomTimer--; + } + pthis->unusedTimer++; + if (pthis->unusedRandomTimer == 0) { + pthis->faceState++; + if (pthis->faceState >= 3) { + pthis->faceState = 0; + pthis->unusedRandomTimer = ((s16)Rand_ZeroFloat(60.0f) + 0x14); + } + } + Actor_UpdateBgCheckInfo(globalCtx, thisx, 20.0f, 20.0f, 60.0f, 0x1D); + Collider_UpdateCylinder(thisx, &pthis->collider); + if (1) {} + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +Gfx* func_80ABB0A0(GraphicsContext* gfxCtx) { + Gfx* dList = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); + gSPEndDisplayList(dList); + return dList; +} + +s32 EnNiwLady_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnNiwLady* pthis = (EnNiwLady*)thisx; + s32 pad; + + if (limbIndex == 15) { + rot->x += pthis->unk_254.y; + rot->z += pthis->unk_254.x; + } + if (limbIndex == 8) { + rot->x += pthis->unk_25A.y; + } + if (pthis->unk_275 != 0) { + if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { + rot->y += (Math_SinS((globalCtx->state.frames * ((limbIndex * 0x32) + 0x814))) * 200.0f); + rot->z += (Math_CosS((globalCtx->state.frames * ((limbIndex * 0x32) + 0x940))) * 200.0f); + } + } + return false; +} + +void EnNiwLady_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* sEyeTextures[] = { gCuccoLadyEyeOpenTex, gCuccoLadyEyeHalfTex, gCuccoLadyEyeClosedTex }; + EnNiwLady* pthis = (EnNiwLady*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_lady.c", 1347); + if (pthis->unk_27E != 0) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->faceState])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80ABB0A0(globalCtx->state.gfxCtx)); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnNiwLady_OverrideLimbDraw, NULL, pthis); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_niw_lady.c", 1370); +} diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.cpp similarity index 55% rename from src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c rename to src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.cpp index 6656eabed..9b8cd19c2 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.cpp @@ -28,10 +28,10 @@ void EnNutsball_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx); void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80ABBB34(EnNutsball* this, GlobalContext* globalCtx); -void func_80ABBBA8(EnNutsball* this, GlobalContext* globalCtx); +void func_80ABBB34(EnNutsball* pthis, GlobalContext* globalCtx); +void func_80ABBBA8(EnNutsball* pthis, GlobalContext* globalCtx); -const ActorInit En_Nutsball_InitVars = { +ActorInit En_Nutsball_InitVars = { ACTOR_EN_NUTSBALL, ACTORCAT_PROP, FLAGS, @@ -72,101 +72,101 @@ static Gfx* sDLists[] = { }; void EnNutsball_Init(Actor* thisx, GlobalContext* globalCtx) { - EnNutsball* this = (EnNutsball*)thisx; + EnNutsball* pthis = (EnNutsball*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIDs[this->actor.params]); + ActorShape_Init(&pthis->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIDs[pthis->actor.params]); - if (this->objBankIndex < 0) { - Actor_Kill(&this->actor); + if (pthis->objBankIndex < 0) { + Actor_Kill(&pthis->actor); } else { - this->actionFunc = func_80ABBB34; + pthis->actionFunc = func_80ABBB34; } } void EnNutsball_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnNutsball* this = (EnNutsball*)thisx; + EnNutsball* pthis = (EnNutsball*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void func_80ABBB34(EnNutsball* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; - this->actor.draw = EnNutsball_Draw; - this->actor.shape.rot.y = 0; - this->timer = 30; - this->actionFunc = func_80ABBBA8; - this->actor.speedXZ = 10.0f; +void func_80ABBB34(EnNutsball* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->actor.objBankIndex = pthis->objBankIndex; + pthis->actor.draw = EnNutsball_Draw; + pthis->actor.shape.rot.y = 0; + pthis->timer = 30; + pthis->actionFunc = func_80ABBBA8; + pthis->actor.speedXZ = 10.0f; } } -void func_80ABBBA8(EnNutsball* this, GlobalContext* globalCtx) { +void func_80ABBBA8(EnNutsball* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3s sp4C; Vec3f sp40; - this->timer--; + pthis->timer--; - if (this->timer == 0) { - this->actor.gravity = -1.0f; + if (pthis->timer == 0) { + pthis->actor.gravity = -1.0f; } - this->actor.home.rot.z += 0x2AA8; + pthis->actor.home.rot.z += 0x2AA8; - if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->collider.base.atFlags & AT_HIT) || - (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { + if ((pthis->actor.bgCheckFlags & 8) || (pthis->actor.bgCheckFlags & 1) || (pthis->collider.base.atFlags & AT_HIT) || + (pthis->collider.base.acFlags & AC_HIT) || (pthis->collider.base.ocFlags1 & OC1_HIT)) { // Checking if the player is using a shield that reflects projectiles // And if so, reflects the projectile on impact if ((player->currentShield == PLAYER_SHIELD_DEKU) || ((player->currentShield == PLAYER_SHIELD_HYLIAN) && LINK_IS_ADULT)) { - if ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_TYPE_ENEMY) && - (this->collider.base.atFlags & AT_BOUNCED)) { - this->collider.base.atFlags &= ~AT_TYPE_ENEMY & ~AT_BOUNCED & ~AT_HIT; - this->collider.base.atFlags |= AT_TYPE_PLAYER; + if ((pthis->collider.base.atFlags & AT_HIT) && (pthis->collider.base.atFlags & AT_TYPE_ENEMY) && + (pthis->collider.base.atFlags & AT_BOUNCED)) { + pthis->collider.base.atFlags &= ~AT_TYPE_ENEMY & ~AT_BOUNCED & ~AT_HIT; + pthis->collider.base.atFlags |= AT_TYPE_PLAYER; - this->collider.info.toucher.dmgFlags = 2; + pthis->collider.info.toucher.dmgFlags = 2; Matrix_MtxFToYXZRotS(&player->shieldMf, &sp4C, 0); - this->actor.world.rot.y = sp4C.y + 0x8000; - this->timer = 30; + pthis->actor.world.rot.y = sp4C.y + 0x8000; + pthis->timer = 30; return; } } - sp40.x = this->actor.world.pos.x; - sp40.y = this->actor.world.pos.y + 4; - sp40.z = this->actor.world.pos.z; + sp40.x = pthis->actor.world.pos.x; + sp40.y = pthis->actor.world.pos.y + 4; + sp40.z = pthis->actor.world.pos.z; EffectSsHahen_SpawnBurst(globalCtx, &sp40, 6.0f, 0, 7, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); - Actor_Kill(&this->actor); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); + Actor_Kill(&pthis->actor); } else { - if (this->timer == -300) { - Actor_Kill(&this->actor); + if (pthis->timer == -300) { + Actor_Kill(&pthis->actor); } } } void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { - EnNutsball* this = (EnNutsball*)thisx; + EnNutsball* pthis = (EnNutsball*)thisx; Player* player = GET_PLAYER(globalCtx); s32 pad; - if (!(player->stateFlags1 & 0x300000C0) || (this->actionFunc == func_80ABBB34)) { - this->actionFunc(this, globalCtx); + if (!(player->stateFlags1 & 0x300000C0) || (pthis->actionFunc == func_80ABBB34)) { + pthis->actionFunc(pthis, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10, sCylinderInit.dim.radius, sCylinderInit.dim.height, 5); - Collider_UpdateCylinder(&this->actor, &this->collider); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10, sCylinderInit.dim.radius, sCylinderInit.dim.height, 5); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); - this->actor.flags |= ACTOR_FLAG_24; + pthis->actor.flags |= ACTOR_FLAG_24; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.cpp similarity index 76% rename from src/overlays/actors/ovl_En_Nwc/z_en_nwc.c rename to src/overlays/actors/ovl_En_Nwc/z_en_nwc.cpp index 9c7513425..ee7b6bd6c 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.cpp @@ -22,13 +22,13 @@ void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnNwc_SetUpdate(EnNwc* this, EnNwcUpdateFunc updateFunc); -void EnNwc_ChickNoop(EnNwcChick* chick, EnNwc* this, GlobalContext* globalCtx); +void EnNwc_SetUpdate(EnNwc* pthis, EnNwcUpdateFunc updateFunc); +void EnNwc_ChickNoop(EnNwcChick* chick, EnNwc* pthis, GlobalContext* globalCtx); void EnNwc_ChickBgCheck(EnNwcChick* chick, GlobalContext* globalCtx); -void EnNwc_ChickFall(EnNwcChick* chick, EnNwc* this, GlobalContext* globalCtx); -void EnNwc_UpdateChicks(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_Idle(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_ChickFall(EnNwcChick* chick, EnNwc* pthis, GlobalContext* globalCtx); +void EnNwc_UpdateChicks(EnNwc* pthis, GlobalContext* globalCtx); +void EnNwc_DrawChicks(EnNwc* pthis, GlobalContext* globalCtx); +void EnNwc_Idle(EnNwc* pthis, GlobalContext* globalCtx); #define CHICK_BG_FLOOR (1 << 0) #define CHICK_BG_WALL (1 << 1) @@ -38,7 +38,7 @@ typedef enum { /* 1 */ CHICK_NORMAL } ChickTypes; -const ActorInit En_Nwc_InitVars = { +ActorInit En_Nwc_InitVars = { ACTOR_EN_NWC, ACTORCAT_PROP, FLAGS, @@ -74,11 +74,11 @@ static ColliderJntSphInitType1 sJntSphInit = { NULL, }; -void EnNwc_SetUpdate(EnNwc* this, EnNwcUpdateFunc updateFunc) { - this->updateFunc = updateFunc; +void EnNwc_SetUpdate(EnNwc* pthis, EnNwcUpdateFunc updateFunc) { + pthis->updateFunc = updateFunc; } -void EnNwc_ChickNoop(EnNwcChick* chick, EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_ChickNoop(EnNwcChick* chick, EnNwc* pthis, GlobalContext* globalCtx) { } void EnNwc_ChickBgCheck(EnNwcChick* chick, GlobalContext* globalCtx) { @@ -106,7 +106,7 @@ void EnNwc_ChickBgCheck(EnNwcChick* chick, GlobalContext* globalCtx) { } } -void EnNwc_ChickFall(EnNwcChick* chick, EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_ChickFall(EnNwcChick* chick, EnNwc* pthis, GlobalContext* globalCtx) { chick->velY -= 0.1f; if (chick->velY < -10.0f) { chick->velY = -10.0f; @@ -116,19 +116,19 @@ void EnNwc_ChickFall(EnNwcChick* chick, EnNwc* this, GlobalContext* globalCtx) { if (chick) {} // Needed for matching. Possibly from remnant of unfinished code? } -void EnNwc_UpdateChicks(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_UpdateChicks(EnNwc* pthis, GlobalContext* globalCtx) { static EnNwcChickFunc chickActionFuncs[] = { EnNwc_ChickNoop, EnNwc_ChickFall }; - EnNwcChick* chick = this->chicks; - ColliderJntSphElement* element = this->collider.elements; + EnNwcChick* chick = pthis->chicks; + ColliderJntSphElement* element = pthis->collider.elements; Vec3f prevChickPos; s32 i; f32 test; prevChickPos.y = 99999.9f; - for (i = 0; i < this->count; i++, prevChickPos = chick->pos, chick++, element++) { + for (i = 0; i < pthis->count; i++, prevChickPos = chick->pos, chick++, element++) { Math_Vec3f_Copy(&chick->lastPos, &chick->pos); - chickActionFuncs[chick->type](chick, this, globalCtx); + chickActionFuncs[chick->type](chick, pthis, globalCtx); element->dim.worldSphere.center.x = chick->pos.x; element->dim.worldSphere.center.y = chick->pos.y; @@ -153,7 +153,7 @@ void EnNwc_UpdateChicks(EnNwc* this, GlobalContext* globalCtx) { } } -void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_DrawChicks(EnNwc* pthis, GlobalContext* globalCtx) { s32 i; Gfx* dList1; Gfx* dList2; @@ -165,15 +165,15 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { func_80093C80(globalCtx); dList1 = POLY_XLU_DISP; - dList2 = dList1 + 3 * this->count + 1; - dList3 = dList2 + 2 * this->count + 1; + dList2 = dList1 + 3 * pthis->count + 1; + dList3 = dList2 + 2 * pthis->count + 1; gSPDisplayList(dList1++, gCuccoChickSetupBodyDL); gSPDisplayList(dList2++, gCuccoChickSetupEyeDL); gSPDisplayList(dList3++, gCuccoChickSetupBeakDL); - chick = this->chicks; - for (i = 0; i < this->count; i++, chick++) { + chick = pthis->chicks; + for (i = 0; i < pthis->count; i++, chick++) { if (chick->type != CHICK_NONE) { Mtx* mtx; @@ -190,12 +190,12 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { } } - chick = this->chicks; + chick = pthis->chicks; POLY_XLU_DISP = dList3; func_80094044(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gCuccoChickSetupShadowDL); - for (i = 0; i < this->count; i++, chick++) { + for (i = 0; i < pthis->count; i++, chick++) { if ((chick->type != CHICK_NONE) && (chick->floorPoly != NULL)) { func_80038A28(chick->floorPoly, chick->pos.x, chick->floorY, chick->pos.z, &floorMat); Matrix_Put(&floorMat); @@ -211,7 +211,7 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnNwc* this = (EnNwc*)thisx; + EnNwc* pthis = (EnNwc*)thisx; ColliderJntSphElementInit elementInits[16]; ColliderJntSphElementInit* element; EnNwcChick* chick; @@ -222,42 +222,42 @@ void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { *element = sJntSphElementInit; } - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSphAllocType1(globalCtx, &this->collider, &this->actor, &sJntSphInit); - this->count = 16; - chick = this->chicks; - for (i = 0; i < this->count; i++, chick++) { + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSphAllocType1(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit); + pthis->count = 16; + chick = pthis->chicks; + for (i = 0; i < pthis->count; i++, chick++) { chick->type = CHICK_NORMAL; chick->pos.x = thisx->world.pos.x + ((Rand_ZeroOne() * 100.0f) - 50.0f); chick->pos.y = thisx->world.pos.y + 20.0f; chick->pos.z = thisx->world.pos.z + ((Rand_ZeroOne() * 100.0f) - 50.0f); chick->height = 5; } - EnNwc_SetUpdate(this, EnNwc_Idle); + EnNwc_SetUpdate(pthis, EnNwc_Idle); } void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnNwc* this = (EnNwc*)thisx; + EnNwc* pthis = (EnNwc*)thisx; - Collider_FreeJntSph(globalCtx, &this->collider); + Collider_FreeJntSph(globalCtx, &pthis->collider); } -void EnNwc_Idle(EnNwc* this, GlobalContext* globalCtx) { - EnNwc_UpdateChicks(this, globalCtx); +void EnNwc_Idle(EnNwc* pthis, GlobalContext* globalCtx) { + EnNwc_UpdateChicks(pthis, globalCtx); } void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnNwc* this = (EnNwc*)thisx; + EnNwc* pthis = (EnNwc*)thisx; - this->updateFunc(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->updateFunc(pthis, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnNwc* this = (EnNwc*)thisx; + EnNwc* pthis = (EnNwc*)thisx; - EnNwc_DrawChicks(this, globalCtx); + EnNwc_DrawChicks(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ny/z_en_ny.c b/src/overlays/actors/ovl_En_Ny/z_en_ny.c deleted file mode 100644 index 55abd5c38..000000000 --- a/src/overlays/actors/ovl_En_Ny/z_en_ny.c +++ /dev/null @@ -1,616 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NY_Z_EN_NY_C -#include "actor_common.h" -#include "z_en_ny.h" -#include "objects/object_ny/object_ny.h" -#include "def/code_800FCE80.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnNy_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNy_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNy_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNy_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnNy_UpdateUnused(Actor* thisx, GlobalContext* globalCtx); -void EnNy_Move(EnNy* this, GlobalContext* globalCtx); -void EnNy_Die(EnNy* this, GlobalContext* globalCtx); -void func_80ABCD40(EnNy* this); -void func_80ABCDBC(EnNy* this); -void EnNy_TurnToStone(EnNy* this, GlobalContext* globalCtx); -void func_80ABD11C(EnNy* this, GlobalContext* globalCtx); -void func_80ABCE50(EnNy* this, GlobalContext* globalCtx); -void func_80ABCE90(EnNy* this, GlobalContext* globalCtx); -void func_80ABCEEC(EnNy* this, GlobalContext* globalCtx); -void EnNy_UpdateDeath(Actor* thisx, GlobalContext* GlobalContext); -void EnNy_SetupDie(EnNy* this, GlobalContext* globalCtx); -void EnNy_DrawDeathEffect(Actor* thisx, GlobalContext* GlobalContext); -void func_80ABD3B8(EnNy* this, f32, f32); - -const ActorInit En_Ny_InitVars = { - ACTOR_EN_NY, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_NY, - sizeof(EnNy), - (ActorFunc)EnNy_Init, - (ActorFunc)EnNy_Destroy, - (ActorFunc)EnNy_Update, - (ActorFunc)EnNy_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x04, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 15 }, 100 }, - }, -}; - -static ColliderJntSphInit sColliderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(2, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0xF), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(2, 0x1), - /* Kokiri sword */ DMG_ENTRY(0, 0x0), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0xF), - /* Light arrow */ DMG_ENTRY(2, 0xF), - /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(0, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(0, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x28, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -void EnNy_Init(Actor* thisx, GlobalContext* globalCtx) { - EnNy* this = (EnNy*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.health = 2; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderInit, this->elements); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - this->unk_1CA = 0; - this->unk_1D0 = 0; - Actor_SetScale(&this->actor, 0.01f); - this->actor.speedXZ = 0.0f; - this->actor.shape.rot.y = 0; - this->actor.gravity = -0.4f; - this->hitPlayer = 0; - this->unk_1CE = 2; - this->actor.velocity.y = 0.0f; - this->unk_1D4 = 0xFF; - this->unk_1D8 = 0; - this->unk_1E8 = 0.0f; - this->unk_1E0 = 0.25f; - if (this->actor.params == 0) { - // "New initials" - osSyncPrintf("ニュウ イニシャル[ %d ] !!\n", this->actor.params); - this->actor.colChkInfo.mass = 0; - this->unk_1D4 = 0; - this->unk_1D8 = 0xFF; - this->unk_1E0 = 1.0f; - func_80ABCDBC(this); - } else { - // This mode is unused in the final game - // "Dummy new initials" - osSyncPrintf("ダミーニュウ イニシャル[ %d ] !!\n", this->actor.params); - osSyncPrintf("En_Ny_actor_move2[ %x ] !!\n", EnNy_UpdateUnused); - this->actor.colChkInfo.mass = 0xFF; - this->collider.base.colType = COLTYPE_METAL; - this->actor.update = EnNy_UpdateUnused; - } -} - -void EnNy_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnNy* this = (EnNy*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void func_80ABCD40(EnNy* this) { - f32 temp; - - temp = (this->actor.yDistToWater > 0.0f) ? 0.7f : 1.0f; - this->unk_1E8 = 2.8f * temp; -} - -void func_80ABCD84(EnNy* this) { - this->actionFunc = func_80ABCE50; -} - -void func_80ABCD94(EnNy* this) { - this->stoneTimer = 0x14; - this->actionFunc = func_80ABCE90; -} - -void func_80ABCDAC(EnNy* this) { - this->actionFunc = func_80ABCEEC; -} - -void func_80ABCDBC(EnNy* this) { - this->unk_1F4 = 0.0f; - func_80ABCD40(this); - this->stoneTimer = 180; - this->actionFunc = EnNy_Move; -} - -void EnNy_SetupTurnToStone(EnNy* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NYU_HIT_STOP); - this->actionFunc = EnNy_TurnToStone; - this->unk_1E8 = 0.0f; -} - -void func_80ABCE38(EnNy* this) { - this->stoneTimer = 0x3C; - this->actionFunc = func_80ABD11C; -} - -void func_80ABCE50(EnNy* this, GlobalContext* globalCtx) { - if (this->actor.xyzDistToPlayerSq <= 25600.0f) { - func_80ABCD94(this); - } -} - -void func_80ABCE90(EnNy* this, GlobalContext* globalCtx) { - s32 phi_v1; - s32 phi_v0; - - phi_v1 = this->unk_1D4 - 0x40; - phi_v0 = this->unk_1D8 + 0x40; - if (phi_v0 >= 0xFF) { - phi_v1 = 0; - phi_v0 = 0xFF; - func_80ABCDAC(this); - } - this->unk_1D4 = phi_v1; - this->unk_1D8 = phi_v0; -} - -void func_80ABCEEC(EnNy* this, GlobalContext* globalCtx) { - f32 phi_f0; - - phi_f0 = this->unk_1E0; - phi_f0 += 2.0f; - if (phi_f0 >= 1.0f) { - phi_f0 = 1.0f; - func_80ABCDBC(this); - } - this->unk_1E0 = phi_f0; -} - -void EnNy_Move(EnNy* this, GlobalContext* globalCtx) { - f32 yawDiff; - s32 stoneTimer; - - if (!(this->unk_1F0 < this->actor.yDistToWater)) { - func_8002F974(&this->actor, NA_SE_EN_NYU_MOVE - SFX_FLAG); - } - func_80ABCD40(this); - stoneTimer = this->stoneTimer; - this->stoneTimer--; - if ((stoneTimer <= 0) || (this->hitPlayer != false)) { - EnNy_SetupTurnToStone(this); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, this->unk_1F4, 0); - Math_ApproachF(&this->unk_1F4, 2000.0f, 1.0f, 100.0f); - this->actor.world.rot.y = this->actor.shape.rot.y; - yawDiff = Math_FAtan2F(this->actor.yDistToPlayer, this->actor.xzDistToPlayer); - this->actor.speedXZ = fabsf(cosf(yawDiff) * this->unk_1E8); - if (this->unk_1F0 < this->actor.yDistToWater) { - this->unk_1EC = sinf(yawDiff) * this->unk_1E8; - } - } -} - -void EnNy_TurnToStone(EnNy* this, GlobalContext* globalCtx) { - f32 phi_f0; - - phi_f0 = this->unk_1E0; - phi_f0 -= 2.0f; - if (phi_f0 <= 0.25f) { - phi_f0 = 0.25f; - if (this->actor.bgCheckFlags & 2) { - if (!(this->unk_1F0 < this->actor.yDistToWater)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - this->actor.bgCheckFlags &= ~2; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80ABCE38(this); - } - } - this->unk_1E0 = phi_f0; -} - -void func_80ABD11C(EnNy* this, GlobalContext* globalCtx) { - s32 phi_v0; - s32 phi_v1; - - phi_v0 = this->unk_1D4; - phi_v0 += 0x40; - phi_v1 = this->unk_1D8; - phi_v1 -= 0x40; - if (phi_v0 >= 0xFF) { - phi_v0 = 0xFF; - phi_v1 = 0; - if (this->stoneTimer != 0) { - this->stoneTimer--; - } else { - func_80ABCD84(this); - } - } - this->unk_1D4 = phi_v0; - this->unk_1D8 = phi_v1; -} - -s32 EnNy_CollisionCheck(EnNy* this, GlobalContext* globalCtx) { - u8 sp3F; - Vec3f effectPos; - - sp3F = 0; - this->hitPlayer = 0; - if (this->collider.base.atFlags & 4) { - this->collider.base.atFlags &= ~4; - this->hitPlayer = 1; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = -4.0f; - return 0; - } - if (this->collider.base.atFlags & 2) { - this->collider.base.atFlags &= ~2; - this->hitPlayer = 1; - return 0; - } else { - if (this->collider.base.acFlags & 2) { - this->collider.base.acFlags &= ~2; - effectPos.x = this->collider.elements[0].info.bumper.hitPos.x; - effectPos.y = this->collider.elements[0].info.bumper.hitPos.y; - effectPos.z = this->collider.elements[0].info.bumper.hitPos.z; - if ((this->unk_1E0 == 0.25f) && (this->unk_1D4 == 0xFF)) { - switch (this->actor.colChkInfo.damageEffect) { - case 0xE: - sp3F = 1; - case 0xF: - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - break; - case 1: - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - break; - case 2: - this->unk_1CA = 4; - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - break; - } - } - this->stoneTimer = 0; - if (this->actor.colChkInfo.health == 0) { - this->actor.shape.shadowAlpha = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_1D0 = sp3F; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - return 1; - } - EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &effectPos); - return 0; - } - } - return 0; -} - -void func_80ABD3B8(EnNy* this, f32 arg1, f32 arg2) { - if (this->unk_1E8 == 0.0f) { - this->actor.gravity = -0.4f; - } else if (!(arg1 < this->actor.yDistToWater)) { - this->actor.gravity = -0.4f; - } else if (arg2 < this->actor.yDistToWater) { - this->actor.gravity = 0.0; - if (this->unk_1EC < this->actor.velocity.y) { - this->actor.velocity.y -= 0.4f; - if (this->actor.velocity.y < this->unk_1EC) { - this->actor.velocity.y = this->unk_1EC; - } - } else if (this->actor.velocity.y < this->unk_1EC) { - this->actor.velocity.y += 0.4f; - if (this->unk_1EC < this->actor.velocity.y) { - this->actor.velocity.y = this->unk_1EC; - } - } - } -} - -void EnNy_Update(Actor* thisx, GlobalContext* globalCtx) { - EnNy* this = (EnNy*)thisx; - f32 temp_f20; - f32 temp_f22; - s32 i; - - this->timer++; - temp_f20 = this->unk_1E0 - 0.25f; - if (this->unk_1CA != 0) { - this->unk_1CA--; - } - Actor_SetFocus(&this->actor, 0.0f); - Actor_SetScale(&this->actor, 0.01f); - this->collider.elements[0].dim.scale = 1.33f * temp_f20 + 1.0f; - temp_f22 = (24.0f * temp_f20) + 12.0f; - this->actor.shape.rot.x += (s16)(this->unk_1E8 * 1000.0f); - func_80ABD3B8(this, temp_f22 + 10.0f, temp_f22 - 10.0f); - Actor_MoveForward(&this->actor); - Math_StepToF(&this->unk_1E4, this->unk_1E8, 0.1f); - this->actionFunc(this, globalCtx); - this->actor.prevPos.y -= temp_f22; - this->actor.world.pos.y -= temp_f22; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 7); - this->unk_1F0 = temp_f22; - this->actor.world.pos.y += temp_f22; - if (EnNy_CollisionCheck(this, globalCtx) != 0) { - for (i = 0; i < 8; i++) { - this->unk_1F8[i].x = (Rand_CenteredFloat(20.0f) + this->actor.world.pos.x); - this->unk_1F8[i].y = (Rand_CenteredFloat(20.0f) + this->actor.world.pos.y); - this->unk_1F8[i].z = (Rand_CenteredFloat(20.0f) + this->actor.world.pos.z); - } - this->timer = 0; - this->actor.update = EnNy_UpdateDeath; - this->actor.draw = EnNy_DrawDeathEffect; - this->actionFunc = EnNy_SetupDie; - return; - } - if (this->unk_1E0 > 0.25f) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnNy_SetupDie(EnNy* this, GlobalContext* globalCtx) { - s32 effectScale; - s32 i; - Vec3f effectPos; - Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; - Vec3f effectAccel = { 0.0f, 0.1f, 0.0f }; - - if (this->timer >= 2) { - if (this->actor.yDistToWater > 0.0f) { - for (i = 0; i < 10; i++) { - effectPos.x = Rand_CenteredFloat(30.0f) + this->actor.world.pos.x; - effectPos.y = Rand_CenteredFloat(30.0f) + this->actor.world.pos.y; - effectPos.z = Rand_CenteredFloat(30.0f) + this->actor.world.pos.z; - effectScale = Rand_S16Offset(0x50, 0x64); - EffectSsDtBubble_SpawnColorProfile(globalCtx, &effectPos, &effectVelocity, &effectAccel, effectScale, - 25, 0, 1); - } - for (i = 0; i < 0x14; i++) { - effectPos.x = Rand_CenteredFloat(30.0f) + this->actor.world.pos.x; - effectPos.y = Rand_CenteredFloat(30.0f) + this->actor.world.pos.y; - effectPos.z = Rand_CenteredFloat(30.0f) + this->actor.world.pos.z; - EffectSsBubble_Spawn(globalCtx, &effectPos, 10.0f, 10.0f, 30.0f, 0.25f); - } - } - for (i = 0; i < 8; i++) { - this->unk_1F8[i + 8].x = Rand_CenteredFloat(10.0f); - this->unk_1F8[i + 8].z = Rand_CenteredFloat(10.0f); - this->unk_1F8[i + 8].y = Rand_ZeroFloat(4.0f) + 4.0f; - } - this->timer = 0; - if (this->unk_1D0 == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, 8); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NYU_DEAD); - this->actionFunc = EnNy_Die; - } -} - -void EnNy_Die(EnNy* this, GlobalContext* globalCtx) { - s32 i; - - if (this->actor.yDistToWater > 0.0f) { - for (i = 0; i < 8; i += 1) { - this->unk_1F8[i].x += this->unk_1F8[i + 8].x; - this->unk_1F8[i].y += this->unk_1F8[i + 8].y; - this->unk_1F8[i].z += this->unk_1F8[i + 8].z; - Math_StepToF(&this->unk_1F8[i + 8].x, 0.0f, 0.1f); - Math_StepToF(&this->unk_1F8[i + 8].y, -1.0f, 0.4f); - Math_StepToF(&this->unk_1F8[i + 8].z, 0.0f, 0.1f); - } - if (this->timer >= 0x1F) { - Actor_Kill(&this->actor); - return; - } - } else { - for (i = 0; i < 8; i += 1) { - this->unk_1F8[i].x += this->unk_1F8[i + 8].x; - this->unk_1F8[i].y += this->unk_1F8[i + 8].y; - this->unk_1F8[i].z += this->unk_1F8[i + 8].z; - Math_StepToF(&this->unk_1F8[i + 8].x, 0.0f, 0.15f); - Math_StepToF(&this->unk_1F8[i + 8].y, -1.0f, 0.6f); - Math_StepToF(&this->unk_1F8[i + 8].z, 0.0f, 0.15f); - } - if (this->timer >= 0x10) { - Actor_Kill(&this->actor); - return; - } - } -} - -void EnNy_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { - EnNy* this = (EnNy*)thisx; - - this->timer++; - if (this->unk_1CA != 0) { - this->unk_1CA--; - } - this->actionFunc(this, globalCtx); -} - -void EnNy_UpdateUnused(Actor* thisx, GlobalContext* globalCtx2) { - EnNy* this = (EnNy*)thisx; - GlobalContext* globalCtx = globalCtx2; - f32 sp3C; - f32 temp_f0; - - sp3C = this->unk_1E0 - 0.25f; - this->timer++; - Actor_SetFocus(&this->actor, 0.0f); - Actor_SetScale(&this->actor, 0.01f); - temp_f0 = (24.0f * sp3C) + 12.0f; - this->actor.prevPos.y -= temp_f0; - this->actor.world.pos.y -= temp_f0; - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 7); - this->unk_1F0 = temp_f0; - this->actor.world.pos.y += temp_f0; - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Math_StepToF(&this->unk_1E4, this->unk_1E8, 0.1f); -} -static Vec3f sFireOffsets[] = { - { 5.0f, 0.0f, 0.0f }, - { -5.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 5.0f }, - { 0.0f, 0.0f, -5.0f }, -}; - -void EnNy_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnNy* this = (EnNy*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 837); - Collider_UpdateSpheres(0, &this->collider); - func_8002ED80(&this->actor, globalCtx, 1); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ny.c", 845), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1D8); - gSPDisplayList(POLY_XLU_DISP++, gEnNyMetalBodyDL); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1D4); - gSPDisplayList(POLY_XLU_DISP++, gEnNyRockBodyDL); - if (this->unk_1E0 > 0.25f) { - Matrix_Scale(this->unk_1E0, this->unk_1E0, this->unk_1E0, MTXMODE_APPLY); - func_8002EBCC(&this->actor, globalCtx, 1); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ny.c", 868), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gEnNySpikeDL); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 872); - if (this->unk_1CA != 0) { - Vec3f tempVec; - Vec3f* fireOffset; - s16 temp; - - temp = this->unk_1CA - 1; - this->actor.colorFilterTimer++; - if (temp == 0) { - fireOffset = &sFireOffsets[temp & 3]; - tempVec.x = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.x + fireOffset->x); - tempVec.y = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.y + fireOffset->y); - tempVec.z = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.z + fireOffset->z); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &tempVec, 100, 0, 0, -1); - } - } -} - -void EnNy_DrawDeathEffect(Actor* thisx, GlobalContext* globalCtx) { - EnNy* this = (EnNy*)thisx; - Vec3f* temp; - f32 scale; - s32 i; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 900); - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0x00, 0x00, 0x00, 0xFF); - gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); - gDPPipeSync(POLY_OPA_DISP++); - for (i = 0; i < 8; i++) { - if (this->timer < (i + 22)) { - temp = &this->unk_1F8[i]; - Matrix_Translate(temp->x, temp->y, temp->z, MTXMODE_NEW); - scale = this->actor.scale.x * 0.4f * (1.0f + (i * 0.04f)); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ny.c", 912), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gEnNyRockBodyDL); - } - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 919); - if (this->unk_1CA != 0) { - Vec3f tempVec; - Vec3f* fireOffset; - s16 fireOffsetIndex; - - fireOffsetIndex = this->unk_1CA - 1; - this->actor.colorFilterTimer++; - if ((fireOffsetIndex & 1) == 0) { - fireOffset = &sFireOffsets[fireOffsetIndex & 3]; - tempVec.x = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.x + fireOffset->x); - tempVec.y = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.y + fireOffset->y); - tempVec.z = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.z + fireOffset->z); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &tempVec, 100, 0, 0, -1); - } - } -} diff --git a/src/overlays/actors/ovl_En_Ny/z_en_ny.cpp b/src/overlays/actors/ovl_En_Ny/z_en_ny.cpp new file mode 100644 index 000000000..2dc97234e --- /dev/null +++ b/src/overlays/actors/ovl_En_Ny/z_en_ny.cpp @@ -0,0 +1,616 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_NY_Z_EN_NY_C +#include "actor_common.h" +#include "z_en_ny.h" +#include "objects/object_ny/object_ny.h" +#include "def/code_800FCE80.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnNy_Init(Actor* thisx, GlobalContext* globalCtx); +void EnNy_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnNy_Update(Actor* thisx, GlobalContext* globalCtx); +void EnNy_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnNy_UpdateUnused(Actor* thisx, GlobalContext* globalCtx); +void EnNy_Move(EnNy* pthis, GlobalContext* globalCtx); +void EnNy_Die(EnNy* pthis, GlobalContext* globalCtx); +void func_80ABCD40(EnNy* pthis); +void func_80ABCDBC(EnNy* pthis); +void EnNy_TurnToStone(EnNy* pthis, GlobalContext* globalCtx); +void func_80ABD11C(EnNy* pthis, GlobalContext* globalCtx); +void func_80ABCE50(EnNy* pthis, GlobalContext* globalCtx); +void func_80ABCE90(EnNy* pthis, GlobalContext* globalCtx); +void func_80ABCEEC(EnNy* pthis, GlobalContext* globalCtx); +void EnNy_UpdateDeath(Actor* thisx, GlobalContext* GlobalContext); +void EnNy_SetupDie(EnNy* pthis, GlobalContext* globalCtx); +void EnNy_DrawDeathEffect(Actor* thisx, GlobalContext* GlobalContext); +void func_80ABD3B8(EnNy* pthis, f32, f32); + +ActorInit En_Ny_InitVars = { + ACTOR_EN_NY, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_NY, + sizeof(EnNy), + (ActorFunc)EnNy_Init, + (ActorFunc)EnNy_Destroy, + (ActorFunc)EnNy_Update, + (ActorFunc)EnNy_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x04, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 15 }, 100 }, + }, +}; + +static ColliderJntSphInit sColliderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0xF), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(2, 0x1), + /* Kokiri sword */ DMG_ENTRY(0, 0x0), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(2, 0xF), + /* Light arrow */ DMG_ENTRY(2, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(0, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x28, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +void EnNy_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNy* pthis = (EnNy*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.colChkInfo.health = 2; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sColliderInit, pthis->elements); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + pthis->unk_1CA = 0; + pthis->unk_1D0 = 0; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.shape.rot.y = 0; + pthis->actor.gravity = -0.4f; + pthis->hitPlayer = 0; + pthis->unk_1CE = 2; + pthis->actor.velocity.y = 0.0f; + pthis->unk_1D4 = 0xFF; + pthis->unk_1D8 = 0; + pthis->unk_1E8 = 0.0f; + pthis->unk_1E0 = 0.25f; + if (pthis->actor.params == 0) { + // "New initials" + osSyncPrintf("ニュウ イニシャル[ %d ] !!\n", pthis->actor.params); + pthis->actor.colChkInfo.mass = 0; + pthis->unk_1D4 = 0; + pthis->unk_1D8 = 0xFF; + pthis->unk_1E0 = 1.0f; + func_80ABCDBC(pthis); + } else { + // This mode is unused in the final game + // "Dummy new initials" + osSyncPrintf("ダミーニュウ イニシャル[ %d ] !!\n", pthis->actor.params); + osSyncPrintf("En_Ny_actor_move2[ %x ] !!\n", EnNy_UpdateUnused); + pthis->actor.colChkInfo.mass = 0xFF; + pthis->collider.base.colType = COLTYPE_METAL; + pthis->actor.update = EnNy_UpdateUnused; + } +} + +void EnNy_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNy* pthis = (EnNy*)thisx; + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void func_80ABCD40(EnNy* pthis) { + f32 temp; + + temp = (pthis->actor.yDistToWater > 0.0f) ? 0.7f : 1.0f; + pthis->unk_1E8 = 2.8f * temp; +} + +void func_80ABCD84(EnNy* pthis) { + pthis->actionFunc = func_80ABCE50; +} + +void func_80ABCD94(EnNy* pthis) { + pthis->stoneTimer = 0x14; + pthis->actionFunc = func_80ABCE90; +} + +void func_80ABCDAC(EnNy* pthis) { + pthis->actionFunc = func_80ABCEEC; +} + +void func_80ABCDBC(EnNy* pthis) { + pthis->unk_1F4 = 0.0f; + func_80ABCD40(pthis); + pthis->stoneTimer = 180; + pthis->actionFunc = EnNy_Move; +} + +void EnNy_SetupTurnToStone(EnNy* pthis) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NYU_HIT_STOP); + pthis->actionFunc = EnNy_TurnToStone; + pthis->unk_1E8 = 0.0f; +} + +void func_80ABCE38(EnNy* pthis) { + pthis->stoneTimer = 0x3C; + pthis->actionFunc = func_80ABD11C; +} + +void func_80ABCE50(EnNy* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xyzDistToPlayerSq <= 25600.0f) { + func_80ABCD94(pthis); + } +} + +void func_80ABCE90(EnNy* pthis, GlobalContext* globalCtx) { + s32 phi_v1; + s32 phi_v0; + + phi_v1 = pthis->unk_1D4 - 0x40; + phi_v0 = pthis->unk_1D8 + 0x40; + if (phi_v0 >= 0xFF) { + phi_v1 = 0; + phi_v0 = 0xFF; + func_80ABCDAC(pthis); + } + pthis->unk_1D4 = phi_v1; + pthis->unk_1D8 = phi_v0; +} + +void func_80ABCEEC(EnNy* pthis, GlobalContext* globalCtx) { + f32 phi_f0; + + phi_f0 = pthis->unk_1E0; + phi_f0 += 2.0f; + if (phi_f0 >= 1.0f) { + phi_f0 = 1.0f; + func_80ABCDBC(pthis); + } + pthis->unk_1E0 = phi_f0; +} + +void EnNy_Move(EnNy* pthis, GlobalContext* globalCtx) { + f32 yawDiff; + s32 stoneTimer; + + if (!(pthis->unk_1F0 < pthis->actor.yDistToWater)) { + func_8002F974(&pthis->actor, NA_SE_EN_NYU_MOVE - SFX_FLAG); + } + func_80ABCD40(pthis); + stoneTimer = pthis->stoneTimer; + pthis->stoneTimer--; + if ((stoneTimer <= 0) || (pthis->hitPlayer != false)) { + EnNy_SetupTurnToStone(pthis); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, pthis->unk_1F4, 0); + Math_ApproachF(&pthis->unk_1F4, 2000.0f, 1.0f, 100.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + yawDiff = Math_FAtan2F(pthis->actor.yDistToPlayer, pthis->actor.xzDistToPlayer); + pthis->actor.speedXZ = fabsf(cosf(yawDiff) * pthis->unk_1E8); + if (pthis->unk_1F0 < pthis->actor.yDistToWater) { + pthis->unk_1EC = sinf(yawDiff) * pthis->unk_1E8; + } + } +} + +void EnNy_TurnToStone(EnNy* pthis, GlobalContext* globalCtx) { + f32 phi_f0; + + phi_f0 = pthis->unk_1E0; + phi_f0 -= 2.0f; + if (phi_f0 <= 0.25f) { + phi_f0 = 0.25f; + if (pthis->actor.bgCheckFlags & 2) { + if (!(pthis->unk_1F0 < pthis->actor.yDistToWater)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + pthis->actor.bgCheckFlags &= ~2; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80ABCE38(pthis); + } + } + pthis->unk_1E0 = phi_f0; +} + +void func_80ABD11C(EnNy* pthis, GlobalContext* globalCtx) { + s32 phi_v0; + s32 phi_v1; + + phi_v0 = pthis->unk_1D4; + phi_v0 += 0x40; + phi_v1 = pthis->unk_1D8; + phi_v1 -= 0x40; + if (phi_v0 >= 0xFF) { + phi_v0 = 0xFF; + phi_v1 = 0; + if (pthis->stoneTimer != 0) { + pthis->stoneTimer--; + } else { + func_80ABCD84(pthis); + } + } + pthis->unk_1D4 = phi_v0; + pthis->unk_1D8 = phi_v1; +} + +s32 EnNy_CollisionCheck(EnNy* pthis, GlobalContext* globalCtx) { + u8 sp3F; + Vec3f effectPos; + + sp3F = 0; + pthis->hitPlayer = 0; + if (pthis->collider.base.atFlags & 4) { + pthis->collider.base.atFlags &= ~4; + pthis->hitPlayer = 1; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = -4.0f; + return 0; + } + if (pthis->collider.base.atFlags & 2) { + pthis->collider.base.atFlags &= ~2; + pthis->hitPlayer = 1; + return 0; + } else { + if (pthis->collider.base.acFlags & 2) { + pthis->collider.base.acFlags &= ~2; + effectPos.x = pthis->collider.elements[0].info.bumper.hitPos.x; + effectPos.y = pthis->collider.elements[0].info.bumper.hitPos.y; + effectPos.z = pthis->collider.elements[0].info.bumper.hitPos.z; + if ((pthis->unk_1E0 == 0.25f) && (pthis->unk_1D4 == 0xFF)) { + switch (pthis->actor.colChkInfo.damageEffect) { + case 0xE: + sp3F = 1; + case 0xF: + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + break; + case 1: + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + break; + case 2: + pthis->unk_1CA = 4; + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + break; + } + } + pthis->stoneTimer = 0; + if (pthis->actor.colChkInfo.health == 0) { + pthis->actor.shape.shadowAlpha = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_1D0 = sp3F; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + return 1; + } + EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &effectPos); + return 0; + } + } + return 0; +} + +void func_80ABD3B8(EnNy* pthis, f32 arg1, f32 arg2) { + if (pthis->unk_1E8 == 0.0f) { + pthis->actor.gravity = -0.4f; + } else if (!(arg1 < pthis->actor.yDistToWater)) { + pthis->actor.gravity = -0.4f; + } else if (arg2 < pthis->actor.yDistToWater) { + pthis->actor.gravity = 0.0; + if (pthis->unk_1EC < pthis->actor.velocity.y) { + pthis->actor.velocity.y -= 0.4f; + if (pthis->actor.velocity.y < pthis->unk_1EC) { + pthis->actor.velocity.y = pthis->unk_1EC; + } + } else if (pthis->actor.velocity.y < pthis->unk_1EC) { + pthis->actor.velocity.y += 0.4f; + if (pthis->unk_1EC < pthis->actor.velocity.y) { + pthis->actor.velocity.y = pthis->unk_1EC; + } + } + } +} + +void EnNy_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNy* pthis = (EnNy*)thisx; + f32 temp_f20; + f32 temp_f22; + s32 i; + + pthis->timer++; + temp_f20 = pthis->unk_1E0 - 0.25f; + if (pthis->unk_1CA != 0) { + pthis->unk_1CA--; + } + Actor_SetFocus(&pthis->actor, 0.0f); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->collider.elements[0].dim.scale = 1.33f * temp_f20 + 1.0f; + temp_f22 = (24.0f * temp_f20) + 12.0f; + pthis->actor.shape.rot.x += (s16)(pthis->unk_1E8 * 1000.0f); + func_80ABD3B8(pthis, temp_f22 + 10.0f, temp_f22 - 10.0f); + Actor_MoveForward(&pthis->actor); + Math_StepToF(&pthis->unk_1E4, pthis->unk_1E8, 0.1f); + pthis->actionFunc(pthis, globalCtx); + pthis->actor.prevPos.y -= temp_f22; + pthis->actor.world.pos.y -= temp_f22; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 7); + pthis->unk_1F0 = temp_f22; + pthis->actor.world.pos.y += temp_f22; + if (EnNy_CollisionCheck(pthis, globalCtx) != 0) { + for (i = 0; i < 8; i++) { + pthis->unk_1F8[i].x = (Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x); + pthis->unk_1F8[i].y = (Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.y); + pthis->unk_1F8[i].z = (Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z); + } + pthis->timer = 0; + pthis->actor.update = EnNy_UpdateDeath; + pthis->actor.draw = EnNy_DrawDeathEffect; + pthis->actionFunc = EnNy_SetupDie; + return; + } + if (pthis->unk_1E0 > 0.25f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnNy_SetupDie(EnNy* pthis, GlobalContext* globalCtx) { + s32 effectScale; + s32 i; + Vec3f effectPos; + Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; + Vec3f effectAccel = { 0.0f, 0.1f, 0.0f }; + + if (pthis->timer >= 2) { + if (pthis->actor.yDistToWater > 0.0f) { + for (i = 0; i < 10; i++) { + effectPos.x = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.x; + effectPos.y = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.y; + effectPos.z = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.z; + effectScale = Rand_S16Offset(0x50, 0x64); + EffectSsDtBubble_SpawnColorProfile(globalCtx, &effectPos, &effectVelocity, &effectAccel, effectScale, + 25, 0, 1); + } + for (i = 0; i < 0x14; i++) { + effectPos.x = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.x; + effectPos.y = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.y; + effectPos.z = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.z; + EffectSsBubble_Spawn(globalCtx, &effectPos, 10.0f, 10.0f, 30.0f, 0.25f); + } + } + for (i = 0; i < 8; i++) { + pthis->unk_1F8[i + 8].x = Rand_CenteredFloat(10.0f); + pthis->unk_1F8[i + 8].z = Rand_CenteredFloat(10.0f); + pthis->unk_1F8[i + 8].y = Rand_ZeroFloat(4.0f) + 4.0f; + } + pthis->timer = 0; + if (pthis->unk_1D0 == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xA0); + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, 8); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NYU_DEAD); + pthis->actionFunc = EnNy_Die; + } +} + +void EnNy_Die(EnNy* pthis, GlobalContext* globalCtx) { + s32 i; + + if (pthis->actor.yDistToWater > 0.0f) { + for (i = 0; i < 8; i += 1) { + pthis->unk_1F8[i].x += pthis->unk_1F8[i + 8].x; + pthis->unk_1F8[i].y += pthis->unk_1F8[i + 8].y; + pthis->unk_1F8[i].z += pthis->unk_1F8[i + 8].z; + Math_StepToF(&pthis->unk_1F8[i + 8].x, 0.0f, 0.1f); + Math_StepToF(&pthis->unk_1F8[i + 8].y, -1.0f, 0.4f); + Math_StepToF(&pthis->unk_1F8[i + 8].z, 0.0f, 0.1f); + } + if (pthis->timer >= 0x1F) { + Actor_Kill(&pthis->actor); + return; + } + } else { + for (i = 0; i < 8; i += 1) { + pthis->unk_1F8[i].x += pthis->unk_1F8[i + 8].x; + pthis->unk_1F8[i].y += pthis->unk_1F8[i + 8].y; + pthis->unk_1F8[i].z += pthis->unk_1F8[i + 8].z; + Math_StepToF(&pthis->unk_1F8[i + 8].x, 0.0f, 0.15f); + Math_StepToF(&pthis->unk_1F8[i + 8].y, -1.0f, 0.6f); + Math_StepToF(&pthis->unk_1F8[i + 8].z, 0.0f, 0.15f); + } + if (pthis->timer >= 0x10) { + Actor_Kill(&pthis->actor); + return; + } + } +} + +void EnNy_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { + EnNy* pthis = (EnNy*)thisx; + + pthis->timer++; + if (pthis->unk_1CA != 0) { + pthis->unk_1CA--; + } + pthis->actionFunc(pthis, globalCtx); +} + +void EnNy_UpdateUnused(Actor* thisx, GlobalContext* globalCtx2) { + EnNy* pthis = (EnNy*)thisx; + GlobalContext* globalCtx = globalCtx2; + f32 sp3C; + f32 temp_f0; + + sp3C = pthis->unk_1E0 - 0.25f; + pthis->timer++; + Actor_SetFocus(&pthis->actor, 0.0f); + Actor_SetScale(&pthis->actor, 0.01f); + temp_f0 = (24.0f * sp3C) + 12.0f; + pthis->actor.prevPos.y -= temp_f0; + pthis->actor.world.pos.y -= temp_f0; + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 7); + pthis->unk_1F0 = temp_f0; + pthis->actor.world.pos.y += temp_f0; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Math_StepToF(&pthis->unk_1E4, pthis->unk_1E8, 0.1f); +} +static Vec3f sFireOffsets[] = { + { 5.0f, 0.0f, 0.0f }, + { -5.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 5.0f }, + { 0.0f, 0.0f, -5.0f }, +}; + +void EnNy_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnNy* pthis = (EnNy*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 837); + Collider_UpdateSpheres(0, &pthis->collider); + func_8002ED80(&pthis->actor, globalCtx, 1); + func_80093D84(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ny.c", 845), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->unk_1D8); + gSPDisplayList(POLY_XLU_DISP++, gEnNyMetalBodyDL); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->unk_1D4); + gSPDisplayList(POLY_XLU_DISP++, gEnNyRockBodyDL); + if (pthis->unk_1E0 > 0.25f) { + Matrix_Scale(pthis->unk_1E0, pthis->unk_1E0, pthis->unk_1E0, MTXMODE_APPLY); + func_8002EBCC(&pthis->actor, globalCtx, 1); + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ny.c", 868), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gEnNySpikeDL); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 872); + if (pthis->unk_1CA != 0) { + Vec3f tempVec; + Vec3f* fireOffset; + s16 temp; + + temp = pthis->unk_1CA - 1; + pthis->actor.colorFilterTimer++; + if (temp == 0) { + fireOffset = &sFireOffsets[temp & 3]; + tempVec.x = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.x + fireOffset->x); + tempVec.y = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.y + fireOffset->y); + tempVec.z = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.z + fireOffset->z); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &tempVec, 100, 0, 0, -1); + } + } +} + +void EnNy_DrawDeathEffect(Actor* thisx, GlobalContext* globalCtx) { + EnNy* pthis = (EnNy*)thisx; + Vec3f* temp; + f32 scale; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 900); + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0x00, 0x00, 0x00, 0xFF); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gDPPipeSync(POLY_OPA_DISP++); + for (i = 0; i < 8; i++) { + if (pthis->timer < (i + 22)) { + temp = &pthis->unk_1F8[i]; + Matrix_Translate(temp->x, temp->y, temp->z, MTXMODE_NEW); + scale = pthis->actor.scale.x * 0.4f * (1.0f + (i * 0.04f)); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ny.c", 912), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gEnNyRockBodyDL); + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ny.c", 919); + if (pthis->unk_1CA != 0) { + Vec3f tempVec; + Vec3f* fireOffset; + s16 fireOffsetIndex; + + fireOffsetIndex = pthis->unk_1CA - 1; + pthis->actor.colorFilterTimer++; + if ((fireOffsetIndex & 1) == 0) { + fireOffset = &sFireOffsets[fireOffsetIndex & 3]; + tempVec.x = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.x + fireOffset->x); + tempVec.y = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.y + fireOffset->y); + tempVec.z = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.z + fireOffset->z); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &tempVec, 100, 0, 0, -1); + } + } +} diff --git a/src/overlays/actors/ovl_En_OE2/z_en_oe2.c b/src/overlays/actors/ovl_En_OE2/z_en_oe2.cpp similarity index 72% rename from src/overlays/actors/ovl_En_OE2/z_en_oe2.c rename to src/overlays/actors/ovl_En_OE2/z_en_oe2.cpp index dc5027d22..c040f616c 100644 --- a/src/overlays/actors/ovl_En_OE2/z_en_oe2.c +++ b/src/overlays/actors/ovl_En_OE2/z_en_oe2.cpp @@ -14,9 +14,9 @@ void EnOE2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOE2_Update(Actor* thisx, GlobalContext* globalCtx); void EnOE2_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnOE2_DoNothing(EnOE2* this, GlobalContext* globalCtx); +void EnOE2_DoNothing(EnOE2* pthis, GlobalContext* globalCtx); -const ActorInit En_OE2_InitVars = { +ActorInit En_OE2_InitVars = { ACTOR_EN_OE2, ACTORCAT_NPC, FLAGS, @@ -28,20 +28,20 @@ const ActorInit En_OE2_InitVars = { (ActorFunc)EnOE2_Draw, }; -void EnOE2_SetupAction(EnOE2* this, EnOE2ActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnOE2_SetupAction(EnOE2* pthis, EnOE2ActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnOE2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnOE2* this = (EnOE2*)thisx; + EnOE2* pthis = (EnOE2*)thisx; - EnOE2_SetupAction(this, EnOE2_DoNothing); + EnOE2_SetupAction(pthis, EnOE2_DoNothing); } void EnOE2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void EnOE2_DoNothing(EnOE2* this, GlobalContext* globalCtx) { +void EnOE2_DoNothing(EnOE2* pthis, GlobalContext* globalCtx) { } void EnOE2_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.cpp similarity index 75% rename from src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c rename to src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.cpp index 60d437a34..2a95b8fd9 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.cpp @@ -23,10 +23,10 @@ void EnOkarinaEffect_Init(Actor* thisx, GlobalContext* globalCtx); void EnOkarinaEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOkarinaEffect_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, GlobalContext* globalCtx); -void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, GlobalContext* globalCtx); +void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* pthis, GlobalContext* globalCtx); +void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* pthis, GlobalContext* globalCtx); -const ActorInit En_Okarina_Effect_InitVars = { +ActorInit En_Okarina_Effect_InitVars = { ACTOR_EN_OKARINA_EFFECT, ACTORCAT_ITEMACTION, FLAGS, @@ -38,12 +38,12 @@ const ActorInit En_Okarina_Effect_InitVars = { NULL, }; -void EnOkarinaEffect_SetupAction(EnOkarinaEffect* this, EnOkarinaEffectActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnOkarinaEffect_SetupAction(EnOkarinaEffect* pthis, EnOkarinaEffectActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnOkarinaEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnOkarinaEffect* this = (EnOkarinaEffect*)thisx; + EnOkarinaEffect* pthis = (EnOkarinaEffect*)thisx; globalCtx->envCtx.unk_F2[0] = 0; if ((gWeatherMode != 4) && (gWeatherMode != 5) && (globalCtx->envCtx.gloomySkyMode == 1)) { @@ -54,20 +54,20 @@ void EnOkarinaEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnOkarinaEffect_Init(Actor* thisx, GlobalContext* globalCtx) { - EnOkarinaEffect* this = (EnOkarinaEffect*)thisx; + EnOkarinaEffect* pthis = (EnOkarinaEffect*)thisx; osSyncPrintf("\n\n"); // "Ocarina Storm Effect" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ オカリナあらし効果ビカビカビカ〜 ☆☆☆☆☆ \n" VT_RST); osSyncPrintf("\n\n"); if (globalCtx->envCtx.unk_EE[1] != 0) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - EnOkarinaEffect_SetupAction(this, EnOkarinaEffect_TriggerStorm); + EnOkarinaEffect_SetupAction(pthis, EnOkarinaEffect_TriggerStorm); } -void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, GlobalContext* globalCtx) { - this->timer = 400; // 20 seconds +void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* pthis, GlobalContext* globalCtx) { + pthis->timer = 400; // 20 seconds globalCtx->envCtx.unk_F2[0] = 20; // rain intensity target globalCtx->envCtx.gloomySkyMode = 1; // start gloomy sky if ((gWeatherMode != 0) || globalCtx->envCtx.unk_17 != 0) { @@ -75,30 +75,30 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, GlobalContext* globalCt } globalCtx->envCtx.lightningMode = LIGHTNING_MODE_ON; func_80077624(globalCtx); - EnOkarinaEffect_SetupAction(this, EnOkarinaEffect_ManageStorm); + EnOkarinaEffect_SetupAction(pthis, EnOkarinaEffect_ManageStorm); } -void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, GlobalContext* globalCtx) { +void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* pthis, GlobalContext* globalCtx) { Flags_UnsetEnv(globalCtx, 5); // clear storms env flag if (((globalCtx->pauseCtx.state == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->msgCtx.msgLength == 0) && (!FrameAdvance_IsEnabled(globalCtx)) && ((globalCtx->transitionMode == 0) || (gSaveContext.gameMode != 0))) || - (this->timer >= 250)) { + (pthis->timer >= 250)) { if (globalCtx->envCtx.indoors || globalCtx->envCtx.unk_1F != 1) { - this->timer--; + pthis->timer--; } - osSyncPrintf("\nthis->timer=[%d]", this->timer); - if (this->timer == 308) { + osSyncPrintf("\nthis->timer=[%d]", pthis->timer); + if (pthis->timer == 308) { osSyncPrintf("\n\n\n豆よ のびろ 指定\n\n\n"); // "Let's grow some beans" Flags_SetEnv(globalCtx, 5); // set storms env flag } } if (D_8011FB38 != 0) { - this->timer = 0; + pthis->timer = 0; } - if (this->timer == 0) { + if (pthis->timer == 0) { globalCtx->envCtx.unk_F2[0] = 0; if (globalCtx->csCtx.state == CS_STATE_IDLE) { func_80077684(globalCtx); @@ -115,12 +115,12 @@ void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, GlobalContext* globalCtx globalCtx->envCtx.unk_DE = 0; } globalCtx->envCtx.lightningMode = LIGHTNING_MODE_LAST; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void EnOkarinaEffect_Update(Actor* thisx, GlobalContext* globalCtx) { - EnOkarinaEffect* this = (EnOkarinaEffect*)thisx; + EnOkarinaEffect* pthis = (EnOkarinaEffect*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.cpp similarity index 59% rename from src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c rename to src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.cpp index df7cc13c0..9dc53cc8a 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.cpp @@ -22,14 +22,14 @@ void EnOkarinaTag_Init(Actor* thisx, GlobalContext* globalCtx); void EnOkarinaTag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOkarinaTag_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80ABEF2C(EnOkarinaTag* this, GlobalContext* globalCtx); -void func_80ABF708(EnOkarinaTag* this, GlobalContext* globalCtx); -void func_80ABF28C(EnOkarinaTag* this, GlobalContext* globalCtx); -void func_80ABF0CC(EnOkarinaTag* this, GlobalContext* globalCtx); -void func_80ABF4C8(EnOkarinaTag* this, GlobalContext* globalCtx); -void func_80ABF7CC(EnOkarinaTag* this, GlobalContext* globalCtx); +void func_80ABEF2C(EnOkarinaTag* pthis, GlobalContext* globalCtx); +void func_80ABF708(EnOkarinaTag* pthis, GlobalContext* globalCtx); +void func_80ABF28C(EnOkarinaTag* pthis, GlobalContext* globalCtx); +void func_80ABF0CC(EnOkarinaTag* pthis, GlobalContext* globalCtx); +void func_80ABF4C8(EnOkarinaTag* pthis, GlobalContext* globalCtx); +void func_80ABF7CC(EnOkarinaTag* pthis, GlobalContext* globalCtx); -const ActorInit En_Okarina_Tag_InitVars = { +ActorInit En_Okarina_Tag_InitVars = { ACTOR_EN_OKARINA_TAG, ACTORCAT_PROP, FLAGS, @@ -48,112 +48,112 @@ void EnOkarinaTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnOkarinaTag_Init(Actor* thisx, GlobalContext* globalCtx) { - EnOkarinaTag* this = (EnOkarinaTag*)thisx; + EnOkarinaTag* pthis = (EnOkarinaTag*)thisx; osSyncPrintf("\n\n"); // "Ocarina tag outbreak" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ オカリナタグ発生 ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); - this->actor.flags &= ~ACTOR_FLAG_0; - this->type = (this->actor.params >> 0xA) & 0x3F; - this->ocarinaSong = (this->actor.params >> 6) & 0xF; - this->switchFlag = this->actor.params & 0x3F; - if (this->switchFlag == 0x3F) { - this->switchFlag = -1; + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ オカリナタグ発生 ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->type = (pthis->actor.params >> 0xA) & 0x3F; + pthis->ocarinaSong = (pthis->actor.params >> 6) & 0xF; + pthis->switchFlag = pthis->actor.params & 0x3F; + if (pthis->switchFlag == 0x3F) { + pthis->switchFlag = -1; } - if (this->ocarinaSong == 0xF) { - this->ocarinaSong = 0; - this->unk_158 = 1; + if (pthis->ocarinaSong == 0xF) { + pthis->ocarinaSong = 0; + pthis->unk_158 = 1; } - this->actor.targetMode = 1; - if (this->actor.world.rot.z > 0) { - this->interactRange = this->actor.world.rot.z * 40.0f; + pthis->actor.targetMode = 1; + if (pthis->actor.world.rot.z > 0) { + pthis->interactRange = pthis->actor.world.rot.z * 40.0f; } // "Save information" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セーブ情報\t ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ セーブ情報\t ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); // "Type index" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 種類インデックス ☆☆☆☆☆ %d\n" VT_RST, this->type); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 種類インデックス ☆☆☆☆☆ %d\n" VT_RST, pthis->type); // "Correct answer information" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 正解情報\t ☆☆☆☆☆ %d\n" VT_RST, this->ocarinaSong); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 正解情報\t ☆☆☆☆☆ %d\n" VT_RST, pthis->ocarinaSong); // "Range information" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 範囲情報\t ☆☆☆☆☆ %d\n" VT_RST, this->actor.world.rot.z); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 範囲情報\t ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.world.rot.z); // "Processing range information" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 処理範囲情報\t ☆☆☆☆☆ %f\n" VT_RST, this->interactRange); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 処理範囲情報\t ☆☆☆☆☆ %f\n" VT_RST, pthis->interactRange); // "Hit?" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 当り?\t\t ☆☆☆☆☆ %d\n" VT_RST, this->unk_158); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 当り?\t\t ☆☆☆☆☆ %d\n" VT_RST, pthis->unk_158); osSyncPrintf("\n\n"); - if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { - Actor_Kill(&this->actor); + if ((pthis->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, pthis->switchFlag))) { + Actor_Kill(&pthis->actor); } else { - switch (this->type) { + switch (pthis->type) { case 7: - this->actionFunc = func_80ABEF2C; + pthis->actionFunc = func_80ABEF2C; break; case 2: if (LINK_IS_ADULT) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; } case 1: case 4: case 6: - this->actionFunc = func_80ABF28C; + pthis->actionFunc = func_80ABF28C; break; case 5: - this->actor.textId = 0x5021; - this->actionFunc = func_80ABF708; + pthis->actor.textId = 0x5021; + pthis->actionFunc = func_80ABF708; break; default: - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); break; } } } -void func_80ABEF2C(EnOkarinaTag* this, GlobalContext* globalCtx) { +void func_80ABEF2C(EnOkarinaTag* pthis, GlobalContext* globalCtx) { Player* player; u16 ocarinaSong; player = GET_PLAYER(globalCtx); - this->unk_15A++; - if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_15A++; + if ((pthis->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, pthis->switchFlag))) { + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { - if ((this->ocarinaSong != 6) || (gSaveContext.scarecrowSpawnSongSet)) { + if ((pthis->ocarinaSong != 6) || (gSaveContext.scarecrowSpawnSongSet)) { if (player->stateFlags2 & 0x1000000) { // "North! ! ! ! !" - osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 北!!!!! ☆☆☆☆☆ %f\n" VT_RST, this->actor.xzDistToPlayer); + osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 北!!!!! ☆☆☆☆☆ %f\n" VT_RST, pthis->actor.xzDistToPlayer); } - if ((this->actor.xzDistToPlayer < (90.0f + this->interactRange)) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + if ((pthis->actor.xzDistToPlayer < (90.0f + pthis->interactRange)) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 80.0f)) { if (player->stateFlags2 & 0x2000000) { - ocarinaSong = this->ocarinaSong; + ocarinaSong = pthis->ocarinaSong; if (ocarinaSong == 6) { ocarinaSong = 0xA; } player->stateFlags2 |= 0x800000; func_8010BD58(globalCtx, ocarinaSong + OCARINA_ACTION_CHECK_SARIA); - this->actionFunc = func_80ABF0CC; - } else if ((this->actor.xzDistToPlayer < (50.0f + this->interactRange) && - ((fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 40.0f)))) { - this->unk_15A = 0; - player->unk_6A8 = &this->actor; + pthis->actionFunc = func_80ABF0CC; + } else if ((pthis->actor.xzDistToPlayer < (50.0f + pthis->interactRange) && + ((fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 40.0f)))) { + pthis->unk_15A = 0; + player->unk_6A8 = &pthis->actor; } } } } } -void func_80ABF0CC(EnOkarinaTag* this, GlobalContext* globalCtx) { +void func_80ABF0CC(EnOkarinaTag* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - this->actionFunc = func_80ABEF2C; + pthis->actionFunc = func_80ABEF2C; } else { if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); } if (globalCtx->sceneNum == SCENE_MIZUSIN) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; @@ -162,10 +162,10 @@ void func_80ABF0CC(EnOkarinaTag* this, GlobalContext* globalCtx) { globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } func_80078884(NA_SE_SY_CORRECT_CHIME); - this->actionFunc = func_80ABEF2C; + pthis->actionFunc = func_80ABEF2C; return; } - if (this->unk_158 != 0) { + if (pthis->unk_158 != 0) { if ((globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_05) || (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_06) || (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_07) || @@ -173,37 +173,37 @@ void func_80ABF0CC(EnOkarinaTag* this, GlobalContext* globalCtx) { (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_09) || (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0A) || (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0D)) { - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); } globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; func_80078884(NA_SE_SY_CORRECT_CHIME); - this->actionFunc = func_80ABEF2C; + pthis->actionFunc = func_80ABEF2C; return; } } if ((globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05) && (globalCtx->msgCtx.ocarinaMode < OCARINA_MODE_0E)) { globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - this->actionFunc = func_80ABEF2C; + pthis->actionFunc = func_80ABEF2C; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { player->stateFlags2 |= 0x800000; } } } -void func_80ABF28C(EnOkarinaTag* this, GlobalContext* globalCtx) { +void func_80ABF28C(EnOkarinaTag* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk_15A++; - if ((this->ocarinaSong != 6) || (gSaveContext.scarecrowSpawnSongSet)) { - if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - this->actor.flags &= ~ACTOR_FLAG_0; - } else if (((this->type != 4) || !(gSaveContext.eventChkInf[4] & 0x800)) && - ((this->type != 6) || !(gSaveContext.eventChkInf[1] & 0x2000)) && - (this->actor.xzDistToPlayer < (90.0f + this->interactRange)) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + pthis->unk_15A++; + if ((pthis->ocarinaSong != 6) || (gSaveContext.scarecrowSpawnSongSet)) { + if ((pthis->switchFlag >= 0) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else if (((pthis->type != 4) || !(gSaveContext.eventChkInf[4] & 0x800)) && + ((pthis->type != 6) || !(gSaveContext.eventChkInf[1] & 0x2000)) && + (pthis->actor.xzDistToPlayer < (90.0f + pthis->interactRange)) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 80.0f)) { if (player->stateFlags2 & 0x1000000) { - switch (this->type) { + switch (pthis->type) { case 1: func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_LULLABY); break; @@ -219,34 +219,34 @@ void func_80ABF28C(EnOkarinaTag* this, GlobalContext* globalCtx) { default: // "Ocarina Invisible-kun demo start check error source" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ オカリナ透明君デモ開始チェックエラー原 ☆☆☆☆☆ %d\n" VT_RST, - this->type); - Actor_Kill(&this->actor); + pthis->type); + Actor_Kill(&pthis->actor); break; } player->stateFlags2 |= 0x800000; - this->actionFunc = func_80ABF4C8; - } else if ((this->actor.xzDistToPlayer < (50.0f + this->interactRange)) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 40.0f)) { - this->unk_15A = 0; + pthis->actionFunc = func_80ABF4C8; + } else if ((pthis->actor.xzDistToPlayer < (50.0f + pthis->interactRange)) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 40.0f)) { + pthis->unk_15A = 0; player->stateFlags2 |= 0x800000; } } } } -void func_80ABF4C8(EnOkarinaTag* this, GlobalContext* globalCtx) { +void func_80ABF4C8(EnOkarinaTag* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - this->actionFunc = func_80ABF28C; + pthis->actionFunc = func_80ABF28C; } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { func_80078884(NA_SE_SY_CORRECT_CHIME); - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); } - switch (this->type) { + switch (pthis->type) { case 1: - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, pthis->switchFlag); gSaveContext.eventChkInf[3] |= 0x200; break; case 2: @@ -269,12 +269,12 @@ void func_80ABF4C8(EnOkarinaTag* this, GlobalContext* globalCtx) { break; } globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - this->actionFunc = func_80ABF28C; + pthis->actionFunc = func_80ABF28C; } else { if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05) { if (globalCtx->msgCtx.ocarinaMode < OCARINA_MODE_0E) { globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - this->actionFunc = func_80ABF28C; + pthis->actionFunc = func_80ABF28C; return; } } @@ -284,29 +284,29 @@ void func_80ABF4C8(EnOkarinaTag* this, GlobalContext* globalCtx) { } } -void func_80ABF708(EnOkarinaTag* this, GlobalContext* globalCtx) { +void func_80ABF708(EnOkarinaTag* pthis, GlobalContext* globalCtx) { s16 yawDiff; s16 yawDiffNew; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_80ABF7CC; + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80ABF7CC; } else { - yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - this->unk_15A++; - if (!(this->actor.xzDistToPlayer > 120.0f)) { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y; + pthis->unk_15A++; + if (!(pthis->actor.xzDistToPlayer > 120.0f)) { if (CHECK_QUEST_ITEM(QUEST_SONG_SUN)) { - this->actor.textId = 0x5021; + pthis->actor.textId = 0x5021; } yawDiffNew = ABS(yawDiff); if (yawDiffNew < 0x4300) { - this->unk_15A = 0; - func_8002F2CC(&this->actor, globalCtx, 70.0f); + pthis->unk_15A = 0; + func_8002F2CC(&pthis->actor, globalCtx, 70.0f); } } } } -void func_80ABF7CC(EnOkarinaTag* this, GlobalContext* globalCtx) { +void func_80ABF7CC(EnOkarinaTag* pthis, GlobalContext* globalCtx) { // "Open sesame sesame!" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 開けゴマゴマゴマ! ☆☆☆☆☆ %d\n" VT_RST, Message_GetState(&globalCtx->msgCtx)); @@ -316,12 +316,12 @@ void func_80ABF7CC(EnOkarinaTag* this, GlobalContext* globalCtx) { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(&gSunSongGraveSunSongTeachCs); gSaveContext.cutsceneTrigger = 1; } - this->actionFunc = func_80ABF708; + pthis->actionFunc = func_80ABF708; } } void EnOkarinaTag_Update(Actor* thisx, GlobalContext* globalCtx) { - EnOkarinaTag* this = (EnOkarinaTag*)thisx; + EnOkarinaTag* pthis = (EnOkarinaTag*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag_cutscene_data.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag_cutscene_data.c rename to src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c deleted file mode 100644 index 0aedbf30d..000000000 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ /dev/null @@ -1,737 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_OKUTA_Z_EN_OKUTA_C -#include "actor_common.h" -#include "z_en_okuta.h" -#include "objects/object_okuta/object_okuta.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnOkuta_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOkuta_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnOkuta_SetupWaitToAppear(EnOkuta* this); -void EnOkuta_WaitToAppear(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_Appear(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_Hide(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_WaitToShoot(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_Shoot(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_WaitToDie(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_Die(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_Freeze(EnOkuta* this, GlobalContext* globalCtx); -void EnOkuta_ProjectileFly(EnOkuta* this, GlobalContext* globalCtx); - -const ActorInit En_Okuta_InitVars = { - ACTOR_EN_OKUTA, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_OKUTA, - sizeof(EnOkuta), - (ActorFunc)EnOkuta_Init, - (ActorFunc)EnOkuta_Destroy, - (ActorFunc)EnOkuta_Update, - (ActorFunc)EnOkuta_Draw, -}; - -static ColliderCylinderInit sProjectileColliderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 13, 20, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sOctorockColliderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 40, -30, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 60, 100 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(4, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x42, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), -}; - -void EnOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { - EnOkuta* this = (EnOkuta*)thisx; - s32 pad; - WaterBox* outWaterBox; - f32 ySurface; - s32 sp30; - - Actor_ProcessInitChain(thisx, sInitChain); - this->numShots = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - if (thisx->params == 0) { - SkelAnime_Init(globalCtx, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, - this->morphTable, 38); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sOctorockColliderInit); - CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); - if ((this->numShots == 0xFF) || (this->numShots == 0)) { - this->numShots = 1; - } - thisx->floorHeight = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &thisx->floorPoly, &sp30, thisx, &thisx->world.pos); - //! @bug calls WaterBox_GetSurfaceImpl directly - if (!WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, thisx->world.pos.x, thisx->world.pos.z, &ySurface, - &outWaterBox) || - (ySurface <= thisx->floorHeight)) { - Actor_Kill(thisx); - } else { - thisx->home.pos.y = ySurface; - } - EnOkuta_SetupWaitToAppear(this); - } else { - ActorShape_Init(&thisx->shape, 1100.0f, ActorShadow_DrawCircle, 18.0f); - thisx->flags &= ~ACTOR_FLAG_0; - thisx->flags |= ACTOR_FLAG_4; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sProjectileColliderInit); - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); - this->timer = 30; - thisx->shape.rot.y = 0; - this->actionFunc = EnOkuta_ProjectileFly; - thisx->speedXZ = 10.0f; - } -} - -void EnOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnOkuta* this = (EnOkuta*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnOkuta_SpawnBubbles(EnOkuta* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < 10; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -10.0f, 10.0f, 30.0f, 0.25f); - } -} - -void EnOkuta_SpawnDust(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { - static Vec3f accel = { 0.0f, 0.0f, 0.0f }; - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 150, 150, 150, 255 }; - - func_8002829C(globalCtx, pos, velocity, &accel, &primColor, &envColor, 0x190, scaleStep); -} - -void EnOkuta_SpawnSplash(EnOkuta* this, GlobalContext* globalCtx) { - EffectSsGSplash_Spawn(globalCtx, &this->actor.home.pos, NULL, NULL, 0, 1300); -} - -void EnOkuta_SpawnRipple(EnOkuta* this, GlobalContext* globalCtx) { - Vec3f pos; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.home.pos.y; - pos.z = this->actor.world.pos.z; - if ((globalCtx->gameplayFrames % 7) == 0 && - ((this->actionFunc != EnOkuta_Shoot) || ((this->actor.world.pos.y - this->actor.home.pos.y) < 50.0f))) { - EffectSsGRipple_Spawn(globalCtx, &pos, 250, 650, 0); - } -} - -void EnOkuta_SetupWaitToAppear(EnOkuta* this) { - this->actor.draw = NULL; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnOkuta_WaitToAppear; - this->actor.world.pos.y = this->actor.home.pos.y; -} - -void EnOkuta_SetupAppear(EnOkuta* this, GlobalContext* globalCtx) { - this->actor.draw = EnOkuta_Draw; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.flags |= ACTOR_FLAG_0; - Animation_PlayOnce(&this->skelAnime, &gOctorokAppearAnim); - EnOkuta_SpawnBubbles(this, globalCtx); - this->actionFunc = EnOkuta_Appear; -} - -void EnOkuta_SetupHide(EnOkuta* this) { - Animation_PlayOnce(&this->skelAnime, &gOctorokHideAnim); - this->actionFunc = EnOkuta_Hide; -} - -void EnOkuta_SetupWaitToShoot(EnOkuta* this) { - Animation_PlayLoop(&this->skelAnime, &gOctorokFloatAnim); - this->timer = (this->actionFunc == EnOkuta_Shoot) ? 2 : 0; - this->actionFunc = EnOkuta_WaitToShoot; -} - -void EnOkuta_SetupShoot(EnOkuta* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gOctorokShootAnim); - if (this->actionFunc != EnOkuta_Shoot) { - this->timer = this->numShots; - } - this->jumpHeight = this->actor.yDistToPlayer + 20.0f; - this->jumpHeight = CLAMP_MIN(this->jumpHeight, 10.0f); - if (this->jumpHeight > 50.0f) { - EnOkuta_SpawnSplash(this, globalCtx); - } - if (this->jumpHeight > 50.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_JUMP); - } - this->actionFunc = EnOkuta_Shoot; -} - -void EnOkuta_SetupWaitToDie(EnOkuta* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gOctorokHitAnim, -5.0f); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0xB); - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetScale(&this->actor, 0.01f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); - this->actionFunc = EnOkuta_WaitToDie; -} - -void EnOkuta_SetupDie(EnOkuta* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gOctorokDieAnim, -3.0f); - this->timer = 0; - this->actionFunc = EnOkuta_Die; -} - -void EnOkuta_SetupFreeze(EnOkuta* this) { - this->timer = 80; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); - this->actionFunc = EnOkuta_Freeze; -} - -void EnOkuta_SpawnProjectile(EnOkuta* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f velocity; - f32 sin = Math_SinS(this->actor.shape.rot.y); - f32 cos = Math_CosS(this->actor.shape.rot.y); - - pos.x = this->actor.world.pos.x + (25.0f * sin); - pos.y = this->actor.world.pos.y - 6.0f; - pos.z = this->actor.world.pos.z + (25.0f * cos); - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OKUTA, pos.x, pos.y, pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, this->actor.shape.rot.z, 0x10) != NULL) { - pos.x = this->actor.world.pos.x + (40.0f * sin); - pos.z = this->actor.world.pos.z + (40.0f * cos); - pos.y = this->actor.world.pos.y; - velocity.x = 1.5f * sin; - velocity.y = 0.0f; - velocity.z = 1.5f * cos; - EnOkuta_SpawnDust(&pos, &velocity, 20, globalCtx); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); -} - -void EnOkuta_WaitToAppear(EnOkuta* this, GlobalContext* globalCtx) { - this->actor.world.pos.y = this->actor.home.pos.y; - if ((this->actor.xzDistToPlayer < 480.0f) && (this->actor.xzDistToPlayer > 200.0f)) { - EnOkuta_SetupAppear(this, globalCtx); - } -} - -void EnOkuta_Appear(EnOkuta* this, GlobalContext* globalCtx) { - s32 pad; - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.xzDistToPlayer < 160.0f) { - EnOkuta_SetupHide(this); - } else { - EnOkuta_SetupWaitToShoot(this); - } - } else if (this->skelAnime.curFrame <= 4.0f) { - Actor_SetScale(&this->actor, this->skelAnime.curFrame * 0.25f * 0.01f); - } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_SetScale(&this->actor, 0.01f); - } - if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_JUMP); - } - if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_LAND); - } - if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - EnOkuta_SpawnSplash(this, globalCtx); - } -} - -void EnOkuta_Hide(EnOkuta* this, GlobalContext* globalCtx) { - s32 pad; - - Math_ApproachF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f, 30.0f); - if (SkelAnime_Update(&this->skelAnime)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_BUBLE); - EnOkuta_SpawnBubbles(this, globalCtx); - EnOkuta_SetupWaitToAppear(this); - } else if (this->skelAnime.curFrame >= 4.0f) { - Actor_SetScale(&this->actor, (6.0f - this->skelAnime.curFrame) * 0.5f * 0.01f); - } - if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_SINK); - } - if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - EnOkuta_SpawnSplash(this, globalCtx); - } -} - -void EnOkuta_WaitToShoot(EnOkuta* this, GlobalContext* globalCtx) { - s16 temp_v0_2; - s32 phi_v1; - - this->actor.world.pos.y = this->actor.home.pos.y; - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->timer != 0) { - this->timer--; - } - } - if (Animation_OnFrame(&this->skelAnime, 0.5f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_FLOAT); - } - if (this->actor.xzDistToPlayer < 160.0f || this->actor.xzDistToPlayer > 560.0f) { - EnOkuta_SetupHide(this); - } else { - temp_v0_2 = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C, 0x38E); - phi_v1 = ABS(temp_v0_2); - if ((phi_v1 < 0x38E) && (this->timer == 0) && (this->actor.yDistToPlayer < 200.0f)) { - EnOkuta_SetupShoot(this, globalCtx); - } - } -} - -void EnOkuta_Shoot(EnOkuta* this, GlobalContext* globalCtx) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - EnOkuta_SetupWaitToShoot(this); - } else { - EnOkuta_SetupShoot(this, globalCtx); - } - } else { - f32 curFrame = this->skelAnime.curFrame; - - if (curFrame < 13.0f) { - this->actor.world.pos.y = (sinf((0.08333f * M_PI) * curFrame) * this->jumpHeight) + this->actor.home.pos.y; - } - if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - EnOkuta_SpawnProjectile(this, globalCtx); - } - if ((this->jumpHeight > 50.0f) && Animation_OnFrame(&this->skelAnime, 13.0f)) { - EnOkuta_SpawnSplash(this, globalCtx); - } - if ((this->jumpHeight > 50.0f) && Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_LAND); - } - } - if (this->actor.xzDistToPlayer < 160.0f) { - EnOkuta_SetupHide(this); - } -} - -void EnOkuta_WaitToDie(EnOkuta* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnOkuta_SetupDie(this); - } - Math_ApproachF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f, 5.0f); -} - -void EnOkuta_Die(EnOkuta* this, GlobalContext* globalCtx) { - static Vec3f accel = { 0.0f, -0.5f, 0.0f }; - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 150, 150, 150, 0 }; - Vec3f velocity; - Vec3f pos; - s32 i; - - if (SkelAnime_Update(&this->skelAnime)) { - this->timer++; - } - Math_ApproachF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f, 5.0f); - if (this->timer == 5) { - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 40.0f; - pos.z = this->actor.world.pos.z; - velocity.x = 0.0f; - velocity.y = -0.5f; - velocity.z = 0.0f; - EnOkuta_SpawnDust(&pos, &velocity, -0x14, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); - } - if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - EnOkuta_SpawnSplash(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_LAND); - } - if (this->timer < 3) { - Actor_SetScale(&this->actor, ((this->timer * 0.25f) + 1.0f) * 0.01f); - } else if (this->timer < 6) { - Actor_SetScale(&this->actor, (1.5f - ((this->timer - 2) * 0.2333f)) * 0.01f); - } else if (this->timer < 11) { - Actor_SetScale(&this->actor, (((this->timer - 5) * 0.04f) + 0.8f) * 0.01f); - } else { - if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0005f)) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_OCTAROCK_BUBLE); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); - for (i = 0; i < 20; i++) { - velocity.x = (Rand_ZeroOne() - 0.5f) * 7.0f; - velocity.y = Rand_ZeroOne() * 7.0f; - velocity.z = (Rand_ZeroOne() - 0.5f) * 7.0f; - EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->actor.world.pos, &velocity, &accel, &primColor, - &envColor, Rand_S16Offset(100, 50), 25, 0); - } - Actor_Kill(&this->actor); - } - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; - } -} - -void EnOkuta_Freeze(EnOkuta* this, GlobalContext* globalCtx) { - Vec3f pos; - s16 temp_v1; - - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - EnOkuta_SetupDie(this); - } - if ((this->timer >= 64) && (this->timer & 1)) { - temp_v1 = (this->timer - 64) >> 1; - pos.y = (this->actor.world.pos.y - 32.0f) + (8.0f * (8 - temp_v1)); - pos.x = this->actor.world.pos.x + ((temp_v1 & 2) ? 10.0f : -10.0f); - pos.z = this->actor.world.pos.z + ((temp_v1 & 1) ? 10.0f : -10.0f); - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &pos, 150, 150, 150, 250, 235, 245, 255, - (Rand_ZeroOne() * 0.2f) + 1.9f); - } - Math_ApproachF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f, 5.0f); -} - -void EnOkuta_ProjectileFly(EnOkuta* this, GlobalContext* globalCtx) { - Vec3f pos; - Player* player = GET_PLAYER(globalCtx); - Vec3s sp40; - - this->timer--; - if (this->timer == 0) { - this->actor.gravity = -1.0f; - } - this->actor.home.rot.z += 0x1554; - if (this->actor.bgCheckFlags & 0x20) { - this->actor.gravity = -1.0f; - this->actor.speedXZ -= 0.1f; - this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 1.0f); - } - if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->collider.base.atFlags & AT_HIT) || - this->collider.base.acFlags & AC_HIT || this->collider.base.ocFlags1 & OC1_HIT || - this->actor.floorHeight == BGCHECK_Y_MIN) { - if ((player->currentShield == PLAYER_SHIELD_DEKU || - (player->currentShield == PLAYER_SHIELD_HYLIAN && LINK_IS_ADULT)) && - this->collider.base.atFlags & AT_HIT && this->collider.base.atFlags & AT_TYPE_ENEMY && - this->collider.base.atFlags & AT_BOUNCED) { - this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED | AT_TYPE_ENEMY); - this->collider.base.atFlags |= AT_TYPE_PLAYER; - this->collider.info.toucher.dmgFlags = 2; - Matrix_MtxFToYXZRotS(&player->shieldMf, &sp40, 0); - this->actor.world.rot.y = sp40.y + 0x8000; - this->timer = 30; - } else { - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 11.0f; - pos.z = this->actor.world.pos.z; - EffectSsHahen_SpawnBurst(globalCtx, &pos, 6.0f, 0, 1, 2, 15, 7, 10, gOctorokProjectileDL); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); - Actor_Kill(&this->actor); - } - } else if (this->timer == -300) { - Actor_Kill(&this->actor); - } -} - -void EnOkuta_UpdateHeadScale(EnOkuta* this) { - f32 curFrame = this->skelAnime.curFrame; - - if (this->actionFunc == EnOkuta_Appear) { - if (curFrame < 8.0f) { - this->headScale.x = this->headScale.y = this->headScale.z = 1.0f; - } else if (curFrame < 10.0f) { - this->headScale.x = this->headScale.z = 1.0f; - this->headScale.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; - } else if (curFrame < 14.0f) { - this->headScale.x = this->headScale.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; - this->headScale.y = 1.8f - ((curFrame - 9.0f) * 0.25f); - } else { - this->headScale.x = this->headScale.z = 1.3f - ((curFrame - 13.0f) * 0.05f); - this->headScale.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; - } - } else if (this->actionFunc == EnOkuta_Hide) { - if (curFrame < 3.0f) { - this->headScale.y = 1.0f; - } else if (curFrame < 4.0f) { - this->headScale.y = (curFrame - 2.0f) + 1.0f; - } else { - this->headScale.y = 2.0f - ((curFrame - 3.0f) * 0.333f); - } - this->headScale.x = this->headScale.z = 1.0f; - } else if (this->actionFunc == EnOkuta_Shoot) { - if (curFrame < 5.0f) { - this->headScale.x = this->headScale.y = this->headScale.z = (curFrame * 0.125f) + 1.0f; - } else if (curFrame < 7.0f) { - this->headScale.x = this->headScale.y = this->headScale.z = 1.5f - ((curFrame - 4.0f) * 0.35f); - } else if (curFrame < 17.0f) { - this->headScale.x = this->headScale.z = ((curFrame - 6.0f) * 0.05f) + 0.8f; - this->headScale.y = 0.8f; - } else { - this->headScale.x = this->headScale.z = 1.3f - ((curFrame - 16.0f) * 0.1f); - this->headScale.y = ((curFrame - 16.0f) * 0.0666f) + 0.8f; - } - } else if (this->actionFunc == EnOkuta_WaitToShoot) { - this->headScale.x = this->headScale.z = 1.0f; - this->headScale.y = (sinf((M_PI / 16) * curFrame) * 0.2f) + 1.0f; - } else { - this->headScale.x = this->headScale.y = this->headScale.z = 1.0f; - } -} - -void EnOkuta_ColliderCheck(EnOkuta* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.colChkInfo.health = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->actor.colChkInfo.damageEffect == 3) { - EnOkuta_SetupFreeze(this); - } else { - EnOkuta_SetupWaitToDie(this); - } - } - } -} - -void EnOkuta_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnOkuta* this = (EnOkuta*)thisx; - GlobalContext* globalCtx = globalCtx2; - Player* player = GET_PLAYER(globalCtx); - WaterBox* outWaterBox; - f32 ySurface; - Vec3f sp38; - s32 sp34; - - if (!(player->stateFlags1 & 0x300000C0)) { - if (this->actor.params == 0) { - EnOkuta_ColliderCheck(this, globalCtx); - if (!WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, - this->actor.world.pos.z, &ySurface, &outWaterBox) || - (ySurface < this->actor.floorHeight)) { - if (this->actor.colChkInfo.health != 0) { - Actor_Kill(&this->actor); - return; - } - } else { - this->actor.home.pos.y = ySurface; - } - } - this->actionFunc(this, globalCtx); - if (this->actor.params == 0) { - EnOkuta_UpdateHeadScale(this); - this->collider.dim.height = - (((sOctorockColliderInit.dim.height * this->headScale.y) - this->collider.dim.yShift) * - this->actor.scale.y * 100.0f); - } else { - sp34 = false; - Actor_MoveForward(&this->actor); - Math_Vec3f_Copy(&sp38, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 30.0f, 5); - if ((this->actor.bgCheckFlags & 8) && - SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { - sp34 = true; - this->actor.bgCheckFlags &= ~8; - } - if ((this->actor.bgCheckFlags & 1) && - SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { - sp34 = true; - this->actor.bgCheckFlags &= ~1; - } - if (sp34 && !(this->actor.bgCheckFlags & 9)) { - Math_Vec3f_Copy(&this->actor.world.pos, &sp38); - } - } - Collider_UpdateCylinder(&this->actor, &this->collider); - if ((this->actionFunc == EnOkuta_Appear) || (this->actionFunc == EnOkuta_Hide)) { - this->collider.dim.pos.y = this->actor.world.pos.y + (this->skelAnime.jointTable->y * this->actor.scale.y); - this->collider.dim.radius = sOctorockColliderInit.dim.radius * this->actor.scale.x * 100.0f; - } - if (this->actor.params == 0x10) { - this->actor.flags |= ACTOR_FLAG_24; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->actionFunc != EnOkuta_WaitToAppear) { - if ((this->actionFunc != EnOkuta_Die) && (this->actionFunc != EnOkuta_WaitToDie) && - (this->actionFunc != EnOkuta_Freeze)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - Actor_SetFocus(&this->actor, 15.0f); - if ((this->actor.params == 0) && (this->actor.draw != NULL)) { - EnOkuta_SpawnRipple(this, globalCtx); - } - } -} - -s32 EnOkuta_GetSnoutScale(EnOkuta* this, f32 curFrame, Vec3f* scale) { - if (this->actionFunc == EnOkuta_WaitToShoot) { - scale->x = scale->z = 1.0f; - scale->y = (sinf((M_PI / 16) * curFrame) * 0.4f) + 1.0f; - } else if (this->actionFunc == EnOkuta_Shoot) { - if (curFrame < 5.0f) { - scale->x = 1.0f; - scale->y = scale->z = (curFrame * 0.25f) + 1.0f; - } else if (curFrame < 7.0f) { - scale->x = (curFrame - 4.0f) * 0.5f + 1.0f; - scale->y = scale->z = 2.0f - (curFrame - 4.0f) * 0.5f; - } else { - scale->x = 2.0f - ((curFrame - 6.0f) * 0.0769f); - scale->y = scale->z = 1.0f; - } - } else if (this->actionFunc == EnOkuta_Die) { - if (curFrame >= 35.0f || curFrame < 25.0f) { - return false; - } - if (curFrame < 27.0f) { - scale->x = 1.0f; - scale->y = scale->z = ((curFrame - 24.0f) * 0.5f) + 1.0f; - } else if (curFrame < 30.0f) { - scale->x = (curFrame - 26.0f) * 0.333f + 1.0f; - scale->y = scale->z = 2.0f - (curFrame - 26.0f) * 0.333f; - } else { - scale->x = 2.0f - ((curFrame - 29.0f) * 0.2f); - scale->y = scale->z = 1.0f; - } - } else { - return false; - } - - return true; -} - -s32 EnOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnOkuta* this = (EnOkuta*)thisx; - f32 curFrame = this->skelAnime.curFrame; - Vec3f scale; - s32 doScale = false; - - if (this->actionFunc == EnOkuta_Die) { - curFrame += this->timer; - } - if (limbIndex == 5) { - if ((this->headScale.x != 1.0f) || (this->headScale.y != 1.0f) || (this->headScale.z != 1.0f)) { - scale = this->headScale; - doScale = true; - } - } else if (limbIndex == 8) { - doScale = EnOkuta_GetSnoutScale(this, curFrame, &scale); - } - if (doScale) { - Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); - } - return false; -} - -void EnOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnOkuta* this = (EnOkuta*)thisx; - s32 pad; - - func_80093D18(globalCtx->state.gfxCtx); - - if (this->actor.params == 0) { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnOkuta_OverrideLimbDraw, - NULL, this); - } else { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_okuta.c", 1653); - - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(this->actor.home.rot.z * (M_PI / 0x8000), MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_okuta.c", 1657), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gOctorokProjectileDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_okuta.c", 1662); - } -} diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.cpp b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.cpp new file mode 100644 index 000000000..9c83bfe06 --- /dev/null +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.cpp @@ -0,0 +1,737 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_OKUTA_Z_EN_OKUTA_C +#include "actor_common.h" +#include "z_en_okuta.h" +#include "objects/object_okuta/object_okuta.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnOkuta_Init(Actor* thisx, GlobalContext* globalCtx); +void EnOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnOkuta_Update(Actor* thisx, GlobalContext* globalCtx); +void EnOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnOkuta_SetupWaitToAppear(EnOkuta* pthis); +void EnOkuta_WaitToAppear(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_Appear(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_Hide(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_WaitToShoot(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_Shoot(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_WaitToDie(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_Die(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_Freeze(EnOkuta* pthis, GlobalContext* globalCtx); +void EnOkuta_ProjectileFly(EnOkuta* pthis, GlobalContext* globalCtx); + +ActorInit En_Okuta_InitVars = { + ACTOR_EN_OKUTA, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_OKUTA, + sizeof(EnOkuta), + (ActorFunc)EnOkuta_Init, + (ActorFunc)EnOkuta_Destroy, + (ActorFunc)EnOkuta_Update, + (ActorFunc)EnOkuta_Draw, +}; + +static ColliderCylinderInit sProjectileColliderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 13, 20, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sOctorockColliderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 40, -30, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 60, 100 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(1, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(4, 0x3), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x42, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), +}; + +void EnOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { + EnOkuta* pthis = (EnOkuta*)thisx; + s32 pad; + WaterBox* outWaterBox; + f32 ySurface; + s32 sp30; + + Actor_ProcessInitChain(thisx, sInitChain); + pthis->numShots = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + if (thisx->params == 0) { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, pthis->jointTable, + pthis->morphTable, 38); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sOctorockColliderInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + if ((pthis->numShots == 0xFF) || (pthis->numShots == 0)) { + pthis->numShots = 1; + } + thisx->floorHeight = + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &thisx->floorPoly, &sp30, thisx, &thisx->world.pos); + //! @bug calls WaterBox_GetSurfaceImpl directly + if (!WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, thisx->world.pos.x, thisx->world.pos.z, &ySurface, + &outWaterBox) || + (ySurface <= thisx->floorHeight)) { + Actor_Kill(thisx); + } else { + thisx->home.pos.y = ySurface; + } + EnOkuta_SetupWaitToAppear(pthis); + } else { + ActorShape_Init(&thisx->shape, 1100.0f, ActorShadow_DrawCircle, 18.0f); + thisx->flags &= ~ACTOR_FLAG_0; + thisx->flags |= ACTOR_FLAG_4; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sProjectileColliderInit); + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); + pthis->timer = 30; + thisx->shape.rot.y = 0; + pthis->actionFunc = EnOkuta_ProjectileFly; + thisx->speedXZ = 10.0f; + } +} + +void EnOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOkuta* pthis = (EnOkuta*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnOkuta_SpawnBubbles(EnOkuta* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < 10; i++) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, -10.0f, 10.0f, 30.0f, 0.25f); + } +} + +void EnOkuta_SpawnDust(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { + static Vec3f accel = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 150, 150, 150, 255 }; + + func_8002829C(globalCtx, pos, velocity, &accel, &primColor, &envColor, 0x190, scaleStep); +} + +void EnOkuta_SpawnSplash(EnOkuta* pthis, GlobalContext* globalCtx) { + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.home.pos, NULL, NULL, 0, 1300); +} + +void EnOkuta_SpawnRipple(EnOkuta* pthis, GlobalContext* globalCtx) { + Vec3f pos; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.home.pos.y; + pos.z = pthis->actor.world.pos.z; + if ((globalCtx->gameplayFrames % 7) == 0 && + ((pthis->actionFunc != EnOkuta_Shoot) || ((pthis->actor.world.pos.y - pthis->actor.home.pos.y) < 50.0f))) { + EffectSsGRipple_Spawn(globalCtx, &pos, 250, 650, 0); + } +} + +void EnOkuta_SetupWaitToAppear(EnOkuta* pthis) { + pthis->actor.draw = NULL; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnOkuta_WaitToAppear; + pthis->actor.world.pos.y = pthis->actor.home.pos.y; +} + +void EnOkuta_SetupAppear(EnOkuta* pthis, GlobalContext* globalCtx) { + pthis->actor.draw = EnOkuta_Draw; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.flags |= ACTOR_FLAG_0; + Animation_PlayOnce(&pthis->skelAnime, &gOctorokAppearAnim); + EnOkuta_SpawnBubbles(pthis, globalCtx); + pthis->actionFunc = EnOkuta_Appear; +} + +void EnOkuta_SetupHide(EnOkuta* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gOctorokHideAnim); + pthis->actionFunc = EnOkuta_Hide; +} + +void EnOkuta_SetupWaitToShoot(EnOkuta* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gOctorokFloatAnim); + pthis->timer = (pthis->actionFunc == EnOkuta_Shoot) ? 2 : 0; + pthis->actionFunc = EnOkuta_WaitToShoot; +} + +void EnOkuta_SetupShoot(EnOkuta* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gOctorokShootAnim); + if (pthis->actionFunc != EnOkuta_Shoot) { + pthis->timer = pthis->numShots; + } + pthis->jumpHeight = pthis->actor.yDistToPlayer + 20.0f; + pthis->jumpHeight = CLAMP_MIN(pthis->jumpHeight, 10.0f); + if (pthis->jumpHeight > 50.0f) { + EnOkuta_SpawnSplash(pthis, globalCtx); + } + if (pthis->jumpHeight > 50.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_JUMP); + } + pthis->actionFunc = EnOkuta_Shoot; +} + +void EnOkuta_SetupWaitToDie(EnOkuta* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gOctorokHitAnim, -5.0f); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0xB); + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetScale(&pthis->actor, 0.01f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_DEAD1); + pthis->actionFunc = EnOkuta_WaitToDie; +} + +void EnOkuta_SetupDie(EnOkuta* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gOctorokDieAnim, -3.0f); + pthis->timer = 0; + pthis->actionFunc = EnOkuta_Die; +} + +void EnOkuta_SetupFreeze(EnOkuta* pthis) { + pthis->timer = 80; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); + pthis->actionFunc = EnOkuta_Freeze; +} + +void EnOkuta_SpawnProjectile(EnOkuta* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f velocity; + f32 sin = Math_SinS(pthis->actor.shape.rot.y); + f32 cos = Math_CosS(pthis->actor.shape.rot.y); + + pos.x = pthis->actor.world.pos.x + (25.0f * sin); + pos.y = pthis->actor.world.pos.y - 6.0f; + pos.z = pthis->actor.world.pos.z + (25.0f * cos); + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OKUTA, pos.x, pos.y, pos.z, pthis->actor.shape.rot.x, + pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 0x10) != NULL) { + pos.x = pthis->actor.world.pos.x + (40.0f * sin); + pos.z = pthis->actor.world.pos.z + (40.0f * cos); + pos.y = pthis->actor.world.pos.y; + velocity.x = 1.5f * sin; + velocity.y = 0.0f; + velocity.z = 1.5f * cos; + EnOkuta_SpawnDust(&pos, &velocity, 20, globalCtx); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_THROW); +} + +void EnOkuta_WaitToAppear(EnOkuta* pthis, GlobalContext* globalCtx) { + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + if ((pthis->actor.xzDistToPlayer < 480.0f) && (pthis->actor.xzDistToPlayer > 200.0f)) { + EnOkuta_SetupAppear(pthis, globalCtx); + } +} + +void EnOkuta_Appear(EnOkuta* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.xzDistToPlayer < 160.0f) { + EnOkuta_SetupHide(pthis); + } else { + EnOkuta_SetupWaitToShoot(pthis); + } + } else if (pthis->skelAnime.curFrame <= 4.0f) { + Actor_SetScale(&pthis->actor, pthis->skelAnime.curFrame * 0.25f * 0.01f); + } else if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + Actor_SetScale(&pthis->actor, 0.01f); + } + if (Animation_OnFrame(&pthis->skelAnime, 2.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_JUMP); + } + if (Animation_OnFrame(&pthis->skelAnime, 12.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_LAND); + } + if (Animation_OnFrame(&pthis->skelAnime, 3.0f) || Animation_OnFrame(&pthis->skelAnime, 15.0f)) { + EnOkuta_SpawnSplash(pthis, globalCtx); + } +} + +void EnOkuta_Hide(EnOkuta* pthis, GlobalContext* globalCtx) { + s32 pad; + + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f, 30.0f); + if (SkelAnime_Update(&pthis->skelAnime)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_BUBLE); + EnOkuta_SpawnBubbles(pthis, globalCtx); + EnOkuta_SetupWaitToAppear(pthis); + } else if (pthis->skelAnime.curFrame >= 4.0f) { + Actor_SetScale(&pthis->actor, (6.0f - pthis->skelAnime.curFrame) * 0.5f * 0.01f); + } + if (Animation_OnFrame(&pthis->skelAnime, 2.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_SINK); + } + if (Animation_OnFrame(&pthis->skelAnime, 4.0f)) { + EnOkuta_SpawnSplash(pthis, globalCtx); + } +} + +void EnOkuta_WaitToShoot(EnOkuta* pthis, GlobalContext* globalCtx) { + s16 temp_v0_2; + s32 phi_v1; + + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + if (pthis->timer != 0) { + pthis->timer--; + } + } + if (Animation_OnFrame(&pthis->skelAnime, 0.5f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_FLOAT); + } + if (pthis->actor.xzDistToPlayer < 160.0f || pthis->actor.xzDistToPlayer > 560.0f) { + EnOkuta_SetupHide(pthis); + } else { + temp_v0_2 = Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x71C, 0x38E); + phi_v1 = ABS(temp_v0_2); + if ((phi_v1 < 0x38E) && (pthis->timer == 0) && (pthis->actor.yDistToPlayer < 200.0f)) { + EnOkuta_SetupShoot(pthis, globalCtx); + } + } +} + +void EnOkuta_Shoot(EnOkuta* pthis, GlobalContext* globalCtx) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 3, 0x71C); + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + EnOkuta_SetupWaitToShoot(pthis); + } else { + EnOkuta_SetupShoot(pthis, globalCtx); + } + } else { + f32 curFrame = pthis->skelAnime.curFrame; + + if (curFrame < 13.0f) { + pthis->actor.world.pos.y = (sinf((0.08333f * M_PI) * curFrame) * pthis->jumpHeight) + pthis->actor.home.pos.y; + } + if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + EnOkuta_SpawnProjectile(pthis, globalCtx); + } + if ((pthis->jumpHeight > 50.0f) && Animation_OnFrame(&pthis->skelAnime, 13.0f)) { + EnOkuta_SpawnSplash(pthis, globalCtx); + } + if ((pthis->jumpHeight > 50.0f) && Animation_OnFrame(&pthis->skelAnime, 13.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_LAND); + } + } + if (pthis->actor.xzDistToPlayer < 160.0f) { + EnOkuta_SetupHide(pthis); + } +} + +void EnOkuta_WaitToDie(EnOkuta* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnOkuta_SetupDie(pthis); + } + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f, 5.0f); +} + +void EnOkuta_Die(EnOkuta* pthis, GlobalContext* globalCtx) { + static Vec3f accel = { 0.0f, -0.5f, 0.0f }; + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 150, 150, 150, 0 }; + Vec3f velocity; + Vec3f pos; + s32 i; + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->timer++; + } + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f, 5.0f); + if (pthis->timer == 5) { + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 40.0f; + pos.z = pthis->actor.world.pos.z; + velocity.x = 0.0f; + velocity.y = -0.5f; + velocity.z = 0.0f; + EnOkuta_SpawnDust(&pos, &velocity, -0x14, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_DEAD2); + } + if (Animation_OnFrame(&pthis->skelAnime, 15.0f)) { + EnOkuta_SpawnSplash(pthis, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_LAND); + } + if (pthis->timer < 3) { + Actor_SetScale(&pthis->actor, ((pthis->timer * 0.25f) + 1.0f) * 0.01f); + } else if (pthis->timer < 6) { + Actor_SetScale(&pthis->actor, (1.5f - ((pthis->timer - 2) * 0.2333f)) * 0.01f); + } else if (pthis->timer < 11) { + Actor_SetScale(&pthis->actor, (((pthis->timer - 5) * 0.04f) + 0.8f) * 0.01f); + } else { + if (Math_StepToF(&pthis->actor.scale.x, 0.0f, 0.0005f)) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 30, NA_SE_EN_OCTAROCK_BUBLE); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x70); + for (i = 0; i < 20; i++) { + velocity.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + velocity.y = Rand_ZeroOne() * 7.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &pthis->actor.world.pos, &velocity, &accel, &primColor, + &envColor, Rand_S16Offset(100, 50), 25, 0); + } + Actor_Kill(&pthis->actor); + } + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; + } +} + +void EnOkuta_Freeze(EnOkuta* pthis, GlobalContext* globalCtx) { + Vec3f pos; + s16 temp_v1; + + if (pthis->timer != 0) { + pthis->timer--; + } + if (pthis->timer == 0) { + EnOkuta_SetupDie(pthis); + } + if ((pthis->timer >= 64) && (pthis->timer & 1)) { + temp_v1 = (pthis->timer - 64) >> 1; + pos.y = (pthis->actor.world.pos.y - 32.0f) + (8.0f * (8 - temp_v1)); + pos.x = pthis->actor.world.pos.x + ((temp_v1 & 2) ? 10.0f : -10.0f); + pos.z = pthis->actor.world.pos.z + ((temp_v1 & 1) ? 10.0f : -10.0f); + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &pos, 150, 150, 150, 250, 235, 245, 255, + (Rand_ZeroOne() * 0.2f) + 1.9f); + } + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f, 5.0f); +} + +void EnOkuta_ProjectileFly(EnOkuta* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Player* player = GET_PLAYER(globalCtx); + Vec3s sp40; + + pthis->timer--; + if (pthis->timer == 0) { + pthis->actor.gravity = -1.0f; + } + pthis->actor.home.rot.z += 0x1554; + if (pthis->actor.bgCheckFlags & 0x20) { + pthis->actor.gravity = -1.0f; + pthis->actor.speedXZ -= 0.1f; + pthis->actor.speedXZ = CLAMP_MIN(pthis->actor.speedXZ, 1.0f); + } + if ((pthis->actor.bgCheckFlags & 8) || (pthis->actor.bgCheckFlags & 1) || (pthis->collider.base.atFlags & AT_HIT) || + pthis->collider.base.acFlags & AC_HIT || pthis->collider.base.ocFlags1 & OC1_HIT || + pthis->actor.floorHeight == BGCHECK_Y_MIN) { + if ((player->currentShield == PLAYER_SHIELD_DEKU || + (player->currentShield == PLAYER_SHIELD_HYLIAN && LINK_IS_ADULT)) && + pthis->collider.base.atFlags & AT_HIT && pthis->collider.base.atFlags & AT_TYPE_ENEMY && + pthis->collider.base.atFlags & AT_BOUNCED) { + pthis->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED | AT_TYPE_ENEMY); + pthis->collider.base.atFlags |= AT_TYPE_PLAYER; + pthis->collider.info.toucher.dmgFlags = 2; + Matrix_MtxFToYXZRotS(&player->shieldMf, &sp40, 0); + pthis->actor.world.rot.y = sp40.y + 0x8000; + pthis->timer = 30; + } else { + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 11.0f; + pos.z = pthis->actor.world.pos.z; + EffectSsHahen_SpawnBurst(globalCtx, &pos, 6.0f, 0, 1, 2, 15, 7, 10, gOctorokProjectileDL); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); + Actor_Kill(&pthis->actor); + } + } else if (pthis->timer == -300) { + Actor_Kill(&pthis->actor); + } +} + +void EnOkuta_UpdateHeadScale(EnOkuta* pthis) { + f32 curFrame = pthis->skelAnime.curFrame; + + if (pthis->actionFunc == EnOkuta_Appear) { + if (curFrame < 8.0f) { + pthis->headScale.x = pthis->headScale.y = pthis->headScale.z = 1.0f; + } else if (curFrame < 10.0f) { + pthis->headScale.x = pthis->headScale.z = 1.0f; + pthis->headScale.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; + } else if (curFrame < 14.0f) { + pthis->headScale.x = pthis->headScale.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; + pthis->headScale.y = 1.8f - ((curFrame - 9.0f) * 0.25f); + } else { + pthis->headScale.x = pthis->headScale.z = 1.3f - ((curFrame - 13.0f) * 0.05f); + pthis->headScale.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; + } + } else if (pthis->actionFunc == EnOkuta_Hide) { + if (curFrame < 3.0f) { + pthis->headScale.y = 1.0f; + } else if (curFrame < 4.0f) { + pthis->headScale.y = (curFrame - 2.0f) + 1.0f; + } else { + pthis->headScale.y = 2.0f - ((curFrame - 3.0f) * 0.333f); + } + pthis->headScale.x = pthis->headScale.z = 1.0f; + } else if (pthis->actionFunc == EnOkuta_Shoot) { + if (curFrame < 5.0f) { + pthis->headScale.x = pthis->headScale.y = pthis->headScale.z = (curFrame * 0.125f) + 1.0f; + } else if (curFrame < 7.0f) { + pthis->headScale.x = pthis->headScale.y = pthis->headScale.z = 1.5f - ((curFrame - 4.0f) * 0.35f); + } else if (curFrame < 17.0f) { + pthis->headScale.x = pthis->headScale.z = ((curFrame - 6.0f) * 0.05f) + 0.8f; + pthis->headScale.y = 0.8f; + } else { + pthis->headScale.x = pthis->headScale.z = 1.3f - ((curFrame - 16.0f) * 0.1f); + pthis->headScale.y = ((curFrame - 16.0f) * 0.0666f) + 0.8f; + } + } else if (pthis->actionFunc == EnOkuta_WaitToShoot) { + pthis->headScale.x = pthis->headScale.z = 1.0f; + pthis->headScale.y = (sinf((M_PI / 16) * curFrame) * 0.2f) + 1.0f; + } else { + pthis->headScale.x = pthis->headScale.y = pthis->headScale.z = 1.0f; + } +} + +void EnOkuta_ColliderCheck(EnOkuta* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.colChkInfo.health = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->actor.colChkInfo.damageEffect == 3) { + EnOkuta_SetupFreeze(pthis); + } else { + EnOkuta_SetupWaitToDie(pthis); + } + } + } +} + +void EnOkuta_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnOkuta* pthis = (EnOkuta*)thisx; + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + WaterBox* outWaterBox; + f32 ySurface; + Vec3f sp38; + s32 sp34; + + if (!(player->stateFlags1 & 0x300000C0)) { + if (pthis->actor.params == 0) { + EnOkuta_ColliderCheck(pthis, globalCtx); + if (!WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, + pthis->actor.world.pos.z, &ySurface, &outWaterBox) || + (ySurface < pthis->actor.floorHeight)) { + if (pthis->actor.colChkInfo.health != 0) { + Actor_Kill(&pthis->actor); + return; + } + } else { + pthis->actor.home.pos.y = ySurface; + } + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->actor.params == 0) { + EnOkuta_UpdateHeadScale(pthis); + pthis->collider.dim.height = + (((sOctorockColliderInit.dim.height * pthis->headScale.y) - pthis->collider.dim.yShift) * + pthis->actor.scale.y * 100.0f); + } else { + sp34 = false; + Actor_MoveForward(&pthis->actor); + Math_Vec3f_Copy(&sp38, &pthis->actor.world.pos); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 15.0f, 30.0f, 5); + if ((pthis->actor.bgCheckFlags & 8) && + SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, pthis->actor.wallPoly, pthis->actor.wallBgId)) { + sp34 = true; + pthis->actor.bgCheckFlags &= ~8; + } + if ((pthis->actor.bgCheckFlags & 1) && + SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId)) { + sp34 = true; + pthis->actor.bgCheckFlags &= ~1; + } + if (sp34 && !(pthis->actor.bgCheckFlags & 9)) { + Math_Vec3f_Copy(&pthis->actor.world.pos, &sp38); + } + } + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if ((pthis->actionFunc == EnOkuta_Appear) || (pthis->actionFunc == EnOkuta_Hide)) { + pthis->collider.dim.pos.y = pthis->actor.world.pos.y + (pthis->skelAnime.jointTable->y * pthis->actor.scale.y); + pthis->collider.dim.radius = sOctorockColliderInit.dim.radius * pthis->actor.scale.x * 100.0f; + } + if (pthis->actor.params == 0x10) { + pthis->actor.flags |= ACTOR_FLAG_24; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->actionFunc != EnOkuta_WaitToAppear) { + if ((pthis->actionFunc != EnOkuta_Die) && (pthis->actionFunc != EnOkuta_WaitToDie) && + (pthis->actionFunc != EnOkuta_Freeze)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + Actor_SetFocus(&pthis->actor, 15.0f); + if ((pthis->actor.params == 0) && (pthis->actor.draw != NULL)) { + EnOkuta_SpawnRipple(pthis, globalCtx); + } + } +} + +s32 EnOkuta_GetSnoutScale(EnOkuta* pthis, f32 curFrame, Vec3f* scale) { + if (pthis->actionFunc == EnOkuta_WaitToShoot) { + scale->x = scale->z = 1.0f; + scale->y = (sinf((M_PI / 16) * curFrame) * 0.4f) + 1.0f; + } else if (pthis->actionFunc == EnOkuta_Shoot) { + if (curFrame < 5.0f) { + scale->x = 1.0f; + scale->y = scale->z = (curFrame * 0.25f) + 1.0f; + } else if (curFrame < 7.0f) { + scale->x = (curFrame - 4.0f) * 0.5f + 1.0f; + scale->y = scale->z = 2.0f - (curFrame - 4.0f) * 0.5f; + } else { + scale->x = 2.0f - ((curFrame - 6.0f) * 0.0769f); + scale->y = scale->z = 1.0f; + } + } else if (pthis->actionFunc == EnOkuta_Die) { + if (curFrame >= 35.0f || curFrame < 25.0f) { + return false; + } + if (curFrame < 27.0f) { + scale->x = 1.0f; + scale->y = scale->z = ((curFrame - 24.0f) * 0.5f) + 1.0f; + } else if (curFrame < 30.0f) { + scale->x = (curFrame - 26.0f) * 0.333f + 1.0f; + scale->y = scale->z = 2.0f - (curFrame - 26.0f) * 0.333f; + } else { + scale->x = 2.0f - ((curFrame - 29.0f) * 0.2f); + scale->y = scale->z = 1.0f; + } + } else { + return false; + } + + return true; +} + +s32 EnOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnOkuta* pthis = (EnOkuta*)thisx; + f32 curFrame = pthis->skelAnime.curFrame; + Vec3f scale; + s32 doScale = false; + + if (pthis->actionFunc == EnOkuta_Die) { + curFrame += pthis->timer; + } + if (limbIndex == 5) { + if ((pthis->headScale.x != 1.0f) || (pthis->headScale.y != 1.0f) || (pthis->headScale.z != 1.0f)) { + scale = pthis->headScale; + doScale = true; + } + } else if (limbIndex == 8) { + doScale = EnOkuta_GetSnoutScale(pthis, curFrame, &scale); + } + if (doScale) { + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + } + return false; +} + +void EnOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnOkuta* pthis = (EnOkuta*)thisx; + s32 pad; + + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->actor.params == 0) { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnOkuta_OverrideLimbDraw, + NULL, pthis); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_okuta.c", 1653); + + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZ(pthis->actor.home.rot.z * (M_PI / 0x8000), MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_okuta.c", 1657), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gOctorokProjectileDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_okuta.c", 1662); + } +} diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.cpp similarity index 53% rename from src/overlays/actors/ovl_En_Ossan/z_en_ossan.c rename to src/overlays/actors/ovl_En_Ossan/z_en_ossan.cpp index 8e99c0346..2d3183a35 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.cpp @@ -42,8 +42,8 @@ void EnOssan_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx); void EnOssan_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx); void EnOssan_DrawHappyMaskShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_InitActionFunc(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_MainActionFunc(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_InitActionFunc(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_MainActionFunc(EnOssan* pthis, GlobalContext* globalCtx); void EnOssan_TalkDefaultShopkeeper(GlobalContext* globalCtx); void EnOssan_TalkKokiriShopkeeper(GlobalContext* globalCtx); @@ -63,59 +63,59 @@ s16 ShopItemDisp_ZoraMask(s16 v); s16 ShopItemDisp_GoronMask(s16 v); s16 ShopItemDisp_GerudoMask(s16 v); -void EnOssan_InitKokiriShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitPotionShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitBombchuShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitBazaarShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitZoraShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitGoronShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitHappyMaskShopkeeper(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_InitKokiriShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_InitPotionShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_InitBombchuShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_InitBazaarShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_InitZoraShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_InitGoronShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); +void EnOssan_InitHappyMaskShopkeeper(EnOssan* pthis, GlobalContext* globalCtx); -void EnOssan_State_Idle(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_StartConversation(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_FacingShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_TalkingToShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_LookToLeftShelf(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_LookToRightShelf(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_LookFromShelfToShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_ItemSelected(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_SelectMilkBottle(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_SelectWeirdEgg(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_SelectUnimplementedItem(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_SelectBombs(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_CantGetItem(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_GiveItemWithFanfare(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_ItemPurchased(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_ContinueShoppingPrompt(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_GiveLonLonMilk(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_DisplayOnlyBombDialog(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_WaitForDisplayOnlyBombDialog(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_21(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_22(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_QuickBuyDialog(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_SelectMaskItem(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_LendMaskOfTruth(EnOssan* this, GlobalContext* globalCtx, Player* player); -void EnOssan_State_GiveDiscountDialog(EnOssan* this, GlobalContext* globalCtx, Player* player); +void EnOssan_State_Idle(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_StartConversation(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_FacingShopkeeper(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_TalkingToShopkeeper(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_LookToLeftShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_LookToRightShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_BrowseLeftShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_BrowseRightShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_LookFromShelfToShopkeeper(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_ItemSelected(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_SelectMilkBottle(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_SelectWeirdEgg(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_SelectUnimplementedItem(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_SelectBombs(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_CantGetItem(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_GiveItemWithFanfare(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_ItemPurchased(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_ContinueShoppingPrompt(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_GiveLonLonMilk(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_DisplayOnlyBombDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_WaitForDisplayOnlyBombDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_21(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_22(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_QuickBuyDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_SelectMaskItem(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_LendMaskOfTruth(EnOssan* pthis, GlobalContext* globalCtx, Player* player); +void EnOssan_State_GiveDiscountDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player); -void EnOssan_Obj3ToSeg6(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_Obj3ToSeg6(EnOssan* pthis, GlobalContext* globalCtx); -void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this); +void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* pthis); -void EnOssan_WaitForBlink(EnOssan* this); -void EnOssan_Blink(EnOssan* this); +void EnOssan_WaitForBlink(EnOssan* pthis); +void EnOssan_Blink(EnOssan* pthis); -u16 EnOssan_SetupHelloDialog(EnOssan* this); +u16 EnOssan_SetupHelloDialog(EnOssan* pthis); -s32 EnOssan_TakeItemOffShelf(EnOssan* this); -s32 EnOssan_ReturnItemToShelf(EnOssan* this); -void EnOssan_ResetItemPosition(EnOssan* this); -void EnOssan_SetStateGiveDiscountDialog(GlobalContext* globalCtx, EnOssan* this); +s32 EnOssan_TakeItemOffShelf(EnOssan* pthis); +s32 EnOssan_ReturnItemToShelf(EnOssan* pthis); +void EnOssan_ResetItemPosition(EnOssan* pthis); +void EnOssan_SetStateGiveDiscountDialog(GlobalContext* globalCtx, EnOssan* pthis); #define CURSOR_INVALID 0xFF -const ActorInit En_Ossan_InitVars = { +ActorInit En_Ossan_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, FLAGS, @@ -156,7 +156,7 @@ static s16 sItemShelfRot[] = { 0xEAAC, 0xEAAC, 0xEAAC, 0xEAAC, 0x1554, 0x1554, 0 // unused values? static s16 D_80AC8904[] = { 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025 }; -static char* sShopkeeperPrintName[] = { +static const char* sShopkeeperPrintName[] = { "コキリの店 ", // "Kokiri Shop" "薬屋 ", // "Potion Shop" "夜の店 ", // "Night Shop" @@ -329,7 +329,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -// When selecting an item to buy, this is the position the item moves to +// When selecting an item to buy, pthis is the position the item moves to static Vec3f sSelectedItemPosition[] = { { 17.0f, 58.0f, 30.0f }, { -17.0f, 58.0f, 30.0f } }; static EnOssanInitFunc sInitFuncs[] = { @@ -375,8 +375,8 @@ static EnOssanStateFunc sStateFunc[] = { EnOssan_State_GiveDiscountDialog, }; -void EnOssan_SetupAction(EnOssan* this, EnOssanActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnOssan_SetupAction(EnOssan* pthis, EnOssanActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } s16 ShopItemDisp_Default(s16 v) { @@ -431,22 +431,22 @@ s16 ShopItemDisp_GerudoMask(s16 v) { return -1; } -void EnOssan_SpawnItemsOnShelves(EnOssan* this, GlobalContext* globalCtx, ShopItem* shopItems) { +void EnOssan_SpawnItemsOnShelves(EnOssan* pthis, GlobalContext* globalCtx, ShopItem* shopItems) { EnTana* shelves; s16 itemParams; s32 i; for (i = 0; i < 8; i++, shopItems++) { if (shopItems->shopItemIndex < 0) { - this->shelfSlots[i] = NULL; + pthis->shelfSlots[i] = NULL; } else { itemParams = sShopItemReplaceFunc[shopItems->shopItemIndex](shopItems->shopItemIndex); if (itemParams < 0) { - this->shelfSlots[i] = NULL; + pthis->shelfSlots[i] = NULL; } else { - shelves = this->shelves; - this->shelfSlots[i] = (EnGirlA*)Actor_Spawn( + shelves = pthis->shelves; + pthis->shelfSlots[i] = (EnGirlA*)Actor_Spawn( &globalCtx->actorCtx, globalCtx, ACTOR_EN_GIRLA, shelves->actor.world.pos.x + shopItems->xOffset, shelves->actor.world.pos.y + shopItems->yOffset, shelves->actor.world.pos.z + shopItems->zOffset, shelves->actor.shape.rot.x, shelves->actor.shape.rot.y + sItemShelfRot[i], @@ -456,26 +456,26 @@ void EnOssan_SpawnItemsOnShelves(EnOssan* this, GlobalContext* globalCtx, ShopIt } } -void EnOssan_UpdateShopOfferings(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_UpdateShopOfferings(EnOssan* pthis, GlobalContext* globalCtx) { s32 i; ShopItem* storeItems; ShopItem* shopItem; - if (this->actor.params == OSSAN_TYPE_MASK) { - storeItems = sShopkeeperStores[this->actor.params]; + if (pthis->actor.params == OSSAN_TYPE_MASK) { + storeItems = sShopkeeperStores[pthis->actor.params]; if (1) {} for (i = 0; i < 8; i++) { shopItem = &storeItems[i]; - if (shopItem->shopItemIndex >= 0 && this->shelfSlots[i] == NULL) { + if (shopItem->shopItemIndex >= 0 && pthis->shelfSlots[i] == NULL) { s16 params = sShopItemReplaceFunc[shopItem->shopItemIndex](shopItem->shopItemIndex); if (params >= 0) { - this->shelfSlots[i] = (EnGirlA*)Actor_Spawn( + pthis->shelfSlots[i] = (EnGirlA*)Actor_Spawn( &globalCtx->actorCtx, globalCtx, ACTOR_EN_GIRLA, - this->shelves->actor.world.pos.x + shopItem->xOffset, - this->shelves->actor.world.pos.y + shopItem->yOffset, - this->shelves->actor.world.pos.z + shopItem->zOffset, this->shelves->actor.shape.rot.x, - this->shelves->actor.shape.rot.y + sItemShelfRot[i], this->shelves->actor.shape.rot.z, params); + pthis->shelves->actor.world.pos.x + shopItem->xOffset, + pthis->shelves->actor.world.pos.y + shopItem->yOffset, + pthis->shelves->actor.world.pos.z + shopItem->zOffset, pthis->shelves->actor.shape.rot.x, + pthis->shelves->actor.shape.rot.y + sItemShelfRot[i], pthis->shelves->actor.shape.rot.z, params); } } } @@ -558,163 +558,163 @@ void EnOssan_TalkHappyMaskShopkeeper(GlobalContext* globalCtx) { } } -void EnOssan_UpdateCameraDirection(EnOssan* this, GlobalContext* globalCtx, f32 cameraFaceAngle) { - this->cameraFaceAngle = cameraFaceAngle; +void EnOssan_UpdateCameraDirection(EnOssan* pthis, GlobalContext* globalCtx, f32 cameraFaceAngle) { + pthis->cameraFaceAngle = cameraFaceAngle; Camera_SetCameraData(GET_ACTIVE_CAM(globalCtx), 0xC, NULL, NULL, cameraFaceAngle, 0, 0); } -s32 EnOssan_TryGetObjBankIndexes(EnOssan* this, GlobalContext* globalCtx, s16* objectIds) { +s32 EnOssan_TryGetObjBankIndexes(EnOssan* pthis, GlobalContext* globalCtx, s16* objectIds) { if (objectIds[1] != OBJECT_ID_MAX) { - this->objBankIndex2 = Object_GetIndex(&globalCtx->objectCtx, objectIds[1]); - if (this->objBankIndex2 < 0) { + pthis->objBankIndex2 = Object_GetIndex(&globalCtx->objectCtx, objectIds[1]); + if (pthis->objBankIndex2 < 0) { return false; } } else { - this->objBankIndex2 = -1; + pthis->objBankIndex2 = -1; } if (objectIds[2] != OBJECT_ID_MAX) { - this->objBankIndex3 = Object_GetIndex(&globalCtx->objectCtx, objectIds[2]); - if (this->objBankIndex3 < 0) { + pthis->objBankIndex3 = Object_GetIndex(&globalCtx->objectCtx, objectIds[2]); + if (pthis->objBankIndex3 < 0) { return false; } } else { - this->objBankIndex3 = -1; + pthis->objBankIndex3 = -1; } return true; } void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx) { - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; s16* objectIds; - if (this->actor.params == OSSAN_TYPE_TALON && (LINK_AGE_IN_YEARS != YEARS_CHILD)) { - this->actor.params = OSSAN_TYPE_INGO; + if (pthis->actor.params == OSSAN_TYPE_TALON && (LINK_AGE_IN_YEARS != YEARS_CHILD)) { + pthis->actor.params = OSSAN_TYPE_INGO; } //! @bug This check will always evaluate to false, it should be || not && - if (this->actor.params > OSSAN_TYPE_MASK && this->actor.params < OSSAN_TYPE_KOKIRI) { - Actor_Kill(&this->actor); + if (pthis->actor.params > OSSAN_TYPE_MASK && pthis->actor.params < OSSAN_TYPE_KOKIRI) { + Actor_Kill(&pthis->actor); osSyncPrintf(VT_COL(RED, WHITE)); - osSyncPrintf("引数がおかしいよ(arg_data=%d)!!\n", this->actor.params); + osSyncPrintf("引数がおかしいよ(arg_data=%d)!!\n", pthis->actor.params); osSyncPrintf(VT_RST); ASSERT(0, "0", "../z_en_oB1.c", 1246); return; } // If you've given Zelda's Letter to the Kakariko Guard - if (this->actor.params == OSSAN_TYPE_MASK && !(gSaveContext.infTable[7] & 0x40)) { - Actor_Kill(&this->actor); + if (pthis->actor.params == OSSAN_TYPE_MASK && !(gSaveContext.infTable[7] & 0x40)) { + Actor_Kill(&pthis->actor); return; } - if (this->actor.params == OSSAN_TYPE_KAKARIKO_POTION && (LINK_AGE_IN_YEARS == YEARS_CHILD)) { - Actor_Kill(&this->actor); + if (pthis->actor.params == OSSAN_TYPE_KAKARIKO_POTION && (LINK_AGE_IN_YEARS == YEARS_CHILD)) { + Actor_Kill(&pthis->actor); return; } // Completed Dodongo's Cavern - if (this->actor.params == OSSAN_TYPE_BOMBCHUS && !(gSaveContext.eventChkInf[2] & 0x20)) { - Actor_Kill(&this->actor); + if (pthis->actor.params == OSSAN_TYPE_BOMBCHUS && !(gSaveContext.eventChkInf[2] & 0x20)) { + Actor_Kill(&pthis->actor); return; } - objectIds = sShopkeeperObjectIds[this->actor.params]; - this->objBankIndex1 = Object_GetIndex(&globalCtx->objectCtx, objectIds[0]); + objectIds = sShopkeeperObjectIds[pthis->actor.params]; + pthis->objBankIndex1 = Object_GetIndex(&globalCtx->objectCtx, objectIds[0]); - if (this->objBankIndex1 < 0) { - Actor_Kill(&this->actor); + if (pthis->objBankIndex1 < 0) { + Actor_Kill(&pthis->actor); osSyncPrintf(VT_COL(RED, WHITE)); - osSyncPrintf("バンクが無いよ!!(%s)\n", sShopkeeperPrintName[this->actor.params]); + osSyncPrintf("バンクが無いよ!!(%s)\n", sShopkeeperPrintName[pthis->actor.params]); osSyncPrintf(VT_RST); ASSERT(0, "0", "../z_en_oB1.c", 1284); return; } - if (EnOssan_TryGetObjBankIndexes(this, globalCtx, objectIds) == 0) { - Actor_Kill(&this->actor); + if (EnOssan_TryGetObjBankIndexes(pthis, globalCtx, objectIds) == 0) { + Actor_Kill(&pthis->actor); osSyncPrintf(VT_COL(RED, WHITE)); - osSyncPrintf("予備バンクが無いよ!!(%s)\n", sShopkeeperPrintName[this->actor.params]); + osSyncPrintf("予備バンクが無いよ!!(%s)\n", sShopkeeperPrintName[pthis->actor.params]); osSyncPrintf(VT_RST); ASSERT(0, "0", "../z_en_oB1.c", 1295); return; } - Actor_ProcessInitChain(&this->actor, sInitChain); - EnOssan_SetupAction(this, EnOssan_InitActionFunc); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + EnOssan_SetupAction(pthis, EnOssan_InitActionFunc); } void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnOssan* this = (EnOssan*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + EnOssan* pthis = (EnOssan*)thisx; + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* pthis) { s16 x; s16 y; - Actor_GetScreenPos(globalCtx, &this->shelfSlots[this->cursorIndex]->actor, &x, &y); - this->cursorX = x; - this->cursorY = y; + Actor_GetScreenPos(globalCtx, &pthis->shelfSlots[pthis->cursorIndex]->actor, &x, &y); + pthis->cursorX = x; + pthis->cursorY = y; } -void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* pthis) { Player* player = GET_PLAYER(globalCtx); // "End of conversation!" osSyncPrintf(VT_FGCOL(YELLOW) "%s[%d]:★★★ 会話終了!! ★★★" VT_RST "\n", "../z_en_oB1.c", 1337); YREG(31) = 0; - Actor_ProcessTalkRequest(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&pthis->actor, globalCtx); globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; globalCtx->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; func_800BC490(globalCtx, 1); Interface_ChangeAlpha(50); - this->drawCursor = 0; - this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = false; - EnOssan_UpdateCameraDirection(this, globalCtx, 0.0f); - this->actor.textId = EnOssan_SetupHelloDialog(this); - this->stateFlag = OSSAN_STATE_IDLE; + pthis->drawCursor = 0; + pthis->stickLeftPrompt.isEnabled = false; + pthis->stickRightPrompt.isEnabled = false; + EnOssan_UpdateCameraDirection(pthis, globalCtx, 0.0f); + pthis->actor.textId = EnOssan_SetupHelloDialog(pthis); + pthis->stateFlag = OSSAN_STATE_IDLE; } -s32 EnOssan_TestEndInteraction(EnOssan* this, GlobalContext* globalCtx, Input* input) { +s32 EnOssan_TestEndInteraction(EnOssan* pthis, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(globalCtx, pthis); return true; } else { return false; } } -s32 EnOssan_TestCancelOption(EnOssan* this, GlobalContext* globalCtx, Input* input) { +s32 EnOssan_TestCancelOption(EnOssan* pthis, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); return true; } else { return false; } } -void EnOssan_SetStateStartShopping(GlobalContext* globalCtx, EnOssan* this, u8 skipHelloState) { +void EnOssan_SetStateStartShopping(GlobalContext* globalCtx, EnOssan* pthis, u8 skipHelloState) { YREG(31) = 1; - this->headRot = this->headTargetRot = 0; + pthis->headRot = pthis->headTargetRot = 0; Interface_SetDoAction(globalCtx, DO_ACTION_NEXT); - EnOssan_UpdateCameraDirection(this, globalCtx, 0); + EnOssan_UpdateCameraDirection(pthis, globalCtx, 0); if (!skipHelloState) { - this->stateFlag = OSSAN_STATE_START_CONVERSATION; + pthis->stateFlag = OSSAN_STATE_START_CONVERSATION; } else { - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(globalCtx, pthis); } } -void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this) { - this->stateFlag = OSSAN_STATE_FACING_SHOPKEEPER; +void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* pthis) { + pthis->stateFlag = OSSAN_STATE_FACING_SHOPKEEPER; - if (this->actor.params == OSSAN_TYPE_MASK) { + if (pthis->actor.params == OSSAN_TYPE_MASK) { // if all masks have been sold, give the option to ask about the mask of truth if ((gSaveContext.itemGetInf[3] & 0x100) && (gSaveContext.itemGetInf[3] & 0x200) && (gSaveContext.itemGetInf[3] & 0x400) && (gSaveContext.itemGetInf[3] & 0x800)) { @@ -727,114 +727,114 @@ void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this) { } Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - this->stickRightPrompt.isEnabled = true; - this->stickLeftPrompt.isEnabled = true; - EnOssan_UpdateCameraDirection(this, globalCtx, 0.0f); + pthis->stickRightPrompt.isEnabled = true; + pthis->stickLeftPrompt.isEnabled = true; + EnOssan_UpdateCameraDirection(pthis, globalCtx, 0.0f); } -void EnOssan_ChooseTalkToOwner(GlobalContext* globalCtx, EnOssan* this) { - this->stateFlag = OSSAN_STATE_TALKING_TO_SHOPKEEPER; - sShopkeeperTalkOwner[this->actor.params](globalCtx); +void EnOssan_ChooseTalkToOwner(GlobalContext* globalCtx, EnOssan* pthis) { + pthis->stateFlag = OSSAN_STATE_TALKING_TO_SHOPKEEPER; + sShopkeeperTalkOwner[pthis->actor.params](globalCtx); Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = false; + pthis->stickLeftPrompt.isEnabled = false; + pthis->stickRightPrompt.isEnabled = false; } -void EnOssan_SetLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_SetLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* pthis) { func_80078884(NA_SE_SY_CURSOR); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_LOOK_SHOPKEEPER; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_LOOK_SHOPKEEPER; } -void EnOssan_State_Idle(EnOssan* this, GlobalContext* globalCtx, Player* player) { - this->headTargetRot = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +void EnOssan_State_Idle(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + pthis->headTargetRot = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { // "Start conversation!!" osSyncPrintf(VT_FGCOL(YELLOW) "★★★ 会話開始!! ★★★" VT_RST "\n"); player->stateFlags2 |= 0x20000000; func_800BC590(globalCtx); - EnOssan_SetStateStartShopping(globalCtx, this, false); - } else if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100); + EnOssan_SetStateStartShopping(globalCtx, pthis, false); + } else if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100); } } -void EnOssan_UpdateJoystickInputState(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_UpdateJoystickInputState(GlobalContext* globalCtx, EnOssan* pthis) { Input* input = &globalCtx->state.input[0]; s8 stickX = input->rel.stick_x; s8 stickY = input->rel.stick_y; - this->moveHorizontal = this->moveVertical = false; + pthis->moveHorizontal = pthis->moveVertical = false; - if (this->stickAccumX == 0) { + if (pthis->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { - this->stickAccumX = stickX; - this->moveHorizontal = true; + pthis->stickAccumX = stickX; + pthis->moveHorizontal = true; } } else if (stickX <= 30 && stickX >= -30) { - this->stickAccumX = 0; - } else if (this->stickAccumX * stickX < 0) { // Stick has swapped directions - this->stickAccumX = stickX; - this->moveHorizontal = true; + pthis->stickAccumX = 0; + } else if (pthis->stickAccumX * stickX < 0) { // Stick has swapped directions + pthis->stickAccumX = stickX; + pthis->moveHorizontal = true; } else { - this->stickAccumX += stickX; + pthis->stickAccumX += stickX; - if (this->stickAccumX > 2000) { - this->stickAccumX = 2000; - } else if (this->stickAccumX < -2000) { - this->stickAccumX = -2000; + if (pthis->stickAccumX > 2000) { + pthis->stickAccumX = 2000; + } else if (pthis->stickAccumX < -2000) { + pthis->stickAccumX = -2000; } } - if (this->stickAccumY == 0) { + if (pthis->stickAccumY == 0) { if (stickY > 30 || stickY < -30) { - this->stickAccumY = stickY; - this->moveVertical = true; + pthis->stickAccumY = stickY; + pthis->moveVertical = true; } } else if (stickY <= 30 && stickY >= -30) { - this->stickAccumY = 0; - } else if (this->stickAccumY * stickY < 0) { // Stick has swapped directions - this->stickAccumY = stickY; - this->moveVertical = true; + pthis->stickAccumY = 0; + } else if (pthis->stickAccumY * stickY < 0) { // Stick has swapped directions + pthis->stickAccumY = stickY; + pthis->moveVertical = true; } else { - this->stickAccumY += stickY; + pthis->stickAccumY += stickY; - if (this->stickAccumY > 2000) { - this->stickAccumY = 2000; - } else if (this->stickAccumY < -2000) { - this->stickAccumY = -2000; + if (pthis->stickAccumY > 2000) { + pthis->stickAccumY = 2000; + } else if (pthis->stickAccumY < -2000) { + pthis->stickAccumY = -2000; } } } -u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* this, u8 shelfOffset) { +u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* pthis, u8 shelfOffset) { u8 i; // if cursor is on the top shelf - if (this->cursorIndex & 1) { + if (pthis->cursorIndex & 1) { // scan top shelf for non-null item for (i = shelfOffset + 1; i < shelfOffset + 4; i += 2) { - if (this->shelfSlots[i] != NULL) { + if (pthis->shelfSlots[i] != NULL) { return i; } } // scan bottom shelf for non-null item for (i = shelfOffset; i < shelfOffset + 4; i += 2) { - if (this->shelfSlots[i] != NULL) { + if (pthis->shelfSlots[i] != NULL) { return i; } } } else { // scan bottom shelf for non-null item for (i = shelfOffset; i < shelfOffset + 4; i += 2) { - if (this->shelfSlots[i] != NULL) { + if (pthis->shelfSlots[i] != NULL) { return i; } } // scan top shelf for non-null item for (i = shelfOffset + 1; i < shelfOffset + 4; i += 2) { - if (this->shelfSlots[i] != NULL) { + if (pthis->shelfSlots[i] != NULL) { return i; } } @@ -842,13 +842,13 @@ u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* this, u8 shelfOffset) { return CURSOR_INVALID; } -u8 EnOssan_CursorRight(EnOssan* this, u8 cursorIndex, u8 shelfSlotMin) { +u8 EnOssan_CursorRight(EnOssan* pthis, u8 cursorIndex, u8 shelfSlotMin) { u8 c = shelfSlotMin + 4; while (cursorIndex >= shelfSlotMin && cursorIndex < c) { cursorIndex -= 2; if (cursorIndex >= shelfSlotMin && cursorIndex < c) { - if (this->shelfSlots[cursorIndex] != NULL) { + if (pthis->shelfSlots[cursorIndex] != NULL) { return cursorIndex; } } @@ -856,11 +856,11 @@ u8 EnOssan_CursorRight(EnOssan* this, u8 cursorIndex, u8 shelfSlotMin) { return CURSOR_INVALID; } -u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIndex, u8 shelfSlotMax) { +u8 EnOssan_CursorLeft(EnOssan* pthis, u8 cursorIndex, u8 shelfSlotMax) { while (cursorIndex < shelfSlotMax) { cursorIndex += 2; - if ((cursorIndex < shelfSlotMax) && this->shelfSlots[cursorIndex] != NULL) { + if ((cursorIndex < shelfSlotMax) && pthis->shelfSlots[cursorIndex] != NULL) { return cursorIndex; } } @@ -868,68 +868,68 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIndex, u8 shelfSlotMax) { } // pay salesman back -void EnOssan_TryPaybackMask(EnOssan* this, GlobalContext* globalCtx) { - s16 price = sMaskPaymentPrice[this->happyMaskShopState]; +void EnOssan_TryPaybackMask(EnOssan* pthis, GlobalContext* globalCtx) { + s16 price = sMaskPaymentPrice[pthis->happyMaskShopState]; if (gSaveContext.rupees < price) { Message_ContinueTextbox(globalCtx, 0x70A8); - this->happyMaskShopkeeperEyeIdx = 1; - this->happyMaskShopState = OSSAN_HAPPY_STATE_ANGRY; + pthis->happyMaskShopkeeperEyeIdx = 1; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_ANGRY; } else { Rupees_ChangeBy(-price); - if (this->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_BUNNY_HOOD) { + if (pthis->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_BUNNY_HOOD) { gSaveContext.eventChkInf[8] |= 0x8000; Message_ContinueTextbox(globalCtx, 0x70A9); - this->happyMaskShopState = OSSAN_HAPPY_STATE_ALL_MASKS_SOLD; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_ALL_MASKS_SOLD; return; } - if (this->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_KEATON_MASK) { + if (pthis->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_KEATON_MASK) { gSaveContext.eventChkInf[8] |= 0x1000; - } else if (this->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SPOOKY_MASK) { + } else if (pthis->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SPOOKY_MASK) { gSaveContext.eventChkInf[8] |= 0x4000; - } else if (this->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SKULL_MASK) { + } else if (pthis->happyMaskShopState == OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SKULL_MASK) { gSaveContext.eventChkInf[8] |= 0x2000; } Message_ContinueTextbox(globalCtx, 0x70A7); - this->happyMaskShopState = OSSAN_HAPPY_STATE_NONE; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_NONE; } - this->stateFlag = OSSAN_STATE_START_CONVERSATION; + pthis->stateFlag = OSSAN_STATE_START_CONVERSATION; } -void EnOssan_State_StartConversation(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_StartConversation(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { u8 dialogState = Message_GetState(&globalCtx->msgCtx); - if (this->actor.params == OSSAN_TYPE_MASK && dialogState == TEXT_STATE_CHOICE) { - if (!EnOssan_TestEndInteraction(this, globalCtx, &globalCtx->state.input[0]) && + if (pthis->actor.params == OSSAN_TYPE_MASK && dialogState == TEXT_STATE_CHOICE) { + if (!EnOssan_TestEndInteraction(pthis, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(globalCtx, pthis); break; case 1: - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(globalCtx, pthis); break; } } } else if (dialogState == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { func_80078884(NA_SE_SY_MESSAGE_PASS); - switch (this->happyMaskShopState) { + switch (pthis->happyMaskShopState) { case OSSAN_HAPPY_STATE_ALL_MASKS_SOLD: Message_ContinueTextbox(globalCtx, 0x70AA); - this->stateFlag = OSSAN_STATE_LEND_MASK_OF_TRUTH; + pthis->stateFlag = OSSAN_STATE_LEND_MASK_OF_TRUTH; return; case OSSAN_HAPPY_STATE_BORROWED_FIRST_MASK: - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(globalCtx, pthis); return; case OSSAN_HAPPY_STATE_REQUEST_PAYMENT_KEATON_MASK: case OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SPOOKY_MASK: case OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SKULL_MASK: case OSSAN_HAPPY_STATE_REQUEST_PAYMENT_BUNNY_HOOD: - EnOssan_TryPaybackMask(this, globalCtx); + EnOssan_TryPaybackMask(pthis, globalCtx); return; case OSSAN_HAPPY_STATE_ANGRY: globalCtx->nextEntranceIndex = 0x1D1; @@ -938,113 +938,113 @@ void EnOssan_State_StartConversation(EnOssan* this, GlobalContext* globalCtx, Pl return; } - if (!EnOssan_TestEndInteraction(this, globalCtx, &globalCtx->state.input[0])) { + if (!EnOssan_TestEndInteraction(pthis, globalCtx, &globalCtx->state.input[0])) { // "Shop around by moving the stick left and right" osSyncPrintf("「スティック左右で品物みてくれ!」\n"); - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(globalCtx, pthis); } } if (1) {} } -s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx) { +s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* pthis, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - EnOssan_ChooseTalkToOwner(globalCtx, this); + EnOssan_ChooseTalkToOwner(globalCtx, pthis); return true; case 1: - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(globalCtx, pthis); return true; default: return false; } } -void EnOssan_State_FacingShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_FacingShopkeeper(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { u8 nextIndex; if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && - !EnOssan_TestEndInteraction(this, globalCtx, &globalCtx->state.input[0])) { - if (Message_ShouldAdvance(globalCtx) && EnOssan_FacingShopkeeperDialogResult(this, globalCtx)) { + !EnOssan_TestEndInteraction(pthis, globalCtx, &globalCtx->state.input[0])) { + if (Message_ShouldAdvance(globalCtx) && EnOssan_FacingShopkeeperDialogResult(pthis, globalCtx)) { func_80078884(NA_SE_SY_DECIDE); return; } // Stick Left - if (this->stickAccumX < 0) { - nextIndex = EnOssan_SetCursorIndexFromNeutral(this, 4); + if (pthis->stickAccumX < 0) { + nextIndex = EnOssan_SetCursorIndexFromNeutral(pthis, 4); if (nextIndex != CURSOR_INVALID) { - this->cursorIndex = nextIndex; - this->stateFlag = OSSAN_STATE_LOOK_SHELF_LEFT; + pthis->cursorIndex = nextIndex; + pthis->stateFlag = OSSAN_STATE_LOOK_SHELF_LEFT; Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - this->stickLeftPrompt.isEnabled = false; + pthis->stickLeftPrompt.isEnabled = false; func_80078884(NA_SE_SY_CURSOR); } - } else if (this->stickAccumX > 0) { - nextIndex = EnOssan_SetCursorIndexFromNeutral(this, 0); + } else if (pthis->stickAccumX > 0) { + nextIndex = EnOssan_SetCursorIndexFromNeutral(pthis, 0); if (nextIndex != CURSOR_INVALID) { - this->cursorIndex = nextIndex; - this->stateFlag = OSSAN_STATE_LOOK_SHELF_RIGHT; + pthis->cursorIndex = nextIndex; + pthis->stateFlag = OSSAN_STATE_LOOK_SHELF_RIGHT; Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - this->stickRightPrompt.isEnabled = false; + pthis->stickRightPrompt.isEnabled = false; func_80078884(NA_SE_SY_CURSOR); } } } } -void EnOssan_State_TalkingToShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_TalkingToShopkeeper(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(globalCtx, pthis); } } -void EnOssan_State_LookToLeftShelf(EnOssan* this, GlobalContext* globalCtx, Player* player) { - Math_ApproachF(&this->cameraFaceAngle, 30.0f, 0.5f, 10.0f); +void EnOssan_State_LookToLeftShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + Math_ApproachF(&pthis->cameraFaceAngle, 30.0f, 0.5f, 10.0f); - if (this->cameraFaceAngle > 29.5f) { - EnOssan_UpdateCameraDirection(this, globalCtx, 30.0f); + if (pthis->cameraFaceAngle > 29.5f) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, 30.0f); } - EnOssan_UpdateCameraDirection(this, globalCtx, this->cameraFaceAngle); + EnOssan_UpdateCameraDirection(pthis, globalCtx, pthis->cameraFaceAngle); - if (this->cameraFaceAngle >= 30.0f) { - EnOssan_UpdateCameraDirection(this, globalCtx, 30.0f); - EnOssan_UpdateCursorPos(globalCtx, this); - this->stateFlag = OSSAN_STATE_BROWSE_LEFT_SHELF; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + if (pthis->cameraFaceAngle >= 30.0f) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, 30.0f); + EnOssan_UpdateCursorPos(globalCtx, pthis); + pthis->stateFlag = OSSAN_STATE_BROWSE_LEFT_SHELF; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); } else { - this->stickAccumX = 0; + pthis->stickAccumX = 0; } } -void EnOssan_State_LookToRightShelf(EnOssan* this, GlobalContext* globalCtx, Player* player) { - Math_ApproachF(&this->cameraFaceAngle, -30.0f, 0.5f, 10.0f); +void EnOssan_State_LookToRightShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + Math_ApproachF(&pthis->cameraFaceAngle, -30.0f, 0.5f, 10.0f); - if (this->cameraFaceAngle < -29.5f) { - EnOssan_UpdateCameraDirection(this, globalCtx, -30.0f); + if (pthis->cameraFaceAngle < -29.5f) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, -30.0f); } - EnOssan_UpdateCameraDirection(this, globalCtx, this->cameraFaceAngle); + EnOssan_UpdateCameraDirection(pthis, globalCtx, pthis->cameraFaceAngle); - if (this->cameraFaceAngle <= -30.0f) { - EnOssan_UpdateCameraDirection(this, globalCtx, -30.0f); - EnOssan_UpdateCursorPos(globalCtx, this); - this->stateFlag = OSSAN_STATE_BROWSE_RIGHT_SHELF; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + if (pthis->cameraFaceAngle <= -30.0f) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, -30.0f); + EnOssan_UpdateCursorPos(globalCtx, pthis); + pthis->stateFlag = OSSAN_STATE_BROWSE_RIGHT_SHELF; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); } else { - this->stickAccumX = 0; + pthis->stickAccumX = 0; } } -void EnOssan_CursorUpDown(EnOssan* this) { - u8 curTemp = this->cursorIndex; +void EnOssan_CursorUpDown(EnOssan* pthis) { + u8 curTemp = pthis->cursorIndex; u8 curScanTemp; - if (this->stickAccumY < 0) { + if (pthis->stickAccumY < 0) { curTemp &= 0xFE; - if (this->shelfSlots[curTemp] != NULL) { - this->cursorIndex = curTemp; + if (pthis->shelfSlots[curTemp] != NULL) { + pthis->cursorIndex = curTemp; return; } // cursorIndex on right shelf @@ -1054,8 +1054,8 @@ void EnOssan_CursorUpDown(EnOssan* this) { curScanTemp = 0; } while (curScanTemp != curTemp) { - if (this->shelfSlots[curScanTemp] != NULL) { - this->cursorIndex = curScanTemp; + if (pthis->shelfSlots[curScanTemp] != NULL) { + pthis->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -1070,8 +1070,8 @@ void EnOssan_CursorUpDown(EnOssan* this) { curScanTemp = 4; } while (curScanTemp != curTemp) { - if (this->shelfSlots[curScanTemp] != NULL) { - this->cursorIndex = curScanTemp; + if (pthis->shelfSlots[curScanTemp] != NULL) { + pthis->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -1080,10 +1080,10 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } } - } else if (this->stickAccumY > 0) { + } else if (pthis->stickAccumY > 0) { curTemp |= 1; - if (this->shelfSlots[curTemp] != NULL) { - this->cursorIndex = curTemp; + if (pthis->shelfSlots[curTemp] != NULL) { + pthis->cursorIndex = curTemp; return; } // cursorIndex on right shelf @@ -1093,8 +1093,8 @@ void EnOssan_CursorUpDown(EnOssan* this) { curScanTemp = 1; } while (curScanTemp != curTemp) { - if (this->shelfSlots[curScanTemp] != NULL) { - this->cursorIndex = curScanTemp; + if (pthis->shelfSlots[curScanTemp] != NULL) { + pthis->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -1109,8 +1109,8 @@ void EnOssan_CursorUpDown(EnOssan* this) { curScanTemp = 5; } while (curScanTemp != curTemp) { - if (this->shelfSlots[curScanTemp] != NULL) { - this->cursorIndex = curScanTemp; + if (pthis->shelfSlots[curScanTemp] != NULL) { + pthis->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -1122,18 +1122,18 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } -s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input* input) { - EnGirlA* selectedItem = this->shelfSlots[this->cursorIndex]; +s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* pthis, Input* input) { + EnGirlA* selectedItem = pthis->shelfSlots[pthis->cursorIndex]; - if (EnOssan_TestEndInteraction(this, globalCtx, input)) { + if (EnOssan_TestEndInteraction(pthis, globalCtx, input)) { return true; } if (Message_ShouldAdvance(globalCtx)) { if (selectedItem->actor.params != SI_SOLD_OUT && selectedItem->isInvisible == 0) { - this->tempStateFlag = this->stateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->itemBuyPromptTextId); - this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = false; + pthis->tempStateFlag = pthis->stateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->itemBuyPromptTextId); + pthis->stickLeftPrompt.isEnabled = false; + pthis->stickRightPrompt.isEnabled = false; switch (selectedItem->actor.params) { case SI_KEATON_MASK: case SI_SPOOKY_MASK: @@ -1144,24 +1144,24 @@ s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input case SI_GORON_MASK: case SI_GERUDO_MASK: func_80078884(NA_SE_SY_DECIDE); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_SELECT_ITEM_MASK; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_SELECT_ITEM_MASK; return true; case SI_MILK_BOTTLE: func_80078884(NA_SE_SY_DECIDE); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_SELECT_ITEM_MILK_BOTTLE; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_SELECT_ITEM_MILK_BOTTLE; return true; case SI_WEIRD_EGG: func_80078884(NA_SE_SY_DECIDE); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_SELECT_ITEM_WEIRD_EGG; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_SELECT_ITEM_WEIRD_EGG; return true; case SI_19: case SI_20: func_80078884(NA_SE_SY_ERROR); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_SELECT_ITEM_UNIMPLEMENTED; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_SELECT_ITEM_UNIMPLEMENTED; return true; case SI_BOMBS_5_R25: case SI_BOMBS_10: @@ -1169,13 +1169,13 @@ s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input case SI_BOMBS_30: case SI_BOMBS_5_R35: func_80078884(NA_SE_SY_DECIDE); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_SELECT_ITEM_BOMBS; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_SELECT_ITEM_BOMBS; return true; default: func_80078884(NA_SE_SY_DECIDE); - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_SELECT_ITEM; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_SELECT_ITEM; return true; } } @@ -1185,426 +1185,426 @@ s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input return false; } -void EnOssan_State_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_BrowseLeftShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { s32 a; s32 b; - u8 prevIndex = this->cursorIndex; + u8 prevIndex = pthis->cursorIndex; s32 c; s32 d; - if (!EnOssan_ReturnItemToShelf(this)) { + if (!EnOssan_ReturnItemToShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2152); - this->delayTimer = 3; + pthis->delayTimer = 3; return; } - if (this->delayTimer != 0) { - this->delayTimer--; + if (pthis->delayTimer != 0) { + pthis->delayTimer--; return; } - this->drawCursor = 0xFF; - this->stickRightPrompt.isEnabled = true; - EnOssan_UpdateCursorPos(globalCtx, this); + pthis->drawCursor = 0xFF; + pthis->stickRightPrompt.isEnabled = true; + EnOssan_UpdateCursorPos(globalCtx, pthis); if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && - !EnOssan_HasPlayerSelectedItem(globalCtx, this, &globalCtx->state.input[0])) { - if (this->moveHorizontal) { - if (this->stickAccumX > 0) { - a = EnOssan_CursorRight(this, this->cursorIndex, 4); + !EnOssan_HasPlayerSelectedItem(globalCtx, pthis, &globalCtx->state.input[0])) { + if (pthis->moveHorizontal) { + if (pthis->stickAccumX > 0) { + a = EnOssan_CursorRight(pthis, pthis->cursorIndex, 4); if (a != CURSOR_INVALID) { - this->cursorIndex = a; + pthis->cursorIndex = a; } else { - EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetLookToShopkeeperFromShelf(globalCtx, pthis); return; } - } else if (this->stickAccumX < 0) { - b = EnOssan_CursorLeft(this, this->cursorIndex, 8); + } else if (pthis->stickAccumX < 0) { + b = EnOssan_CursorLeft(pthis, pthis->cursorIndex, 8); if (b != CURSOR_INVALID) { - this->cursorIndex = b; + pthis->cursorIndex = b; } } } else { - if (this->stickAccumX > 0 && this->stickAccumX > 500) { - c = EnOssan_CursorRight(this, this->cursorIndex, 4); + if (pthis->stickAccumX > 0 && pthis->stickAccumX > 500) { + c = EnOssan_CursorRight(pthis, pthis->cursorIndex, 4); if (c != CURSOR_INVALID) { - this->cursorIndex = c; + pthis->cursorIndex = c; } else { - EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetLookToShopkeeperFromShelf(globalCtx, pthis); return; } - } else if (this->stickAccumX < 0 && this->stickAccumX < -500) { - d = EnOssan_CursorLeft(this, this->cursorIndex, 8); + } else if (pthis->stickAccumX < 0 && pthis->stickAccumX < -500) { + d = EnOssan_CursorLeft(pthis, pthis->cursorIndex, 8); if (d != CURSOR_INVALID) { - this->cursorIndex = d; + pthis->cursorIndex = d; } } } - EnOssan_CursorUpDown(this); - if (this->cursorIndex != prevIndex) { - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + EnOssan_CursorUpDown(pthis); + if (pthis->cursorIndex != prevIndex) { + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); func_80078884(NA_SE_SY_CURSOR); } } } -void EnOssan_State_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_BrowseRightShelf(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { s32 pad[2]; u8 prevIndex; u8 nextIndex; - prevIndex = this->cursorIndex; - if (!EnOssan_ReturnItemToShelf(this)) { + prevIndex = pthis->cursorIndex; + if (!EnOssan_ReturnItemToShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2244); - this->delayTimer = 3; + pthis->delayTimer = 3; return; } - if (this->delayTimer != 0) { - this->delayTimer--; + if (pthis->delayTimer != 0) { + pthis->delayTimer--; return; } - this->drawCursor = 0xFF; - this->stickLeftPrompt.isEnabled = true; - EnOssan_UpdateCursorPos(globalCtx, this); + pthis->drawCursor = 0xFF; + pthis->stickLeftPrompt.isEnabled = true; + EnOssan_UpdateCursorPos(globalCtx, pthis); if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && - !EnOssan_HasPlayerSelectedItem(globalCtx, this, &globalCtx->state.input[0])) { - if (this->moveHorizontal) { - if (this->stickAccumX < 0) { - nextIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); + !EnOssan_HasPlayerSelectedItem(globalCtx, pthis, &globalCtx->state.input[0])) { + if (pthis->moveHorizontal) { + if (pthis->stickAccumX < 0) { + nextIndex = EnOssan_CursorRight(pthis, pthis->cursorIndex, 0); if (nextIndex != CURSOR_INVALID) { - this->cursorIndex = nextIndex; + pthis->cursorIndex = nextIndex; } else { - EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetLookToShopkeeperFromShelf(globalCtx, pthis); return; } - } else if (this->stickAccumX > 0) { - nextIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); + } else if (pthis->stickAccumX > 0) { + nextIndex = EnOssan_CursorLeft(pthis, pthis->cursorIndex, 4); if (nextIndex != CURSOR_INVALID) { - this->cursorIndex = nextIndex; + pthis->cursorIndex = nextIndex; } } } else { - if (this->stickAccumX < 0 && this->stickAccumX < -500) { - nextIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); + if (pthis->stickAccumX < 0 && pthis->stickAccumX < -500) { + nextIndex = EnOssan_CursorRight(pthis, pthis->cursorIndex, 0); if (nextIndex != CURSOR_INVALID) { - this->cursorIndex = nextIndex; + pthis->cursorIndex = nextIndex; } else { - EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetLookToShopkeeperFromShelf(globalCtx, pthis); return; } - } else if (this->stickAccumX > 0 && this->stickAccumX > 500) { - nextIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); + } else if (pthis->stickAccumX > 0 && pthis->stickAccumX > 500) { + nextIndex = EnOssan_CursorLeft(pthis, pthis->cursorIndex, 4); if (nextIndex != CURSOR_INVALID) { - this->cursorIndex = nextIndex; + pthis->cursorIndex = nextIndex; } } } - EnOssan_CursorUpDown(this); - if (this->cursorIndex != prevIndex) { - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + EnOssan_CursorUpDown(pthis); + if (pthis->cursorIndex != prevIndex) { + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); func_80078884(NA_SE_SY_CURSOR); } } } -void EnOssan_State_LookFromShelfToShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player) { - Math_ApproachF(&this->cameraFaceAngle, 0.0f, 0.5f, 10.0f); - if ((this->cameraFaceAngle < 0.5f) && (this->cameraFaceAngle > -0.5f)) { - EnOssan_UpdateCameraDirection(this, globalCtx, 0.0f); +void EnOssan_State_LookFromShelfToShopkeeper(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + Math_ApproachF(&pthis->cameraFaceAngle, 0.0f, 0.5f, 10.0f); + if ((pthis->cameraFaceAngle < 0.5f) && (pthis->cameraFaceAngle > -0.5f)) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, 0.0f); } - EnOssan_UpdateCameraDirection(this, globalCtx, this->cameraFaceAngle); - if (this->cameraFaceAngle == 0.0f) { - EnOssan_StartShopping(globalCtx, this); + EnOssan_UpdateCameraDirection(pthis, globalCtx, pthis->cameraFaceAngle); + if (pthis->cameraFaceAngle == 0.0f) { + EnOssan_StartShopping(globalCtx, pthis); } } -void EnOssan_State_DisplayOnlyBombDialog(EnOssan* this, GlobalContext* globalCtx, Player* player) { - if (!EnOssan_ReturnItemToShelf(this)) { +void EnOssan_State_DisplayOnlyBombDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + if (!EnOssan_ReturnItemToShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2355); return; } - Math_ApproachF(&this->cameraFaceAngle, 0.0f, 0.5f, 10.0f); - if (this->cameraFaceAngle < 0.5f && this->cameraFaceAngle > -0.5f) { - EnOssan_UpdateCameraDirection(this, globalCtx, 0.0f); + Math_ApproachF(&pthis->cameraFaceAngle, 0.0f, 0.5f, 10.0f); + if (pthis->cameraFaceAngle < 0.5f && pthis->cameraFaceAngle > -0.5f) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, 0.0f); } - EnOssan_UpdateCameraDirection(this, globalCtx, this->cameraFaceAngle); - if (this->cameraFaceAngle == 0.0f) { + EnOssan_UpdateCameraDirection(pthis, globalCtx, pthis->cameraFaceAngle); + if (pthis->cameraFaceAngle == 0.0f) { Message_ContinueTextbox(globalCtx, 0x3010); - this->stateFlag = OSSAN_STATE_WAIT_FOR_DISPLAY_ONLY_BOMB_DIALOG; + pthis->stateFlag = OSSAN_STATE_WAIT_FOR_DISPLAY_ONLY_BOMB_DIALOG; } } -void EnOssan_GiveItemWithFanfare(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_GiveItemWithFanfare(GlobalContext* globalCtx, EnOssan* pthis) { Player* player = GET_PLAYER(globalCtx); osSyncPrintf("\n" VT_FGCOL(YELLOW) "初めて手にいれた!!" VT_RST "\n\n"); - func_8002F434(&this->actor, globalCtx, this->shelfSlots[this->cursorIndex]->getItemId, 120.0f, 120.0f); + func_8002F434(&pthis->actor, globalCtx, pthis->shelfSlots[pthis->cursorIndex]->getItemId, 120.0f, 120.0f); globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; globalCtx->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; func_800BC490(globalCtx, 1); Interface_ChangeAlpha(50); - this->drawCursor = 0; - EnOssan_UpdateCameraDirection(this, globalCtx, 0.0f); - this->stateFlag = OSSAN_STATE_GIVE_ITEM_FANFARE; + pthis->drawCursor = 0; + EnOssan_UpdateCameraDirection(pthis, globalCtx, 0.0f); + pthis->stateFlag = OSSAN_STATE_GIVE_ITEM_FANFARE; osSyncPrintf(VT_FGCOL(YELLOW) "持ち上げ開始!!" VT_RST "\n\n"); } -void EnOssan_SetStateCantGetItem(GlobalContext* globalCtx, EnOssan* this, u16 textId) { +void EnOssan_SetStateCantGetItem(GlobalContext* globalCtx, EnOssan* pthis, u16 textId) { Message_ContinueTextbox(globalCtx, textId); - this->stateFlag = OSSAN_STATE_CANT_GET_ITEM; + pthis->stateFlag = OSSAN_STATE_CANT_GET_ITEM; } -void EnOssan_SetStateQuickBuyDialog(GlobalContext* globalCtx, EnOssan* this, u16 textId) { +void EnOssan_SetStateQuickBuyDialog(GlobalContext* globalCtx, EnOssan* pthis, u16 textId) { Message_ContinueTextbox(globalCtx, textId); - this->stateFlag = OSSAN_STATE_QUICK_BUY; + pthis->stateFlag = OSSAN_STATE_QUICK_BUY; } -void EnOssan_HandleCanBuyItem(GlobalContext* globalCtx, EnOssan* this) { - EnGirlA* selectedItem = this->shelfSlots[this->cursorIndex]; +void EnOssan_HandleCanBuyItem(GlobalContext* globalCtx, EnOssan* pthis) { + EnGirlA* selectedItem = pthis->shelfSlots[pthis->cursorIndex]; switch (selectedItem->canBuyFunc(globalCtx, selectedItem)) { case CANBUY_RESULT_SUCCESS_FANFARE: if (selectedItem->actor.params == SI_HYLIAN_SHIELD && gSaveContext.infTable[7] & 0x40) { - EnOssan_SetStateGiveDiscountDialog(globalCtx, this); + EnOssan_SetStateGiveDiscountDialog(globalCtx, pthis); } else { - EnOssan_GiveItemWithFanfare(globalCtx, this); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_GiveItemWithFanfare(globalCtx, pthis); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; selectedItem->setOutOfStockFunc(globalCtx, selectedItem); } break; case CANBUY_RESULT_SUCCESS: selectedItem->itemGiveFunc(globalCtx, selectedItem); - EnOssan_SetStateQuickBuyDialog(globalCtx, this, 0x84); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_SetStateQuickBuyDialog(globalCtx, pthis, 0x84); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; selectedItem->setOutOfStockFunc(globalCtx, selectedItem); break; case CANBUY_RESULT_CANT_GET_NOW: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x86); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x86); break; case CANBUY_RESULT_NEED_BOTTLE: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x96); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x96); break; case CANBUY_RESULT_NEED_RUPEES: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x85); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x85); break; case CANBUY_RESULT_CANT_GET_NOW_5: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x86); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x86); break; } } -void EnOssan_HandleCanBuyLonLonMilk(GlobalContext* globalCtx, EnOssan* this) { - EnGirlA* item = this->shelfSlots[this->cursorIndex]; +void EnOssan_HandleCanBuyLonLonMilk(GlobalContext* globalCtx, EnOssan* pthis) { + EnGirlA* item = pthis->shelfSlots[pthis->cursorIndex]; switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_FANFARE: Message_ContinueTextbox(globalCtx, 0x9C); - this->stateFlag = OSSAN_STATE_GIVE_LON_LON_MILK; - this->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_GIVE_LON_LON_MILK; + pthis->drawCursor = 0; break; case CANBUY_RESULT_SUCCESS: item->itemGiveFunc(globalCtx, item); - EnOssan_SetStateQuickBuyDialog(globalCtx, this, 0x98); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_SetStateQuickBuyDialog(globalCtx, pthis, 0x98); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; item->setOutOfStockFunc(globalCtx, item); break; case CANBUY_RESULT_NEED_BOTTLE: - EnOssan_SetStateCantGetItem(globalCtx, this, 0x96); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x96); break; case CANBUY_RESULT_NEED_RUPEES: - EnOssan_SetStateCantGetItem(globalCtx, this, 0x85); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x85); break; } } -void EnOssan_HandleCanBuyWeirdEgg(GlobalContext* globalCtx, EnOssan* this) { - EnGirlA* item = this->shelfSlots[this->cursorIndex]; +void EnOssan_HandleCanBuyWeirdEgg(GlobalContext* globalCtx, EnOssan* pthis) { + EnGirlA* item = pthis->shelfSlots[pthis->cursorIndex]; switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_FANFARE: - EnOssan_GiveItemWithFanfare(globalCtx, this); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_GiveItemWithFanfare(globalCtx, pthis); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; item->setOutOfStockFunc(globalCtx, item); break; case CANBUY_RESULT_SUCCESS: item->itemGiveFunc(globalCtx, item); - EnOssan_SetStateQuickBuyDialog(globalCtx, this, 0x9A); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_SetStateQuickBuyDialog(globalCtx, pthis, 0x9A); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; item->setOutOfStockFunc(globalCtx, item); break; case CANBUY_RESULT_CANT_GET_NOW: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x9D); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x9D); break; case CANBUY_RESULT_NEED_RUPEES: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x85); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x85); break; } } -void EnOssan_HandleCanBuyBombs(GlobalContext* globalCtx, EnOssan* this) { - EnGirlA* item = this->shelfSlots[this->cursorIndex]; +void EnOssan_HandleCanBuyBombs(GlobalContext* globalCtx, EnOssan* pthis) { + EnGirlA* item = pthis->shelfSlots[pthis->cursorIndex]; switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_FANFARE: case CANBUY_RESULT_SUCCESS: item->itemGiveFunc(globalCtx, item); - EnOssan_SetStateQuickBuyDialog(globalCtx, this, 0x84); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_SetStateQuickBuyDialog(globalCtx, pthis, 0x84); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; item->setOutOfStockFunc(globalCtx, item); break; case CANBUY_RESULT_CANT_GET_NOW: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x86); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x86); break; case CANBUY_RESULT_NEED_RUPEES: func_80078884(NA_SE_SY_ERROR); - EnOssan_SetStateCantGetItem(globalCtx, this, 0x85); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x85); break; } } -void EnOssan_BuyGoronCityBombs(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_BuyGoronCityBombs(GlobalContext* globalCtx, EnOssan* pthis) { if (LINK_AGE_IN_YEARS == YEARS_CHILD) { if (!(gSaveContext.eventChkInf[2] & 0x20)) { if (gSaveContext.infTable[15] & 0x1000) { - EnOssan_SetStateCantGetItem(globalCtx, this, 0x302E); + EnOssan_SetStateCantGetItem(globalCtx, pthis, 0x302E); } else { - this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = false; - this->drawCursor = 0; - this->stateFlag = OSSAN_STATE_DISPLAY_ONLY_BOMB_DIALOG; + pthis->stickLeftPrompt.isEnabled = false; + pthis->stickRightPrompt.isEnabled = false; + pthis->drawCursor = 0; + pthis->stateFlag = OSSAN_STATE_DISPLAY_ONLY_BOMB_DIALOG; } } else { - EnOssan_HandleCanBuyBombs(globalCtx, this); + EnOssan_HandleCanBuyBombs(globalCtx, pthis); } } else { - EnOssan_HandleCanBuyBombs(globalCtx, this); + EnOssan_HandleCanBuyBombs(globalCtx, pthis); } } -void EnOssan_State_ItemSelected(EnOssan* this, GlobalContext* globalCtx2, Player* player) { +void EnOssan_State_ItemSelected(EnOssan* pthis, GlobalContext* globalCtx2, Player* player) { GlobalContext* globalCtx = globalCtx2; // Necessary for OKs - if (!EnOssan_TakeItemOffShelf(this)) { + if (!EnOssan_TakeItemOffShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2654); return; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && - !EnOssan_TestCancelOption(this, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { + !EnOssan_TestCancelOption(pthis, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - EnOssan_HandleCanBuyItem(globalCtx, this); + EnOssan_HandleCanBuyItem(globalCtx, pthis); break; case 1: - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); break; } } } -void EnOssan_State_SelectMilkBottle(EnOssan* this, GlobalContext* globalCtx2, Player* player) { +void EnOssan_State_SelectMilkBottle(EnOssan* pthis, GlobalContext* globalCtx2, Player* player) { GlobalContext* globalCtx = globalCtx2; // Need for OK - if (!EnOssan_TakeItemOffShelf(this)) { + if (!EnOssan_TakeItemOffShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2693); return; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && - !EnOssan_TestCancelOption(this, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { + !EnOssan_TestCancelOption(pthis, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - EnOssan_HandleCanBuyLonLonMilk(globalCtx, this); + EnOssan_HandleCanBuyLonLonMilk(globalCtx, pthis); break; case 1: - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); break; } } } -void EnOssan_State_SelectWeirdEgg(EnOssan* this, GlobalContext* globalCtx2, Player* player) { +void EnOssan_State_SelectWeirdEgg(EnOssan* pthis, GlobalContext* globalCtx2, Player* player) { GlobalContext* globalCtx = globalCtx2; // Needed for OK - if (!EnOssan_TakeItemOffShelf(this)) { + if (!EnOssan_TakeItemOffShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2732); return; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && - !EnOssan_TestCancelOption(this, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { + !EnOssan_TestCancelOption(pthis, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - EnOssan_HandleCanBuyWeirdEgg(globalCtx, this); + EnOssan_HandleCanBuyWeirdEgg(globalCtx, pthis); break; case 1: - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); break; } } } -void EnOssan_State_SelectUnimplementedItem(EnOssan* this, GlobalContext* globalCtx, Player* player) { - if (!EnOssan_TakeItemOffShelf(this)) { +void EnOssan_State_SelectUnimplementedItem(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + if (!EnOssan_TakeItemOffShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2771); return; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); } } -void EnOssan_State_SelectBombs(EnOssan* this, GlobalContext* globalCtx, Player* player) { - if (!EnOssan_TakeItemOffShelf(this)) { +void EnOssan_State_SelectBombs(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { + if (!EnOssan_TakeItemOffShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2798); return; } osSyncPrintf("店主の依頼 ( %d )\n", gSaveContext.infTable[15] & 0x1000); - if (this->actor.params != OSSAN_TYPE_GORON) { - EnOssan_State_ItemSelected(this, globalCtx, player); + if (pthis->actor.params != OSSAN_TYPE_GORON) { + EnOssan_State_ItemSelected(pthis, globalCtx, player); return; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && - !EnOssan_TestCancelOption(this, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { + !EnOssan_TestCancelOption(pthis, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - EnOssan_BuyGoronCityBombs(globalCtx, this); + EnOssan_BuyGoronCityBombs(globalCtx, pthis); break; case 1: - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); break; } } } -void EnOssan_State_SelectMaskItem(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_SelectMaskItem(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - EnGirlA* item = this->shelfSlots[this->cursorIndex]; + EnGirlA* item = pthis->shelfSlots[pthis->cursorIndex]; - if (!EnOssan_TakeItemOffShelf(this)) { + if (!EnOssan_TakeItemOffShelf(pthis)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2845); return; } if (talkState == TEXT_STATE_EVENT) { if (Message_ShouldAdvance(globalCtx)) { - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); } } else if (talkState == TEXT_STATE_CHOICE && - !EnOssan_TestCancelOption(this, globalCtx, &globalCtx->state.input[0]) && + !EnOssan_TestCancelOption(pthis, globalCtx, &globalCtx->state.input[0]) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -1627,176 +1627,176 @@ void EnOssan_State_SelectMaskItem(EnOssan* this, GlobalContext* globalCtx, Playe case SI_GERUDO_MASK: break; } - EnOssan_GiveItemWithFanfare(globalCtx, this); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + EnOssan_GiveItemWithFanfare(globalCtx, pthis); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; item->setOutOfStockFunc(globalCtx, item); break; case 1: - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); break; } } } -void EnOssan_State_CantGetItem(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_CantGetItem(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); } } -void EnOssan_State_QuickBuyDialog(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_QuickBuyDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { EnGirlA* item; if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - this->shopItemSelectedTween = 0.0f; - EnOssan_ResetItemPosition(this); - item = this->shelfSlots[this->cursorIndex]; + pthis->shopItemSelectedTween = 0.0f; + EnOssan_ResetItemPosition(pthis); + item = pthis->shelfSlots[pthis->cursorIndex]; item->updateStockedItemFunc(globalCtx, item); - this->stateFlag = this->tempStateFlag; - Message_ContinueTextbox(globalCtx, this->shelfSlots[this->cursorIndex]->actor.textId); + pthis->stateFlag = pthis->tempStateFlag; + Message_ContinueTextbox(globalCtx, pthis->shelfSlots[pthis->cursorIndex]->actor.textId); } } -void EnOssan_State_GiveItemWithFanfare(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_GiveItemWithFanfare(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { // The player sets itself as the parent actor to signal that it has obtained the give item request - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->stateFlag = OSSAN_STATE_ITEM_PURCHASED; + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->stateFlag = OSSAN_STATE_ITEM_PURCHASED; return; } - func_8002F434(&this->actor, globalCtx, this->shelfSlots[this->cursorIndex]->getItemId, 120.0f, 120.0f); + func_8002F434(&pthis->actor, globalCtx, pthis->shelfSlots[pthis->cursorIndex]->getItemId, 120.0f, 120.0f); } -void EnOssan_State_ItemPurchased(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_ItemPurchased(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { EnGirlA* item; EnGirlA* itemTemp; if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - if (this->actor.params == OSSAN_TYPE_MASK) { - itemTemp = this->shelfSlots[this->cursorIndex]; - EnOssan_ResetItemPosition(this); - item = this->shelfSlots[this->cursorIndex]; + if (pthis->actor.params == OSSAN_TYPE_MASK) { + itemTemp = pthis->shelfSlots[pthis->cursorIndex]; + EnOssan_ResetItemPosition(pthis); + item = pthis->shelfSlots[pthis->cursorIndex]; item->updateStockedItemFunc(globalCtx, item); if (itemTemp->actor.params == SI_MASK_OF_TRUTH && !(gSaveContext.itemGetInf[3] & 0x8000)) { gSaveContext.itemGetInf[3] |= 0x8000; Message_ContinueTextbox(globalCtx, 0x70AB); - this->happyMaskShopState = OSSAN_HAPPY_STATE_BORROWED_FIRST_MASK; - EnOssan_UpdateShopOfferings(this, globalCtx); - this->stateFlag = OSSAN_STATE_START_CONVERSATION; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_BORROWED_FIRST_MASK; + EnOssan_UpdateShopOfferings(pthis, globalCtx); + pthis->stateFlag = OSSAN_STATE_START_CONVERSATION; return; } else { - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(globalCtx, pthis); return; } } - item = this->shelfSlots[this->cursorIndex]; + item = pthis->shelfSlots[pthis->cursorIndex]; item->buyEventFunc(globalCtx, item); - this->stateFlag = OSSAN_STATE_CONTINUE_SHOPPING_PROMPT; + pthis->stateFlag = OSSAN_STATE_CONTINUE_SHOPPING_PROMPT; Message_ContinueTextbox(globalCtx, 0x6B); } } -void EnOssan_State_ContinueShoppingPrompt(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_ContinueShoppingPrompt(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { EnGirlA* selectedItem; u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(globalCtx)) { - EnOssan_ResetItemPosition(this); - selectedItem = this->shelfSlots[this->cursorIndex]; + EnOssan_ResetItemPosition(pthis); + selectedItem = pthis->shelfSlots[pthis->cursorIndex]; selectedItem->updateStockedItemFunc(globalCtx, selectedItem); - if (!EnOssan_TestEndInteraction(this, globalCtx, &globalCtx->state.input[0])) { + if (!EnOssan_TestEndInteraction(pthis, globalCtx, &globalCtx->state.input[0])) { switch (globalCtx->msgCtx.choiceIndex) { case 0: osSyncPrintf(VT_FGCOL(YELLOW) "★★★ 続けるよ!! ★★★" VT_RST "\n"); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; func_800BC490(globalCtx, 2); - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - EnOssan_SetStateStartShopping(globalCtx, this, true); - func_8002F298(&this->actor, globalCtx, 100.0f, -1); + Message_StartTextbox(globalCtx, pthis->actor.textId, &pthis->actor); + EnOssan_SetStateStartShopping(globalCtx, pthis, true); + func_8002F298(&pthis->actor, globalCtx, 100.0f, -1); break; case 1: default: osSyncPrintf(VT_FGCOL(YELLOW) "★★★ やめるよ!! ★★★" VT_RST "\n"); - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(globalCtx, pthis); break; } } } } else if (talkState == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - EnOssan_ResetItemPosition(this); - selectedItem = this->shelfSlots[this->cursorIndex]; + EnOssan_ResetItemPosition(pthis); + selectedItem = pthis->shelfSlots[pthis->cursorIndex]; selectedItem->updateStockedItemFunc(globalCtx, selectedItem); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; func_800BC490(globalCtx, 2); - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - EnOssan_SetStateStartShopping(globalCtx, this, true); - func_8002F298(&this->actor, globalCtx, 100.0f, -1); + Message_StartTextbox(globalCtx, pthis->actor.textId, &pthis->actor); + EnOssan_SetStateStartShopping(globalCtx, pthis, true); + func_8002F298(&pthis->actor, globalCtx, 100.0f, -1); } } -void EnOssan_State_WaitForDisplayOnlyBombDialog(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_WaitForDisplayOnlyBombDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { gSaveContext.infTable[15] |= 0x1000; - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(globalCtx, pthis); } } // Unreachable -void EnOssan_State_21(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_21(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE_HAS_NEXT && Message_ShouldAdvance(globalCtx)) { - this->stateFlag = OSSAN_STATE_22; + pthis->stateFlag = OSSAN_STATE_22; Message_ContinueTextbox(globalCtx, 0x3012); gSaveContext.infTable[15] |= 0x1000; } } // Unreachable -void EnOssan_State_22(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_22(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(globalCtx, pthis); } } -void EnOssan_State_GiveLonLonMilk(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_GiveLonLonMilk(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - EnOssan_GiveItemWithFanfare(globalCtx, this); + EnOssan_GiveItemWithFanfare(globalCtx, pthis); } } // For giving Mask of Truth when you first sell all masks -void EnOssan_State_LendMaskOfTruth(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_LendMaskOfTruth(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { gSaveContext.itemGetInf[2] |= 0x400; - this->cursorIndex = 2; - EnOssan_GiveItemWithFanfare(globalCtx, this); + pthis->cursorIndex = 2; + EnOssan_GiveItemWithFanfare(globalCtx, pthis); } } // Hylian Shield discount dialog -void EnOssan_SetStateGiveDiscountDialog(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_SetStateGiveDiscountDialog(GlobalContext* globalCtx, EnOssan* pthis) { Message_ContinueTextbox(globalCtx, 0x71B2); - this->stateFlag = OSSAN_STATE_DISCOUNT_DIALOG; + pthis->stateFlag = OSSAN_STATE_DISCOUNT_DIALOG; } -void EnOssan_State_GiveDiscountDialog(EnOssan* this, GlobalContext* globalCtx, Player* player) { +void EnOssan_State_GiveDiscountDialog(EnOssan* pthis, GlobalContext* globalCtx, Player* player) { EnGirlA* selectedItem; if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - selectedItem = this->shelfSlots[this->cursorIndex]; - EnOssan_GiveItemWithFanfare(globalCtx, this); - this->drawCursor = 0; - this->shopItemSelectedTween = 0.0f; + selectedItem = pthis->shelfSlots[pthis->cursorIndex]; + EnOssan_GiveItemWithFanfare(globalCtx, pthis); + pthis->drawCursor = 0; + pthis->shopItemSelectedTween = 0.0f; selectedItem->setOutOfStockFunc(globalCtx, selectedItem); } } -void EnOssan_PositionSelectedItem(EnOssan* this) { +void EnOssan_PositionSelectedItem(EnOssan* pthis) { EnGirlA* item; u8 i; u8 i2; @@ -1805,33 +1805,33 @@ void EnOssan_PositionSelectedItem(EnOssan* this) { f32 ty; f32 tz; - i = this->cursorIndex; - shopItem = &sShopkeeperStores[this->actor.params][i]; - item = this->shelfSlots[i]; + i = pthis->cursorIndex; + shopItem = &sShopkeeperStores[pthis->actor.params][i]; + item = pthis->shelfSlots[i]; i2 = i >> 2; - tx = (sSelectedItemPosition[i2].x - shopItem->xOffset) * this->shopItemSelectedTween + shopItem->xOffset; - ty = (sSelectedItemPosition[i2].y - shopItem->yOffset) * this->shopItemSelectedTween + shopItem->yOffset; - tz = (sSelectedItemPosition[i2].z - shopItem->zOffset) * this->shopItemSelectedTween + shopItem->zOffset; + tx = (sSelectedItemPosition[i2].x - shopItem->xOffset) * pthis->shopItemSelectedTween + shopItem->xOffset; + ty = (sSelectedItemPosition[i2].y - shopItem->yOffset) * pthis->shopItemSelectedTween + shopItem->yOffset; + tz = (sSelectedItemPosition[i2].z - shopItem->zOffset) * pthis->shopItemSelectedTween + shopItem->zOffset; - item->actor.world.pos.x = this->shelves->actor.world.pos.x + tx; - item->actor.world.pos.y = this->shelves->actor.world.pos.y + ty; - item->actor.world.pos.z = this->shelves->actor.world.pos.z + tz; + item->actor.world.pos.x = pthis->shelves->actor.world.pos.x + tx; + item->actor.world.pos.y = pthis->shelves->actor.world.pos.y + ty; + item->actor.world.pos.z = pthis->shelves->actor.world.pos.z + tz; } -void EnOssan_ResetItemPosition(EnOssan* this) { - this->shopItemSelectedTween = 0.0f; - EnOssan_PositionSelectedItem(this); +void EnOssan_ResetItemPosition(EnOssan* pthis) { + pthis->shopItemSelectedTween = 0.0f; + EnOssan_PositionSelectedItem(pthis); } // returns true if animation has completed -s32 EnOssan_TakeItemOffShelf(EnOssan* this) { - Math_ApproachF(&this->shopItemSelectedTween, 1.0f, 1.0f, 0.15f); - if (this->shopItemSelectedTween >= 0.85f) { - this->shopItemSelectedTween = 1.0f; +s32 EnOssan_TakeItemOffShelf(EnOssan* pthis) { + Math_ApproachF(&pthis->shopItemSelectedTween, 1.0f, 1.0f, 0.15f); + if (pthis->shopItemSelectedTween >= 0.85f) { + pthis->shopItemSelectedTween = 1.0f; } - EnOssan_PositionSelectedItem(this); - if (this->shopItemSelectedTween == 1.0f) { + EnOssan_PositionSelectedItem(pthis); + if (pthis->shopItemSelectedTween == 1.0f) { return true; } else { return false; @@ -1839,33 +1839,33 @@ s32 EnOssan_TakeItemOffShelf(EnOssan* this) { } // returns true if animation has completed -s32 EnOssan_ReturnItemToShelf(EnOssan* this) { - Math_ApproachF(&this->shopItemSelectedTween, 0.0f, 1.0f, 0.15f); - if (this->shopItemSelectedTween <= 0.15f) { - this->shopItemSelectedTween = 0.0f; +s32 EnOssan_ReturnItemToShelf(EnOssan* pthis) { + Math_ApproachF(&pthis->shopItemSelectedTween, 0.0f, 1.0f, 0.15f); + if (pthis->shopItemSelectedTween <= 0.15f) { + pthis->shopItemSelectedTween = 0.0f; } - EnOssan_PositionSelectedItem(this); - if (this->shopItemSelectedTween == 0.0f) { + EnOssan_PositionSelectedItem(pthis); + if (pthis->shopItemSelectedTween == 0.0f) { return true; } else { return false; } } -void EnOssan_UpdateItemSelectedProperty(EnOssan* this) { - EnGirlA** temp_a1 = this->shelfSlots; +void EnOssan_UpdateItemSelectedProperty(EnOssan* pthis) { + EnGirlA** temp_a1 = pthis->shelfSlots; s32 i; for (i = 0; i < 8; i++) { if (temp_a1[0] != NULL) { - if (this->stateFlag != OSSAN_STATE_SELECT_ITEM && this->stateFlag != OSSAN_STATE_SELECT_ITEM_MILK_BOTTLE && - this->stateFlag != OSSAN_STATE_SELECT_ITEM_WEIRD_EGG && - this->stateFlag != OSSAN_STATE_SELECT_ITEM_UNIMPLEMENTED && - this->stateFlag != OSSAN_STATE_SELECT_ITEM_BOMBS && this->stateFlag != OSSAN_STATE_SELECT_ITEM_MASK && - this->stateFlag != OSSAN_STATE_CANT_GET_ITEM && this->drawCursor == 0) { + if (pthis->stateFlag != OSSAN_STATE_SELECT_ITEM && pthis->stateFlag != OSSAN_STATE_SELECT_ITEM_MILK_BOTTLE && + pthis->stateFlag != OSSAN_STATE_SELECT_ITEM_WEIRD_EGG && + pthis->stateFlag != OSSAN_STATE_SELECT_ITEM_UNIMPLEMENTED && + pthis->stateFlag != OSSAN_STATE_SELECT_ITEM_BOMBS && pthis->stateFlag != OSSAN_STATE_SELECT_ITEM_MASK && + pthis->stateFlag != OSSAN_STATE_CANT_GET_ITEM && pthis->drawCursor == 0) { temp_a1[0]->isSelected = false; } else { - if (this->cursorIndex == i) { + if (pthis->cursorIndex == i) { temp_a1[0]->isSelected = true; } else { temp_a1[0]->isSelected = false; @@ -1876,122 +1876,122 @@ void EnOssan_UpdateItemSelectedProperty(EnOssan* this) { } } -void EnOssan_UpdateCursorAnim(EnOssan* this) { +void EnOssan_UpdateCursorAnim(EnOssan* pthis) { f32 t; - t = this->cursorAnimTween; - if (this->cursorAnimState == 0) { + t = pthis->cursorAnimTween; + if (pthis->cursorAnimState == 0) { t += 0.05f; if (t >= 1.0f) { t = 1.0f; - this->cursorAnimState = 1; + pthis->cursorAnimState = 1; } } else { t -= 0.05f; if (t <= 0.0f) { t = 0.0f; - this->cursorAnimState = 0; + pthis->cursorAnimState = 0; } } - this->cursorColorR = ColChanMix(0, 0.0f, t); - this->cursorColorG = ColChanMix(80, 0.0f, t); - this->cursorColorB = ColChanMix(255, 80.0f, t); - this->cursorColorA = ColChanMix(255, 0.0f, t); - this->cursorAnimTween = t; + pthis->cursorColorR = ColChanMix(0, 0.0f, t); + pthis->cursorColorG = ColChanMix(80, 0.0f, t); + pthis->cursorColorB = ColChanMix(255, 80.0f, t); + pthis->cursorColorA = ColChanMix(255, 0.0f, t); + pthis->cursorAnimTween = t; } -void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { +void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* pthis) { f32 arrowAnimTween; f32 new_var3; // likely fake temp s32 new_var2 = 255; // likely fake temp f32 stickAnimTween; - arrowAnimTween = this->arrowAnimTween; - stickAnimTween = this->stickAnimTween; - if (this->arrowAnimState == 0) { + arrowAnimTween = pthis->arrowAnimTween; + stickAnimTween = pthis->stickAnimTween; + if (pthis->arrowAnimState == 0) { arrowAnimTween += 0.05f; if (arrowAnimTween > 1.0f) { arrowAnimTween = 1.0f; - this->arrowAnimState = 1; + pthis->arrowAnimState = 1; } } else { arrowAnimTween -= 0.05f; if (arrowAnimTween < 0.0f) { arrowAnimTween = 0.0f; - this->arrowAnimState = 0; + pthis->arrowAnimState = 0; } } - this->arrowAnimTween = arrowAnimTween; - if (this->stickAnimState == 0) { + pthis->arrowAnimTween = arrowAnimTween; + if (pthis->stickAnimState == 0) { stickAnimTween += 0.1f; if (stickAnimTween > 1.0f) { stickAnimTween = 1.0f; - this->stickAnimState = 1; + pthis->stickAnimState = 1; } } else { stickAnimTween = 0.0f; - this->stickAnimState = 0; + pthis->stickAnimState = 0; } - this->stickAnimTween = stickAnimTween; - this->stickLeftPrompt.arrowColorR = (u8)(255 - ((s32)(155.0f * arrowAnimTween))); - this->stickLeftPrompt.arrowColorG = (u8)(new_var2 - (s32)(155.0f * arrowAnimTween)); + pthis->stickAnimTween = stickAnimTween; + pthis->stickLeftPrompt.arrowColorR = (u8)(255 - ((s32)(155.0f * arrowAnimTween))); + pthis->stickLeftPrompt.arrowColorG = (u8)(new_var2 - (s32)(155.0f * arrowAnimTween)); new_var3 = (155.0f * arrowAnimTween); - this->stickLeftPrompt.arrowColorB = (u8)(0 - ((s32)((-100.0f) * arrowAnimTween))); - this->stickLeftPrompt.arrowColorA = (u8)(200 - ((s32)(50.0f * arrowAnimTween))); - this->stickRightPrompt.arrowColorR = (u8)(new_var2 - (s32)new_var3); - this->stickRightPrompt.arrowColorG = (u8)(255 - (s32)new_var3); - this->stickRightPrompt.arrowColorB = (u8)(0 - ((s32)((-100.0f) * arrowAnimTween))); - this->stickRightPrompt.arrowColorA = (u8)(200 - ((s32)(50.0f * arrowAnimTween))); - this->stickRightPrompt.arrowTexX = 290.0f; - this->stickLeftPrompt.arrowTexX = 33.0f; - this->stickRightPrompt.stickTexX = 274.0f; - this->stickLeftPrompt.stickTexX = 49.0f; - this->stickRightPrompt.stickTexX += (8.0f * stickAnimTween); - this->stickLeftPrompt.stickTexX -= (8.0f * stickAnimTween); - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + pthis->stickLeftPrompt.arrowColorB = (u8)(0 - ((s32)((-100.0f) * arrowAnimTween))); + pthis->stickLeftPrompt.arrowColorA = (u8)(200 - ((s32)(50.0f * arrowAnimTween))); + pthis->stickRightPrompt.arrowColorR = (u8)(new_var2 - (s32)new_var3); + pthis->stickRightPrompt.arrowColorG = (u8)(255 - (s32)new_var3); + pthis->stickRightPrompt.arrowColorB = (u8)(0 - ((s32)((-100.0f) * arrowAnimTween))); + pthis->stickRightPrompt.arrowColorA = (u8)(200 - ((s32)(50.0f * arrowAnimTween))); + pthis->stickRightPrompt.arrowTexX = 290.0f; + pthis->stickLeftPrompt.arrowTexX = 33.0f; + pthis->stickRightPrompt.stickTexX = 274.0f; + pthis->stickLeftPrompt.stickTexX = 49.0f; + pthis->stickRightPrompt.stickTexX += (8.0f * stickAnimTween); + pthis->stickLeftPrompt.stickTexX -= (8.0f * stickAnimTween); + pthis->stickLeftPrompt.arrowTexY = pthis->stickRightPrompt.arrowTexY = 91.0f; + pthis->stickLeftPrompt.stickTexY = pthis->stickRightPrompt.stickTexY = 95.0f; } -void EnOssan_WaitForBlink(EnOssan* this) { - s16 decr = this->blinkTimer - 1; +void EnOssan_WaitForBlink(EnOssan* pthis) { + s16 decr = pthis->blinkTimer - 1; if (decr != 0) { - this->blinkTimer = decr; + pthis->blinkTimer = decr; } else { - this->blinkFunc = EnOssan_Blink; + pthis->blinkFunc = EnOssan_Blink; } } -void EnOssan_Blink(EnOssan* this) { +void EnOssan_Blink(EnOssan* pthis) { s16 decr; s16 eyeTextureIdxTemp; - decr = this->blinkTimer - 1; + decr = pthis->blinkTimer - 1; if (decr != 0) { - this->blinkTimer = decr; + pthis->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTextureIdx + 1; + eyeTextureIdxTemp = pthis->eyeTextureIdx + 1; if (eyeTextureIdxTemp > 2) { - this->eyeTextureIdx = 0; - this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; - this->blinkFunc = EnOssan_WaitForBlink; + pthis->eyeTextureIdx = 0; + pthis->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; + pthis->blinkFunc = EnOssan_WaitForBlink; } else { - this->eyeTextureIdx = eyeTextureIdxTemp; - this->blinkTimer = 1; + pthis->eyeTextureIdx = eyeTextureIdxTemp; + pthis->blinkTimer = 1; } } -s32 EnOssan_AreShopkeeperObjectsLoaded(EnOssan* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex1)) { - if (this->objBankIndex2 >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex2)) { +s32 EnOssan_AreShopkeeperObjectsLoaded(EnOssan* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex1)) { + if (pthis->objBankIndex2 >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex2)) { return false; } - if (this->objBankIndex3 >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex3)) { + if (pthis->objBankIndex3 >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex3)) { return false; } return true; @@ -1999,68 +1999,68 @@ s32 EnOssan_AreShopkeeperObjectsLoaded(EnOssan* this, GlobalContext* globalCtx) return false; } -void EnOssan_InitBazaarShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectOssanSkel, &gObjectOssanAnim_000338, NULL, NULL, 0); - this->actor.draw = EnOssan_DrawBazaarShopkeeper; - this->obj3ToSeg6Func = NULL; +void EnOssan_InitBazaarShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gObjectOssanSkel, &gObjectOssanAnim_000338, NULL, NULL, 0); + pthis->actor.draw = EnOssan_DrawBazaarShopkeeper; + pthis->obj3ToSeg6Func = NULL; } -void EnOssan_InitKokiriShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gKm1Skel, NULL, NULL, NULL, 0); - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[this->objBankIndex3].vromStart); - Animation_Change(&this->skelAnime, &object_masterkokiri_Anim_0004A8, 1.0f, 0.0f, +void EnOssan_InitKokiriShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gKm1Skel, NULL, NULL, NULL, 0); + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[pthis->objBankIndex3].vromStart.get()); + Animation_Change(&pthis->skelAnime, &object_masterkokiri_Anim_0004A8, 1.0f, 0.0f, Animation_GetLastFrame(&object_masterkokiri_Anim_0004A8), 0, 0.0f); - this->actor.draw = EnOssan_DrawKokiriShopkeeper; - this->obj3ToSeg6Func = EnOssan_Obj3ToSeg6; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); + pthis->actor.draw = EnOssan_DrawKokiriShopkeeper; + pthis->obj3ToSeg6Func = EnOssan_Obj3ToSeg6; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); } -void EnOssan_InitGoronShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, NULL, NULL, 0); - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[this->objBankIndex3].vromStart); - Animation_Change(&this->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), +void EnOssan_InitGoronShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gGoronSkel, NULL, NULL, NULL, 0); + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[pthis->objBankIndex3].vromStart.get()); + Animation_Change(&pthis->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), 0, 0.0f); - this->actor.draw = EnOssan_DrawGoronShopkeeper; - this->obj3ToSeg6Func = EnOssan_Obj3ToSeg6; + pthis->actor.draw = EnOssan_DrawGoronShopkeeper; + pthis->obj3ToSeg6Func = EnOssan_Obj3ToSeg6; } -void EnOssan_InitZoraShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, NULL, NULL, 0); - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[this->objBankIndex3].vromStart); - Animation_Change(&this->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), +void EnOssan_InitZoraShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gZoraSkel, NULL, NULL, NULL, 0); + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[pthis->objBankIndex3].vromStart.get()); + Animation_Change(&pthis->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), 0, 0.0f); - this->actor.draw = EnOssan_DrawZoraShopkeeper; - this->obj3ToSeg6Func = EnOssan_Obj3ToSeg6; + pthis->actor.draw = EnOssan_DrawZoraShopkeeper; + pthis->obj3ToSeg6Func = EnOssan_Obj3ToSeg6; } -void EnOssan_InitPotionShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ds2_Skel_004258, &object_ds2_Anim_0002E4, 0, 0, 0); - this->actor.draw = EnOssan_DrawPotionShopkeeper; - this->obj3ToSeg6Func = NULL; +void EnOssan_InitPotionShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ds2_Skel_004258, &object_ds2_Anim_0002E4, 0, 0, 0); + pthis->actor.draw = EnOssan_DrawPotionShopkeeper; + pthis->obj3ToSeg6Func = NULL; } -void EnOssan_InitHappyMaskShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_os_Skel_004658, &object_os_Anim_0002E4, NULL, NULL, 0); - this->actor.draw = EnOssan_DrawHappyMaskShopkeeper; - this->obj3ToSeg6Func = NULL; +void EnOssan_InitHappyMaskShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_os_Skel_004658, &object_os_Anim_0002E4, NULL, NULL, 0); + pthis->actor.draw = EnOssan_DrawHappyMaskShopkeeper; + pthis->obj3ToSeg6Func = NULL; } -void EnOssan_InitBombchuShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_004868, &object_rs_Anim_00065C, 0, 0, 0); - this->actor.draw = EnOssan_DrawBombchuShopkeeper; - this->obj3ToSeg6Func = NULL; +void EnOssan_InitBombchuShopkeeper(EnOssan* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_rs_Skel_004868, &object_rs_Anim_00065C, 0, 0, 0); + pthis->actor.draw = EnOssan_DrawBombchuShopkeeper; + pthis->obj3ToSeg6Func = NULL; } -u16 EnOssan_SetupHelloDialog(EnOssan* this) { - this->happyMaskShopState = OSSAN_HAPPY_STATE_NONE; +u16 EnOssan_SetupHelloDialog(EnOssan* pthis) { + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_NONE; // mask shop messages - if (this->actor.params == OSSAN_TYPE_MASK) { + if (pthis->actor.params == OSSAN_TYPE_MASK) { if (INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_SOLD_OUT) { if (gSaveContext.itemGetInf[3] & 0x800) { if (!(gSaveContext.eventChkInf[8] & 0x8000)) { // Pay back Bunny Hood - this->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_BUNNY_HOOD; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_BUNNY_HOOD; return 0x70C6; } else { return 0x70AC; @@ -2069,7 +2069,7 @@ u16 EnOssan_SetupHelloDialog(EnOssan* this) { if (gSaveContext.itemGetInf[3] & 0x400) { if (!(gSaveContext.eventChkInf[8] & 0x4000)) { // Pay back Spooky Mask - this->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SPOOKY_MASK; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SPOOKY_MASK; return 0x70C5; } else { return 0x70AC; @@ -2078,7 +2078,7 @@ u16 EnOssan_SetupHelloDialog(EnOssan* this) { if (gSaveContext.itemGetInf[3] & 0x200) { if (!(gSaveContext.eventChkInf[8] & 0x2000)) { // Pay back Skull Mask - this->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SKULL_MASK; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_SKULL_MASK; return 0x70C4; } else { return 0x70AC; @@ -2087,7 +2087,7 @@ u16 EnOssan_SetupHelloDialog(EnOssan* this) { if (gSaveContext.itemGetInf[3] & 0x100) { if (!(gSaveContext.eventChkInf[8] & 0x1000)) { // Pay back Keaton Mask - this->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_KEATON_MASK; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_REQUEST_PAYMENT_KEATON_MASK; return 0x70A5; } else { return 0x70AC; @@ -2103,7 +2103,7 @@ u16 EnOssan_SetupHelloDialog(EnOssan* this) { return 0x70A1; } else { // Haven't sold the Keaton Mask - this->happyMaskShopState = OSSAN_HAPPY_STATE_BORROWED_FIRST_MASK; + pthis->happyMaskShopState = OSSAN_HAPPY_STATE_BORROWED_FIRST_MASK; return 0x70A6; } } else { @@ -2115,17 +2115,17 @@ u16 EnOssan_SetupHelloDialog(EnOssan* this) { return 0x9E; } -void EnOssan_InitActionFunc(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_InitActionFunc(EnOssan* pthis, GlobalContext* globalCtx) { ShopItem* items; - if (EnOssan_AreShopkeeperObjectsLoaded(this, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_4; - this->actor.objBankIndex = this->objBankIndex1; - Actor_SetObjectDependency(globalCtx, &this->actor); + if (EnOssan_AreShopkeeperObjectsLoaded(pthis, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->actor.objBankIndex = pthis->objBankIndex1; + Actor_SetObjectDependency(globalCtx, &pthis->actor); - this->shelves = (EnTana*)Actor_Find(&globalCtx->actorCtx, ACTOR_EN_TANA, ACTORCAT_PROP); + pthis->shelves = (EnTana*)Actor_Find(&globalCtx->actorCtx, ACTOR_EN_TANA, ACTORCAT_PROP); - if (this->shelves == NULL) { + if (pthis->shelves == NULL) { osSyncPrintf(VT_COL(RED, WHITE)); // "Warning!! There are no shelves!!" osSyncPrintf("★★★ 警告!! 棚がないよ!! ★★★\n"); @@ -2134,130 +2134,130 @@ void EnOssan_InitActionFunc(EnOssan* this, GlobalContext* globalCtx) { } // "Shopkeeper (params) init" - osSyncPrintf(VT_FGCOL(YELLOW) "◇◇◇ 店のおやじ( %d ) 初期設定 ◇◇◇" VT_RST "\n", this->actor.params); + osSyncPrintf(VT_FGCOL(YELLOW) "◇◇◇ 店のおやじ( %d ) 初期設定 ◇◇◇" VT_RST "\n", pthis->actor.params); - this->actor.world.pos.x += sShopkeeperPositionOffsets[this->actor.params].x; - this->actor.world.pos.y += sShopkeeperPositionOffsets[this->actor.params].y; - this->actor.world.pos.z += sShopkeeperPositionOffsets[this->actor.params].z; + pthis->actor.world.pos.x += sShopkeeperPositionOffsets[pthis->actor.params].x; + pthis->actor.world.pos.y += sShopkeeperPositionOffsets[pthis->actor.params].y; + pthis->actor.world.pos.z += sShopkeeperPositionOffsets[pthis->actor.params].z; - items = sShopkeeperStores[this->actor.params]; + items = sShopkeeperStores[pthis->actor.params]; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - sInitFuncs[this->actor.params](this, globalCtx); - this->actor.textId = EnOssan_SetupHelloDialog(this); - this->cursorY = this->cursorX = 100.0f; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.colChkInfo.cylRadius = 50; - this->stateFlag = OSSAN_STATE_IDLE; - this->stickAccumX = this->stickAccumY = 0; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + sInitFuncs[pthis->actor.params](pthis, globalCtx); + pthis->actor.textId = EnOssan_SetupHelloDialog(pthis); + pthis->cursorY = pthis->cursorX = 100.0f; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.colChkInfo.cylRadius = 50; + pthis->stateFlag = OSSAN_STATE_IDLE; + pthis->stickAccumX = pthis->stickAccumY = 0; - this->cursorIndex = 0; - this->cursorZ = 1.5f; - this->cursorColorR = 0; - this->cursorColorG = 255; - this->cursorColorB = 80; - this->cursorColorA = 255; - this->cursorAnimTween = 0; + pthis->cursorIndex = 0; + pthis->cursorZ = 1.5f; + pthis->cursorColorR = 0; + pthis->cursorColorG = 255; + pthis->cursorColorB = 80; + pthis->cursorColorA = 255; + pthis->cursorAnimTween = 0; - this->cursorAnimState = 0; - this->drawCursor = 0; - this->happyMaskShopkeeperEyeIdx = 0; + pthis->cursorAnimState = 0; + pthis->drawCursor = 0; + pthis->happyMaskShopkeeperEyeIdx = 0; - this->stickLeftPrompt.stickColorR = 200; - this->stickLeftPrompt.stickColorG = 200; - this->stickLeftPrompt.stickColorB = 200; - this->stickLeftPrompt.stickColorA = 180; - this->stickLeftPrompt.stickTexX = 49; - this->stickLeftPrompt.stickTexY = 95; - this->stickLeftPrompt.arrowColorR = 255; - this->stickLeftPrompt.arrowColorG = 255; - this->stickLeftPrompt.arrowColorB = 0; - this->stickLeftPrompt.arrowColorA = 200; - this->stickLeftPrompt.arrowTexX = 33; - this->stickLeftPrompt.arrowTexY = 91; - this->stickLeftPrompt.z = 1; - this->stickLeftPrompt.isEnabled = false; + pthis->stickLeftPrompt.stickColorR = 200; + pthis->stickLeftPrompt.stickColorG = 200; + pthis->stickLeftPrompt.stickColorB = 200; + pthis->stickLeftPrompt.stickColorA = 180; + pthis->stickLeftPrompt.stickTexX = 49; + pthis->stickLeftPrompt.stickTexY = 95; + pthis->stickLeftPrompt.arrowColorR = 255; + pthis->stickLeftPrompt.arrowColorG = 255; + pthis->stickLeftPrompt.arrowColorB = 0; + pthis->stickLeftPrompt.arrowColorA = 200; + pthis->stickLeftPrompt.arrowTexX = 33; + pthis->stickLeftPrompt.arrowTexY = 91; + pthis->stickLeftPrompt.z = 1; + pthis->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.stickColorR = 200; - this->stickRightPrompt.stickColorG = 200; - this->stickRightPrompt.stickColorB = 200; - this->stickRightPrompt.stickColorA = 180; - this->stickRightPrompt.stickTexX = 274; - this->stickRightPrompt.stickTexY = 95; - this->stickRightPrompt.arrowColorR = 255; - this->stickRightPrompt.arrowColorG = 255; - this->stickRightPrompt.arrowColorB = 0; - this->stickRightPrompt.arrowColorA = 200; - this->stickRightPrompt.arrowTexX = 290; - this->stickRightPrompt.arrowTexY = 91; - this->stickRightPrompt.z = 1; - this->stickRightPrompt.isEnabled = false; + pthis->stickRightPrompt.stickColorR = 200; + pthis->stickRightPrompt.stickColorG = 200; + pthis->stickRightPrompt.stickColorB = 200; + pthis->stickRightPrompt.stickColorA = 180; + pthis->stickRightPrompt.stickTexX = 274; + pthis->stickRightPrompt.stickTexY = 95; + pthis->stickRightPrompt.arrowColorR = 255; + pthis->stickRightPrompt.arrowColorG = 255; + pthis->stickRightPrompt.arrowColorB = 0; + pthis->stickRightPrompt.arrowColorA = 200; + pthis->stickRightPrompt.arrowTexX = 290; + pthis->stickRightPrompt.arrowTexY = 91; + pthis->stickRightPrompt.z = 1; + pthis->stickRightPrompt.isEnabled = false; - this->arrowAnimState = 0; - this->stickAnimState = 0; - this->arrowAnimTween = 0; - this->stickAnimTween = 0; - this->shopItemSelectedTween = 0; - Actor_SetScale(&this->actor, sShopkeeperScale[this->actor.params]); - EnOssan_SpawnItemsOnShelves(this, globalCtx, items); - this->headRot = this->headTargetRot = 0; - this->blinkTimer = 20; - this->eyeTextureIdx = 0; - this->blinkFunc = EnOssan_WaitForBlink; - this->actor.flags &= ~ACTOR_FLAG_0; - EnOssan_SetupAction(this, EnOssan_MainActionFunc); + pthis->arrowAnimState = 0; + pthis->stickAnimState = 0; + pthis->arrowAnimTween = 0; + pthis->stickAnimTween = 0; + pthis->shopItemSelectedTween = 0; + Actor_SetScale(&pthis->actor, sShopkeeperScale[pthis->actor.params]); + EnOssan_SpawnItemsOnShelves(pthis, globalCtx, items); + pthis->headRot = pthis->headTargetRot = 0; + pthis->blinkTimer = 20; + pthis->eyeTextureIdx = 0; + pthis->blinkFunc = EnOssan_WaitForBlink; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnOssan_SetupAction(pthis, EnOssan_MainActionFunc); } } -void EnOssan_Obj3ToSeg6(EnOssan* this, GlobalContext* globalCtx) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndex3].vromStart); +void EnOssan_Obj3ToSeg6(EnOssan* pthis, GlobalContext* globalCtx) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndex3].vromStart.get()); } -void EnOssan_MainActionFunc(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_MainActionFunc(EnOssan* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->blinkFunc(this); - EnOssan_UpdateJoystickInputState(globalCtx, this); - EnOssan_UpdateItemSelectedProperty(this); - EnOssan_UpdateStickDirectionPromptAnim(this); - EnOssan_UpdateCursorAnim(this); - Math_StepToS(&this->headRot, this->headTargetRot, 0x190); + pthis->blinkFunc(pthis); + EnOssan_UpdateJoystickInputState(globalCtx, pthis); + EnOssan_UpdateItemSelectedProperty(pthis); + EnOssan_UpdateStickDirectionPromptAnim(pthis); + EnOssan_UpdateCursorAnim(pthis); + Math_StepToS(&pthis->headRot, pthis->headTargetRot, 0x190); if (player != NULL) { - sStateFunc[this->stateFlag](this, globalCtx, player); + sStateFunc[pthis->stateFlag](pthis, globalCtx, player); } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); - Actor_SetFocus(&this->actor, 90.0f); - Actor_SetScale(&this->actor, sShopkeeperScale[this->actor.params]); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 26.0f, 10.0f, 0.0f, 5); + Actor_SetFocus(&pthis->actor, 90.0f); + Actor_SetScale(&pthis->actor, sShopkeeperScale[pthis->actor.params]); // use animation object if needed - if (this->obj3ToSeg6Func != NULL) { - this->obj3ToSeg6Func(this, globalCtx); + if (pthis->obj3ToSeg6Func != NULL) { + pthis->obj3ToSeg6Func(pthis, globalCtx); } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); } void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; - this->timer++; - this->actionFunc(this, globalCtx); + pthis->timer++; + pthis->actionFunc(pthis, globalCtx); } s32 EnOssan_OverrideLimbDrawDefaultShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; if (limbIndex == 8) { - rot->x += this->headRot; + rot->x += pthis->headRot; } return 0; } -void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { +void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* pthis, f32 x, f32 y, f32 z, u8 drawCursor) { s32 ulx, uly, lrx, lry; f32 w; s32 dsdx; @@ -2265,8 +2265,8 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4192); if (drawCursor != 0) { func_80094520(globalCtx->state.gfxCtx); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColorR, this->cursorColorG, this->cursorColorB, - this->cursorColorA); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, pthis->cursorColorR, pthis->cursorColorG, pthis->cursorColorB, + pthis->cursorColorA); gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; @@ -2305,9 +2305,9 @@ void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4242); } -void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) { - s32 drawStickLeftPrompt = this->stickLeftPrompt.isEnabled; - s32 drawStickRightPrompt = this->stickRightPrompt.isEnabled; +void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* pthis) { + s32 drawStickLeftPrompt = pthis->stickLeftPrompt.isEnabled; + s32 drawStickRightPrompt = pthis->stickRightPrompt.isEnabled; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4252); if (drawStickLeftPrompt || drawStickRightPrompt) { @@ -2317,31 +2317,31 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); if (drawStickLeftPrompt) { - EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColorR, this->stickLeftPrompt.arrowColorG, - this->stickLeftPrompt.arrowColorB, this->stickLeftPrompt.arrowColorA, - this->stickLeftPrompt.arrowTexX, this->stickLeftPrompt.arrowTexY, - this->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); + EnOssan_DrawTextRec(globalCtx, pthis->stickLeftPrompt.arrowColorR, pthis->stickLeftPrompt.arrowColorG, + pthis->stickLeftPrompt.arrowColorB, pthis->stickLeftPrompt.arrowColorA, + pthis->stickLeftPrompt.arrowTexX, pthis->stickLeftPrompt.arrowTexY, + pthis->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); } if (drawStickRightPrompt) { - EnOssan_DrawTextRec(globalCtx, this->stickRightPrompt.arrowColorR, this->stickRightPrompt.arrowColorG, - this->stickRightPrompt.arrowColorB, this->stickRightPrompt.arrowColorA, - this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, - this->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); + EnOssan_DrawTextRec(globalCtx, pthis->stickRightPrompt.arrowColorR, pthis->stickRightPrompt.arrowColorG, + pthis->stickRightPrompt.arrowColorB, pthis->stickRightPrompt.arrowColorA, + pthis->stickRightPrompt.arrowTexX, pthis->stickRightPrompt.arrowTexY, + pthis->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); } gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); if (drawStickLeftPrompt) { - EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColorR, this->stickLeftPrompt.stickColorG, - this->stickLeftPrompt.stickColorB, this->stickLeftPrompt.stickColorA, - this->stickLeftPrompt.stickTexX, this->stickLeftPrompt.stickTexY, - this->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); + EnOssan_DrawTextRec(globalCtx, pthis->stickLeftPrompt.stickColorR, pthis->stickLeftPrompt.stickColorG, + pthis->stickLeftPrompt.stickColorB, pthis->stickLeftPrompt.stickColorA, + pthis->stickLeftPrompt.stickTexX, pthis->stickLeftPrompt.stickTexY, + pthis->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); } if (drawStickRightPrompt) { - EnOssan_DrawTextRec(globalCtx, this->stickRightPrompt.stickColorR, this->stickRightPrompt.stickColorG, - this->stickRightPrompt.stickColorB, this->stickRightPrompt.stickColorA, - this->stickRightPrompt.stickTexX, this->stickRightPrompt.stickTexY, - this->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); + EnOssan_DrawTextRec(globalCtx, pthis->stickRightPrompt.stickColorR, pthis->stickRightPrompt.stickColorG, + pthis->stickRightPrompt.stickColorB, pthis->stickRightPrompt.stickColorA, + pthis->stickRightPrompt.stickTexX, pthis->stickRightPrompt.stickTexY, + pthis->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); } } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4300); @@ -2349,17 +2349,17 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) void EnOssan_DrawBazaarShopkeeper(Actor* thisx, GlobalContext* globalCtx) { static void* sBazaarShopkeeperEyeTextures[] = { gOssanEyeOpenTex, gOssanEyeHalfTex, gOssanEyeClosedTex }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4320); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sBazaarShopkeeperEyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawDefaultShopkeeper, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sBazaarShopkeeperEyeTextures[pthis->eyeTextureIdx])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnOssan_OverrideLimbDrawDefaultShopkeeper, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4340); } @@ -2371,16 +2371,16 @@ s32 EnOssan_OverrideLimbDrawKokiriShopkeeper(GlobalContext* globalCtx, s32 limbI gKokiriShopkeeperEyeHalfTex, gKokiriShopkeeperEyeOpenTex, }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4354); if (limbIndex == 15) { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->objBankIndex2].vromStart); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->objBankIndex2].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->objBankIndex2].vromStart.get()); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->objBankIndex2].vromStart.get()); *dList = gKokiriShopkeeperHeadDL; - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sKokiriShopkeeperEyeTextures[this->eyeTextureIdx])); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(sKokiriShopkeeperEyeTextures[pthis->eyeTextureIdx])); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4374); @@ -2389,14 +2389,14 @@ s32 EnOssan_OverrideLimbDrawKokiriShopkeeper(GlobalContext* globalCtx, s32 limbI } Gfx* EnOssan_EndDList(GraphicsContext* gfxCtx) { - Gfx* disp = Graph_Alloc(gfxCtx, sizeof(Gfx)); + Gfx* disp = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); gSPEndDisplayList(disp); return disp; } Gfx* EnOssan_SetEnvColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { - Gfx* disp = Graph_Alloc(gfxCtx, sizeof(Gfx) * 2); + Gfx* disp = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 2); gDPSetEnvColor(disp, r, g, b, a); gSPEndDisplayList(disp + 1); @@ -2404,7 +2404,7 @@ Gfx* EnOssan_SetEnvColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { } void EnOssan_DrawKokiriShopkeeper(Actor* thisx, GlobalContext* globalCtx) { - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4409); @@ -2415,45 +2415,45 @@ void EnOssan_DrawKokiriShopkeeper(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, EnOssan_SetEnvColor(globalCtx->state.gfxCtx, 110, 170, 20, 255)); gSPSegment(POLY_OPA_DISP++, 0x0C, EnOssan_EndDList(globalCtx->state.gfxCtx)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawKokiriShopkeeper, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnOssan_OverrideLimbDrawKokiriShopkeeper, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4434); } void EnOssan_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { static void* sGoronShopkeeperEyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4455); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronShopkeeperEyeTextures[this->eyeTextureIdx])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronShopkeeperEyeTextures[pthis->eyeTextureIdx])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gGoronCsMouthNeutralTex)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4476); } s32 EnOssan_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; if (limbIndex == 15) { - rot->x += this->headRot; + rot->x += pthis->headRot; } return 0; } void EnOssan_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { static void* sZoraShopkeeperEyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4506); @@ -2461,12 +2461,12 @@ void EnOssan_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x0C, EnOssan_EndDList(globalCtx->state.gfxCtx)); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZoraShopkeeperEyeTextures[this->eyeTextureIdx])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZoraShopkeeperEyeTextures[pthis->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawZoraShopkeeper, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnOssan_OverrideLimbDrawZoraShopkeeper, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4531); } @@ -2474,24 +2474,24 @@ void EnOssan_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { void EnOssan_DrawPotionShopkeeper(Actor* thisx, GlobalContext* globalCtx) { static void* sPotionShopkeeperEyeTextures[] = { gPotionShopkeeperEyeOpenTex, gPotionShopkeeperEyeHalfTex, gPotionShopkeeperEyeClosedTex }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4544); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sPotionShopkeeperEyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sPotionShopkeeperEyeTextures[pthis->eyeTextureIdx])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4564); } void EnOssan_DrawHappyMaskShopkeeper(Actor* thisx, GlobalContext* globalCtx) { static void* sHappyMaskShopkeeperEyeTextures[] = { gOsEyeClosedTex, gOsEyeOpenTex }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4578); @@ -2499,11 +2499,11 @@ void EnOssan_DrawHappyMaskShopkeeper(Actor* thisx, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - SEGMENTED_TO_VIRTUAL(sHappyMaskShopkeeperEyeTextures[this->happyMaskShopkeeperEyeIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + SEGMENTED_TO_VIRTUAL(sHappyMaskShopkeeperEyeTextures[pthis->happyMaskShopkeeperEyeIdx])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4598); } @@ -2511,18 +2511,18 @@ void EnOssan_DrawHappyMaskShopkeeper(Actor* thisx, GlobalContext* globalCtx) { void EnOssan_DrawBombchuShopkeeper(Actor* thisx, GlobalContext* globalCtx) { static void* sBombchuShopkeeperEyeTextures[] = { gBombchuShopkeeperEyeOpenTex, gBombchuShopkeeperEyeHalfTex, gBombchuShopkeeperEyeClosedTex }; - EnOssan* this = (EnOssan*)thisx; + EnOssan* pthis = (EnOssan*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4611); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sBombchuShopkeeperEyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, this); - EnOssan_DrawCursor(globalCtx, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); - EnOssan_DrawStickDirectionPrompts(globalCtx, this); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sBombchuShopkeeperEyeTextures[pthis->eyeTextureIdx])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, NULL, pthis); + EnOssan_DrawCursor(globalCtx, pthis, pthis->cursorX, pthis->cursorY, pthis->cursorZ, pthis->drawCursor); + EnOssan_DrawStickDirectionPrompts(globalCtx, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_oB1.c", 4631); } diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c deleted file mode 100644 index fddbdc957..000000000 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ /dev/null @@ -1,1438 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_OWL_Z_EN_OWL_C -#include "actor_common.h" -/* - * File: z_en_owl.c - * Overlay: ovl_En_Owl - * Description: Owl - */ - -#include "z_en_owl.h" -#include "objects/object_owl/object_owl.h" -#include "scenes/overworld/spot06/spot06_scene.h" -#include "scenes/overworld/spot16/spot16_scene.h" -#include "vt.h" -#include "z_kankyo.h" -#include "def/code_800EC960.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc, OwlFunc, SkelAnime*, AnimationHeader*, f32); -void EnOwl_WaitDefault(EnOwl* this, GlobalContext* globalCtx); -void func_80ACC540(EnOwl* this); -void EnOwl_WaitOutsideKokiri(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitHyruleCastle(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitKakariko(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitGerudo(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitLakeHylia(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitZoraRiver(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitHyliaShortcut(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitDeathMountainShortcut(EnOwl* this, GlobalContext* globalCtx); -void func_80ACB3E0(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitLWPreSaria(EnOwl* this, GlobalContext* globalCtx); -void EnOwl_WaitLWPostSaria(EnOwl* this, GlobalContext* globalCtx); -void func_80ACD4D4(EnOwl* this, GlobalContext* globalCtx); -void func_80ACD130(EnOwl* this, GlobalContext* globalCtx, s32 arg2); -void func_80ACBAB8(EnOwl* this, GlobalContext* globalCtx); -void func_80ACD2CC(EnOwl* this, GlobalContext* globalCtx); -void func_80ACAA54(EnOwl* this, GlobalContext* globalCtx); -void func_80ACAC6C(EnOwl* this, GlobalContext* globalCtx); -void func_80ACADF0(EnOwl* this, GlobalContext* globalCtx); -void func_80ACAF74(EnOwl* this, GlobalContext* globalCtx); -void func_80ACC30C(EnOwl* this, GlobalContext* globalCtx); -void func_80ACB4FC(EnOwl* this, GlobalContext* globalCtx); -void func_80ACB680(EnOwl* this, GlobalContext* globalCtx); -void func_80ACC460(EnOwl* this); -void func_80ACBEA0(EnOwl*, GlobalContext*); - -typedef enum { - /* 0x00 */ OWL_DEFAULT, - /* 0x01 */ OWL_OUTSIDE_KOKIRI, - /* 0x02 */ OWL_HYRULE_CASTLE, - /* 0x03 */ OWL_KAKARIKO, - /* 0x04 */ OWL_HYLIA_GERUDO, - /* 0x05 */ OWL_LAKE_HYLIA, - /* 0x06 */ OWL_ZORA_RIVER, - /* 0x07 */ OWL_HYLIA_SHORTCUT, - /* 0x08 */ OWL_DEATH_MOUNTAIN, - /* 0x09 */ OWL_DEATH_MOUNTAIN2, - /* 0x0A */ OWL_DESSERT_COLOSSUS, - /* 0x0B */ OWL_LOST_WOODS_PRESARIA, - /* 0x0C */ OWL_LOST_WOODS_POSTSARIA -} EnOwlType; - -typedef enum { - /* 0x00 */ OWL_REPEAT, - /* 0x01 */ OWL_OK -} EnOwlMessageChoice; - -const ActorInit En_Owl_InitVars = { - ACTOR_EN_OWL, - ACTORCAT_NPC, - FLAGS, - OBJECT_OWL, - sizeof(EnOwl), - (ActorFunc)EnOwl_Init, - (ActorFunc)EnOwl_Destroy, - (ActorFunc)EnOwl_Update, - (ActorFunc)EnOwl_Draw, -}; - -static ColliderCylinderInit sOwlCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 2400, ICHAIN_STOP), -}; - -void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { - EnOwl* this = (EnOwl*)thisx; - ColliderCylinder* collider; - s32 owlType; - s32 switchFlag; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gOwlFlyingSkel, &gOwlFlyAnim, this->jointTable, this->morphTable, - 21); - SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &gOwlPerchingSkel, &gOwlPerchAnim, this->jointTable2, - this->morphTable2, 16); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sOwlCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.minVelocityY = -10.0f; - this->actor.targetArrowOffset = 500.0f; - EnOwl_ChangeMode(this, EnOwl_WaitDefault, func_80ACC540, &this->skelAnime2, &gOwlPerchAnim, 0.0f); - this->actionFlags = this->unk_406 = this->unk_409 = 0; - this->unk_405 = 4; - this->unk_404 = this->unk_407 = 0; - this->unk_408 = 4; - owlType = (this->actor.params & 0xFC0) >> 6; - switchFlag = (this->actor.params & 0x3F); - if (this->actor.params == 0xFFF) { - owlType = OWL_OUTSIDE_KOKIRI; - switchFlag = 0x20; - } - // "conversation owl %4x no = %d, sv = %d" - osSyncPrintf(VT_FGCOL(CYAN) " 会話フクロウ %4x no = %d, sv = %d\n" VT_RST, this->actor.params, owlType, switchFlag); - - if ((owlType != OWL_DEFAULT) && (switchFlag < 0x20) && Flags_GetSwitch(globalCtx, switchFlag)) { - osSyncPrintf("savebitでフクロウ退避\n"); // "Save owl with savebit" - Actor_Kill(&this->actor); - return; - } - - this->unk_3EE = 0; - this->unk_400 = this->actor.world.rot.y; - - switch (owlType) { - case OWL_DEFAULT: - this->actionFunc = EnOwl_WaitDefault; - this->actor.uncullZoneForward = 4000.0f; - this->unk_40A = 0; - break; - case OWL_OUTSIDE_KOKIRI: - this->actionFunc = EnOwl_WaitOutsideKokiri; - break; - case OWL_HYRULE_CASTLE: - this->actionFlags |= 2; - this->unk_3EE = 0x20; - this->actionFunc = EnOwl_WaitHyruleCastle; - break; - case OWL_KAKARIKO: - if (gSaveContext.eventChkInf[4] & 1) { - // has zelda's letter - osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" - Actor_Kill(&this->actor); - return; - } - - this->actionFunc = EnOwl_WaitKakariko; - break; - case OWL_HYLIA_GERUDO: - if (gSaveContext.eventChkInf[4] & 8) { - // has ocarina of time - osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" - Actor_Kill(&this->actor); - return; - } - this->actionFunc = EnOwl_WaitGerudo; - break; - case OWL_LAKE_HYLIA: - this->actionFunc = EnOwl_WaitLakeHylia; - break; - case OWL_ZORA_RIVER: - if ((gSaveContext.eventChkInf[3] & 0x200) || !(gSaveContext.eventChkInf[4] & 1)) { - // opened zora's domain or has zelda's letter - osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" - Actor_Kill(&this->actor); - return; - } - - this->actionFunc = EnOwl_WaitZoraRiver; - break; - case OWL_HYLIA_SHORTCUT: - this->actionFunc = EnOwl_WaitHyliaShortcut; - Flags_UnsetSwitch(globalCtx, 0x23); - return; - case OWL_DEATH_MOUNTAIN: - this->actionFunc = EnOwl_WaitDeathMountainShortcut; - break; - case OWL_DEATH_MOUNTAIN2: - this->actionFunc = EnOwl_WaitDeathMountainShortcut; - break; - case OWL_DESSERT_COLOSSUS: - this->actionFunc = func_80ACB3E0; - break; - case OWL_LOST_WOODS_PRESARIA: - if (!CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { - osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" - Actor_Kill(&this->actor); - return; - } - this->actionFunc = EnOwl_WaitLWPreSaria; - break; - case OWL_LOST_WOODS_POSTSARIA: - if (!CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { - osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" - Actor_Kill(&this->actor); - return; - } - this->actionFunc = EnOwl_WaitLWPostSaria; - break; - default: - // Outside kokiri forest - osSyncPrintf(VT_FGCOL(CYAN)); - osSyncPrintf("no = %d \n", owlType); - // "Unfinished owl unfinished owl unfinished owl" - osSyncPrintf("未完成のフクロウ未完成のフクロウ未完成のフクロウ\n"); - osSyncPrintf(VT_RST); - this->actionFlags |= 2; - this->unk_3EE = 0x20; - this->actionFunc = EnOwl_WaitOutsideKokiri; - break; - } -} - -void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnOwl* this = (EnOwl*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -/** - * Rotates this to the player instance - */ -void EnOwl_LookAtLink(EnOwl* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->actor.shape.rot.y = this->actor.world.rot.y = - Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); -} - -/** - * Checks if link is within `targetDist` units, initalize the camera for the owl. - * returns 0 if the link is not within `targetDistance`, returns 1 once link is within - * the distance, and the camera has been initalized. - */ -s32 EnOwl_CheckInitTalk(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetDist, u16 flags) { - s32 timer; - f32 distCheck; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->actor.params == 0xFFF) { - this->actionFlags |= 0x40; - timer = -100; - } else { - if (Rand_ZeroOne() < 0.5f) { - timer = (flags & 1) ? -97 : -99; - this->actionFlags |= 0x40; - } else { - timer = (flags & 1) ? -96 : -98; - this->actionFlags &= ~0x40; - } - } - this->cameraIdx = OnePointCutscene_Init(globalCtx, 8700, timer, &this->actor, MAIN_CAM); - return true; - } else { - this->actor.textId = textId; - distCheck = (flags & 2) ? 200.0f : 1000.0f; - if (this->actor.xzDistToPlayer < targetDist) { - this->actor.flags |= ACTOR_FLAG_16; - func_8002F1C4(&this->actor, globalCtx, targetDist, distCheck, 0); - } - return false; - } -} - -s32 func_80ACA558(EnOwl* this, GlobalContext* globalCtx, u16 textId) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - return true; - } else { - this->actor.textId = textId; - if (this->actor.xzDistToPlayer < 120.0f) { - func_8002F1C4(&this->actor, globalCtx, 350.0f, 1000.0f, 0); - } - return false; - } -} - -void func_80ACA5C8(EnOwl* this) { - EnOwl_ChangeMode(this, func_80ACBEA0, func_80ACC540, &this->skelAnime, &gOwlUnfoldWingsAnim, 0.0f); - this->eyeTexIndex = 0; - this->blinkTimer = Rand_S16Offset(60, 60); -} - -void func_80ACA62C(EnOwl* this, GlobalContext* globalCtx) { - s32 switchFlag = this->actor.params & 0x3F; - - if (switchFlag < 0x20) { - Flags_SetSwitch(globalCtx, switchFlag); - osSyncPrintf(VT_FGCOL(CYAN) " Actor_Environment_sw = %d\n" VT_RST, Flags_GetSwitch(globalCtx, switchFlag)); - } - func_80ACA5C8(this); -} - -void func_80ACA690(EnOwl* this, GlobalContext* globalCtx) { - if ((this->unk_3EE & 0x3F) == 0) { - func_80ACA62C(this, globalCtx); - } -} - -void func_80ACA6C0(EnOwl* this) { - if (Rand_CenteredFloat(1.0f) < 0.0f) { - this->actionFlags |= 0x20; - } else { - this->actionFlags &= ~0x20; - } -} - -void func_80ACA71C(EnOwl* this) { - func_80ACA6C0(this); - this->unk_3F2 = 0; - this->actionFlags |= 0x10; - this->unk_408 = 4; - this->unk_404 = 0; - this->unk_406 = 0; - this->unk_405 = 4; - this->unk_407 = this->unk_3F2; -} - -void func_80ACA76C(EnOwl* this, GlobalContext* globalCtx) { - func_8002DF54(globalCtx, &this->actor, 8); - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); - func_80ACA62C(this, globalCtx); - this->actor.flags &= ~ACTOR_FLAG_16; - } -} - -void func_80ACA7E0(EnOwl* this, GlobalContext* globalCtx) { - func_8002DF54(globalCtx, &this->actor, 8); - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); - if ((this->unk_3EE & 0x3F) == 0) { - func_80ACA62C(this, globalCtx); - } else { - this->actionFlags &= ~2; - func_80ACA71C(this); - this->actionFunc = func_80ACA690; - } - this->actor.flags &= ~ACTOR_FLAG_16; - } -} - -void EnOwl_ConfirmKokiriMessage(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x2065); - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x2067); - this->actionFunc = func_80ACA76C; - break; - } - } -} - -void EnOwl_WaitOutsideKokiri(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x2064, 360.0f, 0)) { - // Sets BGM - Audio_PlayFanfare(NA_BGM_OWL); - - this->actionFunc = EnOwl_ConfirmKokiriMessage; - // spoke to owl by lost woods - gSaveContext.eventChkInf[6] |= 0x8000; - } -} - -void func_80ACA998(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x2069); - this->actionFunc = func_80ACAA54; - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x206B); - this->actionFunc = func_80ACA7E0; - break; - } - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void func_80ACAA54(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x206A); - this->actionFunc = func_80ACA998; - this->actionFlags |= 2; - func_80ACA71C(this); - } -} - -void func_80ACAAC0(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x2069); - this->actionFunc = func_80ACAA54; - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void EnOwl_WaitHyruleCastle(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x2068, 540.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACAAC0; - } -} - -void func_80ACAB88(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - // obtained zelda's letter - if (gSaveContext.eventChkInf[4] & 1) { - Message_ContinueTextbox(globalCtx, 0x206D); - } else { - Message_ContinueTextbox(globalCtx, 0x206C); - } - this->actionFunc = func_80ACAC6C; - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x206E); - this->actionFunc = func_80ACA7E0; - break; - } - - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void func_80ACAC6C(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x206A); - this->actionFunc = func_80ACAB88; - this->actionFlags |= 2; - func_80ACA71C(this); - } -} - -void EnOwl_WaitKakariko(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x206C, 480.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACAC6C; - } -} - -void func_80ACAD34(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x206F); - this->actionFunc = func_80ACADF0; - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x2070); - this->actionFunc = func_80ACA7E0; - break; - } - - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void func_80ACADF0(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x206A); - this->actionFunc = func_80ACAD34; - this->actionFlags |= 2; - func_80ACA71C(this); - } -} - -void EnOwl_WaitGerudo(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x206F, 360.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACADF0; - } -} - -void func_80ACAEB8(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x2071); - this->actionFunc = func_80ACAF74; - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x2072); - this->actionFunc = func_80ACA7E0; - break; - } - - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void func_80ACAF74(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x206A); - this->actionFunc = func_80ACAEB8; - this->actionFlags |= 2; - func_80ACA71C(this); - } -} - -void EnOwl_WaitLakeHylia(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x2071, 360.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACAF74; - } -} - -void func_80ACB03C(EnOwl* this, GlobalContext* globalCtx) { - func_8002DF54(globalCtx, &this->actor, 8); - - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); - func_80ACA62C(this, globalCtx); - this->actor.flags &= ~ACTOR_FLAG_16; - } -} - -void EnOwl_WaitZoraRiver(EnOwl* this, GlobalContext* globalCtx) { - u16 textId; - - EnOwl_LookAtLink(this, globalCtx); - - if (CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { - if (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { - textId = 0x4031; - } else { - textId = 0x4017; - } - } else { - textId = 0x4002; - } - - if (EnOwl_CheckInitTalk(this, globalCtx, textId, 360.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB03C; - } -} - -void func_80ACB148(EnOwl* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); - func_80ACA5C8(this); - this->actionFunc = func_80ACC30C; - Flags_SetSwitch(globalCtx, 0x23); - } -} - -void EnOwl_WaitHyliaShortcut(EnOwl* this, GlobalContext* globalCtx) { - u16 textId = (gSaveContext.infTable[25] & 0x20) ? 0x4004 : 0x4003; - - // Spoke to Owl in Lake Hylia - EnOwl_LookAtLink(this, globalCtx); - if (func_80ACA558(this, globalCtx, textId)) { - gSaveContext.infTable[25] |= 0x20; - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB148; - } -} - -void func_80ACB22C(EnOwl* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); - func_80ACA5C8(this); - this->actionFunc = func_80ACC30C; - } -} - -void func_80ACB274(EnOwl* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); - this->actionFunc = EnOwl_WaitDeathMountainShortcut; - } -} - -void EnOwl_WaitDeathMountainShortcut(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (!gSaveContext.magicAcquired) { - if (func_80ACA558(this, globalCtx, 0x3062)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB274; - return; - } - } else { - if (func_80ACA558(this, globalCtx, 0x3063)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB22C; - } - } -} - -void func_80ACB344(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x607A); - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x607C); - this->actionFunc = func_80ACA7E0; - break; - } - } -} - -void func_80ACB3E0(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x6079, 360.0f, 2)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB344; - } -} - -void func_80ACB440(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x10C1); - this->actionFunc = func_80ACB4FC; - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x10C3); - this->actionFunc = func_80ACA7E0; - } - - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void func_80ACB4FC(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x10C2); - this->actionFunc = func_80ACB440; - this->actionFlags |= 2; - func_80ACA71C(this); - } -} - -void EnOwl_WaitLWPreSaria(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x10C0, 190.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB4FC; - } -} - -void func_80ACB5C4(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case OWL_REPEAT: - Message_ContinueTextbox(globalCtx, 0x10C5); - this->actionFunc = func_80ACB680; - break; - case OWL_OK: - Message_ContinueTextbox(globalCtx, 0x10C7); - this->actionFunc = func_80ACA7E0; - break; - } - - this->actionFlags &= ~2; - func_80ACA71C(this); - } -} - -void func_80ACB680(EnOwl* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x10C6); - this->actionFunc = func_80ACB5C4; - this->actionFlags |= 2; - func_80ACA71C(this); - } -} - -void EnOwl_WaitLWPostSaria(EnOwl* this, GlobalContext* globalCtx) { - EnOwl_LookAtLink(this, globalCtx); - - if (EnOwl_CheckInitTalk(this, globalCtx, 0x10C4, 360.0f, 0)) { - Audio_PlayFanfare(NA_BGM_OWL); - this->actionFunc = func_80ACB680; - } -} - -void func_80ACB748(EnOwl* this, GlobalContext* globalCtx) { - static Vec3f D_80ACD62C = { 0.0f, 0.0f, 0.0f }; - f32 dist; - f32 weight; - s32 owlType = (this->actor.params & 0xFC0) >> 6; - - dist = Math3D_Vec3f_DistXYZ(&this->eye, &globalCtx->view.eye) / 45.0f; - this->eye.x = globalCtx->view.eye.x; - this->eye.y = globalCtx->view.eye.y; - this->eye.z = globalCtx->view.eye.z; - - weight = dist; - if (weight > 1.0f) { - weight = 1.0f; - } - - switch (owlType) { - case 7: - func_800F436C(&D_80ACD62C, NA_SE_EV_FLYING_AIR - SFX_FLAG, weight * 2.0f); - if ((globalCtx->csCtx.frames > 324) || - ((globalCtx->csCtx.frames >= 142 && (globalCtx->csCtx.frames <= 266)))) { - func_800F4414(&D_80ACD62C, NA_SE_EN_OWL_FLUTTER, weight * 2.0f); - } - if (globalCtx->csCtx.frames == 85) { - func_800F436C(&D_80ACD62C, NA_SE_EV_PASS_AIR, weight * 2.0f); - } - break; - case 8: - case 9: - func_800F436C(&D_80ACD62C, NA_SE_EV_FLYING_AIR - SFX_FLAG, weight * 2.0f); - if ((globalCtx->csCtx.frames >= 420) || - ((0xC1 < globalCtx->csCtx.frames && (globalCtx->csCtx.frames <= 280)))) { - func_800F4414(&D_80ACD62C, NA_SE_EN_OWL_FLUTTER, weight * 2.0f); - } - if (globalCtx->csCtx.frames == 217) { - func_800F436C(&D_80ACD62C, NA_SE_EV_PASS_AIR, weight * 2.0f); - } - break; - } -} - -void func_80ACB904(EnOwl* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE && (globalCtx->csCtx.npcActions[7] != NULL)) { - if (this->unk_40A != globalCtx->csCtx.npcActions[7]->action) { - func_80ACD130(this, globalCtx, 7); - func_80ACBAB8(this, globalCtx); - } - func_80ACD2CC(this, globalCtx); - } - - if (this->actionFlags & 0x80) { - func_80ACB748(this, globalCtx); - } -} - -void func_80ACB994(EnOwl* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE && (globalCtx->csCtx.npcActions[7] != NULL)) { - if (this->unk_40A != globalCtx->csCtx.npcActions[7]->action) { - func_80ACD130(this, globalCtx, 7); - func_80ACBAB8(this, globalCtx); - } - func_80ACD4D4(this, globalCtx); - } - - if (this->actionFlags & 0x80) { - func_80ACB748(this, globalCtx); - } -} - -void EnOwl_WaitDefault(EnOwl* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE && (globalCtx->csCtx.npcActions[7] != NULL)) { - if (this->unk_40A != globalCtx->csCtx.npcActions[7]->action) { - this->actionFlags |= 4; - func_80ACD130(this, globalCtx, 7); - func_80ACBAB8(this, globalCtx); - } else { - this->actor.world.rot.z = globalCtx->csCtx.npcActions[7]->urot.y; - } - } - - if (this->actionFlags & 0x80) { - func_80ACB748(this, globalCtx); - } -} - -void func_80ACBAB8(EnOwl* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.npcActions[7]->action - 1) { - case 0: - EnOwl_ChangeMode(this, func_80ACB904, func_80ACC540, &this->skelAnime, &gOwlFlyAnim, 0.0f); - break; - case 1: - this->actor.draw = EnOwl_Draw; - EnOwl_ChangeMode(this, EnOwl_WaitDefault, func_80ACC540, &this->skelAnime, &gOwlPerchAnim, 0.0f); - break; - case 2: - this->actor.draw = EnOwl_Draw; - EnOwl_ChangeMode(this, func_80ACB994, func_80ACC540, &this->skelAnime, &gOwlFlyAnim, 0.0f); - break; - case 3: - this->actor.draw = NULL; - this->actionFunc = EnOwl_WaitDefault; - break; - case 4: - Actor_Kill(&this->actor); - break; - } - - this->unk_40A = globalCtx->csCtx.npcActions[7]->action; -} - -void func_80ACBC0C(EnOwl* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_5; - - if (this->actor.xzDistToPlayer > 6000.0f && !(this->actionFlags & 0x80)) { - Actor_Kill(&this->actor); - } - - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_400, 2, 0x80, 0x40); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->actor.speedXZ < 16.0f) { - this->actor.speedXZ += 0.5f; - } - - if ((this->unk_3F8 + 1000.0f) < this->actor.world.pos.y) { - if (this->actor.velocity.y > 0.0f) { - this->actor.velocity.y -= 0.4f; - } - } else if (this->actor.velocity.y < 4.0f) { - this->actor.velocity.y += 0.2f; - } - - this->actionFlags |= 8; -} - -void func_80ACBD4C(EnOwl* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame > 10.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_400, 2, 0x400, 0x40); - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - if (this->skelAnime.curFrame > 45.0f) { - this->actor.velocity.y = 2.0f; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 8.0f; - } else if (this->skelAnime.curFrame > 17.0f) { - this->actor.velocity.y = 6.0f; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 4.0f; - } - - if (this->actionFlags & 1) { - EnOwl_ChangeMode(this, func_80ACBC0C, func_80ACC460, &this->skelAnime, &gOwlFlyAnim, 0.0f); - this->unk_3FE = 6; - if (this->actionFlags & 0x40) { - this->unk_400 += 0x2000; - } else { - this->unk_400 -= 0x2000; - } - } - - this->actionFlags |= 8; -} - -void func_80ACBEA0(EnOwl* this, GlobalContext* GlobalContext) { - if (this->actionFlags & 1) { - this->unk_3FE = 3; - EnOwl_ChangeMode(this, func_80ACBD4C, func_80ACC540, &this->skelAnime, &gOwlTakeoffAnim, 0.0f); - this->unk_3F8 = this->actor.world.pos.y; - this->actor.velocity.y = 2.0f; - if (this->actionFlags & 0x40) { - this->unk_400 = this->actor.world.rot.y + 0x4000; - } else { - this->unk_400 = this->actor.world.rot.y - 0x4000; - } - } - - this->actionFlags |= 8; -} - -void func_80ACBF50(EnOwl* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_400, 2, 0x384, 0x258); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->actionFlags & 1) { - EnOwl_ChangeMode(this, func_80ACBC0C, func_80ACC460, &this->skelAnime, &gOwlFlyAnim, 0.0f); - this->unk_3FE = 6; - this->actor.velocity.y = 2.0f; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 4.0f; - } - this->actionFlags |= 8; -} - -void func_80ACC00C(EnOwl* this, GlobalContext* globalCtx) { - s32 owlType; - s32 temp_v0; - s32 temp_v0_2; - - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_400, 2, 0x384, 0x258); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->actor.xzDistToPlayer < 50.0f) { - if (!Gameplay_InCsMode(globalCtx)) { - owlType = (this->actor.params & 0xFC0) >> 6; - osSyncPrintf(VT_FGCOL(CYAN)); - osSyncPrintf("%dのフクロウ\n", owlType); // "%d owl" - osSyncPrintf(VT_RST); - switch (owlType) { - case 7: - osSyncPrintf(VT_FGCOL(CYAN)); - osSyncPrintf("SPOT 06 の デモがはしった\n"); // "Demo of SPOT 06 has been completed" - osSyncPrintf(VT_RST); - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gLakeHyliaOwlCs); - this->actor.draw = NULL; - break; - case 8: - case 9: - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gDMTOwlCs); - this->actor.draw = NULL; - break; - default: - ASSERT(0, "0", "../z_en_owl.c", 1693); - break; - } - - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - gSaveContext.cutsceneTrigger = 1; - func_800F44EC(0x14, 0xA); - this->actionFunc = EnOwl_WaitDefault; - this->unk_40A = 0; - this->actionFlags |= 0x80; - gTimeIncrement = 0; - } - } - - if (this->skelAnime.curFrame >= 37.0f) { - if (this->unk_3FE > 0) { - this->skelAnime.curFrame = 21.0f; - this->unk_3FE--; - } else { - this->actionFunc = func_80ACBF50; - } - } - - this->actionFlags |= 8; -} - -void func_80ACC23C(EnOwl* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame < 20.0f) { - this->actor.speedXZ = 1.5f; - } else { - this->actor.speedXZ = 0.0f; - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_400, 2, 0x384, 0x258); - this->actor.shape.rot.y = this->actor.world.rot.y; - } - - if (this->skelAnime.curFrame >= 37.0f) { - this->skelAnime.curFrame = 21.0f; - this->actionFunc = func_80ACC00C; - this->unk_3FE = 5; - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - this->actor.speedXZ = 0.0f; - } - - this->actionFlags |= 8; -} - -void func_80ACC30C(EnOwl* this, GlobalContext* globalCtx) { - if (this->actionFlags & 1) { - this->unk_3FE = 3; - EnOwl_ChangeMode(this, func_80ACC23C, func_80ACC540, &this->skelAnime, &gOwlTakeoffAnim, 0.0f); - this->unk_3F8 = this->actor.world.pos.y; - this->actor.velocity.y = 0.2f; - } - - this->actionFlags |= 8; -} - -void func_80ACC390(EnOwl* this) { - SkelAnime_Update(this->curSkelAnime); - - if (this->unk_3FE > 0) { - this->unk_3FE--; - this->actor.shape.rot.z = Math_SinS(this->unk_3FE * 0x333) * 1000.0f; - } else { - this->unk_410 = func_80ACC460; - this->unk_3FE = 6; - Animation_Change(this->curSkelAnime, &gOwlFlyAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gOwlFlyAnim), 2, 5.0f); - } -} - -void func_80ACC460(EnOwl* this) { - if (SkelAnime_Update(this->curSkelAnime)) { - if (this->unk_3FE > 0) { - this->unk_3FE--; - Animation_Change(this->curSkelAnime, this->curSkelAnime->animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->curSkelAnime->animation), ANIMMODE_ONCE, 0.0f); - } else { - this->unk_3FE = 0xA0; - this->unk_410 = func_80ACC390; - Animation_Change(this->curSkelAnime, &gOwlGlideAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gOwlGlideAnim), 0, - 5.0f); - } - } -} - -void func_80ACC540(EnOwl* this) { - if (SkelAnime_Update(this->curSkelAnime)) { - Animation_Change(this->curSkelAnime, this->curSkelAnime->animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->curSkelAnime->animation), ANIMMODE_ONCE, 0.0f); - this->actionFlags |= 1; - } else { - this->actionFlags &= ~1; - } -} - -s32 func_80ACC5CC(EnOwl* this) { - s32 phi_v1 = (this->actionFlags & 2) ? 0x20 : 0; - - if (phi_v1 == (this->unk_3EE & 0x3F)) { - return true; - } else { - if (this->actionFlags & 0x20) { - this->unk_3EE += 4; - } else { - this->unk_3EE -= 4; - } - - return false; - } -} - -s32 func_80ACC624(EnOwl* this, GlobalContext* globalCtx) { - s32 switchFlag = (this->actor.params & 0xFC0) >> 6; - - if (globalCtx->sceneNum != SCENE_SPOT11) { - return true; - } else if (switchFlag == 0xA) { - return true; - } else if (globalCtx->csCtx.frames >= 300 && globalCtx->csCtx.frames <= 430) { - return true; - } else if (globalCtx->csCtx.frames >= 1080 && globalCtx->csCtx.frames <= 1170) { - return true; - } else { - return false; - } -} - -void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnOwl* this = (EnOwl*)thisx; - s16 phi_a1; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); - this->unk_410(this); - this->actionFlags &= ~8; - this->actionFunc(this, globalCtx); - if (this->actor.update == NULL) { - // "Owl disappears" - osSyncPrintf("フクロウ消滅!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - return; - } - - if (!(this->actionFlags & 0x80) && func_80ACC624(this, globalCtx)) { - if ((this->skelAnime.animation == &gOwlTakeoffAnim && - (this->skelAnime.curFrame == 2.0f || this->skelAnime.curFrame == 9.0f || - this->skelAnime.curFrame == 23.0f || this->skelAnime.curFrame == 40.0f || - this->skelAnime.curFrame == 58.0f)) || - (this->skelAnime.animation == &gOwlFlyAnim && this->skelAnime.curFrame == 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); - } - } - - if (this->actor.draw != NULL) { - Actor_MoveForward(&this->actor); - } - - if (this->actionFlags & 2) { - this->eyeTexIndex = 2; - } else { - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - - this->eyeTexIndex = this->blinkTimer; - - if (this->eyeTexIndex >= 3) { - this->eyeTexIndex = 0; - } - } - - if (!(this->actionFlags & 8)) { - phi_a1 = 0; - if (this->actionFlags & 0x10) { - switch (this->unk_404) { - case 0: - this->unk_404 = 1; - this->unk_405 = 6; - break; - case 1: - this->unk_405--; - - if (this->unk_405 != 0) { - phi_a1 = Math_CosS(this->unk_405 * 8192) * 4096.0f; - } else { - if (this->actionFlags & 2) { - this->unk_3EE = 0; - } else { - this->unk_3EE = 0x20; - } - - if (this->actionFlags & 0x20) { - this->unk_3EE -= 4; - } else { - this->unk_3EE += 4; - } - this->unk_404++; - } - - if (this->actionFlags & 0x20) { - phi_a1 = -phi_a1; - } - break; - case 2: - if (func_80ACC5CC(this)) { - this->actionFlags &= ~0x10; - this->unk_406 = (s32)Rand_ZeroFloat(20.0f) + 0x3C; - this->unk_404 = 0; - func_80ACA6C0(this); - } - break; - default: - break; - } - } else { - if (this->unk_406 > 0) { - this->unk_406--; - } else { - if (this->unk_404 == 0) { - if (Rand_ZeroOne() < 0.3f) { - this->unk_404 = 4; - this->unk_405 = 0xC; - } else { - this->unk_404 = 1; - this->unk_405 = 4; - } - } - - this->unk_405--; - - switch (this->unk_404) { - case 1: - phi_a1 = Math_SinS((-this->unk_405 * 4096) + 0x4000) * 5000.0f; - if (this->unk_405 <= 0) { - this->unk_405 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); - this->unk_404 = 2; - } - break; - case 2: - phi_a1 = 0x1388; - if (this->unk_405 <= 0) { - this->unk_404 = 3; - this->unk_405 = 4; - } - break; - case 3: - phi_a1 = Math_SinS(this->unk_405 * 4096) * 5000.0f; - if (this->unk_405 <= 0) { - this->unk_406 = (s32)Rand_ZeroFloat(20.0f) + 0x3C; - this->unk_404 = 0; - func_80ACA6C0(this); - } - break; - case 4: - phi_a1 = Math_SinS(this->unk_405 * 8192) * 5000.0f; - if (this->unk_405 <= 0) { - this->unk_406 = (s32)Rand_ZeroFloat(20.0f) + 0x3C; - this->unk_404 = 0; - func_80ACA6C0(this); - } - break; - default: - break; - } - - if (this->actionFlags & 0x20) { - phi_a1 = -phi_a1; - } - } - - if (this->unk_409 > 0) { - this->unk_409--; - } else { - this->unk_408--; - switch (this->unk_407) { - case 0: - this->unk_3F2 = (-this->unk_408 * 0x5DC) + 0x1770; - if (this->unk_408 <= 0) { - this->unk_407 = 1; - this->unk_408 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); - } - break; - case 1: - this->unk_3F2 = 0x1770; - if (this->unk_408 <= 0) { - this->unk_407 = 2; - this->unk_408 = 4; - } - break; - case 2: - this->unk_3F2 = this->unk_408 * 0x5DC; - if (this->unk_408 <= 0) { - this->unk_407 = 0; - this->unk_408 = 4; - this->unk_409 = (s32)Rand_ZeroFloat(40.0f) + 0xA0; - } - break; - default: - break; - } - } - } - if (phi_a1) {} - this->unk_3F0 = (u16)((this->unk_3EE << 2) << 8) + phi_a1; - this->unk_3EC = ABS(this->unk_3F0) >> 3; - } else { - this->unk_3F2 = 0; - if (this->actionFlags & 2) { - this->unk_3F0 = -0x8000; - } else { - this->unk_3F0 = 0; - } - - this->unk_3EC = ABS(this->unk_3F0) >> 3; - } -} - -s32 EnOwl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** gfx, Vec3f* pos, Vec3s* rot, void* thisx) { - EnOwl* this = (EnOwl*)thisx; - - switch (limbIndex) { - case 3: - rot->x += this->unk_3F0; - rot->z += this->unk_3EC; - rot->z -= this->unk_3F2; - break; - case 2: - rot->z += this->unk_3F2; - break; - case 4: - if (!(this->actionFlags & 8)) { - rot->y -= (s16)(this->unk_3EC * 1.5f); - } - break; - case 5: - if (!(this->actionFlags & 8)) { - rot->y += (s16)(this->unk_3EC * 1.5f); - } - break; - default: - break; - } - return false; -} - -void EnOwl_PostLimbUpdate(GlobalContext* globalCtx, s32 limbIndex, Gfx** gfx, Vec3s* rot, void* thisx) { - EnOwl* this = (EnOwl*)thisx; - Vec3f vec; - - vec.z = 0.0f; - if (this->actionFlags & 2) { - vec.x = 700.0f; - vec.y = 400.0f; - } else { - vec.y = 0.0f; - vec.x = 1400.0f; - } - if (limbIndex == 3) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); - } -} - -void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { gObjOwlEyeOpenTex, gObjOwlEyeHalfTex, gObjOwlEyeClosedTex }; - EnOwl* this = (EnOwl*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_owl.c", 2247); - - func_800943C8(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->curSkelAnime->skeleton, this->curSkelAnime->jointTable, - this->curSkelAnime->dListCount, EnOwl_OverrideLimbDraw, EnOwl_PostLimbUpdate, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_owl.c", 2264); -} - -void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, OwlFunc arg2, SkelAnime* skelAnime, - AnimationHeader* animation, f32 morphFrames) { - this->curSkelAnime = skelAnime; - Animation_Change(this->curSkelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, - morphFrames); - this->actionFunc = actionFunc; - this->unk_410 = arg2; -} - -void func_80ACD130(EnOwl* this, GlobalContext* globalCtx, s32 idx) { - Vec3f startPos; - - startPos.x = globalCtx->csCtx.npcActions[idx]->startPos.x; - startPos.y = globalCtx->csCtx.npcActions[idx]->startPos.y; - startPos.z = globalCtx->csCtx.npcActions[idx]->startPos.z; - this->actor.world.pos = startPos; - this->actor.world.rot.y = this->actor.shape.rot.y = globalCtx->csCtx.npcActions[idx]->rot.y; - this->actor.shape.rot.z = globalCtx->csCtx.npcActions[idx]->urot.z; -} - -f32 func_80ACD1C4(GlobalContext* globalCtx, s32 idx) { - f32 ret = Environment_LerpWeight(globalCtx->csCtx.npcActions[idx]->endFrame, - globalCtx->csCtx.npcActions[idx]->startFrame, globalCtx->csCtx.frames); - - ret = CLAMP_MAX(ret, 1.0f); - return ret; -} - -void func_80ACD220(EnOwl* this, Vec3f* arg1, f32 arg2) { - Vec3f rpy; - - rpy.x = (arg1->x - this->actor.world.pos.x) * arg2; - rpy.y = (arg1->y - this->actor.world.pos.y) * arg2; - rpy.z = (arg1->z - this->actor.world.pos.z) * arg2; - - Math_StepToF(&this->actor.velocity.y, rpy.y, 1.0f); - this->actor.speedXZ = sqrtf(SQ(rpy.x) + SQ(rpy.z)); - this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, arg1); - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void func_80ACD2CC(EnOwl* this, GlobalContext* globalCtx) { - Vec3f pos; - s32 angle; - f32 t = func_80ACD1C4(globalCtx, 7); - - pos.x = globalCtx->csCtx.npcActions[7]->startPos.x; - pos.y = globalCtx->csCtx.npcActions[7]->startPos.y; - pos.z = globalCtx->csCtx.npcActions[7]->startPos.z; - angle = (s16)globalCtx->csCtx.npcActions[7]->rot.y - this->actor.world.rot.z; - if (angle < 0) { - angle += 0x10000; - } - angle = (s16)((t * angle) + this->actor.world.rot.z); - angle = (u16)angle; - if (this->actionFlags & 4) { - f32 phi_f2 = globalCtx->csCtx.npcActions[7]->urot.x; - - phi_f2 *= 10.0f * (360.0f / 0x10000); - if (phi_f2 < 0.0f) { - phi_f2 += 360.0f; - } - pos.x -= Math_SinS(angle) * phi_f2; - pos.z += Math_CosS(angle) * phi_f2; - this->unk_3F8 = phi_f2; - this->actor.world.pos = pos; - this->actor.draw = EnOwl_Draw; - this->actionFlags &= ~4; - this->actor.speedXZ = 0.0f; - } else { - pos.x -= Math_SinS(angle) * this->unk_3F8; - pos.z += Math_CosS(angle) * this->unk_3F8; - func_80ACD220(this, &pos, 1.0f); - } -} - -void func_80ACD4D4(EnOwl* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f endPosf; - f32 temp_ret = func_80ACD1C4(globalCtx, 7); - - pos.x = globalCtx->csCtx.npcActions[7]->startPos.x; - pos.y = globalCtx->csCtx.npcActions[7]->startPos.y; - pos.z = globalCtx->csCtx.npcActions[7]->startPos.z; - endPosf.x = globalCtx->csCtx.npcActions[7]->endPos.x; - endPosf.y = globalCtx->csCtx.npcActions[7]->endPos.y; - endPosf.z = globalCtx->csCtx.npcActions[7]->endPos.z; - pos.x = (endPosf.x - pos.x) * temp_ret + pos.x; - pos.y = (endPosf.y - pos.y) * temp_ret + pos.y; - pos.z = (endPosf.z - pos.z) * temp_ret + pos.z; - func_80ACD220(this, &pos, 1.0f); -} diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.cpp b/src/overlays/actors/ovl_En_Owl/z_en_owl.cpp new file mode 100644 index 000000000..36954b012 --- /dev/null +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.cpp @@ -0,0 +1,1438 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_OWL_Z_EN_OWL_C +#include "actor_common.h" +/* + * File: z_en_owl.c + * Overlay: ovl_En_Owl + * Description: Owl + */ + +#include "z_en_owl.h" +#include "objects/object_owl/object_owl.h" +#include "scenes/overworld/spot06/spot06_scene.h" +#include "scenes/overworld/spot16/spot16_scene.h" +#include "vt.h" +#include "z_kankyo.h" +#include "def/code_800EC960.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx); +void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx); +void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOwl_ChangeMode(EnOwl* pthis, EnOwlActionFunc, OwlFunc, SkelAnime*, AnimationHeader*, f32); +void EnOwl_WaitDefault(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACC540(EnOwl* pthis); +void EnOwl_WaitOutsideKokiri(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitHyruleCastle(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitKakariko(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitGerudo(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitLakeHylia(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitZoraRiver(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitHyliaShortcut(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitDeathMountainShortcut(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACB3E0(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitLWPreSaria(EnOwl* pthis, GlobalContext* globalCtx); +void EnOwl_WaitLWPostSaria(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACD4D4(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACD130(EnOwl* pthis, GlobalContext* globalCtx, s32 arg2); +void func_80ACBAB8(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACD2CC(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACAA54(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACAC6C(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACADF0(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACAF74(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACC30C(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACB4FC(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACB680(EnOwl* pthis, GlobalContext* globalCtx); +void func_80ACC460(EnOwl* pthis); +void func_80ACBEA0(EnOwl*, GlobalContext*); + +typedef enum { + /* 0x00 */ OWL_DEFAULT, + /* 0x01 */ OWL_OUTSIDE_KOKIRI, + /* 0x02 */ OWL_HYRULE_CASTLE, + /* 0x03 */ OWL_KAKARIKO, + /* 0x04 */ OWL_HYLIA_GERUDO, + /* 0x05 */ OWL_LAKE_HYLIA, + /* 0x06 */ OWL_ZORA_RIVER, + /* 0x07 */ OWL_HYLIA_SHORTCUT, + /* 0x08 */ OWL_DEATH_MOUNTAIN, + /* 0x09 */ OWL_DEATH_MOUNTAIN2, + /* 0x0A */ OWL_DESSERT_COLOSSUS, + /* 0x0B */ OWL_LOST_WOODS_PRESARIA, + /* 0x0C */ OWL_LOST_WOODS_POSTSARIA +} EnOwlType; + +typedef enum { + /* 0x00 */ OWL_REPEAT, + /* 0x01 */ OWL_OK +} EnOwlMessageChoice; + +ActorInit En_Owl_InitVars = { + ACTOR_EN_OWL, + ACTORCAT_NPC, + FLAGS, + OBJECT_OWL, + sizeof(EnOwl), + (ActorFunc)EnOwl_Init, + (ActorFunc)EnOwl_Destroy, + (ActorFunc)EnOwl_Update, + (ActorFunc)EnOwl_Draw, +}; + +static ColliderCylinderInit sOwlCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 2400, ICHAIN_STOP), +}; + +void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnOwl* pthis = (EnOwl*)thisx; + ColliderCylinder* collider; + s32 owlType; + s32 switchFlag; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gOwlFlyingSkel, &gOwlFlyAnim, pthis->jointTable, pthis->morphTable, + 21); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime2, &gOwlPerchingSkel, &gOwlPerchAnim, pthis->jointTable2, + pthis->morphTable2, 16); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sOwlCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.minVelocityY = -10.0f; + pthis->actor.targetArrowOffset = 500.0f; + EnOwl_ChangeMode(pthis, EnOwl_WaitDefault, func_80ACC540, &pthis->skelAnime2, &gOwlPerchAnim, 0.0f); + pthis->actionFlags = pthis->unk_406 = pthis->unk_409 = 0; + pthis->unk_405 = 4; + pthis->unk_404 = pthis->unk_407 = 0; + pthis->unk_408 = 4; + owlType = (pthis->actor.params & 0xFC0) >> 6; + switchFlag = (pthis->actor.params & 0x3F); + if (pthis->actor.params == 0xFFF) { + owlType = OWL_OUTSIDE_KOKIRI; + switchFlag = 0x20; + } + // "conversation owl %4x no = %d, sv = %d" + osSyncPrintf(VT_FGCOL(CYAN) " 会話フクロウ %4x no = %d, sv = %d\n" VT_RST, pthis->actor.params, owlType, switchFlag); + + if ((owlType != OWL_DEFAULT) && (switchFlag < 0x20) && Flags_GetSwitch(globalCtx, switchFlag)) { + osSyncPrintf("savebitでフクロウ退避\n"); // "Save owl with savebit" + Actor_Kill(&pthis->actor); + return; + } + + pthis->unk_3EE = 0; + pthis->unk_400 = pthis->actor.world.rot.y; + + switch (owlType) { + case OWL_DEFAULT: + pthis->actionFunc = EnOwl_WaitDefault; + pthis->actor.uncullZoneForward = 4000.0f; + pthis->unk_40A = 0; + break; + case OWL_OUTSIDE_KOKIRI: + pthis->actionFunc = EnOwl_WaitOutsideKokiri; + break; + case OWL_HYRULE_CASTLE: + pthis->actionFlags |= 2; + pthis->unk_3EE = 0x20; + pthis->actionFunc = EnOwl_WaitHyruleCastle; + break; + case OWL_KAKARIKO: + if (gSaveContext.eventChkInf[4] & 1) { + // has zelda's letter + osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" + Actor_Kill(&pthis->actor); + return; + } + + pthis->actionFunc = EnOwl_WaitKakariko; + break; + case OWL_HYLIA_GERUDO: + if (gSaveContext.eventChkInf[4] & 8) { + // has ocarina of time + osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" + Actor_Kill(&pthis->actor); + return; + } + pthis->actionFunc = EnOwl_WaitGerudo; + break; + case OWL_LAKE_HYLIA: + pthis->actionFunc = EnOwl_WaitLakeHylia; + break; + case OWL_ZORA_RIVER: + if ((gSaveContext.eventChkInf[3] & 0x200) || !(gSaveContext.eventChkInf[4] & 1)) { + // opened zora's domain or has zelda's letter + osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" + Actor_Kill(&pthis->actor); + return; + } + + pthis->actionFunc = EnOwl_WaitZoraRiver; + break; + case OWL_HYLIA_SHORTCUT: + pthis->actionFunc = EnOwl_WaitHyliaShortcut; + Flags_UnsetSwitch(globalCtx, 0x23); + return; + case OWL_DEATH_MOUNTAIN: + pthis->actionFunc = EnOwl_WaitDeathMountainShortcut; + break; + case OWL_DEATH_MOUNTAIN2: + pthis->actionFunc = EnOwl_WaitDeathMountainShortcut; + break; + case OWL_DESSERT_COLOSSUS: + pthis->actionFunc = func_80ACB3E0; + break; + case OWL_LOST_WOODS_PRESARIA: + if (!CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { + osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" + Actor_Kill(&pthis->actor); + return; + } + pthis->actionFunc = EnOwl_WaitLWPreSaria; + break; + case OWL_LOST_WOODS_POSTSARIA: + if (!CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { + osSyncPrintf("フクロウ退避\n"); // "Owl evacuation" + Actor_Kill(&pthis->actor); + return; + } + pthis->actionFunc = EnOwl_WaitLWPostSaria; + break; + default: + // Outside kokiri forest + osSyncPrintf(VT_FGCOL(CYAN)); + osSyncPrintf("no = %d \n", owlType); + // "Unfinished owl unfinished owl unfinished owl" + osSyncPrintf("未完成のフクロウ未完成のフクロウ未完成のフクロウ\n"); + osSyncPrintf(VT_RST); + pthis->actionFlags |= 2; + pthis->unk_3EE = 0x20; + pthis->actionFunc = EnOwl_WaitOutsideKokiri; + break; + } +} + +void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOwl* pthis = (EnOwl*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +/** + * Rotates pthis to the player instance + */ +void EnOwl_LookAtLink(EnOwl* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = + Math_Vec3f_Yaw(&pthis->actor.world.pos, &player->actor.world.pos); +} + +/** + * Checks if link is within `targetDist` units, initalize the camera for the owl. + * returns 0 if the link is not within `targetDistance`, returns 1 once link is within + * the distance, and the camera has been initalized. + */ +s32 EnOwl_CheckInitTalk(EnOwl* pthis, GlobalContext* globalCtx, u16 textId, f32 targetDist, u16 flags) { + s32 timer; + f32 distCheck; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->actor.params == 0xFFF) { + pthis->actionFlags |= 0x40; + timer = -100; + } else { + if (Rand_ZeroOne() < 0.5f) { + timer = (flags & 1) ? -97 : -99; + pthis->actionFlags |= 0x40; + } else { + timer = (flags & 1) ? -96 : -98; + pthis->actionFlags &= ~0x40; + } + } + pthis->cameraIdx = OnePointCutscene_Init(globalCtx, 8700, timer, &pthis->actor, MAIN_CAM); + return true; + } else { + pthis->actor.textId = textId; + distCheck = (flags & 2) ? 200.0f : 1000.0f; + if (pthis->actor.xzDistToPlayer < targetDist) { + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F1C4(&pthis->actor, globalCtx, targetDist, distCheck, 0); + } + return false; + } +} + +s32 func_80ACA558(EnOwl* pthis, GlobalContext* globalCtx, u16 textId) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + return true; + } else { + pthis->actor.textId = textId; + if (pthis->actor.xzDistToPlayer < 120.0f) { + func_8002F1C4(&pthis->actor, globalCtx, 350.0f, 1000.0f, 0); + } + return false; + } +} + +void func_80ACA5C8(EnOwl* pthis) { + EnOwl_ChangeMode(pthis, func_80ACBEA0, func_80ACC540, &pthis->skelAnime, &gOwlUnfoldWingsAnim, 0.0f); + pthis->eyeTexIndex = 0; + pthis->blinkTimer = Rand_S16Offset(60, 60); +} + +void func_80ACA62C(EnOwl* pthis, GlobalContext* globalCtx) { + s32 switchFlag = pthis->actor.params & 0x3F; + + if (switchFlag < 0x20) { + Flags_SetSwitch(globalCtx, switchFlag); + osSyncPrintf(VT_FGCOL(CYAN) " Actor_Environment_sw = %d\n" VT_RST, Flags_GetSwitch(globalCtx, switchFlag)); + } + func_80ACA5C8(pthis); +} + +void func_80ACA690(EnOwl* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_3EE & 0x3F) == 0) { + func_80ACA62C(pthis, globalCtx); + } +} + +void func_80ACA6C0(EnOwl* pthis) { + if (Rand_CenteredFloat(1.0f) < 0.0f) { + pthis->actionFlags |= 0x20; + } else { + pthis->actionFlags &= ~0x20; + } +} + +void func_80ACA71C(EnOwl* pthis) { + func_80ACA6C0(pthis); + pthis->unk_3F2 = 0; + pthis->actionFlags |= 0x10; + pthis->unk_408 = 4; + pthis->unk_404 = 0; + pthis->unk_406 = 0; + pthis->unk_405 = 4; + pthis->unk_407 = pthis->unk_3F2; +} + +void func_80ACA76C(EnOwl* pthis, GlobalContext* globalCtx) { + func_8002DF54(globalCtx, &pthis->actor, 8); + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + func_80ACA62C(pthis, globalCtx); + pthis->actor.flags &= ~ACTOR_FLAG_16; + } +} + +void func_80ACA7E0(EnOwl* pthis, GlobalContext* globalCtx) { + func_8002DF54(globalCtx, &pthis->actor, 8); + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + if ((pthis->unk_3EE & 0x3F) == 0) { + func_80ACA62C(pthis, globalCtx); + } else { + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + pthis->actionFunc = func_80ACA690; + } + pthis->actor.flags &= ~ACTOR_FLAG_16; + } +} + +void EnOwl_ConfirmKokiriMessage(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x2065); + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x2067); + pthis->actionFunc = func_80ACA76C; + break; + } + } +} + +void EnOwl_WaitOutsideKokiri(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x2064, 360.0f, 0)) { + // Sets BGM + Audio_PlayFanfare(NA_BGM_OWL); + + pthis->actionFunc = EnOwl_ConfirmKokiriMessage; + // spoke to owl by lost woods + gSaveContext.eventChkInf[6] |= 0x8000; + } +} + +void func_80ACA998(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x2069); + pthis->actionFunc = func_80ACAA54; + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x206B); + pthis->actionFunc = func_80ACA7E0; + break; + } + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void func_80ACAA54(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x206A); + pthis->actionFunc = func_80ACA998; + pthis->actionFlags |= 2; + func_80ACA71C(pthis); + } +} + +void func_80ACAAC0(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x2069); + pthis->actionFunc = func_80ACAA54; + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void EnOwl_WaitHyruleCastle(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x2068, 540.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACAAC0; + } +} + +void func_80ACAB88(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + // obtained zelda's letter + if (gSaveContext.eventChkInf[4] & 1) { + Message_ContinueTextbox(globalCtx, 0x206D); + } else { + Message_ContinueTextbox(globalCtx, 0x206C); + } + pthis->actionFunc = func_80ACAC6C; + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x206E); + pthis->actionFunc = func_80ACA7E0; + break; + } + + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void func_80ACAC6C(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x206A); + pthis->actionFunc = func_80ACAB88; + pthis->actionFlags |= 2; + func_80ACA71C(pthis); + } +} + +void EnOwl_WaitKakariko(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x206C, 480.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACAC6C; + } +} + +void func_80ACAD34(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x206F); + pthis->actionFunc = func_80ACADF0; + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x2070); + pthis->actionFunc = func_80ACA7E0; + break; + } + + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void func_80ACADF0(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x206A); + pthis->actionFunc = func_80ACAD34; + pthis->actionFlags |= 2; + func_80ACA71C(pthis); + } +} + +void EnOwl_WaitGerudo(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x206F, 360.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACADF0; + } +} + +void func_80ACAEB8(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x2071); + pthis->actionFunc = func_80ACAF74; + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x2072); + pthis->actionFunc = func_80ACA7E0; + break; + } + + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void func_80ACAF74(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x206A); + pthis->actionFunc = func_80ACAEB8; + pthis->actionFlags |= 2; + func_80ACA71C(pthis); + } +} + +void EnOwl_WaitLakeHylia(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x2071, 360.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACAF74; + } +} + +void func_80ACB03C(EnOwl* pthis, GlobalContext* globalCtx) { + func_8002DF54(globalCtx, &pthis->actor, 8); + + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + func_80ACA62C(pthis, globalCtx); + pthis->actor.flags &= ~ACTOR_FLAG_16; + } +} + +void EnOwl_WaitZoraRiver(EnOwl* pthis, GlobalContext* globalCtx) { + u16 textId; + + EnOwl_LookAtLink(pthis, globalCtx); + + if (CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { + if (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { + textId = 0x4031; + } else { + textId = 0x4017; + } + } else { + textId = 0x4002; + } + + if (EnOwl_CheckInitTalk(pthis, globalCtx, textId, 360.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB03C; + } +} + +void func_80ACB148(EnOwl* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + func_80ACA5C8(pthis); + pthis->actionFunc = func_80ACC30C; + Flags_SetSwitch(globalCtx, 0x23); + } +} + +void EnOwl_WaitHyliaShortcut(EnOwl* pthis, GlobalContext* globalCtx) { + u16 textId = (gSaveContext.infTable[25] & 0x20) ? 0x4004 : 0x4003; + + // Spoke to Owl in Lake Hylia + EnOwl_LookAtLink(pthis, globalCtx); + if (func_80ACA558(pthis, globalCtx, textId)) { + gSaveContext.infTable[25] |= 0x20; + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB148; + } +} + +void func_80ACB22C(EnOwl* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + func_80ACA5C8(pthis); + pthis->actionFunc = func_80ACC30C; + } +} + +void func_80ACB274(EnOwl* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + pthis->actionFunc = EnOwl_WaitDeathMountainShortcut; + } +} + +void EnOwl_WaitDeathMountainShortcut(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (!gSaveContext.magicAcquired) { + if (func_80ACA558(pthis, globalCtx, 0x3062)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB274; + return; + } + } else { + if (func_80ACA558(pthis, globalCtx, 0x3063)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB22C; + } + } +} + +void func_80ACB344(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x607A); + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x607C); + pthis->actionFunc = func_80ACA7E0; + break; + } + } +} + +void func_80ACB3E0(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x6079, 360.0f, 2)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB344; + } +} + +void func_80ACB440(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x10C1); + pthis->actionFunc = func_80ACB4FC; + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x10C3); + pthis->actionFunc = func_80ACA7E0; + } + + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void func_80ACB4FC(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x10C2); + pthis->actionFunc = func_80ACB440; + pthis->actionFlags |= 2; + func_80ACA71C(pthis); + } +} + +void EnOwl_WaitLWPreSaria(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x10C0, 190.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB4FC; + } +} + +void func_80ACB5C4(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + Message_ContinueTextbox(globalCtx, 0x10C5); + pthis->actionFunc = func_80ACB680; + break; + case OWL_OK: + Message_ContinueTextbox(globalCtx, 0x10C7); + pthis->actionFunc = func_80ACA7E0; + break; + } + + pthis->actionFlags &= ~2; + func_80ACA71C(pthis); + } +} + +void func_80ACB680(EnOwl* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x10C6); + pthis->actionFunc = func_80ACB5C4; + pthis->actionFlags |= 2; + func_80ACA71C(pthis); + } +} + +void EnOwl_WaitLWPostSaria(EnOwl* pthis, GlobalContext* globalCtx) { + EnOwl_LookAtLink(pthis, globalCtx); + + if (EnOwl_CheckInitTalk(pthis, globalCtx, 0x10C4, 360.0f, 0)) { + Audio_PlayFanfare(NA_BGM_OWL); + pthis->actionFunc = func_80ACB680; + } +} + +void func_80ACB748(EnOwl* pthis, GlobalContext* globalCtx) { + static Vec3f D_80ACD62C = { 0.0f, 0.0f, 0.0f }; + f32 dist; + f32 weight; + s32 owlType = (pthis->actor.params & 0xFC0) >> 6; + + dist = Math3D_Vec3f_DistXYZ(&pthis->eye, &globalCtx->view.eye) / 45.0f; + pthis->eye.x = globalCtx->view.eye.x; + pthis->eye.y = globalCtx->view.eye.y; + pthis->eye.z = globalCtx->view.eye.z; + + weight = dist; + if (weight > 1.0f) { + weight = 1.0f; + } + + switch (owlType) { + case 7: + func_800F436C(&D_80ACD62C, NA_SE_EV_FLYING_AIR - SFX_FLAG, weight * 2.0f); + if ((globalCtx->csCtx.frames > 324) || + ((globalCtx->csCtx.frames >= 142 && (globalCtx->csCtx.frames <= 266)))) { + func_800F4414(&D_80ACD62C, NA_SE_EN_OWL_FLUTTER, weight * 2.0f); + } + if (globalCtx->csCtx.frames == 85) { + func_800F436C(&D_80ACD62C, NA_SE_EV_PASS_AIR, weight * 2.0f); + } + break; + case 8: + case 9: + func_800F436C(&D_80ACD62C, NA_SE_EV_FLYING_AIR - SFX_FLAG, weight * 2.0f); + if ((globalCtx->csCtx.frames >= 420) || + ((0xC1 < globalCtx->csCtx.frames && (globalCtx->csCtx.frames <= 280)))) { + func_800F4414(&D_80ACD62C, NA_SE_EN_OWL_FLUTTER, weight * 2.0f); + } + if (globalCtx->csCtx.frames == 217) { + func_800F436C(&D_80ACD62C, NA_SE_EV_PASS_AIR, weight * 2.0f); + } + break; + } +} + +void func_80ACB904(EnOwl* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE && (globalCtx->csCtx.npcActions[7] != NULL)) { + if (pthis->unk_40A != globalCtx->csCtx.npcActions[7]->action) { + func_80ACD130(pthis, globalCtx, 7); + func_80ACBAB8(pthis, globalCtx); + } + func_80ACD2CC(pthis, globalCtx); + } + + if (pthis->actionFlags & 0x80) { + func_80ACB748(pthis, globalCtx); + } +} + +void func_80ACB994(EnOwl* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE && (globalCtx->csCtx.npcActions[7] != NULL)) { + if (pthis->unk_40A != globalCtx->csCtx.npcActions[7]->action) { + func_80ACD130(pthis, globalCtx, 7); + func_80ACBAB8(pthis, globalCtx); + } + func_80ACD4D4(pthis, globalCtx); + } + + if (pthis->actionFlags & 0x80) { + func_80ACB748(pthis, globalCtx); + } +} + +void EnOwl_WaitDefault(EnOwl* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE && (globalCtx->csCtx.npcActions[7] != NULL)) { + if (pthis->unk_40A != globalCtx->csCtx.npcActions[7]->action) { + pthis->actionFlags |= 4; + func_80ACD130(pthis, globalCtx, 7); + func_80ACBAB8(pthis, globalCtx); + } else { + pthis->actor.world.rot.z = globalCtx->csCtx.npcActions[7]->urot.y; + } + } + + if (pthis->actionFlags & 0x80) { + func_80ACB748(pthis, globalCtx); + } +} + +void func_80ACBAB8(EnOwl* pthis, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.npcActions[7]->action - 1) { + case 0: + EnOwl_ChangeMode(pthis, func_80ACB904, func_80ACC540, &pthis->skelAnime, &gOwlFlyAnim, 0.0f); + break; + case 1: + pthis->actor.draw = EnOwl_Draw; + EnOwl_ChangeMode(pthis, EnOwl_WaitDefault, func_80ACC540, &pthis->skelAnime, &gOwlPerchAnim, 0.0f); + break; + case 2: + pthis->actor.draw = EnOwl_Draw; + EnOwl_ChangeMode(pthis, func_80ACB994, func_80ACC540, &pthis->skelAnime, &gOwlFlyAnim, 0.0f); + break; + case 3: + pthis->actor.draw = NULL; + pthis->actionFunc = EnOwl_WaitDefault; + break; + case 4: + Actor_Kill(&pthis->actor); + break; + } + + pthis->unk_40A = globalCtx->csCtx.npcActions[7]->action; +} + +void func_80ACBC0C(EnOwl* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_5; + + if (pthis->actor.xzDistToPlayer > 6000.0f && !(pthis->actionFlags & 0x80)) { + Actor_Kill(&pthis->actor); + } + + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_400, 2, 0x80, 0x40); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->actor.speedXZ < 16.0f) { + pthis->actor.speedXZ += 0.5f; + } + + if ((pthis->unk_3F8 + 1000.0f) < pthis->actor.world.pos.y) { + if (pthis->actor.velocity.y > 0.0f) { + pthis->actor.velocity.y -= 0.4f; + } + } else if (pthis->actor.velocity.y < 4.0f) { + pthis->actor.velocity.y += 0.2f; + } + + pthis->actionFlags |= 8; +} + +void func_80ACBD4C(EnOwl* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame > 10.0f) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_400, 2, 0x400, 0x40); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + if (pthis->skelAnime.curFrame > 45.0f) { + pthis->actor.velocity.y = 2.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 8.0f; + } else if (pthis->skelAnime.curFrame > 17.0f) { + pthis->actor.velocity.y = 6.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 4.0f; + } + + if (pthis->actionFlags & 1) { + EnOwl_ChangeMode(pthis, func_80ACBC0C, func_80ACC460, &pthis->skelAnime, &gOwlFlyAnim, 0.0f); + pthis->unk_3FE = 6; + if (pthis->actionFlags & 0x40) { + pthis->unk_400 += 0x2000; + } else { + pthis->unk_400 -= 0x2000; + } + } + + pthis->actionFlags |= 8; +} + +void func_80ACBEA0(EnOwl* pthis, GlobalContext* GlobalContext) { + if (pthis->actionFlags & 1) { + pthis->unk_3FE = 3; + EnOwl_ChangeMode(pthis, func_80ACBD4C, func_80ACC540, &pthis->skelAnime, &gOwlTakeoffAnim, 0.0f); + pthis->unk_3F8 = pthis->actor.world.pos.y; + pthis->actor.velocity.y = 2.0f; + if (pthis->actionFlags & 0x40) { + pthis->unk_400 = pthis->actor.world.rot.y + 0x4000; + } else { + pthis->unk_400 = pthis->actor.world.rot.y - 0x4000; + } + } + + pthis->actionFlags |= 8; +} + +void func_80ACBF50(EnOwl* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_400, 2, 0x384, 0x258); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->actionFlags & 1) { + EnOwl_ChangeMode(pthis, func_80ACBC0C, func_80ACC460, &pthis->skelAnime, &gOwlFlyAnim, 0.0f); + pthis->unk_3FE = 6; + pthis->actor.velocity.y = 2.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 4.0f; + } + pthis->actionFlags |= 8; +} + +void func_80ACC00C(EnOwl* pthis, GlobalContext* globalCtx) { + s32 owlType; + s32 temp_v0; + s32 temp_v0_2; + + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_400, 2, 0x384, 0x258); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->actor.xzDistToPlayer < 50.0f) { + if (!Gameplay_InCsMode(globalCtx)) { + owlType = (pthis->actor.params & 0xFC0) >> 6; + osSyncPrintf(VT_FGCOL(CYAN)); + osSyncPrintf("%dのフクロウ\n", owlType); // "%d owl" + osSyncPrintf(VT_RST); + switch (owlType) { + case 7: + osSyncPrintf(VT_FGCOL(CYAN)); + osSyncPrintf("SPOT 06 の デモがはしった\n"); // "Demo of SPOT 06 has been completed" + osSyncPrintf(VT_RST); + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gLakeHyliaOwlCs); + pthis->actor.draw = NULL; + break; + case 8: + case 9: + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gDMTOwlCs); + pthis->actor.draw = NULL; + break; + default: + ASSERT(0, "0", "../z_en_owl.c", 1693); + break; + } + + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + gSaveContext.cutsceneTrigger = 1; + func_800F44EC(0x14, 0xA); + pthis->actionFunc = EnOwl_WaitDefault; + pthis->unk_40A = 0; + pthis->actionFlags |= 0x80; + gTimeIncrement = 0; + } + } + + if (pthis->skelAnime.curFrame >= 37.0f) { + if (pthis->unk_3FE > 0) { + pthis->skelAnime.curFrame = 21.0f; + pthis->unk_3FE--; + } else { + pthis->actionFunc = func_80ACBF50; + } + } + + pthis->actionFlags |= 8; +} + +void func_80ACC23C(EnOwl* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame < 20.0f) { + pthis->actor.speedXZ = 1.5f; + } else { + pthis->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_400, 2, 0x384, 0x258); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + + if (pthis->skelAnime.curFrame >= 37.0f) { + pthis->skelAnime.curFrame = 21.0f; + pthis->actionFunc = func_80ACC00C; + pthis->unk_3FE = 5; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + + pthis->actionFlags |= 8; +} + +void func_80ACC30C(EnOwl* pthis, GlobalContext* globalCtx) { + if (pthis->actionFlags & 1) { + pthis->unk_3FE = 3; + EnOwl_ChangeMode(pthis, func_80ACC23C, func_80ACC540, &pthis->skelAnime, &gOwlTakeoffAnim, 0.0f); + pthis->unk_3F8 = pthis->actor.world.pos.y; + pthis->actor.velocity.y = 0.2f; + } + + pthis->actionFlags |= 8; +} + +void func_80ACC390(EnOwl* pthis) { + SkelAnime_Update(pthis->curSkelAnime); + + if (pthis->unk_3FE > 0) { + pthis->unk_3FE--; + pthis->actor.shape.rot.z = Math_SinS(pthis->unk_3FE * 0x333) * 1000.0f; + } else { + pthis->unk_410 = func_80ACC460; + pthis->unk_3FE = 6; + Animation_Change(pthis->curSkelAnime, &gOwlFlyAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gOwlFlyAnim), 2, 5.0f); + } +} + +void func_80ACC460(EnOwl* pthis) { + if (SkelAnime_Update(pthis->curSkelAnime)) { + if (pthis->unk_3FE > 0) { + pthis->unk_3FE--; + Animation_Change(pthis->curSkelAnime, (AnimationHeader*)pthis->curSkelAnime->animation, 1.0f, 0.0f, + Animation_GetLastFrame(pthis->curSkelAnime->animation), ANIMMODE_ONCE, 0.0f); + } else { + pthis->unk_3FE = 0xA0; + pthis->unk_410 = func_80ACC390; + Animation_Change(pthis->curSkelAnime, &gOwlGlideAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gOwlGlideAnim), 0, + 5.0f); + } + } +} + +void func_80ACC540(EnOwl* pthis) { + if (SkelAnime_Update(pthis->curSkelAnime)) { + Animation_Change(pthis->curSkelAnime, (AnimationHeader*)pthis->curSkelAnime->animation, 1.0f, 0.0f, + Animation_GetLastFrame(pthis->curSkelAnime->animation), ANIMMODE_ONCE, 0.0f); + pthis->actionFlags |= 1; + } else { + pthis->actionFlags &= ~1; + } +} + +s32 func_80ACC5CC(EnOwl* pthis) { + s32 phi_v1 = (pthis->actionFlags & 2) ? 0x20 : 0; + + if (phi_v1 == (pthis->unk_3EE & 0x3F)) { + return true; + } else { + if (pthis->actionFlags & 0x20) { + pthis->unk_3EE += 4; + } else { + pthis->unk_3EE -= 4; + } + + return false; + } +} + +s32 func_80ACC624(EnOwl* pthis, GlobalContext* globalCtx) { + s32 switchFlag = (pthis->actor.params & 0xFC0) >> 6; + + if (globalCtx->sceneNum != SCENE_SPOT11) { + return true; + } else if (switchFlag == 0xA) { + return true; + } else if (globalCtx->csCtx.frames >= 300 && globalCtx->csCtx.frames <= 430) { + return true; + } else if (globalCtx->csCtx.frames >= 1080 && globalCtx->csCtx.frames <= 1170) { + return true; + } else { + return false; + } +} + +void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOwl* pthis = (EnOwl*)thisx; + s16 phi_a1; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 10.0f, 5); + pthis->unk_410(pthis); + pthis->actionFlags &= ~8; + pthis->actionFunc(pthis, globalCtx); + if (pthis->actor.update == NULL) { + // "Owl disappears" + osSyncPrintf("フクロウ消滅!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + return; + } + + if (!(pthis->actionFlags & 0x80) && func_80ACC624(pthis, globalCtx)) { + if ((pthis->skelAnime.animation == &gOwlTakeoffAnim && + (pthis->skelAnime.curFrame == 2.0f || pthis->skelAnime.curFrame == 9.0f || + pthis->skelAnime.curFrame == 23.0f || pthis->skelAnime.curFrame == 40.0f || + pthis->skelAnime.curFrame == 58.0f)) || + (pthis->skelAnime.animation == &gOwlFlyAnim && pthis->skelAnime.curFrame == 4.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OWL_FLUTTER); + } + } + + if (pthis->actor.draw != NULL) { + Actor_MoveForward(&pthis->actor); + } + + if (pthis->actionFlags & 2) { + pthis->eyeTexIndex = 2; + } else { + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + + pthis->eyeTexIndex = pthis->blinkTimer; + + if (pthis->eyeTexIndex >= 3) { + pthis->eyeTexIndex = 0; + } + } + + if (!(pthis->actionFlags & 8)) { + phi_a1 = 0; + if (pthis->actionFlags & 0x10) { + switch (pthis->unk_404) { + case 0: + pthis->unk_404 = 1; + pthis->unk_405 = 6; + break; + case 1: + pthis->unk_405--; + + if (pthis->unk_405 != 0) { + phi_a1 = Math_CosS(pthis->unk_405 * 8192) * 4096.0f; + } else { + if (pthis->actionFlags & 2) { + pthis->unk_3EE = 0; + } else { + pthis->unk_3EE = 0x20; + } + + if (pthis->actionFlags & 0x20) { + pthis->unk_3EE -= 4; + } else { + pthis->unk_3EE += 4; + } + pthis->unk_404++; + } + + if (pthis->actionFlags & 0x20) { + phi_a1 = -phi_a1; + } + break; + case 2: + if (func_80ACC5CC(pthis)) { + pthis->actionFlags &= ~0x10; + pthis->unk_406 = (s32)Rand_ZeroFloat(20.0f) + 0x3C; + pthis->unk_404 = 0; + func_80ACA6C0(pthis); + } + break; + default: + break; + } + } else { + if (pthis->unk_406 > 0) { + pthis->unk_406--; + } else { + if (pthis->unk_404 == 0) { + if (Rand_ZeroOne() < 0.3f) { + pthis->unk_404 = 4; + pthis->unk_405 = 0xC; + } else { + pthis->unk_404 = 1; + pthis->unk_405 = 4; + } + } + + pthis->unk_405--; + + switch (pthis->unk_404) { + case 1: + phi_a1 = Math_SinS((-pthis->unk_405 * 4096) + 0x4000) * 5000.0f; + if (pthis->unk_405 <= 0) { + pthis->unk_405 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); + pthis->unk_404 = 2; + } + break; + case 2: + phi_a1 = 0x1388; + if (pthis->unk_405 <= 0) { + pthis->unk_404 = 3; + pthis->unk_405 = 4; + } + break; + case 3: + phi_a1 = Math_SinS(pthis->unk_405 * 4096) * 5000.0f; + if (pthis->unk_405 <= 0) { + pthis->unk_406 = (s32)Rand_ZeroFloat(20.0f) + 0x3C; + pthis->unk_404 = 0; + func_80ACA6C0(pthis); + } + break; + case 4: + phi_a1 = Math_SinS(pthis->unk_405 * 8192) * 5000.0f; + if (pthis->unk_405 <= 0) { + pthis->unk_406 = (s32)Rand_ZeroFloat(20.0f) + 0x3C; + pthis->unk_404 = 0; + func_80ACA6C0(pthis); + } + break; + default: + break; + } + + if (pthis->actionFlags & 0x20) { + phi_a1 = -phi_a1; + } + } + + if (pthis->unk_409 > 0) { + pthis->unk_409--; + } else { + pthis->unk_408--; + switch (pthis->unk_407) { + case 0: + pthis->unk_3F2 = (-pthis->unk_408 * 0x5DC) + 0x1770; + if (pthis->unk_408 <= 0) { + pthis->unk_407 = 1; + pthis->unk_408 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); + } + break; + case 1: + pthis->unk_3F2 = 0x1770; + if (pthis->unk_408 <= 0) { + pthis->unk_407 = 2; + pthis->unk_408 = 4; + } + break; + case 2: + pthis->unk_3F2 = pthis->unk_408 * 0x5DC; + if (pthis->unk_408 <= 0) { + pthis->unk_407 = 0; + pthis->unk_408 = 4; + pthis->unk_409 = (s32)Rand_ZeroFloat(40.0f) + 0xA0; + } + break; + default: + break; + } + } + } + if (phi_a1) {} + pthis->unk_3F0 = (u16)((pthis->unk_3EE << 2) << 8) + phi_a1; + pthis->unk_3EC = ABS(pthis->unk_3F0) >> 3; + } else { + pthis->unk_3F2 = 0; + if (pthis->actionFlags & 2) { + pthis->unk_3F0 = -0x8000; + } else { + pthis->unk_3F0 = 0; + } + + pthis->unk_3EC = ABS(pthis->unk_3F0) >> 3; + } +} + +s32 EnOwl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** gfx, Vec3f* pos, Vec3s* rot, void* thisx) { + EnOwl* pthis = (EnOwl*)thisx; + + switch (limbIndex) { + case 3: + rot->x += pthis->unk_3F0; + rot->z += pthis->unk_3EC; + rot->z -= pthis->unk_3F2; + break; + case 2: + rot->z += pthis->unk_3F2; + break; + case 4: + if (!(pthis->actionFlags & 8)) { + rot->y -= (s16)(pthis->unk_3EC * 1.5f); + } + break; + case 5: + if (!(pthis->actionFlags & 8)) { + rot->y += (s16)(pthis->unk_3EC * 1.5f); + } + break; + default: + break; + } + return false; +} + +void EnOwl_PostLimbUpdate(GlobalContext* globalCtx, s32 limbIndex, Gfx** gfx, Vec3s* rot, void* thisx) { + EnOwl* pthis = (EnOwl*)thisx; + Vec3f vec; + + vec.z = 0.0f; + if (pthis->actionFlags & 2) { + vec.x = 700.0f; + vec.y = 400.0f; + } else { + vec.y = 0.0f; + vec.x = 1400.0f; + } + if (limbIndex == 3) { + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); + } +} + +void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { gObjOwlEyeOpenTex, gObjOwlEyeHalfTex, gObjOwlEyeClosedTex }; + EnOwl* pthis = (EnOwl*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_owl.c", 2247); + + func_800943C8(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexIndex])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->curSkelAnime->skeleton, pthis->curSkelAnime->jointTable, + pthis->curSkelAnime->dListCount, EnOwl_OverrideLimbDraw, EnOwl_PostLimbUpdate, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_owl.c", 2264); +} + +void EnOwl_ChangeMode(EnOwl* pthis, EnOwlActionFunc actionFunc, OwlFunc arg2, SkelAnime* skelAnime, + AnimationHeader* animation, f32 morphFrames) { + pthis->curSkelAnime = skelAnime; + Animation_Change(pthis->curSkelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, + morphFrames); + pthis->actionFunc = actionFunc; + pthis->unk_410 = arg2; +} + +void func_80ACD130(EnOwl* pthis, GlobalContext* globalCtx, s32 idx) { + Vec3f startPos; + + startPos.x = globalCtx->csCtx.npcActions[idx]->startPos.x; + startPos.y = globalCtx->csCtx.npcActions[idx]->startPos.y; + startPos.z = globalCtx->csCtx.npcActions[idx]->startPos.z; + pthis->actor.world.pos = startPos; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = globalCtx->csCtx.npcActions[idx]->rot.y; + pthis->actor.shape.rot.z = globalCtx->csCtx.npcActions[idx]->urot.z; +} + +f32 func_80ACD1C4(GlobalContext* globalCtx, s32 idx) { + f32 ret = Environment_LerpWeight(globalCtx->csCtx.npcActions[idx]->endFrame, + globalCtx->csCtx.npcActions[idx]->startFrame, globalCtx->csCtx.frames); + + ret = CLAMP_MAX(ret, 1.0f); + return ret; +} + +void func_80ACD220(EnOwl* pthis, Vec3f* arg1, f32 arg2) { + Vec3f rpy; + + rpy.x = (arg1->x - pthis->actor.world.pos.x) * arg2; + rpy.y = (arg1->y - pthis->actor.world.pos.y) * arg2; + rpy.z = (arg1->z - pthis->actor.world.pos.z) * arg2; + + Math_StepToF(&pthis->actor.velocity.y, rpy.y, 1.0f); + pthis->actor.speedXZ = sqrtf(SQ(rpy.x) + SQ(rpy.z)); + pthis->actor.world.rot.y = Math_Vec3f_Yaw(&pthis->actor.world.pos, arg1); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void func_80ACD2CC(EnOwl* pthis, GlobalContext* globalCtx) { + Vec3f pos; + s32 angle; + f32 t = func_80ACD1C4(globalCtx, 7); + + pos.x = globalCtx->csCtx.npcActions[7]->startPos.x; + pos.y = globalCtx->csCtx.npcActions[7]->startPos.y; + pos.z = globalCtx->csCtx.npcActions[7]->startPos.z; + angle = (s16)globalCtx->csCtx.npcActions[7]->rot.y - pthis->actor.world.rot.z; + if (angle < 0) { + angle += 0x10000; + } + angle = (s16)((t * angle) + pthis->actor.world.rot.z); + angle = (u16)angle; + if (pthis->actionFlags & 4) { + f32 phi_f2 = globalCtx->csCtx.npcActions[7]->urot.x; + + phi_f2 *= 10.0f * (360.0f / 0x10000); + if (phi_f2 < 0.0f) { + phi_f2 += 360.0f; + } + pos.x -= Math_SinS(angle) * phi_f2; + pos.z += Math_CosS(angle) * phi_f2; + pthis->unk_3F8 = phi_f2; + pthis->actor.world.pos = pos; + pthis->actor.draw = EnOwl_Draw; + pthis->actionFlags &= ~4; + pthis->actor.speedXZ = 0.0f; + } else { + pos.x -= Math_SinS(angle) * pthis->unk_3F8; + pos.z += Math_CosS(angle) * pthis->unk_3F8; + func_80ACD220(pthis, &pos, 1.0f); + } +} + +void func_80ACD4D4(EnOwl* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f endPosf; + f32 temp_ret = func_80ACD1C4(globalCtx, 7); + + pos.x = globalCtx->csCtx.npcActions[7]->startPos.x; + pos.y = globalCtx->csCtx.npcActions[7]->startPos.y; + pos.z = globalCtx->csCtx.npcActions[7]->startPos.z; + endPosf.x = globalCtx->csCtx.npcActions[7]->endPos.x; + endPosf.y = globalCtx->csCtx.npcActions[7]->endPos.y; + endPosf.z = globalCtx->csCtx.npcActions[7]->endPos.z; + pos.x = (endPosf.x - pos.x) * temp_ret + pos.x; + pos.y = (endPosf.y - pos.y) * temp_ret + pos.y; + pos.z = (endPosf.z - pos.z) * temp_ret + pos.z; + func_80ACD220(pthis, &pos, 1.0f); +} diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.cpp similarity index 50% rename from src/overlays/actors/ovl_En_Part/z_en_part.c rename to src/overlays/actors/ovl_En_Part/z_en_part.cpp index 5288f4fd0..4c6f05be4 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.cpp @@ -24,7 +24,7 @@ void EnPart_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPart_Update(Actor* thisx, GlobalContext* globalCtx); void EnPart_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Part_InitVars = { +ActorInit En_Part_InitVars = { ACTOR_EN_PART, ACTORCAT_ITEMACTION, FLAGS, @@ -42,111 +42,111 @@ void EnPart_Init(Actor* thisx, GlobalContext* globalCtx) { void EnPart_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80ACDDE8(EnPart* this, GlobalContext* globalCtx) { +void func_80ACDDE8(EnPart* pthis, GlobalContext* globalCtx) { f32 sign = 1.0f; - this->action = 1; - this->actor.world.rot.y = Rand_ZeroOne() * 20000.0f; + pthis->action = 1; + pthis->actor.world.rot.y = Rand_ZeroOne() * 20000.0f; - switch (this->actor.params) { + switch (pthis->actor.params) { case 0: - this->actor.velocity.y = 0.0f; - this->actor.gravity = -0.3f - Rand_ZeroOne() * 0.5f; - this->rotZSpeed = 0.3f; - this->timer = 25; - this->actor.speedXZ = (Rand_ZeroOne() - 0.5f) * 2.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -0.3f - Rand_ZeroOne() * 0.5f; + pthis->rotZSpeed = 0.3f; + pthis->timer = 25; + pthis->actor.speedXZ = (Rand_ZeroOne() - 0.5f) * 2.0f; break; case 13: - this->timer = 400; + pthis->timer = 400; case 12: - this->actor.speedXZ = Rand_CenteredFloat(6.0f); - this->actor.home.pos = this->actor.world.pos; - this->timer += 60; - this->actor.velocity.y = Rand_ZeroOne() * 5.0f + 4.0f; - this->actor.gravity = -0.6f - Rand_ZeroOne() * 0.5f; - this->rotZSpeed = 0.15f; + pthis->actor.speedXZ = Rand_CenteredFloat(6.0f); + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->timer += 60; + pthis->actor.velocity.y = Rand_ZeroOne() * 5.0f + 4.0f; + pthis->actor.gravity = -0.6f - Rand_ZeroOne() * 0.5f; + pthis->rotZSpeed = 0.15f; break; case 14: - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &this->actor.world.pos, 40, 0x8001, 0, -1); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40, 0x8001, 0, -1); case 1: case 4: case 9: case 10: - this->timer += (s16)(Rand_ZeroOne() * 17.0f) + 5; + pthis->timer += (s16)(Rand_ZeroOne() * 17.0f) + 5; case 2: - this->actor.velocity.y = Rand_ZeroOne() * 5.0f + 4.0f; - this->actor.gravity = -0.6f - Rand_ZeroOne() * 0.5f; - this->rotZSpeed = 0.15f; + pthis->actor.velocity.y = Rand_ZeroOne() * 5.0f + 4.0f; + pthis->actor.gravity = -0.6f - Rand_ZeroOne() * 0.5f; + pthis->rotZSpeed = 0.15f; break; case 11: - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &this->actor.world.pos, 40, 0x8001, 0, -1); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40, 0x8001, 0, -1); case 3: - this->actor.speedXZ = (Rand_ZeroOne() - 0.5f) * 3.0f; - this->timer = (s16)(Rand_ZeroOne() * 17.0f) + 10; - this->actor.velocity.y = Rand_ZeroOne() * 3.0f + 8.0f; - this->actor.gravity = -0.6f - Rand_ZeroOne() * 0.3f; - this->rotZSpeed = 0.15f; + pthis->actor.speedXZ = (Rand_ZeroOne() - 0.5f) * 3.0f; + pthis->timer = (s16)(Rand_ZeroOne() * 17.0f) + 10; + pthis->actor.velocity.y = Rand_ZeroOne() * 3.0f + 8.0f; + pthis->actor.gravity = -0.6f - Rand_ZeroOne() * 0.3f; + pthis->rotZSpeed = 0.15f; break; case 5: case 6: case 7: case 8: - this->actor.world.rot.y = this->actor.parent->shape.rot.y; - if (this->displayList == object_ik_DL_015380) { + pthis->actor.world.rot.y = pthis->actor.parent->shape.rot.y; + if (pthis->displayList == object_ik_DL_015380) { sign = -1.0f; } - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 6.0f * sign; - this->actor.gravity = -1.2f; - this->rotZSpeed = 0.15f * sign; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->timer = 18; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 6.0f * sign; + pthis->actor.gravity = -1.2f; + pthis->rotZSpeed = 0.15f * sign; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + pthis->timer = 18; break; } } -void func_80ACE13C(EnPart* this, GlobalContext* globalCtx) { +void func_80ACE13C(EnPart* pthis, GlobalContext* globalCtx) { s32 i; Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.0f, 0.0f }; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if ((this->actor.params == 12) || (this->actor.params == 13)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 15.0f, 0.0f, 0x1D); + if ((pthis->actor.params == 12) || (pthis->actor.params == 13)) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 15.0f, 0.0f, 0x1D); - if ((this->actor.bgCheckFlags & 1) || (this->actor.world.pos.y <= this->actor.floorHeight)) { - this->action = 4; - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; + if ((pthis->actor.bgCheckFlags & 1) || (pthis->actor.world.pos.y <= pthis->actor.floorHeight)) { + pthis->action = 4; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; } - if ((this->actor.params == 13) && (this->actor.parent != NULL) && (this->actor.parent->update == NULL)) { - this->actor.parent = NULL; + if ((pthis->actor.params == 13) && (pthis->actor.parent != NULL) && (pthis->actor.parent->update == NULL)) { + pthis->actor.parent = NULL; } - } else if (this->timer <= 0) { - switch (this->actor.params) { + } else if (pthis->timer <= 0) { + switch (pthis->actor.params) { case 1: case 9: case 10: case 14: - EffectSsDeadDb_Spawn(globalCtx, &this->actor.world.pos, &zeroVec, &zeroVec, - (s16)(this->actor.scale.y * 100.0f) * 40, 7, 255, 255, 255, 255, 0, 255, 0, 1, 9, + EffectSsDeadDb_Spawn(globalCtx, &pthis->actor.world.pos, &zeroVec, &zeroVec, + (s16)(pthis->actor.scale.y * 100.0f) * 40, 7, 255, 255, 255, 255, 0, 255, 0, 1, 9, true); break; case 3: case 11: - EffectSsDeadDb_Spawn(globalCtx, &this->actor.world.pos, &zeroVec, &zeroVec, - (s16)(this->actor.scale.y * 100.0f) * 40, 7, 255, 255, 255, 255, 0, 0, 255, 1, 9, + EffectSsDeadDb_Spawn(globalCtx, &pthis->actor.world.pos, &zeroVec, &zeroVec, + (s16)(pthis->actor.scale.y * 100.0f) * 40, 7, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); break; case 4: for (i = 7; i >= 0; i--) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(60.0f); - pos.y = this->actor.world.pos.y + this->actor.shape.yOffset * this->actor.scale.y + + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(60.0f); + pos.y = pthis->actor.world.pos.y + pthis->actor.shape.yOffset * pthis->actor.scale.y + Rand_CenteredFloat(50.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(60.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(60.0f); velocity.y = Rand_ZeroOne() + 1.0f; EffectSsDtBubble_SpawnColorProfile(globalCtx, &pos, &velocity, &accel, Rand_S16Offset(80, 100), 25, 0, true); @@ -157,38 +157,38 @@ void func_80ACE13C(EnPart* this, GlobalContext* globalCtx) { case 7: case 8: for (i = 4; i >= 0; i--) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(25.0f); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(40.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(25.0f); + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(25.0f); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(40.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(25.0f); EffectSsDeadDb_Spawn(globalCtx, &pos, &zeroVec, &zeroVec, 40, 7, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); } break; } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->timer--; - this->rotZ += this->rotZSpeed; + pthis->timer--; + pthis->rotZ += pthis->rotZSpeed; } -void func_80ACE5B8(EnPart* this, GlobalContext* globalCtx) { - this->action = 3; +void func_80ACE5B8(EnPart* pthis, GlobalContext* globalCtx) { + pthis->action = 3; } -void func_80ACE5C8(EnPart* this, GlobalContext* globalCtx) { +void func_80ACE5C8(EnPart* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->timer--; - if (this->timer == 0) { - Actor_Kill(&this->actor); + pthis->timer--; + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); } else { Vec3f velocity = { 0.0f, 8.0f, 0.0f }; Vec3f accel = { 0.0f, -1.5f, 0.0f }; - if (sqrt(this->actor.xyzDistToPlayerSq) <= 40.0f) { + if (sqrt(pthis->actor.xyzDistToPlayerSq) <= 40.0f) { u8 prevInvincibilityTimer = player->invincibilityTimer; if (player->invincibilityTimer <= 0) { @@ -199,47 +199,47 @@ void func_80ACE5C8(EnPart* this, GlobalContext* globalCtx) { globalCtx->damagePlayer(globalCtx, -8); } } - func_8002F71C(globalCtx, this->actor.parent, (650.0f - this->actor.parent->xzDistToPlayer) * 0.04f + 4.0f, - this->actor.parent->world.rot.y, 8.0f); + func_8002F71C(globalCtx, pthis->actor.parent, (650.0f - pthis->actor.parent->xzDistToPlayer) * 0.04f + 4.0f, + pthis->actor.parent->world.rot.y, 8.0f); player->invincibilityTimer = prevInvincibilityTimer; - this->timer = 1; + pthis->timer = 1; } - func_80033480(globalCtx, &this->actor.world.pos, 0.0f, 1, 300, 150, 1); + func_80033480(globalCtx, &pthis->actor.world.pos, 0.0f, 1, 300, 150, 1); velocity.x = Rand_CenteredFloat(16.0f); - EffectSsHahen_Spawn(globalCtx, &this->actor.world.pos, &velocity, &accel, 20, + EffectSsHahen_Spawn(globalCtx, &pthis->actor.world.pos, &velocity, &accel, 20, (s32)((Rand_ZeroOne() * 5.0f + 12.0f) * 2), -1, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MONBLIN_GNDWAVE - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MONBLIN_GNDWAVE - SFX_FLAG); } } -void func_80ACE7E8(EnPart* this, GlobalContext* globalCtx) { +void func_80ACE7E8(EnPart* pthis, GlobalContext* globalCtx) { Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if ((this->actor.parent == NULL) || (this->actor.parent->update == NULL)) { - EffectSsDeadDb_Spawn(globalCtx, &this->actor.world.pos, &zeroVec, &zeroVec, - (s16)(this->actor.scale.y * 100.0f) * 40, 7, 255, 255, 255, 255, 0, 255, 0, 1, 9, true); - Actor_Kill(&this->actor); + if ((pthis->actor.parent == NULL) || (pthis->actor.parent->update == NULL)) { + EffectSsDeadDb_Spawn(globalCtx, &pthis->actor.world.pos, &zeroVec, &zeroVec, + (s16)(pthis->actor.scale.y * 100.0f) * 40, 7, 255, 255, 255, 255, 0, 255, 0, 1, 9, true); + Actor_Kill(&pthis->actor); return; } - if (this->timer == 0) { - f32 diffsSum = Math_SmoothStepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f, 5.0f, 0.0f); + if (pthis->timer == 0) { + f32 diffsSum = Math_SmoothStepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 1.0f, 5.0f, 0.0f); - diffsSum += Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 1.0f, 5.0f, 0.0f); - diffsSum += Math_SmoothStepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f, 5.0f, 0.0f); - diffsSum += Math_SmoothStepToF(&this->rotZ, 0.0f, 1.0f, 0.25f, 0.0f); + diffsSum += Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 1.0f, 5.0f, 0.0f); + diffsSum += Math_SmoothStepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 1.0f, 5.0f, 0.0f); + diffsSum += Math_SmoothStepToF(&pthis->rotZ, 0.0f, 1.0f, 0.25f, 0.0f); if (diffsSum == 0.0f) { - this->actor.parent->home.rot.x--; - this->timer--; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_DAMAGE); + pthis->actor.parent->home.rot.x--; + pthis->timer--; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_DAMAGE); } - } else if (this->timer > 0) { - this->timer--; + } else if (pthis->timer > 0) { + pthis->timer--; } - if (this->actor.parent->colChkInfo.health != 0) { - Actor_Kill(&this->actor); + if (pthis->actor.parent->colChkInfo.health != 0) { + Actor_Kill(&pthis->actor); } } @@ -248,14 +248,14 @@ void EnPart_Update(Actor* thisx, GlobalContext* globalCtx) { func_80ACDDE8, func_80ACE13C, func_80ACE5B8, func_80ACE5C8, func_80ACE7E8, }; - EnPart* this = (EnPart*)thisx; + EnPart* pthis = (EnPart*)thisx; - Actor_MoveForward(&this->actor); + Actor_MoveForward(&pthis->actor); - if ((this->actor.params > 4 && this->actor.params < 9) || this->actor.params < 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 15.0f, 0.0f, 5); - if (this->actor.params >= 0) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((pthis->actor.params > 4 && pthis->actor.params < 9) || pthis->actor.params < 0) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 15.0f, 0.0f, 5); + if (pthis->actor.params >= 0) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); if (thisx->bgCheckFlags & 1) { thisx->bgCheckFlags &= ~1; thisx->velocity.y = 6.0f; @@ -263,14 +263,14 @@ void EnPart_Update(Actor* thisx, GlobalContext* globalCtx) { } } - sActionFuncs[this->action](this, globalCtx); + sActionFuncs[pthis->action](pthis, globalCtx); } Gfx* func_80ACEAC0(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { Gfx* dList; Gfx* dListHead; - dList = Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); + dList = (Gfx*)Graph_Alloc(gfxCtx, 4 * sizeof(Gfx)); dListHead = dList; gDPPipeSync(dListHead++); @@ -282,12 +282,12 @@ Gfx* func_80ACEAC0(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 env } void EnPart_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnPart* this = (EnPart*)thisx; + EnPart* pthis = (EnPart*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_part.c", 647); if (thisx->params > 0) { - Matrix_RotateZ(this->rotZ, MTXMODE_APPLY); + Matrix_RotateZ(pthis->rotZ, MTXMODE_APPLY); } func_80093D18(globalCtx->state.gfxCtx); @@ -305,20 +305,20 @@ void EnPart_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, func_80ACEAC0(globalCtx->state.gfxCtx, 255, 255, 255, 180, 180, 180)); gSPSegment(POLY_OPA_DISP++, 0x09, func_80ACEAC0(globalCtx->state.gfxCtx, 225, 205, 115, 25, 20, 0)); gSPSegment(POLY_OPA_DISP++, 0x0A, func_80ACEAC0(globalCtx->state.gfxCtx, 225, 205, 115, 25, 20, 0)); - } else if ((thisx->params == 9) && (this->displayList == object_tite_DL_002FF0)) { + } else if ((thisx->params == 9) && (pthis->displayList == object_tite_DL_002FF0)) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001300)); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001700)); gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001900)); - } else if ((thisx->params == 10) && (this->displayList == object_tite_DL_002FF0)) { + } else if ((thisx->params == 10) && (pthis->displayList == object_tite_DL_002FF0)) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001B00)); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001F00)); gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_002100)); } - if (this->displayList != NULL) { + if (pthis->displayList != NULL) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_part.c", 696), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->displayList); + gSPDisplayList(POLY_OPA_DISP++, pthis->displayList); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_part.c", 700); diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c deleted file mode 100644 index 2c8c3519b..000000000 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ /dev/null @@ -1,1096 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PEEHAT_Z_EN_PEEHAT_C -#include "actor_common.h" -#include "z_en_peehat.h" -#include "objects/object_peehat/object_peehat.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_24) - -#define GROUND_HOVER_HEIGHT 75.0f -#define MAX_LARVA 3 - -void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnPeehat_Ground_SetStateGround(EnPeehat* this); -void EnPeehat_Flying_SetStateGround(EnPeehat* this); -void EnPeehat_Larva_SetStateSeekPlayer(EnPeehat* this); -void EnPeehat_Ground_StateGround(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Ground_SetStateRise(EnPeehat* this); -void EnPeehat_Flying_StateGrounded(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Flying_SetStateRise(EnPeehat* this); -void EnPeehat_Flying_StateFly(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Flying_SetStateLanding(EnPeehat* this); -void EnPeehat_Ground_StateRise(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Ground_SetStateHover(EnPeehat* this); -void EnPeehat_Flying_StateRise(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Ground_StateSeekPlayer(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Ground_SetStateReturnHome(EnPeehat* this); -void EnPeehat_Ground_SetStateLanding(EnPeehat* this); -void EnPeehat_Larva_StateSeekPlayer(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_SetStateAttackRecoil(EnPeehat* this); -void EnPeehat_Ground_StateLanding(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Flying_StateLanding(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Ground_StateHover(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Ground_StateReturnHome(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_StateAttackRecoil(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_StateBoomerangStunned(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_Adult_StateDie(EnPeehat* this, GlobalContext* globalCtx); -void EnPeehat_SetStateExplode(EnPeehat* this); -void EnPeehat_StateExplode(EnPeehat* this, GlobalContext* globalCtx); - -const ActorInit En_Peehat_InitVars = { - ACTOR_EN_PEEHAT, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_PEEHAT, - sizeof(EnPeehat), - (ActorFunc)EnPeehat_Init, - (ActorFunc)EnPeehat_Destroy, - (ActorFunc)EnPeehat_Update, - (ActorFunc)EnPeehat_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_WOOD, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 50, 160, -70, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElemInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElemInit, -}; - -static ColliderQuadInit sQuadInit = { - { - COLTYPE_METAL, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x10 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -typedef enum { - /* 00 */ PEAHAT_DMG_EFF_ATTACK = 0, - /* 06 */ PEAHAT_DMG_EFF_LIGHT_ICE_ARROW = 6, - /* 12 */ PEAHAT_DMG_EFF_FIRE = 12, - /* 13 */ PEAHAT_DMG_EFF_HOOKSHOT = 13, - /* 14 */ PEAHAT_DMG_EFF_BOOMERANG = 14, - /* 15 */ PEAHAT_DMG_EFF_NUT = 15 -} DamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, PEAHAT_DMG_EFF_NUT), - /* Deku stick */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Slingshot */ DMG_ENTRY(1, PEAHAT_DMG_EFF_ATTACK), - /* Explosive */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Boomerang */ DMG_ENTRY(0, PEAHAT_DMG_EFF_BOOMERANG), - /* Normal arrow */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Hammer swing */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Hookshot */ DMG_ENTRY(2, PEAHAT_DMG_EFF_HOOKSHOT), - /* Kokiri sword */ DMG_ENTRY(1, PEAHAT_DMG_EFF_ATTACK), - /* Master sword */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Giant's Knife */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), - /* Fire arrow */ DMG_ENTRY(4, PEAHAT_DMG_EFF_FIRE), - /* Ice arrow */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Light arrow */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Unk arrow 1 */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Unk arrow 2 */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Unk arrow 3 */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Fire magic */ DMG_ENTRY(3, PEAHAT_DMG_EFF_FIRE), - /* Ice magic */ DMG_ENTRY(0, PEAHAT_DMG_EFF_LIGHT_ICE_ARROW), - /* Light magic */ DMG_ENTRY(0, PEAHAT_DMG_EFF_LIGHT_ICE_ARROW), - /* Shield */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), - /* Mirror Ray */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), - /* Kokiri spin */ DMG_ENTRY(1, PEAHAT_DMG_EFF_ATTACK), - /* Giant spin */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), - /* Master spin */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Kokiri jump */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), - /* Giant jump */ DMG_ENTRY(8, PEAHAT_DMG_EFF_ATTACK), - /* Master jump */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), - /* Unknown 1 */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), - /* Unblockable */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), - /* Hammer jump */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), - /* Unknown 2 */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), -}; - -typedef enum { - /* 00 */ PEAHAT_STATE_DYING, - /* 01 */ PEAHAT_STATE_EXPLODE, - /* 03 */ PEAHAT_STATE_3 = 3, - /* 04 */ PEAHAT_STATE_4, - /* 05 */ PEAHAT_STATE_FLY, - /* 07 */ PEAHAT_STATE_ATTACK_RECOIL = 7, - /* 08 */ PEAHAT_STATE_8, - /* 09 */ PEAHAT_STATE_9, - /* 10 */ PEAHAT_STATE_LANDING, - /* 12 */ PEAHAT_STATE_RETURN_HOME = 12, - /* 13 */ PEAHAT_STATE_STUNNED, - /* 14 */ PEAHAT_STATE_SEEK_PLAYER, - /* 15 */ PEAHAT_STATE_15 -} PeahatState; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 700, ICHAIN_STOP), -}; - -void EnPeehat_SetupAction(EnPeehat* this, EnPeehatActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { - EnPeehat* this = (EnPeehat*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 36.0f * 0.001f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gPeehatSkel, &gPeehatRisingAnim, this->jointTable, this->morphTable, - 24); - ActorShape_Init(&this->actor.shape, 100.0f, ActorShadow_DrawCircle, 27.0f); - this->actor.focus.pos = this->actor.world.pos; - this->unk2D4 = 0; - this->actor.world.rot.y = 0; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.colChkInfo.health = 6; - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.floorHeight = this->actor.world.pos.y; - Collider_InitCylinder(globalCtx, &this->colCylinder); - Collider_SetCylinder(globalCtx, &this->colCylinder, &this->actor, &sCylinderInit); - Collider_InitQuad(globalCtx, &this->colQuad); - Collider_SetQuad(globalCtx, &this->colQuad, &this->actor, &sQuadInit); - Collider_InitJntSph(globalCtx, &this->colJntSph); - Collider_SetJntSph(globalCtx, &this->colJntSph, &this->actor, &sJntSphInit, this->colJntSphItemList); - - this->actor.naviEnemyId = 0x48; - this->xzDistToRise = 740.0f; - this->xzDistMax = 1200.0f; - this->actor.uncullZoneForward = 4000.0f; - this->actor.uncullZoneScale = 800.0f; - this->actor.uncullZoneDownward = 1800.0f; - switch (this->actor.params) { - case PEAHAT_TYPE_GROUNDED: - EnPeehat_Ground_SetStateGround(this); - break; - case PEAHAT_TYPE_FLYING: - this->actor.uncullZoneForward = 4200.0f; - this->xzDistToRise = 2800.0f; - this->xzDistMax = 1400.0f; - EnPeehat_Flying_SetStateGround(this); - this->actor.flags &= ~ACTOR_FLAG_0; - break; - case PEAHAT_TYPE_LARVA: - this->actor.scale.x = this->actor.scale.z = 0.006f; - this->actor.scale.y = 0.003f; - this->colCylinder.dim.radius = 25; - this->colCylinder.dim.height = 15; - this->colCylinder.dim.yShift = -5; - this->colCylinder.info.bumper.dmgFlags = 0x1F824; - this->colQuad.base.atFlags = AT_ON | AT_TYPE_ENEMY; - this->colQuad.base.acFlags = AC_ON | AC_TYPE_PLAYER; - this->actor.naviEnemyId = 0x49; // Larva - EnPeehat_Larva_SetStateSeekPlayer(this); - break; - } -} - -void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPeehat* this = (EnPeehat*)thisx; - EnPeehat* parent; - - Collider_DestroyCylinder(globalCtx, &this->colCylinder); - Collider_DestroyJntSph(globalCtx, &this->colJntSph); - - // If PEAHAT_TYPE_LARVA, decrement total larva spawned - if (this->actor.params > 0) { - parent = (EnPeehat*)this->actor.parent; - if (parent != NULL && parent->actor.update != NULL) { - parent->unk2FA--; - } - } -} - -void EnPeehat_SpawnDust(GlobalContext* globalCtx, EnPeehat* this, Vec3f* pos, f32 arg3, s32 arg4, f32 arg5, f32 arg6) { - Vec3f dustPos; - Vec3f dustVel = { 0.0f, 8.0f, 0.0f }; - Vec3f dustAccel = { 0.0f, -1.5f, 0.0f }; - f32 rot; // radians - s32 pScale; - - rot = (Rand_ZeroOne() - 0.5f) * 6.28f; - dustPos.y = this->actor.floorHeight; - dustPos.x = Math_SinF(rot) * arg3 + pos->x; - dustPos.z = Math_CosF(rot) * arg3 + pos->z; - dustAccel.x = (Rand_ZeroOne() - 0.5f) * arg5; - dustAccel.z = (Rand_ZeroOne() - 0.5f) * arg5; - dustVel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - pScale = (Rand_ZeroOne() * 5 + 12) * arg6; - EffectSsHahen_Spawn(globalCtx, &dustPos, &dustVel, &dustAccel, arg4, pScale, HAHEN_OBJECT_DEFAULT, 10, NULL); -} - -/** - * Handles being hit when on the ground - */ -void EnPeehat_HitWhenGrounded(EnPeehat* this, GlobalContext* globalCtx) { - this->colCylinder.base.acFlags &= ~AC_HIT; - if ((globalCtx->gameplayFrames & 0xF) == 0) { - Vec3f itemDropPos = this->actor.world.pos; - - itemDropPos.y += 70.0f; - Item_DropCollectibleRandom(globalCtx, &this->actor, &itemDropPos, 0x40); - Item_DropCollectibleRandom(globalCtx, &this->actor, &itemDropPos, 0x40); - Item_DropCollectibleRandom(globalCtx, &this->actor, &itemDropPos, 0x40); - this->unk2D4 = 240; - } else { - s32 i; - - this->colCylinder.base.acFlags &= ~AC_HIT; - for (i = MAX_LARVA - this->unk2FA; i > 0; i--) { - Actor* larva = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PEEHAT, - Rand_CenteredFloat(25.0f) + this->actor.world.pos.x, - Rand_CenteredFloat(25.0f) + (this->actor.world.pos.y + 50.0f), - Rand_CenteredFloat(25.0f) + this->actor.world.pos.z, 0, 0, 0, PEAHAT_TYPE_LARVA); - - if (larva != NULL) { - larva->velocity.y = 6.0f; - larva->shape.rot.y = larva->world.rot.y = Rand_CenteredFloat(0xFFFF); - this->unk2FA++; - } - } - this->unk2D4 = 8; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_DAMAGE); -} - -void EnPeehat_Ground_SetStateGround(EnPeehat* this) { - Animation_Change(&this->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, Animation_GetLastFrame(&gPeehatRisingAnim), - ANIMMODE_ONCE, 0.0f); - this->seekPlayerTimer = 600; - this->unk2D4 = 0; - this->unk2FA = 0; - this->state = PEAHAT_STATE_3; - this->colCylinder.base.acFlags &= ~AC_HIT; - EnPeehat_SetupAction(this, EnPeehat_Ground_StateGround); -} - -void EnPeehat_Ground_StateGround(EnPeehat* this, GlobalContext* globalCtx) { - if (IS_DAY) { - this->actor.flags |= ACTOR_FLAG_0; - if (this->riseDelayTimer == 0) { - if (this->actor.xzDistToPlayer < this->xzDistToRise) { - EnPeehat_Ground_SetStateRise(this); - } - } else { - Math_SmoothStepToF(&this->actor.shape.yOffset, -1000.0f, 1.0f, 10.0f, 0.0f); - this->riseDelayTimer--; - } - } else { - this->actor.flags &= ~ACTOR_FLAG_0; - Math_SmoothStepToF(&this->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); - if (this->unk2D4 != 0) { - this->unk2D4--; - if (this->unk2D4 & 4) { - Math_SmoothStepToF(&this->scaleShift, 0.205f, 1.0f, 0.235f, 0.0f); - } else { - Math_SmoothStepToF(&this->scaleShift, 0.0f, 1.0f, 0.005f, 0.0f); - } - } else if (this->colCylinder.base.acFlags & AC_HIT) { - EnPeehat_HitWhenGrounded(this, globalCtx); - } - } -} - -void EnPeehat_Flying_SetStateGround(EnPeehat* this) { - Animation_Change(&this->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, Animation_GetLastFrame(&gPeehatRisingAnim), - ANIMMODE_ONCE, 0.0f); - this->seekPlayerTimer = 400; - this->unk2D4 = 0; - this->unk2FA = 0; //! @bug: overwrites number of child larva spawned, allowing for more than MAX_LARVA spawns - this->state = PEAHAT_STATE_4; - EnPeehat_SetupAction(this, EnPeehat_Flying_StateGrounded); -} - -void EnPeehat_Flying_StateGrounded(EnPeehat* this, GlobalContext* globalCtx) { - if (IS_DAY) { - if (this->actor.xzDistToPlayer < this->xzDistToRise) { - EnPeehat_Flying_SetStateRise(this); - } - } else { - Math_SmoothStepToF(&this->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); - if (this->unk2D4 != 0) { - this->unk2D4--; - if (this->unk2D4 & 4) { - Math_SmoothStepToF(&this->scaleShift, 0.205f, 1.0f, 0.235f, 0.0f); - } else { - Math_SmoothStepToF(&this->scaleShift, 0.0f, 1.0f, 0.005f, 0.0f); - } - } else if (this->colCylinder.base.acFlags & AC_HIT) { - EnPeehat_HitWhenGrounded(this, globalCtx); - } - } -} - -void EnPeehat_Flying_SetStateFly(EnPeehat* this) { - Animation_PlayLoop(&this->skelAnime, &gPeehatFlyingAnim); - this->state = PEAHAT_STATE_FLY; - EnPeehat_SetupAction(this, EnPeehat_Flying_StateFly); -} - -void EnPeehat_Flying_StateFly(EnPeehat* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); - SkelAnime_Update(&this->skelAnime); - if (!IS_DAY || this->xzDistToRise < this->actor.xzDistToPlayer) { - EnPeehat_Flying_SetStateLanding(this); - } else if (this->actor.xzDistToPlayer < this->xzDistMax) { - if (this->unk2FA < MAX_LARVA && (globalCtx->gameplayFrames & 7) == 0) { - Actor* larva = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PEEHAT, - Rand_CenteredFloat(25.0f) + this->actor.world.pos.x, - Rand_CenteredFloat(5.0f) + this->actor.world.pos.y, - Rand_CenteredFloat(25.0f) + this->actor.world.pos.z, 0, 0, 0, 1); - if (larva != NULL) { - larva->shape.rot.y = larva->world.rot.y = Rand_CenteredFloat(0xFFFF); - this->unk2FA++; - } - } - } - this->bladeRot += this->bladeRotVel; -} - -void EnPeehat_Ground_SetStateRise(EnPeehat* this) { - f32 lastFrame = Animation_GetLastFrame(&gPeehatRisingAnim); - - if (this->state != PEAHAT_STATE_STUNNED) { - Animation_Change(&this->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, lastFrame, ANIMMODE_ONCE, 0.0f); - } - this->state = PEAHAT_STATE_8; - this->animTimer = lastFrame; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_UP); - EnPeehat_SetupAction(this, EnPeehat_Ground_StateRise); -} - -void EnPeehat_Ground_StateRise(EnPeehat* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 50.0f, 0.0f); - if (Math_SmoothStepToS(&this->bladeRotVel, 4000, 1, 800, 0) == 0) { - if (this->animTimer != 0) { - this->animTimer--; - if (this->skelAnime.playSpeed == 0.0f) { - if (this->animTimer == 0) { - this->animTimer = 40; - this->skelAnime.playSpeed = 1.0f; - } - } - } - if (SkelAnime_Update(&this->skelAnime) || this->animTimer == 0) { - EnPeehat_Ground_SetStateHover(this); - } else { - this->actor.world.pos.y += 6.5f; - } - if (this->actor.world.pos.y - this->actor.floorHeight < 80.0f) { - Vec3f pos = this->actor.world.pos; - pos.y = this->actor.floorHeight; - func_80033480(globalCtx, &pos, 90.0f, 1, 0x96, 100, 1); - } - } - EnPeehat_SpawnDust(globalCtx, this, &this->actor.world.pos, 75.0f, 2, 1.05f, 2.0f); - Math_SmoothStepToF(&this->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); - this->bladeRot += this->bladeRotVel; -} - -void EnPeehat_Flying_SetStateRise(EnPeehat* this) { - f32 lastFrame; - - lastFrame = Animation_GetLastFrame(&gPeehatRisingAnim); - if (this->state != PEAHAT_STATE_STUNNED) { - Animation_Change(&this->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, lastFrame, ANIMMODE_ONCE, 0.0f); - } - this->state = PEAHAT_STATE_9; - this->animTimer = lastFrame; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_UP); - EnPeehat_SetupAction(this, EnPeehat_Flying_StateRise); -} - -void EnPeehat_Flying_StateRise(EnPeehat* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 50.0f, 0.0f); - if (Math_SmoothStepToS(&this->bladeRotVel, 4000, 1, 800, 0) == 0) { - if (this->animTimer != 0) { - this->animTimer--; - if (this->skelAnime.playSpeed == 0.0f) { - if (this->animTimer == 0) { - this->animTimer = 40; - this->skelAnime.playSpeed = 1.0f; - } - } - } - if (SkelAnime_Update(&this->skelAnime) || this->animTimer == 0) { - //! @bug: overwrites number of child larva spawned, allowing for more than MAX_LARVA spawns - this->unk2FA = 0; - EnPeehat_Flying_SetStateFly(this); - } else { - this->actor.world.pos.y += 18.0f; - } - if (this->actor.world.pos.y - this->actor.floorHeight < 80.0f) { - Vec3f pos = this->actor.world.pos; - pos.y = this->actor.floorHeight; - func_80033480(globalCtx, &pos, 90.0f, 1, 0x96, 100, 1); - } - } - EnPeehat_SpawnDust(globalCtx, this, &this->actor.world.pos, 75.0f, 2, 1.05f, 2.0f); - Math_SmoothStepToF(&this->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); - this->bladeRot += this->bladeRotVel; -} - -void EnPeehat_Ground_SetStateSeekPlayer(EnPeehat* this) { - Animation_PlayLoop(&this->skelAnime, &gPeehatFlyingAnim); - this->state = PEAHAT_STATE_SEEK_PLAYER; - this->unk2E0 = 0.0f; - EnPeehat_SetupAction(this, EnPeehat_Ground_StateSeekPlayer); -} - -void EnPeehat_Ground_StateSeekPlayer(EnPeehat* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.speedXZ, 3.0f, 1.0f, 0.25f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 1.0f, 3.0f, 0.0f); - if (this->seekPlayerTimer <= 0) { - EnPeehat_Ground_SetStateLanding(this); - this->riseDelayTimer = 40; - } else { - this->seekPlayerTimer--; - } - if (IS_DAY && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->xzDistMax)) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 1000, 0); - if (this->unk2FA != 0) { - this->actor.shape.rot.y += 0x1C2; - } else { - this->actor.shape.rot.y -= 0x1C2; - } - } else { - EnPeehat_Ground_SetStateReturnHome(this); - } - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->bladeRotVel, 4000, 1, 500, 0); - this->bladeRot += this->bladeRotVel; - Math_SmoothStepToF(&this->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); -} - -void EnPeehat_Larva_SetStateSeekPlayer(EnPeehat* this) { - Animation_PlayLoop(&this->skelAnime, &gPeehatFlyingAnim); - this->state = PEAHAT_STATE_SEEK_PLAYER; - this->unk2D4 = 0; - EnPeehat_SetupAction(this, EnPeehat_Larva_StateSeekPlayer); -} - -void EnPeehat_Larva_StateSeekPlayer(EnPeehat* this, GlobalContext* globalCtx) { - f32 speedXZ = 5.3f; - - if (this->actor.xzDistToPlayer <= 5.3f) { - speedXZ = this->actor.xzDistToPlayer + 0.0005f; - } - if (this->actor.parent != NULL && this->actor.parent->update == NULL) { - this->actor.parent = NULL; - } - this->actor.speedXZ = speedXZ; - if (this->actor.world.pos.y - this->actor.floorHeight >= 70.0f) { - Math_SmoothStepToF(&this->actor.velocity.y, -1.3f, 1.0f, 0.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->actor.velocity.y, -0.135f, 1.0f, 0.05f, 0.0f); - } - if (this->unk2D4 == 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 830, 0); - } else { - this->unk2D4--; - } - this->actor.shape.rot.y += 0x15E; - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->bladeRotVel, 4000, 1, 500, 0); - this->bladeRot += this->bladeRotVel; - Math_SmoothStepToF(&this->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_SM_FLY - SFX_FLAG); - if (this->colQuad.base.atFlags & AT_BOUNCED) { - this->actor.colChkInfo.health = 0; - this->colQuad.base.acFlags = this->colQuad.base.acFlags & ~AC_BOUNCED; - EnPeehat_SetStateAttackRecoil(this); - } else if ((this->colQuad.base.atFlags & AT_HIT) || (this->colCylinder.base.acFlags & AC_HIT) || - (this->actor.bgCheckFlags & 1)) { - Player* player = GET_PLAYER(globalCtx); - this->colQuad.base.atFlags &= ~AT_HIT; - if (!(this->colCylinder.base.acFlags & AC_HIT) && &player->actor == this->colQuad.base.at) { - if (Rand_ZeroOne() > 0.5f) { - this->actor.world.rot.y += 0x2000; - } else { - this->actor.world.rot.y -= 0x2000; - } - this->unk2D4 = 40; - } else if (this->colCylinder.base.acFlags & AC_HIT || this->actor.bgCheckFlags & 1) { - Vec3f zeroVec = { 0, 0, 0 }; - s32 i; - for (i = 4; i >= 0; i--) { - Vec3f pos; - pos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - pos.y = Rand_CenteredFloat(10.0f) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &pos, &zeroVec, &zeroVec, 40, 7, 255, 255, 255, 255, 255, 0, 0, 1, 9, - 1); - } - } - if (&player->actor != this->colQuad.base.at || this->colCylinder.base.acFlags & AC_HIT) { - if (!(this->actor.bgCheckFlags & 1)) { - EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_PIHAT_SM_DEAD, 1, 1, - 40); - } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x20); - Actor_Kill(&this->actor); - } - } -} - -void EnPeehat_Ground_SetStateLanding(EnPeehat* this) { - this->state = PEAHAT_STATE_LANDING; - Animation_PlayOnce(&this->skelAnime, &gPeehatLandingAnim); - EnPeehat_SetupAction(this, EnPeehat_Ground_StateLanding); -} - -void EnPeehat_Ground_StateLanding(EnPeehat* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 50, 0); - if (SkelAnime_Update(&this->skelAnime)) { - EnPeehat_Ground_SetStateGround(this); - this->actor.world.pos.y = this->actor.floorHeight; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_LAND); - } else if (this->actor.floorHeight < this->actor.world.pos.y) { - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight, 0.3f, 3.5f, 0.25f); - if (this->actor.world.pos.y - this->actor.floorHeight < 60.0f) { - Vec3f pos = this->actor.world.pos; - pos.y = this->actor.floorHeight; - func_80033480(globalCtx, &pos, 80.0f, 1, 150, 100, 1); - EnPeehat_SpawnDust(globalCtx, this, &pos, 75.0f, 2, 1.05f, 2.0f); - } - } - Math_SmoothStepToS(&this->bladeRotVel, 0, 1, 100, 0); - this->bladeRot += this->bladeRotVel; -} - -void EnPeehat_Flying_SetStateLanding(EnPeehat* this) { - Animation_PlayOnce(&this->skelAnime, &gPeehatLandingAnim); - this->state = PEAHAT_STATE_LANDING; - EnPeehat_SetupAction(this, EnPeehat_Flying_StateLanding); -} - -void EnPeehat_Flying_StateLanding(EnPeehat* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 50, 0); - if (SkelAnime_Update(&this->skelAnime)) { - EnPeehat_Flying_SetStateGround(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_LAND); - this->actor.world.pos.y = this->actor.floorHeight; - } else if (this->actor.floorHeight < this->actor.world.pos.y) { - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight, 0.3f, 13.5f, 0.25f); - if (this->actor.world.pos.y - this->actor.floorHeight < 60.0f) { - Vec3f pos = this->actor.world.pos; - pos.y = this->actor.floorHeight; - func_80033480(globalCtx, &pos, 80.0f, 1, 150, 100, 1); - EnPeehat_SpawnDust(globalCtx, this, &pos, 75.0f, 2, 1.05f, 2.0f); - } - } - Math_SmoothStepToS(&this->bladeRotVel, 0, 1, 100, 0); - this->bladeRot += this->bladeRotVel; -} - -void EnPeehat_Ground_SetStateHover(EnPeehat* this) { - Animation_PlayLoop(&this->skelAnime, &gPeehatFlyingAnim); - this->actor.speedXZ = Rand_ZeroOne() * 0.5f + 2.5f; - this->unk2D4 = Rand_ZeroOne() * 10 + 10; - this->state = PEAHAT_STATE_15; - EnPeehat_SetupAction(this, EnPeehat_Ground_StateHover); -} - -void EnPeehat_Ground_StateHover(EnPeehat* this, GlobalContext* globalCtx) { - f32 cos; - Player* player = GET_PLAYER(globalCtx); - - // hover but don't gain altitude - if (this->actor.world.pos.y - this->actor.floorHeight > 75.0f) { - this->actor.world.pos.y -= 1.0f; - } - this->actor.world.pos.y += Math_CosF(this->unk2E0) * 1.4f; - cos = Math_CosF(this->unk2E0) * 0.18f; - this->unk2E0 += ((0.0f <= cos) ? cos : -cos) + 0.07f; - this->unk2D4--; - if (this->unk2D4 <= 0) { - this->actor.speedXZ = Rand_ZeroOne() * 0.5f + 2.5f; - this->unk2D4 = Rand_ZeroOne() * 10.0f + 10.0f; - this->unk2F4 = (Rand_ZeroOne() - 0.5f) * 1000.0f; - } - SkelAnime_Update(&this->skelAnime); - this->actor.world.rot.y += this->unk2F4; - if (this->seekPlayerTimer <= 0) { - EnPeehat_Ground_SetStateLanding(this); - this->riseDelayTimer = 40; - } else { - this->seekPlayerTimer--; - } - this->actor.shape.rot.y += 0x15E; - // if daytime, and the player is close to the initial spawn position - if (IS_DAY && Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->xzDistMax) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnPeehat_Ground_SetStateSeekPlayer(this); - this->unk2FA = globalCtx->gameplayFrames & 1; - } else { - EnPeehat_Ground_SetStateReturnHome(this); - } - Math_SmoothStepToS(&this->bladeRotVel, 4000, 1, 500, 0); - this->bladeRot += this->bladeRotVel; - Math_SmoothStepToF(&this->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); -} - -void EnPeehat_Ground_SetStateReturnHome(EnPeehat* this) { - this->state = PEAHAT_STATE_RETURN_HOME; - this->actor.speedXZ = 2.5f; - EnPeehat_SetupAction(this, EnPeehat_Ground_StateReturnHome); -} - -void EnPeehat_Ground_StateReturnHome(EnPeehat* this, GlobalContext* globalCtx) { - f32 cos; - s16 yRot; - Player* player; - - player = GET_PLAYER(globalCtx); - if (this->actor.world.pos.y - this->actor.floorHeight > 75.0f) { - this->actor.world.pos.y -= 1.0f; - } else { - this->actor.world.pos.y += 1.0f; - } - this->actor.world.pos.y += Math_CosF(this->unk2E0) * 1.4f; - cos = Math_CosF(this->unk2E0) * 0.18f; - this->unk2E0 += ((0.0f <= cos) ? cos : -cos) + 0.07f; - yRot = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 1, 600, 0); - Math_SmoothStepToS(&this->actor.shape.rot.x, 4500, 1, 600, 0); - this->actor.shape.rot.y += 0x15E; - this->bladeRot += this->bladeRotVel; - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) < 2.0f) { - EnPeehat_Ground_SetStateLanding(this); - this->riseDelayTimer = 60; - } - if (IS_DAY && Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->xzDistMax) { - this->seekPlayerTimer = 400; - EnPeehat_Ground_SetStateSeekPlayer(this); - this->unk2FA = (globalCtx->gameplayFrames & 1); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); -} - -void EnPeehat_SetStateAttackRecoil(EnPeehat* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPeehatRecoilAnim, -4.0f); - this->state = PEAHAT_STATE_ATTACK_RECOIL; - this->actor.speedXZ = -9.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnPeehat_SetupAction(this, EnPeehat_StateAttackRecoil); -} - -void EnPeehat_StateAttackRecoil(EnPeehat* this, GlobalContext* globalCtx) { - this->bladeRot += this->bladeRotVel; - SkelAnime_Update(&this->skelAnime); - this->actor.speedXZ += 0.5f; - if (this->actor.speedXZ == 0.0f) { - // Is PEAHAT_TYPE_LARVA - if (this->actor.params > 0) { - Vec3f zeroVec = { 0, 0, 0 }; - s32 i; - for (i = 4; i >= 0; i--) { - Vec3f pos; - pos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - pos.y = Rand_CenteredFloat(10.0f) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &pos, &zeroVec, &zeroVec, 40, 7, 255, 255, 255, 255, 255, 0, 0, 1, 9, - 1); - } - Actor_Kill(&this->actor); - } else { - EnPeehat_Ground_SetStateSeekPlayer(this); - // Is PEAHAT_TYPE_GROUNDED - if (this->actor.params < 0) { - this->unk2FA = (this->unk2FA != 0) ? 0 : 1; - } - } - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); -} - -void EnPeehat_SetStateBoomerangStunned(EnPeehat* this) { - this->state = PEAHAT_STATE_STUNNED; - if (this->actor.floorHeight < this->actor.world.pos.y) { - this->actor.speedXZ = -9.0f; - } - this->bladeRotVel = 0; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_SetColorFilter(&this->actor, 0, 200, 0, 80); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - EnPeehat_SetupAction(this, EnPeehat_StateBoomerangStunned); -} - -void EnPeehat_StateBoomerangStunned(EnPeehat* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight, 1.0f, 8.0f, 0.0f); - if (this->actor.colorFilterTimer == 0) { - EnPeehat_Ground_SetStateRise(this); - } -} - -void EnPeehat_Adult_SetStateDie(EnPeehat* this) { - this->bladeRotVel = 0; - this->isStateDieFirstUpdate = 1; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->state = PEAHAT_STATE_DYING; - this->scaleShift = 0.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnPeehat_SetupAction(this, EnPeehat_Adult_StateDie); -} - -void EnPeehat_Adult_StateDie(EnPeehat* this, GlobalContext* globalCtx) { - if (this->isStateDieFirstUpdate) { - this->unk2D4--; - if (this->unk2D4 <= 0 || this->actor.colChkInfo.health == 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPeehatRecoilAnim, -4.0f); - this->bladeRotVel = 4000; - this->unk2D4 = 14; - this->actor.speedXZ = 0; - this->actor.velocity.y = 6; - this->isStateDieFirstUpdate = 0; - this->actor.shape.rot.z = this->actor.shape.rot.x = 0; - } else if (this->actor.colorFilterTimer & 4) { - Math_SmoothStepToF(&this->scaleShift, 0.205f, 1.0f, 0.235f, 0); - } else { - Math_SmoothStepToF(&this->scaleShift, 0, 1.0f, 0.005f, 0); - } - } else { - SkelAnime_Update(&this->skelAnime); - this->bladeRot += this->bladeRotVel; - Math_SmoothStepToS(&this->bladeRotVel, 4000, 1, 250, 0); - if (this->actor.colChkInfo.health == 0) { - this->actor.scale.x -= 0.0015f; - Actor_SetScale(&this->actor, this->actor.scale.x); - } - if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight + 88.5f, 1.0f, 3.0f, 0.0f) == 0.0f && - this->actor.world.pos.y - this->actor.floorHeight < 59.0f) { - Vec3f pos = this->actor.world.pos; - pos.y = this->actor.floorHeight; - func_80033480(globalCtx, &pos, 80.0f, 1, 150, 100, 1); - EnPeehat_SpawnDust(globalCtx, this, &pos, 75.0f, 2, 1.05f, 2.0f); - } - if (this->actor.speedXZ < 0) { - this->actor.speedXZ += 0.25f; - } - this->unk2D4--; - if (this->unk2D4 <= 0) { - if (this->actor.colChkInfo.health == 0) { - EnPeehat_SetStateExplode(this); - // if PEAHAT_TYPE_GROUNDED - } else if (this->actor.params < 0) { - EnPeehat_Ground_SetStateHover(this); - this->riseDelayTimer = 60; - } else { - EnPeehat_Flying_SetStateFly(this); - } - } - } -} - -void EnPeehat_SetStateExplode(EnPeehat* this) { - Animation_PlayLoop(&this->skelAnime, &gPeehatFlyingAnim); - this->state = PEAHAT_STATE_EXPLODE; - this->animTimer = 5; - this->unk2E0 = 0.0f; - EnPeehat_SetupAction(this, EnPeehat_StateExplode); -} - -void EnPeehat_StateExplode(EnPeehat* this, GlobalContext* globalCtx) { - EnBom* bomb; - s32 pad[2]; - - if (this->animTimer == 5) { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x602, 0); - if (bomb != NULL) { - bomb->timer = 0; - } - } - this->animTimer--; - if (this->animTimer == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x40); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x40); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x40); - Actor_Kill(&this->actor); - } -} - -void EnPeehat_Adult_CollisionCheck(EnPeehat* this, GlobalContext* globalCtx) { - if ((this->colCylinder.base.acFlags & AC_BOUNCED) || (this->colQuad.base.acFlags & AC_BOUNCED)) { - this->colQuad.base.acFlags &= ~AC_BOUNCED; - this->colCylinder.base.acFlags &= ~AC_BOUNCED; - this->colJntSph.base.acFlags &= ~AC_HIT; - } else if (this->colJntSph.base.acFlags & AC_HIT) { - this->colJntSph.base.acFlags &= ~AC_HIT; - Actor_SetDropFlagJntSph(&this->actor, &this->colJntSph, 1); - if (this->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_NUT || - this->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_LIGHT_ICE_ARROW) { - return; - } - if (this->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_HOOKSHOT) { - this->actor.colChkInfo.health = 0; - } else if (this->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_BOOMERANG) { - if (this->state != PEAHAT_STATE_STUNNED) { - EnPeehat_SetStateBoomerangStunned(this); - } - return; - } else { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIHAT_DAMAGE); - } - - if (this->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_FIRE) { - Vec3f pos; - s32 i; - for (i = 4; i >= 0; i--) { - pos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - pos.y = Rand_ZeroOne() * 25.0f + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &pos, 70, 0, 0, -1); - } - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, 100); - } - if (this->actor.colChkInfo.health == 0) { - EnPeehat_Adult_SetStateDie(this); - } - } -} - -void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx) { - EnPeehat* this = (EnPeehat*)thisx; - s32 i; - Player* player = GET_PLAYER(globalCtx); - - // If Adult Peahat - if (thisx->params <= 0) { - EnPeehat_Adult_CollisionCheck(this, globalCtx); - } - if (thisx->colChkInfo.damageEffect != PEAHAT_DMG_EFF_LIGHT_ICE_ARROW) { - if (thisx->speedXZ != 0.0f || thisx->velocity.y != 0.0f) { - Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 30.0f, 30.0f, 5); - } - - this->actionFunc(this, globalCtx); - if ((globalCtx->gameplayFrames & 0x7F) == 0) { - this->jiggleRotInc = (Rand_ZeroOne() * 0.25f) + 0.5f; - } - this->jiggleRot += this->jiggleRotInc; - } - // if PEAHAT_TYPE_GROUNDED - if (thisx->params < 0) { - // Set the Z-Target point on the Peahat's weak point - thisx->focus.pos.x = this->colJntSph.elements[0].dim.worldSphere.center.x; - thisx->focus.pos.y = this->colJntSph.elements[0].dim.worldSphere.center.y; - thisx->focus.pos.z = this->colJntSph.elements[0].dim.worldSphere.center.z; - if (this->state == PEAHAT_STATE_SEEK_PLAYER) { - Math_SmoothStepToS(&thisx->shape.rot.x, 6000, 1, 300, 0); - } else { - Math_SmoothStepToS(&thisx->shape.rot.x, 0, 1, 300, 0); - } - } else { - thisx->focus.pos = thisx->world.pos; - } - Collider_UpdateCylinder(thisx, &this->colCylinder); - if (thisx->colChkInfo.health > 0) { - // If Adult Peahat - if (thisx->params <= 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colJntSph.base); - if (thisx->colorFilterTimer == 0 || !(thisx->colorFilterParams & 0x4000)) { - if (this->state != PEAHAT_STATE_EXPLODE) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colJntSph.base); - } - } - } - if (thisx->params != PEAHAT_TYPE_FLYING && this->colQuad.base.atFlags & AT_HIT) { - this->colQuad.base.atFlags &= ~AT_HIT; - if (&player->actor == this->colQuad.base.at) { - EnPeehat_SetStateAttackRecoil(this); - } - } - } - if (this->state == PEAHAT_STATE_15 || this->state == PEAHAT_STATE_SEEK_PLAYER || this->state == PEAHAT_STATE_FLY || - this->state == PEAHAT_STATE_RETURN_HOME || this->state == PEAHAT_STATE_EXPLODE) { - if (thisx->params != PEAHAT_TYPE_FLYING) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colQuad.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colQuad.base); - } - // if PEAHAT_TYPE_GROUNDED - if (thisx->params < 0 && (thisx->flags & ACTOR_FLAG_UNCULLED)) { - for (i = 1; i >= 0; i--) { - Vec3f posResult; - CollisionPoly* poly = NULL; - s32 bgId; - Vec3f* posB = &this->bladeTip[i]; - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, posB, &posResult, &poly, true, true, - false, true, &bgId) == true) { - func_80033480(globalCtx, &posResult, 0.0f, 1, 300, 150, 1); - EnPeehat_SpawnDust(globalCtx, this, &posResult, 0.0f, 3, 1.05f, 1.5f); - } - } - } else if (thisx->params != PEAHAT_TYPE_FLYING) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder.base); - } - } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder.base); - } - Math_SmoothStepToF(&this->scaleShift, 0.0f, 1.0f, 0.001f, 0.0f); -} - -s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnPeehat* this = (EnPeehat*)thisx; - - if (limbIndex == 4) { - rot->x = -this->bladeRot; - } - if (limbIndex == 3 || (limbIndex == 23 && (this->state == PEAHAT_STATE_DYING || this->state == PEAHAT_STATE_3 || - this->state == PEAHAT_STATE_4))) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1946); - Matrix_Push(); - Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateX(this->jiggleRot * 0.115f, MTXMODE_APPLY); - Matrix_RotateY(this->jiggleRot * 0.13f, MTXMODE_APPLY); - Matrix_RotateZ(this->jiggleRot * 0.1f, MTXMODE_APPLY); - Matrix_Scale(1.0f - this->scaleShift, this->scaleShift + 1.0f, 1.0f - this->scaleShift, MTXMODE_APPLY); - Matrix_RotateZ(-(this->jiggleRot * 0.1f), MTXMODE_APPLY); - Matrix_RotateY(-(this->jiggleRot * 0.13f), MTXMODE_APPLY); - Matrix_RotateX(-(this->jiggleRot * 0.115f), MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1959), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1963); - return true; - } - return false; -} - -void EnPeehat_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f peahatBladeTip[] = { { 0.0f, 0.0f, 5500.0f }, { 0.0f, 0.0f, -5500.0f } }; - - EnPeehat* this = (EnPeehat*)thisx; - f32 damageYRot; - - if (limbIndex == 4) { - Matrix_MultVec3f(&peahatBladeTip[0], &this->bladeTip[0]); - Matrix_MultVec3f(&peahatBladeTip[1], &this->bladeTip[1]); - return; - } - // is Adult Peahat - if (limbIndex == 3 && this->actor.params <= 0) { - damageYRot = 0.0f; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1981); - Matrix_Push(); - Matrix_Translate(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Collider_UpdateSpheres(0, &this->colJntSph); - Matrix_Translate(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - if (this->actor.colorFilterTimer != 0 && (this->actor.colorFilterParams & 0x4000)) { - damageYRot = Math_SinS(this->actor.colorFilterTimer * 0x4E20) * 0.35f; - } - Matrix_RotateY(3.2f + damageYRot, MTXMODE_APPLY); - Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1990), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1994); - } -} - -void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f D_80AD285C[] = { - { 0.0f, 0.0f, -4500.0f }, { -4500.0f, 0.0f, 0.0f }, { 4500.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 4500.0f } - }; - EnPeehat* this = (EnPeehat*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPeehat_OverrideLimbDraw, - EnPeehat_PostLimbDraw, this); - if (this->actor.speedXZ != 0.0f || this->actor.velocity.y != 0.0f) { - Matrix_MultVec3f(&D_80AD285C[0], &this->colQuad.dim.quad[1]); - Matrix_MultVec3f(&D_80AD285C[1], &this->colQuad.dim.quad[0]); - Matrix_MultVec3f(&D_80AD285C[2], &this->colQuad.dim.quad[3]); - Matrix_MultVec3f(&D_80AD285C[3], &this->colQuad.dim.quad[2]); - Collider_SetQuadVertices(&this->colQuad, &this->colQuad.dim.quad[0], &this->colQuad.dim.quad[1], - &this->colQuad.dim.quad[2], &this->colQuad.dim.quad[3]); - } -} diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.cpp b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.cpp new file mode 100644 index 000000000..71e8fe285 --- /dev/null +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.cpp @@ -0,0 +1,1096 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PEEHAT_Z_EN_PEEHAT_C +#include "actor_common.h" +#include "z_en_peehat.h" +#include "objects/object_peehat/object_peehat.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_24) + +#define GROUND_HOVER_HEIGHT 75.0f +#define MAX_LARVA 3 + +void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx); +void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx); +void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnPeehat_Ground_SetStateGround(EnPeehat* pthis); +void EnPeehat_Flying_SetStateGround(EnPeehat* pthis); +void EnPeehat_Larva_SetStateSeekPlayer(EnPeehat* pthis); +void EnPeehat_Ground_StateGround(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Ground_SetStateRise(EnPeehat* pthis); +void EnPeehat_Flying_StateGrounded(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Flying_SetStateRise(EnPeehat* pthis); +void EnPeehat_Flying_StateFly(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Flying_SetStateLanding(EnPeehat* pthis); +void EnPeehat_Ground_StateRise(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Ground_SetStateHover(EnPeehat* pthis); +void EnPeehat_Flying_StateRise(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Ground_StateSeekPlayer(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Ground_SetStateReturnHome(EnPeehat* pthis); +void EnPeehat_Ground_SetStateLanding(EnPeehat* pthis); +void EnPeehat_Larva_StateSeekPlayer(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_SetStateAttackRecoil(EnPeehat* pthis); +void EnPeehat_Ground_StateLanding(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Flying_StateLanding(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Ground_StateHover(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Ground_StateReturnHome(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_StateAttackRecoil(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_StateBoomerangStunned(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_Adult_StateDie(EnPeehat* pthis, GlobalContext* globalCtx); +void EnPeehat_SetStateExplode(EnPeehat* pthis); +void EnPeehat_StateExplode(EnPeehat* pthis, GlobalContext* globalCtx); + +ActorInit En_Peehat_InitVars = { + ACTOR_EN_PEEHAT, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_PEEHAT, + sizeof(EnPeehat), + (ActorFunc)EnPeehat_Init, + (ActorFunc)EnPeehat_Destroy, + (ActorFunc)EnPeehat_Update, + (ActorFunc)EnPeehat_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_WOOD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 50, 160, -70, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElemInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElemInit, +}; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x10 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +typedef enum { + /* 00 */ PEAHAT_DMG_EFF_ATTACK = 0, + /* 06 */ PEAHAT_DMG_EFF_LIGHT_ICE_ARROW = 6, + /* 12 */ PEAHAT_DMG_EFF_FIRE = 12, + /* 13 */ PEAHAT_DMG_EFF_HOOKSHOT = 13, + /* 14 */ PEAHAT_DMG_EFF_BOOMERANG = 14, + /* 15 */ PEAHAT_DMG_EFF_NUT = 15 +} DamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, PEAHAT_DMG_EFF_NUT), + /* Deku stick */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Slingshot */ DMG_ENTRY(1, PEAHAT_DMG_EFF_ATTACK), + /* Explosive */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Boomerang */ DMG_ENTRY(0, PEAHAT_DMG_EFF_BOOMERANG), + /* Normal arrow */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Hammer swing */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Hookshot */ DMG_ENTRY(2, PEAHAT_DMG_EFF_HOOKSHOT), + /* Kokiri sword */ DMG_ENTRY(1, PEAHAT_DMG_EFF_ATTACK), + /* Master sword */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Giant's Knife */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), + /* Fire arrow */ DMG_ENTRY(4, PEAHAT_DMG_EFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Light arrow */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Unk arrow 1 */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Unk arrow 2 */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Unk arrow 3 */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Fire magic */ DMG_ENTRY(3, PEAHAT_DMG_EFF_FIRE), + /* Ice magic */ DMG_ENTRY(0, PEAHAT_DMG_EFF_LIGHT_ICE_ARROW), + /* Light magic */ DMG_ENTRY(0, PEAHAT_DMG_EFF_LIGHT_ICE_ARROW), + /* Shield */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), + /* Mirror Ray */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), + /* Kokiri spin */ DMG_ENTRY(1, PEAHAT_DMG_EFF_ATTACK), + /* Giant spin */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), + /* Master spin */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Kokiri jump */ DMG_ENTRY(2, PEAHAT_DMG_EFF_ATTACK), + /* Giant jump */ DMG_ENTRY(8, PEAHAT_DMG_EFF_ATTACK), + /* Master jump */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), + /* Unknown 1 */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), + /* Unblockable */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), + /* Hammer jump */ DMG_ENTRY(4, PEAHAT_DMG_EFF_ATTACK), + /* Unknown 2 */ DMG_ENTRY(0, PEAHAT_DMG_EFF_ATTACK), +}; + +typedef enum { + /* 00 */ PEAHAT_STATE_DYING, + /* 01 */ PEAHAT_STATE_EXPLODE, + /* 03 */ PEAHAT_STATE_3 = 3, + /* 04 */ PEAHAT_STATE_4, + /* 05 */ PEAHAT_STATE_FLY, + /* 07 */ PEAHAT_STATE_ATTACK_RECOIL = 7, + /* 08 */ PEAHAT_STATE_8, + /* 09 */ PEAHAT_STATE_9, + /* 10 */ PEAHAT_STATE_LANDING, + /* 12 */ PEAHAT_STATE_RETURN_HOME = 12, + /* 13 */ PEAHAT_STATE_STUNNED, + /* 14 */ PEAHAT_STATE_SEEK_PLAYER, + /* 15 */ PEAHAT_STATE_15 +} PeahatState; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 700, ICHAIN_STOP), +}; + +void EnPeehat_SetupAction(EnPeehat* pthis, EnPeehatActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* pthis = (EnPeehat*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, 36.0f * 0.001f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gPeehatSkel, &gPeehatRisingAnim, pthis->jointTable, pthis->morphTable, + 24); + ActorShape_Init(&pthis->actor.shape, 100.0f, ActorShadow_DrawCircle, 27.0f); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->unk2D4 = 0; + pthis->actor.world.rot.y = 0; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.colChkInfo.health = 6; + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.floorHeight = pthis->actor.world.pos.y; + Collider_InitCylinder(globalCtx, &pthis->colCylinder); + Collider_SetCylinder(globalCtx, &pthis->colCylinder, &pthis->actor, &sCylinderInit); + Collider_InitQuad(globalCtx, &pthis->colQuad); + Collider_SetQuad(globalCtx, &pthis->colQuad, &pthis->actor, &sQuadInit); + Collider_InitJntSph(globalCtx, &pthis->colJntSph); + Collider_SetJntSph(globalCtx, &pthis->colJntSph, &pthis->actor, &sJntSphInit, pthis->colJntSphItemList); + + pthis->actor.naviEnemyId = 0x48; + pthis->xzDistToRise = 740.0f; + pthis->xzDistMax = 1200.0f; + pthis->actor.uncullZoneForward = 4000.0f; + pthis->actor.uncullZoneScale = 800.0f; + pthis->actor.uncullZoneDownward = 1800.0f; + switch (pthis->actor.params) { + case PEAHAT_TYPE_GROUNDED: + EnPeehat_Ground_SetStateGround(pthis); + break; + case PEAHAT_TYPE_FLYING: + pthis->actor.uncullZoneForward = 4200.0f; + pthis->xzDistToRise = 2800.0f; + pthis->xzDistMax = 1400.0f; + EnPeehat_Flying_SetStateGround(pthis); + pthis->actor.flags &= ~ACTOR_FLAG_0; + break; + case PEAHAT_TYPE_LARVA: + pthis->actor.scale.x = pthis->actor.scale.z = 0.006f; + pthis->actor.scale.y = 0.003f; + pthis->colCylinder.dim.radius = 25; + pthis->colCylinder.dim.height = 15; + pthis->colCylinder.dim.yShift = -5; + pthis->colCylinder.info.bumper.dmgFlags = 0x1F824; + pthis->colQuad.base.atFlags = AT_ON | AT_TYPE_ENEMY; + pthis->colQuad.base.acFlags = AC_ON | AC_TYPE_PLAYER; + pthis->actor.naviEnemyId = 0x49; // Larva + EnPeehat_Larva_SetStateSeekPlayer(pthis); + break; + } +} + +void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* pthis = (EnPeehat*)thisx; + EnPeehat* parent; + + Collider_DestroyCylinder(globalCtx, &pthis->colCylinder); + Collider_DestroyJntSph(globalCtx, &pthis->colJntSph); + + // If PEAHAT_TYPE_LARVA, decrement total larva spawned + if (pthis->actor.params > 0) { + parent = (EnPeehat*)pthis->actor.parent; + if (parent != NULL && parent->actor.update != NULL) { + parent->unk2FA--; + } + } +} + +void EnPeehat_SpawnDust(GlobalContext* globalCtx, EnPeehat* pthis, Vec3f* pos, f32 arg3, s32 arg4, f32 arg5, f32 arg6) { + Vec3f dustPos; + Vec3f dustVel = { 0.0f, 8.0f, 0.0f }; + Vec3f dustAccel = { 0.0f, -1.5f, 0.0f }; + f32 rot; // radians + s32 pScale; + + rot = (Rand_ZeroOne() - 0.5f) * 6.28f; + dustPos.y = pthis->actor.floorHeight; + dustPos.x = Math_SinF(rot) * arg3 + pos->x; + dustPos.z = Math_CosF(rot) * arg3 + pos->z; + dustAccel.x = (Rand_ZeroOne() - 0.5f) * arg5; + dustAccel.z = (Rand_ZeroOne() - 0.5f) * arg5; + dustVel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; + pScale = (Rand_ZeroOne() * 5 + 12) * arg6; + EffectSsHahen_Spawn(globalCtx, &dustPos, &dustVel, &dustAccel, arg4, pScale, HAHEN_OBJECT_DEFAULT, 10, NULL); +} + +/** + * Handles being hit when on the ground + */ +void EnPeehat_HitWhenGrounded(EnPeehat* pthis, GlobalContext* globalCtx) { + pthis->colCylinder.base.acFlags &= ~AC_HIT; + if ((globalCtx->gameplayFrames & 0xF) == 0) { + Vec3f itemDropPos = pthis->actor.world.pos; + + itemDropPos.y += 70.0f; + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &itemDropPos, 0x40); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &itemDropPos, 0x40); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &itemDropPos, 0x40); + pthis->unk2D4 = 240; + } else { + s32 i; + + pthis->colCylinder.base.acFlags &= ~AC_HIT; + for (i = MAX_LARVA - pthis->unk2FA; i > 0; i--) { + Actor* larva = + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_PEEHAT, + Rand_CenteredFloat(25.0f) + pthis->actor.world.pos.x, + Rand_CenteredFloat(25.0f) + (pthis->actor.world.pos.y + 50.0f), + Rand_CenteredFloat(25.0f) + pthis->actor.world.pos.z, 0, 0, 0, PEAHAT_TYPE_LARVA); + + if (larva != NULL) { + larva->velocity.y = 6.0f; + larva->shape.rot.y = larva->world.rot.y = Rand_CenteredFloat(0xFFFF); + pthis->unk2FA++; + } + } + pthis->unk2D4 = 8; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_DAMAGE); +} + +void EnPeehat_Ground_SetStateGround(EnPeehat* pthis) { + Animation_Change(&pthis->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, Animation_GetLastFrame(&gPeehatRisingAnim), + ANIMMODE_ONCE, 0.0f); + pthis->seekPlayerTimer = 600; + pthis->unk2D4 = 0; + pthis->unk2FA = 0; + pthis->state = PEAHAT_STATE_3; + pthis->colCylinder.base.acFlags &= ~AC_HIT; + EnPeehat_SetupAction(pthis, EnPeehat_Ground_StateGround); +} + +void EnPeehat_Ground_StateGround(EnPeehat* pthis, GlobalContext* globalCtx) { + if (IS_DAY) { + pthis->actor.flags |= ACTOR_FLAG_0; + if (pthis->riseDelayTimer == 0) { + if (pthis->actor.xzDistToPlayer < pthis->xzDistToRise) { + EnPeehat_Ground_SetStateRise(pthis); + } + } else { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1000.0f, 1.0f, 10.0f, 0.0f); + pthis->riseDelayTimer--; + } + } else { + pthis->actor.flags &= ~ACTOR_FLAG_0; + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); + if (pthis->unk2D4 != 0) { + pthis->unk2D4--; + if (pthis->unk2D4 & 4) { + Math_SmoothStepToF(&pthis->scaleShift, 0.205f, 1.0f, 0.235f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->scaleShift, 0.0f, 1.0f, 0.005f, 0.0f); + } + } else if (pthis->colCylinder.base.acFlags & AC_HIT) { + EnPeehat_HitWhenGrounded(pthis, globalCtx); + } + } +} + +void EnPeehat_Flying_SetStateGround(EnPeehat* pthis) { + Animation_Change(&pthis->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, Animation_GetLastFrame(&gPeehatRisingAnim), + ANIMMODE_ONCE, 0.0f); + pthis->seekPlayerTimer = 400; + pthis->unk2D4 = 0; + pthis->unk2FA = 0; //! @bug: overwrites number of child larva spawned, allowing for more than MAX_LARVA spawns + pthis->state = PEAHAT_STATE_4; + EnPeehat_SetupAction(pthis, EnPeehat_Flying_StateGrounded); +} + +void EnPeehat_Flying_StateGrounded(EnPeehat* pthis, GlobalContext* globalCtx) { + if (IS_DAY) { + if (pthis->actor.xzDistToPlayer < pthis->xzDistToRise) { + EnPeehat_Flying_SetStateRise(pthis); + } + } else { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); + if (pthis->unk2D4 != 0) { + pthis->unk2D4--; + if (pthis->unk2D4 & 4) { + Math_SmoothStepToF(&pthis->scaleShift, 0.205f, 1.0f, 0.235f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->scaleShift, 0.0f, 1.0f, 0.005f, 0.0f); + } + } else if (pthis->colCylinder.base.acFlags & AC_HIT) { + EnPeehat_HitWhenGrounded(pthis, globalCtx); + } + } +} + +void EnPeehat_Flying_SetStateFly(EnPeehat* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gPeehatFlyingAnim); + pthis->state = PEAHAT_STATE_FLY; + EnPeehat_SetupAction(pthis, EnPeehat_Flying_StateFly); +} + +void EnPeehat_Flying_StateFly(EnPeehat* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); + SkelAnime_Update(&pthis->skelAnime); + if (!IS_DAY || pthis->xzDistToRise < pthis->actor.xzDistToPlayer) { + EnPeehat_Flying_SetStateLanding(pthis); + } else if (pthis->actor.xzDistToPlayer < pthis->xzDistMax) { + if (pthis->unk2FA < MAX_LARVA && (globalCtx->gameplayFrames & 7) == 0) { + Actor* larva = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_PEEHAT, + Rand_CenteredFloat(25.0f) + pthis->actor.world.pos.x, + Rand_CenteredFloat(5.0f) + pthis->actor.world.pos.y, + Rand_CenteredFloat(25.0f) + pthis->actor.world.pos.z, 0, 0, 0, 1); + if (larva != NULL) { + larva->shape.rot.y = larva->world.rot.y = Rand_CenteredFloat(0xFFFF); + pthis->unk2FA++; + } + } + } + pthis->bladeRot += pthis->bladeRotVel; +} + +void EnPeehat_Ground_SetStateRise(EnPeehat* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gPeehatRisingAnim); + + if (pthis->state != PEAHAT_STATE_STUNNED) { + Animation_Change(&pthis->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + } + pthis->state = PEAHAT_STATE_8; + pthis->animTimer = lastFrame; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_UP); + EnPeehat_SetupAction(pthis, EnPeehat_Ground_StateRise); +} + +void EnPeehat_Ground_StateRise(EnPeehat* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 1.0f, 50.0f, 0.0f); + if (Math_SmoothStepToS(&pthis->bladeRotVel, 4000, 1, 800, 0) == 0) { + if (pthis->animTimer != 0) { + pthis->animTimer--; + if (pthis->skelAnime.playSpeed == 0.0f) { + if (pthis->animTimer == 0) { + pthis->animTimer = 40; + pthis->skelAnime.playSpeed = 1.0f; + } + } + } + if (SkelAnime_Update(&pthis->skelAnime) || pthis->animTimer == 0) { + EnPeehat_Ground_SetStateHover(pthis); + } else { + pthis->actor.world.pos.y += 6.5f; + } + if (pthis->actor.world.pos.y - pthis->actor.floorHeight < 80.0f) { + Vec3f pos = pthis->actor.world.pos; + pos.y = pthis->actor.floorHeight; + func_80033480(globalCtx, &pos, 90.0f, 1, 0x96, 100, 1); + } + } + EnPeehat_SpawnDust(globalCtx, pthis, &pthis->actor.world.pos, 75.0f, 2, 1.05f, 2.0f); + Math_SmoothStepToF(&pthis->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); + pthis->bladeRot += pthis->bladeRotVel; +} + +void EnPeehat_Flying_SetStateRise(EnPeehat* pthis) { + f32 lastFrame; + + lastFrame = Animation_GetLastFrame(&gPeehatRisingAnim); + if (pthis->state != PEAHAT_STATE_STUNNED) { + Animation_Change(&pthis->skelAnime, &gPeehatRisingAnim, 0.0f, 3.0f, lastFrame, ANIMMODE_ONCE, 0.0f); + } + pthis->state = PEAHAT_STATE_9; + pthis->animTimer = lastFrame; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_UP); + EnPeehat_SetupAction(pthis, EnPeehat_Flying_StateRise); +} + +void EnPeehat_Flying_StateRise(EnPeehat* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 1.0f, 50.0f, 0.0f); + if (Math_SmoothStepToS(&pthis->bladeRotVel, 4000, 1, 800, 0) == 0) { + if (pthis->animTimer != 0) { + pthis->animTimer--; + if (pthis->skelAnime.playSpeed == 0.0f) { + if (pthis->animTimer == 0) { + pthis->animTimer = 40; + pthis->skelAnime.playSpeed = 1.0f; + } + } + } + if (SkelAnime_Update(&pthis->skelAnime) || pthis->animTimer == 0) { + //! @bug: overwrites number of child larva spawned, allowing for more than MAX_LARVA spawns + pthis->unk2FA = 0; + EnPeehat_Flying_SetStateFly(pthis); + } else { + pthis->actor.world.pos.y += 18.0f; + } + if (pthis->actor.world.pos.y - pthis->actor.floorHeight < 80.0f) { + Vec3f pos = pthis->actor.world.pos; + pos.y = pthis->actor.floorHeight; + func_80033480(globalCtx, &pos, 90.0f, 1, 0x96, 100, 1); + } + } + EnPeehat_SpawnDust(globalCtx, pthis, &pthis->actor.world.pos, 75.0f, 2, 1.05f, 2.0f); + Math_SmoothStepToF(&pthis->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); + pthis->bladeRot += pthis->bladeRotVel; +} + +void EnPeehat_Ground_SetStateSeekPlayer(EnPeehat* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gPeehatFlyingAnim); + pthis->state = PEAHAT_STATE_SEEK_PLAYER; + pthis->unk2E0 = 0.0f; + EnPeehat_SetupAction(pthis, EnPeehat_Ground_StateSeekPlayer); +} + +void EnPeehat_Ground_StateSeekPlayer(EnPeehat* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 3.0f, 1.0f, 0.25f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 80.0f, 1.0f, 3.0f, 0.0f); + if (pthis->seekPlayerTimer <= 0) { + EnPeehat_Ground_SetStateLanding(pthis); + pthis->riseDelayTimer = 40; + } else { + pthis->seekPlayerTimer--; + } + if (IS_DAY && (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < pthis->xzDistMax)) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 1000, 0); + if (pthis->unk2FA != 0) { + pthis->actor.shape.rot.y += 0x1C2; + } else { + pthis->actor.shape.rot.y -= 0x1C2; + } + } else { + EnPeehat_Ground_SetStateReturnHome(pthis); + } + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->bladeRotVel, 4000, 1, 500, 0); + pthis->bladeRot += pthis->bladeRotVel; + Math_SmoothStepToF(&pthis->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void EnPeehat_Larva_SetStateSeekPlayer(EnPeehat* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gPeehatFlyingAnim); + pthis->state = PEAHAT_STATE_SEEK_PLAYER; + pthis->unk2D4 = 0; + EnPeehat_SetupAction(pthis, EnPeehat_Larva_StateSeekPlayer); +} + +void EnPeehat_Larva_StateSeekPlayer(EnPeehat* pthis, GlobalContext* globalCtx) { + f32 speedXZ = 5.3f; + + if (pthis->actor.xzDistToPlayer <= 5.3f) { + speedXZ = pthis->actor.xzDistToPlayer + 0.0005f; + } + if (pthis->actor.parent != NULL && pthis->actor.parent->update == NULL) { + pthis->actor.parent = NULL; + } + pthis->actor.speedXZ = speedXZ; + if (pthis->actor.world.pos.y - pthis->actor.floorHeight >= 70.0f) { + Math_SmoothStepToF(&pthis->actor.velocity.y, -1.3f, 1.0f, 0.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->actor.velocity.y, -0.135f, 1.0f, 0.05f, 0.0f); + } + if (pthis->unk2D4 == 0) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 830, 0); + } else { + pthis->unk2D4--; + } + pthis->actor.shape.rot.y += 0x15E; + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->bladeRotVel, 4000, 1, 500, 0); + pthis->bladeRot += pthis->bladeRotVel; + Math_SmoothStepToF(&pthis->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_SM_FLY - SFX_FLAG); + if (pthis->colQuad.base.atFlags & AT_BOUNCED) { + pthis->actor.colChkInfo.health = 0; + pthis->colQuad.base.acFlags = pthis->colQuad.base.acFlags & ~AC_BOUNCED; + EnPeehat_SetStateAttackRecoil(pthis); + } else if ((pthis->colQuad.base.atFlags & AT_HIT) || (pthis->colCylinder.base.acFlags & AC_HIT) || + (pthis->actor.bgCheckFlags & 1)) { + Player* player = GET_PLAYER(globalCtx); + pthis->colQuad.base.atFlags &= ~AT_HIT; + if (!(pthis->colCylinder.base.acFlags & AC_HIT) && &player->actor == pthis->colQuad.base.at) { + if (Rand_ZeroOne() > 0.5f) { + pthis->actor.world.rot.y += 0x2000; + } else { + pthis->actor.world.rot.y -= 0x2000; + } + pthis->unk2D4 = 40; + } else if (pthis->colCylinder.base.acFlags & AC_HIT || pthis->actor.bgCheckFlags & 1) { + Vec3f zeroVec = { 0, 0, 0 }; + s32 i; + for (i = 4; i >= 0; i--) { + Vec3f pos; + pos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + pos.y = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &pos, &zeroVec, &zeroVec, 40, 7, 255, 255, 255, 255, 255, 0, 0, 1, 9, + 1); + } + } + if (&player->actor != pthis->colQuad.base.at || pthis->colCylinder.base.acFlags & AC_HIT) { + if (!(pthis->actor.bgCheckFlags & 1)) { + EffectSsDeadSound_SpawnStationary(globalCtx, &pthis->actor.projectedPos, NA_SE_EN_PIHAT_SM_DEAD, 1, 1, + 40); + } + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x20); + Actor_Kill(&pthis->actor); + } + } +} + +void EnPeehat_Ground_SetStateLanding(EnPeehat* pthis) { + pthis->state = PEAHAT_STATE_LANDING; + Animation_PlayOnce(&pthis->skelAnime, &gPeehatLandingAnim); + EnPeehat_SetupAction(pthis, EnPeehat_Ground_StateLanding); +} + +void EnPeehat_Ground_StateLanding(EnPeehat* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 50, 0); + if (SkelAnime_Update(&pthis->skelAnime)) { + EnPeehat_Ground_SetStateGround(pthis); + pthis->actor.world.pos.y = pthis->actor.floorHeight; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_LAND); + } else if (pthis->actor.floorHeight < pthis->actor.world.pos.y) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, 0.3f, 3.5f, 0.25f); + if (pthis->actor.world.pos.y - pthis->actor.floorHeight < 60.0f) { + Vec3f pos = pthis->actor.world.pos; + pos.y = pthis->actor.floorHeight; + func_80033480(globalCtx, &pos, 80.0f, 1, 150, 100, 1); + EnPeehat_SpawnDust(globalCtx, pthis, &pos, 75.0f, 2, 1.05f, 2.0f); + } + } + Math_SmoothStepToS(&pthis->bladeRotVel, 0, 1, 100, 0); + pthis->bladeRot += pthis->bladeRotVel; +} + +void EnPeehat_Flying_SetStateLanding(EnPeehat* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gPeehatLandingAnim); + pthis->state = PEAHAT_STATE_LANDING; + EnPeehat_SetupAction(pthis, EnPeehat_Flying_StateLanding); +} + +void EnPeehat_Flying_StateLanding(EnPeehat* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1000.0f, 1.0f, 50.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 50, 0); + if (SkelAnime_Update(&pthis->skelAnime)) { + EnPeehat_Flying_SetStateGround(pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_LAND); + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } else if (pthis->actor.floorHeight < pthis->actor.world.pos.y) { + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, 0.3f, 13.5f, 0.25f); + if (pthis->actor.world.pos.y - pthis->actor.floorHeight < 60.0f) { + Vec3f pos = pthis->actor.world.pos; + pos.y = pthis->actor.floorHeight; + func_80033480(globalCtx, &pos, 80.0f, 1, 150, 100, 1); + EnPeehat_SpawnDust(globalCtx, pthis, &pos, 75.0f, 2, 1.05f, 2.0f); + } + } + Math_SmoothStepToS(&pthis->bladeRotVel, 0, 1, 100, 0); + pthis->bladeRot += pthis->bladeRotVel; +} + +void EnPeehat_Ground_SetStateHover(EnPeehat* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gPeehatFlyingAnim); + pthis->actor.speedXZ = Rand_ZeroOne() * 0.5f + 2.5f; + pthis->unk2D4 = Rand_ZeroOne() * 10 + 10; + pthis->state = PEAHAT_STATE_15; + EnPeehat_SetupAction(pthis, EnPeehat_Ground_StateHover); +} + +void EnPeehat_Ground_StateHover(EnPeehat* pthis, GlobalContext* globalCtx) { + f32 cos; + Player* player = GET_PLAYER(globalCtx); + + // hover but don't gain altitude + if (pthis->actor.world.pos.y - pthis->actor.floorHeight > 75.0f) { + pthis->actor.world.pos.y -= 1.0f; + } + pthis->actor.world.pos.y += Math_CosF(pthis->unk2E0) * 1.4f; + cos = Math_CosF(pthis->unk2E0) * 0.18f; + pthis->unk2E0 += ((0.0f <= cos) ? cos : -cos) + 0.07f; + pthis->unk2D4--; + if (pthis->unk2D4 <= 0) { + pthis->actor.speedXZ = Rand_ZeroOne() * 0.5f + 2.5f; + pthis->unk2D4 = Rand_ZeroOne() * 10.0f + 10.0f; + pthis->unk2F4 = (Rand_ZeroOne() - 0.5f) * 1000.0f; + } + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.world.rot.y += pthis->unk2F4; + if (pthis->seekPlayerTimer <= 0) { + EnPeehat_Ground_SetStateLanding(pthis); + pthis->riseDelayTimer = 40; + } else { + pthis->seekPlayerTimer--; + } + pthis->actor.shape.rot.y += 0x15E; + // if daytime, and the player is close to the initial spawn position + if (IS_DAY && Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < pthis->xzDistMax) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnPeehat_Ground_SetStateSeekPlayer(pthis); + pthis->unk2FA = globalCtx->gameplayFrames & 1; + } else { + EnPeehat_Ground_SetStateReturnHome(pthis); + } + Math_SmoothStepToS(&pthis->bladeRotVel, 4000, 1, 500, 0); + pthis->bladeRot += pthis->bladeRotVel; + Math_SmoothStepToF(&pthis->scaleShift, 0.075f, 1.0f, 0.005f, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void EnPeehat_Ground_SetStateReturnHome(EnPeehat* pthis) { + pthis->state = PEAHAT_STATE_RETURN_HOME; + pthis->actor.speedXZ = 2.5f; + EnPeehat_SetupAction(pthis, EnPeehat_Ground_StateReturnHome); +} + +void EnPeehat_Ground_StateReturnHome(EnPeehat* pthis, GlobalContext* globalCtx) { + f32 cos; + s16 yRot; + Player* player; + + player = GET_PLAYER(globalCtx); + if (pthis->actor.world.pos.y - pthis->actor.floorHeight > 75.0f) { + pthis->actor.world.pos.y -= 1.0f; + } else { + pthis->actor.world.pos.y += 1.0f; + } + pthis->actor.world.pos.y += Math_CosF(pthis->unk2E0) * 1.4f; + cos = Math_CosF(pthis->unk2E0) * 0.18f; + pthis->unk2E0 += ((0.0f <= cos) ? cos : -cos) + 0.07f; + yRot = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + Math_SmoothStepToS(&pthis->actor.world.rot.y, yRot, 1, 600, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 4500, 1, 600, 0); + pthis->actor.shape.rot.y += 0x15E; + pthis->bladeRot += pthis->bladeRotVel; + if (Math_Vec3f_DistXZ(&pthis->actor.world.pos, &pthis->actor.home.pos) < 2.0f) { + EnPeehat_Ground_SetStateLanding(pthis); + pthis->riseDelayTimer = 60; + } + if (IS_DAY && Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < pthis->xzDistMax) { + pthis->seekPlayerTimer = 400; + EnPeehat_Ground_SetStateSeekPlayer(pthis); + pthis->unk2FA = (globalCtx->gameplayFrames & 1); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void EnPeehat_SetStateAttackRecoil(EnPeehat* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPeehatRecoilAnim, -4.0f); + pthis->state = PEAHAT_STATE_ATTACK_RECOIL; + pthis->actor.speedXZ = -9.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnPeehat_SetupAction(pthis, EnPeehat_StateAttackRecoil); +} + +void EnPeehat_StateAttackRecoil(EnPeehat* pthis, GlobalContext* globalCtx) { + pthis->bladeRot += pthis->bladeRotVel; + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.speedXZ += 0.5f; + if (pthis->actor.speedXZ == 0.0f) { + // Is PEAHAT_TYPE_LARVA + if (pthis->actor.params > 0) { + Vec3f zeroVec = { 0, 0, 0 }; + s32 i; + for (i = 4; i >= 0; i--) { + Vec3f pos; + pos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + pos.y = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &pos, &zeroVec, &zeroVec, 40, 7, 255, 255, 255, 255, 255, 0, 0, 1, 9, + 1); + } + Actor_Kill(&pthis->actor); + } else { + EnPeehat_Ground_SetStateSeekPlayer(pthis); + // Is PEAHAT_TYPE_GROUNDED + if (pthis->actor.params < 0) { + pthis->unk2FA = (pthis->unk2FA != 0) ? 0 : 1; + } + } + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void EnPeehat_SetStateBoomerangStunned(EnPeehat* pthis) { + pthis->state = PEAHAT_STATE_STUNNED; + if (pthis->actor.floorHeight < pthis->actor.world.pos.y) { + pthis->actor.speedXZ = -9.0f; + } + pthis->bladeRotVel = 0; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Actor_SetColorFilter(&pthis->actor, 0, 200, 0, 80); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + EnPeehat_SetupAction(pthis, EnPeehat_StateBoomerangStunned); +} + +void EnPeehat_StateBoomerangStunned(EnPeehat* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, 1.0f, 8.0f, 0.0f); + if (pthis->actor.colorFilterTimer == 0) { + EnPeehat_Ground_SetStateRise(pthis); + } +} + +void EnPeehat_Adult_SetStateDie(EnPeehat* pthis) { + pthis->bladeRotVel = 0; + pthis->isStateDieFirstUpdate = 1; + pthis->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 8); + pthis->state = PEAHAT_STATE_DYING; + pthis->scaleShift = 0.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnPeehat_SetupAction(pthis, EnPeehat_Adult_StateDie); +} + +void EnPeehat_Adult_StateDie(EnPeehat* pthis, GlobalContext* globalCtx) { + if (pthis->isStateDieFirstUpdate) { + pthis->unk2D4--; + if (pthis->unk2D4 <= 0 || pthis->actor.colChkInfo.health == 0) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPeehatRecoilAnim, -4.0f); + pthis->bladeRotVel = 4000; + pthis->unk2D4 = 14; + pthis->actor.speedXZ = 0; + pthis->actor.velocity.y = 6; + pthis->isStateDieFirstUpdate = 0; + pthis->actor.shape.rot.z = pthis->actor.shape.rot.x = 0; + } else if (pthis->actor.colorFilterTimer & 4) { + Math_SmoothStepToF(&pthis->scaleShift, 0.205f, 1.0f, 0.235f, 0); + } else { + Math_SmoothStepToF(&pthis->scaleShift, 0, 1.0f, 0.005f, 0); + } + } else { + SkelAnime_Update(&pthis->skelAnime); + pthis->bladeRot += pthis->bladeRotVel; + Math_SmoothStepToS(&pthis->bladeRotVel, 4000, 1, 250, 0); + if (pthis->actor.colChkInfo.health == 0) { + pthis->actor.scale.x -= 0.0015f; + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + } + if (Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight + 88.5f, 1.0f, 3.0f, 0.0f) == 0.0f && + pthis->actor.world.pos.y - pthis->actor.floorHeight < 59.0f) { + Vec3f pos = pthis->actor.world.pos; + pos.y = pthis->actor.floorHeight; + func_80033480(globalCtx, &pos, 80.0f, 1, 150, 100, 1); + EnPeehat_SpawnDust(globalCtx, pthis, &pos, 75.0f, 2, 1.05f, 2.0f); + } + if (pthis->actor.speedXZ < 0) { + pthis->actor.speedXZ += 0.25f; + } + pthis->unk2D4--; + if (pthis->unk2D4 <= 0) { + if (pthis->actor.colChkInfo.health == 0) { + EnPeehat_SetStateExplode(pthis); + // if PEAHAT_TYPE_GROUNDED + } else if (pthis->actor.params < 0) { + EnPeehat_Ground_SetStateHover(pthis); + pthis->riseDelayTimer = 60; + } else { + EnPeehat_Flying_SetStateFly(pthis); + } + } + } +} + +void EnPeehat_SetStateExplode(EnPeehat* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gPeehatFlyingAnim); + pthis->state = PEAHAT_STATE_EXPLODE; + pthis->animTimer = 5; + pthis->unk2E0 = 0.0f; + EnPeehat_SetupAction(pthis, EnPeehat_StateExplode); +} + +void EnPeehat_StateExplode(EnPeehat* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + s32 pad[2]; + + if (pthis->animTimer == 5) { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0x602, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + } + pthis->animTimer--; + if (pthis->animTimer == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x40); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x40); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x40); + Actor_Kill(&pthis->actor); + } +} + +void EnPeehat_Adult_CollisionCheck(EnPeehat* pthis, GlobalContext* globalCtx) { + if ((pthis->colCylinder.base.acFlags & AC_BOUNCED) || (pthis->colQuad.base.acFlags & AC_BOUNCED)) { + pthis->colQuad.base.acFlags &= ~AC_BOUNCED; + pthis->colCylinder.base.acFlags &= ~AC_BOUNCED; + pthis->colJntSph.base.acFlags &= ~AC_HIT; + } else if (pthis->colJntSph.base.acFlags & AC_HIT) { + pthis->colJntSph.base.acFlags &= ~AC_HIT; + Actor_SetDropFlagJntSph(&pthis->actor, &pthis->colJntSph, 1); + if (pthis->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_NUT || + pthis->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_LIGHT_ICE_ARROW) { + return; + } + if (pthis->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_HOOKSHOT) { + pthis->actor.colChkInfo.health = 0; + } else if (pthis->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_BOOMERANG) { + if (pthis->state != PEAHAT_STATE_STUNNED) { + EnPeehat_SetStateBoomerangStunned(pthis); + } + return; + } else { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 8); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PIHAT_DAMAGE); + } + + if (pthis->actor.colChkInfo.damageEffect == PEAHAT_DMG_EFF_FIRE) { + Vec3f pos; + s32 i; + for (i = 4; i >= 0; i--) { + pos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + pos.y = Rand_ZeroOne() * 25.0f + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &pos, 70, 0, 0, -1); + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 200, 0, 100); + } + if (pthis->actor.colChkInfo.health == 0) { + EnPeehat_Adult_SetStateDie(pthis); + } + } +} + +void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* pthis = (EnPeehat*)thisx; + s32 i; + Player* player = GET_PLAYER(globalCtx); + + // If Adult Peahat + if (thisx->params <= 0) { + EnPeehat_Adult_CollisionCheck(pthis, globalCtx); + } + if (thisx->colChkInfo.damageEffect != PEAHAT_DMG_EFF_LIGHT_ICE_ARROW) { + if (thisx->speedXZ != 0.0f || thisx->velocity.y != 0.0f) { + Actor_MoveForward(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 30.0f, 30.0f, 5); + } + + pthis->actionFunc(pthis, globalCtx); + if ((globalCtx->gameplayFrames & 0x7F) == 0) { + pthis->jiggleRotInc = (Rand_ZeroOne() * 0.25f) + 0.5f; + } + pthis->jiggleRot += pthis->jiggleRotInc; + } + // if PEAHAT_TYPE_GROUNDED + if (thisx->params < 0) { + // Set the Z-Target point on the Peahat's weak point + thisx->focus.pos.x = pthis->colJntSph.elements[0].dim.worldSphere.center.x; + thisx->focus.pos.y = pthis->colJntSph.elements[0].dim.worldSphere.center.y; + thisx->focus.pos.z = pthis->colJntSph.elements[0].dim.worldSphere.center.z; + if (pthis->state == PEAHAT_STATE_SEEK_PLAYER) { + Math_SmoothStepToS(&thisx->shape.rot.x, 6000, 1, 300, 0); + } else { + Math_SmoothStepToS(&thisx->shape.rot.x, 0, 1, 300, 0); + } + } else { + thisx->focus.pos = thisx->world.pos; + } + Collider_UpdateCylinder(thisx, &pthis->colCylinder); + if (thisx->colChkInfo.health > 0) { + // If Adult Peahat + if (thisx->params <= 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colJntSph.base); + if (thisx->colorFilterTimer == 0 || !(thisx->colorFilterParams & 0x4000)) { + if (pthis->state != PEAHAT_STATE_EXPLODE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colJntSph.base); + } + } + } + if (thisx->params != PEAHAT_TYPE_FLYING && pthis->colQuad.base.atFlags & AT_HIT) { + pthis->colQuad.base.atFlags &= ~AT_HIT; + if (&player->actor == pthis->colQuad.base.at) { + EnPeehat_SetStateAttackRecoil(pthis); + } + } + } + if (pthis->state == PEAHAT_STATE_15 || pthis->state == PEAHAT_STATE_SEEK_PLAYER || pthis->state == PEAHAT_STATE_FLY || + pthis->state == PEAHAT_STATE_RETURN_HOME || pthis->state == PEAHAT_STATE_EXPLODE) { + if (thisx->params != PEAHAT_TYPE_FLYING) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colQuad.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colQuad.base); + } + // if PEAHAT_TYPE_GROUNDED + if (thisx->params < 0 && (thisx->flags & ACTOR_FLAG_UNCULLED)) { + for (i = 1; i >= 0; i--) { + Vec3f posResult; + CollisionPoly* poly = NULL; + s32 bgId; + Vec3f* posB = &pthis->bladeTip[i]; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, posB, &posResult, &poly, true, true, + false, true, &bgId) == true) { + func_80033480(globalCtx, &posResult, 0.0f, 1, 300, 150, 1); + EnPeehat_SpawnDust(globalCtx, pthis, &posResult, 0.0f, 3, 1.05f, 1.5f); + } + } + } else if (thisx->params != PEAHAT_TYPE_FLYING) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder.base); + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder.base); + } + Math_SmoothStepToF(&pthis->scaleShift, 0.0f, 1.0f, 0.001f, 0.0f); +} + +s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnPeehat* pthis = (EnPeehat*)thisx; + + if (limbIndex == 4) { + rot->x = -pthis->bladeRot; + } + if (limbIndex == 3 || (limbIndex == 23 && (pthis->state == PEAHAT_STATE_DYING || pthis->state == PEAHAT_STATE_3 || + pthis->state == PEAHAT_STATE_4))) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1946); + Matrix_Push(); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateX(pthis->jiggleRot * 0.115f, MTXMODE_APPLY); + Matrix_RotateY(pthis->jiggleRot * 0.13f, MTXMODE_APPLY); + Matrix_RotateZ(pthis->jiggleRot * 0.1f, MTXMODE_APPLY); + Matrix_Scale(1.0f - pthis->scaleShift, pthis->scaleShift + 1.0f, 1.0f - pthis->scaleShift, MTXMODE_APPLY); + Matrix_RotateZ(-(pthis->jiggleRot * 0.1f), MTXMODE_APPLY); + Matrix_RotateY(-(pthis->jiggleRot * 0.13f), MTXMODE_APPLY); + Matrix_RotateX(-(pthis->jiggleRot * 0.115f), MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1959), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1963); + return true; + } + return false; +} + +void EnPeehat_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f peahatBladeTip[] = { { 0.0f, 0.0f, 5500.0f }, { 0.0f, 0.0f, -5500.0f } }; + + EnPeehat* pthis = (EnPeehat*)thisx; + f32 damageYRot; + + if (limbIndex == 4) { + Matrix_MultVec3f(&peahatBladeTip[0], &pthis->bladeTip[0]); + Matrix_MultVec3f(&peahatBladeTip[1], &pthis->bladeTip[1]); + return; + } + // is Adult Peahat + if (limbIndex == 3 && pthis->actor.params <= 0) { + damageYRot = 0.0f; + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1981); + Matrix_Push(); + Matrix_Translate(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &pthis->colJntSph); + Matrix_Translate(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if (pthis->actor.colorFilterTimer != 0 && (pthis->actor.colorFilterParams & 0x4000)) { + damageYRot = Math_SinS(pthis->actor.colorFilterTimer * 0x4E20) * 0.35f; + } + Matrix_RotateY(3.2f + damageYRot, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1990), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + Matrix_Pop(); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_peehat.c", 1994); + } +} + +void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_80AD285C[] = { + { 0.0f, 0.0f, -4500.0f }, { -4500.0f, 0.0f, 0.0f }, { 4500.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 4500.0f } + }; + EnPeehat* pthis = (EnPeehat*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnPeehat_OverrideLimbDraw, + EnPeehat_PostLimbDraw, pthis); + if (pthis->actor.speedXZ != 0.0f || pthis->actor.velocity.y != 0.0f) { + Matrix_MultVec3f(&D_80AD285C[0], &pthis->colQuad.dim.quad[1]); + Matrix_MultVec3f(&D_80AD285C[1], &pthis->colQuad.dim.quad[0]); + Matrix_MultVec3f(&D_80AD285C[2], &pthis->colQuad.dim.quad[3]); + Matrix_MultVec3f(&D_80AD285C[3], &pthis->colQuad.dim.quad[2]); + Collider_SetQuadVertices(&pthis->colQuad, &pthis->colQuad.dim.quad[0], &pthis->colQuad.dim.quad[1], + &pthis->colQuad.dim.quad[2], &pthis->colQuad.dim.quad[3]); + } +} diff --git a/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c b/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c deleted file mode 100644 index e6947f7a0..000000000 --- a/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c +++ /dev/null @@ -1,283 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_DESERT_Z_EN_PO_DESERT_C -#include "actor_common.h" -/* - * File: z_en_po_desert.c - * Overlay: ovl_En_Po_Desert - * Description: Guide Poe (Haunted Wasteland) - */ - -#include "z_en_po_desert.h" -#include "objects/object_po_field/object_po_field.h" -#include "def/code_800FD970.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_7 | ACTOR_FLAG_12) - -void EnPoDesert_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoDesert_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoDesert_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoDesert_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnPoDesert_SetNextPathPoint(EnPoDesert* this, GlobalContext* globalCtx); -void EnPoDesert_WaitForPlayer(EnPoDesert* this, GlobalContext* globalCtx); -void EnPoDesert_MoveToNextPoint(EnPoDesert* this, GlobalContext* globalCtx); -void EnPoDesert_Disappear(EnPoDesert* this, GlobalContext* globalCtx); - -const ActorInit En_Po_Desert_InitVars = { - ACTOR_EN_PO_DESERT, - ACTORCAT_BG, - FLAGS, - OBJECT_PO_FIELD, - sizeof(EnPoDesert), - (ActorFunc)EnPoDesert_Init, - (ActorFunc)EnPoDesert_Destroy, - (ActorFunc)EnPoDesert_Update, - (ActorFunc)EnPoDesert_Draw, -}; - -static ColliderCylinderInit sColliderInit = { - { - COLTYPE_HIT3, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 25, 50, 20, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x5C, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), -}; - -void EnPoDesert_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnPoDesert* this = (EnPoDesert*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gPoeFieldSkel, &gPoeFieldFloatAnim, this->jointTable, this->morphTable, - 10); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sColliderInit); - this->lightColor.r = 255; - this->lightColor.g = 255; - this->lightColor.b = 210; - this->lightColor.a = 255; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - 255, 255, 255, 200); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 37.0f); - this->currentPathPoint = 1; - this->actor.params = (this->actor.params >> 8) & 0xFF; - this->targetY = this->actor.world.pos.y; - EnPoDesert_SetNextPathPoint(this, globalCtx); -} - -void EnPoDesert_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPoDesert* this = (EnPoDesert*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnPoDesert_SetNextPathPoint(EnPoDesert* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[this->actor.params]; - Vec3s* pathPoint; - - Animation_MorphToLoop(&this->skelAnime, &gPoeFieldDisappearAnim, -6.0f); - pathPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->currentPathPoint]; - this->actor.home.pos.x = pathPoint->x; - this->actor.home.pos.y = pathPoint->y; - this->actor.home.pos.z = pathPoint->z; - this->initDistToNextPoint = Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos); - this->initDistToNextPoint = CLAMP_MIN(this->initDistToNextPoint, 1.0f); - this->currentPathPoint++; - this->yDiff = this->actor.home.pos.y - this->actor.world.pos.y; - this->actor.speedXZ = 0.0f; - if (path->count == this->currentPathPoint) { - this->currentPathPoint = 0; - } - this->actionFunc = EnPoDesert_WaitForPlayer; -} - -void EnPoDesert_SetupMoveToNextPoint(EnPoDesert* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeFieldFloatAnim, -5.0f); - this->actionFunc = EnPoDesert_MoveToNextPoint; -} - -void EnPoDesert_SetupDisappear(EnPoDesert* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPoeFieldDisappearAnim, -6.0f); - this->actionTimer = 16; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - this->actionFunc = EnPoDesert_Disappear; -} - -void EnPoDesert_UpdateSpeedModifier(EnPoDesert* this) { - if (this->speedModifier == 0) { - this->speedModifier = 32; - } - if (this->speedModifier != 0) { - this->speedModifier--; - } - this->actor.world.pos.y = Math_SinS(this->speedModifier * 0x800) * 13.0f + this->targetY; -} - -void EnPoDesert_WaitForPlayer(EnPoDesert* this, GlobalContext* globalCtx) { - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - if (this->actor.xzDistToPlayer < 200.0f && (this->currentPathPoint != 2 || globalCtx->actorCtx.unk_03)) { - if (this->currentPathPoint == 2) { - if (Gameplay_InCsMode(globalCtx)) { - this->actor.shape.rot.y += 0x800; - return; - } - Message_StartTextbox(globalCtx, 0x600B, NULL); - } - EnPoDesert_SetupMoveToNextPoint(this); - } else { - this->actor.shape.rot.y += 0x800; - } -} - -void EnPoDesert_MoveToNextPoint(EnPoDesert* this, GlobalContext* globalCtx) { - f32 temp_f20; - - if (this->actionTimer != 0) { - this->actionTimer--; - } - temp_f20 = sinf(this->actionTimer * (M_PI / 20.0f)) * 5.0f; - this->actor.world.pos.x += temp_f20 * Math_CosS(this->actor.shape.rot.y); - this->actor.world.pos.z += temp_f20 * Math_SinS(this->actor.shape.rot.y); - if (this->actionTimer == 0) { - this->actionTimer = 40; - } - temp_f20 = Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos); - this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y + 0x8000, 5, 0x400); - this->actor.speedXZ = sinf(this->speedModifier * (M_PI / 32.0f)) * 2.5f + 5.5f; - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - this->targetY = this->actor.home.pos.y - ((temp_f20 * this->yDiff) / this->initDistToNextPoint); - if (temp_f20 < 40.0f) { - if (this->currentPathPoint != 0) { - EnPoDesert_SetNextPathPoint(this, globalCtx); - } else { - EnPoDesert_SetupDisappear(this); - } - } -} - -void EnPoDesert_Disappear(EnPoDesert* this, GlobalContext* globalCtx) { - if (this->actionTimer != 0) { - this->actionTimer--; - } - this->actor.shape.rot.y += 0x2000; - this->lightColor.a = this->actionTimer * 15.9375f; - this->actor.shape.shadowAlpha = this->lightColor.a; - if (this->actionTimer == 0) { - Actor_Kill(&this->actor); - } -} - -void EnPoDesert_Update(Actor* thisx, GlobalContext* globalCtx) { - EnPoDesert* this = (EnPoDesert*)thisx; - s32 pad; - - SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - EnPoDesert_UpdateSpeedModifier(this); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 27.0f, 60.0f, 4); - Actor_SetFocus(&this->actor, 42.0f); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (globalCtx->actorCtx.unk_03) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_7; - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - } else { - this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_7); - } -} - -s32 EnPoDesert_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx, Gfx** gfxP) { - EnPoDesert* this = (EnPoDesert*)thisx; - f32 mtxScale; - - if (this->actionFunc == EnPoDesert_Disappear && limbIndex == 7) { - mtxScale = this->actionTimer / 16.0f; - Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - } - if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { - *dList = NULL; - } - return false; -} - -void EnPoDesert_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, - Gfx** gfxP) { - static Vec3f baseLightPos = { 0.0f, 1400.0f, 0.0f }; - - EnPoDesert* this = (EnPoDesert*)thisx; - f32 rand; - Color_RGBA8 color; - Vec3f lightPos; - - if (limbIndex == 7) { - Matrix_MultVec3f(&baseLightPos, &lightPos); - rand = Rand_ZeroOne(); - color.r = (s16)(rand * 30.0f) + 225; - color.g = (s16)(rand * 100.0f) + 155; - color.b = (s16)(rand * 160.0f) + 95; - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { - gDPPipeSync((*gfxP)++); - gDPSetEnvColor((*gfxP)++, color.r, color.g, color.b, 255); - gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_desert.c", 523), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfxP)++, gPoeFieldLanternDL); - gSPDisplayList((*gfxP)++, gPoeFieldLanternTopDL); - gDPPipeSync((*gfxP)++); - gDPSetEnvColor((*gfxP)++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); - } - Lights_PointNoGlowSetInfo(&this->lightInfo, lightPos.x, lightPos.y, lightPos.z, color.r, color.g, color.b, 200); - } -} - -void EnPoDesert_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnPoDesert* this = (EnPoDesert*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_desert.c", 559); - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 85, 0, 255)); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, - this->lightColor.a)); - if (this->actionFunc == EnPoDesert_Disappear) { - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - } else { - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280 + 2); - } - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoDesert_OverrideLimbDraw, EnPoDesert_PostLimbDraw, &this->actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_desert.c", 597); -} diff --git a/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.cpp b/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.cpp new file mode 100644 index 000000000..0b2f60582 --- /dev/null +++ b/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.cpp @@ -0,0 +1,283 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_DESERT_Z_EN_PO_DESERT_C +#include "actor_common.h" +/* + * File: z_en_po_desert.c + * Overlay: ovl_En_Po_Desert + * Description: Guide Poe (Haunted Wasteland) + */ + +#include "z_en_po_desert.h" +#include "objects/object_po_field/object_po_field.h" +#include "def/code_800FD970.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_7 | ACTOR_FLAG_12) + +void EnPoDesert_Init(Actor* thisx, GlobalContext* globalCtx); +void EnPoDesert_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnPoDesert_Update(Actor* thisx, GlobalContext* globalCtx); +void EnPoDesert_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnPoDesert_SetNextPathPoint(EnPoDesert* pthis, GlobalContext* globalCtx); +void EnPoDesert_WaitForPlayer(EnPoDesert* pthis, GlobalContext* globalCtx); +void EnPoDesert_MoveToNextPoint(EnPoDesert* pthis, GlobalContext* globalCtx); +void EnPoDesert_Disappear(EnPoDesert* pthis, GlobalContext* globalCtx); + +ActorInit En_Po_Desert_InitVars = { + ACTOR_EN_PO_DESERT, + ACTORCAT_BG, + FLAGS, + OBJECT_PO_FIELD, + sizeof(EnPoDesert), + (ActorFunc)EnPoDesert_Init, + (ActorFunc)EnPoDesert_Destroy, + (ActorFunc)EnPoDesert_Update, + (ActorFunc)EnPoDesert_Draw, +}; + +static ColliderCylinderInit sColliderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 25, 50, 20, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x5C, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), +}; + +void EnPoDesert_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPoDesert* pthis = (EnPoDesert*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gPoeFieldSkel, &gPoeFieldFloatAnim, pthis->jointTable, pthis->morphTable, + 10); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sColliderInit); + pthis->lightColor.r = 255; + pthis->lightColor.g = 255; + pthis->lightColor.b = 210; + pthis->lightColor.a = 255; + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, + 255, 255, 255, 200); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 37.0f); + pthis->currentPathPoint = 1; + pthis->actor.params = (pthis->actor.params >> 8) & 0xFF; + pthis->targetY = pthis->actor.world.pos.y; + EnPoDesert_SetNextPathPoint(pthis, globalCtx); +} + +void EnPoDesert_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoDesert* pthis = (EnPoDesert*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnPoDesert_SetNextPathPoint(EnPoDesert* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[pthis->actor.params]; + Vec3s* pathPoint; + + Animation_MorphToLoop(&pthis->skelAnime, &gPoeFieldDisappearAnim, -6.0f); + pathPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[pthis->currentPathPoint]; + pthis->actor.home.pos.x = pathPoint->x; + pthis->actor.home.pos.y = pathPoint->y; + pthis->actor.home.pos.z = pathPoint->z; + pthis->initDistToNextPoint = Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos); + pthis->initDistToNextPoint = CLAMP_MIN(pthis->initDistToNextPoint, 1.0f); + pthis->currentPathPoint++; + pthis->yDiff = pthis->actor.home.pos.y - pthis->actor.world.pos.y; + pthis->actor.speedXZ = 0.0f; + if (path->count == pthis->currentPathPoint) { + pthis->currentPathPoint = 0; + } + pthis->actionFunc = EnPoDesert_WaitForPlayer; +} + +void EnPoDesert_SetupMoveToNextPoint(EnPoDesert* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeFieldFloatAnim, -5.0f); + pthis->actionFunc = EnPoDesert_MoveToNextPoint; +} + +void EnPoDesert_SetupDisappear(EnPoDesert* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPoeFieldDisappearAnim, -6.0f); + pthis->actionTimer = 16; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DISAPPEAR); + pthis->actionFunc = EnPoDesert_Disappear; +} + +void EnPoDesert_UpdateSpeedModifier(EnPoDesert* pthis) { + if (pthis->speedModifier == 0) { + pthis->speedModifier = 32; + } + if (pthis->speedModifier != 0) { + pthis->speedModifier--; + } + pthis->actor.world.pos.y = Math_SinS(pthis->speedModifier * 0x800) * 13.0f + pthis->targetY; +} + +void EnPoDesert_WaitForPlayer(EnPoDesert* pthis, GlobalContext* globalCtx) { + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + if (pthis->actor.xzDistToPlayer < 200.0f && (pthis->currentPathPoint != 2 || globalCtx->actorCtx.unk_03)) { + if (pthis->currentPathPoint == 2) { + if (Gameplay_InCsMode(globalCtx)) { + pthis->actor.shape.rot.y += 0x800; + return; + } + Message_StartTextbox(globalCtx, 0x600B, NULL); + } + EnPoDesert_SetupMoveToNextPoint(pthis); + } else { + pthis->actor.shape.rot.y += 0x800; + } +} + +void EnPoDesert_MoveToNextPoint(EnPoDesert* pthis, GlobalContext* globalCtx) { + f32 temp_f20; + + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + temp_f20 = sinf(pthis->actionTimer * (M_PI / 20.0f)) * 5.0f; + pthis->actor.world.pos.x += temp_f20 * Math_CosS(pthis->actor.shape.rot.y); + pthis->actor.world.pos.z += temp_f20 * Math_SinS(pthis->actor.shape.rot.y); + if (pthis->actionTimer == 0) { + pthis->actionTimer = 40; + } + temp_f20 = Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos); + pthis->actor.world.rot.y = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y + 0x8000, 5, 0x400); + pthis->actor.speedXZ = sinf(pthis->speedModifier * (M_PI / 32.0f)) * 2.5f + 5.5f; + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + pthis->targetY = pthis->actor.home.pos.y - ((temp_f20 * pthis->yDiff) / pthis->initDistToNextPoint); + if (temp_f20 < 40.0f) { + if (pthis->currentPathPoint != 0) { + EnPoDesert_SetNextPathPoint(pthis, globalCtx); + } else { + EnPoDesert_SetupDisappear(pthis); + } + } +} + +void EnPoDesert_Disappear(EnPoDesert* pthis, GlobalContext* globalCtx) { + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + pthis->actor.shape.rot.y += 0x2000; + pthis->lightColor.a = pthis->actionTimer * 15.9375f; + pthis->actor.shape.shadowAlpha = pthis->lightColor.a; + if (pthis->actionTimer == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnPoDesert_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPoDesert* pthis = (EnPoDesert*)thisx; + s32 pad; + + SkelAnime_Update(&pthis->skelAnime); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + EnPoDesert_UpdateSpeedModifier(pthis); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 27.0f, 60.0f, 4); + Actor_SetFocus(&pthis->actor, 42.0f); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (globalCtx->actorCtx.unk_03) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_7; + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + pthis->actor.shape.shadowDraw = NULL; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_7); + } +} + +s32 EnPoDesert_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx, Gfx** gfxP) { + EnPoDesert* pthis = (EnPoDesert*)thisx; + f32 mtxScale; + + if (pthis->actionFunc == EnPoDesert_Disappear && limbIndex == 7) { + mtxScale = pthis->actionTimer / 16.0f; + Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); + } + if (!CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { + *dList = NULL; + } + return false; +} + +void EnPoDesert_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, + Gfx** gfxP) { + static Vec3f baseLightPos = { 0.0f, 1400.0f, 0.0f }; + + EnPoDesert* pthis = (EnPoDesert*)thisx; + f32 rand; + Color_RGBA8 color; + Vec3f lightPos; + + if (limbIndex == 7) { + Matrix_MultVec3f(&baseLightPos, &lightPos); + rand = Rand_ZeroOne(); + color.r = (s16)(rand * 30.0f) + 225; + color.g = (s16)(rand * 100.0f) + 155; + color.b = (s16)(rand * 160.0f) + 95; + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { + gDPPipeSync((*gfxP)++); + gDPSetEnvColor((*gfxP)++, color.r, color.g, color.b, 255); + gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_desert.c", 523), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfxP)++, gPoeFieldLanternDL); + gSPDisplayList((*gfxP)++, gPoeFieldLanternTopDL); + gDPPipeSync((*gfxP)++); + gDPSetEnvColor((*gfxP)++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, pthis->lightColor.a); + } + Lights_PointNoGlowSetInfo(&pthis->lightInfo, lightPos.x, lightPos.y, lightPos.z, color.r, color.g, color.b, 200); + } +} + +void EnPoDesert_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPoDesert* pthis = (EnPoDesert*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_desert.c", 559); + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 85, 0, 255)); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, + pthis->lightColor.a)); + if (pthis->actionFunc == EnPoDesert_Disappear) { + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); + } else { + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280 + 2); + } + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoDesert_OverrideLimbDraw, EnPoDesert_PostLimbDraw, &pthis->actor, POLY_XLU_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_desert.c", 597); +} diff --git a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c deleted file mode 100644 index ed69ad79f..000000000 --- a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c +++ /dev/null @@ -1,1022 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_FIELD_Z_EN_PO_FIELD_C -#include "actor_common.h" -/* - * File: z_en_po_field.c - * Overlay: ovl_En_Po_Field - * Description: Field Poe - */ - -#include "z_en_po_field.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_po_field/object_po_field.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_12) - -void EnPoField_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoField_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoField_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoField_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnPoField_UpdateDead(Actor* thisx, GlobalContext* globalCtx); -void EnPoField_DrawSoul(Actor* thisx, GlobalContext* globalCtx); - -void EnPoField_SetupWaitForSpawn(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_WaitForSpawn(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_Appear(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_CirclePlayer(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_Damage(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_Flee(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_Death(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_Disappear(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_SoulIdle(EnPoField* this, GlobalContext* globalCtx); -void func_80AD587C(EnPoField* this, GlobalContext* globalCtx); -void func_80AD58D4(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_SoulDisappear(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_SoulInteract(EnPoField* this, GlobalContext* globalCtx); -void EnPoField_SpawnFlame(EnPoField* this); - -const ActorInit En_Po_Field_InitVars = { - ACTOR_EN_PO_FIELD, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_PO_FIELD, - sizeof(EnPoField), - (ActorFunc)EnPoField_Init, - (ActorFunc)EnPoField_Destroy, - (ActorFunc)EnPoField_Update, - (ActorFunc)EnPoField_Draw, -}; - -static ColliderCylinderInit D_80AD7080 = { - { - COLTYPE_HIT3, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 25, 50, 20, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit D_80AD70AC = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x01, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { 10, 30, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit D_80AD70D8 = { 4, 25, 50, 40 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(1, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static s32 sNumSpawned = 0; - -static Vec3f sFieldMiddle = { -1000.0f, 0.0f, 6500.0f }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), -}; - -static Vec3f D_80AD7114 = { 0.0f, 3.0f, 0.0f }; - -static Vec3f D_80AD7120 = { 0.0f, 0.0f, 0.0f }; - -static EnPoFieldInfo sPoFieldInfo[2] = { - { { 255, 170, 255 }, { 100, 0, 150 }, { 255, 85, 0 }, 248, gPoeFieldSoulTex }, - { { 255, 255, 170 }, { 255, 200, 0 }, { 160, 0, 255 }, 241, gBigPoeSoulTex }, -}; - -static Vec3f D_80AD714C = { 0.0f, 1400.0f, 0.0f }; - -static Vec3s sSpawnPositions[10]; -static u8 sSpawnSwitchFlags[10]; -static MtxF sLimb7Mtx; - -void EnPoField_Init(Actor* thisx, GlobalContext* globalCtx) { - EnPoField* this = (EnPoField*)thisx; - s32 pad; - - if (sNumSpawned != 10) { - sSpawnPositions[sNumSpawned].x = this->actor.world.pos.x; - sSpawnPositions[sNumSpawned].y = this->actor.world.pos.y; - sSpawnPositions[sNumSpawned].z = this->actor.world.pos.z; - sSpawnSwitchFlags[sNumSpawned] = this->actor.params & 0xFF; - sNumSpawned++; - } - if (sNumSpawned >= 2) { - this->actor.params = 0xFF; - Actor_Kill(&this->actor); - return; - } - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gPoeFieldSkel, &gPoeFieldFloatAnim, this->jointTable, this->morphTable, - 10); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80AD7080); - Collider_InitCylinder(globalCtx, &this->flameCollider); - Collider_SetCylinder(globalCtx, &this->flameCollider, &this->actor, &D_80AD70AC); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &D_80AD70D8); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - 255, 255, 255, 0); - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - EnPoField_SetupWaitForSpawn(this, globalCtx); -} - -void EnPoField_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPoField* this = (EnPoField*)thisx; - - if (this->actor.params != 0xFF) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyCylinder(globalCtx, &this->flameCollider); - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void EnPoField_SetupWaitForSpawn(EnPoField* this, GlobalContext* globalCtx) { - this->actor.update = EnPoField_Update; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - this->actor.shape.rot.x = 0; - Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); - this->actionTimer = 200; - Actor_SetScale(&this->actor, 0.0f); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_16); - this->collider.base.acFlags &= ~AC_ON; - this->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_ALL; - this->actor.colChkInfo.health = D_80AD70D8.health; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actionFunc = EnPoField_WaitForSpawn; -} - -void EnPoField_SetupAppear(EnPoField* this) { - Animation_PlayOnce(&this->skelAnime, &gPoeFieldAppearAnim); - this->actor.draw = EnPoField_Draw; - this->lightColor.r = 255; - this->lightColor.g = 255; - this->lightColor.b = 210; - this->lightColor.a = 0; - this->actor.shape.shadowAlpha = 0; - this->actor.shape.yOffset = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - this->actor.home.pos.y = this->actor.world.pos.y; - if (this->actor.params == EN_PO_FIELD_BIG) { - this->actor.speedXZ = 12.0f; - this->collider.dim.radius = 35; - this->collider.dim.height = 100; - this->collider.dim.yShift = 10; - this->actor.shape.shadowScale = 45.0f; - this->scaleModifier = 0.014f; - this->actor.naviEnemyId = 0x5A; - } else { - this->actor.speedXZ = 0.0f; - this->collider.dim.radius = D_80AD7080.dim.radius; - this->collider.dim.height = D_80AD7080.dim.height; - this->collider.dim.yShift = D_80AD7080.dim.yShift; - this->actor.shape.shadowScale = 37.0f; - this->scaleModifier = 0.01f; - this->actor.naviEnemyId = 0x5C; - } - this->actionFunc = EnPoField_Appear; -} - -void EnPoField_SetupCirclePlayer(EnPoField* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Animation_PlayLoop(&this->skelAnime, &gPoeFieldFloatAnim); - this->collider.base.acFlags |= AC_ON; - this->scaleModifier = this->actor.xzDistToPlayer; - Math_Vec3f_Copy(&this->actor.home.pos, &player->actor.world.pos); - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (this->actionFunc != EnPoField_Damage) { - this->actor.flags |= ACTOR_FLAG_0; - this->actionTimer = 600; - this->unk_194 = 32; - } - this->actionFunc = EnPoField_CirclePlayer; -} - -void EnPoField_SetupFlee(EnPoField* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeFieldFleeAnim, -5.0f); - this->collider.base.acFlags |= AC_ON; - this->actionFunc = EnPoField_Flee; - this->actor.speedXZ = 12.0f; - if (this->actionFunc != EnPoField_Damage) { - this->actor.flags |= ACTOR_FLAG_0; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; - this->actionTimer = 2000; - this->unk_194 = 32; - } -} - -void EnPoField_SetupDamage(EnPoField* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPoeFieldDamagedAnim, -6.0f); - if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) { - this->actor.world.rot.y = this->collider.base.ac->world.rot.y; - } else { - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac) + 0x8000; - } - this->collider.base.acFlags &= ~(AC_HIT | AC_ON); - this->actor.speedXZ = 5.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); - this->actionFunc = EnPoField_Damage; -} - -void EnPoField_SetupDeath(EnPoField* this) { - this->actionTimer = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.naviEnemyId = 0xFF; - if (this->flameTimer >= 20) { - this->flameTimer = 19; - } - this->actionFunc = EnPoField_Death; -} - -void EnPoField_SetupDisappear(EnPoField* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeFieldDisappearAnim, -6.0f); - this->actionTimer = 16; - this->collider.base.acFlags &= ~(AC_HIT | AC_ON); - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - this->actionFunc = EnPoField_Disappear; -} - -void EnPoField_SetupSoulIdle(EnPoField* this, GlobalContext* globalCtx) { - this->actor.update = EnPoField_UpdateDead; - this->actor.draw = EnPoField_DrawSoul; - this->actor.shape.shadowDraw = NULL; - Actor_SetScale(&this->actor, 0.01f); - this->actor.gravity = -1.0f; - this->actor.shape.yOffset = 1500.0f; - this->actor.shape.rot.x = -0x8000; - this->actionTimer = 60; - this->actor.world.pos.y -= 15.0f; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); - this->actionFunc = EnPoField_SoulIdle; -} - -void func_80AD42B0(EnPoField* this) { - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); - this->actor.shape.rot.y = 0; - this->lightColor.a = 0; - this->actor.shape.rot.x = 0; - this->actor.shape.yOffset = 0.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.home.pos.y = this->actor.world.pos.y; - this->actor.scale.x = 0.0f; - this->actor.scale.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); - if (this->actor.params == EN_PO_FIELD_BIG) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - this->actionFunc = func_80AD587C; -} - -void func_80AD4384(EnPoField* this) { - this->actor.home.pos.y = this->actor.world.pos.y; - Actor_SetFocus(&this->actor, -10.0f); - this->collider.dim.radius = 13; - this->collider.dim.height = 30; - this->collider.dim.yShift = 0; - this->collider.dim.pos.x = this->actor.world.pos.x; - this->collider.dim.pos.y = this->actor.world.pos.y - 20.0f; - this->collider.dim.pos.z = this->actor.world.pos.z; - this->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_PLAYER; - this->actor.textId = 0x5005; - this->actionTimer = 400; - this->unk_194 = 32; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = func_80AD58D4; -} - -void EnPoField_SetupSoulDisappear(EnPoField* this) { - this->actionFunc = EnPoField_SoulDisappear; -} - -void EnPoField_SetupInteractWithSoul(EnPoField* this) { - this->actionFunc = EnPoField_SoulInteract; - this->actor.home.pos.y = this->actor.world.pos.y - 15.0f; -} - -void EnPoField_CorrectYPos(EnPoField* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->unk_194 == 0) { - this->unk_194 = 32; - } - if (this->unk_194 != 0) { - this->unk_194 -= 1; - } - if (this->actor.floorHeight == BGCHECK_Y_MIN) { - EnPoField_SetupDisappear(this); - return; - } - Math_ApproachF( - &this->actor.home.pos.y, - ((player->actor.world.pos.y > this->actor.floorHeight) ? player->actor.world.pos.y : this->actor.floorHeight) + - 13.0f, - 0.2f, 5.0f); - this->actor.world.pos.y = Math_SinS(this->unk_194 * 0x800) * 13.0f + this->actor.home.pos.y; -} - -f32 EnPoField_SetFleeSpeed(EnPoField* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 speed = ((player->stateFlags1 & 0x800000) && player->rideActor != NULL) ? player->rideActor->speedXZ : 12.0f; - - if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.speedXZ = speed * 1.5f + 2.0f; - } else if (this->actor.xzDistToPlayer < 400.0f) { - this->actor.speedXZ = speed * 1.25f + 2.0f; - } else if (this->actor.xzDistToPlayer < 500.0f) { - this->actor.speedXZ = speed + 2.0f; - } else { - this->actor.speedXZ = 12.0f; - } - this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 12.0f); - return this->actor.speedXZ; -} - -void EnPoField_WaitForSpawn(EnPoField* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 spawnDist; - s32 i; - s32 bgId; - - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (this->actionTimer == 0) { - for (i = 0; i < sNumSpawned; i++) { - if (fabsf(sSpawnPositions[i].x - player->actor.world.pos.x) < 150.0f && - fabsf(sSpawnPositions[i].z - player->actor.world.pos.z) < 150.0f) { - if (Flags_GetSwitch(globalCtx, sSpawnSwitchFlags[i])) { - if (player->stateFlags1 & 0x800000) { // Player riding Epona - return; - } else { - this->actor.params = EN_PO_FIELD_SMALL; - spawnDist = 300.0f; - } - } else if (player->stateFlags1 & 0x800000 || Rand_ZeroOne() < 0.4f) { - this->actor.params = EN_PO_FIELD_BIG; - this->spawnFlagIndex = i; - spawnDist = 480.0f; - } else { - this->actor.params = EN_PO_FIELD_SMALL; - spawnDist = 300.0f; - } - this->actor.world.pos.x = Math_SinS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.x; - this->actor.world.pos.z = Math_CosS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.z; - this->actor.world.pos.y = player->actor.world.pos.y + 1000.0f; - this->actor.world.pos.y = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); - if (this->actor.world.pos.y != BGCHECK_Y_MIN) { - this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &player->actor); - EnPoField_SetupAppear(this); - } else { - return; - } - } - } - } -} - -void EnPoField_Appear(EnPoField* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->lightColor.a = 255; - Actor_SetScale(&this->actor, this->scaleModifier); - if (this->actor.params == EN_PO_FIELD_BIG) { - EnPoField_SetupFlee(this); - } else { - EnPoField_SetupCirclePlayer(this, globalCtx); - } - } else if (this->skelAnime.curFrame > 10.0f) { - this->lightColor.a = ((this->skelAnime.curFrame - 10.0f) * 0.05f) * 255.0f; - } else { - this->actor.scale.x += this->scaleModifier * 0.1f; - this->actor.scale.y = this->actor.scale.x; - this->actor.scale.z = this->actor.scale.x; - } - this->actor.shape.shadowAlpha = this->lightColor.a; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - if (this->actor.params == EN_PO_FIELD_BIG) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; - EnPoField_SetFleeSpeed(this, globalCtx); - } -} - -void EnPoField_CirclePlayer(EnPoField* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 temp_v1 = 16 - this->unk_194; - - SkelAnime_Update(&this->skelAnime); - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (ABS(temp_v1) < 16) { - this->actor.world.rot.y += 512.0f * fabsf(Math_SinS(this->unk_194 * 0x800)); - } - Math_ApproachF(&this->scaleModifier, 180.0f, 0.5f, 10.0f); - Math_ApproachF(&this->actor.home.pos.x, player->actor.world.pos.x, 0.2f, 6.0f); - Math_ApproachF(&this->actor.home.pos.z, player->actor.world.pos.z, 0.2f, 6.0f); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x800, 0x200); - if (this->actor.home.pos.x - player->actor.world.pos.x > 100.0f) { - this->actor.home.pos.x = player->actor.world.pos.x + 100.0f; - } else if (this->actor.home.pos.x - player->actor.world.pos.x < -100.0f) { - this->actor.home.pos.x = player->actor.world.pos.x + -100.0f; - } - if (this->actor.home.pos.z - player->actor.world.pos.z > 100.0f) { - this->actor.home.pos.z = player->actor.world.pos.z + 100.0f; - } else if (this->actor.home.pos.z - player->actor.world.pos.z < -100.0f) { - this->actor.home.pos.z = player->actor.world.pos.z + -100.0f; - } - this->actor.world.pos.x = this->actor.home.pos.x - (Math_SinS(this->actor.world.rot.y) * this->scaleModifier); - this->actor.world.pos.z = this->actor.home.pos.z - (Math_CosS(this->actor.world.rot.y) * this->scaleModifier); - if (this->actionTimer == 0) { - EnPoField_SetupDisappear(this); - } else { - EnPoField_SpawnFlame(this); - } - EnPoField_CorrectYPos(this, globalCtx); - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); -} - -void EnPoField_Flee(EnPoField* this, GlobalContext* globalCtx) { - f32 temp_f6; - s16 phi_t0; - - SkelAnime_Update(&this->skelAnime); - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (Actor_WorldDistXZToPoint(&this->actor, &sFieldMiddle) > 3000.0f) { - phi_t0 = (s16)(this->actor.yawTowardsPlayer - Actor_WorldYawTowardPoint(&this->actor, &sFieldMiddle) - 0x8000) * - 0.2f; - } else { - phi_t0 = 0; - } - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - phi_t0, 6, 0x400); - EnPoField_SetFleeSpeed(this, globalCtx); - this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; - temp_f6 = Math_SinS(this->actionTimer * 0x800) * 3.0f; - this->actor.world.pos.x -= temp_f6 * Math_CosS(this->actor.shape.rot.y); - this->actor.world.pos.z += temp_f6 * Math_SinS(this->actor.shape.rot.y); - if (this->actionTimer == 0 || this->actor.xzDistToPlayer > 1500.0f) { - EnPoField_SetupDisappear(this); - } else { - EnPoField_CorrectYPos(this, globalCtx); - } - func_8002F974(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); -} - -void EnPoField_Damage(EnPoField* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.colChkInfo.health == 0) { - EnPoField_SetupDeath(this); - } else if (this->actor.params == EN_PO_FIELD_BIG) { - EnPoField_SetupFlee(this); - } else { - EnPoField_SetupCirclePlayer(this, globalCtx); - } - } -} - -void EnPoField_Death(EnPoField* this, GlobalContext* globalCtx) { - Vec3f sp6C; - f32 sp68; - s32 pad; - s32 pad1; - f32 temp_f0; - - this->actionTimer++; - if (this->actionTimer < 8) { - if (this->actionTimer < 5) { - sp6C.y = Math_SinS(this->actionTimer * 0x1000 - 0x4000) * 23.0f + (this->actor.world.pos.y + 40.0f); - sp68 = Math_CosS(this->actionTimer * 0x1000 - 0x4000) * 23.0f; - sp6C.x = - Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * sp68 + this->actor.world.pos.x; - sp6C.z = - Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * sp68 + this->actor.world.pos.z; - } else { - sp6C.y = this->actor.world.pos.y + 40.0f + 15.0f * (this->actionTimer - 5); - sp6C.x = - Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + this->actor.world.pos.x; - sp6C.z = - Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + this->actor.world.pos.z; - } - EffectSsDeadDb_Spawn(globalCtx, &sp6C, &D_80AD7114, &D_80AD7120, this->actionTimer * 10 + 80, 0, 255, 255, 255, - 255, 0, 0, 255, 1, 9, 1); - sp6C.x = (this->actor.world.pos.x + this->actor.world.pos.x) - sp6C.x; - sp6C.z = (this->actor.world.pos.z + this->actor.world.pos.z) - sp6C.z; - EffectSsDeadDb_Spawn(globalCtx, &sp6C, &D_80AD7114, &D_80AD7120, this->actionTimer * 10 + 80, 0, 255, 255, 255, - 255, 0, 0, 255, 1, 9, 1); - sp6C.x = this->actor.world.pos.x; - sp6C.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &sp6C, &D_80AD7114, &D_80AD7120, this->actionTimer * 10 + 80, 0, 255, 255, 255, - 255, 0, 0, 255, 1, 9, 1); - if (this->actionTimer == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EXTINCT); - } - } else if (this->actionTimer == 28) { - EnPoField_SetupSoulIdle(this, globalCtx); - } else if (this->actionTimer >= 19) { - temp_f0 = (28 - this->actionTimer) * 0.001f; - this->actor.world.pos.y += 5.0f; - this->actor.scale.z = temp_f0; - this->actor.scale.y = temp_f0; - this->actor.scale.x = temp_f0; - } - if (this->actionTimer == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD2); - } -} - -void EnPoField_Disappear(EnPoField* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->actionTimer != 0) { - this->actionTimer--; - } - this->actor.shape.rot.y += 0x1000; - this->lightColor.a = this->actionTimer * 15.9375f; - this->actor.shape.shadowAlpha = this->lightColor.a; - if (this->actionTimer == 0) { - EnPoField_SetupWaitForSpawn(this, globalCtx); - } -} - -void EnPoField_SoulIdle(EnPoField* this, GlobalContext* globalCtx) { - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (this->actor.bgCheckFlags & 1) { - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_PO_FIELD, 10, - gPoeFieldLanternDL); - func_80AD42B0(this); - } else if (this->actionTimer == 0) { - EnPoField_SetupWaitForSpawn(this, globalCtx); - } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); -} - -void EnPoField_SoulUpdateProperties(EnPoField* this, s32 arg1) { - EnPoFieldInfo* info = &sPoFieldInfo[this->actor.params]; - f32 multiplier; - - this->lightColor.a = CLAMP(this->lightColor.a + arg1, 0, 255); - if (arg1 < 0) { - multiplier = this->lightColor.a * (1.0f / 255); - this->actor.scale.x = this->actor.scale.z = 0.0056000003f * multiplier + 0.0014000001f; - this->actor.scale.y = 0.007f - 0.007f * multiplier + 0.007f; - } else { - multiplier = 1.0f; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = this->lightColor.a * (0.007f / 255); - this->actor.world.pos.y = this->actor.home.pos.y + ((1.0f / 17.0f) * this->lightColor.a); - } - this->lightColor.r = info->lightColor.r * multiplier; - this->lightColor.g = info->lightColor.g * multiplier; - this->lightColor.b = info->lightColor.b * multiplier; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, info->lightColor.r, info->lightColor.g, info->lightColor.b, - this->lightColor.a * (200.0f / 255)); -} - -void func_80AD587C(EnPoField* this, GlobalContext* globalCtx) { - this->actor.home.pos.y += 2.0f; - EnPoField_SoulUpdateProperties(this, 20); - if (this->lightColor.a == 255) { - func_80AD4384(this); - } -} - -void func_80AD58D4(EnPoField* this, GlobalContext* globalCtx) { - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - EnPoField_SetupInteractWithSoul(this); - return; - } - if (this->actionTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - this->actor.flags &= ~ACTOR_FLAG_16; - EnPoField_SetupSoulDisappear(this); - return; - } - if (this->collider.base.ocFlags1 & OC1_HIT) { - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2F4(&this->actor, globalCtx); - } else { - this->actor.flags &= ~ACTOR_FLAG_16; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - this->actor.world.pos.y = Math_SinS(this->unk_194 * 0x800) * 5.0f + this->actor.home.pos.y; - if (this->unk_194 != 0) { - this->unk_194 -= 1; - } - if (this->unk_194 == 0) { - this->unk_194 = 32; - } - this->collider.dim.pos.y = this->actor.world.pos.y - 20.0f; - Actor_SetFocus(&this->actor, -10.0f); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->lightInfo.params.point.color[0], - this->lightInfo.params.point.color[1], this->lightInfo.params.point.color[2], - this->lightColor.a * (200.0f / 255)); -} - -void EnPoField_SoulDisappear(EnPoField* this, GlobalContext* globalCtx) { - EnPoField_SoulUpdateProperties(this, -13); - if (this->lightColor.a == 0) { - EnPoField_SetupWaitForSpawn(this, globalCtx); - } -} - -void EnPoField_SoulInteract(EnPoField* this, GlobalContext* globalCtx) { - if (this->actor.textId != 0x5005) { - EnPoField_SoulUpdateProperties(this, -13); - } else { - func_8002F974(&this->actor, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - } - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { - if (Message_ShouldAdvance(globalCtx)) { - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - if (globalCtx->msgCtx.choiceIndex == 0) { - if (Inventory_HasEmptyBottle()) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_BIG_GET); - if (this->actor.params == 0) { - Item_Give(globalCtx, ITEM_POE); - this->actor.textId = 0x5008; - } else { - this->actor.textId = 0x508F; - Item_Give(globalCtx, ITEM_BIG_POE); - Flags_SetSwitch(globalCtx, sSpawnSwitchFlags[this->spawnFlagIndex]); - } - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - this->actor.textId = 0x5006; - } - } else { - this->actor.textId = 0x5007; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - return; - } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - EnPoField_SetupSoulDisappear(this); - } -} - -void EnPoField_TestForDamage(EnPoField* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != 0 || this->actor.colChkInfo.damage != 0) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); - } - EnPoField_SetupDamage(this); - } - } -} - -void EnPoField_SpawnFlame(EnPoField* this) { - if (this->flameTimer == 0) { - this->flamePosition.x = this->lightInfo.params.point.x; - this->flamePosition.y = this->lightInfo.params.point.y; - this->flamePosition.z = this->lightInfo.params.point.z; - this->flameTimer = 70; - this->flameRotation = this->actor.shape.rot.y; - } -} - -void EnPoField_UpdateFlame(EnPoField* this, GlobalContext* globalCtx) { - if (this->flameTimer != 0) { - if (this->flameTimer != 0) { - this->flameTimer--; - } - if (this->flameCollider.base.atFlags & AT_HIT) { - this->flameCollider.base.atFlags &= ~AT_HIT; - this->flameTimer = 19; - } - if (this->flameTimer < 20) { - Math_StepToF(&this->flameScale, 0.0f, 0.00015f); - return; - } - if (Math_StepToF(&this->flameScale, 0.003f, 0.0006f) != 0) { - this->flamePosition.x += 2.5f * Math_SinS(this->flameRotation); - this->flamePosition.z += 2.5f * Math_CosS(this->flameRotation); - } - this->flameCollider.dim.pos.x = this->flamePosition.x; - this->flameCollider.dim.pos.y = this->flamePosition.y; - this->flameCollider.dim.pos.z = this->flamePosition.z; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->flameCollider.base); - } -} - -void EnPoField_DrawFlame(EnPoField* this, GlobalContext* globalCtx) { - f32 sp4C; - s32 pad; - - if (this->flameTimer != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1669); - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - (globalCtx->gameplayFrames * -20) % 512, 32, 128)); - sp4C = this->flameScale * 85000.0f; - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, sp4C); - Matrix_Translate(this->flamePosition.x, this->flamePosition.y, this->flamePosition.z, MTXMODE_NEW); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); - if (this->flameTimer >= 20) { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_Scale(this->flameScale, this->flameScale, this->flameScale, MTXMODE_APPLY); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, sp4C, 0, 0, 0); - Matrix_Scale((this->flameScale * 0.7f) + 0.00090000004f, (0.003f - this->flameScale) + 0.003f, 0.003f, - MTXMODE_APPLY); - } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1709), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1712); - } -} - -void func_80AD619C(EnPoField* this) { - s16 temp_var; - - if (this->actionFunc == EnPoField_Flee) { - this->lightColor.r = CLAMP_MAX((s16)(this->lightColor.r + 5), 80); - this->lightColor.g = CLAMP_MAX((s16)(this->lightColor.g + 5), 255); - temp_var = this->lightColor.b + 5; - this->lightColor.b = CLAMP_MAX(temp_var, 225); - } else if (this->actionFunc == EnPoField_Damage) { - if (this->actor.colorFilterTimer & 2) { - this->lightColor.r = 0; - this->lightColor.g = 0; - this->lightColor.b = 0; - } else { - this->lightColor.r = 80; - this->lightColor.g = 255; - this->lightColor.b = 225; - } - } else { - this->lightColor.r = CLAMP_MAX((s16)(this->lightColor.r + 5), 255); - this->lightColor.g = CLAMP_MAX((s16)(this->lightColor.g + 5), 255); - if (this->lightColor.b > 210) { - temp_var = this->lightColor.b - 5; - this->lightColor.b = CLAMP_MIN(temp_var, 210); - } else { - temp_var = this->lightColor.b + 5; - this->lightColor.b = CLAMP_MAX(temp_var, 210); - } - } -} - -void func_80AD6330(EnPoField* this) { - f32 rand; - - if (this->actionFunc == EnPoField_Appear && this->skelAnime.curFrame < 12.0f) { - this->soulColor.r = this->soulColor.g = this->soulColor.b = (s16)(this->skelAnime.curFrame * 16.66f) + 55; - this->soulColor.a = this->skelAnime.curFrame * (100.0f / 6.0f); - } else { - rand = Rand_ZeroOne(); - this->soulColor.r = (s16)(rand * 30.0f) + 225; - this->soulColor.g = (s16)(rand * 100.0f) + 155; - this->soulColor.b = (s16)(rand * 160.0f) + 95; - this->soulColor.a = 200; - } -} - -void EnPoField_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnPoField* this = (EnPoField*)thisx; - - EnPoField_TestForDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - EnPoField_UpdateFlame(this, globalCtx); - if (this->actionFunc == EnPoField_Flee || this->actionFunc == EnPoField_Damage || - this->actionFunc == EnPoField_Appear) { - Actor_MoveForward(&this->actor); - } - if (this->actionFunc != EnPoField_WaitForSpawn) { - Actor_SetFocus(&this->actor, 42.0f); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 27.0f, 60.0f, 4); - func_80AD619C(this); - func_80AD6330(this); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -s32 EnPoField_OverrideLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx, Gfx** gfxP) { - EnPoField* this = (EnPoField*)thisx; - - if (this->lightColor.a == 0 || limbIndex == 7 || (this->actionFunc == EnPoField_Death && this->actionTimer >= 2)) { - *dList = NULL; - } else if (this->actor.params == EN_PO_FIELD_BIG) { - if (limbIndex == 1) { - *dList = gBigPoeFaceDL; - } else if (limbIndex == 8) { - *dList = gBigPoeCloakDL; - } else if (limbIndex == 9) { - *dList = gBigPoeBodyDL; - } - } - if (this->actionFunc == EnPoField_Disappear && limbIndex == 7) { - Matrix_Scale(this->actionTimer / 16.0f, this->actionTimer / 16.0f, this->actionTimer / 16.0f, MTXMODE_APPLY); - } - return false; -} - -void EnPoField_PostLimDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfxP) { - EnPoField* this = (EnPoField*)thisx; - - if (this->actionFunc == EnPoField_Death && this->actionTimer >= 2 && limbIndex == 8) { - gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1916), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfxP)++, gPoeFieldBurnDL); - } - if (limbIndex == 7) { - Vec3f vec; - Matrix_MultVec3f(&D_80AD714C, &vec); - if (this->actionFunc == EnPoField_Death && this->actionTimer >= 19 && this->actor.scale.x != 0.0f) { - f32 mtxScale = 0.01f / this->actor.scale.x; - Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - } - Matrix_Get(&sLimb7Mtx); - if (this->actionFunc == EnPoField_Death && this->actionTimer == 27) { - this->actor.world.pos.x = sLimb7Mtx.xw; - this->actor.world.pos.y = sLimb7Mtx.yw; - this->actor.world.pos.z = sLimb7Mtx.zw; - } - Lights_PointGlowSetInfo(&this->lightInfo, vec.x, vec.y, vec.z, this->soulColor.r, this->soulColor.g, - this->soulColor.b, this->soulColor.a * (200.0f / 255)); - } -} - -void EnPoField_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnPoField* this = (EnPoField*)thisx; - EnPoFieldInfo* info = &sPoFieldInfo[this->actor.params]; - - if (this->actionFunc != EnPoField_WaitForSpawn) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1976); - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_EnvColor(globalCtx->state.gfxCtx, info->envColor.r, info->envColor.g, info->envColor.b, 255)); - if (this->lightColor.a == 255 || this->lightColor.a == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, - this->lightColor.a)); - gSPSegment(POLY_OPA_DISP++, 0x0C, D_80116280 + 2); - POLY_OPA_DISP = - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoField_OverrideLimbDraw2, EnPoField_PostLimDraw2, &this->actor, POLY_OPA_DISP); - } else { - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, - this->lightColor.a)); - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - POLY_XLU_DISP = - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoField_OverrideLimbDraw2, EnPoField_PostLimDraw2, &this->actor, POLY_XLU_DISP); - } - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, this->soulColor.r, this->soulColor.g, this->soulColor.b, 255); - Matrix_Put(&sLimb7Mtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2033), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternDL); - gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternTopDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2039); - } - EnPoField_DrawFlame(this, globalCtx); -} - -void EnPoField_UpdateDead(Actor* thisx, GlobalContext* globalCtx) { - EnPoField* this = (EnPoField*)thisx; - - this->actionFunc(this, globalCtx); - if (this->actionFunc == EnPoField_SoulIdle) { - func_80AD6330(this); - } - EnPoField_UpdateFlame(this, globalCtx); -} - -void EnPoField_DrawSoul(Actor* thisx, GlobalContext* globalCtx) { - EnPoField* this = (EnPoField*)thisx; - s32 pad; - EnPoFieldInfo* info = &sPoFieldInfo[this->actor.params]; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2077); - if (this->actionFunc == EnPoField_SoulIdle) { - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_EnvColor(globalCtx->state.gfxCtx, info->envColor.r, info->envColor.g, info->envColor.b, 255)); - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->soulColor.r, this->soulColor.g, this->soulColor.b, 200); - gDPSetEnvColor(POLY_OPA_DISP++, this->soulColor.r, this->soulColor.g, this->soulColor.b, 255); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2104), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternDL); - gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternTopDL); - } else { - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (globalCtx->gameplayFrames * info->unk_9) & 0x1FF, 0x20, 0x80)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(info->soulTexture)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, info->primColor.r, info->primColor.g, info->primColor.b, - this->lightColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, this->lightColor.r, this->lightColor.g, this->lightColor.b, 255); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * 9.58738e-05f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2143), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gPoeFieldSoulDL); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2149); - EnPoField_DrawFlame(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.cpp b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.cpp new file mode 100644 index 000000000..49aa33ff3 --- /dev/null +++ b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.cpp @@ -0,0 +1,1022 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_FIELD_Z_EN_PO_FIELD_C +#include "actor_common.h" +/* + * File: z_en_po_field.c + * Overlay: ovl_En_Po_Field + * Description: Field Poe + */ + +#include "z_en_po_field.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_po_field/object_po_field.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_12) + +void EnPoField_Init(Actor* thisx, GlobalContext* globalCtx); +void EnPoField_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnPoField_Update(Actor* thisx, GlobalContext* globalCtx); +void EnPoField_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnPoField_UpdateDead(Actor* thisx, GlobalContext* globalCtx); +void EnPoField_DrawSoul(Actor* thisx, GlobalContext* globalCtx); + +void EnPoField_SetupWaitForSpawn(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_WaitForSpawn(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_Appear(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_CirclePlayer(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_Damage(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_Flee(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_Death(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_Disappear(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_SoulIdle(EnPoField* pthis, GlobalContext* globalCtx); +void func_80AD587C(EnPoField* pthis, GlobalContext* globalCtx); +void func_80AD58D4(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_SoulDisappear(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_SoulInteract(EnPoField* pthis, GlobalContext* globalCtx); +void EnPoField_SpawnFlame(EnPoField* pthis); + +ActorInit En_Po_Field_InitVars = { + ACTOR_EN_PO_FIELD, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_PO_FIELD, + sizeof(EnPoField), + (ActorFunc)EnPoField_Init, + (ActorFunc)EnPoField_Destroy, + (ActorFunc)EnPoField_Update, + (ActorFunc)EnPoField_Draw, +}; + +static ColliderCylinderInit D_80AD7080 = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 25, 50, 20, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit D_80AD70AC = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { 10, 30, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit D_80AD70D8 = { 4, 25, 50, 40 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(1, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static s32 sNumSpawned = 0; + +static Vec3f sFieldMiddle = { -1000.0f, 0.0f, 6500.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), +}; + +static Vec3f D_80AD7114 = { 0.0f, 3.0f, 0.0f }; + +static Vec3f D_80AD7120 = { 0.0f, 0.0f, 0.0f }; + +static EnPoFieldInfo sPoFieldInfo[2] = { + { { 255, 170, 255 }, { 100, 0, 150 }, { 255, 85, 0 }, 248, gPoeFieldSoulTex }, + { { 255, 255, 170 }, { 255, 200, 0 }, { 160, 0, 255 }, 241, gBigPoeSoulTex }, +}; + +static Vec3f D_80AD714C = { 0.0f, 1400.0f, 0.0f }; + +static Vec3s sSpawnPositions[10]; +static u8 sSpawnSwitchFlags[10]; +static MtxF sLimb7Mtx; + +void EnPoField_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPoField* pthis = (EnPoField*)thisx; + s32 pad; + + if (sNumSpawned != 10) { + sSpawnPositions[sNumSpawned].x = pthis->actor.world.pos.x; + sSpawnPositions[sNumSpawned].y = pthis->actor.world.pos.y; + sSpawnPositions[sNumSpawned].z = pthis->actor.world.pos.z; + sSpawnSwitchFlags[sNumSpawned] = pthis->actor.params & 0xFF; + sNumSpawned++; + } + if (sNumSpawned >= 2) { + pthis->actor.params = 0xFF; + Actor_Kill(&pthis->actor); + return; + } + Actor_ProcessInitChain(&pthis->actor, sInitChain); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gPoeFieldSkel, &gPoeFieldFloatAnim, pthis->jointTable, pthis->morphTable, + 10); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &D_80AD7080); + Collider_InitCylinder(globalCtx, &pthis->flameCollider); + Collider_SetCylinder(globalCtx, &pthis->flameCollider, &pthis->actor, &D_80AD70AC); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &D_80AD70D8); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, + 255, 255, 255, 0); + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + EnPoField_SetupWaitForSpawn(pthis, globalCtx); +} + +void EnPoField_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoField* pthis = (EnPoField*)thisx; + + if (pthis->actor.params != 0xFF) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + Collider_DestroyCylinder(globalCtx, &pthis->flameCollider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void EnPoField_SetupWaitForSpawn(EnPoField* pthis, GlobalContext* globalCtx) { + pthis->actor.update = EnPoField_Update; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + pthis->actor.shape.rot.x = 0; + Lights_PointSetColorAndRadius(&pthis->lightInfo, 0, 0, 0, 0); + pthis->actionTimer = 200; + Actor_SetScale(&pthis->actor, 0.0f); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_16); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_ALL; + pthis->actor.colChkInfo.health = D_80AD70D8.health; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actionFunc = EnPoField_WaitForSpawn; +} + +void EnPoField_SetupAppear(EnPoField* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gPoeFieldAppearAnim); + pthis->actor.draw = EnPoField_Draw; + pthis->lightColor.r = 255; + pthis->lightColor.g = 255; + pthis->lightColor.b = 210; + pthis->lightColor.a = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->actor.shape.yOffset = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + if (pthis->actor.params == EN_PO_FIELD_BIG) { + pthis->actor.speedXZ = 12.0f; + pthis->collider.dim.radius = 35; + pthis->collider.dim.height = 100; + pthis->collider.dim.yShift = 10; + pthis->actor.shape.shadowScale = 45.0f; + pthis->scaleModifier = 0.014f; + pthis->actor.naviEnemyId = 0x5A; + } else { + pthis->actor.speedXZ = 0.0f; + pthis->collider.dim.radius = D_80AD7080.dim.radius; + pthis->collider.dim.height = D_80AD7080.dim.height; + pthis->collider.dim.yShift = D_80AD7080.dim.yShift; + pthis->actor.shape.shadowScale = 37.0f; + pthis->scaleModifier = 0.01f; + pthis->actor.naviEnemyId = 0x5C; + } + pthis->actionFunc = EnPoField_Appear; +} + +void EnPoField_SetupCirclePlayer(EnPoField* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Animation_PlayLoop(&pthis->skelAnime, &gPoeFieldFloatAnim); + pthis->collider.base.acFlags |= AC_ON; + pthis->scaleModifier = pthis->actor.xzDistToPlayer; + Math_Vec3f_Copy(&pthis->actor.home.pos, &player->actor.world.pos); + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (pthis->actionFunc != EnPoField_Damage) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionTimer = 600; + pthis->unk_194 = 32; + } + pthis->actionFunc = EnPoField_CirclePlayer; +} + +void EnPoField_SetupFlee(EnPoField* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeFieldFleeAnim, -5.0f); + pthis->collider.base.acFlags |= AC_ON; + pthis->actionFunc = EnPoField_Flee; + pthis->actor.speedXZ = 12.0f; + if (pthis->actionFunc != EnPoField_Damage) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x8000; + pthis->actionTimer = 2000; + pthis->unk_194 = 32; + } +} + +void EnPoField_SetupDamage(EnPoField* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPoeFieldDamagedAnim, -6.0f); + if (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) { + pthis->actor.world.rot.y = pthis->collider.base.ac->world.rot.y; + } else { + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; + } + pthis->collider.base.acFlags &= ~(AC_HIT | AC_ON); + pthis->actor.speedXZ = 5.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 16); + pthis->actionFunc = EnPoField_Damage; +} + +void EnPoField_SetupDeath(EnPoField* pthis) { + pthis->actionTimer = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.naviEnemyId = 0xFF; + if (pthis->flameTimer >= 20) { + pthis->flameTimer = 19; + } + pthis->actionFunc = EnPoField_Death; +} + +void EnPoField_SetupDisappear(EnPoField* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeFieldDisappearAnim, -6.0f); + pthis->actionTimer = 16; + pthis->collider.base.acFlags &= ~(AC_HIT | AC_ON); + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DISAPPEAR); + pthis->actionFunc = EnPoField_Disappear; +} + +void EnPoField_SetupSoulIdle(EnPoField* pthis, GlobalContext* globalCtx) { + pthis->actor.update = EnPoField_UpdateDead; + pthis->actor.draw = EnPoField_DrawSoul; + pthis->actor.shape.shadowDraw = NULL; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.gravity = -1.0f; + pthis->actor.shape.yOffset = 1500.0f; + pthis->actor.shape.rot.x = -0x8000; + pthis->actionTimer = 60; + pthis->actor.world.pos.y -= 15.0f; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_MISC); + pthis->actionFunc = EnPoField_SoulIdle; +} + +void func_80AD42B0(EnPoField* pthis) { + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0); + pthis->actor.shape.rot.y = 0; + pthis->lightColor.a = 0; + pthis->actor.shape.rot.x = 0; + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + pthis->actor.scale.x = 0.0f; + pthis->actor.scale.y = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_METAL_BOX_BOUND); + if (pthis->actor.params == EN_PO_FIELD_BIG) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + pthis->actionFunc = func_80AD587C; +} + +void func_80AD4384(EnPoField* pthis) { + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + Actor_SetFocus(&pthis->actor, -10.0f); + pthis->collider.dim.radius = 13; + pthis->collider.dim.height = 30; + pthis->collider.dim.yShift = 0; + pthis->collider.dim.pos.x = pthis->actor.world.pos.x; + pthis->collider.dim.pos.y = pthis->actor.world.pos.y - 20.0f; + pthis->collider.dim.pos.z = pthis->actor.world.pos.z; + pthis->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_PLAYER; + pthis->actor.textId = 0x5005; + pthis->actionTimer = 400; + pthis->unk_194 = 32; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = func_80AD58D4; +} + +void EnPoField_SetupSoulDisappear(EnPoField* pthis) { + pthis->actionFunc = EnPoField_SoulDisappear; +} + +void EnPoField_SetupInteractWithSoul(EnPoField* pthis) { + pthis->actionFunc = EnPoField_SoulInteract; + pthis->actor.home.pos.y = pthis->actor.world.pos.y - 15.0f; +} + +void EnPoField_CorrectYPos(EnPoField* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->unk_194 == 0) { + pthis->unk_194 = 32; + } + if (pthis->unk_194 != 0) { + pthis->unk_194 -= 1; + } + if (pthis->actor.floorHeight == BGCHECK_Y_MIN) { + EnPoField_SetupDisappear(pthis); + return; + } + Math_ApproachF( + &pthis->actor.home.pos.y, + ((player->actor.world.pos.y > pthis->actor.floorHeight) ? player->actor.world.pos.y : pthis->actor.floorHeight) + + 13.0f, + 0.2f, 5.0f); + pthis->actor.world.pos.y = Math_SinS(pthis->unk_194 * 0x800) * 13.0f + pthis->actor.home.pos.y; +} + +f32 EnPoField_SetFleeSpeed(EnPoField* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 speed = ((player->stateFlags1 & 0x800000) && player->rideActor != NULL) ? player->rideActor->speedXZ : 12.0f; + + if (pthis->actor.xzDistToPlayer < 300.0f) { + pthis->actor.speedXZ = speed * 1.5f + 2.0f; + } else if (pthis->actor.xzDistToPlayer < 400.0f) { + pthis->actor.speedXZ = speed * 1.25f + 2.0f; + } else if (pthis->actor.xzDistToPlayer < 500.0f) { + pthis->actor.speedXZ = speed + 2.0f; + } else { + pthis->actor.speedXZ = 12.0f; + } + pthis->actor.speedXZ = CLAMP_MIN(pthis->actor.speedXZ, 12.0f); + return pthis->actor.speedXZ; +} + +void EnPoField_WaitForSpawn(EnPoField* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 spawnDist; + s32 i; + s32 bgId; + + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (pthis->actionTimer == 0) { + for (i = 0; i < sNumSpawned; i++) { + if (fabsf(sSpawnPositions[i].x - player->actor.world.pos.x) < 150.0f && + fabsf(sSpawnPositions[i].z - player->actor.world.pos.z) < 150.0f) { + if (Flags_GetSwitch(globalCtx, sSpawnSwitchFlags[i])) { + if (player->stateFlags1 & 0x800000) { // Player riding Epona + return; + } else { + pthis->actor.params = EN_PO_FIELD_SMALL; + spawnDist = 300.0f; + } + } else if (player->stateFlags1 & 0x800000 || Rand_ZeroOne() < 0.4f) { + pthis->actor.params = EN_PO_FIELD_BIG; + pthis->spawnFlagIndex = i; + spawnDist = 480.0f; + } else { + pthis->actor.params = EN_PO_FIELD_SMALL; + spawnDist = 300.0f; + } + pthis->actor.world.pos.x = Math_SinS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.x; + pthis->actor.world.pos.z = Math_CosS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.z; + pthis->actor.world.pos.y = player->actor.world.pos.y + 1000.0f; + pthis->actor.world.pos.y = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, + &pthis->actor, &pthis->actor.world.pos); + if (pthis->actor.world.pos.y != BGCHECK_Y_MIN) { + pthis->actor.shape.rot.y = Actor_WorldYawTowardActor(&pthis->actor, &player->actor); + EnPoField_SetupAppear(pthis); + } else { + return; + } + } + } + } +} + +void EnPoField_Appear(EnPoField* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->lightColor.a = 255; + Actor_SetScale(&pthis->actor, pthis->scaleModifier); + if (pthis->actor.params == EN_PO_FIELD_BIG) { + EnPoField_SetupFlee(pthis); + } else { + EnPoField_SetupCirclePlayer(pthis, globalCtx); + } + } else if (pthis->skelAnime.curFrame > 10.0f) { + pthis->lightColor.a = ((pthis->skelAnime.curFrame - 10.0f) * 0.05f) * 255.0f; + } else { + pthis->actor.scale.x += pthis->scaleModifier * 0.1f; + pthis->actor.scale.y = pthis->actor.scale.x; + pthis->actor.scale.z = pthis->actor.scale.x; + } + pthis->actor.shape.shadowAlpha = pthis->lightColor.a; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + if (pthis->actor.params == EN_PO_FIELD_BIG) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + EnPoField_SetFleeSpeed(pthis, globalCtx); + } +} + +void EnPoField_CirclePlayer(EnPoField* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 temp_v1 = 16 - pthis->unk_194; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (ABS(temp_v1) < 16) { + pthis->actor.world.rot.y += 512.0f * fabsf(Math_SinS(pthis->unk_194 * 0x800)); + } + Math_ApproachF(&pthis->scaleModifier, 180.0f, 0.5f, 10.0f); + Math_ApproachF(&pthis->actor.home.pos.x, player->actor.world.pos.x, 0.2f, 6.0f); + Math_ApproachF(&pthis->actor.home.pos.z, player->actor.world.pos.z, 0.2f, 6.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 1, 0x800, 0x200); + if (pthis->actor.home.pos.x - player->actor.world.pos.x > 100.0f) { + pthis->actor.home.pos.x = player->actor.world.pos.x + 100.0f; + } else if (pthis->actor.home.pos.x - player->actor.world.pos.x < -100.0f) { + pthis->actor.home.pos.x = player->actor.world.pos.x + -100.0f; + } + if (pthis->actor.home.pos.z - player->actor.world.pos.z > 100.0f) { + pthis->actor.home.pos.z = player->actor.world.pos.z + 100.0f; + } else if (pthis->actor.home.pos.z - player->actor.world.pos.z < -100.0f) { + pthis->actor.home.pos.z = player->actor.world.pos.z + -100.0f; + } + pthis->actor.world.pos.x = pthis->actor.home.pos.x - (Math_SinS(pthis->actor.world.rot.y) * pthis->scaleModifier); + pthis->actor.world.pos.z = pthis->actor.home.pos.z - (Math_CosS(pthis->actor.world.rot.y) * pthis->scaleModifier); + if (pthis->actionTimer == 0) { + EnPoField_SetupDisappear(pthis); + } else { + EnPoField_SpawnFlame(pthis); + } + EnPoField_CorrectYPos(pthis, globalCtx); + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); +} + +void EnPoField_Flee(EnPoField* pthis, GlobalContext* globalCtx) { + f32 temp_f6; + s16 phi_t0; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (Actor_WorldDistXZToPoint(&pthis->actor, &sFieldMiddle) > 3000.0f) { + phi_t0 = (s16)(pthis->actor.yawTowardsPlayer - Actor_WorldYawTowardPoint(&pthis->actor, &sFieldMiddle) - 0x8000) * + 0.2f; + } else { + phi_t0 = 0; + } + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer - phi_t0, 6, 0x400); + EnPoField_SetFleeSpeed(pthis, globalCtx); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x8000; + temp_f6 = Math_SinS(pthis->actionTimer * 0x800) * 3.0f; + pthis->actor.world.pos.x -= temp_f6 * Math_CosS(pthis->actor.shape.rot.y); + pthis->actor.world.pos.z += temp_f6 * Math_SinS(pthis->actor.shape.rot.y); + if (pthis->actionTimer == 0 || pthis->actor.xzDistToPlayer > 1500.0f) { + EnPoField_SetupDisappear(pthis); + } else { + EnPoField_CorrectYPos(pthis, globalCtx); + } + func_8002F974(&pthis->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); +} + +void EnPoField_Damage(EnPoField* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.colChkInfo.health == 0) { + EnPoField_SetupDeath(pthis); + } else if (pthis->actor.params == EN_PO_FIELD_BIG) { + EnPoField_SetupFlee(pthis); + } else { + EnPoField_SetupCirclePlayer(pthis, globalCtx); + } + } +} + +void EnPoField_Death(EnPoField* pthis, GlobalContext* globalCtx) { + Vec3f sp6C; + f32 sp68; + s32 pad; + s32 pad1; + f32 temp_f0; + + pthis->actionTimer++; + if (pthis->actionTimer < 8) { + if (pthis->actionTimer < 5) { + sp6C.y = Math_SinS(pthis->actionTimer * 0x1000 - 0x4000) * 23.0f + (pthis->actor.world.pos.y + 40.0f); + sp68 = Math_CosS(pthis->actionTimer * 0x1000 - 0x4000) * 23.0f; + sp6C.x = + Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * sp68 + pthis->actor.world.pos.x; + sp6C.z = + Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * sp68 + pthis->actor.world.pos.z; + } else { + sp6C.y = pthis->actor.world.pos.y + 40.0f + 15.0f * (pthis->actionTimer - 5); + sp6C.x = + Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + pthis->actor.world.pos.x; + sp6C.z = + Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + pthis->actor.world.pos.z; + } + EffectSsDeadDb_Spawn(globalCtx, &sp6C, &D_80AD7114, &D_80AD7120, pthis->actionTimer * 10 + 80, 0, 255, 255, 255, + 255, 0, 0, 255, 1, 9, 1); + sp6C.x = (pthis->actor.world.pos.x + pthis->actor.world.pos.x) - sp6C.x; + sp6C.z = (pthis->actor.world.pos.z + pthis->actor.world.pos.z) - sp6C.z; + EffectSsDeadDb_Spawn(globalCtx, &sp6C, &D_80AD7114, &D_80AD7120, pthis->actionTimer * 10 + 80, 0, 255, 255, 255, + 255, 0, 0, 255, 1, 9, 1); + sp6C.x = pthis->actor.world.pos.x; + sp6C.z = pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &sp6C, &D_80AD7114, &D_80AD7120, pthis->actionTimer * 10 + 80, 0, 255, 255, 255, + 255, 0, 0, 255, 1, 9, 1); + if (pthis->actionTimer == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EXTINCT); + } + } else if (pthis->actionTimer == 28) { + EnPoField_SetupSoulIdle(pthis, globalCtx); + } else if (pthis->actionTimer >= 19) { + temp_f0 = (28 - pthis->actionTimer) * 0.001f; + pthis->actor.world.pos.y += 5.0f; + pthis->actor.scale.z = temp_f0; + pthis->actor.scale.y = temp_f0; + pthis->actor.scale.x = temp_f0; + } + if (pthis->actionTimer == 18) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DEAD2); + } +} + +void EnPoField_Disappear(EnPoField* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + pthis->actor.shape.rot.y += 0x1000; + pthis->lightColor.a = pthis->actionTimer * 15.9375f; + pthis->actor.shape.shadowAlpha = pthis->lightColor.a; + if (pthis->actionTimer == 0) { + EnPoField_SetupWaitForSpawn(pthis, globalCtx); + } +} + +void EnPoField_SoulIdle(EnPoField* pthis, GlobalContext* globalCtx) { + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (pthis->actor.bgCheckFlags & 1) { + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_PO_FIELD, 10, + gPoeFieldLanternDL); + func_80AD42B0(pthis); + } else if (pthis->actionTimer == 0) { + EnPoField_SetupWaitForSpawn(pthis, globalCtx); + } + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 10.0f, 4); +} + +void EnPoField_SoulUpdateProperties(EnPoField* pthis, s32 arg1) { + EnPoFieldInfo* info = &sPoFieldInfo[pthis->actor.params]; + f32 multiplier; + + pthis->lightColor.a = CLAMP(pthis->lightColor.a + arg1, 0, 255); + if (arg1 < 0) { + multiplier = pthis->lightColor.a * (1.0f / 255); + pthis->actor.scale.x = pthis->actor.scale.z = 0.0056000003f * multiplier + 0.0014000001f; + pthis->actor.scale.y = 0.007f - 0.007f * multiplier + 0.007f; + } else { + multiplier = 1.0f; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = pthis->lightColor.a * (0.007f / 255); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + ((1.0f / 17.0f) * pthis->lightColor.a); + } + pthis->lightColor.r = info->lightColor.r * multiplier; + pthis->lightColor.g = info->lightColor.g * multiplier; + pthis->lightColor.b = info->lightColor.b * multiplier; + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, info->lightColor.r, info->lightColor.g, info->lightColor.b, + pthis->lightColor.a * (200.0f / 255)); +} + +void func_80AD587C(EnPoField* pthis, GlobalContext* globalCtx) { + pthis->actor.home.pos.y += 2.0f; + EnPoField_SoulUpdateProperties(pthis, 20); + if (pthis->lightColor.a == 255) { + func_80AD4384(pthis); + } +} + +void func_80AD58D4(EnPoField* pthis, GlobalContext* globalCtx) { + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + EnPoField_SetupInteractWithSoul(pthis); + return; + } + if (pthis->actionTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + pthis->actor.flags &= ~ACTOR_FLAG_16; + EnPoField_SetupSoulDisappear(pthis); + return; + } + if (pthis->collider.base.ocFlags1 & OC1_HIT) { + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2F4(&pthis->actor, globalCtx); + } else { + pthis->actor.flags &= ~ACTOR_FLAG_16; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + pthis->actor.world.pos.y = Math_SinS(pthis->unk_194 * 0x800) * 5.0f + pthis->actor.home.pos.y; + if (pthis->unk_194 != 0) { + pthis->unk_194 -= 1; + } + if (pthis->unk_194 == 0) { + pthis->unk_194 = 32; + } + pthis->collider.dim.pos.y = pthis->actor.world.pos.y - 20.0f; + Actor_SetFocus(&pthis->actor, -10.0f); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->lightInfo.params.point.color[0], + pthis->lightInfo.params.point.color[1], pthis->lightInfo.params.point.color[2], + pthis->lightColor.a * (200.0f / 255)); +} + +void EnPoField_SoulDisappear(EnPoField* pthis, GlobalContext* globalCtx) { + EnPoField_SoulUpdateProperties(pthis, -13); + if (pthis->lightColor.a == 0) { + EnPoField_SetupWaitForSpawn(pthis, globalCtx); + } +} + +void EnPoField_SoulInteract(EnPoField* pthis, GlobalContext* globalCtx) { + if (pthis->actor.textId != 0x5005) { + EnPoField_SoulUpdateProperties(pthis, -13); + } else { + func_8002F974(&pthis->actor, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + } + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(globalCtx)) { + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + if (globalCtx->msgCtx.choiceIndex == 0) { + if (Inventory_HasEmptyBottle()) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_BIG_GET); + if (pthis->actor.params == 0) { + Item_Give(globalCtx, ITEM_POE); + pthis->actor.textId = 0x5008; + } else { + pthis->actor.textId = 0x508F; + Item_Give(globalCtx, ITEM_BIG_POE); + Flags_SetSwitch(globalCtx, sSpawnSwitchFlags[pthis->spawnFlagIndex]); + } + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + pthis->actor.textId = 0x5006; + } + } else { + pthis->actor.textId = 0x5007; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + return; + } + } else if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + EnPoField_SetupSoulDisappear(pthis); + } +} + +void EnPoField_TestForDamage(EnPoField* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != 0 || pthis->actor.colChkInfo.damage != 0) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DEAD); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DAMAGE); + } + EnPoField_SetupDamage(pthis); + } + } +} + +void EnPoField_SpawnFlame(EnPoField* pthis) { + if (pthis->flameTimer == 0) { + pthis->flamePosition.x = pthis->lightInfo.params.point.x; + pthis->flamePosition.y = pthis->lightInfo.params.point.y; + pthis->flamePosition.z = pthis->lightInfo.params.point.z; + pthis->flameTimer = 70; + pthis->flameRotation = pthis->actor.shape.rot.y; + } +} + +void EnPoField_UpdateFlame(EnPoField* pthis, GlobalContext* globalCtx) { + if (pthis->flameTimer != 0) { + if (pthis->flameTimer != 0) { + pthis->flameTimer--; + } + if (pthis->flameCollider.base.atFlags & AT_HIT) { + pthis->flameCollider.base.atFlags &= ~AT_HIT; + pthis->flameTimer = 19; + } + if (pthis->flameTimer < 20) { + Math_StepToF(&pthis->flameScale, 0.0f, 0.00015f); + return; + } + if (Math_StepToF(&pthis->flameScale, 0.003f, 0.0006f) != 0) { + pthis->flamePosition.x += 2.5f * Math_SinS(pthis->flameRotation); + pthis->flamePosition.z += 2.5f * Math_CosS(pthis->flameRotation); + } + pthis->flameCollider.dim.pos.x = pthis->flamePosition.x; + pthis->flameCollider.dim.pos.y = pthis->flamePosition.y; + pthis->flameCollider.dim.pos.z = pthis->flamePosition.z; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->flameCollider.base); + } +} + +void EnPoField_DrawFlame(EnPoField* pthis, GlobalContext* globalCtx) { + f32 sp4C; + s32 pad; + + if (pthis->flameTimer != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1669); + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (globalCtx->gameplayFrames * -20) % 512, 32, 128)); + sp4C = pthis->flameScale * 85000.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, sp4C); + Matrix_Translate(pthis->flamePosition.x, pthis->flamePosition.y, pthis->flamePosition.z, MTXMODE_NEW); + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); + if (pthis->flameTimer >= 20) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + Matrix_Scale(pthis->flameScale, pthis->flameScale, pthis->flameScale, MTXMODE_APPLY); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, sp4C, 0, 0, 0); + Matrix_Scale((pthis->flameScale * 0.7f) + 0.00090000004f, (0.003f - pthis->flameScale) + 0.003f, 0.003f, + MTXMODE_APPLY); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1709), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1712); + } +} + +void func_80AD619C(EnPoField* pthis) { + s16 temp_var; + + if (pthis->actionFunc == EnPoField_Flee) { + pthis->lightColor.r = CLAMP_MAX((s16)(pthis->lightColor.r + 5), 80); + pthis->lightColor.g = CLAMP_MAX((s16)(pthis->lightColor.g + 5), 255); + temp_var = pthis->lightColor.b + 5; + pthis->lightColor.b = CLAMP_MAX(temp_var, 225); + } else if (pthis->actionFunc == EnPoField_Damage) { + if (pthis->actor.colorFilterTimer & 2) { + pthis->lightColor.r = 0; + pthis->lightColor.g = 0; + pthis->lightColor.b = 0; + } else { + pthis->lightColor.r = 80; + pthis->lightColor.g = 255; + pthis->lightColor.b = 225; + } + } else { + pthis->lightColor.r = CLAMP_MAX((s16)(pthis->lightColor.r + 5), 255); + pthis->lightColor.g = CLAMP_MAX((s16)(pthis->lightColor.g + 5), 255); + if (pthis->lightColor.b > 210) { + temp_var = pthis->lightColor.b - 5; + pthis->lightColor.b = CLAMP_MIN(temp_var, 210); + } else { + temp_var = pthis->lightColor.b + 5; + pthis->lightColor.b = CLAMP_MAX(temp_var, 210); + } + } +} + +void func_80AD6330(EnPoField* pthis) { + f32 rand; + + if (pthis->actionFunc == EnPoField_Appear && pthis->skelAnime.curFrame < 12.0f) { + pthis->soulColor.r = pthis->soulColor.g = pthis->soulColor.b = (s16)(pthis->skelAnime.curFrame * 16.66f) + 55; + pthis->soulColor.a = pthis->skelAnime.curFrame * (100.0f / 6.0f); + } else { + rand = Rand_ZeroOne(); + pthis->soulColor.r = (s16)(rand * 30.0f) + 225; + pthis->soulColor.g = (s16)(rand * 100.0f) + 155; + pthis->soulColor.b = (s16)(rand * 160.0f) + 95; + pthis->soulColor.a = 200; + } +} + +void EnPoField_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPoField* pthis = (EnPoField*)thisx; + + EnPoField_TestForDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + EnPoField_UpdateFlame(pthis, globalCtx); + if (pthis->actionFunc == EnPoField_Flee || pthis->actionFunc == EnPoField_Damage || + pthis->actionFunc == EnPoField_Appear) { + Actor_MoveForward(&pthis->actor); + } + if (pthis->actionFunc != EnPoField_WaitForSpawn) { + Actor_SetFocus(&pthis->actor, 42.0f); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 27.0f, 60.0f, 4); + func_80AD619C(pthis); + func_80AD6330(pthis); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +s32 EnPoField_OverrideLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx, Gfx** gfxP) { + EnPoField* pthis = (EnPoField*)thisx; + + if (pthis->lightColor.a == 0 || limbIndex == 7 || (pthis->actionFunc == EnPoField_Death && pthis->actionTimer >= 2)) { + *dList = NULL; + } else if (pthis->actor.params == EN_PO_FIELD_BIG) { + if (limbIndex == 1) { + *dList = gBigPoeFaceDL; + } else if (limbIndex == 8) { + *dList = gBigPoeCloakDL; + } else if (limbIndex == 9) { + *dList = gBigPoeBodyDL; + } + } + if (pthis->actionFunc == EnPoField_Disappear && limbIndex == 7) { + Matrix_Scale(pthis->actionTimer / 16.0f, pthis->actionTimer / 16.0f, pthis->actionTimer / 16.0f, MTXMODE_APPLY); + } + return false; +} + +void EnPoField_PostLimDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfxP) { + EnPoField* pthis = (EnPoField*)thisx; + + if (pthis->actionFunc == EnPoField_Death && pthis->actionTimer >= 2 && limbIndex == 8) { + gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1916), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfxP)++, gPoeFieldBurnDL); + } + if (limbIndex == 7) { + Vec3f vec; + Matrix_MultVec3f(&D_80AD714C, &vec); + if (pthis->actionFunc == EnPoField_Death && pthis->actionTimer >= 19 && pthis->actor.scale.x != 0.0f) { + f32 mtxScale = 0.01f / pthis->actor.scale.x; + Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); + } + Matrix_Get(&sLimb7Mtx); + if (pthis->actionFunc == EnPoField_Death && pthis->actionTimer == 27) { + pthis->actor.world.pos.x = sLimb7Mtx.xw; + pthis->actor.world.pos.y = sLimb7Mtx.yw; + pthis->actor.world.pos.z = sLimb7Mtx.zw; + } + Lights_PointGlowSetInfo(&pthis->lightInfo, vec.x, vec.y, vec.z, pthis->soulColor.r, pthis->soulColor.g, + pthis->soulColor.b, pthis->soulColor.a * (200.0f / 255)); + } +} + +void EnPoField_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPoField* pthis = (EnPoField*)thisx; + EnPoFieldInfo* info = &sPoFieldInfo[pthis->actor.params]; + + if (pthis->actionFunc != EnPoField_WaitForSpawn) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 1976); + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x0A, + Gfx_EnvColor(globalCtx->state.gfxCtx, info->envColor.r, info->envColor.g, info->envColor.b, 255)); + if (pthis->lightColor.a == 255 || pthis->lightColor.a == 0) { + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, + pthis->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0C, D_80116280 + 2); + POLY_OPA_DISP = + SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoField_OverrideLimbDraw2, EnPoField_PostLimDraw2, &pthis->actor, POLY_OPA_DISP); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, + pthis->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); + POLY_XLU_DISP = + SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoField_OverrideLimbDraw2, EnPoField_PostLimDraw2, &pthis->actor, POLY_XLU_DISP); + } + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->soulColor.r, pthis->soulColor.g, pthis->soulColor.b, 255); + Matrix_Put(&sLimb7Mtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2033), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternDL); + gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternTopDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2039); + } + EnPoField_DrawFlame(pthis, globalCtx); +} + +void EnPoField_UpdateDead(Actor* thisx, GlobalContext* globalCtx) { + EnPoField* pthis = (EnPoField*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc == EnPoField_SoulIdle) { + func_80AD6330(pthis); + } + EnPoField_UpdateFlame(pthis, globalCtx); +} + +void EnPoField_DrawSoul(Actor* thisx, GlobalContext* globalCtx) { + EnPoField* pthis = (EnPoField*)thisx; + s32 pad; + EnPoFieldInfo* info = &sPoFieldInfo[pthis->actor.params]; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2077); + if (pthis->actionFunc == EnPoField_SoulIdle) { + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x0A, + Gfx_EnvColor(globalCtx->state.gfxCtx, info->envColor.r, info->envColor.g, info->envColor.b, 255)); + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->soulColor.r, pthis->soulColor.g, pthis->soulColor.b, 200); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->soulColor.r, pthis->soulColor.g, pthis->soulColor.b, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2104), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternDL); + gSPDisplayList(POLY_OPA_DISP++, gPoeFieldLanternTopDL); + } else { + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + (globalCtx->gameplayFrames * info->unk_9) & 0x1FF, 0x20, 0x80)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(info->soulTexture)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, info->primColor.r, info->primColor.g, info->primColor.b, + pthis->lightColor.a); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, 255); + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * 9.58738e-05f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2143), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gPoeFieldSoulDL); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_field.c", 2149); + EnPoField_DrawFlame(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c b/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c deleted file mode 100644 index 782cd8e7a..000000000 --- a/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.c +++ /dev/null @@ -1,423 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_RELAY_Z_EN_PO_RELAY_C -#include "actor_common.h" -/* - * File: z_en_po_relay.c - * Overlay: ovl_En_Po_Relay - * Description: Dampé's Ghost - */ - -#include "z_en_po_relay.h" -#include "overlays/actors/ovl_En_Honotrap/z_en_honotrap.h" -#include "objects/object_tk/object_tk.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_12 | ACTOR_FLAG_16) - -void EnPoRelay_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoRelay_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoRelay_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoRelay_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnPoRelay_Idle(EnPoRelay* this, GlobalContext* globalCtx); -void EnPoRelay_Race(EnPoRelay* this, GlobalContext* globalCtx); -void EnPoRelay_EndRace(EnPoRelay* this, GlobalContext* globalCtx); -void EnPoRelay_Talk(EnPoRelay* this, GlobalContext* globalCtx); -void EnPoRelay_Talk2(EnPoRelay* this, GlobalContext* globalCtx); -void EnPoRelay_DisappearAndReward(EnPoRelay* this, GlobalContext* globalCtx); -void EnPoRelay_SetupIdle(EnPoRelay* this); - -static Vec3s D_80AD8C30[] = { - { 0xFFC4, 0xFDEE, 0xF47A }, { 0x0186, 0xFE0C, 0xF47A }, { 0x0186, 0xFE0C, 0xF0F6 }, { 0x00D2, 0xFDEE, 0xF0F6 }, - { 0x00D2, 0xFD9E, 0xEEDA }, { 0x023A, 0xFDC6, 0xEEDA }, { 0x023A, 0xFDC6, 0xED18 }, { 0x00D2, 0xFDC6, 0xED18 }, - { 0x00D2, 0xFDC6, 0xEBCE }, { 0x00D2, 0xFDC6, 0xEAA2 }, { 0x023A, 0xFDC6, 0xEAA2 }, { 0x023A, 0xFDC6, 0xEBB0 }, - { 0x04EC, 0xFD9E, 0xEBB0 }, { 0x0672, 0xFD62, 0xED18 }, { 0x0672, 0xFD30, 0xEE80 }, { 0x07DA, 0xFD26, 0xEE80 }, - { 0x07DA, 0xFD26, 0xEF70 }, { 0x07DA, 0xFD26, 0xF204 }, { 0x0672, 0xFD44, 0xF204 }, { 0x0672, 0xFD6C, 0xF3C6 }, - { 0x088E, 0xFD6C, 0xF3C6 }, { 0x088E, 0xFDB2, 0xF5E2 }, { 0x099C, 0xFDD0, 0xF5E2 }, { 0x0B54, 0xFE66, 0xF772 }, - { 0x0B4E, 0xFE66, 0xF87E }, { 0x0B4A, 0xFE66, 0xF97A }, { 0x0B4A, 0xFE98, 0xF9FC }, { 0x0BAE, 0xFE98, 0xF9FC }, -}; - -const ActorInit En_Po_Relay_InitVars = { - ACTOR_EN_PO_RELAY, - ACTORCAT_NPC, - FLAGS, - OBJECT_TK, - sizeof(EnPoRelay), - (ActorFunc)EnPoRelay_Init, - (ActorFunc)EnPoRelay_Destroy, - (ActorFunc)EnPoRelay_Update, - (ActorFunc)EnPoRelay_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 30, 52, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x4F, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_STOP), -}; - -static Vec3f D_80AD8D30 = { 0.0f, 1.5f, 0.0f }; - -static Vec3f D_80AD8D3C = { 0.0f, 0.0f, 0.0f }; - -static Vec3f D_80AD8D48 = { 0.0f, 1200.0f, 0.0f }; - -static void* sEyesTextures[] = { - gDampeEyeOpenTex, - gDampeEyeHalfTex, - gDampeEyeClosedTex, -}; - -void EnPoRelay_Init(Actor* thisx, GlobalContext* globalCtx) { - EnPoRelay* this = (EnPoRelay*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 42.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDampeSkel, &gDampeFloatAnim, this->jointTable, this->morphTable, - 18); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - 255, 255, 255, 200); - this->lightColor.a = 255; - - Actor_SetTextWithPrefix(globalCtx, &this->actor, 65); - this->textId = this->actor.textId; - EnPoRelay_SetupIdle(this); - - this->actor.params &= 0x3F; -} - -void EnPoRelay_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPoRelay* this = (EnPoRelay*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnPoRelay_SetupIdle(EnPoRelay* this) { - this->unk_195 = 32; - this->pathIndex = 0; - this->actor.room = -1; - this->actor.shape.rot.y = 0; - this->actor.world.rot.y = -0x8000; - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actionFunc = EnPoRelay_Idle; -} - -void EnPoRelay_Vec3sToVec3f(Vec3f* dest, Vec3s* src) { - dest->x = src->x; - dest->y = src->y; - dest->z = src->z; -} - -void EnPoRelay_SetupRace(EnPoRelay* this) { - Vec3f vec; - - EnPoRelay_Vec3sToVec3f(&vec, &D_80AD8C30[this->pathIndex]); - this->actionTimer = ((s16)(this->actor.shape.rot.y - this->actor.world.rot.y - 0x8000) >> 0xB) % 32U; - func_80088B34(0); - this->hookshotSlotFull = INV_CONTENT(ITEM_HOOKSHOT) != ITEM_NONE; - this->unk_19A = Actor_WorldYawTowardPoint(&this->actor, &vec); - this->actor.flags |= ACTOR_FLAG_27; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - this->actionFunc = EnPoRelay_Race; -} - -void EnPoRelay_SetupEndRace(EnPoRelay* this) { - this->actor.world.rot.y = this->actor.home.rot.y + 0xC000; - this->actor.flags &= ~ACTOR_FLAG_27; - this->actor.speedXZ = 0.0f; - this->actionFunc = EnPoRelay_EndRace; -} - -void EnPoRelay_CorrectY(EnPoRelay* this) { - Math_StepToF(&this->actor.home.pos.y, D_80AD8C30[(this->pathIndex >= 28) ? 27 : this->pathIndex].y + 45.0f, 2.0f); - this->actor.world.pos.y = Math_SinS(this->unk_195 * 0x800) * 8.0f + this->actor.home.pos.y; -} - -void EnPoRelay_Idle(EnPoRelay* this, GlobalContext* globalCtx) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x100); - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actor.flags &= ~ACTOR_FLAG_16; - this->actionFunc = EnPoRelay_Talk; - } else if (this->actor.xzDistToPlayer < 250.0f) { - this->actor.flags |= ACTOR_FLAG_16; - this->actor.textId = this->textId; - func_8002F2CC(&this->actor, globalCtx, 250.0f); - } - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); -} - -void EnPoRelay_Talk(EnPoRelay* this, GlobalContext* globalCtx) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x100); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - Actor_SetTextWithPrefix(globalCtx, &this->actor, 0x2F); - this->textId = this->actor.textId; - EnPoRelay_SetupRace(this); - } - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); -} - -void EnPoRelay_Race(EnPoRelay* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f vec; - f32 speed; - f32 multiplier; - - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (this->actionTimer == 0 && Rand_ZeroOne() < 0.03f) { - this->actionTimer = 32; - if (this->pathIndex < 23) { - speed = Rand_ZeroOne() * 3.0f; - if (speed < 1.0f) { - multiplier = 1.0f; - } else if (speed < 2.0f) { - multiplier = -1.0f; - } else { - multiplier = 0.0f; - } - speed = 30.0f * multiplier; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HONOTRAP, - Math_CosS(this->unk_19A) * speed + this->actor.world.pos.x, this->actor.world.pos.y, - Math_SinS(this->unk_19A) * speed + this->actor.world.pos.z, 0, - (this->unk_19A + 0x8000) - (0x2000 * multiplier), 0, HONOTRAP_FLAME_DROP); - } - } - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_19A, 2, 0x1000, 0x100); - this->actor.shape.rot.y = this->actor.world.rot.y + (this->actionTimer * 0x800) + 0x8000; - if (this->pathIndex < 23) { - // If the player travels along a different path to Dampé that converges later - if ((Math3D_PointInSquare2D(660.0f, 840.0f, -4480.0f, -3760.0f, player->actor.world.pos.x, - player->actor.world.pos.z) != 0) || - (Math3D_PointInSquare2D(1560.0f, 1740.0f, -4030.0f, -3670.0f, player->actor.world.pos.x, - player->actor.world.pos.z) != 0) || - (Math3D_PointInSquare2D(1580.0f, 2090.0f, -3030.0f, -2500.0f, player->actor.world.pos.x, - player->actor.world.pos.z) != 0)) { - speed = (this->hookshotSlotFull) ? player->actor.speedXZ * 1.4f : player->actor.speedXZ * 1.2f; - } else if (this->actor.xzDistToPlayer < 150.0f) { - speed = (this->hookshotSlotFull) ? player->actor.speedXZ * 1.2f : player->actor.speedXZ; - } else if (this->actor.xzDistToPlayer < 300.0f) { - speed = (this->hookshotSlotFull) ? player->actor.speedXZ : player->actor.speedXZ * 0.8f; - } else if (this->hookshotSlotFull) { - speed = 4.5f; - } else { - speed = 3.5f; - } - multiplier = 250.0f - this->actor.xzDistToPlayer; - multiplier = CLAMP_MIN(multiplier, 0.0f); - speed += multiplier * 0.02f + 1.0f; - Math_ApproachF(&this->actor.speedXZ, speed, 0.5f, 1.5f); - } else { - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.5f, 1.5f); - } - EnPoRelay_Vec3sToVec3f(&vec, &D_80AD8C30[this->pathIndex]); - if (Actor_WorldDistXZToPoint(&this->actor, &vec) < 40.0f) { - this->pathIndex++; - EnPoRelay_Vec3sToVec3f(&vec, &D_80AD8C30[this->pathIndex]); - if (this->pathIndex == 28) { - EnPoRelay_SetupEndRace(this); - } else if (this->pathIndex == 9) { - Flags_SetSwitch(globalCtx, 0x35); - } else if (this->pathIndex == 17) { - Flags_SetSwitch(globalCtx, 0x36); - } else if (this->pathIndex == 25) { - Flags_SetSwitch(globalCtx, 0x37); - } - } - this->unk_19A = Actor_WorldYawTowardPoint(&this->actor, &vec); - func_8002F974(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); -} - -void EnPoRelay_EndRace(EnPoRelay* this, GlobalContext* globalCtx) { - Math_ScaledStepToS(&this->actor.shape.rot.y, -0x4000, 0x800); - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnPoRelay_Talk2; - } else if (globalCtx->roomCtx.curRoom.num == 5) { - Actor_Kill(&this->actor); - gSaveContext.timer1State = 0; - } else if (Actor_IsFacingAndNearPlayer(&this->actor, 150.0f, 0x3000)) { - this->actor.textId = this->textId; - func_8002F2CC(&this->actor, globalCtx, 250.0f); - } - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); -} - -void EnPoRelay_Talk2(EnPoRelay* this, GlobalContext* globalCtx) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x100); - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { - if (Message_ShouldAdvance(globalCtx)) { - if (this->hookshotSlotFull != 0) { - Actor_SetTextWithPrefix(globalCtx, &this->actor, 0x2E); - } else { - Actor_SetTextWithPrefix(globalCtx, &this->actor, 0x2D); - } - this->textId = this->actor.textId; - Message_ContinueTextbox(globalCtx, this->actor.textId); - } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - gSaveContext.timer1State = 0; - this->actionTimer = 0; - this->actionFunc = EnPoRelay_DisappearAndReward; - } - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); -} - -void EnPoRelay_DisappearAndReward(EnPoRelay* this, GlobalContext* globalCtx) { - Vec3f vec; - f32 multiplier; - s32 pad; - Vec3f sp60; - s32 pad1; - - this->actionTimer++; - if (this->actionTimer < 8) { - if (this->actionTimer < 5) { - vec.y = Math_SinS((this->actionTimer * 0x1000) - 0x4000) * 23.0f + (this->actor.world.pos.y + 40.0f); - multiplier = Math_CosS((this->actionTimer * 0x1000) - 0x4000) * 23.0f; - vec.x = (Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier) + - this->actor.world.pos.x; - vec.z = (Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier) + - this->actor.world.pos.z; - } else { - vec.y = this->actor.world.pos.y + 40.0f + 15.0f * (this->actionTimer - 5); - vec.x = - (Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f) + this->actor.world.pos.x; - vec.z = - (Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f) + this->actor.world.pos.z; - } - EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AD8D30, &D_80AD8D3C, this->actionTimer * 10 + 80, 0, 255, 255, 255, - 255, 0, 0, 255, 1, 9, true); - vec.x = (this->actor.world.pos.x + this->actor.world.pos.x) - vec.x; - vec.z = (this->actor.world.pos.z + this->actor.world.pos.z) - vec.z; - EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AD8D30, &D_80AD8D3C, this->actionTimer * 10 + 80, 0, 255, 255, 255, - 255, 0, 0, 255, 1, 9, true); - vec.x = this->actor.world.pos.x; - vec.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AD8D30, &D_80AD8D3C, this->actionTimer * 10 + 80, 0, 255, 255, 255, - 255, 0, 0, 255, 1, 9, true); - if (this->actionTimer == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EXTINCT); - } - } - if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f) != 0) { - if (this->hookshotSlotFull != 0) { - sp60.x = this->actor.world.pos.x; - sp60.y = this->actor.floorHeight; - sp60.z = this->actor.world.pos.z; - if (gSaveContext.timer1Value < HIGH_SCORE(HS_DAMPE_RACE)) { - HIGH_SCORE(HS_DAMPE_RACE) = gSaveContext.timer1Value; - } - if (Flags_GetCollectible(globalCtx, this->actor.params) == 0 && gSaveContext.timer1Value <= 60) { - Item_DropCollectible2(globalCtx, &sp60, (this->actor.params << 8) + (0x4000 | ITEM00_HEART_PIECE)); - } else { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, sp60.x, sp60.y, sp60.z, 0, 0, 0, 2); - } - } else { - Flags_SetTempClear(globalCtx, 4); - HIGH_SCORE(HS_DAMPE_RACE) = gSaveContext.timer1Value; - } - Actor_Kill(&this->actor); - } - this->actor.scale.y = this->actor.scale.x; - this->actor.scale.z = this->actor.scale.x; - this->actor.world.pos.y += 10.0f; -} - -void EnPoRelay_Update(Actor* thisx, GlobalContext* globalCtx) { - EnPoRelay* this = (EnPoRelay*)thisx; - s32 pad; - - SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - EnPoRelay_CorrectY(this); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 27.0f, 60.0f, 4); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_SetFocus(&this->actor, 50.0f); - if (this->unk_195 != 0) { - this->unk_195 -= 1; - } - if (this->unk_195 == 0) { - this->unk_195 = 32; - } - this->eyeTextureIdx++; - if (this->eyeTextureIdx == 3) { - this->eyeTextureIdx = 0; - } -} - -void EnPoRelay_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnPoRelay* this = (EnPoRelay*)thisx; - - if (limbIndex == 14) { - f32 rand; - Vec3f vec; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 885); - rand = Rand_ZeroOne(); - this->lightColor.r = (s16)(rand * 30.0f) + 225; - this->lightColor.g = (s16)(rand * 100.0f) + 155; - this->lightColor.b = (s16)(rand * 160.0f) + 95; - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, this->lightColor.r, this->lightColor.g, this->lightColor.b, 128); - gSPDisplayList(POLY_OPA_DISP++, gDampeLanternDL); - if (1) {} - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 901); - Matrix_MultVec3f(&D_80AD8D48, &vec); - Lights_PointNoGlowSetInfo(&this->lightInfo, vec.x, vec.y, vec.z, this->lightColor.r, this->lightColor.g, - this->lightColor.b, 200); - } else if (limbIndex == 8) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 916); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 918), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gDampeHaloDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 922); - } -} - -void EnPoRelay_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnPoRelay* this = (EnPoRelay*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 940); - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyesTextures[this->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnPoRelay_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 954); -} diff --git a/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.cpp b/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.cpp new file mode 100644 index 000000000..e4f8ffa7a --- /dev/null +++ b/src/overlays/actors/ovl_En_Po_Relay/z_en_po_relay.cpp @@ -0,0 +1,423 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_RELAY_Z_EN_PO_RELAY_C +#include "actor_common.h" +/* + * File: z_en_po_relay.c + * Overlay: ovl_En_Po_Relay + * Description: Dampé's Ghost + */ + +#include "z_en_po_relay.h" +#include "overlays/actors/ovl_En_Honotrap/z_en_honotrap.h" +#include "objects/object_tk/object_tk.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_12 | ACTOR_FLAG_16) + +void EnPoRelay_Init(Actor* thisx, GlobalContext* globalCtx); +void EnPoRelay_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnPoRelay_Update(Actor* thisx, GlobalContext* globalCtx); +void EnPoRelay_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnPoRelay_Idle(EnPoRelay* pthis, GlobalContext* globalCtx); +void EnPoRelay_Race(EnPoRelay* pthis, GlobalContext* globalCtx); +void EnPoRelay_EndRace(EnPoRelay* pthis, GlobalContext* globalCtx); +void EnPoRelay_Talk(EnPoRelay* pthis, GlobalContext* globalCtx); +void EnPoRelay_Talk2(EnPoRelay* pthis, GlobalContext* globalCtx); +void EnPoRelay_DisappearAndReward(EnPoRelay* pthis, GlobalContext* globalCtx); +void EnPoRelay_SetupIdle(EnPoRelay* pthis); + +static Vec3s D_80AD8C30[] = { + { 0xFFC4, 0xFDEE, 0xF47A }, { 0x0186, 0xFE0C, 0xF47A }, { 0x0186, 0xFE0C, 0xF0F6 }, { 0x00D2, 0xFDEE, 0xF0F6 }, + { 0x00D2, 0xFD9E, 0xEEDA }, { 0x023A, 0xFDC6, 0xEEDA }, { 0x023A, 0xFDC6, 0xED18 }, { 0x00D2, 0xFDC6, 0xED18 }, + { 0x00D2, 0xFDC6, 0xEBCE }, { 0x00D2, 0xFDC6, 0xEAA2 }, { 0x023A, 0xFDC6, 0xEAA2 }, { 0x023A, 0xFDC6, 0xEBB0 }, + { 0x04EC, 0xFD9E, 0xEBB0 }, { 0x0672, 0xFD62, 0xED18 }, { 0x0672, 0xFD30, 0xEE80 }, { 0x07DA, 0xFD26, 0xEE80 }, + { 0x07DA, 0xFD26, 0xEF70 }, { 0x07DA, 0xFD26, 0xF204 }, { 0x0672, 0xFD44, 0xF204 }, { 0x0672, 0xFD6C, 0xF3C6 }, + { 0x088E, 0xFD6C, 0xF3C6 }, { 0x088E, 0xFDB2, 0xF5E2 }, { 0x099C, 0xFDD0, 0xF5E2 }, { 0x0B54, 0xFE66, 0xF772 }, + { 0x0B4E, 0xFE66, 0xF87E }, { 0x0B4A, 0xFE66, 0xF97A }, { 0x0B4A, 0xFE98, 0xF9FC }, { 0x0BAE, 0xFE98, 0xF9FC }, +}; + +ActorInit En_Po_Relay_InitVars = { + ACTOR_EN_PO_RELAY, + ACTORCAT_NPC, + FLAGS, + OBJECT_TK, + sizeof(EnPoRelay), + (ActorFunc)EnPoRelay_Init, + (ActorFunc)EnPoRelay_Destroy, + (ActorFunc)EnPoRelay_Update, + (ActorFunc)EnPoRelay_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 30, 52, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x4F, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_STOP), +}; + +static Vec3f D_80AD8D30 = { 0.0f, 1.5f, 0.0f }; + +static Vec3f D_80AD8D3C = { 0.0f, 0.0f, 0.0f }; + +static Vec3f D_80AD8D48 = { 0.0f, 1200.0f, 0.0f }; + +static void* sEyesTextures[] = { + gDampeEyeOpenTex, + gDampeEyeHalfTex, + gDampeEyeClosedTex, +}; + +void EnPoRelay_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPoRelay* pthis = (EnPoRelay*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 42.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDampeSkel, &gDampeFloatAnim, pthis->jointTable, pthis->morphTable, + 18); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, + 255, 255, 255, 200); + pthis->lightColor.a = 255; + + Actor_SetTextWithPrefix(globalCtx, &pthis->actor, 65); + pthis->textId = pthis->actor.textId; + EnPoRelay_SetupIdle(pthis); + + pthis->actor.params &= 0x3F; +} + +void EnPoRelay_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoRelay* pthis = (EnPoRelay*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnPoRelay_SetupIdle(EnPoRelay* pthis) { + pthis->unk_195 = 32; + pthis->pathIndex = 0; + pthis->actor.room = -1; + pthis->actor.shape.rot.y = 0; + pthis->actor.world.rot.y = -0x8000; + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actionFunc = EnPoRelay_Idle; +} + +void EnPoRelay_Vec3sToVec3f(Vec3f* dest, Vec3s* src) { + dest->x = src->x; + dest->y = src->y; + dest->z = src->z; +} + +void EnPoRelay_SetupRace(EnPoRelay* pthis) { + Vec3f vec; + + EnPoRelay_Vec3sToVec3f(&vec, &D_80AD8C30[pthis->pathIndex]); + pthis->actionTimer = ((s16)(pthis->actor.shape.rot.y - pthis->actor.world.rot.y - 0x8000) >> 0xB) % 32U; + func_80088B34(0); + pthis->hookshotSlotFull = INV_CONTENT(ITEM_HOOKSHOT) != ITEM_NONE; + pthis->unk_19A = Actor_WorldYawTowardPoint(&pthis->actor, &vec); + pthis->actor.flags |= ACTOR_FLAG_27; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + pthis->actionFunc = EnPoRelay_Race; +} + +void EnPoRelay_SetupEndRace(EnPoRelay* pthis) { + pthis->actor.world.rot.y = pthis->actor.home.rot.y + 0xC000; + pthis->actor.flags &= ~ACTOR_FLAG_27; + pthis->actor.speedXZ = 0.0f; + pthis->actionFunc = EnPoRelay_EndRace; +} + +void EnPoRelay_CorrectY(EnPoRelay* pthis) { + Math_StepToF(&pthis->actor.home.pos.y, D_80AD8C30[(pthis->pathIndex >= 28) ? 27 : pthis->pathIndex].y + 45.0f, 2.0f); + pthis->actor.world.pos.y = Math_SinS(pthis->unk_195 * 0x800) * 8.0f + pthis->actor.home.pos.y; +} + +void EnPoRelay_Idle(EnPoRelay* pthis, GlobalContext* globalCtx) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0x100); + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actor.flags &= ~ACTOR_FLAG_16; + pthis->actionFunc = EnPoRelay_Talk; + } else if (pthis->actor.xzDistToPlayer < 250.0f) { + pthis->actor.flags |= ACTOR_FLAG_16; + pthis->actor.textId = pthis->textId; + func_8002F2CC(&pthis->actor, globalCtx, 250.0f); + } + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); +} + +void EnPoRelay_Talk(EnPoRelay* pthis, GlobalContext* globalCtx) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0x100); + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + Actor_SetTextWithPrefix(globalCtx, &pthis->actor, 0x2F); + pthis->textId = pthis->actor.textId; + EnPoRelay_SetupRace(pthis); + } + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); +} + +void EnPoRelay_Race(EnPoRelay* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f vec; + f32 speed; + f32 multiplier; + + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (pthis->actionTimer == 0 && Rand_ZeroOne() < 0.03f) { + pthis->actionTimer = 32; + if (pthis->pathIndex < 23) { + speed = Rand_ZeroOne() * 3.0f; + if (speed < 1.0f) { + multiplier = 1.0f; + } else if (speed < 2.0f) { + multiplier = -1.0f; + } else { + multiplier = 0.0f; + } + speed = 30.0f * multiplier; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HONOTRAP, + Math_CosS(pthis->unk_19A) * speed + pthis->actor.world.pos.x, pthis->actor.world.pos.y, + Math_SinS(pthis->unk_19A) * speed + pthis->actor.world.pos.z, 0, + (pthis->unk_19A + 0x8000) - (0x2000 * multiplier), 0, HONOTRAP_FLAME_DROP); + } + } + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->unk_19A, 2, 0x1000, 0x100); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + (pthis->actionTimer * 0x800) + 0x8000; + if (pthis->pathIndex < 23) { + // If the player travels along a different path to Dampé that converges later + if ((Math3D_PointInSquare2D(660.0f, 840.0f, -4480.0f, -3760.0f, player->actor.world.pos.x, + player->actor.world.pos.z) != 0) || + (Math3D_PointInSquare2D(1560.0f, 1740.0f, -4030.0f, -3670.0f, player->actor.world.pos.x, + player->actor.world.pos.z) != 0) || + (Math3D_PointInSquare2D(1580.0f, 2090.0f, -3030.0f, -2500.0f, player->actor.world.pos.x, + player->actor.world.pos.z) != 0)) { + speed = (pthis->hookshotSlotFull) ? player->actor.speedXZ * 1.4f : player->actor.speedXZ * 1.2f; + } else if (pthis->actor.xzDistToPlayer < 150.0f) { + speed = (pthis->hookshotSlotFull) ? player->actor.speedXZ * 1.2f : player->actor.speedXZ; + } else if (pthis->actor.xzDistToPlayer < 300.0f) { + speed = (pthis->hookshotSlotFull) ? player->actor.speedXZ : player->actor.speedXZ * 0.8f; + } else if (pthis->hookshotSlotFull) { + speed = 4.5f; + } else { + speed = 3.5f; + } + multiplier = 250.0f - pthis->actor.xzDistToPlayer; + multiplier = CLAMP_MIN(multiplier, 0.0f); + speed += multiplier * 0.02f + 1.0f; + Math_ApproachF(&pthis->actor.speedXZ, speed, 0.5f, 1.5f); + } else { + Math_ApproachF(&pthis->actor.speedXZ, 3.5f, 0.5f, 1.5f); + } + EnPoRelay_Vec3sToVec3f(&vec, &D_80AD8C30[pthis->pathIndex]); + if (Actor_WorldDistXZToPoint(&pthis->actor, &vec) < 40.0f) { + pthis->pathIndex++; + EnPoRelay_Vec3sToVec3f(&vec, &D_80AD8C30[pthis->pathIndex]); + if (pthis->pathIndex == 28) { + EnPoRelay_SetupEndRace(pthis); + } else if (pthis->pathIndex == 9) { + Flags_SetSwitch(globalCtx, 0x35); + } else if (pthis->pathIndex == 17) { + Flags_SetSwitch(globalCtx, 0x36); + } else if (pthis->pathIndex == 25) { + Flags_SetSwitch(globalCtx, 0x37); + } + } + pthis->unk_19A = Actor_WorldYawTowardPoint(&pthis->actor, &vec); + func_8002F974(&pthis->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); +} + +void EnPoRelay_EndRace(EnPoRelay* pthis, GlobalContext* globalCtx) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, -0x4000, 0x800); + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnPoRelay_Talk2; + } else if (globalCtx->roomCtx.curRoom.num == 5) { + Actor_Kill(&pthis->actor); + gSaveContext.timer1State = 0; + } else if (Actor_IsFacingAndNearPlayer(&pthis->actor, 150.0f, 0x3000)) { + pthis->actor.textId = pthis->textId; + func_8002F2CC(&pthis->actor, globalCtx, 250.0f); + } + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); +} + +void EnPoRelay_Talk2(EnPoRelay* pthis, GlobalContext* globalCtx) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0x100); + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { + if (Message_ShouldAdvance(globalCtx)) { + if (pthis->hookshotSlotFull != 0) { + Actor_SetTextWithPrefix(globalCtx, &pthis->actor, 0x2E); + } else { + Actor_SetTextWithPrefix(globalCtx, &pthis->actor, 0x2D); + } + pthis->textId = pthis->actor.textId; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } + } else if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + gSaveContext.timer1State = 0; + pthis->actionTimer = 0; + pthis->actionFunc = EnPoRelay_DisappearAndReward; + } + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); +} + +void EnPoRelay_DisappearAndReward(EnPoRelay* pthis, GlobalContext* globalCtx) { + Vec3f vec; + f32 multiplier; + s32 pad; + Vec3f sp60; + s32 pad1; + + pthis->actionTimer++; + if (pthis->actionTimer < 8) { + if (pthis->actionTimer < 5) { + vec.y = Math_SinS((pthis->actionTimer * 0x1000) - 0x4000) * 23.0f + (pthis->actor.world.pos.y + 40.0f); + multiplier = Math_CosS((pthis->actionTimer * 0x1000) - 0x4000) * 23.0f; + vec.x = (Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier) + + pthis->actor.world.pos.x; + vec.z = (Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier) + + pthis->actor.world.pos.z; + } else { + vec.y = pthis->actor.world.pos.y + 40.0f + 15.0f * (pthis->actionTimer - 5); + vec.x = + (Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f) + pthis->actor.world.pos.x; + vec.z = + (Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f) + pthis->actor.world.pos.z; + } + EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AD8D30, &D_80AD8D3C, pthis->actionTimer * 10 + 80, 0, 255, 255, 255, + 255, 0, 0, 255, 1, 9, true); + vec.x = (pthis->actor.world.pos.x + pthis->actor.world.pos.x) - vec.x; + vec.z = (pthis->actor.world.pos.z + pthis->actor.world.pos.z) - vec.z; + EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AD8D30, &D_80AD8D3C, pthis->actionTimer * 10 + 80, 0, 255, 255, 255, + 255, 0, 0, 255, 1, 9, true); + vec.x = pthis->actor.world.pos.x; + vec.z = pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AD8D30, &D_80AD8D3C, pthis->actionTimer * 10 + 80, 0, 255, 255, 255, + 255, 0, 0, 255, 1, 9, true); + if (pthis->actionTimer == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EXTINCT); + } + } + if (Math_StepToF(&pthis->actor.scale.x, 0.0f, 0.001f) != 0) { + if (pthis->hookshotSlotFull != 0) { + sp60.x = pthis->actor.world.pos.x; + sp60.y = pthis->actor.floorHeight; + sp60.z = pthis->actor.world.pos.z; + if (gSaveContext.timer1Value < HIGH_SCORE(HS_DAMPE_RACE)) { + HIGH_SCORE(HS_DAMPE_RACE) = gSaveContext.timer1Value; + } + if (Flags_GetCollectible(globalCtx, pthis->actor.params) == 0 && gSaveContext.timer1Value <= 60) { + Item_DropCollectible2(globalCtx, &sp60, (pthis->actor.params << 8) + (0x4000 | ITEM00_HEART_PIECE)); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, sp60.x, sp60.y, sp60.z, 0, 0, 0, 2); + } + } else { + Flags_SetTempClear(globalCtx, 4); + HIGH_SCORE(HS_DAMPE_RACE) = gSaveContext.timer1Value; + } + Actor_Kill(&pthis->actor); + } + pthis->actor.scale.y = pthis->actor.scale.x; + pthis->actor.scale.z = pthis->actor.scale.x; + pthis->actor.world.pos.y += 10.0f; +} + +void EnPoRelay_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPoRelay* pthis = (EnPoRelay*)thisx; + s32 pad; + + SkelAnime_Update(&pthis->skelAnime); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + EnPoRelay_CorrectY(pthis); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 27.0f, 60.0f, 4); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_SetFocus(&pthis->actor, 50.0f); + if (pthis->unk_195 != 0) { + pthis->unk_195 -= 1; + } + if (pthis->unk_195 == 0) { + pthis->unk_195 = 32; + } + pthis->eyeTextureIdx++; + if (pthis->eyeTextureIdx == 3) { + pthis->eyeTextureIdx = 0; + } +} + +void EnPoRelay_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnPoRelay* pthis = (EnPoRelay*)thisx; + + if (limbIndex == 14) { + f32 rand; + Vec3f vec; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 885); + rand = Rand_ZeroOne(); + pthis->lightColor.r = (s16)(rand * 30.0f) + 225; + pthis->lightColor.g = (s16)(rand * 100.0f) + 155; + pthis->lightColor.b = (s16)(rand * 160.0f) + 95; + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, 128); + gSPDisplayList(POLY_OPA_DISP++, gDampeLanternDL); + if (1) {} + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 901); + Matrix_MultVec3f(&D_80AD8D48, &vec); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, vec.x, vec.y, vec.z, pthis->lightColor.r, pthis->lightColor.g, + pthis->lightColor.b, 200); + } else if (limbIndex == 8) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 916); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 918), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDampeHaloDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 922); + } +} + +void EnPoRelay_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPoRelay* pthis = (EnPoRelay*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 940); + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyesTextures[pthis->eyeTextureIdx])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, EnPoRelay_PostLimbDraw, &pthis->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_relay.c", 954); +} diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c deleted file mode 100644 index cb7485d64..000000000 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ /dev/null @@ -1,1436 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_SISTERS_Z_EN_PO_SISTERS_C -#include "actor_common.h" -/* - * File: z_en_po_sisters.c - * Overlay: ovl_En_Po_Sisters - * Description: Forest Temple Four Poe Sisters - */ - -#include "z_en_po_sisters.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_po_sisters/object_po_sisters.h" -#include "def/code_8006BA00.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9 | ACTOR_FLAG_12 | ACTOR_FLAG_14) - -void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80ADA094(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADA4A8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADA530(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADA6A0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADA7F0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADA8C0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADA9E8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADAAA4(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADAC70(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADAD54(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADAE6C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADAFC0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB17C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB2B8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB338(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB9F0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB4B0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB51C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADB770(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBB6C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBBF4(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBC88(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBD38(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBD8C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBEE8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80ADBF58(EnPoSisters* this, GlobalContext* globalCtx); - -void func_80AD9AA8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80AD9C24(EnPoSisters* this, GlobalContext* globalCtx); - -void func_80AD9D44(EnPoSisters* this); - -static Color_RGBA8 D_80ADD6F0[4] = { - { 255, 170, 255, 255 }, - { 255, 200, 0, 255 }, - { 0, 170, 255, 255 }, - { 170, 255, 0, 255 }, -}; - -static Color_RGBA8 D_80ADD700[4] = { - { 100, 0, 255, 255 }, - { 255, 0, 0, 255 }, - { 0, 0, 255, 255 }, - { 0, 150, 0, 255 }, -}; - -const ActorInit En_Po_Sisters_InitVars = { - ACTOR_EN_PO_SISTERS, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_PO_SISTERS, - sizeof(EnPoSisters), - (ActorFunc)EnPoSisters_Init, - (ActorFunc)EnPoSisters_Destroy, - (ActorFunc)EnPoSisters_Update, - (ActorFunc)EnPoSisters_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x4FC7FFEA, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 18, 60, 15, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 10, 25, 60, 40 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0xF), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0xE), - /* Master sword */ DMG_ENTRY(2, 0xE), - /* Giant's Knife */ DMG_ENTRY(4, 0xE), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0xE), - /* Giant spin */ DMG_ENTRY(4, 0xE), - /* Master spin */ DMG_ENTRY(2, 0xE), - /* Kokiri jump */ DMG_ENTRY(2, 0xE), - /* Giant jump */ DMG_ENTRY(8, 0xE), - /* Master jump */ DMG_ENTRY(4, 0xE), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static s32 D_80ADD784 = 0; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 7, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_STOP), -}; - -static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; - -static s16 D_80ADD79C[4] = { 0xB000, 0xD000, 0x5000, 0x3000 }; - -static Vec3s D_80ADD7A4[4] = { - { -22, 337, -1704 }, - { -431, 879, -3410 }, - { 549, 879, -3410 }, - { 1717, 515, -1340 }, -}; - -static Vec3f D_80ADD7BC = { 120.0f, 250.0f, -1420.0f }; - -static Gfx* D_80ADD7C8[4] = { - gPoeSistersMegBodyDL, - gPoeSistersJoelleBodyDL, - gPoeSistersBethBodyDL, - gPoeSistersAmyBodyDL, -}; - -static Gfx* D_80ADD7D8[4] = { - gPoeSistersMegFaceDL, - gPoeSistersJoelleFaceDL, - gPoeSistersBethFaceDL, - gPoSistersAmyFaceDL, -}; - -static Color_RGBA8 D_80ADD7E8[4] = { - { 80, 0, 100, 0 }, - { 80, 15, 0, 0 }, - { 0, 70, 50, 0 }, - { 70, 70, 0, 0 }, -}; - -static Vec3f D_80ADD7F8 = { 1000.0f, -1700.0f, 0.0f }; - -void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { - EnPoSisters* this = (EnPoSisters*)thisx; - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gPoeSistersSkel, &gPoeSistersSwayAnim, this->jointTable, - this->morphTable, 12); - this->unk_22E.r = 255; - this->unk_22E.g = 255; - this->unk_22E.b = 210; - this->unk_22E.a = 255; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, - 0, 0, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->unk_194 = (thisx->params >> 8) & 3; - this->actor.naviEnemyId = this->unk_194 + 0x50; - if (1) {} - this->unk_195 = (thisx->params >> 0xA) & 3; - this->unk_196 = 32; - this->unk_197 = 20; - this->unk_198 = 1; - this->unk_199 = 32; - this->unk_294 = 110.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->actor.params & 0x1000) { - func_80ADA094(this, globalCtx); - } else if (this->unk_194 == 0) { - if (this->unk_195 == 0) { - this->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_PLAYER; - func_80AD9AA8(this, globalCtx); - } else { - this->actor.flags &= ~(ACTOR_FLAG_9 | ACTOR_FLAG_14); - this->collider.info.elemType = ELEMTYPE_UNK4; - this->collider.info.bumper.dmgFlags |= 1; - this->collider.base.ocFlags1 = OC1_NONE; - func_80AD9C24(this, NULL); - } - } else { - func_80AD9D44(this); - } - this->actor.params &= 0x3F; -} - -void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPoSisters* this = (EnPoSisters*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - if (this->unk_194 == 0 && this->unk_195 == 0) { - func_800F5B58(); - } - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AD9240(EnPoSisters* this, s32 arg1, Vec3f* arg2) { - f32 temp_f20 = SQ(arg1) * 0.1f; - Vec3f* vec; - s32 i; - - for (i = 0; i < this->unk_198; i++) { - vec = &this->unk_234[i]; - vec->x = arg2->x + Math_SinS((s16)(this->actor.shape.rot.y + (this->unk_19A * 0x800) + i * 0x2000)) * temp_f20; - vec->z = arg2->z + Math_CosS((s16)(this->actor.shape.rot.y + (this->unk_19A * 0x800) + i * 0x2000)) * temp_f20; - vec->y = arg2->y + arg1; - } -} - -void func_80AD9368(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersSwayAnim, -3.0f); - this->unk_19A = Rand_S16Offset(2, 3); - this->actionFunc = func_80ADA4A8; - this->actor.speedXZ = 0.0f; -} - -void func_80AD93C4(EnPoSisters* this) { - if (this->actionFunc != func_80ADA6A0) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); - } - this->unk_19A = Rand_S16Offset(0xF, 3); - this->unk_199 |= 7; - this->actionFunc = func_80ADA530; -} - -void func_80AD943C(EnPoSisters* this) { - this->actionFunc = func_80ADA6A0; -} - -void func_80AD944C(EnPoSisters* this) { - if (this->unk_22E.a != 0) { - this->collider.base.colType = COLTYPE_METAL; - this->collider.base.acFlags |= AC_HARD; - } - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersAttackAnim, -5.0f); - this->actor.speedXZ = 0.0f; - this->unk_19A = Animation_GetLastFrame(&gPoeSistersAttackAnim) * 3 + 3; - this->unk_199 &= ~2; - this->actionFunc = func_80ADA7F0; -} - -void func_80AD94E0(EnPoSisters* this) { - this->actor.speedXZ = 5.0f; - if (this->unk_194 == 0) { - this->collider.base.colType = COLTYPE_METAL; - this->collider.base.acFlags |= AC_HARD; - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersAttackAnim, -5.0f); - } - this->unk_19A = 5; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->unk_199 |= 8; - this->actionFunc = func_80ADA8C0; -} - -void func_80AD9568(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); - this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; - if (this->unk_194 != 0) { - this->collider.base.colType = COLTYPE_HIT3; - this->collider.base.acFlags &= ~AC_HARD; - } - this->actionFunc = func_80ADA9E8; -} - -void func_80AD95D8(EnPoSisters* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPoeSistersDamagedAnim, -3.0f); - if (this->collider.base.ac != NULL) { - this->actor.world.rot.y = (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) - ? this->collider.base.ac->world.rot.y - : Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac) + 0x8000; - } - if (this->unk_194 != 0) { - this->actor.speedXZ = 10.0f; - } - this->unk_199 &= ~0xB; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x10); - this->actionFunc = func_80ADAAA4; -} - -void func_80AD96A4(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFleeAnim, -3.0f); - this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; - this->unk_19A = 5; - this->unk_199 |= 0xB; - this->actor.speedXZ = 5.0f; - this->actionFunc = func_80ADAC70; -} - -void func_80AD9718(EnPoSisters* this) { - Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, - Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE, -3.0f); - this->actor.speedXZ = 0.0f; - this->unk_19C = 100; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_199 &= ~5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); - this->actionFunc = func_80ADAD54; -} - -void func_80AD97C8(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 sp20; - - if (this->unk_195 == 0 || this->actionFunc != func_80ADAAA4) { - if ((player->swordState == 0 || player->swordAnimation >= 24) && - player->actor.world.pos.y - player->actor.floorHeight < 1.0f) { - Math_StepToF(&this->unk_294, 110.0f, 3.0f); - } else { - Math_StepToF(&this->unk_294, 170.0f, 10.0f); - } - sp20 = this->unk_294; - } else if (this->unk_195 != 0) { - sp20 = this->actor.parent->xzDistToPlayer; - } - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y + 0x8000) * sp20) + player->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y + 0x8000) * sp20) + player->actor.world.pos.z; -} - -void func_80AD98F4(EnPoSisters* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, - Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE, -3.0f); - if (this->unk_194 == 0) { - this->unk_294 = 110.0f; - func_80AD97C8(this, globalCtx); - this->unk_22E.a = 0; - this->actor.draw = EnPoSisters_Draw; - } else { - this->actor.world.rot.y = this->actor.shape.rot.y; - } - this->unk_19A = 15; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - this->unk_199 &= ~1; - this->actionFunc = func_80ADAE6C; -} - -void func_80AD99D4(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_19A = 0; - this->actor.speedXZ = 0.0f; - this->actor.world.pos.y += 42.0f; - this->actor.shape.yOffset = -6000.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_199 = 0; - this->actionFunc = func_80ADAFC0; - OnePointCutscene_Init(globalCtx, 3190, 999, &this->actor, MAIN_CAM); -} - -void func_80AD9A54(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_19A = 0; - this->actor.world.pos.y = this->unk_234[0].y; - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); - this->actionFunc = func_80ADB17C; -} - -// Meg spawning fakes -void func_80AD9AA8(EnPoSisters* this, GlobalContext* globalCtx) { - Actor* actor1 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x400); - Actor* actor2 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x800); - Actor* actor3 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0xC00); - s32 pad; - s32 pad1; - - if (actor1 == NULL || actor2 == NULL || actor3 == NULL) { - if (actor1 != NULL) { - Actor_Kill(actor1); - } - if (actor2 != NULL) { - Actor_Kill(actor2); - } - if (actor3 != NULL) { - Actor_Kill(actor3); - } - Actor_Kill(&this->actor); - } else { - actor3->parent = &this->actor; - actor2->parent = &this->actor; - actor1->parent = &this->actor; - Animation_PlayLoop(&this->skelAnime, &gPoeSistersMegCryAnim); - this->unk_198 = 0; - this->unk_199 = 160; - this->actionFunc = func_80ADB2B8; - } -} - -void func_80AD9C24(EnPoSisters* this, GlobalContext* globalCtx) { - Vec3f vec; - - this->actor.draw = NULL; - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_19C = 100; - this->unk_199 = 32; - this->collider.base.colType = COLTYPE_HIT3; - this->collider.base.acFlags &= ~AC_HARD; - if (globalCtx != NULL) { - vec.x = this->actor.world.pos.x; - vec.y = this->actor.world.pos.y + 45.0f; - vec.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &vec, &sZeroVector, &sZeroVector, 150, 0, 255, 255, 255, 155, 150, 150, 150, 1, - 9, 0); - } - Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); - this->actionFunc = func_80ADB338; -} - -void func_80AD9D44(EnPoSisters* this) { - if (this->unk_194 == 3) { - Animation_PlayOnce(&this->skelAnime, &gPoeSistersAppearDisappearAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - } else { - Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE_INTERP, 0.0f); - } - this->unk_22E.a = 0; - this->unk_199 = 32; - this->actionFunc = func_80ADB9F0; -} - -void func_80AD9DF0(EnPoSisters* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPoeSistersAppearDisappearAnim, -5.0f); - this->unk_198 = 1; - this->unk_199 &= ~0x80; - this->actionFunc = func_80ADB4B0; - OnePointCutscene_Init(globalCtx, 3180, 156, &this->actor, MAIN_CAM); -} - -void func_80AD9E60(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); - this->unk_19A = Animation_GetLastFrame(&gPoeSistersFloatAnim) * 7 + 7; - if (this->actor.parent != NULL) { - this->actor.world.pos = this->actor.parent->world.pos; - this->actor.shape.rot.y = this->actor.parent->shape.rot.y; - } else { - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->unk_19A++; - } - if (this->unk_195 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); - } - this->actionFunc = func_80ADB51C; -} - -void func_80AD9F1C(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); - this->unk_22E.a = 255; - this->unk_19A = 300; - this->unk_19C = 3; - this->unk_199 |= 9; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = func_80ADB770; -} - -void func_80AD9F90(EnPoSisters* this) { - if (this->unk_194 == 1) { - this->actor.home.pos.x = -632.0f; - this->actor.home.pos.z = -3440.0f; - } else { - this->actor.home.pos.x = 752.0f; - this->actor.home.pos.z = -3440.0f; - } - Animation_PlayLoop(&this->skelAnime, &gPoeSistersFloatAnim); - this->unk_199 |= 0xA; - this->actionFunc = func_80ADBB6C; - this->actor.speedXZ = 5.0f; -} - -void func_80ADA028(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersSwayAnim, -3.0f); - this->unk_22E.a = 255; - this->unk_199 |= 0x15; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = func_80ADBBF4; - this->actor.speedXZ = 0.0f; -} - -void func_80ADA094(EnPoSisters* this, GlobalContext* globalCtx) { - D_80ADD784 = 0; - this->unk_22E.a = 0; - this->unk_199 = 128; - this->unk_19A = 50; - this->unk_234[0] = this->actor.home.pos; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - this->actionFunc = func_80ADBC88; -} - -void func_80ADA10C(EnPoSisters* this) { - s32 i; - - this->unk_198 = ARRAY_COUNT(this->unk_234); - for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { - this->unk_234[i] = this->unk_234[0]; - } - this->actionFunc = func_80ADBD38; -} - -void func_80ADA1B8(EnPoSisters* this) { - Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 0.833f, 0.0f, - Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE_INTERP, 0.0f); - if (this->unk_194 == 0 || this->unk_194 == 1) { - this->unk_19A = 40; - } else { - this->unk_19A = 76; - } - this->unk_198 = 0; - D_80ADD784 = 0; - this->actionFunc = func_80ADBD8C; -} - -void func_80ADA25C(EnPoSisters* this) { - Animation_PlayLoop(&this->skelAnime, &gPoeSistersSwayAnim); - this->unk_198 = 8; - this->unk_19A = 32; - func_80AD9240(this, this->unk_19A, &this->actor.home.pos); - this->actionFunc = func_80ADBEE8; -} - -void func_80ADA2BC(EnPoSisters* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); - this->unk_198 = 0; - this->unk_199 = 40; - this->unk_19A = 90; - this->unk_196 = 32; - this->actor.world.rot.y = D_80ADD79C[this->unk_194]; - this->actor.home.pos.y = this->actor.world.pos.y; - if (this->unk_194 == 0) { - Flags_SetSwitch(globalCtx, 0x1B); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FLAME_IGNITION); - this->actionFunc = func_80ADBF58; -} - -void func_80ADA35C(EnPoSisters* this, GlobalContext* globalCtx) { - f32 targetY; - Player* player = GET_PLAYER(globalCtx); - - if (this->actionFunc == func_80ADBF58) { - targetY = this->actor.home.pos.y; - } else if (this->unk_194 == 0 || this->unk_194 == 3) { - targetY = player->actor.world.pos.y + 5.0f; - } else { - targetY = 832.0f; - } - Math_ApproachF(&this->actor.world.pos.y, targetY, 0.5f, 3.0f); - if (!this->unk_196) { - this->unk_196 = 32; - } - if (this->unk_196 != 0) { - this->unk_196--; - } - this->actor.world.pos.y += (2.0f + 0.5f * Rand_ZeroOne()) * Math_SinS(this->unk_196 * 0x800); - if (this->unk_22E.a == 255 && this->actionFunc != func_80ADA8C0 && this->actionFunc != func_80ADA7F0) { - if (this->actionFunc == func_80ADAC70) { - func_8002F974(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); - } else { - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - } - } -} - -void func_80ADA4A8(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->unk_19A != 0) { - this->unk_19A--; - } - if (this->unk_19A == 0 || this->actor.xzDistToPlayer < 200.0f) { - func_80AD93C4(this); - } -} - -void func_80ADA530(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->unk_19A != 0) { - this->unk_19A--; - } - if (this->actor.xzDistToPlayer < 200.0f && fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f) { - func_80AD943C(this); - } else if (this->unk_19A == 0 && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f) != 0) { - func_80AD9368(this); - } - if (this->actor.bgCheckFlags & 8) { - Math_ScaledStepToS(&this->actor.world.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), - 0x71C); - } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - Math_ScaledStepToS(&this->actor.world.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), - 0x71C); - } -} - -void func_80ADA6A0(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 temp_v0; - - SkelAnime_Update(&this->skelAnime); - temp_v0 = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; - Math_StepToF(&this->actor.speedXZ, 2.0f, 0.2f); - if (temp_v0 > 0x3000) { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x3000, 0x71C); - } else if (temp_v0 < -0x3000) { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x3000, 0x71C); - } else { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); - } - if (this->actor.xzDistToPlayer < 160.0f && fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f) { - func_80AD944C(this); - } else if (this->actor.xzDistToPlayer > 240.0f) { - func_80AD93C4(this); - } -} - -void func_80ADA7F0(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_19A != 0) { - this->unk_19A--; - } - this->actor.shape.rot.y += 384.0f * ((this->skelAnime.endFrame + 1.0f) * 3.0f - this->unk_19A); - if (this->unk_19A == 18 || this->unk_19A == 7) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); - } - if (this->unk_19A == 0) { - func_80AD94E0(this); - } -} - -void func_80ADA8C0(EnPoSisters* this, GlobalContext* globalCtx) { - s32 pad; - - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->unk_19A != 0) { - this->unk_19A--; - } - this->actor.shape.rot.y += (384.0f * this->skelAnime.endFrame) * 3.0f; - if (this->unk_19A == 0 && ABS((s16)(this->actor.shape.rot.y - this->actor.world.rot.y)) < 0x1000) { - if (this->unk_194 != 0) { - this->collider.base.colType = COLTYPE_HIT3; - this->collider.base.acFlags &= ~AC_HARD; - func_80AD93C4(this); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); - func_80AD9C24(this, globalCtx); - } - } - if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); - } -} - -void func_80ADA9E8(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - this->actor.shape.rot.y -= (this->actor.speedXZ * 10.0f) * 128.0f; - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f) != 0) { - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->unk_194 != 0) { - func_80AD93C4(this); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); - func_80AD9C24(this, globalCtx); - } - } -} - -void func_80ADAAA4(EnPoSisters* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & ACTOR_FLAG_15)) { - if (this->actor.colChkInfo.health != 0) { - if (this->unk_194 != 0) { - func_80AD96A4(this); - } else if (this->unk_195 != 0) { - func_80AD9C24(this, NULL); - } else { - func_80AD9C24(this, globalCtx); - } - } else { - func_80AD99D4(this, globalCtx); - } - } - if (this->unk_195 != 0) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.parent->shape.rot.y, - (this->unk_195 == 2) ? 0x800 : 0x400); - this->unk_22E.a = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; - this->actor.world.pos.y = this->actor.parent->world.pos.y; - func_80AD97C8(this, globalCtx); - } else if (this->unk_194 != 0) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - } -} - -void func_80ADAC70(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x8000, 1820); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->unk_19A != 0) { - this->unk_19A--; - } - if (this->actor.bgCheckFlags & 8) { - this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_199 |= 2; - func_80AD9718(this); - } else if (this->unk_19A == 0 && 240.0f < this->actor.xzDistToPlayer) { - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80AD93C4(this); - } -} - -void func_80ADAD54(EnPoSisters* this, GlobalContext* globalCtx) { - s32 endFrame; - - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_22E.a = 0; - this->collider.info.bumper.dmgFlags = 0x00060001; - func_80AD93C4(this); - } else { - endFrame = this->skelAnime.endFrame; - this->unk_22E.a = ((endFrame - this->skelAnime.curFrame) * 255.0f) / endFrame; - } -} - -void func_80ADAE6C(EnPoSisters* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_22E.a = 255; - if (this->unk_194 != 0) { - this->unk_199 |= 1; - this->collider.info.bumper.dmgFlags = 0x4FC7FFEA; - if (this->unk_19A != 0) { - this->unk_19A--; - } - if (this->unk_19A == 0) { - this->unk_197 = 20; - func_80AD93C4(this); - } - } else { - func_80AD9F1C(this); - } - } else { - this->unk_22E.a = (this->skelAnime.curFrame * 255.0f) / this->skelAnime.endFrame; - if (this->unk_194 == 0) { - func_80AD97C8(this, globalCtx); - } - } -} - -void func_80ADAFC0(EnPoSisters* this, GlobalContext* globalCtx) { - s32 i; - - this->unk_19A++; - this->unk_198 = CLAMP_MAX(this->unk_198 + 1, 8); - for (i = this->unk_198 - 1; i > 0; i--) { - this->unk_234[i] = this->unk_234[i - 1]; - } - this->unk_234[0].x = - (Math_SinS((this->actor.shape.rot.y + this->unk_19A * 0x3000) - 0x4000) * (3000.0f * this->actor.scale.x)) + - this->actor.world.pos.x; - this->unk_234[0].z = - (Math_CosS((this->actor.shape.rot.y + this->unk_19A * 0x3000) - 0x4000) * (3000.0f * this->actor.scale.x)) + - this->actor.world.pos.z; - if (this->unk_19A < 8) { - this->unk_234[0].y = this->unk_234[1].y - 9.0f; - } else { - this->unk_234[0].y = this->unk_234[1].y + 2.0f; - if (this->unk_19A >= 16) { - if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f) != 0) { - func_80AD9A54(this, globalCtx); - } - this->actor.scale.z = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.x; - } - } - if (this->unk_19A == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD2); - } -} - -void func_80ADB17C(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_19A++; - if (this->unk_19A == 64) { - Flags_SetSwitch(globalCtx, this->actor.params); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_FLAME_IGNITION); - if (this->unk_194 == 0) { - Flags_UnsetSwitch(globalCtx, 0x1B); - } - globalCtx->envCtx.unk_BF = 0xFF; - func_80078884(NA_SE_SY_CORRECT_CHIME); - Actor_Kill(&this->actor); - } else if (this->unk_19A < 32) { - func_80AD9240(this, this->unk_19A, &this->actor.world.pos); - } else { - func_80AD9240(this, 64 - this->unk_19A, &this->actor.world.pos); - } - if (this->unk_19A == 32) { - this->actor.world.pos.x = D_80ADD7A4[this->unk_194].x; - this->actor.world.pos.y = D_80ADD7A4[this->unk_194].y; - this->actor.world.pos.z = D_80ADD7A4[this->unk_194].z; - } -} - -void func_80ADB2B8(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->actor.xzDistToPlayer < 130.0f) { - func_80AD9DF0(this, globalCtx); - } - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_CRY); - } - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; -} - -void func_80ADB338(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - EnPoSisters* realMeg = (EnPoSisters*)this->actor.parent; - - if (this->unk_195 == 0) { - if (Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos) < 600.0f) { - if (this->unk_19C != 0) { - this->unk_19C--; - } - } else { - this->unk_19C = 100; - } - if (this->unk_19C == 0) { - this->actor.shape.rot.y = (s32)(4.0f * Rand_ZeroOne()) * 0x4000 + this->actor.yawTowardsPlayer; - this->actor.world.pos.y = player->actor.world.pos.y + 5.0f; - func_80AD98F4(this, globalCtx); - } - } else { - if (realMeg->actionFunc == func_80ADB51C) { - this->actor.draw = EnPoSisters_Draw; - func_80AD9E60(this); - } else if (realMeg->actionFunc == func_80ADAE6C) { - this->actor.shape.rot.y = this->actor.parent->shape.rot.y + this->unk_195 * 0x4000; - this->actor.world.pos.y = player->actor.world.pos.y + 5.0f; - func_80AD98F4(this, globalCtx); - } else if (realMeg->actionFunc == func_80ADAFC0) { - Actor_Kill(&this->actor); - } - } -} - -void func_80ADB4B0(EnPoSisters* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - func_80AD9E60(this); - } - func_80AD97C8(this, globalCtx); - this->actor.world.pos.y += 1.0f; - Actor_SetFocus(&this->actor, 40.0f); -} - -void func_80ADB51C(EnPoSisters* this, GlobalContext* globalCtx) { - f32 temp_f2; - s16 phi_v0; - s16 phi_a2; - u8 temp; - - SkelAnime_Update(&this->skelAnime); - temp_f2 = this->skelAnime.endFrame * 0.5f; - this->unk_22E.a = (fabsf(temp_f2 - this->skelAnime.curFrame) * 255.0f) / temp_f2; - if (this->unk_19A != 0) { - this->unk_19A -= 1; - } - if (this->unk_19A == 0) { - this->actor.world.rot.y = this->actor.shape.rot.y += 0x4000 * (s32)(Rand_ZeroOne() * 4.0f); - if (this->unk_195 == 0) { - func_800F5ACC(NA_BGM_MINI_BOSS); - } - func_80AD9F1C(this); - } else { - this->actor.world.pos.y += 0.1f; - temp = this->unk_195; - if (temp != 0) { - if (this->unk_19A > 90) { - phi_v0 = 1; - phi_a2 = 64; - } else if (this->unk_19A > 70) { - phi_v0 = 0; - phi_a2 = 64; - } else if (this->unk_19A > 55) { - phi_v0 = 1; - phi_a2 = 96; - } else if (this->unk_19A > 40) { - phi_v0 = 0; - phi_a2 = 96; - } else { - phi_v0 = 1; - phi_a2 = 256; - } - if (this->unk_195 == 2) { - phi_a2 *= 2; - } - Math_ScaledStepToS(&this->actor.shape.rot.y, - this->actor.parent->shape.rot.y + (this->unk_195 * 0x4000) * phi_v0, phi_a2); - } else if (this->unk_19A == 70 || this->unk_19A == 40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); - } - } - func_80AD97C8(this, globalCtx); - Actor_SetFocus(&this->actor, 40.0f); -} - -void func_80ADB770(EnPoSisters* this, GlobalContext* globalCtx) { - s32 temp_v0; - s32 phi_a0; - - if (this->unk_19A != 0) { - this->unk_19A--; - } - if (this->unk_19C > 0) { - if (this->unk_19A >= 16) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_195 == 0) { - if (ABS((s16)(16 - this->unk_196)) < 14) { - this->actor.shape.rot.y += - (0x580 - (this->unk_19C * 0x180)) * fabsf(Math_SinS(this->unk_196 * 0x800)); - } - if (this->unk_19A >= 284 || this->unk_19A < 31) { - this->unk_199 |= 0x40; - } else { - this->unk_199 &= ~0x40; - } - } else { - this->actor.shape.rot.y = (s16)(this->actor.parent->shape.rot.y + (this->unk_195 * 0x4000)); - } - } - } - if (this->unk_195 == 0) { - if (this->unk_19A >= 284 || (this->unk_19A < 31 && this->unk_19A >= 16)) { - this->unk_199 |= 0x40; - } else { - this->unk_199 &= ~0x40; - } - } - if (Actor_WorldDistXZToPoint(&GET_PLAYER(globalCtx)->actor, &this->actor.home.pos) > 600.0f) { - this->unk_199 &= ~0x40; - func_80AD9C24(this, globalCtx); - } else if (this->unk_19A == 0) { - if (this->unk_195 == 0) { - func_80AD94E0(this); - } else { - func_80AD9C24(this, globalCtx); - } - } else if (this->unk_195 != 0) { - EnPoSisters* realMeg = (EnPoSisters*)this->actor.parent; - - if (realMeg->actionFunc == func_80ADAAA4) { - func_80AD95D8(this); - } - } else if (this->unk_19C == 0) { - this->unk_19C = -15; - } else if (this->unk_19C < 0) { - this->unk_19C++; - if (this->unk_19C == 0) { - func_80AD94E0(this); - } - } - func_80AD97C8(this, globalCtx); -} - -void func_80ADB9F0(EnPoSisters* this, GlobalContext* globalCtx) { - f32 div; - - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_22E.a = 255; - if (this->unk_194 == 3) { - this->actor.flags |= ACTOR_FLAG_0; - this->actor.home.pos.x = 1992.0f; - this->actor.home.pos.z = -1440.0f; - this->unk_199 |= 0x18; - func_80AD93C4(this); - } else { - func_80AD9F90(this); - } - } else { - div = this->skelAnime.curFrame / this->skelAnime.endFrame; - this->unk_22E.a = 255.0f * div; - } - if (this->unk_194 != 3 && Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - } - Actor_SetFocus(&this->actor, 40.0f); -} - -void func_80ADBB6C(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 10.0f) { - func_80ADA028(this); - } else { - Math_ScaledStepToS(&this->actor.world.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), - 1820); - } -} - -void func_80ADBBF4(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1820); - if (this->actor.xzDistToPlayer < 240.0f && fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f) { - func_80AD93C4(this); - } -} - -void func_80ADBC88(EnPoSisters* this, GlobalContext* globalCtx) { - if (D_80ADD784 != 0 || !Player_InCsMode(globalCtx)) { - if (this->unk_19A != 0) { - this->unk_19A--; - } - if (this->unk_19A == 30) { - if (this->unk_194 == 0) { - OnePointCutscene_Init(globalCtx, 3140, 999, NULL, MAIN_CAM); - } - D_80ADD784 = 1; - } - if (this->unk_19A == 0) { - func_80ADA10C(this); - } - } - func_8002F974(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); -} - -void func_80ADBD38(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_19A++; - func_80AD9240(this, this->unk_19A, &this->actor.home.pos); - if (this->unk_19A == 32) { - func_80ADA1B8(this); - } -} - -void func_80ADBD8C(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_19A--; - if (this->unk_19A == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - this->unk_199 &= ~0x80; - } - if (this->unk_19A <= 0) { - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_22E.a = 255; - D_80ADD784 |= (1 << this->unk_194); - } else { - this->unk_22E.a = (this->skelAnime.curFrame * 255.0f) / this->skelAnime.endFrame; - } - } - if (D_80ADD784 == 15) { - func_80ADA25C(this); - } -} - -void func_80ADBEE8(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_19A != 0) { - this->unk_19A--; - } - func_80AD9240(this, this->unk_19A, &this->actor.home.pos); - if (this->unk_19A == 0) { - func_80ADA2BC(this, globalCtx); - } -} - -void func_80ADBF58(EnPoSisters* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - this->unk_19A--; - Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 0x500); - if (this->unk_19A == 0 && this->unk_194 == 0) { - globalCtx->envCtx.unk_BF = 4; - } - if (this->unk_19A < 0) { - Math_StepToF(&this->actor.speedXZ, 5.0f, 0.2f); - } - if (this->unk_19A == -70 && this->unk_194 == 1) { - Audio_PlaySoundAtPosition(globalCtx, &D_80ADD7BC, 40, NA_SE_EN_PO_LAUGH); - } - if (this->unk_19A < -120) { - Actor_Kill(&this->actor); - } -} - -void func_80ADC034(EnPoSisters* this, GlobalContext* globalCtx) { - if (this->actor.isTargeted && this->unk_22E.a == 255) { - if (this->unk_197 != 0) { - this->unk_197--; - } - } else { - this->unk_197 = 20; - } - if (this->unk_22E.a == 0) { - if (this->unk_19C != 0) { - this->unk_19C--; - } - } - if (this->actionFunc != func_80ADA7F0 && this->actionFunc != func_80ADA8C0 && this->actionFunc != func_80ADAAA4) { - if (this->unk_197 == 0) { - func_80AD9718(this); - } else if (this->unk_19C == 0 && this->unk_22E.a == 0) { - func_80AD98F4(this, globalCtx); - } - } -} - -void func_80ADC10C(EnPoSisters* this, GlobalContext* globalCtx) { - Vec3f sp24; - - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if (this->unk_195 != 0) { - ((EnPoSisters*)this->actor.parent)->unk_19C--; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); - func_80AD9C24(this, globalCtx); - if (Rand_ZeroOne() < 0.2f) { - sp24.x = this->actor.world.pos.x; - sp24.y = this->actor.world.pos.y; - sp24.z = this->actor.world.pos.z; - Item_DropCollectible(globalCtx, &sp24, ITEM00_ARROWS_SMALL); - } - } else if (this->collider.base.colType == 9 || - (this->actor.colChkInfo.damageEffect == 0 && this->actor.colChkInfo.damage == 0)) { - if (this->unk_194 == 0) { - this->actor.freezeTimer = 0; - } - } else if (this->actor.colChkInfo.damageEffect == 0xF) { - this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_199 |= 2; - func_80AD98F4(this, globalCtx); - } else if (this->unk_194 == 0 && this->actor.colChkInfo.damageEffect == 0xE && - this->actionFunc == func_80ADB770) { - if (this->unk_19C == 0) { - this->unk_19C = -45; - } - } else { - if (Actor_ApplyDamage(&this->actor) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); - } else { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_SISTER_DEAD); - } - func_80AD95D8(this); - } - } -} - -void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnPoSisters* this = (EnPoSisters*)thisx; - s16 temp; - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - func_80AD9568(this); - } - func_80ADC10C(this, globalCtx); - if (this->unk_199 & 4) { - func_80ADC034(this, globalCtx); - } - this->actionFunc(this, globalCtx); - if (this->unk_199 & 0x1F) { - if (this->unk_199 & 8) { - func_80ADA35C(this, globalCtx); - } - Actor_MoveForward(&this->actor); - - if (this->unk_199 & 0x10) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); - } else { - Vec3f vec; - s32 sp34; - - vec.x = this->actor.world.pos.x; - vec.y = this->actor.world.pos.y + 10.0f; - vec.z = this->actor.world.pos.z; - this->actor.floorHeight = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &sp34, &this->actor, &vec); - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->actionFunc == func_80ADA8C0 || this->actionFunc == func_80ADA7F0) { - this->unk_198++; - this->unk_198 = CLAMP_MAX(this->unk_198, 8); - } else if (this->actionFunc != func_80ADAFC0) { - temp = this->unk_198 - 1; - this->unk_198 = CLAMP_MIN(temp, 1); - } - if (this->actionFunc == func_80ADA8C0) { - this->actor.flags |= ACTOR_FLAG_24; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->unk_199 & 1) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - if (this->actionFunc != func_80ADB338) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - Actor_SetFocus(&this->actor, 40.0f); - if (this->actionFunc == func_80ADAC70) { - this->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - } else if (this->unk_199 & 2) { - this->actor.shape.rot.y = this->actor.world.rot.y; - } - } -} - -void func_80ADC55C(EnPoSisters* this) { - s16 temp_var; - - if (this->skelAnime.animation == &gPoeSistersAttackAnim) { - this->unk_22E.r = CLAMP_MAX((s16)(this->unk_22E.r + 5), 255); - this->unk_22E.g = CLAMP_MIN((s16)(this->unk_22E.g - 5), 50); - temp_var = this->unk_22E.b - 5; - this->unk_22E.b = CLAMP_MIN(temp_var, 0); - } else if (this->skelAnime.animation == &gPoeSistersFleeAnim) { - this->unk_22E.r = CLAMP_MAX((s16)(this->unk_22E.r + 5), 80); - this->unk_22E.g = CLAMP_MAX((s16)(this->unk_22E.g + 5), 255); - temp_var = this->unk_22E.b + 5; - this->unk_22E.b = CLAMP_MAX(temp_var, 225); - } else if (this->skelAnime.animation == &gPoeSistersDamagedAnim) { - if (this->actor.colorFilterTimer & 2) { - this->unk_22E.r = 0; - this->unk_22E.g = 0; - this->unk_22E.b = 0; - } else { - this->unk_22E.r = 80; - this->unk_22E.g = 255; - this->unk_22E.b = 225; - } - } else { - this->unk_22E.r = CLAMP_MAX((s16)(this->unk_22E.r + 5), 255); - this->unk_22E.g = CLAMP_MAX((s16)(this->unk_22E.g + 5), 255); - if (this->unk_22E.b > 210) { - temp_var = this->unk_22E.b - 5; - this->unk_22E.b = CLAMP_MIN(temp_var, 210); - } else { - temp_var = this->unk_22E.b + 5; - this->unk_22E.b = CLAMP_MAX(temp_var, 210); - } - } -} - -s32 EnPoSisters_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx, Gfx** gfxP) { - EnPoSisters* this = (EnPoSisters*)thisx; - Color_RGBA8* color; - - if (limbIndex == 1 && (this->unk_199 & 0x40)) { - if (this->unk_19A >= 284) { - rot->x += (this->unk_19A * 0x1000) + 0xFFEE4000; - } else { - rot->x += (this->unk_19A * 0x1000) + 0xFFFF1000; - } - } - if (this->unk_22E.a == 0 || limbIndex == 8 || (this->actionFunc == func_80ADAFC0 && this->unk_19A >= 8)) { - *dList = NULL; - } else if (limbIndex == 9) { - *dList = D_80ADD7C8[this->unk_194]; - } else if (limbIndex == 10) { - *dList = D_80ADD7D8[this->unk_194]; - gDPPipeSync((*gfxP)++); - gDPSetEnvColor((*gfxP)++, this->unk_22E.r, this->unk_22E.g, this->unk_22E.b, this->unk_22E.a); - } else if (limbIndex == 11) { - color = &D_80ADD7E8[this->unk_194]; - gDPPipeSync((*gfxP)++); - gDPSetEnvColor((*gfxP)++, color->r, color->g, color->b, this->unk_22E.a); - } - return false; -} - -void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, - Gfx** gfxP) { - EnPoSisters* this = (EnPoSisters*)thisx; - s32 i; - s32 pad; - - if (this->actionFunc == func_80ADAFC0 && this->unk_19A >= 8 && limbIndex == 9) { - gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 2876), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfxP)++, gPoSistersBurnDL); - } - if (limbIndex == 8 && this->actionFunc != func_80ADB2B8) { - if (this->unk_199 & 0x20) { - for (i = this->unk_198 - 1; i > 0; i--) { - this->unk_234[i] = this->unk_234[i - 1]; - } - Matrix_MultVec3f(&D_80ADD7F8, &this->unk_234[0]); - } else if (this->actionFunc == func_80ADBD8C) { - Matrix_MultVec3f(&D_80ADD7F8, &this->actor.home.pos); - } - if (this->unk_198 > 0) { - Color_RGBA8* color = &D_80ADD6F0[this->unk_194]; - f32 temp_f2 = Rand_ZeroOne() * 0.3f + 0.7f; - - if (this->actionFunc == func_80ADB17C || this->actionFunc == func_80ADBD38 || - this->actionFunc == func_80ADBEE8) { - Lights_PointNoGlowSetInfo(&this->lightInfo, this->unk_234[0].x, this->unk_234[0].y + 15.0f, - this->unk_234[0].z, color->r * temp_f2, color->g * temp_f2, - color->b * temp_f2, 200); - } else { - Lights_PointGlowSetInfo(&this->lightInfo, this->unk_234[0].x, this->unk_234[0].y + 15.0f, - this->unk_234[0].z, color->r * temp_f2, color->g * temp_f2, color->b * temp_f2, - 200); - } - } else { - Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); - } - if (!(this->unk_199 & 0x80)) { - Matrix_Get(&this->unk_2F8); - } - } -} - -void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnPoSisters* this = (EnPoSisters*)thisx; - u8 phi_s5; - f32 phi_f20; - s32 i; - u8 spE7 = 0; - Color_RGBA8* temp_s1 = &D_80ADD700[this->unk_194]; - Color_RGBA8* temp_s7 = &D_80ADD6F0[this->unk_194]; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 2989); - func_80ADC55C(this); - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - if (this->unk_22E.a == 255 || this->unk_22E.a == 0) { - gDPSetEnvColor(POLY_OPA_DISP++, this->unk_22E.r, this->unk_22E.g, this->unk_22E.b, this->unk_22E.a); - gSPSegment(POLY_OPA_DISP++, 0x09, D_80116280 + 2); - POLY_OPA_DISP = - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_22E.a); - gSPSegment(POLY_XLU_DISP++, 0x09, D_80116280); - POLY_XLU_DISP = - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_XLU_DISP); - } - if (!(this->unk_199 & 0x80)) { - Matrix_Put(&this->unk_2F8); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 3034), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gPoSistersTorchDL); - } - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (globalCtx->gameplayFrames * -20) % 512, 0x20, 0x80)); - gDPSetEnvColor(POLY_XLU_DISP++, temp_s1->r, temp_s1->g, temp_s1->b, temp_s1->a); - if (this->actionFunc == func_80ADB17C) { - if (this->unk_19A < 32) { - phi_s5 = ((32 - this->unk_19A) * 255) / 32; - phi_f20 = 0.0056000003f; - } else { - phi_s5 = (this->unk_19A * 255 - 8160) / 32; - phi_f20 = 0.0027f; - } - } else if (this->actionFunc == func_80ADBD38) { - phi_s5 = ((32 - this->unk_19A) * 255) / 32; - phi_f20 = 0.0027f; - } else if (this->actionFunc == func_80ADBEE8) { - phi_s5 = ((32 - this->unk_19A) * 255) / 32; - phi_f20 = 0.0035f; - } else if (this->actionFunc == func_80ADBC88) { - //! @bug uninitialised spE7 - phi_s5 = spE7; - phi_f20 = 0.0027f; - } else { - phi_s5 = spE7; - phi_f20 = this->actor.scale.x * 0.5f; - } - for (i = 0; i < this->unk_198; i++) { - if (this->actionFunc != func_80ADB17C && this->actionFunc != func_80ADBD38 && - this->actionFunc != func_80ADBEE8) { - phi_s5 = -i * 31 + 248; - } - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); - Matrix_Translate(this->unk_234[i].x, this->unk_234[i].y, this->unk_234[i].z, MTXMODE_NEW); - Matrix_RotateZYX(0, (s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000), 0, MTXMODE_APPLY); - if (this->actionFunc == func_80ADAFC0) { - phi_f20 = (this->unk_19A - i) * 0.025f + 0.5f; - phi_f20 = CLAMP(phi_f20, 0.5f, 0.8f) * 0.007f; - } - Matrix_Scale(phi_f20, phi_f20, phi_f20, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 3132), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 3139); -} diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp new file mode 100644 index 000000000..d9e6f06a4 --- /dev/null +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp @@ -0,0 +1,1436 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_PO_SISTERS_Z_EN_PO_SISTERS_C +#include "actor_common.h" +/* + * File: z_en_po_sisters.c + * Overlay: ovl_En_Po_Sisters + * Description: Forest Temple Four Poe Sisters + */ + +#include "z_en_po_sisters.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_po_sisters/object_po_sisters.h" +#include "def/code_8006BA00.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9 | ACTOR_FLAG_12 | ACTOR_FLAG_14) + +void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx); +void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx); +void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80ADA094(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADA4A8(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADA530(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADA6A0(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADA7F0(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADA8C0(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADA9E8(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADAAA4(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADAC70(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADAD54(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADAE6C(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADAFC0(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB17C(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB2B8(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB338(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB9F0(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB4B0(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB51C(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADB770(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBB6C(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBBF4(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBC88(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBD38(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBD8C(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBEE8(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80ADBF58(EnPoSisters* pthis, GlobalContext* globalCtx); + +void func_80AD9AA8(EnPoSisters* pthis, GlobalContext* globalCtx); +void func_80AD9C24(EnPoSisters* pthis, GlobalContext* globalCtx); + +void func_80AD9D44(EnPoSisters* pthis); + +static Color_RGBA8 D_80ADD6F0[4] = { + { 255, 170, 255, 255 }, + { 255, 200, 0, 255 }, + { 0, 170, 255, 255 }, + { 170, 255, 0, 255 }, +}; + +static Color_RGBA8 D_80ADD700[4] = { + { 100, 0, 255, 255 }, + { 255, 0, 0, 255 }, + { 0, 0, 255, 255 }, + { 0, 150, 0, 255 }, +}; + +ActorInit En_Po_Sisters_InitVars = { + ACTOR_EN_PO_SISTERS, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_PO_SISTERS, + sizeof(EnPoSisters), + (ActorFunc)EnPoSisters_Init, + (ActorFunc)EnPoSisters_Destroy, + (ActorFunc)EnPoSisters_Update, + (ActorFunc)EnPoSisters_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x4FC7FFEA, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 18, 60, 15, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 10, 25, 60, 40 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0xF), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0xE), + /* Master sword */ DMG_ENTRY(2, 0xE), + /* Giant's Knife */ DMG_ENTRY(4, 0xE), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xE), + /* Giant spin */ DMG_ENTRY(4, 0xE), + /* Master spin */ DMG_ENTRY(2, 0xE), + /* Kokiri jump */ DMG_ENTRY(2, 0xE), + /* Giant jump */ DMG_ENTRY(8, 0xE), + /* Master jump */ DMG_ENTRY(4, 0xE), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static s32 D_80ADD784 = 0; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 7, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_STOP), +}; + +static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; + +static s16 D_80ADD79C[4] = { 0xB000, 0xD000, 0x5000, 0x3000 }; + +static Vec3s D_80ADD7A4[4] = { + { -22, 337, -1704 }, + { -431, 879, -3410 }, + { 549, 879, -3410 }, + { 1717, 515, -1340 }, +}; + +static Vec3f D_80ADD7BC = { 120.0f, 250.0f, -1420.0f }; + +static Gfx* D_80ADD7C8[4] = { + gPoeSistersMegBodyDL, + gPoeSistersJoelleBodyDL, + gPoeSistersBethBodyDL, + gPoeSistersAmyBodyDL, +}; + +static Gfx* D_80ADD7D8[4] = { + gPoeSistersMegFaceDL, + gPoeSistersJoelleFaceDL, + gPoeSistersBethFaceDL, + gPoSistersAmyFaceDL, +}; + +static Color_RGBA8 D_80ADD7E8[4] = { + { 80, 0, 100, 0 }, + { 80, 15, 0, 0 }, + { 0, 70, 50, 0 }, + { 70, 70, 0, 0 }, +}; + +static Vec3f D_80ADD7F8 = { 1000.0f, -1700.0f, 0.0f }; + +void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPoSisters* pthis = (EnPoSisters*)thisx; + s32 pad; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gPoeSistersSkel, &gPoeSistersSwayAnim, pthis->jointTable, + pthis->morphTable, 12); + pthis->unk_22E.r = 255; + pthis->unk_22E.g = 255; + pthis->unk_22E.b = 210; + pthis->unk_22E.a = 255; + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, 0, + 0, 0, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->unk_194 = (thisx->params >> 8) & 3; + pthis->actor.naviEnemyId = pthis->unk_194 + 0x50; + if (1) {} + pthis->unk_195 = (thisx->params >> 0xA) & 3; + pthis->unk_196 = 32; + pthis->unk_197 = 20; + pthis->unk_198 = 1; + pthis->unk_199 = 32; + pthis->unk_294 = 110.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->actor.params & 0x1000) { + func_80ADA094(pthis, globalCtx); + } else if (pthis->unk_194 == 0) { + if (pthis->unk_195 == 0) { + pthis->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_PLAYER; + func_80AD9AA8(pthis, globalCtx); + } else { + pthis->actor.flags &= ~(ACTOR_FLAG_9 | ACTOR_FLAG_14); + pthis->collider.info.elemType = ELEMTYPE_UNK4; + pthis->collider.info.bumper.dmgFlags |= 1; + pthis->collider.base.ocFlags1 = OC1_NONE; + func_80AD9C24(pthis, NULL); + } + } else { + func_80AD9D44(pthis); + } + pthis->actor.params &= 0x3F; +} + +void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoSisters* pthis = (EnPoSisters*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + if (pthis->unk_194 == 0 && pthis->unk_195 == 0) { + func_800F5B58(); + } + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AD9240(EnPoSisters* pthis, s32 arg1, Vec3f* arg2) { + f32 temp_f20 = SQ(arg1) * 0.1f; + Vec3f* vec; + s32 i; + + for (i = 0; i < pthis->unk_198; i++) { + vec = &pthis->unk_234[i]; + vec->x = arg2->x + Math_SinS((s16)(pthis->actor.shape.rot.y + (pthis->unk_19A * 0x800) + i * 0x2000)) * temp_f20; + vec->z = arg2->z + Math_CosS((s16)(pthis->actor.shape.rot.y + (pthis->unk_19A * 0x800) + i * 0x2000)) * temp_f20; + vec->y = arg2->y + arg1; + } +} + +void func_80AD9368(EnPoSisters* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersSwayAnim, -3.0f); + pthis->unk_19A = Rand_S16Offset(2, 3); + pthis->actionFunc = func_80ADA4A8; + pthis->actor.speedXZ = 0.0f; +} + +void func_80AD93C4(EnPoSisters* pthis) { + if (pthis->actionFunc != func_80ADA6A0) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersFloatAnim, -3.0f); + } + pthis->unk_19A = Rand_S16Offset(0xF, 3); + pthis->unk_199 |= 7; + pthis->actionFunc = func_80ADA530; +} + +void func_80AD943C(EnPoSisters* pthis) { + pthis->actionFunc = func_80ADA6A0; +} + +void func_80AD944C(EnPoSisters* pthis) { + if (pthis->unk_22E.a != 0) { + pthis->collider.base.colType = COLTYPE_METAL; + pthis->collider.base.acFlags |= AC_HARD; + } + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersAttackAnim, -5.0f); + pthis->actor.speedXZ = 0.0f; + pthis->unk_19A = Animation_GetLastFrame(&gPoeSistersAttackAnim) * 3 + 3; + pthis->unk_199 &= ~2; + pthis->actionFunc = func_80ADA7F0; +} + +void func_80AD94E0(EnPoSisters* pthis) { + pthis->actor.speedXZ = 5.0f; + if (pthis->unk_194 == 0) { + pthis->collider.base.colType = COLTYPE_METAL; + pthis->collider.base.acFlags |= AC_HARD; + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersAttackAnim, -5.0f); + } + pthis->unk_19A = 5; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->unk_199 |= 8; + pthis->actionFunc = func_80ADA8C0; +} + +void func_80AD9568(EnPoSisters* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersFloatAnim, -3.0f); + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + 0x8000; + if (pthis->unk_194 != 0) { + pthis->collider.base.colType = COLTYPE_HIT3; + pthis->collider.base.acFlags &= ~AC_HARD; + } + pthis->actionFunc = func_80ADA9E8; +} + +void func_80AD95D8(EnPoSisters* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPoeSistersDamagedAnim, -3.0f); + if (pthis->collider.base.ac != NULL) { + pthis->actor.world.rot.y = (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) + ? pthis->collider.base.ac->world.rot.y + : Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; + } + if (pthis->unk_194 != 0) { + pthis->actor.speedXZ = 10.0f; + } + pthis->unk_199 &= ~0xB; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0x10); + pthis->actionFunc = func_80ADAAA4; +} + +void func_80AD96A4(EnPoSisters* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersFleeAnim, -3.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x8000; + pthis->unk_19A = 5; + pthis->unk_199 |= 0xB; + pthis->actor.speedXZ = 5.0f; + pthis->actionFunc = func_80ADAC70; +} + +void func_80AD9718(EnPoSisters* pthis) { + Animation_Change(&pthis->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, + Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE, -3.0f); + pthis->actor.speedXZ = 0.0f; + pthis->unk_19C = 100; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->unk_199 &= ~5; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DISAPPEAR); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH2); + pthis->actionFunc = func_80ADAD54; +} + +void func_80AD97C8(EnPoSisters* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp20; + + if (pthis->unk_195 == 0 || pthis->actionFunc != func_80ADAAA4) { + if ((player->swordState == 0 || player->swordAnimation >= 24) && + player->actor.world.pos.y - player->actor.floorHeight < 1.0f) { + Math_StepToF(&pthis->unk_294, 110.0f, 3.0f); + } else { + Math_StepToF(&pthis->unk_294, 170.0f, 10.0f); + } + sp20 = pthis->unk_294; + } else if (pthis->unk_195 != 0) { + sp20 = pthis->actor.parent->xzDistToPlayer; + } + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.shape.rot.y + 0x8000) * sp20) + player->actor.world.pos.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.shape.rot.y + 0x8000) * sp20) + player->actor.world.pos.z; +} + +void func_80AD98F4(EnPoSisters* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, + Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE, -3.0f); + if (pthis->unk_194 == 0) { + pthis->unk_294 = 110.0f; + func_80AD97C8(pthis, globalCtx); + pthis->unk_22E.a = 0; + pthis->actor.draw = EnPoSisters_Draw; + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } + pthis->unk_19A = 15; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + pthis->unk_199 &= ~1; + pthis->actionFunc = func_80ADAE6C; +} + +void func_80AD99D4(EnPoSisters* pthis, GlobalContext* globalCtx) { + pthis->unk_19A = 0; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.pos.y += 42.0f; + pthis->actor.shape.yOffset = -6000.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_199 = 0; + pthis->actionFunc = func_80ADAFC0; + OnePointCutscene_Init(globalCtx, 3190, 999, &pthis->actor, MAIN_CAM); +} + +void func_80AD9A54(EnPoSisters* pthis, GlobalContext* globalCtx) { + pthis->unk_19A = 0; + pthis->actor.world.pos.y = pthis->unk_234[0].y; + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x80); + pthis->actionFunc = func_80ADB17C; +} + +// Meg spawning fakes +void func_80AD9AA8(EnPoSisters* pthis, GlobalContext* globalCtx) { + Actor* actor1 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0x400); + Actor* actor2 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0x800); + Actor* actor3 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0xC00); + s32 pad; + s32 pad1; + + if (actor1 == NULL || actor2 == NULL || actor3 == NULL) { + if (actor1 != NULL) { + Actor_Kill(actor1); + } + if (actor2 != NULL) { + Actor_Kill(actor2); + } + if (actor3 != NULL) { + Actor_Kill(actor3); + } + Actor_Kill(&pthis->actor); + } else { + actor3->parent = &pthis->actor; + actor2->parent = &pthis->actor; + actor1->parent = &pthis->actor; + Animation_PlayLoop(&pthis->skelAnime, &gPoeSistersMegCryAnim); + pthis->unk_198 = 0; + pthis->unk_199 = 160; + pthis->actionFunc = func_80ADB2B8; + } +} + +void func_80AD9C24(EnPoSisters* pthis, GlobalContext* globalCtx) { + Vec3f vec; + + pthis->actor.draw = NULL; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_19C = 100; + pthis->unk_199 = 32; + pthis->collider.base.colType = COLTYPE_HIT3; + pthis->collider.base.acFlags &= ~AC_HARD; + if (globalCtx != NULL) { + vec.x = pthis->actor.world.pos.x; + vec.y = pthis->actor.world.pos.y + 45.0f; + vec.z = pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &vec, &sZeroVector, &sZeroVector, 150, 0, 255, 255, 255, 155, 150, 150, 150, 1, + 9, 0); + } + Lights_PointSetColorAndRadius(&pthis->lightInfo, 0, 0, 0, 0); + pthis->actionFunc = func_80ADB338; +} + +void func_80AD9D44(EnPoSisters* pthis) { + if (pthis->unk_194 == 3) { + Animation_PlayOnce(&pthis->skelAnime, &gPoeSistersAppearDisappearAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + } else { + Animation_Change(&pthis->skelAnime, &gPoeSistersAppearDisappearAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE_INTERP, 0.0f); + } + pthis->unk_22E.a = 0; + pthis->unk_199 = 32; + pthis->actionFunc = func_80ADB9F0; +} + +void func_80AD9DF0(EnPoSisters* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPoeSistersAppearDisappearAnim, -5.0f); + pthis->unk_198 = 1; + pthis->unk_199 &= ~0x80; + pthis->actionFunc = func_80ADB4B0; + OnePointCutscene_Init(globalCtx, 3180, 156, &pthis->actor, MAIN_CAM); +} + +void func_80AD9E60(EnPoSisters* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersFloatAnim, -3.0f); + pthis->unk_19A = Animation_GetLastFrame(&gPoeSistersFloatAnim) * 7 + 7; + if (pthis->actor.parent != NULL) { + pthis->actor.world.pos = pthis->actor.parent->world.pos; + pthis->actor.shape.rot.y = pthis->actor.parent->shape.rot.y; + } else { + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->unk_19A++; + } + if (pthis->unk_195 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH2); + } + pthis->actionFunc = func_80ADB51C; +} + +void func_80AD9F1C(EnPoSisters* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersFloatAnim, -3.0f); + pthis->unk_22E.a = 255; + pthis->unk_19A = 300; + pthis->unk_19C = 3; + pthis->unk_199 |= 9; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = func_80ADB770; +} + +void func_80AD9F90(EnPoSisters* pthis) { + if (pthis->unk_194 == 1) { + pthis->actor.home.pos.x = -632.0f; + pthis->actor.home.pos.z = -3440.0f; + } else { + pthis->actor.home.pos.x = 752.0f; + pthis->actor.home.pos.z = -3440.0f; + } + Animation_PlayLoop(&pthis->skelAnime, &gPoeSistersFloatAnim); + pthis->unk_199 |= 0xA; + pthis->actionFunc = func_80ADBB6C; + pthis->actor.speedXZ = 5.0f; +} + +void func_80ADA028(EnPoSisters* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersSwayAnim, -3.0f); + pthis->unk_22E.a = 255; + pthis->unk_199 |= 0x15; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = func_80ADBBF4; + pthis->actor.speedXZ = 0.0f; +} + +void func_80ADA094(EnPoSisters* pthis, GlobalContext* globalCtx) { + D_80ADD784 = 0; + pthis->unk_22E.a = 0; + pthis->unk_199 = 128; + pthis->unk_19A = 50; + pthis->unk_234[0] = pthis->actor.home.pos; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + pthis->actionFunc = func_80ADBC88; +} + +void func_80ADA10C(EnPoSisters* pthis) { + s32 i; + + pthis->unk_198 = ARRAY_COUNT(pthis->unk_234); + for (i = 0; i < ARRAY_COUNT(pthis->unk_234); i++) { + pthis->unk_234[i] = pthis->unk_234[0]; + } + pthis->actionFunc = func_80ADBD38; +} + +void func_80ADA1B8(EnPoSisters* pthis) { + Animation_Change(&pthis->skelAnime, &gPoeSistersAppearDisappearAnim, 0.833f, 0.0f, + Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim), ANIMMODE_ONCE_INTERP, 0.0f); + if (pthis->unk_194 == 0 || pthis->unk_194 == 1) { + pthis->unk_19A = 40; + } else { + pthis->unk_19A = 76; + } + pthis->unk_198 = 0; + D_80ADD784 = 0; + pthis->actionFunc = func_80ADBD8C; +} + +void func_80ADA25C(EnPoSisters* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gPoeSistersSwayAnim); + pthis->unk_198 = 8; + pthis->unk_19A = 32; + func_80AD9240(pthis, pthis->unk_19A, &pthis->actor.home.pos); + pthis->actionFunc = func_80ADBEE8; +} + +void func_80ADA2BC(EnPoSisters* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeSistersFloatAnim, -3.0f); + pthis->unk_198 = 0; + pthis->unk_199 = 40; + pthis->unk_19A = 90; + pthis->unk_196 = 32; + pthis->actor.world.rot.y = D_80ADD79C[pthis->unk_194]; + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + if (pthis->unk_194 == 0) { + Flags_SetSwitch(globalCtx, 0x1B); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FLAME_IGNITION); + pthis->actionFunc = func_80ADBF58; +} + +void func_80ADA35C(EnPoSisters* pthis, GlobalContext* globalCtx) { + f32 targetY; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actionFunc == func_80ADBF58) { + targetY = pthis->actor.home.pos.y; + } else if (pthis->unk_194 == 0 || pthis->unk_194 == 3) { + targetY = player->actor.world.pos.y + 5.0f; + } else { + targetY = 832.0f; + } + Math_ApproachF(&pthis->actor.world.pos.y, targetY, 0.5f, 3.0f); + if (!pthis->unk_196) { + pthis->unk_196 = 32; + } + if (pthis->unk_196 != 0) { + pthis->unk_196--; + } + pthis->actor.world.pos.y += (2.0f + 0.5f * Rand_ZeroOne()) * Math_SinS(pthis->unk_196 * 0x800); + if (pthis->unk_22E.a == 255 && pthis->actionFunc != func_80ADA8C0 && pthis->actionFunc != func_80ADA7F0) { + if (pthis->actionFunc == func_80ADAC70) { + func_8002F974(&pthis->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); + } else { + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } + } +} + +void func_80ADA4A8(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->unk_19A != 0) { + pthis->unk_19A--; + } + if (pthis->unk_19A == 0 || pthis->actor.xzDistToPlayer < 200.0f) { + func_80AD93C4(pthis); + } +} + +void func_80ADA530(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.speedXZ, 1.0f, 0.2f); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->unk_19A != 0) { + pthis->unk_19A--; + } + if (pthis->actor.xzDistToPlayer < 200.0f && fabsf(pthis->actor.yDistToPlayer + 5.0f) < 30.0f) { + func_80AD943C(pthis); + } else if (pthis->unk_19A == 0 && Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.2f) != 0) { + func_80AD9368(pthis); + } + if (pthis->actor.bgCheckFlags & 8) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), + 0x71C); + } else if (Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) > 300.0f) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), + 0x71C); + } +} + +void func_80ADA6A0(EnPoSisters* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v0; + + SkelAnime_Update(&pthis->skelAnime); + temp_v0 = pthis->actor.yawTowardsPlayer - player->actor.shape.rot.y; + Math_StepToF(&pthis->actor.speedXZ, 2.0f, 0.2f); + if (temp_v0 > 0x3000) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x3000, 0x71C); + } else if (temp_v0 < -0x3000) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer - 0x3000, 0x71C); + } else { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0x71C); + } + if (pthis->actor.xzDistToPlayer < 160.0f && fabsf(pthis->actor.yDistToPlayer + 5.0f) < 30.0f) { + func_80AD944C(pthis); + } else if (pthis->actor.xzDistToPlayer > 240.0f) { + func_80AD93C4(pthis); + } +} + +void func_80ADA7F0(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_19A != 0) { + pthis->unk_19A--; + } + pthis->actor.shape.rot.y += 384.0f * ((pthis->skelAnime.endFrame + 1.0f) * 3.0f - pthis->unk_19A); + if (pthis->unk_19A == 18 || pthis->unk_19A == 7) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_ROLL); + } + if (pthis->unk_19A == 0) { + func_80AD94E0(pthis); + } +} + +void func_80ADA8C0(EnPoSisters* pthis, GlobalContext* globalCtx) { + s32 pad; + + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->unk_19A != 0) { + pthis->unk_19A--; + } + pthis->actor.shape.rot.y += (384.0f * pthis->skelAnime.endFrame) * 3.0f; + if (pthis->unk_19A == 0 && ABS((s16)(pthis->actor.shape.rot.y - pthis->actor.world.rot.y)) < 0x1000) { + if (pthis->unk_194 != 0) { + pthis->collider.base.colType = COLTYPE_HIT3; + pthis->collider.base.acFlags &= ~AC_HARD; + func_80AD93C4(pthis); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH2); + func_80AD9C24(pthis, globalCtx); + } + } + if (Animation_OnFrame(&pthis->skelAnime, 1.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_ROLL); + } +} + +void func_80ADA9E8(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.shape.rot.y -= (pthis->actor.speedXZ * 10.0f) * 128.0f; + if (Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.1f) != 0) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->unk_194 != 0) { + func_80AD93C4(pthis); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH2); + func_80AD9C24(pthis, globalCtx); + } + } +} + +void func_80ADAAA4(EnPoSisters* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) && !(pthis->actor.flags & ACTOR_FLAG_15)) { + if (pthis->actor.colChkInfo.health != 0) { + if (pthis->unk_194 != 0) { + func_80AD96A4(pthis); + } else if (pthis->unk_195 != 0) { + func_80AD9C24(pthis, NULL); + } else { + func_80AD9C24(pthis, globalCtx); + } + } else { + func_80AD99D4(pthis, globalCtx); + } + } + if (pthis->unk_195 != 0) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.parent->shape.rot.y, + (pthis->unk_195 == 2) ? 0x800 : 0x400); + pthis->unk_22E.a = ((pthis->skelAnime.endFrame - pthis->skelAnime.curFrame) * 255.0f) / pthis->skelAnime.endFrame; + pthis->actor.world.pos.y = pthis->actor.parent->world.pos.y; + func_80AD97C8(pthis, globalCtx); + } else if (pthis->unk_194 != 0) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + } +} + +void func_80ADAC70(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 1820); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->unk_19A != 0) { + pthis->unk_19A--; + } + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->unk_199 |= 2; + func_80AD9718(pthis); + } else if (pthis->unk_19A == 0 && 240.0f < pthis->actor.xzDistToPlayer) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80AD93C4(pthis); + } +} + +void func_80ADAD54(EnPoSisters* pthis, GlobalContext* globalCtx) { + s32 endFrame; + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_22E.a = 0; + pthis->collider.info.bumper.dmgFlags = 0x00060001; + func_80AD93C4(pthis); + } else { + endFrame = pthis->skelAnime.endFrame; + pthis->unk_22E.a = ((endFrame - pthis->skelAnime.curFrame) * 255.0f) / endFrame; + } +} + +void func_80ADAE6C(EnPoSisters* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_22E.a = 255; + if (pthis->unk_194 != 0) { + pthis->unk_199 |= 1; + pthis->collider.info.bumper.dmgFlags = 0x4FC7FFEA; + if (pthis->unk_19A != 0) { + pthis->unk_19A--; + } + if (pthis->unk_19A == 0) { + pthis->unk_197 = 20; + func_80AD93C4(pthis); + } + } else { + func_80AD9F1C(pthis); + } + } else { + pthis->unk_22E.a = (pthis->skelAnime.curFrame * 255.0f) / pthis->skelAnime.endFrame; + if (pthis->unk_194 == 0) { + func_80AD97C8(pthis, globalCtx); + } + } +} + +void func_80ADAFC0(EnPoSisters* pthis, GlobalContext* globalCtx) { + s32 i; + + pthis->unk_19A++; + pthis->unk_198 = CLAMP_MAX(pthis->unk_198 + 1, 8); + for (i = pthis->unk_198 - 1; i > 0; i--) { + pthis->unk_234[i] = pthis->unk_234[i - 1]; + } + pthis->unk_234[0].x = + (Math_SinS((pthis->actor.shape.rot.y + pthis->unk_19A * 0x3000) - 0x4000) * (3000.0f * pthis->actor.scale.x)) + + pthis->actor.world.pos.x; + pthis->unk_234[0].z = + (Math_CosS((pthis->actor.shape.rot.y + pthis->unk_19A * 0x3000) - 0x4000) * (3000.0f * pthis->actor.scale.x)) + + pthis->actor.world.pos.z; + if (pthis->unk_19A < 8) { + pthis->unk_234[0].y = pthis->unk_234[1].y - 9.0f; + } else { + pthis->unk_234[0].y = pthis->unk_234[1].y + 2.0f; + if (pthis->unk_19A >= 16) { + if (Math_StepToF(&pthis->actor.scale.x, 0.0f, 0.001f) != 0) { + func_80AD9A54(pthis, globalCtx); + } + pthis->actor.scale.z = pthis->actor.scale.x; + pthis->actor.scale.y = pthis->actor.scale.x; + } + } + if (pthis->unk_19A == 16) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DEAD2); + } +} + +void func_80ADB17C(EnPoSisters* pthis, GlobalContext* globalCtx) { + pthis->unk_19A++; + if (pthis->unk_19A == 64) { + Flags_SetSwitch(globalCtx, pthis->actor.params); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 30, NA_SE_EV_FLAME_IGNITION); + if (pthis->unk_194 == 0) { + Flags_UnsetSwitch(globalCtx, 0x1B); + } + globalCtx->envCtx.unk_BF = 0xFF; + func_80078884(NA_SE_SY_CORRECT_CHIME); + Actor_Kill(&pthis->actor); + } else if (pthis->unk_19A < 32) { + func_80AD9240(pthis, pthis->unk_19A, &pthis->actor.world.pos); + } else { + func_80AD9240(pthis, 64 - pthis->unk_19A, &pthis->actor.world.pos); + } + if (pthis->unk_19A == 32) { + pthis->actor.world.pos.x = D_80ADD7A4[pthis->unk_194].x; + pthis->actor.world.pos.y = D_80ADD7A4[pthis->unk_194].y; + pthis->actor.world.pos.z = D_80ADD7A4[pthis->unk_194].z; + } +} + +void func_80ADB2B8(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.xzDistToPlayer < 130.0f) { + func_80AD9DF0(pthis, globalCtx); + } + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_CRY); + } + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; +} + +void func_80ADB338(EnPoSisters* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnPoSisters* realMeg = (EnPoSisters*)pthis->actor.parent; + + if (pthis->unk_195 == 0) { + if (Actor_WorldDistXZToPoint(&player->actor, &pthis->actor.home.pos) < 600.0f) { + if (pthis->unk_19C != 0) { + pthis->unk_19C--; + } + } else { + pthis->unk_19C = 100; + } + if (pthis->unk_19C == 0) { + pthis->actor.shape.rot.y = (s32)(4.0f * Rand_ZeroOne()) * 0x4000 + pthis->actor.yawTowardsPlayer; + pthis->actor.world.pos.y = player->actor.world.pos.y + 5.0f; + func_80AD98F4(pthis, globalCtx); + } + } else { + if (realMeg->actionFunc == func_80ADB51C) { + pthis->actor.draw = EnPoSisters_Draw; + func_80AD9E60(pthis); + } else if (realMeg->actionFunc == func_80ADAE6C) { + pthis->actor.shape.rot.y = pthis->actor.parent->shape.rot.y + pthis->unk_195 * 0x4000; + pthis->actor.world.pos.y = player->actor.world.pos.y + 5.0f; + func_80AD98F4(pthis, globalCtx); + } else if (realMeg->actionFunc == func_80ADAFC0) { + Actor_Kill(&pthis->actor); + } + } +} + +void func_80ADB4B0(EnPoSisters* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + func_80AD9E60(pthis); + } + func_80AD97C8(pthis, globalCtx); + pthis->actor.world.pos.y += 1.0f; + Actor_SetFocus(&pthis->actor, 40.0f); +} + +void func_80ADB51C(EnPoSisters* pthis, GlobalContext* globalCtx) { + f32 temp_f2; + s16 phi_v0; + s16 phi_a2; + u8 temp; + + SkelAnime_Update(&pthis->skelAnime); + temp_f2 = pthis->skelAnime.endFrame * 0.5f; + pthis->unk_22E.a = (fabsf(temp_f2 - pthis->skelAnime.curFrame) * 255.0f) / temp_f2; + if (pthis->unk_19A != 0) { + pthis->unk_19A -= 1; + } + if (pthis->unk_19A == 0) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y += 0x4000 * (s32)(Rand_ZeroOne() * 4.0f); + if (pthis->unk_195 == 0) { + func_800F5ACC(NA_BGM_MINI_BOSS); + } + func_80AD9F1C(pthis); + } else { + pthis->actor.world.pos.y += 0.1f; + temp = pthis->unk_195; + if (temp != 0) { + if (pthis->unk_19A > 90) { + phi_v0 = 1; + phi_a2 = 64; + } else if (pthis->unk_19A > 70) { + phi_v0 = 0; + phi_a2 = 64; + } else if (pthis->unk_19A > 55) { + phi_v0 = 1; + phi_a2 = 96; + } else if (pthis->unk_19A > 40) { + phi_v0 = 0; + phi_a2 = 96; + } else { + phi_v0 = 1; + phi_a2 = 256; + } + if (pthis->unk_195 == 2) { + phi_a2 *= 2; + } + Math_ScaledStepToS(&pthis->actor.shape.rot.y, + pthis->actor.parent->shape.rot.y + (pthis->unk_195 * 0x4000) * phi_v0, phi_a2); + } else if (pthis->unk_19A == 70 || pthis->unk_19A == 40) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH2); + } + } + func_80AD97C8(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 40.0f); +} + +void func_80ADB770(EnPoSisters* pthis, GlobalContext* globalCtx) { + s32 temp_v0; + s32 phi_a0; + + if (pthis->unk_19A != 0) { + pthis->unk_19A--; + } + if (pthis->unk_19C > 0) { + if (pthis->unk_19A >= 16) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_195 == 0) { + if (ABS((s16)(16 - pthis->unk_196)) < 14) { + pthis->actor.shape.rot.y += + (0x580 - (pthis->unk_19C * 0x180)) * fabsf(Math_SinS(pthis->unk_196 * 0x800)); + } + if (pthis->unk_19A >= 284 || pthis->unk_19A < 31) { + pthis->unk_199 |= 0x40; + } else { + pthis->unk_199 &= ~0x40; + } + } else { + pthis->actor.shape.rot.y = (s16)(pthis->actor.parent->shape.rot.y + (pthis->unk_195 * 0x4000)); + } + } + } + if (pthis->unk_195 == 0) { + if (pthis->unk_19A >= 284 || (pthis->unk_19A < 31 && pthis->unk_19A >= 16)) { + pthis->unk_199 |= 0x40; + } else { + pthis->unk_199 &= ~0x40; + } + } + if (Actor_WorldDistXZToPoint(&GET_PLAYER(globalCtx)->actor, &pthis->actor.home.pos) > 600.0f) { + pthis->unk_199 &= ~0x40; + func_80AD9C24(pthis, globalCtx); + } else if (pthis->unk_19A == 0) { + if (pthis->unk_195 == 0) { + func_80AD94E0(pthis); + } else { + func_80AD9C24(pthis, globalCtx); + } + } else if (pthis->unk_195 != 0) { + EnPoSisters* realMeg = (EnPoSisters*)pthis->actor.parent; + + if (realMeg->actionFunc == func_80ADAAA4) { + func_80AD95D8(pthis); + } + } else if (pthis->unk_19C == 0) { + pthis->unk_19C = -15; + } else if (pthis->unk_19C < 0) { + pthis->unk_19C++; + if (pthis->unk_19C == 0) { + func_80AD94E0(pthis); + } + } + func_80AD97C8(pthis, globalCtx); +} + +void func_80ADB9F0(EnPoSisters* pthis, GlobalContext* globalCtx) { + f32 div; + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_22E.a = 255; + if (pthis->unk_194 == 3) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.home.pos.x = 1992.0f; + pthis->actor.home.pos.z = -1440.0f; + pthis->unk_199 |= 0x18; + func_80AD93C4(pthis); + } else { + func_80AD9F90(pthis); + } + } else { + div = pthis->skelAnime.curFrame / pthis->skelAnime.endFrame; + pthis->unk_22E.a = 255.0f * div; + } + if (pthis->unk_194 != 3 && Animation_OnFrame(&pthis->skelAnime, 1.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + } + Actor_SetFocus(&pthis->actor, 40.0f); +} + +void func_80ADBB6C(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) < 10.0f) { + func_80ADA028(pthis); + } else { + Math_ScaledStepToS(&pthis->actor.world.rot.y, Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos), + 1820); + } +} + +void func_80ADBBF4(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1820); + if (pthis->actor.xzDistToPlayer < 240.0f && fabsf(pthis->actor.yDistToPlayer + 5.0f) < 30.0f) { + func_80AD93C4(pthis); + } +} + +void func_80ADBC88(EnPoSisters* pthis, GlobalContext* globalCtx) { + if (D_80ADD784 != 0 || !Player_InCsMode(globalCtx)) { + if (pthis->unk_19A != 0) { + pthis->unk_19A--; + } + if (pthis->unk_19A == 30) { + if (pthis->unk_194 == 0) { + OnePointCutscene_Init(globalCtx, 3140, 999, NULL, MAIN_CAM); + } + D_80ADD784 = 1; + } + if (pthis->unk_19A == 0) { + func_80ADA10C(pthis); + } + } + func_8002F974(&pthis->actor, NA_SE_EV_TORCH - SFX_FLAG); +} + +void func_80ADBD38(EnPoSisters* pthis, GlobalContext* globalCtx) { + pthis->unk_19A++; + func_80AD9240(pthis, pthis->unk_19A, &pthis->actor.home.pos); + if (pthis->unk_19A == 32) { + func_80ADA1B8(pthis); + } +} + +void func_80ADBD8C(EnPoSisters* pthis, GlobalContext* globalCtx) { + pthis->unk_19A--; + if (pthis->unk_19A == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + pthis->unk_199 &= ~0x80; + } + if (pthis->unk_19A <= 0) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_22E.a = 255; + D_80ADD784 |= (1 << pthis->unk_194); + } else { + pthis->unk_22E.a = (pthis->skelAnime.curFrame * 255.0f) / pthis->skelAnime.endFrame; + } + } + if (D_80ADD784 == 15) { + func_80ADA25C(pthis); + } +} + +void func_80ADBEE8(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_19A != 0) { + pthis->unk_19A--; + } + func_80AD9240(pthis, pthis->unk_19A, &pthis->actor.home.pos); + if (pthis->unk_19A == 0) { + func_80ADA2BC(pthis, globalCtx); + } +} + +void func_80ADBF58(EnPoSisters* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + pthis->unk_19A--; + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 0x500); + if (pthis->unk_19A == 0 && pthis->unk_194 == 0) { + globalCtx->envCtx.unk_BF = 4; + } + if (pthis->unk_19A < 0) { + Math_StepToF(&pthis->actor.speedXZ, 5.0f, 0.2f); + } + if (pthis->unk_19A == -70 && pthis->unk_194 == 1) { + Audio_PlaySoundAtPosition(globalCtx, &D_80ADD7BC, 40, NA_SE_EN_PO_LAUGH); + } + if (pthis->unk_19A < -120) { + Actor_Kill(&pthis->actor); + } +} + +void func_80ADC034(EnPoSisters* pthis, GlobalContext* globalCtx) { + if (pthis->actor.isTargeted && pthis->unk_22E.a == 255) { + if (pthis->unk_197 != 0) { + pthis->unk_197--; + } + } else { + pthis->unk_197 = 20; + } + if (pthis->unk_22E.a == 0) { + if (pthis->unk_19C != 0) { + pthis->unk_19C--; + } + } + if (pthis->actionFunc != func_80ADA7F0 && pthis->actionFunc != func_80ADA8C0 && pthis->actionFunc != func_80ADAAA4) { + if (pthis->unk_197 == 0) { + func_80AD9718(pthis); + } else if (pthis->unk_19C == 0 && pthis->unk_22E.a == 0) { + func_80AD98F4(pthis, globalCtx); + } + } +} + +void func_80ADC10C(EnPoSisters* pthis, GlobalContext* globalCtx) { + Vec3f sp24; + + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if (pthis->unk_195 != 0) { + ((EnPoSisters*)pthis->actor.parent)->unk_19C--; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH2); + func_80AD9C24(pthis, globalCtx); + if (Rand_ZeroOne() < 0.2f) { + sp24.x = pthis->actor.world.pos.x; + sp24.y = pthis->actor.world.pos.y; + sp24.z = pthis->actor.world.pos.z; + Item_DropCollectible(globalCtx, &sp24, ITEM00_ARROWS_SMALL); + } + } else if (pthis->collider.base.colType == 9 || + (pthis->actor.colChkInfo.damageEffect == 0 && pthis->actor.colChkInfo.damage == 0)) { + if (pthis->unk_194 == 0) { + pthis->actor.freezeTimer = 0; + } + } else if (pthis->actor.colChkInfo.damageEffect == 0xF) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->unk_199 |= 2; + func_80AD98F4(pthis, globalCtx); + } else if (pthis->unk_194 == 0 && pthis->actor.colChkInfo.damageEffect == 0xE && + pthis->actionFunc == func_80ADB770) { + if (pthis->unk_19C == 0) { + pthis->unk_19C = -45; + } + } else { + if (Actor_ApplyDamage(&pthis->actor) != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DAMAGE); + } else { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_SISTER_DEAD); + } + func_80AD95D8(pthis); + } + } +} + +void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPoSisters* pthis = (EnPoSisters*)thisx; + s16 temp; + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + func_80AD9568(pthis); + } + func_80ADC10C(pthis, globalCtx); + if (pthis->unk_199 & 4) { + func_80ADC034(pthis, globalCtx); + } + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_199 & 0x1F) { + if (pthis->unk_199 & 8) { + func_80ADA35C(pthis, globalCtx); + } + Actor_MoveForward(&pthis->actor); + + if (pthis->unk_199 & 0x10) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 0.0f, 5); + } else { + Vec3f vec; + s32 sp34; + + vec.x = pthis->actor.world.pos.x; + vec.y = pthis->actor.world.pos.y + 10.0f; + vec.z = pthis->actor.world.pos.z; + pthis->actor.floorHeight = + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &sp34, &pthis->actor, &vec); + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + if (pthis->actionFunc == func_80ADA8C0 || pthis->actionFunc == func_80ADA7F0) { + pthis->unk_198++; + pthis->unk_198 = CLAMP_MAX(pthis->unk_198, 8); + } else if (pthis->actionFunc != func_80ADAFC0) { + temp = pthis->unk_198 - 1; + pthis->unk_198 = CLAMP_MIN(temp, 1); + } + if (pthis->actionFunc == func_80ADA8C0) { + pthis->actor.flags |= ACTOR_FLAG_24; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->unk_199 & 1) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + if (pthis->actionFunc != func_80ADB338) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + Actor_SetFocus(&pthis->actor, 40.0f); + if (pthis->actionFunc == func_80ADAC70) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + } else if (pthis->unk_199 & 2) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + } +} + +void func_80ADC55C(EnPoSisters* pthis) { + s16 temp_var; + + if (pthis->skelAnime.animation == &gPoeSistersAttackAnim) { + pthis->unk_22E.r = CLAMP_MAX((s16)(pthis->unk_22E.r + 5), 255); + pthis->unk_22E.g = CLAMP_MIN((s16)(pthis->unk_22E.g - 5), 50); + temp_var = pthis->unk_22E.b - 5; + pthis->unk_22E.b = CLAMP_MIN(temp_var, 0); + } else if (pthis->skelAnime.animation == &gPoeSistersFleeAnim) { + pthis->unk_22E.r = CLAMP_MAX((s16)(pthis->unk_22E.r + 5), 80); + pthis->unk_22E.g = CLAMP_MAX((s16)(pthis->unk_22E.g + 5), 255); + temp_var = pthis->unk_22E.b + 5; + pthis->unk_22E.b = CLAMP_MAX(temp_var, 225); + } else if (pthis->skelAnime.animation == &gPoeSistersDamagedAnim) { + if (pthis->actor.colorFilterTimer & 2) { + pthis->unk_22E.r = 0; + pthis->unk_22E.g = 0; + pthis->unk_22E.b = 0; + } else { + pthis->unk_22E.r = 80; + pthis->unk_22E.g = 255; + pthis->unk_22E.b = 225; + } + } else { + pthis->unk_22E.r = CLAMP_MAX((s16)(pthis->unk_22E.r + 5), 255); + pthis->unk_22E.g = CLAMP_MAX((s16)(pthis->unk_22E.g + 5), 255); + if (pthis->unk_22E.b > 210) { + temp_var = pthis->unk_22E.b - 5; + pthis->unk_22E.b = CLAMP_MIN(temp_var, 210); + } else { + temp_var = pthis->unk_22E.b + 5; + pthis->unk_22E.b = CLAMP_MAX(temp_var, 210); + } + } +} + +s32 EnPoSisters_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx, Gfx** gfxP) { + EnPoSisters* pthis = (EnPoSisters*)thisx; + Color_RGBA8* color; + + if (limbIndex == 1 && (pthis->unk_199 & 0x40)) { + if (pthis->unk_19A >= 284) { + rot->x += (pthis->unk_19A * 0x1000) + 0xFFEE4000; + } else { + rot->x += (pthis->unk_19A * 0x1000) + 0xFFFF1000; + } + } + if (pthis->unk_22E.a == 0 || limbIndex == 8 || (pthis->actionFunc == func_80ADAFC0 && pthis->unk_19A >= 8)) { + *dList = NULL; + } else if (limbIndex == 9) { + *dList = D_80ADD7C8[pthis->unk_194]; + } else if (limbIndex == 10) { + *dList = D_80ADD7D8[pthis->unk_194]; + gDPPipeSync((*gfxP)++); + gDPSetEnvColor((*gfxP)++, pthis->unk_22E.r, pthis->unk_22E.g, pthis->unk_22E.b, pthis->unk_22E.a); + } else if (limbIndex == 11) { + color = &D_80ADD7E8[pthis->unk_194]; + gDPPipeSync((*gfxP)++); + gDPSetEnvColor((*gfxP)++, color->r, color->g, color->b, pthis->unk_22E.a); + } + return false; +} + +void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, + Gfx** gfxP) { + EnPoSisters* pthis = (EnPoSisters*)thisx; + s32 i; + s32 pad; + + if (pthis->actionFunc == func_80ADAFC0 && pthis->unk_19A >= 8 && limbIndex == 9) { + gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 2876), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfxP)++, gPoSistersBurnDL); + } + if (limbIndex == 8 && pthis->actionFunc != func_80ADB2B8) { + if (pthis->unk_199 & 0x20) { + for (i = pthis->unk_198 - 1; i > 0; i--) { + pthis->unk_234[i] = pthis->unk_234[i - 1]; + } + Matrix_MultVec3f(&D_80ADD7F8, &pthis->unk_234[0]); + } else if (pthis->actionFunc == func_80ADBD8C) { + Matrix_MultVec3f(&D_80ADD7F8, &pthis->actor.home.pos); + } + if (pthis->unk_198 > 0) { + Color_RGBA8* color = &D_80ADD6F0[pthis->unk_194]; + f32 temp_f2 = Rand_ZeroOne() * 0.3f + 0.7f; + + if (pthis->actionFunc == func_80ADB17C || pthis->actionFunc == func_80ADBD38 || + pthis->actionFunc == func_80ADBEE8) { + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->unk_234[0].x, pthis->unk_234[0].y + 15.0f, + pthis->unk_234[0].z, color->r * temp_f2, color->g * temp_f2, + color->b * temp_f2, 200); + } else { + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->unk_234[0].x, pthis->unk_234[0].y + 15.0f, + pthis->unk_234[0].z, color->r * temp_f2, color->g * temp_f2, color->b * temp_f2, + 200); + } + } else { + Lights_PointSetColorAndRadius(&pthis->lightInfo, 0, 0, 0, 0); + } + if (!(pthis->unk_199 & 0x80)) { + Matrix_Get(&pthis->unk_2F8); + } + } +} + +void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPoSisters* pthis = (EnPoSisters*)thisx; + u8 phi_s5; + f32 phi_f20; + s32 i; + u8 spE7 = 0; + Color_RGBA8* temp_s1 = &D_80ADD700[pthis->unk_194]; + Color_RGBA8* temp_s7 = &D_80ADD6F0[pthis->unk_194]; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 2989); + func_80ADC55C(pthis); + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + if (pthis->unk_22E.a == 255 || pthis->unk_22E.a == 0) { + gDPSetEnvColor(POLY_OPA_DISP++, pthis->unk_22E.r, pthis->unk_22E.g, pthis->unk_22E.b, pthis->unk_22E.a); + gSPSegment(POLY_OPA_DISP++, 0x09, D_80116280 + 2); + POLY_OPA_DISP = + SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &pthis->actor, POLY_OPA_DISP); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, pthis->unk_22E.a); + gSPSegment(POLY_XLU_DISP++, 0x09, D_80116280); + POLY_XLU_DISP = + SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &pthis->actor, POLY_XLU_DISP); + } + if (!(pthis->unk_199 & 0x80)) { + Matrix_Put(&pthis->unk_2F8); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 3034), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPoSistersTorchDL); + } + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + (globalCtx->gameplayFrames * -20) % 512, 0x20, 0x80)); + gDPSetEnvColor(POLY_XLU_DISP++, temp_s1->r, temp_s1->g, temp_s1->b, temp_s1->a); + if (pthis->actionFunc == func_80ADB17C) { + if (pthis->unk_19A < 32) { + phi_s5 = ((32 - pthis->unk_19A) * 255) / 32; + phi_f20 = 0.0056000003f; + } else { + phi_s5 = (pthis->unk_19A * 255 - 8160) / 32; + phi_f20 = 0.0027f; + } + } else if (pthis->actionFunc == func_80ADBD38) { + phi_s5 = ((32 - pthis->unk_19A) * 255) / 32; + phi_f20 = 0.0027f; + } else if (pthis->actionFunc == func_80ADBEE8) { + phi_s5 = ((32 - pthis->unk_19A) * 255) / 32; + phi_f20 = 0.0035f; + } else if (pthis->actionFunc == func_80ADBC88) { + //! @bug uninitialised spE7 + phi_s5 = spE7; + phi_f20 = 0.0027f; + } else { + phi_s5 = spE7; + phi_f20 = pthis->actor.scale.x * 0.5f; + } + for (i = 0; i < pthis->unk_198; i++) { + if (pthis->actionFunc != func_80ADB17C && pthis->actionFunc != func_80ADBD38 && + pthis->actionFunc != func_80ADBEE8) { + phi_s5 = -i * 31 + 248; + } + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); + Matrix_Translate(pthis->unk_234[i].x, pthis->unk_234[i].y, pthis->unk_234[i].z, MTXMODE_NEW); + Matrix_RotateZYX(0, (s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000), 0, MTXMODE_APPLY); + if (pthis->actionFunc == func_80ADAFC0) { + phi_f20 = (pthis->unk_19A - i) * 0.025f + 0.5f; + phi_f20 = CLAMP(phi_f20, 0.5f, 0.8f) * 0.007f; + } + Matrix_Scale(phi_f20, phi_f20, phi_f20, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 3132), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_po_sisters.c", 3139); +} diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c deleted file mode 100644 index 07fd6b90e..000000000 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ /dev/null @@ -1,1219 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_POH_Z_EN_POH_C -#include "actor_common.h" -/* - * File: z_en_poh.c - * Overlay: ovl_En_Poh - * Description: Graveyard Poe - */ - -#include "z_en_poh.h" -#include "objects/object_poh/object_poh.h" -#include "objects/object_po_composer/object_po_composer.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_lights.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_12) - -void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx); - -void EnPoh_UpdateLiving(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_UpdateDead(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_DrawRegular(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_DrawComposer(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_DrawSoul(Actor* thisx, GlobalContext* globalCtx); - -void func_80ADEAC4(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_Idle(EnPoh* this, GlobalContext* globalCtx); -void func_80ADEC9C(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_Attack(EnPoh* this, GlobalContext* globalCtx); -void func_80ADEECC(EnPoh* this, GlobalContext* globalCtx); -void func_80ADF894(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_ComposerAppear(EnPoh* this, GlobalContext* globalCtx); -void func_80ADEF38(EnPoh* this, GlobalContext* globalCtx); -void func_80ADF15C(EnPoh* this, GlobalContext* globalCtx); -void func_80ADF574(EnPoh* this, GlobalContext* globalCtx); -void func_80ADF5E0(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_Disappear(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_Appear(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_Death(EnPoh* this, GlobalContext* globalCtx); -void func_80ADFE28(EnPoh* this, GlobalContext* globalCtx); -void func_80ADFE80(EnPoh* this, GlobalContext* globalCtx); -void func_80AE009C(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_TalkRegular(EnPoh* this, GlobalContext* globalCtx); -void EnPoh_TalkComposer(EnPoh* this, GlobalContext* globalCtx); - -static s16 D_80AE1A50 = 0; - -const ActorInit En_Poh_InitVars = { - ACTOR_EN_POH, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnPoh), - (ActorFunc)EnPoh_Init, - (ActorFunc)EnPoh_Destroy, - (ActorFunc)EnPoh_Update, - NULL, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT3, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 40, 20, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit D_80AE1AA0[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 18, { { 0, 1400, 0 }, 10 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - D_80AE1AA0, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 4, 25, 50, 40 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(1, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static EnPohInfo sPoeInfo[2] = { - { - { 255, 170, 255 }, - { 100, 0, 150 }, - 18, - 5, - 248, - &gPoeDisappearAnim, - &gPoeFloatAnim, - &gPoeDamagedAnim, - &gPoeFleeAnim, - gPoeLanternDL, - gPoeBurnDL, - gPoeSoulDL, - }, - { - { 255, 255, 170 }, - { 0, 150, 0 }, - 9, - 1, - 244, - &gPoeComposerDisappearAnim, - &gPoeComposerFloatAnim, - &gPoeComposerDamagedAnim, - &gPoeComposerFleeAnim, - gPoeComposerLanternDL, - gPoeComposerBurnDL, - gPoeComposerSoulDL, - }, -}; - -static Color_RGBA8 D_80AE1B4C = { 75, 20, 25, 255 }; -static Color_RGBA8 D_80AE1B50 = { 80, 110, 90, 255 }; -static Color_RGBA8 D_80AE1B54 = { 90, 85, 50, 255 }; -static Color_RGBA8 D_80AE1B58 = { 100, 90, 100, 255 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), -}; - -static Vec3f D_80AE1B60 = { 0.0f, 3.0f, 0.0f }; -static Vec3f D_80AE1B6C = { 0.0f, 0.0f, 0.0f }; - -void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnItem00* collectible; - EnPoh* this = (EnPoh*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - Collider_InitJntSph(globalCtx, &this->colliderSph); - Collider_SetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInit, &this->colliderSphItem); - this->colliderSph.elements[0].dim.worldSphere.radius = 0; - this->colliderSph.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; - this->colliderSph.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; - this->colliderSph.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - Collider_InitCylinder(globalCtx, &this->colliderCyl); - Collider_SetCylinder(globalCtx, &this->colliderCyl, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->unk_194 = 0; - this->unk_195 = 32; - this->visibilityTimer = Rand_S16Offset(700, 300); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - 255, 255, 255, 0); - if (this->actor.params >= 4) { - this->actor.params = EN_POH_NORMAL; - } - if (this->actor.params == EN_POH_RUPEE) { - D_80AE1A50++; - if (D_80AE1A50 >= 3) { - Actor_Kill(&this->actor); - } else { - collectible = Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x4000 | ITEM00_RUPEE_BLUE); - if (collectible != NULL) { - collectible->actor.speedXZ = 0.0f; - } - } - } else if (this->actor.params == EN_POH_FLAT) { - if (Flags_GetSwitch(globalCtx, 0x28) || Flags_GetSwitch(globalCtx, 0x9)) { - Actor_Kill(&this->actor); - } else { - Flags_SetSwitch(globalCtx, 0x28); - } - } else if (this->actor.params == EN_POH_SHARP) { - if (Flags_GetSwitch(globalCtx, 0x29) || Flags_GetSwitch(globalCtx, 0x9)) { - Actor_Kill(&this->actor); - } else { - Flags_SetSwitch(globalCtx, 0x29); - } - } - if (this->actor.params < EN_POH_SHARP) { - this->objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_POH); - this->infoIdx = EN_POH_INFO_NORMAL; - this->actor.naviEnemyId = 0x44; - } else { - this->objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_PO_COMPOSER); - this->infoIdx = EN_POH_INFO_COMPOSER; - this->actor.naviEnemyId = 0x43; - } - this->info = &sPoeInfo[this->infoIdx]; - if (this->objectIdx < 0) { - Actor_Kill(&this->actor); - } -} - -void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyJntSph(globalCtx, &this->colliderSph); - Collider_DestroyCylinder(globalCtx, &this->colliderCyl); - if (this->actor.params == EN_POH_RUPEE) { - D_80AE1A50--; - } -} - -void func_80ADE114(EnPoh* this) { - Animation_PlayLoop(&this->skelAnime, this->info->idleAnim); - this->unk_198 = Rand_S16Offset(2, 3); - this->actionFunc = func_80ADEAC4; - this->actor.speedXZ = 0.0f; -} - -void EnPoh_SetupIdle(EnPoh* this) { - Animation_PlayLoop(&this->skelAnime, this->info->idleAnim2); - this->unk_198 = Rand_S16Offset(15, 3); - this->actionFunc = EnPoh_Idle; -} - -void func_80ADE1BC(EnPoh* this) { - Animation_PlayLoop(&this->skelAnime, this->info->idleAnim2); - this->actionFunc = func_80ADEC9C; - this->unk_198 = 0; - this->actor.speedXZ = 2.0f; -} - -void EnPoh_SetupAttack(EnPoh* this) { - if (this->infoIdx == EN_POH_INFO_NORMAL) { - Animation_MorphToLoop(&this->skelAnime, &gPoeAttackAnim, -6.0f); - } else { - Animation_PlayLoop(&this->skelAnime, &gPoeComposerAttackAnim); - } - this->unk_198 = 12; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - this->actionFunc = EnPoh_Attack; -} - -void func_80ADE28C(EnPoh* this) { - if (this->infoIdx == EN_POH_INFO_NORMAL) { - Animation_MorphToPlayOnce(&this->skelAnime, &gPoeDamagedAnim, -6.0f); - } else { - Animation_PlayOnce(&this->skelAnime, &gPoeComposerDamagedAnim); - } - if (this->colliderCyl.info.acHitInfo->toucher.dmgFlags & 0x0001F824) { - this->actor.world.rot.y = this->colliderCyl.base.ac->world.rot.y; - } else { - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, this->colliderCyl.base.ac) + 0x8000; - } - this->colliderCyl.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 5.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x10); - this->actionFunc = func_80ADEECC; -} - -void func_80ADE368(EnPoh* this) { - Animation_MorphToLoop(&this->skelAnime, this->info->fleeAnim, -5.0f); - this->actor.speedXZ = 5.0f; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; - this->colliderCyl.base.acFlags |= AC_ON; - this->unk_198 = 200; - this->actionFunc = func_80ADF894; -} - -void EnPoh_SetupInitialAction(EnPoh* this) { - this->lightColor.a = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->infoIdx == EN_POH_INFO_NORMAL) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gPoeAppearAnim, 0.0f); - this->actionFunc = func_80ADEF38; - } else { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gPoeComposerAppearAnim, 1.0f); - this->actor.world.pos.y = this->actor.home.pos.y + 20.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - this->actionFunc = EnPoh_ComposerAppear; - } -} - -void func_80ADE48C(EnPoh* this) { - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_198 = 0; - this->actor.naviEnemyId = 0xFF; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = func_80ADF15C; -} - -void func_80ADE4C8(EnPoh* this) { - Animation_PlayOnce(&this->skelAnime, this->info->idleAnim2); - this->actionFunc = func_80ADF574; - this->actor.speedXZ = -5.0f; -} - -void func_80ADE514(EnPoh* this) { - Animation_PlayLoop(&this->skelAnime, this->info->idleAnim); - this->unk_19C = this->actor.world.rot.y + 0x8000; - this->actionFunc = func_80ADF5E0; - this->actor.speedXZ = 0.0f; -} - -void EnPoh_SetupDisappear(EnPoh* this) { - this->unk_194 = 32; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - this->actionFunc = EnPoh_Disappear; -} - -void EnPoh_SetupAppear(EnPoh* this) { - this->unk_194 = 0; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - this->actionFunc = EnPoh_Appear; -} - -void EnPoh_SetupDeath(EnPoh* this, GlobalContext* globalCtx) { - this->actor.update = EnPoh_UpdateDead; - this->actor.draw = EnPoh_DrawSoul; - this->actor.shape.shadowDraw = NULL; - Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= ACTOR_FLAG_4; - this->actor.gravity = -1.0f; - this->actor.shape.yOffset = 1500.0f; - this->actor.world.pos.y -= 15.0f; - if (this->infoIdx != EN_POH_INFO_COMPOSER) { - this->actor.shape.rot.x = -0x8000; - } - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, 8); - this->unk_198 = 60; - this->actionFunc = EnPoh_Death; -} - -void func_80ADE6D4(EnPoh* this) { - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); - this->visibilityTimer = 0; - this->actor.shape.rot.y = 0; - this->lightColor.r = 0; - this->lightColor.a = 0; - this->actor.shape.yOffset = 0.0f; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - if (this->actor.params >= EN_POH_SHARP) { - this->lightColor.g = 200; - this->lightColor.b = 0; - } else { - this->lightColor.g = 0; - this->lightColor.b = 200; - } - this->actor.scale.x = 0.0f; - this->actor.scale.y = 0.0f; - this->actor.shape.rot.x = 0; - this->actor.home.pos.y = this->actor.world.pos.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); - this->actionFunc = func_80ADFE28; -} - -void EnPoh_Talk(EnPoh* this, GlobalContext* globalCtx) { - this->actor.home.pos.y = this->actor.world.pos.y; - Actor_SetFocus(&this->actor, -10.0f); - this->colliderCyl.dim.radius = 13; - this->colliderCyl.dim.height = 30; - this->colliderCyl.dim.yShift = 0; - this->colliderCyl.dim.pos.x = this->actor.world.pos.x; - this->colliderCyl.dim.pos.y = this->actor.world.pos.y - 20.0f; - this->colliderCyl.dim.pos.z = this->actor.world.pos.z; - this->colliderCyl.base.ocFlags1 = OC1_ON | OC1_TYPE_PLAYER; - if (this->actor.params == EN_POH_FLAT || this->actor.params == EN_POH_SHARP) { - if (CHECK_QUEST_ITEM(QUEST_SONG_SUN)) { - this->actor.textId = 0x5000; - } else if (!Flags_GetSwitch(globalCtx, 0xA) && !Flags_GetSwitch(globalCtx, 0xB)) { - this->actor.textId = 0x500F; - } else if ((this->actor.params == EN_POH_FLAT && Flags_GetSwitch(globalCtx, 0xA)) || - (this->actor.params == EN_POH_SHARP && Flags_GetSwitch(globalCtx, 0xB))) { - this->actor.textId = 0x5013; - } else { - this->actor.textId = 0x5012; - } - } else { - this->actor.textId = 0x5005; - } - this->unk_198 = 200; - this->unk_195 = 32; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = func_80ADFE80; -} - -void func_80ADE950(EnPoh* this, s32 arg1) { - if (arg1) { - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - } - this->actionFunc = func_80AE009C; -} - -void func_80ADE998(EnPoh* this) { - this->actionFunc = EnPoh_TalkRegular; - this->actor.home.pos.y = this->actor.world.pos.y - 15.0f; -} - -void func_80ADE9BC(EnPoh* this) { - this->actionFunc = EnPoh_TalkComposer; -} - -void EnPoh_MoveTowardsPlayerHeight(EnPoh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_StepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 1.0f); - this->actor.world.pos.y += 2.5f * Math_SinS(this->unk_195 * 0x800); - if (this->unk_195 != 0) { - this->unk_195 -= 1; - } - if (this->unk_195 == 0) { - this->unk_195 = 32; - } -} - -void func_80ADEA5C(EnPoh* this) { - if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 400.0f) { - this->unk_19C = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - } - Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_19C, 0x71C); -} - -void func_80ADEAC4(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->unk_198 != 0) { - this->unk_198--; - } - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - if (this->actor.xzDistToPlayer < 200.0f) { - func_80ADE1BC(this); - } else if (this->unk_198 == 0) { - EnPoh_SetupIdle(this); - } - if (this->lightColor.a == 255) { - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - } -} - -void EnPoh_Idle(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && this->unk_198 != 0) { - this->unk_198--; - } - func_80ADEA5C(this); - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - if (this->actor.xzDistToPlayer < 200.0f && this->unk_198 < 19) { - func_80ADE1BC(this); - } else if (this->unk_198 == 0) { - if (Rand_ZeroOne() < 0.1f) { - func_80ADE514(this); - } else { - func_80ADE114(this); - } - } - if (this->lightColor.a == 255) { - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - } -} - -void func_80ADEC9C(EnPoh* this, GlobalContext* globalCtx) { - Player* player; - s16 facingDiff; - - player = GET_PLAYER(globalCtx); - SkelAnime_Update(&this->skelAnime); - if (this->unk_198 != 0) { - this->unk_198--; - } - facingDiff = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; - if (facingDiff >= 0x3001) { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x3000, 0x71C); - } else if (facingDiff < -0x3000) { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x3000, 0x71C); - } else { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); - } - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - if (this->actor.xzDistToPlayer > 280.0f) { - EnPoh_SetupIdle(this); - } else if (this->unk_198 == 0 && this->actor.xzDistToPlayer < 140.0f && - !Player_IsFacingActor(&this->actor, 0x2AAA, globalCtx)) { - EnPoh_SetupAttack(this); - } - if (this->lightColor.a == 255) { - func_8002F974(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - } -} - -void EnPoh_Attack(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_KANTERA); - if (this->unk_198 != 0) { - this->unk_198--; - } - } - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - if (this->unk_198 >= 10) { - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xE38); - } else if (this->unk_198 == 9) { - this->actor.speedXZ = 5.0f; - this->skelAnime.playSpeed = 2.0f; - } else if (this->unk_198 == 0) { - EnPoh_SetupIdle(this); - this->unk_198 = 23; - } -} - -void func_80ADEECC(EnPoh* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.colChkInfo.health != 0) { - func_80ADE368(this); - } else { - func_80ADE48C(this); - } - } -} - -void func_80ADEF38(EnPoh* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->lightColor.a = 255; - this->visibilityTimer = Rand_S16Offset(700, 300); - this->actor.flags |= ACTOR_FLAG_0; - EnPoh_SetupIdle(this); - } else if (this->skelAnime.curFrame > 10.0f) { - this->lightColor.a = ((this->skelAnime.curFrame - 10.0f) * 0.05f) * 255.0f; - } - if (this->skelAnime.playSpeed < 0.5f && this->actor.xzDistToPlayer < 280.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_APPEAR); - this->skelAnime.playSpeed = 1.0f; - } -} - -void EnPoh_ComposerAppear(EnPoh* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->lightColor.a = 255; - this->visibilityTimer = Rand_S16Offset(700, 300); - this->actor.flags |= ACTOR_FLAG_0; - EnPoh_SetupIdle(this); - } else { - this->lightColor.a = CLAMP_MAX((s32)(this->skelAnime.curFrame * 25.5f), 255); - } -} - -void func_80ADF15C(EnPoh* this, GlobalContext* globalCtx) { - Vec3f vec; - f32 multiplier; - f32 newScale; - s32 pad; - s32 pad1; - - this->unk_198++; - if (this->unk_198 < 8) { - if (this->unk_198 < 5) { - vec.y = Math_SinS((this->unk_198 * 0x1000) - 0x4000) * 23.0f + (this->actor.world.pos.y + 40.0f); - multiplier = Math_CosS((this->unk_198 * 0x1000) - 0x4000) * 23.0f; - vec.x = Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier + - this->actor.world.pos.x; - vec.z = Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier + - this->actor.world.pos.z; - } else { - vec.y = (this->actor.world.pos.y + 40.0f) + (15.0f * (this->unk_198 - 5)); - vec.x = - Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + this->actor.world.pos.x; - vec.z = - Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + this->actor.world.pos.z; - } - EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AE1B60, &D_80AE1B6C, this->unk_198 * 10 + 80, 0, 255, 255, 255, 255, - 0, 0, 255, 1, 9, 1); - vec.x = (this->actor.world.pos.x + this->actor.world.pos.x) - vec.x; - vec.z = (this->actor.world.pos.z + this->actor.world.pos.z) - vec.z; - EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AE1B60, &D_80AE1B6C, this->unk_198 * 10 + 80, 0, 255, 255, 255, 255, - 0, 0, 255, 1, 9, 1); - vec.x = this->actor.world.pos.x; - vec.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AE1B60, &D_80AE1B6C, this->unk_198 * 10 + 80, 0, 255, 255, 255, 255, - 0, 0, 255, 1, 9, 1); - if (this->unk_198 == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EXTINCT); - } - } else if (this->unk_198 == 28) { - EnPoh_SetupDeath(this, globalCtx); - } else if (this->unk_198 >= 19) { - newScale = (28 - this->unk_198) * 0.001f; - this->actor.world.pos.y += 5.0f; - this->actor.scale.z = newScale; - this->actor.scale.y = newScale; - this->actor.scale.x = newScale; - } - if (this->unk_198 == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD2); - } -} - -void func_80ADF574(EnPoh* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.world.rot.y = this->actor.shape.rot.y; - EnPoh_SetupIdle(this); - this->unk_198 = 23; - } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - this->actor.shape.rot.y += 0x1000; - } -} - -void func_80ADF5E0(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_19C, 1820) != 0) { - EnPoh_SetupIdle(this); - } - if (this->actor.xzDistToPlayer < 200.0f) { - func_80ADE1BC(this); - } - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); -} - -void EnPoh_Disappear(EnPoh* this, GlobalContext* globalCtx) { - if (this->unk_194 != 0) { - this->unk_194--; - } - this->actor.world.rot.y += 0x1000; - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - this->lightColor.a = this->unk_194 * 7.96875f; - if (this->unk_194 == 0) { - this->visibilityTimer = Rand_S16Offset(100, 50); - EnPoh_SetupIdle(this); - } -} - -void EnPoh_Appear(EnPoh* this, GlobalContext* globalCtx) { - this->unk_194++; - this->actor.world.rot.y -= 0x1000; - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - this->lightColor.a = this->unk_194 * 7.96875f; - if (this->unk_194 == 32) { - this->visibilityTimer = Rand_S16Offset(700, 300); - this->unk_194 = 0; - EnPoh_SetupIdle(this); - } -} - -void func_80ADF894(EnPoh* this, GlobalContext* globalCtx) { - f32 multiplier; - - SkelAnime_Update(&this->skelAnime); - multiplier = Math_SinS(this->unk_195 * 0x800) * 3.0f; - this->actor.world.pos.x -= multiplier * Math_CosS(this->actor.shape.rot.y); - this->actor.world.pos.z += multiplier * Math_SinS(this->actor.shape.rot.y); - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0x71C); - EnPoh_MoveTowardsPlayerHeight(this, globalCtx); - if (this->unk_198 == 0 || this->actor.xzDistToPlayer > 250.0f) { - this->actor.world.rot.y = this->actor.shape.rot.y; - EnPoh_SetupIdle(this); - } - func_8002F974(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); -} - -void EnPoh_Death(EnPoh* this, GlobalContext* globalCtx) { - s32 objId; - - if (this->unk_198 != 0) { - this->unk_198--; - } - if (this->actor.bgCheckFlags & 1) { - objId = (this->infoIdx == EN_POH_INFO_COMPOSER) ? OBJECT_PO_COMPOSER : OBJECT_POH; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, objId, 10, - this->info->lanternDisplayList); - func_80ADE6D4(this); - } else if (this->unk_198 == 0) { - Actor_Kill(&this->actor); - return; - } - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); -} - -void func_80ADFA90(EnPoh* this, s32 arg1) { - f32 multiplier; - - this->lightColor.a = CLAMP(this->lightColor.a + arg1, 0, 255); - if (arg1 < 0) { - multiplier = this->lightColor.a * (1.0f / 255); - this->actor.scale.x = this->actor.scale.z = 0.0056000002f * multiplier + 0.0014000001f; - this->actor.scale.y = (0.007f - 0.007f * multiplier) + 0.007f; - } else { - multiplier = 1.0f; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = this->lightColor.a * (0.007f / 0xFF); - this->actor.world.pos.y = this->actor.home.pos.y + (1.0f / 17.0f) * this->lightColor.a; - } - this->lightColor.r = this->info->lightColor.r * multiplier; - this->lightColor.g = this->info->lightColor.g * multiplier; - this->lightColor.b = this->info->lightColor.b * multiplier; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->info->lightColor.r, this->info->lightColor.g, - this->info->lightColor.b, this->lightColor.a * (200.0f / 255)); -} - -void func_80ADFE28(EnPoh* this, GlobalContext* globalCtx) { - this->actor.home.pos.y += 2.0f; - func_80ADFA90(this, 20); - if (this->lightColor.a == 255) { - EnPoh_Talk(this, globalCtx); - } -} - -void func_80ADFE80(EnPoh* this, GlobalContext* globalCtx) { - if (this->unk_198 != 0) { - this->unk_198--; - } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if (this->actor.params >= EN_POH_SHARP) { - func_80ADE9BC(this); - } else { - func_80ADE998(this); - } - return; - } - if (this->unk_198 == 0) { - func_80ADE950(this, 1); - this->actor.flags &= ~ACTOR_FLAG_16; - return; - } - if (this->colliderCyl.base.ocFlags1 & OC1_HIT) { - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2F4(&this->actor, globalCtx); - } else { - this->actor.flags &= ~ACTOR_FLAG_16; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCyl.base); - } - this->actor.world.pos.y = Math_SinS(this->unk_195 * 0x800) * 5.0f + this->actor.home.pos.y; - if (this->unk_195 != 0) { - this->unk_195 -= 1; - } - if (this->unk_195 == 0) { - this->unk_195 = 32; - } - this->colliderCyl.dim.pos.y = this->actor.world.pos.y - 20.0f; - Actor_SetFocus(&this->actor, -10.0f); - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->info->lightColor.r, this->info->lightColor.g, - this->info->lightColor.b, this->lightColor.a * (200.0f / 255)); -} - -void func_80AE009C(EnPoh* this, GlobalContext* globalCtx) { - func_80ADFA90(this, -13); - if (this->lightColor.a == 0) { - Actor_Kill(&this->actor); - } -} - -void EnPoh_TalkRegular(EnPoh* this, GlobalContext* globalCtx) { - if (this->actor.textId != 0x5005) { - func_80ADFA90(this, -13); - } else { - func_8002F974(&this->actor, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - } - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { - if (Message_ShouldAdvance(globalCtx)) { - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - if (globalCtx->msgCtx.choiceIndex == 0) { - if (Inventory_HasEmptyBottle()) { - this->actor.textId = 0x5008; - Item_Give(globalCtx, ITEM_POE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_BIG_GET); - } else { - this->actor.textId = 0x5006; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - } - } else { - this->actor.textId = 0x5007; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80ADE950(this, 0); - } -} - -void EnPoh_TalkComposer(EnPoh* this, GlobalContext* globalCtx) { - func_8002F974(&this->actor, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { - if (!Flags_GetSwitch(globalCtx, 0xB) && !Flags_GetSwitch(globalCtx, 0xA)) { - this->actor.textId = 0x5010; - } else { - this->actor.textId = 0x5014; - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - } else { - if (this->actor.params == EN_POH_SHARP) { - Flags_SetSwitch(globalCtx, 0xB); - } else { - Flags_SetSwitch(globalCtx, 0xA); - } - func_80ADE950(this, 1); - } - } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - if (this->actor.textId == 0x5000) { - Flags_SetSwitch(globalCtx, 9); - } - func_80ADE950(this, 1); - } -} - -void func_80AE032C(EnPoh* this, GlobalContext* globalCtx) { - if (this->colliderCyl.base.acFlags & AC_HIT) { - this->colliderCyl.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != 0 || this->actor.colChkInfo.damage != 0) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); - } - func_80ADE28C(this); - } - } -} - -void EnPoh_UpdateVisibility(EnPoh* this) { - if (this->actionFunc != EnPoh_Appear && this->actionFunc != EnPoh_Disappear && this->actionFunc != func_80ADEF38 && - this->actionFunc != EnPoh_ComposerAppear) { - if (this->visibilityTimer != 0) { - this->visibilityTimer--; - } - if (this->lightColor.a == 255) { - if (this->actor.isTargeted) { - this->unk_194++; - this->unk_194 = CLAMP_MAX(this->unk_194, 20); - } else { - this->unk_194 = 0; - } - if ((this->unk_194 == 20 || this->visibilityTimer == 0) && - (this->actionFunc == func_80ADEAC4 || this->actionFunc == EnPoh_Idle || - this->actionFunc == func_80ADEC9C || this->actionFunc == func_80ADF894 || - this->actionFunc == func_80ADF5E0)) { - EnPoh_SetupDisappear(this); - } - } else if (this->lightColor.a == 0 && this->visibilityTimer == 0 && - (this->actionFunc == func_80ADEAC4 || this->actionFunc == EnPoh_Idle || - this->actionFunc == func_80ADEC9C || this->actionFunc == func_80ADF5E0)) { - EnPoh_SetupAppear(this); - } - } -} - -void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - - if (Object_IsLoaded(&globalCtx->objectCtx, this->objectIdx) != 0) { - this->actor.objBankIndex = this->objectIdx; - this->actor.update = EnPoh_UpdateLiving; - Actor_SetObjectDependency(globalCtx, &this->actor); - if (this->infoIdx == EN_POH_INFO_NORMAL) { - SkelAnime_Init(globalCtx, &this->skelAnime, &gPoeSkel, &gPoeFloatAnim, this->jointTable, this->morphTable, - 21); - this->actor.draw = EnPoh_DrawRegular; - } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gPoeComposerSkel, &gPoeComposerFloatAnim, this->jointTable, - this->morphTable, 12); - this->actor.draw = EnPoh_DrawComposer; - this->colliderSph.elements[0].dim.limb = 9; - this->colliderSph.elements[0].dim.modelSphere.center.y *= -1; - this->actor.shape.rot.y = this->actor.world.rot.y = -0x4000; - this->colliderCyl.dim.radius = 20; - this->colliderCyl.dim.height = 55; - this->colliderCyl.dim.yShift = 15; - } - this->actor.flags &= ~ACTOR_FLAG_4; - EnPoh_SetupInitialAction(this); - } -} - -void func_80AE067C(EnPoh* this) { - s16 temp_var; - - if (this->actionFunc == EnPoh_Attack) { - this->lightColor.r = CLAMP_MAX((s16)(this->lightColor.r + 5), 255); - this->lightColor.g = CLAMP_MIN((s16)(this->lightColor.g - 5), 50); - temp_var = this->lightColor.b - 5; - this->lightColor.b = CLAMP_MIN(temp_var, 0); - } else if (this->actionFunc == func_80ADF894) { - this->lightColor.r = CLAMP_MAX((s16)(this->lightColor.r + 5), 80); - this->lightColor.g = CLAMP_MAX((s16)(this->lightColor.g + 5), 255); - temp_var = this->lightColor.b + 5; - this->lightColor.b = CLAMP_MAX(temp_var, 225); - } else if (this->actionFunc == func_80ADEECC) { - if (this->actor.colorFilterTimer & 2) { - this->lightColor.r = 0; - this->lightColor.g = 0; - this->lightColor.b = 0; - } else { - this->lightColor.r = 80; - this->lightColor.g = 255; - this->lightColor.b = 225; - } - } else { - this->lightColor.r = CLAMP_MAX((s16)(this->lightColor.r + 5), 255); - this->lightColor.g = CLAMP_MAX((s16)(this->lightColor.g + 5), 255); - if (this->lightColor.b >= 211) { - temp_var = this->lightColor.b - 5; - this->lightColor.b = CLAMP_MIN(temp_var, 210); - } else { - temp_var = this->lightColor.b + 5; - this->lightColor.b = CLAMP_MAX(temp_var, 210); - } - } -} - -void func_80AE089C(EnPoh* this) { - f32 rand; - - if ((this->actionFunc == func_80ADEF38 || this->actionFunc == EnPoh_ComposerAppear) && - this->skelAnime.curFrame < 12.0f) { - this->envColor.r = this->envColor.g = this->envColor.b = (s16)(this->skelAnime.curFrame * 16.66f) + 55; - this->envColor.a = this->skelAnime.curFrame * (100.0f / 6.0f); - } else { - rand = Rand_ZeroOne(); - this->envColor.r = (s16)(rand * 30.0f) + 225; - this->envColor.g = (s16)(rand * 100.0f) + 155; - this->envColor.b = (s16)(rand * 160.0f) + 95; - this->envColor.a = 200; - } -} - -void EnPoh_UpdateLiving(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - s32 pad; - Vec3f vec; - s32 sp38; - - if (this->colliderSph.base.atFlags & AT_HIT) { - this->colliderSph.base.atFlags &= ~AT_HIT; - func_80ADE4C8(this); - } - func_80AE032C(this, globalCtx); - EnPoh_UpdateVisibility(this); - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - if (this->actionFunc == EnPoh_Attack && this->unk_198 < 10) { - this->actor.flags |= ACTOR_FLAG_24; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); - } - Collider_UpdateCylinder(&this->actor, &this->colliderCyl); - if ((this->colliderCyl.base.acFlags & AC_ON) && this->lightColor.a == 255) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCyl.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCyl.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); - Actor_SetFocus(&this->actor, 42.0f); - if (this->actionFunc != func_80ADEECC && this->actionFunc != func_80ADF574) { - if (this->actionFunc == func_80ADF894) { - this->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - } else { - this->actor.shape.rot.y = this->actor.world.rot.y; - } - } - vec.x = this->actor.world.pos.x; - vec.y = this->actor.world.pos.y + 20.0f; - vec.z = this->actor.world.pos.z; - this->actor.floorHeight = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &sp38, &this->actor, &vec); - func_80AE089C(this); - this->actor.shape.shadowAlpha = this->lightColor.a; -} - -s32 EnPoh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfxP) { - EnPoh* this = (EnPoh*)thisx; - - if ((this->lightColor.a == 0 || limbIndex == this->info->unk_6) || - (this->actionFunc == func_80ADF15C && this->unk_198 >= 2)) { - *dList = NULL; - } else if (this->actor.params == EN_POH_FLAT && limbIndex == 0xA) { - // Replace Sharp's head with Flat's - *dList = gPoeComposerFlatHeadDL; - } - if (limbIndex == 0x13 && this->infoIdx == EN_POH_INFO_NORMAL) { - gDPPipeSync((*gfxP)++); - gDPSetEnvColor((*gfxP)++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); - } - return false; -} - -void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfxP) { - EnPoh* this = (EnPoh*)thisx; - - Collider_UpdateSpheres(limbIndex, &this->colliderSph); - if (this->actionFunc == func_80ADF15C && this->unk_198 >= 2 && limbIndex == this->info->unk_7) { - gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2460), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfxP)++, this->info->burnDisplayList); - } - if (limbIndex == this->info->unk_6) { - if (this->actionFunc == func_80ADF15C && this->unk_198 >= 19 && 0.0f != this->actor.scale.x) { - f32 mtxScale = 0.01f / this->actor.scale.x; - Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - } - Matrix_Get(&this->unk_368); - if (this->actionFunc == func_80ADF15C && this->unk_198 == 27) { - this->actor.world.pos.x = this->unk_368.xw; - this->actor.world.pos.y = this->unk_368.yw; - this->actor.world.pos.z = this->unk_368.zw; - } - Lights_PointGlowSetInfo(&this->lightInfo, this->colliderSph.elements[0].dim.worldSphere.center.x, - this->colliderSph.elements[0].dim.worldSphere.center.y, - this->colliderSph.elements[0].dim.worldSphere.center.z, this->envColor.r, - this->envColor.g, this->envColor.b, this->envColor.a * (200.0f / 255)); - } -} - -void EnPoh_DrawRegular(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2629); - func_80AE067C(this); - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - if (this->lightColor.a == 255 || this->lightColor.a == 0) { - gDPSetEnvColor(POLY_OPA_DISP++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); - gSPSegment(POLY_OPA_DISP++, 0x08, D_80116280 + 2); - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, POLY_OPA_DISP); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->lightColor.a); - gSPSegment(POLY_XLU_DISP++, 0x08, D_80116280); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, POLY_XLU_DISP); - } - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, this->envColor.r, this->envColor.g, this->envColor.b, 255); - Matrix_Put(&this->unk_368); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2676), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->info->lanternDisplayList); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2681); -} - -void EnPoh_DrawComposer(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - Color_RGBA8* sp90; - Color_RGBA8* phi_t0; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2694); - func_80AE067C(this); - if (this->actor.params == EN_POH_SHARP) { - sp90 = &D_80AE1B4C; - phi_t0 = &D_80AE1B54; - } else { - sp90 = &D_80AE1B50; - phi_t0 = &D_80AE1B58; - } - if (this->lightColor.a == 255 || this->lightColor.a == 0) { - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, - this->lightColor.a)); - gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_EnvColor(globalCtx->state.gfxCtx, sp90->r, sp90->g, sp90->b, this->lightColor.a)); - gSPSegment(POLY_OPA_DISP++, 0x0B, - Gfx_EnvColor(globalCtx->state.gfxCtx, phi_t0->r, phi_t0->g, phi_t0->b, this->lightColor.a)); - gSPSegment(POLY_OPA_DISP++, 0x0C, D_80116280 + 2); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, - &this->actor, POLY_OPA_DISP); - } else { - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, - this->lightColor.a)); - gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_EnvColor(globalCtx->state.gfxCtx, sp90->r, sp90->g, sp90->b, this->lightColor.a)); - gSPSegment(POLY_XLU_DISP++, 0x0B, - Gfx_EnvColor(globalCtx->state.gfxCtx, phi_t0->r, phi_t0->g, phi_t0->b, this->lightColor.a)); - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, - &this->actor, POLY_XLU_DISP); - } - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, this->envColor.r, this->envColor.g, this->envColor.b, 255); - Matrix_Put(&this->unk_368); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2787), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->info->lanternDisplayList); - gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternBottomDL); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, sp90->r, sp90->g, sp90->b, 255); - gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternTopDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2802); -} - -void EnPoh_UpdateDead(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - - this->actionFunc(this, globalCtx); - if (this->actionFunc != EnPoh_Death) { - this->visibilityTimer++; - } - func_80AE089C(this); -} - -void EnPoh_DrawSoul(Actor* thisx, GlobalContext* globalCtx) { - EnPoh* this = (EnPoh*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2833); - - if (this->actionFunc == EnPoh_Death) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, this->envColor.r, this->envColor.g, this->envColor.b, 255); - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->envColor.r, this->envColor.g, this->envColor.b, 200); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2854), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->info->lanternDisplayList); - if (this->infoIdx == EN_POH_INFO_COMPOSER) { - Color_RGBA8* envColor = (this->actor.params == EN_POH_SHARP) ? &D_80AE1B4C : &D_80AE1B50; - s32 pad; - - gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternBottomDL); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, 255); - gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternTopDL); - } - } else { - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (this->visibilityTimer * this->info->unk_8) % 512U, 0x20, 0x80)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, this->info->primColor.r, this->info->primColor.g, - this->info->primColor.b, this->lightColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, this->lightColor.r, this->lightColor.g, this->lightColor.b, 255); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * 9.58738e-05f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2910), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, this->info->soulDisplayList); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2916); -} diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.cpp b/src/overlays/actors/ovl_En_Poh/z_en_poh.cpp new file mode 100644 index 000000000..5ad4b14eb --- /dev/null +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.cpp @@ -0,0 +1,1219 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_POH_Z_EN_POH_C +#include "actor_common.h" +/* + * File: z_en_poh.c + * Overlay: ovl_En_Poh + * Description: Graveyard Poe + */ + +#include "z_en_poh.h" +#include "objects/object_poh/object_poh.h" +#include "objects/object_po_composer/object_po_composer.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_lights.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_12) + +void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx); + +void EnPoh_UpdateLiving(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_UpdateDead(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_DrawRegular(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_DrawComposer(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_DrawSoul(Actor* thisx, GlobalContext* globalCtx); + +void func_80ADEAC4(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_Idle(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADEC9C(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_Attack(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADEECC(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADF894(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_ComposerAppear(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADEF38(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADF15C(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADF574(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADF5E0(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_Disappear(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_Appear(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_Death(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADFE28(EnPoh* pthis, GlobalContext* globalCtx); +void func_80ADFE80(EnPoh* pthis, GlobalContext* globalCtx); +void func_80AE009C(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_TalkRegular(EnPoh* pthis, GlobalContext* globalCtx); +void EnPoh_TalkComposer(EnPoh* pthis, GlobalContext* globalCtx); + +static s16 D_80AE1A50 = 0; + +ActorInit En_Poh_InitVars = { + ACTOR_EN_POH, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnPoh), + (ActorFunc)EnPoh_Init, + (ActorFunc)EnPoh_Destroy, + (ActorFunc)EnPoh_Update, + NULL, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 40, 20, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit D_80AE1AA0[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 18, { { 0, 1400, 0 }, 10 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + D_80AE1AA0, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 4, 25, 50, 40 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(1, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static EnPohInfo sPoeInfo[2] = { + { + { 255, 170, 255 }, + { 100, 0, 150 }, + 18, + 5, + 248, + &gPoeDisappearAnim, + &gPoeFloatAnim, + &gPoeDamagedAnim, + &gPoeFleeAnim, + gPoeLanternDL, + gPoeBurnDL, + gPoeSoulDL, + }, + { + { 255, 255, 170 }, + { 0, 150, 0 }, + 9, + 1, + 244, + &gPoeComposerDisappearAnim, + &gPoeComposerFloatAnim, + &gPoeComposerDamagedAnim, + &gPoeComposerFleeAnim, + gPoeComposerLanternDL, + gPoeComposerBurnDL, + gPoeComposerSoulDL, + }, +}; + +static Color_RGBA8 D_80AE1B4C = { 75, 20, 25, 255 }; +static Color_RGBA8 D_80AE1B50 = { 80, 110, 90, 255 }; +static Color_RGBA8 D_80AE1B54 = { 90, 85, 50, 255 }; +static Color_RGBA8 D_80AE1B58 = { 100, 90, 100, 255 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), +}; + +static Vec3f D_80AE1B60 = { 0.0f, 3.0f, 0.0f }; +static Vec3f D_80AE1B6C = { 0.0f, 0.0f, 0.0f }; + +void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnItem00* collectible; + EnPoh* pthis = (EnPoh*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + Collider_InitJntSph(globalCtx, &pthis->colliderSph); + Collider_SetJntSph(globalCtx, &pthis->colliderSph, &pthis->actor, &sJntSphInit, &pthis->colliderSphItem); + pthis->colliderSph.elements[0].dim.worldSphere.radius = 0; + pthis->colliderSph.elements[0].dim.worldSphere.center.x = pthis->actor.world.pos.x; + pthis->colliderSph.elements[0].dim.worldSphere.center.y = pthis->actor.world.pos.y; + pthis->colliderSph.elements[0].dim.worldSphere.center.z = pthis->actor.world.pos.z; + Collider_InitCylinder(globalCtx, &pthis->colliderCyl); + Collider_SetCylinder(globalCtx, &pthis->colliderCyl, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->unk_194 = 0; + pthis->unk_195 = 32; + pthis->visibilityTimer = Rand_S16Offset(700, 300); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, + 255, 255, 255, 0); + if (pthis->actor.params >= 4) { + pthis->actor.params = EN_POH_NORMAL; + } + if (pthis->actor.params == EN_POH_RUPEE) { + D_80AE1A50++; + if (D_80AE1A50 >= 3) { + Actor_Kill(&pthis->actor); + } else { + collectible = Item_DropCollectible(globalCtx, &pthis->actor.world.pos, 0x4000 | ITEM00_RUPEE_BLUE); + if (collectible != NULL) { + collectible->actor.speedXZ = 0.0f; + } + } + } else if (pthis->actor.params == EN_POH_FLAT) { + if (Flags_GetSwitch(globalCtx, 0x28) || Flags_GetSwitch(globalCtx, 0x9)) { + Actor_Kill(&pthis->actor); + } else { + Flags_SetSwitch(globalCtx, 0x28); + } + } else if (pthis->actor.params == EN_POH_SHARP) { + if (Flags_GetSwitch(globalCtx, 0x29) || Flags_GetSwitch(globalCtx, 0x9)) { + Actor_Kill(&pthis->actor); + } else { + Flags_SetSwitch(globalCtx, 0x29); + } + } + if (pthis->actor.params < EN_POH_SHARP) { + pthis->objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_POH); + pthis->infoIdx = EN_POH_INFO_NORMAL; + pthis->actor.naviEnemyId = 0x44; + } else { + pthis->objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_PO_COMPOSER); + pthis->infoIdx = EN_POH_INFO_COMPOSER; + pthis->actor.naviEnemyId = 0x43; + } + pthis->info = &sPoeInfo[pthis->infoIdx]; + if (pthis->objectIdx < 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); + Collider_DestroyJntSph(globalCtx, &pthis->colliderSph); + Collider_DestroyCylinder(globalCtx, &pthis->colliderCyl); + if (pthis->actor.params == EN_POH_RUPEE) { + D_80AE1A50--; + } +} + +void func_80ADE114(EnPoh* pthis) { + Animation_PlayLoop(&pthis->skelAnime, pthis->info->idleAnim); + pthis->unk_198 = Rand_S16Offset(2, 3); + pthis->actionFunc = func_80ADEAC4; + pthis->actor.speedXZ = 0.0f; +} + +void EnPoh_SetupIdle(EnPoh* pthis) { + Animation_PlayLoop(&pthis->skelAnime, pthis->info->idleAnim2); + pthis->unk_198 = Rand_S16Offset(15, 3); + pthis->actionFunc = EnPoh_Idle; +} + +void func_80ADE1BC(EnPoh* pthis) { + Animation_PlayLoop(&pthis->skelAnime, pthis->info->idleAnim2); + pthis->actionFunc = func_80ADEC9C; + pthis->unk_198 = 0; + pthis->actor.speedXZ = 2.0f; +} + +void EnPoh_SetupAttack(EnPoh* pthis) { + if (pthis->infoIdx == EN_POH_INFO_NORMAL) { + Animation_MorphToLoop(&pthis->skelAnime, &gPoeAttackAnim, -6.0f); + } else { + Animation_PlayLoop(&pthis->skelAnime, &gPoeComposerAttackAnim); + } + pthis->unk_198 = 12; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + pthis->actionFunc = EnPoh_Attack; +} + +void func_80ADE28C(EnPoh* pthis) { + if (pthis->infoIdx == EN_POH_INFO_NORMAL) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gPoeDamagedAnim, -6.0f); + } else { + Animation_PlayOnce(&pthis->skelAnime, &gPoeComposerDamagedAnim); + } + if (pthis->colliderCyl.info.acHitInfo->toucher.dmgFlags & 0x0001F824) { + pthis->actor.world.rot.y = pthis->colliderCyl.base.ac->world.rot.y; + } else { + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, pthis->colliderCyl.base.ac) + 0x8000; + } + pthis->colliderCyl.base.acFlags &= ~AC_ON; + pthis->actor.speedXZ = 5.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0x10); + pthis->actionFunc = func_80ADEECC; +} + +void func_80ADE368(EnPoh* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, pthis->info->fleeAnim, -5.0f); + pthis->actor.speedXZ = 5.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x8000; + pthis->colliderCyl.base.acFlags |= AC_ON; + pthis->unk_198 = 200; + pthis->actionFunc = func_80ADF894; +} + +void EnPoh_SetupInitialAction(EnPoh* pthis) { + pthis->lightColor.a = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->infoIdx == EN_POH_INFO_NORMAL) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gPoeAppearAnim, 0.0f); + pthis->actionFunc = func_80ADEF38; + } else { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gPoeComposerAppearAnim, 1.0f); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 20.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + pthis->actionFunc = EnPoh_ComposerAppear; + } +} + +void func_80ADE48C(EnPoh* pthis) { + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->unk_198 = 0; + pthis->actor.naviEnemyId = 0xFF; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = func_80ADF15C; +} + +void func_80ADE4C8(EnPoh* pthis) { + Animation_PlayOnce(&pthis->skelAnime, pthis->info->idleAnim2); + pthis->actionFunc = func_80ADF574; + pthis->actor.speedXZ = -5.0f; +} + +void func_80ADE514(EnPoh* pthis) { + Animation_PlayLoop(&pthis->skelAnime, pthis->info->idleAnim); + pthis->unk_19C = pthis->actor.world.rot.y + 0x8000; + pthis->actionFunc = func_80ADF5E0; + pthis->actor.speedXZ = 0.0f; +} + +void EnPoh_SetupDisappear(EnPoh* pthis) { + pthis->unk_194 = 32; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DISAPPEAR); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + pthis->actionFunc = EnPoh_Disappear; +} + +void EnPoh_SetupAppear(EnPoh* pthis) { + pthis->unk_194 = 0; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + pthis->actionFunc = EnPoh_Appear; +} + +void EnPoh_SetupDeath(EnPoh* pthis, GlobalContext* globalCtx) { + pthis->actor.update = EnPoh_UpdateDead; + pthis->actor.draw = EnPoh_DrawSoul; + pthis->actor.shape.shadowDraw = NULL; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->actor.gravity = -1.0f; + pthis->actor.shape.yOffset = 1500.0f; + pthis->actor.world.pos.y -= 15.0f; + if (pthis->infoIdx != EN_POH_INFO_COMPOSER) { + pthis->actor.shape.rot.x = -0x8000; + } + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, 8); + pthis->unk_198 = 60; + pthis->actionFunc = EnPoh_Death; +} + +void func_80ADE6D4(EnPoh* pthis) { + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0); + pthis->visibilityTimer = 0; + pthis->actor.shape.rot.y = 0; + pthis->lightColor.r = 0; + pthis->lightColor.a = 0; + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + if (pthis->actor.params >= EN_POH_SHARP) { + pthis->lightColor.g = 200; + pthis->lightColor.b = 0; + } else { + pthis->lightColor.g = 0; + pthis->lightColor.b = 200; + } + pthis->actor.scale.x = 0.0f; + pthis->actor.scale.y = 0.0f; + pthis->actor.shape.rot.x = 0; + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_METAL_BOX_BOUND); + pthis->actionFunc = func_80ADFE28; +} + +void EnPoh_Talk(EnPoh* pthis, GlobalContext* globalCtx) { + pthis->actor.home.pos.y = pthis->actor.world.pos.y; + Actor_SetFocus(&pthis->actor, -10.0f); + pthis->colliderCyl.dim.radius = 13; + pthis->colliderCyl.dim.height = 30; + pthis->colliderCyl.dim.yShift = 0; + pthis->colliderCyl.dim.pos.x = pthis->actor.world.pos.x; + pthis->colliderCyl.dim.pos.y = pthis->actor.world.pos.y - 20.0f; + pthis->colliderCyl.dim.pos.z = pthis->actor.world.pos.z; + pthis->colliderCyl.base.ocFlags1 = OC1_ON | OC1_TYPE_PLAYER; + if (pthis->actor.params == EN_POH_FLAT || pthis->actor.params == EN_POH_SHARP) { + if (CHECK_QUEST_ITEM(QUEST_SONG_SUN)) { + pthis->actor.textId = 0x5000; + } else if (!Flags_GetSwitch(globalCtx, 0xA) && !Flags_GetSwitch(globalCtx, 0xB)) { + pthis->actor.textId = 0x500F; + } else if ((pthis->actor.params == EN_POH_FLAT && Flags_GetSwitch(globalCtx, 0xA)) || + (pthis->actor.params == EN_POH_SHARP && Flags_GetSwitch(globalCtx, 0xB))) { + pthis->actor.textId = 0x5013; + } else { + pthis->actor.textId = 0x5012; + } + } else { + pthis->actor.textId = 0x5005; + } + pthis->unk_198 = 200; + pthis->unk_195 = 32; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = func_80ADFE80; +} + +void func_80ADE950(EnPoh* pthis, s32 arg1) { + if (arg1) { + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + } + pthis->actionFunc = func_80AE009C; +} + +void func_80ADE998(EnPoh* pthis) { + pthis->actionFunc = EnPoh_TalkRegular; + pthis->actor.home.pos.y = pthis->actor.world.pos.y - 15.0f; +} + +void func_80ADE9BC(EnPoh* pthis) { + pthis->actionFunc = EnPoh_TalkComposer; +} + +void EnPoh_MoveTowardsPlayerHeight(EnPoh* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_StepToF(&pthis->actor.world.pos.y, player->actor.world.pos.y, 1.0f); + pthis->actor.world.pos.y += 2.5f * Math_SinS(pthis->unk_195 * 0x800); + if (pthis->unk_195 != 0) { + pthis->unk_195 -= 1; + } + if (pthis->unk_195 == 0) { + pthis->unk_195 = 32; + } +} + +void func_80ADEA5C(EnPoh* pthis) { + if (Actor_WorldDistXZToPoint(&pthis->actor, &pthis->actor.home.pos) > 400.0f) { + pthis->unk_19C = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + } + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->unk_19C, 0x71C); +} + +void func_80ADEAC4(EnPoh* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->unk_198 != 0) { + pthis->unk_198--; + } + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + if (pthis->actor.xzDistToPlayer < 200.0f) { + func_80ADE1BC(pthis); + } else if (pthis->unk_198 == 0) { + EnPoh_SetupIdle(pthis); + } + if (pthis->lightColor.a == 255) { + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } +} + +void EnPoh_Idle(EnPoh* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_StepToF(&pthis->actor.speedXZ, 1.0f, 0.2f); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && pthis->unk_198 != 0) { + pthis->unk_198--; + } + func_80ADEA5C(pthis); + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + if (pthis->actor.xzDistToPlayer < 200.0f && pthis->unk_198 < 19) { + func_80ADE1BC(pthis); + } else if (pthis->unk_198 == 0) { + if (Rand_ZeroOne() < 0.1f) { + func_80ADE514(pthis); + } else { + func_80ADE114(pthis); + } + } + if (pthis->lightColor.a == 255) { + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } +} + +void func_80ADEC9C(EnPoh* pthis, GlobalContext* globalCtx) { + Player* player; + s16 facingDiff; + + player = GET_PLAYER(globalCtx); + SkelAnime_Update(&pthis->skelAnime); + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + facingDiff = pthis->actor.yawTowardsPlayer - player->actor.shape.rot.y; + if (facingDiff >= 0x3001) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x3000, 0x71C); + } else if (facingDiff < -0x3000) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer - 0x3000, 0x71C); + } else { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0x71C); + } + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + if (pthis->actor.xzDistToPlayer > 280.0f) { + EnPoh_SetupIdle(pthis); + } else if (pthis->unk_198 == 0 && pthis->actor.xzDistToPlayer < 140.0f && + !Player_IsFacingActor(&pthis->actor, 0x2AAA, globalCtx)) { + EnPoh_SetupAttack(pthis); + } + if (pthis->lightColor.a == 255) { + func_8002F974(&pthis->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } +} + +void EnPoh_Attack(EnPoh* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_KANTERA); + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + } + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + if (pthis->unk_198 >= 10) { + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 0xE38); + } else if (pthis->unk_198 == 9) { + pthis->actor.speedXZ = 5.0f; + pthis->skelAnime.playSpeed = 2.0f; + } else if (pthis->unk_198 == 0) { + EnPoh_SetupIdle(pthis); + pthis->unk_198 = 23; + } +} + +void func_80ADEECC(EnPoh* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.colChkInfo.health != 0) { + func_80ADE368(pthis); + } else { + func_80ADE48C(pthis); + } + } +} + +void func_80ADEF38(EnPoh* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->lightColor.a = 255; + pthis->visibilityTimer = Rand_S16Offset(700, 300); + pthis->actor.flags |= ACTOR_FLAG_0; + EnPoh_SetupIdle(pthis); + } else if (pthis->skelAnime.curFrame > 10.0f) { + pthis->lightColor.a = ((pthis->skelAnime.curFrame - 10.0f) * 0.05f) * 255.0f; + } + if (pthis->skelAnime.playSpeed < 0.5f && pthis->actor.xzDistToPlayer < 280.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_APPEAR); + pthis->skelAnime.playSpeed = 1.0f; + } +} + +void EnPoh_ComposerAppear(EnPoh* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->lightColor.a = 255; + pthis->visibilityTimer = Rand_S16Offset(700, 300); + pthis->actor.flags |= ACTOR_FLAG_0; + EnPoh_SetupIdle(pthis); + } else { + pthis->lightColor.a = CLAMP_MAX((s32)(pthis->skelAnime.curFrame * 25.5f), 255); + } +} + +void func_80ADF15C(EnPoh* pthis, GlobalContext* globalCtx) { + Vec3f vec; + f32 multiplier; + f32 newScale; + s32 pad; + s32 pad1; + + pthis->unk_198++; + if (pthis->unk_198 < 8) { + if (pthis->unk_198 < 5) { + vec.y = Math_SinS((pthis->unk_198 * 0x1000) - 0x4000) * 23.0f + (pthis->actor.world.pos.y + 40.0f); + multiplier = Math_CosS((pthis->unk_198 * 0x1000) - 0x4000) * 23.0f; + vec.x = Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier + + pthis->actor.world.pos.x; + vec.z = Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * multiplier + + pthis->actor.world.pos.z; + } else { + vec.y = (pthis->actor.world.pos.y + 40.0f) + (15.0f * (pthis->unk_198 - 5)); + vec.x = + Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + pthis->actor.world.pos.x; + vec.z = + Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800) * 23.0f + pthis->actor.world.pos.z; + } + EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AE1B60, &D_80AE1B6C, pthis->unk_198 * 10 + 80, 0, 255, 255, 255, 255, + 0, 0, 255, 1, 9, 1); + vec.x = (pthis->actor.world.pos.x + pthis->actor.world.pos.x) - vec.x; + vec.z = (pthis->actor.world.pos.z + pthis->actor.world.pos.z) - vec.z; + EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AE1B60, &D_80AE1B6C, pthis->unk_198 * 10 + 80, 0, 255, 255, 255, 255, + 0, 0, 255, 1, 9, 1); + vec.x = pthis->actor.world.pos.x; + vec.z = pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &vec, &D_80AE1B60, &D_80AE1B6C, pthis->unk_198 * 10 + 80, 0, 255, 255, 255, 255, + 0, 0, 255, 1, 9, 1); + if (pthis->unk_198 == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EXTINCT); + } + } else if (pthis->unk_198 == 28) { + EnPoh_SetupDeath(pthis, globalCtx); + } else if (pthis->unk_198 >= 19) { + newScale = (28 - pthis->unk_198) * 0.001f; + pthis->actor.world.pos.y += 5.0f; + pthis->actor.scale.z = newScale; + pthis->actor.scale.y = newScale; + pthis->actor.scale.x = newScale; + } + if (pthis->unk_198 == 18) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DEAD2); + } +} + +void func_80ADF574(EnPoh* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnPoh_SetupIdle(pthis); + pthis->unk_198 = 23; + } else { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.5f); + pthis->actor.shape.rot.y += 0x1000; + } +} + +void func_80ADF5E0(EnPoh* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->unk_19C, 1820) != 0) { + EnPoh_SetupIdle(pthis); + } + if (pthis->actor.xzDistToPlayer < 200.0f) { + func_80ADE1BC(pthis); + } + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); +} + +void EnPoh_Disappear(EnPoh* pthis, GlobalContext* globalCtx) { + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + pthis->actor.world.rot.y += 0x1000; + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + pthis->lightColor.a = pthis->unk_194 * 7.96875f; + if (pthis->unk_194 == 0) { + pthis->visibilityTimer = Rand_S16Offset(100, 50); + EnPoh_SetupIdle(pthis); + } +} + +void EnPoh_Appear(EnPoh* pthis, GlobalContext* globalCtx) { + pthis->unk_194++; + pthis->actor.world.rot.y -= 0x1000; + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + pthis->lightColor.a = pthis->unk_194 * 7.96875f; + if (pthis->unk_194 == 32) { + pthis->visibilityTimer = Rand_S16Offset(700, 300); + pthis->unk_194 = 0; + EnPoh_SetupIdle(pthis); + } +} + +void func_80ADF894(EnPoh* pthis, GlobalContext* globalCtx) { + f32 multiplier; + + SkelAnime_Update(&pthis->skelAnime); + multiplier = Math_SinS(pthis->unk_195 * 0x800) * 3.0f; + pthis->actor.world.pos.x -= multiplier * Math_CosS(pthis->actor.shape.rot.y); + pthis->actor.world.pos.z += multiplier * Math_SinS(pthis->actor.shape.rot.y); + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 0x71C); + EnPoh_MoveTowardsPlayerHeight(pthis, globalCtx); + if (pthis->unk_198 == 0 || pthis->actor.xzDistToPlayer > 250.0f) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnPoh_SetupIdle(pthis); + } + func_8002F974(&pthis->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); +} + +void EnPoh_Death(EnPoh* pthis, GlobalContext* globalCtx) { + s32 objId; + + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + if (pthis->actor.bgCheckFlags & 1) { + objId = (pthis->infoIdx == EN_POH_INFO_COMPOSER) ? OBJECT_PO_COMPOSER : OBJECT_POH; + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 6.0f, 0, 1, 1, 15, objId, 10, + pthis->info->lanternDisplayList); + func_80ADE6D4(pthis); + } else if (pthis->unk_198 == 0) { + Actor_Kill(&pthis->actor); + return; + } + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 10.0f, 4); +} + +void func_80ADFA90(EnPoh* pthis, s32 arg1) { + f32 multiplier; + + pthis->lightColor.a = CLAMP(pthis->lightColor.a + arg1, 0, 255); + if (arg1 < 0) { + multiplier = pthis->lightColor.a * (1.0f / 255); + pthis->actor.scale.x = pthis->actor.scale.z = 0.0056000002f * multiplier + 0.0014000001f; + pthis->actor.scale.y = (0.007f - 0.007f * multiplier) + 0.007f; + } else { + multiplier = 1.0f; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = pthis->lightColor.a * (0.007f / 0xFF); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (1.0f / 17.0f) * pthis->lightColor.a; + } + pthis->lightColor.r = pthis->info->lightColor.r * multiplier; + pthis->lightColor.g = pthis->info->lightColor.g * multiplier; + pthis->lightColor.b = pthis->info->lightColor.b * multiplier; + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->info->lightColor.r, pthis->info->lightColor.g, + pthis->info->lightColor.b, pthis->lightColor.a * (200.0f / 255)); +} + +void func_80ADFE28(EnPoh* pthis, GlobalContext* globalCtx) { + pthis->actor.home.pos.y += 2.0f; + func_80ADFA90(pthis, 20); + if (pthis->lightColor.a == 255) { + EnPoh_Talk(pthis, globalCtx); + } +} + +void func_80ADFE80(EnPoh* pthis, GlobalContext* globalCtx) { + if (pthis->unk_198 != 0) { + pthis->unk_198--; + } + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if (pthis->actor.params >= EN_POH_SHARP) { + func_80ADE9BC(pthis); + } else { + func_80ADE998(pthis); + } + return; + } + if (pthis->unk_198 == 0) { + func_80ADE950(pthis, 1); + pthis->actor.flags &= ~ACTOR_FLAG_16; + return; + } + if (pthis->colliderCyl.base.ocFlags1 & OC1_HIT) { + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2F4(&pthis->actor, globalCtx); + } else { + pthis->actor.flags &= ~ACTOR_FLAG_16; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCyl.base); + } + pthis->actor.world.pos.y = Math_SinS(pthis->unk_195 * 0x800) * 5.0f + pthis->actor.home.pos.y; + if (pthis->unk_195 != 0) { + pthis->unk_195 -= 1; + } + if (pthis->unk_195 == 0) { + pthis->unk_195 = 32; + } + pthis->colliderCyl.dim.pos.y = pthis->actor.world.pos.y - 20.0f; + Actor_SetFocus(&pthis->actor, -10.0f); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->info->lightColor.r, pthis->info->lightColor.g, + pthis->info->lightColor.b, pthis->lightColor.a * (200.0f / 255)); +} + +void func_80AE009C(EnPoh* pthis, GlobalContext* globalCtx) { + func_80ADFA90(pthis, -13); + if (pthis->lightColor.a == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnPoh_TalkRegular(EnPoh* pthis, GlobalContext* globalCtx) { + if (pthis->actor.textId != 0x5005) { + func_80ADFA90(pthis, -13); + } else { + func_8002F974(&pthis->actor, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + } + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(globalCtx)) { + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + if (globalCtx->msgCtx.choiceIndex == 0) { + if (Inventory_HasEmptyBottle()) { + pthis->actor.textId = 0x5008; + Item_Give(globalCtx, ITEM_POE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_BIG_GET); + } else { + pthis->actor.textId = 0x5006; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + } + } else { + pthis->actor.textId = 0x5007; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_LAUGH); + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } + } else if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80ADE950(pthis, 0); + } +} + +void EnPoh_TalkComposer(EnPoh* pthis, GlobalContext* globalCtx) { + func_8002F974(&pthis->actor, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (!Flags_GetSwitch(globalCtx, 0xB) && !Flags_GetSwitch(globalCtx, 0xA)) { + pthis->actor.textId = 0x5010; + } else { + pthis->actor.textId = 0x5014; + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } else { + if (pthis->actor.params == EN_POH_SHARP) { + Flags_SetSwitch(globalCtx, 0xB); + } else { + Flags_SetSwitch(globalCtx, 0xA); + } + func_80ADE950(pthis, 1); + } + } + } else if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + if (pthis->actor.textId == 0x5000) { + Flags_SetSwitch(globalCtx, 9); + } + func_80ADE950(pthis, 1); + } +} + +void func_80AE032C(EnPoh* pthis, GlobalContext* globalCtx) { + if (pthis->colliderCyl.base.acFlags & AC_HIT) { + pthis->colliderCyl.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != 0 || pthis->actor.colChkInfo.damage != 0) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DEAD); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DAMAGE); + } + func_80ADE28C(pthis); + } + } +} + +void EnPoh_UpdateVisibility(EnPoh* pthis) { + if (pthis->actionFunc != EnPoh_Appear && pthis->actionFunc != EnPoh_Disappear && pthis->actionFunc != func_80ADEF38 && + pthis->actionFunc != EnPoh_ComposerAppear) { + if (pthis->visibilityTimer != 0) { + pthis->visibilityTimer--; + } + if (pthis->lightColor.a == 255) { + if (pthis->actor.isTargeted) { + pthis->unk_194++; + pthis->unk_194 = CLAMP_MAX(pthis->unk_194, 20); + } else { + pthis->unk_194 = 0; + } + if ((pthis->unk_194 == 20 || pthis->visibilityTimer == 0) && + (pthis->actionFunc == func_80ADEAC4 || pthis->actionFunc == EnPoh_Idle || + pthis->actionFunc == func_80ADEC9C || pthis->actionFunc == func_80ADF894 || + pthis->actionFunc == func_80ADF5E0)) { + EnPoh_SetupDisappear(pthis); + } + } else if (pthis->lightColor.a == 0 && pthis->visibilityTimer == 0 && + (pthis->actionFunc == func_80ADEAC4 || pthis->actionFunc == EnPoh_Idle || + pthis->actionFunc == func_80ADEC9C || pthis->actionFunc == func_80ADF5E0)) { + EnPoh_SetupAppear(pthis); + } + } +} + +void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objectIdx) != 0) { + pthis->actor.objBankIndex = pthis->objectIdx; + pthis->actor.update = EnPoh_UpdateLiving; + Actor_SetObjectDependency(globalCtx, &pthis->actor); + if (pthis->infoIdx == EN_POH_INFO_NORMAL) { + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gPoeSkel, &gPoeFloatAnim, pthis->jointTable, pthis->morphTable, + 21); + pthis->actor.draw = EnPoh_DrawRegular; + } else { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gPoeComposerSkel, &gPoeComposerFloatAnim, pthis->jointTable, + pthis->morphTable, 12); + pthis->actor.draw = EnPoh_DrawComposer; + pthis->colliderSph.elements[0].dim.limb = 9; + pthis->colliderSph.elements[0].dim.modelSphere.center.y *= -1; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = -0x4000; + pthis->colliderCyl.dim.radius = 20; + pthis->colliderCyl.dim.height = 55; + pthis->colliderCyl.dim.yShift = 15; + } + pthis->actor.flags &= ~ACTOR_FLAG_4; + EnPoh_SetupInitialAction(pthis); + } +} + +void func_80AE067C(EnPoh* pthis) { + s16 temp_var; + + if (pthis->actionFunc == EnPoh_Attack) { + pthis->lightColor.r = CLAMP_MAX((s16)(pthis->lightColor.r + 5), 255); + pthis->lightColor.g = CLAMP_MIN((s16)(pthis->lightColor.g - 5), 50); + temp_var = pthis->lightColor.b - 5; + pthis->lightColor.b = CLAMP_MIN(temp_var, 0); + } else if (pthis->actionFunc == func_80ADF894) { + pthis->lightColor.r = CLAMP_MAX((s16)(pthis->lightColor.r + 5), 80); + pthis->lightColor.g = CLAMP_MAX((s16)(pthis->lightColor.g + 5), 255); + temp_var = pthis->lightColor.b + 5; + pthis->lightColor.b = CLAMP_MAX(temp_var, 225); + } else if (pthis->actionFunc == func_80ADEECC) { + if (pthis->actor.colorFilterTimer & 2) { + pthis->lightColor.r = 0; + pthis->lightColor.g = 0; + pthis->lightColor.b = 0; + } else { + pthis->lightColor.r = 80; + pthis->lightColor.g = 255; + pthis->lightColor.b = 225; + } + } else { + pthis->lightColor.r = CLAMP_MAX((s16)(pthis->lightColor.r + 5), 255); + pthis->lightColor.g = CLAMP_MAX((s16)(pthis->lightColor.g + 5), 255); + if (pthis->lightColor.b >= 211) { + temp_var = pthis->lightColor.b - 5; + pthis->lightColor.b = CLAMP_MIN(temp_var, 210); + } else { + temp_var = pthis->lightColor.b + 5; + pthis->lightColor.b = CLAMP_MAX(temp_var, 210); + } + } +} + +void func_80AE089C(EnPoh* pthis) { + f32 rand; + + if ((pthis->actionFunc == func_80ADEF38 || pthis->actionFunc == EnPoh_ComposerAppear) && + pthis->skelAnime.curFrame < 12.0f) { + pthis->envColor.r = pthis->envColor.g = pthis->envColor.b = (s16)(pthis->skelAnime.curFrame * 16.66f) + 55; + pthis->envColor.a = pthis->skelAnime.curFrame * (100.0f / 6.0f); + } else { + rand = Rand_ZeroOne(); + pthis->envColor.r = (s16)(rand * 30.0f) + 225; + pthis->envColor.g = (s16)(rand * 100.0f) + 155; + pthis->envColor.b = (s16)(rand * 160.0f) + 95; + pthis->envColor.a = 200; + } +} + +void EnPoh_UpdateLiving(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + s32 pad; + Vec3f vec; + s32 sp38; + + if (pthis->colliderSph.base.atFlags & AT_HIT) { + pthis->colliderSph.base.atFlags &= ~AT_HIT; + func_80ADE4C8(pthis); + } + func_80AE032C(pthis, globalCtx); + EnPoh_UpdateVisibility(pthis); + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + if (pthis->actionFunc == EnPoh_Attack && pthis->unk_198 < 10) { + pthis->actor.flags |= ACTOR_FLAG_24; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); + } + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderCyl); + if ((pthis->colliderCyl.base.acFlags & AC_ON) && pthis->lightColor.a == 255) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCyl.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCyl.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); + Actor_SetFocus(&pthis->actor, 42.0f); + if (pthis->actionFunc != func_80ADEECC && pthis->actionFunc != func_80ADF574) { + if (pthis->actionFunc == func_80ADF894) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + } else { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + } + vec.x = pthis->actor.world.pos.x; + vec.y = pthis->actor.world.pos.y + 20.0f; + vec.z = pthis->actor.world.pos.z; + pthis->actor.floorHeight = + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &sp38, &pthis->actor, &vec); + func_80AE089C(pthis); + pthis->actor.shape.shadowAlpha = pthis->lightColor.a; +} + +s32 EnPoh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfxP) { + EnPoh* pthis = (EnPoh*)thisx; + + if ((pthis->lightColor.a == 0 || limbIndex == pthis->info->unk_6) || + (pthis->actionFunc == func_80ADF15C && pthis->unk_198 >= 2)) { + *dList = NULL; + } else if (pthis->actor.params == EN_POH_FLAT && limbIndex == 0xA) { + // Replace Sharp's head with Flat's + *dList = gPoeComposerFlatHeadDL; + } + if (limbIndex == 0x13 && pthis->infoIdx == EN_POH_INFO_NORMAL) { + gDPPipeSync((*gfxP)++); + gDPSetEnvColor((*gfxP)++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, pthis->lightColor.a); + } + return false; +} + +void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfxP) { + EnPoh* pthis = (EnPoh*)thisx; + + Collider_UpdateSpheres(limbIndex, &pthis->colliderSph); + if (pthis->actionFunc == func_80ADF15C && pthis->unk_198 >= 2 && limbIndex == pthis->info->unk_7) { + gSPMatrix((*gfxP)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2460), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfxP)++, pthis->info->burnDisplayList); + } + if (limbIndex == pthis->info->unk_6) { + if (pthis->actionFunc == func_80ADF15C && pthis->unk_198 >= 19 && 0.0f != pthis->actor.scale.x) { + f32 mtxScale = 0.01f / pthis->actor.scale.x; + Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); + } + Matrix_Get(&pthis->unk_368); + if (pthis->actionFunc == func_80ADF15C && pthis->unk_198 == 27) { + pthis->actor.world.pos.x = pthis->unk_368.xw; + pthis->actor.world.pos.y = pthis->unk_368.yw; + pthis->actor.world.pos.z = pthis->unk_368.zw; + } + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->colliderSph.elements[0].dim.worldSphere.center.x, + pthis->colliderSph.elements[0].dim.worldSphere.center.y, + pthis->colliderSph.elements[0].dim.worldSphere.center.z, pthis->envColor.r, + pthis->envColor.g, pthis->envColor.b, pthis->envColor.a * (200.0f / 255)); + } +} + +void EnPoh_DrawRegular(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2629); + func_80AE067C(pthis); + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + if (pthis->lightColor.a == 255 || pthis->lightColor.a == 0) { + gDPSetEnvColor(POLY_OPA_DISP++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, pthis->lightColor.a); + gSPSegment(POLY_OPA_DISP++, 0x08, D_80116280 + 2); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &pthis->actor, POLY_OPA_DISP); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, pthis->lightColor.a); + gSPSegment(POLY_XLU_DISP++, 0x08, D_80116280); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &pthis->actor, POLY_XLU_DISP); + } + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->envColor.r, pthis->envColor.g, pthis->envColor.b, 255); + Matrix_Put(&pthis->unk_368); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2676), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, pthis->info->lanternDisplayList); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2681); +} + +void EnPoh_DrawComposer(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + Color_RGBA8* sp90; + Color_RGBA8* phi_t0; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2694); + func_80AE067C(pthis); + if (pthis->actor.params == EN_POH_SHARP) { + sp90 = &D_80AE1B4C; + phi_t0 = &D_80AE1B54; + } else { + sp90 = &D_80AE1B50; + phi_t0 = &D_80AE1B58; + } + if (pthis->lightColor.a == 255 || pthis->lightColor.a == 0) { + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, + pthis->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0A, + Gfx_EnvColor(globalCtx->state.gfxCtx, sp90->r, sp90->g, sp90->b, pthis->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0B, + Gfx_EnvColor(globalCtx->state.gfxCtx, phi_t0->r, phi_t0->g, phi_t0->b, pthis->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0C, D_80116280 + 2); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, + &pthis->actor, POLY_OPA_DISP); + } else { + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, + pthis->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0A, + Gfx_EnvColor(globalCtx->state.gfxCtx, sp90->r, sp90->g, sp90->b, pthis->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0B, + Gfx_EnvColor(globalCtx->state.gfxCtx, phi_t0->r, phi_t0->g, phi_t0->b, pthis->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, + &pthis->actor, POLY_XLU_DISP); + } + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->envColor.r, pthis->envColor.g, pthis->envColor.b, 255); + Matrix_Put(&pthis->unk_368); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2787), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, pthis->info->lanternDisplayList); + gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternBottomDL); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, sp90->r, sp90->g, sp90->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternTopDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2802); +} + +void EnPoh_UpdateDead(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc != EnPoh_Death) { + pthis->visibilityTimer++; + } + func_80AE089C(pthis); +} + +void EnPoh_DrawSoul(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* pthis = (EnPoh*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2833); + + if (pthis->actionFunc == EnPoh_Death) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->envColor.r, pthis->envColor.g, pthis->envColor.b, 255); + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->envColor.r, pthis->envColor.g, pthis->envColor.b, 200); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2854), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, pthis->info->lanternDisplayList); + if (pthis->infoIdx == EN_POH_INFO_COMPOSER) { + Color_RGBA8* envColor = (pthis->actor.params == EN_POH_SHARP) ? &D_80AE1B4C : &D_80AE1B50; + s32 pad; + + gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternBottomDL); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gPoeComposerLanternTopDL); + } + } else { + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + (pthis->visibilityTimer * pthis->info->unk_8) % 512U, 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, pthis->info->primColor.r, pthis->info->primColor.g, + pthis->info->primColor.b, pthis->lightColor.a); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->lightColor.r, pthis->lightColor.g, pthis->lightColor.b, 255); + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * 9.58738e-05f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_poh.c", 2910), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, pthis->info->soulDisplayList); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_poh.c", 2916); +} diff --git a/src/overlays/actors/ovl_En_Pu_box/z_en_pu_box.c b/src/overlays/actors/ovl_En_Pu_box/z_en_pu_box.cpp similarity index 81% rename from src/overlays/actors/ovl_En_Pu_box/z_en_pu_box.c rename to src/overlays/actors/ovl_En_Pu_box/z_en_pu_box.cpp index b857241f7..7b2e36bb8 100644 --- a/src/overlays/actors/ovl_En_Pu_box/z_en_pu_box.c +++ b/src/overlays/actors/ovl_En_Pu_box/z_en_pu_box.cpp @@ -21,7 +21,7 @@ void EnPubox_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPubox_Update(Actor* thisx, GlobalContext* globalCtx); void EnPubox_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Pu_box_InitVars = { +ActorInit En_Pu_box_InitVars = { ACTOR_EN_PU_BOX, ACTORCAT_BG, FLAGS, @@ -35,7 +35,7 @@ const ActorInit En_Pu_box_InitVars = { void EnPubox_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionHeader* colHeader = NULL; - EnPubox* this = (EnPubox*)thisx; + EnPubox* pthis = (EnPubox*)thisx; switch (thisx->params) { case 0: @@ -52,39 +52,39 @@ void EnPubox_Init(Actor* thisx, GlobalContext* globalCtx) { default: break; } - this->unk_164 = 1; + pthis->unk_164 = 1; thisx->colChkInfo.cylRadius = 20; thisx->colChkInfo.cylHeight = 50; thisx->uncullZoneDownward = 1200.0f; thisx->uncullZoneScale = 720.0f; ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 6.0f); - this->dyna.unk_160 = 0; - this->dyna.unk_15C = DPM_UNK; + pthis->dyna.unk_160 = 0; + pthis->dyna.unk_15C = DPM_UNK; thisx->targetMode = 1; thisx->gravity = -2.0f; CollisionHeader_GetVirtual(&gBlockMediumCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); } void EnPubox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnPubox* this = (EnPubox*)thisx; + EnPubox* pthis = (EnPubox*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } void EnPubox_Update(Actor* thisx, GlobalContext* globalCtx) { - EnPubox* this = (EnPubox*)thisx; + EnPubox* pthis = (EnPubox*)thisx; - thisx->speedXZ += this->dyna.unk_150; - thisx->world.rot.y = this->dyna.unk_158; + thisx->speedXZ += pthis->dyna.unk_150; + thisx->world.rot.y = pthis->dyna.unk_158; thisx->speedXZ = (thisx->speedXZ < -2.5f) ? -2.5f : ((thisx->speedXZ > 2.5f) ? 2.5f : thisx->speedXZ); Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); if (thisx->speedXZ != 0.0f) { Audio_PlaySoundGeneral(NA_SE_EV_ROCK_SLIDE - SFX_FLAG, &thisx->projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - this->dyna.unk_154 = 0.0f; - this->dyna.unk_150 = 0.0f; + pthis->dyna.unk_154 = 0.0f; + pthis->dyna.unk_150 = 0.0f; Actor_MoveForward(thisx); Actor_UpdateBgCheckInfo(globalCtx, thisx, thisx->colChkInfo.cylHeight, thisx->colChkInfo.cylRadius, thisx->colChkInfo.cylRadius, 0x1D); diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c deleted file mode 100644 index 1fa5695e3..000000000 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ /dev/null @@ -1,940 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RD_Z_EN_RD_C -#include "actor_common.h" -#include "z_en_rd.h" -#include "objects/object_rd/object_rd.h" -#include "def/code_800A9F30.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) - -void EnRd_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AE269C(EnRd* this); -void func_80AE2744(EnRd* this, GlobalContext* globalCtx); -void func_80AE2970(EnRd* this); -void func_80AE2A10(EnRd* this, GlobalContext* globalCtx); -void func_80AE2C1C(EnRd* this, GlobalContext* globalCtx); -void func_80AE2F50(EnRd* this, GlobalContext* globalCtx); -void func_80AE2FD0(EnRd* this, GlobalContext* globalCtx); -void func_80AE31DC(EnRd* this); -void func_80AE3260(EnRd* this, GlobalContext* globalCtx); -void func_80AE33F0(EnRd* this); -void func_80AE392C(EnRd* this); -void func_80AE39D4(EnRd* this); -void func_80AE3454(EnRd* this, GlobalContext* globalCtx); -void func_80AE37BC(EnRd* this); -void func_80AE3834(EnRd* this, GlobalContext* globalCtx); -void func_80AE3978(EnRd* this, GlobalContext* globalCtx); -void func_80AE3A54(EnRd* this, GlobalContext* globalCtx); -void func_80AE3B18(EnRd* this, GlobalContext* globalCtx); -void func_80AE3C98(EnRd* this, GlobalContext* globalCtx); -void func_80AE3ECC(EnRd* this, GlobalContext* globalCtx); - -const ActorInit En_Rd_InitVars = { - ACTOR_EN_RD, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_RD, - sizeof(EnRd), - (ActorFunc)EnRd_Init, - (ActorFunc)EnRd_Destroy, - (ActorFunc)EnRd_Update, - (ActorFunc)EnRd_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0xF), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(0, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0xE), - /* Ice magic */ DMG_ENTRY(0, 0x6), - /* Light magic */ DMG_ENTRY(3, 0xD), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0xF), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(2, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xF), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), -}; - -static Vec3f D_80AE4918 = { 0.0f, 0.0f, 0.0f }; - -// I'm guessing these are primitive and environment colors that go unused -static Color_RGBA8 D_80AE4924 = { 200, 200, 255, 255 }; -static Color_RGBA8 D_80AE4928 = { 0, 0, 255, 0 }; - -static Vec3f D_80AE492C = { 0.0f, 0.0f, 0.0f }; -static Color_RGBA8 D_80AE4938 = { 200, 200, 255, 255 }; -static Color_RGBA8 D_80AE493C = { 0, 0, 255, 0 }; - -static Vec3f D_80AE4940 = { 300.0f, 0.0f, 0.0f }; -static Vec3f D_80AE494C = { 300.0f, 0.0f, 0.0f }; -static Vec3f D_80AE4958 = { 0.25f, 0.25f, 0.25f }; - -void EnRd_SetupAction(EnRd* this, EnRdActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { - EnRd* this = (EnRd*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - thisx->targetMode = 0; - thisx->colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - this->unk_310 = this->unk_30E = 0; - thisx->focus.pos = thisx->world.pos; - thisx->focus.pos.y += 50.0f; - thisx->colChkInfo.mass = MASS_HEAVY; - thisx->colChkInfo.health = 8; - this->unk_314 = this->unk_31D = 0xFF; - this->unk_312 = (thisx->params & 0xFF00) >> 8; - - if (thisx->params & 0x80) { - thisx->params |= 0xFF00; - } else { - thisx->params &= 0xFF; - } - - if (thisx->params >= -1) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_00E778, &object_rd_Anim_0087D0, - this->jointTable, this->morphTable, 26); - thisx->naviEnemyId = 0x2A; - } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_003DD8, &object_rd_Anim_0087D0, - this->jointTable, this->morphTable, 26); - thisx->naviEnemyId = 0x2D; - } - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - - if (thisx->params >= -2) { - func_80AE269C(this); - } else { - func_80AE2970(this); - } - - SkelAnime_Update(&this->skelAnime); - - if (thisx->params == 3) { - thisx->flags |= ACTOR_FLAG_7; - } -} - -void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnRd* this = (EnRd*)thisx; - - if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { - gSaveContext.sunsSongState = SUNSSONG_INACTIVE; - } - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AE2630(GlobalContext* globalCtx, Actor* thisx, s32 arg2) { - Actor* enemyIt = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].head; - - while (enemyIt != NULL) { - if ((enemyIt->id != ACTOR_EN_RD) || (enemyIt == thisx) || (enemyIt->params < 0)) { - enemyIt = enemyIt->next; - continue; - } - - if (arg2 != 0) { - enemyIt->parent = thisx; - } else if (enemyIt->parent == thisx) { - enemyIt->parent = NULL; - } - enemyIt = enemyIt->next; - } -} - -void func_80AE269C(EnRd* this) { - if (this->actor.params != 2) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_0087D0, -6.0f); - } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_005D98); - } - - this->unk_31B = 0; - this->unk_30C = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnRd_SetupAction(this, func_80AE2744); -} - -void func_80AE2744(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x64, 0); - - if ((this->actor.params == 2) && (0.0f == this->skelAnime.curFrame)) { - if (Rand_ZeroOne() >= 0.5f) { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_005D98); - } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0057AC); - } - } else { - this->unk_30C--; - if (this->unk_30C == 0) { - this->unk_30C = (Rand_ZeroOne() * 10.0f) + 10.0f; - this->skelAnime.curFrame = 0.0f; - } - } - - if (this->actor.parent != NULL) { - if (this->unk_305 == 0) { - if (this->actor.params != 2) { - func_80AE31DC(this); - } else { - func_80AE392C(this); - } - } - } else { - if (this->unk_305 != 0) { - if (this->actor.params != 2) { - func_80AE37BC(this); - } else { - func_80AE392C(this); - } - } - - this->unk_305 = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_8002DDE4(globalCtx)) { - if ((this->actor.params != 2) && (this->unk_305 == 0)) { - func_80AE37BC(this); - } else { - func_80AE392C(this); - } - } - } - - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); - } -} - -void func_80AE2970(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0087D0, 0, 0, Animation_GetLastFrame(&object_rd_Anim_0087D0), - ANIMMODE_LOOP, -6.0f); - this->unk_31B = 11; - this->unk_30C = 6; - this->actor.shape.rot.x = -0x4000; - this->actor.gravity = 0.0f; - this->actor.shape.yOffset = 0.0f; - this->actor.speedXZ = 0.0f; - EnRd_SetupAction(this, func_80AE2A10); -} - -// Rising out of coffin -void func_80AE2A10(EnRd* this, GlobalContext* globalCtx) { - if (this->actor.shape.rot.x != -0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); - if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 2.0f, 0.3f) == 0.0f) { - this->actor.gravity = -3.5f; - func_80AE269C(this); - } - } else { - if (this->actor.world.pos.y == this->actor.home.pos.y) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); - } - if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { - if (this->unk_30C != 0) { - this->unk_30C--; - Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.3f, 1.0f, 0.3f); - } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); - } - } - } -} - -void func_80AE2B90(EnRd* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00EFDC, 1.0f, 4.0f, - Animation_GetLastFrame(&object_rd_Anim_00EFDC), ANIMMODE_LOOP_INTERP, -4.0f); - this->actor.speedXZ = 0.4f; - this->unk_31B = 4; - EnRd_SetupAction(this, func_80AE2C1C); -} - -void func_80AE2C1C(EnRd* this, GlobalContext* globalCtx) { - Vec3f sp44 = D_80AE4918; - Color_RGBA8 sp40 = D_80AE4924; - Color_RGBA8 sp3C = D_80AE4928; - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 sp32 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y - this->unk_30E - this->unk_310; - - this->skelAnime.playSpeed = this->actor.speedXZ; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA, 0); - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x64, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_Update(&this->skelAnime); - - if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_80AE2F50(this, globalCtx); - } - - if ((ABS(sp32) < 0x1554) && (Actor_WorldDistXYZToActor(&this->actor, &player->actor) <= 150.0f)) { - if (!(player->stateFlags1 & 0x2C6080) && !(player->stateFlags2 & 0x80)) { - if (this->unk_306 == 0) { - if (!(this->unk_312 & 0x80)) { - player->actor.freezeTimer = 40; - func_8008EEAC(globalCtx, &this->actor); - GET_PLAYER(globalCtx)->unk_684 = &this->actor; - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); - } - this->unk_306 = 0x3C; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); - } - } else { - func_80AE2F50(this, globalCtx); - } - } - - if (this->unk_307 != 0) { - this->unk_307--; - } - - if (!this->unk_307 && (Actor_WorldDistXYZToActor(&this->actor, &player->actor) <= 45.0f) && - Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - player->actor.freezeTimer = 0; - if (globalCtx->grabPlayer(globalCtx, player)) { - this->actor.flags &= ~ACTOR_FLAG_0; - func_80AE33F0(this); - } - } else if (this->actor.params > 0) { - if (this->actor.parent != NULL) { - func_80AE31DC(this); - } else { - this->unk_305 = 0; - } - } - - if ((this->skelAnime.curFrame == 10.0f) || (this->skelAnime.curFrame == 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); - } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); - } -} - -void func_80AE2F50(EnRd* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00EFDC, 0.5f, 0, Animation_GetLastFrame(&object_rd_Anim_00EFDC), - ANIMMODE_LOOP_INTERP, -4.0f); - this->unk_31B = 2; - EnRd_SetupAction(this, func_80AE2FD0); -} - -void func_80AE2FD0(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 targetY = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - - if (Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos) >= 5.0f) { - Math_SmoothStepToS(&this->actor.shape.rot.y, targetY, 1, 0x1C2, 0); - } else { - this->actor.speedXZ = 0.0f; - if (Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 0x1C2, 0) == 0) { - if (this->actor.params != 2) { - func_80AE269C(this); - } else { - func_80AE39D4(this); - } - } - } - - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x64, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_Update(&this->skelAnime); - - if (!(player->stateFlags1 & 0x2C6080) && !(player->stateFlags2 & 0x80) && - (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { - this->actor.targetMode = 0; - func_80AE2B90(this, globalCtx); - } else if (this->actor.params > 0) { - if (this->actor.parent != NULL) { - func_80AE31DC(this); - } else { - this->unk_305 = 0; - } - } - - if (this->skelAnime.curFrame == 10.0f || this->skelAnime.curFrame == 22.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); - } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); - } -} - -void func_80AE31DC(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00EFDC, 0.5f, 0, Animation_GetLastFrame(&object_rd_Anim_00EFDC), - ANIMMODE_LOOP_INTERP, -4.0f); - this->unk_31B = 3; - this->unk_305 = 1; - EnRd_SetupAction(this, func_80AE3260); -} - -void func_80AE3260(EnRd* this, GlobalContext* globalCtx) { - if (this->actor.parent != NULL) { - s32 pad; - s16 targetY; - Vec3f thisPos = this->actor.parent->world.pos; - - targetY = Actor_WorldYawTowardPoint(&this->actor, &thisPos); - - Math_SmoothStepToS(&this->actor.shape.rot.y, targetY, 1, 0xFA, 0); - - if (Actor_WorldDistXYZToPoint(&this->actor, &thisPos) >= 45.0f) { - this->actor.speedXZ = 0.4f; - } else { - this->actor.speedXZ = 0.0f; - - if (this->actor.params != 2) { - func_80AE269C(this); - } else { - func_80AE39D4(this); - } - } - - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x64, 0); - } else { - func_80AE2B90(this, globalCtx); - } - - this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_Update(&this->skelAnime); - - if (this->skelAnime.curFrame == 10.0f || this->skelAnime.curFrame == 22.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); - } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); - } -} - -void func_80AE33F0(EnRd* this) { - Animation_PlayOnce(&this->skelAnime, &object_rd_Anim_004ADC); - this->unk_30C = this->unk_304 = 0; - this->unk_319 = 200; - this->unk_31B = 8; - this->actor.speedXZ = 0.0f; - EnRd_SetupAction(this, func_80AE3454); -} - -void func_80AE3454(EnRd* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_304++; - } - - switch (this->unk_304) { - case 1: - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_004268); - this->unk_304++; - globalCtx->damagePlayer(globalCtx, -8); - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 1, 0xC); - this->unk_319 = 20; - case 0: - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x5DC, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x5DC, 0); - case 2: - if (!(player->stateFlags2 & 0x80)) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0046F8, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0046F8), ANIMMODE_ONCE_INTERP, 0.0f); - this->unk_304++; - this->unk_31B = 4; - return; - } - - if (!LINK_IS_ADULT) { - Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); - } - - Math_SmoothStepToF(&this->actor.world.pos.x, - (Math_SinS(player->actor.shape.rot.y) * -25.0f) + player->actor.world.pos.x, 1.0f, 10.0f, - 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 1.0f, 10.0f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, - (Math_CosS(player->actor.shape.rot.y) * -25.0f) + player->actor.world.pos.z, 1.0f, 10.0f, - 0.0f); - Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0); - - if (this->skelAnime.curFrame == 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); - } - this->unk_319--; - - if (this->unk_319 == 0) { - globalCtx->damagePlayer(globalCtx, -8); - func_800AA000(this->actor.xzDistToPlayer, 0xF0, 1, 0xC); - this->unk_319 = 20; - func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); - } - break; - case 3: - if (!LINK_IS_ADULT) { - Math_SmoothStepToF(&this->actor.shape.yOffset, 0, 1.0f, 400.0f, 0.0f); - } - break; - case 4: - if (!LINK_IS_ADULT) { - Math_SmoothStepToF(&this->actor.shape.yOffset, 0, 1.0f, 400.0f, 0.0f); - } - this->actor.targetMode = 0; - this->actor.flags |= ACTOR_FLAG_0; - this->unk_306 = 0xA; - this->unk_307 = 0xF; - func_80AE2B90(this, globalCtx); - break; - } -} - -void func_80AE37BC(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_004F94, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_004F94), ANIMMODE_ONCE, 0.0f); - this->unk_31B = 7; - EnRd_SetupAction(this, func_80AE3834); -} - -void func_80AE3834(EnRd* this, GlobalContext* globalCtx) { - Vec3f sp34 = D_80AE492C; - Color_RGBA8 sp30 = D_80AE4938; - Color_RGBA8 sp2C = D_80AE493C; - Player* player = GET_PLAYER(globalCtx); - s16 temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y - this->unk_30E - this->unk_310; - - if (ABS(temp_v0) < 0x2008) { - if (!(this->unk_312 & 0x80)) { - player->actor.freezeTimer = 60; - func_800AA000(this->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); - func_8008EEAC(globalCtx, &this->actor); - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); - func_80AE2B90(this, globalCtx); - } -} - -void func_80AE392C(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_008040, -4.0f); - this->unk_31B = 5; - EnRd_SetupAction(this, func_80AE3978); -} - -void func_80AE3978(EnRd* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.parent != NULL) { - func_80AE31DC(this); - } else { - func_80AE37BC(this); - } - } -} - -void func_80AE39D4(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_008040, -1.0f, Animation_GetLastFrame(&object_rd_Anim_008040), - 0.0f, ANIMMODE_ONCE, -4.0f); - this->unk_31B = 6; - EnRd_SetupAction(this, func_80AE3A54); -} - -void func_80AE3A54(EnRd* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - func_80AE269C(this); - } -} - -void func_80AE3A8C(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_0074F0, -6.0f); - - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -2.0f; - } - - this->actor.flags |= ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_31B = 9; - EnRd_SetupAction(this, func_80AE3B18); -} - -void func_80AE3B18(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; - } - - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x12C, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x12C, 0); - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (this->actor.parent != NULL) { - func_80AE31DC(this); - } else if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_80AE2F50(this, globalCtx); - } else { - func_80AE2B90(this, globalCtx); - } - - this->unk_31D = 0xFF; - } -} - -void func_80AE3C20(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_006E88, -1.0f); - this->unk_31B = 10; - this->unk_30C = 300; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); - EnRd_SetupAction(this, func_80AE3C98); -} - -void func_80AE3C98(EnRd* this, GlobalContext* globalCtx) { - if (this->actor.category != ACTORCAT_PROP) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - } - - Math_SmoothStepToS(&this->unk_30E, 0, 1, 0x7D0, 0); - Math_SmoothStepToS(&this->unk_310, 0, 1, 0x7D0, 0); - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_30C == 0) { - if (!Flags_GetSwitch(globalCtx, this->unk_312 & 0x7F)) { - Flags_SetSwitch(globalCtx, this->unk_312 & 0x7F); - } - if (this->unk_314 != 0) { - if (this->unk_314 == 0xB4) { - func_80AE2630(globalCtx, &this->actor, 0); - } - this->actor.scale.y -= 0.000075f; - this->unk_314 -= 5; - } else { - Actor_Kill(&this->actor); - } - } else { - this->unk_30C--; - } - } else if (((s32)this->skelAnime.curFrame == 33) || ((s32)this->skelAnime.curFrame == 40)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } -} - -void func_80AE3DE4(EnRd* this) { - this->unk_31B = 1; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { - this->unk_318 = 1; - this->unk_316 = 0x258; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); - Actor_SetColorFilter(&this->actor, -0x8000, -0x7F38, 0, 0xFF); - } else if (this->unk_31C == 1) { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x50); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); - Actor_SetColorFilter(&this->actor, -0x8000, 0xC8, 0, 0x50); - } - EnRd_SetupAction(this, func_80AE3ECC); -} - -void func_80AE3ECC(EnRd* this, GlobalContext* globalCtx) { - if ((this->unk_318 != 0) && (this->unk_316 != 0)) { - this->unk_316--; - if (this->unk_316 >= 0xFF) { - Actor_SetColorFilter(&this->actor, -0x8000, 0xC8, 0, 0xFF); - } - if (this->unk_316 == 0) { - this->unk_318 = 0; - gSaveContext.sunsSongState = SUNSSONG_INACTIVE; - } - } - - if (this->actor.colorFilterTimer == 0) { - if (this->actor.colChkInfo.health == 0) { - func_80AE2630(globalCtx, &this->actor, 1); - func_80AE3C20(this); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); - } else { - func_80AE3A8C(this); - } - } -} - -void func_80AE3F9C(EnRd* this, GlobalContext* globalCtx) { - s16 temp1; - s16 temp2; - s16 temp3; - - temp1 = this->actor.yawTowardsPlayer - (s16)(this->actor.shape.rot.y + this->unk_310); - temp2 = CLAMP(temp1, -500, 500); - - temp1 -= this->unk_30E; - temp3 = CLAMP(temp1, -500, 500); - - if ((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) >= 0) { - this->unk_310 += ABS(temp2); - this->unk_30E += ABS(temp3); - } else { - this->unk_310 -= ABS(temp2); - this->unk_30E -= ABS(temp3); - } - - this->unk_310 = CLAMP(this->unk_310, -18783, 18783); - this->unk_30E = CLAMP(this->unk_30E, -9583, 9583); -} - -void func_80AE4114(EnRd* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && (this->unk_318 == 0) && - (this->unk_31B != 9) && (this->unk_31B != 10) && (this->unk_31B != 1)) { - func_80AE3DE4(this); - return; - } - - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - this->unk_31C = this->actor.colChkInfo.damageEffect; - - if (this->unk_31B != 11) { - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if (player->unk_844 != 0) { - this->unk_31D = player->unk_845; - } - - if ((this->unk_31C != 0) && (this->unk_31C != 6)) { - if (((this->unk_31C == 1) || (this->unk_31C == 13)) && (this->unk_31B != 1)) { - Actor_ApplyDamage(&this->actor); - func_80AE3DE4(this); - return; - } - - this->unk_318 = 0; - this->unk_316 = 0; - - if (this->unk_31C == 0xE) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x50); - this->unk_31A = 0x28; - } else { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - } - - Actor_ApplyDamage(&this->actor); - if (this->actor.colChkInfo.health == 0) { - func_80AE2630(globalCtx, &this->actor, 1); - func_80AE3C20(this); - Item_DropCollectibleRandom(globalCtx, 0, &this->actor.world.pos, 0x90); - } else { - func_80AE3A8C(this); - } - } - } - } -} - -void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnRd* this = (EnRd*)thisx; - Player* player = GET_PLAYER(globalCtx); - s32 pad2; - - func_80AE4114(this, globalCtx); - - if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE && this->unk_318 == 0) { - gSaveContext.sunsSongState = SUNSSONG_INACTIVE; - } - - if (this->unk_31C != 6 && ((this->unk_31B != 11) || (this->unk_31C != 14))) { - if (this->unk_306 != 0) { - this->unk_306--; - } - - this->actionFunc(this, globalCtx); - if (this->unk_31B != 8 && this->actor.speedXZ != 0.0f) { - Actor_MoveForward(&this->actor); - } - - if ((this->actor.shape.rot.x == 0) && (this->unk_31B != 8) && (this->actor.speedXZ != 0.0f)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); - } - - if (this->unk_31B == 7) { - func_80AE3F9C(this, globalCtx); - } - } - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 50.0f; - - if ((this->actor.colChkInfo.health > 0) && (this->unk_31B != 8)) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if ((this->unk_31B != 9) || ((player->unk_844 != 0) && (player->unk_845 != this->unk_31D))) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } -} - -s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnRd* this = (EnRd*)thisx; - - if (limbIndex == 23) { - rot->y += this->unk_30E; - } else if (limbIndex == 12) { - rot->y += this->unk_310; - } - return false; -} - -void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - Vec3f sp2C = D_80AE4940; - EnRd* this = (EnRd*)thisx; - s32 idx = -1; - Vec3f destPos; - - if ((this->unk_31A != 0) || ((this->actor.colorFilterTimer != 0) && (this->actor.colorFilterParams & 0x4000))) { - switch (limbIndex - 1) { - case 23: - idx = 0; - break; - case 0: - idx = 1; - break; - case 21: - idx = 2; - break; - case 17: - idx = 3; - break; - case 13: - idx = 4; - break; - case 24: - idx = 5; - break; - case 8: - idx = 6; - break; - case 3: - idx = 7; - break; - case 10: - idx = 8; - break; - case 5: - idx = 9; - break; - } - - if (idx >= 0) { - Matrix_MultVec3f(&sp2C, &destPos); - this->firePos[idx].x = destPos.x; - this->firePos[idx].y = destPos.y; - this->firePos[idx].z = destPos.z; - } - } -} - -void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnRd* this = (EnRd*)thisx; - Vec3f thisPos = thisx->world.pos; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rd.c", 1679); - - if (this->unk_314 == 0xFF) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_314); - gSPSegment(POLY_OPA_DISP++, 8, &D_80116280[2]); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, this, - POLY_OPA_DISP); - func_80033C30(&thisPos, &D_80AE4958, 255, globalCtx); - if (this->unk_31A != 0) { - thisx->colorFilterTimer++; - this->unk_31A--; - if (this->unk_31A % 4 == 0) { - EffectSsEnFire_SpawnVec3s(globalCtx, thisx, &this->firePos[this->unk_31A >> 2], 0x4B, 0, 0, - (this->unk_31A >> 2)); - } - } - } else { - func_80093D84(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_314); - gSPSegment(POLY_XLU_DISP++, 8, &D_80116280[0]); - POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - - func_80033C30(&thisPos, &D_80AE4958, this->unk_314, globalCtx); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rd.c", 1735); -} diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.cpp b/src/overlays/actors/ovl_En_Rd/z_en_rd.cpp new file mode 100644 index 000000000..e8bfa3395 --- /dev/null +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.cpp @@ -0,0 +1,940 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RD_Z_EN_RD_C +#include "actor_common.h" +#include "z_en_rd.h" +#include "objects/object_rd/object_rd.h" +#include "def/code_800A9F30.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) + +void EnRd_Init(Actor* thisx, GlobalContext* globalCtx); +void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); +void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AE269C(EnRd* pthis); +void func_80AE2744(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE2970(EnRd* pthis); +void func_80AE2A10(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE2C1C(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE2F50(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE2FD0(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE31DC(EnRd* pthis); +void func_80AE3260(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE33F0(EnRd* pthis); +void func_80AE392C(EnRd* pthis); +void func_80AE39D4(EnRd* pthis); +void func_80AE3454(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE37BC(EnRd* pthis); +void func_80AE3834(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE3978(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE3A54(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE3B18(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE3C98(EnRd* pthis, GlobalContext* globalCtx); +void func_80AE3ECC(EnRd* pthis, GlobalContext* globalCtx); + +ActorInit En_Rd_InitVars = { + ACTOR_EN_RD, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_RD, + sizeof(EnRd), + (ActorFunc)EnRd_Init, + (ActorFunc)EnRd_Destroy, + (ActorFunc)EnRd_Update, + (ActorFunc)EnRd_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0xF), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(0, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0xE), + /* Ice magic */ DMG_ENTRY(0, 0x6), + /* Light magic */ DMG_ENTRY(3, 0xD), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(2, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), +}; + +static Vec3f D_80AE4918 = { 0.0f, 0.0f, 0.0f }; + +// I'm guessing these are primitive and environment colors that go unused +static Color_RGBA8 D_80AE4924 = { 200, 200, 255, 255 }; +static Color_RGBA8 D_80AE4928 = { 0, 0, 255, 0 }; + +static Vec3f D_80AE492C = { 0.0f, 0.0f, 0.0f }; +static Color_RGBA8 D_80AE4938 = { 200, 200, 255, 255 }; +static Color_RGBA8 D_80AE493C = { 0, 0, 255, 0 }; + +static Vec3f D_80AE4940 = { 300.0f, 0.0f, 0.0f }; +static Vec3f D_80AE494C = { 300.0f, 0.0f, 0.0f }; +static Vec3f D_80AE4958 = { 0.25f, 0.25f, 0.25f }; + +void EnRd_SetupAction(EnRd* pthis, EnRdActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRd* pthis = (EnRd*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + thisx->targetMode = 0; + thisx->colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + pthis->unk_310 = pthis->unk_30E = 0; + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 50.0f; + thisx->colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.health = 8; + pthis->unk_314 = pthis->unk_31D = 0xFF; + pthis->unk_312 = (thisx->params & 0xFF00) >> 8; + + if (thisx->params & 0x80) { + thisx->params |= 0xFF00; + } else { + thisx->params &= 0xFF; + } + + if (thisx->params >= -1) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_rd_Skel_00E778, &object_rd_Anim_0087D0, + pthis->jointTable, pthis->morphTable, 26); + thisx->naviEnemyId = 0x2A; + } else { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_rd_Skel_003DD8, &object_rd_Anim_0087D0, + pthis->jointTable, pthis->morphTable, 26); + thisx->naviEnemyId = 0x2D; + } + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + + if (thisx->params >= -2) { + func_80AE269C(pthis); + } else { + func_80AE2970(pthis); + } + + SkelAnime_Update(&pthis->skelAnime); + + if (thisx->params == 3) { + thisx->flags |= ACTOR_FLAG_7; + } +} + +void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRd* pthis = (EnRd*)thisx; + + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + } + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AE2630(GlobalContext* globalCtx, Actor* thisx, s32 arg2) { + Actor* enemyIt = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].head; + + while (enemyIt != NULL) { + if ((enemyIt->id != ACTOR_EN_RD) || (enemyIt == thisx) || (enemyIt->params < 0)) { + enemyIt = enemyIt->next; + continue; + } + + if (arg2 != 0) { + enemyIt->parent = thisx; + } else if (enemyIt->parent == thisx) { + enemyIt->parent = NULL; + } + enemyIt = enemyIt->next; + } +} + +void func_80AE269C(EnRd* pthis) { + if (pthis->actor.params != 2) { + Animation_MorphToLoop(&pthis->skelAnime, &object_rd_Anim_0087D0, -6.0f); + } else { + Animation_PlayLoop(&pthis->skelAnime, &object_rd_Anim_005D98); + } + + pthis->unk_31B = 0; + pthis->unk_30C = (Rand_ZeroOne() * 10.0f) + 5.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnRd_SetupAction(pthis, func_80AE2744); +} + +void func_80AE2744(EnRd* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x64, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x64, 0); + + if ((pthis->actor.params == 2) && (0.0f == pthis->skelAnime.curFrame)) { + if (Rand_ZeroOne() >= 0.5f) { + Animation_PlayLoop(&pthis->skelAnime, &object_rd_Anim_005D98); + } else { + Animation_PlayLoop(&pthis->skelAnime, &object_rd_Anim_0057AC); + } + } else { + pthis->unk_30C--; + if (pthis->unk_30C == 0) { + pthis->unk_30C = (Rand_ZeroOne() * 10.0f) + 10.0f; + pthis->skelAnime.curFrame = 0.0f; + } + } + + if (pthis->actor.parent != NULL) { + if (pthis->unk_305 == 0) { + if (pthis->actor.params != 2) { + func_80AE31DC(pthis); + } else { + func_80AE392C(pthis); + } + } + } else { + if (pthis->unk_305 != 0) { + if (pthis->actor.params != 2) { + func_80AE37BC(pthis); + } else { + func_80AE392C(pthis); + } + } + + pthis->unk_305 = 0; + if ((pthis->actor.xzDistToPlayer <= 150.0f) && func_8002DDE4(globalCtx)) { + if ((pthis->actor.params != 2) && (pthis->unk_305 == 0)) { + func_80AE37BC(pthis); + } else { + func_80AE392C(pthis); + } + } + } + + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_80AE2970(EnRd* pthis) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_0087D0, 0, 0, Animation_GetLastFrame(&object_rd_Anim_0087D0), + ANIMMODE_LOOP, -6.0f); + pthis->unk_31B = 11; + pthis->unk_30C = 6; + pthis->actor.shape.rot.x = -0x4000; + pthis->actor.gravity = 0.0f; + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.speedXZ = 0.0f; + EnRd_SetupAction(pthis, func_80AE2A10); +} + +// Rising out of coffin +void func_80AE2A10(EnRd* pthis, GlobalContext* globalCtx) { + if (pthis->actor.shape.rot.x != -0x4000) { + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 0x7D0, 0); + if (Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.3f, 2.0f, 0.3f) == 0.0f) { + pthis->actor.gravity = -3.5f; + func_80AE269C(pthis); + } + } else { + if (pthis->actor.world.pos.y == pthis->actor.home.pos.y) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_CRY); + } + if (Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { + if (pthis->unk_30C != 0) { + pthis->unk_30C--; + Math_SmoothStepToF(&pthis->actor.speedXZ, 6.0f, 0.3f, 1.0f, 0.3f); + } else if (Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 0x7D0, 0); + } + } + } +} + +void func_80AE2B90(EnRd* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_00EFDC, 1.0f, 4.0f, + Animation_GetLastFrame(&object_rd_Anim_00EFDC), ANIMMODE_LOOP_INTERP, -4.0f); + pthis->actor.speedXZ = 0.4f; + pthis->unk_31B = 4; + EnRd_SetupAction(pthis, func_80AE2C1C); +} + +void func_80AE2C1C(EnRd* pthis, GlobalContext* globalCtx) { + Vec3f sp44 = D_80AE4918; + Color_RGBA8 sp40 = D_80AE4924; + Color_RGBA8 sp3C = D_80AE4928; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 sp32 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y - pthis->unk_30E - pthis->unk_310; + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA, 0); + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x64, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x64, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + SkelAnime_Update(&pthis->skelAnime); + + if (Actor_WorldDistXYZToPoint(&player->actor, &pthis->actor.home.pos) >= 150.0f) { + func_80AE2F50(pthis, globalCtx); + } + + if ((ABS(sp32) < 0x1554) && (Actor_WorldDistXYZToActor(&pthis->actor, &player->actor) <= 150.0f)) { + if (!(player->stateFlags1 & 0x2C6080) && !(player->stateFlags2 & 0x80)) { + if (pthis->unk_306 == 0) { + if (!(pthis->unk_312 & 0x80)) { + player->actor.freezeTimer = 40; + func_8008EEAC(globalCtx, &pthis->actor); + GET_PLAYER(globalCtx)->unk_684 = &pthis->actor; + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + } + pthis->unk_306 = 0x3C; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_AIM); + } + } else { + func_80AE2F50(pthis, globalCtx); + } + } + + if (pthis->unk_307 != 0) { + pthis->unk_307--; + } + + if (!pthis->unk_307 && (Actor_WorldDistXYZToActor(&pthis->actor, &player->actor) <= 45.0f) && + Actor_IsFacingPlayer(&pthis->actor, 0x38E3)) { + player->actor.freezeTimer = 0; + if (globalCtx->grabPlayer(globalCtx, player)) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + func_80AE33F0(pthis); + } + } else if (pthis->actor.params > 0) { + if (pthis->actor.parent != NULL) { + func_80AE31DC(pthis); + } else { + pthis->unk_305 = 0; + } + } + + if ((pthis->skelAnime.curFrame == 10.0f) || (pthis->skelAnime.curFrame == 22.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_WALK); + } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_80AE2F50(EnRd* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_00EFDC, 0.5f, 0, Animation_GetLastFrame(&object_rd_Anim_00EFDC), + ANIMMODE_LOOP_INTERP, -4.0f); + pthis->unk_31B = 2; + EnRd_SetupAction(pthis, func_80AE2FD0); +} + +void func_80AE2FD0(EnRd* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 targetY = Actor_WorldYawTowardPoint(&pthis->actor, &pthis->actor.home.pos); + + if (Actor_WorldDistXYZToPoint(&pthis->actor, &pthis->actor.home.pos) >= 5.0f) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, targetY, 1, 0x1C2, 0); + } else { + pthis->actor.speedXZ = 0.0f; + if (Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.home.rot.y, 1, 0x1C2, 0) == 0) { + if (pthis->actor.params != 2) { + func_80AE269C(pthis); + } else { + func_80AE39D4(pthis); + } + } + } + + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x64, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x64, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + SkelAnime_Update(&pthis->skelAnime); + + if (!(player->stateFlags1 & 0x2C6080) && !(player->stateFlags2 & 0x80) && + (Actor_WorldDistXYZToPoint(&player->actor, &pthis->actor.home.pos) < 150.0f)) { + pthis->actor.targetMode = 0; + func_80AE2B90(pthis, globalCtx); + } else if (pthis->actor.params > 0) { + if (pthis->actor.parent != NULL) { + func_80AE31DC(pthis); + } else { + pthis->unk_305 = 0; + } + } + + if (pthis->skelAnime.curFrame == 10.0f || pthis->skelAnime.curFrame == 22.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_WALK); + } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_80AE31DC(EnRd* pthis) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_00EFDC, 0.5f, 0, Animation_GetLastFrame(&object_rd_Anim_00EFDC), + ANIMMODE_LOOP_INTERP, -4.0f); + pthis->unk_31B = 3; + pthis->unk_305 = 1; + EnRd_SetupAction(pthis, func_80AE3260); +} + +void func_80AE3260(EnRd* pthis, GlobalContext* globalCtx) { + if (pthis->actor.parent != NULL) { + s32 pad; + s16 targetY; + Vec3f thisPos = pthis->actor.parent->world.pos; + + targetY = Actor_WorldYawTowardPoint(&pthis->actor, &thisPos); + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, targetY, 1, 0xFA, 0); + + if (Actor_WorldDistXYZToPoint(&pthis->actor, &thisPos) >= 45.0f) { + pthis->actor.speedXZ = 0.4f; + } else { + pthis->actor.speedXZ = 0.0f; + + if (pthis->actor.params != 2) { + func_80AE269C(pthis); + } else { + func_80AE39D4(pthis); + } + } + + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x64, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x64, 0); + } else { + func_80AE2B90(pthis, globalCtx); + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->skelAnime.curFrame == 10.0f || pthis->skelAnime.curFrame == 22.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_WALK); + } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_80AE33F0(EnRd* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &object_rd_Anim_004ADC); + pthis->unk_30C = pthis->unk_304 = 0; + pthis->unk_319 = 200; + pthis->unk_31B = 8; + pthis->actor.speedXZ = 0.0f; + EnRd_SetupAction(pthis, func_80AE3454); +} + +void func_80AE3454(EnRd* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_304++; + } + + switch (pthis->unk_304) { + case 1: + Animation_PlayLoop(&pthis->skelAnime, &object_rd_Anim_004268); + pthis->unk_304++; + globalCtx->damagePlayer(globalCtx, -8); + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 1, 0xC); + pthis->unk_319 = 20; + case 0: + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x5DC, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x5DC, 0); + case 2: + if (!(player->stateFlags2 & 0x80)) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_0046F8, 0.5f, 0.0f, + Animation_GetLastFrame(&object_rd_Anim_0046F8), ANIMMODE_ONCE_INTERP, 0.0f); + pthis->unk_304++; + pthis->unk_31B = 4; + return; + } + + if (!LINK_IS_ADULT) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); + } + + Math_SmoothStepToF(&pthis->actor.world.pos.x, + (Math_SinS(player->actor.shape.rot.y) * -25.0f) + player->actor.world.pos.x, 1.0f, 10.0f, + 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, player->actor.world.pos.y, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.z, + (Math_CosS(player->actor.shape.rot.y) * -25.0f) + player->actor.world.pos.z, 1.0f, 10.0f, + 0.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0); + + if (pthis->skelAnime.curFrame == 0.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_ATTACK); + } + pthis->unk_319--; + + if (pthis->unk_319 == 0) { + globalCtx->damagePlayer(globalCtx, -8); + func_800AA000(pthis->actor.xzDistToPlayer, 0xF0, 1, 0xC); + pthis->unk_319 = 20; + func_8002F7DC(&player->actor, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + } + break; + case 3: + if (!LINK_IS_ADULT) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0, 1.0f, 400.0f, 0.0f); + } + break; + case 4: + if (!LINK_IS_ADULT) { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0, 1.0f, 400.0f, 0.0f); + } + pthis->actor.targetMode = 0; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->unk_306 = 0xA; + pthis->unk_307 = 0xF; + func_80AE2B90(pthis, globalCtx); + break; + } +} + +void func_80AE37BC(EnRd* pthis) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_004F94, 0.0f, 0.0f, + Animation_GetLastFrame(&object_rd_Anim_004F94), ANIMMODE_ONCE, 0.0f); + pthis->unk_31B = 7; + EnRd_SetupAction(pthis, func_80AE3834); +} + +void func_80AE3834(EnRd* pthis, GlobalContext* globalCtx) { + Vec3f sp34 = D_80AE492C; + Color_RGBA8 sp30 = D_80AE4938; + Color_RGBA8 sp2C = D_80AE493C; + Player* player = GET_PLAYER(globalCtx); + s16 temp_v0 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y - pthis->unk_30E - pthis->unk_310; + + if (ABS(temp_v0) < 0x2008) { + if (!(pthis->unk_312 & 0x80)) { + player->actor.freezeTimer = 60; + func_800AA000(pthis->actor.xzDistToPlayer, 0xFF, 0x14, 0x96); + func_8008EEAC(globalCtx, &pthis->actor); + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_AIM); + func_80AE2B90(pthis, globalCtx); + } +} + +void func_80AE392C(EnRd* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_rd_Anim_008040, -4.0f); + pthis->unk_31B = 5; + EnRd_SetupAction(pthis, func_80AE3978); +} + +void func_80AE3978(EnRd* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.parent != NULL) { + func_80AE31DC(pthis); + } else { + func_80AE37BC(pthis); + } + } +} + +void func_80AE39D4(EnRd* pthis) { + Animation_Change(&pthis->skelAnime, &object_rd_Anim_008040, -1.0f, Animation_GetLastFrame(&object_rd_Anim_008040), + 0.0f, ANIMMODE_ONCE, -4.0f); + pthis->unk_31B = 6; + EnRd_SetupAction(pthis, func_80AE3A54); +} + +void func_80AE3A54(EnRd* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + func_80AE269C(pthis); + } +} + +void func_80AE3A8C(EnRd* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_rd_Anim_0074F0, -6.0f); + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = -2.0f; + } + + pthis->actor.flags |= ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_DAMAGE); + pthis->unk_31B = 9; + EnRd_SetupAction(pthis, func_80AE3B18); +} + +void func_80AE3B18(EnRd* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.15f; + } + + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x12C, 0); + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (pthis->actor.parent != NULL) { + func_80AE31DC(pthis); + } else if (Actor_WorldDistXYZToPoint(&player->actor, &pthis->actor.home.pos) >= 150.0f) { + func_80AE2F50(pthis, globalCtx); + } else { + func_80AE2B90(pthis, globalCtx); + } + + pthis->unk_31D = 0xFF; + } +} + +void func_80AE3C20(EnRd* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &object_rd_Anim_006E88, -1.0f); + pthis->unk_31B = 10; + pthis->unk_30C = 300; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_REDEAD_DEAD); + EnRd_SetupAction(pthis, func_80AE3C98); +} + +void func_80AE3C98(EnRd* pthis, GlobalContext* globalCtx) { + if (pthis->actor.category != ACTORCAT_PROP) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + } + + Math_SmoothStepToS(&pthis->unk_30E, 0, 1, 0x7D0, 0); + Math_SmoothStepToS(&pthis->unk_310, 0, 1, 0x7D0, 0); + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->unk_30C == 0) { + if (!Flags_GetSwitch(globalCtx, pthis->unk_312 & 0x7F)) { + Flags_SetSwitch(globalCtx, pthis->unk_312 & 0x7F); + } + if (pthis->unk_314 != 0) { + if (pthis->unk_314 == 0xB4) { + func_80AE2630(globalCtx, &pthis->actor, 0); + } + pthis->actor.scale.y -= 0.000075f; + pthis->unk_314 -= 5; + } else { + Actor_Kill(&pthis->actor); + } + } else { + pthis->unk_30C--; + } + } else if (((s32)pthis->skelAnime.curFrame == 33) || ((s32)pthis->skelAnime.curFrame == 40)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } +} + +void func_80AE3DE4(EnRd* pthis) { + pthis->unk_31B = 1; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { + pthis->unk_318 = 1; + pthis->unk_316 = 0x258; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIGHT_ARROW_HIT); + Actor_SetColorFilter(&pthis->actor, -0x8000, -0x7F38, 0, 0xFF); + } else if (pthis->unk_31C == 1) { + Actor_SetColorFilter(&pthis->actor, 0, 0xC8, 0, 0x50); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIGHT_ARROW_HIT); + Actor_SetColorFilter(&pthis->actor, -0x8000, 0xC8, 0, 0x50); + } + EnRd_SetupAction(pthis, func_80AE3ECC); +} + +void func_80AE3ECC(EnRd* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_318 != 0) && (pthis->unk_316 != 0)) { + pthis->unk_316--; + if (pthis->unk_316 >= 0xFF) { + Actor_SetColorFilter(&pthis->actor, -0x8000, 0xC8, 0, 0xFF); + } + if (pthis->unk_316 == 0) { + pthis->unk_318 = 0; + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + } + } + + if (pthis->actor.colorFilterTimer == 0) { + if (pthis->actor.colChkInfo.health == 0) { + func_80AE2630(globalCtx, &pthis->actor, 1); + func_80AE3C20(pthis); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x90); + } else { + func_80AE3A8C(pthis); + } + } +} + +void func_80AE3F9C(EnRd* pthis, GlobalContext* globalCtx) { + s16 temp1; + s16 temp2; + s16 temp3; + + temp1 = pthis->actor.yawTowardsPlayer - (s16)(pthis->actor.shape.rot.y + pthis->unk_310); + temp2 = CLAMP(temp1, -500, 500); + + temp1 -= pthis->unk_30E; + temp3 = CLAMP(temp1, -500, 500); + + if ((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) >= 0) { + pthis->unk_310 += ABS(temp2); + pthis->unk_30E += ABS(temp3); + } else { + pthis->unk_310 -= ABS(temp2); + pthis->unk_30E -= ABS(temp3); + } + + pthis->unk_310 = CLAMP(pthis->unk_310, -18783, 18783); + pthis->unk_30E = CLAMP(pthis->unk_30E, -9583, 9583); +} + +void func_80AE4114(EnRd* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (pthis->actor.shape.rot.x == 0) && (pthis->unk_318 == 0) && + (pthis->unk_31B != 9) && (pthis->unk_31B != 10) && (pthis->unk_31B != 1)) { + func_80AE3DE4(pthis); + return; + } + + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->unk_31C = pthis->actor.colChkInfo.damageEffect; + + if (pthis->unk_31B != 11) { + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if (player->unk_844 != 0) { + pthis->unk_31D = player->unk_845; + } + + if ((pthis->unk_31C != 0) && (pthis->unk_31C != 6)) { + if (((pthis->unk_31C == 1) || (pthis->unk_31C == 13)) && (pthis->unk_31B != 1)) { + Actor_ApplyDamage(&pthis->actor); + func_80AE3DE4(pthis); + return; + } + + pthis->unk_318 = 0; + pthis->unk_316 = 0; + + if (pthis->unk_31C == 0xE) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0x50); + pthis->unk_31A = 0x28; + } else { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + } + + Actor_ApplyDamage(&pthis->actor); + if (pthis->actor.colChkInfo.health == 0) { + func_80AE2630(globalCtx, &pthis->actor, 1); + func_80AE3C20(pthis); + Item_DropCollectibleRandom(globalCtx, 0, &pthis->actor.world.pos, 0x90); + } else { + func_80AE3A8C(pthis); + } + } + } + } +} + +void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRd* pthis = (EnRd*)thisx; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + + func_80AE4114(pthis, globalCtx); + + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE && pthis->unk_318 == 0) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + } + + if (pthis->unk_31C != 6 && ((pthis->unk_31B != 11) || (pthis->unk_31C != 14))) { + if (pthis->unk_306 != 0) { + pthis->unk_306--; + } + + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_31B != 8 && pthis->actor.speedXZ != 0.0f) { + Actor_MoveForward(&pthis->actor); + } + + if ((pthis->actor.shape.rot.x == 0) && (pthis->unk_31B != 8) && (pthis->actor.speedXZ != 0.0f)) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 20.0f, 35.0f, 0x1D); + } + + if (pthis->unk_31B == 7) { + func_80AE3F9C(pthis, globalCtx); + } + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 50.0f; + + if ((pthis->actor.colChkInfo.health > 0) && (pthis->unk_31B != 8)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if ((pthis->unk_31B != 9) || ((player->unk_844 != 0) && (player->unk_845 != pthis->unk_31D))) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } +} + +s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnRd* pthis = (EnRd*)thisx; + + if (limbIndex == 23) { + rot->y += pthis->unk_30E; + } else if (limbIndex == 12) { + rot->y += pthis->unk_310; + } + return false; +} + +void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + Vec3f sp2C = D_80AE4940; + EnRd* pthis = (EnRd*)thisx; + s32 idx = -1; + Vec3f destPos; + + if ((pthis->unk_31A != 0) || ((pthis->actor.colorFilterTimer != 0) && (pthis->actor.colorFilterParams & 0x4000))) { + switch (limbIndex - 1) { + case 23: + idx = 0; + break; + case 0: + idx = 1; + break; + case 21: + idx = 2; + break; + case 17: + idx = 3; + break; + case 13: + idx = 4; + break; + case 24: + idx = 5; + break; + case 8: + idx = 6; + break; + case 3: + idx = 7; + break; + case 10: + idx = 8; + break; + case 5: + idx = 9; + break; + } + + if (idx >= 0) { + Matrix_MultVec3f(&sp2C, &destPos); + pthis->firePos[idx].x = destPos.x; + pthis->firePos[idx].y = destPos.y; + pthis->firePos[idx].z = destPos.z; + } + } +} + +void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRd* pthis = (EnRd*)thisx; + Vec3f thisPos = thisx->world.pos; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rd.c", 1679); + + if (pthis->unk_314 == 0xFF) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, pthis->unk_314); + gSPSegment(POLY_OPA_DISP++, 8, &D_80116280[2]); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, pthis, + POLY_OPA_DISP); + func_80033C30(&thisPos, &D_80AE4958, 255, globalCtx); + if (pthis->unk_31A != 0) { + thisx->colorFilterTimer++; + pthis->unk_31A--; + if (pthis->unk_31A % 4 == 0) { + EffectSsEnFire_SpawnVec3s(globalCtx, thisx, &pthis->firePos[pthis->unk_31A >> 2], 0x4B, 0, 0, + (pthis->unk_31A >> 2)); + } + } + } else { + func_80093D84(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->unk_314); + gSPSegment(POLY_XLU_DISP++, 8, &D_80116280[0]); + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + + func_80033C30(&thisPos, &D_80AE4958, pthis->unk_314, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rd.c", 1735); +} diff --git a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c deleted file mode 100644 index 9297991bc..000000000 --- a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c +++ /dev/null @@ -1,678 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_REEBA_Z_EN_REEBA_C -#include "actor_common.h" - -/* - * File: z_en_reeba.c - * Overlay: ovl_En_Reeba - * Description: Leever - */ - -#include "z_en_reeba.h" -#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" -#include "vt.h" -#include "objects/object_reeba/object_reeba.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_27) - -void EnReeba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnReeba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnReeba_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AE4F40(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5054(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5270(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5688(EnReeba* this, GlobalContext* globalCtx); -void func_80AE56E0(EnReeba* this, GlobalContext* globalCtx); -void func_80AE538C(EnReeba* this, GlobalContext* globalCtx); -void func_80AE53AC(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5E48(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5854(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5C38(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5938(EnReeba* this, GlobalContext* globalCtx); -void func_80AE5A9C(EnReeba* this, GlobalContext* globalCtx); - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(2, 0xE), - /* Slingshot */ DMG_ENTRY(1, 0xE), - /* Explosive */ DMG_ENTRY(2, 0xE), - /* Boomerang */ DMG_ENTRY(1, 0xC), - /* Normal arrow */ DMG_ENTRY(2, 0xE), - /* Hammer swing */ DMG_ENTRY(2, 0xE), - /* Hookshot */ DMG_ENTRY(2, 0xD), - /* Kokiri sword */ DMG_ENTRY(1, 0xE), - /* Master sword */ DMG_ENTRY(4, 0xE), - /* Giant's Knife */ DMG_ENTRY(6, 0xE), - /* Fire arrow */ DMG_ENTRY(2, 0xE), - /* Ice arrow */ DMG_ENTRY(4, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0xE), - /* Unk arrow 1 */ DMG_ENTRY(2, 0xE), - /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), - /* Unk arrow 3 */ DMG_ENTRY(2, 0xE), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(4, 0x3), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(2, 0xE), - /* Giant spin */ DMG_ENTRY(8, 0xE), - /* Master spin */ DMG_ENTRY(4, 0xE), - /* Kokiri jump */ DMG_ENTRY(2, 0xE), - /* Giant jump */ DMG_ENTRY(8, 0xE), - /* Master jump */ DMG_ENTRY(4, 0xE), - /* Unknown 1 */ DMG_ENTRY(0, 0x1), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -const ActorInit En_Reeba_InitVars = { - ACTOR_EN_REEBA, - ACTORCAT_MISC, - FLAGS, - OBJECT_REEBA, - sizeof(EnReeba), - (ActorFunc)EnReeba_Init, - (ActorFunc)EnReeba_Destroy, - (ActorFunc)EnReeba_Update, - (ActorFunc)EnReeba_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT5, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x08, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 20, 40, 0, { 0, 0, 0 } }, -}; - -void EnReeba_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnReeba* this = (EnReeba*)thisx; - s32 surfaceType; - - this->actor.naviEnemyId = 0x47; - this->actor.targetMode = 3; - this->actor.gravity = -3.5f; - this->actor.focus.pos = this->actor.world.pos; - SkelAnime_Init(globalCtx, &this->skelanime, &object_reeba_Skel_001EE8, &object_reeba_Anim_0001E4, this->jointTable, - this->morphTable, 18); - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.colChkInfo.health = 4; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->isBig = this->actor.params; - this->scale = 0.04f; - - if (this->isBig) { - this->collider.dim.radius = 35; - this->collider.dim.height = 45; - this->scale *= 1.5f; - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ リーバぼす登場 ☆☆☆☆☆ %f\n" VT_RST, this->scale); - this->actor.colChkInfo.health = 20; - this->collider.info.toucher.effect = 4; - this->collider.info.toucher.damage = 16; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - } - - this->actor.shape.yOffset = this->unk_284 = this->scale * -27500.0f; - ActorShape_Init(&this->actor.shape, this->actor.shape.yOffset, ActorShadow_DrawCircle, 0.0f); - this->actor.colChkInfo.damageTable = &sDamageTable; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 0x1D); - - surfaceType = func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - - if ((surfaceType != 4) && (surfaceType != 7)) { - Actor_Kill(&this->actor); - return; - } - - this->actionfunc = func_80AE4F40; -} - -void EnReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnReeba* this = (EnReeba*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); - - if (this->actor.parent != NULL) { - EnEncount1* spawner = (EnEncount1*)this->actor.parent; - - if (spawner->actor.update != NULL) { - if (spawner->curNumSpawn > 0) { - spawner->curNumSpawn--; - } - if (this->isBig) { - spawner->bigLeever = NULL; - spawner->timer = 600; - } - } - } -} - -void func_80AE4F40(EnReeba* this, GlobalContext* globalCtx) { - f32 frames = Animation_GetLastFrame(&object_reeba_Anim_0001E4); - Player* player = GET_PLAYER(globalCtx); - s16 playerSpeed; - - Animation_Change(&this->skelanime, &object_reeba_Anim_0001E4, 2.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); - - playerSpeed = fabsf(player->linearVelocity); - this->unk_278 = 20 - playerSpeed * 2; - if (this->unk_278 < 0) { - this->unk_278 = 2; - } - if (this->unk_278 > 20) { - this->unk_278 = 20; - } - - this->actor.flags &= ~ACTOR_FLAG_27; - this->actor.world.pos.y = this->actor.floorHeight; - - if (this->isBig) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_BIG_APPEAR); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_APPEAR); - } - - this->actionfunc = func_80AE5054; -} - -void func_80AE5054(EnReeba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 playerLinearVel; - - SkelAnime_Update(&this->skelanime); - - if ((globalCtx->gameplayFrames % 4) == 0) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, - 8.0f, 500, 10, 1); - } - - if (this->unk_278 == 0) { - Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 1.0f, 1.0f); - if (this->actor.shape.yOffset < 0.0f) { - Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, this->unk_288); - Math_ApproachF(&this->unk_288, 300.0f, 1.0f, 5.0f); - } else { - this->unk_288 = 0.0f; - this->actor.shape.yOffset = 0.0f; - playerLinearVel = player->linearVelocity; - - switch (this->unk_280) { - case 0: - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - break; - case 1: - this->actor.world.rot.y = this->actor.yawTowardsPlayer + (800.0f * playerLinearVel); - break; - case 2: - case 3: - this->actor.world.rot.y = - this->actor.yawTowardsPlayer + - (player->actor.shape.rot.y - this->actor.yawTowardsPlayer) * (playerLinearVel * 0.15f); - break; - case 4: - this->actor.world.rot.y = this->actor.yawTowardsPlayer - (800.0f * playerLinearVel); - break; - } - - if (this->isBig) { - this->actionfunc = func_80AE538C; - } else { - this->unk_272 = 130; - this->actor.speedXZ = Rand_ZeroFloat(4.0f) + 6.0f; - this->actionfunc = func_80AE5270; - } - } - } -} - -void func_80AE5270(EnReeba* this, GlobalContext* globalCtx) { - s32 surfaceType; - - SkelAnime_Update(&this->skelanime); - - if (this->actor.shape.shadowScale < 12.0f) { - Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 3.0f, 1.0f); - } - - surfaceType = func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - - if ((surfaceType != 4) && (surfaceType != 7)) { - this->actor.speedXZ = 0.0f; - this->actionfunc = func_80AE5688; - } else if ((this->unk_272 == 0) || (this->actor.xzDistToPlayer < 30.0f) || (this->actor.xzDistToPlayer > 400.0f) || - (this->actor.bgCheckFlags & 8)) { - this->actionfunc = func_80AE5688; - } else if (this->unk_274 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_MOVE); - this->unk_274 = 10; - } -} - -void func_80AE538C(EnReeba* this, GlobalContext* globalCtx) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; - this->actionfunc = func_80AE53AC; -} - -void func_80AE53AC(EnReeba* this, GlobalContext* globalCtx) { - f32 speed; - s16 yawDiff; - s16 yaw; - s32 surfaceType; - - SkelAnime_Update(&this->skelanime); - - if (this->actor.shape.shadowScale < 12.0f) { - Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 3.0f, 1.0f); - } - - surfaceType = func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - - if (((surfaceType != 4) && (surfaceType != 7)) || (this->actor.xzDistToPlayer > 400.0f) || - (this->actor.bgCheckFlags & 8)) { - this->actionfunc = func_80AE5688; - } else { - if ((this->actor.xzDistToPlayer < 70.0f) && (this->unk_270 == 0)) { - this->unk_270 = 30; - } - - speed = (this->actor.xzDistToPlayer - 20.0f) / ((Rand_ZeroOne() * 50.0f) + 150.0f); - this->actor.speedXZ += speed * 1.8f; - if (this->actor.speedXZ >= 3.0f) { - this->actor.speedXZ = 3.0f; - } - if (this->actor.speedXZ < -3.0f) { - this->actor.speedXZ = -3.0f; - } - - yawDiff = (this->unk_270 == 0) ? this->actor.yawTowardsPlayer : -this->actor.yawTowardsPlayer; - yawDiff -= this->actor.world.rot.y; - yaw = (yawDiff > 0) ? ((yawDiff / 31.0f) + 10.0f) : ((yawDiff / 31.0f) - 10.0f); - this->actor.world.rot.y += yaw * 2.0f; - - if (this->unk_274 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_MOVE); - this->unk_274 = 20; - } - } -} - -void func_80AE561C(EnReeba* this, GlobalContext* globalCtx) { - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.3f); - - if (this->unk_272 == 0) { - if (this->isBig) { - this->actionfunc = func_80AE538C; - } else { - this->actionfunc = func_80AE5688; - } - } -} - -void func_80AE5688(EnReeba* this, GlobalContext* globalCtx) { - this->unk_27E = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - this->actor.flags |= ACTOR_FLAG_27; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actionfunc = func_80AE56E0; -} - -void func_80AE56E0(EnReeba* this, GlobalContext* globalCtx) { - Math_ApproachZeroF(&this->actor.shape.shadowScale, 1.0f, 0.3f); - Math_ApproachZeroF(&this->actor.speedXZ, 0.1f, 0.3f); - SkelAnime_Update(&this->skelanime); - - if ((this->unk_284 + 10.0f) <= this->actor.shape.yOffset) { - if ((globalCtx->gameplayFrames % 4) == 0) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, - 8.0f, 500, 10, 1); - } - - Math_ApproachF(&this->actor.shape.yOffset, this->unk_284, 1.0f, this->unk_288); - Math_ApproachF(&this->unk_288, 300.0f, 1.0f, 5.0f); - } else { - Actor_Kill(&this->actor); - } -} - -void func_80AE57F0(EnReeba* this, GlobalContext* globalCtx) { - this->unk_276 = 14; - this->actor.speedXZ = -8.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - this->actionfunc = func_80AE5854; -} - -void func_80AE5854(EnReeba* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelanime); - - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 1.0f; - } - - if (this->unk_276 == 0) { - if (this->isBig) { - this->unk_270 = 30; - this->actionfunc = func_80AE538C; - } else { - this->actionfunc = func_80AE5688; - } - } -} - -void func_80AE58EC(EnReeba* this, GlobalContext* globalCtx) { - this->unk_278 = 14; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = -8.0f; - this->actor.flags |= ACTOR_FLAG_27; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actionfunc = func_80AE5938; -} - -void func_80AE5938(EnReeba* this, GlobalContext* globalCtx) { - Vec3f pos; - f32 scale; - - if (this->unk_278 != 0) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 1.0f; - } - } else { - this->actor.speedXZ = 0.0f; - - if ((this->unk_27E == 4) || (this->actor.colChkInfo.health != 0)) { - if (this->unk_27E == 2) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(20.0f); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(20.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(20.0f); - scale = 3.0f; - - if (this->isBig) { - scale = 6.0f; - } - - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &pos, 150, 150, 150, 250, 235, 245, 255, scale); - } - - this->unk_278 = 66; - this->actionfunc = func_80AE5E48; - } else { - this->unk_278 = 30; - this->actionfunc = func_80AE5A9C; - } - } -} - -void func_80AE5A9C(EnReeba* this, GlobalContext* globalCtx) { - Vec3f pos; - f32 scale; - - if (this->unk_278 != 0) { - if ((this->unk_27E == 2) && ((this->unk_278 & 0xF) == 0)) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(20.0f); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(20.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(20.0f); - - scale = 3.0f; - if (this->isBig) { - scale = 6.0f; - } - - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &pos, 150, 150, 150, 250, 235, 245, 255, scale); - } - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actionfunc = func_80AE5C38; - } -} - -void func_80AE5BC4(EnReeba* this, GlobalContext* globalCtx) { - this->actor.speedXZ = -8.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - this->unk_278 = 14; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionfunc = func_80AE5C38; -} - -void func_80AE5C38(EnReeba* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f accel = { 0.0f, 0.0f, 0.0f }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - - if (this->unk_278 != 0) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 1.0f; - } - } else { - this->actor.speedXZ = 0.0f; - Math_ApproachZeroF(&this->scale, 0.1f, 0.01f); - - if (this->scale < 0.01f) { - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z; - - velocity.y = 4.0f; - - EffectSsDeadDb_Spawn(globalCtx, &pos, &velocity, &accel, 120, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, true); - - if (!this->isBig) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &pos, 0xE0); - } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &pos, 0xC0); - } - - if (this->actor.parent != NULL) { - EnEncount1* spawner = (EnEncount1*)this->actor.parent; - - if ((spawner->actor.update != NULL) && !this->isBig) { - if (spawner->killCount < 10) { - spawner->killCount++; - } - // "How many are dead?" - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 何匹DEAD? ☆☆☆☆☆%d\n" VT_RST, spawner->killCount); - osSyncPrintf("\n\n"); - } - - Actor_Kill(&this->actor); - } - } - } -} - -void func_80AE5E48(EnReeba* this, GlobalContext* globalCtx) { - if (this->unk_278 < 37) { - this->actor.shape.rot.x = Rand_CenteredFloat(3000.0f); - this->actor.shape.rot.z = Rand_CenteredFloat(3000.0f); - - if (this->unk_278 == 0) { - if (this->isBig) { - this->actionfunc = func_80AE538C; - } else { - this->actionfunc = func_80AE5688; - } - } - } -} - -void func_80AE5EDC(EnReeba* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - - if ((this->actionfunc != func_80AE5C38) && (this->actionfunc != func_80AE5854)) { - this->actor.shape.rot.x = this->actor.shape.rot.z = 0; - this->unk_27E = 0; - - switch (this->actor.colChkInfo.damageEffect) { - case 11: // none - case 12: // boomerang - if ((this->actor.colChkInfo.health > 1) && (this->unk_27E != 4)) { - this->unk_27E = 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); - this->actionfunc = func_80AE58EC; - break; - } - case 13: // hookshot/longshot - if ((this->actor.colChkInfo.health > 2) && (this->unk_27E != 4)) { - this->unk_27E = 4; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionfunc = func_80AE58EC; - break; - } - case 14: - this->unk_27C = 6; - Actor_ApplyDamage(&this->actor); - if (this->actor.colChkInfo.health == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actionfunc = func_80AE5BC4; - } else { - if (this->actionfunc == func_80AE5E48) { - this->actor.shape.rot.x = this->actor.shape.rot.z = 0; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_DAMAGE); - this->actionfunc = func_80AE57F0; - } - break; - case 3: // ice arrows/ice magic - Actor_ApplyDamage(&this->actor); - this->unk_27C = 2; - this->unk_27E = 2; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 80); - this->actionfunc = func_80AE58EC; - break; - case 1: // unknown - if (this->unk_27E != 4) { - this->unk_27E = 4; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 80); - this->actionfunc = func_80AE58EC; - } - break; - } - } - } -} - -void EnReeba_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnReeba* this = (EnReeba*)thisx; - Player* player = GET_PLAYER(globalCtx); - - func_80AE5EDC(this, globalCtx); - this->actionfunc(this, globalCtx); - Actor_SetScale(&this->actor, this->scale); - - if (this->unk_270 != 0) { - this->unk_270--; - } - - if (this->unk_272 != 0) { - this->unk_272--; - } - - if (this->unk_278 != 0) { - this->unk_278--; - } - - if (this->unk_274 != 0) { - this->unk_274--; - } - - if (this->unk_276 != 0) { - this->unk_276--; - } - - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 0x1D); - - if (this->collider.base.atFlags & AT_BOUNCED) { - this->collider.base.atFlags &= ~AT_BOUNCED; - - if ((this->actionfunc == func_80AE5270) || (this->actionfunc == func_80AE53AC)) { - this->actor.speedXZ = 8.0f; - this->actor.world.rot.y *= -1.0f; - this->unk_272 = 14; - this->actionfunc = func_80AE561C; - return; - } - } - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - if ((this->collider.base.at == &player->actor) && !this->isBig && (this->actionfunc != func_80AE56E0)) { - this->actionfunc = func_80AE5688; - } - } - - this->actor.focus.pos = this->actor.world.pos; - - if (!this->isBig) { - this->actor.focus.pos.y += 15.0f; - } else { - this->actor.focus.pos.y += 30.0f; - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - - if ((this->actor.shape.yOffset >= -700.0f) && (this->actor.colChkInfo.health > 0) && - (this->actionfunc != func_80AE56E0)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (!(this->actor.shape.yOffset < 0.0f)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if ((this->actionfunc == func_80AE5270) || (this->actionfunc == func_80AE53AC)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - } -} - -void EnReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnReeba* this = (EnReeba*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_reeba.c", 1062); - - func_80093D18(globalCtx->state.gfxCtx); - - if (this->isBig) { - gDPSetPrimColor(POLY_OPA_DISP++, 0x0, 0x01, 155, 55, 255, 255); - } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0x0, 0x01, 255, 255, 255, 255); - } - - SkelAnime_DrawOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, NULL, NULL, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_reeba.c", 1088); -} diff --git a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.cpp b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.cpp new file mode 100644 index 000000000..2de3ba899 --- /dev/null +++ b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.cpp @@ -0,0 +1,678 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_REEBA_Z_EN_REEBA_C +#include "actor_common.h" + +/* + * File: z_en_reeba.c + * Overlay: ovl_En_Reeba + * Description: Leever + */ + +#include "z_en_reeba.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "vt.h" +#include "objects/object_reeba/object_reeba.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_27) + +void EnReeba_Init(Actor* thisx, GlobalContext* globalCtx); +void EnReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnReeba_Update(Actor* thisx, GlobalContext* globalCtx); +void EnReeba_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AE4F40(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5054(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5270(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5688(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE56E0(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE538C(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE53AC(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5E48(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5854(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5C38(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5938(EnReeba* pthis, GlobalContext* globalCtx); +void func_80AE5A9C(EnReeba* pthis, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(2, 0xE), + /* Slingshot */ DMG_ENTRY(1, 0xE), + /* Explosive */ DMG_ENTRY(2, 0xE), + /* Boomerang */ DMG_ENTRY(1, 0xC), + /* Normal arrow */ DMG_ENTRY(2, 0xE), + /* Hammer swing */ DMG_ENTRY(2, 0xE), + /* Hookshot */ DMG_ENTRY(2, 0xD), + /* Kokiri sword */ DMG_ENTRY(1, 0xE), + /* Master sword */ DMG_ENTRY(4, 0xE), + /* Giant's Knife */ DMG_ENTRY(6, 0xE), + /* Fire arrow */ DMG_ENTRY(2, 0xE), + /* Ice arrow */ DMG_ENTRY(4, 0x3), + /* Light arrow */ DMG_ENTRY(2, 0xE), + /* Unk arrow 1 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 3 */ DMG_ENTRY(2, 0xE), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(4, 0x3), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(2, 0xE), + /* Giant spin */ DMG_ENTRY(8, 0xE), + /* Master spin */ DMG_ENTRY(4, 0xE), + /* Kokiri jump */ DMG_ENTRY(2, 0xE), + /* Giant jump */ DMG_ENTRY(8, 0xE), + /* Master jump */ DMG_ENTRY(4, 0xE), + /* Unknown 1 */ DMG_ENTRY(0, 0x1), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +ActorInit En_Reeba_InitVars = { + ACTOR_EN_REEBA, + ACTORCAT_MISC, + FLAGS, + OBJECT_REEBA, + sizeof(EnReeba), + (ActorFunc)EnReeba_Init, + (ActorFunc)EnReeba_Destroy, + (ActorFunc)EnReeba_Update, + (ActorFunc)EnReeba_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x08, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 20, 40, 0, { 0, 0, 0 } }, +}; + +void EnReeba_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnReeba* pthis = (EnReeba*)thisx; + s32 surfaceType; + + pthis->actor.naviEnemyId = 0x47; + pthis->actor.targetMode = 3; + pthis->actor.gravity = -3.5f; + pthis->actor.focus.pos = pthis->actor.world.pos; + SkelAnime_Init(globalCtx, &pthis->skelanime, &object_reeba_Skel_001EE8, &object_reeba_Anim_0001E4, pthis->jointTable, + pthis->morphTable, 18); + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.colChkInfo.health = 4; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->isBig = pthis->actor.params; + pthis->scale = 0.04f; + + if (pthis->isBig) { + pthis->collider.dim.radius = 35; + pthis->collider.dim.height = 45; + pthis->scale *= 1.5f; + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ リーバぼす登場 ☆☆☆☆☆ %f\n" VT_RST, pthis->scale); + pthis->actor.colChkInfo.health = 20; + pthis->collider.info.toucher.effect = 4; + pthis->collider.info.toucher.damage = 16; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + } + + pthis->actor.shape.yOffset = pthis->unk_284 = pthis->scale * -27500.0f; + ActorShape_Init(&pthis->actor.shape, pthis->actor.shape.yOffset, ActorShadow_DrawCircle, 0.0f); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 35.0f, 60.0f, 60.0f, 0x1D); + + surfaceType = func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + + if ((surfaceType != 4) && (surfaceType != 7)) { + Actor_Kill(&pthis->actor); + return; + } + + pthis->actionfunc = func_80AE4F40; +} + +void EnReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnReeba* pthis = (EnReeba*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); + + if (pthis->actor.parent != NULL) { + EnEncount1* spawner = (EnEncount1*)pthis->actor.parent; + + if (spawner->actor.update != NULL) { + if (spawner->curNumSpawn > 0) { + spawner->curNumSpawn--; + } + if (pthis->isBig) { + spawner->bigLeever = NULL; + spawner->timer = 600; + } + } + } +} + +void func_80AE4F40(EnReeba* pthis, GlobalContext* globalCtx) { + f32 frames = Animation_GetLastFrame(&object_reeba_Anim_0001E4); + Player* player = GET_PLAYER(globalCtx); + s16 playerSpeed; + + Animation_Change(&pthis->skelanime, &object_reeba_Anim_0001E4, 2.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f); + + playerSpeed = fabsf(player->linearVelocity); + pthis->unk_278 = 20 - playerSpeed * 2; + if (pthis->unk_278 < 0) { + pthis->unk_278 = 2; + } + if (pthis->unk_278 > 20) { + pthis->unk_278 = 20; + } + + pthis->actor.flags &= ~ACTOR_FLAG_27; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + + if (pthis->isBig) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_BIG_APPEAR); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_APPEAR); + } + + pthis->actionfunc = func_80AE5054; +} + +void func_80AE5054(EnReeba* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 playerLinearVel; + + SkelAnime_Update(&pthis->skelanime); + + if ((globalCtx->gameplayFrames % 4) == 0) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, pthis->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } + + if (pthis->unk_278 == 0) { + Math_ApproachF(&pthis->actor.shape.shadowScale, 12.0f, 1.0f, 1.0f); + if (pthis->actor.shape.yOffset < 0.0f) { + Math_ApproachZeroF(&pthis->actor.shape.yOffset, 1.0f, pthis->unk_288); + Math_ApproachF(&pthis->unk_288, 300.0f, 1.0f, 5.0f); + } else { + pthis->unk_288 = 0.0f; + pthis->actor.shape.yOffset = 0.0f; + playerLinearVel = player->linearVelocity; + + switch (pthis->unk_280) { + case 0: + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + break; + case 1: + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer + (800.0f * playerLinearVel); + break; + case 2: + case 3: + pthis->actor.world.rot.y = + pthis->actor.yawTowardsPlayer + + (player->actor.shape.rot.y - pthis->actor.yawTowardsPlayer) * (playerLinearVel * 0.15f); + break; + case 4: + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer - (800.0f * playerLinearVel); + break; + } + + if (pthis->isBig) { + pthis->actionfunc = func_80AE538C; + } else { + pthis->unk_272 = 130; + pthis->actor.speedXZ = Rand_ZeroFloat(4.0f) + 6.0f; + pthis->actionfunc = func_80AE5270; + } + } + } +} + +void func_80AE5270(EnReeba* pthis, GlobalContext* globalCtx) { + s32 surfaceType; + + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.shape.shadowScale < 12.0f) { + Math_ApproachF(&pthis->actor.shape.shadowScale, 12.0f, 3.0f, 1.0f); + } + + surfaceType = func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + + if ((surfaceType != 4) && (surfaceType != 7)) { + pthis->actor.speedXZ = 0.0f; + pthis->actionfunc = func_80AE5688; + } else if ((pthis->unk_272 == 0) || (pthis->actor.xzDistToPlayer < 30.0f) || (pthis->actor.xzDistToPlayer > 400.0f) || + (pthis->actor.bgCheckFlags & 8)) { + pthis->actionfunc = func_80AE5688; + } else if (pthis->unk_274 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_MOVE); + pthis->unk_274 = 10; + } +} + +void func_80AE538C(EnReeba* pthis, GlobalContext* globalCtx) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2; + pthis->actionfunc = func_80AE53AC; +} + +void func_80AE53AC(EnReeba* pthis, GlobalContext* globalCtx) { + f32 speed; + s16 yawDiff; + s16 yaw; + s32 surfaceType; + + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.shape.shadowScale < 12.0f) { + Math_ApproachF(&pthis->actor.shape.shadowScale, 12.0f, 3.0f, 1.0f); + } + + surfaceType = func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + + if (((surfaceType != 4) && (surfaceType != 7)) || (pthis->actor.xzDistToPlayer > 400.0f) || + (pthis->actor.bgCheckFlags & 8)) { + pthis->actionfunc = func_80AE5688; + } else { + if ((pthis->actor.xzDistToPlayer < 70.0f) && (pthis->unk_270 == 0)) { + pthis->unk_270 = 30; + } + + speed = (pthis->actor.xzDistToPlayer - 20.0f) / ((Rand_ZeroOne() * 50.0f) + 150.0f); + pthis->actor.speedXZ += speed * 1.8f; + if (pthis->actor.speedXZ >= 3.0f) { + pthis->actor.speedXZ = 3.0f; + } + if (pthis->actor.speedXZ < -3.0f) { + pthis->actor.speedXZ = -3.0f; + } + + yawDiff = (pthis->unk_270 == 0) ? pthis->actor.yawTowardsPlayer : -pthis->actor.yawTowardsPlayer; + yawDiff -= pthis->actor.world.rot.y; + yaw = (yawDiff > 0) ? ((yawDiff / 31.0f) + 10.0f) : ((yawDiff / 31.0f) - 10.0f); + pthis->actor.world.rot.y += yaw * 2.0f; + + if (pthis->unk_274 == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_MOVE); + pthis->unk_274 = 20; + } + } +} + +void func_80AE561C(EnReeba* pthis, GlobalContext* globalCtx) { + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 0.3f); + + if (pthis->unk_272 == 0) { + if (pthis->isBig) { + pthis->actionfunc = func_80AE538C; + } else { + pthis->actionfunc = func_80AE5688; + } + } +} + +void func_80AE5688(EnReeba* pthis, GlobalContext* globalCtx) { + pthis->unk_27E = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_AKINDONUTS_HIDE); + pthis->actor.flags |= ACTOR_FLAG_27; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actionfunc = func_80AE56E0; +} + +void func_80AE56E0(EnReeba* pthis, GlobalContext* globalCtx) { + Math_ApproachZeroF(&pthis->actor.shape.shadowScale, 1.0f, 0.3f); + Math_ApproachZeroF(&pthis->actor.speedXZ, 0.1f, 0.3f); + SkelAnime_Update(&pthis->skelanime); + + if ((pthis->unk_284 + 10.0f) <= pthis->actor.shape.yOffset) { + if ((globalCtx->gameplayFrames % 4) == 0) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, pthis->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } + + Math_ApproachF(&pthis->actor.shape.yOffset, pthis->unk_284, 1.0f, pthis->unk_288); + Math_ApproachF(&pthis->unk_288, 300.0f, 1.0f, 5.0f); + } else { + Actor_Kill(&pthis->actor); + } +} + +void func_80AE57F0(EnReeba* pthis, GlobalContext* globalCtx) { + pthis->unk_276 = 14; + pthis->actor.speedXZ = -8.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + pthis->actionfunc = func_80AE5854; +} + +void func_80AE5854(EnReeba* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelanime); + + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 1.0f; + } + + if (pthis->unk_276 == 0) { + if (pthis->isBig) { + pthis->unk_270 = 30; + pthis->actionfunc = func_80AE538C; + } else { + pthis->actionfunc = func_80AE5688; + } + } +} + +void func_80AE58EC(EnReeba* pthis, GlobalContext* globalCtx) { + pthis->unk_278 = 14; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = -8.0f; + pthis->actor.flags |= ACTOR_FLAG_27; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actionfunc = func_80AE5938; +} + +void func_80AE5938(EnReeba* pthis, GlobalContext* globalCtx) { + Vec3f pos; + f32 scale; + + if (pthis->unk_278 != 0) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 1.0f; + } + } else { + pthis->actor.speedXZ = 0.0f; + + if ((pthis->unk_27E == 4) || (pthis->actor.colChkInfo.health != 0)) { + if (pthis->unk_27E == 2) { + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(20.0f); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(20.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(20.0f); + scale = 3.0f; + + if (pthis->isBig) { + scale = 6.0f; + } + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &pos, 150, 150, 150, 250, 235, 245, 255, scale); + } + + pthis->unk_278 = 66; + pthis->actionfunc = func_80AE5E48; + } else { + pthis->unk_278 = 30; + pthis->actionfunc = func_80AE5A9C; + } + } +} + +void func_80AE5A9C(EnReeba* pthis, GlobalContext* globalCtx) { + Vec3f pos; + f32 scale; + + if (pthis->unk_278 != 0) { + if ((pthis->unk_27E == 2) && ((pthis->unk_278 & 0xF) == 0)) { + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(20.0f); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(20.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(20.0f); + + scale = 3.0f; + if (pthis->isBig) { + scale = 6.0f; + } + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &pos, 150, 150, 150, 250, 235, 245, 255, scale); + } + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_DEAD); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actionfunc = func_80AE5C38; + } +} + +void func_80AE5BC4(EnReeba* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = -8.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + pthis->unk_278 = 14; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionfunc = func_80AE5C38; +} + +void func_80AE5C38(EnReeba* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + + if (pthis->unk_278 != 0) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 1.0f; + } + } else { + pthis->actor.speedXZ = 0.0f; + Math_ApproachZeroF(&pthis->scale, 0.1f, 0.01f); + + if (pthis->scale < 0.01f) { + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z; + + velocity.y = 4.0f; + + EffectSsDeadDb_Spawn(globalCtx, &pos, &velocity, &accel, 120, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, true); + + if (!pthis->isBig) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pos, 0xE0); + } else { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pos, 0xC0); + } + + if (pthis->actor.parent != NULL) { + EnEncount1* spawner = (EnEncount1*)pthis->actor.parent; + + if ((spawner->actor.update != NULL) && !pthis->isBig) { + if (spawner->killCount < 10) { + spawner->killCount++; + } + // "How many are dead?" + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 何匹DEAD? ☆☆☆☆☆%d\n" VT_RST, spawner->killCount); + osSyncPrintf("\n\n"); + } + + Actor_Kill(&pthis->actor); + } + } + } +} + +void func_80AE5E48(EnReeba* pthis, GlobalContext* globalCtx) { + if (pthis->unk_278 < 37) { + pthis->actor.shape.rot.x = Rand_CenteredFloat(3000.0f); + pthis->actor.shape.rot.z = Rand_CenteredFloat(3000.0f); + + if (pthis->unk_278 == 0) { + if (pthis->isBig) { + pthis->actionfunc = func_80AE538C; + } else { + pthis->actionfunc = func_80AE5688; + } + } + } +} + +void func_80AE5EDC(EnReeba* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + + if ((pthis->actionfunc != func_80AE5C38) && (pthis->actionfunc != func_80AE5854)) { + pthis->actor.shape.rot.x = pthis->actor.shape.rot.z = 0; + pthis->unk_27E = 0; + + switch (pthis->actor.colChkInfo.damageEffect) { + case 11: // none + case 12: // boomerang + if ((pthis->actor.colChkInfo.health > 1) && (pthis->unk_27E != 4)) { + pthis->unk_27E = 4; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); + pthis->actionfunc = func_80AE58EC; + break; + } + case 13: // hookshot/longshot + if ((pthis->actor.colChkInfo.health > 2) && (pthis->unk_27E != 4)) { + pthis->unk_27E = 4; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actionfunc = func_80AE58EC; + break; + } + case 14: + pthis->unk_27C = 6; + Actor_ApplyDamage(&pthis->actor); + if (pthis->actor.colChkInfo.health == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_DEAD); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actionfunc = func_80AE5BC4; + } else { + if (pthis->actionfunc == func_80AE5E48) { + pthis->actor.shape.rot.x = pthis->actor.shape.rot.z = 0; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_DAMAGE); + pthis->actionfunc = func_80AE57F0; + } + break; + case 3: // ice arrows/ice magic + Actor_ApplyDamage(&pthis->actor); + pthis->unk_27C = 2; + pthis->unk_27E = 2; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 80); + pthis->actionfunc = func_80AE58EC; + break; + case 1: // unknown + if (pthis->unk_27E != 4) { + pthis->unk_27E = 4; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 80); + pthis->actionfunc = func_80AE58EC; + } + break; + } + } + } +} + +void EnReeba_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnReeba* pthis = (EnReeba*)thisx; + Player* player = GET_PLAYER(globalCtx); + + func_80AE5EDC(pthis, globalCtx); + pthis->actionfunc(pthis, globalCtx); + Actor_SetScale(&pthis->actor, pthis->scale); + + if (pthis->unk_270 != 0) { + pthis->unk_270--; + } + + if (pthis->unk_272 != 0) { + pthis->unk_272--; + } + + if (pthis->unk_278 != 0) { + pthis->unk_278--; + } + + if (pthis->unk_274 != 0) { + pthis->unk_274--; + } + + if (pthis->unk_276 != 0) { + pthis->unk_276--; + } + + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 35.0f, 60.0f, 60.0f, 0x1D); + + if (pthis->collider.base.atFlags & AT_BOUNCED) { + pthis->collider.base.atFlags &= ~AT_BOUNCED; + + if ((pthis->actionfunc == func_80AE5270) || (pthis->actionfunc == func_80AE53AC)) { + pthis->actor.speedXZ = 8.0f; + pthis->actor.world.rot.y *= -1.0f; + pthis->unk_272 = 14; + pthis->actionfunc = func_80AE561C; + return; + } + } + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + if ((pthis->collider.base.at == &player->actor) && !pthis->isBig && (pthis->actionfunc != func_80AE56E0)) { + pthis->actionfunc = func_80AE5688; + } + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + + if (!pthis->isBig) { + pthis->actor.focus.pos.y += 15.0f; + } else { + pthis->actor.focus.pos.y += 30.0f; + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if ((pthis->actor.shape.yOffset >= -700.0f) && (pthis->actor.colChkInfo.health > 0) && + (pthis->actionfunc != func_80AE56E0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (!(pthis->actor.shape.yOffset < 0.0f)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if ((pthis->actionfunc == func_80AE5270) || (pthis->actionfunc == func_80AE53AC)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + } +} + +void EnReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnReeba* pthis = (EnReeba*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_reeba.c", 1062); + + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->isBig) { + gDPSetPrimColor(POLY_OPA_DISP++, 0x0, 0x01, 155, 55, 255, 255); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0x0, 0x01, 255, 255, 255, 255); + } + + SkelAnime_DrawOpa(globalCtx, pthis->skelanime.skeleton, pthis->skelanime.jointTable, NULL, NULL, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_reeba.c", 1088); +} diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.cpp similarity index 70% rename from src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c rename to src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.cpp index aac07d1d9..721c166ac 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.cpp @@ -19,7 +19,7 @@ void EnRiverSound_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_River_Sound_InitVars = { +ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, ACTORCAT_BG, FLAGS, @@ -32,31 +32,31 @@ const ActorInit En_River_Sound_InitVars = { }; void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { - EnRiverSound* this = (EnRiverSound*)thisx; + EnRiverSound* pthis = (EnRiverSound*)thisx; - this->playSound = 0; - this->pathIndex = (this->actor.params >> 8) & 0xFF; - this->actor.params = this->actor.params & 0xFF; + pthis->playSound = 0; + pthis->pathIndex = (pthis->actor.params >> 8) & 0xFF; + pthis->actor.params = pthis->actor.params & 0xFF; - if (this->actor.params >= RS_MAX) { // used for ganon and ganon_boss scenes - func_800F4870(this->actor.params - RS_MAX); - Actor_Kill(&this->actor); - } else if (this->actor.params == RS_UNK_F7) { + if (pthis->actor.params >= RS_MAX) { // used for ganon and ganon_boss scenes + func_800F4870(pthis->actor.params - RS_MAX); + Actor_Kill(&pthis->actor); + } else if (pthis->actor.params == RS_UNK_F7) { func_800F6FB4(4); - Actor_Kill(&this->actor); - } else if (this->actor.params == RS_SARIAS_SONG) { + Actor_Kill(&pthis->actor); + } else if (pthis->actor.params == RS_SARIAS_SONG) { if (!CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } } void EnRiverSound_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnRiverSound* this = (EnRiverSound*)thisx; + EnRiverSound* pthis = (EnRiverSound*)thisx; - if (this->actor.params == RS_SARIAS_SONG) { - Audio_ClearSariaBgmAtPos(&this->actor.projectedPos); - } else if (this->actor.params == RS_UNK_13) { + if (pthis->actor.params == RS_SARIAS_SONG) { + Audio_ClearSariaBgmAtPos(&pthis->actor.projectedPos); + } else if (pthis->actor.params == RS_UNK_13) { Audio_ClearSariaBgm2(); } } @@ -172,33 +172,33 @@ void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { Path* path; Vec3f* pos; Player* player = GET_PLAYER(globalCtx); - EnRiverSound* this = (EnRiverSound*)thisx; + EnRiverSound* pthis = (EnRiverSound*)thisx; s32 sp34; if ((thisx->params == RS_UNK_0) || (thisx->params == RS_UNK_4) || (thisx->params == RS_UNK_5)) { - path = &globalCtx->setupPathList[this->pathIndex]; + path = &globalCtx->setupPathList[pthis->pathIndex]; pos = &thisx->world.pos; if (EnRiverSound_GetSoundPos(SEGMENTED_TO_VIRTUAL(path->points), path->count, &player->actor.world.pos, pos)) { if (BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &thisx->floorPoly, &sp34, thisx, pos) != BGCHECK_Y_MIN) { // Get the sound volume pitch based on the speed of the river current under the actor - this->soundPitchIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, thisx->floorPoly, sp34); + pthis->soundPitchIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, thisx->floorPoly, sp34); } else { - this->soundPitchIndex = 0; + pthis->soundPitchIndex = 0; } - if (this->soundPitchIndex == 0) { + if (pthis->soundPitchIndex == 0) { if (thisx->params == RS_UNK_4) { - this->soundPitchIndex = 0; + pthis->soundPitchIndex = 0; } else if (thisx->params == RS_UNK_0) { - this->soundPitchIndex = 1; + pthis->soundPitchIndex = 1; } else { - this->soundPitchIndex = 2; + pthis->soundPitchIndex = 2; } } else { - this->soundPitchIndex--; - this->soundPitchIndex = CLAMP_MAX(this->soundPitchIndex, 2); + pthis->soundPitchIndex--; + pthis->soundPitchIndex = CLAMP_MAX(pthis->soundPitchIndex, 2); } } } else if ((thisx->params == RS_UNK_13) || (thisx->params == RS_UNK_19)) { @@ -234,25 +234,25 @@ void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { NA_SE_EV_COW_CRY_LV - SFX_FLAG, }; static f32 soundPitch[] = { 0.7f, 1.0f, 1.4f }; - EnRiverSound* this = (EnRiverSound*)thisx; + EnRiverSound* pthis = (EnRiverSound*)thisx; - if (!(this->playSound)) { - this->playSound = true; - } else if ((this->actor.params == RS_UNK_0) || (this->actor.params == RS_UNK_4) || - (this->actor.params == RS_UNK_5)) { - Audio_PlaySoundRiver(&this->actor.projectedPos, soundPitch[this->soundPitchIndex]); - } else if (this->actor.params == RS_UNK_11) { + if (!(pthis->playSound)) { + pthis->playSound = true; + } else if ((pthis->actor.params == RS_UNK_0) || (pthis->actor.params == RS_UNK_4) || + (pthis->actor.params == RS_UNK_5)) { + Audio_PlaySoundRiver(&pthis->actor.projectedPos, soundPitch[pthis->soundPitchIndex]); + } else if (pthis->actor.params == RS_UNK_11) { func_800F4A54(90); - } else if (this->actor.params == RS_SARIAS_SONG) { - func_800F4E30(&this->actor.projectedPos, this->actor.xzDistToPlayer); - } else if (this->actor.params == RS_UNK_13) { - Audio_PlaySariaBgm(&this->actor.home.pos, NA_BGM_SARIA_THEME, 1000); - } else if (this->actor.params == RS_UNK_19) { - Audio_PlaySariaBgm(&this->actor.home.pos, NA_BGM_GREAT_FAIRY, 800); - } else if ((this->actor.params == RS_SANDSTORM) || (this->actor.params == RS_CHAMBER_OF_SAGES_1) || - (this->actor.params == RS_CHAMBER_OF_SAGES_2) || (this->actor.params == RS_RUMBLING)) { - func_800788CC(soundEffects[this->actor.params]); + } else if (pthis->actor.params == RS_SARIAS_SONG) { + func_800F4E30(&pthis->actor.projectedPos, pthis->actor.xzDistToPlayer); + } else if (pthis->actor.params == RS_UNK_13) { + Audio_PlaySariaBgm(&pthis->actor.home.pos, NA_BGM_SARIA_THEME, 1000); + } else if (pthis->actor.params == RS_UNK_19) { + Audio_PlaySariaBgm(&pthis->actor.home.pos, NA_BGM_GREAT_FAIRY, 800); + } else if ((pthis->actor.params == RS_SANDSTORM) || (pthis->actor.params == RS_CHAMBER_OF_SAGES_1) || + (pthis->actor.params == RS_CHAMBER_OF_SAGES_2) || (pthis->actor.params == RS_RUMBLING)) { + func_800788CC(soundEffects[pthis->actor.params]); } else { - Audio_PlayActorSound2(&this->actor, soundEffects[this->actor.params]); + Audio_PlayActorSound2(&pthis->actor, soundEffects[pthis->actor.params]); } } diff --git a/src/overlays/actors/ovl_En_Rl/z_en_rl.c b/src/overlays/actors/ovl_En_Rl/z_en_rl.c deleted file mode 100644 index 09edc809e..000000000 --- a/src/overlays/actors/ovl_En_Rl/z_en_rl.c +++ /dev/null @@ -1,401 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RL_Z_EN_RL_C -#include "actor_common.h" -/* - * File: z_en_rl.c - * Overlay: En_Rl - * Description: Rauru - */ - -#include "z_en_rl.h" -#include "vt.h" -#include "objects/object_rl/object_rl.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnRl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRl_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AE7798(EnRl* this, GlobalContext* globalCtx); -void func_80AE77B8(EnRl* this, GlobalContext* globalCtx); -void func_80AE77F8(EnRl* this, GlobalContext* globalCtx); -void func_80AE7838(EnRl* this, GlobalContext* globalCtx); -void func_80AE7C64(EnRl* this, GlobalContext* globalCtx); -void func_80AE7C94(EnRl* this, GlobalContext* globalCtx); -void func_80AE7CE8(EnRl* this, GlobalContext* globalCtx); -void func_80AE7D40(EnRl* this, GlobalContext* globalCtx); -void func_80AE7FD0(EnRl* this, GlobalContext* globalCtx); -void func_80AE7FDC(EnRl* this, GlobalContext* globalCtx); -void func_80AE7D94(EnRl* this, GlobalContext* globalCtx); - -static void* D_80AE81A0[] = { object_rl_Tex_003620, object_rl_Tex_003960, object_rl_Tex_003B60 }; - -void EnRl_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnRl* this = (EnRl*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); -} - -void func_80AE72D0(EnRl* this) { - s32 pad[3]; - s16* timer = &this->timer; - s16* eyeTextureIndex = &this->eyeTextureIndex; - - if (DECR(*timer) == 0) { - *timer = Rand_S16Offset(60, 60); - } - - *eyeTextureIndex = *timer; - if (*eyeTextureIndex > 2) { - *eyeTextureIndex = 0; - } -} - -void func_80AE7358(EnRl* this) { - Animation_Change(&this->skelAnime, &object_rl_Anim_000A3C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_rl_Anim_000A3C), ANIMMODE_LOOP, 0.0f); - this->action = 4; - this->drawConfig = 0; - this->alpha = 0; - this->lightBallSpawned = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_19C = 0.0f; -} - -void func_80AE73D8(EnRl* this, GlobalContext* globalCtx) { - static s32 D_80AE81AC = 0; - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - if (D_80AE81AC) { - if (this->actor.params == 2) { - func_80AE7358(this); - } - D_80AE81AC = 0; - } - } else if (!D_80AE81AC) { - D_80AE81AC = 1; - } -} - -void func_80AE744C(EnRl* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -s32 func_80AE7494(EnRl* this) { - return SkelAnime_Update(&this->skelAnime); -} - -s32 func_80AE74B4(EnRl* this, GlobalContext* globalCtx, u16 arg2, s32 arg3) { - CsCmdActorAction* csCmdActorAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdActorAction = globalCtx->csCtx.npcActions[arg3]; - if (csCmdActorAction != NULL && csCmdActorAction->action == arg2) { - return 1; - } - } - return 0; -} - -s32 func_80AE74FC(EnRl* this, GlobalContext* globalCtx, u16 arg2, s32 arg3) { - CsCmdActorAction* csCmdActorAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdActorAction = globalCtx->csCtx.npcActions[arg3]; - if (csCmdActorAction != NULL && csCmdActorAction->action != arg2) { - return 1; - } - } - return 0; -} - -void func_80AE7544(EnRl* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rl_Skel_007B38, &object_rl_Anim_000A3C, NULL, NULL, 0); -} - -void func_80AE7590(EnRl* this, GlobalContext* globalCtx) { - s32 pad; - Player* player; - Vec3f pos; - s16 sceneNum = globalCtx->sceneNum; - - if (gSaveContext.sceneSetupIndex == 4 && sceneNum == SCENE_KENJYANOMA && globalCtx->csCtx.state != CS_STATE_IDLE && - globalCtx->csCtx.npcActions[6] != NULL && globalCtx->csCtx.npcActions[6]->action == 2 && - !this->lightMedallionGiven) { - player = GET_PLAYER(globalCtx); - pos.x = player->actor.world.pos.x; - pos.y = player->actor.world.pos.y + 80.0f; - pos.z = player->actor.world.pos.z; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pos.x, pos.y, pos.z, 0, 0, 0, 0xE); - Item_Give(globalCtx, ITEM_MEDALLION_LIGHT); - this->lightMedallionGiven = 1; - } -} - -void func_80AE7668(EnRl* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->drawConfig = 1; - this->action = 1; - player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; -} - -void func_80AE7698(EnRl* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdActorAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdActorAction = globalCtx->csCtx.npcActions[0]; - if (csCmdActorAction != NULL && csCmdActorAction->action == 3) { - Animation_Change(&this->skelAnime, &object_rl_Anim_00040C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_rl_Anim_00040C), ANIMMODE_ONCE, 0.0f); - this->action = 2; - } - } -} - -void func_80AE772C(EnRl* this, s32 arg1) { - if (arg1) { - Animation_Change(&this->skelAnime, &object_rl_Anim_000830, 1.0f, 0.0f, - Animation_GetLastFrame(&object_rl_Anim_000830), ANIMMODE_LOOP, 0.0f); - this->action = 3; - } -} - -void func_80AE7798(EnRl* this, GlobalContext* globalCtx) { - func_80AE7668(this, globalCtx); -} - -void func_80AE77B8(EnRl* this, GlobalContext* globalCtx) { - func_80AE744C(this, globalCtx); - func_80AE7494(this); - func_80AE72D0(this); - func_80AE7698(this, globalCtx); -} - -void func_80AE77F8(EnRl* this, GlobalContext* globalCtx) { - s32 temp; - - func_80AE744C(this, globalCtx); - temp = func_80AE7494(this); - func_80AE72D0(this); - func_80AE772C(this, temp); -} - -void func_80AE7838(EnRl* this, GlobalContext* globalCtx) { - func_80AE744C(this, globalCtx); - func_80AE7494(this); - func_80AE72D0(this); - func_80AE7590(this, globalCtx); -} - -void func_80AE7878(EnRl* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rl_Skel_007B38, &object_rl_Anim_000A3C, NULL, NULL, 0); - this->action = 4; - this->actor.shape.shadowAlpha = 0; -} - -void func_80AE78D4(EnRl* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - kREG(18) + 22.0f + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 5); -} - -void func_80AE7954(EnRl* this, GlobalContext* globalCtx) { - if (func_80AE74B4(this, globalCtx, 4, 0)) { - this->action = 5; - this->drawConfig = 2; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_19C = 0.0f; - } -} - -void func_80AE79A4(EnRl* this, GlobalContext* globalCtx) { - f32* unk_19C = &this->unk_19C; - s32 alpha = 255; - - if (func_80AE74B4(this, globalCtx, 4, 0)) { - *unk_19C += 1.0f; - if (*unk_19C >= kREG(5) + 10.0f) { - this->action = 7; - this->drawConfig = 1; - *unk_19C = kREG(5) + 10.0f; - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; - return; - } - } else { - *unk_19C -= 1.0f; - if (*unk_19C <= 0.0f) { - this->action = 4; - this->drawConfig = 0; - *unk_19C = 0.0f; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - return; - } - } - alpha = (*unk_19C / (kREG(5) + 10.0f)) * 255.0f; - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; -} - -void func_80AE7AF8(EnRl* this, GlobalContext* globalCtx) { - if (func_80AE74B4(this, globalCtx, 3, 0)) { - Animation_Change(&this->skelAnime, &object_rl_Anim_00040C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_rl_Anim_00040C), ANIMMODE_ONCE, -8.0f); - this->action = 6; - } else if (func_80AE74FC(this, globalCtx, 4, 0)) { - this->action = 5; - this->drawConfig = 2; - this->unk_19C = kREG(5) + 10.0f; - this->alpha = 255; - if (!this->lightBallSpawned) { - func_80AE78D4(this, globalCtx); - this->lightBallSpawned = 1; - } - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80AE7BF8(EnRl* this, s32 arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &object_rl_Anim_000830, 1.0f, 0.0f, - Animation_GetLastFrame(&object_rl_Anim_000830), ANIMMODE_LOOP, 0.0f); - this->action = 7; - } -} - -void func_80AE7C64(EnRl* this, GlobalContext* globalCtx) { - func_80AE7954(this, globalCtx); - func_80AE73D8(this, globalCtx); -} - -void func_80AE7C94(EnRl* this, GlobalContext* globalCtx) { - func_80AE744C(this, globalCtx); - func_80AE7494(this); - func_80AE72D0(this); - func_80AE79A4(this, globalCtx); - func_80AE73D8(this, globalCtx); -} - -void func_80AE7CE8(EnRl* this, GlobalContext* globalCtx) { - s32 temp; - - func_80AE744C(this, globalCtx); - temp = func_80AE7494(this); - func_80AE72D0(this); - func_80AE7BF8(this, temp); - func_80AE73D8(this, globalCtx); -} - -void func_80AE7D40(EnRl* this, GlobalContext* globalCtx) { - func_80AE744C(this, globalCtx); - func_80AE7494(this); - func_80AE72D0(this); - func_80AE7AF8(this, globalCtx); - func_80AE73D8(this, globalCtx); -} - -void func_80AE7D94(EnRl* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 temp = this->eyeTextureIndex; - void* tex = D_80AE81A0[temp]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rl_inKenjyanomaDemo02.c", 304); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - NULL, NULL, NULL, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rl_inKenjyanomaDemo02.c", 331); -} - -static EnRlActionFunc sActionFuncs[] = { - func_80AE7798, func_80AE77B8, func_80AE77F8, func_80AE7838, - func_80AE7C64, func_80AE7C94, func_80AE7CE8, func_80AE7D40, -}; - -void EnRl_Update(Actor* thisx, GlobalContext* globalCtx) { - EnRl* this = (EnRl*)thisx; - - if ((this->action < 0) || (this->action > 7) || (sActionFuncs[this->action] == NULL)) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sActionFuncs[this->action](this, globalCtx); -} - -void EnRl_Init(Actor* thisx, GlobalContext* globalCtx) { - EnRl* this = (EnRl*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - if (this->actor.params == 2) { - func_80AE7878(this, globalCtx); - } else { - func_80AE7544(this, globalCtx); - } -} -void func_80AE7FD0(EnRl* this, GlobalContext* globalCtx) { -} - -void func_80AE7FDC(EnRl* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 temp = this->eyeTextureIndex; - void* tex = D_80AE81A0[temp]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rl.c", 416); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, - &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rl.c", 437); -} - -static EnRlDrawFunc sDrawFuncs[] = { - func_80AE7FD0, - func_80AE7FDC, - func_80AE7D94, -}; - -void EnRl_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnRl* this = (EnRl*)thisx; - - if (this->drawConfig < 0 || this->drawConfig >= 3 || sDrawFuncs[this->drawConfig] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} - -const ActorInit En_Rl_InitVars = { - ACTOR_EN_RL, - ACTORCAT_NPC, - FLAGS, - OBJECT_RL, - sizeof(EnRl), - (ActorFunc)EnRl_Init, - (ActorFunc)EnRl_Destroy, - (ActorFunc)EnRl_Update, - (ActorFunc)EnRl_Draw, -}; diff --git a/src/overlays/actors/ovl_En_Rl/z_en_rl.cpp b/src/overlays/actors/ovl_En_Rl/z_en_rl.cpp new file mode 100644 index 000000000..9b4de7c18 --- /dev/null +++ b/src/overlays/actors/ovl_En_Rl/z_en_rl.cpp @@ -0,0 +1,401 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RL_Z_EN_RL_C +#include "actor_common.h" +/* + * File: z_en_rl.c + * Overlay: En_Rl + * Description: Rauru + */ + +#include "z_en_rl.h" +#include "vt.h" +#include "objects/object_rl/object_rl.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnRl_Init(Actor* thisx, GlobalContext* globalCtx); +void EnRl_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnRl_Update(Actor* thisx, GlobalContext* globalCtx); +void EnRl_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AE7798(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE77B8(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE77F8(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7838(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7C64(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7C94(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7CE8(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7D40(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7FD0(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7FDC(EnRl* pthis, GlobalContext* globalCtx); +void func_80AE7D94(EnRl* pthis, GlobalContext* globalCtx); + +static void* D_80AE81A0[] = { object_rl_Tex_003620, object_rl_Tex_003960, object_rl_Tex_003B60 }; + +void EnRl_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRl* pthis = (EnRl*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); +} + +void func_80AE72D0(EnRl* pthis) { + s32 pad[3]; + s16* timer = &pthis->timer; + s16* eyeTextureIndex = &pthis->eyeTextureIndex; + + if (DECR(*timer) == 0) { + *timer = Rand_S16Offset(60, 60); + } + + *eyeTextureIndex = *timer; + if (*eyeTextureIndex > 2) { + *eyeTextureIndex = 0; + } +} + +void func_80AE7358(EnRl* pthis) { + Animation_Change(&pthis->skelAnime, &object_rl_Anim_000A3C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_rl_Anim_000A3C), ANIMMODE_LOOP, 0.0f); + pthis->action = 4; + pthis->drawConfig = 0; + pthis->alpha = 0; + pthis->lightBallSpawned = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_19C = 0.0f; +} + +void func_80AE73D8(EnRl* pthis, GlobalContext* globalCtx) { + static s32 D_80AE81AC = 0; + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + if (D_80AE81AC) { + if (pthis->actor.params == 2) { + func_80AE7358(pthis); + } + D_80AE81AC = 0; + } + } else if (!D_80AE81AC) { + D_80AE81AC = 1; + } +} + +void func_80AE744C(EnRl* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +s32 func_80AE7494(EnRl* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +s32 func_80AE74B4(EnRl* pthis, GlobalContext* globalCtx, u16 arg2, s32 arg3) { + CsCmdActorAction* csCmdActorAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdActorAction = globalCtx->csCtx.npcActions[arg3]; + if (csCmdActorAction != NULL && csCmdActorAction->action == arg2) { + return 1; + } + } + return 0; +} + +s32 func_80AE74FC(EnRl* pthis, GlobalContext* globalCtx, u16 arg2, s32 arg3) { + CsCmdActorAction* csCmdActorAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdActorAction = globalCtx->csCtx.npcActions[arg3]; + if (csCmdActorAction != NULL && csCmdActorAction->action != arg2) { + return 1; + } + } + return 0; +} + +void func_80AE7544(EnRl* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_rl_Skel_007B38, &object_rl_Anim_000A3C, NULL, NULL, 0); +} + +void func_80AE7590(EnRl* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player; + Vec3f pos; + s16 sceneNum = globalCtx->sceneNum; + + if (gSaveContext.sceneSetupIndex == 4 && sceneNum == SCENE_KENJYANOMA && globalCtx->csCtx.state != CS_STATE_IDLE && + globalCtx->csCtx.npcActions[6] != NULL && globalCtx->csCtx.npcActions[6]->action == 2 && + !pthis->lightMedallionGiven) { + player = GET_PLAYER(globalCtx); + pos.x = player->actor.world.pos.x; + pos.y = player->actor.world.pos.y + 80.0f; + pos.z = player->actor.world.pos.z; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pos.x, pos.y, pos.z, 0, 0, 0, 0xE); + Item_Give(globalCtx, ITEM_MEDALLION_LIGHT); + pthis->lightMedallionGiven = 1; + } +} + +void func_80AE7668(EnRl* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->drawConfig = 1; + pthis->action = 1; + player->actor.world.rot.y = player->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; +} + +void func_80AE7698(EnRl* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdActorAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdActorAction = globalCtx->csCtx.npcActions[0]; + if (csCmdActorAction != NULL && csCmdActorAction->action == 3) { + Animation_Change(&pthis->skelAnime, &object_rl_Anim_00040C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_rl_Anim_00040C), ANIMMODE_ONCE, 0.0f); + pthis->action = 2; + } + } +} + +void func_80AE772C(EnRl* pthis, s32 arg1) { + if (arg1) { + Animation_Change(&pthis->skelAnime, &object_rl_Anim_000830, 1.0f, 0.0f, + Animation_GetLastFrame(&object_rl_Anim_000830), ANIMMODE_LOOP, 0.0f); + pthis->action = 3; + } +} + +void func_80AE7798(EnRl* pthis, GlobalContext* globalCtx) { + func_80AE7668(pthis, globalCtx); +} + +void func_80AE77B8(EnRl* pthis, GlobalContext* globalCtx) { + func_80AE744C(pthis, globalCtx); + func_80AE7494(pthis); + func_80AE72D0(pthis); + func_80AE7698(pthis, globalCtx); +} + +void func_80AE77F8(EnRl* pthis, GlobalContext* globalCtx) { + s32 temp; + + func_80AE744C(pthis, globalCtx); + temp = func_80AE7494(pthis); + func_80AE72D0(pthis); + func_80AE772C(pthis, temp); +} + +void func_80AE7838(EnRl* pthis, GlobalContext* globalCtx) { + func_80AE744C(pthis, globalCtx); + func_80AE7494(pthis); + func_80AE72D0(pthis); + func_80AE7590(pthis, globalCtx); +} + +void func_80AE7878(EnRl* pthis, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_rl_Skel_007B38, &object_rl_Anim_000A3C, NULL, NULL, 0); + pthis->action = 4; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80AE78D4(EnRl* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + kREG(18) + 22.0f + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 5); +} + +void func_80AE7954(EnRl* pthis, GlobalContext* globalCtx) { + if (func_80AE74B4(pthis, globalCtx, 4, 0)) { + pthis->action = 5; + pthis->drawConfig = 2; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_19C = 0.0f; + } +} + +void func_80AE79A4(EnRl* pthis, GlobalContext* globalCtx) { + f32* unk_19C = &pthis->unk_19C; + s32 alpha = 255; + + if (func_80AE74B4(pthis, globalCtx, 4, 0)) { + *unk_19C += 1.0f; + if (*unk_19C >= kREG(5) + 10.0f) { + pthis->action = 7; + pthis->drawConfig = 1; + *unk_19C = kREG(5) + 10.0f; + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; + return; + } + } else { + *unk_19C -= 1.0f; + if (*unk_19C <= 0.0f) { + pthis->action = 4; + pthis->drawConfig = 0; + *unk_19C = 0.0f; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + return; + } + } + alpha = (*unk_19C / (kREG(5) + 10.0f)) * 255.0f; + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; +} + +void func_80AE7AF8(EnRl* pthis, GlobalContext* globalCtx) { + if (func_80AE74B4(pthis, globalCtx, 3, 0)) { + Animation_Change(&pthis->skelAnime, &object_rl_Anim_00040C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_rl_Anim_00040C), ANIMMODE_ONCE, -8.0f); + pthis->action = 6; + } else if (func_80AE74FC(pthis, globalCtx, 4, 0)) { + pthis->action = 5; + pthis->drawConfig = 2; + pthis->unk_19C = kREG(5) + 10.0f; + pthis->alpha = 255; + if (!pthis->lightBallSpawned) { + func_80AE78D4(pthis, globalCtx); + pthis->lightBallSpawned = 1; + } + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80AE7BF8(EnRl* pthis, s32 arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &object_rl_Anim_000830, 1.0f, 0.0f, + Animation_GetLastFrame(&object_rl_Anim_000830), ANIMMODE_LOOP, 0.0f); + pthis->action = 7; + } +} + +void func_80AE7C64(EnRl* pthis, GlobalContext* globalCtx) { + func_80AE7954(pthis, globalCtx); + func_80AE73D8(pthis, globalCtx); +} + +void func_80AE7C94(EnRl* pthis, GlobalContext* globalCtx) { + func_80AE744C(pthis, globalCtx); + func_80AE7494(pthis); + func_80AE72D0(pthis); + func_80AE79A4(pthis, globalCtx); + func_80AE73D8(pthis, globalCtx); +} + +void func_80AE7CE8(EnRl* pthis, GlobalContext* globalCtx) { + s32 temp; + + func_80AE744C(pthis, globalCtx); + temp = func_80AE7494(pthis); + func_80AE72D0(pthis); + func_80AE7BF8(pthis, temp); + func_80AE73D8(pthis, globalCtx); +} + +void func_80AE7D40(EnRl* pthis, GlobalContext* globalCtx) { + func_80AE744C(pthis, globalCtx); + func_80AE7494(pthis); + func_80AE72D0(pthis); + func_80AE7AF8(pthis, globalCtx); + func_80AE73D8(pthis, globalCtx); +} + +void func_80AE7D94(EnRl* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp = pthis->eyeTextureIndex; + void* tex = D_80AE81A0[temp]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rl_inKenjyanomaDemo02.c", 304); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + NULL, NULL, NULL, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rl_inKenjyanomaDemo02.c", 331); +} + +static EnRlActionFunc sActionFuncs[] = { + func_80AE7798, func_80AE77B8, func_80AE77F8, func_80AE7838, + func_80AE7C64, func_80AE7C94, func_80AE7CE8, func_80AE7D40, +}; + +void EnRl_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRl* pthis = (EnRl*)thisx; + + if ((pthis->action < 0) || (pthis->action > 7) || (sActionFuncs[pthis->action] == NULL)) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void EnRl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRl* pthis = (EnRl*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); + if (pthis->actor.params == 2) { + func_80AE7878(pthis, globalCtx); + } else { + func_80AE7544(pthis, globalCtx); + } +} +void func_80AE7FD0(EnRl* pthis, GlobalContext* globalCtx) { +} + +void func_80AE7FDC(EnRl* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp = pthis->eyeTextureIndex; + void* tex = D_80AE81A0[temp]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rl.c", 416); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, + &pthis->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rl.c", 437); +} + +static EnRlDrawFunc sDrawFuncs[] = { + func_80AE7FD0, + func_80AE7FDC, + func_80AE7D94, +}; + +void EnRl_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRl* pthis = (EnRl*)thisx; + + if (pthis->drawConfig < 0 || pthis->drawConfig >= 3 || sDrawFuncs[pthis->drawConfig] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} + +ActorInit En_Rl_InitVars = { + ACTOR_EN_RL, + ACTORCAT_NPC, + FLAGS, + OBJECT_RL, + sizeof(EnRl), + (ActorFunc)EnRl_Init, + (ActorFunc)EnRl_Destroy, + (ActorFunc)EnRl_Update, + (ActorFunc)EnRl_Draw, +}; diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c deleted file mode 100644 index 8323dc893..000000000 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ /dev/null @@ -1,917 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RR_Z_EN_RR_C -#include "actor_common.h" -/* - * File: z_en_rr.c - * Overlay: ovl_En_Rr - * Description: Like Like - */ - -#include "z_en_rr.h" -#include "objects/object_rr/object_rr.h" -#include "vt.h" -#include "def/code_80097A00.h" -#include "def/code_800A9F30.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_10) - -#define RR_MESSAGE_SHIELD (1 << 0) -#define RR_MESSAGE_TUNIC (1 << 1) -#define RR_MOUTH 4 -#define RR_BASE 0 - -typedef enum { - /* 0 */ REACH_NONE, - /* 1 */ REACH_EXTEND, - /* 2 */ REACH_STOP, - /* 3 */ REACH_OPEN, - /* 4 */ REACH_GAPE, - /* 5 */ REACH_CLOSE -} EnRrReachState; - -typedef enum { - /* 0x0 */ RR_DMG_NONE, - /* 0x1 */ RR_DMG_STUN, - /* 0x2 */ RR_DMG_FIRE, - /* 0x3 */ RR_DMG_ICE, - /* 0x4 */ RR_DMG_LIGHT_MAGIC, - /* 0xB */ RR_DMG_LIGHT_ARROW = 11, - /* 0xC */ RR_DMG_SHDW_ARROW, - /* 0xD */ RR_DMG_WIND_ARROW, - /* 0xE */ RR_DMG_SPRT_ARROW, - /* 0xF */ RR_DMG_NORMAL -} EnRrDamageEffect; - -typedef enum { - /* 0 */ RR_DROP_RANDOM_RUPEE, - /* 1 */ RR_DROP_MAGIC, - /* 2 */ RR_DROP_ARROW, - /* 3 */ RR_DROP_FLEXIBLE, - /* 4 */ RR_DROP_RUPEE_PURPLE, - /* 5 */ RR_DROP_RUPEE_RED -} EnRrDropType; - -void EnRr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRr_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnRr_InitBodySegments(EnRr* this, GlobalContext* globalCtx); - -void EnRr_SetupDamage(EnRr* this); -void EnRr_SetupDeath(EnRr* this); - -void EnRr_Approach(EnRr* this, GlobalContext* globalCtx); -void EnRr_Reach(EnRr* this, GlobalContext* globalCtx); -void EnRr_GrabPlayer(EnRr* this, GlobalContext* globalCtx); -void EnRr_Damage(EnRr* this, GlobalContext* globalCtx); -void EnRr_Death(EnRr* this, GlobalContext* globalCtx); -void EnRr_Retreat(EnRr* this, GlobalContext* globalCtx); -void EnRr_Stunned(EnRr* this, GlobalContext* globalCtx); - -const ActorInit En_Rr_InitVars = { - ACTOR_EN_RR, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_RR, - sizeof(EnRr), - (ActorFunc)EnRr_Init, - (ActorFunc)EnRr_Destroy, - (ActorFunc)EnRr_Update, - (ActorFunc)EnRr_Draw, -}; - -static char* sDropNames[] = { - // "type 7", "small magic jar", "arrow", "fairy", "20 rupees", "50 rupees" - "タイプ7 ", "魔法の壷小", "矢 ", "妖精 ", "20ルピー ", "50ルピー ", -}; - -static ColliderCylinderInitType1 sCylinderInit1 = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 30, 55, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInitType1 sCylinderInit2 = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 20, 20, -10, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, RR_DMG_NONE), - /* Deku stick */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Slingshot */ DMG_ENTRY(1, RR_DMG_NORMAL), - /* Explosive */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Boomerang */ DMG_ENTRY(0, RR_DMG_STUN), - /* Normal arrow */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Hammer swing */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Hookshot */ DMG_ENTRY(0, RR_DMG_STUN), - /* Kokiri sword */ DMG_ENTRY(1, RR_DMG_NORMAL), - /* Master sword */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Giant's Knife */ DMG_ENTRY(4, RR_DMG_NORMAL), - /* Fire arrow */ DMG_ENTRY(4, RR_DMG_FIRE), - /* Ice arrow */ DMG_ENTRY(4, RR_DMG_ICE), - /* Light arrow */ DMG_ENTRY(15, RR_DMG_LIGHT_ARROW), - /* Unk arrow 1 */ DMG_ENTRY(4, RR_DMG_WIND_ARROW), - /* Unk arrow 2 */ DMG_ENTRY(15, RR_DMG_SHDW_ARROW), - /* Unk arrow 3 */ DMG_ENTRY(15, RR_DMG_SPRT_ARROW), - /* Fire magic */ DMG_ENTRY(4, RR_DMG_FIRE), - /* Ice magic */ DMG_ENTRY(3, RR_DMG_ICE), - /* Light magic */ DMG_ENTRY(10, RR_DMG_LIGHT_MAGIC), - /* Shield */ DMG_ENTRY(0, RR_DMG_NONE), - /* Mirror Ray */ DMG_ENTRY(0, RR_DMG_NONE), - /* Kokiri spin */ DMG_ENTRY(1, RR_DMG_NORMAL), - /* Giant spin */ DMG_ENTRY(4, RR_DMG_NORMAL), - /* Master spin */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Kokiri jump */ DMG_ENTRY(2, RR_DMG_NORMAL), - /* Giant jump */ DMG_ENTRY(8, RR_DMG_NORMAL), - /* Master jump */ DMG_ENTRY(4, RR_DMG_NORMAL), - /* Unknown 1 */ DMG_ENTRY(10, RR_DMG_SPRT_ARROW), - /* Unblockable */ DMG_ENTRY(0, RR_DMG_NONE), - /* Hammer jump */ DMG_ENTRY(0, RR_DMG_NONE), - /* Unknown 2 */ DMG_ENTRY(0, RR_DMG_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x37, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -void EnRr_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnRr* this = (EnRr*)thisx; - s32 i; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.health = 4; - Collider_InitCylinder(globalCtx, &this->collider1); - Collider_SetCylinderType1(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_InitCylinder(globalCtx, &this->collider2); - Collider_SetCylinderType1(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); - Actor_SetFocus(&this->actor, 30.0f); - this->actor.scale.y = 0.013f; - this->actor.scale.x = this->actor.scale.z = 0.014f; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.velocity.y = this->actor.speedXZ = 0.0f; - this->actor.gravity = -0.4f; - this->actionTimer = 0; - this->eatenShield = 0; - this->eatenTunic = 0; - this->retreat = false; - this->grabTimer = 0; - this->invincibilityTimer = 0; - this->effectTimer = 0; - this->hasPlayer = false; - this->stopScroll = false; - this->ocTimer = 0; - this->reachState = this->isDead = false; - this->actionFunc = EnRr_Approach; - for (i = 0; i < 5; i++) { - this->bodySegs[i].height = this->bodySegs[i].heightTarget = this->bodySegs[i].scaleMod.x = - this->bodySegs[i].scaleMod.y = this->bodySegs[i].scaleMod.z = 0.0f; - } - EnRr_InitBodySegments(this, globalCtx); -} - -void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnRr* this = (EnRr*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); -} - -void EnRr_SetSpeed(EnRr* this, f32 speed) { - this->actor.speedXZ = speed; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_WALK); -} - -void EnRr_SetupReach(EnRr* this) { - static f32 segmentHeights[] = { 0.0f, 500.0f, 750.0f, 1000.0f, 1000.0f }; - s32 i; - - this->reachState = 1; - this->actionTimer = 20; - this->segPhaseVelTarget = 2500.0f; - this->segMoveRate = 0.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].heightTarget = segmentHeights[i]; - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.z = 0.8f; - this->bodySegs[i].rotTarget.x = 6000.0f; - this->bodySegs[i].rotTarget.z = 0.0f; - } - this->actionFunc = EnRr_Reach; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_UNARI); -} - -void EnRr_SetupNeutral(EnRr* this) { - s32 i; - - this->reachState = 0; - this->segMoveRate = 0.0f; - this->segPhaseVelTarget = 2500.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].heightTarget = 0.0f; - this->bodySegs[i].rotTarget.x = this->bodySegs[i].rotTarget.z = 0.0f; - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.z = 1.0f; - } - if (this->retreat) { - this->actionTimer = 100; - this->actionFunc = EnRr_Retreat; - } else { - this->actionTimer = 60; - this->actionFunc = EnRr_Approach; - } -} - -void EnRr_SetupGrabPlayer(EnRr* this, Player* player) { - s32 i; - - this->grabTimer = 100; - this->actor.flags &= ~ACTOR_FLAG_0; - this->ocTimer = 8; - this->hasPlayer = true; - this->reachState = 0; - this->segMoveRate = this->swallowOffset = this->actor.speedXZ = 0.0f; - this->pulseSizeTarget = 0.15f; - this->segPhaseVelTarget = 5000.0f; - this->wobbleSizeTarget = 512.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].heightTarget = 0.0f; - this->bodySegs[i].rotTarget.x = this->bodySegs[i].rotTarget.z = 0.0f; - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.z = 1.0f; - } - this->actionFunc = EnRr_GrabPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DRINK); -} - -u8 EnRr_GetMessage(u8 shield, u8 tunic) { - u8 messageIndex = 0; - - if ((shield == 1 /* Deku shield */) || (shield == 2 /* Hylian shield */)) { - messageIndex = RR_MESSAGE_SHIELD; - } - if ((tunic == 2 /* Goron tunic */) || (tunic == 3 /* Zora tunic */)) { - messageIndex |= RR_MESSAGE_TUNIC; - } - - return messageIndex; -} - -void EnRr_SetupReleasePlayer(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u8 shield; - u8 tunic; - - this->actor.flags |= ACTOR_FLAG_0; - this->hasPlayer = false; - this->ocTimer = 110; - this->segMoveRate = 0.0f; - this->segPhaseVelTarget = 2500.0f; - this->wobbleSizeTarget = 2048.0f; - tunic = 0; - shield = 0; - if (CUR_EQUIP_VALUE(EQUIP_SHIELD) != 3 /* Mirror shield */) { - shield = Inventory_DeleteEquipment(globalCtx, EQUIP_SHIELD); - if (shield != 0) { - this->eatenShield = shield; - this->retreat = true; - } - } - if (CUR_EQUIP_VALUE(EQUIP_TUNIC) != 1 /* Kokiri tunic */) { - tunic = Inventory_DeleteEquipment(globalCtx, EQUIP_TUNIC); - if (tunic != 0) { - this->eatenTunic = tunic; - this->retreat = true; - } - } - player->actor.parent = NULL; - switch (EnRr_GetMessage(shield, tunic)) { - case RR_MESSAGE_SHIELD: - Message_StartTextbox(globalCtx, 0x305F, NULL); - break; - case RR_MESSAGE_TUNIC: - Message_StartTextbox(globalCtx, 0x3060, NULL); - break; - case RR_MESSAGE_TUNIC | RR_MESSAGE_SHIELD: - Message_StartTextbox(globalCtx, 0x3061, NULL); - break; - } - osSyncPrintf(VT_FGCOL(YELLOW) "%s[%d] : Rr_Catch_Cancel" VT_RST "\n", "../z_en_rr.c", 650); - func_8002F6D4(globalCtx, &this->actor, 4.0f, this->actor.shape.rot.y, 12.0f, 8); - if (this->actor.colorFilterTimer == 0) { - this->actionFunc = EnRr_Approach; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_THROW); - } else if (this->actor.colChkInfo.health != 0) { - EnRr_SetupDamage(this); - } else { - EnRr_SetupDeath(this); - } -} - -void EnRr_SetupDamage(EnRr* this) { - s32 i; - - this->reachState = 0; - this->actionTimer = 20; - this->segMoveRate = 0.0f; - this->segPhaseVelTarget = 2500.0f; - this->pulseSizeTarget = 0.0f; - this->wobbleSizeTarget = 0.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].heightTarget = 0.0f; - this->bodySegs[i].rotTarget.x = this->bodySegs[i].rotTarget.z = 0.0f; - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.z = 1.0f; - } - this->actionFunc = EnRr_Damage; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DAMAGE); -} - -void EnRr_SetupApproach(EnRr* this) { - s32 i; - - this->segMoveRate = 0.0f; - this->pulseSizeTarget = 0.15f; - this->segPhaseVelTarget = 2500.0f; - this->wobbleSizeTarget = 2048.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].heightTarget = 0.0f; - this->bodySegs[i].rotTarget.x = this->bodySegs[i].rotTarget.z = 0.0f; - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.z = 1.0f; - } - this->actionFunc = EnRr_Approach; -} - -void EnRr_SetupDeath(EnRr* this) { - s32 i; - - this->isDead = true; - this->frameCount = 0; - this->shrinkRate = 0.0f; - this->segMoveRate = 0.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].heightTarget = 0.0f; - this->bodySegs[i].rotTarget.x = this->bodySegs[i].rotTarget.z = 0.0f; - } - this->actionFunc = EnRr_Death; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DEAD); - this->actor.flags &= ~ACTOR_FLAG_0; -} - -void EnRr_SetupStunned(EnRr* this) { - s32 i; - - this->stopScroll = true; - this->segMovePhase = 0; - this->segPhaseVel = 0.0f; - this->segPhaseVelTarget = 2500.0f; - this->segPulsePhaseDiff = 0.0f; - this->segWobblePhaseDiffX = 0.0f; - this->segWobbleXTarget = 3.0f; - this->segWobblePhaseDiffZ = 0.0f; - this->segWobbleZTarget = 1.0f; - this->pulseSize = 0.0f; - this->pulseSizeTarget = 0.15f; - this->wobbleSize = 0.0f; - this->wobbleSizeTarget = 2048.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].scaleMod.y = 0.0f; - this->bodySegs[i].rotTarget.x = 0.0f; - this->bodySegs[i].rotTarget.y = 0.0f; - this->bodySegs[i].rotTarget.z = 0.0f; - this->bodySegs[i].scale.x = this->bodySegs[i].scale.y = this->bodySegs[i].scale.z = - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.y = this->bodySegs[i].scaleTarget.z = 1.0f; - } - this->actionFunc = EnRr_Stunned; -} - -void EnRr_CollisionCheck(EnRr* this, GlobalContext* globalCtx) { - Vec3f hitPos; - Player* player = GET_PLAYER(globalCtx); - - if (this->collider2.base.acFlags & AC_HIT) { - this->collider2.base.acFlags &= ~AC_HIT; - // "Kakin" (not sure what this means) - osSyncPrintf(VT_FGCOL(GREEN) "カキン(%d)!!" VT_RST "\n", this->frameCount); - hitPos.x = this->collider2.info.bumper.hitPos.x; - hitPos.y = this->collider2.info.bumper.hitPos.y; - hitPos.z = this->collider2.info.bumper.hitPos.z; - CollisionCheck_SpawnShieldParticlesMetal2(globalCtx, &hitPos); - } else { - if (this->collider1.base.acFlags & AC_HIT) { - u8 dropType = RR_DROP_RANDOM_RUPEE; - - this->collider1.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != 0) { - hitPos.x = this->collider1.info.bumper.hitPos.x; - hitPos.y = this->collider1.info.bumper.hitPos.y; - hitPos.z = this->collider1.info.bumper.hitPos.z; - CollisionCheck_BlueBlood(globalCtx, NULL, &hitPos); - } - switch (this->actor.colChkInfo.damageEffect) { - case RR_DMG_LIGHT_ARROW: - dropType++; // purple rupee - case RR_DMG_SHDW_ARROW: - dropType++; // flexible - case RR_DMG_WIND_ARROW: - dropType++; // arrow - case RR_DMG_SPRT_ARROW: - dropType++; // magic jar - case RR_DMG_NORMAL: - // "ouch" - osSyncPrintf(VT_FGCOL(RED) "いてっ( %d : LIFE %d : DAMAGE %d : %x )!!" VT_RST "\n", - this->frameCount, this->actor.colChkInfo.health, this->actor.colChkInfo.damage, - this->actor.colChkInfo.damageEffect); - this->stopScroll = false; - Actor_ApplyDamage(&this->actor); - this->invincibilityTimer = 40; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, this->invincibilityTimer); - if (this->hasPlayer) { - EnRr_SetupReleasePlayer(this, globalCtx); - } else if (this->actor.colChkInfo.health != 0) { - EnRr_SetupDamage(this); - } else { - this->dropType = dropType; - EnRr_SetupDeath(this); - } - return; - case RR_DMG_FIRE: // Fire Arrow and Din's Fire - Actor_ApplyDamage(&this->actor); - if (this->actor.colChkInfo.health == 0) { - this->dropType = RR_DROP_RANDOM_RUPEE; - } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - this->effectTimer = 20; - EnRr_SetupStunned(this); - return; - case RR_DMG_ICE: // Ice Arrow and unused ice magic - Actor_ApplyDamage(&this->actor); - if (this->actor.colChkInfo.health == 0) { - this->dropType = RR_DROP_RANDOM_RUPEE; - } - if (this->actor.colorFilterTimer == 0) { - this->effectTimer = 20; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0x2000, 0x50); - } - EnRr_SetupStunned(this); - return; - case RR_DMG_LIGHT_MAGIC: // Unused light magic - Actor_ApplyDamage(&this->actor); - if (this->actor.colChkInfo.health == 0) { - this->dropType = RR_DROP_RUPEE_RED; - } - Actor_SetColorFilter(&this->actor, -0x8000, 0xFF, 0x2000, 0x50); - EnRr_SetupStunned(this); - return; - case RR_DMG_STUN: // Boomerang and Hookshot - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0x2000, 0x50); - EnRr_SetupStunned(this); - return; - } - } - if ((this->ocTimer == 0) && (this->actor.colorFilterTimer == 0) && (player->invincibilityTimer == 0) && - !(player->stateFlags2 & 0x80) && - ((this->collider1.base.ocFlags1 & OC1_HIT) || (this->collider2.base.ocFlags1 & OC1_HIT))) { - this->collider1.base.ocFlags1 &= ~OC1_HIT; - this->collider2.base.ocFlags1 &= ~OC1_HIT; - // "catch" - osSyncPrintf(VT_FGCOL(GREEN) "キャッチ(%d)!!" VT_RST "\n", this->frameCount); - if (globalCtx->grabPlayer(globalCtx, player)) { - player->actor.parent = &this->actor; - this->stopScroll = false; - EnRr_SetupGrabPlayer(this, player); - } - } - } -} - -void EnRr_InitBodySegments(EnRr* this, GlobalContext* globalCtx) { - s32 i; - - this->segMovePhase = 0; - this->segPhaseVel = 0.0f; - this->segPhaseVelTarget = 2500.0f; - this->segPulsePhaseDiff = 0.0f; - this->segWobblePhaseDiffX = 0.0f; - this->segWobbleXTarget = 3.0f; - this->segWobblePhaseDiffZ = 0.0f; - this->segWobbleZTarget = 1.0f; - this->pulseSize = 0.0f; - this->pulseSizeTarget = 0.15f; - this->wobbleSize = 0.0f; - this->wobbleSizeTarget = 2048.0f; - for (i = 0; i < 5; i++) { - this->bodySegs[i].scaleMod.y = 0.0f; - this->bodySegs[i].rotTarget.x = 0.0f; - this->bodySegs[i].rotTarget.y = 0.0f; - this->bodySegs[i].rotTarget.z = 0.0f; - this->bodySegs[i].scale.x = this->bodySegs[i].scale.y = this->bodySegs[i].scale.z = - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.y = this->bodySegs[i].scaleTarget.z = 1.0f; - } - for (i = 0; i < 5; i++) { - this->bodySegs[i].scaleMod.x = this->bodySegs[i].scaleMod.z = - Math_CosS(i * (u32)(s16)this->segPulsePhaseDiff * 0x1000) * this->pulseSize; - } - for (i = 1; i < 5; i++) { - this->bodySegs[i].rotTarget.x = Math_CosS(i * (u32)(s16)this->segWobblePhaseDiffX * 0x1000) * this->wobbleSize; - this->bodySegs[i].rotTarget.z = Math_SinS(i * (u32)(s16)this->segWobblePhaseDiffZ * 0x1000) * this->wobbleSize; - } -} - -void EnRr_UpdateBodySegments(EnRr* this, GlobalContext* globalCtx) { - s32 i; - s16 phase = this->segMovePhase; - - if (!this->isDead) { - for (i = 0; i < 5; i++) { - this->bodySegs[i].scaleMod.x = this->bodySegs[i].scaleMod.z = - Math_CosS(phase + i * (s16)this->segPulsePhaseDiff * 0x1000) * this->pulseSize; - } - phase = this->segMovePhase; - if (!this->isDead && (this->reachState == 0)) { - for (i = 1; i < 5; i++) { - this->bodySegs[i].rotTarget.x = - Math_CosS(phase + i * (s16)this->segWobblePhaseDiffX * 0x1000) * this->wobbleSize; - this->bodySegs[i].rotTarget.z = - Math_SinS(phase + i * (s16)this->segWobblePhaseDiffZ * 0x1000) * this->wobbleSize; - } - } - } - if (!this->stopScroll) { - this->segMovePhase += (s16)this->segPhaseVel; - } -} - -void EnRr_Approach(EnRr* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1F4, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actionTimer == 0) && (this->actor.xzDistToPlayer < 160.0f)) { - EnRr_SetupReach(this); - } else if ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.speedXZ == 0.0f)) { - EnRr_SetSpeed(this, 2.0f); - } -} - -void EnRr_Reach(EnRr* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1F4, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - switch (this->reachState) { - case REACH_EXTEND: - if (this->actionTimer == 0) { - this->reachState = REACH_STOP; - } - break; - case REACH_STOP: - if (this->actionTimer == 0) { - this->actionTimer = 5; - this->bodySegs[RR_MOUTH].scaleTarget.x = this->bodySegs[RR_MOUTH].scaleTarget.z = 1.5f; - this->reachState = REACH_OPEN; - } - break; - case REACH_OPEN: - if (this->actionTimer == 0) { - this->actionTimer = 2; - this->bodySegs[RR_MOUTH].heightTarget = 2000.0f; - this->reachState = REACH_GAPE; - } - break; - case REACH_GAPE: - if (this->actionTimer == 0) { - this->actionTimer = 20; - this->bodySegs[RR_MOUTH].scaleTarget.x = this->bodySegs[RR_MOUTH].scaleTarget.z = 0.8f; - this->reachState = REACH_CLOSE; - } - break; - case REACH_CLOSE: - if (this->actionTimer == 0) { - EnRr_SetupNeutral(this); - } - break; - } -} - -void EnRr_GrabPlayer(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - func_800AA000(this->actor.xyzDistToPlayerSq, 120, 2, 120); - if ((this->frameCount % 8) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_EAT); - } - this->ocTimer = 8; - if ((this->grabTimer == 0) || !(player->stateFlags2 & 0x80)) { - EnRr_SetupReleasePlayer(this, globalCtx); - } else { - Math_ApproachF(&player->actor.world.pos.x, this->mouthPos.x, 1.0f, 30.0f); - Math_ApproachF(&player->actor.world.pos.y, this->mouthPos.y + this->swallowOffset, 1.0f, 30.0f); - Math_ApproachF(&player->actor.world.pos.z, this->mouthPos.z, 1.0f, 30.0f); - Math_ApproachF(&this->swallowOffset, -55.0f, 1.0f, 5.0f); - } -} - -void EnRr_Damage(EnRr* this, GlobalContext* globalCtx) { - s32 i; - - if (this->actor.colorFilterTimer == 0) { - EnRr_SetupApproach(this); - } else if ((this->actor.colorFilterTimer & 8) != 0) { - for (i = 1; i < 5; i++) { - this->bodySegs[i].rotTarget.z = 5000.0f; - } - } else { - for (i = 1; i < 5; i++) { - this->bodySegs[i].rotTarget.z = -5000.0f; - } - } -} - -void EnRr_Death(EnRr* this, GlobalContext* globalCtx) { - s32 pad; - s32 i; - - if (this->frameCount < 40) { - for (i = 0; i < 5; i++) { - Math_ApproachF(&this->bodySegs[i].heightTarget, i + 59 - (this->frameCount * 25.0f), 1.0f, 50.0f); - this->bodySegs[i].scaleTarget.x = this->bodySegs[i].scaleTarget.z = - (SQ(4 - i) * (f32)this->frameCount * 0.003f) + 1.0f; - } - } else if (this->frameCount >= 95) { - Vec3f dropPos; - - dropPos.x = this->actor.world.pos.x; - dropPos.y = this->actor.world.pos.y; - dropPos.z = this->actor.world.pos.z; - switch (this->eatenShield) { - case 1: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_SHIELD_DEKU); - break; - case 2: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_SHIELD_HYLIAN); - break; - } - switch (this->eatenTunic) { - case 2: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_TUNIC_GORON); - break; - case 3: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_TUNIC_ZORA); - break; - } - // "dropped" - osSyncPrintf(VT_FGCOL(GREEN) "「%s」が出た!!" VT_RST "\n", sDropNames[this->dropType]); - switch (this->dropType) { - case RR_DROP_MAGIC: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_MAGIC_SMALL); - break; - case RR_DROP_ARROW: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_ARROWS_SINGLE); - break; - case RR_DROP_FLEXIBLE: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_FLEXIBLE); - break; - case RR_DROP_RUPEE_PURPLE: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_RUPEE_PURPLE); - break; - case RR_DROP_RUPEE_RED: - Item_DropCollectible(globalCtx, &dropPos, ITEM00_RUPEE_RED); - break; - case RR_DROP_RANDOM_RUPEE: - default: - Item_DropCollectibleRandom(globalCtx, &this->actor, &dropPos, 12 << 4); - break; - } - Actor_Kill(&this->actor); - } else if (this->frameCount == 88) { - Vec3f pos; - Vec3f vel; - Vec3f accel; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 20.0f; - pos.z = this->actor.world.pos.z; - vel.x = 0.0f; - vel.y = 0.0f; - vel.z = 0.0f; - accel.x = 0.0f; - accel.y = 0.0f; - accel.z = 0.0f; - - EffectSsDeadDb_Spawn(globalCtx, &pos, &vel, &accel, 100, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, true); - } else { - Math_ApproachF(&this->actor.scale.x, 0.0f, 1.0f, this->shrinkRate); - Math_ApproachF(&this->shrinkRate, 0.001f, 1.0f, 0.00001f); - this->actor.scale.z = this->actor.scale.x; - } -} - -void EnRr_Retreat(EnRr* this, GlobalContext* globalCtx) { - if (this->actionTimer == 0) { - this->retreat = false; - this->actionFunc = EnRr_Approach; - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xA, 0x3E8, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->actor.speedXZ == 0.0f) { - EnRr_SetSpeed(this, 2.0f); - } - } -} - -void EnRr_Stunned(EnRr* this, GlobalContext* globalCtx) { - if (this->actor.colorFilterTimer == 0) { - this->stopScroll = false; - if (this->hasPlayer) { - EnRr_SetupReleasePlayer(this, globalCtx); - } else if (this->actor.colChkInfo.health != 0) { - this->actionFunc = EnRr_Approach; - } else { - EnRr_SetupDeath(this); - } - } -} - -void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnRr* this = (EnRr*)thisx; - s32 i; - - this->frameCount++; - if (!this->stopScroll) { - this->scrollTimer++; - } - if (this->actionTimer != 0) { - this->actionTimer--; - } - if (this->grabTimer != 0) { - this->grabTimer--; - } - if (this->ocTimer != 0) { - this->ocTimer--; - } - if (this->invincibilityTimer != 0) { - this->invincibilityTimer--; - } - if (this->effectTimer != 0) { - this->effectTimer--; - } - - Actor_SetFocus(&this->actor, 30.0f); - EnRr_UpdateBodySegments(this, globalCtx); - if (!this->isDead && ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000))) { - EnRr_CollisionCheck(this, globalCtx); - } - - this->actionFunc(this, globalCtx); - if (this->hasPlayer == 0x3F80) { // checks if 1.0f has been stored to hasPlayer's address - ASSERT(0, "0", "../z_en_rr.c", 1355); - } - - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); - Actor_MoveForward(&this->actor); - Collider_UpdateCylinder(&this->actor, &this->collider1); - this->collider2.dim.pos.x = this->mouthPos.x; - this->collider2.dim.pos.y = this->mouthPos.y; - this->collider2.dim.pos.z = this->mouthPos.z; - if (!this->isDead && (this->invincibilityTimer == 0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - if (this->ocTimer == 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - } else { - this->collider2.base.ocFlags1 &= ~OC1_HIT; - this->collider2.base.acFlags &= ~AC_HIT; - this->collider1.base.ocFlags1 &= ~OC1_HIT; - this->collider1.base.acFlags &= ~AC_HIT; - } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 30.0f, 20.0f, 7); - if (!this->stopScroll) { - Math_ApproachF(&this->segPhaseVel, this->segPhaseVelTarget, 1.0f, 50.0f); - Math_ApproachF(&this->segPulsePhaseDiff, 4.0f, 1.0f, 5.0f); - Math_ApproachF(&this->segWobblePhaseDiffX, this->segWobbleXTarget, 1.0f, 0.04f); - Math_ApproachF(&this->segWobblePhaseDiffZ, this->segWobbleZTarget, 1.0f, 0.01f); - Math_ApproachF(&this->pulseSize, this->pulseSizeTarget, 1.0f, 0.0015f); - Math_ApproachF(&this->wobbleSize, this->wobbleSizeTarget, 1.0f, 20.0f); - for (i = 0; i < 5; i++) { - Math_SmoothStepToS(&this->bodySegs[i].rot.x, this->bodySegs[i].rotTarget.x, 5, this->segMoveRate * 1000.0f, - 0); - Math_SmoothStepToS(&this->bodySegs[i].rot.z, this->bodySegs[i].rotTarget.z, 5, this->segMoveRate * 1000.0f, - 0); - Math_ApproachF(&this->bodySegs[i].scale.x, this->bodySegs[i].scaleTarget.x, 1.0f, this->segMoveRate * 0.2f); - this->bodySegs[i].scale.z = this->bodySegs[i].scale.x; - Math_ApproachF(&this->bodySegs[i].height, this->bodySegs[i].heightTarget, 1.0f, this->segMoveRate * 300.0f); - } - Math_ApproachF(&this->segMoveRate, 1.0f, 1.0f, 0.2f); - } -} - -static Vec3f sEffectOffsets[] = { - { 25.0f, 0.0f, 0.0f }, - { -25.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 25.0f }, - { 0.0f, 0.0f, -25.0f }, -}; - -void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - Vec3f zeroVec; - EnRr* this = (EnRr*)thisx; - s32 i; - Mtx* segMtx = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Mtx)); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rr.c", 1478); - if (1) {} - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x0C, segMtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (this->scrollTimer * 0) & 0x7F, - (this->scrollTimer * 0) & 0x3F, 32, 16, 1, (this->scrollTimer * 0) & 0x3F, - (this->scrollTimer * -6) & 0x7F, 32, 16)); - Matrix_Push(); - - Matrix_Scale((1.0f + this->bodySegs[RR_BASE].scaleMod.x) * this->bodySegs[RR_BASE].scale.x, - (1.0f + this->bodySegs[RR_BASE].scaleMod.y) * this->bodySegs[RR_BASE].scale.y, - (1.0f + this->bodySegs[RR_BASE].scaleMod.z) * this->bodySegs[RR_BASE].scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_rr.c", 1501), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_Pop(); - zeroVec.x = 0.0f; - zeroVec.y = 0.0f; - zeroVec.z = 0.0f; - for (i = 1; i < 5; i++) { - Matrix_Translate(0.0f, this->bodySegs[i].height + 1000.0f, 0.0f, MTXMODE_APPLY); - - Matrix_RotateZYX(this->bodySegs[i].rot.x, this->bodySegs[i].rot.y, this->bodySegs[i].rot.z, MTXMODE_APPLY); - Matrix_Push(); - Matrix_Scale((1.0f + this->bodySegs[i].scaleMod.x) * this->bodySegs[i].scale.x, - (1.0f + this->bodySegs[i].scaleMod.y) * this->bodySegs[i].scale.y, - (1.0f + this->bodySegs[i].scaleMod.z) * this->bodySegs[i].scale.z, MTXMODE_APPLY); - Matrix_ToMtx(segMtx, "../z_en_rr.c", 1527); - Matrix_Pop(); - segMtx++; - Matrix_MultVec3f(&zeroVec, &this->effectPos[i]); - } - this->effectPos[0] = this->actor.world.pos; - Matrix_MultVec3f(&zeroVec, &this->mouthPos); - gSPDisplayList(POLY_XLU_DISP++, gLikeLikeDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rr.c", 1551); - if (this->effectTimer != 0) { - Vec3f effectPos; - s16 effectTimer = this->effectTimer - 1; - - this->actor.colorFilterTimer++; - if ((effectTimer & 1) == 0) { - s32 segIndex = 4 - (effectTimer >> 2); - s32 offIndex = (effectTimer >> 1) & 3; - - effectPos.x = this->effectPos[segIndex].x + sEffectOffsets[offIndex].x + Rand_CenteredFloat(10.0f); - effectPos.y = this->effectPos[segIndex].y + sEffectOffsets[offIndex].y + Rand_CenteredFloat(10.0f); - effectPos.z = this->effectPos[segIndex].z + sEffectOffsets[offIndex].z + Rand_CenteredFloat(10.0f); - if (this->actor.colorFilterParams & 0x4000) { - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &effectPos, 100, 0, 0, -1); - } else { - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &effectPos, 150, 150, 150, 250, 235, 245, 255, - 3.0f); - } - } - } -} diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.cpp b/src/overlays/actors/ovl_En_Rr/z_en_rr.cpp new file mode 100644 index 000000000..c0476c113 --- /dev/null +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.cpp @@ -0,0 +1,917 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RR_Z_EN_RR_C +#include "actor_common.h" +/* + * File: z_en_rr.c + * Overlay: ovl_En_Rr + * Description: Like Like + */ + +#include "z_en_rr.h" +#include "objects/object_rr/object_rr.h" +#include "vt.h" +#include "def/code_80097A00.h" +#include "def/code_800A9F30.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_10) + +#define RR_MESSAGE_SHIELD (1 << 0) +#define RR_MESSAGE_TUNIC (1 << 1) +#define RR_MOUTH 4 +#define RR_BASE 0 + +typedef enum { + /* 0 */ REACH_NONE, + /* 1 */ REACH_EXTEND, + /* 2 */ REACH_STOP, + /* 3 */ REACH_OPEN, + /* 4 */ REACH_GAPE, + /* 5 */ REACH_CLOSE +} EnRrReachState; + +typedef enum { + /* 0x0 */ RR_DMG_NONE, + /* 0x1 */ RR_DMG_STUN, + /* 0x2 */ RR_DMG_FIRE, + /* 0x3 */ RR_DMG_ICE, + /* 0x4 */ RR_DMG_LIGHT_MAGIC, + /* 0xB */ RR_DMG_LIGHT_ARROW = 11, + /* 0xC */ RR_DMG_SHDW_ARROW, + /* 0xD */ RR_DMG_WIND_ARROW, + /* 0xE */ RR_DMG_SPRT_ARROW, + /* 0xF */ RR_DMG_NORMAL +} EnRrDamageEffect; + +typedef enum { + /* 0 */ RR_DROP_RANDOM_RUPEE, + /* 1 */ RR_DROP_MAGIC, + /* 2 */ RR_DROP_ARROW, + /* 3 */ RR_DROP_FLEXIBLE, + /* 4 */ RR_DROP_RUPEE_PURPLE, + /* 5 */ RR_DROP_RUPEE_RED +} EnRrDropType; + +void EnRr_Init(Actor* thisx, GlobalContext* globalCtx); +void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnRr_Update(Actor* thisx, GlobalContext* globalCtx); +void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnRr_InitBodySegments(EnRr* pthis, GlobalContext* globalCtx); + +void EnRr_SetupDamage(EnRr* pthis); +void EnRr_SetupDeath(EnRr* pthis); + +void EnRr_Approach(EnRr* pthis, GlobalContext* globalCtx); +void EnRr_Reach(EnRr* pthis, GlobalContext* globalCtx); +void EnRr_GrabPlayer(EnRr* pthis, GlobalContext* globalCtx); +void EnRr_Damage(EnRr* pthis, GlobalContext* globalCtx); +void EnRr_Death(EnRr* pthis, GlobalContext* globalCtx); +void EnRr_Retreat(EnRr* pthis, GlobalContext* globalCtx); +void EnRr_Stunned(EnRr* pthis, GlobalContext* globalCtx); + +ActorInit En_Rr_InitVars = { + ACTOR_EN_RR, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_RR, + sizeof(EnRr), + (ActorFunc)EnRr_Init, + (ActorFunc)EnRr_Destroy, + (ActorFunc)EnRr_Update, + (ActorFunc)EnRr_Draw, +}; + +static const char* sDropNames[] = { + // "type 7", "small magic jar", "arrow", "fairy", "20 rupees", "50 rupees" + "タイプ7 ", "魔法の壷小", "矢 ", "妖精 ", "20ルピー ", "50ルピー ", +}; + +static ColliderCylinderInitType1 sCylinderInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 30, 55, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInitType1 sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 20, 20, -10, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, RR_DMG_NONE), + /* Deku stick */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Slingshot */ DMG_ENTRY(1, RR_DMG_NORMAL), + /* Explosive */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Boomerang */ DMG_ENTRY(0, RR_DMG_STUN), + /* Normal arrow */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Hammer swing */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Hookshot */ DMG_ENTRY(0, RR_DMG_STUN), + /* Kokiri sword */ DMG_ENTRY(1, RR_DMG_NORMAL), + /* Master sword */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Giant's Knife */ DMG_ENTRY(4, RR_DMG_NORMAL), + /* Fire arrow */ DMG_ENTRY(4, RR_DMG_FIRE), + /* Ice arrow */ DMG_ENTRY(4, RR_DMG_ICE), + /* Light arrow */ DMG_ENTRY(15, RR_DMG_LIGHT_ARROW), + /* Unk arrow 1 */ DMG_ENTRY(4, RR_DMG_WIND_ARROW), + /* Unk arrow 2 */ DMG_ENTRY(15, RR_DMG_SHDW_ARROW), + /* Unk arrow 3 */ DMG_ENTRY(15, RR_DMG_SPRT_ARROW), + /* Fire magic */ DMG_ENTRY(4, RR_DMG_FIRE), + /* Ice magic */ DMG_ENTRY(3, RR_DMG_ICE), + /* Light magic */ DMG_ENTRY(10, RR_DMG_LIGHT_MAGIC), + /* Shield */ DMG_ENTRY(0, RR_DMG_NONE), + /* Mirror Ray */ DMG_ENTRY(0, RR_DMG_NONE), + /* Kokiri spin */ DMG_ENTRY(1, RR_DMG_NORMAL), + /* Giant spin */ DMG_ENTRY(4, RR_DMG_NORMAL), + /* Master spin */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Kokiri jump */ DMG_ENTRY(2, RR_DMG_NORMAL), + /* Giant jump */ DMG_ENTRY(8, RR_DMG_NORMAL), + /* Master jump */ DMG_ENTRY(4, RR_DMG_NORMAL), + /* Unknown 1 */ DMG_ENTRY(10, RR_DMG_SPRT_ARROW), + /* Unblockable */ DMG_ENTRY(0, RR_DMG_NONE), + /* Hammer jump */ DMG_ENTRY(0, RR_DMG_NONE), + /* Unknown 2 */ DMG_ENTRY(0, RR_DMG_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x37, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +void EnRr_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnRr* pthis = (EnRr*)thisx; + s32 i; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.colChkInfo.health = 4; + Collider_InitCylinder(globalCtx, &pthis->collider1); + Collider_SetCylinderType1(globalCtx, &pthis->collider1, &pthis->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &pthis->collider2); + Collider_SetCylinderType1(globalCtx, &pthis->collider2, &pthis->actor, &sCylinderInit2); + Actor_SetFocus(&pthis->actor, 30.0f); + pthis->actor.scale.y = 0.013f; + pthis->actor.scale.x = pthis->actor.scale.z = 0.014f; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.velocity.y = pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = -0.4f; + pthis->actionTimer = 0; + pthis->eatenShield = 0; + pthis->eatenTunic = 0; + pthis->retreat = false; + pthis->grabTimer = 0; + pthis->invincibilityTimer = 0; + pthis->effectTimer = 0; + pthis->hasPlayer = false; + pthis->stopScroll = false; + pthis->ocTimer = 0; + pthis->reachState = pthis->isDead = false; + pthis->actionFunc = EnRr_Approach; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].height = pthis->bodySegs[i].heightTarget = pthis->bodySegs[i].scaleMod.x = + pthis->bodySegs[i].scaleMod.y = pthis->bodySegs[i].scaleMod.z = 0.0f; + } + EnRr_InitBodySegments(pthis, globalCtx); +} + +void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRr* pthis = (EnRr*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider1); + Collider_DestroyCylinder(globalCtx, &pthis->collider2); +} + +void EnRr_SetSpeed(EnRr* pthis, f32 speed) { + pthis->actor.speedXZ = speed; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_WALK); +} + +void EnRr_SetupReach(EnRr* pthis) { + static f32 segmentHeights[] = { 0.0f, 500.0f, 750.0f, 1000.0f, 1000.0f }; + s32 i; + + pthis->reachState = 1; + pthis->actionTimer = 20; + pthis->segPhaseVelTarget = 2500.0f; + pthis->segMoveRate = 0.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].heightTarget = segmentHeights[i]; + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.z = 0.8f; + pthis->bodySegs[i].rotTarget.x = 6000.0f; + pthis->bodySegs[i].rotTarget.z = 0.0f; + } + pthis->actionFunc = EnRr_Reach; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_UNARI); +} + +void EnRr_SetupNeutral(EnRr* pthis) { + s32 i; + + pthis->reachState = 0; + pthis->segMoveRate = 0.0f; + pthis->segPhaseVelTarget = 2500.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].heightTarget = 0.0f; + pthis->bodySegs[i].rotTarget.x = pthis->bodySegs[i].rotTarget.z = 0.0f; + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.z = 1.0f; + } + if (pthis->retreat) { + pthis->actionTimer = 100; + pthis->actionFunc = EnRr_Retreat; + } else { + pthis->actionTimer = 60; + pthis->actionFunc = EnRr_Approach; + } +} + +void EnRr_SetupGrabPlayer(EnRr* pthis, Player* player) { + s32 i; + + pthis->grabTimer = 100; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->ocTimer = 8; + pthis->hasPlayer = true; + pthis->reachState = 0; + pthis->segMoveRate = pthis->swallowOffset = pthis->actor.speedXZ = 0.0f; + pthis->pulseSizeTarget = 0.15f; + pthis->segPhaseVelTarget = 5000.0f; + pthis->wobbleSizeTarget = 512.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].heightTarget = 0.0f; + pthis->bodySegs[i].rotTarget.x = pthis->bodySegs[i].rotTarget.z = 0.0f; + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.z = 1.0f; + } + pthis->actionFunc = EnRr_GrabPlayer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_DRINK); +} + +u8 EnRr_GetMessage(u8 shield, u8 tunic) { + u8 messageIndex = 0; + + if ((shield == 1 /* Deku shield */) || (shield == 2 /* Hylian shield */)) { + messageIndex = RR_MESSAGE_SHIELD; + } + if ((tunic == 2 /* Goron tunic */) || (tunic == 3 /* Zora tunic */)) { + messageIndex |= RR_MESSAGE_TUNIC; + } + + return messageIndex; +} + +void EnRr_SetupReleasePlayer(EnRr* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u8 shield; + u8 tunic; + + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->hasPlayer = false; + pthis->ocTimer = 110; + pthis->segMoveRate = 0.0f; + pthis->segPhaseVelTarget = 2500.0f; + pthis->wobbleSizeTarget = 2048.0f; + tunic = 0; + shield = 0; + if (CUR_EQUIP_VALUE(EQUIP_SHIELD) != 3 /* Mirror shield */) { + shield = Inventory_DeleteEquipment(globalCtx, EQUIP_SHIELD); + if (shield != 0) { + pthis->eatenShield = shield; + pthis->retreat = true; + } + } + if (CUR_EQUIP_VALUE(EQUIP_TUNIC) != 1 /* Kokiri tunic */) { + tunic = Inventory_DeleteEquipment(globalCtx, EQUIP_TUNIC); + if (tunic != 0) { + pthis->eatenTunic = tunic; + pthis->retreat = true; + } + } + player->actor.parent = NULL; + switch (EnRr_GetMessage(shield, tunic)) { + case RR_MESSAGE_SHIELD: + Message_StartTextbox(globalCtx, 0x305F, NULL); + break; + case RR_MESSAGE_TUNIC: + Message_StartTextbox(globalCtx, 0x3060, NULL); + break; + case RR_MESSAGE_TUNIC | RR_MESSAGE_SHIELD: + Message_StartTextbox(globalCtx, 0x3061, NULL); + break; + } + osSyncPrintf(VT_FGCOL(YELLOW) "%s[%d] : Rr_Catch_Cancel" VT_RST "\n", "../z_en_rr.c", 650); + func_8002F6D4(globalCtx, &pthis->actor, 4.0f, pthis->actor.shape.rot.y, 12.0f, 8); + if (pthis->actor.colorFilterTimer == 0) { + pthis->actionFunc = EnRr_Approach; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_THROW); + } else if (pthis->actor.colChkInfo.health != 0) { + EnRr_SetupDamage(pthis); + } else { + EnRr_SetupDeath(pthis); + } +} + +void EnRr_SetupDamage(EnRr* pthis) { + s32 i; + + pthis->reachState = 0; + pthis->actionTimer = 20; + pthis->segMoveRate = 0.0f; + pthis->segPhaseVelTarget = 2500.0f; + pthis->pulseSizeTarget = 0.0f; + pthis->wobbleSizeTarget = 0.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].heightTarget = 0.0f; + pthis->bodySegs[i].rotTarget.x = pthis->bodySegs[i].rotTarget.z = 0.0f; + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.z = 1.0f; + } + pthis->actionFunc = EnRr_Damage; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_DAMAGE); +} + +void EnRr_SetupApproach(EnRr* pthis) { + s32 i; + + pthis->segMoveRate = 0.0f; + pthis->pulseSizeTarget = 0.15f; + pthis->segPhaseVelTarget = 2500.0f; + pthis->wobbleSizeTarget = 2048.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].heightTarget = 0.0f; + pthis->bodySegs[i].rotTarget.x = pthis->bodySegs[i].rotTarget.z = 0.0f; + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.z = 1.0f; + } + pthis->actionFunc = EnRr_Approach; +} + +void EnRr_SetupDeath(EnRr* pthis) { + s32 i; + + pthis->isDead = true; + pthis->frameCount = 0; + pthis->shrinkRate = 0.0f; + pthis->segMoveRate = 0.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].heightTarget = 0.0f; + pthis->bodySegs[i].rotTarget.x = pthis->bodySegs[i].rotTarget.z = 0.0f; + } + pthis->actionFunc = EnRr_Death; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_DEAD); + pthis->actor.flags &= ~ACTOR_FLAG_0; +} + +void EnRr_SetupStunned(EnRr* pthis) { + s32 i; + + pthis->stopScroll = true; + pthis->segMovePhase = 0; + pthis->segPhaseVel = 0.0f; + pthis->segPhaseVelTarget = 2500.0f; + pthis->segPulsePhaseDiff = 0.0f; + pthis->segWobblePhaseDiffX = 0.0f; + pthis->segWobbleXTarget = 3.0f; + pthis->segWobblePhaseDiffZ = 0.0f; + pthis->segWobbleZTarget = 1.0f; + pthis->pulseSize = 0.0f; + pthis->pulseSizeTarget = 0.15f; + pthis->wobbleSize = 0.0f; + pthis->wobbleSizeTarget = 2048.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].scaleMod.y = 0.0f; + pthis->bodySegs[i].rotTarget.x = 0.0f; + pthis->bodySegs[i].rotTarget.y = 0.0f; + pthis->bodySegs[i].rotTarget.z = 0.0f; + pthis->bodySegs[i].scale.x = pthis->bodySegs[i].scale.y = pthis->bodySegs[i].scale.z = + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.y = pthis->bodySegs[i].scaleTarget.z = 1.0f; + } + pthis->actionFunc = EnRr_Stunned; +} + +void EnRr_CollisionCheck(EnRr* pthis, GlobalContext* globalCtx) { + Vec3f hitPos; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->collider2.base.acFlags & AC_HIT) { + pthis->collider2.base.acFlags &= ~AC_HIT; + // "Kakin" (not sure what pthis means) + osSyncPrintf(VT_FGCOL(GREEN) "カキン(%d)!!" VT_RST "\n", pthis->frameCount); + hitPos.x = pthis->collider2.info.bumper.hitPos.x; + hitPos.y = pthis->collider2.info.bumper.hitPos.y; + hitPos.z = pthis->collider2.info.bumper.hitPos.z; + CollisionCheck_SpawnShieldParticlesMetal2(globalCtx, &hitPos); + } else { + if (pthis->collider1.base.acFlags & AC_HIT) { + u8 dropType = RR_DROP_RANDOM_RUPEE; + + pthis->collider1.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != 0) { + hitPos.x = pthis->collider1.info.bumper.hitPos.x; + hitPos.y = pthis->collider1.info.bumper.hitPos.y; + hitPos.z = pthis->collider1.info.bumper.hitPos.z; + CollisionCheck_BlueBlood(globalCtx, NULL, &hitPos); + } + switch (pthis->actor.colChkInfo.damageEffect) { + case RR_DMG_LIGHT_ARROW: + dropType++; // purple rupee + case RR_DMG_SHDW_ARROW: + dropType++; // flexible + case RR_DMG_WIND_ARROW: + dropType++; // arrow + case RR_DMG_SPRT_ARROW: + dropType++; // magic jar + case RR_DMG_NORMAL: + // "ouch" + osSyncPrintf(VT_FGCOL(RED) "いてっ( %d : LIFE %d : DAMAGE %d : %x )!!" VT_RST "\n", + pthis->frameCount, pthis->actor.colChkInfo.health, pthis->actor.colChkInfo.damage, + pthis->actor.colChkInfo.damageEffect); + pthis->stopScroll = false; + Actor_ApplyDamage(&pthis->actor); + pthis->invincibilityTimer = 40; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, pthis->invincibilityTimer); + if (pthis->hasPlayer) { + EnRr_SetupReleasePlayer(pthis, globalCtx); + } else if (pthis->actor.colChkInfo.health != 0) { + EnRr_SetupDamage(pthis); + } else { + pthis->dropType = dropType; + EnRr_SetupDeath(pthis); + } + return; + case RR_DMG_FIRE: // Fire Arrow and Din's Fire + Actor_ApplyDamage(&pthis->actor); + if (pthis->actor.colChkInfo.health == 0) { + pthis->dropType = RR_DROP_RANDOM_RUPEE; + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + pthis->effectTimer = 20; + EnRr_SetupStunned(pthis); + return; + case RR_DMG_ICE: // Ice Arrow and unused ice magic + Actor_ApplyDamage(&pthis->actor); + if (pthis->actor.colChkInfo.health == 0) { + pthis->dropType = RR_DROP_RANDOM_RUPEE; + } + if (pthis->actor.colorFilterTimer == 0) { + pthis->effectTimer = 20; + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0x2000, 0x50); + } + EnRr_SetupStunned(pthis); + return; + case RR_DMG_LIGHT_MAGIC: // Unused light magic + Actor_ApplyDamage(&pthis->actor); + if (pthis->actor.colChkInfo.health == 0) { + pthis->dropType = RR_DROP_RUPEE_RED; + } + Actor_SetColorFilter(&pthis->actor, -0x8000, 0xFF, 0x2000, 0x50); + EnRr_SetupStunned(pthis); + return; + case RR_DMG_STUN: // Boomerang and Hookshot + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0x2000, 0x50); + EnRr_SetupStunned(pthis); + return; + } + } + if ((pthis->ocTimer == 0) && (pthis->actor.colorFilterTimer == 0) && (player->invincibilityTimer == 0) && + !(player->stateFlags2 & 0x80) && + ((pthis->collider1.base.ocFlags1 & OC1_HIT) || (pthis->collider2.base.ocFlags1 & OC1_HIT))) { + pthis->collider1.base.ocFlags1 &= ~OC1_HIT; + pthis->collider2.base.ocFlags1 &= ~OC1_HIT; + // "catch" + osSyncPrintf(VT_FGCOL(GREEN) "キャッチ(%d)!!" VT_RST "\n", pthis->frameCount); + if (globalCtx->grabPlayer(globalCtx, player)) { + player->actor.parent = &pthis->actor; + pthis->stopScroll = false; + EnRr_SetupGrabPlayer(pthis, player); + } + } + } +} + +void EnRr_InitBodySegments(EnRr* pthis, GlobalContext* globalCtx) { + s32 i; + + pthis->segMovePhase = 0; + pthis->segPhaseVel = 0.0f; + pthis->segPhaseVelTarget = 2500.0f; + pthis->segPulsePhaseDiff = 0.0f; + pthis->segWobblePhaseDiffX = 0.0f; + pthis->segWobbleXTarget = 3.0f; + pthis->segWobblePhaseDiffZ = 0.0f; + pthis->segWobbleZTarget = 1.0f; + pthis->pulseSize = 0.0f; + pthis->pulseSizeTarget = 0.15f; + pthis->wobbleSize = 0.0f; + pthis->wobbleSizeTarget = 2048.0f; + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].scaleMod.y = 0.0f; + pthis->bodySegs[i].rotTarget.x = 0.0f; + pthis->bodySegs[i].rotTarget.y = 0.0f; + pthis->bodySegs[i].rotTarget.z = 0.0f; + pthis->bodySegs[i].scale.x = pthis->bodySegs[i].scale.y = pthis->bodySegs[i].scale.z = + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.y = pthis->bodySegs[i].scaleTarget.z = 1.0f; + } + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].scaleMod.x = pthis->bodySegs[i].scaleMod.z = + Math_CosS(i * (u32)(s16)pthis->segPulsePhaseDiff * 0x1000) * pthis->pulseSize; + } + for (i = 1; i < 5; i++) { + pthis->bodySegs[i].rotTarget.x = Math_CosS(i * (u32)(s16)pthis->segWobblePhaseDiffX * 0x1000) * pthis->wobbleSize; + pthis->bodySegs[i].rotTarget.z = Math_SinS(i * (u32)(s16)pthis->segWobblePhaseDiffZ * 0x1000) * pthis->wobbleSize; + } +} + +void EnRr_UpdateBodySegments(EnRr* pthis, GlobalContext* globalCtx) { + s32 i; + s16 phase = pthis->segMovePhase; + + if (!pthis->isDead) { + for (i = 0; i < 5; i++) { + pthis->bodySegs[i].scaleMod.x = pthis->bodySegs[i].scaleMod.z = + Math_CosS(phase + i * (s16)pthis->segPulsePhaseDiff * 0x1000) * pthis->pulseSize; + } + phase = pthis->segMovePhase; + if (!pthis->isDead && (pthis->reachState == 0)) { + for (i = 1; i < 5; i++) { + pthis->bodySegs[i].rotTarget.x = + Math_CosS(phase + i * (s16)pthis->segWobblePhaseDiffX * 0x1000) * pthis->wobbleSize; + pthis->bodySegs[i].rotTarget.z = + Math_SinS(phase + i * (s16)pthis->segWobblePhaseDiffZ * 0x1000) * pthis->wobbleSize; + } + } + } + if (!pthis->stopScroll) { + pthis->segMovePhase += (s16)pthis->segPhaseVel; + } +} + +void EnRr_Approach(EnRr* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, 0x1F4, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if ((pthis->actionTimer == 0) && (pthis->actor.xzDistToPlayer < 160.0f)) { + EnRr_SetupReach(pthis); + } else if ((pthis->actor.xzDistToPlayer < 400.0f) && (pthis->actor.speedXZ == 0.0f)) { + EnRr_SetSpeed(pthis, 2.0f); + } +} + +void EnRr_Reach(EnRr* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, 0x1F4, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + switch (pthis->reachState) { + case REACH_EXTEND: + if (pthis->actionTimer == 0) { + pthis->reachState = REACH_STOP; + } + break; + case REACH_STOP: + if (pthis->actionTimer == 0) { + pthis->actionTimer = 5; + pthis->bodySegs[RR_MOUTH].scaleTarget.x = pthis->bodySegs[RR_MOUTH].scaleTarget.z = 1.5f; + pthis->reachState = REACH_OPEN; + } + break; + case REACH_OPEN: + if (pthis->actionTimer == 0) { + pthis->actionTimer = 2; + pthis->bodySegs[RR_MOUTH].heightTarget = 2000.0f; + pthis->reachState = REACH_GAPE; + } + break; + case REACH_GAPE: + if (pthis->actionTimer == 0) { + pthis->actionTimer = 20; + pthis->bodySegs[RR_MOUTH].scaleTarget.x = pthis->bodySegs[RR_MOUTH].scaleTarget.z = 0.8f; + pthis->reachState = REACH_CLOSE; + } + break; + case REACH_CLOSE: + if (pthis->actionTimer == 0) { + EnRr_SetupNeutral(pthis); + } + break; + } +} + +void EnRr_GrabPlayer(EnRr* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_800AA000(pthis->actor.xyzDistToPlayerSq, 120, 2, 120); + if ((pthis->frameCount % 8) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_LIKE_EAT); + } + pthis->ocTimer = 8; + if ((pthis->grabTimer == 0) || !(player->stateFlags2 & 0x80)) { + EnRr_SetupReleasePlayer(pthis, globalCtx); + } else { + Math_ApproachF(&player->actor.world.pos.x, pthis->mouthPos.x, 1.0f, 30.0f); + Math_ApproachF(&player->actor.world.pos.y, pthis->mouthPos.y + pthis->swallowOffset, 1.0f, 30.0f); + Math_ApproachF(&player->actor.world.pos.z, pthis->mouthPos.z, 1.0f, 30.0f); + Math_ApproachF(&pthis->swallowOffset, -55.0f, 1.0f, 5.0f); + } +} + +void EnRr_Damage(EnRr* pthis, GlobalContext* globalCtx) { + s32 i; + + if (pthis->actor.colorFilterTimer == 0) { + EnRr_SetupApproach(pthis); + } else if ((pthis->actor.colorFilterTimer & 8) != 0) { + for (i = 1; i < 5; i++) { + pthis->bodySegs[i].rotTarget.z = 5000.0f; + } + } else { + for (i = 1; i < 5; i++) { + pthis->bodySegs[i].rotTarget.z = -5000.0f; + } + } +} + +void EnRr_Death(EnRr* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 i; + + if (pthis->frameCount < 40) { + for (i = 0; i < 5; i++) { + Math_ApproachF(&pthis->bodySegs[i].heightTarget, i + 59 - (pthis->frameCount * 25.0f), 1.0f, 50.0f); + pthis->bodySegs[i].scaleTarget.x = pthis->bodySegs[i].scaleTarget.z = + (SQ(4 - i) * (f32)pthis->frameCount * 0.003f) + 1.0f; + } + } else if (pthis->frameCount >= 95) { + Vec3f dropPos; + + dropPos.x = pthis->actor.world.pos.x; + dropPos.y = pthis->actor.world.pos.y; + dropPos.z = pthis->actor.world.pos.z; + switch (pthis->eatenShield) { + case 1: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_SHIELD_DEKU); + break; + case 2: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_SHIELD_HYLIAN); + break; + } + switch (pthis->eatenTunic) { + case 2: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_TUNIC_GORON); + break; + case 3: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_TUNIC_ZORA); + break; + } + // "dropped" + osSyncPrintf(VT_FGCOL(GREEN) "「%s」が出た!!" VT_RST "\n", sDropNames[pthis->dropType]); + switch (pthis->dropType) { + case RR_DROP_MAGIC: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_MAGIC_SMALL); + break; + case RR_DROP_ARROW: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_ARROWS_SINGLE); + break; + case RR_DROP_FLEXIBLE: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_FLEXIBLE); + break; + case RR_DROP_RUPEE_PURPLE: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_RUPEE_PURPLE); + break; + case RR_DROP_RUPEE_RED: + Item_DropCollectible(globalCtx, &dropPos, ITEM00_RUPEE_RED); + break; + case RR_DROP_RANDOM_RUPEE: + default: + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &dropPos, 12 << 4); + break; + } + Actor_Kill(&pthis->actor); + } else if (pthis->frameCount == 88) { + Vec3f pos; + Vec3f vel; + Vec3f accel; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 20.0f; + pos.z = pthis->actor.world.pos.z; + vel.x = 0.0f; + vel.y = 0.0f; + vel.z = 0.0f; + accel.x = 0.0f; + accel.y = 0.0f; + accel.z = 0.0f; + + EffectSsDeadDb_Spawn(globalCtx, &pos, &vel, &accel, 100, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, true); + } else { + Math_ApproachF(&pthis->actor.scale.x, 0.0f, 1.0f, pthis->shrinkRate); + Math_ApproachF(&pthis->shrinkRate, 0.001f, 1.0f, 0.00001f); + pthis->actor.scale.z = pthis->actor.scale.x; + } +} + +void EnRr_Retreat(EnRr* pthis, GlobalContext* globalCtx) { + if (pthis->actionTimer == 0) { + pthis->retreat = false; + pthis->actionFunc = EnRr_Approach; + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 0xA, 0x3E8, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->actor.speedXZ == 0.0f) { + EnRr_SetSpeed(pthis, 2.0f); + } + } +} + +void EnRr_Stunned(EnRr* pthis, GlobalContext* globalCtx) { + if (pthis->actor.colorFilterTimer == 0) { + pthis->stopScroll = false; + if (pthis->hasPlayer) { + EnRr_SetupReleasePlayer(pthis, globalCtx); + } else if (pthis->actor.colChkInfo.health != 0) { + pthis->actionFunc = EnRr_Approach; + } else { + EnRr_SetupDeath(pthis); + } + } +} + +void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRr* pthis = (EnRr*)thisx; + s32 i; + + pthis->frameCount++; + if (!pthis->stopScroll) { + pthis->scrollTimer++; + } + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } + if (pthis->grabTimer != 0) { + pthis->grabTimer--; + } + if (pthis->ocTimer != 0) { + pthis->ocTimer--; + } + if (pthis->invincibilityTimer != 0) { + pthis->invincibilityTimer--; + } + if (pthis->effectTimer != 0) { + pthis->effectTimer--; + } + + Actor_SetFocus(&pthis->actor, 30.0f); + EnRr_UpdateBodySegments(pthis, globalCtx); + if (!pthis->isDead && ((pthis->actor.colorFilterTimer == 0) || !(pthis->actor.colorFilterParams & 0x4000))) { + EnRr_CollisionCheck(pthis, globalCtx); + } + + pthis->actionFunc(pthis, globalCtx); + if (pthis->hasPlayer == 0x3F80) { // checks if 1.0f has been stored to hasPlayer's address + ASSERT(0, "0", "../z_en_rr.c", 1355); + } + + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.1f); + Actor_MoveForward(&pthis->actor); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider1); + pthis->collider2.dim.pos.x = pthis->mouthPos.x; + pthis->collider2.dim.pos.y = pthis->mouthPos.y; + pthis->collider2.dim.pos.z = pthis->mouthPos.z; + if (!pthis->isDead && (pthis->invincibilityTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + if (pthis->ocTimer == 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider1.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + } else { + pthis->collider2.base.ocFlags1 &= ~OC1_HIT; + pthis->collider2.base.acFlags &= ~AC_HIT; + pthis->collider1.base.ocFlags1 &= ~OC1_HIT; + pthis->collider1.base.acFlags &= ~AC_HIT; + } + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 30.0f, 20.0f, 7); + if (!pthis->stopScroll) { + Math_ApproachF(&pthis->segPhaseVel, pthis->segPhaseVelTarget, 1.0f, 50.0f); + Math_ApproachF(&pthis->segPulsePhaseDiff, 4.0f, 1.0f, 5.0f); + Math_ApproachF(&pthis->segWobblePhaseDiffX, pthis->segWobbleXTarget, 1.0f, 0.04f); + Math_ApproachF(&pthis->segWobblePhaseDiffZ, pthis->segWobbleZTarget, 1.0f, 0.01f); + Math_ApproachF(&pthis->pulseSize, pthis->pulseSizeTarget, 1.0f, 0.0015f); + Math_ApproachF(&pthis->wobbleSize, pthis->wobbleSizeTarget, 1.0f, 20.0f); + for (i = 0; i < 5; i++) { + Math_SmoothStepToS(&pthis->bodySegs[i].rot.x, pthis->bodySegs[i].rotTarget.x, 5, pthis->segMoveRate * 1000.0f, + 0); + Math_SmoothStepToS(&pthis->bodySegs[i].rot.z, pthis->bodySegs[i].rotTarget.z, 5, pthis->segMoveRate * 1000.0f, + 0); + Math_ApproachF(&pthis->bodySegs[i].scale.x, pthis->bodySegs[i].scaleTarget.x, 1.0f, pthis->segMoveRate * 0.2f); + pthis->bodySegs[i].scale.z = pthis->bodySegs[i].scale.x; + Math_ApproachF(&pthis->bodySegs[i].height, pthis->bodySegs[i].heightTarget, 1.0f, pthis->segMoveRate * 300.0f); + } + Math_ApproachF(&pthis->segMoveRate, 1.0f, 1.0f, 0.2f); + } +} + +static Vec3f sEffectOffsets[] = { + { 25.0f, 0.0f, 0.0f }, + { -25.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 25.0f }, + { 0.0f, 0.0f, -25.0f }, +}; + +void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + Vec3f zeroVec; + EnRr* pthis = (EnRr*)thisx; + s32 i; + Mtx* segMtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Mtx)); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rr.c", 1478); + + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x0C, segMtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (pthis->scrollTimer * 0) & 0x7F, + (pthis->scrollTimer * 0) & 0x3F, 32, 16, 1, (pthis->scrollTimer * 0) & 0x3F, + (pthis->scrollTimer * -6) & 0x7F, 32, 16)); + Matrix_Push(); + + Matrix_Scale((1.0f + pthis->bodySegs[RR_BASE].scaleMod.x) * pthis->bodySegs[RR_BASE].scale.x, + (1.0f + pthis->bodySegs[RR_BASE].scaleMod.y) * pthis->bodySegs[RR_BASE].scale.y, + (1.0f + pthis->bodySegs[RR_BASE].scaleMod.z) * pthis->bodySegs[RR_BASE].scale.z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_rr.c", 1501), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Pop(); + zeroVec.x = 0.0f; + zeroVec.y = 0.0f; + zeroVec.z = 0.0f; + for (i = 1; i < 5; i++) { + Matrix_Translate(0.0f, pthis->bodySegs[i].height + 1000.0f, 0.0f, MTXMODE_APPLY); + + Matrix_RotateZYX(pthis->bodySegs[i].rot.x, pthis->bodySegs[i].rot.y, pthis->bodySegs[i].rot.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Scale((1.0f + pthis->bodySegs[i].scaleMod.x) * pthis->bodySegs[i].scale.x, + (1.0f + pthis->bodySegs[i].scaleMod.y) * pthis->bodySegs[i].scale.y, + (1.0f + pthis->bodySegs[i].scaleMod.z) * pthis->bodySegs[i].scale.z, MTXMODE_APPLY); + Matrix_ToMtx(segMtx, "../z_en_rr.c", 1527); + Matrix_Pop(); + segMtx++; + Matrix_MultVec3f(&zeroVec, &pthis->effectPos[i]); + } + pthis->effectPos[0] = pthis->actor.world.pos; + Matrix_MultVec3f(&zeroVec, &pthis->mouthPos); + gSPDisplayList(POLY_XLU_DISP++, gLikeLikeDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_rr.c", 1551); + if (pthis->effectTimer != 0) { + Vec3f effectPos; + s16 effectTimer = pthis->effectTimer - 1; + + pthis->actor.colorFilterTimer++; + if ((effectTimer & 1) == 0) { + s32 segIndex = 4 - (effectTimer >> 2); + s32 offIndex = (effectTimer >> 1) & 3; + + effectPos.x = pthis->effectPos[segIndex].x + sEffectOffsets[offIndex].x + Rand_CenteredFloat(10.0f); + effectPos.y = pthis->effectPos[segIndex].y + sEffectOffsets[offIndex].y + Rand_CenteredFloat(10.0f); + effectPos.z = pthis->effectPos[segIndex].z + sEffectOffsets[offIndex].z + Rand_CenteredFloat(10.0f); + if (pthis->actor.colorFilterParams & 0x4000) { + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &effectPos, 100, 0, 0, -1); + } else { + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &effectPos, 150, 150, 150, 250, 235, 245, 255, + 3.0f); + } + } + } +} diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c deleted file mode 100644 index 5ae553aaa..000000000 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ /dev/null @@ -1,2385 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RU1_Z_EN_RU1_C -#include "actor_common.h" -/* - * File: z_en_ru1.c - * Overlay: En_Ru1 - * Description: Ruto (child) - */ - -#include "z_en_ru1.h" -#include "objects/object_ru1/object_ru1.h" -#include "vt.h" -#include "def/code_8006BA00.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_26) - -void EnRu1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRu1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRu1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRu1_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AEC0B4(EnRu1* this, GlobalContext* globalCtx); -void func_80AEC100(EnRu1* this, GlobalContext* globalCtx); -void func_80AEC130(EnRu1* this, GlobalContext* globalCtx); -void func_80AEC17C(EnRu1* this, GlobalContext* globalCtx); -void func_80AEC1D4(EnRu1* this, GlobalContext* globalCtx); -void func_80AEC244(EnRu1* this, GlobalContext* globalCtx); -void func_80AEC2C0(EnRu1* this, GlobalContext* globalCtx); -void func_80AECA94(EnRu1* this, GlobalContext* globalCtx); -void func_80AECAB4(EnRu1* this, GlobalContext* globalCtx); -void func_80AECAD4(EnRu1* this, GlobalContext* globalCtx); -void func_80AECB18(EnRu1* this, GlobalContext* globalCtx); -void func_80AECB60(EnRu1* this, GlobalContext* globalCtx); -void func_80AECBB8(EnRu1* this, GlobalContext* globalCtx); -void func_80AECC1C(EnRu1* this, GlobalContext* globalCtx); -void func_80AECC84(EnRu1* this, GlobalContext* globalCtx); -void func_80AED304(EnRu1* this, GlobalContext* globalCtx); -void func_80AED324(EnRu1* this, GlobalContext* globalCtx); -void func_80AED344(EnRu1* this, GlobalContext* globalCtx); -void func_80AED374(EnRu1* this, GlobalContext* globalCtx); -void func_80AED3A4(EnRu1* this, GlobalContext* globalCtx); -void func_80AED3E0(EnRu1* this, GlobalContext* globalCtx); -void func_80AED414(EnRu1* this, GlobalContext* globalCtx); -void func_80AEF29C(EnRu1* this, GlobalContext* globalCtx); -void func_80AEF2AC(EnRu1* this, GlobalContext* globalCtx); -void func_80AEF2D0(EnRu1* this, GlobalContext* globalCtx); -void func_80AEF354(EnRu1* this, GlobalContext* globalCtx); -void func_80AEF3A8(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEBD4(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEC5C(EnRu1* this, GlobalContext* globalCtx); -void func_80AEECF0(EnRu1* this, GlobalContext* globalCtx); -void func_80AEED58(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEDCC(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEE34(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEE9C(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEF08(EnRu1* this, GlobalContext* globalCtx); -void func_80AEEF5C(EnRu1* this, GlobalContext* globalCtx); -void func_80AEF9D8(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFA2C(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFAAC(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFB04(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFB68(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFCE8(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFBC8(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFC24(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFECC(EnRu1* this, GlobalContext* globalCtx); -void func_80AEFF40(EnRu1* this, GlobalContext* globalCtx); - -void func_80AF0278(EnRu1* this, GlobalContext* globalCtx, s32 limbIndex, Vec3s* rot); - -void EnRu1_DrawNothing(EnRu1* this, GlobalContext* globalCtx); -void EnRu1_DrawOpa(EnRu1* this, GlobalContext* globalCtx); -void EnRu1_DrawXlu(EnRu1* this, GlobalContext* globalCtx); - -static ColliderCylinderInitType1 sCylinderInit1 = { - { - COLTYPE_HIT0, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 }, - { 25, 80, 0, { 0 } }, -}; - -static ColliderCylinderInitType1 sCylinderInit2 = { - { - COLTYPE_HIT0, - AT_ON | AT_TYPE_PLAYER, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { 0x00, { 0x00000101, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x01, 0x00, 0x01 }, - { 20, 30, 0, { 0 } }, -}; - -static void* sEyeTextures[] = { - gRutoChildEyeOpenTex, gRutoChildEyeHalfTex, gRutoChildEyeClosedTex, - gRutoChildEyeRollLeftTex, gRutoChildEyeHalf2Tex, gRutoChildEyeHalfWithBlushTex, -}; - -static void* sMouthTextures[] = { - gRutoChildMouthClosedTex, - gRutoChildMouthFrownTex, - gRutoChildMouthOpenTex, -}; - -static s32 sUnused = 0; - -#include "z_en_ru1_cutscene_data.c" EARLY - -static u32 D_80AF1938 = 0; - -static EnRu1ActionFunc sActionFuncs[] = { - func_80AEC0B4, func_80AEC100, func_80AEC130, func_80AEC17C, func_80AEC1D4, func_80AEC244, func_80AEC2C0, - func_80AECA94, func_80AECAB4, func_80AECAD4, func_80AECB18, func_80AECB60, func_80AECBB8, func_80AECC1C, - func_80AECC84, func_80AED304, func_80AED324, func_80AED344, func_80AED374, func_80AED3A4, func_80AED3E0, - func_80AED414, func_80AEF29C, func_80AEF2AC, func_80AEF2D0, func_80AEF354, func_80AEF3A8, func_80AEEBD4, - func_80AEEC5C, func_80AEECF0, func_80AEED58, func_80AEEDCC, func_80AEEE34, func_80AEEE9C, func_80AEEF08, - func_80AEEF5C, func_80AEF9D8, func_80AEFA2C, func_80AEFAAC, func_80AEFB04, func_80AEFB68, func_80AEFCE8, - func_80AEFBC8, func_80AEFC24, func_80AEFECC, func_80AEFF40, -}; - -static EnRu1PreLimbDrawFunc sPreLimbDrawFuncs[] = { - func_80AF0278, -}; - -static Vec3f sMultVec = { 0.0f, 10.0f, 0.0f }; - -static EnRu1DrawFunc sDrawFuncs[] = { - EnRu1_DrawNothing, - EnRu1_DrawOpa, - EnRu1_DrawXlu, -}; - -const ActorInit En_Ru1_InitVars = { - ACTOR_EN_RU1, - ACTORCAT_NPC, - FLAGS, - OBJECT_RU1, - sizeof(EnRu1), - (ActorFunc)EnRu1_Init, - (ActorFunc)EnRu1_Destroy, - (ActorFunc)EnRu1_Update, - (ActorFunc)EnRu1_Draw, -}; - -void func_80AEAC10(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[5]; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void func_80AEAC54(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[5]; - - Collider_UpdateCylinder(&this->actor, &this->collider2); - if (this->unk_34C != 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - } else if (this->actor.xzDistToPlayer > 32.0f) { - this->unk_34C = 1; - } -} - -void func_80AEACDC(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[5]; - - Collider_UpdateCylinder(&this->actor, &this->collider2); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); -} - -void func_80AEAD20(Actor* thisx, GlobalContext* globalCtx) { - EnRu1* this = (EnRu1*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit1); - - Collider_InitCylinder(globalCtx, &this->collider2); - Collider_SetCylinderType1(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); -} - -void EnRu1_DestroyColliders(EnRu1* this, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &this->collider); - Collider_DestroyCylinder(globalCtx, &this->collider2); -} - -void func_80AEADD8(EnRu1* this) { - this->unk_34C = 0; -} - -u8 func_80AEADE0(EnRu1* this) { - u8 params = this->actor.params >> 8; - - return params; -} - -u8 func_80AEADF0(EnRu1* this) { - s16 params = this->actor.params; - - return params; -} - -void EnRu1_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnRu1* this = (EnRu1*)thisx; - - EnRu1_DestroyColliders(this, globalCtx); -} - -void EnRu1_UpdateEyes(EnRu1* this) { - s32 pad[3]; - s16* blinkTimer = &this->blinkTimer; - s16* eyeIndex = &this->eyeIndex; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - - *eyeIndex = *blinkTimer; - if (*eyeIndex >= 3) { - *eyeIndex = 0; - } -} - -void EnRu1_SetEyeIndex(EnRu1* this, s16 eyeIndex) { - this->eyeIndex = eyeIndex; -} - -void EnRu1_SetMouthIndex(EnRu1* this, s16 mouthIndex) { - this->mouthIndex = mouthIndex; -} - -void func_80AEAECC(EnRu1* this, GlobalContext* globalCtx) { - f32* velocityY = &this->actor.velocity.y; - f32 velocityYHeld = *velocityY; - - *velocityY = -4.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 19.0f, 25.0f, 30.0f, 7); - *velocityY = velocityYHeld; -} - -s32 EnRu1_IsCsStateIdle(GlobalContext* globalCtx) { - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - return true; - } - return false; -} - -CsCmdActorAction* func_80AEAF58(GlobalContext* globalCtx, s32 npcActionIdx) { - s32 pad[2]; - CsCmdActorAction* ret = NULL; - - if (!EnRu1_IsCsStateIdle(globalCtx)) { - ret = globalCtx->csCtx.npcActions[npcActionIdx]; - } - return ret; -} - -s32 func_80AEAFA0(GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = func_80AEAF58(globalCtx, npcActionIdx); - - if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == action)) { - return true; - } - return false; -} - -s32 func_80AEAFE0(GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = func_80AEAF58(globalCtx, npcActionIdx); - - if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action != action)) { - return true; - } - return false; -} - -s32 func_80AEB020(EnRu1* this, GlobalContext* globalCtx) { - Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; - EnRu1* someEnRu1; - - while (actorIt != NULL) { - if (actorIt->id == ACTOR_EN_RU1) { - someEnRu1 = (EnRu1*)actorIt; - if (someEnRu1 != this) { - if ((someEnRu1->action == 31) || (someEnRu1->action == 32) || (someEnRu1->action == 24)) { - return true; - } - } - } - actorIt = actorIt->next; - } - return false; -} - -BgBdanObjects* EnRu1_FindSwitch(GlobalContext* globalCtx) { - Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_BG].head; - - while (actorIt != NULL) { - if (actorIt->id == ACTOR_BG_BDAN_OBJECTS && actorIt->params == 0) { - return (BgBdanObjects*)actorIt; - } - actorIt = actorIt->next; - } - // "There is no stand" - osSyncPrintf(VT_FGCOL(RED) "お立ち台が無い!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return NULL; -} - -void func_80AEB0EC(EnRu1* this, s32 cameraSetting) { - if (this->unk_28C != NULL) { - this->unk_28C->cameraSetting = cameraSetting; - } -} - -s32 func_80AEB104(EnRu1* this) { - if (this->unk_28C != NULL) { - return this->unk_28C->cameraSetting; - } else { - return 0; - } -} - -Actor* func_80AEB124(GlobalContext* globalCtx) { - Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].head; - - while (actorIt != NULL) { - if ((actorIt->id == ACTOR_DEMO_EFFECT) && ((actorIt->params & 0xFF) == 0x15)) { - return actorIt; - } - actorIt = actorIt->next; - } - return NULL; -} - -s32 func_80AEB174(GlobalContext* globalCtx) { - return (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx); -} - -s32 func_80AEB1B4(GlobalContext* globalCtx) { - return Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING; -} - -void func_80AEB1D8(EnRu1* this) { - this->action = 36; - this->drawConfig = 0; - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - func_80AEB0EC(this, 0); -} - -void func_80AEB220(EnRu1* this, GlobalContext* globalCtx) { - if ((EnRu1_IsCsStateIdle(globalCtx)) && (this->actor.params == 0xA)) { - func_80AEB1D8(this); - } -} - -void func_80AEB264(EnRu1* this, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { - s32 pad[2]; - AnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); - f32 frameCount = Animation_GetLastFrame(animHeader); - f32 playbackSpeed; - f32 unk0; - f32 fc; - - if (arg4 == 0) { - unk0 = 0.0f; - fc = frameCount; - playbackSpeed = 1.0f; - } else { - unk0 = frameCount; - fc = 0.0f; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animHeader, playbackSpeed, unk0, fc, arg2, transitionRate); -} - -s32 EnRu1_UpdateSkelAnime(EnRu1* this) { - // why? - if (this->action != 32) { - return SkelAnime_Update(&this->skelAnime); - } else { - return SkelAnime_Update(&this->skelAnime); - } -} - -void func_80AEB364(EnRu1* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 1; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_80AEB3A4(EnRu1* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 1; - func_80AEB364(this, globalCtx); -} - -void func_80AEB3CC(EnRu1* this) { - this->skelAnime.moveFlags &= ~0x1; -} - -void func_80AEB3DC(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB264(this, &gRutoChildWaitHandsBehindBackAnim, 0, 0, 0); - this->action = 0; - this->drawConfig = 1; - EnRu1_SetEyeIndex(this, 4); - EnRu1_SetMouthIndex(this, 0); -} - -CsCmdActorAction* func_80AEB438(GlobalContext* globalCtx) { - return func_80AEAF58(globalCtx, 3); -} - -s32 func_80AEB458(GlobalContext* globalCtx, u16 action) { - return func_80AEAFA0(globalCtx, action, 3); -} - -s32 func_80AEB480(GlobalContext* globalCtx, u16 action) { - return func_80AEAFE0(globalCtx, action, 3); -} - -void EnRu1_SpawnRipple(EnRu1* this, GlobalContext* globalCtx, s16 radiusMax, s16 life) { - Vec3f pos; - Actor* thisx = &this->actor; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + this->actor.yDistToWater; - pos.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &pos, 100, radiusMax, life); -} - -void func_80AEB50C(EnRu1* this, GlobalContext* globalCtx) { - this->unk_270 += 1.0f; - if (this->unk_270 >= kREG(3) + 10.0f) { - EnRu1_SpawnRipple(this, globalCtx, kREG(1) + 500, 0); - this->unk_270 = 0.0f; - } -} - -void func_80AEB59C(EnRu1* this, GlobalContext* globalCtx) { - EnRu1_SpawnRipple(this, globalCtx, kREG(2) + 500, 0); - EnRu1_SpawnRipple(this, globalCtx, kREG(2) + 500, kREG(3) + 10.0f); - EnRu1_SpawnRipple(this, globalCtx, kREG(2) + 500, (kREG(3) + 10.0f) * 2.0f); -} - -void EnRu1_SpawnSplash(EnRu1* this, GlobalContext* globalCtx) { - Vec3f pos; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + this->actor.yDistToWater; - pos.z = this->actor.world.pos.z; - - EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 1, 0); -} - -void func_80AEB6E0(EnRu1* this, GlobalContext* globalCtx) { - SkelAnime* skelAnime = &this->skelAnime; - - if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, skelAnime, 1.0f); - } -} - -void func_80AEB738(EnRu1* this, GlobalContext* globalCtx) { - SkelAnime* skelAnime = &this->skelAnime; - - skelAnime->baseTransl = skelAnime->jointTable[0]; - skelAnime->prevTransl = skelAnime->jointTable[0]; - if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, skelAnime, 1.0f); - } -} - -void func_80AEB7D0(EnRu1* this) { - this->skelAnime.moveFlags &= ~0x3; -} - -f32 func_80AEB7E0(CsCmdActorAction* csCmdNPCAction, GlobalContext* globalCtx) { - s32 csCtxFrames = globalCtx->csCtx.frames; - - if ((csCtxFrames < csCmdNPCAction->endFrame) && (csCmdNPCAction->endFrame - csCmdNPCAction->startFrame > 0)) { - return (Math_CosS(((csCtxFrames - csCmdNPCAction->startFrame) / - (f32)(csCmdNPCAction->endFrame - csCmdNPCAction->startFrame)) * - 32768.0f) * - -0.5f) + - 0.5f; - } - return 1.0f; -} - -f32 func_80AEB87C(f32 arg0, s32 arg1, s32 arg2) { - return (((f32)arg2 - arg1) * arg0) + arg1; -} - -void func_80AEB89C(EnRu1* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = func_80AEB438(globalCtx); - s16 npcActionRotY; - - if (npcAction != NULL) { - npcActionRotY = npcAction->rot.y; - this->actor.shape.rot.y = npcActionRotY; - this->actor.world.rot.y = npcActionRotY; - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - } -} - -void func_80AEB914(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB89C(this, globalCtx); -} - -void func_80AEB934(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB89C(this, globalCtx); -} - -void func_80AEB954(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB6E0(this, globalCtx); -} - -void func_80AEB974(EnRu1* this, GlobalContext* globalCtx) { - Vec3f* thisPos; - f32 sp30; - CsCmdActorAction* csCmdNPCAction = func_80AEB438(globalCtx); - s32 pad; - - if (csCmdNPCAction != NULL) { - sp30 = func_80AEB7E0(csCmdNPCAction, globalCtx); - thisPos = &this->actor.world.pos; - thisPos->x = func_80AEB87C(sp30, csCmdNPCAction->startPos.x, csCmdNPCAction->endPos.x); - thisPos->y = func_80AEB87C(sp30, csCmdNPCAction->startPos.y, csCmdNPCAction->endPos.y); - thisPos->z = func_80AEB87C(sp30, csCmdNPCAction->startPos.z, csCmdNPCAction->endPos.z); - } -} - -void func_80AEBA0C(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB6E0(this, globalCtx); -} - -void func_80AEBA2C(EnRu1* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f* unk_364 = &this->unk_364; - Vec3f* thisPos; - f32 temp_ret_2; - CsCmdActorAction* csCmdNPCAction = func_80AEB438(globalCtx); - s32 pad2; - - if (csCmdNPCAction != NULL) { - temp_ret_2 = func_80AEB7E0(csCmdNPCAction, globalCtx); - thisPos = &this->actor.world.pos; - thisPos->x = func_80AEB87C(temp_ret_2, unk_364->x, csCmdNPCAction->endPos.x); - thisPos->y = func_80AEB87C(temp_ret_2, unk_364->y, csCmdNPCAction->endPos.y); - thisPos->z = func_80AEB87C(temp_ret_2, unk_364->z, csCmdNPCAction->endPos.z); - } -} - -void func_80AEBAFC(EnRu1* this) { - if (this->unk_298 == 0) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_DIVE_INTO_WATER); - this->unk_298 = 1; - } -} - -void func_80AEBB3C(EnRu1* this) { - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_FACE_UP); - } -} - -void func_80AEBB78(EnRu1* this) { - SkelAnime* skelAnime = &this->skelAnime; - - if (Animation_OnFrame(skelAnime, 4.0f) || Animation_OnFrame(skelAnime, 13.0f) || - Animation_OnFrame(skelAnime, 22.0f) || Animation_OnFrame(skelAnime, 31.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_SWIM); - } -} - -void func_80AEBBF4(EnRu1* this) { - if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_SUBMERGE); - } -} - -void func_80AEBC30(GlobalContext* globalCtx) { - Player* player; - - if (globalCtx->csCtx.frames == 0xCD) { - player = GET_PLAYER(globalCtx); - Audio_PlaySoundGeneral(NA_SE_EV_DIVE_INTO_WATER, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void func_80AEBC84(EnRu1* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 0x82) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_LAUGH_0); - } -} - -void func_80AEBCB8(EnRu1* this, UNK_TYPE arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gRutoChildSwimOnBackAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildSwimOnBackAnim), ANIMMODE_LOOP, -8.0f); - } -} - -void func_80AEBD1C(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEB480(globalCtx, 2)) { - this->action = 1; - this->drawConfig = 0; - func_80AEB914(this, globalCtx); - func_80AEAECC(this, globalCtx); - EnRu1_SpawnSplash(this, globalCtx); - func_80AEB59C(this, globalCtx); - } -} - -void func_80AEBD94(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - f32 frameCount; - - if (func_80AEB480(globalCtx, 3)) { - frameCount = Animation_GetLastFrame(&gRutoChildAnim_009060); - func_80AEB934(this, globalCtx); - func_80AEB738(this, globalCtx); - Animation_Change(&this->skelAnime, &gRutoChildAnim_009060, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); - this->action = 2; - this->drawConfig = 1; - } -} - -void func_80AEBE3C(EnRu1* this, GlobalContext* globalCtx, s32 arg2) { - s32 pad[2]; - f32 frameCount; - - if (arg2 != 0) { - frameCount = Animation_GetLastFrame(&gRutoChildTreadWaterAnim); - func_80AEB7D0(this); - Animation_Change(&this->skelAnime, &gRutoChildTreadWaterAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); - this->action = 3; - } else { - func_80AEB954(this, globalCtx); - } -} - -void func_80AEBEC8(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - f32 frameCount; - - if (func_80AEB458(globalCtx, 6)) { - frameCount = Animation_GetLastFrame(&gRutoChildTransitionToSwimOnBackAnim); - func_80AEB738(this, globalCtx); - Animation_Change(&this->skelAnime, &gRutoChildTransitionToSwimOnBackAnim, 1.0f, 0, frameCount, ANIMMODE_ONCE, - -8.0f); - this->action = 4; - } -} - -void func_80AEBF60(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEB480(globalCtx, 6)) { - func_80AEB7D0(this); - this->action = 5; - this->unk_364 = this->actor.world.pos; - } else { - func_80AEBA0C(this, globalCtx); - } -} - -void func_80AEBFD8(EnRu1* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction = func_80AEB438(globalCtx); - f32 frameCount; - u16 csCtxFrames; - u16 endFrame; - - if (csCmdNPCAction != NULL) { - csCtxFrames = globalCtx->csCtx.frames; - endFrame = csCmdNPCAction->endFrame; - if (csCtxFrames >= endFrame - 2) { - frameCount = Animation_GetLastFrame(&gRutoChildTransitionFromSwimOnBackAnim); - Animation_Change(&this->skelAnime, &gRutoChildTransitionFromSwimOnBackAnim, 1.0, 0, frameCount, - ANIMMODE_ONCE, -8.0f); - this->action = 6; - } - } -} - -void func_80AEC070(EnRu1* this, GlobalContext* globalCtx, UNK_TYPE arg2) { - if ((func_80AEB458(globalCtx, 8)) && (arg2 != 0)) { - Actor_Kill(&this->actor); - } -} - -void func_80AEC0B4(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB89C(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - func_80AEBC84(this, globalCtx); - func_80AEBC30(globalCtx); - func_80AEBD1C(this, globalCtx); -} - -void func_80AEC100(EnRu1* this, GlobalContext* globalCtx) { - func_80AEBAFC(this); - func_80AEBD94(this, globalCtx); -} - -void func_80AEC130(EnRu1* this, GlobalContext* globalCtx) { - s32 something = EnRu1_UpdateSkelAnime(this); - - func_80AEAECC(this, globalCtx); - func_80AEBB3C(this); - func_80AEBE3C(this, globalCtx, something); -} - -void func_80AEC17C(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB974(this, globalCtx); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - func_80AEB50C(this, globalCtx); - func_80AEBEC8(this, globalCtx); -} - -void func_80AEC1D4(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - something = EnRu1_UpdateSkelAnime(this); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateEyes(this); - func_80AEB50C(this, globalCtx); - func_80AEBCB8(this, something); - func_80AEBBF4(this); - func_80AEBF60(this, globalCtx); -} - -void func_80AEC244(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - something = EnRu1_UpdateSkelAnime(this); - func_80AEBA2C(this, globalCtx); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateEyes(this); - func_80AEB50C(this, globalCtx); - func_80AEBCB8(this, something); - func_80AEBB78(this); - func_80AEBFD8(this, globalCtx); -} - -void func_80AEC2C0(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - something = EnRu1_UpdateSkelAnime(this); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateEyes(this); - func_80AEB50C(this, globalCtx); - func_80AEC070(this, globalCtx, something); -} - -void func_80AEC320(EnRu1* this, GlobalContext* globalCtx) { - s8 actorRoom; - - if (!(gSaveContext.infTable[20] & 2)) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - this->action = 7; - EnRu1_SetMouthIndex(this, 1); - } else if ((gSaveContext.infTable[20] & 0x80) && !(gSaveContext.infTable[20] & 1) && - !(gSaveContext.infTable[20] & 0x20)) { - if (!func_80AEB020(this, globalCtx)) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - actorRoom = this->actor.room; - this->action = 22; - this->actor.room = -1; - this->drawConfig = 0; - this->roomNum1 = actorRoom; - this->roomNum3 = actorRoom; - this->roomNum2 = actorRoom; - } else { - Actor_Kill(&this->actor); - } - } else { - Actor_Kill(&this->actor); - } -} - -void func_80AEC40C(EnRu1* this) { - f32 unk_26C = this->unk_26C; - - if (unk_26C < 8.0f) { - this->actor.speedXZ = (((kREG(3) * 0.01f) + 2.7f) / 8.0f) * unk_26C; - } else { - this->actor.speedXZ = (kREG(3) * 0.01f) + 2.7f; - } - this->actor.velocity.y = -1.0f; - Actor_MoveForward(&this->actor); -} - -void func_80AEC4CC(EnRu1* this) { - this->actor.velocity.y = -1.0f; - Actor_MoveForward(&this->actor); -} - -void func_80AEC4F4(EnRu1* this) { - f32* speedXZ = &this->actor.speedXZ; - f32* unk_26C = &this->unk_26C; - - if (this->unk_26C < 8.0f) { - *unk_26C += 1.0f; - *speedXZ *= (8.0f - *unk_26C) / 8.0f; - this->actor.velocity.y = -*unk_26C * (((kREG(4) * 0.01f) + 13.0f) / 8.0f); - } else { - *speedXZ = 0.0f; - this->actor.velocity.y = -((kREG(4) * 0.01f) + 13.0f); - } - Actor_MoveForward(&this->actor); -} - -s32 func_80AEC5FC(EnRu1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 thisPosZ = this->actor.world.pos.z; - f32 playerPosZ = player->actor.world.pos.z; - - if ((playerPosZ - thisPosZ <= 265.0f) && (player->actor.world.pos.y >= this->actor.world.pos.y)) { - return true; - } - return false; -} - -void func_80AEC650(EnRu1* this) { - s32 pad[2]; - - if (this->unk_280 == 0) { - if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_DIRT); - } - } -} - -void func_80AEC6B0(EnRu1* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_FALL_DOWN_DIRT); - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_FALL); -} - -void func_80AEC6E4(EnRu1* this, GlobalContext* globalCtx) { - if ((func_80AEAFA0(globalCtx, 4, 3)) && (this->unk_280 == 0)) { - Animation_Change(&this->skelAnime, &gRutoChildBringArmsUpAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildBringArmsUpAnim), ANIMMODE_ONCE, -8.0f); - this->unk_280 = 1; - func_80AEC6B0(this); - } -} - -void func_80AEC780(EnRu1* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - if ((func_80AEC5FC(this, globalCtx)) && (!Gameplay_InCsMode(globalCtx)) && (!(player->stateFlags1 & 0x206000)) && - (player->actor.bgCheckFlags & 1)) { - - globalCtx->csCtx.segment = &D_80AF0880; - gSaveContext.cutsceneTrigger = 1; - player->linearVelocity = 0.0f; - this->action = 8; - } -} - -void func_80AEC81C(EnRu1* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction; - s16 newRotY; - - if (func_80AEAFE0(globalCtx, 1, 3)) { - csCmdNPCAction = globalCtx->csCtx.npcActions[3]; - this->actor.world.pos.x = csCmdNPCAction->startPos.x; - this->actor.world.pos.y = csCmdNPCAction->startPos.y; - this->actor.world.pos.z = csCmdNPCAction->startPos.z; - newRotY = csCmdNPCAction->rot.y; - this->actor.shape.rot.y = newRotY; - this->actor.world.rot.y = newRotY; - this->action = 9; - this->drawConfig = 1; - } -} - -void func_80AEC8B8(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEAFA0(globalCtx, 3, 3)) { - Animation_Change(&this->skelAnime, &gRutoChildTurnAroundAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildTurnAroundAnim), ANIMMODE_ONCE, -8.0f); - this->action = 10; - } -} - -void func_80AEC93C(EnRu1* this, UNK_TYPE arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gRutoChildWalkAnim, 1.0f, 0, Animation_GetLastFrame(&gRutoChildWalkAnim), - ANIMMODE_LOOP, -8.0f); - this->actor.world.rot.y += 0x8000; - this->action = 0xB; - this->unk_26C = 0.0f; - } -} - -void func_80AEC9C4(EnRu1* this) { - this->unk_26C += 1.0f; - if (this->unk_26C >= 8.0f) { - this->action = 12; - this->unk_26C = 0.0f; - this->actor.velocity.y = -1.0f; - } -} - -void func_80AECA18(EnRu1* this) { - if (!(this->actor.bgCheckFlags & 1)) { - this->action = 13; - this->unk_26C = 0.0f; - this->actor.velocity.y = 0.0f; - } -} - -void func_80AECA44(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEAFA0(globalCtx, 5, 3)) { - gSaveContext.infTable[20] |= 2; - this->action = 14; - } -} - -void func_80AECA94(EnRu1* this, GlobalContext* globalCtx) { - func_80AEC780(this, globalCtx); -} - -void func_80AECAB4(EnRu1* this, GlobalContext* globalCtx) { - func_80AEC81C(this, globalCtx); -} - -void func_80AECAD4(EnRu1* this, GlobalContext* globalCtx) { - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEC8B8(this, globalCtx); -} - -void func_80AECB18(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - something = EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEC93C(this, something); -} - -void func_80AECB60(EnRu1* this, GlobalContext* globalCtx) { - func_80AEC40C(this); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEC650(this); - func_80AEC9C4(this); -} - -void func_80AECBB8(EnRu1* this, GlobalContext* globalCtx) { - func_80AEC4CC(this); - func_80AEC6E4(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEC650(this); - func_80AECA18(this); -} - -void func_80AECC1C(EnRu1* this, GlobalContext* globalCtx) { - func_80AEC4F4(this); - func_80AEC6E4(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEC650(this); - func_80AECA44(this, globalCtx); -} - -void func_80AECC84(EnRu1* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - Actor_Kill(&this->actor); - } -} - -void func_80AECCB0(EnRu1* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f* pos; - s16 yawTowardsPlayer; - f32 spawnX; - f32 spawnY; - f32 spawnZ; - s32 pad2[2]; - - yawTowardsPlayer = this->actor.yawTowardsPlayer; - pos = &this->actor.world.pos; - spawnX = ((kREG(1) + 12.0f) * Math_SinS(yawTowardsPlayer)) + pos->x; - spawnY = pos->y; - spawnZ = ((kREG(1) + 12.0f) * Math_CosS(yawTowardsPlayer)) + pos->z; - this->blueWarp = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, - spawnX, spawnY, spawnZ, 0, yawTowardsPlayer, 0, WARP_BLUE_RUTO); -} - -void func_80AECDA0(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB264(this, &gRutoChildWaitHandsOnHipsAnim, 0, 0, 0); - this->action = 15; - this->actor.shape.yOffset = -10000.0f; - EnRu1_SetEyeIndex(this, 5); - EnRu1_SetMouthIndex(this, 2); -} - -void func_80AECE04(EnRu1* this, GlobalContext* globalCtx) { - this->actor.shape.yOffset += (250.0f / 3.0f); -} - -void func_80AECE20(EnRu1* this, GlobalContext* globalCtx) { - s32 pad2; - Player* player = GET_PLAYER(globalCtx); - Vec3f* playerPos = &player->actor.world.pos; - s16 shapeRotY = player->actor.shape.rot.y; - s32 pad; - f32 unk_27C = this->unk_27C; - Vec3f* pos = &this->actor.world.pos; - - pos->x = (Math_SinS(shapeRotY) * unk_27C) + playerPos->x; - pos->y = playerPos->y; - pos->z = (Math_CosS(shapeRotY) * unk_27C) + playerPos->z; -} - -void func_80AECEB4(EnRu1* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - Vec3f* player_unk_450 = &player->unk_450; - Vec3f* pos = &this->actor.world.pos; - s16 shapeRotY = this->actor.shape.rot.y; - - player_unk_450->x = ((kREG(2) + 30.0f) * Math_SinS(shapeRotY)) + pos->x; - player_unk_450->z = ((kREG(2) + 30.0f) * Math_CosS(shapeRotY)) + pos->z; -} - -s32 func_80AECF6C(EnRu1* this, GlobalContext* globalCtx) { - s16* shapeRotY; - Player* player = GET_PLAYER(globalCtx); - Player* otherPlayer; - s16 temp_f16; - f32 temp1; - f32 temp2; - s32 pad2[5]; - - this->unk_26C += 1.0f; - if ((player->actor.speedXZ == 0.0f) && (this->unk_26C >= 3.0f)) { - otherPlayer = GET_PLAYER(globalCtx); - player->actor.world.pos.x = otherPlayer->unk_450.x; - player->actor.world.pos.y = otherPlayer->unk_450.y; - player->actor.world.pos.z = otherPlayer->unk_450.z; - shapeRotY = &player->actor.shape.rot.y; - temp1 = this->actor.world.pos.x - player->actor.world.pos.x; - temp2 = this->actor.world.pos.z - player->actor.world.pos.z; - temp_f16 = Math_FAtan2F(temp1, temp2) * (0x8000 / M_PI); - if (*shapeRotY != temp_f16) { - Math_SmoothStepToS(shapeRotY, temp_f16, 0x14, 0x1838, 0x64); - player->actor.world.rot.y = *shapeRotY; - } else { - return true; - } - } - return false; -} - -s32 func_80AED084(EnRu1* this, s32 state) { - if (this->blueWarp != NULL && this->blueWarp->rutoWarpState == state) { - return true; - } - return false; -} - -void func_80AED0B0(EnRu1* this, s32 state) { - if (this->blueWarp != NULL) { - this->blueWarp->rutoWarpState = state; - } -} - -void func_80AED0C8(EnRu1* this, GlobalContext* globalCtx) { - this->action = 16; -} - -void func_80AED0D8(EnRu1* this, GlobalContext* globalCtx) { - this->action = 17; - this->drawConfig = 1; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - func_80AECCB0(this, globalCtx); -} - -void func_80AED110(EnRu1* this) { - if (this->actor.shape.yOffset >= 0.0f) { - this->action = 18; - this->actor.shape.yOffset = 0.0f; - func_80AED0B0(this, WARP_BLUE_RUTO_STATE_READY); - } -} - -void func_80AED154(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AED084(this, WARP_BLUE_RUTO_STATE_ENTERED)) { - this->action = 0x13; - this->unk_26C = 0.0f; - func_80AECEB4(this, globalCtx); - } -} - -void func_80AED19C(EnRu1* this, s32 cond) { - if (cond) { - Animation_Change(&this->skelAnime, &gRutoChildTransitionHandsOnHipToCrossArmsAndLegsAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildTransitionHandsOnHipToCrossArmsAndLegsAnim), ANIMMODE_ONCE, - -8.0f); - this->action = 20; - func_80AED0B0(this, WARP_BLUE_RUTO_STATE_3); - } -} - -void func_80AED218(EnRu1* this, UNK_TYPE arg1) { - if (func_80AED084(this, WARP_BLUE_RUTO_STATE_TALKING)) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gRutoChildWaitSittingAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildWaitSittingAnim), ANIMMODE_LOOP, -8.0f); - } - } else if (func_80AED084(this, WARP_BLUE_RUTO_STATE_WARPING)) { - Animation_Change(&this->skelAnime, &gRutoChildWaitInBlueWarpAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildWaitInBlueWarpAnim), ANIMMODE_ONCE, -8.0f); - this->action = 21; - this->unk_27C = this->actor.xzDistToPlayer; - } -} - -void func_80AED304(EnRu1* this, GlobalContext* globalCtx) { - func_80AED0C8(this, globalCtx); -} - -void func_80AED324(EnRu1* this, GlobalContext* globalCtx) { - func_80AED0D8(this, globalCtx); -} - -void func_80AED344(EnRu1* this, GlobalContext* globalCtx) { - func_80AECE04(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - func_80AED110(this); -} - -void func_80AED374(EnRu1* this, GlobalContext* globalCtx) { - EnRu1_UpdateSkelAnime(this); - func_80AED154(this, globalCtx); -} - -void func_80AED3A4(EnRu1* this, GlobalContext* globalCtx) { - EnRu1_UpdateSkelAnime(this); - func_80AED19C(this, func_80AECF6C(this, globalCtx)); -} - -void func_80AED3E0(EnRu1* this, GlobalContext* globalCtx) { - func_80AEAECC(this, globalCtx); - func_80AED218(this, EnRu1_UpdateSkelAnime(this)); -} - -void func_80AED414(EnRu1* this, GlobalContext* globalCtx) { - func_80AECE20(this, globalCtx); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); -} - -void func_80AED44C(EnRu1* this, GlobalContext* globalCtx) { - s8 actorRoom; - - if ((gSaveContext.infTable[20] & 2) && !(gSaveContext.infTable[20] & 0x20) && !(gSaveContext.infTable[20] & 1) && - !(gSaveContext.infTable[20] & 0x80)) { - if (!func_80AEB020(this, globalCtx)) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - actorRoom = this->actor.room; - this->action = 22; - this->actor.room = -1; - this->roomNum1 = actorRoom; - this->roomNum3 = actorRoom; - this->roomNum2 = actorRoom; - } else { - Actor_Kill(&this->actor); - } - } else { - Actor_Kill(&this->actor); - } -} - -void func_80AED4FC(EnRu1* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_LAND_DIRT); -} - -void func_80AED520(EnRu1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Audio_PlaySoundGeneral(NA_SE_PL_PULL_UP_RUTO, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_LIFT); -} - -void func_80AED57C(EnRu1* this) { - if (this->actor.speedXZ != 0.0f) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_THROW); - } -} - -void func_80AED5B8(EnRu1* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_CRASH); -} - -void func_80AED5DC(EnRu1* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_UNBALLANCE); -} - -void func_80AED600(EnRu1* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_DISCOVER); -} - -s32 func_80AED624(EnRu1* this, GlobalContext* globalCtx) { - s8 curRoomNum = globalCtx->roomCtx.curRoom.num; - - if (this->roomNum2 != curRoomNum) { - Actor_Kill(&this->actor); - return false; - } else if (((this->roomNum1 != curRoomNum) || (this->roomNum2 != curRoomNum)) && - (this->actor.yDistToWater > kREG(16) + 50.0f) && (this->action != 33)) { - this->action = 33; - this->drawConfig = 2; - this->alpha = 0xFF; - this->unk_2A4 = 0.0f; - } - return true; -} - -void func_80AED6DC(EnRu1* this, GlobalContext* globalCtx) { - s8 curRoomNum = globalCtx->roomCtx.curRoom.num; - - this->roomNum2 = curRoomNum; - this->unk_288 = 0.0f; -} - -void func_80AED6F8(GlobalContext* globalCtx) { - s8 curRoomNum; - - if ((!(gSaveContext.infTable[20] & 0x80))) { - curRoomNum = globalCtx->roomCtx.curRoom.num; - if (curRoomNum == 2) { - gSaveContext.infTable[20] |= 0x80; - } - } -} - -void func_80AED738(EnRu1* this, GlobalContext* globalCtx) { - u32 temp_v0; - - if (func_80AED624(this, globalCtx)) { - this->unk_2A4 += 1.0f; - if (this->unk_2A4 < 20.0f) { - temp_v0 = ((20.0f - this->unk_2A4) * 255.0f) / 20.0f; - this->alpha = temp_v0; - this->actor.shape.shadowAlpha = temp_v0; - } else { - Actor_Kill(&this->actor); - } - } -} - -void func_80AED83C(EnRu1* this) { - s32 pad[2]; - Vec3s* tempPtr; - Vec3s* tempPtr2; - - tempPtr = &this->unk_374.unk_08; - Math_SmoothStepToS(&tempPtr->x, 0, 0x14, 0x1838, 0x64); - Math_SmoothStepToS(&tempPtr->y, 0, 0x14, 0x1838, 0x64); - tempPtr2 = &this->unk_374.unk_0E; - Math_SmoothStepToS(&tempPtr2->x, 0, 0x14, 0x1838, 0x64); - Math_SmoothStepToS(&tempPtr2->y, 0, 0x14, 0x1838, 0x64); -} - -void func_80AED8DC(EnRu1* this) { - s32 temp_hi; - s16* unk_2AC = &this->unk_2AC; - s16* someY = &this->unk_374.unk_08.y; - s16* unk_29E = &this->unk_29E; - s32 pad[2]; - - if (DECR(*unk_2AC) == 0) { - *unk_2AC = Rand_S16Offset(0xA, 0x19); - temp_hi = *unk_2AC % 5; - if (temp_hi == 0) { - this->unk_2B0 = 1; - } else if (temp_hi == 1) { - this->unk_2B0 = 2; - } else { - this->unk_2B0 = 0; - } - *unk_29E = 0; - } - - if (this->unk_2B0 == 0) { - Math_SmoothStepToS(unk_29E, 0 - *someY, 1, 0x190, 0x190); - Math_SmoothStepToS(someY, 0, 3, ABS(*unk_29E), 0x64); - } else if (this->unk_2B0 == 1) { - Math_SmoothStepToS(unk_29E, -0x2AAA - *someY, 1, 0x190, 0x190); - Math_SmoothStepToS(someY, -0x2AAA, 3, ABS(*unk_29E), 0x64); - } else { - Math_SmoothStepToS(unk_29E, 0x2AAA - *someY, 1, 0x190, 0x190); - Math_SmoothStepToS(someY, 0x2AAA, 3, ABS(*unk_29E), 0x64); - } -} - -void func_80AEDAE0(EnRu1* this, GlobalContext* globalCtx) { - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); - - if (dynaPolyActor == NULL || dynaPolyActor->actor.id == ACTOR_EN_BOX) { - this->actor.bgCheckFlags &= ~0x19; - } -} - -void func_80AEDB30(EnRu1* this, GlobalContext* globalCtx) { - DynaPolyActor* dynaPolyActor; - f32* velocityY; - f32* speedXZ; - f32* gravity; - s16 wallYaw; - s16 rotY; - s32 temp_a1_2; - s32 temp_a0; - s32 phi_v1; - - if (this->actor.bgCheckFlags & 1) { - velocityY = &this->actor.velocity.y; - dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); - if (*velocityY <= 0.0f) { - speedXZ = &this->actor.speedXZ; - if (dynaPolyActor != NULL) { - if (dynaPolyActor->actor.id != ACTOR_EN_BOX) { - *speedXZ = 0.0f; - } - } else { - if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { - *speedXZ *= (kREG(19) * 0.01f) + 0.8f; - } else { - *speedXZ = 0.0f; - } - } - gravity = &this->actor.gravity; - if (dynaPolyActor != NULL) { - if (dynaPolyActor->actor.id != ACTOR_EN_BOX) { - *velocityY = 0.0f; - this->actor.minVelocityY = 0.0f; - *gravity = 0.0f; - } else { - *velocityY *= -1.0f; - } - } else { - *velocityY *= -((kREG(20) * 0.01f) + 0.6f); - if (*velocityY <= -*gravity * ((kREG(20) * 0.01f) + 0.6f)) { - *velocityY = 0.0f; - this->actor.minVelocityY = 0.0f; - *gravity = 0.0f; - } - } - func_80AED4FC(this); - } - } - if (this->actor.bgCheckFlags & 0x10) { - speedXZ = &this->actor.speedXZ; - velocityY = &this->actor.velocity.y; - if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { - *speedXZ *= (kREG(19) * 0.01f) + 0.8f; - } else { - *speedXZ = 0.0f; - } - if (*velocityY >= 0.0f) { - *velocityY *= -((kREG(20) * 0.01f) + 0.6f); - func_80AED4FC(this); - } - } - if (this->actor.bgCheckFlags & 8) { - speedXZ = &this->actor.speedXZ; - if (*speedXZ != 0.0f) { - rotY = this->actor.world.rot.y; - wallYaw = this->actor.wallYaw; - temp_a0 = (wallYaw * 2) - rotY; - temp_a1_2 = temp_a0 + 0x8000; - if ((s16)((temp_a0 - wallYaw) + 0x8000) >= 0) { - phi_v1 = (s16)(temp_a1_2 - wallYaw); - } else { - phi_v1 = -(s16)(temp_a1_2 - wallYaw); - } - if (phi_v1 < 0x4001) { - if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { - *speedXZ *= (kREG(21) * 0.01f) + 0.6f; - } else { - *speedXZ = 0.0f; - } - this->actor.world.rot.y = temp_a1_2; - func_80AED4FC(this); - func_80AED5B8(this); - } - } - } -} - -void func_80AEDEF4(EnRu1* this, GlobalContext* globalCtx) { - f32* speedXZ = &this->actor.speedXZ; - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); - - if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_EN_BOX) { - if (*speedXZ != 0.0f) { - *speedXZ *= 1.1f; - } else { - *speedXZ = 1.0f; - } - } - if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { - *speedXZ *= (kREG(22) * 0.01f) + 0.98f; - } else { - *speedXZ = 0.0f; - } -} - -void func_80AEDFF4(EnRu1* this, GlobalContext* globalCtx) { - func_80AEDB30(this, globalCtx); - func_80AEDEF4(this, globalCtx); - Actor_MoveForward(&this->actor); -} - -void func_80AEE02C(EnRu1* this) { - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; -} - -void func_80AEE050(EnRu1* this) { - s32 pad; - f32 sp28; - f32 sp24; - f32 temp_f10; - EnRu1* thisx = this; // necessary to match - - if (this->unk_350 == 0) { - if ((this->actor.minVelocityY == 0.0f) && (this->actor.speedXZ == 0.0f)) { - this->unk_350 = 1; - func_80AEE02C(this); - this->unk_35C = 0; - this->unk_358 = (this->actor.yDistToWater - 10.0f) * 0.5f; - this->unk_354 = this->actor.world.pos.y + thisx->unk_358; // thisx only used here - } else { - this->actor.gravity = 0.0f; - this->actor.minVelocityY *= 0.2f; - this->actor.velocity.y *= 0.2f; - if (this->actor.minVelocityY >= -0.1f) { - this->actor.minVelocityY = 0.0f; - this->actor.velocity.y = 0.0f; - } - this->actor.speedXZ *= 0.5f; - if (this->actor.speedXZ <= 0.1f) { - this->actor.speedXZ = 0.0f; - } - this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - func_8002D7EC(&this->actor); - } - } else { - if (this->unk_350 == 1) { - if (this->unk_358 <= 1.0f) { - func_80AEE02C(this); - this->unk_350 = 2; - this->unk_360 = 0.0f; - } else { - sp28 = this->unk_358; - sp24 = this->unk_354; - temp_f10 = Math_CosS(this->unk_35C) * -sp28; - this->actor.world.pos.y = temp_f10 + sp24; - this->unk_35C += 0x3E8; - this->unk_358 *= 0.95f; - } - } else { - this->unk_360 += 1.0f; - if (this->unk_360 > 0.0f) { - this->unk_350 = 3; - } - } - } -} - -s32 func_80AEE264(EnRu1* this, GlobalContext* globalCtx) { - if (!Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - if ((gSaveContext.infTable[20] & 8)) { - this->actor.textId = 0x404E; - func_8002F2F4(&this->actor, globalCtx); - } else if (gSaveContext.infTable[20] & 4) { - this->actor.textId = 0x404D; - func_8002F2F4(&this->actor, globalCtx); - } else { - this->actor.textId = 0x404C; - func_8002F2F4(&this->actor, globalCtx); - } - return false; - } - return true; -} - -void func_80AEE2F8(EnRu1* this, GlobalContext* globalCtx) { - DynaPolyActor* dynaPolyActor; - s32 floorBgId; - - if ((this->actor.bgCheckFlags & 1) && (this->actor.floorBgId != BGCHECK_SCENE)) { - floorBgId = this->actor.floorBgId; - dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, floorBgId); - if ((dynaPolyActor != NULL) && (dynaPolyActor->actor.id == ACTOR_BG_BDAN_SWITCH)) { - if (((dynaPolyActor->actor.params >> 8) & 0x3F) == 0x38) { - gSaveContext.infTable[20] |= 1; - return; - } - } - } - gSaveContext.infTable[20] &= ~0x1; -} - -s32 func_80AEE394(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - CollisionContext* colCtx; - DynaPolyActor* dynaPolyActor; - s32 floorBgId; - - if ((this->actor.bgCheckFlags & 1) && this->actor.floorBgId != BGCHECK_SCENE) { - colCtx = &globalCtx->colCtx; - floorBgId = this->actor.floorBgId; // necessary match, can't move this out of this block unfortunately - dynaPolyActor = DynaPoly_GetActor(colCtx, floorBgId); - if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_BG_BDAN_OBJECTS && - dynaPolyActor->actor.params == 0 && !Player_InCsMode(globalCtx) && globalCtx->msgCtx.msgLength == 0) { - func_80AEE02C(this); - globalCtx->csCtx.segment = &D_80AF10A4; - gSaveContext.cutsceneTrigger = 1; - this->action = 36; - this->drawConfig = 0; - this->unk_28C = (BgBdanObjects*)dynaPolyActor; - this->actor.shape.shadowAlpha = 0; - return true; - } - } - return false; -} - -void func_80AEE488(EnRu1* this, GlobalContext* globalCtx) { - s8 curRoomNum; - - if (Actor_HasParent(&this->actor, globalCtx)) { - curRoomNum = globalCtx->roomCtx.curRoom.num; - this->roomNum3 = curRoomNum; - this->action = 31; - func_80AED520(this, globalCtx); - } else if ((!func_80AEE394(this, globalCtx)) && (!(this->actor.bgCheckFlags & 1))) { - this->actor.minVelocityY = -((kREG(24) * 0.01f) + 6.8f); - this->actor.gravity = -((kREG(23) * 0.01f) + 1.3f); - this->action = 28; - } -} - -void func_80AEE568(EnRu1* this, GlobalContext* globalCtx) { - if (!func_80AEE394(this, globalCtx)) { - if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ == 0.0f) && (this->actor.minVelocityY == 0.0f)) { - func_80AEE02C(this); - func_8002F580(&this->actor, globalCtx); - this->action = 27; - func_80AEADD8(this); - } else if (this->actor.yDistToWater > 0.0f) { - this->action = 29; - this->unk_350 = 0; - } - } -} - -void func_80AEE628(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - s8 curRoomNum = globalCtx->roomCtx.curRoom.num; - - if (EnRu1_IsCsStateIdle(globalCtx)) { - Animation_Change(&this->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildSittingAnim), ANIMMODE_LOOP, -8.0f); - gSaveContext.infTable[20] |= 0x10; - this->action = 31; - } - this->roomNum3 = curRoomNum; -} - -s32 func_80AEE6D0(EnRu1* this, GlobalContext* globalCtx) { - s32 pad; - s8 curRoomNum = globalCtx->roomCtx.curRoom.num; - - if (!(gSaveContext.infTable[20] & 0x10) && (func_80AEB124(globalCtx) != 0)) { - if (!Player_InCsMode(globalCtx)) { - Animation_Change(&this->skelAnime, &gRutoChildSeesSapphireAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildSquirmAnim), ANIMMODE_LOOP, -8.0f); - func_80AED600(this); - this->action = 34; - this->unk_26C = 0.0f; - globalCtx->csCtx.segment = &D_80AF1728; - gSaveContext.cutsceneTrigger = 1; - } - this->roomNum3 = curRoomNum; - return true; - } - this->roomNum3 = curRoomNum; - return false; -} - -void func_80AEE7C4(EnRu1* this, GlobalContext* globalCtx) { - f32 frameCount; - s32 pad[13]; - Player* player; - f32* unk_370 = &this->unk_370; - - if (Actor_HasNoParent(&this->actor, globalCtx)) { - frameCount = Animation_GetLastFrame(&gRutoChildSittingAnim); - Animation_Change(&this->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); - func_80AED6DC(this, globalCtx); - this->actor.speedXZ *= (kREG(25) * 0.01f) + 1.0f; - this->actor.velocity.y *= (kREG(26) * 0.01f) + 1.0f; - this->actor.minVelocityY = -((kREG(24) * 0.01f) + 6.8f); - this->actor.gravity = -((kREG(23) * 0.01f) + 1.3f); - func_80AED57C(this); - this->action = 28; - *unk_370 = 0.0f; - return; - } - - if (func_80AEE6D0(this, globalCtx)) { - *unk_370 = 0.0f; - return; - } - - player = GET_PLAYER(globalCtx); - if (player->stateFlags2 & 0x10000000) { - this->unk_370 += 1.0f; - if (this->action != 32) { - if (*unk_370 > 30.0f) { - if (Rand_S16Offset(0, 3) == 0) { - frameCount = Animation_GetLastFrame(&gRutoChildSquirmAnim); - Animation_Change(&this->skelAnime, &gRutoChildSquirmAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, - -8.0f); - func_80AED5DC(this); - this->action = 32; - } - *unk_370 = 0.0f; - } - } else { - if (*unk_370 > 50.0f) { - frameCount = Animation_GetLastFrame(&gRutoChildSittingAnim); - Animation_Change(&this->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); - this->action = 31; - *unk_370 = 0.0f; - } - } - } else { - frameCount = Animation_GetLastFrame(&gRutoChildSittingAnim); - Animation_Change(&this->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); - *unk_370 = 0.0f; - } -} - -s32 func_80AEEAC8(EnRu1* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { - func_80AEE02C(this); - func_8002F580(&this->actor, globalCtx); - this->action = 27; - func_80AEADD8(this); - return true; - } - return false; -} - -void func_80AEEB24(EnRu1* this, GlobalContext* globalCtx) { - if ((func_80AEEAC8(this, globalCtx) == 0) && (this->unk_350 == 3)) { - this->action = 30; - func_80AEE02C(this); - this->actor.gravity = -0.1f; - this->actor.minVelocityY = -((kREG(18) * 0.1f) + 0.7f); - } -} - -void func_80AEEBB4(EnRu1* this, GlobalContext* globalCtx) { - func_8002F580(&this->actor, globalCtx); -} - -void func_80AEEBD4(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAC54(this, globalCtx); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEEBB4(this, globalCtx); - func_80AEE488(this, globalCtx); - func_80AED624(this, globalCtx); - func_80AEDAE0(this, globalCtx); -} - -void func_80AEEC5C(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEACDC(this, globalCtx); - func_80AEAECC(this, globalCtx); - func_80AEE2F8(this, globalCtx); - func_80AEDFF4(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEE568(this, globalCtx); - func_80AED624(this, globalCtx); - func_80AEDAE0(this, globalCtx); -} - -void func_80AEECF0(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - func_80AEE050(this); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEEB24(this, globalCtx); - func_80AED624(this, globalCtx); -} - -void func_80AEED58(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - Actor_MoveForward(&this->actor); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEEAC8(this, globalCtx); - func_80AED624(this, globalCtx); - func_80AEDAE0(this, globalCtx); -} - -void func_80AEEDCC(EnRu1* this, GlobalContext* globalCtx) { - func_80AED8DC(this); - EnRu1_UpdateSkelAnime(this); - func_80AEAECC(this, globalCtx); - func_80AEE2F8(this, globalCtx); - EnRu1_UpdateEyes(this); - func_80AED6F8(globalCtx); - func_80AEE7C4(this, globalCtx); -} - -void func_80AEEE34(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - EnRu1_UpdateSkelAnime(this); - func_80AEAECC(this, globalCtx); - func_80AEE2F8(this, globalCtx); - EnRu1_UpdateEyes(this); - func_80AED6F8(globalCtx); - func_80AEE7C4(this, globalCtx); -} - -void func_80AEEE9C(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - func_80AEDFF4(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AED738(this, globalCtx); - func_80AED624(this, globalCtx); -} - -void func_80AEEF08(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - EnRu1_UpdateSkelAnime(this); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateEyes(this); - func_80AEE628(this, globalCtx); -} - -void func_80AEEF5C(EnRu1* this, GlobalContext* globalCtx) { -} - -void func_80AEEF68(EnRu1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 something; - - this->unk_374.unk_18 = player->actor.world.pos; - this->unk_374.unk_14 = kREG(16) - 3.0f; - something = kREG(17) + 0xC; - func_80034A14(&this->actor, &this->unk_374, something, 2); -} - -void func_80AEEFEC(EnRu1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 something; - - this->unk_374.unk_18 = player->actor.world.pos; - this->unk_374.unk_14 = kREG(16) - 3.0f; - something = kREG(17) + 0xC; - func_80034A14(&this->actor, &this->unk_374, something, 4); - this->actor.world.rot.y = this->actor.shape.rot.y; -} - -void func_80AEF080(EnRu1* this) { - if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_LAND_DIRT); - } -} - -s32 func_80AEF0BC(EnRu1* this, GlobalContext* globalCtx) { - s32 frameCount; - - if (gSaveContext.infTable[20] & 4) { - frameCount = Animation_GetLastFrame(&gRutoChildSitAnim); - Animation_Change(&this->skelAnime, &gRutoChildSitAnim, 1.0f, 0, frameCount, ANIMMODE_ONCE, -8.0f); - globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->action = 26; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - return true; - } - return false; -} - -void func_80AEF170(EnRu1* this, GlobalContext* globalCtx, s32 cond) { - if (cond) { - this->action = 25; - } -} - -void func_80AEF188(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEB174(globalCtx) && !func_80AEF0BC(this, globalCtx)) { - Message_CloseTextbox(globalCtx); - gSaveContext.infTable[20] |= 4; - this->action = 24; - } -} - -void func_80AEF1F0(EnRu1* this, GlobalContext* globalCtx, UNK_TYPE arg2) { - if (arg2 != 0) { - Animation_Change(&this->skelAnime, &gRutoChildSittingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gRutoChildSittingAnim), ANIMMODE_LOOP, 0.0f); - Message_CloseTextbox(globalCtx); - gSaveContext.infTable[20] |= 8; - func_80AED6DC(this, globalCtx); - func_8002F580(&this->actor, globalCtx); - this->action = 27; - func_80AEADD8(this); - } -} - -void func_80AEF29C(EnRu1* this, GlobalContext* globalCtx) { - this->action = 23; -} - -void func_80AEF2AC(EnRu1* this, GlobalContext* globalCtx) { - this->action = 24; - this->drawConfig = 1; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; -} - -void func_80AEF2D0(EnRu1* this, GlobalContext* globalCtx) { - s32 cond; - - func_80AEEF68(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAC10(this, globalCtx); - func_80AEAECC(this, globalCtx); - cond = func_80AEE264(this, globalCtx); - func_80AED624(this, globalCtx); - func_80AEF170(this, globalCtx, cond); -} - -void func_80AEF354(EnRu1* this, GlobalContext* globalCtx) { - func_80AEEFEC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEF188(this, globalCtx); -} - -void func_80AEF3A8(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - func_80AED83C(this); - something = EnRu1_UpdateSkelAnime(this); - func_80AEF080(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEF1F0(this, globalCtx, something); -} - -void func_80AEF40C(EnRu1* this) { - SkelAnime* skelAnime = &this->skelAnime; - - if (Animation_OnFrame(skelAnime, 2.0f) || Animation_OnFrame(skelAnime, 7.0f) || - Animation_OnFrame(skelAnime, 12.0f) || Animation_OnFrame(skelAnime, 18.0f) || - Animation_OnFrame(skelAnime, 25.0f) || Animation_OnFrame(skelAnime, 33.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_DIRT); - } -} - -void func_80AEF4A8(EnRu1* this, GlobalContext* globalCtx) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.projectedPos, 20, NA_SE_VO_RT_FALL); -} - -void func_80AEF4E0(EnRu1* this) { - if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_LAUGH_0); - } -} - -void func_80AEF51C(EnRu1* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_THROW); -} - -void func_80AEF540(EnRu1* this) { - if (func_80AEB104(this) == 2) { - EnRu1_SetEyeIndex(this, 3); - EnRu1_SetMouthIndex(this, 2); - if (this->skelAnime.mode != 2) { - func_80AEB264(this, &gRutoChildShutterAnim, 2, -8.0f, 0); - func_80AEF51C(this); - } - } -} - -void func_80AEF5B8(EnRu1* this) { - f32 curFrame; - - if (D_80AF1938 == 0) { - curFrame = this->skelAnime.curFrame; - if (curFrame >= 60.0f) { - EnRu1_SetEyeIndex(this, 3); - EnRu1_SetMouthIndex(this, 0); - func_80AED57C(this); - D_80AF1938 = 1; - } - } -} - -void func_80AEF624(EnRu1* this, GlobalContext* globalCtx) { - f32 frameCount; - CsCmdActorAction* csCmdNPCAction; - CsCmdActorAction* csCmdNPCAction2; - s16 newRotTmp; - - if (func_80AEAFE0(globalCtx, 1, 3)) { - frameCount = Animation_GetLastFrame(&gRutoChildWalkToAndHoldUpSapphireAnim); - // this weird part with the redundant variable is necessary to match for some reason - csCmdNPCAction2 = globalCtx->csCtx.npcActions[3]; - csCmdNPCAction = csCmdNPCAction2; - this->actor.world.pos.x = csCmdNPCAction->startPos.x; - this->actor.world.pos.y = csCmdNPCAction->startPos.y; - this->actor.world.pos.z = csCmdNPCAction->startPos.z; - newRotTmp = csCmdNPCAction->rot.x; - this->actor.shape.rot.x = newRotTmp; - this->actor.world.rot.x = newRotTmp; - newRotTmp = csCmdNPCAction->rot.y; - this->actor.shape.rot.y = newRotTmp; - this->actor.world.rot.y = newRotTmp; - newRotTmp = csCmdNPCAction->rot.z; - this->actor.shape.rot.z = newRotTmp; - this->actor.world.rot.z = newRotTmp; - Animation_Change(&this->skelAnime, &gRutoChildWalkToAndHoldUpSapphireAnim, 1.0f, 0.0f, frameCount, - ANIMMODE_ONCE, 0.0f); - func_80AEB3A4(this, globalCtx); - this->action = 37; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80AEF728(EnRu1* this, UNK_TYPE arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gRutoChildHoldArmsUpAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gRutoChildHoldArmsUpAnim), ANIMMODE_LOOP, 0.0f); - func_80AEB3CC(this); - this->action = 38; - } -} - -void func_80AEF79C(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEAFE0(globalCtx, 2, 3)) { - Animation_Change(&this->skelAnime, &gRutoChildBringHandsDownAnim, 1.0f, 0, - Animation_GetLastFrame(&gRutoChildBringHandsDownAnim), ANIMMODE_ONCE, -8.0f); - this->action = 39; - } -} - -void func_80AEF820(EnRu1* this, UNK_TYPE arg1) { - if (arg1 != 0) { - Animation_Change(&this->skelAnime, &gRutoChildWait2Anim, 1.0f, 0, Animation_GetLastFrame(&gRutoChildWait2Anim), - ANIMMODE_LOOP, -8.0f); - this->action = 40; - } -} - -void func_80AEF890(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - s8 curRoomNum; - - if ((gSaveContext.sceneSetupIndex < 4) && (EnRu1_IsCsStateIdle(globalCtx))) { - curRoomNum = globalCtx->roomCtx.curRoom.num; - gSaveContext.infTable[20] |= 0x20; - Flags_SetSwitch(globalCtx, func_80AEADE0(this)); - func_80AEB0EC(this, 1); - this->action = 42; - this->actor.room = curRoomNum; - } -} - -void func_80AEF930(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEB104(this) == 3) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.textId = 0x4048; - Message_ContinueTextbox(globalCtx, this->actor.textId); - func_80AEF4A8(this, globalCtx); - this->action = 43; - this->drawConfig = 0; - } -} - -void func_80AEF99C(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEB1B4(globalCtx) != 0) { - func_80AEB0EC(this, 4); - Actor_Kill(&this->actor); - } -} - -void func_80AEF9D8(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEF624(this, globalCtx); - func_80AEB220(this, globalCtx); -} - -void func_80AEFA2C(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - func_80AED83C(this); - func_80AEB364(this, globalCtx); - func_80AEAECC(this, globalCtx); - something = EnRu1_UpdateSkelAnime(this); - func_80AEF4E0(this); - func_80AEF5B8(this); - func_80AEF40C(this); - func_80AEF728(this, something); - func_80AEB220(this, globalCtx); -} - -void func_80AEFAAC(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - func_80AEF79C(this, globalCtx); - func_80AEB220(this, globalCtx); -} - -void func_80AEFB04(EnRu1* this, GlobalContext* globalCtx) { - s32 something; - - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - something = EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEF820(this, something); - func_80AEB220(this, globalCtx); -} - -void func_80AEFB68(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEF890(this, globalCtx); - func_80AEB220(this, globalCtx); -} - -void func_80AEFBC8(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEAECC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEF540(this); - func_80AEF930(this, globalCtx); -} - -void func_80AEFC24(EnRu1* this, GlobalContext* globalCtx) { - func_80AED83C(this); - func_80AEF99C(this, globalCtx); -} - -void func_80AEFC54(EnRu1* this, GlobalContext* globalCtx) { - if ((gSaveContext.infTable[20] & 0x20) && !(gSaveContext.infTable[20] & 0x40)) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - this->action = 41; - this->unk_28C = EnRu1_FindSwitch(globalCtx); - func_80AEB0EC(this, 1); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - } else { - Actor_Kill(&this->actor); - } -} - -void func_80AEFCE8(EnRu1* this, GlobalContext* globalCtx) { - this->unk_28C = EnRu1_FindSwitch(globalCtx); - if (this->unk_28C != NULL) { - this->action = 42; - this->drawConfig = 1; - func_80AEB0EC(this, 1); - } -} - -void func_80AEFD38(EnRu1* this, GlobalContext* globalCtx) { - if ((gSaveContext.eventChkInf[3] & 0x80) && LINK_IS_CHILD) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - this->actor.flags &= ~ACTOR_FLAG_4; - this->action = 44; - this->drawConfig = 1; - } else { - Actor_Kill(&this->actor); - } -} - -s32 func_80AEFDC0(EnRu1* this, GlobalContext* globalCtx) { - if (!Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x1F); - if (this->actor.textId == 0) { - this->actor.textId = 0x402C; - } - func_8002F2F4(&this->actor, globalCtx); - return false; - } - return true; -} - -s32 func_80AEFE38(EnRu1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - return true; - } - return false; -} - -void func_80AEFE84(EnRu1* this, GlobalContext* globalCtx, s32 cond) { - if (cond) { - this->action = 45; - } -} - -void func_80AEFE9C(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AEFE38(this, globalCtx)) { - this->action = 44; - } -} - -void func_80AEFECC(EnRu1* this, GlobalContext* globalCtx) { - func_80AEEF68(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAC10(this, globalCtx); - func_80AEAECC(this, globalCtx); - func_80AEFE84(this, globalCtx, func_80AEFDC0(this, globalCtx)); -} - -void func_80AEFF40(EnRu1* this, GlobalContext* globalCtx) { - func_80AEEFEC(this, globalCtx); - EnRu1_UpdateSkelAnime(this); - EnRu1_UpdateEyes(this); - func_80AEAECC(this, globalCtx); - func_80AEFE9C(this, globalCtx); -} - -void func_80AEFF94(EnRu1* this, GlobalContext* globalCtx) { - s8 actorRoom; - - if ((gSaveContext.infTable[20] & 2) && (gSaveContext.infTable[20] & 1) && !(gSaveContext.infTable[20] & 0x20) && - (!(func_80AEB020(this, globalCtx)))) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - actorRoom = this->actor.room; - this->action = 22; - this->actor.room = -1; - this->drawConfig = 0; - this->roomNum1 = actorRoom; - this->roomNum3 = actorRoom; - this->roomNum2 = actorRoom; - // "Ruto switch set" - osSyncPrintf("スイッチルトセット!!!!!!!!!!!!!!!!!!!!!!\n"); - } else { - // "Ruto switch not set" - osSyncPrintf("スイッチルトセットしない!!!!!!!!!!!!!!!!!!!!!!\n"); - Actor_Kill(&this->actor); - } -} - -void func_80AF0050(EnRu1* this, GlobalContext* globalCtx) { - func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); - this->action = 36; - this->roomNum1 = this->actor.room; - this->unk_28C = EnRu1_FindSwitch(globalCtx); - this->actor.room = -1; -} - -void EnRu1_Update(Actor* thisx, GlobalContext* globalCtx) { - EnRu1* this = (EnRu1*)thisx; - - if (this->action < 0 || this->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[this->action] == NULL) { - // "Main mode is improper!" - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - - sActionFuncs[this->action](this, globalCtx); -} - -void EnRu1_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnRu1* this = (EnRu1*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRutoChildSkel, NULL, this->jointTable, this->morphTable, 17); - func_80AEAD20(&this->actor, globalCtx); - switch (func_80AEADF0(this)) { - case 0: - func_80AECDA0(this, globalCtx); - break; - case 1: - func_80AEB3DC(this, globalCtx); - break; - case 2: - func_80AEC320(this, globalCtx); - break; - case 3: - func_80AED44C(this, globalCtx); - break; - case 4: - func_80AEFC54(this, globalCtx); - break; - case 5: - func_80AEFD38(this, globalCtx); - break; - case 6: - func_80AEFF94(this, globalCtx); - break; - case 10: - func_80AF0050(this, globalCtx); - break; - default: - Actor_Kill(&this->actor); - // "Relevant arge_data = %d unacceptable" - osSyncPrintf("該当 arge_data = %d 無し\n", func_80AEADF0(this)); - break; - } -} - -void func_80AF0278(EnRu1* this, GlobalContext* globalCtx, s32 limbIndex, Vec3s* rot) { - Vec3s* vec1 = &this->unk_374.unk_0E; - Vec3s* vec2 = &this->unk_374.unk_08; - - switch (limbIndex) { - case RUTO_CHILD_LEFT_UPPER_ARM: - rot->x += vec1->y; - rot->y -= vec1->x; - break; - case RUTO_CHILD_TORSO: - rot->x += vec2->y; - rot->z += vec2->x; - break; - } -} - -s32 EnRu1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnRu1* this = (EnRu1*)thisx; - - if ((this->unk_290 < 0) || (this->unk_290 > 0) || (*sPreLimbDrawFuncs[this->unk_290] == NULL)) { - // "Neck rotation mode is improper!" - osSyncPrintf(VT_FGCOL(RED) "首回しモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - } else { - sPreLimbDrawFuncs[this->unk_290](this, globalCtx, limbIndex, rot); - } - return false; -} - -void EnRu1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnRu1* this = (EnRu1*)thisx; - Vec3f vec1; - Vec3f vec2; - - if (limbIndex == RUTO_CHILD_TORSO) { - vec1 = sMultVec; - Matrix_MultVec3f(&vec1, &vec2); - this->actor.focus.pos.x = vec2.x; - this->actor.focus.pos.y = vec2.y; - this->actor.focus.pos.z = vec2.z; - this->actor.focus.rot.x = this->actor.world.rot.x; - this->actor.focus.rot.y = this->actor.world.rot.y; - this->actor.focus.rot.z = this->actor.world.rot.z; - } -} - -void EnRu1_DrawNothing(EnRu1* this, GlobalContext* globalCtx) { -} - -void EnRu1_DrawOpa(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeIndex = this->eyeIndex; - void* eyeTex = sEyeTextures[eyeIndex]; - s16 mouthIndex = this->mouthIndex; - SkelAnime* skelAnime = &this->skelAnime; - void* mouthTex = sMouthTextures[mouthIndex]; - s32 pad1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1282); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnRu1_OverrideLimbDraw, EnRu1_PostLimbDraw, this, POLY_OPA_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1309); -} - -void EnRu1_DrawXlu(EnRu1* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeIndex = this->eyeIndex; - void* eyeTex = sEyeTextures[eyeIndex]; - s16 mouthIndex = this->mouthIndex; - SkelAnime* skelAnime = &this->skelAnime; - void* mouthTex = sMouthTextures[mouthIndex]; - s32 pad1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1324); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnRu1_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1353); -} - -void EnRu1_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnRu1* this = (EnRu1*)thisx; - - if (this->drawConfig < 0 || this->drawConfig >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[this->drawConfig] == 0) { - // "Draw mode is improper!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.cpp b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.cpp new file mode 100644 index 000000000..359d93986 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.cpp @@ -0,0 +1,2385 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RU1_Z_EN_RU1_C +#include "actor_common.h" +/* + * File: z_en_ru1.c + * Overlay: En_Ru1 + * Description: Ruto (child) + */ + +#include "z_en_ru1.h" +#include "objects/object_ru1/object_ru1.h" +#include "vt.h" +#include "def/code_8006BA00.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_26) + +void EnRu1_Init(Actor* thisx, GlobalContext* globalCtx); +void EnRu1_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnRu1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnRu1_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AEC0B4(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEC100(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEC130(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEC17C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEC1D4(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEC244(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEC2C0(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECA94(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECAB4(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECAD4(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECB18(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECB60(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECBB8(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECC1C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AECC84(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED304(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED324(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED344(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED374(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED3A4(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED3E0(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AED414(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEF29C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEF2AC(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEF2D0(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEF354(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEF3A8(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEBD4(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEC5C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEECF0(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEED58(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEDCC(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEE34(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEE9C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEF08(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEEF5C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEF9D8(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFA2C(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFAAC(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFB04(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFB68(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFCE8(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFBC8(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFC24(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFECC(EnRu1* pthis, GlobalContext* globalCtx); +void func_80AEFF40(EnRu1* pthis, GlobalContext* globalCtx); + +void func_80AF0278(EnRu1* pthis, GlobalContext* globalCtx, s32 limbIndex, Vec3s* rot); + +void EnRu1_DrawNothing(EnRu1* pthis, GlobalContext* globalCtx); +void EnRu1_DrawOpa(EnRu1* pthis, GlobalContext* globalCtx); +void EnRu1_DrawXlu(EnRu1* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInitType1 sCylinderInit1 = { + { + COLTYPE_HIT0, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 }, + { 25, 80, 0, { 0 } }, +}; + +static ColliderCylinderInitType1 sCylinderInit2 = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { 0x00, { 0x00000101, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x01, 0x00, 0x01 }, + { 20, 30, 0, { 0 } }, +}; + +static void* sEyeTextures[] = { + gRutoChildEyeOpenTex, gRutoChildEyeHalfTex, gRutoChildEyeClosedTex, + gRutoChildEyeRollLeftTex, gRutoChildEyeHalf2Tex, gRutoChildEyeHalfWithBlushTex, +}; + +static void* sMouthTextures[] = { + gRutoChildMouthClosedTex, + gRutoChildMouthFrownTex, + gRutoChildMouthOpenTex, +}; + +static s32 sUnused = 0; + +#include "z_en_ru1_cutscene_data.cpp" EARLY + +static u32 D_80AF1938 = 0; + +static EnRu1ActionFunc sActionFuncs[] = { + func_80AEC0B4, func_80AEC100, func_80AEC130, func_80AEC17C, func_80AEC1D4, func_80AEC244, func_80AEC2C0, + func_80AECA94, func_80AECAB4, func_80AECAD4, func_80AECB18, func_80AECB60, func_80AECBB8, func_80AECC1C, + func_80AECC84, func_80AED304, func_80AED324, func_80AED344, func_80AED374, func_80AED3A4, func_80AED3E0, + func_80AED414, func_80AEF29C, func_80AEF2AC, func_80AEF2D0, func_80AEF354, func_80AEF3A8, func_80AEEBD4, + func_80AEEC5C, func_80AEECF0, func_80AEED58, func_80AEEDCC, func_80AEEE34, func_80AEEE9C, func_80AEEF08, + func_80AEEF5C, func_80AEF9D8, func_80AEFA2C, func_80AEFAAC, func_80AEFB04, func_80AEFB68, func_80AEFCE8, + func_80AEFBC8, func_80AEFC24, func_80AEFECC, func_80AEFF40, +}; + +static EnRu1PreLimbDrawFunc sPreLimbDrawFuncs[] = { + func_80AF0278, +}; + +static Vec3f sMultVec = { 0.0f, 10.0f, 0.0f }; + +static EnRu1DrawFunc sDrawFuncs[] = { + EnRu1_DrawNothing, + EnRu1_DrawOpa, + EnRu1_DrawXlu, +}; + +ActorInit En_Ru1_InitVars = { + ACTOR_EN_RU1, + ACTORCAT_NPC, + FLAGS, + OBJECT_RU1, + sizeof(EnRu1), + (ActorFunc)EnRu1_Init, + (ActorFunc)EnRu1_Destroy, + (ActorFunc)EnRu1_Update, + (ActorFunc)EnRu1_Draw, +}; + +void func_80AEAC10(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[5]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void func_80AEAC54(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[5]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider2); + if (pthis->unk_34C != 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); + } else if (pthis->actor.xzDistToPlayer > 32.0f) { + pthis->unk_34C = 1; + } +} + +void func_80AEACDC(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[5]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider2); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider2.base); +} + +void func_80AEAD20(Actor* thisx, GlobalContext* globalCtx) { + EnRu1* pthis = (EnRu1*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit1); + + Collider_InitCylinder(globalCtx, &pthis->collider2); + Collider_SetCylinderType1(globalCtx, &pthis->collider2, &pthis->actor, &sCylinderInit2); +} + +void EnRu1_DestroyColliders(EnRu1* pthis, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider2); +} + +void func_80AEADD8(EnRu1* pthis) { + pthis->unk_34C = 0; +} + +u8 func_80AEADE0(EnRu1* pthis) { + u8 params = pthis->actor.params >> 8; + + return params; +} + +u8 func_80AEADF0(EnRu1* pthis) { + s16 params = pthis->actor.params; + + return params; +} + +void EnRu1_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRu1* pthis = (EnRu1*)thisx; + + EnRu1_DestroyColliders(pthis, globalCtx); +} + +void EnRu1_UpdateEyes(EnRu1* pthis) { + s32 pad[3]; + s16* blinkTimer = &pthis->blinkTimer; + s16* eyeIndex = &pthis->eyeIndex; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + + *eyeIndex = *blinkTimer; + if (*eyeIndex >= 3) { + *eyeIndex = 0; + } +} + +void EnRu1_SetEyeIndex(EnRu1* pthis, s16 eyeIndex) { + pthis->eyeIndex = eyeIndex; +} + +void EnRu1_SetMouthIndex(EnRu1* pthis, s16 mouthIndex) { + pthis->mouthIndex = mouthIndex; +} + +void func_80AEAECC(EnRu1* pthis, GlobalContext* globalCtx) { + f32* velocityY = &pthis->actor.velocity.y; + f32 velocityYHeld = *velocityY; + + *velocityY = -4.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 19.0f, 25.0f, 30.0f, 7); + *velocityY = velocityYHeld; +} + +s32 EnRu1_IsCsStateIdle(GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + return true; + } + return false; +} + +CsCmdActorAction* func_80AEAF58(GlobalContext* globalCtx, s32 npcActionIdx) { + s32 pad[2]; + CsCmdActorAction* ret = NULL; + + if (!EnRu1_IsCsStateIdle(globalCtx)) { + ret = globalCtx->csCtx.npcActions[npcActionIdx]; + } + return ret; +} + +s32 func_80AEAFA0(GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = func_80AEAF58(globalCtx, npcActionIdx); + + if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == action)) { + return true; + } + return false; +} + +s32 func_80AEAFE0(GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = func_80AEAF58(globalCtx, npcActionIdx); + + if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action != action)) { + return true; + } + return false; +} + +s32 func_80AEB020(EnRu1* pthis, GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; + EnRu1* someEnRu1; + + while (actorIt != NULL) { + if (actorIt->id == ACTOR_EN_RU1) { + someEnRu1 = (EnRu1*)actorIt; + if (someEnRu1 != pthis) { + if ((someEnRu1->action == 31) || (someEnRu1->action == 32) || (someEnRu1->action == 24)) { + return true; + } + } + } + actorIt = actorIt->next; + } + return false; +} + +BgBdanObjects* EnRu1_FindSwitch(GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_BG].head; + + while (actorIt != NULL) { + if (actorIt->id == ACTOR_BG_BDAN_OBJECTS && actorIt->params == 0) { + return (BgBdanObjects*)actorIt; + } + actorIt = actorIt->next; + } + // "There is no stand" + osSyncPrintf(VT_FGCOL(RED) "お立ち台が無い!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return NULL; +} + +void func_80AEB0EC(EnRu1* pthis, s32 cameraSetting) { + if (pthis->unk_28C != NULL) { + pthis->unk_28C->cameraSetting = cameraSetting; + } +} + +s32 func_80AEB104(EnRu1* pthis) { + if (pthis->unk_28C != NULL) { + return pthis->unk_28C->cameraSetting; + } else { + return 0; + } +} + +Actor* func_80AEB124(GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].head; + + while (actorIt != NULL) { + if ((actorIt->id == ACTOR_DEMO_EFFECT) && ((actorIt->params & 0xFF) == 0x15)) { + return actorIt; + } + actorIt = actorIt->next; + } + return NULL; +} + +s32 func_80AEB174(GlobalContext* globalCtx) { + return (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx); +} + +s32 func_80AEB1B4(GlobalContext* globalCtx) { + return Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING; +} + +void func_80AEB1D8(EnRu1* pthis) { + pthis->action = 36; + pthis->drawConfig = 0; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.velocity.z = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; + func_80AEB0EC(pthis, 0); +} + +void func_80AEB220(EnRu1* pthis, GlobalContext* globalCtx) { + if ((EnRu1_IsCsStateIdle(globalCtx)) && (pthis->actor.params == 0xA)) { + func_80AEB1D8(pthis); + } +} + +void func_80AEB264(EnRu1* pthis, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { + s32 pad[2]; + AnimationHeader* animHeader = SEGMENTED_TO_VIRTUAL(animation); + f32 frameCount = Animation_GetLastFrame(animHeader); + f32 playbackSpeed; + f32 unk0; + f32 fc; + + if (arg4 == 0) { + unk0 = 0.0f; + fc = frameCount; + playbackSpeed = 1.0f; + } else { + unk0 = frameCount; + fc = 0.0f; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animHeader, playbackSpeed, unk0, fc, arg2, transitionRate); +} + +s32 EnRu1_UpdateSkelAnime(EnRu1* pthis) { + // why? + if (pthis->action != 32) { + return SkelAnime_Update(&pthis->skelAnime); + } else { + return SkelAnime_Update(&pthis->skelAnime); + } +} + +void func_80AEB364(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 1; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_80AEB3A4(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 1; + func_80AEB364(pthis, globalCtx); +} + +void func_80AEB3CC(EnRu1* pthis) { + pthis->skelAnime.moveFlags &= ~0x1; +} + +void func_80AEB3DC(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB264(pthis, &gRutoChildWaitHandsBehindBackAnim, 0, 0, 0); + pthis->action = 0; + pthis->drawConfig = 1; + EnRu1_SetEyeIndex(pthis, 4); + EnRu1_SetMouthIndex(pthis, 0); +} + +CsCmdActorAction* func_80AEB438(GlobalContext* globalCtx) { + return func_80AEAF58(globalCtx, 3); +} + +s32 func_80AEB458(GlobalContext* globalCtx, u16 action) { + return func_80AEAFA0(globalCtx, action, 3); +} + +s32 func_80AEB480(GlobalContext* globalCtx, u16 action) { + return func_80AEAFE0(globalCtx, action, 3); +} + +void EnRu1_SpawnRipple(EnRu1* pthis, GlobalContext* globalCtx, s16 radiusMax, s16 life) { + Vec3f pos; + Actor* thisx = &pthis->actor; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + pos.z = pthis->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &pos, 100, radiusMax, life); +} + +void func_80AEB50C(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->unk_270 += 1.0f; + if (pthis->unk_270 >= kREG(3) + 10.0f) { + EnRu1_SpawnRipple(pthis, globalCtx, kREG(1) + 500, 0); + pthis->unk_270 = 0.0f; + } +} + +void func_80AEB59C(EnRu1* pthis, GlobalContext* globalCtx) { + EnRu1_SpawnRipple(pthis, globalCtx, kREG(2) + 500, 0); + EnRu1_SpawnRipple(pthis, globalCtx, kREG(2) + 500, kREG(3) + 10.0f); + EnRu1_SpawnRipple(pthis, globalCtx, kREG(2) + 500, (kREG(3) + 10.0f) * 2.0f); +} + +void EnRu1_SpawnSplash(EnRu1* pthis, GlobalContext* globalCtx) { + Vec3f pos; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + pos.z = pthis->actor.world.pos.z; + + EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 1, 0); +} + +void func_80AEB6E0(EnRu1* pthis, GlobalContext* globalCtx) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { + skelAnime->moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, skelAnime, 1.0f); + } +} + +void func_80AEB738(EnRu1* pthis, GlobalContext* globalCtx) { + SkelAnime* skelAnime = &pthis->skelAnime; + + skelAnime->baseTransl = skelAnime->jointTable[0]; + skelAnime->prevTransl = skelAnime->jointTable[0]; + if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { + skelAnime->moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, skelAnime, 1.0f); + } +} + +void func_80AEB7D0(EnRu1* pthis) { + pthis->skelAnime.moveFlags &= ~0x3; +} + +f32 func_80AEB7E0(CsCmdActorAction* csCmdNPCAction, GlobalContext* globalCtx) { + s32 csCtxFrames = globalCtx->csCtx.frames; + + if ((csCtxFrames < csCmdNPCAction->endFrame) && (csCmdNPCAction->endFrame - csCmdNPCAction->startFrame > 0)) { + return (Math_CosS(((csCtxFrames - csCmdNPCAction->startFrame) / + (f32)(csCmdNPCAction->endFrame - csCmdNPCAction->startFrame)) * + 32768.0f) * + -0.5f) + + 0.5f; + } + return 1.0f; +} + +f32 func_80AEB87C(f32 arg0, s32 arg1, s32 arg2) { + return (((f32)arg2 - arg1) * arg0) + arg1; +} + +void func_80AEB89C(EnRu1* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = func_80AEB438(globalCtx); + s16 npcActionRotY; + + if (npcAction != NULL) { + npcActionRotY = npcAction->rot.y; + pthis->actor.shape.rot.y = npcActionRotY; + pthis->actor.world.rot.y = npcActionRotY; + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + } +} + +void func_80AEB914(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB89C(pthis, globalCtx); +} + +void func_80AEB934(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB89C(pthis, globalCtx); +} + +void func_80AEB954(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB6E0(pthis, globalCtx); +} + +void func_80AEB974(EnRu1* pthis, GlobalContext* globalCtx) { + Vec3f* thisPos; + f32 sp30; + CsCmdActorAction* csCmdNPCAction = func_80AEB438(globalCtx); + s32 pad; + + if (csCmdNPCAction != NULL) { + sp30 = func_80AEB7E0(csCmdNPCAction, globalCtx); + thisPos = &pthis->actor.world.pos; + thisPos->x = func_80AEB87C(sp30, csCmdNPCAction->startPos.x, csCmdNPCAction->endPos.x); + thisPos->y = func_80AEB87C(sp30, csCmdNPCAction->startPos.y, csCmdNPCAction->endPos.y); + thisPos->z = func_80AEB87C(sp30, csCmdNPCAction->startPos.z, csCmdNPCAction->endPos.z); + } +} + +void func_80AEBA0C(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB6E0(pthis, globalCtx); +} + +void func_80AEBA2C(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f* unk_364 = &pthis->unk_364; + Vec3f* thisPos; + f32 temp_ret_2; + CsCmdActorAction* csCmdNPCAction = func_80AEB438(globalCtx); + s32 pad2; + + if (csCmdNPCAction != NULL) { + temp_ret_2 = func_80AEB7E0(csCmdNPCAction, globalCtx); + thisPos = &pthis->actor.world.pos; + thisPos->x = func_80AEB87C(temp_ret_2, unk_364->x, csCmdNPCAction->endPos.x); + thisPos->y = func_80AEB87C(temp_ret_2, unk_364->y, csCmdNPCAction->endPos.y); + thisPos->z = func_80AEB87C(temp_ret_2, unk_364->z, csCmdNPCAction->endPos.z); + } +} + +void func_80AEBAFC(EnRu1* pthis) { + if (pthis->unk_298 == 0) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_DIVE_INTO_WATER); + pthis->unk_298 = 1; + } +} + +void func_80AEBB3C(EnRu1* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_FACE_UP); + } +} + +void func_80AEBB78(EnRu1* pthis) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if (Animation_OnFrame(skelAnime, 4.0f) || Animation_OnFrame(skelAnime, 13.0f) || + Animation_OnFrame(skelAnime, 22.0f) || Animation_OnFrame(skelAnime, 31.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_SWIM); + } +} + +void func_80AEBBF4(EnRu1* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 8.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_SUBMERGE); + } +} + +void func_80AEBC30(GlobalContext* globalCtx) { + Player* player; + + if (globalCtx->csCtx.frames == 0xCD) { + player = GET_PLAYER(globalCtx); + Audio_PlaySoundGeneral(NA_SE_EV_DIVE_INTO_WATER, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void func_80AEBC84(EnRu1* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 0x82) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_LAUGH_0); + } +} + +void func_80AEBCB8(EnRu1* pthis, UNK_TYPE arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gRutoChildSwimOnBackAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildSwimOnBackAnim), ANIMMODE_LOOP, -8.0f); + } +} + +void func_80AEBD1C(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEB480(globalCtx, 2)) { + pthis->action = 1; + pthis->drawConfig = 0; + func_80AEB914(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + EnRu1_SpawnSplash(pthis, globalCtx); + func_80AEB59C(pthis, globalCtx); + } +} + +void func_80AEBD94(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + f32 frameCount; + + if (func_80AEB480(globalCtx, 3)) { + frameCount = Animation_GetLastFrame(&gRutoChildAnim_009060); + func_80AEB934(pthis, globalCtx); + func_80AEB738(pthis, globalCtx); + Animation_Change(&pthis->skelAnime, &gRutoChildAnim_009060, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + pthis->action = 2; + pthis->drawConfig = 1; + } +} + +void func_80AEBE3C(EnRu1* pthis, GlobalContext* globalCtx, s32 arg2) { + s32 pad[2]; + f32 frameCount; + + if (arg2 != 0) { + frameCount = Animation_GetLastFrame(&gRutoChildTreadWaterAnim); + func_80AEB7D0(pthis); + Animation_Change(&pthis->skelAnime, &gRutoChildTreadWaterAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); + pthis->action = 3; + } else { + func_80AEB954(pthis, globalCtx); + } +} + +void func_80AEBEC8(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + f32 frameCount; + + if (func_80AEB458(globalCtx, 6)) { + frameCount = Animation_GetLastFrame(&gRutoChildTransitionToSwimOnBackAnim); + func_80AEB738(pthis, globalCtx); + Animation_Change(&pthis->skelAnime, &gRutoChildTransitionToSwimOnBackAnim, 1.0f, 0, frameCount, ANIMMODE_ONCE, + -8.0f); + pthis->action = 4; + } +} + +void func_80AEBF60(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEB480(globalCtx, 6)) { + func_80AEB7D0(pthis); + pthis->action = 5; + pthis->unk_364 = pthis->actor.world.pos; + } else { + func_80AEBA0C(pthis, globalCtx); + } +} + +void func_80AEBFD8(EnRu1* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction = func_80AEB438(globalCtx); + f32 frameCount; + u16 csCtxFrames; + u16 endFrame; + + if (csCmdNPCAction != NULL) { + csCtxFrames = globalCtx->csCtx.frames; + endFrame = csCmdNPCAction->endFrame; + if (csCtxFrames >= endFrame - 2) { + frameCount = Animation_GetLastFrame(&gRutoChildTransitionFromSwimOnBackAnim); + Animation_Change(&pthis->skelAnime, &gRutoChildTransitionFromSwimOnBackAnim, 1.0, 0, frameCount, + ANIMMODE_ONCE, -8.0f); + pthis->action = 6; + } + } +} + +void func_80AEC070(EnRu1* pthis, GlobalContext* globalCtx, UNK_TYPE arg2) { + if ((func_80AEB458(globalCtx, 8)) && (arg2 != 0)) { + Actor_Kill(&pthis->actor); + } +} + +void func_80AEC0B4(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB89C(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + func_80AEBC84(pthis, globalCtx); + func_80AEBC30(globalCtx); + func_80AEBD1C(pthis, globalCtx); +} + +void func_80AEC100(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEBAFC(pthis); + func_80AEBD94(pthis, globalCtx); +} + +void func_80AEC130(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something = EnRu1_UpdateSkelAnime(pthis); + + func_80AEAECC(pthis, globalCtx); + func_80AEBB3C(pthis); + func_80AEBE3C(pthis, globalCtx, something); +} + +void func_80AEC17C(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB974(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + func_80AEB50C(pthis, globalCtx); + func_80AEBEC8(pthis, globalCtx); +} + +void func_80AEC1D4(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + something = EnRu1_UpdateSkelAnime(pthis); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateEyes(pthis); + func_80AEB50C(pthis, globalCtx); + func_80AEBCB8(pthis, something); + func_80AEBBF4(pthis); + func_80AEBF60(pthis, globalCtx); +} + +void func_80AEC244(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + something = EnRu1_UpdateSkelAnime(pthis); + func_80AEBA2C(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateEyes(pthis); + func_80AEB50C(pthis, globalCtx); + func_80AEBCB8(pthis, something); + func_80AEBB78(pthis); + func_80AEBFD8(pthis, globalCtx); +} + +void func_80AEC2C0(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + something = EnRu1_UpdateSkelAnime(pthis); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateEyes(pthis); + func_80AEB50C(pthis, globalCtx); + func_80AEC070(pthis, globalCtx, something); +} + +void func_80AEC320(EnRu1* pthis, GlobalContext* globalCtx) { + s8 actorRoom; + + if (!(gSaveContext.infTable[20] & 2)) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + pthis->action = 7; + EnRu1_SetMouthIndex(pthis, 1); + } else if ((gSaveContext.infTable[20] & 0x80) && !(gSaveContext.infTable[20] & 1) && + !(gSaveContext.infTable[20] & 0x20)) { + if (!func_80AEB020(pthis, globalCtx)) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + actorRoom = pthis->actor.room; + pthis->action = 22; + pthis->actor.room = -1; + pthis->drawConfig = 0; + pthis->roomNum1 = actorRoom; + pthis->roomNum3 = actorRoom; + pthis->roomNum2 = actorRoom; + } else { + Actor_Kill(&pthis->actor); + } + } else { + Actor_Kill(&pthis->actor); + } +} + +void func_80AEC40C(EnRu1* pthis) { + f32 unk_26C = pthis->unk_26C; + + if (unk_26C < 8.0f) { + pthis->actor.speedXZ = (((kREG(3) * 0.01f) + 2.7f) / 8.0f) * unk_26C; + } else { + pthis->actor.speedXZ = (kREG(3) * 0.01f) + 2.7f; + } + pthis->actor.velocity.y = -1.0f; + Actor_MoveForward(&pthis->actor); +} + +void func_80AEC4CC(EnRu1* pthis) { + pthis->actor.velocity.y = -1.0f; + Actor_MoveForward(&pthis->actor); +} + +void func_80AEC4F4(EnRu1* pthis) { + f32* speedXZ = &pthis->actor.speedXZ; + f32* unk_26C = &pthis->unk_26C; + + if (pthis->unk_26C < 8.0f) { + *unk_26C += 1.0f; + *speedXZ *= (8.0f - *unk_26C) / 8.0f; + pthis->actor.velocity.y = -*unk_26C * (((kREG(4) * 0.01f) + 13.0f) / 8.0f); + } else { + *speedXZ = 0.0f; + pthis->actor.velocity.y = -((kREG(4) * 0.01f) + 13.0f); + } + Actor_MoveForward(&pthis->actor); +} + +s32 func_80AEC5FC(EnRu1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 thisPosZ = pthis->actor.world.pos.z; + f32 playerPosZ = player->actor.world.pos.z; + + if ((playerPosZ - thisPosZ <= 265.0f) && (player->actor.world.pos.y >= pthis->actor.world.pos.y)) { + return true; + } + return false; +} + +void func_80AEC650(EnRu1* pthis) { + s32 pad[2]; + + if (pthis->unk_280 == 0) { + if (Animation_OnFrame(&pthis->skelAnime, 2.0f) || Animation_OnFrame(&pthis->skelAnime, 7.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_DIRT); + } + } +} + +void func_80AEC6B0(EnRu1* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_FALL_DOWN_DIRT); + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_FALL); +} + +void func_80AEC6E4(EnRu1* pthis, GlobalContext* globalCtx) { + if ((func_80AEAFA0(globalCtx, 4, 3)) && (pthis->unk_280 == 0)) { + Animation_Change(&pthis->skelAnime, &gRutoChildBringArmsUpAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildBringArmsUpAnim), ANIMMODE_ONCE, -8.0f); + pthis->unk_280 = 1; + func_80AEC6B0(pthis); + } +} + +void func_80AEC780(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if ((func_80AEC5FC(pthis, globalCtx)) && (!Gameplay_InCsMode(globalCtx)) && (!(player->stateFlags1 & 0x206000)) && + (player->actor.bgCheckFlags & 1)) { + + globalCtx->csCtx.segment = &D_80AF0880; + gSaveContext.cutsceneTrigger = 1; + player->linearVelocity = 0.0f; + pthis->action = 8; + } +} + +void func_80AEC81C(EnRu1* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction; + s16 newRotY; + + if (func_80AEAFE0(globalCtx, 1, 3)) { + csCmdNPCAction = globalCtx->csCtx.npcActions[3]; + pthis->actor.world.pos.x = csCmdNPCAction->startPos.x; + pthis->actor.world.pos.y = csCmdNPCAction->startPos.y; + pthis->actor.world.pos.z = csCmdNPCAction->startPos.z; + newRotY = csCmdNPCAction->rot.y; + pthis->actor.shape.rot.y = newRotY; + pthis->actor.world.rot.y = newRotY; + pthis->action = 9; + pthis->drawConfig = 1; + } +} + +void func_80AEC8B8(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEAFA0(globalCtx, 3, 3)) { + Animation_Change(&pthis->skelAnime, &gRutoChildTurnAroundAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildTurnAroundAnim), ANIMMODE_ONCE, -8.0f); + pthis->action = 10; + } +} + +void func_80AEC93C(EnRu1* pthis, UNK_TYPE arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gRutoChildWalkAnim, 1.0f, 0, Animation_GetLastFrame(&gRutoChildWalkAnim), + ANIMMODE_LOOP, -8.0f); + pthis->actor.world.rot.y += 0x8000; + pthis->action = 0xB; + pthis->unk_26C = 0.0f; + } +} + +void func_80AEC9C4(EnRu1* pthis) { + pthis->unk_26C += 1.0f; + if (pthis->unk_26C >= 8.0f) { + pthis->action = 12; + pthis->unk_26C = 0.0f; + pthis->actor.velocity.y = -1.0f; + } +} + +void func_80AECA18(EnRu1* pthis) { + if (!(pthis->actor.bgCheckFlags & 1)) { + pthis->action = 13; + pthis->unk_26C = 0.0f; + pthis->actor.velocity.y = 0.0f; + } +} + +void func_80AECA44(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEAFA0(globalCtx, 5, 3)) { + gSaveContext.infTable[20] |= 2; + pthis->action = 14; + } +} + +void func_80AECA94(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEC780(pthis, globalCtx); +} + +void func_80AECAB4(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEC81C(pthis, globalCtx); +} + +void func_80AECAD4(EnRu1* pthis, GlobalContext* globalCtx) { + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEC8B8(pthis, globalCtx); +} + +void func_80AECB18(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + something = EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEC93C(pthis, something); +} + +void func_80AECB60(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEC40C(pthis); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEC650(pthis); + func_80AEC9C4(pthis); +} + +void func_80AECBB8(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEC4CC(pthis); + func_80AEC6E4(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEC650(pthis); + func_80AECA18(pthis); +} + +void func_80AECC1C(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEC4F4(pthis); + func_80AEC6E4(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEC650(pthis); + func_80AECA44(pthis, globalCtx); +} + +void func_80AECC84(EnRu1* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + Actor_Kill(&pthis->actor); + } +} + +void func_80AECCB0(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f* pos; + s16 yawTowardsPlayer; + f32 spawnX; + f32 spawnY; + f32 spawnZ; + s32 pad2[2]; + + yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + pos = &pthis->actor.world.pos; + spawnX = ((kREG(1) + 12.0f) * Math_SinS(yawTowardsPlayer)) + pos->x; + spawnY = pos->y; + spawnZ = ((kREG(1) + 12.0f) * Math_CosS(yawTowardsPlayer)) + pos->z; + pthis->blueWarp = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, + spawnX, spawnY, spawnZ, 0, yawTowardsPlayer, 0, WARP_BLUE_RUTO); +} + +void func_80AECDA0(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB264(pthis, &gRutoChildWaitHandsOnHipsAnim, 0, 0, 0); + pthis->action = 15; + pthis->actor.shape.yOffset = -10000.0f; + EnRu1_SetEyeIndex(pthis, 5); + EnRu1_SetMouthIndex(pthis, 2); +} + +void func_80AECE04(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.yOffset += (250.0f / 3.0f); +} + +void func_80AECE20(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad2; + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + s16 shapeRotY = player->actor.shape.rot.y; + s32 pad; + f32 unk_27C = pthis->unk_27C; + Vec3f* pos = &pthis->actor.world.pos; + + pos->x = (Math_SinS(shapeRotY) * unk_27C) + playerPos->x; + pos->y = playerPos->y; + pos->z = (Math_CosS(shapeRotY) * unk_27C) + playerPos->z; +} + +void func_80AECEB4(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f* player_unk_450 = &player->unk_450; + Vec3f* pos = &pthis->actor.world.pos; + s16 shapeRotY = pthis->actor.shape.rot.y; + + player_unk_450->x = ((kREG(2) + 30.0f) * Math_SinS(shapeRotY)) + pos->x; + player_unk_450->z = ((kREG(2) + 30.0f) * Math_CosS(shapeRotY)) + pos->z; +} + +s32 func_80AECF6C(EnRu1* pthis, GlobalContext* globalCtx) { + s16* shapeRotY; + Player* player = GET_PLAYER(globalCtx); + Player* otherPlayer; + s16 temp_f16; + f32 temp1; + f32 temp2; + s32 pad2[5]; + + pthis->unk_26C += 1.0f; + if ((player->actor.speedXZ == 0.0f) && (pthis->unk_26C >= 3.0f)) { + otherPlayer = GET_PLAYER(globalCtx); + player->actor.world.pos.x = otherPlayer->unk_450.x; + player->actor.world.pos.y = otherPlayer->unk_450.y; + player->actor.world.pos.z = otherPlayer->unk_450.z; + shapeRotY = &player->actor.shape.rot.y; + temp1 = pthis->actor.world.pos.x - player->actor.world.pos.x; + temp2 = pthis->actor.world.pos.z - player->actor.world.pos.z; + temp_f16 = Math_FAtan2F(temp1, temp2) * (0x8000 / M_PI); + if (*shapeRotY != temp_f16) { + Math_SmoothStepToS(shapeRotY, temp_f16, 0x14, 0x1838, 0x64); + player->actor.world.rot.y = *shapeRotY; + } else { + return true; + } + } + return false; +} + +s32 func_80AED084(EnRu1* pthis, s32 state) { + if (pthis->blueWarp != NULL && pthis->blueWarp->rutoWarpState == state) { + return true; + } + return false; +} + +void func_80AED0B0(EnRu1* pthis, s32 state) { + if (pthis->blueWarp != NULL) { + pthis->blueWarp->rutoWarpState = state; + } +} + +void func_80AED0C8(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->action = 16; +} + +void func_80AED0D8(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->action = 17; + pthis->drawConfig = 1; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + func_80AECCB0(pthis, globalCtx); +} + +void func_80AED110(EnRu1* pthis) { + if (pthis->actor.shape.yOffset >= 0.0f) { + pthis->action = 18; + pthis->actor.shape.yOffset = 0.0f; + func_80AED0B0(pthis, WARP_BLUE_RUTO_STATE_READY); + } +} + +void func_80AED154(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AED084(pthis, WARP_BLUE_RUTO_STATE_ENTERED)) { + pthis->action = 0x13; + pthis->unk_26C = 0.0f; + func_80AECEB4(pthis, globalCtx); + } +} + +void func_80AED19C(EnRu1* pthis, s32 cond) { + if (cond) { + Animation_Change(&pthis->skelAnime, &gRutoChildTransitionHandsOnHipToCrossArmsAndLegsAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildTransitionHandsOnHipToCrossArmsAndLegsAnim), ANIMMODE_ONCE, + -8.0f); + pthis->action = 20; + func_80AED0B0(pthis, WARP_BLUE_RUTO_STATE_3); + } +} + +void func_80AED218(EnRu1* pthis, UNK_TYPE arg1) { + if (func_80AED084(pthis, WARP_BLUE_RUTO_STATE_TALKING)) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gRutoChildWaitSittingAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildWaitSittingAnim), ANIMMODE_LOOP, -8.0f); + } + } else if (func_80AED084(pthis, WARP_BLUE_RUTO_STATE_WARPING)) { + Animation_Change(&pthis->skelAnime, &gRutoChildWaitInBlueWarpAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildWaitInBlueWarpAnim), ANIMMODE_ONCE, -8.0f); + pthis->action = 21; + pthis->unk_27C = pthis->actor.xzDistToPlayer; + } +} + +void func_80AED304(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED0C8(pthis, globalCtx); +} + +void func_80AED324(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED0D8(pthis, globalCtx); +} + +void func_80AED344(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AECE04(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + func_80AED110(pthis); +} + +void func_80AED374(EnRu1* pthis, GlobalContext* globalCtx) { + EnRu1_UpdateSkelAnime(pthis); + func_80AED154(pthis, globalCtx); +} + +void func_80AED3A4(EnRu1* pthis, GlobalContext* globalCtx) { + EnRu1_UpdateSkelAnime(pthis); + func_80AED19C(pthis, func_80AECF6C(pthis, globalCtx)); +} + +void func_80AED3E0(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEAECC(pthis, globalCtx); + func_80AED218(pthis, EnRu1_UpdateSkelAnime(pthis)); +} + +void func_80AED414(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AECE20(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); +} + +void func_80AED44C(EnRu1* pthis, GlobalContext* globalCtx) { + s8 actorRoom; + + if ((gSaveContext.infTable[20] & 2) && !(gSaveContext.infTable[20] & 0x20) && !(gSaveContext.infTable[20] & 1) && + !(gSaveContext.infTable[20] & 0x80)) { + if (!func_80AEB020(pthis, globalCtx)) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + actorRoom = pthis->actor.room; + pthis->action = 22; + pthis->actor.room = -1; + pthis->roomNum1 = actorRoom; + pthis->roomNum3 = actorRoom; + pthis->roomNum2 = actorRoom; + } else { + Actor_Kill(&pthis->actor); + } + } else { + Actor_Kill(&pthis->actor); + } +} + +void func_80AED4FC(EnRu1* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_LAND_DIRT); +} + +void func_80AED520(EnRu1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Audio_PlaySoundGeneral(NA_SE_PL_PULL_UP_RUTO, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_LIFT); +} + +void func_80AED57C(EnRu1* pthis) { + if (pthis->actor.speedXZ != 0.0f) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_THROW); + } +} + +void func_80AED5B8(EnRu1* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_CRASH); +} + +void func_80AED5DC(EnRu1* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_UNBALLANCE); +} + +void func_80AED600(EnRu1* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_DISCOVER); +} + +s32 func_80AED624(EnRu1* pthis, GlobalContext* globalCtx) { + s8 curRoomNum = globalCtx->roomCtx.curRoom.num; + + if (pthis->roomNum2 != curRoomNum) { + Actor_Kill(&pthis->actor); + return false; + } else if (((pthis->roomNum1 != curRoomNum) || (pthis->roomNum2 != curRoomNum)) && + (pthis->actor.yDistToWater > kREG(16) + 50.0f) && (pthis->action != 33)) { + pthis->action = 33; + pthis->drawConfig = 2; + pthis->alpha = 0xFF; + pthis->unk_2A4 = 0.0f; + } + return true; +} + +void func_80AED6DC(EnRu1* pthis, GlobalContext* globalCtx) { + s8 curRoomNum = globalCtx->roomCtx.curRoom.num; + + pthis->roomNum2 = curRoomNum; + pthis->unk_288 = 0.0f; +} + +void func_80AED6F8(GlobalContext* globalCtx) { + s8 curRoomNum; + + if ((!(gSaveContext.infTable[20] & 0x80))) { + curRoomNum = globalCtx->roomCtx.curRoom.num; + if (curRoomNum == 2) { + gSaveContext.infTable[20] |= 0x80; + } + } +} + +void func_80AED738(EnRu1* pthis, GlobalContext* globalCtx) { + u32 temp_v0; + + if (func_80AED624(pthis, globalCtx)) { + pthis->unk_2A4 += 1.0f; + if (pthis->unk_2A4 < 20.0f) { + temp_v0 = ((20.0f - pthis->unk_2A4) * 255.0f) / 20.0f; + pthis->alpha = temp_v0; + pthis->actor.shape.shadowAlpha = temp_v0; + } else { + Actor_Kill(&pthis->actor); + } + } +} + +void func_80AED83C(EnRu1* pthis) { + s32 pad[2]; + Vec3s* tempPtr; + Vec3s* tempPtr2; + + tempPtr = &pthis->unk_374.unk_08; + Math_SmoothStepToS(&tempPtr->x, 0, 0x14, 0x1838, 0x64); + Math_SmoothStepToS(&tempPtr->y, 0, 0x14, 0x1838, 0x64); + tempPtr2 = &pthis->unk_374.unk_0E; + Math_SmoothStepToS(&tempPtr2->x, 0, 0x14, 0x1838, 0x64); + Math_SmoothStepToS(&tempPtr2->y, 0, 0x14, 0x1838, 0x64); +} + +void func_80AED8DC(EnRu1* pthis) { + s32 temp_hi; + s16* unk_2AC = &pthis->unk_2AC; + s16* someY = &pthis->unk_374.unk_08.y; + s16* unk_29E = &pthis->unk_29E; + s32 pad[2]; + + if (DECR(*unk_2AC) == 0) { + *unk_2AC = Rand_S16Offset(0xA, 0x19); + temp_hi = *unk_2AC % 5; + if (temp_hi == 0) { + pthis->unk_2B0 = 1; + } else if (temp_hi == 1) { + pthis->unk_2B0 = 2; + } else { + pthis->unk_2B0 = 0; + } + *unk_29E = 0; + } + + if (pthis->unk_2B0 == 0) { + Math_SmoothStepToS(unk_29E, 0 - *someY, 1, 0x190, 0x190); + Math_SmoothStepToS(someY, 0, 3, ABS(*unk_29E), 0x64); + } else if (pthis->unk_2B0 == 1) { + Math_SmoothStepToS(unk_29E, -0x2AAA - *someY, 1, 0x190, 0x190); + Math_SmoothStepToS(someY, -0x2AAA, 3, ABS(*unk_29E), 0x64); + } else { + Math_SmoothStepToS(unk_29E, 0x2AAA - *someY, 1, 0x190, 0x190); + Math_SmoothStepToS(someY, 0x2AAA, 3, ABS(*unk_29E), 0x64); + } +} + +void func_80AEDAE0(EnRu1* pthis, GlobalContext* globalCtx) { + DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.floorBgId); + + if (dynaPolyActor == NULL || dynaPolyActor->actor.id == ACTOR_EN_BOX) { + pthis->actor.bgCheckFlags &= ~0x19; + } +} + +void func_80AEDB30(EnRu1* pthis, GlobalContext* globalCtx) { + DynaPolyActor* dynaPolyActor; + f32* velocityY; + f32* speedXZ; + f32* gravity; + s16 wallYaw; + s16 rotY; + s32 temp_a1_2; + s32 temp_a0; + s32 phi_v1; + + if (pthis->actor.bgCheckFlags & 1) { + velocityY = &pthis->actor.velocity.y; + dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.floorBgId); + if (*velocityY <= 0.0f) { + speedXZ = &pthis->actor.speedXZ; + if (dynaPolyActor != NULL) { + if (dynaPolyActor->actor.id != ACTOR_EN_BOX) { + *speedXZ = 0.0f; + } + } else { + if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { + *speedXZ *= (kREG(19) * 0.01f) + 0.8f; + } else { + *speedXZ = 0.0f; + } + } + gravity = &pthis->actor.gravity; + if (dynaPolyActor != NULL) { + if (dynaPolyActor->actor.id != ACTOR_EN_BOX) { + *velocityY = 0.0f; + pthis->actor.minVelocityY = 0.0f; + *gravity = 0.0f; + } else { + *velocityY *= -1.0f; + } + } else { + *velocityY *= -((kREG(20) * 0.01f) + 0.6f); + if (*velocityY <= -*gravity * ((kREG(20) * 0.01f) + 0.6f)) { + *velocityY = 0.0f; + pthis->actor.minVelocityY = 0.0f; + *gravity = 0.0f; + } + } + func_80AED4FC(pthis); + } + } + if (pthis->actor.bgCheckFlags & 0x10) { + speedXZ = &pthis->actor.speedXZ; + velocityY = &pthis->actor.velocity.y; + if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { + *speedXZ *= (kREG(19) * 0.01f) + 0.8f; + } else { + *speedXZ = 0.0f; + } + if (*velocityY >= 0.0f) { + *velocityY *= -((kREG(20) * 0.01f) + 0.6f); + func_80AED4FC(pthis); + } + } + if (pthis->actor.bgCheckFlags & 8) { + speedXZ = &pthis->actor.speedXZ; + if (*speedXZ != 0.0f) { + rotY = pthis->actor.world.rot.y; + wallYaw = pthis->actor.wallYaw; + temp_a0 = (wallYaw * 2) - rotY; + temp_a1_2 = temp_a0 + 0x8000; + if ((s16)((temp_a0 - wallYaw) + 0x8000) >= 0) { + phi_v1 = (s16)(temp_a1_2 - wallYaw); + } else { + phi_v1 = -(s16)(temp_a1_2 - wallYaw); + } + if (phi_v1 < 0x4001) { + if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { + *speedXZ *= (kREG(21) * 0.01f) + 0.6f; + } else { + *speedXZ = 0.0f; + } + pthis->actor.world.rot.y = temp_a1_2; + func_80AED4FC(pthis); + func_80AED5B8(pthis); + } + } + } +} + +void func_80AEDEF4(EnRu1* pthis, GlobalContext* globalCtx) { + f32* speedXZ = &pthis->actor.speedXZ; + DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.floorBgId); + + if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_EN_BOX) { + if (*speedXZ != 0.0f) { + *speedXZ *= 1.1f; + } else { + *speedXZ = 1.0f; + } + } + if (*speedXZ >= (kREG(27) * 0.01f) + 3.0f) { + *speedXZ *= (kREG(22) * 0.01f) + 0.98f; + } else { + *speedXZ = 0.0f; + } +} + +void func_80AEDFF4(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEDB30(pthis, globalCtx); + func_80AEDEF4(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); +} + +void func_80AEE02C(EnRu1* pthis) { + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.velocity.z = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY = 0.0f; +} + +void func_80AEE050(EnRu1* pthis) { + s32 pad; + f32 sp28; + f32 sp24; + f32 temp_f10; + EnRu1* thisx = pthis; // necessary to match + + if (pthis->unk_350 == 0) { + if ((pthis->actor.minVelocityY == 0.0f) && (pthis->actor.speedXZ == 0.0f)) { + pthis->unk_350 = 1; + func_80AEE02C(pthis); + pthis->unk_35C = 0; + pthis->unk_358 = (pthis->actor.yDistToWater - 10.0f) * 0.5f; + pthis->unk_354 = pthis->actor.world.pos.y + thisx->unk_358; // thisx only used here + } else { + pthis->actor.gravity = 0.0f; + pthis->actor.minVelocityY *= 0.2f; + pthis->actor.velocity.y *= 0.2f; + if (pthis->actor.minVelocityY >= -0.1f) { + pthis->actor.minVelocityY = 0.0f; + pthis->actor.velocity.y = 0.0f; + } + pthis->actor.speedXZ *= 0.5f; + if (pthis->actor.speedXZ <= 0.1f) { + pthis->actor.speedXZ = 0.0f; + } + pthis->actor.velocity.x = Math_SinS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.velocity.z = Math_CosS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + func_8002D7EC(&pthis->actor); + } + } else { + if (pthis->unk_350 == 1) { + if (pthis->unk_358 <= 1.0f) { + func_80AEE02C(pthis); + pthis->unk_350 = 2; + pthis->unk_360 = 0.0f; + } else { + sp28 = pthis->unk_358; + sp24 = pthis->unk_354; + temp_f10 = Math_CosS(pthis->unk_35C) * -sp28; + pthis->actor.world.pos.y = temp_f10 + sp24; + pthis->unk_35C += 0x3E8; + pthis->unk_358 *= 0.95f; + } + } else { + pthis->unk_360 += 1.0f; + if (pthis->unk_360 > 0.0f) { + pthis->unk_350 = 3; + } + } + } +} + +s32 func_80AEE264(EnRu1* pthis, GlobalContext* globalCtx) { + if (!Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + if ((gSaveContext.infTable[20] & 8)) { + pthis->actor.textId = 0x404E; + func_8002F2F4(&pthis->actor, globalCtx); + } else if (gSaveContext.infTable[20] & 4) { + pthis->actor.textId = 0x404D; + func_8002F2F4(&pthis->actor, globalCtx); + } else { + pthis->actor.textId = 0x404C; + func_8002F2F4(&pthis->actor, globalCtx); + } + return false; + } + return true; +} + +void func_80AEE2F8(EnRu1* pthis, GlobalContext* globalCtx) { + DynaPolyActor* dynaPolyActor; + s32 floorBgId; + + if ((pthis->actor.bgCheckFlags & 1) && (pthis->actor.floorBgId != BGCHECK_SCENE)) { + floorBgId = pthis->actor.floorBgId; + dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, floorBgId); + if ((dynaPolyActor != NULL) && (dynaPolyActor->actor.id == ACTOR_BG_BDAN_SWITCH)) { + if (((dynaPolyActor->actor.params >> 8) & 0x3F) == 0x38) { + gSaveContext.infTable[20] |= 1; + return; + } + } + } + gSaveContext.infTable[20] &= ~0x1; +} + +s32 func_80AEE394(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + CollisionContext* colCtx; + DynaPolyActor* dynaPolyActor; + s32 floorBgId; + + if ((pthis->actor.bgCheckFlags & 1) && pthis->actor.floorBgId != BGCHECK_SCENE) { + colCtx = &globalCtx->colCtx; + floorBgId = pthis->actor.floorBgId; // necessary match, can't move pthis out of pthis block unfortunately + dynaPolyActor = DynaPoly_GetActor(colCtx, floorBgId); + if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_BG_BDAN_OBJECTS && + dynaPolyActor->actor.params == 0 && !Player_InCsMode(globalCtx) && globalCtx->msgCtx.msgLength == 0) { + func_80AEE02C(pthis); + globalCtx->csCtx.segment = &D_80AF10A4; + gSaveContext.cutsceneTrigger = 1; + pthis->action = 36; + pthis->drawConfig = 0; + pthis->unk_28C = (BgBdanObjects*)dynaPolyActor; + pthis->actor.shape.shadowAlpha = 0; + return true; + } + } + return false; +} + +void func_80AEE488(EnRu1* pthis, GlobalContext* globalCtx) { + s8 curRoomNum; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + curRoomNum = globalCtx->roomCtx.curRoom.num; + pthis->roomNum3 = curRoomNum; + pthis->action = 31; + func_80AED520(pthis, globalCtx); + } else if ((!func_80AEE394(pthis, globalCtx)) && (!(pthis->actor.bgCheckFlags & 1))) { + pthis->actor.minVelocityY = -((kREG(24) * 0.01f) + 6.8f); + pthis->actor.gravity = -((kREG(23) * 0.01f) + 1.3f); + pthis->action = 28; + } +} + +void func_80AEE568(EnRu1* pthis, GlobalContext* globalCtx) { + if (!func_80AEE394(pthis, globalCtx)) { + if ((pthis->actor.bgCheckFlags & 1) && (pthis->actor.speedXZ == 0.0f) && (pthis->actor.minVelocityY == 0.0f)) { + func_80AEE02C(pthis); + func_8002F580(&pthis->actor, globalCtx); + pthis->action = 27; + func_80AEADD8(pthis); + } else if (pthis->actor.yDistToWater > 0.0f) { + pthis->action = 29; + pthis->unk_350 = 0; + } + } +} + +void func_80AEE628(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s8 curRoomNum = globalCtx->roomCtx.curRoom.num; + + if (EnRu1_IsCsStateIdle(globalCtx)) { + Animation_Change(&pthis->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildSittingAnim), ANIMMODE_LOOP, -8.0f); + gSaveContext.infTable[20] |= 0x10; + pthis->action = 31; + } + pthis->roomNum3 = curRoomNum; +} + +s32 func_80AEE6D0(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad; + s8 curRoomNum = globalCtx->roomCtx.curRoom.num; + + if (!(gSaveContext.infTable[20] & 0x10) && (func_80AEB124(globalCtx) != 0)) { + if (!Player_InCsMode(globalCtx)) { + Animation_Change(&pthis->skelAnime, &gRutoChildSeesSapphireAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildSquirmAnim), ANIMMODE_LOOP, -8.0f); + func_80AED600(pthis); + pthis->action = 34; + pthis->unk_26C = 0.0f; + globalCtx->csCtx.segment = &D_80AF1728; + gSaveContext.cutsceneTrigger = 1; + } + pthis->roomNum3 = curRoomNum; + return true; + } + pthis->roomNum3 = curRoomNum; + return false; +} + +void func_80AEE7C4(EnRu1* pthis, GlobalContext* globalCtx) { + f32 frameCount; + s32 pad[13]; + Player* player; + f32* unk_370 = &pthis->unk_370; + + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + frameCount = Animation_GetLastFrame(&gRutoChildSittingAnim); + Animation_Change(&pthis->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); + func_80AED6DC(pthis, globalCtx); + pthis->actor.speedXZ *= (kREG(25) * 0.01f) + 1.0f; + pthis->actor.velocity.y *= (kREG(26) * 0.01f) + 1.0f; + pthis->actor.minVelocityY = -((kREG(24) * 0.01f) + 6.8f); + pthis->actor.gravity = -((kREG(23) * 0.01f) + 1.3f); + func_80AED57C(pthis); + pthis->action = 28; + *unk_370 = 0.0f; + return; + } + + if (func_80AEE6D0(pthis, globalCtx)) { + *unk_370 = 0.0f; + return; + } + + player = GET_PLAYER(globalCtx); + if (player->stateFlags2 & 0x10000000) { + pthis->unk_370 += 1.0f; + if (pthis->action != 32) { + if (*unk_370 > 30.0f) { + if (Rand_S16Offset(0, 3) == 0) { + frameCount = Animation_GetLastFrame(&gRutoChildSquirmAnim); + Animation_Change(&pthis->skelAnime, &gRutoChildSquirmAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, + -8.0f); + func_80AED5DC(pthis); + pthis->action = 32; + } + *unk_370 = 0.0f; + } + } else { + if (*unk_370 > 50.0f) { + frameCount = Animation_GetLastFrame(&gRutoChildSittingAnim); + Animation_Change(&pthis->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); + pthis->action = 31; + *unk_370 = 0.0f; + } + } + } else { + frameCount = Animation_GetLastFrame(&gRutoChildSittingAnim); + Animation_Change(&pthis->skelAnime, &gRutoChildSittingAnim, 1.0f, 0, frameCount, ANIMMODE_LOOP, -8.0f); + *unk_370 = 0.0f; + } +} + +s32 func_80AEEAC8(EnRu1* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 1) { + func_80AEE02C(pthis); + func_8002F580(&pthis->actor, globalCtx); + pthis->action = 27; + func_80AEADD8(pthis); + return true; + } + return false; +} + +void func_80AEEB24(EnRu1* pthis, GlobalContext* globalCtx) { + if ((func_80AEEAC8(pthis, globalCtx) == 0) && (pthis->unk_350 == 3)) { + pthis->action = 30; + func_80AEE02C(pthis); + pthis->actor.gravity = -0.1f; + pthis->actor.minVelocityY = -((kREG(18) * 0.1f) + 0.7f); + } +} + +void func_80AEEBB4(EnRu1* pthis, GlobalContext* globalCtx) { + func_8002F580(&pthis->actor, globalCtx); +} + +void func_80AEEBD4(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAC54(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEEBB4(pthis, globalCtx); + func_80AEE488(pthis, globalCtx); + func_80AED624(pthis, globalCtx); + func_80AEDAE0(pthis, globalCtx); +} + +void func_80AEEC5C(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEACDC(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + func_80AEE2F8(pthis, globalCtx); + func_80AEDFF4(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEE568(pthis, globalCtx); + func_80AED624(pthis, globalCtx); + func_80AEDAE0(pthis, globalCtx); +} + +void func_80AEECF0(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEE050(pthis); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEEB24(pthis, globalCtx); + func_80AED624(pthis, globalCtx); +} + +void func_80AEED58(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEEAC8(pthis, globalCtx); + func_80AED624(pthis, globalCtx); + func_80AEDAE0(pthis, globalCtx); +} + +void func_80AEEDCC(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED8DC(pthis); + EnRu1_UpdateSkelAnime(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEE2F8(pthis, globalCtx); + EnRu1_UpdateEyes(pthis); + func_80AED6F8(globalCtx); + func_80AEE7C4(pthis, globalCtx); +} + +void func_80AEEE34(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + EnRu1_UpdateSkelAnime(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEE2F8(pthis, globalCtx); + EnRu1_UpdateEyes(pthis); + func_80AED6F8(globalCtx); + func_80AEE7C4(pthis, globalCtx); +} + +void func_80AEEE9C(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEDFF4(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AED738(pthis, globalCtx); + func_80AED624(pthis, globalCtx); +} + +void func_80AEEF08(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + EnRu1_UpdateSkelAnime(pthis); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateEyes(pthis); + func_80AEE628(pthis, globalCtx); +} + +void func_80AEEF5C(EnRu1* pthis, GlobalContext* globalCtx) { +} + +void func_80AEEF68(EnRu1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 something; + + pthis->unk_374.unk_18 = player->actor.world.pos; + pthis->unk_374.unk_14 = kREG(16) - 3.0f; + something = kREG(17) + 0xC; + func_80034A14(&pthis->actor, &pthis->unk_374, something, 2); +} + +void func_80AEEFEC(EnRu1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 something; + + pthis->unk_374.unk_18 = player->actor.world.pos; + pthis->unk_374.unk_14 = kREG(16) - 3.0f; + something = kREG(17) + 0xC; + func_80034A14(&pthis->actor, &pthis->unk_374, something, 4); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; +} + +void func_80AEF080(EnRu1* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 11.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_LAND_DIRT); + } +} + +s32 func_80AEF0BC(EnRu1* pthis, GlobalContext* globalCtx) { + s32 frameCount; + + if (gSaveContext.infTable[20] & 4) { + frameCount = Animation_GetLastFrame(&gRutoChildSitAnim); + Animation_Change(&pthis->skelAnime, &gRutoChildSitAnim, 1.0f, 0, frameCount, ANIMMODE_ONCE, -8.0f); + globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; + pthis->action = 26; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + return true; + } + return false; +} + +void func_80AEF170(EnRu1* pthis, GlobalContext* globalCtx, s32 cond) { + if (cond) { + pthis->action = 25; + } +} + +void func_80AEF188(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEB174(globalCtx) && !func_80AEF0BC(pthis, globalCtx)) { + Message_CloseTextbox(globalCtx); + gSaveContext.infTable[20] |= 4; + pthis->action = 24; + } +} + +void func_80AEF1F0(EnRu1* pthis, GlobalContext* globalCtx, UNK_TYPE arg2) { + if (arg2 != 0) { + Animation_Change(&pthis->skelAnime, &gRutoChildSittingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gRutoChildSittingAnim), ANIMMODE_LOOP, 0.0f); + Message_CloseTextbox(globalCtx); + gSaveContext.infTable[20] |= 8; + func_80AED6DC(pthis, globalCtx); + func_8002F580(&pthis->actor, globalCtx); + pthis->action = 27; + func_80AEADD8(pthis); + } +} + +void func_80AEF29C(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->action = 23; +} + +void func_80AEF2AC(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->action = 24; + pthis->drawConfig = 1; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; +} + +void func_80AEF2D0(EnRu1* pthis, GlobalContext* globalCtx) { + s32 cond; + + func_80AEEF68(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAC10(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + cond = func_80AEE264(pthis, globalCtx); + func_80AED624(pthis, globalCtx); + func_80AEF170(pthis, globalCtx, cond); +} + +void func_80AEF354(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEEFEC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEF188(pthis, globalCtx); +} + +void func_80AEF3A8(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80AED83C(pthis); + something = EnRu1_UpdateSkelAnime(pthis); + func_80AEF080(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEF1F0(pthis, globalCtx, something); +} + +void func_80AEF40C(EnRu1* pthis) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if (Animation_OnFrame(skelAnime, 2.0f) || Animation_OnFrame(skelAnime, 7.0f) || + Animation_OnFrame(skelAnime, 12.0f) || Animation_OnFrame(skelAnime, 18.0f) || + Animation_OnFrame(skelAnime, 25.0f) || Animation_OnFrame(skelAnime, 33.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_DIRT); + } +} + +void func_80AEF4A8(EnRu1* pthis, GlobalContext* globalCtx) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.projectedPos, 20, NA_SE_VO_RT_FALL); +} + +void func_80AEF4E0(EnRu1* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 5.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_LAUGH_0); + } +} + +void func_80AEF51C(EnRu1* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_RT_THROW); +} + +void func_80AEF540(EnRu1* pthis) { + if (func_80AEB104(pthis) == 2) { + EnRu1_SetEyeIndex(pthis, 3); + EnRu1_SetMouthIndex(pthis, 2); + if (pthis->skelAnime.mode != 2) { + func_80AEB264(pthis, &gRutoChildShutterAnim, 2, -8.0f, 0); + func_80AEF51C(pthis); + } + } +} + +void func_80AEF5B8(EnRu1* pthis) { + f32 curFrame; + + if (D_80AF1938 == 0) { + curFrame = pthis->skelAnime.curFrame; + if (curFrame >= 60.0f) { + EnRu1_SetEyeIndex(pthis, 3); + EnRu1_SetMouthIndex(pthis, 0); + func_80AED57C(pthis); + D_80AF1938 = 1; + } + } +} + +void func_80AEF624(EnRu1* pthis, GlobalContext* globalCtx) { + f32 frameCount; + CsCmdActorAction* csCmdNPCAction; + CsCmdActorAction* csCmdNPCAction2; + s16 newRotTmp; + + if (func_80AEAFE0(globalCtx, 1, 3)) { + frameCount = Animation_GetLastFrame(&gRutoChildWalkToAndHoldUpSapphireAnim); + // pthis weird part with the redundant variable is necessary to match for some reason + csCmdNPCAction2 = globalCtx->csCtx.npcActions[3]; + csCmdNPCAction = csCmdNPCAction2; + pthis->actor.world.pos.x = csCmdNPCAction->startPos.x; + pthis->actor.world.pos.y = csCmdNPCAction->startPos.y; + pthis->actor.world.pos.z = csCmdNPCAction->startPos.z; + newRotTmp = csCmdNPCAction->rot.x; + pthis->actor.shape.rot.x = newRotTmp; + pthis->actor.world.rot.x = newRotTmp; + newRotTmp = csCmdNPCAction->rot.y; + pthis->actor.shape.rot.y = newRotTmp; + pthis->actor.world.rot.y = newRotTmp; + newRotTmp = csCmdNPCAction->rot.z; + pthis->actor.shape.rot.z = newRotTmp; + pthis->actor.world.rot.z = newRotTmp; + Animation_Change(&pthis->skelAnime, &gRutoChildWalkToAndHoldUpSapphireAnim, 1.0f, 0.0f, frameCount, + ANIMMODE_ONCE, 0.0f); + func_80AEB3A4(pthis, globalCtx); + pthis->action = 37; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80AEF728(EnRu1* pthis, UNK_TYPE arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gRutoChildHoldArmsUpAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gRutoChildHoldArmsUpAnim), ANIMMODE_LOOP, 0.0f); + func_80AEB3CC(pthis); + pthis->action = 38; + } +} + +void func_80AEF79C(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEAFE0(globalCtx, 2, 3)) { + Animation_Change(&pthis->skelAnime, &gRutoChildBringHandsDownAnim, 1.0f, 0, + Animation_GetLastFrame(&gRutoChildBringHandsDownAnim), ANIMMODE_ONCE, -8.0f); + pthis->action = 39; + } +} + +void func_80AEF820(EnRu1* pthis, UNK_TYPE arg1) { + if (arg1 != 0) { + Animation_Change(&pthis->skelAnime, &gRutoChildWait2Anim, 1.0f, 0, Animation_GetLastFrame(&gRutoChildWait2Anim), + ANIMMODE_LOOP, -8.0f); + pthis->action = 40; + } +} + +void func_80AEF890(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s8 curRoomNum; + + if ((gSaveContext.sceneSetupIndex < 4) && (EnRu1_IsCsStateIdle(globalCtx))) { + curRoomNum = globalCtx->roomCtx.curRoom.num; + gSaveContext.infTable[20] |= 0x20; + Flags_SetSwitch(globalCtx, func_80AEADE0(pthis)); + func_80AEB0EC(pthis, 1); + pthis->action = 42; + pthis->actor.room = curRoomNum; + } +} + +void func_80AEF930(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEB104(pthis) == 3) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.textId = 0x4048; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + func_80AEF4A8(pthis, globalCtx); + pthis->action = 43; + pthis->drawConfig = 0; + } +} + +void func_80AEF99C(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEB1B4(globalCtx) != 0) { + func_80AEB0EC(pthis, 4); + Actor_Kill(&pthis->actor); + } +} + +void func_80AEF9D8(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEF624(pthis, globalCtx); + func_80AEB220(pthis, globalCtx); +} + +void func_80AEFA2C(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80AED83C(pthis); + func_80AEB364(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + something = EnRu1_UpdateSkelAnime(pthis); + func_80AEF4E0(pthis); + func_80AEF5B8(pthis); + func_80AEF40C(pthis); + func_80AEF728(pthis, something); + func_80AEB220(pthis, globalCtx); +} + +void func_80AEFAAC(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + func_80AEF79C(pthis, globalCtx); + func_80AEB220(pthis, globalCtx); +} + +void func_80AEFB04(EnRu1* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + something = EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEF820(pthis, something); + func_80AEB220(pthis, globalCtx); +} + +void func_80AEFB68(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEF890(pthis, globalCtx); + func_80AEB220(pthis, globalCtx); +} + +void func_80AEFBC8(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEAECC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEF540(pthis); + func_80AEF930(pthis, globalCtx); +} + +void func_80AEFC24(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AED83C(pthis); + func_80AEF99C(pthis, globalCtx); +} + +void func_80AEFC54(EnRu1* pthis, GlobalContext* globalCtx) { + if ((gSaveContext.infTable[20] & 0x20) && !(gSaveContext.infTable[20] & 0x40)) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + pthis->action = 41; + pthis->unk_28C = EnRu1_FindSwitch(globalCtx); + func_80AEB0EC(pthis, 1); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + } else { + Actor_Kill(&pthis->actor); + } +} + +void func_80AEFCE8(EnRu1* pthis, GlobalContext* globalCtx) { + pthis->unk_28C = EnRu1_FindSwitch(globalCtx); + if (pthis->unk_28C != NULL) { + pthis->action = 42; + pthis->drawConfig = 1; + func_80AEB0EC(pthis, 1); + } +} + +void func_80AEFD38(EnRu1* pthis, GlobalContext* globalCtx) { + if ((gSaveContext.eventChkInf[3] & 0x80) && LINK_IS_CHILD) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->action = 44; + pthis->drawConfig = 1; + } else { + Actor_Kill(&pthis->actor); + } +} + +s32 func_80AEFDC0(EnRu1* pthis, GlobalContext* globalCtx) { + if (!Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 0x1F); + if (pthis->actor.textId == 0) { + pthis->actor.textId = 0x402C; + } + func_8002F2F4(&pthis->actor, globalCtx); + return false; + } + return true; +} + +s32 func_80AEFE38(EnRu1* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + return true; + } + return false; +} + +void func_80AEFE84(EnRu1* pthis, GlobalContext* globalCtx, s32 cond) { + if (cond) { + pthis->action = 45; + } +} + +void func_80AEFE9C(EnRu1* pthis, GlobalContext* globalCtx) { + if (func_80AEFE38(pthis, globalCtx)) { + pthis->action = 44; + } +} + +void func_80AEFECC(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEEF68(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAC10(pthis, globalCtx); + func_80AEAECC(pthis, globalCtx); + func_80AEFE84(pthis, globalCtx, func_80AEFDC0(pthis, globalCtx)); +} + +void func_80AEFF40(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEEFEC(pthis, globalCtx); + EnRu1_UpdateSkelAnime(pthis); + EnRu1_UpdateEyes(pthis); + func_80AEAECC(pthis, globalCtx); + func_80AEFE9C(pthis, globalCtx); +} + +void func_80AEFF94(EnRu1* pthis, GlobalContext* globalCtx) { + s8 actorRoom; + + if ((gSaveContext.infTable[20] & 2) && (gSaveContext.infTable[20] & 1) && !(gSaveContext.infTable[20] & 0x20) && + (!(func_80AEB020(pthis, globalCtx)))) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + actorRoom = pthis->actor.room; + pthis->action = 22; + pthis->actor.room = -1; + pthis->drawConfig = 0; + pthis->roomNum1 = actorRoom; + pthis->roomNum3 = actorRoom; + pthis->roomNum2 = actorRoom; + // "Ruto switch set" + osSyncPrintf("スイッチルトセット!!!!!!!!!!!!!!!!!!!!!!\n"); + } else { + // "Ruto switch not set" + osSyncPrintf("スイッチルトセットしない!!!!!!!!!!!!!!!!!!!!!!\n"); + Actor_Kill(&pthis->actor); + } +} + +void func_80AF0050(EnRu1* pthis, GlobalContext* globalCtx) { + func_80AEB264(pthis, &gRutoChildWait2Anim, 0, 0, 0); + pthis->action = 36; + pthis->roomNum1 = pthis->actor.room; + pthis->unk_28C = EnRu1_FindSwitch(globalCtx); + pthis->actor.room = -1; +} + +void EnRu1_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRu1* pthis = (EnRu1*)thisx; + + if (pthis->action < 0 || pthis->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[pthis->action] == NULL) { + // "Main mode is improper!" + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void EnRu1_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRu1* pthis = (EnRu1*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gRutoChildSkel, NULL, pthis->jointTable, pthis->morphTable, 17); + func_80AEAD20(&pthis->actor, globalCtx); + switch (func_80AEADF0(pthis)) { + case 0: + func_80AECDA0(pthis, globalCtx); + break; + case 1: + func_80AEB3DC(pthis, globalCtx); + break; + case 2: + func_80AEC320(pthis, globalCtx); + break; + case 3: + func_80AED44C(pthis, globalCtx); + break; + case 4: + func_80AEFC54(pthis, globalCtx); + break; + case 5: + func_80AEFD38(pthis, globalCtx); + break; + case 6: + func_80AEFF94(pthis, globalCtx); + break; + case 10: + func_80AF0050(pthis, globalCtx); + break; + default: + Actor_Kill(&pthis->actor); + // "Relevant arge_data = %d unacceptable" + osSyncPrintf("該当 arge_data = %d 無し\n", func_80AEADF0(pthis)); + break; + } +} + +void func_80AF0278(EnRu1* pthis, GlobalContext* globalCtx, s32 limbIndex, Vec3s* rot) { + Vec3s* vec1 = &pthis->unk_374.unk_0E; + Vec3s* vec2 = &pthis->unk_374.unk_08; + + switch (limbIndex) { + case RUTO_CHILD_LEFT_UPPER_ARM: + rot->x += vec1->y; + rot->y -= vec1->x; + break; + case RUTO_CHILD_TORSO: + rot->x += vec2->y; + rot->z += vec2->x; + break; + } +} + +s32 EnRu1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnRu1* pthis = (EnRu1*)thisx; + + if ((pthis->unk_290 < 0) || (pthis->unk_290 > 0) || (*sPreLimbDrawFuncs[pthis->unk_290] == NULL)) { + // "Neck rotation mode is improper!" + osSyncPrintf(VT_FGCOL(RED) "首回しモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + } else { + sPreLimbDrawFuncs[pthis->unk_290](pthis, globalCtx, limbIndex, rot); + } + return false; +} + +void EnRu1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + EnRu1* pthis = (EnRu1*)thisx; + Vec3f vec1; + Vec3f vec2; + + if (limbIndex == RUTO_CHILD_TORSO) { + vec1 = sMultVec; + Matrix_MultVec3f(&vec1, &vec2); + pthis->actor.focus.pos.x = vec2.x; + pthis->actor.focus.pos.y = vec2.y; + pthis->actor.focus.pos.z = vec2.z; + pthis->actor.focus.rot.x = pthis->actor.world.rot.x; + pthis->actor.focus.rot.y = pthis->actor.world.rot.y; + pthis->actor.focus.rot.z = pthis->actor.world.rot.z; + } +} + +void EnRu1_DrawNothing(EnRu1* pthis, GlobalContext* globalCtx) { +} + +void EnRu1_DrawOpa(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeIndex = pthis->eyeIndex; + void* eyeTex = sEyeTextures[eyeIndex]; + s16 mouthIndex = pthis->mouthIndex; + SkelAnime* skelAnime = &pthis->skelAnime; + void* mouthTex = sMouthTextures[mouthIndex]; + s32 pad1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1282); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnRu1_OverrideLimbDraw, EnRu1_PostLimbDraw, pthis, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1309); +} + +void EnRu1_DrawXlu(EnRu1* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeIndex = pthis->eyeIndex; + void* eyeTex = sEyeTextures[eyeIndex]; + s16 mouthIndex = pthis->mouthIndex; + SkelAnime* skelAnime = &pthis->skelAnime; + void* mouthTex = sMouthTextures[mouthIndex]; + s32 pad1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1324); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnRu1_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru1.c", 1353); +} + +void EnRu1_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRu1* pthis = (EnRu1*)thisx; + + if (pthis->drawConfig < 0 || pthis->drawConfig >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[pthis->drawConfig] == 0) { + // "Draw mode is improper!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1_cutscene_data.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Ru1/z_en_ru1_cutscene_data.c rename to src/overlays/actors/ovl_En_Ru1/z_en_ru1_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c deleted file mode 100644 index fba875709..000000000 --- a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c +++ /dev/null @@ -1,842 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RU2_Z_EN_RU2_C -#include "actor_common.h" -/* - * File: z_en_ru2.c - * Overlay: En_Ru2 - * Description: Adult Ruto - */ - -#include "z_en_ru2.h" -#include "objects/object_ru2/object_ru2.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "vt.h" -#include "def/code_800EC960.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnRu2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRu2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRu2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRu2_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AF2CB4(EnRu2* this, GlobalContext* globalCtx); -void func_80AF2CD4(EnRu2* this, GlobalContext* globalCtx); -void func_80AF2CF4(EnRu2* this, GlobalContext* globalCtx); -void func_80AF2D2C(EnRu2* this, GlobalContext* globalCtx); -void func_80AF2D6C(EnRu2* this, GlobalContext* globalCtx); -void func_80AF2DAC(EnRu2* this, GlobalContext* globalCtx); -void func_80AF2DEC(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3144(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3174(EnRu2* this, GlobalContext* globalCtx); -void func_80AF31C8(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3604(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3624(EnRu2* this, GlobalContext* globalCtx); -void func_80AF366C(EnRu2* this, GlobalContext* globalCtx); -void func_80AF36AC(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3BC8(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3C04(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3C64(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3CB8(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3D0C(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3D60(EnRu2* this, GlobalContext* globalCtx); - -void func_80AF3F14(EnRu2* this, GlobalContext* globalCtx); -void func_80AF3F20(EnRu2* this, GlobalContext* globalCtx); -void func_80AF321C(EnRu2* this, GlobalContext* globalCtx); - -void func_80AF2AB4(EnRu2* this, GlobalContext* globalCtx); - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000080, 0x00, 0x00 }, 0x00, 0x01, 0x00 }, - { 30, 100, 0, { 0 } }, -}; - -static void* sEyeTextures[] = { - gAdultRutoEyeOpenTex, - gAdultRutoEyeHalfTex, - gAdultRutoEyeClosedTex, -}; - -static UNK_TYPE D_80AF4118 = 0; - -#include "z_en_ru2_cutscene_data.c" EARLY - -static EnRu2ActionFunc sActionFuncs[] = { - func_80AF2CB4, func_80AF2CD4, func_80AF2CF4, func_80AF2D2C, func_80AF2D6C, func_80AF2DAC, func_80AF2DEC, - func_80AF3144, func_80AF3174, func_80AF31C8, func_80AF3604, func_80AF3624, func_80AF366C, func_80AF36AC, - func_80AF3BC8, func_80AF3C04, func_80AF3C64, func_80AF3CB8, func_80AF3D0C, func_80AF3D60, -}; - -static EnRu2DrawFunc sDrawFuncs[] = { - func_80AF3F14, - func_80AF3F20, - func_80AF321C, -}; - -const ActorInit En_Ru2_InitVars = { - ACTOR_EN_RU2, - ACTORCAT_NPC, - FLAGS, - OBJECT_RU2, - sizeof(EnRu2), - (ActorFunc)EnRu2_Init, - (ActorFunc)EnRu2_Destroy, - (ActorFunc)EnRu2_Update, - (ActorFunc)EnRu2_Draw, -}; - -void func_80AF2550(Actor* thisx, GlobalContext* globalCtx) { - EnRu2* this = (EnRu2*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); -} - -void func_80AF259C(EnRu2* this, GlobalContext* globalCtx) { - s32 pad[5]; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnRu2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnRu2* this = (EnRu2*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AF2608(EnRu2* this) { - s32 pad[3]; - s16* unk_2A6 = &this->unk_2A6; - s16* unk_2A4 = &this->unk_2A4; - - if (!DECR(*unk_2A6)) { - *unk_2A6 = Rand_S16Offset(0x3C, 0x3C); - } - - *unk_2A4 = *unk_2A6; - if (*unk_2A4 >= 3) { - *unk_2A4 = 0; - } -} - -s32 func_80AF2690(EnRu2* this) { - s32 params_shift = this->actor.params >> 8; - - return params_shift & 0xFF; -} - -s32 func_80AF26A0(EnRu2* this) { - s16 params = this->actor.params; - - return params & 0xFF; -} - -void func_80AF26AC(EnRu2* this) { - this->action = 7; - this->drawConfig = 0; - this->alpha = 0; - this->unk_2B8 = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_2B0 = 0.0f; -} - -void func_80AF26D0(EnRu2* this, GlobalContext* globalCtx) { - s32 one; // Needed to match - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - if (D_80AF4118 != 0) { - if (this->actor.params == 2) { - func_80AF26AC(this); - } - D_80AF4118 = 0; - return; - } - } else { - one = 1; - if (D_80AF4118 == 0) { - D_80AF4118 = one; - } - } -} - -void func_80AF2744(EnRu2* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 4); -} - -s32 EnRu2_UpdateSkelAnime(EnRu2* this) { - return SkelAnime_Update(&this->skelAnime); -} - -CsCmdActorAction* func_80AF27AC(GlobalContext* globalCtx, s32 npcActionIdx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[npcActionIdx]; - } - return NULL; -} - -s32 func_80AF27D0(EnRu2* this, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { - CsCmdActorAction* csCmdActorAction = func_80AF27AC(globalCtx, npcActionIdx); - - if ((csCmdActorAction != NULL) && (csCmdActorAction->action == arg2)) { - return true; - } - return false; -} - -s32 func_80AF281C(EnRu2* this, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = func_80AF27AC(globalCtx, npcActionIdx); - - if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action != arg2)) { - return true; - } - return false; -} - -void func_80AF2868(EnRu2* this, GlobalContext* globalCtx, u32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = func_80AF27AC(globalCtx, npcActionIdx); - s16 newRotY; - Actor* thisx = &this->actor; - - if (csCmdNPCAction != NULL) { - thisx->world.pos.x = csCmdNPCAction->startPos.x; - thisx->world.pos.y = csCmdNPCAction->startPos.y; - thisx->world.pos.z = csCmdNPCAction->startPos.z; - newRotY = csCmdNPCAction->rot.y; - thisx->shape.rot.y = newRotY; - thisx->world.rot.y = newRotY; - } -} - -void func_80AF28E8(EnRu2* this, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { - f32 frameCount = Animation_GetLastFrame(animation); - f32 playbackSpeed; - f32 unk0; - f32 fc; - - if (arg4 == 0) { - unk0 = 0.0f; - fc = frameCount; - playbackSpeed = 1.0f; - } else { - unk0 = frameCount; - fc = 0.0f; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animation, playbackSpeed, unk0, fc, arg2, transitionRate); -} - -void func_80AF2978(EnRu2* this, GlobalContext* globalCtx) { - this->actor.shape.yOffset += 250.0f / 3.0f; -} - -void func_80AF2994(EnRu2* this, GlobalContext* globalCtx) { - func_80AF28E8(this, &gAdultRutoIdleAnim, 0, 0.0f, 0); - this->actor.shape.yOffset = -10000.0f; -} - -void func_80AF29DC(EnRu2* this, GlobalContext* globalCtx) { - Actor* thisx = &this->actor; - f32 posX = thisx->world.pos.x; - f32 posY = thisx->world.pos.y; - f32 posZ = thisx->world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, - WARP_SAGES); -} - -void func_80AF2A38(EnRu2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 posX = player->actor.world.pos.x; - f32 posY = player->actor.world.pos.y + 50.0f; - f32 posZ = player->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, 10); - Item_Give(globalCtx, ITEM_MEDALLION_WATER); -} - -void func_80AF2AB4(EnRu2* this, GlobalContext* globalCtx) { - s32 pad[2]; - Player* player; - s16 temp; - - if ((gSaveContext.chamberCutsceneNum == 2) && (gSaveContext.sceneSetupIndex < 4)) { - player = GET_PLAYER(globalCtx); - this->action = 1; - globalCtx->csCtx.segment = &D_80AF411C; - gSaveContext.cutsceneTrigger = 2; - Item_Give(globalCtx, ITEM_MEDALLION_WATER); - temp = this->actor.world.rot.y + 0x8000; - player->actor.shape.rot.y = temp; - player->actor.world.rot.y = temp; - } -} - -void func_80AF2B44(EnRu2* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - CsCmdActorAction* csCmdNPCAction; - - if (csCtx->state != CS_STATE_IDLE) { - csCmdNPCAction = csCtx->npcActions[3]; - if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == 2)) { - this->action = 2; - this->drawConfig = 1; - func_80AF29DC(this, globalCtx); - } - } -} - -void func_80AF2B94(EnRu2* this) { - if (this->actor.shape.yOffset >= 0.0f) { - this->action = 3; - this->actor.shape.yOffset = 0.0f; - } -} - -void func_80AF2BC0(EnRu2* this, GlobalContext* globalCtx) { - AnimationHeader* animation = &gAdultRutoRaisingArmsUpAnim; - CsCmdActorAction* csCmdNPCAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdNPCAction = globalCtx->csCtx.npcActions[3]; - if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == 3)) { - Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, - 0.0f); - this->action = 4; - } - } -} - -void func_80AF2C54(EnRu2* this, s32 arg1) { - if (arg1 != 0) { - this->action = 5; - } -} - -void func_80AF2C68(EnRu2* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - csCmdNPCAction = globalCtx->csCtx.npcActions[6]; - if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == 2)) { - this->action = 6; - func_80AF2A38(this, globalCtx); - } - } -} - -void func_80AF2CB4(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2AB4(this, globalCtx); -} - -void func_80AF2CD4(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2B44(this, globalCtx); -} - -void func_80AF2CF4(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2978(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF2B94(this); -} - -void func_80AF2D2C(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF2BC0(this, globalCtx); -} - -void func_80AF2D6C(EnRu2* this, GlobalContext* globalCtx) { - s32 something; - - func_80AF2744(this, globalCtx); - something = EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF2C54(this, something); -} - -void func_80AF2DAC(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF2C68(this, globalCtx); -} - -void func_80AF2DEC(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); -} - -void func_80AF2E1C(EnRu2* this, GlobalContext* globalCtx) { - func_80AF28E8(this, &gAdultRutoCrossingArmsAnim, 2, 0.0f, 0); - this->action = 7; - this->actor.shape.shadowAlpha = 0; -} - -void func_80AF2E64() { - func_800788CC(NA_SE_SY_WHITE_OUT_T); -} - -void func_80AF2E84(EnRu2* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, this->actor.world.pos.x, - kREG(19) + 24.0f + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 8); -} - -void func_80AF2F04(EnRu2* this, GlobalContext* globalCtx) { - if (func_80AF27D0(this, globalCtx, 4, 3)) { - this->action = 8; - this->drawConfig = 2; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - this->unk_2B0 = 0.0f; - func_80AF2E64(); - } -} - -void func_80AF2F58(EnRu2* this, GlobalContext* globalCtx) { - f32* unk_2B0 = &this->unk_2B0; - s32 alpha; - - if (func_80AF27D0(this, globalCtx, 4, 3)) { - *unk_2B0 += 1.0f; - if (*unk_2B0 >= kREG(5) + 10.0f) { - this->action = 9; - this->drawConfig = 1; - *unk_2B0 = kREG(5) + 10.0f; - this->alpha = 255; - this->actor.shape.shadowAlpha = 0xFF; - return; - } - } else { - *unk_2B0 -= 1.0f; - if (*unk_2B0 <= 0.0f) { - this->action = 7; - this->drawConfig = 0; - *unk_2B0 = 0.0f; - this->alpha = 0; - this->actor.shape.shadowAlpha = 0; - return; - } - } - alpha = (*unk_2B0 / (kREG(5) + 10.0f)) * 255.0f; - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; -} - -void func_80AF30AC(EnRu2* this, GlobalContext* globalCtx) { - if (func_80AF281C(this, globalCtx, 4, 3)) { - this->action = 8; - this->drawConfig = 2; - this->unk_2B0 = kREG(5) + 10.0f; - this->alpha = 255; - if (this->unk_2B8 == 0) { - func_80AF2E84(this, globalCtx); - this->unk_2B8 = 1; - } - this->actor.shape.shadowAlpha = 0xFF; - } -} - -void func_80AF3144(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2F04(this, globalCtx); - func_80AF26D0(this, globalCtx); -} - -void func_80AF3174(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF2F58(this, globalCtx); - func_80AF26D0(this, globalCtx); -} - -void func_80AF31C8(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF30AC(this, globalCtx); - func_80AF26D0(this, globalCtx); -} - -void func_80AF321C(EnRu2* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 temp = this->unk_2A4; - void* tex = sEyeTextures[temp]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2_inKenjyanomaDemo02.c", 264); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - NULL, NULL, NULL, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2_inKenjyanomaDemo02.c", 291); -} - -void func_80AF3394(EnRu2* this, GlobalContext* globalCtx) { - func_80AF28E8(this, &gAdultRutoIdleHandsOnHipsAnim, 0, 0.0f, 0); - this->action = 10; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80AF33E0(EnRu2* this) { - f32* unk_2B0 = &this->unk_2B0; - f32 temp_f0; - s32 temp_f18; - - *unk_2B0 += 1.0f; - - temp_f0 = kREG(17) + 10.0f; - if (temp_f0 <= *unk_2B0) { - this->alpha = 255; - this->actor.shape.shadowAlpha = 0xFF; - } else { - temp_f18 = (*unk_2B0 / temp_f0) * 255.0f; - this->alpha = temp_f18; - this->actor.shape.shadowAlpha = temp_f18; - } -} - -void func_80AF346C(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2868(this, globalCtx, 3); - this->action = 11; - this->drawConfig = 2; -} - -void func_80AF34A4(EnRu2* this) { - if (this->unk_2B0 >= kREG(17) + 10.0f) { - this->action = 12; - this->drawConfig = 1; - } -} - -void func_80AF34F0(EnRu2* this) { - func_80AF28E8(this, &gAdultRutoHeadTurnDownLeftAnim, 2, 0.0f, 0); - this->action = 13; -} - -void func_80AF3530(EnRu2* this, s32 arg1) { - if (arg1 != 0) { - func_80AF28E8(this, &gAdultRutoLookingDownLeftAnim, 0, 0.0f, 0); - } -} - -void func_80AF3564(EnRu2* this, GlobalContext* globalCtx) { - CsCmdActorAction* csCmdNPCAction = func_80AF27AC(globalCtx, 3); - s32 action; - s32 unk_2BC; - - if (csCmdNPCAction != NULL) { - action = csCmdNPCAction->action; - unk_2BC = this->unk_2BC; - if (action != unk_2BC) { - switch (action) { - case 7: - func_80AF346C(this, globalCtx); - break; - case 8: - func_80AF34F0(this); - break; - default: - // "There is no such action!" - osSyncPrintf("En_Ru2_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - this->unk_2BC = action; - } - } -} - -void func_80AF3604(EnRu2* this, GlobalContext* globalCtx) { - func_80AF3564(this, globalCtx); -} - -void func_80AF3624(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF33E0(this); - func_80AF34A4(this); -} - -void func_80AF366C(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF3564(this, globalCtx); -} - -void func_80AF36AC(EnRu2* this, GlobalContext* globalCtx) { - s32 something; - - func_80AF2744(this, globalCtx); - something = EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - func_80AF3530(this, something); -} - -void func_80AF36EC(EnRu2* this, GlobalContext* globalCtx) { - Flags_SetSwitch(globalCtx, func_80AF2690(this)); -} - -s32 func_80AF3718(EnRu2* this, GlobalContext* globalCtx) { - return Flags_GetSwitch(globalCtx, func_80AF2690(this)); -} - -void func_80AF3744(EnRu2* this, GlobalContext* globalCtx) { - if (func_80AF3718(this, globalCtx)) { - Actor_Kill(&this->actor); - } else { - func_80AF28E8(this, &gAdultRutoIdleAnim, 0, 0.0f, 0); - this->action = 14; - this->drawConfig = 1; - } -} - -void func_80AF37AC(void) { - Audio_PlayFanfare(NA_BGM_APPEAR); -} - -void func_80AF37CC(EnRu2* this) { - f32 funcFloat; - - this->unk_2C0++; - funcFloat = Environment_LerpWeightAccelDecel((kREG(2) + 0x96) & 0xFFFF, 0, this->unk_2C0, 8, 0); - this->actor.world.pos.y = this->actor.home.pos.y + (300.0f * funcFloat); -} - -s32 func_80AF383C(EnRu2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 thisPosX = this->actor.world.pos.x; - f32 playerPosX = player->actor.world.pos.x; - - if (playerPosX - thisPosX >= -202.0f) { - return 1; - } - return 0; -} - -void func_80AF3878(EnRu2* this, GlobalContext* globalCtx) { - if (func_80AF383C(this, globalCtx) && !Gameplay_InCsMode(globalCtx)) { - this->action = 16; - OnePointCutscene_Init(globalCtx, 3130, -99, &this->actor, MAIN_CAM); - } -} - -void func_80AF38D0(EnRu2* this, GlobalContext* globalCtx) { - this->action = 16; - OnePointCutscene_Init(globalCtx, 3130, -99, &this->actor, MAIN_CAM); -} - -void func_80AF390C(EnRu2* this, GlobalContext* globalCtx) { - f32* unk_2C4 = &this->unk_2C4; - - *unk_2C4 += 1.0f; - if (*unk_2C4 == kREG(6) + 40.0f) { - func_80AF37AC(); - } else if (*unk_2C4 > kREG(4) + 50.0f) { - this->actor.textId = 0x403E; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->action = 17; - } -} - -void func_80AF39DC(EnRu2* this, GlobalContext* globalCtx) { - s32 pad; - MessageContext* msgCtx; - s32 pad2; - u8 dialogState; - Player* player; - s32 pad3; - - msgCtx = &globalCtx->msgCtx; - dialogState = Message_GetState(msgCtx); - - if (dialogState == TEXT_STATE_DONE_FADING) { - if (this->unk_2C3 != TEXT_STATE_DONE_FADING) { - // "I'm Komatsu!" (cinema scene dev) - osSyncPrintf("おれが小松だ! \n"); - this->unk_2C2++; - if (this->unk_2C2 % 6 == 3) { - player = GET_PLAYER(globalCtx); - // "uorya-!" (screeming sound) - osSyncPrintf("うおりゃー! \n"); - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - player->actor.world.pos.x = 820.0f; - player->actor.world.pos.y = 0.0f; - player->actor.world.pos.z = 180.0f; - } - } - } - - this->unk_2C3 = dialogState; - if (Message_GetState(msgCtx) == TEXT_STATE_CLOSING) { - this->action = 18; - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - } -} - -void func_80AF3ADC(EnRu2* this, GlobalContext* globalCtx) { - this->unk_2C4 += 1.0f; - if (this->unk_2C4 > kREG(5) + 100.0f) { - func_80AF28E8(this, &gAdultRutoSwimmingUpAnim, 0, -12.0f, 0); - this->action = 19; - func_80AF36EC(this, globalCtx); - } -} - -void func_80AF3B74(EnRu2* this, GlobalContext* globalCtx) { - if (this->unk_2C0 > ((((u16)(kREG(3) + 0x28)) + ((u16)(kREG(2) + 0x96))) & 0xFFFF)) { - Actor_Kill(&this->actor); - } -} - -void func_80AF3BC8(EnRu2* this, GlobalContext* globalCtx) { - func_80AF3878(this, globalCtx); - Actor_SetFocus(&this->actor, 50.0f); - func_80AF259C(this, globalCtx); -} - -void func_80AF3C04(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - func_80AF259C(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - Actor_SetFocus(&this->actor, 50.0f); - func_80AF38D0(this, globalCtx); -} - -void func_80AF3C64(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - Actor_SetFocus(&this->actor, 50.0f); - func_80AF390C(this, globalCtx); -} - -void func_80AF3CB8(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - Actor_SetFocus(&this->actor, 50.0f); - func_80AF39DC(this, globalCtx); -} - -void func_80AF3D0C(EnRu2* this, GlobalContext* globalCtx) { - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - Actor_SetFocus(&this->actor, 50.0f); - func_80AF3ADC(this, globalCtx); -} - -void func_80AF3D60(EnRu2* this, GlobalContext* globalCtx) { - func_80AF37CC(this); - func_80AF2744(this, globalCtx); - EnRu2_UpdateSkelAnime(this); - func_80AF2608(this); - Actor_SetFocus(&this->actor, 50.0f); - func_80AF3B74(this, globalCtx); -} - -void EnRu2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnRu2* this = (EnRu2*)thisx; - - if ((this->action < 0) || (this->action >= ARRAY_COUNT(sActionFuncs)) || (sActionFuncs[this->action] == NULL)) { - // "Main Mode is improper!" - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sActionFuncs[this->action](this, globalCtx); -} - -void EnRu2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnRu2* this = (EnRu2*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - func_80AF2550(thisx, globalCtx); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAdultRutoSkel, NULL, this->jointTable, this->morphTable, 23); - - switch (func_80AF26A0(this)) { - case 2: - func_80AF2E1C(this, globalCtx); - break; - case 3: - func_80AF3394(this, globalCtx); - break; - case 4: - func_80AF3744(this, globalCtx); - break; - default: - func_80AF2994(this, globalCtx); - break; - } - - this->unk_2C2 = 0; - this->unk_2C3 = TEXT_STATE_DONE_FADING; -} - -void func_80AF3F14(EnRu2* this, GlobalContext* globalCtx) { -} - -void func_80AF3F20(EnRu2* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 temp = this->unk_2A4; - void* tex = sEyeTextures[temp]; - SkelAnime* skelAnime = &this->skelAnime; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2.c", 642); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, - this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2.c", 663); -} - -void EnRu2_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnRu2* this = (EnRu2*)thisx; - - if ((this->drawConfig < 0) || (this->drawConfig >= ARRAY_COUNT(sDrawFuncs)) || - (sDrawFuncs[this->drawConfig] == 0)) { - // "Draw Mode is improper!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.cpp b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.cpp new file mode 100644 index 000000000..a1b47fff7 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.cpp @@ -0,0 +1,842 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_RU2_Z_EN_RU2_C +#include "actor_common.h" +/* + * File: z_en_ru2.c + * Overlay: En_Ru2 + * Description: Adult Ruto + */ + +#include "z_en_ru2.h" +#include "objects/object_ru2/object_ru2.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "vt.h" +#include "def/code_800EC960.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnRu2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnRu2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnRu2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnRu2_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AF2CB4(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF2CD4(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF2CF4(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF2D2C(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF2D6C(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF2DAC(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF2DEC(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3144(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3174(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF31C8(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3604(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3624(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF366C(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF36AC(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3BC8(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3C04(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3C64(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3CB8(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3D0C(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3D60(EnRu2* pthis, GlobalContext* globalCtx); + +void func_80AF3F14(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF3F20(EnRu2* pthis, GlobalContext* globalCtx); +void func_80AF321C(EnRu2* pthis, GlobalContext* globalCtx); + +void func_80AF2AB4(EnRu2* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000080, 0x00, 0x00 }, 0x00, 0x01, 0x00 }, + { 30, 100, 0, { 0 } }, +}; + +static void* sEyeTextures[] = { + gAdultRutoEyeOpenTex, + gAdultRutoEyeHalfTex, + gAdultRutoEyeClosedTex, +}; + +static UNK_TYPE D_80AF4118 = 0; + +#include "z_en_ru2_cutscene_data.cpp" EARLY + +static EnRu2ActionFunc sActionFuncs[] = { + func_80AF2CB4, func_80AF2CD4, func_80AF2CF4, func_80AF2D2C, func_80AF2D6C, func_80AF2DAC, func_80AF2DEC, + func_80AF3144, func_80AF3174, func_80AF31C8, func_80AF3604, func_80AF3624, func_80AF366C, func_80AF36AC, + func_80AF3BC8, func_80AF3C04, func_80AF3C64, func_80AF3CB8, func_80AF3D0C, func_80AF3D60, +}; + +static EnRu2DrawFunc sDrawFuncs[] = { + func_80AF3F14, + func_80AF3F20, + func_80AF321C, +}; + +ActorInit En_Ru2_InitVars = { + ACTOR_EN_RU2, + ACTORCAT_NPC, + FLAGS, + OBJECT_RU2, + sizeof(EnRu2), + (ActorFunc)EnRu2_Init, + (ActorFunc)EnRu2_Destroy, + (ActorFunc)EnRu2_Update, + (ActorFunc)EnRu2_Draw, +}; + +void func_80AF2550(Actor* thisx, GlobalContext* globalCtx) { + EnRu2* pthis = (EnRu2*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); +} + +void func_80AF259C(EnRu2* pthis, GlobalContext* globalCtx) { + s32 pad[5]; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnRu2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRu2* pthis = (EnRu2*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AF2608(EnRu2* pthis) { + s32 pad[3]; + s16* unk_2A6 = &pthis->unk_2A6; + s16* unk_2A4 = &pthis->unk_2A4; + + if (!DECR(*unk_2A6)) { + *unk_2A6 = Rand_S16Offset(0x3C, 0x3C); + } + + *unk_2A4 = *unk_2A6; + if (*unk_2A4 >= 3) { + *unk_2A4 = 0; + } +} + +s32 func_80AF2690(EnRu2* pthis) { + s32 params_shift = pthis->actor.params >> 8; + + return params_shift & 0xFF; +} + +s32 func_80AF26A0(EnRu2* pthis) { + s16 params = pthis->actor.params; + + return params & 0xFF; +} + +void func_80AF26AC(EnRu2* pthis) { + pthis->action = 7; + pthis->drawConfig = 0; + pthis->alpha = 0; + pthis->unk_2B8 = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_2B0 = 0.0f; +} + +void func_80AF26D0(EnRu2* pthis, GlobalContext* globalCtx) { + s32 one; // Needed to match + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + if (D_80AF4118 != 0) { + if (pthis->actor.params == 2) { + func_80AF26AC(pthis); + } + D_80AF4118 = 0; + return; + } + } else { + one = 1; + if (D_80AF4118 == 0) { + D_80AF4118 = one; + } + } +} + +void func_80AF2744(EnRu2* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 4); +} + +s32 EnRu2_UpdateSkelAnime(EnRu2* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +CsCmdActorAction* func_80AF27AC(GlobalContext* globalCtx, s32 npcActionIdx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[npcActionIdx]; + } + return NULL; +} + +s32 func_80AF27D0(EnRu2* pthis, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { + CsCmdActorAction* csCmdActorAction = func_80AF27AC(globalCtx, npcActionIdx); + + if ((csCmdActorAction != NULL) && (csCmdActorAction->action == arg2)) { + return true; + } + return false; +} + +s32 func_80AF281C(EnRu2* pthis, GlobalContext* globalCtx, u16 arg2, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = func_80AF27AC(globalCtx, npcActionIdx); + + if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action != arg2)) { + return true; + } + return false; +} + +void func_80AF2868(EnRu2* pthis, GlobalContext* globalCtx, u32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = func_80AF27AC(globalCtx, npcActionIdx); + s16 newRotY; + Actor* thisx = &pthis->actor; + + if (csCmdNPCAction != NULL) { + thisx->world.pos.x = csCmdNPCAction->startPos.x; + thisx->world.pos.y = csCmdNPCAction->startPos.y; + thisx->world.pos.z = csCmdNPCAction->startPos.z; + newRotY = csCmdNPCAction->rot.y; + thisx->shape.rot.y = newRotY; + thisx->world.rot.y = newRotY; + } +} + +void func_80AF28E8(EnRu2* pthis, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { + f32 frameCount = Animation_GetLastFrame(animation); + f32 playbackSpeed; + f32 unk0; + f32 fc; + + if (arg4 == 0) { + unk0 = 0.0f; + fc = frameCount; + playbackSpeed = 1.0f; + } else { + unk0 = frameCount; + fc = 0.0f; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animation, playbackSpeed, unk0, fc, arg2, transitionRate); +} + +void func_80AF2978(EnRu2* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.yOffset += 250.0f / 3.0f; +} + +void func_80AF2994(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF28E8(pthis, &gAdultRutoIdleAnim, 0, 0.0f, 0); + pthis->actor.shape.yOffset = -10000.0f; +} + +void func_80AF29DC(EnRu2* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->actor; + f32 posX = thisx->world.pos.x; + f32 posY = thisx->world.pos.y; + f32 posZ = thisx->world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, + WARP_SAGES); +} + +void func_80AF2A38(EnRu2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 posX = player->actor.world.pos.x; + f32 posY = player->actor.world.pos.y + 50.0f; + f32 posZ = player->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, 10); + Item_Give(globalCtx, ITEM_MEDALLION_WATER); +} + +void func_80AF2AB4(EnRu2* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + s16 temp; + + if ((gSaveContext.chamberCutsceneNum == 2) && (gSaveContext.sceneSetupIndex < 4)) { + player = GET_PLAYER(globalCtx); + pthis->action = 1; + globalCtx->csCtx.segment = &D_80AF411C; + gSaveContext.cutsceneTrigger = 2; + Item_Give(globalCtx, ITEM_MEDALLION_WATER); + temp = pthis->actor.world.rot.y + 0x8000; + player->actor.shape.rot.y = temp; + player->actor.world.rot.y = temp; + } +} + +void func_80AF2B44(EnRu2* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + CsCmdActorAction* csCmdNPCAction; + + if (csCtx->state != CS_STATE_IDLE) { + csCmdNPCAction = csCtx->npcActions[3]; + if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == 2)) { + pthis->action = 2; + pthis->drawConfig = 1; + func_80AF29DC(pthis, globalCtx); + } + } +} + +void func_80AF2B94(EnRu2* pthis) { + if (pthis->actor.shape.yOffset >= 0.0f) { + pthis->action = 3; + pthis->actor.shape.yOffset = 0.0f; + } +} + +void func_80AF2BC0(EnRu2* pthis, GlobalContext* globalCtx) { + AnimationHeader* animation = &gAdultRutoRaisingArmsUpAnim; + CsCmdActorAction* csCmdNPCAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdNPCAction = globalCtx->csCtx.npcActions[3]; + if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == 3)) { + Animation_Change(&pthis->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, + 0.0f); + pthis->action = 4; + } + } +} + +void func_80AF2C54(EnRu2* pthis, s32 arg1) { + if (arg1 != 0) { + pthis->action = 5; + } +} + +void func_80AF2C68(EnRu2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + csCmdNPCAction = globalCtx->csCtx.npcActions[6]; + if ((csCmdNPCAction != NULL) && (csCmdNPCAction->action == 2)) { + pthis->action = 6; + func_80AF2A38(pthis, globalCtx); + } + } +} + +void func_80AF2CB4(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2AB4(pthis, globalCtx); +} + +void func_80AF2CD4(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2B44(pthis, globalCtx); +} + +void func_80AF2CF4(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2978(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF2B94(pthis); +} + +void func_80AF2D2C(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF2BC0(pthis, globalCtx); +} + +void func_80AF2D6C(EnRu2* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80AF2744(pthis, globalCtx); + something = EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF2C54(pthis, something); +} + +void func_80AF2DAC(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF2C68(pthis, globalCtx); +} + +void func_80AF2DEC(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); +} + +void func_80AF2E1C(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF28E8(pthis, &gAdultRutoCrossingArmsAnim, 2, 0.0f, 0); + pthis->action = 7; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80AF2E64() { + func_800788CC(NA_SE_SY_WHITE_OUT_T); +} + +void func_80AF2E84(EnRu2* pthis, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, pthis->actor.world.pos.x, + kREG(19) + 24.0f + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 8); +} + +void func_80AF2F04(EnRu2* pthis, GlobalContext* globalCtx) { + if (func_80AF27D0(pthis, globalCtx, 4, 3)) { + pthis->action = 8; + pthis->drawConfig = 2; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + pthis->unk_2B0 = 0.0f; + func_80AF2E64(); + } +} + +void func_80AF2F58(EnRu2* pthis, GlobalContext* globalCtx) { + f32* unk_2B0 = &pthis->unk_2B0; + s32 alpha; + + if (func_80AF27D0(pthis, globalCtx, 4, 3)) { + *unk_2B0 += 1.0f; + if (*unk_2B0 >= kREG(5) + 10.0f) { + pthis->action = 9; + pthis->drawConfig = 1; + *unk_2B0 = kREG(5) + 10.0f; + pthis->alpha = 255; + pthis->actor.shape.shadowAlpha = 0xFF; + return; + } + } else { + *unk_2B0 -= 1.0f; + if (*unk_2B0 <= 0.0f) { + pthis->action = 7; + pthis->drawConfig = 0; + *unk_2B0 = 0.0f; + pthis->alpha = 0; + pthis->actor.shape.shadowAlpha = 0; + return; + } + } + alpha = (*unk_2B0 / (kREG(5) + 10.0f)) * 255.0f; + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; +} + +void func_80AF30AC(EnRu2* pthis, GlobalContext* globalCtx) { + if (func_80AF281C(pthis, globalCtx, 4, 3)) { + pthis->action = 8; + pthis->drawConfig = 2; + pthis->unk_2B0 = kREG(5) + 10.0f; + pthis->alpha = 255; + if (pthis->unk_2B8 == 0) { + func_80AF2E84(pthis, globalCtx); + pthis->unk_2B8 = 1; + } + pthis->actor.shape.shadowAlpha = 0xFF; + } +} + +void func_80AF3144(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2F04(pthis, globalCtx); + func_80AF26D0(pthis, globalCtx); +} + +void func_80AF3174(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF2F58(pthis, globalCtx); + func_80AF26D0(pthis, globalCtx); +} + +void func_80AF31C8(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF30AC(pthis, globalCtx); + func_80AF26D0(pthis, globalCtx); +} + +void func_80AF321C(EnRu2* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp = pthis->unk_2A4; + void* tex = sEyeTextures[temp]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2_inKenjyanomaDemo02.c", 264); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, &D_80116280[0]); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + NULL, NULL, NULL, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2_inKenjyanomaDemo02.c", 291); +} + +void func_80AF3394(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF28E8(pthis, &gAdultRutoIdleHandsOnHipsAnim, 0, 0.0f, 0); + pthis->action = 10; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80AF33E0(EnRu2* pthis) { + f32* unk_2B0 = &pthis->unk_2B0; + f32 temp_f0; + s32 temp_f18; + + *unk_2B0 += 1.0f; + + temp_f0 = kREG(17) + 10.0f; + if (temp_f0 <= *unk_2B0) { + pthis->alpha = 255; + pthis->actor.shape.shadowAlpha = 0xFF; + } else { + temp_f18 = (*unk_2B0 / temp_f0) * 255.0f; + pthis->alpha = temp_f18; + pthis->actor.shape.shadowAlpha = temp_f18; + } +} + +void func_80AF346C(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2868(pthis, globalCtx, 3); + pthis->action = 11; + pthis->drawConfig = 2; +} + +void func_80AF34A4(EnRu2* pthis) { + if (pthis->unk_2B0 >= kREG(17) + 10.0f) { + pthis->action = 12; + pthis->drawConfig = 1; + } +} + +void func_80AF34F0(EnRu2* pthis) { + func_80AF28E8(pthis, &gAdultRutoHeadTurnDownLeftAnim, 2, 0.0f, 0); + pthis->action = 13; +} + +void func_80AF3530(EnRu2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80AF28E8(pthis, &gAdultRutoLookingDownLeftAnim, 0, 0.0f, 0); + } +} + +void func_80AF3564(EnRu2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* csCmdNPCAction = func_80AF27AC(globalCtx, 3); + s32 action; + s32 unk_2BC; + + if (csCmdNPCAction != NULL) { + action = csCmdNPCAction->action; + unk_2BC = pthis->unk_2BC; + if (action != unk_2BC) { + switch (action) { + case 7: + func_80AF346C(pthis, globalCtx); + break; + case 8: + func_80AF34F0(pthis); + break; + default: + // "There is no such action!" + osSyncPrintf("En_Ru2_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + pthis->unk_2BC = action; + } + } +} + +void func_80AF3604(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF3564(pthis, globalCtx); +} + +void func_80AF3624(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF33E0(pthis); + func_80AF34A4(pthis); +} + +void func_80AF366C(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF3564(pthis, globalCtx); +} + +void func_80AF36AC(EnRu2* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80AF2744(pthis, globalCtx); + something = EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + func_80AF3530(pthis, something); +} + +void func_80AF36EC(EnRu2* pthis, GlobalContext* globalCtx) { + Flags_SetSwitch(globalCtx, func_80AF2690(pthis)); +} + +s32 func_80AF3718(EnRu2* pthis, GlobalContext* globalCtx) { + return Flags_GetSwitch(globalCtx, func_80AF2690(pthis)); +} + +void func_80AF3744(EnRu2* pthis, GlobalContext* globalCtx) { + if (func_80AF3718(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); + } else { + func_80AF28E8(pthis, &gAdultRutoIdleAnim, 0, 0.0f, 0); + pthis->action = 14; + pthis->drawConfig = 1; + } +} + +void func_80AF37AC(void) { + Audio_PlayFanfare(NA_BGM_APPEAR); +} + +void func_80AF37CC(EnRu2* pthis) { + f32 funcFloat; + + pthis->unk_2C0++; + funcFloat = Environment_LerpWeightAccelDecel((kREG(2) + 0x96) & 0xFFFF, 0, pthis->unk_2C0, 8, 0); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + (300.0f * funcFloat); +} + +s32 func_80AF383C(EnRu2* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 thisPosX = pthis->actor.world.pos.x; + f32 playerPosX = player->actor.world.pos.x; + + if (playerPosX - thisPosX >= -202.0f) { + return 1; + } + return 0; +} + +void func_80AF3878(EnRu2* pthis, GlobalContext* globalCtx) { + if (func_80AF383C(pthis, globalCtx) && !Gameplay_InCsMode(globalCtx)) { + pthis->action = 16; + OnePointCutscene_Init(globalCtx, 3130, -99, &pthis->actor, MAIN_CAM); + } +} + +void func_80AF38D0(EnRu2* pthis, GlobalContext* globalCtx) { + pthis->action = 16; + OnePointCutscene_Init(globalCtx, 3130, -99, &pthis->actor, MAIN_CAM); +} + +void func_80AF390C(EnRu2* pthis, GlobalContext* globalCtx) { + f32* unk_2C4 = &pthis->unk_2C4; + + *unk_2C4 += 1.0f; + if (*unk_2C4 == kREG(6) + 40.0f) { + func_80AF37AC(); + } else if (*unk_2C4 > kREG(4) + 50.0f) { + pthis->actor.textId = 0x403E; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->action = 17; + } +} + +void func_80AF39DC(EnRu2* pthis, GlobalContext* globalCtx) { + s32 pad; + MessageContext* msgCtx; + s32 pad2; + u8 dialogState; + Player* player; + s32 pad3; + + msgCtx = &globalCtx->msgCtx; + dialogState = Message_GetState(msgCtx); + + if (dialogState == TEXT_STATE_DONE_FADING) { + if (pthis->unk_2C3 != TEXT_STATE_DONE_FADING) { + // "I'm Komatsu!" (cinema scene dev) + osSyncPrintf("おれが小松だ! \n"); + pthis->unk_2C2++; + if (pthis->unk_2C2 % 6 == 3) { + player = GET_PLAYER(globalCtx); + // "uorya-!" (screeming sound) + osSyncPrintf("うおりゃー! \n"); + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + player->actor.world.pos.x = 820.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 180.0f; + } + } + } + + pthis->unk_2C3 = dialogState; + if (Message_GetState(msgCtx) == TEXT_STATE_CLOSING) { + pthis->action = 18; + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + } +} + +void func_80AF3ADC(EnRu2* pthis, GlobalContext* globalCtx) { + pthis->unk_2C4 += 1.0f; + if (pthis->unk_2C4 > kREG(5) + 100.0f) { + func_80AF28E8(pthis, &gAdultRutoSwimmingUpAnim, 0, -12.0f, 0); + pthis->action = 19; + func_80AF36EC(pthis, globalCtx); + } +} + +void func_80AF3B74(EnRu2* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2C0 > ((((u16)(kREG(3) + 0x28)) + ((u16)(kREG(2) + 0x96))) & 0xFFFF)) { + Actor_Kill(&pthis->actor); + } +} + +void func_80AF3BC8(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF3878(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 50.0f); + func_80AF259C(pthis, globalCtx); +} + +void func_80AF3C04(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + func_80AF259C(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + Actor_SetFocus(&pthis->actor, 50.0f); + func_80AF38D0(pthis, globalCtx); +} + +void func_80AF3C64(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + Actor_SetFocus(&pthis->actor, 50.0f); + func_80AF390C(pthis, globalCtx); +} + +void func_80AF3CB8(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + Actor_SetFocus(&pthis->actor, 50.0f); + func_80AF39DC(pthis, globalCtx); +} + +void func_80AF3D0C(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + Actor_SetFocus(&pthis->actor, 50.0f); + func_80AF3ADC(pthis, globalCtx); +} + +void func_80AF3D60(EnRu2* pthis, GlobalContext* globalCtx) { + func_80AF37CC(pthis); + func_80AF2744(pthis, globalCtx); + EnRu2_UpdateSkelAnime(pthis); + func_80AF2608(pthis); + Actor_SetFocus(&pthis->actor, 50.0f); + func_80AF3B74(pthis, globalCtx); +} + +void EnRu2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRu2* pthis = (EnRu2*)thisx; + + if ((pthis->action < 0) || (pthis->action >= ARRAY_COUNT(sActionFuncs)) || (sActionFuncs[pthis->action] == NULL)) { + // "Main Mode is improper!" + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void EnRu2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRu2* pthis = (EnRu2*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + func_80AF2550(thisx, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gAdultRutoSkel, NULL, pthis->jointTable, pthis->morphTable, 23); + + switch (func_80AF26A0(pthis)) { + case 2: + func_80AF2E1C(pthis, globalCtx); + break; + case 3: + func_80AF3394(pthis, globalCtx); + break; + case 4: + func_80AF3744(pthis, globalCtx); + break; + default: + func_80AF2994(pthis, globalCtx); + break; + } + + pthis->unk_2C2 = 0; + pthis->unk_2C3 = TEXT_STATE_DONE_FADING; +} + +void func_80AF3F14(EnRu2* pthis, GlobalContext* globalCtx) { +} + +void func_80AF3F20(EnRu2* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp = pthis->unk_2A4; + void* tex = sEyeTextures[temp]; + SkelAnime* skelAnime = &pthis->skelAnime; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2.c", 642); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(tex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(tex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); + + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, + pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ru2.c", 663); +} + +void EnRu2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRu2* pthis = (EnRu2*)thisx; + + if ((pthis->drawConfig < 0) || (pthis->drawConfig >= ARRAY_COUNT(sDrawFuncs)) || + (sDrawFuncs[pthis->drawConfig] == 0)) { + // "Draw Mode is improper!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2_cutscene_data.c b/src/overlays/actors/ovl_En_Ru2/z_en_ru2_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Ru2/z_en_ru2_cutscene_data.c rename to src/overlays/actors/ovl_En_Ru2/z_en_ru2_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Sa/z_en_sa.c b/src/overlays/actors/ovl_En_Sa/z_en_sa.c deleted file mode 100644 index b4e3f3295..000000000 --- a/src/overlays/actors/ovl_En_Sa/z_en_sa.c +++ /dev/null @@ -1,800 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SA_Z_EN_SA_C -#include "actor_common.h" -#include "z_en_sa.h" -#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#include "objects/object_sa/object_sa.h" -#include "scenes/overworld/spot04/spot04_scene.h" -#include "scenes/overworld/spot05/spot05_scene.h" -#include "def/code_800F7260.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25) - -void EnSa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSa_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AF6448(EnSa* this, GlobalContext* globalCtx); -void func_80AF67D0(EnSa* this, GlobalContext* globalCtx); -void func_80AF683C(EnSa* this, GlobalContext* globalCtx); -void func_80AF68E4(EnSa* this, GlobalContext* globalCtx); -void func_80AF6B20(EnSa* this, GlobalContext* globalCtx); - -typedef enum { - /* 0 */ SARIA_EYE_OPEN, - /* 1 */ SARIA_EYE_HALF, - /* 2 */ SARIA_EYE_CLOSED, - /* 3 */ SARIA_EYE_SUPRISED, - /* 4 */ SARIA_EYE_SAD -} SariaEyeState; - -typedef enum { - /* 0 */ SARIA_MOUTH_CLOSED2, - /* 1 */ SARIA_MOUTH_SUPRISED, - /* 2 */ SARIA_MOUTH_CLOSED, - /* 3 */ SARIA_MOUTH_SMILING_OPEN, - /* 4 */ SARIA_MOUTH_FROWNING -} SariaMouthState; - -const ActorInit En_Sa_InitVars = { - ACTOR_EN_SA, - ACTORCAT_NPC, - FLAGS, - OBJECT_SA, - sizeof(EnSa), - (ActorFunc)EnSa_Init, - (ActorFunc)EnSa_Destroy, - (ActorFunc)EnSa_Update, - (ActorFunc)EnSa_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 46, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { - 0, 0, 0, 0, MASS_IMMOVABLE, -}; - -static struct_D_80AA1678 sAnimationInfo[] = { - { &gSariaWaitArmsToSideAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &gSariaLookUpArmExtendedAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, - { &gSariaWaveAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, - { &gSariaRunAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, - { &gSariaWaitArmsToSideAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, - { &gSariaLookOverShoulderAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, - { &gSariaPlayingOcarinaAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, - { &gSariaStopPlayingOcarinaAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, - { &gSariaOcarinaToMouthAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, - { &gSariaLinkLearnedSariasSongAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, - { &gSariaReturnToOcarinaAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, - { &gSariaPlayingOcarinaAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, -}; - -static struct_80034EC0_Entry sAnimations[] = { - { &gSariaTransitionHandsSideToChestToSideAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gSariaTransitionHandsSideToBackAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -4.0f }, - { &gSariaRightArmExtendedWaitAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gSariaHandsOutAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gSariaStandHandsOnHipsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gSariaExtendRightArmAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gSariaTransitionHandsSideToHipsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gSariaHandsBehindBackWaitAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, - { &gSariaHandsOnFaceAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, - { &gSariaWaitArmsToSideAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, -}; - -s16 func_80AF5560(EnSa* this, GlobalContext* globalCtx) { - s16 textState = Message_GetState(&globalCtx->msgCtx); - - if (this->unk_209 == TEXT_STATE_AWAITING_NEXT || this->unk_209 == TEXT_STATE_EVENT || - this->unk_209 == TEXT_STATE_CLOSING || this->unk_209 == TEXT_STATE_DONE_HAS_NEXT) { - if (textState != this->unk_209) { - this->unk_208++; - } - } - this->unk_209 = textState; - return textState; -} - -u16 func_80AF55E0(GlobalContext* globalCtx, Actor* thisx) { - EnSa* this = (EnSa*)thisx; - u16 reaction = Text_GetFaceReaction(globalCtx, 0x10); - - if (reaction != 0) { - return reaction; - } - if (CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { - return 0x10AD; - } - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { - this->unk_208 = 0; - this->unk_209 = TEXT_STATE_NONE; - if (gSaveContext.infTable[0] & 0x20) { - return 0x1048; - } else { - return 0x1047; - } - } - if (gSaveContext.eventChkInf[0] & 4) { - this->unk_208 = 0; - this->unk_209 = TEXT_STATE_NONE; - if (gSaveContext.infTable[0] & 8) { - return 0x1032; - } else { - return 0x1031; - } - } - if (gSaveContext.infTable[0] & 1) { - this->unk_208 = 0; - this->unk_209 = TEXT_STATE_NONE; - if (gSaveContext.infTable[0] & 2) { - return 0x1003; - } else { - return 0x1002; - } - } - return 0x1001; -} - -s16 func_80AF56F4(GlobalContext* globalCtx, Actor* thisx) { - s16 ret = 1; - EnSa* this = (EnSa*)thisx; - - switch (func_80AF5560(this, globalCtx)) { - case TEXT_STATE_CLOSING: - switch (this->actor.textId) { - case 0x1002: - gSaveContext.infTable[0] |= 2; - ret = 0; - break; - case 0x1031: - gSaveContext.eventChkInf[0] |= 8; - gSaveContext.infTable[0] |= 8; - ret = 0; - break; - case 0x1047: - gSaveContext.infTable[0] |= 0x20; - ret = 0; - break; - default: - ret = 0; - break; - } - break; - case TEXT_STATE_NONE: - case TEXT_STATE_DONE_HAS_NEXT: - case TEXT_STATE_DONE_FADING: - case TEXT_STATE_CHOICE: - case TEXT_STATE_EVENT: - case TEXT_STATE_SONG_DEMO_DONE: - case TEXT_STATE_8: - case TEXT_STATE_9: - break; - } - return ret; -} - -void func_80AF57D8(EnSa* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum != SCENE_SPOT05 || - ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x1555 || this->unk_1E0.unk_00 != 0) { - func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, this->collider.dim.radius + 30.0f, func_80AF55E0, - func_80AF56F4); - } -} - -f32 func_80AF5894(EnSa* this) { - f32 endFrame = this->skelAnime.endFrame; - f32 startFrame = this->skelAnime.startFrame; - - this->skelAnime.startFrame = endFrame; - this->skelAnime.curFrame = endFrame; - this->skelAnime.endFrame = startFrame; - this->skelAnime.playSpeed = -1.0f; - return startFrame; -} - -void func_80AF58B8(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 2); - this->unk_20A++; - } - break; - } -} - -void func_80AF594C(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 8); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 9); - this->unk_20A++; - } - break; - } -} - -void func_80AF59E0(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 7); - this->unk_20A++; - } - break; - } -} - -void func_80AF5A74(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 1); - func_80AF5894(this); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 9); - this->unk_20A++; - } - break; - } -} - -void func_80AF5B10(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 6); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 4); - this->unk_20A++; - } - break; - } -} - -void func_80AF5BA4(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 6); - func_80AF5894(this); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 9); - this->unk_20A++; - } - break; - } -} - -void func_80AF5C40(EnSa* this) { - switch (this->unk_20A) { - case 0: - func_80034EC0(&this->skelAnime, sAnimations, 5); - this->unk_20A++; - case 1: - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80034EC0(&this->skelAnime, sAnimations, 0); - this->unk_20A++; - } - break; - } -} - -void func_80AF5CD4(EnSa* this, u8 arg1) { - this->unk_20B = arg1; - this->unk_20A = 0; -} - -void func_80AF5CE4(EnSa* this) { - switch (this->unk_20B) { - case 1: - func_80AF58B8(this); - break; - case 2: - func_80AF594C(this); - break; - case 3: - func_80AF59E0(this); - break; - case 4: - func_80AF5A74(this); - break; - case 5: - func_80AF5B10(this); - break; - case 6: - func_80AF5BA4(this); - break; - case 7: - func_80AF5C40(this); - break; - } -} - -void EnSa_ChangeAnim(EnSa* this, s32 action) { - Animation_Change(&this->skelAnime, sAnimationInfo[action].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[action].animation), sAnimationInfo[action].mode, - sAnimationInfo[action].transitionRate); -} - -s32 func_80AF5DFC(EnSa* this, GlobalContext* globalCtx) { - if (gSaveContext.cutsceneIndex >= 0xFFF0 && gSaveContext.cutsceneIndex != 0xFFFD) { - if (globalCtx->sceneNum == SCENE_SPOT04) { - return 4; - } - if (globalCtx->sceneNum == SCENE_SPOT05) { - return 5; - } - } - if (globalCtx->sceneNum == SCENE_KOKIRI_HOME5 && !LINK_IS_ADULT && - INV_CONTENT(ITEM_OCARINA_FAIRY) == ITEM_OCARINA_FAIRY && !(gSaveContext.eventChkInf[4] & 1)) { - return 1; - } - if (globalCtx->sceneNum == SCENE_SPOT05 && (gSaveContext.eventChkInf[4] & 1)) { - return CHECK_QUEST_ITEM(QUEST_SONG_SARIA) ? 2 : 5; - } - if (globalCtx->sceneNum == SCENE_SPOT04 && !CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { - if (gSaveContext.infTable[0] & 1) { - return 1; - } - return 4; - } - return 0; -} - -void func_80AF5F34(EnSa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 phi_a3 = 0; - - if (globalCtx->sceneNum == SCENE_SPOT04) { - phi_a3 = (this->actionFunc == func_80AF68E4) ? 1 : 4; - } - if (globalCtx->sceneNum == SCENE_SPOT05) { - phi_a3 = (this->skelAnime.animation == &gSariaPlayingOcarinaAnim) ? 1 : 3; - } - if (globalCtx->sceneNum == SCENE_SPOT05 && this->actionFunc == func_80AF6448 && - this->skelAnime.animation == &gSariaStopPlayingOcarinaAnim) { - phi_a3 = 1; - } - if (globalCtx->sceneNum == SCENE_SPOT05 && this->actionFunc == func_80AF68E4 && - this->skelAnime.animation == &gSariaOcarinaToMouthAnim) { - phi_a3 = 1; - } - this->unk_1E0.unk_18 = player->actor.world.pos; - this->unk_1E0.unk_14 = 4.0f; - func_80034A14(&this->actor, &this->unk_1E0, 2, phi_a3); -} - -s32 func_80AF603C(EnSa* this) { - if (this->skelAnime.animation != &gSariaPlayingOcarinaAnim && - this->skelAnime.animation != &gSariaOcarinaToMouthAnim) { - return 0; - } - if (this->unk_1E0.unk_00 != 0) { - return 0; - } - this->unk_20E = 0; - if (this->rightEyeIndex != SARIA_EYE_CLOSED) { - return 0; - } - return 1; -} - -void func_80AF609C(EnSa* this) { - s16 phi_v1; - - if (func_80AF603C(this) == 0) { - if (this->unk_20E == 0) { - phi_v1 = 0; - } else { - this->unk_20E--; - phi_v1 = this->unk_20E; - } - if (phi_v1 == 0) { - this->rightEyeIndex++; - if (this->rightEyeIndex < SARIA_EYE_SUPRISED) { - this->leftEyeIndex = this->rightEyeIndex; - } else { - this->unk_20E = Rand_S16Offset(30, 30); - this->leftEyeIndex = SARIA_EYE_OPEN; - this->rightEyeIndex = this->leftEyeIndex; - } - } - } -} - -void func_80AF6130(CsCmdActorAction* csAction, Vec3f* dst) { - dst->x = csAction->startPos.x; - dst->y = csAction->startPos.y; - dst->z = csAction->startPos.z; -} - -void func_80AF6170(CsCmdActorAction* csAction, Vec3f* dst) { - dst->x = csAction->endPos.x; - dst->y = csAction->endPos.y; - dst->z = csAction->endPos.z; -} - -void EnSa_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSa* this = (EnSa*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 12.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSariaSkel, NULL, this->jointTable, this->morphTable, 17); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - - switch (func_80AF5DFC(this, globalCtx)) { - case 2: - EnSa_ChangeAnim(this, 0xB); - this->actionFunc = func_80AF6448; - break; - case 5: - EnSa_ChangeAnim(this, 0xB); - this->actionFunc = func_80AF683C; - break; - case 1: - this->actor.gravity = -1.0f; - EnSa_ChangeAnim(this, 0); - this->actionFunc = func_80AF6448; - break; - case 4: - this->unk_210 = 0; - this->actor.gravity = -1.0f; - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gSpot04Cs_10E20); - gSaveContext.cutsceneTrigger = 1; - EnSa_ChangeAnim(this, 4); - this->actionFunc = func_80AF68E4; - break; - case 3: - this->unk_210 = 0; - this->actor.gravity = -1.0f; - EnSa_ChangeAnim(this, 0); - this->actionFunc = func_80AF68E4; - break; - case 0: - Actor_Kill(&this->actor); - return; - } - - Actor_SetScale(&this->actor, 0.01f); - - this->actor.targetMode = 6; - this->unk_1E0.unk_00 = 0; - this->alpha = 255; - this->unk_21A = this->actor.shape.rot; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); -} - -void EnSa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSa* this = (EnSa*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80AF6448(EnSa* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SPOT04) { - if (this->unk_1E0.unk_00 != 0) { - switch (this->actor.textId) { - case 0x1002: - if (this->unk_208 == 0 && this->unk_20B != 1) { - func_80AF5CD4(this, 1); - this->mouthIndex = 1; - } - if (this->unk_208 == 2 && this->unk_20B != 2) { - func_80AF5CD4(this, 2); - this->mouthIndex = 1; - } - if (this->unk_208 == 5) { - this->mouthIndex = 0; - } - break; - case 0x1003: - if (this->unk_208 == 0 && this->unk_20B != 4) { - func_80AF5CD4(this, 4); - } - break; - case 0x1031: - if (this->unk_208 == 0 && this->unk_20B != 4 && - this->skelAnime.animation == &gSariaHandsBehindBackWaitAnim) { - func_80AF5CD4(this, 4); - this->mouthIndex = 3; - } - if (this->unk_208 == 2 && this->unk_20B != 5) { - func_80AF5CD4(this, 5); - this->mouthIndex = 2; - } - if (this->unk_208 == 4 && this->unk_20B != 6) { - func_80AF5CD4(this, 6); - this->mouthIndex = 0; - } - break; - case 0x1032: - if (this->unk_208 == 0 && this->unk_20B != 4 && - this->skelAnime.animation == &gSariaHandsBehindBackWaitAnim) { - func_80AF5CD4(this, 4); - } - break; - case 0x1047: - if (this->unk_208 == 1 && this->unk_20B != 7) { - func_80AF5CD4(this, 7); - } - break; - case 0x1048: - if (this->unk_208 == 0 && this->unk_20B != 7) { - func_80AF5CD4(this, 7); - } - break; - } - } else if (!CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && - ((gSaveContext.infTable[0] & 2) || (gSaveContext.infTable[0] & 8))) { - if (this->unk_20B != 3) { - func_80AF5CD4(this, 3); - } - } else { - func_80AF5CD4(this, 0); - } - func_80AF5CE4(this); - } - if (this->skelAnime.animation == &gSariaStopPlayingOcarinaAnim) { - this->skelAnime.playSpeed = -1.0f; - if ((s32)this->skelAnime.curFrame == 0) { - EnSa_ChangeAnim(this, 6); - } - } - if (this->unk_1E0.unk_00 != 0 && globalCtx->sceneNum == SCENE_SPOT05) { - Animation_Change(&this->skelAnime, &gSariaStopPlayingOcarinaAnim, 1.0f, 0.0f, 10.0f, ANIMMODE_ONCE, -10.0f); - this->actionFunc = func_80AF67D0; - } -} - -void func_80AF67D0(EnSa* this, GlobalContext* globalCtx) { - if (this->unk_1E0.unk_00 == 0) { - Animation_Change(&this->skelAnime, &gSariaStopPlayingOcarinaAnim, 0.0f, 10.0f, 0.0f, ANIMMODE_ONCE, -10.0f); - this->actionFunc = func_80AF6448; - } -} - -void func_80AF683C(EnSa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (!(player->actor.world.pos.z >= -2220.0f) && !Gameplay_InCsMode(globalCtx)) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(spot05_scene_Cs_005730); - gSaveContext.cutsceneTrigger = 1; - this->actionFunc = func_80AF68E4; - } -} - -void func_80AF68E4(EnSa* this, GlobalContext* globalCtx) { - s16 phi_v0 = 0; - Vec3f startPos; - Vec3f endPos; - Vec3f D_80AF7448 = { 0.0f, 0.0f, 0.0f }; - CsCmdActorAction* csAction; - f32 temp_f0; - f32 gravity; - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - this->actionFunc = func_80AF6B20; - return; - } - csAction = globalCtx->csCtx.npcActions[1]; - if (csAction != NULL) { - func_80AF6130(csAction, &startPos); - func_80AF6170(csAction, &endPos); - - if (this->unk_210 == 0) { - this->actor.world.pos = startPos; - } - if (this->unk_210 != csAction->action) { - switch (csAction->action) { - case 2: - this->mouthIndex = 1; - break; - case 9: - this->mouthIndex = 1; - break; - default: - this->mouthIndex = 0; - break; - } - EnSa_ChangeAnim(this, csAction->action); - this->unk_210 = csAction->action; - } - if (phi_v0) {} - if (csAction->action == 3) { - if (this->unk_20C == 0) { - phi_v0 = 0; - } else { - this->unk_20C--; - phi_v0 = this->unk_20C; - } - if (phi_v0 == 0) { - Audio_PlaySoundGeneral(NA_SE_PL_WALK_GROUND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->unk_20C = 8; - } - } - this->actor.shape.rot.x = csAction->urot.x; - this->actor.shape.rot.y = csAction->urot.y; - this->actor.shape.rot.z = csAction->urot.z; - this->actor.velocity = D_80AF7448; - - if (globalCtx->csCtx.frames < csAction->endFrame) { - temp_f0 = csAction->endFrame - csAction->startFrame; - this->actor.velocity.x = (endPos.x - startPos.x) / temp_f0; - this->actor.velocity.y = (endPos.y - startPos.y) / temp_f0; - gravity = this->actor.gravity; - if (globalCtx->sceneNum == SCENE_SPOT05) { - gravity = 0.0f; - } - this->actor.velocity.y += gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } - this->actor.velocity.z = (endPos.z - startPos.z) / temp_f0; - } - } -} - -void func_80AF6B20(EnSa* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SPOT05) { - Item_Give(globalCtx, ITEM_SONG_SARIA); - EnSa_ChangeAnim(this, 6); - } - - if (globalCtx->sceneNum == SCENE_SPOT04) { - EnSa_ChangeAnim(this, 4); - this->actor.world.pos = this->actor.home.pos; - this->actor.world.rot = this->unk_21A; - this->mouthIndex = 0; - gSaveContext.infTable[0] |= 1; - } - - this->actionFunc = func_80AF6448; -} - -void EnSa_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSa* this = (EnSa*)thisx; - s32 pad; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - - if (this->skelAnime.animation == &gSariaOcarinaToMouthAnim && - this->skelAnime.curFrame >= Animation_GetLastFrame(&gSariaOcarinaToMouthAnim)) { - EnSa_ChangeAnim(this, 6); - } - - if (this->actionFunc != func_80AF68E4) { - this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, 400.0f); - } else { - this->alpha = 255; - } - - this->actor.shape.shadowAlpha = this->alpha; - - if (this->actionFunc == func_80AF68E4) { - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.world.pos.z += this->actor.velocity.z; - } else { - func_8002D7EC(&this->actor); - } - - if (globalCtx->sceneNum != SCENE_SPOT05) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - } - - func_80AF609C(this); - this->actionFunc(this, globalCtx); - func_80AF57D8(this, globalCtx); - func_80AF5F34(this, globalCtx); -} - -s32 EnSa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnSa* this = (EnSa*)thisx; - s32 pad; - Vec3s sp18; - - if (limbIndex == 16) { - Matrix_Translate(900.0f, 0.0f, 0.0f, MTXMODE_APPLY); - sp18 = this->unk_1E0.unk_08; - Matrix_RotateX(BINANG_TO_RAD(sp18.y), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD(sp18.x), MTXMODE_APPLY); - Matrix_Translate(-900.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } - - if (limbIndex == 9) { - sp18 = this->unk_1E0.unk_0E; - Matrix_RotateY(BINANG_TO_RAD(sp18.y), MTXMODE_APPLY); - Matrix_RotateX(BINANG_TO_RAD(sp18.x), MTXMODE_APPLY); - } - - if (globalCtx->sceneNum == SCENE_SPOT05 && limbIndex == 15) { - *dList = gSariaRightHandAndOcarinaDL; - } - - return 0; -} - -void EnSa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnSa* this = (EnSa*)thisx; - Vec3f D_80AF7454 = { 400.0, 0.0f, 0.0f }; - - if (limbIndex == 16) { - Matrix_MultVec3f(&D_80AF7454, &this->actor.focus.pos); - } -} - -void EnSa_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* mouthTextures[] = { - gSariaMouthClosed2Tex, gSariaMouthSmilingOpenTex, gSariaMouthFrowningTex, - gSariaMouthSuprisedTex, gSariaMouthClosedTex, - }; - static void* eyeTextures[] = { - gSariaEyeOpenTex, gSariaEyeHalfTex, gSariaEyeClosedTex, gSariaEyeSuprisedTex, gSariaEyeSadTex, - }; - EnSa* this = (EnSa*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sa.c", 1444); - - if (this->alpha == 255) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->rightEyeIndex])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[this->leftEyeIndex])); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTextures[this->mouthIndex])); - func_80034BA0(globalCtx, &this->skelAnime, EnSa_OverrideLimbDraw, EnSa_PostLimbDraw, &this->actor, this->alpha); - } else if (this->alpha != 0) { - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->rightEyeIndex])); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[this->leftEyeIndex])); - gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTextures[this->mouthIndex])); - func_80034CC4(globalCtx, &this->skelAnime, EnSa_OverrideLimbDraw, EnSa_PostLimbDraw, &this->actor, this->alpha); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sa.c", 1497); -} diff --git a/src/overlays/actors/ovl_En_Sa/z_en_sa.cpp b/src/overlays/actors/ovl_En_Sa/z_en_sa.cpp new file mode 100644 index 000000000..3aa298044 --- /dev/null +++ b/src/overlays/actors/ovl_En_Sa/z_en_sa.cpp @@ -0,0 +1,800 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SA_Z_EN_SA_C +#include "actor_common.h" +#include "z_en_sa.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "objects/object_sa/object_sa.h" +#include "scenes/overworld/spot04/spot04_scene.h" +#include "scenes/overworld/spot05/spot05_scene.h" +#include "def/code_800F7260.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25) + +void EnSa_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSa_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSa_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSa_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AF6448(EnSa* pthis, GlobalContext* globalCtx); +void func_80AF67D0(EnSa* pthis, GlobalContext* globalCtx); +void func_80AF683C(EnSa* pthis, GlobalContext* globalCtx); +void func_80AF68E4(EnSa* pthis, GlobalContext* globalCtx); +void func_80AF6B20(EnSa* pthis, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SARIA_EYE_OPEN, + /* 1 */ SARIA_EYE_HALF, + /* 2 */ SARIA_EYE_CLOSED, + /* 3 */ SARIA_EYE_SUPRISED, + /* 4 */ SARIA_EYE_SAD +} SariaEyeState; + +typedef enum { + /* 0 */ SARIA_MOUTH_CLOSED2, + /* 1 */ SARIA_MOUTH_SUPRISED, + /* 2 */ SARIA_MOUTH_CLOSED, + /* 3 */ SARIA_MOUTH_SMILING_OPEN, + /* 4 */ SARIA_MOUTH_FROWNING +} SariaMouthState; + +ActorInit En_Sa_InitVars = { + ACTOR_EN_SA, + ACTORCAT_NPC, + FLAGS, + OBJECT_SA, + sizeof(EnSa), + (ActorFunc)EnSa_Init, + (ActorFunc)EnSa_Destroy, + (ActorFunc)EnSa_Update, + (ActorFunc)EnSa_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 46, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { + 0, 0, 0, 0, MASS_IMMOVABLE, +}; + +static struct_D_80AA1678 sAnimationInfo[] = { + { &gSariaWaitArmsToSideAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSariaLookUpArmExtendedAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &gSariaWaveAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gSariaRunAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gSariaWaitArmsToSideAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gSariaLookOverShoulderAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gSariaPlayingOcarinaAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gSariaStopPlayingOcarinaAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &gSariaOcarinaToMouthAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &gSariaLinkLearnedSariasSongAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &gSariaReturnToOcarinaAnim, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &gSariaPlayingOcarinaAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, +}; + +static struct_80034EC0_Entry sAnimations[] = { + { &gSariaTransitionHandsSideToChestToSideAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gSariaTransitionHandsSideToBackAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -4.0f }, + { &gSariaRightArmExtendedWaitAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gSariaHandsOutAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gSariaStandHandsOnHipsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gSariaExtendRightArmAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gSariaTransitionHandsSideToHipsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gSariaHandsBehindBackWaitAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, + { &gSariaHandsOnFaceAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, + { &gSariaWaitArmsToSideAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, +}; + +s16 func_80AF5560(EnSa* pthis, GlobalContext* globalCtx) { + s16 textState = Message_GetState(&globalCtx->msgCtx); + + if (pthis->unk_209 == TEXT_STATE_AWAITING_NEXT || pthis->unk_209 == TEXT_STATE_EVENT || + pthis->unk_209 == TEXT_STATE_CLOSING || pthis->unk_209 == TEXT_STATE_DONE_HAS_NEXT) { + if (textState != pthis->unk_209) { + pthis->unk_208++; + } + } + pthis->unk_209 = textState; + return textState; +} + +u16 func_80AF55E0(GlobalContext* globalCtx, Actor* thisx) { + EnSa* pthis = (EnSa*)thisx; + u16 reaction = Text_GetFaceReaction(globalCtx, 0x10); + + if (reaction != 0) { + return reaction; + } + if (CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { + return 0x10AD; + } + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { + pthis->unk_208 = 0; + pthis->unk_209 = TEXT_STATE_NONE; + if (gSaveContext.infTable[0] & 0x20) { + return 0x1048; + } else { + return 0x1047; + } + } + if (gSaveContext.eventChkInf[0] & 4) { + pthis->unk_208 = 0; + pthis->unk_209 = TEXT_STATE_NONE; + if (gSaveContext.infTable[0] & 8) { + return 0x1032; + } else { + return 0x1031; + } + } + if (gSaveContext.infTable[0] & 1) { + pthis->unk_208 = 0; + pthis->unk_209 = TEXT_STATE_NONE; + if (gSaveContext.infTable[0] & 2) { + return 0x1003; + } else { + return 0x1002; + } + } + return 0x1001; +} + +s16 func_80AF56F4(GlobalContext* globalCtx, Actor* thisx) { + s16 ret = 1; + EnSa* pthis = (EnSa*)thisx; + + switch (func_80AF5560(pthis, globalCtx)) { + case TEXT_STATE_CLOSING: + switch (pthis->actor.textId) { + case 0x1002: + gSaveContext.infTable[0] |= 2; + ret = 0; + break; + case 0x1031: + gSaveContext.eventChkInf[0] |= 8; + gSaveContext.infTable[0] |= 8; + ret = 0; + break; + case 0x1047: + gSaveContext.infTable[0] |= 0x20; + ret = 0; + break; + default: + ret = 0; + break; + } + break; + case TEXT_STATE_NONE: + case TEXT_STATE_DONE_HAS_NEXT: + case TEXT_STATE_DONE_FADING: + case TEXT_STATE_CHOICE: + case TEXT_STATE_EVENT: + case TEXT_STATE_SONG_DEMO_DONE: + case TEXT_STATE_8: + case TEXT_STATE_9: + break; + } + return ret; +} + +void func_80AF57D8(EnSa* pthis, GlobalContext* globalCtx) { + if (globalCtx->sceneNum != SCENE_SPOT05 || + ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) < 0x1555 || pthis->unk_1E0.unk_00 != 0) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E0.unk_00, pthis->collider.dim.radius + 30.0f, func_80AF55E0, + func_80AF56F4); + } +} + +f32 func_80AF5894(EnSa* pthis) { + f32 endFrame = pthis->skelAnime.endFrame; + f32 startFrame = pthis->skelAnime.startFrame; + + pthis->skelAnime.startFrame = endFrame; + pthis->skelAnime.curFrame = endFrame; + pthis->skelAnime.endFrame = startFrame; + pthis->skelAnime.playSpeed = -1.0f; + return startFrame; +} + +void func_80AF58B8(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF594C(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 8); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 9); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF59E0(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 7); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF5A74(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + func_80AF5894(pthis); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 9); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF5B10(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 6); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF5BA4(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 6); + func_80AF5894(pthis); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 9); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF5C40(EnSa* pthis) { + switch (pthis->unk_20A) { + case 0: + func_80034EC0(&pthis->skelAnime, sAnimations, 5); + pthis->unk_20A++; + case 1: + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + pthis->unk_20A++; + } + break; + } +} + +void func_80AF5CD4(EnSa* pthis, u8 arg1) { + pthis->unk_20B = arg1; + pthis->unk_20A = 0; +} + +void func_80AF5CE4(EnSa* pthis) { + switch (pthis->unk_20B) { + case 1: + func_80AF58B8(pthis); + break; + case 2: + func_80AF594C(pthis); + break; + case 3: + func_80AF59E0(pthis); + break; + case 4: + func_80AF5A74(pthis); + break; + case 5: + func_80AF5B10(pthis); + break; + case 6: + func_80AF5BA4(pthis); + break; + case 7: + func_80AF5C40(pthis); + break; + } +} + +void EnSa_ChangeAnim(EnSa* pthis, s32 action) { + Animation_Change(&pthis->skelAnime, sAnimationInfo[action].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[action].animation), sAnimationInfo[action].mode, + sAnimationInfo[action].transitionRate); +} + +s32 func_80AF5DFC(EnSa* pthis, GlobalContext* globalCtx) { + if (gSaveContext.cutsceneIndex >= 0xFFF0 && gSaveContext.cutsceneIndex != 0xFFFD) { + if (globalCtx->sceneNum == SCENE_SPOT04) { + return 4; + } + if (globalCtx->sceneNum == SCENE_SPOT05) { + return 5; + } + } + if (globalCtx->sceneNum == SCENE_KOKIRI_HOME5 && !LINK_IS_ADULT && + INV_CONTENT(ITEM_OCARINA_FAIRY) == ITEM_OCARINA_FAIRY && !(gSaveContext.eventChkInf[4] & 1)) { + return 1; + } + if (globalCtx->sceneNum == SCENE_SPOT05 && (gSaveContext.eventChkInf[4] & 1)) { + return CHECK_QUEST_ITEM(QUEST_SONG_SARIA) ? 2 : 5; + } + if (globalCtx->sceneNum == SCENE_SPOT04 && !CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { + if (gSaveContext.infTable[0] & 1) { + return 1; + } + return 4; + } + return 0; +} + +void func_80AF5F34(EnSa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_a3 = 0; + + if (globalCtx->sceneNum == SCENE_SPOT04) { + phi_a3 = (pthis->actionFunc == func_80AF68E4) ? 1 : 4; + } + if (globalCtx->sceneNum == SCENE_SPOT05) { + phi_a3 = (pthis->skelAnime.animation == &gSariaPlayingOcarinaAnim) ? 1 : 3; + } + if (globalCtx->sceneNum == SCENE_SPOT05 && pthis->actionFunc == func_80AF6448 && + pthis->skelAnime.animation == &gSariaStopPlayingOcarinaAnim) { + phi_a3 = 1; + } + if (globalCtx->sceneNum == SCENE_SPOT05 && pthis->actionFunc == func_80AF68E4 && + pthis->skelAnime.animation == &gSariaOcarinaToMouthAnim) { + phi_a3 = 1; + } + pthis->unk_1E0.unk_18 = player->actor.world.pos; + pthis->unk_1E0.unk_14 = 4.0f; + func_80034A14(&pthis->actor, &pthis->unk_1E0, 2, phi_a3); +} + +s32 func_80AF603C(EnSa* pthis) { + if (pthis->skelAnime.animation != &gSariaPlayingOcarinaAnim && + pthis->skelAnime.animation != &gSariaOcarinaToMouthAnim) { + return 0; + } + if (pthis->unk_1E0.unk_00 != 0) { + return 0; + } + pthis->unk_20E = 0; + if (pthis->rightEyeIndex != SARIA_EYE_CLOSED) { + return 0; + } + return 1; +} + +void func_80AF609C(EnSa* pthis) { + s16 phi_v1; + + if (func_80AF603C(pthis) == 0) { + if (pthis->unk_20E == 0) { + phi_v1 = 0; + } else { + pthis->unk_20E--; + phi_v1 = pthis->unk_20E; + } + if (phi_v1 == 0) { + pthis->rightEyeIndex++; + if (pthis->rightEyeIndex < SARIA_EYE_SUPRISED) { + pthis->leftEyeIndex = pthis->rightEyeIndex; + } else { + pthis->unk_20E = Rand_S16Offset(30, 30); + pthis->leftEyeIndex = SARIA_EYE_OPEN; + pthis->rightEyeIndex = pthis->leftEyeIndex; + } + } + } +} + +void func_80AF6130(CsCmdActorAction* csAction, Vec3f* dst) { + dst->x = csAction->startPos.x; + dst->y = csAction->startPos.y; + dst->z = csAction->startPos.z; +} + +void func_80AF6170(CsCmdActorAction* csAction, Vec3f* dst) { + dst->x = csAction->endPos.x; + dst->y = csAction->endPos.y; + dst->z = csAction->endPos.z; +} + +void EnSa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSa* pthis = (EnSa*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 12.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSariaSkel, NULL, pthis->jointTable, pthis->morphTable, 17); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + + switch (func_80AF5DFC(pthis, globalCtx)) { + case 2: + EnSa_ChangeAnim(pthis, 0xB); + pthis->actionFunc = func_80AF6448; + break; + case 5: + EnSa_ChangeAnim(pthis, 0xB); + pthis->actionFunc = func_80AF683C; + break; + case 1: + pthis->actor.gravity = -1.0f; + EnSa_ChangeAnim(pthis, 0); + pthis->actionFunc = func_80AF6448; + break; + case 4: + pthis->unk_210 = 0; + pthis->actor.gravity = -1.0f; + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gSpot04Cs_10E20); + gSaveContext.cutsceneTrigger = 1; + EnSa_ChangeAnim(pthis, 4); + pthis->actionFunc = func_80AF68E4; + break; + case 3: + pthis->unk_210 = 0; + pthis->actor.gravity = -1.0f; + EnSa_ChangeAnim(pthis, 0); + pthis->actionFunc = func_80AF68E4; + break; + case 0: + Actor_Kill(&pthis->actor); + return; + } + + Actor_SetScale(&pthis->actor, 0.01f); + + pthis->actor.targetMode = 6; + pthis->unk_1E0.unk_00 = 0; + pthis->alpha = 255; + pthis->unk_21A = pthis->actor.shape.rot; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ELF, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); +} + +void EnSa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSa* pthis = (EnSa*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80AF6448(EnSa* pthis, GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SPOT04) { + if (pthis->unk_1E0.unk_00 != 0) { + switch (pthis->actor.textId) { + case 0x1002: + if (pthis->unk_208 == 0 && pthis->unk_20B != 1) { + func_80AF5CD4(pthis, 1); + pthis->mouthIndex = 1; + } + if (pthis->unk_208 == 2 && pthis->unk_20B != 2) { + func_80AF5CD4(pthis, 2); + pthis->mouthIndex = 1; + } + if (pthis->unk_208 == 5) { + pthis->mouthIndex = 0; + } + break; + case 0x1003: + if (pthis->unk_208 == 0 && pthis->unk_20B != 4) { + func_80AF5CD4(pthis, 4); + } + break; + case 0x1031: + if (pthis->unk_208 == 0 && pthis->unk_20B != 4 && + pthis->skelAnime.animation == &gSariaHandsBehindBackWaitAnim) { + func_80AF5CD4(pthis, 4); + pthis->mouthIndex = 3; + } + if (pthis->unk_208 == 2 && pthis->unk_20B != 5) { + func_80AF5CD4(pthis, 5); + pthis->mouthIndex = 2; + } + if (pthis->unk_208 == 4 && pthis->unk_20B != 6) { + func_80AF5CD4(pthis, 6); + pthis->mouthIndex = 0; + } + break; + case 0x1032: + if (pthis->unk_208 == 0 && pthis->unk_20B != 4 && + pthis->skelAnime.animation == &gSariaHandsBehindBackWaitAnim) { + func_80AF5CD4(pthis, 4); + } + break; + case 0x1047: + if (pthis->unk_208 == 1 && pthis->unk_20B != 7) { + func_80AF5CD4(pthis, 7); + } + break; + case 0x1048: + if (pthis->unk_208 == 0 && pthis->unk_20B != 7) { + func_80AF5CD4(pthis, 7); + } + break; + } + } else if (!CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && + ((gSaveContext.infTable[0] & 2) || (gSaveContext.infTable[0] & 8))) { + if (pthis->unk_20B != 3) { + func_80AF5CD4(pthis, 3); + } + } else { + func_80AF5CD4(pthis, 0); + } + func_80AF5CE4(pthis); + } + if (pthis->skelAnime.animation == &gSariaStopPlayingOcarinaAnim) { + pthis->skelAnime.playSpeed = -1.0f; + if ((s32)pthis->skelAnime.curFrame == 0) { + EnSa_ChangeAnim(pthis, 6); + } + } + if (pthis->unk_1E0.unk_00 != 0 && globalCtx->sceneNum == SCENE_SPOT05) { + Animation_Change(&pthis->skelAnime, &gSariaStopPlayingOcarinaAnim, 1.0f, 0.0f, 10.0f, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = func_80AF67D0; + } +} + +void func_80AF67D0(EnSa* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1E0.unk_00 == 0) { + Animation_Change(&pthis->skelAnime, &gSariaStopPlayingOcarinaAnim, 0.0f, 10.0f, 0.0f, ANIMMODE_ONCE, -10.0f); + pthis->actionFunc = func_80AF6448; + } +} + +void func_80AF683C(EnSa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->actor.world.pos.z >= -2220.0f) && !Gameplay_InCsMode(globalCtx)) { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(spot05_scene_Cs_005730); + gSaveContext.cutsceneTrigger = 1; + pthis->actionFunc = func_80AF68E4; + } +} + +void func_80AF68E4(EnSa* pthis, GlobalContext* globalCtx) { + s16 phi_v0 = 0; + Vec3f startPos; + Vec3f endPos; + Vec3f D_80AF7448 = { 0.0f, 0.0f, 0.0f }; + CsCmdActorAction* csAction; + f32 temp_f0; + f32 gravity; + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + pthis->actionFunc = func_80AF6B20; + return; + } + csAction = globalCtx->csCtx.npcActions[1]; + if (csAction != NULL) { + func_80AF6130(csAction, &startPos); + func_80AF6170(csAction, &endPos); + + if (pthis->unk_210 == 0) { + pthis->actor.world.pos = startPos; + } + if (pthis->unk_210 != csAction->action) { + switch (csAction->action) { + case 2: + pthis->mouthIndex = 1; + break; + case 9: + pthis->mouthIndex = 1; + break; + default: + pthis->mouthIndex = 0; + break; + } + EnSa_ChangeAnim(pthis, csAction->action); + pthis->unk_210 = csAction->action; + } + if (phi_v0) {} + if (csAction->action == 3) { + if (pthis->unk_20C == 0) { + phi_v0 = 0; + } else { + pthis->unk_20C--; + phi_v0 = pthis->unk_20C; + } + if (phi_v0 == 0) { + Audio_PlaySoundGeneral(NA_SE_PL_WALK_GROUND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->unk_20C = 8; + } + } + pthis->actor.shape.rot.x = csAction->urot.x; + pthis->actor.shape.rot.y = csAction->urot.y; + pthis->actor.shape.rot.z = csAction->urot.z; + pthis->actor.velocity = D_80AF7448; + + if (globalCtx->csCtx.frames < csAction->endFrame) { + temp_f0 = csAction->endFrame - csAction->startFrame; + pthis->actor.velocity.x = (endPos.x - startPos.x) / temp_f0; + pthis->actor.velocity.y = (endPos.y - startPos.y) / temp_f0; + gravity = pthis->actor.gravity; + if (globalCtx->sceneNum == SCENE_SPOT05) { + gravity = 0.0f; + } + pthis->actor.velocity.y += gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } + pthis->actor.velocity.z = (endPos.z - startPos.z) / temp_f0; + } + } +} + +void func_80AF6B20(EnSa* pthis, GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SPOT05) { + Item_Give(globalCtx, ITEM_SONG_SARIA); + EnSa_ChangeAnim(pthis, 6); + } + + if (globalCtx->sceneNum == SCENE_SPOT04) { + EnSa_ChangeAnim(pthis, 4); + pthis->actor.world.pos = pthis->actor.home.pos; + pthis->actor.world.rot = pthis->unk_21A; + pthis->mouthIndex = 0; + gSaveContext.infTable[0] |= 1; + } + + pthis->actionFunc = func_80AF6448; +} + +void EnSa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSa* pthis = (EnSa*)thisx; + s32 pad; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->skelAnime.animation == &gSariaOcarinaToMouthAnim && + pthis->skelAnime.curFrame >= Animation_GetLastFrame(&gSariaOcarinaToMouthAnim)) { + EnSa_ChangeAnim(pthis, 6); + } + + if (pthis->actionFunc != func_80AF68E4) { + pthis->alpha = func_80034DD4(&pthis->actor, globalCtx, pthis->alpha, 400.0f); + } else { + pthis->alpha = 255; + } + + pthis->actor.shape.shadowAlpha = pthis->alpha; + + if (pthis->actionFunc == func_80AF68E4) { + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.world.pos.z += pthis->actor.velocity.z; + } else { + func_8002D7EC(&pthis->actor); + } + + if (globalCtx->sceneNum != SCENE_SPOT05) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + } + + func_80AF609C(pthis); + pthis->actionFunc(pthis, globalCtx); + func_80AF57D8(pthis, globalCtx); + func_80AF5F34(pthis, globalCtx); +} + +s32 EnSa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnSa* pthis = (EnSa*)thisx; + s32 pad; + Vec3s sp18; + + if (limbIndex == 16) { + Matrix_Translate(900.0f, 0.0f, 0.0f, MTXMODE_APPLY); + sp18 = pthis->unk_1E0.unk_08; + Matrix_RotateX(BINANG_TO_RAD(sp18.y), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD(sp18.x), MTXMODE_APPLY); + Matrix_Translate(-900.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == 9) { + sp18 = pthis->unk_1E0.unk_0E; + Matrix_RotateY(BINANG_TO_RAD(sp18.y), MTXMODE_APPLY); + Matrix_RotateX(BINANG_TO_RAD(sp18.x), MTXMODE_APPLY); + } + + if (globalCtx->sceneNum == SCENE_SPOT05 && limbIndex == 15) { + *dList = gSariaRightHandAndOcarinaDL; + } + + return 0; +} + +void EnSa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + EnSa* pthis = (EnSa*)thisx; + Vec3f D_80AF7454 = { 400.0, 0.0f, 0.0f }; + + if (limbIndex == 16) { + Matrix_MultVec3f(&D_80AF7454, &pthis->actor.focus.pos); + } +} + +void EnSa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* mouthTextures[] = { + gSariaMouthClosed2Tex, gSariaMouthSmilingOpenTex, gSariaMouthFrowningTex, + gSariaMouthSuprisedTex, gSariaMouthClosedTex, + }; + static void* eyeTextures[] = { + gSariaEyeOpenTex, gSariaEyeHalfTex, gSariaEyeClosedTex, gSariaEyeSuprisedTex, gSariaEyeSadTex, + }; + EnSa* pthis = (EnSa*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sa.c", 1444); + + if (pthis->alpha == 255) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->rightEyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->leftEyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTextures[pthis->mouthIndex])); + func_80034BA0(globalCtx, &pthis->skelAnime, EnSa_OverrideLimbDraw, EnSa_PostLimbDraw, &pthis->actor, pthis->alpha); + } else if (pthis->alpha != 0) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->rightEyeIndex])); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->leftEyeIndex])); + gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTextures[pthis->mouthIndex])); + func_80034CC4(globalCtx, &pthis->skelAnime, EnSa_OverrideLimbDraw, EnSa_PostLimbDraw, &pthis->actor, pthis->alpha); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sa.c", 1497); +} diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c deleted file mode 100644 index 9d1919302..000000000 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ /dev/null @@ -1,512 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SB_Z_EN_SB_C -#include "actor_common.h" -/* - * File: z_en_sb.c - * Overlay: ovl_En_Sb - * Description: Shellblade - */ - -#include "z_en_sb.h" -#include "vt.h" -#include "objects/object_sb/object_sb.h" -#include "def/code_8006BA00.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnSb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnSb_SetupWaitClosed(EnSb* this); - -void EnSb_WaitClosed(EnSb* this, GlobalContext* globalCtx); -void EnSb_Open(EnSb* this, GlobalContext* globalCtx); -void EnSb_WaitOpen(EnSb* this, GlobalContext* globalCtx); -void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx); -void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx); -void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx); -void EnSb_Cooldown(EnSb* this, GlobalContext* globalCtx); - -const ActorInit En_Sb_InitVars = { - ACTOR_EN_SB, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_SB, - sizeof(EnSb), - (ActorFunc)EnSb_Init, - (ActorFunc)EnSb_Destroy, - (ActorFunc)EnSb_Update, - (ActorFunc)EnSb_Draw, -}; - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - COLSHAPE_CYLINDER, - }, - { 0x00, { 0xFFCFFFFF, 0x04, 0x08 }, { 0xFFCFFFFF, 0x00, 0x00 }, 0x01, 0x01, 0x01 }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable[] = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(2, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(2, 0xF), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(2, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0xD), - /* Master sword */ DMG_ENTRY(2, 0xD), - /* Giant's Knife */ DMG_ENTRY(4, 0xD), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0xF), - /* Light arrow */ DMG_ENTRY(2, 0xF), - /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), - /* Unk arrow 2 */ DMG_ENTRY(2, 0xF), - /* Unk arrow 3 */ DMG_ENTRY(2, 0xF), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0xD), - /* Giant spin */ DMG_ENTRY(4, 0xD), - /* Master spin */ DMG_ENTRY(2, 0xD), - /* Kokiri jump */ DMG_ENTRY(2, 0xD), - /* Giant jump */ DMG_ENTRY(8, 0xD), - /* Master jump */ DMG_ENTRY(4, 0xD), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x27, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -static Vec3f sFlamePosOffsets[] = { - { 5.0f, 0.0f, 0.0f }, - { -5.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 5.0f }, - { 0.0f, 0.0f, -5.0f }, -}; - -typedef enum { - /* 0x00 */ SHELLBLADE_OPEN, - /* 0x01 */ SHELLBLADE_WAIT_CLOSED, - /* 0x02 */ SHELLBLADE_WAIT_OPEN, - /* 0x03 */ SHELLBLADE_LUNGE, - /* 0x04 */ SHELLBLADE_BOUNCE -} ShellbladeBehavior; - -void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSb* this = (EnSb*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = sDamageTable; - this->actor.colChkInfo.health = 2; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sb_Skel_002BF0, &object_sb_Anim_000194, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->isDead = false; - this->actor.colChkInfo.mass = 0; - Actor_SetScale(&this->actor, 0.006f); - this->actor.shape.rot.y = 0; - this->actor.speedXZ = 0.0f; - this->actor.gravity = -0.35f; - this->fire = 0; - this->hitByWindArrow = false; - this->actor.velocity.y = -1.0f; - EnSb_SetupWaitClosed(this); -} - -void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSb* this = (EnSb*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnSb_SpawnBubbles(GlobalContext* globalCtx, EnSb* this) { - s32 i; - - if (this->actor.yDistToWater > 0) { - for (i = 0; i < 10; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 10.0f, 10.0f, 30.0f, 0.25f); - } - } -} - -void EnSb_SetupWaitClosed(EnSb* this) { - Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_00004C), - ANIMMODE_ONCE, 0.0f); - this->behavior = SHELLBLADE_WAIT_CLOSED; - this->actionFunc = EnSb_WaitClosed; -} - -void EnSb_SetupOpen(EnSb* this) { - Animation_Change(&this->skelAnime, &object_sb_Anim_000194, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_000194), - ANIMMODE_ONCE, 0.0f); - this->behavior = SHELLBLADE_OPEN; - this->actionFunc = EnSb_Open; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHELL_MOUTH); -} - -void EnSb_SetupWaitOpen(EnSb* this) { - Animation_Change(&this->skelAnime, &object_sb_Anim_002C8C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_002C8C), - ANIMMODE_LOOP, 0.0f); - this->behavior = SHELLBLADE_WAIT_OPEN; - this->actionFunc = EnSb_WaitOpen; -} - -void EnSb_SetupLunge(EnSb* this) { - f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_000124); - f32 playbackSpeed = this->actor.yDistToWater > 0.0f ? 1.0f : 0.0f; - - Animation_Change(&this->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0); - this->behavior = SHELLBLADE_LUNGE; - this->actionFunc = EnSb_Lunge; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SHELL_MOUTH); -} - -void EnSb_SetupBounce(EnSb* this) { - Animation_Change(&this->skelAnime, &object_sb_Anim_0000B4, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_0000B4), - ANIMMODE_ONCE, 0.0f); - this->behavior = SHELLBLADE_BOUNCE; - this->actionFunc = EnSb_Bounce; -} - -void EnSb_SetupCooldown(EnSb* this, s32 changeSpeed) { - f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_00004C); - - if (this->behavior != SHELLBLADE_WAIT_CLOSED) { - Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, frameCount, ANIMMODE_ONCE, 0.0f); - } - this->behavior = SHELLBLADE_WAIT_CLOSED; - if (changeSpeed) { - if (this->actor.yDistToWater > 0.0f) { - this->actor.speedXZ = -5.0f; - if (this->actor.velocity.y < 0.0f) { - this->actor.velocity.y = 2.1f; - } - } else { - this->actor.speedXZ = -6.0f; - if (this->actor.velocity.y < 0.0f) { - this->actor.velocity.y = 1.4f; - } - } - } - this->timer = 60; - this->actionFunc = EnSb_Cooldown; -} - -void EnSb_WaitClosed(EnSb* this, GlobalContext* globalCtx) { - // always face toward link - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x7D0, 0x0); - - if ((this->actor.xzDistToPlayer <= 160.0f) && (this->actor.xzDistToPlayer > 40.0f)) { - EnSb_SetupOpen(this); - } -} - -void EnSb_Open(EnSb* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.curFrame; - - if (Animation_GetLastFrame(&object_sb_Anim_000194) <= currentFrame) { - this->timer = 15; - EnSb_SetupWaitOpen(this); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x7D0, 0x0); - if ((this->actor.xzDistToPlayer > 160.0f) || (this->actor.xzDistToPlayer <= 40.0f)) { - EnSb_SetupWaitClosed(this); - } - } -} - -void EnSb_WaitOpen(EnSb* this, GlobalContext* globalCtx) { - s16 timer = this->timer; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x7D0, 0x0); - - if ((this->actor.xzDistToPlayer > 160.0f) || (this->actor.xzDistToPlayer <= 40.0f)) { - EnSb_SetupWaitClosed(this); - } - - if (timer != 0) { - this->timer = timer - 1; - } else { - this->timer = 0; - this->attackYaw = this->actor.yawTowardsPlayer; - this->actionFunc = EnSb_TurnAround; - } -} - -void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx) { - s16 invertedYaw; - - invertedYaw = this->attackYaw + 0x8000; - Math_SmoothStepToS(&this->actor.shape.rot.y, invertedYaw, 0x1, 0x1F40, 0xA); - - if (this->actor.shape.rot.y == invertedYaw) { - this->actor.world.rot.y = this->attackYaw; - if (this->actor.yDistToWater > 0.0f) { - this->actor.velocity.y = 3.0f; - this->actor.speedXZ = 5.0f; - this->actor.gravity = -0.35f; - } else { - this->actor.velocity.y = 2.0f; - this->actor.speedXZ = 6.0f; - this->actor.gravity = -2.0f; - } - EnSb_SpawnBubbles(globalCtx, this); - this->bouncesLeft = 3; - EnSb_SetupLunge(this); - // "Attack!!" - osSyncPrintf("アタァ〜ック!!\n"); - } -} - -void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); - if ((this->actor.velocity.y <= -0.1f) || ((this->actor.bgCheckFlags & 2))) { - if (!(this->actor.yDistToWater > 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - this->actor.bgCheckFlags = this->actor.bgCheckFlags & ~2; - EnSb_SetupBounce(this); - } -} - -void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx) { - s32 pad; - f32 currentFrame; - f32 frameCount; - - currentFrame = this->skelAnime.curFrame; - frameCount = Animation_GetLastFrame(&object_sb_Anim_0000B4); - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); - - if (currentFrame == frameCount) { - if (this->bouncesLeft != 0) { - this->bouncesLeft--; - this->timer = 1; - if (this->actor.yDistToWater > 0.0f) { - this->actor.velocity.y = 3.0f; - this->actor.speedXZ = 5.0f; - this->actor.gravity = -0.35f; - } else { - this->actor.velocity.y = 2.0f; - this->actor.speedXZ = 6.0f; - this->actor.gravity = -2.0f; - } - EnSb_SpawnBubbles(globalCtx, this); - EnSb_SetupLunge(this); - } else if (this->actor.bgCheckFlags & 1) { - this->actor.bgCheckFlags &= ~2; - this->actor.speedXZ = 0.0f; - this->timer = 1; - EnSb_SetupWaitClosed(this); - osSyncPrintf(VT_FGCOL(RED) "攻撃終了!!" VT_RST "\n"); // "Attack Complete!" - } - } -} - -void EnSb_Cooldown(EnSb* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - if (this->actor.bgCheckFlags & 1) { - this->actor.bgCheckFlags &= ~1; - this->actor.speedXZ = 0.0f; - } - } else { - if (this->actor.bgCheckFlags & 1) { - this->actor.bgCheckFlags &= ~1; - this->actionFunc = EnSb_WaitClosed; - this->actor.speedXZ = 0.0f; - } - } -} - -s32 EnSb_IsVulnerable(EnSb* this) { - switch (this->behavior) { - case SHELLBLADE_OPEN: - if ((this->skelAnime.curFrame >= 2.0f) && (this->skelAnime.curFrame <= 5.0f)) { - return true; - } - break; - case SHELLBLADE_WAIT_CLOSED: - if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 1.0f)) { - return true; - } - break; - case SHELLBLADE_WAIT_OPEN: - if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 19.0f)) { - return true; - } - break; - case SHELLBLADE_LUNGE: - if (this->skelAnime.curFrame == 0.0f) { - return true; - } - break; - case SHELLBLADE_BOUNCE: - if ((this->skelAnime.curFrame >= 3.0f) && (this->skelAnime.curFrame <= 5.0f)) { - return true; - } - break; - } - return false; -} - -s32 EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { - Vec3f hitPoint; - f32 hitY; - s16 yawDiff; - s32 tookDamage; - u8 hitByWindArrow; - - // hit box collided, switch to cool down - if ((this->collider.base.atFlags & AT_HIT)) { - EnSb_SetupCooldown(this, 1); - return 1; - } - - // hurt box collided, take damage if appropriate - if ((this->collider.base.acFlags & AC_HIT)) { - hitByWindArrow = false; - tookDamage = false; - this->collider.base.acFlags &= ~AC_HIT; - - switch (this->actor.colChkInfo.damageEffect) { - case 14: // wind arrow - hitByWindArrow = true; - case 15: // explosions, arrow, hammer, ice arrow, light arrow, spirit arrow, shadow arrow - if (EnSb_IsVulnerable(this)) { - hitY = this->collider.info.bumper.hitPos.y - this->actor.world.pos.y; - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((hitY < 30.0f) && (hitY > 10.0f) && (yawDiff >= -0x1FFF) && (yawDiff < 0x2000)) { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - tookDamage = true; - } - } - break; - case 2: // fire arrow, dins fire - this->fire = 4; - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - tookDamage = true; - break; - case 1: // hookshot/longshot - case 13: // all sword damage - if (EnSb_IsVulnerable(this)) { - hitY = this->collider.info.bumper.hitPos.y - this->actor.world.pos.y; - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((hitY < 30.0f) && (hitY > 10.0f) && (yawDiff >= -0x1FFF) && (yawDiff < 0x2000)) { - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0x50); - tookDamage = true; - EnSb_SetupCooldown(this, 0); - } - } - break; - default: - break; - } - if (this->actor.colChkInfo.health == 0) { - this->hitByWindArrow = hitByWindArrow; - BodyBreak_Alloc(&this->bodyBreak, 8, globalCtx); - this->isDead = true; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_SHELL_DEAD); - return 1; - } - - // if player attack didn't do damage, play recoil sound and spawn sparks - if (!tookDamage) { - hitPoint.x = this->collider.info.bumper.hitPos.x; - hitPoint.y = this->collider.info.bumper.hitPos.y; - hitPoint.z = this->collider.info.bumper.hitPos.z; - CollisionCheck_SpawnShieldParticlesMetal2(globalCtx, &hitPoint); - } - } - - return 0; -} - -void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSb* this = (EnSb*)thisx; - s32 pad; - - if (this->isDead) { - if (this->actor.yDistToWater > 0.0f) { - this->actor.params = 4; - } else { - this->actor.params = 1; - } - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params)) { - if (!this->hitByWindArrow) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, 8); - } - Actor_Kill(&this->actor); - } - } else { - Actor_SetFocus(&this->actor, 20.0f); - Actor_SetScale(&this->actor, 0.006f); - Actor_MoveForward(&this->actor); - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); - EnSb_UpdateDamage(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - } -} - -void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnSb* this = (EnSb*)thisx; - - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 6, 8, dList, BODYBREAK_OBJECT_DEFAULT); -} - -void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSb* this = (EnSb*)thisx; - Vec3f flamePos; - Vec3f* offset; - s16 fireDecr; - - func_8002EBCC(&this->actor, globalCtx, 1); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnSb_PostLimbDraw, this); - if (this->fire != 0) { - this->actor.colorFilterTimer++; - fireDecr = this->fire - 1; - // this is intended to draw flames after being burned, but the condition is never met to run this code - // fire gets set to 4 when burned, decrements to 3 and fails the "& 1" check and never stores the decrement - if ((fireDecr & 1) == 0) { - offset = &sFlamePosOffsets[(fireDecr & 3)]; - flamePos.x = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.x + offset->x); - flamePos.y = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.y + offset->y); - flamePos.z = Rand_CenteredFloat(5.0f) + (this->actor.world.pos.z + offset->z); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &flamePos, 100, 0, 0, -1); - } - } -} diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.cpp b/src/overlays/actors/ovl_En_Sb/z_en_sb.cpp new file mode 100644 index 000000000..9cb8db970 --- /dev/null +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.cpp @@ -0,0 +1,512 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SB_Z_EN_SB_C +#include "actor_common.h" +/* + * File: z_en_sb.c + * Overlay: ovl_En_Sb + * Description: Shellblade + */ + +#include "z_en_sb.h" +#include "vt.h" +#include "objects/object_sb/object_sb.h" +#include "def/code_8006BA00.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnSb_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSb_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSb_SetupWaitClosed(EnSb* pthis); + +void EnSb_WaitClosed(EnSb* pthis, GlobalContext* globalCtx); +void EnSb_Open(EnSb* pthis, GlobalContext* globalCtx); +void EnSb_WaitOpen(EnSb* pthis, GlobalContext* globalCtx); +void EnSb_TurnAround(EnSb* pthis, GlobalContext* globalCtx); +void EnSb_Lunge(EnSb* pthis, GlobalContext* globalCtx); +void EnSb_Bounce(EnSb* pthis, GlobalContext* globalCtx); +void EnSb_Cooldown(EnSb* pthis, GlobalContext* globalCtx); + +ActorInit En_Sb_InitVars = { + ACTOR_EN_SB, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_SB, + sizeof(EnSb), + (ActorFunc)EnSb_Init, + (ActorFunc)EnSb_Destroy, + (ActorFunc)EnSb_Update, + (ActorFunc)EnSb_Draw, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { 0x00, { 0xFFCFFFFF, 0x04, 0x08 }, { 0xFFCFFFFF, 0x00, 0x00 }, 0x01, 0x01, 0x01 }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable[] = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(2, 0xF), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(2, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0xD), + /* Master sword */ DMG_ENTRY(2, 0xD), + /* Giant's Knife */ DMG_ENTRY(4, 0xD), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(2, 0xF), + /* Light arrow */ DMG_ENTRY(2, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(4, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xF), + /* Unk arrow 3 */ DMG_ENTRY(2, 0xF), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xD), + /* Giant spin */ DMG_ENTRY(4, 0xD), + /* Master spin */ DMG_ENTRY(2, 0xD), + /* Kokiri jump */ DMG_ENTRY(2, 0xD), + /* Giant jump */ DMG_ENTRY(8, 0xD), + /* Master jump */ DMG_ENTRY(4, 0xD), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x27, ICHAIN_CONTINUE), + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +static Vec3f sFlamePosOffsets[] = { + { 5.0f, 0.0f, 0.0f }, + { -5.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 5.0f }, + { 0.0f, 0.0f, -5.0f }, +}; + +typedef enum { + /* 0x00 */ SHELLBLADE_OPEN, + /* 0x01 */ SHELLBLADE_WAIT_CLOSED, + /* 0x02 */ SHELLBLADE_WAIT_OPEN, + /* 0x03 */ SHELLBLADE_LUNGE, + /* 0x04 */ SHELLBLADE_BOUNCE +} ShellbladeBehavior; + +void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSb* pthis = (EnSb*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = sDamageTable; + pthis->actor.colChkInfo.health = 2; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_sb_Skel_002BF0, &object_sb_Anim_000194, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->isDead = false; + pthis->actor.colChkInfo.mass = 0; + Actor_SetScale(&pthis->actor, 0.006f); + pthis->actor.shape.rot.y = 0; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = -0.35f; + pthis->fire = 0; + pthis->hitByWindArrow = false; + pthis->actor.velocity.y = -1.0f; + EnSb_SetupWaitClosed(pthis); +} + +void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSb* pthis = (EnSb*)thisx; + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnSb_SpawnBubbles(GlobalContext* globalCtx, EnSb* pthis) { + s32 i; + + if (pthis->actor.yDistToWater > 0) { + for (i = 0; i < 10; i++) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 10.0f, 10.0f, 30.0f, 0.25f); + } + } +} + +void EnSb_SetupWaitClosed(EnSb* pthis) { + Animation_Change(&pthis->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_00004C), + ANIMMODE_ONCE, 0.0f); + pthis->behavior = SHELLBLADE_WAIT_CLOSED; + pthis->actionFunc = EnSb_WaitClosed; +} + +void EnSb_SetupOpen(EnSb* pthis) { + Animation_Change(&pthis->skelAnime, &object_sb_Anim_000194, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_000194), + ANIMMODE_ONCE, 0.0f); + pthis->behavior = SHELLBLADE_OPEN; + pthis->actionFunc = EnSb_Open; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHELL_MOUTH); +} + +void EnSb_SetupWaitOpen(EnSb* pthis) { + Animation_Change(&pthis->skelAnime, &object_sb_Anim_002C8C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_002C8C), + ANIMMODE_LOOP, 0.0f); + pthis->behavior = SHELLBLADE_WAIT_OPEN; + pthis->actionFunc = EnSb_WaitOpen; +} + +void EnSb_SetupLunge(EnSb* pthis) { + f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_000124); + f32 playbackSpeed = pthis->actor.yDistToWater > 0.0f ? 1.0f : 0.0f; + + Animation_Change(&pthis->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0); + pthis->behavior = SHELLBLADE_LUNGE; + pthis->actionFunc = EnSb_Lunge; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_SHELL_MOUTH); +} + +void EnSb_SetupBounce(EnSb* pthis) { + Animation_Change(&pthis->skelAnime, &object_sb_Anim_0000B4, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_0000B4), + ANIMMODE_ONCE, 0.0f); + pthis->behavior = SHELLBLADE_BOUNCE; + pthis->actionFunc = EnSb_Bounce; +} + +void EnSb_SetupCooldown(EnSb* pthis, s32 changeSpeed) { + f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_00004C); + + if (pthis->behavior != SHELLBLADE_WAIT_CLOSED) { + Animation_Change(&pthis->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, frameCount, ANIMMODE_ONCE, 0.0f); + } + pthis->behavior = SHELLBLADE_WAIT_CLOSED; + if (changeSpeed) { + if (pthis->actor.yDistToWater > 0.0f) { + pthis->actor.speedXZ = -5.0f; + if (pthis->actor.velocity.y < 0.0f) { + pthis->actor.velocity.y = 2.1f; + } + } else { + pthis->actor.speedXZ = -6.0f; + if (pthis->actor.velocity.y < 0.0f) { + pthis->actor.velocity.y = 1.4f; + } + } + } + pthis->timer = 60; + pthis->actionFunc = EnSb_Cooldown; +} + +void EnSb_WaitClosed(EnSb* pthis, GlobalContext* globalCtx) { + // always face toward link + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, 0x7D0, 0x0); + + if ((pthis->actor.xzDistToPlayer <= 160.0f) && (pthis->actor.xzDistToPlayer > 40.0f)) { + EnSb_SetupOpen(pthis); + } +} + +void EnSb_Open(EnSb* pthis, GlobalContext* globalCtx) { + f32 currentFrame = pthis->skelAnime.curFrame; + + if (Animation_GetLastFrame(&object_sb_Anim_000194) <= currentFrame) { + pthis->timer = 15; + EnSb_SetupWaitOpen(pthis); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, 0x7D0, 0x0); + if ((pthis->actor.xzDistToPlayer > 160.0f) || (pthis->actor.xzDistToPlayer <= 40.0f)) { + EnSb_SetupWaitClosed(pthis); + } + } +} + +void EnSb_WaitOpen(EnSb* pthis, GlobalContext* globalCtx) { + s16 timer = pthis->timer; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, 0x7D0, 0x0); + + if ((pthis->actor.xzDistToPlayer > 160.0f) || (pthis->actor.xzDistToPlayer <= 40.0f)) { + EnSb_SetupWaitClosed(pthis); + } + + if (timer != 0) { + pthis->timer = timer - 1; + } else { + pthis->timer = 0; + pthis->attackYaw = pthis->actor.yawTowardsPlayer; + pthis->actionFunc = EnSb_TurnAround; + } +} + +void EnSb_TurnAround(EnSb* pthis, GlobalContext* globalCtx) { + s16 invertedYaw; + + invertedYaw = pthis->attackYaw + 0x8000; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, invertedYaw, 0x1, 0x1F40, 0xA); + + if (pthis->actor.shape.rot.y == invertedYaw) { + pthis->actor.world.rot.y = pthis->attackYaw; + if (pthis->actor.yDistToWater > 0.0f) { + pthis->actor.velocity.y = 3.0f; + pthis->actor.speedXZ = 5.0f; + pthis->actor.gravity = -0.35f; + } else { + pthis->actor.velocity.y = 2.0f; + pthis->actor.speedXZ = 6.0f; + pthis->actor.gravity = -2.0f; + } + EnSb_SpawnBubbles(globalCtx, pthis); + pthis->bouncesLeft = 3; + EnSb_SetupLunge(pthis); + // "Attack!!" + osSyncPrintf("アタァ〜ック!!\n"); + } +} + +void EnSb_Lunge(EnSb* pthis, GlobalContext* globalCtx) { + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.2f); + if ((pthis->actor.velocity.y <= -0.1f) || ((pthis->actor.bgCheckFlags & 2))) { + if (!(pthis->actor.yDistToWater > 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + pthis->actor.bgCheckFlags = pthis->actor.bgCheckFlags & ~2; + EnSb_SetupBounce(pthis); + } +} + +void EnSb_Bounce(EnSb* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 currentFrame; + f32 frameCount; + + currentFrame = pthis->skelAnime.curFrame; + frameCount = Animation_GetLastFrame(&object_sb_Anim_0000B4); + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.2f); + + if (currentFrame == frameCount) { + if (pthis->bouncesLeft != 0) { + pthis->bouncesLeft--; + pthis->timer = 1; + if (pthis->actor.yDistToWater > 0.0f) { + pthis->actor.velocity.y = 3.0f; + pthis->actor.speedXZ = 5.0f; + pthis->actor.gravity = -0.35f; + } else { + pthis->actor.velocity.y = 2.0f; + pthis->actor.speedXZ = 6.0f; + pthis->actor.gravity = -2.0f; + } + EnSb_SpawnBubbles(globalCtx, pthis); + EnSb_SetupLunge(pthis); + } else if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.bgCheckFlags &= ~2; + pthis->actor.speedXZ = 0.0f; + pthis->timer = 1; + EnSb_SetupWaitClosed(pthis); + osSyncPrintf(VT_FGCOL(RED) "攻撃終了!!" VT_RST "\n"); // "Attack Complete!" + } + } +} + +void EnSb_Cooldown(EnSb* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.bgCheckFlags &= ~1; + pthis->actor.speedXZ = 0.0f; + } + } else { + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.bgCheckFlags &= ~1; + pthis->actionFunc = EnSb_WaitClosed; + pthis->actor.speedXZ = 0.0f; + } + } +} + +s32 EnSb_IsVulnerable(EnSb* pthis) { + switch (pthis->behavior) { + case SHELLBLADE_OPEN: + if ((pthis->skelAnime.curFrame >= 2.0f) && (pthis->skelAnime.curFrame <= 5.0f)) { + return true; + } + break; + case SHELLBLADE_WAIT_CLOSED: + if ((pthis->skelAnime.curFrame >= 0.0f) && (pthis->skelAnime.curFrame <= 1.0f)) { + return true; + } + break; + case SHELLBLADE_WAIT_OPEN: + if ((pthis->skelAnime.curFrame >= 0.0f) && (pthis->skelAnime.curFrame <= 19.0f)) { + return true; + } + break; + case SHELLBLADE_LUNGE: + if (pthis->skelAnime.curFrame == 0.0f) { + return true; + } + break; + case SHELLBLADE_BOUNCE: + if ((pthis->skelAnime.curFrame >= 3.0f) && (pthis->skelAnime.curFrame <= 5.0f)) { + return true; + } + break; + } + return false; +} + +s32 EnSb_UpdateDamage(EnSb* pthis, GlobalContext* globalCtx) { + Vec3f hitPoint; + f32 hitY; + s16 yawDiff; + s32 tookDamage; + u8 hitByWindArrow; + + // hit box collided, switch to cool down + if ((pthis->collider.base.atFlags & AT_HIT)) { + EnSb_SetupCooldown(pthis, 1); + return 1; + } + + // hurt box collided, take damage if appropriate + if ((pthis->collider.base.acFlags & AC_HIT)) { + hitByWindArrow = false; + tookDamage = false; + pthis->collider.base.acFlags &= ~AC_HIT; + + switch (pthis->actor.colChkInfo.damageEffect) { + case 14: // wind arrow + hitByWindArrow = true; + case 15: // explosions, arrow, hammer, ice arrow, light arrow, spirit arrow, shadow arrow + if (EnSb_IsVulnerable(pthis)) { + hitY = pthis->collider.info.bumper.hitPos.y - pthis->actor.world.pos.y; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((hitY < 30.0f) && (hitY > 10.0f) && (yawDiff >= -0x1FFF) && (yawDiff < 0x2000)) { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + tookDamage = true; + } + } + break; + case 2: // fire arrow, dins fire + pthis->fire = 4; + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + tookDamage = true; + break; + case 1: // hookshot/longshot + case 13: // all sword damage + if (EnSb_IsVulnerable(pthis)) { + hitY = pthis->collider.info.bumper.hitPos.y - pthis->actor.world.pos.y; + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((hitY < 30.0f) && (hitY > 10.0f) && (yawDiff >= -0x1FFF) && (yawDiff < 0x2000)) { + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0x50); + tookDamage = true; + EnSb_SetupCooldown(pthis, 0); + } + } + break; + default: + break; + } + if (pthis->actor.colChkInfo.health == 0) { + pthis->hitByWindArrow = hitByWindArrow; + BodyBreak_Alloc(&pthis->bodyBreak, 8, globalCtx); + pthis->isDead = true; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_SHELL_DEAD); + return 1; + } + + // if player attack didn't do damage, play recoil sound and spawn sparks + if (!tookDamage) { + hitPoint.x = pthis->collider.info.bumper.hitPos.x; + hitPoint.y = pthis->collider.info.bumper.hitPos.y; + hitPoint.z = pthis->collider.info.bumper.hitPos.z; + CollisionCheck_SpawnShieldParticlesMetal2(globalCtx, &hitPoint); + } + } + + return 0; +} + +void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSb* pthis = (EnSb*)thisx; + s32 pad; + + if (pthis->isDead) { + if (pthis->actor.yDistToWater > 0.0f) { + pthis->actor.params = 4; + } else { + pthis->actor.params = 1; + } + if (BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, pthis->actor.params)) { + if (!pthis->hitByWindArrow) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x80); + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, 8); + } + Actor_Kill(&pthis->actor); + } + } else { + Actor_SetFocus(&pthis->actor, 20.0f); + Actor_SetScale(&pthis->actor, 0.006f); + Actor_MoveForward(&pthis->actor); + pthis->actionFunc(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 20.0f, 5); + EnSb_UpdateDamage(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + } +} + +void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnSb* pthis = (EnSb*)thisx; + + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 0, 6, 8, dList, BODYBREAK_OBJECT_DEFAULT); +} + +void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSb* pthis = (EnSb*)thisx; + Vec3f flamePos; + Vec3f* offset; + s16 fireDecr; + + func_8002EBCC(&pthis->actor, globalCtx, 1); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + NULL, EnSb_PostLimbDraw, pthis); + if (pthis->fire != 0) { + pthis->actor.colorFilterTimer++; + fireDecr = pthis->fire - 1; + // pthis is intended to draw flames after being burned, but the condition is never met to run pthis code + // fire gets set to 4 when burned, decrements to 3 and fails the "& 1" check and never stores the decrement + if ((fireDecr & 1) == 0) { + offset = &sFlamePosOffsets[(fireDecr & 3)]; + flamePos.x = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.x + offset->x); + flamePos.y = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.y + offset->y); + flamePos.z = Rand_CenteredFloat(5.0f) + (pthis->actor.world.pos.z + offset->z); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &flamePos, 100, 0, 0, -1); + } + } +} diff --git a/src/overlays/actors/ovl_En_Scene_Change/z_en_scene_change.c b/src/overlays/actors/ovl_En_Scene_Change/z_en_scene_change.cpp similarity index 71% rename from src/overlays/actors/ovl_En_Scene_Change/z_en_scene_change.c rename to src/overlays/actors/ovl_En_Scene_Change/z_en_scene_change.cpp index cffbdc9bc..4958b4c2c 100644 --- a/src/overlays/actors/ovl_En_Scene_Change/z_en_scene_change.c +++ b/src/overlays/actors/ovl_En_Scene_Change/z_en_scene_change.cpp @@ -17,9 +17,9 @@ void EnSceneChange_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSceneChange_Update(Actor* thisx, GlobalContext* globalCtx); void EnSceneChange_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnSceneChange_DoNothing(EnSceneChange* this, GlobalContext* globalCtx); +void EnSceneChange_DoNothing(EnSceneChange* pthis, GlobalContext* globalCtx); -const ActorInit En_Scene_Change_InitVars = { +ActorInit En_Scene_Change_InitVars = { ACTOR_EN_SCENE_CHANGE, ACTORCAT_PROP, FLAGS, @@ -31,26 +31,26 @@ const ActorInit En_Scene_Change_InitVars = { (ActorFunc)EnSceneChange_Draw, }; -void EnSceneChange_SetupAction(EnSceneChange* this, EnSceneChangeActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnSceneChange_SetupAction(EnSceneChange* pthis, EnSceneChangeActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnSceneChange_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSceneChange* this = (EnSceneChange*)thisx; + EnSceneChange* pthis = (EnSceneChange*)thisx; - EnSceneChange_SetupAction(this, EnSceneChange_DoNothing); + EnSceneChange_SetupAction(pthis, EnSceneChange_DoNothing); } void EnSceneChange_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void EnSceneChange_DoNothing(EnSceneChange* this, GlobalContext* globalCtx) { +void EnSceneChange_DoNothing(EnSceneChange* pthis, GlobalContext* globalCtx) { } void EnSceneChange_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSceneChange* this = (EnSceneChange*)thisx; + EnSceneChange* pthis = (EnSceneChange*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void EnSceneChange_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -59,7 +59,7 @@ void EnSceneChange_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad2[2]; Gfx* displayListHead; - displayList = Graph_Alloc(globalCtx->state.gfxCtx, 0x3C0); + displayList = (Gfx*)Graph_Alloc(globalCtx->state.gfxCtx, 0x3C0); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_scene_change.c", 290); diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.cpp similarity index 94% rename from src/overlays/actors/ovl_En_Sda/z_en_sda.c rename to src/overlays/actors/ovl_En_Sda/z_en_sda.cpp index be6c8e28f..dc049971c 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.cpp @@ -18,11 +18,11 @@ void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSda_Update(Actor* thisx, GlobalContext* globalCtx); void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AF95C4(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx); +void func_80AF95C4(EnSda* pthis, u8* shadowTexture, Player* player, GlobalContext* globalCtx); void func_80AF9C70(u8* shadowTexture, Player* player, GlobalContext* globalCtx); void func_80AF8F60(Player* player, u8* shadowTexture, f32 arg2); -const ActorInit En_Sda_InitVars = { +ActorInit En_Sda_InitVars = { ACTOR_EN_SDA, ACTORCAT_BOSS, FLAGS, @@ -89,7 +89,7 @@ static Vec3f D_80AFA288[] = { static u32 D_80AFA390[] = { 0, 0 }; -#include "overlays/ovl_En_Sda/ovl_En_Sda.c" +#include "overlays/ovl_En_Sda/ovl_En_Sda.cpp" static Vec3f D_80AFA660[16]; @@ -101,37 +101,37 @@ void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSda_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnSda* this = (EnSda*)thisx; + EnSda* pthis = (EnSda*)thisx; Player* player; osSyncPrintf("SDA MOVE\n"); - if (this->actor.params == 1) { - player = (Player*)this->actor.parent; + if (pthis->actor.params == 1) { + player = (Player*)pthis->actor.parent; } else { player = GET_PLAYER(globalCtx); } - this->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos = player->actor.world.pos; osSyncPrintf("SDA MOVE END\n"); } void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSda* this = (EnSda*)thisx; + EnSda* pthis = (EnSda*)thisx; Player* player; - u8* shadowTexture = Graph_Alloc(globalCtx->state.gfxCtx, 0x1000); + u8* shadowTexture = (u8*)Graph_Alloc(globalCtx->state.gfxCtx, 0x1000); osSyncPrintf("SDA DRAW \n"); - if (this->actor.params == 1) { - player = (Player*)this->actor.parent; + if (pthis->actor.params == 1) { + player = (Player*)pthis->actor.parent; } else { player = GET_PLAYER(globalCtx); } player->actor.shape.shadowAlpha = 0; - func_80AF95C4(this, shadowTexture, player, globalCtx); + func_80AF95C4(pthis, shadowTexture, player, globalCtx); if (KREG(0) < 5) { func_80AF9C70(shadowTexture, player, globalCtx); @@ -239,7 +239,7 @@ void func_80AF8F60(Player* player, u8* shadowTexture, f32 arg2) { } } -void func_80AF95C4(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { +void func_80AF95C4(EnSda* pthis, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { s16 temp_t0; s16 temp_t1; s16 temp_v0; @@ -285,7 +285,7 @@ void func_80AF95C4(EnSda* this, u8* shadowTexture, Player* player, GlobalContext func_80AF8F60(player, shadowTexture, i / 5.0f); } osSyncPrintf("SDA CONT 3\n"); - if (this->actor.params != 1) { + if (pthis->actor.params != 1) { Matrix_MtxFToYXZRotS(&player->shieldMf, &sp178, false); sp178.y += (KREG(87) << 0xF) + 0x8000; sp178.x *= (KREG(88) - 1); diff --git a/src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.c b/src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.c deleted file mode 100644 index 399c6229a..000000000 --- a/src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.c +++ /dev/null @@ -1,315 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SHOPNUTS_Z_EN_SHOPNUTS_C -#include "actor_common.h" -#include "z_en_shopnuts.h" -#include "objects/object_shopnuts/object_shopnuts.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnShopnuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnShopnuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnShopnuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnShopnuts_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnShopnuts_SetupWait(EnShopnuts* this); -void EnShopnuts_Wait(EnShopnuts* this, GlobalContext* globalCtx); -void EnShopnuts_LookAround(EnShopnuts* this, GlobalContext* globalCtx); -void EnShopnuts_Stand(EnShopnuts* this, GlobalContext* globalCtx); -void EnShopnuts_ThrowNut(EnShopnuts* this, GlobalContext* globalCtx); -void EnShopnuts_Burrow(EnShopnuts* this, GlobalContext* globalCtx); -void EnShopnuts_SpawnSalesman(EnShopnuts* this, GlobalContext* globalCtx); - -const ActorInit En_Shopnuts_InitVars = { - ACTOR_EN_SHOPNUTS, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_SHOPNUTS, - sizeof(EnShopnuts), - (ActorFunc)EnShopnuts_Init, - (ActorFunc)EnShopnuts_Destroy, - (ActorFunc)EnShopnuts_Update, - (ActorFunc)EnShopnuts_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 40, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 1, 20, 40, 0xFE }; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x4E, ICHAIN_CONTINUE), - ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), -}; - -void EnShopnuts_Init(Actor* thisx, GlobalContext* globalCtx) { - EnShopnuts* this = (EnShopnuts*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBusinessScrubSkel, &gBusinessScrubAnim_4574, this->jointTable, - this->morphTable, 18); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (((this->actor.params == 0x0002) && (gSaveContext.itemGetInf[0] & 0x800)) || - ((this->actor.params == 0x0009) && (gSaveContext.infTable[25] & 4)) || - ((this->actor.params == 0x000A) && (gSaveContext.infTable[25] & 8))) { - Actor_Kill(&this->actor); - } else { - EnShopnuts_SetupWait(this); - } -} - -void EnShopnuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnShopnuts* this = (EnShopnuts*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnShopnuts_SetupWait(EnShopnuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gBusinessScrubAnim_139C, 0.0f); - this->animFlagAndTimer = Rand_S16Offset(100, 50); - this->collider.dim.height = 5; - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnShopnuts_Wait; -} - -void EnShopnuts_SetupLookAround(EnShopnuts* this) { - Animation_PlayLoop(&this->skelAnime, &gBusinessScrubLookAroundAnim); - this->animFlagAndTimer = 2; - this->actionFunc = EnShopnuts_LookAround; -} - -void EnShopnuts_SetupThrowNut(EnShopnuts* this) { - Animation_PlayOnce(&this->skelAnime, &gBusinessScrubAnim_1EC); - this->actionFunc = EnShopnuts_ThrowNut; -} - -void EnShopnuts_SetupStand(EnShopnuts* this) { - Animation_MorphToLoop(&this->skelAnime, &gBusinessScrubAnim_4574, -3.0f); - if (this->actionFunc == EnShopnuts_ThrowNut) { - this->animFlagAndTimer = 2 | 0x1000; // sets timer and flag - } else { - this->animFlagAndTimer = 1; - } - this->actionFunc = EnShopnuts_Stand; -} - -void EnShopnuts_SetupBurrow(EnShopnuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBusinessScrubAnim_39C, -5.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); - this->actionFunc = EnShopnuts_Burrow; -} - -void EnShopnuts_SetupSpawnSalesman(EnShopnuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBusinessScrubRotateAnim, -3.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - this->collider.base.acFlags &= ~AC_ON; - this->actionFunc = EnShopnuts_SpawnSalesman; -} - -void EnShopnuts_Wait(EnShopnuts* this, GlobalContext* globalCtx) { - s32 hasSlowPlaybackSpeed = false; - - if (this->skelAnime.playSpeed < 0.5f) { - hasSlowPlaybackSpeed = true; - } - if (hasSlowPlaybackSpeed && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - this->collider.base.acFlags |= AC_ON; - } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); - } - - this->collider.dim.height = ((CLAMP(this->skelAnime.curFrame, 9.0f, 13.0f) - 9.0f) * 9.0f) + 5.0f; - if (!hasSlowPlaybackSpeed && (this->actor.xzDistToPlayer < 120.0f)) { - EnShopnuts_SetupBurrow(this); - } else if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.xzDistToPlayer < 120.0f) { - EnShopnuts_SetupBurrow(this); - } else if ((this->animFlagAndTimer == 0) && (this->actor.xzDistToPlayer > 320.0f)) { - EnShopnuts_SetupLookAround(this); - } else { - EnShopnuts_SetupStand(this); - } - } - if (hasSlowPlaybackSpeed && - ((this->actor.xzDistToPlayer > 160.0f) && (fabsf(this->actor.yDistToPlayer) < 120.0f)) && - ((this->animFlagAndTimer == 0) || (this->actor.xzDistToPlayer < 480.0f))) { - this->skelAnime.playSpeed = 1.0f; - } -} - -void EnShopnuts_LookAround(EnShopnuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if ((this->actor.xzDistToPlayer < 120.0f) || (this->animFlagAndTimer == 0)) { - EnShopnuts_SetupBurrow(this); - } -} - -void EnShopnuts_Stand(EnShopnuts* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->animFlagAndTimer != 0)) { - this->animFlagAndTimer--; - } - if (!(this->animFlagAndTimer & 0x1000)) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - } - if ((this->actor.xzDistToPlayer < 120.0f) || (this->animFlagAndTimer == 0x1000)) { - EnShopnuts_SetupBurrow(this); - } else if (this->animFlagAndTimer == 0) { - EnShopnuts_SetupThrowNut(this); - } -} - -void EnShopnuts_ThrowNut(EnShopnuts* this, GlobalContext* globalCtx) { - Vec3f spawnPos; - - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (this->actor.xzDistToPlayer < 120.0f) { - EnShopnuts_SetupBurrow(this); - } else if (SkelAnime_Update(&this->skelAnime)) { - EnShopnuts_SetupStand(this); - } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - spawnPos.x = this->actor.world.pos.x + (Math_SinS(this->actor.shape.rot.y) * 23.0f); - spawnPos.y = this->actor.world.pos.y + 12.0f; - spawnPos.z = this->actor.world.pos.z + (Math_CosS(this->actor.shape.rot.y) * 23.0f); - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, spawnPos.x, spawnPos.y, spawnPos.z, - this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 2) != NULL) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); - } - } -} - -void EnShopnuts_Burrow(EnShopnuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnShopnuts_SetupWait(this); - } else { - this->collider.dim.height = ((4.0f - CLAMP_MAX(this->skelAnime.curFrame, 4.0f)) * 10.0f) + 5.0f; - } - if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - this->collider.base.acFlags &= ~AC_ON; - } -} - -void EnShopnuts_SpawnSalesman(EnShopnuts* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_DNS, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, - this->actor.params); - Actor_Kill(&this->actor); - } else { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - } -} - -void EnShopnuts_ColliderCheck(EnShopnuts* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - EnShopnuts_SetupSpawnSalesman(this); - } else if (globalCtx->actorCtx.unk_02 != 0) { - EnShopnuts_SetupSpawnSalesman(this); - } -} - -void EnShopnuts_Update(Actor* thisx, GlobalContext* globalCtx) { - EnShopnuts* this = (EnShopnuts*)thisx; - - EnShopnuts_ColliderCheck(this, globalCtx); - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 4); - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actionFunc == EnShopnuts_Wait) { - Actor_SetFocus(&this->actor, this->skelAnime.curFrame); - } else if (this->actionFunc == EnShopnuts_Burrow) { - Actor_SetFocus(&this->actor, - 20.0f - ((this->skelAnime.curFrame * 20.0f) / Animation_GetLastFrame(&gBusinessScrubAnim_39C))); - } else { - Actor_SetFocus(&this->actor, 20.0f); - } -} - -s32 EnShopnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnShopnuts* this = (EnShopnuts*)thisx; - - if ((limbIndex == 9) && (this->actionFunc == EnShopnuts_ThrowNut)) { - *dList = NULL; - } - return 0; -} - -void EnShopnuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnShopnuts* this = (EnShopnuts*)thisx; - - f32 curFrame; - f32 x; - f32 y; - f32 z; - - if ((limbIndex == 9) && (this->actionFunc == EnShopnuts_ThrowNut)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_shopnuts.c", 682); - curFrame = this->skelAnime.curFrame; - if (curFrame <= 6.0f) { - y = 1.0f - (curFrame * 0.0833f); - x = z = (curFrame * 0.1167f) + 1.0f; - } else if (curFrame <= 7.0f) { - curFrame -= 6.0f; - y = 0.5f + curFrame; - x = z = 1.7f - (curFrame * 0.7f); - } else if (curFrame <= 10.0f) { - y = 1.5f - ((curFrame - 7.0f) * 0.1667f); - x = z = 1.0f; - } else { - x = y = z = 1.0f; - } - - Matrix_Scale(x, y, z, MTXMODE_APPLY); - if (1) {} - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_shopnuts.c", 714), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gBusinessScrubNoseDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_shopnuts.c", 717); - } -} - -void EnShopnuts_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnShopnuts* this = (EnShopnuts*)thisx; - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnShopnuts_OverrideLimbDraw, EnShopnuts_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.cpp b/src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.cpp new file mode 100644 index 000000000..ab22f8359 --- /dev/null +++ b/src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.cpp @@ -0,0 +1,315 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SHOPNUTS_Z_EN_SHOPNUTS_C +#include "actor_common.h" +#include "z_en_shopnuts.h" +#include "objects/object_shopnuts/object_shopnuts.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnShopnuts_Init(Actor* thisx, GlobalContext* globalCtx); +void EnShopnuts_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnShopnuts_Update(Actor* thisx, GlobalContext* globalCtx); +void EnShopnuts_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnShopnuts_SetupWait(EnShopnuts* pthis); +void EnShopnuts_Wait(EnShopnuts* pthis, GlobalContext* globalCtx); +void EnShopnuts_LookAround(EnShopnuts* pthis, GlobalContext* globalCtx); +void EnShopnuts_Stand(EnShopnuts* pthis, GlobalContext* globalCtx); +void EnShopnuts_ThrowNut(EnShopnuts* pthis, GlobalContext* globalCtx); +void EnShopnuts_Burrow(EnShopnuts* pthis, GlobalContext* globalCtx); +void EnShopnuts_SpawnSalesman(EnShopnuts* pthis, GlobalContext* globalCtx); + +ActorInit En_Shopnuts_InitVars = { + ACTOR_EN_SHOPNUTS, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_SHOPNUTS, + sizeof(EnShopnuts), + (ActorFunc)EnShopnuts_Init, + (ActorFunc)EnShopnuts_Destroy, + (ActorFunc)EnShopnuts_Update, + (ActorFunc)EnShopnuts_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 40, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 1, 20, 40, 0xFE }; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x4E, ICHAIN_CONTINUE), + ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), +}; + +void EnShopnuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnShopnuts* pthis = (EnShopnuts*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gBusinessScrubSkel, &gBusinessScrubAnim_4574, pthis->jointTable, + pthis->morphTable, 18); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (((pthis->actor.params == 0x0002) && (gSaveContext.itemGetInf[0] & 0x800)) || + ((pthis->actor.params == 0x0009) && (gSaveContext.infTable[25] & 4)) || + ((pthis->actor.params == 0x000A) && (gSaveContext.infTable[25] & 8))) { + Actor_Kill(&pthis->actor); + } else { + EnShopnuts_SetupWait(pthis); + } +} + +void EnShopnuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnShopnuts* pthis = (EnShopnuts*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnShopnuts_SetupWait(EnShopnuts* pthis) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gBusinessScrubAnim_139C, 0.0f); + pthis->animFlagAndTimer = Rand_S16Offset(100, 50); + pthis->collider.dim.height = 5; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnShopnuts_Wait; +} + +void EnShopnuts_SetupLookAround(EnShopnuts* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gBusinessScrubLookAroundAnim); + pthis->animFlagAndTimer = 2; + pthis->actionFunc = EnShopnuts_LookAround; +} + +void EnShopnuts_SetupThrowNut(EnShopnuts* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gBusinessScrubAnim_1EC); + pthis->actionFunc = EnShopnuts_ThrowNut; +} + +void EnShopnuts_SetupStand(EnShopnuts* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gBusinessScrubAnim_4574, -3.0f); + if (pthis->actionFunc == EnShopnuts_ThrowNut) { + pthis->animFlagAndTimer = 2 | 0x1000; // sets timer and flag + } else { + pthis->animFlagAndTimer = 1; + } + pthis->actionFunc = EnShopnuts_Stand; +} + +void EnShopnuts_SetupBurrow(EnShopnuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBusinessScrubAnim_39C, -5.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DOWN); + pthis->actionFunc = EnShopnuts_Burrow; +} + +void EnShopnuts_SetupSpawnSalesman(EnShopnuts* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBusinessScrubRotateAnim, -3.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_DAMAGE); + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnShopnuts_SpawnSalesman; +} + +void EnShopnuts_Wait(EnShopnuts* pthis, GlobalContext* globalCtx) { + s32 hasSlowPlaybackSpeed = false; + + if (pthis->skelAnime.playSpeed < 0.5f) { + hasSlowPlaybackSpeed = true; + } + if (hasSlowPlaybackSpeed && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (Animation_OnFrame(&pthis->skelAnime, 9.0f)) { + pthis->collider.base.acFlags |= AC_ON; + } else if (Animation_OnFrame(&pthis->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_UP); + } + + pthis->collider.dim.height = ((CLAMP(pthis->skelAnime.curFrame, 9.0f, 13.0f) - 9.0f) * 9.0f) + 5.0f; + if (!hasSlowPlaybackSpeed && (pthis->actor.xzDistToPlayer < 120.0f)) { + EnShopnuts_SetupBurrow(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.xzDistToPlayer < 120.0f) { + EnShopnuts_SetupBurrow(pthis); + } else if ((pthis->animFlagAndTimer == 0) && (pthis->actor.xzDistToPlayer > 320.0f)) { + EnShopnuts_SetupLookAround(pthis); + } else { + EnShopnuts_SetupStand(pthis); + } + } + if (hasSlowPlaybackSpeed && + ((pthis->actor.xzDistToPlayer > 160.0f) && (fabsf(pthis->actor.yDistToPlayer) < 120.0f)) && + ((pthis->animFlagAndTimer == 0) || (pthis->actor.xzDistToPlayer < 480.0f))) { + pthis->skelAnime.playSpeed = 1.0f; + } +} + +void EnShopnuts_LookAround(EnShopnuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if ((pthis->actor.xzDistToPlayer < 120.0f) || (pthis->animFlagAndTimer == 0)) { + EnShopnuts_SetupBurrow(pthis); + } +} + +void EnShopnuts_Stand(EnShopnuts* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) && (pthis->animFlagAndTimer != 0)) { + pthis->animFlagAndTimer--; + } + if (!(pthis->animFlagAndTimer & 0x1000)) { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + } + if ((pthis->actor.xzDistToPlayer < 120.0f) || (pthis->animFlagAndTimer == 0x1000)) { + EnShopnuts_SetupBurrow(pthis); + } else if (pthis->animFlagAndTimer == 0) { + EnShopnuts_SetupThrowNut(pthis); + } +} + +void EnShopnuts_ThrowNut(EnShopnuts* pthis, GlobalContext* globalCtx) { + Vec3f spawnPos; + + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + if (pthis->actor.xzDistToPlayer < 120.0f) { + EnShopnuts_SetupBurrow(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime)) { + EnShopnuts_SetupStand(pthis); + } else if (Animation_OnFrame(&pthis->skelAnime, 6.0f)) { + spawnPos.x = pthis->actor.world.pos.x + (Math_SinS(pthis->actor.shape.rot.y) * 23.0f); + spawnPos.y = pthis->actor.world.pos.y + 12.0f; + spawnPos.z = pthis->actor.world.pos.z + (Math_CosS(pthis->actor.shape.rot.y) * 23.0f); + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, spawnPos.x, spawnPos.y, spawnPos.z, + pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 2) != NULL) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_NUTS_THROW); + } + } +} + +void EnShopnuts_Burrow(EnShopnuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnShopnuts_SetupWait(pthis); + } else { + pthis->collider.dim.height = ((4.0f - CLAMP_MAX(pthis->skelAnime.curFrame, 4.0f)) * 10.0f) + 5.0f; + } + if (Animation_OnFrame(&pthis->skelAnime, 4.0f)) { + pthis->collider.base.acFlags &= ~AC_ON; + } +} + +void EnShopnuts_SpawnSalesman(EnShopnuts* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_DNS, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, + pthis->actor.params); + Actor_Kill(&pthis->actor); + } else { + Math_ApproachS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0xE38); + } +} + +void EnShopnuts_ColliderCheck(EnShopnuts* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + EnShopnuts_SetupSpawnSalesman(pthis); + } else if (globalCtx->actorCtx.unk_02 != 0) { + EnShopnuts_SetupSpawnSalesman(pthis); + } +} + +void EnShopnuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnShopnuts* pthis = (EnShopnuts*)thisx; + + EnShopnuts_ColliderCheck(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, pthis->collider.dim.radius, pthis->collider.dim.height, 4); + if (pthis->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actionFunc == EnShopnuts_Wait) { + Actor_SetFocus(&pthis->actor, pthis->skelAnime.curFrame); + } else if (pthis->actionFunc == EnShopnuts_Burrow) { + Actor_SetFocus(&pthis->actor, + 20.0f - ((pthis->skelAnime.curFrame * 20.0f) / Animation_GetLastFrame(&gBusinessScrubAnim_39C))); + } else { + Actor_SetFocus(&pthis->actor, 20.0f); + } +} + +s32 EnShopnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnShopnuts* pthis = (EnShopnuts*)thisx; + + if ((limbIndex == 9) && (pthis->actionFunc == EnShopnuts_ThrowNut)) { + *dList = NULL; + } + return 0; +} + +void EnShopnuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnShopnuts* pthis = (EnShopnuts*)thisx; + + f32 curFrame; + f32 x; + f32 y; + f32 z; + + if ((limbIndex == 9) && (pthis->actionFunc == EnShopnuts_ThrowNut)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_shopnuts.c", 682); + curFrame = pthis->skelAnime.curFrame; + if (curFrame <= 6.0f) { + y = 1.0f - (curFrame * 0.0833f); + x = z = (curFrame * 0.1167f) + 1.0f; + } else if (curFrame <= 7.0f) { + curFrame -= 6.0f; + y = 0.5f + curFrame; + x = z = 1.7f - (curFrame * 0.7f); + } else if (curFrame <= 10.0f) { + y = 1.5f - ((curFrame - 7.0f) * 0.1667f); + x = z = 1.0f; + } else { + x = y = z = 1.0f; + } + + Matrix_Scale(x, y, z, MTXMODE_APPLY); + if (1) {} + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_shopnuts.c", 714), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBusinessScrubNoseDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_shopnuts.c", 717); + } +} + +void EnShopnuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnShopnuts* pthis = (EnShopnuts*)thisx; + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnShopnuts_OverrideLimbDraw, EnShopnuts_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.cpp similarity index 51% rename from src/overlays/actors/ovl_En_Si/z_en_si.c rename to src/overlays/actors/ovl_En_Si/z_en_si.cpp index bf32c0910..9ecaccb79 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.cpp @@ -23,10 +23,10 @@ void EnSi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSi_Update(Actor* thisx, GlobalContext* globalCtx); void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx); -void func_80AFB768(EnSi* this, GlobalContext* globalCtx); -void func_80AFB89C(EnSi* this, GlobalContext* globalCtx); -void func_80AFB950(EnSi* this, GlobalContext* globalCtx); +s32 func_80AFB748(EnSi* pthis, GlobalContext* globalCtx); +void func_80AFB768(EnSi* pthis, GlobalContext* globalCtx); +void func_80AFB89C(EnSi* pthis, GlobalContext* globalCtx); +void func_80AFB950(EnSi* pthis, GlobalContext* globalCtx); static ColliderCylinderInit sCylinderInit = { { @@ -50,7 +50,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 D_80AFBADC = { 0, 0, 0, 0, MASS_IMMOVABLE }; -const ActorInit En_Si_InitVars = { +ActorInit En_Si_InitVars = { ACTOR_EN_SI, ACTORCAT_ITEMACTION, FLAGS, @@ -63,101 +63,101 @@ const ActorInit En_Si_InitVars = { }; void EnSi_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSi* this = (EnSi*)thisx; + EnSi* pthis = (EnSi*)thisx; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &D_80AFBADC); - Actor_SetScale(&this->actor, 0.025f); - this->unk_19C = 0; - this->actionFunc = func_80AFB768; - this->actor.shape.yOffset = 42.0f; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &D_80AFBADC); + Actor_SetScale(&pthis->actor, 0.025f); + pthis->unk_19C = 0; + pthis->actionFunc = func_80AFB768; + pthis->actor.shape.yOffset = 42.0f; } void EnSi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSi* this = (EnSi*)thisx; + EnSi* pthis = (EnSi*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; +s32 func_80AFB748(EnSi* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; } return 0; } -void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { +void func_80AFB768(EnSi* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { - this->actionFunc = func_80AFB89C; + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_13)) { + pthis->actionFunc = func_80AFB89C; } else { - Math_SmoothStepToF(&this->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); - Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.shape.rot.y += 0x400; + Math_SmoothStepToF(&pthis->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + pthis->actor.shape.rot.y += 0x400; if (!Player_InCsMode(globalCtx)) { - func_80AFB748(this, globalCtx); + func_80AFB748(pthis, globalCtx); - if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + if (pthis->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + pthis->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; Item_Give(globalCtx, ITEM_SKULL_TOKEN); player->actor.freezeTimer = 10; Message_StartTextbox(globalCtx, 0xB4, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); - this->actionFunc = func_80AFB950; + pthis->actionFunc = func_80AFB950; } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } } } -void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { +void func_80AFB89C(EnSi* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Math_SmoothStepToF(&this->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); - Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.shape.rot.y += 0x400; + Math_SmoothStepToF(&pthis->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + pthis->actor.shape.rot.y += 0x400; - if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { + if (!CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_13)) { Item_Give(globalCtx, ITEM_SKULL_TOKEN); player->actor.freezeTimer = 10; Message_StartTextbox(globalCtx, 0xB4, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); - this->actionFunc = func_80AFB950; + pthis->actionFunc = func_80AFB950; } } -void func_80AFB950(EnSi* this, GlobalContext* globalCtx) { +void func_80AFB950(EnSi* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING) { player->actor.freezeTimer = 10; } else { - SET_GS_FLAGS((this->actor.params & 0x1F00) >> 8, this->actor.params & 0xFF); - Actor_Kill(&this->actor); + SET_GS_FLAGS((pthis->actor.params & 0x1F00) >> 8, pthis->actor.params & 0xFF); + Actor_Kill(&pthis->actor); } } void EnSi_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSi* this = (EnSi*)thisx; + EnSi* pthis = (EnSi*)thisx; - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, 16.0f); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 16.0f); } void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSi* this = (EnSi*)thisx; + EnSi* pthis = (EnSi*)thisx; - if (this->actionFunc != func_80AFB950) { - func_8002ED80(&this->actor, globalCtx, 0); - func_8002EBCC(&this->actor, globalCtx, 0); + if (pthis->actionFunc != func_80AFB950) { + func_8002ED80(&pthis->actor, globalCtx, 0); + func_8002EBCC(&pthis->actor, globalCtx, 0); GetItem_Draw(globalCtx, GID_SKULL_TOKEN_2); } } diff --git a/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c b/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c deleted file mode 100644 index e869dda70..000000000 --- a/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c +++ /dev/null @@ -1,324 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SIOFUKI_Z_EN_SIOFUKI_C -#include "actor_common.h" -/* - * File: z_en_siofuki.c - * Overlay: ovl_En_Siofuki - * Description: Water Spout - */ - -#include "z_en_siofuki.h" -#include "objects/object_siofuki/object_siofuki.h" -#include "def/code_80043480.h" -#include "def/code_800EC960.h" -#include "def/code_800FCE80.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnSiofuki_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSiofuki_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSiofuki_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSiofuki_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AFC34C(EnSiofuki* this, GlobalContext* globalCtx); -void func_80AFC544(EnSiofuki* this, GlobalContext* globalCtx); -void func_80AFC478(EnSiofuki* this, GlobalContext* globalCtx); - -const ActorInit En_Siofuki_InitVars = { - ACTOR_EN_SIOFUKI, - ACTORCAT_BG, - FLAGS, - OBJECT_SIOFUKI, - sizeof(EnSiofuki), - (ActorFunc)EnSiofuki_Init, - (ActorFunc)EnSiofuki_Destroy, - (ActorFunc)EnSiofuki_Update, - (ActorFunc)EnSiofuki_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; - -void EnSiofuki_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSiofuki* this = (EnSiofuki*)thisx; - s32 type; - CollisionHeader* colHeader = NULL; - s32 pad; - - if ((thisx->room == 10) && Flags_GetSwitch(globalCtx, 0x1E)) { - Actor_Kill(thisx); - return; - } - - Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_Init(&this->dyna, DPM_PLAYER); - CollisionHeader_GetVirtual(&object_siofuki_Col_000D78, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - this->sfxFlags |= 1; - - type = ((u16)thisx->params >> 0xC) & 0xF; - if (!((type == 0) || (type == 1))) { - Actor_Kill(thisx); - return; - } - - this->initPosY = thisx->world.pos.y; - this->unk_174 = 35.0f; - this->unk_170 = -6058.0f + this->unk_174; - - if (thisx->shape.rot.x != 0) { - this->maxHeight = thisx->shape.rot.x * 40.0f; - this->currentHeight = this->maxHeight; - } - this->activeTime = 0; - if (thisx->shape.rot.y != 0) { - this->activeTime = thisx->shape.rot.y; - } - if (thisx->shape.rot.z != 0) { - thisx->scale.x = thisx->shape.rot.z * (1.0f / 1.73f) * 0.1f; - thisx->scale.z = thisx->shape.rot.z * 0.5f * 0.1f; - } - - thisx->world.rot.x = 0; - thisx->world.rot.y = 0; - thisx->world.rot.z = 0; - thisx->shape.rot.x = 0; - thisx->shape.rot.y = 0; - thisx->shape.rot.z = 0; - - type = ((u16)thisx->params >> 0xC) & 0xF; - if (type == EN_SIOFUKI_RAISING) { - this->currentHeight = 10.0f; - this->targetHeight = 10.0f; - this->actionFunc = func_80AFC34C; - } else if (type == EN_SIOFUKI_LOWERING) { - if (Flags_GetTreasure(globalCtx, (u16)thisx->params & 0x3F)) { - this->currentHeight = -45.0f; - this->targetHeight = -45.0f; - this->actionFunc = func_80AFC544; - } else { - this->targetHeight = this->currentHeight; - this->actionFunc = func_80AFC478; - } - } -} - -void EnSiofuki_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSiofuki* this = (EnSiofuki*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80AFBDC8(EnSiofuki* this, GlobalContext* globalCtx) { - this->oscillation = sinf((globalCtx->gameplayFrames & 0x1F) / 32.0f * M_PI * 2.0f) * 4.0f; - this->unk_170 = this->unk_174 * 10.0f + -6058.0f - this->oscillation * 10.0f; - this->unk_174 = 35.0f; - this->dyna.actor.world.pos.y = this->initPosY + this->currentHeight + this->oscillation; -} - -void func_80AFBE8C(EnSiofuki* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 dX; - f32 dY; - f32 dZ; - s16 angle; - s16 dAngle; - f32 dist2d; - f32 speedScale; - - dX = player->actor.world.pos.x - this->dyna.actor.world.pos.x; - dY = player->actor.world.pos.y - this->dyna.actor.world.pos.y; - dZ = player->actor.world.pos.z - this->dyna.actor.world.pos.z; - - if ((dX > (this->dyna.actor.scale.x * -346.0f)) && (dX < (this->dyna.actor.scale.x * 346.0f)) && - (dZ > (this->dyna.actor.scale.z * -400.0f)) && (dZ < (this->dyna.actor.scale.z * 400.0f)) && (dY < 0.0f)) { - if (func_8004356C(&this->dyna)) { - if (this->splashTimer <= 0) { - EffectSsGSplash_Spawn(globalCtx, &player->actor.world.pos, NULL, NULL, 1, 1); - this->splashTimer = 10; - } else { - this->splashTimer--; - } - - this->applySpeed = false; - this->appliedSpeed = 0.0f; - this->targetAppliedSpeed = 0.0f; - } else { - dist2d = sqrtf(SQ(dX) + SQ(dZ)); - this->applySpeed = true; - this->splashTimer = 0; - angle = Math_FAtan2F(dX, dZ) * (0x8000 / M_PI); - dAngle = (player->actor.world.rot.y ^ 0x8000) - angle; - player->actor.gravity = 0.0f; - player->actor.velocity.y = 0.0f; - Math_SmoothStepToF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.5f, 4.0f, 1.0f); - - if ((dAngle < 0x4000) && (dAngle > -0x4000)) { - this->appliedYaw = player->actor.world.rot.y ^ 0x8000; - speedScale = dist2d / (this->dyna.actor.scale.x * 40.0f * 10.0f); - speedScale = CLAMP_MIN(speedScale, 0.0f); - speedScale = CLAMP_MAX(speedScale, 1.0f); - player->linearVelocity *= speedScale; - Math_ApproachF(&this->targetAppliedSpeed, 3.0f, 1.0f, 1.0f); - Math_ApproachF(&this->appliedSpeed, this->targetAppliedSpeed, 1.0f, 0.3f * speedScale); - } else { - this->appliedYaw = player->actor.world.rot.y; - player->linearVelocity /= 2.0f; - Math_ApproachF(&this->targetAppliedSpeed, 3.0f, 1.0f, 1.0f); - Math_ApproachF(&this->appliedSpeed, this->targetAppliedSpeed, 1.0f, 0.1f); - } - - player->windDirection = this->appliedYaw; - player->windSpeed = this->appliedSpeed; - } - } else { - if (this->applySpeed) { - player->linearVelocity = this->appliedSpeed + player->linearVelocity; - player->currentYaw = this->appliedYaw; - } - - this->targetAppliedSpeed = 0.0f; - this->appliedSpeed = 0.0f; - this->applySpeed = false; - } -} - -void func_80AFC1D0(EnSiofuki* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->currentHeight, this->targetHeight, 0.8f, 3.0f, 0.01f); -} - -void func_80AFC218(EnSiofuki* this, GlobalContext* globalCtx) { - func_80AFBDC8(this, globalCtx); - func_80AFBE8C(this, globalCtx); - func_80AFC1D0(this, globalCtx); - - this->timer--; - if (this->timer < 0) { - Flags_UnsetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 6) & 0x3F); - switch (((u16)this->dyna.actor.params >> 0xC) & 0xF) { - case EN_SIOFUKI_RAISING: - this->targetHeight = 10.0f; - this->actionFunc = func_80AFC34C; - break; - case EN_SIOFUKI_LOWERING: - this->targetHeight = this->maxHeight; - this->actionFunc = func_80AFC478; - break; - } - } else { - func_8002F994(&this->dyna.actor, this->timer); - } - - if (((((u16)this->dyna.actor.params >> 0xC) & 0xF) == EN_SIOFUKI_LOWERING) && - Flags_GetTreasure(globalCtx, (u16)this->dyna.actor.params & 0x3F)) { - this->currentHeight = -45.0f; - this->targetHeight = -45.0f; - Flags_UnsetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 6) & 0x3F); - this->actionFunc = func_80AFC544; - } -} - -void func_80AFC34C(EnSiofuki* this, GlobalContext* globalCtx) { - func_80AFBDC8(this, globalCtx); - func_80AFBE8C(this, globalCtx); - func_80AFC1D0(this, globalCtx); - - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 6) & 0x3F)) { - this->targetHeight = 400.0f; - this->timer = 300; - this->actionFunc = func_80AFC218; - } -} - -void func_80AFC3C8(EnSiofuki* this, GlobalContext* globalCtx) { - func_80AFBDC8(this, globalCtx); - func_80AFBE8C(this, globalCtx); - func_80AFC1D0(this, globalCtx); - - this->timer--; - if (this->timer < 0) { - this->timer = this->activeTime * 20; - this->targetHeight = -45.0f; - this->actionFunc = func_80AFC218; - } - - if (Flags_GetTreasure(globalCtx, (u16)this->dyna.actor.params & 0x3F)) { - this->currentHeight = -45.0f; - this->targetHeight = -45.0f; - this->actionFunc = func_80AFC544; - } -} - -void func_80AFC478(EnSiofuki* this, GlobalContext* globalCtx) { - func_80AFBDC8(this, globalCtx); - func_80AFBE8C(this, globalCtx); - func_80AFC1D0(this, globalCtx); - - if (((u16)this->dyna.actor.params >> 0xC & 0xF) == EN_SIOFUKI_LOWERING) { - if (Flags_GetSwitch(globalCtx, ((u16)this->dyna.actor.params >> 6) & 0x3F)) { - this->timer = 20; - this->actionFunc = func_80AFC3C8; - OnePointCutscene_Init(globalCtx, 5010, 40, &this->dyna.actor, MAIN_CAM); - } - - if (Flags_GetTreasure(globalCtx, (u16)this->dyna.actor.params & 0x3F)) { - this->currentHeight = -45.0f; - this->targetHeight = -45.0f; - this->actionFunc = func_80AFC544; - } - } -} - -void func_80AFC544(EnSiofuki* this, GlobalContext* globalCtx) { - func_80AFBDC8(this, globalCtx); - func_80AFC1D0(this, globalCtx); -} - -void EnSiofuki_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSiofuki* this = (EnSiofuki*)thisx; - - this->actionFunc(this, globalCtx); -} - -void EnSiofuki_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSiofuki* this = (EnSiofuki*)thisx; - u32 x; - u32 y; - u32 gameplayFrames = globalCtx->gameplayFrames; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_siofuki.c", 654); - func_80093D84(globalCtx->state.gfxCtx); - Matrix_Translate(0.0f, this->unk_170, 0.0f, MTXMODE_APPLY); - Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_siofuki.c", 662), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - x = gameplayFrames * 15; - y = gameplayFrames * -15; - gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, x, y, 64, 64, 1, x, y, 64, 64)); - gSPDisplayList(POLY_XLU_DISP++, object_siofuki_DL_000B70); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_siofuki.c", 674); - - if (this->sfxFlags & 1) { - f32 heightRatio; - switch (((u16)thisx->params >> 0xC) & 0xF) { - case EN_SIOFUKI_RAISING: - heightRatio = (this->currentHeight - 10.0f) / (400.0f - 10.0f); - func_800F436C(&thisx->projectedPos, NA_SE_EV_FOUNTAIN - SFX_FLAG, 1.0f + heightRatio); - break; - case EN_SIOFUKI_LOWERING: - if (this->currentHeight > -35.0f) { - heightRatio = (this->currentHeight - -35.0f) / (this->maxHeight - -35.0f); - func_800F436C(&thisx->projectedPos, NA_SE_EV_FOUNTAIN - SFX_FLAG, 1.0f + heightRatio); - } - break; - } - } -} diff --git a/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.cpp b/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.cpp new file mode 100644 index 000000000..746346ac1 --- /dev/null +++ b/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.cpp @@ -0,0 +1,324 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SIOFUKI_Z_EN_SIOFUKI_C +#include "actor_common.h" +/* + * File: z_en_siofuki.c + * Overlay: ovl_En_Siofuki + * Description: Water Spout + */ + +#include "z_en_siofuki.h" +#include "objects/object_siofuki/object_siofuki.h" +#include "def/code_80043480.h" +#include "def/code_800EC960.h" +#include "def/code_800FCE80.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnSiofuki_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSiofuki_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSiofuki_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSiofuki_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AFC34C(EnSiofuki* pthis, GlobalContext* globalCtx); +void func_80AFC544(EnSiofuki* pthis, GlobalContext* globalCtx); +void func_80AFC478(EnSiofuki* pthis, GlobalContext* globalCtx); + +ActorInit En_Siofuki_InitVars = { + ACTOR_EN_SIOFUKI, + ACTORCAT_BG, + FLAGS, + OBJECT_SIOFUKI, + sizeof(EnSiofuki), + (ActorFunc)EnSiofuki_Init, + (ActorFunc)EnSiofuki_Destroy, + (ActorFunc)EnSiofuki_Update, + (ActorFunc)EnSiofuki_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +void EnSiofuki_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSiofuki* pthis = (EnSiofuki*)thisx; + s32 type; + CollisionHeader* colHeader = NULL; + s32 pad; + + if ((thisx->room == 10) && Flags_GetSwitch(globalCtx, 0x1E)) { + Actor_Kill(thisx); + return; + } + + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_Init(&pthis->dyna, DPM_PLAYER); + CollisionHeader_GetVirtual(&object_siofuki_Col_000D78, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + pthis->sfxFlags |= 1; + + type = ((u16)thisx->params >> 0xC) & 0xF; + if (!((type == 0) || (type == 1))) { + Actor_Kill(thisx); + return; + } + + pthis->initPosY = thisx->world.pos.y; + pthis->unk_174 = 35.0f; + pthis->unk_170 = -6058.0f + pthis->unk_174; + + if (thisx->shape.rot.x != 0) { + pthis->maxHeight = thisx->shape.rot.x * 40.0f; + pthis->currentHeight = pthis->maxHeight; + } + pthis->activeTime = 0; + if (thisx->shape.rot.y != 0) { + pthis->activeTime = thisx->shape.rot.y; + } + if (thisx->shape.rot.z != 0) { + thisx->scale.x = thisx->shape.rot.z * (1.0f / 1.73f) * 0.1f; + thisx->scale.z = thisx->shape.rot.z * 0.5f * 0.1f; + } + + thisx->world.rot.x = 0; + thisx->world.rot.y = 0; + thisx->world.rot.z = 0; + thisx->shape.rot.x = 0; + thisx->shape.rot.y = 0; + thisx->shape.rot.z = 0; + + type = ((u16)thisx->params >> 0xC) & 0xF; + if (type == EN_SIOFUKI_RAISING) { + pthis->currentHeight = 10.0f; + pthis->targetHeight = 10.0f; + pthis->actionFunc = func_80AFC34C; + } else if (type == EN_SIOFUKI_LOWERING) { + if (Flags_GetTreasure(globalCtx, (u16)thisx->params & 0x3F)) { + pthis->currentHeight = -45.0f; + pthis->targetHeight = -45.0f; + pthis->actionFunc = func_80AFC544; + } else { + pthis->targetHeight = pthis->currentHeight; + pthis->actionFunc = func_80AFC478; + } + } +} + +void EnSiofuki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSiofuki* pthis = (EnSiofuki*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80AFBDC8(EnSiofuki* pthis, GlobalContext* globalCtx) { + pthis->oscillation = sinf((globalCtx->gameplayFrames & 0x1F) / 32.0f * M_PI * 2.0f) * 4.0f; + pthis->unk_170 = pthis->unk_174 * 10.0f + -6058.0f - pthis->oscillation * 10.0f; + pthis->unk_174 = 35.0f; + pthis->dyna.actor.world.pos.y = pthis->initPosY + pthis->currentHeight + pthis->oscillation; +} + +void func_80AFBE8C(EnSiofuki* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dX; + f32 dY; + f32 dZ; + s16 angle; + s16 dAngle; + f32 dist2d; + f32 speedScale; + + dX = player->actor.world.pos.x - pthis->dyna.actor.world.pos.x; + dY = player->actor.world.pos.y - pthis->dyna.actor.world.pos.y; + dZ = player->actor.world.pos.z - pthis->dyna.actor.world.pos.z; + + if ((dX > (pthis->dyna.actor.scale.x * -346.0f)) && (dX < (pthis->dyna.actor.scale.x * 346.0f)) && + (dZ > (pthis->dyna.actor.scale.z * -400.0f)) && (dZ < (pthis->dyna.actor.scale.z * 400.0f)) && (dY < 0.0f)) { + if (func_8004356C(&pthis->dyna)) { + if (pthis->splashTimer <= 0) { + EffectSsGSplash_Spawn(globalCtx, &player->actor.world.pos, NULL, NULL, 1, 1); + pthis->splashTimer = 10; + } else { + pthis->splashTimer--; + } + + pthis->applySpeed = false; + pthis->appliedSpeed = 0.0f; + pthis->targetAppliedSpeed = 0.0f; + } else { + dist2d = sqrtf(SQ(dX) + SQ(dZ)); + pthis->applySpeed = true; + pthis->splashTimer = 0; + angle = Math_FAtan2F(dX, dZ) * (0x8000 / M_PI); + dAngle = (player->actor.world.rot.y ^ 0x8000) - angle; + player->actor.gravity = 0.0f; + player->actor.velocity.y = 0.0f; + Math_SmoothStepToF(&player->actor.world.pos.y, pthis->dyna.actor.world.pos.y, 0.5f, 4.0f, 1.0f); + + if ((dAngle < 0x4000) && (dAngle > -0x4000)) { + pthis->appliedYaw = player->actor.world.rot.y ^ 0x8000; + speedScale = dist2d / (pthis->dyna.actor.scale.x * 40.0f * 10.0f); + speedScale = CLAMP_MIN(speedScale, 0.0f); + speedScale = CLAMP_MAX(speedScale, 1.0f); + player->linearVelocity *= speedScale; + Math_ApproachF(&pthis->targetAppliedSpeed, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&pthis->appliedSpeed, pthis->targetAppliedSpeed, 1.0f, 0.3f * speedScale); + } else { + pthis->appliedYaw = player->actor.world.rot.y; + player->linearVelocity /= 2.0f; + Math_ApproachF(&pthis->targetAppliedSpeed, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&pthis->appliedSpeed, pthis->targetAppliedSpeed, 1.0f, 0.1f); + } + + player->windDirection = pthis->appliedYaw; + player->windSpeed = pthis->appliedSpeed; + } + } else { + if (pthis->applySpeed) { + player->linearVelocity = pthis->appliedSpeed + player->linearVelocity; + player->currentYaw = pthis->appliedYaw; + } + + pthis->targetAppliedSpeed = 0.0f; + pthis->appliedSpeed = 0.0f; + pthis->applySpeed = false; + } +} + +void func_80AFC1D0(EnSiofuki* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->currentHeight, pthis->targetHeight, 0.8f, 3.0f, 0.01f); +} + +void func_80AFC218(EnSiofuki* pthis, GlobalContext* globalCtx) { + func_80AFBDC8(pthis, globalCtx); + func_80AFBE8C(pthis, globalCtx); + func_80AFC1D0(pthis, globalCtx); + + pthis->timer--; + if (pthis->timer < 0) { + Flags_UnsetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 6) & 0x3F); + switch (((u16)pthis->dyna.actor.params >> 0xC) & 0xF) { + case EN_SIOFUKI_RAISING: + pthis->targetHeight = 10.0f; + pthis->actionFunc = func_80AFC34C; + break; + case EN_SIOFUKI_LOWERING: + pthis->targetHeight = pthis->maxHeight; + pthis->actionFunc = func_80AFC478; + break; + } + } else { + func_8002F994(&pthis->dyna.actor, pthis->timer); + } + + if (((((u16)pthis->dyna.actor.params >> 0xC) & 0xF) == EN_SIOFUKI_LOWERING) && + Flags_GetTreasure(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { + pthis->currentHeight = -45.0f; + pthis->targetHeight = -45.0f; + Flags_UnsetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 6) & 0x3F); + pthis->actionFunc = func_80AFC544; + } +} + +void func_80AFC34C(EnSiofuki* pthis, GlobalContext* globalCtx) { + func_80AFBDC8(pthis, globalCtx); + func_80AFBE8C(pthis, globalCtx); + func_80AFC1D0(pthis, globalCtx); + + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 6) & 0x3F)) { + pthis->targetHeight = 400.0f; + pthis->timer = 300; + pthis->actionFunc = func_80AFC218; + } +} + +void func_80AFC3C8(EnSiofuki* pthis, GlobalContext* globalCtx) { + func_80AFBDC8(pthis, globalCtx); + func_80AFBE8C(pthis, globalCtx); + func_80AFC1D0(pthis, globalCtx); + + pthis->timer--; + if (pthis->timer < 0) { + pthis->timer = pthis->activeTime * 20; + pthis->targetHeight = -45.0f; + pthis->actionFunc = func_80AFC218; + } + + if (Flags_GetTreasure(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { + pthis->currentHeight = -45.0f; + pthis->targetHeight = -45.0f; + pthis->actionFunc = func_80AFC544; + } +} + +void func_80AFC478(EnSiofuki* pthis, GlobalContext* globalCtx) { + func_80AFBDC8(pthis, globalCtx); + func_80AFBE8C(pthis, globalCtx); + func_80AFC1D0(pthis, globalCtx); + + if (((u16)pthis->dyna.actor.params >> 0xC & 0xF) == EN_SIOFUKI_LOWERING) { + if (Flags_GetSwitch(globalCtx, ((u16)pthis->dyna.actor.params >> 6) & 0x3F)) { + pthis->timer = 20; + pthis->actionFunc = func_80AFC3C8; + OnePointCutscene_Init(globalCtx, 5010, 40, &pthis->dyna.actor, MAIN_CAM); + } + + if (Flags_GetTreasure(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { + pthis->currentHeight = -45.0f; + pthis->targetHeight = -45.0f; + pthis->actionFunc = func_80AFC544; + } + } +} + +void func_80AFC544(EnSiofuki* pthis, GlobalContext* globalCtx) { + func_80AFBDC8(pthis, globalCtx); + func_80AFC1D0(pthis, globalCtx); +} + +void EnSiofuki_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSiofuki* pthis = (EnSiofuki*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void EnSiofuki_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSiofuki* pthis = (EnSiofuki*)thisx; + u32 x; + u32 y; + u32 gameplayFrames = globalCtx->gameplayFrames; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_siofuki.c", 654); + func_80093D84(globalCtx->state.gfxCtx); + Matrix_Translate(0.0f, pthis->unk_170, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_siofuki.c", 662), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + x = gameplayFrames * 15; + y = gameplayFrames * -15; + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, x, y, 64, 64, 1, x, y, 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, object_siofuki_DL_000B70); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_siofuki.c", 674); + + if (pthis->sfxFlags & 1) { + f32 heightRatio; + switch (((u16)thisx->params >> 0xC) & 0xF) { + case EN_SIOFUKI_RAISING: + heightRatio = (pthis->currentHeight - 10.0f) / (400.0f - 10.0f); + func_800F436C(&thisx->projectedPos, NA_SE_EV_FOUNTAIN - SFX_FLAG, 1.0f + heightRatio); + break; + case EN_SIOFUKI_LOWERING: + if (pthis->currentHeight > -35.0f) { + heightRatio = (pthis->currentHeight - -35.0f) / (pthis->maxHeight - -35.0f); + func_800F436C(&thisx->projectedPos, NA_SE_EV_FOUNTAIN - SFX_FLAG, 1.0f + heightRatio); + } + break; + } + } +} diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c deleted file mode 100644 index 8453ebe02..000000000 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ /dev/null @@ -1,566 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SKB_Z_EN_SKB_C -#include "actor_common.h" -#include "z_en_skb.h" -#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" -#include "objects/object_skb/object_skb.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AFCD60(EnSkb* this); -void func_80AFCDF8(EnSkb* this); -void func_80AFCE5C(EnSkb* this, GlobalContext* globalCtx); -void func_80AFCF48(EnSkb* this); -void func_80AFCFF0(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD0A4(EnSkb* this); -void EnSkb_Advance(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD33C(EnSkb* this); -void EnSkb_SetupAttack(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD47C(EnSkb* this); -void func_80AFD508(EnSkb* this, GlobalContext* globalCtx); -void EnSkb_SetupStunned(EnSkb* this); -void func_80AFD59C(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD6CC(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD7B4(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD880(EnSkb* this, GlobalContext* globalCtx); -void func_80AFD968(EnSkb* this, GlobalContext* globalCtx); - -static ColliderJntSphElementInit sJntSphElementsInit[2] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { 15, { { 0, 0, 0 }, 10 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 1, { { 0, 0, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 2, - sJntSphElementsInit, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0xF), - /* Slingshot */ DMG_ENTRY(1, 0xF), - /* Explosive */ DMG_ENTRY(2, 0xF), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0xF), - /* Hammer swing */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0xE), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(4, 0x7), - /* Ice arrow */ DMG_ENTRY(2, 0xF), - /* Light arrow */ DMG_ENTRY(2, 0xF), - /* Unk arrow 1 */ DMG_ENTRY(2, 0xF), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0x7), - /* Ice magic */ DMG_ENTRY(0, 0x6), - /* Light magic */ DMG_ENTRY(3, 0xD), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0xD), - /* Giant spin */ DMG_ENTRY(4, 0xF), - /* Master spin */ DMG_ENTRY(2, 0xF), - /* Kokiri jump */ DMG_ENTRY(2, 0xF), - /* Giant jump */ DMG_ENTRY(8, 0xF), - /* Master jump */ DMG_ENTRY(4, 0xF), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0xF), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -const ActorInit En_Skb_InitVars = { - ACTOR_EN_SKB, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_SKB, - sizeof(EnSkb), - (ActorFunc)EnSkb_Init, - (ActorFunc)EnSkb_Destroy, - (ActorFunc)EnSkb_Update, - (ActorFunc)EnSkb_Draw, -}; - -void EnSkb_SetupAction(EnSkb* this, EnSkbActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnSkb_SpawnDebris(GlobalContext* globalCtx, EnSkb* this, Vec3f* spawnPos) { - Vec3f pos; - Vec3f vel = { 0.0f, 8.0f, 0.0f }; - Vec3f accel = { 0.0f, -1.5f, 0.0f }; - f32 spreadAngle; - f32 scale; - - spreadAngle = (Rand_ZeroOne() - 0.5f) * 6.28f; - pos.y = this->actor.floorHeight; - pos.x = (Math_SinF(spreadAngle) * 15.0f) + spawnPos->x; - pos.z = (Math_CosF(spreadAngle) * 15.0f) + spawnPos->z; - accel.x = Rand_CenteredFloat(1.0f); - accel.z = Rand_CenteredFloat(1.0f); - vel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - scale = (Rand_ZeroOne() * 5.0f) + 12.0f; - EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accel, 2, scale * 0.8f, -1, 10, 0); - func_80033480(globalCtx, &pos, 10.0f, 1, 150, 0, 1); -} - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), -}; - -void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSkb* this = (EnSkb*)thisx; - s16 paramOffsetBody; - s16 paramOffsetArm; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - this->actor.focus.pos = this->actor.world.pos; - this->actor.colChkInfo.mass = 0xFE; - this->actor.colChkInfo.health = 2; - this->actor.shape.yOffset = -8000.0f; - SkelAnime_Init(globalCtx, &this->skelAnime, &gStalchildSkel, &gStalchildUncurlingAnim, this->jointTable, - this->morphTable, 20); - this->actor.naviEnemyId = 0x55; - - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItem); - Actor_SetScale(&this->actor, ((this->actor.params * 0.1f) + 1.0f) * 0.01f); - - paramOffsetBody = this->actor.params + 0xA; - this->collider.elements[0].dim.worldSphere.radius = paramOffsetBody; - this->collider.elements[0].dim.modelSphere.radius = paramOffsetBody; - if (1) {}; - paramOffsetArm = (this->actor.params * 2) + 0x14; - this->collider.elements[1].dim.worldSphere.radius = paramOffsetArm; - this->collider.elements[1].dim.modelSphere.radius = paramOffsetArm; - this->actor.home.pos = this->actor.world.pos; - this->actor.floorHeight = this->actor.world.pos.y; - func_80AFCDF8(this); -} - -void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSkb* this = (EnSkb*)thisx; - - if (this->actor.parent != NULL) { - EnEncount1* spawner = (EnEncount1*)this->actor.parent; - - if (spawner->actor.update != NULL) { - if (spawner->curNumSpawn > 0) { - spawner->curNumSpawn--; - } - } - } - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void func_80AFCD60(EnSkb* this) { - if (IS_DAY) { - func_80AFCF48(this); - } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && - (this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) { - func_80AFD33C(this); - } else { - func_80AFD0A4(this); - } -} - -void func_80AFCDF8(EnSkb* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalchildUncurlingAnim, 1.0f); - this->unk_280 = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_APPEAR); - EnSkb_SetupAction(this, func_80AFCE5C); -} - -void func_80AFCE5C(EnSkb* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame < 4.0f) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - } else { - this->actor.flags |= ACTOR_FLAG_0; - } - Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 800.0f, 0.0f); - Math_SmoothStepToF(&this->actor.shape.shadowScale, 25.0f, 1.0f, 2.5f, 0.0f); - if ((globalCtx->gameplayFrames & 1) != 0) { - EnSkb_SpawnDebris(globalCtx, this, &this->actor.world.pos); - } - if ((SkelAnime_Update(&this->skelAnime) != 0) && (0.0f == this->actor.shape.yOffset)) { - func_80AFCD60(this); - } -} - -void func_80AFCF48(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildUncurlingAnim, -1.0f, - Animation_GetLastFrame(&gStalchildUncurlingAnim), 0.0f, ANIMMODE_ONCE, -4.0f); - this->unk_280 = 0; - this->unk_281 = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - EnSkb_SetupAction(this, func_80AFCFF0); -} - -void func_80AFCFF0(EnSkb* this, GlobalContext* globalCtx) { - if ((Math_SmoothStepToF(&this->actor.shape.yOffset, -8000.0f, 1.0f, 500.0f, 0.0f) != 0.0f) && - (globalCtx->gameplayFrames & 1)) { - EnSkb_SpawnDebris(globalCtx, this, &this->actor.world.pos); - } - Math_SmoothStepToF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f, 0.0f); - if (SkelAnime_Update(&this->skelAnime) != 0) { - Actor_Kill(&this->actor); - } -} - -void func_80AFD0A4(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildWalkingAnim, 0.96000004f, 0.0f, - Animation_GetLastFrame(&gStalchildWalkingAnim), ANIMMODE_LOOP, -4.0f); - this->unk_280 = 4; - this->unk_288 = 0; - this->actor.speedXZ = this->actor.scale.y * 160.0f; - EnSkb_SetupAction(this, EnSkb_Advance); -} - -void EnSkb_Advance(EnSkb* this, GlobalContext* globalCtx) { - s32 thisKeyFrame; - s32 prevKeyFrame; - f32 playSpeed; - Player* player = GET_PLAYER(globalCtx); - - if ((this->unk_283 != 0) && ((globalCtx->gameplayFrames & 0xF) == 0)) { - this->unk_288 = Rand_CenteredFloat(50000.0f); - } - Math_SmoothStepToS(&this->actor.shape.rot.y, (this->actor.yawTowardsPlayer + this->unk_288), 1, 0x2EE, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - thisKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - if (this->skelAnime.playSpeed >= 0.0f) { - playSpeed = this->skelAnime.playSpeed; - } else { - playSpeed = -this->skelAnime.playSpeed; - } - prevKeyFrame = (this->skelAnime.curFrame - playSpeed); - if (this->skelAnime.playSpeed >= 0.0f) { - playSpeed = this->skelAnime.playSpeed; - } else { - playSpeed = -this->skelAnime.playSpeed; - } - if (thisKeyFrame != (s32)this->skelAnime.curFrame) { - if (((prevKeyFrame < 9) && (((s32)playSpeed + thisKeyFrame) >= 8)) || - !((prevKeyFrame >= 16) || (((s32)playSpeed + thisKeyFrame) < 15))) { - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_WALK); - } - } - if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 800.0f || IS_DAY) { - func_80AFCF48(this); - } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && - (this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) { - func_80AFD33C(this); - } -} - -void func_80AFD33C(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, 0.6f, 0.0f, - Animation_GetLastFrame(&gStalchildAttackingAnim), ANIMMODE_ONCE_INTERP, 4.0f); - this->collider.base.atFlags &= ~4; - this->unk_280 = 3; - this->actor.speedXZ = 0.0f; - EnSkb_SetupAction(this, EnSkb_SetupAttack); -} - -void EnSkb_SetupAttack(EnSkb* this, GlobalContext* globalCtx) { - s32 frameData; - - frameData = this->skelAnime.curFrame; - if (frameData == 3) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - this->unk_281 = 1; - } else if (frameData == 6) { - this->unk_281 = 0; - } - if (this->collider.base.atFlags & 4) { - this->collider.base.atFlags &= ~6; - func_80AFD47C(this); - } else if (SkelAnime_Update(&this->skelAnime) != 0) { - func_80AFCD60(this); - } -} - -void func_80AFD47C(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, - ANIMMODE_ONCE_INTERP, 0.0f); - this->collider.base.atFlags &= ~4; - this->unk_280 = 5; - this->unk_281 = 0; - EnSkb_SetupAction(this, func_80AFD508); -} - -void func_80AFD508(EnSkb* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - func_80AFCD60(this); - } -} - -void EnSkb_SetupStunned(EnSkb* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->unk_281 = 0; - this->unk_280 = 6; - EnSkb_SetupAction(this, func_80AFD59C); -} - -void func_80AFD59C(EnSkb* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - } - if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { - if (this->actor.colChkInfo.health == 0) { - func_80AFD7B4(this, globalCtx); - } else { - func_80AFCD60(this); - } - } -} - -void func_80AFD644(EnSkb* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDamagedAnim, -4.0f); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -4.0f; - } - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_280 = 2; - EnSkb_SetupAction(this, func_80AFD6CC); -} - -void func_80AFD6CC(EnSkb* this, GlobalContext* globalCtx) { - // this cast is likely not real, but allows for a match - u8* new_var; - - new_var = &this->unk_283; - if ((this->unk_283 != 1) || BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, 1)) { - if ((*new_var) != 0) { - this->unk_283 = (*new_var) | 2; - } - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0; - } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x1194, 0); - if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { - func_80AFCD60(this); - } - } -} - -void func_80AFD7B4(EnSkb* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDyingAnim, -4.0f); - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -6.0f; - } - this->unk_280 = 1; - this->actor.flags &= ~ACTOR_FLAG_0; - BodyBreak_Alloc(&this->bodyBreak, 18, globalCtx); - this->unk_283 |= 4; - EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 0x28); - EnSkb_SetupAction(this, func_80AFD880); -} - -void func_80AFD880(EnSkb* this, GlobalContext* globalCtx) { - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, 1)) { - if (this->actor.scale.x == 0.01f) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x10); - } else if (this->actor.scale.x <= 0.015f) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - } - - this->unk_283 |= 8; - Actor_Kill(&this->actor); - } -} - -void func_80AFD968(EnSkb* this, GlobalContext* globalCtx) { - s16 pad; - s32 i; - Vec3f flamePos; - s16 scale; - s16 phi_v1; - Player* player; - - if ((this->unk_280 != 1) && (this->actor.bgCheckFlags & 0x60) && (this->actor.yDistToWater >= 40.0f)) { - this->actor.colChkInfo.health = 0; - this->unk_281 = 0; - func_80AFD7B4(this, globalCtx); - } else if (this->unk_280 >= 3) { - if ((this->collider.base.acFlags & 2) != 0) { - this->collider.base.acFlags &= ~2; - if (this->actor.colChkInfo.damageEffect != 6) { - this->unk_282 = this->actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->actor, &this->collider.elements[1].info, 1); - this->unk_281 = 0; - if (this->actor.colChkInfo.damageEffect == 1) { - if (this->unk_280 != 6) { - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); - Actor_ApplyDamage(&this->actor); - EnSkb_SetupStunned(this); - } - } else { - phi_v1 = 8; - if (this->actor.colChkInfo.damageEffect == 7) { - scale = this->actor.scale.y * 7500.0f; - for (i = 4; i >= 0; i--) { - flamePos = this->actor.world.pos; - flamePos.x += Rand_CenteredFloat(20.0f); - flamePos.z += Rand_CenteredFloat(20.0f); - flamePos.y += (Rand_ZeroOne() * 25.0f); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &flamePos, scale, 0, 0, -1); - } - phi_v1 = 25; - } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, phi_v1); - if (!Actor_ApplyDamage(&this->actor)) { - func_80AFD7B4(this, globalCtx); - return; - } - player = GET_PLAYER(globalCtx); - if (this->unk_283 == 0) { - if ((this->actor.colChkInfo.damageEffect == 0xD) || - ((this->actor.colChkInfo.damageEffect == 0xE) && - ((player->swordAnimation >= 4 && player->swordAnimation <= 11) || - (player->swordAnimation == 20 || player->swordAnimation == 21)))) { - BodyBreak_Alloc(&this->bodyBreak, 2, globalCtx); - this->unk_283 = 1; - } - } - func_80AFD644(this); - } - } - } - } -} - -void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSkb* this = (EnSkb*)thisx; - s32 pad; - - func_80AFD968(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); - this->actionFunc(this, globalCtx); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += (3000.0f * this->actor.scale.y); - if (this->unk_281 != 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (this->unk_280 >= 3) { - if ((this->actor.colorFilterTimer == 0) || ((this->actor.colorFilterParams & 0x4000) == 0)) { - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnSkb* this = (EnSkb*)thisx; - s16 color; - s16 pad[2]; - - if (limbIndex == 11) { - if ((this->unk_283 & 2) == 0) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_skb.c", 972); - color = ABS((s16)(Math_SinS((globalCtx->gameplayFrames * 0x1770)) * 95.0f)) + 160; - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, color, color, color, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_skb.c", 978); - } else { - *dList = NULL; - } - } else if ((limbIndex == 12) && ((this->unk_283 & 2) != 0)) { - *dList = NULL; - } - return 0; -} - -void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnSkb* this = (EnSkb*)thisx; - - Collider_UpdateSpheres(limbIndex, &this->collider); - - if ((this->unk_283 ^ 1) == 0) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_DEFAULT); - } else if ((this->unk_283 ^ (this->unk_283 | 4)) == 0) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_DEFAULT); - } -} - -void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSkb* this = (EnSkb*)thisx; - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, - EnSkb_PostLimbDraw, &this->actor); -} diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.cpp b/src/overlays/actors/ovl_En_Skb/z_en_skb.cpp new file mode 100644 index 000000000..c7216f27a --- /dev/null +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.cpp @@ -0,0 +1,566 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SKB_Z_EN_SKB_C +#include "actor_common.h" +#include "z_en_skb.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/object_skb/object_skb.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80AFCD60(EnSkb* pthis); +void func_80AFCDF8(EnSkb* pthis); +void func_80AFCE5C(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFCF48(EnSkb* pthis); +void func_80AFCFF0(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD0A4(EnSkb* pthis); +void EnSkb_Advance(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD33C(EnSkb* pthis); +void EnSkb_SetupAttack(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD47C(EnSkb* pthis); +void func_80AFD508(EnSkb* pthis, GlobalContext* globalCtx); +void EnSkb_SetupStunned(EnSkb* pthis); +void func_80AFD59C(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD6CC(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD7B4(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD880(EnSkb* pthis, GlobalContext* globalCtx); +void func_80AFD968(EnSkb* pthis, GlobalContext* globalCtx); + +static ColliderJntSphElementInit sJntSphElementsInit[2] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { 15, { { 0, 0, 0 }, 10 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 1, { { 0, 0, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0xF), + /* Slingshot */ DMG_ENTRY(1, 0xF), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0xF), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0xE), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(4, 0x7), + /* Ice arrow */ DMG_ENTRY(2, 0xF), + /* Light arrow */ DMG_ENTRY(2, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(2, 0xF), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0x7), + /* Ice magic */ DMG_ENTRY(0, 0x6), + /* Light magic */ DMG_ENTRY(3, 0xD), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xD), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(2, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +ActorInit En_Skb_InitVars = { + ACTOR_EN_SKB, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_SKB, + sizeof(EnSkb), + (ActorFunc)EnSkb_Init, + (ActorFunc)EnSkb_Destroy, + (ActorFunc)EnSkb_Update, + (ActorFunc)EnSkb_Draw, +}; + +void EnSkb_SetupAction(EnSkb* pthis, EnSkbActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnSkb_SpawnDebris(GlobalContext* globalCtx, EnSkb* pthis, Vec3f* spawnPos) { + Vec3f pos; + Vec3f vel = { 0.0f, 8.0f, 0.0f }; + Vec3f accel = { 0.0f, -1.5f, 0.0f }; + f32 spreadAngle; + f32 scale; + + spreadAngle = (Rand_ZeroOne() - 0.5f) * 6.28f; + pos.y = pthis->actor.floorHeight; + pos.x = (Math_SinF(spreadAngle) * 15.0f) + spawnPos->x; + pos.z = (Math_CosF(spreadAngle) * 15.0f) + spawnPos->z; + accel.x = Rand_CenteredFloat(1.0f); + accel.z = Rand_CenteredFloat(1.0f); + vel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; + scale = (Rand_ZeroOne() * 5.0f) + 12.0f; + EffectSsHahen_Spawn(globalCtx, &pos, &vel, &accel, 2, scale * 0.8f, -1, 10, 0); + func_80033480(globalCtx, &pos, 10.0f, 1, 150, 0, 1); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), +}; + +void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSkb* pthis = (EnSkb*)thisx; + s16 paramOffsetBody; + s16 paramOffsetArm; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.colChkInfo.mass = 0xFE; + pthis->actor.colChkInfo.health = 2; + pthis->actor.shape.yOffset = -8000.0f; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gStalchildSkel, &gStalchildUncurlingAnim, pthis->jointTable, + pthis->morphTable, 20); + pthis->actor.naviEnemyId = 0x55; + + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItem); + Actor_SetScale(&pthis->actor, ((pthis->actor.params * 0.1f) + 1.0f) * 0.01f); + + paramOffsetBody = pthis->actor.params + 0xA; + pthis->collider.elements[0].dim.worldSphere.radius = paramOffsetBody; + pthis->collider.elements[0].dim.modelSphere.radius = paramOffsetBody; + if (1) {}; + paramOffsetArm = (pthis->actor.params * 2) + 0x14; + pthis->collider.elements[1].dim.worldSphere.radius = paramOffsetArm; + pthis->collider.elements[1].dim.modelSphere.radius = paramOffsetArm; + pthis->actor.home.pos = pthis->actor.world.pos; + pthis->actor.floorHeight = pthis->actor.world.pos.y; + func_80AFCDF8(pthis); +} + +void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSkb* pthis = (EnSkb*)thisx; + + if (pthis->actor.parent != NULL) { + EnEncount1* spawner = (EnEncount1*)pthis->actor.parent; + + if (spawner->actor.update != NULL) { + if (spawner->curNumSpawn > 0) { + spawner->curNumSpawn--; + } + } + } + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void func_80AFCD60(EnSkb* pthis) { + if (IS_DAY) { + func_80AFCF48(pthis); + } else if (Actor_IsFacingPlayer(&pthis->actor, 0x11C7) && + (pthis->actor.xzDistToPlayer < (60.0f + (pthis->actor.params * 6.0f)))) { + func_80AFD33C(pthis); + } else { + func_80AFD0A4(pthis); + } +} + +void func_80AFCDF8(EnSkb* pthis) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gStalchildUncurlingAnim, 1.0f); + pthis->unk_280 = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIVA_APPEAR); + EnSkb_SetupAction(pthis, func_80AFCE5C); +} + +void func_80AFCE5C(EnSkb* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame < 4.0f) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + } else { + pthis->actor.flags |= ACTOR_FLAG_0; + } + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 0.0f, 1.0f, 800.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.shape.shadowScale, 25.0f, 1.0f, 2.5f, 0.0f); + if ((globalCtx->gameplayFrames & 1) != 0) { + EnSkb_SpawnDebris(globalCtx, pthis, &pthis->actor.world.pos); + } + if ((SkelAnime_Update(&pthis->skelAnime) != 0) && (0.0f == pthis->actor.shape.yOffset)) { + func_80AFCD60(pthis); + } +} + +void func_80AFCF48(EnSkb* pthis) { + Animation_Change(&pthis->skelAnime, &gStalchildUncurlingAnim, -1.0f, + Animation_GetLastFrame(&gStalchildUncurlingAnim), 0.0f, ANIMMODE_ONCE, -4.0f); + pthis->unk_280 = 0; + pthis->unk_281 = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_AKINDONUTS_HIDE); + EnSkb_SetupAction(pthis, func_80AFCFF0); +} + +void func_80AFCFF0(EnSkb* pthis, GlobalContext* globalCtx) { + if ((Math_SmoothStepToF(&pthis->actor.shape.yOffset, -8000.0f, 1.0f, 500.0f, 0.0f) != 0.0f) && + (globalCtx->gameplayFrames & 1)) { + EnSkb_SpawnDebris(globalCtx, pthis, &pthis->actor.world.pos); + } + Math_SmoothStepToF(&pthis->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f, 0.0f); + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_80AFD0A4(EnSkb* pthis) { + Animation_Change(&pthis->skelAnime, &gStalchildWalkingAnim, 0.96000004f, 0.0f, + Animation_GetLastFrame(&gStalchildWalkingAnim), ANIMMODE_LOOP, -4.0f); + pthis->unk_280 = 4; + pthis->unk_288 = 0; + pthis->actor.speedXZ = pthis->actor.scale.y * 160.0f; + EnSkb_SetupAction(pthis, EnSkb_Advance); +} + +void EnSkb_Advance(EnSkb* pthis, GlobalContext* globalCtx) { + s32 thisKeyFrame; + s32 prevKeyFrame; + f32 playSpeed; + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->unk_283 != 0) && ((globalCtx->gameplayFrames & 0xF) == 0)) { + pthis->unk_288 = Rand_CenteredFloat(50000.0f); + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, (pthis->actor.yawTowardsPlayer + pthis->unk_288), 1, 0x2EE, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + thisKeyFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + if (pthis->skelAnime.playSpeed >= 0.0f) { + playSpeed = pthis->skelAnime.playSpeed; + } else { + playSpeed = -pthis->skelAnime.playSpeed; + } + prevKeyFrame = (pthis->skelAnime.curFrame - playSpeed); + if (pthis->skelAnime.playSpeed >= 0.0f) { + playSpeed = pthis->skelAnime.playSpeed; + } else { + playSpeed = -pthis->skelAnime.playSpeed; + } + if (thisKeyFrame != (s32)pthis->skelAnime.curFrame) { + if (((prevKeyFrame < 9) && (((s32)playSpeed + thisKeyFrame) >= 8)) || + !((prevKeyFrame >= 16) || (((s32)playSpeed + thisKeyFrame) < 15))) { + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_WALK); + } + } + if (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) > 800.0f || IS_DAY) { + func_80AFCF48(pthis); + } else if (Actor_IsFacingPlayer(&pthis->actor, 0x11C7) && + (pthis->actor.xzDistToPlayer < (60.0f + (pthis->actor.params * 6.0f)))) { + func_80AFD33C(pthis); + } +} + +void func_80AFD33C(EnSkb* pthis) { + Animation_Change(&pthis->skelAnime, &gStalchildAttackingAnim, 0.6f, 0.0f, + Animation_GetLastFrame(&gStalchildAttackingAnim), ANIMMODE_ONCE_INTERP, 4.0f); + pthis->collider.base.atFlags &= ~4; + pthis->unk_280 = 3; + pthis->actor.speedXZ = 0.0f; + EnSkb_SetupAction(pthis, EnSkb_SetupAttack); +} + +void EnSkb_SetupAttack(EnSkb* pthis, GlobalContext* globalCtx) { + s32 frameData; + + frameData = pthis->skelAnime.curFrame; + if (frameData == 3) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_ATTACK); + pthis->unk_281 = 1; + } else if (frameData == 6) { + pthis->unk_281 = 0; + } + if (pthis->collider.base.atFlags & 4) { + pthis->collider.base.atFlags &= ~6; + func_80AFD47C(pthis); + } else if (SkelAnime_Update(&pthis->skelAnime) != 0) { + func_80AFCD60(pthis); + } +} + +void func_80AFD47C(EnSkb* pthis) { + Animation_Change(&pthis->skelAnime, &gStalchildAttackingAnim, -0.4f, pthis->skelAnime.curFrame - 1.0f, 0.0f, + ANIMMODE_ONCE_INTERP, 0.0f); + pthis->collider.base.atFlags &= ~4; + pthis->unk_280 = 5; + pthis->unk_281 = 0; + EnSkb_SetupAction(pthis, func_80AFD508); +} + +void func_80AFD508(EnSkb* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + func_80AFCD60(pthis); + } +} + +void EnSkb_SetupStunned(EnSkb* pthis) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = 0.0f; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->unk_281 = 0; + pthis->unk_280 = 6; + EnSkb_SetupAction(pthis, func_80AFD59C); +} + +void func_80AFD59C(EnSkb* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + } + if ((pthis->actor.colorFilterTimer == 0) && (pthis->actor.bgCheckFlags & 1)) { + if (pthis->actor.colChkInfo.health == 0) { + func_80AFD7B4(pthis, globalCtx); + } else { + func_80AFCD60(pthis); + } + } +} + +void func_80AFD644(EnSkb* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gStalchildDamagedAnim, -4.0f); + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = -4.0f; + } + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALKID_DAMAGE); + pthis->unk_280 = 2; + EnSkb_SetupAction(pthis, func_80AFD6CC); +} + +void func_80AFD6CC(EnSkb* pthis, GlobalContext* globalCtx) { + // pthis cast is likely not real, but allows for a match + u8* new_var; + + new_var = &pthis->unk_283; + if ((pthis->unk_283 != 1) || BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, 1)) { + if ((*new_var) != 0) { + pthis->unk_283 = (*new_var) | 2; + } + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0; + } + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x1194, 0); + if (SkelAnime_Update(&pthis->skelAnime) && (pthis->actor.bgCheckFlags & 1)) { + func_80AFCD60(pthis); + } + } +} + +void func_80AFD7B4(EnSkb* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gStalchildDyingAnim, -4.0f); + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = -6.0f; + } + pthis->unk_280 = 1; + pthis->actor.flags &= ~ACTOR_FLAG_0; + BodyBreak_Alloc(&pthis->bodyBreak, 18, globalCtx); + pthis->unk_283 |= 4; + EffectSsDeadSound_SpawnStationary(globalCtx, &pthis->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 0x28); + EnSkb_SetupAction(pthis, func_80AFD880); +} + +void func_80AFD880(EnSkb* pthis, GlobalContext* globalCtx) { + if (BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, 1)) { + if (pthis->actor.scale.x == 0.01f) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x10); + } else if (pthis->actor.scale.x <= 0.015f) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_RUPEE_BLUE); + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_RUPEE_RED); + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_RUPEE_RED); + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, ITEM00_RUPEE_RED); + } + + pthis->unk_283 |= 8; + Actor_Kill(&pthis->actor); + } +} + +void func_80AFD968(EnSkb* pthis, GlobalContext* globalCtx) { + s16 pad; + s32 i; + Vec3f flamePos; + s16 scale; + s16 phi_v1; + Player* player; + + if ((pthis->unk_280 != 1) && (pthis->actor.bgCheckFlags & 0x60) && (pthis->actor.yDistToWater >= 40.0f)) { + pthis->actor.colChkInfo.health = 0; + pthis->unk_281 = 0; + func_80AFD7B4(pthis, globalCtx); + } else if (pthis->unk_280 >= 3) { + if ((pthis->collider.base.acFlags & 2) != 0) { + pthis->collider.base.acFlags &= ~2; + if (pthis->actor.colChkInfo.damageEffect != 6) { + pthis->unk_282 = pthis->actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.elements[1].info, 1); + pthis->unk_281 = 0; + if (pthis->actor.colChkInfo.damageEffect == 1) { + if (pthis->unk_280 != 6) { + Actor_SetColorFilter(&pthis->actor, 0, 0x78, 0, 0x50); + Actor_ApplyDamage(&pthis->actor); + EnSkb_SetupStunned(pthis); + } + } else { + phi_v1 = 8; + if (pthis->actor.colChkInfo.damageEffect == 7) { + scale = pthis->actor.scale.y * 7500.0f; + for (i = 4; i >= 0; i--) { + flamePos = pthis->actor.world.pos; + flamePos.x += Rand_CenteredFloat(20.0f); + flamePos.z += Rand_CenteredFloat(20.0f); + flamePos.y += (Rand_ZeroOne() * 25.0f); + EffectSsEnFire_SpawnVec3f(globalCtx, &pthis->actor, &flamePos, scale, 0, 0, -1); + } + phi_v1 = 25; + } + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, phi_v1); + if (!Actor_ApplyDamage(&pthis->actor)) { + func_80AFD7B4(pthis, globalCtx); + return; + } + player = GET_PLAYER(globalCtx); + if (pthis->unk_283 == 0) { + if ((pthis->actor.colChkInfo.damageEffect == 0xD) || + ((pthis->actor.colChkInfo.damageEffect == 0xE) && + ((player->swordAnimation >= 4 && player->swordAnimation <= 11) || + (player->swordAnimation == 20 || player->swordAnimation == 21)))) { + BodyBreak_Alloc(&pthis->bodyBreak, 2, globalCtx); + pthis->unk_283 = 1; + } + } + func_80AFD644(pthis); + } + } + } + } +} + +void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSkb* pthis = (EnSkb*)thisx; + s32 pad; + + func_80AFD968(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 15.0f, 30.0f, 60.0f, 0x1D); + pthis->actionFunc(pthis, globalCtx); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += (3000.0f * pthis->actor.scale.y); + if (pthis->unk_281 != 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (pthis->unk_280 >= 3) { + if ((pthis->actor.colorFilterTimer == 0) || ((pthis->actor.colorFilterParams & 0x4000) == 0)) { + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnSkb* pthis = (EnSkb*)thisx; + s16 color; + s16 pad[2]; + + if (limbIndex == 11) { + if ((pthis->unk_283 & 2) == 0) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_skb.c", 972); + color = ABS((s16)(Math_SinS((globalCtx->gameplayFrames * 0x1770)) * 95.0f)) + 160; + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, color, color, color, 255); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_skb.c", 978); + } else { + *dList = NULL; + } + } else if ((limbIndex == 12) && ((pthis->unk_283 & 2) != 0)) { + *dList = NULL; + } + return 0; +} + +void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnSkb* pthis = (EnSkb*)thisx; + + Collider_UpdateSpheres(limbIndex, &pthis->collider); + + if ((pthis->unk_283 ^ 1) == 0) { + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_DEFAULT); + } else if ((pthis->unk_283 ^ (pthis->unk_283 | 4)) == 0) { + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_DEFAULT); + } +} + +void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSkb* pthis = (EnSkb*)thisx; + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnSkb_OverrideLimbDraw, + EnSkb_PostLimbDraw, &pthis->actor); +} diff --git a/src/overlays/actors/ovl_En_Skj/z_en_skj.c b/src/overlays/actors/ovl_En_Skj/z_en_skj.c deleted file mode 100644 index 17fb3ebfe..000000000 --- a/src/overlays/actors/ovl_En_Skj/z_en_skj.c +++ /dev/null @@ -1,1675 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SKJ_Z_EN_SKJ_C -#include "actor_common.h" -#include "z_en_skj.h" -#include "overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.h" -#include "objects/object_skj/object_skj.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_25) - -void EnSkj_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSkj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSkj_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSkj_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnSkj_SariasSongShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx); -void EnSkj_OcarinaMinigameShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx); - -void func_80AFF2A0(EnSkj* this); -void func_80AFF334(EnSkj* this); - -void EnSkj_CalculateCenter(EnSkj* this); -void EnSkj_OcarinaGameSetupWaitForPlayer(EnSkj* this); -void EnSkj_SetupResetFight(EnSkj* this); -void EnSkj_SetupLeaveOcarinaGame(EnSkj* this); -void EnSkj_SetupPlayOcarinaGame(EnSkj* this); -void EnSkj_Backflip(EnSkj* this); -void EnSkj_SetupNeedleRecover(EnSkj* this); -void EnSkj_SetupSpawnDeathEffect(EnSkj* this); -void EnSkj_SetupStand(EnSkj* this); -void EnSkj_SetupWaitForSong(EnSkj* this); -void EnSkj_SetupTalk(EnSkj* this); -void EnSkj_SetupMaskTrade(EnSkj* this); -void EnSkj_SetupWrongSong(EnSkj* this); -void EnSkj_SetupAfterSong(EnSkj* this); -void func_80AFFE24(EnSkj* this); -void EnSkj_SetupPostSariasSong(EnSkj* this); -void EnSkj_JumpFromStump(EnSkj* this); -void EnSkj_SetupWaitForLandAnimFinish(EnSkj* this); -void EnSkj_SetupWalkToPlayer(EnSkj* this); -void EnSkj_SetupWaitForMaskTextClear(EnSkj* this); -void EnSkj_SetupWaitForTextClear(EnSkj* this); -void EnSkj_SetupDie(EnSkj* this); -void func_80AFF1F0(EnSkj* this); -void EnSkj_OfferNextRound(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SetupAskForMask(EnSkj* this, GlobalContext* globalCtx); -f32 EnSkj_GetItemXzRange(EnSkj* this); -s32 EnSkj_CollisionCheck(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SetupTakeMask(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_TurnPlayer(EnSkj* this, Player* player); - -void EnSkj_SetupWaitForOcarina(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_StartOcarinaMinigame(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForOcarina(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForPlayback(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_FailedMiniGame(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WonOcarinaMiniGame(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitToGiveReward(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_GiveOcarinaGameReward(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_FinishOcarinaGameRound(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForNextRound(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForOfferResponse(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SetupWaitForOcarina(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_CleanupOcarinaGame(EnSkj* this, GlobalContext* globalCtx); - -void EnSkj_Fade(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitToShootNeedle(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SariasSongKidIdle(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForDeathAnim(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_PickNextFightAction(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForLandAnim(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_ResetFight(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_Fight(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_NeedleRecover(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SpawnDeathEffect(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitInRange(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForSong(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_AfterSong(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SariaSongTalk(EnSkj* this, GlobalContext* globalCtx); -void func_80AFFE44(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_ChangeModeAfterSong(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_StartMaskTrade(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForLanding(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForLandAnimFinish(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WalkToPlayer(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_AskForMask(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_TakeMask(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WaitForMaskTextClear(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_WrongSong(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_SariasSongWaitForTextClear(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_OcarinaGameWaitForPlayer(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_OcarinaGameIdle(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_PlayOcarinaGame(EnSkj* this, GlobalContext* globalCtx); -void EnSkj_LeaveOcarinaGame(EnSkj* this, GlobalContext* globalCtx); - -void EnSkj_SpawnBlood(GlobalContext* globalCtx, Vec3f* pos); - -void EnSkj_SetupWaitInRange(EnSkj* this); - -#define songFailTimer multiuseTimer -#define battleExitTimer multiuseTimer - -typedef enum { - /* 0 */ SKJ_ANIM_BACKFLIP, - /* 1 */ SKJ_ANIM_SHOOT_NEEDLE, - /* 2 */ SKJ_ANIM_PLAY_FLUTE, - /* 3 */ SKJ_ANIM_DIE, - /* 4 */ SKJ_ANIM_HIT, - /* 5 */ SKJ_ANIM_LAND, - /* 6 */ SKJ_ANIM_LOOK_LEFT_RIGHT, - /* 7 */ SKJ_ANIM_FIGHTING_STANCE, - /* 8 */ SKJ_ANIM_WALK_TO_PLAYER, - /* 9 */ SKJ_ANIM_WAIT -} SkullKidAnim; - -typedef enum { - /* 0 */ SKULL_KID_LEFT, - /* 1 */ SKULL_KID_RIGHT -} SkullKidStumpSide; - -typedef enum { - /* 0 */ SKULL_KID_OCRAINA_WAIT, - /* 1 */ SKULL_KID_OCARINA_PLAY_NOTES, - /* 2 */ SKULL_KID_OCARINA_LEAVE_GAME -} SkullKidOcarinaGameState; - -typedef enum { - /* 00 */ SKJ_ACTION_FADE, - /* 01 */ SKJ_ACTION_WAIT_TO_SHOOT_NEEDLE, - /* 02 */ SKJ_ACTION_SARIA_SONG_IDLE, - /* 03 */ SKJ_ACTION_WAIT_FOR_DEATH_ANIM, - /* 04 */ SKJ_ACTION_PICK_NEXT_FIHGT_ACTION, - /* 05 */ SKJ_ACTION_WAIT_FOR_LAND_ANIM, - /* 06 */ SKJ_ACTION_RESET_FIGHT, - /* 07 */ SKJ_ACTION_FIGHT, - /* 08 */ SKJ_ACTION_NEEDLE_RECOVER, - /* 09 */ SKJ_ACTION_SPAWN_DEATH_EFFECT, - /* 10 */ SKJ_ACTION_SARIA_SONG_WAIT_IN_RANGE, - /* 11 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_SONG, - /* 12 */ SKJ_ACTION_SARIA_SONG_AFTER_SONG, - /* 13 */ SKJ_ACTION_SARIA_TALK, - /* 14 */ SKJ_ACTION_UNK14, - /* 15 */ SKJ_ACTION_SARIA_SONG_CHANGE_MODE, - /* 16 */ SKJ_ACTION_SARIA_SONG_START_TRADE, - /* 17 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING, - /* 18 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING_ANIM, - /* 19 */ SKJ_ACTION_SARIA_SONG_WALK_TO_PLAYER, - /* 20 */ SKJ_ACTION_SARIA_SONG_ASK_FOR_MASK, - /* 21 */ SKJ_ACTION_SARIA_SONG_TAKE_MASK, - /* 22 */ SKJ_ACTION_SARIA_SONG_WAIT_MASK_TEXT, - /* 23 */ SKJ_ACTION_SARIA_SONG_WRONG_SONG, - /* 24 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_TEXT, - /* 25 */ SKJ_ACTION_OCARINA_GAME_WAIT_FOR_PLAYER, - /* 26 */ SKJ_ACTION_OCARINA_GAME_IDLE, - /* 27 */ SKJ_ACTION_OCARINA_GAME_PLAY, - /* 28 */ SKJ_ACTION_OCARINA_GAME_LEAVE -} SkullKidAction; - -typedef struct { - u8 unk0; - EnSkj* skullkid; -} unkSkjStruct; - -static unkSkjStruct sSmallStumpSkullKid = { 0, NULL }; -static unkSkjStruct sOcarinaMinigameSkullKids[] = { { 0, NULL }, { 0, NULL } }; - -const ActorInit En_Skj_InitVars = { - ACTOR_EN_SKJ, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_SKJ, - sizeof(EnSkj), - (ActorFunc)EnSkj_Init, - (ActorFunc)EnSkj_Destroy, - (ActorFunc)EnSkj_Update, - (ActorFunc)EnSkj_Draw, -}; - -static ColliderCylinderInitType1 D_80B01678 = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x0, 0x08 }, - { 0xFFCFFFFF, 0x0, 0x0 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 8, 48, 0, { 0, 0, 0 } }, -}; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x0), - /* Deku stick */ DMG_ENTRY(0, 0x0), - /* Slingshot */ DMG_ENTRY(0, 0x0), - /* Explosive */ DMG_ENTRY(0, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0xF), - /* Master sword */ DMG_ENTRY(2, 0xF), - /* Giant's Knife */ DMG_ENTRY(4, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(0, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static s32 sOcarinaGameRewards[] = { - GI_RUPEE_GREEN, - GI_RUPEE_BLUE, - GI_HEART_PIECE, - GI_RUPEE_RED, -}; - -typedef struct { - AnimationHeader* animation; - u8 mode; - f32 morphFrames; -} SkullkidAnimationEntry; - -static SkullkidAnimationEntry sSkullKidAnimations[] = { - { &gSkullKidBackflipAnim, ANIMMODE_ONCE, 0.0f }, - { &gSkullKidShootNeedleAnim, ANIMMODE_ONCE, 0.0f }, - { &gSkullKidPlayFluteAnim, ANIMMODE_LOOP, 0.0f }, - { &gSkullKidDieAnim, ANIMMODE_ONCE, 0.0f }, - { &gSkullKidHitAnim, ANIMMODE_ONCE, 0.0f }, - { &gSkullKidLandAnim, ANIMMODE_ONCE, 0.0f }, - { &gSkullKidLookLeftAndRightAnim, ANIMMODE_LOOP, 0.0f }, - { &gSkullKidFightingStanceAnim, ANIMMODE_LOOP, 0.0f }, - { &gSkullKidWalkToPlayerAnim, ANIMMODE_LOOP, 0.0f }, - { &gSkullKidWaitAnim, ANIMMODE_LOOP, 0.0f }, -}; - -static EnSkjActionFunc sActionFuncs[] = { - EnSkj_Fade, - EnSkj_WaitToShootNeedle, - EnSkj_SariasSongKidIdle, - EnSkj_WaitForDeathAnim, - EnSkj_PickNextFightAction, - EnSkj_WaitForLandAnim, - EnSkj_ResetFight, - EnSkj_Fight, - EnSkj_NeedleRecover, - EnSkj_SpawnDeathEffect, - EnSkj_WaitInRange, - EnSkj_WaitForSong, - EnSkj_AfterSong, - EnSkj_SariaSongTalk, - func_80AFFE44, - EnSkj_ChangeModeAfterSong, - EnSkj_StartMaskTrade, - EnSkj_WaitForLanding, - EnSkj_WaitForLandAnimFinish, - EnSkj_WalkToPlayer, - EnSkj_AskForMask, - EnSkj_TakeMask, - EnSkj_WaitForMaskTextClear, - EnSkj_WrongSong, - EnSkj_SariasSongWaitForTextClear, - EnSkj_OcarinaGameWaitForPlayer, - EnSkj_OcarinaGameIdle, - EnSkj_PlayOcarinaGame, - EnSkj_LeaveOcarinaGame, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), -}; - -static s32 D_80B01EA0; // gets set if ACTOR_FLAG_8 is set - -void EnSkj_ChangeAnim(EnSkj* this, u8 animIndex) { - f32 endFrame = Animation_GetLastFrame(sSkullKidAnimations[animIndex].animation); - - this->animIndex = animIndex; - Animation_Change(&this->skelAnime, sSkullKidAnimations[animIndex].animation, 1.0f, 0.0f, endFrame, - sSkullKidAnimations[animIndex].mode, sSkullKidAnimations[animIndex].morphFrames); -} - -void EnSkj_SetupAction(EnSkj* this, u8 action) { - this->action = action; - this->actionFunc = sActionFuncs[action]; - - switch (action) { - case SKJ_ACTION_FADE: - case SKJ_ACTION_WAIT_FOR_DEATH_ANIM: - case SKJ_ACTION_PICK_NEXT_FIHGT_ACTION: - case SKJ_ACTION_SPAWN_DEATH_EFFECT: - case SKJ_ACTION_SARIA_SONG_START_TRADE: - case SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING: - case SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING_ANIM: - case SKJ_ACTION_SARIA_SONG_WALK_TO_PLAYER: - case SKJ_ACTION_SARIA_SONG_ASK_FOR_MASK: - case SKJ_ACTION_SARIA_SONG_TAKE_MASK: - case SKJ_ACTION_SARIA_SONG_WAIT_MASK_TEXT: - case SKJ_ACTION_SARIA_SONG_WRONG_SONG: - case SKJ_ACTION_SARIA_SONG_WAIT_FOR_TEXT: - case SKJ_ACTION_OCARINA_GAME_WAIT_FOR_PLAYER: - case SKJ_ACTION_OCARINA_GAME_IDLE: - case SKJ_ACTION_OCARINA_GAME_PLAY: - case SKJ_ACTION_OCARINA_GAME_LEAVE: - this->unk_2D3 = 0; - break; - default: - this->unk_2D3 = 1; - break; - } -} - -void EnSkj_CalculateCenter(EnSkj* this) { - Vec3f mult; - - mult.x = 0.0f; - mult.y = 0.0f; - mult.z = 120.0f; - - Matrix_RotateY((this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&mult, &this->center); - - this->center.x += this->actor.world.pos.x; - this->center.z += this->actor.world.pos.z; -} - -void EnSkj_SetNaviId(EnSkj* this) { - switch (this->actor.params) { - case 0: - if (gSaveContext.itemGetInf[3] & 0x200) { - this->actor.naviEnemyId = 0x41; // Skull kid with skull mask - } else if (gSaveContext.itemGetInf[1] & 0x40) { - this->actor.naviEnemyId = 0x40; // Skull kid after Saria's song but no mask - } else { - this->actor.naviEnemyId = 0x3F; // No Sarias song no skull mask - } - break; - - case 1: - case 2: - this->actor.naviEnemyId = 0x3F; - break; - - default: - this->actor.naviEnemyId = 0x36; // Skull kid as adult - break; - } -} - -void EnSkj_Init(Actor* thisx, GlobalContext* globalCtx2) { - s16 type = (thisx->params >> 0xA) & 0x3F; - EnSkj* this = (EnSkj*)thisx; - GlobalContext* globalCtx = globalCtx2; - s32 pad; - Player* player; - - Actor_ProcessInitChain(thisx, sInitChain); - switch (type) { - case 5: // Invisible on the small stump (sarias song)) - sSmallStumpSkullKid.unk0 = 1; - sSmallStumpSkullKid.skullkid = (EnSkj*)thisx; - this->actor.destroy = NULL; - this->actor.draw = NULL; - this->actor.update = EnSkj_SariasSongShortStumpUpdate; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actor.flags |= 0; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); - break; - - case 6: // Invisible on the short stump (ocarina game) - sSmallStumpSkullKid.unk0 = 1; - sSmallStumpSkullKid.skullkid = (EnSkj*)thisx; - this->actor.destroy = NULL; - this->actor.draw = NULL; - this->actor.update = EnSkj_OcarinaMinigameShortStumpUpdate; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actor.flags |= 0; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); - this->actor.focus.pos.x = 1230.0f; - this->actor.focus.pos.y = -90.0f; - this->actor.focus.pos.z = 450.0f; - this->actionFunc = EnSkj_SetupWaitForOcarina; - break; - - default: - this->actor.params = type; - if (((this->actor.params != 0) && (this->actor.params != 1)) && (this->actor.params != 2)) { - if (INV_CONTENT(ITEM_TRADE_ADULT) < ITEM_SAW) { - Actor_Kill(&this->actor); - return; - } - } - - EnSkj_SetNaviId(this); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, &gSkullKidPlayFluteAnim, this->jointTable, - this->morphTable, 19); - if ((type >= 0) && (type < 3)) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); - } - - if ((type < 0) || (type >= 7)) { - this->actor.flags &= ~ACTOR_FLAG_25; - } - - if ((type > 0) && (type < 3)) { - this->actor.targetMode = 7; - this->posCopy = this->actor.world.pos; - sOcarinaMinigameSkullKids[type - 1].unk0 = 1; - sOcarinaMinigameSkullKids[type - 1].skullkid = this; - this->minigameState = 0; - this->alpha = 0; - EnSkj_OcarinaGameSetupWaitForPlayer(this); - } else { - this->alpha = 255; - EnSkj_SetupResetFight(this); - } - - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.health = 10; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &D_80B01678); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - Actor_SetScale(thisx, 0.01f); - this->actor.textId = this->textId = 0; - this->multiuseTimer = 0; - this->backfilpFlag = 0; - this->needlesToShoot = 3; - this->hitsUntilDodge = 3; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -1.0f; - EnSkj_CalculateCenter(this); - - player = GET_PLAYER(globalCtx); - osSyncPrintf("Player_X : %f\n", player->actor.world.pos.x); - osSyncPrintf("Player_Z : %f\n", player->actor.world.pos.z); - osSyncPrintf("World_X : %f\n", this->actor.world.pos.x); - osSyncPrintf("World_Z : %f\n", this->actor.world.pos.z); - osSyncPrintf("Center_X : %f\n", this->center.x); - osSyncPrintf("Center_Z : %f\n\n", this->center.z); - - break; - } -} - -void EnSkj_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSkj* this = (EnSkj*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -s32 EnSkj_RangeCheck(Player* player, EnSkj* this) { - f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; - f32 zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - f32 yDiff = player->actor.world.pos.y - this->actor.world.pos.y; - - return (SQ(xDiff) + SQ(zDiff) <= 676.0f) && (yDiff >= 0.0f); -} - -f32 EnSkj_GetItemXzRange(EnSkj* this) { - EnSkj* temp_v0; - f32 zDiff; - f32 xDiff; - - temp_v0 = sSmallStumpSkullKid.skullkid; - xDiff = temp_v0->actor.world.pos.x - this->actor.world.pos.x; - zDiff = temp_v0->actor.world.pos.z - this->actor.world.pos.z; - return sqrtf(SQ(xDiff) + SQ(zDiff)) + 26.0f; -} - -f32 EnSkj_GetItemYRange(EnSkj* this) { - return fabsf(sSmallStumpSkullKid.skullkid->actor.world.pos.y - this->actor.world.pos.y) + 10.0f; -} - -s32 EnSkj_ShootNeedle(EnSkj* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f pos; - Vec3f pos2; - EnSkjneedle* needle; - - pos.x = 1.5f; - pos.y = 0.0f; - pos.z = 40.0f; - - Matrix_RotateY((this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&pos, &pos2); - - pos2.x += this->actor.world.pos.x; - pos2.z += this->actor.world.pos.z; - pos2.y = this->actor.world.pos.y + 27.0f; - - needle = (EnSkjneedle*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SKJNEEDLE, pos2.x, pos2.y, pos2.z, - this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 0); - if (needle != NULL) { - needle->killTimer = 100; - needle->actor.speedXZ = 24.0f; - return 1; - } - return 0; -} - -void EnSkj_SpawnBlood(GlobalContext* globalCtx, Vec3f* pos) { - EffectSparkInit effect; - s32 sp20; - - effect.position.x = pos->x; - effect.position.y = pos->y; - effect.position.z = pos->z; - effect.uDiv = 5; - effect.vDiv = 5; - - effect.colorStart[0].r = 0; - effect.colorStart[0].g = 0; - effect.colorStart[0].b = 128; - effect.colorStart[0].a = 255; - - effect.colorStart[1].r = 0; - effect.colorStart[1].g = 0; - effect.colorStart[1].b = 128; - effect.colorStart[1].a = 255; - - effect.colorStart[2].r = 0; - effect.colorStart[2].g = 0; - effect.colorStart[2].b = 128; - effect.colorStart[2].a = 255; - - effect.colorStart[3].r = 0; - effect.colorStart[3].g = 0; - effect.colorStart[3].b = 128; - effect.colorStart[3].a = 255; - - effect.colorEnd[0].r = 0; - effect.colorEnd[0].g = 0; - effect.colorEnd[0].b = 32; - effect.colorEnd[0].a = 0; - - effect.colorEnd[1].r = 0; - effect.colorEnd[1].g = 0; - effect.colorEnd[1].b = 32; - effect.colorEnd[1].a = 0; - - effect.colorEnd[2].r = 0; - effect.colorEnd[2].g = 0; - effect.colorEnd[2].b = 64; - effect.colorEnd[2].a = 0; - - effect.colorEnd[3].r = 0; - effect.colorEnd[3].g = 0; - effect.colorEnd[3].b = 64; - effect.colorEnd[3].a = 0; - - effect.speed = 8.0f; - effect.gravity = -1.0f; - - effect.timer = 0; - effect.duration = 8; - - Effect_Add(globalCtx, &sp20, EFFECT_SPARK, 0, 1, &effect); -} - -s32 EnSkj_CollisionCheck(EnSkj* this, GlobalContext* globalCtx) { - s16 yawDiff; - Vec3f effectPos; - - if (!((this->unk_2D3 == 0) || (D_80B01EA0 != 0) || !(this->collider.base.acFlags & AC_HIT))) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageEffect != 0) { - if (this->actor.colChkInfo.damageEffect == 0xF) { - effectPos.x = this->collider.info.bumper.hitPos.x; - effectPos.y = this->collider.info.bumper.hitPos.y; - effectPos.z = this->collider.info.bumper.hitPos.z; - - EnSkj_SpawnBlood(globalCtx, &effectPos); - EffectSsHitMark_SpawnFixedScale(globalCtx, 1, &effectPos); - - yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - if ((this->action == 2) || (this->action == 6)) { - if ((yawDiff > 0x6000) || (yawDiff < -0x6000)) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - EnSkj_SetupDie(this); - return 1; - } - } - - Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - - if (this->actor.colChkInfo.health != 0) { - if (this->hitsUntilDodge != 0) { - this->hitsUntilDodge--; - } - if (this->dodgeResetTimer == 0) { - this->dodgeResetTimer = 60; - } - func_80AFF1F0(this); - return 1; - } - EnSkj_SetupDie(this); - return 1; - } - } else { - this->backfilpFlag = 1; - EnSkj_Backflip(this); - return 1; - } - } - return 0; -} - -s32 func_80AFEDF8(EnSkj* this, GlobalContext* globalCtx) { - s16 yawDiff; - - if (this->actor.xzDistToPlayer < this->unk_2EC) { - this = this; - if (func_8002DDE4(globalCtx) != 0) { - return 1; - } - } - - yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - - if ((yawDiff < this->unk_2C8) && (-this->unk_2C8 < yawDiff)) { - return 1; - } - - return 0; -} - -void EnSkj_Backflip(EnSkj* this) { - this->actor.velocity.y = 8.0f; - this->actor.speedXZ = -8.0f; - - EnSkj_ChangeAnim(this, SKJ_ANIM_BACKFLIP); - EnSkj_SetupAction(this, SKJ_ACTION_FADE); -} - -void EnSkj_Fade(EnSkj* this, GlobalContext* globalCtx) { - u32 alpha = this->alpha; - - if (this->unk_2D6 == 2) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; - this->unk_2D6 = 0; - } - - alpha -= 20; - - if (this->backfilpFlag != 0) { - if (alpha > 255) { - alpha = 0; - } - - this->alpha = alpha; - this->actor.shape.shadowAlpha = alpha; - } - - if (this->actor.velocity.y <= 0.0f) { - if (this->actor.bgCheckFlags & 2) { - this->actor.bgCheckFlags &= ~2; - func_80AFF2A0(this); - } - } -} - -void EnSkj_SetupWaitToShootNeedle(EnSkj* this) { - this->needlesToShoot = 3; - this->needleShootTimer = 0; - EnSkj_ChangeAnim(this, SKJ_ANIM_SHOOT_NEEDLE); - EnSkj_SetupAction(this, SKJ_ACTION_WAIT_TO_SHOOT_NEEDLE); -} - -void EnSkj_WaitToShootNeedle(EnSkj* this, GlobalContext* globalCtx) { - u8 val; - s16 lastFrame = Animation_GetLastFrame(&gSkullKidShootNeedleAnim); - - if ((this->skelAnime.curFrame == lastFrame) && (this->needleShootTimer == 0)) { - val = this->needlesToShoot; - if (this->needlesToShoot != 0) { - EnSkj_ShootNeedle(this, globalCtx); - this->needleShootTimer = 4; - val--; - this->needlesToShoot = val; - - } else { - EnSkj_SetupNeedleRecover(this); - } - } -} - -void EnSkj_SetupResetFight(EnSkj* this) { - this->unk_2C8 = 0xAAA; - this->unk_2EC = 200.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_PLAY_FLUTE); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_IDLE); -} - -void EnSkj_SariasSongKidIdle(EnSkj* this, GlobalContext* globalCtx) { - if (this->actor.params == 0) { - if (!(gSaveContext.itemGetInf[1] & 0x40) && (this->actor.xzDistToPlayer < 200.0f)) { - this->backfilpFlag = 1; - EnSkj_Backflip(this); - } else if (sSmallStumpSkullKid.unk0 != 0) { - Player* player = GET_PLAYER(globalCtx); - if (EnSkj_RangeCheck(player, sSmallStumpSkullKid.skullkid)) { - EnSkj_SetupWaitInRange(this); - player->stateFlags2 |= 0x800000; - player->unk_6A8 = &sSmallStumpSkullKid.skullkid->actor; - } - } - } else { - if (func_80AFEDF8(this, globalCtx) != 0) { - func_80AFF334(this); - } - } -} - -void EnSkj_SetupDie(EnSkj* this) { - EnSkj_ChangeAnim(this, SKJ_ANIM_DIE); - EnSkj_SetupAction(this, SKJ_ACTION_WAIT_FOR_DEATH_ANIM); -} - -void EnSkj_WaitForDeathAnim(EnSkj* this, GlobalContext* globalCtx) { - s16 lastFrame = Animation_GetLastFrame(&gSkullKidDieAnim); - - if (this->skelAnime.curFrame == lastFrame) { - EnSkj_SetupSpawnDeathEffect(this); - } -} - -void func_80AFF1F0(EnSkj* this) { - EnSkj_ChangeAnim(this, SKJ_ANIM_HIT); - EnSkj_SetupAction(this, SKJ_ACTION_PICK_NEXT_FIHGT_ACTION); -} - -void EnSkj_PickNextFightAction(EnSkj* this, GlobalContext* globalCtx) { - s16 lastFrame = Animation_GetLastFrame(&gSkullKidHitAnim); - - if (this->skelAnime.curFrame == lastFrame) { - if (this->hitsUntilDodge == 0) { - this->hitsUntilDodge = 3; - EnSkj_Backflip(this); - } else { - EnSkj_SetupStand(this); - } - } -} - -void func_80AFF2A0(EnSkj* this) { - EnSkj_CalculateCenter(this); - this->actor.speedXZ = 0.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_LAND); - EnSkj_SetupAction(this, SKJ_ACTION_WAIT_FOR_LAND_ANIM); -} - -void EnSkj_WaitForLandAnim(EnSkj* this, GlobalContext* globalCtx) { - s16 lastFrame = Animation_GetLastFrame(&gSkullKidLandAnim); - - if (this->skelAnime.curFrame == lastFrame) { - EnSkj_SetupStand(this); - } -} - -void func_80AFF334(EnSkj* this) { - this->unk_2C8 = 0x2000; - this->battleExitTimer = 400; - this->unk_2EC = 600.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_LOOK_LEFT_RIGHT); - EnSkj_SetupAction(this, SKJ_ACTION_RESET_FIGHT); -} - -void EnSkj_ResetFight(EnSkj* this, GlobalContext* globalCtx) { - if (this->battleExitTimer == 0) { - EnSkj_SetupResetFight(this); - } else if (func_80AFEDF8(this, globalCtx) != 0) { - this->battleExitTimer = 600; - EnSkj_SetupStand(this); - } -} - -void EnSkj_SetupStand(EnSkj* this) { - this->needleShootTimer = 60; - this->unk_2C8 = 0x2000; - this->unk_2F0 = 0.0f; - this->unk_2EC = 600.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_FIGHTING_STANCE); - EnSkj_SetupAction(this, SKJ_ACTION_FIGHT); -} - -void EnSkj_Fight(EnSkj* this, GlobalContext* globalCtx) { - Vec3f pos1; - Vec3f pos2; - s32 pad[3]; - f32 prevPosX; - f32 prevPosZ; - f32 phi_f14; - s16 yawDistToPlayer; - - if (this->needleShootTimer == 0) { - EnSkj_SetupWaitToShootNeedle(this); - } else if (this->battleExitTimer != 0) { - yawDistToPlayer = - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->unk_2F0, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - Math_ApproachF(&this->unk_2F0, 2000.0f, 1.0f, 200.0f); - - pos1.x = 0.0f; - pos1.y = 0.0f; - pos1.z = -120.0f; - - Matrix_RotateY((this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&pos1, &pos2); - prevPosX = this->actor.world.pos.x; - prevPosZ = this->actor.world.pos.z; - if (1) {} - this->actor.world.pos.x = this->center.x + pos2.x; - this->actor.world.pos.z = this->center.z + pos2.z; - - phi_f14 = sqrtf(SQ(this->actor.world.pos.x - prevPosX) + SQ(this->actor.world.pos.z - prevPosZ)); - phi_f14 = CLAMP_MAX(phi_f14, 10.0f); - phi_f14 /= 10.0f; - - this->skelAnime.playSpeed = (yawDistToPlayer < 0) ? -(1.0f + phi_f14) : (1.0f + phi_f14); - - } else if (func_80AFEDF8(this, globalCtx) != 0) { - this->backfilpFlag = 1; - EnSkj_Backflip(this); - } else { - EnSkj_SetupResetFight(this); - } -} - -void EnSkj_SetupNeedleRecover(EnSkj* this) { - Animation_Reverse(&this->skelAnime); - EnSkj_SetupAction(this, SKJ_ACTION_NEEDLE_RECOVER); -} - -void EnSkj_NeedleRecover(EnSkj* this, GlobalContext* globalCtx) { - if (this->skelAnime.curFrame == 0.0f) { - EnSkj_SetupStand(this); - } -} - -void EnSkj_SetupSpawnDeathEffect(EnSkj* this) { - this->backfilpFlag = 1; - EnSkj_SetupAction(this, SKJ_ACTION_SPAWN_DEATH_EFFECT); -} - -void EnSkj_SpawnDeathEffect(EnSkj* this, GlobalContext* globalCtx) { - Vec3f effectPos; - Vec3f effectVel; - Vec3f effectAccel; - u32 phi_v0; - - phi_v0 = this->alpha - 4; - - if (phi_v0 > 255) { - phi_v0 = 0; - } - this->alpha = phi_v0; - this->actor.shape.shadowAlpha = phi_v0; - - effectPos.x = Rand_CenteredFloat(30.0f) + this->actor.world.pos.x; - effectPos.y = Rand_CenteredFloat(30.0f) + this->actor.world.pos.y; - effectPos.z = Rand_CenteredFloat(30.0f) + this->actor.world.pos.z; - - effectAccel.z = 0.0f; - effectAccel.y = 0.0f; - effectAccel.x = 0.0f; - - effectVel.z = 0.0f; - effectVel.y = 0.0f; - effectVel.x = 0.0f; - - EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVel, &effectAccel, 100, 10, 255, 255, 255, 255, 0, 0, 255, 1, 9, - 1); -} - -void EnSkj_SetupWaitInRange(EnSkj* this) { - this->textId = 0x10BC; - - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_IN_RANGE); -} - -void EnSkj_WaitInRange(EnSkj* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - // When link pulls out the Ocarina center him on the stump - // Link was probably supposed to be pointed towards skull kid as well - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; - player->unk_6A8 = &sSmallStumpSkullKid.skullkid->actor; - player->actor.world.pos.x = sSmallStumpSkullKid.skullkid->actor.world.pos.x; - player->actor.world.pos.y = sSmallStumpSkullKid.skullkid->actor.world.pos.y; - player->actor.world.pos.z = sSmallStumpSkullKid.skullkid->actor.world.pos.z; - EnSkj_TurnPlayer(sSmallStumpSkullKid.skullkid, player); - func_8010BD88(globalCtx, OCARINA_ACTION_CHECK_SARIA); - EnSkj_SetupWaitForSong(this); - } else if (D_80B01EA0 != 0) { - player->actor.world.pos.x = sSmallStumpSkullKid.skullkid->actor.world.pos.x; - player->actor.world.pos.y = sSmallStumpSkullKid.skullkid->actor.world.pos.y; - player->actor.world.pos.z = sSmallStumpSkullKid.skullkid->actor.world.pos.z; - if ((Player_GetMask(globalCtx) == PLAYER_MASK_SKULL) && !(gSaveContext.itemGetInf[3] & 0x200)) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - EnSkj_SetupMaskTrade(this); - } else { - EnSkj_SetupTalk(this); - } - } else if (!EnSkj_RangeCheck(player, sSmallStumpSkullKid.skullkid)) { - EnSkj_SetupResetFight(this); - } else { - player->stateFlags2 |= 0x800000; - if (gSaveContext.itemGetInf[1] & 0x40) { - if (gSaveContext.itemGetInf[3] & 0x200) { - this->textId = Text_GetFaceReaction(globalCtx, 0x15); - if (this->textId == 0) { - this->textId = 0x1020; - } - } else if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { - this->textId = 0x10BC; - } else if (Player_GetMask(globalCtx) == PLAYER_MASK_SKULL) { - this->textId = 0x101B; - } else { - this->textId = Text_GetFaceReaction(globalCtx, 0x15); - } - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - } - } -} - -void EnSkj_SetupWaitForSong(EnSkj* this) { - this->unk_2D6 = 0; - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_FOR_SONG); -} - -void EnSkj_WaitForSong(EnSkj* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - // Played a song thats not Saria's song - if (!(gSaveContext.itemGetInf[1] & 0x40) && ((globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_FAIL) || - (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_FAIL_NO_TEXT))) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - Message_CloseTextbox(globalCtx); - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - EnSkj_SetupWrongSong(this); - } else { - if ((globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) && (this->unk_2D6 == 0)) { - this->unk_2D6 = 1; - EnSkj_ChangeAnim(this, SKJ_ANIM_PLAY_FLUTE); - } else if ((this->unk_2D6 != 0) && (globalCtx->msgCtx.msgMode == MSGMODE_SONG_DEMONSTRATION_DONE)) { - this->unk_2D6 = 0; - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - } - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; - this->unk_2D6 = 0; - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_IN_RANGE); - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { - if (!(gSaveContext.itemGetInf[1] & 0x40)) { - // Saria's song has been played for the first titme - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - func_80078884(NA_SE_SY_CORRECT_CHIME); - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - this->textId = 0x10BB; - EnSkj_SetupAfterSong(this); - } else { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_05; - } - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_02) { - player->stateFlags2 &= ~0x1000000; - Actor_Kill(&this->actor); - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; - } else { - if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05) { - gSaveContext.sunsSongState = 0; - if (gSaveContext.itemGetInf[1] & 0x40) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - this->textId = 0x10BD; - EnSkj_SetupAfterSong(this); - } else { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - EnSkj_SetupWrongSong(this); - } - } - } - } -} - -void EnSkj_SetupAfterSong(EnSkj* this) { - this->unk_2D6 = 0; - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_AFTER_SONG); -} - -void EnSkj_AfterSong(EnSkj* this, GlobalContext* globalCtx) { - if (D_80B01EA0 != 0) { - EnSkj_SetupTalk(this); - } else { - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - } -} - -void EnSkj_SetupTalk(EnSkj* this) { - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_TALK); -} - -void EnSkj_SariaSongTalk(EnSkj* this, GlobalContext* globalCtx) { - s32 pad; - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - if (gSaveContext.itemGetInf[1] & 0x40) { - EnSkj_SetupWaitInRange(this); - } else { - func_80AFFE24(this); - func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, EnSkj_GetItemXzRange(this), - EnSkj_GetItemYRange(this)); - } - } -} - -void func_80AFFE24(EnSkj* this) { - EnSkj_SetupAction(this, SKJ_ACTION_UNK14); -} - -void func_80AFFE44(EnSkj* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - EnSkj_SetupPostSariasSong(this); - } else { - func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, EnSkj_GetItemXzRange(this), EnSkj_GetItemYRange(this)); - } -} - -void EnSkj_SetupPostSariasSong(EnSkj* this) { - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_CHANGE_MODE); -} - -void EnSkj_ChangeModeAfterSong(EnSkj* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - gSaveContext.itemGetInf[1] |= 0x40; - EnSkj_SetNaviId(this); - EnSkj_SetupWaitInRange(this); - } -} - -void EnSkj_SetupMaskTrade(EnSkj* this) { - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_START_TRADE); -} - -void EnSkj_StartMaskTrade(EnSkj* this, GlobalContext* globalCtx) { - u8 sp1F = Message_GetState(&globalCtx->msgCtx); - - func_8002DF54(globalCtx, &this->actor, 1); - if ((sp1F == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - EnSkj_JumpFromStump(this); - } -} - -void EnSkj_JumpFromStump(EnSkj* this) { - this->actor.velocity.y = 8.0f; - this->actor.speedXZ = 2.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_BACKFLIP); - Animation_Reverse(&this->skelAnime); - this->skelAnime.curFrame = this->skelAnime.startFrame; - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING); -} - -void EnSkj_WaitForLanding(EnSkj* this, GlobalContext* globalCtx) { - if (this->actor.velocity.y <= 0.0f) { - if (this->actor.bgCheckFlags & 2) { - this->actor.bgCheckFlags &= ~2; - this->actor.speedXZ = 0.0f; - EnSkj_SetupWaitForLandAnimFinish(this); - } - } -} - -void EnSkj_SetupWaitForLandAnimFinish(EnSkj* this) { - EnSkj_ChangeAnim(this, SKJ_ANIM_LAND); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING_ANIM); -} - -void EnSkj_WaitForLandAnimFinish(EnSkj* this, GlobalContext* globalCtx) { - s16 lastFrame = Animation_GetLastFrame(&gSkullKidLandAnim); - - if (this->skelAnime.curFrame == lastFrame) { - EnSkj_SetupWalkToPlayer(this); - } -} - -void EnSkj_SetupWalkToPlayer(EnSkj* this) { - this->unk_2F0 = 0.0f; - this->actor.speedXZ = 2.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_WALK_TO_PLAYER); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WALK_TO_PLAYER); -} - -void EnSkj_WalkToPlayer(EnSkj* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, this->unk_2F0, 0); - Math_ApproachF(&this->unk_2F0, 2000.0f, 1.0f, 100.0f); - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->actor.xzDistToPlayer < 120.0f) { - this->actor.speedXZ = 0.0f; - EnSkj_SetupAskForMask(this, globalCtx); - } -} - -void EnSkj_SetupAskForMask(EnSkj* this, GlobalContext* globalCtx) { - Message_StartTextbox(globalCtx, 0x101C, &this->actor); - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_ASK_FOR_MASK); -} - -void EnSkj_AskForMask(EnSkj* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // Yes - EnSkj_SetupTakeMask(this, globalCtx); - break; - case 1: // No - Message_ContinueTextbox(globalCtx, 0x101D); - EnSkj_SetupWaitForMaskTextClear(this); - break; - } - } -} - -void EnSkj_SetupTakeMask(EnSkj* this, GlobalContext* globalCtx) { - Message_ContinueTextbox(globalCtx, 0x101E); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_TAKE_MASK); -} - -void EnSkj_TakeMask(EnSkj* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - Rupees_ChangeBy(10); - gSaveContext.itemGetInf[3] |= 0x200; - EnSkj_SetNaviId(this); - Player_UnsetMask(globalCtx); - Item_Give(globalCtx, ITEM_SOLD_OUT); - Message_ContinueTextbox(globalCtx, 0x101F); - EnSkj_SetupWaitForMaskTextClear(this); - } -} - -void EnSkj_SetupWaitForMaskTextClear(EnSkj* this) { - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_MASK_TEXT); -} - -void EnSkj_WaitForMaskTextClear(EnSkj* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - func_8002DF54(globalCtx, &this->actor, 7); - this->backfilpFlag = 1; - EnSkj_Backflip(this); - } -} - -void EnSkj_SetupWrongSong(EnSkj* this) { - this->textId = 0x1041; - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WRONG_SONG); -} - -void EnSkj_WrongSong(EnSkj* this, GlobalContext* globalCtx) { - if (D_80B01EA0 != 0) { - EnSkj_SetupWaitForTextClear(this); - } else { - func_8002F2CC(&this->actor, globalCtx, EnSkj_GetItemXzRange(this)); - } -} - -void EnSkj_SetupWaitForTextClear(EnSkj* this) { - EnSkj_SetupAction(this, SKJ_ACTION_SARIA_SONG_WAIT_FOR_TEXT); -} - -void EnSkj_SariasSongWaitForTextClear(EnSkj* this, GlobalContext* globalCtx) { - u8 state = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); - - if (state == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - EnSkj_SetupWaitInRange(this); - player->stateFlags2 |= 0x800000; - player->unk_6A8 = (Actor*)sSmallStumpSkullKid.skullkid; - } -} - -void EnSkj_OcarinaGameSetupWaitForPlayer(EnSkj* this) { - this->actor.flags &= ~ACTOR_FLAG_0; - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_OCARINA_GAME_WAIT_FOR_PLAYER); -} - -void EnSkj_OcarinaGameWaitForPlayer(EnSkj* this, GlobalContext* globalCtx) { - if (this->playerInRange) { - this->actor.flags |= ACTOR_FLAG_0; - EnSkj_SetupAction(this, SKJ_ACTION_OCARINA_GAME_IDLE); - } -} - -s32 EnSkj_IsLeavingGame(EnSkj* this) { - s32 paramDecr = this->actor.params - 1; - - if (sOcarinaMinigameSkullKids[paramDecr].unk0 == 2) { - EnSkj_SetupLeaveOcarinaGame(this); - return true; - } - return false; -} - -void EnSkj_SetupIdle(EnSkj* this) { - EnSkj_ChangeAnim(this, SKJ_ANIM_WAIT); - EnSkj_SetupAction(this, SKJ_ACTION_OCARINA_GAME_IDLE); -} - -void EnSkj_Appear(EnSkj* this) { - if (this->alpha != 255) { - this->alpha += 20; - - if (this->alpha > 255) { - this->alpha = 255; - } - } -} - -void EnSkj_OcarinaGameIdle(EnSkj* this, GlobalContext* globalCtx) { - EnSkj_Appear(this); - - if ((EnSkj_IsLeavingGame(this) == false) && (this->minigameState != 0)) { - EnSkj_SetupPlayOcarinaGame(this); - } -} - -void EnSkj_SetupPlayOcarinaGame(EnSkj* this) { - EnSkj_ChangeAnim(this, SKJ_ANIM_PLAY_FLUTE); - EnSkj_SetupAction(this, SKJ_ACTION_OCARINA_GAME_PLAY); -} - -void EnSkj_PlayOcarinaGame(EnSkj* this, GlobalContext* globalCtx) { - EnSkj_Appear(this); - - if (!EnSkj_IsLeavingGame(this) && (this->minigameState == 0)) { - EnSkj_SetupIdle(this); - } -} - -void EnSkj_SetupLeaveOcarinaGame(EnSkj* this) { - this->actor.velocity.y = 8.0f; - this->actor.speedXZ = -8.0f; - EnSkj_ChangeAnim(this, SKJ_ANIM_BACKFLIP); - EnSkj_SetupAction(this, SKJ_ACTION_OCARINA_GAME_LEAVE); -} - -void EnSkj_LeaveOcarinaGame(EnSkj* this, GlobalContext* globalCtx) { - s32 paramsDecr = this->actor.params - 1; - - sOcarinaMinigameSkullKids[paramsDecr].unk0 = 0; - sOcarinaMinigameSkullKids[paramsDecr].skullkid = NULL; - this->backfilpFlag = 1; - EnSkj_Backflip(this); -} - -void EnSkj_Update(Actor* thisx, GlobalContext* globalCtx) { - Vec3f dropPos; - s32 pad; - EnSkj* this = (EnSkj*)thisx; - - D_80B01EA0 = Actor_ProcessTalkRequest(&this->actor, globalCtx); - - this->timer++; - - if (this->multiuseTimer != 0) { - this->multiuseTimer--; - } - - if (this->needleShootTimer != 0) { - this->needleShootTimer--; - } - - if (this->dodgeResetTimer != 0) { - this->dodgeResetTimer--; - } - - if (this->dodgeResetTimer == 0) { - this->hitsUntilDodge = 3; - } - - if ((this->backfilpFlag != 0) && (this->alpha == 0)) { - if (this->action == 9) { - dropPos.x = this->actor.world.pos.x; - dropPos.y = this->actor.world.pos.y; - dropPos.z = this->actor.world.pos.z; - - Item_DropCollectible(globalCtx, &dropPos, ITEM00_RUPEE_ORANGE); - } - Actor_Kill(&this->actor); - return; - } - - Actor_SetFocus(&this->actor, 30.0f); - Actor_SetScale(&this->actor, 0.01f); - this->actionFunc(this, globalCtx); - this->actor.textId = this->textId; - EnSkj_CollisionCheck(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->collider); - - if ((this->unk_2D3 != 0) && (D_80B01EA0 == 0)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (this->actor.colorFilterTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 7); -} - -void EnSkj_SariasSongShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx) { - EnSkj* this = (EnSkj*)thisx; - - D_80B01EA0 = Actor_ProcessTalkRequest(&this->actor, globalCtx); -} - -void EnSkj_TurnPlayer(EnSkj* this, Player* player) { - Math_SmoothStepToS(&player->actor.shape.rot.y, this->actor.world.rot.y, 5, 2000, 0); - player->actor.world.rot.y = player->actor.shape.rot.y; - player->currentYaw = player->actor.shape.rot.y; -} - -void EnSkj_SetupWaitForOcarina(EnSkj* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (EnSkj_RangeCheck(player, this)) { - sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->playerInRange = true; - sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->playerInRange = true; - - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; - func_800F5BF0(4); - EnSkj_TurnPlayer(this, player); - player->unk_6A8 = &this->actor; - Message_StartTextbox(globalCtx, 0x10BE, &this->actor); - this->actionFunc = EnSkj_StartOcarinaMinigame; - } else { - this->actionFunc = EnSkj_WaitForOcarina; - } - } -} - -void EnSkj_WaitForOcarina(EnSkj* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; - func_800F5BF0(4); - EnSkj_TurnPlayer(this, player); - player->unk_6A8 = &this->actor; - Message_StartTextbox(globalCtx, 0x10BE, &this->actor); - this->actionFunc = EnSkj_StartOcarinaMinigame; - } else if (EnSkj_RangeCheck(player, this)) { - player->stateFlags2 |= 0x800000; - } -} - -void EnSkj_StartOcarinaMinigame(EnSkj* this, GlobalContext* globalCtx) { - u8 dialogState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); - - EnSkj_TurnPlayer(this, player); - - if (dialogState == TEXT_STATE_CLOSING) { - func_8010BD58(globalCtx, OCARINA_ACTION_MEMORY_GAME); - if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->minigameState = SKULL_KID_OCARINA_PLAY_NOTES; - } - this->songFailTimer = 160; - this->actionFunc = EnSkj_WaitForPlayback; - } -} - -void EnSkj_WaitForPlayback(EnSkj* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - EnSkj_TurnPlayer(this, player); - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { // failed the game - Message_CloseTextbox(globalCtx); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, 26.0f); - this->textId = 0x102D; - this->actionFunc = EnSkj_FailedMiniGame; - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0F) { // completed the game - func_80078884(NA_SE_SY_CORRECT_CHIME); - Message_CloseTextbox(globalCtx); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, 26.0f); - this->textId = 0x10BF; - this->actionFunc = EnSkj_WonOcarinaMiniGame; - } else { // playing the game - switch (globalCtx->msgCtx.msgMode) { - case MSGMODE_MEMORY_GAME_LEFT_SKULLKID_WAIT: - if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->minigameState = SKULL_KID_OCRAINA_WAIT; - } - if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { - if (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->minigameState = - SKULL_KID_OCARINA_PLAY_NOTES; - } - Message_UpdateOcarinaGame(globalCtx); - } - break; - case MSGMODE_MEMORY_GAME_RIGHT_SKULLKID_WAIT: - if (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->minigameState = SKULL_KID_OCRAINA_WAIT; - } - if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { - Message_UpdateOcarinaGame(globalCtx); - this->songFailTimer = 160; - } - break; - case MSGMODE_MEMORY_GAME_PLAYER_PLAYING: - if (this->songFailTimer != 0) { - this->songFailTimer--; - } else { // took too long, game failed - func_80078884(NA_SE_SY_OCARINA_ERROR); - Message_CloseTextbox(globalCtx); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - player->unk_6A8 = &this->actor; - func_8002F2CC(&this->actor, globalCtx, 26.0f); - this->textId = 0x102D; - this->actionFunc = EnSkj_FailedMiniGame; - } - break; - case MSGMODE_MEMORY_GAME_START_NEXT_ROUND: - if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { - if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->minigameState = - SKULL_KID_OCARINA_PLAY_NOTES; - } - this->songFailTimer = 160; - Audio_OcaSetInstrument(6); // related instrument sound (flute?) - Audio_OcaSetSongPlayback(OCARINA_SONG_MEMORY_GAME + 1, 1); - globalCtx->msgCtx.msgMode = MSGMODE_MEMORY_GAME_LEFT_SKULLKID_PLAYING; - globalCtx->msgCtx.stateTimer = 2; - } - break; - } - } -} - -void EnSkj_FailedMiniGame(EnSkj* this, GlobalContext* globalCtx) { - if (D_80B01EA0) { - this->actionFunc = EnSkj_WaitForNextRound; - } else { - func_8002F2CC(&this->actor, globalCtx, 26.0f); - } -} - -void EnSkj_WaitForNextRound(EnSkj* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - EnSkj_OfferNextRound(this, globalCtx); - } -} - -void EnSkj_OfferNextRound(EnSkj* this, GlobalContext* globalCtx) { - Message_ContinueTextbox(globalCtx, 0x102E); - this->actionFunc = EnSkj_WaitForOfferResponse; -} - -void EnSkj_WaitForOfferResponse(EnSkj* this, GlobalContext* globalCtx) { - Player* player; - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // yes - player = GET_PLAYER(globalCtx); - player->stateFlags3 |= 0x20; // makes player take ocarina out right away after closing box - this->actionFunc = EnSkj_SetupWaitForOcarina; - break; - case 1: // no - this->actionFunc = EnSkj_CleanupOcarinaGame; - break; - } - } -} - -void EnSkj_WonOcarinaMiniGame(EnSkj* this, GlobalContext* globalCtx) { - if (D_80B01EA0) { - this->actionFunc = EnSkj_WaitToGiveReward; - } else { - func_8002F2CC(&this->actor, globalCtx, 26.0f); - } -} - -void EnSkj_WaitToGiveReward(EnSkj* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - func_8002F434(&this->actor, globalCtx, sOcarinaGameRewards[gSaveContext.ocarinaGameRoundNum], 26.0f, 26.0f); - this->actionFunc = EnSkj_GiveOcarinaGameReward; - } -} - -void EnSkj_GiveOcarinaGameReward(EnSkj* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = EnSkj_FinishOcarinaGameRound; - } else { - func_8002F434(&this->actor, globalCtx, sOcarinaGameRewards[gSaveContext.ocarinaGameRoundNum], 26.0f, 26.0f); - } -} - -void EnSkj_FinishOcarinaGameRound(EnSkj* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - s32 ocarinaGameRoundNum = gSaveContext.ocarinaGameRoundNum; - - if (gSaveContext.ocarinaGameRoundNum < 3) { - gSaveContext.ocarinaGameRoundNum++; - } - - if (ocarinaGameRoundNum == 2) { - gSaveContext.itemGetInf[1] |= 0x80; - this->actionFunc = EnSkj_CleanupOcarinaGame; - } else { - EnSkj_OfferNextRound(this, globalCtx); - } - } -} - -void EnSkj_CleanupOcarinaGame(EnSkj* this, GlobalContext* globalCtx) { - if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_LEFT].unk0 = 2; - } - - if (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid != NULL) { - sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].unk0 = 2; - } - - if ((sOcarinaMinigameSkullKids[SKULL_KID_LEFT].unk0 == 2) && - (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].unk0 == 2)) { - func_800F5C2C(); - Actor_Kill(&this->actor); - } -} - -void EnSkj_OcarinaMinigameShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx) { - EnSkj* this = (EnSkj*)thisx; - - D_80B01EA0 = Actor_ProcessTalkRequest(&this->actor, globalCtx); - this->timer++; - - this->actor.focus.pos.x = 1230.0f; - this->actor.focus.pos.y = -90.0f; - this->actor.focus.pos.z = 450.0f; - - this->actionFunc(this, globalCtx); - - this->actor.textId = this->textId; - this->actor.xzDistToPlayer = 50.0; -} - -s32 EnSkj_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - return 0; -} - -void EnSkj_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2417); - - if ((limbIndex == 11) && (gSaveContext.itemGetInf[3] & 0x200)) { - func_80093D18(globalCtx->state.gfxCtx); - Matrix_Push(); - Matrix_RotateZYX(-0x4000, 0, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_skj.c", 2430), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gSKJskullMaskDL); - Matrix_Pop(); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2437); -} - -Gfx* EnSkj_TranslucentDL(GraphicsContext* gfxCtx, u32 alpha) { - Gfx* dList; - Gfx* dListHead; - - //! @bug This only allocates space for 1 command but uses 3 - dList = dListHead = Graph_Alloc(gfxCtx, sizeof(Gfx)); - gDPSetRenderMode(dListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); - gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); - gSPEndDisplayList(dListHead++); - - return dList; -} - -Gfx* EnSkj_OpaqueDL(GraphicsContext* gfxCtx, u32 alpha) { - Gfx* dList; - Gfx* dListHead; - - //! @bug This only allocates space for 1 command but uses 2 - dList = dListHead = Graph_Alloc(gfxCtx, sizeof(Gfx)); - gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); - gSPEndDisplayList(dListHead++); - - return dList; -} - -void EnSkj_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSkj* this = (EnSkj*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2475); - - func_80093D18(globalCtx->state.gfxCtx); - - if (this->alpha < 255) { - gSPSegment(POLY_OPA_DISP++, 0x0C, EnSkj_TranslucentDL(globalCtx->state.gfxCtx, this->alpha)); - } else { - gSPSegment(POLY_OPA_DISP++, 0x0C, EnSkj_OpaqueDL(globalCtx->state.gfxCtx, this->alpha)); - } - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSkj_OverrideLimbDraw, EnSkj_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2495); -} diff --git a/src/overlays/actors/ovl_En_Skj/z_en_skj.cpp b/src/overlays/actors/ovl_En_Skj/z_en_skj.cpp new file mode 100644 index 000000000..81ab4f591 --- /dev/null +++ b/src/overlays/actors/ovl_En_Skj/z_en_skj.cpp @@ -0,0 +1,1675 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SKJ_Z_EN_SKJ_C +#include "actor_common.h" +#include "z_en_skj.h" +#include "overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.h" +#include "objects/object_skj/object_skj.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_25) + +void EnSkj_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSkj_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSkj_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSkj_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSkj_SariasSongShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx); +void EnSkj_OcarinaMinigameShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx); + +void func_80AFF2A0(EnSkj* pthis); +void func_80AFF334(EnSkj* pthis); + +void EnSkj_CalculateCenter(EnSkj* pthis); +void EnSkj_OcarinaGameSetupWaitForPlayer(EnSkj* pthis); +void EnSkj_SetupResetFight(EnSkj* pthis); +void EnSkj_SetupLeaveOcarinaGame(EnSkj* pthis); +void EnSkj_SetupPlayOcarinaGame(EnSkj* pthis); +void EnSkj_Backflip(EnSkj* pthis); +void EnSkj_SetupNeedleRecover(EnSkj* pthis); +void EnSkj_SetupSpawnDeathEffect(EnSkj* pthis); +void EnSkj_SetupStand(EnSkj* pthis); +void EnSkj_SetupWaitForSong(EnSkj* pthis); +void EnSkj_SetupTalk(EnSkj* pthis); +void EnSkj_SetupMaskTrade(EnSkj* pthis); +void EnSkj_SetupWrongSong(EnSkj* pthis); +void EnSkj_SetupAfterSong(EnSkj* pthis); +void func_80AFFE24(EnSkj* pthis); +void EnSkj_SetupPostSariasSong(EnSkj* pthis); +void EnSkj_JumpFromStump(EnSkj* pthis); +void EnSkj_SetupWaitForLandAnimFinish(EnSkj* pthis); +void EnSkj_SetupWalkToPlayer(EnSkj* pthis); +void EnSkj_SetupWaitForMaskTextClear(EnSkj* pthis); +void EnSkj_SetupWaitForTextClear(EnSkj* pthis); +void EnSkj_SetupDie(EnSkj* pthis); +void func_80AFF1F0(EnSkj* pthis); +void EnSkj_OfferNextRound(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SetupAskForMask(EnSkj* pthis, GlobalContext* globalCtx); +f32 EnSkj_GetItemXzRange(EnSkj* pthis); +s32 EnSkj_CollisionCheck(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SetupTakeMask(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_TurnPlayer(EnSkj* pthis, Player* player); + +void EnSkj_SetupWaitForOcarina(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_StartOcarinaMinigame(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForOcarina(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForPlayback(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_FailedMiniGame(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WonOcarinaMiniGame(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitToGiveReward(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_GiveOcarinaGameReward(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_FinishOcarinaGameRound(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForNextRound(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForOfferResponse(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SetupWaitForOcarina(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_CleanupOcarinaGame(EnSkj* pthis, GlobalContext* globalCtx); + +void EnSkj_Fade(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitToShootNeedle(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SariasSongKidIdle(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForDeathAnim(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_PickNextFightAction(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForLandAnim(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_ResetFight(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_Fight(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_NeedleRecover(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SpawnDeathEffect(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitInRange(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForSong(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_AfterSong(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SariaSongTalk(EnSkj* pthis, GlobalContext* globalCtx); +void func_80AFFE44(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_ChangeModeAfterSong(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_StartMaskTrade(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForLanding(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForLandAnimFinish(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WalkToPlayer(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_AskForMask(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_TakeMask(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WaitForMaskTextClear(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_WrongSong(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_SariasSongWaitForTextClear(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_OcarinaGameWaitForPlayer(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_OcarinaGameIdle(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_PlayOcarinaGame(EnSkj* pthis, GlobalContext* globalCtx); +void EnSkj_LeaveOcarinaGame(EnSkj* pthis, GlobalContext* globalCtx); + +void EnSkj_SpawnBlood(GlobalContext* globalCtx, Vec3f* pos); + +void EnSkj_SetupWaitInRange(EnSkj* pthis); + +#define songFailTimer multiuseTimer +#define battleExitTimer multiuseTimer + +typedef enum { + /* 0 */ SKJ_ANIM_BACKFLIP, + /* 1 */ SKJ_ANIM_SHOOT_NEEDLE, + /* 2 */ SKJ_ANIM_PLAY_FLUTE, + /* 3 */ SKJ_ANIM_DIE, + /* 4 */ SKJ_ANIM_HIT, + /* 5 */ SKJ_ANIM_LAND, + /* 6 */ SKJ_ANIM_LOOK_LEFT_RIGHT, + /* 7 */ SKJ_ANIM_FIGHTING_STANCE, + /* 8 */ SKJ_ANIM_WALK_TO_PLAYER, + /* 9 */ SKJ_ANIM_WAIT +} SkullKidAnim; + +typedef enum { + /* 0 */ SKULL_KID_LEFT, + /* 1 */ SKULL_KID_RIGHT +} SkullKidStumpSide; + +typedef enum { + /* 0 */ SKULL_KID_OCRAINA_WAIT, + /* 1 */ SKULL_KID_OCARINA_PLAY_NOTES, + /* 2 */ SKULL_KID_OCARINA_LEAVE_GAME +} SkullKidOcarinaGameState; + +typedef enum { + /* 00 */ SKJ_ACTION_FADE, + /* 01 */ SKJ_ACTION_WAIT_TO_SHOOT_NEEDLE, + /* 02 */ SKJ_ACTION_SARIA_SONG_IDLE, + /* 03 */ SKJ_ACTION_WAIT_FOR_DEATH_ANIM, + /* 04 */ SKJ_ACTION_PICK_NEXT_FIHGT_ACTION, + /* 05 */ SKJ_ACTION_WAIT_FOR_LAND_ANIM, + /* 06 */ SKJ_ACTION_RESET_FIGHT, + /* 07 */ SKJ_ACTION_FIGHT, + /* 08 */ SKJ_ACTION_NEEDLE_RECOVER, + /* 09 */ SKJ_ACTION_SPAWN_DEATH_EFFECT, + /* 10 */ SKJ_ACTION_SARIA_SONG_WAIT_IN_RANGE, + /* 11 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_SONG, + /* 12 */ SKJ_ACTION_SARIA_SONG_AFTER_SONG, + /* 13 */ SKJ_ACTION_SARIA_TALK, + /* 14 */ SKJ_ACTION_UNK14, + /* 15 */ SKJ_ACTION_SARIA_SONG_CHANGE_MODE, + /* 16 */ SKJ_ACTION_SARIA_SONG_START_TRADE, + /* 17 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING, + /* 18 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING_ANIM, + /* 19 */ SKJ_ACTION_SARIA_SONG_WALK_TO_PLAYER, + /* 20 */ SKJ_ACTION_SARIA_SONG_ASK_FOR_MASK, + /* 21 */ SKJ_ACTION_SARIA_SONG_TAKE_MASK, + /* 22 */ SKJ_ACTION_SARIA_SONG_WAIT_MASK_TEXT, + /* 23 */ SKJ_ACTION_SARIA_SONG_WRONG_SONG, + /* 24 */ SKJ_ACTION_SARIA_SONG_WAIT_FOR_TEXT, + /* 25 */ SKJ_ACTION_OCARINA_GAME_WAIT_FOR_PLAYER, + /* 26 */ SKJ_ACTION_OCARINA_GAME_IDLE, + /* 27 */ SKJ_ACTION_OCARINA_GAME_PLAY, + /* 28 */ SKJ_ACTION_OCARINA_GAME_LEAVE +} SkullKidAction; + +typedef struct { + u8 unk0; + EnSkj* skullkid; +} unkSkjStruct; + +static unkSkjStruct sSmallStumpSkullKid = { 0, NULL }; +static unkSkjStruct sOcarinaMinigameSkullKids[] = { { 0, NULL }, { 0, NULL } }; + +ActorInit En_Skj_InitVars = { + ACTOR_EN_SKJ, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_SKJ, + sizeof(EnSkj), + (ActorFunc)EnSkj_Init, + (ActorFunc)EnSkj_Destroy, + (ActorFunc)EnSkj_Update, + (ActorFunc)EnSkj_Draw, +}; + +static ColliderCylinderInitType1 D_80B01678 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x0, 0x08 }, + { 0xFFCFFFFF, 0x0, 0x0 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 8, 48, 0, { 0, 0, 0 } }, +}; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0x0), + /* Slingshot */ DMG_ENTRY(0, 0x0), + /* Explosive */ DMG_ENTRY(0, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x0), + /* Normal arrow */ DMG_ENTRY(0, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(0, 0x0), + /* Ice arrow */ DMG_ENTRY(0, 0x0), + /* Light arrow */ DMG_ENTRY(0, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static s32 sOcarinaGameRewards[] = { + GI_RUPEE_GREEN, + GI_RUPEE_BLUE, + GI_HEART_PIECE, + GI_RUPEE_RED, +}; + +typedef struct { + AnimationHeader* animation; + u8 mode; + f32 morphFrames; +} SkullkidAnimationEntry; + +static SkullkidAnimationEntry sSkullKidAnimations[] = { + { &gSkullKidBackflipAnim, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidShootNeedleAnim, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayFluteAnim, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDieAnim, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHitAnim, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLandAnim, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookLeftAndRightAnim, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidFightingStanceAnim, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidWalkToPlayerAnim, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidWaitAnim, ANIMMODE_LOOP, 0.0f }, +}; + +static EnSkjActionFunc sActionFuncs[] = { + EnSkj_Fade, + EnSkj_WaitToShootNeedle, + EnSkj_SariasSongKidIdle, + EnSkj_WaitForDeathAnim, + EnSkj_PickNextFightAction, + EnSkj_WaitForLandAnim, + EnSkj_ResetFight, + EnSkj_Fight, + EnSkj_NeedleRecover, + EnSkj_SpawnDeathEffect, + EnSkj_WaitInRange, + EnSkj_WaitForSong, + EnSkj_AfterSong, + EnSkj_SariaSongTalk, + func_80AFFE44, + EnSkj_ChangeModeAfterSong, + EnSkj_StartMaskTrade, + EnSkj_WaitForLanding, + EnSkj_WaitForLandAnimFinish, + EnSkj_WalkToPlayer, + EnSkj_AskForMask, + EnSkj_TakeMask, + EnSkj_WaitForMaskTextClear, + EnSkj_WrongSong, + EnSkj_SariasSongWaitForTextClear, + EnSkj_OcarinaGameWaitForPlayer, + EnSkj_OcarinaGameIdle, + EnSkj_PlayOcarinaGame, + EnSkj_LeaveOcarinaGame, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), +}; + +static s32 D_80B01EA0; // gets set if ACTOR_FLAG_8 is set + +void EnSkj_ChangeAnim(EnSkj* pthis, u8 animIndex) { + f32 endFrame = Animation_GetLastFrame(sSkullKidAnimations[animIndex].animation); + + pthis->animIndex = animIndex; + Animation_Change(&pthis->skelAnime, sSkullKidAnimations[animIndex].animation, 1.0f, 0.0f, endFrame, + sSkullKidAnimations[animIndex].mode, sSkullKidAnimations[animIndex].morphFrames); +} + +void EnSkj_SetupAction(EnSkj* pthis, u8 action) { + pthis->action = action; + pthis->actionFunc = sActionFuncs[action]; + + switch (action) { + case SKJ_ACTION_FADE: + case SKJ_ACTION_WAIT_FOR_DEATH_ANIM: + case SKJ_ACTION_PICK_NEXT_FIHGT_ACTION: + case SKJ_ACTION_SPAWN_DEATH_EFFECT: + case SKJ_ACTION_SARIA_SONG_START_TRADE: + case SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING: + case SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING_ANIM: + case SKJ_ACTION_SARIA_SONG_WALK_TO_PLAYER: + case SKJ_ACTION_SARIA_SONG_ASK_FOR_MASK: + case SKJ_ACTION_SARIA_SONG_TAKE_MASK: + case SKJ_ACTION_SARIA_SONG_WAIT_MASK_TEXT: + case SKJ_ACTION_SARIA_SONG_WRONG_SONG: + case SKJ_ACTION_SARIA_SONG_WAIT_FOR_TEXT: + case SKJ_ACTION_OCARINA_GAME_WAIT_FOR_PLAYER: + case SKJ_ACTION_OCARINA_GAME_IDLE: + case SKJ_ACTION_OCARINA_GAME_PLAY: + case SKJ_ACTION_OCARINA_GAME_LEAVE: + pthis->unk_2D3 = 0; + break; + default: + pthis->unk_2D3 = 1; + break; + } +} + +void EnSkj_CalculateCenter(EnSkj* pthis) { + Vec3f mult; + + mult.x = 0.0f; + mult.y = 0.0f; + mult.z = 120.0f; + + Matrix_RotateY((pthis->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&mult, &pthis->center); + + pthis->center.x += pthis->actor.world.pos.x; + pthis->center.z += pthis->actor.world.pos.z; +} + +void EnSkj_SetNaviId(EnSkj* pthis) { + switch (pthis->actor.params) { + case 0: + if (gSaveContext.itemGetInf[3] & 0x200) { + pthis->actor.naviEnemyId = 0x41; // Skull kid with skull mask + } else if (gSaveContext.itemGetInf[1] & 0x40) { + pthis->actor.naviEnemyId = 0x40; // Skull kid after Saria's song but no mask + } else { + pthis->actor.naviEnemyId = 0x3F; // No Sarias song no skull mask + } + break; + + case 1: + case 2: + pthis->actor.naviEnemyId = 0x3F; + break; + + default: + pthis->actor.naviEnemyId = 0x36; // Skull kid as adult + break; + } +} + +void EnSkj_Init(Actor* thisx, GlobalContext* globalCtx2) { + s16 type = (thisx->params >> 0xA) & 0x3F; + EnSkj* pthis = (EnSkj*)thisx; + GlobalContext* globalCtx = globalCtx2; + s32 pad; + Player* player; + + Actor_ProcessInitChain(thisx, sInitChain); + switch (type) { + case 5: // Invisible on the small stump (sarias song)) + sSmallStumpSkullKid.unk0 = 1; + sSmallStumpSkullKid.skullkid = (EnSkj*)thisx; + pthis->actor.destroy = NULL; + pthis->actor.draw = NULL; + pthis->actor.update = EnSkj_SariasSongShortStumpUpdate; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actor.flags |= 0; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); + break; + + case 6: // Invisible on the short stump (ocarina game) + sSmallStumpSkullKid.unk0 = 1; + sSmallStumpSkullKid.skullkid = (EnSkj*)thisx; + pthis->actor.destroy = NULL; + pthis->actor.draw = NULL; + pthis->actor.update = EnSkj_OcarinaMinigameShortStumpUpdate; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actor.flags |= 0; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); + pthis->actor.focus.pos.x = 1230.0f; + pthis->actor.focus.pos.y = -90.0f; + pthis->actor.focus.pos.z = 450.0f; + pthis->actionFunc = EnSkj_SetupWaitForOcarina; + break; + + default: + pthis->actor.params = type; + if (((pthis->actor.params != 0) && (pthis->actor.params != 1)) && (pthis->actor.params != 2)) { + if (INV_CONTENT(ITEM_TRADE_ADULT) < ITEM_SAW) { + Actor_Kill(&pthis->actor); + return; + } + } + + EnSkj_SetNaviId(pthis); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSkullKidSkel, &gSkullKidPlayFluteAnim, pthis->jointTable, + pthis->morphTable, 19); + if ((type >= 0) && (type < 3)) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_NPC); + } + + if ((type < 0) || (type >= 7)) { + pthis->actor.flags &= ~ACTOR_FLAG_25; + } + + if ((type > 0) && (type < 3)) { + pthis->actor.targetMode = 7; + pthis->posCopy = pthis->actor.world.pos; + sOcarinaMinigameSkullKids[type - 1].unk0 = 1; + sOcarinaMinigameSkullKids[type - 1].skullkid = pthis; + pthis->minigameState = 0; + pthis->alpha = 0; + EnSkj_OcarinaGameSetupWaitForPlayer(pthis); + } else { + pthis->alpha = 255; + EnSkj_SetupResetFight(pthis); + } + + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.colChkInfo.health = 10; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &D_80B01678); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); + Actor_SetScale(thisx, 0.01f); + pthis->actor.textId = pthis->textId = 0; + pthis->multiuseTimer = 0; + pthis->backfilpFlag = 0; + pthis->needlesToShoot = 3; + pthis->hitsUntilDodge = 3; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -1.0f; + EnSkj_CalculateCenter(pthis); + + player = GET_PLAYER(globalCtx); + osSyncPrintf("Player_X : %f\n", player->actor.world.pos.x); + osSyncPrintf("Player_Z : %f\n", player->actor.world.pos.z); + osSyncPrintf("World_X : %f\n", pthis->actor.world.pos.x); + osSyncPrintf("World_Z : %f\n", pthis->actor.world.pos.z); + osSyncPrintf("Center_X : %f\n", pthis->center.x); + osSyncPrintf("Center_Z : %f\n\n", pthis->center.z); + + break; + } +} + +void EnSkj_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSkj* pthis = (EnSkj*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +s32 EnSkj_RangeCheck(Player* player, EnSkj* pthis) { + f32 xDiff = player->actor.world.pos.x - pthis->actor.world.pos.x; + f32 zDiff = player->actor.world.pos.z - pthis->actor.world.pos.z; + f32 yDiff = player->actor.world.pos.y - pthis->actor.world.pos.y; + + return (SQ(xDiff) + SQ(zDiff) <= 676.0f) && (yDiff >= 0.0f); +} + +f32 EnSkj_GetItemXzRange(EnSkj* pthis) { + EnSkj* temp_v0; + f32 zDiff; + f32 xDiff; + + temp_v0 = sSmallStumpSkullKid.skullkid; + xDiff = temp_v0->actor.world.pos.x - pthis->actor.world.pos.x; + zDiff = temp_v0->actor.world.pos.z - pthis->actor.world.pos.z; + return sqrtf(SQ(xDiff) + SQ(zDiff)) + 26.0f; +} + +f32 EnSkj_GetItemYRange(EnSkj* pthis) { + return fabsf(sSmallStumpSkullKid.skullkid->actor.world.pos.y - pthis->actor.world.pos.y) + 10.0f; +} + +s32 EnSkj_ShootNeedle(EnSkj* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + Vec3f pos2; + EnSkjneedle* needle; + + pos.x = 1.5f; + pos.y = 0.0f; + pos.z = 40.0f; + + Matrix_RotateY((pthis->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&pos, &pos2); + + pos2.x += pthis->actor.world.pos.x; + pos2.z += pthis->actor.world.pos.z; + pos2.y = pthis->actor.world.pos.y + 27.0f; + + needle = (EnSkjneedle*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SKJNEEDLE, pos2.x, pos2.y, pos2.z, + pthis->actor.shape.rot.x, pthis->actor.shape.rot.y, pthis->actor.shape.rot.z, 0); + if (needle != NULL) { + needle->killTimer = 100; + needle->actor.speedXZ = 24.0f; + return 1; + } + return 0; +} + +void EnSkj_SpawnBlood(GlobalContext* globalCtx, Vec3f* pos) { + EffectSparkInit effect; + s32 sp20; + + effect.position.x = pos->x; + effect.position.y = pos->y; + effect.position.z = pos->z; + effect.uDiv = 5; + effect.vDiv = 5; + + effect.colorStart[0].r = 0; + effect.colorStart[0].g = 0; + effect.colorStart[0].b = 128; + effect.colorStart[0].a = 255; + + effect.colorStart[1].r = 0; + effect.colorStart[1].g = 0; + effect.colorStart[1].b = 128; + effect.colorStart[1].a = 255; + + effect.colorStart[2].r = 0; + effect.colorStart[2].g = 0; + effect.colorStart[2].b = 128; + effect.colorStart[2].a = 255; + + effect.colorStart[3].r = 0; + effect.colorStart[3].g = 0; + effect.colorStart[3].b = 128; + effect.colorStart[3].a = 255; + + effect.colorEnd[0].r = 0; + effect.colorEnd[0].g = 0; + effect.colorEnd[0].b = 32; + effect.colorEnd[0].a = 0; + + effect.colorEnd[1].r = 0; + effect.colorEnd[1].g = 0; + effect.colorEnd[1].b = 32; + effect.colorEnd[1].a = 0; + + effect.colorEnd[2].r = 0; + effect.colorEnd[2].g = 0; + effect.colorEnd[2].b = 64; + effect.colorEnd[2].a = 0; + + effect.colorEnd[3].r = 0; + effect.colorEnd[3].g = 0; + effect.colorEnd[3].b = 64; + effect.colorEnd[3].a = 0; + + effect.speed = 8.0f; + effect.gravity = -1.0f; + + effect.timer = 0; + effect.duration = 8; + + Effect_Add(globalCtx, &sp20, EFFECT_SPARK, 0, 1, &effect); +} + +s32 EnSkj_CollisionCheck(EnSkj* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + Vec3f effectPos; + + if (!((pthis->unk_2D3 == 0) || (D_80B01EA0 != 0) || !(pthis->collider.base.acFlags & AC_HIT))) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (pthis->actor.colChkInfo.damageEffect != 0) { + if (pthis->actor.colChkInfo.damageEffect == 0xF) { + effectPos.x = pthis->collider.info.bumper.hitPos.x; + effectPos.y = pthis->collider.info.bumper.hitPos.y; + effectPos.z = pthis->collider.info.bumper.hitPos.z; + + EnSkj_SpawnBlood(globalCtx, &effectPos); + EffectSsHitMark_SpawnFixedScale(globalCtx, 1, &effectPos); + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y; + if ((pthis->action == 2) || (pthis->action == 6)) { + if ((yawDiff > 0x6000) || (yawDiff < -0x6000)) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + EnSkj_SetupDie(pthis); + return 1; + } + } + + Actor_ApplyDamage(&pthis->actor); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + + if (pthis->actor.colChkInfo.health != 0) { + if (pthis->hitsUntilDodge != 0) { + pthis->hitsUntilDodge--; + } + if (pthis->dodgeResetTimer == 0) { + pthis->dodgeResetTimer = 60; + } + func_80AFF1F0(pthis); + return 1; + } + EnSkj_SetupDie(pthis); + return 1; + } + } else { + pthis->backfilpFlag = 1; + EnSkj_Backflip(pthis); + return 1; + } + } + return 0; +} + +s32 func_80AFEDF8(EnSkj* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + + if (pthis->actor.xzDistToPlayer < pthis->unk_2EC) { + pthis = pthis; + if (func_8002DDE4(globalCtx) != 0) { + return 1; + } + } + + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y; + + if ((yawDiff < pthis->unk_2C8) && (-pthis->unk_2C8 < yawDiff)) { + return 1; + } + + return 0; +} + +void EnSkj_Backflip(EnSkj* pthis) { + pthis->actor.velocity.y = 8.0f; + pthis->actor.speedXZ = -8.0f; + + EnSkj_ChangeAnim(pthis, SKJ_ANIM_BACKFLIP); + EnSkj_SetupAction(pthis, SKJ_ACTION_FADE); +} + +void EnSkj_Fade(EnSkj* pthis, GlobalContext* globalCtx) { + u32 alpha = pthis->alpha; + + if (pthis->unk_2D6 == 2) { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; + pthis->unk_2D6 = 0; + } + + alpha -= 20; + + if (pthis->backfilpFlag != 0) { + if (alpha > 255) { + alpha = 0; + } + + pthis->alpha = alpha; + pthis->actor.shape.shadowAlpha = alpha; + } + + if (pthis->actor.velocity.y <= 0.0f) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.bgCheckFlags &= ~2; + func_80AFF2A0(pthis); + } + } +} + +void EnSkj_SetupWaitToShootNeedle(EnSkj* pthis) { + pthis->needlesToShoot = 3; + pthis->needleShootTimer = 0; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_SHOOT_NEEDLE); + EnSkj_SetupAction(pthis, SKJ_ACTION_WAIT_TO_SHOOT_NEEDLE); +} + +void EnSkj_WaitToShootNeedle(EnSkj* pthis, GlobalContext* globalCtx) { + u8 val; + s16 lastFrame = Animation_GetLastFrame(&gSkullKidShootNeedleAnim); + + if ((pthis->skelAnime.curFrame == lastFrame) && (pthis->needleShootTimer == 0)) { + val = pthis->needlesToShoot; + if (pthis->needlesToShoot != 0) { + EnSkj_ShootNeedle(pthis, globalCtx); + pthis->needleShootTimer = 4; + val--; + pthis->needlesToShoot = val; + + } else { + EnSkj_SetupNeedleRecover(pthis); + } + } +} + +void EnSkj_SetupResetFight(EnSkj* pthis) { + pthis->unk_2C8 = 0xAAA; + pthis->unk_2EC = 200.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_PLAY_FLUTE); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_IDLE); +} + +void EnSkj_SariasSongKidIdle(EnSkj* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == 0) { + if (!(gSaveContext.itemGetInf[1] & 0x40) && (pthis->actor.xzDistToPlayer < 200.0f)) { + pthis->backfilpFlag = 1; + EnSkj_Backflip(pthis); + } else if (sSmallStumpSkullKid.unk0 != 0) { + Player* player = GET_PLAYER(globalCtx); + if (EnSkj_RangeCheck(player, sSmallStumpSkullKid.skullkid)) { + EnSkj_SetupWaitInRange(pthis); + player->stateFlags2 |= 0x800000; + player->unk_6A8 = &sSmallStumpSkullKid.skullkid->actor; + } + } + } else { + if (func_80AFEDF8(pthis, globalCtx) != 0) { + func_80AFF334(pthis); + } + } +} + +void EnSkj_SetupDie(EnSkj* pthis) { + EnSkj_ChangeAnim(pthis, SKJ_ANIM_DIE); + EnSkj_SetupAction(pthis, SKJ_ACTION_WAIT_FOR_DEATH_ANIM); +} + +void EnSkj_WaitForDeathAnim(EnSkj* pthis, GlobalContext* globalCtx) { + s16 lastFrame = Animation_GetLastFrame(&gSkullKidDieAnim); + + if (pthis->skelAnime.curFrame == lastFrame) { + EnSkj_SetupSpawnDeathEffect(pthis); + } +} + +void func_80AFF1F0(EnSkj* pthis) { + EnSkj_ChangeAnim(pthis, SKJ_ANIM_HIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_PICK_NEXT_FIHGT_ACTION); +} + +void EnSkj_PickNextFightAction(EnSkj* pthis, GlobalContext* globalCtx) { + s16 lastFrame = Animation_GetLastFrame(&gSkullKidHitAnim); + + if (pthis->skelAnime.curFrame == lastFrame) { + if (pthis->hitsUntilDodge == 0) { + pthis->hitsUntilDodge = 3; + EnSkj_Backflip(pthis); + } else { + EnSkj_SetupStand(pthis); + } + } +} + +void func_80AFF2A0(EnSkj* pthis) { + EnSkj_CalculateCenter(pthis); + pthis->actor.speedXZ = 0.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_LAND); + EnSkj_SetupAction(pthis, SKJ_ACTION_WAIT_FOR_LAND_ANIM); +} + +void EnSkj_WaitForLandAnim(EnSkj* pthis, GlobalContext* globalCtx) { + s16 lastFrame = Animation_GetLastFrame(&gSkullKidLandAnim); + + if (pthis->skelAnime.curFrame == lastFrame) { + EnSkj_SetupStand(pthis); + } +} + +void func_80AFF334(EnSkj* pthis) { + pthis->unk_2C8 = 0x2000; + pthis->battleExitTimer = 400; + pthis->unk_2EC = 600.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_LOOK_LEFT_RIGHT); + EnSkj_SetupAction(pthis, SKJ_ACTION_RESET_FIGHT); +} + +void EnSkj_ResetFight(EnSkj* pthis, GlobalContext* globalCtx) { + if (pthis->battleExitTimer == 0) { + EnSkj_SetupResetFight(pthis); + } else if (func_80AFEDF8(pthis, globalCtx) != 0) { + pthis->battleExitTimer = 600; + EnSkj_SetupStand(pthis); + } +} + +void EnSkj_SetupStand(EnSkj* pthis) { + pthis->needleShootTimer = 60; + pthis->unk_2C8 = 0x2000; + pthis->unk_2F0 = 0.0f; + pthis->unk_2EC = 600.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_FIGHTING_STANCE); + EnSkj_SetupAction(pthis, SKJ_ACTION_FIGHT); +} + +void EnSkj_Fight(EnSkj* pthis, GlobalContext* globalCtx) { + Vec3f pos1; + Vec3f pos2; + s32 pad[3]; + f32 prevPosX; + f32 prevPosZ; + f32 phi_f14; + s16 yawDistToPlayer; + + if (pthis->needleShootTimer == 0) { + EnSkj_SetupWaitToShootNeedle(pthis); + } else if (pthis->battleExitTimer != 0) { + yawDistToPlayer = + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 5, pthis->unk_2F0, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + Math_ApproachF(&pthis->unk_2F0, 2000.0f, 1.0f, 200.0f); + + pos1.x = 0.0f; + pos1.y = 0.0f; + pos1.z = -120.0f; + + Matrix_RotateY((pthis->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&pos1, &pos2); + prevPosX = pthis->actor.world.pos.x; + prevPosZ = pthis->actor.world.pos.z; + if (1) {} + pthis->actor.world.pos.x = pthis->center.x + pos2.x; + pthis->actor.world.pos.z = pthis->center.z + pos2.z; + + phi_f14 = sqrtf(SQ(pthis->actor.world.pos.x - prevPosX) + SQ(pthis->actor.world.pos.z - prevPosZ)); + phi_f14 = CLAMP_MAX(phi_f14, 10.0f); + phi_f14 /= 10.0f; + + pthis->skelAnime.playSpeed = (yawDistToPlayer < 0) ? -(1.0f + phi_f14) : (1.0f + phi_f14); + + } else if (func_80AFEDF8(pthis, globalCtx) != 0) { + pthis->backfilpFlag = 1; + EnSkj_Backflip(pthis); + } else { + EnSkj_SetupResetFight(pthis); + } +} + +void EnSkj_SetupNeedleRecover(EnSkj* pthis) { + Animation_Reverse(&pthis->skelAnime); + EnSkj_SetupAction(pthis, SKJ_ACTION_NEEDLE_RECOVER); +} + +void EnSkj_NeedleRecover(EnSkj* pthis, GlobalContext* globalCtx) { + if (pthis->skelAnime.curFrame == 0.0f) { + EnSkj_SetupStand(pthis); + } +} + +void EnSkj_SetupSpawnDeathEffect(EnSkj* pthis) { + pthis->backfilpFlag = 1; + EnSkj_SetupAction(pthis, SKJ_ACTION_SPAWN_DEATH_EFFECT); +} + +void EnSkj_SpawnDeathEffect(EnSkj* pthis, GlobalContext* globalCtx) { + Vec3f effectPos; + Vec3f effectVel; + Vec3f effectAccel; + u32 phi_v0; + + phi_v0 = pthis->alpha - 4; + + if (phi_v0 > 255) { + phi_v0 = 0; + } + pthis->alpha = phi_v0; + pthis->actor.shape.shadowAlpha = phi_v0; + + effectPos.x = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.x; + effectPos.y = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.y; + effectPos.z = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.z; + + effectAccel.z = 0.0f; + effectAccel.y = 0.0f; + effectAccel.x = 0.0f; + + effectVel.z = 0.0f; + effectVel.y = 0.0f; + effectVel.x = 0.0f; + + EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVel, &effectAccel, 100, 10, 255, 255, 255, 255, 0, 0, 255, 1, 9, + 1); +} + +void EnSkj_SetupWaitInRange(EnSkj* pthis) { + pthis->textId = 0x10BC; + + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_IN_RANGE); +} + +void EnSkj_WaitInRange(EnSkj* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + // When link pulls out the Ocarina center him on the stump + // Link was probably supposed to be pointed towards skull kid as well + if (player->stateFlags2 & 0x1000000) { + player->stateFlags2 |= 0x2000000; + player->unk_6A8 = &sSmallStumpSkullKid.skullkid->actor; + player->actor.world.pos.x = sSmallStumpSkullKid.skullkid->actor.world.pos.x; + player->actor.world.pos.y = sSmallStumpSkullKid.skullkid->actor.world.pos.y; + player->actor.world.pos.z = sSmallStumpSkullKid.skullkid->actor.world.pos.z; + EnSkj_TurnPlayer(sSmallStumpSkullKid.skullkid, player); + func_8010BD88(globalCtx, OCARINA_ACTION_CHECK_SARIA); + EnSkj_SetupWaitForSong(pthis); + } else if (D_80B01EA0 != 0) { + player->actor.world.pos.x = sSmallStumpSkullKid.skullkid->actor.world.pos.x; + player->actor.world.pos.y = sSmallStumpSkullKid.skullkid->actor.world.pos.y; + player->actor.world.pos.z = sSmallStumpSkullKid.skullkid->actor.world.pos.z; + if ((Player_GetMask(globalCtx) == PLAYER_MASK_SKULL) && !(gSaveContext.itemGetInf[3] & 0x200)) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + EnSkj_SetupMaskTrade(pthis); + } else { + EnSkj_SetupTalk(pthis); + } + } else if (!EnSkj_RangeCheck(player, sSmallStumpSkullKid.skullkid)) { + EnSkj_SetupResetFight(pthis); + } else { + player->stateFlags2 |= 0x800000; + if (gSaveContext.itemGetInf[1] & 0x40) { + if (gSaveContext.itemGetInf[3] & 0x200) { + pthis->textId = Text_GetFaceReaction(globalCtx, 0x15); + if (pthis->textId == 0) { + pthis->textId = 0x1020; + } + } else if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { + pthis->textId = 0x10BC; + } else if (Player_GetMask(globalCtx) == PLAYER_MASK_SKULL) { + pthis->textId = 0x101B; + } else { + pthis->textId = Text_GetFaceReaction(globalCtx, 0x15); + } + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + } + } +} + +void EnSkj_SetupWaitForSong(EnSkj* pthis) { + pthis->unk_2D6 = 0; + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_FOR_SONG); +} + +void EnSkj_WaitForSong(EnSkj* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + // Played a song thats not Saria's song + if (!(gSaveContext.itemGetInf[1] & 0x40) && ((globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_FAIL) || + (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_FAIL_NO_TEXT))) { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_CloseTextbox(globalCtx); + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + EnSkj_SetupWrongSong(pthis); + } else { + if ((globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) && (pthis->unk_2D6 == 0)) { + pthis->unk_2D6 = 1; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_PLAY_FLUTE); + } else if ((pthis->unk_2D6 != 0) && (globalCtx->msgCtx.msgMode == MSGMODE_SONG_DEMONSTRATION_DONE)) { + pthis->unk_2D6 = 0; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + } + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; + pthis->unk_2D6 = 0; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_IN_RANGE); + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { + if (!(gSaveContext.itemGetInf[1] & 0x40)) { + // Saria's song has been played for the first titme + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + func_80078884(NA_SE_SY_CORRECT_CHIME); + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + pthis->textId = 0x10BB; + EnSkj_SetupAfterSong(pthis); + } else { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_05; + } + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_02) { + player->stateFlags2 &= ~0x1000000; + Actor_Kill(&pthis->actor); + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { + player->stateFlags2 |= 0x800000; + } else { + if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_05) { + gSaveContext.sunsSongState = 0; + if (gSaveContext.itemGetInf[1] & 0x40) { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + pthis->textId = 0x10BD; + EnSkj_SetupAfterSong(pthis); + } else { + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + EnSkj_SetupWrongSong(pthis); + } + } + } + } +} + +void EnSkj_SetupAfterSong(EnSkj* pthis) { + pthis->unk_2D6 = 0; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_AFTER_SONG); +} + +void EnSkj_AfterSong(EnSkj* pthis, GlobalContext* globalCtx) { + if (D_80B01EA0 != 0) { + EnSkj_SetupTalk(pthis); + } else { + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + } +} + +void EnSkj_SetupTalk(EnSkj* pthis) { + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_TALK); +} + +void EnSkj_SariaSongTalk(EnSkj* pthis, GlobalContext* globalCtx) { + s32 pad; + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + if (gSaveContext.itemGetInf[1] & 0x40) { + EnSkj_SetupWaitInRange(pthis); + } else { + func_80AFFE24(pthis); + func_8002F434(&pthis->actor, globalCtx, GI_HEART_PIECE, EnSkj_GetItemXzRange(pthis), + EnSkj_GetItemYRange(pthis)); + } + } +} + +void func_80AFFE24(EnSkj* pthis) { + EnSkj_SetupAction(pthis, SKJ_ACTION_UNK14); +} + +void func_80AFFE44(EnSkj* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + EnSkj_SetupPostSariasSong(pthis); + } else { + func_8002F434(&pthis->actor, globalCtx, GI_HEART_PIECE, EnSkj_GetItemXzRange(pthis), EnSkj_GetItemYRange(pthis)); + } +} + +void EnSkj_SetupPostSariasSong(EnSkj* pthis) { + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_CHANGE_MODE); +} + +void EnSkj_ChangeModeAfterSong(EnSkj* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + gSaveContext.itemGetInf[1] |= 0x40; + EnSkj_SetNaviId(pthis); + EnSkj_SetupWaitInRange(pthis); + } +} + +void EnSkj_SetupMaskTrade(EnSkj* pthis) { + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_START_TRADE); +} + +void EnSkj_StartMaskTrade(EnSkj* pthis, GlobalContext* globalCtx) { + u8 sp1F = Message_GetState(&globalCtx->msgCtx); + + func_8002DF54(globalCtx, &pthis->actor, 1); + if ((sp1F == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + EnSkj_JumpFromStump(pthis); + } +} + +void EnSkj_JumpFromStump(EnSkj* pthis) { + pthis->actor.velocity.y = 8.0f; + pthis->actor.speedXZ = 2.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_BACKFLIP); + Animation_Reverse(&pthis->skelAnime); + pthis->skelAnime.curFrame = pthis->skelAnime.startFrame; + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING); +} + +void EnSkj_WaitForLanding(EnSkj* pthis, GlobalContext* globalCtx) { + if (pthis->actor.velocity.y <= 0.0f) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.bgCheckFlags &= ~2; + pthis->actor.speedXZ = 0.0f; + EnSkj_SetupWaitForLandAnimFinish(pthis); + } + } +} + +void EnSkj_SetupWaitForLandAnimFinish(EnSkj* pthis) { + EnSkj_ChangeAnim(pthis, SKJ_ANIM_LAND); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_FOR_LANDING_ANIM); +} + +void EnSkj_WaitForLandAnimFinish(EnSkj* pthis, GlobalContext* globalCtx) { + s16 lastFrame = Animation_GetLastFrame(&gSkullKidLandAnim); + + if (pthis->skelAnime.curFrame == lastFrame) { + EnSkj_SetupWalkToPlayer(pthis); + } +} + +void EnSkj_SetupWalkToPlayer(EnSkj* pthis) { + pthis->unk_2F0 = 0.0f; + pthis->actor.speedXZ = 2.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WALK_TO_PLAYER); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WALK_TO_PLAYER); +} + +void EnSkj_WalkToPlayer(EnSkj* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xA, pthis->unk_2F0, 0); + Math_ApproachF(&pthis->unk_2F0, 2000.0f, 1.0f, 100.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->actor.xzDistToPlayer < 120.0f) { + pthis->actor.speedXZ = 0.0f; + EnSkj_SetupAskForMask(pthis, globalCtx); + } +} + +void EnSkj_SetupAskForMask(EnSkj* pthis, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0x101C, &pthis->actor); + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_ASK_FOR_MASK); +} + +void EnSkj_AskForMask(EnSkj* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // Yes + EnSkj_SetupTakeMask(pthis, globalCtx); + break; + case 1: // No + Message_ContinueTextbox(globalCtx, 0x101D); + EnSkj_SetupWaitForMaskTextClear(pthis); + break; + } + } +} + +void EnSkj_SetupTakeMask(EnSkj* pthis, GlobalContext* globalCtx) { + Message_ContinueTextbox(globalCtx, 0x101E); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_TAKE_MASK); +} + +void EnSkj_TakeMask(EnSkj* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + Rupees_ChangeBy(10); + gSaveContext.itemGetInf[3] |= 0x200; + EnSkj_SetNaviId(pthis); + Player_UnsetMask(globalCtx); + Item_Give(globalCtx, ITEM_SOLD_OUT); + Message_ContinueTextbox(globalCtx, 0x101F); + EnSkj_SetupWaitForMaskTextClear(pthis); + } +} + +void EnSkj_SetupWaitForMaskTextClear(EnSkj* pthis) { + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_MASK_TEXT); +} + +void EnSkj_WaitForMaskTextClear(EnSkj* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->backfilpFlag = 1; + EnSkj_Backflip(pthis); + } +} + +void EnSkj_SetupWrongSong(EnSkj* pthis) { + pthis->textId = 0x1041; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WRONG_SONG); +} + +void EnSkj_WrongSong(EnSkj* pthis, GlobalContext* globalCtx) { + if (D_80B01EA0 != 0) { + EnSkj_SetupWaitForTextClear(pthis); + } else { + func_8002F2CC(&pthis->actor, globalCtx, EnSkj_GetItemXzRange(pthis)); + } +} + +void EnSkj_SetupWaitForTextClear(EnSkj* pthis) { + EnSkj_SetupAction(pthis, SKJ_ACTION_SARIA_SONG_WAIT_FOR_TEXT); +} + +void EnSkj_SariasSongWaitForTextClear(EnSkj* pthis, GlobalContext* globalCtx) { + u8 state = Message_GetState(&globalCtx->msgCtx); + Player* player = GET_PLAYER(globalCtx); + + if (state == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + EnSkj_SetupWaitInRange(pthis); + player->stateFlags2 |= 0x800000; + player->unk_6A8 = (Actor*)sSmallStumpSkullKid.skullkid; + } +} + +void EnSkj_OcarinaGameSetupWaitForPlayer(EnSkj* pthis) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_OCARINA_GAME_WAIT_FOR_PLAYER); +} + +void EnSkj_OcarinaGameWaitForPlayer(EnSkj* pthis, GlobalContext* globalCtx) { + if (pthis->playerInRange) { + pthis->actor.flags |= ACTOR_FLAG_0; + EnSkj_SetupAction(pthis, SKJ_ACTION_OCARINA_GAME_IDLE); + } +} + +s32 EnSkj_IsLeavingGame(EnSkj* pthis) { + s32 paramDecr = pthis->actor.params - 1; + + if (sOcarinaMinigameSkullKids[paramDecr].unk0 == 2) { + EnSkj_SetupLeaveOcarinaGame(pthis); + return true; + } + return false; +} + +void EnSkj_SetupIdle(EnSkj* pthis) { + EnSkj_ChangeAnim(pthis, SKJ_ANIM_WAIT); + EnSkj_SetupAction(pthis, SKJ_ACTION_OCARINA_GAME_IDLE); +} + +void EnSkj_Appear(EnSkj* pthis) { + if (pthis->alpha != 255) { + pthis->alpha += 20; + + if (pthis->alpha > 255) { + pthis->alpha = 255; + } + } +} + +void EnSkj_OcarinaGameIdle(EnSkj* pthis, GlobalContext* globalCtx) { + EnSkj_Appear(pthis); + + if ((EnSkj_IsLeavingGame(pthis) == false) && (pthis->minigameState != 0)) { + EnSkj_SetupPlayOcarinaGame(pthis); + } +} + +void EnSkj_SetupPlayOcarinaGame(EnSkj* pthis) { + EnSkj_ChangeAnim(pthis, SKJ_ANIM_PLAY_FLUTE); + EnSkj_SetupAction(pthis, SKJ_ACTION_OCARINA_GAME_PLAY); +} + +void EnSkj_PlayOcarinaGame(EnSkj* pthis, GlobalContext* globalCtx) { + EnSkj_Appear(pthis); + + if (!EnSkj_IsLeavingGame(pthis) && (pthis->minigameState == 0)) { + EnSkj_SetupIdle(pthis); + } +} + +void EnSkj_SetupLeaveOcarinaGame(EnSkj* pthis) { + pthis->actor.velocity.y = 8.0f; + pthis->actor.speedXZ = -8.0f; + EnSkj_ChangeAnim(pthis, SKJ_ANIM_BACKFLIP); + EnSkj_SetupAction(pthis, SKJ_ACTION_OCARINA_GAME_LEAVE); +} + +void EnSkj_LeaveOcarinaGame(EnSkj* pthis, GlobalContext* globalCtx) { + s32 paramsDecr = pthis->actor.params - 1; + + sOcarinaMinigameSkullKids[paramsDecr].unk0 = 0; + sOcarinaMinigameSkullKids[paramsDecr].skullkid = NULL; + pthis->backfilpFlag = 1; + EnSkj_Backflip(pthis); +} + +void EnSkj_Update(Actor* thisx, GlobalContext* globalCtx) { + Vec3f dropPos; + s32 pad; + EnSkj* pthis = (EnSkj*)thisx; + + D_80B01EA0 = Actor_ProcessTalkRequest(&pthis->actor, globalCtx); + + pthis->timer++; + + if (pthis->multiuseTimer != 0) { + pthis->multiuseTimer--; + } + + if (pthis->needleShootTimer != 0) { + pthis->needleShootTimer--; + } + + if (pthis->dodgeResetTimer != 0) { + pthis->dodgeResetTimer--; + } + + if (pthis->dodgeResetTimer == 0) { + pthis->hitsUntilDodge = 3; + } + + if ((pthis->backfilpFlag != 0) && (pthis->alpha == 0)) { + if (pthis->action == 9) { + dropPos.x = pthis->actor.world.pos.x; + dropPos.y = pthis->actor.world.pos.y; + dropPos.z = pthis->actor.world.pos.z; + + Item_DropCollectible(globalCtx, &dropPos, ITEM00_RUPEE_ORANGE); + } + Actor_Kill(&pthis->actor); + return; + } + + Actor_SetFocus(&pthis->actor, 30.0f); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actionFunc(pthis, globalCtx); + pthis->actor.textId = pthis->textId; + EnSkj_CollisionCheck(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if ((pthis->unk_2D3 != 0) && (D_80B01EA0 == 0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if (pthis->actor.colorFilterTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 20.0f, 7); +} + +void EnSkj_SariasSongShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx) { + EnSkj* pthis = (EnSkj*)thisx; + + D_80B01EA0 = Actor_ProcessTalkRequest(&pthis->actor, globalCtx); +} + +void EnSkj_TurnPlayer(EnSkj* pthis, Player* player) { + Math_SmoothStepToS(&player->actor.shape.rot.y, pthis->actor.world.rot.y, 5, 2000, 0); + player->actor.world.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; +} + +void EnSkj_SetupWaitForOcarina(EnSkj* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (EnSkj_RangeCheck(player, pthis)) { + sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->playerInRange = true; + sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->playerInRange = true; + + if (player->stateFlags2 & 0x1000000) { + player->stateFlags2 |= 0x2000000; + func_800F5BF0(4); + EnSkj_TurnPlayer(pthis, player); + player->unk_6A8 = &pthis->actor; + Message_StartTextbox(globalCtx, 0x10BE, &pthis->actor); + pthis->actionFunc = EnSkj_StartOcarinaMinigame; + } else { + pthis->actionFunc = EnSkj_WaitForOcarina; + } + } +} + +void EnSkj_WaitForOcarina(EnSkj* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->stateFlags2 & 0x1000000) { + player->stateFlags2 |= 0x2000000; + func_800F5BF0(4); + EnSkj_TurnPlayer(pthis, player); + player->unk_6A8 = &pthis->actor; + Message_StartTextbox(globalCtx, 0x10BE, &pthis->actor); + pthis->actionFunc = EnSkj_StartOcarinaMinigame; + } else if (EnSkj_RangeCheck(player, pthis)) { + player->stateFlags2 |= 0x800000; + } +} + +void EnSkj_StartOcarinaMinigame(EnSkj* pthis, GlobalContext* globalCtx) { + u8 dialogState = Message_GetState(&globalCtx->msgCtx); + Player* player = GET_PLAYER(globalCtx); + + EnSkj_TurnPlayer(pthis, player); + + if (dialogState == TEXT_STATE_CLOSING) { + func_8010BD58(globalCtx, OCARINA_ACTION_MEMORY_GAME); + if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->minigameState = SKULL_KID_OCARINA_PLAY_NOTES; + } + pthis->songFailTimer = 160; + pthis->actionFunc = EnSkj_WaitForPlayback; + } +} + +void EnSkj_WaitForPlayback(EnSkj* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnSkj_TurnPlayer(pthis, player); + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) { // failed the game + Message_CloseTextbox(globalCtx); + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, 26.0f); + pthis->textId = 0x102D; + pthis->actionFunc = EnSkj_FailedMiniGame; + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0F) { // completed the game + func_80078884(NA_SE_SY_CORRECT_CHIME); + Message_CloseTextbox(globalCtx); + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, 26.0f); + pthis->textId = 0x10BF; + pthis->actionFunc = EnSkj_WonOcarinaMiniGame; + } else { // playing the game + switch (globalCtx->msgCtx.msgMode) { + case MSGMODE_MEMORY_GAME_LEFT_SKULLKID_WAIT: + if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->minigameState = SKULL_KID_OCRAINA_WAIT; + } + if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { + if (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->minigameState = + SKULL_KID_OCARINA_PLAY_NOTES; + } + Message_UpdateOcarinaGame(globalCtx); + } + break; + case MSGMODE_MEMORY_GAME_RIGHT_SKULLKID_WAIT: + if (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->minigameState = SKULL_KID_OCRAINA_WAIT; + } + if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { + Message_UpdateOcarinaGame(globalCtx); + pthis->songFailTimer = 160; + } + break; + case MSGMODE_MEMORY_GAME_PLAYER_PLAYING: + if (pthis->songFailTimer != 0) { + pthis->songFailTimer--; + } else { // took too long, game failed + func_80078884(NA_SE_SY_OCARINA_ERROR); + Message_CloseTextbox(globalCtx); + globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + player->unk_6A8 = &pthis->actor; + func_8002F2CC(&pthis->actor, globalCtx, 26.0f); + pthis->textId = 0x102D; + pthis->actionFunc = EnSkj_FailedMiniGame; + } + break; + case MSGMODE_MEMORY_GAME_START_NEXT_ROUND: + if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { + if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->minigameState = + SKULL_KID_OCARINA_PLAY_NOTES; + } + pthis->songFailTimer = 160; + Audio_OcaSetInstrument(6); // related instrument sound (flute?) + Audio_OcaSetSongPlayback(OCARINA_SONG_MEMORY_GAME + 1, 1); + globalCtx->msgCtx.msgMode = MSGMODE_MEMORY_GAME_LEFT_SKULLKID_PLAYING; + globalCtx->msgCtx.stateTimer = 2; + } + break; + } + } +} + +void EnSkj_FailedMiniGame(EnSkj* pthis, GlobalContext* globalCtx) { + if (D_80B01EA0) { + pthis->actionFunc = EnSkj_WaitForNextRound; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 26.0f); + } +} + +void EnSkj_WaitForNextRound(EnSkj* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + EnSkj_OfferNextRound(pthis, globalCtx); + } +} + +void EnSkj_OfferNextRound(EnSkj* pthis, GlobalContext* globalCtx) { + Message_ContinueTextbox(globalCtx, 0x102E); + pthis->actionFunc = EnSkj_WaitForOfferResponse; +} + +void EnSkj_WaitForOfferResponse(EnSkj* pthis, GlobalContext* globalCtx) { + Player* player; + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + player = GET_PLAYER(globalCtx); + player->stateFlags3 |= 0x20; // makes player take ocarina out right away after closing box + pthis->actionFunc = EnSkj_SetupWaitForOcarina; + break; + case 1: // no + pthis->actionFunc = EnSkj_CleanupOcarinaGame; + break; + } + } +} + +void EnSkj_WonOcarinaMiniGame(EnSkj* pthis, GlobalContext* globalCtx) { + if (D_80B01EA0) { + pthis->actionFunc = EnSkj_WaitToGiveReward; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 26.0f); + } +} + +void EnSkj_WaitToGiveReward(EnSkj* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + func_8002F434(&pthis->actor, globalCtx, sOcarinaGameRewards[gSaveContext.ocarinaGameRoundNum], 26.0f, 26.0f); + pthis->actionFunc = EnSkj_GiveOcarinaGameReward; + } +} + +void EnSkj_GiveOcarinaGameReward(EnSkj* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = EnSkj_FinishOcarinaGameRound; + } else { + func_8002F434(&pthis->actor, globalCtx, sOcarinaGameRewards[gSaveContext.ocarinaGameRoundNum], 26.0f, 26.0f); + } +} + +void EnSkj_FinishOcarinaGameRound(EnSkj* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + s32 ocarinaGameRoundNum = gSaveContext.ocarinaGameRoundNum; + + if (gSaveContext.ocarinaGameRoundNum < 3) { + gSaveContext.ocarinaGameRoundNum++; + } + + if (ocarinaGameRoundNum == 2) { + gSaveContext.itemGetInf[1] |= 0x80; + pthis->actionFunc = EnSkj_CleanupOcarinaGame; + } else { + EnSkj_OfferNextRound(pthis, globalCtx); + } + } +} + +void EnSkj_CleanupOcarinaGame(EnSkj* pthis, GlobalContext* globalCtx) { + if (sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_LEFT].unk0 = 2; + } + + if (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid != NULL) { + sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].unk0 = 2; + } + + if ((sOcarinaMinigameSkullKids[SKULL_KID_LEFT].unk0 == 2) && + (sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].unk0 == 2)) { + func_800F5C2C(); + Actor_Kill(&pthis->actor); + } +} + +void EnSkj_OcarinaMinigameShortStumpUpdate(Actor* thisx, GlobalContext* globalCtx) { + EnSkj* pthis = (EnSkj*)thisx; + + D_80B01EA0 = Actor_ProcessTalkRequest(&pthis->actor, globalCtx); + pthis->timer++; + + pthis->actor.focus.pos.x = 1230.0f; + pthis->actor.focus.pos.y = -90.0f; + pthis->actor.focus.pos.z = 450.0f; + + pthis->actionFunc(pthis, globalCtx); + + pthis->actor.textId = pthis->textId; + pthis->actor.xzDistToPlayer = 50.0; +} + +s32 EnSkj_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + return 0; +} + +void EnSkj_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2417); + + if ((limbIndex == 11) && (gSaveContext.itemGetInf[3] & 0x200)) { + func_80093D18(globalCtx->state.gfxCtx); + Matrix_Push(); + Matrix_RotateZYX(-0x4000, 0, 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_skj.c", 2430), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gSKJskullMaskDL); + Matrix_Pop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2437); +} + +Gfx* EnSkj_TranslucentDL(GraphicsContext* gfxCtx, u32 alpha) { + Gfx* dList; + Gfx* dListHead; + + //! @bug This only allocates space for 1 command but uses 3 + dList = dListHead = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); + gDPSetRenderMode(dListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); + gSPEndDisplayList(dListHead++); + + return dList; +} + +Gfx* EnSkj_OpaqueDL(GraphicsContext* gfxCtx, u32 alpha) { + Gfx* dList; + Gfx* dListHead; + + //! @bug This only allocates space for 1 command but uses 2 + dList = dListHead = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx)); + gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); + gSPEndDisplayList(dListHead++); + + return dList; +} + +void EnSkj_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSkj* pthis = (EnSkj*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2475); + + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->alpha < 255) { + gSPSegment(POLY_OPA_DISP++, 0x0C, EnSkj_TranslucentDL(globalCtx->state.gfxCtx, pthis->alpha)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x0C, EnSkj_OpaqueDL(globalCtx->state.gfxCtx, pthis->alpha)); + } + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnSkj_OverrideLimbDraw, EnSkj_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_skj.c", 2495); +} diff --git a/src/overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.c b/src/overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.cpp similarity index 66% rename from src/overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.c rename to src/overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.cpp index 18918a763..31b014c58 100644 --- a/src/overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.c +++ b/src/overlays/actors/ovl_En_Skjneedle/z_en_skjneedle.cpp @@ -21,9 +21,9 @@ void EnSkjneedle_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSkjneedle_Update(Actor* thisx, GlobalContext* globalCtx); void EnSkjneedle_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 EnSkjNeedle_CollisionCheck(EnSkjneedle* this); +s32 EnSkjNeedle_CollisionCheck(EnSkjneedle* pthis); -const ActorInit En_Skjneedle_InitVars = { +ActorInit En_Skjneedle_InitVars = { ACTOR_EN_SKJNEEDLE, ACTORCAT_ENEMY, FLAGS, @@ -60,47 +60,47 @@ static InitChainEntry sInitChain[] = { }; void EnSkjneedle_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSkjneedle* this = (EnSkjneedle*)thisx; + EnSkjneedle* pthis = (EnSkjneedle*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 20.0f); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + ActorShape_Init(&pthis->actor.shape, 0, ActorShadow_DrawCircle, 20.0f); thisx->flags &= ~ACTOR_FLAG_0; - Actor_SetScale(&this->actor, 0.01f); + Actor_SetScale(&pthis->actor, 0.01f); } void EnSkjneedle_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSkjneedle* this = (EnSkjneedle*)thisx; + EnSkjneedle* pthis = (EnSkjneedle*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 EnSkjNeedle_CollisionCheck(EnSkjneedle* this) { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.acFlags &= ~AC_HIT; +s32 EnSkjNeedle_CollisionCheck(EnSkjneedle* pthis) { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; return 1; } return 0; } void EnSkjneedle_Update(Actor* thisx, GlobalContext* globalCtx2) { - EnSkjneedle* this = (EnSkjneedle*)thisx; + EnSkjneedle* pthis = (EnSkjneedle*)thisx; GlobalContext* globalCtx = globalCtx2; - this->unusedTimer1++; - if (this->killTimer != 0) { - this->killTimer--; + pthis->unusedTimer1++; + if (pthis->killTimer != 0) { + pthis->killTimer--; } - if (EnSkjNeedle_CollisionCheck(this) || this->killTimer == 0) { - Actor_Kill(&this->actor); + if (EnSkjNeedle_CollisionCheck(pthis) || pthis->killTimer == 0) { + Actor_Kill(&pthis->actor); } else { - Actor_SetScale(&this->actor, 0.01f); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 7); + Actor_SetScale(&pthis->actor, 0.01f); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 20.0f, 7); } } diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c deleted file mode 100644 index 693318aae..000000000 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ /dev/null @@ -1,899 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SSH_Z_EN_SSH_C -#include "actor_common.h" -#include "z_en_ssh.h" -#include "objects/object_ssh/object_ssh.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -#define SSH_STATE_STUNNED (1 << 0) -#define SSH_STATE_GROUND_START (1 << 2) -#define SSH_STATE_ATTACKED (1 << 3) -#define SSH_STATE_SPIN (1 << 4) - -typedef enum { - SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? - SSH_ANIM_UP, - SSH_ANIM_WAIT, - SSH_ANIM_LAND, - SSH_ANIM_DROP, - SSH_ANIM_UNK5, // Slower version of ANIM_DROP - SSH_ANIM_UNK6 // Faster repeating version of ANIM_UNK0 -} EnSshAnimation; - -void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx); - -#include "overlays/ovl_En_Ssh/ovl_En_Ssh.c" - -const ActorInit En_Ssh_InitVars = { - ACTOR_EN_SSH, - ACTORCAT_NPC, - FLAGS, - OBJECT_SSH, - sizeof(EnSsh), - (ActorFunc)EnSsh_Init, - (ActorFunc)EnSsh_Destroy, - (ActorFunc)EnSsh_Update, - (ActorFunc)EnSsh_Draw, -}; - -static ColliderCylinderInit sCylinderInit1 = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 32, 50, -24, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; - -static ColliderCylinderInit sCylinderInit2 = { - { - COLTYPE_HIT6, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 60, -30, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 1, { { 0, -240, 0 }, 28 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphElementsInit), - sJntSphElementsInit, -}; - -void EnSsh_SetupAction(EnSsh* this, EnSshActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnSsh_SpawnShockwave(EnSsh* this, GlobalContext* globalCtx) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f pos; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.floorHeight; - pos.z = this->actor.world.pos.z; - EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &pos, &zeroVec, &zeroVec, 100, 220, 8); -} - -s32 EnSsh_CreateBlureEffect(GlobalContext* globalCtx) { - EffectBlureInit1 blureInit; - u8 p1StartColor[] = { 255, 255, 255, 75 }; - u8 p2StartColor[] = { 255, 255, 255, 75 }; - u8 p1EndColor[] = { 255, 255, 255, 0 }; - u8 p2EndColor[] = { 255, 255, 255, 0 }; - s32 i; - s32 blureIdx; - - for (i = 0; i < 4; i++) { - blureInit.p1StartColor[i] = p1StartColor[i]; - blureInit.p2StartColor[i] = p2StartColor[i]; - blureInit.p1EndColor[i] = p1EndColor[i]; - blureInit.p2EndColor[i] = p2EndColor[i]; - } - - blureInit.elemDuration = 6; - blureInit.unkFlag = 0; - blureInit.calcMode = 3; - - Effect_Add(globalCtx, &blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); - return blureIdx; -} - -s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { - CollisionPoly* poly; - s32 bgId; - Vec3f posB; - - posB.x = this->actor.world.pos.x; - posB.y = this->actor.world.pos.y + 1000.0f; - posB.z = this->actor.world.pos.z; - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, false, - false, true, true, &bgId)) { - return false; - } else { - return true; - } -} - -void EnSsh_AddBlureVertex(EnSsh* this) { - Vec3f p1base = { 834.0f, 834.0f, 0.0f }; - Vec3f p2base = { 834.0f, -584.0f, 0.0f }; - Vec3f p1; - Vec3f p2; - - p1base.x *= this->colliderScale; - p1base.y *= this->colliderScale; - p1base.z *= this->colliderScale; - p2base.x *= this->colliderScale; - p2base.y *= this->colliderScale; - p2base.z *= this->colliderScale; - Matrix_Push(); - Matrix_MultVec3f(&p1base, &p1); - Matrix_MultVec3f(&p2base, &p2); - Matrix_Pop(); - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &p1, &p2); -} - -void EnSsh_AddBlureSpace(EnSsh* this) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); -} - -void EnSsh_InitColliders(EnSsh* this, GlobalContext* globalCtx) { - ColliderCylinderInit* cylinders[6] = { - &sCylinderInit1, &sCylinderInit1, &sCylinderInit1, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, - }; - s32 i; - s32 pad; - - for (i = 0; i < ARRAY_COUNT(cylinders); i++) { - Collider_InitCylinder(globalCtx, &this->colCylinder[i]); - Collider_SetCylinder(globalCtx, &this->colCylinder[i], &this->actor, cylinders[i]); - } - - this->colCylinder[0].info.bumper.dmgFlags = 0x0003F8E9; - this->colCylinder[1].info.bumper.dmgFlags = 0xFFC00716; - this->colCylinder[2].base.colType = COLTYPE_METAL; - this->colCylinder[2].info.bumperFlags = BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO; - this->colCylinder[2].info.elemType = ELEMTYPE_UNK2; - this->colCylinder[2].info.bumper.dmgFlags = 0xFFCC0716; - - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(2), &sColChkInfoInit); - - Collider_InitJntSph(globalCtx, &this->colSph); - Collider_SetJntSph(globalCtx, &this->colSph, &this->actor, &sJntSphInit, this->colSphElements); -} - -f32 EnSsh_SetAnimation(EnSsh* this, s32 animIndex) { - AnimationHeader* animation[] = { - &object_ssh_Anim_005BE8, &object_ssh_Anim_000304, &object_ssh_Anim_000304, &object_ssh_Anim_0055F8, - &object_ssh_Anim_000304, &object_ssh_Anim_000304, &object_ssh_Anim_005BE8, - }; - f32 playbackSpeed[] = { 1.0f, 4.0f, 1.0f, 1.0f, 8.0f, 6.0f, 2.0f }; - u8 mode[] = { 3, 3, 1, 3, 1, 1, 1 }; - f32 frameCount = Animation_GetLastFrame(animation[animIndex]); - s32 pad; - - Animation_Change(&this->skelAnime, animation[animIndex], playbackSpeed[animIndex], 0.0f, frameCount, - mode[animIndex], -6.0f); - - return frameCount; -} - -void EnSsh_SetWaitAnimation(EnSsh* this) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); -} - -void EnSsh_SetReturnAnimation(EnSsh* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_UP); - EnSsh_SetAnimation(this, SSH_ANIM_UP); -} - -void EnSsh_SetLandAnimation(EnSsh* this) { - this->actor.world.pos.y = this->floorHeightOffset + this->actor.floorHeight; - this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_LAND); -} - -void EnSsh_SetDropAnimation(EnSsh* this) { - if (this->unkTimer == 0) { - this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_DROP); - } - this->actor.velocity.y = -10.0f; -} - -void EnSsh_SetStunned(EnSsh* this) { - if (this->stunTimer == 0) { - this->stateFlags |= SSH_STATE_ATTACKED; - this->stunTimer = 120; - this->actor.colorFilterTimer = 0; - } -} - -void EnSsh_SetColliderScale(EnSsh* this, f32 scale, f32 radiusMod) { - f32 radius; - f32 height; - f32 yShift; - s32 i; - - radius = this->colSph.elements[0].dim.modelSphere.radius; - radius *= scale; - this->colSph.elements[0].dim.modelSphere.radius = radius; - - for (i = 0; i < 6; i++) { - yShift = this->colCylinder[i].dim.yShift; - radius = this->colCylinder[i].dim.radius; - height = this->colCylinder[i].dim.height; - yShift *= scale; - radius *= scale * radiusMod; - height *= scale; - - this->colCylinder[i].dim.yShift = yShift; - this->colCylinder[i].dim.radius = radius; - this->colCylinder[i].dim.height = height; - } - Actor_SetScale(&this->actor, 0.04f * scale); - this->floorHeightOffset = 40.0f * scale; - this->colliderScale = scale * 1.5f; -} - -s32 EnSsh_Damaged(EnSsh* this) { - if ((this->stunTimer == 120) && (this->stateFlags & SSH_STATE_STUNNED)) { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, this->stunTimer); - } - if (DECR(this->stunTimer) != 0) { - Math_SmoothStepToS(&this->maxTurnRate, 0x2710, 0xA, 0x3E8, 1); - return false; - } else { - this->stunTimer = 0; - this->stateFlags &= ~SSH_STATE_STUNNED; - this->spinTimer = 0; - if (this->swayTimer == 0) { - this->spinTimer = 30; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_ROLL); - Audio_PlayActorSound2(&this->actor, NA_SE_VO_ST_ATTACK); - return true; - } -} - -void EnSsh_Turn(EnSsh* this, GlobalContext* globalCtx) { - if (this->hitTimer != 0) { - this->hitTimer--; - } - if (DECR(this->spinTimer) != 0) { - this->actor.world.rot.y += 10000.0f * (this->spinTimer / 30.0f); - } else if ((this->swayTimer == 0) && (this->stunTimer == 0)) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 4, 0x2710, 1); - } - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnSsh_Stunned(EnSsh* this, GlobalContext* globalCtx) { - if ((this->swayTimer == 0) && (this->stunTimer == 0)) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer ^ 0x8000, 4, this->maxTurnRate, 1); - } - this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->stunTimer < 30) { - if (this->stunTimer & 1) { - this->actor.shape.rot.y += 0x7D0; - } else { - this->actor.shape.rot.y -= 0x7D0; - } - } -} - -void EnSsh_UpdateYaw(EnSsh* this, GlobalContext* globalCtx) { - if (this->stunTimer != 0) { - EnSsh_Stunned(this, globalCtx); - } else { - EnSsh_Turn(this, globalCtx); - } -} - -void EnSsh_Bob(EnSsh* this, GlobalContext* globalCtx) { - f32 bobVel = 0.5f; - - if ((globalCtx->state.frames & 8) != 0) { - bobVel *= -1.0f; - } - Math_SmoothStepToF(&this->actor.velocity.y, bobVel, 0.4f, 1000.0f, 0.0f); -} - -s32 EnSsh_IsCloseToLink(EnSsh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 yDist; - - if (this->stateFlags & SSH_STATE_GROUND_START) { - return true; - } - if (this->unkTimer != 0) { - return true; - } - if (this->swayTimer != 0) { - return true; - } - if (this->animTimer != 0) { - return true; - } - - if (this->actor.xzDistToPlayer > 160.0f) { - return false; - } - - yDist = this->actor.world.pos.y - player->actor.world.pos.y; - if (yDist < 0.0f || yDist > 400.0f) { - return false; - } - - if (player->actor.world.pos.y < this->actor.floorHeight) { - return false; - } - return true; -} - -s32 EnSsh_IsCloseToHome(EnSsh* this) { - f32 vel = this->actor.velocity.y; - f32 nextY = this->actor.world.pos.y + 2.0f * this->actor.velocity.y; - - if (nextY >= this->actor.home.pos.y) { - return 1; - } - return 0; -} - -s32 EnSsh_IsCloseToGround(EnSsh* this) { - f32 vel = this->actor.velocity.y; - f32 nextY = this->actor.world.pos.y + 2.0f * this->actor.velocity.y; - - if ((nextY - this->actor.floorHeight) <= this->floorHeightOffset) { - return 1; - } - return 0; -} - -void EnSsh_Sway(EnSsh* this) { - Vec3f swayVecBase; - Vec3f swayVec; - f32 temp; - s16 swayAngle; - - if (this->swayTimer != 0) { - this->swayAngle += 0x640; - this->swayTimer--; - if (this->swayTimer == 0) { - this->swayAngle = 0; - } - temp = this->swayTimer * (1.0f / 6); - swayAngle = temp * (0x10000 / 360.0f) * Math_SinS(this->swayAngle); - temp = this->actor.world.pos.y - this->ceilingPos.y; - swayVecBase.x = Math_SinS(swayAngle) * temp; - swayVecBase.y = Math_CosS(swayAngle) * temp; - swayVecBase.z = 0.0f; - Matrix_Push(); - Matrix_Translate(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultVec3f(&swayVecBase, &swayVec); - Matrix_Pop(); - this->actor.shape.rot.z = -(swayAngle * 2); - this->actor.world.pos.x = swayVec.x; - this->actor.world.pos.z = swayVec.z; - } -} - -void EnSsh_CheckBodyStickHit(EnSsh* this, GlobalContext* globalCtx) { - ColliderInfo* info = &this->colCylinder[0].info; - Player* player = GET_PLAYER(globalCtx); - - if (player->unk_860 != 0) { - info->bumper.dmgFlags |= 2; - this->colCylinder[1].info.bumper.dmgFlags &= ~2; - this->colCylinder[2].info.bumper.dmgFlags &= ~2; - } else { - info->bumper.dmgFlags &= ~2; - this->colCylinder[1].info.bumper.dmgFlags |= 2; - this->colCylinder[2].info.bumper.dmgFlags |= 2; - } -} - -s32 EnSsh_CheckHitPlayer(EnSsh* this, GlobalContext* globalCtx) { - s32 i; - s32 hit = false; - - if ((this->hitCount == 0) && (this->spinTimer == 0)) { - return false; - } - for (i = 0; i < 3; i++) { - if (this->colCylinder[i + 3].base.ocFlags2 & OC2_HIT_PLAYER) { - this->colCylinder[i + 3].base.ocFlags2 &= ~OC2_HIT_PLAYER; - hit = true; - } - } - if (!hit) { - return false; - } - this->hitTimer = 30; - if (this->swayTimer == 0) { - this->spinTimer = this->hitTimer; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_ROLL); - Audio_PlayActorSound2(&this->actor, NA_SE_VO_ST_ATTACK); - globalCtx->damagePlayer(globalCtx, -8); - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); - this->hitCount--; - return true; -} - -s32 EnSsh_CheckHitFront(EnSsh* this) { - u32 acFlags; - - if (this->colCylinder[2].base.acFlags) {} // Needed for matching - acFlags = this->colCylinder[2].base.acFlags; - - if (!!(acFlags & AC_HIT) == 0) { - return 0; - } else { - this->colCylinder[2].base.acFlags &= ~AC_HIT; - this->invincibilityTimer = 8; - if ((this->swayTimer == 0) && (this->hitTimer == 0) && (this->stunTimer == 0)) { - this->swayTimer = 60; - } - return 1; - } -} - -s32 EnSsh_CheckHitBack(EnSsh* this, GlobalContext* globalCtx) { - ColliderCylinder* cyl = &this->colCylinder[0]; - s32 hit = false; - - if (cyl->base.acFlags & AC_HIT) { - cyl->base.acFlags &= ~AC_HIT; - hit = true; - } - cyl = &this->colCylinder[1]; - if (cyl->base.acFlags & AC_HIT) { - cyl->base.acFlags &= ~AC_HIT; - hit = true; - } - if (!hit) { - return false; - } - this->invincibilityTimer = 8; - if (this->hitCount <= 0) { - this->hitCount++; - } - if (this->stunTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Audio_PlayActorSound2(&this->actor, NA_SE_VO_ST_DAMAGE); - } - EnSsh_SetStunned(this); - this->stateFlags |= SSH_STATE_STUNNED; - return false; -} - -s32 EnSsh_CollisionCheck(EnSsh* this, GlobalContext* globalCtx) { - if (this->stunTimer == 0) { - EnSsh_CheckHitPlayer(this, globalCtx); - } - if (EnSsh_CheckHitFront(this)) { - return false; - } else if (globalCtx->actorCtx.unk_02 != 0) { - this->invincibilityTimer = 8; - if (this->stunTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Audio_PlayActorSound2(&this->actor, NA_SE_VO_ST_DAMAGE); - } - EnSsh_SetStunned(this); - this->stateFlags |= SSH_STATE_STUNNED; - return false; - } else { - return EnSsh_CheckHitBack(this, globalCtx); - // Always returns false - } -} - -void EnSsh_SetBodyCylinderAC(EnSsh* this, GlobalContext* globalCtx) { - Collider_UpdateCylinder(&this->actor, &this->colCylinder[0]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[0].base); -} - -void EnSsh_SetLegsCylinderAC(EnSsh* this, GlobalContext* globalCtx) { - s16 angleTowardsLink = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); - - if (angleTowardsLink < 90 * (0x10000 / 360)) { - Collider_UpdateCylinder(&this->actor, &this->colCylinder[2]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[2].base); - } else { - Collider_UpdateCylinder(&this->actor, &this->colCylinder[1]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[1].base); - } -} - -s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { - Vec3f cyloffsets[] = { - { 40.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f }, - { -40.0f, 0.0f, 0.0f }, - }; - Vec3f cylPos; - s32 i; - - for (i = 0; i < 3; i++) { - cylPos = this->actor.world.pos; - cyloffsets[i].x *= this->colliderScale; - cyloffsets[i].y *= this->colliderScale; - cyloffsets[i].z *= this->colliderScale; - Matrix_Push(); - Matrix_Translate(cylPos.x, cylPos.y, cylPos.z, MTXMODE_NEW); - Matrix_RotateY((this->initialYaw / (f32)0x8000) * M_PI, MTXMODE_APPLY); - Matrix_MultVec3f(&cyloffsets[i], &cylPos); - Matrix_Pop(); - this->colCylinder[i + 3].dim.pos.x = cylPos.x; - this->colCylinder[i + 3].dim.pos.y = cylPos.y; - this->colCylinder[i + 3].dim.pos.z = cylPos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[i + 3].base); - } - return 1; -} - -void EnSsh_SetColliders(EnSsh* this, GlobalContext* globalCtx) { - if (this->actor.colChkInfo.health == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colSph.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colSph.base); - } else { - if (this->hitTimer == 0) { - EnSsh_SetCylinderOC(this, globalCtx); - } - if (DECR(this->invincibilityTimer) == 0) { - EnSsh_SetBodyCylinderAC(this, globalCtx); - EnSsh_SetLegsCylinderAC(this, globalCtx); - } - } -} - -void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx) { - f32 frameCount; - s32 pad; - EnSsh* this = (EnSsh*)thisx; - - frameCount = Animation_GetLastFrame(&object_ssh_Anim_000304); - if (this->actor.params == ENSSH_FATHER) { - if (gSaveContext.inventory.gsTokens >= 100) { - Actor_Kill(&this->actor); - return; - } - } else if (gSaveContext.inventory.gsTokens >= (this->actor.params * 10)) { - Actor_Kill(&this->actor); - return; - } - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_ssh_Skel_0052E0, NULL, this->jointTable, this->morphTable, 30); - Animation_Change(&this->skelAnime, &object_ssh_Anim_000304, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, 0.0f); - this->blureIdx = EnSsh_CreateBlureEffect(globalCtx); - EnSsh_InitColliders(this, globalCtx); - this->stateFlags = 0; - this->hitCount = 0; - EnSsh_CheckCeilingPos(this, globalCtx); - if (this->actor.params != ENSSH_FATHER) { - EnSsh_SetColliderScale(this, 0.5f, 1.0f); - } else { - EnSsh_SetColliderScale(this, 0.75f, 1.0f); - } - this->actor.gravity = 0.0f; - this->initialYaw = this->actor.world.rot.y; - EnSsh_SetupAction(this, EnSsh_Start); -} - -void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSsh* this = (EnSsh*)thisx; - s32 i; - - Effect_Delete(globalCtx, this->blureIdx); - for (i = 0; i < 6; i++) { - Collider_DestroyCylinder(globalCtx, &this->colCylinder[i]); - } - Collider_DestroyJntSph(globalCtx, &this->colSph); -} - -void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { - if (EnSsh_IsCloseToLink(this, globalCtx)) { - EnSsh_SetDropAnimation(this); - EnSsh_SetupAction(this, EnSsh_Drop); - } else { - EnSsh_Bob(this, globalCtx); - } -} - -void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { - EnSsh_Bob(this, globalCtx); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnSsh_Idle; - } -} - -void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { - if (1) {} - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnSsh_Talk; - if (this->actor.params == ENSSH_FATHER) { - gSaveContext.eventChkInf[9] |= 0x40; - } - if ((this->actor.textId == 0x26) || (this->actor.textId == 0x27)) { - gSaveContext.infTable[25] |= 0x40; - } - if ((this->actor.textId == 0x24) || (this->actor.textId == 0x25)) { - gSaveContext.infTable[25] |= 0x80; - } - } else { - if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); - } - if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); - } - if (!EnSsh_IsCloseToLink(this, globalCtx)) { - EnSsh_SetReturnAnimation(this); - EnSsh_SetupAction(this, EnSsh_Return); - } else { - if (DECR(this->sfxTimer) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_LAUGH); - this->sfxTimer = 64; - } - EnSsh_Bob(this, globalCtx); - if ((this->unkTimer == 0) && (this->animTimer == 0)) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0xD); - if (this->actor.textId == 0) { - if (this->actor.params == ENSSH_FATHER) { - if (gSaveContext.inventory.gsTokens >= 50) { - this->actor.textId = 0x29; - } else if (gSaveContext.inventory.gsTokens >= 10) { - if (gSaveContext.infTable[25] & 0x80) { - this->actor.textId = 0x24; - } else { - this->actor.textId = 0x25; - } - } else { - if (gSaveContext.infTable[25] & 0x40) { - this->actor.textId = 0x27; - } else { - this->actor.textId = 0x26; - } - } - } else { - this->actor.textId = 0x22; - } - } - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - } -} - -void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx) { - if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); - } - if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); - } - if ((this->actor.floorHeight + this->floorHeightOffset) <= this->actor.world.pos.y) { - EnSsh_SetupAction(this, EnSsh_Idle); - } else { - Math_SmoothStepToF(&this->actor.velocity.y, 2.0f, 0.6f, 1000.0f, 0.0f); - } -} - -void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx) { - if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_DROP); - } - if (!EnSsh_IsCloseToLink(this, globalCtx)) { - EnSsh_SetReturnAnimation(this); - EnSsh_SetupAction(this, EnSsh_Return); - } else if (EnSsh_IsCloseToGround(this)) { - EnSsh_SpawnShockwave(this, globalCtx); - EnSsh_SetLandAnimation(this); - EnSsh_SetupAction(this, EnSsh_Land); - } else if (DECR(this->sfxTimer) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DOWN); - this->sfxTimer = 3; - } -} - -void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx) { - f32 frameRatio = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); - - if (frameRatio == 1.0f) { - EnSsh_SetReturnAnimation(this); - } - if (EnSsh_IsCloseToLink(this, globalCtx)) { - EnSsh_SetDropAnimation(this); - EnSsh_SetupAction(this, EnSsh_Drop); - } else if (EnSsh_IsCloseToHome(this)) { - EnSsh_SetWaitAnimation(this); - EnSsh_SetupAction(this, EnSsh_Wait); - } else { - this->actor.velocity.y = 4.0f * frameRatio; - } -} - -void EnSsh_UpdateColliderScale(EnSsh* this) { - if (this->stateFlags & SSH_STATE_SPIN) { - if (this->spinTimer == 0) { - this->stateFlags &= ~SSH_STATE_SPIN; - if (this->actor.params != ENSSH_FATHER) { - EnSsh_SetColliderScale(this, 0.5f, 1.0f); - } else { - EnSsh_SetColliderScale(this, 0.75f, 1.0f); - } - } - } else { - if (this->spinTimer != 0) { - this->stateFlags |= SSH_STATE_SPIN; - if (this->actor.params != ENSSH_FATHER) { - EnSsh_SetColliderScale(this, 0.5f, 2.0f); - } else { - EnSsh_SetColliderScale(this, 0.75f, 2.0f); - } - } - } -} - -void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx) { - if (!EnSsh_IsCloseToGround(this)) { - EnSsh_SetupAction(this, EnSsh_Wait); - EnSsh_Wait(this, globalCtx); - } else { - EnSsh_SetLandAnimation(this); - this->stateFlags |= 4; - EnSsh_SetupAction(this, EnSsh_Land); - EnSsh_Land(this, globalCtx); - } -} - -void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSsh* this = (EnSsh*)thisx; - - EnSsh_UpdateColliderScale(this); - if (EnSsh_CollisionCheck(this, globalCtx)) { - return; // EnSsh_CollisionCheck always returns false, so this never happens - } - if (this->stunTimer != 0) { - EnSsh_Damaged(this); - } else { - SkelAnime_Update(&this->skelAnime); - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); - } - EnSsh_UpdateYaw(this, globalCtx); - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - this->blinkState = this->blinkTimer; - if (this->blinkState >= 3) { - this->blinkState = 0; - } - EnSsh_SetColliders(this, globalCtx); - Actor_SetFocus(&this->actor, 0.0f); -} - -s32 EnSsh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnSsh* this = (EnSsh*)thisx; - - switch (limbIndex) { - case 1: - if ((this->spinTimer != 0) && (this->swayTimer == 0)) { - if (this->spinTimer >= 2) { - EnSsh_AddBlureVertex(this); - } else { - EnSsh_AddBlureSpace(this); - } - } - break; - case 4: - if (this->actor.params == ENSSH_FATHER) { - *dList = object_ssh_DL_0046C0; - } - break; - case 5: - if (this->actor.params == ENSSH_FATHER) { - *dList = object_ssh_DL_004080; - } - break; - case 8: - if (this->actor.params == ENSSH_FATHER) { - *dList = object_ssh_DL_004DE8; - } - break; - } - return false; -} - -void EnSsh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnSsh* this = (EnSsh*)thisx; - - Collider_UpdateSpheres(limbIndex, &this->colSph); -} - -void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* blinkTex[] = { - object_ssh_Tex_0007E0, - object_ssh_Tex_000C60, - object_ssh_Tex_001060, - }; - s32 pad; - EnSsh* this = (EnSsh*)thisx; - - EnSsh_CheckBodyStickHit(this, globalCtx); - EnSsh_Sway(this); - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ssh.c", 2333); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(blinkTex[this->blinkState])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ssh.c", 2336); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSsh_OverrideLimbDraw, - EnSsh_PostLimbDraw, &this->actor); -} diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.cpp b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.cpp new file mode 100644 index 000000000..b731cb4b9 --- /dev/null +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.cpp @@ -0,0 +1,899 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SSH_Z_EN_SSH_C +#include "actor_common.h" +#include "z_en_ssh.h" +#include "objects/object_ssh/object_ssh.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +#define SSH_STATE_STUNNED (1 << 0) +#define SSH_STATE_GROUND_START (1 << 2) +#define SSH_STATE_ATTACKED (1 << 3) +#define SSH_STATE_SPIN (1 << 4) + +typedef enum { + SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? + SSH_ANIM_UP, + SSH_ANIM_WAIT, + SSH_ANIM_LAND, + SSH_ANIM_DROP, + SSH_ANIM_UNK5, // Slower version of ANIM_DROP + SSH_ANIM_UNK6 // Faster repeating version of ANIM_UNK0 +} EnSshAnimation; + +void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSsh_Idle(EnSsh* pthis, GlobalContext* globalCtx); +void EnSsh_Drop(EnSsh* pthis, GlobalContext* globalCtx); +void EnSsh_Return(EnSsh* pthis, GlobalContext* globalCtx); +void EnSsh_Start(EnSsh* pthis, GlobalContext* globalCtx); + +#include "overlays/ovl_En_Ssh/ovl_En_Ssh.cpp" + +ActorInit En_Ssh_InitVars = { + ACTOR_EN_SSH, + ACTORCAT_NPC, + FLAGS, + OBJECT_SSH, + sizeof(EnSsh), + (ActorFunc)EnSsh_Init, + (ActorFunc)EnSsh_Destroy, + (ActorFunc)EnSsh_Update, + (ActorFunc)EnSsh_Draw, +}; + +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 32, 50, -24, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 60, -30, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 1, { { 0, -240, 0 }, 28 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, +}; + +void EnSsh_SetupAction(EnSsh* pthis, EnSshActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnSsh_SpawnShockwave(EnSsh* pthis, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.floorHeight; + pos.z = pthis->actor.world.pos.z; + EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &pos, &zeroVec, &zeroVec, 100, 220, 8); +} + +s32 EnSsh_CreateBlureEffect(GlobalContext* globalCtx) { + EffectBlureInit1 blureInit; + u8 p1StartColor[] = { 255, 255, 255, 75 }; + u8 p2StartColor[] = { 255, 255, 255, 75 }; + u8 p1EndColor[] = { 255, 255, 255, 0 }; + u8 p2EndColor[] = { 255, 255, 255, 0 }; + s32 i; + s32 blureIdx; + + for (i = 0; i < 4; i++) { + blureInit.p1StartColor[i] = p1StartColor[i]; + blureInit.p2StartColor[i] = p2StartColor[i]; + blureInit.p1EndColor[i] = p1EndColor[i]; + blureInit.p2EndColor[i] = p2EndColor[i]; + } + + blureInit.elemDuration = 6; + blureInit.unkFlag = 0; + blureInit.calcMode = 3; + + Effect_Add(globalCtx, &blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); + return blureIdx; +} + +s32 EnSsh_CheckCeilingPos(EnSsh* pthis, GlobalContext* globalCtx) { + CollisionPoly* poly; + s32 bgId; + Vec3f posB; + + posB.x = pthis->actor.world.pos.x; + posB.y = pthis->actor.world.pos.y + 1000.0f; + posB.z = pthis->actor.world.pos.z; + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &posB, &pthis->ceilingPos, &poly, false, + false, true, true, &bgId)) { + return false; + } else { + return true; + } +} + +void EnSsh_AddBlureVertex(EnSsh* pthis) { + Vec3f p1base = { 834.0f, 834.0f, 0.0f }; + Vec3f p2base = { 834.0f, -584.0f, 0.0f }; + Vec3f p1; + Vec3f p2; + + p1base.x *= pthis->colliderScale; + p1base.y *= pthis->colliderScale; + p1base.z *= pthis->colliderScale; + p2base.x *= pthis->colliderScale; + p2base.y *= pthis->colliderScale; + p2base.z *= pthis->colliderScale; + Matrix_Push(); + Matrix_MultVec3f(&p1base, &p1); + Matrix_MultVec3f(&p2base, &p2); + Matrix_Pop(); + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIdx), &p1, &p2); +} + +void EnSsh_AddBlureSpace(EnSsh* pthis) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIdx)); +} + +void EnSsh_InitColliders(EnSsh* pthis, GlobalContext* globalCtx) { + ColliderCylinderInit* cylinders[6] = { + &sCylinderInit1, &sCylinderInit1, &sCylinderInit1, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, + }; + s32 i; + s32 pad; + + for (i = 0; i < ARRAY_COUNT(cylinders); i++) { + Collider_InitCylinder(globalCtx, &pthis->colCylinder[i]); + Collider_SetCylinder(globalCtx, &pthis->colCylinder[i], &pthis->actor, cylinders[i]); + } + + pthis->colCylinder[0].info.bumper.dmgFlags = 0x0003F8E9; + pthis->colCylinder[1].info.bumper.dmgFlags = 0xFFC00716; + pthis->colCylinder[2].base.colType = COLTYPE_METAL; + pthis->colCylinder[2].info.bumperFlags = BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO; + pthis->colCylinder[2].info.elemType = ELEMTYPE_UNK2; + pthis->colCylinder[2].info.bumper.dmgFlags = 0xFFCC0716; + + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(2), &sColChkInfoInit); + + Collider_InitJntSph(globalCtx, &pthis->colSph); + Collider_SetJntSph(globalCtx, &pthis->colSph, &pthis->actor, &sJntSphInit, pthis->colSphElements); +} + +f32 EnSsh_SetAnimation(EnSsh* pthis, s32 animIndex) { + AnimationHeader* animation[] = { + &object_ssh_Anim_005BE8, &object_ssh_Anim_000304, &object_ssh_Anim_000304, &object_ssh_Anim_0055F8, + &object_ssh_Anim_000304, &object_ssh_Anim_000304, &object_ssh_Anim_005BE8, + }; + f32 playbackSpeed[] = { 1.0f, 4.0f, 1.0f, 1.0f, 8.0f, 6.0f, 2.0f }; + u8 mode[] = { 3, 3, 1, 3, 1, 1, 1 }; + f32 frameCount = Animation_GetLastFrame(animation[animIndex]); + s32 pad; + + Animation_Change(&pthis->skelAnime, animation[animIndex], playbackSpeed[animIndex], 0.0f, frameCount, + mode[animIndex], -6.0f); + + return frameCount; +} + +void EnSsh_SetWaitAnimation(EnSsh* pthis) { + EnSsh_SetAnimation(pthis, SSH_ANIM_WAIT); +} + +void EnSsh_SetReturnAnimation(EnSsh* pthis) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_UP); + EnSsh_SetAnimation(pthis, SSH_ANIM_UP); +} + +void EnSsh_SetLandAnimation(EnSsh* pthis) { + pthis->actor.world.pos.y = pthis->floorHeightOffset + pthis->actor.floorHeight; + pthis->animTimer = EnSsh_SetAnimation(pthis, SSH_ANIM_LAND); +} + +void EnSsh_SetDropAnimation(EnSsh* pthis) { + if (pthis->unkTimer == 0) { + pthis->animTimer = EnSsh_SetAnimation(pthis, SSH_ANIM_DROP); + } + pthis->actor.velocity.y = -10.0f; +} + +void EnSsh_SetStunned(EnSsh* pthis) { + if (pthis->stunTimer == 0) { + pthis->stateFlags |= SSH_STATE_ATTACKED; + pthis->stunTimer = 120; + pthis->actor.colorFilterTimer = 0; + } +} + +void EnSsh_SetColliderScale(EnSsh* pthis, f32 scale, f32 radiusMod) { + f32 radius; + f32 height; + f32 yShift; + s32 i; + + radius = pthis->colSph.elements[0].dim.modelSphere.radius; + radius *= scale; + pthis->colSph.elements[0].dim.modelSphere.radius = radius; + + for (i = 0; i < 6; i++) { + yShift = pthis->colCylinder[i].dim.yShift; + radius = pthis->colCylinder[i].dim.radius; + height = pthis->colCylinder[i].dim.height; + yShift *= scale; + radius *= scale * radiusMod; + height *= scale; + + pthis->colCylinder[i].dim.yShift = yShift; + pthis->colCylinder[i].dim.radius = radius; + pthis->colCylinder[i].dim.height = height; + } + Actor_SetScale(&pthis->actor, 0.04f * scale); + pthis->floorHeightOffset = 40.0f * scale; + pthis->colliderScale = scale * 1.5f; +} + +s32 EnSsh_Damaged(EnSsh* pthis) { + if ((pthis->stunTimer == 120) && (pthis->stateFlags & SSH_STATE_STUNNED)) { + Actor_SetColorFilter(&pthis->actor, 0, 0xC8, 0, pthis->stunTimer); + } + if (DECR(pthis->stunTimer) != 0) { + Math_SmoothStepToS(&pthis->maxTurnRate, 0x2710, 0xA, 0x3E8, 1); + return false; + } else { + pthis->stunTimer = 0; + pthis->stateFlags &= ~SSH_STATE_STUNNED; + pthis->spinTimer = 0; + if (pthis->swayTimer == 0) { + pthis->spinTimer = 30; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_ROLL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_ST_ATTACK); + return true; + } +} + +void EnSsh_Turn(EnSsh* pthis, GlobalContext* globalCtx) { + if (pthis->hitTimer != 0) { + pthis->hitTimer--; + } + if (DECR(pthis->spinTimer) != 0) { + pthis->actor.world.rot.y += 10000.0f * (pthis->spinTimer / 30.0f); + } else if ((pthis->swayTimer == 0) && (pthis->stunTimer == 0)) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 4, 0x2710, 1); + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnSsh_Stunned(EnSsh* pthis, GlobalContext* globalCtx) { + if ((pthis->swayTimer == 0) && (pthis->stunTimer == 0)) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer ^ 0x8000, 4, pthis->maxTurnRate, 1); + } + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if (pthis->stunTimer < 30) { + if (pthis->stunTimer & 1) { + pthis->actor.shape.rot.y += 0x7D0; + } else { + pthis->actor.shape.rot.y -= 0x7D0; + } + } +} + +void EnSsh_UpdateYaw(EnSsh* pthis, GlobalContext* globalCtx) { + if (pthis->stunTimer != 0) { + EnSsh_Stunned(pthis, globalCtx); + } else { + EnSsh_Turn(pthis, globalCtx); + } +} + +void EnSsh_Bob(EnSsh* pthis, GlobalContext* globalCtx) { + f32 bobVel = 0.5f; + + if ((globalCtx->state.frames & 8) != 0) { + bobVel *= -1.0f; + } + Math_SmoothStepToF(&pthis->actor.velocity.y, bobVel, 0.4f, 1000.0f, 0.0f); +} + +s32 EnSsh_IsCloseToLink(EnSsh* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 yDist; + + if (pthis->stateFlags & SSH_STATE_GROUND_START) { + return true; + } + if (pthis->unkTimer != 0) { + return true; + } + if (pthis->swayTimer != 0) { + return true; + } + if (pthis->animTimer != 0) { + return true; + } + + if (pthis->actor.xzDistToPlayer > 160.0f) { + return false; + } + + yDist = pthis->actor.world.pos.y - player->actor.world.pos.y; + if (yDist < 0.0f || yDist > 400.0f) { + return false; + } + + if (player->actor.world.pos.y < pthis->actor.floorHeight) { + return false; + } + return true; +} + +s32 EnSsh_IsCloseToHome(EnSsh* pthis) { + f32 vel = pthis->actor.velocity.y; + f32 nextY = pthis->actor.world.pos.y + 2.0f * pthis->actor.velocity.y; + + if (nextY >= pthis->actor.home.pos.y) { + return 1; + } + return 0; +} + +s32 EnSsh_IsCloseToGround(EnSsh* pthis) { + f32 vel = pthis->actor.velocity.y; + f32 nextY = pthis->actor.world.pos.y + 2.0f * pthis->actor.velocity.y; + + if ((nextY - pthis->actor.floorHeight) <= pthis->floorHeightOffset) { + return 1; + } + return 0; +} + +void EnSsh_Sway(EnSsh* pthis) { + Vec3f swayVecBase; + Vec3f swayVec; + f32 temp; + s16 swayAngle; + + if (pthis->swayTimer != 0) { + pthis->swayAngle += 0x640; + pthis->swayTimer--; + if (pthis->swayTimer == 0) { + pthis->swayAngle = 0; + } + temp = pthis->swayTimer * (1.0f / 6); + swayAngle = temp * (0x10000 / 360.0f) * Math_SinS(pthis->swayAngle); + temp = pthis->actor.world.pos.y - pthis->ceilingPos.y; + swayVecBase.x = Math_SinS(swayAngle) * temp; + swayVecBase.y = Math_CosS(swayAngle) * temp; + swayVecBase.z = 0.0f; + Matrix_Push(); + Matrix_Translate(pthis->ceilingPos.x, pthis->ceilingPos.y, pthis->ceilingPos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&swayVecBase, &swayVec); + Matrix_Pop(); + pthis->actor.shape.rot.z = -(swayAngle * 2); + pthis->actor.world.pos.x = swayVec.x; + pthis->actor.world.pos.z = swayVec.z; + } +} + +void EnSsh_CheckBodyStickHit(EnSsh* pthis, GlobalContext* globalCtx) { + ColliderInfo* info = &pthis->colCylinder[0].info; + Player* player = GET_PLAYER(globalCtx); + + if (player->unk_860 != 0) { + info->bumper.dmgFlags |= 2; + pthis->colCylinder[1].info.bumper.dmgFlags &= ~2; + pthis->colCylinder[2].info.bumper.dmgFlags &= ~2; + } else { + info->bumper.dmgFlags &= ~2; + pthis->colCylinder[1].info.bumper.dmgFlags |= 2; + pthis->colCylinder[2].info.bumper.dmgFlags |= 2; + } +} + +s32 EnSsh_CheckHitPlayer(EnSsh* pthis, GlobalContext* globalCtx) { + s32 i; + s32 hit = false; + + if ((pthis->hitCount == 0) && (pthis->spinTimer == 0)) { + return false; + } + for (i = 0; i < 3; i++) { + if (pthis->colCylinder[i + 3].base.ocFlags2 & OC2_HIT_PLAYER) { + pthis->colCylinder[i + 3].base.ocFlags2 &= ~OC2_HIT_PLAYER; + hit = true; + } + } + if (!hit) { + return false; + } + pthis->hitTimer = 30; + if (pthis->swayTimer == 0) { + pthis->spinTimer = pthis->hitTimer; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_ROLL); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_ST_ATTACK); + globalCtx->damagePlayer(globalCtx, -8); + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.yawTowardsPlayer, 6.0f); + pthis->hitCount--; + return true; +} + +s32 EnSsh_CheckHitFront(EnSsh* pthis) { + u32 acFlags; + + if (pthis->colCylinder[2].base.acFlags) {} // Needed for matching + acFlags = pthis->colCylinder[2].base.acFlags; + + if (!!(acFlags & AC_HIT) == 0) { + return 0; + } else { + pthis->colCylinder[2].base.acFlags &= ~AC_HIT; + pthis->invincibilityTimer = 8; + if ((pthis->swayTimer == 0) && (pthis->hitTimer == 0) && (pthis->stunTimer == 0)) { + pthis->swayTimer = 60; + } + return 1; + } +} + +s32 EnSsh_CheckHitBack(EnSsh* pthis, GlobalContext* globalCtx) { + ColliderCylinder* cyl = &pthis->colCylinder[0]; + s32 hit = false; + + if (cyl->base.acFlags & AC_HIT) { + cyl->base.acFlags &= ~AC_HIT; + hit = true; + } + cyl = &pthis->colCylinder[1]; + if (cyl->base.acFlags & AC_HIT) { + cyl->base.acFlags &= ~AC_HIT; + hit = true; + } + if (!hit) { + return false; + } + pthis->invincibilityTimer = 8; + if (pthis->hitCount <= 0) { + pthis->hitCount++; + } + if (pthis->stunTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_ST_DAMAGE); + } + EnSsh_SetStunned(pthis); + pthis->stateFlags |= SSH_STATE_STUNNED; + return false; +} + +s32 EnSsh_CollisionCheck(EnSsh* pthis, GlobalContext* globalCtx) { + if (pthis->stunTimer == 0) { + EnSsh_CheckHitPlayer(pthis, globalCtx); + } + if (EnSsh_CheckHitFront(pthis)) { + return false; + } else if (globalCtx->actorCtx.unk_02 != 0) { + pthis->invincibilityTimer = 8; + if (pthis->stunTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_ST_DAMAGE); + } + EnSsh_SetStunned(pthis); + pthis->stateFlags |= SSH_STATE_STUNNED; + return false; + } else { + return EnSsh_CheckHitBack(pthis, globalCtx); + // Always returns false + } +} + +void EnSsh_SetBodyCylinderAC(EnSsh* pthis, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCylinder[0]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[0].base); +} + +void EnSsh_SetLegsCylinderAC(EnSsh* pthis, GlobalContext* globalCtx) { + s16 angleTowardsLink = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)); + + if (angleTowardsLink < 90 * (0x10000 / 360)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCylinder[2]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[2].base); + } else { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCylinder[1]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[1].base); + } +} + +s32 EnSsh_SetCylinderOC(EnSsh* pthis, GlobalContext* globalCtx) { + Vec3f cyloffsets[] = { + { 40.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, + { -40.0f, 0.0f, 0.0f }, + }; + Vec3f cylPos; + s32 i; + + for (i = 0; i < 3; i++) { + cylPos = pthis->actor.world.pos; + cyloffsets[i].x *= pthis->colliderScale; + cyloffsets[i].y *= pthis->colliderScale; + cyloffsets[i].z *= pthis->colliderScale; + Matrix_Push(); + Matrix_Translate(cylPos.x, cylPos.y, cylPos.z, MTXMODE_NEW); + Matrix_RotateY((pthis->initialYaw / (f32)0x8000) * M_PI, MTXMODE_APPLY); + Matrix_MultVec3f(&cyloffsets[i], &cylPos); + Matrix_Pop(); + pthis->colCylinder[i + 3].dim.pos.x = cylPos.x; + pthis->colCylinder[i + 3].dim.pos.y = cylPos.y; + pthis->colCylinder[i + 3].dim.pos.z = cylPos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[i + 3].base); + } + return 1; +} + +void EnSsh_SetColliders(EnSsh* pthis, GlobalContext* globalCtx) { + if (pthis->actor.colChkInfo.health == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colSph.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colSph.base); + } else { + if (pthis->hitTimer == 0) { + EnSsh_SetCylinderOC(pthis, globalCtx); + } + if (DECR(pthis->invincibilityTimer) == 0) { + EnSsh_SetBodyCylinderAC(pthis, globalCtx); + EnSsh_SetLegsCylinderAC(pthis, globalCtx); + } + } +} + +void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx) { + f32 frameCount; + s32 pad; + EnSsh* pthis = (EnSsh*)thisx; + + frameCount = Animation_GetLastFrame(&object_ssh_Anim_000304); + if (pthis->actor.params == ENSSH_FATHER) { + if (gSaveContext.inventory.gsTokens >= 100) { + Actor_Kill(&pthis->actor); + return; + } + } else if (gSaveContext.inventory.gsTokens >= (pthis->actor.params * 10)) { + Actor_Kill(&pthis->actor); + return; + } + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_ssh_Skel_0052E0, NULL, pthis->jointTable, pthis->morphTable, 30); + Animation_Change(&pthis->skelAnime, &object_ssh_Anim_000304, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, 0.0f); + pthis->blureIdx = EnSsh_CreateBlureEffect(globalCtx); + EnSsh_InitColliders(pthis, globalCtx); + pthis->stateFlags = 0; + pthis->hitCount = 0; + EnSsh_CheckCeilingPos(pthis, globalCtx); + if (pthis->actor.params != ENSSH_FATHER) { + EnSsh_SetColliderScale(pthis, 0.5f, 1.0f); + } else { + EnSsh_SetColliderScale(pthis, 0.75f, 1.0f); + } + pthis->actor.gravity = 0.0f; + pthis->initialYaw = pthis->actor.world.rot.y; + EnSsh_SetupAction(pthis, EnSsh_Start); +} + +void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSsh* pthis = (EnSsh*)thisx; + s32 i; + + Effect_Delete(globalCtx, pthis->blureIdx); + for (i = 0; i < 6; i++) { + Collider_DestroyCylinder(globalCtx, &pthis->colCylinder[i]); + } + Collider_DestroyJntSph(globalCtx, &pthis->colSph); +} + +void EnSsh_Wait(EnSsh* pthis, GlobalContext* globalCtx) { + if (EnSsh_IsCloseToLink(pthis, globalCtx)) { + EnSsh_SetDropAnimation(pthis); + EnSsh_SetupAction(pthis, EnSsh_Drop); + } else { + EnSsh_Bob(pthis, globalCtx); + } +} + +void EnSsh_Talk(EnSsh* pthis, GlobalContext* globalCtx) { + EnSsh_Bob(pthis, globalCtx); + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnSsh_Idle; + } +} + +void EnSsh_Idle(EnSsh* pthis, GlobalContext* globalCtx) { + if (1) {} + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnSsh_Talk; + if (pthis->actor.params == ENSSH_FATHER) { + gSaveContext.eventChkInf[9] |= 0x40; + } + if ((pthis->actor.textId == 0x26) || (pthis->actor.textId == 0x27)) { + gSaveContext.infTable[25] |= 0x40; + } + if ((pthis->actor.textId == 0x24) || (pthis->actor.textId == 0x25)) { + gSaveContext.infTable[25] |= 0x80; + } + } else { + if ((pthis->unkTimer != 0) && (DECR(pthis->unkTimer) == 0)) { + EnSsh_SetAnimation(pthis, SSH_ANIM_WAIT); + } + if ((pthis->animTimer != 0) && (DECR(pthis->animTimer) == 0)) { + EnSsh_SetAnimation(pthis, SSH_ANIM_WAIT); + } + if (!EnSsh_IsCloseToLink(pthis, globalCtx)) { + EnSsh_SetReturnAnimation(pthis); + EnSsh_SetupAction(pthis, EnSsh_Return); + } else { + if (DECR(pthis->sfxTimer) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_LAUGH); + pthis->sfxTimer = 64; + } + EnSsh_Bob(pthis, globalCtx); + if ((pthis->unkTimer == 0) && (pthis->animTimer == 0)) { + pthis->actor.textId = Text_GetFaceReaction(globalCtx, 0xD); + if (pthis->actor.textId == 0) { + if (pthis->actor.params == ENSSH_FATHER) { + if (gSaveContext.inventory.gsTokens >= 50) { + pthis->actor.textId = 0x29; + } else if (gSaveContext.inventory.gsTokens >= 10) { + if (gSaveContext.infTable[25] & 0x80) { + pthis->actor.textId = 0x24; + } else { + pthis->actor.textId = 0x25; + } + } else { + if (gSaveContext.infTable[25] & 0x40) { + pthis->actor.textId = 0x27; + } else { + pthis->actor.textId = 0x26; + } + } + } else { + pthis->actor.textId = 0x22; + } + } + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + } +} + +void EnSsh_Land(EnSsh* pthis, GlobalContext* globalCtx) { + if ((pthis->unkTimer != 0) && (DECR(pthis->unkTimer) == 0)) { + EnSsh_SetAnimation(pthis, SSH_ANIM_WAIT); + } + if ((pthis->animTimer != 0) && (DECR(pthis->animTimer) == 0)) { + EnSsh_SetAnimation(pthis, SSH_ANIM_WAIT); + } + if ((pthis->actor.floorHeight + pthis->floorHeightOffset) <= pthis->actor.world.pos.y) { + EnSsh_SetupAction(pthis, EnSsh_Idle); + } else { + Math_SmoothStepToF(&pthis->actor.velocity.y, 2.0f, 0.6f, 1000.0f, 0.0f); + } +} + +void EnSsh_Drop(EnSsh* pthis, GlobalContext* globalCtx) { + if ((pthis->unkTimer != 0) && (DECR(pthis->unkTimer) == 0)) { + EnSsh_SetAnimation(pthis, SSH_ANIM_DROP); + } + if (!EnSsh_IsCloseToLink(pthis, globalCtx)) { + EnSsh_SetReturnAnimation(pthis); + EnSsh_SetupAction(pthis, EnSsh_Return); + } else if (EnSsh_IsCloseToGround(pthis)) { + EnSsh_SpawnShockwave(pthis, globalCtx); + EnSsh_SetLandAnimation(pthis); + EnSsh_SetupAction(pthis, EnSsh_Land); + } else if (DECR(pthis->sfxTimer) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_DOWN); + pthis->sfxTimer = 3; + } +} + +void EnSsh_Return(EnSsh* pthis, GlobalContext* globalCtx) { + f32 frameRatio = pthis->skelAnime.curFrame / (pthis->skelAnime.animLength - 1.0f); + + if (frameRatio == 1.0f) { + EnSsh_SetReturnAnimation(pthis); + } + if (EnSsh_IsCloseToLink(pthis, globalCtx)) { + EnSsh_SetDropAnimation(pthis); + EnSsh_SetupAction(pthis, EnSsh_Drop); + } else if (EnSsh_IsCloseToHome(pthis)) { + EnSsh_SetWaitAnimation(pthis); + EnSsh_SetupAction(pthis, EnSsh_Wait); + } else { + pthis->actor.velocity.y = 4.0f * frameRatio; + } +} + +void EnSsh_UpdateColliderScale(EnSsh* pthis) { + if (pthis->stateFlags & SSH_STATE_SPIN) { + if (pthis->spinTimer == 0) { + pthis->stateFlags &= ~SSH_STATE_SPIN; + if (pthis->actor.params != ENSSH_FATHER) { + EnSsh_SetColliderScale(pthis, 0.5f, 1.0f); + } else { + EnSsh_SetColliderScale(pthis, 0.75f, 1.0f); + } + } + } else { + if (pthis->spinTimer != 0) { + pthis->stateFlags |= SSH_STATE_SPIN; + if (pthis->actor.params != ENSSH_FATHER) { + EnSsh_SetColliderScale(pthis, 0.5f, 2.0f); + } else { + EnSsh_SetColliderScale(pthis, 0.75f, 2.0f); + } + } + } +} + +void EnSsh_Start(EnSsh* pthis, GlobalContext* globalCtx) { + if (!EnSsh_IsCloseToGround(pthis)) { + EnSsh_SetupAction(pthis, EnSsh_Wait); + EnSsh_Wait(pthis, globalCtx); + } else { + EnSsh_SetLandAnimation(pthis); + pthis->stateFlags |= 4; + EnSsh_SetupAction(pthis, EnSsh_Land); + EnSsh_Land(pthis, globalCtx); + } +} + +void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSsh* pthis = (EnSsh*)thisx; + + EnSsh_UpdateColliderScale(pthis); + if (EnSsh_CollisionCheck(pthis, globalCtx)) { + return; // EnSsh_CollisionCheck always returns false, so pthis never happens + } + if (pthis->stunTimer != 0) { + EnSsh_Damaged(pthis); + } else { + SkelAnime_Update(&pthis->skelAnime); + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); + } + EnSsh_UpdateYaw(pthis, globalCtx); + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + pthis->blinkState = pthis->blinkTimer; + if (pthis->blinkState >= 3) { + pthis->blinkState = 0; + } + EnSsh_SetColliders(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 0.0f); +} + +s32 EnSsh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnSsh* pthis = (EnSsh*)thisx; + + switch (limbIndex) { + case 1: + if ((pthis->spinTimer != 0) && (pthis->swayTimer == 0)) { + if (pthis->spinTimer >= 2) { + EnSsh_AddBlureVertex(pthis); + } else { + EnSsh_AddBlureSpace(pthis); + } + } + break; + case 4: + if (pthis->actor.params == ENSSH_FATHER) { + *dList = object_ssh_DL_0046C0; + } + break; + case 5: + if (pthis->actor.params == ENSSH_FATHER) { + *dList = object_ssh_DL_004080; + } + break; + case 8: + if (pthis->actor.params == ENSSH_FATHER) { + *dList = object_ssh_DL_004DE8; + } + break; + } + return false; +} + +void EnSsh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnSsh* pthis = (EnSsh*)thisx; + + Collider_UpdateSpheres(limbIndex, &pthis->colSph); +} + +void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* blinkTex[] = { + object_ssh_Tex_0007E0, + object_ssh_Tex_000C60, + object_ssh_Tex_001060, + }; + s32 pad; + EnSsh* pthis = (EnSsh*)thisx; + + EnSsh_CheckBodyStickHit(pthis, globalCtx); + EnSsh_Sway(pthis); + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ssh.c", 2333); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(blinkTex[pthis->blinkState])); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ssh.c", 2336); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnSsh_OverrideLimbDraw, + EnSsh_PostLimbDraw, &pthis->actor); +} diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c deleted file mode 100644 index 77ef02f2d..000000000 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ /dev/null @@ -1,1093 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ST_Z_EN_ST_C -#include "actor_common.h" -/* - * File: z_en_st.c - * Overlay: ovl_En_St - * Description: Skulltula (normal, big, invisible) - */ - -#include "z_en_st.h" -#include "objects/object_st/object_st.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) - -void EnSt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSt_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnSt_ReturnToCeiling(EnSt* this, GlobalContext* globalCtx); -void EnSt_MoveToGround(EnSt* this, GlobalContext* globalCtx); -void EnSt_StartOnCeilingOrGround(EnSt* this, GlobalContext* globalCtx); -void EnSt_WaitOnGround(EnSt* this, GlobalContext* globalCtx); -void EnSt_Die(EnSt* this, GlobalContext* globalCtx); -void EnSt_BounceAround(EnSt* this, GlobalContext* globalCtx); -void EnSt_FinishBouncing(EnSt* this, GlobalContext* globalCtx); - -#include "overlays/ovl_En_St/ovl_En_St.c" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -const ActorInit En_St_InitVars = { - ACTOR_EN_ST, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_ST, - sizeof(EnSt), - (ActorFunc)EnSt_Init, - (ActorFunc)EnSt_Destroy, - (ActorFunc)EnSt_Update, - (ActorFunc)EnSt_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT6, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 32, 50, -24, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit2 sColChkInit = { 2, 0, 0, 0, MASS_IMMOVABLE }; - -static ColliderCylinderInit sCylinderInit2 = { - { - COLTYPE_HIT6, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 60, -30, { 0, 0, 0 } }, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 1, { { 0, -240, 0 }, 28 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static struct_80034EC0_Entry sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, 0.0f }, - { &object_st_Anim_005B98, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, - { &object_st_Anim_000304, 4.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, - { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, - { &object_st_Anim_0055A8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, - { &object_st_Anim_000304, 8.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, - { &object_st_Anim_000304, 6.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, - { &object_st_Anim_005B98, 2.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, -}; - -void EnSt_SetupAction(EnSt* this, EnStActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -/** - * Spawns `dustCnt` dust particles in a random pattern around the Skulltula - */ -void EnSt_SpawnDust(EnSt* this, GlobalContext* globalCtx, s32 dustCnt) { - Color_RGBA8 primColor = { 170, 130, 90, 255 }; - Color_RGBA8 envColor = { 100, 60, 20, 0 }; - Vec3f dustVel = { 0.0f, 0.0f, 0.0f }; - Vec3f dustAccel = { 0.0f, 0.3f, 0.0f }; - Vec3f dustPos; - s16 yAngle; - s32 i; - - yAngle = (Rand_ZeroOne() - 0.5f) * 65536.0f; - dustPos.y = this->actor.floorHeight; - for (i = dustCnt; i >= 0; i--, yAngle += (s16)(0x10000 / dustCnt)) { - dustAccel.x = (Rand_ZeroOne() - 0.5f) * 4.0f; - dustAccel.z = (Rand_ZeroOne() - 0.5f) * 4.0f; - dustPos.x = this->actor.world.pos.x + (Math_SinS(yAngle) * 22.0f); - dustPos.z = this->actor.world.pos.z + (Math_CosS(yAngle) * 22.0f); - func_8002836C(globalCtx, &dustPos, &dustVel, &dustAccel, &primColor, &envColor, 120, 40, 10); - } -} - -void EnSt_SpawnBlastEffect(EnSt* this, GlobalContext* globalCtx) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f blastPos; - - blastPos.x = this->actor.world.pos.x; - blastPos.y = this->actor.floorHeight; - blastPos.z = this->actor.world.pos.z; - - EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &blastPos, &zeroVec, &zeroVec, 100, 220, 8); -} - -void EnSt_SpawnDeadEffect(EnSt* this, GlobalContext* globalCtx) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f firePos; - - firePos.x = this->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 60.0f); - firePos.y = (this->actor.world.pos.y + 10.0f) + ((Rand_ZeroOne() - 0.5f) * 45.0f); - firePos.z = this->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 60.0f); - EffectSsDeadDb_Spawn(globalCtx, &firePos, &zeroVec, &zeroVec, 100, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, true); -} - -s32 EnSt_CreateBlureEffect(GlobalContext* globalCtx) { - EffectBlureInit1 blureInit; - u8 p1StartColor[] = { 255, 255, 255, 75 }; - u8 p2StartColor[] = { 255, 255, 255, 75 }; - u8 p1EndColor[] = { 255, 255, 255, 0 }; - u8 p2EndColor[] = { 255, 255, 255, 0 }; - s32 i; - s32 blureIdx; - - for (i = 0; i < 4; i++) { - blureInit.p1StartColor[i] = p1StartColor[i]; - blureInit.p2StartColor[i] = p2StartColor[i]; - blureInit.p1EndColor[i] = p1EndColor[i]; - blureInit.p2EndColor[i] = p2EndColor[i]; - } - - blureInit.elemDuration = 6; - blureInit.unkFlag = 0; - blureInit.calcMode = 3; - - Effect_Add(globalCtx, &blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); - return blureIdx; -} - -/** - * Checks for the position of the ceiling above the Skulltula. - * If no ceiling is found it is set to 1000 units above the Skulltula - */ -s32 EnSt_CheckCeilingPos(EnSt* this, GlobalContext* globalCtx) { - CollisionPoly* poly; - s32 bgId; - Vec3f checkPos; - - checkPos.x = this->actor.world.pos.x; - checkPos.y = this->actor.world.pos.y + 1000.0f; - checkPos.z = this->actor.world.pos.z; - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &checkPos, &this->ceilingPos, &poly, false, - false, true, true, &bgId)) { - return false; - } - this->unusedPos = this->actor.world.pos; - this->unusedPos.y -= 100.0f; - return true; -} - -void EnSt_AddBlurVertex(EnSt* this) { - Vec3f v1 = { 834.0f, 834.0f, 0.0f }; - Vec3f v2 = { 834.0f, -584.0f, 0.0f }; - Vec3f v1Pos; - Vec3f v2Pos; - - v1.x *= this->colliderScale; - v1.y *= this->colliderScale; - v1.z *= this->colliderScale; - - v2.x *= this->colliderScale; - v2.y *= this->colliderScale; - v2.z *= this->colliderScale; - - Matrix_Push(); - Matrix_MultVec3f(&v1, &v1Pos); - Matrix_MultVec3f(&v2, &v2Pos); - Matrix_Pop(); - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &v1Pos, &v2Pos); -} - -void EnSt_AddBlurSpace(EnSt* this) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); -} - -void EnSt_SetWaitingAnimation(EnSt* this) { - func_80034EC0(&this->skelAnime, sAnimations, 3); -} - -void EnSt_SetReturnToCeilingAnimation(EnSt* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_UP); - func_80034EC0(&this->skelAnime, sAnimations, 2); -} - -void EnSt_SetLandAnimation(EnSt* this) { - this->actor.world.pos.y = this->actor.floorHeight + this->floorHeightOffset; - func_80034EC0(&this->skelAnime, sAnimations, 4); - this->sfxTimer = 0; - this->animFrames = this->skelAnime.animLength; -} - -void EnSt_SetDropAnimAndVel(EnSt* this) { - if (this->takeDamageSpinTimer == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 4); - this->animFrames = this->skelAnime.animLength; - } - this->sfxTimer = 0; - this->actor.velocity.y = -10.0f; -} - -/** - * Initalizes the Skulltula's 6 cylinders, and sphere collider. - */ -void EnSt_InitColliders(EnSt* this, GlobalContext* globalCtx) { - ColliderCylinderInit* cylinders[6] = { - &sCylinderInit, &sCylinderInit, &sCylinderInit, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, - }; - - s32 i; - s32 pad; - - for (i = 0; i < ARRAY_COUNT(cylinders); i++) { - Collider_InitCylinder(globalCtx, &this->colCylinder[i]); - Collider_SetCylinder(globalCtx, &this->colCylinder[i], &this->actor, cylinders[i]); - } - - this->colCylinder[0].info.bumper.dmgFlags = 0x0003F8F9; - this->colCylinder[1].info.bumper.dmgFlags = 0xFFC00706; - this->colCylinder[2].base.colType = COLTYPE_METAL; - this->colCylinder[2].info.bumperFlags = BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO; - this->colCylinder[2].info.elemType = ELEMTYPE_UNK2; - this->colCylinder[2].info.bumper.dmgFlags = 0xFFCC0706; - - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(2), &sColChkInit); - - Collider_InitJntSph(globalCtx, &this->colSph); - Collider_SetJntSph(globalCtx, &this->colSph, &this->actor, &sJntSphInit, this->colSphItems); -} - -void EnSt_CheckBodyStickHit(EnSt* this, GlobalContext* globalCtx) { - ColliderInfo* body = &this->colCylinder[0].info; - Player* player = GET_PLAYER(globalCtx); - - if (player->unk_860 != 0) { - body->bumper.dmgFlags |= 2; - this->colCylinder[1].info.bumper.dmgFlags &= ~2; - this->colCylinder[2].info.bumper.dmgFlags &= ~2; - } else { - body->bumper.dmgFlags &= ~2; - this->colCylinder[1].info.bumper.dmgFlags |= 2; - this->colCylinder[2].info.bumper.dmgFlags |= 2; - } -} - -void EnSt_SetBodyCylinderAC(EnSt* this, GlobalContext* globalCtx) { - Collider_UpdateCylinder(&this->actor, &this->colCylinder[0]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[0].base); -} - -void EnSt_SetLegsCylinderAC(EnSt* this, GlobalContext* globalCtx) { - s16 angleTowardsLink = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); - - if (angleTowardsLink < 0x3FFC) { - Collider_UpdateCylinder(&this->actor, &this->colCylinder[2]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[2].base); - } else { - Collider_UpdateCylinder(&this->actor, &this->colCylinder[1]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[1].base); - } -} - -s32 EnSt_SetCylinderOC(EnSt* this, GlobalContext* globalCtx) { - Vec3f cyloffsets[] = { - { 40.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f }, - { -40.0f, 0.0f, 0.0f }, - }; - Vec3f cylPos; - s32 i; - - for (i = 0; i < 3; i++) { - cylPos = this->actor.world.pos; - cyloffsets[i].x *= this->colliderScale; - cyloffsets[i].y *= this->colliderScale; - cyloffsets[i].z *= this->colliderScale; - Matrix_Push(); - Matrix_Translate(cylPos.x, cylPos.y, cylPos.z, MTXMODE_NEW); - Matrix_RotateY((this->initalYaw / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_MultVec3f(&cyloffsets[i], &cylPos); - Matrix_Pop(); - this->colCylinder[i + 3].dim.pos.x = cylPos.x; - this->colCylinder[i + 3].dim.pos.y = cylPos.y; - this->colCylinder[i + 3].dim.pos.z = cylPos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colCylinder[i + 3].base); - } - - return true; -} - -void EnSt_UpdateCylinders(EnSt* this, GlobalContext* globalCtx) { - if ((this->actor.colChkInfo.health != 0) || (this->actionFunc == EnSt_FinishBouncing)) { - if (DECR(this->gaveDamageSpinTimer) == 0) { - EnSt_SetCylinderOC(this, globalCtx); - } - - DECR(this->invulnerableTimer); - DECR(this->takeDamageSpinTimer); - - if (this->invulnerableTimer == 0 && this->takeDamageSpinTimer == 0) { - EnSt_SetBodyCylinderAC(this, globalCtx); - EnSt_SetLegsCylinderAC(this, globalCtx); - } - } -} - -s32 EnSt_CheckHitLink(EnSt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 hit; - s32 i; - - for (i = 0, hit = 0; i < 3; i++) { - if (((this->colCylinder[i + 3].base.ocFlags2 & OC2_HIT_PLAYER) != 0) == 0) { - continue; - } - this->colCylinder[i + 3].base.ocFlags2 &= ~OC2_HIT_PLAYER; - hit = true; - } - - if (!hit) { - return false; - } - - if (this->swayTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_ROLL); - } - - this->gaveDamageSpinTimer = 30; - globalCtx->damagePlayer(globalCtx, -8); - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - func_8002F71C(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); - return true; -} - -s32 EnSt_CheckHitFrontside(EnSt* this) { - u8 acFlags = this->colCylinder[2].base.acFlags; - - if (!!(acFlags & AC_HIT) == 0) { - // not hit - return false; - } else { - this->colCylinder[2].base.acFlags &= ~AC_HIT; - this->invulnerableTimer = 8; - this->playSwayFlag = 0; - this->swayTimer = 60; - return true; - } -} - -s32 EnSt_CheckHitBackside(EnSt* this, GlobalContext* globalCtx) { - ColliderCylinder* cyl = &this->colCylinder[0]; - s32 flags = 0; // ac hit flags from colliders 0 and 1 - s32 hit = false; - - if (cyl->base.acFlags & AC_HIT) { - cyl->base.acFlags &= ~AC_HIT; - hit = true; - flags |= cyl->info.acHitInfo->toucher.dmgFlags; - } - - cyl = &this->colCylinder[1]; - if (cyl->base.acFlags & AC_HIT) { - cyl->base.acFlags &= ~AC_HIT; - hit = true; - flags |= cyl->info.acHitInfo->toucher.dmgFlags; - } - - if (!hit) { - return false; - } - - this->invulnerableTimer = 8; - if (this->actor.colChkInfo.damageEffect == 1) { - if (this->stunTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->stunTimer = 120; - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, this->stunTimer); - } - return false; - } - - this->swayTimer = this->stunTimer = 0; - this->gaveDamageSpinTimer = 1; - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->takeDamageSpinTimer = this->skelAnime.animLength; - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, this->takeDamageSpinTimer); - if (Actor_ApplyDamage(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DAMAGE); - return false; - } - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~ACTOR_FLAG_0; - this->groundBounces = 3; - this->deathTimer = 20; - this->actor.gravity = -1.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DEAD); - - if (flags & 0x1F820) { - // arrow, fire arrow, ice arrow, light arrow, - // and three unknows, unused arrows? - EnSt_SetupAction(this, EnSt_Die); - this->finishDeathTimer = 8; - } else { - EnSt_SetupAction(this, EnSt_BounceAround); - } - - return true; -} - -/** - * Checks if the Skulltula's colliders have been hit, returns true if the hit has dealt damage to the Skulltula - */ -s32 EnSt_CheckColliders(EnSt* this, GlobalContext* globalCtx) { - if (EnSt_CheckHitFrontside(this)) { - // player has hit the front shield area of the Skulltula - return false; - } - - if (globalCtx->actorCtx.unk_02 != 0) { - return true; - } - - if (EnSt_CheckHitBackside(this, globalCtx)) { - // player has hit the backside of the Skulltula - return true; - } - - if (this->stunTimer == 0 && this->takeDamageSpinTimer == 0) { - // check if the Skulltula has hit link. - EnSt_CheckHitLink(this, globalCtx); - } - return false; -} - -void EnSt_SetColliderScale(EnSt* this) { - f32 scaleAmount = 1.0f; - f32 radius; - f32 height; - f32 yShift; - s32 i; - - if (this->actor.params == 1) { - scaleAmount = 1.4f; - } - - radius = this->colSph.elements[0].dim.modelSphere.radius; - radius *= scaleAmount; - this->colSph.elements[0].dim.modelSphere.radius = radius; - - for (i = 0; i < 6; i++) { - yShift = this->colCylinder[i].dim.yShift; - radius = this->colCylinder[i].dim.radius; - height = this->colCylinder[i].dim.height; - yShift *= scaleAmount; - radius *= scaleAmount; - height *= scaleAmount; - - this->colCylinder[i].dim.yShift = yShift; - this->colCylinder[i].dim.radius = radius; - this->colCylinder[i].dim.height = height; - } - Actor_SetScale(&this->actor, 0.04f * scaleAmount); - this->colliderScale = scaleAmount; - this->floorHeightOffset = 32.0f * scaleAmount; -} - -s32 EnSt_SetTeethColor(EnSt* this, s16 redTarget, s16 greenTarget, s16 blueTarget, s16 minMaxStep) { - s16 red = this->teethR; - s16 green = this->teethG; - s16 blue = this->teethB; - - minMaxStep = 255 / (s16)(0.6f * minMaxStep); - if (minMaxStep <= 0) { - minMaxStep = 1; - } - - Math_SmoothStepToS(&red, redTarget, 1, minMaxStep, minMaxStep); - Math_SmoothStepToS(&green, greenTarget, 1, minMaxStep, minMaxStep); - Math_SmoothStepToS(&blue, blueTarget, 1, minMaxStep, minMaxStep); - this->teethR = red; - this->teethG = green; - this->teethB = blue; - return 1; -} - -s32 EnSt_DecrStunTimer(EnSt* this) { - if (this->stunTimer == 0) { - return 0; - } - this->stunTimer--; //! @bug no return but v0 ends up being stunTimer before decrement - return this->stunTimer + 1; -} - -/** - * Updates the yaw of the Skulltula, used for the shaking animation right before - * turning, and the actual turning to face away from the player, and then back to - * face the player - */ -void EnSt_UpdateYaw(EnSt* this, GlobalContext* globalCtx) { - u16 yawDir = 0; - Vec3s rot; - s16 yawDiff; - s16 timer; - s16 yawTarget; - - // Shake towards the end of the stun. - if (this->stunTimer != 0) { - if (this->stunTimer < 30) { - if ((this->stunTimer % 2) != 0) { - this->actor.shape.rot.y += 0x800; - } else { - this->actor.shape.rot.y -= 0x800; - } - } - return; - } - - if (this->swayTimer == 0 && this->deathTimer == 0 && this->finishDeathTimer == 0) { - // not swaying or dying - if (this->takeDamageSpinTimer != 0 || this->gaveDamageSpinTimer != 0) { - // Skulltula is doing a spinning animation - this->actor.shape.rot.y += 0x2000; - return; - } - - if (this->actionFunc != EnSt_WaitOnGround) { - // set the timers to turn away or turn towards the player - this->rotAwayTimer = 30; - this->rotTowardsTimer = 0; - } - - if (this->rotAwayTimer != 0) { - // turn away from the player - this->rotAwayTimer--; - if (this->rotAwayTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_ROLL); - this->rotTowardsTimer = 30; - } - } else if (this->rotTowardsTimer != 0) { - // turn towards the player - this->rotTowardsTimer--; - if (this->rotTowardsTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_ROLL); - this->rotAwayTimer = 30; - } - yawDir = 0x8000; - } - - // calculate the new yaw to or away from the player. - rot = this->actor.shape.rot; - yawTarget = (this->actionFunc == EnSt_WaitOnGround ? this->actor.yawTowardsPlayer : this->initalYaw); - yawDiff = rot.y - (yawTarget ^ yawDir); - if (ABS(yawDiff) <= 0x4000) { - Math_SmoothStepToS(&rot.y, yawTarget ^ yawDir, 4, 0x2000, 1); - } else { - rot.y += 0x2000; - } - - this->actor.shape.rot = this->actor.world.rot = rot; - - // Do the shaking animation. - if (yawDir == 0 && this->rotAwayTimer < 0xA) { - timer = this->rotAwayTimer; - } else if (yawDir == 0x8000 && this->rotTowardsTimer < 0xA) { - timer = this->rotTowardsTimer; - } else { - return; - } - - if ((timer % 2) != 0) { - this->actor.shape.rot.y += 0x800; - } else { - this->actor.shape.rot.y -= 0x800; - } - } -} - -/** - * Checks to see if the Skulltula is done bouncing on the ground, - * spawns dust particles as the Skulltula hits the ground - */ -s32 EnSt_IsDoneBouncing(EnSt* this, GlobalContext* globalCtx) { - if (this->actor.velocity.y > 0.0f || this->groundBounces == 0) { - // the Skulltula is moving upwards or the groundBounces is 0 - return false; - } - - if (!(this->actor.bgCheckFlags & 1)) { - // the Skulltula is not on the ground. - return false; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - EnSt_SpawnDust(this, globalCtx, 10); - // creates an elastic bouncing effect, boucing up less for each hit on the ground. - this->actor.velocity.y = 6.0f / (4 - this->groundBounces); - this->groundBounces--; - if (this->groundBounces != 0) { - return false; - } else { - // make sure the Skulltula stays on the ground. - this->actor.velocity.y = 0.0f; - } - return true; -} - -void EnSt_Bob(EnSt* this, GlobalContext* globalCtx) { - f32 ySpeedTarget = 0.5f; - - if ((globalCtx->state.frames & 8) != 0) { - ySpeedTarget *= -1.0f; - } - Math_SmoothStepToF(&this->actor.velocity.y, ySpeedTarget, 0.4f, 1000.0f, 0.0f); -} - -s32 EnSt_IsCloseToPlayer(EnSt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 yDist; - - if (this->takeDamageSpinTimer != 0) { - // skull is spinning from damage. - return false; - } else if (this->actor.xzDistToPlayer > 160.0f) { - // player is more than 160 xz units from the Skulltula - return false; - } - - yDist = this->actor.world.pos.y - player->actor.world.pos.y; - if (yDist < 0.0f || yDist > 400.0f) { - // player is above the Skulltula or more than 400 units below - // the Skulltula - return false; - } - - if (player->actor.world.pos.y < this->actor.floorHeight) { - // player is below the Skulltula's ground position - return false; - } - return true; -} - -s32 EnSt_IsCloseToInitalPos(EnSt* this) { - f32 velY = this->actor.velocity.y; - f32 checkY = this->actor.world.pos.y + (velY * 2.0f); - - if (checkY >= this->actor.home.pos.y) { - return true; - } - return false; -} - -s32 EnSt_IsCloseToGround(EnSt* this) { - f32 velY = this->actor.velocity.y; - f32 checkY = this->actor.world.pos.y + (velY * 2.0f); - - if (checkY - this->actor.floorHeight <= this->floorHeightOffset) { - return true; - } - return false; -} - -/** - * Does the animation of the Skulltula swaying back and forth after the Skulltula - * has been hit in the front by a sword - */ -void EnSt_Sway(EnSt* this) { - Vec3f amtToTranslate; - Vec3f translatedPos; - f32 swayAmt; - s16 rotAngle; - - if (this->swayTimer != 0) { - - this->swayAngle += 0xA28; - this->swayTimer--; - - if (this->swayTimer == 0) { - this->swayAngle = 0; - } - - swayAmt = this->swayTimer * (7.0f / 15.0f); - rotAngle = Math_SinS(this->swayAngle) * (swayAmt * (65536.0f / 360.0f)); - - if (this->absPrevSwayAngle >= ABS(rotAngle) && this->playSwayFlag == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_WAVE); - this->playSwayFlag = 1; - } - - if (this->absPrevSwayAngle < ABS(rotAngle)) { - this->playSwayFlag = 0; - } - - this->absPrevSwayAngle = ABS(rotAngle); - amtToTranslate.x = Math_SinS(rotAngle) * -200.0f; - amtToTranslate.y = Math_CosS(rotAngle) * -200.0f; - amtToTranslate.z = 0.0f; - Matrix_Push(); - Matrix_Translate(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y * (M_PI / 32768.0f), MTXMODE_APPLY); - Matrix_MultVec3f(&amtToTranslate, &translatedPos); - Matrix_Pop(); - this->actor.shape.rot.z = -(rotAngle * 2); - this->actor.world.pos.x = translatedPos.x; - this->actor.world.pos.z = translatedPos.z; - } -} - -void EnSt_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSt* this = (EnSt*)thisx; - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_80034EC0(&this->skelAnime, sAnimations, 0); - this->blureIdx = EnSt_CreateBlureEffect(globalCtx); - EnSt_InitColliders(this, globalCtx); - if (thisx->params == 2) { - this->actor.flags |= ACTOR_FLAG_7; - } - if (this->actor.params == 1) { - this->actor.naviEnemyId = 0x05; - } else { - this->actor.naviEnemyId = 0x04; - } - EnSt_CheckCeilingPos(this, globalCtx); - this->actor.flags |= ACTOR_FLAG_14; - this->actor.flags |= ACTOR_FLAG_24; - EnSt_SetColliderScale(this); - this->actor.gravity = 0.0f; - this->initalYaw = this->actor.world.rot.y; - EnSt_SetupAction(this, EnSt_StartOnCeilingOrGround); -} - -void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSt* this = (EnSt*)thisx; - s32 i; - - Effect_Delete(globalCtx, this->blureIdx); - for (i = 0; i < 6; i++) { - Collider_DestroyCylinder(globalCtx, &this->colCylinder[i]); - } - Collider_DestroyJntSph(globalCtx, &this->colSph); -} - -void EnSt_WaitOnCeiling(EnSt* this, GlobalContext* globalCtx) { - if (EnSt_IsCloseToPlayer(this, globalCtx)) { - EnSt_SetDropAnimAndVel(this); - EnSt_SetupAction(this, EnSt_MoveToGround); - } else { - EnSt_Bob(this, globalCtx); - } -} - -/** - * Skulltula is waiting on the ground for the player to move away, or for - * a collider to have contact - */ -void EnSt_WaitOnGround(EnSt* this, GlobalContext* globalCtx) { - if (this->takeDamageSpinTimer != 0) { - this->takeDamageSpinTimer--; - if (this->takeDamageSpinTimer == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 3); - } - } - - if (this->animFrames != 0) { - this->animFrames--; - if (this->animFrames == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 3); - } - } - - if (!EnSt_IsCloseToPlayer(this, globalCtx)) { - // Player is no longer within range, return to ceiling. - EnSt_SetReturnToCeilingAnimation(this); - EnSt_SetupAction(this, EnSt_ReturnToCeiling); - return; - } - - if (DECR(this->sfxTimer) == 0) { - // play the "laugh" sfx every 64 frames. - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_LAUGH); - this->sfxTimer = 64; - } - - // simply bob up and down. - EnSt_Bob(this, globalCtx); -} - -void EnSt_LandOnGround(EnSt* this, GlobalContext* globalCtx) { - if (this->animFrames != 0) { - this->animFrames--; - if (this->animFrames == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 3); - } - } - - if (this->takeDamageSpinTimer != 0) { - this->takeDamageSpinTimer--; - if (this->takeDamageSpinTimer == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 3); - } - } - - this->sfxTimer++; - if (this->sfxTimer == 14) { - // play the sound effect of the Skulltula hitting the ground. - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DOWN_SET); - } - - if ((this->actor.floorHeight + this->floorHeightOffset) < this->actor.world.pos.y) { - // the Skulltula has hit the ground. - this->sfxTimer = 0; - EnSt_SetupAction(this, EnSt_WaitOnGround); - } else { - Math_SmoothStepToF(&this->actor.velocity.y, 2.0f, 0.3f, 1.0f, 0.0f); - } -} - -void EnSt_MoveToGround(EnSt* this, GlobalContext* globalCtx) { - if (this->takeDamageSpinTimer != 0) { - this->takeDamageSpinTimer--; - if (this->takeDamageSpinTimer == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 5); - } - } - - if (!EnSt_IsCloseToPlayer(this, globalCtx)) { - // the player moved out of range, return to the ceiling. - EnSt_SetReturnToCeilingAnimation(this); - EnSt_SetupAction(this, EnSt_ReturnToCeiling); - } else if (EnSt_IsCloseToGround(this)) { - // The Skulltula has become close to the ground. - EnSt_SpawnBlastEffect(this, globalCtx); - EnSt_SetLandAnimation(this); - EnSt_SetupAction(this, EnSt_LandOnGround); - } else if (DECR(this->sfxTimer) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DOWN); - this->sfxTimer = 3; - } -} - -void EnSt_ReturnToCeiling(EnSt* this, GlobalContext* globalCtx) { - f32 animPctDone = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); - - if (animPctDone == 1.0f) { - EnSt_SetReturnToCeilingAnimation(this); - } - - if (EnSt_IsCloseToPlayer(this, globalCtx)) { - // player came back into range - EnSt_SetDropAnimAndVel(this); - EnSt_SetupAction(this, EnSt_MoveToGround); - } else if (EnSt_IsCloseToInitalPos(this)) { - // the Skulltula is close to the initial postion. - EnSt_SetWaitingAnimation(this); - EnSt_SetupAction(this, EnSt_WaitOnCeiling); - } else { - // accelerate based on the current animation frame. - this->actor.velocity.y = 4.0f * animPctDone; - } -} - -/** - * The Skulltula has been killed, bounce around - */ -void EnSt_BounceAround(EnSt* this, GlobalContext* globalCtx) { - this->actor.colorFilterTimer = this->deathTimer; - func_8002D868(&this->actor); - this->actor.world.rot.x += 0x800; - this->actor.world.rot.z -= 0x800; - this->actor.shape.rot = this->actor.world.rot; - if (EnSt_IsDoneBouncing(this, globalCtx)) { - this->actor.shape.yOffset = 400.0f; - this->actor.speedXZ = 1.0f; - this->actor.gravity = -2.0f; - EnSt_SetupAction(this, EnSt_FinishBouncing); - } else { - Math_SmoothStepToF(&this->actor.shape.yOffset, 400.0f, 0.4f, 10000.0f, 0.0f); - } -} - -/** - * Finish up the bouncing animation, and rotate towards the final position - */ -void EnSt_FinishBouncing(EnSt* this, GlobalContext* globalCtx) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - - if (DECR(this->deathTimer) == 0) { - this->actor.velocity = zeroVec; - this->finishDeathTimer = 8; - EnSt_SetupAction(this, EnSt_Die); - return; - } - - if (DECR(this->setTargetYawTimer) == 0) { - this->deathYawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); - this->setTargetYawTimer = 8; - } - - Math_SmoothStepToS(&this->actor.world.rot.x, 0x3FFC, 4, 0x2710, 1); - Math_SmoothStepToS(&this->actor.world.rot.z, 0, 4, 0x2710, 1); - Math_SmoothStepToS(&this->actor.world.rot.y, this->deathYawTarget, 0xA, 0x2710, 1); - - this->actor.shape.rot = this->actor.world.rot; - - func_8002D868(&this->actor); - this->groundBounces = 2; - EnSt_IsDoneBouncing(this, globalCtx); -} - -/** - * Spawn the enemy dying effects, and drop a random item - */ -void EnSt_Die(EnSt* this, GlobalContext* globalCtx) { - if (DECR(this->finishDeathTimer) != 0) { - EnSt_SpawnDeadEffect(this, globalCtx); - } else { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0xE0); - Actor_Kill(&this->actor); - } -} - -void EnSt_StartOnCeilingOrGround(EnSt* this, GlobalContext* globalCtx) { - if (!EnSt_IsCloseToGround(this)) { - this->rotAwayTimer = 60; - EnSt_SetupAction(this, EnSt_WaitOnCeiling); - EnSt_WaitOnCeiling(this, globalCtx); - } else { - EnSt_SetLandAnimation(this); - EnSt_SetupAction(this, EnSt_LandOnGround); - EnSt_LandOnGround(this, globalCtx); - } -} - -void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSt* this = (EnSt*)thisx; - s32 pad; - Color_RGBA8 color = { 0, 0, 0, 0 }; - - if (this->actor.flags & ACTOR_FLAG_15) { - SkelAnime_Update(&this->skelAnime); - } else if (!EnSt_CheckColliders(this, globalCtx)) { - // no collision has been detected. - - if (this->stunTimer == 0) { - SkelAnime_Update(&this->skelAnime); - } - - if (this->swayTimer == 0 && this->stunTimer == 0) { - func_8002D7EC(&this->actor); - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - - if ((this->stunTimer == 0) && (this->swayTimer == 0)) { - // run the current action if the Skulltula isn't stunned - // or swaying. - this->actionFunc(this, globalCtx); - } else if (this->stunTimer != 0) { - // decrement the stun timer. - EnSt_DecrStunTimer(this); - } else { - // sway the Skulltula. - EnSt_Sway(this); - } - - EnSt_UpdateYaw(this, globalCtx); - - if (this->actionFunc == EnSt_WaitOnGround) { - if ((globalCtx->state.frames & 0x10) != 0) { - color.r = 255; - } - } - - EnSt_SetTeethColor(this, color.r, color.g, color.b, 8); - EnSt_UpdateCylinders(this, globalCtx); - Actor_SetFocus(&this->actor, 0.0f); - } -} - -s32 EnSt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dListP, Vec3f* pos, Vec3s* rot, void* thisx) { - EnSt* this = (EnSt*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_st.c", 2260); - switch (limbIndex) { - case 1: - if (this->gaveDamageSpinTimer != 0 && this->swayTimer == 0) { - if (this->gaveDamageSpinTimer >= 2) { - EnSt_AddBlurVertex(this); - } else { - EnSt_AddBlurSpace(this); - } - } - break; - case 4: - // teeth - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, this->teethR, this->teethG, this->teethB, 0); - break; - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_st.c", 2295); - return false; -} - -void EnSt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dListP, Vec3s* rot, void* thisx) { - EnSt* this = (EnSt*)thisx; - - Collider_UpdateSpheres(limbIndex, &this->colSph); -} - -void EnSt_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSt* this = (EnSt*)thisx; - - EnSt_CheckBodyStickHit(this, globalCtx); - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSt_OverrideLimbDraw, - EnSt_PostLimbDraw, this); -} diff --git a/src/overlays/actors/ovl_En_St/z_en_st.cpp b/src/overlays/actors/ovl_En_St/z_en_st.cpp new file mode 100644 index 000000000..516e1f14b --- /dev/null +++ b/src/overlays/actors/ovl_En_St/z_en_st.cpp @@ -0,0 +1,1093 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ST_Z_EN_ST_C +#include "actor_common.h" +/* + * File: z_en_st.c + * Overlay: ovl_En_St + * Description: Skulltula (normal, big, invisible) + */ + +#include "z_en_st.h" +#include "objects/object_st/object_st.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) + +void EnSt_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSt_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSt_ReturnToCeiling(EnSt* pthis, GlobalContext* globalCtx); +void EnSt_MoveToGround(EnSt* pthis, GlobalContext* globalCtx); +void EnSt_StartOnCeilingOrGround(EnSt* pthis, GlobalContext* globalCtx); +void EnSt_WaitOnGround(EnSt* pthis, GlobalContext* globalCtx); +void EnSt_Die(EnSt* pthis, GlobalContext* globalCtx); +void EnSt_BounceAround(EnSt* pthis, GlobalContext* globalCtx); +void EnSt_FinishBouncing(EnSt* pthis, GlobalContext* globalCtx); + +#include "overlays/ovl_En_St/ovl_En_St.cpp" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +ActorInit En_St_InitVars = { + ACTOR_EN_ST, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_ST, + sizeof(EnSt), + (ActorFunc)EnSt_Init, + (ActorFunc)EnSt_Destroy, + (ActorFunc)EnSt_Update, + (ActorFunc)EnSt_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 32, 50, -24, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit2 sColChkInit = { 2, 0, 0, 0, MASS_IMMOVABLE }; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 60, -30, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 1, { { 0, -240, 0 }, 28 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static struct_80034EC0_Entry sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, 0.0f }, + { &object_st_Anim_005B98, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, + { &object_st_Anim_000304, 4.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, + { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &object_st_Anim_0055A8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE_INTERP, -8.0f }, + { &object_st_Anim_000304, 8.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &object_st_Anim_000304, 6.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &object_st_Anim_005B98, 2.0f, 0.0f, -1.0f, ANIMMODE_LOOP_INTERP, -8.0f }, +}; + +void EnSt_SetupAction(EnSt* pthis, EnStActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +/** + * Spawns `dustCnt` dust particles in a random pattern around the Skulltula + */ +void EnSt_SpawnDust(EnSt* pthis, GlobalContext* globalCtx, s32 dustCnt) { + Color_RGBA8 primColor = { 170, 130, 90, 255 }; + Color_RGBA8 envColor = { 100, 60, 20, 0 }; + Vec3f dustVel = { 0.0f, 0.0f, 0.0f }; + Vec3f dustAccel = { 0.0f, 0.3f, 0.0f }; + Vec3f dustPos; + s16 yAngle; + s32 i; + + yAngle = (Rand_ZeroOne() - 0.5f) * 65536.0f; + dustPos.y = pthis->actor.floorHeight; + for (i = dustCnt; i >= 0; i--, yAngle += (s16)(0x10000 / dustCnt)) { + dustAccel.x = (Rand_ZeroOne() - 0.5f) * 4.0f; + dustAccel.z = (Rand_ZeroOne() - 0.5f) * 4.0f; + dustPos.x = pthis->actor.world.pos.x + (Math_SinS(yAngle) * 22.0f); + dustPos.z = pthis->actor.world.pos.z + (Math_CosS(yAngle) * 22.0f); + func_8002836C(globalCtx, &dustPos, &dustVel, &dustAccel, &primColor, &envColor, 120, 40, 10); + } +} + +void EnSt_SpawnBlastEffect(EnSt* pthis, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f blastPos; + + blastPos.x = pthis->actor.world.pos.x; + blastPos.y = pthis->actor.floorHeight; + blastPos.z = pthis->actor.world.pos.z; + + EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &blastPos, &zeroVec, &zeroVec, 100, 220, 8); +} + +void EnSt_SpawnDeadEffect(EnSt* pthis, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f firePos; + + firePos.x = pthis->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 60.0f); + firePos.y = (pthis->actor.world.pos.y + 10.0f) + ((Rand_ZeroOne() - 0.5f) * 45.0f); + firePos.z = pthis->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 60.0f); + EffectSsDeadDb_Spawn(globalCtx, &firePos, &zeroVec, &zeroVec, 100, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, true); +} + +s32 EnSt_CreateBlureEffect(GlobalContext* globalCtx) { + EffectBlureInit1 blureInit; + u8 p1StartColor[] = { 255, 255, 255, 75 }; + u8 p2StartColor[] = { 255, 255, 255, 75 }; + u8 p1EndColor[] = { 255, 255, 255, 0 }; + u8 p2EndColor[] = { 255, 255, 255, 0 }; + s32 i; + s32 blureIdx; + + for (i = 0; i < 4; i++) { + blureInit.p1StartColor[i] = p1StartColor[i]; + blureInit.p2StartColor[i] = p2StartColor[i]; + blureInit.p1EndColor[i] = p1EndColor[i]; + blureInit.p2EndColor[i] = p2EndColor[i]; + } + + blureInit.elemDuration = 6; + blureInit.unkFlag = 0; + blureInit.calcMode = 3; + + Effect_Add(globalCtx, &blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); + return blureIdx; +} + +/** + * Checks for the position of the ceiling above the Skulltula. + * If no ceiling is found it is set to 1000 units above the Skulltula + */ +s32 EnSt_CheckCeilingPos(EnSt* pthis, GlobalContext* globalCtx) { + CollisionPoly* poly; + s32 bgId; + Vec3f checkPos; + + checkPos.x = pthis->actor.world.pos.x; + checkPos.y = pthis->actor.world.pos.y + 1000.0f; + checkPos.z = pthis->actor.world.pos.z; + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &checkPos, &pthis->ceilingPos, &poly, false, + false, true, true, &bgId)) { + return false; + } + pthis->unusedPos = pthis->actor.world.pos; + pthis->unusedPos.y -= 100.0f; + return true; +} + +void EnSt_AddBlurVertex(EnSt* pthis) { + Vec3f v1 = { 834.0f, 834.0f, 0.0f }; + Vec3f v2 = { 834.0f, -584.0f, 0.0f }; + Vec3f v1Pos; + Vec3f v2Pos; + + v1.x *= pthis->colliderScale; + v1.y *= pthis->colliderScale; + v1.z *= pthis->colliderScale; + + v2.x *= pthis->colliderScale; + v2.y *= pthis->colliderScale; + v2.z *= pthis->colliderScale; + + Matrix_Push(); + Matrix_MultVec3f(&v1, &v1Pos); + Matrix_MultVec3f(&v2, &v2Pos); + Matrix_Pop(); + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIdx), &v1Pos, &v2Pos); +} + +void EnSt_AddBlurSpace(EnSt* pthis) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIdx)); +} + +void EnSt_SetWaitingAnimation(EnSt* pthis) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); +} + +void EnSt_SetReturnToCeilingAnimation(EnSt* pthis) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_UP); + func_80034EC0(&pthis->skelAnime, sAnimations, 2); +} + +void EnSt_SetLandAnimation(EnSt* pthis) { + pthis->actor.world.pos.y = pthis->actor.floorHeight + pthis->floorHeightOffset; + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + pthis->sfxTimer = 0; + pthis->animFrames = pthis->skelAnime.animLength; +} + +void EnSt_SetDropAnimAndVel(EnSt* pthis) { + if (pthis->takeDamageSpinTimer == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + pthis->animFrames = pthis->skelAnime.animLength; + } + pthis->sfxTimer = 0; + pthis->actor.velocity.y = -10.0f; +} + +/** + * Initalizes the Skulltula's 6 cylinders, and sphere collider. + */ +void EnSt_InitColliders(EnSt* pthis, GlobalContext* globalCtx) { + ColliderCylinderInit* cylinders[6] = { + &sCylinderInit, &sCylinderInit, &sCylinderInit, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, + }; + + s32 i; + s32 pad; + + for (i = 0; i < ARRAY_COUNT(cylinders); i++) { + Collider_InitCylinder(globalCtx, &pthis->colCylinder[i]); + Collider_SetCylinder(globalCtx, &pthis->colCylinder[i], &pthis->actor, cylinders[i]); + } + + pthis->colCylinder[0].info.bumper.dmgFlags = 0x0003F8F9; + pthis->colCylinder[1].info.bumper.dmgFlags = 0xFFC00706; + pthis->colCylinder[2].base.colType = COLTYPE_METAL; + pthis->colCylinder[2].info.bumperFlags = BUMP_ON | BUMP_HOOKABLE | BUMP_NO_AT_INFO; + pthis->colCylinder[2].info.elemType = ELEMTYPE_UNK2; + pthis->colCylinder[2].info.bumper.dmgFlags = 0xFFCC0706; + + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(2), &sColChkInit); + + Collider_InitJntSph(globalCtx, &pthis->colSph); + Collider_SetJntSph(globalCtx, &pthis->colSph, &pthis->actor, &sJntSphInit, pthis->colSphItems); +} + +void EnSt_CheckBodyStickHit(EnSt* pthis, GlobalContext* globalCtx) { + ColliderInfo* body = &pthis->colCylinder[0].info; + Player* player = GET_PLAYER(globalCtx); + + if (player->unk_860 != 0) { + body->bumper.dmgFlags |= 2; + pthis->colCylinder[1].info.bumper.dmgFlags &= ~2; + pthis->colCylinder[2].info.bumper.dmgFlags &= ~2; + } else { + body->bumper.dmgFlags &= ~2; + pthis->colCylinder[1].info.bumper.dmgFlags |= 2; + pthis->colCylinder[2].info.bumper.dmgFlags |= 2; + } +} + +void EnSt_SetBodyCylinderAC(EnSt* pthis, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCylinder[0]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[0].base); +} + +void EnSt_SetLegsCylinderAC(EnSt* pthis, GlobalContext* globalCtx) { + s16 angleTowardsLink = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)); + + if (angleTowardsLink < 0x3FFC) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCylinder[2]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[2].base); + } else { + Collider_UpdateCylinder(&pthis->actor, &pthis->colCylinder[1]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[1].base); + } +} + +s32 EnSt_SetCylinderOC(EnSt* pthis, GlobalContext* globalCtx) { + Vec3f cyloffsets[] = { + { 40.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, + { -40.0f, 0.0f, 0.0f }, + }; + Vec3f cylPos; + s32 i; + + for (i = 0; i < 3; i++) { + cylPos = pthis->actor.world.pos; + cyloffsets[i].x *= pthis->colliderScale; + cyloffsets[i].y *= pthis->colliderScale; + cyloffsets[i].z *= pthis->colliderScale; + Matrix_Push(); + Matrix_Translate(cylPos.x, cylPos.y, cylPos.z, MTXMODE_NEW); + Matrix_RotateY((pthis->initalYaw / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_MultVec3f(&cyloffsets[i], &cylPos); + Matrix_Pop(); + pthis->colCylinder[i + 3].dim.pos.x = cylPos.x; + pthis->colCylinder[i + 3].dim.pos.y = cylPos.y; + pthis->colCylinder[i + 3].dim.pos.z = cylPos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colCylinder[i + 3].base); + } + + return true; +} + +void EnSt_UpdateCylinders(EnSt* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.colChkInfo.health != 0) || (pthis->actionFunc == EnSt_FinishBouncing)) { + if (DECR(pthis->gaveDamageSpinTimer) == 0) { + EnSt_SetCylinderOC(pthis, globalCtx); + } + + DECR(pthis->invulnerableTimer); + DECR(pthis->takeDamageSpinTimer); + + if (pthis->invulnerableTimer == 0 && pthis->takeDamageSpinTimer == 0) { + EnSt_SetBodyCylinderAC(pthis, globalCtx); + EnSt_SetLegsCylinderAC(pthis, globalCtx); + } + } +} + +s32 EnSt_CheckHitLink(EnSt* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 hit; + s32 i; + + for (i = 0, hit = 0; i < 3; i++) { + if (((pthis->colCylinder[i + 3].base.ocFlags2 & OC2_HIT_PLAYER) != 0) == 0) { + continue; + } + pthis->colCylinder[i + 3].base.ocFlags2 &= ~OC2_HIT_PLAYER; + hit = true; + } + + if (!hit) { + return false; + } + + if (pthis->swayTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_ROLL); + } + + pthis->gaveDamageSpinTimer = 30; + globalCtx->damagePlayer(globalCtx, -8); + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + func_8002F71C(globalCtx, &pthis->actor, 4.0f, pthis->actor.yawTowardsPlayer, 6.0f); + return true; +} + +s32 EnSt_CheckHitFrontside(EnSt* pthis) { + u8 acFlags = pthis->colCylinder[2].base.acFlags; + + if (!!(acFlags & AC_HIT) == 0) { + // not hit + return false; + } else { + pthis->colCylinder[2].base.acFlags &= ~AC_HIT; + pthis->invulnerableTimer = 8; + pthis->playSwayFlag = 0; + pthis->swayTimer = 60; + return true; + } +} + +s32 EnSt_CheckHitBackside(EnSt* pthis, GlobalContext* globalCtx) { + ColliderCylinder* cyl = &pthis->colCylinder[0]; + s32 flags = 0; // ac hit flags from colliders 0 and 1 + s32 hit = false; + + if (cyl->base.acFlags & AC_HIT) { + cyl->base.acFlags &= ~AC_HIT; + hit = true; + flags |= cyl->info.acHitInfo->toucher.dmgFlags; + } + + cyl = &pthis->colCylinder[1]; + if (cyl->base.acFlags & AC_HIT) { + cyl->base.acFlags &= ~AC_HIT; + hit = true; + flags |= cyl->info.acHitInfo->toucher.dmgFlags; + } + + if (!hit) { + return false; + } + + pthis->invulnerableTimer = 8; + if (pthis->actor.colChkInfo.damageEffect == 1) { + if (pthis->stunTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->stunTimer = 120; + Actor_SetColorFilter(&pthis->actor, 0, 0xC8, 0, pthis->stunTimer); + } + return false; + } + + pthis->swayTimer = pthis->stunTimer = 0; + pthis->gaveDamageSpinTimer = 1; + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->takeDamageSpinTimer = pthis->skelAnime.animLength; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0, pthis->takeDamageSpinTimer); + if (Actor_ApplyDamage(&pthis->actor)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_DAMAGE); + return false; + } + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->groundBounces = 3; + pthis->deathTimer = 20; + pthis->actor.gravity = -1.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALWALL_DEAD); + + if (flags & 0x1F820) { + // arrow, fire arrow, ice arrow, light arrow, + // and three unknows, unused arrows? + EnSt_SetupAction(pthis, EnSt_Die); + pthis->finishDeathTimer = 8; + } else { + EnSt_SetupAction(pthis, EnSt_BounceAround); + } + + return true; +} + +/** + * Checks if the Skulltula's colliders have been hit, returns true if the hit has dealt damage to the Skulltula + */ +s32 EnSt_CheckColliders(EnSt* pthis, GlobalContext* globalCtx) { + if (EnSt_CheckHitFrontside(pthis)) { + // player has hit the front shield area of the Skulltula + return false; + } + + if (globalCtx->actorCtx.unk_02 != 0) { + return true; + } + + if (EnSt_CheckHitBackside(pthis, globalCtx)) { + // player has hit the backside of the Skulltula + return true; + } + + if (pthis->stunTimer == 0 && pthis->takeDamageSpinTimer == 0) { + // check if the Skulltula has hit link. + EnSt_CheckHitLink(pthis, globalCtx); + } + return false; +} + +void EnSt_SetColliderScale(EnSt* pthis) { + f32 scaleAmount = 1.0f; + f32 radius; + f32 height; + f32 yShift; + s32 i; + + if (pthis->actor.params == 1) { + scaleAmount = 1.4f; + } + + radius = pthis->colSph.elements[0].dim.modelSphere.radius; + radius *= scaleAmount; + pthis->colSph.elements[0].dim.modelSphere.radius = radius; + + for (i = 0; i < 6; i++) { + yShift = pthis->colCylinder[i].dim.yShift; + radius = pthis->colCylinder[i].dim.radius; + height = pthis->colCylinder[i].dim.height; + yShift *= scaleAmount; + radius *= scaleAmount; + height *= scaleAmount; + + pthis->colCylinder[i].dim.yShift = yShift; + pthis->colCylinder[i].dim.radius = radius; + pthis->colCylinder[i].dim.height = height; + } + Actor_SetScale(&pthis->actor, 0.04f * scaleAmount); + pthis->colliderScale = scaleAmount; + pthis->floorHeightOffset = 32.0f * scaleAmount; +} + +s32 EnSt_SetTeethColor(EnSt* pthis, s16 redTarget, s16 greenTarget, s16 blueTarget, s16 minMaxStep) { + s16 red = pthis->teethR; + s16 green = pthis->teethG; + s16 blue = pthis->teethB; + + minMaxStep = 255 / (s16)(0.6f * minMaxStep); + if (minMaxStep <= 0) { + minMaxStep = 1; + } + + Math_SmoothStepToS(&red, redTarget, 1, minMaxStep, minMaxStep); + Math_SmoothStepToS(&green, greenTarget, 1, minMaxStep, minMaxStep); + Math_SmoothStepToS(&blue, blueTarget, 1, minMaxStep, minMaxStep); + pthis->teethR = red; + pthis->teethG = green; + pthis->teethB = blue; + return 1; +} + +s32 EnSt_DecrStunTimer(EnSt* pthis) { + if (pthis->stunTimer == 0) { + return 0; + } + pthis->stunTimer--; //! @bug no return but v0 ends up being stunTimer before decrement + return pthis->stunTimer + 1; +} + +/** + * Updates the yaw of the Skulltula, used for the shaking animation right before + * turning, and the actual turning to face away from the player, and then back to + * face the player + */ +void EnSt_UpdateYaw(EnSt* pthis, GlobalContext* globalCtx) { + u16 yawDir = 0; + Vec3s rot; + s16 yawDiff; + s16 timer; + s16 yawTarget; + + // Shake towards the end of the stun. + if (pthis->stunTimer != 0) { + if (pthis->stunTimer < 30) { + if ((pthis->stunTimer % 2) != 0) { + pthis->actor.shape.rot.y += 0x800; + } else { + pthis->actor.shape.rot.y -= 0x800; + } + } + return; + } + + if (pthis->swayTimer == 0 && pthis->deathTimer == 0 && pthis->finishDeathTimer == 0) { + // not swaying or dying + if (pthis->takeDamageSpinTimer != 0 || pthis->gaveDamageSpinTimer != 0) { + // Skulltula is doing a spinning animation + pthis->actor.shape.rot.y += 0x2000; + return; + } + + if (pthis->actionFunc != EnSt_WaitOnGround) { + // set the timers to turn away or turn towards the player + pthis->rotAwayTimer = 30; + pthis->rotTowardsTimer = 0; + } + + if (pthis->rotAwayTimer != 0) { + // turn away from the player + pthis->rotAwayTimer--; + if (pthis->rotAwayTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_ROLL); + pthis->rotTowardsTimer = 30; + } + } else if (pthis->rotTowardsTimer != 0) { + // turn towards the player + pthis->rotTowardsTimer--; + if (pthis->rotTowardsTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_ROLL); + pthis->rotAwayTimer = 30; + } + yawDir = 0x8000; + } + + // calculate the new yaw to or away from the player. + rot = pthis->actor.shape.rot; + yawTarget = (pthis->actionFunc == EnSt_WaitOnGround ? pthis->actor.yawTowardsPlayer : pthis->initalYaw); + yawDiff = rot.y - (yawTarget ^ yawDir); + if (ABS(yawDiff) <= 0x4000) { + Math_SmoothStepToS(&rot.y, yawTarget ^ yawDir, 4, 0x2000, 1); + } else { + rot.y += 0x2000; + } + + pthis->actor.shape.rot = pthis->actor.world.rot = rot; + + // Do the shaking animation. + if (yawDir == 0 && pthis->rotAwayTimer < 0xA) { + timer = pthis->rotAwayTimer; + } else if (yawDir == 0x8000 && pthis->rotTowardsTimer < 0xA) { + timer = pthis->rotTowardsTimer; + } else { + return; + } + + if ((timer % 2) != 0) { + pthis->actor.shape.rot.y += 0x800; + } else { + pthis->actor.shape.rot.y -= 0x800; + } + } +} + +/** + * Checks to see if the Skulltula is done bouncing on the ground, + * spawns dust particles as the Skulltula hits the ground + */ +s32 EnSt_IsDoneBouncing(EnSt* pthis, GlobalContext* globalCtx) { + if (pthis->actor.velocity.y > 0.0f || pthis->groundBounces == 0) { + // the Skulltula is moving upwards or the groundBounces is 0 + return false; + } + + if (!(pthis->actor.bgCheckFlags & 1)) { + // the Skulltula is not on the ground. + return false; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + EnSt_SpawnDust(pthis, globalCtx, 10); + // creates an elastic bouncing effect, boucing up less for each hit on the ground. + pthis->actor.velocity.y = 6.0f / (4 - pthis->groundBounces); + pthis->groundBounces--; + if (pthis->groundBounces != 0) { + return false; + } else { + // make sure the Skulltula stays on the ground. + pthis->actor.velocity.y = 0.0f; + } + return true; +} + +void EnSt_Bob(EnSt* pthis, GlobalContext* globalCtx) { + f32 ySpeedTarget = 0.5f; + + if ((globalCtx->state.frames & 8) != 0) { + ySpeedTarget *= -1.0f; + } + Math_SmoothStepToF(&pthis->actor.velocity.y, ySpeedTarget, 0.4f, 1000.0f, 0.0f); +} + +s32 EnSt_IsCloseToPlayer(EnSt* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 yDist; + + if (pthis->takeDamageSpinTimer != 0) { + // skull is spinning from damage. + return false; + } else if (pthis->actor.xzDistToPlayer > 160.0f) { + // player is more than 160 xz units from the Skulltula + return false; + } + + yDist = pthis->actor.world.pos.y - player->actor.world.pos.y; + if (yDist < 0.0f || yDist > 400.0f) { + // player is above the Skulltula or more than 400 units below + // the Skulltula + return false; + } + + if (player->actor.world.pos.y < pthis->actor.floorHeight) { + // player is below the Skulltula's ground position + return false; + } + return true; +} + +s32 EnSt_IsCloseToInitalPos(EnSt* pthis) { + f32 velY = pthis->actor.velocity.y; + f32 checkY = pthis->actor.world.pos.y + (velY * 2.0f); + + if (checkY >= pthis->actor.home.pos.y) { + return true; + } + return false; +} + +s32 EnSt_IsCloseToGround(EnSt* pthis) { + f32 velY = pthis->actor.velocity.y; + f32 checkY = pthis->actor.world.pos.y + (velY * 2.0f); + + if (checkY - pthis->actor.floorHeight <= pthis->floorHeightOffset) { + return true; + } + return false; +} + +/** + * Does the animation of the Skulltula swaying back and forth after the Skulltula + * has been hit in the front by a sword + */ +void EnSt_Sway(EnSt* pthis) { + Vec3f amtToTranslate; + Vec3f translatedPos; + f32 swayAmt; + s16 rotAngle; + + if (pthis->swayTimer != 0) { + + pthis->swayAngle += 0xA28; + pthis->swayTimer--; + + if (pthis->swayTimer == 0) { + pthis->swayAngle = 0; + } + + swayAmt = pthis->swayTimer * (7.0f / 15.0f); + rotAngle = Math_SinS(pthis->swayAngle) * (swayAmt * (65536.0f / 360.0f)); + + if (pthis->absPrevSwayAngle >= ABS(rotAngle) && pthis->playSwayFlag == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_WAVE); + pthis->playSwayFlag = 1; + } + + if (pthis->absPrevSwayAngle < ABS(rotAngle)) { + pthis->playSwayFlag = 0; + } + + pthis->absPrevSwayAngle = ABS(rotAngle); + amtToTranslate.x = Math_SinS(rotAngle) * -200.0f; + amtToTranslate.y = Math_CosS(rotAngle) * -200.0f; + amtToTranslate.z = 0.0f; + Matrix_Push(); + Matrix_Translate(pthis->ceilingPos.x, pthis->ceilingPos.y, pthis->ceilingPos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->actor.world.rot.y * (M_PI / 32768.0f), MTXMODE_APPLY); + Matrix_MultVec3f(&amtToTranslate, &translatedPos); + Matrix_Pop(); + pthis->actor.shape.rot.z = -(rotAngle * 2); + pthis->actor.world.pos.x = translatedPos.x; + pthis->actor.world.pos.z = translatedPos.z; + } +} + +void EnSt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSt* pthis = (EnSt*)thisx; + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_st_Skel_005298, NULL, pthis->jointTable, pthis->morphTable, 30); + func_80034EC0(&pthis->skelAnime, sAnimations, 0); + pthis->blureIdx = EnSt_CreateBlureEffect(globalCtx); + EnSt_InitColliders(pthis, globalCtx); + if (thisx->params == 2) { + pthis->actor.flags |= ACTOR_FLAG_7; + } + if (pthis->actor.params == 1) { + pthis->actor.naviEnemyId = 0x05; + } else { + pthis->actor.naviEnemyId = 0x04; + } + EnSt_CheckCeilingPos(pthis, globalCtx); + pthis->actor.flags |= ACTOR_FLAG_14; + pthis->actor.flags |= ACTOR_FLAG_24; + EnSt_SetColliderScale(pthis); + pthis->actor.gravity = 0.0f; + pthis->initalYaw = pthis->actor.world.rot.y; + EnSt_SetupAction(pthis, EnSt_StartOnCeilingOrGround); +} + +void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSt* pthis = (EnSt*)thisx; + s32 i; + + Effect_Delete(globalCtx, pthis->blureIdx); + for (i = 0; i < 6; i++) { + Collider_DestroyCylinder(globalCtx, &pthis->colCylinder[i]); + } + Collider_DestroyJntSph(globalCtx, &pthis->colSph); +} + +void EnSt_WaitOnCeiling(EnSt* pthis, GlobalContext* globalCtx) { + if (EnSt_IsCloseToPlayer(pthis, globalCtx)) { + EnSt_SetDropAnimAndVel(pthis); + EnSt_SetupAction(pthis, EnSt_MoveToGround); + } else { + EnSt_Bob(pthis, globalCtx); + } +} + +/** + * Skulltula is waiting on the ground for the player to move away, or for + * a collider to have contact + */ +void EnSt_WaitOnGround(EnSt* pthis, GlobalContext* globalCtx) { + if (pthis->takeDamageSpinTimer != 0) { + pthis->takeDamageSpinTimer--; + if (pthis->takeDamageSpinTimer == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + } + } + + if (pthis->animFrames != 0) { + pthis->animFrames--; + if (pthis->animFrames == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + } + } + + if (!EnSt_IsCloseToPlayer(pthis, globalCtx)) { + // Player is no longer within range, return to ceiling. + EnSt_SetReturnToCeilingAnimation(pthis); + EnSt_SetupAction(pthis, EnSt_ReturnToCeiling); + return; + } + + if (DECR(pthis->sfxTimer) == 0) { + // play the "laugh" sfx every 64 frames. + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_LAUGH); + pthis->sfxTimer = 64; + } + + // simply bob up and down. + EnSt_Bob(pthis, globalCtx); +} + +void EnSt_LandOnGround(EnSt* pthis, GlobalContext* globalCtx) { + if (pthis->animFrames != 0) { + pthis->animFrames--; + if (pthis->animFrames == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + } + } + + if (pthis->takeDamageSpinTimer != 0) { + pthis->takeDamageSpinTimer--; + if (pthis->takeDamageSpinTimer == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + } + } + + pthis->sfxTimer++; + if (pthis->sfxTimer == 14) { + // play the sound effect of the Skulltula hitting the ground. + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_DOWN_SET); + } + + if ((pthis->actor.floorHeight + pthis->floorHeightOffset) < pthis->actor.world.pos.y) { + // the Skulltula has hit the ground. + pthis->sfxTimer = 0; + EnSt_SetupAction(pthis, EnSt_WaitOnGround); + } else { + Math_SmoothStepToF(&pthis->actor.velocity.y, 2.0f, 0.3f, 1.0f, 0.0f); + } +} + +void EnSt_MoveToGround(EnSt* pthis, GlobalContext* globalCtx) { + if (pthis->takeDamageSpinTimer != 0) { + pthis->takeDamageSpinTimer--; + if (pthis->takeDamageSpinTimer == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 5); + } + } + + if (!EnSt_IsCloseToPlayer(pthis, globalCtx)) { + // the player moved out of range, return to the ceiling. + EnSt_SetReturnToCeilingAnimation(pthis); + EnSt_SetupAction(pthis, EnSt_ReturnToCeiling); + } else if (EnSt_IsCloseToGround(pthis)) { + // The Skulltula has become close to the ground. + EnSt_SpawnBlastEffect(pthis, globalCtx); + EnSt_SetLandAnimation(pthis); + EnSt_SetupAction(pthis, EnSt_LandOnGround); + } else if (DECR(pthis->sfxTimer) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_DOWN); + pthis->sfxTimer = 3; + } +} + +void EnSt_ReturnToCeiling(EnSt* pthis, GlobalContext* globalCtx) { + f32 animPctDone = pthis->skelAnime.curFrame / (pthis->skelAnime.animLength - 1.0f); + + if (animPctDone == 1.0f) { + EnSt_SetReturnToCeilingAnimation(pthis); + } + + if (EnSt_IsCloseToPlayer(pthis, globalCtx)) { + // player came back into range + EnSt_SetDropAnimAndVel(pthis); + EnSt_SetupAction(pthis, EnSt_MoveToGround); + } else if (EnSt_IsCloseToInitalPos(pthis)) { + // the Skulltula is close to the initial postion. + EnSt_SetWaitingAnimation(pthis); + EnSt_SetupAction(pthis, EnSt_WaitOnCeiling); + } else { + // accelerate based on the current animation frame. + pthis->actor.velocity.y = 4.0f * animPctDone; + } +} + +/** + * The Skulltula has been killed, bounce around + */ +void EnSt_BounceAround(EnSt* pthis, GlobalContext* globalCtx) { + pthis->actor.colorFilterTimer = pthis->deathTimer; + func_8002D868(&pthis->actor); + pthis->actor.world.rot.x += 0x800; + pthis->actor.world.rot.z -= 0x800; + pthis->actor.shape.rot = pthis->actor.world.rot; + if (EnSt_IsDoneBouncing(pthis, globalCtx)) { + pthis->actor.shape.yOffset = 400.0f; + pthis->actor.speedXZ = 1.0f; + pthis->actor.gravity = -2.0f; + EnSt_SetupAction(pthis, EnSt_FinishBouncing); + } else { + Math_SmoothStepToF(&pthis->actor.shape.yOffset, 400.0f, 0.4f, 10000.0f, 0.0f); + } +} + +/** + * Finish up the bouncing animation, and rotate towards the final position + */ +void EnSt_FinishBouncing(EnSt* pthis, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (DECR(pthis->deathTimer) == 0) { + pthis->actor.velocity = zeroVec; + pthis->finishDeathTimer = 8; + EnSt_SetupAction(pthis, EnSt_Die); + return; + } + + if (DECR(pthis->setTargetYawTimer) == 0) { + pthis->deathYawTarget = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos); + pthis->setTargetYawTimer = 8; + } + + Math_SmoothStepToS(&pthis->actor.world.rot.x, 0x3FFC, 4, 0x2710, 1); + Math_SmoothStepToS(&pthis->actor.world.rot.z, 0, 4, 0x2710, 1); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->deathYawTarget, 0xA, 0x2710, 1); + + pthis->actor.shape.rot = pthis->actor.world.rot; + + func_8002D868(&pthis->actor); + pthis->groundBounces = 2; + EnSt_IsDoneBouncing(pthis, globalCtx); +} + +/** + * Spawn the enemy dying effects, and drop a random item + */ +void EnSt_Die(EnSt* pthis, GlobalContext* globalCtx) { + if (DECR(pthis->finishDeathTimer) != 0) { + EnSt_SpawnDeadEffect(pthis, globalCtx); + } else { + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, 0xE0); + Actor_Kill(&pthis->actor); + } +} + +void EnSt_StartOnCeilingOrGround(EnSt* pthis, GlobalContext* globalCtx) { + if (!EnSt_IsCloseToGround(pthis)) { + pthis->rotAwayTimer = 60; + EnSt_SetupAction(pthis, EnSt_WaitOnCeiling); + EnSt_WaitOnCeiling(pthis, globalCtx); + } else { + EnSt_SetLandAnimation(pthis); + EnSt_SetupAction(pthis, EnSt_LandOnGround); + EnSt_LandOnGround(pthis, globalCtx); + } +} + +void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSt* pthis = (EnSt*)thisx; + s32 pad; + Color_RGBA8 color = { 0, 0, 0, 0 }; + + if (pthis->actor.flags & ACTOR_FLAG_15) { + SkelAnime_Update(&pthis->skelAnime); + } else if (!EnSt_CheckColliders(pthis, globalCtx)) { + // no collision has been detected. + + if (pthis->stunTimer == 0) { + SkelAnime_Update(&pthis->skelAnime); + } + + if (pthis->swayTimer == 0 && pthis->stunTimer == 0) { + func_8002D7EC(&pthis->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + + if ((pthis->stunTimer == 0) && (pthis->swayTimer == 0)) { + // run the current action if the Skulltula isn't stunned + // or swaying. + pthis->actionFunc(pthis, globalCtx); + } else if (pthis->stunTimer != 0) { + // decrement the stun timer. + EnSt_DecrStunTimer(pthis); + } else { + // sway the Skulltula. + EnSt_Sway(pthis); + } + + EnSt_UpdateYaw(pthis, globalCtx); + + if (pthis->actionFunc == EnSt_WaitOnGround) { + if ((globalCtx->state.frames & 0x10) != 0) { + color.r = 255; + } + } + + EnSt_SetTeethColor(pthis, color.r, color.g, color.b, 8); + EnSt_UpdateCylinders(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 0.0f); + } +} + +s32 EnSt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dListP, Vec3f* pos, Vec3s* rot, void* thisx) { + EnSt* pthis = (EnSt*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_st.c", 2260); + switch (limbIndex) { + case 1: + if (pthis->gaveDamageSpinTimer != 0 && pthis->swayTimer == 0) { + if (pthis->gaveDamageSpinTimer >= 2) { + EnSt_AddBlurVertex(pthis); + } else { + EnSt_AddBlurSpace(pthis); + } + } + break; + case 4: + // teeth + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->teethR, pthis->teethG, pthis->teethB, 0); + break; + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_st.c", 2295); + return false; +} + +void EnSt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dListP, Vec3s* rot, void* thisx) { + EnSt* pthis = (EnSt*)thisx; + + Collider_UpdateSpheres(limbIndex, &pthis->colSph); +} + +void EnSt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSt* pthis = (EnSt*)thisx; + + EnSt_CheckBodyStickHit(pthis, globalCtx); + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnSt_OverrideLimbDraw, + EnSt_PostLimbDraw, pthis); +} diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index d6feb1106..7c116f7d7 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -6,7 +6,7 @@ struct EnSt; -typedef void (*EnStActionFunc)(struct EnSt* this, GlobalContext* globalCtx); +typedef void (*EnStActionFunc)(struct EnSt* pthis, GlobalContext* globalCtx); typedef struct EnSt { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c deleted file mode 100644 index 0de072d67..000000000 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ /dev/null @@ -1,424 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_STH_Z_EN_STH_C -#include "actor_common.h" -/* - * File: z_en_sth.c - * Overlay: ovl_En_Sth - * Description: Uncursed House of Skulltula People - */ - -#include "vt.h" -#include "z_en_sth.h" -#include "objects/object_ahg/object_ahg.h" -#include "objects/object_boj/object_boj.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnSth_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSth_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSth_Update2(Actor* thisx, GlobalContext* globalCtx); -void EnSth_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnSth_WaitForObjectLoaded(EnSth* this, GlobalContext* globalCtx); -void EnSth_ParentRewardObtainedWait(EnSth* this, GlobalContext* globalCtx); -void EnSth_RewardUnobtainedWait(EnSth* this, GlobalContext* globalCtx); -void EnSth_ChildRewardObtainedWait(EnSth* this, GlobalContext* globalCtx); - -const ActorInit En_Sth_InitVars = { - ACTOR_EN_STH, - ACTORCAT_NPC, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnSth), - (ActorFunc)EnSth_Init, - (ActorFunc)EnSth_Destroy, - (ActorFunc)EnSth_Update, - NULL, -}; - -#include "overlays/ovl_En_Sth/ovl_En_Sth.c" - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -static s16 sObjectIds[6] = { - OBJECT_AHG, OBJECT_BOJ, OBJECT_BOJ, OBJECT_BOJ, OBJECT_BOJ, OBJECT_BOJ, -}; - -static FlexSkeletonHeader* sSkeletons[6] = { - &object_ahg_Skel_0000F0, - &object_boj_Skel_0000F0, - &object_boj_Skel_0000F0, - &object_boj_Skel_0000F0, - &object_boj_Skel_0000F0, - &object_boj_Skel_0000F0, -}; - -static AnimationHeader* sAnimations[6] = { - &sParentDanceAnim, &sChildDanceAnim, &sChildDanceAnim, &sChildDanceAnim, &sChildDanceAnim, &sChildDanceAnim, -}; - -static EnSthActionFunc sRewardObtainedWaitActions[6] = { - EnSth_ParentRewardObtainedWait, EnSth_ChildRewardObtainedWait, EnSth_ChildRewardObtainedWait, - EnSth_ChildRewardObtainedWait, EnSth_ChildRewardObtainedWait, EnSth_ChildRewardObtainedWait, -}; - -static u16 sEventFlags[6] = { - 0x0000, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, -}; - -static s16 sGetItemIds[6] = { - GI_RUPEE_GOLD, GI_WALLET_ADULT, GI_STONE_OF_AGONY, GI_WALLET_GIANT, GI_BOMBCHUS_10, GI_HEART_PIECE, -}; - -static Vec3f D_80B0B49C = { 700.0f, 400.0f, 0.0f }; - -static Color_RGB8 sTunicColors[6] = { - { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 80 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, -}; - -void EnSth_SetupAction(EnSth* this, EnSthActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSth* this = (EnSth*)thisx; - - s16 objectId; - s32 params = this->actor.params; - s32 objectBankIdx; - - osSyncPrintf(VT_FGCOL(BLUE) "金スタル屋 no = %d\n" VT_RST, params); // "Gold Skulltula Shop" - if (this->actor.params == 0) { - if (gSaveContext.inventory.gsTokens < 100) { - Actor_Kill(&this->actor); - // "Gold Skulltula Shop I still can't be a human" - osSyncPrintf("金スタル屋 まだ 人間に戻れない \n"); - return; - } - } else if (gSaveContext.inventory.gsTokens < (this->actor.params * 10)) { - Actor_Kill(&this->actor); - // "Gold Skulltula Shop I still can't be a human" - osSyncPrintf(VT_FGCOL(BLUE) "金スタル屋 まだ 人間に戻れない \n" VT_RST); - return; - } - - objectId = sObjectIds[params]; - if (objectId != 1) { - objectBankIdx = Object_GetIndex(&globalCtx->objectCtx, objectId); - } else { - objectBankIdx = 0; - } - - osSyncPrintf("bank_ID = %d\n", objectBankIdx); - if (objectBankIdx < 0) { - ASSERT(0, "0", "../z_en_sth.c", 1564); - } - this->objectBankIdx = objectBankIdx; - this->drawFunc = EnSth_Draw; - Actor_SetScale(&this->actor, 0.01f); - EnSth_SetupAction(this, EnSth_WaitForObjectLoaded); - this->actor.draw = NULL; - this->unk_2B2 = 0; - this->actor.targetMode = 6; -} - -void EnSth_SetupShapeColliderUpdate2AndDraw(EnSth* this, GlobalContext* globalCtx) { - s32 pad; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.update = EnSth_Update2; - this->actor.draw = this->drawFunc; -} - -void EnSth_SetupAfterObjectLoaded(EnSth* this, GlobalContext* globalCtx) { - s32 pad; - s16* params; - - EnSth_SetupShapeColliderUpdate2AndDraw(this, globalCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[this->objectBankIdx].vromStart); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, sSkeletons[this->actor.params], NULL, this->jointTable, - this->morphTable, 16); - Animation_PlayLoop(&this->skelAnime, sAnimations[this->actor.params]); - - this->eventFlag = sEventFlags[this->actor.params]; - params = &this->actor.params; - if (gSaveContext.eventChkInf[13] & this->eventFlag) { - EnSth_SetupAction(this, sRewardObtainedWaitActions[*params]); - } else { - EnSth_SetupAction(this, EnSth_RewardUnobtainedWait); - } -} - -void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSth* this = (EnSth*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnSth_WaitForObjectLoaded(EnSth* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objectBankIdx)) { - this->actor.objBankIndex = this->objectBankIdx; - this->actionFunc = EnSth_SetupAfterObjectLoaded; - } -} - -void EnSth_FacePlayer(EnSth* this, GlobalContext* globalCtx) { - s32 pad; - s16 diffRot = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(diffRot) <= 0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 0xFA0, 0x64); - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_2AC, this->actor.focus.pos); - } else { - if (diffRot < 0) { - Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 0x1838, 0x100); - } else { - Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 0x1838, 0x100); - } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xC, 0x3E8, 0x64); - this->actor.world.rot.y = this->actor.shape.rot.y; - } -} - -void EnSth_LookAtPlayer(EnSth* this, GlobalContext* globalCtx) { - s16 diffRot = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(diffRot) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { - func_80038290(globalCtx, &this->actor, &this->headRot, &this->unk_2AC, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_2AC.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_2AC.y, 0, 6, 0x1838, 0x64); - } -} - -void EnSth_RewardObtainedTalk(EnSth* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - if (this->actor.params == 0) { - EnSth_SetupAction(this, EnSth_ParentRewardObtainedWait); - } else { - EnSth_SetupAction(this, EnSth_ChildRewardObtainedWait); - } - } - EnSth_FacePlayer(this, globalCtx); -} - -void EnSth_ParentRewardObtainedWait(EnSth* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - EnSth_SetupAction(this, EnSth_RewardObtainedTalk); - } else { - this->actor.textId = 0x23; - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - EnSth_LookAtPlayer(this, globalCtx); -} - -void EnSth_GivePlayerItem(EnSth* this, GlobalContext* globalCtx) { - u16 getItemId = sGetItemIds[this->actor.params]; - - switch (this->actor.params) { - case 1: - case 3: - switch (CUR_UPG_VALUE(UPG_WALLET)) { - case 0: - getItemId = GI_WALLET_ADULT; - break; - - case 1: - getItemId = GI_WALLET_GIANT; - break; - } - break; - } - - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); -} - -void EnSth_GiveReward(EnSth* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - EnSth_SetupAction(this, EnSth_RewardObtainedTalk); - gSaveContext.eventChkInf[13] |= this->eventFlag; - } else { - EnSth_GivePlayerItem(this, globalCtx); - } - EnSth_FacePlayer(this, globalCtx); -} - -void EnSth_RewardUnobtainedTalk(EnSth* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - EnSth_SetupAction(this, EnSth_GiveReward); - EnSth_GivePlayerItem(this, globalCtx); - } - EnSth_FacePlayer(this, globalCtx); -} - -void EnSth_RewardUnobtainedWait(EnSth* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - EnSth_SetupAction(this, EnSth_RewardUnobtainedTalk); - } else { - if (this->actor.params == 0) { - this->actor.textId = 0x28; - } else { - this->actor.textId = 0x21; - } - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - EnSth_LookAtPlayer(this, globalCtx); -} - -void EnSth_ChildRewardObtainedWait(EnSth* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - EnSth_SetupAction(this, EnSth_RewardObtainedTalk); - } else { - if (gSaveContext.inventory.gsTokens < 50) { - this->actor.textId = 0x20; - } else { - this->actor.textId = 0x1F; - } - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - EnSth_LookAtPlayer(this, globalCtx); -} - -void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSth* this = (EnSth*)thisx; - - this->actionFunc(this, globalCtx); -} - -void EnSth_Update2(Actor* thisx, GlobalContext* globalCtx) { - EnSth* this = (EnSth*)thisx; - s32 pad; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (SkelAnime_Update(&this->skelAnime)) { - this->skelAnime.curFrame = 0.0f; - } - this->actionFunc(this, globalCtx); - - // Likely an unused blink timer and eye index - if (DECR(this->unk_2B6) == 0) { - this->unk_2B6 = Rand_S16Offset(0x3C, 0x3C); - } - this->unk_2B4 = this->unk_2B6; - if (this->unk_2B4 >= 3) { - this->unk_2B4 = 0; - } -} - -s32 EnSth_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnSth* this = (EnSth*)thisx; - - s32 temp_v1; - - if (limbIndex == 15) { - rot->x += this->headRot.y; - rot->z += this->headRot.x; - *dList = D_80B0A050; - } - - if (this->unk_2B2 & 2) { - this->unk_2B2 &= ~2; - return 0; - } - - if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { - temp_v1 = limbIndex * 0x32; - rot->y += (Math_SinS(globalCtx->state.frames * (temp_v1 + 0x814)) * 200.0f); - rot->z += (Math_CosS(globalCtx->state.frames * (temp_v1 + 0x940)) * 200.0f); - } - return 0; -} - -void EnSth_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnSth* this = (EnSth*)thisx; - - if (limbIndex == 15) { - Matrix_MultVec3f(&D_80B0B49C, &this->actor.focus.pos); - if (this->actor.params != 0) { // Children - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2079); - - gSPDisplayList(POLY_OPA_DISP++, D_80B0A3C0); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2081); - } - } -} - -Gfx* EnSth_AllocColorDList(GraphicsContext* globalCtx, u8 envR, u8 envG, u8 envB, u8 envA) { - Gfx* dList; - - dList = Graph_Alloc(globalCtx, 2 * sizeof(Gfx)); - gDPSetEnvColor(dList, envR, envG, envB, envA); - gSPEndDisplayList(dList + 1); - - return dList; -} - -void EnSth_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSth* this = (EnSth*)thisx; - Color_RGB8* envColor1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2133); - - gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[this->objectBankIdx].vromStart); - func_800943C8(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, - EnSth_AllocColorDList(globalCtx->state.gfxCtx, sTunicColors[this->actor.params].r, - sTunicColors[this->actor.params].g, sTunicColors[this->actor.params].b, 255)); - - if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x09, EnSth_AllocColorDList(globalCtx->state.gfxCtx, 190, 110, 0, 255)); - } else { - gSPSegment(POLY_OPA_DISP++, 0x09, EnSth_AllocColorDList(globalCtx->state.gfxCtx, 90, 110, 130, 255)); - } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSth_OverrideLimbDraw, EnSth_PostLimbDraw, &this->actor); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2176); -} diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.cpp b/src/overlays/actors/ovl_En_Sth/z_en_sth.cpp new file mode 100644 index 000000000..a5d04a3df --- /dev/null +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.cpp @@ -0,0 +1,424 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_STH_Z_EN_STH_C +#include "actor_common.h" +/* + * File: z_en_sth.c + * Overlay: ovl_En_Sth + * Description: Uncursed House of Skulltula People + */ + +#include "vt.h" +#include "z_en_sth.h" +#include "objects/object_ahg/object_ahg.h" +#include "objects/object_boj/object_boj.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnSth_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSth_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSth_Update2(Actor* thisx, GlobalContext* globalCtx); +void EnSth_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSth_WaitForObjectLoaded(EnSth* pthis, GlobalContext* globalCtx); +void EnSth_ParentRewardObtainedWait(EnSth* pthis, GlobalContext* globalCtx); +void EnSth_RewardUnobtainedWait(EnSth* pthis, GlobalContext* globalCtx); +void EnSth_ChildRewardObtainedWait(EnSth* pthis, GlobalContext* globalCtx); + +ActorInit En_Sth_InitVars = { + ACTOR_EN_STH, + ACTORCAT_NPC, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnSth), + (ActorFunc)EnSth_Init, + (ActorFunc)EnSth_Destroy, + (ActorFunc)EnSth_Update, + NULL, +}; + +#include "overlays/ovl_En_Sth/ovl_En_Sth.cpp" + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +static s16 sObjectIds[6] = { + OBJECT_AHG, OBJECT_BOJ, OBJECT_BOJ, OBJECT_BOJ, OBJECT_BOJ, OBJECT_BOJ, +}; + +static FlexSkeletonHeader* sSkeletons[6] = { + &object_ahg_Skel_0000F0, + &object_boj_Skel_0000F0, + &object_boj_Skel_0000F0, + &object_boj_Skel_0000F0, + &object_boj_Skel_0000F0, + &object_boj_Skel_0000F0, +}; + +static AnimationHeader* sAnimations[6] = { + &sParentDanceAnim, &sChildDanceAnim, &sChildDanceAnim, &sChildDanceAnim, &sChildDanceAnim, &sChildDanceAnim, +}; + +static EnSthActionFunc sRewardObtainedWaitActions[6] = { + EnSth_ParentRewardObtainedWait, EnSth_ChildRewardObtainedWait, EnSth_ChildRewardObtainedWait, + EnSth_ChildRewardObtainedWait, EnSth_ChildRewardObtainedWait, EnSth_ChildRewardObtainedWait, +}; + +static u16 sEventFlags[6] = { + 0x0000, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, +}; + +static s16 sGetItemIds[6] = { + GI_RUPEE_GOLD, GI_WALLET_ADULT, GI_STONE_OF_AGONY, GI_WALLET_GIANT, GI_BOMBCHUS_10, GI_HEART_PIECE, +}; + +static Vec3f D_80B0B49C = { 700.0f, 400.0f, 0.0f }; + +static Color_RGB8 sTunicColors[6] = { + { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 80 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, +}; + +void EnSth_SetupAction(EnSth* pthis, EnSthActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSth* pthis = (EnSth*)thisx; + + s16 objectId; + s32 params = pthis->actor.params; + s32 objectBankIdx; + + osSyncPrintf(VT_FGCOL(BLUE) "金スタル屋 no = %d\n" VT_RST, params); // "Gold Skulltula Shop" + if (pthis->actor.params == 0) { + if (gSaveContext.inventory.gsTokens < 100) { + Actor_Kill(&pthis->actor); + // "Gold Skulltula Shop I still can't be a human" + osSyncPrintf("金スタル屋 まだ 人間に戻れない \n"); + return; + } + } else if (gSaveContext.inventory.gsTokens < (pthis->actor.params * 10)) { + Actor_Kill(&pthis->actor); + // "Gold Skulltula Shop I still can't be a human" + osSyncPrintf(VT_FGCOL(BLUE) "金スタル屋 まだ 人間に戻れない \n" VT_RST); + return; + } + + objectId = sObjectIds[params]; + if (objectId != 1) { + objectBankIdx = Object_GetIndex(&globalCtx->objectCtx, objectId); + } else { + objectBankIdx = 0; + } + + osSyncPrintf("bank_ID = %d\n", objectBankIdx); + if (objectBankIdx < 0) { + ASSERT(0, "0", "../z_en_sth.c", 1564); + } + pthis->objectBankIdx = objectBankIdx; + pthis->drawFunc = EnSth_Draw; + Actor_SetScale(&pthis->actor, 0.01f); + EnSth_SetupAction(pthis, EnSth_WaitForObjectLoaded); + pthis->actor.draw = NULL; + pthis->unk_2B2 = 0; + pthis->actor.targetMode = 6; +} + +void EnSth_SetupShapeColliderUpdate2AndDraw(EnSth* pthis, GlobalContext* globalCtx) { + s32 pad; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.update = EnSth_Update2; + pthis->actor.draw = pthis->drawFunc; +} + +void EnSth_SetupAfterObjectLoaded(EnSth* pthis, GlobalContext* globalCtx) { + s32 pad; + s16* params; + + EnSth_SetupShapeColliderUpdate2AndDraw(pthis, globalCtx); + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[pthis->objectBankIdx].vromStart.get()); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, sSkeletons[pthis->actor.params], NULL, pthis->jointTable, + pthis->morphTable, 16); + Animation_PlayLoop(&pthis->skelAnime, sAnimations[pthis->actor.params]); + + pthis->eventFlag = sEventFlags[pthis->actor.params]; + params = &pthis->actor.params; + if (gSaveContext.eventChkInf[13] & pthis->eventFlag) { + EnSth_SetupAction(pthis, sRewardObtainedWaitActions[*params]); + } else { + EnSth_SetupAction(pthis, EnSth_RewardUnobtainedWait); + } +} + +void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSth* pthis = (EnSth*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnSth_WaitForObjectLoaded(EnSth* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objectBankIdx)) { + pthis->actor.objBankIndex = pthis->objectBankIdx; + pthis->actionFunc = EnSth_SetupAfterObjectLoaded; + } +} + +void EnSth_FacePlayer(EnSth* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 diffRot = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(diffRot) <= 0x4000) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 6, 0xFA0, 0x64); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_2AC, pthis->actor.focus.pos); + } else { + if (diffRot < 0) { + Math_SmoothStepToS(&pthis->headRot.y, -0x2000, 6, 0x1838, 0x100); + } else { + Math_SmoothStepToS(&pthis->headRot.y, 0x2000, 6, 0x1838, 0x100); + } + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 0xC, 0x3E8, 0x64); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } +} + +void EnSth_LookAtPlayer(EnSth* pthis, GlobalContext* globalCtx) { + s16 diffRot = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(diffRot) <= 0x4300) && (pthis->actor.xzDistToPlayer < 100.0f)) { + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->unk_2AC, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&pthis->headRot.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&pthis->unk_2AC.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&pthis->unk_2AC.y, 0, 6, 0x1838, 0x64); + } +} + +void EnSth_RewardObtainedTalk(EnSth* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + if (pthis->actor.params == 0) { + EnSth_SetupAction(pthis, EnSth_ParentRewardObtainedWait); + } else { + EnSth_SetupAction(pthis, EnSth_ChildRewardObtainedWait); + } + } + EnSth_FacePlayer(pthis, globalCtx); +} + +void EnSth_ParentRewardObtainedWait(EnSth* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + EnSth_SetupAction(pthis, EnSth_RewardObtainedTalk); + } else { + pthis->actor.textId = 0x23; + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + EnSth_LookAtPlayer(pthis, globalCtx); +} + +void EnSth_GivePlayerItem(EnSth* pthis, GlobalContext* globalCtx) { + u16 getItemId = sGetItemIds[pthis->actor.params]; + + switch (pthis->actor.params) { + case 1: + case 3: + switch (CUR_UPG_VALUE(UPG_WALLET)) { + case 0: + getItemId = GI_WALLET_ADULT; + break; + + case 1: + getItemId = GI_WALLET_GIANT; + break; + } + break; + } + + func_8002F434(&pthis->actor, globalCtx, getItemId, 10000.0f, 50.0f); +} + +void EnSth_GiveReward(EnSth* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + EnSth_SetupAction(pthis, EnSth_RewardObtainedTalk); + gSaveContext.eventChkInf[13] |= pthis->eventFlag; + } else { + EnSth_GivePlayerItem(pthis, globalCtx); + } + EnSth_FacePlayer(pthis, globalCtx); +} + +void EnSth_RewardUnobtainedTalk(EnSth* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + EnSth_SetupAction(pthis, EnSth_GiveReward); + EnSth_GivePlayerItem(pthis, globalCtx); + } + EnSth_FacePlayer(pthis, globalCtx); +} + +void EnSth_RewardUnobtainedWait(EnSth* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + EnSth_SetupAction(pthis, EnSth_RewardUnobtainedTalk); + } else { + if (pthis->actor.params == 0) { + pthis->actor.textId = 0x28; + } else { + pthis->actor.textId = 0x21; + } + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + EnSth_LookAtPlayer(pthis, globalCtx); +} + +void EnSth_ChildRewardObtainedWait(EnSth* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + EnSth_SetupAction(pthis, EnSth_RewardObtainedTalk); + } else { + if (gSaveContext.inventory.gsTokens < 50) { + pthis->actor.textId = 0x20; + } else { + pthis->actor.textId = 0x1F; + } + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + EnSth_LookAtPlayer(pthis, globalCtx); +} + +void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSth* pthis = (EnSth*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void EnSth_Update2(Actor* thisx, GlobalContext* globalCtx) { + EnSth* pthis = (EnSth*)thisx; + s32 pad; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->skelAnime.curFrame = 0.0f; + } + pthis->actionFunc(pthis, globalCtx); + + // Likely an unused blink timer and eye index + if (DECR(pthis->unk_2B6) == 0) { + pthis->unk_2B6 = Rand_S16Offset(0x3C, 0x3C); + } + pthis->unk_2B4 = pthis->unk_2B6; + if (pthis->unk_2B4 >= 3) { + pthis->unk_2B4 = 0; + } +} + +s32 EnSth_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnSth* pthis = (EnSth*)thisx; + + s32 temp_v1; + + if (limbIndex == 15) { + rot->x += pthis->headRot.y; + rot->z += pthis->headRot.x; + *dList = D_80B0A050; + } + + if (pthis->unk_2B2 & 2) { + pthis->unk_2B2 &= ~2; + return 0; + } + + if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { + temp_v1 = limbIndex * 0x32; + rot->y += (Math_SinS(globalCtx->state.frames * (temp_v1 + 0x814)) * 200.0f); + rot->z += (Math_CosS(globalCtx->state.frames * (temp_v1 + 0x940)) * 200.0f); + } + return 0; +} + +void EnSth_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnSth* pthis = (EnSth*)thisx; + + if (limbIndex == 15) { + Matrix_MultVec3f(&D_80B0B49C, &pthis->actor.focus.pos); + if (pthis->actor.params != 0) { // Children + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2079); + + gSPDisplayList(POLY_OPA_DISP++, D_80B0A3C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2081); + } + } +} + +Gfx* EnSth_AllocColorDList(GraphicsContext* globalCtx, u8 envR, u8 envG, u8 envB, u8 envA) { + Gfx* dList; + + dList = (Gfx*)Graph_Alloc(globalCtx, 2 * sizeof(Gfx)); + gDPSetEnvColor(dList, envR, envG, envB, envA); + gSPEndDisplayList(dList + 1); + + return dList; +} + +void EnSth_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSth* pthis = (EnSth*)thisx; + Color_RGB8* envColor1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2133); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(gObjectTable[pthis->objectBankIdx].vromStart.get()); + func_800943C8(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + EnSth_AllocColorDList(globalCtx->state.gfxCtx, sTunicColors[pthis->actor.params].r, + sTunicColors[pthis->actor.params].g, sTunicColors[pthis->actor.params].b, 255)); + + if (pthis->actor.params == 0) { + gSPSegment(POLY_OPA_DISP++, 0x09, EnSth_AllocColorDList(globalCtx->state.gfxCtx, 190, 110, 0, 255)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x09, EnSth_AllocColorDList(globalCtx->state.gfxCtx, 90, 110, 130, 255)); + } + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnSth_OverrideLimbDraw, EnSth_PostLimbDraw, &pthis->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sth.c", 2176); +} diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.cpp similarity index 75% rename from src/overlays/actors/ovl_En_Stream/z_en_stream.c rename to src/overlays/actors/ovl_En_Stream/z_en_stream.cpp index 5997b0667..1b79c3aba 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.cpp @@ -20,9 +20,9 @@ void EnStream_Init(Actor* thisx, GlobalContext* globalCtx); void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnStream_Update(Actor* thisx, GlobalContext* globalCtx); void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx); +void EnStream_WaitForPlayer(EnStream* pthis, GlobalContext* globalCtx); -const ActorInit En_Stream_InitVars = { +ActorInit En_Stream_InitVars = { ACTOR_EN_STREAM, ACTORCAT_BG, FLAGS, @@ -38,19 +38,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), }; -void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnStream_SetupAction(EnStream* pthis, EnStreamActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnStream_Init(Actor* thisx, GlobalContext* globalCtx) { - EnStream* this = (EnStream*)thisx; + EnStream* pthis = (EnStream*)thisx; - this->unk_150 = thisx->params & 0xFF; + pthis->unk_150 = thisx->params & 0xFF; Actor_ProcessInitChain(thisx, sInitChain); - if ((this->unk_150 != 0) && (this->unk_150 == 1)) { + if ((pthis->unk_150 != 0) && (pthis->unk_150 == 1)) { thisx->scale.y = 0.01f; } - EnStream_SetupAction(this, EnStream_WaitForPlayer); + EnStream_SetupAction(pthis, EnStream_WaitForPlayer); } void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -86,7 +86,7 @@ s32 func_80B0B81C(Vec3f* vortexPosRot, Vec3f* playerPosRot, Vec3f* posDifference return ret; } -void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { +void EnStream_SuckPlayer(EnStream* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad48; Vec3f posDifference; @@ -95,16 +95,16 @@ void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { s32 pad30; s32 pad2C; - if (func_80B0B81C(&this->actor.world.pos, &player->actor.world.pos, &posDifference, this->actor.scale.y) != 0) { + if (func_80B0B81C(&pthis->actor.world.pos, &player->actor.world.pos, &posDifference, pthis->actor.scale.y) != 0) { xzDist = sqrtf(SQ(posDifference.x) + SQ(posDifference.z)); - yDistWithOffset = player->actor.world.pos.y - (this->actor.world.pos.y - 90.0f); + yDistWithOffset = player->actor.world.pos.y - (pthis->actor.world.pos.y - 90.0f); player->windDirection = Math_FAtan2F(-posDifference.x, -posDifference.z) * (0x8000 / M_PI); if (xzDist > 3.0f) { Math_SmoothStepToF(&player->windSpeed, 3.0f, 0.5f, xzDist, 0.0f); } else { player->windSpeed = 0.0f; - Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 0.5f, 3.0f, 0.0f); - Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 0.5f, 3.0f, 0.0f); + Math_SmoothStepToF(&player->actor.world.pos.x, pthis->actor.world.pos.x, 0.5f, 3.0f, 0.0f); + Math_SmoothStepToF(&player->actor.world.pos.z, pthis->actor.world.pos.z, 0.5f, 3.0f, 0.0f); } if (yDistWithOffset > 0.0f) { Math_SmoothStepToF(&player->actor.velocity.y, -3.0f, 0.7f, yDistWithOffset, 0.0f); @@ -113,24 +113,24 @@ void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { } } } else { - EnStream_SetupAction(this, EnStream_WaitForPlayer); + EnStream_SetupAction(pthis, EnStream_WaitForPlayer); } } -void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx) { +void EnStream_WaitForPlayer(EnStream* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 pad; Vec3f temp; - if (func_80B0B81C(&this->actor.world.pos, &player->actor.world.pos, &temp, this->actor.scale.y) != 0) { - EnStream_SetupAction(this, EnStream_SuckPlayer); + if (func_80B0B81C(&pthis->actor.world.pos, &player->actor.world.pos, &temp, pthis->actor.scale.y) != 0) { + EnStream_SetupAction(pthis, EnStream_SuckPlayer); } } void EnStream_Update(Actor* thisx, GlobalContext* globalCtx) { - EnStream* this = (EnStream*)thisx; + EnStream* pthis = (EnStream*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); func_8002F948(thisx, NA_SE_EV_WHIRLPOOL - SFX_FLAG); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c deleted file mode 100644 index 0a182ca3a..000000000 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ /dev/null @@ -1,1029 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SW_Z_EN_SW_C -#include "actor_common.h" -#include "z_en_sw.h" -#include "objects/object_st/object_st.h" -#include "def/code_8006BA00.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_btltbls.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnSw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 func_80B0DFFC(EnSw* this, GlobalContext* globalCtx); -void func_80B0D364(EnSw* this, GlobalContext* globalCtx); -void func_80B0E5E0(EnSw* this, GlobalContext* globalCtx); -void func_80B0D590(EnSw* this, GlobalContext* globalCtx); -void func_80B0E90C(EnSw* this, GlobalContext* globalCtx); -void func_80B0E9BC(EnSw* this, GlobalContext* globalCtx); -void func_80B0E728(EnSw* this, GlobalContext* globalCtx); -void func_80B0DC7C(EnSw* this, GlobalContext* globalCtx); -s32 func_80B0C0CC(EnSw* this, GlobalContext* globalCtx, s32); -void func_80B0D3AC(EnSw* this, GlobalContext* globalCtx); -void func_80B0DB00(EnSw* this, GlobalContext* globalCtx); -void func_80B0D878(EnSw* this, GlobalContext* globalCtx); - -const ActorInit En_Sw_InitVars = { - ACTOR_EN_SW, - ACTORCAT_NPC, - FLAGS, - OBJECT_ST, - sizeof(EnSw), - (ActorFunc)EnSw_Init, - (ActorFunc)EnSw_Destroy, - (ActorFunc)EnSw_Update, - (ActorFunc)EnSw_Draw, -}; - -static ColliderJntSphElementInit sJntSphItemsInit[1] = { - { - { ELEMTYPE_UNK0, { 0xFFCFFFFF, 0x00, 0x08 }, { 0xFFC3FFFE, 0x00, 0x00 }, 0x01, 0x05, 0x01 }, - { 2, { { 0, -300, 0 }, 21 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { COLTYPE_HIT6, 0x11, 0x09, 0x39, 0x10, COLSHAPE_JNTSPH }, - 1, - sJntSphItemsInit, -}; - -static CollisionCheckInfoInit2 D_80B0F074 = { 1, 2, 25, 25, MASS_IMMOVABLE }; - -static struct_80034EC0_Entry D_80B0F080[] = { - { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, 0x01, 0.0f }, - { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, 0x01, -8.0f }, - { &object_st_Anim_0055A8, 1.0f, 0.0f, -1.0f, 0x01, -8.0f }, - { &object_st_Anim_005B98, 1.0f, 0.0f, -1.0f, 0x01, -8.0f }, -}; - -char D_80B0F630[0x80]; // unused - -void EnSw_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dst) { - dst->x = (a->y * b->z) - (a->z * b->y); - dst->y = (a->z * b->x) - (a->x * b->z); - dst->z = (a->x * b->y) - (a->y * b->x); -} - -s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { - Vec3f sp44; - Vec3f sp38; - f32 sp34; - f32 temp_f0; - s32 pad; - - this->actor.floorPoly = poly; - sp44.x = COLPOLY_GET_NORMAL(poly->normal.x); - sp44.y = COLPOLY_GET_NORMAL(poly->normal.y); - sp44.z = COLPOLY_GET_NORMAL(poly->normal.z); - sp34 = Math_FAcosF(DOTXYZ(sp44, this->unk_364)); - EnSw_CrossProduct(&this->unk_364, &sp44, &sp38); - Matrix_RotateAxis(sp34, &sp38, MTXMODE_NEW); - Matrix_MultVec3f(&this->unk_370, &sp38); - this->unk_370 = sp38; - EnSw_CrossProduct(&this->unk_370, &sp44, &this->unk_37C); - temp_f0 = Math3D_Vec3fMagnitude(&this->unk_37C); - if (temp_f0 < 0.001f) { - return 0; - } - this->unk_37C.x = this->unk_37C.x * (1.0f / temp_f0); - this->unk_37C.y = this->unk_37C.y * (1.0f / temp_f0); - this->unk_37C.z = this->unk_37C.z * (1.0f / temp_f0); - this->unk_364 = sp44; - this->unk_3D8.xx = this->unk_370.x; - this->unk_3D8.yx = this->unk_370.y; - this->unk_3D8.zx = this->unk_370.z; - this->unk_3D8.wx = 0.0f; - this->unk_3D8.xy = this->unk_364.x; - this->unk_3D8.yy = this->unk_364.y; - this->unk_3D8.zy = this->unk_364.z; - this->unk_3D8.wy = 0.0f; - this->unk_3D8.xz = this->unk_37C.x; - this->unk_3D8.yz = this->unk_37C.y; - this->unk_3D8.zz = this->unk_37C.z; - this->unk_3D8.wz = 0.0f; - this->unk_3D8.xw = 0.0f; - this->unk_3D8.yw = 0.0f; - this->unk_3D8.zw = 0.0f; - this->unk_3D8.ww = 1.0f; - Matrix_MtxFToYXZRotS(&this->unk_3D8, &this->actor.world.rot, 0); - //! @bug: Does not return. - return 0; -} - -CollisionPoly* func_80B0C020(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32* arg4) { - CollisionPoly* sp3C; - s32 pad; - - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, arg1, arg2, arg3, &sp3C, true, true, true, false, arg4)) { - return NULL; - } - - if (func_80041DB8(&globalCtx->colCtx, sp3C, *arg4) & 0x30) { - return NULL; - } - - if (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp3C, *arg4)) { - return NULL; - } - - return sp3C; -} - -s32 func_80B0C0CC(EnSw* this, GlobalContext* globalCtx, s32 arg2) { - CollisionPoly* temp_v0_2; - CollisionPoly* temp_s1; - Vec3f sp9C; - Vec3f sp90; - Vec3f sp84; - Vec3f sp78; - s32 pad; - s32 sp70; - s32 sp6C; - s32 phi_s1; - s32 sp64; - - sp64 = 0; - this->unk_42C = 1; - sp84 = sp78 = this->actor.world.pos; - sp84.x += this->unk_364.x * 18.0f; - sp84.y += this->unk_364.y * 18.0f; - sp84.z += this->unk_364.z * 18.0f; - sp78.x -= this->unk_364.x * 18.0f; - sp78.y -= this->unk_364.y * 18.0f; - sp78.z -= this->unk_364.z * 18.0f; - temp_s1 = func_80B0C020(globalCtx, &sp84, &sp78, &sp90, &sp70); - - if ((temp_s1 != NULL) && (this->unk_360 == 0)) { - sp78.x = sp84.x + (this->unk_37C.x * 24); - sp78.y = sp84.y + (this->unk_37C.y * 24); - sp78.z = sp84.z + (this->unk_37C.z * 24); - temp_v0_2 = func_80B0C020(globalCtx, &sp84, &sp78, &sp9C, &sp6C); - if (temp_v0_2 != NULL) { - if (arg2 == 1) { - func_80B0BE20(this, temp_v0_2); - this->actor.world.pos = sp9C; - this->actor.floorBgId = sp6C; - } - } else { - if (this->actor.floorPoly != temp_s1) { - func_80B0BE20(this, temp_s1); - } - this->actor.world.pos = sp90; - this->actor.floorBgId = sp70; - } - sp64 = 1; - } else { - sp84 = sp78; - for (phi_s1 = 0; phi_s1 < 3; phi_s1++) { - if (phi_s1 == 0) { - sp78.x = sp84.x - (this->unk_37C.x * 24.0f); - sp78.y = sp84.y - (this->unk_37C.y * 24.0f); - if (0) {} - sp78.z = sp84.z - (this->unk_37C.z * 24.0f); - } else if (phi_s1 == 1) { - sp78.x = sp84.x + (this->unk_370.x * 24.0f); - sp78.y = sp84.y + (this->unk_370.y * 24.0f); - sp78.z = sp84.z + (this->unk_370.z * 24.0f); - } else { - sp78.x = sp84.x - (this->unk_370.x * 24.0f); - sp78.y = sp84.y - (this->unk_370.y * 24.0f); - sp78.z = sp84.z - (this->unk_370.z * 24.0f); - } - temp_v0_2 = func_80B0C020(globalCtx, &sp84, &sp78, &sp9C, &sp6C); - if (temp_v0_2 != NULL) { - if (arg2 == 1) { - func_80B0BE20(this, temp_v0_2); - this->actor.world.pos = sp9C; - this->actor.floorBgId = sp6C; - } - sp64 = 1; - break; - } - } - } - - Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 8, 0xFA0, 1); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 8, 0xFA0, 1); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->actor.world.rot.z, 8, 0xFA0, 1); - - return sp64; -} - -void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSw* this = (EnSw*)thisx; - s32 phi_v0; - Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; - s32 pad; - - if (thisx->params & 0x8000) { - phi_v0 = (((thisx->params - 0x8000) & 0xE000) >> 0xD) + 1; - thisx->params = (thisx->params & 0x1FFF) | (phi_v0 << 0xD); - } - - if (((thisx->params & 0xE000) >> 0xD) > 0) { - phi_v0 = ((thisx->params & 0x1F00) >> 8) - 1; - thisx->params = (thisx->params & 0xE0FF) | (phi_v0 << 8); - } - - // Check to see if this gold skull token has already been retrieved. - if (GET_GS_FLAGS((thisx->params & 0x1F00) >> 8) & (thisx->params & 0xFF)) { - Actor_Kill(&this->actor); - return; - } - - SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_80034EC0(&this->skelAnime, D_80B0F080, 0); - ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->sphs); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xE), &D_80B0F074); - this->actor.scale.x = 0.02f; - - if (((thisx->params & 0xE000) >> 0xD) == 0) { - this->actor.world.rot.x = 0; - this->actor.world.rot.z = 0; - thisx->shape.rot = this->actor.world.rot; - this->unk_484.y = this->actor.world.pos.y; - this->unk_484.x = this->actor.world.pos.x + (Math_SinS(this->actor.world.rot.y) * -60.0f); - this->unk_484.z = this->actor.world.pos.z + (Math_CosS(this->actor.world.rot.y) * -60.0f); - func_80B0DFFC(this, globalCtx); - this->actor.home.pos = this->actor.world.pos; - } else { - this->unk_370.x = Math_SinS(thisx->shape.rot.y + 0x4000); - this->unk_370.y = 0.0f; - this->unk_370.z = Math_CosS(thisx->shape.rot.y + 0x4000); - this->unk_364.x = 0.0f; - this->unk_364.y = 1.0f; - this->unk_364.z = 0.0f; - this->unk_37C.x = Math_SinS(thisx->shape.rot.y); - this->unk_37C.y = 0.0f; - this->unk_37C.z = Math_CosS(thisx->shape.rot.y); - func_80B0C0CC(this, globalCtx, 1); - } - - if (((thisx->params & 0xE000) >> 0xD) >= 3) { - Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - - switch ((thisx->params & 0xE000) >> 0xD) { - case 3: - case 4: - this->unk_360 = 1; - this->actor.velocity.y = 8.0f; - this->actor.speedXZ = 4.0f; - this->actor.gravity = -1.0f; - case 2: - this->actor.scale.x = 0.0f; - case 1: - this->collider.elements[0].info.toucher.damage *= 2; - this->actor.naviEnemyId = 0x20; - this->actor.colChkInfo.health *= 2; - this->actor.flags &= ~ACTOR_FLAG_0; - break; - default: - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - this->actor.naviEnemyId = 0x1F; - break; - } - - this->unk_38E = Rand_S16Offset(0xF, 0x1E); - Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.home.pos = this->actor.world.pos; - thisx->shape.rot = this->actor.world.rot; - - if (((thisx->params & 0xE000) >> 0xD) >= 3) { - this->unk_38C = 0x28; - this->unk_394 = 1; - this->actionFunc = func_80B0D364; - } else if (((thisx->params & 0xE000) >> 0xD) == 0) { - this->actionFunc = func_80B0E5E0; - } else { - this->actionFunc = func_80B0D590; - } -} - -void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSw* this = (EnSw*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -s32 func_80B0C9F0(EnSw* this, GlobalContext* globalCtx) { - s32 phi_v1 = false; - - if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && ((this->actor.params & 0xE000) >> 0xD) == 0 && - globalCtx->actorCtx.unk_02 != 0) { - - this->actor.colChkInfo.damage = this->actor.colChkInfo.health; - phi_v1 = true; - } - - if (this->unk_392 == 0) { - if ((this->collider.base.acFlags & 2) || phi_v1) { - this->collider.base.acFlags &= ~2; - this->unk_392 = 0x10; - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, this->unk_392); - if (Actor_ApplyDamage(&this->actor) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DAMAGE); - return true; - } - Enemy_StartFinishingBlow(globalCtx, &this->actor); - if (((this->actor.params & 0xE000) >> 0xD) != 0) { - this->skelAnime.playSpeed = 8.0f; - if ((globalCtx->state.frames & 1) == 0) { - this->unk_420 = 0.1f; - } else { - this->unk_420 = -0.1f; - } - this->unk_394 = 0xA; - this->unk_38A = 1; - this->unk_420 *= 4.0f; - this->actionFunc = func_80B0D878; - } else { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_38A = 2; - this->actor.shape.shadowScale = 16.0f; - this->actor.gravity = -1.0f; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = func_80B0DB00; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DEAD); - return true; - } - } - - if ((this->unk_390 == 0) && (this->collider.base.atFlags & 2)) { - this->unk_390 = 30; - } - - return false; -} - -void func_80B0CBE8(EnSw* this, GlobalContext* globalCtx) { - if ((((this->actor.params & 0xE000) >> 0xD) > 0) && (this->actionFunc != func_80B0D590)) { - if (this->unk_392 != 0) { - this->unk_392--; - } - } else { - if ((DECR(this->unk_390) == 0) && (this->actor.colChkInfo.health != 0)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if ((DECR(this->unk_392) == 0) && (this->actor.colChkInfo.health != 0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -s32 func_80B0CCF4(EnSw* this, f32* arg1) { - CollisionPoly* temp_v1; - f32 temp_f0; - Vec3f sp6C; - MtxF sp2C; - - if (this->actor.floorPoly == NULL) { - return false; - } - - temp_v1 = this->actor.floorPoly; - sp6C.x = COLPOLY_GET_NORMAL(temp_v1->normal.x); - sp6C.y = COLPOLY_GET_NORMAL(temp_v1->normal.y); - sp6C.z = COLPOLY_GET_NORMAL(temp_v1->normal.z); - Matrix_RotateAxis(*arg1, &sp6C, MTXMODE_NEW); - Matrix_MultVec3f(&this->unk_370, &sp6C); - this->unk_370 = sp6C; - EnSw_CrossProduct(&this->unk_370, &this->unk_364, &this->unk_37C); - temp_f0 = Math3D_Vec3fMagnitude(&this->unk_37C); - if (temp_f0 < 0.001f) { - return false; - } - temp_f0 = 1.0f / temp_f0; - this->unk_37C.x *= temp_f0; - this->unk_37C.y *= temp_f0; - this->unk_37C.z *= temp_f0; - sp2C.xx = this->unk_370.x; - sp2C.yx = this->unk_370.y; - sp2C.zx = this->unk_370.z; - sp2C.wx = 0.0f; - sp2C.xy = this->unk_364.x; - sp2C.yy = this->unk_364.y; - sp2C.zy = this->unk_364.z; - sp2C.wy = 0.0f; - sp2C.xz = this->unk_37C.x; - sp2C.yz = this->unk_37C.y; - sp2C.zz = this->unk_37C.z; - sp2C.wz = 0.0f; - sp2C.xw = 0.0f; - sp2C.yw = 0.0f; - sp2C.zw = 0.0f; - sp2C.ww = 1.0f; - Matrix_MtxFToYXZRotS(&sp2C, &this->actor.world.rot, 0); - return true; -} - -void func_80B0CEA8(EnSw* this, GlobalContext* globalCtx) { - if (!(this->actor.scale.x < 0.0139999995f)) { - Camera* activeCam = GET_ACTIVE_CAM(globalCtx); - - if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) >= 380.0f)) { - Audio_PlayActorSound2(&this->actor, ((this->actor.params & 0xE000) >> 0xD) > 0 ? NA_SE_EN_STALGOLD_ROLL - : NA_SE_EN_STALWALL_ROLL); - } - } -} - -void func_80B0CF44(EnSw* this, GlobalContext* globalCtx, s32 cnt) { - Color_RGBA8 primColor = { 80, 80, 50, 255 }; - Color_RGBA8 envColor = { 100, 100, 80, 0 }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.3f, 0.0f }; - Vec3f pos; - s16 angle = (Rand_ZeroOne() - 0.5f) * 65536.0f; - s32 i; - - for (i = cnt; i >= 0; i--, angle += (s16)(0x10000 / cnt)) { - accel.x = (Rand_ZeroOne() - 0.5f) * 2.0f; - accel.z = (Rand_ZeroOne() - 0.5f) * 2.0f; - pos.x = this->actor.world.pos.x + (Math_SinS(angle) * 2.0f); - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z + (Math_CosS(angle) * 2.0f); - func_8002836C(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 20, 30, 12); - } -} - -void func_80B0D14C(EnSw* this, GlobalContext* globalCtx, s32 cnt) { - Color_RGBA8 primColor = { 80, 80, 50, 255 }; - Color_RGBA8 envColor = { 100, 100, 80, 0 }; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f accel = { 0.0f, 0.3f, 0.0f }; - Vec3f pos; - s16 angle = (Rand_ZeroOne() - 0.5f) * 65536.0f; - s32 i; - - for (i = cnt; i >= 0; i--, angle += (s16)(0x10000 / cnt)) { - accel.x = (Rand_ZeroOne() - 0.5f) * 2.0f; - accel.z = (Rand_ZeroOne() - 0.5f) * 2.0f; - pos.x = this->actor.world.pos.x + (Math_SinS(angle) * 14.0f); - pos.y = this->actor.world.pos.y; - pos.z = this->actor.world.pos.z + (Math_CosS(angle) * 14.0f); - func_8002836C(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 20, 40, 10); - } -} - -void func_80B0D364(EnSw* this, GlobalContext* globalCtx) { - if (((this->actor.params & 0xE000) >> 0xD) == 4) { - this->unk_38C = 0; - this->actionFunc = func_80B0D3AC; - } else { - this->unk_38C = 10; - this->actionFunc = func_80B0D3AC; - } -} - -void func_80B0D3AC(EnSw* this, GlobalContext* globalCtx) { - if (this->unk_38C != 0) { - if ((this->unk_38C & 4) != 0) { - func_80B0CF44(this, globalCtx, 5); - } - this->unk_38C--; - if (this->unk_38C == 0) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_STALGOLD_UP_CRY); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_DODO_M_UP); - } else { - return; - } - } - - Math_ApproachF(&this->actor.scale.x, 0.02f, 0.2f, 0.01f); - Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.world.pos.x += this->unk_364.x * this->actor.velocity.y; - this->actor.world.pos.y += this->unk_364.y * this->actor.velocity.y; - this->actor.world.pos.z += this->unk_364.z * this->actor.velocity.y; - this->actor.world.pos.x += this->unk_37C.x * this->actor.speedXZ; - this->actor.world.pos.y += this->unk_37C.y * this->actor.speedXZ; - this->actor.world.pos.z += this->unk_37C.z * this->actor.speedXZ; - this->actor.velocity.y += this->actor.gravity; - this->actor.velocity.y = CLAMP_MIN(this->actor.velocity.y, this->actor.minVelocityY); - - if (this->actor.velocity.y < 0.0f) { - this->unk_360 = 0; - } - - if (func_80B0C0CC(this, globalCtx, 1) == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - func_80B0D14C(this, globalCtx, 8); - this->actor.scale.x = 0.02f; - Actor_SetScale(&this->actor, 0.02f); - this->actionFunc = func_80B0D590; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.gravity = 0.0f; - } -} - -void func_80B0D590(EnSw* this, GlobalContext* globalCtx) { - f32 sp2C; - - if (((this->actor.params & 0xE000) >> 0xD) == 2) { - if (this->actor.scale.x < 0.0139999995f) { - this->collider.elements[0].info.toucherFlags = 0; - this->collider.elements[0].info.bumperFlags = 0; - this->collider.elements[0].info.ocElemFlags = 0; - } - - if (this->actor.scale.x >= 0.0139999995f) { - this->collider.elements[0].info.toucherFlags = 1; - this->collider.elements[0].info.bumperFlags = 1; - this->collider.elements[0].info.ocElemFlags = 1; - } - - Math_ApproachF(&this->actor.scale.x, !IS_DAY ? 0.02f : 0.0f, 0.2f, 0.01f); - Actor_SetScale(&this->actor, this->actor.scale.x); - } - - if (this->unk_38E != 0) { - this->unk_38E--; - if (this->unk_38E == 0) { - func_80B0CEA8(this, globalCtx); - this->unk_420 = ((globalCtx->state.frames % 2) == 0) ? 0.1f : -0.1f; - this->unk_38A = 1; - this->unk_38C = Rand_S16Offset(30, 60); - if (((this->actor.params & 0xE000) >> 0xD) != 0) { - this->unk_38C *= 2; - this->unk_420 *= 2.0f; - } - } - } else { - this->unk_38C--; - if (this->unk_38C == 0) { - this->unk_38E = Rand_S16Offset(15, 30); - this->unk_38A = 0; - this->skelAnime.playSpeed = 0.0f; - if (((this->actor.params & 0xE000) >> 0xD) != 0) { - this->unk_38E /= 2; - } - } else if (this->unk_38A != 0) { - this->unk_38A--; - this->skelAnime.playSpeed = (this->unk_38A == 0) ? 4.0f : 0.0f; - - if (this->skelAnime.playSpeed > 0.0f) { - func_80B0CEA8(this, globalCtx); - } - if (((this->actor.params & 0xE000) >> 0xD) != 0) { - this->skelAnime.playSpeed *= 2.0f; - } - } else { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { - this->unk_38A = 2; - } - sp2C = 32768.0f / this->skelAnime.endFrame; - sp2C *= this->skelAnime.curFrame; - sp2C = Math_SinS(sp2C) * this->unk_420; - func_80B0CCF4(this, &sp2C); - this->actor.shape.rot = this->actor.world.rot; - } - } -} - -void func_80B0D878(EnSw* this, GlobalContext* globalCtx) { - Actor* temp_v0; - Vec3f pos; - Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; - f32 x; - f32 y; - f32 z; - - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { - func_80B0CEA8(this, globalCtx); - } - - func_80B0CCF4(this, &this->unk_420); - this->actor.shape.rot = this->actor.world.rot; - - if ((this->unk_394 == 0) && (this->unk_392 == 0)) { - Audio_PlaySoundGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - x = (this->unk_364.x * 10.0f); - y = (this->unk_364.y * 10.0f); - z = (this->unk_364.z * 10.0f); - temp_v0 = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_SI, this->actor.world.pos.x + x, - this->actor.world.pos.y + y, this->actor.world.pos.z + z, 0, 0, 0, this->actor.params); - if (temp_v0 != NULL) { - temp_v0->parent = NULL; - } - Actor_Kill(&this->actor); - return; - } - - if ((this->unk_392 == 0) && (DECR(this->unk_394) != 0)) { - pos = this->actor.world.pos; - pos.y += 10.0f + ((Rand_ZeroOne() - 0.5f) * 6.0f); - pos.x += (Rand_ZeroOne() - 0.5f) * 32.0f; - pos.z += (Rand_ZeroOne() - 0.5f) * 32.0f; - EffectSsDeadDb_Spawn(globalCtx, &pos, &velAndAccel, &velAndAccel, 42, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, - true); - } -} - -void func_80B0DB00(EnSw* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->actor); - this->actor.shape.rot.x += 0x1000; - this->actor.shape.rot.z += 0x1000; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); - - if ((this->actor.bgCheckFlags & 1) && (!(0.0f <= this->actor.velocity.y))) { - if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= 32000.0f) { - Actor_Kill(&this->actor); - return; - } - - this->actor.bgCheckFlags &= ~1; - - if (this->unk_38A == 0) { - this->actionFunc = func_80B0DC7C; - this->unk_394 = 10; - } else { - this->actor.velocity.y = ((this->unk_38A--) * 8.0f) * 0.5f; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 16.0f, 0xC, 2.0f, 0x78, 0xA, 0); - } -} - -void func_80B0DC7C(EnSw* this, GlobalContext* globalCtx) { - Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; - Vec3f pos = { 0.0f, 0.0f, 0.0f }; - - if (DECR(this->unk_394) != 0) { - pos.y = ((Rand_ZeroOne() - 0.5f) * 6.0f) + (this->actor.world.pos.y + 10.0f); - pos.x = ((Rand_ZeroOne() - 0.5f) * 32.0f) + this->actor.world.pos.x; - pos.z = ((Rand_ZeroOne() - 0.5f) * 32.0f) + this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &pos, &velAndAccel, &velAndAccel, 42, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, - 1); - this->actor.shape.rot.x += 0x1000; - this->actor.shape.rot.z += 0x1000; - } else { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x30); - Actor_Kill(&this->actor); - } -} - -s16 func_80B0DE34(EnSw* this, Vec3f* arg1) { - s16 pitch; - s16 yaw; - - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, arg1) - this->actor.wallYaw; - pitch = Math_Vec3f_Pitch(&this->actor.world.pos, arg1) - 0x4000; - return pitch * (yaw >= 0 ? -1 : 1); -} - -s32 func_80B0DEA8(EnSw* this, GlobalContext* globalCtx, s32 arg2) { - Player* player = GET_PLAYER(globalCtx); - CollisionPoly* sp58; - s32 sp54; - Vec3f sp48; - - if (!(player->stateFlags1 & 0x200000) && arg2) { - return false; - } else if (func_8002DDF4(globalCtx) && arg2) { - return false; - } else if (ABS(func_80B0DE34(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { - return false; - } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { - return false; - } else if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &player->actor.world.pos, &sp48, - &sp58, true, false, false, true, &sp54)) { - return true; - } else { - return false; - } -} - -s32 func_80B0DFFC(EnSw* this, GlobalContext* globalCtx) { - s32 pad; - CollisionPoly* sp60; - s32 sp5C; - Vec3f sp50; - s32 sp4C = true; - - if (this->collider.base.ocFlags1 & OC1_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - sp4C = false; - } else if (((globalCtx->state.frames % 4) == 0) && - !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_454, &sp50, &sp60, true, - false, false, true, &sp5C)) { - sp4C = false; - } else if (((globalCtx->state.frames % 4) == 1) && - BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_460, &sp50, &sp60, true, - false, false, true, &sp5C)) { - sp4C = false; - } else if (((globalCtx->state.frames % 4) == 2) && - !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_46C, &sp50, &sp60, true, - false, false, true, &sp5C)) { - if (0) {} - sp4C = false; - } else if (((globalCtx->state.frames % 4) == 3) && - BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_478, &sp50, &sp60, true, - false, false, true, &sp5C)) { - sp4C = false; - } - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_484, &sp50, &this->unk_430, true, - false, false, true, &sp5C)) { - this->actor.wallYaw = Math_FAtan2F(this->unk_430->normal.x, this->unk_430->normal.z) * (0x8000 / M_PI); - this->actor.world.pos = sp50; - this->actor.world.pos.x += 6.0f * Math_SinS(this->actor.world.rot.y); - this->actor.world.pos.z += 6.0f * Math_CosS(this->actor.world.rot.y); - this->unk_434 = sp50; - this->unk_434.x += Math_SinS(this->actor.world.rot.y); - this->unk_434.z += Math_CosS(this->actor.world.rot.y); - } - - return sp4C; -} - -void func_80B0E314(EnSw* this, Vec3f arg1, f32 arg4) { - f32 xDist; - f32 yDist; - f32 zDist; - f32 dist; - f32 xDiff; - f32 yDiff; - f32 zDiff; - - Math_SmoothStepToF(&this->actor.speedXZ, arg4, 0.3f, 100.0f, 0.1f); - xDiff = arg1.x - this->actor.world.pos.x; - yDiff = arg1.y - this->actor.world.pos.y; - zDiff = arg1.z - this->actor.world.pos.z; - dist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); - if (dist == 0.0f) { - xDist = yDist = zDist = 0.0f; - } else { - xDist = xDiff / dist; - yDist = yDiff / dist; - zDist = zDiff / dist; - } - xDist *= this->actor.speedXZ; - yDist *= this->actor.speedXZ; - zDist *= this->actor.speedXZ; - this->actor.world.pos.x += xDist; - this->actor.world.pos.y += yDist; - this->actor.world.pos.z += zDist; -} - -s32 func_80B0E430(EnSw* this, f32 arg1, s16 arg2, s32 arg3, GlobalContext* globalCtx) { - Camera* activeCam; - f32 lastFrame = Animation_GetLastFrame(&object_st_Anim_000304); - - if (DECR(this->unk_388) != 0) { - Math_SmoothStepToF(&this->skelAnime.playSpeed, 0.0f, 0.6f, 1000.0f, 0.01f); - return 0; - } - - Math_SmoothStepToF(&this->skelAnime.playSpeed, arg1, 0.6f, 1000.0f, 0.01f); - - if ((arg3 == 1) && (lastFrame < (this->skelAnime.curFrame + this->skelAnime.playSpeed))) { - return 0; - } - - activeCam = GET_ACTIVE_CAM(globalCtx); - - if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) < 380.0f) { - if (DECR(this->unk_440) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); - this->unk_440 = 4; - } - } else { - this->unk_440 = 0; - } - Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_444, 4, arg2, arg2); - this->actor.world.rot = this->actor.shape.rot; - if (this->actor.shape.rot.z == this->unk_444) { - return 1; - } - return 0; -} - -void func_80B0E5E0(EnSw* this, GlobalContext* globalCtx) { - s32 pad[2]; - f32 rand; - - if (func_80B0E430(this, 6.0f, 0x3E8, 1, globalCtx)) { - rand = Rand_ZeroOne(); - this->unk_444 = - ((s16)(20000.0f * rand) + 0x2EE0) * (Rand_ZeroOne() >= 0.5f ? 1.0f : -1.0f) + this->actor.world.rot.z; - this->unk_388 = Rand_S16Offset(10, 30); - } - - if ((DECR(this->unk_442) == 0) && (func_80B0DEA8(this, globalCtx, 1))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_LAUGH); - this->unk_442 = 20; - this->actionFunc = func_80B0E728; - } -} - -void func_80B0E728(EnSw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - - if (DECR(this->unk_442) != 0) { - if (func_80B0DEA8(this, globalCtx, 1)) { - this->unk_448 = player->actor.world.pos; - this->unk_448.y += 30.0f; - this->unk_444 = func_80B0DE34(this, &this->unk_448); - func_80B0E430(this, 6.0f, (u16)0xFA0, 0, globalCtx); - } else { - this->actionFunc = func_80B0E5E0; - } - } else { - if (!func_80B0DFFC(this, globalCtx)) { - this->unk_442 = Rand_S16Offset(20, 10); - this->unk_444 = func_80B0DE34(this, &this->actor.home.pos); - this->unk_448 = this->actor.home.pos; - this->actionFunc = func_80B0E9BC; - } else { - func_80B0E314(this, this->unk_448, 8.0f); - - if (DECR(this->unk_440) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); - this->unk_440 = 4; - } - - if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_448) > 13.0f) || func_8002DDF4(globalCtx)) { - this->actionFunc = func_80B0E90C; - } - } - } -} - -void func_80B0E90C(EnSw* this, GlobalContext* globalCtx) { - s32 pad; - - func_80B0E314(this, this->unk_448, 0.0f); - if (this->actor.speedXZ == 0.0f) { - this->unk_444 = func_80B0DE34(this, &this->actor.home.pos); - this->unk_448 = this->actor.home.pos; - this->actionFunc = func_80B0E9BC; - } -} - -void func_80B0E9BC(EnSw* this, GlobalContext* globalCtx) { - s32 pad; - - if (func_80B0E430(this, 6.0f, 0x3E8, 0, globalCtx)) { - func_80B0E314(this, this->unk_448, 2.0f); - if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_448) > 4.0f)) { - this->actionFunc = func_80B0E5E0; - } - } -} - -void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSw* this = (EnSw*)thisx; - - SkelAnime_Update(&this->skelAnime); - func_80B0C9F0(this, globalCtx); - this->actionFunc(this, globalCtx); - func_80B0CBE8(this, globalCtx); -} - -s32 EnSw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Vec3f sp7C = { 1400.0f, -2600.0f, -800.0f }; - Vec3f sp70 = { 1400.0f, -1600.0f, 0.0f }; - Vec3f sp64 = { -1400.0f, -2600.0f, -800.0f }; - Vec3f sp58 = { -1400.0f, -1600.0f, 0.0f }; - Vec3f sp4C = { 0.0, 0.0f, -600.0f }; - EnSw* this = (EnSw*)thisx; - Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2084); - - if (((this->actor.params & 0xE000) >> 0xD) != 0) { - switch (limbIndex) { - case 23: - *dList = object_st_DL_004788; - break; - case 8: - *dList = object_st_DL_0046F0; - break; - case 14: - *dList = object_st_DL_004658; - break; - case 11: - *dList = object_st_DL_0045C0; - break; - case 26: - *dList = object_st_DL_004820; - break; - case 20: - *dList = object_st_DL_0048B8; - break; - case 17: - *dList = object_st_DL_004950; - break; - case 29: - *dList = object_st_DL_0049E8; - break; - case 5: - *dList = object_st_DL_003FB0; - break; - case 4: - *dList = object_st_DL_0043D8; - break; - } - } - - if (limbIndex == 1) { - Matrix_MultVec3f(&sp7C, &this->unk_454); - Matrix_MultVec3f(&sp70, &this->unk_460); - Matrix_MultVec3f(&sp64, &this->unk_46C); - Matrix_MultVec3f(&sp58, &this->unk_478); - Matrix_MultVec3f(&sp4C, &this->unk_484); - } - - if (limbIndex == 5) { - Matrix_MultVec3f(&sp3C, &this->actor.focus.pos); - } - - if (limbIndex == 4) { - gDPSetEnvColor(POLY_OPA_DISP++, this->unk_1F4.r, this->unk_1F4.g, this->unk_1F4.b, 0); - } - - Collider_UpdateSpheres(limbIndex, &this->collider); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2145); - - return false; -} - -void EnSw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { -} - -void func_80B0EDB8(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 arg3) { - f32 temp_f2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2181); - - temp_f2 = (11500.0f / arg3) * (arg3 - arg2); - - if (0.0f == temp_f2) { - temp_f2 = 11500; - } - - POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, arg1->r, arg1->g, arg1->b, arg1->a, 0, (s16)temp_f2); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2197); -} - -void func_80B0EEA4(GlobalContext* globalCtx) { - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2205); - - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2207); -} - -void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSw* this = (EnSw*)thisx; - Color_RGBA8 sp30 = { 184, 0, 228, 255 }; - - if (((this->actor.params & 0xE000) >> 0xD) != 0) { - Matrix_RotateX(DEGF_TO_RADF(-80), MTXMODE_APPLY); - if (this->actor.colChkInfo.health != 0) { - Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); - } - func_8002EBCC(&this->actor, globalCtx, 0); - } else if (this->actionFunc == func_80B0E728) { - func_80B0EDB8(globalCtx, &sp30, 0x14, 0x1E); - } - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, - EnSw_PostLimbDraw, this); - if (this->actionFunc == func_80B0E728) { - func_80B0EEA4(globalCtx); - } -} diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.cpp b/src/overlays/actors/ovl_En_Sw/z_en_sw.cpp new file mode 100644 index 000000000..9fe597d07 --- /dev/null +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.cpp @@ -0,0 +1,1029 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SW_Z_EN_SW_C +#include "actor_common.h" +#include "z_en_sw.h" +#include "objects/object_st/object_st.h" +#include "def/code_8006BA00.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_btltbls.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnSw_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSw_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80B0DFFC(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0D364(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0E5E0(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0D590(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0E90C(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0E9BC(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0E728(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0DC7C(EnSw* pthis, GlobalContext* globalCtx); +s32 func_80B0C0CC(EnSw* pthis, GlobalContext* globalCtx, s32); +void func_80B0D3AC(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0DB00(EnSw* pthis, GlobalContext* globalCtx); +void func_80B0D878(EnSw* pthis, GlobalContext* globalCtx); + +ActorInit En_Sw_InitVars = { + ACTOR_EN_SW, + ACTORCAT_NPC, + FLAGS, + OBJECT_ST, + sizeof(EnSw), + (ActorFunc)EnSw_Init, + (ActorFunc)EnSw_Destroy, + (ActorFunc)EnSw_Update, + (ActorFunc)EnSw_Draw, +}; + +static ColliderJntSphElementInit sJntSphItemsInit[1] = { + { + { ELEMTYPE_UNK0, { 0xFFCFFFFF, 0x00, 0x08 }, { 0xFFC3FFFE, 0x00, 0x00 }, 0x01, 0x05, 0x01 }, + { 2, { { 0, -300, 0 }, 21 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { COLTYPE_HIT6, 0x11, 0x09, 0x39, 0x10, COLSHAPE_JNTSPH }, + 1, + sJntSphItemsInit, +}; + +static CollisionCheckInfoInit2 D_80B0F074 = { 1, 2, 25, 25, MASS_IMMOVABLE }; + +static struct_80034EC0_Entry D_80B0F080[] = { + { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, 0x01, 0.0f }, + { &object_st_Anim_000304, 1.0f, 0.0f, -1.0f, 0x01, -8.0f }, + { &object_st_Anim_0055A8, 1.0f, 0.0f, -1.0f, 0x01, -8.0f }, + { &object_st_Anim_005B98, 1.0f, 0.0f, -1.0f, 0x01, -8.0f }, +}; + +char D_80B0F630[0x80]; // unused + +void EnSw_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dst) { + dst->x = (a->y * b->z) - (a->z * b->y); + dst->y = (a->z * b->x) - (a->x * b->z); + dst->z = (a->x * b->y) - (a->y * b->x); +} + +s32 func_80B0BE20(EnSw* pthis, CollisionPoly* poly) { + Vec3f sp44; + Vec3f sp38; + f32 sp34; + f32 temp_f0; + s32 pad; + + pthis->actor.floorPoly = poly; + sp44.x = COLPOLY_GET_NORMAL(poly->normal.x); + sp44.y = COLPOLY_GET_NORMAL(poly->normal.y); + sp44.z = COLPOLY_GET_NORMAL(poly->normal.z); + sp34 = Math_FAcosF(DOTXYZ(sp44, pthis->unk_364)); + EnSw_CrossProduct(&pthis->unk_364, &sp44, &sp38); + Matrix_RotateAxis(sp34, &sp38, MTXMODE_NEW); + Matrix_MultVec3f(&pthis->unk_370, &sp38); + pthis->unk_370 = sp38; + EnSw_CrossProduct(&pthis->unk_370, &sp44, &pthis->unk_37C); + temp_f0 = Math3D_Vec3fMagnitude(&pthis->unk_37C); + if (temp_f0 < 0.001f) { + return 0; + } + pthis->unk_37C.x = pthis->unk_37C.x * (1.0f / temp_f0); + pthis->unk_37C.y = pthis->unk_37C.y * (1.0f / temp_f0); + pthis->unk_37C.z = pthis->unk_37C.z * (1.0f / temp_f0); + pthis->unk_364 = sp44; + pthis->unk_3D8.xx = pthis->unk_370.x; + pthis->unk_3D8.yx = pthis->unk_370.y; + pthis->unk_3D8.zx = pthis->unk_370.z; + pthis->unk_3D8.wx = 0.0f; + pthis->unk_3D8.xy = pthis->unk_364.x; + pthis->unk_3D8.yy = pthis->unk_364.y; + pthis->unk_3D8.zy = pthis->unk_364.z; + pthis->unk_3D8.wy = 0.0f; + pthis->unk_3D8.xz = pthis->unk_37C.x; + pthis->unk_3D8.yz = pthis->unk_37C.y; + pthis->unk_3D8.zz = pthis->unk_37C.z; + pthis->unk_3D8.wz = 0.0f; + pthis->unk_3D8.xw = 0.0f; + pthis->unk_3D8.yw = 0.0f; + pthis->unk_3D8.zw = 0.0f; + pthis->unk_3D8.ww = 1.0f; + Matrix_MtxFToYXZRotS(&pthis->unk_3D8, &pthis->actor.world.rot, 0); + //! @bug: Does not return. + return 0; +} + +CollisionPoly* func_80B0C020(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32* arg4) { + CollisionPoly* sp3C; + s32 pad; + + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, arg1, arg2, arg3, &sp3C, true, true, true, false, arg4)) { + return NULL; + } + + if (func_80041DB8(&globalCtx->colCtx, sp3C, *arg4) & 0x30) { + return NULL; + } + + if (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp3C, *arg4)) { + return NULL; + } + + return sp3C; +} + +s32 func_80B0C0CC(EnSw* pthis, GlobalContext* globalCtx, s32 arg2) { + CollisionPoly* temp_v0_2; + CollisionPoly* temp_s1; + Vec3f sp9C; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + s32 pad; + s32 sp70; + s32 sp6C; + s32 phi_s1; + s32 sp64; + + sp64 = 0; + pthis->unk_42C = 1; + sp84 = sp78 = pthis->actor.world.pos; + sp84.x += pthis->unk_364.x * 18.0f; + sp84.y += pthis->unk_364.y * 18.0f; + sp84.z += pthis->unk_364.z * 18.0f; + sp78.x -= pthis->unk_364.x * 18.0f; + sp78.y -= pthis->unk_364.y * 18.0f; + sp78.z -= pthis->unk_364.z * 18.0f; + temp_s1 = func_80B0C020(globalCtx, &sp84, &sp78, &sp90, &sp70); + + if ((temp_s1 != NULL) && (pthis->unk_360 == 0)) { + sp78.x = sp84.x + (pthis->unk_37C.x * 24); + sp78.y = sp84.y + (pthis->unk_37C.y * 24); + sp78.z = sp84.z + (pthis->unk_37C.z * 24); + temp_v0_2 = func_80B0C020(globalCtx, &sp84, &sp78, &sp9C, &sp6C); + if (temp_v0_2 != NULL) { + if (arg2 == 1) { + func_80B0BE20(pthis, temp_v0_2); + pthis->actor.world.pos = sp9C; + pthis->actor.floorBgId = sp6C; + } + } else { + if (pthis->actor.floorPoly != temp_s1) { + func_80B0BE20(pthis, temp_s1); + } + pthis->actor.world.pos = sp90; + pthis->actor.floorBgId = sp70; + } + sp64 = 1; + } else { + sp84 = sp78; + for (phi_s1 = 0; phi_s1 < 3; phi_s1++) { + if (phi_s1 == 0) { + sp78.x = sp84.x - (pthis->unk_37C.x * 24.0f); + sp78.y = sp84.y - (pthis->unk_37C.y * 24.0f); + if (0) {} + sp78.z = sp84.z - (pthis->unk_37C.z * 24.0f); + } else if (phi_s1 == 1) { + sp78.x = sp84.x + (pthis->unk_370.x * 24.0f); + sp78.y = sp84.y + (pthis->unk_370.y * 24.0f); + sp78.z = sp84.z + (pthis->unk_370.z * 24.0f); + } else { + sp78.x = sp84.x - (pthis->unk_370.x * 24.0f); + sp78.y = sp84.y - (pthis->unk_370.y * 24.0f); + sp78.z = sp84.z - (pthis->unk_370.z * 24.0f); + } + temp_v0_2 = func_80B0C020(globalCtx, &sp84, &sp78, &sp9C, &sp6C); + if (temp_v0_2 != NULL) { + if (arg2 == 1) { + func_80B0BE20(pthis, temp_v0_2); + pthis->actor.world.pos = sp9C; + pthis->actor.floorBgId = sp6C; + } + sp64 = 1; + break; + } + } + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->actor.world.rot.x, 8, 0xFA0, 1); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 8, 0xFA0, 1); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->actor.world.rot.z, 8, 0xFA0, 1); + + return sp64; +} + +void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSw* pthis = (EnSw*)thisx; + s32 phi_v0; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + s32 pad; + + if (thisx->params & 0x8000) { + phi_v0 = (((thisx->params - 0x8000) & 0xE000) >> 0xD) + 1; + thisx->params = (thisx->params & 0x1FFF) | (phi_v0 << 0xD); + } + + if (((thisx->params & 0xE000) >> 0xD) > 0) { + phi_v0 = ((thisx->params & 0x1F00) >> 8) - 1; + thisx->params = (thisx->params & 0xE0FF) | (phi_v0 << 8); + } + + // Check to see if pthis gold skull token has already been retrieved. + if (GET_GS_FLAGS((thisx->params & 0x1F00) >> 8) & (thisx->params & 0xFF)) { + Actor_Kill(&pthis->actor); + return; + } + + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_st_Skel_005298, NULL, pthis->jointTable, pthis->morphTable, 30); + func_80034EC0(&pthis->skelAnime, D_80B0F080, 0); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->sphs); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, DamageTable_Get(0xE), &D_80B0F074); + pthis->actor.scale.x = 0.02f; + + if (((thisx->params & 0xE000) >> 0xD) == 0) { + pthis->actor.world.rot.x = 0; + pthis->actor.world.rot.z = 0; + thisx->shape.rot = pthis->actor.world.rot; + pthis->unk_484.y = pthis->actor.world.pos.y; + pthis->unk_484.x = pthis->actor.world.pos.x + (Math_SinS(pthis->actor.world.rot.y) * -60.0f); + pthis->unk_484.z = pthis->actor.world.pos.z + (Math_CosS(pthis->actor.world.rot.y) * -60.0f); + func_80B0DFFC(pthis, globalCtx); + pthis->actor.home.pos = pthis->actor.world.pos; + } else { + pthis->unk_370.x = Math_SinS(thisx->shape.rot.y + 0x4000); + pthis->unk_370.y = 0.0f; + pthis->unk_370.z = Math_CosS(thisx->shape.rot.y + 0x4000); + pthis->unk_364.x = 0.0f; + pthis->unk_364.y = 1.0f; + pthis->unk_364.z = 0.0f; + pthis->unk_37C.x = Math_SinS(thisx->shape.rot.y); + pthis->unk_37C.y = 0.0f; + pthis->unk_37C.z = Math_CosS(thisx->shape.rot.y); + func_80B0C0CC(pthis, globalCtx, 1); + } + + if (((thisx->params & 0xE000) >> 0xD) >= 3) { + Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + switch ((thisx->params & 0xE000) >> 0xD) { + case 3: + case 4: + pthis->unk_360 = 1; + pthis->actor.velocity.y = 8.0f; + pthis->actor.speedXZ = 4.0f; + pthis->actor.gravity = -1.0f; + case 2: + pthis->actor.scale.x = 0.0f; + case 1: + pthis->collider.elements[0].info.toucher.damage *= 2; + pthis->actor.naviEnemyId = 0x20; + pthis->actor.colChkInfo.health *= 2; + pthis->actor.flags &= ~ACTOR_FLAG_0; + break; + default: + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + pthis->actor.naviEnemyId = 0x1F; + break; + } + + pthis->unk_38E = Rand_S16Offset(0xF, 0x1E); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + pthis->actor.home.pos = pthis->actor.world.pos; + thisx->shape.rot = pthis->actor.world.rot; + + if (((thisx->params & 0xE000) >> 0xD) >= 3) { + pthis->unk_38C = 0x28; + pthis->unk_394 = 1; + pthis->actionFunc = func_80B0D364; + } else if (((thisx->params & 0xE000) >> 0xD) == 0) { + pthis->actionFunc = func_80B0E5E0; + } else { + pthis->actionFunc = func_80B0D590; + } +} + +void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSw* pthis = (EnSw*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +s32 func_80B0C9F0(EnSw* pthis, GlobalContext* globalCtx) { + s32 phi_v1 = false; + + if (pthis->actor.xyzDistToPlayerSq < SQ(400.0f) && ((pthis->actor.params & 0xE000) >> 0xD) == 0 && + globalCtx->actorCtx.unk_02 != 0) { + + pthis->actor.colChkInfo.damage = pthis->actor.colChkInfo.health; + phi_v1 = true; + } + + if (pthis->unk_392 == 0) { + if ((pthis->collider.base.acFlags & 2) || phi_v1) { + pthis->collider.base.acFlags &= ~2; + pthis->unk_392 = 0x10; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0, pthis->unk_392); + if (Actor_ApplyDamage(&pthis->actor) != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALTU_DAMAGE); + return true; + } + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + if (((pthis->actor.params & 0xE000) >> 0xD) != 0) { + pthis->skelAnime.playSpeed = 8.0f; + if ((globalCtx->state.frames & 1) == 0) { + pthis->unk_420 = 0.1f; + } else { + pthis->unk_420 = -0.1f; + } + pthis->unk_394 = 0xA; + pthis->unk_38A = 1; + pthis->unk_420 *= 4.0f; + pthis->actionFunc = func_80B0D878; + } else { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_38A = 2; + pthis->actor.shape.shadowScale = 16.0f; + pthis->actor.gravity = -1.0f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = func_80B0DB00; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALWALL_DEAD); + return true; + } + } + + if ((pthis->unk_390 == 0) && (pthis->collider.base.atFlags & 2)) { + pthis->unk_390 = 30; + } + + return false; +} + +void func_80B0CBE8(EnSw* pthis, GlobalContext* globalCtx) { + if ((((pthis->actor.params & 0xE000) >> 0xD) > 0) && (pthis->actionFunc != func_80B0D590)) { + if (pthis->unk_392 != 0) { + pthis->unk_392--; + } + } else { + if ((DECR(pthis->unk_390) == 0) && (pthis->actor.colChkInfo.health != 0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if ((DECR(pthis->unk_392) == 0) && (pthis->actor.colChkInfo.health != 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +s32 func_80B0CCF4(EnSw* pthis, f32* arg1) { + CollisionPoly* temp_v1; + f32 temp_f0; + Vec3f sp6C; + MtxF sp2C; + + if (pthis->actor.floorPoly == NULL) { + return false; + } + + temp_v1 = pthis->actor.floorPoly; + sp6C.x = COLPOLY_GET_NORMAL(temp_v1->normal.x); + sp6C.y = COLPOLY_GET_NORMAL(temp_v1->normal.y); + sp6C.z = COLPOLY_GET_NORMAL(temp_v1->normal.z); + Matrix_RotateAxis(*arg1, &sp6C, MTXMODE_NEW); + Matrix_MultVec3f(&pthis->unk_370, &sp6C); + pthis->unk_370 = sp6C; + EnSw_CrossProduct(&pthis->unk_370, &pthis->unk_364, &pthis->unk_37C); + temp_f0 = Math3D_Vec3fMagnitude(&pthis->unk_37C); + if (temp_f0 < 0.001f) { + return false; + } + temp_f0 = 1.0f / temp_f0; + pthis->unk_37C.x *= temp_f0; + pthis->unk_37C.y *= temp_f0; + pthis->unk_37C.z *= temp_f0; + sp2C.xx = pthis->unk_370.x; + sp2C.yx = pthis->unk_370.y; + sp2C.zx = pthis->unk_370.z; + sp2C.wx = 0.0f; + sp2C.xy = pthis->unk_364.x; + sp2C.yy = pthis->unk_364.y; + sp2C.zy = pthis->unk_364.z; + sp2C.wy = 0.0f; + sp2C.xz = pthis->unk_37C.x; + sp2C.yz = pthis->unk_37C.y; + sp2C.zz = pthis->unk_37C.z; + sp2C.wz = 0.0f; + sp2C.xw = 0.0f; + sp2C.yw = 0.0f; + sp2C.zw = 0.0f; + sp2C.ww = 1.0f; + Matrix_MtxFToYXZRotS(&sp2C, &pthis->actor.world.rot, 0); + return true; +} + +void func_80B0CEA8(EnSw* pthis, GlobalContext* globalCtx) { + if (!(pthis->actor.scale.x < 0.0139999995f)) { + Camera* activeCam = GET_ACTIVE_CAM(globalCtx); + + if (!(Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &activeCam->eye) >= 380.0f)) { + Audio_PlayActorSound2(&pthis->actor, ((pthis->actor.params & 0xE000) >> 0xD) > 0 ? NA_SE_EN_STALGOLD_ROLL + : NA_SE_EN_STALWALL_ROLL); + } + } +} + +void func_80B0CF44(EnSw* pthis, GlobalContext* globalCtx, s32 cnt) { + Color_RGBA8 primColor = { 80, 80, 50, 255 }; + Color_RGBA8 envColor = { 100, 100, 80, 0 }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + Vec3f pos; + s16 angle = (Rand_ZeroOne() - 0.5f) * 65536.0f; + s32 i; + + for (i = cnt; i >= 0; i--, angle += (s16)(0x10000 / cnt)) { + accel.x = (Rand_ZeroOne() - 0.5f) * 2.0f; + accel.z = (Rand_ZeroOne() - 0.5f) * 2.0f; + pos.x = pthis->actor.world.pos.x + (Math_SinS(angle) * 2.0f); + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z + (Math_CosS(angle) * 2.0f); + func_8002836C(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 20, 30, 12); + } +} + +void func_80B0D14C(EnSw* pthis, GlobalContext* globalCtx, s32 cnt) { + Color_RGBA8 primColor = { 80, 80, 50, 255 }; + Color_RGBA8 envColor = { 100, 100, 80, 0 }; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + Vec3f pos; + s16 angle = (Rand_ZeroOne() - 0.5f) * 65536.0f; + s32 i; + + for (i = cnt; i >= 0; i--, angle += (s16)(0x10000 / cnt)) { + accel.x = (Rand_ZeroOne() - 0.5f) * 2.0f; + accel.z = (Rand_ZeroOne() - 0.5f) * 2.0f; + pos.x = pthis->actor.world.pos.x + (Math_SinS(angle) * 14.0f); + pos.y = pthis->actor.world.pos.y; + pos.z = pthis->actor.world.pos.z + (Math_CosS(angle) * 14.0f); + func_8002836C(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 20, 40, 10); + } +} + +void func_80B0D364(EnSw* pthis, GlobalContext* globalCtx) { + if (((pthis->actor.params & 0xE000) >> 0xD) == 4) { + pthis->unk_38C = 0; + pthis->actionFunc = func_80B0D3AC; + } else { + pthis->unk_38C = 10; + pthis->actionFunc = func_80B0D3AC; + } +} + +void func_80B0D3AC(EnSw* pthis, GlobalContext* globalCtx) { + if (pthis->unk_38C != 0) { + if ((pthis->unk_38C & 4) != 0) { + func_80B0CF44(pthis, globalCtx, 5); + } + pthis->unk_38C--; + if (pthis->unk_38C == 0) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 0x28, NA_SE_EN_STALGOLD_UP_CRY); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 0x28, NA_SE_EN_DODO_M_UP); + } else { + return; + } + } + + Math_ApproachF(&pthis->actor.scale.x, 0.02f, 0.2f, 0.01f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + pthis->actor.world.pos.x += pthis->unk_364.x * pthis->actor.velocity.y; + pthis->actor.world.pos.y += pthis->unk_364.y * pthis->actor.velocity.y; + pthis->actor.world.pos.z += pthis->unk_364.z * pthis->actor.velocity.y; + pthis->actor.world.pos.x += pthis->unk_37C.x * pthis->actor.speedXZ; + pthis->actor.world.pos.y += pthis->unk_37C.y * pthis->actor.speedXZ; + pthis->actor.world.pos.z += pthis->unk_37C.z * pthis->actor.speedXZ; + pthis->actor.velocity.y += pthis->actor.gravity; + pthis->actor.velocity.y = CLAMP_MIN(pthis->actor.velocity.y, pthis->actor.minVelocityY); + + if (pthis->actor.velocity.y < 0.0f) { + pthis->unk_360 = 0; + } + + if (func_80B0C0CC(pthis, globalCtx, 1) == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + func_80B0D14C(pthis, globalCtx, 8); + pthis->actor.scale.x = 0.02f; + Actor_SetScale(&pthis->actor, 0.02f); + pthis->actionFunc = func_80B0D590; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = 0.0f; + } +} + +void func_80B0D590(EnSw* pthis, GlobalContext* globalCtx) { + f32 sp2C; + + if (((pthis->actor.params & 0xE000) >> 0xD) == 2) { + if (pthis->actor.scale.x < 0.0139999995f) { + pthis->collider.elements[0].info.toucherFlags = 0; + pthis->collider.elements[0].info.bumperFlags = 0; + pthis->collider.elements[0].info.ocElemFlags = 0; + } + + if (pthis->actor.scale.x >= 0.0139999995f) { + pthis->collider.elements[0].info.toucherFlags = 1; + pthis->collider.elements[0].info.bumperFlags = 1; + pthis->collider.elements[0].info.ocElemFlags = 1; + } + + Math_ApproachF(&pthis->actor.scale.x, !IS_DAY ? 0.02f : 0.0f, 0.2f, 0.01f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x); + } + + if (pthis->unk_38E != 0) { + pthis->unk_38E--; + if (pthis->unk_38E == 0) { + func_80B0CEA8(pthis, globalCtx); + pthis->unk_420 = ((globalCtx->state.frames % 2) == 0) ? 0.1f : -0.1f; + pthis->unk_38A = 1; + pthis->unk_38C = Rand_S16Offset(30, 60); + if (((pthis->actor.params & 0xE000) >> 0xD) != 0) { + pthis->unk_38C *= 2; + pthis->unk_420 *= 2.0f; + } + } + } else { + pthis->unk_38C--; + if (pthis->unk_38C == 0) { + pthis->unk_38E = Rand_S16Offset(15, 30); + pthis->unk_38A = 0; + pthis->skelAnime.playSpeed = 0.0f; + if (((pthis->actor.params & 0xE000) >> 0xD) != 0) { + pthis->unk_38E /= 2; + } + } else if (pthis->unk_38A != 0) { + pthis->unk_38A--; + pthis->skelAnime.playSpeed = (pthis->unk_38A == 0) ? 4.0f : 0.0f; + + if (pthis->skelAnime.playSpeed > 0.0f) { + func_80B0CEA8(pthis, globalCtx); + } + if (((pthis->actor.params & 0xE000) >> 0xD) != 0) { + pthis->skelAnime.playSpeed *= 2.0f; + } + } else { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame) == 1) { + pthis->unk_38A = 2; + } + sp2C = 32768.0f / pthis->skelAnime.endFrame; + sp2C *= pthis->skelAnime.curFrame; + sp2C = Math_SinS(sp2C) * pthis->unk_420; + func_80B0CCF4(pthis, &sp2C); + pthis->actor.shape.rot = pthis->actor.world.rot; + } + } +} + +void func_80B0D878(EnSw* pthis, GlobalContext* globalCtx) { + Actor* temp_v0; + Vec3f pos; + Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; + f32 x; + f32 y; + f32 z; + + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame) == 1) { + func_80B0CEA8(pthis, globalCtx); + } + + func_80B0CCF4(pthis, &pthis->unk_420); + pthis->actor.shape.rot = pthis->actor.world.rot; + + if ((pthis->unk_394 == 0) && (pthis->unk_392 == 0)) { + Audio_PlaySoundGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + x = (pthis->unk_364.x * 10.0f); + y = (pthis->unk_364.y * 10.0f); + z = (pthis->unk_364.z * 10.0f); + temp_v0 = + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_SI, pthis->actor.world.pos.x + x, + pthis->actor.world.pos.y + y, pthis->actor.world.pos.z + z, 0, 0, 0, pthis->actor.params); + if (temp_v0 != NULL) { + temp_v0->parent = NULL; + } + Actor_Kill(&pthis->actor); + return; + } + + if ((pthis->unk_392 == 0) && (DECR(pthis->unk_394) != 0)) { + pos = pthis->actor.world.pos; + pos.y += 10.0f + ((Rand_ZeroOne() - 0.5f) * 6.0f); + pos.x += (Rand_ZeroOne() - 0.5f) * 32.0f; + pos.z += (Rand_ZeroOne() - 0.5f) * 32.0f; + EffectSsDeadDb_Spawn(globalCtx, &pos, &velAndAccel, &velAndAccel, 42, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, + true); + } +} + +void func_80B0DB00(EnSw* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->actor); + pthis->actor.shape.rot.x += 0x1000; + pthis->actor.shape.rot.z += 0x1000; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 0.0f, 5); + + if ((pthis->actor.bgCheckFlags & 1) && (!(0.0f <= pthis->actor.velocity.y))) { + if (pthis->actor.floorHeight <= BGCHECK_Y_MIN || pthis->actor.floorHeight >= 32000.0f) { + Actor_Kill(&pthis->actor); + return; + } + + pthis->actor.bgCheckFlags &= ~1; + + if (pthis->unk_38A == 0) { + pthis->actionFunc = func_80B0DC7C; + pthis->unk_394 = 10; + } else { + pthis->actor.velocity.y = ((pthis->unk_38A--) * 8.0f) * 0.5f; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 16.0f, 0xC, 2.0f, 0x78, 0xA, 0); + } +} + +void func_80B0DC7C(EnSw* pthis, GlobalContext* globalCtx) { + Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; + Vec3f pos = { 0.0f, 0.0f, 0.0f }; + + if (DECR(pthis->unk_394) != 0) { + pos.y = ((Rand_ZeroOne() - 0.5f) * 6.0f) + (pthis->actor.world.pos.y + 10.0f); + pos.x = ((Rand_ZeroOne() - 0.5f) * 32.0f) + pthis->actor.world.pos.x; + pos.z = ((Rand_ZeroOne() - 0.5f) * 32.0f) + pthis->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &pos, &velAndAccel, &velAndAccel, 42, 0, 255, 255, 255, 255, 255, 0, 0, 1, 9, + 1); + pthis->actor.shape.rot.x += 0x1000; + pthis->actor.shape.rot.z += 0x1000; + } else { + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, 0x30); + Actor_Kill(&pthis->actor); + } +} + +s16 func_80B0DE34(EnSw* pthis, Vec3f* arg1) { + s16 pitch; + s16 yaw; + + yaw = Math_Vec3f_Yaw(&pthis->actor.world.pos, arg1) - pthis->actor.wallYaw; + pitch = Math_Vec3f_Pitch(&pthis->actor.world.pos, arg1) - 0x4000; + return pitch * (yaw >= 0 ? -1 : 1); +} + +s32 func_80B0DEA8(EnSw* pthis, GlobalContext* globalCtx, s32 arg2) { + Player* player = GET_PLAYER(globalCtx); + CollisionPoly* sp58; + s32 sp54; + Vec3f sp48; + + if (!(player->stateFlags1 & 0x200000) && arg2) { + return false; + } else if (func_8002DDF4(globalCtx) && arg2) { + return false; + } else if (ABS(func_80B0DE34(pthis, &player->actor.world.pos) - pthis->actor.shape.rot.z) >= 0x1FC2) { + return false; + } else if (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &player->actor.world.pos) >= 130.0f) { + return false; + } else if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &player->actor.world.pos, &sp48, + &sp58, true, false, false, true, &sp54)) { + return true; + } else { + return false; + } +} + +s32 func_80B0DFFC(EnSw* pthis, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* sp60; + s32 sp5C; + Vec3f sp50; + s32 sp4C = true; + + if (pthis->collider.base.ocFlags1 & OC1_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + sp4C = false; + } else if (((globalCtx->state.frames % 4) == 0) && + !BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &pthis->unk_454, &sp50, &sp60, true, + false, false, true, &sp5C)) { + sp4C = false; + } else if (((globalCtx->state.frames % 4) == 1) && + BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &pthis->unk_460, &sp50, &sp60, true, + false, false, true, &sp5C)) { + sp4C = false; + } else if (((globalCtx->state.frames % 4) == 2) && + !BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &pthis->unk_46C, &sp50, &sp60, true, + false, false, true, &sp5C)) { + if (0) {} + sp4C = false; + } else if (((globalCtx->state.frames % 4) == 3) && + BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &pthis->unk_478, &sp50, &sp60, true, + false, false, true, &sp5C)) { + sp4C = false; + } + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &pthis->unk_484, &sp50, &pthis->unk_430, true, + false, false, true, &sp5C)) { + pthis->actor.wallYaw = Math_FAtan2F(pthis->unk_430->normal.x, pthis->unk_430->normal.z) * (0x8000 / M_PI); + pthis->actor.world.pos = sp50; + pthis->actor.world.pos.x += 6.0f * Math_SinS(pthis->actor.world.rot.y); + pthis->actor.world.pos.z += 6.0f * Math_CosS(pthis->actor.world.rot.y); + pthis->unk_434 = sp50; + pthis->unk_434.x += Math_SinS(pthis->actor.world.rot.y); + pthis->unk_434.z += Math_CosS(pthis->actor.world.rot.y); + } + + return sp4C; +} + +void func_80B0E314(EnSw* pthis, Vec3f arg1, f32 arg4) { + f32 xDist; + f32 yDist; + f32 zDist; + f32 dist; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + Math_SmoothStepToF(&pthis->actor.speedXZ, arg4, 0.3f, 100.0f, 0.1f); + xDiff = arg1.x - pthis->actor.world.pos.x; + yDiff = arg1.y - pthis->actor.world.pos.y; + zDiff = arg1.z - pthis->actor.world.pos.z; + dist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + if (dist == 0.0f) { + xDist = yDist = zDist = 0.0f; + } else { + xDist = xDiff / dist; + yDist = yDiff / dist; + zDist = zDiff / dist; + } + xDist *= pthis->actor.speedXZ; + yDist *= pthis->actor.speedXZ; + zDist *= pthis->actor.speedXZ; + pthis->actor.world.pos.x += xDist; + pthis->actor.world.pos.y += yDist; + pthis->actor.world.pos.z += zDist; +} + +s32 func_80B0E430(EnSw* pthis, f32 arg1, s16 arg2, s32 arg3, GlobalContext* globalCtx) { + Camera* activeCam; + f32 lastFrame = Animation_GetLastFrame(&object_st_Anim_000304); + + if (DECR(pthis->unk_388) != 0) { + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, 0.0f, 0.6f, 1000.0f, 0.01f); + return 0; + } + + Math_SmoothStepToF(&pthis->skelAnime.playSpeed, arg1, 0.6f, 1000.0f, 0.01f); + + if ((arg3 == 1) && (lastFrame < (pthis->skelAnime.curFrame + pthis->skelAnime.playSpeed))) { + return 0; + } + + activeCam = GET_ACTIVE_CAM(globalCtx); + + if (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &activeCam->eye) < 380.0f) { + if (DECR(pthis->unk_440) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALWALL_ROLL); + pthis->unk_440 = 4; + } + } else { + pthis->unk_440 = 0; + } + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->unk_444, 4, arg2, arg2); + pthis->actor.world.rot = pthis->actor.shape.rot; + if (pthis->actor.shape.rot.z == pthis->unk_444) { + return 1; + } + return 0; +} + +void func_80B0E5E0(EnSw* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + f32 rand; + + if (func_80B0E430(pthis, 6.0f, 0x3E8, 1, globalCtx)) { + rand = Rand_ZeroOne(); + pthis->unk_444 = + ((s16)(20000.0f * rand) + 0x2EE0) * (Rand_ZeroOne() >= 0.5f ? 1.0f : -1.0f) + pthis->actor.world.rot.z; + pthis->unk_388 = Rand_S16Offset(10, 30); + } + + if ((DECR(pthis->unk_442) == 0) && (func_80B0DEA8(pthis, globalCtx, 1))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALWALL_LAUGH); + pthis->unk_442 = 20; + pthis->actionFunc = func_80B0E728; + } +} + +void func_80B0E728(EnSw* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (DECR(pthis->unk_442) != 0) { + if (func_80B0DEA8(pthis, globalCtx, 1)) { + pthis->unk_448 = player->actor.world.pos; + pthis->unk_448.y += 30.0f; + pthis->unk_444 = func_80B0DE34(pthis, &pthis->unk_448); + func_80B0E430(pthis, 6.0f, (u16)0xFA0, 0, globalCtx); + } else { + pthis->actionFunc = func_80B0E5E0; + } + } else { + if (!func_80B0DFFC(pthis, globalCtx)) { + pthis->unk_442 = Rand_S16Offset(20, 10); + pthis->unk_444 = func_80B0DE34(pthis, &pthis->actor.home.pos); + pthis->unk_448 = pthis->actor.home.pos; + pthis->actionFunc = func_80B0E9BC; + } else { + func_80B0E314(pthis, pthis->unk_448, 8.0f); + + if (DECR(pthis->unk_440) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STALWALL_DASH); + pthis->unk_440 = 4; + } + + if (!(Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->unk_448) > 13.0f) || func_8002DDF4(globalCtx)) { + pthis->actionFunc = func_80B0E90C; + } + } + } +} + +void func_80B0E90C(EnSw* pthis, GlobalContext* globalCtx) { + s32 pad; + + func_80B0E314(pthis, pthis->unk_448, 0.0f); + if (pthis->actor.speedXZ == 0.0f) { + pthis->unk_444 = func_80B0DE34(pthis, &pthis->actor.home.pos); + pthis->unk_448 = pthis->actor.home.pos; + pthis->actionFunc = func_80B0E9BC; + } +} + +void func_80B0E9BC(EnSw* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (func_80B0E430(pthis, 6.0f, 0x3E8, 0, globalCtx)) { + func_80B0E314(pthis, pthis->unk_448, 2.0f); + if (!(Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &pthis->unk_448) > 4.0f)) { + pthis->actionFunc = func_80B0E5E0; + } + } +} + +void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSw* pthis = (EnSw*)thisx; + + SkelAnime_Update(&pthis->skelAnime); + func_80B0C9F0(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + func_80B0CBE8(pthis, globalCtx); +} + +s32 EnSw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + Vec3f sp7C = { 1400.0f, -2600.0f, -800.0f }; + Vec3f sp70 = { 1400.0f, -1600.0f, 0.0f }; + Vec3f sp64 = { -1400.0f, -2600.0f, -800.0f }; + Vec3f sp58 = { -1400.0f, -1600.0f, 0.0f }; + Vec3f sp4C = { 0.0, 0.0f, -600.0f }; + EnSw* pthis = (EnSw*)thisx; + Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2084); + + if (((pthis->actor.params & 0xE000) >> 0xD) != 0) { + switch (limbIndex) { + case 23: + *dList = object_st_DL_004788; + break; + case 8: + *dList = object_st_DL_0046F0; + break; + case 14: + *dList = object_st_DL_004658; + break; + case 11: + *dList = object_st_DL_0045C0; + break; + case 26: + *dList = object_st_DL_004820; + break; + case 20: + *dList = object_st_DL_0048B8; + break; + case 17: + *dList = object_st_DL_004950; + break; + case 29: + *dList = object_st_DL_0049E8; + break; + case 5: + *dList = object_st_DL_003FB0; + break; + case 4: + *dList = object_st_DL_0043D8; + break; + } + } + + if (limbIndex == 1) { + Matrix_MultVec3f(&sp7C, &pthis->unk_454); + Matrix_MultVec3f(&sp70, &pthis->unk_460); + Matrix_MultVec3f(&sp64, &pthis->unk_46C); + Matrix_MultVec3f(&sp58, &pthis->unk_478); + Matrix_MultVec3f(&sp4C, &pthis->unk_484); + } + + if (limbIndex == 5) { + Matrix_MultVec3f(&sp3C, &pthis->actor.focus.pos); + } + + if (limbIndex == 4) { + gDPSetEnvColor(POLY_OPA_DISP++, pthis->unk_1F4.r, pthis->unk_1F4.g, pthis->unk_1F4.b, 0); + } + + Collider_UpdateSpheres(limbIndex, &pthis->collider); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2145); + + return false; +} + +void EnSw_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +} + +void func_80B0EDB8(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 arg3) { + f32 temp_f2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2181); + + temp_f2 = (11500.0f / arg3) * (arg3 - arg2); + + if (0.0f == temp_f2) { + temp_f2 = 11500; + } + + POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, arg1->r, arg1->g, arg1->b, arg1->a, 0, (s16)temp_f2); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2197); +} + +void func_80B0EEA4(GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2205); + + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_sw.c", 2207); +} + +void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSw* pthis = (EnSw*)thisx; + Color_RGBA8 sp30 = { 184, 0, 228, 255 }; + + if (((pthis->actor.params & 0xE000) >> 0xD) != 0) { + Matrix_RotateX(DEGF_TO_RADF(-80), MTXMODE_APPLY); + if (pthis->actor.colChkInfo.health != 0) { + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + } + func_8002EBCC(&pthis->actor, globalCtx, 0); + } else if (pthis->actionFunc == func_80B0E728) { + func_80B0EDB8(globalCtx, &sp30, 0x14, 0x1E); + } + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnSw_OverrideLimbDraw, + EnSw_PostLimbDraw, pthis); + if (pthis->actionFunc == func_80B0E728) { + func_80B0EEA4(globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 7f46dba22..0c0faa184 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -8,7 +8,7 @@ struct EnSw; -typedef void (*EnSwActionFunc)(struct EnSw* this, GlobalContext* globalCtx); +typedef void (*EnSwActionFunc)(struct EnSw* pthis, GlobalContext* globalCtx); typedef struct EnSw { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c b/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.cpp similarity index 52% rename from src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c rename to src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.cpp index b5e85e6ba..c4930434c 100644 --- a/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c +++ b/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.cpp @@ -25,14 +25,14 @@ void EnSyatekiItm_Init(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiItm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiItm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiItm_Idle(EnSyatekiItm* this, GlobalContext* globalCtx); -void EnSyatekiItm_StartRound(EnSyatekiItm* this, GlobalContext* globalCtx); -void EnSyatekiItm_SpawnTargets(EnSyatekiItm* this, GlobalContext* globalCtx); -void EnSyatekiItm_CheckTargets(EnSyatekiItm* this, GlobalContext* globalCtx); -void EnSyatekiItm_CleanupGame(EnSyatekiItm* this, GlobalContext* globalCtx); -void EnSyatekiItm_EndGame(EnSyatekiItm* this, GlobalContext* globalCtx); +void EnSyatekiItm_Idle(EnSyatekiItm* pthis, GlobalContext* globalCtx); +void EnSyatekiItm_StartRound(EnSyatekiItm* pthis, GlobalContext* globalCtx); +void EnSyatekiItm_SpawnTargets(EnSyatekiItm* pthis, GlobalContext* globalCtx); +void EnSyatekiItm_CheckTargets(EnSyatekiItm* pthis, GlobalContext* globalCtx); +void EnSyatekiItm_CleanupGame(EnSyatekiItm* pthis, GlobalContext* globalCtx); +void EnSyatekiItm_EndGame(EnSyatekiItm* pthis, GlobalContext* globalCtx); -const ActorInit En_Syateki_Itm_InitVars = { +ActorInit En_Syateki_Itm_InitVars = { ACTOR_EN_SYATEKI_ITM, ACTORCAT_PROP, FLAGS, @@ -74,40 +74,40 @@ static Vec3f sRupeePos[] = { void EnSyatekiItm_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnSyatekiItm* this = (EnSyatekiItm*)thisx; + EnSyatekiItm* pthis = (EnSyatekiItm*)thisx; s32 i; - this->man = (EnSyatekiMan*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_SYATEKI_MAN, + pthis->man = (EnSyatekiMan*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_SYATEKI_MAN, 140.0f, 0.0f, 255.0f, 0, -0x4000, 0, 0); - if (this->man == NULL) { + if (pthis->man == NULL) { // "Spawn error" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ エラー原 ☆☆☆☆ \n" VT_RST); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } for (i = 0; i < 10; i++) { - this->markers[i] = - (EnExRuppy*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_RUPPY, + pthis->markers[i] = + (EnExRuppy*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_EX_RUPPY, sRupeePos[i].x, sRupeePos[i].y, sRupeePos[i].z, 0, 0, 0, 4); - if (this->markers[i] == NULL) { + if (pthis->markers[i] == NULL) { // "Second spawn error" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ エラー原セカンド ☆☆☆☆ \n" VT_RST); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->markers[i]->colorIdx = sRupeeTypes[i]; + pthis->markers[i]->colorIdx = sRupeeTypes[i]; } - this->actionFunc = EnSyatekiItm_Idle; + pthis->actionFunc = EnSyatekiItm_Idle; } void EnSyatekiItm_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void EnSyatekiItm_Idle(EnSyatekiItm* this, GlobalContext* globalCtx) { +void EnSyatekiItm_Idle(EnSyatekiItm* pthis, GlobalContext* globalCtx) { s32 i; Player* player = GET_PLAYER(globalCtx); - if (this->signal == ENSYATEKI_START) { + if (pthis->signal == ENSYATEKI_START) { player->actor.world.pos.x = -12.0f; player->actor.world.pos.y = 20.0f; player->actor.world.pos.z = 182.0f; @@ -115,60 +115,60 @@ void EnSyatekiItm_Idle(EnSyatekiItm* this, GlobalContext* globalCtx) { player->actor.world.rot.x = player->actor.shape.rot.x = player->actor.world.rot.z = player->actor.shape.rot.z = 0; func_8008EF44(globalCtx, 15); - this->roundNum = this->hitCount = 0; + pthis->roundNum = pthis->hitCount = 0; for (i = 0; i < 6; i++) { - this->roundFlags[i] = false; + pthis->roundFlags[i] = false; } for (i = 0; i < 10; i++) { - this->markers[i]->galleryFlag = false; + pthis->markers[i]->galleryFlag = false; } - this->actionFunc = EnSyatekiItm_StartRound; + pthis->actionFunc = EnSyatekiItm_StartRound; } } -void EnSyatekiItm_StartRound(EnSyatekiItm* this, GlobalContext* globalCtx) { +void EnSyatekiItm_StartRound(EnSyatekiItm* pthis, GlobalContext* globalCtx) { s32 i; s32 j; Player* player = GET_PLAYER(globalCtx); - if (this->unkTimer == 0) { + if (pthis->unkTimer == 0) { if (LINK_IS_ADULT) { for (i = 0, j = 0; i < SYATEKI_ROUND_MAX; i++) { - if (this->roundFlags[i]) { + if (pthis->roundFlags[i]) { j++; } } if (j >= SYATEKI_ROUND_MAX) { player->actor.freezeTimer = 10; - this->signal = ENSYATEKI_END; - this->actionFunc = EnSyatekiItm_CleanupGame; + pthis->signal = ENSYATEKI_END; + pthis->actionFunc = EnSyatekiItm_CleanupGame; return; } i = Rand_ZeroFloat(5.99f); - while (this->roundFlags[i]) { + while (pthis->roundFlags[i]) { i = Rand_ZeroFloat(5.99f); if (1) {} } - this->roundNum = i + 1; - this->roundFlags[i] = true; + pthis->roundNum = i + 1; + pthis->roundFlags[i] = true; } else { - this->roundNum++; - if (this->roundNum > SYATEKI_ROUND_MAX) { + pthis->roundNum++; + if (pthis->roundNum > SYATEKI_ROUND_MAX) { player->actor.freezeTimer = 10; - this->signal = ENSYATEKI_END; - this->actionFunc = EnSyatekiItm_CleanupGame; + pthis->signal = ENSYATEKI_END; + pthis->actionFunc = EnSyatekiItm_CleanupGame; return; } } - this->timer = (this->roundNum == 1) ? 50 : 30; + pthis->timer = (pthis->roundNum == 1) ? 50 : 30; func_80078884(NA_SE_SY_FOUND); - this->actionFunc = EnSyatekiItm_SpawnTargets; + pthis->actionFunc = EnSyatekiItm_SpawnTargets; } } -void EnSyatekiItm_SpawnTargets(EnSyatekiItm* this, GlobalContext* globalCtx) { +void EnSyatekiItm_SpawnTargets(EnSyatekiItm* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s32 i; @@ -176,150 +176,150 @@ void EnSyatekiItm_SpawnTargets(EnSyatekiItm* this, GlobalContext* globalCtx) { if (globalCtx->shootingGalleryStatus == -1) { player->actor.freezeTimer = 10; - this->signal = ENSYATEKI_END; - this->actionFunc = EnSyatekiItm_CleanupGame; + pthis->signal = ENSYATEKI_END; + pthis->actionFunc = EnSyatekiItm_CleanupGame; return; } - if (this->timer == 0) { + if (pthis->timer == 0) { for (i = 0; i < 2; i++) { - Math_Vec3f_Copy(&this->targetHome[i], &zeroVec); - Math_Vec3f_Copy(&this->targetFinal[i], &zeroVec); - this->targets[i] = NULL; + Math_Vec3f_Copy(&pthis->targetHome[i], &zeroVec); + Math_Vec3f_Copy(&pthis->targetFinal[i], &zeroVec); + pthis->targets[i] = NULL; } - this->numTargets = 2; - this->curMarkers[0] = this->curMarkers[1] = NULL; - roundIdx = this->roundNum - 1; + pthis->numTargets = 2; + pthis->curMarkers[0] = pthis->curMarkers[1] = NULL; + roundIdx = pthis->roundNum - 1; switch (roundIdx) { case SYATEKI_ROUND_GREEN_APPEAR: - Math_Vec3f_Copy(&this->targetHome[0], &sGreenAppearHome); - Math_Vec3f_Copy(&this->targetFinal[0], &sGreenAppearFinal); - this->curMarkers[0] = this->markers[0]; - this->numTargets = 1; + Math_Vec3f_Copy(&pthis->targetHome[0], &sGreenAppearHome); + Math_Vec3f_Copy(&pthis->targetFinal[0], &sGreenAppearFinal); + pthis->curMarkers[0] = pthis->markers[0]; + pthis->numTargets = 1; break; case SYATEKI_ROUND_BLUE_SEQUENTIAL: - Math_Vec3f_Copy(&this->targetHome[0], &sBlueSeqHome1); - Math_Vec3f_Copy(&this->targetHome[1], &sBlueSeqHome2); - Math_Vec3f_Copy(&this->targetFinal[0], &sBlueSeqFinal1); - Math_Vec3f_Copy(&this->targetFinal[1], &sBlueSeqFinal2); - this->curMarkers[0] = this->markers[1]; - this->curMarkers[1] = this->markers[2]; + Math_Vec3f_Copy(&pthis->targetHome[0], &sBlueSeqHome1); + Math_Vec3f_Copy(&pthis->targetHome[1], &sBlueSeqHome2); + Math_Vec3f_Copy(&pthis->targetFinal[0], &sBlueSeqFinal1); + Math_Vec3f_Copy(&pthis->targetFinal[1], &sBlueSeqFinal2); + pthis->curMarkers[0] = pthis->markers[1]; + pthis->curMarkers[1] = pthis->markers[2]; break; case SYATEKI_ROUND_GREEN_THROW: - Math_Vec3f_Copy(&this->targetHome[0], &sGreenThrowHome); - Math_Vec3f_Copy(&this->targetFinal[0], &sGreenThrowFinal); - this->curMarkers[0] = this->markers[3]; - this->numTargets = 1; + Math_Vec3f_Copy(&pthis->targetHome[0], &sGreenThrowHome); + Math_Vec3f_Copy(&pthis->targetFinal[0], &sGreenThrowFinal); + pthis->curMarkers[0] = pthis->markers[3]; + pthis->numTargets = 1; break; case SYATEKI_ROUND_BLUE_SIMUL: - Math_Vec3f_Copy(&this->targetHome[0], &sBlueSimulHome1); - Math_Vec3f_Copy(&this->targetHome[1], &sBlueSimulHome2); - Math_Vec3f_Copy(&this->targetFinal[0], &sBlueSimulFinal1); - Math_Vec3f_Copy(&this->targetFinal[1], &sBlueSimulFinal2); - this->curMarkers[0] = this->markers[4]; - this->curMarkers[1] = this->markers[5]; + Math_Vec3f_Copy(&pthis->targetHome[0], &sBlueSimulHome1); + Math_Vec3f_Copy(&pthis->targetHome[1], &sBlueSimulHome2); + Math_Vec3f_Copy(&pthis->targetFinal[0], &sBlueSimulFinal1); + Math_Vec3f_Copy(&pthis->targetFinal[1], &sBlueSimulFinal2); + pthis->curMarkers[0] = pthis->markers[4]; + pthis->curMarkers[1] = pthis->markers[5]; break; case SYATEKI_ROUND_RED_LEFT: - Math_Vec3f_Copy(&this->targetHome[0], &sRedLeftHome1); - Math_Vec3f_Copy(&this->targetHome[1], &sRedLeftHome2); - Math_Vec3f_Copy(&this->targetFinal[0], &sRedLeftFinal1); - Math_Vec3f_Copy(&this->targetFinal[1], &sRedLeftFinal2); - this->curMarkers[0] = this->markers[6]; - this->curMarkers[1] = this->markers[7]; + Math_Vec3f_Copy(&pthis->targetHome[0], &sRedLeftHome1); + Math_Vec3f_Copy(&pthis->targetHome[1], &sRedLeftHome2); + Math_Vec3f_Copy(&pthis->targetFinal[0], &sRedLeftFinal1); + Math_Vec3f_Copy(&pthis->targetFinal[1], &sRedLeftFinal2); + pthis->curMarkers[0] = pthis->markers[6]; + pthis->curMarkers[1] = pthis->markers[7]; break; case SYATEKI_ROUND_RED_RIGHT: - Math_Vec3f_Copy(&this->targetHome[0], &sRedRightHome1); - Math_Vec3f_Copy(&this->targetHome[1], &sRedRightHome2); - Math_Vec3f_Copy(&this->targetFinal[0], &sRedRightFinal1); - Math_Vec3f_Copy(&this->targetFinal[1], &sRedRightFinal2); - this->curMarkers[0] = this->markers[8]; - this->curMarkers[1] = this->markers[9]; + Math_Vec3f_Copy(&pthis->targetHome[0], &sRedRightHome1); + Math_Vec3f_Copy(&pthis->targetHome[1], &sRedRightHome2); + Math_Vec3f_Copy(&pthis->targetFinal[0], &sRedRightFinal1); + Math_Vec3f_Copy(&pthis->targetFinal[1], &sRedRightFinal2); + pthis->curMarkers[0] = pthis->markers[8]; + pthis->curMarkers[1] = pthis->markers[9]; break; } - for (i = 0; i < this->numTargets; i++) { - this->targets[i] = (EnGSwitch*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_G_SWITCH, this->targetHome[i].x, - this->targetHome[i].y, this->targetHome[i].z, 0, 0, 0, (ENGSWITCH_TARGET_RUPEE << 0xC) | 0x3F); - if (this->targets[i] == NULL) { + for (i = 0; i < pthis->numTargets; i++) { + pthis->targets[i] = (EnGSwitch*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_G_SWITCH, pthis->targetHome[i].x, + pthis->targetHome[i].y, pthis->targetHome[i].z, 0, 0, 0, (ENGSWITCH_TARGET_RUPEE << 0xC) | 0x3F); + if (pthis->targets[i] == NULL) { // "Rupee spawn error" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ルピーでエラー原 ☆☆☆☆ \n" VT_RST); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - this->targets[i]->index = i; - this->targets[i]->colorIdx = sTargetColors[roundIdx]; - Math_Vec3f_Copy(&this->targets[i]->targetPos, &this->targetFinal[i]); + pthis->targets[i]->index = i; + pthis->targets[i]->colorIdx = sTargetColors[roundIdx]; + Math_Vec3f_Copy(&pthis->targets[i]->targetPos, &pthis->targetFinal[i]); switch (roundIdx) { case SYATEKI_ROUND_BLUE_SEQUENTIAL: if (i == 1) { - this->targets[i]->delayTimer = 60; + pthis->targets[i]->delayTimer = 60; } break; case SYATEKI_ROUND_GREEN_THROW: - this->targets[i]->actor.velocity.y = 15.0f; - this->targets[i]->actor.gravity = -1.0f; - this->targets[i]->moveMode = GSWITCH_THROW; + pthis->targets[i]->actor.velocity.y = 15.0f; + pthis->targets[i]->actor.gravity = -1.0f; + pthis->targets[i]->moveMode = GSWITCH_THROW; break; case SYATEKI_ROUND_RED_LEFT: - this->targets[i]->actor.velocity.x = -5.0f; - this->targets[i]->moveMode = GSWITCH_LEFT; + pthis->targets[i]->actor.velocity.x = -5.0f; + pthis->targets[i]->moveMode = GSWITCH_LEFT; break; case SYATEKI_ROUND_RED_RIGHT: - this->targets[i]->actor.velocity.x = 7.0f; - this->targets[i]->moveMode = GSWITCH_RIGHT; + pthis->targets[i]->actor.velocity.x = 7.0f; + pthis->targets[i]->moveMode = GSWITCH_RIGHT; break; } } - this->targetState[0] = this->targetState[1] = ENSYATEKIHIT_NONE; - this->actionFunc = EnSyatekiItm_CheckTargets; + pthis->targetState[0] = pthis->targetState[1] = ENSYATEKIHIT_NONE; + pthis->actionFunc = EnSyatekiItm_CheckTargets; } } -void EnSyatekiItm_CheckTargets(EnSyatekiItm* this, GlobalContext* globalCtx) { +void EnSyatekiItm_CheckTargets(EnSyatekiItm* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; s16 j; if (globalCtx->shootingGalleryStatus == -1) { player->actor.freezeTimer = 10; - this->signal = ENSYATEKI_END; - this->actionFunc = EnSyatekiItm_CleanupGame; + pthis->signal = ENSYATEKI_END; + pthis->actionFunc = EnSyatekiItm_CleanupGame; } else { for (i = 0, j = 0; i < 2; i++) { - if (this->targetState[i] != ENSYATEKIHIT_NONE) { - if (this->targetState[i] == ENSYATEKIHIT_HIT) { - this->curMarkers[i]->galleryFlag = true; + if (pthis->targetState[i] != ENSYATEKIHIT_NONE) { + if (pthis->targetState[i] == ENSYATEKIHIT_HIT) { + pthis->curMarkers[i]->galleryFlag = true; } j++; } } - if (j == this->numTargets) { - this->actionFunc = EnSyatekiItm_StartRound; + if (j == pthis->numTargets) { + pthis->actionFunc = EnSyatekiItm_StartRound; } } } -void EnSyatekiItm_CleanupGame(EnSyatekiItm* this, GlobalContext* globalCtx) { +void EnSyatekiItm_CleanupGame(EnSyatekiItm* pthis, GlobalContext* globalCtx) { s32 i; for (i = 0; i < 2; i++) { - if ((this->targetState[i] == ENSYATEKIHIT_NONE) && (this->targets[i] != NULL)) { - Actor_Kill(&this->targets[i]->actor); + if ((pthis->targetState[i] == ENSYATEKIHIT_NONE) && (pthis->targets[i] != NULL)) { + Actor_Kill(&pthis->targets[i]->actor); } } - this->actionFunc = EnSyatekiItm_EndGame; + pthis->actionFunc = EnSyatekiItm_EndGame; } -void EnSyatekiItm_EndGame(EnSyatekiItm* this, GlobalContext* globalCtx) { +void EnSyatekiItm_EndGame(EnSyatekiItm* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); player->actor.freezeTimer = 10; - if (this->signal == ENSYATEKI_RESULTS) { - this->signal = ENSYATEKI_NONE; - this->actionFunc = EnSyatekiItm_Idle; + if (pthis->signal == ENSYATEKI_RESULTS) { + pthis->signal = ENSYATEKI_NONE; + pthis->actionFunc = EnSyatekiItm_Idle; } - if (this->signal == ENSYATEKI_START) { + if (pthis->signal == ENSYATEKI_START) { // "1 frame attack and defense!" osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 1フレームの攻防! ☆☆☆☆ \n" VT_RST); osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 1フレームの攻防! ☆☆☆☆ \n" VT_RST); @@ -331,21 +331,21 @@ void EnSyatekiItm_EndGame(EnSyatekiItm* this, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 1フレームの攻防! ☆☆☆☆ \n" VT_RST); osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 1フレームの攻防! ☆☆☆☆ \n" VT_RST); osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 1フレームの攻防! ☆☆☆☆ \n" VT_RST); - this->signal = ENSYATEKI_NONE; - this->actionFunc = EnSyatekiItm_Idle; + pthis->signal = ENSYATEKI_NONE; + pthis->actionFunc = EnSyatekiItm_Idle; } } void EnSyatekiItm_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnSyatekiItm* this = (EnSyatekiItm*)thisx; + EnSyatekiItm* pthis = (EnSyatekiItm*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - if (this->unkTimer != 0) { - this->unkTimer--; + if (pthis->unkTimer != 0) { + pthis->unkTimer--; } } diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c deleted file mode 100644 index 189dde90f..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ /dev/null @@ -1,523 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SYATEKI_MAN_Z_EN_SYATEKI_MAN_C -#include "actor_common.h" -#include "z_en_syateki_man.h" -#include "vt.h" -#include "overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.h" -#include "objects/object_ossan/object_ossan.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_27) - -typedef enum { - /* 0 */ SYATEKI_RESULT_NONE, - /* 1 */ SYATEKI_RESULT_WINNER, - /* 2 */ SYATEKI_RESULT_ALMOST, - /* 3 */ SYATEKI_RESULT_FAILURE, - /* 4 */ SYATEKI_RESULT_REFUSE -} EnSyatekiManGameResult; - -typedef enum { - /* 0 */ SYATEKI_TEXT_CHOICE, - /* 1 */ SYATEKI_TEXT_START_GAME, - /* 2 */ SYATEKI_TEXT_NO_RUPEES, - /* 3 */ SYATEKI_TEXT_REFUSE -} EnSyatekiManTextIdx; - -void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnSyatekiMan_Start(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_SetupIdle(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_Idle(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_Talk(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_StopTalk(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_StartGame(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_WaitForGame(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_GivePrize(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_FinishPrize(EnSyatekiMan* this, GlobalContext* globalCtx); -void EnSyatekiMan_RestartGame(EnSyatekiMan* this, GlobalContext* globalCtx); - -void EnSyatekiMan_BlinkWait(EnSyatekiMan* this); -void EnSyatekiMan_Blink(EnSyatekiMan* this); - -void EnSyatekiMan_SetBgm(void); - -const ActorInit En_Syateki_Man_InitVars = { - ACTOR_EN_SYATEKI_MAN, - ACTORCAT_NPC, - FLAGS, - OBJECT_OSSAN, - sizeof(EnSyatekiMan), - (ActorFunc)EnSyatekiMan_Init, - (ActorFunc)EnSyatekiMan_Destroy, - (ActorFunc)EnSyatekiMan_Update, - (ActorFunc)EnSyatekiMan_Draw, -}; - -static u16 sBgmList[] = { - NA_BGM_GENERAL_SFX, - NA_BGM_NATURE_AMBIENCE, - NA_BGM_FIELD_LOGIC, - NA_BGM_DUNGEON, - NA_BGM_KAKARIKO_ADULT, - NA_BGM_FIELD_LOGIC, - NA_BGM_KAKARIKO_ADULT, - NA_BGM_ENEMY, - NA_BGM_ENEMY, - NA_BGM_ENEMY | 0x800, - NA_BGM_BOSS, - NA_BGM_INSIDE_DEKU_TREE, - NA_BGM_MARKET, - NA_BGM_TITLE, - NA_BGM_LINK_HOUSE, - NA_BGM_GAME_OVER, - NA_BGM_BOSS_CLEAR, - NA_BGM_ITEM_GET | 0x900, - NA_BGM_OPENING_GANON, - NA_BGM_HEART_GET | 0x900, - NA_BGM_OCA_LIGHT, - NA_BGM_JABU_JABU, - NA_BGM_KAKARIKO_KID, - NA_BGM_GREAT_FAIRY, - NA_BGM_ZELDA_THEME, - NA_BGM_FIRE_TEMPLE, - NA_BGM_OPEN_TRE_BOX | 0x900, - NA_BGM_FOREST_TEMPLE, - NA_BGM_COURTYARD, - NA_BGM_GANON_TOWER, - NA_BGM_LONLON, - NA_BGM_GORON_CITY, - NA_BGM_SPIRITUAL_STONE, - NA_BGM_OCA_BOLERO, - NA_BGM_OCA_MINUET, - NA_BGM_OCA_SERENADE, - NA_BGM_OCA_REQUIEM, - NA_BGM_OCA_NOCTURNE, - NA_BGM_MINI_BOSS, - NA_BGM_SMALL_ITEM_GET, - NA_BGM_TEMPLE_OF_TIME, - NA_BGM_EVENT_CLEAR, - NA_BGM_KOKIRI, - NA_BGM_OCA_FAIRY_GET, - NA_BGM_SARIA_THEME, - NA_BGM_SPIRIT_TEMPLE, - NA_BGM_HORSE, - NA_BGM_HORSE_GOAL, - NA_BGM_INGO, - NA_BGM_MEDALLION_GET, - NA_BGM_OCA_SARIA, - NA_BGM_OCA_EPONA, - NA_BGM_OCA_ZELDA, - NA_BGM_OCA_SUNS, - NA_BGM_OCA_TIME, - NA_BGM_OCA_STORM, - NA_BGM_NAVI_OPENING, - NA_BGM_DEKU_TREE_CS, - NA_BGM_WINDMILL, - NA_BGM_HYRULE_CS, - NA_BGM_MINI_GAME, - NA_BGM_SHEIK, - NA_BGM_ZORA_DOMAIN, - NA_BGM_APPEAR, - NA_BGM_ADULT_LINK, - NA_BGM_MASTER_SWORD, - NA_BGM_INTRO_GANON, - NA_BGM_SHOP, - NA_BGM_CHAMBER_OF_SAGES, - NA_BGM_FILE_SELECT, - NA_BGM_ICE_CAVERN, - NA_BGM_DOOR_OF_TIME, - NA_BGM_OWL, - NA_BGM_SHADOW_TEMPLE, - NA_BGM_WATER_TEMPLE, - NA_BGM_BRIDGE_TO_GANONS, - NA_BGM_VARIOUS_SFX, - NA_BGM_OCARINA_OF_TIME, - NA_BGM_OCARINA_OF_TIME, - NA_BGM_GERUDO_VALLEY, - NA_BGM_POTION_SHOP, - NA_BGM_KOTAKE_KOUME, - NA_BGM_VARIOUS_SFX, - NA_BGM_ESCAPE, - NA_BGM_UNDERGROUND, - NA_BGM_GANONDORF_BOSS, - NA_BGM_GANON_BOSS, - NA_BGM_END_DEMO, -}; - -static s16 sTextIds[] = { 0x2B, 0x2E, 0xC8, 0x2D }; - -static s16 sTextBoxCount[] = { TEXT_STATE_CHOICE, TEXT_STATE_EVENT, TEXT_STATE_EVENT, TEXT_STATE_EVENT }; - -void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSyatekiMan* this = (EnSyatekiMan*)thisx; - - osSyncPrintf("\n\n"); - // "Old man appeared!! Muhohohohohohohon" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 親父登場!!むほほほほほほほーん ☆☆☆☆☆ \n" VT_RST); - this->actor.targetMode = 1; - Actor_SetScale(&this->actor, 0.01f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectOssanSkel, &gObjectOssanAnim_000338, this->jointTable, - this->morphTable, 9); - if (!LINK_IS_ADULT) { - this->headRot.z = 20; - } - this->blinkTimer = 20; - this->eyeState = 0; - this->blinkFunc = EnSyatekiMan_BlinkWait; - this->actor.colChkInfo.cylRadius = 100; - this->actionFunc = EnSyatekiMan_Start; -} - -void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnSyatekiMan_Start(EnSyatekiMan* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gObjectOssanAnim_000338); - - Animation_Change(&this->skelAnime, &gObjectOssanAnim_000338, 1.0f, 0.0f, (s16)lastFrame, ANIMMODE_LOOP, -10.0f); - this->actionFunc = EnSyatekiMan_SetupIdle; -} - -void EnSyatekiMan_SetupIdle(EnSyatekiMan* this, GlobalContext* globalCtx) { - if (this->gameResult == SYATEKI_RESULT_REFUSE) { - this->textIdx = SYATEKI_TEXT_REFUSE; - } - - this->actor.textId = sTextIds[this->textIdx]; - this->numTextBox = sTextBoxCount[this->textIdx]; - this->actionFunc = EnSyatekiMan_Idle; -} - -void EnSyatekiMan_Idle(EnSyatekiMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = EnSyatekiMan_Talk; - } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } -} - -void EnSyatekiMan_Talk(EnSyatekiMan* this, GlobalContext* globalCtx) { - s16 nextState = 0; - - SkelAnime_Update(&this->skelAnime); - if (this->cameraHold) { - globalCtx->shootingGalleryStatus = -2; - } - if ((this->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - if (this->textIdx == SYATEKI_TEXT_CHOICE) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - if (gSaveContext.rupees >= 20) { - Rupees_ChangeBy(-20); - this->textIdx = SYATEKI_TEXT_START_GAME; - nextState = 1; - } else { - this->textIdx = SYATEKI_TEXT_NO_RUPEES; - nextState = 2; - } - this->actor.textId = sTextIds[this->textIdx]; - this->numTextBox = sTextBoxCount[this->textIdx]; - break; - case 1: - this->actor.textId = sTextIds[SYATEKI_TEXT_REFUSE]; - this->numTextBox = sTextBoxCount[SYATEKI_TEXT_REFUSE]; - nextState = 2; - break; - } - Message_ContinueTextbox(globalCtx, this->actor.textId); - } else { - Message_CloseTextbox(globalCtx); - } - switch (nextState) { - case 0: - this->actionFunc = EnSyatekiMan_SetupIdle; - break; - case 1: - this->actionFunc = EnSyatekiMan_StartGame; - break; - case 2: - this->actionFunc = EnSyatekiMan_StopTalk; - break; - } - } -} - -void EnSyatekiMan_StopTalk(EnSyatekiMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->cameraHold) { - globalCtx->shootingGalleryStatus = -2; - } - if ((this->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - if (this->cameraHold) { - OnePointCutscene_EndCutscene(globalCtx, this->csCam); - this->csCam = SUBCAM_NONE; - this->cameraHold = false; - } - Message_CloseTextbox(globalCtx); - this->actionFunc = EnSyatekiMan_SetupIdle; - } -} - -void EnSyatekiMan_StartGame(EnSyatekiMan* this, GlobalContext* globalCtx) { - EnSyatekiItm* gallery; - - SkelAnime_Update(&this->skelAnime); - if (this->cameraHold) { - globalCtx->shootingGalleryStatus = -2; - } - if ((this->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - if (this->cameraHold) { - OnePointCutscene_EndCutscene(globalCtx, this->csCam); - this->csCam = SUBCAM_NONE; - this->cameraHold = false; - } - Message_CloseTextbox(globalCtx); - gallery = ((EnSyatekiItm*)this->actor.parent); - if (gallery->actor.update != NULL) { - gallery->signal = ENSYATEKI_START; - this->actionFunc = EnSyatekiMan_WaitForGame; - } - } -} - -void EnSyatekiMan_WaitForGame(EnSyatekiMan* this, GlobalContext* globalCtx) { - EnSyatekiItm* gallery; - - SkelAnime_Update(&this->skelAnime); - if (1) {} - gallery = ((EnSyatekiItm*)this->actor.parent); - if ((gallery->actor.update != NULL) && (gallery->signal == ENSYATEKI_END)) { - this->csCam = OnePointCutscene_Init(globalCtx, 8002, -99, &this->actor, MAIN_CAM); - switch (gallery->hitCount) { - case 10: - this->gameResult = SYATEKI_RESULT_WINNER; - this->actor.textId = 0x71AF; - break; - case 8: - case 9: - this->gameResult = SYATEKI_RESULT_ALMOST; - this->actor.textId = 0x71AE; - break; - default: - this->gameResult = SYATEKI_RESULT_FAILURE; - this->actor.textId = 0x71AD; - if (globalCtx->shootingGalleryStatus == 15 + 1) { - this->gameResult = SYATEKI_RESULT_REFUSE; - this->actor.textId = 0x2D; - } - break; - } - globalCtx->shootingGalleryStatus = -2; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->actionFunc = EnSyatekiMan_EndGame; - } -} - -void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { - EnSyatekiItm* gallery; - - SkelAnime_Update(&this->skelAnime); - if ((this->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - if (this->gameResult != SYATEKI_RESULT_FAILURE) { - OnePointCutscene_EndCutscene(globalCtx, this->csCam); - this->csCam = SUBCAM_NONE; - } - Message_CloseTextbox(globalCtx); - gallery = ((EnSyatekiItm*)this->actor.parent); - if (gallery->actor.update != NULL) { - gallery->signal = ENSYATEKI_RESULTS; - this->textIdx = 0; - switch (this->gameResult) { - case SYATEKI_RESULT_WINNER: - this->tempGallery = this->actor.parent; - this->actor.parent = NULL; - if (!LINK_IS_ADULT) { - if (!(gSaveContext.itemGetInf[0] & 0x2000)) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ Equip_Pachinko ☆☆☆☆☆ %d\n" VT_RST, - CUR_UPG_VALUE(UPG_BULLET_BAG)); - if (CUR_UPG_VALUE(UPG_BULLET_BAG) == 1) { - this->getItemId = GI_BULLET_BAG_40; - } else { - this->getItemId = GI_BULLET_BAG_50; - } - } else { - this->getItemId = GI_RUPEE_PURPLE; - } - } else { - if (!(gSaveContext.itemGetInf[0] & 0x4000)) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ Equip_Bow ☆☆☆☆☆ %d\n" VT_RST, - CUR_UPG_VALUE(UPG_QUIVER)); - switch (CUR_UPG_VALUE(UPG_QUIVER)) { - case 0: - this->getItemId = GI_RUPEE_PURPLE; - break; - case 1: - this->getItemId = GI_QUIVER_40; - break; - case 2: - this->getItemId = GI_QUIVER_50; - break; - } - } else { - this->getItemId = GI_RUPEE_PURPLE; - } - } - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); - this->actionFunc = EnSyatekiMan_GivePrize; - break; - case SYATEKI_RESULT_ALMOST: - this->timer = 20; - func_8008EF44(globalCtx, 15); - this->actionFunc = EnSyatekiMan_RestartGame; - break; - default: - if (this->gameResult == SYATEKI_RESULT_REFUSE) { - this->actionFunc = EnSyatekiMan_SetupIdle; - } else { - this->cameraHold = true; - this->actor.textId = sTextIds[this->textIdx]; - this->numTextBox = sTextBoxCount[this->textIdx]; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->actionFunc = EnSyatekiMan_Talk; - } - break; - } - } - } -} - -void EnSyatekiMan_GivePrize(EnSyatekiMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = EnSyatekiMan_FinishPrize; - } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); - } -} - -void EnSyatekiMan_FinishPrize(EnSyatekiMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - // "Successful completion" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); - if (!LINK_IS_ADULT) { - gSaveContext.itemGetInf[0] |= 0x2000; - } else if ((this->getItemId == GI_QUIVER_40) || (this->getItemId == GI_QUIVER_50)) { - gSaveContext.itemGetInf[0] |= 0x4000; - } - this->gameResult = SYATEKI_RESULT_NONE; - this->actor.parent = this->tempGallery; - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = EnSyatekiMan_SetupIdle; - } -} - -void EnSyatekiMan_RestartGame(EnSyatekiMan* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer == 0) { - EnSyatekiItm* gallery = ((EnSyatekiItm*)this->actor.parent); - - if (gallery->actor.update != NULL) { - gallery->signal = ENSYATEKI_START; - this->gameResult = SYATEKI_RESULT_NONE; - this->actionFunc = EnSyatekiMan_WaitForGame; - // "Let's try again! Baby!" - osSyncPrintf(VT_FGCOL(BLUE) "再挑戦だぜ!ベイビー!" VT_RST "\n", this); - } - } -} - -void EnSyatekiMan_BlinkWait(EnSyatekiMan* this) { - s16 decrBlinkTimer = this->blinkTimer - 1; - - if (decrBlinkTimer != 0) { - this->blinkTimer = decrBlinkTimer; - } else { - this->blinkFunc = EnSyatekiMan_Blink; - } -} - -void EnSyatekiMan_Blink(EnSyatekiMan* this) { - s16 decrBlinkTimer = this->blinkTimer - 1; - - if (decrBlinkTimer != 0) { - this->blinkTimer = decrBlinkTimer; - } else { - s16 nextEyeState = this->eyeState + 1; - - if (nextEyeState >= 3) { - this->eyeState = 0; - this->blinkTimer = 20 + (s32)(Rand_ZeroOne() * 60.0f); - this->blinkFunc = EnSyatekiMan_BlinkWait; - } else { - this->eyeState = nextEyeState; - this->blinkTimer = 1; - } - } -} - -void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSyatekiMan* this = (EnSyatekiMan*)thisx; - - if (this->timer != 0) { - this->timer--; - } - this->actionFunc(this, globalCtx); - EnSyatekiMan_SetBgm(); - this->blinkFunc(this); - this->actor.focus.pos.y = 70.0f; - Actor_SetFocus(&this->actor, 70.0f); - func_80038290(globalCtx, &this->actor, &this->headRot, &this->bodyRot, this->actor.focus.pos); -} - -s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnSyatekiMan* this = (EnSyatekiMan*)thisx; - s32 turnDirection; - - if (limbIndex == 1) { - rot->x += this->bodyRot.y; - } - if (limbIndex == 8) { - *dList = gObjectOssanEnSyatekiManDL_007E28; - turnDirection = 1; - if (this->gameResult == SYATEKI_RESULT_REFUSE) { - turnDirection = -1; - } - rot->x += this->headRot.y * turnDirection; - rot->z += this->headRot.z; - } - return 0; -} - -void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnSyatekiMan* this = (EnSyatekiMan*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSyatekiMan_OverrideLimbDraw, NULL, this); -} - -void EnSyatekiMan_SetBgm(void) { - if (BREG(80)) { - BREG(80) = false; - Audio_QueueSeqCmd(sBgmList[BREG(81)]); - } -} diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.cpp b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.cpp new file mode 100644 index 000000000..f1da90aff --- /dev/null +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.cpp @@ -0,0 +1,523 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SYATEKI_MAN_Z_EN_SYATEKI_MAN_C +#include "actor_common.h" +#include "z_en_syateki_man.h" +#include "vt.h" +#include "overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.h" +#include "objects/object_ossan/object_ossan.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_27) + +typedef enum { + /* 0 */ SYATEKI_RESULT_NONE, + /* 1 */ SYATEKI_RESULT_WINNER, + /* 2 */ SYATEKI_RESULT_ALMOST, + /* 3 */ SYATEKI_RESULT_FAILURE, + /* 4 */ SYATEKI_RESULT_REFUSE +} EnSyatekiManGameResult; + +typedef enum { + /* 0 */ SYATEKI_TEXT_CHOICE, + /* 1 */ SYATEKI_TEXT_START_GAME, + /* 2 */ SYATEKI_TEXT_NO_RUPEES, + /* 3 */ SYATEKI_TEXT_REFUSE +} EnSyatekiManTextIdx; + +void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSyatekiMan_Start(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_SetupIdle(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_Idle(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_Talk(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_StopTalk(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_StartGame(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_WaitForGame(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_EndGame(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_GivePrize(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_FinishPrize(EnSyatekiMan* pthis, GlobalContext* globalCtx); +void EnSyatekiMan_RestartGame(EnSyatekiMan* pthis, GlobalContext* globalCtx); + +void EnSyatekiMan_BlinkWait(EnSyatekiMan* pthis); +void EnSyatekiMan_Blink(EnSyatekiMan* pthis); + +void EnSyatekiMan_SetBgm(void); + +ActorInit En_Syateki_Man_InitVars = { + ACTOR_EN_SYATEKI_MAN, + ACTORCAT_NPC, + FLAGS, + OBJECT_OSSAN, + sizeof(EnSyatekiMan), + (ActorFunc)EnSyatekiMan_Init, + (ActorFunc)EnSyatekiMan_Destroy, + (ActorFunc)EnSyatekiMan_Update, + (ActorFunc)EnSyatekiMan_Draw, +}; + +static u16 sBgmList[] = { + NA_BGM_GENERAL_SFX, + NA_BGM_NATURE_AMBIENCE, + NA_BGM_FIELD_LOGIC, + NA_BGM_DUNGEON, + NA_BGM_KAKARIKO_ADULT, + NA_BGM_FIELD_LOGIC, + NA_BGM_KAKARIKO_ADULT, + NA_BGM_ENEMY, + NA_BGM_ENEMY, + NA_BGM_ENEMY | 0x800, + NA_BGM_BOSS, + NA_BGM_INSIDE_DEKU_TREE, + NA_BGM_MARKET, + NA_BGM_TITLE, + NA_BGM_LINK_HOUSE, + NA_BGM_GAME_OVER, + NA_BGM_BOSS_CLEAR, + NA_BGM_ITEM_GET | 0x900, + NA_BGM_OPENING_GANON, + NA_BGM_HEART_GET | 0x900, + NA_BGM_OCA_LIGHT, + NA_BGM_JABU_JABU, + NA_BGM_KAKARIKO_KID, + NA_BGM_GREAT_FAIRY, + NA_BGM_ZELDA_THEME, + NA_BGM_FIRE_TEMPLE, + NA_BGM_OPEN_TRE_BOX | 0x900, + NA_BGM_FOREST_TEMPLE, + NA_BGM_COURTYARD, + NA_BGM_GANON_TOWER, + NA_BGM_LONLON, + NA_BGM_GORON_CITY, + NA_BGM_SPIRITUAL_STONE, + NA_BGM_OCA_BOLERO, + NA_BGM_OCA_MINUET, + NA_BGM_OCA_SERENADE, + NA_BGM_OCA_REQUIEM, + NA_BGM_OCA_NOCTURNE, + NA_BGM_MINI_BOSS, + NA_BGM_SMALL_ITEM_GET, + NA_BGM_TEMPLE_OF_TIME, + NA_BGM_EVENT_CLEAR, + NA_BGM_KOKIRI, + NA_BGM_OCA_FAIRY_GET, + NA_BGM_SARIA_THEME, + NA_BGM_SPIRIT_TEMPLE, + NA_BGM_HORSE, + NA_BGM_HORSE_GOAL, + NA_BGM_INGO, + NA_BGM_MEDALLION_GET, + NA_BGM_OCA_SARIA, + NA_BGM_OCA_EPONA, + NA_BGM_OCA_ZELDA, + NA_BGM_OCA_SUNS, + NA_BGM_OCA_TIME, + NA_BGM_OCA_STORM, + NA_BGM_NAVI_OPENING, + NA_BGM_DEKU_TREE_CS, + NA_BGM_WINDMILL, + NA_BGM_HYRULE_CS, + NA_BGM_MINI_GAME, + NA_BGM_SHEIK, + NA_BGM_ZORA_DOMAIN, + NA_BGM_APPEAR, + NA_BGM_ADULT_LINK, + NA_BGM_MASTER_SWORD, + NA_BGM_INTRO_GANON, + NA_BGM_SHOP, + NA_BGM_CHAMBER_OF_SAGES, + NA_BGM_FILE_SELECT, + NA_BGM_ICE_CAVERN, + NA_BGM_DOOR_OF_TIME, + NA_BGM_OWL, + NA_BGM_SHADOW_TEMPLE, + NA_BGM_WATER_TEMPLE, + NA_BGM_BRIDGE_TO_GANONS, + NA_BGM_VARIOUS_SFX, + NA_BGM_OCARINA_OF_TIME, + NA_BGM_OCARINA_OF_TIME, + NA_BGM_GERUDO_VALLEY, + NA_BGM_POTION_SHOP, + NA_BGM_KOTAKE_KOUME, + NA_BGM_VARIOUS_SFX, + NA_BGM_ESCAPE, + NA_BGM_UNDERGROUND, + NA_BGM_GANONDORF_BOSS, + NA_BGM_GANON_BOSS, + NA_BGM_END_DEMO, +}; + +static s16 sTextIds[] = { 0x2B, 0x2E, 0xC8, 0x2D }; + +static s16 sTextBoxCount[] = { TEXT_STATE_CHOICE, TEXT_STATE_EVENT, TEXT_STATE_EVENT, TEXT_STATE_EVENT }; + +void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiMan* pthis = (EnSyatekiMan*)thisx; + + osSyncPrintf("\n\n"); + // "Old man appeared!! Muhohohohohohohon" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 親父登場!!むほほほほほほほーん ☆☆☆☆☆ \n" VT_RST); + pthis->actor.targetMode = 1; + Actor_SetScale(&pthis->actor, 0.01f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gObjectOssanSkel, &gObjectOssanAnim_000338, pthis->jointTable, + pthis->morphTable, 9); + if (!LINK_IS_ADULT) { + pthis->headRot.z = 20; + } + pthis->blinkTimer = 20; + pthis->eyeState = 0; + pthis->blinkFunc = EnSyatekiMan_BlinkWait; + pthis->actor.colChkInfo.cylRadius = 100; + pthis->actionFunc = EnSyatekiMan_Start; +} + +void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSyatekiMan_Start(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gObjectOssanAnim_000338); + + Animation_Change(&pthis->skelAnime, &gObjectOssanAnim_000338, 1.0f, 0.0f, (s16)lastFrame, ANIMMODE_LOOP, -10.0f); + pthis->actionFunc = EnSyatekiMan_SetupIdle; +} + +void EnSyatekiMan_SetupIdle(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + if (pthis->gameResult == SYATEKI_RESULT_REFUSE) { + pthis->textIdx = SYATEKI_TEXT_REFUSE; + } + + pthis->actor.textId = sTextIds[pthis->textIdx]; + pthis->numTextBox = sTextBoxCount[pthis->textIdx]; + pthis->actionFunc = EnSyatekiMan_Idle; +} + +void EnSyatekiMan_Idle(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnSyatekiMan_Talk; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } +} + +void EnSyatekiMan_Talk(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + s16 nextState = 0; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->cameraHold) { + globalCtx->shootingGalleryStatus = -2; + } + if ((pthis->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (pthis->textIdx == SYATEKI_TEXT_CHOICE) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees >= 20) { + Rupees_ChangeBy(-20); + pthis->textIdx = SYATEKI_TEXT_START_GAME; + nextState = 1; + } else { + pthis->textIdx = SYATEKI_TEXT_NO_RUPEES; + nextState = 2; + } + pthis->actor.textId = sTextIds[pthis->textIdx]; + pthis->numTextBox = sTextBoxCount[pthis->textIdx]; + break; + case 1: + pthis->actor.textId = sTextIds[SYATEKI_TEXT_REFUSE]; + pthis->numTextBox = sTextBoxCount[SYATEKI_TEXT_REFUSE]; + nextState = 2; + break; + } + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + } else { + Message_CloseTextbox(globalCtx); + } + switch (nextState) { + case 0: + pthis->actionFunc = EnSyatekiMan_SetupIdle; + break; + case 1: + pthis->actionFunc = EnSyatekiMan_StartGame; + break; + case 2: + pthis->actionFunc = EnSyatekiMan_StopTalk; + break; + } + } +} + +void EnSyatekiMan_StopTalk(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->cameraHold) { + globalCtx->shootingGalleryStatus = -2; + } + if ((pthis->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (pthis->cameraHold) { + OnePointCutscene_EndCutscene(globalCtx, pthis->csCam); + pthis->csCam = SUBCAM_NONE; + pthis->cameraHold = false; + } + Message_CloseTextbox(globalCtx); + pthis->actionFunc = EnSyatekiMan_SetupIdle; + } +} + +void EnSyatekiMan_StartGame(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + EnSyatekiItm* gallery; + + SkelAnime_Update(&pthis->skelAnime); + if (pthis->cameraHold) { + globalCtx->shootingGalleryStatus = -2; + } + if ((pthis->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (pthis->cameraHold) { + OnePointCutscene_EndCutscene(globalCtx, pthis->csCam); + pthis->csCam = SUBCAM_NONE; + pthis->cameraHold = false; + } + Message_CloseTextbox(globalCtx); + gallery = ((EnSyatekiItm*)pthis->actor.parent); + if (gallery->actor.update != NULL) { + gallery->signal = ENSYATEKI_START; + pthis->actionFunc = EnSyatekiMan_WaitForGame; + } + } +} + +void EnSyatekiMan_WaitForGame(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + EnSyatekiItm* gallery; + + SkelAnime_Update(&pthis->skelAnime); + if (1) {} + gallery = ((EnSyatekiItm*)pthis->actor.parent); + if ((gallery->actor.update != NULL) && (gallery->signal == ENSYATEKI_END)) { + pthis->csCam = OnePointCutscene_Init(globalCtx, 8002, -99, &pthis->actor, MAIN_CAM); + switch (gallery->hitCount) { + case 10: + pthis->gameResult = SYATEKI_RESULT_WINNER; + pthis->actor.textId = 0x71AF; + break; + case 8: + case 9: + pthis->gameResult = SYATEKI_RESULT_ALMOST; + pthis->actor.textId = 0x71AE; + break; + default: + pthis->gameResult = SYATEKI_RESULT_FAILURE; + pthis->actor.textId = 0x71AD; + if (globalCtx->shootingGalleryStatus == 15 + 1) { + pthis->gameResult = SYATEKI_RESULT_REFUSE; + pthis->actor.textId = 0x2D; + } + break; + } + globalCtx->shootingGalleryStatus = -2; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->actionFunc = EnSyatekiMan_EndGame; + } +} + +void EnSyatekiMan_EndGame(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + EnSyatekiItm* gallery; + + SkelAnime_Update(&pthis->skelAnime); + if ((pthis->numTextBox == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (pthis->gameResult != SYATEKI_RESULT_FAILURE) { + OnePointCutscene_EndCutscene(globalCtx, pthis->csCam); + pthis->csCam = SUBCAM_NONE; + } + Message_CloseTextbox(globalCtx); + gallery = ((EnSyatekiItm*)pthis->actor.parent); + if (gallery->actor.update != NULL) { + gallery->signal = ENSYATEKI_RESULTS; + pthis->textIdx = 0; + switch (pthis->gameResult) { + case SYATEKI_RESULT_WINNER: + pthis->tempGallery = pthis->actor.parent; + pthis->actor.parent = NULL; + if (!LINK_IS_ADULT) { + if (!(gSaveContext.itemGetInf[0] & 0x2000)) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ Equip_Pachinko ☆☆☆☆☆ %d\n" VT_RST, + CUR_UPG_VALUE(UPG_BULLET_BAG)); + if (CUR_UPG_VALUE(UPG_BULLET_BAG) == 1) { + pthis->getItemId = GI_BULLET_BAG_40; + } else { + pthis->getItemId = GI_BULLET_BAG_50; + } + } else { + pthis->getItemId = GI_RUPEE_PURPLE; + } + } else { + if (!(gSaveContext.itemGetInf[0] & 0x4000)) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ Equip_Bow ☆☆☆☆☆ %d\n" VT_RST, + CUR_UPG_VALUE(UPG_QUIVER)); + switch (CUR_UPG_VALUE(UPG_QUIVER)) { + case 0: + pthis->getItemId = GI_RUPEE_PURPLE; + break; + case 1: + pthis->getItemId = GI_QUIVER_40; + break; + case 2: + pthis->getItemId = GI_QUIVER_50; + break; + } + } else { + pthis->getItemId = GI_RUPEE_PURPLE; + } + } + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 2000.0f, 1000.0f); + pthis->actionFunc = EnSyatekiMan_GivePrize; + break; + case SYATEKI_RESULT_ALMOST: + pthis->timer = 20; + func_8008EF44(globalCtx, 15); + pthis->actionFunc = EnSyatekiMan_RestartGame; + break; + default: + if (pthis->gameResult == SYATEKI_RESULT_REFUSE) { + pthis->actionFunc = EnSyatekiMan_SetupIdle; + } else { + pthis->cameraHold = true; + pthis->actor.textId = sTextIds[pthis->textIdx]; + pthis->numTextBox = sTextBoxCount[pthis->textIdx]; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->actionFunc = EnSyatekiMan_Talk; + } + break; + } + } + } +} + +void EnSyatekiMan_GivePrize(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = EnSyatekiMan_FinishPrize; + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 2000.0f, 1000.0f); + } +} + +void EnSyatekiMan_FinishPrize(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + // "Successful completion" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); + if (!LINK_IS_ADULT) { + gSaveContext.itemGetInf[0] |= 0x2000; + } else if ((pthis->getItemId == GI_QUIVER_40) || (pthis->getItemId == GI_QUIVER_50)) { + gSaveContext.itemGetInf[0] |= 0x4000; + } + pthis->gameResult = SYATEKI_RESULT_NONE; + pthis->actor.parent = pthis->tempGallery; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = EnSyatekiMan_SetupIdle; + } +} + +void EnSyatekiMan_RestartGame(EnSyatekiMan* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer == 0) { + EnSyatekiItm* gallery = ((EnSyatekiItm*)pthis->actor.parent); + + if (gallery->actor.update != NULL) { + gallery->signal = ENSYATEKI_START; + pthis->gameResult = SYATEKI_RESULT_NONE; + pthis->actionFunc = EnSyatekiMan_WaitForGame; + // "Let's try again! Baby!" + osSyncPrintf(VT_FGCOL(BLUE) "再挑戦だぜ!ベイビー!" VT_RST "\n", pthis); + } + } +} + +void EnSyatekiMan_BlinkWait(EnSyatekiMan* pthis) { + s16 decrBlinkTimer = pthis->blinkTimer - 1; + + if (decrBlinkTimer != 0) { + pthis->blinkTimer = decrBlinkTimer; + } else { + pthis->blinkFunc = EnSyatekiMan_Blink; + } +} + +void EnSyatekiMan_Blink(EnSyatekiMan* pthis) { + s16 decrBlinkTimer = pthis->blinkTimer - 1; + + if (decrBlinkTimer != 0) { + pthis->blinkTimer = decrBlinkTimer; + } else { + s16 nextEyeState = pthis->eyeState + 1; + + if (nextEyeState >= 3) { + pthis->eyeState = 0; + pthis->blinkTimer = 20 + (s32)(Rand_ZeroOne() * 60.0f); + pthis->blinkFunc = EnSyatekiMan_BlinkWait; + } else { + pthis->eyeState = nextEyeState; + pthis->blinkTimer = 1; + } + } +} + +void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiMan* pthis = (EnSyatekiMan*)thisx; + + if (pthis->timer != 0) { + pthis->timer--; + } + pthis->actionFunc(pthis, globalCtx); + EnSyatekiMan_SetBgm(); + pthis->blinkFunc(pthis); + pthis->actor.focus.pos.y = 70.0f; + Actor_SetFocus(&pthis->actor, 70.0f); + func_80038290(globalCtx, &pthis->actor, &pthis->headRot, &pthis->bodyRot, pthis->actor.focus.pos); +} + +s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnSyatekiMan* pthis = (EnSyatekiMan*)thisx; + s32 turnDirection; + + if (limbIndex == 1) { + rot->x += pthis->bodyRot.y; + } + if (limbIndex == 8) { + *dList = gObjectOssanEnSyatekiManDL_007E28; + turnDirection = 1; + if (pthis->gameResult == SYATEKI_RESULT_REFUSE) { + turnDirection = -1; + } + rot->x += pthis->headRot.y * turnDirection; + rot->z += pthis->headRot.z; + } + return 0; +} + +void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiMan* pthis = (EnSyatekiMan*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnSyatekiMan_OverrideLimbDraw, NULL, pthis); +} + +void EnSyatekiMan_SetBgm(void) { + if (BREG(80)) { + BREG(80) = false; + Audio_QueueSeqCmd(sBgmList[BREG(81)]); + } +} diff --git a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c deleted file mode 100644 index 58eca7cda..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c +++ /dev/null @@ -1,805 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SYATEKI_NIW_Z_EN_SYATEKI_NIW_C -#include "actor_common.h" -/* - * File: z_en_syateki_niw.c - * Overlay: ovl_En_Syateki_Niw - * Description: Hopping Cucco - */ - -#include "z_en_syateki_niw.h" -#include "objects/object_niw/object_niw.h" -#include "vt.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_eff_ss_dead.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnSyatekiNiw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiNiw_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B11DEC(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B132A8(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B129EC(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B13464(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B123A8(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B11E78(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B12460(EnSyatekiNiw* this, GlobalContext* globalCtx); -void func_80B128D8(EnSyatekiNiw* this, GlobalContext* globalCtx); - -void func_80B131B8(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4); - -const ActorInit En_Syateki_Niw_InitVars = { - ACTOR_EN_SYATEKI_NIW, - ACTORCAT_PROP, - FLAGS, - OBJECT_NIW, - sizeof(EnSyatekiNiw), - (ActorFunc)EnSyatekiNiw_Init, - (ActorFunc)EnSyatekiNiw_Destroy, - (ActorFunc)EnSyatekiNiw_Update, - (ActorFunc)EnSyatekiNiw_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 10, 20, 4, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -void EnSyatekiNiw_Init(Actor* thisx, GlobalContext* globalCtx) { - EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.flags &= ~ACTOR_FLAG_0; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCuccoSkel, &gCuccoAnim, this->jointTable, this->morphTable, 16); - - this->unk_29E = this->actor.params; - if (this->unk_29E < 0) { - this->unk_29E = 0; - } - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (this->unk_29E == 0) { - osSyncPrintf("\n\n"); - // "Archery range chicken" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 射的場鶏 ☆☆☆☆☆ \n" VT_RST); - Actor_SetScale(&this->actor, 0.01f); - } else { - osSyncPrintf("\n\n"); - // "Bomb chicken" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ボムにわ! ☆☆☆☆☆ \n" VT_RST); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); - } - - this->unk_2DC = this->actor.world.pos; - this->unk_2E8 = this->actor.world.pos; - this->actionFunc = func_80B11DEC; -} - -void EnSyatekiNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80B11A94(EnSyatekiNiw* this, GlobalContext* globalCtx, s16 arg2) { - if (this->unk_254 == 0) { - if (arg2 == 0) { - this->unk_264 = 0.0f; - } else { - this->unk_264 = -10000.0f; - } - - this->unk_28E += 1; - this->unk_254 = 3; - if (!(this->unk_28E & 1)) { - this->unk_264 = 0.0f; - if (arg2 == 0) { - this->unk_254 = Rand_ZeroFloat(30.0f); - } - } - } - - if (this->unk_258 == 0) { - this->unk_292++; - this->unk_292 &= 1; - switch (arg2) { - case 0: - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; - break; - - case 1: - this->unk_258 = 3; - this->unk_26C = 7000.0f; - this->unk_268 = 7000.0f; - if (this->unk_292 == 0) { - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; - } - break; - - case 2: - this->unk_258 = 2; - this->unk_268 = this->unk_26C = -10000.0f; - this->unk_280 = this->unk_278 = 25000.0f; - this->unk_284 = this->unk_27C = 6000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 8000.0f; - this->unk_280 = 8000.0f; - } - break; - - case 3: - this->unk_258 = 2; - this->unk_278 = 10000.0f; - this->unk_280 = 10000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 3000.0f; - this->unk_280 = 3000.0f; - } - break; - - case 4: - this->unk_254 = this->unk_256 = 5; - break; - - case 5: - this->unk_258 = 5; - this->unk_278 = 14000.0f; - this->unk_280 = 14000.0f; - if (this->unk_292 == 0) { - this->unk_278 = 10000.0f; - this->unk_280 = 10000.0f; - } - break; - } - } - - if (this->unk_264 != this->unk_2BC.x) { - Math_ApproachF(&this->unk_2BC.x, this->unk_264, 0.5f, 4000.0f); - } - - if (this->unk_26C != this->unk_2A4.x) { - Math_ApproachF(&this->unk_2A4.x, this->unk_26C, 0.8f, 7000.0f); - } - - if (this->unk_280 != this->unk_2A4.y) { - Math_ApproachF(&this->unk_2A4.y, this->unk_280, 0.8f, 7000.0f); - } - - if (this->unk_284 != this->unk_2A4.z) { - Math_ApproachF(&this->unk_2A4.z, this->unk_284, 0.8f, 7000.0f); - } - - if (this->unk_268 != this->unk_2B0.x) { - Math_ApproachF(&this->unk_2B0.x, this->unk_268, 0.8f, 7000.0f); - } - - if (this->unk_278 != this->unk_2B0.y) { - Math_ApproachF(&this->unk_2B0.y, this->unk_278, 0.8f, 7000.0f); - } - - if (this->unk_27C != this->unk_2B0.z) { - Math_ApproachF(&this->unk_2B0.z, this->unk_27C, 0.8f, 7000.0f); - } -} - -void func_80B11DEC(EnSyatekiNiw* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, - -10.0f); - if (this->unk_29E != 0) { - Actor_SetScale(&this->actor, this->unk_2F4); - } - - this->actionFunc = func_80B11E78; -} - -void func_80B11E78(EnSyatekiNiw* this, GlobalContext* globalCtx) { - Vec3f dustVelocity = { 0.0f, 0.0f, 0.0f }; - Vec3f dustAccel = { 0.0f, 0.2f, 0.0f }; - Color_RGBA8 dustPrimColor = { 0, 0, 0, 255 }; - Color_RGBA8 dustEnvColor = { 0, 0, 0, 255 }; - Vec3f dustPos; - f32 tmpf2; - f32 sp4C; - f32 sp50; - f32 tmpf1; - s16 sp4A; - - if ((this->unk_29C != 0) && (this->unk_29E == 0) && (this->actor.bgCheckFlags & 1)) { - this->unk_29C = 0; - this->actionFunc = func_80B123A8; - return; - } - - sp4A = 0; - if ((this->unk_25E == 0) && (this->unk_25C == 0)) { - this->unk_294++; - if (this->unk_294 >= 8) { - this->unk_25E = Rand_ZeroFloat(30.0f); - this->unk_294 = Rand_ZeroFloat(3.99f); - - switch (this->unk_29E) { - case 0: - sp50 = Rand_CenteredFloat(100.0f); - if (sp50 < 0.0f) { - sp50 -= 100.0f; - } else { - sp50 += 100.0f; - } - - sp4C = Rand_CenteredFloat(100.0f); - if (sp4C < 0.0f) { - sp4C -= 100.0f; - } else { - sp4C += 100.0f; - } - - this->unk_2E8.x = this->unk_2DC.x + sp50; - this->unk_2E8.z = this->unk_2DC.z + sp4C; - - if (this->unk_2E8.x < -150.0f) { - this->unk_2E8.x = -150.0f; - } - - if (this->unk_2E8.x > 150.0f) { - this->unk_2E8.x = 150.0f; - } - - if (this->unk_2E8.z < -60.0f) { - this->unk_2E8.z = -60.0f; - } - - if (this->unk_2E8.z > -40.0f) { - this->unk_2E8.z = -40.0f; - } - break; - - case 1: - sp50 = Rand_CenteredFloat(50.0f); - if (sp50 < 0.0f) { - sp50 -= 50.0f; - } else { - sp50 += 50.0f; - } - - sp4C = Rand_CenteredFloat(30.0f); - if (sp4C < 0.0f) { - sp4C -= 30.0f; - } else { - sp4C += 30.0f; - } - - this->unk_2E8.x = this->unk_2DC.x + sp50; - this->unk_2E8.z = this->unk_2DC.z + sp4C; - break; - } - } else { - this->unk_25C = 4; - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y = 2.5f; - if ((Rand_ZeroFloat(10.0f) < 1.0f) && (this->unk_29E == 0)) { - this->unk_25C = 0xC; - this->actor.velocity.y = 10.0f; - } - } - } - } - if (this->unk_25C != 0) { - sp4A = 1; - Math_ApproachF(&this->actor.world.pos.x, this->unk_2E8.x, 1.0f, this->unk_2C8.y); - Math_ApproachF(&this->actor.world.pos.z, this->unk_2E8.z, 1.0f, this->unk_2C8.y); - Math_ApproachF(&this->unk_2C8.y, 3.0f, 1.0f, 0.3f); - tmpf1 = this->unk_2E8.x - this->actor.world.pos.x; - tmpf2 = this->unk_2E8.z - this->actor.world.pos.z; - - if (fabsf(tmpf1) < 10.0f) { - tmpf1 = 0; - } - - if (fabsf(tmpf2) < 10.0f) { - tmpf2 = 0.0f; - } - - if ((tmpf1 == 0.0f) && (tmpf2 == 0.0f)) { - this->unk_25C = 0; - this->unk_294 = 7; - } - - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(tmpf1, tmpf2) * (0x8000 / M_PI), 3, this->unk_2C8.z, - 0); - Math_ApproachF(&this->unk_2C8.z, 10000.0f, 1.0f, 1000.0f); - } - - if (this->unk_260 == 0) { - func_80B11A94(this, globalCtx, sp4A); - return; - } - - if ((globalCtx->gameplayFrames % 4) == 0) { - dustVelocity.y = Rand_CenteredFloat(5.0f); - dustAccel.y = 0.2f; - dustPos = this->actor.world.pos; - func_8002836C(globalCtx, &dustPos, &dustVelocity, &dustAccel, &dustPrimColor, &dustEnvColor, 600, 40, 30); - } -} - -void func_80B123A8(EnSyatekiNiw* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, - -10.0f); - this->unk_27C = 6000.0f; - this->unk_288 = -10000.0f; - this->unk_2B0.z = 6000.0f; - this->unk_2B0.y = 10000.0f; - this->actionFunc = func_80B12460; - this->unk_2A4.z = 6000.0f; - this->unk_284 = 6000.0f; - this->unk_2B0.x = -10000.0f; - this->unk_268 = -10000.0f; - this->unk_2A4.y = -10000.0f; - this->unk_2A4.x = -10000.0f; - this->unk_26C = -10000.0f; -} - -void func_80B12460(EnSyatekiNiw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 phi_f16 = 0.0f; - - player->actor.freezeTimer = 10; - switch (this->unk_29A) { - case 0: - this->unk_296 = 2; - this->unk_2C8.y = 0.0f; - this->unk_29A = 1; - break; - - case 1: - this->actor.speedXZ = 2.0f; - if (this->unk_25C == 0) { - this->unk_25C = 3; - this->actor.velocity.y = 3.5f; - } - - if (this->unk_25A == 0) { - this->unk_298++; - this->unk_298 &= 1; - this->unk_25A = 5; - } - - phi_f16 = (this->unk_298 == 0) ? 5000.0f : -5000.0f; - if (this->actor.world.pos.z > 100.0f) { - this->actor.speedXZ = 2.0f; - this->actor.gravity = -0.3f; - this->actor.velocity.y = 5.0f; - this->unk_29A = 2; - } - break; - - case 2: - if ((player->actor.world.pos.z - 40.0f) < this->actor.world.pos.z) { - this->actor.speedXZ = 0.0f; - } - - if ((this->actor.bgCheckFlags & 1) && (this->actor.world.pos.z > 110.0f)) { - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - this->unk_284 = 0.0f; - this->unk_27C = 0.0f; - this->unk_278 = 0.0f; - this->unk_280 = 0.0f; - this->unk_288 = 0.0f; - this->actor.speedXZ = 0.5f; - this->unk_254 = this->unk_256 = 0; - this->unk_28E = this->unk_290 = 0; - this->unk_296 = 1; - this->unk_29A = 3; - } - break; - - case 3: - if ((player->actor.world.pos.z - 50.0f) < this->actor.world.pos.z) { - this->actor.speedXZ = 0.0f; - this->unk_262 = 0x3C; - this->unk_25A = 0x14; - this->unk_264 = 10000.0f; - this->unk_29A = 4; - } - break; - - case 4: - if (this->unk_25A == 0) { - this->unk_296 = 4; - this->unk_264 = 5000.0f; - this->unk_26C = 0.0f; - this->unk_268 = 0.0f; - this->unk_284 = 0.0f; - this->unk_27C = 0.0f; - this->unk_280 = 14000.0f; - this->unk_278 = 14000.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - this->unk_254 = this->unk_256 = this->unk_25A = 0x1E; - this->unk_29A = 5; - } - break; - - case 5: - if (this->unk_25A == 1) { - this->unk_258 = 0; - this->unk_296 = 5; - this->unk_256 = this->unk_258; - this->unk_254 = this->unk_258; - this->actor.speedXZ = 1.0f; - } - - if ((this->unk_25A == 0) && ((player->actor.world.pos.z - 30.0f) < this->actor.world.pos.z)) { - Audio_PlaySoundGeneral(NA_SE_VO_LI_DOWN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - this->unk_25E = 0x14; - this->unk_29A = 6; - this->actor.speedXZ = 0.0f; - } - break; - - case 6: - if (this->unk_25E == 1) { - globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.entranceIndex; - globalCtx->shootingGalleryStatus = 0; - player->actor.freezeTimer = 20; - this->unk_25E = 0x14; - this->actionFunc = func_80B128D8; - } - break; - } - - Math_SmoothStepToS(&this->actor.world.rot.y, - (s16)(Math_FAtan2F(player->actor.world.pos.x - this->actor.world.pos.x, - player->actor.world.pos.z - this->actor.world.pos.z) * - (0x8000 / M_PI)) + - phi_f16, - 5, this->unk_2C8.y, 0); - Math_ApproachF(&this->unk_2C8.y, 3000.0f, 1.0f, 500.0f); - if (this->unk_296 == 2) { - this->unk_256 = 10; - this->unk_254 = this->unk_256; - } - - func_80B11A94(this, globalCtx, this->unk_296); -} - -void func_80B128D8(EnSyatekiNiw* this, GlobalContext* globalCtx) { - if (this->unk_25E == 1) { - gSaveContext.timer1State = 0; - } -} - -void func_80B128F8(EnSyatekiNiw* this, GlobalContext* globalCtx) { - s16 sp26; - s16 sp24; - - Actor_SetFocus(&this->actor, this->unk_2D4); - Actor_GetScreenPos(globalCtx, &this->actor, &sp26, &sp24); - if ((this->actor.projectedPos.z > 200.0f) && (this->actor.projectedPos.z < 800.0f) && (sp26 > 0) && - (sp26 < SCREEN_WIDTH) && (sp24 > 0) && (sp24 < SCREEN_HEIGHT)) { - this->actor.speedXZ = 5.0f; - this->unk_298 = Rand_ZeroFloat(1.99f); - this->unk_2D8 = Rand_CenteredFloat(8000.0f) + -10000.0f; - this->unk_262 = 0x1E; - this->unk_25E = 0x64; - this->actionFunc = func_80B129EC; - } -} - -void func_80B129EC(EnSyatekiNiw* this, GlobalContext* globalCtx) { - s32 pad; - f32 phi_f2; - s16 sp2E; - s16 sp2C; - f32 tmpf2; - - Actor_SetFocus(&this->actor, this->unk_2D4); - Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); - if ((this->unk_25E == 0) || (this->actor.projectedPos.z < -70.0f) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || - (sp2C < 0) || (sp2C > SCREEN_HEIGHT)) { - Actor_Kill(&this->actor); - return; - } - - this->unk_2A0 = 1; - if (this->unk_25C == 0) { - this->unk_298++; - this->unk_298 &= 1; - this->unk_25C = (s16)Rand_CenteredFloat(4.0f) + 5; - if ((Rand_ZeroFloat(5.0f) < 1.0f) && (this->actor.bgCheckFlags & 1)) { - this->actor.velocity.y = 4.0f; - } - } - - phi_f2 = (this->unk_298 == 0) ? 5000.0f : -5000.0f; - tmpf2 = this->unk_2D8 + phi_f2; - Math_SmoothStepToS(&this->actor.world.rot.y, tmpf2, 3, this->unk_2C8.y, 0); - Math_ApproachF(&this->unk_2C8.y, 3000.0f, 1.0f, 500.0f); - func_80B11A94(this, globalCtx, 2); -} - -void func_80B12BA4(EnSyatekiNiw* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - switch (this->unk_29E) { - case 0: - if (this->unk_29C == 0) { - this->unk_262 = 0x1E; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - this->unk_29C = 1; - this->unk_2A0 = 1; - this->actionFunc = func_80B123A8; - this->actor.gravity = -3.0f; - } - break; - - case 1: - this->unk_262 = 0x1E; - this->unk_2F8 = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - this->unk_260 = 100; - this->unk_2A0 = 1; - this->unk_25E = this->unk_260; - break; - } - } -} - -void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx) { - EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - s32 pad; - s16 i; - Vec3f sp90 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp84 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp78; - Vec3f sp6C; - Vec3f sp60; - - if (1) {} - if (1) {} - if (1) {} - - func_80B132A8(this, globalCtx); - this->unk_28C++; - if (this->unk_254 != 0) { - this->unk_254--; - } - - if (this->unk_258 != 0) { - this->unk_258--; - } - - if (this->unk_25A != 0) { - this->unk_25A--; - } - - if (this->unk_25C != 0) { - this->unk_25C--; - } - - if (this->unk_25E != 0) { - this->unk_25E--; - } - - if (this->unk_262 != 0) { - this->unk_262--; - } - - if (this->unk_260 != 0) { - this->unk_260--; - } - - this->actor.shape.rot = this->actor.world.rot; - this->actor.shape.shadowScale = 15.0f; - - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - - if (this->unk_2A0 != 0) { - for (i = 0; i < 20; i++) { - sp78.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; - sp78.y = Rand_CenteredFloat(10.0f) + (this->actor.world.pos.y + 20.0f); - sp78.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; - sp6C.x = Rand_CenteredFloat(3.0f); - sp6C.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; - sp6C.z = Rand_CenteredFloat(3.0f); - sp60.z = sp60.x = 0.0f; - sp60.y = -0.15f; - func_80B131B8(this, &sp78, &sp6C, &sp60, Rand_ZeroFloat(8.0f) + 8.0f); - } - - this->unk_2A0 = 0; - } - - func_80B12BA4(this, globalCtx); - if (this->unk_262 == 0) { - if (this->actionFunc == func_80B11E78) { - this->unk_262 = 0x12C; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_N); - } else { - this->unk_262 = 0x1E; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); - } - } - - i = 0; - switch (this->unk_29E) { - case 0: - if (globalCtx->shootingGalleryStatus != 0) { - i = 1; - } - break; - - case 1: - i = 1; - break; - } - - if (i != 0) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -s32 SyatekiNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - Vec3f sp0 = { 0.0f, 0.0f, 0.0f }; - - if (limbIndex == 13) { - rot->y += (s16)this->unk_2BC.x; - } - - if (limbIndex == 11) { - rot->x += (s16)this->unk_2B0.z; - rot->y += (s16)this->unk_2B0.y; - rot->z += (s16)this->unk_2B0.x; - } - - if (limbIndex == 7) { - rot->x += (s16)this->unk_2A4.z; - rot->y += (s16)this->unk_2A4.y; - rot->z += (s16)this->unk_2A4.x; - } - - return false; -} - -void EnSyatekiNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnSyatekiNiw* this = (EnSyatekiNiw*)thisx; - Color_RGBA8 sp30 = { 0, 0, 0, 255 }; - - if (this->actionFunc != func_80B128F8) { - func_80093D18(globalCtx->state.gfxCtx); - if (this->unk_260 != 0) { - func_80026230(globalCtx, &sp30, 0, 0x14); - } - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, SyatekiNiw_OverrideLimbDraw, NULL, this); - func_80026608(globalCtx); - func_80B13464(this, globalCtx); - } -} - -void func_80B131B8(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4) { - s16 i; - EnSyatekiNiw_1* ptr = &this->unk_348[0]; - - for (i = 0; i < 5; i++, ptr++) { - if (ptr->unk_00 == 0) { - ptr->unk_00 = 1; - ptr->unk_04 = *arg1; - ptr->unk_10 = *arg2; - ptr->unk_1C = *arg3; - ptr->unk_34 = 0; - ptr->unk_2C = (arg4 / 1000.0f); - ptr->unk_28 = (s16)Rand_ZeroFloat(20.0f) + 0x28; - ptr->unk_2A = Rand_ZeroFloat(1000.0f); - return; - } - } -} - -void func_80B132A8(EnSyatekiNiw* this, GlobalContext* globalCtx) { - s16 i; - EnSyatekiNiw_1* ptr = &this->unk_348[0]; - - for (i = 0; i < 5; i++, ptr++) { - if (ptr->unk_00 != 0) { - ptr->unk_04.x += ptr->unk_10.x; - ptr->unk_04.y += ptr->unk_10.y; - ptr->unk_04.z += ptr->unk_10.z; - ptr->unk_34++; - ptr->unk_10.x += ptr->unk_1C.x; - ptr->unk_10.y += ptr->unk_1C.y; - ptr->unk_10.z += ptr->unk_1C.z; - if (ptr->unk_00 == 1) { - ptr->unk_2A++; - Math_ApproachF(&ptr->unk_10.x, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&ptr->unk_10.z, 0.0f, 1.0f, 0.05f); - if (ptr->unk_10.y < -0.5f) { - ptr->unk_10.y = 0.5f; - } - - ptr->unk_30 = (Math_SinS(ptr->unk_2A * 3000) * M_PI) * 0.2f; - if (ptr->unk_28 < ptr->unk_34) { - ptr->unk_00 = 0; - } - } - } - } -} - -void func_80B13464(EnSyatekiNiw* this, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s16 i; - EnSyatekiNiw_1* ptr = &this->unk_348[0]; - u8 flag = 0; - - OPEN_DISPS(gfxCtx, "../z_en_syateki_niw.c", 1234); - - func_80093D84(globalCtx->state.gfxCtx); - - for (i = 0; i < 5; i++, ptr++) { - if (ptr->unk_00 == 1) { - if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); - flag++; - } - - Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); - func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_Scale(ptr->unk_2C, ptr->unk_2C, 1.0f, MTXMODE_APPLY); - Matrix_RotateZ(ptr->unk_30, MTXMODE_APPLY); - Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_syateki_niw.c", 1251), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); - } - } - - CLOSE_DISPS(gfxCtx, "../z_en_syateki_niw.c", 1257); -} diff --git a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.cpp b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.cpp new file mode 100644 index 000000000..82f2a3e0b --- /dev/null +++ b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.cpp @@ -0,0 +1,805 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_SYATEKI_NIW_Z_EN_SYATEKI_NIW_C +#include "actor_common.h" +/* + * File: z_en_syateki_niw.c + * Overlay: ovl_En_Syateki_Niw + * Description: Hopping Cucco + */ + +#include "z_en_syateki_niw.h" +#include "objects/object_niw/object_niw.h" +#include "vt.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_eff_ss_dead.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnSyatekiNiw_Init(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiNiw_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B11DEC(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B132A8(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B129EC(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B13464(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B123A8(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B11E78(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B12460(EnSyatekiNiw* pthis, GlobalContext* globalCtx); +void func_80B128D8(EnSyatekiNiw* pthis, GlobalContext* globalCtx); + +void func_80B131B8(EnSyatekiNiw* pthis, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4); + +ActorInit En_Syateki_Niw_InitVars = { + ACTOR_EN_SYATEKI_NIW, + ACTORCAT_PROP, + FLAGS, + OBJECT_NIW, + sizeof(EnSyatekiNiw), + (ActorFunc)EnSyatekiNiw_Init, + (ActorFunc)EnSyatekiNiw_Destroy, + (ActorFunc)EnSyatekiNiw_Update, + (ActorFunc)EnSyatekiNiw_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 10, 20, 4, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; + +void EnSyatekiNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiNiw* pthis = (EnSyatekiNiw*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.flags &= ~ACTOR_FLAG_0; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gCuccoSkel, &gCuccoAnim, pthis->jointTable, pthis->morphTable, 16); + + pthis->unk_29E = pthis->actor.params; + if (pthis->unk_29E < 0) { + pthis->unk_29E = 0; + } + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + if (pthis->unk_29E == 0) { + osSyncPrintf("\n\n"); + // "Archery range chicken" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 射的場鶏 ☆☆☆☆☆ \n" VT_RST); + Actor_SetScale(&pthis->actor, 0.01f); + } else { + osSyncPrintf("\n\n"); + // "Bomb chicken" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ボムにわ! ☆☆☆☆☆ \n" VT_RST); + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&pthis->actor, 0.01f); + } + + pthis->unk_2DC = pthis->actor.world.pos; + pthis->unk_2E8 = pthis->actor.world.pos; + pthis->actionFunc = func_80B11DEC; +} + +void EnSyatekiNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiNiw* pthis = (EnSyatekiNiw*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80B11A94(EnSyatekiNiw* pthis, GlobalContext* globalCtx, s16 arg2) { + if (pthis->unk_254 == 0) { + if (arg2 == 0) { + pthis->unk_264 = 0.0f; + } else { + pthis->unk_264 = -10000.0f; + } + + pthis->unk_28E += 1; + pthis->unk_254 = 3; + if (!(pthis->unk_28E & 1)) { + pthis->unk_264 = 0.0f; + if (arg2 == 0) { + pthis->unk_254 = Rand_ZeroFloat(30.0f); + } + } + } + + if (pthis->unk_258 == 0) { + pthis->unk_292++; + pthis->unk_292 &= 1; + switch (arg2) { + case 0: + pthis->unk_26C = 0.0f; + pthis->unk_268 = 0.0f; + break; + + case 1: + pthis->unk_258 = 3; + pthis->unk_26C = 7000.0f; + pthis->unk_268 = 7000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_26C = 0.0f; + pthis->unk_268 = 0.0f; + } + break; + + case 2: + pthis->unk_258 = 2; + pthis->unk_268 = pthis->unk_26C = -10000.0f; + pthis->unk_280 = pthis->unk_278 = 25000.0f; + pthis->unk_284 = pthis->unk_27C = 6000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_278 = 8000.0f; + pthis->unk_280 = 8000.0f; + } + break; + + case 3: + pthis->unk_258 = 2; + pthis->unk_278 = 10000.0f; + pthis->unk_280 = 10000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_278 = 3000.0f; + pthis->unk_280 = 3000.0f; + } + break; + + case 4: + pthis->unk_254 = pthis->unk_256 = 5; + break; + + case 5: + pthis->unk_258 = 5; + pthis->unk_278 = 14000.0f; + pthis->unk_280 = 14000.0f; + if (pthis->unk_292 == 0) { + pthis->unk_278 = 10000.0f; + pthis->unk_280 = 10000.0f; + } + break; + } + } + + if (pthis->unk_264 != pthis->unk_2BC.x) { + Math_ApproachF(&pthis->unk_2BC.x, pthis->unk_264, 0.5f, 4000.0f); + } + + if (pthis->unk_26C != pthis->unk_2A4.x) { + Math_ApproachF(&pthis->unk_2A4.x, pthis->unk_26C, 0.8f, 7000.0f); + } + + if (pthis->unk_280 != pthis->unk_2A4.y) { + Math_ApproachF(&pthis->unk_2A4.y, pthis->unk_280, 0.8f, 7000.0f); + } + + if (pthis->unk_284 != pthis->unk_2A4.z) { + Math_ApproachF(&pthis->unk_2A4.z, pthis->unk_284, 0.8f, 7000.0f); + } + + if (pthis->unk_268 != pthis->unk_2B0.x) { + Math_ApproachF(&pthis->unk_2B0.x, pthis->unk_268, 0.8f, 7000.0f); + } + + if (pthis->unk_278 != pthis->unk_2B0.y) { + Math_ApproachF(&pthis->unk_2B0.y, pthis->unk_278, 0.8f, 7000.0f); + } + + if (pthis->unk_27C != pthis->unk_2B0.z) { + Math_ApproachF(&pthis->unk_2B0.z, pthis->unk_27C, 0.8f, 7000.0f); + } +} + +void func_80B11DEC(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, + -10.0f); + if (pthis->unk_29E != 0) { + Actor_SetScale(&pthis->actor, pthis->unk_2F4); + } + + pthis->actionFunc = func_80B11E78; +} + +void func_80B11E78(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + Vec3f dustVelocity = { 0.0f, 0.0f, 0.0f }; + Vec3f dustAccel = { 0.0f, 0.2f, 0.0f }; + Color_RGBA8 dustPrimColor = { 0, 0, 0, 255 }; + Color_RGBA8 dustEnvColor = { 0, 0, 0, 255 }; + Vec3f dustPos; + f32 tmpf2; + f32 sp4C; + f32 sp50; + f32 tmpf1; + s16 sp4A; + + if ((pthis->unk_29C != 0) && (pthis->unk_29E == 0) && (pthis->actor.bgCheckFlags & 1)) { + pthis->unk_29C = 0; + pthis->actionFunc = func_80B123A8; + return; + } + + sp4A = 0; + if ((pthis->unk_25E == 0) && (pthis->unk_25C == 0)) { + pthis->unk_294++; + if (pthis->unk_294 >= 8) { + pthis->unk_25E = Rand_ZeroFloat(30.0f); + pthis->unk_294 = Rand_ZeroFloat(3.99f); + + switch (pthis->unk_29E) { + case 0: + sp50 = Rand_CenteredFloat(100.0f); + if (sp50 < 0.0f) { + sp50 -= 100.0f; + } else { + sp50 += 100.0f; + } + + sp4C = Rand_CenteredFloat(100.0f); + if (sp4C < 0.0f) { + sp4C -= 100.0f; + } else { + sp4C += 100.0f; + } + + pthis->unk_2E8.x = pthis->unk_2DC.x + sp50; + pthis->unk_2E8.z = pthis->unk_2DC.z + sp4C; + + if (pthis->unk_2E8.x < -150.0f) { + pthis->unk_2E8.x = -150.0f; + } + + if (pthis->unk_2E8.x > 150.0f) { + pthis->unk_2E8.x = 150.0f; + } + + if (pthis->unk_2E8.z < -60.0f) { + pthis->unk_2E8.z = -60.0f; + } + + if (pthis->unk_2E8.z > -40.0f) { + pthis->unk_2E8.z = -40.0f; + } + break; + + case 1: + sp50 = Rand_CenteredFloat(50.0f); + if (sp50 < 0.0f) { + sp50 -= 50.0f; + } else { + sp50 += 50.0f; + } + + sp4C = Rand_CenteredFloat(30.0f); + if (sp4C < 0.0f) { + sp4C -= 30.0f; + } else { + sp4C += 30.0f; + } + + pthis->unk_2E8.x = pthis->unk_2DC.x + sp50; + pthis->unk_2E8.z = pthis->unk_2DC.z + sp4C; + break; + } + } else { + pthis->unk_25C = 4; + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.velocity.y = 2.5f; + if ((Rand_ZeroFloat(10.0f) < 1.0f) && (pthis->unk_29E == 0)) { + pthis->unk_25C = 0xC; + pthis->actor.velocity.y = 10.0f; + } + } + } + } + if (pthis->unk_25C != 0) { + sp4A = 1; + Math_ApproachF(&pthis->actor.world.pos.x, pthis->unk_2E8.x, 1.0f, pthis->unk_2C8.y); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->unk_2E8.z, 1.0f, pthis->unk_2C8.y); + Math_ApproachF(&pthis->unk_2C8.y, 3.0f, 1.0f, 0.3f); + tmpf1 = pthis->unk_2E8.x - pthis->actor.world.pos.x; + tmpf2 = pthis->unk_2E8.z - pthis->actor.world.pos.z; + + if (fabsf(tmpf1) < 10.0f) { + tmpf1 = 0; + } + + if (fabsf(tmpf2) < 10.0f) { + tmpf2 = 0.0f; + } + + if ((tmpf1 == 0.0f) && (tmpf2 == 0.0f)) { + pthis->unk_25C = 0; + pthis->unk_294 = 7; + } + + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_FAtan2F(tmpf1, tmpf2) * (0x8000 / M_PI), 3, pthis->unk_2C8.z, + 0); + Math_ApproachF(&pthis->unk_2C8.z, 10000.0f, 1.0f, 1000.0f); + } + + if (pthis->unk_260 == 0) { + func_80B11A94(pthis, globalCtx, sp4A); + return; + } + + if ((globalCtx->gameplayFrames % 4) == 0) { + dustVelocity.y = Rand_CenteredFloat(5.0f); + dustAccel.y = 0.2f; + dustPos = pthis->actor.world.pos; + func_8002836C(globalCtx, &dustPos, &dustVelocity, &dustAccel, &dustPrimColor, &dustEnvColor, 600, 40, 30); + } +} + +void func_80B123A8(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + Animation_Change(&pthis->skelAnime, &gCuccoAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCuccoAnim), ANIMMODE_LOOP, + -10.0f); + pthis->unk_27C = 6000.0f; + pthis->unk_288 = -10000.0f; + pthis->unk_2B0.z = 6000.0f; + pthis->unk_2B0.y = 10000.0f; + pthis->actionFunc = func_80B12460; + pthis->unk_2A4.z = 6000.0f; + pthis->unk_284 = 6000.0f; + pthis->unk_2B0.x = -10000.0f; + pthis->unk_268 = -10000.0f; + pthis->unk_2A4.y = -10000.0f; + pthis->unk_2A4.x = -10000.0f; + pthis->unk_26C = -10000.0f; +} + +void func_80B12460(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 phi_f16 = 0.0f; + + player->actor.freezeTimer = 10; + switch (pthis->unk_29A) { + case 0: + pthis->unk_296 = 2; + pthis->unk_2C8.y = 0.0f; + pthis->unk_29A = 1; + break; + + case 1: + pthis->actor.speedXZ = 2.0f; + if (pthis->unk_25C == 0) { + pthis->unk_25C = 3; + pthis->actor.velocity.y = 3.5f; + } + + if (pthis->unk_25A == 0) { + pthis->unk_298++; + pthis->unk_298 &= 1; + pthis->unk_25A = 5; + } + + phi_f16 = (pthis->unk_298 == 0) ? 5000.0f : -5000.0f; + if (pthis->actor.world.pos.z > 100.0f) { + pthis->actor.speedXZ = 2.0f; + pthis->actor.gravity = -0.3f; + pthis->actor.velocity.y = 5.0f; + pthis->unk_29A = 2; + } + break; + + case 2: + if ((player->actor.world.pos.z - 40.0f) < pthis->actor.world.pos.z) { + pthis->actor.speedXZ = 0.0f; + } + + if ((pthis->actor.bgCheckFlags & 1) && (pthis->actor.world.pos.z > 110.0f)) { + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->unk_284 = 0.0f; + pthis->unk_27C = 0.0f; + pthis->unk_278 = 0.0f; + pthis->unk_280 = 0.0f; + pthis->unk_288 = 0.0f; + pthis->actor.speedXZ = 0.5f; + pthis->unk_254 = pthis->unk_256 = 0; + pthis->unk_28E = pthis->unk_290 = 0; + pthis->unk_296 = 1; + pthis->unk_29A = 3; + } + break; + + case 3: + if ((player->actor.world.pos.z - 50.0f) < pthis->actor.world.pos.z) { + pthis->actor.speedXZ = 0.0f; + pthis->unk_262 = 0x3C; + pthis->unk_25A = 0x14; + pthis->unk_264 = 10000.0f; + pthis->unk_29A = 4; + } + break; + + case 4: + if (pthis->unk_25A == 0) { + pthis->unk_296 = 4; + pthis->unk_264 = 5000.0f; + pthis->unk_26C = 0.0f; + pthis->unk_268 = 0.0f; + pthis->unk_284 = 0.0f; + pthis->unk_27C = 0.0f; + pthis->unk_280 = 14000.0f; + pthis->unk_278 = 14000.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + pthis->unk_254 = pthis->unk_256 = pthis->unk_25A = 0x1E; + pthis->unk_29A = 5; + } + break; + + case 5: + if (pthis->unk_25A == 1) { + pthis->unk_258 = 0; + pthis->unk_296 = 5; + pthis->unk_256 = pthis->unk_258; + pthis->unk_254 = pthis->unk_258; + pthis->actor.speedXZ = 1.0f; + } + + if ((pthis->unk_25A == 0) && ((player->actor.world.pos.z - 30.0f) < pthis->actor.world.pos.z)) { + Audio_PlaySoundGeneral(NA_SE_VO_LI_DOWN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pthis->unk_25E = 0x14; + pthis->unk_29A = 6; + pthis->actor.speedXZ = 0.0f; + } + break; + + case 6: + if (pthis->unk_25E == 1) { + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.entranceIndex; + globalCtx->shootingGalleryStatus = 0; + player->actor.freezeTimer = 20; + pthis->unk_25E = 0x14; + pthis->actionFunc = func_80B128D8; + } + break; + } + + Math_SmoothStepToS(&pthis->actor.world.rot.y, + (s16)(Math_FAtan2F(player->actor.world.pos.x - pthis->actor.world.pos.x, + player->actor.world.pos.z - pthis->actor.world.pos.z) * + (0x8000 / M_PI)) + + phi_f16, + 5, pthis->unk_2C8.y, 0); + Math_ApproachF(&pthis->unk_2C8.y, 3000.0f, 1.0f, 500.0f); + if (pthis->unk_296 == 2) { + pthis->unk_256 = 10; + pthis->unk_254 = pthis->unk_256; + } + + func_80B11A94(pthis, globalCtx, pthis->unk_296); +} + +void func_80B128D8(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + if (pthis->unk_25E == 1) { + gSaveContext.timer1State = 0; + } +} + +void func_80B128F8(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + s16 sp26; + s16 sp24; + + Actor_SetFocus(&pthis->actor, pthis->unk_2D4); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp26, &sp24); + if ((pthis->actor.projectedPos.z > 200.0f) && (pthis->actor.projectedPos.z < 800.0f) && (sp26 > 0) && + (sp26 < SCREEN_WIDTH) && (sp24 > 0) && (sp24 < SCREEN_HEIGHT)) { + pthis->actor.speedXZ = 5.0f; + pthis->unk_298 = Rand_ZeroFloat(1.99f); + pthis->unk_2D8 = Rand_CenteredFloat(8000.0f) + -10000.0f; + pthis->unk_262 = 0x1E; + pthis->unk_25E = 0x64; + pthis->actionFunc = func_80B129EC; + } +} + +void func_80B129EC(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 phi_f2; + s16 sp2E; + s16 sp2C; + f32 tmpf2; + + Actor_SetFocus(&pthis->actor, pthis->unk_2D4); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp2E, &sp2C); + if ((pthis->unk_25E == 0) || (pthis->actor.projectedPos.z < -70.0f) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || + (sp2C < 0) || (sp2C > SCREEN_HEIGHT)) { + Actor_Kill(&pthis->actor); + return; + } + + pthis->unk_2A0 = 1; + if (pthis->unk_25C == 0) { + pthis->unk_298++; + pthis->unk_298 &= 1; + pthis->unk_25C = (s16)Rand_CenteredFloat(4.0f) + 5; + if ((Rand_ZeroFloat(5.0f) < 1.0f) && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.velocity.y = 4.0f; + } + } + + phi_f2 = (pthis->unk_298 == 0) ? 5000.0f : -5000.0f; + tmpf2 = pthis->unk_2D8 + phi_f2; + Math_SmoothStepToS(&pthis->actor.world.rot.y, tmpf2, 3, pthis->unk_2C8.y, 0); + Math_ApproachF(&pthis->unk_2C8.y, 3000.0f, 1.0f, 500.0f); + func_80B11A94(pthis, globalCtx, 2); +} + +void func_80B12BA4(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + switch (pthis->unk_29E) { + case 0: + if (pthis->unk_29C == 0) { + pthis->unk_262 = 0x1E; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_A); + pthis->unk_29C = 1; + pthis->unk_2A0 = 1; + pthis->actionFunc = func_80B123A8; + pthis->actor.gravity = -3.0f; + } + break; + + case 1: + pthis->unk_262 = 0x1E; + pthis->unk_2F8 = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_A); + pthis->unk_260 = 100; + pthis->unk_2A0 = 1; + pthis->unk_25E = pthis->unk_260; + break; + } + } +} + +void EnSyatekiNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiNiw* pthis = (EnSyatekiNiw*)thisx; + s32 pad; + s16 i; + Vec3f sp90 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp84 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60; + + if (1) {} + if (1) {} + if (1) {} + + func_80B132A8(pthis, globalCtx); + pthis->unk_28C++; + if (pthis->unk_254 != 0) { + pthis->unk_254--; + } + + if (pthis->unk_258 != 0) { + pthis->unk_258--; + } + + if (pthis->unk_25A != 0) { + pthis->unk_25A--; + } + + if (pthis->unk_25C != 0) { + pthis->unk_25C--; + } + + if (pthis->unk_25E != 0) { + pthis->unk_25E--; + } + + if (pthis->unk_262 != 0) { + pthis->unk_262--; + } + + if (pthis->unk_260 != 0) { + pthis->unk_260--; + } + + pthis->actor.shape.rot = pthis->actor.world.rot; + pthis->actor.shape.shadowScale = 15.0f; + + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 20.0f, 60.0f, 0x1D); + + if (pthis->unk_2A0 != 0) { + for (i = 0; i < 20; i++) { + sp78.x = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.x; + sp78.y = Rand_CenteredFloat(10.0f) + (pthis->actor.world.pos.y + 20.0f); + sp78.z = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.z; + sp6C.x = Rand_CenteredFloat(3.0f); + sp6C.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; + sp6C.z = Rand_CenteredFloat(3.0f); + sp60.z = sp60.x = 0.0f; + sp60.y = -0.15f; + func_80B131B8(pthis, &sp78, &sp6C, &sp60, Rand_ZeroFloat(8.0f) + 8.0f); + } + + pthis->unk_2A0 = 0; + } + + func_80B12BA4(pthis, globalCtx); + if (pthis->unk_262 == 0) { + if (pthis->actionFunc == func_80B11E78) { + pthis->unk_262 = 0x12C; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_N); + } else { + pthis->unk_262 = 0x1E; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_CHICKEN_CRY_A); + } + } + + i = 0; + switch (pthis->unk_29E) { + case 0: + if (globalCtx->shootingGalleryStatus != 0) { + i = 1; + } + break; + + case 1: + i = 1; + break; + } + + if (i != 0) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +s32 SyatekiNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnSyatekiNiw* pthis = (EnSyatekiNiw*)thisx; + Vec3f sp0 = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 13) { + rot->y += (s16)pthis->unk_2BC.x; + } + + if (limbIndex == 11) { + rot->x += (s16)pthis->unk_2B0.z; + rot->y += (s16)pthis->unk_2B0.y; + rot->z += (s16)pthis->unk_2B0.x; + } + + if (limbIndex == 7) { + rot->x += (s16)pthis->unk_2A4.z; + rot->y += (s16)pthis->unk_2A4.y; + rot->z += (s16)pthis->unk_2A4.x; + } + + return false; +} + +void EnSyatekiNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiNiw* pthis = (EnSyatekiNiw*)thisx; + Color_RGBA8 sp30 = { 0, 0, 0, 255 }; + + if (pthis->actionFunc != func_80B128F8) { + func_80093D18(globalCtx->state.gfxCtx); + if (pthis->unk_260 != 0) { + func_80026230(globalCtx, &sp30, 0, 0x14); + } + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, SyatekiNiw_OverrideLimbDraw, NULL, pthis); + func_80026608(globalCtx); + func_80B13464(pthis, globalCtx); + } +} + +void func_80B131B8(EnSyatekiNiw* pthis, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4) { + s16 i; + EnSyatekiNiw_1* ptr = &pthis->unk_348[0]; + + for (i = 0; i < 5; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + ptr->unk_04 = *arg1; + ptr->unk_10 = *arg2; + ptr->unk_1C = *arg3; + ptr->unk_34 = 0; + ptr->unk_2C = (arg4 / 1000.0f); + ptr->unk_28 = (s16)Rand_ZeroFloat(20.0f) + 0x28; + ptr->unk_2A = Rand_ZeroFloat(1000.0f); + return; + } + } +} + +void func_80B132A8(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + s16 i; + EnSyatekiNiw_1* ptr = &pthis->unk_348[0]; + + for (i = 0; i < 5; i++, ptr++) { + if (ptr->unk_00 != 0) { + ptr->unk_04.x += ptr->unk_10.x; + ptr->unk_04.y += ptr->unk_10.y; + ptr->unk_04.z += ptr->unk_10.z; + ptr->unk_34++; + ptr->unk_10.x += ptr->unk_1C.x; + ptr->unk_10.y += ptr->unk_1C.y; + ptr->unk_10.z += ptr->unk_1C.z; + if (ptr->unk_00 == 1) { + ptr->unk_2A++; + Math_ApproachF(&ptr->unk_10.x, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&ptr->unk_10.z, 0.0f, 1.0f, 0.05f); + if (ptr->unk_10.y < -0.5f) { + ptr->unk_10.y = 0.5f; + } + + ptr->unk_30 = (Math_SinS(ptr->unk_2A * 3000) * M_PI) * 0.2f; + if (ptr->unk_28 < ptr->unk_34) { + ptr->unk_00 = 0; + } + } + } + } +} + +void func_80B13464(EnSyatekiNiw* pthis, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 i; + EnSyatekiNiw_1* ptr = &pthis->unk_348[0]; + u8 flag = 0; + + OPEN_DISPS(gfxCtx, "../z_en_syateki_niw.c", 1234); + + func_80093D84(globalCtx->state.gfxCtx); + + for (i = 0; i < 5; i++, ptr++) { + if (ptr->unk_00 == 1) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); + flag++; + } + + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + func_800D1FD4(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, 1.0f, MTXMODE_APPLY); + Matrix_RotateZ(ptr->unk_30, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_syateki_niw.c", 1251), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); + } + } + + CLOSE_DISPS(gfxCtx, "../z_en_syateki_niw.c", 1257); +} diff --git a/src/overlays/actors/ovl_En_Ta/z_en_ta.c b/src/overlays/actors/ovl_En_Ta/z_en_ta.c deleted file mode 100644 index 98ce8d8d1..000000000 --- a/src/overlays/actors/ovl_En_Ta/z_en_ta.c +++ /dev/null @@ -1,1241 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TA_Z_EN_TA_C -#include "actor_common.h" -/* - * File: z_en_ta.c - * Overlay: ovl_En_Ta - * Description: Talon - */ - -#include "z_en_ta.h" -#include "vt.h" -#include "objects/object_ta/object_ta.h" -#include "def/code_800EC960.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_face_reaction.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) - -void EnTa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTa_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B14634(EnTa* this, GlobalContext* globalCtx); -void func_80B146F8(EnTa* this, GlobalContext* globalCtx); -void func_80B14754(EnTa* this, GlobalContext* globalCtx); -void func_80B14C18(EnTa* this, GlobalContext* globalCtx); -void func_80B14CAC(EnTa* this, GlobalContext* globalCtx); -void func_80B14D98(EnTa* this, GlobalContext* globalCtx); -void func_80B154FC(EnTa* this, GlobalContext* globalCtx); -void func_80B16504(EnTa* this, GlobalContext* globalCtx); -void func_80B16608(EnTa* this, GlobalContext* globalCtx); -void func_80B166CC(EnTa* this); -void func_80B16700(EnTa* this); -void func_80B167C0(EnTa* this); -void func_80B167FC(EnTa* this); -void func_80B16854(EnTa* this); -void func_80B16938(EnTa* this); - -const ActorInit En_Ta_InitVars = { - ACTOR_EN_TA, - ACTORCAT_NPC, - FLAGS, - OBJECT_TA, - sizeof(EnTa), - (ActorFunc)EnTa_Init, - (ActorFunc)EnTa_Destroy, - (ActorFunc)EnTa_Update, - (ActorFunc)EnTa_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000004, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0, 0, 0 } }, -}; - -void func_80B13AA0(EnTa* this, EnTaActionFunc arg1, EnTaUnkFunc arg2) { - this->actionFunc = arg1; - this->unk_260 = arg2; -} - -void func_80B13AAC(EnTa* this, GlobalContext* globalCtx) { - u16 faceReaction = Text_GetFaceReaction(globalCtx, 24); - - if (gSaveContext.eventInf[0] & 0x400) { - if (gSaveContext.eventInf[0] & 0x100) { - if (gSaveContext.itemGetInf[0] & 4) { - this->actor.textId = 0x2088; - } else { - this->actor.textId = 0x2086; - } - } else { - this->actor.textId = 0x2085; - } - gSaveContext.eventInf[0] &= ~0x100; - } else if (faceReaction == 0) { - if (gSaveContext.infTable[7] & 0x4000) { - if (gSaveContext.itemGetInf[0] & 4) { - this->actor.textId = 0x208B; - } else { - this->actor.textId = 0x207F; - } - } else { - this->actor.textId = 0x207E; - } - } else { - this->actor.textId = faceReaction; - } -} - -void EnTa_Init(Actor* thisx, GlobalContext* globalCtx2) { - EnTa* this = (EnTa*)thisx; - GlobalContext* globalCtx = globalCtx2; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gTalonSkel, &gTalonStandAnim, this->jointTable, this->morphTable, - 17); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_2E0 = 0; - this->unk_2CE = 0; - this->unk_2E2 = 0; - this->blinkTimer = 20; - this->unk_2B0 = func_80B166CC; - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->actor.velocity.y = -4.0f; - this->actor.minVelocityY = -4.0f; - this->actor.gravity = -1.0f; - - switch (this->actor.params) { - case 1: - osSyncPrintf(VT_FGCOL(CYAN) " 追放タロン \n" VT_RST); - if (gSaveContext.eventChkInf[6] & 0x800) { - Actor_Kill(&this->actor); - } else if (!LINK_IS_ADULT) { - Actor_Kill(&this->actor); - } else if (gSaveContext.eventChkInf[6] & 0x400) { - func_80B13AA0(this, func_80B14CAC, func_80B167C0); - this->eyeIndex = 0; - Animation_PlayOnce(&this->skelAnime, &gTalonStandAnim); - this->currentAnimation = &gTalonStandAnim; - } else { - func_80B13AA0(this, func_80B14754, func_80B167FC); - this->eyeIndex = 2; - Animation_PlayOnce(&this->skelAnime, &gTalonSleepAnim); - this->currentAnimation = &gTalonSleepAnim; - this->actor.shape.shadowScale = 54.0f; - } - break; - case 2: - osSyncPrintf(VT_FGCOL(CYAN) " 出戻りタロン \n" VT_RST); - if (!(gSaveContext.eventChkInf[6] & 0x800)) { - Actor_Kill(&this->actor); - } else if (!LINK_IS_ADULT) { - Actor_Kill(&this->actor); - } else if (globalCtx->sceneNum == SCENE_MALON_STABLE && gSaveContext.nightFlag) { - Actor_Kill(&this->actor); - osSyncPrintf(VT_FGCOL(CYAN) " 夜はいない \n" VT_RST); - } else { - func_80B13AA0(this, func_80B14D98, func_80B167C0); - this->eyeIndex = 0; - Animation_PlayOnce(&this->skelAnime, &gTalonStandAnim); - this->currentAnimation = &gTalonStandAnim; - } - break; - default: - osSyncPrintf(VT_FGCOL(CYAN) " その他のタロン \n" VT_RST); - if (globalCtx->sceneNum == SCENE_SPOT15) { - if (gSaveContext.eventChkInf[1] & 0x10) { - Actor_Kill(&this->actor); - } else if (gSaveContext.eventChkInf[1] & 0x8) { - func_80B13AA0(this, func_80B14C18, func_80B167C0); - this->eyeIndex = 0; - Animation_PlayOnce(&this->skelAnime, &gTalonStandAnim); - this->currentAnimation = &gTalonStandAnim; - } else { - func_80B13AA0(this, func_80B14634, func_80B167FC); - this->eyeIndex = 2; - Animation_PlayOnce(&this->skelAnime, &gTalonSleepAnim); - this->currentAnimation = &gTalonSleepAnim; - this->actor.shape.shadowScale = 54.0f; - } - } else if (globalCtx->sceneNum == SCENE_SOUKO) { - osSyncPrintf(VT_FGCOL(CYAN) " ロンロン牧場の倉庫 の タロン\n" VT_RST); - if (!(gSaveContext.eventChkInf[1] & 0x10)) { - Actor_Kill(&this->actor); - } else if (LINK_IS_ADULT) { - Actor_Kill(&this->actor); - } else { - if (IS_DAY) { - this->actor.flags |= ACTOR_FLAG_4; - this->unk_2C4[0] = this->unk_2C4[1] = this->unk_2C4[2] = 7; - this->superCuccos[0] = (EnNiw*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x + 5.0f, - this->actor.world.pos.y + 3.0f, this->actor.world.pos.z + 26.0f, 0, 0, 0, 0xD); - this->superCuccos[1] = (EnNiw*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x - 20.0f, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z - 30.0f, 0, 0, 0, 0xD); - this->superCuccos[2] = (EnNiw*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x + 20.0f, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z - 30.0f, 0, 0, 0, 0xD); - func_80B13AAC(this, globalCtx); - - if (gSaveContext.eventInf[0] & 0x400) { - func_80B13AA0(this, func_80B16608, func_80B16938); - Animation_Change(&this->skelAnime, &gTalonSitWakeUpAnim, 1.0f, - Animation_GetLastFrame(&gTalonSitWakeUpAnim) - 1.0f, - Animation_GetLastFrame(&gTalonSitWakeUpAnim), ANIMMODE_ONCE, 0.0f); - gSaveContext.eventInf[0] &= ~0x400; - } else { - func_80B13AA0(this, func_80B16504, func_80B16854); - this->eyeIndex = 0; - Animation_PlayOnce(&this->skelAnime, &gTalonSitSleepingAnim); - this->currentAnimation = &gTalonSitSleepingAnim; - } - } else { - func_80B13AA0(this, func_80B146F8, func_80B167FC); - this->eyeIndex = 2; - Animation_PlayOnce(&this->skelAnime, &gTalonSleepAnim); - this->currentAnimation = &gTalonSleepAnim; - this->actor.shape.shadowScale = 54.0f; - } - } - } else { - func_80B13AA0(this, func_80B14634, func_80B167FC); - this->eyeIndex = 2; - Animation_PlayOnce(&this->skelAnime, &gTalonSleepAnim); - this->currentAnimation = &gTalonSleepAnim; - this->actor.shape.shadowScale = 54.0f; - } - break; - } -} - -void func_80B14248(EnTa* this) { - if (this->actor.shape.shadowScale > 36.0f) { - this->actor.shape.shadowScale -= 0.8f; - } -} - -void EnTa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTa* this = (EnTa*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); - - if (this->actor.params != 1 && this->actor.params != 2 && globalCtx->sceneNum == SCENE_SOUKO) { - gSaveContext.timer1State = 0; - } - - if (this->unk_2E0 & 0x200) { - func_800F5B58(); - } -} - -s32 func_80B142F4(EnTa* this, GlobalContext* globalCtx, u16 textId) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - return true; - } - - this->actor.textId = textId; - - if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4300) && - (this->actor.xzDistToPlayer < 100.0f)) { - this->unk_2E0 |= 1; - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - return false; -} - -void func_80B14398(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B13AA0(this, func_80B14754, func_80B167FC); - } -} - -void func_80B143D4(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B13AA0(this, func_80B146F8, func_80B167FC); - } -} - -void func_80B14410(EnTa* this) { - if (!LINK_IS_ADULT) { - func_80B13AA0(this, func_80B14C18, func_80B167C0); - gSaveContext.eventChkInf[1] |= 0x8; - } else { - func_80B13AA0(this, func_80B14CAC, func_80B167C0); - gSaveContext.eventChkInf[6] |= 0x400; - } -} - -void func_80B1448C(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B14410(this); - } - func_80B14248(this); - this->unk_2E0 |= 0x4; -} - -void func_80B144D8(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B14410(this); - this->blinkTimer = 1; - this->unk_2B0 = func_80B16700; - } - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) { - this->eyeIndex = 1; - func_80B13AA0(this, func_80B1448C, func_80B167C0); - } - func_80B14248(this); - this->unk_2E0 |= 4; -} - -void func_80B14570(EnTa* this, GlobalContext* globalCtx) { - this->unk_2E0 |= 4; - - if (this->unk_2CC == 0) { - func_80B13AA0(this, func_80B144D8, func_80B167C0); - this->unk_2CE = 3; - this->unk_2CC = 60; - Animation_PlayOnce(&this->skelAnime, &gTalonWakeUpAnim); - this->currentAnimation = &gTalonStandAnim; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_TA_SURPRISE); - } -} - -void func_80B145F8(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B13AA0(this, func_80B14634, func_80B167FC); - } -} - -void func_80B14634(EnTa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - s32 exchangeItemId = func_8002F368(globalCtx); - - switch (exchangeItemId) { - case EXCH_ITEM_CHICKEN: - player->actor.textId = 0x702B; - func_80B13AA0(this, func_80B14570, func_80B167C0); - this->unk_2CC = 40; - break; - default: - if (exchangeItemId != EXCH_ITEM_NONE) { - player->actor.textId = 0x702A; - } - func_80B13AA0(this, func_80B145F8, func_80B167FC); - break; - } - } else { - this->actor.textId = 0x702A; - func_8002F298(&this->actor, globalCtx, 100.0f, 3); - } -} - -void func_80B146F8(EnTa* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - func_80B13AA0(this, func_80B143D4, func_80B167FC); - } - this->actor.textId = 0x204B; - func_8002F2CC(&this->actor, globalCtx, 100.0f); -} - -void func_80B14754(EnTa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - s32 exchangeItemId = func_8002F368(globalCtx); - - switch (exchangeItemId) { - case EXCH_ITEM_POCKET_CUCCO: - player->actor.textId = 0x702B; - func_80B13AA0(this, func_80B14570, func_80B167C0); - this->unk_2CC = 40; - break; - default: - if (exchangeItemId != EXCH_ITEM_NONE) { - player->actor.textId = 0x5015; - } - func_80B13AA0(this, func_80B14398, func_80B167FC); - break; - } - } else { - this->actor.textId = 0x5015; - func_8002F298(&this->actor, globalCtx, 100.0f, 6); - } -} - -void func_80B14818(EnTa* this, GlobalContext* globalCtx) { - s32 framesMod12 = (s32)globalCtx->state.frames % 12; - - if (framesMod12 == 0 || framesMod12 == 6) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_GROUND); - } - if (this->actor.speedXZ < 6.0f) { - this->actor.speedXZ += 0.4f; - } - Actor_MoveForward(&this->actor); -} - -void func_80B14898(EnTa* this, GlobalContext* globalCtx) { - func_80033480(globalCtx, &this->actor.world.pos, 50.0f, 2, 250, 20, 1); - func_80B14818(this, globalCtx); - - if (this->unk_2CC == 0) { - Actor_Kill(&this->actor); - } -} - -void func_80B1490C(EnTa* this, GlobalContext* globalCtx) { - this->actor.world.rot.y += 0xC00; - this->actor.shape.rot.y += 0xC00; - - if (this->unk_2CC == 0) { - func_80B13AA0(this, func_80B14898, func_80B167C0); - this->unk_2CC = 60; - } -} - -void func_80B1496C(EnTa* this, GlobalContext* globalCtx) { - func_80033480(globalCtx, &this->actor.world.pos, 50.0f, 2, 250, 20, 1); - func_80B14818(this, globalCtx); - - if (this->unk_2CC == 0) { - func_80B13AA0(this, func_80B1490C, func_80B167C0); - this->unk_2CC = 5; - } -} - -void func_80B149F4(EnTa* this, GlobalContext* globalCtx) { - this->actor.world.rot.y -= 0xD00; - this->actor.shape.rot.y -= 0xD00; - - if (this->unk_2CC == 0) { - func_80B13AA0(this, func_80B1496C, func_80B167C0); - this->unk_2CC = 65; - } -} - -void func_80B14A54(EnTa* this, GlobalContext* globalCtx) { - func_80033480(globalCtx, &this->actor.world.pos, 50.0f, 2, 250, 20, 1); - func_80B14818(this, globalCtx); - - if (this->unk_2CC == 20) { - Message_CloseTextbox(globalCtx); - } - if (this->unk_2CC == 0) { - this->unk_2CC = 5; - func_80B13AA0(this, func_80B149F4, func_80B167C0); - } -} - -void func_80B14AF4(EnTa* this, GlobalContext* globalCtx) { - this->actor.world.rot.y -= 0xC00; - this->actor.shape.rot.y -= 0xC00; - - if (this->unk_2CC == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_TA_CRY_1); - func_80B13AA0(this, func_80B14A54, func_80B167C0); - this->unk_2CC = 65; - this->actor.flags |= ACTOR_FLAG_4; - } -} - -void func_80B14B6C(EnTa* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { - OnePointCutscene_Init(globalCtx, 4175, -99, &this->actor, MAIN_CAM); - func_80B13AA0(this, func_80B14AF4, func_80B167C0); - this->unk_2CC = 5; - gSaveContext.eventChkInf[1] |= 0x10; - Animation_PlayOnce(&this->skelAnime, &gTalonRunTransitionAnim); - this->currentAnimation = &gTalonRunAnim; - } - this->unk_2E0 |= 1; -} - -void func_80B14C18(EnTa* this, GlobalContext* globalCtx) { - if (func_80B142F4(this, globalCtx, 0x702C)) { - func_80B13AA0(this, func_80B14B6C, func_80B167C0); - } - func_80B14248(this); -} - -void func_80B14C60(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B13AA0(this, func_80B14CAC, func_80B167C0); - } - this->unk_2E0 |= 1; -} - -void func_80B14CAC(EnTa* this, GlobalContext* globalCtx) { - if (gSaveContext.eventChkInf[1] & 0x100) { - if (func_80B142F4(this, globalCtx, 0x5017)) { - func_80B13AA0(this, func_80B14C60, func_80B167C0); - gSaveContext.eventChkInf[6] |= 0x800; - } - } else if (func_80B142F4(this, globalCtx, 0x5016)) { - func_80B13AA0(this, func_80B14C60, func_80B167C0); - } - func_80B14248(this); -} - -void func_80B14D4C(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B13AA0(this, func_80B14D98, func_80B167C0); - } - this->unk_2E0 |= 1; -} - -void func_80B14D98(EnTa* this, GlobalContext* globalCtx) { - if (func_80B142F4(this, globalCtx, 0x2055)) { - func_80B13AA0(this, func_80B14D4C, func_80B167C0); - } -} - -s32 func_80B14DD8(void) { - if (gSaveContext.rupees < 30) { - return 0; - } else if (!Inventory_HasEmptyBottle()) { - return 1; - } else { - return 2; - } -} - -void func_80B14E28(EnTa* this, GlobalContext* globalCtx) { - Vec3f b; - Vec3f a; - - this->unk_2D0 = Gameplay_CreateSubCamera(globalCtx); - this->unk_2D2 = globalCtx->activeCamera; - Gameplay_ChangeCameraStatus(globalCtx, this->unk_2D2, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_2D0, CAM_STAT_ACTIVE); - - b.x = 1053.0f; - b.y = 11.0f; - b.z = 22.0f; - - a.x = 1053.0f; - a.y = 45.0f; - a.z = -40.0f; - - Gameplay_CameraSetAtEye(globalCtx, this->unk_2D0, &a, &b); -} - -void func_80B14EDC(EnTa* this, GlobalContext* globalCtx) { - Gameplay_ChangeCameraStatus(globalCtx, this->unk_2D2, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, this->unk_2D0); -} - -void func_80B14F20(EnTa* this, EnTaActionFunc arg1) { - func_80B13AA0(this, arg1, func_80B16854); - this->eyeIndex = 2; - Animation_Change(&this->skelAnime, &gTalonSitSleepingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gTalonSitSleepingAnim), ANIMMODE_ONCE, -5.0f); - this->unk_2E2 = 0; - this->currentAnimation = &gTalonSitSleepingAnim; -} - -void func_80B14FAC(EnTa* this, EnTaActionFunc arg1) { - this->eyeIndex = 1; - func_80B13AA0(this, arg1, func_80B16938); - this->unk_2E0 &= ~0x10; - Animation_Change(&this->skelAnime, &gTalonSitWakeUpAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gTalonSitWakeUpAnim), - ANIMMODE_ONCE, -5.0f); -} - -void func_80B15034(EnTa* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - func_80B14F20(this, func_80B16504); - func_80B13AAC(this, globalCtx); - } - this->unk_2E0 |= 1; -} - -s32 func_80B150AC(EnTa* this, GlobalContext* globalCtx, s32 idx) { - Player* player = GET_PLAYER(globalCtx); - Actor* interactRangeActor; - - if (player->stateFlags1 & 0x800) { - interactRangeActor = player->interactRangeActor; - if (interactRangeActor != NULL && interactRangeActor->id == ACTOR_EN_NIW && - interactRangeActor == &this->superCuccos[idx]->actor) { - return true; - } - } - return false; -} - -void func_80B15100(EnTa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - s32 unk_2CA; - - Animation_Change(&this->skelAnime, &gTalonSitWakeUpAnim, 1.0f, - Animation_GetLastFrame(&gTalonSitWakeUpAnim) - 1.0f, - Animation_GetLastFrame(&gTalonSitWakeUpAnim), ANIMMODE_ONCE, 10.0f); - this->unk_2E0 &= ~0x10; - Message_CloseTextbox(globalCtx); - unk_2CA = this->unk_2CA; - this->actionFunc = func_80B154FC; - this->superCuccos[unk_2CA]->actor.gravity = 0.1f; - this->superCuccos[unk_2CA]->actor.velocity.y = 0.0f; - this->superCuccos[unk_2CA]->actor.speedXZ = 0.0f; - this->superCuccos[unk_2CA]->actor.parent = NULL; - - if (player->interactRangeActor == &this->superCuccos[unk_2CA]->actor) { - player->interactRangeActor = NULL; - } - if (player->heldActor == &this->superCuccos[unk_2CA]->actor) { - player->heldActor = NULL; - } - player->stateFlags1 &= ~0x800; - this->superCuccos[unk_2CA] = NULL; - } - this->unk_2E0 |= 1; -} - -void func_80B15260(EnTa* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->actionFunc = func_80B15100; - this->actor.flags &= ~ACTOR_FLAG_16; - } else { - func_8002F2CC(&this->actor, globalCtx, 1000.0f); - } - this->unk_2E0 |= 1; -} - -s32 EnTa_GetSuperCuccosCount(EnTa* this, GlobalContext* globalCtx) { - s32 count; - s32 i; - - for (count = 0, i = 0; i < ARRAY_COUNT(this->superCuccos); i++) { - if (this->superCuccos[i] != NULL) { - count++; - } - } - return count; -} - -void func_80B15308(EnTa* this) { - if (this->unk_2E0 & 0x10) { - if (this->unk_2E0 & 0x100) { - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 17.0f, 22.0f, ANIMMODE_ONCE, 0.0f); - this->unk_2E0 &= ~0x100; - } else { - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, -1.0f, 21.0f, 16.0f, ANIMMODE_ONCE, 3.0f); - this->unk_2E0 |= 0x100; - } - this->unk_2E0 &= ~0x10; - } -} - -void func_80B153D4(EnTa* this, GlobalContext* globalCtx) { - func_80B15308(this); - - if (this->unk_2CC == 0) { - if (this->unk_2E0 & 0x80) { - this->unk_2E0 &= ~0x80; - func_80B14EDC(this, globalCtx); - } - } -} - -void func_80B15424(EnTa* this, GlobalContext* globalCtx) { - func_80B15308(this); - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - globalCtx->nextEntranceIndex = 0x5E4; - - if (gSaveContext.eventInf[0] & 0x100) { - globalCtx->fadeTransition = 46; - gSaveContext.nextTransition = 3; - } else { - globalCtx->fadeTransition = 38; - gSaveContext.nextTransition = 2; - } - - globalCtx->sceneLoadFlag = 0x14; - gSaveContext.eventInf[0] |= 0x400; - this->actionFunc = func_80B153D4; - this->unk_2CC = 22; - } -} - -void func_80B154FC(EnTa* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < ARRAY_COUNT(this->superCuccos); i++) { - if (this->superCuccos[i] != NULL) { - if (this->superCuccos[i]->actor.gravity > -2.0f) { - this->superCuccos[i]->actor.gravity -= 0.03f; - } - - if (func_80B150AC(this, globalCtx, i)) { - if (this->unk_2C4[i] > 0) { - this->unk_2C4[i]--; - } else { - this->unk_2CA = i; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, -10.0f); - this->unk_2E0 &= ~0x10; - - switch (EnTa_GetSuperCuccosCount(this, globalCtx)) { - case 1: - gSaveContext.timer1State = 0; - func_8002DF54(globalCtx, &this->actor, 1); - - Message_StartTextbox(globalCtx, 0x2084, &this->actor); - this->actionFunc = func_80B15424; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, - -10.0f); - this->unk_2E0 &= ~0x10; - this->unk_2E0 &= ~0x100; - gSaveContext.eventInf[0] |= 0x100; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); - this->unk_2E0 &= ~0x200; - Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); - return; - case 2: - this->actor.textId = 0x2083; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_TA_CRY_1); - break; - case 3: - this->actor.textId = 0x2082; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_TA_SURPRISE); - break; - } - this->actionFunc = func_80B15260; - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2CC(&this->actor, globalCtx, 1000.0f); - return; - } - } else { - this->unk_2C4[i] = 7; - } - } - } - - if (gSaveContext.timer1Value == 10) { - func_800F5918(); - } - - if (gSaveContext.timer1Value == 0 && !Gameplay_InCsMode(globalCtx)) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); - this->unk_2E0 &= ~0x200; - func_80078884(NA_SE_SY_FOUND); - gSaveContext.timer1State = 0; - func_8002DF54(globalCtx, &this->actor, 1); - Message_StartTextbox(globalCtx, 0x2081, &this->actor); - this->actionFunc = func_80B15424; - func_80B14E28(this, globalCtx); - gSaveContext.eventInf[0] &= ~0x100; - this->unk_2E0 |= 0x80; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, -10.0f); - this->unk_2E0 &= ~0x10; - this->unk_2E0 &= ~0x100; - } - - this->unk_2E0 |= 1; -} - -void func_80B1585C(EnTa* this, GlobalContext* globalCtx) { - s32 i; - - if (this->unk_2CC > 35) { - for (i = 1; i < ARRAY_COUNT(this->superCuccos); i++) { - if (this->superCuccos[i] != NULL) { - Math_SmoothStepToS(&this->superCuccos[i]->actor.world.rot.y, i * -10000 - 3000, 2, 0x800, 0x100); - this->superCuccos[i]->actor.shape.rot.y = this->superCuccos[i]->actor.world.rot.y; - } - } - } else if (this->unk_2CC == 35) { - for (i = 0; i < ARRAY_COUNT(this->superCuccos); i++) { - this->unk_2C4[i] = (s32)(Rand_CenteredFloat(6.0f) + 10.0f); - - if (this->superCuccos[i] != NULL) { - EnNiw* niw = this->superCuccos[i]; - - niw->unk_308 = 1; - niw->actor.gravity = 0.0f; - } - } - } else { - for (i = 0; i < ARRAY_COUNT(this->superCuccos); i++) { - if (this->unk_2CC < 35 - this->unk_2C4[i]) { - if (this->superCuccos[i] != NULL) { - if (this->superCuccos[i]->actor.gravity > -2.0f) { - this->superCuccos[i]->actor.gravity -= 0.03f; - } - } - } - } - } - - if (this->unk_2CC == 0) { - func_80B13AA0(this, func_80B154FC, func_80B16938); - this->unk_2E0 &= ~0x10; - Animation_Change(&this->skelAnime, &gTalonSitWakeUpAnim, 1.0f, - Animation_GetLastFrame(&gTalonSitWakeUpAnim) - 1.0f, - Animation_GetLastFrame(&gTalonSitWakeUpAnim), ANIMMODE_ONCE, 10.0f); - func_8002DF54(globalCtx, &this->actor, 7); - } -} - -void func_80B15AD4(EnTa* this, GlobalContext* globalCtx) { - if (this->unk_2CC == 0 && this->unk_2E0 & 0x20) { - func_80B13AA0(this, func_80B1585C, func_80B16938); - this->unk_2E0 &= ~0x10; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 1.0f, - Animation_GetLastFrame(&gTalonSitHandsUpAnim), ANIMMODE_ONCE, 0.0f); - this->unk_2CC = 50; - func_80088B34(0x1E); - func_800F5ACC(NA_BGM_MINI_GAME_2); - this->unk_2E0 |= 0x200; - Message_CloseTextbox(globalCtx); - func_8002DF54(globalCtx, &this->actor, 1); - } - - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->unk_2E0 |= 0x20; - } - - this->unk_2E0 |= 1; -} - -void func_80B15BF8(EnTa* this, GlobalContext* globalCtx) { - if (this->unk_2E0 & 0x10) { - func_80B13AA0(this, func_80B15AD4, func_80B16938); - this->unk_2E0 &= ~0x10; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 0.0f, 1.0f, ANIMMODE_ONCE, 0.0f); - this->unk_2CC = 5; - } - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->unk_2E0 |= 0x20; - } - this->unk_2E0 |= 1; -} - -void func_80B15CC8(EnTa* this, GlobalContext* globalCtx) { - if (this->unk_2E0 & 0x10) { - func_80B13AA0(this, func_80B15BF8, func_80B16938); - this->unk_2E0 &= ~0x10; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, -1.0f, 29.0f, 0.0f, ANIMMODE_ONCE, 10.0f); - } - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->unk_2E0 |= 0x20; - } - this->unk_2E0 |= 1; -} - -void func_80B15D90(EnTa* this, GlobalContext* globalCtx) { - func_80B13AA0(this, func_80B15CC8, func_80B16938); - this->unk_2E0 &= ~0x10; - Animation_Change(&this->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, -10.0f); - Message_ContinueTextbox(globalCtx, 0x2080); - this->unk_2E0 &= ~0x20; -} - -void func_80B15E28(EnTa* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80B14F20(this, func_80B16504); - func_80B13AAC(this, globalCtx); - } - this->unk_2E0 |= 1; -} - -void func_80B15E80(EnTa* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->actionFunc = func_80B15E28; - if (!(this->unk_2E0 & 0x2)) { - gSaveContext.itemGetInf[0] |= 4; - } - this->unk_2E0 &= ~0x2; - } else if (this->unk_2E0 & 2) { - func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); - } else { - func_8002F434(&this->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); - } - this->unk_2E0 |= 1; -} - -void func_80B15F54(EnTa* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->unk_2E0 &= ~0x2; - func_80B13AA0(this, func_80B15E80, func_80B16938); - func_8002F434(&this->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); - } -} - -void func_80B15FE8(EnTa* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - switch (func_80B14DD8()) { - case 0: - Message_ContinueTextbox(globalCtx, 0x85); - func_80B13AA0(this, func_80B15034, func_80B16938); - break; - case 1: - Message_ContinueTextbox(globalCtx, 0x208A); - func_80B13AA0(this, func_80B15E28, func_80B16938); - break; - case 2: - this->unk_2E0 |= 2; - func_80B13AA0(this, func_80B15E80, func_80B16938); - Rupees_ChangeBy(-30); - func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); - break; - } - break; - case 1: - if (gSaveContext.rupees < 10) { - Message_ContinueTextbox(globalCtx, 0x85); - func_80B13AA0(this, func_80B15034, func_80B16938); - } else { - Rupees_ChangeBy(-10); - func_80B15D90(this, globalCtx); - } - break; - case 2: - func_80B14F20(this, func_80B16504); - func_80B13AAC(this, globalCtx); - break; - } - } - - if (this->unk_2E0 & 0x10) { - this->unk_2E0 |= 1; - } -} - -void func_80B161C0(EnTa* this, GlobalContext* globalCtx) { - s32 price; - - if (this->actor.textId == 0x2085) { - price = 5; - } else { - price = 10; - } - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: - if (gSaveContext.rupees < price) { - Message_ContinueTextbox(globalCtx, 0x85); - func_80B13AA0(this, func_80B15034, func_80B16938); - } else { - Rupees_ChangeBy(-price); - func_80B15D90(this, globalCtx); - } - break; - case 1: - func_80B14F20(this, func_80B16504); - func_80B13AAC(this, globalCtx); - break; - } - } - - if (this->unk_2E0 & 0x10) { - this->unk_2E0 |= 1; - } -} - -void func_80B162E8(EnTa* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - Message_ContinueTextbox(globalCtx, 0x2087); - func_80B13AA0(this, func_80B15F54, func_80B16938); - } - - if (this->unk_2E0 & 0x10) { - this->unk_2E0 |= 1; - } -} - -void func_80B16364(EnTa* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - gSaveContext.infTable[7] |= 0x4000; - if (gSaveContext.itemGetInf[0] & 4) { - Message_ContinueTextbox(globalCtx, 0x208B); - func_80B13AA0(this, func_80B15FE8, func_80B16938); - } else { - Message_ContinueTextbox(globalCtx, 0x207F); - func_80B13AA0(this, func_80B161C0, func_80B16938); - } - } - - if (this->unk_2E0 & 0x10) { - this->unk_2E0 |= 1; - } -} - -void func_80B1642C(EnTa* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - if (Inventory_HasEmptyBottle()) { - Message_CloseTextbox(globalCtx); - this->unk_2E0 |= 2; - func_80B13AA0(this, func_80B15E80, func_80B16938); - func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); - } else { - Message_ContinueTextbox(globalCtx, 0x208A); - func_80B13AA0(this, func_80B15E28, func_80B16938); - } - } -} - -void func_80B16504(EnTa* this, GlobalContext* globalCtx) { - u16 faceReaction = Text_GetFaceReaction(globalCtx, 0x18); - - func_80B13AAC(this, globalCtx); - - if (func_80B142F4(this, globalCtx, this->actor.textId)) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_TA_SURPRISE); - - if (faceReaction != 0) { - func_80B14FAC(this, func_80B15E28); - } else { - gSaveContext.infTable[7] |= 0x4000; - - switch (this->actor.textId) { - case 0x207E: - case 0x207F: - func_80B14FAC(this, func_80B161C0); - break; - case 0x208B: - func_80B14FAC(this, func_80B15FE8); - break; - default: - func_80B14FAC(this, func_80B16364); - break; - } - } - } - this->unk_2E0 &= ~1; -} - -void func_80B16608(EnTa* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - switch (this->actor.textId) { - case 0x2085: - this->actionFunc = func_80B161C0; - break; - case 0x2086: - this->actionFunc = func_80B162E8; - break; - case 0x2088: - this->actionFunc = func_80B1642C; - break; - } - this->actor.flags &= ~ACTOR_FLAG_16; - } else { - this->actor.flags |= ACTOR_FLAG_16; - func_8002F2CC(&this->actor, globalCtx, 1000.0f); - } - this->unk_2E0 |= 1; -} - -void func_80B166CC(EnTa* this) { - s16 temp_v0 = this->blinkTimer - 1; - - if (temp_v0 != 0) { - this->blinkTimer = temp_v0; - } else { - this->unk_2B0 = func_80B16700; - } -} - -void func_80B16700(EnTa* this) { - s16 blinkTimer = this->blinkTimer - 1; - - if (blinkTimer != 0) { - this->blinkTimer = blinkTimer; - } else { - s16 nextEyeIndex = this->eyeIndex + 1; - s16 blinkTimer = 3; - - if (nextEyeIndex >= blinkTimer) { - this->eyeIndex = 0; - if (this->unk_2CE > 0) { - this->unk_2CE--; - blinkTimer = 1; - } else { - blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; - } - this->blinkTimer = blinkTimer; - this->unk_2B0 = func_80B166CC; - } else { - this->eyeIndex = nextEyeIndex; - this->blinkTimer = 1; - } - } -} - -void func_80B167C0(EnTa* this) { - if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayOnce(&this->skelAnime, this->currentAnimation); - } -} - -void func_80B167FC(EnTa* this) { - if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayOnce(&this->skelAnime, this->currentAnimation); - Audio_PlayActorSound2(&this->actor, NA_SE_VO_TA_SLEEP); - } - this->unk_2E0 |= 0xC; -} - -void func_80B16854(EnTa* this) { - if (this->unk_2E2 > 0) { - this->unk_2E2--; - } else { - if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayOnce(&this->skelAnime, this->currentAnimation); - this->unk_2E2 = Rand_ZeroFloat(100.0f) + 100.0f; - } - - if (this->skelAnime.curFrame < 96.0f && this->skelAnime.curFrame >= 53.0f) { - this->eyeIndex = 1; - } else { - this->eyeIndex = 2; - } - this->unk_2E0 |= 8; - } - this->unk_2E0 |= 4; -} - -void func_80B16938(EnTa* this) { - if (!(this->unk_2E0 & 0x10)) { - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_2E0 |= 0x10; - } - this->unk_2E0 |= 8; - } -} - -void EnTa_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTa* this = (EnTa*)thisx; - s32 pad; - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->unk_260(this); - this->actionFunc(this, globalCtx); - - if (!(this->unk_2E0 & 4)) { - this->unk_2B0(this); - } - - if (this->unk_2E0 & 1) { - func_80038290(globalCtx, &this->actor, &this->unk_2D4, &this->unk_2DA, this->actor.focus.pos); - } else { - Math_SmoothStepToS(&this->unk_2D4.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2D4.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2DA.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_2DA.y, 0, 6, 6200, 100); - } - - this->unk_2E0 &= ~0x5; - - if (this->unk_2CC > 0) { - this->unk_2CC--; - } -} - -s32 EnTa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnTa* this = (EnTa*)thisx; - - switch (limbIndex) { - case 8: - rot->x += this->unk_2DA.y; - rot->y -= this->unk_2DA.x; - break; - case 15: - rot->x += this->unk_2D4.y; - rot->z += this->unk_2D4.x; - break; - } - - if (this->unk_2E0 & 0x8) { - this->unk_2E0 &= ~0x8; - } else if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { - s32 limbIdx50 = limbIndex * 50; - - rot->y += Math_SinS(globalCtx->state.frames * (limbIdx50 + 0x814)) * 200.0f; - rot->z += Math_CosS(globalCtx->state.frames * (limbIdx50 + 0x940)) * 200.0f; - } - - return false; -} - -void EnTa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f D_80B16E7C = { - 1100.0f, - 1000.0f, - 0.0f, - }; - EnTa* this = (EnTa*)thisx; - - if (limbIndex == 15) { - Matrix_MultVec3f(&D_80B16E7C, &this->actor.focus.pos); - } -} - -void EnTa_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { - gTalonEyeOpenTex, - gTalonEyeHalfTex, - gTalonEyeClosedTex, - }; - EnTa* this = (EnTa*)thisx; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ta.c", 2381); - - func_800943C8(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); - gSPSegment(POLY_OPA_DISP++, 0x9, SEGMENTED_TO_VIRTUAL(gTalonHeadSkinTex)); - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnTa_OverrideLimbDraw, EnTa_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ta.c", 2400); -} diff --git a/src/overlays/actors/ovl_En_Ta/z_en_ta.cpp b/src/overlays/actors/ovl_En_Ta/z_en_ta.cpp new file mode 100644 index 000000000..10f78779b --- /dev/null +++ b/src/overlays/actors/ovl_En_Ta/z_en_ta.cpp @@ -0,0 +1,1241 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TA_Z_EN_TA_C +#include "actor_common.h" +/* + * File: z_en_ta.c + * Overlay: ovl_En_Ta + * Description: Talon + */ + +#include "z_en_ta.h" +#include "vt.h" +#include "objects/object_ta/object_ta.h" +#include "def/code_800EC960.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_face_reaction.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) + +void EnTa_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTa_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTa_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTa_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B14634(EnTa* pthis, GlobalContext* globalCtx); +void func_80B146F8(EnTa* pthis, GlobalContext* globalCtx); +void func_80B14754(EnTa* pthis, GlobalContext* globalCtx); +void func_80B14C18(EnTa* pthis, GlobalContext* globalCtx); +void func_80B14CAC(EnTa* pthis, GlobalContext* globalCtx); +void func_80B14D98(EnTa* pthis, GlobalContext* globalCtx); +void func_80B154FC(EnTa* pthis, GlobalContext* globalCtx); +void func_80B16504(EnTa* pthis, GlobalContext* globalCtx); +void func_80B16608(EnTa* pthis, GlobalContext* globalCtx); +void func_80B166CC(EnTa* pthis); +void func_80B16700(EnTa* pthis); +void func_80B167C0(EnTa* pthis); +void func_80B167FC(EnTa* pthis); +void func_80B16854(EnTa* pthis); +void func_80B16938(EnTa* pthis); + +ActorInit En_Ta_InitVars = { + ACTOR_EN_TA, + ACTORCAT_NPC, + FLAGS, + OBJECT_TA, + sizeof(EnTa), + (ActorFunc)EnTa_Init, + (ActorFunc)EnTa_Destroy, + (ActorFunc)EnTa_Update, + (ActorFunc)EnTa_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000004, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0, 0, 0 } }, +}; + +void func_80B13AA0(EnTa* pthis, EnTaActionFunc arg1, EnTaUnkFunc arg2) { + pthis->actionFunc = arg1; + pthis->unk_260 = arg2; +} + +void func_80B13AAC(EnTa* pthis, GlobalContext* globalCtx) { + u16 faceReaction = Text_GetFaceReaction(globalCtx, 24); + + if (gSaveContext.eventInf[0] & 0x400) { + if (gSaveContext.eventInf[0] & 0x100) { + if (gSaveContext.itemGetInf[0] & 4) { + pthis->actor.textId = 0x2088; + } else { + pthis->actor.textId = 0x2086; + } + } else { + pthis->actor.textId = 0x2085; + } + gSaveContext.eventInf[0] &= ~0x100; + } else if (faceReaction == 0) { + if (gSaveContext.infTable[7] & 0x4000) { + if (gSaveContext.itemGetInf[0] & 4) { + pthis->actor.textId = 0x208B; + } else { + pthis->actor.textId = 0x207F; + } + } else { + pthis->actor.textId = 0x207E; + } + } else { + pthis->actor.textId = faceReaction; + } +} + +void EnTa_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnTa* pthis = (EnTa*)thisx; + GlobalContext* globalCtx = globalCtx2; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gTalonSkel, &gTalonStandAnim, pthis->jointTable, pthis->morphTable, + 17); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->unk_2E0 = 0; + pthis->unk_2CE = 0; + pthis->unk_2E2 = 0; + pthis->blinkTimer = 20; + pthis->unk_2B0 = func_80B166CC; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->actor.velocity.y = -4.0f; + pthis->actor.minVelocityY = -4.0f; + pthis->actor.gravity = -1.0f; + + switch (pthis->actor.params) { + case 1: + osSyncPrintf(VT_FGCOL(CYAN) " 追放タロン \n" VT_RST); + if (gSaveContext.eventChkInf[6] & 0x800) { + Actor_Kill(&pthis->actor); + } else if (!LINK_IS_ADULT) { + Actor_Kill(&pthis->actor); + } else if (gSaveContext.eventChkInf[6] & 0x400) { + func_80B13AA0(pthis, func_80B14CAC, func_80B167C0); + pthis->eyeIndex = 0; + Animation_PlayOnce(&pthis->skelAnime, &gTalonStandAnim); + pthis->currentAnimation = &gTalonStandAnim; + } else { + func_80B13AA0(pthis, func_80B14754, func_80B167FC); + pthis->eyeIndex = 2; + Animation_PlayOnce(&pthis->skelAnime, &gTalonSleepAnim); + pthis->currentAnimation = &gTalonSleepAnim; + pthis->actor.shape.shadowScale = 54.0f; + } + break; + case 2: + osSyncPrintf(VT_FGCOL(CYAN) " 出戻りタロン \n" VT_RST); + if (!(gSaveContext.eventChkInf[6] & 0x800)) { + Actor_Kill(&pthis->actor); + } else if (!LINK_IS_ADULT) { + Actor_Kill(&pthis->actor); + } else if (globalCtx->sceneNum == SCENE_MALON_STABLE && gSaveContext.nightFlag) { + Actor_Kill(&pthis->actor); + osSyncPrintf(VT_FGCOL(CYAN) " 夜はいない \n" VT_RST); + } else { + func_80B13AA0(pthis, func_80B14D98, func_80B167C0); + pthis->eyeIndex = 0; + Animation_PlayOnce(&pthis->skelAnime, &gTalonStandAnim); + pthis->currentAnimation = &gTalonStandAnim; + } + break; + default: + osSyncPrintf(VT_FGCOL(CYAN) " その他のタロン \n" VT_RST); + if (globalCtx->sceneNum == SCENE_SPOT15) { + if (gSaveContext.eventChkInf[1] & 0x10) { + Actor_Kill(&pthis->actor); + } else if (gSaveContext.eventChkInf[1] & 0x8) { + func_80B13AA0(pthis, func_80B14C18, func_80B167C0); + pthis->eyeIndex = 0; + Animation_PlayOnce(&pthis->skelAnime, &gTalonStandAnim); + pthis->currentAnimation = &gTalonStandAnim; + } else { + func_80B13AA0(pthis, func_80B14634, func_80B167FC); + pthis->eyeIndex = 2; + Animation_PlayOnce(&pthis->skelAnime, &gTalonSleepAnim); + pthis->currentAnimation = &gTalonSleepAnim; + pthis->actor.shape.shadowScale = 54.0f; + } + } else if (globalCtx->sceneNum == SCENE_SOUKO) { + osSyncPrintf(VT_FGCOL(CYAN) " ロンロン牧場の倉庫 の タロン\n" VT_RST); + if (!(gSaveContext.eventChkInf[1] & 0x10)) { + Actor_Kill(&pthis->actor); + } else if (LINK_IS_ADULT) { + Actor_Kill(&pthis->actor); + } else { + if (IS_DAY) { + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->unk_2C4[0] = pthis->unk_2C4[1] = pthis->unk_2C4[2] = 7; + pthis->superCuccos[0] = (EnNiw*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, pthis->actor.world.pos.x + 5.0f, + pthis->actor.world.pos.y + 3.0f, pthis->actor.world.pos.z + 26.0f, 0, 0, 0, 0xD); + pthis->superCuccos[1] = (EnNiw*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, pthis->actor.world.pos.x - 20.0f, + pthis->actor.world.pos.y + 40.0f, pthis->actor.world.pos.z - 30.0f, 0, 0, 0, 0xD); + pthis->superCuccos[2] = (EnNiw*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, pthis->actor.world.pos.x + 20.0f, + pthis->actor.world.pos.y + 40.0f, pthis->actor.world.pos.z - 30.0f, 0, 0, 0, 0xD); + func_80B13AAC(pthis, globalCtx); + + if (gSaveContext.eventInf[0] & 0x400) { + func_80B13AA0(pthis, func_80B16608, func_80B16938); + Animation_Change(&pthis->skelAnime, &gTalonSitWakeUpAnim, 1.0f, + Animation_GetLastFrame(&gTalonSitWakeUpAnim) - 1.0f, + Animation_GetLastFrame(&gTalonSitWakeUpAnim), ANIMMODE_ONCE, 0.0f); + gSaveContext.eventInf[0] &= ~0x400; + } else { + func_80B13AA0(pthis, func_80B16504, func_80B16854); + pthis->eyeIndex = 0; + Animation_PlayOnce(&pthis->skelAnime, &gTalonSitSleepingAnim); + pthis->currentAnimation = &gTalonSitSleepingAnim; + } + } else { + func_80B13AA0(pthis, func_80B146F8, func_80B167FC); + pthis->eyeIndex = 2; + Animation_PlayOnce(&pthis->skelAnime, &gTalonSleepAnim); + pthis->currentAnimation = &gTalonSleepAnim; + pthis->actor.shape.shadowScale = 54.0f; + } + } + } else { + func_80B13AA0(pthis, func_80B14634, func_80B167FC); + pthis->eyeIndex = 2; + Animation_PlayOnce(&pthis->skelAnime, &gTalonSleepAnim); + pthis->currentAnimation = &gTalonSleepAnim; + pthis->actor.shape.shadowScale = 54.0f; + } + break; + } +} + +void func_80B14248(EnTa* pthis) { + if (pthis->actor.shape.shadowScale > 36.0f) { + pthis->actor.shape.shadowScale -= 0.8f; + } +} + +void EnTa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTa* pthis = (EnTa*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); + + if (pthis->actor.params != 1 && pthis->actor.params != 2 && globalCtx->sceneNum == SCENE_SOUKO) { + gSaveContext.timer1State = 0; + } + + if (pthis->unk_2E0 & 0x200) { + func_800F5B58(); + } +} + +s32 func_80B142F4(EnTa* pthis, GlobalContext* globalCtx, u16 textId) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + return true; + } + + pthis->actor.textId = textId; + + if ((ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4300) && + (pthis->actor.xzDistToPlayer < 100.0f)) { + pthis->unk_2E0 |= 1; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + return false; +} + +void func_80B14398(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B13AA0(pthis, func_80B14754, func_80B167FC); + } +} + +void func_80B143D4(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B13AA0(pthis, func_80B146F8, func_80B167FC); + } +} + +void func_80B14410(EnTa* pthis) { + if (!LINK_IS_ADULT) { + func_80B13AA0(pthis, func_80B14C18, func_80B167C0); + gSaveContext.eventChkInf[1] |= 0x8; + } else { + func_80B13AA0(pthis, func_80B14CAC, func_80B167C0); + gSaveContext.eventChkInf[6] |= 0x400; + } +} + +void func_80B1448C(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B14410(pthis); + } + func_80B14248(pthis); + pthis->unk_2E0 |= 0x4; +} + +void func_80B144D8(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B14410(pthis); + pthis->blinkTimer = 1; + pthis->unk_2B0 = func_80B16700; + } + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) { + pthis->eyeIndex = 1; + func_80B13AA0(pthis, func_80B1448C, func_80B167C0); + } + func_80B14248(pthis); + pthis->unk_2E0 |= 4; +} + +void func_80B14570(EnTa* pthis, GlobalContext* globalCtx) { + pthis->unk_2E0 |= 4; + + if (pthis->unk_2CC == 0) { + func_80B13AA0(pthis, func_80B144D8, func_80B167C0); + pthis->unk_2CE = 3; + pthis->unk_2CC = 60; + Animation_PlayOnce(&pthis->skelAnime, &gTalonWakeUpAnim); + pthis->currentAnimation = &gTalonStandAnim; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_TA_SURPRISE); + } +} + +void func_80B145F8(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B13AA0(pthis, func_80B14634, func_80B167FC); + } +} + +void func_80B14634(EnTa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + s32 exchangeItemId = func_8002F368(globalCtx); + + switch (exchangeItemId) { + case EXCH_ITEM_CHICKEN: + player->actor.textId = 0x702B; + func_80B13AA0(pthis, func_80B14570, func_80B167C0); + pthis->unk_2CC = 40; + break; + default: + if (exchangeItemId != EXCH_ITEM_NONE) { + player->actor.textId = 0x702A; + } + func_80B13AA0(pthis, func_80B145F8, func_80B167FC); + break; + } + } else { + pthis->actor.textId = 0x702A; + func_8002F298(&pthis->actor, globalCtx, 100.0f, 3); + } +} + +void func_80B146F8(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + func_80B13AA0(pthis, func_80B143D4, func_80B167FC); + } + pthis->actor.textId = 0x204B; + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); +} + +void func_80B14754(EnTa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + s32 exchangeItemId = func_8002F368(globalCtx); + + switch (exchangeItemId) { + case EXCH_ITEM_POCKET_CUCCO: + player->actor.textId = 0x702B; + func_80B13AA0(pthis, func_80B14570, func_80B167C0); + pthis->unk_2CC = 40; + break; + default: + if (exchangeItemId != EXCH_ITEM_NONE) { + player->actor.textId = 0x5015; + } + func_80B13AA0(pthis, func_80B14398, func_80B167FC); + break; + } + } else { + pthis->actor.textId = 0x5015; + func_8002F298(&pthis->actor, globalCtx, 100.0f, 6); + } +} + +void func_80B14818(EnTa* pthis, GlobalContext* globalCtx) { + s32 framesMod12 = (s32)globalCtx->state.frames % 12; + + if (framesMod12 == 0 || framesMod12 == 6) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_WALK_GROUND); + } + if (pthis->actor.speedXZ < 6.0f) { + pthis->actor.speedXZ += 0.4f; + } + Actor_MoveForward(&pthis->actor); +} + +void func_80B14898(EnTa* pthis, GlobalContext* globalCtx) { + func_80033480(globalCtx, &pthis->actor.world.pos, 50.0f, 2, 250, 20, 1); + func_80B14818(pthis, globalCtx); + + if (pthis->unk_2CC == 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_80B1490C(EnTa* pthis, GlobalContext* globalCtx) { + pthis->actor.world.rot.y += 0xC00; + pthis->actor.shape.rot.y += 0xC00; + + if (pthis->unk_2CC == 0) { + func_80B13AA0(pthis, func_80B14898, func_80B167C0); + pthis->unk_2CC = 60; + } +} + +void func_80B1496C(EnTa* pthis, GlobalContext* globalCtx) { + func_80033480(globalCtx, &pthis->actor.world.pos, 50.0f, 2, 250, 20, 1); + func_80B14818(pthis, globalCtx); + + if (pthis->unk_2CC == 0) { + func_80B13AA0(pthis, func_80B1490C, func_80B167C0); + pthis->unk_2CC = 5; + } +} + +void func_80B149F4(EnTa* pthis, GlobalContext* globalCtx) { + pthis->actor.world.rot.y -= 0xD00; + pthis->actor.shape.rot.y -= 0xD00; + + if (pthis->unk_2CC == 0) { + func_80B13AA0(pthis, func_80B1496C, func_80B167C0); + pthis->unk_2CC = 65; + } +} + +void func_80B14A54(EnTa* pthis, GlobalContext* globalCtx) { + func_80033480(globalCtx, &pthis->actor.world.pos, 50.0f, 2, 250, 20, 1); + func_80B14818(pthis, globalCtx); + + if (pthis->unk_2CC == 20) { + Message_CloseTextbox(globalCtx); + } + if (pthis->unk_2CC == 0) { + pthis->unk_2CC = 5; + func_80B13AA0(pthis, func_80B149F4, func_80B167C0); + } +} + +void func_80B14AF4(EnTa* pthis, GlobalContext* globalCtx) { + pthis->actor.world.rot.y -= 0xC00; + pthis->actor.shape.rot.y -= 0xC00; + + if (pthis->unk_2CC == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_TA_CRY_1); + func_80B13AA0(pthis, func_80B14A54, func_80B167C0); + pthis->unk_2CC = 65; + pthis->actor.flags |= ACTOR_FLAG_4; + } +} + +void func_80B14B6C(EnTa* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { + OnePointCutscene_Init(globalCtx, 4175, -99, &pthis->actor, MAIN_CAM); + func_80B13AA0(pthis, func_80B14AF4, func_80B167C0); + pthis->unk_2CC = 5; + gSaveContext.eventChkInf[1] |= 0x10; + Animation_PlayOnce(&pthis->skelAnime, &gTalonRunTransitionAnim); + pthis->currentAnimation = &gTalonRunAnim; + } + pthis->unk_2E0 |= 1; +} + +void func_80B14C18(EnTa* pthis, GlobalContext* globalCtx) { + if (func_80B142F4(pthis, globalCtx, 0x702C)) { + func_80B13AA0(pthis, func_80B14B6C, func_80B167C0); + } + func_80B14248(pthis); +} + +void func_80B14C60(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B13AA0(pthis, func_80B14CAC, func_80B167C0); + } + pthis->unk_2E0 |= 1; +} + +void func_80B14CAC(EnTa* pthis, GlobalContext* globalCtx) { + if (gSaveContext.eventChkInf[1] & 0x100) { + if (func_80B142F4(pthis, globalCtx, 0x5017)) { + func_80B13AA0(pthis, func_80B14C60, func_80B167C0); + gSaveContext.eventChkInf[6] |= 0x800; + } + } else if (func_80B142F4(pthis, globalCtx, 0x5016)) { + func_80B13AA0(pthis, func_80B14C60, func_80B167C0); + } + func_80B14248(pthis); +} + +void func_80B14D4C(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B13AA0(pthis, func_80B14D98, func_80B167C0); + } + pthis->unk_2E0 |= 1; +} + +void func_80B14D98(EnTa* pthis, GlobalContext* globalCtx) { + if (func_80B142F4(pthis, globalCtx, 0x2055)) { + func_80B13AA0(pthis, func_80B14D4C, func_80B167C0); + } +} + +s32 func_80B14DD8(void) { + if (gSaveContext.rupees < 30) { + return 0; + } else if (!Inventory_HasEmptyBottle()) { + return 1; + } else { + return 2; + } +} + +void func_80B14E28(EnTa* pthis, GlobalContext* globalCtx) { + Vec3f b; + Vec3f a; + + pthis->unk_2D0 = Gameplay_CreateSubCamera(globalCtx); + pthis->unk_2D2 = globalCtx->activeCamera; + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_2D2, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_2D0, CAM_STAT_ACTIVE); + + b.x = 1053.0f; + b.y = 11.0f; + b.z = 22.0f; + + a.x = 1053.0f; + a.y = 45.0f; + a.z = -40.0f; + + Gameplay_CameraSetAtEye(globalCtx, pthis->unk_2D0, &a, &b); +} + +void func_80B14EDC(EnTa* pthis, GlobalContext* globalCtx) { + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_2D2, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, pthis->unk_2D0); +} + +void func_80B14F20(EnTa* pthis, EnTaActionFunc arg1) { + func_80B13AA0(pthis, arg1, func_80B16854); + pthis->eyeIndex = 2; + Animation_Change(&pthis->skelAnime, &gTalonSitSleepingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gTalonSitSleepingAnim), ANIMMODE_ONCE, -5.0f); + pthis->unk_2E2 = 0; + pthis->currentAnimation = &gTalonSitSleepingAnim; +} + +void func_80B14FAC(EnTa* pthis, EnTaActionFunc arg1) { + pthis->eyeIndex = 1; + func_80B13AA0(pthis, arg1, func_80B16938); + pthis->unk_2E0 &= ~0x10; + Animation_Change(&pthis->skelAnime, &gTalonSitWakeUpAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gTalonSitWakeUpAnim), + ANIMMODE_ONCE, -5.0f); +} + +void func_80B15034(EnTa* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + func_80B14F20(pthis, func_80B16504); + func_80B13AAC(pthis, globalCtx); + } + pthis->unk_2E0 |= 1; +} + +s32 func_80B150AC(EnTa* pthis, GlobalContext* globalCtx, s32 idx) { + Player* player = GET_PLAYER(globalCtx); + Actor* interactRangeActor; + + if (player->stateFlags1 & 0x800) { + interactRangeActor = player->interactRangeActor; + if (interactRangeActor != NULL && interactRangeActor->id == ACTOR_EN_NIW && + interactRangeActor == &pthis->superCuccos[idx]->actor) { + return true; + } + } + return false; +} + +void func_80B15100(EnTa* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + s32 unk_2CA; + + Animation_Change(&pthis->skelAnime, &gTalonSitWakeUpAnim, 1.0f, + Animation_GetLastFrame(&gTalonSitWakeUpAnim) - 1.0f, + Animation_GetLastFrame(&gTalonSitWakeUpAnim), ANIMMODE_ONCE, 10.0f); + pthis->unk_2E0 &= ~0x10; + Message_CloseTextbox(globalCtx); + unk_2CA = pthis->unk_2CA; + pthis->actionFunc = func_80B154FC; + pthis->superCuccos[unk_2CA]->actor.gravity = 0.1f; + pthis->superCuccos[unk_2CA]->actor.velocity.y = 0.0f; + pthis->superCuccos[unk_2CA]->actor.speedXZ = 0.0f; + pthis->superCuccos[unk_2CA]->actor.parent = NULL; + + if (player->interactRangeActor == &pthis->superCuccos[unk_2CA]->actor) { + player->interactRangeActor = NULL; + } + if (player->heldActor == &pthis->superCuccos[unk_2CA]->actor) { + player->heldActor = NULL; + } + player->stateFlags1 &= ~0x800; + pthis->superCuccos[unk_2CA] = NULL; + } + pthis->unk_2E0 |= 1; +} + +void func_80B15260(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80B15100; + pthis->actor.flags &= ~ACTOR_FLAG_16; + } else { + func_8002F2CC(&pthis->actor, globalCtx, 1000.0f); + } + pthis->unk_2E0 |= 1; +} + +s32 EnTa_GetSuperCuccosCount(EnTa* pthis, GlobalContext* globalCtx) { + s32 count; + s32 i; + + for (count = 0, i = 0; i < ARRAY_COUNT(pthis->superCuccos); i++) { + if (pthis->superCuccos[i] != NULL) { + count++; + } + } + return count; +} + +void func_80B15308(EnTa* pthis) { + if (pthis->unk_2E0 & 0x10) { + if (pthis->unk_2E0 & 0x100) { + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 17.0f, 22.0f, ANIMMODE_ONCE, 0.0f); + pthis->unk_2E0 &= ~0x100; + } else { + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, -1.0f, 21.0f, 16.0f, ANIMMODE_ONCE, 3.0f); + pthis->unk_2E0 |= 0x100; + } + pthis->unk_2E0 &= ~0x10; + } +} + +void func_80B153D4(EnTa* pthis, GlobalContext* globalCtx) { + func_80B15308(pthis); + + if (pthis->unk_2CC == 0) { + if (pthis->unk_2E0 & 0x80) { + pthis->unk_2E0 &= ~0x80; + func_80B14EDC(pthis, globalCtx); + } + } +} + +void func_80B15424(EnTa* pthis, GlobalContext* globalCtx) { + func_80B15308(pthis); + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + globalCtx->nextEntranceIndex = 0x5E4; + + if (gSaveContext.eventInf[0] & 0x100) { + globalCtx->fadeTransition = 46; + gSaveContext.nextTransition = 3; + } else { + globalCtx->fadeTransition = 38; + gSaveContext.nextTransition = 2; + } + + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.eventInf[0] |= 0x400; + pthis->actionFunc = func_80B153D4; + pthis->unk_2CC = 22; + } +} + +void func_80B154FC(EnTa* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(pthis->superCuccos); i++) { + if (pthis->superCuccos[i] != NULL) { + if (pthis->superCuccos[i]->actor.gravity > -2.0f) { + pthis->superCuccos[i]->actor.gravity -= 0.03f; + } + + if (func_80B150AC(pthis, globalCtx, i)) { + if (pthis->unk_2C4[i] > 0) { + pthis->unk_2C4[i]--; + } else { + pthis->unk_2CA = i; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, -10.0f); + pthis->unk_2E0 &= ~0x10; + + switch (EnTa_GetSuperCuccosCount(pthis, globalCtx)) { + case 1: + gSaveContext.timer1State = 0; + func_8002DF54(globalCtx, &pthis->actor, 1); + + Message_StartTextbox(globalCtx, 0x2084, &pthis->actor); + pthis->actionFunc = func_80B15424; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, + -10.0f); + pthis->unk_2E0 &= ~0x10; + pthis->unk_2E0 &= ~0x100; + gSaveContext.eventInf[0] |= 0x100; + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + pthis->unk_2E0 &= ~0x200; + Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); + return; + case 2: + pthis->actor.textId = 0x2083; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_TA_CRY_1); + break; + case 3: + pthis->actor.textId = 0x2082; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_TA_SURPRISE); + break; + } + pthis->actionFunc = func_80B15260; + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2CC(&pthis->actor, globalCtx, 1000.0f); + return; + } + } else { + pthis->unk_2C4[i] = 7; + } + } + } + + if (gSaveContext.timer1Value == 10) { + func_800F5918(); + } + + if (gSaveContext.timer1Value == 0 && !Gameplay_InCsMode(globalCtx)) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + pthis->unk_2E0 &= ~0x200; + func_80078884(NA_SE_SY_FOUND); + gSaveContext.timer1State = 0; + func_8002DF54(globalCtx, &pthis->actor, 1); + Message_StartTextbox(globalCtx, 0x2081, &pthis->actor); + pthis->actionFunc = func_80B15424; + func_80B14E28(pthis, globalCtx); + gSaveContext.eventInf[0] &= ~0x100; + pthis->unk_2E0 |= 0x80; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, -10.0f); + pthis->unk_2E0 &= ~0x10; + pthis->unk_2E0 &= ~0x100; + } + + pthis->unk_2E0 |= 1; +} + +void func_80B1585C(EnTa* pthis, GlobalContext* globalCtx) { + s32 i; + + if (pthis->unk_2CC > 35) { + for (i = 1; i < ARRAY_COUNT(pthis->superCuccos); i++) { + if (pthis->superCuccos[i] != NULL) { + Math_SmoothStepToS(&pthis->superCuccos[i]->actor.world.rot.y, i * -10000 - 3000, 2, 0x800, 0x100); + pthis->superCuccos[i]->actor.shape.rot.y = pthis->superCuccos[i]->actor.world.rot.y; + } + } + } else if (pthis->unk_2CC == 35) { + for (i = 0; i < ARRAY_COUNT(pthis->superCuccos); i++) { + pthis->unk_2C4[i] = (s32)(Rand_CenteredFloat(6.0f) + 10.0f); + + if (pthis->superCuccos[i] != NULL) { + EnNiw* niw = pthis->superCuccos[i]; + + niw->unk_308 = 1; + niw->actor.gravity = 0.0f; + } + } + } else { + for (i = 0; i < ARRAY_COUNT(pthis->superCuccos); i++) { + if (pthis->unk_2CC < 35 - pthis->unk_2C4[i]) { + if (pthis->superCuccos[i] != NULL) { + if (pthis->superCuccos[i]->actor.gravity > -2.0f) { + pthis->superCuccos[i]->actor.gravity -= 0.03f; + } + } + } + } + } + + if (pthis->unk_2CC == 0) { + func_80B13AA0(pthis, func_80B154FC, func_80B16938); + pthis->unk_2E0 &= ~0x10; + Animation_Change(&pthis->skelAnime, &gTalonSitWakeUpAnim, 1.0f, + Animation_GetLastFrame(&gTalonSitWakeUpAnim) - 1.0f, + Animation_GetLastFrame(&gTalonSitWakeUpAnim), ANIMMODE_ONCE, 10.0f); + func_8002DF54(globalCtx, &pthis->actor, 7); + } +} + +void func_80B15AD4(EnTa* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2CC == 0 && pthis->unk_2E0 & 0x20) { + func_80B13AA0(pthis, func_80B1585C, func_80B16938); + pthis->unk_2E0 &= ~0x10; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 1.0f, + Animation_GetLastFrame(&gTalonSitHandsUpAnim), ANIMMODE_ONCE, 0.0f); + pthis->unk_2CC = 50; + func_80088B34(0x1E); + func_800F5ACC(NA_BGM_MINI_GAME_2); + pthis->unk_2E0 |= 0x200; + Message_CloseTextbox(globalCtx); + func_8002DF54(globalCtx, &pthis->actor, 1); + } + + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->unk_2E0 |= 0x20; + } + + pthis->unk_2E0 |= 1; +} + +void func_80B15BF8(EnTa* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2E0 & 0x10) { + func_80B13AA0(pthis, func_80B15AD4, func_80B16938); + pthis->unk_2E0 &= ~0x10; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 0.0f, 1.0f, ANIMMODE_ONCE, 0.0f); + pthis->unk_2CC = 5; + } + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->unk_2E0 |= 0x20; + } + pthis->unk_2E0 |= 1; +} + +void func_80B15CC8(EnTa* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2E0 & 0x10) { + func_80B13AA0(pthis, func_80B15BF8, func_80B16938); + pthis->unk_2E0 &= ~0x10; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, -1.0f, 29.0f, 0.0f, ANIMMODE_ONCE, 10.0f); + } + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->unk_2E0 |= 0x20; + } + pthis->unk_2E0 |= 1; +} + +void func_80B15D90(EnTa* pthis, GlobalContext* globalCtx) { + func_80B13AA0(pthis, func_80B15CC8, func_80B16938); + pthis->unk_2E0 &= ~0x10; + Animation_Change(&pthis->skelAnime, &gTalonSitHandsUpAnim, 1.0f, 8.0f, 29.0f, ANIMMODE_ONCE, -10.0f); + Message_ContinueTextbox(globalCtx, 0x2080); + pthis->unk_2E0 &= ~0x20; +} + +void func_80B15E28(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_80B14F20(pthis, func_80B16504); + func_80B13AAC(pthis, globalCtx); + } + pthis->unk_2E0 |= 1; +} + +void func_80B15E80(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->actionFunc = func_80B15E28; + if (!(pthis->unk_2E0 & 0x2)) { + gSaveContext.itemGetInf[0] |= 4; + } + pthis->unk_2E0 &= ~0x2; + } else if (pthis->unk_2E0 & 2) { + func_8002F434(&pthis->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); + } else { + func_8002F434(&pthis->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); + } + pthis->unk_2E0 |= 1; +} + +void func_80B15F54(EnTa* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->unk_2E0 &= ~0x2; + func_80B13AA0(pthis, func_80B15E80, func_80B16938); + func_8002F434(&pthis->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); + } +} + +void func_80B15FE8(EnTa* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + switch (func_80B14DD8()) { + case 0: + Message_ContinueTextbox(globalCtx, 0x85); + func_80B13AA0(pthis, func_80B15034, func_80B16938); + break; + case 1: + Message_ContinueTextbox(globalCtx, 0x208A); + func_80B13AA0(pthis, func_80B15E28, func_80B16938); + break; + case 2: + pthis->unk_2E0 |= 2; + func_80B13AA0(pthis, func_80B15E80, func_80B16938); + Rupees_ChangeBy(-30); + func_8002F434(&pthis->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); + break; + } + break; + case 1: + if (gSaveContext.rupees < 10) { + Message_ContinueTextbox(globalCtx, 0x85); + func_80B13AA0(pthis, func_80B15034, func_80B16938); + } else { + Rupees_ChangeBy(-10); + func_80B15D90(pthis, globalCtx); + } + break; + case 2: + func_80B14F20(pthis, func_80B16504); + func_80B13AAC(pthis, globalCtx); + break; + } + } + + if (pthis->unk_2E0 & 0x10) { + pthis->unk_2E0 |= 1; + } +} + +void func_80B161C0(EnTa* pthis, GlobalContext* globalCtx) { + s32 price; + + if (pthis->actor.textId == 0x2085) { + price = 5; + } else { + price = 10; + } + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < price) { + Message_ContinueTextbox(globalCtx, 0x85); + func_80B13AA0(pthis, func_80B15034, func_80B16938); + } else { + Rupees_ChangeBy(-price); + func_80B15D90(pthis, globalCtx); + } + break; + case 1: + func_80B14F20(pthis, func_80B16504); + func_80B13AAC(pthis, globalCtx); + break; + } + } + + if (pthis->unk_2E0 & 0x10) { + pthis->unk_2E0 |= 1; + } +} + +void func_80B162E8(EnTa* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + Message_ContinueTextbox(globalCtx, 0x2087); + func_80B13AA0(pthis, func_80B15F54, func_80B16938); + } + + if (pthis->unk_2E0 & 0x10) { + pthis->unk_2E0 |= 1; + } +} + +void func_80B16364(EnTa* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + gSaveContext.infTable[7] |= 0x4000; + if (gSaveContext.itemGetInf[0] & 4) { + Message_ContinueTextbox(globalCtx, 0x208B); + func_80B13AA0(pthis, func_80B15FE8, func_80B16938); + } else { + Message_ContinueTextbox(globalCtx, 0x207F); + func_80B13AA0(pthis, func_80B161C0, func_80B16938); + } + } + + if (pthis->unk_2E0 & 0x10) { + pthis->unk_2E0 |= 1; + } +} + +void func_80B1642C(EnTa* pthis, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + if (Inventory_HasEmptyBottle()) { + Message_CloseTextbox(globalCtx); + pthis->unk_2E0 |= 2; + func_80B13AA0(pthis, func_80B15E80, func_80B16938); + func_8002F434(&pthis->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); + } else { + Message_ContinueTextbox(globalCtx, 0x208A); + func_80B13AA0(pthis, func_80B15E28, func_80B16938); + } + } +} + +void func_80B16504(EnTa* pthis, GlobalContext* globalCtx) { + u16 faceReaction = Text_GetFaceReaction(globalCtx, 0x18); + + func_80B13AAC(pthis, globalCtx); + + if (func_80B142F4(pthis, globalCtx, pthis->actor.textId)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_TA_SURPRISE); + + if (faceReaction != 0) { + func_80B14FAC(pthis, func_80B15E28); + } else { + gSaveContext.infTable[7] |= 0x4000; + + switch (pthis->actor.textId) { + case 0x207E: + case 0x207F: + func_80B14FAC(pthis, func_80B161C0); + break; + case 0x208B: + func_80B14FAC(pthis, func_80B15FE8); + break; + default: + func_80B14FAC(pthis, func_80B16364); + break; + } + } + } + pthis->unk_2E0 &= ~1; +} + +void func_80B16608(EnTa* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + switch (pthis->actor.textId) { + case 0x2085: + pthis->actionFunc = func_80B161C0; + break; + case 0x2086: + pthis->actionFunc = func_80B162E8; + break; + case 0x2088: + pthis->actionFunc = func_80B1642C; + break; + } + pthis->actor.flags &= ~ACTOR_FLAG_16; + } else { + pthis->actor.flags |= ACTOR_FLAG_16; + func_8002F2CC(&pthis->actor, globalCtx, 1000.0f); + } + pthis->unk_2E0 |= 1; +} + +void func_80B166CC(EnTa* pthis) { + s16 temp_v0 = pthis->blinkTimer - 1; + + if (temp_v0 != 0) { + pthis->blinkTimer = temp_v0; + } else { + pthis->unk_2B0 = func_80B16700; + } +} + +void func_80B16700(EnTa* pthis) { + s16 blinkTimer = pthis->blinkTimer - 1; + + if (blinkTimer != 0) { + pthis->blinkTimer = blinkTimer; + } else { + s16 nextEyeIndex = pthis->eyeIndex + 1; + s16 blinkTimer = 3; + + if (nextEyeIndex >= blinkTimer) { + pthis->eyeIndex = 0; + if (pthis->unk_2CE > 0) { + pthis->unk_2CE--; + blinkTimer = 1; + } else { + blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } + pthis->blinkTimer = blinkTimer; + pthis->unk_2B0 = func_80B166CC; + } else { + pthis->eyeIndex = nextEyeIndex; + pthis->blinkTimer = 1; + } + } +} + +void func_80B167C0(EnTa* pthis) { + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_PlayOnce(&pthis->skelAnime, pthis->currentAnimation); + } +} + +void func_80B167FC(EnTa* pthis) { + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_PlayOnce(&pthis->skelAnime, pthis->currentAnimation); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_TA_SLEEP); + } + pthis->unk_2E0 |= 0xC; +} + +void func_80B16854(EnTa* pthis) { + if (pthis->unk_2E2 > 0) { + pthis->unk_2E2--; + } else { + if (SkelAnime_Update(&pthis->skelAnime)) { + Animation_PlayOnce(&pthis->skelAnime, pthis->currentAnimation); + pthis->unk_2E2 = Rand_ZeroFloat(100.0f) + 100.0f; + } + + if (pthis->skelAnime.curFrame < 96.0f && pthis->skelAnime.curFrame >= 53.0f) { + pthis->eyeIndex = 1; + } else { + pthis->eyeIndex = 2; + } + pthis->unk_2E0 |= 8; + } + pthis->unk_2E0 |= 4; +} + +void func_80B16938(EnTa* pthis) { + if (!(pthis->unk_2E0 & 0x10)) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_2E0 |= 0x10; + } + pthis->unk_2E0 |= 8; + } +} + +void EnTa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTa* pthis = (EnTa*)thisx; + s32 pad; + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->unk_260(pthis); + pthis->actionFunc(pthis, globalCtx); + + if (!(pthis->unk_2E0 & 4)) { + pthis->unk_2B0(pthis); + } + + if (pthis->unk_2E0 & 1) { + func_80038290(globalCtx, &pthis->actor, &pthis->unk_2D4, &pthis->unk_2DA, pthis->actor.focus.pos); + } else { + Math_SmoothStepToS(&pthis->unk_2D4.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2D4.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2DA.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&pthis->unk_2DA.y, 0, 6, 6200, 100); + } + + pthis->unk_2E0 &= ~0x5; + + if (pthis->unk_2CC > 0) { + pthis->unk_2CC--; + } +} + +s32 EnTa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnTa* pthis = (EnTa*)thisx; + + switch (limbIndex) { + case 8: + rot->x += pthis->unk_2DA.y; + rot->y -= pthis->unk_2DA.x; + break; + case 15: + rot->x += pthis->unk_2D4.y; + rot->z += pthis->unk_2D4.x; + break; + } + + if (pthis->unk_2E0 & 0x8) { + pthis->unk_2E0 &= ~0x8; + } else if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { + s32 limbIdx50 = limbIndex * 50; + + rot->y += Math_SinS(globalCtx->state.frames * (limbIdx50 + 0x814)) * 200.0f; + rot->z += Math_CosS(globalCtx->state.frames * (limbIdx50 + 0x940)) * 200.0f; + } + + return false; +} + +void EnTa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f D_80B16E7C = { + 1100.0f, + 1000.0f, + 0.0f, + }; + EnTa* pthis = (EnTa*)thisx; + + if (limbIndex == 15) { + Matrix_MultVec3f(&D_80B16E7C, &pthis->actor.focus.pos); + } +} + +void EnTa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { + gTalonEyeOpenTex, + gTalonEyeHalfTex, + gTalonEyeClosedTex, + }; + EnTa* pthis = (EnTa*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ta.c", 2381); + + func_800943C8(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x9, SEGMENTED_TO_VIRTUAL(gTalonHeadSkinTex)); + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnTa_OverrideLimbDraw, EnTa_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_ta.c", 2400); +} diff --git a/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c b/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c deleted file mode 100644 index a9b42ff30..000000000 --- a/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c +++ /dev/null @@ -1,237 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TAKARA_MAN_Z_EN_TAKARA_MAN_C -#include "actor_common.h" -/* - * File: z_en_takara_man.c - * Overlay: ovl_En_Takara_Man - * Description: Treasure Chest Game Man - */ - -#include "z_en_takara_man.h" -#include "vt.h" -#include "objects/object_ts/object_ts.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_27) - -void EnTakaraMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTakaraMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTakaraMan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTakaraMan_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B176E0(EnTakaraMan* this, GlobalContext* globalCtx); -void func_80B1778C(EnTakaraMan* this, GlobalContext* globalCtx); -void func_80B17B14(EnTakaraMan* this, GlobalContext* globalCtx); -void func_80B17934(EnTakaraMan* this, GlobalContext* globalCtx); -void func_80B17A6C(EnTakaraMan* this, GlobalContext* globalCtx); -void func_80B17AC4(EnTakaraMan* this, GlobalContext* globalCtx); - -const ActorInit En_Takara_Man_InitVars = { - ACTOR_EN_TAKARA_MAN, - ACTORCAT_NPC, - FLAGS, - OBJECT_TS, - sizeof(EnTakaraMan), - (ActorFunc)EnTakaraMan_Init, - (ActorFunc)EnTakaraMan_Destroy, - (ActorFunc)EnTakaraMan_Update, - (ActorFunc)EnTakaraMan_Draw, -}; - -static u8 sTakaraIsInitialized = false; - -void EnTakaraMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnTakaraMan_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTakaraMan* this = (EnTakaraMan*)thisx; - - if (sTakaraIsInitialized) { - Actor_Kill(&this->actor); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もういてる原 ☆☆☆☆☆ \n" VT_RST); // "Already initialized" - return; - } - - sTakaraIsInitialized = true; - osSyncPrintf("\n\n"); - // "Bun! %x" (needs a better translation) - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ばぅん! ☆☆☆☆☆ %x\n" VT_RST, globalCtx->actorCtx.flags.chest); - globalCtx->actorCtx.flags.chest = 0; - gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] = -1; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ts_Skel_004FE0, &object_ts_Anim_000498, this->jointTable, - this->morphTable, 10); - thisx->focus.pos = thisx->world.pos; - this->pos = thisx->world.pos; - thisx->world.pos.x = 133.0f; - thisx->world.pos.y = -12.0f; - thisx->world.pos.z = 102.0f; - Actor_SetScale(&this->actor, 0.013f); - this->height = 90.0f; - this->originalRoomNum = thisx->room; - thisx->room = -1; - thisx->world.rot.y = thisx->shape.rot.y = -0x4E20; - thisx->targetMode = 1; - this->actionFunc = func_80B176E0; -} - -void func_80B176E0(EnTakaraMan* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_ts_Anim_000498); - - Animation_Change(&this->skelAnime, &object_ts_Anim_000498, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - if (!this->unk_214) { - this->actor.textId = 0x6D; - this->dialogState = TEXT_STATE_CHOICE; - } - this->actionFunc = func_80B1778C; -} - -void func_80B1778C(EnTakaraMan* this, GlobalContext* globalCtx) { - s16 absYawDiff; - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, globalCtx) && this->dialogState != TEXT_STATE_DONE) { - if (!this->unk_214) { - this->actionFunc = func_80B17934; - } else { - this->actionFunc = func_80B17B14; - } - } else { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (globalCtx->roomCtx.curRoom.num == 6 && !this->unk_21A) { - this->actor.textId = 0x6E; - this->unk_21A = 1; - this->dialogState = TEXT_STATE_DONE; - } - - if (!this->unk_21A && this->unk_214) { - if (Flags_GetSwitch(globalCtx, 0x32)) { - this->actor.textId = 0x84; - this->dialogState = TEXT_STATE_EVENT; - } else { - this->actor.textId = 0x704C; - this->dialogState = TEXT_STATE_DONE; - } - } - - absYawDiff = ABS(yawDiff); - if (absYawDiff < 0x4300) { - if (globalCtx->roomCtx.curRoom.num != this->originalRoomNum) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_218 = 0; - } else { - if (!this->unk_218) { - this->actor.flags |= ACTOR_FLAG_0; - this->unk_218 = 1; - } - func_8002F2CC(&this->actor, globalCtx, 100.0f); - } - } - } -} - -void func_80B17934(EnTakaraMan* this, GlobalContext* globalCtx) { - if (this->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { - case 0: // Yes - if (gSaveContext.rupees >= 10) { - Message_CloseTextbox(globalCtx); - Rupees_ChangeBy(-10); - this->unk_214 = 1; - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, GI_DOOR_KEY, 2000.0f, 1000.0f); - this->actionFunc = func_80B17A6C; - } else { - Message_CloseTextbox(globalCtx); - this->actor.textId = 0x85; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - this->actionFunc = func_80B17B14; - } - break; - case 1: // No - Message_CloseTextbox(globalCtx); - this->actor.textId = 0x2D; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->dialogState = TEXT_STATE_EVENT; - this->actionFunc = func_80B17B14; - break; - } - } -} - -void func_80B17A6C(EnTakaraMan* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actionFunc = func_80B17AC4; - } else { - func_8002F434(&this->actor, globalCtx, GI_DOOR_KEY, 2000.0f, 1000.0f); - } -} - -void func_80B17AC4(EnTakaraMan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = func_80B176E0; - } -} - -void func_80B17B14(EnTakaraMan* this, GlobalContext* globalCtx) { - if (this->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - Message_CloseTextbox(globalCtx); - this->actionFunc = func_80B176E0; - } -} - -void EnTakaraMan_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTakaraMan* this = (EnTakaraMan*)thisx; - - if (this->eyeTimer != 0) { - this->eyeTimer--; - } - - Actor_SetFocus(&this->actor, this->height); - func_80038290(globalCtx, &this->actor, &this->unk_22C, &this->unk_232, this->actor.focus.pos); - if (this->eyeTimer == 0) { - this->eyeTextureIdx++; - if (this->eyeTextureIdx >= 2) { - this->eyeTextureIdx = 0; - this->eyeTimer = (s16)Rand_ZeroFloat(60.0f) + 20; - } - } - this->unk_212++; - this->actionFunc(this, globalCtx); -} - -s32 EnTakaraMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnTakaraMan* this = (EnTakaraMan*)thisx; - - if (limbIndex == 1) { - rot->x += this->unk_232.y; - } - if (limbIndex == 8) { - rot->x += this->unk_22C.y; - rot->z += this->unk_22C.z; - } - return false; -} - -void EnTakaraMan_Draw(Actor* thisx, GlobalContext* globalCtx) { - static void* eyeTextures[] = { - object_ts_Tex_000970, - object_ts_Tex_000D70, - }; - EnTakaraMan* this = (EnTakaraMan*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_takara_man.c", 528); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnTakaraMan_OverrideLimbDraw, NULL, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_takara_man.c", 544); -} diff --git a/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.cpp b/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.cpp new file mode 100644 index 000000000..8ea0b4091 --- /dev/null +++ b/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.cpp @@ -0,0 +1,237 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TAKARA_MAN_Z_EN_TAKARA_MAN_C +#include "actor_common.h" +/* + * File: z_en_takara_man.c + * Overlay: ovl_En_Takara_Man + * Description: Treasure Chest Game Man + */ + +#include "z_en_takara_man.h" +#include "vt.h" +#include "objects/object_ts/object_ts.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_27) + +void EnTakaraMan_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTakaraMan_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTakaraMan_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTakaraMan_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B176E0(EnTakaraMan* pthis, GlobalContext* globalCtx); +void func_80B1778C(EnTakaraMan* pthis, GlobalContext* globalCtx); +void func_80B17B14(EnTakaraMan* pthis, GlobalContext* globalCtx); +void func_80B17934(EnTakaraMan* pthis, GlobalContext* globalCtx); +void func_80B17A6C(EnTakaraMan* pthis, GlobalContext* globalCtx); +void func_80B17AC4(EnTakaraMan* pthis, GlobalContext* globalCtx); + +ActorInit En_Takara_Man_InitVars = { + ACTOR_EN_TAKARA_MAN, + ACTORCAT_NPC, + FLAGS, + OBJECT_TS, + sizeof(EnTakaraMan), + (ActorFunc)EnTakaraMan_Init, + (ActorFunc)EnTakaraMan_Destroy, + (ActorFunc)EnTakaraMan_Update, + (ActorFunc)EnTakaraMan_Draw, +}; + +static u8 sTakaraIsInitialized = false; + +void EnTakaraMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnTakaraMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTakaraMan* pthis = (EnTakaraMan*)thisx; + + if (sTakaraIsInitialized) { + Actor_Kill(&pthis->actor); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もういてる原 ☆☆☆☆☆ \n" VT_RST); // "Already initialized" + return; + } + + sTakaraIsInitialized = true; + osSyncPrintf("\n\n"); + // "Bun! %x" (needs a better translation) + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ばぅん! ☆☆☆☆☆ %x\n" VT_RST, globalCtx->actorCtx.flags.chest); + globalCtx->actorCtx.flags.chest = 0; + gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] = -1; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_ts_Skel_004FE0, &object_ts_Anim_000498, pthis->jointTable, + pthis->morphTable, 10); + thisx->focus.pos = thisx->world.pos; + pthis->pos = thisx->world.pos; + thisx->world.pos.x = 133.0f; + thisx->world.pos.y = -12.0f; + thisx->world.pos.z = 102.0f; + Actor_SetScale(&pthis->actor, 0.013f); + pthis->height = 90.0f; + pthis->originalRoomNum = thisx->room; + thisx->room = -1; + thisx->world.rot.y = thisx->shape.rot.y = -0x4E20; + thisx->targetMode = 1; + pthis->actionFunc = func_80B176E0; +} + +void func_80B176E0(EnTakaraMan* pthis, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&object_ts_Anim_000498); + + Animation_Change(&pthis->skelAnime, &object_ts_Anim_000498, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); + if (!pthis->unk_214) { + pthis->actor.textId = 0x6D; + pthis->dialogState = TEXT_STATE_CHOICE; + } + pthis->actionFunc = func_80B1778C; +} + +void func_80B1778C(EnTakaraMan* pthis, GlobalContext* globalCtx) { + s16 absYawDiff; + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx) && pthis->dialogState != TEXT_STATE_DONE) { + if (!pthis->unk_214) { + pthis->actionFunc = func_80B17934; + } else { + pthis->actionFunc = func_80B17B14; + } + } else { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (globalCtx->roomCtx.curRoom.num == 6 && !pthis->unk_21A) { + pthis->actor.textId = 0x6E; + pthis->unk_21A = 1; + pthis->dialogState = TEXT_STATE_DONE; + } + + if (!pthis->unk_21A && pthis->unk_214) { + if (Flags_GetSwitch(globalCtx, 0x32)) { + pthis->actor.textId = 0x84; + pthis->dialogState = TEXT_STATE_EVENT; + } else { + pthis->actor.textId = 0x704C; + pthis->dialogState = TEXT_STATE_DONE; + } + } + + absYawDiff = ABS(yawDiff); + if (absYawDiff < 0x4300) { + if (globalCtx->roomCtx.curRoom.num != pthis->originalRoomNum) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_218 = 0; + } else { + if (!pthis->unk_218) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->unk_218 = 1; + } + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); + } + } + } +} + +void func_80B17934(EnTakaraMan* pthis, GlobalContext* globalCtx) { + if (pthis->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // Yes + if (gSaveContext.rupees >= 10) { + Message_CloseTextbox(globalCtx); + Rupees_ChangeBy(-10); + pthis->unk_214 = 1; + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, GI_DOOR_KEY, 2000.0f, 1000.0f); + pthis->actionFunc = func_80B17A6C; + } else { + Message_CloseTextbox(globalCtx); + pthis->actor.textId = 0x85; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + pthis->actionFunc = func_80B17B14; + } + break; + case 1: // No + Message_CloseTextbox(globalCtx); + pthis->actor.textId = 0x2D; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->dialogState = TEXT_STATE_EVENT; + pthis->actionFunc = func_80B17B14; + break; + } + } +} + +void func_80B17A6C(EnTakaraMan* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actionFunc = func_80B17AC4; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_DOOR_KEY, 2000.0f, 1000.0f); + } +} + +void func_80B17AC4(EnTakaraMan* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { + pthis->actionFunc = func_80B176E0; + } +} + +void func_80B17B14(EnTakaraMan* pthis, GlobalContext* globalCtx) { + if (pthis->dialogState == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + Message_CloseTextbox(globalCtx); + pthis->actionFunc = func_80B176E0; + } +} + +void EnTakaraMan_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTakaraMan* pthis = (EnTakaraMan*)thisx; + + if (pthis->eyeTimer != 0) { + pthis->eyeTimer--; + } + + Actor_SetFocus(&pthis->actor, pthis->height); + func_80038290(globalCtx, &pthis->actor, &pthis->unk_22C, &pthis->unk_232, pthis->actor.focus.pos); + if (pthis->eyeTimer == 0) { + pthis->eyeTextureIdx++; + if (pthis->eyeTextureIdx >= 2) { + pthis->eyeTextureIdx = 0; + pthis->eyeTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + pthis->unk_212++; + pthis->actionFunc(pthis, globalCtx); +} + +s32 EnTakaraMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnTakaraMan* pthis = (EnTakaraMan*)thisx; + + if (limbIndex == 1) { + rot->x += pthis->unk_232.y; + } + if (limbIndex == 8) { + rot->x += pthis->unk_22C.y; + rot->z += pthis->unk_22C.z; + } + return false; +} + +void EnTakaraMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static void* eyeTextures[] = { + object_ts_Tex_000970, + object_ts_Tex_000D70, + }; + EnTakaraMan* pthis = (EnTakaraMan*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_takara_man.c", 528); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTextureIdx])); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnTakaraMan_OverrideLimbDraw, NULL, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_takara_man.c", 544); +} diff --git a/src/overlays/actors/ovl_En_Tana/z_en_tana.c b/src/overlays/actors/ovl_En_Tana/z_en_tana.cpp similarity index 92% rename from src/overlays/actors/ovl_En_Tana/z_en_tana.c rename to src/overlays/actors/ovl_En_Tana/z_en_tana.cpp index 62d51520f..b91e714a8 100644 --- a/src/overlays/actors/ovl_En_Tana/z_en_tana.c +++ b/src/overlays/actors/ovl_En_Tana/z_en_tana.cpp @@ -20,7 +20,7 @@ void EnTana_Update(Actor* thisx, GlobalContext* globalCtx); void EnTana_DrawWoodenShelves(Actor* thisx, GlobalContext* globalCtx); void EnTana_DrawStoneShelves(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Tana_InitVars = { +ActorInit En_Tana_InitVars = { ACTOR_EN_TANA, ACTORCAT_PROP, FLAGS, @@ -34,7 +34,7 @@ const ActorInit En_Tana_InitVars = { //! @bug A third entry is missing here. When printing the string indexed by `params` for type 2, the //! next data entry will be dereferenced and print garbage, stopping any future printing. -//! In a non-matching context, this can cause a crash if the next item isn't a valid pointer. +//! In a non-matching context, pthis can cause a crash if the next item isn't a valid pointer. static const char* sShelfTypes[] = { "木の棚", // "Wooden Shelves" "石の棚", // "Stone Shelves" @@ -59,7 +59,7 @@ static void* sStoneTextures[] = { }; void EnTana_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTana* this = (EnTana*)thisx; + EnTana* pthis = (EnTana*)thisx; osSyncPrintf("☆☆☆ %s ☆☆☆\n", sShelfTypes[thisx->params]); Actor_SetScale(thisx, 1.0f); @@ -74,7 +74,7 @@ void EnTana_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnTana_DrawWoodenShelves(Actor* thisx, GlobalContext* globalCtx) { - EnTana* this = (EnTana*)thisx; + EnTana* pthis = (EnTana*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tana.c", 148); @@ -87,7 +87,7 @@ void EnTana_DrawWoodenShelves(Actor* thisx, GlobalContext* globalCtx) { } void EnTana_DrawStoneShelves(Actor* thisx, GlobalContext* globalCtx) { - EnTana* this = (EnTana*)thisx; + EnTana* pthis = (EnTana*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tana.c", 163); diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c deleted file mode 100644 index 4385c7db1..000000000 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ /dev/null @@ -1,2072 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TEST_Z_EN_TEST_C -#include "actor_common.h" -/* - * File: z_en_test.c - * Overlay: ovl_En_Test - * Description: Stalfos - */ - -#include "z_en_test.h" -#include "objects/object_sk2/object_sk2.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnTest_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnTest_SetupWaitGround(EnTest* this); -void EnTest_SetupWaitAbove(EnTest* this); -void EnTest_SetupJumpBack(EnTest* this); -void EnTest_SetupSlashDownEnd(EnTest* this); -void EnTest_SetupSlashUp(EnTest* this); -void EnTest_SetupJumpslash(EnTest* this); -void EnTest_SetupWalkAndBlock(EnTest* this); -void func_80860EC0(EnTest* this); -void EnTest_SetupSlashDown(EnTest* this); -void func_80860BDC(EnTest* this); -void EnTest_SetupIdleFromBlock(EnTest* this); -void EnTest_SetupRecoil(EnTest* this); -void func_80862398(EnTest* this); -void func_80862154(EnTest* this); -void EnTest_SetupStopAndBlock(EnTest* this); -void func_808627C4(EnTest* this, GlobalContext* globalCtx); - -void EnTest_WaitGround(EnTest* this, GlobalContext* globalCtx); -void EnTest_WaitAbove(EnTest* this, GlobalContext* globalCtx); -void EnTest_Fall(EnTest* this, GlobalContext* globalCtx); -void EnTest_Land(EnTest* this, GlobalContext* globalCtx); -void EnTest_Rise(EnTest* this, GlobalContext* globalCtx); -void EnTest_Idle(EnTest* this, GlobalContext* globalCtx); -void EnTest_WalkAndBlock(EnTest* this, GlobalContext* globalCtx); -void func_80860C24(EnTest* this, GlobalContext* globalCtx); -void func_80860F84(EnTest* this, GlobalContext* globalCtx); -void EnTest_SlashDown(EnTest* this, GlobalContext* globalCtx); -void EnTest_SlashDownEnd(EnTest* this, GlobalContext* globalCtx); -void EnTest_SlashUp(EnTest* this, GlobalContext* globalCtx); -void EnTest_JumpBack(EnTest* this, GlobalContext* globalCtx); -void EnTest_Jumpslash(EnTest* this, GlobalContext* globalCtx); -void EnTest_JumpUp(EnTest* this, GlobalContext* globalCtx); -void EnTest_StopAndBlock(EnTest* this, GlobalContext* globalCtx); -void EnTest_IdleFromBlock(EnTest* this, GlobalContext* globalCtx); -void func_808621D4(EnTest* this, GlobalContext* globalCtx); -void func_80862418(EnTest* this, GlobalContext* globalCtx); -void EnTest_Stunned(EnTest* this, GlobalContext* globalCtx); -void func_808628C8(EnTest* this, GlobalContext* globalCtx); -void func_80862E6C(EnTest* this, GlobalContext* globalCtx); -void func_80863044(EnTest* this, GlobalContext* globalCtx); -void func_8086318C(EnTest* this, GlobalContext* globalCtx); -void EnTest_Recoil(EnTest* this, GlobalContext* globalCtx); -void func_808633E8(EnTest* this, GlobalContext* globalCtx); -void func_80862FA8(EnTest* this, GlobalContext* globalCtx); - -s32 EnTest_ReactToProjectile(GlobalContext* globalCtx, EnTest* this); - -static u8 sJointCopyFlags[] = { - false, // STALFOS_LIMB_NONE - false, // STALFOS_LIMB_ROOT - false, // STALFOS_LIMB_UPPERBODY_ROOT - false, // STALFOS_LIMB_CORE_LOWER_ROOT - true, // STALFOS_LIMB_CORE_UPPER_ROOT - true, // STALFOS_LIMB_NECK_ROOT - true, // STALFOS_LIMB_HEAD_ROOT - true, // STALFOS_LIMB_7 - true, // STALFOS_LIMB_8 - true, // STALFOS_LIMB_JAW_ROOT - true, // STALFOS_LIMB_JAW - true, // STALFOS_LIMB_HEAD - true, // STALFOS_LIMB_NECK_UPPER - true, // STALFOS_LIMB_NECK_LOWER - true, // STALFOS_LIMB_CORE_UPPER - true, // STALFOS_LIMB_CHEST - true, // STALFOS_LIMB_SHOULDER_R_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_R_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_R - true, // STALFOS_LIMB_SHOULDER_L_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_L_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_L - true, // STALFOS_LIMB_ARM_L_ROOT - true, // STALFOS_LIMB_UPPERARM_L_ROOT - true, // STALFOS_LIMB_FOREARM_L_ROOT - true, // STALFOS_LIMB_HAND_L_ROOT - true, // STALFOS_LIMB_HAND_L - true, // STALFOS_LIMB_SHIELD - true, // STALFOS_LIMB_FOREARM_L - true, // STALFOS_LIMB_UPPERARM_L - true, // STALFOS_LIMB_ARM_R_ROOT - true, // STALFOS_LIMB_UPPERARM_R_ROOT - true, // STALFOS_LIMB_FOREARM_R_ROOT - true, // STALFOS_LIMB_HAND_R_ROOT - true, // STALFOS_LIMB_SWORD - true, // STALFOS_LIMB_HAND_R - true, // STALFOS_LIMB_FOREARM_R - true, // STALFOS_LIMB_UPPERARM_R - true, // STALFOS_LIMB_CORE_LOWER - false, // STALFOS_LIMB_LOWERBODY_ROOT - false, // STALFOS_LIMB_WAIST_ROOT - false, // STALFOS_LIMB_LEGS_ROOT - false, // STALFOS_LIMB_LEG_L_ROOT - false, // STALFOS_LIMB_THIGH_L_ROOT - false, // STALFOS_LIMB_LOWERLEG_L_ROOT - false, // STALFOS_LIMB_ANKLE_L_ROOT - false, // STALFOS_LIMB_ANKLE_L - false, // STALFOS_LIMB_FOOT_L_ROOT - false, // STALFOS_LIMB_FOOT_L - false, // STALFOS_LIMB_LOWERLEG_L - false, // STALFOS_LIMB_THIGH_L - false, // STALFOS_LIMB_LEG_R_ROOT - false, // STALFOS_LIMB_THIGH_R_ROOT - false, // STALFOS_LIMB_LOWERLEG_R_ROOT - false, // STALFOS_LIMB_ANKLE_R_ROOT - false, // STALFOS_LIMB_ANKLE_R - false, // STALFOS_LIMB_FOOT_R_ROOT - false, // STALFOS_LIMB_FOOT_R - false, // STALFOS_LIMB_LOWERLEG_R - false, // STALFOS_LIMB_THIGH_R - false, // STALFOS_LIMB_WAIST -}; - -const ActorInit En_Test_InitVars = { - ACTOR_EN_TEST, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_SK2, - sizeof(EnTest), - (ActorFunc)EnTest_Init, - (ActorFunc)EnTest_Destroy, - (ActorFunc)EnTest_Update, - (ActorFunc)EnTest_Draw, -}; - -static ColliderCylinderInit sBodyColliderInit = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 25, 65, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sShieldColliderInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC1FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 20, 70, -50, { 0, 0, 0 } }, -}; - -static ColliderQuadInit sSwordColliderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x10 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -typedef enum { - /* 0x0 */ STALFOS_DMGEFF_NORMAL, - /* 0x1 */ STALFOS_DMGEFF_STUN, - /* 0x6 */ STALFOS_DMGEFF_FIREMAGIC = 6, - /* 0xD */ STALFOS_DMGEFF_SLING = 0xD, - /* 0xE */ STALFOS_DMGEFF_LIGHT, - /* 0xF */ STALFOS_DMGEFF_FREEZE -} StalfosDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, STALFOS_DMGEFF_STUN), - /* Deku stick */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Slingshot */ DMG_ENTRY(1, STALFOS_DMGEFF_SLING), - /* Explosive */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Boomerang */ DMG_ENTRY(0, STALFOS_DMGEFF_STUN), - /* Normal arrow */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Hammer swing */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Hookshot */ DMG_ENTRY(0, STALFOS_DMGEFF_STUN), - /* Kokiri sword */ DMG_ENTRY(1, STALFOS_DMGEFF_NORMAL), - /* Master sword */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Giant's Knife */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), - /* Fire arrow */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Ice arrow */ DMG_ENTRY(4, STALFOS_DMGEFF_FREEZE), - /* Light arrow */ DMG_ENTRY(2, STALFOS_DMGEFF_LIGHT), - /* Unk arrow 1 */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Unk arrow 2 */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Unk arrow 3 */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Fire magic */ DMG_ENTRY(0, STALFOS_DMGEFF_FIREMAGIC), - /* Ice magic */ DMG_ENTRY(3, STALFOS_DMGEFF_FREEZE), - /* Light magic */ DMG_ENTRY(0, STALFOS_DMGEFF_LIGHT), - /* Shield */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), - /* Mirror Ray */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), - /* Kokiri spin */ DMG_ENTRY(1, STALFOS_DMGEFF_NORMAL), - /* Giant spin */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), - /* Master spin */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Kokiri jump */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), - /* Giant jump */ DMG_ENTRY(8, STALFOS_DMGEFF_NORMAL), - /* Master jump */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), - /* Unknown 1 */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), - /* Unblockable */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), - /* Hammer jump */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), - /* Unknown 2 */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x1B, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 500, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), ICHAIN_F32(scale.y, 0, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), -}; - -void EnTest_SetupAction(EnTest* this, EnTestActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnTest_Init(Actor* thisx, GlobalContext* globalCtx) { - EffectBlureInit1 slashBlure; - EnTest* this = (EnTest*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - - SkelAnime_Init(globalCtx, &this->skelAnime, &gStalfosSkel, &gStalfosMiddleGuardAnim, this->jointTable, - this->morphTable, STALFOS_LIMB_MAX); - SkelAnime_Init(globalCtx, &this->upperSkelanime, &gStalfosSkel, &gStalfosMiddleGuardAnim, this->upperJointTable, - this->upperMorphTable, STALFOS_LIMB_MAX); - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); - - this->actor.colChkInfo.cylRadius = 40; - this->actor.colChkInfo.cylHeight = 100; - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 45.0f; - this->actor.colChkInfo.damageTable = &sDamageTable; - - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, &this->actor, &sBodyColliderInit); - - Collider_InitCylinder(globalCtx, &this->shieldCollider); - Collider_SetCylinder(globalCtx, &this->shieldCollider, &this->actor, &sShieldColliderInit); - - Collider_InitQuad(globalCtx, &this->swordCollider); - Collider_SetQuad(globalCtx, &this->swordCollider, &this->actor, &sSwordColliderInit); - - this->actor.colChkInfo.mass = MASS_HEAVY; - this->actor.colChkInfo.health = 10; - - slashBlure.p1StartColor[0] = slashBlure.p1StartColor[1] = slashBlure.p1StartColor[2] = slashBlure.p1StartColor[3] = - slashBlure.p2StartColor[0] = slashBlure.p2StartColor[1] = slashBlure.p2StartColor[2] = - slashBlure.p1EndColor[0] = slashBlure.p1EndColor[1] = slashBlure.p1EndColor[2] = slashBlure.p2EndColor[0] = - slashBlure.p2EndColor[1] = slashBlure.p2EndColor[2] = 255; - - slashBlure.p1EndColor[3] = 0; - slashBlure.p2EndColor[3] = 0; - slashBlure.p2StartColor[3] = 64; - - slashBlure.elemDuration = 4; - slashBlure.unkFlag = 0; - slashBlure.calcMode = 2; - - Effect_Add(globalCtx, &this->effectIndex, EFFECT_BLURE1, 0, 0, &slashBlure); - - if (this->actor.params != STALFOS_TYPE_CEILING) { - EnTest_SetupWaitGround(this); - } else { - EnTest_SetupWaitAbove(this); - } - - if (this->actor.params == STALFOS_TYPE_INVISIBLE) { - this->actor.flags |= ACTOR_FLAG_7; - } -} - -void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTest* this = (EnTest*)thisx; - - if ((this->actor.params != STALFOS_TYPE_2) && - !Actor_FindNearby(globalCtx, &this->actor, ACTOR_EN_TEST, ACTORCAT_ENEMY, 8000.0f)) { - func_800F5B58(); - } - - Effect_Delete(globalCtx, this->effectIndex); - Collider_DestroyCylinder(globalCtx, &this->shieldCollider); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyQuad(globalCtx, &this->swordCollider); -} - -/** - * If EnTest_ChooseAction failed to pick a new action, this function will unconditionally pick - * a new action as a last resort - */ -void EnTest_ChooseRandomAction(EnTest* this, GlobalContext* globalCtx) { - switch ((u32)(Rand_ZeroOne() * 10.0f)) { - case 0: - case 1: - case 5: - case 6: - if ((this->actor.xzDistToPlayer < 220.0f) && (this->actor.xzDistToPlayer > 170.0f) && - Actor_IsFacingPlayer(&this->actor, 0x71C) && Actor_IsTargeted(globalCtx, &this->actor)) { - EnTest_SetupJumpslash(this); - break; - } - // fallthrough - case 8: - EnTest_SetupWalkAndBlock(this); - break; - - case 3: - case 4: - case 7: - func_808627C4(this, globalCtx); - break; - - case 2: - case 9: - case 10: - EnTest_SetupStopAndBlock(this); - break; - } -} - -void EnTest_ChooseAction(EnTest* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - - yawDiff = ABS(yawDiff); - - if (yawDiff >= 0x61A8) { - switch ((u32)(Rand_ZeroOne() * 10.0f)) { - case 0: - case 3: - case 7: - EnTest_SetupStopAndBlock(this); - break; - - case 1: - case 5: - case 6: - case 8: - func_808627C4(this, globalCtx); - break; - - case 2: - case 4: - case 9: - if (this->actor.params != STALFOS_TYPE_CEILING) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnTest_SetupJumpBack(this); - } - break; - } - } else if (yawDiff <= 0x3E80) { - if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 0x3E80) { - if (((globalCtx->gameplayFrames % 2) != 0) && (this->actor.params != STALFOS_TYPE_CEILING)) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnTest_SetupJumpBack(this); - } else if ((this->actor.xzDistToPlayer < 220.0f) && (this->actor.xzDistToPlayer > 170.0f)) { - if (Actor_IsFacingPlayer(&this->actor, 0x71C) && !Actor_IsTargeted(globalCtx, &this->actor)) { - EnTest_SetupJumpslash(this); - } - } else { - EnTest_SetupWalkAndBlock(this); - } - } else { - if (this->actor.xzDistToPlayer < 110.0f) { - if (Rand_ZeroOne() > 0.2f) { - if (player->stateFlags1 & 0x10) { - if (this->actor.isTargeted) { - EnTest_SetupSlashDown(this); - } else { - func_808627C4(this, globalCtx); - } - } else { - EnTest_SetupSlashDown(this); - } - } - } else { - EnTest_ChooseRandomAction(this, globalCtx); - } - } - } else { - EnTest_ChooseRandomAction(this, globalCtx); - } -} - -void EnTest_SetupWaitGround(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosMiddleGuardAnim); - this->unk_7C8 = 0; - this->timer = 15; - this->actor.scale.y = 0.0f; - this->actor.world.pos.y = this->actor.home.pos.y - 3.5f; - this->actor.flags &= ~ACTOR_FLAG_0; - EnTest_SetupAction(this, EnTest_WaitGround); -} - -void EnTest_WaitGround(EnTest* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if ((this->timer == 0) && (ABS(this->actor.yDistToPlayer) < 150.0f)) { - this->unk_7C8 = 3; - EnTest_SetupAction(this, EnTest_Rise); - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - - if (this->actor.params != STALFOS_TYPE_2) { - func_800F5ACC(NA_BGM_MINI_BOSS); - } - } else { - if (this->timer != 0) { - this->timer--; - } - - this->actor.world.pos.y = this->actor.home.pos.y - 3.5f; - } -} - -void EnTest_SetupWaitAbove(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosMiddleGuardAnim); - this->unk_7C8 = 0; - this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; - Actor_SetScale(&this->actor, 0.0f); - this->actor.flags &= ~ACTOR_FLAG_0; - EnTest_SetupAction(this, EnTest_WaitAbove); -} - -void EnTest_WaitAbove(EnTest* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; - - if ((this->actor.xzDistToPlayer < 200.0f) && (ABS(this->actor.yDistToPlayer) < 450.0f)) { - EnTest_SetupAction(this, EnTest_Fall); - this->actor.flags |= ACTOR_FLAG_0; - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_SetScale(&this->actor, 0.015f); - } -} - -void EnTest_SetupIdle(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosMiddleGuardAnim); - this->unk_7C8 = 0xA; - this->timer = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnTest_SetupAction(this, EnTest_Idle); -} - -void EnTest_Idle(EnTest* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff; - - SkelAnime_Update(&this->skelAnime); - - if (!EnTest_ReactToProjectile(globalCtx, this)) { - yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if (this->actor.xzDistToPlayer < 100.0f) { - if ((player->swordState != 0) && (ABS(yawDiff) >= 0x1F40)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (Rand_ZeroOne() > 0.7f && player->swordAnimation != 0x11) { - EnTest_SetupJumpBack(this); - } else { - func_808627C4(this, globalCtx); - } - return; - } - } - - if (this->timer != 0) { - this->timer--; - } else { - if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { - if ((this->actor.xzDistToPlayer < 220.0f) && (this->actor.xzDistToPlayer > 160.0f) && - (Rand_ZeroOne() < 0.3f)) { - if (Actor_IsTargeted(globalCtx, &this->actor)) { - EnTest_SetupJumpslash(this); - } else { - func_808627C4(this, globalCtx); - } - } else { - if (Rand_ZeroOne() > 0.3f) { - EnTest_SetupWalkAndBlock(this); - } else { - func_808627C4(this, globalCtx); - } - } - } else { - if (Rand_ZeroOne() > 0.7f) { - func_80860BDC(this); - } else { - EnTest_ChooseAction(this, globalCtx); - } - } - } - } -} - -void EnTest_Fall(EnTest* this, GlobalContext* globalCtx) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalfosLandFromLeapAnim, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->actor.world.pos.y <= this->actor.floorHeight) { - this->skelAnime.playSpeed = 1.0f; - this->unk_7C8 = 0xC; - this->timer = this->unk_7E4 * 0.15f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - EnTest_SetupAction(this, EnTest_Land); - } -} - -void EnTest_Land(EnTest* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnTest_SetupIdle(this); - this->timer = (Rand_ZeroOne() * 10.0f) + 5.0f; - } -} - -void EnTest_SetupWalkAndBlock(EnTest* this) { - Animation_Change(&this->upperSkelanime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); - Animation_PlayLoop(&this->skelAnime, &gStalfosSlowAdvanceAnim); - this->timer = (s16)(Rand_ZeroOne() * 5.0f); - this->unk_7C8 = 0xD; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnTest_SetupAction(this, EnTest_WalkAndBlock); -} - -void EnTest_WalkAndBlock(EnTest* this, GlobalContext* globalCtx) { - s32 pad; - f32 checkDist = 0.0f; - s32 pad1; - s32 prevFrame; - s32 temp_f16; - f32 playSpeed; - Player* player = GET_PLAYER(globalCtx); - s32 absPlaySpeed; - s16 yawDiff; - - if (!EnTest_ReactToProjectile(globalCtx, this)) { - this->timer++; - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - checkDist = 150.0f; - } - - if (this->actor.xzDistToPlayer <= (80.0f + checkDist)) { - Math_SmoothStepToF(&this->actor.speedXZ, -5.0f, 1.0f, 0.8f, 0.0f); - } else if (this->actor.xzDistToPlayer > (110.0f + checkDist)) { - Math_SmoothStepToF(&this->actor.speedXZ, 5.0f, 1.0f, 0.8f, 0.0f); - } - - if (this->actor.speedXZ >= 5.0f) { - this->actor.speedXZ = 5.0f; - } else if (this->actor.speedXZ < -5.0f) { - this->actor.speedXZ = -5.0f; - } - - if ((this->actor.params == STALFOS_TYPE_CEILING) && - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.world.rot.y)) { - this->actor.speedXZ *= -1.0f; - } - - if (ABS(this->actor.speedXZ) < 3.0f) { - Animation_Change(&this->skelAnime, &gStalfosSlowAdvanceAnim, 0.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gStalfosSlowAdvanceAnim), 0, -6.0f); - playSpeed = this->actor.speedXZ * 10.0f; - } else { - Animation_Change(&this->skelAnime, &gStalfosFastAdvanceAnim, 0.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gStalfosFastAdvanceAnim), 0, -4.0f); - playSpeed = this->actor.speedXZ * 10.0f * 0.02f; - } - - if (this->actor.speedXZ >= 0.0f) { - if (this->unk_7DE == 0) { - this->unk_7DE++; - } - - playSpeed = CLAMP_MAX(playSpeed, 2.5f); - this->skelAnime.playSpeed = playSpeed; - } else { - playSpeed = CLAMP_MIN(playSpeed, -2.5f); - this->skelAnime.playSpeed = playSpeed; - } - - yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0)) { - if (ABS(yawDiff) >= 0x1F40) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if ((Rand_ZeroOne() > 0.7f) && (player->swordAnimation != 0x11)) { - EnTest_SetupJumpBack(this); - } else { - EnTest_SetupStopAndBlock(this); - } - - return; - } - } - - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - - temp_f16 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = (f32)ABS(this->skelAnime.playSpeed); - - if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 temp_v0_2 = absPlaySpeed + prevFrame; - - if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); - } - } - - if ((this->timer % 32) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WARAU); - this->timer += (s16)(Rand_ZeroOne() * 5.0f); - } - - if ((this->actor.xzDistToPlayer < 220.0f) && (this->actor.xzDistToPlayer > 160.0f) && - (Actor_IsFacingPlayer(&this->actor, 0x71C))) { - if (Actor_IsTargeted(globalCtx, &this->actor)) { - if (Rand_ZeroOne() < 0.1f) { - EnTest_SetupJumpslash(this); - return; - } - } else if (player->heldItemActionParam != PLAYER_AP_NONE) { - if (this->actor.isTargeted) { - if ((globalCtx->gameplayFrames % 2) != 0) { - func_808627C4(this, globalCtx); - return; - } - - EnTest_ChooseAction(this, globalCtx); - } else { - func_80860EC0(this); - } - } - } - - if (Rand_ZeroOne() < 0.4f) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - } - - if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { - EnTest_SetupIdle(this); - this->timer = (Rand_ZeroOne() * 10.0f) + 10.0f; - return; - } - - if (this->actor.xzDistToPlayer < 110.0f) { - if (Rand_ZeroOne() > 0.2f) { - if (player->stateFlags1 & 0x10) { - if (this->actor.isTargeted) { - EnTest_SetupSlashDown(this); - } else { - func_808627C4(this, globalCtx); - } - } else { - EnTest_SetupSlashDown(this); - } - } else { - EnTest_SetupStopAndBlock(this); - } - } else if (Rand_ZeroOne() < 0.1f) { - this->actor.speedXZ = 5.0f; - } - } -} - -// a variation of sidestep -void func_80860BDC(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosSidestepAnim); - this->unk_7C8 = 0xE; - EnTest_SetupAction(this, func_80860C24); -} - -// a variation of sidestep -void func_80860C24(EnTest* this, GlobalContext* globalCtx) { - s16 yawDiff; - s16 yawChange; - f32 playSpeed; - s32 prevFrame; - s32 temp1; - s32 temp2; - s32 absPlaySpeed; - - if (!EnTest_ReactToProjectile(globalCtx, this)) { - yawDiff = this->actor.yawTowardsPlayer; - yawDiff -= this->actor.shape.rot.y; - - if (yawDiff > 0) { - yawChange = (yawDiff / 42.0f) + 300.0f; - this->actor.shape.rot.y += yawChange * 2; - } else { - yawChange = (yawDiff / 42.0f) - 300.0f; - this->actor.shape.rot.y += yawChange * 2; - } - - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (yawDiff > 0) { - playSpeed = yawChange * 0.02f; - playSpeed = CLAMP_MAX(playSpeed, 1.0f); - this->skelAnime.playSpeed = playSpeed; - } else { - playSpeed = yawChange * 0.02f; - playSpeed = CLAMP_MIN(playSpeed, -1.0f); - this->skelAnime.playSpeed = playSpeed; - } - - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - temp1 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = (f32)ABS(this->skelAnime.playSpeed); - - if ((s32)this->skelAnime.curFrame != prevFrame) { - temp2 = absPlaySpeed + prevFrame; - - if (((temp2 > 2) && (temp1 <= 0)) || ((temp1 < 7) && (temp2 >= 9))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); - } - } - - if (Actor_IsFacingPlayer(&this->actor, 0x71C)) { - if (Rand_ZeroOne() > 0.8f) { - if ((Rand_ZeroOne() > 0.7f)) { - func_80860EC0(this); - } else { - EnTest_ChooseAction(this, globalCtx); - } - } else { - EnTest_SetupWalkAndBlock(this); - } - } - } -} - -// a variation of sidestep -void func_80860EC0(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosSidestepAnim); - this->unk_7C8 = 0xF; - this->actor.speedXZ = (Rand_ZeroOne() > 0.5f) ? -0.5f : 0.5f; - this->timer = (s16)((Rand_ZeroOne() * 15.0f) + 25.0f); - this->unk_7EC = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnTest_SetupAction(this, func_80860F84); -} - -// a variation of sidestep -void func_80860F84(EnTest* this, GlobalContext* globalCtx) { - s16 playerYaw180; - s32 pad; - s32 prevFrame; - s32 temp_f16; - s16 yawDiff; - Player* player = GET_PLAYER(globalCtx); - f32 checkDist = 0.0f; - s16 newYaw; - s32 absPlaySpeed; - - if (!EnTest_ReactToProjectile(globalCtx, this)) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3E80; - playerYaw180 = player->actor.shape.rot.y + 0x8000; - - if (this->actor.speedXZ >= 0.0f) { - if (this->actor.speedXZ < 6.0f) { - this->actor.speedXZ += 0.5f; - } else { - this->actor.speedXZ = 6.0f; - } - } else { - if (this->actor.speedXZ > -6.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ = -6.0f; - } - } - - if ((this->actor.bgCheckFlags & 8) || - ((this->actor.params == STALFOS_TYPE_CEILING) && - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.world.rot.y))) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - newYaw = this->actor.shape.rot.y + 0x3FFF; - } else { - newYaw = this->actor.shape.rot.y - 0x3FFF; - } - - newYaw = this->actor.wallYaw - newYaw; - } else { - this->actor.speedXZ *= -0.8f; - newYaw = 0; - } - - if (ABS(newYaw) > 0x4000) { - this->actor.speedXZ *= -0.8f; - - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ += 0.5f; - } - } - } - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - checkDist = 200.0f; - } - - if (this->actor.xzDistToPlayer <= (80.0f + checkDist)) { - Math_SmoothStepToF(&this->unk_7EC, -2.5f, 1.0f, 0.8f, 0.0f); - } else if (this->actor.xzDistToPlayer > (110.0f + checkDist)) { - Math_SmoothStepToF(&this->unk_7EC, 2.5f, 1.0f, 0.8f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_7EC, 0.0f, 1.0f, 6.65f, 0.0f); - } - - if (this->unk_7EC != 0.0f) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->unk_7EC; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->unk_7EC; - } - - this->skelAnime.playSpeed = this->actor.speedXZ * 0.5f; - - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - temp_f16 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = (f32)ABS(this->skelAnime.playSpeed); - - if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 temp_v0_2 = absPlaySpeed + prevFrame; - - if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); - } - } - - if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WARAU); - } - - yawDiff = playerYaw180 - this->actor.shape.rot.y; - yawDiff = ABS(yawDiff); - - if ((yawDiff > 0x6800) || (this->timer == 0)) { - EnTest_ChooseAction(this, globalCtx); - } else if (this->timer != 0) { - this->timer--; - } - } -} - -void EnTest_SetupSlashDown(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosDownSlashAnim); - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_STAL_WARAU); - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - this->unk_7C8 = 0x10; - this->actor.speedXZ = 0.0f; - EnTest_SetupAction(this, EnTest_SlashDown); - this->swordCollider.info.toucher.damage = 16; - - if (this->unk_7DE != 0) { - this->unk_7DE = 3; - } -} - -void EnTest_SlashDown(EnTest* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - - if ((s32)this->skelAnime.curFrame < 4) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - } - - if ((s32)this->skelAnime.curFrame == 7) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_SAKEBI); - } - - if ((this->skelAnime.curFrame > 7.0f) && (this->skelAnime.curFrame < 11.0f)) { - this->swordState = 1; - } else { - this->swordState = 0; - } - - if (SkelAnime_Update(&this->skelAnime)) { - if ((globalCtx->gameplayFrames % 2) != 0) { - EnTest_SetupSlashDownEnd(this); - } else { - EnTest_SetupSlashUp(this); - } - } -} - -void EnTest_SetupSlashDownEnd(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosRecoverFromDownSlashAnim); - this->unk_7C8 = 0x12; - this->actor.speedXZ = 0.0f; - EnTest_SetupAction(this, EnTest_SlashDownEnd); -} - -void EnTest_SlashDownEnd(EnTest* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yawDiff; - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->swordCollider.base.atFlags & AT_HIT) { - this->swordCollider.base.atFlags &= ~AT_HIT; - if (this->actor.params != STALFOS_TYPE_CEILING) { - EnTest_SetupJumpBack(this); - return; - } - } - - if (Rand_ZeroOne() > 0.7f) { - EnTest_SetupIdle(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - return; - } - - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, &player->actor); - - if (Rand_ZeroOne() > 0.7f) { - if (this->actor.params != STALFOS_TYPE_CEILING) { - EnTest_SetupJumpBack(this); - return; - } - } - - yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if (ABS(yawDiff) <= 0x2710) { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(yawDiff) > 0x3E80) && (this->actor.params != STALFOS_TYPE_CEILING)) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnTest_SetupJumpBack(this); - } else if (player->stateFlags1 & 0x10) { - if (this->actor.isTargeted) { - EnTest_SetupSlashDown(this); - } else if ((globalCtx->gameplayFrames % 2) != 0) { - func_808627C4(this, globalCtx); - } else { - EnTest_SetupJumpBack(this); - } - } else { - EnTest_SetupSlashDown(this); - } - } else { - func_808627C4(this, globalCtx); - } - } -} - -void EnTest_SetupSlashUp(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosUpSlashAnim); - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - this->unk_7C8 = 0x11; - this->swordCollider.info.toucher.damage = 16; - this->actor.speedXZ = 0.0f; - EnTest_SetupAction(this, EnTest_SlashUp); - - if (this->unk_7DE != 0) { - this->unk_7DE = 3; - } -} - -void EnTest_SlashUp(EnTest* this, GlobalContext* globalCtx) { - this->actor.speedXZ = 0.0f; - - if ((s32)this->skelAnime.curFrame == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_SAKEBI); - } - - if ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 8.0f)) { - this->swordState = 1; - } else { - this->swordState = 0; - } - - if (SkelAnime_Update(&this->skelAnime)) { - EnTest_SetupSlashDown(this); - } -} - -void EnTest_SetupJumpBack(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpBackwardsAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->unk_7C8 = 0x14; - this->timer = 5; - EnTest_SetupAction(this, EnTest_JumpBack); - - if (this->unk_7DE != 0) { - this->unk_7DE = 3; - } - - if (this->actor.params != STALFOS_TYPE_CEILING) { - this->actor.speedXZ = -11.0f; - } else { - this->actor.speedXZ = -7.0f; - } -} - -void EnTest_JumpBack(EnTest* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 1); - - if (this->timer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WARAU); - } else { - this->timer--; - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (!EnTest_ReactToProjectile(globalCtx, this)) { - if (this->actor.xzDistToPlayer <= 100.0f) { - if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { - EnTest_SetupSlashDown(this); - } else { - EnTest_SetupIdle(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } - } else { - if ((this->actor.xzDistToPlayer <= 220.0f) && Actor_IsFacingPlayer(&this->actor, 0xE38)) { - EnTest_SetupJumpslash(this); - } else { - EnTest_SetupIdle(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } - } - this->actor.flags |= ACTOR_FLAG_0; - } - } else if (this->skelAnime.curFrame == (this->skelAnime.endFrame - 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } -} - -void EnTest_SetupJumpslash(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpAnim); - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_STAL_WARAU); - this->timer = 0; - this->unk_7C8 = 0x17; - this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 8.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actor.world.rot.y = this->actor.shape.rot.y; - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - EnTest_SetupAction(this, EnTest_Jumpslash); - this->swordCollider.info.toucher.damage = 32; - - if (this->unk_7DE != 0) { - this->unk_7DE = 3; - } -} - -void EnTest_Jumpslash(EnTest* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (this->timer == 0) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpslashAnim); - this->timer = 1; - this->swordState = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_SAKEBI); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - } else { - this->actor.speedXZ = 0.0f; - EnTest_SetupIdle(this); - } - } - - if ((this->timer != 0) && (this->skelAnime.curFrame >= 5.0f)) { - this->swordState = 0; - } - - if (this->actor.world.pos.y <= this->actor.floorHeight) { - if (this->actor.speedXZ != 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - - this->actor.world.pos.y = this->actor.floorHeight; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } -} - -void EnTest_SetupJumpUp(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpAnim); - this->timer = 0; - this->unk_7C8 = 4; - this->actor.velocity.y = 14.0f; - this->actor.speedXZ = 6.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actor.world.rot.y = this->actor.shape.rot.y; - EnTest_SetupAction(this, EnTest_JumpUp); -} - -void EnTest_JumpUp(EnTest* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - SkelAnime_Update(&this->skelAnime); - - if (this->actor.world.pos.y <= this->actor.floorHeight) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.world.pos.y = this->actor.floorHeight; - this->unk_7E4 = -(s32)this->actor.velocity.y; - - if (this->unk_7E4 == 0) { - this->unk_7E4 = 1; - } - - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - this->unk_7C8 = 0xC; - this->timer = 4; - Animation_Change(&this->skelAnime, &gStalfosLandFromLeapAnim, 0.0f, 0.0f, 0.0f, 2, 0.0f); - EnTest_SetupAction(this, EnTest_Land); - } -} - -void EnTest_SetupStopAndBlock(EnTest* this) { - Animation_Change(&this->skelAnime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); - this->unk_7C8 = 0x15; - this->actor.speedXZ = 0.0f; - this->timer = (Rand_ZeroOne() * 10.0f) + 11.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_7DE = 5; - EnTest_SetupAction(this, EnTest_StopAndBlock); -} - -void EnTest_StopAndBlock(EnTest* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 0x3E80) && - (this->actor.params != STALFOS_TYPE_CEILING) && ((globalCtx->gameplayFrames % 2) != 0)) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnTest_SetupJumpBack(this); - } - - if (this->timer == 0) { - EnTest_SetupIdleFromBlock(this); - } else { - this->timer--; - } -} - -void EnTest_SetupIdleFromBlock(EnTest* this) { - Animation_MorphToLoop(&this->skelAnime, &gStalfosMiddleGuardAnim, -4.0f); - this->unk_7C8 = 0x16; - EnTest_SetupAction(this, EnTest_IdleFromBlock); -} - -void EnTest_IdleFromBlock(EnTest* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->skelAnime.morphWeight == 0.0f) { - this->actor.speedXZ = 0.0f; - this->unk_7DE = 0; - - if (!EnTest_ReactToProjectile(globalCtx, this)) { - if (this->actor.xzDistToPlayer < 500.0f) { - EnTest_ChooseAction(this, globalCtx); - } else { - func_808627C4(this, globalCtx); - } - } - } -} - -void func_80862154(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFlinchFromHitFrontAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_DAMAGE); - this->unk_7C8 = 8; - this->actor.speedXZ = -2.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - EnTest_SetupAction(this, func_808621D4); -} - -void func_808621D4(EnTest* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.1f, 0.0f); - - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.speedXZ = 0.0f; - - if ((this->actor.bgCheckFlags & 8) && ((ABS((s16)(this->actor.wallYaw - this->actor.shape.rot.y)) < 0x38A4) && - (this->actor.xzDistToPlayer < 80.0f))) { - EnTest_SetupJumpUp(this); - } else if (!EnTest_ReactToProjectile(globalCtx, this)) { - EnTest_ChooseAction(this, globalCtx); - } else { - return; - } - } - - if (player->swordState != 0) { - if ((this->actor.bgCheckFlags & 8) && ((ABS((s16)(this->actor.wallYaw - this->actor.shape.rot.y)) < 0x38A4) && - (this->actor.xzDistToPlayer < 80.0f))) { - EnTest_SetupJumpUp(this); - } else if ((Rand_ZeroOne() > 0.7f) && (this->actor.params != STALFOS_TYPE_CEILING) && - (player->swordAnimation != 0x11)) { - EnTest_SetupJumpBack(this); - } else { - EnTest_SetupStopAndBlock(this); - } - - this->unk_7C8 = 8; - } -} - -void func_80862398(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFlinchFromHitBehindAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_DAMAGE); - this->unk_7C8 = 9; - this->actor.speedXZ = -2.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - EnTest_SetupAction(this, func_80862418); -} - -void func_80862418(EnTest* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.1f, 0.0f); - - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.speedXZ = 0.0f; - - if (!EnTest_ReactToProjectile(globalCtx, this)) { - EnTest_ChooseAction(this, globalCtx); - } else { - return; - } - } - - if (player->swordState != 0) { - if ((this->actor.bgCheckFlags & 8) && ((ABS((s16)(this->actor.wallYaw - this->actor.shape.rot.y)) < 0x38A4) && - (this->actor.xzDistToPlayer < 80.0f))) { - EnTest_SetupJumpUp(this); - } else if ((Rand_ZeroOne() > 0.7f) && (this->actor.params != STALFOS_TYPE_CEILING) && - (player->swordAnimation != 0x11)) { - EnTest_SetupJumpBack(this); - } else { - EnTest_SetupStopAndBlock(this); - } - - this->unk_7C8 = 8; - } -} - -void EnTest_SetupStunned(EnTest* this) { - this->unk_7C8 = 0xB; - this->unk_7DE = 0; - this->swordState = 0; - this->skelAnime.playSpeed = 0.0f; - this->actor.speedXZ = -4.0f; - - if (this->lastDamageEffect == STALFOS_DMGEFF_LIGHT) { - Actor_SetColorFilter(&this->actor, -0x8000, 0x78, 0, 0x50); - } else { - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); - - if (this->lastDamageEffect == STALFOS_DMGEFF_FREEZE) { - this->iceTimer = 36; - } else { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalfosFlinchFromHitFrontAnim, 0.0f); - } - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - EnTest_SetupAction(this, EnTest_Stunned); -} - -void EnTest_Stunned(EnTest* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - - if (this->actor.colorFilterTimer == 0) { - if (this->actor.colChkInfo.health == 0) { - func_80862FA8(this, globalCtx); - } else if (player->swordState != 0) { - if ((this->actor.bgCheckFlags & 8) && - ((ABS((s16)(this->actor.wallYaw - this->actor.shape.rot.y)) < 0x38A4) && - (this->actor.xzDistToPlayer < 80.0f))) { - EnTest_SetupJumpUp(this); - } else if ((Rand_ZeroOne() > 0.7f) && (player->swordAnimation != 0x11)) { - EnTest_SetupJumpBack(this); - } else { - EnTest_SetupStopAndBlock(this); - } - - this->unk_7C8 = 8; - } else { - this->actor.speedXZ = 0.0f; - if (!EnTest_ReactToProjectile(globalCtx, this)) { - EnTest_ChooseAction(this, globalCtx); - } - } - } -} - -// a variation of sidestep -void func_808627C4(EnTest* this, GlobalContext* globalCtx) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - func_80860EC0(this); - return; - } - - Animation_MorphToLoop(&this->skelAnime, &gStalfosSidestepAnim, -2.0f); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - this->actor.speedXZ = ((globalCtx->gameplayFrames % 2) != 0) ? -4.0f : 4.0f; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - this->timer = (Rand_ZeroOne() * 20.0f) + 20.0f; - this->unk_7C8 = 0x18; - EnTest_SetupAction(this, func_808628C8); - this->unk_7EC = 0.0f; -} - -// a variation of sidestep -void func_808628C8(EnTest* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 pad1; - s32 prevFrame; - s32 temp_f16; - s32 pad2; - f32 checkDist = 0.0f; - s16 newYaw; - f32 absPlaySpeed; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); - - if (this->unk_7DE == 0) { - this->unk_7DE++; - } - - if (this->actor.speedXZ >= 0.0f) { - if (this->actor.speedXZ < 6.0f) { - this->actor.speedXZ += 0.125f; - } else { - this->actor.speedXZ = 6.0f; - } - } else { - if (this->actor.speedXZ > -6.0f) { - this->actor.speedXZ -= 0.125f; - } else { - this->actor.speedXZ = -6.0f; - } - } - - if ((this->actor.bgCheckFlags & 8) || - ((this->actor.params == STALFOS_TYPE_CEILING) && - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.shape.rot.y + 0x3FFF))) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - newYaw = (this->actor.shape.rot.y + 0x3FFF); - } else { - newYaw = (this->actor.shape.rot.y - 0x3FFF); - } - - newYaw = this->actor.wallYaw - newYaw; - } else { - this->actor.speedXZ *= -0.8f; - newYaw = 0; - } - - if (ABS(newYaw) > 0x4000) { - this->actor.speedXZ *= -0.8f; - - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ += 0.5f; - } - } - } - - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - checkDist = 200.0f; - } - - if (this->actor.xzDistToPlayer <= (80.0f + checkDist)) { - Math_SmoothStepToF(&this->unk_7EC, -2.5f, 1.0f, 0.8f, 0.0f); - } else if (this->actor.xzDistToPlayer > (110.0f + checkDist)) { - Math_SmoothStepToF(&this->unk_7EC, 2.5f, 1.0f, 0.8f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_7EC, 0.0f, 1.0f, 6.65f, 0.0f); - } - - if (this->unk_7EC != 0.0f) { - this->actor.world.pos.x += (Math_SinS(this->actor.shape.rot.y) * this->unk_7EC); - this->actor.world.pos.z += (Math_CosS(this->actor.shape.rot.y) * this->unk_7EC); - } - - this->skelAnime.playSpeed = this->actor.speedXZ * 0.5f; - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - - temp_f16 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = ABS(this->skelAnime.playSpeed); - - if ((this->timer % 32) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WARAU); - } - if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 temp_v0_2 = (s32)absPlaySpeed + prevFrame; - - if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); - } - } - - if (this->timer == 0) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - EnTest_SetupIdle(this); - } else if (Actor_IsTargeted(globalCtx, &this->actor)) { - if (!EnTest_ReactToProjectile(globalCtx, this)) { - EnTest_ChooseAction(this, globalCtx); - } - } else if (player->heldItemActionParam != PLAYER_AP_NONE) { - if ((globalCtx->gameplayFrames % 2) != 0) { - EnTest_SetupIdle(this); - } else { - EnTest_SetupWalkAndBlock(this); - } - } else { - EnTest_SetupWalkAndBlock(this); - } - - } else { - this->timer--; - } -} - -void func_80862DBC(EnTest* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_DAMAGE); - this->unk_7C8 = 2; - BodyBreak_Alloc(&this->bodyBreak, 60, globalCtx); - this->actor.home.rot.x = 0; - - if (this->swordState >= 0) { - EffectBlure_AddSpace(Effect_GetByIndex(this->effectIndex)); - this->swordState = -1; - } - - this->actor.flags &= ~ACTOR_FLAG_0; - - if (this->actor.params == STALFOS_TYPE_5) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - } - - EnTest_SetupAction(this, func_80862E6C); -} - -void func_80862E6C(EnTest* this, GlobalContext* globalCtx) { - if (this->actor.child == NULL) { - if (this->actor.home.rot.x == 0) { - this->actor.home.rot.x = this->bodyBreak.count; - } - - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params + 8)) { - this->actor.child = &this->actor; - } - } else { - if (this->actor.home.rot.x == 0) { - this->actor.colChkInfo.health = 10; - - if (this->actor.params == STALFOS_TYPE_4) { - this->actor.params = -1; - } else { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - } - - this->actor.child = NULL; - this->actor.flags |= ACTOR_FLAG_0; - EnTest_SetupJumpBack(this); - } else if ((this->actor.params == STALFOS_TYPE_5) && - !Actor_FindNearby(globalCtx, &this->actor, ACTOR_EN_TEST, ACTORCAT_ENEMY, 8000.0f)) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xD0); - - if (this->actor.parent != NULL) { - this->actor.parent->home.rot.z--; - } - - Actor_Kill(&this->actor); - } - } -} - -void func_80862FA8(EnTest* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFallOverBackwardsAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_DEAD); - this->unk_7DE = 0; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.colorFilterTimer = 0; - this->actor.speedXZ = 0.0f; - - if (this->actor.params <= STALFOS_TYPE_CEILING) { - this->unk_7C8 = 5; - EnTest_SetupAction(this, func_80863044); - } else { - func_80862DBC(this, globalCtx); - } -} - -void func_80863044(EnTest* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->timer = (Rand_ZeroOne() * 10.0f) + 10.0f; - this->unk_7C8 = 7; - EnTest_SetupAction(this, func_808633E8); - BodyBreak_Alloc(&this->bodyBreak, 60, globalCtx); - } - - if ((s32)this->skelAnime.curFrame == 15) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } -} - -void func_808630F0(EnTest* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFallOverForwardsAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_DEAD); - this->unk_7C8 = 6; - this->actor.colorFilterTimer = 0; - this->unk_7DE = 0; - this->actor.speedXZ = 0.0f; - - if (this->actor.params <= STALFOS_TYPE_CEILING) { - this->actor.flags &= ~ACTOR_FLAG_0; - EnTest_SetupAction(this, func_8086318C); - } else { - func_80862DBC(this, globalCtx); - } -} - -void func_8086318C(EnTest* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - this->timer = (Rand_ZeroOne() * 10.0f) + 10.0f; - this->unk_7C8 = 7; - EnTest_SetupAction(this, func_808633E8); - BodyBreak_Alloc(&this->bodyBreak, 60, globalCtx); - } - - if (((s32)this->skelAnime.curFrame == 10) || ((s32)this->skelAnime.curFrame == 25)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } -} - -void EnTest_SetupRecoil(EnTest* this) { - this->swordState = 0; - this->skelAnime.moveFlags = 2; - this->unk_7C8 = 0x13; - this->skelAnime.playSpeed = -1.0f; - this->skelAnime.startFrame = this->skelAnime.curFrame; - this->skelAnime.endFrame = 0.0f; - EnTest_SetupAction(this, EnTest_Recoil); -} - -void EnTest_Recoil(EnTest* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (Rand_ZeroOne() > 0.7f) { - EnTest_SetupIdle(this); - this->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } else if (((globalCtx->gameplayFrames % 2) != 0) && (this->actor.params != STALFOS_TYPE_CEILING)) { - EnTest_SetupJumpBack(this); - } else { - func_808627C4(this, globalCtx); - } - } -} - -void EnTest_Rise(EnTest* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->actor.scale.y < 0.015f) { - this->actor.scale.y += 0.002f; - this->actor.world.pos.y = this->actor.home.pos.y - 3.5f; - } else { - this->actor.world.pos.y = this->actor.home.pos.y; - EnTest_SetupJumpBack(this); - } -} - -void func_808633E8(EnTest* this, GlobalContext* globalCtx) { - this->actor.params = STALFOS_TYPE_1; - - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params)) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xD0); - - if (this->actor.parent != NULL) { - this->actor.parent->home.rot.z--; - } - - Actor_Kill(&this->actor); - } -} - -void EnTest_UpdateHeadRot(EnTest* this, GlobalContext* globalCtx) { - s16 lookAngle = this->actor.yawTowardsPlayer; - - lookAngle -= (s16)(this->headRot.y + this->actor.shape.rot.y); - - this->headRotOffset.y = CLAMP(lookAngle, -0x7D0, 0x7D0); - this->headRot.y += this->headRotOffset.y; - this->headRot.y = CLAMP(this->headRot.y, -0x382F, 0x382F); -} - -void EnTest_UpdateDamage(EnTest* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (this->shieldCollider.base.acFlags & AC_BOUNCED) { - this->shieldCollider.base.acFlags &= ~AC_BOUNCED; - this->bodyCollider.base.acFlags &= ~AC_HIT; - - if (this->unk_7C8 >= 0xA) { - this->actor.speedXZ = -4.0f; - } - } else if (this->bodyCollider.base.acFlags & AC_HIT) { - this->bodyCollider.base.acFlags &= ~AC_HIT; - - if ((this->actor.colChkInfo.damageEffect != STALFOS_DMGEFF_SLING) && - (this->actor.colChkInfo.damageEffect != STALFOS_DMGEFF_FIREMAGIC)) { - this->lastDamageEffect = this->actor.colChkInfo.damageEffect; - if (this->swordState >= 1) { - this->swordState = 0; - } - this->unk_7DC = player->unk_845; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_SetDropFlag(&this->actor, &this->bodyCollider.info, false); - Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_STAL_WARAU); - - if ((this->actor.colChkInfo.damageEffect == STALFOS_DMGEFF_STUN) || - (this->actor.colChkInfo.damageEffect == STALFOS_DMGEFF_FREEZE) || - (this->actor.colChkInfo.damageEffect == STALFOS_DMGEFF_LIGHT)) { - if (this->unk_7C8 != 0xB) { - Actor_ApplyDamage(&this->actor); - EnTest_SetupStunned(this); - } - } else { - if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - func_80862FA8(this, globalCtx); - } else { - func_80862154(this); - } - } else if (Actor_ApplyDamage(&this->actor) == 0) { - func_808630F0(this, globalCtx); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else { - func_80862398(this); - } - } - } - } -} - -void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTest* this = (EnTest*)thisx; - f32 oldWeight; - u32 floorProperty; - s32 pad; - - EnTest_UpdateDamage(this, globalCtx); - - if (this->actor.colChkInfo.damageEffect != STALFOS_DMGEFF_FIREMAGIC) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 0x1D); - - if (this->actor.params == STALFOS_TYPE_1) { - if (this->actor.world.pos.y <= this->actor.home.pos.y) { - this->actor.world.pos.y = this->actor.home.pos.y; - this->actor.velocity.y = 0.0f; - } - - if (this->actor.floorHeight <= this->actor.home.pos.y) { - this->actor.floorHeight = this->actor.home.pos.y; - } - } else if (this->actor.bgCheckFlags & 2) { - floorProperty = func_80041EA4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - - if ((floorProperty == 5) || (floorProperty == 0xC) || - func_80041D4C(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 9) { - Actor_Kill(&this->actor); - return; - } - } - - this->actionFunc(this, globalCtx); - - switch (this->unk_7DE) { - case 0: - break; - - case 1: - Animation_Change(&this->upperSkelanime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); - AnimationContext_SetCopyTrue(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->upperSkelanime.jointTable, sJointCopyFlags); - this->unk_7DE++; - break; - - case 2: - SkelAnime_Update(&this->upperSkelanime); - SkelAnime_CopyFrameTableTrue(&this->skelAnime, this->skelAnime.jointTable, - this->upperSkelanime.jointTable, sJointCopyFlags); - break; - - case 3: - this->unk_7DE++; - this->upperSkelanime.morphWeight = 4.0f; - // fallthrough - case 4: - oldWeight = this->upperSkelanime.morphWeight; - this->upperSkelanime.morphWeight -= 1.0f; - - if (this->upperSkelanime.morphWeight <= 0.0f) { - this->unk_7DE = 0; - } - - SkelAnime_InterpFrameTable(this->skelAnime.limbCount, this->upperSkelanime.jointTable, - this->upperSkelanime.jointTable, this->skelAnime.jointTable, - 1.0f - (this->upperSkelanime.morphWeight / oldWeight)); - SkelAnime_CopyFrameTableTrue(&this->skelAnime, this->skelAnime.jointTable, - this->upperSkelanime.jointTable, sJointCopyFlags); - break; - } - - if ((this->actor.colorFilterTimer == 0) && (this->actor.colChkInfo.health != 0)) { - if ((this->unk_7C8 != 0x10) && (this->unk_7C8 != 0x17)) { - EnTest_UpdateHeadRot(this, globalCtx); - } else { - Math_SmoothStepToS(&this->headRot.y, 0, 1, 0x3E8, 0); - } - } - } - - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 45.0f; - - if ((this->actor.colChkInfo.health > 0) || (this->actor.colorFilterTimer != 0)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - - if ((this->unk_7C8 >= 0xA) && - ((this->actor.colorFilterTimer == 0) || (!(this->actor.colorFilterParams & 0x4000)))) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - - if (this->unk_7DE != 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->shieldCollider.base); - } - } - - if (this->swordState >= 1) { - if (!(this->swordCollider.base.atFlags & AT_BOUNCED)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->swordCollider.base); - } else { - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - EnTest_SetupRecoil(this); - } - } - - if (this->actor.params == STALFOS_TYPE_INVISIBLE) { - if (globalCtx->actorCtx.unk_03 != 0) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_7; - this->actor.shape.shadowDraw = ActorShadow_DrawFeet; - } else { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_7); - this->actor.shape.shadowDraw = NULL; - } - } -} - -s32 EnTest_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnTest* this = (EnTest*)thisx; - s32 pad; - - if (limbIndex == STALFOS_LIMB_HEAD_ROOT) { - rot->x += this->headRot.y; - rot->y -= this->headRot.x; - rot->z += this->headRot.z; - } else if (limbIndex == STALFOS_LIMB_HEAD) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_test.c", 3582); - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 80 + ABS((s16)(Math_SinS(globalCtx->gameplayFrames * 2000) * 175.0f)), 0, 0, - 255); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_test.c", 3587); - } - - if ((this->actor.params == STALFOS_TYPE_INVISIBLE) && !CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_7)) { - *dList = NULL; - } - - return false; -} - -void EnTest_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f unused1 = { 1100.0f, -700.0f, 0.0f }; - static Vec3f D_80864658 = { 300.0f, 0.0f, 0.0f }; - static Vec3f D_80864664 = { 3400.0f, 0.0f, 0.0f }; - static Vec3f D_80864670 = { 0.0f, 0.0f, 0.0f }; - static Vec3f D_8086467C = { 7000.0f, 1000.0f, 0.0f }; - static Vec3f D_80864688 = { 3000.0f, -2000.0f, -1000.0f }; - static Vec3f D_80864694 = { 3000.0f, -2000.0f, 1000.0f }; - static Vec3f D_808646A0 = { -1300.0f, 1100.0f, 0.0f }; - static Vec3f unused2 = { -3000.0f, 1900.0f, 800.0f }; - static Vec3f unused3 = { -3000.0f, -1100.0f, 800.0f }; - static Vec3f unused4 = { 1900.0f, 1900.0f, 800.0f }; - static Vec3f unused5 = { -3000.0f, -1100.0f, 800.0f }; - static Vec3f unused6 = { 1900.0f, -1100.0f, 800.0f }; - static Vec3f unused7 = { 1900.0f, 1900.0f, 800.0f }; - s32 bodyPart = -1; - Vec3f sp70; - Vec3f sp64; - EnTest* this = (EnTest*)thisx; - s32 pad; - Vec3f sp50; - - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 60, 60, dList, BODYBREAK_OBJECT_DEFAULT); - - if (limbIndex == STALFOS_LIMB_SWORD) { - Matrix_MultVec3f(&D_8086467C, &this->swordCollider.dim.quad[1]); - Matrix_MultVec3f(&D_80864688, &this->swordCollider.dim.quad[0]); - Matrix_MultVec3f(&D_80864694, &this->swordCollider.dim.quad[3]); - Matrix_MultVec3f(&D_808646A0, &this->swordCollider.dim.quad[2]); - - Collider_SetQuadVertices(&this->swordCollider, &this->swordCollider.dim.quad[0], - &this->swordCollider.dim.quad[1], &this->swordCollider.dim.quad[2], - &this->swordCollider.dim.quad[3]); - - Matrix_MultVec3f(&D_80864664, &sp70); - Matrix_MultVec3f(&D_80864670, &sp64); - - if ((this->swordState >= 1) && - ((this->actor.params != STALFOS_TYPE_INVISIBLE) || (globalCtx->actorCtx.unk_03 != 0))) { - EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp70, &sp64); - } else if (this->swordState >= 0) { - EffectBlure_AddSpace(Effect_GetByIndex(this->effectIndex)); - this->swordState = -1; - } - - } else if ((limbIndex == STALFOS_LIMB_SHIELD) && (this->unk_7DE != 0)) { - Matrix_MultVec3f(&D_80864670, &sp64); - - this->shieldCollider.dim.pos.x = sp64.x; - this->shieldCollider.dim.pos.y = sp64.y; - this->shieldCollider.dim.pos.z = sp64.z; - } else { - Actor_SetFeetPos(&this->actor, limbIndex, STALFOS_LIMB_FOOT_L, &D_80864658, STALFOS_LIMB_ANKLE_R, &D_80864658); - - if ((limbIndex == STALFOS_LIMB_FOOT_L) || (limbIndex == STALFOS_LIMB_ANKLE_R)) { - if ((this->unk_7C8 == 0x15) || (this->unk_7C8 == 0x16)) { - if (this->actor.speedXZ != 0.0f) { - Matrix_MultVec3f(&D_80864658, &sp64); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp64, 10.0f, 1, 8.0f, 0x64, 0xF, 0); - } - } - } - } - - if (this->iceTimer != 0) { - switch (limbIndex) { - case STALFOS_LIMB_HEAD: - bodyPart = 0; - break; - case STALFOS_LIMB_CHEST: - bodyPart = 1; - break; - case STALFOS_LIMB_SWORD: - bodyPart = 2; - break; - case STALFOS_LIMB_SHIELD: - bodyPart = 3; - break; - case STALFOS_LIMB_UPPERARM_R: - bodyPart = 4; - break; - case STALFOS_LIMB_UPPERARM_L: - bodyPart = 5; - break; - case STALFOS_LIMB_WAIST: - bodyPart = 6; - break; - case STALFOS_LIMB_FOOT_L: - bodyPart = 7; - break; - case STALFOS_LIMB_FOOT_R: - bodyPart = 8; - break; - } - - if (bodyPart >= 0) { - Matrix_MultVec3f(&D_80864670, &sp50); - - this->bodyPartsPos[bodyPart].x = sp50.x; - this->bodyPartsPos[bodyPart].y = sp50.y; - this->bodyPartsPos[bodyPart].z = sp50.z; - } - } -} - -void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnTest* this = (EnTest*)thisx; - - func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 1); - - if ((thisx->params <= STALFOS_TYPE_CEILING) || (thisx->child == NULL)) { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTest_OverrideLimbDraw, - EnTest_PostLimbDraw, this); - } - - if (this->iceTimer != 0) { - thisx->colorFilterTimer++; - this->iceTimer--; - - if ((this->iceTimer % 4) == 0) { - s32 iceIndex = this->iceTimer >> 2; - - EffectSsEnIce_SpawnFlyingVec3s(globalCtx, thisx, &this->bodyPartsPos[iceIndex], 150, 150, 150, 250, 235, - 245, 255, 1.5f); - } - } -} - -// a variation of sidestep -void func_80864158(EnTest* this, f32 xzSpeed) { - Animation_MorphToLoop(&this->skelAnime, &gStalfosSidestepAnim, -2.0f); - this->actor.speedXZ = xzSpeed; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - this->timer = (Rand_ZeroOne() * 20.0f) + 15.0f; - this->unk_7C8 = 0x18; - EnTest_SetupAction(this, func_808628C8); -} - -/** - * Check if a projectile actor is within 300 units and react accordingly. - * Returns true if the projectile test passes and a new action is performed. - */ -s32 EnTest_ReactToProjectile(GlobalContext* globalCtx, EnTest* this) { - Actor* projectileActor; - s16 yawToProjectile; - s16 wallYawDiff; - s16 touchingWall; - s16 directionFlag; - - projectileActor = Actor_GetProjectileActor(globalCtx, &this->actor, 300.0f); - - if (projectileActor != NULL) { - yawToProjectile = Actor_WorldYawTowardActor(&this->actor, projectileActor) - (u16)this->actor.shape.rot.y; - - if ((u8)(this->actor.bgCheckFlags & 8)) { - wallYawDiff = ((u16)this->actor.wallYaw - (u16)this->actor.shape.rot.y); - touchingWall = true; - } else { - touchingWall = false; - } - - if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &projectileActor->world.pos) < 200.0f) { - if (Actor_IsTargeted(globalCtx, &this->actor) && (projectileActor->id == ACTOR_ARMS_HOOK)) { - EnTest_SetupJumpUp(this); - } else if (ABS(yawToProjectile) < 0x2000) { - EnTest_SetupStopAndBlock(this); - } else if (ABS(yawToProjectile) < 0x6000) { - EnTest_SetupJumpBack(this); - } else { - EnTest_SetupJumpUp(this); - } - - return true; - } - - if (Actor_IsTargeted(globalCtx, &this->actor) && (projectileActor->id == ACTOR_ARMS_HOOK)) { - EnTest_SetupJumpUp(this); - return true; - } - - if ((ABS(yawToProjectile) < 0x2000) || (ABS(yawToProjectile) > 0x6000)) { - directionFlag = globalCtx->gameplayFrames % 2; - - if (touchingWall && (wallYawDiff > 0x2000) && (wallYawDiff < 0x6000)) { - directionFlag = false; - } else if (touchingWall && (wallYawDiff < -0x2000) && (wallYawDiff > -0x6000)) { - directionFlag = true; - } - - if (directionFlag) { - func_80864158(this, 4.0f); - } else { - func_80864158(this, -4.0f); - } - } else if (ABS(yawToProjectile) < 0x6000) { - directionFlag = globalCtx->gameplayFrames % 2; - - if (touchingWall && (ABS(wallYawDiff) > 0x6000)) { - directionFlag = false; - } else if (touchingWall && (ABS(wallYawDiff) < 0x2000)) { - directionFlag = true; - } - - if (directionFlag) { - EnTest_SetupJumpBack(this); - } else { - EnTest_SetupJumpUp(this); - } - } - - return true; - } - - return false; -} diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.cpp b/src/overlays/actors/ovl_En_Test/z_en_test.cpp new file mode 100644 index 000000000..60c21cca7 --- /dev/null +++ b/src/overlays/actors/ovl_En_Test/z_en_test.cpp @@ -0,0 +1,2072 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TEST_Z_EN_TEST_C +#include "actor_common.h" +/* + * File: z_en_test.c + * Overlay: ovl_En_Test + * Description: Stalfos + */ + +#include "z_en_test.h" +#include "objects/object_sk2/object_sk2.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnTest_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnTest_SetupWaitGround(EnTest* pthis); +void EnTest_SetupWaitAbove(EnTest* pthis); +void EnTest_SetupJumpBack(EnTest* pthis); +void EnTest_SetupSlashDownEnd(EnTest* pthis); +void EnTest_SetupSlashUp(EnTest* pthis); +void EnTest_SetupJumpslash(EnTest* pthis); +void EnTest_SetupWalkAndBlock(EnTest* pthis); +void func_80860EC0(EnTest* pthis); +void EnTest_SetupSlashDown(EnTest* pthis); +void func_80860BDC(EnTest* pthis); +void EnTest_SetupIdleFromBlock(EnTest* pthis); +void EnTest_SetupRecoil(EnTest* pthis); +void func_80862398(EnTest* pthis); +void func_80862154(EnTest* pthis); +void EnTest_SetupStopAndBlock(EnTest* pthis); +void func_808627C4(EnTest* pthis, GlobalContext* globalCtx); + +void EnTest_WaitGround(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_WaitAbove(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Fall(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Land(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Rise(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Idle(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_WalkAndBlock(EnTest* pthis, GlobalContext* globalCtx); +void func_80860C24(EnTest* pthis, GlobalContext* globalCtx); +void func_80860F84(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_SlashDown(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_SlashDownEnd(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_SlashUp(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_JumpBack(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Jumpslash(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_JumpUp(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_StopAndBlock(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_IdleFromBlock(EnTest* pthis, GlobalContext* globalCtx); +void func_808621D4(EnTest* pthis, GlobalContext* globalCtx); +void func_80862418(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Stunned(EnTest* pthis, GlobalContext* globalCtx); +void func_808628C8(EnTest* pthis, GlobalContext* globalCtx); +void func_80862E6C(EnTest* pthis, GlobalContext* globalCtx); +void func_80863044(EnTest* pthis, GlobalContext* globalCtx); +void func_8086318C(EnTest* pthis, GlobalContext* globalCtx); +void EnTest_Recoil(EnTest* pthis, GlobalContext* globalCtx); +void func_808633E8(EnTest* pthis, GlobalContext* globalCtx); +void func_80862FA8(EnTest* pthis, GlobalContext* globalCtx); + +s32 EnTest_ReactToProjectile(GlobalContext* globalCtx, EnTest* pthis); + +static u8 sJointCopyFlags[] = { + false, // STALFOS_LIMB_NONE + false, // STALFOS_LIMB_ROOT + false, // STALFOS_LIMB_UPPERBODY_ROOT + false, // STALFOS_LIMB_CORE_LOWER_ROOT + true, // STALFOS_LIMB_CORE_UPPER_ROOT + true, // STALFOS_LIMB_NECK_ROOT + true, // STALFOS_LIMB_HEAD_ROOT + true, // STALFOS_LIMB_7 + true, // STALFOS_LIMB_8 + true, // STALFOS_LIMB_JAW_ROOT + true, // STALFOS_LIMB_JAW + true, // STALFOS_LIMB_HEAD + true, // STALFOS_LIMB_NECK_UPPER + true, // STALFOS_LIMB_NECK_LOWER + true, // STALFOS_LIMB_CORE_UPPER + true, // STALFOS_LIMB_CHEST + true, // STALFOS_LIMB_SHOULDER_R_ROOT + true, // STALFOS_LIMB_SHOULDER_ARMOR_R_ROOT + true, // STALFOS_LIMB_SHOULDER_ARMOR_R + true, // STALFOS_LIMB_SHOULDER_L_ROOT + true, // STALFOS_LIMB_SHOULDER_ARMOR_L_ROOT + true, // STALFOS_LIMB_SHOULDER_ARMOR_L + true, // STALFOS_LIMB_ARM_L_ROOT + true, // STALFOS_LIMB_UPPERARM_L_ROOT + true, // STALFOS_LIMB_FOREARM_L_ROOT + true, // STALFOS_LIMB_HAND_L_ROOT + true, // STALFOS_LIMB_HAND_L + true, // STALFOS_LIMB_SHIELD + true, // STALFOS_LIMB_FOREARM_L + true, // STALFOS_LIMB_UPPERARM_L + true, // STALFOS_LIMB_ARM_R_ROOT + true, // STALFOS_LIMB_UPPERARM_R_ROOT + true, // STALFOS_LIMB_FOREARM_R_ROOT + true, // STALFOS_LIMB_HAND_R_ROOT + true, // STALFOS_LIMB_SWORD + true, // STALFOS_LIMB_HAND_R + true, // STALFOS_LIMB_FOREARM_R + true, // STALFOS_LIMB_UPPERARM_R + true, // STALFOS_LIMB_CORE_LOWER + false, // STALFOS_LIMB_LOWERBODY_ROOT + false, // STALFOS_LIMB_WAIST_ROOT + false, // STALFOS_LIMB_LEGS_ROOT + false, // STALFOS_LIMB_LEG_L_ROOT + false, // STALFOS_LIMB_THIGH_L_ROOT + false, // STALFOS_LIMB_LOWERLEG_L_ROOT + false, // STALFOS_LIMB_ANKLE_L_ROOT + false, // STALFOS_LIMB_ANKLE_L + false, // STALFOS_LIMB_FOOT_L_ROOT + false, // STALFOS_LIMB_FOOT_L + false, // STALFOS_LIMB_LOWERLEG_L + false, // STALFOS_LIMB_THIGH_L + false, // STALFOS_LIMB_LEG_R_ROOT + false, // STALFOS_LIMB_THIGH_R_ROOT + false, // STALFOS_LIMB_LOWERLEG_R_ROOT + false, // STALFOS_LIMB_ANKLE_R_ROOT + false, // STALFOS_LIMB_ANKLE_R + false, // STALFOS_LIMB_FOOT_R_ROOT + false, // STALFOS_LIMB_FOOT_R + false, // STALFOS_LIMB_LOWERLEG_R + false, // STALFOS_LIMB_THIGH_R + false, // STALFOS_LIMB_WAIST +}; + +ActorInit En_Test_InitVars = { + ACTOR_EN_TEST, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_SK2, + sizeof(EnTest), + (ActorFunc)EnTest_Init, + (ActorFunc)EnTest_Destroy, + (ActorFunc)EnTest_Update, + (ActorFunc)EnTest_Draw, +}; + +static ColliderCylinderInit sBodyColliderInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 25, 65, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sShieldColliderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC1FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 20, 70, -50, { 0, 0, 0 } }, +}; + +static ColliderQuadInit sSwordColliderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +typedef enum { + /* 0x0 */ STALFOS_DMGEFF_NORMAL, + /* 0x1 */ STALFOS_DMGEFF_STUN, + /* 0x6 */ STALFOS_DMGEFF_FIREMAGIC = 6, + /* 0xD */ STALFOS_DMGEFF_SLING = 0xD, + /* 0xE */ STALFOS_DMGEFF_LIGHT, + /* 0xF */ STALFOS_DMGEFF_FREEZE +} StalfosDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, STALFOS_DMGEFF_STUN), + /* Deku stick */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Slingshot */ DMG_ENTRY(1, STALFOS_DMGEFF_SLING), + /* Explosive */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Boomerang */ DMG_ENTRY(0, STALFOS_DMGEFF_STUN), + /* Normal arrow */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Hammer swing */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Hookshot */ DMG_ENTRY(0, STALFOS_DMGEFF_STUN), + /* Kokiri sword */ DMG_ENTRY(1, STALFOS_DMGEFF_NORMAL), + /* Master sword */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Giant's Knife */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), + /* Fire arrow */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Ice arrow */ DMG_ENTRY(4, STALFOS_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, STALFOS_DMGEFF_LIGHT), + /* Unk arrow 1 */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Unk arrow 2 */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Unk arrow 3 */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Fire magic */ DMG_ENTRY(0, STALFOS_DMGEFF_FIREMAGIC), + /* Ice magic */ DMG_ENTRY(3, STALFOS_DMGEFF_FREEZE), + /* Light magic */ DMG_ENTRY(0, STALFOS_DMGEFF_LIGHT), + /* Shield */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), + /* Mirror Ray */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), + /* Kokiri spin */ DMG_ENTRY(1, STALFOS_DMGEFF_NORMAL), + /* Giant spin */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), + /* Master spin */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Kokiri jump */ DMG_ENTRY(2, STALFOS_DMGEFF_NORMAL), + /* Giant jump */ DMG_ENTRY(8, STALFOS_DMGEFF_NORMAL), + /* Master jump */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), + /* Unknown 1 */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), + /* Unblockable */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), + /* Hammer jump */ DMG_ENTRY(4, STALFOS_DMGEFF_NORMAL), + /* Unknown 2 */ DMG_ENTRY(0, STALFOS_DMGEFF_NORMAL), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x1B, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 500, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), ICHAIN_F32(scale.y, 0, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), +}; + +void EnTest_SetupAction(EnTest* pthis, EnTestActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnTest_Init(Actor* thisx, GlobalContext* globalCtx) { + EffectBlureInit1 slashBlure; + EnTest* pthis = (EnTest*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gStalfosSkel, &gStalfosMiddleGuardAnim, pthis->jointTable, + pthis->morphTable, STALFOS_LIMB_MAX); + SkelAnime_Init(globalCtx, &pthis->upperSkelanime, &gStalfosSkel, &gStalfosMiddleGuardAnim, pthis->upperJointTable, + pthis->upperMorphTable, STALFOS_LIMB_MAX); + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); + + pthis->actor.colChkInfo.cylRadius = 40; + pthis->actor.colChkInfo.cylHeight = 100; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 45.0f; + pthis->actor.colChkInfo.damageTable = &sDamageTable; + + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, &pthis->actor, &sBodyColliderInit); + + Collider_InitCylinder(globalCtx, &pthis->shieldCollider); + Collider_SetCylinder(globalCtx, &pthis->shieldCollider, &pthis->actor, &sShieldColliderInit); + + Collider_InitQuad(globalCtx, &pthis->swordCollider); + Collider_SetQuad(globalCtx, &pthis->swordCollider, &pthis->actor, &sSwordColliderInit); + + pthis->actor.colChkInfo.mass = MASS_HEAVY; + pthis->actor.colChkInfo.health = 10; + + slashBlure.p1StartColor[0] = slashBlure.p1StartColor[1] = slashBlure.p1StartColor[2] = slashBlure.p1StartColor[3] = + slashBlure.p2StartColor[0] = slashBlure.p2StartColor[1] = slashBlure.p2StartColor[2] = + slashBlure.p1EndColor[0] = slashBlure.p1EndColor[1] = slashBlure.p1EndColor[2] = slashBlure.p2EndColor[0] = + slashBlure.p2EndColor[1] = slashBlure.p2EndColor[2] = 255; + + slashBlure.p1EndColor[3] = 0; + slashBlure.p2EndColor[3] = 0; + slashBlure.p2StartColor[3] = 64; + + slashBlure.elemDuration = 4; + slashBlure.unkFlag = 0; + slashBlure.calcMode = 2; + + Effect_Add(globalCtx, &pthis->effectIndex, EFFECT_BLURE1, 0, 0, &slashBlure); + + if (pthis->actor.params != STALFOS_TYPE_CEILING) { + EnTest_SetupWaitGround(pthis); + } else { + EnTest_SetupWaitAbove(pthis); + } + + if (pthis->actor.params == STALFOS_TYPE_INVISIBLE) { + pthis->actor.flags |= ACTOR_FLAG_7; + } +} + +void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest* pthis = (EnTest*)thisx; + + if ((pthis->actor.params != STALFOS_TYPE_2) && + !Actor_FindNearby(globalCtx, &pthis->actor, ACTOR_EN_TEST, ACTORCAT_ENEMY, 8000.0f)) { + func_800F5B58(); + } + + Effect_Delete(globalCtx, pthis->effectIndex); + Collider_DestroyCylinder(globalCtx, &pthis->shieldCollider); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyQuad(globalCtx, &pthis->swordCollider); +} + +/** + * If EnTest_ChooseAction failed to pick a new action, pthis function will unconditionally pick + * a new action as a last resort + */ +void EnTest_ChooseRandomAction(EnTest* pthis, GlobalContext* globalCtx) { + switch ((u32)(Rand_ZeroOne() * 10.0f)) { + case 0: + case 1: + case 5: + case 6: + if ((pthis->actor.xzDistToPlayer < 220.0f) && (pthis->actor.xzDistToPlayer > 170.0f) && + Actor_IsFacingPlayer(&pthis->actor, 0x71C) && Actor_IsTargeted(globalCtx, &pthis->actor)) { + EnTest_SetupJumpslash(pthis); + break; + } + // fallthrough + case 8: + EnTest_SetupWalkAndBlock(pthis); + break; + + case 3: + case 4: + case 7: + func_808627C4(pthis, globalCtx); + break; + + case 2: + case 9: + case 10: + EnTest_SetupStopAndBlock(pthis); + break; + } +} + +void EnTest_ChooseAction(EnTest* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + yawDiff = ABS(yawDiff); + + if (yawDiff >= 0x61A8) { + switch ((u32)(Rand_ZeroOne() * 10.0f)) { + case 0: + case 3: + case 7: + EnTest_SetupStopAndBlock(pthis); + break; + + case 1: + case 5: + case 6: + case 8: + func_808627C4(pthis, globalCtx); + break; + + case 2: + case 4: + case 9: + if (pthis->actor.params != STALFOS_TYPE_CEILING) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnTest_SetupJumpBack(pthis); + } + break; + } + } else if (yawDiff <= 0x3E80) { + if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) > 0x3E80) { + if (((globalCtx->gameplayFrames % 2) != 0) && (pthis->actor.params != STALFOS_TYPE_CEILING)) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnTest_SetupJumpBack(pthis); + } else if ((pthis->actor.xzDistToPlayer < 220.0f) && (pthis->actor.xzDistToPlayer > 170.0f)) { + if (Actor_IsFacingPlayer(&pthis->actor, 0x71C) && !Actor_IsTargeted(globalCtx, &pthis->actor)) { + EnTest_SetupJumpslash(pthis); + } + } else { + EnTest_SetupWalkAndBlock(pthis); + } + } else { + if (pthis->actor.xzDistToPlayer < 110.0f) { + if (Rand_ZeroOne() > 0.2f) { + if (player->stateFlags1 & 0x10) { + if (pthis->actor.isTargeted) { + EnTest_SetupSlashDown(pthis); + } else { + func_808627C4(pthis, globalCtx); + } + } else { + EnTest_SetupSlashDown(pthis); + } + } + } else { + EnTest_ChooseRandomAction(pthis, globalCtx); + } + } + } else { + EnTest_ChooseRandomAction(pthis, globalCtx); + } +} + +void EnTest_SetupWaitGround(EnTest* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gStalfosMiddleGuardAnim); + pthis->unk_7C8 = 0; + pthis->timer = 15; + pthis->actor.scale.y = 0.0f; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 3.5f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnTest_SetupAction(pthis, EnTest_WaitGround); +} + +void EnTest_WaitGround(EnTest* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if ((pthis->timer == 0) && (ABS(pthis->actor.yDistToPlayer) < 150.0f)) { + pthis->unk_7C8 = 3; + EnTest_SetupAction(pthis, EnTest_Rise); + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + + if (pthis->actor.params != STALFOS_TYPE_2) { + func_800F5ACC(NA_BGM_MINI_BOSS); + } + } else { + if (pthis->timer != 0) { + pthis->timer--; + } + + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 3.5f; + } +} + +void EnTest_SetupWaitAbove(EnTest* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gStalfosMiddleGuardAnim); + pthis->unk_7C8 = 0; + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 150.0f; + Actor_SetScale(&pthis->actor, 0.0f); + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnTest_SetupAction(pthis, EnTest_WaitAbove); +} + +void EnTest_WaitAbove(EnTest* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.world.pos.y = pthis->actor.home.pos.y + 150.0f; + + if ((pthis->actor.xzDistToPlayer < 200.0f) && (ABS(pthis->actor.yDistToPlayer) < 450.0f)) { + EnTest_SetupAction(pthis, EnTest_Fall); + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Actor_SetScale(&pthis->actor, 0.015f); + } +} + +void EnTest_SetupIdle(EnTest* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gStalfosMiddleGuardAnim); + pthis->unk_7C8 = 0xA; + pthis->timer = (Rand_ZeroOne() * 10.0f) + 5.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnTest_SetupAction(pthis, EnTest_Idle); +} + +void EnTest_Idle(EnTest* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff; + + SkelAnime_Update(&pthis->skelAnime); + + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + yawDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if (pthis->actor.xzDistToPlayer < 100.0f) { + if ((player->swordState != 0) && (ABS(yawDiff) >= 0x1F40)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (Rand_ZeroOne() > 0.7f && player->swordAnimation != 0x11) { + EnTest_SetupJumpBack(pthis); + } else { + func_808627C4(pthis, globalCtx); + } + return; + } + } + + if (pthis->timer != 0) { + pthis->timer--; + } else { + if (Actor_IsFacingPlayer(&pthis->actor, 0x1555)) { + if ((pthis->actor.xzDistToPlayer < 220.0f) && (pthis->actor.xzDistToPlayer > 160.0f) && + (Rand_ZeroOne() < 0.3f)) { + if (Actor_IsTargeted(globalCtx, &pthis->actor)) { + EnTest_SetupJumpslash(pthis); + } else { + func_808627C4(pthis, globalCtx); + } + } else { + if (Rand_ZeroOne() > 0.3f) { + EnTest_SetupWalkAndBlock(pthis); + } else { + func_808627C4(pthis, globalCtx); + } + } + } else { + if (Rand_ZeroOne() > 0.7f) { + func_80860BDC(pthis); + } else { + EnTest_ChooseAction(pthis, globalCtx); + } + } + } + } +} + +void EnTest_Fall(EnTest* pthis, GlobalContext* globalCtx) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gStalfosLandFromLeapAnim, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.world.pos.y <= pthis->actor.floorHeight) { + pthis->skelAnime.playSpeed = 1.0f; + pthis->unk_7C8 = 0xC; + pthis->timer = pthis->unk_7E4 * 0.15f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + EnTest_SetupAction(pthis, EnTest_Land); + } +} + +void EnTest_Land(EnTest* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnTest_SetupIdle(pthis); + pthis->timer = (Rand_ZeroOne() * 10.0f) + 5.0f; + } +} + +void EnTest_SetupWalkAndBlock(EnTest* pthis) { + Animation_Change(&pthis->upperSkelanime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); + Animation_PlayLoop(&pthis->skelAnime, &gStalfosSlowAdvanceAnim); + pthis->timer = (s16)(Rand_ZeroOne() * 5.0f); + pthis->unk_7C8 = 0xD; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnTest_SetupAction(pthis, EnTest_WalkAndBlock); +} + +void EnTest_WalkAndBlock(EnTest* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 checkDist = 0.0f; + s32 pad1; + s32 prevFrame; + s32 temp_f16; + f32 playSpeed; + Player* player = GET_PLAYER(globalCtx); + s32 absPlaySpeed; + s16 yawDiff; + + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + pthis->timer++; + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + checkDist = 150.0f; + } + + if (pthis->actor.xzDistToPlayer <= (80.0f + checkDist)) { + Math_SmoothStepToF(&pthis->actor.speedXZ, -5.0f, 1.0f, 0.8f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > (110.0f + checkDist)) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 5.0f, 1.0f, 0.8f, 0.0f); + } + + if (pthis->actor.speedXZ >= 5.0f) { + pthis->actor.speedXZ = 5.0f; + } else if (pthis->actor.speedXZ < -5.0f) { + pthis->actor.speedXZ = -5.0f; + } + + if ((pthis->actor.params == STALFOS_TYPE_CEILING) && + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.world.rot.y)) { + pthis->actor.speedXZ *= -1.0f; + } + + if (ABS(pthis->actor.speedXZ) < 3.0f) { + Animation_Change(&pthis->skelAnime, &gStalfosSlowAdvanceAnim, 0.0f, pthis->skelAnime.curFrame, + Animation_GetLastFrame(&gStalfosSlowAdvanceAnim), 0, -6.0f); + playSpeed = pthis->actor.speedXZ * 10.0f; + } else { + Animation_Change(&pthis->skelAnime, &gStalfosFastAdvanceAnim, 0.0f, pthis->skelAnime.curFrame, + Animation_GetLastFrame(&gStalfosFastAdvanceAnim), 0, -4.0f); + playSpeed = pthis->actor.speedXZ * 10.0f * 0.02f; + } + + if (pthis->actor.speedXZ >= 0.0f) { + if (pthis->unk_7DE == 0) { + pthis->unk_7DE++; + } + + playSpeed = CLAMP_MAX(playSpeed, 2.5f); + pthis->skelAnime.playSpeed = playSpeed; + } else { + playSpeed = CLAMP_MIN(playSpeed, -2.5f); + pthis->skelAnime.playSpeed = playSpeed; + } + + yawDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if ((pthis->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0)) { + if (ABS(yawDiff) >= 0x1F40) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if ((Rand_ZeroOne() > 0.7f) && (player->swordAnimation != 0x11)) { + EnTest_SetupJumpBack(pthis); + } else { + EnTest_SetupStopAndBlock(pthis); + } + + return; + } + } + + prevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + + temp_f16 = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + absPlaySpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if ((s32)pthis->skelAnime.curFrame != prevFrame) { + s32 temp_v0_2 = absPlaySpeed + prevFrame; + + if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WALK); + } + } + + if ((pthis->timer % 32) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WARAU); + pthis->timer += (s16)(Rand_ZeroOne() * 5.0f); + } + + if ((pthis->actor.xzDistToPlayer < 220.0f) && (pthis->actor.xzDistToPlayer > 160.0f) && + (Actor_IsFacingPlayer(&pthis->actor, 0x71C))) { + if (Actor_IsTargeted(globalCtx, &pthis->actor)) { + if (Rand_ZeroOne() < 0.1f) { + EnTest_SetupJumpslash(pthis); + return; + } + } else if (player->heldItemActionParam != PLAYER_AP_NONE) { + if (pthis->actor.isTargeted) { + if ((globalCtx->gameplayFrames % 2) != 0) { + func_808627C4(pthis, globalCtx); + return; + } + + EnTest_ChooseAction(pthis, globalCtx); + } else { + func_80860EC0(pthis); + } + } + } + + if (Rand_ZeroOne() < 0.4f) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + } + + if (!Actor_IsFacingPlayer(&pthis->actor, 0x11C7)) { + EnTest_SetupIdle(pthis); + pthis->timer = (Rand_ZeroOne() * 10.0f) + 10.0f; + return; + } + + if (pthis->actor.xzDistToPlayer < 110.0f) { + if (Rand_ZeroOne() > 0.2f) { + if (player->stateFlags1 & 0x10) { + if (pthis->actor.isTargeted) { + EnTest_SetupSlashDown(pthis); + } else { + func_808627C4(pthis, globalCtx); + } + } else { + EnTest_SetupSlashDown(pthis); + } + } else { + EnTest_SetupStopAndBlock(pthis); + } + } else if (Rand_ZeroOne() < 0.1f) { + pthis->actor.speedXZ = 5.0f; + } + } +} + +// a variation of sidestep +void func_80860BDC(EnTest* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gStalfosSidestepAnim); + pthis->unk_7C8 = 0xE; + EnTest_SetupAction(pthis, func_80860C24); +} + +// a variation of sidestep +void func_80860C24(EnTest* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + s16 yawChange; + f32 playSpeed; + s32 prevFrame; + s32 temp1; + s32 temp2; + s32 absPlaySpeed; + + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + yawDiff = pthis->actor.yawTowardsPlayer; + yawDiff -= pthis->actor.shape.rot.y; + + if (yawDiff > 0) { + yawChange = (yawDiff / 42.0f) + 300.0f; + pthis->actor.shape.rot.y += yawChange * 2; + } else { + yawChange = (yawDiff / 42.0f) - 300.0f; + pthis->actor.shape.rot.y += yawChange * 2; + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (yawDiff > 0) { + playSpeed = yawChange * 0.02f; + playSpeed = CLAMP_MAX(playSpeed, 1.0f); + pthis->skelAnime.playSpeed = playSpeed; + } else { + playSpeed = yawChange * 0.02f; + playSpeed = CLAMP_MIN(playSpeed, -1.0f); + pthis->skelAnime.playSpeed = playSpeed; + } + + prevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + temp1 = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + absPlaySpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if ((s32)pthis->skelAnime.curFrame != prevFrame) { + temp2 = absPlaySpeed + prevFrame; + + if (((temp2 > 2) && (temp1 <= 0)) || ((temp1 < 7) && (temp2 >= 9))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WALK); + } + } + + if (Actor_IsFacingPlayer(&pthis->actor, 0x71C)) { + if (Rand_ZeroOne() > 0.8f) { + if ((Rand_ZeroOne() > 0.7f)) { + func_80860EC0(pthis); + } else { + EnTest_ChooseAction(pthis, globalCtx); + } + } else { + EnTest_SetupWalkAndBlock(pthis); + } + } + } +} + +// a variation of sidestep +void func_80860EC0(EnTest* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gStalfosSidestepAnim); + pthis->unk_7C8 = 0xF; + pthis->actor.speedXZ = (Rand_ZeroOne() > 0.5f) ? -0.5f : 0.5f; + pthis->timer = (s16)((Rand_ZeroOne() * 15.0f) + 25.0f); + pthis->unk_7EC = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnTest_SetupAction(pthis, func_80860F84); +} + +// a variation of sidestep +void func_80860F84(EnTest* pthis, GlobalContext* globalCtx) { + s16 playerYaw180; + s32 pad; + s32 prevFrame; + s32 temp_f16; + s16 yawDiff; + Player* player = GET_PLAYER(globalCtx); + f32 checkDist = 0.0f; + s16 newYaw; + s32 absPlaySpeed; + + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3E80; + playerYaw180 = player->actor.shape.rot.y + 0x8000; + + if (pthis->actor.speedXZ >= 0.0f) { + if (pthis->actor.speedXZ < 6.0f) { + pthis->actor.speedXZ += 0.5f; + } else { + pthis->actor.speedXZ = 6.0f; + } + } else { + if (pthis->actor.speedXZ > -6.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ = -6.0f; + } + } + + if ((pthis->actor.bgCheckFlags & 8) || + ((pthis->actor.params == STALFOS_TYPE_CEILING) && + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.world.rot.y))) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + newYaw = pthis->actor.shape.rot.y + 0x3FFF; + } else { + newYaw = pthis->actor.shape.rot.y - 0x3FFF; + } + + newYaw = pthis->actor.wallYaw - newYaw; + } else { + pthis->actor.speedXZ *= -0.8f; + newYaw = 0; + } + + if (ABS(newYaw) > 0x4000) { + pthis->actor.speedXZ *= -0.8f; + + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ += 0.5f; + } + } + } + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + checkDist = 200.0f; + } + + if (pthis->actor.xzDistToPlayer <= (80.0f + checkDist)) { + Math_SmoothStepToF(&pthis->unk_7EC, -2.5f, 1.0f, 0.8f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > (110.0f + checkDist)) { + Math_SmoothStepToF(&pthis->unk_7EC, 2.5f, 1.0f, 0.8f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_7EC, 0.0f, 1.0f, 6.65f, 0.0f); + } + + if (pthis->unk_7EC != 0.0f) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->unk_7EC; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->unk_7EC; + } + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 0.5f; + + prevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + temp_f16 = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + absPlaySpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if ((s32)pthis->skelAnime.curFrame != prevFrame) { + s32 temp_v0_2 = absPlaySpeed + prevFrame; + + if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WALK); + } + } + + if ((globalCtx->gameplayFrames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WARAU); + } + + yawDiff = playerYaw180 - pthis->actor.shape.rot.y; + yawDiff = ABS(yawDiff); + + if ((yawDiff > 0x6800) || (pthis->timer == 0)) { + EnTest_ChooseAction(pthis, globalCtx); + } else if (pthis->timer != 0) { + pthis->timer--; + } + } +} + +void EnTest_SetupSlashDown(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosDownSlashAnim); + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_STAL_WARAU); + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + pthis->unk_7C8 = 0x10; + pthis->actor.speedXZ = 0.0f; + EnTest_SetupAction(pthis, EnTest_SlashDown); + pthis->swordCollider.info.toucher.damage = 16; + + if (pthis->unk_7DE != 0) { + pthis->unk_7DE = 3; + } +} + +void EnTest_SlashDown(EnTest* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + + if ((s32)pthis->skelAnime.curFrame < 4) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xBB8, 0); + } + + if ((s32)pthis->skelAnime.curFrame == 7) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_SAKEBI); + } + + if ((pthis->skelAnime.curFrame > 7.0f) && (pthis->skelAnime.curFrame < 11.0f)) { + pthis->swordState = 1; + } else { + pthis->swordState = 0; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if ((globalCtx->gameplayFrames % 2) != 0) { + EnTest_SetupSlashDownEnd(pthis); + } else { + EnTest_SetupSlashUp(pthis); + } + } +} + +void EnTest_SetupSlashDownEnd(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosRecoverFromDownSlashAnim); + pthis->unk_7C8 = 0x12; + pthis->actor.speedXZ = 0.0f; + EnTest_SetupAction(pthis, EnTest_SlashDownEnd); +} + +void EnTest_SlashDownEnd(EnTest* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff; + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->swordCollider.base.atFlags & AT_HIT) { + pthis->swordCollider.base.atFlags &= ~AT_HIT; + if (pthis->actor.params != STALFOS_TYPE_CEILING) { + EnTest_SetupJumpBack(pthis); + return; + } + } + + if (Rand_ZeroOne() > 0.7f) { + EnTest_SetupIdle(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + return; + } + + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, &player->actor); + + if (Rand_ZeroOne() > 0.7f) { + if (pthis->actor.params != STALFOS_TYPE_CEILING) { + EnTest_SetupJumpBack(pthis); + return; + } + } + + yawDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if (ABS(yawDiff) <= 0x2710) { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(yawDiff) > 0x3E80) && (pthis->actor.params != STALFOS_TYPE_CEILING)) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnTest_SetupJumpBack(pthis); + } else if (player->stateFlags1 & 0x10) { + if (pthis->actor.isTargeted) { + EnTest_SetupSlashDown(pthis); + } else if ((globalCtx->gameplayFrames % 2) != 0) { + func_808627C4(pthis, globalCtx); + } else { + EnTest_SetupJumpBack(pthis); + } + } else { + EnTest_SetupSlashDown(pthis); + } + } else { + func_808627C4(pthis, globalCtx); + } + } +} + +void EnTest_SetupSlashUp(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosUpSlashAnim); + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + pthis->unk_7C8 = 0x11; + pthis->swordCollider.info.toucher.damage = 16; + pthis->actor.speedXZ = 0.0f; + EnTest_SetupAction(pthis, EnTest_SlashUp); + + if (pthis->unk_7DE != 0) { + pthis->unk_7DE = 3; + } +} + +void EnTest_SlashUp(EnTest* pthis, GlobalContext* globalCtx) { + pthis->actor.speedXZ = 0.0f; + + if ((s32)pthis->skelAnime.curFrame == 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_SAKEBI); + } + + if ((pthis->skelAnime.curFrame > 1.0f) && (pthis->skelAnime.curFrame < 8.0f)) { + pthis->swordState = 1; + } else { + pthis->swordState = 0; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + EnTest_SetupSlashDown(pthis); + } +} + +void EnTest_SetupJumpBack(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosJumpBackwardsAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->unk_7C8 = 0x14; + pthis->timer = 5; + EnTest_SetupAction(pthis, EnTest_JumpBack); + + if (pthis->unk_7DE != 0) { + pthis->unk_7DE = 3; + } + + if (pthis->actor.params != STALFOS_TYPE_CEILING) { + pthis->actor.speedXZ = -11.0f; + } else { + pthis->actor.speedXZ = -7.0f; + } +} + +void EnTest_JumpBack(EnTest* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xBB8, 1); + + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WARAU); + } else { + pthis->timer--; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + if (pthis->actor.xzDistToPlayer <= 100.0f) { + if (Actor_IsFacingPlayer(&pthis->actor, 0x1555)) { + EnTest_SetupSlashDown(pthis); + } else { + EnTest_SetupIdle(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } + } else { + if ((pthis->actor.xzDistToPlayer <= 220.0f) && Actor_IsFacingPlayer(&pthis->actor, 0xE38)) { + EnTest_SetupJumpslash(pthis); + } else { + EnTest_SetupIdle(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } + } + pthis->actor.flags |= ACTOR_FLAG_0; + } + } else if (pthis->skelAnime.curFrame == (pthis->skelAnime.endFrame - 4.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } +} + +void EnTest_SetupJumpslash(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosJumpAnim); + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_STAL_WARAU); + pthis->timer = 0; + pthis->unk_7C8 = 0x17; + pthis->actor.velocity.y = 10.0f; + pthis->actor.speedXZ = 8.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + EnTest_SetupAction(pthis, EnTest_Jumpslash); + pthis->swordCollider.info.toucher.damage = 32; + + if (pthis->unk_7DE != 0) { + pthis->unk_7DE = 3; + } +} + +void EnTest_Jumpslash(EnTest* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->timer == 0) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosJumpslashAnim); + pthis->timer = 1; + pthis->swordState = 1; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_SAKEBI); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + } else { + pthis->actor.speedXZ = 0.0f; + EnTest_SetupIdle(pthis); + } + } + + if ((pthis->timer != 0) && (pthis->skelAnime.curFrame >= 5.0f)) { + pthis->swordState = 0; + } + + if (pthis->actor.world.pos.y <= pthis->actor.floorHeight) { + if (pthis->actor.speedXZ != 0.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } +} + +void EnTest_SetupJumpUp(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosJumpAnim); + pthis->timer = 0; + pthis->unk_7C8 = 4; + pthis->actor.velocity.y = 14.0f; + pthis->actor.speedXZ = 6.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnTest_SetupAction(pthis, EnTest_JumpUp); +} + +void EnTest_JumpUp(EnTest* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.world.pos.y <= pthis->actor.floorHeight) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->unk_7E4 = -(s32)pthis->actor.velocity.y; + + if (pthis->unk_7E4 == 0) { + pthis->unk_7E4 = 1; + } + + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->unk_7C8 = 0xC; + pthis->timer = 4; + Animation_Change(&pthis->skelAnime, &gStalfosLandFromLeapAnim, 0.0f, 0.0f, 0.0f, 2, 0.0f); + EnTest_SetupAction(pthis, EnTest_Land); + } +} + +void EnTest_SetupStopAndBlock(EnTest* pthis) { + Animation_Change(&pthis->skelAnime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); + pthis->unk_7C8 = 0x15; + pthis->actor.speedXZ = 0.0f; + pthis->timer = (Rand_ZeroOne() * 10.0f) + 11.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->unk_7DE = 5; + EnTest_SetupAction(pthis, EnTest_StopAndBlock); +} + +void EnTest_StopAndBlock(EnTest* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if ((ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) > 0x3E80) && + (pthis->actor.params != STALFOS_TYPE_CEILING) && ((globalCtx->gameplayFrames % 2) != 0)) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnTest_SetupJumpBack(pthis); + } + + if (pthis->timer == 0) { + EnTest_SetupIdleFromBlock(pthis); + } else { + pthis->timer--; + } +} + +void EnTest_SetupIdleFromBlock(EnTest* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gStalfosMiddleGuardAnim, -4.0f); + pthis->unk_7C8 = 0x16; + EnTest_SetupAction(pthis, EnTest_IdleFromBlock); +} + +void EnTest_IdleFromBlock(EnTest* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->skelAnime.morphWeight == 0.0f) { + pthis->actor.speedXZ = 0.0f; + pthis->unk_7DE = 0; + + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + if (pthis->actor.xzDistToPlayer < 500.0f) { + EnTest_ChooseAction(pthis, globalCtx); + } else { + func_808627C4(pthis, globalCtx); + } + } + } +} + +void func_80862154(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosFlinchFromHitFrontAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_DAMAGE); + pthis->unk_7C8 = 8; + pthis->actor.speedXZ = -2.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + EnTest_SetupAction(pthis, func_808621D4); +} + +void func_808621D4(EnTest* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.1f, 0.0f); + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.speedXZ = 0.0f; + + if ((pthis->actor.bgCheckFlags & 8) && ((ABS((s16)(pthis->actor.wallYaw - pthis->actor.shape.rot.y)) < 0x38A4) && + (pthis->actor.xzDistToPlayer < 80.0f))) { + EnTest_SetupJumpUp(pthis); + } else if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + EnTest_ChooseAction(pthis, globalCtx); + } else { + return; + } + } + + if (player->swordState != 0) { + if ((pthis->actor.bgCheckFlags & 8) && ((ABS((s16)(pthis->actor.wallYaw - pthis->actor.shape.rot.y)) < 0x38A4) && + (pthis->actor.xzDistToPlayer < 80.0f))) { + EnTest_SetupJumpUp(pthis); + } else if ((Rand_ZeroOne() > 0.7f) && (pthis->actor.params != STALFOS_TYPE_CEILING) && + (player->swordAnimation != 0x11)) { + EnTest_SetupJumpBack(pthis); + } else { + EnTest_SetupStopAndBlock(pthis); + } + + pthis->unk_7C8 = 8; + } +} + +void func_80862398(EnTest* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosFlinchFromHitBehindAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_DAMAGE); + pthis->unk_7C8 = 9; + pthis->actor.speedXZ = -2.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + EnTest_SetupAction(pthis, func_80862418); +} + +void func_80862418(EnTest* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.1f, 0.0f); + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.speedXZ = 0.0f; + + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + EnTest_ChooseAction(pthis, globalCtx); + } else { + return; + } + } + + if (player->swordState != 0) { + if ((pthis->actor.bgCheckFlags & 8) && ((ABS((s16)(pthis->actor.wallYaw - pthis->actor.shape.rot.y)) < 0x38A4) && + (pthis->actor.xzDistToPlayer < 80.0f))) { + EnTest_SetupJumpUp(pthis); + } else if ((Rand_ZeroOne() > 0.7f) && (pthis->actor.params != STALFOS_TYPE_CEILING) && + (player->swordAnimation != 0x11)) { + EnTest_SetupJumpBack(pthis); + } else { + EnTest_SetupStopAndBlock(pthis); + } + + pthis->unk_7C8 = 8; + } +} + +void EnTest_SetupStunned(EnTest* pthis) { + pthis->unk_7C8 = 0xB; + pthis->unk_7DE = 0; + pthis->swordState = 0; + pthis->skelAnime.playSpeed = 0.0f; + pthis->actor.speedXZ = -4.0f; + + if (pthis->lastDamageEffect == STALFOS_DMGEFF_LIGHT) { + Actor_SetColorFilter(&pthis->actor, -0x8000, 0x78, 0, 0x50); + } else { + Actor_SetColorFilter(&pthis->actor, 0, 0x78, 0, 0x50); + + if (pthis->lastDamageEffect == STALFOS_DMGEFF_FREEZE) { + pthis->iceTimer = 36; + } else { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gStalfosFlinchFromHitFrontAnim, 0.0f); + } + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + EnTest_SetupAction(pthis, EnTest_Stunned); +} + +void EnTest_Stunned(EnTest* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); + + if (pthis->actor.colorFilterTimer == 0) { + if (pthis->actor.colChkInfo.health == 0) { + func_80862FA8(pthis, globalCtx); + } else if (player->swordState != 0) { + if ((pthis->actor.bgCheckFlags & 8) && + ((ABS((s16)(pthis->actor.wallYaw - pthis->actor.shape.rot.y)) < 0x38A4) && + (pthis->actor.xzDistToPlayer < 80.0f))) { + EnTest_SetupJumpUp(pthis); + } else if ((Rand_ZeroOne() > 0.7f) && (player->swordAnimation != 0x11)) { + EnTest_SetupJumpBack(pthis); + } else { + EnTest_SetupStopAndBlock(pthis); + } + + pthis->unk_7C8 = 8; + } else { + pthis->actor.speedXZ = 0.0f; + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + EnTest_ChooseAction(pthis, globalCtx); + } + } + } +} + +// a variation of sidestep +void func_808627C4(EnTest* pthis, GlobalContext* globalCtx) { + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + func_80860EC0(pthis); + return; + } + + Animation_MorphToLoop(&pthis->skelAnime, &gStalfosSidestepAnim, -2.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + pthis->actor.speedXZ = ((globalCtx->gameplayFrames % 2) != 0) ? -4.0f : 4.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + pthis->timer = (Rand_ZeroOne() * 20.0f) + 20.0f; + pthis->unk_7C8 = 0x18; + EnTest_SetupAction(pthis, func_808628C8); + pthis->unk_7EC = 0.0f; +} + +// a variation of sidestep +void func_808628C8(EnTest* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad1; + s32 prevFrame; + s32 temp_f16; + s32 pad2; + f32 checkDist = 0.0f; + s16 newYaw; + f32 absPlaySpeed; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xFA0, 1); + + if (pthis->unk_7DE == 0) { + pthis->unk_7DE++; + } + + if (pthis->actor.speedXZ >= 0.0f) { + if (pthis->actor.speedXZ < 6.0f) { + pthis->actor.speedXZ += 0.125f; + } else { + pthis->actor.speedXZ = 6.0f; + } + } else { + if (pthis->actor.speedXZ > -6.0f) { + pthis->actor.speedXZ -= 0.125f; + } else { + pthis->actor.speedXZ = -6.0f; + } + } + + if ((pthis->actor.bgCheckFlags & 8) || + ((pthis->actor.params == STALFOS_TYPE_CEILING) && + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.shape.rot.y + 0x3FFF))) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + newYaw = (pthis->actor.shape.rot.y + 0x3FFF); + } else { + newYaw = (pthis->actor.shape.rot.y - 0x3FFF); + } + + newYaw = pthis->actor.wallYaw - newYaw; + } else { + pthis->actor.speedXZ *= -0.8f; + newYaw = 0; + } + + if (ABS(newYaw) > 0x4000) { + pthis->actor.speedXZ *= -0.8f; + + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ += 0.5f; + } + } + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + checkDist = 200.0f; + } + + if (pthis->actor.xzDistToPlayer <= (80.0f + checkDist)) { + Math_SmoothStepToF(&pthis->unk_7EC, -2.5f, 1.0f, 0.8f, 0.0f); + } else if (pthis->actor.xzDistToPlayer > (110.0f + checkDist)) { + Math_SmoothStepToF(&pthis->unk_7EC, 2.5f, 1.0f, 0.8f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_7EC, 0.0f, 1.0f, 6.65f, 0.0f); + } + + if (pthis->unk_7EC != 0.0f) { + pthis->actor.world.pos.x += (Math_SinS(pthis->actor.shape.rot.y) * pthis->unk_7EC); + pthis->actor.world.pos.z += (Math_CosS(pthis->actor.shape.rot.y) * pthis->unk_7EC); + } + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 0.5f; + prevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + + temp_f16 = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + absPlaySpeed = ABS(pthis->skelAnime.playSpeed); + + if ((pthis->timer % 32) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WARAU); + } + if ((s32)pthis->skelAnime.curFrame != prevFrame) { + s32 temp_v0_2 = (s32)absPlaySpeed + prevFrame; + + if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_WALK); + } + } + + if (pthis->timer == 0) { + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + EnTest_SetupIdle(pthis); + } else if (Actor_IsTargeted(globalCtx, &pthis->actor)) { + if (!EnTest_ReactToProjectile(globalCtx, pthis)) { + EnTest_ChooseAction(pthis, globalCtx); + } + } else if (player->heldItemActionParam != PLAYER_AP_NONE) { + if ((globalCtx->gameplayFrames % 2) != 0) { + EnTest_SetupIdle(pthis); + } else { + EnTest_SetupWalkAndBlock(pthis); + } + } else { + EnTest_SetupWalkAndBlock(pthis); + } + + } else { + pthis->timer--; + } +} + +void func_80862DBC(EnTest* pthis, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_DAMAGE); + pthis->unk_7C8 = 2; + BodyBreak_Alloc(&pthis->bodyBreak, 60, globalCtx); + pthis->actor.home.rot.x = 0; + + if (pthis->swordState >= 0) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->effectIndex)); + pthis->swordState = -1; + } + + pthis->actor.flags &= ~ACTOR_FLAG_0; + + if (pthis->actor.params == STALFOS_TYPE_5) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + } + + EnTest_SetupAction(pthis, func_80862E6C); +} + +void func_80862E6C(EnTest* pthis, GlobalContext* globalCtx) { + if (pthis->actor.child == NULL) { + if (pthis->actor.home.rot.x == 0) { + pthis->actor.home.rot.x = pthis->bodyBreak.count; + } + + if (BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, pthis->actor.params + 8)) { + pthis->actor.child = &pthis->actor; + } + } else { + if (pthis->actor.home.rot.x == 0) { + pthis->actor.colChkInfo.health = 10; + + if (pthis->actor.params == STALFOS_TYPE_4) { + pthis->actor.params = -1; + } else { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + } + + pthis->actor.child = NULL; + pthis->actor.flags |= ACTOR_FLAG_0; + EnTest_SetupJumpBack(pthis); + } else if ((pthis->actor.params == STALFOS_TYPE_5) && + !Actor_FindNearby(globalCtx, &pthis->actor, ACTOR_EN_TEST, ACTORCAT_ENEMY, 8000.0f)) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xD0); + + if (pthis->actor.parent != NULL) { + pthis->actor.parent->home.rot.z--; + } + + Actor_Kill(&pthis->actor); + } + } +} + +void func_80862FA8(EnTest* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosFallOverBackwardsAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_DEAD); + pthis->unk_7DE = 0; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.colorFilterTimer = 0; + pthis->actor.speedXZ = 0.0f; + + if (pthis->actor.params <= STALFOS_TYPE_CEILING) { + pthis->unk_7C8 = 5; + EnTest_SetupAction(pthis, func_80863044); + } else { + func_80862DBC(pthis, globalCtx); + } +} + +void func_80863044(EnTest* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->timer = (Rand_ZeroOne() * 10.0f) + 10.0f; + pthis->unk_7C8 = 7; + EnTest_SetupAction(pthis, func_808633E8); + BodyBreak_Alloc(&pthis->bodyBreak, 60, globalCtx); + } + + if ((s32)pthis->skelAnime.curFrame == 15) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } +} + +void func_808630F0(EnTest* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gStalfosFallOverForwardsAnim); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_DEAD); + pthis->unk_7C8 = 6; + pthis->actor.colorFilterTimer = 0; + pthis->unk_7DE = 0; + pthis->actor.speedXZ = 0.0f; + + if (pthis->actor.params <= STALFOS_TYPE_CEILING) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnTest_SetupAction(pthis, func_8086318C); + } else { + func_80862DBC(pthis, globalCtx); + } +} + +void func_8086318C(EnTest* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->timer = (Rand_ZeroOne() * 10.0f) + 10.0f; + pthis->unk_7C8 = 7; + EnTest_SetupAction(pthis, func_808633E8); + BodyBreak_Alloc(&pthis->bodyBreak, 60, globalCtx); + } + + if (((s32)pthis->skelAnime.curFrame == 10) || ((s32)pthis->skelAnime.curFrame == 25)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } +} + +void EnTest_SetupRecoil(EnTest* pthis) { + pthis->swordState = 0; + pthis->skelAnime.moveFlags = 2; + pthis->unk_7C8 = 0x13; + pthis->skelAnime.playSpeed = -1.0f; + pthis->skelAnime.startFrame = pthis->skelAnime.curFrame; + pthis->skelAnime.endFrame = 0.0f; + EnTest_SetupAction(pthis, EnTest_Recoil); +} + +void EnTest_Recoil(EnTest* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (Rand_ZeroOne() > 0.7f) { + EnTest_SetupIdle(pthis); + pthis->timer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } else if (((globalCtx->gameplayFrames % 2) != 0) && (pthis->actor.params != STALFOS_TYPE_CEILING)) { + EnTest_SetupJumpBack(pthis); + } else { + func_808627C4(pthis, globalCtx); + } + } +} + +void EnTest_Rise(EnTest* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.scale.y < 0.015f) { + pthis->actor.scale.y += 0.002f; + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 3.5f; + } else { + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + EnTest_SetupJumpBack(pthis); + } +} + +void func_808633E8(EnTest* pthis, GlobalContext* globalCtx) { + pthis->actor.params = STALFOS_TYPE_1; + + if (BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, pthis->actor.params)) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xD0); + + if (pthis->actor.parent != NULL) { + pthis->actor.parent->home.rot.z--; + } + + Actor_Kill(&pthis->actor); + } +} + +void EnTest_UpdateHeadRot(EnTest* pthis, GlobalContext* globalCtx) { + s16 lookAngle = pthis->actor.yawTowardsPlayer; + + lookAngle -= (s16)(pthis->headRot.y + pthis->actor.shape.rot.y); + + pthis->headRotOffset.y = CLAMP(lookAngle, -0x7D0, 0x7D0); + pthis->headRot.y += pthis->headRotOffset.y; + pthis->headRot.y = CLAMP(pthis->headRot.y, -0x382F, 0x382F); +} + +void EnTest_UpdateDamage(EnTest* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->shieldCollider.base.acFlags & AC_BOUNCED) { + pthis->shieldCollider.base.acFlags &= ~AC_BOUNCED; + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + + if (pthis->unk_7C8 >= 0xA) { + pthis->actor.speedXZ = -4.0f; + } + } else if (pthis->bodyCollider.base.acFlags & AC_HIT) { + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + + if ((pthis->actor.colChkInfo.damageEffect != STALFOS_DMGEFF_SLING) && + (pthis->actor.colChkInfo.damageEffect != STALFOS_DMGEFF_FIREMAGIC)) { + pthis->lastDamageEffect = pthis->actor.colChkInfo.damageEffect; + if (pthis->swordState >= 1) { + pthis->swordState = 0; + } + pthis->unk_7DC = player->unk_845; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Actor_SetDropFlag(&pthis->actor, &pthis->bodyCollider.info, false); + Audio_StopSfxByPosAndId(&pthis->actor.projectedPos, NA_SE_EN_STAL_WARAU); + + if ((pthis->actor.colChkInfo.damageEffect == STALFOS_DMGEFF_STUN) || + (pthis->actor.colChkInfo.damageEffect == STALFOS_DMGEFF_FREEZE) || + (pthis->actor.colChkInfo.damageEffect == STALFOS_DMGEFF_LIGHT)) { + if (pthis->unk_7C8 != 0xB) { + Actor_ApplyDamage(&pthis->actor); + EnTest_SetupStunned(pthis); + } + } else { + if (Actor_IsFacingPlayer(&pthis->actor, 0x4000)) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + func_80862FA8(pthis, globalCtx); + } else { + func_80862154(pthis); + } + } else if (Actor_ApplyDamage(&pthis->actor) == 0) { + func_808630F0(pthis, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else { + func_80862398(pthis); + } + } + } + } +} + +void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest* pthis = (EnTest*)thisx; + f32 oldWeight; + u32 floorProperty; + s32 pad; + + EnTest_UpdateDamage(pthis, globalCtx); + + if (pthis->actor.colChkInfo.damageEffect != STALFOS_DMGEFF_FIREMAGIC) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 0x1D); + + if (pthis->actor.params == STALFOS_TYPE_1) { + if (pthis->actor.world.pos.y <= pthis->actor.home.pos.y) { + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + pthis->actor.velocity.y = 0.0f; + } + + if (pthis->actor.floorHeight <= pthis->actor.home.pos.y) { + pthis->actor.floorHeight = pthis->actor.home.pos.y; + } + } else if (pthis->actor.bgCheckFlags & 2) { + floorProperty = func_80041EA4(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + + if ((floorProperty == 5) || (floorProperty == 0xC) || + func_80041D4C(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId) == 9) { + Actor_Kill(&pthis->actor); + return; + } + } + + pthis->actionFunc(pthis, globalCtx); + + switch (pthis->unk_7DE) { + case 0: + break; + + case 1: + Animation_Change(&pthis->upperSkelanime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); + AnimationContext_SetCopyTrue(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->upperSkelanime.jointTable, sJointCopyFlags); + pthis->unk_7DE++; + break; + + case 2: + SkelAnime_Update(&pthis->upperSkelanime); + SkelAnime_CopyFrameTableTrue(&pthis->skelAnime, pthis->skelAnime.jointTable, + pthis->upperSkelanime.jointTable, sJointCopyFlags); + break; + + case 3: + pthis->unk_7DE++; + pthis->upperSkelanime.morphWeight = 4.0f; + // fallthrough + case 4: + oldWeight = pthis->upperSkelanime.morphWeight; + pthis->upperSkelanime.morphWeight -= 1.0f; + + if (pthis->upperSkelanime.morphWeight <= 0.0f) { + pthis->unk_7DE = 0; + } + + SkelAnime_InterpFrameTable(pthis->skelAnime.limbCount, pthis->upperSkelanime.jointTable, + pthis->upperSkelanime.jointTable, pthis->skelAnime.jointTable, + 1.0f - (pthis->upperSkelanime.morphWeight / oldWeight)); + SkelAnime_CopyFrameTableTrue(&pthis->skelAnime, pthis->skelAnime.jointTable, + pthis->upperSkelanime.jointTable, sJointCopyFlags); + break; + } + + if ((pthis->actor.colorFilterTimer == 0) && (pthis->actor.colChkInfo.health != 0)) { + if ((pthis->unk_7C8 != 0x10) && (pthis->unk_7C8 != 0x17)) { + EnTest_UpdateHeadRot(pthis, globalCtx); + } else { + Math_SmoothStepToS(&pthis->headRot.y, 0, 1, 0x3E8, 0); + } + } + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 45.0f; + + if ((pthis->actor.colChkInfo.health > 0) || (pthis->actor.colorFilterTimer != 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + + if ((pthis->unk_7C8 >= 0xA) && + ((pthis->actor.colorFilterTimer == 0) || (!(pthis->actor.colorFilterParams & 0x4000)))) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + + if (pthis->unk_7DE != 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->shieldCollider.base); + } + } + + if (pthis->swordState >= 1) { + if (!(pthis->swordCollider.base.atFlags & AT_BOUNCED)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->swordCollider.base); + } else { + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + EnTest_SetupRecoil(pthis); + } + } + + if (pthis->actor.params == STALFOS_TYPE_INVISIBLE) { + if (globalCtx->actorCtx.unk_03 != 0) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_7; + pthis->actor.shape.shadowDraw = ActorShadow_DrawFeet; + } else { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_7); + pthis->actor.shape.shadowDraw = NULL; + } + } +} + +s32 EnTest_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnTest* pthis = (EnTest*)thisx; + s32 pad; + + if (limbIndex == STALFOS_LIMB_HEAD_ROOT) { + rot->x += pthis->headRot.y; + rot->y -= pthis->headRot.x; + rot->z += pthis->headRot.z; + } else if (limbIndex == STALFOS_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_test.c", 3582); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 80 + ABS((s16)(Math_SinS(globalCtx->gameplayFrames * 2000) * 175.0f)), 0, 0, + 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_test.c", 3587); + } + + if ((pthis->actor.params == STALFOS_TYPE_INVISIBLE) && !CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_7)) { + *dList = NULL; + } + + return false; +} + +void EnTest_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f unused1 = { 1100.0f, -700.0f, 0.0f }; + static Vec3f D_80864658 = { 300.0f, 0.0f, 0.0f }; + static Vec3f D_80864664 = { 3400.0f, 0.0f, 0.0f }; + static Vec3f D_80864670 = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_8086467C = { 7000.0f, 1000.0f, 0.0f }; + static Vec3f D_80864688 = { 3000.0f, -2000.0f, -1000.0f }; + static Vec3f D_80864694 = { 3000.0f, -2000.0f, 1000.0f }; + static Vec3f D_808646A0 = { -1300.0f, 1100.0f, 0.0f }; + static Vec3f unused2 = { -3000.0f, 1900.0f, 800.0f }; + static Vec3f unused3 = { -3000.0f, -1100.0f, 800.0f }; + static Vec3f unused4 = { 1900.0f, 1900.0f, 800.0f }; + static Vec3f unused5 = { -3000.0f, -1100.0f, 800.0f }; + static Vec3f unused6 = { 1900.0f, -1100.0f, 800.0f }; + static Vec3f unused7 = { 1900.0f, 1900.0f, 800.0f }; + s32 bodyPart = -1; + Vec3f sp70; + Vec3f sp64; + EnTest* pthis = (EnTest*)thisx; + s32 pad; + Vec3f sp50; + + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 0, 60, 60, dList, BODYBREAK_OBJECT_DEFAULT); + + if (limbIndex == STALFOS_LIMB_SWORD) { + Matrix_MultVec3f(&D_8086467C, &pthis->swordCollider.dim.quad[1]); + Matrix_MultVec3f(&D_80864688, &pthis->swordCollider.dim.quad[0]); + Matrix_MultVec3f(&D_80864694, &pthis->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&D_808646A0, &pthis->swordCollider.dim.quad[2]); + + Collider_SetQuadVertices(&pthis->swordCollider, &pthis->swordCollider.dim.quad[0], + &pthis->swordCollider.dim.quad[1], &pthis->swordCollider.dim.quad[2], + &pthis->swordCollider.dim.quad[3]); + + Matrix_MultVec3f(&D_80864664, &sp70); + Matrix_MultVec3f(&D_80864670, &sp64); + + if ((pthis->swordState >= 1) && + ((pthis->actor.params != STALFOS_TYPE_INVISIBLE) || (globalCtx->actorCtx.unk_03 != 0))) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->effectIndex), &sp70, &sp64); + } else if (pthis->swordState >= 0) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->effectIndex)); + pthis->swordState = -1; + } + + } else if ((limbIndex == STALFOS_LIMB_SHIELD) && (pthis->unk_7DE != 0)) { + Matrix_MultVec3f(&D_80864670, &sp64); + + pthis->shieldCollider.dim.pos.x = sp64.x; + pthis->shieldCollider.dim.pos.y = sp64.y; + pthis->shieldCollider.dim.pos.z = sp64.z; + } else { + Actor_SetFeetPos(&pthis->actor, limbIndex, STALFOS_LIMB_FOOT_L, &D_80864658, STALFOS_LIMB_ANKLE_R, &D_80864658); + + if ((limbIndex == STALFOS_LIMB_FOOT_L) || (limbIndex == STALFOS_LIMB_ANKLE_R)) { + if ((pthis->unk_7C8 == 0x15) || (pthis->unk_7C8 == 0x16)) { + if (pthis->actor.speedXZ != 0.0f) { + Matrix_MultVec3f(&D_80864658, &sp64); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &sp64, 10.0f, 1, 8.0f, 0x64, 0xF, 0); + } + } + } + } + + if (pthis->iceTimer != 0) { + switch (limbIndex) { + case STALFOS_LIMB_HEAD: + bodyPart = 0; + break; + case STALFOS_LIMB_CHEST: + bodyPart = 1; + break; + case STALFOS_LIMB_SWORD: + bodyPart = 2; + break; + case STALFOS_LIMB_SHIELD: + bodyPart = 3; + break; + case STALFOS_LIMB_UPPERARM_R: + bodyPart = 4; + break; + case STALFOS_LIMB_UPPERARM_L: + bodyPart = 5; + break; + case STALFOS_LIMB_WAIST: + bodyPart = 6; + break; + case STALFOS_LIMB_FOOT_L: + bodyPart = 7; + break; + case STALFOS_LIMB_FOOT_R: + bodyPart = 8; + break; + } + + if (bodyPart >= 0) { + Matrix_MultVec3f(&D_80864670, &sp50); + + pthis->bodyPartsPos[bodyPart].x = sp50.x; + pthis->bodyPartsPos[bodyPart].y = sp50.y; + pthis->bodyPartsPos[bodyPart].z = sp50.z; + } + } +} + +void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest* pthis = (EnTest*)thisx; + + func_80093D18(globalCtx->state.gfxCtx); + func_8002EBCC(&pthis->actor, globalCtx, 1); + + if ((thisx->params <= STALFOS_TYPE_CEILING) || (thisx->child == NULL)) { + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnTest_OverrideLimbDraw, + EnTest_PostLimbDraw, pthis); + } + + if (pthis->iceTimer != 0) { + thisx->colorFilterTimer++; + pthis->iceTimer--; + + if ((pthis->iceTimer % 4) == 0) { + s32 iceIndex = pthis->iceTimer >> 2; + + EffectSsEnIce_SpawnFlyingVec3s(globalCtx, thisx, &pthis->bodyPartsPos[iceIndex], 150, 150, 150, 250, 235, + 245, 255, 1.5f); + } + } +} + +// a variation of sidestep +void func_80864158(EnTest* pthis, f32 xzSpeed) { + Animation_MorphToLoop(&pthis->skelAnime, &gStalfosSidestepAnim, -2.0f); + pthis->actor.speedXZ = xzSpeed; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + pthis->timer = (Rand_ZeroOne() * 20.0f) + 15.0f; + pthis->unk_7C8 = 0x18; + EnTest_SetupAction(pthis, func_808628C8); +} + +/** + * Check if a projectile actor is within 300 units and react accordingly. + * Returns true if the projectile test passes and a new action is performed. + */ +s32 EnTest_ReactToProjectile(GlobalContext* globalCtx, EnTest* pthis) { + Actor* projectileActor; + s16 yawToProjectile; + s16 wallYawDiff; + s16 touchingWall; + s16 directionFlag; + + projectileActor = Actor_GetProjectileActor(globalCtx, &pthis->actor, 300.0f); + + if (projectileActor != NULL) { + yawToProjectile = Actor_WorldYawTowardActor(&pthis->actor, projectileActor) - (u16)pthis->actor.shape.rot.y; + + if ((u8)(pthis->actor.bgCheckFlags & 8)) { + wallYawDiff = ((u16)pthis->actor.wallYaw - (u16)pthis->actor.shape.rot.y); + touchingWall = true; + } else { + touchingWall = false; + } + + if (Math_Vec3f_DistXYZ(&pthis->actor.world.pos, &projectileActor->world.pos) < 200.0f) { + if (Actor_IsTargeted(globalCtx, &pthis->actor) && (projectileActor->id == ACTOR_ARMS_HOOK)) { + EnTest_SetupJumpUp(pthis); + } else if (ABS(yawToProjectile) < 0x2000) { + EnTest_SetupStopAndBlock(pthis); + } else if (ABS(yawToProjectile) < 0x6000) { + EnTest_SetupJumpBack(pthis); + } else { + EnTest_SetupJumpUp(pthis); + } + + return true; + } + + if (Actor_IsTargeted(globalCtx, &pthis->actor) && (projectileActor->id == ACTOR_ARMS_HOOK)) { + EnTest_SetupJumpUp(pthis); + return true; + } + + if ((ABS(yawToProjectile) < 0x2000) || (ABS(yawToProjectile) > 0x6000)) { + directionFlag = globalCtx->gameplayFrames % 2; + + if (touchingWall && (wallYawDiff > 0x2000) && (wallYawDiff < 0x6000)) { + directionFlag = false; + } else if (touchingWall && (wallYawDiff < -0x2000) && (wallYawDiff > -0x6000)) { + directionFlag = true; + } + + if (directionFlag) { + func_80864158(pthis, 4.0f); + } else { + func_80864158(pthis, -4.0f); + } + } else if (ABS(yawToProjectile) < 0x6000) { + directionFlag = globalCtx->gameplayFrames % 2; + + if (touchingWall && (ABS(wallYawDiff) > 0x6000)) { + directionFlag = false; + } else if (touchingWall && (ABS(wallYawDiff) < 0x2000)) { + directionFlag = true; + } + + if (directionFlag) { + EnTest_SetupJumpBack(pthis); + } else { + EnTest_SetupJumpUp(pthis); + } + } + + return true; + } + + return false; +} diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.c b/src/overlays/actors/ovl_En_Tg/z_en_tg.cpp similarity index 64% rename from src/overlays/actors/ovl_En_Tg/z_en_tg.c rename to src/overlays/actors/ovl_En_Tg/z_en_tg.cpp index e454de4c0..96d7e3202 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.cpp @@ -23,7 +23,7 @@ void EnTg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTg_Update(Actor* thisx, GlobalContext* globalCtx); void EnTg_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnTg_SpinIfNotTalking(EnTg* this, GlobalContext* globalCtx); +void EnTg_SpinIfNotTalking(EnTg* pthis, GlobalContext* globalCtx); static ColliderCylinderInit sCylinderInit = { { @@ -47,7 +47,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -const ActorInit En_Tg_InitVars = { +ActorInit En_Tg_InitVars = { ACTOR_EN_TG, ACTORCAT_NPC, FLAGS, @@ -60,7 +60,7 @@ const ActorInit En_Tg_InitVars = { }; u16 EnTg_GetTextId(GlobalContext* globalCtx, Actor* thisx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; u16 temp; u32 phi; @@ -71,14 +71,14 @@ u16 EnTg_GetTextId(GlobalContext* globalCtx, Actor* thisx) { } // Use a different set of dialogue in Kakariko Village (Adult) if (globalCtx->sceneNum == SCENE_SPOT01) { - if (this->nextDialogue % 2 != 0) { + if (pthis->nextDialogue % 2 != 0) { phi = 0x5089; } else { phi = 0x508A; } return phi; } else { - if (this->nextDialogue % 2 != 0) { + if (pthis->nextDialogue % 2 != 0) { phi = 0x7025; } else { phi = 0x7026; @@ -88,7 +88,7 @@ u16 EnTg_GetTextId(GlobalContext* globalCtx, Actor* thisx) { } s16 EnTg_OnTextComplete(GlobalContext* globalCtx, Actor* thisx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; switch (Message_GetState(&globalCtx->msgCtx)) { case TEXT_STATE_NONE: @@ -102,15 +102,15 @@ s16 EnTg_OnTextComplete(GlobalContext* globalCtx, Actor* thisx) { case TEXT_STATE_9: return 1; case TEXT_STATE_CLOSING: - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x5089: case 0x508A: - this->nextDialogue++; + pthis->nextDialogue++; break; case 0x7025: case 0x7026: - this->actor.params ^= 1; - this->nextDialogue++; + pthis->actor.params ^= 1; + pthis->nextDialogue++; break; } return 0; @@ -120,48 +120,48 @@ s16 EnTg_OnTextComplete(GlobalContext* globalCtx, Actor* thisx) { } void EnTg_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDancingCoupleSkel, &gDancingCoupleAnim, NULL, NULL, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - this->actor.targetMode = 6; - Actor_SetScale(&this->actor, 0.01f); - this->nextDialogue = globalCtx->state.frames % 2; - this->actionFunc = EnTg_SpinIfNotTalking; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDancingCoupleSkel, &gDancingCoupleAnim, NULL, NULL, 0); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + pthis->actor.targetMode = 6; + Actor_SetScale(&pthis->actor, 0.01f); + pthis->nextDialogue = globalCtx->state.frames % 2; + pthis->actionFunc = EnTg_SpinIfNotTalking; } void EnTg_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void EnTg_SpinIfNotTalking(EnTg* this, GlobalContext* globalCtx) { - if (!this->isTalking) { - this->actor.shape.rot.y += 0x800; +void EnTg_SpinIfNotTalking(EnTg* pthis, GlobalContext* globalCtx) { + if (!pthis->isTalking) { + pthis->actor.shape.rot.y += 0x800; } } void EnTg_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; s32 pad; f32 temp; Vec3s sp2C; - sp2C.x = this->actor.world.pos.x; - sp2C.y = this->actor.world.pos.y; - sp2C.z = (s16)this->actor.world.pos.z + 3; - this->collider.dim.pos = sp2C; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); - temp = this->collider.dim.radius + 30.0f; - func_800343CC(globalCtx, &this->actor, &this->isTalking, temp, EnTg_GetTextId, EnTg_OnTextComplete); + sp2C.x = pthis->actor.world.pos.x; + sp2C.y = pthis->actor.world.pos.y; + sp2C.z = (s16)pthis->actor.world.pos.z + 3; + pthis->collider.dim.pos = sp2C; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + SkelAnime_Update(&pthis->skelAnime); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); + temp = pthis->collider.dim.radius + 30.0f; + func_800343CC(globalCtx, &pthis->actor, &pthis->isTalking, temp, EnTg_GetTextId, EnTg_OnTextComplete); } s32 EnTg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { @@ -169,17 +169,17 @@ s32 EnTg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnTg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; Vec3f targetOffset = { 0.0f, 800.0f, 0.0f }; if (limbIndex == 9) { // Place the target point at the guy's head instead of the center of the actor - Matrix_MultVec3f(&targetOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&targetOffset, &pthis->actor.focus.pos); } } Gfx* EnTg_SetColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { - Gfx* displayList = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + Gfx* displayList = (Gfx*)Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); gDPSetEnvColor(displayList, r, g, b, a); gSPEndDisplayList(displayList + 1); @@ -187,7 +187,7 @@ Gfx* EnTg_SetColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) { } void EnTg_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnTg* this = (EnTg*)thisx; + EnTg* pthis = (EnTg*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tg.c", 462); Matrix_Translate(0.0f, 0.0f, -560.0f, MTXMODE_APPLY); @@ -198,7 +198,7 @@ void EnTg_Draw(Actor* thisx, GlobalContext* globalCtx) { // Set the girl's shirt to white gSPSegment(POLY_OPA_DISP++, 0x09, EnTg_SetColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnTg_OverrideLimbDraw, EnTg_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnTg_OverrideLimbDraw, EnTg_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tg.c", 480); } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c deleted file mode 100644 index 1489f96a3..000000000 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ /dev/null @@ -1,1024 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TITE_Z_EN_TITE_C -#include "actor_common.h" -/* - * File: z_en_tite.c - * Overlay: ovl_En_Tite - * Description: Tektite - */ - -#include "z_en_tite.h" -#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" -#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" -#include "vt.h" -#include "objects/object_tite/object_tite.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -// EnTite_Idle -#define vIdleTimer actionVar1 - -// EnTite_Attack (vQueuedJumps also used by EnTite_MoveTowardPlayer) -#define vAttackState actionVar1 -#define vQueuedJumps actionVar2 - -// EnTite_FlipOnBack -#define vOnBackTimer actionVar1 -#define vLegTwitchTimer actionVar2 - -typedef enum { - /* 0x0 */ TEKTITE_DEATH_CRY, - /* 0x1 */ TEKTITE_UNK_1, - /* 0x2 */ TEKTITE_UNK_2, - /* 0x3 */ TEKTITE_RECOIL, - /* 0x4 */ TEKTITE_UNK_4, - /* 0x5 */ TEKTITE_FALL_APART, - /* 0x6 */ TEKTITE_IDLE, - /* 0x7 */ TEKTITE_STUNNED, - /* 0x8 */ TEKTITE_UNK_8, - /* 0x9 */ TEKTITE_ATTACK, - /* 0xA */ TEKTITE_TURN_TOWARD_PLAYER, - /* 0xB */ TEKTITE_UNK9, - /* 0xC */ TEKTITE_MOVE_TOWARD_PLAYER -} EnTiteAction; - -typedef enum { - /* 0x0 */ TEKTITE_BEGIN_LUNGE, - /* 0x1 */ TEKTITE_MID_LUNGE, - /* 0x2 */ TEKTITE_LANDED, - /* 0x2 */ TEKTITE_SUBMERGED -} EnTiteAttackState; - -typedef enum { - /* 0x0 */ TEKTITE_INITIAL, - /* 0x1 */ TEKTITE_UNFLIPPED, - /* 0x2 */ TEKTITE_FLIPPED -} EnTiteFlipState; - -void EnTite_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTite_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnTite_SetupIdle(EnTite* this); -void EnTite_SetupTurnTowardPlayer(EnTite* this); -void EnTite_SetupMoveTowardPlayer(EnTite* this); -void EnTite_SetupDeathCry(EnTite* this); -void EnTite_SetupFlipUpright(EnTite* this); - -void EnTite_Idle(EnTite* this, GlobalContext* globalCtx); -void EnTite_Attack(EnTite* this, GlobalContext* globalCtx); -void EnTite_TurnTowardPlayer(EnTite* this, GlobalContext* globalCtx); -void EnTite_MoveTowardPlayer(EnTite* this, GlobalContext* globalCtx); -void EnTite_Recoil(EnTite* this, GlobalContext* globalCtx); -void EnTite_Stunned(EnTite* this, GlobalContext* globalCtx); -void EnTite_DeathCry(EnTite* this, GlobalContext* globalCtx); -void EnTite_FallApart(EnTite* this, GlobalContext* globalCtx); -void EnTite_FlipOnBack(EnTite* this, GlobalContext* globalCtx); -void EnTite_FlipUpright(EnTite* this, GlobalContext* globalCtx); - -const ActorInit En_Tite_InitVars = { - ACTOR_EN_TITE, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_TITE, - sizeof(EnTite), - (ActorFunc)EnTite_Init, - (ActorFunc)EnTite_Destroy, - (ActorFunc)EnTite_Update, - (ActorFunc)EnTite_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { 0, { { 0, 1500, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT6, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -static DamageTable sDamageTable[] = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(4, 0xF), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0xE), - /* Ice magic */ DMG_ENTRY(3, 0xF), - /* Light magic */ DMG_ENTRY(0, 0xE), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x45, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), -}; - -static AnimationHeader* D_80B1B634[] = { - &object_tite_Anim_00083C, &object_tite_Anim_0004F8, &object_tite_Anim_00069C, NULL, NULL, NULL, -}; - -// Some kind of offset for the position of each tektite foot -static Vec3f sFootOffset = { 2800.0f, -200.0f, 0.0f }; - -// Relative positions to spawn ice chunks when tektite is frozen -static Vec3f sIceChunks[12] = { - { 20.0f, 20.0f, 0.0f }, { 10.0f, 40.0f, 10.0f }, { -10.0f, 40.0f, 10.0f }, { -20.0f, 20.0f, 0.0f }, - { 10.0f, 40.0f, -10.0f }, { -10.0f, 40.0f, -10.0f }, { 0.0f, 20.0f, -20.0f }, { 10.0f, 0.0f, 10.0f }, - { 10.0f, 0.0f, -10.0f }, { 0.0f, 20.0f, 20.0f }, { -10.0f, 0.0f, 10.0f }, { -10.0f, 0.0f, -10.0f }, -}; - -void EnTite_SetupAction(EnTite* this, EnTiteActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTite* this = (EnTite*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - thisx->targetMode = 3; - Actor_SetScale(thisx, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_tite_Skel_003A20, &object_tite_Anim_0012E4, this->jointTable, - this->morphTable, 25); - ActorShape_Init(&thisx->shape, -200.0f, ActorShadow_DrawCircle, 70.0f); - this->flipState = TEKTITE_INITIAL; - thisx->colChkInfo.damageTable = sDamageTable; - this->actionVar1 = 0; - this->bodyBreak.val = BODYBREAK_STATUS_FINISHED; - thisx->focus.pos = thisx->world.pos; - thisx->focus.pos.y += 20.0f; - thisx->colChkInfo.health = 2; - thisx->colChkInfo.mass = MASS_HEAVY; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, thisx, &sJntSphInit, &this->colliderItem); - this->unk_2DC = 0x1D; - if (this->actor.params == TEKTITE_BLUE) { - this->unk_2DC |= 0x40; // Don't use the actor engine's ripple spawning code - thisx->colChkInfo.health = 4; - thisx->naviEnemyId += 1; - } - EnTite_SetupIdle(this); -} - -void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTite* this = (EnTite*)thisx; - EnEncount1* spawner; - - if (thisx->parent != NULL) { - spawner = (EnEncount1*)thisx->parent; - if (spawner->curNumSpawn > 0) { - spawner->curNumSpawn--; - } - osSyncPrintf("\n\n"); - // "Number of simultaneous occurrences" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 同時発生数 ☆☆☆☆☆%d\n" VT_RST, spawner->curNumSpawn); - osSyncPrintf("\n\n"); - } - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnTite_SetupIdle(EnTite* this) { - Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f); - this->action = TEKTITE_IDLE; - this->vIdleTimer = Rand_S16Offset(15, 30); - this->actor.speedXZ = 0.0f; - EnTite_SetupAction(this, EnTite_Idle); -} - -void EnTite_Idle(EnTite* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if (this->actor.params == TEKTITE_BLUE) { - if (this->actor.bgCheckFlags & 0x20) { - // Float on water surface - this->actor.gravity = 0.0f; - Math_SmoothStepToF(&this->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.yDistToWater, 1.0f, 2.0f, - 0.0f); - } else { - this->actor.gravity = -1.0f; - } - } - if ((this->actor.bgCheckFlags & 3) && (this->actor.velocity.y <= 0.0f)) { - this->actor.velocity.y = 0.0f; - } - if (this->vIdleTimer > 0) { - this->vIdleTimer--; - } else if ((this->actor.xzDistToPlayer < 300.0f) && (this->actor.yDistToPlayer <= 80.0f)) { - EnTite_SetupTurnTowardPlayer(this); - } -} - -void EnTite_SetupAttack(EnTite* this) { - Animation_PlayOnce(&this->skelAnime, &object_tite_Anim_00083C); - this->action = TEKTITE_ATTACK; - this->vAttackState = TEKTITE_BEGIN_LUNGE; - this->vQueuedJumps = Rand_S16Offset(1, 3); - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnTite_SetupAction(this, EnTite_Attack); -} - -void EnTite_Attack(EnTite* this, GlobalContext* globalCtx) { - s16 angleToPlayer; - s32 attackState; - Vec3f ripplePos; - - if (SkelAnime_Update(&this->skelAnime) != 0) { - attackState = this->vAttackState; // for deciding whether to change animation - switch (this->vAttackState) { - case TEKTITE_BEGIN_LUNGE: - // Snap to ground or water, then lunge into the air with some initial speed - this->vAttackState = TEKTITE_MID_LUNGE; - if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & 0x20)) { - if (this->actor.floorHeight > BGCHECK_Y_MIN) { - this->actor.world.pos.y = this->actor.floorHeight; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - } else { - this->actor.world.pos.y += this->actor.yDistToWater; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); - } - this->actor.velocity.y = 8.0f; - this->actor.gravity = -1.0f; - this->actor.speedXZ = 4.0f; - break; - case TEKTITE_MID_LUNGE: - // Continue trajectory until tektite has negative velocity and has landed on ground/water surface - // Snap to ground/water surface, or if falling fast dip into the water and slow fall speed - this->actor.flags |= ACTOR_FLAG_24; - if ((this->actor.bgCheckFlags & 3) || - ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20))) { - if (this->actor.velocity.y <= 0.0f) { - this->vAttackState = TEKTITE_LANDED; - if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & 0x20)) { - if (BGCHECK_Y_MIN < this->actor.floorHeight) { - this->actor.world.pos.y = this->actor.floorHeight; - } - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } else { - this->actor.gravity = 0.0f; - if (this->actor.velocity.y < -8.0f) { - ripplePos = this->actor.world.pos; - ripplePos.y += this->actor.yDistToWater; - this->vAttackState++; // TEKTITE_SUBMERGED - this->actor.velocity.y *= 0.75f; - attackState = this->vAttackState; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 500, 0); - } else { - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } - } - this->actor.world.rot.y = this->actor.shape.rot.y; - } - } - break; - case TEKTITE_LANDED: - // Get ready to begin another lunge if more lunges are queued, otherwise start turning - if (this->vQueuedJumps != 0) { - this->vQueuedJumps--; - this->vAttackState = TEKTITE_BEGIN_LUNGE; - this->collider.base.atFlags &= ~AT_HIT; - } else { - EnTite_SetupTurnTowardPlayer(this); - } - break; - case TEKTITE_SUBMERGED: - // Check if floated to surface - if (this->actor.yDistToWater == 0.0f) { - this->vAttackState = TEKTITE_LANDED; - attackState = this->vAttackState; - } - break; - } - // If switching attack state, change animation (unless tektite is switching between submerged and landed) - if (attackState != this->vAttackState) { - Animation_PlayOnce(&this->skelAnime, D_80B1B634[this->vAttackState]); - } - } - - switch (this->vAttackState) { - case TEKTITE_BEGIN_LUNGE: - // Slightly turn to player and switch to turning/idling action if the player is too far - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 1000, 0); - this->actor.shape.rot.y = this->actor.world.rot.y; - angleToPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f)) { - EnTite_SetupIdle(this); - } else if (ABS(angleToPlayer) >= 9000) { - EnTite_SetupTurnTowardPlayer(this); - } - break; - case TEKTITE_MID_LUNGE: - // Generate sparkles at feet upon landing, set jumping animation and hurtbox and check if hit player - if (this->actor.velocity.y >= 5.0f) { - if (this->actor.bgCheckFlags & 1) { - func_800355B8(globalCtx, &this->frontLeftFootPos); - func_800355B8(globalCtx, &this->frontRightFootPos); - func_800355B8(globalCtx, &this->backRightFootPos); - func_800355B8(globalCtx, &this->backLeftFootPos); - } - } - if (!(this->collider.base.atFlags & AT_HIT) && (this->actor.flags & ACTOR_FLAG_UNCULLED)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } else { - Player* player = GET_PLAYER(globalCtx); - this->collider.base.atFlags &= ~AT_HIT; - Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f); - this->actor.speedXZ = -6.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (&player->actor == this->collider.base.at) { - if (!(this->collider.base.atFlags & AT_BOUNCED)) { - Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); - } - } - EnTite_SetupAction(this, EnTite_Recoil); - } - break; - case TEKTITE_LANDED: - // Slightly turn to player - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 1500, 0); - break; - case TEKTITE_SUBMERGED: - // Float up to water surface - Math_SmoothStepToF(&this->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f); - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.yDistToWater, 1.0f, 2.0f, - 0.0f); - break; - } - // Create ripples on water surface where tektite feet landed - if (this->actor.bgCheckFlags & 2) { - if (!(this->actor.bgCheckFlags & 0x20)) { - func_80033480(globalCtx, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1); - } - } - // if landed, kill XZ speed and play appropriate sounds - if (this->actor.params == TEKTITE_BLUE) { - if (this->actor.bgCheckFlags & 0x40) { - this->actor.speedXZ = 0.0f; - if (this->vAttackState == TEKTITE_SUBMERGED) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); - } - this->actor.bgCheckFlags &= ~0x40; - } else if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - } else if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } -} - -void EnTite_SetupTurnTowardPlayer(EnTite* this) { - Animation_PlayLoop(&this->skelAnime, &object_tite_Anim_000A14); - this->action = TEKTITE_TURN_TOWARD_PLAYER; - if ((this->actor.bgCheckFlags & 3) || ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20))) { - if (this->actor.velocity.y <= 0.0f) { - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } - } - EnTite_SetupAction(this, EnTite_TurnTowardPlayer); -} - -void EnTite_TurnTowardPlayer(EnTite* this, GlobalContext* globalCtx) { - s16 angleToPlayer; - s16 turnVelocity; - - if (((this->actor.bgCheckFlags & 3) || - ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20))) && - (this->actor.velocity.y <= 0.0f)) { - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } - // Calculate turn velocity and animation speed based on angle to player - if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)) { - this->actor.world.pos.y += this->actor.yDistToWater; - } - angleToPlayer = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; - if (angleToPlayer > 0) { - turnVelocity = (angleToPlayer / 42.0f) + 10.0f; - this->actor.world.rot.y += (turnVelocity * 2); - } else { - turnVelocity = (angleToPlayer / 42.0f) - 10.0f; - this->actor.world.rot.y += (turnVelocity * 2); - } - if (angleToPlayer > 0) { - this->skelAnime.playSpeed = turnVelocity * 0.01f; - } else { - this->skelAnime.playSpeed = turnVelocity * 0.01f; - } - - /** - * Play sounds once every animation cycle - */ - SkelAnime_Update(&this->skelAnime); - if (((s16)this->skelAnime.curFrame & 7) == 0) { - if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK_WATER); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); - } - } - - // Idle if player is far enough away from the tektite, move or attack if almost facing player - this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f)) { - EnTite_SetupIdle(this); - } else if (Actor_IsFacingPlayer(&this->actor, 3640)) { - if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { - EnTite_SetupAttack(this); - } else { - EnTite_SetupMoveTowardPlayer(this); - } - } -} - -void EnTite_SetupMoveTowardPlayer(EnTite* this) { - Animation_PlayLoop(&this->skelAnime, &object_tite_Anim_000C70); - this->action = TEKTITE_MOVE_TOWARD_PLAYER; - this->actor.velocity.y = 10.0f; - this->actor.gravity = -1.0f; - this->actor.speedXZ = 4.0f; - this->vQueuedJumps = Rand_S16Offset(1, 3); - if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - } - EnTite_SetupAction(this, EnTite_MoveTowardPlayer); -} - -/** - * Jumping toward player as a method of travel (different from attacking, has no hitbox) - */ -void EnTite_MoveTowardPlayer(EnTite* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); - SkelAnime_Update(&this->skelAnime); - - if (this->actor.bgCheckFlags & 0x42) { - if (!(this->actor.bgCheckFlags & 0x40)) { - func_80033480(globalCtx, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); - } - } - - if ((this->actor.bgCheckFlags & 2) || ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x40))) { - if (this->vQueuedJumps != 0) { - this->vQueuedJumps--; - } else { - EnTite_SetupIdle(this); - } - } - - if (((this->actor.bgCheckFlags & 3) || (this->actor.params == TEKTITE_BLUE && (this->actor.bgCheckFlags & 0x60))) && - (this->actor.velocity.y <= 0.0f)) { - // slightly turn toward player upon landing and snap to ground or water. - this->actor.speedXZ = 0.0f; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4000, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & 0x20)) { - if (this->actor.floorHeight > BGCHECK_Y_MIN) { - this->actor.world.pos.y = this->actor.floorHeight; - } - } else if (this->actor.bgCheckFlags & 0x40) { - Vec3f ripplePos = this->actor.world.pos; - this->actor.bgCheckFlags &= ~0x40; - ripplePos.y += this->actor.yDistToWater; - this->actor.gravity = 0.0f; - this->actor.velocity.y *= 0.75f; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 500, 0); - return; - } else { - // If submerged, float to surface - Math_SmoothStepToF(&this->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.yDistToWater, 1.0f, 2.0f, - 0.0f); - if (this->actor.yDistToWater != 0.0f) { - // Do not change state until tekite has floated to surface - return; - } - } - - // Idle or turn if player is too far away, otherwise keep jumping - if (((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f))) { - EnTite_SetupIdle(this); - } else if (((this->actor.xzDistToPlayer <= 180.0f)) && ((this->actor.yDistToPlayer <= 80.0f))) { - if (this->vQueuedJumps <= 0) { - EnTite_SetupTurnTowardPlayer(this); - } else { - this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 4.0f; - this->actor.flags |= ACTOR_FLAG_24; - this->actor.gravity = -1.0f; - if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - } - } - } else { - this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 4.0f; - this->actor.flags |= ACTOR_FLAG_24; - this->actor.gravity = -1.0f; - if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - } - } - // If in midair: - } else { - // Turn slowly toward player - this->actor.flags |= ACTOR_FLAG_24; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 1000, 0); - if (this->actor.velocity.y >= 6.0f) { - if (this->actor.bgCheckFlags & 1) { - func_800355B8(globalCtx, &this->frontLeftFootPos); - func_800355B8(globalCtx, &this->frontRightFootPos); - func_800355B8(globalCtx, &this->backRightFootPos); - func_800355B8(globalCtx, &this->backLeftFootPos); - } - } - } -} - -void EnTite_SetupRecoil(EnTite* this) { - this->action = TEKTITE_RECOIL; - Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f); - this->actor.speedXZ = -6.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.gravity = -1.0f; - EnTite_SetupAction(this, EnTite_Recoil); -} - -/** - * After tektite hits or gets hit, recoils backwards and slides a bit upon landing - */ -void EnTite_Recoil(EnTite* this, GlobalContext* globalCtx) { - s16 angleToPlayer; - - // Snap to ground or water surface upon landing - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if (((this->actor.bgCheckFlags & 3) || (this->actor.params == TEKTITE_BLUE && (this->actor.bgCheckFlags & 0x20))) && - (this->actor.velocity.y <= 0.0f)) { - if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & 0x20)) { - if (this->actor.floorHeight > BGCHECK_Y_MIN) { - this->actor.world.pos.y = this->actor.floorHeight; - } - } else { - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - this->actor.world.pos.y += this->actor.yDistToWater; - } - } - - // play sound and generate ripples - if (this->actor.bgCheckFlags & 0x42) { - if (!(this->actor.bgCheckFlags & 0x40)) { - func_80033480(globalCtx, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } else { - this->actor.bgCheckFlags &= ~0x40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); - } - } - - // If player is far away, idle. Otherwise attack or move - angleToPlayer = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y); - if ((this->actor.speedXZ == 0.0f) && ((this->actor.bgCheckFlags & 1) || ((this->actor.params == TEKTITE_BLUE) && - (this->actor.bgCheckFlags & 0x20)))) { - this->actor.world.rot.y = this->actor.shape.rot.y; - this->collider.base.atFlags &= ~AT_HIT; - if ((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f) && - (ABS(this->actor.shape.rot.x) < 4000) && (ABS(this->actor.shape.rot.z) < 4000) && - ((this->actor.bgCheckFlags & 1) || - ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)))) { - EnTite_SetupIdle(this); - } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && - (ABS(angleToPlayer) <= 6000)) { - EnTite_SetupAttack(this); - } else { - EnTite_SetupMoveTowardPlayer(this); - } - } - SkelAnime_Update(&this->skelAnime); -} - -void EnTite_SetupStunned(EnTite* this) { - Animation_Change(&this->skelAnime, &object_tite_Anim_0012E4, 0.0f, 0.0f, - (f32)Animation_GetLastFrame(&object_tite_Anim_0012E4), ANIMMODE_LOOP, 4.0f); - this->action = TEKTITE_STUNNED; - this->actor.speedXZ = -6.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (this->damageEffect == 0xF) { - this->spawnIceTimer = 48; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - EnTite_SetupAction(this, EnTite_Stunned); -} - -/** - * stunned or frozen - */ -void EnTite_Stunned(EnTite* this, GlobalContext* globalCtx) { - s16 angleToPlayer; - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - // Snap to ground or water - if (((this->actor.bgCheckFlags & 3) || - ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20))) && - (this->actor.velocity.y <= 0.0f)) { - if (((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & 0x20))) { - if (this->actor.floorHeight > BGCHECK_Y_MIN) { - this->actor.world.pos.y = this->actor.floorHeight; - } - } else { - this->actor.velocity.y = 0.0f; - this->actor.gravity = 0.0f; - this->actor.world.pos.y += this->actor.yDistToWater; - } - } - // Play sounds and spawn dirt effects upon landing - if (this->actor.bgCheckFlags & 0x42) { - if (!(this->actor.bgCheckFlags & 0x40)) { - func_80033480(globalCtx, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } else { - this->actor.bgCheckFlags &= ~0x40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); - } - } - // Decide on next action based on health, flip state and player distance - angleToPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (((this->actor.colorFilterTimer == 0) && (this->actor.speedXZ == 0.0f)) && - ((this->actor.bgCheckFlags & 1) || - ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)))) { - this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->actor.colChkInfo.health == 0) { - EnTite_SetupDeathCry(this); - } else if (this->flipState == TEKTITE_FLIPPED) { - EnTite_SetupFlipUpright(this); - } else if (((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f) && - (ABS(this->actor.shape.rot.x) < 4000) && (ABS(this->actor.shape.rot.z) < 4000)) && - ((this->actor.bgCheckFlags & 1) || - ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & 0x20)))) { - EnTite_SetupIdle(this); - } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && - (ABS(angleToPlayer) <= 6000)) { - EnTite_SetupAttack(this); - } else { - EnTite_SetupMoveTowardPlayer(this); - } - } - SkelAnime_Update(&this->skelAnime); -} - -void EnTite_SetupDeathCry(EnTite* this) { - this->action = TEKTITE_DEATH_CRY; - this->actor.colorFilterTimer = 0; - this->actor.speedXZ = 0.0f; - EnTite_SetupAction(this, EnTite_DeathCry); -} - -/** - * First frame of death. Scream in pain and allocate memory for EnPart data - */ -void EnTite_DeathCry(EnTite* this, GlobalContext* globalCtx) { - EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_TEKU_DEAD, true, - DEADSOUND_REPEAT_MODE_OFF, 40); - this->action = TEKTITE_FALL_APART; - EnTite_SetupAction(this, EnTite_FallApart); - BodyBreak_Alloc(&this->bodyBreak, 24, globalCtx); -} - -/** - * Spawn EnPart and drop items - */ -void EnTite_FallApart(EnTite* this, GlobalContext* globalCtx) { - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params + 0xB)) { - if (this->actor.params == TEKTITE_BLUE) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); - } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x40); - } - Actor_Kill(&this->actor); - } -} - -void EnTite_SetupFlipOnBack(EnTite* this) { - - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_tite_Anim_000A14, 1.5f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_REVERSE); - this->flipState = TEKTITE_FLIPPED; - this->vOnBackTimer = 500; - this->actor.speedXZ = 0.0f; - this->actor.gravity = -1.0f; - this->vLegTwitchTimer = (Rand_ZeroOne() * 50.0f); - this->actor.velocity.y = 11.0f; - EnTite_SetupAction(this, EnTite_FlipOnBack); -} - -/** - * During the flip animation and also while idling on back - */ -void EnTite_FlipOnBack(EnTite* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.z, 0x7FFF, 1, 4000, 0); - // randomly reset the leg wiggling animation whenever timer reaches 0 to give illusion of twitching legs - this->vLegTwitchTimer--; - if (this->vLegTwitchTimer == 0) { - this->vLegTwitchTimer = Rand_ZeroOne() * 30.0f; - this->skelAnime.curFrame = Rand_ZeroOne() * 5.0f; - } - SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 3) { - // Upon landing, spawn dust and make noise - if (this->actor.bgCheckFlags & 2) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 0xB, 4.0f, 0, 0, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - this->vOnBackTimer--; - if (this->vOnBackTimer == 0) { - EnTite_SetupFlipUpright(this); - } - } else { - // Gradually increase y offset during flip so that the actor position is at tektite's back instead of feet - if (this->actor.shape.yOffset < 2800.0f) { - this->actor.shape.yOffset += 400.0f; - } - } -} - -void EnTite_SetupFlipUpright(EnTite* this) { - this->flipState = TEKTITE_UNFLIPPED; - this->actionVar1 = 1000; // value unused here and overwritten in SetupIdle - //! @bug flying tektite: water sets gravity to 0 so y velocity will never decrease from 13 - this->actor.velocity.y = 13.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_REVERSE); - EnTite_SetupAction(this, EnTite_FlipUpright); -} - -void EnTite_FlipUpright(EnTite* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 0xFA0, 0); - SkelAnime_Update(&this->skelAnime); - //! @bug flying tektite: the following condition is never met and tektite stays stuck in this action forever - if (this->actor.bgCheckFlags & 2) { - func_80033480(globalCtx, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backRightFootPos, 1.0f, 2, 80, 15, 1); - func_80033480(globalCtx, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1); - this->actor.shape.yOffset = 0.0f; - this->actor.world.pos.y = this->actor.floorHeight; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - EnTite_SetupIdle(this); - } -} - -void EnTite_CheckDamage(Actor* thisx, GlobalContext* globalCtx) { - EnTite* this = (EnTite*)thisx; - - if ((this->collider.base.acFlags & AC_HIT) && (this->action >= TEKTITE_IDLE)) { - this->collider.base.acFlags &= ~AC_HIT; - if (thisx->colChkInfo.damageEffect != 0xE) { // Immune to fire magic - this->damageEffect = thisx->colChkInfo.damageEffect; - Actor_SetDropFlag(thisx, &this->collider.elements[0].info, 0); - // Stun if Tektite hit by nut, boomerang, hookshot, ice arrow or ice magic - if ((thisx->colChkInfo.damageEffect == 1) || (thisx->colChkInfo.damageEffect == 0xF)) { - if (this->action != TEKTITE_STUNNED) { - Actor_SetColorFilter(thisx, 0, 0x78, 0, 0x50); - Actor_ApplyDamage(thisx); - EnTite_SetupStunned(this); - } - // Otherwise apply damage and handle death where necessary - } else { - if ((thisx->colorFilterTimer == 0) || ((thisx->colorFilterParams & 0x4000) == 0)) { - Actor_SetColorFilter(thisx, 0x4000, 0xFF, 0, 8); - Actor_ApplyDamage(thisx); - } - if (thisx->colChkInfo.health == 0) { - EnTite_SetupDeathCry(this); - } else { - // Flip tektite back up if it's on its back - Audio_PlayActorSound2(thisx, NA_SE_EN_TEKU_DAMAGE); - if (this->flipState != TEKTITE_FLIPPED) { - EnTite_SetupRecoil(this); - } else { - EnTite_SetupFlipUpright(this); - } - } - } - } - // If hammer has recently hit the floor and player is close to tektite, flip over - } else if ((thisx->colChkInfo.health != 0) && (globalCtx->actorCtx.unk_02 != 0) && - (thisx->xzDistToPlayer <= 400.0f) && (thisx->bgCheckFlags & 1)) { - if (this->flipState == TEKTITE_FLIPPED) { - EnTite_SetupFlipUpright(this); - } else if ((this->action >= TEKTITE_IDLE) || (this->action >= TEKTITE_IDLE)) { - if (1) {} - EnTite_SetupFlipOnBack(this); - } - } -} - -void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTite* this = (EnTite*)thisx; - char pad[0x4]; - CollisionPoly* floorPoly; - WaterBox* waterBox; - f32 waterSurfaceY; - - EnTite_CheckDamage(thisx, globalCtx); - // Stay still if hit by immunity damage type this frame - if (thisx->colChkInfo.damageEffect != 0xE) { - this->actionFunc(this, globalCtx); - Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 40.0f, 20.0f, this->unk_2DC); - // If on water, snap feet to surface and spawn ripples - if ((this->actor.params == TEKTITE_BLUE) && (thisx->bgCheckFlags & 0x20)) { - floorPoly = thisx->floorPoly; - if ((((globalCtx->gameplayFrames % 8) == 0) || (thisx->velocity.y < 0.0f)) && - (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->backRightFootPos.x, - this->backRightFootPos.z, &waterSurfaceY, &waterBox)) && - (this->backRightFootPos.y <= waterSurfaceY)) { - this->backRightFootPos.y = waterSurfaceY; - EffectSsGRipple_Spawn(globalCtx, &this->backRightFootPos, 0, 220, 0); - } - if (((((globalCtx->gameplayFrames + 2) % 8) == 0) || (thisx->velocity.y < 0.0f)) && - (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->backLeftFootPos.x, - this->backLeftFootPos.z, &waterSurfaceY, &waterBox)) && - (this->backLeftFootPos.y <= waterSurfaceY)) { - this->backLeftFootPos.y = waterSurfaceY; - EffectSsGRipple_Spawn(globalCtx, &this->backLeftFootPos, 0, 220, 0); - } - if (((((globalCtx->gameplayFrames + 4) % 8) == 0) || (thisx->velocity.y < 0.0f)) && - (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->frontLeftFootPos.x, - this->frontLeftFootPos.z, &waterSurfaceY, &waterBox)) && - (this->frontLeftFootPos.y <= waterSurfaceY)) { - this->frontLeftFootPos.y = waterSurfaceY; - EffectSsGRipple_Spawn(globalCtx, &this->frontLeftFootPos, 0, 220, 0); - } - if (((((globalCtx->gameplayFrames + 1) % 8) == 0) || (thisx->velocity.y < 0.0f)) && - (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->frontRightFootPos.x, - this->frontRightFootPos.z, &waterSurfaceY, &waterBox)) && - (this->frontRightFootPos.y <= waterSurfaceY)) { - this->frontRightFootPos.y = waterSurfaceY; - EffectSsGRipple_Spawn(globalCtx, &this->frontRightFootPos, 0, 220, 0); - } - thisx->floorPoly = floorPoly; - } - - // If on ground and currently flipped over, set tektite to be fully upside-down - if (thisx->bgCheckFlags & 3) { - func_800359B8(thisx, thisx->shape.rot.y, &thisx->shape.rot); - if (this->flipState >= TEKTITE_FLIPPED) { - thisx->shape.rot.z += 0x7FFF; - } - // Otherwise ensure the tektite is rotating back upright - } else { - Math_SmoothStepToS(&thisx->shape.rot.x, 0, 1, 1000, 0); - if (this->flipState <= TEKTITE_UNFLIPPED) { - Math_SmoothStepToS(&thisx->shape.rot.z, 0, 1, 1000, 0); - if (thisx->shape.yOffset > 0) { - thisx->shape.yOffset -= 400.0f; - } - } - } - } - thisx->focus.pos = thisx->world.pos; - thisx->focus.pos.y += 20.0f; - - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** limbDList, Vec3s* rot, void* thisx) { - EnTite* this = (EnTite*)thisx; - - switch (limbIndex) { - case 8: - Matrix_MultVec3f(&sFootOffset, &this->backRightFootPos); - break; - case 13: - Matrix_MultVec3f(&sFootOffset, &this->frontRightFootPos); - break; - case 18: - Matrix_MultVec3f(&sFootOffset, &this->backLeftFootPos); - break; - case 23: - Matrix_MultVec3f(&sFootOffset, &this->frontLeftFootPos); - break; - } - - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 24, 24, limbDList, BODYBREAK_OBJECT_DEFAULT); -} - -void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnTite* this = (EnTite*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tite.c", 1704); - func_80093D18(globalCtx->state.gfxCtx); - Collider_UpdateSpheres(0, &this->collider); - if (this->actor.params == TEKTITE_BLUE) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001300)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001700)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001900)); - } else { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001B00)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001F00)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_002100)); - } - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnTite_PostLimbDraw, - thisx); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tite.c", 1735); - - if (this->spawnIceTimer != 0) { - // Spawn chunks of ice all over the tektite's body - thisx->colorFilterTimer++; - this->spawnIceTimer--; - if ((this->spawnIceTimer & 3) == 0) { - Vec3f iceChunk; - s32 idx = this->spawnIceTimer >> 2; - - iceChunk.x = thisx->world.pos.x + sIceChunks[idx].x; - iceChunk.y = thisx->world.pos.y + sIceChunks[idx].y; - iceChunk.z = thisx->world.pos.z + sIceChunks[idx].z; - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &iceChunk, 150, 150, 150, 250, 235, 245, 255, 1.0f); - } - } -} diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.cpp b/src/overlays/actors/ovl_En_Tite/z_en_tite.cpp new file mode 100644 index 000000000..91a79deba --- /dev/null +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.cpp @@ -0,0 +1,1024 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TITE_Z_EN_TITE_C +#include "actor_common.h" +/* + * File: z_en_tite.c + * Overlay: ovl_En_Tite + * Description: Tektite + */ + +#include "z_en_tite.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" +#include "vt.h" +#include "objects/object_tite/object_tite.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +// EnTite_Idle +#define vIdleTimer actionVar1 + +// EnTite_Attack (vQueuedJumps also used by EnTite_MoveTowardPlayer) +#define vAttackState actionVar1 +#define vQueuedJumps actionVar2 + +// EnTite_FlipOnBack +#define vOnBackTimer actionVar1 +#define vLegTwitchTimer actionVar2 + +typedef enum { + /* 0x0 */ TEKTITE_DEATH_CRY, + /* 0x1 */ TEKTITE_UNK_1, + /* 0x2 */ TEKTITE_UNK_2, + /* 0x3 */ TEKTITE_RECOIL, + /* 0x4 */ TEKTITE_UNK_4, + /* 0x5 */ TEKTITE_FALL_APART, + /* 0x6 */ TEKTITE_IDLE, + /* 0x7 */ TEKTITE_STUNNED, + /* 0x8 */ TEKTITE_UNK_8, + /* 0x9 */ TEKTITE_ATTACK, + /* 0xA */ TEKTITE_TURN_TOWARD_PLAYER, + /* 0xB */ TEKTITE_UNK9, + /* 0xC */ TEKTITE_MOVE_TOWARD_PLAYER +} EnTiteAction; + +typedef enum { + /* 0x0 */ TEKTITE_BEGIN_LUNGE, + /* 0x1 */ TEKTITE_MID_LUNGE, + /* 0x2 */ TEKTITE_LANDED, + /* 0x2 */ TEKTITE_SUBMERGED +} EnTiteAttackState; + +typedef enum { + /* 0x0 */ TEKTITE_INITIAL, + /* 0x1 */ TEKTITE_UNFLIPPED, + /* 0x2 */ TEKTITE_FLIPPED +} EnTiteFlipState; + +void EnTite_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTite_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnTite_SetupIdle(EnTite* pthis); +void EnTite_SetupTurnTowardPlayer(EnTite* pthis); +void EnTite_SetupMoveTowardPlayer(EnTite* pthis); +void EnTite_SetupDeathCry(EnTite* pthis); +void EnTite_SetupFlipUpright(EnTite* pthis); + +void EnTite_Idle(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_Attack(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_TurnTowardPlayer(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_MoveTowardPlayer(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_Recoil(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_Stunned(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_DeathCry(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_FallApart(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_FlipOnBack(EnTite* pthis, GlobalContext* globalCtx); +void EnTite_FlipUpright(EnTite* pthis, GlobalContext* globalCtx); + +ActorInit En_Tite_InitVars = { + ACTOR_EN_TITE, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_TITE, + sizeof(EnTite), + (ActorFunc)EnTite_Init, + (ActorFunc)EnTite_Destroy, + (ActorFunc)EnTite_Update, + (ActorFunc)EnTite_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 0, { { 0, 1500, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static DamageTable sDamageTable[] = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(4, 0xF), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0xE), + /* Ice magic */ DMG_ENTRY(3, 0xF), + /* Light magic */ DMG_ENTRY(0, 0xE), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x45, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), +}; + +static AnimationHeader* D_80B1B634[] = { + &object_tite_Anim_00083C, &object_tite_Anim_0004F8, &object_tite_Anim_00069C, NULL, NULL, NULL, +}; + +// Some kind of offset for the position of each tektite foot +static Vec3f sFootOffset = { 2800.0f, -200.0f, 0.0f }; + +// Relative positions to spawn ice chunks when tektite is frozen +static Vec3f sIceChunks[12] = { + { 20.0f, 20.0f, 0.0f }, { 10.0f, 40.0f, 10.0f }, { -10.0f, 40.0f, 10.0f }, { -20.0f, 20.0f, 0.0f }, + { 10.0f, 40.0f, -10.0f }, { -10.0f, 40.0f, -10.0f }, { 0.0f, 20.0f, -20.0f }, { 10.0f, 0.0f, 10.0f }, + { 10.0f, 0.0f, -10.0f }, { 0.0f, 20.0f, 20.0f }, { -10.0f, 0.0f, 10.0f }, { -10.0f, 0.0f, -10.0f }, +}; + +void EnTite_SetupAction(EnTite* pthis, EnTiteActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTite* pthis = (EnTite*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + thisx->targetMode = 3; + Actor_SetScale(thisx, 0.01f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &object_tite_Skel_003A20, &object_tite_Anim_0012E4, pthis->jointTable, + pthis->morphTable, 25); + ActorShape_Init(&thisx->shape, -200.0f, ActorShadow_DrawCircle, 70.0f); + pthis->flipState = TEKTITE_INITIAL; + thisx->colChkInfo.damageTable = sDamageTable; + pthis->actionVar1 = 0; + pthis->bodyBreak.val = BODYBREAK_STATUS_FINISHED; + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 20.0f; + thisx->colChkInfo.health = 2; + thisx->colChkInfo.mass = MASS_HEAVY; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, thisx, &sJntSphInit, &pthis->colliderItem); + pthis->unk_2DC = 0x1D; + if (pthis->actor.params == TEKTITE_BLUE) { + pthis->unk_2DC |= 0x40; // Don't use the actor engine's ripple spawning code + thisx->colChkInfo.health = 4; + thisx->naviEnemyId += 1; + } + EnTite_SetupIdle(pthis); +} + +void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTite* pthis = (EnTite*)thisx; + EnEncount1* spawner; + + if (thisx->parent != NULL) { + spawner = (EnEncount1*)thisx->parent; + if (spawner->curNumSpawn > 0) { + spawner->curNumSpawn--; + } + osSyncPrintf("\n\n"); + // "Number of simultaneous occurrences" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 同時発生数 ☆☆☆☆☆%d\n" VT_RST, spawner->curNumSpawn); + osSyncPrintf("\n\n"); + } + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnTite_SetupIdle(EnTite* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &object_tite_Anim_0012E4, 4.0f); + pthis->action = TEKTITE_IDLE; + pthis->vIdleTimer = Rand_S16Offset(15, 30); + pthis->actor.speedXZ = 0.0f; + EnTite_SetupAction(pthis, EnTite_Idle); +} + +void EnTite_Idle(EnTite* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if (pthis->actor.params == TEKTITE_BLUE) { + if (pthis->actor.bgCheckFlags & 0x20) { + // Float on water surface + pthis->actor.gravity = 0.0f; + Math_SmoothStepToF(&pthis->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.world.pos.y + pthis->actor.yDistToWater, 1.0f, 2.0f, + 0.0f); + } else { + pthis->actor.gravity = -1.0f; + } + } + if ((pthis->actor.bgCheckFlags & 3) && (pthis->actor.velocity.y <= 0.0f)) { + pthis->actor.velocity.y = 0.0f; + } + if (pthis->vIdleTimer > 0) { + pthis->vIdleTimer--; + } else if ((pthis->actor.xzDistToPlayer < 300.0f) && (pthis->actor.yDistToPlayer <= 80.0f)) { + EnTite_SetupTurnTowardPlayer(pthis); + } +} + +void EnTite_SetupAttack(EnTite* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &object_tite_Anim_00083C); + pthis->action = TEKTITE_ATTACK; + pthis->vAttackState = TEKTITE_BEGIN_LUNGE; + pthis->vQueuedJumps = Rand_S16Offset(1, 3); + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnTite_SetupAction(pthis, EnTite_Attack); +} + +void EnTite_Attack(EnTite* pthis, GlobalContext* globalCtx) { + s16 angleToPlayer; + s32 attackState; + Vec3f ripplePos; + + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + attackState = pthis->vAttackState; // for deciding whether to change animation + switch (pthis->vAttackState) { + case TEKTITE_BEGIN_LUNGE: + // Snap to ground or water, then lunge into the air with some initial speed + pthis->vAttackState = TEKTITE_MID_LUNGE; + if ((pthis->actor.params != TEKTITE_BLUE) || !(pthis->actor.bgCheckFlags & 0x20)) { + if (pthis->actor.floorHeight > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + } else { + pthis->actor.world.pos.y += pthis->actor.yDistToWater; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_JUMP_WATER); + } + pthis->actor.velocity.y = 8.0f; + pthis->actor.gravity = -1.0f; + pthis->actor.speedXZ = 4.0f; + break; + case TEKTITE_MID_LUNGE: + // Continue trajectory until tektite has negative velocity and has landed on ground/water surface + // Snap to ground/water surface, or if falling fast dip into the water and slow fall speed + pthis->actor.flags |= ACTOR_FLAG_24; + if ((pthis->actor.bgCheckFlags & 3) || + ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20))) { + if (pthis->actor.velocity.y <= 0.0f) { + pthis->vAttackState = TEKTITE_LANDED; + if ((pthis->actor.params != TEKTITE_BLUE) || !(pthis->actor.bgCheckFlags & 0x20)) { + if (BGCHECK_Y_MIN < pthis->actor.floorHeight) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } else { + pthis->actor.gravity = 0.0f; + if (pthis->actor.velocity.y < -8.0f) { + ripplePos = pthis->actor.world.pos; + ripplePos.y += pthis->actor.yDistToWater; + pthis->vAttackState++; // TEKTITE_SUBMERGED + pthis->actor.velocity.y *= 0.75f; + attackState = pthis->vAttackState; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 500, 0); + } else { + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + } + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } + } + break; + case TEKTITE_LANDED: + // Get ready to begin another lunge if more lunges are queued, otherwise start turning + if (pthis->vQueuedJumps != 0) { + pthis->vQueuedJumps--; + pthis->vAttackState = TEKTITE_BEGIN_LUNGE; + pthis->collider.base.atFlags &= ~AT_HIT; + } else { + EnTite_SetupTurnTowardPlayer(pthis); + } + break; + case TEKTITE_SUBMERGED: + // Check if floated to surface + if (pthis->actor.yDistToWater == 0.0f) { + pthis->vAttackState = TEKTITE_LANDED; + attackState = pthis->vAttackState; + } + break; + } + // If switching attack state, change animation (unless tektite is switching between submerged and landed) + if (attackState != pthis->vAttackState) { + Animation_PlayOnce(&pthis->skelAnime, D_80B1B634[pthis->vAttackState]); + } + } + + switch (pthis->vAttackState) { + case TEKTITE_BEGIN_LUNGE: + // Slightly turn to player and switch to turning/idling action if the player is too far + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 1000, 0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + angleToPlayer = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if ((pthis->actor.xzDistToPlayer > 300.0f) && (pthis->actor.yDistToPlayer > 80.0f)) { + EnTite_SetupIdle(pthis); + } else if (ABS(angleToPlayer) >= 9000) { + EnTite_SetupTurnTowardPlayer(pthis); + } + break; + case TEKTITE_MID_LUNGE: + // Generate sparkles at feet upon landing, set jumping animation and hurtbox and check if hit player + if (pthis->actor.velocity.y >= 5.0f) { + if (pthis->actor.bgCheckFlags & 1) { + func_800355B8(globalCtx, &pthis->frontLeftFootPos); + func_800355B8(globalCtx, &pthis->frontRightFootPos); + func_800355B8(globalCtx, &pthis->backRightFootPos); + func_800355B8(globalCtx, &pthis->backLeftFootPos); + } + } + if (!(pthis->collider.base.atFlags & AT_HIT) && (pthis->actor.flags & ACTOR_FLAG_UNCULLED)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } else { + Player* player = GET_PLAYER(globalCtx); + pthis->collider.base.atFlags &= ~AT_HIT; + Animation_MorphToLoop(&pthis->skelAnime, &object_tite_Anim_0012E4, 4.0f); + pthis->actor.speedXZ = -6.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (&player->actor == pthis->collider.base.at) { + if (!(pthis->collider.base.atFlags & AT_BOUNCED)) { + Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); + } + } + EnTite_SetupAction(pthis, EnTite_Recoil); + } + break; + case TEKTITE_LANDED: + // Slightly turn to player + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 1500, 0); + break; + case TEKTITE_SUBMERGED: + // Float up to water surface + Math_SmoothStepToF(&pthis->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.world.pos.y + pthis->actor.yDistToWater, 1.0f, 2.0f, + 0.0f); + break; + } + // Create ripples on water surface where tektite feet landed + if (pthis->actor.bgCheckFlags & 2) { + if (!(pthis->actor.bgCheckFlags & 0x20)) { + func_80033480(globalCtx, &pthis->frontLeftFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->frontRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backLeftFootPos, 1.0f, 2, 80, 15, 1); + } + } + // if landed, kill XZ speed and play appropriate sounds + if (pthis->actor.params == TEKTITE_BLUE) { + if (pthis->actor.bgCheckFlags & 0x40) { + pthis->actor.speedXZ = 0.0f; + if (pthis->vAttackState == TEKTITE_SUBMERGED) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_LAND_WATER); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_LAND_WATER2); + } + pthis->actor.bgCheckFlags &= ~0x40; + } else if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + } else if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } +} + +void EnTite_SetupTurnTowardPlayer(EnTite* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_tite_Anim_000A14); + pthis->action = TEKTITE_TURN_TOWARD_PLAYER; + if ((pthis->actor.bgCheckFlags & 3) || ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20))) { + if (pthis->actor.velocity.y <= 0.0f) { + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + } + EnTite_SetupAction(pthis, EnTite_TurnTowardPlayer); +} + +void EnTite_TurnTowardPlayer(EnTite* pthis, GlobalContext* globalCtx) { + s16 angleToPlayer; + s16 turnVelocity; + + if (((pthis->actor.bgCheckFlags & 3) || + ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20))) && + (pthis->actor.velocity.y <= 0.0f)) { + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + // Calculate turn velocity and animation speed based on angle to player + if ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)) { + pthis->actor.world.pos.y += pthis->actor.yDistToWater; + } + angleToPlayer = Actor_WorldYawTowardActor(&pthis->actor, &GET_PLAYER(globalCtx)->actor) - pthis->actor.world.rot.y; + if (angleToPlayer > 0) { + turnVelocity = (angleToPlayer / 42.0f) + 10.0f; + pthis->actor.world.rot.y += (turnVelocity * 2); + } else { + turnVelocity = (angleToPlayer / 42.0f) - 10.0f; + pthis->actor.world.rot.y += (turnVelocity * 2); + } + if (angleToPlayer > 0) { + pthis->skelAnime.playSpeed = turnVelocity * 0.01f; + } else { + pthis->skelAnime.playSpeed = turnVelocity * 0.01f; + } + + /** + * Play sounds once every animation cycle + */ + SkelAnime_Update(&pthis->skelAnime); + if (((s16)pthis->skelAnime.curFrame & 7) == 0) { + if ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_WALK_WATER); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_WALK); + } + } + + // Idle if player is far enough away from the tektite, move or attack if almost facing player + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + if ((pthis->actor.xzDistToPlayer > 300.0f) && (pthis->actor.yDistToPlayer > 80.0f)) { + EnTite_SetupIdle(pthis); + } else if (Actor_IsFacingPlayer(&pthis->actor, 3640)) { + if ((pthis->actor.xzDistToPlayer <= 180.0f) && (pthis->actor.yDistToPlayer <= 80.0f)) { + EnTite_SetupAttack(pthis); + } else { + EnTite_SetupMoveTowardPlayer(pthis); + } + } +} + +void EnTite_SetupMoveTowardPlayer(EnTite* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &object_tite_Anim_000C70); + pthis->action = TEKTITE_MOVE_TOWARD_PLAYER; + pthis->actor.velocity.y = 10.0f; + pthis->actor.gravity = -1.0f; + pthis->actor.speedXZ = 4.0f; + pthis->vQueuedJumps = Rand_S16Offset(1, 3); + if ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_JUMP_WATER); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + } + EnTite_SetupAction(pthis, EnTite_MoveTowardPlayer); +} + +/** + * Jumping toward player as a method of travel (different from attacking, has no hitbox) + */ +void EnTite_MoveTowardPlayer(EnTite* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.bgCheckFlags & 0x42) { + if (!(pthis->actor.bgCheckFlags & 0x40)) { + func_80033480(globalCtx, &pthis->frontLeftFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->frontRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backLeftFootPos, 1.0f, 2, 80, 15, 1); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_LAND_WATER); + } + } + + if ((pthis->actor.bgCheckFlags & 2) || ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x40))) { + if (pthis->vQueuedJumps != 0) { + pthis->vQueuedJumps--; + } else { + EnTite_SetupIdle(pthis); + } + } + + if (((pthis->actor.bgCheckFlags & 3) || (pthis->actor.params == TEKTITE_BLUE && (pthis->actor.bgCheckFlags & 0x60))) && + (pthis->actor.velocity.y <= 0.0f)) { + // slightly turn toward player upon landing and snap to ground or water. + pthis->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4000, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if ((pthis->actor.params != TEKTITE_BLUE) || !(pthis->actor.bgCheckFlags & 0x20)) { + if (pthis->actor.floorHeight > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } + } else if (pthis->actor.bgCheckFlags & 0x40) { + Vec3f ripplePos = pthis->actor.world.pos; + pthis->actor.bgCheckFlags &= ~0x40; + ripplePos.y += pthis->actor.yDistToWater; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y *= 0.75f; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 500, 0); + return; + } else { + // If submerged, float to surface + Math_SmoothStepToF(&pthis->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.world.pos.y + pthis->actor.yDistToWater, 1.0f, 2.0f, + 0.0f); + if (pthis->actor.yDistToWater != 0.0f) { + // Do not change state until tekite has floated to surface + return; + } + } + + // Idle or turn if player is too far away, otherwise keep jumping + if (((pthis->actor.xzDistToPlayer > 300.0f) && (pthis->actor.yDistToPlayer > 80.0f))) { + EnTite_SetupIdle(pthis); + } else if (((pthis->actor.xzDistToPlayer <= 180.0f)) && ((pthis->actor.yDistToPlayer <= 80.0f))) { + if (pthis->vQueuedJumps <= 0) { + EnTite_SetupTurnTowardPlayer(pthis); + } else { + pthis->actor.velocity.y = 10.0f; + pthis->actor.speedXZ = 4.0f; + pthis->actor.flags |= ACTOR_FLAG_24; + pthis->actor.gravity = -1.0f; + if ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_JUMP_WATER); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + } + } + } else { + pthis->actor.velocity.y = 10.0f; + pthis->actor.speedXZ = 4.0f; + pthis->actor.flags |= ACTOR_FLAG_24; + pthis->actor.gravity = -1.0f; + if ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_JUMP_WATER); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + } + } + // If in midair: + } else { + // Turn slowly toward player + pthis->actor.flags |= ACTOR_FLAG_24; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 1000, 0); + if (pthis->actor.velocity.y >= 6.0f) { + if (pthis->actor.bgCheckFlags & 1) { + func_800355B8(globalCtx, &pthis->frontLeftFootPos); + func_800355B8(globalCtx, &pthis->frontRightFootPos); + func_800355B8(globalCtx, &pthis->backRightFootPos); + func_800355B8(globalCtx, &pthis->backLeftFootPos); + } + } + } +} + +void EnTite_SetupRecoil(EnTite* pthis) { + pthis->action = TEKTITE_RECOIL; + Animation_MorphToLoop(&pthis->skelAnime, &object_tite_Anim_0012E4, 4.0f); + pthis->actor.speedXZ = -6.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.gravity = -1.0f; + EnTite_SetupAction(pthis, EnTite_Recoil); +} + +/** + * After tektite hits or gets hit, recoils backwards and slides a bit upon landing + */ +void EnTite_Recoil(EnTite* pthis, GlobalContext* globalCtx) { + s16 angleToPlayer; + + // Snap to ground or water surface upon landing + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if (((pthis->actor.bgCheckFlags & 3) || (pthis->actor.params == TEKTITE_BLUE && (pthis->actor.bgCheckFlags & 0x20))) && + (pthis->actor.velocity.y <= 0.0f)) { + if ((pthis->actor.params != TEKTITE_BLUE) || !(pthis->actor.bgCheckFlags & 0x20)) { + if (pthis->actor.floorHeight > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } + } else { + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.world.pos.y += pthis->actor.yDistToWater; + } + } + + // play sound and generate ripples + if (pthis->actor.bgCheckFlags & 0x42) { + if (!(pthis->actor.bgCheckFlags & 0x40)) { + func_80033480(globalCtx, &pthis->frontLeftFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->frontRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backLeftFootPos, 1.0f, 2, 80, 15, 1); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } else { + pthis->actor.bgCheckFlags &= ~0x40; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_LAND_WATER2); + } + } + + // If player is far away, idle. Otherwise attack or move + angleToPlayer = (pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y); + if ((pthis->actor.speedXZ == 0.0f) && ((pthis->actor.bgCheckFlags & 1) || ((pthis->actor.params == TEKTITE_BLUE) && + (pthis->actor.bgCheckFlags & 0x20)))) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->collider.base.atFlags &= ~AT_HIT; + if ((pthis->actor.xzDistToPlayer > 300.0f) && (pthis->actor.yDistToPlayer > 80.0f) && + (ABS(pthis->actor.shape.rot.x) < 4000) && (ABS(pthis->actor.shape.rot.z) < 4000) && + ((pthis->actor.bgCheckFlags & 1) || + ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)))) { + EnTite_SetupIdle(pthis); + } else if ((pthis->actor.xzDistToPlayer < 180.0f) && (pthis->actor.yDistToPlayer <= 80.0f) && + (ABS(angleToPlayer) <= 6000)) { + EnTite_SetupAttack(pthis); + } else { + EnTite_SetupMoveTowardPlayer(pthis); + } + } + SkelAnime_Update(&pthis->skelAnime); +} + +void EnTite_SetupStunned(EnTite* pthis) { + Animation_Change(&pthis->skelAnime, &object_tite_Anim_0012E4, 0.0f, 0.0f, + (f32)Animation_GetLastFrame(&object_tite_Anim_0012E4), ANIMMODE_LOOP, 4.0f); + pthis->action = TEKTITE_STUNNED; + pthis->actor.speedXZ = -6.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (pthis->damageEffect == 0xF) { + pthis->spawnIceTimer = 48; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + EnTite_SetupAction(pthis, EnTite_Stunned); +} + +/** + * stunned or frozen + */ +void EnTite_Stunned(EnTite* pthis, GlobalContext* globalCtx) { + s16 angleToPlayer; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + // Snap to ground or water + if (((pthis->actor.bgCheckFlags & 3) || + ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20))) && + (pthis->actor.velocity.y <= 0.0f)) { + if (((pthis->actor.params != TEKTITE_BLUE) || !(pthis->actor.bgCheckFlags & 0x20))) { + if (pthis->actor.floorHeight > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + } + } else { + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = 0.0f; + pthis->actor.world.pos.y += pthis->actor.yDistToWater; + } + } + // Play sounds and spawn dirt effects upon landing + if (pthis->actor.bgCheckFlags & 0x42) { + if (!(pthis->actor.bgCheckFlags & 0x40)) { + func_80033480(globalCtx, &pthis->frontLeftFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->frontRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backLeftFootPos, 1.0f, 2, 80, 15, 1); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } else { + pthis->actor.bgCheckFlags &= ~0x40; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_LAND_WATER2); + } + } + // Decide on next action based on health, flip state and player distance + angleToPlayer = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + if (((pthis->actor.colorFilterTimer == 0) && (pthis->actor.speedXZ == 0.0f)) && + ((pthis->actor.bgCheckFlags & 1) || + ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)))) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (pthis->actor.colChkInfo.health == 0) { + EnTite_SetupDeathCry(pthis); + } else if (pthis->flipState == TEKTITE_FLIPPED) { + EnTite_SetupFlipUpright(pthis); + } else if (((pthis->actor.xzDistToPlayer > 300.0f) && (pthis->actor.yDistToPlayer > 80.0f) && + (ABS(pthis->actor.shape.rot.x) < 4000) && (ABS(pthis->actor.shape.rot.z) < 4000)) && + ((pthis->actor.bgCheckFlags & 1) || + ((pthis->actor.params == TEKTITE_BLUE) && (pthis->actor.bgCheckFlags & 0x20)))) { + EnTite_SetupIdle(pthis); + } else if ((pthis->actor.xzDistToPlayer < 180.0f) && (pthis->actor.yDistToPlayer <= 80.0f) && + (ABS(angleToPlayer) <= 6000)) { + EnTite_SetupAttack(pthis); + } else { + EnTite_SetupMoveTowardPlayer(pthis); + } + } + SkelAnime_Update(&pthis->skelAnime); +} + +void EnTite_SetupDeathCry(EnTite* pthis) { + pthis->action = TEKTITE_DEATH_CRY; + pthis->actor.colorFilterTimer = 0; + pthis->actor.speedXZ = 0.0f; + EnTite_SetupAction(pthis, EnTite_DeathCry); +} + +/** + * First frame of death. Scream in pain and allocate memory for EnPart data + */ +void EnTite_DeathCry(EnTite* pthis, GlobalContext* globalCtx) { + EffectSsDeadSound_SpawnStationary(globalCtx, &pthis->actor.projectedPos, NA_SE_EN_TEKU_DEAD, true, + DEADSOUND_REPEAT_MODE_OFF, 40); + pthis->action = TEKTITE_FALL_APART; + EnTite_SetupAction(pthis, EnTite_FallApart); + BodyBreak_Alloc(&pthis->bodyBreak, 24, globalCtx); +} + +/** + * Spawn EnPart and drop items + */ +void EnTite_FallApart(EnTite* pthis, GlobalContext* globalCtx) { + if (BodyBreak_SpawnParts(&pthis->actor, &pthis->bodyBreak, globalCtx, pthis->actor.params + 0xB)) { + if (pthis->actor.params == TEKTITE_BLUE) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xE0); + } else { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x40); + } + Actor_Kill(&pthis->actor); + } +} + +void EnTite_SetupFlipOnBack(EnTite* pthis) { + + Animation_PlayLoopSetSpeed(&pthis->skelAnime, &object_tite_Anim_000A14, 1.5f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_REVERSE); + pthis->flipState = TEKTITE_FLIPPED; + pthis->vOnBackTimer = 500; + pthis->actor.speedXZ = 0.0f; + pthis->actor.gravity = -1.0f; + pthis->vLegTwitchTimer = (Rand_ZeroOne() * 50.0f); + pthis->actor.velocity.y = 11.0f; + EnTite_SetupAction(pthis, EnTite_FlipOnBack); +} + +/** + * During the flip animation and also while idling on back + */ +void EnTite_FlipOnBack(EnTite* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.z, 0x7FFF, 1, 4000, 0); + // randomly reset the leg wiggling animation whenever timer reaches 0 to give illusion of twitching legs + pthis->vLegTwitchTimer--; + if (pthis->vLegTwitchTimer == 0) { + pthis->vLegTwitchTimer = Rand_ZeroOne() * 30.0f; + pthis->skelAnime.curFrame = Rand_ZeroOne() * 5.0f; + } + SkelAnime_Update(&pthis->skelAnime); + if (pthis->actor.bgCheckFlags & 3) { + // Upon landing, spawn dust and make noise + if (pthis->actor.bgCheckFlags & 2) { + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 20.0f, 0xB, 4.0f, 0, 0, 0); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + pthis->vOnBackTimer--; + if (pthis->vOnBackTimer == 0) { + EnTite_SetupFlipUpright(pthis); + } + } else { + // Gradually increase y offset during flip so that the actor position is at tektite's back instead of feet + if (pthis->actor.shape.yOffset < 2800.0f) { + pthis->actor.shape.yOffset += 400.0f; + } + } +} + +void EnTite_SetupFlipUpright(EnTite* pthis) { + pthis->flipState = TEKTITE_UNFLIPPED; + pthis->actionVar1 = 1000; // value unused here and overwritten in SetupIdle + //! @bug flying tektite: water sets gravity to 0 so y velocity will never decrease from 13 + pthis->actor.velocity.y = 13.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TEKU_REVERSE); + EnTite_SetupAction(pthis, EnTite_FlipUpright); +} + +void EnTite_FlipUpright(EnTite* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.z, 0, 1, 0xFA0, 0); + SkelAnime_Update(&pthis->skelAnime); + //! @bug flying tektite: the following condition is never met and tektite stays stuck in pthis action forever + if (pthis->actor.bgCheckFlags & 2) { + func_80033480(globalCtx, &pthis->frontLeftFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->frontRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backRightFootPos, 1.0f, 2, 80, 15, 1); + func_80033480(globalCtx, &pthis->backLeftFootPos, 1.0f, 2, 80, 15, 1); + pthis->actor.shape.yOffset = 0.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + EnTite_SetupIdle(pthis); + } +} + +void EnTite_CheckDamage(Actor* thisx, GlobalContext* globalCtx) { + EnTite* pthis = (EnTite*)thisx; + + if ((pthis->collider.base.acFlags & AC_HIT) && (pthis->action >= TEKTITE_IDLE)) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (thisx->colChkInfo.damageEffect != 0xE) { // Immune to fire magic + pthis->damageEffect = thisx->colChkInfo.damageEffect; + Actor_SetDropFlag(thisx, &pthis->collider.elements[0].info, 0); + // Stun if Tektite hit by nut, boomerang, hookshot, ice arrow or ice magic + if ((thisx->colChkInfo.damageEffect == 1) || (thisx->colChkInfo.damageEffect == 0xF)) { + if (pthis->action != TEKTITE_STUNNED) { + Actor_SetColorFilter(thisx, 0, 0x78, 0, 0x50); + Actor_ApplyDamage(thisx); + EnTite_SetupStunned(pthis); + } + // Otherwise apply damage and handle death where necessary + } else { + if ((thisx->colorFilterTimer == 0) || ((thisx->colorFilterParams & 0x4000) == 0)) { + Actor_SetColorFilter(thisx, 0x4000, 0xFF, 0, 8); + Actor_ApplyDamage(thisx); + } + if (thisx->colChkInfo.health == 0) { + EnTite_SetupDeathCry(pthis); + } else { + // Flip tektite back up if it's on its back + Audio_PlayActorSound2(thisx, NA_SE_EN_TEKU_DAMAGE); + if (pthis->flipState != TEKTITE_FLIPPED) { + EnTite_SetupRecoil(pthis); + } else { + EnTite_SetupFlipUpright(pthis); + } + } + } + } + // If hammer has recently hit the floor and player is close to tektite, flip over + } else if ((thisx->colChkInfo.health != 0) && (globalCtx->actorCtx.unk_02 != 0) && + (thisx->xzDistToPlayer <= 400.0f) && (thisx->bgCheckFlags & 1)) { + if (pthis->flipState == TEKTITE_FLIPPED) { + EnTite_SetupFlipUpright(pthis); + } else if ((pthis->action >= TEKTITE_IDLE) || (pthis->action >= TEKTITE_IDLE)) { + if (1) {} + EnTite_SetupFlipOnBack(pthis); + } + } +} + +void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTite* pthis = (EnTite*)thisx; + char pad[0x4]; + CollisionPoly* floorPoly; + WaterBox* waterBox; + f32 waterSurfaceY; + + EnTite_CheckDamage(thisx, globalCtx); + // Stay still if hit by immunity damage type pthis frame + if (thisx->colChkInfo.damageEffect != 0xE) { + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 40.0f, 20.0f, pthis->unk_2DC); + // If on water, snap feet to surface and spawn ripples + if ((pthis->actor.params == TEKTITE_BLUE) && (thisx->bgCheckFlags & 0x20)) { + floorPoly = thisx->floorPoly; + if ((((globalCtx->gameplayFrames % 8) == 0) || (thisx->velocity.y < 0.0f)) && + (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->backRightFootPos.x, + pthis->backRightFootPos.z, &waterSurfaceY, &waterBox)) && + (pthis->backRightFootPos.y <= waterSurfaceY)) { + pthis->backRightFootPos.y = waterSurfaceY; + EffectSsGRipple_Spawn(globalCtx, &pthis->backRightFootPos, 0, 220, 0); + } + if (((((globalCtx->gameplayFrames + 2) % 8) == 0) || (thisx->velocity.y < 0.0f)) && + (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->backLeftFootPos.x, + pthis->backLeftFootPos.z, &waterSurfaceY, &waterBox)) && + (pthis->backLeftFootPos.y <= waterSurfaceY)) { + pthis->backLeftFootPos.y = waterSurfaceY; + EffectSsGRipple_Spawn(globalCtx, &pthis->backLeftFootPos, 0, 220, 0); + } + if (((((globalCtx->gameplayFrames + 4) % 8) == 0) || (thisx->velocity.y < 0.0f)) && + (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->frontLeftFootPos.x, + pthis->frontLeftFootPos.z, &waterSurfaceY, &waterBox)) && + (pthis->frontLeftFootPos.y <= waterSurfaceY)) { + pthis->frontLeftFootPos.y = waterSurfaceY; + EffectSsGRipple_Spawn(globalCtx, &pthis->frontLeftFootPos, 0, 220, 0); + } + if (((((globalCtx->gameplayFrames + 1) % 8) == 0) || (thisx->velocity.y < 0.0f)) && + (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->frontRightFootPos.x, + pthis->frontRightFootPos.z, &waterSurfaceY, &waterBox)) && + (pthis->frontRightFootPos.y <= waterSurfaceY)) { + pthis->frontRightFootPos.y = waterSurfaceY; + EffectSsGRipple_Spawn(globalCtx, &pthis->frontRightFootPos, 0, 220, 0); + } + thisx->floorPoly = floorPoly; + } + + // If on ground and currently flipped over, set tektite to be fully upside-down + if (thisx->bgCheckFlags & 3) { + func_800359B8(thisx, thisx->shape.rot.y, &thisx->shape.rot); + if (pthis->flipState >= TEKTITE_FLIPPED) { + thisx->shape.rot.z += 0x7FFF; + } + // Otherwise ensure the tektite is rotating back upright + } else { + Math_SmoothStepToS(&thisx->shape.rot.x, 0, 1, 1000, 0); + if (pthis->flipState <= TEKTITE_UNFLIPPED) { + Math_SmoothStepToS(&thisx->shape.rot.z, 0, 1, 1000, 0); + if (thisx->shape.yOffset > 0) { + thisx->shape.yOffset -= 400.0f; + } + } + } + } + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 20.0f; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** limbDList, Vec3s* rot, void* thisx) { + EnTite* pthis = (EnTite*)thisx; + + switch (limbIndex) { + case 8: + Matrix_MultVec3f(&sFootOffset, &pthis->backRightFootPos); + break; + case 13: + Matrix_MultVec3f(&sFootOffset, &pthis->frontRightFootPos); + break; + case 18: + Matrix_MultVec3f(&sFootOffset, &pthis->backLeftFootPos); + break; + case 23: + Matrix_MultVec3f(&sFootOffset, &pthis->frontLeftFootPos); + break; + } + + BodyBreak_SetInfo(&pthis->bodyBreak, limbIndex, 0, 24, 24, limbDList, BODYBREAK_OBJECT_DEFAULT); +} + +void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTite* pthis = (EnTite*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tite.c", 1704); + func_80093D18(globalCtx->state.gfxCtx); + Collider_UpdateSpheres(0, &pthis->collider); + if (pthis->actor.params == TEKTITE_BLUE) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001300)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001700)); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001900)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001B00)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001F00)); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_002100)); + } + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, NULL, EnTite_PostLimbDraw, + thisx); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tite.c", 1735); + + if (pthis->spawnIceTimer != 0) { + // Spawn chunks of ice all over the tektite's body + thisx->colorFilterTimer++; + pthis->spawnIceTimer--; + if ((pthis->spawnIceTimer & 3) == 0) { + Vec3f iceChunk; + s32 idx = pthis->spawnIceTimer >> 2; + + iceChunk.x = thisx->world.pos.x + sIceChunks[idx].x; + iceChunk.y = thisx->world.pos.y + sIceChunks[idx].y; + iceChunk.z = thisx->world.pos.z + sIceChunks[idx].z; + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &iceChunk, 150, 150, 150, 250, 235, 245, 255, 1.0f); + } + } +} diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.cpp similarity index 55% rename from src/overlays/actors/ovl_En_Tk/z_en_tk.c rename to src/overlays/actors/ovl_En_Tk/z_en_tk.cpp index f7339b6cf..8a49771f9 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.cpp @@ -31,12 +31,12 @@ void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTk_Update(Actor* thisx, GlobalContext* globalCtx); void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 EnTk_CheckNextSpot(EnTk* this, GlobalContext* globalCtx); -void EnTk_Rest(EnTk* this, GlobalContext* globalCtx); -void EnTk_Walk(EnTk* this, GlobalContext* globalCtx); -void EnTk_Dig(EnTk* this, GlobalContext* globalCtx); +s32 EnTk_CheckNextSpot(EnTk* pthis, GlobalContext* globalCtx); +void EnTk_Rest(EnTk* pthis, GlobalContext* globalCtx); +void EnTk_Walk(EnTk* pthis, GlobalContext* globalCtx); +void EnTk_Dig(EnTk* pthis, GlobalContext* globalCtx); -const ActorInit En_Tk_InitVars = { +ActorInit En_Tk_InitVars = { ACTOR_EN_TK, ACTORCAT_NPC, FLAGS, @@ -48,11 +48,11 @@ const ActorInit En_Tk_InitVars = { (ActorFunc)EnTk_Draw, }; -void EnTkEff_Create(EnTk* this, Vec3f* pos, Vec3f* speed, Vec3f* accel, u8 duration, f32 size, f32 growth) { +void EnTkEff_Create(EnTk* pthis, Vec3f* pos, Vec3f* speed, Vec3f* accel, u8 duration, f32 size, f32 growth) { s16 i; - EnTkEff* eff = this->eff; + EnTkEff* eff = pthis->eff; - for (i = 0; i < ARRAY_COUNT(this->eff); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->eff); i++) { if (eff->active != 1) { eff->size = size; eff->growth = growth; @@ -67,12 +67,12 @@ void EnTkEff_Create(EnTk* this, Vec3f* pos, Vec3f* speed, Vec3f* accel, u8 durat } } -void EnTkEff_Update(EnTk* this) { +void EnTkEff_Update(EnTk* pthis) { s16 i; EnTkEff* eff; - eff = this->eff; - for (i = 0; i < ARRAY_COUNT(this->eff); i++) { + eff = pthis->eff; + for (i = 0; i < ARRAY_COUNT(pthis->eff); i++) { if (eff->active != 0) { eff->timeLeft--; if (eff->timeLeft == 0) { @@ -92,12 +92,12 @@ void EnTkEff_Update(EnTk* this) { } } -void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) { +void EnTkEff_Draw(EnTk* pthis, GlobalContext* globalCtx) { static void* dustTextures[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; - EnTkEff* eff = this->eff; + EnTkEff* eff = pthis->eff; s16 imageIdx; s16 gfxSetup; s16 alpha; @@ -111,7 +111,7 @@ void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) { if (1) {} - for (i = 0; i < ARRAY_COUNT(this->eff); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->eff); i++) { if (eff->active != 0) { if (gfxSetup == 0) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); @@ -141,13 +141,13 @@ void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tk_eff.c", 154); } -s32 EnTkEff_CreateDflt(EnTk* this, Vec3f* pos, u8 duration, f32 size, f32 growth, f32 yAccelMax) { +s32 EnTkEff_CreateDflt(EnTk* pthis, Vec3f* pos, u8 duration, f32 size, f32 growth, f32 yAccelMax) { Vec3f speed = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.3f, 0.0f }; accel.y += Rand_ZeroOne() * yAccelMax; - EnTkEff_Create(this, pos, &speed, &accel, duration, size, growth); + EnTkEff_Create(pthis, pos, &speed, &accel, duration, size, growth); return 0; } @@ -176,65 +176,65 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -void EnTk_RestAnim(EnTk* this, GlobalContext* globalCtx) { +void EnTk_RestAnim(EnTk* pthis, GlobalContext* globalCtx) { AnimationHeader* anim = &gDampeRestAnim; - Animation_Change(&this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeRestAnim), ANIMMODE_LOOP, + Animation_Change(&pthis->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeRestAnim), ANIMMODE_LOOP, -10.0f); - this->actionCountdown = Rand_S16Offset(60, 60); - this->actor.speedXZ = 0.0f; + pthis->actionCountdown = Rand_S16Offset(60, 60); + pthis->actor.speedXZ = 0.0f; } -void EnTk_WalkAnim(EnTk* this, GlobalContext* globalCtx) { +void EnTk_WalkAnim(EnTk* pthis, GlobalContext* globalCtx) { AnimationHeader* anim = &gDampeWalkAnim; - Animation_Change(&this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeRestAnim), ANIMMODE_LOOP, + Animation_Change(&pthis->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeRestAnim), ANIMMODE_LOOP, -10.0f); - this->actionCountdown = Rand_S16Offset(240, 240); + pthis->actionCountdown = Rand_S16Offset(240, 240); } -void EnTk_DigAnim(EnTk* this, GlobalContext* globalCtx) { +void EnTk_DigAnim(EnTk* pthis, GlobalContext* globalCtx) { AnimationHeader* anim = &gDampeDigAnim; - Animation_Change(&this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeDigAnim), ANIMMODE_LOOP, -10.0f); + Animation_Change(&pthis->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeDigAnim), ANIMMODE_LOOP, -10.0f); - if (EnTk_CheckNextSpot(this, globalCtx) >= 0) { - this->validDigHere = 1; + if (EnTk_CheckNextSpot(pthis, globalCtx) >= 0) { + pthis->validDigHere = 1; } } -void EnTk_UpdateEyes(EnTk* this) { - if (DECR(this->blinkCountdown) == 0) { - this->eyeTextureIdx++; - if (this->eyeTextureIdx > 2) { - this->blinkCycles--; - if (this->blinkCycles < 0) { - this->blinkCountdown = Rand_S16Offset(30, 30); - this->blinkCycles = 2; +void EnTk_UpdateEyes(EnTk* pthis) { + if (DECR(pthis->blinkCountdown) == 0) { + pthis->eyeTextureIdx++; + if (pthis->eyeTextureIdx > 2) { + pthis->blinkCycles--; + if (pthis->blinkCycles < 0) { + pthis->blinkCountdown = Rand_S16Offset(30, 30); + pthis->blinkCycles = 2; if (Rand_ZeroOne() > 0.5f) { - this->blinkCycles++; + pthis->blinkCycles++; } } - this->eyeTextureIdx = 0; + pthis->eyeTextureIdx = 0; } } } -s32 EnTk_CheckFacingPlayer(EnTk* this) { +s32 EnTk_CheckFacingPlayer(EnTk* pthis) { s16 v0; s16 v1; - if (this->actor.xyzDistToPlayerSq > 10000.0f) { + if (pthis->actor.xyzDistToPlayerSq > 10000.0f) { return 0; } - v0 = this->actor.shape.rot.y; - v0 -= this->h_21E; - v0 -= this->headRot; + v0 = pthis->actor.shape.rot.y; + v0 -= pthis->h_21E; + v0 -= pthis->headRot; - v1 = this->actor.yawTowardsPlayer - v0; + v1 = pthis->actor.yawTowardsPlayer - v0; if (ABS(v1) < 0x1554) { return 1; } else { @@ -242,7 +242,7 @@ s32 EnTk_CheckFacingPlayer(EnTk* this) { } } -s32 EnTk_CheckNextSpot(EnTk* this, GlobalContext* globalCtx) { +s32 EnTk_CheckNextSpot(EnTk* pthis, GlobalContext* globalCtx) { Actor* prop; f32 dxz; f32 dy; @@ -255,52 +255,52 @@ s32 EnTk_CheckNextSpot(EnTk* this, GlobalContext* globalCtx) { continue; } - if (prop == this->currentSpot) { + if (prop == pthis->currentSpot) { prop = prop->next; continue; } - dy = prop->world.pos.y - this->actor.floorHeight; - dxz = Actor_WorldDistXZToActor(&this->actor, prop); + dy = prop->world.pos.y - pthis->actor.floorHeight; + dxz = Actor_WorldDistXZToActor(&pthis->actor, prop); if (dxz > 40.0f || dy > 10.0f) { prop = prop->next; continue; } - this->currentSpot = prop; + pthis->currentSpot = prop; return prop->params; } return -1; } -void EnTk_CheckCurrentSpot(EnTk* this) { +void EnTk_CheckCurrentSpot(EnTk* pthis) { f32 dxz; f32 dy; - if (this->currentSpot != NULL) { - dy = this->currentSpot->world.pos.y - this->actor.floorHeight; - dxz = Actor_WorldDistXZToActor(&this->actor, this->currentSpot); + if (pthis->currentSpot != NULL) { + dy = pthis->currentSpot->world.pos.y - pthis->actor.floorHeight; + dxz = Actor_WorldDistXZToActor(&pthis->actor, pthis->currentSpot); if (dxz > 40.0f || dy > 10.0f) { - this->currentSpot = NULL; + pthis->currentSpot = NULL; } } } -f32 EnTk_Step(EnTk* this, GlobalContext* globalCtx) { +f32 EnTk_Step(EnTk* pthis, GlobalContext* globalCtx) { f32 stepFrames[] = { 36.0f, 10.0f }; f32 a1_; s32 i; - if (this->skelAnime.curFrame == 0.0f || this->skelAnime.curFrame == 25.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK); + if (pthis->skelAnime.curFrame == 0.0f || pthis->skelAnime.curFrame == 25.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_MORIBLIN_WALK); } - if (this->skelAnime.animation != &gDampeWalkAnim) { + if (pthis->skelAnime.animation != &gDampeWalkAnim) { return 0.0f; } - a1_ = this->skelAnime.curFrame; + a1_ = pthis->skelAnime.curFrame; for (i = 0; i < ARRAY_COUNT(stepFrames); i++) { if (a1_ < stepFrames[i] + 12.0f && a1_ >= stepFrames[i]) { break; @@ -314,30 +314,30 @@ f32 EnTk_Step(EnTk* this, GlobalContext* globalCtx) { } } -s32 EnTk_Orient(EnTk* this, GlobalContext* globalCtx) { +s32 EnTk_Orient(EnTk* pthis, GlobalContext* globalCtx) { Path* path; Vec3s* point; f32 dx; f32 dz; - if (this->actor.params < 0) { + if (pthis->actor.params < 0) { return 1; } path = &globalCtx->setupPathList[0]; point = SEGMENTED_TO_VIRTUAL(path->points); - point += this->currentWaypoint; + point += pthis->currentWaypoint; - dx = point->x - this->actor.world.pos.x; - dz = point->z - this->actor.world.pos.z; + dx = point->x - pthis->actor.world.pos.x; + dz = point->z - pthis->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 10, 1000, 1); - this->actor.world.rot = this->actor.shape.rot; + Math_SmoothStepToS(&pthis->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 10, 1000, 1); + pthis->actor.world.rot = pthis->actor.shape.rot; if (SQ(dx) + SQ(dz) < 10.0f) { - this->currentWaypoint++; - if (this->currentWaypoint >= path->count) { - this->currentWaypoint = 0; + pthis->currentWaypoint++; + if (pthis->currentWaypoint >= path->count) { + pthis->currentWaypoint = 0; } return 0; @@ -413,7 +413,7 @@ s16 func_80B1C5A0(GlobalContext* globalCtx, Actor* thisx) { return ret; } -s32 EnTk_ChooseReward(EnTk* this) { +s32 EnTk_ChooseReward(EnTk* pthis) { f32 luck; s32 reward; @@ -431,261 +431,261 @@ s32 EnTk_ChooseReward(EnTk* this) { switch (reward) { case 0: - if (this->rewardCount[0] < 8) { - this->rewardCount[0] += 1; + if (pthis->rewardCount[0] < 8) { + pthis->rewardCount[0] += 1; return reward; } break; case 1: - if (this->rewardCount[1] < 4) { - this->rewardCount[1] += 1; + if (pthis->rewardCount[1] < 4) { + pthis->rewardCount[1] += 1; return reward; } break; case 2: - if (this->rewardCount[2] < 2) { - this->rewardCount[2] += 1; + if (pthis->rewardCount[2] < 2) { + pthis->rewardCount[2] += 1; return reward; } break; case 3: - if (this->rewardCount[3] < 1) { - this->rewardCount[3] += 1; + if (pthis->rewardCount[3] < 1) { + pthis->rewardCount[3] += 1; return reward; } break; } - if (this->rewardCount[0] < 8) { - this->rewardCount[0] += 1; + if (pthis->rewardCount[0] < 8) { + pthis->rewardCount[0] += 1; reward = 0; - } else if (this->rewardCount[1] < 4) { - this->rewardCount[1] += 1; + } else if (pthis->rewardCount[1] < 4) { + pthis->rewardCount[1] += 1; reward = 1; - } else if (this->rewardCount[2] < 2) { - this->rewardCount[2] += 1; + } else if (pthis->rewardCount[2] < 2) { + pthis->rewardCount[2] += 1; reward = 2; - } else if (this->rewardCount[3] < 1) { - this->rewardCount[3] += 1; + } else if (pthis->rewardCount[3] < 1) { + pthis->rewardCount[3] += 1; reward = 3; } else { reward = 0; - this->rewardCount[0] = 1; - this->rewardCount[1] = 0; - this->rewardCount[2] = 0; - this->rewardCount[3] = 0; + pthis->rewardCount[0] = 1; + pthis->rewardCount[1] = 0; + pthis->rewardCount[2] = 0; + pthis->rewardCount[3] = 0; } return reward; } -void EnTk_DigEff(EnTk* this) { +void EnTk_DigEff(EnTk* pthis) { Vec3f pos = { 0.0f, 0.0f, 0.0f }; Vec3f speed = { 0.0f, 0.0f, 0.0f }; Vec3f accel = { 0.0f, 0.3f, 0.0f }; - if (this->skelAnime.curFrame >= 32.0f && this->skelAnime.curFrame < 40.0f) { - pos.x = (Rand_ZeroOne() - 0.5f) * 12.0f + this->v3f_304.x; - pos.y = (Rand_ZeroOne() - 0.5f) * 8.0f + this->v3f_304.y; - pos.z = (Rand_ZeroOne() - 0.5f) * 12.0f + this->v3f_304.z; - EnTkEff_CreateDflt(this, &pos, 12, 0.2f, 0.1f, 0.0f); + if (pthis->skelAnime.curFrame >= 32.0f && pthis->skelAnime.curFrame < 40.0f) { + pos.x = (Rand_ZeroOne() - 0.5f) * 12.0f + pthis->v3f_304.x; + pos.y = (Rand_ZeroOne() - 0.5f) * 8.0f + pthis->v3f_304.y; + pos.z = (Rand_ZeroOne() - 0.5f) * 12.0f + pthis->v3f_304.z; + EnTkEff_CreateDflt(pthis, &pos, 12, 0.2f, 0.1f, 0.0f); } } void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTk* this = (EnTk*)thisx; + EnTk* pthis = (EnTk*)thisx; s32 pad; - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); + ActorShape_Init(&pthis->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDampeSkel, NULL, this->jointTable, this->morphTable, 18); - Animation_Change(&this->skelAnime, &gDampeRestAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeRestAnim), + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gDampeSkel, NULL, pthis->jointTable, pthis->morphTable, 18); + Animation_Change(&pthis->skelAnime, &gDampeRestAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gDampeRestAnim), ANIMMODE_LOOP, 0.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); if (gSaveContext.dayTime <= 0xC000 || gSaveContext.dayTime >= 0xE000 || !!LINK_IS_ADULT || globalCtx->sceneNum != SCENE_SPOT02) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - Actor_SetScale(&this->actor, 0.01f); + Actor_SetScale(&pthis->actor, 0.01f); - this->actor.targetMode = 6; - this->actor.gravity = -0.1f; - this->currentReward = -1; - this->currentSpot = NULL; - this->actionFunc = EnTk_Rest; + pthis->actor.targetMode = 6; + pthis->actor.gravity = -0.1f; + pthis->currentReward = -1; + pthis->currentSpot = NULL; + pthis->actionFunc = EnTk_Rest; } void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTk* this = (EnTk*)thisx; + EnTk* pthis = (EnTk*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void EnTk_Rest(EnTk* this, GlobalContext* globalCtx) { +void EnTk_Rest(EnTk* pthis, GlobalContext* globalCtx) { s16 v1; s16 a1_; - if (this->h_1E0 != 0) { - v1 = this->actor.shape.rot.y; - v1 -= this->h_21E; - v1 = this->actor.yawTowardsPlayer - v1; + if (pthis->h_1E0 != 0) { + v1 = pthis->actor.shape.rot.y; + v1 -= pthis->h_21E; + v1 = pthis->actor.yawTowardsPlayer - v1; - if (this->h_1E0 == 2) { - EnTk_DigAnim(this, globalCtx); - this->h_1E0 = 0; - this->actionFunc = EnTk_Dig; + if (pthis->h_1E0 == 2) { + EnTk_DigAnim(pthis, globalCtx); + pthis->h_1E0 = 0; + pthis->actionFunc = EnTk_Dig; return; } - func_800343CC(globalCtx, &this->actor, &this->h_1E0, this->collider.dim.radius + 30.0f, func_80B1C54C, + func_800343CC(globalCtx, &pthis->actor, &pthis->h_1E0, pthis->collider.dim.radius + 30.0f, func_80B1C54C, func_80B1C5A0); - } else if (EnTk_CheckFacingPlayer(this)) { - v1 = this->actor.shape.rot.y; - v1 -= this->h_21E; - v1 = this->actor.yawTowardsPlayer - v1; + } else if (EnTk_CheckFacingPlayer(pthis)) { + v1 = pthis->actor.shape.rot.y; + v1 -= pthis->h_21E; + v1 = pthis->actor.yawTowardsPlayer - v1; - this->actionCountdown = 0; - func_800343CC(globalCtx, &this->actor, &this->h_1E0, this->collider.dim.radius + 30.0f, func_80B1C54C, + pthis->actionCountdown = 0; + func_800343CC(globalCtx, &pthis->actor, &pthis->h_1E0, pthis->collider.dim.radius + 30.0f, func_80B1C54C, func_80B1C5A0); - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - v1 = this->actor.shape.rot.y; - v1 -= this->h_21E; - v1 = this->actor.yawTowardsPlayer - v1; + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + v1 = pthis->actor.shape.rot.y; + v1 -= pthis->h_21E; + v1 = pthis->actor.yawTowardsPlayer - v1; - this->actionCountdown = 0; - this->h_1E0 = 1; - } else if (DECR(this->actionCountdown) == 0) { - EnTk_WalkAnim(this, globalCtx); - this->actionFunc = EnTk_Walk; + pthis->actionCountdown = 0; + pthis->h_1E0 = 1; + } else if (DECR(pthis->actionCountdown) == 0) { + EnTk_WalkAnim(pthis, globalCtx); + pthis->actionFunc = EnTk_Walk; - /*! @bug v1 is uninitialized past this branch */ + /*! @bug v1 is uninitialized past pthis branch */ v1 = 0; } else { v1 = 0; } a1_ = CLAMP(-v1, 1270, 10730); - Math_SmoothStepToS(&this->headRot, a1_, 6, 1000, 1); + Math_SmoothStepToS(&pthis->headRot, a1_, 6, 1000, 1); } -void EnTk_Walk(EnTk* this, GlobalContext* globalCtx) { - if (this->h_1E0 == 2) { - EnTk_DigAnim(this, globalCtx); - this->h_1E0 = 0; - this->actionFunc = EnTk_Dig; +void EnTk_Walk(EnTk* pthis, GlobalContext* globalCtx) { + if (pthis->h_1E0 == 2) { + EnTk_DigAnim(pthis, globalCtx); + pthis->h_1E0 = 0; + pthis->actionFunc = EnTk_Dig; } else { - this->actor.speedXZ = EnTk_Step(this, globalCtx); - EnTk_Orient(this, globalCtx); - Math_SmoothStepToS(&this->headRot, 0, 6, 1000, 1); - EnTk_CheckCurrentSpot(this); + pthis->actor.speedXZ = EnTk_Step(pthis, globalCtx); + EnTk_Orient(pthis, globalCtx); + Math_SmoothStepToS(&pthis->headRot, 0, 6, 1000, 1); + EnTk_CheckCurrentSpot(pthis); - DECR(this->actionCountdown); - if (EnTk_CheckFacingPlayer(this) || this->actionCountdown == 0) { - EnTk_RestAnim(this, globalCtx); - this->actionFunc = EnTk_Rest; + DECR(pthis->actionCountdown); + if (EnTk_CheckFacingPlayer(pthis) || pthis->actionCountdown == 0) { + EnTk_RestAnim(pthis, globalCtx); + pthis->actionFunc = EnTk_Rest; } } } -void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) { +void EnTk_Dig(EnTk* pthis, GlobalContext* globalCtx) { Vec3f rewardOrigin; Vec3f rewardPos; s32 rewardParams[] = { ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE, ITEM00_HEART_PIECE, }; - EnTk_DigEff(this); + EnTk_DigEff(pthis); - if (this->skelAnime.curFrame == 32.0f) { + if (pthis->skelAnime.curFrame == 32.0f) { /* What's gonna come out? */ - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIG_UP); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_DIG_UP); - this->rewardTimer = 0; + pthis->rewardTimer = 0; - if (this->validDigHere == 1) { + if (pthis->validDigHere == 1) { rewardOrigin.x = 0.0f; rewardOrigin.y = 0.0f; rewardOrigin.z = -40.0f; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateY(pthis->actor.shape.rot.y, MTXMODE_NEW); Matrix_MultVec3f(&rewardOrigin, &rewardPos); - rewardPos.x += this->actor.world.pos.x; - rewardPos.y += this->actor.world.pos.y; - rewardPos.z += this->actor.world.pos.z; + rewardPos.x += pthis->actor.world.pos.x; + rewardPos.y += pthis->actor.world.pos.y; + rewardPos.z += pthis->actor.world.pos.z; - this->currentReward = EnTk_ChooseReward(this); - if (this->currentReward == 3) { + pthis->currentReward = EnTk_ChooseReward(pthis); + if (pthis->currentReward == 3) { /* * Upgrade the purple rupee reward to the heart piece if this * is the first grand prize dig. */ if (!(gSaveContext.itemGetInf[1] & 0x1000)) { gSaveContext.itemGetInf[1] |= 0x1000; - this->currentReward = 4; + pthis->currentReward = 4; } } - Item_DropCollectible(globalCtx, &rewardPos, rewardParams[this->currentReward]); + Item_DropCollectible(globalCtx, &rewardPos, rewardParams[pthis->currentReward]); } } - if (this->skelAnime.curFrame >= 32.0f && this->rewardTimer == 10) { + if (pthis->skelAnime.curFrame >= 32.0f && pthis->rewardTimer == 10) { /* Play a reward sound shortly after digging */ - if (this->validDigHere == 0) { + if (pthis->validDigHere == 0) { /* Bad dig spot */ - Audio_PlayActorSound2(&this->actor, NA_SE_SY_ERROR); - } else if (this->currentReward == 4) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_SY_ERROR); + } else if (pthis->currentReward == 4) { /* Heart piece */ Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { /* Rupee */ - Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Audio_PlayActorSound2(&pthis->actor, NA_SE_SY_TRE_BOX_APPEAR); } } - this->rewardTimer++; + pthis->rewardTimer++; - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->currentReward < 0) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + if (pthis->currentReward < 0) { /* "Nope, nothing here!" */ Message_StartTextbox(globalCtx, 0x501A, NULL); } else { Message_CloseTextbox(globalCtx); } - EnTk_RestAnim(this, globalCtx); + EnTk_RestAnim(pthis, globalCtx); - this->currentReward = -1; - this->validDigHere = 0; - this->actionFunc = EnTk_Rest; + pthis->currentReward = -1; + pthis->validDigHere = 0; + pthis->actionFunc = EnTk_Rest; } } void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTk* this = (EnTk*)thisx; + EnTk* pthis = (EnTk*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); - Actor_MoveForward(&this->actor); + Actor_MoveForward(&pthis->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 40.0f, 10.0f, 0.0f, 5); - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - EnTkEff_Update(this); + EnTkEff_Update(pthis); - EnTk_UpdateEyes(this); + EnTk_UpdateEyes(pthis); } void func_80B1D200(GlobalContext* globalCtx) { @@ -697,17 +697,17 @@ void func_80B1D200(GlobalContext* globalCtx) { } s32 EnTk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnTk* this = (EnTk*)thisx; + EnTk* pthis = (EnTk*)thisx; switch (limbIndex) { /* Limb 15 - Head */ case 15: - this->h_21E = rot->y; + pthis->h_21E = rot->y; break; /* Limb 16 - Jaw */ case 16: - this->h_21E += rot->y; - rot->y += this->headRot; + pthis->h_21E += rot->y; + rot->y += pthis->headRot; break; } @@ -715,18 +715,18 @@ s32 EnTk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnTk* this = (EnTk*)thisx; + EnTk* pthis = (EnTk*)thisx; Vec3f sp28 = { 0.0f, 0.0f, 4600.0f }; Vec3f sp1C = { 0.0f, 0.0f, 0.0f }; /* Limb 16 - Jaw */ if (limbIndex == 16) { - Matrix_MultVec3f(&sp1C, &this->actor.focus.pos); + Matrix_MultVec3f(&sp1C, &pthis->actor.focus.pos); } /* Limb 14 - Neck */ if (limbIndex == 14) { - Matrix_MultVec3f(&sp28, &this->v3f_304); + Matrix_MultVec3f(&sp28, &pthis->v3f_304); func_80B1D200(globalCtx); } } @@ -737,20 +737,20 @@ void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { gDampeEyeHalfTex, gDampeEyeClosedTex, }; - EnTk* this = (EnTk*)thisx; + EnTk* pthis = (EnTk*)thisx; Matrix_Push(); - EnTkEff_Draw(this, globalCtx); + EnTkEff_Draw(pthis, globalCtx); Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tk.c", 1294); func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyesSegments[this->eyeTextureIdx])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyesSegments[pthis->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnTk_OverrideLimbDraw, EnTk_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnTk_OverrideLimbDraw, EnTk_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tk.c", 1312); } diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.cpp similarity index 78% rename from src/overlays/actors/ovl_En_Torch/z_en_torch.c rename to src/overlays/actors/ovl_En_Torch/z_en_torch.cpp index 6d7ef3063..bed4e54b6 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.cpp @@ -14,7 +14,7 @@ void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Torch_InitVars = { +ActorInit En_Torch_InitVars = { ACTOR_EN_TORCH, ACTORCAT_ITEMACTION, FLAGS, @@ -31,14 +31,14 @@ static u8 sChestContents[] = { }; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTorch* this = (EnTorch*)thisx; + EnTorch* pthis = (EnTorch*)thisx; s8 returnData = gSaveContext.respawn[RESPAWN_MODE_RETURN].data; /* Spawn chest with desired contents. Contents are passed to en_torch from grotto params via Save Context. */ - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, pthis->actor.shape.rot.y, 0, (sChestContents[(returnData >> 0x5) & 0x7] << 0x5) | 0x5000 | (returnData & 0x1F)); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.cpp similarity index 60% rename from src/overlays/actors/ovl_En_Torch2/z_en_torch2.c rename to src/overlays/actors/ovl_En_Torch2/z_en_torch2.cpp index 9b1a8854a..b631d0c06 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.cpp @@ -67,7 +67,7 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx); void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Torch2_InitVars = { +ActorInit En_Torch2_InitVars = { ACTOR_EN_TORCH2, ACTORCAT_BOSS, FLAGS, @@ -137,28 +137,28 @@ static DamageTable sDamageTable = { void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - Player* this = (Player*)thisx; + Player* pthis = (Player*)thisx; sInput.cur.button = sInput.press.button = sInput.rel.button = 0; sInput.cur.stick_x = sInput.cur.stick_y = 0; - this->currentShield = PLAYER_SHIELD_HYLIAN; - this->heldItemActionParam = this->heldItemId = PLAYER_AP_SWORD_MASTER; - Player_SetModelGroup(this, 2); - globalCtx->playerInit(this, globalCtx, &gDarkLinkSkel); - this->actor.naviEnemyId = 0x26; - this->cylinder.base.acFlags = AC_ON | AC_TYPE_PLAYER; - this->swordQuads[0].base.atFlags = this->swordQuads[1].base.atFlags = AT_ON | AT_TYPE_ENEMY; - this->swordQuads[0].base.acFlags = this->swordQuads[1].base.acFlags = AC_ON | AC_HARD | AC_TYPE_PLAYER; - this->swordQuads[0].base.colType = this->swordQuads[1].base.colType = COLTYPE_METAL; - this->swordQuads[0].info.toucher.damage = this->swordQuads[1].info.toucher.damage = 8; - this->swordQuads[0].info.bumperFlags = this->swordQuads[1].info.bumperFlags = BUMP_ON; - this->shieldQuad.base.atFlags = AT_ON | AT_TYPE_ENEMY; - this->shieldQuad.base.acFlags = AC_ON | AC_HARD | AC_TYPE_PLAYER; - this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.health = gSaveContext.healthCapacity >> 3; - this->actor.colChkInfo.cylRadius = 60; - this->actor.colChkInfo.cylHeight = 100; - globalCtx->func_11D54(this, globalCtx); + pthis->currentShield = PLAYER_SHIELD_HYLIAN; + pthis->heldItemActionParam = pthis->heldItemId = PLAYER_AP_SWORD_MASTER; + Player_SetModelGroup(pthis, 2); + globalCtx->playerInit(pthis, globalCtx, &gDarkLinkSkel); + pthis->actor.naviEnemyId = 0x26; + pthis->cylinder.base.acFlags = AC_ON | AC_TYPE_PLAYER; + pthis->swordQuads[0].base.atFlags = pthis->swordQuads[1].base.atFlags = AT_ON | AT_TYPE_ENEMY; + pthis->swordQuads[0].base.acFlags = pthis->swordQuads[1].base.acFlags = AC_ON | AC_HARD | AC_TYPE_PLAYER; + pthis->swordQuads[0].base.colType = pthis->swordQuads[1].base.colType = COLTYPE_METAL; + pthis->swordQuads[0].info.toucher.damage = pthis->swordQuads[1].info.toucher.damage = 8; + pthis->swordQuads[0].info.bumperFlags = pthis->swordQuads[1].info.bumperFlags = BUMP_ON; + pthis->shieldQuad.base.atFlags = AT_ON | AT_TYPE_ENEMY; + pthis->shieldQuad.base.acFlags = AC_ON | AC_HARD | AC_TYPE_PLAYER; + pthis->actor.colChkInfo.damageTable = &sDamageTable; + pthis->actor.colChkInfo.health = gSaveContext.healthCapacity >> 3; + pthis->actor.colChkInfo.cylRadius = 60; + pthis->actor.colChkInfo.cylHeight = 100; + globalCtx->func_11D54(pthis, globalCtx); sActionState = ENTORCH2_WAIT; sDodgeRollState = 0; @@ -169,37 +169,37 @@ void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx2) { sCounterState = sStaggerTimer = sStaggerCount = 0; sLastSwordAnim = 0; sAlpha = 95; - sSpawnPoint = this->actor.home.pos; + sSpawnPoint = pthis->actor.home.pos; } void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - Player* this = (Player*)thisx; + Player* pthis = (Player*)thisx; - Effect_Delete(globalCtx, this->swordEffectIndex); + Effect_Delete(globalCtx, pthis->swordEffectIndex); func_800F5B58(); - Collider_DestroyCylinder(globalCtx, &this->cylinder); - Collider_DestroyQuad(globalCtx, &this->swordQuads[0]); - Collider_DestroyQuad(globalCtx, &this->swordQuads[1]); - Collider_DestroyQuad(globalCtx, &this->shieldQuad); + Collider_DestroyCylinder(globalCtx, &pthis->cylinder); + Collider_DestroyQuad(globalCtx, &pthis->swordQuads[0]); + Collider_DestroyQuad(globalCtx, &pthis->swordQuads[1]); + Collider_DestroyQuad(globalCtx, &pthis->shieldQuad); } -Actor* EnTorch2_GetAttackItem(GlobalContext* globalCtx, Player* this) { - Actor* rangedItem = Actor_GetProjectileActor(globalCtx, &this->actor, 4000.0f); +Actor* EnTorch2_GetAttackItem(GlobalContext* globalCtx, Player* pthis) { + Actor* rangedItem = Actor_GetProjectileActor(globalCtx, &pthis->actor, 4000.0f); if (rangedItem != NULL) { return rangedItem; } else { - return func_80033684(globalCtx, &this->actor); + return func_80033684(globalCtx, &pthis->actor); } } -s32 EnTorch2_SwingSword(GlobalContext* globalCtx, Input* input, Player* this) { +s32 EnTorch2_SwingSword(GlobalContext* globalCtx, Input* input, Player* pthis) { f32 noAttackChance = 0.0f; s32 attackDelay = 7; Player* player = GET_PLAYER(globalCtx); - if ((this->linearVelocity < 0.0f) || (player->linearVelocity < 0.0f)) { + if ((pthis->linearVelocity < 0.0f) || (player->linearVelocity < 0.0f)) { return 0; } if (gSaveContext.health < 0x50) { @@ -231,13 +231,13 @@ s32 EnTorch2_SwingSword(GlobalContext* globalCtx, Input* input, Player* this) { return 0; } -void EnTorch2_Backflip(Player* this, Input* input, Actor* thisx) { +void EnTorch2_Backflip(Player* pthis, Input* input, Actor* thisx) { thisx->world.rot.y = thisx->shape.rot.y = thisx->yawTowardsPlayer; sStickAngle = thisx->yawTowardsPlayer + 0x8000; sStickTilt = 127.0f; sZTargetFlag = true; input->cur.button = BTN_A; - this->invincibilityTimer = 10; + pthis->invincibilityTimer = 10; sCounterState = 0; } @@ -245,7 +245,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; Player* player2 = GET_PLAYER(globalCtx2); Player* player = player2; - Player* this = (Player*)thisx; + Player* pthis = (Player*)thisx; Input* input = &sInput; Camera* camera; s16 sp66; @@ -259,22 +259,22 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { f32 sp50; s16 sp4E; - sp5A = player->actor.shape.rot.y - this->actor.shape.rot.y; + sp5A = player->actor.shape.rot.y - pthis->actor.shape.rot.y; input->cur.button = 0; camera = Gameplay_GetCamera(globalCtx, 0); - attackItem = EnTorch2_GetAttackItem(globalCtx, this); + attackItem = EnTorch2_GetAttackItem(globalCtx, pthis); switch (sActionState) { case ENTORCH2_WAIT: - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->skelAnime.curFrame = 0.0f; - this->skelAnime.playSpeed = 0.0f; - this->actor.world.pos.x = (Math_SinS(this->actor.world.rot.y) * 25.0f) + sSpawnPoint.x; - this->actor.world.pos.z = (Math_CosS(this->actor.world.rot.y) * 25.0f) + sSpawnPoint.z; - if ((this->actor.xzDistToPlayer <= 120.0f) || Actor_IsTargeted(globalCtx, &this->actor) || + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->skelAnime.curFrame = 0.0f; + pthis->skelAnime.playSpeed = 0.0f; + pthis->actor.world.pos.x = (Math_SinS(pthis->actor.world.rot.y) * 25.0f) + sSpawnPoint.x; + pthis->actor.world.pos.z = (Math_CosS(pthis->actor.world.rot.y) * 25.0f) + sSpawnPoint.z; + if ((pthis->actor.xzDistToPlayer <= 120.0f) || Actor_IsTargeted(globalCtx, &pthis->actor) || (attackItem != NULL)) { if (attackItem != NULL) { sDodgeRollState = 1; - sStickAngle = this->actor.yawTowardsPlayer; + sStickAngle = pthis->actor.yawTowardsPlayer; sStickTilt = 127.0f; input->cur.button = BTN_A; sZTargetFlag = false; @@ -294,16 +294,16 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { // Handles Dark Link's sword clanking on Link's sword - if ((this->swordQuads[0].base.acFlags & AC_BOUNCED) || (this->swordQuads[1].base.acFlags & AC_BOUNCED)) { - this->swordQuads[0].base.acFlags &= ~AC_BOUNCED; - this->swordQuads[1].base.acFlags &= ~AC_BOUNCED; - this->swordQuads[0].base.atFlags |= AT_BOUNCED; - this->swordQuads[1].base.atFlags |= AT_BOUNCED; - this->cylinder.base.acFlags &= ~AC_HIT; + if ((pthis->swordQuads[0].base.acFlags & AC_BOUNCED) || (pthis->swordQuads[1].base.acFlags & AC_BOUNCED)) { + pthis->swordQuads[0].base.acFlags &= ~AC_BOUNCED; + pthis->swordQuads[1].base.acFlags &= ~AC_BOUNCED; + pthis->swordQuads[0].base.atFlags |= AT_BOUNCED; + pthis->swordQuads[1].base.atFlags |= AT_BOUNCED; + pthis->cylinder.base.acFlags &= ~AC_HIT; - if (sLastSwordAnim != this->swordAnimation) { + if (sLastSwordAnim != pthis->swordAnimation) { sStaggerCount++; - sLastSwordAnim = this->swordAnimation; + sLastSwordAnim = pthis->swordAnimation; } /*! @bug * This code is needed to reset sCounterState, and should run regardless @@ -317,15 +317,15 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { sStaggerTimer = 50; } } - if ((sCounterState != 0) && (this->swordState != 0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->swordQuads[0].base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->swordQuads[1].base); + if ((sCounterState != 0) && (pthis->swordState != 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->swordQuads[0].base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->swordQuads[1].base); } // Ignores hits when jumping on Link's sword - if ((this->invincibilityTimer < 0) && (sActionState != ENTORCH2_DAMAGE) && - (this->cylinder.base.acFlags & AC_HIT)) { - this->cylinder.base.acFlags &= ~AC_HIT; + if ((pthis->invincibilityTimer < 0) && (sActionState != ENTORCH2_DAMAGE) && + (pthis->cylinder.base.acFlags & AC_HIT)) { + pthis->cylinder.base.acFlags &= ~AC_HIT; } // Handles Dark Link rolling to dodge item attacks @@ -334,7 +334,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { sStickTilt = 127.0f; } else if (attackItem != NULL) { sDodgeRollState = 1; - sStickAngle = this->actor.yawTowardsPlayer; + sStickAngle = pthis->actor.yawTowardsPlayer; sStickTilt = 127.0f; input->cur.button = BTN_A; } else if (sJumpslashTimer == 0) { @@ -343,12 +343,12 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { if (((player->swordState != 0) || (player->actor.velocity.y > -3.0f)) && (player->swordAnimation == JUMPSLASH_START)) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; if (globalCtx->gameplayFrames % 2) { - sStickAngle = this->actor.yawTowardsPlayer + 0x4000; + sStickAngle = pthis->actor.yawTowardsPlayer + 0x4000; } else { - sStickAngle = this->actor.yawTowardsPlayer - 0x4000; + sStickAngle = pthis->actor.yawTowardsPlayer - 0x4000; } sStickTilt = 127.0f; sJumpslashTimer = 15; @@ -360,30 +360,30 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { } else if (sSwordJumpState != 0) { sStickTilt = 0.0f; player->stateFlags3 |= 4; - Math_SmoothStepToF(&this->actor.world.pos.x, + Math_SmoothStepToF(&pthis->actor.world.pos.x, (Math_SinS(player->actor.shape.rot.y - 0x3E8) * 45.0f) + player->actor.world.pos.x, 1.0f, 5.0f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.z, + Math_SmoothStepToF(&pthis->actor.world.pos.z, (Math_CosS(player->actor.shape.rot.y - 0x3E8) * 45.0f) + player->actor.world.pos.z, 1.0f, 5.0f, 0.0f); sSwordJumpTimer--; - if (((u32)sSwordJumpTimer == 0) || ((player->invincibilityTimer > 0) && (this->swordState == 0))) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + if (((u32)sSwordJumpTimer == 0) || ((player->invincibilityTimer > 0) && (pthis->swordState == 0))) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; input->cur.button = BTN_A; player->stateFlags3 &= ~4; sStickTilt = 127.0f; player->skelAnime.curFrame = 3.0f; - sStickAngle = this->actor.yawTowardsPlayer + 0x8000; + sStickAngle = pthis->actor.yawTowardsPlayer + 0x8000; sSwordJumpTimer = sSwordJumpState = 0; - this->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags |= ACTOR_FLAG_0; } else if (sSwordJumpState == 1) { if (sSwordJumpTimer < 16) { - EnTorch2_SwingSword(globalCtx, input, this); + EnTorch2_SwingSword(globalCtx, input, pthis); sSwordJumpState++; } else if (sSwordJumpTimer == 19) { - func_800F4190(&this->actor.projectedPos, NA_SE_VO_LI_AUTO_JUMP); + func_800F4190(&pthis->actor.projectedPos, NA_SE_VO_LI_AUTO_JUMP); } } } else { @@ -395,31 +395,31 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { // Handles Dark Link's reaction to sword attack other than jumpslashes - if (func_800354B4(globalCtx, &this->actor, 120.0f, 0x7FFF, 0x7FFF, this->actor.world.rot.y)) { - if ((player->swordAnimation == STAB_1H) && (this->actor.xzDistToPlayer < 90.0f)) { + if (func_800354B4(globalCtx, &pthis->actor, 120.0f, 0x7FFF, 0x7FFF, pthis->actor.world.rot.y)) { + if ((player->swordAnimation == STAB_1H) && (pthis->actor.xzDistToPlayer < 90.0f)) { // Handles the reaction to a one-handed stab. If the conditions are satisfied, // Dark Link jumps on Link's sword. Otherwise he backflips away. - if ((this->swordState == 0) && (sCounterState == 0) && (player->invincibilityTimer == 0) && - (player->swordAnimation == STAB_1H) && (this->actor.xzDistToPlayer <= 85.0f) && - Actor_IsTargeted(globalCtx, &this->actor)) { + if ((pthis->swordState == 0) && (sCounterState == 0) && (player->invincibilityTimer == 0) && + (player->swordAnimation == STAB_1H) && (pthis->actor.xzDistToPlayer <= 85.0f) && + Actor_IsTargeted(globalCtx, &pthis->actor)) { sStickTilt = 0.0f; sSwordJumpState = 1; player->stateFlags3 |= 4; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; sSwordJumpTimer = 27; player->swordState = 0; player->linearVelocity = 0.0f; - this->invincibilityTimer = -7; - this->linearVelocity = 0.0f; + pthis->invincibilityTimer = -7; + pthis->linearVelocity = 0.0f; player->skelAnime.curFrame = 2.0f; LinkAnimation_Update(globalCtx, &player->skelAnime); sHoldShieldTimer = 0; input->cur.button = BTN_A; } else { - EnTorch2_Backflip(this, input, &this->actor); + EnTorch2_Backflip(pthis, input, &pthis->actor); } } else { @@ -439,11 +439,11 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { } else if (player->swordAnimation <= HAMMER_SIDE) { input->cur.button = BTN_R; } else if (player->swordAnimation <= BIG_SPIN_2H) { - EnTorch2_Backflip(this, input, &this->actor); + EnTorch2_Backflip(pthis, input, &pthis->actor); } else { - EnTorch2_Backflip(this, input, &this->actor); + EnTorch2_Backflip(pthis, input, &pthis->actor); } - if (!CHECK_BTN_ANY(input->cur.button, BTN_A | BTN_R) && (this->swordState == 0) && + if (!CHECK_BTN_ANY(input->cur.button, BTN_A | BTN_R) && (pthis->swordState == 0) && (player->swordState != 0)) { sCounterState = 1; } @@ -454,38 +454,38 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { sStickAngle = thisx->yawTowardsPlayer; sp50 = 0.0f; - if ((90.0f >= this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 70.0f) && - (ABS(sp5A) >= 0x7800) && (this->actor.isTargeted || !(player->stateFlags1 & 0x00400000))) { - EnTorch2_SwingSword(globalCtx, input, this); - } else if (((this->actor.xzDistToPlayer <= 70.0f) || - ((this->actor.xzDistToPlayer <= 80.0f + sp50) && (player->swordState != 0))) && - (this->swordState == 0)) { - if (!EnTorch2_SwingSword(globalCtx, input, this) && (this->swordState == 0) && + if ((90.0f >= pthis->actor.xzDistToPlayer) && (pthis->actor.xzDistToPlayer > 70.0f) && + (ABS(sp5A) >= 0x7800) && (pthis->actor.isTargeted || !(player->stateFlags1 & 0x00400000))) { + EnTorch2_SwingSword(globalCtx, input, pthis); + } else if (((pthis->actor.xzDistToPlayer <= 70.0f) || + ((pthis->actor.xzDistToPlayer <= 80.0f + sp50) && (player->swordState != 0))) && + (pthis->swordState == 0)) { + if (!EnTorch2_SwingSword(globalCtx, input, pthis) && (pthis->swordState == 0) && (sCounterState == 0)) { - EnTorch2_Backflip(this, input, &this->actor); + EnTorch2_Backflip(pthis, input, &pthis->actor); } - } else if (this->actor.xzDistToPlayer <= 50 + sp50) { + } else if (pthis->actor.xzDistToPlayer <= 50 + sp50) { sStickTilt = 127.0f; - sStickAngle = this->actor.yawTowardsPlayer; - if (!this->actor.isTargeted) { + sStickAngle = pthis->actor.yawTowardsPlayer; + if (!pthis->actor.isTargeted) { Math_SmoothStepToS(&sStickAngle, player->actor.shape.rot.y + 0x7FFF, 1, 0x2328, 0); } - } else if (this->actor.xzDistToPlayer > 100.0f + sp50) { + } else if (pthis->actor.xzDistToPlayer > 100.0f + sp50) { if ((player->swordState == 0) || (player->swordAnimation < SPIN_ATTACK_1H) || - (player->swordAnimation > BIG_SPIN_2H) || (this->actor.xzDistToPlayer >= 280.0f)) { + (player->swordAnimation > BIG_SPIN_2H) || (pthis->actor.xzDistToPlayer >= 280.0f)) { sStickTilt = 127.0f; - sStickAngle = this->actor.yawTowardsPlayer; - if (!this->actor.isTargeted) { + sStickAngle = pthis->actor.yawTowardsPlayer; + if (!pthis->actor.isTargeted) { Math_SmoothStepToS(&sStickAngle, player->actor.shape.rot.y + 0x7FFF, 1, 0x2328, 0); } } else { - EnTorch2_Backflip(this, input, &this->actor); + EnTorch2_Backflip(pthis, input, &pthis->actor); } } else if (((ABS(sp5A) < 0x7800) && (ABS(sp5A) >= 0x3000)) || - !EnTorch2_SwingSword(globalCtx, input, this)) { - sStickAngle = this->actor.yawTowardsPlayer; + !EnTorch2_SwingSword(globalCtx, input, pthis)) { + sStickAngle = pthis->actor.yawTowardsPlayer; sStickTilt = 127.0f; - if (!this->actor.isTargeted) { + if (!pthis->actor.isTargeted) { Math_SmoothStepToS(&sStickAngle, player->actor.shape.rot.y + 0x7FFF, 1, 0x2328, 0); } } @@ -494,11 +494,11 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { // Handles Dark Link's counterattack to jumpslashes - } else if (sJumpslashFlag && (sAlpha == 255) && (this->actor.velocity.y > 0)) { + } else if (sJumpslashFlag && (sAlpha == 255) && (pthis->actor.velocity.y > 0)) { input->cur.button |= BTN_B; - } else if (!sJumpslashFlag && (this->actor.bgCheckFlags & 1)) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - sStickAngle = this->actor.yawTowardsPlayer; + } else if (!sJumpslashFlag && (pthis->actor.bgCheckFlags & 1)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + sStickAngle = pthis->actor.yawTowardsPlayer; if (sAlpha != 255) { sStickAngle += 0x8000; sStickTilt = 127.0f; @@ -506,7 +506,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { } input->cur.button |= BTN_A; sJumpslashFlag = true; - this->invincibilityTimer = 10; + pthis->invincibilityTimer = 10; } // Rotates Dark Link's stick angle from Link-relative to camera-relative. @@ -523,31 +523,31 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { break; case ENTORCH2_DAMAGE: - this->swordState = 0; + pthis->swordState = 0; input->cur.stick_x = input->cur.stick_y = 0; - if ((this->invincibilityTimer > 0) && (this->actor.world.pos.y < (this->actor.floorHeight - 160.0f))) { - this->stateFlags3 &= ~1; - this->actor.flags |= ACTOR_FLAG_0; - this->invincibilityTimer = 0; - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = sSpawnPoint.y + 40.0f; - this->actor.world.pos.x = (Math_SinS(player->actor.shape.rot.y) * -120.0f) + player->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(player->actor.shape.rot.y) * -120.0f) + player->actor.world.pos.z; - if (Actor_WorldDistXYZToPoint(&this->actor, &sSpawnPoint) > 800.0f) { + if ((pthis->invincibilityTimer > 0) && (pthis->actor.world.pos.y < (pthis->actor.floorHeight - 160.0f))) { + pthis->stateFlags3 &= ~1; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->invincibilityTimer = 0; + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = sSpawnPoint.y + 40.0f; + pthis->actor.world.pos.x = (Math_SinS(player->actor.shape.rot.y) * -120.0f) + player->actor.world.pos.x; + pthis->actor.world.pos.z = (Math_CosS(player->actor.shape.rot.y) * -120.0f) + player->actor.world.pos.z; + if (Actor_WorldDistXYZToPoint(&pthis->actor, &sSpawnPoint) > 800.0f) { sp50 = Rand_ZeroOne() * 20.0f; sp4E = Rand_CenteredFloat(4000.0f); - this->actor.shape.rot.y = this->actor.world.rot.y = + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = Math_Vec3f_Yaw(&sSpawnPoint, &player->actor.world.pos); - this->actor.world.pos.x = - (Math_SinS(this->actor.world.rot.y + sp4E) * (25.0f + sp50)) + sSpawnPoint.x; - this->actor.world.pos.z = - (Math_CosS(this->actor.world.rot.y + sp4E) * (25.0f + sp50)) + sSpawnPoint.z; - this->actor.world.pos.y = sSpawnPoint.y; + pthis->actor.world.pos.x = + (Math_SinS(pthis->actor.world.rot.y + sp4E) * (25.0f + sp50)) + sSpawnPoint.x; + pthis->actor.world.pos.z = + (Math_CosS(pthis->actor.world.rot.y + sp4E) * (25.0f + sp50)) + sSpawnPoint.z; + pthis->actor.world.pos.y = sSpawnPoint.y; } else { - this->actor.world.pos.y = this->actor.floorHeight; + pthis->actor.world.pos.y = pthis->actor.floorHeight; } - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - globalCtx->func_11D54(this, globalCtx); + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); + globalCtx->func_11D54(pthis, globalCtx); sActionState = ENTORCH2_ATTACK; sStickTilt = 0.0f; if (sAlpha != 255) { @@ -560,11 +560,11 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { case ENTORCH2_DEATH: if (sAlpha - 13 <= 0) { sAlpha = 0; - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } sAlpha -= 13; - this->actor.shape.shadowAlpha -= 13; + pthis->actor.shape.shadowAlpha -= 13; break; } @@ -578,7 +578,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { input->cur.button = BTN_R; } - if ((sActionState == ENTORCH2_ATTACK) && (this->actor.xzDistToPlayer <= 610.0f) && sZTargetFlag) { + if ((sActionState == ENTORCH2_ATTACK) && (pthis->actor.xzDistToPlayer <= 610.0f) && sZTargetFlag) { input->cur.button |= BTN_Z; } @@ -588,7 +588,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { pad54 = input->prev.button ^ input->cur.button; input->press.button = input->cur.button & pad54; if (CHECK_BTN_ANY(input->cur.button, BTN_R)) { - input->cur.button = ((sCounterState == 0) && (this->swordState == 0)) ? BTN_R : input->cur.button ^ BTN_R; + input->cur.button = ((sCounterState == 0) && (pthis->swordState == 0)) ? BTN_R : input->cur.button ^ BTN_R; } input->rel.button = input->prev.button & pad54; input->prev.button = input->cur.button & (u16) ~(BTN_A | BTN_B); @@ -599,67 +599,67 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { // Handles Dark Link being damaged - if ((this->actor.colChkInfo.health == 0) && sDeathFlag) { - this->csMode = 0x18; - this->unk_448 = &player->actor; - this->unk_46A = 1; + if ((pthis->actor.colChkInfo.health == 0) && sDeathFlag) { + pthis->csMode = 0x18; + pthis->unk_448 = &player->actor; + pthis->unk_46A = 1; sDeathFlag = false; } - if ((this->invincibilityTimer == 0) && (this->actor.colChkInfo.health != 0) && - (this->cylinder.base.acFlags & AC_HIT) && !(this->stateFlags1 & 0x04000000) && - !(this->swordQuads[0].base.atFlags & AT_HIT) && !(this->swordQuads[1].base.atFlags & AT_HIT)) { + if ((pthis->invincibilityTimer == 0) && (pthis->actor.colChkInfo.health != 0) && + (pthis->cylinder.base.acFlags & AC_HIT) && !(pthis->stateFlags1 & 0x04000000) && + !(pthis->swordQuads[0].base.atFlags & AT_HIT) && !(pthis->swordQuads[1].base.atFlags & AT_HIT)) { - if (!Actor_ApplyDamage(&this->actor)) { + if (!Actor_ApplyDamage(&pthis->actor)) { func_800F5B58(); - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - this->unk_8A1 = 2; - this->unk_8A4 = 6.0f; - this->unk_8A8 = 6.0f; - this->unk_8A0 = this->actor.colChkInfo.damage; - this->unk_8A2 = this->actor.yawTowardsPlayer + 0x8000; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + pthis->unk_8A1 = 2; + pthis->unk_8A4 = 6.0f; + pthis->unk_8A8 = 6.0f; + pthis->unk_8A0 = pthis->actor.colChkInfo.damage; + pthis->unk_8A2 = pthis->actor.yawTowardsPlayer + 0x8000; sDeathFlag++; sActionState = ENTORCH2_DEATH; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Item_DropCollectibleRandom(globalCtx, &this->actor, &thisx->world.pos, 0xC0); - this->stateFlags3 &= ~4; + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &thisx->world.pos, 0xC0); + pthis->stateFlags3 &= ~4; } else { func_800F5ACC(NA_BGM_MINI_BOSS); - if (this->actor.colChkInfo.damageEffect == 1) { + if (pthis->actor.colChkInfo.damageEffect == 1) { if (sAlpha == 255) { - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); } else { - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0x2000, 0x50); + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0x2000, 0x50); } } else { - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_8A0 = this->actor.colChkInfo.damage; - this->unk_8A1 = 1; - this->unk_8A8 = 6.0f; - this->unk_8A4 = 8.0f; - this->unk_8A2 = this->actor.yawTowardsPlayer + 0x8000; - Actor_SetDropFlag(&this->actor, &this->cylinder.info, 1); - this->stateFlags3 &= ~4; - this->stateFlags3 |= 1; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_8A0 = pthis->actor.colChkInfo.damage; + pthis->unk_8A1 = 1; + pthis->unk_8A8 = 6.0f; + pthis->unk_8A4 = 8.0f; + pthis->unk_8A2 = pthis->actor.yawTowardsPlayer + 0x8000; + Actor_SetDropFlag(&pthis->actor, &pthis->cylinder.info, 1); + pthis->stateFlags3 &= ~4; + pthis->stateFlags3 |= 1; sActionState = ENTORCH2_DAMAGE; if (sAlpha == 255) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0xC); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0xC); } else { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 0xC); + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0x2000, 0xC); } } } - this->actor.colChkInfo.damage = 0; - this->unk_8A0 = 0; + pthis->actor.colChkInfo.damage = 0; + pthis->unk_8A0 = 0; } // Handles being frozen by a deku nut - if ((this->actor.colorFilterTimer == 0) || (this->actor.colorFilterParams & 0x4000)) { - this->stateFlags3 &= ~4; + if ((pthis->actor.colorFilterTimer == 0) || (pthis->actor.colorFilterParams & 0x4000)) { + pthis->stateFlags3 &= ~4; } else { - this->stateFlags3 |= 4; - this->stateFlags1 &= ~0x04000000; - this->invincibilityTimer = 0; + pthis->stateFlags3 |= 4; + pthis->stateFlags1 &= ~0x04000000; + pthis->invincibilityTimer = 0; input->press.stick_x = input->press.stick_y = 0; /*! @bug * Setting cur.button to 0 clears the Z-trigger, causing Dark Link to break his @@ -668,38 +668,38 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { */ input->cur.button = 0; input->press.button = 0; - this->linearVelocity = 0.0f; + pthis->linearVelocity = 0.0f; } - globalCtx->playerUpdate(this, globalCtx, input); + globalCtx->playerUpdate(pthis, globalCtx, input); /* * Handles sword clanks and removes their recoil for both Links. Dark Link staggers * if he's had to counter with enough different sword animations in a row. */ - if (this->linearVelocity == -18.0f) { + if (pthis->linearVelocity == -18.0f) { staggerThreshold = (u32)Rand_CenteredFloat(2.0f) + 6; if (gSaveContext.health < 0x50) { staggerThreshold = (u32)Rand_CenteredFloat(2.0f) + 3; } - if (this->actor.xzDistToPlayer > 80.0f) { - this->linearVelocity = 1.2f; - } else if (this->actor.xzDistToPlayer < 70.0f) { - this->linearVelocity = -1.5f; + if (pthis->actor.xzDistToPlayer > 80.0f) { + pthis->linearVelocity = 1.2f; + } else if (pthis->actor.xzDistToPlayer < 70.0f) { + pthis->linearVelocity = -1.5f; } else { - this->linearVelocity = 1.0f; + pthis->linearVelocity = 1.0f; } if (staggerThreshold < sStaggerCount) { - this->skelAnime.playSpeed *= 0.6f; - func_800F4190(&this->actor.projectedPos, NA_SE_PL_DAMAGE); + pthis->skelAnime.playSpeed *= 0.6f; + func_800F4190(&pthis->actor.projectedPos, NA_SE_PL_DAMAGE); sStaggerTimer = 0; sStaggerCount = 0; } } if (player->linearVelocity == -18.0f) { - if (this->actor.xzDistToPlayer > 80.0f) { + if (pthis->actor.xzDistToPlayer > 80.0f) { player->linearVelocity = 1.2f; - } else if (this->actor.xzDistToPlayer < 70.0f) { + } else if (pthis->actor.xzDistToPlayer < 70.0f) { player->linearVelocity = -1.5f; } else { player->linearVelocity = 1.0f; @@ -709,16 +709,16 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { * This ensures Dark Link's counter animation mirrors Link's exactly. */ if ((sCounterState != 0) && (sCounterState == 1)) { - if (this->swordState == 0) { + if (pthis->swordState == 0) { sCounterState = 0; } else { sCounterState = 2; - this->swordState = 1; - this->skelAnime.curFrame = player->skelAnime.curFrame - player->skelAnime.playSpeed; - this->skelAnime.playSpeed = player->skelAnime.playSpeed; - LinkAnimation_Update(globalCtx, &this->skelAnime); - Collider_ResetQuadAT(globalCtx, &this->swordQuads[0].base); - Collider_ResetQuadAT(globalCtx, &this->swordQuads[1].base); + pthis->swordState = 1; + pthis->skelAnime.curFrame = player->skelAnime.curFrame - player->skelAnime.playSpeed; + pthis->skelAnime.playSpeed = player->skelAnime.playSpeed; + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + Collider_ResetQuadAT(globalCtx, &pthis->swordQuads[0].base); + Collider_ResetQuadAT(globalCtx, &pthis->swordQuads[1].base); } } if (sStaggerTimer != 0) { @@ -730,16 +730,16 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { } if (sDodgeRollState != 0) { if (sDodgeRollState == 1) { - this->invincibilityTimer = 20; + pthis->invincibilityTimer = 20; } - sDodgeRollState = (this->invincibilityTimer > 0) ? 2 : 0; + sDodgeRollState = (pthis->invincibilityTimer > 0) ? 2 : 0; } - if (this->invincibilityTimer != 0) { - this->cylinder.base.colType = COLTYPE_NONE; - this->cylinder.info.elemType = ELEMTYPE_UNK5; + if (pthis->invincibilityTimer != 0) { + pthis->cylinder.base.colType = COLTYPE_NONE; + pthis->cylinder.info.elemType = ELEMTYPE_UNK5; } else { - this->cylinder.base.colType = COLTYPE_HIT5; - this->cylinder.info.elemType = ELEMTYPE_UNK1; + pthis->cylinder.base.colType = COLTYPE_HIT5; + pthis->cylinder.info.elemType = ELEMTYPE_UNK1; } /* * Handles the jump movement onto Link's sword. Dark Link doesn't move during the @@ -748,12 +748,12 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { */ if (sSwordJumpState != 0) { Math_SmoothStepToF(&sSwordJumpHeight, 2630.0f, 1.0f, 2000.0f, 0.0f); - this->actor.velocity.y -= 0.6f; + pthis->actor.velocity.y -= 0.6f; } else if (sSwordJumpHeight != 0) { - this->actor.world.pos.y += sSwordJumpHeight * 0.01f; + pthis->actor.world.pos.y += sSwordJumpHeight * 0.01f; sSwordJumpHeight = 0; } - if ((sActionState == ENTORCH2_WAIT) || (this->invincibilityTimer < 0)) { + if ((sActionState == ENTORCH2_WAIT) || (pthis->invincibilityTimer < 0)) { sZTargetFlag = false; } else { sZTargetFlag = true; @@ -761,27 +761,27 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) { if (sJumpslashTimer != 0) { sJumpslashTimer--; } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 20.0f; - this->actor.shape.yOffset = sSwordJumpHeight; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 20.0f; + pthis->actor.shape.yOffset = sSwordJumpHeight; } s32 EnTorch2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx) { - Player* this = (Player*)thisx; + Player* pthis = (Player*)thisx; - return func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, &this->actor); + return func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, &pthis->actor); } void EnTorch2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - Player* this = (Player*)thisx; + Player* pthis = (Player*)thisx; - func_80090D20(globalCtx, limbIndex, dList, rot, &this->actor); + func_80090D20(globalCtx, limbIndex, dList, rot, &pthis->actor); } void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - Player* this = (Player*)thisx; + Player* pthis = (Player*)thisx; s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_torch2.c", 1050); @@ -790,19 +790,19 @@ void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (sAlpha == 255) { gDPSetEnvColor(POLY_OPA_DISP++, 255, 0, 0, sAlpha); gSPSegment(POLY_OPA_DISP++, 0x0C, D_80116280 + 2); - func_8002EBCC(&this->actor, globalCtx, 0); - func_8002ED80(&this->actor, globalCtx, 0); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnTorch2_OverrideLimbDraw, EnTorch2_PostLimbDraw, - this, POLY_OPA_DISP); + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnTorch2_OverrideLimbDraw, EnTorch2_PostLimbDraw, + pthis, POLY_OPA_DISP); } else { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, sAlpha); gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - func_8002EBCC(&this->actor, globalCtx, 0); - func_8002ED80(&this->actor, globalCtx, 0); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnTorch2_OverrideLimbDraw, EnTorch2_PostLimbDraw, - this, POLY_XLU_DISP); + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnTorch2_OverrideLimbDraw, EnTorch2_PostLimbDraw, + pthis, POLY_XLU_DISP); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_torch2.c", 1114); } diff --git a/src/overlays/actors/ovl_En_Toryo/z_en_toryo.c b/src/overlays/actors/ovl_En_Toryo/z_en_toryo.cpp similarity index 67% rename from src/overlays/actors/ovl_En_Toryo/z_en_toryo.c rename to src/overlays/actors/ovl_En_Toryo/z_en_toryo.cpp index 8e436d10a..54dfb4f8f 100644 --- a/src/overlays/actors/ovl_En_Toryo/z_en_toryo.c +++ b/src/overlays/actors/ovl_En_Toryo/z_en_toryo.cpp @@ -25,11 +25,11 @@ void EnToryo_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnToryo_Update(Actor* thisx, GlobalContext* globalCtx); void EnToryo_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B20914(EnToryo* this, GlobalContext* globalCtx); +void func_80B20914(EnToryo* pthis, GlobalContext* globalCtx); s32 EnToryo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); void EnToryo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); -const ActorInit En_Toryo_InitVars = { +ActorInit En_Toryo_InitVars = { ACTOR_EN_TORYO, ACTORCAT_NPC, FLAGS, @@ -110,53 +110,53 @@ static EnToryoAnimation sEnToryoAnimation = { &object_toryo_Anim_000E50, 1.0f, 0 static Vec3f sMultVec = { 800.0f, 1000.0f, 0.0f }; void EnToryo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnToryo* this = (EnToryo*)thisx; + EnToryo* pthis = (EnToryo*)thisx; s32 pad; switch (globalCtx->sceneNum) { case SCENE_SPOT09: if (LINK_AGE_IN_YEARS == YEARS_ADULT) { - this->stateFlags |= 1; + pthis->stateFlags |= 1; } break; case SCENE_SPOT01: if ((LINK_AGE_IN_YEARS == YEARS_CHILD) && IS_DAY) { - this->stateFlags |= 2; + pthis->stateFlags |= 2; } break; case SCENE_KAKARIKO: if ((LINK_AGE_IN_YEARS == YEARS_CHILD) && IS_NIGHT) { - this->stateFlags |= 4; + pthis->stateFlags |= 4; } break; } - if ((this->stateFlags & 7) == 0) { - Actor_Kill(&this->actor); + if ((pthis->stateFlags & 7) == 0) { + Actor_Kill(&pthis->actor); } - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 42.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_toryo_Skel_007150, NULL, this->jointTable, this->morphTable, + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 42.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_toryo_Skel_007150, NULL, pthis->jointTable, pthis->morphTable, 17); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sEnToryoAnimation.anim, 1.0f, 0.0f, + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + Animation_Change(&pthis->skelAnime, sEnToryoAnimation.anim, 1.0f, 0.0f, Animation_GetLastFrame(sEnToryoAnimation.anim), sEnToryoAnimation.mode, sEnToryoAnimation.transitionRate); - this->stateFlags |= 8; - this->actor.targetMode = 6; - this->actionFunc = func_80B20914; + pthis->stateFlags |= 8; + pthis->actor.targetMode = 6; + pthis->actionFunc = func_80B20914; } void EnToryo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnToryo* this = (EnToryo*)thisx; + EnToryo* pthis = (EnToryo*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 func_80B203D8(EnToryo* this, GlobalContext* globalCtx) { +s32 func_80B203D8(EnToryo* pthis, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); s32 ret = 1; @@ -173,19 +173,19 @@ s32 func_80B203D8(EnToryo* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { Message_CloseTextbox(globalCtx); - this->actor.parent = NULL; + pthis->actor.parent = NULL; player->exchangeItemId = EXCH_ITEM_NONE; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->actor.textId = 0x601B; + pthis->actor.textId = 0x601B; ret = 3; } else { - this->actor.textId = 0x606F; + pthis->actor.textId = 0x606F; ret = 2; } } break; case TEXT_STATE_DONE: - switch (this->actor.textId) { + switch (pthis->actor.textId) { case 0x5028: ret = 1; if (Message_ShouldAdvance(globalCtx)) { @@ -229,7 +229,7 @@ s32 func_80B203D8(EnToryo* this, GlobalContext* globalCtx) { return ret; } -s32 func_80B205CC(EnToryo* this, GlobalContext* globalCtx) { +s32 func_80B205CC(EnToryo* pthis, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); s32 ret = 5; @@ -252,11 +252,11 @@ s32 func_80B205CC(EnToryo* this, GlobalContext* globalCtx) { return ret; } -u32 func_80B20634(EnToryo* this, GlobalContext* globalCtx) { +u32 func_80B20634(EnToryo* pthis, GlobalContext* globalCtx) { u32 ret; - if (this->unk_1E0 != 0) { - if (this->unk_1E0 == 10) { + if (pthis->unk_1E0 != 0) { + if (pthis->unk_1E0 == 10) { func_80078884(NA_SE_SY_TRE_BOX_APPEAR); if (gSaveContext.infTable[23] & 2) { ret = 0x606E; @@ -271,12 +271,12 @@ u32 func_80B20634(EnToryo* this, GlobalContext* globalCtx) { return ret; } -s32 func_80B206A0(EnToryo* this, GlobalContext* globalCtx) { +s32 func_80B206A0(EnToryo* pthis, GlobalContext* globalCtx) { s32 textId = Text_GetFaceReaction(globalCtx, 0); s32 ret = textId; if (textId == 0) { - if ((this->stateFlags & 1)) { + if ((pthis->stateFlags & 1)) { if ((gSaveContext.eventChkInf[9] & 0xF) == 0xF) { ret = 0x606C; } else if ((gSaveContext.infTable[23] & 1)) { @@ -284,7 +284,7 @@ s32 func_80B206A0(EnToryo* this, GlobalContext* globalCtx) { } else { ret = 0x606A; } - } else if ((this->stateFlags & 2)) { + } else if ((pthis->stateFlags & 2)) { if ((gSaveContext.infTable[23] & 4)) { ret = 0x5029; } else { @@ -292,7 +292,7 @@ s32 func_80B206A0(EnToryo* this, GlobalContext* globalCtx) { } } else { ret = textId; - if ((this->stateFlags & 4)) { + if ((pthis->stateFlags & 4)) { ret = 0x506C; } } @@ -300,121 +300,121 @@ s32 func_80B206A0(EnToryo* this, GlobalContext* globalCtx) { return ret; } -void func_80B20768(EnToryo* this, GlobalContext* globalCtx) { +void func_80B20768(EnToryo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 sp32; s16 sp30; - if (this->unk_1E4 == 3) { - Actor_ProcessTalkRequest(&this->actor, globalCtx); - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E4 = 1; + if (pthis->unk_1E4 == 3) { + Actor_ProcessTalkRequest(&pthis->actor, globalCtx); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E4 = 1; } - if (this->unk_1E4 == 1) { - this->unk_1E4 = func_80B203D8(this, globalCtx); + if (pthis->unk_1E4 == 1) { + pthis->unk_1E4 = func_80B203D8(pthis, globalCtx); } - if (this->unk_1E4 == 5) { - this->unk_1E4 = func_80B205CC(this, globalCtx); + if (pthis->unk_1E4 == 5) { + pthis->unk_1E4 = func_80B205CC(pthis, globalCtx); return; } - if (this->unk_1E4 == 2) { - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E4 = 1; + if (pthis->unk_1E4 == 2) { + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E4 = 1; } - if (this->unk_1E4 == 4) { - if (Actor_HasParent(&this->actor, globalCtx)) { - this->actor.parent = NULL; - this->unk_1E4 = 5; + if (pthis->unk_1E4 == 4) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->actor.parent = NULL; + pthis->unk_1E4 = 5; } else { - func_8002F434(&this->actor, globalCtx, GI_SWORD_BROKEN, 100.0f, 10.0f); + func_8002F434(&pthis->actor, globalCtx, GI_SWORD_BROKEN, 100.0f, 10.0f); } return; } - if (this->unk_1E4 == 0) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_1E0 = func_8002F368(globalCtx); - if (this->unk_1E0 != 0) { - player->actor.textId = func_80B20634(this, globalCtx); - this->actor.textId = player->actor.textId; + if (pthis->unk_1E4 == 0) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_1E0 = func_8002F368(globalCtx); + if (pthis->unk_1E0 != 0) { + player->actor.textId = func_80B20634(pthis, globalCtx); + pthis->actor.textId = player->actor.textId; } - this->unk_1E4 = 1; + pthis->unk_1E4 = 1; return; } - Actor_GetScreenPos(globalCtx, &this->actor, &sp32, &sp30); + Actor_GetScreenPos(globalCtx, &pthis->actor, &sp32, &sp30); if ((sp32 >= 0) && (sp32 < 0x141) && (sp30 >= 0) && (sp30 < 0xF1)) { - this->actor.textId = func_80B206A0(this, globalCtx); - func_8002F298(&this->actor, globalCtx, 100.0f, 10); + pthis->actor.textId = func_80B206A0(pthis, globalCtx); + func_8002F298(&pthis->actor, globalCtx, 100.0f, 10); } } } -void func_80B20914(EnToryo* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - func_80B20768(this, globalCtx); - if (this->unk_1E4 != 0) { - this->stateFlags |= 0x10; +void func_80B20914(EnToryo* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + func_80B20768(pthis, globalCtx); + if (pthis->unk_1E4 != 0) { + pthis->stateFlags |= 0x10; } else { - this->stateFlags &= ~0x10; + pthis->stateFlags &= ~0x10; } } void EnToryo_Update(Actor* thisx, GlobalContext* globalCtx) { - EnToryo* this = (EnToryo*)thisx; - ColliderCylinder* collider = &this->collider; + EnToryo* pthis = (EnToryo*)thisx; + ColliderCylinder* collider = &pthis->collider; Player* player = GET_PLAYER(globalCtx); f32 rot; Collider_UpdateCylinder(thisx, collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, (Collider*)collider); - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); - if ((this->stateFlags & 8)) { - this->unk_1EC.unk_18.x = player->actor.focus.pos.x; - this->unk_1EC.unk_18.y = player->actor.focus.pos.y; - this->unk_1EC.unk_18.z = player->actor.focus.pos.z; + if ((pthis->stateFlags & 8)) { + pthis->unk_1EC.unk_18.x = player->actor.focus.pos.x; + pthis->unk_1EC.unk_18.y = player->actor.focus.pos.y; + pthis->unk_1EC.unk_18.z = player->actor.focus.pos.z; - if ((this->stateFlags & 0x10)) { - func_80034A14(thisx, &this->unk_1EC, 0, 4); + if ((pthis->stateFlags & 0x10)) { + func_80034A14(thisx, &pthis->unk_1EC, 0, 4); return; } rot = thisx->yawTowardsPlayer - thisx->shape.rot.y; if ((rot < 14563.0f) && (rot > -14563.0f)) { - func_80034A14(thisx, &this->unk_1EC, 0, 2); + func_80034A14(thisx, &pthis->unk_1EC, 0, 2); } else { - func_80034A14(thisx, &this->unk_1EC, 0, 1); + func_80034A14(thisx, &pthis->unk_1EC, 0, 1); } } } void EnToryo_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnToryo* this = (EnToryo*)thisx; + EnToryo* pthis = (EnToryo*)thisx; func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnToryo_OverrideLimbDraw, EnToryo_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnToryo_OverrideLimbDraw, EnToryo_PostLimbDraw, pthis); } s32 EnToryo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnToryo* this = (EnToryo*)thisx; + EnToryo* pthis = (EnToryo*)thisx; - if ((this->stateFlags & 8)) { + if ((pthis->stateFlags & 8)) { switch (limbIndex) { case 8: - rot->x += this->unk_1EC.unk_0E.y; - rot->y -= this->unk_1EC.unk_0E.x; + rot->x += pthis->unk_1EC.unk_0E.y; + rot->y -= pthis->unk_1EC.unk_0E.x; break; case 15: - rot->x += this->unk_1EC.unk_08.y; - rot->z += this->unk_1EC.unk_08.x; + rot->x += pthis->unk_1EC.unk_08.y; + rot->z += pthis->unk_1EC.unk_08.x; break; } } @@ -422,11 +422,11 @@ s32 EnToryo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } void EnToryo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnToryo* this = (EnToryo*)thisx; + EnToryo* pthis = (EnToryo*)thisx; switch (limbIndex) { case 15: - Matrix_MultVec3f(&sMultVec, &this->actor.focus.pos); + Matrix_MultVec3f(&sMultVec, &pthis->actor.focus.pos); break; } } diff --git a/src/overlays/actors/ovl_En_Toryo/z_en_toryo.h b/src/overlays/actors/ovl_En_Toryo/z_en_toryo.h index b6963f501..6df6f02ba 100644 --- a/src/overlays/actors/ovl_En_Toryo/z_en_toryo.h +++ b/src/overlays/actors/ovl_En_Toryo/z_en_toryo.h @@ -6,7 +6,7 @@ struct EnToryo; -typedef void (*EnToryoActionFunc)(struct EnToryo* this, GlobalContext* globalCtx); +typedef void (*EnToryoActionFunc)(struct EnToryo* pthis, GlobalContext* globalCtx); typedef struct EnToryo { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Tp/z_en_tp.c b/src/overlays/actors/ovl_En_Tp/z_en_tp.c deleted file mode 100644 index 19c1d7c5b..000000000 --- a/src/overlays/actors/ovl_En_Tp/z_en_tp.c +++ /dev/null @@ -1,778 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TP_Z_EN_TP_C -#include "actor_common.h" -/* - * File: z_en_tp.c - * Overlay: ovl_En_Tp - * Description: Electric Tailpasaran - */ - -#include "z_en_tp.h" -#include "objects/object_tp/object_tp.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/sys_math.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS 0 - -void EnTp_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTp_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTp_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTp_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnTp_Tail_SetupFollowHead(EnTp* this); -void EnTp_Tail_FollowHead(EnTp* this, GlobalContext* globalCtx); -void EnTp_Head_SetupApproachPlayer(EnTp* this); -void EnTp_Head_ApproachPlayer(EnTp* this, GlobalContext* globalCtx); -void EnTp_SetupDie(EnTp* this); -void EnTp_Die(EnTp* this, GlobalContext* globalCtx); -void EnTp_Fragment_SetupFade(EnTp* this); -void EnTp_Fragment_Fade(EnTp* this, GlobalContext* globalCtx); -void EnTp_Head_SetupTakeOff(EnTp* this); -void EnTp_Head_TakeOff(EnTp* this, GlobalContext* globalCtx); -void EnTp_Head_SetupWait(EnTp* this); -void EnTp_Head_Wait(EnTp* this, GlobalContext* globalCtx); -void EnTp_Head_SetupBurrowReturnHome(EnTp* this); -void EnTp_Head_BurrowReturnHome(EnTp* this, GlobalContext* globalCtx); - -typedef enum { - /* 0 */ TAILPASARAN_ACTION_FRAGMENT_FADE, - /* 1 */ TAILPASARAN_ACTION_DIE, - /* 2 */ TAILPASARAN_ACTION_TAIL_FOLLOWHEAD, - /* 4 */ TAILPASARAN_ACTION_HEAD_WAIT = 4, - /* 7 */ TAILPASARAN_ACTION_HEAD_APPROACHPLAYER = 7, - /* 8 */ TAILPASARAN_ACTION_HEAD_TAKEOFF, - /* 9 */ TAILPASARAN_ACTION_HEAD_BURROWRETURNHOME -} TailpasaranAction; - -const ActorInit En_Tp_InitVars = { - ACTOR_EN_TP, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_TP, - sizeof(EnTp), - (ActorFunc)EnTp_Init, - (ActorFunc)EnTp_Destroy, - (ActorFunc)EnTp_Update, - (ActorFunc)EnTp_Draw, -}; - -static ColliderJntSphElementInit sJntSphElementsInit[1] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x03, 0x08 }, - { 0xFFCFFFFF, 0x01, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 0, { { 0, 0, 0 }, 4 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_HIT1, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - 1, - sJntSphElementsInit, -}; - -typedef enum { - /* 00 */ TAILPASARAN_DMGEFF_NONE, - /* 01 */ TAILPASARAN_DMGEFF_DEKUNUT, - /* 14 */ TAILPASARAN_DMGEFF_SHOCKING = 14, // Kills the Tailpasaran but shocks Player - /* 15 */ TAILPASARAN_DMGEFF_INSULATING // Kills the Tailpasaran and does not shock Player -} TailpasaranDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_DEKUNUT), - /* Deku stick */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_INSULATING), - /* Slingshot */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Explosive */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(1, TAILPASARAN_DMGEFF_INSULATING), - /* Normal arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), - /* Hookshot */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Kokiri sword */ DMG_ENTRY(1, TAILPASARAN_DMGEFF_SHOCKING), - /* Master sword */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), - /* Giant's Knife */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), - /* Fire arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Ice arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Light arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Unk arrow 1 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Ice magic */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Light magic */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Shield */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, TAILPASARAN_DMGEFF_SHOCKING), - /* Giant spin */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), - /* Master spin */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), - /* Kokiri jump */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), - /* Giant jump */ DMG_ENTRY(8, TAILPASARAN_DMGEFF_SHOCKING), - /* Master jump */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), - /* Unknown 1 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), - /* Unknown 2 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), -}; - -void EnTp_SetupAction(EnTp* this, EnTpActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnTp_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnTp* this = (EnTp*)thisx; - EnTp* now; - EnTp* next; - s32 i; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.targetMode = 3; - this->actor.colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.14f); - this->unk_150 = 0; - this->actor.colChkInfo.health = 1; - now = this; - this->alpha = 255; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - - if (this->actor.params <= TAILPASARAN_HEAD) { - this->actor.naviEnemyId = 0x06; - this->timer = 0; - this->collider.base.acFlags |= AC_HARD; - this->collider.elements->dim.modelSphere.radius = this->collider.elements->dim.worldSphere.radius = 8; - EnTp_Head_SetupWait(this); - this->actor.focus.pos = this->actor.world.pos; - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4; - Actor_SetScale(&this->actor, 1.5f); - - for (i = 0; i <= 6; i++) { - next = (EnTp*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TP, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0 * i); - - if (0 * i) {} // Very fake, but needed to get the s registers right - if (next != NULL) { - now->actor.child = &next->actor; - next->actor.parent = &now->actor; - next->kiraSpawnTimer = i + 1; - next->head = this; - Actor_SetScale(&next->actor, 0.3f); - - if (i == 2) { - next->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4; - next->unk_150 = 1; // Why? - } - - next->timer = next->unk_15C = i * -5; - next->horizontalVariation = 6.0f - (i * 0.75f); - now = next; - if (0 * i) {} - } - } - } else if (this->actor.params == TAILPASARAN_TAIL) { - EnTp_Tail_SetupFollowHead(this); - } else { - EnTp_Fragment_SetupFade(this); - } -} - -void EnTp_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTp* this = (EnTp*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void EnTp_Tail_SetupFollowHead(EnTp* this) { - this->actionIndex = TAILPASARAN_ACTION_TAIL_FOLLOWHEAD; - EnTp_SetupAction(this, EnTp_Tail_FollowHead); -} - -void EnTp_Tail_FollowHead(EnTp* this, GlobalContext* globalCtx) { - s16 angle; - s16 phase; - - if (this->actor.params == TAILPASARAN_TAIL_DYING) { - this->actionIndex = TAILPASARAN_ACTION_DIE; - - if (this->actor.parent == NULL) { - EnTp_SetupDie(this); - } - } else { - if (this->unk_150 != 0) { - this->actor.flags |= ACTOR_FLAG_0; - } - - if (this->head->unk_150 != 0) { - this->actor.speedXZ = this->red = this->actor.velocity.y = this->heightPhase = 0.0f; - if (this->actor.world.pos.y < this->head->actor.home.pos.y) { - this->actor.flags &= ~ACTOR_FLAG_0; - } - - this->actor.world.pos = this->actor.parent->prevPos; - } else { - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.parent->world.pos.y - 4.0f, 1.0f, 1.0f, 0.0f); - angle = this->head->actor.shape.rot.y + 0x4000; - phase = 2000 * (this->head->unk_15C + this->timer); - this->actor.world.pos.x = - this->actor.home.pos.x + Math_SinS(phase) * (Math_SinS(angle) * this->horizontalVariation); - this->actor.world.pos.z = - this->actor.home.pos.z + Math_SinS(phase) * (Math_CosS(angle) * this->horizontalVariation); - } - } -} - -void EnTp_Head_SetupApproachPlayer(EnTp* this) { - this->actionIndex = TAILPASARAN_ACTION_HEAD_APPROACHPLAYER; - this->timer = 200; - EnTp_SetupAction(this, EnTp_Head_ApproachPlayer); -} - -void EnTp_Head_ApproachPlayer(EnTp* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 30.0f, 1.0f, 0.5f, 0.0f); - Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - if (&player->actor == this->collider.base.at) { - this->timer = 1; - } - } - - if (this->red < 255) { - this->red += 15; - } - - if (Math_CosF(this->heightPhase) == 0.0f) { - this->extraHeightVariation = 2.0f * Rand_ZeroOne(); - } - - this->actor.world.pos.y += Math_CosF(this->heightPhase) * (2.0f + this->extraHeightVariation); - this->heightPhase += 0.2f; - Math_SmoothStepToF(&this->actor.speedXZ, 2.5f, 0.1f, 0.2f, 0.0f); - this->timer--; - - if (this->timer != 0) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 750, 0); - this->actor.shape.rot.y = this->actor.world.rot.y; - } else { - EnTp_Head_SetupBurrowReturnHome(this); - } -} - -void EnTp_SetupDie(EnTp* this) { - Actor* now; - - this->timer = 2; - - if (this->actor.params <= TAILPASARAN_HEAD) { - for (now = this->actor.child; now != NULL; now = now->child) { - now->params = TAILPASARAN_TAIL_DYING; - now->colChkInfo.health = 0; - } - - this->timer = 13; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TAIL_DEAD); - } - this->actionIndex = TAILPASARAN_ACTION_DIE; - EnTp_SetupAction(this, EnTp_Die); -} - -/** - * Spawns effects and smaller tail segment-like fragments - */ -void EnTp_Die(EnTp* this, GlobalContext* globalCtx) { - EnTp* now; - s16 i; - s32 pad; - Vec3f effectVelAccel = { 0.0f, 0.5f, 0.0f }; - Vec3f effectPos = { 0.0f, 0.0f, 0.0f }; - - this->timer--; - - if (this->timer <= 0) { - if (this->actor.params == TAILPASARAN_HEAD_DYING) { - effectPos.x = ((Rand_ZeroOne() - 0.5f) * 15.0f) + this->actor.world.pos.x; - effectPos.z = ((Rand_ZeroOne() - 0.5f) * 15.0f) + this->actor.world.pos.z; - effectPos.y = ((Rand_ZeroOne() - 0.5f) * 5.0f) + this->actor.world.pos.y; - EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVelAccel, &effectVelAccel, 100, 0, 255, 255, 255, 255, 0, - 0, 255, 1, 9, 1); - - effectPos.x = ((Rand_ZeroOne() - 0.5f) * 15.0f) + this->actor.world.pos.x; - effectPos.z = ((Rand_ZeroOne() - 0.5f) * 15.0f) + this->actor.world.pos.z; - effectPos.y = ((Rand_ZeroOne() - 0.5f) * 5.0f) + this->actor.world.pos.y; - EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVelAccel, &effectVelAccel, 100, 0, 255, 255, 255, 255, 0, - 0, 255, 1, 9, 1); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x50); - } else { - for (i = 0; i < 1; i++) { - now = - (EnTp*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TP, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, TAILPASARAN_FRAGMENT); - - if (now != NULL) { - Actor_SetScale(&now->actor, this->actor.scale.z * 0.5f); - now->red = this->red; - } - } - } - - if (this->actor.child != NULL) { - this->actor.child->parent = NULL; - this->actor.child->params = TAILPASARAN_TAIL_DYING; - this->actor.child->colChkInfo.health = 0; - } - - this->unk_150 = 2; - Actor_Kill(&this->actor); - } -} - -void EnTp_Fragment_SetupFade(EnTp* this) { - this->actionIndex = TAILPASARAN_ACTION_FRAGMENT_FADE; - this->actor.world.pos.x += ((Rand_ZeroOne() - 0.5f) * 5.0f); - this->actor.world.pos.y += ((Rand_ZeroOne() - 0.5f) * 5.0f); - this->actor.world.pos.z += ((Rand_ZeroOne() - 0.5f) * 5.0f); - this->actor.velocity.x = (Rand_ZeroOne() - 0.5f) * 1.5f; - this->actor.velocity.y = (Rand_ZeroOne() - 0.5f) * 1.5f; - this->actor.velocity.z = (Rand_ZeroOne() - 0.5f) * 1.5f; - this->actor.flags &= ~ACTOR_FLAG_0; - EnTp_SetupAction(this, EnTp_Fragment_Fade); -} - -void EnTp_Fragment_Fade(EnTp* this, GlobalContext* globalCtx) { - func_8002D7EC(&this->actor); - this->alpha -= 20; - - if (this->alpha < 20) { - this->alpha = 0; - Actor_Kill(&this->actor); - } -} - -void EnTp_Head_SetupTakeOff(EnTp* this) { - this->timer = (Rand_ZeroOne() * 15.0f) + 40.0f; - this->actionIndex = TAILPASARAN_ACTION_HEAD_TAKEOFF; - EnTp_SetupAction(this, EnTp_Head_TakeOff); -} - -/** - * Flies up and loops around until it makes for Player - */ -void EnTp_Head_TakeOff(EnTp* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToF(&this->actor.speedXZ, 2.5f, 0.1f, 0.2f, 0.0f); - Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 85.0f + this->horizontalVariation, 1.0f, - this->actor.speedXZ * 0.25f, 0.0f); - Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - if (&player->actor == this->collider.base.at) { - this->unk_15C = 1; - } - } - - if (this->red != 0) { - this->red -= 15; - } - - if (Math_CosF(this->heightPhase) == 0.0f) { - this->extraHeightVariation = Rand_ZeroOne() * 4.0f; - } - - this->actor.world.pos.y += - Math_CosF(this->heightPhase) * ((this->actor.speedXZ * 0.25f) + this->extraHeightVariation); - this->actor.world.rot.y += this->unk_164; - this->heightPhase += 0.2f; - - if (this->timer != 0) { - this->timer--; - } - - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), 1, 750, - 0); - - if (this->timer == 0) { - EnTp_Head_SetupApproachPlayer(this); - } - - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnTp_Head_SetupWait(EnTp* this) { - this->actionIndex = TAILPASARAN_ACTION_HEAD_WAIT; - this->unk_150 = 0; - this->actor.shape.rot.x = -0x4000; - this->timer = 60; - this->unk_15C = 0; - this->actor.speedXZ = 0.0f; - EnTp_SetupAction(this, EnTp_Head_Wait); -} - -/** - * Awaken and rise from the ground when Player is closer than 200 - */ -void EnTp_Head_Wait(EnTp* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yaw; - - this->unk_15C--; - - if (this->actor.xzDistToPlayer < 200.0f) { - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - if (&player->actor == this->collider.base.at) { - this->timer = 0; - } - } - - if (this->timer != 0) { - this->timer--; - - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 500, 0); - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 1500, 0); - - yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos) + 0x4000; - Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 30.0f, 0.3f, 1.0f, 0.3f); - this->actor.world.pos.x = this->actor.home.pos.x + - (Math_SinS(2000 * this->unk_15C) * (Math_SinS(yaw) * this->horizontalVariation)); - this->actor.world.pos.z = this->actor.home.pos.z + - (Math_SinS(2000 * this->unk_15C) * (Math_CosS(yaw) * this->horizontalVariation)); - } else { - this->actor.shape.rot.x = 0; - this->unk_150 = 1; - EnTp_Head_SetupTakeOff(this); - } - } else { - Math_SmoothStepToS(&this->actor.shape.rot.x, -0x4000, 1, 500, 0); - - if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 1.5f, 0.3f) == 0.0f) { - this->timer = 60; - } else { - yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); - this->actor.world.pos.x = - this->actor.home.pos.x + (Math_SinS(2000 * this->unk_15C) * (Math_SinS(yaw) * 6.0f)); - this->actor.world.pos.z = - this->actor.home.pos.z + (Math_SinS(2000 * this->unk_15C) * (Math_CosS(yaw) * 6.0f)); - } - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (this->actor.world.pos.y != this->actor.home.pos.y) { - Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } -} - -void EnTp_Head_SetupBurrowReturnHome(EnTp* this) { - this->actionIndex = TAILPASARAN_ACTION_HEAD_BURROWRETURNHOME; - this->timer = 0; - EnTp_SetupAction(this, EnTp_Head_BurrowReturnHome); -} - -void EnTp_Head_BurrowReturnHome(EnTp* this, GlobalContext* globalCtx) { - static Vec3f bubbleAccel = { 0.0f, -0.5f, 0.0f }; - static Color_RGBA8 bubblePrimColor = { 255, 255, 255, 255 }; - static Color_RGBA8 bubbleEnvColor = { 150, 150, 150, 0 }; - Vec3f bubbleVelocity; - Vec3f bubblePos; - s32 closeToFloor; - EnTp* now; - s16 temp_v0; // Required to match, usage can maybe be improved - - closeToFloor = false; - temp_v0 = this->timer; - this->unk_15C--; - - if ((temp_v0 != 0) || ((this->actor.home.pos.y - this->actor.world.pos.y) > 60.0f)) { - this->timer = temp_v0 - 1; - temp_v0 = this->timer; - - if (temp_v0 == 0) { - EnTp_Head_SetupWait(this); - - for (now = (EnTp*)this->actor.child; now != NULL; now = (EnTp*)now->actor.child) { - now->unk_15C = now->timer; - } - } else { - if (this->actor.shape.rot.x != -0x4000) { - this->timer = 80; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.pos = this->actor.home.pos; - this->actor.shape.rot.x = -0x4000; - - for (now = (EnTp*)this->actor.child; now != NULL; now = (EnTp*)now->actor.child) { - now->actor.velocity.y = 0.0f; - now->actor.speedXZ = 0.0f; - now->actor.world.pos = this->actor.home.pos; - now->actor.world.pos.y = this->actor.home.pos.y - 80.0f; - } - } - - this->actor.world.pos.y = this->actor.home.pos.y - this->timer; - } - } else { - if (this->actor.shape.rot.x != 0x4000) { - this->actor.shape.rot.x -= 0x400; - } - - if (this->red != 0) { - this->red -= 15; - } - - this->actor.speedXZ = 2.0f * Math_CosS(this->actor.shape.rot.x); - this->actor.velocity.y = Math_SinS(this->actor.shape.rot.x) * -2.0f; - - if ((this->actor.world.pos.y - this->actor.floorHeight) < 20.0f) { - closeToFloor = true; - } - - if (this->actor.world.pos.y != this->actor.home.pos.y) { - Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - - if (closeToFloor && ((globalCtx->gameplayFrames & 1) != 0)) { - bubblePos = this->actor.world.pos; - bubblePos.y = this->actor.floorHeight; - - bubbleVelocity.x = Rand_CenteredFloat(5.0f); - bubbleVelocity.y = (Rand_ZeroOne() * 3.5f) + 1.5f; - bubbleVelocity.z = Rand_CenteredFloat(5.0f); - - EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &bubbleVelocity, &bubbleAccel, &bubblePrimColor, - &bubbleEnvColor, Rand_S16Offset(100, 50), 20, 0); - } - } -} - -void EnTp_UpdateDamage(EnTp* this, GlobalContext* globalCtx) { - s32 phi_s2; - s32 phi_s4; - EnTp* head; // Can eliminate this and just use now, but they're used differently - EnTp* now; - - if ((this->collider.base.acFlags & AC_HIT) && (this->actionIndex >= TAILPASARAN_ACTION_TAIL_FOLLOWHEAD)) { - phi_s4 = phi_s2 = 0; - - if (this->actor.params <= TAILPASARAN_HEAD) { - phi_s2 = 1; - } - - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlagJntSph(&this->actor, &this->collider, 1); - this->damageEffect = this->actor.colChkInfo.damageEffect; - - if (this->actor.colChkInfo.damageEffect != TAILPASARAN_DMGEFF_NONE) { - if (this->actor.colChkInfo.damageEffect == TAILPASARAN_DMGEFF_DEKUNUT) { - phi_s4 = 1; - } - - // Head is invincible - if (phi_s2 == 0) { - Actor_ApplyDamage(&this->actor); - } - - if (this->actor.colChkInfo.health == 0) { - this->actor.flags &= ~ACTOR_FLAG_0; - head = this->head; - - if (head->actor.params <= TAILPASARAN_HEAD) { - EnTp_SetupDie(head); - head->damageEffect = this->actor.colChkInfo.damageEffect; - head->actor.params = TAILPASARAN_HEAD_DYING; - } - } else { - if (phi_s4 != 0) { - this->actor.freezeTimer = 80; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - if (phi_s2 != 0) { - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); - } else { - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0x2000, 0x50); - } - } - - for (now = (EnTp*)this->actor.parent; now != NULL; now = (EnTp*)now->actor.parent) { - now->collider.base.acFlags &= ~AC_HIT; - - if (phi_s4 != 0) { - now->actor.freezeTimer = 80; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - - if (phi_s2 != 0) { - Actor_SetColorFilter(&now->actor, 0, 0xFF, 0, 0x50); - } else { - Actor_SetColorFilter(&now->actor, 0, 0xFF, 0x2000, 0x50); - } - } - } - - for (now = (EnTp*)this->actor.child; now != NULL; now = (EnTp*)now->actor.child) { - now->collider.base.acFlags &= ~AC_HIT; - if (phi_s4 != 0) { - now->actor.freezeTimer = 80; - - if (phi_s2 != 0) { - Actor_SetColorFilter(&now->actor, 0, 0xFF, 0, 0x50); - } else { - Actor_SetColorFilter(&now->actor, 0, 0xFF, 0x2000, 0x50); - } - } - } - } - } - } -} - -void EnTp_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnTp* this = (EnTp*)thisx; - Vec3f kiraVelocity = { 0.0f, 0.0f, 0.0f }; - Vec3f kiraAccel = { 0.0f, -0.6f, 0.0f }; - Vec3f kiraPos; - Color_RGBA8 kiraPrimColor = { 0, 0, 255, 255 }; - Color_RGBA8 kiraEnvColor = { 0, 0, 0, 0 }; - Player* player = GET_PLAYER(globalCtx); - s16 yawToWall; - - if (player->stateFlags1 & 0x4000000) { // Shielding - this->damageEffect = TAILPASARAN_DMGEFF_NONE; - } - - if (this->actor.colChkInfo.health != 0) { - EnTp_UpdateDamage(this, globalCtx); - } - - this->actionFunc(this, globalCtx); - - if (this->actor.params <= TAILPASARAN_HEAD) { - Actor_MoveForward(&this->actor); - - if (this->actionIndex != TAILPASARAN_ACTION_HEAD_BURROWRETURNHOME) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 15.0f, 10.0f, 5); - } - - // Turn away from wall - if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { - yawToWall = this->actor.wallYaw - this->actor.world.rot.y; - - if (ABS(yawToWall) > 0x4000) { - if (yawToWall >= 0) { - this->actor.world.rot.y -= 500; - } else { - this->actor.world.rot.y += 500; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; - } - } - - this->actor.shape.rot.z += 0x800; - - if (this->actor.shape.rot.z == 0) { - Audio_PlaySoundGeneral(NA_SE_EN_TAIL_CRY, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - - if (this->actionIndex >= TAILPASARAN_ACTION_TAIL_FOLLOWHEAD) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - if (this->actor.params != TAILPASARAN_TAIL_DYING) { - this->kiraSpawnTimer--; - this->kiraSpawnTimer &= 7; - } - - this->actor.focus.pos = this->actor.world.pos; - - if (this->damageEffect == TAILPASARAN_DMGEFF_SHOCKING) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if ((this->kiraSpawnTimer & 7) == 0) { - kiraPrimColor.r = this->red; - kiraAccel.x = -this->actor.velocity.x * 0.25f; - kiraAccel.y = -this->actor.velocity.y * 0.25f; - kiraAccel.z = -this->actor.velocity.z * 0.25f; - kiraPos.x = ((Rand_ZeroOne() - 0.5f) * 25.0f) + this->actor.world.pos.x; - kiraPos.y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + this->actor.world.pos.y; - kiraPos.z = ((Rand_ZeroOne() - 0.5f) * 25.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnSmall(globalCtx, &kiraPos, &kiraVelocity, &kiraAccel, &kiraPrimColor, &kiraEnvColor); - } - - if ((this->actionIndex >= TAILPASARAN_ACTION_TAIL_FOLLOWHEAD) && (this->actor.colChkInfo.health != 0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void EnTp_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnTp* this = (EnTp*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tp.c", 1451); - - if (this->unk_150 != 2) { - if ((thisx->params <= TAILPASARAN_HEAD) || (thisx->params == TAILPASARAN_HEAD_DYING)) { - func_80093D18(globalCtx->state.gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_tp.c", 1459), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gTailpasaranHeadDL); - - Matrix_Translate(0.0f, 0.0f, 8.0f, MTXMODE_APPLY); - } else { - func_80093D84(globalCtx->state.gfxCtx); - func_800D1FD4(&globalCtx->billboardMtxF); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->red, 0, 255, this->alpha); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, - TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, - TEXEL0, ENVIRONMENT); - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gTailpasaranTailSegmentTex)); - gDPPipeSync(POLY_XLU_DISP++); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_tp.c", 1480), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gTailpasaranTailSegmentDL); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tp.c", 1495); - - if ((thisx->params <= TAILPASARAN_TAIL) || (thisx->params == TAILPASARAN_TAIL_DYING)) { - Collider_UpdateSpheres(0, &this->collider); - } -} diff --git a/src/overlays/actors/ovl_En_Tp/z_en_tp.cpp b/src/overlays/actors/ovl_En_Tp/z_en_tp.cpp new file mode 100644 index 000000000..7f2377552 --- /dev/null +++ b/src/overlays/actors/ovl_En_Tp/z_en_tp.cpp @@ -0,0 +1,778 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TP_Z_EN_TP_C +#include "actor_common.h" +/* + * File: z_en_tp.c + * Overlay: ovl_En_Tp + * Description: Electric Tailpasaran + */ + +#include "z_en_tp.h" +#include "objects/object_tp/object_tp.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/sys_math.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS 0 + +void EnTp_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTp_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTp_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTp_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnTp_Tail_SetupFollowHead(EnTp* pthis); +void EnTp_Tail_FollowHead(EnTp* pthis, GlobalContext* globalCtx); +void EnTp_Head_SetupApproachPlayer(EnTp* pthis); +void EnTp_Head_ApproachPlayer(EnTp* pthis, GlobalContext* globalCtx); +void EnTp_SetupDie(EnTp* pthis); +void EnTp_Die(EnTp* pthis, GlobalContext* globalCtx); +void EnTp_Fragment_SetupFade(EnTp* pthis); +void EnTp_Fragment_Fade(EnTp* pthis, GlobalContext* globalCtx); +void EnTp_Head_SetupTakeOff(EnTp* pthis); +void EnTp_Head_TakeOff(EnTp* pthis, GlobalContext* globalCtx); +void EnTp_Head_SetupWait(EnTp* pthis); +void EnTp_Head_Wait(EnTp* pthis, GlobalContext* globalCtx); +void EnTp_Head_SetupBurrowReturnHome(EnTp* pthis); +void EnTp_Head_BurrowReturnHome(EnTp* pthis, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ TAILPASARAN_ACTION_FRAGMENT_FADE, + /* 1 */ TAILPASARAN_ACTION_DIE, + /* 2 */ TAILPASARAN_ACTION_TAIL_FOLLOWHEAD, + /* 4 */ TAILPASARAN_ACTION_HEAD_WAIT = 4, + /* 7 */ TAILPASARAN_ACTION_HEAD_APPROACHPLAYER = 7, + /* 8 */ TAILPASARAN_ACTION_HEAD_TAKEOFF, + /* 9 */ TAILPASARAN_ACTION_HEAD_BURROWRETURNHOME +} TailpasaranAction; + +ActorInit En_Tp_InitVars = { + ACTOR_EN_TP, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_TP, + sizeof(EnTp), + (ActorFunc)EnTp_Init, + (ActorFunc)EnTp_Destroy, + (ActorFunc)EnTp_Update, + (ActorFunc)EnTp_Draw, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x03, 0x08 }, + { 0xFFCFFFFF, 0x01, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 0, { { 0, 0, 0 }, 4 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT1, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +typedef enum { + /* 00 */ TAILPASARAN_DMGEFF_NONE, + /* 01 */ TAILPASARAN_DMGEFF_DEKUNUT, + /* 14 */ TAILPASARAN_DMGEFF_SHOCKING = 14, // Kills the Tailpasaran but shocks Player + /* 15 */ TAILPASARAN_DMGEFF_INSULATING // Kills the Tailpasaran and does not shock Player +} TailpasaranDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_DEKUNUT), + /* Deku stick */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_INSULATING), + /* Slingshot */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Explosive */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(1, TAILPASARAN_DMGEFF_INSULATING), + /* Normal arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), + /* Hookshot */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Kokiri sword */ DMG_ENTRY(1, TAILPASARAN_DMGEFF_SHOCKING), + /* Master sword */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), + /* Giant's Knife */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), + /* Fire arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Unk arrow 1 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Ice magic */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Light magic */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Shield */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, TAILPASARAN_DMGEFF_SHOCKING), + /* Giant spin */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), + /* Master spin */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), + /* Kokiri jump */ DMG_ENTRY(2, TAILPASARAN_DMGEFF_SHOCKING), + /* Giant jump */ DMG_ENTRY(8, TAILPASARAN_DMGEFF_SHOCKING), + /* Master jump */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), + /* Unknown 1 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, TAILPASARAN_DMGEFF_SHOCKING), + /* Unknown 2 */ DMG_ENTRY(0, TAILPASARAN_DMGEFF_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), +}; + +void EnTp_SetupAction(EnTp* pthis, EnTpActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnTp_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTp* pthis = (EnTp*)thisx; + EnTp* now; + EnTp* next; + s32 i; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.targetMode = 3; + pthis->actor.colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.14f); + pthis->unk_150 = 0; + pthis->actor.colChkInfo.health = 1; + now = pthis; + pthis->alpha = 255; + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + + if (pthis->actor.params <= TAILPASARAN_HEAD) { + pthis->actor.naviEnemyId = 0x06; + pthis->timer = 0; + pthis->collider.base.acFlags |= AC_HARD; + pthis->collider.elements->dim.modelSphere.radius = pthis->collider.elements->dim.worldSphere.radius = 8; + EnTp_Head_SetupWait(pthis); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4; + Actor_SetScale(&pthis->actor, 1.5f); + + for (i = 0; i <= 6; i++) { + next = (EnTp*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TP, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0 * i); + + if (0 * i) {} // Very fake, but needed to get the s registers right + if (next != NULL) { + now->actor.child = &next->actor; + next->actor.parent = &now->actor; + next->kiraSpawnTimer = i + 1; + next->head = pthis; + Actor_SetScale(&next->actor, 0.3f); + + if (i == 2) { + next->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4; + next->unk_150 = 1; // Why? + } + + next->timer = next->unk_15C = i * -5; + next->horizontalVariation = 6.0f - (i * 0.75f); + now = next; + if (0 * i) {} + } + } + } else if (pthis->actor.params == TAILPASARAN_TAIL) { + EnTp_Tail_SetupFollowHead(pthis); + } else { + EnTp_Fragment_SetupFade(pthis); + } +} + +void EnTp_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTp* pthis = (EnTp*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void EnTp_Tail_SetupFollowHead(EnTp* pthis) { + pthis->actionIndex = TAILPASARAN_ACTION_TAIL_FOLLOWHEAD; + EnTp_SetupAction(pthis, EnTp_Tail_FollowHead); +} + +void EnTp_Tail_FollowHead(EnTp* pthis, GlobalContext* globalCtx) { + s16 angle; + s16 phase; + + if (pthis->actor.params == TAILPASARAN_TAIL_DYING) { + pthis->actionIndex = TAILPASARAN_ACTION_DIE; + + if (pthis->actor.parent == NULL) { + EnTp_SetupDie(pthis); + } + } else { + if (pthis->unk_150 != 0) { + pthis->actor.flags |= ACTOR_FLAG_0; + } + + if (pthis->head->unk_150 != 0) { + pthis->actor.speedXZ = pthis->red = pthis->actor.velocity.y = pthis->heightPhase = 0.0f; + if (pthis->actor.world.pos.y < pthis->head->actor.home.pos.y) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + } + + pthis->actor.world.pos = pthis->actor.parent->prevPos; + } else { + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.parent->world.pos.y - 4.0f, 1.0f, 1.0f, 0.0f); + angle = pthis->head->actor.shape.rot.y + 0x4000; + phase = 2000 * (pthis->head->unk_15C + pthis->timer); + pthis->actor.world.pos.x = + pthis->actor.home.pos.x + Math_SinS(phase) * (Math_SinS(angle) * pthis->horizontalVariation); + pthis->actor.world.pos.z = + pthis->actor.home.pos.z + Math_SinS(phase) * (Math_CosS(angle) * pthis->horizontalVariation); + } + } +} + +void EnTp_Head_SetupApproachPlayer(EnTp* pthis) { + pthis->actionIndex = TAILPASARAN_ACTION_HEAD_APPROACHPLAYER; + pthis->timer = 200; + EnTp_SetupAction(pthis, EnTp_Head_ApproachPlayer); +} + +void EnTp_Head_ApproachPlayer(EnTp* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.world.pos.y, player->actor.world.pos.y + 30.0f, 1.0f, 0.5f, 0.0f); + Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + if (&player->actor == pthis->collider.base.at) { + pthis->timer = 1; + } + } + + if (pthis->red < 255) { + pthis->red += 15; + } + + if (Math_CosF(pthis->heightPhase) == 0.0f) { + pthis->extraHeightVariation = 2.0f * Rand_ZeroOne(); + } + + pthis->actor.world.pos.y += Math_CosF(pthis->heightPhase) * (2.0f + pthis->extraHeightVariation); + pthis->heightPhase += 0.2f; + Math_SmoothStepToF(&pthis->actor.speedXZ, 2.5f, 0.1f, 0.2f, 0.0f); + pthis->timer--; + + if (pthis->timer != 0) { + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 750, 0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } else { + EnTp_Head_SetupBurrowReturnHome(pthis); + } +} + +void EnTp_SetupDie(EnTp* pthis) { + Actor* now; + + pthis->timer = 2; + + if (pthis->actor.params <= TAILPASARAN_HEAD) { + for (now = pthis->actor.child; now != NULL; now = now->child) { + now->params = TAILPASARAN_TAIL_DYING; + now->colChkInfo.health = 0; + } + + pthis->timer = 13; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TAIL_DEAD); + } + pthis->actionIndex = TAILPASARAN_ACTION_DIE; + EnTp_SetupAction(pthis, EnTp_Die); +} + +/** + * Spawns effects and smaller tail segment-like fragments + */ +void EnTp_Die(EnTp* pthis, GlobalContext* globalCtx) { + EnTp* now; + s16 i; + s32 pad; + Vec3f effectVelAccel = { 0.0f, 0.5f, 0.0f }; + Vec3f effectPos = { 0.0f, 0.0f, 0.0f }; + + pthis->timer--; + + if (pthis->timer <= 0) { + if (pthis->actor.params == TAILPASARAN_HEAD_DYING) { + effectPos.x = ((Rand_ZeroOne() - 0.5f) * 15.0f) + pthis->actor.world.pos.x; + effectPos.z = ((Rand_ZeroOne() - 0.5f) * 15.0f) + pthis->actor.world.pos.z; + effectPos.y = ((Rand_ZeroOne() - 0.5f) * 5.0f) + pthis->actor.world.pos.y; + EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVelAccel, &effectVelAccel, 100, 0, 255, 255, 255, 255, 0, + 0, 255, 1, 9, 1); + + effectPos.x = ((Rand_ZeroOne() - 0.5f) * 15.0f) + pthis->actor.world.pos.x; + effectPos.z = ((Rand_ZeroOne() - 0.5f) * 15.0f) + pthis->actor.world.pos.z; + effectPos.y = ((Rand_ZeroOne() - 0.5f) * 5.0f) + pthis->actor.world.pos.y; + EffectSsDeadDb_Spawn(globalCtx, &effectPos, &effectVelAccel, &effectVelAccel, 100, 0, 255, 255, 255, 255, 0, + 0, 255, 1, 9, 1); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x50); + } else { + for (i = 0; i < 1; i++) { + now = + (EnTp*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TP, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, TAILPASARAN_FRAGMENT); + + if (now != NULL) { + Actor_SetScale(&now->actor, pthis->actor.scale.z * 0.5f); + now->red = pthis->red; + } + } + } + + if (pthis->actor.child != NULL) { + pthis->actor.child->parent = NULL; + pthis->actor.child->params = TAILPASARAN_TAIL_DYING; + pthis->actor.child->colChkInfo.health = 0; + } + + pthis->unk_150 = 2; + Actor_Kill(&pthis->actor); + } +} + +void EnTp_Fragment_SetupFade(EnTp* pthis) { + pthis->actionIndex = TAILPASARAN_ACTION_FRAGMENT_FADE; + pthis->actor.world.pos.x += ((Rand_ZeroOne() - 0.5f) * 5.0f); + pthis->actor.world.pos.y += ((Rand_ZeroOne() - 0.5f) * 5.0f); + pthis->actor.world.pos.z += ((Rand_ZeroOne() - 0.5f) * 5.0f); + pthis->actor.velocity.x = (Rand_ZeroOne() - 0.5f) * 1.5f; + pthis->actor.velocity.y = (Rand_ZeroOne() - 0.5f) * 1.5f; + pthis->actor.velocity.z = (Rand_ZeroOne() - 0.5f) * 1.5f; + pthis->actor.flags &= ~ACTOR_FLAG_0; + EnTp_SetupAction(pthis, EnTp_Fragment_Fade); +} + +void EnTp_Fragment_Fade(EnTp* pthis, GlobalContext* globalCtx) { + func_8002D7EC(&pthis->actor); + pthis->alpha -= 20; + + if (pthis->alpha < 20) { + pthis->alpha = 0; + Actor_Kill(&pthis->actor); + } +} + +void EnTp_Head_SetupTakeOff(EnTp* pthis) { + pthis->timer = (Rand_ZeroOne() * 15.0f) + 40.0f; + pthis->actionIndex = TAILPASARAN_ACTION_HEAD_TAKEOFF; + EnTp_SetupAction(pthis, EnTp_Head_TakeOff); +} + +/** + * Flies up and loops around until it makes for Player + */ +void EnTp_Head_TakeOff(EnTp* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToF(&pthis->actor.speedXZ, 2.5f, 0.1f, 0.2f, 0.0f); + Math_SmoothStepToF(&pthis->actor.world.pos.y, player->actor.world.pos.y + 85.0f + pthis->horizontalVariation, 1.0f, + pthis->actor.speedXZ * 0.25f, 0.0f); + Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + if (&player->actor == pthis->collider.base.at) { + pthis->unk_15C = 1; + } + } + + if (pthis->red != 0) { + pthis->red -= 15; + } + + if (Math_CosF(pthis->heightPhase) == 0.0f) { + pthis->extraHeightVariation = Rand_ZeroOne() * 4.0f; + } + + pthis->actor.world.pos.y += + Math_CosF(pthis->heightPhase) * ((pthis->actor.speedXZ * 0.25f) + pthis->extraHeightVariation); + pthis->actor.world.rot.y += pthis->unk_164; + pthis->heightPhase += 0.2f; + + if (pthis->timer != 0) { + pthis->timer--; + } + + Math_SmoothStepToS(&pthis->actor.world.rot.y, Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->actor.home.pos), 1, 750, + 0); + + if (pthis->timer == 0) { + EnTp_Head_SetupApproachPlayer(pthis); + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnTp_Head_SetupWait(EnTp* pthis) { + pthis->actionIndex = TAILPASARAN_ACTION_HEAD_WAIT; + pthis->unk_150 = 0; + pthis->actor.shape.rot.x = -0x4000; + pthis->timer = 60; + pthis->unk_15C = 0; + pthis->actor.speedXZ = 0.0f; + EnTp_SetupAction(pthis, EnTp_Head_Wait); +} + +/** + * Awaken and rise from the ground when Player is closer than 200 + */ +void EnTp_Head_Wait(EnTp* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yaw; + + pthis->unk_15C--; + + if (pthis->actor.xzDistToPlayer < 200.0f) { + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + if (&player->actor == pthis->collider.base.at) { + pthis->timer = 0; + } + } + + if (pthis->timer != 0) { + pthis->timer--; + + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 500, 0); + Math_SmoothStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer, 1, 1500, 0); + + yaw = Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos) + 0x4000; + Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 30.0f, 0.3f, 1.0f, 0.3f); + pthis->actor.world.pos.x = pthis->actor.home.pos.x + + (Math_SinS(2000 * pthis->unk_15C) * (Math_SinS(yaw) * pthis->horizontalVariation)); + pthis->actor.world.pos.z = pthis->actor.home.pos.z + + (Math_SinS(2000 * pthis->unk_15C) * (Math_CosS(yaw) * pthis->horizontalVariation)); + } else { + pthis->actor.shape.rot.x = 0; + pthis->unk_150 = 1; + EnTp_Head_SetupTakeOff(pthis); + } + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.x, -0x4000, 1, 500, 0); + + if (Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.3f, 1.5f, 0.3f) == 0.0f) { + pthis->timer = 60; + } else { + yaw = Math_Vec3f_Yaw(&pthis->actor.home.pos, &player->actor.world.pos); + pthis->actor.world.pos.x = + pthis->actor.home.pos.x + (Math_SinS(2000 * pthis->unk_15C) * (Math_SinS(yaw) * 6.0f)); + pthis->actor.world.pos.z = + pthis->actor.home.pos.z + (Math_SinS(2000 * pthis->unk_15C) * (Math_CosS(yaw) * 6.0f)); + } + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (pthis->actor.world.pos.y != pthis->actor.home.pos.y) { + Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } +} + +void EnTp_Head_SetupBurrowReturnHome(EnTp* pthis) { + pthis->actionIndex = TAILPASARAN_ACTION_HEAD_BURROWRETURNHOME; + pthis->timer = 0; + EnTp_SetupAction(pthis, EnTp_Head_BurrowReturnHome); +} + +void EnTp_Head_BurrowReturnHome(EnTp* pthis, GlobalContext* globalCtx) { + static Vec3f bubbleAccel = { 0.0f, -0.5f, 0.0f }; + static Color_RGBA8 bubblePrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 bubbleEnvColor = { 150, 150, 150, 0 }; + Vec3f bubbleVelocity; + Vec3f bubblePos; + s32 closeToFloor; + EnTp* now; + s16 temp_v0; // Required to match, usage can maybe be improved + + closeToFloor = false; + temp_v0 = pthis->timer; + pthis->unk_15C--; + + if ((temp_v0 != 0) || ((pthis->actor.home.pos.y - pthis->actor.world.pos.y) > 60.0f)) { + pthis->timer = temp_v0 - 1; + temp_v0 = pthis->timer; + + if (temp_v0 == 0) { + EnTp_Head_SetupWait(pthis); + + for (now = (EnTp*)pthis->actor.child; now != NULL; now = (EnTp*)now->actor.child) { + now->unk_15C = now->timer; + } + } else { + if (pthis->actor.shape.rot.x != -0x4000) { + pthis->timer = 80; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.pos = pthis->actor.home.pos; + pthis->actor.shape.rot.x = -0x4000; + + for (now = (EnTp*)pthis->actor.child; now != NULL; now = (EnTp*)now->actor.child) { + now->actor.velocity.y = 0.0f; + now->actor.speedXZ = 0.0f; + now->actor.world.pos = pthis->actor.home.pos; + now->actor.world.pos.y = pthis->actor.home.pos.y - 80.0f; + } + } + + pthis->actor.world.pos.y = pthis->actor.home.pos.y - pthis->timer; + } + } else { + if (pthis->actor.shape.rot.x != 0x4000) { + pthis->actor.shape.rot.x -= 0x400; + } + + if (pthis->red != 0) { + pthis->red -= 15; + } + + pthis->actor.speedXZ = 2.0f * Math_CosS(pthis->actor.shape.rot.x); + pthis->actor.velocity.y = Math_SinS(pthis->actor.shape.rot.x) * -2.0f; + + if ((pthis->actor.world.pos.y - pthis->actor.floorHeight) < 20.0f) { + closeToFloor = true; + } + + if (pthis->actor.world.pos.y != pthis->actor.home.pos.y) { + Audio_PlaySoundGeneral(NA_SE_EN_TAIL_FLY - SFX_FLAG, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + + if (closeToFloor && ((globalCtx->gameplayFrames & 1) != 0)) { + bubblePos = pthis->actor.world.pos; + bubblePos.y = pthis->actor.floorHeight; + + bubbleVelocity.x = Rand_CenteredFloat(5.0f); + bubbleVelocity.y = (Rand_ZeroOne() * 3.5f) + 1.5f; + bubbleVelocity.z = Rand_CenteredFloat(5.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &bubbleVelocity, &bubbleAccel, &bubblePrimColor, + &bubbleEnvColor, Rand_S16Offset(100, 50), 20, 0); + } + } +} + +void EnTp_UpdateDamage(EnTp* pthis, GlobalContext* globalCtx) { + s32 phi_s2; + s32 phi_s4; + EnTp* head; // Can eliminate pthis and just use now, but they're used differently + EnTp* now; + + if ((pthis->collider.base.acFlags & AC_HIT) && (pthis->actionIndex >= TAILPASARAN_ACTION_TAIL_FOLLOWHEAD)) { + phi_s4 = phi_s2 = 0; + + if (pthis->actor.params <= TAILPASARAN_HEAD) { + phi_s2 = 1; + } + + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlagJntSph(&pthis->actor, &pthis->collider, 1); + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + + if (pthis->actor.colChkInfo.damageEffect != TAILPASARAN_DMGEFF_NONE) { + if (pthis->actor.colChkInfo.damageEffect == TAILPASARAN_DMGEFF_DEKUNUT) { + phi_s4 = 1; + } + + // Head is invincible + if (phi_s2 == 0) { + Actor_ApplyDamage(&pthis->actor); + } + + if (pthis->actor.colChkInfo.health == 0) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + head = pthis->head; + + if (head->actor.params <= TAILPASARAN_HEAD) { + EnTp_SetupDie(head); + head->damageEffect = pthis->actor.colChkInfo.damageEffect; + head->actor.params = TAILPASARAN_HEAD_DYING; + } + } else { + if (phi_s4 != 0) { + pthis->actor.freezeTimer = 80; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + if (phi_s2 != 0) { + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); + } else { + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0x2000, 0x50); + } + } + + for (now = (EnTp*)pthis->actor.parent; now != NULL; now = (EnTp*)now->actor.parent) { + now->collider.base.acFlags &= ~AC_HIT; + + if (phi_s4 != 0) { + now->actor.freezeTimer = 80; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + + if (phi_s2 != 0) { + Actor_SetColorFilter(&now->actor, 0, 0xFF, 0, 0x50); + } else { + Actor_SetColorFilter(&now->actor, 0, 0xFF, 0x2000, 0x50); + } + } + } + + for (now = (EnTp*)pthis->actor.child; now != NULL; now = (EnTp*)now->actor.child) { + now->collider.base.acFlags &= ~AC_HIT; + if (phi_s4 != 0) { + now->actor.freezeTimer = 80; + + if (phi_s2 != 0) { + Actor_SetColorFilter(&now->actor, 0, 0xFF, 0, 0x50); + } else { + Actor_SetColorFilter(&now->actor, 0, 0xFF, 0x2000, 0x50); + } + } + } + } + } + } +} + +void EnTp_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTp* pthis = (EnTp*)thisx; + Vec3f kiraVelocity = { 0.0f, 0.0f, 0.0f }; + Vec3f kiraAccel = { 0.0f, -0.6f, 0.0f }; + Vec3f kiraPos; + Color_RGBA8 kiraPrimColor = { 0, 0, 255, 255 }; + Color_RGBA8 kiraEnvColor = { 0, 0, 0, 0 }; + Player* player = GET_PLAYER(globalCtx); + s16 yawToWall; + + if (player->stateFlags1 & 0x4000000) { // Shielding + pthis->damageEffect = TAILPASARAN_DMGEFF_NONE; + } + + if (pthis->actor.colChkInfo.health != 0) { + EnTp_UpdateDamage(pthis, globalCtx); + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.params <= TAILPASARAN_HEAD) { + Actor_MoveForward(&pthis->actor); + + if (pthis->actionIndex != TAILPASARAN_ACTION_HEAD_BURROWRETURNHOME) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 15.0f, 10.0f, 5); + } + + // Turn away from wall + if ((pthis->actor.speedXZ != 0.0f) && (pthis->actor.bgCheckFlags & 8)) { + yawToWall = pthis->actor.wallYaw - pthis->actor.world.rot.y; + + if (ABS(yawToWall) > 0x4000) { + if (yawToWall >= 0) { + pthis->actor.world.rot.y -= 500; + } else { + pthis->actor.world.rot.y += 500; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + } + } + + pthis->actor.shape.rot.z += 0x800; + + if (pthis->actor.shape.rot.z == 0) { + Audio_PlaySoundGeneral(NA_SE_EN_TAIL_CRY, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + + if (pthis->actionIndex >= TAILPASARAN_ACTION_TAIL_FOLLOWHEAD) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + if (pthis->actor.params != TAILPASARAN_TAIL_DYING) { + pthis->kiraSpawnTimer--; + pthis->kiraSpawnTimer &= 7; + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + + if (pthis->damageEffect == TAILPASARAN_DMGEFF_SHOCKING) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if ((pthis->kiraSpawnTimer & 7) == 0) { + kiraPrimColor.r = pthis->red; + kiraAccel.x = -pthis->actor.velocity.x * 0.25f; + kiraAccel.y = -pthis->actor.velocity.y * 0.25f; + kiraAccel.z = -pthis->actor.velocity.z * 0.25f; + kiraPos.x = ((Rand_ZeroOne() - 0.5f) * 25.0f) + pthis->actor.world.pos.x; + kiraPos.y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + pthis->actor.world.pos.y; + kiraPos.z = ((Rand_ZeroOne() - 0.5f) * 25.0f) + pthis->actor.world.pos.z; + EffectSsKiraKira_SpawnSmall(globalCtx, &kiraPos, &kiraVelocity, &kiraAccel, &kiraPrimColor, &kiraEnvColor); + } + + if ((pthis->actionIndex >= TAILPASARAN_ACTION_TAIL_FOLLOWHEAD) && (pthis->actor.colChkInfo.health != 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void EnTp_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTp* pthis = (EnTp*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tp.c", 1451); + + if (pthis->unk_150 != 2) { + if ((thisx->params <= TAILPASARAN_HEAD) || (thisx->params == TAILPASARAN_HEAD_DYING)) { + func_80093D18(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_tp.c", 1459), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gTailpasaranHeadDL); + + Matrix_Translate(0.0f, 0.0f, 8.0f, MTXMODE_APPLY); + } else { + func_80093D84(globalCtx->state.gfxCtx); + func_800D1FD4(&globalCtx->billboardMtxF); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->red, 0, 255, pthis->alpha); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, + TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, + TEXEL0, ENVIRONMENT); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gTailpasaranTailSegmentTex)); + gDPPipeSync(POLY_XLU_DISP++); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_tp.c", 1480), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gTailpasaranTailSegmentDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tp.c", 1495); + + if ((thisx->params <= TAILPASARAN_TAIL) || (thisx->params == TAILPASARAN_TAIL_DYING)) { + Collider_UpdateSpheres(0, &pthis->collider); + } +} diff --git a/src/overlays/actors/ovl_En_Tr/z_en_tr.c b/src/overlays/actors/ovl_En_Tr/z_en_tr.c deleted file mode 100644 index df8d83e77..000000000 --- a/src/overlays/actors/ovl_En_Tr/z_en_tr.c +++ /dev/null @@ -1,541 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TR_Z_EN_TR_C -#include "actor_common.h" -/* - * File: z_en_tr.c - * Overlay: ovl_En_Tr - * Description: Koume and Kotake - */ - -#include "z_en_tr.h" -#include "objects/object_tr/object_tr.h" -#include "def/code_800F7260.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnTr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTr_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTr_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnTr_DoNothing(EnTr* this, GlobalContext* globalCtx); -void EnTr_ShrinkVanish(EnTr* this, GlobalContext* globalCtx); -void EnTr_WaitToReappear(EnTr* this, GlobalContext* globalCtx); -void EnTr_ChooseAction1(EnTr* this, GlobalContext* globalCtx); - -void EnTr_UpdateRotation(EnTr* this, GlobalContext* globalCtx, s32 actionIndex); -void func_80B24038(EnTr* this, GlobalContext* globalCtx, s32 actionIndex); -void EnTr_SetStartPosRot(EnTr* this, GlobalContext* globalCtx, s32 actionIndex); - -const ActorInit En_Tr_InitVars = { - ACTOR_EN_TR, - ACTORCAT_NPC, - FLAGS, - OBJECT_TR, - sizeof(EnTr), - (ActorFunc)EnTr_Init, - (ActorFunc)EnTr_Destroy, - (ActorFunc)EnTr_Update, - (ActorFunc)EnTr_Draw, -}; - -// The first elements of these animation arrays are for Koume, the second for Kotake - -static AnimationHeader* unused[] = { - &object_tr_Anim_003FC8, - &object_tr_Anim_001CDC, -}; - -static AnimationHeader* D_80B24368[] = { - &object_tr_Anim_002BC4, - &object_tr_Anim_000BFC, -}; - -static AnimationHeader* D_80B24370[] = { - &object_tr_Anim_0035CC, - &object_tr_Anim_0013CC, -}; - -static AnimationHeader* D_80B24378[] = { - &object_tr_Anim_0049C8, - &object_tr_Anim_0049C8, -}; - -static AnimationHeader* D_80B24380[] = { - &object_tr_Anim_012E1C, - &object_tr_Anim_012E1C, -}; - -static f32 D_80B24388[] = { 0.0f, 20.0f, -30.0f, 20.0f, -20.0f, -20.0f, 30.0f }; - -static f32 D_80B243A4[] = { 0.0f, 30.0f, 0.0f, -30.0f, 30.0f, -30.0f, 0.0f }; - -// Has to be 1-dimensional to match -static Color_RGBA8 D_80B243C0[4] = { - { 255, 200, 0, 255 }, - { 255, 0, 0, 255 }, - { 255, 255, 255, 255 }, - { 0, 0, 255, 255 }, -}; - -static void* sEyeTextures[] = { - object_tr_Tex_0086D8, - object_tr_Tex_0094D8, - object_tr_Tex_0098D8, -}; - -void EnTr_SetupAction(EnTr* this, EnTrActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnTr_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTr* this = (EnTr*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - EnTr_SetupAction(this, EnTr_DoNothing); - this->unk_2D4 = 0; // Set and not used - this->actor.child = NULL; - Actor_SetScale(&this->actor, 0.01f); - - switch (this->actor.params) { - case TR_KOUME: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tr_Skel_011688, &object_tr_Anim_003FC8, - this->jointTable, this->morphTable, 27); - Animation_PlayOnce(&this->skelAnime, &object_tr_Anim_003FC8); - this->animation = NULL; - EnTr_SetupAction(this, EnTr_ChooseAction1); - this->actionIndex = 3; - break; - - case TR_KOTAKE: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tr_Skel_00C530, &object_tr_Anim_001CDC, - this->jointTable, this->morphTable, 27); - Animation_PlayOnce(&this->skelAnime, &object_tr_Anim_001CDC); - this->animation = NULL; - EnTr_SetupAction(this, EnTr_ChooseAction1); - this->actionIndex = 2; - break; - - default: - ASSERT(0, "0", "../z_en_tr.c", 277); - break; - } -} - -void EnTr_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnTr_CrySpellcast(EnTr* this, GlobalContext* globalCtx) { - if (this->timer == 11) { - // Both cry in the title screen cutscene, but only Kotake in the in-game cutscene - if ((this->actor.params != TR_KOUME) || (gSaveContext.sceneSetupIndex == 6)) { - Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_VOICE, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } - } - - if (this->timer > 0) { - this->timer--; - } else if (this->actor.child != NULL) { - this->actor.child = NULL; - } - func_8002F974(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); -} - -void EnTr_DoNothing(EnTr* this, GlobalContext* globalCtx) { -} - -void EnTr_ChooseAction2(EnTr* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if (globalCtx->csCtx.npcActions[this->actionIndex] != NULL) { - switch (globalCtx->csCtx.npcActions[this->actionIndex]->action) { - - case 4: - Actor_SetScale(&this->actor, 0.01f); - EnTr_SetupAction(this, EnTr_ShrinkVanish); - this->timer = 24; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD2); - break; - - case 6: - Animation_Change(&this->skelAnime, D_80B24380[this->actor.params], 1.0f, 0.0f, - Animation_GetLastFrame(D_80B24380[this->actor.params]), ANIMMODE_ONCE, -5.0f); - EnTr_SetupAction(this, EnTr_CrySpellcast); - this->animation = D_80B24378[this->actor.params]; - this->timer = 39; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, - 0, this->actor.params + 9); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_MASIC1); - break; - - default: - func_80B24038(this, globalCtx, this->actionIndex); - EnTr_UpdateRotation(this, globalCtx, this->actionIndex); - break; - } - func_8002F974(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); - } - } -} - -void EnTr_FlyKidnapCutscene(EnTr* this, GlobalContext* globalCtx) { - Vec3f originalPos = this->actor.world.pos; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if (globalCtx->csCtx.npcActions[this->actionIndex] != NULL) { - if (globalCtx->csCtx.npcActions[this->actionIndex]->action == 8) { - func_80B24038(this, globalCtx, this->actionIndex); - this->actor.world.rot.y = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 10, 0x400, 0x100); - this->actor.world.rot.y = this->actor.shape.rot.y; - } else { - EnTr_SetStartPosRot(this, globalCtx, this->actionIndex); - this->actor.world.pos.x += Math_SinS(this->timer) * 150.0f; - this->actor.world.pos.y += -100.0f; - this->actor.world.pos.z += Math_CosS(this->timer) * 150.0f; - - this->actor.shape.rot.y = (s16)(this->timer) + 0x4000; - this->timer += 0x400; - - this->actor.velocity.x = this->actor.world.pos.x - originalPos.x; - this->actor.velocity.y = this->actor.world.pos.y - originalPos.y; - this->actor.velocity.z = this->actor.world.pos.z - originalPos.z; - } - - if (globalCtx->csCtx.frames < 670) { - func_8002F974(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); - } - } - } -} - -void func_80B23254(EnTr* this, GlobalContext* globalCtx, s32 arg2, f32 arg3, f32 scale) { - Vec3f pos; - Vec3f velocity; - Vec3f accel; - Vec3f sp58; - Color_RGBA8* primColor; - Color_RGBA8* envColor; - Vec3f cameraEye = GET_ACTIVE_CAM(globalCtx)->eye; - s16 yaw = Math_Vec3f_Yaw(&cameraEye, &this->actor.world.pos); - s16 reversePitch = -Math_Vec3f_Pitch(&cameraEye, &this->actor.world.pos); - f32 sp3C; - - accel.x = accel.z = 0.0f; - sp3C = Math_SinS(yaw); - velocity.x = Math_CosS(reversePitch) * (arg3 * sp3C); - velocity.y = Math_SinS(reversePitch) * arg3; - sp3C = Math_CosS(yaw); - velocity.z = Math_CosS(reversePitch) * (arg3 * sp3C); - accel.y = 0.5f; - - primColor = &D_80B243C0[2 * this->actor.params]; - envColor = &D_80B243C0[2 * this->actor.params + 1]; - - sp58 = this->actor.world.pos; - sp58.x -= velocity.x * 10.0f; - sp58.y -= velocity.y * 10.0f; - sp58.z -= velocity.z * 10.0f; - - pos.x = sp58.x + ((D_80B24388[arg2] * scale) * Math_CosS(yaw)); - pos.y = sp58.y + (D_80B243A4[arg2] * scale); - pos.z = sp58.z - ((D_80B24388[arg2] * scale) * Math_SinS(yaw)); - func_8002829C(globalCtx, &pos, &velocity, &accel, primColor, envColor, (s32)(800.0f * scale), (s32)(80.0f * scale)); -} - -void EnTr_ShrinkVanish(EnTr* this, GlobalContext* globalCtx) { - if (this->timer >= 17) { - this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68; - } else { - if (this->timer >= 5) { - Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); - this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68; - } else if (this->timer > 0) { - s32 temp_hi = (this->timer * 2) % 7; - - func_80B23254(this, globalCtx, temp_hi, 5.0f, 0.2f); - func_80B23254(this, globalCtx, (temp_hi + 1) % 7, 5.0f, 0.2f); - Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); - this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68; - } else { - EnTr_SetupAction(this, EnTr_WaitToReappear); - this->actor.draw = NULL; - } - } - - if (this->timer == 4) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BUBLE_DOWN); - } - - if (this->timer > 0) { - this->timer--; - } -} - -void EnTr_Reappear(EnTr* this, GlobalContext* globalCtx) { - if (this->timer >= 31) { - s32 temp_hi = (this->timer * 2) % 7; - - func_80B23254(this, globalCtx, temp_hi, 5.0f, 1.0f); - func_80B23254(this, globalCtx, (temp_hi + 1) % 7, 5.0f, 1.0f); - } else if (this->timer == 30) { - this->actor.draw = EnTr_Draw; - this->actor.shape.rot.y += this->timer * 0x1A6; - } else if (this->timer > 0) { - this->actor.shape.rot.y += this->timer * 0x1A6; - Actor_SetScale(&this->actor, (this->actor.scale.x * 0.8f) + 0.002f); - } else { - EnTr_SetupAction(this, EnTr_ChooseAction2); - Actor_SetScale(&this->actor, 0.01f); - } - - if (this->timer > 0) { - this->timer--; - } - func_8002F974(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); -} - -void EnTr_WaitToReappear(EnTr* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if ((globalCtx->csCtx.npcActions[this->actionIndex] != NULL) && - ((globalCtx->csCtx.npcActions[this->actionIndex]->action == 3) || - (globalCtx->csCtx.npcActions[this->actionIndex]->action == 5))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_TRANSFORM); - this->timer = 34; - EnTr_SetStartPosRot(this, globalCtx, this->actionIndex); - EnTr_SetupAction(this, EnTr_Reappear); - Animation_PlayLoop(&this->skelAnime, &object_tr_Anim_0049C8); - this->animation = NULL; - Actor_SetScale(&this->actor, 0.003f); - } - } -} - -void EnTr_TakeOff(EnTr* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(D_80B24378[this->actor.params]); - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if ((globalCtx->csCtx.npcActions[this->actionIndex] != NULL) && - (globalCtx->csCtx.npcActions[this->actionIndex]->action == 3)) { - Animation_Change(&this->skelAnime, D_80B24378[this->actor.params], 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, - -10.0f); - this->animation = NULL; - EnTr_SetupAction(this, EnTr_ChooseAction2); - } - } -} - -void EnTr_TurnLookOverShoulder(EnTr* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(D_80B24368[this->actor.params]); - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if ((globalCtx->csCtx.npcActions[this->actionIndex] != NULL) && - (globalCtx->csCtx.npcActions[this->actionIndex]->action == 2)) { - Animation_Change(&this->skelAnime, D_80B24368[this->actor.params], 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, - -4.0f); - this->animation = D_80B24370[this->actor.params]; - EnTr_SetupAction(this, EnTr_TakeOff); - } - } -} - -void EnTr_ChooseAction1(EnTr* this, GlobalContext* globalCtx) { - u32 frames = globalCtx->gameplayFrames; - - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - if (globalCtx->csCtx.npcActions[this->actionIndex] != NULL) { - switch (globalCtx->csCtx.npcActions[this->actionIndex]->action) { - case 1: - EnTr_SetStartPosRot(this, globalCtx, this->actionIndex); - EnTr_SetupAction(this, EnTr_TurnLookOverShoulder); - break; - - case 3: - EnTr_SetStartPosRot(this, globalCtx, this->actionIndex); - EnTr_SetupAction(this, EnTr_ChooseAction2); - Animation_PlayLoop(&this->skelAnime, &object_tr_Anim_0049C8); - this->animation = NULL; - break; - - case 4: - EnTr_SetupAction(this, EnTr_WaitToReappear); - this->actor.draw = NULL; - break; - - case 7: - EnTr_SetupAction(this, EnTr_FlyKidnapCutscene); - Animation_PlayLoop(&this->skelAnime, &object_tr_Anim_0049C8); - this->animation = NULL; - this->timer = - ((this->actor.params != TR_KOUME) ? ((u8)frames * 0x400) + 0x8000 : (u8)frames * 0x400); - break; - } - } - } -} - -void EnTr_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnTr* this = (EnTr*)thisx; - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 5); - this->actionFunc(this, globalCtx); - - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->animation != NULL) { - if ((this->animation == &object_tr_Anim_0035CC) || (this->animation == &object_tr_Anim_0013CC)) { - if (this->actor.params != TR_KOUME) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_LAUGH2); - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TWINROBA_LAUGH); - } - Animation_PlayLoop(&this->skelAnime, this->animation); - } else if (this->animation == &object_tr_Anim_0049C8) { - EnTr_SetupAction(this, EnTr_ChooseAction2); - Animation_Change(&this->skelAnime, &object_tr_Anim_0049C8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_tr_Anim_0049C8), ANIMMODE_LOOP, -5.0f); - } else { - Animation_PlayLoop(&this->skelAnime, this->animation); - } - this->animation = NULL; - } else { - this->skelAnime.curFrame = 0.0f; - } - } - Actor_SetFocus(&this->actor, 0.0f); - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - this->eyeIndex = this->blinkTimer; - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; - } -} - -s32 EnTr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Vec3f src = { 2300.0f, 0.0f, -600.0f }; - Vec3f dest = { 0.0f, 0.0f, 0.0f }; - EnTr* this = (EnTr*)thisx; - Actor* child = this->actor.child; - - if ((child != NULL) && (limbIndex == 19)) { - Matrix_MultVec3f(&src, &dest); - dest.x -= (10.0f * Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)))); - dest.z -= (10.0f * Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)))); - child->world.pos = dest; - } - return 0; -} - -void EnTr_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnTr* this = (EnTr*)thisx; - - if (1) {} - - if ((globalCtx->csCtx.state == CS_STATE_IDLE) || (globalCtx->csCtx.npcActions[this->actionIndex] == 0)) { - this->actor.shape.shadowDraw = NULL; - } else { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 840); - func_800943C8(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); - func_8002EBCC(&this->actor, globalCtx, 0); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnTr_OverrideLimbDraw, NULL, this); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 854); - } -} - -f32 func_80B23FDC(GlobalContext* globalCtx, s32 actionIndex) { - f32 phi_f2 = Environment_LerpWeight(globalCtx->csCtx.npcActions[actionIndex]->endFrame, - globalCtx->csCtx.npcActions[actionIndex]->startFrame, globalCtx->csCtx.frames); - phi_f2 = CLAMP_MAX(phi_f2, 1.0f); - return phi_f2; -} - -void func_80B24038(EnTr* this, GlobalContext* globalCtx, s32 actionIndex) { - Vec3f startPos; - Vec3f endPos; - f32 temp_f0; - f32 temp_f0_2; - f32 phi_f12; - - startPos.x = globalCtx->csCtx.npcActions[actionIndex]->startPos.x; - startPos.y = globalCtx->csCtx.npcActions[actionIndex]->startPos.y; - startPos.z = globalCtx->csCtx.npcActions[actionIndex]->startPos.z; - - endPos.x = globalCtx->csCtx.npcActions[actionIndex]->endPos.x; - endPos.y = globalCtx->csCtx.npcActions[actionIndex]->endPos.y; - endPos.z = globalCtx->csCtx.npcActions[actionIndex]->endPos.z; - - temp_f0 = func_80B23FDC(globalCtx, actionIndex); - - startPos.x = ((endPos.x - startPos.x) * temp_f0) + startPos.x; - startPos.y = ((endPos.y - startPos.y) * temp_f0) + startPos.y; - startPos.z = ((endPos.z - startPos.z) * temp_f0) + startPos.z; - - endPos.x = (startPos.x - this->actor.world.pos.x) * 0.1f; - endPos.y = (startPos.y - this->actor.world.pos.y) * 0.1f; - endPos.z = (startPos.z - this->actor.world.pos.z) * 0.1f; - - temp_f0_2 = sqrtf(SQ(endPos.x) + SQ(endPos.y) + SQ(endPos.z)); - phi_f12 = CLAMP(temp_f0_2, 0.0f, 20.0f); - - if ((temp_f0_2 != phi_f12) && (temp_f0_2 != 0.0f)) { - endPos.x *= phi_f12 / temp_f0_2; - endPos.y *= phi_f12 / temp_f0_2; - endPos.z *= phi_f12 / temp_f0_2; - } - - Math_StepToF(&this->actor.velocity.x, endPos.x, 1.0f); - Math_StepToF(&this->actor.velocity.y, endPos.y, 1.0f); - Math_StepToF(&this->actor.velocity.z, endPos.z, 1.0f); - func_8002D7EC(&this->actor); -} - -void EnTr_UpdateRotation(EnTr* this, GlobalContext* globalCtx, s32 actionIndex) { - s16 rotY = globalCtx->csCtx.npcActions[actionIndex]->rot.y; - s32 rotDiff = this->actor.world.rot.y - rotY; - s32 rotSign; - - if (rotDiff < 0) { - rotDiff = -rotDiff; - rotSign = 1; - } else { - rotSign = -1; - } - - if (rotDiff >= 0x8000) { - rotSign = -rotSign; - rotDiff = 0x10000 - rotDiff; - } - - rotDiff *= 0.1f; - - this->actor.world.rot.y += rotDiff * rotSign; - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnTr_SetStartPosRot(EnTr* this, GlobalContext* globalCtx, s32 actionIndex) { - Vec3f startPos; - - startPos.x = globalCtx->csCtx.npcActions[actionIndex]->startPos.x; - startPos.y = globalCtx->csCtx.npcActions[actionIndex]->startPos.y; - startPos.z = globalCtx->csCtx.npcActions[actionIndex]->startPos.z; - - this->actor.world.pos = startPos; - this->actor.world.rot.y = this->actor.shape.rot.y = globalCtx->csCtx.npcActions[actionIndex]->rot.y; -} diff --git a/src/overlays/actors/ovl_En_Tr/z_en_tr.cpp b/src/overlays/actors/ovl_En_Tr/z_en_tr.cpp new file mode 100644 index 000000000..bc8b6ad18 --- /dev/null +++ b/src/overlays/actors/ovl_En_Tr/z_en_tr.cpp @@ -0,0 +1,541 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TR_Z_EN_TR_C +#include "actor_common.h" +/* + * File: z_en_tr.c + * Overlay: ovl_En_Tr + * Description: Koume and Kotake + */ + +#include "z_en_tr.h" +#include "objects/object_tr/object_tr.h" +#include "def/code_800F7260.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnTr_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTr_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTr_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTr_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnTr_DoNothing(EnTr* pthis, GlobalContext* globalCtx); +void EnTr_ShrinkVanish(EnTr* pthis, GlobalContext* globalCtx); +void EnTr_WaitToReappear(EnTr* pthis, GlobalContext* globalCtx); +void EnTr_ChooseAction1(EnTr* pthis, GlobalContext* globalCtx); + +void EnTr_UpdateRotation(EnTr* pthis, GlobalContext* globalCtx, s32 actionIndex); +void func_80B24038(EnTr* pthis, GlobalContext* globalCtx, s32 actionIndex); +void EnTr_SetStartPosRot(EnTr* pthis, GlobalContext* globalCtx, s32 actionIndex); + +ActorInit En_Tr_InitVars = { + ACTOR_EN_TR, + ACTORCAT_NPC, + FLAGS, + OBJECT_TR, + sizeof(EnTr), + (ActorFunc)EnTr_Init, + (ActorFunc)EnTr_Destroy, + (ActorFunc)EnTr_Update, + (ActorFunc)EnTr_Draw, +}; + +// The first elements of these animation arrays are for Koume, the second for Kotake + +static AnimationHeader* unused[] = { + &object_tr_Anim_003FC8, + &object_tr_Anim_001CDC, +}; + +static AnimationHeader* D_80B24368[] = { + &object_tr_Anim_002BC4, + &object_tr_Anim_000BFC, +}; + +static AnimationHeader* D_80B24370[] = { + &object_tr_Anim_0035CC, + &object_tr_Anim_0013CC, +}; + +static AnimationHeader* D_80B24378[] = { + &object_tr_Anim_0049C8, + &object_tr_Anim_0049C8, +}; + +static AnimationHeader* D_80B24380[] = { + &object_tr_Anim_012E1C, + &object_tr_Anim_012E1C, +}; + +static f32 D_80B24388[] = { 0.0f, 20.0f, -30.0f, 20.0f, -20.0f, -20.0f, 30.0f }; + +static f32 D_80B243A4[] = { 0.0f, 30.0f, 0.0f, -30.0f, 30.0f, -30.0f, 0.0f }; + +// Has to be 1-dimensional to match +static Color_RGBA8 D_80B243C0[4] = { + { 255, 200, 0, 255 }, + { 255, 0, 0, 255 }, + { 255, 255, 255, 255 }, + { 0, 0, 255, 255 }, +}; + +static void* sEyeTextures[] = { + object_tr_Tex_0086D8, + object_tr_Tex_0094D8, + object_tr_Tex_0098D8, +}; + +void EnTr_SetupAction(EnTr* pthis, EnTrActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnTr_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTr* pthis = (EnTr*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + EnTr_SetupAction(pthis, EnTr_DoNothing); + pthis->unk_2D4 = 0; // Set and not used + pthis->actor.child = NULL; + Actor_SetScale(&pthis->actor, 0.01f); + + switch (pthis->actor.params) { + case TR_KOUME: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_tr_Skel_011688, &object_tr_Anim_003FC8, + pthis->jointTable, pthis->morphTable, 27); + Animation_PlayOnce(&pthis->skelAnime, &object_tr_Anim_003FC8); + pthis->animation = NULL; + EnTr_SetupAction(pthis, EnTr_ChooseAction1); + pthis->actionIndex = 3; + break; + + case TR_KOTAKE: + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &object_tr_Skel_00C530, &object_tr_Anim_001CDC, + pthis->jointTable, pthis->morphTable, 27); + Animation_PlayOnce(&pthis->skelAnime, &object_tr_Anim_001CDC); + pthis->animation = NULL; + EnTr_SetupAction(pthis, EnTr_ChooseAction1); + pthis->actionIndex = 2; + break; + + default: + ASSERT(0, "0", "../z_en_tr.c", 277); + break; + } +} + +void EnTr_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnTr_CrySpellcast(EnTr* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 11) { + // Both cry in the title screen cutscene, but only Kotake in the in-game cutscene + if ((pthis->actor.params != TR_KOUME) || (gSaveContext.sceneSetupIndex == 6)) { + Audio_PlaySoundGeneral(NA_SE_EN_TWINROBA_SHOOT_VOICE, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + + if (pthis->timer > 0) { + pthis->timer--; + } else if (pthis->actor.child != NULL) { + pthis->actor.child = NULL; + } + func_8002F974(&pthis->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); +} + +void EnTr_DoNothing(EnTr* pthis, GlobalContext* globalCtx) { +} + +void EnTr_ChooseAction2(EnTr* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if (globalCtx->csCtx.npcActions[pthis->actionIndex] != NULL) { + switch (globalCtx->csCtx.npcActions[pthis->actionIndex]->action) { + + case 4: + Actor_SetScale(&pthis->actor, 0.01f); + EnTr_SetupAction(pthis, EnTr_ShrinkVanish); + pthis->timer = 24; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_PO_DEAD2); + break; + + case 6: + Animation_Change(&pthis->skelAnime, D_80B24380[pthis->actor.params], 1.0f, 0.0f, + Animation_GetLastFrame(D_80B24380[pthis->actor.params]), ANIMMODE_ONCE, -5.0f); + EnTr_SetupAction(pthis, EnTr_CrySpellcast); + pthis->animation = D_80B24378[pthis->actor.params]; + pthis->timer = 39; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, + 0, pthis->actor.params + 9); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_MASIC1); + break; + + default: + func_80B24038(pthis, globalCtx, pthis->actionIndex); + EnTr_UpdateRotation(pthis, globalCtx, pthis->actionIndex); + break; + } + func_8002F974(&pthis->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); + } + } +} + +void EnTr_FlyKidnapCutscene(EnTr* pthis, GlobalContext* globalCtx) { + Vec3f originalPos = pthis->actor.world.pos; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if (globalCtx->csCtx.npcActions[pthis->actionIndex] != NULL) { + if (globalCtx->csCtx.npcActions[pthis->actionIndex]->action == 8) { + func_80B24038(pthis, globalCtx, pthis->actionIndex); + pthis->actor.world.rot.y = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 10, 0x400, 0x100); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + } else { + EnTr_SetStartPosRot(pthis, globalCtx, pthis->actionIndex); + pthis->actor.world.pos.x += Math_SinS(pthis->timer) * 150.0f; + pthis->actor.world.pos.y += -100.0f; + pthis->actor.world.pos.z += Math_CosS(pthis->timer) * 150.0f; + + pthis->actor.shape.rot.y = (s16)(pthis->timer) + 0x4000; + pthis->timer += 0x400; + + pthis->actor.velocity.x = pthis->actor.world.pos.x - originalPos.x; + pthis->actor.velocity.y = pthis->actor.world.pos.y - originalPos.y; + pthis->actor.velocity.z = pthis->actor.world.pos.z - originalPos.z; + } + + if (globalCtx->csCtx.frames < 670) { + func_8002F974(&pthis->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); + } + } + } +} + +void func_80B23254(EnTr* pthis, GlobalContext* globalCtx, s32 arg2, f32 arg3, f32 scale) { + Vec3f pos; + Vec3f velocity; + Vec3f accel; + Vec3f sp58; + Color_RGBA8* primColor; + Color_RGBA8* envColor; + Vec3f cameraEye = GET_ACTIVE_CAM(globalCtx)->eye; + s16 yaw = Math_Vec3f_Yaw(&cameraEye, &pthis->actor.world.pos); + s16 reversePitch = -Math_Vec3f_Pitch(&cameraEye, &pthis->actor.world.pos); + f32 sp3C; + + accel.x = accel.z = 0.0f; + sp3C = Math_SinS(yaw); + velocity.x = Math_CosS(reversePitch) * (arg3 * sp3C); + velocity.y = Math_SinS(reversePitch) * arg3; + sp3C = Math_CosS(yaw); + velocity.z = Math_CosS(reversePitch) * (arg3 * sp3C); + accel.y = 0.5f; + + primColor = &D_80B243C0[2 * pthis->actor.params]; + envColor = &D_80B243C0[2 * pthis->actor.params + 1]; + + sp58 = pthis->actor.world.pos; + sp58.x -= velocity.x * 10.0f; + sp58.y -= velocity.y * 10.0f; + sp58.z -= velocity.z * 10.0f; + + pos.x = sp58.x + ((D_80B24388[arg2] * scale) * Math_CosS(yaw)); + pos.y = sp58.y + (D_80B243A4[arg2] * scale); + pos.z = sp58.z - ((D_80B24388[arg2] * scale) * Math_SinS(yaw)); + func_8002829C(globalCtx, &pos, &velocity, &accel, primColor, envColor, (s32)(800.0f * scale), (s32)(80.0f * scale)); +} + +void EnTr_ShrinkVanish(EnTr* pthis, GlobalContext* globalCtx) { + if (pthis->timer >= 17) { + pthis->actor.shape.rot.y = (pthis->actor.shape.rot.y - (pthis->timer * 0x28F)) + 0x3D68; + } else { + if (pthis->timer >= 5) { + Actor_SetScale(&pthis->actor, pthis->actor.scale.x * 0.9f); + pthis->actor.shape.rot.y = (pthis->actor.shape.rot.y - (pthis->timer * 0x28F)) + 0x3D68; + } else if (pthis->timer > 0) { + s32 temp_hi = (pthis->timer * 2) % 7; + + func_80B23254(pthis, globalCtx, temp_hi, 5.0f, 0.2f); + func_80B23254(pthis, globalCtx, (temp_hi + 1) % 7, 5.0f, 0.2f); + Actor_SetScale(&pthis->actor, pthis->actor.scale.x * 0.9f); + pthis->actor.shape.rot.y = (pthis->actor.shape.rot.y - (pthis->timer * 0x28F)) + 0x3D68; + } else { + EnTr_SetupAction(pthis, EnTr_WaitToReappear); + pthis->actor.draw = NULL; + } + } + + if (pthis->timer == 4) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BUBLE_DOWN); + } + + if (pthis->timer > 0) { + pthis->timer--; + } +} + +void EnTr_Reappear(EnTr* pthis, GlobalContext* globalCtx) { + if (pthis->timer >= 31) { + s32 temp_hi = (pthis->timer * 2) % 7; + + func_80B23254(pthis, globalCtx, temp_hi, 5.0f, 1.0f); + func_80B23254(pthis, globalCtx, (temp_hi + 1) % 7, 5.0f, 1.0f); + } else if (pthis->timer == 30) { + pthis->actor.draw = EnTr_Draw; + pthis->actor.shape.rot.y += pthis->timer * 0x1A6; + } else if (pthis->timer > 0) { + pthis->actor.shape.rot.y += pthis->timer * 0x1A6; + Actor_SetScale(&pthis->actor, (pthis->actor.scale.x * 0.8f) + 0.002f); + } else { + EnTr_SetupAction(pthis, EnTr_ChooseAction2); + Actor_SetScale(&pthis->actor, 0.01f); + } + + if (pthis->timer > 0) { + pthis->timer--; + } + func_8002F974(&pthis->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); +} + +void EnTr_WaitToReappear(EnTr* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if ((globalCtx->csCtx.npcActions[pthis->actionIndex] != NULL) && + ((globalCtx->csCtx.npcActions[pthis->actionIndex]->action == 3) || + (globalCtx->csCtx.npcActions[pthis->actionIndex]->action == 5))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_TRANSFORM); + pthis->timer = 34; + EnTr_SetStartPosRot(pthis, globalCtx, pthis->actionIndex); + EnTr_SetupAction(pthis, EnTr_Reappear); + Animation_PlayLoop(&pthis->skelAnime, &object_tr_Anim_0049C8); + pthis->animation = NULL; + Actor_SetScale(&pthis->actor, 0.003f); + } + } +} + +void EnTr_TakeOff(EnTr* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(D_80B24378[pthis->actor.params]); + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if ((globalCtx->csCtx.npcActions[pthis->actionIndex] != NULL) && + (globalCtx->csCtx.npcActions[pthis->actionIndex]->action == 3)) { + Animation_Change(&pthis->skelAnime, D_80B24378[pthis->actor.params], 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, + -10.0f); + pthis->animation = NULL; + EnTr_SetupAction(pthis, EnTr_ChooseAction2); + } + } +} + +void EnTr_TurnLookOverShoulder(EnTr* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(D_80B24368[pthis->actor.params]); + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if ((globalCtx->csCtx.npcActions[pthis->actionIndex] != NULL) && + (globalCtx->csCtx.npcActions[pthis->actionIndex]->action == 2)) { + Animation_Change(&pthis->skelAnime, D_80B24368[pthis->actor.params], 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, + -4.0f); + pthis->animation = D_80B24370[pthis->actor.params]; + EnTr_SetupAction(pthis, EnTr_TakeOff); + } + } +} + +void EnTr_ChooseAction1(EnTr* pthis, GlobalContext* globalCtx) { + u32 frames = globalCtx->gameplayFrames; + + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + if (globalCtx->csCtx.npcActions[pthis->actionIndex] != NULL) { + switch (globalCtx->csCtx.npcActions[pthis->actionIndex]->action) { + case 1: + EnTr_SetStartPosRot(pthis, globalCtx, pthis->actionIndex); + EnTr_SetupAction(pthis, EnTr_TurnLookOverShoulder); + break; + + case 3: + EnTr_SetStartPosRot(pthis, globalCtx, pthis->actionIndex); + EnTr_SetupAction(pthis, EnTr_ChooseAction2); + Animation_PlayLoop(&pthis->skelAnime, &object_tr_Anim_0049C8); + pthis->animation = NULL; + break; + + case 4: + EnTr_SetupAction(pthis, EnTr_WaitToReappear); + pthis->actor.draw = NULL; + break; + + case 7: + EnTr_SetupAction(pthis, EnTr_FlyKidnapCutscene); + Animation_PlayLoop(&pthis->skelAnime, &object_tr_Anim_0049C8); + pthis->animation = NULL; + pthis->timer = + ((pthis->actor.params != TR_KOUME) ? ((u8)frames * 0x400) + 0x8000 : (u8)frames * 0x400); + break; + } + } + } +} + +void EnTr_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTr* pthis = (EnTr*)thisx; + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 5); + pthis->actionFunc(pthis, globalCtx); + + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->animation != NULL) { + if ((pthis->animation == &object_tr_Anim_0035CC) || (pthis->animation == &object_tr_Anim_0013CC)) { + if (pthis->actor.params != TR_KOUME) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_LAUGH2); + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TWINROBA_LAUGH); + } + Animation_PlayLoop(&pthis->skelAnime, pthis->animation); + } else if (pthis->animation == &object_tr_Anim_0049C8) { + EnTr_SetupAction(pthis, EnTr_ChooseAction2); + Animation_Change(&pthis->skelAnime, &object_tr_Anim_0049C8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_tr_Anim_0049C8), ANIMMODE_LOOP, -5.0f); + } else { + Animation_PlayLoop(&pthis->skelAnime, pthis->animation); + } + pthis->animation = NULL; + } else { + pthis->skelAnime.curFrame = 0.0f; + } + } + Actor_SetFocus(&pthis->actor, 0.0f); + + if (DECR(pthis->blinkTimer) == 0) { + pthis->blinkTimer = Rand_S16Offset(60, 60); + } + pthis->eyeIndex = pthis->blinkTimer; + if (pthis->eyeIndex >= 3) { + pthis->eyeIndex = 0; + } +} + +s32 EnTr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + Vec3f src = { 2300.0f, 0.0f, -600.0f }; + Vec3f dest = { 0.0f, 0.0f, 0.0f }; + EnTr* pthis = (EnTr*)thisx; + Actor* child = pthis->actor.child; + + if ((child != NULL) && (limbIndex == 19)) { + Matrix_MultVec3f(&src, &dest); + dest.x -= (10.0f * Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)))); + dest.z -= (10.0f * Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)))); + child->world.pos = dest; + } + return 0; +} + +void EnTr_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTr* pthis = (EnTr*)thisx; + + if (1) {} + + if ((globalCtx->csCtx.state == CS_STATE_IDLE) || (globalCtx->csCtx.npcActions[pthis->actionIndex] == 0)) { + pthis->actor.shape.shadowDraw = NULL; + } else { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 840); + func_800943C8(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[pthis->eyeIndex])); + func_8002EBCC(&pthis->actor, globalCtx, 0); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnTr_OverrideLimbDraw, NULL, pthis); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 854); + } +} + +f32 func_80B23FDC(GlobalContext* globalCtx, s32 actionIndex) { + f32 phi_f2 = Environment_LerpWeight(globalCtx->csCtx.npcActions[actionIndex]->endFrame, + globalCtx->csCtx.npcActions[actionIndex]->startFrame, globalCtx->csCtx.frames); + phi_f2 = CLAMP_MAX(phi_f2, 1.0f); + return phi_f2; +} + +void func_80B24038(EnTr* pthis, GlobalContext* globalCtx, s32 actionIndex) { + Vec3f startPos; + Vec3f endPos; + f32 temp_f0; + f32 temp_f0_2; + f32 phi_f12; + + startPos.x = globalCtx->csCtx.npcActions[actionIndex]->startPos.x; + startPos.y = globalCtx->csCtx.npcActions[actionIndex]->startPos.y; + startPos.z = globalCtx->csCtx.npcActions[actionIndex]->startPos.z; + + endPos.x = globalCtx->csCtx.npcActions[actionIndex]->endPos.x; + endPos.y = globalCtx->csCtx.npcActions[actionIndex]->endPos.y; + endPos.z = globalCtx->csCtx.npcActions[actionIndex]->endPos.z; + + temp_f0 = func_80B23FDC(globalCtx, actionIndex); + + startPos.x = ((endPos.x - startPos.x) * temp_f0) + startPos.x; + startPos.y = ((endPos.y - startPos.y) * temp_f0) + startPos.y; + startPos.z = ((endPos.z - startPos.z) * temp_f0) + startPos.z; + + endPos.x = (startPos.x - pthis->actor.world.pos.x) * 0.1f; + endPos.y = (startPos.y - pthis->actor.world.pos.y) * 0.1f; + endPos.z = (startPos.z - pthis->actor.world.pos.z) * 0.1f; + + temp_f0_2 = sqrtf(SQ(endPos.x) + SQ(endPos.y) + SQ(endPos.z)); + phi_f12 = CLAMP(temp_f0_2, 0.0f, 20.0f); + + if ((temp_f0_2 != phi_f12) && (temp_f0_2 != 0.0f)) { + endPos.x *= phi_f12 / temp_f0_2; + endPos.y *= phi_f12 / temp_f0_2; + endPos.z *= phi_f12 / temp_f0_2; + } + + Math_StepToF(&pthis->actor.velocity.x, endPos.x, 1.0f); + Math_StepToF(&pthis->actor.velocity.y, endPos.y, 1.0f); + Math_StepToF(&pthis->actor.velocity.z, endPos.z, 1.0f); + func_8002D7EC(&pthis->actor); +} + +void EnTr_UpdateRotation(EnTr* pthis, GlobalContext* globalCtx, s32 actionIndex) { + s16 rotY = globalCtx->csCtx.npcActions[actionIndex]->rot.y; + s32 rotDiff = pthis->actor.world.rot.y - rotY; + s32 rotSign; + + if (rotDiff < 0) { + rotDiff = -rotDiff; + rotSign = 1; + } else { + rotSign = -1; + } + + if (rotDiff >= 0x8000) { + rotSign = -rotSign; + rotDiff = 0x10000 - rotDiff; + } + + rotDiff *= 0.1f; + + pthis->actor.world.rot.y += rotDiff * rotSign; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnTr_SetStartPosRot(EnTr* pthis, GlobalContext* globalCtx, s32 actionIndex) { + Vec3f startPos; + + startPos.x = globalCtx->csCtx.npcActions[actionIndex]->startPos.x; + startPos.y = globalCtx->csCtx.npcActions[actionIndex]->startPos.y; + startPos.z = globalCtx->csCtx.npcActions[actionIndex]->startPos.z; + + pthis->actor.world.pos = startPos; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = globalCtx->csCtx.npcActions[actionIndex]->rot.y; +} diff --git a/src/overlays/actors/ovl_En_Trap/z_en_trap.c b/src/overlays/actors/ovl_En_Trap/z_en_trap.cpp similarity index 64% rename from src/overlays/actors/ovl_En_Trap/z_en_trap.c rename to src/overlays/actors/ovl_En_Trap/z_en_trap.cpp index 4d1ebadaf..cda5c4cdf 100644 --- a/src/overlays/actors/ovl_En_Trap/z_en_trap.c +++ b/src/overlays/actors/ovl_En_Trap/z_en_trap.cpp @@ -42,7 +42,7 @@ void EnTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTrap_Update(Actor* thisx, GlobalContext* globalCtx); void EnTrap_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Trap_InitVars = { +ActorInit En_Trap_InitVars = { ACTOR_EN_TRAP, ACTORCAT_BG, FLAGS, @@ -72,25 +72,25 @@ void EnTrap_Init(Actor* thisx, GlobalContext* globalCtx) { f32 trapSpeed; s16 zSpeed; s16 xSpeed; - EnTrap* this = (EnTrap*)thisx; - ColliderCylinder* unused = &this->collider; // required to match + EnTrap* pthis = (EnTrap*)thisx; + ColliderCylinder* unused = &pthis->collider; // required to match - this->upperParams = (thisx->params >> 8) & 0xFF; + pthis->upperParams = (thisx->params >> 8) & 0xFF; thisx->params &= 0xFF; Actor_SetScale(thisx, 0.1f); thisx->gravity = -2.0f; if (thisx->params & SPIKETRAP_MODE_LINEAR) { - thisx->speedXZ = this->moveSpeedForwardBack.z = this->upperParams & 0xF; + thisx->speedXZ = pthis->moveSpeedForwardBack.z = pthis->upperParams & 0xF; Audio_PlayActorSound2(thisx, NA_SE_EV_SPINE_TRAP_MOVE); } else if (thisx->params & SPIKETRAP_MODE_CIRCULAR) { - this->vRadius = (this->upperParams & 0xF) * 40.0f; - this->vAngularVel = ((this->upperParams & 0xF0) + 0x10) << 5; - thisx->world.pos.x = thisx->home.pos.x + (Math_SinS(0) * this->vRadius); - thisx->world.pos.z = thisx->home.pos.z + (Math_CosS(0) * this->vRadius); + pthis->vRadius = (pthis->upperParams & 0xF) * 40.0f; + pthis->vAngularVel = ((pthis->upperParams & 0xF0) + 0x10) << 5; + thisx->world.pos.x = thisx->home.pos.x + (Math_SinS(0) * pthis->vRadius); + thisx->world.pos.z = thisx->home.pos.z + (Math_CosS(0) * pthis->vRadius); } else { // Four-way motion - if (this->upperParams != 0) { - trapDist = (this->upperParams >> 4) * 40; - trapSpeed = (this->upperParams & 0xF); + if (pthis->upperParams != 0) { + trapDist = (pthis->upperParams >> 4) * 40; + trapSpeed = (pthis->upperParams & 0xF); } else { trapDist = 200.0f; trapSpeed = 10.0f; @@ -98,37 +98,37 @@ void EnTrap_Init(Actor* thisx, GlobalContext* globalCtx) { } Actor_UpdateBgCheckInfo(globalCtx, thisx, 10.0f, 20.0f, 20.0f, 0x1D); thisx->home.pos = thisx->world.pos; - this->targetPosLeft.x = thisx->world.pos.x + (trapDist * Math_CosS(thisx->world.rot.y)); - this->targetPosLeft.z = thisx->world.pos.z - (trapDist * Math_SinS(thisx->world.rot.y)); - this->targetPosRight.x = thisx->world.pos.x + (trapDist * Math_CosS(thisx->world.rot.y + 0x8000)); - this->targetPosRight.z = thisx->world.pos.z - (trapDist * Math_SinS(thisx->world.rot.y + 0x8000)); - this->targetPosFwd.x = thisx->world.pos.x + (trapDist * Math_SinS(thisx->world.rot.y)); - this->targetPosFwd.z = thisx->world.pos.z + (trapDist * Math_CosS(thisx->world.rot.y)); - this->targetPosBack.x = thisx->world.pos.x + (trapDist * Math_SinS(thisx->world.rot.y + 0x8000)); - this->targetPosBack.z = thisx->world.pos.z + (trapDist * Math_CosS(thisx->world.rot.y + 0x8000)); + pthis->targetPosLeft.x = thisx->world.pos.x + (trapDist * Math_CosS(thisx->world.rot.y)); + pthis->targetPosLeft.z = thisx->world.pos.z - (trapDist * Math_SinS(thisx->world.rot.y)); + pthis->targetPosRight.x = thisx->world.pos.x + (trapDist * Math_CosS(thisx->world.rot.y + 0x8000)); + pthis->targetPosRight.z = thisx->world.pos.z - (trapDist * Math_SinS(thisx->world.rot.y + 0x8000)); + pthis->targetPosFwd.x = thisx->world.pos.x + (trapDist * Math_SinS(thisx->world.rot.y)); + pthis->targetPosFwd.z = thisx->world.pos.z + (trapDist * Math_CosS(thisx->world.rot.y)); + pthis->targetPosBack.x = thisx->world.pos.x + (trapDist * Math_SinS(thisx->world.rot.y + 0x8000)); + pthis->targetPosBack.z = thisx->world.pos.z + (trapDist * Math_CosS(thisx->world.rot.y + 0x8000)); zSpeed = trapSpeed * Math_CosS(thisx->world.rot.y); xSpeed = trapSpeed * Math_SinS(thisx->world.rot.y); zSpeed = ABS(zSpeed); xSpeed = ABS(xSpeed); - this->moveSpeedLeftRight.x = this->moveSpeedForwardBack.z = zSpeed; - this->moveSpeedLeftRight.z = this->moveSpeedForwardBack.x = xSpeed; + pthis->moveSpeedLeftRight.x = pthis->moveSpeedForwardBack.z = zSpeed; + pthis->moveSpeedLeftRight.z = pthis->moveSpeedForwardBack.x = xSpeed; } thisx->focus.pos = thisx->world.pos; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 0.0f); thisx->targetMode = 3; thisx->colChkInfo.mass = 0xFF; } void EnTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTrap* this = (EnTrap*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + EnTrap* pthis = (EnTrap*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void EnTrap_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTrap* this = (EnTrap*)thisx; + EnTrap* pthis = (EnTrap*)thisx; Vec3f posTemp; s16 angleToKnockPlayer; s16 angleToCollidedActor; @@ -146,16 +146,16 @@ void EnTrap_Update(Actor* thisx, GlobalContext* globalCtx) { touchingActor = false; blockedOnReturn = false; angleToWall = thisx->wallYaw - thisx->world.rot.y; - if (this->collider.base.ocFlags1 & OC1_HIT) { - this->collider.base.ocFlags1 &= ~OC1_HIT; + if (pthis->collider.base.ocFlags1 & OC1_HIT) { + pthis->collider.base.ocFlags1 &= ~OC1_HIT; angleToCollidedActor = - thisx->world.rot.y + Math_Vec3f_Yaw(&this->collider.base.oc->world.pos, &thisx->world.pos); + thisx->world.rot.y + Math_Vec3f_Yaw(&pthis->collider.base.oc->world.pos, &thisx->world.pos); touchingActor = true; } // Freeze the trap if hit by ice arrows: - if ((this->collider.base.acFlags & AC_HIT) != 0) { + if ((pthis->collider.base.acFlags & AC_HIT) != 0) { icePos = thisx->world.pos; - this->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.acFlags &= ~AC_HIT; Actor_SetColorFilter(thisx, 0, 250, 0, 250); icePos.y += 10.0f; icePos.z += 10.0f; @@ -168,169 +168,169 @@ void EnTrap_Update(Actor* thisx, GlobalContext* globalCtx) { } // If not frozen: if (thisx->colorFilterTimer == 0) { - DECR(this->playerDmgTimer); + DECR(pthis->playerDmgTimer); // Handles damaging player: //! @bug there is no yDistToPlayer check for player being below. Therefore hitbox extends down infinitely - if ((thisx->xzDistToPlayer <= 40.0f) && (this->playerDmgTimer == 0) && (thisx->yDistToPlayer <= 20.0f)) { + if ((thisx->xzDistToPlayer <= 40.0f) && (pthis->playerDmgTimer == 0) && (thisx->yDistToPlayer <= 20.0f)) { if (!(thisx->params & (SPIKETRAP_MODE_LINEAR | SPIKETRAP_MODE_CIRCULAR))) { // if in 4-way mode: - if ((s16)(this->vClosestDirection - thisx->yawTowardsPlayer) >= 0) { - angleToKnockPlayer = this->vClosestDirection - 0x4000; + if ((s16)(pthis->vClosestDirection - thisx->yawTowardsPlayer) >= 0) { + angleToKnockPlayer = pthis->vClosestDirection - 0x4000; } else { - angleToKnockPlayer = this->vClosestDirection + 0x4000; + angleToKnockPlayer = pthis->vClosestDirection + 0x4000; } } else { angleToKnockPlayer = thisx->yawTowardsPlayer; } globalCtx->damagePlayer(globalCtx, -4); func_8002F7A0(globalCtx, thisx, 6.0f, angleToKnockPlayer, 6.0f); - this->playerDmgTimer = 15; + pthis->playerDmgTimer = 15; } if (thisx->params & SPIKETRAP_MODE_LINEAR) { - this->vContinue = 1.0f; + pthis->vContinue = 1.0f; // If physically touching a wall and wall faces towards spike trap if ((thisx->bgCheckFlags & 8) && (ABS(angleToWall) >= 0x6000)) { - this->vContinue = 0.0f; + pthis->vContinue = 0.0f; } // If there is a collision poly between current position and a position 30 units ahead of spike trap - if (this->vContinue != 0.0f) { + if (pthis->vContinue != 0.0f) { posAhead.x = (Math_SinS(thisx->world.rot.y) * 30.0f) + thisx->world.pos.x; posAhead.z = (Math_CosS(thisx->world.rot.y) * 30.0f) + thisx->world.pos.z; posAhead.y = thisx->world.pos.y; if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &posAhead, &colPoint, &colPoly, true, true, false, true, &bgId) == true) { - this->vContinue = 0.0f; + pthis->vContinue = 0.0f; } } // If spike trap is touching an actor which is in the path of the spike trap - if (touchingActor && (this->vContinue != 0.0f)) { + if (touchingActor && (pthis->vContinue != 0.0f)) { angleToCollidedActor = - Math_Vec3f_Yaw(&thisx->world.pos, &this->collider.base.oc->world.pos) - thisx->world.rot.y; + Math_Vec3f_Yaw(&thisx->world.pos, &pthis->collider.base.oc->world.pos) - thisx->world.rot.y; if (ABS(angleToCollidedActor) < 0x1000) { - this->vContinue = 0.0f; + pthis->vContinue = 0.0f; } } // If any of the above three conditions are met, turn around - if (this->vContinue == 0.0f) { + if (pthis->vContinue == 0.0f) { thisx->world.rot.y += 0x8000; Audio_PlayActorSound2(thisx, NA_SE_EV_SPINE_TRAP_MOVE); } } else if (thisx->params & SPIKETRAP_MODE_CIRCULAR) { - temp_cond = Math_SinS(this->vAngularPos); - this->vAngularPos += this->vAngularVel; + temp_cond = Math_SinS(pthis->vAngularPos); + pthis->vAngularPos += pthis->vAngularVel; // Every full circle make a sound: - if ((temp_cond < 0.0f) && (Math_SinS(this->vAngularPos) >= 0.0f)) { + if ((temp_cond < 0.0f) && (Math_SinS(pthis->vAngularPos) >= 0.0f)) { Audio_PlayActorSound2(thisx, NA_SE_EV_ROUND_TRAP_MOVE); } - thisx->world.pos.x = (this->vRadius * Math_SinS(this->vAngularPos)) + thisx->home.pos.x; - thisx->world.pos.z = (this->vRadius * Math_CosS(this->vAngularPos)) + thisx->home.pos.z; + thisx->world.pos.x = (pthis->vRadius * Math_SinS(pthis->vAngularPos)) + thisx->home.pos.x; + thisx->world.pos.z = (pthis->vRadius * Math_CosS(pthis->vAngularPos)) + thisx->home.pos.z; thisx->world.pos.y = thisx->floorHeight; thisx->prevPos = thisx->world.pos; } else { // 4 way movement // if moving outwards: - if (this->vMovementMetric != 0.0f) { - switch (this->vClosestDirection) { // movement direction relative to spike trap + if (pthis->vMovementMetric != 0.0f) { + switch (pthis->vClosestDirection) { // movement direction relative to spike trap case DIR_FWD: if (!(thisx->params & SPIKETRAP_FOURWAY_FWD_ALLOWED)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; } else if ((thisx->bgCheckFlags & 8) && (ABS(angleToWall) > 0x6000)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; } - if (touchingActor && (this->vMovementMetric != 0.0f) && (ABS(angleToCollidedActor) > 0x6000)) { - this->vMovementMetric = 0.0f; + if (touchingActor && (pthis->vMovementMetric != 0.0f) && (ABS(angleToCollidedActor) > 0x6000)) { + pthis->vMovementMetric = 0.0f; } - if (this->vMovementMetric != 0.0f) { - if (this->vMovementMetric == BEGIN_MOVE_OUT) { + if (pthis->vMovementMetric != 0.0f) { + if (pthis->vMovementMetric == BEGIN_MOVE_OUT) { Audio_PlayActorSound2(thisx, NA_SE_EV_SPINE_TRAP_MOVE); } - this->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.z, this->targetPosFwd.z, 1.0f, - this->moveSpeedForwardBack.z, 0.0f); - this->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.x, this->targetPosFwd.x, 1.0f, - this->moveSpeedForwardBack.x, 0.0f); + pthis->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.z, pthis->targetPosFwd.z, 1.0f, + pthis->moveSpeedForwardBack.z, 0.0f); + pthis->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.x, pthis->targetPosFwd.x, 1.0f, + pthis->moveSpeedForwardBack.x, 0.0f); } break; case DIR_LEFT: if (!(thisx->params & SPIKETRAP_FOURWAY_LEFT_ALLOWED)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; } else if ((thisx->bgCheckFlags & 8) && (angleToWall < -0x2000) && (angleToWall > -0x6000)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; break; } - if (touchingActor && (this->vMovementMetric != 0.0f) && (angleToCollidedActor <= -0x2000) && + if (touchingActor && (pthis->vMovementMetric != 0.0f) && (angleToCollidedActor <= -0x2000) && (angleToCollidedActor > -0x6000)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; break; } - if (this->vMovementMetric != 0.0f) { - if (this->vMovementMetric == BEGIN_MOVE_OUT) { + if (pthis->vMovementMetric != 0.0f) { + if (pthis->vMovementMetric == BEGIN_MOVE_OUT) { Audio_PlayActorSound2(thisx, NA_SE_EV_SPINE_TRAP_MOVE); } - this->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.x, this->targetPosLeft.x, 1.0f, - this->moveSpeedLeftRight.x, 0.0f); - this->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.z, this->targetPosLeft.z, - 1.0f, this->moveSpeedLeftRight.z, 0.0f); + pthis->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.x, pthis->targetPosLeft.x, 1.0f, + pthis->moveSpeedLeftRight.x, 0.0f); + pthis->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.z, pthis->targetPosLeft.z, + 1.0f, pthis->moveSpeedLeftRight.z, 0.0f); } break; case DIR_BACK: if (!(thisx->params & SPIKETRAP_FOURWAY_BACK_ALLOWED)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; } else if ((thisx->bgCheckFlags & 8) && (ABS(angleToWall) < 0x2000)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; break; } - if (touchingActor && (this->vMovementMetric != 0.0f) && (ABS(angleToCollidedActor) < 0x2000)) { - this->vMovementMetric = 0.0f; + if (touchingActor && (pthis->vMovementMetric != 0.0f) && (ABS(angleToCollidedActor) < 0x2000)) { + pthis->vMovementMetric = 0.0f; break; } - if (this->vMovementMetric != 0.0f) { - if (this->vMovementMetric == BEGIN_MOVE_OUT) { + if (pthis->vMovementMetric != 0.0f) { + if (pthis->vMovementMetric == BEGIN_MOVE_OUT) { Audio_PlayActorSound2(thisx, NA_SE_EV_SPINE_TRAP_MOVE); } - this->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.z, this->targetPosBack.z, 1.0f, - this->moveSpeedForwardBack.z, 0.0f); - this->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.x, this->targetPosBack.x, - 1.0f, this->moveSpeedForwardBack.x, 0.0f); + pthis->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.z, pthis->targetPosBack.z, 1.0f, + pthis->moveSpeedForwardBack.z, 0.0f); + pthis->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.x, pthis->targetPosBack.x, + 1.0f, pthis->moveSpeedForwardBack.x, 0.0f); } break; case DIR_RIGHT: if (!(thisx->params & SPIKETRAP_FOURWAY_RIGHT_ALLOWED)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; } else if ((thisx->bgCheckFlags & 8) && (angleToWall > 0x2000) && (angleToWall < 0x6000)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; break; } - if (touchingActor && (this->vMovementMetric != 0.0f) && (angleToCollidedActor > 0x2000) && + if (touchingActor && (pthis->vMovementMetric != 0.0f) && (angleToCollidedActor > 0x2000) && (angleToCollidedActor < 0x6000)) { - this->vMovementMetric = 0.0f; + pthis->vMovementMetric = 0.0f; break; } - if (this->vMovementMetric != 0.0f) { - if (this->vMovementMetric == BEGIN_MOVE_OUT) { + if (pthis->vMovementMetric != 0.0f) { + if (pthis->vMovementMetric == BEGIN_MOVE_OUT) { Audio_PlayActorSound2(thisx, NA_SE_EV_SPINE_TRAP_MOVE); } - this->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.x, this->targetPosRight.x, - 1.0f, this->moveSpeedLeftRight.x, 0.0f); - this->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.z, this->targetPosRight.z, - 1.0f, this->moveSpeedLeftRight.z, 0.0f); + pthis->vMovementMetric = Math_SmoothStepToF(&thisx->world.pos.x, pthis->targetPosRight.x, + 1.0f, pthis->moveSpeedLeftRight.x, 0.0f); + pthis->vMovementMetric += Math_SmoothStepToF(&thisx->world.pos.z, pthis->targetPosRight.z, + 1.0f, pthis->moveSpeedLeftRight.z, 0.0f); } break; } - if (!Actor_TestFloorInDirection(thisx, globalCtx, 50.0f, this->vClosestDirection)) { - this->vMovementMetric = 0.0f; + if (!Actor_TestFloorInDirection(thisx, globalCtx, 50.0f, pthis->vClosestDirection)) { + pthis->vMovementMetric = 0.0f; } // if in initial position: } else if ((thisx->world.pos.x == thisx->home.pos.x) && (thisx->world.pos.z == thisx->home.pos.z)) { // of the available 4-way directions, get the one which is closest to the direction of player: - this->vClosestDirection = ((thisx->yawTowardsPlayer - thisx->world.rot.y) + 0x2000) & 0xC000; - this->vMovementMetric = 0.0f; + pthis->vClosestDirection = ((thisx->yawTowardsPlayer - thisx->world.rot.y) + 0x2000) & 0xC000; + pthis->vMovementMetric = 0.0f; if (thisx->xzDistToPlayer < 200.0f) { - this->vMovementMetric = BEGIN_MOVE_OUT; + pthis->vMovementMetric = BEGIN_MOVE_OUT; } // If returning to origin: } else { // Of the four real world compass directions, get the one which is closest to the movement direction of - // the returning spike. Note that this is different from the previous usages of vClosestDirection - this->vClosestDirection = (Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos) + 0x2000) & 0xC000; - switch (this->vClosestDirection) { + // the returning spike. Note that pthis is different from the previous usages of vClosestDirection + pthis->vClosestDirection = (Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos) + 0x2000) & 0xC000; + switch (pthis->vClosestDirection) { case 0: // movement is closest to +z direction if (thisx->bgCheckFlags & 8) { if (ABS(thisx->wallYaw) > 0x6000) { @@ -387,10 +387,10 @@ void EnTrap_Update(Actor* thisx, GlobalContext* globalCtx) { thisx->world.pos.z = posTemp.z; } } - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); if (thisx->colorFilterTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c deleted file mode 100644 index 992db4f3f..000000000 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ /dev/null @@ -1,300 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TUBO_TRAP_Z_EN_TUBO_TRAP_C -#include "actor_common.h" -/* - * File: z_en_tubo_trap.c - * Overlay: ovl_En_Tubo_Trap - * Description: Flying pot enemy - */ - -#include "z_en_tubo_trap.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#include "vt.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { 9, 23, 0, { 0 } }, -}; - -const ActorInit En_Tubo_Trap_InitVars = { - ACTOR_EN_TUBO_TRAP, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_DANGEON_KEEP, - sizeof(EnTuboTrap), - (ActorFunc)EnTuboTrap_Init, - (ActorFunc)EnTuboTrap_Destroy, - (ActorFunc)EnTuboTrap_Update, - (ActorFunc)EnTuboTrap_Draw, -}; - -void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx) { - EnTuboTrap* this = (EnTuboTrap*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.0f); - osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); // "Urn Trap" - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Actor_SetScale(&this->actor, 0.1f); - this->actionFunc = EnTuboTrap_WaitForProximity; -} - -void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnTuboTrap* this = (EnTuboTrap*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx) { - s16 params = this->actor.params; - s16 param3FF = (params >> 6) & 0x3FF; - - if (param3FF >= 0 && param3FF < 0x1A) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, param3FF | ((params & 0x3F) << 8)); - } -} - -void EnTuboTrap_SpawnEffectsOnLand(EnTuboTrap* this, GlobalContext* globalCtx) { - f32 rand; - f32 cos; - f32 sin; - Vec3f pos; - Vec3f velocity; - s16 var; - s32 arg5; - s32 i; - Vec3f* actorPos = &this->actor.world.pos; - - for (i = 0, var = 0; i < 15; i++, var += 20000) { - sin = Math_SinS(var); - cos = Math_CosS(var); - pos.x = sin * 8.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = cos * 8.0f; - - velocity.x = pos.x * 0.23f; - velocity.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - velocity.z = pos.z * 0.23f; - - pos.x += actorPos->x; - pos.y += actorPos->y; - pos.z += actorPos->z; - - rand = Rand_ZeroOne(); - if (rand < 0.2f) { - arg5 = 96; - } else if (rand < 0.6f) { - arg5 = 64; - } else { - arg5 = 32; - } - - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, actorPos, -240, arg5, 10, 10, 0, - (Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 60, KAKERA_COLOR_NONE, - OBJECT_GAMEPLAY_DANGEON_KEEP, gPotFragmentDL); - } - - func_80033480(globalCtx, actorPos, 30.0f, 4, 20, 50, 0); -} - -void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, GlobalContext* globalCtx) { - f32 rand; - f32 cos; - f32 sin; - Vec3f pos; - Vec3f velocity; - s16 var; - s32 arg5; - s32 i; - Vec3f* actorPos = &this->actor.world.pos; - - pos = *actorPos; - pos.y += this->actor.yDistToWater; - - EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); - - for (i = 0, var = 0; i < 15; i++, var += 20000) { - sin = Math_SinS(var); - cos = Math_CosS(var); - pos.x = sin * 8.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = cos * 8.0f; - - velocity.x = pos.x * 0.20f; - velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; - velocity.z = pos.z * 0.20f; - - pos.x += actorPos->x; - pos.y += actorPos->y; - pos.z += actorPos->z; - - rand = Rand_ZeroOne(); - if (rand < 0.2f) { - arg5 = 64; - } else { - arg5 = 32; - } - - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, actorPos, -180, arg5, 30, 30, 0, - (Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 70, KAKERA_COLOR_NONE, - OBJECT_GAMEPLAY_DANGEON_KEEP, gPotFragmentDL); - } -} - -void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); - - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f)) { - EnTuboTrap_SpawnEffectsInWater(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } - - if (this->collider.base.atFlags & AT_BOUNCED) { - this->collider.base.atFlags &= ~AT_BOUNCED; - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } - - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_EXPLOSION); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~AT_HIT; - if (this->collider.base.at == &player->actor) { - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - Audio_PlaySoundAtPosition(globalCtx, &player2->actor.world.pos, 40, NA_SE_PL_BODY_HIT); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } - } - - if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1)) { - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } -} - -void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 targetHeight; - - if (BREG(2) != 0) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わて ☆☆☆☆☆ %f\n" VT_RST, this->actor.world.pos.y); // "You" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n" VT_RST, player->actor.world.pos.y); // "Me" - osSyncPrintf("\n\n"); - } - - if (this->actor.xzDistToPlayer < 200.0f && this->actor.world.pos.y <= player->actor.world.pos.y) { - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); - this->actor.flags |= ACTOR_FLAG_0; - targetHeight = 40.0f + -10.0f * gSaveContext.linkAge; - - this->targetY = player->actor.world.pos.y + targetHeight; - if (this->targetY < this->actor.world.pos.y) { - this->targetY = this->actor.world.pos.y + targetHeight; - } - - this->originPos = this->actor.world.pos; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POT_MOVE_START); - this->actionFunc = EnTuboTrap_Levitate; - } -} - -void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 5000; - Math_ApproachF(&this->actor.world.pos.y, this->targetY, 0.8f, 3.0f); - - if (fabsf(this->actor.world.pos.y - this->targetY) < 10.0f) { - this->actor.speedXZ = 10.0f; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = EnTuboTrap_Fly; - } -} - -void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx) { - f32 dx = this->originPos.x - this->actor.world.pos.x; - f32 dy = this->originPos.y - this->actor.world.pos.y; - f32 dz = this->originPos.z - this->actor.world.pos.z; - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TUBOOCK_FLY - SFX_FLAG); - - if (240.0f < sqrtf(SQ(dx) + SQ(dy) + SQ(dz))) { - Math_ApproachF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); - } - - this->actor.shape.rot.y += 5000; - EnTuboTrap_HandleImpact(this, globalCtx); -} - -void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { - EnTuboTrap* this = (EnTuboTrap*)thisx; - s32 pad; - - this->actionFunc(this, globalCtx); - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 20.0f, 0x1D); - Actor_SetFocus(&this->actor, 0.0f); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gPotDL); -} diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.cpp b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.cpp new file mode 100644 index 000000000..0e3abb966 --- /dev/null +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.cpp @@ -0,0 +1,300 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_TUBO_TRAP_Z_EN_TUBO_TRAP_C +#include "actor_common.h" +/* + * File: z_en_tubo_trap.c + * Overlay: ovl_En_Tubo_Trap + * Description: Flying pot enemy + */ + +#include "z_en_tubo_trap.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "vt.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnTuboTrap_WaitForProximity(EnTuboTrap* pthis, GlobalContext* globalCtx); +void EnTuboTrap_Levitate(EnTuboTrap* pthis, GlobalContext* globalCtx); +void EnTuboTrap_Fly(EnTuboTrap* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 9, 23, 0, { 0 } }, +}; + +ActorInit En_Tubo_Trap_InitVars = { + ACTOR_EN_TUBO_TRAP, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_DANGEON_KEEP, + sizeof(EnTuboTrap), + (ActorFunc)EnTuboTrap_Init, + (ActorFunc)EnTuboTrap_Destroy, + (ActorFunc)EnTuboTrap_Update, + (ActorFunc)EnTuboTrap_Draw, +}; + +void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTuboTrap* pthis = (EnTuboTrap*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.0f); + osSyncPrintf("\n\n"); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); // "Urn Trap" + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Actor_SetScale(&pthis->actor, 0.1f); + pthis->actionFunc = EnTuboTrap_WaitForProximity; +} + +void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTuboTrap* pthis = (EnTuboTrap*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnTuboTrap_DropCollectible(EnTuboTrap* pthis, GlobalContext* globalCtx) { + s16 params = pthis->actor.params; + s16 param3FF = (params >> 6) & 0x3FF; + + if (param3FF >= 0 && param3FF < 0x1A) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, param3FF | ((params & 0x3F) << 8)); + } +} + +void EnTuboTrap_SpawnEffectsOnLand(EnTuboTrap* pthis, GlobalContext* globalCtx) { + f32 rand; + f32 cos; + f32 sin; + Vec3f pos; + Vec3f velocity; + s16 var; + s32 arg5; + s32 i; + Vec3f* actorPos = &pthis->actor.world.pos; + + for (i = 0, var = 0; i < 15; i++, var += 20000) { + sin = Math_SinS(var); + cos = Math_CosS(var); + pos.x = sin * 8.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = cos * 8.0f; + + velocity.x = pos.x * 0.23f; + velocity.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + velocity.z = pos.z * 0.23f; + + pos.x += actorPos->x; + pos.y += actorPos->y; + pos.z += actorPos->z; + + rand = Rand_ZeroOne(); + if (rand < 0.2f) { + arg5 = 96; + } else if (rand < 0.6f) { + arg5 = 64; + } else { + arg5 = 32; + } + + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, actorPos, -240, arg5, 10, 10, 0, + (Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 60, KAKERA_COLOR_NONE, + OBJECT_GAMEPLAY_DANGEON_KEEP, gPotFragmentDL); + } + + func_80033480(globalCtx, actorPos, 30.0f, 4, 20, 50, 0); +} + +void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* pthis, GlobalContext* globalCtx) { + f32 rand; + f32 cos; + f32 sin; + Vec3f pos; + Vec3f velocity; + s16 var; + s32 arg5; + s32 i; + Vec3f* actorPos = &pthis->actor.world.pos; + + pos = *actorPos; + pos.y += pthis->actor.yDistToWater; + + EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); + + for (i = 0, var = 0; i < 15; i++, var += 20000) { + sin = Math_SinS(var); + cos = Math_CosS(var); + pos.x = sin * 8.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = cos * 8.0f; + + velocity.x = pos.x * 0.20f; + velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + velocity.z = pos.z * 0.20f; + + pos.x += actorPos->x; + pos.y += actorPos->y; + pos.z += actorPos->z; + + rand = Rand_ZeroOne(); + if (rand < 0.2f) { + arg5 = 64; + } else { + arg5 = 32; + } + + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, actorPos, -180, arg5, 30, 30, 0, + (Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 70, KAKERA_COLOR_NONE, + OBJECT_GAMEPLAY_DANGEON_KEEP, gPotFragmentDL); + } +} + +void EnTuboTrap_HandleImpact(EnTuboTrap* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + if ((pthis->actor.bgCheckFlags & 0x20) && (pthis->actor.yDistToWater > 15.0f)) { + EnTuboTrap_SpawnEffectsInWater(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_DropCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->collider.base.atFlags & AT_BOUNCED) { + pthis->collider.base.atFlags &= ~AT_BOUNCED; + EnTuboTrap_SpawnEffectsOnLand(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + EnTuboTrap_SpawnEffectsOnLand(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_EXPLOSION); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~AT_HIT; + if (pthis->collider.base.at == &player->actor) { + EnTuboTrap_SpawnEffectsOnLand(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + Audio_PlaySoundAtPosition(globalCtx, &player2->actor.world.pos, 40, NA_SE_PL_BODY_HIT); + EnTuboTrap_DropCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + return; + } + } + + if ((pthis->actor.bgCheckFlags & 8) || (pthis->actor.bgCheckFlags & 1)) { + EnTuboTrap_SpawnEffectsOnLand(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + return; + } +} + +void EnTuboTrap_WaitForProximity(EnTuboTrap* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 targetHeight; + + if (BREG(2) != 0) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わて ☆☆☆☆☆ %f\n" VT_RST, pthis->actor.world.pos.y); // "You" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n" VT_RST, player->actor.world.pos.y); // "Me" + osSyncPrintf("\n\n"); + } + + if (pthis->actor.xzDistToPlayer < 200.0f && pthis->actor.world.pos.y <= player->actor.world.pos.y) { + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ENEMY); + pthis->actor.flags |= ACTOR_FLAG_0; + targetHeight = 40.0f + -10.0f * gSaveContext.linkAge; + + pthis->targetY = player->actor.world.pos.y + targetHeight; + if (pthis->targetY < pthis->actor.world.pos.y) { + pthis->targetY = pthis->actor.world.pos.y + targetHeight; + } + + pthis->originPos = pthis->actor.world.pos; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_POT_MOVE_START); + pthis->actionFunc = EnTuboTrap_Levitate; + } +} + +void EnTuboTrap_Levitate(EnTuboTrap* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.y += 5000; + Math_ApproachF(&pthis->actor.world.pos.y, pthis->targetY, 0.8f, 3.0f); + + if (fabsf(pthis->actor.world.pos.y - pthis->targetY) < 10.0f) { + pthis->actor.speedXZ = 10.0f; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actionFunc = EnTuboTrap_Fly; + } +} + +void EnTuboTrap_Fly(EnTuboTrap* pthis, GlobalContext* globalCtx) { + f32 dx = pthis->originPos.x - pthis->actor.world.pos.x; + f32 dy = pthis->originPos.y - pthis->actor.world.pos.y; + f32 dz = pthis->originPos.z - pthis->actor.world.pos.z; + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_TUBOOCK_FLY - SFX_FLAG); + + if (240.0f < sqrtf(SQ(dx) + SQ(dy) + SQ(dz))) { + Math_ApproachF(&pthis->actor.gravity, -3.0f, 0.2f, 0.5f); + } + + pthis->actor.shape.rot.y += 5000; + EnTuboTrap_HandleImpact(pthis, globalCtx); +} + +void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTuboTrap* pthis = (EnTuboTrap*)thisx; + s32 pad; + + pthis->actionFunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 20.0f, 0x1D); + Actor_SetFocus(&pthis->actor, 0.0f); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gPotDL); +} diff --git a/src/overlays/actors/ovl_En_Vali/z_en_vali.c b/src/overlays/actors/ovl_En_Vali/z_en_vali.c deleted file mode 100644 index b1ad22c6a..000000000 --- a/src/overlays/actors/ovl_En_Vali/z_en_vali.c +++ /dev/null @@ -1,824 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_VALI_Z_EN_VALI_C -#include "actor_common.h" -/* - * File: z_en_vali.c - * Overlay: ovl_En_Vali - * Description: Bari (Big Jellyfish) - */ - -#include "z_en_vali.h" -#include "objects/object_vali/object_vali.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_12) - -void EnVali_Init(Actor* thisx, GlobalContext* globalCtx); -void EnVali_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnVali_Update(Actor* thisx, GlobalContext* globalCtx); -void EnVali_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnVali_SetupLurk(EnVali* this); -void EnVali_SetupDropAppear(EnVali* this); - -void EnVali_Lurk(EnVali* this, GlobalContext* globalCtx); -void EnVali_DropAppear(EnVali* this, GlobalContext* globalCtx); -void EnVali_FloatIdle(EnVali* this, GlobalContext* globalCtx); -void EnVali_Attacked(EnVali* this, GlobalContext* globalCtx); -void EnVali_Retaliate(EnVali* this, GlobalContext* globalCtx); -void EnVali_MoveArmsDown(EnVali* this, GlobalContext* globalCtx); -void EnVali_Burnt(EnVali* this, GlobalContext* globalCtx); -void EnVali_DivideAndDie(EnVali* this, GlobalContext* globalCtx); -void EnVali_Stunned(EnVali* this, GlobalContext* globalCtx); -void EnVali_Frozen(EnVali* this, GlobalContext* globalCtx); -void EnVali_ReturnToLurk(EnVali* this, GlobalContext* globalCtx); - -const ActorInit En_Vali_InitVars = { - ACTOR_EN_VALI, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_VALI, - sizeof(EnVali), - (ActorFunc)EnVali_Init, - (ActorFunc)EnVali_Destroy, - (ActorFunc)EnVali_Update, - (ActorFunc)EnVali_Draw, -}; - -static ColliderQuadInit sQuadInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_TYPE_1, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x07, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT8, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x07, 0x08 }, - { 0xFFCFFFFF, 0x01, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 17, 35, -15, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 2, 18, 32, MASS_HEAVY }; - -typedef enum { - /* 0x0 */ BARI_DMGEFF_NONE, - /* 0x1 */ BARI_DMGEFF_STUN, - /* 0x2 */ BARI_DMGEFF_FIRE, - /* 0x3 */ BARI_DMGEFF_ICE, - /* 0xE */ BARI_DMGEFF_SLINGSHOT = 0xE, - /* 0xF */ BARI_DMGEFF_SWORD -} BariDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, BARI_DMGEFF_STUN), - /* Deku stick */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(0, BARI_DMGEFF_SLINGSHOT), - /* Explosive */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(0, BARI_DMGEFF_STUN), - /* Normal arrow */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Hookshot */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Kokiri sword */ DMG_ENTRY(1, BARI_DMGEFF_SWORD), - /* Master sword */ DMG_ENTRY(2, BARI_DMGEFF_SWORD), - /* Giant's Knife */ DMG_ENTRY(4, BARI_DMGEFF_SWORD), - /* Fire arrow */ DMG_ENTRY(4, BARI_DMGEFF_FIRE), - /* Ice arrow */ DMG_ENTRY(4, BARI_DMGEFF_ICE), - /* Light arrow */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Unk arrow 1 */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(4, BARI_DMGEFF_FIRE), - /* Ice magic */ DMG_ENTRY(4, BARI_DMGEFF_ICE), - /* Light magic */ DMG_ENTRY(0, BARI_DMGEFF_NONE), - /* Shield */ DMG_ENTRY(0, BARI_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, BARI_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, BARI_DMGEFF_NONE), - /* Giant spin */ DMG_ENTRY(4, BARI_DMGEFF_NONE), - /* Master spin */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Kokiri jump */ DMG_ENTRY(2, BARI_DMGEFF_NONE), - /* Giant jump */ DMG_ENTRY(8, BARI_DMGEFF_NONE), - /* Master jump */ DMG_ENTRY(4, BARI_DMGEFF_NONE), - /* Unknown 1 */ DMG_ENTRY(0, BARI_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, BARI_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, BARI_DMGEFF_NONE), - /* Unknown 2 */ DMG_ENTRY(0, BARI_DMGEFF_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x18, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 5000, ICHAIN_STOP), -}; - -void EnVali_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnVali* this = (EnVali*)thisx; - s32 bgId; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 27.0f); - this->actor.shape.shadowAlpha = 155; - SkelAnime_Init(globalCtx, &this->skelAnime, &gBariSkel, &gBariLurkingAnim, this->jointTable, this->morphTable, - EN_VALI_LIMB_MAX); - - Collider_InitQuad(globalCtx, &this->leftArmCollider); - Collider_SetQuad(globalCtx, &this->leftArmCollider, &this->actor, &sQuadInit); - Collider_InitQuad(globalCtx, &this->rightArmCollider); - Collider_SetQuad(globalCtx, &this->rightArmCollider, &this->actor, &sQuadInit); - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - - EnVali_SetupLurk(this); - - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); - this->actor.params = BARI_TYPE_NORMAL; - - if (this->actor.floorHeight == BGCHECK_Y_MIN) { - Actor_Kill(&this->actor); - } -} - -void EnVali_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnVali* this = (EnVali*)thisx; - - Collider_DestroyQuad(globalCtx, &this->leftArmCollider); - Collider_DestroyQuad(globalCtx, &this->rightArmCollider); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); -} - -void EnVali_SetupLurk(EnVali* this) { - Animation_PlayLoop(&this->skelAnime, &gBariLurkingAnim); - this->actor.draw = NULL; - this->bodyCollider.base.acFlags &= ~AC_ON; - this->actionFunc = EnVali_Lurk; -} - -void EnVali_SetupDropAppear(EnVali* this) { - this->actor.draw = EnVali_Draw; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.velocity.y = 1.0f; - this->actionFunc = EnVali_DropAppear; -} - -void EnVali_SetupFloatIdle(EnVali* this) { - Animation_MorphToLoop(&this->skelAnime, &gBariWaitingAnim, -3.0f); - this->leftArmCollider.dim.quad[2] = this->leftArmCollider.dim.quad[3] = this->rightArmCollider.dim.quad[2] = - this->rightArmCollider.dim.quad[3] = this->leftArmCollider.dim.quad[0] = this->leftArmCollider.dim.quad[1] = - this->rightArmCollider.dim.quad[0] = this->rightArmCollider.dim.quad[1] = this->actor.world.pos; - - this->leftArmCollider.dim.quad[2].y = this->leftArmCollider.dim.quad[3].y = this->rightArmCollider.dim.quad[2].y = - this->rightArmCollider.dim.quad[3].y = this->leftArmCollider.dim.quad[0].y = - this->leftArmCollider.dim.quad[1].y = this->rightArmCollider.dim.quad[0].y = - this->rightArmCollider.dim.quad[1].y = this->actor.world.pos.y - 10.0f; - - this->actor.flags &= ~ACTOR_FLAG_4; - this->bodyCollider.base.acFlags |= AC_ON; - this->slingshotReactionTimer = 0; - this->floatHomeHeight = this->actor.world.pos.y; - this->actionFunc = EnVali_FloatIdle; -} - -/** - * Used for both touching player/player's shield and being hit with sword. What to do next is determined by params. - */ -void EnVali_SetupAttacked(EnVali* this) { - this->lightningTimer = 20; - this->actor.flags &= ~ACTOR_FLAG_0; - this->bodyCollider.base.acFlags &= ~AC_ON; - this->actionFunc = EnVali_Attacked; -} - -void EnVali_SetupRetaliate(EnVali* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBariRetaliatingAnim, -5.0f); - Actor_SetColorFilter(&this->actor, 0x4000, 150, 0x2000, 30); - this->actor.params = BARI_TYPE_NORMAL; - this->bodyCollider.base.acFlags &= ~AC_ON; - this->actionFunc = EnVali_Retaliate; -} - -void EnVali_SetupMoveArmsDown(EnVali* this) { - Animation_PlayOnce(&this->skelAnime, &gBariMovingArmsDownAnim); - this->actionFunc = EnVali_MoveArmsDown; -} - -void EnVali_SetupBurnt(EnVali* this) { - this->timer = 2; - this->bodyCollider.base.acFlags &= ~AC_ON; - Actor_SetColorFilter(&this->actor, 0x4000, 150, 0x2000, 30); - this->actionFunc = EnVali_Burnt; -} - -void EnVali_SetupDivideAndDie(EnVali* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < 3; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BILI, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); - - this->actor.world.rot.y += 0x10000 / 3; - } - - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x50); - this->timer = Rand_S16Offset(10, 10); - this->bodyCollider.base.acFlags &= ~AC_ON; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BARI_SPLIT); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.draw = NULL; - this->actionFunc = EnVali_DivideAndDie; -} - -void EnVali_SetupStunned(EnVali* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBariWaitingAnim, 10.0f); - this->timer = 80; - this->actor.velocity.y = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, 80); - this->bodyCollider.info.bumper.effect = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actor.velocity.y = 1.0f; - this->actionFunc = EnVali_Stunned; -} - -void EnVali_SetupFrozen(EnVali* this) { - this->actor.velocity.y = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, 36); - this->bodyCollider.base.acFlags &= ~AC_ON; - this->timer = 36; - this->actionFunc = EnVali_Frozen; -} - -void EnVali_SetupReturnToLurk(EnVali* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gBariLurkingAnim, 10.0f); - this->actor.flags |= ACTOR_FLAG_4; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnVali_ReturnToLurk; -} - -void EnVali_DischargeLightning(EnVali* this, GlobalContext* globalCtx) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 255, 255, 255 }; - Vec3f pos; - s32 i; - f32 cos; - f32 sin; - s16 yaw; - - for (i = 0; i < 4; i++) { - cos = -Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - sin = Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - if (!((this->lightningTimer + (i << 1)) % 4)) { - yaw = (s16)Rand_CenteredFloat(12288.0f) + (i * 0x4000) + 0x2000; - pos.x = this->actor.world.pos.x + (Math_SinS(yaw) * 12.0f * cos); - pos.y = this->actor.world.pos.y - (Math_CosS(yaw) * 12.0f) + 10.0f; - pos.z = this->actor.world.pos.z + (Math_SinS(yaw) * 12.0f * sin); - - EffectSsLightning_Spawn(globalCtx, &pos, &primColor, &envColor, 17, yaw, 6, 2); - } - } - - func_8002F974(&this->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); -} - -void EnVali_Lurk(EnVali* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < 150.0f) { - EnVali_SetupDropAppear(this); - } -} - -void EnVali_DropAppear(EnVali* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - this->actor.velocity.y *= 1.5f; - this->actor.velocity.y = CLAMP_MAX(this->actor.velocity.y, 40.0f); - - if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, this->actor.velocity.y)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - EnVali_SetupFloatIdle(this); - } -} - -void EnVali_FloatIdle(EnVali* this, GlobalContext* globalCtx) { - s32 curFrame; - - SkelAnime_Update(&this->skelAnime); - - if (this->slingshotReactionTimer != 0) { - this->slingshotReactionTimer--; - } - - curFrame = this->skelAnime.curFrame; - - Math_StepToF(&this->floatHomeHeight, this->actor.floorHeight + 40.0f, 1.2f); - this->actor.world.pos.y = this->floatHomeHeight - (sinf(curFrame * M_PI * 0.0125f) * 8.0f); - - if (this->slingshotReactionTimer) { - this->actor.shape.rot.y += 0x800; - - if (((this->slingshotReactionTimer % 6) == 0) && (curFrame > 15) && (curFrame <= 55)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BARI_ROLL); - } - } else if ((curFrame == 16) || (curFrame == 30) || (curFrame == 42) || (curFrame == 55)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BARI_ROLL); - } - - curFrame = ((curFrame > 40) ? (80 - curFrame) : curFrame); - - this->actor.shape.rot.y += (s16)((curFrame + 4) * 0.4f * (0x10000 / 360.0f)); - if (this->actor.xzDistToPlayer > 250.0f) { - EnVali_SetupReturnToLurk(this); - } -} - -void EnVali_Attacked(EnVali* this, GlobalContext* globalCtx) { - if (this->lightningTimer != 0) { - this->lightningTimer--; - } - - EnVali_DischargeLightning(this, globalCtx); - - if (this->lightningTimer == 0) { - this->actor.flags |= ACTOR_FLAG_0; - this->bodyCollider.base.acFlags |= AC_ON; - if (this->actor.params == BARI_TYPE_SWORD_DAMAGE) { - EnVali_SetupRetaliate(this); - } else { - this->actionFunc = EnVali_FloatIdle; - } - } else if ((this->lightningTimer % 2) != 0) { - this->actor.world.pos.y += 1.0f; - } else { - this->actor.world.pos.y -= 1.0f; - } -} - -void EnVali_Retaliate(EnVali* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.colChkInfo.health != 0) { - EnVali_SetupMoveArmsDown(this); - } else { - EnVali_SetupDivideAndDie(this, globalCtx); - } - } -} - -void EnVali_MoveArmsDown(EnVali* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - EnVali_SetupFloatIdle(this); - } -} - -void EnVali_Burnt(EnVali* this, GlobalContext* globalCtx) { - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - EnVali_SetupDivideAndDie(this, globalCtx); - } -} - -void EnVali_DivideAndDie(EnVali* this, GlobalContext* globalCtx) { - static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f accel = { 0.0f, 0.0f, 0.0f }; - s16 scale; - Vec3f pos; - s32 i; - - if (this->timer != 0) { - this->timer--; - } - - for (i = 0; i < 2; i++) { - pos.x = this->actor.world.pos.x + Rand_CenteredFloat(20.0f); - pos.y = this->actor.world.pos.y + Rand_CenteredFloat(8.0f); - pos.z = this->actor.world.pos.z + Rand_CenteredFloat(20.0f); - velocity.y = (Rand_ZeroOne() + 1.0f); - scale = Rand_S16Offset(40, 40); - - if (Rand_ZeroOne() < 0.7f) { - EffectSsDtBubble_SpawnColorProfile(globalCtx, &pos, &velocity, &accel, scale, 25, 2, 1); - } else { - EffectSsDtBubble_SpawnColorProfile(globalCtx, &pos, &velocity, &accel, scale, 25, 0, 1); - } - } - - if (this->timer == 0) { - Actor_Kill(&this->actor); - } -} - -void EnVali_Stunned(EnVali* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->timer != 0) { - this->timer--; - } - - if (this->actor.velocity.y != 0.0f) { - if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, this->actor.velocity.y)) { - this->actor.velocity.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } else { - this->actor.velocity.y += 1.0f; - } - } - - if (this->timer == 0) { - this->bodyCollider.info.bumper.effect = 1; // Shock? - EnVali_SetupFloatIdle(this); - } -} - -void EnVali_Frozen(EnVali* this, GlobalContext* globalCtx) { - Vec3f pos; - s32 temp_v0; - s32 temp_v1; - - if (this->timer != 0) { - this->timer--; - } - - temp_v1 = this->timer - 20; - this->actor.colorFilterTimer = 36; - - if (temp_v1 > 0) { - temp_v0 = temp_v1 >> 1; - - if ((this->timer % 2) != 0) { - pos.y = this->actor.world.pos.y - 20.0f + (-temp_v0 * 5 + 40); - pos.x = this->actor.world.pos.x + ((temp_v0 & 2) ? 12.0f : -12.0f); - pos.z = this->actor.world.pos.z + ((temp_v0 & 1) ? 12.0f : -12.0f); - - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &this->actor, &pos, 150, 150, 150, 250, 235, 245, 255, - (Rand_ZeroOne() * 0.2f) + 1.3f); - } - } else if (this->timer == 0) { - this->actor.velocity.y += 1.0f; - if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, this->actor.velocity.y)) { - EnVali_SetupDivideAndDie(this, globalCtx); - this->actor.colorFilterTimer = 0; - } - } -} - -void EnVali_ReturnToLurk(EnVali* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.5f, 15.0f, 0.1f) < 0.01f) { - EnVali_SetupLurk(this); - } -} - -void EnVali_UpdateDamage(EnVali* this, GlobalContext* globalCtx) { - if (this->bodyCollider.base.acFlags & AC_HIT) { - this->bodyCollider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->bodyCollider.info, 1); - - if ((this->actor.colChkInfo.damageEffect != BARI_DMGEFF_NONE) || (this->actor.colChkInfo.damage != 0)) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BARI_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~ACTOR_FLAG_0; - } else if ((this->actor.colChkInfo.damageEffect != BARI_DMGEFF_STUN) && - (this->actor.colChkInfo.damageEffect != BARI_DMGEFF_SLINGSHOT)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BARI_DAMAGE); - } - - if (this->actor.colChkInfo.damageEffect == BARI_DMGEFF_STUN) { - if (this->actionFunc != EnVali_Stunned) { - EnVali_SetupStunned(this); - } - } else if (this->actor.colChkInfo.damageEffect == BARI_DMGEFF_SWORD) { - if (this->actionFunc != EnVali_Stunned) { - Actor_SetColorFilter(&this->actor, 0x4000, 150, 0x2000, 30); - this->actor.params = BARI_TYPE_SWORD_DAMAGE; - EnVali_SetupAttacked(this); - } else { - EnVali_SetupRetaliate(this); - } - } else if (this->actor.colChkInfo.damageEffect == BARI_DMGEFF_FIRE) { - EnVali_SetupBurnt(this); - } else if (this->actor.colChkInfo.damageEffect == BARI_DMGEFF_ICE) { - EnVali_SetupFrozen(this); - } else if (this->actor.colChkInfo.damageEffect == BARI_DMGEFF_SLINGSHOT) { - if (this->slingshotReactionTimer == 0) { - this->slingshotReactionTimer = 20; - } - } else { - EnVali_SetupRetaliate(this); - } - } - } -} - -void EnVali_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnVali* this = (EnVali*)thisx; - - if ((this->bodyCollider.base.atFlags & AT_HIT) || (this->leftArmCollider.base.atFlags & AT_HIT) || - (this->rightArmCollider.base.atFlags & AT_HIT)) { - this->leftArmCollider.base.atFlags &= ~AT_HIT; - this->rightArmCollider.base.atFlags &= ~AT_HIT; - this->bodyCollider.base.atFlags &= ~AT_HIT; - EnVali_SetupAttacked(this); - } - - EnVali_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); - - if ((this->actionFunc != EnVali_DivideAndDie) && (this->actionFunc != EnVali_Lurk)) { - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - - if (this->actionFunc == EnVali_FloatIdle) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->leftArmCollider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->rightArmCollider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - - if (this->bodyCollider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - Actor_SetFocus(&this->actor, 0.0f); - } -} - -// Draw and associated functions - -void EnVali_PulseOutside(EnVali* this, f32 curFrame, Vec3f* scale) { - f32 scaleChange; - - if (this->actionFunc == EnVali_Attacked) { - s32 scalePhase = 20 - (this->lightningTimer % 20); - - if (scalePhase >= 10) { - scalePhase -= 10; - } - - scale->y -= 0.2f * sinf((M_PI / 10) * scalePhase); - } else if (this->actionFunc == EnVali_Retaliate) { - scaleChange = sinf((M_PI / 10) * curFrame); - scale->y -= 0.24f * scaleChange; - scale->x -= 0.13f * scaleChange; - scale->z = scale->x; - } else if (this->actionFunc == EnVali_MoveArmsDown) { - scaleChange = cosf((M_PI / 50) * curFrame); - scale->y -= 0.24f * scaleChange; - scale->x -= 0.13f * scaleChange; - scale->z = scale->x; - } else if (this->actionFunc == EnVali_Stunned) { - scaleChange = sinf((M_PI / 10) * this->timer) * 0.08f; - scale->x += scaleChange; - scale->y -= scaleChange; - scale->z += scaleChange; - } else { - if (curFrame >= 40.0f) { - curFrame -= 40.0f; - } - - scale->y -= 0.2f * sinf((M_PI / 40) * curFrame); - } -} - -void EnVali_PulseInsides(EnVali* this, f32 curFrame, Vec3f* scale) { - f32 scaleChange; - - if (this->actionFunc == EnVali_Attacked) { - s32 scalePhase = 20 - (this->lightningTimer % 20); - - if (scalePhase >= 10) { - scalePhase -= 10; - } - - scale->y -= 0.13f * sinf((M_PI / 10) * scalePhase); - } else if (this->actionFunc == EnVali_Retaliate) { - scaleChange = sinf((M_PI / 10) * curFrame); - scale->y -= 0.18f * scaleChange; - scale->x -= 0.1f * scaleChange; - scale->z = scale->x; - } else if (this->actionFunc == EnVali_MoveArmsDown) { - scaleChange = cosf((M_PI / 50) * curFrame); - scale->y -= 0.18f * scaleChange; - scale->x -= 0.1f * scaleChange; - scale->z = scale->x; - } else if (this->actionFunc == EnVali_Stunned) { - scaleChange = sinf((M_PI / 10) * this->timer) * 0.08f; - scale->x -= scaleChange; - scale->y += scaleChange; - scale->z -= scaleChange; - } else { - if (curFrame >= 40.0f) { - curFrame -= 40.0f; - } - - scale->y -= 0.13f * sinf((M_PI / 40) * curFrame); - } -} - -s32 EnVali_SetArmLength(EnVali* this, f32 curFrame) { - f32 targetArmScale; - - if (this->actionFunc == EnVali_FloatIdle) { - if (curFrame <= 10.0f) { - targetArmScale = curFrame * 0.05f + 1.0f; - } else if (curFrame > 70.0f) { - targetArmScale = (80.0f - curFrame) * 0.05f + 1.0f; - } else { - targetArmScale = 1.5f; - } - } else if (this->actionFunc == EnVali_Retaliate) { - targetArmScale = 1.0f - sinf((M_PI / 10) * curFrame) * 0.35f; - } else if (this->actionFunc == EnVali_MoveArmsDown) { - targetArmScale = 1.0f - cosf((M_PI / 50) * curFrame) * 0.35f; - } else if ((this->actionFunc == EnVali_Attacked) || (this->actionFunc == EnVali_Frozen)) { - targetArmScale = this->armScale; - } else { - targetArmScale = 1.0f; - } - - Math_StepToF(&this->armScale, targetArmScale, 0.1f); - - if (this->armScale == 1.0f) { - return false; - } else { - return true; - } -} - -s32 EnVali_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnVali* this = (EnVali*)thisx; - f32 curFrame; - - if ((limbIndex == EN_VALI_LIMB_NUCLEUS) || (limbIndex == EN_VALI_LIMB_OUTER_HOOD) || - (limbIndex == EN_VALI_LIMB_INNER_HOOD)) { - *dList = NULL; - return false; - } else { - curFrame = this->skelAnime.curFrame; - - if ((limbIndex == EN_VALI_LIMB_LEFT_ARM_BASE) || (limbIndex == EN_VALI_LIMB_RIGHT_ARM_BASE)) { - if (EnVali_SetArmLength(this, curFrame)) { - Matrix_Scale(this->armScale, 1.0f, 1.0f, MTXMODE_APPLY); - } - } - - return false; - } -} - -void EnVali_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - static Vec3f D_80B28970 = { 3000.0f, 0.0f, 0.0f }; - static Vec3f D_80B2897C = { -1000.0f, 0.0f, 0.0f }; - Vec3f sp3C; - Vec3f sp30; - EnVali* this = (EnVali*)thisx; - - if (this->actionFunc == EnVali_FloatIdle) { - if ((limbIndex == EN_VALI_LIMB_LEFT_FOREARM_BASE) || (limbIndex == EN_VALI_LIMB_RIGHT_FOREARM_BASE)) { - Matrix_MultVec3f(&D_80B28970, &sp3C); - Matrix_MultVec3f(&D_80B2897C, &sp30); - - if (limbIndex == EN_VALI_LIMB_LEFT_FOREARM_BASE) { - Collider_SetQuadVertices(&this->leftArmCollider, &sp30, &sp3C, &this->leftArmCollider.dim.quad[0], - &this->leftArmCollider.dim.quad[1]); - } else { - Collider_SetQuadVertices(&this->rightArmCollider, &sp30, &sp3C, &this->rightArmCollider.dim.quad[0], - &this->rightArmCollider.dim.quad[1]); - } - } - } -} - -void EnVali_DrawBody(EnVali* this, GlobalContext* globalCtx) { - MtxF mtx; - f32 cos; - f32 sin; - f32 curFrame; - Vec3f scale = { 1.0f, 1.0f, 1.0f }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1428); - - Matrix_Get(&mtx); - curFrame = this->skelAnime.curFrame; - EnVali_PulseInsides(this, curFrame, &scale); - Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1436), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBariInnerHoodDL); - - Matrix_Put(&mtx); - Matrix_RotateY(-this->actor.shape.rot.y * (M_PI / 32768.0f), MTXMODE_APPLY); - - cos = Math_CosS(this->actor.shape.rot.y); - sin = Math_SinS(this->actor.shape.rot.y); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1446), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBariNucleusDL); - - Matrix_Translate((506.0f * cos) + (372.0f * sin), 1114.0f, (372.0f * cos) - (506.0f * sin), MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1455), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBariNucleusDL); - - Matrix_Translate((-964.0f * cos) - (804.0f * sin), -108.0f, (-804.0f * cos) + (964.0f * sin), MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1463), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBariNucleusDL); - - Matrix_Put(&mtx); - - scale.x = scale.y = scale.z = 1.0f; - - EnVali_PulseOutside(this, curFrame, &scale); - Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1471), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gBariOuterHoodDL); - - Matrix_Put(&mtx); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1477); -} - -static Gfx D_80B28998[] = { - gsDPSetCombineLERP(1, TEXEL0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0, TEXEL1, 0, - PRIM_LOD_FRAC, COMBINED), - gsSPEndDisplayList(), -}; - -static Gfx D_80B289A8[] = { - gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0, TEXEL1, 0, - PRIM_LOD_FRAC, COMBINED), - gsSPEndDisplayList(), -}; - -void EnVali_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnVali* this = (EnVali*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1505); - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (127 - (globalCtx->gameplayFrames * 12)) % 128, 32, 32)); - - if ((this->lightningTimer % 2) != 0) { - gSPSegment(POLY_XLU_DISP++, 0x09, D_80B28998); - } else { - gSPSegment(POLY_XLU_DISP++, 0x09, D_80B289A8); - } - - EnVali_DrawBody(this, globalCtx); - - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnVali_OverrideLimbDraw, EnVali_PostLimbDraw, this, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1538); -} diff --git a/src/overlays/actors/ovl_En_Vali/z_en_vali.cpp b/src/overlays/actors/ovl_En_Vali/z_en_vali.cpp new file mode 100644 index 000000000..951594468 --- /dev/null +++ b/src/overlays/actors/ovl_En_Vali/z_en_vali.cpp @@ -0,0 +1,824 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_VALI_Z_EN_VALI_C +#include "actor_common.h" +/* + * File: z_en_vali.c + * Overlay: ovl_En_Vali + * Description: Bari (Big Jellyfish) + */ + +#include "z_en_vali.h" +#include "objects/object_vali/object_vali.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_12) + +void EnVali_Init(Actor* thisx, GlobalContext* globalCtx); +void EnVali_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnVali_Update(Actor* thisx, GlobalContext* globalCtx); +void EnVali_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnVali_SetupLurk(EnVali* pthis); +void EnVali_SetupDropAppear(EnVali* pthis); + +void EnVali_Lurk(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_DropAppear(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_FloatIdle(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_Attacked(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_Retaliate(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_MoveArmsDown(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_Burnt(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_DivideAndDie(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_Stunned(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_Frozen(EnVali* pthis, GlobalContext* globalCtx); +void EnVali_ReturnToLurk(EnVali* pthis, GlobalContext* globalCtx); + +ActorInit En_Vali_InitVars = { + ACTOR_EN_VALI, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_VALI, + sizeof(EnVali), + (ActorFunc)EnVali_Init, + (ActorFunc)EnVali_Destroy, + (ActorFunc)EnVali_Update, + (ActorFunc)EnVali_Draw, +}; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x07, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT8, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x07, 0x08 }, + { 0xFFCFFFFF, 0x01, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 17, 35, -15, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 2, 18, 32, MASS_HEAVY }; + +typedef enum { + /* 0x0 */ BARI_DMGEFF_NONE, + /* 0x1 */ BARI_DMGEFF_STUN, + /* 0x2 */ BARI_DMGEFF_FIRE, + /* 0x3 */ BARI_DMGEFF_ICE, + /* 0xE */ BARI_DMGEFF_SLINGSHOT = 0xE, + /* 0xF */ BARI_DMGEFF_SWORD +} BariDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, BARI_DMGEFF_STUN), + /* Deku stick */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(0, BARI_DMGEFF_SLINGSHOT), + /* Explosive */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(0, BARI_DMGEFF_STUN), + /* Normal arrow */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Kokiri sword */ DMG_ENTRY(1, BARI_DMGEFF_SWORD), + /* Master sword */ DMG_ENTRY(2, BARI_DMGEFF_SWORD), + /* Giant's Knife */ DMG_ENTRY(4, BARI_DMGEFF_SWORD), + /* Fire arrow */ DMG_ENTRY(4, BARI_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(4, BARI_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Unk arrow 1 */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(4, BARI_DMGEFF_FIRE), + /* Ice magic */ DMG_ENTRY(4, BARI_DMGEFF_ICE), + /* Light magic */ DMG_ENTRY(0, BARI_DMGEFF_NONE), + /* Shield */ DMG_ENTRY(0, BARI_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, BARI_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, BARI_DMGEFF_NONE), + /* Giant spin */ DMG_ENTRY(4, BARI_DMGEFF_NONE), + /* Master spin */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Kokiri jump */ DMG_ENTRY(2, BARI_DMGEFF_NONE), + /* Giant jump */ DMG_ENTRY(8, BARI_DMGEFF_NONE), + /* Master jump */ DMG_ENTRY(4, BARI_DMGEFF_NONE), + /* Unknown 1 */ DMG_ENTRY(0, BARI_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, BARI_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, BARI_DMGEFF_NONE), + /* Unknown 2 */ DMG_ENTRY(0, BARI_DMGEFF_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x18, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 5000, ICHAIN_STOP), +}; + +void EnVali_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVali* pthis = (EnVali*)thisx; + s32 bgId; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 27.0f); + pthis->actor.shape.shadowAlpha = 155; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBariSkel, &gBariLurkingAnim, pthis->jointTable, pthis->morphTable, + EN_VALI_LIMB_MAX); + + Collider_InitQuad(globalCtx, &pthis->leftArmCollider); + Collider_SetQuad(globalCtx, &pthis->leftArmCollider, &pthis->actor, &sQuadInit); + Collider_InitQuad(globalCtx, &pthis->rightArmCollider); + Collider_SetQuad(globalCtx, &pthis->rightArmCollider, &pthis->actor, &sQuadInit); + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + EnVali_SetupLurk(pthis); + + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, + &pthis->actor, &pthis->actor.world.pos); + pthis->actor.params = BARI_TYPE_NORMAL; + + if (pthis->actor.floorHeight == BGCHECK_Y_MIN) { + Actor_Kill(&pthis->actor); + } +} + +void EnVali_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnVali* pthis = (EnVali*)thisx; + + Collider_DestroyQuad(globalCtx, &pthis->leftArmCollider); + Collider_DestroyQuad(globalCtx, &pthis->rightArmCollider); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); +} + +void EnVali_SetupLurk(EnVali* pthis) { + Animation_PlayLoop(&pthis->skelAnime, &gBariLurkingAnim); + pthis->actor.draw = NULL; + pthis->bodyCollider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnVali_Lurk; +} + +void EnVali_SetupDropAppear(EnVali* pthis) { + pthis->actor.draw = EnVali_Draw; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.velocity.y = 1.0f; + pthis->actionFunc = EnVali_DropAppear; +} + +void EnVali_SetupFloatIdle(EnVali* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gBariWaitingAnim, -3.0f); + pthis->leftArmCollider.dim.quad[2] = pthis->leftArmCollider.dim.quad[3] = pthis->rightArmCollider.dim.quad[2] = + pthis->rightArmCollider.dim.quad[3] = pthis->leftArmCollider.dim.quad[0] = pthis->leftArmCollider.dim.quad[1] = + pthis->rightArmCollider.dim.quad[0] = pthis->rightArmCollider.dim.quad[1] = pthis->actor.world.pos; + + pthis->leftArmCollider.dim.quad[2].y = pthis->leftArmCollider.dim.quad[3].y = pthis->rightArmCollider.dim.quad[2].y = + pthis->rightArmCollider.dim.quad[3].y = pthis->leftArmCollider.dim.quad[0].y = + pthis->leftArmCollider.dim.quad[1].y = pthis->rightArmCollider.dim.quad[0].y = + pthis->rightArmCollider.dim.quad[1].y = pthis->actor.world.pos.y - 10.0f; + + pthis->actor.flags &= ~ACTOR_FLAG_4; + pthis->bodyCollider.base.acFlags |= AC_ON; + pthis->slingshotReactionTimer = 0; + pthis->floatHomeHeight = pthis->actor.world.pos.y; + pthis->actionFunc = EnVali_FloatIdle; +} + +/** + * Used for both touching player/player's shield and being hit with sword. What to do next is determined by params. + */ +void EnVali_SetupAttacked(EnVali* pthis) { + pthis->lightningTimer = 20; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->bodyCollider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnVali_Attacked; +} + +void EnVali_SetupRetaliate(EnVali* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBariRetaliatingAnim, -5.0f); + Actor_SetColorFilter(&pthis->actor, 0x4000, 150, 0x2000, 30); + pthis->actor.params = BARI_TYPE_NORMAL; + pthis->bodyCollider.base.acFlags &= ~AC_ON; + pthis->actionFunc = EnVali_Retaliate; +} + +void EnVali_SetupMoveArmsDown(EnVali* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gBariMovingArmsDownAnim); + pthis->actionFunc = EnVali_MoveArmsDown; +} + +void EnVali_SetupBurnt(EnVali* pthis) { + pthis->timer = 2; + pthis->bodyCollider.base.acFlags &= ~AC_ON; + Actor_SetColorFilter(&pthis->actor, 0x4000, 150, 0x2000, 30); + pthis->actionFunc = EnVali_Burnt; +} + +void EnVali_SetupDivideAndDie(EnVali* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < 3; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BILI, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, pthis->actor.world.rot.y, 0, 0); + + pthis->actor.world.rot.y += 0x10000 / 3; + } + + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0x50); + pthis->timer = Rand_S16Offset(10, 10); + pthis->bodyCollider.base.acFlags &= ~AC_ON; + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EN_BARI_SPLIT); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.draw = NULL; + pthis->actionFunc = EnVali_DivideAndDie; +} + +void EnVali_SetupStunned(EnVali* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBariWaitingAnim, 10.0f); + pthis->timer = 80; + pthis->actor.velocity.y = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0x2000, 80); + pthis->bodyCollider.info.bumper.effect = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actor.velocity.y = 1.0f; + pthis->actionFunc = EnVali_Stunned; +} + +void EnVali_SetupFrozen(EnVali* pthis) { + pthis->actor.velocity.y = 0.0f; + Actor_SetColorFilter(&pthis->actor, 0, 255, 0x2000, 36); + pthis->bodyCollider.base.acFlags &= ~AC_ON; + pthis->timer = 36; + pthis->actionFunc = EnVali_Frozen; +} + +void EnVali_SetupReturnToLurk(EnVali* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gBariLurkingAnim, 10.0f); + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnVali_ReturnToLurk; +} + +void EnVali_DischargeLightning(EnVali* pthis, GlobalContext* globalCtx) { + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 255, 255, 255 }; + Vec3f pos; + s32 i; + f32 cos; + f32 sin; + s16 yaw; + + for (i = 0; i < 4; i++) { + cos = -Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + sin = Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + if (!((pthis->lightningTimer + (i << 1)) % 4)) { + yaw = (s16)Rand_CenteredFloat(12288.0f) + (i * 0x4000) + 0x2000; + pos.x = pthis->actor.world.pos.x + (Math_SinS(yaw) * 12.0f * cos); + pos.y = pthis->actor.world.pos.y - (Math_CosS(yaw) * 12.0f) + 10.0f; + pos.z = pthis->actor.world.pos.z + (Math_SinS(yaw) * 12.0f * sin); + + EffectSsLightning_Spawn(globalCtx, &pos, &primColor, &envColor, 17, yaw, 6, 2); + } + } + + func_8002F974(&pthis->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); +} + +void EnVali_Lurk(EnVali* pthis, GlobalContext* globalCtx) { + if (pthis->actor.xzDistToPlayer < 150.0f) { + EnVali_SetupDropAppear(pthis); + } +} + +void EnVali_DropAppear(EnVali* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + pthis->actor.velocity.y *= 1.5f; + pthis->actor.velocity.y = CLAMP_MAX(pthis->actor.velocity.y, 40.0f); + + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, pthis->actor.velocity.y)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + EnVali_SetupFloatIdle(pthis); + } +} + +void EnVali_FloatIdle(EnVali* pthis, GlobalContext* globalCtx) { + s32 curFrame; + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->slingshotReactionTimer != 0) { + pthis->slingshotReactionTimer--; + } + + curFrame = pthis->skelAnime.curFrame; + + Math_StepToF(&pthis->floatHomeHeight, pthis->actor.floorHeight + 40.0f, 1.2f); + pthis->actor.world.pos.y = pthis->floatHomeHeight - (sinf(curFrame * M_PI * 0.0125f) * 8.0f); + + if (pthis->slingshotReactionTimer) { + pthis->actor.shape.rot.y += 0x800; + + if (((pthis->slingshotReactionTimer % 6) == 0) && (curFrame > 15) && (curFrame <= 55)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BARI_ROLL); + } + } else if ((curFrame == 16) || (curFrame == 30) || (curFrame == 42) || (curFrame == 55)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BARI_ROLL); + } + + curFrame = ((curFrame > 40) ? (80 - curFrame) : curFrame); + + pthis->actor.shape.rot.y += (s16)((curFrame + 4) * 0.4f * (0x10000 / 360.0f)); + if (pthis->actor.xzDistToPlayer > 250.0f) { + EnVali_SetupReturnToLurk(pthis); + } +} + +void EnVali_Attacked(EnVali* pthis, GlobalContext* globalCtx) { + if (pthis->lightningTimer != 0) { + pthis->lightningTimer--; + } + + EnVali_DischargeLightning(pthis, globalCtx); + + if (pthis->lightningTimer == 0) { + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->bodyCollider.base.acFlags |= AC_ON; + if (pthis->actor.params == BARI_TYPE_SWORD_DAMAGE) { + EnVali_SetupRetaliate(pthis); + } else { + pthis->actionFunc = EnVali_FloatIdle; + } + } else if ((pthis->lightningTimer % 2) != 0) { + pthis->actor.world.pos.y += 1.0f; + } else { + pthis->actor.world.pos.y -= 1.0f; + } +} + +void EnVali_Retaliate(EnVali* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.colChkInfo.health != 0) { + EnVali_SetupMoveArmsDown(pthis); + } else { + EnVali_SetupDivideAndDie(pthis, globalCtx); + } + } +} + +void EnVali_MoveArmsDown(EnVali* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + EnVali_SetupFloatIdle(pthis); + } +} + +void EnVali_Burnt(EnVali* pthis, GlobalContext* globalCtx) { + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + EnVali_SetupDivideAndDie(pthis, globalCtx); + } +} + +void EnVali_DivideAndDie(EnVali* pthis, GlobalContext* globalCtx) { + static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f accel = { 0.0f, 0.0f, 0.0f }; + s16 scale; + Vec3f pos; + s32 i; + + if (pthis->timer != 0) { + pthis->timer--; + } + + for (i = 0; i < 2; i++) { + pos.x = pthis->actor.world.pos.x + Rand_CenteredFloat(20.0f); + pos.y = pthis->actor.world.pos.y + Rand_CenteredFloat(8.0f); + pos.z = pthis->actor.world.pos.z + Rand_CenteredFloat(20.0f); + velocity.y = (Rand_ZeroOne() + 1.0f); + scale = Rand_S16Offset(40, 40); + + if (Rand_ZeroOne() < 0.7f) { + EffectSsDtBubble_SpawnColorProfile(globalCtx, &pos, &velocity, &accel, scale, 25, 2, 1); + } else { + EffectSsDtBubble_SpawnColorProfile(globalCtx, &pos, &velocity, &accel, scale, 25, 0, 1); + } + } + + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); + } +} + +void EnVali_Stunned(EnVali* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->actor.velocity.y != 0.0f) { + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, pthis->actor.velocity.y)) { + pthis->actor.velocity.y = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } else { + pthis->actor.velocity.y += 1.0f; + } + } + + if (pthis->timer == 0) { + pthis->bodyCollider.info.bumper.effect = 1; // Shock? + EnVali_SetupFloatIdle(pthis); + } +} + +void EnVali_Frozen(EnVali* pthis, GlobalContext* globalCtx) { + Vec3f pos; + s32 temp_v0; + s32 temp_v1; + + if (pthis->timer != 0) { + pthis->timer--; + } + + temp_v1 = pthis->timer - 20; + pthis->actor.colorFilterTimer = 36; + + if (temp_v1 > 0) { + temp_v0 = temp_v1 >> 1; + + if ((pthis->timer % 2) != 0) { + pos.y = pthis->actor.world.pos.y - 20.0f + (-temp_v0 * 5 + 40); + pos.x = pthis->actor.world.pos.x + ((temp_v0 & 2) ? 12.0f : -12.0f); + pos.z = pthis->actor.world.pos.z + ((temp_v0 & 1) ? 12.0f : -12.0f); + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, &pthis->actor, &pos, 150, 150, 150, 250, 235, 245, 255, + (Rand_ZeroOne() * 0.2f) + 1.3f); + } + } else if (pthis->timer == 0) { + pthis->actor.velocity.y += 1.0f; + if (Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.floorHeight, pthis->actor.velocity.y)) { + EnVali_SetupDivideAndDie(pthis, globalCtx); + pthis->actor.colorFilterTimer = 0; + } + } +} + +void EnVali_ReturnToLurk(EnVali* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (Math_SmoothStepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y, 0.5f, 15.0f, 0.1f) < 0.01f) { + EnVali_SetupLurk(pthis); + } +} + +void EnVali_UpdateDamage(EnVali* pthis, GlobalContext* globalCtx) { + if (pthis->bodyCollider.base.acFlags & AC_HIT) { + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->bodyCollider.info, 1); + + if ((pthis->actor.colChkInfo.damageEffect != BARI_DMGEFF_NONE) || (pthis->actor.colChkInfo.damage != 0)) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BARI_DEAD); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else if ((pthis->actor.colChkInfo.damageEffect != BARI_DMGEFF_STUN) && + (pthis->actor.colChkInfo.damageEffect != BARI_DMGEFF_SLINGSHOT)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BARI_DAMAGE); + } + + if (pthis->actor.colChkInfo.damageEffect == BARI_DMGEFF_STUN) { + if (pthis->actionFunc != EnVali_Stunned) { + EnVali_SetupStunned(pthis); + } + } else if (pthis->actor.colChkInfo.damageEffect == BARI_DMGEFF_SWORD) { + if (pthis->actionFunc != EnVali_Stunned) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 150, 0x2000, 30); + pthis->actor.params = BARI_TYPE_SWORD_DAMAGE; + EnVali_SetupAttacked(pthis); + } else { + EnVali_SetupRetaliate(pthis); + } + } else if (pthis->actor.colChkInfo.damageEffect == BARI_DMGEFF_FIRE) { + EnVali_SetupBurnt(pthis); + } else if (pthis->actor.colChkInfo.damageEffect == BARI_DMGEFF_ICE) { + EnVali_SetupFrozen(pthis); + } else if (pthis->actor.colChkInfo.damageEffect == BARI_DMGEFF_SLINGSHOT) { + if (pthis->slingshotReactionTimer == 0) { + pthis->slingshotReactionTimer = 20; + } + } else { + EnVali_SetupRetaliate(pthis); + } + } + } +} + +void EnVali_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVali* pthis = (EnVali*)thisx; + + if ((pthis->bodyCollider.base.atFlags & AT_HIT) || (pthis->leftArmCollider.base.atFlags & AT_HIT) || + (pthis->rightArmCollider.base.atFlags & AT_HIT)) { + pthis->leftArmCollider.base.atFlags &= ~AT_HIT; + pthis->rightArmCollider.base.atFlags &= ~AT_HIT; + pthis->bodyCollider.base.atFlags &= ~AT_HIT; + EnVali_SetupAttacked(pthis); + } + + EnVali_UpdateDamage(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if ((pthis->actionFunc != EnVali_DivideAndDie) && (pthis->actionFunc != EnVali_Lurk)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + + if (pthis->actionFunc == EnVali_FloatIdle) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->leftArmCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->rightArmCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + + if (pthis->bodyCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + Actor_SetFocus(&pthis->actor, 0.0f); + } +} + +// Draw and associated functions + +void EnVali_PulseOutside(EnVali* pthis, f32 curFrame, Vec3f* scale) { + f32 scaleChange; + + if (pthis->actionFunc == EnVali_Attacked) { + s32 scalePhase = 20 - (pthis->lightningTimer % 20); + + if (scalePhase >= 10) { + scalePhase -= 10; + } + + scale->y -= 0.2f * sinf((M_PI / 10) * scalePhase); + } else if (pthis->actionFunc == EnVali_Retaliate) { + scaleChange = sinf((M_PI / 10) * curFrame); + scale->y -= 0.24f * scaleChange; + scale->x -= 0.13f * scaleChange; + scale->z = scale->x; + } else if (pthis->actionFunc == EnVali_MoveArmsDown) { + scaleChange = cosf((M_PI / 50) * curFrame); + scale->y -= 0.24f * scaleChange; + scale->x -= 0.13f * scaleChange; + scale->z = scale->x; + } else if (pthis->actionFunc == EnVali_Stunned) { + scaleChange = sinf((M_PI / 10) * pthis->timer) * 0.08f; + scale->x += scaleChange; + scale->y -= scaleChange; + scale->z += scaleChange; + } else { + if (curFrame >= 40.0f) { + curFrame -= 40.0f; + } + + scale->y -= 0.2f * sinf((M_PI / 40) * curFrame); + } +} + +void EnVali_PulseInsides(EnVali* pthis, f32 curFrame, Vec3f* scale) { + f32 scaleChange; + + if (pthis->actionFunc == EnVali_Attacked) { + s32 scalePhase = 20 - (pthis->lightningTimer % 20); + + if (scalePhase >= 10) { + scalePhase -= 10; + } + + scale->y -= 0.13f * sinf((M_PI / 10) * scalePhase); + } else if (pthis->actionFunc == EnVali_Retaliate) { + scaleChange = sinf((M_PI / 10) * curFrame); + scale->y -= 0.18f * scaleChange; + scale->x -= 0.1f * scaleChange; + scale->z = scale->x; + } else if (pthis->actionFunc == EnVali_MoveArmsDown) { + scaleChange = cosf((M_PI / 50) * curFrame); + scale->y -= 0.18f * scaleChange; + scale->x -= 0.1f * scaleChange; + scale->z = scale->x; + } else if (pthis->actionFunc == EnVali_Stunned) { + scaleChange = sinf((M_PI / 10) * pthis->timer) * 0.08f; + scale->x -= scaleChange; + scale->y += scaleChange; + scale->z -= scaleChange; + } else { + if (curFrame >= 40.0f) { + curFrame -= 40.0f; + } + + scale->y -= 0.13f * sinf((M_PI / 40) * curFrame); + } +} + +s32 EnVali_SetArmLength(EnVali* pthis, f32 curFrame) { + f32 targetArmScale; + + if (pthis->actionFunc == EnVali_FloatIdle) { + if (curFrame <= 10.0f) { + targetArmScale = curFrame * 0.05f + 1.0f; + } else if (curFrame > 70.0f) { + targetArmScale = (80.0f - curFrame) * 0.05f + 1.0f; + } else { + targetArmScale = 1.5f; + } + } else if (pthis->actionFunc == EnVali_Retaliate) { + targetArmScale = 1.0f - sinf((M_PI / 10) * curFrame) * 0.35f; + } else if (pthis->actionFunc == EnVali_MoveArmsDown) { + targetArmScale = 1.0f - cosf((M_PI / 50) * curFrame) * 0.35f; + } else if ((pthis->actionFunc == EnVali_Attacked) || (pthis->actionFunc == EnVali_Frozen)) { + targetArmScale = pthis->armScale; + } else { + targetArmScale = 1.0f; + } + + Math_StepToF(&pthis->armScale, targetArmScale, 0.1f); + + if (pthis->armScale == 1.0f) { + return false; + } else { + return true; + } +} + +s32 EnVali_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnVali* pthis = (EnVali*)thisx; + f32 curFrame; + + if ((limbIndex == EN_VALI_LIMB_NUCLEUS) || (limbIndex == EN_VALI_LIMB_OUTER_HOOD) || + (limbIndex == EN_VALI_LIMB_INNER_HOOD)) { + *dList = NULL; + return false; + } else { + curFrame = pthis->skelAnime.curFrame; + + if ((limbIndex == EN_VALI_LIMB_LEFT_ARM_BASE) || (limbIndex == EN_VALI_LIMB_RIGHT_ARM_BASE)) { + if (EnVali_SetArmLength(pthis, curFrame)) { + Matrix_Scale(pthis->armScale, 1.0f, 1.0f, MTXMODE_APPLY); + } + } + + return false; + } +} + +void EnVali_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + static Vec3f D_80B28970 = { 3000.0f, 0.0f, 0.0f }; + static Vec3f D_80B2897C = { -1000.0f, 0.0f, 0.0f }; + Vec3f sp3C; + Vec3f sp30; + EnVali* pthis = (EnVali*)thisx; + + if (pthis->actionFunc == EnVali_FloatIdle) { + if ((limbIndex == EN_VALI_LIMB_LEFT_FOREARM_BASE) || (limbIndex == EN_VALI_LIMB_RIGHT_FOREARM_BASE)) { + Matrix_MultVec3f(&D_80B28970, &sp3C); + Matrix_MultVec3f(&D_80B2897C, &sp30); + + if (limbIndex == EN_VALI_LIMB_LEFT_FOREARM_BASE) { + Collider_SetQuadVertices(&pthis->leftArmCollider, &sp30, &sp3C, &pthis->leftArmCollider.dim.quad[0], + &pthis->leftArmCollider.dim.quad[1]); + } else { + Collider_SetQuadVertices(&pthis->rightArmCollider, &sp30, &sp3C, &pthis->rightArmCollider.dim.quad[0], + &pthis->rightArmCollider.dim.quad[1]); + } + } + } +} + +void EnVali_DrawBody(EnVali* pthis, GlobalContext* globalCtx) { + MtxF mtx; + f32 cos; + f32 sin; + f32 curFrame; + Vec3f scale = { 1.0f, 1.0f, 1.0f }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1428); + + Matrix_Get(&mtx); + curFrame = pthis->skelAnime.curFrame; + EnVali_PulseInsides(pthis, curFrame, &scale); + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1436), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBariInnerHoodDL); + + Matrix_Put(&mtx); + Matrix_RotateY(-pthis->actor.shape.rot.y * (M_PI / 32768.0f), MTXMODE_APPLY); + + cos = Math_CosS(pthis->actor.shape.rot.y); + sin = Math_SinS(pthis->actor.shape.rot.y); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1446), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBariNucleusDL); + + Matrix_Translate((506.0f * cos) + (372.0f * sin), 1114.0f, (372.0f * cos) - (506.0f * sin), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1455), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBariNucleusDL); + + Matrix_Translate((-964.0f * cos) - (804.0f * sin), -108.0f, (-804.0f * cos) + (964.0f * sin), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1463), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBariNucleusDL); + + Matrix_Put(&mtx); + + scale.x = scale.y = scale.z = 1.0f; + + EnVali_PulseOutside(pthis, curFrame, &scale); + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vali.c", 1471), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBariOuterHoodDL); + + Matrix_Put(&mtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1477); +} + +static Gfx D_80B28998[] = { + gsDPSetCombineLERP(1, TEXEL0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0, TEXEL1, 0, + PRIM_LOD_FRAC, COMBINED), + gsSPEndDisplayList(), +}; + +static Gfx D_80B289A8[] = { + gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0, TEXEL1, 0, + PRIM_LOD_FRAC, COMBINED), + gsSPEndDisplayList(), +}; + +void EnVali_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVali* pthis = (EnVali*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1505); + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (127 - (globalCtx->gameplayFrames * 12)) % 128, 32, 32)); + + if ((pthis->lightningTimer % 2) != 0) { + gSPSegment(POLY_XLU_DISP++, 0x09, D_80B28998); + } else { + gSPSegment(POLY_XLU_DISP++, 0x09, D_80B289A8); + } + + EnVali_DrawBody(pthis, globalCtx); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnVali_OverrideLimbDraw, EnVali_PostLimbDraw, pthis, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_vali.c", 1538); +} diff --git a/src/overlays/actors/ovl_En_Vase/z_en_vase.c b/src/overlays/actors/ovl_En_Vase/z_en_vase.cpp similarity index 80% rename from src/overlays/actors/ovl_En_Vase/z_en_vase.c rename to src/overlays/actors/ovl_En_Vase/z_en_vase.cpp index 70eabbadd..30d376f75 100644 --- a/src/overlays/actors/ovl_En_Vase/z_en_vase.c +++ b/src/overlays/actors/ovl_En_Vase/z_en_vase.cpp @@ -17,7 +17,7 @@ void EnVase_Init(Actor* thisx, GlobalContext* globalCtx); void EnVase_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnVase_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Vase_InitVars = { +ActorInit En_Vase_InitVars = { ACTOR_EN_VASE, ACTORCAT_PROP, FLAGS, @@ -30,11 +30,11 @@ const ActorInit En_Vase_InitVars = { }; void EnVase_Init(Actor* thisx, GlobalContext* globalCtx) { - EnVase* this = (EnVase*)thisx; + EnVase* pthis = (EnVase*)thisx; - Actor_SetScale(&this->actor, 0.01f); - this->actor.focus.pos = this->actor.world.pos; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 6.0f); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.focus.pos = pthis->actor.world.pos; + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 6.0f); } void EnVase_Destroy(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c b/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.cpp similarity index 60% rename from src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c rename to src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.cpp index 7329e469a..528d9a8f6 100644 --- a/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c +++ b/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.cpp @@ -27,7 +27,7 @@ void EnVbBall_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx); void EnVbBall_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit En_Vb_Ball_InitVars = { +ActorInit En_Vb_Ball_InitVars = { 0, ACTORCAT_BOSS, FLAGS, @@ -61,37 +61,37 @@ static ColliderCylinderInit sCylinderInit = { void EnVbBall_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnVbBall* this = (EnVbBall*)thisx; + EnVbBall* pthis = (EnVbBall*)thisx; s32 pad2; f32 angle; - if (this->actor.params >= 200) { // Volvagia's bones - this->yRotVel = Rand_CenteredFloat(0x300); - this->xRotVel = Rand_CenteredFloat(0x300); - angle = Math_FAtan2F(this->actor.world.pos.x, this->actor.world.pos.z); - this->actor.velocity.y = Rand_ZeroFloat(3.0f); - this->actor.velocity.x = 2.0f * sinf(angle); - this->actor.velocity.z = 2.0f * cosf(angle); - this->actor.gravity = -0.8f; + if (pthis->actor.params >= 200) { // Volvagia's bones + pthis->yRotVel = Rand_CenteredFloat(0x300); + pthis->xRotVel = Rand_CenteredFloat(0x300); + angle = Math_FAtan2F(pthis->actor.world.pos.x, pthis->actor.world.pos.z); + pthis->actor.velocity.y = Rand_ZeroFloat(3.0f); + pthis->actor.velocity.x = 2.0f * sinf(angle); + pthis->actor.velocity.z = 2.0f * cosf(angle); + pthis->actor.gravity = -0.8f; } else { // Volvagia's rocks - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Actor_SetScale(&this->actor, this->actor.world.rot.z / 10000.0f); - this->collider.dim.radius = this->actor.scale.y * 3000.0f; - this->collider.dim.height = this->actor.scale.y * 5000.0f; - this->collider.dim.yShift = this->actor.scale.y * -2500.0f; - this->xRotVel = Rand_CenteredFloat(0x2000); - this->yRotVel = Rand_CenteredFloat(0x2000); - this->shadowSize = this->actor.scale.y * 68.0f; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Actor_SetScale(&pthis->actor, pthis->actor.world.rot.z / 10000.0f); + pthis->collider.dim.radius = pthis->actor.scale.y * 3000.0f; + pthis->collider.dim.height = pthis->actor.scale.y * 5000.0f; + pthis->collider.dim.yShift = pthis->actor.scale.y * -2500.0f; + pthis->xRotVel = Rand_CenteredFloat(0x2000); + pthis->yRotVel = Rand_CenteredFloat(0x2000); + pthis->shadowSize = pthis->actor.scale.y * 68.0f; } } void EnVbBall_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnVbBall* this = (EnVbBall*)thisx; + EnVbBall* pthis = (EnVbBall*)thisx; - if (this->actor.params < 200) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if (pthis->actor.params < 200) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } @@ -130,23 +130,23 @@ void EnVbBall_SpawnDust(GlobalContext* globalCtx, BossFdEffect* effect, Vec3f* p } } -void EnVbBall_UpdateBones(EnVbBall* this, GlobalContext* globalCtx) { - BossFd* bossFd = (BossFd*)this->actor.parent; +void EnVbBall_UpdateBones(EnVbBall* pthis, GlobalContext* globalCtx) { + BossFd* bossFd = (BossFd*)pthis->actor.parent; f32 pad2; f32 pad1; f32 angle; s16 i; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 4); - if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y <= 0.0f)) { - this->xRotVel = Rand_CenteredFloat((f32)0x4000); - this->yRotVel = Rand_CenteredFloat((f32)0x4000); - angle = Math_FAtan2F(this->actor.world.pos.x, this->actor.world.pos.z); - this->actor.velocity.x = sinf(angle) * 10.0f; - this->actor.velocity.z = cosf(angle) * 10.0f; - this->actor.velocity.y *= -0.5f; - if (this->actor.params & 1) { - Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_LAND, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 4); + if ((pthis->actor.bgCheckFlags & 1) && (pthis->actor.velocity.y <= 0.0f)) { + pthis->xRotVel = Rand_CenteredFloat((f32)0x4000); + pthis->yRotVel = Rand_CenteredFloat((f32)0x4000); + angle = Math_FAtan2F(pthis->actor.world.pos.x, pthis->actor.world.pos.z); + pthis->actor.velocity.x = sinf(angle) * 10.0f; + pthis->actor.velocity.z = cosf(angle) * 10.0f; + pthis->actor.velocity.y *= -0.5f; + if (pthis->actor.params & 1) { + Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_LAND, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } for (i = 0; i < 10; i++) { @@ -160,52 +160,52 @@ void EnVbBall_UpdateBones(EnVbBall* this, GlobalContext* globalCtx) { dustAcc.y = 0.3f; - dustPos.x = Rand_CenteredFloat(20.0f) + this->actor.world.pos.x; - dustPos.y = this->actor.floorHeight + 10.0f; - dustPos.z = Rand_CenteredFloat(20.0f) + this->actor.world.pos.z; + dustPos.x = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.x; + dustPos.y = pthis->actor.floorHeight + 10.0f; + dustPos.z = Rand_CenteredFloat(20.0f) + pthis->actor.world.pos.z; EnVbBall_SpawnDust(globalCtx, bossFd->effects, &dustPos, &dustVel, &dustAcc, Rand_ZeroFloat(80.0f) + 200.0f); } } - if (this->actor.world.pos.y < 50.0f) { - Actor_Kill(&this->actor); + if (pthis->actor.world.pos.y < 50.0f) { + Actor_Kill(&pthis->actor); } } void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - EnVbBall* this = (EnVbBall*)thisx; - BossFd* bossFd = (BossFd*)this->actor.parent; + EnVbBall* pthis = (EnVbBall*)thisx; + BossFd* bossFd = (BossFd*)pthis->actor.parent; f32 radius; f32 pad2; s16 spawnNum; s16 i; - this->unkTimer2++; - if (this->unkTimer1 != 0) { - this->unkTimer1--; + pthis->unkTimer2++; + if (pthis->unkTimer1 != 0) { + pthis->unkTimer1--; } - this->actor.shape.rot.x += (s16)this->xRotVel; - this->actor.shape.rot.y += (s16)this->yRotVel; - this->actor.velocity.y += -1.0f; - this->actor.gravity = -1.0f; - func_8002D7EC(&this->actor); - if (this->actor.params >= 200) { - EnVbBall_UpdateBones(this, globalCtx); + pthis->actor.shape.rot.x += (s16)pthis->xRotVel; + pthis->actor.shape.rot.y += (s16)pthis->yRotVel; + pthis->actor.velocity.y += -1.0f; + pthis->actor.gravity = -1.0f; + func_8002D7EC(&pthis->actor); + if (pthis->actor.params >= 200) { + EnVbBall_UpdateBones(pthis, globalCtx); } else { - Math_ApproachF(&this->shadowOpacity, 175.0f, 1.0f, 40.0f); - radius = this->actor.scale.y * 1700.0f; - this->actor.world.pos.y -= radius; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 4); - this->actor.world.pos.y += radius; - if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y <= 0.0f)) { - if ((this->actor.params == 100) || (this->actor.params == 101)) { - Actor_Kill(&this->actor); - if (this->actor.params == 100) { - func_80033E88(&this->actor, globalCtx, 5, 0xA); + Math_ApproachF(&pthis->shadowOpacity, 175.0f, 1.0f, 40.0f); + radius = pthis->actor.scale.y * 1700.0f; + pthis->actor.world.pos.y -= radius; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 50.0f, 50.0f, 100.0f, 4); + pthis->actor.world.pos.y += radius; + if ((pthis->actor.bgCheckFlags & 1) && (pthis->actor.velocity.y <= 0.0f)) { + if ((pthis->actor.params == 100) || (pthis->actor.params == 101)) { + Actor_Kill(&pthis->actor); + if (pthis->actor.params == 100) { + func_80033E88(&pthis->actor, globalCtx, 5, 0xA); } - if (this->actor.params == 100) { + if (pthis->actor.params == 100) { spawnNum = 2; } else { spawnNum = 2; @@ -215,7 +215,7 @@ void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { EnVbBall* newActor; f32 xRotVel; - if (this->actor.params == 100) { + if (pthis->actor.params == 100) { spawnOffset.x = Rand_CenteredFloat(13.0f); spawnOffset.y = Rand_ZeroFloat(5.0f) + 6.0f; spawnOffset.z = Rand_CenteredFloat(13); @@ -224,17 +224,17 @@ void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { spawnOffset.y = Rand_ZeroFloat(3.0f) + 4.0f; spawnOffset.z = Rand_CenteredFloat(10.0f); } - newActor = (EnVbBall*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, - ACTOR_EN_VB_BALL, this->actor.world.pos.x + spawnOffset.x, - this->actor.world.pos.y + spawnOffset.y, - this->actor.world.pos.z + spawnOffset.z, 0, 0, - this->actor.world.rot.z * 0.5f, this->actor.params + 1); + newActor = (EnVbBall*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, + ACTOR_EN_VB_BALL, pthis->actor.world.pos.x + spawnOffset.x, + pthis->actor.world.pos.y + spawnOffset.y, + pthis->actor.world.pos.z + spawnOffset.z, 0, 0, + pthis->actor.world.rot.z * 0.5f, pthis->actor.params + 1); if (newActor != NULL) { - if ((i == 0) && (this->actor.params == 100)) { + if ((i == 0) && (pthis->actor.params == 100)) { Audio_PlaySoundGeneral(NA_SE_EN_VALVAISA_ROCK, &newActor->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - newActor->actor.parent = this->actor.parent; + newActor->actor.parent = pthis->actor.parent; newActor->actor.velocity = spawnOffset; newActor->yRotVel = 0.0f; xRotVel = sqrtf(SQ(spawnOffset.x) + SQ(spawnOffset.z)); @@ -252,9 +252,9 @@ void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { debrisVel1.y = Rand_ZeroFloat(5.0f) + 8; debrisVel1.z = Rand_CenteredFloat(25.0f); - debrisPos1.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; - debrisPos1.y = Rand_CenteredFloat(10.0f) + this->actor.world.pos.y; - debrisPos1.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; + debrisPos1.x = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.x; + debrisPos1.y = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.y; + debrisPos1.z = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.z; EnVbBall_SpawnDebris(globalCtx, bossFd->effects, &debrisPos1, &debrisVel1, &debrisAcc1, (s16)Rand_ZeroFloat(12.0f) + 15); @@ -270,9 +270,9 @@ void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { dustAcc.y = 1.0f / 2; - dustPos.x = Rand_CenteredFloat(30.0f) + this->actor.world.pos.x; - dustPos.y = Rand_CenteredFloat(30.0f) + this->actor.world.pos.y; - dustPos.z = Rand_CenteredFloat(30.0f) + this->actor.world.pos.z; + dustPos.x = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.x; + dustPos.y = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.y; + dustPos.z = Rand_CenteredFloat(30.0f) + pthis->actor.world.pos.z; EnVbBall_SpawnDust(globalCtx, bossFd->effects, &dustPos, &dustVel, &dustAcc, Rand_ZeroFloat(100.0f) + 350.0f); @@ -287,30 +287,30 @@ void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { debrisVel2.y = Rand_ZeroFloat(3.0f) + 3.0f; debrisVel2.z = Rand_CenteredFloat(10.0f); - debrisPos2.x = Rand_CenteredFloat(5.0f) + this->actor.world.pos.x; - debrisPos2.y = Rand_CenteredFloat(5.0f) + this->actor.world.pos.y; - debrisPos2.z = Rand_CenteredFloat(5.0f) + this->actor.world.pos.z; + debrisPos2.x = Rand_CenteredFloat(5.0f) + pthis->actor.world.pos.x; + debrisPos2.y = Rand_CenteredFloat(5.0f) + pthis->actor.world.pos.y; + debrisPos2.z = Rand_CenteredFloat(5.0f) + pthis->actor.world.pos.z; EnVbBall_SpawnDebris(globalCtx, bossFd->effects, &debrisPos2, &debrisVel2, &debrisAcc2, (s16)Rand_ZeroFloat(12.0f) + 15); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } - if (this->collider.base.atFlags & AT_HIT) { + if (pthis->collider.base.atFlags & AT_HIT) { Player* player = GET_PLAYER(globalCtx); - this->collider.base.atFlags &= ~AT_HIT; + pthis->collider.base.atFlags &= ~AT_HIT; Audio_PlayActorSound2(&player->actor, NA_SE_PL_BODY_HIT); } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } void EnVbBall_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnVbBall* this = (EnVbBall*)thisx; + EnVbBall* pthis = (EnVbBall*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vb_ball.c", 604); if (1) {} // needed for match @@ -318,15 +318,15 @@ void EnVbBall_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vb_ball.c", 607), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->actor.params >= 200) { + if (pthis->actor.params >= 200) { gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gVolvagiaRibsDL)); } else { gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gVolvagiaRockDL)); func_80094044(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (s8)this->shadowOpacity); - Matrix_Translate(this->actor.world.pos.x, 100.0f, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->shadowSize, 1.0f, this->shadowSize, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, (s8)pthis->shadowOpacity); + Matrix_Translate(pthis->actor.world.pos.x, 100.0f, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(pthis->shadowSize, 1.0f, pthis->shadowSize, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vb_ball.c", 626), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gCircleShadowDL)); diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.cpp similarity index 63% rename from src/overlays/actors/ovl_En_Viewer/z_en_viewer.c rename to src/overlays/actors/ovl_En_Viewer/z_en_viewer.cpp index 5a8919dff..fcf459c45 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.cpp @@ -40,15 +40,15 @@ void EnViewer_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnViewer_Update(Actor* thisx, GlobalContext* globalCtx); void EnViewer_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnViewer_UpdatePosition(EnViewer* this, GlobalContext* globalCtx); -void EnViewer_DrawFireEffects(EnViewer* this2, GlobalContext* globalCtx); -void EnViewer_UpdateGanondorfCape(GlobalContext* globalCtx, EnViewer* this); -void EnViewer_InitImpl(EnViewer* this, GlobalContext* globalCtx); -void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx); +void EnViewer_UpdatePosition(EnViewer* pthis, GlobalContext* globalCtx); +void EnViewer_DrawFireEffects(EnViewer* pthis2, GlobalContext* globalCtx); +void EnViewer_UpdateGanondorfCape(GlobalContext* globalCtx, EnViewer* pthis); +void EnViewer_InitImpl(EnViewer* pthis, GlobalContext* globalCtx); +void EnViewer_UpdateImpl(EnViewer* pthis, GlobalContext* globalCtx); static u8 sHorseSfxPlayed = false; -const ActorInit En_Viewer_InitVars = { +ActorInit En_Viewer_InitVars = { ACTOR_EN_VIEWER, ACTORCAT_ITEMACTION, FLAGS, @@ -101,71 +101,71 @@ static EnGanonMant* sGanondorfCape; static Vec3f sGanondorfNeckWorldPos; -void EnViewer_SetupAction(EnViewer* this, EnViewerActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnViewer_SetupAction(EnViewer* pthis, EnViewerActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnViewer_Init(Actor* thisx, GlobalContext* globalCtx) { - EnViewer* this = (EnViewer*)thisx; + EnViewer* pthis = (EnViewer*)thisx; u8 type; - Actor_ProcessInitChain(&this->actor, sInitChain); - EnViewer_SetupAction(this, EnViewer_InitImpl); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + EnViewer_SetupAction(pthis, EnViewer_InitImpl); sHorseSfxPlayed = false; - type = this->actor.params >> 8; - this->unused = 0; - this->state = 0; - this->isVisible = false; + type = pthis->actor.params >> 8; + pthis->unused = 0; + pthis->state = 0; + pthis->isVisible = false; if (type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_5_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF || type == ENVIEWER_TYPE_9_GANONDORF) { - sGanondorfCape = (EnGanonMant*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, + sGanondorfCape = (EnGanonMant*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_GANON_MANT, 0.0f, 0.0f, 0.0f, 0, 0, 0, 35); } } void EnViewer_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnViewer* this = (EnViewer*)thisx; + EnViewer* pthis = (EnViewer*)thisx; - func_800A6888(globalCtx, &this->skin); + func_800A6888(globalCtx, &pthis->skin); } -void EnViewer_InitAnimGanondorfOrZelda(EnViewer* this, GlobalContext* globalCtx, void* skeletonHeaderSeg, +void EnViewer_InitAnimGanondorfOrZelda(EnViewer* pthis, GlobalContext* globalCtx, void* skeletonHeaderSeg, AnimationHeader* anim) { - s16 type = this->actor.params >> 8; + s16 type = pthis->actor.params >> 8; if (type == ENVIEWER_TYPE_2_ZELDA || type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_5_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF || type == ENVIEWER_TYPE_9_GANONDORF) { - SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, skeletonHeaderSeg, NULL, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &pthis->skin.skelAnime, (FlexSkeletonHeader*)skeletonHeaderSeg, NULL, NULL, NULL, 0); } else { - SkelAnime_Init(globalCtx, &this->skin.skelAnime, skeletonHeaderSeg, NULL, NULL, NULL, 0); + SkelAnime_Init(globalCtx, &pthis->skin.skelAnime, (SkeletonHeader*)skeletonHeaderSeg, NULL, NULL, NULL, 0); } - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animObjBankIndex].vromStart); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animObjBankIndex].vromStart.get()); if (type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF || type == ENVIEWER_TYPE_9_GANONDORF) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, anim, 1.0f); + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, anim, 1.0f); } else { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, anim, 3.0f); + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, anim, 3.0f); } } -void EnViewer_InitAnimImpa(EnViewer* this, GlobalContext* globalCtx, void* skeletonHeaderSeg, AnimationHeader* anim) { - SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, skeletonHeaderSeg, NULL, NULL, NULL, 0); - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animObjBankIndex].vromStart); - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, anim, 3.0f); +void EnViewer_InitAnimImpa(EnViewer* pthis, GlobalContext* globalCtx, void* skeletonHeaderSeg, AnimationHeader* anim) { + SkelAnime_InitFlex(globalCtx, &pthis->skin.skelAnime, (FlexSkeletonHeader*)skeletonHeaderSeg, NULL, NULL, NULL, 0); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animObjBankIndex].vromStart.get()); + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, anim, 3.0f); } -void EnViewer_InitAnimHorse(EnViewer* this, GlobalContext* globalCtx, void* skeletonHeaderSeg, AnimationHeader* anim) { +void EnViewer_InitAnimHorse(EnViewer* pthis, GlobalContext* globalCtx, void* skeletonHeaderSeg, AnimationHeader* anim) { u8 type; - func_800A663C(globalCtx, &this->skin, skeletonHeaderSeg, anim); - type = this->actor.params >> 8; + func_800A663C(globalCtx, &pthis->skin, (SkeletonHeader*)skeletonHeaderSeg, anim); + type = pthis->actor.params >> 8; if (!(type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_4_HORSE_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF || type == ENVIEWER_TYPE_9_GANONDORF)) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, anim, 3.0f); + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, anim, 3.0f); } else { - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, anim, 1.0f); + Animation_PlayOnceSetSpeed(&pthis->skin.skelAnime, anim, 1.0f); } } @@ -182,36 +182,36 @@ static ActorShadowFunc sShadowDrawFuncs[] = { ActorShadow_DrawHorse, }; -void EnViewer_InitImpl(EnViewer* this, GlobalContext* globalCtx) { - EnViewerInitData* initData = &sInitData[this->actor.params >> 8]; +void EnViewer_InitImpl(EnViewer* pthis, GlobalContext* globalCtx) { + EnViewerInitData* initData = &sInitData[pthis->actor.params >> 8]; s32 skelObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, initData->skeletonObject); ASSERT(skelObjBankIndex >= 0, "bank_ID >= 0", "../z_en_viewer.c", 576); - this->animObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, initData->animObject); - ASSERT(this->animObjBankIndex >= 0, "this->anime_bank_ID >= 0", "../z_en_viewer.c", 579); + pthis->animObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, initData->animObject); + ASSERT(pthis->animObjBankIndex >= 0, "pthis->anime_bank_ID >= 0", "../z_en_viewer.c", 579); if (!Object_IsLoaded(&globalCtx->objectCtx, skelObjBankIndex) || - !Object_IsLoaded(&globalCtx->objectCtx, this->animObjBankIndex)) { - this->actor.flags &= ~ACTOR_FLAG_UNCULLED; + !Object_IsLoaded(&globalCtx->objectCtx, pthis->animObjBankIndex)) { + pthis->actor.flags &= ~ACTOR_FLAG_UNCULLED; return; } - this->isVisible = true; - this->actor.objBankIndex = skelObjBankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); - Actor_SetScale(&this->actor, initData->scale / 100.0f); - ActorShape_Init(&this->actor.shape, initData->yOffset * 100, sShadowDrawFuncs[initData->shadowType], + pthis->isVisible = true; + pthis->actor.objBankIndex = skelObjBankIndex; + Actor_SetObjectDependency(globalCtx, &pthis->actor); + Actor_SetScale(&pthis->actor, initData->scale / 100.0f); + ActorShape_Init(&pthis->actor.shape, initData->yOffset * 100, sShadowDrawFuncs[initData->shadowType], initData->shadowScale); - this->drawFuncIndex = initData->drawType; - sInitAnimFuncs[this->drawFuncIndex](this, globalCtx, initData->skeletonHeaderSeg, initData->anim); - EnViewer_SetupAction(this, EnViewer_UpdateImpl); + pthis->drawFuncIndex = initData->drawType; + sInitAnimFuncs[pthis->drawFuncIndex](pthis, globalCtx, initData->skeletonHeaderSeg, initData->anim); + EnViewer_SetupAction(pthis, EnViewer_UpdateImpl); } static s16 sTimer = 0; -void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx) { - u8 type = this->actor.params >> 8; +void EnViewer_UpdateImpl(EnViewer* pthis, GlobalContext* globalCtx) { + u8 type = pthis->actor.params >> 8; u16 csFrames; s32 animationEnded; @@ -219,16 +219,16 @@ void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx) { if (gSaveContext.sceneSetupIndex == 5) { csFrames = globalCtx->csCtx.frames; if (csFrames == 792) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_SURPRISE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_SURPRISE); } else if (csFrames == 845) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_THROW); + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_THROW); } } } else if (type == ENVIEWER_TYPE_7_GANONDORF) { - Actor_SetScale(&this->actor, 0.3f); - this->actor.uncullZoneForward = 10000.0f; - this->actor.uncullZoneScale = 10000.0f; - this->actor.uncullZoneDownward = 10000.0f; + Actor_SetScale(&pthis->actor, 0.3f); + pthis->actor.uncullZoneForward = 10000.0f; + pthis->actor.uncullZoneScale = 10000.0f; + pthis->actor.uncullZoneDownward = 10000.0f; } else if (type == ENVIEWER_TYPE_3_GANONDORF) { if (gSaveContext.sceneSetupIndex == 4) { switch (globalCtx->csCtx.frames) { @@ -249,10 +249,10 @@ void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx) { } if (gSaveContext.sceneSetupIndex == 5) { if (globalCtx->csCtx.frames == 1508) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_ST_LAUGH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_ST_LAUGH); } if (globalCtx->csCtx.frames == 1545) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DEMO_6K, 32.0f, 101.0f, 1226.0f, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DEMO_6K, 32.0f, 101.0f, 1226.0f, 0, 0, 0, 0xC); } } @@ -260,29 +260,29 @@ void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(SEQ_PLAYER_FANFARE << 24 | NA_BGM_OPENING_GANON); } if (globalCtx->csCtx.frames == 960) { - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_GROAN, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } else if (type == ENVIEWER_TYPE_6_HORSE_GANONDORF) { if (gSaveContext.sceneSetupIndex == 5 || gSaveContext.sceneSetupIndex == 10) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_RUN_LEVEL - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_RUN_LEVEL - SFX_FLAG); } } else if (type == ENVIEWER_TYPE_4_HORSE_GANONDORF) { - s16 curFrame = this->skin.skelAnime.curFrame; + s16 curFrame = pthis->skin.skelAnime.curFrame; - if (this->skin.skelAnime.animation == &gHorseGanonRearingAnim) { + if (pthis->skin.skelAnime.animation == &gHorseGanonRearingAnim) { if (curFrame == 8) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_HORSE_NEIGH); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_HORSE_NEIGH); } if (curFrame == 30) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_LAND2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_LAND2); } - } else if (this->skin.skelAnime.animation == &gHorseGanonIdleAnim) { + } else if (pthis->skin.skelAnime.animation == &gHorseGanonIdleAnim) { if (curFrame == 25) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_SANDDUST); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_SANDDUST); } - } else if (this->skin.skelAnime.animation == &gHorseGanonGallopingAnim) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_RUN_LEVEL - SFX_FLAG); + } else if (pthis->skin.skelAnime.animation == &gHorseGanonGallopingAnim) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_RUN_LEVEL - SFX_FLAG); } } @@ -290,152 +290,152 @@ void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx) { sTimer--; } - EnViewer_UpdatePosition(this, globalCtx); - Actor_MoveForward(&this->actor); // has no effect, speed/velocity and gravity are 0 + EnViewer_UpdatePosition(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); // has no effect, speed/velocity and gravity are 0 - animationEnded = SkelAnime_Update(&this->skin.skelAnime); + animationEnded = SkelAnime_Update(&pthis->skin.skelAnime); if (type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_4_HORSE_GANONDORF) { if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[1] != NULL) { if (globalCtx->csCtx.npcActions[1]->action == 2 && sTimer == 0) { if (type == ENVIEWER_TYPE_3_GANONDORF) { - if (this->skin.skelAnime.animation != &object_gndd_Anim_002928) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_gndd_Anim_002928, 1.0f); + if (pthis->skin.skelAnime.animation != &object_gndd_Anim_002928) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_gndd_Anim_002928, 1.0f); } - } else if (this->skin.skelAnime.animation != &gHorseGanonIdleAnim) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &gHorseGanonIdleAnim, 1.0f); + } else if (pthis->skin.skelAnime.animation != &gHorseGanonIdleAnim) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &gHorseGanonIdleAnim, 1.0f); } } else if (globalCtx->csCtx.npcActions[1]->action == 1) { sTimer = 100; if (type == ENVIEWER_TYPE_3_GANONDORF) { - if (this->skin.skelAnime.animation != &object_gndd_Anim_001D28) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_gndd_Anim_001D28, 1.0f); + if (pthis->skin.skelAnime.animation != &object_gndd_Anim_001D28) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_gndd_Anim_001D28, 1.0f); } - } else if (this->skin.skelAnime.animation != &gHorseGanonRearingAnim) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &gHorseGanonRearingAnim, 1.0f); + } else if (pthis->skin.skelAnime.animation != &gHorseGanonRearingAnim) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &gHorseGanonRearingAnim, 1.0f); } } else if (type == ENVIEWER_TYPE_3_GANONDORF) { - switch (this->state) { + switch (pthis->state) { case 0: if (globalCtx->csCtx.npcActions[1]->action == 4) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &object_gndd_Anim_000F54, -5.0f); - this->state++; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &object_gndd_Anim_000F54, -5.0f); + pthis->state++; } break; case 1: if (animationEnded) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_gndd_Anim_0014F4, -5.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_gndd_Anim_0014F4, -5.0f); + pthis->state++; } break; case 2: if (globalCtx->csCtx.npcActions[1]->action == 5) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &object_gndd_Anim_0008A0, -5.0f); - this->state++; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &object_gndd_Anim_0008A0, -5.0f); + pthis->state++; } break; case 3: if (animationEnded) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_gndd_Anim_000BC8, -5.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_gndd_Anim_000BC8, -5.0f); + pthis->state++; } break; case 4: if (globalCtx->csCtx.npcActions[1]->action == 11) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_gndd_Anim_0014F4, -20.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_gndd_Anim_0014F4, -20.0f); + pthis->state++; } break; case 5: if (globalCtx->csCtx.npcActions[1]->action == 8) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_gndd_Anim_002928, -15.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_gndd_Anim_002928, -15.0f); + pthis->state++; } break; case 6: if (globalCtx->csCtx.npcActions[1]->action == 12) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_VOICE_DEMO); - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_gndd_Anim_0005B4, 3.0f); - this->state++; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GANON_VOICE_DEMO); + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_gndd_Anim_0005B4, 3.0f); + pthis->state++; } break; case 7: - this->state = 0; + pthis->state = 0; break; } - } else if (this->skin.skelAnime.animation != &gHorseGanonGallopingAnim && + } else if (pthis->skin.skelAnime.animation != &gHorseGanonGallopingAnim && globalCtx->csCtx.npcActions[1]->action == 12) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &gHorseGanonGallopingAnim, 3.0f); + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &gHorseGanonGallopingAnim, 3.0f); } } } else if (type == ENVIEWER_TYPE_1_IMPA) { if (gSaveContext.sceneSetupIndex == 5) { if (globalCtx->csCtx.frames == 845) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_ITEM_OCARINA, 4.0f, 81.0f, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_ITEM_OCARINA, 4.0f, 81.0f, 2600.0f, 0, 0, 0, 0); } } else { if (globalCtx->csCtx.frames == 195) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_ITEM_OCARINA, 4.0f, 81.0f, + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_ITEM_OCARINA, 4.0f, 81.0f, 2035.0f, 0, 0, 0, 1); } } - switch (this->state) { + switch (pthis->state) { case 0: if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[0] != NULL && globalCtx->csCtx.npcActions[0]->action == 6 && - this->skin.skelAnime.animation != &object_opening_demo1_Anim_002574) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_opening_demo1_Anim_002574, 1.5f); - this->state++; + pthis->skin.skelAnime.animation != &object_opening_demo1_Anim_002574) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_opening_demo1_Anim_002574, 1.5f); + pthis->state++; } break; case 1: if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[0] != NULL && globalCtx->csCtx.npcActions[0]->action == 2 && - this->skin.skelAnime.animation != &object_opening_demo1_Anim_0029CC) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_opening_demo1_Anim_0029CC, 3.0f); - this->state++; + pthis->skin.skelAnime.animation != &object_opening_demo1_Anim_0029CC) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_opening_demo1_Anim_0029CC, 3.0f); + pthis->state++; } break; } } else if (type == ENVIEWER_TYPE_2_ZELDA) { if (globalCtx->sceneNum == SCENE_SPOT00) { // Hyrule Field - switch (this->state) { + switch (pthis->state) { case 0: if (globalCtx->csCtx.state != CS_STATE_IDLE) { if (globalCtx->csCtx.npcActions[0] != NULL && globalCtx->csCtx.npcActions[0]->action == 6 && - this->skin.skelAnime.animation != &object_opening_demo1_Anim_001410) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_opening_demo1_Anim_001410, 1.5f); - this->state++; + pthis->skin.skelAnime.animation != &object_opening_demo1_Anim_001410) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_opening_demo1_Anim_001410, 1.5f); + pthis->state++; } } break; case 1: if (globalCtx->csCtx.state != CS_STATE_IDLE) { if (globalCtx->csCtx.npcActions[0] != NULL && globalCtx->csCtx.npcActions[0]->action == 2 && - this->skin.skelAnime.animation != &object_opening_demo1_Anim_000450) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_opening_demo1_Anim_000450, 3.0f); - this->state++; + pthis->skin.skelAnime.animation != &object_opening_demo1_Anim_000450) { + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_opening_demo1_Anim_000450, 3.0f); + pthis->state++; } } break; } } else { Audio_SetBaseFilter(0); - switch (this->state) { + switch (pthis->state) { case 0: - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_opening_demo1_Anim_00504C, 1.0f); - this->state++; + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_opening_demo1_Anim_00504C, 1.0f); + pthis->state++; break; case 1: if (globalCtx->csCtx.npcActions[0]->action == 11) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &object_opening_demo1_Anim_00420C, -5.0f); - this->state++; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &object_opening_demo1_Anim_00420C, -5.0f); + pthis->state++; } break; case 2: if (animationEnded) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_opening_demo1_Anim_0048FC, -5.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_opening_demo1_Anim_0048FC, -5.0f); + pthis->state++; } break; case 3: @@ -443,62 +443,62 @@ void EnViewer_UpdateImpl(EnViewer* this, GlobalContext* globalCtx) { } } } else if (type == ENVIEWER_TYPE_7_GANONDORF) { - switch (this->state) { + switch (pthis->state) { case 0: if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[1] != NULL && globalCtx->csCtx.npcActions[1]->action == 7) { Audio_PlaySoundGeneral(NA_SE_EN_GANON_LAUGH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Animation_MorphToPlayOnce(&this->skin.skelAnime, &object_gndd_Anim_004534, -5.0f); - this->state++; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &object_gndd_Anim_004534, -5.0f); + pthis->state++; } break; case 1: if (animationEnded) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_gndd_Anim_0048B0, -5.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_gndd_Anim_0048B0, -5.0f); + pthis->state++; } break; } } else if (type == ENVIEWER_TYPE_8_GANONDORF) { - switch (this->state) { + switch (pthis->state) { case 0: if (globalCtx->csCtx.state != CS_STATE_IDLE) { if (globalCtx->csCtx.npcActions[1] != NULL && globalCtx->csCtx.npcActions[1]->action == 9) { - Animation_PlayLoopSetSpeed(&this->skin.skelAnime, &object_gndd_Anim_0050A8, 1.0f); - this->state++; + Animation_PlayLoopSetSpeed(&pthis->skin.skelAnime, &object_gndd_Anim_0050A8, 1.0f); + pthis->state++; } } break; case 1: if (globalCtx->csCtx.npcActions[1]->action == 10) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &object_gndd_Anim_003284, -10.0f); - this->state++; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &object_gndd_Anim_003284, -10.0f); + pthis->state++; } break; case 2: if (animationEnded) { - Animation_MorphToLoop(&this->skin.skelAnime, &object_gndd_Anim_003D84, -5.0f); - this->state++; + Animation_MorphToLoop(&pthis->skin.skelAnime, &object_gndd_Anim_003D84, -5.0f); + pthis->state++; } break; case 3: if (globalCtx->csCtx.npcActions[1]->action == 4) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &object_gndd_Anim_003428, -5.0f); - this->state++; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &object_gndd_Anim_003428, -5.0f); + pthis->state++; } break; default: - this->state = 0; + pthis->state = 0; break; } } } void EnViewer_Update(Actor* thisx, GlobalContext* globalCtx) { - EnViewer* this = (EnViewer*)thisx; + EnViewer* pthis = (EnViewer*)thisx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[this->animObjBankIndex].vromStart); - this->actionFunc(this, globalCtx); + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[pthis->animObjBankIndex].vromStart.get()); + pthis->actionFunc(pthis, globalCtx); } s32 EnViewer_Ganondorf3OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, @@ -539,12 +539,12 @@ void EnViewer_GanondorfPostLimbDrawUpdateCapeVec(GlobalContext* globalCtx, s32 l } } -void EnViewer_DrawGanondorf(EnViewer* this, GlobalContext* globalCtx) { +void EnViewer_DrawGanondorf(EnViewer* pthis, GlobalContext* globalCtx) { s16 frames = 0; s16 type; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1405); - type = this->actor.params >> 8; + type = pthis->actor.params >> 8; if (type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_5_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF) { if (gSaveContext.sceneSetupIndex != 4) { @@ -572,29 +572,29 @@ void EnViewer_DrawGanondorf(EnViewer* this, GlobalContext* globalCtx) { } if (type == ENVIEWER_TYPE_9_GANONDORF) { - SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, NULL, EnViewer_Ganondorf9PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skin.skelAnime.skeleton, pthis->skin.skelAnime.jointTable, + pthis->skin.skelAnime.dListCount, NULL, EnViewer_Ganondorf9PostLimbDraw, pthis); } else if (type == ENVIEWER_TYPE_3_GANONDORF) { - SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, EnViewer_Ganondorf3OverrideLimbDraw, - EnViewer_GanondorfPostLimbDrawUpdateCapeVec, this); - EnViewer_UpdateGanondorfCape(globalCtx, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skin.skelAnime.skeleton, pthis->skin.skelAnime.jointTable, + pthis->skin.skelAnime.dListCount, EnViewer_Ganondorf3OverrideLimbDraw, + EnViewer_GanondorfPostLimbDrawUpdateCapeVec, pthis); + EnViewer_UpdateGanondorfCape(globalCtx, pthis); } else if (type == ENVIEWER_TYPE_3_GANONDORF || type == ENVIEWER_TYPE_5_GANONDORF || type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF) { if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[1] != NULL)) { - SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, NULL, EnViewer_GanondorfPostLimbDrawUpdateCapeVec, - this); - EnViewer_UpdateGanondorfCape(globalCtx, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skin.skelAnime.skeleton, pthis->skin.skelAnime.jointTable, + pthis->skin.skelAnime.dListCount, NULL, EnViewer_GanondorfPostLimbDrawUpdateCapeVec, + pthis); + EnViewer_UpdateGanondorfCape(globalCtx, pthis); } } else { - SkelAnime_DrawOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, NULL, NULL, this); + SkelAnime_DrawOpa(globalCtx, pthis->skin.skelAnime.skeleton, pthis->skin.skelAnime.jointTable, NULL, NULL, pthis); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1511); } -void EnViewer_DrawHorse(EnViewer* this, GlobalContext* globalCtx) { - func_800A6330(&this->actor, globalCtx, &this->skin, NULL, 1); +void EnViewer_DrawHorse(EnViewer* pthis, GlobalContext* globalCtx) { + func_800A6330(&pthis->actor, globalCtx, &pthis->skin, NULL, 1); } s32 EnViewer_ZeldaOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, @@ -634,7 +634,7 @@ void EnViewer_ZeldaPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } } -void EnViewer_DrawZelda(EnViewer* this, GlobalContext* globalCtx) { +void EnViewer_DrawZelda(EnViewer* pthis, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1583); if (globalCtx->sceneNum == SCENE_SPOT00) { // Hyrule Field if (globalCtx->csCtx.frames < 771) { @@ -676,9 +676,9 @@ void EnViewer_DrawZelda(EnViewer* this, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gChildZeldaEyeShutTex)); gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(gChildZeldaMouthWorriedTex)); } - SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, EnViewer_ZeldaOverrideLimbDraw, EnViewer_ZeldaPostLimbDraw, - this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skin.skelAnime.skeleton, pthis->skin.skelAnime.jointTable, + pthis->skin.skelAnime.dListCount, EnViewer_ZeldaOverrideLimbDraw, EnViewer_ZeldaPostLimbDraw, + pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1690); } @@ -690,14 +690,14 @@ s32 EnViewer_ImpaOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnViewer_DrawImpa(EnViewer* this, GlobalContext* globalCtx) { +void EnViewer_DrawImpa(EnViewer* pthis, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1717); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gImpaEyeOpenTex)); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gImpaEyeOpenTex)); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x0C, &D_80116280[2]); - SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, EnViewer_ImpaOverrideLimbDraw, NULL, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skin.skelAnime.skeleton, pthis->skin.skelAnime.jointTable, + pthis->skin.skelAnime.dListCount, EnViewer_ImpaOverrideLimbDraw, NULL, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1740); } @@ -709,32 +709,32 @@ static EnViewerDrawFunc sDrawFuncs[] = { }; void EnViewer_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnViewer* this = (EnViewer*)thisx; + EnViewer* pthis = (EnViewer*)thisx; s32 pad; s16 type; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1760); - if (this->isVisible) { - type = this->actor.params >> 8; + if (pthis->isVisible) { + type = pthis->actor.params >> 8; if (type <= ENVIEWER_TYPE_2_ZELDA) { // zelda's horse, impa and zelda if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[0] != NULL) { func_80093D18(globalCtx->state.gfxCtx); - sDrawFuncs[this->drawFuncIndex](this, globalCtx); + sDrawFuncs[pthis->drawFuncIndex](pthis, globalCtx); } } else if ((globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[1] != NULL) || type == ENVIEWER_TYPE_9_GANONDORF) { func_80093D18(globalCtx->state.gfxCtx); - sDrawFuncs[this->drawFuncIndex](this, globalCtx); + sDrawFuncs[pthis->drawFuncIndex](pthis, globalCtx); } } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1784); } -void EnViewer_UpdatePosition(EnViewer* this, GlobalContext* globalCtx) { +void EnViewer_UpdatePosition(EnViewer* pthis, GlobalContext* globalCtx) { Vec3f startPos; Vec3f endPos; f32 lerpFactor; - s16 type = this->actor.params >> 8; + s16 type = pthis->actor.params >> 8; if (type <= ENVIEWER_TYPE_2_ZELDA) { // zelda's horse, impa and zelda if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[0] != NULL && @@ -742,10 +742,10 @@ void EnViewer_UpdatePosition(EnViewer* this, GlobalContext* globalCtx) { if (type == ENVIEWER_TYPE_0_HORSE_ZELDA) { if (!sHorseSfxPlayed) { sHorseSfxPlayed = true; - Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EV_HORSE_NEIGH, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_RUN_LEVEL - SFX_FLAG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_RUN_LEVEL - SFX_FLAG); } startPos.x = globalCtx->csCtx.npcActions[0]->startPos.x; @@ -756,9 +756,9 @@ void EnViewer_UpdatePosition(EnViewer* this, GlobalContext* globalCtx) { endPos.z = globalCtx->csCtx.npcActions[0]->endPos.z; lerpFactor = Environment_LerpWeight(globalCtx->csCtx.npcActions[0]->endFrame, globalCtx->csCtx.npcActions[0]->startFrame, globalCtx->csCtx.frames); - this->actor.world.pos.x = (endPos.x - startPos.x) * lerpFactor + startPos.x; - this->actor.world.pos.y = (endPos.y - startPos.y) * lerpFactor + startPos.y; - this->actor.world.pos.z = (endPos.z - startPos.z) * lerpFactor + startPos.z; + pthis->actor.world.pos.x = (endPos.x - startPos.x) * lerpFactor + startPos.x; + pthis->actor.world.pos.y = (endPos.y - startPos.y) * lerpFactor + startPos.y; + pthis->actor.world.pos.z = (endPos.z - startPos.z) * lerpFactor + startPos.z; } } else { // ganondorf and ganondorf's horse if (globalCtx->csCtx.state != CS_STATE_IDLE && globalCtx->csCtx.npcActions[1] != NULL && @@ -771,38 +771,38 @@ void EnViewer_UpdatePosition(EnViewer* this, GlobalContext* globalCtx) { endPos.z = globalCtx->csCtx.npcActions[1]->endPos.z; lerpFactor = Environment_LerpWeight(globalCtx->csCtx.npcActions[1]->endFrame, globalCtx->csCtx.npcActions[1]->startFrame, globalCtx->csCtx.frames); - this->actor.world.pos.x = (endPos.x - startPos.x) * lerpFactor + startPos.x; - this->actor.world.pos.y = (endPos.y - startPos.y) * lerpFactor + startPos.y; - this->actor.world.pos.z = (endPos.z - startPos.z) * lerpFactor + startPos.z; + pthis->actor.world.pos.x = (endPos.x - startPos.x) * lerpFactor + startPos.x; + pthis->actor.world.pos.y = (endPos.y - startPos.y) * lerpFactor + startPos.y; + pthis->actor.world.pos.z = (endPos.z - startPos.z) * lerpFactor + startPos.z; if (globalCtx->csCtx.npcActions[1]->action == 12) { s16 yaw = Math_Vec3f_Yaw(&startPos, &endPos); - Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 0xA, 0x3E8, 1); - Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 0xA, 0x3E8, 1); + Math_SmoothStepToS(&pthis->actor.world.rot.y, yaw, 0xA, 0x3E8, 1); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, yaw, 0xA, 0x3E8, 1); } if (type == ENVIEWER_TYPE_9_GANONDORF) { - this->actor.world.rot.x = globalCtx->csCtx.npcActions[1]->urot.x; - this->actor.world.rot.y = globalCtx->csCtx.npcActions[1]->urot.y; - this->actor.world.rot.z = globalCtx->csCtx.npcActions[1]->urot.z; - this->actor.shape.rot.x = globalCtx->csCtx.npcActions[1]->urot.x; - this->actor.shape.rot.y = globalCtx->csCtx.npcActions[1]->urot.y; - this->actor.shape.rot.z = globalCtx->csCtx.npcActions[1]->urot.z; + pthis->actor.world.rot.x = globalCtx->csCtx.npcActions[1]->urot.x; + pthis->actor.world.rot.y = globalCtx->csCtx.npcActions[1]->urot.y; + pthis->actor.world.rot.z = globalCtx->csCtx.npcActions[1]->urot.z; + pthis->actor.shape.rot.x = globalCtx->csCtx.npcActions[1]->urot.x; + pthis->actor.shape.rot.y = globalCtx->csCtx.npcActions[1]->urot.y; + pthis->actor.shape.rot.z = globalCtx->csCtx.npcActions[1]->urot.z; } } if (type == ENVIEWER_TYPE_5_GANONDORF) { Audio_PlaySoundGeneral(NA_SE_EV_BURNING - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - EnViewer_DrawFireEffects(this, globalCtx); + EnViewer_DrawFireEffects(pthis, globalCtx); } } } -void EnViewer_InitFireEffect(EnViewer* this, GlobalContext* globalCtx, s16 i) { +void EnViewer_InitFireEffect(EnViewer* pthis, GlobalContext* globalCtx, s16 i) { EnViewerFireEffect* eff; if ((i % 2) == 0) { - eff = &this->fireEffects[i]; + eff = &pthis->fireEffects[i]; eff->startPos.x = 100.0f; eff->startPos.y = -420.0f; eff->startPos.z = 400.0f; @@ -811,7 +811,7 @@ void EnViewer_InitFireEffect(EnViewer* this, GlobalContext* globalCtx, s16 i) { eff->endPos.z = -400.0f; eff->scale = (Rand_ZeroOne() * 5.0f + 12.0f) * 0.001f; } else { - eff = &this->fireEffects[i]; + eff = &pthis->fireEffects[i]; eff->startPos.x = -100.0f; eff->startPos.y = -420.0f; eff->startPos.z = 400.0f; @@ -820,50 +820,50 @@ void EnViewer_InitFireEffect(EnViewer* this, GlobalContext* globalCtx, s16 i) { eff->endPos.z = -400.0f; eff->scale = (Rand_ZeroOne() * 5.0f + 12.0f) * 0.001f; } - if (this) {} + if (pthis) {} } -void EnViewer_DrawFireEffects(EnViewer* this2, GlobalContext* globalCtx) { - EnViewer* this = this2; +void EnViewer_DrawFireEffects(EnViewer* pthis2, GlobalContext* globalCtx) { + EnViewer* pthis = pthis2; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 1941); - for (i = 0; i < ARRAY_COUNT(this->fireEffects); i++) { - switch (this->fireEffects[i].state) { + for (i = 0; i < ARRAY_COUNT(pthis->fireEffects); i++) { + switch (pthis->fireEffects[i].state) { case 0: - EnViewer_InitFireEffect(this, globalCtx, i); - this->fireEffects[i].lerpFactor = (i >> 1) * 0.1f; - this->fireEffects[i].lerpFactorSpeed = 0.01f; - this->fireEffects[i].state++; + EnViewer_InitFireEffect(pthis, globalCtx, i); + pthis->fireEffects[i].lerpFactor = (i >> 1) * 0.1f; + pthis->fireEffects[i].lerpFactorSpeed = 0.01f; + pthis->fireEffects[i].state++; break; case 1: - Math_SmoothStepToF(&this->fireEffects[i].lerpFactor, 1.0f, 1.0f, this->fireEffects[i].lerpFactorSpeed, - this->fireEffects[i].lerpFactorSpeed); - this->fireEffects[i].pos.x = - this->fireEffects[i].startPos.x + - (this->fireEffects[i].endPos.x - this->fireEffects[i].startPos.x) * this->fireEffects[i].lerpFactor; - this->fireEffects[i].pos.y = - this->fireEffects[i].startPos.y + - (this->fireEffects[i].endPos.y - this->fireEffects[i].startPos.y) * this->fireEffects[i].lerpFactor; - this->fireEffects[i].pos.z = - this->fireEffects[i].startPos.z + - (this->fireEffects[i].endPos.z - this->fireEffects[i].startPos.z) * this->fireEffects[i].lerpFactor; - if (this->fireEffects[i].lerpFactor >= 1.0f) { - this->fireEffects[i].state++; + Math_SmoothStepToF(&pthis->fireEffects[i].lerpFactor, 1.0f, 1.0f, pthis->fireEffects[i].lerpFactorSpeed, + pthis->fireEffects[i].lerpFactorSpeed); + pthis->fireEffects[i].pos.x = + pthis->fireEffects[i].startPos.x + + (pthis->fireEffects[i].endPos.x - pthis->fireEffects[i].startPos.x) * pthis->fireEffects[i].lerpFactor; + pthis->fireEffects[i].pos.y = + pthis->fireEffects[i].startPos.y + + (pthis->fireEffects[i].endPos.y - pthis->fireEffects[i].startPos.y) * pthis->fireEffects[i].lerpFactor; + pthis->fireEffects[i].pos.z = + pthis->fireEffects[i].startPos.z + + (pthis->fireEffects[i].endPos.z - pthis->fireEffects[i].startPos.z) * pthis->fireEffects[i].lerpFactor; + if (pthis->fireEffects[i].lerpFactor >= 1.0f) { + pthis->fireEffects[i].state++; } break; case 2: - EnViewer_InitFireEffect(this, globalCtx, i); - this->fireEffects[i].lerpFactor = 0.0f; - this->fireEffects[i].lerpFactorSpeed = 0.01f; - this->fireEffects[i].state--; + EnViewer_InitFireEffect(pthis, globalCtx, i); + pthis->fireEffects[i].lerpFactor = 0.0f; + pthis->fireEffects[i].lerpFactorSpeed = 0.01f; + pthis->fireEffects[i].state--; break; } func_80093D84(globalCtx->state.gfxCtx); - Matrix_Translate(this->fireEffects[i].pos.x, this->fireEffects[i].pos.y, this->fireEffects[i].pos.z, + Matrix_Translate(pthis->fireEffects[i].pos.x, pthis->fireEffects[i].pos.y, pthis->fireEffects[i].pos.z, MTXMODE_NEW); - Matrix_Scale(this->fireEffects[i].scale, this->fireEffects[i].scale, this->fireEffects[i].scale, MTXMODE_APPLY); + Matrix_Scale(pthis->fireEffects[i].scale, pthis->fireEffects[i].scale, pthis->fireEffects[i].scale, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (10 * i - 20 * globalCtx->state.frames) % 512, 32, 128)); @@ -877,12 +877,12 @@ void EnViewer_DrawFireEffects(EnViewer* this2, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_viewer.c", 2034); } -void EnViewer_UpdateGanondorfCape(GlobalContext* globalCtx, EnViewer* this) { +void EnViewer_UpdateGanondorfCape(GlobalContext* globalCtx, EnViewer* pthis) { static s16 yOscillationPhase = 0; Vec3f forearmModelOffset; Vec3f forearmWorldOffset; - if ((this->actor.params >> 8) == ENVIEWER_TYPE_5_GANONDORF) { + if ((pthis->actor.params >> 8) == ENVIEWER_TYPE_5_GANONDORF) { if (1) {} sGanondorfCape->backPush = BREG(54) / 10.0f; sGanondorfCape->backSwayMagnitude = (BREG(60) + 25) / 100.0f; @@ -895,7 +895,7 @@ void EnViewer_UpdateGanondorfCape(GlobalContext* globalCtx, EnViewer* this) { forearmModelOffset.z = KREG(18) - 10.0f; yOscillationPhase += KREG(19) * 0x1000 + 0x2000; - Matrix_RotateY((this->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); + Matrix_RotateY((pthis->actor.shape.rot.y / (f32)0x8000) * M_PI, MTXMODE_NEW); Matrix_MultVec3f(&forearmModelOffset, &forearmWorldOffset); sGanondorfCape->rightForearmPos.x = sGanondorfNeckWorldPos.x + forearmWorldOffset.x; sGanondorfCape->rightForearmPos.y = sGanondorfNeckWorldPos.y + forearmWorldOffset.y; diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c deleted file mode 100644 index 8ba1ccc95..000000000 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ /dev/null @@ -1,568 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_VM_Z_EN_VM_C -#include "actor_common.h" -/* - * File: z_en_vm.c - * Overlay: ovl_En_Vm - * Description: Beamos - */ - -#include "z_en_vm.h" -#include "objects/object_vm/object_vm.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4) - -void EnVm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnVm_SetupWait(EnVm* this); -void EnVm_Wait(EnVm* this, GlobalContext* globalCtx); -void EnVm_SetupAttack(EnVm* this); -void EnVm_Attack(EnVm* this, GlobalContext* globalCtx); -void EnVm_Stun(EnVm* this, GlobalContext* globalCtx); -void EnVm_Die(EnVm* this, GlobalContext* globalCtx); - -const ActorInit En_Vm_InitVars = { - ACTOR_EN_VM, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_VM, - sizeof(EnVm), - (ActorFunc)EnVm_Init, - (ActorFunc)EnVm_Destroy, - (ActorFunc)EnVm_Update, - (ActorFunc)EnVm_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 25, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderQuadInit sQuadInit1 = { - { - COLTYPE_METAL, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x10 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static ColliderQuadInit sQuadInit2 = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static Vec3f D_80B2EAEC = { 0.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EAF8 = { 0.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EB04 = { 500.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EB10 = { -500.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EB1C = { 0.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EB28 = { 0.0f, 0.0f, 1600.0f }; - -static Vec3f D_80B2EB34 = { 1000.0f, 700.0f, 2000.0f }; - -static Vec3f D_80B2EB40 = { 1000.0f, -700.0f, 2000.0f }; - -static Vec3f D_80B2EB4C = { -1000.0f, 700.0f, 1500.0f }; - -static Vec3f D_80B2EB58 = { -1000.0f, -700.0f, 1500.0f }; - -static Vec3f D_80B2EB64 = { 500.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EB70 = { -500.0f, 0.0f, 0.0f }; - -static Vec3f D_80B2EB7C = { 0.4f, 0.4f, 0.4f }; - -static void* D_80B2EB88[] = { - gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, - gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, - gEffEnemyDeathFlame9Tex, gEffEnemyDeathFlame10Tex, -}; - -void EnVm_SetupAction(EnVm* this, EnVmActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { - EnVm* this = (EnVm*)thisx; - - SkelAnime_Init(globalCtx, &this->skelAnime, &gBeamosSkel, &gBeamosAnim, this->jointTable, this->morphTable, 11); - ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, thisx, &sCylinderInit); - Collider_InitQuad(globalCtx, &this->colliderQuad1); - Collider_SetQuad(globalCtx, &this->colliderQuad1, thisx, &sQuadInit1); - Collider_InitQuad(globalCtx, &this->colliderQuad2); - Collider_SetQuad(globalCtx, &this->colliderQuad2, thisx, &sQuadInit2); - this->beamSightRange = (thisx->params >> 8) * 40.0f; - thisx->params &= 0xFF; - thisx->naviEnemyId = 0x39; - - if (thisx->params == BEAMOS_LARGE) { - thisx->colChkInfo.health = 2; - Actor_SetScale(thisx, 0.014f); - } else { - thisx->colChkInfo.health = 1; - Actor_SetScale(thisx, 0.01f); - } - - EnVm_SetupWait(this); -} - -void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnVm* this = (EnVm*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); -} - -void EnVm_SetupWait(EnVm* this) { - f32 frameCount = Animation_GetLastFrame(&gBeamosAnim); - - Animation_Change(&this->skelAnime, &gBeamosAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, 0.0f); - this->unk_25E = this->unk_260 = 0; - this->unk_21C = 0; - this->timer = 10; - EnVm_SetupAction(this, EnVm_Wait); -} - -void EnVm_Wait(EnVm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 dist; - s16 headRot; - s16 pad; - s16 pitch; - - switch (this->unk_25E) { - case 0: - Math_SmoothStepToS(&this->beamRot.x, 0, 10, 1500, 0); - headRot = this->actor.yawTowardsPlayer - this->headRotY - this->actor.shape.rot.y; - pitch = Math_Vec3f_Pitch(&this->beamPos1, &player->actor.world.pos); - - if (pitch > 0x1B91) { - pitch = 0x1B91; - } - - dist = this->beamSightRange - this->actor.xzDistToPlayer; - - if (this->actor.xzDistToPlayer <= this->beamSightRange && ABS(headRot) <= 0x2710 && pitch >= 0xE38 && - this->actor.yDistToPlayer <= 80.0f && this->actor.yDistToPlayer >= -160.0f) { - Math_SmoothStepToS(&this->beamRot.x, pitch, 10, 0xFA0, 0); - if (Math_SmoothStepToS(&this->headRotY, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 1, - (ABS((s16)(dist * 180.0f)) / 3) + 0xFA0, 0) <= 5460) { - this->timer--; - if (this->timer == 0) { - this->unk_25E++; - this->skelAnime.curFrame = 0.0f; - this->skelAnime.startFrame = 0.0f; - this->skelAnime.playSpeed = 2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIMOS_AIM); - } - } - } else { - this->headRotY -= 0x1F4; - } - - SkelAnime_Update(&this->skelAnime); - return; - case 1: - break; - default: - return; - } - - Math_SmoothStepToS(&this->headRotY, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 1, 0x1F40, 0); - - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_260++; - this->skelAnime.curFrame = 0.0f; - } - - if (this->unk_260 == 2) { - this->beamRot.y = this->actor.yawTowardsPlayer; - this->beamRot.x = Math_Vec3f_Pitch(&this->beamPos1, &player->actor.world.pos); - - if (this->beamRot.x > 0x1B91) { - this->beamRot.x = 0x1B91; - } - - if (this->beamRot.x < 0xAAA) { - this->skelAnime.startFrame = this->skelAnime.curFrame = this->skelAnime.endFrame; - this->unk_25E = this->unk_260 = 0; - this->timer = 10; - this->skelAnime.playSpeed = 1.0f; - } else { - this->skelAnime.curFrame = 6.0f; - EffectSsDeadDd_Spawn(globalCtx, &this->beamPos2, &D_80B2EAEC, &D_80B2EAEC, 150, -25, 0, 0, 255, 0, 255, 255, - 255, 16, 20); - EnVm_SetupAttack(this); - } - } -} - -void EnVm_SetupAttack(EnVm* this) { - Animation_Change(&this->skelAnime, &gBeamosAnim, 3.0f, 3.0f, 7.0f, ANIMMODE_ONCE, 0.0f); - this->timer = 305; - this->beamScale.x = 0.6f; - this->beamSpeed = 40.0f; - this->unk_21C = 1; - this->colliderQuad1.base.atFlags &= ~AT_HIT; - EnVm_SetupAction(this, EnVm_Attack); -} - -void EnVm_Attack(EnVm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 pitch = Math_Vec3f_Pitch(&this->beamPos1, &player->actor.world.pos); - f32 dist; - Vec3f playerPos; - - if (pitch > 0x1B91) { - pitch = 0x1B91; - } - - if (this->colliderQuad1.base.atFlags & AT_HIT) { - this->colliderQuad1.base.atFlags &= ~AT_HIT; - this->timer = 0; - - if (this->beamScale.x > 0.1f) { - this->beamScale.x = 0.1f; - } - } - - if (this->beamRot.x < 0xAAA || this->timer == 0) { - Math_SmoothStepToF(&this->beamScale.x, 0.0f, 1.0f, 0.03f, 0.0f); - this->unk_260 = 0; - - if (this->beamScale.x == 0.0f) { - this->beamScale.y = this->beamScale.z = 0.0f; - EnVm_SetupWait(this); - } - } else { - if (--this->timer > 300) { - return; - } - - Math_SmoothStepToS(&this->headRotY, -this->actor.shape.rot.y + this->actor.yawTowardsPlayer, 10, 0xDAC, 0); - Math_SmoothStepToS(&this->beamRot.y, this->actor.yawTowardsPlayer, 10, 0xDAC, 0); - Math_SmoothStepToS(&this->beamRot.x, pitch, 10, 0xDAC, 0); - playerPos = player->actor.world.pos; - - if (player->actor.floorHeight > BGCHECK_Y_MIN) { - playerPos.y = player->actor.floorHeight; - } - - dist = Math_Vec3f_DistXYZ(&this->beamPos1, &playerPos); - Math_SmoothStepToF(&this->beamScale.z, dist, 1.0f, this->beamSpeed, 0.0f); - Math_SmoothStepToF(&this->beamScale.x, 0.1f, 1.0f, 0.12f, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); - - if (this->unk_260 > 2) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad1.base); - } - - this->unk_260 = 3; - } - - if (SkelAnime_Update(&this->skelAnime)) { - this->skelAnime.curFrame = this->skelAnime.startFrame; - } -} - -void EnVm_SetupStun(EnVm* this) { - Animation_Change(&this->skelAnime, &gBeamosAnim, -1.0f, Animation_GetLastFrame(&gBeamosAnim), 0.0f, ANIMMODE_ONCE, - 0.0f); - this->unk_260 = 0; - this->timer = 180; - this->unk_25E = this->unk_260; - this->unk_21C = 2; - this->beamScale.z = 0.0f; - this->beamScale.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - EnVm_SetupAction(this, EnVm_Stun); -} - -void EnVm_Stun(EnVm* this, GlobalContext* globalCtx) { - if (this->timer == 0) { - if (SkelAnime_Update(&this->skelAnime)) { - this->unk_25E++; - if (this->unk_25E == 3) { - EnVm_SetupWait(this); - } else if (this->unk_25E == 1) { - Animation_Change(&this->skelAnime, &gBeamosAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBeamosAnim), - ANIMMODE_ONCE, 0.0f); - } else { - this->timer = 10; - this->skelAnime.curFrame = 0.0f; - this->skelAnime.playSpeed = 2.0f; - } - } - } else { - Math_SmoothStepToS(&this->beamRot.x, 0, 10, 0x5DC, 0); - this->timer--; - SkelAnime_Update(&this->skelAnime); - } -} - -void EnVm_SetupDie(EnVm* this) { - Animation_Change(&this->skelAnime, &gBeamosAnim, -1.0f, Animation_GetLastFrame(&gBeamosAnim), 0.0f, ANIMMODE_ONCE, - 0.0f); - this->timer = 33; - this->unk_25E = this->unk_260 = 0; - this->unk_21C = 3; - this->beamScale.z = 0.0f; - this->beamScale.y = 0.0f; - this->actor.shape.yOffset = -5000.0f; - this->actor.world.pos.y += 5000.0f * this->actor.scale.y; - this->actor.velocity.y = 8.0f; - this->actor.gravity = -0.5f; - this->actor.speedXZ = Rand_ZeroOne() + 1.0f; - this->actor.world.rot.y = Rand_CenteredFloat(65535.0f); - EnVm_SetupAction(this, EnVm_Die); -} - -void EnVm_Die(EnVm* this, GlobalContext* globalCtx) { - EnBom* bomb; - - this->beamRot.x += 0x5DC; - this->headRotY += 0x9C4; - Actor_MoveForward(&this->actor); - - if (--this->timer == 0) { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, BOMB_BODY); - - if (bomb != NULL) { - bomb->timer = 0; - } - - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0); - Actor_Kill(&this->actor); - } -} - -void EnVm_CheckHealth(EnVm* this, GlobalContext* globalCtx) { - EnBom* bomb; - - if (Actor_GetCollidedExplosive(globalCtx, &this->colliderCylinder.base) != NULL) { - this->actor.colChkInfo.health--; - osSyncPrintf("hp down %d\n", this->actor.colChkInfo.health); - } else { - if (!(this->colliderQuad2.base.acFlags & AC_HIT) || this->unk_21C == 2) { - return; - } - this->colliderQuad2.base.acFlags &= ~AC_HIT; - } - - if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - EnVm_SetupStun(this); - } else { - bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y + 20.0f, this->actor.world.pos.z, 0, 0, 0x601, BOMB_BODY); - - if (bomb != NULL) { - bomb->timer = 0; - } - - EnVm_SetupDie(this); - } -} - -void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { - EnVm* this = (EnVm*)thisx; - CollisionCheckContext* colChkCtx = &globalCtx->colChkCtx; - - if (this->actor.colChkInfo.health != 0) { - EnVm_CheckHealth(this, globalCtx); - } - - if (this->unk_260 == 4) { - EffectSsDeadDs_SpawnStationary(globalCtx, &this->beamPos3, 20, -1, 255, 20); - func_80033480(globalCtx, &this->beamPos3, 6.0f, 1, 120, 20, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); - } - - this->actionFunc(this, globalCtx); - this->beamTexScroll += 0xC; - - if (this->actor.colChkInfo.health != 0 && this->unk_21C != 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIMOS_ROLL_HEAD - SFX_FLAG); - } - - Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetOC(globalCtx, colChkCtx, &this->colliderCylinder.base); - - if (this->actor.colorFilterTimer == 0 && this->actor.colChkInfo.health != 0) { - CollisionCheck_SetAC(globalCtx, colChkCtx, &this->colliderCylinder.base); - } - - CollisionCheck_SetAC(globalCtx, colChkCtx, &this->colliderQuad2.base); - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += (6500.0f + this->actor.shape.yOffset) * this->actor.scale.y; -} - -s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnVm* this = (EnVm*)thisx; - - if (limbIndex == 2) { - rot->x += this->beamRot.x; - rot->y += this->headRotY; - } else if (limbIndex == 10) { - if (this->unk_21C == 3) { - *dList = NULL; - } - } - - return false; -} - -void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnVm* this = (EnVm*)thisx; - Vec3f sp80 = D_80B2EAF8; - Vec3f sp74 = D_80B2EB04; - Vec3f sp68 = D_80B2EB10; - s32 pad; - Vec3f posResult; - CollisionPoly* poly; - s32 bgId; - f32 dist; - - if (limbIndex == 2) { - Matrix_MultVec3f(&D_80B2EB1C, &this->beamPos1); - Matrix_MultVec3f(&D_80B2EB28, &this->beamPos2); - - if (this->unk_260 >= 3) { - poly = NULL; - sp80.z = (this->beamScale.z + 500.0f) * (this->actor.scale.y * 10000.0f); - Matrix_MultVec3f(&sp80, &this->beamPos3); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->beamPos1, &this->beamPos3, &posResult, &poly, true, - true, false, true, &bgId) == true) { - this->beamScale.z = Math_Vec3f_DistXYZ(&this->beamPos1, &posResult) - 5.0f; - this->unk_260 = 4; - this->beamPos3 = posResult; - } - if (this->beamScale.z != 0.0f) { - dist = 100.0f; - if (this->actor.scale.y > 0.01f) { - dist = 70.0f; - } - sp74.z = sp68.z = Math_Vec3f_DistXYZ(&this->beamPos1, &this->beamPos3) * dist; - Matrix_MultVec3f(&D_80B2EB64, &this->colliderQuad1.dim.quad[3]); - Matrix_MultVec3f(&D_80B2EB70, &this->colliderQuad1.dim.quad[2]); - Matrix_MultVec3f(&sp74, &this->colliderQuad1.dim.quad[1]); - Matrix_MultVec3f(&sp68, &this->colliderQuad1.dim.quad[0]); - Collider_SetQuadVertices(&this->colliderQuad1, &this->colliderQuad1.dim.quad[0], - &this->colliderQuad1.dim.quad[1], &this->colliderQuad1.dim.quad[2], - &this->colliderQuad1.dim.quad[3]); - } - } - Matrix_MultVec3f(&D_80B2EB34, &this->colliderQuad2.dim.quad[1]); - Matrix_MultVec3f(&D_80B2EB40, &this->colliderQuad2.dim.quad[0]); - Matrix_MultVec3f(&D_80B2EB4C, &this->colliderQuad2.dim.quad[3]); - Matrix_MultVec3f(&D_80B2EB58, &this->colliderQuad2.dim.quad[2]); - Collider_SetQuadVertices(&this->colliderQuad2, &this->colliderQuad2.dim.quad[0], - &this->colliderQuad2.dim.quad[1], &this->colliderQuad2.dim.quad[2], - &this->colliderQuad2.dim.quad[3]); - } -} - -void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx2) { - EnVm* this = (EnVm*)thisx; - GlobalContext* globalCtx = globalCtx2; - Vec3f actorPos; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vm.c", 1014); - - func_80093D18(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, - EnVm_PostLimbDraw, this); - actorPos = this->actor.world.pos; - func_80033C30(&actorPos, &D_80B2EB7C, 255, globalCtx); - - if (this->unk_260 >= 3) { - Matrix_Translate(this->beamPos3.x, this->beamPos3.y + 10.0f, this->beamPos3.z, MTXMODE_NEW); - Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vm.c", 1033), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 168); - func_80094BC4(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80B2EB88[globalCtx->gameplayFrames % 8])); - gSPDisplayList(POLY_XLU_DISP++, gEffEnemyDeathFlameDL); - Matrix_RotateY(32767.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vm.c", 1044), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80B2EB88[(globalCtx->gameplayFrames + 4) % 8])); - gSPDisplayList(POLY_XLU_DISP++, gEffEnemyDeathFlameDL); - } - gSPSegment(POLY_OPA_DISP++, 0x08, func_80094E78(globalCtx->state.gfxCtx, 0, this->beamTexScroll)); - Matrix_Translate(this->beamPos1.x, this->beamPos1.y, this->beamPos1.z, MTXMODE_NEW); - Matrix_RotateZYX(this->beamRot.x, this->beamRot.y, this->beamRot.z, MTXMODE_APPLY); - Matrix_Scale(this->beamScale.x * 0.1f, this->beamScale.x * 0.1f, this->beamScale.z * 0.0015f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vm.c", 1063), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gBeamosLaserDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_vm.c", 1068); -} diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.cpp b/src/overlays/actors/ovl_En_Vm/z_en_vm.cpp new file mode 100644 index 000000000..0140260ef --- /dev/null +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.cpp @@ -0,0 +1,568 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_VM_Z_EN_VM_C +#include "actor_common.h" +/* + * File: z_en_vm.c + * Overlay: ovl_En_Vm + * Description: Beamos + */ + +#include "z_en_vm.h" +#include "objects/object_vm/object_vm.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4) + +void EnVm_Init(Actor* thisx, GlobalContext* globalCtx); +void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); +void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnVm_SetupWait(EnVm* pthis); +void EnVm_Wait(EnVm* pthis, GlobalContext* globalCtx); +void EnVm_SetupAttack(EnVm* pthis); +void EnVm_Attack(EnVm* pthis, GlobalContext* globalCtx); +void EnVm_Stun(EnVm* pthis, GlobalContext* globalCtx); +void EnVm_Die(EnVm* pthis, GlobalContext* globalCtx); + +ActorInit En_Vm_InitVars = { + ACTOR_EN_VM, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_VM, + sizeof(EnVm), + (ActorFunc)EnVm_Init, + (ActorFunc)EnVm_Destroy, + (ActorFunc)EnVm_Update, + (ActorFunc)EnVm_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 25, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderQuadInit sQuadInit1 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static ColliderQuadInit sQuadInit2 = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static Vec3f D_80B2EAEC = { 0.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EAF8 = { 0.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EB04 = { 500.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EB10 = { -500.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EB1C = { 0.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EB28 = { 0.0f, 0.0f, 1600.0f }; + +static Vec3f D_80B2EB34 = { 1000.0f, 700.0f, 2000.0f }; + +static Vec3f D_80B2EB40 = { 1000.0f, -700.0f, 2000.0f }; + +static Vec3f D_80B2EB4C = { -1000.0f, 700.0f, 1500.0f }; + +static Vec3f D_80B2EB58 = { -1000.0f, -700.0f, 1500.0f }; + +static Vec3f D_80B2EB64 = { 500.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EB70 = { -500.0f, 0.0f, 0.0f }; + +static Vec3f D_80B2EB7C = { 0.4f, 0.4f, 0.4f }; + +static void* D_80B2EB88[] = { + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, + gEffEnemyDeathFlame9Tex, gEffEnemyDeathFlame10Tex, +}; + +void EnVm_SetupAction(EnVm* pthis, EnVmActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnVm* pthis = (EnVm*)thisx; + + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gBeamosSkel, &gBeamosAnim, pthis->jointTable, pthis->morphTable, 11); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + Collider_InitCylinder(globalCtx, &pthis->colliderCylinder); + Collider_SetCylinder(globalCtx, &pthis->colliderCylinder, thisx, &sCylinderInit); + Collider_InitQuad(globalCtx, &pthis->colliderQuad1); + Collider_SetQuad(globalCtx, &pthis->colliderQuad1, thisx, &sQuadInit1); + Collider_InitQuad(globalCtx, &pthis->colliderQuad2); + Collider_SetQuad(globalCtx, &pthis->colliderQuad2, thisx, &sQuadInit2); + pthis->beamSightRange = (thisx->params >> 8) * 40.0f; + thisx->params &= 0xFF; + thisx->naviEnemyId = 0x39; + + if (thisx->params == BEAMOS_LARGE) { + thisx->colChkInfo.health = 2; + Actor_SetScale(thisx, 0.014f); + } else { + thisx->colChkInfo.health = 1; + Actor_SetScale(thisx, 0.01f); + } + + EnVm_SetupWait(pthis); +} + +void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnVm* pthis = (EnVm*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinder); +} + +void EnVm_SetupWait(EnVm* pthis) { + f32 frameCount = Animation_GetLastFrame(&gBeamosAnim); + + Animation_Change(&pthis->skelAnime, &gBeamosAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, 0.0f); + pthis->unk_25E = pthis->unk_260 = 0; + pthis->unk_21C = 0; + pthis->timer = 10; + EnVm_SetupAction(pthis, EnVm_Wait); +} + +void EnVm_Wait(EnVm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dist; + s16 headRot; + s16 pad; + s16 pitch; + + switch (pthis->unk_25E) { + case 0: + Math_SmoothStepToS(&pthis->beamRot.x, 0, 10, 1500, 0); + headRot = pthis->actor.yawTowardsPlayer - pthis->headRotY - pthis->actor.shape.rot.y; + pitch = Math_Vec3f_Pitch(&pthis->beamPos1, &player->actor.world.pos); + + if (pitch > 0x1B91) { + pitch = 0x1B91; + } + + dist = pthis->beamSightRange - pthis->actor.xzDistToPlayer; + + if (pthis->actor.xzDistToPlayer <= pthis->beamSightRange && ABS(headRot) <= 0x2710 && pitch >= 0xE38 && + pthis->actor.yDistToPlayer <= 80.0f && pthis->actor.yDistToPlayer >= -160.0f) { + Math_SmoothStepToS(&pthis->beamRot.x, pitch, 10, 0xFA0, 0); + if (Math_SmoothStepToS(&pthis->headRotY, pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y, 1, + (ABS((s16)(dist * 180.0f)) / 3) + 0xFA0, 0) <= 5460) { + pthis->timer--; + if (pthis->timer == 0) { + pthis->unk_25E++; + pthis->skelAnime.curFrame = 0.0f; + pthis->skelAnime.startFrame = 0.0f; + pthis->skelAnime.playSpeed = 2.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIMOS_AIM); + } + } + } else { + pthis->headRotY -= 0x1F4; + } + + SkelAnime_Update(&pthis->skelAnime); + return; + case 1: + break; + default: + return; + } + + Math_SmoothStepToS(&pthis->headRotY, pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y, 1, 0x1F40, 0); + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_260++; + pthis->skelAnime.curFrame = 0.0f; + } + + if (pthis->unk_260 == 2) { + pthis->beamRot.y = pthis->actor.yawTowardsPlayer; + pthis->beamRot.x = Math_Vec3f_Pitch(&pthis->beamPos1, &player->actor.world.pos); + + if (pthis->beamRot.x > 0x1B91) { + pthis->beamRot.x = 0x1B91; + } + + if (pthis->beamRot.x < 0xAAA) { + pthis->skelAnime.startFrame = pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; + pthis->unk_25E = pthis->unk_260 = 0; + pthis->timer = 10; + pthis->skelAnime.playSpeed = 1.0f; + } else { + pthis->skelAnime.curFrame = 6.0f; + EffectSsDeadDd_Spawn(globalCtx, &pthis->beamPos2, &D_80B2EAEC, &D_80B2EAEC, 150, -25, 0, 0, 255, 0, 255, 255, + 255, 16, 20); + EnVm_SetupAttack(pthis); + } + } +} + +void EnVm_SetupAttack(EnVm* pthis) { + Animation_Change(&pthis->skelAnime, &gBeamosAnim, 3.0f, 3.0f, 7.0f, ANIMMODE_ONCE, 0.0f); + pthis->timer = 305; + pthis->beamScale.x = 0.6f; + pthis->beamSpeed = 40.0f; + pthis->unk_21C = 1; + pthis->colliderQuad1.base.atFlags &= ~AT_HIT; + EnVm_SetupAction(pthis, EnVm_Attack); +} + +void EnVm_Attack(EnVm* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 pitch = Math_Vec3f_Pitch(&pthis->beamPos1, &player->actor.world.pos); + f32 dist; + Vec3f playerPos; + + if (pitch > 0x1B91) { + pitch = 0x1B91; + } + + if (pthis->colliderQuad1.base.atFlags & AT_HIT) { + pthis->colliderQuad1.base.atFlags &= ~AT_HIT; + pthis->timer = 0; + + if (pthis->beamScale.x > 0.1f) { + pthis->beamScale.x = 0.1f; + } + } + + if (pthis->beamRot.x < 0xAAA || pthis->timer == 0) { + Math_SmoothStepToF(&pthis->beamScale.x, 0.0f, 1.0f, 0.03f, 0.0f); + pthis->unk_260 = 0; + + if (pthis->beamScale.x == 0.0f) { + pthis->beamScale.y = pthis->beamScale.z = 0.0f; + EnVm_SetupWait(pthis); + } + } else { + if (--pthis->timer > 300) { + return; + } + + Math_SmoothStepToS(&pthis->headRotY, -pthis->actor.shape.rot.y + pthis->actor.yawTowardsPlayer, 10, 0xDAC, 0); + Math_SmoothStepToS(&pthis->beamRot.y, pthis->actor.yawTowardsPlayer, 10, 0xDAC, 0); + Math_SmoothStepToS(&pthis->beamRot.x, pitch, 10, 0xDAC, 0); + playerPos = player->actor.world.pos; + + if (player->actor.floorHeight > BGCHECK_Y_MIN) { + playerPos.y = player->actor.floorHeight; + } + + dist = Math_Vec3f_DistXYZ(&pthis->beamPos1, &playerPos); + Math_SmoothStepToF(&pthis->beamScale.z, dist, 1.0f, pthis->beamSpeed, 0.0f); + Math_SmoothStepToF(&pthis->beamScale.x, 0.1f, 1.0f, 0.12f, 0.0f); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); + + if (pthis->unk_260 > 2) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderQuad1.base); + } + + pthis->unk_260 = 3; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->skelAnime.curFrame = pthis->skelAnime.startFrame; + } +} + +void EnVm_SetupStun(EnVm* pthis) { + Animation_Change(&pthis->skelAnime, &gBeamosAnim, -1.0f, Animation_GetLastFrame(&gBeamosAnim), 0.0f, ANIMMODE_ONCE, + 0.0f); + pthis->unk_260 = 0; + pthis->timer = 180; + pthis->unk_25E = pthis->unk_260; + pthis->unk_21C = 2; + pthis->beamScale.z = 0.0f; + pthis->beamScale.y = 0.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + EnVm_SetupAction(pthis, EnVm_Stun); +} + +void EnVm_Stun(EnVm* pthis, GlobalContext* globalCtx) { + if (pthis->timer == 0) { + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->unk_25E++; + if (pthis->unk_25E == 3) { + EnVm_SetupWait(pthis); + } else if (pthis->unk_25E == 1) { + Animation_Change(&pthis->skelAnime, &gBeamosAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBeamosAnim), + ANIMMODE_ONCE, 0.0f); + } else { + pthis->timer = 10; + pthis->skelAnime.curFrame = 0.0f; + pthis->skelAnime.playSpeed = 2.0f; + } + } + } else { + Math_SmoothStepToS(&pthis->beamRot.x, 0, 10, 0x5DC, 0); + pthis->timer--; + SkelAnime_Update(&pthis->skelAnime); + } +} + +void EnVm_SetupDie(EnVm* pthis) { + Animation_Change(&pthis->skelAnime, &gBeamosAnim, -1.0f, Animation_GetLastFrame(&gBeamosAnim), 0.0f, ANIMMODE_ONCE, + 0.0f); + pthis->timer = 33; + pthis->unk_25E = pthis->unk_260 = 0; + pthis->unk_21C = 3; + pthis->beamScale.z = 0.0f; + pthis->beamScale.y = 0.0f; + pthis->actor.shape.yOffset = -5000.0f; + pthis->actor.world.pos.y += 5000.0f * pthis->actor.scale.y; + pthis->actor.velocity.y = 8.0f; + pthis->actor.gravity = -0.5f; + pthis->actor.speedXZ = Rand_ZeroOne() + 1.0f; + pthis->actor.world.rot.y = Rand_CenteredFloat(65535.0f); + EnVm_SetupAction(pthis, EnVm_Die); +} + +void EnVm_Die(EnVm* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + + pthis->beamRot.x += 0x5DC; + pthis->headRotY += 0x9C4; + Actor_MoveForward(&pthis->actor); + + if (--pthis->timer == 0) { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0x6FF, BOMB_BODY); + + if (bomb != NULL) { + bomb->timer = 0; + } + + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xA0); + Actor_Kill(&pthis->actor); + } +} + +void EnVm_CheckHealth(EnVm* pthis, GlobalContext* globalCtx) { + EnBom* bomb; + + if (Actor_GetCollidedExplosive(globalCtx, &pthis->colliderCylinder.base) != NULL) { + pthis->actor.colChkInfo.health--; + osSyncPrintf("hp down %d\n", pthis->actor.colChkInfo.health); + } else { + if (!(pthis->colliderQuad2.base.acFlags & AC_HIT) || pthis->unk_21C == 2) { + return; + } + pthis->colliderQuad2.base.acFlags &= ~AC_HIT; + } + + if (pthis->actor.colChkInfo.health != 0) { + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 8); + EnVm_SetupStun(pthis); + } else { + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 20.0f, pthis->actor.world.pos.z, 0, 0, 0x601, BOMB_BODY); + + if (bomb != NULL) { + bomb->timer = 0; + } + + EnVm_SetupDie(pthis); + } +} + +void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnVm* pthis = (EnVm*)thisx; + CollisionCheckContext* colChkCtx = &globalCtx->colChkCtx; + + if (pthis->actor.colChkInfo.health != 0) { + EnVm_CheckHealth(pthis, globalCtx); + } + + if (pthis->unk_260 == 4) { + EffectSsDeadDs_SpawnStationary(globalCtx, &pthis->beamPos3, 20, -1, 255, 20); + func_80033480(globalCtx, &pthis->beamPos3, 6.0f, 1, 120, 20, 1); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); + } + + pthis->actionFunc(pthis, globalCtx); + pthis->beamTexScroll += 0xC; + + if (pthis->actor.colChkInfo.health != 0 && pthis->unk_21C != 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIMOS_ROLL_HEAD - SFX_FLAG); + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderCylinder); + CollisionCheck_SetOC(globalCtx, colChkCtx, &pthis->colliderCylinder.base); + + if (pthis->actor.colorFilterTimer == 0 && pthis->actor.colChkInfo.health != 0) { + CollisionCheck_SetAC(globalCtx, colChkCtx, &pthis->colliderCylinder.base); + } + + CollisionCheck_SetAC(globalCtx, colChkCtx, &pthis->colliderQuad2.base); + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += (6500.0f + pthis->actor.shape.yOffset) * pthis->actor.scale.y; +} + +s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnVm* pthis = (EnVm*)thisx; + + if (limbIndex == 2) { + rot->x += pthis->beamRot.x; + rot->y += pthis->headRotY; + } else if (limbIndex == 10) { + if (pthis->unk_21C == 3) { + *dList = NULL; + } + } + + return false; +} + +void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnVm* pthis = (EnVm*)thisx; + Vec3f sp80 = D_80B2EAF8; + Vec3f sp74 = D_80B2EB04; + Vec3f sp68 = D_80B2EB10; + s32 pad; + Vec3f posResult; + CollisionPoly* poly; + s32 bgId; + f32 dist; + + if (limbIndex == 2) { + Matrix_MultVec3f(&D_80B2EB1C, &pthis->beamPos1); + Matrix_MultVec3f(&D_80B2EB28, &pthis->beamPos2); + + if (pthis->unk_260 >= 3) { + poly = NULL; + sp80.z = (pthis->beamScale.z + 500.0f) * (pthis->actor.scale.y * 10000.0f); + Matrix_MultVec3f(&sp80, &pthis->beamPos3); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->beamPos1, &pthis->beamPos3, &posResult, &poly, true, + true, false, true, &bgId) == true) { + pthis->beamScale.z = Math_Vec3f_DistXYZ(&pthis->beamPos1, &posResult) - 5.0f; + pthis->unk_260 = 4; + pthis->beamPos3 = posResult; + } + if (pthis->beamScale.z != 0.0f) { + dist = 100.0f; + if (pthis->actor.scale.y > 0.01f) { + dist = 70.0f; + } + sp74.z = sp68.z = Math_Vec3f_DistXYZ(&pthis->beamPos1, &pthis->beamPos3) * dist; + Matrix_MultVec3f(&D_80B2EB64, &pthis->colliderQuad1.dim.quad[3]); + Matrix_MultVec3f(&D_80B2EB70, &pthis->colliderQuad1.dim.quad[2]); + Matrix_MultVec3f(&sp74, &pthis->colliderQuad1.dim.quad[1]); + Matrix_MultVec3f(&sp68, &pthis->colliderQuad1.dim.quad[0]); + Collider_SetQuadVertices(&pthis->colliderQuad1, &pthis->colliderQuad1.dim.quad[0], + &pthis->colliderQuad1.dim.quad[1], &pthis->colliderQuad1.dim.quad[2], + &pthis->colliderQuad1.dim.quad[3]); + } + } + Matrix_MultVec3f(&D_80B2EB34, &pthis->colliderQuad2.dim.quad[1]); + Matrix_MultVec3f(&D_80B2EB40, &pthis->colliderQuad2.dim.quad[0]); + Matrix_MultVec3f(&D_80B2EB4C, &pthis->colliderQuad2.dim.quad[3]); + Matrix_MultVec3f(&D_80B2EB58, &pthis->colliderQuad2.dim.quad[2]); + Collider_SetQuadVertices(&pthis->colliderQuad2, &pthis->colliderQuad2.dim.quad[0], + &pthis->colliderQuad2.dim.quad[1], &pthis->colliderQuad2.dim.quad[2], + &pthis->colliderQuad2.dim.quad[3]); + } +} + +void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx2) { + EnVm* pthis = (EnVm*)thisx; + GlobalContext* globalCtx = globalCtx2; + Vec3f actorPos; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_vm.c", 1014); + + func_80093D18(globalCtx->state.gfxCtx); + func_80093D84(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, EnVm_OverrideLimbDraw, + EnVm_PostLimbDraw, pthis); + actorPos = pthis->actor.world.pos; + func_80033C30(&actorPos, &D_80B2EB7C, 255, globalCtx); + + if (pthis->unk_260 >= 3) { + Matrix_Translate(pthis->beamPos3.x, pthis->beamPos3.y + 10.0f, pthis->beamPos3.z, MTXMODE_NEW); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vm.c", 1033), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 168); + func_80094BC4(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80B2EB88[globalCtx->gameplayFrames % 8])); + gSPDisplayList(POLY_XLU_DISP++, gEffEnemyDeathFlameDL); + Matrix_RotateY(32767.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vm.c", 1044), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80B2EB88[(globalCtx->gameplayFrames + 4) % 8])); + gSPDisplayList(POLY_XLU_DISP++, gEffEnemyDeathFlameDL); + } + gSPSegment(POLY_OPA_DISP++, 0x08, func_80094E78(globalCtx->state.gfxCtx, 0, pthis->beamTexScroll)); + Matrix_Translate(pthis->beamPos1.x, pthis->beamPos1.y, pthis->beamPos1.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->beamRot.x, pthis->beamRot.y, pthis->beamRot.z, MTXMODE_APPLY); + Matrix_Scale(pthis->beamScale.x * 0.1f, pthis->beamScale.x * 0.1f, pthis->beamScale.z * 0.0015f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_vm.c", 1063), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBeamosLaserDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_vm.c", 1068); +} diff --git a/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c b/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.cpp similarity index 66% rename from src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c rename to src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.cpp index c143745c5..a7937838c 100644 --- a/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.c +++ b/src/overlays/actors/ovl_En_Wall_Tubo/z_en_wall_tubo.cpp @@ -22,11 +22,11 @@ void EnWallTubo_Init(Actor* thisx, GlobalContext* globalCtx); void EnWallTubo_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWallTubo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWallTubo_FindGirl(EnWallTubo* this, GlobalContext* globalCtx); -void EnWallTubo_DetectChu(EnWallTubo* this, GlobalContext* globalCtx); -void EnWallTubo_SetWallFall(EnWallTubo* this, GlobalContext* globalCtx); +void EnWallTubo_FindGirl(EnWallTubo* pthis, GlobalContext* globalCtx); +void EnWallTubo_DetectChu(EnWallTubo* pthis, GlobalContext* globalCtx); +void EnWallTubo_SetWallFall(EnWallTubo* pthis, GlobalContext* globalCtx); -const ActorInit En_Wall_Tubo_InitVars = { +ActorInit En_Wall_Tubo_InitVars = { ACTOR_EN_WALL_TUBO, ACTORCAT_PROP, FLAGS, @@ -39,19 +39,19 @@ const ActorInit En_Wall_Tubo_InitVars = { }; void EnWallTubo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnWallTubo* this = (EnWallTubo*)thisx; + EnWallTubo* pthis = (EnWallTubo*)thisx; osSyncPrintf("\n\n"); // "Wall Target" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 壁のツボ ☆☆☆☆☆ \n" VT_RST); - this->unk_164 = this->actor.world.pos; - this->actionFunc = EnWallTubo_FindGirl; + pthis->unk_164 = pthis->actor.world.pos; + pthis->actionFunc = EnWallTubo_FindGirl; } void EnWallTubo_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void EnWallTubo_FindGirl(EnWallTubo* this, GlobalContext* globalCtx) { +void EnWallTubo_FindGirl(EnWallTubo* pthis, GlobalContext* globalCtx) { Actor* lookForGirl; lookForGirl = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head; @@ -60,15 +60,15 @@ void EnWallTubo_FindGirl(EnWallTubo* this, GlobalContext* globalCtx) { if (lookForGirl->id != ACTOR_EN_BOM_BOWL_MAN) { lookForGirl = lookForGirl->next; } else { - this->chuGirl = (EnBomBowlMan*)lookForGirl; + pthis->chuGirl = (EnBomBowlMan*)lookForGirl; break; } } - this->actionFunc = EnWallTubo_DetectChu; + pthis->actionFunc = EnWallTubo_DetectChu; } -void EnWallTubo_DetectChu(EnWallTubo* this, GlobalContext* globalCtx) { +void EnWallTubo_DetectChu(EnWallTubo* pthis, GlobalContext* globalCtx) { EnBomChu* chu; s32 pad; Vec3f effAccel = { 0.0f, 0.1f, 0.0f }; @@ -76,32 +76,32 @@ void EnWallTubo_DetectChu(EnWallTubo* this, GlobalContext* globalCtx) { Vec3f chuPosDiff; s16 quakeIndex; - if (this->chuGirl->minigamePlayStatus != 0) { + if (pthis->chuGirl->minigamePlayStatus != 0) { if (globalCtx->cameraPtrs[MAIN_CAM]->setting == CAM_SET_CHU_BOWLING) { chu = (EnBomChu*)globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; while (chu != NULL) { - if ((&chu->actor == &this->actor) || (chu->actor.id != ACTOR_EN_BOM_CHU)) { + if ((&chu->actor == &pthis->actor) || (chu->actor.id != ACTOR_EN_BOM_CHU)) { chu = (EnBomChu*)chu->actor.next; continue; } - chuPosDiff.x = chu->actor.world.pos.x - this->actor.world.pos.x; - chuPosDiff.y = chu->actor.world.pos.y - this->actor.world.pos.y; - chuPosDiff.z = chu->actor.world.pos.z - this->actor.world.pos.z; + chuPosDiff.x = chu->actor.world.pos.x - pthis->actor.world.pos.x; + chuPosDiff.y = chu->actor.world.pos.y - pthis->actor.world.pos.y; + chuPosDiff.z = chu->actor.world.pos.z - pthis->actor.world.pos.z; if (((fabsf(chuPosDiff.x) < 40.0f) || (BREG(2))) && ((fabsf(chuPosDiff.y) < 40.0f) || (BREG(2))) && (fabsf(chuPosDiff.z) < 40.0f || (BREG(2)))) { - this->chuGirl->wallStatus[this->actor.params] = 1; + pthis->chuGirl->wallStatus[pthis->actor.params] = 1; chu->timer = 2; func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - this->timer = 60; - EffectSsBomb2_SpawnLayered(globalCtx, &this->explosionCenter, &effVelocity, &effAccel, 200, 40); + pthis->timer = 60; + EffectSsBomb2_SpawnLayered(globalCtx, &pthis->explosionCenter, &effVelocity, &effAccel, 200, 40); quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); Quake_SetSpeed(quakeIndex, 0x7FFF); Quake_SetQuakeValues(quakeIndex, 100, 0, 0, 0); Quake_SetCountdown(quakeIndex, 100); - this->actionFunc = EnWallTubo_SetWallFall; + pthis->actionFunc = EnWallTubo_SetWallFall; break; } @@ -111,23 +111,23 @@ void EnWallTubo_DetectChu(EnWallTubo* this, GlobalContext* globalCtx) { } } -void EnWallTubo_SetWallFall(EnWallTubo* this, GlobalContext* globalCtx) { +void EnWallTubo_SetWallFall(EnWallTubo* pthis, GlobalContext* globalCtx) { BgBowlWall* wall; Vec3f effAccel = { 0.0f, 0.1f, 0.0f }; Vec3f effVelocity = { 0.0f, 0.0f, 0.0f }; Vec3f effPos; if ((globalCtx->gameplayFrames & 1) == 0) { - effPos.x = this->explosionCenter.x + Rand_CenteredFloat(300.0f); - effPos.y = this->explosionCenter.y + Rand_CenteredFloat(300.0f); - effPos.z = this->explosionCenter.z; + effPos.x = pthis->explosionCenter.x + Rand_CenteredFloat(300.0f); + effPos.y = pthis->explosionCenter.y + Rand_CenteredFloat(300.0f); + effPos.z = pthis->explosionCenter.z; EffectSsBomb2_SpawnLayered(globalCtx, &effPos, &effVelocity, &effAccel, 100, 30); EffectSsHahen_SpawnBurst(globalCtx, &effPos, 10.0f, 0, 50, 15, 3, HAHEN_OBJECT_DEFAULT, 10, NULL); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_BOMB_EXPLOSION); } - if (this->timer == 0) { - wall = (BgBowlWall*)this->actor.parent; + if (pthis->timer == 0) { + wall = (BgBowlWall*)pthis->actor.parent; if ((wall != NULL) && (wall->dyna.actor.update != NULL)) { wall->isHit = true; @@ -139,16 +139,16 @@ void EnWallTubo_SetWallFall(EnWallTubo* this, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆ やった原! ☆☆☆☆☆ \n" VT_RST); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void EnWallTubo_Update(Actor* thisx, GlobalContext* globalCtx) { - EnWallTubo* this = (EnWallTubo*)thisx; + EnWallTubo* pthis = (EnWallTubo*)thisx; - if (this->timer != 0) { - this->timer--; + if (pthis->timer != 0) { + pthis->timer--; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c deleted file mode 100644 index bf43f7bee..000000000 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ /dev/null @@ -1,668 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WALLMAS_Z_EN_WALLMAS_C -#include "actor_common.h" -/* - * File: z_en_wallmas - * Overlay: En_Wallmas - * Description: Wallmaster (Ceiling monster) - */ - -#include "z_en_wallmas.h" -#include "objects/object_wallmaster/object_wallmaster.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800F7260.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -#define TIMER_SCALE ((f32)OS_CLOCK_RATE / 10000000000) -#define DEGREE_60_RAD (60.0f * M_PI / 180.0f) -#define DEGREE_15_RAD (15.0f * M_PI / 180.0f) - -#define DAMAGE_EFFECT_BURN 2 -#define DAMAGE_EFFECT_STUN_WHITE 4 -#define DAMAGE_EFFECT_STUN_BLUE 1 - -void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_ProximityOrSwitchInit(EnWallmas* this); -void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_TakeDamage(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); - -const ActorInit En_Wallmas_InitVars = { - ACTOR_EN_WALLMAS, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_WALLMASTER, - sizeof(EnWallmas), - (ActorFunc)EnWallmas_Init, - (ActorFunc)EnWallmas_Destroy, - (ActorFunc)EnWallmas_Update, - (ActorFunc)EnWallmas_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 30, 40, 0, { 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 4, 30, 40, 150 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(4, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(4, 0x4), - /* Unk arrow 1 */ DMG_ENTRY(4, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), - /* Fire magic */ DMG_ENTRY(4, 0x2), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(4, 0x4), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x30, 1), - ICHAIN_F32(targetArrowOffset, 5500, 1), - ICHAIN_F32_DIV1000(gravity, -1500, 0), -}; - -void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { - EnWallmas* this = (EnWallmas*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - ActorShape_Init(&thisx->shape, 0, NULL, 0.5f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterWaitAnim, this->jointTable, - this->morphTable, 25); - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); - this->switchFlag = (u8)(thisx->params >> 0x8); - thisx->params = thisx->params & 0xFF; - - if (thisx->params == WMT_FLAG) { - if (Flags_GetSwitch(globalCtx, this->switchFlag) != 0) { - Actor_Kill(thisx); - return; - } - - EnWallmas_ProximityOrSwitchInit(this); - } else if (thisx->params == WMT_PROXIMITY) { - EnWallmas_ProximityOrSwitchInit(this); - } else { - EnWallmas_TimerInit(this, globalCtx); - } -} - -void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnWallmas* this = (EnWallmas*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.flags |= ACTOR_FLAG_5; - this->timer = 0x82; - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = player->actor.world.pos.y; - this->actor.floorHeight = player->actor.floorHeight; - this->actor.draw = EnWallmas_Draw; - this->actionFunc = EnWallmas_WaitToDrop; -} - -void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - AnimationHeader* objSegChangee = &gWallmasterLungeAnim; - - Animation_Change(&this->skelAnime, objSegChangee, 0.0f, 20.0f, Animation_GetLastFrame(&gWallmasterLungeAnim), - ANIMMODE_ONCE, 0.0f); - - this->yTarget = player->actor.world.pos.y; - this->actor.world.pos.y = player->actor.world.pos.y + 300.0f; - this->actor.world.rot.y = player->actor.shape.rot.y + 0x8000; - this->actor.floorHeight = player->actor.floorHeight; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.flags &= ~ACTOR_FLAG_5; - this->actionFunc = EnWallmas_Drop; -} - -void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { - AnimationHeader* objSegFrameCount = &gWallmasterJumpAnim; - AnimationHeader* objSegChangee = &gWallmasterJumpAnim; - - Animation_Change(&this->skelAnime, objSegChangee, 1.0f, 41.0f, Animation_GetLastFrame(objSegFrameCount), - ANIMMODE_ONCE, -3.0f); - - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 0x12C, 0x64, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_LAND); - this->actionFunc = EnWallmas_Land; -} - -void EnWallmas_SetupStand(EnWallmas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterStandUpAnim); - this->actionFunc = EnWallmas_Stand; -} - -void EnWallmas_SetupWalk(EnWallmas* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); - this->actionFunc = EnWallmas_Walk; - this->actor.speedXZ = 3.0f; -} - -void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); - this->actionFunc = EnWallmas_JumpToCeiling; - this->actor.speedXZ = 0.0f; -} -void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { - AnimationHeader* objSegFrameCount = &gWallmasterJumpAnim; - AnimationHeader* objSegChangee = &gWallmasterJumpAnim; - - this->timer = 0; - this->actor.speedXZ = 0.0f; - - Animation_Change(&this->skelAnime, objSegChangee, 3.0f, 0.0f, Animation_GetLastFrame(objSegFrameCount), - ANIMMODE_ONCE, -3.0f); - - this->actionFunc = EnWallmas_ReturnToCeiling; -} - -void EnWallmas_SetupTakeDamage(EnWallmas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); - if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x0001F824) { - this->actor.world.rot.y = this->collider.base.ac->world.rot.y; - } else { - this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac) + 0x8000; - } - - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x14); - this->actionFunc = EnWallmas_TakeDamage; - this->actor.speedXZ = 5.0f; - this->actor.velocity.y = 10.0f; -} - -void EnWallmas_SetupCooldown(EnWallmas* this) { - Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = EnWallmas_Cooldown; -} - -void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - - EffectSsDeadDb_Spawn(globalCtx, &this->actor.world.pos, &zeroVec, &zeroVec, 250, -10, 255, 255, 255, 255, 0, 0, 255, - 1, 9, true); - - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xC0); - this->actionFunc = EnWallmas_Die; -} - -void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); - this->timer = -0x1E; - this->actionFunc = EnWallmas_TakePlayer; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - - this->yTarget = this->actor.yDistToPlayer; - func_8002DF38(globalCtx, &this->actor, 0x25); - OnePointCutscene_Init(globalCtx, 9500, 9999, &this->actor, MAIN_CAM); -} - -void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { - this->timer = 0; - this->actor.draw = NULL; - this->actor.flags &= ~ACTOR_FLAG_0; - if (this->actor.params == WMT_PROXIMITY) { - this->actionFunc = EnWallmas_WaitForProximity; - } else { - this->actionFunc = EnWallmas_WaitForSwitchFlag; - } -} - -void EnWallmas_SetupStun(EnWallmas* this) { - Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.5f, 0, 20.0f, ANIMMODE_ONCE, -3.0f); - - this->actor.speedXZ = 0.0f; - if (this->actor.colChkInfo.damageEffect == 4) { - Actor_SetColorFilter(&this->actor, -0x8000, 0xFF, 0, 0x50); - } else { - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 0x50); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - } - - this->timer = 0x50; - this->actionFunc = EnWallmas_Stun; -} - -void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f* playerPos = &player->actor.world.pos; - - this->actor.world.pos = *playerPos; - this->actor.floorHeight = player->actor.floorHeight; - this->actor.floorPoly = player->actor.floorPoly; - - if (this->timer != 0) { - this->timer--; - } - - if ((player->stateFlags1 & 0x100000) || (player->stateFlags1 & 0x8000000) || !(player->actor.bgCheckFlags & 1) || - ((this->actor.params == 1) && (320.0f < Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos)))) { - Audio_StopSfxById(NA_SE_EN_FALL_AIM); - this->timer = 0x82; - } - - if (this->timer == 0x50) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_AIM); - } - - if (this->timer == 0) { - EnWallmas_SetupDrop(this, globalCtx); - } -} - -void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (!Player_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && - (this->actor.xzDistToPlayer < 30.0f) && (this->actor.yDistToPlayer < -5.0f) && - (-(f32)(player->cylinder.dim.height + 10) < this->actor.yDistToPlayer)) { - EnWallmas_SetupTakePlayer(this, globalCtx); - } -} - -void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnWallmas_SetupStand(this); - } -} - -void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnWallmas_SetupWalk(this); - } - - Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); -} - -void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnWallmas_SetupJumpToCeiling(this); - } - - Math_ScaledStepToS(&this->actor.world.rot.y, (s16)((s32)this->actor.yawTowardsPlayer + 0x8000), 0xB6); - - if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || - Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); - } -} - -void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnWallmas_SetupReturnToCeiling(this); - } -} - -void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - SkelAnime_Update(&this->skelAnime); - if (this->skelAnime.curFrame > 20.0f) { - this->timer += 9; - this->actor.world.pos.y = this->actor.world.pos.y + 30.0f; - } - - if (Animation_OnFrame(&this->skelAnime, 20.0f) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_UP); - } - - if (this->actor.yDistToPlayer < -900.0f) { - if (this->actor.params == WMT_FLAG) { - Actor_Kill(&this->actor); - return; - } - - if (this->actor.params == WMT_TIMER || - Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 200.0f) { - EnWallmas_TimerInit(this, globalCtx); - } else { - EnWallmas_ProximityOrSwitchInit(this); - } - } -} - -void EnWallmas_TakeDamage(EnWallmas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->actor.colChkInfo.health == 0) { - EnWallmas_SetupDie(this, globalCtx); - } else { - EnWallmas_SetupCooldown(this); - } - } - if (Animation_OnFrame(&this->skelAnime, 13.0f) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); -} - -void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - EnWallmas_SetupReturnToCeiling(this); - } -} - -void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { - if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015) != 0) { - Actor_SetScale(&this->actor, 0.01f); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xC0); - Actor_Kill(&this->actor); - } - this->actor.scale.z = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.x; -} - -void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (Animation_OnFrame(&this->skelAnime, 1.0f) != 0) { - if (!LINK_IS_ADULT) { - func_8002F7DC(&this->actor, NA_SE_VO_LI_DAMAGE_S_KID); - } else { - func_8002F7DC(&this->actor, NA_SE_VO_LI_DAMAGE_S); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_CATCH); - } - if (SkelAnime_Update(&this->skelAnime) != 0) { - player->actor.world.pos.x = this->actor.world.pos.x; - player->actor.world.pos.z = this->actor.world.pos.z; - - if (this->timer < 0) { - this->actor.world.pos.y = this->actor.world.pos.y + 2.0f; - } else { - this->actor.world.pos.y = this->actor.world.pos.y + 10.0f; - } - - if (!LINK_IS_ADULT) { - player->actor.world.pos.y = this->actor.world.pos.y - 30.0f; - } else { - player->actor.world.pos.y = this->actor.world.pos.y - 50.0f; - } - - if (this->timer == -0x1E) { - if (!LINK_IS_ADULT) { - func_8002F7DC(&this->actor, NA_SE_VO_LI_TAKEN_AWAY_KID); - } else { - func_8002F7DC(&this->actor, NA_SE_VO_LI_TAKEN_AWAY); - } - } - if (this->timer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_UP); - } - - this->timer = this->timer + 2; - } else { - Math_StepToF(&this->actor.world.pos.y, player->actor.world.pos.y + (!LINK_IS_ADULT ? 30.0f : 50.0f), 5.0f); - } - - Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); - Math_StepToF(&this->actor.world.pos.z, player->actor.world.pos.z, 3.0f); - - if (this->timer == 0x1E) { - func_80078884(NA_SE_OC_ABYSS); - Gameplay_TriggerRespawn(globalCtx); - } -} - -void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 200.0f) { - EnWallmas_TimerInit(this, globalCtx); - } -} - -void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag) != 0) { - EnWallmas_TimerInit(this, globalCtx); - this->timer = 0x51; - } -} - -void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - if (this->timer != 0) { - this->timer--; - } - - if (this->timer == 0) { - if (this->actor.colChkInfo.health == 0) { - EnWallmas_SetupDie(this, globalCtx); - } else { - EnWallmas_SetupReturnToCeiling(this); - } - } -} - -void EnWallmas_ColUpdate(EnWallmas* this, GlobalContext* globalCtx) { - if ((this->collider.base.acFlags & AC_HIT) != 0) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DEAD); - this->actor.flags &= ~ACTOR_FLAG_0; - } else { - if (this->actor.colChkInfo.damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DAMAGE); - } - } - - if ((this->actor.colChkInfo.damageEffect == DAMAGE_EFFECT_STUN_WHITE) || - (this->actor.colChkInfo.damageEffect == DAMAGE_EFFECT_STUN_BLUE)) { - if (this->actionFunc != EnWallmas_Stun) { - EnWallmas_SetupStun(this); - } - } else { - if (this->actor.colChkInfo.damageEffect == DAMAGE_EFFECT_BURN) { - EffectSsFCircle_Spawn(globalCtx, &this->actor, &this->actor.world.pos, 40, 40); - } - - EnWallmas_SetupTakeDamage(this); - } - } - } -} - -void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { - EnWallmas* this = (EnWallmas*)thisx; - char pad[4]; - - EnWallmas_ColUpdate(this, globalCtx); - this->actionFunc(this, globalCtx); - - if ((this->actionFunc == EnWallmas_WaitToDrop) || (this->actionFunc == EnWallmas_WaitForProximity) || - (this->actionFunc == EnWallmas_TakePlayer) || (this->actionFunc == EnWallmas_WaitForSwitchFlag)) { - return; - } - - if ((this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer)) { - Actor_MoveForward(&this->actor); - } - - if (this->actionFunc != EnWallmas_Drop) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1D); - } else if (this->actor.world.pos.y <= this->yTarget) { - this->actor.world.pos.y = this->yTarget; - this->actor.velocity.y = 0.0f; - EnWallmas_SetupLand(this, globalCtx); - } - - if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if ((this->actionFunc != EnWallmas_TakeDamage) && (this->actor.bgCheckFlags & 1) != 0 && - (this->actor.freezeTimer == 0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - - Actor_SetFocus(&this->actor, 25.0f); - - if (this->actionFunc == EnWallmas_TakeDamage) { - return; - } - - this->actor.shape.rot.y = this->actor.world.rot.y; -} - -void EnWallmas_DrawXlu(EnWallmas* this, GlobalContext* globalCtx) { - s32 pad; - f32 xzScale; - MtxF mf; - - if ((this->actor.floorPoly == NULL) || ((this->timer >= 0x51) && (this->actionFunc != EnWallmas_Stun))) { - return; - } - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1386); - - func_80094044(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); - - func_80038A28(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - &mf); - Matrix_Mult(&mf, MTXMODE_NEW); - - if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && - (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { - xzScale = this->actor.scale.x * 50.0f; - } else { - xzScale = ((0x50 - this->timer) >= 0x51 ? 0x50 : (0x50 - this->timer)) * TIMER_SCALE; - } - - Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1421), G_MTX_LOAD); - gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1426); -} - -s32 EnWallMas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnWallmas* this = (EnWallmas*)thisx; - - if (limbIndex == 1) { - if (this->actionFunc != EnWallmas_TakePlayer) { - pos->z -= 1600.0f; - } else { - pos->z -= ((1600.0f * (this->skelAnime.endFrame - this->skelAnime.curFrame)) / this->skelAnime.endFrame); - } - } - return false; -} - -void EnWallMas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - if (limbIndex == 2) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1478); - - Matrix_Push(); - Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_RotateY(DEGREE_60_RAD, MTXMODE_APPLY); - Matrix_RotateZ(DEGREE_15_RAD, MTXMODE_APPLY); - Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1489), G_MTX_LOAD); - gSPDisplayList(POLY_OPA_DISP++, gWallmasterFingerDL); - - Matrix_Pop(); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1495); - } -} - -void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnWallmas* this = (EnWallmas*)thisx; - - if (this->actionFunc != EnWallmas_WaitToDrop) { - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnWallMas_OverrideLimbDraw, EnWallMas_PostLimbDraw, this); - } - - EnWallmas_DrawXlu(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.cpp b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.cpp new file mode 100644 index 000000000..37af5d3ef --- /dev/null +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.cpp @@ -0,0 +1,668 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WALLMAS_Z_EN_WALLMAS_C +#include "actor_common.h" +/* + * File: z_en_wallmas + * Overlay: En_Wallmas + * Description: Wallmaster (Ceiling monster) + */ + +#include "z_en_wallmas.h" +#include "objects/object_wallmaster/object_wallmaster.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800F7260.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +#define TIMER_SCALE ((f32)OS_CLOCK_RATE / 10000000000) +#define DEGREE_60_RAD (60.0f * M_PI / 180.0f) +#define DEGREE_15_RAD (15.0f * M_PI / 180.0f) + +#define DAMAGE_EFFECT_BURN 2 +#define DAMAGE_EFFECT_STUN_WHITE 4 +#define DAMAGE_EFFECT_STUN_BLUE 1 + +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx); +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnWallmas_TimerInit(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_ProximityOrSwitchInit(EnWallmas* pthis); +void EnWallmas_WaitToDrop(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Drop(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Land(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Stand(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_JumpToCeiling(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_ReturnToCeiling(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_TakeDamage(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Cooldown(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Die(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_TakePlayer(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_WaitForProximity(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Stun(EnWallmas* pthis, GlobalContext* globalCtx); +void EnWallmas_Walk(EnWallmas* pthis, GlobalContext* globalCtx); + +ActorInit En_Wallmas_InitVars = { + ACTOR_EN_WALLMAS, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_WALLMASTER, + sizeof(EnWallmas), + (ActorFunc)EnWallmas_Init, + (ActorFunc)EnWallmas_Destroy, + (ActorFunc)EnWallmas_Update, + (ActorFunc)EnWallmas_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 30, 40, 0, { 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 4, 30, 40, 150 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(0, 0x1), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(4, 0x2), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(4, 0x4), + /* Unk arrow 1 */ DMG_ENTRY(4, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(2, 0x0), + /* Fire magic */ DMG_ENTRY(4, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(4, 0x4), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x30, 1), + ICHAIN_F32(targetArrowOffset, 5500, 1), + ICHAIN_F32_DIV1000(gravity, -1500, 0), +}; + +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* pthis = (EnWallmas*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + ActorShape_Init(&thisx->shape, 0, NULL, 0.5f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gWallmasterSkel, &gWallmasterWaitAnim, pthis->jointTable, + pthis->morphTable, 25); + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, thisx, &sCylinderInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->switchFlag = (u8)(thisx->params >> 0x8); + thisx->params = thisx->params & 0xFF; + + if (thisx->params == WMT_FLAG) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag) != 0) { + Actor_Kill(thisx); + return; + } + + EnWallmas_ProximityOrSwitchInit(pthis); + } else if (thisx->params == WMT_PROXIMITY) { + EnWallmas_ProximityOrSwitchInit(pthis); + } else { + EnWallmas_TimerInit(pthis, globalCtx); + } +} + +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* pthis = (EnWallmas*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnWallmas_TimerInit(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags |= ACTOR_FLAG_5; + pthis->timer = 0x82; + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = player->actor.world.pos.y; + pthis->actor.floorHeight = player->actor.floorHeight; + pthis->actor.draw = EnWallmas_Draw; + pthis->actionFunc = EnWallmas_WaitToDrop; +} + +void EnWallmas_SetupDrop(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + AnimationHeader* objSegChangee = &gWallmasterLungeAnim; + + Animation_Change(&pthis->skelAnime, objSegChangee, 0.0f, 20.0f, Animation_GetLastFrame(&gWallmasterLungeAnim), + ANIMMODE_ONCE, 0.0f); + + pthis->yTarget = player->actor.world.pos.y; + pthis->actor.world.pos.y = player->actor.world.pos.y + 300.0f; + pthis->actor.world.rot.y = player->actor.shape.rot.y + 0x8000; + pthis->actor.floorHeight = player->actor.floorHeight; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_5; + pthis->actionFunc = EnWallmas_Drop; +} + +void EnWallmas_SetupLand(EnWallmas* pthis, GlobalContext* globalCtx) { + AnimationHeader* objSegFrameCount = &gWallmasterJumpAnim; + AnimationHeader* objSegChangee = &gWallmasterJumpAnim; + + Animation_Change(&pthis->skelAnime, objSegChangee, 1.0f, 41.0f, Animation_GetLastFrame(objSegFrameCount), + ANIMMODE_ONCE, -3.0f); + + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 15.0f, 6, 20.0f, 0x12C, 0x64, 1); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_LAND); + pthis->actionFunc = EnWallmas_Land; +} + +void EnWallmas_SetupStand(EnWallmas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterStandUpAnim); + pthis->actionFunc = EnWallmas_Stand; +} + +void EnWallmas_SetupWalk(EnWallmas* pthis) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gWallmasterWalkAnim, 3.0f); + pthis->actionFunc = EnWallmas_Walk; + pthis->actor.speedXZ = 3.0f; +} + +void EnWallmas_SetupJumpToCeiling(EnWallmas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterStopWalkAnim); + pthis->actionFunc = EnWallmas_JumpToCeiling; + pthis->actor.speedXZ = 0.0f; +} +void EnWallmas_SetupReturnToCeiling(EnWallmas* pthis) { + AnimationHeader* objSegFrameCount = &gWallmasterJumpAnim; + AnimationHeader* objSegChangee = &gWallmasterJumpAnim; + + pthis->timer = 0; + pthis->actor.speedXZ = 0.0f; + + Animation_Change(&pthis->skelAnime, objSegChangee, 3.0f, 0.0f, Animation_GetLastFrame(objSegFrameCount), + ANIMMODE_ONCE, -3.0f); + + pthis->actionFunc = EnWallmas_ReturnToCeiling; +} + +void EnWallmas_SetupTakeDamage(EnWallmas* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWallmasterDamageAnim, -3.0f); + if (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x0001F824) { + pthis->actor.world.rot.y = pthis->collider.base.ac->world.rot.y; + } else { + pthis->actor.world.rot.y = Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; + } + + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xFF, 0, 0x14); + pthis->actionFunc = EnWallmas_TakeDamage; + pthis->actor.speedXZ = 5.0f; + pthis->actor.velocity.y = 10.0f; +} + +void EnWallmas_SetupCooldown(EnWallmas* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWallmasterRecoverFromDamageAnim); + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actionFunc = EnWallmas_Cooldown; +} + +void EnWallmas_SetupDie(EnWallmas* pthis, GlobalContext* globalCtx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + + EffectSsDeadDb_Spawn(globalCtx, &pthis->actor.world.pos, &zeroVec, &zeroVec, 250, -10, 255, 255, 255, 255, 0, 0, 255, + 1, 9, true); + + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xC0); + pthis->actionFunc = EnWallmas_Die; +} + +void EnWallmas_SetupTakePlayer(EnWallmas* pthis, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWallmasterHoverAnim, -5.0f); + pthis->timer = -0x1E; + pthis->actionFunc = EnWallmas_TakePlayer; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + + pthis->yTarget = pthis->actor.yDistToPlayer; + func_8002DF38(globalCtx, &pthis->actor, 0x25); + OnePointCutscene_Init(globalCtx, 9500, 9999, &pthis->actor, MAIN_CAM); +} + +void EnWallmas_ProximityOrSwitchInit(EnWallmas* pthis) { + pthis->timer = 0; + pthis->actor.draw = NULL; + pthis->actor.flags &= ~ACTOR_FLAG_0; + if (pthis->actor.params == WMT_PROXIMITY) { + pthis->actionFunc = EnWallmas_WaitForProximity; + } else { + pthis->actionFunc = EnWallmas_WaitForSwitchFlag; + } +} + +void EnWallmas_SetupStun(EnWallmas* pthis) { + Animation_Change(&pthis->skelAnime, &gWallmasterJumpAnim, 1.5f, 0, 20.0f, ANIMMODE_ONCE, -3.0f); + + pthis->actor.speedXZ = 0.0f; + if (pthis->actor.colChkInfo.damageEffect == 4) { + Actor_SetColorFilter(&pthis->actor, -0x8000, 0xFF, 0, 0x50); + } else { + Actor_SetColorFilter(&pthis->actor, 0, 0xFF, 0, 0x50); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + } + + pthis->timer = 0x50; + pthis->actionFunc = EnWallmas_Stun; +} + +void EnWallmas_WaitToDrop(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + + pthis->actor.world.pos = *playerPos; + pthis->actor.floorHeight = player->actor.floorHeight; + pthis->actor.floorPoly = player->actor.floorPoly; + + if (pthis->timer != 0) { + pthis->timer--; + } + + if ((player->stateFlags1 & 0x100000) || (player->stateFlags1 & 0x8000000) || !(player->actor.bgCheckFlags & 1) || + ((pthis->actor.params == 1) && (320.0f < Math_Vec3f_DistXZ(&pthis->actor.home.pos, playerPos)))) { + Audio_StopSfxById(NA_SE_EN_FALL_AIM); + pthis->timer = 0x82; + } + + if (pthis->timer == 0x50) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_AIM); + } + + if (pthis->timer == 0) { + EnWallmas_SetupDrop(pthis, globalCtx); + } +} + +void EnWallmas_Drop(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!Player_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + (pthis->actor.xzDistToPlayer < 30.0f) && (pthis->actor.yDistToPlayer < -5.0f) && + (-(f32)(player->cylinder.dim.height + 10) < pthis->actor.yDistToPlayer)) { + EnWallmas_SetupTakePlayer(pthis, globalCtx); + } +} + +void EnWallmas_Land(EnWallmas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnWallmas_SetupStand(pthis); + } +} + +void EnWallmas_Stand(EnWallmas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnWallmas_SetupWalk(pthis); + } + + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 0xB6); +} + +void EnWallmas_Walk(EnWallmas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnWallmas_SetupJumpToCeiling(pthis); + } + + Math_ScaledStepToS(&pthis->actor.world.rot.y, (s16)((s32)pthis->actor.yawTowardsPlayer + 0x8000), 0xB6); + + if (Animation_OnFrame(&pthis->skelAnime, 0.0f) || Animation_OnFrame(&pthis->skelAnime, 12.0f) || + Animation_OnFrame(&pthis->skelAnime, 24.0f) || Animation_OnFrame(&pthis->skelAnime, 36.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_WALK); + } +} + +void EnWallmas_JumpToCeiling(EnWallmas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnWallmas_SetupReturnToCeiling(pthis); + } +} + +void EnWallmas_ReturnToCeiling(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + SkelAnime_Update(&pthis->skelAnime); + if (pthis->skelAnime.curFrame > 20.0f) { + pthis->timer += 9; + pthis->actor.world.pos.y = pthis->actor.world.pos.y + 30.0f; + } + + if (Animation_OnFrame(&pthis->skelAnime, 20.0f) != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_UP); + } + + if (pthis->actor.yDistToPlayer < -900.0f) { + if (pthis->actor.params == WMT_FLAG) { + Actor_Kill(&pthis->actor); + return; + } + + if (pthis->actor.params == WMT_TIMER || + Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < 200.0f) { + EnWallmas_TimerInit(pthis, globalCtx); + } else { + EnWallmas_ProximityOrSwitchInit(pthis); + } + } +} + +void EnWallmas_TakeDamage(EnWallmas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + if (pthis->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(pthis, globalCtx); + } else { + EnWallmas_SetupCooldown(pthis); + } + } + if (Animation_OnFrame(&pthis->skelAnime, 13.0f) != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 0.2f); +} + +void EnWallmas_Cooldown(EnWallmas* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + EnWallmas_SetupReturnToCeiling(pthis); + } +} + +void EnWallmas_Die(EnWallmas* pthis, GlobalContext* globalCtx) { + if (Math_StepToF(&pthis->actor.scale.x, 0.0f, 0.0015) != 0) { + Actor_SetScale(&pthis->actor, 0.01f); + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xC0); + Actor_Kill(&pthis->actor); + } + pthis->actor.scale.z = pthis->actor.scale.x; + pthis->actor.scale.y = pthis->actor.scale.x; +} + +void EnWallmas_TakePlayer(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Animation_OnFrame(&pthis->skelAnime, 1.0f) != 0) { + if (!LINK_IS_ADULT) { + func_8002F7DC(&pthis->actor, NA_SE_VO_LI_DAMAGE_S_KID); + } else { + func_8002F7DC(&pthis->actor, NA_SE_VO_LI_DAMAGE_S); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_CATCH); + } + if (SkelAnime_Update(&pthis->skelAnime) != 0) { + player->actor.world.pos.x = pthis->actor.world.pos.x; + player->actor.world.pos.z = pthis->actor.world.pos.z; + + if (pthis->timer < 0) { + pthis->actor.world.pos.y = pthis->actor.world.pos.y + 2.0f; + } else { + pthis->actor.world.pos.y = pthis->actor.world.pos.y + 10.0f; + } + + if (!LINK_IS_ADULT) { + player->actor.world.pos.y = pthis->actor.world.pos.y - 30.0f; + } else { + player->actor.world.pos.y = pthis->actor.world.pos.y - 50.0f; + } + + if (pthis->timer == -0x1E) { + if (!LINK_IS_ADULT) { + func_8002F7DC(&pthis->actor, NA_SE_VO_LI_TAKEN_AWAY_KID); + } else { + func_8002F7DC(&pthis->actor, NA_SE_VO_LI_TAKEN_AWAY); + } + } + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_UP); + } + + pthis->timer = pthis->timer + 2; + } else { + Math_StepToF(&pthis->actor.world.pos.y, player->actor.world.pos.y + (!LINK_IS_ADULT ? 30.0f : 50.0f), 5.0f); + } + + Math_StepToF(&pthis->actor.world.pos.x, player->actor.world.pos.x, 3.0f); + Math_StepToF(&pthis->actor.world.pos.z, player->actor.world.pos.z, 3.0f); + + if (pthis->timer == 0x1E) { + func_80078884(NA_SE_OC_ABYSS); + Gameplay_TriggerRespawn(globalCtx); + } +} + +void EnWallmas_WaitForProximity(EnWallmas* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + if (Math_Vec3f_DistXZ(&pthis->actor.home.pos, &player->actor.world.pos) < 200.0f) { + EnWallmas_TimerInit(pthis, globalCtx); + } +} + +void EnWallmas_WaitForSwitchFlag(EnWallmas* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag) != 0) { + EnWallmas_TimerInit(pthis, globalCtx); + pthis->timer = 0x51; + } +} + +void EnWallmas_Stun(EnWallmas* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + if (pthis->timer != 0) { + pthis->timer--; + } + + if (pthis->timer == 0) { + if (pthis->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(pthis, globalCtx); + } else { + EnWallmas_SetupReturnToCeiling(pthis); + } + } +} + +void EnWallmas_ColUpdate(EnWallmas* pthis, GlobalContext* globalCtx) { + if ((pthis->collider.base.acFlags & AC_HIT) != 0) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_DEAD); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } else { + if (pthis->actor.colChkInfo.damage != 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FALL_DAMAGE); + } + } + + if ((pthis->actor.colChkInfo.damageEffect == DAMAGE_EFFECT_STUN_WHITE) || + (pthis->actor.colChkInfo.damageEffect == DAMAGE_EFFECT_STUN_BLUE)) { + if (pthis->actionFunc != EnWallmas_Stun) { + EnWallmas_SetupStun(pthis); + } + } else { + if (pthis->actor.colChkInfo.damageEffect == DAMAGE_EFFECT_BURN) { + EffectSsFCircle_Spawn(globalCtx, &pthis->actor, &pthis->actor.world.pos, 40, 40); + } + + EnWallmas_SetupTakeDamage(pthis); + } + } + } +} + +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* pthis = (EnWallmas*)thisx; + char pad[4]; + + EnWallmas_ColUpdate(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + + if ((pthis->actionFunc == EnWallmas_WaitToDrop) || (pthis->actionFunc == EnWallmas_WaitForProximity) || + (pthis->actionFunc == EnWallmas_TakePlayer) || (pthis->actionFunc == EnWallmas_WaitForSwitchFlag)) { + return; + } + + if ((pthis->actionFunc != EnWallmas_ReturnToCeiling) && (pthis->actionFunc != EnWallmas_TakePlayer)) { + Actor_MoveForward(&pthis->actor); + } + + if (pthis->actionFunc != EnWallmas_Drop) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 20.0f, 25.0f, 0.0f, 0x1D); + } else if (pthis->actor.world.pos.y <= pthis->yTarget) { + pthis->actor.world.pos.y = pthis->yTarget; + pthis->actor.velocity.y = 0.0f; + EnWallmas_SetupLand(pthis, globalCtx); + } + + if ((pthis->actionFunc != EnWallmas_Die) && (pthis->actionFunc != EnWallmas_Drop)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + + if ((pthis->actionFunc != EnWallmas_TakeDamage) && (pthis->actor.bgCheckFlags & 1) != 0 && + (pthis->actor.freezeTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + + Actor_SetFocus(&pthis->actor, 25.0f); + + if (pthis->actionFunc == EnWallmas_TakeDamage) { + return; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; +} + +void EnWallmas_DrawXlu(EnWallmas* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 xzScale; + MtxF mf; + + if ((pthis->actor.floorPoly == NULL) || ((pthis->timer >= 0x51) && (pthis->actionFunc != EnWallmas_Stun))) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1386); + + func_80094044(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_80038A28(pthis->actor.floorPoly, pthis->actor.world.pos.x, pthis->actor.floorHeight, pthis->actor.world.pos.z, + &mf); + Matrix_Mult(&mf, MTXMODE_NEW); + + if ((pthis->actionFunc != EnWallmas_WaitToDrop) && (pthis->actionFunc != EnWallmas_ReturnToCeiling) && + (pthis->actionFunc != EnWallmas_TakePlayer) && (pthis->actionFunc != EnWallmas_WaitForSwitchFlag)) { + xzScale = pthis->actor.scale.x * 50.0f; + } else { + xzScale = ((0x50 - pthis->timer) >= 0x51 ? 0x50 : (0x50 - pthis->timer)) * TIMER_SCALE; + } + + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1421), G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1426); +} + +s32 EnWallMas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnWallmas* pthis = (EnWallmas*)thisx; + + if (limbIndex == 1) { + if (pthis->actionFunc != EnWallmas_TakePlayer) { + pos->z -= 1600.0f; + } else { + pos->z -= ((1600.0f * (pthis->skelAnime.endFrame - pthis->skelAnime.curFrame)) / pthis->skelAnime.endFrame); + } + } + return false; +} + +void EnWallMas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + if (limbIndex == 2) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1478); + + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateY(DEGREE_60_RAD, MTXMODE_APPLY); + Matrix_RotateZ(DEGREE_15_RAD, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1489), G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, gWallmasterFingerDL); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1495); + } +} + +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* pthis = (EnWallmas*)thisx; + + if (pthis->actionFunc != EnWallmas_WaitToDrop) { + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnWallMas_OverrideLimbDraw, EnWallMas_PostLimbDraw, pthis); + } + + EnWallmas_DrawXlu(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.cpp similarity index 59% rename from src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c rename to src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.cpp index 8867a9b87..cf2bc3dc1 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.cpp @@ -20,25 +20,25 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx); void EnWeatherTag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWeatherTag_DisabledCloudyHyruleMarket(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledCloudyHyruleMarket(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DisabledCloudyLonLonRanch(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledCloudyLonLonRanch(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DisabledCloudySnow(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledCloudySnow(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DisabledRainLakeHylia(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledRainLakeHylia(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DisabledCloudyDeathMountain(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledCloudyDeathMountain(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DisabledCloudyRainThunderKakariko(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledCloudyRainThunderKakariko(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_SetSandstormIntensity(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DisabledRainThunder(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_EnabledRainThunder(EnWeatherTag* this, GlobalContext* globalCtx); +void EnWeatherTag_DisabledCloudyHyruleMarket(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledCloudyHyruleMarket(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_DisabledCloudyLonLonRanch(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledCloudyLonLonRanch(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_DisabledCloudySnow(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledCloudySnow(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_DisabledRainLakeHylia(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledRainLakeHylia(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_DisabledCloudyDeathMountain(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledCloudyDeathMountain(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_DisabledCloudyRainThunderKakariko(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledCloudyRainThunderKakariko(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_SetSandstormIntensity(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_DisabledRainThunder(EnWeatherTag* pthis, GlobalContext* globalCtx); +void EnWeatherTag_EnabledRainThunder(EnWeatherTag* pthis, GlobalContext* globalCtx); #define WEATHER_TAG_RANGE100(x) ((x >> 8) * 100.0f) -const ActorInit En_Weather_Tag_InitVars = { +ActorInit En_Weather_Tag_InitVars = { ACTOR_EN_WEATHER_TAG, ACTORCAT_PROP, FLAGS, @@ -50,33 +50,33 @@ const ActorInit En_Weather_Tag_InitVars = { NULL, }; -void EnWeatherTag_SetupAction(EnWeatherTag* this, EnWeatherTagActionFunc actionFunc) { - this->actionFunc = actionFunc; +void EnWeatherTag_SetupAction(EnWeatherTag* pthis, EnWeatherTagActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void EnWeatherTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { - EnWeatherTag* this = (EnWeatherTag*)thisx; + EnWeatherTag* pthis = (EnWeatherTag*)thisx; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; - switch (this->actor.params & 0xF) { + switch (pthis->actor.params & 0xF) { case EN_WEATHER_TAG_TYPE_CLOUDY_MARKET: osSyncPrintf("\n\n"); // "☆☆☆☆☆ (;o;) About ☆☆☆☆☆☆" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ (;o;) くらいよー ☆☆☆☆☆ \n" VT_RST); - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyHyruleMarket); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyHyruleMarket); break; case EN_WEATHER_TAG_TYPE_CLOUDY_LON_LON_RANCH: osSyncPrintf("\n\n"); // "☆☆☆☆☆ Cloudy (._.) Ah Melancholy ☆☆☆☆☆" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ くもり (._.) あーあ 憂鬱 ☆☆☆☆☆ \n" VT_RST); if (Flags_GetEventChkInf(0x18)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyLonLonRanch); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyLonLonRanch); break; case EN_WEATHER_TAG_TYPE_SNOW_ZORAS_DOMAIN: osSyncPrintf("\n\n"); @@ -84,9 +84,9 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ ゆきがふるー あなたはこないー (._.) ☆☆☆☆☆ \n" VT_RST); if (gSaveContext.eventChkInf[4] & 0x400) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudySnow); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudySnow); break; case EN_WEATHER_TAG_TYPE_RAIN_LAKE_HYLIA: osSyncPrintf("\n\n"); @@ -94,18 +94,18 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ わわわわー なーがーさーきーはー (^o^) ☆☆☆☆☆ \n" VT_RST); if (gSaveContext.eventChkInf[4] & 0x400) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledRainLakeHylia); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledRainLakeHylia); break; case EN_WEATHER_TAG_TYPE_CLOUDY_DEATH_MOUNTAIN: osSyncPrintf("\n\n"); // "☆☆☆☆☆ Cloudy (._.) Ah Melancholy ☆☆☆☆☆" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ くもり (._.) あーあ 憂鬱 ☆☆☆☆☆ \n" VT_RST); if (gSaveContext.eventChkInf[4] & 0x200) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyDeathMountain); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyDeathMountain); break; case EN_WEATHER_TAG_TYPE_THUNDERSTORM_KAKARIKO: osSyncPrintf("\n\n"); @@ -114,33 +114,33 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.eventChkInf[4] & 0x100) || !(gSaveContext.eventChkInf[4] & 0x200) || !(gSaveContext.eventChkInf[4] & 0x400) || CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyRainThunderKakariko); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyRainThunderKakariko); break; case EN_WEATHER_TAG_TYPE_SANDSTORM_INTENSITY: osSyncPrintf("\n\n"); // "☆☆☆☆☆ The desert becomes thicker ☆☆☆☆☆" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 砂漠が濃くなります ☆☆☆☆☆ \n" VT_RST); - EnWeatherTag_SetupAction(this, EnWeatherTag_SetSandstormIntensity); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_SetSandstormIntensity); break; case EN_WEATHER_TAG_TYPE_THUNDERSTORM_GRAVEYARD: osSyncPrintf("\n\n"); // "☆☆☆☆☆ Wow wa wa na wa saa ki ha (^o^) ☆☆☆☆☆" osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ わわわわー なーがーさーきーはー (^o^) ☆☆☆☆☆ \n" VT_RST); - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledRainThunder); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledRainThunder); break; } } -u8 WeatherTag_CheckEnableWeatherEffect(EnWeatherTag* this, GlobalContext* globalCtx, u8 arg2, u8 arg3, u8 arg4, u8 arg5, +u8 WeatherTag_CheckEnableWeatherEffect(EnWeatherTag* pthis, GlobalContext* globalCtx, u8 arg2, u8 arg3, u8 arg4, u8 arg5, u16 arg6, u8 weatherMode) { s32 pad; u8 ret = false; Player* player = GET_PLAYER(globalCtx); - if (Actor_WorldDistXZToActor(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this->actor.params)) { + if (Actor_WorldDistXZToActor(&player->actor, &pthis->actor) < WEATHER_TAG_RANGE100(pthis->actor.params)) { if ((globalCtx->envCtx.indoors != 0) || !gSkyboxBlendingEnabled || (globalCtx->skyboxId != SKYBOX_NORMAL_SKY && globalCtx->envCtx.unk_1F == globalCtx->envCtx.unk_20)) { D_8011FB38 = 1; @@ -174,13 +174,13 @@ u8 WeatherTag_CheckEnableWeatherEffect(EnWeatherTag* this, GlobalContext* global return ret; } -u8 WeatherTag_CheckRestoreWeather(EnWeatherTag* this, GlobalContext* globalCtx, u8 arg2, u8 arg3, u8 arg4, u8 arg5, +u8 WeatherTag_CheckRestoreWeather(EnWeatherTag* pthis, GlobalContext* globalCtx, u8 arg2, u8 arg3, u8 arg4, u8 arg5, u16 arg6) { s32 pad; u8 ret = false; Player* player = GET_PLAYER(globalCtx); - if ((WEATHER_TAG_RANGE100(this->actor.params) + 100.0f) < Actor_WorldDistXZToActor(&player->actor, &this->actor)) { + if ((WEATHER_TAG_RANGE100(pthis->actor.params) + 100.0f) < Actor_WorldDistXZToActor(&player->actor, &pthis->actor)) { if (globalCtx->envCtx.indoors != 0 || !gSkyboxBlendingEnabled || (globalCtx->skyboxId != SKYBOX_NORMAL_SKY && globalCtx->envCtx.unk_1F == globalCtx->envCtx.unk_20)) { D_8011FB38 = 1; @@ -208,94 +208,94 @@ u8 WeatherTag_CheckRestoreWeather(EnWeatherTag* this, GlobalContext* globalCtx, return ret; } -void EnWeatherTag_DisabledCloudyHyruleMarket(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckEnableWeatherEffect(this, globalCtx, 0, 1, 0, 3, 60, 1)) { - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledCloudyHyruleMarket); +void EnWeatherTag_DisabledCloudyHyruleMarket(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckEnableWeatherEffect(pthis, globalCtx, 0, 1, 0, 3, 60, 1)) { + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledCloudyHyruleMarket); } } -void EnWeatherTag_EnabledCloudyHyruleMarket(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckRestoreWeather(this, globalCtx, 1, 0, 3, 0, 60)) { - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyHyruleMarket); +void EnWeatherTag_EnabledCloudyHyruleMarket(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckRestoreWeather(pthis, globalCtx, 1, 0, 3, 0, 60)) { + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyHyruleMarket); } } -void EnWeatherTag_DisabledCloudyLonLonRanch(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckEnableWeatherEffect(this, globalCtx, 0, 1, 0, 2, 100, 2)) { - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledCloudyLonLonRanch); +void EnWeatherTag_DisabledCloudyLonLonRanch(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckEnableWeatherEffect(pthis, globalCtx, 0, 1, 0, 2, 100, 2)) { + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledCloudyLonLonRanch); } } -void EnWeatherTag_EnabledCloudyLonLonRanch(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckRestoreWeather(this, globalCtx, 1, 0, 2, 0, 100)) { - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyLonLonRanch); +void EnWeatherTag_EnabledCloudyLonLonRanch(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckRestoreWeather(pthis, globalCtx, 1, 0, 2, 0, 100)) { + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyLonLonRanch); } } -void EnWeatherTag_DisabledCloudyDeathMountain(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckEnableWeatherEffect(this, globalCtx, 0, 1, 0, 2, 60, 2)) { - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledCloudyDeathMountain); +void EnWeatherTag_DisabledCloudyDeathMountain(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckEnableWeatherEffect(pthis, globalCtx, 0, 1, 0, 2, 60, 2)) { + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledCloudyDeathMountain); } } -void EnWeatherTag_EnabledCloudyDeathMountain(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckRestoreWeather(this, globalCtx, 1, 0, 2, 0, 60)) { - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyLonLonRanch); +void EnWeatherTag_EnabledCloudyDeathMountain(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckRestoreWeather(pthis, globalCtx, 1, 0, 2, 0, 60)) { + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyLonLonRanch); } } -void EnWeatherTag_DisabledCloudySnow(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckEnableWeatherEffect(this, globalCtx, 0, 1, 0, 2, 60, 3)) { +void EnWeatherTag_DisabledCloudySnow(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckEnableWeatherEffect(pthis, globalCtx, 0, 1, 0, 2, 60, 3)) { globalCtx->envCtx.unk_EE[3] = 64; - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledCloudySnow); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledCloudySnow); } } -void EnWeatherTag_EnabledCloudySnow(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckRestoreWeather(this, globalCtx, 1, 0, 2, 0, 60)) { +void EnWeatherTag_EnabledCloudySnow(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckRestoreWeather(pthis, globalCtx, 1, 0, 2, 0, 60)) { globalCtx->envCtx.unk_EE[3] = 0; - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudySnow); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudySnow); } } -void EnWeatherTag_DisabledRainLakeHylia(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckEnableWeatherEffect(this, globalCtx, 0, 1, 0, 2, 100, 4)) { +void EnWeatherTag_DisabledRainLakeHylia(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckEnableWeatherEffect(pthis, globalCtx, 0, 1, 0, 2, 100, 4)) { func_80077624(globalCtx); globalCtx->envCtx.unk_EE[0] = 25; - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledRainLakeHylia); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledRainLakeHylia); } } -void EnWeatherTag_EnabledRainLakeHylia(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckRestoreWeather(this, globalCtx, 1, 0, 2, 0, 100)) { +void EnWeatherTag_EnabledRainLakeHylia(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckRestoreWeather(pthis, globalCtx, 1, 0, 2, 0, 100)) { func_80077684(globalCtx); globalCtx->envCtx.unk_EE[0] = 0; - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledRainLakeHylia); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledRainLakeHylia); } } -void EnWeatherTag_DisabledCloudyRainThunderKakariko(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckEnableWeatherEffect(this, globalCtx, 0, 1, 0, 4, 100, 5)) { +void EnWeatherTag_DisabledCloudyRainThunderKakariko(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckEnableWeatherEffect(pthis, globalCtx, 0, 1, 0, 4, 100, 5)) { func_80077624(globalCtx); globalCtx->envCtx.lightningMode = LIGHTNING_MODE_ON; globalCtx->envCtx.unk_EE[0] = 30; - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledCloudyRainThunderKakariko); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledCloudyRainThunderKakariko); } } -void EnWeatherTag_EnabledCloudyRainThunderKakariko(EnWeatherTag* this, GlobalContext* globalCtx) { - if (WeatherTag_CheckRestoreWeather(this, globalCtx, 1, 0, 4, 0, 100)) { +void EnWeatherTag_EnabledCloudyRainThunderKakariko(EnWeatherTag* pthis, GlobalContext* globalCtx) { + if (WeatherTag_CheckRestoreWeather(pthis, globalCtx, 1, 0, 4, 0, 100)) { func_80077684(globalCtx); globalCtx->envCtx.lightningMode = LIGHTNING_MODE_LAST; globalCtx->envCtx.unk_EE[0] = 0; - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledCloudyRainThunderKakariko); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledCloudyRainThunderKakariko); } } -void EnWeatherTag_SetSandstormIntensity(EnWeatherTag* this, GlobalContext* globalCtx) { +void EnWeatherTag_SetSandstormIntensity(EnWeatherTag* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (Actor_WorldDistXZToActor(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this->actor.params)) { + if (Actor_WorldDistXZToActor(&player->actor, &pthis->actor) < WEATHER_TAG_RANGE100(pthis->actor.params)) { Math_SmoothStepToS(&globalCtx->envCtx.adjFogNear, -0x50, 1, 2, 1); Math_SmoothStepToS(&globalCtx->envCtx.adjFogFar, -0x7D0, 1, 50, 1); } else { @@ -304,31 +304,31 @@ void EnWeatherTag_SetSandstormIntensity(EnWeatherTag* this, GlobalContext* globa } } -void EnWeatherTag_DisabledRainThunder(EnWeatherTag* this, GlobalContext* globalCtx) { +void EnWeatherTag_DisabledRainThunder(EnWeatherTag* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (Actor_WorldDistXZToActor(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this->actor.params)) { + if (Actor_WorldDistXZToActor(&player->actor, &pthis->actor) < WEATHER_TAG_RANGE100(pthis->actor.params)) { func_80077624(globalCtx); globalCtx->envCtx.lightningMode = LIGHTNING_MODE_ON; globalCtx->envCtx.unk_EE[0] = 25; - EnWeatherTag_SetupAction(this, EnWeatherTag_EnabledRainThunder); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_EnabledRainThunder); } } -void EnWeatherTag_EnabledRainThunder(EnWeatherTag* this, GlobalContext* globalCtx) { +void EnWeatherTag_EnabledRainThunder(EnWeatherTag* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((WEATHER_TAG_RANGE100(this->actor.params) + 10.0f) < Actor_WorldDistXZToActor(&player->actor, &this->actor)) { + if ((WEATHER_TAG_RANGE100(pthis->actor.params) + 10.0f) < Actor_WorldDistXZToActor(&player->actor, &pthis->actor)) { func_80077684(globalCtx); globalCtx->envCtx.lightningMode = LIGHTNING_MODE_LAST; globalCtx->envCtx.unk_EE[0] = 0; globalCtx->envCtx.unk_EE[1] = 10; - EnWeatherTag_SetupAction(this, EnWeatherTag_DisabledRainThunder); + EnWeatherTag_SetupAction(pthis, EnWeatherTag_DisabledRainThunder); } } void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { - EnWeatherTag* this = (EnWeatherTag*)thisx; + EnWeatherTag* pthis = (EnWeatherTag*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c b/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c deleted file mode 100644 index 5f9cb2baf..000000000 --- a/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c +++ /dev/null @@ -1,662 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WEIYER_Z_EN_WEIYER_C -#include "actor_common.h" -/* - * File: z_en_weiyer.c - * Overlay: ovl_En_Weiyer - * Description: Stinger (Water) - */ - -#include "z_en_weiyer.h" -#include "objects/object_ei/object_ei.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) - -void EnWeiyer_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWeiyer_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWeiyer_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWeiyer_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B32804(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B328E8(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B32C2C(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B32D30(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B32E34(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B33018(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B331CC(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B333B8(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B332B4(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B33338(EnWeiyer* this, GlobalContext* globalCtx); -void func_80B3349C(EnWeiyer* this, GlobalContext* globalCtx); - -const ActorInit En_Weiyer_InitVars = { - ACTOR_EN_WEIYER, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_EI, - sizeof(EnWeiyer), - (ActorFunc)EnWeiyer_Init, - (ActorFunc)EnWeiyer_Destroy, - (ActorFunc)EnWeiyer_Update, - (ActorFunc)EnWeiyer_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 16, 10, -6, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 2, 45, 15, 100 }; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, 0x1), - /* Deku stick */ DMG_ENTRY(2, 0x0), - /* Slingshot */ DMG_ENTRY(1, 0x0), - /* Explosive */ DMG_ENTRY(2, 0x0), - /* Boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(2, 0x0), - /* Hammer swing */ DMG_ENTRY(2, 0x0), - /* Hookshot */ DMG_ENTRY(2, 0x0), - /* Kokiri sword */ DMG_ENTRY(1, 0x0), - /* Master sword */ DMG_ENTRY(2, 0x0), - /* Giant's Knife */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), - /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), - /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), - /* Fire magic */ DMG_ENTRY(0, 0x0), - /* Ice magic */ DMG_ENTRY(0, 0x0), - /* Light magic */ DMG_ENTRY(0, 0x0), - /* Shield */ DMG_ENTRY(0, 0x0), - /* Mirror Ray */ DMG_ENTRY(0, 0x0), - /* Kokiri spin */ DMG_ENTRY(1, 0x0), - /* Giant spin */ DMG_ENTRY(4, 0x0), - /* Master spin */ DMG_ENTRY(2, 0x0), - /* Kokiri jump */ DMG_ENTRY(2, 0x0), - /* Giant jump */ DMG_ENTRY(8, 0x0), - /* Master jump */ DMG_ENTRY(4, 0x0), - /* Unknown 1 */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* Hammer jump */ DMG_ENTRY(4, 0x0), - /* Unknown 2 */ DMG_ENTRY(0, 0x0), -}; -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x19, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 3, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_STOP), -}; - -void EnWeiyer_Init(Actor* thisx, GlobalContext* globalCtx) { - EnWeiyer* this = (EnWeiyer*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - ActorShape_Init(&this->actor.shape, 1000.0f, ActorShadow_DrawCircle, 65.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gStingerSkel, &gStingerIdleAnim, this->jointTable, this->morphTable, - 19); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->actionFunc = func_80B32804; -} - -void EnWeiyer_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnWeiyer* this = (EnWeiyer*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80B32384(EnWeiyer* this) { - this->unk_196 = this->actor.shape.rot.y; - this->unk_27C = (cosf(-M_PI / 8) * 3.0f) + this->actor.world.pos.y; - Animation_MorphToLoop(&this->skelAnime, &gStingerHitAnim, -5.0f); - this->unk_194 = 30; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 2.5f); - this->collider.base.atFlags &= ~AT_ON; - this->unk_280 = this->actor.floorHeight; - this->actionFunc = func_80B328E8; -} - -void func_80B32434(EnWeiyer* this) { - Animation_MorphToLoop(&this->skelAnime, &gStingerHitAnim, -5.0f); - this->collider.base.atFlags |= AT_ON; - this->unk_194 = 0; - this->actor.speedXZ = 5.0f; - this->actionFunc = func_80B32C2C; -} - -void func_80B32494(EnWeiyer* this) { - Animation_Change(&this->skelAnime, &gStingerPopOutAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); - this->unk_194 = 40; - this->collider.base.atFlags |= AT_ON; - this->actionFunc = func_80B32D30; -} - -void func_80B32508(EnWeiyer* this) { - this->unk_194 = 200; - this->collider.base.atFlags |= AT_ON; - this->skelAnime.playSpeed = 3.0f; - this->actionFunc = func_80B32E34; -} - -void func_80B32538(EnWeiyer* this) { - this->unk_194 = 200; - this->unk_196 = this->actor.yawTowardsPlayer + 0x8000; - this->unk_27C = this->actor.world.pos.y; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 4.0f); - this->collider.base.atFlags &= ~AT_ON; - this->skelAnime.playSpeed = 1.0f; - this->actionFunc = func_80B33018; -} - -void func_80B325A0(EnWeiyer* this) { - Animation_Change(&this->skelAnime, &gStingerHitAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -3.0f); - this->unk_194 = 40; - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 3.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, 0x28); - this->collider.dim.height = sCylinderInit.dim.height; - this->actionFunc = func_80B331CC; -} - -void func_80B32660(EnWeiyer* this) { - Animation_Change(&this->skelAnime, &gStingerPopOutAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); - this->unk_194 = 80; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.gravity = -1.0f; - this->collider.dim.height = sCylinderInit.dim.height + 15; - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x50); - this->collider.base.atFlags &= ~AT_ON; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionFunc = func_80B333B8; -} - -void func_80B32724(EnWeiyer* this) { - Animation_MorphToLoop(&this->skelAnime, &gStingerHitAnim, -5.0f); - this->unk_194 = 20; - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, 0x28); - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 3.0f; - this->actionFunc = func_80B332B4; -} - -void func_80B327B0(EnWeiyer* this) { - this->actor.colorFilterParams |= 0x2000; - this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 0.0f; - this->actionFunc = func_80B33338; -} - -void func_80B327D8(EnWeiyer* this) { - this->actor.shape.rot.x = -0x2000; - this->unk_194 = -1; - this->actor.speedXZ = 5.0f; - this->actionFunc = func_80B3349C; -} - -void func_80B32804(EnWeiyer* this, GlobalContext* globalCtx) { - WaterBox* waterBox; - s32 bgId; - - this->actor.world.pos.y += 0.5f; - this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); - - if (!WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->actor.home.pos.y, &waterBox) || - ((this->actor.home.pos.y - 5.0f) <= this->actor.floorHeight)) { - Actor_Kill(&this->actor); - } else { - this->actor.home.pos.y -= 5.0f; - this->actor.world.pos.y = (this->actor.home.pos.y + this->actor.floorHeight) / 2.0f; - func_80B32384(this); - } -} - -void func_80B328E8(EnWeiyer* this, GlobalContext* globalCtx) { - s32 sp34; - f32 curFrame; - - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x800); - sp34 = Animation_OnFrame(&this->skelAnime, 0.0f); - curFrame = this->skelAnime.curFrame; - Math_StepToF(&this->unk_27C, this->unk_280, 0.5f); - this->actor.world.pos.y = this->unk_27C - cosf((curFrame - 5.0f) * (M_PI / 40)) * 3.0f; - - if (curFrame <= 45.0f) { - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.03f); - } else { - Math_StepToF(&this->actor.speedXZ, 1.3f, 0.03f); - } - - if (this->actor.bgCheckFlags & 8) { - this->unk_196 = this->actor.wallYaw; - this->unk_194 = 30; - } - - if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_196, 182)) { - if (this->unk_194 != 0) { - this->unk_194--; - } - - if (this->unk_194 == 0) { - this->unk_196 = - Rand_S16Offset(0x2000, 0x2000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1) + this->actor.shape.rot.y; - this->unk_194 = 30; - - if (Rand_ZeroOne() < 0.3333f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_CRY); - } - } - } - - if (this->actor.home.pos.y < this->actor.world.pos.y) { - if (this->actor.home.pos.y < this->actor.floorHeight) { - func_80B32434(this); - } else { - this->actor.world.pos.y = this->actor.home.pos.y; - this->unk_280 = - Rand_ZeroOne() * ((this->actor.home.pos.y - this->actor.floorHeight) / 2.0f) + this->actor.floorHeight; - } - } else { - Player* player = GET_PLAYER(globalCtx); - - if (this->actor.bgCheckFlags & 1) { - this->unk_280 = - this->actor.home.pos.y - Rand_ZeroOne() * ((this->actor.home.pos.y - this->actor.floorHeight) / 2.0f); - } else if (sp34 && (Rand_ZeroOne() < 0.1f)) { - this->unk_280 = - Rand_ZeroOne() * (this->actor.home.pos.y - this->actor.floorHeight) + this->actor.floorHeight; - } - - if ((this->actor.xzDistToPlayer < 400.0f) && (fabsf(this->actor.yDistToPlayer) < 250.0f) && - (player->actor.world.pos.y < (this->actor.home.pos.y + 20.0f))) { - func_80B32508(this); - } - } -} - -void func_80B32C2C(EnWeiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->unk_194 == 0) { - if (Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0x800)) { - this->actor.shape.rot.z = 0; - this->actor.shape.rot.y += 0x8000; - this->unk_194 = 1; - } else { - this->actor.shape.rot.z = this->actor.shape.rot.x * 2; - } - } else { - Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1800, 0x800); - - if (this->actor.world.pos.y < this->actor.home.pos.y) { - if (this->actor.shape.rot.x > 0) { - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 1, 400); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_SINK); - } - - func_80B32538(this); - } else if (this->actor.bgCheckFlags & 1) { - func_80B32494(this); - } - } -} - -void func_80B32D30(EnWeiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_FLUTTER); - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x800); - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); - - if (this->unk_194 != 0) { - this->unk_194--; - } - - if (this->unk_194 == 0) { - func_80B32434(this); - } else if (this->actor.world.pos.y < this->actor.home.pos.y) { - func_80B32384(this); - } -} - -s16 func_80B32DEC(EnWeiyer* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f vec; - - vec.x = player->actor.world.pos.x; - vec.y = player->actor.world.pos.y + 20.0f; - vec.z = player->actor.world.pos.z; - - return Actor_WorldPitchTowardPoint(&this->actor, &vec); -} - -void func_80B32E34(EnWeiyer* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - SkelAnime_Update(&this->skelAnime); - - if (this->unk_194 != 0) { - this->unk_194--; - } - - if ((this->unk_194 == 0) || ((this->actor.home.pos.y + 20.0f) <= player->actor.world.pos.y) || - (this->collider.base.atFlags & AT_HIT)) { - func_80B32538(this); - } else { - if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { - Math_StepToF(&this->actor.speedXZ, 4.0f, 0.2f); - } else { - Math_StepToF(&this->actor.speedXZ, 1.3f, 0.2f); - } - - if (this->actor.home.pos.y < this->actor.world.pos.y) { - if (this->actor.home.pos.y < this->actor.floorHeight) { - this->actor.shape.rot.x = 0; - func_80B32434(this); - return; - } - - this->actor.world.pos.y = this->actor.home.pos.y; - Math_SmoothStepToS(&this->actor.shape.rot.x, 0x1000, 2, 0x100, 0x40); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.x, func_80B32DEC(this, globalCtx), 2, 0x100, 0x40); - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x200, 0x80); - - if ((player->actor.yDistToWater < 50.0f) && (this->actor.yDistToWater < 20.0f) && - Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_80B327D8(this); - } - } -} - -void func_80B33018(EnWeiyer* this, GlobalContext* globalCtx) { - f32 curFrame; - - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x800); - curFrame = this->skelAnime.curFrame; - Math_StepToF(&this->unk_27C, (this->actor.home.pos.y - this->actor.floorHeight) / 4.0f + this->actor.floorHeight, - 1.0f); - this->actor.world.pos.y = this->unk_27C - cosf((curFrame - 5.0f) * (M_PI / 40)) * 3.0f; - - if (curFrame <= 45.0f) { - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.03f); - } else { - Math_StepToF(&this->actor.speedXZ, 1.3f, 0.03f); - } - - if (this->unk_194 != 0) { - this->unk_194--; - } - - if (this->actor.bgCheckFlags & 8) { - this->unk_196 = this->actor.wallYaw; - } - - if (Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_196, 2, 0x200, 0x80) == 0) { - this->unk_196 = this->actor.yawTowardsPlayer + 0x8000; - } - - if (this->actor.home.pos.y < this->actor.world.pos.y) { - if (this->actor.home.pos.y < this->actor.floorHeight) { - func_80B32434(this); - } else { - this->actor.world.pos.y = this->actor.home.pos.y; - } - } - - if (this->unk_194 == 0) { - func_80B32384(this); - } -} - -void func_80B331CC(EnWeiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - - if (this->unk_194 != 0) { - this->unk_194--; - } - - if (this->actor.bgCheckFlags & 8) { - this->unk_196 = this->actor.wallYaw; - } else { - this->unk_196 = this->actor.yawTowardsPlayer + 0x8000; - } - - Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_196, 0x38E); - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x200); - this->actor.shape.rot.z = sinf(this->unk_194 * (M_PI / 5)) * 5120.0f; - - if (this->unk_194 == 0) { - this->actor.shape.rot.z = 0; - this->collider.base.acFlags |= AC_ON; - func_80B32384(this); - } -} - -void func_80B332B4(EnWeiyer* this, GlobalContext* globalCtx) { - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0x400); - this->actor.shape.rot.z += 0x1000; - - if (this->unk_194 != 0) { - this->unk_194--; - } - - if ((this->unk_194 == 0) || (this->actor.bgCheckFlags & 0x10)) { - func_80B327B0(this); - } -} - -void func_80B33338(EnWeiyer* this, GlobalContext* globalCtx) { - this->actor.shape.shadowAlpha = CLAMP_MIN((s16)(this->actor.shape.shadowAlpha - 5), 0); - this->actor.world.pos.y -= 2.0f; - - if (this->actor.shape.shadowAlpha == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); - Actor_Kill(&this->actor); - } -} - -void func_80B333B8(EnWeiyer* this, GlobalContext* globalCtx) { - if (this->unk_194 != 0) { - this->unk_194--; - } - - Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x200); - Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x200); - SkelAnime_Update(&this->skelAnime); - - if (this->actor.home.pos.y < this->actor.floorHeight) { - if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_FLUTTER); - } - - if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_GND); - } - } - - if (this->unk_194 == 0) { - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - this->collider.dim.height = sCylinderInit.dim.height; - func_80B32384(this); - } -} - -void func_80B3349C(EnWeiyer* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 phi_a1; - s32 phi_a0; - - SkelAnime_Update(&this->skelAnime); - - phi_a0 = ((this->actor.home.pos.y + 20.0f) <= player->actor.world.pos.y); - - if (this->unk_194 == -1) { - if (phi_a0 || (this->collider.base.atFlags & AT_HIT)) { - func_80B32538(this); - } else if (this->actor.yDistToWater < 0.0f) { - this->unk_194 = 10; - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 1, 400); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_JUMP); - } - } else { - if (phi_a0 || (this->collider.base.atFlags & AT_HIT)) { - this->unk_194 = 0; - } else if (this->unk_194 != 0) { - this->unk_194--; - } - - if (this->unk_194 == 0) { - phi_a1 = 0x1800; - } else { - phi_a1 = func_80B32DEC(this, globalCtx); - phi_a1 = CLAMP_MIN(phi_a1, 0); - } - - if (this->actor.shape.rot.x < phi_a1) { - Math_ScaledStepToS(&this->actor.shape.rot.x, phi_a1, 0x400); - } - - if (this->actor.bgCheckFlags & 1) { - func_80B32434(this); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.shape.rot.x > 0)) { - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 1, 400); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OCTAROCK_SINK); - func_80B32538(this); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 8, 0x100, 0x80); - } - } -} - -void func_80B3368C(EnWeiyer* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Actor_SetDropFlag(&this->actor, &this->collider.info, 1); - - if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) { - if (this->actor.colChkInfo.damageEffect == 1) { - if (this->actionFunc != func_80B333B8) { - func_80B32660(this); - } - } else if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_DEAD); - this->actor.flags &= ~ACTOR_FLAG_0; - func_80B32724(this); - } else { - func_80B325A0(this); - } - } - } -} - -void EnWeiyer_Update(Actor* thisx, GlobalContext* globalCtx) { - EnWeiyer* this = (EnWeiyer*)thisx; - s32 pad; - - this->actor.home.pos.y = this->actor.yDistToWater + this->actor.world.pos.y - 5.0f; - func_80B3368C(this, globalCtx); - this->actionFunc(this, globalCtx); - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.world.rot.x = -this->actor.shape.rot.x; - - if ((this->actor.world.rot.x == 0) || (this->actionFunc == func_80B333B8)) { - Actor_MoveForward(&this->actor); - } else { - func_8002D97C(&this->actor); - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 30.0f, 45.0f, 7); - Actor_SetFocus(&this->actor, 0.0f); - - if (this->collider.base.atFlags & AT_HIT) { - this->collider.base.atFlags &= ~(AT_ON | AT_HIT); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EIER_ATTACK); - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - - if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - if (this->collider.base.acFlags & AT_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -s32 EnWeiyer_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - if (limbIndex == 1) { - pos->z += 2000.0f; - } - - return 0; -} - -void EnWeiyer_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnWeiyer* this = (EnWeiyer*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_weiyer.c", 1193); - - if (this->actionFunc != func_80B33338) { - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnWeiyer_OverrideLimbDraw, NULL, &this->actor, POLY_OPA_DISP); - } else { - func_80093D84(globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->actor.shape.shadowAlpha); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnWeiyer_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_weiyer.c", 1240); -} diff --git a/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.cpp b/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.cpp new file mode 100644 index 000000000..5d9a2a642 --- /dev/null +++ b/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.cpp @@ -0,0 +1,662 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WEIYER_Z_EN_WEIYER_C +#include "actor_common.h" +/* + * File: z_en_weiyer.c + * Overlay: ovl_En_Weiyer + * Description: Stinger (Water) + */ + +#include "z_en_weiyer.h" +#include "objects/object_ei/object_ei.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) + +void EnWeiyer_Init(Actor* thisx, GlobalContext* globalCtx); +void EnWeiyer_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnWeiyer_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWeiyer_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B32804(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B328E8(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B32C2C(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B32D30(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B32E34(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B33018(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B331CC(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B333B8(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B332B4(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B33338(EnWeiyer* pthis, GlobalContext* globalCtx); +void func_80B3349C(EnWeiyer* pthis, GlobalContext* globalCtx); + +ActorInit En_Weiyer_InitVars = { + ACTOR_EN_WEIYER, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_EI, + sizeof(EnWeiyer), + (ActorFunc)EnWeiyer_Init, + (ActorFunc)EnWeiyer_Destroy, + (ActorFunc)EnWeiyer_Update, + (ActorFunc)EnWeiyer_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 16, 10, -6, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 2, 45, 15, 100 }; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, 0x1), + /* Deku stick */ DMG_ENTRY(2, 0x0), + /* Slingshot */ DMG_ENTRY(1, 0x0), + /* Explosive */ DMG_ENTRY(2, 0x0), + /* Boomerang */ DMG_ENTRY(0, 0x1), + /* Normal arrow */ DMG_ENTRY(2, 0x0), + /* Hammer swing */ DMG_ENTRY(2, 0x0), + /* Hookshot */ DMG_ENTRY(2, 0x0), + /* Kokiri sword */ DMG_ENTRY(1, 0x0), + /* Master sword */ DMG_ENTRY(2, 0x0), + /* Giant's Knife */ DMG_ENTRY(4, 0x0), + /* Fire arrow */ DMG_ENTRY(2, 0x0), + /* Ice arrow */ DMG_ENTRY(2, 0x0), + /* Light arrow */ DMG_ENTRY(2, 0x0), + /* Unk arrow 1 */ DMG_ENTRY(2, 0x0), + /* Unk arrow 2 */ DMG_ENTRY(0, 0x0), + /* Unk arrow 3 */ DMG_ENTRY(0, 0x0), + /* Fire magic */ DMG_ENTRY(0, 0x0), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0x0), + /* Giant spin */ DMG_ENTRY(4, 0x0), + /* Master spin */ DMG_ENTRY(2, 0x0), + /* Kokiri jump */ DMG_ENTRY(2, 0x0), + /* Giant jump */ DMG_ENTRY(8, 0x0), + /* Master jump */ DMG_ENTRY(4, 0x0), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), +}; +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x19, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 3, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_STOP), +}; + +void EnWeiyer_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWeiyer* pthis = (EnWeiyer*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + ActorShape_Init(&pthis->actor.shape, 1000.0f, ActorShadow_DrawCircle, 65.0f); + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gStingerSkel, &gStingerIdleAnim, pthis->jointTable, pthis->morphTable, + 19); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + pthis->actionFunc = func_80B32804; +} + +void EnWeiyer_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWeiyer* pthis = (EnWeiyer*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80B32384(EnWeiyer* pthis) { + pthis->unk_196 = pthis->actor.shape.rot.y; + pthis->unk_27C = (cosf(-M_PI / 8) * 3.0f) + pthis->actor.world.pos.y; + Animation_MorphToLoop(&pthis->skelAnime, &gStingerHitAnim, -5.0f); + pthis->unk_194 = 30; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 2.5f); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->unk_280 = pthis->actor.floorHeight; + pthis->actionFunc = func_80B328E8; +} + +void func_80B32434(EnWeiyer* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gStingerHitAnim, -5.0f); + pthis->collider.base.atFlags |= AT_ON; + pthis->unk_194 = 0; + pthis->actor.speedXZ = 5.0f; + pthis->actionFunc = func_80B32C2C; +} + +void func_80B32494(EnWeiyer* pthis) { + Animation_Change(&pthis->skelAnime, &gStingerPopOutAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); + pthis->unk_194 = 40; + pthis->collider.base.atFlags |= AT_ON; + pthis->actionFunc = func_80B32D30; +} + +void func_80B32508(EnWeiyer* pthis) { + pthis->unk_194 = 200; + pthis->collider.base.atFlags |= AT_ON; + pthis->skelAnime.playSpeed = 3.0f; + pthis->actionFunc = func_80B32E34; +} + +void func_80B32538(EnWeiyer* pthis) { + pthis->unk_194 = 200; + pthis->unk_196 = pthis->actor.yawTowardsPlayer + 0x8000; + pthis->unk_27C = pthis->actor.world.pos.y; + pthis->actor.speedXZ = CLAMP_MAX(pthis->actor.speedXZ, 4.0f); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->skelAnime.playSpeed = 1.0f; + pthis->actionFunc = func_80B33018; +} + +void func_80B325A0(EnWeiyer* pthis) { + Animation_Change(&pthis->skelAnime, &gStingerHitAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -3.0f); + pthis->unk_194 = 40; + pthis->collider.base.atFlags &= ~AT_ON; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 3.0f; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0, 0x28); + pthis->collider.dim.height = sCylinderInit.dim.height; + pthis->actionFunc = func_80B331CC; +} + +void func_80B32660(EnWeiyer* pthis) { + Animation_Change(&pthis->skelAnime, &gStingerPopOutAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); + pthis->unk_194 = 80; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.gravity = -1.0f; + pthis->collider.dim.height = sCylinderInit.dim.height + 15; + Actor_SetColorFilter(&pthis->actor, 0, 0xC8, 0, 0x50); + pthis->collider.base.atFlags &= ~AT_ON; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->actionFunc = func_80B333B8; +} + +void func_80B32724(EnWeiyer* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gStingerHitAnim, -5.0f); + pthis->unk_194 = 20; + Actor_SetColorFilter(&pthis->actor, 0x4000, 0xC8, 0, 0x28); + pthis->collider.base.atFlags &= ~AT_ON; + pthis->collider.base.acFlags &= ~AC_ON; + pthis->actor.speedXZ = 3.0f; + pthis->actionFunc = func_80B332B4; +} + +void func_80B327B0(EnWeiyer* pthis) { + pthis->actor.colorFilterParams |= 0x2000; + pthis->actor.speedXZ = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actionFunc = func_80B33338; +} + +void func_80B327D8(EnWeiyer* pthis) { + pthis->actor.shape.rot.x = -0x2000; + pthis->unk_194 = -1; + pthis->actor.speedXZ = 5.0f; + pthis->actionFunc = func_80B3349C; +} + +void func_80B32804(EnWeiyer* pthis, GlobalContext* globalCtx) { + WaterBox* waterBox; + s32 bgId; + + pthis->actor.world.pos.y += 0.5f; + pthis->actor.floorHeight = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->actor.floorPoly, &bgId, + &pthis->actor, &pthis->actor.world.pos); + + if (!WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, + &pthis->actor.home.pos.y, &waterBox) || + ((pthis->actor.home.pos.y - 5.0f) <= pthis->actor.floorHeight)) { + Actor_Kill(&pthis->actor); + } else { + pthis->actor.home.pos.y -= 5.0f; + pthis->actor.world.pos.y = (pthis->actor.home.pos.y + pthis->actor.floorHeight) / 2.0f; + func_80B32384(pthis); + } +} + +void func_80B328E8(EnWeiyer* pthis, GlobalContext* globalCtx) { + s32 sp34; + f32 curFrame; + + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x800); + sp34 = Animation_OnFrame(&pthis->skelAnime, 0.0f); + curFrame = pthis->skelAnime.curFrame; + Math_StepToF(&pthis->unk_27C, pthis->unk_280, 0.5f); + pthis->actor.world.pos.y = pthis->unk_27C - cosf((curFrame - 5.0f) * (M_PI / 40)) * 3.0f; + + if (curFrame <= 45.0f) { + Math_StepToF(&pthis->actor.speedXZ, 1.0f, 0.03f); + } else { + Math_StepToF(&pthis->actor.speedXZ, 1.3f, 0.03f); + } + + if (pthis->actor.bgCheckFlags & 8) { + pthis->unk_196 = pthis->actor.wallYaw; + pthis->unk_194 = 30; + } + + if (Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->unk_196, 182)) { + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if (pthis->unk_194 == 0) { + pthis->unk_196 = + Rand_S16Offset(0x2000, 0x2000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1) + pthis->actor.shape.rot.y; + pthis->unk_194 = 30; + + if (Rand_ZeroOne() < 0.3333f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_CRY); + } + } + } + + if (pthis->actor.home.pos.y < pthis->actor.world.pos.y) { + if (pthis->actor.home.pos.y < pthis->actor.floorHeight) { + func_80B32434(pthis); + } else { + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + pthis->unk_280 = + Rand_ZeroOne() * ((pthis->actor.home.pos.y - pthis->actor.floorHeight) / 2.0f) + pthis->actor.floorHeight; + } + } else { + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actor.bgCheckFlags & 1) { + pthis->unk_280 = + pthis->actor.home.pos.y - Rand_ZeroOne() * ((pthis->actor.home.pos.y - pthis->actor.floorHeight) / 2.0f); + } else if (sp34 && (Rand_ZeroOne() < 0.1f)) { + pthis->unk_280 = + Rand_ZeroOne() * (pthis->actor.home.pos.y - pthis->actor.floorHeight) + pthis->actor.floorHeight; + } + + if ((pthis->actor.xzDistToPlayer < 400.0f) && (fabsf(pthis->actor.yDistToPlayer) < 250.0f) && + (player->actor.world.pos.y < (pthis->actor.home.pos.y + 20.0f))) { + func_80B32508(pthis); + } + } +} + +void func_80B32C2C(EnWeiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_194 == 0) { + if (Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x4000, 0x800)) { + pthis->actor.shape.rot.z = 0; + pthis->actor.shape.rot.y += 0x8000; + pthis->unk_194 = 1; + } else { + pthis->actor.shape.rot.z = pthis->actor.shape.rot.x * 2; + } + } else { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0x1800, 0x800); + + if (pthis->actor.world.pos.y < pthis->actor.home.pos.y) { + if (pthis->actor.shape.rot.x > 0) { + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, NULL, NULL, 1, 400); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_SINK); + } + + func_80B32538(pthis); + } else if (pthis->actor.bgCheckFlags & 1) { + func_80B32494(pthis); + } + } +} + +void func_80B32D30(EnWeiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_FLUTTER); + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x800); + Math_StepToF(&pthis->actor.speedXZ, 0.0f, 1.0f); + + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if (pthis->unk_194 == 0) { + func_80B32434(pthis); + } else if (pthis->actor.world.pos.y < pthis->actor.home.pos.y) { + func_80B32384(pthis); + } +} + +s16 func_80B32DEC(EnWeiyer* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f vec; + + vec.x = player->actor.world.pos.x; + vec.y = player->actor.world.pos.y + 20.0f; + vec.z = player->actor.world.pos.z; + + return Actor_WorldPitchTowardPoint(&pthis->actor, &vec); +} + +void func_80B32E34(EnWeiyer* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if ((pthis->unk_194 == 0) || ((pthis->actor.home.pos.y + 20.0f) <= player->actor.world.pos.y) || + (pthis->collider.base.atFlags & AT_HIT)) { + func_80B32538(pthis); + } else { + if (Actor_IsFacingPlayer(&pthis->actor, 0x2800)) { + Math_StepToF(&pthis->actor.speedXZ, 4.0f, 0.2f); + } else { + Math_StepToF(&pthis->actor.speedXZ, 1.3f, 0.2f); + } + + if (pthis->actor.home.pos.y < pthis->actor.world.pos.y) { + if (pthis->actor.home.pos.y < pthis->actor.floorHeight) { + pthis->actor.shape.rot.x = 0; + func_80B32434(pthis); + return; + } + + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0x1000, 2, 0x100, 0x40); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.x, func_80B32DEC(pthis, globalCtx), 2, 0x100, 0x40); + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 2, 0x200, 0x80); + + if ((player->actor.yDistToWater < 50.0f) && (pthis->actor.yDistToWater < 20.0f) && + Actor_IsFacingPlayer(&pthis->actor, 0x2000)) { + func_80B327D8(pthis); + } + } +} + +void func_80B33018(EnWeiyer* pthis, GlobalContext* globalCtx) { + f32 curFrame; + + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x800); + curFrame = pthis->skelAnime.curFrame; + Math_StepToF(&pthis->unk_27C, (pthis->actor.home.pos.y - pthis->actor.floorHeight) / 4.0f + pthis->actor.floorHeight, + 1.0f); + pthis->actor.world.pos.y = pthis->unk_27C - cosf((curFrame - 5.0f) * (M_PI / 40)) * 3.0f; + + if (curFrame <= 45.0f) { + Math_StepToF(&pthis->actor.speedXZ, 1.0f, 0.03f); + } else { + Math_StepToF(&pthis->actor.speedXZ, 1.3f, 0.03f); + } + + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if (pthis->actor.bgCheckFlags & 8) { + pthis->unk_196 = pthis->actor.wallYaw; + } + + if (Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->unk_196, 2, 0x200, 0x80) == 0) { + pthis->unk_196 = pthis->actor.yawTowardsPlayer + 0x8000; + } + + if (pthis->actor.home.pos.y < pthis->actor.world.pos.y) { + if (pthis->actor.home.pos.y < pthis->actor.floorHeight) { + func_80B32434(pthis); + } else { + pthis->actor.world.pos.y = pthis->actor.home.pos.y; + } + } + + if (pthis->unk_194 == 0) { + func_80B32384(pthis); + } +} + +void func_80B331CC(EnWeiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if (pthis->actor.bgCheckFlags & 8) { + pthis->unk_196 = pthis->actor.wallYaw; + } else { + pthis->unk_196 = pthis->actor.yawTowardsPlayer + 0x8000; + } + + Math_ScaledStepToS(&pthis->actor.world.rot.y, pthis->unk_196, 0x38E); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x200); + pthis->actor.shape.rot.z = sinf(pthis->unk_194 * (M_PI / 5)) * 5120.0f; + + if (pthis->unk_194 == 0) { + pthis->actor.shape.rot.z = 0; + pthis->collider.base.acFlags |= AC_ON; + func_80B32384(pthis); + } +} + +void func_80B332B4(EnWeiyer* pthis, GlobalContext* globalCtx) { + SkelAnime_Update(&pthis->skelAnime); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, -0x4000, 0x400); + pthis->actor.shape.rot.z += 0x1000; + + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if ((pthis->unk_194 == 0) || (pthis->actor.bgCheckFlags & 0x10)) { + func_80B327B0(pthis); + } +} + +void func_80B33338(EnWeiyer* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.shadowAlpha = CLAMP_MIN((s16)(pthis->actor.shape.shadowAlpha - 5), 0); + pthis->actor.world.pos.y -= 2.0f; + + if (pthis->actor.shape.shadowAlpha == 0) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xE0); + Actor_Kill(&pthis->actor); + } +} + +void func_80B333B8(EnWeiyer* pthis, GlobalContext* globalCtx) { + if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.x, 0, 0x200); + Math_ScaledStepToS(&pthis->actor.shape.rot.z, 0, 0x200); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.home.pos.y < pthis->actor.floorHeight) { + if (Animation_OnFrame(&pthis->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_FLUTTER); + } + + if (pthis->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_DODO_M_GND); + } + } + + if (pthis->unk_194 == 0) { + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->collider.dim.height = sCylinderInit.dim.height; + func_80B32384(pthis); + } +} + +void func_80B3349C(EnWeiyer* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_a1; + s32 phi_a0; + + SkelAnime_Update(&pthis->skelAnime); + + phi_a0 = ((pthis->actor.home.pos.y + 20.0f) <= player->actor.world.pos.y); + + if (pthis->unk_194 == -1) { + if (phi_a0 || (pthis->collider.base.atFlags & AT_HIT)) { + func_80B32538(pthis); + } else if (pthis->actor.yDistToWater < 0.0f) { + pthis->unk_194 = 10; + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, NULL, NULL, 1, 400); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_JUMP); + } + } else { + if (phi_a0 || (pthis->collider.base.atFlags & AT_HIT)) { + pthis->unk_194 = 0; + } else if (pthis->unk_194 != 0) { + pthis->unk_194--; + } + + if (pthis->unk_194 == 0) { + phi_a1 = 0x1800; + } else { + phi_a1 = func_80B32DEC(pthis, globalCtx); + phi_a1 = CLAMP_MIN(phi_a1, 0); + } + + if (pthis->actor.shape.rot.x < phi_a1) { + Math_ScaledStepToS(&pthis->actor.shape.rot.x, phi_a1, 0x400); + } + + if (pthis->actor.bgCheckFlags & 1) { + func_80B32434(pthis); + } else if ((pthis->actor.bgCheckFlags & 0x20) && (pthis->actor.shape.rot.x > 0)) { + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, NULL, NULL, 1, 400); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_OCTAROCK_SINK); + func_80B32538(pthis); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 8, 0x100, 0x80); + } + } +} + +void func_80B3368C(EnWeiyer* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&pthis->actor, &pthis->collider.info, 1); + + if ((pthis->actor.colChkInfo.damageEffect != 0) || (pthis->actor.colChkInfo.damage != 0)) { + if (pthis->actor.colChkInfo.damageEffect == 1) { + if (pthis->actionFunc != func_80B333B8) { + func_80B32660(pthis); + } + } else if (Actor_ApplyDamage(&pthis->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_DEAD); + pthis->actor.flags &= ~ACTOR_FLAG_0; + func_80B32724(pthis); + } else { + func_80B325A0(pthis); + } + } + } +} + +void EnWeiyer_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWeiyer* pthis = (EnWeiyer*)thisx; + s32 pad; + + pthis->actor.home.pos.y = pthis->actor.yDistToWater + pthis->actor.world.pos.y - 5.0f; + func_80B3368C(pthis, globalCtx); + pthis->actionFunc(pthis, globalCtx); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actor.world.rot.x = -pthis->actor.shape.rot.x; + + if ((pthis->actor.world.rot.x == 0) || (pthis->actionFunc == func_80B333B8)) { + Actor_MoveForward(&pthis->actor); + } else { + func_8002D97C(&pthis->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 30.0f, 45.0f, 7); + Actor_SetFocus(&pthis->actor, 0.0f); + + if (pthis->collider.base.atFlags & AT_HIT) { + pthis->collider.base.atFlags &= ~(AT_ON | AT_HIT); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_EIER_ATTACK); + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + if (pthis->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + if (pthis->collider.base.acFlags & AT_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +s32 EnWeiyer_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + if (limbIndex == 1) { + pos->z += 2000.0f; + } + + return 0; +} + +void EnWeiyer_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWeiyer* pthis = (EnWeiyer*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_weiyer.c", 1193); + + if (pthis->actionFunc != func_80B33338) { + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnWeiyer_OverrideLimbDraw, NULL, &pthis->actor, POLY_OPA_DISP); + } else { + func_80093D84(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, pthis->actor.shape.shadowAlpha); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnWeiyer_OverrideLimbDraw, NULL, &pthis->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_weiyer.c", 1240); +} diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c deleted file mode 100644 index 285bd6d8c..000000000 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ /dev/null @@ -1,1503 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WF_Z_EN_WF_C -#include "actor_common.h" -/* - * File: z_en_wf.c - * Overlay: ovl_En_Wf - * Description: Wolfos (Normal and White) - */ - -#include "z_en_wf.h" -#include "vt.h" -#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" -#include "objects/object_wf/object_wf.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnWf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnWf_SetupWaitToAppear(EnWf* this); -void EnWf_WaitToAppear(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupWait(EnWf* this); -void EnWf_Wait(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupRunAtPlayer(EnWf* this, GlobalContext* globalCtx); -void EnWf_RunAtPlayer(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupSearchForPlayer(EnWf* this); -void EnWf_SearchForPlayer(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupRunAroundPlayer(EnWf* this); -void EnWf_RunAroundPlayer(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupSlash(EnWf* this); -void EnWf_Slash(EnWf* this, GlobalContext* globalCtx); -void EnWf_RecoilFromBlockedSlash(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupBackflipAway(EnWf* this); -void EnWf_BackflipAway(EnWf* this, GlobalContext* globalCtx); -void EnWf_Stunned(EnWf* this, GlobalContext* globalCtx); -void EnWf_Damaged(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupSomersaultAndAttack(EnWf* this); -void EnWf_SomersaultAndAttack(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupBlocking(EnWf* this); -void EnWf_Blocking(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupSidestep(EnWf* this, GlobalContext* globalCtx); -void EnWf_Sidestep(EnWf* this, GlobalContext* globalCtx); -void EnWf_SetupDie(EnWf* this); -void EnWf_Die(EnWf* this, GlobalContext* globalCtx); -s32 EnWf_DodgeRanged(GlobalContext* globalCtx, EnWf* this); - -static ColliderJntSphElementInit sJntSphItemsInit[4] = { - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { WOLFOS_LIMB_FRONT_RIGHT_CLAW, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { WOLFOS_LIMB_FRONT_LEFT_CLAW, { { 0, 0, 0 }, 15 }, 100 }, - }, - { - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC1FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { WOLFOS_LIMB_HEAD, { { 800, 0, 0 }, 25 }, 100 }, - }, - { - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFC1FFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON | BUMP_HOOKABLE, - OCELEM_ON, - }, - { WOLFOS_LIMB_THORAX, { { 0, 0, 0 }, 30 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { - { - COLTYPE_METAL, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphItemsInit), - sJntSphItemsInit, -}; - -static ColliderCylinderInit sBodyCylinderInit = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 20, 50, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sTailCylinderInit = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 15, 20, -15, { 0, 0, 0 } }, -}; - -typedef enum { - /* 0 */ ENWF_DMGEFF_NONE, - /* 1 */ ENWF_DMGEFF_STUN, - /* 6 */ ENWF_DMGEFF_ICE_MAGIC = 6, - /* 13 */ ENWF_DMGEFF_LIGHT_MAGIC = 13, - /* 14 */ ENWF_DMGEFF_FIRE, - /* 15 */ ENWF_DMGEFF_UNDEF // used like STUN in the code, but not in the table -} EnWfDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, ENWF_DMGEFF_STUN), - /* Deku stick */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(1, ENWF_DMGEFF_NONE), - /* Explosive */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(0, ENWF_DMGEFF_STUN), - /* Normal arrow */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Hookshot */ DMG_ENTRY(0, ENWF_DMGEFF_STUN), - /* Kokiri sword */ DMG_ENTRY(1, ENWF_DMGEFF_NONE), - /* Master sword */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Giant's Knife */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), - /* Fire arrow */ DMG_ENTRY(4, ENWF_DMGEFF_FIRE), - /* Ice arrow */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Light arrow */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Unk arrow 1 */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Unk arrow 2 */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Unk arrow 3 */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Fire magic */ DMG_ENTRY(4, ENWF_DMGEFF_FIRE), - /* Ice magic */ DMG_ENTRY(0, ENWF_DMGEFF_ICE_MAGIC), - /* Light magic */ DMG_ENTRY(3, ENWF_DMGEFF_LIGHT_MAGIC), - /* Shield */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, ENWF_DMGEFF_NONE), - /* Giant spin */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), - /* Master spin */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Kokiri jump */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), - /* Giant jump */ DMG_ENTRY(8, ENWF_DMGEFF_NONE), - /* Master jump */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), - /* Unknown 1 */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), - /* Unknown 2 */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), -}; - -const ActorInit En_Wf_InitVars = { - ACTOR_EN_WF, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_WF, - sizeof(EnWf), - (ActorFunc)EnWf_Init, - (ActorFunc)EnWf_Destroy, - (ActorFunc)EnWf_Update, - (ActorFunc)EnWf_Draw, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -3000, ICHAIN_STOP), -}; - -void EnWf_SetupAction(EnWf* this, EnWfActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnWf* this = (EnWf*)thisx; - - Actor_ProcessInitChain(thisx, sInitChain); - thisx->colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - thisx->focus.pos = thisx->world.pos; - thisx->colChkInfo.mass = MASS_HEAVY; - thisx->colChkInfo.health = 8; - thisx->colChkInfo.cylRadius = 50; - thisx->colChkInfo.cylHeight = 100; - this->switchFlag = (thisx->params >> 8) & 0xFF; - thisx->params &= 0xFF; - this->eyeIndex = 0; - this->unk_2F4 = 10.0f; // Set and not used - - Collider_InitJntSph(globalCtx, &this->colliderSpheres); - Collider_SetJntSph(globalCtx, &this->colliderSpheres, thisx, &sJntSphInit, this->colliderSpheresElements); - Collider_InitCylinder(globalCtx, &this->colliderCylinderBody); - Collider_SetCylinder(globalCtx, &this->colliderCylinderBody, thisx, &sBodyCylinderInit); - Collider_InitCylinder(globalCtx, &this->colliderCylinderTail); - Collider_SetCylinder(globalCtx, &this->colliderCylinderTail, thisx, &sTailCylinderInit); - - if (thisx->params == WOLFOS_NORMAL) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, - this->morphTable, WOLFOS_LIMB_MAX); - Actor_SetScale(thisx, 0.0075f); - thisx->naviEnemyId = 0x4C; // Wolfos - } else { // WOLFOS_WHITE - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, - this->morphTable, WOLFOS_LIMB_MAX); - Actor_SetScale(thisx, 0.01f); - this->colliderSpheres.elements[0].info.toucher.damage = this->colliderSpheres.elements[1].info.toucher.damage = - 8; - thisx->naviEnemyId = 0x57; // White Wolfos - } - - EnWf_SetupWaitToAppear(this); - - if ((this->switchFlag != 0xFF) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - Actor_Kill(thisx); - } -} - -void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnWf* this = (EnWf*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->colliderSpheres); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinderBody); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinderTail); - - if ((this->actor.params != WOLFOS_NORMAL) && (this->switchFlag != 0xFF)) { - func_800F5B58(); - } - - if (this->actor.parent != NULL) { - EnEncount1* parent = (EnEncount1*)this->actor.parent; - - if (parent->actor.update != NULL) { - if (parent->curNumSpawn > 0) { - parent->curNumSpawn--; - } - - osSyncPrintf("\n\n"); - // "☆☆☆☆☆ Number of concurrent events ☆☆☆☆☆" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 同時発生数 ☆☆☆☆☆%d\n" VT_RST, parent->curNumSpawn); - osSyncPrintf("\n\n"); - } - } -} - -s32 EnWf_ChangeAction(GlobalContext* globalCtx, EnWf* this, s16 mustChoose) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 wallYawDiff; - s16 playerYawDiff; - Actor* explosive; - - wallYawDiff = this->actor.wallYaw - this->actor.shape.rot.y; - wallYawDiff = ABS(wallYawDiff); - playerYawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - playerYawDiff = ABS(playerYawDiff); - - if (func_800354B4(globalCtx, &this->actor, 100.0f, 0x2710, 0x2EE0, this->actor.shape.rot.y)) { - if (player->swordAnimation == 0x11) { - EnWf_SetupBlocking(this); - return true; - } - - if ((globalCtx->gameplayFrames % 2) != 0) { - EnWf_SetupBlocking(this); - return true; - } - } - - if (func_800354B4(globalCtx, &this->actor, 100.0f, 0x5DC0, 0x2AA8, this->actor.shape.rot.y)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if ((this->actor.bgCheckFlags & 8) && (ABS(wallYawDiff) < 0x2EE0) && (this->actor.xzDistToPlayer < 120.0f)) { - EnWf_SetupSomersaultAndAttack(this); - return true; - } else if (player->swordAnimation == 0x11) { - EnWf_SetupBlocking(this); - return true; - } else if ((this->actor.xzDistToPlayer < 80.0f) && (globalCtx->gameplayFrames % 2) != 0) { - EnWf_SetupBlocking(this); - return true; - } else { - EnWf_SetupBackflipAway(this); - return true; - } - } - - explosive = Actor_FindNearby(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVE, 80.0f); - - if (explosive != NULL) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (((this->actor.bgCheckFlags & 8) && (wallYawDiff < 0x2EE0)) || (explosive->id == ACTOR_EN_BOM_CHU)) { - if ((explosive->id == ACTOR_EN_BOM_CHU) && (Actor_WorldDistXYZToActor(&this->actor, explosive) < 80.0f) && - (s16)((this->actor.shape.rot.y - explosive->world.rot.y) + 0x8000) < 0x3E80) { - EnWf_SetupSomersaultAndAttack(this); - return true; - } else { - EnWf_SetupSidestep(this, globalCtx); - return true; - } - } else { - EnWf_SetupBackflipAway(this); - return true; - } - } - - if (mustChoose) { - s16 playerFacingAngleDiff; - - if (playerYawDiff >= 0x1B58) { - EnWf_SetupSidestep(this, globalCtx); - return true; - } - - playerFacingAngleDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - (((globalCtx->gameplayFrames % 8) != 0) || (ABS(playerFacingAngleDiff) < 0x38E0))) { - EnWf_SetupSlash(this); - return true; - } - - EnWf_SetupRunAroundPlayer(this); - return true; - } - return false; -} - -void EnWf_SetupWaitToAppear(EnWf* this) { - Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, 0.0f); - this->actor.world.pos.y = this->actor.home.pos.y - 5.0f; - this->actionTimer = 20; - this->unk_300 = false; - this->action = WOLFOS_ACTION_WAIT_TO_APPEAR; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.scale.y = 0.0f; - this->actor.gravity = 0.0f; - EnWf_SetupAction(this, EnWf_WaitToAppear); -} - -void EnWf_WaitToAppear(EnWf* this, GlobalContext* globalCtx) { - if (this->actionTimer >= 6) { - this->actor.world.pos.y = this->actor.home.pos.y - 5.0f; - - if (this->actor.xzDistToPlayer < 240.0f) { - this->actionTimer = 5; - this->actor.flags |= ACTOR_FLAG_0; - - if ((this->actor.params != WOLFOS_NORMAL) && (this->switchFlag != 0xFF)) { - func_800F5ACC(0x38); // Mini-Boss Battle Theme - } - } - } else if (this->actionTimer != 0) { - this->actor.scale.y += this->actor.scale.x * 0.2f; - this->actor.world.pos.y += 0.5f; - Math_SmoothStepToF(&this->actor.shape.shadowScale, 70.0f, 1.0f, 14.0f, 0.0f); - this->actionTimer--; - - if (this->actionTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); - } - } else { // actionTimer == 0 - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.scale.y = this->actor.scale.x; - this->actor.gravity = -2.0f; - EnWf_SetupWait(this); - } - } -} - -void EnWf_SetupWait(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); - this->action = WOLFOS_ACTION_WAIT; - this->actionTimer = (Rand_ZeroOne() * 10.0f) + 2.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnWf_SetupAction(this, EnWf_Wait); -} - -void EnWf_Wait(EnWf* this, GlobalContext* globalCtx) { - Player* player; - s32 pad; - s16 angle; - - player = GET_PLAYER(globalCtx); - SkelAnime_Update(&this->skelAnime); - - if (this->unk_2E2 != 0) { - angle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_4D4.y; - - if (ABS(angle) > 0x2000) { - this->unk_2E2--; - return; - } - - this->unk_2E2 = 0; - } - - angle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - angle = ABS(angle); - - if (!EnWf_DodgeRanged(globalCtx, this)) { - // Only use of unk_2E0: never not zero, so this if block never runs - if (this->unk_2E0 != 0) { - this->unk_2E0--; - - if (angle >= 0x1FFE) { - return; - } - this->unk_2E0 = 0; - } else { - if (EnWf_ChangeAction(globalCtx, this, false)) { - return; - } - } - - angle = player->actor.shape.rot.y - this->actor.shape.rot.y; - angle = ABS(angle); - - if ((this->actor.xzDistToPlayer < 80.0f) && (player->swordState != 0) && (angle >= 0x1F40)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnWf_SetupRunAroundPlayer(this); - } else { - this->actionTimer--; - - if (this->actionTimer == 0) { - if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { - if (Rand_ZeroOne() > 0.3f) { - EnWf_SetupRunAtPlayer(this, globalCtx); - } else { - EnWf_SetupRunAroundPlayer(this); - } - } else { - EnWf_SetupSearchForPlayer(this); - } - if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); - } - } - } - } -} - -void EnWf_SetupRunAtPlayer(EnWf* this, GlobalContext* globalCtx) { - f32 lastFrame = Animation_GetLastFrame(&gWolfosRunningAnim); - - Animation_Change(&this->skelAnime, &gWolfosRunningAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); - this->action = WOLFOS_ACTION_RUN_AT_PLAYER; - EnWf_SetupAction(this, EnWf_RunAtPlayer); -} - -void EnWf_RunAtPlayer(EnWf* this, GlobalContext* globalCtx) { - s32 animPrevFrame; - s32 sp58; - s32 pad; - f32 baseRange = 0.0f; - s16 playerFacingAngleDiff; - Player* player = GET_PLAYER(globalCtx); - s32 playSpeed; - - if (!EnWf_DodgeRanged(globalCtx, this)) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x2EE, 0); - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - baseRange = 150.0f; - } - - if (this->actor.xzDistToPlayer <= (50.0f + baseRange)) { - Math_SmoothStepToF(&this->actor.speedXZ, -8.0f, 1.0f, 1.5f, 0.0f); - } else if ((65.0f + baseRange) < this->actor.xzDistToPlayer) { - Math_SmoothStepToF(&this->actor.speedXZ, 8.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 6.65f, 0.0f); - } - - this->skelAnime.playSpeed = this->actor.speedXZ * 0.175f; - playerFacingAngleDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - playerFacingAngleDiff = ABS(playerFacingAngleDiff); - - if ((this->actor.xzDistToPlayer < (150.0f + baseRange)) && (player->swordState != 0) && - (playerFacingAngleDiff >= 8000)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (Rand_ZeroOne() > 0.7f) { - EnWf_SetupRunAroundPlayer(this); - return; - } - } - - animPrevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - sp58 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); - - if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { - if (Rand_ZeroOne() > 0.5f) { - EnWf_SetupRunAroundPlayer(this); - } else { - EnWf_SetupWait(this); - } - } else if (this->actor.xzDistToPlayer < (90.0f + baseRange)) { - s16 temp_v1 = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && - ((Rand_ZeroOne() > 0.03f) || ((this->actor.xzDistToPlayer <= 80.0f) && (ABS(temp_v1) < 0x38E0)))) { - EnWf_SetupSlash(this); - } else if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { - EnWf_SetupBackflipAway(this); - } else { - EnWf_SetupRunAroundPlayer(this); - } - } - - if (!EnWf_ChangeAction(globalCtx, this, false)) { - if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); - } - if ((animPrevFrame != (s32)this->skelAnime.curFrame) && (sp58 <= 0) && ((playSpeed + animPrevFrame) > 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, 1); - } - } - } -} - -void EnWf_SetupSearchForPlayer(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosSidesteppingAnim, -4.0f); - this->action = WOLFOS_ACTION_SEARCH_FOR_PLAYER; - EnWf_SetupAction(this, EnWf_SearchForPlayer); -} - -void EnWf_SearchForPlayer(EnWf* this, GlobalContext* globalCtx) { - s16 yawDiff; - s16 phi_v1; - f32 phi_f2; - - if (!EnWf_DodgeRanged(globalCtx, this) && !EnWf_ChangeAction(globalCtx, this, false)) { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - phi_v1 = (yawDiff > 0) ? (yawDiff * 0.25f) + 2000.0f : (yawDiff * 0.25f) - 2000.0f; - this->actor.shape.rot.y += phi_v1; - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (yawDiff > 0) { - phi_f2 = phi_v1 * 0.5f; - phi_f2 = CLAMP_MAX(phi_f2, 1.0f); - } else { - phi_f2 = phi_v1 * 0.5f; - phi_f2 = CLAMP_MIN(phi_f2, -1.0f); - } - - this->skelAnime.playSpeed = -phi_f2; - SkelAnime_Update(&this->skelAnime); - - if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { - if (Rand_ZeroOne() > 0.8f) { - EnWf_SetupRunAroundPlayer(this); - } else { - EnWf_SetupRunAtPlayer(this, globalCtx); - } - } - - if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); - } - } -} - -void EnWf_SetupRunAroundPlayer(EnWf* this) { - f32 lastFrame = Animation_GetLastFrame(&gWolfosRunningAnim); - - Animation_Change(&this->skelAnime, &gWolfosRunningAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); - - if (Rand_ZeroOne() > 0.5f) { - this->runAngle = 16000; - } else { - this->runAngle = -16000; - } - - this->skelAnime.playSpeed = this->actor.speedXZ = 6.0f; - this->skelAnime.playSpeed *= 0.175f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionTimer = (Rand_ZeroOne() * 30.0f) + 30.0f; - this->action = WOLFOS_ACTION_RUN_AROUND_PLAYER; - this->runSpeed = 0.0f; - - EnWf_SetupAction(this, EnWf_RunAroundPlayer); -} - -void EnWf_RunAroundPlayer(EnWf* this, GlobalContext* globalCtx) { - s16 angle1; - s16 angle2; - s32 pad; - f32 baseRange = 0.0f; - s32 animPrevFrame; - s32 animFrameSpeedDiff; - s32 animSpeed; - Player* player = GET_PLAYER(globalCtx); - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->runAngle, 1, 4000, 1); - - if (!EnWf_DodgeRanged(globalCtx, this) && !EnWf_ChangeAction(globalCtx, this, false)) { - this->actor.world.rot.y = this->actor.shape.rot.y; - angle1 = player->actor.shape.rot.y + this->runAngle + 0x8000; - - // Actor_TestFloorInDirection is useless here (see comment below) - if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.shape.rot.y)) { - angle2 = (this->actor.bgCheckFlags & 8) - ? (this->actor.wallYaw - this->actor.yawTowardsPlayer) - this->runAngle - : 0; - - // This is probably meant to reverse direction if the edge of a floor is encountered, but does nothing - // unless bgCheckFlags & 8 anyway, since angle2 = 0 otherwise - if (ABS(angle2) > 0x2EE0) { - this->runAngle = -this->runAngle; - } - } - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - baseRange = 150.0f; - } - - if (this->actor.xzDistToPlayer <= (60.0f + baseRange)) { - Math_SmoothStepToF(&this->runSpeed, -4.0f, 1.0f, 1.5f, 0.0f); - } else if ((80.0f + baseRange) < this->actor.xzDistToPlayer) { - Math_SmoothStepToF(&this->runSpeed, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->runSpeed, 0.0f, 1.0f, 6.65f, 0.0f); - } - - if (this->runSpeed != 0.0f) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->runSpeed; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->runSpeed; - } - - if (ABS(this->runSpeed) < ABS(this->actor.speedXZ)) { - this->skelAnime.playSpeed = this->actor.speedXZ * 0.175f; - } else { - this->skelAnime.playSpeed = this->runSpeed * 0.175f; - } - - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - animPrevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - animFrameSpeedDiff = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - animSpeed = (f32)ABS(this->skelAnime.playSpeed); - - if ((animPrevFrame != (s32)this->skelAnime.curFrame) && (animFrameSpeedDiff <= 0) && - (animSpeed + animPrevFrame > 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, 1); - } - - if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); - } - - if ((Math_CosS(angle1 - this->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - (this->actor.xzDistToPlayer <= 80.0f)) { - EnWf_SetupSlash(this); - } else { - this->actionTimer--; - - if (this->actionTimer == 0) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { - EnWf_SetupBackflipAway(this); - } else { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 3.0f) + 1.0f; - } - } - } - } -} - -void EnWf_SetupSlash(EnWf* this) { - Animation_PlayOnce(&this->skelAnime, &gWolfosSlashingAnim); - this->colliderSpheres.base.atFlags &= ~AT_BOUNCED; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->action = WOLFOS_ACTION_SLASH; - this->unk_2FA = 0; // Set and not used - this->actionTimer = 7; - this->skelAnime.endFrame = 20.0f; - this->actor.speedXZ = 0.0f; - - EnWf_SetupAction(this, EnWf_Slash); -} - -void EnWf_Slash(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 shapeAngleDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - s16 yawAngleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - s32 curFrame = this->skelAnime.curFrame; - - shapeAngleDiff = ABS(shapeAngleDiff); - yawAngleDiff = ABS(yawAngleDiff); - this->actor.speedXZ = 0.0f; - - if (((curFrame >= 9) && (curFrame <= 12)) || ((curFrame >= 17) && (curFrame <= 19))) { - if (this->slashStatus == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_ATTACK); - } - - this->slashStatus = 1; - } else { - this->slashStatus = 0; - } - - if (((curFrame == 15) && !Actor_IsTargeted(globalCtx, &this->actor) && - (!Actor_IsFacingPlayer(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || - SkelAnime_Update(&this->skelAnime)) { - if ((curFrame != 15) && (this->actionTimer != 0)) { - this->actor.shape.rot.y += (s16)(3276.0f * (1.5f + (this->actionTimer - 4) * 0.4f)); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 1, 2.0f, 50, 50, 1); - this->actionTimer--; - } else if (!Actor_IsFacingPlayer(&this->actor, 0x1554) && (curFrame != 15)) { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; - - if (yawAngleDiff > 13000) { - this->unk_2E2 = 7; - } - } else if ((Rand_ZeroOne() > 0.7f) || (this->actor.xzDistToPlayer >= 120.0f)) { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } else { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (Rand_ZeroOne() > 0.7f) { - EnWf_SetupSidestep(this, globalCtx); - } else if (shapeAngleDiff <= 10000) { - if (yawAngleDiff > 16000) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnWf_SetupRunAroundPlayer(this); - } else { - EnWf_ChangeAction(globalCtx, this, true); - } - } else { - EnWf_SetupRunAroundPlayer(this); - } - } - } -} - -void EnWf_SetupRecoilFromBlockedSlash(EnWf* this) { - f32 endFrame = 1.0f; - - if ((s32)this->skelAnime.curFrame >= 16) { - endFrame = 15.0f; - } - - Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, endFrame, - ANIMMODE_ONCE_INTERP, 0.0f); - this->action = WOLFOS_ACTION_RECOIL_FROM_BLOCKED_SLASH; - this->slashStatus = 0; - EnWf_SetupAction(this, EnWf_RecoilFromBlockedSlash); -} - -void EnWf_RecoilFromBlockedSlash(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 angle1 = player->actor.shape.rot.y - this->actor.shape.rot.y; - s16 angle2 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - angle1 = ABS(angle1); - angle2 = ABS(angle2); - - if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_IsFacingPlayer(&this->actor, 0x1554)) { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; - - if (angle2 > 0x32C8) { - this->unk_2E2 = 30; - } - } else { - if ((Rand_ZeroOne() > 0.7f) || (this->actor.xzDistToPlayer >= 120.0f)) { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; - } else { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (Rand_ZeroOne() > 0.7f) { - EnWf_SetupSidestep(this, globalCtx); - } else if (angle1 <= 0x2710) { - if (angle2 > 0x3E80) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnWf_SetupRunAroundPlayer(this); - } else { - EnWf_ChangeAction(globalCtx, this, true); - } - } else { - EnWf_SetupRunAroundPlayer(this); - } - } - } - } -} - -void EnWf_SetupBackflipAway(EnWf* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosBackflippingAnim, -3.0f); - this->actor.speedXZ = -6.0f; - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionTimer = 0; - this->unk_300 = true; - this->action = WOLFOS_ACTION_BACKFLIP_AWAY; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - EnWf_SetupAction(this, EnWf_BackflipAway); -} - -void EnWf_BackflipAway(EnWf* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && - (this->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { - EnWf_SetupRunAtPlayer(this, globalCtx); - } else if ((globalCtx->gameplayFrames % 2) != 0) { - EnWf_SetupSidestep(this, globalCtx); - } else { - EnWf_SetupWait(this); - } - } - if ((globalCtx->state.frames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); - } -} - -void EnWf_SetupStunned(EnWf* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - Animation_PlayOnceSetSpeed(&this->skelAnime, &gWolfosDamagedAnim, 0.0f); - this->action = WOLFOS_ACTION_STUNNED; - EnWf_SetupAction(this, EnWf_Stunned); -} - -void EnWf_Stunned(EnWf* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - - this->unk_300 = false; - } - - if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { - if (this->actor.colChkInfo.health == 0) { - EnWf_SetupDie(this); - } else { - EnWf_ChangeAction(globalCtx, this, true); - } - } -} - -void EnWf_SetupDamaged(EnWf* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosDamagedAnim, -4.0f); - - if (this->actor.bgCheckFlags & 1) { - this->unk_300 = false; - this->actor.speedXZ = -4.0f; - } else { - this->unk_300 = true; - } - - this->unk_2E2 = 0; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); - this->action = WOLFOS_ACTION_DAMAGED; - EnWf_SetupAction(this, EnWf_Damaged); -} - -void EnWf_Damaged(EnWf* this, GlobalContext* globalCtx) { - s16 angleToWall; - - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - - this->unk_300 = false; - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4500, 0); - - if (!EnWf_ChangeAction(globalCtx, this, false) && SkelAnime_Update(&this->skelAnime)) { - if (this->actor.bgCheckFlags & 1) { - angleToWall = this->actor.wallYaw - this->actor.shape.rot.y; - angleToWall = ABS(angleToWall); - - if ((this->actor.bgCheckFlags & 8) && (ABS(angleToWall) < 12000) && (this->actor.xzDistToPlayer < 120.0f)) { - EnWf_SetupSomersaultAndAttack(this); - } else if (!EnWf_DodgeRanged(globalCtx, this)) { - if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - ((globalCtx->gameplayFrames % 8) != 0)) { - EnWf_SetupSlash(this); - } else if (Rand_ZeroOne() > 0.5f) { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; - this->unk_2E2 = 30; - } else { - EnWf_SetupBackflipAway(this); - } - } - } - } -} - -void EnWf_SetupSomersaultAndAttack(EnWf* this) { - f32 lastFrame = Animation_GetLastFrame(&gWolfosBackflippingAnim); - - Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, lastFrame, 0.0f, ANIMMODE_ONCE, -3.0f); - this->actionTimer = 0; - this->unk_300 = false; - this->action = WOLFOS_ACTION_TURN_TOWARDS_PLAYER; - this->actor.speedXZ = 6.5f; - this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_JUMP); - this->actor.world.rot.y = this->actor.shape.rot.y; - EnWf_SetupAction(this, EnWf_SomersaultAndAttack); -} - -void EnWf_SomersaultAndAttack(EnWf* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4000, 1); - - if (this->actor.velocity.y >= 5.0f) { - //! @bug unk_4C8 and unk_4BC are used but not set (presumably intended to be feet positions like other actors) - func_800355B8(globalCtx, &this->unk_4C8); - func_800355B8(globalCtx, &this->unk_4BC); - } - - if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & (1 | 2))) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.x = 0; - this->actor.speedXZ = this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = this->actor.floorHeight; - - if (!Actor_OtherIsTargeted(globalCtx, &this->actor)) { - EnWf_SetupSlash(this); - } else { - EnWf_SetupWait(this); - } - } -} - -void EnWf_SetupBlocking(EnWf* this) { - f32 lastFrame = Animation_GetLastFrame(&gWolfosBlockingAnim); - - if (this->slashStatus != 0) { - this->slashStatus = -1; - } - - this->actor.speedXZ = 0.0f; - this->action = WOLFOS_ACTION_BLOCKING; - this->actionTimer = 10; - - Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, 0.0f, 0.0f, lastFrame, ANIMMODE_ONCE_INTERP, -4.0f); - EnWf_SetupAction(this, EnWf_Blocking); -} - -void EnWf_Blocking(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - - if (this->actionTimer != 0) { - this->actionTimer--; - } else { - this->skelAnime.playSpeed = 1.0f; - } - - if (SkelAnime_Update(&this->skelAnime)) { - s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((ABS(yawDiff) <= 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && - (ABS(this->actor.yDistToPlayer) < 50.0f)) { - if (func_800354B4(globalCtx, &this->actor, 100.0f, 10000, 0x4000, this->actor.shape.rot.y)) { - if (player->swordAnimation == 0x11) { - EnWf_SetupBlocking(this); - } else if ((globalCtx->gameplayFrames % 2) != 0) { - EnWf_SetupBlocking(this); - } else { - EnWf_SetupBackflipAway(this); - } - - } else { - s16 angleFacingLink = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && - (((globalCtx->gameplayFrames % 2) != 0) || (ABS(angleFacingLink) < 0x38E0))) { - EnWf_SetupSlash(this); - } else { - EnWf_SetupRunAroundPlayer(this); - } - } - } else { - EnWf_SetupRunAroundPlayer(this); - } - } else if (this->actionTimer == 0) { - if (func_800354B4(globalCtx, &this->actor, 100.0f, 10000, 0x4000, this->actor.shape.rot.y)) { - if (player->swordAnimation == 0x11) { - EnWf_SetupBlocking(this); - } else if ((globalCtx->gameplayFrames % 2) != 0) { - EnWf_SetupBlocking(this); - } else { - EnWf_SetupBackflipAway(this); - } - } - } -} - -void EnWf_SetupSidestep(EnWf* this, GlobalContext* globalCtx) { - s16 angle; - Player* player; - f32 lastFrame = Animation_GetLastFrame(&gWolfosRunningAnim); - - Animation_Change(&this->skelAnime, &gWolfosRunningAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); - - player = GET_PLAYER(globalCtx); - angle = player->actor.shape.rot.y + this->runAngle; - - if (Math_SinS(angle - this->actor.yawTowardsPlayer) > 0.0f) { - this->runAngle = 16000; - } else if (Math_SinS(angle - this->actor.yawTowardsPlayer) < 0.0f) { - this->runAngle = -16000; - } else if (Rand_ZeroOne() > 0.5f) { - this->runAngle = 16000; - } else { - this->runAngle = -16000; - } - - this->skelAnime.playSpeed = this->actor.speedXZ = 6.0f; - this->skelAnime.playSpeed *= 0.175f; - this->actor.world.rot.y = this->actor.shape.rot.y; - this->runSpeed = 0.0f; - this->actionTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->action = WOLFOS_ACTION_SIDESTEP; - - EnWf_SetupAction(this, EnWf_Sidestep); -} - -void EnWf_Sidestep(EnWf* this, GlobalContext* globalCtx) { - s16 angleDiff1; - Player* player = GET_PLAYER(globalCtx); - s32 animPrevFrame; - s32 animFrameSpeedDiff; - s32 animSpeed; - f32 baseRange = 0.0f; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->runAngle, 1, 3000, 1); - - // Actor_TestFloorInDirection is useless here (see comment below) - if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, this->actor.shape.rot.y)) { - s16 angle = - (this->actor.bgCheckFlags & 8) ? (this->actor.wallYaw - this->actor.yawTowardsPlayer) - this->runAngle : 0; - - // This is probably meant to reverse direction if the edge of a floor is encountered, but does nothing - // unless bgCheckFlags & 8 anyway, since angle = 0 otherwise - if (ABS(angle) > 0x2EE0) { - this->runAngle = -this->runAngle; - } - } - - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - baseRange = 150.0f; - } - - if (this->actor.xzDistToPlayer <= (60.0f + baseRange)) { - Math_SmoothStepToF(&this->runSpeed, -4.0f, 1.0f, 1.5f, 0.0f); - } else if ((80.0f + baseRange) < this->actor.xzDistToPlayer) { - Math_SmoothStepToF(&this->runSpeed, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->runSpeed, 0.0f, 1.0f, 6.65f, 0.0f); - } - - if (this->runSpeed != 0.0f) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->runSpeed; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->runSpeed; - } - - if (ABS(this->runSpeed) < ABS(this->actor.speedXZ)) { - this->skelAnime.playSpeed = this->actor.speedXZ * 0.175f; - } else { - this->skelAnime.playSpeed = this->runSpeed * 0.175f; - } - - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - - animPrevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - animFrameSpeedDiff = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - animSpeed = (f32)ABS(this->skelAnime.playSpeed); - - if (!EnWf_ChangeAction(globalCtx, this, false)) { - this->actionTimer--; - - if (this->actionTimer == 0) { - angleDiff1 = player->actor.shape.rot.y - this->actor.yawTowardsPlayer; - angleDiff1 = ABS(angleDiff1); - - if (angleDiff1 >= 0x3A98) { - EnWf_SetupWait(this); - this->actionTimer = (Rand_ZeroOne() * 3.0f) + 1.0f; - } else { - Player* player2 = GET_PLAYER(globalCtx); - s16 angleDiff2 = player2->actor.shape.rot.y - this->actor.yawTowardsPlayer; - - this->actor.world.rot.y = this->actor.shape.rot.y; - - if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - (((globalCtx->gameplayFrames % 4) == 0) || (ABS(angleDiff2) < 0x38E0))) { - EnWf_SetupSlash(this); - } else { - EnWf_SetupRunAtPlayer(this, globalCtx); - } - } - } - - if ((animPrevFrame != (s32)this->skelAnime.curFrame) && (animFrameSpeedDiff <= 0) && - ((animSpeed + animPrevFrame) > 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, 1); - } - - if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); - } - } -} - -void EnWf_SetupDie(EnWf* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, -4.0f); - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (this->actor.bgCheckFlags & 1) { - this->unk_300 = false; - this->actor.speedXZ = -6.0f; - } else { - this->unk_300 = true; - } - - this->action = WOLFOS_ACTION_DIE; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionTimer = this->skelAnime.animLength; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DEAD); - EnWf_SetupAction(this, EnWf_Die); -} - -void EnWf_Die(EnWf* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - - if (this->actor.bgCheckFlags & 1) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - this->unk_300 = false; - } - - if (SkelAnime_Update(&this->skelAnime)) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xD0); - - if (this->switchFlag != 0xFF) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - - Actor_Kill(&this->actor); - } else { - s32 i; - Vec3f pos; - Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; - - this->actionTimer--; - - for (i = ((s32)this->skelAnime.animLength - this->actionTimer) >> 1; i >= 0; i--) { - pos.x = Rand_CenteredFloat(60.0f) + this->actor.world.pos.x; - pos.z = Rand_CenteredFloat(60.0f) + this->actor.world.pos.z; - pos.y = Rand_CenteredFloat(50.0f) + (this->actor.world.pos.y + 20.0f); - EffectSsDeadDb_Spawn(globalCtx, &pos, &velAndAccel, &velAndAccel, 100, 0, 255, 255, 255, 255, 0, 0, 255, 1, - 9, true); - } - } -} - -void func_80B36F40(EnWf* this, GlobalContext* globalCtx) { - if ((this->action == WOLFOS_ACTION_WAIT) && (this->unk_2E2 != 0)) { - this->unk_4D4.y = Math_SinS(this->unk_2E2 * 4200) * 8920.0f; - } else if (this->action != WOLFOS_ACTION_STUNNED) { - if (this->action != WOLFOS_ACTION_SLASH) { - Math_SmoothStepToS(&this->unk_4D4.y, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 1, 1500, 0); - this->unk_4D4.y = CLAMP(this->unk_4D4.y, -0x3127, 0x3127); - } else { - this->unk_4D4.y = 0; - } - } -} - -void EnWf_UpdateDamage(EnWf* this, GlobalContext* globalCtx) { - if (this->colliderSpheres.base.acFlags & AC_BOUNCED) { - this->colliderSpheres.base.acFlags &= ~(AC_HIT | AC_BOUNCED); - this->colliderCylinderBody.base.acFlags &= ~AC_HIT; - this->colliderCylinderTail.base.acFlags &= ~AC_HIT; - } else if ((this->colliderCylinderBody.base.acFlags & AC_HIT) || - (this->colliderCylinderTail.base.acFlags & AC_HIT)) { - if (this->action >= WOLFOS_ACTION_WAIT) { - s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if ((!(this->colliderCylinderBody.base.acFlags & AC_HIT) && - (this->colliderCylinderTail.base.acFlags & AC_HIT)) || - (ABS(yawDiff) > 19000)) { - this->actor.colChkInfo.damage *= 4; - } - - this->colliderCylinderBody.base.acFlags &= ~AC_HIT; - this->colliderCylinderTail.base.acFlags &= ~AC_HIT; - - if (this->actor.colChkInfo.damageEffect != ENWF_DMGEFF_ICE_MAGIC) { - this->damageEffect = this->actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->actor, &this->colliderCylinderBody.info, 1); - this->slashStatus = 0; - - if ((this->actor.colChkInfo.damageEffect == ENWF_DMGEFF_STUN) || - (this->actor.colChkInfo.damageEffect == ENWF_DMGEFF_UNDEF)) { - if (this->action != WOLFOS_ACTION_STUNNED) { - Actor_SetColorFilter(&this->actor, 0, 120, 0, 80); - Actor_ApplyDamage(&this->actor); - EnWf_SetupStunned(this); - } - } else { // LIGHT_MAGIC, FIRE, NONE - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - - if (this->damageEffect == ENWF_DMGEFF_FIRE) { - this->fireTimer = 40; - } - - if (Actor_ApplyDamage(&this->actor) == 0) { - EnWf_SetupDie(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else { - EnWf_SetupDamaged(this); - } - } - } - } - } -} - -void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnWf* this = (EnWf*)thisx; - - EnWf_UpdateDamage(this, globalCtx); - - if (this->actor.colChkInfo.damageEffect != ENWF_DMGEFF_ICE_MAGIC) { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); - this->actionFunc(this, globalCtx); - func_80B36F40(this, globalCtx); - } - - if (this->actor.bgCheckFlags & (1 | 2)) { - func_800359B8(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); - } else { - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 1000, 0); - Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 1000, 0); - } - - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSpheres.base); - - if (this->action >= WOLFOS_ACTION_WAIT) { - if ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000)) { - Collider_UpdateCylinder(&this->actor, &this->colliderCylinderBody); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinderTail.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinderBody.base); - } - } - - if (this->action == WOLFOS_ACTION_BLOCKING) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSpheres.base); - } - - if (this->slashStatus > 0) { - if (!(this->colliderSpheres.base.atFlags & AT_BOUNCED)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSpheres.base); - } else { - EnWf_SetupRecoilFromBlockedSlash(this); - } - } - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 25.0f; - - if (this->eyeIndex == 0) { - if ((Rand_ZeroOne() < 0.2f) && ((globalCtx->gameplayFrames % 4) == 0) && (this->actor.colorFilterTimer == 0)) { - this->eyeIndex++; - } - } else { - this->eyeIndex = (this->eyeIndex + 1) & 3; - } -} - -s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnWf* this = (EnWf*)thisx; - - if ((limbIndex == WOLFOS_LIMB_HEAD) || (limbIndex == WOLFOS_LIMB_EYES)) { - rot->y -= this->unk_4D4.y; - } - - return false; -} - -void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f colliderVec = { 1200.0f, 0.0f, 0.0f }; - static Vec3f bodyPartVec = { 0.0f, 0.0f, 0.0f }; - EnWf* this = (EnWf*)thisx; - s32 bodyPartIndex = -1; - - Collider_UpdateSpheres(limbIndex, &this->colliderSpheres); - - if (limbIndex == WOLFOS_LIMB_TAIL) { - Vec3f colliderPos; - - bodyPartIndex = -1; - Matrix_MultVec3f(&colliderVec, &colliderPos); - this->colliderCylinderTail.dim.pos.x = colliderPos.x; - this->colliderCylinderTail.dim.pos.y = colliderPos.y; - this->colliderCylinderTail.dim.pos.z = colliderPos.z; - } - - if ((this->fireTimer != 0) || ((this->actor.colorFilterTimer != 0) && (this->actor.colorFilterParams & 0x4000))) { - switch (limbIndex) { - case WOLFOS_LIMB_EYES: - bodyPartIndex = 0; - break; - case WOLFOS_LIMB_FRONT_RIGHT_LOWER_LEG: - bodyPartIndex = 1; - break; - case WOLFOS_LIMB_FRONT_LEFT_LOWER_LEG: - bodyPartIndex = 2; - break; - case WOLFOS_LIMB_THORAX: - bodyPartIndex = 3; - break; - case WOLFOS_LIMB_ABDOMEN: - bodyPartIndex = 4; - break; - case WOLFOS_LIMB_TAIL: - bodyPartIndex = 5; - break; - case WOLFOS_LIMB_BACK_RIGHT_SHIN: - bodyPartIndex = 6; - break; - case 37: - //! @bug There is no limb with index this large, so bodyPartsPos[7] is uninitialised. Thus a flame will - //! be drawn at 0,0,0 when the Wolfos is on fire. - bodyPartIndex = 7; - break; - case WOLFOS_LIMB_BACK_RIGHT_PASTERN: - bodyPartIndex = 8; - break; - case WOLFOS_LIMB_BACK_LEFT_PAW: - bodyPartIndex = 9; - break; - } - - if (bodyPartIndex >= 0) { - Vec3f bodyPartPos; - - Matrix_MultVec3f(&bodyPartVec, &bodyPartPos); - this->bodyPartsPos[bodyPartIndex].x = bodyPartPos.x; - this->bodyPartsPos[bodyPartIndex].y = bodyPartPos.y; - this->bodyPartsPos[bodyPartIndex].z = bodyPartPos.z; - } - } -} - -static void* sWolfosNormalEyeTextures[] = { gWolfosNormalEyeOpenTex, gWolfosNormalEyeHalfTex, gWolfosNormalEyeNarrowTex, - gWolfosNormalEyeHalfTex }; -static void* sWolfosWhiteEyeTextures[] = { gWolfosWhiteEyeOpenTex, gWolfosWhiteEyeHalfTex, gWolfosWhiteEyeNarrowTex, - gWolfosWhiteEyeHalfTex }; - -void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnWf* this = (EnWf*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_wf.c", 2157); - - // This conditional will always evaluate to true, since unk_300 is false whenever action is - // WOLFOS_ACTION_WAIT_TO_APPEAR. - if ((this->action != WOLFOS_ACTION_WAIT_TO_APPEAR) || !this->unk_300) { - func_80093D18(globalCtx->state.gfxCtx); - - if (this->actor.params == WOLFOS_NORMAL) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sWolfosNormalEyeTextures[this->eyeIndex])); - } else { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sWolfosWhiteEyeTextures[this->eyeIndex])); - } - - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); - - if (this->fireTimer != 0) { - this->actor.colorFilterTimer++; - if (1) {} - this->fireTimer--; - - if ((this->fireTimer % 4) == 0) { - s32 fireIndex = this->fireTimer >> 2; - - EffectSsEnFire_SpawnVec3s(globalCtx, &this->actor, &this->bodyPartsPos[fireIndex], 75, 0, 0, fireIndex); - } - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_wf.c", 2190); -} - -s32 EnWf_DodgeRanged(GlobalContext* globalCtx, EnWf* this) { - Actor* actor = Actor_GetProjectileActor(globalCtx, &this->actor, 600.0f); - - if (actor != NULL) { - s16 angleToFacing; - s16 pad; - f32 dist; - - angleToFacing = Actor_WorldYawTowardActor(&this->actor, actor) - this->actor.shape.rot.y; - this->actor.world.rot.y = (u16)this->actor.shape.rot.y & 0xFFFF; - dist = Actor_WorldDistXYZToPoint(&this->actor, &actor->world.pos); - - if ((ABS(angleToFacing) < 0x2EE0) && (sqrt(dist) < 400.0)) { - EnWf_SetupBlocking(this); - } else { - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - if ((ABS(angleToFacing) < 0x2000) || (ABS(angleToFacing) > 0x5FFF)) { - EnWf_SetupSidestep(this, globalCtx); - this->actor.speedXZ *= 2.0f; - } else if (ABS(angleToFacing) < 0x5FFF) { - EnWf_SetupBackflipAway(this); - } - } - return true; - } - - return false; -} diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.cpp b/src/overlays/actors/ovl_En_Wf/z_en_wf.cpp new file mode 100644 index 000000000..d69a8276a --- /dev/null +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.cpp @@ -0,0 +1,1503 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WF_Z_EN_WF_C +#include "actor_common.h" +/* + * File: z_en_wf.c + * Overlay: ovl_En_Wf + * Description: Wolfos (Normal and White) + */ + +#include "z_en_wf.h" +#include "vt.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/object_wf/object_wf.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnWf_Init(Actor* thisx, GlobalContext* globalCtx); +void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnWf_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnWf_SetupWaitToAppear(EnWf* pthis); +void EnWf_WaitToAppear(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupWait(EnWf* pthis); +void EnWf_Wait(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupRunAtPlayer(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_RunAtPlayer(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupSearchForPlayer(EnWf* pthis); +void EnWf_SearchForPlayer(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupRunAroundPlayer(EnWf* pthis); +void EnWf_RunAroundPlayer(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupSlash(EnWf* pthis); +void EnWf_Slash(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_RecoilFromBlockedSlash(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupBackflipAway(EnWf* pthis); +void EnWf_BackflipAway(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_Stunned(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_Damaged(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupSomersaultAndAttack(EnWf* pthis); +void EnWf_SomersaultAndAttack(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupBlocking(EnWf* pthis); +void EnWf_Blocking(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupSidestep(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_Sidestep(EnWf* pthis, GlobalContext* globalCtx); +void EnWf_SetupDie(EnWf* pthis); +void EnWf_Die(EnWf* pthis, GlobalContext* globalCtx); +s32 EnWf_DodgeRanged(GlobalContext* globalCtx, EnWf* pthis); + +static ColliderJntSphElementInit sJntSphItemsInit[4] = { + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { WOLFOS_LIMB_FRONT_RIGHT_CLAW, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { WOLFOS_LIMB_FRONT_LEFT_CLAW, { { 0, 0, 0 }, 15 }, 100 }, + }, + { + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC1FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { WOLFOS_LIMB_HEAD, { { 800, 0, 0 }, 25 }, 100 }, + }, + { + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFC1FFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { WOLFOS_LIMB_THORAX, { { 0, 0, 0 }, 30 }, 100 }, + }, +}; + +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphItemsInit), + sJntSphItemsInit, +}; + +static ColliderCylinderInit sBodyCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 20, 50, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sTailCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 15, 20, -15, { 0, 0, 0 } }, +}; + +typedef enum { + /* 0 */ ENWF_DMGEFF_NONE, + /* 1 */ ENWF_DMGEFF_STUN, + /* 6 */ ENWF_DMGEFF_ICE_MAGIC = 6, + /* 13 */ ENWF_DMGEFF_LIGHT_MAGIC = 13, + /* 14 */ ENWF_DMGEFF_FIRE, + /* 15 */ ENWF_DMGEFF_UNDEF // used like STUN in the code, but not in the table +} EnWfDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, ENWF_DMGEFF_STUN), + /* Deku stick */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(1, ENWF_DMGEFF_NONE), + /* Explosive */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(0, ENWF_DMGEFF_STUN), + /* Normal arrow */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, ENWF_DMGEFF_STUN), + /* Kokiri sword */ DMG_ENTRY(1, ENWF_DMGEFF_NONE), + /* Master sword */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Giant's Knife */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(4, ENWF_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Unk arrow 1 */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Unk arrow 2 */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Unk arrow 3 */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Fire magic */ DMG_ENTRY(4, ENWF_DMGEFF_FIRE), + /* Ice magic */ DMG_ENTRY(0, ENWF_DMGEFF_ICE_MAGIC), + /* Light magic */ DMG_ENTRY(3, ENWF_DMGEFF_LIGHT_MAGIC), + /* Shield */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, ENWF_DMGEFF_NONE), + /* Giant spin */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), + /* Master spin */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Kokiri jump */ DMG_ENTRY(2, ENWF_DMGEFF_NONE), + /* Giant jump */ DMG_ENTRY(8, ENWF_DMGEFF_NONE), + /* Master jump */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), + /* Unknown 1 */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, ENWF_DMGEFF_NONE), + /* Unknown 2 */ DMG_ENTRY(0, ENWF_DMGEFF_NONE), +}; + +ActorInit En_Wf_InitVars = { + ACTOR_EN_WF, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_WF, + sizeof(EnWf), + (ActorFunc)EnWf_Init, + (ActorFunc)EnWf_Destroy, + (ActorFunc)EnWf_Update, + (ActorFunc)EnWf_Draw, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -3000, ICHAIN_STOP), +}; + +void EnWf_SetupAction(EnWf* pthis, EnWfActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWf* pthis = (EnWf*)thisx; + + Actor_ProcessInitChain(thisx, sInitChain); + thisx->colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + thisx->focus.pos = thisx->world.pos; + thisx->colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.health = 8; + thisx->colChkInfo.cylRadius = 50; + thisx->colChkInfo.cylHeight = 100; + pthis->switchFlag = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + pthis->eyeIndex = 0; + pthis->unk_2F4 = 10.0f; // Set and not used + + Collider_InitJntSph(globalCtx, &pthis->colliderSpheres); + Collider_SetJntSph(globalCtx, &pthis->colliderSpheres, thisx, &sJntSphInit, pthis->colliderSpheresElements); + Collider_InitCylinder(globalCtx, &pthis->colliderCylinderBody); + Collider_SetCylinder(globalCtx, &pthis->colliderCylinderBody, thisx, &sBodyCylinderInit); + Collider_InitCylinder(globalCtx, &pthis->colliderCylinderTail); + Collider_SetCylinder(globalCtx, &pthis->colliderCylinderTail, thisx, &sTailCylinderInit); + + if (thisx->params == WOLFOS_NORMAL) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, pthis->jointTable, + pthis->morphTable, WOLFOS_LIMB_MAX); + Actor_SetScale(thisx, 0.0075f); + thisx->naviEnemyId = 0x4C; // Wolfos + } else { // WOLFOS_WHITE + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, pthis->jointTable, + pthis->morphTable, WOLFOS_LIMB_MAX); + Actor_SetScale(thisx, 0.01f); + pthis->colliderSpheres.elements[0].info.toucher.damage = pthis->colliderSpheres.elements[1].info.toucher.damage = + 8; + thisx->naviEnemyId = 0x57; // White Wolfos + } + + EnWf_SetupWaitToAppear(pthis); + + if ((pthis->switchFlag != 0xFF) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + Actor_Kill(thisx); + } +} + +void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWf* pthis = (EnWf*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->colliderSpheres); + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinderBody); + Collider_DestroyCylinder(globalCtx, &pthis->colliderCylinderTail); + + if ((pthis->actor.params != WOLFOS_NORMAL) && (pthis->switchFlag != 0xFF)) { + func_800F5B58(); + } + + if (pthis->actor.parent != NULL) { + EnEncount1* parent = (EnEncount1*)pthis->actor.parent; + + if (parent->actor.update != NULL) { + if (parent->curNumSpawn > 0) { + parent->curNumSpawn--; + } + + osSyncPrintf("\n\n"); + // "☆☆☆☆☆ Number of concurrent events ☆☆☆☆☆" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 同時発生数 ☆☆☆☆☆%d\n" VT_RST, parent->curNumSpawn); + osSyncPrintf("\n\n"); + } + } +} + +s32 EnWf_ChangeAction(GlobalContext* globalCtx, EnWf* pthis, s16 mustChoose) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 wallYawDiff; + s16 playerYawDiff; + Actor* explosive; + + wallYawDiff = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + wallYawDiff = ABS(wallYawDiff); + playerYawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + playerYawDiff = ABS(playerYawDiff); + + if (func_800354B4(globalCtx, &pthis->actor, 100.0f, 0x2710, 0x2EE0, pthis->actor.shape.rot.y)) { + if (player->swordAnimation == 0x11) { + EnWf_SetupBlocking(pthis); + return true; + } + + if ((globalCtx->gameplayFrames % 2) != 0) { + EnWf_SetupBlocking(pthis); + return true; + } + } + + if (func_800354B4(globalCtx, &pthis->actor, 100.0f, 0x5DC0, 0x2AA8, pthis->actor.shape.rot.y)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if ((pthis->actor.bgCheckFlags & 8) && (ABS(wallYawDiff) < 0x2EE0) && (pthis->actor.xzDistToPlayer < 120.0f)) { + EnWf_SetupSomersaultAndAttack(pthis); + return true; + } else if (player->swordAnimation == 0x11) { + EnWf_SetupBlocking(pthis); + return true; + } else if ((pthis->actor.xzDistToPlayer < 80.0f) && (globalCtx->gameplayFrames % 2) != 0) { + EnWf_SetupBlocking(pthis); + return true; + } else { + EnWf_SetupBackflipAway(pthis); + return true; + } + } + + explosive = Actor_FindNearby(globalCtx, &pthis->actor, -1, ACTORCAT_EXPLOSIVE, 80.0f); + + if (explosive != NULL) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (((pthis->actor.bgCheckFlags & 8) && (wallYawDiff < 0x2EE0)) || (explosive->id == ACTOR_EN_BOM_CHU)) { + if ((explosive->id == ACTOR_EN_BOM_CHU) && (Actor_WorldDistXYZToActor(&pthis->actor, explosive) < 80.0f) && + (s16)((pthis->actor.shape.rot.y - explosive->world.rot.y) + 0x8000) < 0x3E80) { + EnWf_SetupSomersaultAndAttack(pthis); + return true; + } else { + EnWf_SetupSidestep(pthis, globalCtx); + return true; + } + } else { + EnWf_SetupBackflipAway(pthis); + return true; + } + } + + if (mustChoose) { + s16 playerFacingAngleDiff; + + if (playerYawDiff >= 0x1B58) { + EnWf_SetupSidestep(pthis, globalCtx); + return true; + } + + playerFacingAngleDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if ((pthis->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (((globalCtx->gameplayFrames % 8) != 0) || (ABS(playerFacingAngleDiff) < 0x38E0))) { + EnWf_SetupSlash(pthis); + return true; + } + + EnWf_SetupRunAroundPlayer(pthis); + return true; + } + return false; +} + +void EnWf_SetupWaitToAppear(EnWf* pthis) { + Animation_Change(&pthis->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, 0.0f); + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 5.0f; + pthis->actionTimer = 20; + pthis->unk_300 = false; + pthis->action = WOLFOS_ACTION_WAIT_TO_APPEAR; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.scale.y = 0.0f; + pthis->actor.gravity = 0.0f; + EnWf_SetupAction(pthis, EnWf_WaitToAppear); +} + +void EnWf_WaitToAppear(EnWf* pthis, GlobalContext* globalCtx) { + if (pthis->actionTimer >= 6) { + pthis->actor.world.pos.y = pthis->actor.home.pos.y - 5.0f; + + if (pthis->actor.xzDistToPlayer < 240.0f) { + pthis->actionTimer = 5; + pthis->actor.flags |= ACTOR_FLAG_0; + + if ((pthis->actor.params != WOLFOS_NORMAL) && (pthis->switchFlag != 0xFF)) { + func_800F5ACC(0x38); // Mini-Boss Battle Theme + } + } + } else if (pthis->actionTimer != 0) { + pthis->actor.scale.y += pthis->actor.scale.x * 0.2f; + pthis->actor.world.pos.y += 0.5f; + Math_SmoothStepToF(&pthis->actor.shape.shadowScale, 70.0f, 1.0f, 14.0f, 0.0f); + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_APPEAR); + } + } else { // actionTimer == 0 + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.scale.y = pthis->actor.scale.x; + pthis->actor.gravity = -2.0f; + EnWf_SetupWait(pthis); + } + } +} + +void EnWf_SetupWait(EnWf* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gWolfosWaitingAnim, -4.0f); + pthis->action = WOLFOS_ACTION_WAIT; + pthis->actionTimer = (Rand_ZeroOne() * 10.0f) + 2.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnWf_SetupAction(pthis, EnWf_Wait); +} + +void EnWf_Wait(EnWf* pthis, GlobalContext* globalCtx) { + Player* player; + s32 pad; + s16 angle; + + player = GET_PLAYER(globalCtx); + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->unk_2E2 != 0) { + angle = (pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) - pthis->unk_4D4.y; + + if (ABS(angle) > 0x2000) { + pthis->unk_2E2--; + return; + } + + pthis->unk_2E2 = 0; + } + + angle = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + angle = ABS(angle); + + if (!EnWf_DodgeRanged(globalCtx, pthis)) { + // Only use of unk_2E0: never not zero, so pthis if block never runs + if (pthis->unk_2E0 != 0) { + pthis->unk_2E0--; + + if (angle >= 0x1FFE) { + return; + } + pthis->unk_2E0 = 0; + } else { + if (EnWf_ChangeAction(globalCtx, pthis, false)) { + return; + } + } + + angle = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + angle = ABS(angle); + + if ((pthis->actor.xzDistToPlayer < 80.0f) && (player->swordState != 0) && (angle >= 0x1F40)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnWf_SetupRunAroundPlayer(pthis); + } else { + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + if (Actor_IsFacingPlayer(&pthis->actor, 0x1555)) { + if (Rand_ZeroOne() > 0.3f) { + EnWf_SetupRunAtPlayer(pthis, globalCtx); + } else { + EnWf_SetupRunAroundPlayer(pthis); + } + } else { + EnWf_SetupSearchForPlayer(pthis); + } + if ((globalCtx->gameplayFrames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_CRY); + } + } + } + } +} + +void EnWf_SetupRunAtPlayer(EnWf* pthis, GlobalContext* globalCtx) { + f32 lastFrame = Animation_GetLastFrame(&gWolfosRunningAnim); + + Animation_Change(&pthis->skelAnime, &gWolfosRunningAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); + pthis->action = WOLFOS_ACTION_RUN_AT_PLAYER; + EnWf_SetupAction(pthis, EnWf_RunAtPlayer); +} + +void EnWf_RunAtPlayer(EnWf* pthis, GlobalContext* globalCtx) { + s32 animPrevFrame; + s32 sp58; + s32 pad; + f32 baseRange = 0.0f; + s16 playerFacingAngleDiff; + Player* player = GET_PLAYER(globalCtx); + s32 playSpeed; + + if (!EnWf_DodgeRanged(globalCtx, pthis)) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0x2EE, 0); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + baseRange = 150.0f; + } + + if (pthis->actor.xzDistToPlayer <= (50.0f + baseRange)) { + Math_SmoothStepToF(&pthis->actor.speedXZ, -8.0f, 1.0f, 1.5f, 0.0f); + } else if ((65.0f + baseRange) < pthis->actor.xzDistToPlayer) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 8.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 6.65f, 0.0f); + } + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 0.175f; + playerFacingAngleDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + playerFacingAngleDiff = ABS(playerFacingAngleDiff); + + if ((pthis->actor.xzDistToPlayer < (150.0f + baseRange)) && (player->swordState != 0) && + (playerFacingAngleDiff >= 8000)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (Rand_ZeroOne() > 0.7f) { + EnWf_SetupRunAroundPlayer(pthis); + return; + } + } + + animPrevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + sp58 = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + playSpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if (!Actor_IsFacingPlayer(&pthis->actor, 0x11C7)) { + if (Rand_ZeroOne() > 0.5f) { + EnWf_SetupRunAroundPlayer(pthis); + } else { + EnWf_SetupWait(pthis); + } + } else if (pthis->actor.xzDistToPlayer < (90.0f + baseRange)) { + s16 temp_v1 = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + ((Rand_ZeroOne() > 0.03f) || ((pthis->actor.xzDistToPlayer <= 80.0f) && (ABS(temp_v1) < 0x38E0)))) { + EnWf_SetupSlash(pthis); + } else if (Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (Rand_ZeroOne() > 0.5f)) { + EnWf_SetupBackflipAway(pthis); + } else { + EnWf_SetupRunAroundPlayer(pthis); + } + } + + if (!EnWf_ChangeAction(globalCtx, pthis, false)) { + if ((globalCtx->gameplayFrames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_CRY); + } + if ((animPrevFrame != (s32)pthis->skelAnime.curFrame) && (sp58 <= 0) && ((playSpeed + animPrevFrame) > 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, 1); + } + } + } +} + +void EnWf_SetupSearchForPlayer(EnWf* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gWolfosSidesteppingAnim, -4.0f); + pthis->action = WOLFOS_ACTION_SEARCH_FOR_PLAYER; + EnWf_SetupAction(pthis, EnWf_SearchForPlayer); +} + +void EnWf_SearchForPlayer(EnWf* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + s16 phi_v1; + f32 phi_f2; + + if (!EnWf_DodgeRanged(globalCtx, pthis) && !EnWf_ChangeAction(globalCtx, pthis, false)) { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + phi_v1 = (yawDiff > 0) ? (yawDiff * 0.25f) + 2000.0f : (yawDiff * 0.25f) - 2000.0f; + pthis->actor.shape.rot.y += phi_v1; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (yawDiff > 0) { + phi_f2 = phi_v1 * 0.5f; + phi_f2 = CLAMP_MAX(phi_f2, 1.0f); + } else { + phi_f2 = phi_v1 * 0.5f; + phi_f2 = CLAMP_MIN(phi_f2, -1.0f); + } + + pthis->skelAnime.playSpeed = -phi_f2; + SkelAnime_Update(&pthis->skelAnime); + + if (Actor_IsFacingPlayer(&pthis->actor, 0x1555)) { + if (Rand_ZeroOne() > 0.8f) { + EnWf_SetupRunAroundPlayer(pthis); + } else { + EnWf_SetupRunAtPlayer(pthis, globalCtx); + } + } + + if ((globalCtx->gameplayFrames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_CRY); + } + } +} + +void EnWf_SetupRunAroundPlayer(EnWf* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gWolfosRunningAnim); + + Animation_Change(&pthis->skelAnime, &gWolfosRunningAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); + + if (Rand_ZeroOne() > 0.5f) { + pthis->runAngle = 16000; + } else { + pthis->runAngle = -16000; + } + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ = 6.0f; + pthis->skelAnime.playSpeed *= 0.175f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->actionTimer = (Rand_ZeroOne() * 30.0f) + 30.0f; + pthis->action = WOLFOS_ACTION_RUN_AROUND_PLAYER; + pthis->runSpeed = 0.0f; + + EnWf_SetupAction(pthis, EnWf_RunAroundPlayer); +} + +void EnWf_RunAroundPlayer(EnWf* pthis, GlobalContext* globalCtx) { + s16 angle1; + s16 angle2; + s32 pad; + f32 baseRange = 0.0f; + s32 animPrevFrame; + s32 animFrameSpeedDiff; + s32 animSpeed; + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + pthis->runAngle, 1, 4000, 1); + + if (!EnWf_DodgeRanged(globalCtx, pthis) && !EnWf_ChangeAction(globalCtx, pthis, false)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + angle1 = player->actor.shape.rot.y + pthis->runAngle + 0x8000; + + // Actor_TestFloorInDirection is useless here (see comment below) + if ((pthis->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.shape.rot.y)) { + angle2 = (pthis->actor.bgCheckFlags & 8) + ? (pthis->actor.wallYaw - pthis->actor.yawTowardsPlayer) - pthis->runAngle + : 0; + + // This is probably meant to reverse direction if the edge of a floor is encountered, but does nothing + // unless bgCheckFlags & 8 anyway, since angle2 = 0 otherwise + if (ABS(angle2) > 0x2EE0) { + pthis->runAngle = -pthis->runAngle; + } + } + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + baseRange = 150.0f; + } + + if (pthis->actor.xzDistToPlayer <= (60.0f + baseRange)) { + Math_SmoothStepToF(&pthis->runSpeed, -4.0f, 1.0f, 1.5f, 0.0f); + } else if ((80.0f + baseRange) < pthis->actor.xzDistToPlayer) { + Math_SmoothStepToF(&pthis->runSpeed, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->runSpeed, 0.0f, 1.0f, 6.65f, 0.0f); + } + + if (pthis->runSpeed != 0.0f) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->runSpeed; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->runSpeed; + } + + if (ABS(pthis->runSpeed) < ABS(pthis->actor.speedXZ)) { + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 0.175f; + } else { + pthis->skelAnime.playSpeed = pthis->runSpeed * 0.175f; + } + + pthis->skelAnime.playSpeed = CLAMP(pthis->skelAnime.playSpeed, -3.0f, 3.0f); + animPrevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + animFrameSpeedDiff = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + animSpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if ((animPrevFrame != (s32)pthis->skelAnime.curFrame) && (animFrameSpeedDiff <= 0) && + (animSpeed + animPrevFrame > 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, 1); + } + + if ((globalCtx->gameplayFrames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_CRY); + } + + if ((Math_CosS(angle1 - pthis->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (pthis->actor.xzDistToPlayer <= 80.0f)) { + EnWf_SetupSlash(pthis); + } else { + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (Rand_ZeroOne() > 0.5f)) { + EnWf_SetupBackflipAway(pthis); + } else { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 3.0f) + 1.0f; + } + } + } + } +} + +void EnWf_SetupSlash(EnWf* pthis) { + Animation_PlayOnce(&pthis->skelAnime, &gWolfosSlashingAnim); + pthis->colliderSpheres.base.atFlags &= ~AT_BOUNCED; + pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->action = WOLFOS_ACTION_SLASH; + pthis->unk_2FA = 0; // Set and not used + pthis->actionTimer = 7; + pthis->skelAnime.endFrame = 20.0f; + pthis->actor.speedXZ = 0.0f; + + EnWf_SetupAction(pthis, EnWf_Slash); +} + +void EnWf_Slash(EnWf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 shapeAngleDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + s16 yawAngleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + s32 curFrame = pthis->skelAnime.curFrame; + + shapeAngleDiff = ABS(shapeAngleDiff); + yawAngleDiff = ABS(yawAngleDiff); + pthis->actor.speedXZ = 0.0f; + + if (((curFrame >= 9) && (curFrame <= 12)) || ((curFrame >= 17) && (curFrame <= 19))) { + if (pthis->slashStatus == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_ATTACK); + } + + pthis->slashStatus = 1; + } else { + pthis->slashStatus = 0; + } + + if (((curFrame == 15) && !Actor_IsTargeted(globalCtx, &pthis->actor) && + (!Actor_IsFacingPlayer(&pthis->actor, 0x2000) || (pthis->actor.xzDistToPlayer >= 100.0f))) || + SkelAnime_Update(&pthis->skelAnime)) { + if ((curFrame != 15) && (pthis->actionTimer != 0)) { + pthis->actor.shape.rot.y += (s16)(3276.0f * (1.5f + (pthis->actionTimer - 4) * 0.4f)); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 15.0f, 1, 2.0f, 50, 50, 1); + pthis->actionTimer--; + } else if (!Actor_IsFacingPlayer(&pthis->actor, 0x1554) && (curFrame != 15)) { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; + + if (yawAngleDiff > 13000) { + pthis->unk_2E2 = 7; + } + } else if ((Rand_ZeroOne() > 0.7f) || (pthis->actor.xzDistToPlayer >= 120.0f)) { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } else { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (Rand_ZeroOne() > 0.7f) { + EnWf_SetupSidestep(pthis, globalCtx); + } else if (shapeAngleDiff <= 10000) { + if (yawAngleDiff > 16000) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnWf_SetupRunAroundPlayer(pthis); + } else { + EnWf_ChangeAction(globalCtx, pthis, true); + } + } else { + EnWf_SetupRunAroundPlayer(pthis); + } + } + } +} + +void EnWf_SetupRecoilFromBlockedSlash(EnWf* pthis) { + f32 endFrame = 1.0f; + + if ((s32)pthis->skelAnime.curFrame >= 16) { + endFrame = 15.0f; + } + + Animation_Change(&pthis->skelAnime, &gWolfosSlashingAnim, -0.5f, pthis->skelAnime.curFrame - 1.0f, endFrame, + ANIMMODE_ONCE_INTERP, 0.0f); + pthis->action = WOLFOS_ACTION_RECOIL_FROM_BLOCKED_SLASH; + pthis->slashStatus = 0; + EnWf_SetupAction(pthis, EnWf_RecoilFromBlockedSlash); +} + +void EnWf_RecoilFromBlockedSlash(EnWf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angle1 = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + s16 angle2 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + angle1 = ABS(angle1); + angle2 = ABS(angle2); + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (!Actor_IsFacingPlayer(&pthis->actor, 0x1554)) { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; + + if (angle2 > 0x32C8) { + pthis->unk_2E2 = 30; + } + } else { + if ((Rand_ZeroOne() > 0.7f) || (pthis->actor.xzDistToPlayer >= 120.0f)) { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; + } else { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (Rand_ZeroOne() > 0.7f) { + EnWf_SetupSidestep(pthis, globalCtx); + } else if (angle1 <= 0x2710) { + if (angle2 > 0x3E80) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnWf_SetupRunAroundPlayer(pthis); + } else { + EnWf_ChangeAction(globalCtx, pthis, true); + } + } else { + EnWf_SetupRunAroundPlayer(pthis); + } + } + } + } +} + +void EnWf_SetupBackflipAway(EnWf* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWolfosBackflippingAnim, -3.0f); + pthis->actor.speedXZ = -6.0f; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actionTimer = 0; + pthis->unk_300 = true; + pthis->action = WOLFOS_ACTION_BACKFLIP_AWAY; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + EnWf_SetupAction(pthis, EnWf_BackflipAway); +} + +void EnWf_BackflipAway(EnWf* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && (pthis->actor.xzDistToPlayer < 170.0f) && + (pthis->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { + EnWf_SetupRunAtPlayer(pthis, globalCtx); + } else if ((globalCtx->gameplayFrames % 2) != 0) { + EnWf_SetupSidestep(pthis, globalCtx); + } else { + EnWf_SetupWait(pthis); + } + } + if ((globalCtx->state.frames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_CRY); + } +} + +void EnWf_SetupStunned(EnWf* pthis) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.speedXZ = 0.0f; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gWolfosDamagedAnim, 0.0f); + pthis->action = WOLFOS_ACTION_STUNNED; + EnWf_SetupAction(pthis, EnWf_Stunned); +} + +void EnWf_Stunned(EnWf* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + + pthis->unk_300 = false; + } + + if ((pthis->actor.colorFilterTimer == 0) && (pthis->actor.bgCheckFlags & 1)) { + if (pthis->actor.colChkInfo.health == 0) { + EnWf_SetupDie(pthis); + } else { + EnWf_ChangeAction(globalCtx, pthis, true); + } + } +} + +void EnWf_SetupDamaged(EnWf* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWolfosDamagedAnim, -4.0f); + + if (pthis->actor.bgCheckFlags & 1) { + pthis->unk_300 = false; + pthis->actor.speedXZ = -4.0f; + } else { + pthis->unk_300 = true; + } + + pthis->unk_2E2 = 0; + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_DAMAGE); + pthis->action = WOLFOS_ACTION_DAMAGED; + EnWf_SetupAction(pthis, EnWf_Damaged); +} + +void EnWf_Damaged(EnWf* pthis, GlobalContext* globalCtx) { + s16 angleToWall; + + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + + pthis->unk_300 = false; + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4500, 0); + + if (!EnWf_ChangeAction(globalCtx, pthis, false) && SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.bgCheckFlags & 1) { + angleToWall = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + angleToWall = ABS(angleToWall); + + if ((pthis->actor.bgCheckFlags & 8) && (ABS(angleToWall) < 12000) && (pthis->actor.xzDistToPlayer < 120.0f)) { + EnWf_SetupSomersaultAndAttack(pthis); + } else if (!EnWf_DodgeRanged(globalCtx, pthis)) { + if ((pthis->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + ((globalCtx->gameplayFrames % 8) != 0)) { + EnWf_SetupSlash(pthis); + } else if (Rand_ZeroOne() > 0.5f) { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 5.0f) + 5.0f; + pthis->unk_2E2 = 30; + } else { + EnWf_SetupBackflipAway(pthis); + } + } + } + } +} + +void EnWf_SetupSomersaultAndAttack(EnWf* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gWolfosBackflippingAnim); + + Animation_Change(&pthis->skelAnime, &gWolfosBackflippingAnim, -1.0f, lastFrame, 0.0f, ANIMMODE_ONCE, -3.0f); + pthis->actionTimer = 0; + pthis->unk_300 = false; + pthis->action = WOLFOS_ACTION_TURN_TOWARDS_PLAYER; + pthis->actor.speedXZ = 6.5f; + pthis->actor.velocity.y = 15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_STAL_JUMP); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnWf_SetupAction(pthis, EnWf_SomersaultAndAttack); +} + +void EnWf_SomersaultAndAttack(EnWf* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4000, 1); + + if (pthis->actor.velocity.y >= 5.0f) { + //! @bug unk_4C8 and unk_4BC are used but not set (presumably intended to be feet positions like other actors) + func_800355B8(globalCtx, &pthis->unk_4C8); + func_800355B8(globalCtx, &pthis->unk_4BC); + } + + if (SkelAnime_Update(&pthis->skelAnime) && (pthis->actor.bgCheckFlags & (1 | 2))) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.shape.rot.x = 0; + pthis->actor.speedXZ = pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + EnWf_SetupSlash(pthis); + } else { + EnWf_SetupWait(pthis); + } + } +} + +void EnWf_SetupBlocking(EnWf* pthis) { + f32 lastFrame = Animation_GetLastFrame(&gWolfosBlockingAnim); + + if (pthis->slashStatus != 0) { + pthis->slashStatus = -1; + } + + pthis->actor.speedXZ = 0.0f; + pthis->action = WOLFOS_ACTION_BLOCKING; + pthis->actionTimer = 10; + + Animation_Change(&pthis->skelAnime, &gWolfosBlockingAnim, 0.0f, 0.0f, lastFrame, ANIMMODE_ONCE_INTERP, -4.0f); + EnWf_SetupAction(pthis, EnWf_Blocking); +} + +void EnWf_Blocking(EnWf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (pthis->actionTimer != 0) { + pthis->actionTimer--; + } else { + pthis->skelAnime.playSpeed = 1.0f; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + s16 yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((ABS(yawDiff) <= 0x4000) && (pthis->actor.xzDistToPlayer < 60.0f) && + (ABS(pthis->actor.yDistToPlayer) < 50.0f)) { + if (func_800354B4(globalCtx, &pthis->actor, 100.0f, 10000, 0x4000, pthis->actor.shape.rot.y)) { + if (player->swordAnimation == 0x11) { + EnWf_SetupBlocking(pthis); + } else if ((globalCtx->gameplayFrames % 2) != 0) { + EnWf_SetupBlocking(pthis); + } else { + EnWf_SetupBackflipAway(pthis); + } + + } else { + s16 angleFacingLink = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (((globalCtx->gameplayFrames % 2) != 0) || (ABS(angleFacingLink) < 0x38E0))) { + EnWf_SetupSlash(pthis); + } else { + EnWf_SetupRunAroundPlayer(pthis); + } + } + } else { + EnWf_SetupRunAroundPlayer(pthis); + } + } else if (pthis->actionTimer == 0) { + if (func_800354B4(globalCtx, &pthis->actor, 100.0f, 10000, 0x4000, pthis->actor.shape.rot.y)) { + if (player->swordAnimation == 0x11) { + EnWf_SetupBlocking(pthis); + } else if ((globalCtx->gameplayFrames % 2) != 0) { + EnWf_SetupBlocking(pthis); + } else { + EnWf_SetupBackflipAway(pthis); + } + } + } +} + +void EnWf_SetupSidestep(EnWf* pthis, GlobalContext* globalCtx) { + s16 angle; + Player* player; + f32 lastFrame = Animation_GetLastFrame(&gWolfosRunningAnim); + + Animation_Change(&pthis->skelAnime, &gWolfosRunningAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, -4.0f); + + player = GET_PLAYER(globalCtx); + angle = player->actor.shape.rot.y + pthis->runAngle; + + if (Math_SinS(angle - pthis->actor.yawTowardsPlayer) > 0.0f) { + pthis->runAngle = 16000; + } else if (Math_SinS(angle - pthis->actor.yawTowardsPlayer) < 0.0f) { + pthis->runAngle = -16000; + } else if (Rand_ZeroOne() > 0.5f) { + pthis->runAngle = 16000; + } else { + pthis->runAngle = -16000; + } + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ = 6.0f; + pthis->skelAnime.playSpeed *= 0.175f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->runSpeed = 0.0f; + pthis->actionTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + pthis->action = WOLFOS_ACTION_SIDESTEP; + + EnWf_SetupAction(pthis, EnWf_Sidestep); +} + +void EnWf_Sidestep(EnWf* pthis, GlobalContext* globalCtx) { + s16 angleDiff1; + Player* player = GET_PLAYER(globalCtx); + s32 animPrevFrame; + s32 animFrameSpeedDiff; + s32 animSpeed; + f32 baseRange = 0.0f; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + pthis->runAngle, 1, 3000, 1); + + // Actor_TestFloorInDirection is useless here (see comment below) + if ((pthis->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, pthis->actor.shape.rot.y)) { + s16 angle = + (pthis->actor.bgCheckFlags & 8) ? (pthis->actor.wallYaw - pthis->actor.yawTowardsPlayer) - pthis->runAngle : 0; + + // This is probably meant to reverse direction if the edge of a floor is encountered, but does nothing + // unless bgCheckFlags & 8 anyway, since angle = 0 otherwise + if (ABS(angle) > 0x2EE0) { + pthis->runAngle = -pthis->runAngle; + } + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + baseRange = 150.0f; + } + + if (pthis->actor.xzDistToPlayer <= (60.0f + baseRange)) { + Math_SmoothStepToF(&pthis->runSpeed, -4.0f, 1.0f, 1.5f, 0.0f); + } else if ((80.0f + baseRange) < pthis->actor.xzDistToPlayer) { + Math_SmoothStepToF(&pthis->runSpeed, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->runSpeed, 0.0f, 1.0f, 6.65f, 0.0f); + } + + if (pthis->runSpeed != 0.0f) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->runSpeed; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->runSpeed; + } + + if (ABS(pthis->runSpeed) < ABS(pthis->actor.speedXZ)) { + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 0.175f; + } else { + pthis->skelAnime.playSpeed = pthis->runSpeed * 0.175f; + } + + pthis->skelAnime.playSpeed = CLAMP(pthis->skelAnime.playSpeed, -3.0f, 3.0f); + + animPrevFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + animFrameSpeedDiff = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + animSpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if (!EnWf_ChangeAction(globalCtx, pthis, false)) { + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + angleDiff1 = player->actor.shape.rot.y - pthis->actor.yawTowardsPlayer; + angleDiff1 = ABS(angleDiff1); + + if (angleDiff1 >= 0x3A98) { + EnWf_SetupWait(pthis); + pthis->actionTimer = (Rand_ZeroOne() * 3.0f) + 1.0f; + } else { + Player* player2 = GET_PLAYER(globalCtx); + s16 angleDiff2 = player2->actor.shape.rot.y - pthis->actor.yawTowardsPlayer; + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if ((pthis->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &pthis->actor) && + (((globalCtx->gameplayFrames % 4) == 0) || (ABS(angleDiff2) < 0x38E0))) { + EnWf_SetupSlash(pthis); + } else { + EnWf_SetupRunAtPlayer(pthis, globalCtx); + } + } + } + + if ((animPrevFrame != (s32)pthis->skelAnime.curFrame) && (animFrameSpeedDiff <= 0) && + ((animSpeed + animPrevFrame) > 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, 1); + } + + if ((globalCtx->gameplayFrames & 95) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_CRY); + } + } +} + +void EnWf_SetupDie(EnWf* pthis) { + Animation_MorphToPlayOnce(&pthis->skelAnime, &gWolfosRearingUpFallingOverAnim, -4.0f); + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (pthis->actor.bgCheckFlags & 1) { + pthis->unk_300 = false; + pthis->actor.speedXZ = -6.0f; + } else { + pthis->unk_300 = true; + } + + pthis->action = WOLFOS_ACTION_DIE; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionTimer = pthis->skelAnime.animLength; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_WOLFOS_DEAD); + EnWf_SetupAction(pthis, EnWf_Die); +} + +void EnWf_Die(EnWf* pthis, GlobalContext* globalCtx) { + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 1) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + pthis->unk_300 = false; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, 0xD0); + + if (pthis->switchFlag != 0xFF) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + + Actor_Kill(&pthis->actor); + } else { + s32 i; + Vec3f pos; + Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; + + pthis->actionTimer--; + + for (i = ((s32)pthis->skelAnime.animLength - pthis->actionTimer) >> 1; i >= 0; i--) { + pos.x = Rand_CenteredFloat(60.0f) + pthis->actor.world.pos.x; + pos.z = Rand_CenteredFloat(60.0f) + pthis->actor.world.pos.z; + pos.y = Rand_CenteredFloat(50.0f) + (pthis->actor.world.pos.y + 20.0f); + EffectSsDeadDb_Spawn(globalCtx, &pos, &velAndAccel, &velAndAccel, 100, 0, 255, 255, 255, 255, 0, 0, 255, 1, + 9, true); + } + } +} + +void func_80B36F40(EnWf* pthis, GlobalContext* globalCtx) { + if ((pthis->action == WOLFOS_ACTION_WAIT) && (pthis->unk_2E2 != 0)) { + pthis->unk_4D4.y = Math_SinS(pthis->unk_2E2 * 4200) * 8920.0f; + } else if (pthis->action != WOLFOS_ACTION_STUNNED) { + if (pthis->action != WOLFOS_ACTION_SLASH) { + Math_SmoothStepToS(&pthis->unk_4D4.y, pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y, 1, 1500, 0); + pthis->unk_4D4.y = CLAMP(pthis->unk_4D4.y, -0x3127, 0x3127); + } else { + pthis->unk_4D4.y = 0; + } + } +} + +void EnWf_UpdateDamage(EnWf* pthis, GlobalContext* globalCtx) { + if (pthis->colliderSpheres.base.acFlags & AC_BOUNCED) { + pthis->colliderSpheres.base.acFlags &= ~(AC_HIT | AC_BOUNCED); + pthis->colliderCylinderBody.base.acFlags &= ~AC_HIT; + pthis->colliderCylinderTail.base.acFlags &= ~AC_HIT; + } else if ((pthis->colliderCylinderBody.base.acFlags & AC_HIT) || + (pthis->colliderCylinderTail.base.acFlags & AC_HIT)) { + if (pthis->action >= WOLFOS_ACTION_WAIT) { + s16 yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if ((!(pthis->colliderCylinderBody.base.acFlags & AC_HIT) && + (pthis->colliderCylinderTail.base.acFlags & AC_HIT)) || + (ABS(yawDiff) > 19000)) { + pthis->actor.colChkInfo.damage *= 4; + } + + pthis->colliderCylinderBody.base.acFlags &= ~AC_HIT; + pthis->colliderCylinderTail.base.acFlags &= ~AC_HIT; + + if (pthis->actor.colChkInfo.damageEffect != ENWF_DMGEFF_ICE_MAGIC) { + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->actor, &pthis->colliderCylinderBody.info, 1); + pthis->slashStatus = 0; + + if ((pthis->actor.colChkInfo.damageEffect == ENWF_DMGEFF_STUN) || + (pthis->actor.colChkInfo.damageEffect == ENWF_DMGEFF_UNDEF)) { + if (pthis->action != WOLFOS_ACTION_STUNNED) { + Actor_SetColorFilter(&pthis->actor, 0, 120, 0, 80); + Actor_ApplyDamage(&pthis->actor); + EnWf_SetupStunned(pthis); + } + } else { // LIGHT_MAGIC, FIRE, NONE + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 8); + + if (pthis->damageEffect == ENWF_DMGEFF_FIRE) { + pthis->fireTimer = 40; + } + + if (Actor_ApplyDamage(&pthis->actor) == 0) { + EnWf_SetupDie(pthis); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else { + EnWf_SetupDamaged(pthis); + } + } + } + } + } +} + +void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWf* pthis = (EnWf*)thisx; + + EnWf_UpdateDamage(pthis, globalCtx); + + if (pthis->actor.colChkInfo.damageEffect != ENWF_DMGEFF_ICE_MAGIC) { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 32.0f, 30.0f, 60.0f, 0x1D); + pthis->actionFunc(pthis, globalCtx); + func_80B36F40(pthis, globalCtx); + } + + if (pthis->actor.bgCheckFlags & (1 | 2)) { + func_800359B8(&pthis->actor, pthis->actor.shape.rot.y, &pthis->actor.shape.rot); + } else { + Math_SmoothStepToS(&pthis->actor.shape.rot.x, 0, 1, 1000, 0); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, 0, 1, 1000, 0); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSpheres.base); + + if (pthis->action >= WOLFOS_ACTION_WAIT) { + if ((pthis->actor.colorFilterTimer == 0) || !(pthis->actor.colorFilterParams & 0x4000)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderCylinderBody); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinderTail.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderCylinderBody.base); + } + } + + if (pthis->action == WOLFOS_ACTION_BLOCKING) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSpheres.base); + } + + if (pthis->slashStatus > 0) { + if (!(pthis->colliderSpheres.base.atFlags & AT_BOUNCED)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSpheres.base); + } else { + EnWf_SetupRecoilFromBlockedSlash(pthis); + } + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 25.0f; + + if (pthis->eyeIndex == 0) { + if ((Rand_ZeroOne() < 0.2f) && ((globalCtx->gameplayFrames % 4) == 0) && (pthis->actor.colorFilterTimer == 0)) { + pthis->eyeIndex++; + } + } else { + pthis->eyeIndex = (pthis->eyeIndex + 1) & 3; + } +} + +s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnWf* pthis = (EnWf*)thisx; + + if ((limbIndex == WOLFOS_LIMB_HEAD) || (limbIndex == WOLFOS_LIMB_EYES)) { + rot->y -= pthis->unk_4D4.y; + } + + return false; +} + +void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + static Vec3f colliderVec = { 1200.0f, 0.0f, 0.0f }; + static Vec3f bodyPartVec = { 0.0f, 0.0f, 0.0f }; + EnWf* pthis = (EnWf*)thisx; + s32 bodyPartIndex = -1; + + Collider_UpdateSpheres(limbIndex, &pthis->colliderSpheres); + + if (limbIndex == WOLFOS_LIMB_TAIL) { + Vec3f colliderPos; + + bodyPartIndex = -1; + Matrix_MultVec3f(&colliderVec, &colliderPos); + pthis->colliderCylinderTail.dim.pos.x = colliderPos.x; + pthis->colliderCylinderTail.dim.pos.y = colliderPos.y; + pthis->colliderCylinderTail.dim.pos.z = colliderPos.z; + } + + if ((pthis->fireTimer != 0) || ((pthis->actor.colorFilterTimer != 0) && (pthis->actor.colorFilterParams & 0x4000))) { + switch (limbIndex) { + case WOLFOS_LIMB_EYES: + bodyPartIndex = 0; + break; + case WOLFOS_LIMB_FRONT_RIGHT_LOWER_LEG: + bodyPartIndex = 1; + break; + case WOLFOS_LIMB_FRONT_LEFT_LOWER_LEG: + bodyPartIndex = 2; + break; + case WOLFOS_LIMB_THORAX: + bodyPartIndex = 3; + break; + case WOLFOS_LIMB_ABDOMEN: + bodyPartIndex = 4; + break; + case WOLFOS_LIMB_TAIL: + bodyPartIndex = 5; + break; + case WOLFOS_LIMB_BACK_RIGHT_SHIN: + bodyPartIndex = 6; + break; + case 37: + //! @bug There is no limb with index pthis large, so bodyPartsPos[7] is uninitialised. Thus a flame will + //! be drawn at 0,0,0 when the Wolfos is on fire. + bodyPartIndex = 7; + break; + case WOLFOS_LIMB_BACK_RIGHT_PASTERN: + bodyPartIndex = 8; + break; + case WOLFOS_LIMB_BACK_LEFT_PAW: + bodyPartIndex = 9; + break; + } + + if (bodyPartIndex >= 0) { + Vec3f bodyPartPos; + + Matrix_MultVec3f(&bodyPartVec, &bodyPartPos); + pthis->bodyPartsPos[bodyPartIndex].x = bodyPartPos.x; + pthis->bodyPartsPos[bodyPartIndex].y = bodyPartPos.y; + pthis->bodyPartsPos[bodyPartIndex].z = bodyPartPos.z; + } + } +} + +static void* sWolfosNormalEyeTextures[] = { gWolfosNormalEyeOpenTex, gWolfosNormalEyeHalfTex, gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex }; +static void* sWolfosWhiteEyeTextures[] = { gWolfosWhiteEyeOpenTex, gWolfosWhiteEyeHalfTex, gWolfosWhiteEyeNarrowTex, + gWolfosWhiteEyeHalfTex }; + +void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWf* pthis = (EnWf*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_wf.c", 2157); + + // This conditional will always evaluate to true, since unk_300 is false whenever action is + // WOLFOS_ACTION_WAIT_TO_APPEAR. + if ((pthis->action != WOLFOS_ACTION_WAIT_TO_APPEAR) || !pthis->unk_300) { + func_80093D18(globalCtx->state.gfxCtx); + + if (pthis->actor.params == WOLFOS_NORMAL) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sWolfosNormalEyeTextures[pthis->eyeIndex])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sWolfosWhiteEyeTextures[pthis->eyeIndex])); + } + + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &pthis->actor); + + if (pthis->fireTimer != 0) { + pthis->actor.colorFilterTimer++; + if (1) {} + pthis->fireTimer--; + + if ((pthis->fireTimer % 4) == 0) { + s32 fireIndex = pthis->fireTimer >> 2; + + EffectSsEnFire_SpawnVec3s(globalCtx, &pthis->actor, &pthis->bodyPartsPos[fireIndex], 75, 0, 0, fireIndex); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_wf.c", 2190); +} + +s32 EnWf_DodgeRanged(GlobalContext* globalCtx, EnWf* pthis) { + Actor* actor = Actor_GetProjectileActor(globalCtx, &pthis->actor, 600.0f); + + if (actor != NULL) { + s16 angleToFacing; + s16 pad; + f32 dist; + + angleToFacing = Actor_WorldYawTowardActor(&pthis->actor, actor) - pthis->actor.shape.rot.y; + pthis->actor.world.rot.y = (u16)pthis->actor.shape.rot.y & 0xFFFF; + dist = Actor_WorldDistXYZToPoint(&pthis->actor, &actor->world.pos); + + if ((ABS(angleToFacing) < 0x2EE0) && (sqrt(dist) < 400.0)) { + EnWf_SetupBlocking(pthis); + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + if ((ABS(angleToFacing) < 0x2000) || (ABS(angleToFacing) > 0x5FFF)) { + EnWf_SetupSidestep(pthis, globalCtx); + pthis->actor.speedXZ *= 2.0f; + } else if (ABS(angleToFacing) < 0x5FFF) { + EnWf_SetupBackflipAway(pthis); + } + } + return true; + } + + return false; +} diff --git a/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c b/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c deleted file mode 100644 index e5936fc7c..000000000 --- a/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c +++ /dev/null @@ -1,354 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WONDER_ITEM_Z_EN_WONDER_ITEM_C -#include "actor_common.h" -/* - * File: z_en_wonder_item.c - * Overlay: ovl_En_Wonder_Item - * Description: Invisible Collectable; Used in MQ to create "Cow" switches - */ - -#include "z_en_wonder_item.h" -#include "vt.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void EnWonderItem_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWonderItem_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWonderItem_Update(Actor* thisx, GlobalContext* globalCtx); - -void EnWonderItem_MultitagFree(EnWonderItem* this, GlobalContext* globalCtx); -void EnWonderItem_ProximityDrop(EnWonderItem* this, GlobalContext* globalCtx); -void EnWonderItem_InteractSwitch(EnWonderItem* this, GlobalContext* globalCtx); -void EnWonderItem_ProximitySwitch(EnWonderItem* this, GlobalContext* globalCtx); -void EnWonderItem_MultitagOrdered(EnWonderItem* this, GlobalContext* globalCtx); -void EnWonderItem_BombSoldier(EnWonderItem* this, GlobalContext* globalCtx); -void EnWonderItem_RollDrop(EnWonderItem* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { 20, 30, 0, { 0, 0, 0 } }, -}; - -const ActorInit En_Wonder_Item_InitVars = { - ACTOR_EN_WONDER_ITEM, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(EnWonderItem), - (ActorFunc)EnWonderItem_Init, - (ActorFunc)EnWonderItem_Destroy, - (ActorFunc)EnWonderItem_Update, - NULL, -}; - -static Vec3f sTagPointsFree[9]; -static Vec3f sTagPointsOrdered[9]; - -void EnWonderItem_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnWonderItem* this = (EnWonderItem*)thisx; - - if ((this->collider.dim.radius != 0) || (this->collider.dim.height != 0)) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void EnWonderItem_DropCollectible(EnWonderItem* this, GlobalContext* globalCtx, s32 autoCollect) { - static s16 dropTable[] = { - ITEM00_NUTS, ITEM00_HEART_PIECE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_SMALL, - ITEM00_HEART, ITEM00_ARROWS_SMALL, ITEM00_ARROWS_MEDIUM, ITEM00_ARROWS_LARGE, - ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_FLEXIBLE, - }; - s32 i; - s32 randomDrop; - - func_80078884(NA_SE_SY_GET_ITEM); - - if (this->dropCount == 0) { - this->dropCount++; - } - for (i = this->dropCount; i > 0; i--) { - if (this->itemDrop < WONDERITEM_DROP_RANDOM) { - if ((this->itemDrop == WONDERITEM_DROP_FLEXIBLE) || !autoCollect) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, dropTable[this->itemDrop]); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, dropTable[this->itemDrop] | 0x8000); - } - } else { - randomDrop = this->itemDrop - WONDERITEM_DROP_RANDOM; - if (!autoCollect) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, randomDrop); - } else { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, randomDrop | 0x8000); - } - } - } - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - Actor_Kill(&this->actor); -} - -void EnWonderItem_Init(Actor* thisx, GlobalContext* globalCtx) { - static u32 collisionTypes[] = { - 0x00000702 /* sword slash */, 0x0001F820 /* arrow */, 0x00000040 /* hammer */, 0x00000008 /* bomb */, - 0x00000004 /* slingshot */, 0x00000010 /* boomerang */, 0x00000080 /* hookshot */, - }; - s32 pad; - s16 colTypeIndex; - EnWonderItem* this = (EnWonderItem*)thisx; - s16 rotZover10; - s16 tagIndex; - - osSyncPrintf("\n\n"); - // "Mysterious mystery, very mysterious" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 不思議不思議まか不思議 \t ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); - this->actor.flags &= ~ACTOR_FLAG_0; - - this->wonderMode = (this->actor.params >> 0xB) & 0x1F; - this->itemDrop = (this->actor.params >> 6) & 0x1F; - this->switchFlag = this->actor.params & 0x3F; - if (this->switchFlag == 0x3F) { - this->switchFlag = -1; - } - this->actor.targetMode = 1; - if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - Actor_Kill(&this->actor); - return; - } - switch (this->wonderMode) { - case WONDERITEM_MULTITAG_FREE: - this->numTagPoints = this->actor.world.rot.z & 0xF; - rotZover10 = 0; - if (this->actor.world.rot.z >= 10) { - rotZover10 = this->actor.world.rot.z / 10; - this->timerMod = rotZover10 * 20; - } - this->numTagPoints = this->actor.world.rot.z - rotZover10 * 10; - // i.e timerMod = rot.z / 10 seconds, numTagPoints = rot.z % 10 - this->updateFunc = EnWonderItem_MultitagFree; - break; - case WONDERITEM_TAG_POINT_FREE: - tagIndex = this->actor.world.rot.z & 0xFF; - sTagPointsFree[tagIndex] = this->actor.world.pos; - Actor_Kill(&this->actor); - break; - case WONDERITEM_PROXIMITY_DROP: - this->dropCount = this->actor.world.rot.z & 0xFF; - this->updateFunc = EnWonderItem_ProximityDrop; - break; - case WONDERITEM_INTERACT_SWITCH: - colTypeIndex = this->actor.world.rot.z & 0xFF; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->collider.info.bumper.dmgFlags = collisionTypes[colTypeIndex]; - this->collider.dim.radius = 20; - this->collider.dim.height = 30; - this->updateFunc = EnWonderItem_InteractSwitch; - break; - case WONDERITEM_UNUSED: - break; - case WONDERITEM_MULTITAG_ORDERED: - this->numTagPoints = this->actor.world.rot.z & 0xF; - rotZover10 = 0; - if (this->actor.world.rot.z >= 10) { - rotZover10 = this->actor.world.rot.z / 10; - this->timerMod = rotZover10 * 20; - } - this->numTagPoints = this->actor.world.rot.z - rotZover10 * 10; - // i.e timerMod = rot.z / 10 seconds, numTagPoints = rot.z % 10 - this->updateFunc = EnWonderItem_MultitagOrdered; - break; - case WONDERITEM_TAG_POINT_ORDERED: - tagIndex = this->actor.world.rot.z & 0xFF; - sTagPointsOrdered[tagIndex] = this->actor.world.pos; - Actor_Kill(&this->actor); - break; - case WONDERITEM_PROXIMITY_SWITCH: - this->updateFunc = EnWonderItem_ProximitySwitch; - break; - case WONDERITEM_BOMB_SOLDIER: - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->collider.info.bumper.dmgFlags = 0x00000004; // slingshot - this->unkPos = this->actor.world.pos; - this->collider.dim.radius = 35; - this->collider.dim.height = 75; - this->updateFunc = EnWonderItem_BombSoldier; - break; - case WONDERITEM_ROLL_DROP: - this->dropCount = this->actor.world.rot.z & 0xFF; - this->updateFunc = EnWonderItem_RollDrop; - break; - default: - Actor_Kill(&this->actor); - break; - } -} - -void EnWonderItem_MultitagFree(EnWonderItem* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 prevTagFlags = this->tagFlags; - s32 i; - s32 mask; - - for (i = 0, mask = 1; i < this->numTagPoints; i++, mask <<= 1) { - if (!(prevTagFlags & mask)) { - f32 dx = player->actor.world.pos.x - sTagPointsFree[i].x; - f32 dy = player->actor.world.pos.y - sTagPointsFree[i].y; - f32 dz = player->actor.world.pos.z - sTagPointsFree[i].z; - - if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 50.0f) { - this->tagFlags |= mask; - this->tagCount++; - this->timer = this->timerMod + 81; - return; - } - } - } - if (this->timer == 1) { - Actor_Kill(&this->actor); - return; - } - if (this->tagCount == this->numTagPoints) { - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - EnWonderItem_DropCollectible(this, globalCtx, true); - } -} - -void EnWonderItem_ProximityDrop(EnWonderItem* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((this->actor.xzDistToPlayer < 50.0f) && (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) < 30.0f)) { - EnWonderItem_DropCollectible(this, globalCtx, true); - } -} - -void EnWonderItem_InteractSwitch(EnWonderItem* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - EnWonderItem_DropCollectible(this, globalCtx, false); - } -} - -void EnWonderItem_ProximitySwitch(EnWonderItem* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((this->actor.xzDistToPlayer < 50.0f) && (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) < 30.0f)) { - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - Actor_Kill(&this->actor); - } -} - -void EnWonderItem_MultitagOrdered(EnWonderItem* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 prevTagFlags = this->tagFlags; - s32 i; - s32 mask; - - for (i = 0, mask = 1; i < this->numTagPoints; i++, mask <<= 1) { - if (!(prevTagFlags & mask)) { - f32 dx = player->actor.world.pos.x - sTagPointsOrdered[i].x; - f32 dy = player->actor.world.pos.y - sTagPointsOrdered[i].y; - f32 dz = player->actor.world.pos.z - sTagPointsOrdered[i].z; - - if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 50.0f) { - if (prevTagFlags & mask) { - return; - } else if (i == this->nextTag) { - this->tagFlags |= mask; - this->tagCount++; - this->nextTag++; - this->timer = this->timerMod + 81; - return; - } else { - Actor_Kill(&this->actor); - return; - } - } - } - } - if (this->timer == 1) { - Actor_Kill(&this->actor); - return; - } - if (this->tagCount == this->numTagPoints) { - EnWonderItem_DropCollectible(this, globalCtx, true); - } -} - -void EnWonderItem_BombSoldier(EnWonderItem* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HEISHI2, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.yawTowardsPlayer, 0, - 9) != NULL) { - // "Careless soldier spawned" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ うっかり兵セット完了 ☆☆☆☆☆ \n" VT_RST); - } - if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); - } - Actor_Kill(&this->actor); - } -} - -void EnWonderItem_RollDrop(EnWonderItem* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if ((this->actor.xzDistToPlayer < 50.0f) && (player->invincibilityTimer < 0) && - (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) < 30.0f)) { - EnWonderItem_DropCollectible(this, globalCtx, true); - } -} - -void EnWonderItem_Update(Actor* thisx, GlobalContext* globalCtx) { - static s16 debugArrowColors[] = { - 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 128, 128, - 128, 128, 128, 0, 128, 0, 128, 0, 128, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, - }; // These seem to be mistyped. Logically they should be s16[13][3] and be indexed as [colorIndex][i] - s32 pad; - EnWonderItem* this = (EnWonderItem*)thisx; - s32 colorIndex; - - if (this->timer != 0) { - this->timer--; - } - this->updateFunc(this, globalCtx); - - if (this->wonderMode == WONDERITEM_UNUSED) { - Actor_SetFocus(&this->actor, this->unkHeight); - } - if ((this->wonderMode == WONDERITEM_INTERACT_SWITCH) || (this->wonderMode == WONDERITEM_BOMB_SOLDIER)) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - colorIndex = this->wonderMode; - if (this->wonderMode > 12) { - colorIndex = 0; - } -} diff --git a/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.cpp b/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.cpp new file mode 100644 index 000000000..897d1f8c0 --- /dev/null +++ b/src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.cpp @@ -0,0 +1,354 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WONDER_ITEM_Z_EN_WONDER_ITEM_C +#include "actor_common.h" +/* + * File: z_en_wonder_item.c + * Overlay: ovl_En_Wonder_Item + * Description: Invisible Collectable; Used in MQ to create "Cow" switches + */ + +#include "z_en_wonder_item.h" +#include "vt.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void EnWonderItem_Init(Actor* thisx, GlobalContext* globalCtx); +void EnWonderItem_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnWonderItem_Update(Actor* thisx, GlobalContext* globalCtx); + +void EnWonderItem_MultitagFree(EnWonderItem* pthis, GlobalContext* globalCtx); +void EnWonderItem_ProximityDrop(EnWonderItem* pthis, GlobalContext* globalCtx); +void EnWonderItem_InteractSwitch(EnWonderItem* pthis, GlobalContext* globalCtx); +void EnWonderItem_ProximitySwitch(EnWonderItem* pthis, GlobalContext* globalCtx); +void EnWonderItem_MultitagOrdered(EnWonderItem* pthis, GlobalContext* globalCtx); +void EnWonderItem_BombSoldier(EnWonderItem* pthis, GlobalContext* globalCtx); +void EnWonderItem_RollDrop(EnWonderItem* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { 20, 30, 0, { 0, 0, 0 } }, +}; + +ActorInit En_Wonder_Item_InitVars = { + ACTOR_EN_WONDER_ITEM, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(EnWonderItem), + (ActorFunc)EnWonderItem_Init, + (ActorFunc)EnWonderItem_Destroy, + (ActorFunc)EnWonderItem_Update, + NULL, +}; + +static Vec3f sTagPointsFree[9]; +static Vec3f sTagPointsOrdered[9]; + +void EnWonderItem_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWonderItem* pthis = (EnWonderItem*)thisx; + + if ((pthis->collider.dim.radius != 0) || (pthis->collider.dim.height != 0)) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void EnWonderItem_DropCollectible(EnWonderItem* pthis, GlobalContext* globalCtx, s32 autoCollect) { + static s16 dropTable[] = { + ITEM00_NUTS, ITEM00_HEART_PIECE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_SMALL, + ITEM00_HEART, ITEM00_ARROWS_SMALL, ITEM00_ARROWS_MEDIUM, ITEM00_ARROWS_LARGE, + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_FLEXIBLE, + }; + s32 i; + s32 randomDrop; + + func_80078884(NA_SE_SY_GET_ITEM); + + if (pthis->dropCount == 0) { + pthis->dropCount++; + } + for (i = pthis->dropCount; i > 0; i--) { + if (pthis->itemDrop < WONDERITEM_DROP_RANDOM) { + if ((pthis->itemDrop == WONDERITEM_DROP_FLEXIBLE) || !autoCollect) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, dropTable[pthis->itemDrop]); + } else { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, dropTable[pthis->itemDrop] | 0x8000); + } + } else { + randomDrop = pthis->itemDrop - WONDERITEM_DROP_RANDOM; + if (!autoCollect) { + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, randomDrop); + } else { + Item_DropCollectibleRandom(globalCtx, NULL, &pthis->actor.world.pos, randomDrop | 0x8000); + } + } + } + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + Actor_Kill(&pthis->actor); +} + +void EnWonderItem_Init(Actor* thisx, GlobalContext* globalCtx) { + static u32 collisionTypes[] = { + 0x00000702 /* sword slash */, 0x0001F820 /* arrow */, 0x00000040 /* hammer */, 0x00000008 /* bomb */, + 0x00000004 /* slingshot */, 0x00000010 /* boomerang */, 0x00000080 /* hookshot */, + }; + s32 pad; + s16 colTypeIndex; + EnWonderItem* pthis = (EnWonderItem*)thisx; + s16 rotZover10; + s16 tagIndex; + + osSyncPrintf("\n\n"); + // "Mysterious mystery, very mysterious" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 不思議不思議まか不思議 \t ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); + pthis->actor.flags &= ~ACTOR_FLAG_0; + + pthis->wonderMode = (pthis->actor.params >> 0xB) & 0x1F; + pthis->itemDrop = (pthis->actor.params >> 6) & 0x1F; + pthis->switchFlag = pthis->actor.params & 0x3F; + if (pthis->switchFlag == 0x3F) { + pthis->switchFlag = -1; + } + pthis->actor.targetMode = 1; + if ((pthis->switchFlag >= 0) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + Actor_Kill(&pthis->actor); + return; + } + switch (pthis->wonderMode) { + case WONDERITEM_MULTITAG_FREE: + pthis->numTagPoints = pthis->actor.world.rot.z & 0xF; + rotZover10 = 0; + if (pthis->actor.world.rot.z >= 10) { + rotZover10 = pthis->actor.world.rot.z / 10; + pthis->timerMod = rotZover10 * 20; + } + pthis->numTagPoints = pthis->actor.world.rot.z - rotZover10 * 10; + // i.e timerMod = rot.z / 10 seconds, numTagPoints = rot.z % 10 + pthis->updateFunc = EnWonderItem_MultitagFree; + break; + case WONDERITEM_TAG_POINT_FREE: + tagIndex = pthis->actor.world.rot.z & 0xFF; + sTagPointsFree[tagIndex] = pthis->actor.world.pos; + Actor_Kill(&pthis->actor); + break; + case WONDERITEM_PROXIMITY_DROP: + pthis->dropCount = pthis->actor.world.rot.z & 0xFF; + pthis->updateFunc = EnWonderItem_ProximityDrop; + break; + case WONDERITEM_INTERACT_SWITCH: + colTypeIndex = pthis->actor.world.rot.z & 0xFF; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->collider.info.bumper.dmgFlags = collisionTypes[colTypeIndex]; + pthis->collider.dim.radius = 20; + pthis->collider.dim.height = 30; + pthis->updateFunc = EnWonderItem_InteractSwitch; + break; + case WONDERITEM_UNUSED: + break; + case WONDERITEM_MULTITAG_ORDERED: + pthis->numTagPoints = pthis->actor.world.rot.z & 0xF; + rotZover10 = 0; + if (pthis->actor.world.rot.z >= 10) { + rotZover10 = pthis->actor.world.rot.z / 10; + pthis->timerMod = rotZover10 * 20; + } + pthis->numTagPoints = pthis->actor.world.rot.z - rotZover10 * 10; + // i.e timerMod = rot.z / 10 seconds, numTagPoints = rot.z % 10 + pthis->updateFunc = EnWonderItem_MultitagOrdered; + break; + case WONDERITEM_TAG_POINT_ORDERED: + tagIndex = pthis->actor.world.rot.z & 0xFF; + sTagPointsOrdered[tagIndex] = pthis->actor.world.pos; + Actor_Kill(&pthis->actor); + break; + case WONDERITEM_PROXIMITY_SWITCH: + pthis->updateFunc = EnWonderItem_ProximitySwitch; + break; + case WONDERITEM_BOMB_SOLDIER: + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->collider.info.bumper.dmgFlags = 0x00000004; // slingshot + pthis->unkPos = pthis->actor.world.pos; + pthis->collider.dim.radius = 35; + pthis->collider.dim.height = 75; + pthis->updateFunc = EnWonderItem_BombSoldier; + break; + case WONDERITEM_ROLL_DROP: + pthis->dropCount = pthis->actor.world.rot.z & 0xFF; + pthis->updateFunc = EnWonderItem_RollDrop; + break; + default: + Actor_Kill(&pthis->actor); + break; + } +} + +void EnWonderItem_MultitagFree(EnWonderItem* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 prevTagFlags = pthis->tagFlags; + s32 i; + s32 mask; + + for (i = 0, mask = 1; i < pthis->numTagPoints; i++, mask <<= 1) { + if (!(prevTagFlags & mask)) { + f32 dx = player->actor.world.pos.x - sTagPointsFree[i].x; + f32 dy = player->actor.world.pos.y - sTagPointsFree[i].y; + f32 dz = player->actor.world.pos.z - sTagPointsFree[i].z; + + if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 50.0f) { + pthis->tagFlags |= mask; + pthis->tagCount++; + pthis->timer = pthis->timerMod + 81; + return; + } + } + } + if (pthis->timer == 1) { + Actor_Kill(&pthis->actor); + return; + } + if (pthis->tagCount == pthis->numTagPoints) { + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + EnWonderItem_DropCollectible(pthis, globalCtx, true); + } +} + +void EnWonderItem_ProximityDrop(EnWonderItem* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->actor.xzDistToPlayer < 50.0f) && (fabsf(pthis->actor.world.pos.y - player->actor.world.pos.y) < 30.0f)) { + EnWonderItem_DropCollectible(pthis, globalCtx, true); + } +} + +void EnWonderItem_InteractSwitch(EnWonderItem* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + EnWonderItem_DropCollectible(pthis, globalCtx, false); + } +} + +void EnWonderItem_ProximitySwitch(EnWonderItem* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->actor.xzDistToPlayer < 50.0f) && (fabsf(pthis->actor.world.pos.y - player->actor.world.pos.y) < 30.0f)) { + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + Actor_Kill(&pthis->actor); + } +} + +void EnWonderItem_MultitagOrdered(EnWonderItem* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 prevTagFlags = pthis->tagFlags; + s32 i; + s32 mask; + + for (i = 0, mask = 1; i < pthis->numTagPoints; i++, mask <<= 1) { + if (!(prevTagFlags & mask)) { + f32 dx = player->actor.world.pos.x - sTagPointsOrdered[i].x; + f32 dy = player->actor.world.pos.y - sTagPointsOrdered[i].y; + f32 dz = player->actor.world.pos.z - sTagPointsOrdered[i].z; + + if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 50.0f) { + if (prevTagFlags & mask) { + return; + } else if (i == pthis->nextTag) { + pthis->tagFlags |= mask; + pthis->tagCount++; + pthis->nextTag++; + pthis->timer = pthis->timerMod + 81; + return; + } else { + Actor_Kill(&pthis->actor); + return; + } + } + } + } + if (pthis->timer == 1) { + Actor_Kill(&pthis->actor); + return; + } + if (pthis->tagCount == pthis->numTagPoints) { + EnWonderItem_DropCollectible(pthis, globalCtx, true); + } +} + +void EnWonderItem_BombSoldier(EnWonderItem* pthis, GlobalContext* globalCtx) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HEISHI2, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, pthis->actor.yawTowardsPlayer, 0, + 9) != NULL) { + // "Careless soldier spawned" + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ うっかり兵セット完了 ☆☆☆☆☆ \n" VT_RST); + } + if (pthis->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); + } + Actor_Kill(&pthis->actor); + } +} + +void EnWonderItem_RollDrop(EnWonderItem* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((pthis->actor.xzDistToPlayer < 50.0f) && (player->invincibilityTimer < 0) && + (fabsf(pthis->actor.world.pos.y - player->actor.world.pos.y) < 30.0f)) { + EnWonderItem_DropCollectible(pthis, globalCtx, true); + } +} + +void EnWonderItem_Update(Actor* thisx, GlobalContext* globalCtx) { + static s16 debugArrowColors[] = { + 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 128, 128, + 128, 128, 128, 0, 128, 0, 128, 0, 128, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, + }; // These seem to be mistyped. Logically they should be s16[13][3] and be indexed as [colorIndex][i] + s32 pad; + EnWonderItem* pthis = (EnWonderItem*)thisx; + s32 colorIndex; + + if (pthis->timer != 0) { + pthis->timer--; + } + pthis->updateFunc(pthis, globalCtx); + + if (pthis->wonderMode == WONDERITEM_UNUSED) { + Actor_SetFocus(&pthis->actor, pthis->unkHeight); + } + if ((pthis->wonderMode == WONDERITEM_INTERACT_SWITCH) || (pthis->wonderMode == WONDERITEM_BOMB_SOLDIER)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + colorIndex = pthis->wonderMode; + if (pthis->wonderMode > 12) { + colorIndex = 0; + } +} diff --git a/src/overlays/actors/ovl_En_Wonder_Talk/z_en_wonder_talk.c b/src/overlays/actors/ovl_En_Wonder_Talk/z_en_wonder_talk.cpp similarity index 50% rename from src/overlays/actors/ovl_En_Wonder_Talk/z_en_wonder_talk.c rename to src/overlays/actors/ovl_En_Wonder_Talk/z_en_wonder_talk.cpp index eacb2ec8b..9399143dd 100644 --- a/src/overlays/actors/ovl_En_Wonder_Talk/z_en_wonder_talk.c +++ b/src/overlays/actors/ovl_En_Wonder_Talk/z_en_wonder_talk.cpp @@ -18,11 +18,11 @@ void EnWonderTalk_Init(Actor* thisx, GlobalContext* globalCtx); void EnWonderTalk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWonderTalk_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80B391CC(EnWonderTalk* this, GlobalContext* globalCtx); -void func_80B395F0(EnWonderTalk* this, GlobalContext* globalCtx); -void func_80B3943C(EnWonderTalk* this, GlobalContext* globalCtx); +void func_80B391CC(EnWonderTalk* pthis, GlobalContext* globalCtx); +void func_80B395F0(EnWonderTalk* pthis, GlobalContext* globalCtx); +void func_80B3943C(EnWonderTalk* pthis, GlobalContext* globalCtx); -const ActorInit En_Wonder_Talk_InitVars = { +ActorInit En_Wonder_Talk_InitVars = { ACTOR_EN_WONDER_TALK, ACTORCAT_PROP, FLAGS, @@ -38,155 +38,155 @@ void EnWonderTalk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnWonderTalk_Init(Actor* thisx, GlobalContext* globalCtx) { - EnWonderTalk* this = (EnWonderTalk*)thisx; + EnWonderTalk* pthis = (EnWonderTalk*)thisx; osSyncPrintf("\n\n"); // "Special conversation" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 特殊会話くん ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 特殊会話くん ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); - this->unk_150 = (this->actor.params >> 0xB) & 0x1F; - this->unk_152 = (this->actor.params >> 6) & 0x1F; - this->switchFlag = this->actor.params & 0x3F; - if (this->switchFlag == 0x3F) { - this->switchFlag = -1; + pthis->unk_150 = (pthis->actor.params >> 0xB) & 0x1F; + pthis->unk_152 = (pthis->actor.params >> 6) & 0x1F; + pthis->switchFlag = pthis->actor.params & 0x3F; + if (pthis->switchFlag == 0x3F) { + pthis->switchFlag = -1; } - this->actor.targetMode = 1; - if (this->switchFlag >= 0) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - Actor_Kill(&this->actor); + pthis->actor.targetMode = 1; + if (pthis->switchFlag >= 0) { + if (Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + Actor_Kill(&pthis->actor); return; } } - this->actionFunc = func_80B391CC; - this->unk_15C = 40.0f; + pthis->actionFunc = func_80B391CC; + pthis->unk_15C = 40.0f; } -void func_80B391CC(EnWonderTalk* this, GlobalContext* globalCtx) { - if (this->switchFlag < 0 || !Flags_GetSwitch(globalCtx, this->switchFlag)) { - switch (this->unk_150) { +void func_80B391CC(EnWonderTalk* pthis, GlobalContext* globalCtx) { + if (pthis->switchFlag < 0 || !Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + switch (pthis->unk_150) { case 1: // "Slate GO!" osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 石板GO! ☆☆☆☆☆ \n" VT_RST); - this->height = 0.0f; - this->unk_15C = 80.0f; + pthis->height = 0.0f; + pthis->unk_15C = 80.0f; // "Attention coordinates" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f); if (!LINK_IS_ADULT) { - this->actor.textId = 0x7040; + pthis->actor.textId = 0x7040; // "Children" osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ こども ☆☆☆☆☆ \n" VT_RST); } else { // "Adult" osSyncPrintf(VT_FGCOL(CYAN) " ☆☆☆☆☆ おとな ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x7088; + pthis->actor.textId = 0x7088; } - this->unk_156 = TEXT_STATE_EVENT; - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ this->actor.talk_message ☆☆☆☆☆ %x\n" VT_RST, this->actor.textId); + pthis->unk_156 = TEXT_STATE_EVENT; + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ pthis->actor.talk_message ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.textId); break; case 2: // "Diary start!" osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 日記帳スタート! ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x5002; - this->unk_156 = TEXT_STATE_CHOICE; - this->height = 30.0f; - this->unk_15C = 40.0f; + pthis->actor.textId = 0x5002; + pthis->unk_156 = TEXT_STATE_CHOICE; + pthis->height = 30.0f; + pthis->unk_15C = 40.0f; // "Attention coordinates" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 30.0f); break; case 3: - this->actor.textId = 0x501E; - this->unk_156 = TEXT_STATE_EVENT; - this->height = 0.0f; - this->unk_15C = 110.0f; + pthis->actor.textId = 0x501E; + pthis->unk_156 = TEXT_STATE_EVENT; + pthis->height = 0.0f; + pthis->unk_15C = 110.0f; // "Attention coordinates" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f); break; case 4: - this->actor.textId = 0x5020; - this->unk_156 = TEXT_STATE_DONE; - this->height = 0.0f; + pthis->actor.textId = 0x5020; + pthis->unk_156 = TEXT_STATE_DONE; + pthis->height = 0.0f; // "Attention coordinates" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f); - this->unk_15C = 120.0f; + pthis->unk_15C = 120.0f; if (gSaveContext.eventChkInf[1] & 0x2000) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } break; case 5: - this->actor.textId = 0x501F; - this->unk_156 = TEXT_STATE_EVENT; - this->height = 0.0f; - this->unk_15C = 110.0f; + pthis->actor.textId = 0x501F; + pthis->unk_156 = TEXT_STATE_EVENT; + pthis->height = 0.0f; + pthis->unk_15C = 110.0f; // "Attention coordinates" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f); break; default: - this->actor.textId = 0x7072; - this->unk_156 = TEXT_STATE_EVENT; + pthis->actor.textId = 0x7072; + pthis->unk_156 = TEXT_STATE_EVENT; break; } - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ this->actor.talk_message ☆☆☆☆☆ %x\n" VT_RST, this->actor.textId); - this->actionFunc = func_80B3943C; + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ pthis->actor.talk_message ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.textId); + pthis->actionFunc = func_80B3943C; } } -void func_80B3943C(EnWonderTalk* this, GlobalContext* globalCtx) { +void func_80B3943C(EnWonderTalk* pthis, GlobalContext* globalCtx) { s16 yawDiff; s16 yawDiffTemp; - this->unk_15A++; - if (this->unk_150 == 4 && (gSaveContext.eventChkInf[1] & 0x2000)) { - Actor_Kill(&this->actor); + pthis->unk_15A++; + if (pthis->unk_150 == 4 && (gSaveContext.eventChkInf[1] & 0x2000)) { + Actor_Kill(&pthis->actor); return; } - if (this->switchFlag < 0 || !Flags_GetSwitch(globalCtx, this->switchFlag)) { - if ((Actor_ProcessTalkRequest(&this->actor, globalCtx))) { - if (this->unk_156 != TEXT_STATE_DONE) { - this->actionFunc = func_80B395F0; + if (pthis->switchFlag < 0 || !Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if ((Actor_ProcessTalkRequest(&pthis->actor, globalCtx))) { + if (pthis->unk_156 != TEXT_STATE_DONE) { + pthis->actionFunc = func_80B395F0; } else { - if (this->switchFlag >= 0) { - this->actor.flags &= ~ACTOR_FLAG_0; - Flags_SetSwitch(globalCtx, this->switchFlag); + if (pthis->switchFlag >= 0) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + Flags_SetSwitch(globalCtx, pthis->switchFlag); } - this->actionFunc = func_80B391CC; + pthis->actionFunc = func_80B391CC; } - } else if (!(this->unk_15C < this->actor.xzDistToPlayer)) { - yawDiffTemp = (this->actor.yawTowardsPlayer - this->actor.world.rot.y); + } else if (!(pthis->unk_15C < pthis->actor.xzDistToPlayer)) { + yawDiffTemp = (pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y); yawDiff = ABS(yawDiffTemp); if (yawDiff < 0x4000) { - if (this->unk_15A >= 2) { + if (pthis->unk_15A >= 2) { osSyncPrintf("\n\n"); // "Save information" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報\t\t☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報\t\t☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); // "Type index" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 種類インデックス\t☆☆☆☆☆ %d\n" VT_RST, this->unk_150); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 種類インデックス\t☆☆☆☆☆ %d\n" VT_RST, pthis->unk_150); // "Actual message type" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, this->actor.textId); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, pthis->actor.textId); // "Specified range" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, this->actor.world.rot.z); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, pthis->actor.world.rot.z); osSyncPrintf("\n\n"); } - this->unk_15A = 0; - func_8002F2CC(&this->actor, globalCtx, this->unk_15C); + pthis->unk_15A = 0; + func_8002F2CC(&pthis->actor, globalCtx, pthis->unk_15C); } } } } -void func_80B395F0(EnWonderTalk* this, GlobalContext* globalCtx) { - if (this->unk_156 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { - if (this->switchFlag >= 0) { - this->actor.flags &= ~ACTOR_FLAG_0; - Flags_SetSwitch(globalCtx, this->switchFlag); +void func_80B395F0(EnWonderTalk* pthis, GlobalContext* globalCtx) { + if (pthis->unk_156 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) { + if (pthis->switchFlag >= 0) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + Flags_SetSwitch(globalCtx, pthis->switchFlag); } - switch (this->unk_150) { + switch (pthis->unk_150) { case 1: Message_CloseTextbox(globalCtx); - this->actionFunc = func_80B391CC; + pthis->actionFunc = func_80B391CC; break; case 2: switch (globalCtx->msgCtx.choiceIndex) { @@ -194,53 +194,53 @@ void func_80B395F0(EnWonderTalk* this, GlobalContext* globalCtx) { if (!LINK_IS_ADULT) { // "I'm still a child!" osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ まだコドモなの! ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x5001; + pthis->actor.textId = 0x5001; } else { // "I'm an adult. .. .." osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ アダルトなの。。。 ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x5003; + pthis->actor.textId = 0x5003; } break; case 1: // "Out!" osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ はずれ! ☆☆☆☆☆ \n" VT_RST); - this->actor.textId = 0x5004; + pthis->actor.textId = 0x5004; break; } - this->unk_156 = TEXT_STATE_DONE; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->actionFunc = func_80B391CC; + pthis->unk_156 = TEXT_STATE_DONE; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->actionFunc = func_80B391CC; break; case 3: Message_CloseTextbox(globalCtx); - if (this->unk_164 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 2); - this->unk_164 = 1; + if (pthis->unk_164 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 2); + pthis->unk_164 = 1; } - this->actionFunc = func_80B391CC; + pthis->actionFunc = func_80B391CC; break; case 5: Message_CloseTextbox(globalCtx); - if (this->unk_164 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 3); - this->unk_164 = 1; + if (pthis->unk_164 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 3); + pthis->unk_164 = 1; } - this->actionFunc = func_80B391CC; + pthis->actionFunc = func_80B391CC; break; } } } void EnWonderTalk_Update(Actor* thisx, GlobalContext* globalCtx) { - EnWonderTalk* this = (EnWonderTalk*)thisx; + EnWonderTalk* pthis = (EnWonderTalk*)thisx; - if (this->unk_158 != 0) { - this->unk_158--; + if (pthis->unk_158 != 0) { + pthis->unk_158--; } - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->actor, this->height); + pthis->actionFunc(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, pthis->height); } diff --git a/src/overlays/actors/ovl_En_Wonder_Talk2/z_en_wonder_talk2.c b/src/overlays/actors/ovl_En_Wonder_Talk2/z_en_wonder_talk2.cpp similarity index 52% rename from src/overlays/actors/ovl_En_Wonder_Talk2/z_en_wonder_talk2.c rename to src/overlays/actors/ovl_En_Wonder_Talk2/z_en_wonder_talk2.cpp index b9927f21c..2132dc815 100644 --- a/src/overlays/actors/ovl_En_Wonder_Talk2/z_en_wonder_talk2.c +++ b/src/overlays/actors/ovl_En_Wonder_Talk2/z_en_wonder_talk2.cpp @@ -18,13 +18,13 @@ void EnWonderTalk2_Init(Actor* thisx, GlobalContext* globalCtx); void EnWonderTalk2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWonderTalk2_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80B3A10C(EnWonderTalk2* this, GlobalContext* globalCtx); -void func_80B3A4F8(EnWonderTalk2* this, GlobalContext* globalCtx); -void func_80B3A15C(EnWonderTalk2* this, GlobalContext* globalCtx); -void func_80B3A3D4(EnWonderTalk2* this, GlobalContext* globalCtx); -void EnWonderTalk2_DoNothing(EnWonderTalk2* this, GlobalContext* globalCtx); +void func_80B3A10C(EnWonderTalk2* pthis, GlobalContext* globalCtx); +void func_80B3A4F8(EnWonderTalk2* pthis, GlobalContext* globalCtx); +void func_80B3A15C(EnWonderTalk2* pthis, GlobalContext* globalCtx); +void func_80B3A3D4(EnWonderTalk2* pthis, GlobalContext* globalCtx); +void EnWonderTalk2_DoNothing(EnWonderTalk2* pthis, GlobalContext* globalCtx); -const ActorInit En_Wonder_Talk2_InitVars = { +ActorInit En_Wonder_Talk2_InitVars = { ACTOR_EN_WONDER_TALK2, ACTORCAT_ITEMACTION, FLAGS, @@ -43,113 +43,113 @@ void EnWonderTalk2_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnWonderTalk2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnWonderTalk2* this = (EnWonderTalk2*)thisx; + EnWonderTalk2* pthis = (EnWonderTalk2*)thisx; osSyncPrintf("\n\n"); // "Transparent message" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 透明メッセージ君 ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); - this->baseMsgId = (this->actor.params >> 6) & 0xFF; - if (this->actor.world.rot.z > 0) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 透明メッセージ君 ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); + pthis->baseMsgId = (pthis->actor.params >> 6) & 0xFF; + if (pthis->actor.world.rot.z > 0) { s32 rangeIndex = 0; - s16 rotZmod10 = this->actor.world.rot.z; + s16 rotZmod10 = pthis->actor.world.rot.z; while (rotZmod10 > 10) { rotZmod10 -= 10; rangeIndex++; } // rangeIndex = rot.z/10 here - this->triggerRange = rotZmod10 * 40.0f; + pthis->triggerRange = rotZmod10 * 40.0f; if (rangeIndex > 6) { rangeIndex = 0; } - this->actor.targetMode = D_80B3A8E0[rangeIndex]; + pthis->actor.targetMode = D_80B3A8E0[rangeIndex]; osSyncPrintf("\n\n"); // "originally?" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 元は? ☆☆☆☆☆ %d\n" VT_RST, this->actor.world.rot.z); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 元は? ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.world.rot.z); // "The range is?" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ レンジは? ☆☆☆☆☆ %d\n" VT_RST, this->actor.targetMode); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ レンジは? ☆☆☆☆☆ %d\n" VT_RST, pthis->actor.targetMode); // "Is the range?" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ は、範囲わ? ☆☆☆☆☆ %f\n" VT_RST, this->triggerRange); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ は、範囲わ? ☆☆☆☆☆ %f\n" VT_RST, pthis->triggerRange); osSyncPrintf("\n\n"); osSyncPrintf("\n\n"); osSyncPrintf("\n\n"); } - this->initPos = this->actor.world.pos; - this->switchFlag = (this->actor.params & 0x3F); - this->talkMode = ((this->actor.params >> 0xE) & 3); + pthis->initPos = pthis->actor.world.pos; + pthis->switchFlag = (pthis->actor.params & 0x3F); + pthis->talkMode = ((pthis->actor.params >> 0xE) & 3); - if (this->switchFlag == 0x3F) { - this->switchFlag = -1; + if (pthis->switchFlag == 0x3F) { + pthis->switchFlag = -1; } - if (this->switchFlag >= 0 && Flags_GetSwitch(globalCtx, this->switchFlag)) { - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag); - Actor_Kill(&this->actor); + if (pthis->switchFlag >= 0 && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ You are Shock! ☆☆☆☆☆ %d\n" VT_RST, pthis->switchFlag); + Actor_Kill(&pthis->actor); return; } - if ((this->talkMode == 1) && (globalCtx->sceneNum == SCENE_MEN) && (this->switchFlag != 0x08) && - (this->switchFlag != 0x16) && (this->switchFlag != 0x2F)) { + if ((pthis->talkMode == 1) && (globalCtx->sceneNum == SCENE_MEN) && (pthis->switchFlag != 0x08) && + (pthis->switchFlag != 0x16) && (pthis->switchFlag != 0x2F)) { - this->unk_15A = false; - this->talkMode = 4; + pthis->unk_15A = false; + pthis->talkMode = 4; } - if (this->talkMode == 3) { - this->actor.flags &= ~ACTOR_FLAG_27; - this->actionFunc = EnWonderTalk2_DoNothing; + if (pthis->talkMode == 3) { + pthis->actor.flags &= ~ACTOR_FLAG_27; + pthis->actionFunc = EnWonderTalk2_DoNothing; } else { - this->actionFunc = func_80B3A10C; + pthis->actionFunc = func_80B3A10C; } } -void func_80B3A10C(EnWonderTalk2* this, GlobalContext* globalCtx) { - this->actor.textId = 0x200; - this->actor.textId |= this->baseMsgId; - if (this->talkMode == 1 || this->talkMode == 4) { - this->actionFunc = func_80B3A4F8; +void func_80B3A10C(EnWonderTalk2* pthis, GlobalContext* globalCtx) { + pthis->actor.textId = 0x200; + pthis->actor.textId |= pthis->baseMsgId; + if (pthis->talkMode == 1 || pthis->talkMode == 4) { + pthis->actionFunc = func_80B3A4F8; } else { - this->actionFunc = func_80B3A15C; + pthis->actionFunc = func_80B3A15C; } } -void func_80B3A15C(EnWonderTalk2* this, GlobalContext* globalCtx) { +void func_80B3A15C(EnWonderTalk2* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk_158++; - if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - if (!this->unk_15A) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_15A = true; + pthis->unk_158++; + if ((pthis->switchFlag >= 0) && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if (!pthis->unk_15A) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_15A = true; } - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - if ((this->switchFlag >= 0) && (this->talkMode != 2)) { - Flags_SetSwitch(globalCtx, this->switchFlag); + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + if ((pthis->switchFlag >= 0) && (pthis->talkMode != 2)) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); // "I saved it! All of it!" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ セーブしたよ!おもいっきり! %x\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ セーブしたよ!おもいっきり! %x\n" VT_RST, pthis->switchFlag); } - this->actionFunc = func_80B3A10C; + pthis->actionFunc = func_80B3A10C; } else { - s16 yawDiff = ABS((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + s16 yawDiff = ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.world.rot.y)); - if (!((this->actor.xzDistToPlayer > 40.0f + this->triggerRange) || - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) > 100.0f) || (yawDiff >= 0x4000))) { - if (this->unk_158 >= 2) { + if (!((pthis->actor.xzDistToPlayer > 40.0f + pthis->triggerRange) || + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) > 100.0f) || (yawDiff >= 0x4000))) { + if (pthis->unk_158 >= 2) { osSyncPrintf("\n\n"); // "Transparent Message Kimi Set" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 透明メッセージ君せっと %x\n" VT_RST, this->actor.params); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 透明メッセージ君せっと %x\n" VT_RST, pthis->actor.params); // "Save Information" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報 \t %x\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報 \t %x\n" VT_RST, pthis->switchFlag); // "Specified message type" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 指定メッセージ種類 %x\n" VT_RST, this->baseMsgId); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 指定メッセージ種類 %x\n" VT_RST, pthis->baseMsgId); // "Actual message type" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, this->actor.textId); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, pthis->actor.textId); // "Specified range" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, this->actor.world.rot.z); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, pthis->actor.world.rot.z); // "Processing range" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 処理範囲 %f\n" VT_RST, this->triggerRange); - switch (this->talkMode) { + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 処理範囲 %f\n" VT_RST, pthis->triggerRange); + switch (pthis->talkMode) { case 0: // "Normal" osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆ 通常 ☆☆ \n" VT_RST); @@ -165,13 +165,13 @@ void func_80B3A15C(EnWonderTalk2* this, GlobalContext* globalCtx) { } } - this->unk_158 = 0; - func_8002F1C4(&this->actor, globalCtx, this->triggerRange + 50.0f, 100.0f, EXCH_ITEM_NONE); + pthis->unk_158 = 0; + func_8002F1C4(&pthis->actor, globalCtx, pthis->triggerRange + 50.0f, 100.0f, EXCH_ITEM_NONE); } } } -void func_80B3A3D4(EnWonderTalk2* this, GlobalContext* globalCtx) { +void func_80B3A3D4(EnWonderTalk2* pthis, GlobalContext* globalCtx) { if (BREG(2) != 0) { // "Oh" osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ わー %d\n" VT_RST, Message_GetState(&globalCtx->msgCtx)); @@ -188,60 +188,60 @@ void func_80B3A3D4(EnWonderTalk2* this, GlobalContext* globalCtx) { break; } case TEXT_STATE_NONE: - if ((this->switchFlag >= 0) && (this->talkMode != 4)) { - Flags_SetSwitch(globalCtx, this->switchFlag); + if ((pthis->switchFlag >= 0) && (pthis->talkMode != 4)) { + Flags_SetSwitch(globalCtx, pthis->switchFlag); // "(Forced) I saved it! All of it!" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ (強制)セーブしたよ!おもいっきり! %x\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ (強制)セーブしたよ!おもいっきり! %x\n" VT_RST, pthis->switchFlag); } - if (this->talkMode == 4) { - this->unk_15A = true; + if (pthis->talkMode == 4) { + pthis->unk_15A = true; } - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_4); + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_4); func_8002DF54(globalCtx, NULL, 7); - this->unk_156 = true; - this->actionFunc = func_80B3A4F8; + pthis->unk_156 = true; + pthis->actionFunc = func_80B3A4F8; break; } } -void func_80B3A4F8(EnWonderTalk2* this, GlobalContext* globalCtx) { +void func_80B3A4F8(EnWonderTalk2* pthis, GlobalContext* globalCtx) { Player* player; player = GET_PLAYER(globalCtx); - this->unk_158++; - if (this->switchFlag >= 0 && Flags_GetSwitch(globalCtx, this->switchFlag)) { - if (!this->unk_15A) { - this->actor.flags &= ~ACTOR_FLAG_0; - this->unk_15A = true; + pthis->unk_158++; + if (pthis->switchFlag >= 0 && Flags_GetSwitch(globalCtx, pthis->switchFlag)) { + if (!pthis->unk_15A) { + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_15A = true; } - } else if ((this->talkMode != 4) || !this->unk_15A) { + } else if ((pthis->talkMode != 4) || !pthis->unk_15A) { if (BREG(2) != 0) { // "distance" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ きょり %f\n" VT_RST, this->actor.xzDistToPlayer); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ きょり %f\n" VT_RST, pthis->actor.xzDistToPlayer); } - if (((this->actor.xzDistToPlayer < (40.0f + this->triggerRange)) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f)) && + if (((pthis->actor.xzDistToPlayer < (40.0f + pthis->triggerRange)) && + (fabsf(player->actor.world.pos.y - pthis->actor.world.pos.y) < 100.0f)) && !Gameplay_InCsMode(globalCtx)) { - if (this->unk_158 >= 2) { + if (pthis->unk_158 >= 2) { osSyncPrintf("\n\n"); // "Transparent Message Kimi Seto" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 透明メッセージ君せっと %x\n" VT_RST, this->actor.params); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 透明メッセージ君せっと %x\n" VT_RST, pthis->actor.params); // "Save Information" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報 \t %x\n" VT_RST, this->switchFlag); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報 \t %x\n" VT_RST, pthis->switchFlag); // "Specified message type" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 指定メッセージ種類 %x\n" VT_RST, this->baseMsgId); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 指定メッセージ種類 %x\n" VT_RST, pthis->baseMsgId); // "Real message type" - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, this->actor.textId); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, pthis->actor.textId); // "Specified range" - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, this->actor.world.rot.z); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, pthis->actor.world.rot.z); // "Processing range" - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 処理範囲 %f\n" VT_RST, this->triggerRange); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ 処理範囲 %f\n" VT_RST, pthis->triggerRange); // "What is your range?" - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ レンジは? \t\t %d\n" VT_RST, this->actor.targetMode); + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ レンジは? \t\t %d\n" VT_RST, pthis->actor.targetMode); osSyncPrintf("\n\n"); osSyncPrintf("\n\n"); - switch (this->talkMode) { + switch (pthis->talkMode) { case 1: // "Compulsion" osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆ 強制 ☆☆ \n" VT_RST); @@ -254,29 +254,29 @@ void func_80B3A4F8(EnWonderTalk2* this, GlobalContext* globalCtx) { osSyncPrintf("\n\n"); } - this->unk_158 = 0; - if (!this->unk_156) { - Message_StartTextbox(globalCtx, this->actor.textId, NULL); + pthis->unk_158 = 0; + if (!pthis->unk_156) { + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); func_8002DF54(globalCtx, NULL, 8); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_4; - this->actionFunc = func_80B3A3D4; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_4; + pthis->actionFunc = func_80B3A3D4; } } else { - this->unk_156 = false; + pthis->unk_156 = false; } } } -void EnWonderTalk2_DoNothing(EnWonderTalk2* this, GlobalContext* globalCtx) { +void EnWonderTalk2_DoNothing(EnWonderTalk2* pthis, GlobalContext* globalCtx) { } void EnWonderTalk2_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnWonderTalk2* this = (EnWonderTalk2*)thisx; + EnWonderTalk2* pthis = (EnWonderTalk2*)thisx; - this->actionFunc(this, globalCtx); - this->actor.world.pos.y = this->initPos.y; + pthis->actionFunc(pthis, globalCtx); + pthis->actor.world.pos.y = pthis->initPos.y; - Actor_SetFocus(&this->actor, this->height); + Actor_SetFocus(&pthis->actor, pthis->height); } diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c deleted file mode 100644 index cf4b385a7..000000000 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ /dev/null @@ -1,471 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WOOD02_Z_EN_WOOD02_C -#include "actor_common.h" -/* - * File: z_en_wood02.c - * Overlay: ovl_En_Wood02 - * Description: Trees, bushes, leaves - */ - -#include "z_en_wood02.h" -#include "objects/object_wood02/object_wood02.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define FLAGS 0 - -void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); - -/** - * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any - * despawning code. - * */ -typedef enum { - /* 0 */ WOOD_SPAWN_NORMAL, - /* 1 */ WOOD_SPAWN_SPAWNED, - /* 2 */ WOOD_SPAWN_SPAWNER -} WoodSpawnType; - -typedef enum { - /* 0 */ WOOD_DRAW_TREE_CONICAL, - /* 1 */ WOOD_DRAW_TREE_OVAL, - /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, - /* 3 */ WOOD_DRAW_BUSH_GREEN, - /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves - /* 5 */ WOOD_DRAW_LEAF_YELLOW -} WoodDrawType; - -const ActorInit En_Wood02_InitVars = { - ACTOR_EN_WOOD02, - ACTORCAT_PROP, - FLAGS, - OBJECT_WOOD02, - sizeof(EnWood02), - (ActorFunc)EnWood02_Init, - (ActorFunc)EnWood02_Destroy, - (ActorFunc)EnWood02_Update, - (ActorFunc)EnWood02_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_TREE, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK5, - { 0x00000000, 0x00, 0x00 }, - { 0x0FC0074A, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 18, 60, 0, { 0, 0, 0 } }, -}; - -static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; - -static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, 0xD6C3, 0xA000 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), -}; - -static Gfx* D_80B3BF54[] = { - object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_0080D0, object_wood02_DL_000090, - object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, -}; - -static Gfx* D_80B3BF70[] = { - object_wood02_DL_007968, - object_wood02_DL_007D38, - object_wood02_DL_0081A8, - NULL, - NULL, - NULL, - object_wood02_DL_007AD0, - object_wood02_DL_007E20, - object_wood02_DL_008350, - object_wood02_DL_000160, - object_wood02_DL_000440, - object_wood02_DL_000700, -}; - -static f32 sSpawnCos; - -static f32 sSpawnSin; - -s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* pos) { - f32 phi_f12; - - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, pos, &this->actor.projectedPos, - &this->actor.projectedW); - - phi_f12 = ((this->actor.projectedW == 0.0f) ? 1000.0f : fabsf(1.0f / this->actor.projectedW)); - - if ((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && - (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) && - (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f) && - (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) && - (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) { - return true; - } - return false; -} - -/** Spawns similar-looking trees or bushes only when the player is sufficiently close. Presumably done this way to keep - * memory usage down in Hyrule Field. */ -void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { - EnWood02* childWood; - s16* childSpawnAngle; - Vec3f childPos; - s16 extraRot; - s16 childParams; - s32 i; - - for (i = 4; i >= 0; i--) { - if ((this->unk_14E[i] & 0x7F) == 0) { - extraRot = 0; - if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { - extraRot = 0x4000; - } - childSpawnAngle = &sSpawnAngle[i]; - sSpawnCos = Math_CosS(*childSpawnAngle + this->actor.world.rot.y + extraRot); - sSpawnSin = Math_SinS(*childSpawnAngle + this->actor.world.rot.y + extraRot); - childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; - childPos.y = this->actor.home.pos.y; - childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; - if (EnWood02_SpawnZoneCheck(this, globalCtx, &childPos)) { - if ((this->unk_14E[i] & 0x80) != 0) { - childParams = (0xFF00 | (this->actor.params + 1)); - } else { - childParams = (((this->drawType & 0xF0) << 4) | (this->actor.params + 1)); - } - childWood = (EnWood02*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, - ACTOR_EN_WOOD02, childPos.x, childPos.y, childPos.z, - this->actor.world.rot.x, *childSpawnAngle, 0, childParams); - if (childWood != NULL) { - childWood->unk_14E[0] = i; - this->unk_14E[i] |= 1; - childWood->actor.projectedPos = this->actor.projectedPos; - } else { - this->unk_14E[i] &= 0x80; - } - } - } - } -} - -void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx2) { - s16 spawnType; - f32 actorScale; - GlobalContext* globalCtx = globalCtx2; - EnWood02* this = (EnWood02*)thisx; - CollisionPoly* outPoly; - s32 bgId; - f32 floorY; - s16 extraRot; - - spawnType = WOOD_SPAWN_NORMAL; - actorScale = 1.0f; - this->unk_14C = (this->actor.params >> 8) & 0xFF; - - if (this->actor.home.rot.z != 0) { - this->actor.home.rot.z = (this->actor.home.rot.z << 8) | this->unk_14C; - this->unk_14C = -1; - this->actor.world.rot.z = this->actor.shape.rot.z = 0; - } else if (this->unk_14C & 0x80) { - this->unk_14C = -1; - } - - this->actor.params &= 0xFF; - Actor_ProcessInitChain(&this->actor, sInitChain); - - if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - } - - switch (this->actor.params) { - case WOOD_BUSH_GREEN_LARGE_SPAWNER: - case WOOD_BUSH_BLACK_LARGE_SPAWNER: - spawnType = 1; - case WOOD_BUSH_GREEN_LARGE_SPAWNED: - case WOOD_BUSH_BLACK_LARGE_SPAWNED: - spawnType++; - case WOOD_TREE_CONICAL_LARGE: - case WOOD_BUSH_GREEN_LARGE: - case WOOD_BUSH_BLACK_LARGE: - actorScale = 1.5f; - this->actor.uncullZoneForward = 4000.0f; - this->actor.uncullZoneScale = 2000.0f; - this->actor.uncullZoneDownward = 2400.0f; - break; - case WOOD_TREE_CONICAL_SPAWNER: - case WOOD_TREE_OVAL_YELLOW_SPAWNER: - case WOOD_TREE_OVAL_GREEN_SPAWNER: - case WOOD_BUSH_GREEN_SMALL_SPAWNER: - case WOOD_BUSH_BLACK_SMALL_SPAWNER: - spawnType = 1; - case WOOD_TREE_CONICAL_SPAWNED: - case WOOD_TREE_OVAL_YELLOW_SPAWNED: - case WOOD_TREE_OVAL_GREEN_SPAWNED: - case WOOD_BUSH_GREEN_SMALL_SPAWNED: - case WOOD_BUSH_BLACK_SMALL_SPAWNED: - spawnType++; - case WOOD_TREE_CONICAL_MEDIUM: - case WOOD_TREE_OVAL_GREEN: - case WOOD_TREE_KAKARIKO_ADULT: - case WOOD_BUSH_GREEN_SMALL: - case WOOD_BUSH_BLACK_SMALL: - this->actor.uncullZoneForward = 4000.0f; - this->actor.uncullZoneScale = 800.0f; - this->actor.uncullZoneDownward = 1800.0f; - break; - case WOOD_TREE_CONICAL_SMALL: - actorScale = 0.6f; - this->actor.uncullZoneForward = 4000.0f; - this->actor.uncullZoneScale = 400.0f; - this->actor.uncullZoneDownward = 1000.0f; - break; - case WOOD_LEAF_GREEN: - case WOOD_LEAF_YELLOW: - this->unk_14E[0] = 0x4B; - actorScale = 0.02f; - this->actor.velocity.x = Rand_CenteredFloat(6.0f); - this->actor.velocity.z = Rand_CenteredFloat(6.0f); - this->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; - } - - if (this->actor.params <= WOOD_TREE_CONICAL_SPAWNED) { - this->drawType = WOOD_DRAW_TREE_CONICAL; - } else if (this->actor.params <= WOOD_TREE_OVAL_GREEN_SPAWNED) { - this->drawType = WOOD_DRAW_TREE_OVAL; - } else if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { - this->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; - } else if (this->actor.params <= WOOD_BUSH_GREEN_LARGE_SPAWNED) { - this->drawType = WOOD_DRAW_BUSH_GREEN; - } else if (this->actor.params <= WOOD_LEAF_GREEN) { // Black bushes and green leaves - this->drawType = WOOD_DRAW_4; - } else { - this->drawType = WOOD_DRAW_LEAF_YELLOW; - } - - Actor_SetScale(&this->actor, actorScale); - this->spawnType = spawnType; - - if (spawnType != WOOD_SPAWN_NORMAL) { - extraRot = 0; - - if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { - extraRot = 0x4000; - } - - if (spawnType == WOOD_SPAWN_SPAWNER) { - this->drawType |= this->unk_14C << 4; - EnWood02_SpawnOffspring(this, globalCtx); - sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); - sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); - this->actor.world.pos.x += (sSpawnSin * sSpawnDistance[5]); - this->actor.world.pos.z += (sSpawnCos * sSpawnDistance[5]); - } else { - this->actor.flags |= ACTOR_FLAG_4; - } - - // Snap to floor, or remove if over void - this->actor.world.pos.y += 200.0f; - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); - - if (floorY > BGCHECK_Y_MIN) { - this->actor.world.pos.y = floorY; - } else { - Actor_Kill(&this->actor); - return; - } - } - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - this->actor.home.rot.y = 0; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; -} - -void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnWood02* this = (EnWood02*)thisx; - - if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } -} - -void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnWood02* this = (EnWood02*)thisx; - f32 wobbleAmplitude; - u8 new_var; - u8 phi_v0; - s32 pad; - Vec3f dropsSpawnPt; - s32 i; - s32 leavesParams; - - // Despawn extra trees in a group if out of range - if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (this->actor.parent != NULL)) { - if (!(this->actor.flags & ACTOR_FLAG_UNCULLED)) { - new_var = this->unk_14E[0]; - phi_v0 = 0; - - if (this->unk_14C < 0) { - phi_v0 = 0x80; - } - - ((EnWood02*)this->actor.parent)->unk_14E[new_var] = phi_v0; - Actor_Kill(&this->actor); - return; - } - } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { - EnWood02_SpawnOffspring(this, globalCtx); - } - - if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_REFLECTION_WOOD); - } - - if (this->actor.home.rot.y != 0) { - dropsSpawnPt = this->actor.world.pos; - dropsSpawnPt.y += 200.0f; - - if ((this->unk_14C >= 0) && (this->unk_14C < 0x64)) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &dropsSpawnPt, this->unk_14C << 4); - } else { - if (this->actor.home.rot.z != 0) { - this->actor.home.rot.z &= 0x1FFF; - this->actor.home.rot.z |= 0xE000; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, dropsSpawnPt.x, dropsSpawnPt.y, - dropsSpawnPt.z, 0, this->actor.world.rot.y, 0, this->actor.home.rot.z); - this->actor.home.rot.z = 0; - } - } - - // Spawn falling leaves - if (this->unk_14C >= -1) { - leavesParams = WOOD_LEAF_GREEN; - - if ((this->actor.params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || - (this->actor.params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { - leavesParams = WOOD_LEAF_YELLOW; - } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_TREE_SWING); - - for (i = 3; i >= 0; i--) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, - dropsSpawnPt.z, 0, Rand_CenteredFloat(65535.0f), 0, leavesParams); - } - } - this->unk_14C = -0x15; - this->actor.home.rot.y = 0; - } - - if (this->actor.xzDistToPlayer < 600.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } else if (this->actor.params < 0x17) { // Bush - Player* player = GET_PLAYER(globalCtx); - - if (this->unk_14C >= -1) { - if (((player->rideActor == NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 20.0) && - (player->linearVelocity != 0.0f)) || - ((player->rideActor != NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 60.0) && - (player->rideActor->speedXZ != 0.0f))) { - if ((this->unk_14C >= 0) && (this->unk_14C < 0x64)) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, - ((this->unk_14C << 4) | 0x8000)); - } - this->unk_14C = -0x15; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_TREE_SWING); - } - } - } else { // Leaves - this->unk_14C++; - Math_ApproachF(&this->actor.velocity.x, 0.0f, 1.0f, 5 * 0.01f); - Math_ApproachF(&this->actor.velocity.z, 0.0f, 1.0f, 5 * 0.01f); - func_8002D7EC(&this->actor); - this->actor.shape.rot.z = Math_SinS(3000 * this->unk_14C) * 0x4000; - this->unk_14E[0]--; - - if (this->unk_14E[0] == 0) { - Actor_Kill(&this->actor); - } - } - - // Wobble from impact - if (this->unk_14C < -1) { - this->unk_14C++; - wobbleAmplitude = Math_SinS((this->unk_14C ^ 0xFFFF) * 0x3332) * 250.0f; - this->actor.shape.rot.x = (Math_CosS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) * wobbleAmplitude); - this->actor.shape.rot.z = (Math_SinS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) * wobbleAmplitude); - } -} - -void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnWood02* this = (EnWood02*)thisx; - s16 type; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - u8 red; - u8 green; - u8 blue; - - OPEN_DISPS(gfxCtx, "../z_en_wood02.c", 775); - type = this->actor.params; - - if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || - (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { - red = 50; - green = 170; - blue = 70; - } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || - (type == WOOD_LEAF_YELLOW)) { - red = 180; - green = 155; - blue = 0; - } else { - red = green = blue = 255; - } - - func_80093D84(gfxCtx); - - if ((this->actor.params == WOOD_LEAF_GREEN) || (this->actor.params == WOOD_LEAF_YELLOW)) { - func_80093D18(gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); - Gfx_DrawDListOpa(globalCtx, object_wood02_DL_000700); - } else if (D_80B3BF70[this->drawType & 0xF] != NULL) { - Gfx_DrawDListOpa(globalCtx, D_80B3BF54[this->drawType & 0xF]); - gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_wood02.c", 808), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_80B3BF70[this->drawType & 0xF]); - } else { - func_80093D84(gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_wood02.c", 814), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_80B3BF54[this->drawType & 0xF]); - } - - CLOSE_DISPS(gfxCtx, "../z_en_wood02.c", 840); -} diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.cpp b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.cpp new file mode 100644 index 000000000..424c1bb60 --- /dev/null +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.cpp @@ -0,0 +1,471 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_WOOD02_Z_EN_WOOD02_C +#include "actor_common.h" +/* + * File: z_en_wood02.c + * Overlay: ovl_En_Wood02 + * Description: Trees, bushes, leaves + */ + +#include "z_en_wood02.h" +#include "objects/object_wood02/object_wood02.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define FLAGS 0 + +void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx); +void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); + +/** + * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any + * despawning code. + * */ +typedef enum { + /* 0 */ WOOD_SPAWN_NORMAL, + /* 1 */ WOOD_SPAWN_SPAWNED, + /* 2 */ WOOD_SPAWN_SPAWNER +} WoodSpawnType; + +typedef enum { + /* 0 */ WOOD_DRAW_TREE_CONICAL, + /* 1 */ WOOD_DRAW_TREE_OVAL, + /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, + /* 3 */ WOOD_DRAW_BUSH_GREEN, + /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves + /* 5 */ WOOD_DRAW_LEAF_YELLOW +} WoodDrawType; + +ActorInit En_Wood02_InitVars = { + ACTOR_EN_WOOD02, + ACTORCAT_PROP, + FLAGS, + OBJECT_WOOD02, + sizeof(EnWood02), + (ActorFunc)EnWood02_Init, + (ActorFunc)EnWood02_Destroy, + (ActorFunc)EnWood02_Update, + (ActorFunc)EnWood02_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x0FC0074A, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 18, 60, 0, { 0, 0, 0 } }, +}; + +static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; + +static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, 0xD6C3, 0xA000 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), +}; + +static Gfx* D_80B3BF54[] = { + object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_0080D0, object_wood02_DL_000090, + object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, +}; + +static Gfx* D_80B3BF70[] = { + object_wood02_DL_007968, + object_wood02_DL_007D38, + object_wood02_DL_0081A8, + NULL, + NULL, + NULL, + object_wood02_DL_007AD0, + object_wood02_DL_007E20, + object_wood02_DL_008350, + object_wood02_DL_000160, + object_wood02_DL_000440, + object_wood02_DL_000700, +}; + +static f32 sSpawnCos; + +static f32 sSpawnSin; + +s32 EnWood02_SpawnZoneCheck(EnWood02* pthis, GlobalContext* globalCtx, Vec3f* pos) { + f32 phi_f12; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, pos, &pthis->actor.projectedPos, + &pthis->actor.projectedW); + + phi_f12 = ((pthis->actor.projectedW == 0.0f) ? 1000.0f : fabsf(1.0f / pthis->actor.projectedW)); + + if ((-pthis->actor.uncullZoneScale < pthis->actor.projectedPos.z) && + (pthis->actor.projectedPos.z < (pthis->actor.uncullZoneForward + pthis->actor.uncullZoneScale)) && + (((fabsf(pthis->actor.projectedPos.x) - pthis->actor.uncullZoneScale) * phi_f12) < 1.0f) && + (((pthis->actor.projectedPos.y + pthis->actor.uncullZoneDownward) * phi_f12) > -1.0f) && + (((pthis->actor.projectedPos.y - pthis->actor.uncullZoneScale) * phi_f12) < 1.0f)) { + return true; + } + return false; +} + +/** Spawns similar-looking trees or bushes only when the player is sufficiently close. Presumably done pthis way to keep + * memory usage down in Hyrule Field. */ +void EnWood02_SpawnOffspring(EnWood02* pthis, GlobalContext* globalCtx) { + EnWood02* childWood; + s16* childSpawnAngle; + Vec3f childPos; + s16 extraRot; + s16 childParams; + s32 i; + + for (i = 4; i >= 0; i--) { + if ((pthis->unk_14E[i] & 0x7F) == 0) { + extraRot = 0; + if (pthis->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + childSpawnAngle = &sSpawnAngle[i]; + sSpawnCos = Math_CosS(*childSpawnAngle + pthis->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(*childSpawnAngle + pthis->actor.world.rot.y + extraRot); + childPos.x = (sSpawnDistance[i] * sSpawnSin) + pthis->actor.home.pos.x; + childPos.y = pthis->actor.home.pos.y; + childPos.z = (sSpawnDistance[i] * sSpawnCos) + pthis->actor.home.pos.z; + if (EnWood02_SpawnZoneCheck(pthis, globalCtx, &childPos)) { + if ((pthis->unk_14E[i] & 0x80) != 0) { + childParams = (0xFF00 | (pthis->actor.params + 1)); + } else { + childParams = (((pthis->drawType & 0xF0) << 4) | (pthis->actor.params + 1)); + } + childWood = (EnWood02*)Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, + ACTOR_EN_WOOD02, childPos.x, childPos.y, childPos.z, + pthis->actor.world.rot.x, *childSpawnAngle, 0, childParams); + if (childWood != NULL) { + childWood->unk_14E[0] = i; + pthis->unk_14E[i] |= 1; + childWood->actor.projectedPos = pthis->actor.projectedPos; + } else { + pthis->unk_14E[i] &= 0x80; + } + } + } + } +} + +void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx2) { + s16 spawnType; + f32 actorScale; + GlobalContext* globalCtx = globalCtx2; + EnWood02* pthis = (EnWood02*)thisx; + CollisionPoly* outPoly; + s32 bgId; + f32 floorY; + s16 extraRot; + + spawnType = WOOD_SPAWN_NORMAL; + actorScale = 1.0f; + pthis->unk_14C = (pthis->actor.params >> 8) & 0xFF; + + if (pthis->actor.home.rot.z != 0) { + pthis->actor.home.rot.z = (pthis->actor.home.rot.z << 8) | pthis->unk_14C; + pthis->unk_14C = -1; + pthis->actor.world.rot.z = pthis->actor.shape.rot.z = 0; + } else if (pthis->unk_14C & 0x80) { + pthis->unk_14C = -1; + } + + pthis->actor.params &= 0xFF; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + + if (pthis->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + } + + switch (pthis->actor.params) { + case WOOD_BUSH_GREEN_LARGE_SPAWNER: + case WOOD_BUSH_BLACK_LARGE_SPAWNER: + spawnType = 1; + case WOOD_BUSH_GREEN_LARGE_SPAWNED: + case WOOD_BUSH_BLACK_LARGE_SPAWNED: + spawnType++; + case WOOD_TREE_CONICAL_LARGE: + case WOOD_BUSH_GREEN_LARGE: + case WOOD_BUSH_BLACK_LARGE: + actorScale = 1.5f; + pthis->actor.uncullZoneForward = 4000.0f; + pthis->actor.uncullZoneScale = 2000.0f; + pthis->actor.uncullZoneDownward = 2400.0f; + break; + case WOOD_TREE_CONICAL_SPAWNER: + case WOOD_TREE_OVAL_YELLOW_SPAWNER: + case WOOD_TREE_OVAL_GREEN_SPAWNER: + case WOOD_BUSH_GREEN_SMALL_SPAWNER: + case WOOD_BUSH_BLACK_SMALL_SPAWNER: + spawnType = 1; + case WOOD_TREE_CONICAL_SPAWNED: + case WOOD_TREE_OVAL_YELLOW_SPAWNED: + case WOOD_TREE_OVAL_GREEN_SPAWNED: + case WOOD_BUSH_GREEN_SMALL_SPAWNED: + case WOOD_BUSH_BLACK_SMALL_SPAWNED: + spawnType++; + case WOOD_TREE_CONICAL_MEDIUM: + case WOOD_TREE_OVAL_GREEN: + case WOOD_TREE_KAKARIKO_ADULT: + case WOOD_BUSH_GREEN_SMALL: + case WOOD_BUSH_BLACK_SMALL: + pthis->actor.uncullZoneForward = 4000.0f; + pthis->actor.uncullZoneScale = 800.0f; + pthis->actor.uncullZoneDownward = 1800.0f; + break; + case WOOD_TREE_CONICAL_SMALL: + actorScale = 0.6f; + pthis->actor.uncullZoneForward = 4000.0f; + pthis->actor.uncullZoneScale = 400.0f; + pthis->actor.uncullZoneDownward = 1000.0f; + break; + case WOOD_LEAF_GREEN: + case WOOD_LEAF_YELLOW: + pthis->unk_14E[0] = 0x4B; + actorScale = 0.02f; + pthis->actor.velocity.x = Rand_CenteredFloat(6.0f); + pthis->actor.velocity.z = Rand_CenteredFloat(6.0f); + pthis->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; + } + + if (pthis->actor.params <= WOOD_TREE_CONICAL_SPAWNED) { + pthis->drawType = WOOD_DRAW_TREE_CONICAL; + } else if (pthis->actor.params <= WOOD_TREE_OVAL_GREEN_SPAWNED) { + pthis->drawType = WOOD_DRAW_TREE_OVAL; + } else if (pthis->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + pthis->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; + } else if (pthis->actor.params <= WOOD_BUSH_GREEN_LARGE_SPAWNED) { + pthis->drawType = WOOD_DRAW_BUSH_GREEN; + } else if (pthis->actor.params <= WOOD_LEAF_GREEN) { // Black bushes and green leaves + pthis->drawType = WOOD_DRAW_4; + } else { + pthis->drawType = WOOD_DRAW_LEAF_YELLOW; + } + + Actor_SetScale(&pthis->actor, actorScale); + pthis->spawnType = spawnType; + + if (spawnType != WOOD_SPAWN_NORMAL) { + extraRot = 0; + + if (pthis->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + if (spawnType == WOOD_SPAWN_SPAWNER) { + pthis->drawType |= pthis->unk_14C << 4; + EnWood02_SpawnOffspring(pthis, globalCtx); + sSpawnCos = Math_CosS(sSpawnAngle[5] + pthis->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[5] + pthis->actor.world.rot.y + extraRot); + pthis->actor.world.pos.x += (sSpawnSin * sSpawnDistance[5]); + pthis->actor.world.pos.z += (sSpawnCos * sSpawnDistance[5]); + } else { + pthis->actor.flags |= ACTOR_FLAG_4; + } + + // Snap to floor, or remove if over void + pthis->actor.world.pos.y += 200.0f; + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &outPoly, &bgId, &pthis->actor, &pthis->actor.world.pos); + + if (floorY > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = floorY; + } else { + Actor_Kill(&pthis->actor); + return; + } + } + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + pthis->actor.home.rot.y = 0; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; +} + +void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWood02* pthis = (EnWood02*)thisx; + + if (pthis->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } +} + +void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWood02* pthis = (EnWood02*)thisx; + f32 wobbleAmplitude; + u8 new_var; + u8 phi_v0; + s32 pad; + Vec3f dropsSpawnPt; + s32 i; + s32 leavesParams; + + // Despawn extra trees in a group if out of range + if ((pthis->spawnType == WOOD_SPAWN_SPAWNED) && (pthis->actor.parent != NULL)) { + if (!(pthis->actor.flags & ACTOR_FLAG_UNCULLED)) { + new_var = pthis->unk_14E[0]; + phi_v0 = 0; + + if (pthis->unk_14C < 0) { + phi_v0 = 0x80; + } + + ((EnWood02*)pthis->actor.parent)->unk_14E[new_var] = phi_v0; + Actor_Kill(&pthis->actor); + return; + } + } else if (pthis->spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(pthis, globalCtx); + } + + if (pthis->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; + Audio_PlayActorSound2(&pthis->actor, NA_SE_IT_REFLECTION_WOOD); + } + + if (pthis->actor.home.rot.y != 0) { + dropsSpawnPt = pthis->actor.world.pos; + dropsSpawnPt.y += 200.0f; + + if ((pthis->unk_14C >= 0) && (pthis->unk_14C < 0x64)) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &dropsSpawnPt, pthis->unk_14C << 4); + } else { + if (pthis->actor.home.rot.z != 0) { + pthis->actor.home.rot.z &= 0x1FFF; + pthis->actor.home.rot.z |= 0xE000; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, dropsSpawnPt.x, dropsSpawnPt.y, + dropsSpawnPt.z, 0, pthis->actor.world.rot.y, 0, pthis->actor.home.rot.z); + pthis->actor.home.rot.z = 0; + } + } + + // Spawn falling leaves + if (pthis->unk_14C >= -1) { + leavesParams = WOOD_LEAF_GREEN; + + if ((pthis->actor.params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || + (pthis->actor.params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { + leavesParams = WOOD_LEAF_YELLOW; + } + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_TREE_SWING); + + for (i = 3; i >= 0; i--) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, + dropsSpawnPt.z, 0, Rand_CenteredFloat(65535.0f), 0, leavesParams); + } + } + pthis->unk_14C = -0x15; + pthis->actor.home.rot.y = 0; + } + + if (pthis->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } else if (pthis->actor.params < 0x17) { // Bush + Player* player = GET_PLAYER(globalCtx); + + if (pthis->unk_14C >= -1) { + if (((player->rideActor == NULL) && (sqrt(pthis->actor.xyzDistToPlayerSq) < 20.0) && + (player->linearVelocity != 0.0f)) || + ((player->rideActor != NULL) && (sqrt(pthis->actor.xyzDistToPlayerSq) < 60.0) && + (player->rideActor->speedXZ != 0.0f))) { + if ((pthis->unk_14C >= 0) && (pthis->unk_14C < 0x64)) { + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, + ((pthis->unk_14C << 4) | 0x8000)); + } + pthis->unk_14C = -0x15; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_TREE_SWING); + } + } + } else { // Leaves + pthis->unk_14C++; + Math_ApproachF(&pthis->actor.velocity.x, 0.0f, 1.0f, 5 * 0.01f); + Math_ApproachF(&pthis->actor.velocity.z, 0.0f, 1.0f, 5 * 0.01f); + func_8002D7EC(&pthis->actor); + pthis->actor.shape.rot.z = Math_SinS(3000 * pthis->unk_14C) * 0x4000; + pthis->unk_14E[0]--; + + if (pthis->unk_14E[0] == 0) { + Actor_Kill(&pthis->actor); + } + } + + // Wobble from impact + if (pthis->unk_14C < -1) { + pthis->unk_14C++; + wobbleAmplitude = Math_SinS((pthis->unk_14C ^ 0xFFFF) * 0x3332) * 250.0f; + pthis->actor.shape.rot.x = (Math_CosS(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) * wobbleAmplitude); + pthis->actor.shape.rot.z = (Math_SinS(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y) * wobbleAmplitude); + } +} + +void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWood02* pthis = (EnWood02*)thisx; + s16 type; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + u8 red; + u8 green; + u8 blue; + + OPEN_DISPS(gfxCtx, "../z_en_wood02.c", 775); + type = pthis->actor.params; + + if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + red = 50; + green = 170; + blue = 70; + } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (type == WOOD_LEAF_YELLOW)) { + red = 180; + green = 155; + blue = 0; + } else { + red = green = blue = 255; + } + + func_80093D84(gfxCtx); + + if ((pthis->actor.params == WOOD_LEAF_GREEN) || (pthis->actor.params == WOOD_LEAF_YELLOW)) { + func_80093D18(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); + Gfx_DrawDListOpa(globalCtx, object_wood02_DL_000700); + } else if (D_80B3BF70[pthis->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(globalCtx, D_80B3BF54[pthis->drawType & 0xF]); + gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_wood02.c", 808), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80B3BF70[pthis->drawType & 0xF]); + } else { + func_80093D84(gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_wood02.c", 814), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80B3BF54[pthis->drawType & 0xF]); + } + + CLOSE_DISPS(gfxCtx, "../z_en_wood02.c", 840); +} diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c deleted file mode 100644 index f41f3356a..000000000 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ /dev/null @@ -1,2448 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_XC_Z_EN_XC_C -#include "actor_common.h" -/* - * File: z_en_xc.c - * Overlay: ovl_En_Xc - * Description: Sheik - */ - -#include "z_en_xc.h" -#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "objects/object_xc/object_xc.h" -#include "scenes/overworld/spot05/spot05_scene.h" -#include "scenes/overworld/spot17/spot17_scene.h" -#include "scenes/indoors/tokinoma/tokinoma_scene.h" -#include "scenes/dungeons/ice_doukutu/ice_doukutu_scene.h" -#include "vt.h" -#include "def/code_8006BA00.h" -#include "def/code_800EC960.h" -#include "def/graph.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin_matrix.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnXc_Init(Actor* thisx, GlobalContext* globalCtx); -void EnXc_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnXc_Update(Actor* thisx, GlobalContext* globalCtx); -void EnXc_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnXc_DrawNothing(Actor* thisx, GlobalContext* globalCtx); -void EnXc_DrawDefault(Actor* thisx, GlobalContext* globalCtx); -void EnXc_DrawPullingOutHarp(Actor* thisx, GlobalContext* globalCtx); -void EnXc_DrawHarp(Actor* thisx, GlobalContext* globalCtx); -void EnXc_DrawTriforce(Actor* thisx, GlobalContext* globalCtx); -void EnXc_DrawSquintingEyes(Actor* thisx, GlobalContext* globalCtx); - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 25, 80, 0, { 0, 0, 0 } }, -}; - -static void* sEyeTextures[] = { - gSheikEyeOpenTex, - gSheikEyeHalfClosedTex, - gSheikEyeShutTex, -}; - -void EnXc_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); -} - -void EnXc_UpdateCollider(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - Collider* colliderBase = &this->collider.base; - s32 pad[3]; - - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, colliderBase); -} - -void EnXc_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void EnXc_CalculateHeadTurn(EnXc* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->npcInfo.unk_18 = player->actor.world.pos; - this->npcInfo.unk_14 = kREG(16) - 3.0f; - func_80034A14(&this->actor, &this->npcInfo, kREG(17) + 0xC, 2); -} - -void EnXc_SetEyePattern(EnXc* this) { - s32 pad[3]; - s16* blinkTimer = &this->blinkTimer; - s16* eyePattern = &this->eyeIdx; - - if (!DECR(*blinkTimer)) { - *blinkTimer = Rand_S16Offset(60, 60); - } - - *eyePattern = *blinkTimer; - if (*eyePattern >= ARRAY_COUNT(sEyeTextures)) { - *eyePattern = 0; - } -} - -void EnXc_SpawnNut(EnXc* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f* pos = &this->actor.world.pos; - s16 angle = this->actor.shape.rot.y; - f32 x = (Math_SinS(angle) * 30.0f) + pos->x; - f32 y = pos->y + 3.0f; - f32 z = (Math_CosS(angle) * 30.0f) + pos->z; - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, x, y, z, 0xFA0, this->actor.shape.rot.y, 0, - ARROW_CS_NUT); -} - -void EnXc_BgCheck(EnXc* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 4); -} - -s32 EnXc_AnimIsFinished(EnXc* this) { - return SkelAnime_Update(&this->skelAnime); -} - -CsCmdActorAction* EnXc_GetCsCmd(GlobalContext* globalCtx, s32 npcActionIdx) { - CsCmdActorAction* action = NULL; - - if (globalCtx->csCtx.state != 0) { - action = globalCtx->csCtx.npcActions[npcActionIdx]; - } - return action; -} - -s32 EnXc_CompareCsAction(EnXc* this, GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { - CsCmdActorAction* csCmdActorAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); - - if (csCmdActorAction != NULL && csCmdActorAction->action == action) { - return true; - } - return false; -} - -s32 EnXc_CsActionsAreNotEqual(EnXc* this, GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); - - if (csCmdNPCAction && csCmdNPCAction->action != action) { - return true; - } - return false; -} - -void func_80B3C588(EnXc* this, GlobalContext* globalCtx, u32 npcActionIdx) { - CsCmdActorAction* csCmdNPCAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); - Actor* thisx = &this->actor; - - if (csCmdNPCAction != NULL) { - thisx->world.pos.x = csCmdNPCAction->startPos.x; - thisx->world.pos.y = csCmdNPCAction->startPos.y; - thisx->world.pos.z = csCmdNPCAction->startPos.z; - thisx->world.rot.x = thisx->shape.rot.x = csCmdNPCAction->rot.x; - thisx->world.rot.y = thisx->shape.rot.y = csCmdNPCAction->rot.y; - thisx->world.rot.z = thisx->shape.rot.z = csCmdNPCAction->rot.z; - } -} - -void func_80B3C620(EnXc* this, GlobalContext* globalCtx, s32 npcActionIdx) { - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); - Vec3f* xcPos = &this->actor.world.pos; - f32 startX; - f32 startY; - f32 startZ; - f32 endX; - f32 endY; - f32 endZ; - f32 unk; - - if (npcAction != NULL) { - unk = - Environment_LerpWeightAccelDecel(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, 0, 0); - startX = npcAction->startPos.x; - startY = npcAction->startPos.y; - startZ = npcAction->startPos.z; - endX = npcAction->endPos.x; - endY = npcAction->endPos.y; - endZ = npcAction->endPos.z; - xcPos->x = ((endX - startX) * unk) + startX; - xcPos->y = ((endY - startY) * unk) + startY; - xcPos->z = ((endZ - startZ) * unk) + startZ; - } -} - -void EnXc_ChangeAnimation(EnXc* this, AnimationHeader* animation, u8 mode, f32 morphFrames, s32 reverseFlag) { - s32 pad[2]; - AnimationHeader* animationSeg = SEGMENTED_TO_VIRTUAL(animation); - f32 frameCount = Animation_GetLastFrame(&animationSeg->common); - f32 playbackSpeed; - f32 startFrame; - f32 endFrame; - - if (!reverseFlag) { - startFrame = 0.0f; - endFrame = frameCount; - playbackSpeed = 1.0f; - } else { - startFrame = frameCount; - endFrame = 0.0f; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animationSeg, playbackSpeed, startFrame, endFrame, mode, morphFrames); -} - -void EnXc_CheckAndSetAction(EnXc* this, s32 check, s32 set) { - if (check != this->action) { - this->action = set; - } -} - -void func_80B3C7D4(EnXc* this, s32 action1, s32 action2, s32 action3) { - if (action1 != this->action) { - if (this->action == SHEIK_ACTION_PUT_HARP_AWAY) { - this->action = action2; - } else { - this->action = action3; - } - } -} - -s32 EnXc_NoCutscenePlaying(GlobalContext* globalCtx) { - if (globalCtx->csCtx.state == 0) { - return true; - } - return false; -} - -void func_80B3C820(EnXc* this) { - Animation_Change(&this->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->action = SHEIK_ACTION_53; -} - -void func_80B3C888(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_NoCutscenePlaying(globalCtx) && this->actor.params == SHEIK_TYPE_4) { - func_80B3C820(this); - } -} - -void func_80B3C8CC(EnXc* this, GlobalContext* globalCtx) { - SkelAnime* skelAnime = &this->skelAnime; - - if (skelAnime->jointTable[0].y >= skelAnime->baseTransl.y) { - skelAnime->moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, skelAnime, 1.0f); - } -} - -void func_80B3C924(EnXc* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_80B3C964(EnXc* this, GlobalContext* globalCtx) { - this->skelAnime.baseTransl = this->skelAnime.jointTable[0]; - this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.moveFlags |= 3; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_80B3C9DC(EnXc* this) { - this->skelAnime.moveFlags &= ~0x3; -} - -void func_80B3C9EC(EnXc* this) { - EnXc_ChangeAnimation(this, &gSheikArmsCrossedIdleAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = SHEIK_ACTION_BLOCK_PEDESTAL; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->unk_30C = 1; -} - -void func_80B3CA38(EnXc* this, GlobalContext* globalCtx) { - // If Player is adult but hasn't learned Minuet of Forest - if (!(gSaveContext.eventChkInf[5] & 1) && LINK_IS_ADULT) { - this->action = SHEIK_ACTION_INIT; - } else { - Actor_Kill(&this->actor); - } -} - -s32 EnXc_MinuetCS(EnXc* this, GlobalContext* globalCtx) { - if (this->actor.params == SHEIK_TYPE_MINUET) { - Player* player = GET_PLAYER(globalCtx); - f32 z = player->actor.world.pos.z; - - if (z < -2225.0f) { - if (!Gameplay_InCsMode(globalCtx)) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(&gMinuetCs); - gSaveContext.cutsceneTrigger = 1; - gSaveContext.eventChkInf[5] |= 1; - Item_Give(globalCtx, ITEM_SONG_MINUET); - return true; - } - } - return false; - } - return true; -} - -void func_80B3CB58(EnXc* this, GlobalContext* globalCtx) { - // If hasn't learned Bolero and Player is Adult - if (!(gSaveContext.eventChkInf[5] & 2) && LINK_IS_ADULT) { - this->action = SHEIK_ACTION_INIT; - } else { - Actor_Kill(&this->actor); - } -} - -s32 EnXc_BoleroCS(EnXc* this, GlobalContext* globalCtx) { - Player* player; - PosRot* posRot; - - if (this->actor.params == SHEIK_TYPE_BOLERO) { - player = GET_PLAYER(globalCtx); - posRot = &player->actor.world; - if ((posRot->pos.x > -784.0f) && (posRot->pos.x < -584.0f) && (posRot->pos.y > 447.0f) && - (posRot->pos.y < 647.0f) && (posRot->pos.z > -446.0f) && (posRot->pos.z < -246.0f) && - !Gameplay_InCsMode(globalCtx)) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(&gDeathMountainCraterBoleroCs); - gSaveContext.cutsceneTrigger = 1; - gSaveContext.eventChkInf[5] |= 2; - Item_Give(globalCtx, ITEM_SONG_BOLERO); - return true; - } - return false; - } - return true; -} - -void EnXc_SetupSerenadeAction(EnXc* this, GlobalContext* globalCtx) { - // Player is adult and does not have iron boots and has not learned Serenade - if ((!CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1) && !(gSaveContext.eventChkInf[5] & 4)) && LINK_IS_ADULT) { - this->action = SHEIK_ACTION_SERENADE; - osSyncPrintf("水のセレナーデ シーク誕生!!!!!!!!!!!!!!!!!!\n"); - } else { - Actor_Kill(&this->actor); - osSyncPrintf("水のセレナーデ シーク消滅!!!!!!!!!!!!!!!!!!\n"); - } -} - -s32 EnXc_SerenadeCS(EnXc* this, GlobalContext* globalCtx) { - if (this->actor.params == SHEIK_TYPE_SERENADE) { - Player* player = GET_PLAYER(globalCtx); - s32 stateFlags = player->stateFlags1; - - if (CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1) && !(gSaveContext.eventChkInf[5] & 4) && !(stateFlags & 0x20000000) && - !Gameplay_InCsMode(globalCtx)) { - Cutscene_SetSegment(globalCtx, &gIceCavernSerenadeCs); - gSaveContext.cutsceneTrigger = 1; - gSaveContext.eventChkInf[5] |= 4; // Learned Serenade of Water Flag - Item_Give(globalCtx, ITEM_SONG_SERENADE); - osSyncPrintf("ブーツを取った!!!!!!!!!!!!!!!!!!\n"); - return true; - } - osSyncPrintf("はやくブーツを取るべし!!!!!!!!!!!!!!!!!!\n"); - return false; - } - return true; -} - -void EnXc_DoNothing(EnXc* this, GlobalContext* globalCtx) { -} - -void EnXc_SetWalkingSFX(EnXc* this, GlobalContext* globalCtx) { - s32 pad[2]; - u32 sfxId; - s32 pad2; - - if (Animation_OnFrame(&this->skelAnime, 11.0f) || Animation_OnFrame(&this->skelAnime, 23.0f)) { - if (this->actor.bgCheckFlags & 1) { - sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - func_80078914(&this->actor.projectedPos, sfxId); - } - } -} - -void EnXc_SetNutThrowSFX(EnXc* this, GlobalContext* globalCtx) { - s32 pad[2]; - u32 sfxId; - s32 pad2; - - if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - if (this->actor.bgCheckFlags & 1) { - sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - func_80078914(&this->actor.projectedPos, sfxId); - } - } - if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_SK_SHOUT); - } -} - -void EnXc_SetLandingSFX(EnXc* this, GlobalContext* globalCtx) { - u32 sfxId; - s16 sceneNum = globalCtx->sceneNum; - - if ((gSaveContext.sceneSetupIndex != 4) || (sceneNum != SCENE_SPOT11)) { - if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - func_80078914(&this->actor.projectedPos, sfxId); - } - } -} - -void EnXc_SetColossusAppearSFX(EnXc* this, GlobalContext* globalCtx) { - static Vec3f sXyzDist; - s16 sceneNum; - - if (gSaveContext.sceneSetupIndex == 4) { - sceneNum = globalCtx->sceneNum; - if (sceneNum == SCENE_SPOT11) { - CutsceneContext* csCtx = &globalCtx->csCtx; - u16 frameCount = csCtx->frames; - f32 wDest[2]; - - if (frameCount == 119) { - Vec3f pos = { -611.0f, 728.0f, -2.0f }; - - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &sXyzDist, wDest); - func_80078914(&sXyzDist, NA_SE_EV_JUMP_CONC); - } else if (frameCount == 164) { - Vec3f pos = { -1069.0f, 38.0f, 0.0f }; - s32 pad; - - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &sXyzDist, wDest); - func_80078914(&sXyzDist, NA_SE_PL_WALK_CONCRETE); - } - } - } -} - -void func_80B3D118(GlobalContext* globalCtx) { - s16 sceneNum; - - if ((gSaveContext.sceneSetupIndex != 4) || (sceneNum = globalCtx->sceneNum, sceneNum != SCENE_SPOT11)) { - func_800788CC(NA_SE_PL_SKIP); - } -} - -static Vec3f D_80B42DA0; - -void EnXc_SetColossusWindSFX(GlobalContext* globalCtx) { - if (gSaveContext.sceneSetupIndex == 4) { - static s32 D_80B41D90 = 0; - static Vec3f sPos = { 0.0f, 0.0f, 0.0f }; - static f32 sMaxSpeed = 0.0f; - static Vec3f D_80B42DB0; - s32 pad; - s16 sceneNum = globalCtx->sceneNum; - - if (sceneNum == SCENE_SPOT11) { - CutsceneContext* csCtx = &globalCtx->csCtx; - u16 frameCount = csCtx->frames; - - if ((frameCount >= 120) && (frameCount < 164)) { - s32 pad; - Vec3f* eye = &globalCtx->view.eye; - - if (D_80B41D90 != 0) { - f32 speed = Math3D_Vec3f_DistXYZ(&D_80B42DB0, eye) / 7.058922f; - - sMaxSpeed = CLAMP_MIN(sMaxSpeed, speed); - - osSyncPrintf("MAX speed = %f\n", sMaxSpeed); - - speed = CLAMP_MAX(speed, 2.0f); - func_800F436C(&sPos, NA_SE_EV_FLYING_AIR - SFX_FLAG, 0.6f + (0.4f * speed)); - } - - D_80B42DB0.x = eye->x; - D_80B42DB0.y = eye->y; - D_80B42DB0.z = eye->z; - D_80B41D90 = 1; - } - } - } -} - -void EnXc_SpawnFlame(EnXc* this, GlobalContext* globalCtx) { - static s32 sFlameSpawned = false; - - if (!sFlameSpawned) { - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); - f32 xPos = npcAction->startPos.x; - f32 yPos = npcAction->startPos.y; - f32 zPos = npcAction->startPos.z; - - this->flameActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_LIGHT, xPos, yPos, zPos, 0, 0, 0, 5); - sFlameSpawned = true; - } -} - -void EnXc_SetupFlamePos(EnXc* this, GlobalContext* globalCtx) { - Vec3f* attachedPos; - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); - - if (this->flameActor != NULL) { - attachedPos = &this->flameActor->world.pos; - if (!this) {} - attachedPos->x = npcAction->startPos.x; - attachedPos->y = npcAction->startPos.y; - attachedPos->z = npcAction->startPos.z; - } -} - -void EnXc_DestroyFlame(EnXc* this) { - if (this->flameActor != NULL) { - Actor_Kill(this->flameActor); - this->flameActor = NULL; - } - Actor_Kill(&this->actor); -} - -void EnXc_InitFlame(EnXc* this, GlobalContext* globalCtx) { - static s32 D_80B41DA8 = 1; - s32 pad; - s16 sceneNum = globalCtx->sceneNum; - - if (sceneNum == SCENE_SPOT17) { - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); - if (npcAction != NULL) { - s32 action = npcAction->action; - - if (D_80B41DA8 != action) { - if (action != 1) { - EnXc_SpawnFlame(this, globalCtx); - } - - if (action == 1) { - EnXc_DestroyFlame(this); - } - - D_80B41DA8 = action; - } - - EnXc_SetupFlamePos(this, globalCtx); - } - } -} - -void func_80B3D48C(EnXc* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - CsCmdActorAction* linkAction = csCtx->linkAction; - s16 yaw; - - if (linkAction != NULL) { - yaw = linkAction->urot.y + 0x8000; - } else { - Player* player = GET_PLAYER(globalCtx); - yaw = player->actor.world.rot.y + 0x8000; - } - - this->actor.shape.rot.y = this->actor.world.rot.y = yaw; -} - -AnimationHeader* EnXc_GetCurrentHarpAnim(GlobalContext* globalCtx, s32 index) { - AnimationHeader* animation = &gSheikPlayingHarp5Anim; - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, index); - - if (npcAction != NULL) { - u16 action = npcAction->action; - - if (action == 11) { - animation = &gSheikPlayingHarp3Anim; - } else if (action == 12) { - animation = &gSheikPlayingHarp2Anim; - } else if (action == 13) { - animation = &gSheikPlayingHarp4Anim; - } else if (action == 23) { - animation = &gSheikPlayingHarpAnim; - } else { - animation = &gSheikPlayingHarp5Anim; - } - } - return animation; -} - -void EnXc_CalcXZAccel(EnXc* this) { - f32 timer = this->timer; - f32* speedXZ = &this->actor.speedXZ; - - if (timer < 9.0f) { - *speedXZ = 0.0f; - } else if (timer < 3.0f) { - *speedXZ = (((kREG(2) * 0.01f) + 1.2f) / 3.0f) * (timer - 9.0f); - } else { - *speedXZ = (kREG(2) * 0.01f) + 1.2f; - } - - Actor_MoveForward(&this->actor); -} - -void func_80B3D644(EnXc* this) { - Actor_MoveForward(&this->actor); -} - -void EnXc_CalcXZSpeed(EnXc* this) { - f32 timer = this->timer; - f32* speedXZ = &this->actor.speedXZ; - - if (timer < 3.0f) { - *speedXZ = (((kREG(2) * 0.01f) + 1.2f) / 3.0f) * (3.0f - timer); - } else { - *speedXZ = 0.0f; - } - Actor_MoveForward(&this->actor); -} - -void func_80B3D6F0(EnXc* this) { - EnXc_CalcXZAccel(this); -} - -void func_80B3D710(EnXc* this) { - Actor_MoveForward(&this->actor); -} - -void func_80B3D730(EnXc* this) { - EnXc_CalcXZSpeed(this); -} - -void func_80B3D750(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_MinuetCS(this, globalCtx) && EnXc_BoleroCS(this, globalCtx)) { - this->action = SHEIK_ACTION_WAIT; - } -} - -void EnXc_SetupFallFromSkyAction(EnXc* this, GlobalContext* globalCtx) { - s32 pad; - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->state != 0) { - CsCmdActorAction* npcAction = csCtx->npcActions[4]; - - if (npcAction && npcAction->action == 2) { - s32 pad; - Vec3f* pos = &this->actor.world.pos; - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSheikFallingFromSkyAnim); - - this->action = SHEIK_ACTION_GRACEFUL_FALL; - this->drawMode = SHEIK_DRAW_DEFAULT; - - pos->x = npcAction->startPos.x; - pos->y = npcAction->startPos.y; - pos->z = npcAction->startPos.z; - - func_80B3D48C(this, globalCtx); - func_80B3C964(this, globalCtx); - Animation_Change(skelAnime, &gSheikFallingFromSkyAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); - func_80B3D118(globalCtx); - } - } -} - -void func_80B3D8A4(EnXc* this, GlobalContext* globalCtx, s32 animFinished) { - if (animFinished) { - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSheikWalkingAnim); - - Animation_Change(skelAnime, &gSheikWalkingAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -8.0f); - - this->action = SHEIK_ACTION_ACCEL; - this->timer = 0.0f; - - func_80B3C9DC(this); - this->actor.gravity = -((kREG(1) * 0.01f) + 13.0f); - this->actor.minVelocityY = -((kREG(1) * 0.01f) + 13.0f); - } else { - func_80B3C8CC(this, globalCtx); - } -} - -void EnXc_SetupWalkAction(EnXc* this) { - f32* timer = &this->timer; - - *timer += 1.0f; - if (*timer >= 12.0f) { - this->actor.speedXZ = (kREG(2) * 0.01f) + 1.2f; - this->action = SHEIK_ACTION_WALK; - } -} - -void EnXc_SetupHaltAction(EnXc* this) { - SkelAnime* skelAnime = &this->skelAnime; - f32 xzDistToPlayer = this->actor.xzDistToPlayer; - - if (xzDistToPlayer <= (kREG(3) + 95.0f)) { - f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); - - Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -12.0f); - this->action = SHEIK_ACTION_HALT; - this->timer = 0.0f; - } -} - -void EnXc_SetupStoppedAction(EnXc* this) { - f32* timer = &this->timer; - - *timer += 1.0f; - if (*timer >= 12.0f) { - this->action = SHEIK_ACTION_STOPPED; - this->actor.speedXZ = 0.0f; - } -} - -void func_80B3DAF0(EnXc* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 4); - u16 action; - - if (npcAction && - (action = npcAction->action, action == 3 || action == 11 || action == 12 || action == 13 || action == 23)) { - f32 frameCount; - - frameCount = Animation_GetLastFrame(&gSheikPullingOutHarpAnim); - Animation_Change(&this->skelAnime, &gSheikPullingOutHarpAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -4.0f); - this->action = SHEIK_ACTION_7; - this->drawMode = SHEIK_DRAW_PULLING_OUT_HARP; - } -} - -void EnXc_SetupInitialHarpAction(EnXc* this, s32 animFinished) { - SkelAnime* skelAnime; - f32 frameCount; - - if (animFinished) { - skelAnime = &this->skelAnime; - frameCount = Animation_GetLastFrame(&gSheikInitialHarpAnim); - Animation_Change(skelAnime, &gSheikInitialHarpAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_HARP_READY; - this->drawMode = SHEIK_DRAW_HARP; - } -} - -void EnXc_SetupPlayingHarpAction(EnXc* this, GlobalContext* globalCtx, s32 animFinished) { - s32 pad; - SkelAnime* skelAnime; - AnimationHeader* animation; - f32 frameCount; - - if (animFinished) { - skelAnime = &this->skelAnime; - animation = EnXc_GetCurrentHarpAnim(globalCtx, 4); - frameCount = Animation_GetLastFrame(animation); - Animation_Change(skelAnime, animation, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -8.0f); - this->action = SHEIK_PLAYING_HARP; - this->drawMode = SHEIK_DRAW_HARP; - } -} - -void func_80B3DCA8(EnXc* this, GlobalContext* globalCtx) { - f32 frameCount; - - if (globalCtx->csCtx.state != 0) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; - - if (npcAction != NULL && npcAction->action == 8) { - frameCount = Animation_GetLastFrame(&gSheikInitialHarpAnim); - Animation_Change(&this->skelAnime, &gSheikInitialHarpAnim, 0.0f, frameCount, frameCount, ANIMMODE_LOOP, - -8.0f); - this->action = SHEIK_ACTION_10; - } - } -} - -void EnXc_SetupHarpPutawayAction(EnXc* this, GlobalContext* globalCtx) { - f32 curFrame; - f32 animFrameCount; - - if (EnXc_CompareCsAction(this, globalCtx, 5, 4)) { - curFrame = this->skelAnime.curFrame; - animFrameCount = this->skelAnime.endFrame; - if (curFrame >= animFrameCount) { - Animation_Change(&this->skelAnime, &gSheikInitialHarpAnim, -1.0f, - Animation_GetLastFrame(&gSheikInitialHarpAnim), 0.0f, ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_PUT_HARP_AWAY; - } - } else if (EnXc_CsActionsAreNotEqual(this, globalCtx, 8, 4)) { - EnXc_SetupPlayingHarpAction(this, globalCtx, true); - } -} - -void func_80B3DE00(EnXc* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gSheikPullingOutHarpAnim, -1.0f, - Animation_GetLastFrame(&gSheikPullingOutHarpAnim), 0.0f, ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_12; - this->drawMode = SHEIK_DRAW_PULLING_OUT_HARP; - } -} - -void func_80B3DE78(EnXc* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), - ANIMMODE_LOOP, 0.0f); - this->action = SHEIK_ACTION_13; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->timer = 0.0f; - } -} - -void EnXc_SetupReverseAccel(EnXc* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; - - if (npcAction != NULL && npcAction->action == 4) { - Animation_Change(&this->skelAnime, &gSheikWalkingAnim, -1.0f, Animation_GetLastFrame(&gSheikWalkingAnim), - 0.0f, ANIMMODE_LOOP, -12.0f); - this->action = SHEIK_ACTION_REVERSE_ACCEL; - this->actor.world.rot.y += 0x8000; - this->timer = 0.0f; - } - } -} - -void EnXc_SetupReverseWalkAction(EnXc* this) { - this->timer++; - if (this->timer >= 12.0f) { - this->actor.speedXZ = (kREG(2) * 0.01f) + 1.2f; - this->action = SHEIK_ACTION_REVERSE_WALK; - } -} - -void EnXc_SetupReverseHaltAction(EnXc* this) { - f32 xzDistToPlayer = this->actor.xzDistToPlayer; - - if (xzDistToPlayer >= kREG(5) + 140.0f) { - Animation_Change(&this->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), - ANIMMODE_LOOP, -12.0f); - this->action = SHEIK_ACTION_REVERSE_HALT; - this->timer = 0.0f; - } -} - -void EnXc_SetupNutThrow(EnXc* this) { - this->timer++; - if (this->timer >= 12.0f) { - Animation_Change(&this->skelAnime, &gSheikThrowingNutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gSheikThrowingNutAnim), ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_THROW_NUT; - this->timer = 0.0f; - this->actor.speedXZ = 0.0f; - } -} - -void func_80B3E164(EnXc* this, GlobalContext* globalCtx) { - this->timer++; - if (this->timer >= 30.0f) { - this->action = SHEIK_ACTION_DELETE; - EnXc_SpawnNut(this, globalCtx); - } -} - -void EnXc_SetupDisappear(EnXc* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; - - if (npcAction != NULL && npcAction->action == 9) { - s16 sceneNum = globalCtx->sceneNum; - - // Sheik fades away if end of Bolero CS, kill actor otherwise - if (sceneNum == SCENE_SPOT17) { - this->action = SHEIK_ACTION_FADE; - this->drawMode = SHEIK_DRAW_NOTHING; - this->actor.shape.shadowAlpha = 0; - } else { - Actor_Kill(&this->actor); - } - } - } -} - -void EnXc_ActionFunc0(EnXc* this, GlobalContext* globalCtx) { - EnXc_SetColossusAppearSFX(this, globalCtx); - EnXc_SetColossusWindSFX(globalCtx); - func_80B3D750(this, globalCtx); -} - -void EnXc_ActionFunc1(EnXc* this, GlobalContext* globalCtx) { - EnXc_SetColossusAppearSFX(this, globalCtx); - EnXc_SetColossusWindSFX(globalCtx); - EnXc_SetupFallFromSkyAction(this, globalCtx); -} - -void EnXc_GracefulFall(EnXc* this, GlobalContext* globalCtx) { - s32 animFinished = EnXc_AnimIsFinished(this); - - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetLandingSFX(this, globalCtx); - EnXc_SetColossusAppearSFX(this, globalCtx); - EnXc_SetColossusWindSFX(globalCtx); - func_80B3D8A4(this, globalCtx, animFinished); -} - -void EnXc_Accelerate(EnXc* this, GlobalContext* globalCtx) { - EnXc_CalcXZAccel(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_SetupWalkAction(this); -} - -void EnXc_Walk(EnXc* this, GlobalContext* globalCtx) { - func_80B3D644(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_SetupHaltAction(this); -} - -void EnXc_Stopped(EnXc* this, GlobalContext* globalCtx) { - EnXc_CalcXZSpeed(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_SetupStoppedAction(this); -} - -void EnXc_ActionFunc6(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - func_80B3DAF0(this, globalCtx); -} - -void EnXc_ActionFunc7(EnXc* this, GlobalContext* globalCtx) { - s32 animFinished = EnXc_AnimIsFinished(this); - - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupInitialHarpAction(this, animFinished); -} - -void EnXc_ActionFunc8(EnXc* this, GlobalContext* globalCtx) { - s32 animFinished = EnXc_AnimIsFinished(this); - - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupPlayingHarpAction(this, globalCtx, animFinished); -} - -void EnXc_ActionFunc9(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - func_80B3DCA8(this, globalCtx); -} - -void EnXc_ActionFunc10(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupHarpPutawayAction(this, globalCtx); -} - -void EnXc_ActionFunc11(EnXc* this, GlobalContext* globalCtx) { - s32 animFinished = EnXc_AnimIsFinished(this); - - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - func_80B3DE00(this, animFinished); -} - -void EnXc_ActionFunc12(EnXc* this, GlobalContext* globalCtx) { - s32 animFinished = EnXc_AnimIsFinished(this); - - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - func_80B3DE78(this, animFinished); -} - -void EnXc_ActionFunc13(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_InitFlame(this, globalCtx); - EnXc_SetupReverseAccel(this, globalCtx); -} - -void EnXc_ReverseAccelerate(EnXc* this, GlobalContext* globalCtx) { - func_80B3D6F0(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_InitFlame(this, globalCtx); - EnXc_SetupReverseWalkAction(this); -} - -void EnXc_ActionFunc15(EnXc* this, GlobalContext* globalCtx) { - func_80B3D710(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_InitFlame(this, globalCtx); - EnXc_SetupReverseHaltAction(this); -} - -void EnXc_HaltAndWaitToThrowNut(EnXc* this, GlobalContext* globalCtx) { - func_80B3D730(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_InitFlame(this, globalCtx); - EnXc_SetupNutThrow(this); -} - -void EnXc_ThrowNut(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetNutThrowSFX(this, globalCtx); - EnXc_InitFlame(this, globalCtx); - func_80B3E164(this, globalCtx); -} - -void EnXc_Delete(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_InitFlame(this, globalCtx); - EnXc_SetupDisappear(this, globalCtx); -} - -void EnXc_Fade(EnXc* this, GlobalContext* globalCtx) { - EnXc_InitFlame(this, globalCtx); -} - -void func_80B3E87C(Gfx** dList, EnXc* this) { - f32 currentFrame = this->skelAnime.curFrame; - - if (currentFrame >= 34.0f) { - *dList = gSheikHarpDL; - } -} - -s32 EnXc_PullingOutHarpOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnXc* this = (EnXc*)thisx; - - if (limbIndex == 12) { - func_80B3E87C(dList, this); - } - - return 0; -} - -s32 EnXc_HarpOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - EnXc* this = (EnXc*)thisx; - - if (limbIndex == 12) { - *dList = gSheikHarpDL; - } - - return 0; -} - -void EnXc_DrawPullingOutHarp(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - s32 pad; - s16 eyePattern = this->eyeIdx; - void* eyeTexture = sEyeTextures[eyePattern]; - SkelAnime* skelAnime = &this->skelAnime; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad2; - - OPEN_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1444); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 20, 0); - gDPSetEnvColor(POLY_OPA_DISP++, 60, 0, 0, 0); - - func_80093D18(gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnXc_PullingOutHarpOverrideLimbDraw, NULL, this); - CLOSE_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1497); -} - -void EnXc_DrawHarp(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - s32 pad; - s16 eyePattern = this->eyeIdx; - void* eyeTexture = sEyeTextures[eyePattern]; - SkelAnime* skelAnime = &this->skelAnime; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad2; - - OPEN_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1511); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 20, 0); - gDPSetEnvColor(POLY_OPA_DISP++, 60, 0, 0, 0); - - func_80093D18(gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnXc_HarpOverrideLimbDraw, NULL, this); - CLOSE_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1564); -} - -void func_80B3EBF0(EnXc* this, GlobalContext* globalCtx) { - this->action = SHEIK_ACTION_20; -} - -void func_80B3EC00(EnXc* this) { - this->action = SHEIK_ACTION_21; -} - -void func_80B3EC0C(EnXc* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->state != 0) { - CsCmdActorAction* npcAction = csCtx->npcActions[4]; - - if ((npcAction != NULL) && (npcAction->action != 1)) { - PosRot* posRot = &this->actor.world; - Vec3i* startPos = &npcAction->startPos; - ActorShape* shape = &this->actor.shape; - - posRot->pos.x = startPos->x; - posRot->pos.y = startPos->y; - posRot->pos.z = startPos->z; - - posRot->rot.y = shape->rot.y = npcAction->rot.y; - - this->action = SHEIK_ACTION_22; - this->drawMode = SHEIK_DRAW_DEFAULT; - } - } -} - -void func_80B3EC90(EnXc* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->state != 0) { - CsCmdActorAction* npcAction = csCtx->npcActions[4]; - - if (npcAction != NULL && npcAction->action != 6) { - func_80B3C9EC(this); - } - } -} - -void func_80B3ECD8(EnXc* this) { - this->timer++; - if (this->timer >= 12.0f) { - this->actor.speedXZ = kREG(2) * 0.01f + 1.2f; - this->action = SHEIK_ACTION_24; - } -} - -void EnXc_ActionFunc20(EnXc* this, GlobalContext* globalCtx) { - func_80B3EC00(this); -} - -void EnXc_ActionFunc21(EnXc* this, GlobalContext* globalCtx) { - func_80B3EC0C(this, globalCtx); -} - -void EnXc_ActionFunc22(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - func_80B3EC90(this, globalCtx); -} - -void EnXc_ActionFunc23(EnXc* this, GlobalContext* globalCtx) { - func_80B3D6F0(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - func_80B3ECD8(this); -} - -void EnXc_ActionFunc24(EnXc* this, GlobalContext* globalCtx) { -} - -void EnXc_ActionFunc25(EnXc* this, GlobalContext* globalCtx) { -} - -void EnXc_ActionFunc26(EnXc* this, GlobalContext* globalCtx) { -} - -void EnXc_ActionFunc27(EnXc* this, GlobalContext* globalCtx) { -} - -void EnXc_ActionFunc28(EnXc* this, GlobalContext* globalCtx) { -} - -void func_80B3EE64(EnXc* this, GlobalContext* globalCtx) { - this->action = SHEIK_ACTION_SERENADE; -} - -void func_80B3EE74(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_SerenadeCS(this, globalCtx)) { - this->action = SHEIK_ACTION_30; - } -} - -void func_80B3EEA4(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_30, SHEIK_ACTION_31); -} - -void func_80B3EEC8(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_31, SHEIK_ACTION_32); -} - -void func_80B3EEEC(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_32, SHEIK_ACTION_33); -} - -void func_80B3EF10(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_33, SHEIK_ACTION_34); -} - -void func_80B3EF34(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_34, SHEIK_ACTION_35); -} - -void func_80B3EF58(EnXc* this) { - func_80B3C7D4(this, SHEIK_ACTION_35, SHEIK_ACTION_36, SHEIK_ACTION_34); -} - -void func_80B3EF80(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_36, SHEIK_ACTION_37); -} - -void func_80B3EFA4(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_37, SHEIK_ACTION_38); -} - -void func_80B3EFC8(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_38, SHEIK_ACTION_39); -} - -void func_80B3EFEC(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_39, SHEIK_ACTION_40); -} - -void func_80B3F010(EnXc* this) { - f32 xzDistToPlayer = this->actor.xzDistToPlayer; - - if (kREG(5) + 140.0f <= xzDistToPlayer) { - Animation_Change(&this->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), - ANIMMODE_LOOP, -12.0f); - this->action = SHEIK_ACTION_41; - this->timer = 0.0f; - } -} - -void func_80B3F0B8(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_41, SHEIK_ACTION_42); -} - -void func_80B3F0DC(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_42, SHEIK_ACTION_43); -} - -void func_80B3F100(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_43, SHEIK_ACTION_44); -} - -void EnXc_Serenade(EnXc* this, GlobalContext* globalCtx) { - func_80B3EE74(this, globalCtx); -} - -void EnXc_ActionFunc30(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc21(this, globalCtx); - func_80B3EEA4(this); -} - -void EnXc_ActionFunc31(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc6(this, globalCtx); - func_80B3C588(this, globalCtx, 4); - func_80B3EEC8(this); -} - -void EnXc_ActionFunc32(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc7(this, globalCtx); - func_80B3EEEC(this); -} - -void EnXc_ActionFunc33(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc8(this, globalCtx); - func_80B3EF10(this); -} - -void EnXc_ActionFunc34(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc9(this, globalCtx); - func_80B3EF34(this); -} - -void EnXc_ActionFunc35(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc10(this, globalCtx); - func_80B3EF58(this); -} - -void EnXc_ActionFunc36(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc11(this, globalCtx); - func_80B3EF80(this); -} - -void EnXc_ActionFunc37(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc12(this, globalCtx); - func_80B3EFA4(this); -} - -void EnXc_ActionFunc38(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc13(this, globalCtx); - func_80B3EFC8(this); -} - -void EnXc_ActionFunc39(EnXc* this, GlobalContext* globalCtx) { - EnXc_ReverseAccelerate(this, globalCtx); - func_80B3EFEC(this); -} - -void EnXc_ActionFunc40(EnXc* this, GlobalContext* globalCtx) { - func_80B3D710(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - func_80B3F010(this); -} - -void EnXc_ActionFunc41(EnXc* this, GlobalContext* globalCtx) { - EnXc_HaltAndWaitToThrowNut(this, globalCtx); - func_80B3F0B8(this); -} - -void EnXc_ActionFunc42(EnXc* this, GlobalContext* globalCtx) { - EnXc_ThrowNut(this, globalCtx); - func_80B3F0DC(this); -} - -void EnXc_ActionFunc43(EnXc* this, GlobalContext* globalCtx) { - EnXc_Delete(this, globalCtx); - func_80B3F100(this); -} - -void EnXc_ActionFunc44(EnXc* this, GlobalContext* globalCtx) { -} - -void func_80B3F3C8(EnXc* this, GlobalContext* globalCtx) { - this->action = SHEIK_ACTION_45; -} - -void func_80B3F3D8() { - func_800788CC(NA_SE_PL_SKIP); -} - -void EnXc_PlayDiveSFX(Vec3f* src, GlobalContext* globalCtx) { - f32 wDest[2]; - - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, src, &D_80B42DA0, wDest); - func_80078914(&D_80B42DA0, NA_SE_EV_DIVE_INTO_WATER); -} - -void EnXc_LakeHyliaDive(GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = npcAction = EnXc_GetCsCmd(globalCtx, 0); - - if (npcAction != NULL) { - Vec3f startPos; - - startPos.x = npcAction->startPos.x; - startPos.y = npcAction->startPos.y; - startPos.z = npcAction->startPos.z; - - EffectSsGRipple_Spawn(globalCtx, &startPos, 100, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &startPos, 100, 500, 10); - EffectSsGRipple_Spawn(globalCtx, &startPos, 100, 500, 20); - EffectSsGSplash_Spawn(globalCtx, &startPos, NULL, NULL, 1, 0); - EnXc_PlayDiveSFX(&startPos, globalCtx); - } -} - -void func_80B3F534(GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - u16 frameCount = csCtx->frames; - - if (frameCount == 310) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, -1044.0f, -1243.0f, 7458.0f, 0, 0, 0, - WARP_DESTINATION); - } -} - -void func_80B3F59C(EnXc* this, GlobalContext* globalCtx) { - static s32 D_80B41DAC = 1; - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); - - if (npcAction != NULL) { - s32 action = npcAction->action; - - if (action != D_80B41DAC) { - switch (action) { - case 2: - func_80B3F3D8(); - break; - case 3: - EnXc_LakeHyliaDive(globalCtx); - break; - default: - break; - } - D_80B41DAC = action; - } - } -} - -void func_80B3F620(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_45, SHEIK_ACTION_46); -} - -void func_80B3F644(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_46, SHEIK_ACTION_47); -} - -void func_80B3F668(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CompareCsAction(this, globalCtx, 4, 4)) { - EnXc_ChangeAnimation(this, &gSheikWalkingAnim, ANIMMODE_LOOP, -12.0f, true); - this->action = SHEIK_ACTION_48; - this->actor.world.rot.y += 0x8000; - this->timer = 0.0f; - } -} - -void func_80B3F6DC(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_48, SHEIK_ACTION_49); -} - -void EnXc_SetupKneelAction(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CompareCsAction(this, globalCtx, 16, 4)) { - EnXc_ChangeAnimation(this, &gSheikKneelingAnim, ANIMMODE_LOOP, 0.0f, false); - this->action = SHEIK_ACTION_KNEEL; - } -} - -void func_80B3F754(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CompareCsAction(this, globalCtx, 22, 4)) { - EnXc_ChangeAnimation(this, &gSheikAnim_01A048, ANIMMODE_LOOP, 0.0f, false); - this->action = SHEIK_ACTION_51; - func_80B3C588(this, globalCtx, 4); - } -} - -void func_80B3F7BC(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CompareCsAction(this, globalCtx, 9, 4)) { - this->action = SHEIK_ACTION_52; - this->drawMode = SHEIK_DRAW_NOTHING; - } -} - -void EnXc_ActionFunc45(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc20(this, globalCtx); - func_80B3F620(this); -} - -void EnXc_ActionFunc46(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc21(this, globalCtx); - func_80B3F644(this); -} - -void EnXc_ActionFunc47(EnXc* this, GlobalContext* globalCtx) { - func_80B3F534(globalCtx); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - func_80B3C588(this, globalCtx, 4); - func_80B3F668(this, globalCtx); -} - -void EnXc_ActionFunc48(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc23(this, globalCtx); - func_80B3F6DC(this); -} - -void EnXc_ActionFunc49(EnXc* this, GlobalContext* globalCtx) { - func_80B3D710(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetWalkingSFX(this, globalCtx); - EnXc_SetupKneelAction(this, globalCtx); -} - -void EnXc_Kneel(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - func_80B3F59C(this, globalCtx); - func_80B3C588(this, globalCtx, 4); - func_80B3F754(this, globalCtx); -} - -void EnXc_ActionFunc51(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - func_80B3F59C(this, globalCtx); - func_80B3C620(this, globalCtx, 4); - func_80B3F7BC(this, globalCtx); -} - -void EnXc_ActionFunc52(EnXc* this, GlobalContext* globalCtx) { - func_80B3F59C(this, globalCtx); -} - -void func_80B3FA08(EnXc* this, GlobalContext* globalCtx) { - this->action = SHEIK_ACTION_53; - this->triforceAngle = kREG(24) + 0x53FC; -} - -void func_80B3FA2C(void) { - func_800F3F3C(1); -} - -void EnXc_PlayTriforceSFX(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - - if (this->unk_2A8) { - s32 pad; - Vec3f src; - Vec3f pos; - Vec3f sp1C = { 0.0f, 0.0f, 0.0f }; - f32 wDest; - - Matrix_MultVec3f(&sp1C, &src); - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &src, &pos, &wDest); - Audio_PlaySoundAtPosition(globalCtx, &pos, 80, NA_SE_EV_TRIFORCE_MARK); - this->unk_2A8 = 0; - } -} - -void func_80B3FAE0(EnXc* this) { - if (Animation_OnFrame(&this->skelAnime, 38.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_SK_SHOUT); - func_80B3FA2C(); - } -} - -void EnXc_CalcTriforce(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - - if (EnXc_CompareCsAction(this, globalCtx, 21, 4)) { - this->unk_274 = 1; - if (this->unk_2AC == 0) { - this->unk_2AC = 1; - this->unk_2A8 = 1; - } - } else if (EnXc_CompareCsAction(this, globalCtx, 19, 4)) { - this->unk_274 = 2; - } - if (this->unk_274 != 0) { - f32* timer = &this->timer; - s32* prim = this->triforcePrimColor; - s32* env = this->triforceEnvColor; - f32* scale = this->triforceScale; - - if (this->unk_274 == 1) { - if (*timer < kREG(25) + 40.0f) { - f32 div = *timer / (kREG(25) + 40.0f); - - prim[2] = -85.0f * div + 255; - prim[3] = 255.0f * div; - env[1] = 100.0f * div + 100; - *timer += 1.0f; - } else { - prim[2] = 170; - prim[3] = 255; - env[1] = 200; - } - scale[0] = kREG(19) * 0.1f + 40.0f; - scale[1] = kREG(20) * 0.1f + 40.0f; - scale[2] = kREG(21) * 0.1f + 40.0f; - } else if (this->unk_274 == 2) { - f32 maxTime = (kREG(25) + 40.0f) + (kREG(27) + 90.0f); - - if (*timer < maxTime) { - f32 div = (*timer - (kREG(25) + 40.0f)) / (kREG(27) + 90.0f); - scale[0] = (kREG(19) * 0.1f + 40.0f) + div * ((kREG(26) + 50.0f) * (kREG(19) * 0.1f + 40.0f)); - scale[1] = (kREG(20) * 0.1f + 40.0f) + div * ((kREG(26) + 50.0f) * (kREG(20) * 0.1f + 40.0f)); - scale[2] = (kREG(21) * 0.1f + 40.0f) + div * ((kREG(26) + 50.0f) * (kREG(21) * 0.1f + 40.0f)); - *timer += 1.0f; - } else { - scale[0] = (kREG(19) * 0.1f + 40.0f) * (kREG(26) + 50.0f); - scale[1] = (kREG(20) * 0.1f + 40.0f) * (kREG(26) + 50.0f); - scale[2] = (kREG(21) * 0.1f + 40.0f) * (kREG(26) + 50.0f); - } - this->triforceAngle += (s16)(kREG(28) + 0x2EE0); - } - } -} - -void func_80B3FF0C(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CsActionsAreNotEqual(this, globalCtx, 1, 4)) { - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->state != 0) { - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; - - if (npcAction != NULL) { - PosRot* posRot = &this->actor.world; - ActorShape* shape = &this->actor.shape; - Vec3i* startPos = &npcAction->startPos; - - posRot->pos.x = startPos->x; - posRot->pos.y = startPos->y; - posRot->pos.z = startPos->z; - - posRot->rot.y = shape->rot.y = npcAction->rot.y; - } - } - - this->action = SHEIK_ACTION_54; - this->drawMode = SHEIK_DRAW_DEFAULT; - } -} - -void EnXc_SetupShowTriforceAction(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CompareCsAction(this, globalCtx, 10, 4)) { - Animation_Change(&this->skelAnime, &gSheikShowingTriforceOnHandAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gSheikShowingTriforceOnHandAnim), ANIMMODE_ONCE, -8.0f); - this->action = SHEIK_ACTION_SHOW_TRIFORCE; - this->drawMode = SHEIK_DRAW_TRIFORCE; - } -} - -void EnXc_SetupShowTriforceIdleAction(EnXc* this, s32 animFinished) { - if (animFinished) { - Animation_Change(&this->skelAnime, &gSheikShowingTriforceOnHandIdleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gSheikShowingTriforceOnHandIdleAnim), ANIMMODE_LOOP, 0.0f); - this->action = SHEIK_ACTION_SHOW_TRIFORCE_IDLE; - } -} -void func_80B400AC(EnXc* this, GlobalContext* globalCtx) { - if (EnXc_CompareCsAction(this, globalCtx, 9, 4)) { - Actor_Kill(&this->actor); - } -} - -void EnXc_ActionFunc53(EnXc* this, GlobalContext* globalCtx) { - func_80B3FF0C(this, globalCtx); -} - -void EnXc_ActionFunc54(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupShowTriforceAction(this, globalCtx); - func_80B3C888(this, globalCtx); -} - -void EnXc_ShowTriforce(EnXc* this, GlobalContext* globalCtx) { - s32 animFinished = EnXc_AnimIsFinished(this); - - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_CalcTriforce(&this->actor, globalCtx); - func_80B3FAE0(this); - EnXc_SetupShowTriforceIdleAction(this, animFinished); - func_80B3C888(this, globalCtx); -} - -void EnXc_ShowTriforceIdle(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_CalcTriforce(&this->actor, globalCtx); - func_80B400AC(this, globalCtx); -} - -s32 EnXc_TriforceOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* thisx) { - if (limbIndex == 15) { - *dList = gSheikDL_011620; - } - return 0; -} - -void EnXc_TriforcePostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - s32 pad[2]; - EnXc* this = (EnXc*)thisx; - - if (limbIndex == 15) { - Vec3f vec = { 0.0f, 0.0f, 0.0f }; - EnXc_PlayTriforceSFX(&this->actor, globalCtx); - Matrix_MultVec3f(&vec, &this->handPos); - this->unk_2BC = 1; - } -} - -void EnXc_DrawTriforce(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - s32 pad; - s16 eyeIdx = this->eyeIdx; - void* eyeTexture = sEyeTextures[eyeIdx]; - SkelAnime* skelAnime = &this->skelAnime; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad2; - - OPEN_DISPS(gfxCtx, "../z_en_oA2_inMetamol.c", 565); - if (this->unk_2BC != 0) { - Mtx* mtx = Graph_Alloc(gfxCtx, sizeof(Mtx)); - s32* primColor = this->triforcePrimColor; - s32* envColor = this->triforceEnvColor; - f32* scale = this->triforceScale; - - Matrix_Push(); - Matrix_Translate(kREG(16) + 100.0f, kREG(17) + 4460.0f, kREG(18) + 1190.0f, MTXMODE_APPLY); - Matrix_RotateZYX(kREG(22), kREG(23), this->triforceAngle, MTXMODE_APPLY); - Matrix_Scale(scale[0], scale[1], scale[2], MTXMODE_APPLY); - Matrix_ToMtx(mtx, "../z_en_oA2_inMetamol.c", 602); - Matrix_Pop(); - func_80093D84(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, primColor[2], primColor[3]); - gDPSetEnvColor(POLY_XLU_DISP++, 255, envColor[1], 0, 128); - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gSheikDL_012970); - } - - func_8002EBCC(thisx, globalCtx, 0); - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnXc_TriforceOverrideLimbDraw, EnXc_TriforcePostLimbDraw, this); - CLOSE_DISPS(gfxCtx, "../z_en_oA2_inMetamol.c", 668); -} - -void func_80B40590(EnXc* this, GlobalContext* globalCtx) { - this->action = SHEIK_ACTION_NOCTURNE_INIT; - this->drawMode = SHEIK_DRAW_SQUINT; -} - -void EnXc_SetThrownAroundSFX(EnXc* this) { - SkelAnime* skelAnime = &this->skelAnime; - - if (Animation_OnFrame(skelAnime, 9.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_BOUND_GRASS); - func_80078914(&this->actor.projectedPos, NA_SE_VO_SK_CRASH); - } else if (Animation_OnFrame(skelAnime, 26.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_BOUND_GRASS); - } else if (Animation_OnFrame(skelAnime, 28.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_GRASS); - } else if (Animation_OnFrame(skelAnime, 34.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_GRASS); - } -} - -void EnXc_PlayLinkScreamSFX(EnXc* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 1455) { - func_800F3F3C(7); - } -} - -void EnXc_SetCrySFX(EnXc* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx = &globalCtx->csCtx; - - if (csCtx->frames == 869) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_SK_CRY_0); - } else if (csCtx->frames == 939) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_SK_CRY_1); - } -} - -void func_80B406F8(Actor* thisx) { - EnXc* this = (EnXc*)thisx; - - this->action = SHEIK_ACTION_NOCTURNE_INIT; - this->drawMode = SHEIK_DRAW_NOTHING; - this->actor.shape.shadowAlpha = 0; -} - -void EnXc_SetupIdleInNocturne(EnXc* this, GlobalContext* globalCtx) { - s32 pad; - ActorShape* actorShape = &this->actor.shape; - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); - - func_80B3C9DC(this); - func_80B3C588(this, globalCtx, 4); - Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - this->action = SHEIK_ACTION_NOCTURNE_IDLE; - this->drawMode = SHEIK_DRAW_SQUINT; - actorShape->shadowAlpha = 255; -} - -void EnXc_SetupDefenseStance(Actor* thisx) { - EnXc* this = (EnXc*)thisx; - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSheikDefenseStanceAnim); - - Animation_Change(skelAnime, &gSheikDefenseStanceAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -8.0f); - this->action = SHEIK_ACTION_DEFENSE_STANCE; - this->drawMode = SHEIK_DRAW_DEFAULT; -} - -void EnXc_SetupContortions(EnXc* this, GlobalContext* globalCtx) { - s32 pad; - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); - - Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - func_80B3C588(this, globalCtx, 4); - func_80B3C964(this, globalCtx); - Animation_Change(skelAnime, &gSheikContortionsAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikContortionsAnim), - ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_CONTORT; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 255; -} - -void EnXc_SetupFallInNocturne(EnXc* this, GlobalContext* globalCtx) { - s32 pad; - SkelAnime* skelAnime = &this->skelAnime; - f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); - - Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - func_80B3C588(this, globalCtx, 4); - func_80B3C964(this, globalCtx); - Animation_Change(skelAnime, &gSheikFallingFromContortionsAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gSheikFallingFromContortionsAnim), ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_NOCTURNE_FALL; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 255; -} - -void EnXc_SetupHittingGroundInNocturne(EnXc* this, GlobalContext* globalCtx) { - s32 pad[3]; - f32 frameCount = Animation_GetLastFrame(&gSheikHittingGroundAnim); - - func_80B3C9DC(this); - func_80B3C588(this, globalCtx, 4); - Animation_Change(&this->skelAnime, &gSheikHittingGroundAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_NOCTURNE_HIT_GROUND; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 255; -} - -void func_80B40A78(EnXc* this, GlobalContext* globalCtx) { - s32 pad[3]; - f32 frameCount = Animation_GetLastFrame(&gSheikHittingGroundAnim); - - func_80B3C9DC(this); - func_80B3C588(this, globalCtx, 4); - Animation_Change(&this->skelAnime, &gSheikHittingGroundAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); - this->action = SHEIK_ACTION_63; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 255; -} - -void EnXc_SetupKneelInNocturne(EnXc* this, GlobalContext* globalCtx) { - s32 pad[3]; - f32 frameCount = Animation_GetLastFrame(&gSheikKneelingAnim); - - func_80B3C9DC(this); - func_80B3C588(this, globalCtx, 4); - Animation_Change(&this->skelAnime, &gSheikKneelingAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - this->action = SHEIK_ACTION_NOCTURNE_KNEEL; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 255; -} - -void func_80B40BB4(EnXc* this, GlobalContext* globalCtx) { - s32 pad[3]; - f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); - func_80B3C9DC(this); - func_80B3C588(this, globalCtx, 4); - Animation_Change(&this->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - this->action = SHEIK_ACTION_65; - this->drawMode = SHEIK_DRAW_DEFAULT; - this->actor.shape.shadowAlpha = 255; -} - -void func_80B40C50(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_65, SHEIK_ACTION_66); -} - -void func_80B40C74(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_66, SHEIK_ACTION_67); -} - -void func_80B40C98(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_67, SHEIK_ACTION_68); -} - -void func_80B40CBC(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_68, SHEIK_ACTION_69); -} - -void func_80B40CE0(EnXc* this) { - func_80B3C7D4(this, SHEIK_ACTION_69, SHEIK_ACTION_70, SHEIK_ACTION_68); -} - -void func_80B40D08(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_70, SHEIK_ACTION_71); -} - -void func_80B40D2C(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_71, SHEIK_ACTION_72); -} - -void func_80B40D50(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_72, SHEIK_ACTION_NOCTURNE_REVERSE_ACCEL); -} - -void func_80B40D74(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_NOCTURNE_REVERSE_ACCEL, SHEIK_ACTION_NOCTURNE_REVERSE_WALK); -} - -void EnXc_SetupReverseHaltInNocturneCS(EnXc* this) { - f32 xzDistToPlayer = this->actor.xzDistToPlayer; - - if (kREG(5) + 140.0f <= xzDistToPlayer) { - Animation_Change(&this->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), - ANIMMODE_LOOP, -12.0f); - this->action = SHEIK_ACTION_NOCTURNE_REVERSE_HALT; - this->timer = 0.0f; - } -} - -void func_80B40E40(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_NOCTURNE_REVERSE_HALT, SHEIK_ACTION_NOCTURNE_THROW_NUT); -} - -void func_80B40E64(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_NOCTURNE_THROW_NUT, SHEIK_ACTION_77); -} - -void func_80B40E88(EnXc* this) { - EnXc_CheckAndSetAction(this, SHEIK_ACTION_77, SHEIK_ACTION_78); -} - -s32 EnXc_SetupNocturneState(Actor* thisx, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 4); - - if (npcAction != NULL) { - s32 action = npcAction->action; - EnXc* this = (EnXc*)thisx; - s32 prevAction = this->unk_26C; - - if (action != prevAction) { - switch (action) { - case 1: - func_80B406F8(thisx); - break; - case 6: - EnXc_SetupIdleInNocturne(this, globalCtx); - break; - case 20: - EnXc_SetupDefenseStance(thisx); - break; - case 18: - EnXc_SetupContortions(this, globalCtx); - break; - case 14: - EnXc_SetupFallInNocturne(this, globalCtx); - break; - case 19: - EnXc_SetupHittingGroundInNocturne(this, globalCtx); - break; - case 15: - func_80B40A78(this, globalCtx); - break; - case 16: - EnXc_SetupKneelInNocturne(this, globalCtx); - break; - case 17: - func_80B40BB4(this, globalCtx); - break; - case 9: - Actor_Kill(thisx); - break; - default: - osSyncPrintf("En_Oa2_Stalker_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - - this->unk_26C = action; - return 1; - } - } - return 0; -} - -void EnXc_InitialNocturneAction(EnXc* this, GlobalContext* globalCtx) { - EnXc_SetupNocturneState(&this->actor, globalCtx); -} - -void EnXc_IdleInNocturne(EnXc* this, GlobalContext* globalCtx) { - func_80B3C588(this, globalCtx, 4); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetupNocturneState(&this->actor, globalCtx); -} - -void EnXc_DefenseStance(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupNocturneState(&this->actor, globalCtx); -} - -void EnXc_Contort(EnXc* this, GlobalContext* globalCtx) { - EnXc_SetCrySFX(this, globalCtx); - EnXc_AnimIsFinished(this); - EnXc_SetEyePattern(this); - if (!EnXc_SetupNocturneState(&this->actor, globalCtx)) { - func_80B3C924(this, globalCtx); - EnXc_BgCheck(this, globalCtx); - } -} - -void EnXc_FallInNocturne(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_SetEyePattern(this); - EnXc_SetThrownAroundSFX(this); - if (!EnXc_SetupNocturneState(&this->actor, globalCtx)) { - func_80B3C8CC(this, globalCtx); - EnXc_BgCheck(this, globalCtx); - } -} - -void EnXc_HitGroundInNocturne(EnXc* this, GlobalContext* globalCtx) { - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupNocturneState(&this->actor, globalCtx); -} - -void EnXc_ActionFunc63(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_PlayLinkScreamSFX(this, globalCtx); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupNocturneState(&this->actor, globalCtx); -} - -void EnXc_KneelInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupNocturneState(&this->actor, globalCtx); -} - -void EnXc_ActionFunc65(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc6(this, globalCtx); - func_80B3C588(this, globalCtx, 4); - func_80B40C50(this); -} - -void EnXc_ActionFunc66(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc7(this, globalCtx); - func_80B40C74(this); -} - -void EnXc_ActionFunc67(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc8(this, globalCtx); - func_80B40C98(this); -} - -void EnXc_ActionFunc68(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc9(this, globalCtx); - func_80B40CBC(this); -} - -void EnXc_ActionFunc69(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc10(this, globalCtx); - func_80B40CE0(this); -} - -void EnXc_ActionFunc70(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc11(this, globalCtx); - func_80B40D08(this); -} - -void EnXc_ActionFunc71(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc12(this, globalCtx); - func_80B40D2C(this); -} - -void EnXc_ActionFunc72(EnXc* this, GlobalContext* globalCtx) { - EnXc_ActionFunc13(this, globalCtx); - func_80B40D50(this); -} - -void EnXc_ReverseAccelInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - EnXc_ReverseAccelerate(this, globalCtx); - func_80B40D74(this); -} - -void EnXc_ReverseWalkInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - func_80B3D710(this); - EnXc_AnimIsFinished(this); - EnXc_BgCheck(this, globalCtx); - EnXc_SetEyePattern(this); - EnXc_SetupReverseHaltInNocturneCS(this); -} - -void EnXc_ReverseHaltInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - EnXc_HaltAndWaitToThrowNut(this, globalCtx); - func_80B40E40(this); -} - -void EnXc_ThrowNutInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - EnXc_ThrowNut(this, globalCtx); - func_80B40E64(this); -} - -void EnXc_DeleteInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - EnXc_Delete(this, globalCtx); - func_80B40E88(this); -} - -void EnXc_KillInNocturneCS(EnXc* this, GlobalContext* globalCtx) { - Actor_Kill(&this->actor); -} - -void EnXc_DrawSquintingEyes(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - SkelAnime* skelAnime = &this->skelAnime; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_en_oA2_inStalker.c", 839); - func_80093D18(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gSheikEyeSquintingTex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gSheikEyeSquintingTex)); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, - NULL); - CLOSE_DISPS(gfxCtx, "../z_en_oA2_inStalker.c", 854); -} - -void EnXc_InitTempleOfTime(EnXc* this, GlobalContext* globalCtx) { - if (LINK_IS_ADULT) { - if (!(gSaveContext.eventChkInf[12] & 0x20)) { - gSaveContext.eventChkInf[12] |= 0x20; - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gTempleOfTimeFirstAdultCs); - gSaveContext.cutsceneTrigger = 1; - func_80B3EBF0(this, globalCtx); - } else if (!(gSaveContext.eventChkInf[5] & 0x20) && (gSaveContext.eventChkInf[4] & 0x100)) { - gSaveContext.eventChkInf[5] |= 0x20; - Item_Give(globalCtx, ITEM_SONG_PRELUDE); - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gTempleOfTimePreludeCs); - gSaveContext.cutsceneTrigger = 1; - this->action = SHEIK_ACTION_30; - } else if (!(gSaveContext.eventChkInf[5] & 0x20)) { - func_80B3C9EC(this); - } else { - Actor_Kill(&this->actor); - } - } else { - Actor_Kill(&this->actor); - } -} - -void EnXc_SetupDialogueAction(EnXc* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->action = SHEIK_ACTION_IN_DIALOGUE; - } else { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - if (INV_CONTENT(ITEM_HOOKSHOT) != ITEM_NONE) { - this->actor.textId = 0x7010; - } else { - this->actor.textId = 0x700F; - } - func_8002F2F4(&this->actor, globalCtx); - } -} - -void func_80B41798(EnXc* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->action = SHEIK_ACTION_BLOCK_PEDESTAL; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - } -} - -void EnXc_BlockingPedestalAction(EnXc* this, GlobalContext* globalCtx) { - EnXc_BgCheck(this, globalCtx); - EnXc_UpdateCollider(&this->actor, globalCtx); - EnXc_CalculateHeadTurn(this, globalCtx); - EnXc_AnimIsFinished(this); - EnXc_SetEyePattern(this); - EnXc_SetupDialogueAction(this, globalCtx); -} - -void EnXc_ActionFunc80(EnXc* this, GlobalContext* globalCtx) { - EnXc_BgCheck(this, globalCtx); - EnXc_UpdateCollider(&this->actor, globalCtx); - EnXc_CalculateHeadTurn(this, globalCtx); - EnXc_AnimIsFinished(this); - EnXc_SetEyePattern(this); - func_80B41798(this, globalCtx); -} - -static EnXcActionFunc sActionFuncs[] = { - EnXc_ActionFunc0, - EnXc_ActionFunc1, - EnXc_GracefulFall, - EnXc_Accelerate, - EnXc_Walk, - EnXc_Stopped, - EnXc_ActionFunc6, - EnXc_ActionFunc7, - EnXc_ActionFunc8, - EnXc_ActionFunc9, - EnXc_ActionFunc10, - EnXc_ActionFunc11, - EnXc_ActionFunc12, - EnXc_ActionFunc13, - EnXc_ReverseAccelerate, - EnXc_ActionFunc15, - EnXc_HaltAndWaitToThrowNut, - EnXc_ThrowNut, - EnXc_Delete, - EnXc_Fade, - EnXc_ActionFunc20, - EnXc_ActionFunc21, - EnXc_ActionFunc22, - EnXc_ActionFunc23, - EnXc_ActionFunc24, - EnXc_ActionFunc25, - EnXc_ActionFunc26, - EnXc_ActionFunc27, - EnXc_ActionFunc28, - EnXc_Serenade, - EnXc_ActionFunc30, - EnXc_ActionFunc31, - EnXc_ActionFunc32, - EnXc_ActionFunc33, - EnXc_ActionFunc34, - EnXc_ActionFunc35, - EnXc_ActionFunc36, - EnXc_ActionFunc37, - EnXc_ActionFunc38, - EnXc_ActionFunc39, - EnXc_ActionFunc40, - EnXc_ActionFunc41, - EnXc_ActionFunc42, - EnXc_ActionFunc43, - EnXc_ActionFunc44, - EnXc_ActionFunc45, - EnXc_ActionFunc46, - EnXc_ActionFunc47, - EnXc_ActionFunc48, - EnXc_ActionFunc49, - EnXc_Kneel, - EnXc_ActionFunc51, - EnXc_ActionFunc52, - EnXc_ActionFunc53, - EnXc_ActionFunc54, - EnXc_ShowTriforce, - EnXc_ShowTriforceIdle, - EnXc_InitialNocturneAction, - EnXc_IdleInNocturne, - EnXc_DefenseStance, - EnXc_Contort, - EnXc_FallInNocturne, - EnXc_HitGroundInNocturne, - EnXc_ActionFunc63, - EnXc_KneelInNocturneCS, - EnXc_ActionFunc65, - EnXc_ActionFunc66, - EnXc_ActionFunc67, - EnXc_ActionFunc68, - EnXc_ActionFunc69, - EnXc_ActionFunc70, - EnXc_ActionFunc71, - EnXc_ActionFunc72, - EnXc_ReverseAccelInNocturneCS, - EnXc_ReverseWalkInNocturneCS, - EnXc_ReverseHaltInNocturneCS, - EnXc_ThrowNutInNocturneCS, - EnXc_DeleteInNocturneCS, - EnXc_KillInNocturneCS, - EnXc_BlockingPedestalAction, - EnXc_ActionFunc80, -}; - -void EnXc_Update(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - s32 action = this->action; - - if ((action < 0) || (action >= ARRAY_COUNT(sActionFuncs)) || (sActionFuncs[action] == NULL)) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - } else { - sActionFuncs[action](this, globalCtx); - } -} - -void EnXc_Init(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSheikSkel, &gSheikIdleAnim, this->jointTable, this->morphTable, - ARRAY_COUNT(this->jointTable)); - EnXc_InitCollider(thisx, globalCtx); - - switch (this->actor.params) { - case SHEIK_TYPE_1: - func_80B3EBF0(this, globalCtx); - break; - case SHEIK_TYPE_2: // Beta Serenade Cutscene or Learning Prelude - func_80B3EE64(this, globalCtx); - break; - case SHEIK_TYPE_3: - func_80B3F3C8(this, globalCtx); - break; - case SHEIK_TYPE_4: - func_80B3FA08(this, globalCtx); - break; - case SHEIK_TYPE_5: - func_80B40590(this, globalCtx); - break; - case SHEIK_TYPE_MINUET: - func_80B3CA38(this, globalCtx); - break; - case SHEIK_TYPE_BOLERO: - func_80B3CB58(this, globalCtx); - break; - case SHEIK_TYPE_SERENADE: - EnXc_SetupSerenadeAction(this, globalCtx); - break; - case SHEIK_TYPE_9: - EnXc_InitTempleOfTime(this, globalCtx); - break; - case SHEIK_TYPE_0: - EnXc_DoNothing(this, globalCtx); - break; - default: - osSyncPrintf(VT_FGCOL(RED) " En_Oa2 の arg_data がおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - EnXc_DoNothing(this, globalCtx); - } -} - -s32 EnXc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnXc* this = (EnXc*)thisx; - - if (this->unk_30C != 0) { - if (limbIndex == 9) { - rot->x += this->npcInfo.unk_0E.y; - rot->y -= this->npcInfo.unk_0E.x; - } else if (limbIndex == 16) { - rot->x += this->npcInfo.unk_08.y; - rot->z += this->npcInfo.unk_08.x; - } - } - return 0; -} - -void EnXc_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - if (limbIndex == 16) { - EnXc* this = (EnXc*)thisx; - Vec3f src = { 0.0f, 10.0f, 0.0f }; - Vec3f dest; - - Matrix_MultVec3f(&src, &dest); - this->actor.focus.pos.x = dest.x; - this->actor.focus.pos.y = dest.y; - this->actor.focus.pos.z = dest.z; - this->actor.focus.rot.x = this->actor.world.rot.x; - this->actor.focus.rot.y = this->actor.world.rot.y; - this->actor.focus.rot.z = this->actor.world.rot.z; - } -} - -void EnXc_DrawNothing(Actor* thisx, GlobalContext* globalCtx) { -} - -void EnXc_DrawDefault(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnXc* this = (EnXc*)thisx; - s16 eyeIdx = this->eyeIdx; - void* eyeSegment = sEyeTextures[eyeIdx]; - SkelAnime* skelAnime = &this->skelAnime; - GraphicsContext* localGfxCtx = globalCtx->state.gfxCtx; - GraphicsContext* gfxCtx = localGfxCtx; - - OPEN_DISPS(gfxCtx, "../z_en_oA2.c", 1164); - func_8002EBCC(&this->actor, globalCtx, 0); - func_80093D18(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeSegment)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeSegment)); - SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnXc_OverrideLimbDraw, EnXc_PostLimbDraw, this); - CLOSE_DISPS(gfxCtx, "../z_en_oA2.c", 1207); -} - -static EnXcDrawFunc sDrawFuncs[] = { - EnXc_DrawNothing, EnXc_DrawDefault, EnXc_DrawPullingOutHarp, - EnXc_DrawHarp, EnXc_DrawTriforce, EnXc_DrawSquintingEyes, -}; - -void EnXc_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnXc* this = (EnXc*)thisx; - - if (this->drawMode < 0 || this->drawMode > 5 || sDrawFuncs[this->drawMode] == NULL) { - // "Draw mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - } else { - sDrawFuncs[this->drawMode](thisx, globalCtx); - } -} - -const ActorInit En_Xc_InitVars = { - ACTOR_EN_XC, - ACTORCAT_NPC, - FLAGS, - OBJECT_XC, - sizeof(EnXc), - (ActorFunc)EnXc_Init, - (ActorFunc)EnXc_Destroy, - (ActorFunc)EnXc_Update, - (ActorFunc)EnXc_Draw, -}; diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.cpp b/src/overlays/actors/ovl_En_Xc/z_en_xc.cpp new file mode 100644 index 000000000..4f5815629 --- /dev/null +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.cpp @@ -0,0 +1,2448 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_XC_Z_EN_XC_C +#include "actor_common.h" +/* + * File: z_en_xc.c + * Overlay: ovl_En_Xc + * Description: Sheik + */ + +#include "z_en_xc.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "objects/object_xc/object_xc.h" +#include "scenes/overworld/spot05/spot05_scene.h" +#include "scenes/overworld/spot17/spot17_scene.h" +#include "scenes/indoors/tokinoma/tokinoma_scene.h" +#include "scenes/dungeons/ice_doukutu/ice_doukutu_scene.h" +#include "vt.h" +#include "def/code_8006BA00.h" +#include "def/code_800EC960.h" +#include "def/graph.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin_matrix.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnXc_Init(Actor* thisx, GlobalContext* globalCtx); +void EnXc_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnXc_Update(Actor* thisx, GlobalContext* globalCtx); +void EnXc_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnXc_DrawNothing(Actor* thisx, GlobalContext* globalCtx); +void EnXc_DrawDefault(Actor* thisx, GlobalContext* globalCtx); +void EnXc_DrawPullingOutHarp(Actor* thisx, GlobalContext* globalCtx); +void EnXc_DrawHarp(Actor* thisx, GlobalContext* globalCtx); +void EnXc_DrawTriforce(Actor* thisx, GlobalContext* globalCtx); +void EnXc_DrawSquintingEyes(Actor* thisx, GlobalContext* globalCtx); + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 25, 80, 0, { 0, 0, 0 } }, +}; + +static void* sEyeTextures[] = { + gSheikEyeOpenTex, + gSheikEyeHalfClosedTex, + gSheikEyeShutTex, +}; + +void EnXc_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); +} + +void EnXc_UpdateCollider(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + Collider* colliderBase = &pthis->collider.base; + s32 pad[3]; + + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, colliderBase); +} + +void EnXc_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void EnXc_CalculateHeadTurn(EnXc* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->npcInfo.unk_18 = player->actor.world.pos; + pthis->npcInfo.unk_14 = kREG(16) - 3.0f; + func_80034A14(&pthis->actor, &pthis->npcInfo, kREG(17) + 0xC, 2); +} + +void EnXc_SetEyePattern(EnXc* pthis) { + s32 pad[3]; + s16* blinkTimer = &pthis->blinkTimer; + s16* eyePattern = &pthis->eyeIdx; + + if (!DECR(*blinkTimer)) { + *blinkTimer = Rand_S16Offset(60, 60); + } + + *eyePattern = *blinkTimer; + if (*eyePattern >= ARRAY_COUNT(sEyeTextures)) { + *eyePattern = 0; + } +} + +void EnXc_SpawnNut(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f* pos = &pthis->actor.world.pos; + s16 angle = pthis->actor.shape.rot.y; + f32 x = (Math_SinS(angle) * 30.0f) + pos->x; + f32 y = pos->y + 3.0f; + f32 z = (Math_CosS(angle) * 30.0f) + pos->z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, x, y, z, 0xFA0, pthis->actor.shape.rot.y, 0, + ARROW_CS_NUT); +} + +void EnXc_BgCheck(EnXc* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 4); +} + +s32 EnXc_AnimIsFinished(EnXc* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +CsCmdActorAction* EnXc_GetCsCmd(GlobalContext* globalCtx, s32 npcActionIdx) { + CsCmdActorAction* action = NULL; + + if (globalCtx->csCtx.state != 0) { + action = globalCtx->csCtx.npcActions[npcActionIdx]; + } + return action; +} + +s32 EnXc_CompareCsAction(EnXc* pthis, GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { + CsCmdActorAction* csCmdActorAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); + + if (csCmdActorAction != NULL && csCmdActorAction->action == action) { + return true; + } + return false; +} + +s32 EnXc_CsActionsAreNotEqual(EnXc* pthis, GlobalContext* globalCtx, u16 action, s32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); + + if (csCmdNPCAction && csCmdNPCAction->action != action) { + return true; + } + return false; +} + +void func_80B3C588(EnXc* pthis, GlobalContext* globalCtx, u32 npcActionIdx) { + CsCmdActorAction* csCmdNPCAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); + Actor* thisx = &pthis->actor; + + if (csCmdNPCAction != NULL) { + thisx->world.pos.x = csCmdNPCAction->startPos.x; + thisx->world.pos.y = csCmdNPCAction->startPos.y; + thisx->world.pos.z = csCmdNPCAction->startPos.z; + thisx->world.rot.x = thisx->shape.rot.x = csCmdNPCAction->rot.x; + thisx->world.rot.y = thisx->shape.rot.y = csCmdNPCAction->rot.y; + thisx->world.rot.z = thisx->shape.rot.z = csCmdNPCAction->rot.z; + } +} + +void func_80B3C620(EnXc* pthis, GlobalContext* globalCtx, s32 npcActionIdx) { + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, npcActionIdx); + Vec3f* xcPos = &pthis->actor.world.pos; + f32 startX; + f32 startY; + f32 startZ; + f32 endX; + f32 endY; + f32 endZ; + f32 unk; + + if (npcAction != NULL) { + unk = + Environment_LerpWeightAccelDecel(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, 0, 0); + startX = npcAction->startPos.x; + startY = npcAction->startPos.y; + startZ = npcAction->startPos.z; + endX = npcAction->endPos.x; + endY = npcAction->endPos.y; + endZ = npcAction->endPos.z; + xcPos->x = ((endX - startX) * unk) + startX; + xcPos->y = ((endY - startY) * unk) + startY; + xcPos->z = ((endZ - startZ) * unk) + startZ; + } +} + +void EnXc_ChangeAnimation(EnXc* pthis, AnimationHeader* animation, u8 mode, f32 morphFrames, s32 reverseFlag) { + s32 pad[2]; + AnimationHeader* animationSeg = SEGMENTED_TO_VIRTUAL(animation); + f32 frameCount = Animation_GetLastFrame(&animationSeg->common); + f32 playbackSpeed; + f32 startFrame; + f32 endFrame; + + if (!reverseFlag) { + startFrame = 0.0f; + endFrame = frameCount; + playbackSpeed = 1.0f; + } else { + startFrame = frameCount; + endFrame = 0.0f; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animationSeg, playbackSpeed, startFrame, endFrame, mode, morphFrames); +} + +void EnXc_CheckAndSetAction(EnXc* pthis, s32 check, s32 set) { + if (check != pthis->action) { + pthis->action = set; + } +} + +void func_80B3C7D4(EnXc* pthis, s32 action1, s32 action2, s32 action3) { + if (action1 != pthis->action) { + if (pthis->action == SHEIK_ACTION_PUT_HARP_AWAY) { + pthis->action = action2; + } else { + pthis->action = action3; + } + } +} + +s32 EnXc_NoCutscenePlaying(GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == 0) { + return true; + } + return false; +} + +void func_80B3C820(EnXc* pthis) { + Animation_Change(&pthis->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->action = SHEIK_ACTION_53; +} + +void func_80B3C888(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_NoCutscenePlaying(globalCtx) && pthis->actor.params == SHEIK_TYPE_4) { + func_80B3C820(pthis); + } +} + +void func_80B3C8CC(EnXc* pthis, GlobalContext* globalCtx) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if (skelAnime->jointTable[0].y >= skelAnime->baseTransl.y) { + skelAnime->moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, skelAnime, 1.0f); + } +} + +void func_80B3C924(EnXc* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_80B3C964(EnXc* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.baseTransl = pthis->skelAnime.jointTable[0]; + pthis->skelAnime.prevTransl = pthis->skelAnime.jointTable[0]; + pthis->skelAnime.moveFlags |= 3; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_80B3C9DC(EnXc* pthis) { + pthis->skelAnime.moveFlags &= ~0x3; +} + +void func_80B3C9EC(EnXc* pthis) { + EnXc_ChangeAnimation(pthis, &gSheikArmsCrossedIdleAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = SHEIK_ACTION_BLOCK_PEDESTAL; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->unk_30C = 1; +} + +void func_80B3CA38(EnXc* pthis, GlobalContext* globalCtx) { + // If Player is adult but hasn't learned Minuet of Forest + if (!(gSaveContext.eventChkInf[5] & 1) && LINK_IS_ADULT) { + pthis->action = SHEIK_ACTION_INIT; + } else { + Actor_Kill(&pthis->actor); + } +} + +s32 EnXc_MinuetCS(EnXc* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == SHEIK_TYPE_MINUET) { + Player* player = GET_PLAYER(globalCtx); + f32 z = player->actor.world.pos.z; + + if (z < -2225.0f) { + if (!Gameplay_InCsMode(globalCtx)) { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(&gMinuetCs); + gSaveContext.cutsceneTrigger = 1; + gSaveContext.eventChkInf[5] |= 1; + Item_Give(globalCtx, ITEM_SONG_MINUET); + return true; + } + } + return false; + } + return true; +} + +void func_80B3CB58(EnXc* pthis, GlobalContext* globalCtx) { + // If hasn't learned Bolero and Player is Adult + if (!(gSaveContext.eventChkInf[5] & 2) && LINK_IS_ADULT) { + pthis->action = SHEIK_ACTION_INIT; + } else { + Actor_Kill(&pthis->actor); + } +} + +s32 EnXc_BoleroCS(EnXc* pthis, GlobalContext* globalCtx) { + Player* player; + PosRot* posRot; + + if (pthis->actor.params == SHEIK_TYPE_BOLERO) { + player = GET_PLAYER(globalCtx); + posRot = &player->actor.world; + if ((posRot->pos.x > -784.0f) && (posRot->pos.x < -584.0f) && (posRot->pos.y > 447.0f) && + (posRot->pos.y < 647.0f) && (posRot->pos.z > -446.0f) && (posRot->pos.z < -246.0f) && + !Gameplay_InCsMode(globalCtx)) { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(&gDeathMountainCraterBoleroCs); + gSaveContext.cutsceneTrigger = 1; + gSaveContext.eventChkInf[5] |= 2; + Item_Give(globalCtx, ITEM_SONG_BOLERO); + return true; + } + return false; + } + return true; +} + +void EnXc_SetupSerenadeAction(EnXc* pthis, GlobalContext* globalCtx) { + // Player is adult and does not have iron boots and has not learned Serenade + if ((!CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1) && !(gSaveContext.eventChkInf[5] & 4)) && LINK_IS_ADULT) { + pthis->action = SHEIK_ACTION_SERENADE; + osSyncPrintf("水のセレナーデ シーク誕生!!!!!!!!!!!!!!!!!!\n"); + } else { + Actor_Kill(&pthis->actor); + osSyncPrintf("水のセレナーデ シーク消滅!!!!!!!!!!!!!!!!!!\n"); + } +} + +s32 EnXc_SerenadeCS(EnXc* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params == SHEIK_TYPE_SERENADE) { + Player* player = GET_PLAYER(globalCtx); + s32 stateFlags = player->stateFlags1; + + if (CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1) && !(gSaveContext.eventChkInf[5] & 4) && !(stateFlags & 0x20000000) && + !Gameplay_InCsMode(globalCtx)) { + Cutscene_SetSegment(globalCtx, &gIceCavernSerenadeCs); + gSaveContext.cutsceneTrigger = 1; + gSaveContext.eventChkInf[5] |= 4; // Learned Serenade of Water Flag + Item_Give(globalCtx, ITEM_SONG_SERENADE); + osSyncPrintf("ブーツを取った!!!!!!!!!!!!!!!!!!\n"); + return true; + } + osSyncPrintf("はやくブーツを取るべし!!!!!!!!!!!!!!!!!!\n"); + return false; + } + return true; +} + +void EnXc_DoNothing(EnXc* pthis, GlobalContext* globalCtx) { +} + +void EnXc_SetWalkingSFX(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + u32 sfxId; + s32 pad2; + + if (Animation_OnFrame(&pthis->skelAnime, 11.0f) || Animation_OnFrame(&pthis->skelAnime, 23.0f)) { + if (pthis->actor.bgCheckFlags & 1) { + sfxId = SFX_FLAG; + sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + func_80078914(&pthis->actor.projectedPos, sfxId); + } + } +} + +void EnXc_SetNutThrowSFX(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + u32 sfxId; + s32 pad2; + + if (Animation_OnFrame(&pthis->skelAnime, 7.0f)) { + if (pthis->actor.bgCheckFlags & 1) { + sfxId = SFX_FLAG; + sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + func_80078914(&pthis->actor.projectedPos, sfxId); + } + } + if (Animation_OnFrame(&pthis->skelAnime, 20.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_SK_SHOUT); + } +} + +void EnXc_SetLandingSFX(EnXc* pthis, GlobalContext* globalCtx) { + u32 sfxId; + s16 sceneNum = globalCtx->sceneNum; + + if ((gSaveContext.sceneSetupIndex != 4) || (sceneNum != SCENE_SPOT11)) { + if (Animation_OnFrame(&pthis->skelAnime, 11.0f)) { + sfxId = SFX_FLAG; + sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + func_80078914(&pthis->actor.projectedPos, sfxId); + } + } +} + +void EnXc_SetColossusAppearSFX(EnXc* pthis, GlobalContext* globalCtx) { + static Vec3f sXyzDist; + s16 sceneNum; + + if (gSaveContext.sceneSetupIndex == 4) { + sceneNum = globalCtx->sceneNum; + if (sceneNum == SCENE_SPOT11) { + CutsceneContext* csCtx = &globalCtx->csCtx; + u16 frameCount = csCtx->frames; + f32 wDest[2]; + + if (frameCount == 119) { + Vec3f pos = { -611.0f, 728.0f, -2.0f }; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &sXyzDist, wDest); + func_80078914(&sXyzDist, NA_SE_EV_JUMP_CONC); + } else if (frameCount == 164) { + Vec3f pos = { -1069.0f, 38.0f, 0.0f }; + s32 pad; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &sXyzDist, wDest); + func_80078914(&sXyzDist, NA_SE_PL_WALK_CONCRETE); + } + } + } +} + +void func_80B3D118(GlobalContext* globalCtx) { + s16 sceneNum; + + if ((gSaveContext.sceneSetupIndex != 4) || (sceneNum = globalCtx->sceneNum, sceneNum != SCENE_SPOT11)) { + func_800788CC(NA_SE_PL_SKIP); + } +} + +static Vec3f D_80B42DA0; + +void EnXc_SetColossusWindSFX(GlobalContext* globalCtx) { + if (gSaveContext.sceneSetupIndex == 4) { + static s32 D_80B41D90 = 0; + static Vec3f sPos = { 0.0f, 0.0f, 0.0f }; + static f32 sMaxSpeed = 0.0f; + static Vec3f D_80B42DB0; + s32 pad; + s16 sceneNum = globalCtx->sceneNum; + + if (sceneNum == SCENE_SPOT11) { + CutsceneContext* csCtx = &globalCtx->csCtx; + u16 frameCount = csCtx->frames; + + if ((frameCount >= 120) && (frameCount < 164)) { + s32 pad; + Vec3f* eye = &globalCtx->view.eye; + + if (D_80B41D90 != 0) { + f32 speed = Math3D_Vec3f_DistXYZ(&D_80B42DB0, eye) / 7.058922f; + + sMaxSpeed = CLAMP_MIN(sMaxSpeed, speed); + + osSyncPrintf("MAX speed = %f\n", sMaxSpeed); + + speed = CLAMP_MAX(speed, 2.0f); + func_800F436C(&sPos, NA_SE_EV_FLYING_AIR - SFX_FLAG, 0.6f + (0.4f * speed)); + } + + D_80B42DB0.x = eye->x; + D_80B42DB0.y = eye->y; + D_80B42DB0.z = eye->z; + D_80B41D90 = 1; + } + } + } +} + +void EnXc_SpawnFlame(EnXc* pthis, GlobalContext* globalCtx) { + static s32 sFlameSpawned = false; + + if (!sFlameSpawned) { + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); + f32 xPos = npcAction->startPos.x; + f32 yPos = npcAction->startPos.y; + f32 zPos = npcAction->startPos.z; + + pthis->flameActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_LIGHT, xPos, yPos, zPos, 0, 0, 0, 5); + sFlameSpawned = true; + } +} + +void EnXc_SetupFlamePos(EnXc* pthis, GlobalContext* globalCtx) { + Vec3f* attachedPos; + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); + + if (pthis->flameActor != NULL) { + attachedPos = &pthis->flameActor->world.pos; + if (!pthis) {} + attachedPos->x = npcAction->startPos.x; + attachedPos->y = npcAction->startPos.y; + attachedPos->z = npcAction->startPos.z; + } +} + +void EnXc_DestroyFlame(EnXc* pthis) { + if (pthis->flameActor != NULL) { + Actor_Kill(pthis->flameActor); + pthis->flameActor = NULL; + } + Actor_Kill(&pthis->actor); +} + +void EnXc_InitFlame(EnXc* pthis, GlobalContext* globalCtx) { + static s32 D_80B41DA8 = 1; + s32 pad; + s16 sceneNum = globalCtx->sceneNum; + + if (sceneNum == SCENE_SPOT17) { + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); + if (npcAction != NULL) { + s32 action = npcAction->action; + + if (D_80B41DA8 != action) { + if (action != 1) { + EnXc_SpawnFlame(pthis, globalCtx); + } + + if (action == 1) { + EnXc_DestroyFlame(pthis); + } + + D_80B41DA8 = action; + } + + EnXc_SetupFlamePos(pthis, globalCtx); + } + } +} + +void func_80B3D48C(EnXc* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + CsCmdActorAction* linkAction = csCtx->linkAction; + s16 yaw; + + if (linkAction != NULL) { + yaw = linkAction->urot.y + 0x8000; + } else { + Player* player = GET_PLAYER(globalCtx); + yaw = player->actor.world.rot.y + 0x8000; + } + + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = yaw; +} + +AnimationHeader* EnXc_GetCurrentHarpAnim(GlobalContext* globalCtx, s32 index) { + AnimationHeader* animation = &gSheikPlayingHarp5Anim; + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, index); + + if (npcAction != NULL) { + u16 action = npcAction->action; + + if (action == 11) { + animation = &gSheikPlayingHarp3Anim; + } else if (action == 12) { + animation = &gSheikPlayingHarp2Anim; + } else if (action == 13) { + animation = &gSheikPlayingHarp4Anim; + } else if (action == 23) { + animation = &gSheikPlayingHarpAnim; + } else { + animation = &gSheikPlayingHarp5Anim; + } + } + return animation; +} + +void EnXc_CalcXZAccel(EnXc* pthis) { + f32 timer = pthis->timer; + f32* speedXZ = &pthis->actor.speedXZ; + + if (timer < 9.0f) { + *speedXZ = 0.0f; + } else if (timer < 3.0f) { + *speedXZ = (((kREG(2) * 0.01f) + 1.2f) / 3.0f) * (timer - 9.0f); + } else { + *speedXZ = (kREG(2) * 0.01f) + 1.2f; + } + + Actor_MoveForward(&pthis->actor); +} + +void func_80B3D644(EnXc* pthis) { + Actor_MoveForward(&pthis->actor); +} + +void EnXc_CalcXZSpeed(EnXc* pthis) { + f32 timer = pthis->timer; + f32* speedXZ = &pthis->actor.speedXZ; + + if (timer < 3.0f) { + *speedXZ = (((kREG(2) * 0.01f) + 1.2f) / 3.0f) * (3.0f - timer); + } else { + *speedXZ = 0.0f; + } + Actor_MoveForward(&pthis->actor); +} + +void func_80B3D6F0(EnXc* pthis) { + EnXc_CalcXZAccel(pthis); +} + +void func_80B3D710(EnXc* pthis) { + Actor_MoveForward(&pthis->actor); +} + +void func_80B3D730(EnXc* pthis) { + EnXc_CalcXZSpeed(pthis); +} + +void func_80B3D750(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_MinuetCS(pthis, globalCtx) && EnXc_BoleroCS(pthis, globalCtx)) { + pthis->action = SHEIK_ACTION_WAIT; + } +} + +void EnXc_SetupFallFromSkyAction(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad; + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->state != 0) { + CsCmdActorAction* npcAction = csCtx->npcActions[4]; + + if (npcAction && npcAction->action == 2) { + s32 pad; + Vec3f* pos = &pthis->actor.world.pos; + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSheikFallingFromSkyAnim); + + pthis->action = SHEIK_ACTION_GRACEFUL_FALL; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + + pos->x = npcAction->startPos.x; + pos->y = npcAction->startPos.y; + pos->z = npcAction->startPos.z; + + func_80B3D48C(pthis, globalCtx); + func_80B3C964(pthis, globalCtx); + Animation_Change(skelAnime, &gSheikFallingFromSkyAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + func_80B3D118(globalCtx); + } + } +} + +void func_80B3D8A4(EnXc* pthis, GlobalContext* globalCtx, s32 animFinished) { + if (animFinished) { + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSheikWalkingAnim); + + Animation_Change(skelAnime, &gSheikWalkingAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -8.0f); + + pthis->action = SHEIK_ACTION_ACCEL; + pthis->timer = 0.0f; + + func_80B3C9DC(pthis); + pthis->actor.gravity = -((kREG(1) * 0.01f) + 13.0f); + pthis->actor.minVelocityY = -((kREG(1) * 0.01f) + 13.0f); + } else { + func_80B3C8CC(pthis, globalCtx); + } +} + +void EnXc_SetupWalkAction(EnXc* pthis) { + f32* timer = &pthis->timer; + + *timer += 1.0f; + if (*timer >= 12.0f) { + pthis->actor.speedXZ = (kREG(2) * 0.01f) + 1.2f; + pthis->action = SHEIK_ACTION_WALK; + } +} + +void EnXc_SetupHaltAction(EnXc* pthis) { + SkelAnime* skelAnime = &pthis->skelAnime; + f32 xzDistToPlayer = pthis->actor.xzDistToPlayer; + + if (xzDistToPlayer <= (kREG(3) + 95.0f)) { + f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); + + Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -12.0f); + pthis->action = SHEIK_ACTION_HALT; + pthis->timer = 0.0f; + } +} + +void EnXc_SetupStoppedAction(EnXc* pthis) { + f32* timer = &pthis->timer; + + *timer += 1.0f; + if (*timer >= 12.0f) { + pthis->action = SHEIK_ACTION_STOPPED; + pthis->actor.speedXZ = 0.0f; + } +} + +void func_80B3DAF0(EnXc* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 4); + u16 action; + + if (npcAction && + (action = npcAction->action, action == 3 || action == 11 || action == 12 || action == 13 || action == 23)) { + f32 frameCount; + + frameCount = Animation_GetLastFrame(&gSheikPullingOutHarpAnim); + Animation_Change(&pthis->skelAnime, &gSheikPullingOutHarpAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -4.0f); + pthis->action = SHEIK_ACTION_7; + pthis->drawMode = SHEIK_DRAW_PULLING_OUT_HARP; + } +} + +void EnXc_SetupInitialHarpAction(EnXc* pthis, s32 animFinished) { + SkelAnime* skelAnime; + f32 frameCount; + + if (animFinished) { + skelAnime = &pthis->skelAnime; + frameCount = Animation_GetLastFrame(&gSheikInitialHarpAnim); + Animation_Change(skelAnime, &gSheikInitialHarpAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_HARP_READY; + pthis->drawMode = SHEIK_DRAW_HARP; + } +} + +void EnXc_SetupPlayingHarpAction(EnXc* pthis, GlobalContext* globalCtx, s32 animFinished) { + s32 pad; + SkelAnime* skelAnime; + AnimationHeader* animation; + f32 frameCount; + + if (animFinished) { + skelAnime = &pthis->skelAnime; + animation = EnXc_GetCurrentHarpAnim(globalCtx, 4); + frameCount = Animation_GetLastFrame(animation); + Animation_Change(skelAnime, animation, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -8.0f); + pthis->action = SHEIK_PLAYING_HARP; + pthis->drawMode = SHEIK_DRAW_HARP; + } +} + +void func_80B3DCA8(EnXc* pthis, GlobalContext* globalCtx) { + f32 frameCount; + + if (globalCtx->csCtx.state != 0) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; + + if (npcAction != NULL && npcAction->action == 8) { + frameCount = Animation_GetLastFrame(&gSheikInitialHarpAnim); + Animation_Change(&pthis->skelAnime, &gSheikInitialHarpAnim, 0.0f, frameCount, frameCount, ANIMMODE_LOOP, + -8.0f); + pthis->action = SHEIK_ACTION_10; + } + } +} + +void EnXc_SetupHarpPutawayAction(EnXc* pthis, GlobalContext* globalCtx) { + f32 curFrame; + f32 animFrameCount; + + if (EnXc_CompareCsAction(pthis, globalCtx, 5, 4)) { + curFrame = pthis->skelAnime.curFrame; + animFrameCount = pthis->skelAnime.endFrame; + if (curFrame >= animFrameCount) { + Animation_Change(&pthis->skelAnime, &gSheikInitialHarpAnim, -1.0f, + Animation_GetLastFrame(&gSheikInitialHarpAnim), 0.0f, ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_PUT_HARP_AWAY; + } + } else if (EnXc_CsActionsAreNotEqual(pthis, globalCtx, 8, 4)) { + EnXc_SetupPlayingHarpAction(pthis, globalCtx, true); + } +} + +void func_80B3DE00(EnXc* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gSheikPullingOutHarpAnim, -1.0f, + Animation_GetLastFrame(&gSheikPullingOutHarpAnim), 0.0f, ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_12; + pthis->drawMode = SHEIK_DRAW_PULLING_OUT_HARP; + } +} + +void func_80B3DE78(EnXc* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), + ANIMMODE_LOOP, 0.0f); + pthis->action = SHEIK_ACTION_13; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->timer = 0.0f; + } +} + +void EnXc_SetupReverseAccel(EnXc* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; + + if (npcAction != NULL && npcAction->action == 4) { + Animation_Change(&pthis->skelAnime, &gSheikWalkingAnim, -1.0f, Animation_GetLastFrame(&gSheikWalkingAnim), + 0.0f, ANIMMODE_LOOP, -12.0f); + pthis->action = SHEIK_ACTION_REVERSE_ACCEL; + pthis->actor.world.rot.y += 0x8000; + pthis->timer = 0.0f; + } + } +} + +void EnXc_SetupReverseWalkAction(EnXc* pthis) { + pthis->timer++; + if (pthis->timer >= 12.0f) { + pthis->actor.speedXZ = (kREG(2) * 0.01f) + 1.2f; + pthis->action = SHEIK_ACTION_REVERSE_WALK; + } +} + +void EnXc_SetupReverseHaltAction(EnXc* pthis) { + f32 xzDistToPlayer = pthis->actor.xzDistToPlayer; + + if (xzDistToPlayer >= kREG(5) + 140.0f) { + Animation_Change(&pthis->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), + ANIMMODE_LOOP, -12.0f); + pthis->action = SHEIK_ACTION_REVERSE_HALT; + pthis->timer = 0.0f; + } +} + +void EnXc_SetupNutThrow(EnXc* pthis) { + pthis->timer++; + if (pthis->timer >= 12.0f) { + Animation_Change(&pthis->skelAnime, &gSheikThrowingNutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gSheikThrowingNutAnim), ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_THROW_NUT; + pthis->timer = 0.0f; + pthis->actor.speedXZ = 0.0f; + } +} + +void func_80B3E164(EnXc* pthis, GlobalContext* globalCtx) { + pthis->timer++; + if (pthis->timer >= 30.0f) { + pthis->action = SHEIK_ACTION_DELETE; + EnXc_SpawnNut(pthis, globalCtx); + } +} + +void EnXc_SetupDisappear(EnXc* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; + + if (npcAction != NULL && npcAction->action == 9) { + s16 sceneNum = globalCtx->sceneNum; + + // Sheik fades away if end of Bolero CS, kill actor otherwise + if (sceneNum == SCENE_SPOT17) { + pthis->action = SHEIK_ACTION_FADE; + pthis->drawMode = SHEIK_DRAW_NOTHING; + pthis->actor.shape.shadowAlpha = 0; + } else { + Actor_Kill(&pthis->actor); + } + } + } +} + +void EnXc_ActionFunc0(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_SetColossusAppearSFX(pthis, globalCtx); + EnXc_SetColossusWindSFX(globalCtx); + func_80B3D750(pthis, globalCtx); +} + +void EnXc_ActionFunc1(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_SetColossusAppearSFX(pthis, globalCtx); + EnXc_SetColossusWindSFX(globalCtx); + EnXc_SetupFallFromSkyAction(pthis, globalCtx); +} + +void EnXc_GracefulFall(EnXc* pthis, GlobalContext* globalCtx) { + s32 animFinished = EnXc_AnimIsFinished(pthis); + + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetLandingSFX(pthis, globalCtx); + EnXc_SetColossusAppearSFX(pthis, globalCtx); + EnXc_SetColossusWindSFX(globalCtx); + func_80B3D8A4(pthis, globalCtx, animFinished); +} + +void EnXc_Accelerate(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_CalcXZAccel(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_SetupWalkAction(pthis); +} + +void EnXc_Walk(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D644(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_SetupHaltAction(pthis); +} + +void EnXc_Stopped(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_CalcXZSpeed(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_SetupStoppedAction(pthis); +} + +void EnXc_ActionFunc6(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + func_80B3DAF0(pthis, globalCtx); +} + +void EnXc_ActionFunc7(EnXc* pthis, GlobalContext* globalCtx) { + s32 animFinished = EnXc_AnimIsFinished(pthis); + + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupInitialHarpAction(pthis, animFinished); +} + +void EnXc_ActionFunc8(EnXc* pthis, GlobalContext* globalCtx) { + s32 animFinished = EnXc_AnimIsFinished(pthis); + + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupPlayingHarpAction(pthis, globalCtx, animFinished); +} + +void EnXc_ActionFunc9(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + func_80B3DCA8(pthis, globalCtx); +} + +void EnXc_ActionFunc10(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupHarpPutawayAction(pthis, globalCtx); +} + +void EnXc_ActionFunc11(EnXc* pthis, GlobalContext* globalCtx) { + s32 animFinished = EnXc_AnimIsFinished(pthis); + + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + func_80B3DE00(pthis, animFinished); +} + +void EnXc_ActionFunc12(EnXc* pthis, GlobalContext* globalCtx) { + s32 animFinished = EnXc_AnimIsFinished(pthis); + + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + func_80B3DE78(pthis, animFinished); +} + +void EnXc_ActionFunc13(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_InitFlame(pthis, globalCtx); + EnXc_SetupReverseAccel(pthis, globalCtx); +} + +void EnXc_ReverseAccelerate(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D6F0(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_InitFlame(pthis, globalCtx); + EnXc_SetupReverseWalkAction(pthis); +} + +void EnXc_ActionFunc15(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D710(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_InitFlame(pthis, globalCtx); + EnXc_SetupReverseHaltAction(pthis); +} + +void EnXc_HaltAndWaitToThrowNut(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D730(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_InitFlame(pthis, globalCtx); + EnXc_SetupNutThrow(pthis); +} + +void EnXc_ThrowNut(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetNutThrowSFX(pthis, globalCtx); + EnXc_InitFlame(pthis, globalCtx); + func_80B3E164(pthis, globalCtx); +} + +void EnXc_Delete(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_InitFlame(pthis, globalCtx); + EnXc_SetupDisappear(pthis, globalCtx); +} + +void EnXc_Fade(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_InitFlame(pthis, globalCtx); +} + +void func_80B3E87C(Gfx** dList, EnXc* pthis) { + f32 currentFrame = pthis->skelAnime.curFrame; + + if (currentFrame >= 34.0f) { + *dList = gSheikHarpDL; + } +} + +s32 EnXc_PullingOutHarpOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnXc* pthis = (EnXc*)thisx; + + if (limbIndex == 12) { + func_80B3E87C(dList, pthis); + } + + return 0; +} + +s32 EnXc_HarpOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + EnXc* pthis = (EnXc*)thisx; + + if (limbIndex == 12) { + *dList = gSheikHarpDL; + } + + return 0; +} + +void EnXc_DrawPullingOutHarp(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + s32 pad; + s16 eyePattern = pthis->eyeIdx; + void* eyeTexture = sEyeTextures[eyePattern]; + SkelAnime* skelAnime = &pthis->skelAnime; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad2; + + OPEN_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1444); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 20, 0); + gDPSetEnvColor(POLY_OPA_DISP++, 60, 0, 0, 0); + + func_80093D18(gfxCtx); + func_8002EBCC(&pthis->actor, globalCtx, 0); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnXc_PullingOutHarpOverrideLimbDraw, NULL, pthis); + CLOSE_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1497); +} + +void EnXc_DrawHarp(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + s32 pad; + s16 eyePattern = pthis->eyeIdx; + void* eyeTexture = sEyeTextures[eyePattern]; + SkelAnime* skelAnime = &pthis->skelAnime; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad2; + + OPEN_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1511); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 20, 0); + gDPSetEnvColor(POLY_OPA_DISP++, 60, 0, 0, 0); + + func_80093D18(gfxCtx); + func_8002EBCC(&pthis->actor, globalCtx, 0); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnXc_HarpOverrideLimbDraw, NULL, pthis); + CLOSE_DISPS(gfxCtx, "../z_en_oA2_inSpot05.c", 1564); +} + +void func_80B3EBF0(EnXc* pthis, GlobalContext* globalCtx) { + pthis->action = SHEIK_ACTION_20; +} + +void func_80B3EC00(EnXc* pthis) { + pthis->action = SHEIK_ACTION_21; +} + +void func_80B3EC0C(EnXc* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->state != 0) { + CsCmdActorAction* npcAction = csCtx->npcActions[4]; + + if ((npcAction != NULL) && (npcAction->action != 1)) { + PosRot* posRot = &pthis->actor.world; + Vec3i* startPos = &npcAction->startPos; + ActorShape* shape = &pthis->actor.shape; + + posRot->pos.x = startPos->x; + posRot->pos.y = startPos->y; + posRot->pos.z = startPos->z; + + posRot->rot.y = shape->rot.y = npcAction->rot.y; + + pthis->action = SHEIK_ACTION_22; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + } + } +} + +void func_80B3EC90(EnXc* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->state != 0) { + CsCmdActorAction* npcAction = csCtx->npcActions[4]; + + if (npcAction != NULL && npcAction->action != 6) { + func_80B3C9EC(pthis); + } + } +} + +void func_80B3ECD8(EnXc* pthis) { + pthis->timer++; + if (pthis->timer >= 12.0f) { + pthis->actor.speedXZ = kREG(2) * 0.01f + 1.2f; + pthis->action = SHEIK_ACTION_24; + } +} + +void EnXc_ActionFunc20(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3EC00(pthis); +} + +void EnXc_ActionFunc21(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3EC0C(pthis, globalCtx); +} + +void EnXc_ActionFunc22(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + func_80B3EC90(pthis, globalCtx); +} + +void EnXc_ActionFunc23(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D6F0(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + func_80B3ECD8(pthis); +} + +void EnXc_ActionFunc24(EnXc* pthis, GlobalContext* globalCtx) { +} + +void EnXc_ActionFunc25(EnXc* pthis, GlobalContext* globalCtx) { +} + +void EnXc_ActionFunc26(EnXc* pthis, GlobalContext* globalCtx) { +} + +void EnXc_ActionFunc27(EnXc* pthis, GlobalContext* globalCtx) { +} + +void EnXc_ActionFunc28(EnXc* pthis, GlobalContext* globalCtx) { +} + +void func_80B3EE64(EnXc* pthis, GlobalContext* globalCtx) { + pthis->action = SHEIK_ACTION_SERENADE; +} + +void func_80B3EE74(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_SerenadeCS(pthis, globalCtx)) { + pthis->action = SHEIK_ACTION_30; + } +} + +void func_80B3EEA4(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_30, SHEIK_ACTION_31); +} + +void func_80B3EEC8(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_31, SHEIK_ACTION_32); +} + +void func_80B3EEEC(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_32, SHEIK_ACTION_33); +} + +void func_80B3EF10(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_33, SHEIK_ACTION_34); +} + +void func_80B3EF34(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_34, SHEIK_ACTION_35); +} + +void func_80B3EF58(EnXc* pthis) { + func_80B3C7D4(pthis, SHEIK_ACTION_35, SHEIK_ACTION_36, SHEIK_ACTION_34); +} + +void func_80B3EF80(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_36, SHEIK_ACTION_37); +} + +void func_80B3EFA4(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_37, SHEIK_ACTION_38); +} + +void func_80B3EFC8(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_38, SHEIK_ACTION_39); +} + +void func_80B3EFEC(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_39, SHEIK_ACTION_40); +} + +void func_80B3F010(EnXc* pthis) { + f32 xzDistToPlayer = pthis->actor.xzDistToPlayer; + + if (kREG(5) + 140.0f <= xzDistToPlayer) { + Animation_Change(&pthis->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), + ANIMMODE_LOOP, -12.0f); + pthis->action = SHEIK_ACTION_41; + pthis->timer = 0.0f; + } +} + +void func_80B3F0B8(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_41, SHEIK_ACTION_42); +} + +void func_80B3F0DC(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_42, SHEIK_ACTION_43); +} + +void func_80B3F100(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_43, SHEIK_ACTION_44); +} + +void EnXc_Serenade(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3EE74(pthis, globalCtx); +} + +void EnXc_ActionFunc30(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc21(pthis, globalCtx); + func_80B3EEA4(pthis); +} + +void EnXc_ActionFunc31(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc6(pthis, globalCtx); + func_80B3C588(pthis, globalCtx, 4); + func_80B3EEC8(pthis); +} + +void EnXc_ActionFunc32(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc7(pthis, globalCtx); + func_80B3EEEC(pthis); +} + +void EnXc_ActionFunc33(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc8(pthis, globalCtx); + func_80B3EF10(pthis); +} + +void EnXc_ActionFunc34(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc9(pthis, globalCtx); + func_80B3EF34(pthis); +} + +void EnXc_ActionFunc35(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc10(pthis, globalCtx); + func_80B3EF58(pthis); +} + +void EnXc_ActionFunc36(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc11(pthis, globalCtx); + func_80B3EF80(pthis); +} + +void EnXc_ActionFunc37(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc12(pthis, globalCtx); + func_80B3EFA4(pthis); +} + +void EnXc_ActionFunc38(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc13(pthis, globalCtx); + func_80B3EFC8(pthis); +} + +void EnXc_ActionFunc39(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ReverseAccelerate(pthis, globalCtx); + func_80B3EFEC(pthis); +} + +void EnXc_ActionFunc40(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D710(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + func_80B3F010(pthis); +} + +void EnXc_ActionFunc41(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_HaltAndWaitToThrowNut(pthis, globalCtx); + func_80B3F0B8(pthis); +} + +void EnXc_ActionFunc42(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ThrowNut(pthis, globalCtx); + func_80B3F0DC(pthis); +} + +void EnXc_ActionFunc43(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_Delete(pthis, globalCtx); + func_80B3F100(pthis); +} + +void EnXc_ActionFunc44(EnXc* pthis, GlobalContext* globalCtx) { +} + +void func_80B3F3C8(EnXc* pthis, GlobalContext* globalCtx) { + pthis->action = SHEIK_ACTION_45; +} + +void func_80B3F3D8() { + func_800788CC(NA_SE_PL_SKIP); +} + +void EnXc_PlayDiveSFX(Vec3f* src, GlobalContext* globalCtx) { + f32 wDest[2]; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, src, &D_80B42DA0, wDest); + func_80078914(&D_80B42DA0, NA_SE_EV_DIVE_INTO_WATER); +} + +void EnXc_LakeHyliaDive(GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = npcAction = EnXc_GetCsCmd(globalCtx, 0); + + if (npcAction != NULL) { + Vec3f startPos; + + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; + + EffectSsGRipple_Spawn(globalCtx, &startPos, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &startPos, 100, 500, 10); + EffectSsGRipple_Spawn(globalCtx, &startPos, 100, 500, 20); + EffectSsGSplash_Spawn(globalCtx, &startPos, NULL, NULL, 1, 0); + EnXc_PlayDiveSFX(&startPos, globalCtx); + } +} + +void func_80B3F534(GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + u16 frameCount = csCtx->frames; + + if (frameCount == 310) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, -1044.0f, -1243.0f, 7458.0f, 0, 0, 0, + WARP_DESTINATION); + } +} + +void func_80B3F59C(EnXc* pthis, GlobalContext* globalCtx) { + static s32 D_80B41DAC = 1; + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); + + if (npcAction != NULL) { + s32 action = npcAction->action; + + if (action != D_80B41DAC) { + switch (action) { + case 2: + func_80B3F3D8(); + break; + case 3: + EnXc_LakeHyliaDive(globalCtx); + break; + default: + break; + } + D_80B41DAC = action; + } + } +} + +void func_80B3F620(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_45, SHEIK_ACTION_46); +} + +void func_80B3F644(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_46, SHEIK_ACTION_47); +} + +void func_80B3F668(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CompareCsAction(pthis, globalCtx, 4, 4)) { + EnXc_ChangeAnimation(pthis, &gSheikWalkingAnim, ANIMMODE_LOOP, -12.0f, true); + pthis->action = SHEIK_ACTION_48; + pthis->actor.world.rot.y += 0x8000; + pthis->timer = 0.0f; + } +} + +void func_80B3F6DC(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_48, SHEIK_ACTION_49); +} + +void EnXc_SetupKneelAction(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CompareCsAction(pthis, globalCtx, 16, 4)) { + EnXc_ChangeAnimation(pthis, &gSheikKneelingAnim, ANIMMODE_LOOP, 0.0f, false); + pthis->action = SHEIK_ACTION_KNEEL; + } +} + +void func_80B3F754(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CompareCsAction(pthis, globalCtx, 22, 4)) { + EnXc_ChangeAnimation(pthis, &gSheikAnim_01A048, ANIMMODE_LOOP, 0.0f, false); + pthis->action = SHEIK_ACTION_51; + func_80B3C588(pthis, globalCtx, 4); + } +} + +void func_80B3F7BC(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CompareCsAction(pthis, globalCtx, 9, 4)) { + pthis->action = SHEIK_ACTION_52; + pthis->drawMode = SHEIK_DRAW_NOTHING; + } +} + +void EnXc_ActionFunc45(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc20(pthis, globalCtx); + func_80B3F620(pthis); +} + +void EnXc_ActionFunc46(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc21(pthis, globalCtx); + func_80B3F644(pthis); +} + +void EnXc_ActionFunc47(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3F534(globalCtx); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + func_80B3C588(pthis, globalCtx, 4); + func_80B3F668(pthis, globalCtx); +} + +void EnXc_ActionFunc48(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc23(pthis, globalCtx); + func_80B3F6DC(pthis); +} + +void EnXc_ActionFunc49(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D710(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetWalkingSFX(pthis, globalCtx); + EnXc_SetupKneelAction(pthis, globalCtx); +} + +void EnXc_Kneel(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + func_80B3F59C(pthis, globalCtx); + func_80B3C588(pthis, globalCtx, 4); + func_80B3F754(pthis, globalCtx); +} + +void EnXc_ActionFunc51(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + func_80B3F59C(pthis, globalCtx); + func_80B3C620(pthis, globalCtx, 4); + func_80B3F7BC(pthis, globalCtx); +} + +void EnXc_ActionFunc52(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3F59C(pthis, globalCtx); +} + +void func_80B3FA08(EnXc* pthis, GlobalContext* globalCtx) { + pthis->action = SHEIK_ACTION_53; + pthis->triforceAngle = kREG(24) + 0x53FC; +} + +void func_80B3FA2C(void) { + func_800F3F3C(1); +} + +void EnXc_PlayTriforceSFX(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + + if (pthis->unk_2A8) { + s32 pad; + Vec3f src; + Vec3f pos; + Vec3f sp1C = { 0.0f, 0.0f, 0.0f }; + f32 wDest; + + Matrix_MultVec3f(&sp1C, &src); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &src, &pos, &wDest); + Audio_PlaySoundAtPosition(globalCtx, &pos, 80, NA_SE_EV_TRIFORCE_MARK); + pthis->unk_2A8 = 0; + } +} + +void func_80B3FAE0(EnXc* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 38.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_SK_SHOUT); + func_80B3FA2C(); + } +} + +void EnXc_CalcTriforce(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + + if (EnXc_CompareCsAction(pthis, globalCtx, 21, 4)) { + pthis->unk_274 = 1; + if (pthis->unk_2AC == 0) { + pthis->unk_2AC = 1; + pthis->unk_2A8 = 1; + } + } else if (EnXc_CompareCsAction(pthis, globalCtx, 19, 4)) { + pthis->unk_274 = 2; + } + if (pthis->unk_274 != 0) { + f32* timer = &pthis->timer; + s32* prim = pthis->triforcePrimColor; + s32* env = pthis->triforceEnvColor; + f32* scale = pthis->triforceScale; + + if (pthis->unk_274 == 1) { + if (*timer < kREG(25) + 40.0f) { + f32 div = *timer / (kREG(25) + 40.0f); + + prim[2] = -85.0f * div + 255; + prim[3] = 255.0f * div; + env[1] = 100.0f * div + 100; + *timer += 1.0f; + } else { + prim[2] = 170; + prim[3] = 255; + env[1] = 200; + } + scale[0] = kREG(19) * 0.1f + 40.0f; + scale[1] = kREG(20) * 0.1f + 40.0f; + scale[2] = kREG(21) * 0.1f + 40.0f; + } else if (pthis->unk_274 == 2) { + f32 maxTime = (kREG(25) + 40.0f) + (kREG(27) + 90.0f); + + if (*timer < maxTime) { + f32 div = (*timer - (kREG(25) + 40.0f)) / (kREG(27) + 90.0f); + scale[0] = (kREG(19) * 0.1f + 40.0f) + div * ((kREG(26) + 50.0f) * (kREG(19) * 0.1f + 40.0f)); + scale[1] = (kREG(20) * 0.1f + 40.0f) + div * ((kREG(26) + 50.0f) * (kREG(20) * 0.1f + 40.0f)); + scale[2] = (kREG(21) * 0.1f + 40.0f) + div * ((kREG(26) + 50.0f) * (kREG(21) * 0.1f + 40.0f)); + *timer += 1.0f; + } else { + scale[0] = (kREG(19) * 0.1f + 40.0f) * (kREG(26) + 50.0f); + scale[1] = (kREG(20) * 0.1f + 40.0f) * (kREG(26) + 50.0f); + scale[2] = (kREG(21) * 0.1f + 40.0f) * (kREG(26) + 50.0f); + } + pthis->triforceAngle += (s16)(kREG(28) + 0x2EE0); + } + } +} + +void func_80B3FF0C(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CsActionsAreNotEqual(pthis, globalCtx, 1, 4)) { + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->state != 0) { + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[4]; + + if (npcAction != NULL) { + PosRot* posRot = &pthis->actor.world; + ActorShape* shape = &pthis->actor.shape; + Vec3i* startPos = &npcAction->startPos; + + posRot->pos.x = startPos->x; + posRot->pos.y = startPos->y; + posRot->pos.z = startPos->z; + + posRot->rot.y = shape->rot.y = npcAction->rot.y; + } + } + + pthis->action = SHEIK_ACTION_54; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + } +} + +void EnXc_SetupShowTriforceAction(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CompareCsAction(pthis, globalCtx, 10, 4)) { + Animation_Change(&pthis->skelAnime, &gSheikShowingTriforceOnHandAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gSheikShowingTriforceOnHandAnim), ANIMMODE_ONCE, -8.0f); + pthis->action = SHEIK_ACTION_SHOW_TRIFORCE; + pthis->drawMode = SHEIK_DRAW_TRIFORCE; + } +} + +void EnXc_SetupShowTriforceIdleAction(EnXc* pthis, s32 animFinished) { + if (animFinished) { + Animation_Change(&pthis->skelAnime, &gSheikShowingTriforceOnHandIdleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gSheikShowingTriforceOnHandIdleAnim), ANIMMODE_LOOP, 0.0f); + pthis->action = SHEIK_ACTION_SHOW_TRIFORCE_IDLE; + } +} +void func_80B400AC(EnXc* pthis, GlobalContext* globalCtx) { + if (EnXc_CompareCsAction(pthis, globalCtx, 9, 4)) { + Actor_Kill(&pthis->actor); + } +} + +void EnXc_ActionFunc53(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3FF0C(pthis, globalCtx); +} + +void EnXc_ActionFunc54(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupShowTriforceAction(pthis, globalCtx); + func_80B3C888(pthis, globalCtx); +} + +void EnXc_ShowTriforce(EnXc* pthis, GlobalContext* globalCtx) { + s32 animFinished = EnXc_AnimIsFinished(pthis); + + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_CalcTriforce(&pthis->actor, globalCtx); + func_80B3FAE0(pthis); + EnXc_SetupShowTriforceIdleAction(pthis, animFinished); + func_80B3C888(pthis, globalCtx); +} + +void EnXc_ShowTriforceIdle(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_CalcTriforce(&pthis->actor, globalCtx); + func_80B400AC(pthis, globalCtx); +} + +s32 EnXc_TriforceOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + if (limbIndex == 15) { + *dList = gSheikDL_011620; + } + return 0; +} + +void EnXc_TriforcePostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + s32 pad[2]; + EnXc* pthis = (EnXc*)thisx; + + if (limbIndex == 15) { + Vec3f vec = { 0.0f, 0.0f, 0.0f }; + EnXc_PlayTriforceSFX(&pthis->actor, globalCtx); + Matrix_MultVec3f(&vec, &pthis->handPos); + pthis->unk_2BC = 1; + } +} + +void EnXc_DrawTriforce(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + s32 pad; + s16 eyeIdx = pthis->eyeIdx; + void* eyeTexture = sEyeTextures[eyeIdx]; + SkelAnime* skelAnime = &pthis->skelAnime; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad2; + + OPEN_DISPS(gfxCtx, "../z_en_oA2_inMetamol.c", 565); + if (pthis->unk_2BC != 0) { + Mtx* mtx = (Mtx*)Graph_Alloc(gfxCtx, sizeof(Mtx)); + s32* primColor = pthis->triforcePrimColor; + s32* envColor = pthis->triforceEnvColor; + f32* scale = pthis->triforceScale; + + Matrix_Push(); + Matrix_Translate(kREG(16) + 100.0f, kREG(17) + 4460.0f, kREG(18) + 1190.0f, MTXMODE_APPLY); + Matrix_RotateZYX(kREG(22), kREG(23), pthis->triforceAngle, MTXMODE_APPLY); + Matrix_Scale(scale[0], scale[1], scale[2], MTXMODE_APPLY); + Matrix_ToMtx(mtx, "../z_en_oA2_inMetamol.c", 602); + Matrix_Pop(); + func_80093D84(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, primColor[2], primColor[3]); + gDPSetEnvColor(POLY_XLU_DISP++, 255, envColor[1], 0, 128); + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gSheikDL_012970); + } + + func_8002EBCC(thisx, globalCtx, 0); + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTexture)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTexture)); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnXc_TriforceOverrideLimbDraw, EnXc_TriforcePostLimbDraw, pthis); + CLOSE_DISPS(gfxCtx, "../z_en_oA2_inMetamol.c", 668); +} + +void func_80B40590(EnXc* pthis, GlobalContext* globalCtx) { + pthis->action = SHEIK_ACTION_NOCTURNE_INIT; + pthis->drawMode = SHEIK_DRAW_SQUINT; +} + +void EnXc_SetThrownAroundSFX(EnXc* pthis) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if (Animation_OnFrame(skelAnime, 9.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_BOUND_GRASS); + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_SK_CRASH); + } else if (Animation_OnFrame(skelAnime, 26.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_BOUND_GRASS); + } else if (Animation_OnFrame(skelAnime, 28.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_GRASS); + } else if (Animation_OnFrame(skelAnime, 34.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_GRASS); + } +} + +void EnXc_PlayLinkScreamSFX(EnXc* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 1455) { + func_800F3F3C(7); + } +} + +void EnXc_SetCrySFX(EnXc* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx = &globalCtx->csCtx; + + if (csCtx->frames == 869) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_SK_CRY_0); + } else if (csCtx->frames == 939) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_SK_CRY_1); + } +} + +void func_80B406F8(Actor* thisx) { + EnXc* pthis = (EnXc*)thisx; + + pthis->action = SHEIK_ACTION_NOCTURNE_INIT; + pthis->drawMode = SHEIK_DRAW_NOTHING; + pthis->actor.shape.shadowAlpha = 0; +} + +void EnXc_SetupIdleInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad; + ActorShape* actorShape = &pthis->actor.shape; + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); + + func_80B3C9DC(pthis); + func_80B3C588(pthis, globalCtx, 4); + Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + pthis->action = SHEIK_ACTION_NOCTURNE_IDLE; + pthis->drawMode = SHEIK_DRAW_SQUINT; + actorShape->shadowAlpha = 255; +} + +void EnXc_SetupDefenseStance(Actor* thisx) { + EnXc* pthis = (EnXc*)thisx; + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSheikDefenseStanceAnim); + + Animation_Change(skelAnime, &gSheikDefenseStanceAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -8.0f); + pthis->action = SHEIK_ACTION_DEFENSE_STANCE; + pthis->drawMode = SHEIK_DRAW_DEFAULT; +} + +void EnXc_SetupContortions(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad; + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); + + Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + func_80B3C588(pthis, globalCtx, 4); + func_80B3C964(pthis, globalCtx); + Animation_Change(skelAnime, &gSheikContortionsAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikContortionsAnim), + ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_CONTORT; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 255; +} + +void EnXc_SetupFallInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad; + SkelAnime* skelAnime = &pthis->skelAnime; + f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); + + Animation_Change(skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + func_80B3C588(pthis, globalCtx, 4); + func_80B3C964(pthis, globalCtx); + Animation_Change(skelAnime, &gSheikFallingFromContortionsAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gSheikFallingFromContortionsAnim), ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_NOCTURNE_FALL; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 255; +} + +void EnXc_SetupHittingGroundInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + f32 frameCount = Animation_GetLastFrame(&gSheikHittingGroundAnim); + + func_80B3C9DC(pthis); + func_80B3C588(pthis, globalCtx, 4); + Animation_Change(&pthis->skelAnime, &gSheikHittingGroundAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_NOCTURNE_HIT_GROUND; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 255; +} + +void func_80B40A78(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + f32 frameCount = Animation_GetLastFrame(&gSheikHittingGroundAnim); + + func_80B3C9DC(pthis); + func_80B3C588(pthis, globalCtx, 4); + Animation_Change(&pthis->skelAnime, &gSheikHittingGroundAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + pthis->action = SHEIK_ACTION_63; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 255; +} + +void EnXc_SetupKneelInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + f32 frameCount = Animation_GetLastFrame(&gSheikKneelingAnim); + + func_80B3C9DC(pthis); + func_80B3C588(pthis, globalCtx, 4); + Animation_Change(&pthis->skelAnime, &gSheikKneelingAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + pthis->action = SHEIK_ACTION_NOCTURNE_KNEEL; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 255; +} + +void func_80B40BB4(EnXc* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + f32 frameCount = Animation_GetLastFrame(&gSheikIdleAnim); + func_80B3C9DC(pthis); + func_80B3C588(pthis, globalCtx, 4); + Animation_Change(&pthis->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + pthis->action = SHEIK_ACTION_65; + pthis->drawMode = SHEIK_DRAW_DEFAULT; + pthis->actor.shape.shadowAlpha = 255; +} + +void func_80B40C50(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_65, SHEIK_ACTION_66); +} + +void func_80B40C74(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_66, SHEIK_ACTION_67); +} + +void func_80B40C98(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_67, SHEIK_ACTION_68); +} + +void func_80B40CBC(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_68, SHEIK_ACTION_69); +} + +void func_80B40CE0(EnXc* pthis) { + func_80B3C7D4(pthis, SHEIK_ACTION_69, SHEIK_ACTION_70, SHEIK_ACTION_68); +} + +void func_80B40D08(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_70, SHEIK_ACTION_71); +} + +void func_80B40D2C(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_71, SHEIK_ACTION_72); +} + +void func_80B40D50(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_72, SHEIK_ACTION_NOCTURNE_REVERSE_ACCEL); +} + +void func_80B40D74(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_NOCTURNE_REVERSE_ACCEL, SHEIK_ACTION_NOCTURNE_REVERSE_WALK); +} + +void EnXc_SetupReverseHaltInNocturneCS(EnXc* pthis) { + f32 xzDistToPlayer = pthis->actor.xzDistToPlayer; + + if (kREG(5) + 140.0f <= xzDistToPlayer) { + Animation_Change(&pthis->skelAnime, &gSheikIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gSheikIdleAnim), + ANIMMODE_LOOP, -12.0f); + pthis->action = SHEIK_ACTION_NOCTURNE_REVERSE_HALT; + pthis->timer = 0.0f; + } +} + +void func_80B40E40(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_NOCTURNE_REVERSE_HALT, SHEIK_ACTION_NOCTURNE_THROW_NUT); +} + +void func_80B40E64(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_NOCTURNE_THROW_NUT, SHEIK_ACTION_77); +} + +void func_80B40E88(EnXc* pthis) { + EnXc_CheckAndSetAction(pthis, SHEIK_ACTION_77, SHEIK_ACTION_78); +} + +s32 EnXc_SetupNocturneState(Actor* thisx, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 4); + + if (npcAction != NULL) { + s32 action = npcAction->action; + EnXc* pthis = (EnXc*)thisx; + s32 prevAction = pthis->unk_26C; + + if (action != prevAction) { + switch (action) { + case 1: + func_80B406F8(thisx); + break; + case 6: + EnXc_SetupIdleInNocturne(pthis, globalCtx); + break; + case 20: + EnXc_SetupDefenseStance(thisx); + break; + case 18: + EnXc_SetupContortions(pthis, globalCtx); + break; + case 14: + EnXc_SetupFallInNocturne(pthis, globalCtx); + break; + case 19: + EnXc_SetupHittingGroundInNocturne(pthis, globalCtx); + break; + case 15: + func_80B40A78(pthis, globalCtx); + break; + case 16: + EnXc_SetupKneelInNocturne(pthis, globalCtx); + break; + case 17: + func_80B40BB4(pthis, globalCtx); + break; + case 9: + Actor_Kill(thisx); + break; + default: + osSyncPrintf("En_Oa2_Stalker_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + + pthis->unk_26C = action; + return 1; + } + } + return 0; +} + +void EnXc_InitialNocturneAction(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_SetupNocturneState(&pthis->actor, globalCtx); +} + +void EnXc_IdleInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3C588(pthis, globalCtx, 4); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetupNocturneState(&pthis->actor, globalCtx); +} + +void EnXc_DefenseStance(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupNocturneState(&pthis->actor, globalCtx); +} + +void EnXc_Contort(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_SetCrySFX(pthis, globalCtx); + EnXc_AnimIsFinished(pthis); + EnXc_SetEyePattern(pthis); + if (!EnXc_SetupNocturneState(&pthis->actor, globalCtx)) { + func_80B3C924(pthis, globalCtx); + EnXc_BgCheck(pthis, globalCtx); + } +} + +void EnXc_FallInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_SetEyePattern(pthis); + EnXc_SetThrownAroundSFX(pthis); + if (!EnXc_SetupNocturneState(&pthis->actor, globalCtx)) { + func_80B3C8CC(pthis, globalCtx); + EnXc_BgCheck(pthis, globalCtx); + } +} + +void EnXc_HitGroundInNocturne(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupNocturneState(&pthis->actor, globalCtx); +} + +void EnXc_ActionFunc63(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_PlayLinkScreamSFX(pthis, globalCtx); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupNocturneState(&pthis->actor, globalCtx); +} + +void EnXc_KneelInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupNocturneState(&pthis->actor, globalCtx); +} + +void EnXc_ActionFunc65(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc6(pthis, globalCtx); + func_80B3C588(pthis, globalCtx, 4); + func_80B40C50(pthis); +} + +void EnXc_ActionFunc66(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc7(pthis, globalCtx); + func_80B40C74(pthis); +} + +void EnXc_ActionFunc67(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc8(pthis, globalCtx); + func_80B40C98(pthis); +} + +void EnXc_ActionFunc68(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc9(pthis, globalCtx); + func_80B40CBC(pthis); +} + +void EnXc_ActionFunc69(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc10(pthis, globalCtx); + func_80B40CE0(pthis); +} + +void EnXc_ActionFunc70(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc11(pthis, globalCtx); + func_80B40D08(pthis); +} + +void EnXc_ActionFunc71(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc12(pthis, globalCtx); + func_80B40D2C(pthis); +} + +void EnXc_ActionFunc72(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ActionFunc13(pthis, globalCtx); + func_80B40D50(pthis); +} + +void EnXc_ReverseAccelInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ReverseAccelerate(pthis, globalCtx); + func_80B40D74(pthis); +} + +void EnXc_ReverseWalkInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + func_80B3D710(pthis); + EnXc_AnimIsFinished(pthis); + EnXc_BgCheck(pthis, globalCtx); + EnXc_SetEyePattern(pthis); + EnXc_SetupReverseHaltInNocturneCS(pthis); +} + +void EnXc_ReverseHaltInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_HaltAndWaitToThrowNut(pthis, globalCtx); + func_80B40E40(pthis); +} + +void EnXc_ThrowNutInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_ThrowNut(pthis, globalCtx); + func_80B40E64(pthis); +} + +void EnXc_DeleteInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_Delete(pthis, globalCtx); + func_80B40E88(pthis); +} + +void EnXc_KillInNocturneCS(EnXc* pthis, GlobalContext* globalCtx) { + Actor_Kill(&pthis->actor); +} + +void EnXc_DrawSquintingEyes(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + SkelAnime* skelAnime = &pthis->skelAnime; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_en_oA2_inStalker.c", 839); + func_80093D18(gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gSheikEyeSquintingTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gSheikEyeSquintingTex)); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, NULL, NULL, + NULL); + CLOSE_DISPS(gfxCtx, "../z_en_oA2_inStalker.c", 854); +} + +void EnXc_InitTempleOfTime(EnXc* pthis, GlobalContext* globalCtx) { + if (LINK_IS_ADULT) { + if (!(gSaveContext.eventChkInf[12] & 0x20)) { + gSaveContext.eventChkInf[12] |= 0x20; + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gTempleOfTimeFirstAdultCs); + gSaveContext.cutsceneTrigger = 1; + func_80B3EBF0(pthis, globalCtx); + } else if (!(gSaveContext.eventChkInf[5] & 0x20) && (gSaveContext.eventChkInf[4] & 0x100)) { + gSaveContext.eventChkInf[5] |= 0x20; + Item_Give(globalCtx, ITEM_SONG_PRELUDE); + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gTempleOfTimePreludeCs); + gSaveContext.cutsceneTrigger = 1; + pthis->action = SHEIK_ACTION_30; + } else if (!(gSaveContext.eventChkInf[5] & 0x20)) { + func_80B3C9EC(pthis); + } else { + Actor_Kill(&pthis->actor); + } + } else { + Actor_Kill(&pthis->actor); + } +} + +void EnXc_SetupDialogueAction(EnXc* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->action = SHEIK_ACTION_IN_DIALOGUE; + } else { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + if (INV_CONTENT(ITEM_HOOKSHOT) != ITEM_NONE) { + pthis->actor.textId = 0x7010; + } else { + pthis->actor.textId = 0x700F; + } + func_8002F2F4(&pthis->actor, globalCtx); + } +} + +void func_80B41798(EnXc* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->action = SHEIK_ACTION_BLOCK_PEDESTAL; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + } +} + +void EnXc_BlockingPedestalAction(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_BgCheck(pthis, globalCtx); + EnXc_UpdateCollider(&pthis->actor, globalCtx); + EnXc_CalculateHeadTurn(pthis, globalCtx); + EnXc_AnimIsFinished(pthis); + EnXc_SetEyePattern(pthis); + EnXc_SetupDialogueAction(pthis, globalCtx); +} + +void EnXc_ActionFunc80(EnXc* pthis, GlobalContext* globalCtx) { + EnXc_BgCheck(pthis, globalCtx); + EnXc_UpdateCollider(&pthis->actor, globalCtx); + EnXc_CalculateHeadTurn(pthis, globalCtx); + EnXc_AnimIsFinished(pthis); + EnXc_SetEyePattern(pthis); + func_80B41798(pthis, globalCtx); +} + +static EnXcActionFunc sActionFuncs[] = { + EnXc_ActionFunc0, + EnXc_ActionFunc1, + EnXc_GracefulFall, + EnXc_Accelerate, + EnXc_Walk, + EnXc_Stopped, + EnXc_ActionFunc6, + EnXc_ActionFunc7, + EnXc_ActionFunc8, + EnXc_ActionFunc9, + EnXc_ActionFunc10, + EnXc_ActionFunc11, + EnXc_ActionFunc12, + EnXc_ActionFunc13, + EnXc_ReverseAccelerate, + EnXc_ActionFunc15, + EnXc_HaltAndWaitToThrowNut, + EnXc_ThrowNut, + EnXc_Delete, + EnXc_Fade, + EnXc_ActionFunc20, + EnXc_ActionFunc21, + EnXc_ActionFunc22, + EnXc_ActionFunc23, + EnXc_ActionFunc24, + EnXc_ActionFunc25, + EnXc_ActionFunc26, + EnXc_ActionFunc27, + EnXc_ActionFunc28, + EnXc_Serenade, + EnXc_ActionFunc30, + EnXc_ActionFunc31, + EnXc_ActionFunc32, + EnXc_ActionFunc33, + EnXc_ActionFunc34, + EnXc_ActionFunc35, + EnXc_ActionFunc36, + EnXc_ActionFunc37, + EnXc_ActionFunc38, + EnXc_ActionFunc39, + EnXc_ActionFunc40, + EnXc_ActionFunc41, + EnXc_ActionFunc42, + EnXc_ActionFunc43, + EnXc_ActionFunc44, + EnXc_ActionFunc45, + EnXc_ActionFunc46, + EnXc_ActionFunc47, + EnXc_ActionFunc48, + EnXc_ActionFunc49, + EnXc_Kneel, + EnXc_ActionFunc51, + EnXc_ActionFunc52, + EnXc_ActionFunc53, + EnXc_ActionFunc54, + EnXc_ShowTriforce, + EnXc_ShowTriforceIdle, + EnXc_InitialNocturneAction, + EnXc_IdleInNocturne, + EnXc_DefenseStance, + EnXc_Contort, + EnXc_FallInNocturne, + EnXc_HitGroundInNocturne, + EnXc_ActionFunc63, + EnXc_KneelInNocturneCS, + EnXc_ActionFunc65, + EnXc_ActionFunc66, + EnXc_ActionFunc67, + EnXc_ActionFunc68, + EnXc_ActionFunc69, + EnXc_ActionFunc70, + EnXc_ActionFunc71, + EnXc_ActionFunc72, + EnXc_ReverseAccelInNocturneCS, + EnXc_ReverseWalkInNocturneCS, + EnXc_ReverseHaltInNocturneCS, + EnXc_ThrowNutInNocturneCS, + EnXc_DeleteInNocturneCS, + EnXc_KillInNocturneCS, + EnXc_BlockingPedestalAction, + EnXc_ActionFunc80, +}; + +void EnXc_Update(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + s32 action = pthis->action; + + if ((action < 0) || (action >= ARRAY_COUNT(sActionFuncs)) || (sActionFuncs[action] == NULL)) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + } else { + sActionFuncs[action](pthis, globalCtx); + } +} + +void EnXc_Init(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gSheikSkel, &gSheikIdleAnim, pthis->jointTable, pthis->morphTable, + ARRAY_COUNT(pthis->jointTable)); + EnXc_InitCollider(thisx, globalCtx); + + switch (pthis->actor.params) { + case SHEIK_TYPE_1: + func_80B3EBF0(pthis, globalCtx); + break; + case SHEIK_TYPE_2: // Beta Serenade Cutscene or Learning Prelude + func_80B3EE64(pthis, globalCtx); + break; + case SHEIK_TYPE_3: + func_80B3F3C8(pthis, globalCtx); + break; + case SHEIK_TYPE_4: + func_80B3FA08(pthis, globalCtx); + break; + case SHEIK_TYPE_5: + func_80B40590(pthis, globalCtx); + break; + case SHEIK_TYPE_MINUET: + func_80B3CA38(pthis, globalCtx); + break; + case SHEIK_TYPE_BOLERO: + func_80B3CB58(pthis, globalCtx); + break; + case SHEIK_TYPE_SERENADE: + EnXc_SetupSerenadeAction(pthis, globalCtx); + break; + case SHEIK_TYPE_9: + EnXc_InitTempleOfTime(pthis, globalCtx); + break; + case SHEIK_TYPE_0: + EnXc_DoNothing(pthis, globalCtx); + break; + default: + osSyncPrintf(VT_FGCOL(RED) " En_Oa2 の arg_data がおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + EnXc_DoNothing(pthis, globalCtx); + } +} + +s32 EnXc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnXc* pthis = (EnXc*)thisx; + + if (pthis->unk_30C != 0) { + if (limbIndex == 9) { + rot->x += pthis->npcInfo.unk_0E.y; + rot->y -= pthis->npcInfo.unk_0E.x; + } else if (limbIndex == 16) { + rot->x += pthis->npcInfo.unk_08.y; + rot->z += pthis->npcInfo.unk_08.x; + } + } + return 0; +} + +void EnXc_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + if (limbIndex == 16) { + EnXc* pthis = (EnXc*)thisx; + Vec3f src = { 0.0f, 10.0f, 0.0f }; + Vec3f dest; + + Matrix_MultVec3f(&src, &dest); + pthis->actor.focus.pos.x = dest.x; + pthis->actor.focus.pos.y = dest.y; + pthis->actor.focus.pos.z = dest.z; + pthis->actor.focus.rot.x = pthis->actor.world.rot.x; + pthis->actor.focus.rot.y = pthis->actor.world.rot.y; + pthis->actor.focus.rot.z = pthis->actor.world.rot.z; + } +} + +void EnXc_DrawNothing(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnXc_DrawDefault(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnXc* pthis = (EnXc*)thisx; + s16 eyeIdx = pthis->eyeIdx; + void* eyeSegment = sEyeTextures[eyeIdx]; + SkelAnime* skelAnime = &pthis->skelAnime; + GraphicsContext* localGfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = localGfxCtx; + + OPEN_DISPS(gfxCtx, "../z_en_oA2.c", 1164); + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_80093D18(gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeSegment)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeSegment)); + SkelAnime_DrawFlexOpa(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnXc_OverrideLimbDraw, EnXc_PostLimbDraw, pthis); + CLOSE_DISPS(gfxCtx, "../z_en_oA2.c", 1207); +} + +static EnXcDrawFunc sDrawFuncs[] = { + EnXc_DrawNothing, EnXc_DrawDefault, EnXc_DrawPullingOutHarp, + EnXc_DrawHarp, EnXc_DrawTriforce, EnXc_DrawSquintingEyes, +}; + +void EnXc_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnXc* pthis = (EnXc*)thisx; + + if (pthis->drawMode < 0 || pthis->drawMode > 5 || sDrawFuncs[pthis->drawMode] == NULL) { + // "Draw mode is abnormal!!!!!!!!!!!!!!!!!!!!!!!!!" + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + } else { + sDrawFuncs[pthis->drawMode](thisx, globalCtx); + } +} + +ActorInit En_Xc_InitVars = { + ACTOR_EN_XC, + ACTORCAT_NPC, + FLAGS, + OBJECT_XC, + sizeof(EnXc), + (ActorFunc)EnXc_Init, + (ActorFunc)EnXc_Destroy, + (ActorFunc)EnXc_Update, + (ActorFunc)EnXc_Draw, +}; diff --git a/src/overlays/actors/ovl_En_Yabusame_Mark/z_en_yabusame_mark.c b/src/overlays/actors/ovl_En_Yabusame_Mark/z_en_yabusame_mark.cpp similarity index 62% rename from src/overlays/actors/ovl_En_Yabusame_Mark/z_en_yabusame_mark.c rename to src/overlays/actors/ovl_En_Yabusame_Mark/z_en_yabusame_mark.cpp index 2f299c539..adb3cd44c 100644 --- a/src/overlays/actors/ovl_En_Yabusame_Mark/z_en_yabusame_mark.c +++ b/src/overlays/actors/ovl_En_Yabusame_Mark/z_en_yabusame_mark.cpp @@ -21,7 +21,7 @@ void EnYabusameMark_Init(Actor* thisx, GlobalContext* globalCtx); void EnYabusameMark_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnYabusameMark_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx); +void func_80B42F74(EnYabusameMark* pthis, GlobalContext* globalCtx); static ColliderQuadInit sQuadInit = { { @@ -43,7 +43,7 @@ static ColliderQuadInit sQuadInit = { { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -const ActorInit En_Yabusame_Mark_InitVars = { +ActorInit En_Yabusame_Mark_InitVars = { ACTOR_EN_YABUSAME_MARK, ACTORCAT_PROP, FLAGS, @@ -79,51 +79,51 @@ static f32 sRingDistance[] = { }; void EnYabusameMark_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnYabusameMark* this = (EnYabusameMark*)thisx; + EnYabusameMark* pthis = (EnYabusameMark*)thisx; - Collider_DestroyQuad(globalCtx, &this->collider); + Collider_DestroyQuad(globalCtx, &pthis->collider); } void EnYabusameMark_Init(Actor* thisx, GlobalContext* globalCtx) { - EnYabusameMark* this = (EnYabusameMark*)thisx; + EnYabusameMark* pthis = (EnYabusameMark*)thisx; osSyncPrintf("\n\n"); - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ やぶさめまと ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); - this->actor.flags &= ~ACTOR_FLAG_0; - this->typeIndex = this->actor.params; - this->actor.targetMode = 5; - osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 種類インデックス \t ☆☆☆☆☆ %d\n" VT_RST, this->typeIndex); - switch (this->typeIndex) { + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ やぶさめまと ☆☆☆☆☆ %x\n" VT_RST, pthis->actor.params); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->typeIndex = pthis->actor.params; + pthis->actor.targetMode = 5; + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 種類インデックス \t ☆☆☆☆☆ %d\n" VT_RST, pthis->typeIndex); + switch (pthis->typeIndex) { case 0: - this->subTypeIndex = 0; - if (this->actor.world.pos.z > 0.0f) { - this->subTypeIndex = 1; + pthis->subTypeIndex = 0; + if (pthis->actor.world.pos.z > 0.0f) { + pthis->subTypeIndex = 1; } break; case 1: - this->subTypeIndex = 2; - if (this->actor.world.pos.z < -2000.0f) { - this->subTypeIndex = 3; + pthis->subTypeIndex = 2; + if (pthis->actor.world.pos.z < -2000.0f) { + pthis->subTypeIndex = 3; } break; case 2: - this->subTypeIndex = 4; + pthis->subTypeIndex = 4; break; } - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); - this->worldPos = this->actor.world.pos; - this->actor.flags |= ACTOR_FLAG_4; + Collider_InitQuad(globalCtx, &pthis->collider); + Collider_SetQuad(globalCtx, &pthis->collider, &pthis->actor, &sQuadInit); + pthis->worldPos = pthis->actor.world.pos; + pthis->actor.flags |= ACTOR_FLAG_4; if (gSaveContext.sceneSetupIndex != 4) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 種類 ☆☆☆☆☆ %d\n" VT_RST, this->typeIndex); - osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ さらに分類 ☆☆☆☆☆ %d\n" VT_RST, this->subTypeIndex); - this->actionFunc = func_80B42F74; + osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 種類 ☆☆☆☆☆ %d\n" VT_RST, pthis->typeIndex); + osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ さらに分類 ☆☆☆☆☆ %d\n" VT_RST, pthis->subTypeIndex); + pthis->actionFunc = func_80B42F74; } -void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) { +void func_80B42F74(EnYabusameMark* pthis, GlobalContext* globalCtx) { Vec3f effectAccel = { 0.0f, 0.0f, 0.0f }; Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; Vec3f arrowHitPos; @@ -134,12 +134,12 @@ void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) { f32 scoreDistance60; f32 scoreDistance30; - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; + if (pthis->collider.base.acFlags & AC_HIT) { + pthis->collider.base.acFlags &= ~AC_HIT; - arrowHitPos.x = this->collider.info.bumper.hitPos.x; - arrowHitPos.y = this->collider.info.bumper.hitPos.y; - arrowHitPos.z = this->collider.info.bumper.hitPos.z; + arrowHitPos.x = pthis->collider.info.bumper.hitPos.x; + arrowHitPos.y = pthis->collider.info.bumper.hitPos.y; + arrowHitPos.z = pthis->collider.info.bumper.hitPos.z; effectVelocity.y = 15.0f; @@ -147,13 +147,13 @@ void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) { scoreIndex = 2; - scoreDistance100 = sRingDistance[this->typeIndex * 4 + 0]; - scoreDistance60 = sRingDistance[this->typeIndex * 4 + 1]; - scoreDistance30 = sRingDistance[this->typeIndex * 4 + 2]; + scoreDistance100 = sRingDistance[pthis->typeIndex * 4 + 0]; + scoreDistance60 = sRingDistance[pthis->typeIndex * 4 + 1]; + scoreDistance30 = sRingDistance[pthis->typeIndex * 4 + 2]; - distanceFromCenter.x = fabsf(sTargetPos[this->subTypeIndex].x - arrowHitPos.x); - distanceFromCenter.y = fabsf(sTargetPos[this->subTypeIndex].y - arrowHitPos.y); - distanceFromCenter.z = fabsf(sTargetPos[this->subTypeIndex].z - arrowHitPos.z); + distanceFromCenter.x = fabsf(sTargetPos[pthis->subTypeIndex].x - arrowHitPos.x); + distanceFromCenter.y = fabsf(sTargetPos[pthis->subTypeIndex].y - arrowHitPos.y); + distanceFromCenter.z = fabsf(sTargetPos[pthis->subTypeIndex].z - arrowHitPos.z); if (distanceFromCenter.x > scoreDistance100 || distanceFromCenter.y > scoreDistance100 || distanceFromCenter.z > scoreDistance100) { @@ -172,9 +172,9 @@ void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) { osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ posX ☆☆☆☆☆ %f\n" VT_RST, arrowHitPos.x); osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ posY ☆☆☆☆☆ %f\n" VT_RST, arrowHitPos.y); osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ posZ ☆☆☆☆☆ %f\n" VT_RST, arrowHitPos.z); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ hitX ☆☆☆☆☆ %f\n" VT_RST, sTargetPos[this->subTypeIndex].x); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ hitY ☆☆☆☆☆ %f\n" VT_RST, sTargetPos[this->subTypeIndex].y); - osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ hitZ ☆☆☆☆☆ %f\n" VT_RST, sTargetPos[this->subTypeIndex].z); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ hitX ☆☆☆☆☆ %f\n" VT_RST, sTargetPos[pthis->subTypeIndex].x); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ hitY ☆☆☆☆☆ %f\n" VT_RST, sTargetPos[pthis->subTypeIndex].y); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ hitZ ☆☆☆☆☆ %f\n" VT_RST, sTargetPos[pthis->subTypeIndex].z); osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 小 ☆☆☆☆☆ %f\n" VT_RST, scoreDistance100); osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 大 ☆☆☆☆☆ %f\n" VT_RST, scoreDistance60); osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ point ☆☆☆☆☆ %d\n" VT_RST, scoreIndex); @@ -195,30 +195,30 @@ void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) { } void EnYabusameMark_Update(Actor* thisx, GlobalContext* globalCtx) { - EnYabusameMark* this = (EnYabusameMark*)thisx; + EnYabusameMark* pthis = (EnYabusameMark*)thisx; Vec3f* vertexArray; u32 arrayIndex; - this->actionFunc(this, globalCtx); - arrayIndex = this->typeIndex * 4; + pthis->actionFunc(pthis, globalCtx); + arrayIndex = pthis->typeIndex * 4; vertexArray = &sCollisionVertices[arrayIndex]; - this->vertexA.x = vertexArray[0].x + this->actor.world.pos.x; - this->vertexA.y = vertexArray[0].y + this->actor.world.pos.y; - this->vertexA.z = vertexArray[0].z + this->actor.world.pos.z; + pthis->vertexA.x = vertexArray[0].x + pthis->actor.world.pos.x; + pthis->vertexA.y = vertexArray[0].y + pthis->actor.world.pos.y; + pthis->vertexA.z = vertexArray[0].z + pthis->actor.world.pos.z; - this->vertexB.x = vertexArray[1].x + this->actor.world.pos.x; - this->vertexB.y = vertexArray[1].y + this->actor.world.pos.y; - this->vertexB.z = vertexArray[1].z + this->actor.world.pos.z; + pthis->vertexB.x = vertexArray[1].x + pthis->actor.world.pos.x; + pthis->vertexB.y = vertexArray[1].y + pthis->actor.world.pos.y; + pthis->vertexB.z = vertexArray[1].z + pthis->actor.world.pos.z; - this->vertexC.x = vertexArray[2].x + this->actor.world.pos.x; - this->vertexC.y = vertexArray[2].y + this->actor.world.pos.y; - this->vertexC.z = vertexArray[2].z + this->actor.world.pos.z; + pthis->vertexC.x = vertexArray[2].x + pthis->actor.world.pos.x; + pthis->vertexC.y = vertexArray[2].y + pthis->actor.world.pos.y; + pthis->vertexC.z = vertexArray[2].z + pthis->actor.world.pos.z; - this->vertexD.x = vertexArray[3].x + this->actor.world.pos.x; - this->vertexD.y = vertexArray[3].y + this->actor.world.pos.y; - this->vertexD.z = vertexArray[3].z + this->actor.world.pos.z; + pthis->vertexD.x = vertexArray[3].x + pthis->actor.world.pos.x; + pthis->vertexD.y = vertexArray[3].y + pthis->actor.world.pos.y; + pthis->vertexD.z = vertexArray[3].z + pthis->actor.world.pos.z; - Collider_SetQuadVertices(&this->collider, &this->vertexA, &this->vertexB, &this->vertexC, &this->vertexD); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_SetQuadVertices(&pthis->collider, &pthis->vertexA, &pthis->vertexB, &pthis->vertexC, &pthis->vertexD); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } diff --git a/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c b/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c deleted file mode 100644 index 587429728..000000000 --- a/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.c +++ /dev/null @@ -1,167 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_YUKABYUN_Z_EN_YUKABYUN_C -#include "actor_common.h" -/* - * File: z_en_yukabyun.c - * Overlay: ovl_En_Yukabyun - * Description: Flying floor tile - */ - -#include "z_en_yukabyun.h" -#include "objects/object_yukabyun/object_yukabyun.h" -#include "def/code_8006BA00.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnYukabyun_Init(Actor* thisx, GlobalContext* globalCtx); -void EnYukabyun_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnYukabyun_Update(Actor* thisx, GlobalContext* globalCtx); -void EnYukabyun_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B43A94(EnYukabyun* this, GlobalContext* globalCtx); -void func_80B43AD4(EnYukabyun* this, GlobalContext* globalCtx); -void func_80B43B6C(EnYukabyun* this, GlobalContext* globalCtx); - -const ActorInit En_Yukabyun_InitVars = { - ACTOR_EN_YUKABYUN, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_YUKABYUN, - sizeof(EnYukabyun), - (ActorFunc)EnYukabyun_Init, - (ActorFunc)EnYukabyun_Destroy, - (ActorFunc)EnYukabyun_Update, - (ActorFunc)EnYukabyun_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x04 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_HARD, - BUMP_ON, - OCELEM_ON, - }, - { 28, 8, 0, { 0, 0, 0 } }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 16, ICHAIN_STOP), -}; - -static void* D_80B43F64[] = { gFloorTileEnemyTopTex, gFloorTileEnemyBottomTex }; - -void EnYukabyun_Init(Actor* thisx, GlobalContext* globalCtx) { - EnYukabyun* this = (EnYukabyun*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.4f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.params++; - this->unk_152 = 0; - this->unk_150 = (u8)(this->actor.params) * 0xA + 0x14; - this->actionfunc = func_80B43A94; -} - -void EnYukabyun_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnYukabyun* this = (EnYukabyun*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80B43A94(EnYukabyun* this, GlobalContext* globalCtx) { - if (this->unk_150 != 0) { - this->unk_150--; - } - if (this->unk_150 == 0) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12; - this->actionfunc = func_80B43AD4; - } -} - -void func_80B43AD4(EnYukabyun* this, GlobalContext* globalCtx) { - this->unk_150 += 0xA0; - this->actor.shape.rot.y += this->unk_150; - if (this->unk_150 >= 0x2000) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = 10.0f; - this->actionfunc = func_80B43B6C; - } - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 30.0f, 1.0f); - func_8002F974(&this->actor, NA_SE_EN_YUKABYUN_FLY - SFX_FLAG); -} - -void func_80B43B6C(EnYukabyun* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += this->unk_150; - if (this->actor.xzDistToPlayer > 5000.0f) { - Actor_Kill(&this->actor); - return; - } - func_8002F974(&this->actor, NA_SE_EN_YUKABYUN_FLY - SFX_FLAG); -} - -void EnYukabyun_Break(EnYukabyun* this, GlobalContext* globalCtx) { - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 8.0f, 0, 1300, 300, 15, OBJECT_YUKABYUN, 10, - gFloorTileEnemyFragmentDL); - Actor_Kill(&this->actor); -} - -void EnYukabyun_Update(Actor* thisx, GlobalContext* globalCtx) { - EnYukabyun* this = (EnYukabyun*)thisx; - s32 pad; - - if (((this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || - ((this->collider.base.ocFlags1 & OC1_HIT) && !(this->collider.base.oc->id == ACTOR_EN_YUKABYUN))) || - ((this->actionfunc == func_80B43B6C) && (this->actor.bgCheckFlags & 8))) { - this->collider.base.atFlags &= ~AT_HIT; - this->collider.base.acFlags &= ~AC_HIT; - this->collider.base.ocFlags1 &= ~OC1_HIT; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_OCTAROCK_ROCK); - this->actionfunc = EnYukabyun_Break; - } - - this->actionfunc(this, globalCtx); - Actor_MoveForward(&this->actor); - - if (!(this->actionfunc == func_80B43A94 || this->actionfunc == EnYukabyun_Break)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 20.0f, 8.0f, 5); - Collider_UpdateCylinder(&this->actor, &this->collider); - - this->actor.flags |= ACTOR_FLAG_24; - - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - Actor_SetFocus(&this->actor, 4.0f); -} - -void EnYukabyun_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnYukabyun* this = (EnYukabyun*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_yukabyun.c", 366); - - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80B43F64[this->unk_152])); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_yukabyun.c", 373), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gFloorTileEnemyDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_yukabyun.c", 378); -} diff --git a/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.cpp b/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.cpp new file mode 100644 index 000000000..83b615278 --- /dev/null +++ b/src/overlays/actors/ovl_En_Yukabyun/z_en_yukabyun.cpp @@ -0,0 +1,167 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_YUKABYUN_Z_EN_YUKABYUN_C +#include "actor_common.h" +/* + * File: z_en_yukabyun.c + * Overlay: ovl_En_Yukabyun + * Description: Flying floor tile + */ + +#include "z_en_yukabyun.h" +#include "objects/object_yukabyun/object_yukabyun.h" +#include "def/code_8006BA00.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnYukabyun_Init(Actor* thisx, GlobalContext* globalCtx); +void EnYukabyun_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnYukabyun_Update(Actor* thisx, GlobalContext* globalCtx); +void EnYukabyun_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B43A94(EnYukabyun* pthis, GlobalContext* globalCtx); +void func_80B43AD4(EnYukabyun* pthis, GlobalContext* globalCtx); +void func_80B43B6C(EnYukabyun* pthis, GlobalContext* globalCtx); + +ActorInit En_Yukabyun_InitVars = { + ACTOR_EN_YUKABYUN, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_YUKABYUN, + sizeof(EnYukabyun), + (ActorFunc)EnYukabyun_Init, + (ActorFunc)EnYukabyun_Destroy, + (ActorFunc)EnYukabyun_Update, + (ActorFunc)EnYukabyun_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x04 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, + { 28, 8, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 16, ICHAIN_STOP), +}; + +static void* D_80B43F64[] = { gFloorTileEnemyTopTex, gFloorTileEnemyBottomTex }; + +void EnYukabyun_Init(Actor* thisx, GlobalContext* globalCtx) { + EnYukabyun* pthis = (EnYukabyun*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.4f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actor.params++; + pthis->unk_152 = 0; + pthis->unk_150 = (u8)(pthis->actor.params) * 0xA + 0x14; + pthis->actionfunc = func_80B43A94; +} + +void EnYukabyun_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnYukabyun* pthis = (EnYukabyun*)thisx; + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80B43A94(EnYukabyun* pthis, GlobalContext* globalCtx) { + if (pthis->unk_150 != 0) { + pthis->unk_150--; + } + if (pthis->unk_150 == 0) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_12; + pthis->actionfunc = func_80B43AD4; + } +} + +void func_80B43AD4(EnYukabyun* pthis, GlobalContext* globalCtx) { + pthis->unk_150 += 0xA0; + pthis->actor.shape.rot.y += pthis->unk_150; + if (pthis->unk_150 >= 0x2000) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = 10.0f; + pthis->actionfunc = func_80B43B6C; + } + Math_StepToF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + 30.0f, 1.0f); + func_8002F974(&pthis->actor, NA_SE_EN_YUKABYUN_FLY - SFX_FLAG); +} + +void func_80B43B6C(EnYukabyun* pthis, GlobalContext* globalCtx) { + pthis->actor.shape.rot.y += pthis->unk_150; + if (pthis->actor.xzDistToPlayer > 5000.0f) { + Actor_Kill(&pthis->actor); + return; + } + func_8002F974(&pthis->actor, NA_SE_EN_YUKABYUN_FLY - SFX_FLAG); +} + +void EnYukabyun_Break(EnYukabyun* pthis, GlobalContext* globalCtx) { + EffectSsHahen_SpawnBurst(globalCtx, &pthis->actor.world.pos, 8.0f, 0, 1300, 300, 15, OBJECT_YUKABYUN, 10, + gFloorTileEnemyFragmentDL); + Actor_Kill(&pthis->actor); +} + +void EnYukabyun_Update(Actor* thisx, GlobalContext* globalCtx) { + EnYukabyun* pthis = (EnYukabyun*)thisx; + s32 pad; + + if (((pthis->collider.base.atFlags & AT_HIT) || (pthis->collider.base.acFlags & AC_HIT) || + ((pthis->collider.base.ocFlags1 & OC1_HIT) && !(pthis->collider.base.oc->id == ACTOR_EN_YUKABYUN))) || + ((pthis->actionfunc == func_80B43B6C) && (pthis->actor.bgCheckFlags & 8))) { + pthis->collider.base.atFlags &= ~AT_HIT; + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.ocFlags1 &= ~OC1_HIT; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 30, NA_SE_EN_OCTAROCK_ROCK); + pthis->actionfunc = EnYukabyun_Break; + } + + pthis->actionfunc(pthis, globalCtx); + Actor_MoveForward(&pthis->actor); + + if (!(pthis->actionfunc == func_80B43A94 || pthis->actionfunc == EnYukabyun_Break)) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 20.0f, 8.0f, 5); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + + pthis->actor.flags |= ACTOR_FLAG_24; + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + Actor_SetFocus(&pthis->actor, 4.0f); +} + +void EnYukabyun_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnYukabyun* pthis = (EnYukabyun*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_yukabyun.c", 366); + + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80B43F64[pthis->unk_152])); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_yukabyun.c", 373), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFloorTileEnemyDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_yukabyun.c", 378); +} diff --git a/src/overlays/actors/ovl_En_Zf/z_en_zf.c b/src/overlays/actors/ovl_En_Zf/z_en_zf.c deleted file mode 100644 index f86d29919..000000000 --- a/src/overlays/actors/ovl_En_Zf/z_en_zf.c +++ /dev/null @@ -1,2439 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZF_Z_EN_ZF_C -#include "actor_common.h" -/* - * File: z_en_zf.c - * Overlay: ovl_En_Zf - * Description: Lizalfos and Dinolfos - */ - -#include "z_en_zf.h" -#include "objects/object_zf/object_zf.h" -#include "def/code_800EC960.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_eff_blure.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) - -void EnZf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZf_Draw(Actor* thisx, GlobalContext* globalCtx); - -s16 EnZf_FindPlatform(Vec3f* pos, s16 preferredIndex); -void EnZf_SetupDropIn(EnZf* this); -void EnZf_DropIn(EnZf* this, GlobalContext* globalCtx); -void func_80B45384(EnZf* this); -void func_80B4543C(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupApproachPlayer(EnZf* this, GlobalContext* globalCtx); -void EnZf_ApproachPlayer(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupJumpForward(EnZf* this); -void EnZf_JumpForward(EnZf* this, GlobalContext* globalCtx); -void func_80B4604C(EnZf* this); -void func_80B46098(EnZf* this, GlobalContext* globalCtx); -void func_80B462E4(EnZf* this, GlobalContext* globalCtx); -void func_80B463E4(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupSlash(EnZf* this); -void EnZf_Slash(EnZf* this, GlobalContext* globalCtx); -void EnZf_RecoilFromBlockedSlash(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupJumpBack(EnZf* this); -void EnZf_JumpBack(EnZf* this, GlobalContext* globalCtx); -void EnZf_Stunned(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupSheatheSword(EnZf* this, GlobalContext* globalCtx); -void EnZf_SheatheSword(EnZf* this, GlobalContext* globalCtx); -void EnZf_HopAndTaunt(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupHopAway(EnZf* this, GlobalContext* globalCtx); -void EnZf_HopAway(EnZf* this, GlobalContext* globalCtx); -void EnZf_DrawSword(EnZf* this, GlobalContext* globalCtx); -void EnZf_Damaged(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupJumpUp(EnZf* this); -void EnZf_JumpUp(EnZf* this, GlobalContext* globalCtx); -void func_80B483E4(EnZf* this, GlobalContext* globalCtx); -void EnZf_CircleAroundPlayer(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupDie(EnZf* this); -void EnZf_Die(EnZf* this, GlobalContext* globalCtx); -void EnZf_SetupCircleAroundPlayer(EnZf* this, f32 speed); -s32 EnZf_DodgeRangedEngaging(GlobalContext* globalCtx, EnZf* this); -s32 EnZf_DodgeRangedWaiting(GlobalContext* globalCtx, EnZf* this); - -#define PLATFORM_INDEX_DOWNSTAIRS_MIN 0 -#define PLATFORM_INDEX_DOWNSTAIRS_INNER_MAX 5 -#define PLATFORM_INDEX_DOWNSTAIRS_MAX 7 -#define PLATFORM_INDEX_UPSTAIRS_MIN (PLATFORM_INDEX_DOWNSTAIRS_MAX + 1) -#define PLATFORM_INDEX_UPSTAIRS_INNER_MAX 15 - -/** - * Array of platform positions in Dodongo's Cavern miniboss room. - * 0 - 7 : Downstairs - * 8 - 15 : Upstairs inner platforms - * 16 - 23 : Upstairs outer platforms (including several points on the long thin one) - */ -static Vec3f sPlatformPositions[] = { - // Downstairs - { 3560.0f, 100.0f, -1517.0f }, - { 3170.0f, 100.0f, -1767.0f }, - { 3165.0f, 100.0f, -2217.0f }, - { 3563.0f, 100.0f, -2437.0f }, - { 3946.0f, 100.0f, -2217.0f }, - { 3942.0f, 100.0f, -1765.0f }, - // Westmost downstairs two - { 2861.0f, 100.0f, -2394.0f }, - { 2776.0f, 100.0f, -1987.0f }, - - // Upstairs inner - { 4527.0f, 531.0f, -1146.0f }, - { 4442.0f, 531.0f, -1405.0f }, - { 4170.0f, 531.0f, -1395.0f }, - { 4030.0f, 531.0f, -1162.0f }, - { 4010.0f, 531.0f, -883.0f }, - { 4270.0f, 531.0f, -810.0f }, - { 4520.0f, 531.0f, -880.0f }, - { 4260.0f, 531.0f, -1035.0f }, - - // Upstairs outer - { 4757.0f, 531.0f, -1146.0f }, - { 3850.0f, 531.0f, -883.0f }, - { 4380.0f, 531.0f, -690.0f }, - { 4197.0f, 531.0f, -646.0f }, - { 4070.0f, 531.0f, -1575.0f }, - { 3930.0f, 531.0f, -1705.0f }, - { 3780.0f, 531.0f, -1835.0f }, - { 3560.0f, 531.0f, -1985.0f }, -}; - -// These seem to relate to the tagging in/out the minibosses do -static s16 D_80B4A1B0 = 0; -static s16 D_80B4A1B4 = 1; - -const ActorInit En_Zf_InitVars = { - ACTOR_EN_ZF, - ACTORCAT_ENEMY, - FLAGS, - OBJECT_ZF, - sizeof(EnZf), - (ActorFunc)EnZf_Init, - (ActorFunc)EnZf_Destroy, - (ActorFunc)EnZf_Update, - (ActorFunc)EnZf_Draw, -}; - -static ColliderCylinderInit sBodyCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -static ColliderQuadInit sSwordQuadInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK0, - { 0xFFCFFFFF, 0x00, 0x08 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -typedef enum { - /* 0x0 */ ENZF_DMGEFF_NONE, - /* 0x1 */ ENZF_DMGEFF_STUN, - /* 0x6 */ ENZF_DMGEFF_IMMUNE = 6, // Skips damage code, but also skips the top half of Update - /* 0xD */ ENZF_DMGEFF_PROJECTILE = 0xD, // Projectiles that don't have another damageeffect - /* 0xF */ ENZF_DMGEFF_ICE = 0xF -} EnZfDamageEffect; - -static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, ENZF_DMGEFF_STUN), - /* Deku stick */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Slingshot */ DMG_ENTRY(1, ENZF_DMGEFF_PROJECTILE), - /* Explosive */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Boomerang */ DMG_ENTRY(0, ENZF_DMGEFF_STUN), - /* Normal arrow */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Hammer swing */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Hookshot */ DMG_ENTRY(0, ENZF_DMGEFF_STUN), - /* Kokiri sword */ DMG_ENTRY(1, ENZF_DMGEFF_NONE), - /* Master sword */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Giant's Knife */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), - /* Fire arrow */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), - /* Ice arrow */ DMG_ENTRY(4, ENZF_DMGEFF_ICE), - /* Light arrow */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), - /* Unk arrow 1 */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), - /* Unk arrow 2 */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), - /* Unk arrow 3 */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), - /* Fire magic */ DMG_ENTRY(0, ENZF_DMGEFF_IMMUNE), - /* Ice magic */ DMG_ENTRY(3, ENZF_DMGEFF_ICE), - /* Light magic */ DMG_ENTRY(0, ENZF_DMGEFF_IMMUNE), - /* Shield */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), - /* Mirror Ray */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), - /* Kokiri spin */ DMG_ENTRY(1, ENZF_DMGEFF_NONE), - /* Giant spin */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), - /* Master spin */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Kokiri jump */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), - /* Giant jump */ DMG_ENTRY(8, ENZF_DMGEFF_NONE), - /* Master jump */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), - /* Unknown 1 */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), - /* Unblockable */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), - /* Hammer jump */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), - /* Unknown 2 */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), -}; - -static AnimationHeader* sHoppingAnims[] = { &gZfHopCrouchingAnim, &gZfHopLeapingAnim, &gZfHopLandingAnim }; - -static s32 D_80B4AB30; // Set to 0 and incremented in EnZf_HopAway, but not actually used - -void EnZf_SetupAction(EnZf* this, EnZfActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -/** - * Tests if it will still be on a floor after moving forwards a distance determined by dist, in the shape forward - * direction. If `dist` is 0, it defaults to a dist depending on speed direction, and params. - */ -s32 EnZf_PrimaryFloorCheck(EnZf* this, GlobalContext* globalCtx, f32 dist) { - s16 ret; - s16 curBgCheckFlags; - f32 sin; - f32 cos; - Vec3f curPos; - - if (dist == 0.0f) { - dist = ((this->actor.speedXZ >= 0.0f) ? 1.0f : -1.0f); - dist = ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) ? dist * 45.0f : dist * 30.0f); - } - - // Save currents to restore later - curPos = this->actor.world.pos; - curBgCheckFlags = this->actor.bgCheckFlags; - - sin = Math_SinS(this->actor.world.rot.y) * dist; - cos = Math_CosS(this->actor.world.rot.y) * dist; - - this->actor.world.pos.x += sin; - this->actor.world.pos.z += cos; - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); - this->actor.world.pos = curPos; - ret = !(this->actor.bgCheckFlags & 1); - this->actor.bgCheckFlags = curBgCheckFlags; - return ret; -} - -/** - * Supplementary floor test. - */ -s16 EnZf_SecondaryFloorCheck(EnZf* this, GlobalContext* globalCtx, f32 dist) { - s16 ret; - s16 curBgCheckFlags; - f32 sin; - f32 cos; - Vec3f curPos; - - if ((this->actor.speedXZ != 0.0f) && EnZf_PrimaryFloorCheck(this, globalCtx, this->actor.speedXZ)) { - return true; - } - - // Save currents to restore later - curPos = this->actor.world.pos; - curBgCheckFlags = this->actor.bgCheckFlags; - - sin = Math_SinS(this->actor.shape.rot.y) * dist; - cos = Math_CosS(this->actor.shape.rot.y) * dist; - - this->actor.world.pos.x += sin; - this->actor.world.pos.z += cos; - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); - this->actor.world.pos = curPos; - ret = !(this->actor.bgCheckFlags & 1); - this->actor.bgCheckFlags = curBgCheckFlags; - return ret; -} - -void EnZf_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnZf* this = (EnZf*)thisx; - Player* player = GET_PLAYER(globalCtx); - EffectBlureInit1 blureInit; - f32 posDiff; - - Actor_ProcessInitChain(thisx, sInitChain); - thisx->targetMode = 3; - this->clearFlag = (thisx->params & 0xFF00) >> 8; - /* Strip the top byte of params */ - thisx->params &= 0xFF; - - /* Return the params to their original value if they were originally negative, i.e. 0xFFFF or 0xFFFE */ - if (thisx->params & 0x80) { - thisx->params |= 0xFF00; - } - - ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawFeet, 90.0f); - this->unk_3E0 = 0; - thisx->colChkInfo.mass = MASS_HEAVY; - thisx->colChkInfo.damageTable = &sDamageTable; - - blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = - blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = - blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = blureInit.p2EndColor[1] = - blureInit.p2EndColor[2] = 255; - blureInit.p2StartColor[3] = 64; - blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; - blureInit.elemDuration = 8; - blureInit.unkFlag = 0; - blureInit.calcMode = 2; - - Effect_Add(globalCtx, &this->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); - - Actor_UpdateBgCheckInfo(globalCtx, thisx, 75.0f, 45.0f, 45.0f, 0x1D); - - this->alpha = 255; - thisx->colChkInfo.cylRadius = 40; - thisx->colChkInfo.cylHeight = 100; - Collider_InitCylinder(globalCtx, &this->bodyCollider); - Collider_SetCylinder(globalCtx, &this->bodyCollider, thisx, &sBodyCylinderInit); - Collider_InitQuad(globalCtx, &this->swordCollider); - Collider_SetQuad(globalCtx, &this->swordCollider, thisx, &sSwordQuadInit); - - if (thisx->params == ENZF_TYPE_DINOLFOS) { - thisx->colChkInfo.health = 12; - thisx->naviEnemyId = 0x10; - SkelAnime_Init(globalCtx, &this->skelAnime, &gZfDinolfosSkel, &gZfCryingAnim, this->jointTable, - this->morphTable, ENZF_LIMB_MAX); - } else { // Lizalfos - thisx->colChkInfo.health = 6; - thisx->naviEnemyId = 0x0F; - SkelAnime_Init(globalCtx, &this->skelAnime, &gZfLizalfosSkel, &gZfCryingAnim, this->jointTable, - this->morphTable, ENZF_LIMB_MAX); - } - - if (thisx->params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // Not minibosses - this->homePlatform = this->curPlatform = -1; - D_80B4A1B4 = -1; - this->hopAnimIndex = 1; - if (thisx->params == ENZF_TYPE_LIZALFOS_LONE) { - EnZf_SetupDropIn(this); - } else { // Dinolfos - func_80B45384(this); - } - } else { // Minibosses - posDiff = player->actor.world.pos.y - thisx->world.pos.y; - - if ((ABS(posDiff) <= 100.0f) && !Flags_GetSwitch(globalCtx, this->clearFlag)) { - this->homePlatform = this->curPlatform = EnZf_FindPlatform(&thisx->world.pos, 0); - EnZf_SetupDropIn(this); - D_80B4A1B4 = 1; - } else { - Actor_Kill(thisx); - } - } -} - -void EnZf_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnZf* this = (EnZf*)thisx; - - if ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ && - (Actor_FindNearby(globalCtx, &this->actor, ACTOR_EN_ZF, ACTORCAT_ENEMY, 10000.0f) == NULL)) { - func_800F5B58(); - } - - Effect_Delete(globalCtx, this->blureIndex); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); - Collider_DestroyQuad(globalCtx, &this->swordCollider); -} - -/** - * Finds the index of the platform position in `sPlatformPositions` that is sufficiently close to `pos`. - * Returns `preferedIndex` if the associated position is close enough. - */ -s16 EnZf_FindPlatform(Vec3f* pos, s16 preferredIndex) { - f32 rangeXZ; - s16 i; - - rangeXZ = 210.0f; - - // Upstairs has a smaller range - if (pos->y >= 420.0f) { - rangeXZ = 110.0f; - } - - if (preferredIndex != -1) { - i = preferredIndex; - if (((sPlatformPositions[i].y - 150.0f) <= pos->y) && (pos->y <= (sPlatformPositions[i].y + 150.0f)) && - ((sPlatformPositions[i].x - rangeXZ) <= pos->x) && (pos->x <= (sPlatformPositions[i].x + rangeXZ)) && - ((sPlatformPositions[i].z - rangeXZ) <= pos->z) && (pos->z <= (sPlatformPositions[i].z + rangeXZ))) { - return preferredIndex; - } - } - - for (i = ARRAY_COUNT(sPlatformPositions) - 1; i > -1; i--) { - if (((sPlatformPositions[i].y - 150.0f) <= pos->y) && (pos->y <= (sPlatformPositions[i].y + 150.0f)) && - ((sPlatformPositions[i].x - rangeXZ) <= pos->x) && (pos->x <= (sPlatformPositions[i].x + rangeXZ)) && - ((sPlatformPositions[i].z - rangeXZ) <= pos->z) && (pos->z <= (sPlatformPositions[i].z + rangeXZ))) { - break; - } - } - return i; -} - -s16 EnZf_FindNextPlatformAwayFromPlayer(Vec3f* pos, s16 curPlatform, s16 arg2, GlobalContext* globalCtx) { - f32 distToCurLoopPlatform; - f32 platformMinDist = 585.0f; - Player* player = GET_PLAYER(globalCtx); - s16 initialPlatform = curPlatform; - f32 playerMaxDist = 400.0f; - f32 smallMaxRange = 99998.0f; - s16 curLoopPlatform = PLATFORM_INDEX_DOWNSTAIRS_INNER_MAX; // Will never retreat to the last two - s16 minIndex = PLATFORM_INDEX_DOWNSTAIRS_MIN; - f32 largeMaxRange = 99999.0f; - s16 altNextPlatform = -1; - s16 nextPlatform = -1; - s16 playerPlatform = EnZf_FindPlatform(&player->actor.world.pos, initialPlatform); - - // Set up search constraints - // Upstairs - if (pos->y > 420.0f) { - minIndex = PLATFORM_INDEX_UPSTAIRS_MIN; - playerMaxDist = 50.0f; - - // Upstairs outer - if (initialPlatform >= PLATFORM_INDEX_UPSTAIRS_INNER_MAX) { - curLoopPlatform = ARRAY_COUNT(sPlatformPositions) - 1; - platformMinDist = 400.0f; - } else { // upstairs inner - curLoopPlatform = PLATFORM_INDEX_UPSTAIRS_INNER_MAX - 1; - platformMinDist = 380.0f; - } - } - - for (; curLoopPlatform >= minIndex; curLoopPlatform--) { - if ((curLoopPlatform == initialPlatform) || (curLoopPlatform == playerPlatform)) { - continue; - } - if ((playerPlatform == -1) && - (Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[curLoopPlatform]) < playerMaxDist)) { - continue; - } - distToCurLoopPlatform = Math_Vec3f_DistXYZ(pos, &sPlatformPositions[curLoopPlatform]); - - if (platformMinDist < distToCurLoopPlatform) { - continue; - } - if (distToCurLoopPlatform < smallMaxRange) { - largeMaxRange = smallMaxRange; - altNextPlatform = nextPlatform; - smallMaxRange = distToCurLoopPlatform; - nextPlatform = curLoopPlatform; - } else if (distToCurLoopPlatform < largeMaxRange) { - largeMaxRange = distToCurLoopPlatform; - altNextPlatform = curLoopPlatform; - } - } - - // These functions have no side effects, so these two calls do nothing - Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[nextPlatform]); - Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[altNextPlatform]); - - if (altNextPlatform > 0) { - s16 nextPlatformToPlayerYaw = - Math_Vec3f_Yaw(pos, &sPlatformPositions[nextPlatform]) - Math_Vec3f_Yaw(pos, &player->actor.world.pos); - - if (ABS(nextPlatformToPlayerYaw) < 0x36B0) { - nextPlatform = altNextPlatform; - } - } - - if (nextPlatform < 0) { - nextPlatform = arg2; - } - return nextPlatform; -} - -s16 EnZf_FindNextPlatformTowardsPlayer(Vec3f* pos, s16 curPlatform, s16 arg2, GlobalContext* globalCtx) { - s16 curLoopPlatform = PLATFORM_INDEX_DOWNSTAIRS_MAX; - s16 minIndex = PLATFORM_INDEX_DOWNSTAIRS_MIN; - Player* player = GET_PLAYER(globalCtx); - s16 nextPlatform = EnZf_FindPlatform(&player->actor.world.pos, -1); - f32 minRange = 500.0f; - f32 smallMaxRange = 99998.0f; - f32 largeMaxRange = 99999.0f; - s16 phi_s2 = curPlatform; - s16 phi_s3 = arg2; - - // Upstairs - if (pos->y > 200.0f) { - curLoopPlatform = ARRAY_COUNT(sPlatformPositions) - 1; - minIndex = PLATFORM_INDEX_UPSTAIRS_MIN; - minRange = 290.0f; - } - - for (; curLoopPlatform >= minIndex; curLoopPlatform--) { - if (minRange < Math_Vec3f_DistXYZ(pos, &sPlatformPositions[curLoopPlatform])) { - continue; - } - if (curLoopPlatform != nextPlatform) { - f32 curPlatformDistToPlayer = - Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[curLoopPlatform]); - - if (curPlatformDistToPlayer < smallMaxRange) { - largeMaxRange = smallMaxRange; - phi_s3 = phi_s2; - smallMaxRange = curPlatformDistToPlayer; - phi_s2 = curLoopPlatform; - } else if (curPlatformDistToPlayer < largeMaxRange) { - largeMaxRange = curPlatformDistToPlayer; - phi_s3 = curLoopPlatform; - } - } else { - phi_s2 = nextPlatform; - break; - } - } - - if (phi_s3 != nextPlatform) { - nextPlatform = phi_s2; - } else { - nextPlatform = phi_s3; - } - - return nextPlatform; -} - -// Player not targeting this or another EnZf? -s32 EnZf_CanAttack(GlobalContext* globalCtx, EnZf* this) { - Actor* targetedActor; - Player* player = GET_PLAYER(globalCtx); - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - if (player->stateFlags1 & 0x6000) { // Hanging or climbing - return false; - } else { - return true; - } - } else { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor)) { - return true; - } - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - targetedActor = player->unk_664; - if (targetedActor == NULL) { - return false; - } else { - if (targetedActor->category != ACTORCAT_ENEMY) { - return true; - } - if (targetedActor->id != ACTOR_EN_ZF) { - return false; - } else if (targetedActor->colorFilterTimer != 0) { - return true; - } - } - } - } - return false; -} - -void func_80B44DC4(EnZf* this, GlobalContext* globalCtx) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (angleDiff < 0) { - angleDiff = -angleDiff; - } - - if (angleDiff >= 0x1B58) { - func_80B483E4(this, globalCtx); - } else if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 8) != 0) && - EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else { - func_80B45384(this); - } -} - -s32 EnZf_ChooseAction(GlobalContext* globalCtx, EnZf* this) { - s16 angleToWall; - Actor* explosive; - - angleToWall = this->actor.wallYaw - this->actor.shape.rot.y; - angleToWall = ABS(angleToWall); - - if (func_800354B4(globalCtx, &this->actor, 100.0f, 0x5DC0, 0x2AA8, this->actor.shape.rot.y)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if ((this->actor.bgCheckFlags & 8) && (ABS(angleToWall) < 0x2EE0) && (this->actor.xzDistToPlayer < 80.0f)) { - EnZf_SetupJumpUp(this); - return true; - } else if ((this->actor.xzDistToPlayer < 90.0f) && ((globalCtx->gameplayFrames % 2) != 0)) { - EnZf_SetupJumpUp(this); - return true; - } else { - EnZf_SetupJumpBack(this); - return true; - } - } - - explosive = Actor_FindNearby(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVE, 80.0f); - - if (explosive != NULL) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (((this->actor.bgCheckFlags & 8) && (angleToWall < 0x2EE0)) || (explosive->id == ACTOR_EN_BOM_CHU)) { - if ((explosive->id == ACTOR_EN_BOM_CHU) && (Actor_WorldDistXYZToActor(&this->actor, explosive) < 80.0f) && - ((s16)((this->actor.shape.rot.y - explosive->world.rot.y) + 0x8000) < 0x3E80)) { - EnZf_SetupJumpUp(this); - return true; - } else { - EnZf_SetupCircleAroundPlayer(this, 4.0f); - return true; - } - } else { - EnZf_SetupJumpBack(this); - return true; - } - } - return false; -} - -// Setup functions and action functions - -/** - * Set position 300 units above ground and invisible, fade in and drop to ground, fully solid when on ground - */ -void EnZf_SetupDropIn(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfJumpingAnim, 0.0f, 9.0f, Animation_GetLastFrame(&gZfJumpingAnim), - ANIMMODE_LOOP, 0.0f); - - this->actor.world.pos.y = this->actor.floorHeight + 300.0f; - this->alpha = this->actor.shape.shadowAlpha = 0; - this->unk_3F0 = 10; - this->hopAnimIndex = 1; - this->action = ENZF_ACTION_DROP_IN; - this->actor.bgCheckFlags &= ~2; - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - EnZf_SetupAction(this, EnZf_DropIn); -} - -void EnZf_DropIn(EnZf* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - this->actor.flags |= ACTOR_FLAG_0; - - if (this->actor.params == ENZF_TYPE_LIZALFOS_MINIBOSS_A) { - func_800F5ACC(0x38); // Miniboss theme - } - } - - if (this->unk_3F0 != 0) { - if (this->actor.params != ENZF_TYPE_LIZALFOS_LONE) { - this->unk_3F0--; - } else if (this->actor.xzDistToPlayer <= 160.0f) { - this->unk_3F0 = 0; - this->actor.flags |= ACTOR_FLAG_0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - - this->actor.world.pos.y = this->actor.floorHeight + 300.0f; - } else if (this->alpha < 255) { - this->alpha += 255 / 5; - } - - if ((this->actor.bgCheckFlags & 3) && (this->hopAnimIndex != 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ONGND); - Animation_Change(&this->skelAnime, &gZfLandingAnim, 1.0f, 0.0f, 17.0f, ANIMMODE_ONCE, 0.0f); - this->hopAnimIndex = 0; - this->actor.bgCheckFlags &= ~2; - this->actor.world.pos.y = this->actor.floorHeight; - this->actor.velocity.y = 0.0f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - } - - if (SkelAnime_Update(&this->skelAnime)) { - this->alpha = 255; - if (this->actor.params > ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // Only miniboss B - EnZf_SetupSheatheSword(this, globalCtx); - } else { - func_80B45384(this); - } - } - this->actor.shape.shadowAlpha = this->alpha; -} - -// stop? and choose an action -void func_80B45384(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfCryingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZfCryingAnim), - ANIMMODE_LOOP_INTERP, -4.0f); - this->action = ENZF_ACTION_3; - this->unk_3F0 = Rand_ZeroOne() * 10.0f + 5.0f; - this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y; - EnZf_SetupAction(this, func_80B4543C); -} - -void func_80B4543C(EnZf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - s16 angleToPlayer = (this->actor.yawTowardsPlayer - this->headRot) - this->actor.shape.rot.y; - - angleToPlayer = ABS(angleToPlayer); - SkelAnime_Update(&this->skelAnime); - - if (!EnZf_DodgeRangedEngaging(globalCtx, this)) { - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - if (this->unk_3F4 != 0) { - this->unk_3F4--; - if (angleToPlayer >= 0x1FFE) { - return; - } - this->unk_3F4 = 0; - - } else if (EnZf_ChooseAction(globalCtx, this)) { - return; - } - } - angleToPlayer = player->actor.shape.rot.y - this->actor.shape.rot.y; - angleToPlayer = ABS(angleToPlayer); - - if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && (angleToPlayer >= 0x1F40)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_80B483E4(this, globalCtx); - } else if (this->unk_3F0 != 0) { - this->unk_3F0--; - } else { - if (Actor_IsFacingPlayer(&this->actor, 30 * 0x10000 / 360)) { - if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.xzDistToPlayer > 100.0f) && - (Rand_ZeroOne() < 0.3f)) { - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - EnZf_SetupJumpForward(this); - } else { - func_80B483E4(this, globalCtx); - } - } else if (Rand_ZeroOne() > 0.3f) { - EnZf_SetupApproachPlayer(this, globalCtx); - } else { - func_80B483E4(this, globalCtx); - } - } else { - func_80B4604C(this); - } - - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - } - } -} - -void EnZf_SetupApproachPlayer(EnZf* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &gZfWalkingAnim, -4.0f); - this->action = ENZF_ACTION_APPROACH_PLAYER; - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - this->nextPlatform = EnZf_FindNextPlatformTowardsPlayer(&this->actor.world.pos, this->curPlatform, - this->homePlatform, globalCtx); - this->hopAnimIndex = 0; - } - this->actor.speedXZ = 0.0f; - EnZf_SetupAction(this, EnZf_ApproachPlayer); -} - -void EnZf_ApproachPlayer(EnZf* this, GlobalContext* globalCtx) { - s32 sp54; - s32 sp50; - s32 temp; - s16 temp_v1; - s16 sp48 = -1; - f32 sp44 = 350.0f; - f32 sp40 = 0.0f; - Player* player = GET_PLAYER(globalCtx); - s32 sp30; - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - sp48 = EnZf_FindPlatform(&player->actor.world.pos, sp48); - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, sp48); - - if (this->actor.world.pos.y >= 420.0f) { - sp44 = 270.0f; - } - } - - if (!EnZf_DodgeRangedEngaging(globalCtx, this)) { - if (sp48 != this->curPlatform) { - this->nextPlatform = EnZf_FindNextPlatformTowardsPlayer(&this->actor.world.pos, this->curPlatform, - this->homePlatform, globalCtx); - - if ((sp48 < 0) && (this->nextPlatform == this->curPlatform)) { - sp48 = this->curPlatform; - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - } else { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer = - Actor_WorldYawTowardPoint(&this->actor, &sPlatformPositions[this->nextPlatform]); - - temp_v1 = this->actor.wallYaw - this->actor.shape.rot.y; - temp_v1 = ABS(temp_v1); - - if ((this->unk_3F8 && (this->actor.speedXZ > 0.0f)) || - ((this->actor.bgCheckFlags & 8) && (temp_v1 >= 0x5C19))) { - if ((Actor_WorldDistXZToPoint(&this->actor, &sPlatformPositions[this->nextPlatform]) < sp44) && - !EnZf_PrimaryFloorCheck(this, globalCtx, 191.9956f)) { - EnZf_SetupJumpForward(this); - - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y = 20.0f; - } - - return; - } else { - this->actor.world.rot.y = - Actor_WorldYawTowardPoint(&this->actor, &sPlatformPositions[this->curPlatform]); - } - } else { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToF(&this->actor.speedXZ, 8.0f, 1.0f, 1.5f, 0.0f); - } - } - } - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - sp40 = 100.0f; - } - - if (this->actor.xzDistToPlayer <= (70.0f + sp40)) { - Math_SmoothStepToF(&this->actor.speedXZ, -8.0f, 1.0f, 0.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->actor.speedXZ, 8.0f, 1.0f, 0.5f, 0.0f); - } - - this->skelAnime.playSpeed = this->actor.speedXZ * 1.2f; - - temp_v1 = player->actor.shape.rot.y - this->actor.shape.rot.y; - temp_v1 = ABS(temp_v1); - - if ((sp48 == this->curPlatform) && (this->actor.xzDistToPlayer < 150.0f) && (player->swordState != 0) && - (temp_v1 >= 0x1F40)) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (Rand_ZeroOne() > 0.7f) { - func_80B483E4(this, globalCtx); - return; - } - } - - sp54 = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - sp50 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - sp30 = (f32)ABS(this->skelAnime.playSpeed); - - if (sp48 == this->curPlatform) { - if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { - if (Rand_ZeroOne() > 0.5f) { - func_80B462E4(this, globalCtx); - } else { - func_80B45384(this); - } - } else if (this->actor.xzDistToPlayer < 100.0f) { - if ((Rand_ZeroOne() > 0.05f) && EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else if (Rand_ZeroOne() > 0.5f) { - func_80B483E4(this, globalCtx); - } else { - func_80B45384(this); - } - } else { - if (this->unk_3F8) { - func_80B462E4(this, globalCtx); - } else if (Rand_ZeroOne() < 0.1f) { - func_80B45384(this); - } - } - } - - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - if (EnZf_ChooseAction(globalCtx, this)) { - return; - } - - if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.xzDistToPlayer > 160.0f) && - Actor_IsFacingPlayer(&this->actor, 0x71C)) { - if (Actor_IsTargeted(globalCtx, &this->actor)) { - if (Rand_ZeroOne() < 0.1f) { - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - EnZf_SetupJumpForward(this); - return; - } - } else { - func_80B483E4(this, globalCtx); - return; - } - } - } - - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - - if (sp54 != (s32)this->skelAnime.curFrame) { - temp = sp30 + sp54; - - if (((sp50 < 2) && (temp >= 4)) || ((sp50 < 32) && (temp >= 34))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); - } - } - } -} - -void EnZf_SetupJumpForward(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfJumpingAnim, 1.0f, 0.0f, 3.0f, ANIMMODE_ONCE, -3.0f); - this->unk_3F0 = 0; - this->hopAnimIndex = 1; - this->actor.velocity.y = 15.0f; - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - this->actor.speedXZ = 16.0f; - } else { - this->actor.speedXZ = 10.0f; - } - - this->action = ENZF_ACTION_JUMP_FORWARD; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); - EnZf_SetupAction(this, EnZf_JumpForward); -} - -void EnZf_JumpForward(EnZf* this, GlobalContext* globalCtx) { - if ((this->unk_3F0 != 0) && (this->actor.world.pos.y <= this->actor.floorHeight)) { - this->actor.world.pos.y = this->actor.floorHeight; - this->hopAnimIndex = 0; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_3F0 == 0) { - Animation_Change(&this->skelAnime, &gZfLandingAnim, 3.0f, 0.0f, 17.0f, ANIMMODE_ONCE, -3.0f); - this->unk_3F0 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); - } else { - this->actor.speedXZ = 0.0f; - this->hopAnimIndex = 0; - EnZf_SetupApproachPlayer(this, globalCtx); - } - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - - if ((this->actor.params == ENZF_TYPE_DINOLFOS) && (this->actor.bgCheckFlags & 3)) { - if (EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else { - func_80B483E4(this, globalCtx); - } - } -} - -void func_80B4604C(EnZf* this) { - Animation_MorphToLoop(&this->skelAnime, &gZfWalkingAnim, -4.0f); - this->action = ENZF_ACTION_6; - EnZf_SetupAction(this, func_80B46098); -} - -void func_80B46098(EnZf* this, GlobalContext* globalCtx) { - s32 pad; - f32 phi_f2; - Player* player = GET_PLAYER(globalCtx); - s16 temp_v0; - s16 phi_v1; - - if (!EnZf_DodgeRangedEngaging(globalCtx, this)) { - if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) { - temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (temp_v0 > 0) { - phi_v1 = temp_v0 * 0.25f + 2000.0f; - } else { - phi_v1 = temp_v0 * 0.25f - 2000.0f; - } - - this->actor.shape.rot.y += phi_v1; - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (temp_v0 > 0) { - phi_f2 = phi_v1 * 1.5f; - if (phi_f2 > 2.0f) { - phi_f2 = 2.0f; - } - } else { - phi_f2 = phi_v1 * 1.5f; - if (phi_f2 < -2.0f) { - phi_f2 = -2.0f; - } - } - - this->skelAnime.playSpeed = -phi_f2; - SkelAnime_Update(&this->skelAnime); - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - if (this->curPlatform != EnZf_FindPlatform(&player->actor.world.pos, -1)) { - EnZf_SetupApproachPlayer(this, globalCtx); - return; - } - } - - if (Actor_IsFacingPlayer(&this->actor, 30 * 0x10000 / 360)) { - if (Rand_ZeroOne() > 0.8f) { - func_80B462E4(this, globalCtx); - } else { - EnZf_SetupApproachPlayer(this, globalCtx); - } - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - } - } -} - -// Conditional setup function -void func_80B462E4(EnZf* this, GlobalContext* globalCtx) { - if ((this->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ || - Actor_TestFloorInDirection(&this->actor, globalCtx, 40.0f, (s16)(this->actor.shape.rot.y + 0x3FFF)) || - Actor_TestFloorInDirection(&this->actor, globalCtx, -40.0f, (s16)(this->actor.shape.rot.y + 0x3FFF))) { - Animation_PlayLoop(&this->skelAnime, &gZfSidesteppingAnim); - this->actor.speedXZ = Rand_CenteredFloat(12.0f); - this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_3F0 = Rand_ZeroOne() * 10.0f + 20.0f; - this->hopAnimIndex = 0; - this->action = ENZF_ACTION_7; - this->unk_408 = 0.0f; - EnZf_SetupAction(this, func_80B463E4); - } else { - EnZf_SetupApproachPlayer(this, globalCtx); - } -} - -void func_80B463E4(EnZf* this, GlobalContext* globalCtx) { - s16 angleBehindPlayer; - s16 phi_v0_3; - s32 pad; - s32 curKeyFrame; - s32 prevKeyFrame; - s32 playSpeed; - Player* player = GET_PLAYER(globalCtx); - f32 baseRange = 0.0f; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4000, 1); - - if (!EnZf_DodgeRangedEngaging(globalCtx, this) && - ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this))) { - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3A98; - angleBehindPlayer = player->actor.shape.rot.y + 0x8000; - - if (Math_SinS(angleBehindPlayer - this->actor.shape.rot.y) >= 0.0f) { - this->actor.speedXZ -= 0.25f; - if (this->actor.speedXZ < -8.0f) { - this->actor.speedXZ = -8.0f; - } - } else if (Math_SinS(angleBehindPlayer - this->actor.shape.rot.y) < 0.0f) { // Superfluous check - this->actor.speedXZ += 0.25f; - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ = 8.0f; - } - } - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - if (this->unk_3F8) { - this->actor.speedXZ = -this->actor.speedXZ; - } - } else if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, - this->actor.shape.rot.y + 0x3FFF)) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - phi_v0_3 = this->actor.shape.rot.y + 0x3FFF; - } else { - phi_v0_3 = this->actor.shape.rot.y - 0x3FFF; - } - phi_v0_3 = this->actor.wallYaw - phi_v0_3; - } else { - this->actor.speedXZ *= -0.8f; - phi_v0_3 = 0; - } - - if (ABS(phi_v0_3) > 0x4000) { - this->actor.speedXZ *= -0.8f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ += 0.5f; - } - } - } - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - baseRange = 100.0f; - } - - if (this->actor.xzDistToPlayer <= (70.0f + baseRange)) { - Math_SmoothStepToF(&this->unk_408, -4.0f, 1.0f, 1.5f, 0.0f); - } else if ((90.0f + baseRange) < this->actor.xzDistToPlayer) { - Math_SmoothStepToF(&this->unk_408, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_408, 0.0f, 1.0f, 5.65f, 0.0f); - } - - if ((this->unk_408 != 0.0f) && !EnZf_SecondaryFloorCheck(this, globalCtx, this->unk_408)) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->unk_408; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->unk_408; - } - - if (ABS(this->actor.speedXZ) >= ABS(this->unk_408)) { - this->skelAnime.playSpeed = this->actor.speedXZ * 0.75f; - } else if (this->skelAnime.playSpeed < 0.0f) { - this->skelAnime.playSpeed = this->unk_408 * -0.75f; - } else { - this->skelAnime.playSpeed = this->unk_408 * 0.75f; - } - - curKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); - - if (curKeyFrame != (s32)this->skelAnime.curFrame) { - s32 nextKeyFrame = playSpeed + curKeyFrame; - - if (((prevKeyFrame < 14) && (nextKeyFrame > 15)) || ((prevKeyFrame < 27) && (nextKeyFrame > 28))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); - } - } - - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - - if ((Math_CosS(angleBehindPlayer - this->actor.shape.rot.y) < -0.85f) || (this->unk_3F0 == 0)) { - this->actor.world.rot.y = this->actor.shape.rot.y; - - if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0) && - EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else { - func_80B45384(this); - } - } else if (this->unk_3F0 != 0) { - this->unk_3F0--; - } - } -} - -void EnZf_SetupSlash(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfSlashAnim, 1.25f, 0.0f, Animation_GetLastFrame(&gZfSlashAnim), ANIMMODE_ONCE, - -4.0f); - - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - this->skelAnime.playSpeed = 1.75f; - } - - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - this->action = ENZF_ACTION_SLASH; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - this->actor.speedXZ = 0.0f; - EnZf_SetupAction(this, EnZf_Slash); -} - -void EnZf_Slash(EnZf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 rotDiff; - s16 yawDiff; - - this->actor.speedXZ = 0.0f; - - if ((s32)this->skelAnime.curFrame == 10) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); - } - - if (SkelAnime_Update(&this->skelAnime)) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIndex)); - - if ((this->actor.params == ENZF_TYPE_DINOLFOS) && !Actor_IsFacingPlayer(&this->actor, 5460)) { - func_80B45384(this); - this->unk_3F0 = Rand_ZeroOne() * 5.0f + 5.0f; - this->unk_3F4 = Rand_ZeroOne() * 20.0f + 100.0f; - } else if ((Rand_ZeroOne() > 0.7f) || (this->actor.xzDistToPlayer >= 120.0f)) { - func_80B45384(this); - this->unk_3F0 = Rand_ZeroOne() * 5.0f + 5.0f; - } else { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - - if (Rand_ZeroOne() > 0.7f) { - func_80B483E4(this, globalCtx); - } else { - rotDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; - rotDiff = ABS(rotDiff); - - if (rotDiff <= 10000) { - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - yawDiff = ABS(yawDiff); - - if (yawDiff > 16000) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_80B483E4(this, globalCtx); - } else if (player->stateFlags1 & 0x6010) { - if (this->actor.isTargeted) { - EnZf_SetupSlash(this); - } else { - func_80B483E4(this, globalCtx); - } - } else { - EnZf_SetupSlash(this); - } - } else { - func_80B483E4(this, globalCtx); - } - } - } - } -} - -void EnZf_SetupRecoilFromBlockedSlash(EnZf* this) { - f32 frame = this->skelAnime.curFrame - 3.0f; - - Animation_Change(&this->skelAnime, &gZfSlashAnim, -1.0f, frame, 0.0f, ANIMMODE_ONCE, 0.0f); - this->action = ENZF_ACTION_RECOIL_FROM_BLOCKED_SLASH; - EnZf_SetupAction(this, EnZf_RecoilFromBlockedSlash); -} - -void EnZf_RecoilFromBlockedSlash(EnZf* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime)) { - if (Rand_ZeroOne() > 0.7f) { - func_80B45384(this); - } else if ((Rand_ZeroOne() > 0.2f) && EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else { - func_80B483E4(this, globalCtx); - } - } -} - -void EnZf_SetupJumpBack(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfJumpingAnim, -1.0f, 3.0f, 0.0f, ANIMMODE_ONCE, -3.0f); - this->unk_3F0 = 0; - this->hopAnimIndex = 1; - this->action = ENZF_ACTION_JUMP_BACK; - this->actor.velocity.y = 15.0f; - this->actor.speedXZ = -15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); - EnZf_SetupAction(this, EnZf_JumpBack); -} - -void EnZf_JumpBack(EnZf* this, GlobalContext* globalCtx) { - if ((this->unk_3F0 != 0) && (this->actor.world.pos.y <= this->actor.floorHeight)) { - this->actor.world.pos.y = this->actor.floorHeight; - this->hopAnimIndex = 0; - this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_3F0 == 0) { - Animation_Change(&this->skelAnime, &gZfLandingAnim, 3.0f, 0.0f, 17.0f, ANIMMODE_ONCE, -3.0f); - this->unk_3F0 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); - } else if ((globalCtx->gameplayFrames % 2) != 0) { - func_80B483E4(this, globalCtx); - } else { - func_80B45384(this); - } - } - - if ((globalCtx->state.frames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } -} - -void EnZf_SetupStunned(EnZf* this) { - if ((this->actor.bgCheckFlags & 1) && ((this->actor.velocity.y == 0.0f) || (this->actor.velocity.y == -4.0f))) { - this->actor.speedXZ = 0.0f; - this->hopAnimIndex = 0; - } else { - this->hopAnimIndex = 1; - } - - if (this->damageEffect == ENZF_DMGEFF_ICE) { - this->iceTimer = 36; - } else { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gZfKnockedBackAnim, 0.0f); - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->action = ENZF_ACTION_STUNNED; - EnZf_SetupAction(this, EnZf_Stunned); -} - -void EnZf_Stunned(EnZf* this, GlobalContext* globalCtx) { - s16 angleToWall; - - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - this->hopAnimIndex = 0; - } - - if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { - if (this->actor.colChkInfo.health == 0) { - EnZf_SetupDie(this); - } else if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) { - if (D_80B4A1B4 != -1) { - func_80B44DC4(this, globalCtx); - } else { - angleToWall = this->actor.wallYaw - this->actor.shape.rot.y; - angleToWall = ABS(angleToWall); - - if ((this->actor.params == ENZF_TYPE_DINOLFOS) && (this->actor.bgCheckFlags & 8) && - (ABS(angleToWall) < 0x2EE0) && (this->actor.xzDistToPlayer < 90.0f)) { - this->actor.world.rot.y = this->actor.shape.rot.y; - EnZf_SetupJumpUp(this); - } else if (!EnZf_DodgeRangedEngaging(globalCtx, this)) { - if (this->actor.params != ENZF_TYPE_DINOLFOS) { - func_80B44DC4(this, globalCtx); - } else if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) != 0) && - EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else { - func_80B44DC4(this, globalCtx); - } - } - } - } - } -} - -void EnZf_SetupSheatheSword(EnZf* this, GlobalContext* globalCtx) { - f32 morphFrames = 0.0f; - f32 lastFrame = Animation_GetLastFrame(&gZfSheathingSwordAnim); - - if (this->action <= ENZF_ACTION_DAMAGED) { - morphFrames = -4.0f; - } - - Animation_Change(&this->skelAnime, &gZfSheathingSwordAnim, 2.0f, 0.0f, lastFrame, ANIMMODE_ONCE, morphFrames); - this->action = ENZF_ACTION_SHEATHE_SWORD; - this->actor.speedXZ = 0.0f; - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - this->nextPlatform = - EnZf_FindNextPlatformAwayFromPlayer(&this->actor.world.pos, this->curPlatform, this->homePlatform, globalCtx); - this->actor.world.rot.y = this->actor.shape.rot.y; - EnZf_SetupAction(this, EnZf_SheatheSword); -} - -void EnZf_SheatheSword(EnZf* this, GlobalContext* globalCtx) { - s16 yaw = Actor_WorldYawTowardPoint(&this->actor, &sPlatformPositions[this->nextPlatform]) + 0x8000; - - Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 1, 1000, 0); - this->actor.shape.rot.y = this->actor.world.rot.y; - - if (SkelAnime_Update(&this->skelAnime)) { - this->actor.world.rot.y = yaw - 0x8000; - EnZf_SetupHopAway(this, globalCtx); - this->swordSheathed = true; - } -} - -void EnZf_SetupHopAndTaunt(EnZf* this) { - this->hopAnimIndex = 0; - Animation_MorphToPlayOnce(&this->skelAnime, sHoppingAnims[0], -4.0f); - this->action = ENZF_ACTION_HOP_AND_TAUNT; - this->actor.speedXZ = 0.0f; - this->unk_40C = 0.0f; - this->unk_408 = 0.0f; - EnZf_SetupAction(this, EnZf_HopAndTaunt); -} - -void EnZf_HopAndTaunt(EnZf* this, GlobalContext* globalCtx) { - f32 lastFrame; - f32 maxDist = 400.0f; - - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 1, 4000, 0); - - // Upstairs - if (this->actor.world.pos.y >= 420.0f) { - maxDist = 250.0f; - } - - // If player gets too close, run away - if ((this->actor.xzDistToPlayer < maxDist) && (this->hopAnimIndex != 1)) { - this->actor.shape.rot.y = this->actor.world.rot.y; - EnZf_SetupSheatheSword(this, globalCtx); - } else { - if (this->hopAnimIndex != 1) { - EnZf_DodgeRangedWaiting(globalCtx, this); - } - - if (SkelAnime_Update(&this->skelAnime)) { - this->hopAnimIndex++; // move on to next animation - - // Loop back to beginning - if (this->hopAnimIndex >= ARRAY_COUNT(sHoppingAnims)) { - this->hopAnimIndex = 0; - } - - if ((this->unk_408 != 0.0f) || (this->unk_40C != 0.0f)) { - this->hopAnimIndex = 1; - } - - lastFrame = Animation_GetLastFrame(sHoppingAnims[this->hopAnimIndex]); - - switch (this->hopAnimIndex) { - case 0: - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = this->actor.floorHeight; - break; - - case 1: - this->actor.velocity.y = this->unk_40C + 10.0f; - this->actor.speedXZ = this->unk_408; - this->unk_408 = 0.0f; - this->unk_40C = 0.0f; - break; - - case 2: - this->actor.world.pos.y = this->actor.floorHeight; - lastFrame = 3.0f; - break; - - default: - break; - } - - Animation_Change(&this->skelAnime, sHoppingAnims[this->hopAnimIndex], 1.5f, 0.0f, lastFrame, ANIMMODE_ONCE, - 0.0f); - } - - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - } -} - -void EnZf_SetupHopAway(EnZf* this, GlobalContext* globalCtx) { - this->hopAnimIndex = 0; - Animation_PlayOnce(&this->skelAnime, sHoppingAnims[0]); - this->action = ENZF_ACTION_HOP_AWAY; - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - this->nextPlatform = - EnZf_FindNextPlatformAwayFromPlayer(&this->actor.world.pos, this->curPlatform, this->homePlatform, globalCtx); - EnZf_SetupAction(this, EnZf_HopAway); -} - -void EnZf_HopAway(EnZf* this, GlobalContext* globalCtx) { - f32 sp74; - f32 sp70 = 1.0f; - f32 phi_f20 = 550.0f; - s32 pad; - f32 phi_f20_2; - f32 phi_f0; - s32 pad2; - s16 sp5A; - s32 sp54; - s32 temp_v1_2; - s32 phi_v1; - - sp74 = Actor_WorldDistXZToPoint(&this->actor, &sPlatformPositions[this->nextPlatform]); - sp54 = this->hopAnimIndex; - - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - - // Upstairs - if (this->actor.world.pos.y >= 420.0f) { - phi_f20 = 280.0f; - } - - sp5A = Actor_WorldYawTowardPoint(&this->actor, &sPlatformPositions[this->nextPlatform]); - - switch (this->hopAnimIndex) { - case 0: - this->actor.world.rot.y = sp5A; - this->actor.shape.rot.y = sp5A + 0x8000; - D_80B4AB30 = 0; - this->homePlatform = this->curPlatform; - temp_v1_2 = !EnZf_PrimaryFloorCheck(this, globalCtx, 107.0f); - temp_v1_2 |= !EnZf_PrimaryFloorCheck(this, globalCtx, 220.0f) << 1; - this->hopAnimIndex++; - - switch (temp_v1_2) { - case 1: - case 1 | 2: - this->actor.velocity.y = 12.0f; - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y += 8.0f; - } - - this->actor.speedXZ = 8.0f; - break; - - case 2: - this->actor.velocity.y = 15.0f; - this->actor.speedXZ = 20.0f; - break; - - default: // 0 - phi_f20_2 = 107.0f; - phi_f20_2 += 10.0f; - phi_f0 = 8.0f; - phi_f0 += 1.2f; - - for (phi_v1 = 20; phi_v1 >= 0; phi_v1--, phi_f20_2 += 10.0f, phi_f0 += 1.2f) { - - if (!EnZf_PrimaryFloorCheck(this, globalCtx, phi_f20_2)) { - this->actor.speedXZ = phi_f0; - this->actor.velocity.y = 12.0f; - break; - } - } - if (this->actor.speedXZ == 0.0f) { - EnZf_SetupHopAndTaunt(this); - } - } - break; - - case 1: - if ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ONGND); - this->actor.velocity.y = 0.0f; - this->actor.world.pos.y = this->actor.floorHeight; - this->actor.speedXZ = 0.0f; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - - if (phi_f20 <= this->actor.xzDistToPlayer) { - EnZf_SetupHopAndTaunt(this); - } else if (sp74 < 80.0f) { - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - this->nextPlatform = EnZf_FindNextPlatformAwayFromPlayer(&this->actor.world.pos, this->curPlatform, - this->homePlatform, globalCtx); - } - - this->hopAnimIndex = 0; - sp70 = 2.0f; - } else { - Math_SmoothStepToS(&this->actor.world.rot.y, sp5A, 1, 0xFA0, 0); - this->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; - D_80B4AB30++; - } - break; - - case 2: - if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - this->hopAnimIndex = 0; - } - break; - } - - if (sp54 != this->hopAnimIndex) { - Animation_PlayOnceSetSpeed(&this->skelAnime, sHoppingAnims[this->hopAnimIndex], sp70); - } - - SkelAnime_Update(&this->skelAnime); -} - -void EnZf_SetupDrawSword(EnZf* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &gZfDrawingSwordAnim); - this->actor.world.rot.y += 0x8000; - this->action = ENZF_ACTION_DRAW_SWORD; - this->actor.speedXZ = 0.0f; - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - this->nextPlatform = - EnZf_FindNextPlatformAwayFromPlayer(&this->actor.world.pos, this->curPlatform, this->homePlatform, globalCtx); - EnZf_SetupAction(this, EnZf_DrawSword); -} - -void EnZf_DrawSword(EnZf* this, GlobalContext* globalCtx) { - s16 yawTowardsPlayer = this->actor.yawTowardsPlayer; - - if (this->skelAnime.curFrame >= 26.0f) { - Math_SmoothStepToS(&this->actor.shape.rot.y, yawTowardsPlayer, 1, 6000, 0); - } - - if (SkelAnime_Update(&this->skelAnime)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - this->actor.world.rot.y = yawTowardsPlayer; - this->hopAnimIndex = -1; - func_80B45384(this); - } - - if (this->skelAnime.curFrame == 22.0f) { - this->swordSheathed = false; - } -} - -void EnZf_SetupDamaged(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfKnockedBackAnim, 1.5f, 0.0f, Animation_GetLastFrame(&gZfKnockedBackAnim), - ANIMMODE_ONCE, -4.0f); - - if ((this->actor.bgCheckFlags & 1) && ((this->actor.velocity.y == 0.0f) || (this->actor.velocity.y == -4.0f))) { - this->actor.speedXZ = -4.0f; - this->hopAnimIndex = 0; - } else { - this->hopAnimIndex = 1; - } - - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - this->skelAnime.playSpeed = 4.5f; - } - - if (this->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // not miniboss - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - } - - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DAMAGE); - this->action = ENZF_ACTION_DAMAGED; - EnZf_SetupAction(this, EnZf_Damaged); -} - -void EnZf_Damaged(EnZf* this, GlobalContext* globalCtx) { - s16 wallYawDiff; - - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } - this->hopAnimIndex = 0; - } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4500, 0); - - if (((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) && - SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { - - if (D_80B4A1B4 != -1) { - if (this->damageEffect == ENZF_DMGEFF_PROJECTILE) { - D_80B4A1B0++; - } else { - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (!EnZf_PrimaryFloorCheck(this, globalCtx, 135.0f) && (this->actor.xzDistToPlayer < 90.0f)) { - EnZf_SetupJumpUp(this); - } else if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0)) { - EnZf_SetupSlash(this); - } else { - func_80B44DC4(this, globalCtx); - } - } - } else { - - wallYawDiff = this->actor.wallYaw - this->actor.shape.rot.y; - wallYawDiff = ABS(wallYawDiff); - - if ((this->actor.params == ENZF_TYPE_DINOLFOS) && (this->actor.bgCheckFlags & 8) && - (ABS(wallYawDiff) < 12000) && (this->actor.xzDistToPlayer < 90.0f)) { - EnZf_SetupJumpUp(this); - } else if (!EnZf_DodgeRangedEngaging(globalCtx, this)) { - if (this->actor.params != ENZF_TYPE_DINOLFOS) { - this->actor.world.rot.y = this->actor.shape.rot.y; - - if (!EnZf_PrimaryFloorCheck(this, globalCtx, 135.0f) && (this->actor.xzDistToPlayer < 90.0f)) { - EnZf_SetupJumpUp(this); - } else if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0)) { - EnZf_SetupSlash(this); - } else { - func_80B44DC4(this, globalCtx); - } - } else if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0) && - EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else { - func_80B44DC4(this, globalCtx); - } - } - } - } -} - -void EnZf_SetupJumpUp(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfJumpingAnim, 1.0f, 0.0f, 3.0f, ANIMMODE_ONCE, 0.0f); - this->unk_3F0 = 0; - this->hopAnimIndex = 1; - this->action = ENZF_ACTION_JUMP_UP; - this->actor.velocity.y = 22.0f; - this->actor.speedXZ = 7.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); - this->actor.world.rot.y = this->actor.shape.rot.y; - EnZf_SetupAction(this, EnZf_JumpUp); -} - -void EnZf_JumpUp(EnZf* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4000, 1); - if (this->actor.velocity.y >= 5.0f) { - func_800355B8(globalCtx, &this->leftFootPos); - func_800355B8(globalCtx, &this->rightFootPos); - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_3F0 == 0) { - Animation_Change(&this->skelAnime, &gZfSlashAnim, 3.0f, 0.0f, 13.0f, ANIMMODE_ONCE, -4.0f); - this->unk_3F0 = 10; - } else if (this->actor.bgCheckFlags & 3) { - this->actor.velocity.y = 0.0f; - this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = 0.0f; - this->actor.world.pos.y = this->actor.floorHeight; - EnZf_SetupSlash(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); - this->skelAnime.curFrame = 13.0f; - } - } -} - -// Conditional setup function -void func_80B483E4(EnZf* this, GlobalContext* globalCtx) { - s16 playerRotY; - Player* player; - - if ((this->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* not miniboss */ || - Actor_TestFloorInDirection(&this->actor, globalCtx, 40.0f, (s16)(this->actor.shape.rot.y + 0x3FFF)) || - Actor_TestFloorInDirection(&this->actor, globalCtx, -40.0f, (s16)(this->actor.shape.rot.y + 0x3FFF))) { - Animation_PlayLoop(&this->skelAnime, &gZfSidesteppingAnim); - player = GET_PLAYER(globalCtx); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4000, 1); - playerRotY = player->actor.shape.rot.y; - - if (Math_SinS(playerRotY - this->actor.shape.rot.y) >= 0.0f) { - this->actor.speedXZ = -6.0f; - } else if (Math_SinS(playerRotY - this->actor.shape.rot.y) < 0.0f) { // Superfluous check - this->actor.speedXZ = 6.0f; - } - - this->unk_408 = 0.0f; - this->hopAnimIndex = 0; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - this->unk_3F0 = Rand_ZeroOne() * 10.0f + 5.0f; - this->action = ENZF_ACTION_CIRCLE_AROUND_PLAYER; - EnZf_SetupAction(this, EnZf_CircleAroundPlayer); - } else { - EnZf_SetupApproachPlayer(this, globalCtx); - } -} - -void EnZf_CircleAroundPlayer(EnZf* this, GlobalContext* globalCtx) { - s16 playerRot; - s16 phi_v0_4; - Player* player = GET_PLAYER(globalCtx); - s32 curKeyFrame; - s32 prevKeyFrame; - s32 playSpeed; - f32 baseRange = 0.0f; - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 1); - playerRot = player->actor.shape.rot.y; - - if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - if (this->unk_3F8) { - this->actor.speedXZ = -this->actor.speedXZ; - } - } else if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, this->actor.speedXZ, - this->actor.shape.rot.y + 0x3FFF)) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { - phi_v0_4 = this->actor.shape.rot.y + 0x3FFF; - } else { - phi_v0_4 = this->actor.shape.rot.y - 0x3FFF; - } - - phi_v0_4 = this->actor.wallYaw - phi_v0_4; - } else { - this->actor.speedXZ *= -0.8f; - phi_v0_4 = 0; - } - - if (ABS(phi_v0_4) > 0x4000) { - this->actor.speedXZ *= -0.8f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; - } else { - this->actor.speedXZ += 0.5f; - } - } - } - - if (Math_SinS(playerRot - this->actor.shape.rot.y) >= 0.0f) { - this->actor.speedXZ += 0.125f; - } else { - this->actor.speedXZ -= 0.125f; - } - - this->actor.world.rot.y = this->actor.shape.rot.y + 0x4000; - - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { - baseRange = 100.0f; - } - - if (this->actor.xzDistToPlayer <= (70.0f + baseRange)) { - Math_SmoothStepToF(&this->unk_408, -4.0f, 1.0f, 1.5f, 0.0f); - } else if ((90.0f + baseRange) < this->actor.xzDistToPlayer) { - Math_SmoothStepToF(&this->unk_408, 4.0f, 1.0f, 1.5f, 0.0f); - } else { - Math_SmoothStepToF(&this->unk_408, 0.0f, 1.0f, 5.65f, 0.0f); - } - - if ((this->unk_408 != 0.0f) && !EnZf_SecondaryFloorCheck(this, globalCtx, this->unk_408)) { - this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->unk_408; - this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->unk_408; - } - - if (ABS(this->actor.speedXZ) >= ABS(this->unk_408)) { - this->skelAnime.playSpeed = -this->actor.speedXZ * 0.75f; - } else if (this->skelAnime.playSpeed < 0.0f) { - this->skelAnime.playSpeed = this->unk_408 * -0.75f; - } else { - this->skelAnime.playSpeed = this->unk_408 * 0.75f; - } - - curKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); - - this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); - - if (EnZf_FindPlatform(&player->actor.world.pos, -1) != this->curPlatform) { - this->actor.speedXZ = 0.0f; - - if ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ && - (D_80B4A1B4 == this->actor.params)) { - EnZf_SetupHopAndTaunt(this); - } else { - EnZf_SetupApproachPlayer(this, globalCtx); - } - } else if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) { - if (this->unk_3F0 == 0) { - phi_v0_4 = player->actor.shape.rot.y - this->actor.shape.rot.y; - - phi_v0_4 = ABS(phi_v0_4); - - if (phi_v0_4 >= 0x3A98) { - if ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) && (D_80B4A1B4 == this->actor.params)) { - EnZf_SetupHopAndTaunt(this); - } else { - func_80B45384(this); - this->unk_3F0 = Rand_ZeroOne() * 5.0f + 1.0f; - } - } else if ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) && (D_80B4A1B4 == this->actor.params)) { - EnZf_SetupHopAndTaunt(this); - } else { - this->actor.world.rot.y = this->actor.shape.rot.y; - - if ((this->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0) && - EnZf_CanAttack(globalCtx, this)) { - EnZf_SetupSlash(this); - } else if ((this->actor.xzDistToPlayer < 280.0f) && (this->actor.xzDistToPlayer > 240.0f) && - !EnZf_PrimaryFloorCheck(this, globalCtx, 191.9956f) && - ((globalCtx->gameplayFrames % 2) == 0)) { - EnZf_SetupJumpForward(this); - } else { - EnZf_SetupApproachPlayer(this, globalCtx); - } - } - } else { - this->unk_3F0--; - } - if (curKeyFrame != (s32)this->skelAnime.curFrame) { - s32 nextKeyFrame = playSpeed + curKeyFrame; - if (((prevKeyFrame < 14) && (nextKeyFrame >= 16)) || ((prevKeyFrame < 27) && (nextKeyFrame >= 29))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); - } - } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - } - } -} - -void EnZf_SetupDie(EnZf* this) { - Animation_Change(&this->skelAnime, &gZfDyingAnim, 1.5f, 0.0f, Animation_GetLastFrame(&gZfDyingAnim), ANIMMODE_ONCE, - -4.0f); - - if ((this->actor.bgCheckFlags & 1) && ((this->actor.velocity.y == 0.0f) || (this->actor.velocity.y == -4.0f))) { - this->actor.speedXZ = 0.0f; - this->hopAnimIndex = 0; - } else { - this->hopAnimIndex = 1; - } - - this->action = ENZF_ACTION_DIE; - this->actor.flags &= ~ACTOR_FLAG_0; - - if (D_80B4A1B4 != -1) { - if (this->actor.prev != NULL) { - ((EnZf*)this->actor.prev)->unk_3F4 = 90; - - if (this->actor.prev->colChkInfo.health < 3) { - this->actor.prev->colChkInfo.health = 3; - } - } else { - ((EnZf*)this->actor.next)->unk_3F4 = 90; - - if (this->actor.next->colChkInfo.health < 3) { - this->actor.next->colChkInfo.health = 3; - } - } - } - - D_80B4A1B0 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DEAD); - EnZf_SetupAction(this, EnZf_Die); -} - -void EnZf_Die(EnZf* this, GlobalContext* globalCtx) { - - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } - - if (this->actor.bgCheckFlags & 1) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.15f, 0.0f); - this->hopAnimIndex = 0; - } - - if (SkelAnime_Update(&this->skelAnime)) { - if (this->actor.category != ACTORCAT_PROP) { - if ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ && (D_80B4A1B4 == -1)) { - Flags_SetSwitch(globalCtx, this->clearFlag); - func_800F5B58(); - } else { - D_80B4A1B4 = -1; - } - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - } - - if (this->alpha != 0) { - this->actor.shape.shadowAlpha = this->alpha -= 5; - - } else { - Actor_Kill(&this->actor); - } - } else { - s32 curFrame = this->skelAnime.curFrame; - - if ((curFrame == 10) || (curFrame == 18)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DOWN); - } - } -} - -void EnZf_UpdateHeadRotation(EnZf* this, GlobalContext* globalCtx) { - s16 angleTemp; - - if ((this->actor.params == ENZF_TYPE_DINOLFOS) && (this->action == ENZF_ACTION_3) && (this->unk_3F4 != 0)) { - this->headRot = Math_SinS(this->unk_3F4 * 1400) * 0x2AA8; - } else { - angleTemp = this->actor.yawTowardsPlayer; - angleTemp -= (s16)(this->headRot + this->actor.shape.rot.y); - this->headRotTemp = CLAMP(angleTemp, -0x7D0, 0x7D0); - this->headRot += this->headRotTemp; - this->headRot = CLAMP(this->headRot, -0x1CD7, 0x1CD7); - } -} - -void EnZf_UpdateDamage(EnZf* this, GlobalContext* globalCtx) { - s32 pad; - s16 dropParams; - - if ((this->bodyCollider.base.acFlags & AC_HIT) && (this->action <= ENZF_ACTION_STUNNED)) { - this->bodyCollider.base.acFlags &= ~AC_HIT; - - if (((this->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* not miniboss */ || - (D_80B4A1B4 != this->actor.params)) && - (this->actor.colChkInfo.damageEffect != ENZF_DMGEFF_IMMUNE)) { - this->damageEffect = this->actor.colChkInfo.damageEffect; - Actor_SetDropFlag(&this->actor, &this->bodyCollider.info, 0); - - if ((this->actor.colChkInfo.damageEffect == ENZF_DMGEFF_STUN) || - (this->actor.colChkInfo.damageEffect == ENZF_DMGEFF_ICE)) { - if (this->action != ENZF_ACTION_STUNNED) { - Actor_SetColorFilter(&this->actor, 0, 120, 0, 80); - Actor_ApplyDamage(&this->actor); - EnZf_SetupStunned(this); - } - } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - - if (Actor_ApplyDamage(&this->actor) == 0) { - dropParams = 0x40; - EnZf_SetupDie(this); - - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - dropParams = 0xE0; - } - - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, dropParams); - Enemy_StartFinishingBlow(globalCtx, &this->actor); - } else { - if ((D_80B4A1B4 != -1) && ((this->actor.colChkInfo.health + this->actor.colChkInfo.damage) >= 4) && - (this->actor.colChkInfo.health < 4)) { - this->damageEffect = ENZF_DMGEFF_PROJECTILE; - } - - EnZf_SetupDamaged(this); - } - } - } - } -} - -void EnZf_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnZf* this = (EnZf*)thisx; - s32 pad2; - - EnZf_UpdateDamage(this, globalCtx); - if (this->actor.colChkInfo.damageEffect != ENZF_DMGEFF_IMMUNE) { - this->unk_3F8 = false; - if ((this->hopAnimIndex != 1) && (this->action != ENZF_ACTION_HOP_AWAY)) { - if (this->actor.speedXZ != 0.0f) { - this->unk_3F8 = EnZf_PrimaryFloorCheck(this, globalCtx, this->actor.speedXZ * 1.5f); - } - if (!this->unk_3F8) { - this->unk_3F8 = EnZf_PrimaryFloorCheck(this, globalCtx, 0.0f); - } - } - - if (!this->unk_3F8) { - Actor_MoveForward(&this->actor); - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 30.0f, 60.0f, 0x1D); - - if (!(this->actor.bgCheckFlags & 1)) { - this->hopAnimIndex = 1; - } - - this->actionFunc(this, globalCtx); - } - - if (this->actor.colChkInfo.health > 0) { - if ((this->action != ENZF_ACTION_SLASH) && (this->action != ENZF_ACTION_STUNNED)) { - EnZf_UpdateHeadRotation(this, globalCtx); - } - - if ((D_80B4A1B0 != 0) && (D_80B4A1B4 != this->actor.params)) { - EnZf_SetupSheatheSword(this, globalCtx); - D_80B4A1B4 = this->actor.params; - D_80B4A1B0 = 0; - - if (this->actor.prev != NULL) { - ((EnZf*)this->actor.prev)->unk_3F4 = 90; - } else { - ((EnZf*)this->actor.next)->unk_3F4 = 90; - } - } - } - - if (this->action >= ENZF_ACTION_DIE) { - Math_SmoothStepToS(&this->headRot, 0, 1, 2000, 0); - - if (this->action <= ENZF_ACTION_HOP_AND_TAUNT) { - if ((this->unk_3F4 == 1) && (this->actor.bgCheckFlags & 1)) { - if (this->actor.colChkInfo.health > 0) { - EnZf_SetupDrawSword(this, globalCtx); - } - this->unk_3F4--; - } - } - - if (this->unk_3F4 >= 2) { - this->unk_3F4--; - } - } - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 40.0f; - - if ((this->actor.colChkInfo.health > 0) && (this->alpha == 255)) { - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - - if ((this->actor.world.pos.y == this->actor.floorHeight) && (this->action <= ENZF_ACTION_DAMAGED)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - - if ((this->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* not miniboss */ || - (D_80B4A1B4 != this->actor.params)) { - if ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - } - } - } - - if ((this->action == ENZF_ACTION_SLASH) && (this->skelAnime.curFrame >= 14.0f) && - (this->skelAnime.curFrame <= 20.0f)) { - if (!(this->swordCollider.base.atFlags & AT_BOUNCED) && !(this->swordCollider.base.acFlags & AC_HIT)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->swordCollider.base); - } else { - this->swordCollider.base.atFlags &= ~AT_BOUNCED; - this->swordCollider.base.acFlags &= ~AC_HIT; - EnZf_SetupRecoilFromBlockedSlash(this); - } - } -} - -s32 EnZf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnZf* this = (EnZf*)thisx; - - switch (limbIndex) { - case ENZF_LIMB_HEAD_ROOT: - rot->y -= this->headRot; - break; - case ENZF_LIMB_SWORD: - if (this->swordSheathed) { - *dList = gZfEmptyHandDL; - } - break; - case ENZF_LIMB_SCABBARD: - if (this->swordSheathed) { - *dList = gZfSheathedSwordDL; - } - break; - default: - break; - } - - return false; -} - -void EnZf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - static Vec3f sUnused = { 1100.0f, -700.0f, 0.0f }; - static Vec3f footOffset = { 300.0f, 0.0f, 0.0f }; - static Vec3f D_80B4A2A4 = { 300.0f, -1700.0f, 0.0f }; // Sword tip? - static Vec3f D_80B4A2B0 = { -600.0f, 300.0f, 0.0f }; // Sword hilt? - static Vec3f swordQuadOffset1 = { 0.0f, 1500.0f, 0.0f }; - static Vec3f swordQuadOffset0 = { -600.0f, -3000.0f, 1000.0f }; - static Vec3f swordQuadOffset3 = { -600.0f, -3000.0f, -1000.0f }; - static Vec3f swordQuadOffset2 = { 1500.0f, -3000.0f, 0.0f }; - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f sp54; - Vec3f sp48; - EnZf* this = (EnZf*)thisx; - s32 bodyPart = -1; - - if (limbIndex == ENZF_LIMB_SWORD) { - Matrix_MultVec3f(&swordQuadOffset1, &this->swordCollider.dim.quad[1]); - Matrix_MultVec3f(&swordQuadOffset0, &this->swordCollider.dim.quad[0]); - Matrix_MultVec3f(&swordQuadOffset3, &this->swordCollider.dim.quad[3]); - Matrix_MultVec3f(&swordQuadOffset2, &this->swordCollider.dim.quad[2]); - Collider_SetQuadVertices(&this->swordCollider, &this->swordCollider.dim.quad[0], - &this->swordCollider.dim.quad[1], &this->swordCollider.dim.quad[2], - &this->swordCollider.dim.quad[3]); - Matrix_MultVec3f(&D_80B4A2A4, &sp54); - Matrix_MultVec3f(&D_80B4A2B0, &sp48); - - if (this->action == ENZF_ACTION_SLASH) { - if (this->skelAnime.curFrame < 14.0f) { - EffectBlure_AddSpace(Effect_GetByIndex(this->blureIndex)); - } else if (this->skelAnime.curFrame < 20.0f) { - EffectBlure_AddVertex(Effect_GetByIndex(this->blureIndex), &sp54, &sp48); - } - } - } else { - Actor_SetFeetPos(&this->actor, limbIndex, ENZF_LIMB_LEFT_FOOT, &footOffset, ENZF_LIMB_RIGHT_FOOT, &footOffset); - } - - switch (limbIndex) { - case ENZF_LIMB_LEFT_FOOT: - Matrix_MultVec3f(&footOffset, &this->leftFootPos); - break; - case ENZF_LIMB_RIGHT_FOOT: - Matrix_MultVec3f(&footOffset, &this->rightFootPos); - break; - } - - if (this->iceTimer != 0) { - switch (limbIndex) { - case ENZF_LIMB_HEAD: - bodyPart = 0; - break; - case ENZF_LIMB_NECK: - bodyPart = 1; - break; - case ENZF_LIMB_CHEST_ARMOR: - bodyPart = 2; - break; - case ENZF_LIMB_RIGHT_FOREARM: - bodyPart = 3; - break; - case ENZF_LIMB_LEFT_FOREARM: - bodyPart = 4; - break; - case ENZF_LIMB_TRUNK: - bodyPart = 5; - break; - case ENZF_LIMB_SWORD_ROOT: - bodyPart = 6; - break; - case ENZF_LIMB_RIGHT_SHIN: - bodyPart = 7; - break; - case ENZF_LIMB_LEFT_SHIN_ROOT: - bodyPart = 8; - break; - default: - break; - } - if (bodyPart >= 0) { - Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[bodyPart]); - } - } -} - -static Gfx D_80B4A2F8[] = { - gsSPTexture(0x0A00, 0x0A00, 0, G_TX_RENDERTILE, G_ON), - gsSPEndDisplayList(), -}; - -void EnZf_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnZf* this = (EnZf*)thisx; - ; // Extra ";" required for matching. Cannot be if (1) {} or the like. Typo? - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zf.c", 3533); - - func_8002EBCC(thisx, globalCtx, 1); - - gSPTexture(D_80B4A2F8, IREG(0), IREG(1), 0, G_TX_RENDERTILE, G_ON); - - gSPSegment(POLY_OPA_DISP++, 0x08, D_80B4A2F8); - - if (this->alpha == 255) { - func_80093D18(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_OPA_DISP++, 0x09, &D_80116280[2]); - - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnZf_OverrideLimbDraw, EnZf_PostLimbDraw, this, POLY_OPA_DISP); - - if (this->iceTimer != 0) { - thisx->colorFilterTimer++; - this->iceTimer--; - - if ((this->iceTimer % 4) == 0) { - s32 icePosIndex = this->iceTimer >> 2; - - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, thisx, &this->bodyPartsPos[icePosIndex], 150, 150, 150, 250, - 235, 245, 255, 1.4f); - } - if (1) {} - } - } else { // fades out when dead - func_80093D84(globalCtx->state.gfxCtx); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x09, &D_80116280[0]); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnZf_OverrideLimbDraw, EnZf_PostLimbDraw, this, POLY_XLU_DISP); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zf.c", 3601); -} - -void EnZf_SetupCircleAroundPlayer(EnZf* this, f32 speed) { - Animation_MorphToLoop(&this->skelAnime, &gZfSidesteppingAnim, -1.0f); - this->unk_3F0 = Rand_ZeroOne() * 10.0f + 8.0f; - - if (this->actor.params == ENZF_TYPE_DINOLFOS) { - this->actor.speedXZ = 2.0f * speed; - this->unk_3F0 /= 2; - } else { - this->actor.speedXZ = speed; - } - - this->hopAnimIndex = 0; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - this->action = ENZF_ACTION_CIRCLE_AROUND_PLAYER; - EnZf_SetupAction(this, EnZf_CircleAroundPlayer); -} - -s32 EnZf_DodgeRangedEngaging(GlobalContext* globalCtx, EnZf* this) { - Actor* projectileActor; - s16 yawToProjectile; - s16 phi_t0; - s16 phi_v1; - - projectileActor = Actor_GetProjectileActor(globalCtx, &this->actor, 600.0f); - - if (projectileActor != NULL) { - yawToProjectile = - Actor_WorldYawTowardActor(&this->actor, projectileActor) - (s16)(u16)(this->actor.shape.rot.y); - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - - phi_t0 = 0; - - if (EnZf_PrimaryFloorCheck(this, globalCtx, -8.0f)) { - phi_t0 = 1; - } - - if (EnZf_PrimaryFloorCheck(this, globalCtx, 8.0f)) { - phi_t0 |= 2; - } - - this->actor.world.rot.y = this->actor.shape.rot.y; - - if ((((this->actor.xzDistToPlayer < 90.0f) || (phi_t0 == 3)) && - !EnZf_PrimaryFloorCheck(this, globalCtx, 135.0f)) || - (projectileActor->id == ACTOR_ARMS_HOOK)) { - EnZf_SetupJumpUp(this); - return true; - } - - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; - - if (phi_t0 == 0) { - phi_v1 = globalCtx->gameplayFrames % 2; - } else { - phi_v1 = phi_t0; - } - - if ((ABS(yawToProjectile) < 0x2000) || (ABS(yawToProjectile) >= 0x6000)) { - if (phi_v1 & 1) { - EnZf_SetupCircleAroundPlayer(this, 8.0f); - return true; - } - EnZf_SetupCircleAroundPlayer(this, -8.0f); - return true; - } - if (ABS(yawToProjectile) < 0x5FFF) { - if (phi_v1 & 1) { - EnZf_SetupCircleAroundPlayer(this, 4.0f); - return true; - } - EnZf_SetupCircleAroundPlayer(this, -4.0f); - } - return true; - } - return false; -} - -s32 EnZf_DodgeRangedWaiting(GlobalContext* globalCtx, EnZf* this) { - Actor* projectileActor; - s16 yawToProjectile; - s16 phi_t0; - s16 sp1E; - s16 sp1C = 0; - - projectileActor = Actor_GetProjectileActor(globalCtx, &this->actor, 600.0f); - if (projectileActor != NULL) { - yawToProjectile = Actor_WorldYawTowardActor(&this->actor, projectileActor) - (s16)(u16)this->actor.shape.rot.y; - this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; // Set to move sideways - - phi_t0 = 0; - - if (EnZf_PrimaryFloorCheck(this, globalCtx, -70.0f)) { - phi_t0 = 1; - } - - if (EnZf_PrimaryFloorCheck(this, globalCtx, 70.0f)) { - phi_t0 |= 2; - } - - this->actor.speedXZ = 0.0f; - - if ((ABS(yawToProjectile) < 0x2000) || (ABS(yawToProjectile) >= 0x6000)) { - if (phi_t0 == 0) { - if ((globalCtx->gameplayFrames % 2) != 0) { - sp1E = 6; - } else { - sp1E = -6; - } - } else { - switch (phi_t0) { - case 1: - sp1E = 6; - break; - case 2: - sp1E = -6; - break; - case 1 | 2: - sp1C = 5; - sp1E = 0; - break; - } - } - } else if (ABS(yawToProjectile) < 0x5FFF) { - if (phi_t0 == 0) { - if ((globalCtx->gameplayFrames % 2) != 0) { - sp1E = 6; - } else { - sp1E = -6; - } - } else { - switch (phi_t0) { - case 1: - sp1E = 6; - break; - case 2: - sp1E = -6; - break; - case 1 | 2: - sp1C = 10; - sp1E = 0; - break; - } - } - } - - this->unk_408 = sp1E; - this->unk_40C = sp1C; - return true; - } - return false; -} diff --git a/src/overlays/actors/ovl_En_Zf/z_en_zf.cpp b/src/overlays/actors/ovl_En_Zf/z_en_zf.cpp new file mode 100644 index 000000000..fada3b0ec --- /dev/null +++ b/src/overlays/actors/ovl_En_Zf/z_en_zf.cpp @@ -0,0 +1,2439 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZF_Z_EN_ZF_C +#include "actor_common.h" +/* + * File: z_en_zf.c + * Overlay: ovl_En_Zf + * Description: Lizalfos and Dinolfos + */ + +#include "z_en_zf.h" +#include "objects/object_zf/object_zf.h" +#include "def/code_800EC960.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_eff_blure.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) + +void EnZf_Init(Actor* thisx, GlobalContext* globalCtx); +void EnZf_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnZf_Update(Actor* thisx, GlobalContext* globalCtx); +void EnZf_Draw(Actor* thisx, GlobalContext* globalCtx); + +s16 EnZf_FindPlatform(Vec3f* pos, s16 preferredIndex); +void EnZf_SetupDropIn(EnZf* pthis); +void EnZf_DropIn(EnZf* pthis, GlobalContext* globalCtx); +void func_80B45384(EnZf* pthis); +void func_80B4543C(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupApproachPlayer(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_ApproachPlayer(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupJumpForward(EnZf* pthis); +void EnZf_JumpForward(EnZf* pthis, GlobalContext* globalCtx); +void func_80B4604C(EnZf* pthis); +void func_80B46098(EnZf* pthis, GlobalContext* globalCtx); +void func_80B462E4(EnZf* pthis, GlobalContext* globalCtx); +void func_80B463E4(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupSlash(EnZf* pthis); +void EnZf_Slash(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_RecoilFromBlockedSlash(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupJumpBack(EnZf* pthis); +void EnZf_JumpBack(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_Stunned(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupSheatheSword(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SheatheSword(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_HopAndTaunt(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupHopAway(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_HopAway(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_DrawSword(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_Damaged(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupJumpUp(EnZf* pthis); +void EnZf_JumpUp(EnZf* pthis, GlobalContext* globalCtx); +void func_80B483E4(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_CircleAroundPlayer(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupDie(EnZf* pthis); +void EnZf_Die(EnZf* pthis, GlobalContext* globalCtx); +void EnZf_SetupCircleAroundPlayer(EnZf* pthis, f32 speed); +s32 EnZf_DodgeRangedEngaging(GlobalContext* globalCtx, EnZf* pthis); +s32 EnZf_DodgeRangedWaiting(GlobalContext* globalCtx, EnZf* pthis); + +#define PLATFORM_INDEX_DOWNSTAIRS_MIN 0 +#define PLATFORM_INDEX_DOWNSTAIRS_INNER_MAX 5 +#define PLATFORM_INDEX_DOWNSTAIRS_MAX 7 +#define PLATFORM_INDEX_UPSTAIRS_MIN (PLATFORM_INDEX_DOWNSTAIRS_MAX + 1) +#define PLATFORM_INDEX_UPSTAIRS_INNER_MAX 15 + +/** + * Array of platform positions in Dodongo's Cavern miniboss room. + * 0 - 7 : Downstairs + * 8 - 15 : Upstairs inner platforms + * 16 - 23 : Upstairs outer platforms (including several points on the long thin one) + */ +static Vec3f sPlatformPositions[] = { + // Downstairs + { 3560.0f, 100.0f, -1517.0f }, + { 3170.0f, 100.0f, -1767.0f }, + { 3165.0f, 100.0f, -2217.0f }, + { 3563.0f, 100.0f, -2437.0f }, + { 3946.0f, 100.0f, -2217.0f }, + { 3942.0f, 100.0f, -1765.0f }, + // Westmost downstairs two + { 2861.0f, 100.0f, -2394.0f }, + { 2776.0f, 100.0f, -1987.0f }, + + // Upstairs inner + { 4527.0f, 531.0f, -1146.0f }, + { 4442.0f, 531.0f, -1405.0f }, + { 4170.0f, 531.0f, -1395.0f }, + { 4030.0f, 531.0f, -1162.0f }, + { 4010.0f, 531.0f, -883.0f }, + { 4270.0f, 531.0f, -810.0f }, + { 4520.0f, 531.0f, -880.0f }, + { 4260.0f, 531.0f, -1035.0f }, + + // Upstairs outer + { 4757.0f, 531.0f, -1146.0f }, + { 3850.0f, 531.0f, -883.0f }, + { 4380.0f, 531.0f, -690.0f }, + { 4197.0f, 531.0f, -646.0f }, + { 4070.0f, 531.0f, -1575.0f }, + { 3930.0f, 531.0f, -1705.0f }, + { 3780.0f, 531.0f, -1835.0f }, + { 3560.0f, 531.0f, -1985.0f }, +}; + +// These seem to relate to the tagging in/out the minibosses do +static s16 D_80B4A1B0 = 0; +static s16 D_80B4A1B4 = 1; + +ActorInit En_Zf_InitVars = { + ACTOR_EN_ZF, + ACTORCAT_ENEMY, + FLAGS, + OBJECT_ZF, + sizeof(EnZf), + (ActorFunc)EnZf_Init, + (ActorFunc)EnZf_Destroy, + (ActorFunc)EnZf_Update, + (ActorFunc)EnZf_Draw, +}; + +static ColliderCylinderInit sBodyCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderQuadInit sSwordQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xFFCFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +typedef enum { + /* 0x0 */ ENZF_DMGEFF_NONE, + /* 0x1 */ ENZF_DMGEFF_STUN, + /* 0x6 */ ENZF_DMGEFF_IMMUNE = 6, // Skips damage code, but also skips the top half of Update + /* 0xD */ ENZF_DMGEFF_PROJECTILE = 0xD, // Projectiles that don't have another damageeffect + /* 0xF */ ENZF_DMGEFF_ICE = 0xF +} EnZfDamageEffect; + +static DamageTable sDamageTable = { + /* Deku nut */ DMG_ENTRY(0, ENZF_DMGEFF_STUN), + /* Deku stick */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Slingshot */ DMG_ENTRY(1, ENZF_DMGEFF_PROJECTILE), + /* Explosive */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Boomerang */ DMG_ENTRY(0, ENZF_DMGEFF_STUN), + /* Normal arrow */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Hammer swing */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, ENZF_DMGEFF_STUN), + /* Kokiri sword */ DMG_ENTRY(1, ENZF_DMGEFF_NONE), + /* Master sword */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Giant's Knife */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), + /* Ice arrow */ DMG_ENTRY(4, ENZF_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), + /* Unk arrow 1 */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), + /* Unk arrow 2 */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), + /* Unk arrow 3 */ DMG_ENTRY(2, ENZF_DMGEFF_PROJECTILE), + /* Fire magic */ DMG_ENTRY(0, ENZF_DMGEFF_IMMUNE), + /* Ice magic */ DMG_ENTRY(3, ENZF_DMGEFF_ICE), + /* Light magic */ DMG_ENTRY(0, ENZF_DMGEFF_IMMUNE), + /* Shield */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), + /* Mirror Ray */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), + /* Kokiri spin */ DMG_ENTRY(1, ENZF_DMGEFF_NONE), + /* Giant spin */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), + /* Master spin */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Kokiri jump */ DMG_ENTRY(2, ENZF_DMGEFF_NONE), + /* Giant jump */ DMG_ENTRY(8, ENZF_DMGEFF_NONE), + /* Master jump */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), + /* Unknown 1 */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), + /* Hammer jump */ DMG_ENTRY(4, ENZF_DMGEFF_NONE), + /* Unknown 2 */ DMG_ENTRY(0, ENZF_DMGEFF_NONE), +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), +}; + +static AnimationHeader* sHoppingAnims[] = { &gZfHopCrouchingAnim, &gZfHopLeapingAnim, &gZfHopLandingAnim }; + +static s32 D_80B4AB30; // Set to 0 and incremented in EnZf_HopAway, but not actually used + +void EnZf_SetupAction(EnZf* pthis, EnZfActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +/** + * Tests if it will still be on a floor after moving forwards a distance determined by dist, in the shape forward + * direction. If `dist` is 0, it defaults to a dist depending on speed direction, and params. + */ +s32 EnZf_PrimaryFloorCheck(EnZf* pthis, GlobalContext* globalCtx, f32 dist) { + s16 ret; + s16 curBgCheckFlags; + f32 sin; + f32 cos; + Vec3f curPos; + + if (dist == 0.0f) { + dist = ((pthis->actor.speedXZ >= 0.0f) ? 1.0f : -1.0f); + dist = ((pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) ? dist * 45.0f : dist * 30.0f); + } + + // Save currents to restore later + curPos = pthis->actor.world.pos; + curBgCheckFlags = pthis->actor.bgCheckFlags; + + sin = Math_SinS(pthis->actor.world.rot.y) * dist; + cos = Math_CosS(pthis->actor.world.rot.y) * dist; + + pthis->actor.world.pos.x += sin; + pthis->actor.world.pos.z += cos; + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 0x1C); + pthis->actor.world.pos = curPos; + ret = !(pthis->actor.bgCheckFlags & 1); + pthis->actor.bgCheckFlags = curBgCheckFlags; + return ret; +} + +/** + * Supplementary floor test. + */ +s16 EnZf_SecondaryFloorCheck(EnZf* pthis, GlobalContext* globalCtx, f32 dist) { + s16 ret; + s16 curBgCheckFlags; + f32 sin; + f32 cos; + Vec3f curPos; + + if ((pthis->actor.speedXZ != 0.0f) && EnZf_PrimaryFloorCheck(pthis, globalCtx, pthis->actor.speedXZ)) { + return true; + } + + // Save currents to restore later + curPos = pthis->actor.world.pos; + curBgCheckFlags = pthis->actor.bgCheckFlags; + + sin = Math_SinS(pthis->actor.shape.rot.y) * dist; + cos = Math_CosS(pthis->actor.shape.rot.y) * dist; + + pthis->actor.world.pos.x += sin; + pthis->actor.world.pos.z += cos; + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 0x1C); + pthis->actor.world.pos = curPos; + ret = !(pthis->actor.bgCheckFlags & 1); + pthis->actor.bgCheckFlags = curBgCheckFlags; + return ret; +} + +void EnZf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZf* pthis = (EnZf*)thisx; + Player* player = GET_PLAYER(globalCtx); + EffectBlureInit1 blureInit; + f32 posDiff; + + Actor_ProcessInitChain(thisx, sInitChain); + thisx->targetMode = 3; + pthis->clearFlag = (thisx->params & 0xFF00) >> 8; + /* Strip the top byte of params */ + thisx->params &= 0xFF; + + /* Return the params to their original value if they were originally negative, i.e. 0xFFFF or 0xFFFE */ + if (thisx->params & 0x80) { + thisx->params |= 0xFF00; + } + + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawFeet, 90.0f); + pthis->unk_3E0 = 0; + thisx->colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.damageTable = &sDamageTable; + + blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = + blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = blureInit.p1EndColor[0] = + blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = blureInit.p2EndColor[1] = + blureInit.p2EndColor[2] = 255; + blureInit.p2StartColor[3] = 64; + blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; + blureInit.elemDuration = 8; + blureInit.unkFlag = 0; + blureInit.calcMode = 2; + + Effect_Add(globalCtx, &pthis->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); + + Actor_UpdateBgCheckInfo(globalCtx, thisx, 75.0f, 45.0f, 45.0f, 0x1D); + + pthis->alpha = 255; + thisx->colChkInfo.cylRadius = 40; + thisx->colChkInfo.cylHeight = 100; + Collider_InitCylinder(globalCtx, &pthis->bodyCollider); + Collider_SetCylinder(globalCtx, &pthis->bodyCollider, thisx, &sBodyCylinderInit); + Collider_InitQuad(globalCtx, &pthis->swordCollider); + Collider_SetQuad(globalCtx, &pthis->swordCollider, thisx, &sSwordQuadInit); + + if (thisx->params == ENZF_TYPE_DINOLFOS) { + thisx->colChkInfo.health = 12; + thisx->naviEnemyId = 0x10; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gZfDinolfosSkel, &gZfCryingAnim, pthis->jointTable, + pthis->morphTable, ENZF_LIMB_MAX); + } else { // Lizalfos + thisx->colChkInfo.health = 6; + thisx->naviEnemyId = 0x0F; + SkelAnime_Init(globalCtx, &pthis->skelAnime, &gZfLizalfosSkel, &gZfCryingAnim, pthis->jointTable, + pthis->morphTable, ENZF_LIMB_MAX); + } + + if (thisx->params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // Not minibosses + pthis->homePlatform = pthis->curPlatform = -1; + D_80B4A1B4 = -1; + pthis->hopAnimIndex = 1; + if (thisx->params == ENZF_TYPE_LIZALFOS_LONE) { + EnZf_SetupDropIn(pthis); + } else { // Dinolfos + func_80B45384(pthis); + } + } else { // Minibosses + posDiff = player->actor.world.pos.y - thisx->world.pos.y; + + if ((ABS(posDiff) <= 100.0f) && !Flags_GetSwitch(globalCtx, pthis->clearFlag)) { + pthis->homePlatform = pthis->curPlatform = EnZf_FindPlatform(&thisx->world.pos, 0); + EnZf_SetupDropIn(pthis); + D_80B4A1B4 = 1; + } else { + Actor_Kill(thisx); + } + } +} + +void EnZf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZf* pthis = (EnZf*)thisx; + + if ((pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ && + (Actor_FindNearby(globalCtx, &pthis->actor, ACTOR_EN_ZF, ACTORCAT_ENEMY, 10000.0f) == NULL)) { + func_800F5B58(); + } + + Effect_Delete(globalCtx, pthis->blureIndex); + Collider_DestroyCylinder(globalCtx, &pthis->bodyCollider); + Collider_DestroyQuad(globalCtx, &pthis->swordCollider); +} + +/** + * Finds the index of the platform position in `sPlatformPositions` that is sufficiently close to `pos`. + * Returns `preferedIndex` if the associated position is close enough. + */ +s16 EnZf_FindPlatform(Vec3f* pos, s16 preferredIndex) { + f32 rangeXZ; + s16 i; + + rangeXZ = 210.0f; + + // Upstairs has a smaller range + if (pos->y >= 420.0f) { + rangeXZ = 110.0f; + } + + if (preferredIndex != -1) { + i = preferredIndex; + if (((sPlatformPositions[i].y - 150.0f) <= pos->y) && (pos->y <= (sPlatformPositions[i].y + 150.0f)) && + ((sPlatformPositions[i].x - rangeXZ) <= pos->x) && (pos->x <= (sPlatformPositions[i].x + rangeXZ)) && + ((sPlatformPositions[i].z - rangeXZ) <= pos->z) && (pos->z <= (sPlatformPositions[i].z + rangeXZ))) { + return preferredIndex; + } + } + + for (i = ARRAY_COUNT(sPlatformPositions) - 1; i > -1; i--) { + if (((sPlatformPositions[i].y - 150.0f) <= pos->y) && (pos->y <= (sPlatformPositions[i].y + 150.0f)) && + ((sPlatformPositions[i].x - rangeXZ) <= pos->x) && (pos->x <= (sPlatformPositions[i].x + rangeXZ)) && + ((sPlatformPositions[i].z - rangeXZ) <= pos->z) && (pos->z <= (sPlatformPositions[i].z + rangeXZ))) { + break; + } + } + return i; +} + +s16 EnZf_FindNextPlatformAwayFromPlayer(Vec3f* pos, s16 curPlatform, s16 arg2, GlobalContext* globalCtx) { + f32 distToCurLoopPlatform; + f32 platformMinDist = 585.0f; + Player* player = GET_PLAYER(globalCtx); + s16 initialPlatform = curPlatform; + f32 playerMaxDist = 400.0f; + f32 smallMaxRange = 99998.0f; + s16 curLoopPlatform = PLATFORM_INDEX_DOWNSTAIRS_INNER_MAX; // Will never retreat to the last two + s16 minIndex = PLATFORM_INDEX_DOWNSTAIRS_MIN; + f32 largeMaxRange = 99999.0f; + s16 altNextPlatform = -1; + s16 nextPlatform = -1; + s16 playerPlatform = EnZf_FindPlatform(&player->actor.world.pos, initialPlatform); + + // Set up search constraints + // Upstairs + if (pos->y > 420.0f) { + minIndex = PLATFORM_INDEX_UPSTAIRS_MIN; + playerMaxDist = 50.0f; + + // Upstairs outer + if (initialPlatform >= PLATFORM_INDEX_UPSTAIRS_INNER_MAX) { + curLoopPlatform = ARRAY_COUNT(sPlatformPositions) - 1; + platformMinDist = 400.0f; + } else { // upstairs inner + curLoopPlatform = PLATFORM_INDEX_UPSTAIRS_INNER_MAX - 1; + platformMinDist = 380.0f; + } + } + + for (; curLoopPlatform >= minIndex; curLoopPlatform--) { + if ((curLoopPlatform == initialPlatform) || (curLoopPlatform == playerPlatform)) { + continue; + } + if ((playerPlatform == -1) && + (Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[curLoopPlatform]) < playerMaxDist)) { + continue; + } + distToCurLoopPlatform = Math_Vec3f_DistXYZ(pos, &sPlatformPositions[curLoopPlatform]); + + if (platformMinDist < distToCurLoopPlatform) { + continue; + } + if (distToCurLoopPlatform < smallMaxRange) { + largeMaxRange = smallMaxRange; + altNextPlatform = nextPlatform; + smallMaxRange = distToCurLoopPlatform; + nextPlatform = curLoopPlatform; + } else if (distToCurLoopPlatform < largeMaxRange) { + largeMaxRange = distToCurLoopPlatform; + altNextPlatform = curLoopPlatform; + } + } + + // These functions have no side effects, so these two calls do nothing + Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[nextPlatform]); + Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[altNextPlatform]); + + if (altNextPlatform > 0) { + s16 nextPlatformToPlayerYaw = + Math_Vec3f_Yaw(pos, &sPlatformPositions[nextPlatform]) - Math_Vec3f_Yaw(pos, &player->actor.world.pos); + + if (ABS(nextPlatformToPlayerYaw) < 0x36B0) { + nextPlatform = altNextPlatform; + } + } + + if (nextPlatform < 0) { + nextPlatform = arg2; + } + return nextPlatform; +} + +s16 EnZf_FindNextPlatformTowardsPlayer(Vec3f* pos, s16 curPlatform, s16 arg2, GlobalContext* globalCtx) { + s16 curLoopPlatform = PLATFORM_INDEX_DOWNSTAIRS_MAX; + s16 minIndex = PLATFORM_INDEX_DOWNSTAIRS_MIN; + Player* player = GET_PLAYER(globalCtx); + s16 nextPlatform = EnZf_FindPlatform(&player->actor.world.pos, -1); + f32 minRange = 500.0f; + f32 smallMaxRange = 99998.0f; + f32 largeMaxRange = 99999.0f; + s16 phi_s2 = curPlatform; + s16 phi_s3 = arg2; + + // Upstairs + if (pos->y > 200.0f) { + curLoopPlatform = ARRAY_COUNT(sPlatformPositions) - 1; + minIndex = PLATFORM_INDEX_UPSTAIRS_MIN; + minRange = 290.0f; + } + + for (; curLoopPlatform >= minIndex; curLoopPlatform--) { + if (minRange < Math_Vec3f_DistXYZ(pos, &sPlatformPositions[curLoopPlatform])) { + continue; + } + if (curLoopPlatform != nextPlatform) { + f32 curPlatformDistToPlayer = + Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[curLoopPlatform]); + + if (curPlatformDistToPlayer < smallMaxRange) { + largeMaxRange = smallMaxRange; + phi_s3 = phi_s2; + smallMaxRange = curPlatformDistToPlayer; + phi_s2 = curLoopPlatform; + } else if (curPlatformDistToPlayer < largeMaxRange) { + largeMaxRange = curPlatformDistToPlayer; + phi_s3 = curLoopPlatform; + } + } else { + phi_s2 = nextPlatform; + break; + } + } + + if (phi_s3 != nextPlatform) { + nextPlatform = phi_s2; + } else { + nextPlatform = phi_s3; + } + + return nextPlatform; +} + +// Player not targeting pthis or another EnZf? +s32 EnZf_CanAttack(GlobalContext* globalCtx, EnZf* pthis) { + Actor* targetedActor; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + if (player->stateFlags1 & 0x6000) { // Hanging or climbing + return false; + } else { + return true; + } + } else { + if (!Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + return true; + } + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + targetedActor = player->unk_664; + if (targetedActor == NULL) { + return false; + } else { + if (targetedActor->category != ACTORCAT_ENEMY) { + return true; + } + if (targetedActor->id != ACTOR_EN_ZF) { + return false; + } else if (targetedActor->colorFilterTimer != 0) { + return true; + } + } + } + } + return false; +} + +void func_80B44DC4(EnZf* pthis, GlobalContext* globalCtx) { + s16 angleDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (angleDiff < 0) { + angleDiff = -angleDiff; + } + + if (angleDiff >= 0x1B58) { + func_80B483E4(pthis, globalCtx); + } else if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 8) != 0) && + EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else { + func_80B45384(pthis); + } +} + +s32 EnZf_ChooseAction(GlobalContext* globalCtx, EnZf* pthis) { + s16 angleToWall; + Actor* explosive; + + angleToWall = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + angleToWall = ABS(angleToWall); + + if (func_800354B4(globalCtx, &pthis->actor, 100.0f, 0x5DC0, 0x2AA8, pthis->actor.shape.rot.y)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if ((pthis->actor.bgCheckFlags & 8) && (ABS(angleToWall) < 0x2EE0) && (pthis->actor.xzDistToPlayer < 80.0f)) { + EnZf_SetupJumpUp(pthis); + return true; + } else if ((pthis->actor.xzDistToPlayer < 90.0f) && ((globalCtx->gameplayFrames % 2) != 0)) { + EnZf_SetupJumpUp(pthis); + return true; + } else { + EnZf_SetupJumpBack(pthis); + return true; + } + } + + explosive = Actor_FindNearby(globalCtx, &pthis->actor, -1, ACTORCAT_EXPLOSIVE, 80.0f); + + if (explosive != NULL) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + if (((pthis->actor.bgCheckFlags & 8) && (angleToWall < 0x2EE0)) || (explosive->id == ACTOR_EN_BOM_CHU)) { + if ((explosive->id == ACTOR_EN_BOM_CHU) && (Actor_WorldDistXYZToActor(&pthis->actor, explosive) < 80.0f) && + ((s16)((pthis->actor.shape.rot.y - explosive->world.rot.y) + 0x8000) < 0x3E80)) { + EnZf_SetupJumpUp(pthis); + return true; + } else { + EnZf_SetupCircleAroundPlayer(pthis, 4.0f); + return true; + } + } else { + EnZf_SetupJumpBack(pthis); + return true; + } + } + return false; +} + +// Setup functions and action functions + +/** + * Set position 300 units above ground and invisible, fade in and drop to ground, fully solid when on ground + */ +void EnZf_SetupDropIn(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfJumpingAnim, 0.0f, 9.0f, Animation_GetLastFrame(&gZfJumpingAnim), + ANIMMODE_LOOP, 0.0f); + + pthis->actor.world.pos.y = pthis->actor.floorHeight + 300.0f; + pthis->alpha = pthis->actor.shape.shadowAlpha = 0; + pthis->unk_3F0 = 10; + pthis->hopAnimIndex = 1; + pthis->action = ENZF_ACTION_DROP_IN; + pthis->actor.bgCheckFlags &= ~2; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + EnZf_SetupAction(pthis, EnZf_DropIn); +} + +void EnZf_DropIn(EnZf* pthis, GlobalContext* globalCtx) { + if (pthis->unk_3F0 == 1) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + pthis->actor.flags |= ACTOR_FLAG_0; + + if (pthis->actor.params == ENZF_TYPE_LIZALFOS_MINIBOSS_A) { + func_800F5ACC(0x38); // Miniboss theme + } + } + + if (pthis->unk_3F0 != 0) { + if (pthis->actor.params != ENZF_TYPE_LIZALFOS_LONE) { + pthis->unk_3F0--; + } else if (pthis->actor.xzDistToPlayer <= 160.0f) { + pthis->unk_3F0 = 0; + pthis->actor.flags |= ACTOR_FLAG_0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + + pthis->actor.world.pos.y = pthis->actor.floorHeight + 300.0f; + } else if (pthis->alpha < 255) { + pthis->alpha += 255 / 5; + } + + if ((pthis->actor.bgCheckFlags & 3) && (pthis->hopAnimIndex != 0)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_ONGND); + Animation_Change(&pthis->skelAnime, &gZfLandingAnim, 1.0f, 0.0f, 17.0f, ANIMMODE_ONCE, 0.0f); + pthis->hopAnimIndex = 0; + pthis->actor.bgCheckFlags &= ~2; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->actor.velocity.y = 0.0f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->alpha = 255; + if (pthis->actor.params > ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // Only miniboss B + EnZf_SetupSheatheSword(pthis, globalCtx); + } else { + func_80B45384(pthis); + } + } + pthis->actor.shape.shadowAlpha = pthis->alpha; +} + +// stop? and choose an action +void func_80B45384(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfCryingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZfCryingAnim), + ANIMMODE_LOOP_INTERP, -4.0f); + pthis->action = ENZF_ACTION_3; + pthis->unk_3F0 = Rand_ZeroOne() * 10.0f + 5.0f; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnZf_SetupAction(pthis, func_80B4543C); +} + +void func_80B4543C(EnZf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 angleToPlayer = (pthis->actor.yawTowardsPlayer - pthis->headRot) - pthis->actor.shape.rot.y; + + angleToPlayer = ABS(angleToPlayer); + SkelAnime_Update(&pthis->skelAnime); + + if (!EnZf_DodgeRangedEngaging(globalCtx, pthis)) { + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + if (pthis->unk_3F4 != 0) { + pthis->unk_3F4--; + if (angleToPlayer >= 0x1FFE) { + return; + } + pthis->unk_3F4 = 0; + + } else if (EnZf_ChooseAction(globalCtx, pthis)) { + return; + } + } + angleToPlayer = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + angleToPlayer = ABS(angleToPlayer); + + if ((pthis->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && (angleToPlayer >= 0x1F40)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + func_80B483E4(pthis, globalCtx); + } else if (pthis->unk_3F0 != 0) { + pthis->unk_3F0--; + } else { + if (Actor_IsFacingPlayer(&pthis->actor, 30 * 0x10000 / 360)) { + if ((pthis->actor.xzDistToPlayer < 200.0f) && (pthis->actor.xzDistToPlayer > 100.0f) && + (Rand_ZeroOne() < 0.3f)) { + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + EnZf_SetupJumpForward(pthis); + } else { + func_80B483E4(pthis, globalCtx); + } + } else if (Rand_ZeroOne() > 0.3f) { + EnZf_SetupApproachPlayer(pthis, globalCtx); + } else { + func_80B483E4(pthis, globalCtx); + } + } else { + func_80B4604C(pthis); + } + + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + } + } +} + +void EnZf_SetupApproachPlayer(EnZf* pthis, GlobalContext* globalCtx) { + Animation_MorphToLoop(&pthis->skelAnime, &gZfWalkingAnim, -4.0f); + pthis->action = ENZF_ACTION_APPROACH_PLAYER; + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + pthis->nextPlatform = EnZf_FindNextPlatformTowardsPlayer(&pthis->actor.world.pos, pthis->curPlatform, + pthis->homePlatform, globalCtx); + pthis->hopAnimIndex = 0; + } + pthis->actor.speedXZ = 0.0f; + EnZf_SetupAction(pthis, EnZf_ApproachPlayer); +} + +void EnZf_ApproachPlayer(EnZf* pthis, GlobalContext* globalCtx) { + s32 sp54; + s32 sp50; + s32 temp; + s16 temp_v1; + s16 sp48 = -1; + f32 sp44 = 350.0f; + f32 sp40 = 0.0f; + Player* player = GET_PLAYER(globalCtx); + s32 sp30; + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + sp48 = EnZf_FindPlatform(&player->actor.world.pos, sp48); + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, sp48); + + if (pthis->actor.world.pos.y >= 420.0f) { + sp44 = 270.0f; + } + } + + if (!EnZf_DodgeRangedEngaging(globalCtx, pthis)) { + if (sp48 != pthis->curPlatform) { + pthis->nextPlatform = EnZf_FindNextPlatformTowardsPlayer(&pthis->actor.world.pos, pthis->curPlatform, + pthis->homePlatform, globalCtx); + + if ((sp48 < 0) && (pthis->nextPlatform == pthis->curPlatform)) { + sp48 = pthis->curPlatform; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer = + Actor_WorldYawTowardPoint(&pthis->actor, &sPlatformPositions[pthis->nextPlatform]); + + temp_v1 = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + temp_v1 = ABS(temp_v1); + + if ((pthis->unk_3F8 && (pthis->actor.speedXZ > 0.0f)) || + ((pthis->actor.bgCheckFlags & 8) && (temp_v1 >= 0x5C19))) { + if ((Actor_WorldDistXZToPoint(&pthis->actor, &sPlatformPositions[pthis->nextPlatform]) < sp44) && + !EnZf_PrimaryFloorCheck(pthis, globalCtx, 191.9956f)) { + EnZf_SetupJumpForward(pthis); + + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.velocity.y = 20.0f; + } + + return; + } else { + pthis->actor.world.rot.y = + Actor_WorldYawTowardPoint(&pthis->actor, &sPlatformPositions[pthis->curPlatform]); + } + } else { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + Math_SmoothStepToF(&pthis->actor.speedXZ, 8.0f, 1.0f, 1.5f, 0.0f); + } + } + } + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + sp40 = 100.0f; + } + + if (pthis->actor.xzDistToPlayer <= (70.0f + sp40)) { + Math_SmoothStepToF(&pthis->actor.speedXZ, -8.0f, 1.0f, 0.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->actor.speedXZ, 8.0f, 1.0f, 0.5f, 0.0f); + } + + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 1.2f; + + temp_v1 = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + temp_v1 = ABS(temp_v1); + + if ((sp48 == pthis->curPlatform) && (pthis->actor.xzDistToPlayer < 150.0f) && (player->swordState != 0) && + (temp_v1 >= 0x1F40)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (Rand_ZeroOne() > 0.7f) { + func_80B483E4(pthis, globalCtx); + return; + } + } + + sp54 = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + sp50 = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + sp30 = (f32)ABS(pthis->skelAnime.playSpeed); + + if (sp48 == pthis->curPlatform) { + if (!Actor_IsFacingPlayer(&pthis->actor, 0x11C7)) { + if (Rand_ZeroOne() > 0.5f) { + func_80B462E4(pthis, globalCtx); + } else { + func_80B45384(pthis); + } + } else if (pthis->actor.xzDistToPlayer < 100.0f) { + if ((Rand_ZeroOne() > 0.05f) && EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else if (Rand_ZeroOne() > 0.5f) { + func_80B483E4(pthis, globalCtx); + } else { + func_80B45384(pthis); + } + } else { + if (pthis->unk_3F8) { + func_80B462E4(pthis, globalCtx); + } else if (Rand_ZeroOne() < 0.1f) { + func_80B45384(pthis); + } + } + } + + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + if (EnZf_ChooseAction(globalCtx, pthis)) { + return; + } + + if ((pthis->actor.xzDistToPlayer < 180.0f) && (pthis->actor.xzDistToPlayer > 160.0f) && + Actor_IsFacingPlayer(&pthis->actor, 0x71C)) { + if (Actor_IsTargeted(globalCtx, &pthis->actor)) { + if (Rand_ZeroOne() < 0.1f) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + EnZf_SetupJumpForward(pthis); + return; + } + } else { + func_80B483E4(pthis, globalCtx); + return; + } + } + } + + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + + if (sp54 != (s32)pthis->skelAnime.curFrame) { + temp = sp30 + sp54; + + if (((sp50 < 2) && (temp >= 4)) || ((sp50 < 32) && (temp >= 34))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_WALK); + } + } + } +} + +void EnZf_SetupJumpForward(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfJumpingAnim, 1.0f, 0.0f, 3.0f, ANIMMODE_ONCE, -3.0f); + pthis->unk_3F0 = 0; + pthis->hopAnimIndex = 1; + pthis->actor.velocity.y = 15.0f; + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + pthis->actor.speedXZ = 16.0f; + } else { + pthis->actor.speedXZ = 10.0f; + } + + pthis->action = ENZF_ACTION_JUMP_FORWARD; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_JUMP); + EnZf_SetupAction(pthis, EnZf_JumpForward); +} + +void EnZf_JumpForward(EnZf* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_3F0 != 0) && (pthis->actor.world.pos.y <= pthis->actor.floorHeight)) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->hopAnimIndex = 0; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->unk_3F0 == 0) { + Animation_Change(&pthis->skelAnime, &gZfLandingAnim, 3.0f, 0.0f, 17.0f, ANIMMODE_ONCE, -3.0f); + pthis->unk_3F0 = 10; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_JUMP); + } else { + pthis->actor.speedXZ = 0.0f; + pthis->hopAnimIndex = 0; + EnZf_SetupApproachPlayer(pthis, globalCtx); + } + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + + if ((pthis->actor.params == ENZF_TYPE_DINOLFOS) && (pthis->actor.bgCheckFlags & 3)) { + if (EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else { + func_80B483E4(pthis, globalCtx); + } + } +} + +void func_80B4604C(EnZf* pthis) { + Animation_MorphToLoop(&pthis->skelAnime, &gZfWalkingAnim, -4.0f); + pthis->action = ENZF_ACTION_6; + EnZf_SetupAction(pthis, func_80B46098); +} + +void func_80B46098(EnZf* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 phi_f2; + Player* player = GET_PLAYER(globalCtx); + s16 temp_v0; + s16 phi_v1; + + if (!EnZf_DodgeRangedEngaging(globalCtx, pthis)) { + if ((pthis->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, pthis)) { + temp_v0 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (temp_v0 > 0) { + phi_v1 = temp_v0 * 0.25f + 2000.0f; + } else { + phi_v1 = temp_v0 * 0.25f - 2000.0f; + } + + pthis->actor.shape.rot.y += phi_v1; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (temp_v0 > 0) { + phi_f2 = phi_v1 * 1.5f; + if (phi_f2 > 2.0f) { + phi_f2 = 2.0f; + } + } else { + phi_f2 = phi_v1 * 1.5f; + if (phi_f2 < -2.0f) { + phi_f2 = -2.0f; + } + } + + pthis->skelAnime.playSpeed = -phi_f2; + SkelAnime_Update(&pthis->skelAnime); + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + if (pthis->curPlatform != EnZf_FindPlatform(&player->actor.world.pos, -1)) { + EnZf_SetupApproachPlayer(pthis, globalCtx); + return; + } + } + + if (Actor_IsFacingPlayer(&pthis->actor, 30 * 0x10000 / 360)) { + if (Rand_ZeroOne() > 0.8f) { + func_80B462E4(pthis, globalCtx); + } else { + EnZf_SetupApproachPlayer(pthis, globalCtx); + } + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + } + } +} + +// Conditional setup function +void func_80B462E4(EnZf* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ || + Actor_TestFloorInDirection(&pthis->actor, globalCtx, 40.0f, (s16)(pthis->actor.shape.rot.y + 0x3FFF)) || + Actor_TestFloorInDirection(&pthis->actor, globalCtx, -40.0f, (s16)(pthis->actor.shape.rot.y + 0x3FFF))) { + Animation_PlayLoop(&pthis->skelAnime, &gZfSidesteppingAnim); + pthis->actor.speedXZ = Rand_CenteredFloat(12.0f); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + pthis->unk_3F0 = Rand_ZeroOne() * 10.0f + 20.0f; + pthis->hopAnimIndex = 0; + pthis->action = ENZF_ACTION_7; + pthis->unk_408 = 0.0f; + EnZf_SetupAction(pthis, func_80B463E4); + } else { + EnZf_SetupApproachPlayer(pthis, globalCtx); + } +} + +void func_80B463E4(EnZf* pthis, GlobalContext* globalCtx) { + s16 angleBehindPlayer; + s16 phi_v0_3; + s32 pad; + s32 curKeyFrame; + s32 prevKeyFrame; + s32 playSpeed; + Player* player = GET_PLAYER(globalCtx); + f32 baseRange = 0.0f; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4000, 1); + + if (!EnZf_DodgeRangedEngaging(globalCtx, pthis) && + ((pthis->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, pthis))) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3A98; + angleBehindPlayer = player->actor.shape.rot.y + 0x8000; + + if (Math_SinS(angleBehindPlayer - pthis->actor.shape.rot.y) >= 0.0f) { + pthis->actor.speedXZ -= 0.25f; + if (pthis->actor.speedXZ < -8.0f) { + pthis->actor.speedXZ = -8.0f; + } + } else if (Math_SinS(angleBehindPlayer - pthis->actor.shape.rot.y) < 0.0f) { // Superfluous check + pthis->actor.speedXZ += 0.25f; + if (pthis->actor.speedXZ > 8.0f) { + pthis->actor.speedXZ = 8.0f; + } + } + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + if (pthis->unk_3F8) { + pthis->actor.speedXZ = -pthis->actor.speedXZ; + } + } else if ((pthis->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, + pthis->actor.shape.rot.y + 0x3FFF)) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + phi_v0_3 = pthis->actor.shape.rot.y + 0x3FFF; + } else { + phi_v0_3 = pthis->actor.shape.rot.y - 0x3FFF; + } + phi_v0_3 = pthis->actor.wallYaw - phi_v0_3; + } else { + pthis->actor.speedXZ *= -0.8f; + phi_v0_3 = 0; + } + + if (ABS(phi_v0_3) > 0x4000) { + pthis->actor.speedXZ *= -0.8f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ += 0.5f; + } + } + } + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + baseRange = 100.0f; + } + + if (pthis->actor.xzDistToPlayer <= (70.0f + baseRange)) { + Math_SmoothStepToF(&pthis->unk_408, -4.0f, 1.0f, 1.5f, 0.0f); + } else if ((90.0f + baseRange) < pthis->actor.xzDistToPlayer) { + Math_SmoothStepToF(&pthis->unk_408, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_408, 0.0f, 1.0f, 5.65f, 0.0f); + } + + if ((pthis->unk_408 != 0.0f) && !EnZf_SecondaryFloorCheck(pthis, globalCtx, pthis->unk_408)) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->unk_408; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->unk_408; + } + + if (ABS(pthis->actor.speedXZ) >= ABS(pthis->unk_408)) { + pthis->skelAnime.playSpeed = pthis->actor.speedXZ * 0.75f; + } else if (pthis->skelAnime.playSpeed < 0.0f) { + pthis->skelAnime.playSpeed = pthis->unk_408 * -0.75f; + } else { + pthis->skelAnime.playSpeed = pthis->unk_408 * 0.75f; + } + + curKeyFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + prevKeyFrame = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + playSpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + if (curKeyFrame != (s32)pthis->skelAnime.curFrame) { + s32 nextKeyFrame = playSpeed + curKeyFrame; + + if (((prevKeyFrame < 14) && (nextKeyFrame > 15)) || ((prevKeyFrame < 27) && (nextKeyFrame > 28))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_WALK); + } + } + + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + + if ((Math_CosS(angleBehindPlayer - pthis->actor.shape.rot.y) < -0.85f) || (pthis->unk_3F0 == 0)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0) && + EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else { + func_80B45384(pthis); + } + } else if (pthis->unk_3F0 != 0) { + pthis->unk_3F0--; + } + } +} + +void EnZf_SetupSlash(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfSlashAnim, 1.25f, 0.0f, Animation_GetLastFrame(&gZfSlashAnim), ANIMMODE_ONCE, + -4.0f); + + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + pthis->skelAnime.playSpeed = 1.75f; + } + + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + pthis->action = ENZF_ACTION_SLASH; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + pthis->actor.speedXZ = 0.0f; + EnZf_SetupAction(pthis, EnZf_Slash); +} + +void EnZf_Slash(EnZf* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 rotDiff; + s16 yawDiff; + + pthis->actor.speedXZ = 0.0f; + + if ((s32)pthis->skelAnime.curFrame == 10) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_ATTACK); + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIndex)); + + if ((pthis->actor.params == ENZF_TYPE_DINOLFOS) && !Actor_IsFacingPlayer(&pthis->actor, 5460)) { + func_80B45384(pthis); + pthis->unk_3F0 = Rand_ZeroOne() * 5.0f + 5.0f; + pthis->unk_3F4 = Rand_ZeroOne() * 20.0f + 100.0f; + } else if ((Rand_ZeroOne() > 0.7f) || (pthis->actor.xzDistToPlayer >= 120.0f)) { + func_80B45384(pthis); + pthis->unk_3F0 = Rand_ZeroOne() * 5.0f + 5.0f; + } else { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + + if (Rand_ZeroOne() > 0.7f) { + func_80B483E4(pthis, globalCtx); + } else { + rotDiff = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + rotDiff = ABS(rotDiff); + + if (rotDiff <= 10000) { + yawDiff = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + yawDiff = ABS(yawDiff); + + if (yawDiff > 16000) { + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + func_80B483E4(pthis, globalCtx); + } else if (player->stateFlags1 & 0x6010) { + if (pthis->actor.isTargeted) { + EnZf_SetupSlash(pthis); + } else { + func_80B483E4(pthis, globalCtx); + } + } else { + EnZf_SetupSlash(pthis); + } + } else { + func_80B483E4(pthis, globalCtx); + } + } + } + } +} + +void EnZf_SetupRecoilFromBlockedSlash(EnZf* pthis) { + f32 frame = pthis->skelAnime.curFrame - 3.0f; + + Animation_Change(&pthis->skelAnime, &gZfSlashAnim, -1.0f, frame, 0.0f, ANIMMODE_ONCE, 0.0f); + pthis->action = ENZF_ACTION_RECOIL_FROM_BLOCKED_SLASH; + EnZf_SetupAction(pthis, EnZf_RecoilFromBlockedSlash); +} + +void EnZf_RecoilFromBlockedSlash(EnZf* pthis, GlobalContext* globalCtx) { + if (SkelAnime_Update(&pthis->skelAnime)) { + if (Rand_ZeroOne() > 0.7f) { + func_80B45384(pthis); + } else if ((Rand_ZeroOne() > 0.2f) && EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else { + func_80B483E4(pthis, globalCtx); + } + } +} + +void EnZf_SetupJumpBack(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfJumpingAnim, -1.0f, 3.0f, 0.0f, ANIMMODE_ONCE, -3.0f); + pthis->unk_3F0 = 0; + pthis->hopAnimIndex = 1; + pthis->action = ENZF_ACTION_JUMP_BACK; + pthis->actor.velocity.y = 15.0f; + pthis->actor.speedXZ = -15.0f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_JUMP); + EnZf_SetupAction(pthis, EnZf_JumpBack); +} + +void EnZf_JumpBack(EnZf* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_3F0 != 0) && (pthis->actor.world.pos.y <= pthis->actor.floorHeight)) { + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->hopAnimIndex = 0; + pthis->actor.velocity.y = 0.0f; + pthis->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->unk_3F0 == 0) { + Animation_Change(&pthis->skelAnime, &gZfLandingAnim, 3.0f, 0.0f, 17.0f, ANIMMODE_ONCE, -3.0f); + pthis->unk_3F0 = 10; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_JUMP); + } else if ((globalCtx->gameplayFrames % 2) != 0) { + func_80B483E4(pthis, globalCtx); + } else { + func_80B45384(pthis); + } + } + + if ((globalCtx->state.frames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } +} + +void EnZf_SetupStunned(EnZf* pthis) { + if ((pthis->actor.bgCheckFlags & 1) && ((pthis->actor.velocity.y == 0.0f) || (pthis->actor.velocity.y == -4.0f))) { + pthis->actor.speedXZ = 0.0f; + pthis->hopAnimIndex = 0; + } else { + pthis->hopAnimIndex = 1; + } + + if (pthis->damageEffect == ENZF_DMGEFF_ICE) { + pthis->iceTimer = 36; + } else { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, &gZfKnockedBackAnim, 0.0f); + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_GOMA_JR_FREEZE); + pthis->action = ENZF_ACTION_STUNNED; + EnZf_SetupAction(pthis, EnZf_Stunned); +} + +void EnZf_Stunned(EnZf* pthis, GlobalContext* globalCtx) { + s16 angleToWall; + + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + pthis->hopAnimIndex = 0; + } + + if ((pthis->actor.colorFilterTimer == 0) && (pthis->actor.bgCheckFlags & 1)) { + if (pthis->actor.colChkInfo.health == 0) { + EnZf_SetupDie(pthis); + } else if ((pthis->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, pthis)) { + if (D_80B4A1B4 != -1) { + func_80B44DC4(pthis, globalCtx); + } else { + angleToWall = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + angleToWall = ABS(angleToWall); + + if ((pthis->actor.params == ENZF_TYPE_DINOLFOS) && (pthis->actor.bgCheckFlags & 8) && + (ABS(angleToWall) < 0x2EE0) && (pthis->actor.xzDistToPlayer < 90.0f)) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnZf_SetupJumpUp(pthis); + } else if (!EnZf_DodgeRangedEngaging(globalCtx, pthis)) { + if (pthis->actor.params != ENZF_TYPE_DINOLFOS) { + func_80B44DC4(pthis, globalCtx); + } else if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) != 0) && + EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else { + func_80B44DC4(pthis, globalCtx); + } + } + } + } + } +} + +void EnZf_SetupSheatheSword(EnZf* pthis, GlobalContext* globalCtx) { + f32 morphFrames = 0.0f; + f32 lastFrame = Animation_GetLastFrame(&gZfSheathingSwordAnim); + + if (pthis->action <= ENZF_ACTION_DAMAGED) { + morphFrames = -4.0f; + } + + Animation_Change(&pthis->skelAnime, &gZfSheathingSwordAnim, 2.0f, 0.0f, lastFrame, ANIMMODE_ONCE, morphFrames); + pthis->action = ENZF_ACTION_SHEATHE_SWORD; + pthis->actor.speedXZ = 0.0f; + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + pthis->nextPlatform = + EnZf_FindNextPlatformAwayFromPlayer(&pthis->actor.world.pos, pthis->curPlatform, pthis->homePlatform, globalCtx); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnZf_SetupAction(pthis, EnZf_SheatheSword); +} + +void EnZf_SheatheSword(EnZf* pthis, GlobalContext* globalCtx) { + s16 yaw = Actor_WorldYawTowardPoint(&pthis->actor, &sPlatformPositions[pthis->nextPlatform]) + 0x8000; + + Math_SmoothStepToS(&pthis->actor.world.rot.y, yaw, 1, 1000, 0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->actor.world.rot.y = yaw - 0x8000; + EnZf_SetupHopAway(pthis, globalCtx); + pthis->swordSheathed = true; + } +} + +void EnZf_SetupHopAndTaunt(EnZf* pthis) { + pthis->hopAnimIndex = 0; + Animation_MorphToPlayOnce(&pthis->skelAnime, sHoppingAnims[0], -4.0f); + pthis->action = ENZF_ACTION_HOP_AND_TAUNT; + pthis->actor.speedXZ = 0.0f; + pthis->unk_40C = 0.0f; + pthis->unk_408 = 0.0f; + EnZf_SetupAction(pthis, EnZf_HopAndTaunt); +} + +void EnZf_HopAndTaunt(EnZf* pthis, GlobalContext* globalCtx) { + f32 lastFrame; + f32 maxDist = 400.0f; + + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 1, 4000, 0); + + // Upstairs + if (pthis->actor.world.pos.y >= 420.0f) { + maxDist = 250.0f; + } + + // If player gets too close, run away + if ((pthis->actor.xzDistToPlayer < maxDist) && (pthis->hopAnimIndex != 1)) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + EnZf_SetupSheatheSword(pthis, globalCtx); + } else { + if (pthis->hopAnimIndex != 1) { + EnZf_DodgeRangedWaiting(globalCtx, pthis); + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + pthis->hopAnimIndex++; // move on to next animation + + // Loop back to beginning + if (pthis->hopAnimIndex >= ARRAY_COUNT(sHoppingAnims)) { + pthis->hopAnimIndex = 0; + } + + if ((pthis->unk_408 != 0.0f) || (pthis->unk_40C != 0.0f)) { + pthis->hopAnimIndex = 1; + } + + lastFrame = Animation_GetLastFrame(sHoppingAnims[pthis->hopAnimIndex]); + + switch (pthis->hopAnimIndex) { + case 0: + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + break; + + case 1: + pthis->actor.velocity.y = pthis->unk_40C + 10.0f; + pthis->actor.speedXZ = pthis->unk_408; + pthis->unk_408 = 0.0f; + pthis->unk_40C = 0.0f; + break; + + case 2: + pthis->actor.world.pos.y = pthis->actor.floorHeight; + lastFrame = 3.0f; + break; + + default: + break; + } + + Animation_Change(&pthis->skelAnime, sHoppingAnims[pthis->hopAnimIndex], 1.5f, 0.0f, lastFrame, ANIMMODE_ONCE, + 0.0f); + } + + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + } +} + +void EnZf_SetupHopAway(EnZf* pthis, GlobalContext* globalCtx) { + pthis->hopAnimIndex = 0; + Animation_PlayOnce(&pthis->skelAnime, sHoppingAnims[0]); + pthis->action = ENZF_ACTION_HOP_AWAY; + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + pthis->nextPlatform = + EnZf_FindNextPlatformAwayFromPlayer(&pthis->actor.world.pos, pthis->curPlatform, pthis->homePlatform, globalCtx); + EnZf_SetupAction(pthis, EnZf_HopAway); +} + +void EnZf_HopAway(EnZf* pthis, GlobalContext* globalCtx) { + f32 sp74; + f32 sp70 = 1.0f; + f32 phi_f20 = 550.0f; + s32 pad; + f32 phi_f20_2; + f32 phi_f0; + s32 pad2; + s16 sp5A; + s32 sp54; + s32 temp_v1_2; + s32 phi_v1; + + sp74 = Actor_WorldDistXZToPoint(&pthis->actor, &sPlatformPositions[pthis->nextPlatform]); + sp54 = pthis->hopAnimIndex; + + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + + // Upstairs + if (pthis->actor.world.pos.y >= 420.0f) { + phi_f20 = 280.0f; + } + + sp5A = Actor_WorldYawTowardPoint(&pthis->actor, &sPlatformPositions[pthis->nextPlatform]); + + switch (pthis->hopAnimIndex) { + case 0: + pthis->actor.world.rot.y = sp5A; + pthis->actor.shape.rot.y = sp5A + 0x8000; + D_80B4AB30 = 0; + pthis->homePlatform = pthis->curPlatform; + temp_v1_2 = !EnZf_PrimaryFloorCheck(pthis, globalCtx, 107.0f); + temp_v1_2 |= !EnZf_PrimaryFloorCheck(pthis, globalCtx, 220.0f) << 1; + pthis->hopAnimIndex++; + + switch (temp_v1_2) { + case 1: + case 1 | 2: + pthis->actor.velocity.y = 12.0f; + if (pthis->actor.bgCheckFlags & 8) { + pthis->actor.velocity.y += 8.0f; + } + + pthis->actor.speedXZ = 8.0f; + break; + + case 2: + pthis->actor.velocity.y = 15.0f; + pthis->actor.speedXZ = 20.0f; + break; + + default: // 0 + phi_f20_2 = 107.0f; + phi_f20_2 += 10.0f; + phi_f0 = 8.0f; + phi_f0 += 1.2f; + + for (phi_v1 = 20; phi_v1 >= 0; phi_v1--, phi_f20_2 += 10.0f, phi_f0 += 1.2f) { + + if (!EnZf_PrimaryFloorCheck(pthis, globalCtx, phi_f20_2)) { + pthis->actor.speedXZ = phi_f0; + pthis->actor.velocity.y = 12.0f; + break; + } + } + if (pthis->actor.speedXZ == 0.0f) { + EnZf_SetupHopAndTaunt(pthis); + } + } + break; + + case 1: + if ((pthis->actor.bgCheckFlags & 2) || (pthis->actor.bgCheckFlags & 1)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_ONGND); + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + pthis->actor.speedXZ = 0.0f; + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &pthis->actor, &pthis->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + + if (phi_f20 <= pthis->actor.xzDistToPlayer) { + EnZf_SetupHopAndTaunt(pthis); + } else if (sp74 < 80.0f) { + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + pthis->nextPlatform = EnZf_FindNextPlatformAwayFromPlayer(&pthis->actor.world.pos, pthis->curPlatform, + pthis->homePlatform, globalCtx); + } + + pthis->hopAnimIndex = 0; + sp70 = 2.0f; + } else { + Math_SmoothStepToS(&pthis->actor.world.rot.y, sp5A, 1, 0xFA0, 0); + pthis->actor.shape.rot.y = pthis->actor.world.rot.y + 0x8000; + D_80B4AB30++; + } + break; + + case 2: + if (pthis->skelAnime.curFrame == pthis->skelAnime.endFrame) { + pthis->hopAnimIndex = 0; + } + break; + } + + if (sp54 != pthis->hopAnimIndex) { + Animation_PlayOnceSetSpeed(&pthis->skelAnime, sHoppingAnims[pthis->hopAnimIndex], sp70); + } + + SkelAnime_Update(&pthis->skelAnime); +} + +void EnZf_SetupDrawSword(EnZf* pthis, GlobalContext* globalCtx) { + Animation_PlayOnce(&pthis->skelAnime, &gZfDrawingSwordAnim); + pthis->actor.world.rot.y += 0x8000; + pthis->action = ENZF_ACTION_DRAW_SWORD; + pthis->actor.speedXZ = 0.0f; + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + pthis->nextPlatform = + EnZf_FindNextPlatformAwayFromPlayer(&pthis->actor.world.pos, pthis->curPlatform, pthis->homePlatform, globalCtx); + EnZf_SetupAction(pthis, EnZf_DrawSword); +} + +void EnZf_DrawSword(EnZf* pthis, GlobalContext* globalCtx) { + s16 yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + + if (pthis->skelAnime.curFrame >= 26.0f) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, yawTowardsPlayer, 1, 6000, 0); + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + pthis->actor.world.rot.y = yawTowardsPlayer; + pthis->hopAnimIndex = -1; + func_80B45384(pthis); + } + + if (pthis->skelAnime.curFrame == 22.0f) { + pthis->swordSheathed = false; + } +} + +void EnZf_SetupDamaged(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfKnockedBackAnim, 1.5f, 0.0f, Animation_GetLastFrame(&gZfKnockedBackAnim), + ANIMMODE_ONCE, -4.0f); + + if ((pthis->actor.bgCheckFlags & 1) && ((pthis->actor.velocity.y == 0.0f) || (pthis->actor.velocity.y == -4.0f))) { + pthis->actor.speedXZ = -4.0f; + pthis->hopAnimIndex = 0; + } else { + pthis->hopAnimIndex = 1; + } + + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + pthis->skelAnime.playSpeed = 4.5f; + } + + if (pthis->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // not miniboss + pthis->actor.world.rot.y = pthis->actor.yawTowardsPlayer; + } + + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DAMAGE); + pthis->action = ENZF_ACTION_DAMAGED; + EnZf_SetupAction(pthis, EnZf_Damaged); +} + +void EnZf_Damaged(EnZf* pthis, GlobalContext* globalCtx) { + s16 wallYawDiff; + + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ += 0.05f; + } + pthis->hopAnimIndex = 0; + } + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4500, 0); + + if (((pthis->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, pthis)) && + SkelAnime_Update(&pthis->skelAnime) && (pthis->actor.bgCheckFlags & 1)) { + + if (D_80B4A1B4 != -1) { + if (pthis->damageEffect == ENZF_DMGEFF_PROJECTILE) { + D_80B4A1B0++; + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (!EnZf_PrimaryFloorCheck(pthis, globalCtx, 135.0f) && (pthis->actor.xzDistToPlayer < 90.0f)) { + EnZf_SetupJumpUp(pthis); + } else if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0)) { + EnZf_SetupSlash(pthis); + } else { + func_80B44DC4(pthis, globalCtx); + } + } + } else { + + wallYawDiff = pthis->actor.wallYaw - pthis->actor.shape.rot.y; + wallYawDiff = ABS(wallYawDiff); + + if ((pthis->actor.params == ENZF_TYPE_DINOLFOS) && (pthis->actor.bgCheckFlags & 8) && + (ABS(wallYawDiff) < 12000) && (pthis->actor.xzDistToPlayer < 90.0f)) { + EnZf_SetupJumpUp(pthis); + } else if (!EnZf_DodgeRangedEngaging(globalCtx, pthis)) { + if (pthis->actor.params != ENZF_TYPE_DINOLFOS) { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if (!EnZf_PrimaryFloorCheck(pthis, globalCtx, 135.0f) && (pthis->actor.xzDistToPlayer < 90.0f)) { + EnZf_SetupJumpUp(pthis); + } else if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0)) { + EnZf_SetupSlash(pthis); + } else { + func_80B44DC4(pthis, globalCtx); + } + } else if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0) && + EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else { + func_80B44DC4(pthis, globalCtx); + } + } + } + } +} + +void EnZf_SetupJumpUp(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfJumpingAnim, 1.0f, 0.0f, 3.0f, ANIMMODE_ONCE, 0.0f); + pthis->unk_3F0 = 0; + pthis->hopAnimIndex = 1; + pthis->action = ENZF_ACTION_JUMP_UP; + pthis->actor.velocity.y = 22.0f; + pthis->actor.speedXZ = 7.5f; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_JUMP); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + EnZf_SetupAction(pthis, EnZf_JumpUp); +} + +void EnZf_JumpUp(EnZf* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4000, 1); + if (pthis->actor.velocity.y >= 5.0f) { + func_800355B8(globalCtx, &pthis->leftFootPos); + func_800355B8(globalCtx, &pthis->rightFootPos); + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->unk_3F0 == 0) { + Animation_Change(&pthis->skelAnime, &gZfSlashAnim, 3.0f, 0.0f, 13.0f, ANIMMODE_ONCE, -4.0f); + pthis->unk_3F0 = 10; + } else if (pthis->actor.bgCheckFlags & 3) { + pthis->actor.velocity.y = 0.0f; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = pthis->actor.yawTowardsPlayer; + pthis->actor.speedXZ = 0.0f; + pthis->actor.world.pos.y = pthis->actor.floorHeight; + EnZf_SetupSlash(pthis); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_ATTACK); + pthis->skelAnime.curFrame = 13.0f; + } + } +} + +// Conditional setup function +void func_80B483E4(EnZf* pthis, GlobalContext* globalCtx) { + s16 playerRotY; + Player* player; + + if ((pthis->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* not miniboss */ || + Actor_TestFloorInDirection(&pthis->actor, globalCtx, 40.0f, (s16)(pthis->actor.shape.rot.y + 0x3FFF)) || + Actor_TestFloorInDirection(&pthis->actor, globalCtx, -40.0f, (s16)(pthis->actor.shape.rot.y + 0x3FFF))) { + Animation_PlayLoop(&pthis->skelAnime, &gZfSidesteppingAnim); + player = GET_PLAYER(globalCtx); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 4000, 1); + playerRotY = player->actor.shape.rot.y; + + if (Math_SinS(playerRotY - pthis->actor.shape.rot.y) >= 0.0f) { + pthis->actor.speedXZ = -6.0f; + } else if (Math_SinS(playerRotY - pthis->actor.shape.rot.y) < 0.0f) { // Superfluous check + pthis->actor.speedXZ = 6.0f; + } + + pthis->unk_408 = 0.0f; + pthis->hopAnimIndex = 0; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + pthis->unk_3F0 = Rand_ZeroOne() * 10.0f + 5.0f; + pthis->action = ENZF_ACTION_CIRCLE_AROUND_PLAYER; + EnZf_SetupAction(pthis, EnZf_CircleAroundPlayer); + } else { + EnZf_SetupApproachPlayer(pthis, globalCtx); + } +} + +void EnZf_CircleAroundPlayer(EnZf* pthis, GlobalContext* globalCtx) { + s16 playerRot; + s16 phi_v0_4; + Player* player = GET_PLAYER(globalCtx); + s32 curKeyFrame; + s32 prevKeyFrame; + s32 playSpeed; + f32 baseRange = 0.0f; + + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.yawTowardsPlayer, 1, 0xBB8, 1); + playerRot = player->actor.shape.rot.y; + + if (pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss + if (pthis->unk_3F8) { + pthis->actor.speedXZ = -pthis->actor.speedXZ; + } + } else if ((pthis->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&pthis->actor, globalCtx, pthis->actor.speedXZ, + pthis->actor.shape.rot.y + 0x3FFF)) { + if (pthis->actor.bgCheckFlags & 8) { + if (pthis->actor.speedXZ >= 0.0f) { + phi_v0_4 = pthis->actor.shape.rot.y + 0x3FFF; + } else { + phi_v0_4 = pthis->actor.shape.rot.y - 0x3FFF; + } + + phi_v0_4 = pthis->actor.wallYaw - phi_v0_4; + } else { + pthis->actor.speedXZ *= -0.8f; + phi_v0_4 = 0; + } + + if (ABS(phi_v0_4) > 0x4000) { + pthis->actor.speedXZ *= -0.8f; + if (pthis->actor.speedXZ < 0.0f) { + pthis->actor.speedXZ -= 0.5f; + } else { + pthis->actor.speedXZ += 0.5f; + } + } + } + + if (Math_SinS(playerRot - pthis->actor.shape.rot.y) >= 0.0f) { + pthis->actor.speedXZ += 0.125f; + } else { + pthis->actor.speedXZ -= 0.125f; + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x4000; + + if (Actor_OtherIsTargeted(globalCtx, &pthis->actor)) { + baseRange = 100.0f; + } + + if (pthis->actor.xzDistToPlayer <= (70.0f + baseRange)) { + Math_SmoothStepToF(&pthis->unk_408, -4.0f, 1.0f, 1.5f, 0.0f); + } else if ((90.0f + baseRange) < pthis->actor.xzDistToPlayer) { + Math_SmoothStepToF(&pthis->unk_408, 4.0f, 1.0f, 1.5f, 0.0f); + } else { + Math_SmoothStepToF(&pthis->unk_408, 0.0f, 1.0f, 5.65f, 0.0f); + } + + if ((pthis->unk_408 != 0.0f) && !EnZf_SecondaryFloorCheck(pthis, globalCtx, pthis->unk_408)) { + pthis->actor.world.pos.x += Math_SinS(pthis->actor.shape.rot.y) * pthis->unk_408; + pthis->actor.world.pos.z += Math_CosS(pthis->actor.shape.rot.y) * pthis->unk_408; + } + + if (ABS(pthis->actor.speedXZ) >= ABS(pthis->unk_408)) { + pthis->skelAnime.playSpeed = -pthis->actor.speedXZ * 0.75f; + } else if (pthis->skelAnime.playSpeed < 0.0f) { + pthis->skelAnime.playSpeed = pthis->unk_408 * -0.75f; + } else { + pthis->skelAnime.playSpeed = pthis->unk_408 * 0.75f; + } + + curKeyFrame = pthis->skelAnime.curFrame; + SkelAnime_Update(&pthis->skelAnime); + prevKeyFrame = pthis->skelAnime.curFrame - ABS(pthis->skelAnime.playSpeed); + playSpeed = (f32)ABS(pthis->skelAnime.playSpeed); + + pthis->curPlatform = EnZf_FindPlatform(&pthis->actor.world.pos, pthis->curPlatform); + + if (EnZf_FindPlatform(&player->actor.world.pos, -1) != pthis->curPlatform) { + pthis->actor.speedXZ = 0.0f; + + if ((pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ && + (D_80B4A1B4 == pthis->actor.params)) { + EnZf_SetupHopAndTaunt(pthis); + } else { + EnZf_SetupApproachPlayer(pthis, globalCtx); + } + } else if ((pthis->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, pthis)) { + if (pthis->unk_3F0 == 0) { + phi_v0_4 = player->actor.shape.rot.y - pthis->actor.shape.rot.y; + + phi_v0_4 = ABS(phi_v0_4); + + if (phi_v0_4 >= 0x3A98) { + if ((pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) && (D_80B4A1B4 == pthis->actor.params)) { + EnZf_SetupHopAndTaunt(pthis); + } else { + func_80B45384(pthis); + pthis->unk_3F0 = Rand_ZeroOne() * 5.0f + 1.0f; + } + } else if ((pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) && (D_80B4A1B4 == pthis->actor.params)) { + EnZf_SetupHopAndTaunt(pthis); + } else { + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if ((pthis->actor.xzDistToPlayer <= 100.0f) && ((globalCtx->gameplayFrames % 4) == 0) && + EnZf_CanAttack(globalCtx, pthis)) { + EnZf_SetupSlash(pthis); + } else if ((pthis->actor.xzDistToPlayer < 280.0f) && (pthis->actor.xzDistToPlayer > 240.0f) && + !EnZf_PrimaryFloorCheck(pthis, globalCtx, 191.9956f) && + ((globalCtx->gameplayFrames % 2) == 0)) { + EnZf_SetupJumpForward(pthis); + } else { + EnZf_SetupApproachPlayer(pthis, globalCtx); + } + } + } else { + pthis->unk_3F0--; + } + if (curKeyFrame != (s32)pthis->skelAnime.curFrame) { + s32 nextKeyFrame = playSpeed + curKeyFrame; + if (((prevKeyFrame < 14) && (nextKeyFrame >= 16)) || ((prevKeyFrame < 27) && (nextKeyFrame >= 29))) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_WALK); + } + } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + } + } +} + +void EnZf_SetupDie(EnZf* pthis) { + Animation_Change(&pthis->skelAnime, &gZfDyingAnim, 1.5f, 0.0f, Animation_GetLastFrame(&gZfDyingAnim), ANIMMODE_ONCE, + -4.0f); + + if ((pthis->actor.bgCheckFlags & 1) && ((pthis->actor.velocity.y == 0.0f) || (pthis->actor.velocity.y == -4.0f))) { + pthis->actor.speedXZ = 0.0f; + pthis->hopAnimIndex = 0; + } else { + pthis->hopAnimIndex = 1; + } + + pthis->action = ENZF_ACTION_DIE; + pthis->actor.flags &= ~ACTOR_FLAG_0; + + if (D_80B4A1B4 != -1) { + if (pthis->actor.prev != NULL) { + ((EnZf*)pthis->actor.prev)->unk_3F4 = 90; + + if (pthis->actor.prev->colChkInfo.health < 3) { + pthis->actor.prev->colChkInfo.health = 3; + } + } else { + ((EnZf*)pthis->actor.next)->unk_3F4 = 90; + + if (pthis->actor.next->colChkInfo.health < 3) { + pthis->actor.next->colChkInfo.health = 3; + } + } + } + + D_80B4A1B0 = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DEAD); + EnZf_SetupAction(pthis, EnZf_Die); +} + +void EnZf_Die(EnZf* pthis, GlobalContext* globalCtx) { + + if (pthis->actor.bgCheckFlags & 2) { + pthis->actor.speedXZ = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 1) { + Math_SmoothStepToF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.15f, 0.0f); + pthis->hopAnimIndex = 0; + } + + if (SkelAnime_Update(&pthis->skelAnime)) { + if (pthis->actor.category != ACTORCAT_PROP) { + if ((pthis->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ && (D_80B4A1B4 == -1)) { + Flags_SetSwitch(globalCtx, pthis->clearFlag); + func_800F5B58(); + } else { + D_80B4A1B4 = -1; + } + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + } + + if (pthis->alpha != 0) { + pthis->actor.shape.shadowAlpha = pthis->alpha -= 5; + + } else { + Actor_Kill(&pthis->actor); + } + } else { + s32 curFrame = pthis->skelAnime.curFrame; + + if ((curFrame == 10) || (curFrame == 18)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_DOWN); + } + } +} + +void EnZf_UpdateHeadRotation(EnZf* pthis, GlobalContext* globalCtx) { + s16 angleTemp; + + if ((pthis->actor.params == ENZF_TYPE_DINOLFOS) && (pthis->action == ENZF_ACTION_3) && (pthis->unk_3F4 != 0)) { + pthis->headRot = Math_SinS(pthis->unk_3F4 * 1400) * 0x2AA8; + } else { + angleTemp = pthis->actor.yawTowardsPlayer; + angleTemp -= (s16)(pthis->headRot + pthis->actor.shape.rot.y); + pthis->headRotTemp = CLAMP(angleTemp, -0x7D0, 0x7D0); + pthis->headRot += pthis->headRotTemp; + pthis->headRot = CLAMP(pthis->headRot, -0x1CD7, 0x1CD7); + } +} + +void EnZf_UpdateDamage(EnZf* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 dropParams; + + if ((pthis->bodyCollider.base.acFlags & AC_HIT) && (pthis->action <= ENZF_ACTION_STUNNED)) { + pthis->bodyCollider.base.acFlags &= ~AC_HIT; + + if (((pthis->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* not miniboss */ || + (D_80B4A1B4 != pthis->actor.params)) && + (pthis->actor.colChkInfo.damageEffect != ENZF_DMGEFF_IMMUNE)) { + pthis->damageEffect = pthis->actor.colChkInfo.damageEffect; + Actor_SetDropFlag(&pthis->actor, &pthis->bodyCollider.info, 0); + + if ((pthis->actor.colChkInfo.damageEffect == ENZF_DMGEFF_STUN) || + (pthis->actor.colChkInfo.damageEffect == ENZF_DMGEFF_ICE)) { + if (pthis->action != ENZF_ACTION_STUNNED) { + Actor_SetColorFilter(&pthis->actor, 0, 120, 0, 80); + Actor_ApplyDamage(&pthis->actor); + EnZf_SetupStunned(pthis); + } + } else { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_RIZA_CRY); + Actor_SetColorFilter(&pthis->actor, 0x4000, 255, 0, 8); + + if (Actor_ApplyDamage(&pthis->actor) == 0) { + dropParams = 0x40; + EnZf_SetupDie(pthis); + + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + dropParams = 0xE0; + } + + Item_DropCollectibleRandom(globalCtx, &pthis->actor, &pthis->actor.world.pos, dropParams); + Enemy_StartFinishingBlow(globalCtx, &pthis->actor); + } else { + if ((D_80B4A1B4 != -1) && ((pthis->actor.colChkInfo.health + pthis->actor.colChkInfo.damage) >= 4) && + (pthis->actor.colChkInfo.health < 4)) { + pthis->damageEffect = ENZF_DMGEFF_PROJECTILE; + } + + EnZf_SetupDamaged(pthis); + } + } + } + } +} + +void EnZf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZf* pthis = (EnZf*)thisx; + s32 pad2; + + EnZf_UpdateDamage(pthis, globalCtx); + if (pthis->actor.colChkInfo.damageEffect != ENZF_DMGEFF_IMMUNE) { + pthis->unk_3F8 = false; + if ((pthis->hopAnimIndex != 1) && (pthis->action != ENZF_ACTION_HOP_AWAY)) { + if (pthis->actor.speedXZ != 0.0f) { + pthis->unk_3F8 = EnZf_PrimaryFloorCheck(pthis, globalCtx, pthis->actor.speedXZ * 1.5f); + } + if (!pthis->unk_3F8) { + pthis->unk_3F8 = EnZf_PrimaryFloorCheck(pthis, globalCtx, 0.0f); + } + } + + if (!pthis->unk_3F8) { + Actor_MoveForward(&pthis->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 25.0f, 30.0f, 60.0f, 0x1D); + + if (!(pthis->actor.bgCheckFlags & 1)) { + pthis->hopAnimIndex = 1; + } + + pthis->actionFunc(pthis, globalCtx); + } + + if (pthis->actor.colChkInfo.health > 0) { + if ((pthis->action != ENZF_ACTION_SLASH) && (pthis->action != ENZF_ACTION_STUNNED)) { + EnZf_UpdateHeadRotation(pthis, globalCtx); + } + + if ((D_80B4A1B0 != 0) && (D_80B4A1B4 != pthis->actor.params)) { + EnZf_SetupSheatheSword(pthis, globalCtx); + D_80B4A1B4 = pthis->actor.params; + D_80B4A1B0 = 0; + + if (pthis->actor.prev != NULL) { + ((EnZf*)pthis->actor.prev)->unk_3F4 = 90; + } else { + ((EnZf*)pthis->actor.next)->unk_3F4 = 90; + } + } + } + + if (pthis->action >= ENZF_ACTION_DIE) { + Math_SmoothStepToS(&pthis->headRot, 0, 1, 2000, 0); + + if (pthis->action <= ENZF_ACTION_HOP_AND_TAUNT) { + if ((pthis->unk_3F4 == 1) && (pthis->actor.bgCheckFlags & 1)) { + if (pthis->actor.colChkInfo.health > 0) { + EnZf_SetupDrawSword(pthis, globalCtx); + } + pthis->unk_3F4--; + } + } + + if (pthis->unk_3F4 >= 2) { + pthis->unk_3F4--; + } + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 40.0f; + + if ((pthis->actor.colChkInfo.health > 0) && (pthis->alpha == 255)) { + Collider_UpdateCylinder(&pthis->actor, &pthis->bodyCollider); + + if ((pthis->actor.world.pos.y == pthis->actor.floorHeight) && (pthis->action <= ENZF_ACTION_DAMAGED)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + + if ((pthis->actor.params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* not miniboss */ || + (D_80B4A1B4 != pthis->actor.params)) { + if ((pthis->actor.colorFilterTimer == 0) || !(pthis->actor.colorFilterParams & 0x4000)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->bodyCollider.base); + } + } + } + + if ((pthis->action == ENZF_ACTION_SLASH) && (pthis->skelAnime.curFrame >= 14.0f) && + (pthis->skelAnime.curFrame <= 20.0f)) { + if (!(pthis->swordCollider.base.atFlags & AT_BOUNCED) && !(pthis->swordCollider.base.acFlags & AC_HIT)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->swordCollider.base); + } else { + pthis->swordCollider.base.atFlags &= ~AT_BOUNCED; + pthis->swordCollider.base.acFlags &= ~AC_HIT; + EnZf_SetupRecoilFromBlockedSlash(pthis); + } + } +} + +s32 EnZf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnZf* pthis = (EnZf*)thisx; + + switch (limbIndex) { + case ENZF_LIMB_HEAD_ROOT: + rot->y -= pthis->headRot; + break; + case ENZF_LIMB_SWORD: + if (pthis->swordSheathed) { + *dList = gZfEmptyHandDL; + } + break; + case ENZF_LIMB_SCABBARD: + if (pthis->swordSheathed) { + *dList = gZfSheathedSwordDL; + } + break; + default: + break; + } + + return false; +} + +void EnZf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + static Vec3f sUnused = { 1100.0f, -700.0f, 0.0f }; + static Vec3f footOffset = { 300.0f, 0.0f, 0.0f }; + static Vec3f D_80B4A2A4 = { 300.0f, -1700.0f, 0.0f }; // Sword tip? + static Vec3f D_80B4A2B0 = { -600.0f, 300.0f, 0.0f }; // Sword hilt? + static Vec3f swordQuadOffset1 = { 0.0f, 1500.0f, 0.0f }; + static Vec3f swordQuadOffset0 = { -600.0f, -3000.0f, 1000.0f }; + static Vec3f swordQuadOffset3 = { -600.0f, -3000.0f, -1000.0f }; + static Vec3f swordQuadOffset2 = { 1500.0f, -3000.0f, 0.0f }; + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f sp54; + Vec3f sp48; + EnZf* pthis = (EnZf*)thisx; + s32 bodyPart = -1; + + if (limbIndex == ENZF_LIMB_SWORD) { + Matrix_MultVec3f(&swordQuadOffset1, &pthis->swordCollider.dim.quad[1]); + Matrix_MultVec3f(&swordQuadOffset0, &pthis->swordCollider.dim.quad[0]); + Matrix_MultVec3f(&swordQuadOffset3, &pthis->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&swordQuadOffset2, &pthis->swordCollider.dim.quad[2]); + Collider_SetQuadVertices(&pthis->swordCollider, &pthis->swordCollider.dim.quad[0], + &pthis->swordCollider.dim.quad[1], &pthis->swordCollider.dim.quad[2], + &pthis->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&D_80B4A2A4, &sp54); + Matrix_MultVec3f(&D_80B4A2B0, &sp48); + + if (pthis->action == ENZF_ACTION_SLASH) { + if (pthis->skelAnime.curFrame < 14.0f) { + EffectBlure_AddSpace((EffectBlure*)Effect_GetByIndex(pthis->blureIndex)); + } else if (pthis->skelAnime.curFrame < 20.0f) { + EffectBlure_AddVertex((EffectBlure*)Effect_GetByIndex(pthis->blureIndex), &sp54, &sp48); + } + } + } else { + Actor_SetFeetPos(&pthis->actor, limbIndex, ENZF_LIMB_LEFT_FOOT, &footOffset, ENZF_LIMB_RIGHT_FOOT, &footOffset); + } + + switch (limbIndex) { + case ENZF_LIMB_LEFT_FOOT: + Matrix_MultVec3f(&footOffset, &pthis->leftFootPos); + break; + case ENZF_LIMB_RIGHT_FOOT: + Matrix_MultVec3f(&footOffset, &pthis->rightFootPos); + break; + } + + if (pthis->iceTimer != 0) { + switch (limbIndex) { + case ENZF_LIMB_HEAD: + bodyPart = 0; + break; + case ENZF_LIMB_NECK: + bodyPart = 1; + break; + case ENZF_LIMB_CHEST_ARMOR: + bodyPart = 2; + break; + case ENZF_LIMB_RIGHT_FOREARM: + bodyPart = 3; + break; + case ENZF_LIMB_LEFT_FOREARM: + bodyPart = 4; + break; + case ENZF_LIMB_TRUNK: + bodyPart = 5; + break; + case ENZF_LIMB_SWORD_ROOT: + bodyPart = 6; + break; + case ENZF_LIMB_RIGHT_SHIN: + bodyPart = 7; + break; + case ENZF_LIMB_LEFT_SHIN_ROOT: + bodyPart = 8; + break; + default: + break; + } + if (bodyPart >= 0) { + Matrix_MultVec3f(&zeroVec, &pthis->bodyPartsPos[bodyPart]); + } + } +} + +static Gfx D_80B4A2F8[] = { + gsSPTexture(0x0A00, 0x0A00, 0, G_TX_RENDERTILE, G_ON), + gsSPEndDisplayList(), +}; + +void EnZf_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZf* pthis = (EnZf*)thisx; + ; // Extra ";" required for matching. Cannot be if (1) {} or the like. Typo? + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zf.c", 3533); + + func_8002EBCC(thisx, globalCtx, 1); + + gSPTexture(D_80B4A2F8, IREG(0), IREG(1), 0, G_TX_RENDERTILE, G_ON); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_80B4A2F8); + + if (pthis->alpha == 255) { + func_80093D18(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_OPA_DISP++, 0x09, &D_80116280[2]); + + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnZf_OverrideLimbDraw, EnZf_PostLimbDraw, pthis, POLY_OPA_DISP); + + if (pthis->iceTimer != 0) { + thisx->colorFilterTimer++; + pthis->iceTimer--; + + if ((pthis->iceTimer % 4) == 0) { + s32 icePosIndex = pthis->iceTimer >> 2; + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, thisx, &pthis->bodyPartsPos[icePosIndex], 150, 150, 150, 250, + 235, 245, 255, 1.4f); + } + if (1) {} + } + } else { // fades out when dead + func_80093D84(globalCtx->state.gfxCtx); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x09, &D_80116280[0]); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + EnZf_OverrideLimbDraw, EnZf_PostLimbDraw, pthis, POLY_XLU_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zf.c", 3601); +} + +void EnZf_SetupCircleAroundPlayer(EnZf* pthis, f32 speed) { + Animation_MorphToLoop(&pthis->skelAnime, &gZfSidesteppingAnim, -1.0f); + pthis->unk_3F0 = Rand_ZeroOne() * 10.0f + 8.0f; + + if (pthis->actor.params == ENZF_TYPE_DINOLFOS) { + pthis->actor.speedXZ = 2.0f * speed; + pthis->unk_3F0 /= 2; + } else { + pthis->actor.speedXZ = speed; + } + + pthis->hopAnimIndex = 0; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + pthis->action = ENZF_ACTION_CIRCLE_AROUND_PLAYER; + EnZf_SetupAction(pthis, EnZf_CircleAroundPlayer); +} + +s32 EnZf_DodgeRangedEngaging(GlobalContext* globalCtx, EnZf* pthis) { + Actor* projectileActor; + s16 yawToProjectile; + s16 phi_t0; + s16 phi_v1; + + projectileActor = Actor_GetProjectileActor(globalCtx, &pthis->actor, 600.0f); + + if (projectileActor != NULL) { + yawToProjectile = + Actor_WorldYawTowardActor(&pthis->actor, projectileActor) - (s16)(u16)(pthis->actor.shape.rot.y); + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + + phi_t0 = 0; + + if (EnZf_PrimaryFloorCheck(pthis, globalCtx, -8.0f)) { + phi_t0 = 1; + } + + if (EnZf_PrimaryFloorCheck(pthis, globalCtx, 8.0f)) { + phi_t0 |= 2; + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + + if ((((pthis->actor.xzDistToPlayer < 90.0f) || (phi_t0 == 3)) && + !EnZf_PrimaryFloorCheck(pthis, globalCtx, 135.0f)) || + (projectileActor->id == ACTOR_ARMS_HOOK)) { + EnZf_SetupJumpUp(pthis); + return true; + } + + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; + + if (phi_t0 == 0) { + phi_v1 = globalCtx->gameplayFrames % 2; + } else { + phi_v1 = phi_t0; + } + + if ((ABS(yawToProjectile) < 0x2000) || (ABS(yawToProjectile) >= 0x6000)) { + if (phi_v1 & 1) { + EnZf_SetupCircleAroundPlayer(pthis, 8.0f); + return true; + } + EnZf_SetupCircleAroundPlayer(pthis, -8.0f); + return true; + } + if (ABS(yawToProjectile) < 0x5FFF) { + if (phi_v1 & 1) { + EnZf_SetupCircleAroundPlayer(pthis, 4.0f); + return true; + } + EnZf_SetupCircleAroundPlayer(pthis, -4.0f); + } + return true; + } + return false; +} + +s32 EnZf_DodgeRangedWaiting(GlobalContext* globalCtx, EnZf* pthis) { + Actor* projectileActor; + s16 yawToProjectile; + s16 phi_t0; + s16 sp1E; + s16 sp1C = 0; + + projectileActor = Actor_GetProjectileActor(globalCtx, &pthis->actor, 600.0f); + if (projectileActor != NULL) { + yawToProjectile = Actor_WorldYawTowardActor(&pthis->actor, projectileActor) - (s16)(u16)pthis->actor.shape.rot.y; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y + 0x3FFF; // Set to move sideways + + phi_t0 = 0; + + if (EnZf_PrimaryFloorCheck(pthis, globalCtx, -70.0f)) { + phi_t0 = 1; + } + + if (EnZf_PrimaryFloorCheck(pthis, globalCtx, 70.0f)) { + phi_t0 |= 2; + } + + pthis->actor.speedXZ = 0.0f; + + if ((ABS(yawToProjectile) < 0x2000) || (ABS(yawToProjectile) >= 0x6000)) { + if (phi_t0 == 0) { + if ((globalCtx->gameplayFrames % 2) != 0) { + sp1E = 6; + } else { + sp1E = -6; + } + } else { + switch (phi_t0) { + case 1: + sp1E = 6; + break; + case 2: + sp1E = -6; + break; + case 1 | 2: + sp1C = 5; + sp1E = 0; + break; + } + } + } else if (ABS(yawToProjectile) < 0x5FFF) { + if (phi_t0 == 0) { + if ((globalCtx->gameplayFrames % 2) != 0) { + sp1E = 6; + } else { + sp1E = -6; + } + } else { + switch (phi_t0) { + case 1: + sp1E = 6; + break; + case 2: + sp1E = -6; + break; + case 1 | 2: + sp1C = 10; + sp1E = 0; + break; + } + } + } + + pthis->unk_408 = sp1E; + pthis->unk_40C = sp1C; + return true; + } + return false; +} diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c deleted file mode 100644 index d92bca388..000000000 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ /dev/null @@ -1,644 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZL1_Z_EN_ZL1_C -#include "actor_common.h" -/* - * File: z_en_zl1.c - * Overlay: ovl_En_Zl1 - * Description: Child Princess Zelda (at window) - */ - -#include "z_en_zl1.h" -#include "objects/object_zl1/object_zl1.h" -#include "def/code_800EC960.h" -#include "def/shrink_window.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) - -void EnZl1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZl1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZl1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZl1_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B4AE18(EnZl1* this); -void func_80B4AF18(EnZl1* this, GlobalContext* globalCtx); -void func_80B4B010(EnZl1* this, GlobalContext* globalCtx); -void func_80B4B240(EnZl1* this, GlobalContext* globalCtx); -void func_80B4B8B4(EnZl1* this, GlobalContext* globalCtx); -void func_80B4BBC4(EnZl1* this, GlobalContext* globalCtx); -void func_80B4BC78(EnZl1* this, GlobalContext* globalCtx); -void func_80B4BF2C(EnZl1* this, GlobalContext* globalCtx); - -extern CutsceneData D_80B4C5D0[]; - -#include "z_en_zl1_camera_data.c" - -const ActorInit En_Zl1_InitVars = { - ACTOR_EN_ZL1, - ACTORCAT_NPC, - FLAGS, - OBJECT_ZL1, - sizeof(EnZl1), - (ActorFunc)EnZl1_Init, - (ActorFunc)EnZl1_Destroy, - (ActorFunc)EnZl1_Update, - (ActorFunc)EnZl1_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 20, 46, 0, { 0, 0, 0 } }, -}; - -static void* D_80B4E61C[] = { - gChildZelda1EyeOpenLookingUpRightTex, - gChildZelda1EyeHalf2Tex, - gChildZelda1EyeClosedTex, - gChildZelda1EyeHalf2Tex, -}; -static void* D_80B4E62C[] = { gChildZelda1MouthNeutralTex }; - -void func_80B4AB40(void) { -} - -void func_80B4AB48(void) { -} - -void EnZl1_Init(Actor* thisx, GlobalContext* globalCtx) { - f32 frameCount; - EnZl1* this = (EnZl1*)thisx; - - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_12118); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gChildZelda1Skel, NULL, NULL, NULL, 0); - Animation_Change(&this->skelAnime, &gChildZelda1Anim_12118, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Actor_SetScale(&this->actor, 0.01f); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - this->actor.targetMode = 0; - - if (gSaveContext.sceneSetupIndex >= 4) { - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); - Animation_Change(&this->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - this->unk_1E6 = 0; - this->actionFunc = func_80B4BC78; - } else if (Flags_GetEventChkInf(9) && Flags_GetEventChkInf(0x25) && Flags_GetEventChkInf(0x37)) { - Actor_Kill(&this->actor); - } else if ((Flags_GetEventChkInf(9) && Flags_GetEventChkInf(0x25)) || - (Flags_GetEventChkInf(9) && Flags_GetEventChkInf(0x37))) { - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); - Animation_Change(&this->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - this->actor.textId = 0x703D; - this->actionFunc = func_80B4AF18; - } else if (Flags_GetEventChkInf(0x40)) { - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); - Animation_Change(&this->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - this->actor.textId = 0x703C; - this->actionFunc = func_80B4AF18; - } else { - this->actor.textId = 0xFFFF; - this->actionFunc = func_80B4B010; - } -} - -void EnZl1_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnZl1* this = (EnZl1*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80B4AE18(EnZl1* this) { - if ((this->skelAnime.animation == &gChildZelda1Anim_10B38) && (this->skelAnime.curFrame < 26.0f)) { - this->unk_1F4 = gChildZelda1EyeOpenLookingRightTex; - this->unk_1F8 = gChildZelda1EyeOpenLookingLeftTex; - this->unk_1FC = 2; - } else { - if (DECR(this->unk_1FC) == 0) { - this->unk_1FC = Rand_S16Offset(0x1E, 0xA); - } - this->unk_1FE = (this->unk_1FC < 4) ? this->unk_1FC : 0; - - this->unk_1F4 = D_80B4E61C[this->unk_1FE]; - this->unk_1F8 = D_80B4E61C[this->unk_1FE]; - this->unk_1EC = D_80B4E62C[this->unk_1F2]; - } -} - -void func_80B4AF18(EnZl1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad; - - func_80038290(globalCtx, &this->actor, &this->unk_200, &this->unk_206, this->actor.focus.pos); - - if (this->unk_1E6 != 0) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->unk_1E6 = 0; - } - } else if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_1E6 = 1; - } else if (this->actor.world.pos.y <= player->actor.world.pos.y) { - func_8002F2F4(&this->actor, globalCtx); - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); -} - -void func_80B4B010(EnZl1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 pad2; - s32 pad3; - s32 pad; - Vec3f vec1 = { -460.0f, 118.0f, 0.0f }; - Vec3f vec2 = { -406.0f, 110.0f, 0.0f }; - Vec3f playerPos = { -398.0f, 84.0f, 0.0f }; - s16 rotDiff; - - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - Animation_Change(&this->skelAnime, &gChildZelda1Anim_10B38, 1.0f, 0.0f, - Animation_GetLastFrame(&gChildZelda1Anim_10B38), ANIMMODE_ONCE_INTERP, -10.0f); - this->unk_1E8 = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->unk_1E8, CAM_STAT_ACTIVE); - func_800C0808(globalCtx, this->unk_1E8, player, CAM_SET_FREE0); - globalCtx->envCtx.screenFillColor[0] = 255; - globalCtx->envCtx.screenFillColor[1] = 255; - globalCtx->envCtx.screenFillColor[2] = 255; - globalCtx->envCtx.screenFillColor[3] = 24; - globalCtx->envCtx.fillScreen = true; - Gameplay_CameraSetAtEye(globalCtx, this->unk_1E8, &vec1, &vec2); - Gameplay_CameraSetFov(globalCtx, this->unk_1E8, 30.0f); - ShrinkWindow_SetVal(0x20); - Interface_ChangeAlpha(2); - player->actor.world.pos = playerPos; - player->actor.speedXZ = 0.0f; - this->unk_1E2 = 0; - this->actionFunc = func_80B4B240; - Audio_PlayFanfare(NA_BGM_APPEAR); - } else { - if (1) {} // necessary to match - rotDiff = ABS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y); - if ((rotDiff < 0x238E) && !(player->actor.world.pos.y < this->actor.world.pos.y)) { - func_8002F2F4(&this->actor, globalCtx); - } - } -} - -void func_80B4B240(EnZl1* this, GlobalContext* globalCtx) { - Vec3f sp74 = { -427.0f, 108.0, 26.0 }; - Vec3f sp68 = { -340.0f, 108.0f, 98.0f }; - s32 pad; - Vec3f sp58 = { -434.0f, 84.0f, 0.0f }; - u8 sp54[] = { 0x00, 0x00, 0x02 }; - s32 pad2; - Player* player = GET_PLAYER(globalCtx); - AnimationHeader* animHeaderSeg = NULL; - MessageContext* msgCtx = &globalCtx->msgCtx; - f32 frameCount; - s32 sp3C = 0; - - switch (this->unk_1E2) { - case 0: - switch ((s16)this->skelAnime.curFrame) { - case 14: - this->unk_1E4 = 0; - break; - case 15: - if (DECR(this->unk_1E4) != 0) { - this->skelAnime.curFrame = 15.0f; - } - break; - case 64: - animHeaderSeg = &gChildZelda1Anim_11348; - sp3C = 1; - this->actor.textId = 0x702E; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_1E2++; - break; - } - break; - case 1: - if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - globalCtx->envCtx.fillScreen = false; - Gameplay_CameraSetAtEye(globalCtx, this->unk_1E8, &sp74, &sp68); - Gameplay_CameraSetFov(globalCtx, this->unk_1E8, 25.0f); - player->actor.world.pos = sp58; - this->actor.textId = 0x702F; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2++; - } - break; - case 2: - if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - if (msgCtx->choiceIndex == 0) { - animHeaderSeg = &gChildZelda1Anim_13F10; - sp3C = 2; - this->unk_1E2++; - } else { - animHeaderSeg = &gChildZelda1Anim_116E4; - sp3C = 2; - this->unk_1E2 = 6; - } - } - break; - case 3: - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_13F10); - if (this->skelAnime.curFrame == frameCount) { - animHeaderSeg = &gChildZelda1Anim_143A8; - sp3C = 1; - this->actor.textId = 0x7032; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2++; - } - break; - case 4: - if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - if (msgCtx->choiceIndex == 0) { - animHeaderSeg = &gChildZelda1Anim_132D8; - sp3C = 2; - this->unk_1E2 = 9; - } else { - this->actor.textId = 0x7034; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2++; - } - } - break; - case 5: - if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actor.textId = 0x7033; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2--; - } - break; - case 6: - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_116E4); - if (this->skelAnime.curFrame == frameCount) { - animHeaderSeg = &gChildZelda1Anim_12B88; - sp3C = 1; - this->actor.textId = 0x7031; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2++; - } - break; - case 7: - if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actor.textId = 0x7030; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2++; - } - break; - case 8: - if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - if (msgCtx->choiceIndex == 0) { - animHeaderSeg = &gChildZelda1Anim_138E0; - sp3C = 2; - this->unk_1E2 = 3; - } else { - this->actor.textId = 0x7031; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2--; - } - } - break; - case 9: - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_132D8); - if (this->skelAnime.curFrame == frameCount) { - animHeaderSeg = &gChildZelda1Anim_00438; - sp3C = 1; - globalCtx->csCtx.segment = D_80B4C5D0; - gSaveContext.cutsceneTrigger = 1; - this->actionFunc = func_80B4B8B4; - this->unk_1E2++; - } - break; - } - if (sp3C != 0) { - frameCount = Animation_GetLastFrame(animHeaderSeg); - Animation_Change(&this->skelAnime, animHeaderSeg, 1.0f, 0.0f, frameCount, sp54[sp3C], -10.0f); - } - func_80038290(globalCtx, &this->actor, &this->unk_200, &this->unk_206, this->actor.focus.pos); -} - -void func_80B4B7F4(CsCmdActorAction* npcAction, Vec3f* pos) { - pos->x = npcAction->startPos.x; - pos->y = npcAction->startPos.y; - pos->z = npcAction->startPos.z; -} - -void func_80B4B834(CsCmdActorAction* npcAction, Vec3f* pos) { - pos->x = npcAction->endPos.x; - pos->y = npcAction->endPos.y; - pos->z = npcAction->endPos.z; -} - -void func_80B4B874(EnZl1* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 1; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); -} - -void func_80B4B8B4(EnZl1* this, GlobalContext* globalCtx) { - AnimationHeader* spB0[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &gChildZelda1Anim_12B04, - &gChildZelda1Anim_12118, - &gChildZelda1Anim_10B38, - }; - u8 spA4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, - }; - Vec3f sp98 = { -421.0f, 143.0f, -5.0f }; - Vec3f sp8C = { -512.0f, 105.0f, -4.0f }; - s32 pad2; - f32 actionLength; - CsCmdActorAction* npcAction; - Vec3f sp74; - Vec3f sp68; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - s32 pad; - f32 frameCount; - Vec3f sp48; - - SkelAnime_Update(&this->skelAnime); - func_80B4B874(this, globalCtx); - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - this->actionFunc = func_80B4BBC4; - return; - } - - npcAction = globalCtx->csCtx.npcActions[0]; - if (npcAction != NULL) { - func_80B4B7F4(npcAction, &sp74); - func_80B4B834(npcAction, &sp68); - if (this->unk_1E6 == 0) { - sp48 = sp74; - this->actor.home.pos = sp48; - this->actor.world.pos = sp48; - } - if (this->unk_1E6 != npcAction->action) { - frameCount = Animation_GetLastFrame(spB0[npcAction->action]); - Animation_Change(&this->skelAnime, spB0[npcAction->action], 1.0f, 0.0f, frameCount, spA4[npcAction->action], - -10.0f); - this->unk_1E6 = npcAction->action; - } - this->actor.velocity = velocity; - if (globalCtx->csCtx.frames < npcAction->endFrame) { - actionLength = npcAction->endFrame - npcAction->startFrame; - this->actor.velocity.x = (sp68.x - sp74.x) / actionLength; - this->actor.velocity.y = (sp68.y - sp74.y) / actionLength; - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } - this->actor.velocity.z = (sp68.z - sp74.z) / actionLength; - } - func_80038290(globalCtx, &this->actor, &this->unk_200, &this->unk_206, this->actor.focus.pos); - Gameplay_CameraSetAtEye(globalCtx, this->unk_1E8, &sp98, &sp8C); - Gameplay_CameraSetFov(globalCtx, this->unk_1E8, 70.0f); - } -} - -void func_80B4BBC4(EnZl1* this, GlobalContext* globalCtx) { - s32 pad; - f32 frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); - Player* player = GET_PLAYER(globalCtx); - - Animation_Change(&this->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - func_8002DF54(globalCtx, &this->actor, 1); - func_8002F7DC(&player->actor, NA_SE_VO_LI_SURPRISE_KID); - this->actor.textId = 0x7039; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - this->unk_1E2 = 0; - this->actionFunc = func_80B4BF2C; -} - -void func_80B4BC78(EnZl1* this, GlobalContext* globalCtx) { - AnimationHeader* sp90[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &gChildZelda1Anim_12B04, - &gChildZelda1Anim_12118, - &gChildZelda1Anim_10B38, - }; - u8 sp84[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, - }; - s32 pad2; - f32 actionLength; - Vec3f sp70; - Vec3f sp64; - Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - CsCmdActorAction* npcAction; - s32 pad; - f32 frameCount; - - if (SkelAnime_Update(&this->skelAnime) && (this->skelAnime.animation == &gChildZelda1Anim_10B38)) { - frameCount = Animation_GetLastFrame(&gChildZelda1Anim_11348); - Animation_Change(&this->skelAnime, &gChildZelda1Anim_11348, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -10.0f); - } - func_80B4B874(this, globalCtx); - npcAction = globalCtx->csCtx.npcActions[0]; - if (npcAction != NULL) { - func_80B4B7F4(npcAction, &sp70); - func_80B4B834(npcAction, &sp64); - if (this->unk_1E6 == 0) { - this->actor.world.pos = this->actor.home.pos = sp70; - } - - if (this->unk_1E6 != npcAction->action) { - frameCount = Animation_GetLastFrame(sp90[npcAction->action]); - Animation_Change(&this->skelAnime, sp90[npcAction->action], 1.0f, 0.0f, frameCount, sp84[npcAction->action], - -10.0f); - this->unk_1E6 = npcAction->action; - } - this->actor.velocity = velocity; - if (globalCtx->csCtx.frames < npcAction->endFrame) { - actionLength = npcAction->endFrame - npcAction->startFrame; - this->actor.velocity.x = (sp64.x - sp70.x) / actionLength; - this->actor.velocity.y = (sp64.y - sp70.y) / actionLength; - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } - this->actor.velocity.z = (sp64.z - sp70.z) / actionLength; - } - } -} - -void func_80B4BF2C(EnZl1* this, GlobalContext* globalCtx) { - s32 pad; - MessageContext* msgCtx = &globalCtx->msgCtx; - Player* player = GET_PLAYER(globalCtx); - - switch (this->unk_1E2) { - case 0: - if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - if (msgCtx->choiceIndex == 0) { - this->actor.textId = 0x703B; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2++; - } else { - this->actor.textId = 0x703A; - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_1E2 = 0; - } - } - break; - case 1: - if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - this->actor.textId = 0xFFFF; - globalCtx->talkWithPlayer(globalCtx, &this->actor); - func_8002F434(&this->actor, globalCtx, GI_LETTER_ZELDA, 120.0f, 10.0f); - globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; - globalCtx->msgCtx.stateTimer = 4; - this->unk_1E2++; - } else { - break; - } - case 2: - if (Actor_HasParent(&this->actor, globalCtx)) { - Gameplay_CopyCamera(globalCtx, MAIN_CAM, this->unk_1E8); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, this->unk_1E8); - this->actor.parent = NULL; - this->unk_1E2++; - } else { - func_8002F434(&this->actor, globalCtx, GI_LETTER_ZELDA, 120.0f, 10.0f); - } - break; - case 3: - if ((Message_GetState(msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { - this->actor.textId = 0x703C; - Message_ContinueTextbox(globalCtx, this->actor.textId); - Flags_SetEventChkInf(0x40); - this->unk_1E2 = 6; - } - break; - case 4: - if (player->actor.world.pos.y < this->actor.world.pos.y) { - break; - } else { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->unk_1E2++; - } else { - func_8002F2F4(&this->actor, globalCtx); - } - } - break; - case 5: - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->unk_1E2--; - } - break; - case 6: - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_8002DF54(globalCtx, &this->actor, 7); - Interface_ChangeAlpha(50); - this->actor.flags &= ~ACTOR_FLAG_8; - this->unk_1E2 = 4; - } - break; - } - func_80038290(globalCtx, &this->actor, &this->unk_200, &this->unk_206, this->actor.focus.pos); -} - -void EnZl1_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnZl1* this = (EnZl1*)thisx; - - if ((this->actionFunc != func_80B4B8B4) && (this->actionFunc != func_80B4BC78)) { - SkelAnime_Update(&this->skelAnime); - } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 5); - this->actionFunc(this, globalCtx); - if (this->actionFunc != func_80B4B8B4) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 0xA, 0x3E8, 1); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 0xA, 0x3E8, 1); - Math_SmoothStepToS(&this->actor.shape.rot.z, this->actor.world.rot.z, 0xA, 0x3E8, 1); - func_80B4AE18(this); -} - -s32 EnZl1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnZl1* this = (EnZl1*)thisx; - - if ((limbIndex == 4) || (limbIndex == 3) || (limbIndex == 6) || (limbIndex == 5)) { - *dList = NULL; - } - - if (limbIndex != 10) { - if (limbIndex == 17) { - rot->x += this->unk_200.y; - rot->y += this->unk_200.z; - rot->z += this->unk_200.x; - } - } else { - rot->x += this->unk_206.y; - rot->y += this->unk_206.x; - rot->z += this->unk_206.z; - } - return 0; -} - -void EnZl1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - Vec3f vec = { 0.0f, 0.0f, 0.0f }; - EnZl1* this = (EnZl1*)thisx; - - if (limbIndex == 17) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); - } -} - -void EnZl1_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnZl1* this = (EnZl1*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_girlB.c", 2011); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(this->unk_1F4)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(this->unk_1F8)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(this->unk_1EC)); - - func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnZl1_OverrideLimbDraw, EnZl1_PostLimbDraw, this); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_girlB.c", 2046); -} diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.cpp b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.cpp new file mode 100644 index 000000000..515ee937a --- /dev/null +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.cpp @@ -0,0 +1,644 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZL1_Z_EN_ZL1_C +#include "actor_common.h" +/* + * File: z_en_zl1.c + * Overlay: ovl_En_Zl1 + * Description: Child Princess Zelda (at window) + */ + +#include "z_en_zl1.h" +#include "objects/object_zl1/object_zl1.h" +#include "def/code_800EC960.h" +#include "def/shrink_window.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) + +void EnZl1_Init(Actor* thisx, GlobalContext* globalCtx); +void EnZl1_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnZl1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnZl1_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B4AE18(EnZl1* pthis); +void func_80B4AF18(EnZl1* pthis, GlobalContext* globalCtx); +void func_80B4B010(EnZl1* pthis, GlobalContext* globalCtx); +void func_80B4B240(EnZl1* pthis, GlobalContext* globalCtx); +void func_80B4B8B4(EnZl1* pthis, GlobalContext* globalCtx); +void func_80B4BBC4(EnZl1* pthis, GlobalContext* globalCtx); +void func_80B4BC78(EnZl1* pthis, GlobalContext* globalCtx); +void func_80B4BF2C(EnZl1* pthis, GlobalContext* globalCtx); + +extern CutsceneData D_80B4C5D0[]; + +#include "z_en_zl1_camera_data.cpp" + +ActorInit En_Zl1_InitVars = { + ACTOR_EN_ZL1, + ACTORCAT_NPC, + FLAGS, + OBJECT_ZL1, + sizeof(EnZl1), + (ActorFunc)EnZl1_Init, + (ActorFunc)EnZl1_Destroy, + (ActorFunc)EnZl1_Update, + (ActorFunc)EnZl1_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 46, 0, { 0, 0, 0 } }, +}; + +static void* D_80B4E61C[] = { + gChildZelda1EyeOpenLookingUpRightTex, + gChildZelda1EyeHalf2Tex, + gChildZelda1EyeClosedTex, + gChildZelda1EyeHalf2Tex, +}; +static void* D_80B4E62C[] = { gChildZelda1MouthNeutralTex }; + +void func_80B4AB40(void) { +} + +void func_80B4AB48(void) { +} + +void EnZl1_Init(Actor* thisx, GlobalContext* globalCtx) { + f32 frameCount; + EnZl1* pthis = (EnZl1*)thisx; + + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_12118); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gChildZelda1Skel, NULL, NULL, NULL, 0); + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_12118, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Actor_SetScale(&pthis->actor, 0.01f); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + pthis->actor.targetMode = 0; + + if (gSaveContext.sceneSetupIndex >= 4) { + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + pthis->unk_1E6 = 0; + pthis->actionFunc = func_80B4BC78; + } else if (Flags_GetEventChkInf(9) && Flags_GetEventChkInf(0x25) && Flags_GetEventChkInf(0x37)) { + Actor_Kill(&pthis->actor); + } else if ((Flags_GetEventChkInf(9) && Flags_GetEventChkInf(0x25)) || + (Flags_GetEventChkInf(9) && Flags_GetEventChkInf(0x37))) { + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + pthis->actor.textId = 0x703D; + pthis->actionFunc = func_80B4AF18; + } else if (Flags_GetEventChkInf(0x40)) { + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + pthis->actor.textId = 0x703C; + pthis->actionFunc = func_80B4AF18; + } else { + pthis->actor.textId = 0xFFFF; + pthis->actionFunc = func_80B4B010; + } +} + +void EnZl1_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZl1* pthis = (EnZl1*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80B4AE18(EnZl1* pthis) { + if ((pthis->skelAnime.animation == &gChildZelda1Anim_10B38) && (pthis->skelAnime.curFrame < 26.0f)) { + pthis->unk_1F4 = gChildZelda1EyeOpenLookingRightTex; + pthis->unk_1F8 = gChildZelda1EyeOpenLookingLeftTex; + pthis->unk_1FC = 2; + } else { + if (DECR(pthis->unk_1FC) == 0) { + pthis->unk_1FC = Rand_S16Offset(0x1E, 0xA); + } + pthis->unk_1FE = (pthis->unk_1FC < 4) ? pthis->unk_1FC : 0; + + pthis->unk_1F4 = D_80B4E61C[pthis->unk_1FE]; + pthis->unk_1F8 = D_80B4E61C[pthis->unk_1FE]; + pthis->unk_1EC = D_80B4E62C[pthis->unk_1F2]; + } +} + +void func_80B4AF18(EnZl1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + func_80038290(globalCtx, &pthis->actor, &pthis->unk_200, &pthis->unk_206, pthis->actor.focus.pos); + + if (pthis->unk_1E6 != 0) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->unk_1E6 = 0; + } + } else if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_1E6 = 1; + } else if (pthis->actor.world.pos.y <= player->actor.world.pos.y) { + func_8002F2F4(&pthis->actor, globalCtx); + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); +} + +void func_80B4B010(EnZl1* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + s32 pad3; + s32 pad; + Vec3f vec1 = { -460.0f, 118.0f, 0.0f }; + Vec3f vec2 = { -406.0f, 110.0f, 0.0f }; + Vec3f playerPos = { -398.0f, 84.0f, 0.0f }; + s16 rotDiff; + + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_10B38, 1.0f, 0.0f, + Animation_GetLastFrame(&gChildZelda1Anim_10B38), ANIMMODE_ONCE_INTERP, -10.0f); + pthis->unk_1E8 = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->unk_1E8, CAM_STAT_ACTIVE); + func_800C0808(globalCtx, pthis->unk_1E8, player, CAM_SET_FREE0); + globalCtx->envCtx.screenFillColor[0] = 255; + globalCtx->envCtx.screenFillColor[1] = 255; + globalCtx->envCtx.screenFillColor[2] = 255; + globalCtx->envCtx.screenFillColor[3] = 24; + globalCtx->envCtx.fillScreen = true; + Gameplay_CameraSetAtEye(globalCtx, pthis->unk_1E8, &vec1, &vec2); + Gameplay_CameraSetFov(globalCtx, pthis->unk_1E8, 30.0f); + ShrinkWindow_SetVal(0x20); + Interface_ChangeAlpha(2); + player->actor.world.pos = playerPos; + player->actor.speedXZ = 0.0f; + pthis->unk_1E2 = 0; + pthis->actionFunc = func_80B4B240; + Audio_PlayFanfare(NA_BGM_APPEAR); + } else { + if (1) {} // necessary to match + rotDiff = ABS(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y); + if ((rotDiff < 0x238E) && !(player->actor.world.pos.y < pthis->actor.world.pos.y)) { + func_8002F2F4(&pthis->actor, globalCtx); + } + } +} + +void func_80B4B240(EnZl1* pthis, GlobalContext* globalCtx) { + Vec3f sp74 = { -427.0f, 108.0, 26.0 }; + Vec3f sp68 = { -340.0f, 108.0f, 98.0f }; + s32 pad; + Vec3f sp58 = { -434.0f, 84.0f, 0.0f }; + u8 sp54[] = { 0x00, 0x00, 0x02 }; + s32 pad2; + Player* player = GET_PLAYER(globalCtx); + AnimationHeader* animHeaderSeg = NULL; + MessageContext* msgCtx = &globalCtx->msgCtx; + f32 frameCount; + s32 sp3C = 0; + + switch (pthis->unk_1E2) { + case 0: + switch ((s16)pthis->skelAnime.curFrame) { + case 14: + pthis->unk_1E4 = 0; + break; + case 15: + if (DECR(pthis->unk_1E4) != 0) { + pthis->skelAnime.curFrame = 15.0f; + } + break; + case 64: + animHeaderSeg = &gChildZelda1Anim_11348; + sp3C = 1; + pthis->actor.textId = 0x702E; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_1E2++; + break; + } + break; + case 1: + if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + globalCtx->envCtx.fillScreen = false; + Gameplay_CameraSetAtEye(globalCtx, pthis->unk_1E8, &sp74, &sp68); + Gameplay_CameraSetFov(globalCtx, pthis->unk_1E8, 25.0f); + player->actor.world.pos = sp58; + pthis->actor.textId = 0x702F; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2++; + } + break; + case 2: + if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + if (msgCtx->choiceIndex == 0) { + animHeaderSeg = &gChildZelda1Anim_13F10; + sp3C = 2; + pthis->unk_1E2++; + } else { + animHeaderSeg = &gChildZelda1Anim_116E4; + sp3C = 2; + pthis->unk_1E2 = 6; + } + } + break; + case 3: + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_13F10); + if (pthis->skelAnime.curFrame == frameCount) { + animHeaderSeg = &gChildZelda1Anim_143A8; + sp3C = 1; + pthis->actor.textId = 0x7032; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2++; + } + break; + case 4: + if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + if (msgCtx->choiceIndex == 0) { + animHeaderSeg = &gChildZelda1Anim_132D8; + sp3C = 2; + pthis->unk_1E2 = 9; + } else { + pthis->actor.textId = 0x7034; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2++; + } + } + break; + case 5: + if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.textId = 0x7033; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2--; + } + break; + case 6: + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_116E4); + if (pthis->skelAnime.curFrame == frameCount) { + animHeaderSeg = &gChildZelda1Anim_12B88; + sp3C = 1; + pthis->actor.textId = 0x7031; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2++; + } + break; + case 7: + if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.textId = 0x7030; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2++; + } + break; + case 8: + if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + if (msgCtx->choiceIndex == 0) { + animHeaderSeg = &gChildZelda1Anim_138E0; + sp3C = 2; + pthis->unk_1E2 = 3; + } else { + pthis->actor.textId = 0x7031; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2--; + } + } + break; + case 9: + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_132D8); + if (pthis->skelAnime.curFrame == frameCount) { + animHeaderSeg = &gChildZelda1Anim_00438; + sp3C = 1; + globalCtx->csCtx.segment = D_80B4C5D0; + gSaveContext.cutsceneTrigger = 1; + pthis->actionFunc = func_80B4B8B4; + pthis->unk_1E2++; + } + break; + } + if (sp3C != 0) { + frameCount = Animation_GetLastFrame(animHeaderSeg); + Animation_Change(&pthis->skelAnime, animHeaderSeg, 1.0f, 0.0f, frameCount, sp54[sp3C], -10.0f); + } + func_80038290(globalCtx, &pthis->actor, &pthis->unk_200, &pthis->unk_206, pthis->actor.focus.pos); +} + +void func_80B4B7F4(CsCmdActorAction* npcAction, Vec3f* pos) { + pos->x = npcAction->startPos.x; + pos->y = npcAction->startPos.y; + pos->z = npcAction->startPos.z; +} + +void func_80B4B834(CsCmdActorAction* npcAction, Vec3f* pos) { + pos->x = npcAction->endPos.x; + pos->y = npcAction->endPos.y; + pos->z = npcAction->endPos.z; +} + +void func_80B4B874(EnZl1* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 1; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); +} + +void func_80B4B8B4(EnZl1* pthis, GlobalContext* globalCtx) { + AnimationHeader* spB0[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &gChildZelda1Anim_12B04, + &gChildZelda1Anim_12118, + &gChildZelda1Anim_10B38, + }; + u8 spA4[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, + }; + Vec3f sp98 = { -421.0f, 143.0f, -5.0f }; + Vec3f sp8C = { -512.0f, 105.0f, -4.0f }; + s32 pad2; + f32 actionLength; + CsCmdActorAction* npcAction; + Vec3f sp74; + Vec3f sp68; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + s32 pad; + f32 frameCount; + Vec3f sp48; + + SkelAnime_Update(&pthis->skelAnime); + func_80B4B874(pthis, globalCtx); + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + pthis->actionFunc = func_80B4BBC4; + return; + } + + npcAction = globalCtx->csCtx.npcActions[0]; + if (npcAction != NULL) { + func_80B4B7F4(npcAction, &sp74); + func_80B4B834(npcAction, &sp68); + if (pthis->unk_1E6 == 0) { + sp48 = sp74; + pthis->actor.home.pos = sp48; + pthis->actor.world.pos = sp48; + } + if (pthis->unk_1E6 != npcAction->action) { + frameCount = Animation_GetLastFrame(spB0[npcAction->action]); + Animation_Change(&pthis->skelAnime, spB0[npcAction->action], 1.0f, 0.0f, frameCount, spA4[npcAction->action], + -10.0f); + pthis->unk_1E6 = npcAction->action; + } + pthis->actor.velocity = velocity; + if (globalCtx->csCtx.frames < npcAction->endFrame) { + actionLength = npcAction->endFrame - npcAction->startFrame; + pthis->actor.velocity.x = (sp68.x - sp74.x) / actionLength; + pthis->actor.velocity.y = (sp68.y - sp74.y) / actionLength; + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } + pthis->actor.velocity.z = (sp68.z - sp74.z) / actionLength; + } + func_80038290(globalCtx, &pthis->actor, &pthis->unk_200, &pthis->unk_206, pthis->actor.focus.pos); + Gameplay_CameraSetAtEye(globalCtx, pthis->unk_1E8, &sp98, &sp8C); + Gameplay_CameraSetFov(globalCtx, pthis->unk_1E8, 70.0f); + } +} + +void func_80B4BBC4(EnZl1* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); + Player* player = GET_PLAYER(globalCtx); + + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + func_8002DF54(globalCtx, &pthis->actor, 1); + func_8002F7DC(&player->actor, NA_SE_VO_LI_SURPRISE_KID); + pthis->actor.textId = 0x7039; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + pthis->unk_1E2 = 0; + pthis->actionFunc = func_80B4BF2C; +} + +void func_80B4BC78(EnZl1* pthis, GlobalContext* globalCtx) { + AnimationHeader* sp90[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &gChildZelda1Anim_12B04, + &gChildZelda1Anim_12118, + &gChildZelda1Anim_10B38, + }; + u8 sp84[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, + }; + s32 pad2; + f32 actionLength; + Vec3f sp70; + Vec3f sp64; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + CsCmdActorAction* npcAction; + s32 pad; + f32 frameCount; + + if (SkelAnime_Update(&pthis->skelAnime) && (pthis->skelAnime.animation == &gChildZelda1Anim_10B38)) { + frameCount = Animation_GetLastFrame(&gChildZelda1Anim_11348); + Animation_Change(&pthis->skelAnime, &gChildZelda1Anim_11348, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, -10.0f); + } + func_80B4B874(pthis, globalCtx); + npcAction = globalCtx->csCtx.npcActions[0]; + if (npcAction != NULL) { + func_80B4B7F4(npcAction, &sp70); + func_80B4B834(npcAction, &sp64); + if (pthis->unk_1E6 == 0) { + pthis->actor.world.pos = pthis->actor.home.pos = sp70; + } + + if (pthis->unk_1E6 != npcAction->action) { + frameCount = Animation_GetLastFrame(sp90[npcAction->action]); + Animation_Change(&pthis->skelAnime, sp90[npcAction->action], 1.0f, 0.0f, frameCount, sp84[npcAction->action], + -10.0f); + pthis->unk_1E6 = npcAction->action; + } + pthis->actor.velocity = velocity; + if (globalCtx->csCtx.frames < npcAction->endFrame) { + actionLength = npcAction->endFrame - npcAction->startFrame; + pthis->actor.velocity.x = (sp64.x - sp70.x) / actionLength; + pthis->actor.velocity.y = (sp64.y - sp70.y) / actionLength; + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } + pthis->actor.velocity.z = (sp64.z - sp70.z) / actionLength; + } + } +} + +void func_80B4BF2C(EnZl1* pthis, GlobalContext* globalCtx) { + s32 pad; + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + + switch (pthis->unk_1E2) { + case 0: + if ((Message_GetState(msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { + if (msgCtx->choiceIndex == 0) { + pthis->actor.textId = 0x703B; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2++; + } else { + pthis->actor.textId = 0x703A; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_1E2 = 0; + } + } + break; + case 1: + if ((Message_GetState(msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.textId = 0xFFFF; + globalCtx->talkWithPlayer(globalCtx, &pthis->actor); + func_8002F434(&pthis->actor, globalCtx, GI_LETTER_ZELDA, 120.0f, 10.0f); + globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; + globalCtx->msgCtx.stateTimer = 4; + pthis->unk_1E2++; + } else { + break; + } + case 2: + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Gameplay_CopyCamera(globalCtx, MAIN_CAM, pthis->unk_1E8); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); + Gameplay_ClearCamera(globalCtx, pthis->unk_1E8); + pthis->actor.parent = NULL; + pthis->unk_1E2++; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_LETTER_ZELDA, 120.0f, 10.0f); + } + break; + case 3: + if ((Message_GetState(msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { + pthis->actor.textId = 0x703C; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + Flags_SetEventChkInf(0x40); + pthis->unk_1E2 = 6; + } + break; + case 4: + if (player->actor.world.pos.y < pthis->actor.world.pos.y) { + break; + } else { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->unk_1E2++; + } else { + func_8002F2F4(&pthis->actor, globalCtx); + } + } + break; + case 5: + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->unk_1E2--; + } + break; + case 6: + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + func_8002DF54(globalCtx, &pthis->actor, 7); + Interface_ChangeAlpha(50); + pthis->actor.flags &= ~ACTOR_FLAG_8; + pthis->unk_1E2 = 4; + } + break; + } + func_80038290(globalCtx, &pthis->actor, &pthis->unk_200, &pthis->unk_206, pthis->actor.focus.pos); +} + +void EnZl1_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZl1* pthis = (EnZl1*)thisx; + + if ((pthis->actionFunc != func_80B4B8B4) && (pthis->actionFunc != func_80B4BC78)) { + SkelAnime_Update(&pthis->skelAnime); + } + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 5); + pthis->actionFunc(pthis, globalCtx); + if (pthis->actionFunc != func_80B4B8B4) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + Math_SmoothStepToS(&pthis->actor.shape.rot.x, pthis->actor.world.rot.x, 0xA, 0x3E8, 1); + Math_SmoothStepToS(&pthis->actor.shape.rot.y, pthis->actor.world.rot.y, 0xA, 0x3E8, 1); + Math_SmoothStepToS(&pthis->actor.shape.rot.z, pthis->actor.world.rot.z, 0xA, 0x3E8, 1); + func_80B4AE18(pthis); +} + +s32 EnZl1_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnZl1* pthis = (EnZl1*)thisx; + + if ((limbIndex == 4) || (limbIndex == 3) || (limbIndex == 6) || (limbIndex == 5)) { + *dList = NULL; + } + + if (limbIndex != 10) { + if (limbIndex == 17) { + rot->x += pthis->unk_200.y; + rot->y += pthis->unk_200.z; + rot->z += pthis->unk_200.x; + } + } else { + rot->x += pthis->unk_206.y; + rot->y += pthis->unk_206.x; + rot->z += pthis->unk_206.z; + } + return 0; +} + +void EnZl1_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + Vec3f vec = { 0.0f, 0.0f, 0.0f }; + EnZl1* pthis = (EnZl1*)thisx; + + if (limbIndex == 17) { + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); + } +} + +void EnZl1_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZl1* pthis = (EnZl1*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_girlB.c", 2011); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(pthis->unk_1F4)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(pthis->unk_1F8)); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(pthis->unk_1EC)); + + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnZl1_OverrideLimbDraw, EnZl1_PostLimbDraw, pthis); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_girlB.c", 2046); +} diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1_camera_data.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1_camera_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Zl1/z_en_zl1_camera_data.c rename to src/overlays/actors/ovl_En_Zl1/z_en_zl1_camera_data.cpp diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1_cutscene_data.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Zl1/z_en_zl1_cutscene_data.c rename to src/overlays/actors/ovl_En_Zl1/z_en_zl1_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c deleted file mode 100644 index 9556134cf..000000000 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ /dev/null @@ -1,1708 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZL2_Z_EN_ZL2_C -#include "actor_common.h" -/* - * File: z_en_zl2.c - * Overlay: ovl_En_Zl2 - * Description: Adult Zelda (Cutscenes) - */ - -#include "z_en_zl2.h" -#include "vt.h" - -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "objects/object_zl2/object_zl2.h" -#include "objects/object_zl2_anime1/object_zl2_anime1.h" -#include "def/code_800F7260.h" -#include "def/code_800FCE80.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_common_data.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnZl2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZl2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZl2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZl2_Draw(Actor* thisx, GlobalContext* globalCtx); - -s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx); - -void func_80B50BBC(EnZl2* this, GlobalContext* globalCtx); -void func_80B50BEC(EnZl2* this, GlobalContext* globalCtx); -void func_80B50C40(EnZl2* this, GlobalContext* globalCtx); -void func_80B50CA8(EnZl2* this, GlobalContext* globalCtx); -void func_80B50CFC(EnZl2* this, GlobalContext* globalCtx); -void func_80B50D50(EnZl2* this, GlobalContext* globalCtx); -void func_80B50D94(EnZl2* this, GlobalContext* globalCtx); -void func_80B50DE8(EnZl2* this, GlobalContext* globalCtx); -void func_80B50E3C(EnZl2* this, GlobalContext* globalCtx); -void func_80B50E90(EnZl2* this, GlobalContext* globalCtx); -void func_80B50EE4(EnZl2* this, GlobalContext* globalCtx); -void func_80B50F38(EnZl2* this, GlobalContext* globalCtx); -void func_80B50F8C(EnZl2* this, GlobalContext* globalCtx); -void func_80B50FE8(EnZl2* this, GlobalContext* globalCtx); -void func_80B51034(EnZl2* this, GlobalContext* globalCtx); -void func_80B51080(EnZl2* this, GlobalContext* globalCtx); -void func_80B510CC(EnZl2* this, GlobalContext* globalCtx); -void func_80B51118(EnZl2* this, GlobalContext* globalCtx); -void func_80B51164(EnZl2* this, GlobalContext* globalCtx); -void func_80B511B0(EnZl2* this, GlobalContext* globalCtx); -void func_80B511FC(EnZl2* this, GlobalContext* globalCtx); -void func_80B51250(EnZl2* this, GlobalContext* globalCtx); -void func_80B512B8(EnZl2* this, GlobalContext* globalCtx); -void func_80B51310(EnZl2* this, GlobalContext* globalCtx); -void func_80B51A5C(EnZl2* this, GlobalContext* globalCtx); -void func_80B51A8C(EnZl2* this, GlobalContext* globalCtx); -void func_80B51AE4(EnZl2* this, GlobalContext* globalCtx); -void func_80B51B44(EnZl2* this, GlobalContext* globalCtx); -void func_80B51BA8(EnZl2* this, GlobalContext* globalCtx); -void func_80B51C0C(EnZl2* this, GlobalContext* globalCtx); -void func_80B51C64(EnZl2* this, GlobalContext* globalCtx); -void func_80B51CA8(EnZl2* this, GlobalContext* globalCtx); -void func_80B52068(EnZl2* this, GlobalContext* globalCtx); -void func_80B52098(EnZl2* this, GlobalContext* globalCtx); -void func_80B52108(EnZl2* this, GlobalContext* globalCtx); -void func_80B521A0(EnZl2* this, GlobalContext* globalCtx); -void func_80B523BC(EnZl2* this, GlobalContext* globalCtx); -void func_80B523C8(EnZl2* this, GlobalContext* globalCtx); -void func_80B525D4(EnZl2* this, GlobalContext* globalCtx); - -static void* sEyeTextures[] = { gZelda2EyeOpenTex, gZelda2EyeHalfTex, gZelda2EyeShutTex, - gZelda2Eye03Tex, gZelda2Eye04Tex, gZelda2Eye05Tex, - gZelda2Eye06Tex, gZelda2Eye07Tex, gZelda2Eye08Tex }; - -static void* sMouthTextures[] = { gZelda2MouthSeriousTex, gZelda2MouthHappyTex, gZelda2MouthOpenTex }; - -static EnZl2ActionFunc sActionFuncs[] = { - func_80B521A0, func_80B50BBC, func_80B50BEC, func_80B50C40, func_80B50CA8, func_80B50CFC, - func_80B50D50, func_80B50D94, func_80B50DE8, func_80B50E3C, func_80B50E90, func_80B50EE4, - func_80B50F38, func_80B50F8C, func_80B50FE8, func_80B51034, func_80B51080, func_80B510CC, - func_80B51118, func_80B51164, func_80B511B0, func_80B511FC, func_80B51250, func_80B512B8, - func_80B51310, func_80B51A5C, func_80B51A8C, func_80B51AE4, func_80B51B44, func_80B51BA8, - func_80B51C0C, func_80B51C64, func_80B51CA8, func_80B52068, func_80B52098, func_80B52108, -}; - -static OverrideLimbDraw sOverrideLimbDrawFuncs[] = { - func_80B4F45C, -}; - -static EnZl2DrawFunc sDrawFuncs[] = { - func_80B523BC, - func_80B523C8, - func_80B525D4, -}; - -const ActorInit En_Zl2_InitVars = { - ACTOR_EN_ZL2, - ACTORCAT_NPC, - FLAGS, - OBJECT_ZL2, - sizeof(EnZl2), - (ActorFunc)EnZl2_Init, - (ActorFunc)EnZl2_Destroy, - (ActorFunc)EnZl2_Update, - (ActorFunc)EnZl2_Draw, -}; - -void EnZl2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnZl2* this = (EnZl2*)thisx; - - SkelAnime_Free(&this->skelAnime, globalCtx); -} - -void EnZl2_UpdateEyes(EnZl2* this) { - s32 pad[4]; - s16* eyeTexIndex2 = &this->eyeTexIndex2; - s16* blinkTimer = &this->blinkTimer; - s16* eyeTexIndex = &this->eyeTexIndex; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - *eyeTexIndex = *blinkTimer; - if (*eyeTexIndex >= 3) { - *eyeTexIndex = 0; - } - *eyeTexIndex2 = *eyeTexIndex; -} - -void func_80B4EA40(EnZl2* this) { - s16* eyeTexIndex = &this->eyeTexIndex; - f32* unk_27C = &this->unk_27C; - - if (*unk_27C < 3.0f) { - *eyeTexIndex = 0; - } else if (*unk_27C < 6.0f) { - *eyeTexIndex = 1; - } else if (*unk_27C < 9.0f) { - *eyeTexIndex = 2; - } else { - *eyeTexIndex = 5; - this->eyeTexIndex2 = *eyeTexIndex; - return; - } - *unk_27C += 1.0f; - this->eyeTexIndex2 = *eyeTexIndex; -} - -void func_80B4EAF4(EnZl2* this) { - s16* eyeTexIndex = &this->eyeTexIndex; - f32* unk_27C = &this->unk_27C; - - if (*unk_27C < 2.0f) { - *eyeTexIndex = 5; - } else if (*unk_27C < 4.0f) { - *eyeTexIndex = 2; - } else if (*unk_27C < 6.0f) { - *eyeTexIndex = 1; - } else { - EnZl2_UpdateEyes(this); - return; - } - *unk_27C += 1.0f; - this->eyeTexIndex2 = *eyeTexIndex; -} - -void func_80B4EBB8(EnZl2* this) { - s16* eyeTexIndex = &this->eyeTexIndex; - f32* unk_27C = &this->unk_27C; - - if (*unk_27C < 2.0f) { - *eyeTexIndex = 0; - } else if (*unk_27C < 4.0f) { - *eyeTexIndex = 1; - } else { - *eyeTexIndex = 2; - this->eyeTexIndex2 = *eyeTexIndex; - return; - } - *unk_27C += 1.0f; - this->eyeTexIndex2 = *eyeTexIndex; -} - -void func_80B4EC48(EnZl2* this) { - s16* eyeTexIndex = &this->eyeTexIndex; - f32* unk_27C = &this->unk_27C; - - if (*unk_27C < 2.0f) { - *eyeTexIndex = 2; - } else if (*unk_27C < 4.0f) { - *eyeTexIndex = 1; - } else { - EnZl2_UpdateEyes(this); - return; - } - *unk_27C += 1.0f; - this->eyeTexIndex2 = *eyeTexIndex; -} - -void EnZl2_setEyesIndex(EnZl2* this, s16 index) { - this->eyeTexIndex = index; - this->eyeTexIndex2 = this->eyeTexIndex; -} - -void EnZl2_setEyeIndex2(EnZl2* this, s16 index) { - this->eyeTexIndex2 = index; -} - -void EnZl2_setMouthIndex(EnZl2* this, s16 index) { - this->mouthTexIndex = index; -} - -void func_80B4ED2C(EnZl2* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -s32 EnZl2_UpdateSkelAnime(EnZl2* this) { - return SkelAnime_Update(&this->skelAnime); -} - -CsCmdActorAction* EnZl2_GetNpcAction(GlobalContext* globalCtx, s32 idx) { - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - return globalCtx->csCtx.npcActions[idx]; - } - return NULL; -} - -void func_80B4EDB8(EnZl2* this, GlobalContext* globalCtx, s32 arg2) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, arg2); - - if (npcAction != NULL) { - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - } -} - -void func_80B4EE38(EnZl2* this, s16 arg1, s32 arg2) { - s32 phi_a3; - s32 temp_v1; - s32 phi_v0 = arg2; - - if (this->unk_24C != 0) { - temp_v1 = (s16)(arg1 + this->unk_1DC[phi_v0]); - phi_a3 = arg1 - this->unk_20C[phi_v0]; - phi_v0 = this->unk_1AC[phi_v0]; - - if ((s32)fabsf((f32)phi_a3) > 0x8000) { - if (arg1 > 0) { - phi_a3 -= 0x10000; - } else { - phi_a3 += 0x10000; - } - } - if (phi_a3 != 0) { - phi_v0 += (phi_a3 - phi_v0) / 16; - } - if (phi_v0 != 0) { - phi_v0 -= (phi_v0 / 10); - } - if ((s16)(temp_v1 - arg1) != 0) { - phi_v0 -= ((s16)(temp_v1 - arg1) / 50); - } - temp_v1 += phi_v0; - if (((this->unk_1AC[arg2] * phi_v0) <= 0) && ((s16)(temp_v1 - arg1) > -0x64) && - ((s16)(temp_v1 - arg1) < 0x64)) { - temp_v1 = arg1; - phi_v0 = 0; - } - this->unk_1AC[arg2] = phi_v0; - this->unk_1DC[arg2] = temp_v1 - arg1; - } - this->unk_20C[arg2] = arg1; -} - -void func_80B4EF64(EnZl2* this, s16 arg1, s32 arg2) { - s32 temp_t0 = arg2; - s32 temp_t2; - s32 temp_v1; - s32 phi_t1; - s32 phi_v0; - s32 phi_a0; - f32 curFrame; - f32 unk_278; - - if (temp_t0 == 2) { - phi_a0 = 0x3A98; - phi_t1 = 0; - } else if (temp_t0 == 5) { - phi_a0 = 0x32C8; - phi_t1 = 3; - } else if (temp_t0 == 8) { - phi_a0 = 0x2EE0; - phi_t1 = 6; - } else if (temp_t0 == 11) { - phi_a0 = 0x4000; - phi_t1 = 9; - } else if (temp_t0 == 14) { - phi_a0 = 0x4000; - phi_t1 = 12; - } else if (temp_t0 == 17) { - phi_a0 = 0x4000; - phi_t1 = 15; - } else { - phi_a0 = 0x4000; - phi_t1 = 18; - } - - if (this->unk_24C != 0) { - phi_v0 = this->unk_1DC[temp_t0] + arg1; - temp_v1 = (s16)(phi_v0 & 0xFFFF); - temp_t2 = arg1 - this->unk_20C[temp_t0]; - phi_v0 = this->unk_1AC[temp_t0]; - - if ((s32)fabsf((f32)temp_t2) > 0x8000) { - if (arg1 > 0) { - temp_t2 -= 0x10000; - } else { - temp_t2 += 0x10000; - } - } - if (phi_t1 >= 0) { - temp_t2 += (ABS(this->unk_1AC[phi_t1]) / 3); - } - if (temp_t2 != 0) { - phi_v0 += ((temp_t2 - phi_v0) / 16); - } - if (phi_v0 != 0) { - phi_v0 -= phi_v0 / 10; - } - if ((s16)(temp_v1 - phi_a0) != 0) { - phi_v0 -= (s16)(temp_v1 - phi_a0) / 50; - } - temp_v1 += phi_v0; - - if (((this->unk_1AC[arg2] * phi_v0) <= 0) && ((s16)(temp_v1 - phi_a0) > -0x64) && - ((s16)(temp_v1 - phi_a0) < 0x64)) { - temp_v1 = phi_a0; - phi_v0 = 0; - } - - if (arg2 == 2) { - if ((this->action == 5) || (this->action == 30)) { - curFrame = this->skelAnime.curFrame; - unk_278 = this->unk_278; - temp_t0 = (s32)((3500.0f * curFrame) / unk_278) + phi_a0; - if (temp_t0 >= temp_v1) { - temp_v1 = temp_t0; - phi_v0 /= -2; - } - } else if ((this->action == 6) || (this->action == 31)) { - temp_t0 = phi_a0 + 0xDAC; - if (temp_t0 >= temp_v1) { - temp_v1 = temp_t0; - phi_v0 /= -2; - } - } else if (this->action == 20) { - temp_t0 = phi_a0 - 0x3E8; - if (temp_t0 >= temp_v1) { - temp_v1 = temp_t0; - phi_v0 /= -2; - } - } - } - this->unk_1AC[arg2] = phi_v0; - this->unk_1DC[arg2] = temp_v1 - arg1; - } - this->unk_20C[arg2] = arg1; -} - -void func_80B4F230(EnZl2* this, s16 arg1, s32 arg2) { - s32 temp_v1; - s16 temp_t0; - s32 temp_t2; - s32 temp_t3; - s32 phi_v0; - s32 index1AC; - s32 phi_t5; - - if (this->unk_24C != 0) { - temp_v1 = this->unk_1DC[arg2] - arg1; - temp_t0 = temp_v1; - temp_t2 = temp_t0; - temp_t3 = this->unk_1AC[arg2]; - phi_v0 = temp_t3; - temp_t3 = arg1 - this->unk_20C[arg2]; - - if (arg2 == 1) { - index1AC = 0; - phi_t5 = this->unk_1AC[index1AC]; - } else if (arg2 == 4) { - index1AC = 3; - phi_t5 = this->unk_1AC[index1AC]; - } else if (arg2 == 7) { - index1AC = 6; - phi_t5 = this->unk_1AC[index1AC]; - } else if (arg2 == 10) { - index1AC = 9; - phi_t5 = ABS(this->unk_1AC[index1AC]); - } else if (arg2 == 13) { - index1AC = 12; - phi_t5 = ABS(this->unk_1AC[index1AC]); - } else if (arg2 == 16) { - index1AC = 15; - phi_t5 = -ABS(this->unk_1AC[index1AC]); - } else { - index1AC = 18; - phi_t5 = -ABS(this->unk_1AC[index1AC]); - } - - if ((s32)fabsf(temp_t3) > 0x8000) { - if (arg1 > 0) { - temp_t3 -= 0x10000; - } else { - temp_t3 += 0x10000; - } - } - if (index1AC >= 0) { - temp_t3 += phi_t5 / 3; - } - - if (temp_t3 != 0) { - phi_v0 += (temp_t3 - phi_v0) / 16; - } - if (phi_v0 != 0) { - phi_v0 -= phi_v0 / 10; - } - if (temp_t0 != 0) { - phi_v0 -= temp_t0 / 50; - } - temp_v1 += phi_v0; - if (((this->unk_1AC[arg2] * phi_v0) <= 0) && (temp_t2 > -0x64) && (temp_t2 < 0x64)) { - temp_v1 = 0; - phi_v0 = 0; - } - this->unk_1AC[arg2] = phi_v0; - this->unk_1DC[arg2] = arg1 + temp_v1; - } - this->unk_20C[arg2] = arg1; -} - -s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - s32 pad; - EnZl2* this = (EnZl2*)thisx; - Mtx* sp74; - MtxF sp34; - Vec3s sp2C; - s16 pad2; - s16* unk_1DC = this->unk_1DC; - - if (limbIndex == 14) { - sp74 = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 7); - gSPSegment((*gfx)++, 0x0C, sp74); - - Matrix_Push(); - Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); - Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); - Matrix_Push(); - Matrix_Translate(362.0f, -133.0f, 0.0f, MTXMODE_APPLY); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 0); - func_80B4F230(this, sp2C.x, 1); - func_80B4EF64(this, sp2C.z, 2); - } - Matrix_RotateZYX(unk_1DC[0] + kREG(31), unk_1DC[1] + kREG(32), unk_1DC[2] + kREG(33), MTXMODE_APPLY); - Matrix_Translate(-188.0f, -184.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[0], "../z_en_zl2.c", 1056); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 3); - func_80B4F230(this, sp2C.x, 4); - } - Matrix_RotateZYX(unk_1DC[3] + kREG(34), unk_1DC[4] + kREG(35), unk_1DC[5] + kREG(36), MTXMODE_APPLY); - Matrix_Translate(-410.0f, -184.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[1], "../z_en_zl2.c", 1100); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 6); - func_80B4F230(this, sp2C.x, 7); - } - Matrix_RotateZYX(unk_1DC[6] + kREG(37), unk_1DC[7] + kREG(38), unk_1DC[8] + kREG(39), MTXMODE_APPLY); - Matrix_Translate(-1019.0f, -26.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[2], "../z_en_zl2.c", 1120); - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(467.0f, 265.0f, 389.0f, MTXMODE_APPLY); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 9); - func_80B4F230(this, sp2C.x, 10); - func_80B4EF64(this, sp2C.z, 11); - } - Matrix_RotateZYX(unk_1DC[9] + kREG(40), unk_1DC[10] + kREG(41), unk_1DC[11] + kREG(42), MTXMODE_APPLY); - Matrix_Translate(-427.0f, -1.0f, -3.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[3], "../z_en_zl2.c", 1145); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 12); - func_80B4F230(this, sp2C.x, 13); - func_80B4EF64(this, sp2C.z, 14); - } - Matrix_RotateZYX(unk_1DC[12] + kREG(43), unk_1DC[13] + kREG(44), unk_1DC[14] + kREG(45), MTXMODE_APPLY); - Matrix_Translate(-446.0f, -52.0f, 84.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[4], "../z_en_zl2.c", 1164); - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(467.0f, 265.0f, -389.0f, MTXMODE_APPLY); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 15); - func_80B4F230(this, sp2C.x, 16); - func_80B4EF64(this, sp2C.z, 17); - } - Matrix_RotateZYX(unk_1DC[15] + kREG(46), unk_1DC[16] + kREG(47), unk_1DC[17] + kREG(48), MTXMODE_APPLY); - Matrix_Translate(-427.0f, -1.0f, 3.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[5], "../z_en_zl2.c", 1189); - Matrix_Get(&sp34); - Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B4EE38(this, sp2C.y, 18); - func_80B4F230(this, sp2C.x, 19); - func_80B4EF64(this, sp2C.z, 20); - } - Matrix_RotateZYX(unk_1DC[18] + kREG(49), unk_1DC[19] + kREG(50), unk_1DC[20] + kREG(51), MTXMODE_APPLY); - Matrix_Translate(-446.0f, -52.0f, -84.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp74[6], "../z_en_zl2.c", 1208); - Matrix_Pop(); - Matrix_Pop(); - this->unk_24C = 1; - } - return false; -} - -void EnZl2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnZl2* this = (EnZl2*)thisx; - s32 pad[2]; - - if (limbIndex == 10) { - if ((this->unk_254 != 0) && (globalCtx->csCtx.frames >= 900)) { - gSPDisplayList((*gfx)++, gZelda2OcarinaDL); - } - - { - Player* player = GET_PLAYER(globalCtx); - Matrix_Push(); - if (player->rightHandType == 0xFF) { - Matrix_Put(&player->shieldMf); - Matrix_Translate(180.0f, 979.0f, -375.0f, MTXMODE_APPLY); - Matrix_RotateZYX(-0x5DE7, -0x53E9, 0x3333, MTXMODE_APPLY); - Matrix_Scale(1.2f, 1.2f, 1.2f, MTXMODE_APPLY); - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1253), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, gZelda2OcarinaDL); - } - Matrix_Pop(); - } - } -} - -void func_80B4FCCC(EnZl2* this, GlobalContext* globalCtx) { - s32 unk_274 = this->unk_274; - - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[unk_274].vromStart); -} - -void func_80B4FD00(EnZl2* this, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { - f32 frameCount = Animation_GetLastFrame(animation); - f32 playbackSpeed; - f32 unk0; - f32 fc; - - if (arg4 == 0) { - unk0 = 0.0f; - fc = frameCount; - playbackSpeed = 1.0f; - } else { - fc = 0.0f; - unk0 = frameCount; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animation, playbackSpeed, unk0, fc, arg2, transitionRate); -} - -void func_80B4FD90(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_00B5FC, 0, 0.0f, 0); - this->action = 1; -} - -void func_80B4FDD4(EnZl2* this) { - if (Animation_OnFrame(&this->skelAnime, 14.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_CONCRETE); - } -} - -void func_80B4FE10(GlobalContext* globalCtx) { - if ((globalCtx->csCtx.frames >= 830) && (globalCtx->csCtx.frames < 1081)) { - func_800788CC(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - } -} - -void func_80B4FE48(EnZl2* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EV_GOTO_HEAVEN - SFX_FLAG); -} - -void func_80B4FE6C(EnZl2* this) { - func_80078914(&this->actor.projectedPos, NA_SE_EN_GANON_LAUGH); -} - -void func_80B4FE90(EnZl2* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_SURPRISE); -} - -void func_80B4FEB4(EnZl2* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_PAIN); -} - -void func_80B4FED8(EnZl2* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_CRY_0); -} - -void EnZl2_GiveLightArrows(EnZl2* this, GlobalContext* globalCtx) { - Player* player; - f32 posX; - f32 posY; - f32 posZ; - - if (this->unk_244 == 0) { - player = GET_PLAYER(globalCtx); - posX = player->actor.world.pos.x; - posY = player->actor.world.pos.y + 80.0f; - posZ = player->actor.world.pos.z; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, 0x17); - Item_Give(globalCtx, ITEM_ARROW_LIGHT); - this->unk_244 = 1; - } -} - -void func_80B4FF84(EnZl2* this, GlobalContext* globalCtx) { - f32 posX; - f32 posY; - f32 posZ; - - if (this->unk_250 == 0) { - posX = this->actor.world.pos.x; - posY = this->actor.world.pos.y; - posZ = this->actor.world.pos.z; - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_YELLOW); - this->unk_250 = 1; - } -} - -void func_80B4FFF0(EnZl2* this, GlobalContext* globalCtx) { - f32 posX; - f32 posY; - f32 posZ; - - if (this->unk_248 == 0) { - posX = this->actor.world.pos.x; - posY = this->actor.world.pos.y + (kREG(5) + -26.0f); - posZ = this->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0x4000, - 0, WARP_PURPLE_CRYSTAL); - this->unk_248 = 1; - } -} - -void func_80B5008C(EnZl2* this) { - Actor* child = this->actor.child; - - if (child != NULL) { - child->world.pos.x = this->actor.world.pos.x; - child->world.pos.y = this->actor.world.pos.y + (kREG(5) + -26.0f); - child->world.pos.z = this->actor.world.pos.z; - } -} - -void func_80B500E0(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - Vec3f* thisPos = &this->actor.world.pos; - f32 startX; - f32 startY; - f32 startZ; - f32 endX; - f32 endY; - f32 endZ; - f32 someFloat; - - if (npcAction != NULL) { - someFloat = - Environment_LerpWeightAccelDecel(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, 8, 8); - startX = npcAction->startPos.x; - startY = npcAction->startPos.y; - startZ = npcAction->startPos.z; - endX = npcAction->endPos.x; - endY = npcAction->endPos.y; - endZ = npcAction->endPos.z; - thisPos->x = ((endX - startX) * someFloat) + startX; - thisPos->y = ((endY - startY) * someFloat) + startY; - thisPos->z = ((endZ - startZ) * someFloat) + startZ; - } -} - -void func_80B501C4(EnZl2* this, s32 alpha) { - if (this->actor.child != NULL) { - ((DoorWarp1*)this->actor.child)->crystalAlpha = alpha; - } -} - -void func_80B501E8(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - - if (npcAction != NULL) { - this->actor.shape.shadowAlpha = this->alpha = - (1.0f - Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames)) * - 255.0f; - func_80B501C4(this, this->alpha); - } -} - -void func_80B50260(EnZl2* this, GlobalContext* globalCtx) { - this->action = 1; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80B50278(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - - this->actor.world.pos.x = npcAction->startPos.x; - this->actor.world.pos.y = npcAction->startPos.y; - this->actor.world.pos.z = npcAction->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = npcAction->rot.y; - this->actor.shape.shadowAlpha = 0xFF; - this->action = 2; - this->drawConfig = 1; -} - -void func_80B50304(EnZl2* this, GlobalContext* globalCtx) { - s32 pad[2]; - ActorShape* shape = &this->actor.shape; - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - f32 actionXDelta; - f32 actionZDelta; - - actionXDelta = npcAction->endPos.x - npcAction->startPos.x; - actionZDelta = npcAction->endPos.z - npcAction->startPos.z; - func_80B4FD00(this, &gZelda2Anime1Anim_0003BC, 0, -12.0f, 0); - this->action = 3; - this->drawConfig = 1; - this->unk_23C = 0.0f; - shape->shadowAlpha = 255; - this->actor.world.rot.y = shape->rot.y = Math_FAtan2F(actionXDelta, actionZDelta) * (0x8000 / M_PI); -} - -void func_80B503DC(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - - if ((npcAction != NULL) && (globalCtx->csCtx.frames >= npcAction->endFrame)) { - this->action = 4; - } -} - -void func_80B5042C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_0022D0, 2, -8.0f, 0); - this->action = 5; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_27C = 0.0f; -} - -void func_80B50488(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_002750, 0, 0.0f, 0); - this->action = 6; - this->drawConfig = 1; - } -} - -void func_80B504D4(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_00325C, 2, -8.0f, 0); - this->action = 7; - this->drawConfig = 1; - this->unk_27C = 0.0f; - EnZl2_setMouthIndex(this, 1); - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80B5053C(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_003538, 0, 0.0f, 0); - this->action = 8; - } -} - -void func_80B50580(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_000A50, 2, -8.0f, 0); - this->action = 9; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80B505D4(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_000EB0, 0, 0.0f, 0); - this->action = 10; - } -} - -void func_80B50618(EnZl2* this, GlobalContext* globalCtx) { - EnZl2_GiveLightArrows(this, globalCtx); - this->action = 11; -} - -void func_80B50644(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FF84(this, globalCtx); - this->action = 12; -} - -void func_80B50670(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_00B5FC, 0, -8.0f, 0); - this->action = 13; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80B506C4(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_00AAD4, 2, -8.0f, 0); - this->action = 14; - this->drawConfig = 1; - EnZl2_setEyesIndex(this, 4); - EnZl2_setMouthIndex(this, 2); - this->actor.shape.shadowAlpha = 0xFF; - func_80B4FE90(this); -} - -void func_80B5073C(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_00AFE0, 0, 0.0f, 0); - this->action = 15; - } -} - -void func_80B50780(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_001670, 2, -8.0f, 0); - this->action = 16; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - func_80B4FFF0(this, globalCtx); - EnZl2_setEyesIndex(this, 3); -} - -void func_80B507E8(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_001B48, 0, 0.0f, 0); - this->action = 17; - } -} - -void func_80B5082C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_002B14, 2, -8.0f, 0); - this->action = 18; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80B50880(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_002F30, 0, 0.0f, 0); - this->action = 19; - func_80B4FEB4(this); - } -} - -void func_80B508C8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_001010, 2, -8.0f, 0); - this->action = 20; - this->drawConfig = 1; - EnZl2_setEyesIndex(this, 6); - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80B50928(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_0013A0, 0, 0.0f, 0); - this->action = 21; - func_80B4FED8(this); - } -} - -void func_80B50970(EnZl2* this, GlobalContext* globalCtx) { - this->action = 22; -} - -void func_80B50980(EnZl2* this, GlobalContext* globalCtx) { - this->action = 23; - this->drawConfig = 2; - this->alpha = 255; -} - -void func_80B509A0(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - - if (npcAction != NULL) { - if (globalCtx->csCtx.frames >= npcAction->endFrame) { - this->action = 24; - this->drawConfig = 0; - func_80B4FE6C(this); - } - } -} - -void func_80B50A04(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - s32 newAction; - s32 unk_240; - - if (npcAction != NULL) { - newAction = npcAction->action; - unk_240 = this->unk_240; - if (newAction != unk_240) { - switch (newAction) { - case 1: - func_80B50260(this, globalCtx); - break; - case 2: - func_80B50278(this, globalCtx); - break; - case 3: - func_80B50304(this, globalCtx); - break; - case 4: - func_80B5042C(this, globalCtx); - break; - case 5: - func_80B504D4(this, globalCtx); - break; - case 6: - func_80B50580(this, globalCtx); - break; - case 7: - func_80B50618(this, globalCtx); - break; - case 8: - func_80B50670(this, globalCtx); - break; - case 9: - func_80B506C4(this, globalCtx); - break; - case 10: - func_80B50780(this, globalCtx); - break; - case 11: - func_80B5082C(this, globalCtx); - break; - case 12: - func_80B508C8(this, globalCtx); - break; - case 13: - func_80B50970(this, globalCtx); - break; - case 14: - func_80B50980(this, globalCtx); - break; - case 15: - func_80B50644(this, globalCtx); - break; - default: - osSyncPrintf("En_Zl2_inAgain_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_240 = newAction; - } - } -} - -void func_80B50BBC(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B50A04(this, globalCtx); -} - -void func_80B50BEC(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50C40(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FDD4(this); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B500E0(this, globalCtx); - func_80B503DC(this, globalCtx); -} - -void func_80B50CA8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50CFC(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B4EA40(this); - func_80B50488(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B50D50(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50D94(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B4EAF4(this); - func_80B5053C(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B50DE8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50E3C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - func_80B505D4(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B50E90(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50EE4(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50F38(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50F8C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B50FE8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B5073C(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B51034(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B51080(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B507E8(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B510CC(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B51118(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B50880(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B51164(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B50A04(this, globalCtx); -} - -void func_80B511B0(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE10(globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B50928(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B511FC(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B5008C(this); - func_80B50A04(this, globalCtx); -} - -void func_80B51250(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4FE48(this); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B500E0(this, globalCtx); - func_80B5008C(this); - func_80B50A04(this, globalCtx); -} - -void func_80B512B8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B501E8(this, globalCtx); - func_80B509A0(this, globalCtx); -} - -void func_80B51310(EnZl2* this, GlobalContext* globalCtx) { - Actor* child; - - if (EnZl2_GetNpcAction(globalCtx, 0) == NULL) { - child = this->actor.child; - if (child != NULL) { - Actor_Kill(child); - } - Actor_Kill(&this->actor); - } -} - -void func_80B5135C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_00A15C, 0, 0.0f, 0); - this->action = 25; - this->unk_254 = 1; -} - -void func_80B513A8(EnZl2* this, GlobalContext* globalCtx) { - Player* player; - f32 posX; - f32 posY; - f32 posZ; - - if (this->unk_250 == 0) { - player = GET_PLAYER(globalCtx); - posX = player->actor.world.pos.x; - posY = player->actor.world.pos.y; - posZ = player->actor.world.pos.z; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_UNK_7); - this->unk_250 = 1; - } -} - -void func_80B51418(EnZl2* this, GlobalContext* globalCtx) { - EnZl2_UpdateEyes(this); - if (globalCtx->csCtx.frames < 431) { - EnZl2_setMouthIndex(this, 1); - } else { - EnZl2_setMouthIndex(this, 0); - } -} - -void func_80B5146C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4EA40(this); - EnZl2_setMouthIndex(this, 0); -} - -void func_80B5149C(EnZl2* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames < 988) { - EnZl2_setEyesIndex(this, 7); - EnZl2_setEyeIndex2(this, 8); - } else { - EnZl2_UpdateEyes(this); - } - EnZl2_setMouthIndex(this, 0); -} - -void func_80B514F8(EnZl2* this, GlobalContext* globalCtx) { - EnZl2_UpdateEyes(this); - if (globalCtx->csCtx.frames < 1190) { - EnZl2_setMouthIndex(this, 1); - } else { - EnZl2_setMouthIndex(this, 0); - } -} - -void func_80B5154C(EnZl2* this, GlobalContext* globalCtx) { - CutsceneContext* csCtx; - - if (this->skelAnime.mode != 0) { - EnZl2_UpdateEyes(this); - } else { - csCtx = &globalCtx->csCtx; - if (csCtx->frames < 0x5F0) { - func_80B4EBB8(this); - } else if (csCtx->frames == 0x5F0) { - this->unk_27C = 0.0f; - } else { - func_80B4EC48(this); - } - } -} - -void func_80B515C4(EnZl2* this) { - this->action = 25; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80B515D8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FD00(this, &gZelda2Anime1Anim_00A15C, 0, -8.0f, 0); - func_80B4EDB8(this, globalCtx, 0); - this->action = 26; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_27C = 0.0f; -} - -void func_80B51644(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_0087B8, 0, -8.0f, 0); - } -} - -void func_80B51678(EnZl2* this) { - func_80B4FD00(this, &gZelda2Anime1Anim_007D0C, 2, -8.0f, 0); - this->action = 27; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_27C = 0.0f; -} - -void func_80B516D0(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_009AD4, 0, -8.0f, 0); - } -} - -void func_80B51704(EnZl2* this) { - func_80B4FD00(this, &gZelda2Anime1Anim_0090D8, 2, -8.0f, 0); - this->action = 28; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_27C = 0.0f; -} - -void func_80B5175C(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_006778, 0, -8.0f, 0); - } -} - -void func_80B51790(EnZl2* this) { - func_80B4FD00(this, &gZelda2Anime1Anim_005F40, 2, -8.0f, 0); - this->action = 29; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; -} - -void func_80B517E0(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_002750, 0, -8.0f, 0); - this->action = 31; - } -} - -void func_80B51824(EnZl2* this) { - func_80B4FD00(this, &gZelda2Anime1Anim_0022D0, 2, -8.0f, 0); - this->action = 30; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_27C = 0.0f; -} - -void func_80B5187C(EnZl2* this, s32 arg1) { - if (arg1 != 0) { - func_80B4FD00(this, &gZelda2Anime1Anim_00A79C, 0, -8.0f, 0); - this->unk_27C = 0.0f; - } -} - -void func_80B518C0(EnZl2* this) { - func_80B4FD00(this, SEGMENTED_TO_VIRTUAL(&gZelda2Anime1Anim_004900), 2, -8.0f, 0); - this->action = 32; - this->drawConfig = 1; - this->actor.shape.shadowAlpha = 0xFF; - this->unk_27C = 0.0f; -} - -void func_80B51948(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - s32 newAction; - s32 unk_240; - - if (npcAction != NULL) { - newAction = npcAction->action; - unk_240 = this->unk_240; - if (newAction != unk_240) { - switch (newAction) { - case 1: - func_80B515C4(this); - break; - case 2: - func_80B515D8(this, globalCtx); - break; - case 16: - func_80B51678(this); - break; - case 17: - func_80B51704(this); - break; - case 18: - func_80B51790(this); - break; - case 4: - func_80B51824(this); - break; - case 20: - func_80B518C0(this); - break; - case 21: - func_80B513A8(this, globalCtx); - break; - default: - osSyncPrintf("En_Zl2_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_240 = newAction; - } - } -} - -void func_80B51A5C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B51948(this, globalCtx); -} - -void func_80B51A8C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B51418(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B51948(this, globalCtx); -} - -void func_80B51AE4(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - func_80B51644(this, EnZl2_UpdateSkelAnime(this)); - func_80B51948(this, globalCtx); -} - -void func_80B51B44(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B5149C(this, globalCtx); - func_80B516D0(this, EnZl2_UpdateSkelAnime(this)); - func_80B51948(this, globalCtx); -} - -void func_80B51BA8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B514F8(this, globalCtx); - func_80B5175C(this, EnZl2_UpdateSkelAnime(this)); - func_80B51948(this, globalCtx); -} - -void func_80B51C0C(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B5146C(this, globalCtx); - func_80B517E0(this, EnZl2_UpdateSkelAnime(this)); -} - -void func_80B51C64(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateSkelAnime(this); - func_80B51948(this, globalCtx); -} - -void func_80B51CA8(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - func_80B5154C(this, globalCtx); - func_80B5187C(this, EnZl2_UpdateSkelAnime(this)); - func_80B51948(this, globalCtx); -} - -void func_80B51D0C(EnZl2* this, GlobalContext* globalCtx) { - this->action = 33; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80B51D24(EnZl2* this, GlobalContext* globalCtx) { - s32 pad[2]; - u32 sfxId; - SkelAnime* skelAnime = &this->skelAnime; - - if (Animation_OnFrame(skelAnime, 6.0f) || Animation_OnFrame(skelAnime, 0.0f)) { - if (this->actor.bgCheckFlags & 1) { - sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - func_80078914(&this->actor.projectedPos, sfxId); - } - } -} - -void func_80B51DA4(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - Vec3f* thisPos = &this->actor.world.pos; - f32 startX; - f32 startY; - f32 startZ; - f32 endX; - f32 endY; - f32 endZ; - f32 someFloat; - - if (npcAction != NULL) { - someFloat = - Environment_LerpWeightAccelDecel(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, 0, 8); - startX = npcAction->startPos.x; - startY = npcAction->startPos.y; - startZ = npcAction->startPos.z; - endX = npcAction->endPos.x; - endY = npcAction->endPos.y; - endZ = npcAction->endPos.z; - thisPos->x = ((endX - startX) * someFloat) + startX; - thisPos->y = ((endY - startY) * someFloat) + startY; - thisPos->z = ((endZ - startZ) * someFloat) + startZ; - if (npcAction->endFrame < globalCtx->csCtx.frames) { - Actor_Kill(&this->actor); - } - } -} - -void func_80B51EA8(EnZl2* this) { - this->action = 33; - this->drawConfig = 0; - this->actor.shape.shadowAlpha = 0; -} - -void func_80B51EBC(EnZl2* this, GlobalContext* globalCtx) { - ActorShape* shape = &this->actor.shape; - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - s32 pad[2]; - - this->actor.world.rot.y = shape->rot.y = npcAction->rot.y; - func_80B4FD00(this, &gZelda2Anime1Anim_00B224, 0, 0.0f, 0); - this->action = 34; - this->drawConfig = 1; - shape->shadowAlpha = 255; -} - -void func_80B51F38(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - - if (npcAction != NULL) { - if (globalCtx->csCtx.frames - 8 >= npcAction->endFrame) { - func_80B4FD00(this, &gZelda2Anime1Anim_00B5FC, 0, -8.0f, 0); - this->action = 35; - } - } -} - -void func_80B51FA8(EnZl2* this, GlobalContext* globalCtx) { - CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); - s32 action; - s32 unk_240; - - if (npcAction != NULL) { - action = npcAction->action; - unk_240 = this->unk_240; - if (action != unk_240) { - switch (action) { - case 1: - func_80B51EA8(this); - break; - case 2: - func_80B51EBC(this, globalCtx); - break; - case 14: - Actor_Kill(&this->actor); - break; - default: - osSyncPrintf("En_Zl2_inRunning_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - break; - } - this->unk_240 = action; - } - } -} - -void func_80B52068(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B51FA8(this, globalCtx); -} - -void func_80B52098(EnZl2* this, GlobalContext* globalCtx) { - func_80B4FCCC(this, globalCtx); - func_80B4ED2C(this, globalCtx); - EnZl2_UpdateEyes(this); - EnZl2_UpdateSkelAnime(this); - func_80B51D24(this, globalCtx); - func_80B51F38(this, globalCtx); - func_80B51DA4(this, globalCtx); -} - -void func_80B52108(EnZl2* this, GlobalContext* globalCtx) { -} - -void func_80B52114(EnZl2* this, GlobalContext* globalCtx) { - switch (this->actor.params) { - case 1: - func_80B5135C(this, globalCtx); - break; - case 4: - func_80B51D0C(this, globalCtx); - break; - case 0: - func_80B4FD90(this, globalCtx); - break; - default: - osSyncPrintf(VT_FGCOL(RED) " En_Oa2 の arg_data がおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - func_80B4FD90(this, globalCtx); - } -} - -void func_80B521A0(EnZl2* this, GlobalContext* globalCtx) { - s32 pad; - ObjectContext* objectCtx = &globalCtx->objectCtx; - s32 bankIndex = Object_GetIndex(objectCtx, OBJECT_ZL2_ANIME1); - s32 pad2; - - if (bankIndex < 0) { - osSyncPrintf(VT_FGCOL(RED) "En_Zl2_main_bankアニメーションのバンクを読めない!!!!!!!!!!!!\n" VT_RST); - return; - } - - if (Object_IsLoaded(objectCtx, bankIndex)) { - this->unk_274 = bankIndex; - func_80B4FCCC(this, globalCtx); - this->unk_278 = Animation_GetLastFrame(&gZelda2Anime1Anim_0022D0); - func_80B52114(this, globalCtx); - } -} - -void EnZl2_Update(Actor* thisx, GlobalContext* globalCtx) { - EnZl2* this = (EnZl2*)thisx; - - if (this->action < 0 || this->action >= 0x24 || sActionFuncs[this->action] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sActionFuncs[this->action](this, globalCtx); -} - -void EnZl2_Init(Actor* thisx, GlobalContext* globalCtx) { - EnZl2* this = (EnZl2*)thisx; - ActorShape* shape = &thisx->shape; - s32 pad; - - ActorShape_Init(shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - shape->shadowAlpha = 0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZelda2Skel, NULL, NULL, NULL, 0); - - switch (thisx->params) { - case 1: - Audio_SetSoundBanksMute(0x6F); - break; - case 4: - gSaveContext.timer2State = 0; - break; - } -} - -s32 EnZl2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnZl2* this = (EnZl2*)thisx; - - if (this->overrideLimbDrawConfig < 0 || this->overrideLimbDrawConfig > 0 || - sOverrideLimbDrawFuncs[this->overrideLimbDrawConfig] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画前処理モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return 0; - } - return sOverrideLimbDrawFuncs[this->overrideLimbDrawConfig](globalCtx, limbIndex, dList, pos, rot, thisx, gfx); -} - -void func_80B523BC(EnZl2* this, GlobalContext* globalCtx) { -} - -void func_80B523C8(EnZl2* this, GlobalContext* globalCtx) { - s32 pad[3]; - s16 eyeTexIndex = this->eyeTexIndex; - s16 eyeTexIndex2 = this->eyeTexIndex2; - void* eyeTex = sEyeTextures[eyeTexIndex]; - void* eyeTex2 = sEyeTextures[eyeTexIndex2]; - SkelAnime* skelAnime = &this->skelAnime; - s16 mouthTexIndex = this->mouthTexIndex; - void* mouthTex = sMouthTextures[mouthTexIndex]; - s32 pad1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1623); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex2)); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0B, &D_80116280[2]); - - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnZl2_OverrideLimbDraw, EnZl2_PostLimbDraw, this, POLY_OPA_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1648); -} - -void func_80B525D4(EnZl2* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeTexIndex = this->eyeTexIndex; - void* eyeTex = sEyeTextures[eyeTexIndex]; - s16 mouthTexIndex = this->mouthTexIndex; - SkelAnime* skelAnime = &this->skelAnime; - void* mouthTex = sMouthTextures[mouthTexIndex]; - s32 pad1; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1663); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 0x0B, &D_80116280[0]); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnZl2_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1692); -} - -void EnZl2_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnZl2* this = (EnZl2*)thisx; - - if ((this->drawConfig < 0) || (this->drawConfig >= 3) || (sDrawFuncs[this->drawConfig] == NULL)) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.cpp b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.cpp new file mode 100644 index 000000000..f1655e46d --- /dev/null +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.cpp @@ -0,0 +1,1708 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZL2_Z_EN_ZL2_C +#include "actor_common.h" +/* + * File: z_en_zl2.c + * Overlay: ovl_En_Zl2 + * Description: Adult Zelda (Cutscenes) + */ + +#include "z_en_zl2.h" +#include "vt.h" + +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "objects/object_zl2/object_zl2.h" +#include "objects/object_zl2_anime1/object_zl2_anime1.h" +#include "def/code_800F7260.h" +#include "def/code_800FCE80.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_common_data.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnZl2_Init(Actor* thisx, GlobalContext* globalCtx); +void EnZl2_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnZl2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnZl2_Draw(Actor* thisx, GlobalContext* globalCtx); + +s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx); + +void func_80B50BBC(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50BEC(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50C40(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50CA8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50CFC(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50D50(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50D94(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50DE8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50E3C(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50E90(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50EE4(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50F38(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50F8C(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B50FE8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51034(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51080(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B510CC(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51118(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51164(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B511B0(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B511FC(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51250(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B512B8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51310(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51A5C(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51A8C(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51AE4(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51B44(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51BA8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51C0C(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51C64(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B51CA8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B52068(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B52098(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B52108(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B521A0(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B523BC(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B523C8(EnZl2* pthis, GlobalContext* globalCtx); +void func_80B525D4(EnZl2* pthis, GlobalContext* globalCtx); + +static void* sEyeTextures[] = { gZelda2EyeOpenTex, gZelda2EyeHalfTex, gZelda2EyeShutTex, + gZelda2Eye03Tex, gZelda2Eye04Tex, gZelda2Eye05Tex, + gZelda2Eye06Tex, gZelda2Eye07Tex, gZelda2Eye08Tex }; + +static void* sMouthTextures[] = { gZelda2MouthSeriousTex, gZelda2MouthHappyTex, gZelda2MouthOpenTex }; + +static EnZl2ActionFunc sActionFuncs[] = { + func_80B521A0, func_80B50BBC, func_80B50BEC, func_80B50C40, func_80B50CA8, func_80B50CFC, + func_80B50D50, func_80B50D94, func_80B50DE8, func_80B50E3C, func_80B50E90, func_80B50EE4, + func_80B50F38, func_80B50F8C, func_80B50FE8, func_80B51034, func_80B51080, func_80B510CC, + func_80B51118, func_80B51164, func_80B511B0, func_80B511FC, func_80B51250, func_80B512B8, + func_80B51310, func_80B51A5C, func_80B51A8C, func_80B51AE4, func_80B51B44, func_80B51BA8, + func_80B51C0C, func_80B51C64, func_80B51CA8, func_80B52068, func_80B52098, func_80B52108, +}; + +static OverrideLimbDraw sOverrideLimbDrawFuncs[] = { + func_80B4F45C, +}; + +static EnZl2DrawFunc sDrawFuncs[] = { + func_80B523BC, + func_80B523C8, + func_80B525D4, +}; + +ActorInit En_Zl2_InitVars = { + ACTOR_EN_ZL2, + ACTORCAT_NPC, + FLAGS, + OBJECT_ZL2, + sizeof(EnZl2), + (ActorFunc)EnZl2_Init, + (ActorFunc)EnZl2_Destroy, + (ActorFunc)EnZl2_Update, + (ActorFunc)EnZl2_Draw, +}; + +void EnZl2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZl2* pthis = (EnZl2*)thisx; + + SkelAnime_Free(&pthis->skelAnime, globalCtx); +} + +void EnZl2_UpdateEyes(EnZl2* pthis) { + s32 pad[4]; + s16* eyeTexIndex2 = &pthis->eyeTexIndex2; + s16* blinkTimer = &pthis->blinkTimer; + s16* eyeTexIndex = &pthis->eyeTexIndex; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + *eyeTexIndex = *blinkTimer; + if (*eyeTexIndex >= 3) { + *eyeTexIndex = 0; + } + *eyeTexIndex2 = *eyeTexIndex; +} + +void func_80B4EA40(EnZl2* pthis) { + s16* eyeTexIndex = &pthis->eyeTexIndex; + f32* unk_27C = &pthis->unk_27C; + + if (*unk_27C < 3.0f) { + *eyeTexIndex = 0; + } else if (*unk_27C < 6.0f) { + *eyeTexIndex = 1; + } else if (*unk_27C < 9.0f) { + *eyeTexIndex = 2; + } else { + *eyeTexIndex = 5; + pthis->eyeTexIndex2 = *eyeTexIndex; + return; + } + *unk_27C += 1.0f; + pthis->eyeTexIndex2 = *eyeTexIndex; +} + +void func_80B4EAF4(EnZl2* pthis) { + s16* eyeTexIndex = &pthis->eyeTexIndex; + f32* unk_27C = &pthis->unk_27C; + + if (*unk_27C < 2.0f) { + *eyeTexIndex = 5; + } else if (*unk_27C < 4.0f) { + *eyeTexIndex = 2; + } else if (*unk_27C < 6.0f) { + *eyeTexIndex = 1; + } else { + EnZl2_UpdateEyes(pthis); + return; + } + *unk_27C += 1.0f; + pthis->eyeTexIndex2 = *eyeTexIndex; +} + +void func_80B4EBB8(EnZl2* pthis) { + s16* eyeTexIndex = &pthis->eyeTexIndex; + f32* unk_27C = &pthis->unk_27C; + + if (*unk_27C < 2.0f) { + *eyeTexIndex = 0; + } else if (*unk_27C < 4.0f) { + *eyeTexIndex = 1; + } else { + *eyeTexIndex = 2; + pthis->eyeTexIndex2 = *eyeTexIndex; + return; + } + *unk_27C += 1.0f; + pthis->eyeTexIndex2 = *eyeTexIndex; +} + +void func_80B4EC48(EnZl2* pthis) { + s16* eyeTexIndex = &pthis->eyeTexIndex; + f32* unk_27C = &pthis->unk_27C; + + if (*unk_27C < 2.0f) { + *eyeTexIndex = 2; + } else if (*unk_27C < 4.0f) { + *eyeTexIndex = 1; + } else { + EnZl2_UpdateEyes(pthis); + return; + } + *unk_27C += 1.0f; + pthis->eyeTexIndex2 = *eyeTexIndex; +} + +void EnZl2_setEyesIndex(EnZl2* pthis, s16 index) { + pthis->eyeTexIndex = index; + pthis->eyeTexIndex2 = pthis->eyeTexIndex; +} + +void EnZl2_setEyeIndex2(EnZl2* pthis, s16 index) { + pthis->eyeTexIndex2 = index; +} + +void EnZl2_setMouthIndex(EnZl2* pthis, s16 index) { + pthis->mouthTexIndex = index; +} + +void func_80B4ED2C(EnZl2* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +s32 EnZl2_UpdateSkelAnime(EnZl2* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +CsCmdActorAction* EnZl2_GetNpcAction(GlobalContext* globalCtx, s32 idx) { + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + return globalCtx->csCtx.npcActions[idx]; + } + return NULL; +} + +void func_80B4EDB8(EnZl2* pthis, GlobalContext* globalCtx, s32 arg2) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, arg2); + + if (npcAction != NULL) { + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + } +} + +void func_80B4EE38(EnZl2* pthis, s16 arg1, s32 arg2) { + s32 phi_a3; + s32 temp_v1; + s32 phi_v0 = arg2; + + if (pthis->unk_24C != 0) { + temp_v1 = (s16)(arg1 + pthis->unk_1DC[phi_v0]); + phi_a3 = arg1 - pthis->unk_20C[phi_v0]; + phi_v0 = pthis->unk_1AC[phi_v0]; + + if ((s32)fabsf((f32)phi_a3) > 0x8000) { + if (arg1 > 0) { + phi_a3 -= 0x10000; + } else { + phi_a3 += 0x10000; + } + } + if (phi_a3 != 0) { + phi_v0 += (phi_a3 - phi_v0) / 16; + } + if (phi_v0 != 0) { + phi_v0 -= (phi_v0 / 10); + } + if ((s16)(temp_v1 - arg1) != 0) { + phi_v0 -= ((s16)(temp_v1 - arg1) / 50); + } + temp_v1 += phi_v0; + if (((pthis->unk_1AC[arg2] * phi_v0) <= 0) && ((s16)(temp_v1 - arg1) > -0x64) && + ((s16)(temp_v1 - arg1) < 0x64)) { + temp_v1 = arg1; + phi_v0 = 0; + } + pthis->unk_1AC[arg2] = phi_v0; + pthis->unk_1DC[arg2] = temp_v1 - arg1; + } + pthis->unk_20C[arg2] = arg1; +} + +void func_80B4EF64(EnZl2* pthis, s16 arg1, s32 arg2) { + s32 temp_t0 = arg2; + s32 temp_t2; + s32 temp_v1; + s32 phi_t1; + s32 phi_v0; + s32 phi_a0; + f32 curFrame; + f32 unk_278; + + if (temp_t0 == 2) { + phi_a0 = 0x3A98; + phi_t1 = 0; + } else if (temp_t0 == 5) { + phi_a0 = 0x32C8; + phi_t1 = 3; + } else if (temp_t0 == 8) { + phi_a0 = 0x2EE0; + phi_t1 = 6; + } else if (temp_t0 == 11) { + phi_a0 = 0x4000; + phi_t1 = 9; + } else if (temp_t0 == 14) { + phi_a0 = 0x4000; + phi_t1 = 12; + } else if (temp_t0 == 17) { + phi_a0 = 0x4000; + phi_t1 = 15; + } else { + phi_a0 = 0x4000; + phi_t1 = 18; + } + + if (pthis->unk_24C != 0) { + phi_v0 = pthis->unk_1DC[temp_t0] + arg1; + temp_v1 = (s16)(phi_v0 & 0xFFFF); + temp_t2 = arg1 - pthis->unk_20C[temp_t0]; + phi_v0 = pthis->unk_1AC[temp_t0]; + + if ((s32)fabsf((f32)temp_t2) > 0x8000) { + if (arg1 > 0) { + temp_t2 -= 0x10000; + } else { + temp_t2 += 0x10000; + } + } + if (phi_t1 >= 0) { + temp_t2 += (ABS(pthis->unk_1AC[phi_t1]) / 3); + } + if (temp_t2 != 0) { + phi_v0 += ((temp_t2 - phi_v0) / 16); + } + if (phi_v0 != 0) { + phi_v0 -= phi_v0 / 10; + } + if ((s16)(temp_v1 - phi_a0) != 0) { + phi_v0 -= (s16)(temp_v1 - phi_a0) / 50; + } + temp_v1 += phi_v0; + + if (((pthis->unk_1AC[arg2] * phi_v0) <= 0) && ((s16)(temp_v1 - phi_a0) > -0x64) && + ((s16)(temp_v1 - phi_a0) < 0x64)) { + temp_v1 = phi_a0; + phi_v0 = 0; + } + + if (arg2 == 2) { + if ((pthis->action == 5) || (pthis->action == 30)) { + curFrame = pthis->skelAnime.curFrame; + unk_278 = pthis->unk_278; + temp_t0 = (s32)((3500.0f * curFrame) / unk_278) + phi_a0; + if (temp_t0 >= temp_v1) { + temp_v1 = temp_t0; + phi_v0 /= -2; + } + } else if ((pthis->action == 6) || (pthis->action == 31)) { + temp_t0 = phi_a0 + 0xDAC; + if (temp_t0 >= temp_v1) { + temp_v1 = temp_t0; + phi_v0 /= -2; + } + } else if (pthis->action == 20) { + temp_t0 = phi_a0 - 0x3E8; + if (temp_t0 >= temp_v1) { + temp_v1 = temp_t0; + phi_v0 /= -2; + } + } + } + pthis->unk_1AC[arg2] = phi_v0; + pthis->unk_1DC[arg2] = temp_v1 - arg1; + } + pthis->unk_20C[arg2] = arg1; +} + +void func_80B4F230(EnZl2* pthis, s16 arg1, s32 arg2) { + s32 temp_v1; + s16 temp_t0; + s32 temp_t2; + s32 temp_t3; + s32 phi_v0; + s32 index1AC; + s32 phi_t5; + + if (pthis->unk_24C != 0) { + temp_v1 = pthis->unk_1DC[arg2] - arg1; + temp_t0 = temp_v1; + temp_t2 = temp_t0; + temp_t3 = pthis->unk_1AC[arg2]; + phi_v0 = temp_t3; + temp_t3 = arg1 - pthis->unk_20C[arg2]; + + if (arg2 == 1) { + index1AC = 0; + phi_t5 = pthis->unk_1AC[index1AC]; + } else if (arg2 == 4) { + index1AC = 3; + phi_t5 = pthis->unk_1AC[index1AC]; + } else if (arg2 == 7) { + index1AC = 6; + phi_t5 = pthis->unk_1AC[index1AC]; + } else if (arg2 == 10) { + index1AC = 9; + phi_t5 = ABS(pthis->unk_1AC[index1AC]); + } else if (arg2 == 13) { + index1AC = 12; + phi_t5 = ABS(pthis->unk_1AC[index1AC]); + } else if (arg2 == 16) { + index1AC = 15; + phi_t5 = -ABS(pthis->unk_1AC[index1AC]); + } else { + index1AC = 18; + phi_t5 = -ABS(pthis->unk_1AC[index1AC]); + } + + if ((s32)fabsf(temp_t3) > 0x8000) { + if (arg1 > 0) { + temp_t3 -= 0x10000; + } else { + temp_t3 += 0x10000; + } + } + if (index1AC >= 0) { + temp_t3 += phi_t5 / 3; + } + + if (temp_t3 != 0) { + phi_v0 += (temp_t3 - phi_v0) / 16; + } + if (phi_v0 != 0) { + phi_v0 -= phi_v0 / 10; + } + if (temp_t0 != 0) { + phi_v0 -= temp_t0 / 50; + } + temp_v1 += phi_v0; + if (((pthis->unk_1AC[arg2] * phi_v0) <= 0) && (temp_t2 > -0x64) && (temp_t2 < 0x64)) { + temp_v1 = 0; + phi_v0 = 0; + } + pthis->unk_1AC[arg2] = phi_v0; + pthis->unk_1DC[arg2] = arg1 + temp_v1; + } + pthis->unk_20C[arg2] = arg1; +} + +s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + s32 pad; + EnZl2* pthis = (EnZl2*)thisx; + Mtx* sp74; + MtxF sp34; + Vec3s sp2C; + s16 pad2; + s16* unk_1DC = pthis->unk_1DC; + + if (limbIndex == 14) { + sp74 = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 7); + gSPSegment((*gfx)++, 0x0C, sp74); + + Matrix_Push(); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(362.0f, -133.0f, 0.0f, MTXMODE_APPLY); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 0); + func_80B4F230(pthis, sp2C.x, 1); + func_80B4EF64(pthis, sp2C.z, 2); + } + Matrix_RotateZYX(unk_1DC[0] + kREG(31), unk_1DC[1] + kREG(32), unk_1DC[2] + kREG(33), MTXMODE_APPLY); + Matrix_Translate(-188.0f, -184.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[0], "../z_en_zl2.c", 1056); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 3); + func_80B4F230(pthis, sp2C.x, 4); + } + Matrix_RotateZYX(unk_1DC[3] + kREG(34), unk_1DC[4] + kREG(35), unk_1DC[5] + kREG(36), MTXMODE_APPLY); + Matrix_Translate(-410.0f, -184.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[1], "../z_en_zl2.c", 1100); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 6); + func_80B4F230(pthis, sp2C.x, 7); + } + Matrix_RotateZYX(unk_1DC[6] + kREG(37), unk_1DC[7] + kREG(38), unk_1DC[8] + kREG(39), MTXMODE_APPLY); + Matrix_Translate(-1019.0f, -26.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[2], "../z_en_zl2.c", 1120); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(467.0f, 265.0f, 389.0f, MTXMODE_APPLY); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 9); + func_80B4F230(pthis, sp2C.x, 10); + func_80B4EF64(pthis, sp2C.z, 11); + } + Matrix_RotateZYX(unk_1DC[9] + kREG(40), unk_1DC[10] + kREG(41), unk_1DC[11] + kREG(42), MTXMODE_APPLY); + Matrix_Translate(-427.0f, -1.0f, -3.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[3], "../z_en_zl2.c", 1145); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 12); + func_80B4F230(pthis, sp2C.x, 13); + func_80B4EF64(pthis, sp2C.z, 14); + } + Matrix_RotateZYX(unk_1DC[12] + kREG(43), unk_1DC[13] + kREG(44), unk_1DC[14] + kREG(45), MTXMODE_APPLY); + Matrix_Translate(-446.0f, -52.0f, 84.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[4], "../z_en_zl2.c", 1164); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(467.0f, 265.0f, -389.0f, MTXMODE_APPLY); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 15); + func_80B4F230(pthis, sp2C.x, 16); + func_80B4EF64(pthis, sp2C.z, 17); + } + Matrix_RotateZYX(unk_1DC[15] + kREG(46), unk_1DC[16] + kREG(47), unk_1DC[17] + kREG(48), MTXMODE_APPLY); + Matrix_Translate(-427.0f, -1.0f, 3.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[5], "../z_en_zl2.c", 1189); + Matrix_Get(&sp34); + Matrix_MtxFToYXZRotS(&sp34, &sp2C, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B4EE38(pthis, sp2C.y, 18); + func_80B4F230(pthis, sp2C.x, 19); + func_80B4EF64(pthis, sp2C.z, 20); + } + Matrix_RotateZYX(unk_1DC[18] + kREG(49), unk_1DC[19] + kREG(50), unk_1DC[20] + kREG(51), MTXMODE_APPLY); + Matrix_Translate(-446.0f, -52.0f, -84.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp74[6], "../z_en_zl2.c", 1208); + Matrix_Pop(); + Matrix_Pop(); + pthis->unk_24C = 1; + } + return false; +} + +void EnZl2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + EnZl2* pthis = (EnZl2*)thisx; + s32 pad[2]; + + if (limbIndex == 10) { + if ((pthis->unk_254 != 0) && (globalCtx->csCtx.frames >= 900)) { + gSPDisplayList((*gfx)++, gZelda2OcarinaDL); + } + + { + Player* player = GET_PLAYER(globalCtx); + Matrix_Push(); + if (player->rightHandType == 0xFF) { + Matrix_Put(&player->shieldMf); + Matrix_Translate(180.0f, 979.0f, -375.0f, MTXMODE_APPLY); + Matrix_RotateZYX(-0x5DE7, -0x53E9, 0x3333, MTXMODE_APPLY); + Matrix_Scale(1.2f, 1.2f, 1.2f, MTXMODE_APPLY); + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1253), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, gZelda2OcarinaDL); + } + Matrix_Pop(); + } + } +} + +void func_80B4FCCC(EnZl2* pthis, GlobalContext* globalCtx) { + s32 unk_274 = pthis->unk_274; + + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[unk_274].vromStart.get()); +} + +void func_80B4FD00(EnZl2* pthis, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { + f32 frameCount = Animation_GetLastFrame(animation); + f32 playbackSpeed; + f32 unk0; + f32 fc; + + if (arg4 == 0) { + unk0 = 0.0f; + fc = frameCount; + playbackSpeed = 1.0f; + } else { + fc = 0.0f; + unk0 = frameCount; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animation, playbackSpeed, unk0, fc, arg2, transitionRate); +} + +void func_80B4FD90(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00B5FC, 0, 0.0f, 0); + pthis->action = 1; +} + +void func_80B4FDD4(EnZl2* pthis) { + if (Animation_OnFrame(&pthis->skelAnime, 14.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_PL_WALK_CONCRETE); + } +} + +void func_80B4FE10(GlobalContext* globalCtx) { + if ((globalCtx->csCtx.frames >= 830) && (globalCtx->csCtx.frames < 1081)) { + func_800788CC(NA_SE_EV_EARTHQUAKE - SFX_FLAG); + } +} + +void func_80B4FE48(EnZl2* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_GOTO_HEAVEN - SFX_FLAG); +} + +void func_80B4FE6C(EnZl2* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_EN_GANON_LAUGH); +} + +void func_80B4FE90(EnZl2* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_SURPRISE); +} + +void func_80B4FEB4(EnZl2* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_PAIN); +} + +void func_80B4FED8(EnZl2* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_CRY_0); +} + +void EnZl2_GiveLightArrows(EnZl2* pthis, GlobalContext* globalCtx) { + Player* player; + f32 posX; + f32 posY; + f32 posZ; + + if (pthis->unk_244 == 0) { + player = GET_PLAYER(globalCtx); + posX = player->actor.world.pos.x; + posY = player->actor.world.pos.y + 80.0f; + posZ = player->actor.world.pos.z; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, posX, posY, posZ, 0, 0, 0, 0x17); + Item_Give(globalCtx, ITEM_ARROW_LIGHT); + pthis->unk_244 = 1; + } +} + +void func_80B4FF84(EnZl2* pthis, GlobalContext* globalCtx) { + f32 posX; + f32 posY; + f32 posZ; + + if (pthis->unk_250 == 0) { + posX = pthis->actor.world.pos.x; + posY = pthis->actor.world.pos.y; + posZ = pthis->actor.world.pos.z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_YELLOW); + pthis->unk_250 = 1; + } +} + +void func_80B4FFF0(EnZl2* pthis, GlobalContext* globalCtx) { + f32 posX; + f32 posY; + f32 posZ; + + if (pthis->unk_248 == 0) { + posX = pthis->actor.world.pos.x; + posY = pthis->actor.world.pos.y + (kREG(5) + -26.0f); + posZ = pthis->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0x4000, + 0, WARP_PURPLE_CRYSTAL); + pthis->unk_248 = 1; + } +} + +void func_80B5008C(EnZl2* pthis) { + Actor* child = pthis->actor.child; + + if (child != NULL) { + child->world.pos.x = pthis->actor.world.pos.x; + child->world.pos.y = pthis->actor.world.pos.y + (kREG(5) + -26.0f); + child->world.pos.z = pthis->actor.world.pos.z; + } +} + +void func_80B500E0(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + Vec3f* thisPos = &pthis->actor.world.pos; + f32 startX; + f32 startY; + f32 startZ; + f32 endX; + f32 endY; + f32 endZ; + f32 someFloat; + + if (npcAction != NULL) { + someFloat = + Environment_LerpWeightAccelDecel(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, 8, 8); + startX = npcAction->startPos.x; + startY = npcAction->startPos.y; + startZ = npcAction->startPos.z; + endX = npcAction->endPos.x; + endY = npcAction->endPos.y; + endZ = npcAction->endPos.z; + thisPos->x = ((endX - startX) * someFloat) + startX; + thisPos->y = ((endY - startY) * someFloat) + startY; + thisPos->z = ((endZ - startZ) * someFloat) + startZ; + } +} + +void func_80B501C4(EnZl2* pthis, s32 alpha) { + if (pthis->actor.child != NULL) { + ((DoorWarp1*)pthis->actor.child)->crystalAlpha = alpha; + } +} + +void func_80B501E8(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + + if (npcAction != NULL) { + pthis->actor.shape.shadowAlpha = pthis->alpha = + (1.0f - Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames)) * + 255.0f; + func_80B501C4(pthis, pthis->alpha); + } +} + +void func_80B50260(EnZl2* pthis, GlobalContext* globalCtx) { + pthis->action = 1; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80B50278(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + + pthis->actor.world.pos.x = npcAction->startPos.x; + pthis->actor.world.pos.y = npcAction->startPos.y; + pthis->actor.world.pos.z = npcAction->startPos.z; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y = npcAction->rot.y; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->action = 2; + pthis->drawConfig = 1; +} + +void func_80B50304(EnZl2* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + ActorShape* shape = &pthis->actor.shape; + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + f32 actionXDelta; + f32 actionZDelta; + + actionXDelta = npcAction->endPos.x - npcAction->startPos.x; + actionZDelta = npcAction->endPos.z - npcAction->startPos.z; + func_80B4FD00(pthis, &gZelda2Anime1Anim_0003BC, 0, -12.0f, 0); + pthis->action = 3; + pthis->drawConfig = 1; + pthis->unk_23C = 0.0f; + shape->shadowAlpha = 255; + pthis->actor.world.rot.y = shape->rot.y = Math_FAtan2F(actionXDelta, actionZDelta) * (0x8000 / M_PI); +} + +void func_80B503DC(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + + if ((npcAction != NULL) && (globalCtx->csCtx.frames >= npcAction->endFrame)) { + pthis->action = 4; + } +} + +void func_80B5042C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_0022D0, 2, -8.0f, 0); + pthis->action = 5; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_27C = 0.0f; +} + +void func_80B50488(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_002750, 0, 0.0f, 0); + pthis->action = 6; + pthis->drawConfig = 1; + } +} + +void func_80B504D4(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00325C, 2, -8.0f, 0); + pthis->action = 7; + pthis->drawConfig = 1; + pthis->unk_27C = 0.0f; + EnZl2_setMouthIndex(pthis, 1); + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80B5053C(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_003538, 0, 0.0f, 0); + pthis->action = 8; + } +} + +void func_80B50580(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_000A50, 2, -8.0f, 0); + pthis->action = 9; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80B505D4(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_000EB0, 0, 0.0f, 0); + pthis->action = 10; + } +} + +void func_80B50618(EnZl2* pthis, GlobalContext* globalCtx) { + EnZl2_GiveLightArrows(pthis, globalCtx); + pthis->action = 11; +} + +void func_80B50644(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FF84(pthis, globalCtx); + pthis->action = 12; +} + +void func_80B50670(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00B5FC, 0, -8.0f, 0); + pthis->action = 13; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80B506C4(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00AAD4, 2, -8.0f, 0); + pthis->action = 14; + pthis->drawConfig = 1; + EnZl2_setEyesIndex(pthis, 4); + EnZl2_setMouthIndex(pthis, 2); + pthis->actor.shape.shadowAlpha = 0xFF; + func_80B4FE90(pthis); +} + +void func_80B5073C(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00AFE0, 0, 0.0f, 0); + pthis->action = 15; + } +} + +void func_80B50780(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_001670, 2, -8.0f, 0); + pthis->action = 16; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + func_80B4FFF0(pthis, globalCtx); + EnZl2_setEyesIndex(pthis, 3); +} + +void func_80B507E8(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_001B48, 0, 0.0f, 0); + pthis->action = 17; + } +} + +void func_80B5082C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_002B14, 2, -8.0f, 0); + pthis->action = 18; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80B50880(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_002F30, 0, 0.0f, 0); + pthis->action = 19; + func_80B4FEB4(pthis); + } +} + +void func_80B508C8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_001010, 2, -8.0f, 0); + pthis->action = 20; + pthis->drawConfig = 1; + EnZl2_setEyesIndex(pthis, 6); + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80B50928(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_0013A0, 0, 0.0f, 0); + pthis->action = 21; + func_80B4FED8(pthis); + } +} + +void func_80B50970(EnZl2* pthis, GlobalContext* globalCtx) { + pthis->action = 22; +} + +void func_80B50980(EnZl2* pthis, GlobalContext* globalCtx) { + pthis->action = 23; + pthis->drawConfig = 2; + pthis->alpha = 255; +} + +void func_80B509A0(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + + if (npcAction != NULL) { + if (globalCtx->csCtx.frames >= npcAction->endFrame) { + pthis->action = 24; + pthis->drawConfig = 0; + func_80B4FE6C(pthis); + } + } +} + +void func_80B50A04(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + s32 newAction; + s32 unk_240; + + if (npcAction != NULL) { + newAction = npcAction->action; + unk_240 = pthis->unk_240; + if (newAction != unk_240) { + switch (newAction) { + case 1: + func_80B50260(pthis, globalCtx); + break; + case 2: + func_80B50278(pthis, globalCtx); + break; + case 3: + func_80B50304(pthis, globalCtx); + break; + case 4: + func_80B5042C(pthis, globalCtx); + break; + case 5: + func_80B504D4(pthis, globalCtx); + break; + case 6: + func_80B50580(pthis, globalCtx); + break; + case 7: + func_80B50618(pthis, globalCtx); + break; + case 8: + func_80B50670(pthis, globalCtx); + break; + case 9: + func_80B506C4(pthis, globalCtx); + break; + case 10: + func_80B50780(pthis, globalCtx); + break; + case 11: + func_80B5082C(pthis, globalCtx); + break; + case 12: + func_80B508C8(pthis, globalCtx); + break; + case 13: + func_80B50970(pthis, globalCtx); + break; + case 14: + func_80B50980(pthis, globalCtx); + break; + case 15: + func_80B50644(pthis, globalCtx); + break; + default: + osSyncPrintf("En_Zl2_inAgain_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_240 = newAction; + } + } +} + +void func_80B50BBC(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50BEC(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50C40(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FDD4(pthis); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B500E0(pthis, globalCtx); + func_80B503DC(pthis, globalCtx); +} + +void func_80B50CA8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50CFC(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B4EA40(pthis); + func_80B50488(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B50D50(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50D94(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B4EAF4(pthis); + func_80B5053C(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B50DE8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50E3C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + func_80B505D4(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B50E90(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50EE4(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50F38(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50F8C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B50FE8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B5073C(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B51034(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B51080(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B507E8(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B510CC(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B51118(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B50880(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B51164(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B511B0(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE10(globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B50928(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B511FC(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B5008C(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B51250(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4FE48(pthis); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B500E0(pthis, globalCtx); + func_80B5008C(pthis); + func_80B50A04(pthis, globalCtx); +} + +void func_80B512B8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B501E8(pthis, globalCtx); + func_80B509A0(pthis, globalCtx); +} + +void func_80B51310(EnZl2* pthis, GlobalContext* globalCtx) { + Actor* child; + + if (EnZl2_GetNpcAction(globalCtx, 0) == NULL) { + child = pthis->actor.child; + if (child != NULL) { + Actor_Kill(child); + } + Actor_Kill(&pthis->actor); + } +} + +void func_80B5135C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00A15C, 0, 0.0f, 0); + pthis->action = 25; + pthis->unk_254 = 1; +} + +void func_80B513A8(EnZl2* pthis, GlobalContext* globalCtx) { + Player* player; + f32 posX; + f32 posY; + f32 posZ; + + if (pthis->unk_250 == 0) { + player = GET_PLAYER(globalCtx); + posX = player->actor.world.pos.x; + posY = player->actor.world.pos.y; + posZ = player->actor.world.pos.z; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_UNK_7); + pthis->unk_250 = 1; + } +} + +void func_80B51418(EnZl2* pthis, GlobalContext* globalCtx) { + EnZl2_UpdateEyes(pthis); + if (globalCtx->csCtx.frames < 431) { + EnZl2_setMouthIndex(pthis, 1); + } else { + EnZl2_setMouthIndex(pthis, 0); + } +} + +void func_80B5146C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4EA40(pthis); + EnZl2_setMouthIndex(pthis, 0); +} + +void func_80B5149C(EnZl2* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames < 988) { + EnZl2_setEyesIndex(pthis, 7); + EnZl2_setEyeIndex2(pthis, 8); + } else { + EnZl2_UpdateEyes(pthis); + } + EnZl2_setMouthIndex(pthis, 0); +} + +void func_80B514F8(EnZl2* pthis, GlobalContext* globalCtx) { + EnZl2_UpdateEyes(pthis); + if (globalCtx->csCtx.frames < 1190) { + EnZl2_setMouthIndex(pthis, 1); + } else { + EnZl2_setMouthIndex(pthis, 0); + } +} + +void func_80B5154C(EnZl2* pthis, GlobalContext* globalCtx) { + CutsceneContext* csCtx; + + if (pthis->skelAnime.mode != 0) { + EnZl2_UpdateEyes(pthis); + } else { + csCtx = &globalCtx->csCtx; + if (csCtx->frames < 0x5F0) { + func_80B4EBB8(pthis); + } else if (csCtx->frames == 0x5F0) { + pthis->unk_27C = 0.0f; + } else { + func_80B4EC48(pthis); + } + } +} + +void func_80B515C4(EnZl2* pthis) { + pthis->action = 25; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80B515D8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00A15C, 0, -8.0f, 0); + func_80B4EDB8(pthis, globalCtx, 0); + pthis->action = 26; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_27C = 0.0f; +} + +void func_80B51644(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_0087B8, 0, -8.0f, 0); + } +} + +void func_80B51678(EnZl2* pthis) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_007D0C, 2, -8.0f, 0); + pthis->action = 27; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_27C = 0.0f; +} + +void func_80B516D0(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_009AD4, 0, -8.0f, 0); + } +} + +void func_80B51704(EnZl2* pthis) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_0090D8, 2, -8.0f, 0); + pthis->action = 28; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_27C = 0.0f; +} + +void func_80B5175C(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_006778, 0, -8.0f, 0); + } +} + +void func_80B51790(EnZl2* pthis) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_005F40, 2, -8.0f, 0); + pthis->action = 29; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; +} + +void func_80B517E0(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_002750, 0, -8.0f, 0); + pthis->action = 31; + } +} + +void func_80B51824(EnZl2* pthis) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_0022D0, 2, -8.0f, 0); + pthis->action = 30; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_27C = 0.0f; +} + +void func_80B5187C(EnZl2* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00A79C, 0, -8.0f, 0); + pthis->unk_27C = 0.0f; + } +} + +void func_80B518C0(EnZl2* pthis) { + func_80B4FD00(pthis, SEGMENTED_TO_VIRTUAL(&gZelda2Anime1Anim_004900), 2, -8.0f, 0); + pthis->action = 32; + pthis->drawConfig = 1; + pthis->actor.shape.shadowAlpha = 0xFF; + pthis->unk_27C = 0.0f; +} + +void func_80B51948(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + s32 newAction; + s32 unk_240; + + if (npcAction != NULL) { + newAction = npcAction->action; + unk_240 = pthis->unk_240; + if (newAction != unk_240) { + switch (newAction) { + case 1: + func_80B515C4(pthis); + break; + case 2: + func_80B515D8(pthis, globalCtx); + break; + case 16: + func_80B51678(pthis); + break; + case 17: + func_80B51704(pthis); + break; + case 18: + func_80B51790(pthis); + break; + case 4: + func_80B51824(pthis); + break; + case 20: + func_80B518C0(pthis); + break; + case 21: + func_80B513A8(pthis, globalCtx); + break; + default: + osSyncPrintf("En_Zl2_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_240 = newAction; + } + } +} + +void func_80B51A5C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B51948(pthis, globalCtx); +} + +void func_80B51A8C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B51418(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B51948(pthis, globalCtx); +} + +void func_80B51AE4(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + func_80B51644(pthis, EnZl2_UpdateSkelAnime(pthis)); + func_80B51948(pthis, globalCtx); +} + +void func_80B51B44(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B5149C(pthis, globalCtx); + func_80B516D0(pthis, EnZl2_UpdateSkelAnime(pthis)); + func_80B51948(pthis, globalCtx); +} + +void func_80B51BA8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B514F8(pthis, globalCtx); + func_80B5175C(pthis, EnZl2_UpdateSkelAnime(pthis)); + func_80B51948(pthis, globalCtx); +} + +void func_80B51C0C(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B5146C(pthis, globalCtx); + func_80B517E0(pthis, EnZl2_UpdateSkelAnime(pthis)); +} + +void func_80B51C64(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateSkelAnime(pthis); + func_80B51948(pthis, globalCtx); +} + +void func_80B51CA8(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + func_80B5154C(pthis, globalCtx); + func_80B5187C(pthis, EnZl2_UpdateSkelAnime(pthis)); + func_80B51948(pthis, globalCtx); +} + +void func_80B51D0C(EnZl2* pthis, GlobalContext* globalCtx) { + pthis->action = 33; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80B51D24(EnZl2* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + u32 sfxId; + SkelAnime* skelAnime = &pthis->skelAnime; + + if (Animation_OnFrame(skelAnime, 6.0f) || Animation_OnFrame(skelAnime, 0.0f)) { + if (pthis->actor.bgCheckFlags & 1) { + sfxId = SFX_FLAG; + sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + func_80078914(&pthis->actor.projectedPos, sfxId); + } + } +} + +void func_80B51DA4(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + Vec3f* thisPos = &pthis->actor.world.pos; + f32 startX; + f32 startY; + f32 startZ; + f32 endX; + f32 endY; + f32 endZ; + f32 someFloat; + + if (npcAction != NULL) { + someFloat = + Environment_LerpWeightAccelDecel(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, 0, 8); + startX = npcAction->startPos.x; + startY = npcAction->startPos.y; + startZ = npcAction->startPos.z; + endX = npcAction->endPos.x; + endY = npcAction->endPos.y; + endZ = npcAction->endPos.z; + thisPos->x = ((endX - startX) * someFloat) + startX; + thisPos->y = ((endY - startY) * someFloat) + startY; + thisPos->z = ((endZ - startZ) * someFloat) + startZ; + if (npcAction->endFrame < globalCtx->csCtx.frames) { + Actor_Kill(&pthis->actor); + } + } +} + +void func_80B51EA8(EnZl2* pthis) { + pthis->action = 33; + pthis->drawConfig = 0; + pthis->actor.shape.shadowAlpha = 0; +} + +void func_80B51EBC(EnZl2* pthis, GlobalContext* globalCtx) { + ActorShape* shape = &pthis->actor.shape; + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + s32 pad[2]; + + pthis->actor.world.rot.y = shape->rot.y = npcAction->rot.y; + func_80B4FD00(pthis, &gZelda2Anime1Anim_00B224, 0, 0.0f, 0); + pthis->action = 34; + pthis->drawConfig = 1; + shape->shadowAlpha = 255; +} + +void func_80B51F38(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + + if (npcAction != NULL) { + if (globalCtx->csCtx.frames - 8 >= npcAction->endFrame) { + func_80B4FD00(pthis, &gZelda2Anime1Anim_00B5FC, 0, -8.0f, 0); + pthis->action = 35; + } + } +} + +void func_80B51FA8(EnZl2* pthis, GlobalContext* globalCtx) { + CsCmdActorAction* npcAction = EnZl2_GetNpcAction(globalCtx, 0); + s32 action; + s32 unk_240; + + if (npcAction != NULL) { + action = npcAction->action; + unk_240 = pthis->unk_240; + if (action != unk_240) { + switch (action) { + case 1: + func_80B51EA8(pthis); + break; + case 2: + func_80B51EBC(pthis, globalCtx); + break; + case 14: + Actor_Kill(&pthis->actor); + break; + default: + osSyncPrintf("En_Zl2_inRunning_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + break; + } + pthis->unk_240 = action; + } + } +} + +void func_80B52068(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B51FA8(pthis, globalCtx); +} + +void func_80B52098(EnZl2* pthis, GlobalContext* globalCtx) { + func_80B4FCCC(pthis, globalCtx); + func_80B4ED2C(pthis, globalCtx); + EnZl2_UpdateEyes(pthis); + EnZl2_UpdateSkelAnime(pthis); + func_80B51D24(pthis, globalCtx); + func_80B51F38(pthis, globalCtx); + func_80B51DA4(pthis, globalCtx); +} + +void func_80B52108(EnZl2* pthis, GlobalContext* globalCtx) { +} + +void func_80B52114(EnZl2* pthis, GlobalContext* globalCtx) { + switch (pthis->actor.params) { + case 1: + func_80B5135C(pthis, globalCtx); + break; + case 4: + func_80B51D0C(pthis, globalCtx); + break; + case 0: + func_80B4FD90(pthis, globalCtx); + break; + default: + osSyncPrintf(VT_FGCOL(RED) " En_Oa2 の arg_data がおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + func_80B4FD90(pthis, globalCtx); + } +} + +void func_80B521A0(EnZl2* pthis, GlobalContext* globalCtx) { + s32 pad; + ObjectContext* objectCtx = &globalCtx->objectCtx; + s32 bankIndex = Object_GetIndex(objectCtx, OBJECT_ZL2_ANIME1); + s32 pad2; + + if (bankIndex < 0) { + osSyncPrintf(VT_FGCOL(RED) "En_Zl2_main_bankアニメーションのバンクを読めない!!!!!!!!!!!!\n" VT_RST); + return; + } + + if (Object_IsLoaded(objectCtx, bankIndex)) { + pthis->unk_274 = bankIndex; + func_80B4FCCC(pthis, globalCtx); + pthis->unk_278 = Animation_GetLastFrame(&gZelda2Anime1Anim_0022D0); + func_80B52114(pthis, globalCtx); + } +} + +void EnZl2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnZl2* pthis = (EnZl2*)thisx; + + if (pthis->action < 0 || pthis->action >= 0x24 || sActionFuncs[pthis->action] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void EnZl2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZl2* pthis = (EnZl2*)thisx; + ActorShape* shape = &thisx->shape; + s32 pad; + + ActorShape_Init(shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + shape->shadowAlpha = 0; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gZelda2Skel, NULL, NULL, NULL, 0); + + switch (thisx->params) { + case 1: + Audio_SetSoundBanksMute(0x6F); + break; + case 4: + gSaveContext.timer2State = 0; + break; + } +} + +s32 EnZl2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnZl2* pthis = (EnZl2*)thisx; + + if (pthis->overrideLimbDrawConfig < 0 || pthis->overrideLimbDrawConfig > 0 || + sOverrideLimbDrawFuncs[pthis->overrideLimbDrawConfig] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画前処理モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return 0; + } + return sOverrideLimbDrawFuncs[pthis->overrideLimbDrawConfig](globalCtx, limbIndex, dList, pos, rot, thisx, gfx); +} + +void func_80B523BC(EnZl2* pthis, GlobalContext* globalCtx) { +} + +void func_80B523C8(EnZl2* pthis, GlobalContext* globalCtx) { + s32 pad[3]; + s16 eyeTexIndex = pthis->eyeTexIndex; + s16 eyeTexIndex2 = pthis->eyeTexIndex2; + void* eyeTex = sEyeTextures[eyeTexIndex]; + void* eyeTex2 = sEyeTextures[eyeTexIndex2]; + SkelAnime* skelAnime = &pthis->skelAnime; + s16 mouthTexIndex = pthis->mouthTexIndex; + void* mouthTex = sMouthTextures[mouthTexIndex]; + s32 pad1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1623); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex2)); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x0B, &D_80116280[2]); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnZl2_OverrideLimbDraw, EnZl2_PostLimbDraw, pthis, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1648); +} + +void func_80B525D4(EnZl2* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTex = sEyeTextures[eyeTexIndex]; + s16 mouthTexIndex = pthis->mouthTexIndex; + SkelAnime* skelAnime = &pthis->skelAnime; + void* mouthTex = sMouthTextures[mouthTexIndex]; + s32 pad1; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1663); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 0x0B, &D_80116280[0]); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnZl2_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl2.c", 1692); +} + +void EnZl2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZl2* pthis = (EnZl2*)thisx; + + if ((pthis->drawConfig < 0) || (pthis->drawConfig >= 3) || (sDrawFuncs[pthis->drawConfig] == NULL)) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c deleted file mode 100644 index 6a59f6ebd..000000000 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ /dev/null @@ -1,2798 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZL3_Z_EN_ZL3_C -#include "actor_common.h" -/* - * File: z_en_zl3.c - * Overlay: ovl_En_Zl3 - * Description: Adult Zelda - */ - -#include "z_en_zl3.h" - -#include "vt.h" -#include "overlays/actors/ovl_En_Encount2/z_en_encount2.h" -#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" -#include "objects/object_zl2/object_zl2.h" -#include "objects/object_zl2_anime2/object_zl2_anime2.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/code_800FCE80.h" -#include "def/code_800FD970.h" -#include "def/graph.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_en_item00.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" -#include "def/z_skelanime.h" - -#define FLAGS ACTOR_FLAG_4 - -void EnZl3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZl3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZl3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZl3_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B59AD0(EnZl3* this, GlobalContext* globalCtx); - -static ColliderCylinderInitType1 sCylinderInit = { - { - COLTYPE_HIT0, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 25, 80, 0, { 0, 0, 0 } }, -}; - -static void* sEyeTextures[] = { gZelda2EyeOpenTex, gZelda2EyeHalfTex, gZelda2EyeShutTex, gZelda2Eye03Tex, - gZelda2Eye04Tex, gZelda2Eye05Tex, gZelda2Eye06Tex, NULL }; - -static void* sMouthTextures[] = { gZelda2MouthSeriousTex, gZelda2MouthHappyTex, gZelda2MouthOpenTex }; - -static s32 D_80B5A468 = 0; - -static Vec3f D_80B5A46C = { 0.0f, 0.0f, 0.0f }; - -static Vec3f D_80B5A478 = { 0.0f, 10.0f, 0.0f }; - -static f32 D_80B5A484 = 0.0f; - -static Vec3f D_80B5A488 = { 0.0f, 0.0f, 0.0f }; - -static s32 D_80B5A494 = -1; - -static Vec3f D_80B5A498 = { 148.0f, 260.0f, -87.0f }; - -static Vec3f D_80B5A4A4 = { -12.0f, 260.0f, -147.0f }; - -static Vec3f D_80B5A4B0 = { 42.0f, 260.0f, 13.0f }; - -static u32 D_80B5A4BC = 0; - -void func_80B533B0(Actor* thisx, GlobalContext* globalCtx) { - EnZl3* this = (EnZl3*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); -} - -void func_80B533FC(EnZl3* this, GlobalContext* globalCtx) { - ColliderCylinder* collider = &this->collider; - s32 pad[4]; - - Collider_UpdateCylinder(&this->actor, collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); -} - -void EnZl3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnZl3* this = (EnZl3*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80B53468(void) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ESCAPE); -} - -BossGanon2* func_80B53488(EnZl3* this, GlobalContext* globalCtx) { - if (this->ganon == NULL) { - Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].head; - - while (actorIt != NULL) { - if (actorIt->id == ACTOR_BOSS_GANON2) { - this->ganon = (BossGanon2*)actorIt; - break; - } - actorIt = actorIt->next; - } - } - return this->ganon; -} - -void EnZl3_UpdateEyes(EnZl3* this) { - s32 pad[2]; - s16* eyeTexIndex = &this->eyeTexIndex; - s16* blinkTimer = &this->blinkTimer; - - if (DECR(*blinkTimer) == 0) { - *blinkTimer = Rand_S16Offset(60, 60); - } - *eyeTexIndex = *blinkTimer; - if (*eyeTexIndex >= 3) { - *eyeTexIndex = 0; - } -} - -void EnZl3_setEyeIndex(EnZl3* this, s16 index) { - this->eyeTexIndex = index; -} - -void EnZl3_setMouthIndex(EnZl3* this, s16 index) { - this->mouthTexIndex = index; -} - -void func_80B5357C(EnZl3* this, GlobalContext* globalCtx) { - Vec3f* thisPos = &this->actor.world.pos; - Vec3f sp20; - - sp20.x = thisPos->x + ((Rand_ZeroOne() - 0.5f) * 10.0f); - sp20.y = thisPos->y; - sp20.z = thisPos->z + ((Rand_ZeroOne() - 0.5f) * 10.0f); - Item_DropCollectible(globalCtx, &sp20, 3); -} - -void func_80B53614(EnZl3* this, GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_RIVER_SOUND, -442.0f, 4102.0f, -371.0f, 0, 0, 0, 0x12); -} - -void func_80B5366C(EnZl3* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 30.0f, 30.0f, 5); -} - -void func_80B536B4(EnZl3* this) { - this->actor.bgCheckFlags &= ~0x9; -} - -void func_80B536C4(EnZl3* this) { - s32 pad[2]; - Vec3s* vec1 = &this->unk_3F8.unk_08; - Vec3s* vec2 = &this->unk_3F8.unk_0E; - - Math_SmoothStepToS(&vec1->x, 0, 20, 6200, 100); - Math_SmoothStepToS(&vec1->y, 0, 20, 6200, 100); - Math_SmoothStepToS(&vec2->x, 0, 20, 6200, 100); - Math_SmoothStepToS(&vec2->y, 0, 20, 6200, 100); -} - -void func_80B53764(EnZl3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->unk_3F8.unk_18 = player->actor.world.pos; - this->unk_3F8.unk_14 = kREG(16) - 16.0f; - func_80034A14(&this->actor, &this->unk_3F8, kREG(17) + 0xC, 2); -} - -s32 func_80B537E8(EnZl3* this) { - s16 yawTowardsPlayer = this->actor.yawTowardsPlayer; - s16* rotY = &this->actor.world.rot.y; - s16* unk_3D0 = &this->unk_3D0; - s16 retVal; - s16 pad[2]; - - Math_SmoothStepToS(unk_3D0, ABS((s16)(yawTowardsPlayer - *rotY)), 5, 6200, 100); - retVal = Math_SmoothStepToS(rotY, yawTowardsPlayer, 5, *unk_3D0, 100); - this->actor.shape.rot.y = *rotY; - return retVal; -} - -void func_80B538B0(EnZl3* this) { - s16 yawTowardsPlayer = this->actor.yawTowardsPlayer; - s16* rotY = &this->actor.world.rot.y; - - if (ABS((s16)(yawTowardsPlayer - *rotY)) >= 0x1556) { - D_80B5A468 = 1; - } - - if (D_80B5A468 != 0) { - if (!func_80B537E8(this)) { - D_80B5A468 = 0; - } - } else { - this->unk_3D0 = 0; - } -} - -s32 EnZl3_UpdateSkelAnime(EnZl3* this) { - return SkelAnime_Update(&this->skelAnime); -} - -s32 func_80B5396C(EnZl3* this) { - return this->unk_3C8; -} - -void func_80B53974(EnZl3* this, u8 arg1) { - this->unk_3C8 = arg1; -} - -void func_80B53980(EnZl3* thisx, s16 y, s32 idx) { - EnZl3* this = (EnZl3*)thisx; // this function might take thisx - s32 action = this->action; - s16 y2 = y; - s32 yTemp; - f32 curFrame; - f32 unk_3DC; - - if (this->unk_2FC != 0) { - SkelAnime* skelAnime = &this->skelAnime; - s32 temp25C = this->unk_25C[idx]; - s32 temp28C = (s16)(y + this->unk_28C[idx]); - s32 temp2BC = y - this->unk_2BC[idx]; - - if ((s32)fabsf(temp2BC) > 0x8000) { - if (y2 > 0) { - temp2BC -= 0x10000; - } else { - temp2BC += 0x10000; - } - } - - if ((idx != 0 || action != 4) && (temp2BC != 0)) { - temp25C += (temp2BC - temp25C) / 16; - } - - if (temp25C != 0) { - temp25C -= temp25C / 10; - } - - if ((s16)(temp28C - y) != 0) { - temp25C -= (s16)(temp28C - y) / 50; - } - - temp28C += temp25C; - if (((this->unk_25C[idx] * temp25C) <= 0) && (((s16)(temp28C - y) > -0x64) && ((s16)(temp28C - y) < 0x64))) { - temp28C = y; - temp25C = 0; - } - if (idx == 0 && action == 3) { - yTemp = y + -11000; - if (skelAnime->mode == 2) { - curFrame = skelAnime->curFrame; - unk_3DC = this->unk_3DC; - yTemp = (s32)((curFrame / unk_3DC) * -11000) + y; - if (0) {}; - if (temp28C >= yTemp) { - temp28C = yTemp; - if (temp25C > 0) { - temp25C /= -2; - } - } - } else { - if (temp28C >= yTemp) { - temp28C = yTemp; - if (temp25C > 0) { - temp25C /= -2; - } - } - } - } - this->unk_25C[idx] = temp25C; - this->unk_28C[idx] = temp28C - y; - } - this->unk_2BC[idx] = y; -} - -void func_80B53B64(EnZl3* this, s16 z, s32 idx) { - SkelAnime* skelAnime = &this->skelAnime; - s32 action = this->action; - s32 phi_a1; - s32 idx25C; - s16 temp_t1; - s32 temp_a0; - s32 phi_v0; - s32 phi_v1; - s32 phi_v1_2; - - if (idx == 2) { - phi_a1 = 15000; - idx25C = 0; - } else if (idx == 5) { - phi_a1 = 13000; - idx25C = 3; - } else if (idx == 8) { - phi_a1 = 12000; - idx25C = 6; - } else if (idx == 11) { - phi_a1 = 0x4000; - idx25C = 9; - } else if (idx == 14) { - phi_a1 = 0x4000; - idx25C = 12; - } else if (idx == 17) { - phi_a1 = 0x4000; - idx25C = 15; - } else { - phi_a1 = 0x4000; - idx25C = 18; - } - - if (this->unk_2FC != 0) { - phi_v0 = this->unk_25C[idx]; - temp_a0 = (s16)(z + this->unk_28C[idx]); - phi_v1 = z - this->unk_2BC[idx]; - - if ((s32)fabsf(phi_v1) > 0x8000) { - if (z > 0) { - phi_v1 -= 0x10000; - } else { - phi_v1 += 0x10000; - } - } - - if (idx25C >= 0) { - phi_v1 += ABS(this->unk_25C[idx25C]) / 3; - } - - if (idx == 2 && (action == 5 || action == 24)) { - if (phi_v1 != 0) { - phi_v0 -= (phi_v1 - phi_v0) / 10; - } - } else if (idx == 2 && action == 22 && skelAnime->mode == 2) { - if (phi_v1 != 0) { - phi_v0 -= (phi_v1 - phi_v0) / 10; - } - } else if (idx == 2 && (action == 20 || action == 21) && skelAnime->mode == 2) { - if (phi_v1 != 0) { - phi_v0 -= (phi_v1 - phi_v0) / 10; - } - } else { - if (phi_v1 != 0) { - phi_v0 += (phi_v1 - phi_v0) / 16; - } - } - - if (phi_v0 != 0) { - phi_v0 -= phi_v0 / 10; - } - - if ((s16)(temp_a0 - phi_a1) != 0) { - phi_v0 -= (s16)(temp_a0 - phi_a1) / 50; - } - - temp_a0 += phi_v0; - phi_v1 = (s16)(temp_a0 - phi_a1); - - if (((this->unk_25C[idx] * phi_v0) <= 0) && (phi_v1 > -100) && (phi_v1 < 100)) { - temp_a0 = phi_a1; - phi_v0 = 0; - } - - if (idx == 2) { - if (action == 4) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3E0 = this->unk_3E0; - - phi_v1_2 = (s32)(((unk_3E0 - curFrame) / unk_3E0) * -2000.0f) + phi_a1; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } - } else if (action == 5) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3E4 = this->unk_3E4; - - phi_v1_2 = (s32)((curFrame / unk_3E4) * -2000.0f) + phi_a1; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } else { - phi_v1_2 = phi_a1 - 2000; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } - } else if ((action == 20) || (action == 21)) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3F4 = this->unk_3F4; - - if (curFrame <= 42.0f) { - phi_v1_2 = phi_a1 - 2000; - } else { - phi_v1_2 = (s32)((((curFrame - 42.0f) * 6200.0f) / (unk_3F4 - 42.0f)) + -2000.0f) + phi_a1; - } - - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } else { - phi_v1_2 = phi_a1 + 4200; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } - } else if (action == 22) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3EC = this->unk_3EC; - - phi_v1_2 = (s32)(((curFrame / unk_3EC) * -5200.0f) + 4200.0f) + phi_a1; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } else { - phi_v1_2 = phi_a1 - 2000; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } - } else if (action == 23) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3F0 = this->unk_3F0; - - phi_v1_2 = (s32)(((curFrame / unk_3F0) * -7600.0f) + -2000.0f) + phi_a1; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } else { - phi_v1_2 = phi_a1 - 9600; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } - } else if (action == 24) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3E8 = this->unk_3E8; - - phi_v1_2 = (s32)(((curFrame / unk_3E8) * 21000.0f) + -9600.0f) + phi_a1; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } else { - phi_v1_2 = phi_a1 + 11400; - if (phi_v1_2 >= temp_a0) { - temp_a0 = phi_v1_2; - if (phi_v0 < 0) { - phi_v0 /= -2; - } - } - } - } - } else if (idx == 11 || idx == 17) { - if (action == 4) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3E0 = this->unk_3E0; - - phi_v1_2 = (s32)((curFrame / unk_3E0) * -7000.0f) + phi_a1; - if (temp_a0 >= phi_v1_2) { - temp_a0 = phi_v1_2; - if (phi_v0 > 0) { - phi_v0 /= -2; - } - } - } else { - phi_v1_2 = phi_a1 - 7000; - if (temp_a0 >= phi_v1_2) { - temp_a0 = phi_v1_2; - if (phi_v0 > 0) { - phi_v0 /= -2; - } - } - } - } else if (action == 5) { - if (skelAnime->mode == 2) { - f32 curFrame = skelAnime->curFrame; - f32 unk_3E4 = this->unk_3E4; - - phi_v1_2 = (s32)(((unk_3E4 - curFrame) / unk_3E4) * -7000.0f) + phi_a1; - if (temp_a0 >= phi_v1_2) { - temp_a0 = phi_v1_2; - if (phi_v0 > 0) { - phi_v0 /= -2; - } - } - } - } - } - this->unk_25C[idx] = phi_v0; - this->unk_28C[idx] = temp_a0 - z; - } - this->unk_2BC[idx] = z; -} - -void func_80B54360(EnZl3* this, s16 arg1, s32 arg2) { - if (this->unk_2FC != 0) { - s32 temp_v1 = this->unk_28C[arg2] - arg1; - s16 temp_t0 = temp_v1; - s32 temp_t2 = temp_t0; - s32 temp_t3 = this->unk_25C[arg2]; - s32 phi_v0 = temp_t3; - s32 index25C; - s32 phi_t5; - - temp_t3 = arg1 - this->unk_2BC[arg2]; - - if (arg2 == 1) { - index25C = 0; - phi_t5 = this->unk_25C[index25C]; - } else if (arg2 == 4) { - index25C = 3; - phi_t5 = this->unk_25C[index25C]; - } else if (arg2 == 7) { - index25C = 6; - phi_t5 = this->unk_25C[index25C]; - } else if (arg2 == 10) { - index25C = 9; - phi_t5 = ABS(this->unk_25C[index25C]); - } else if (arg2 == 13) { - index25C = 12; - phi_t5 = ABS(this->unk_25C[index25C]); - } else if (arg2 == 16) { - index25C = 15; - phi_t5 = -ABS(this->unk_25C[index25C]); - } else { - index25C = 18; - phi_t5 = -ABS(this->unk_25C[index25C]); - } - - if ((s32)fabsf(temp_t3) > 0x8000) { - if (arg1 > 0) { - temp_t3 -= 0x10000; - } else { - temp_t3 += 0x10000; - } - } - if (index25C >= 0) { - temp_t3 += phi_t5 / 3; - } - - if (temp_t3 != 0) { - phi_v0 += (temp_t3 - phi_v0) / 16; - } - if (phi_v0 != 0) { - phi_v0 -= phi_v0 / 10; - } - if (temp_t0 != 0) { - phi_v0 -= temp_t0 / 50; - } - temp_v1 += phi_v0; - if (((this->unk_25C[arg2] * phi_v0) <= 0) && (temp_t2 > -0x64) && (temp_t2 < 0x64)) { - temp_v1 = 0; - phi_v0 = 0; - } - this->unk_25C[arg2] = phi_v0; - this->unk_28C[arg2] = arg1 + temp_v1; - } - this->unk_2BC[arg2] = arg1; -} - -s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - s32 pad[3]; - EnZl3* this = (EnZl3*)thisx; - s16* unk_28C = this->unk_28C; - Mtx* sp78; - MtxF sp38; - Vec3s sp30; - Vec3s* unk_3F8_unk_08 = &this->unk_3F8.unk_08; - Vec3s* unk_3F8_unk_0E = &this->unk_3F8.unk_0E; - - if (limbIndex == 14) { - sp78 = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 7); - rot->x += unk_3F8_unk_08->y; - rot->z += unk_3F8_unk_08->x; - gSPSegment((*gfx)++, 0x0C, sp78); - - Matrix_Push(); - Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); - Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); - Matrix_Push(); - Matrix_Translate(362.0f, -133.0f, 0.0f, MTXMODE_APPLY); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B53980(this, sp30.y, 0); - func_80B54360(this, sp30.x, 1); - func_80B53B64(this, sp30.z, 2); - } - Matrix_RotateZYX(unk_28C[0] + kREG(31), unk_28C[1] + kREG(32), unk_28C[2] + kREG(33), MTXMODE_APPLY); - Matrix_Translate(-188.0f, -184.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[0], "../z_en_zl3.c", 1490); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B53980(this, sp30.y, 3); - } - Matrix_RotateZYX(unk_28C[3] + kREG(34), unk_28C[4] + kREG(35), unk_28C[5] + kREG(36), MTXMODE_APPLY); - Matrix_Translate(-410.0f, -184.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[1], "../z_en_zl3.c", 1534); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B54360(this, sp30.x, 7); - } - Matrix_RotateZYX(unk_28C[6] + kREG(37), unk_28C[7] + kREG(38), unk_28C[8] + kREG(39), MTXMODE_APPLY); - Matrix_Translate(-1019.0f, -26.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[2], "../z_en_zl3.c", 1554); - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(467.0f, 265.0f, 389.0f, MTXMODE_APPLY); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B53980(this, sp30.y, 9); - func_80B54360(this, sp30.x, 10); - func_80B53B64(this, sp30.z, 11); - } - Matrix_RotateZYX(unk_28C[9] + kREG(40), unk_28C[10] + kREG(41), unk_28C[11] + kREG(42), MTXMODE_APPLY); - Matrix_Translate(-427.0f, -1.0f, -3.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[3], "../z_en_zl3.c", 1579); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B53980(this, sp30.y, 12); - func_80B54360(this, sp30.x, 13); - func_80B53B64(this, sp30.z, 14); - } - Matrix_RotateZYX(unk_28C[12] + kREG(43), unk_28C[13] + kREG(44), unk_28C[14] + kREG(45), MTXMODE_APPLY); - Matrix_Translate(-446.0f, -52.0f, 84.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[4], "../z_en_zl3.c", 1598); - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(467.0f, 265.0f, -389.0f, MTXMODE_APPLY); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B53980(this, sp30.y, 15); - func_80B54360(this, sp30.x, 16); - func_80B53B64(this, sp30.z, 17); - } - Matrix_RotateZYX(unk_28C[15] + kREG(46), unk_28C[16] + kREG(47), unk_28C[17] + kREG(48), MTXMODE_APPLY); - Matrix_Translate(-427.0f, -1.0f, 3.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[5], "../z_en_zl3.c", 1623); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); - if (!FrameAdvance_IsEnabled(globalCtx)) { - func_80B53980(this, sp30.y, 18); - func_80B54360(this, sp30.x, 19); - func_80B53B64(this, sp30.z, 20); - } - Matrix_RotateZYX(unk_28C[18] + kREG(49), unk_28C[19] + kREG(50), unk_28C[20] + kREG(51), MTXMODE_APPLY); - Matrix_Translate(-446.0f, -52.0f, -84.0f, MTXMODE_APPLY); - Matrix_ToMtx(&sp78[6], "../z_en_zl3.c", 1642); - Matrix_Pop(); - Matrix_Pop(); - this->unk_2FC = 1; - } else if (limbIndex == 7) { - rot->x += unk_3F8_unk_0E->y; - rot->y -= unk_3F8_unk_0E->x; - } - return false; -} - -void EnZl3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnZl3* this = (EnZl3*)thisx; - s32 pad; - Vec3f sp34; - s32 pad2; - Vec3f sp24; - Vec3f sp18; - - if (limbIndex == 13) { - sp34 = D_80B5A46C; - Matrix_MultVec3f(&sp34, &this->unk_31C); - } else if (limbIndex == 14) { - sp24 = D_80B5A478; - Matrix_MultVec3f(&sp24, &sp18); - this->actor.focus.pos.x = sp18.x; - this->actor.focus.pos.y = sp18.y; - this->actor.focus.pos.z = sp18.z; - this->actor.focus.rot.x = this->actor.world.rot.x; - this->actor.focus.rot.y = this->actor.world.rot.y; - this->actor.focus.rot.z = this->actor.world.rot.z; - } -} - -s32 func_80B54DB4(EnZl3* this) { - s32 params = this->actor.params >> 8; - - return params & 0xFF; -} - -s32 func_80B54DC4(EnZl3* this) { - s32 params = this->actor.params >> 4; - - return params & 0xF; -} - -s32 func_80B54DD4(EnZl3* this) { - s32 params = this->actor.params; - - return params & 0xF; -} - -void func_80B54DE0(EnZl3* this, GlobalContext* globalCtx) { - s32 idx = this->unk_318; - - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[idx].vromStart); -} - -void func_80B54E14(EnZl3* this, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { - f32 frameCount = Animation_GetLastFrame(animation); - f32 playbackSpeed; - f32 unk0; - f32 fc; - - if (arg4 == 0) { - unk0 = 0.0f; - fc = frameCount; - playbackSpeed = 1.0f; - } else { - unk0 = frameCount; - fc = 0.0f; - playbackSpeed = -1.0f; - } - - Animation_Change(&this->skelAnime, animation, playbackSpeed, unk0, fc, arg2, transitionRate); -} - -void func_80B54EA4(EnZl3* this, GlobalContext* globalCtx) { - f32 posX = this->actor.world.pos.x; - f32 posY = this->actor.world.pos.y; - f32 posZ = this->actor.world.pos.z; - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EG, posX, posY, posZ, 0, 0, 0, 0); -} - -void func_80B54EF4(EnZl3* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_PAIN); -} - -void func_80B54F18(EnZl3* this, GlobalContext* globalCtx) { - if (this->unk_2F8 == 0) { - f32 posX = this->actor.world.pos.x; - f32 posY = this->actor.world.pos.y + (kREG(5) + -26.0f); - f32 posZ = this->actor.world.pos.z; - - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0x4000, - 0, WARP_PURPLE_CRYSTAL); - this->unk_2F8 = 1; - } -} - -void func_80B54FB4(EnZl3* this, GlobalContext* globalCtx) { - osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal_Init通すよ!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - func_80B54E14(this, &gZelda2Anime2Anim_008AD0, 0, 0.0f, 0); - EnZl3_setEyeIndex(this, 4); - EnZl3_setMouthIndex(this, 2); - this->action = 1; - this->drawConfig = 1; - func_80B54F18(this, globalCtx); - this->actor.shape.rot.z = 0; - this->unk_3C4 = this->actor.world.rot.z; - this->actor.world.rot.z = this->actor.shape.rot.z; - osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal_Initは通った!!!!!!!!!!!!!!!!!!!!!!!!!\n"); -} - -void func_80B55054(EnZl3* this) { - if (this->unk_328 != 0) { - Actor* child = this->actor.child; - - if (child != NULL) { - f32* temp_v0 = &this->unk_2EC; - - if (*temp_v0 < 19.0f) { - ((DoorWarp1*)child)->crystalAlpha = (20.0f - *temp_v0) * 12.75f; - *temp_v0 += 1.0f; - } else { - Actor_Kill(child); - this->actor.child = NULL; - } - } - } -} - -void func_80B550F0(EnZl3* this) { - Actor* child = this->actor.child; - - if (child != NULL) { - child->world.pos.x = this->actor.world.pos.x; - child->world.pos.y = this->actor.world.pos.y + (kREG(5) + -26.0f); - child->world.pos.z = this->actor.world.pos.z; - } -} - -void func_80B55144(EnZl3* this) { - f32* fl = &D_80B5A484; - - if (1) {} // necessary to match - - if (*fl < 2.0f) { - *fl += 1.0f; - EnZl3_setEyeIndex(this, 2); - } else if (*fl < 4.0f) { - *fl += 1.0f; - EnZl3_setEyeIndex(this, 1); - } else { - EnZl3_UpdateEyes(this); - } -} - -void func_80B551E0(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_008AD0, 0, 0.0f, 0); - this->action = 1; -} - -void func_80B55220(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_0091D8, 2, 0.0f, 0); - this->action = 2; - EnZl3_setMouthIndex(this, 0); -} - -void func_80B55268(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_0091D8, 2, 0.0f, 0); - this->action = 3; -} - -void func_80B552A8(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_0099A0, 0, 0.0f, 0); - } -} - -void func_80B552DC(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_00A598, 2, -8.0f, 0); - func_80B54EF4(this); - EnZl3_setMouthIndex(this, 2); - this->action = 4; - func_80B53468(); -} - -void func_80B55334(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_00AACC, 0, 0.0f, 0); - } -} - -void func_80B55368(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_00A334, 2, -8.0f, 0); - EnZl3_setMouthIndex(this, 0); - this->action = 5; -} - -void func_80B553B4(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, 0.0f, 0); - } -} - -void func_80B553E8(EnZl3* this, GlobalContext* globalCtx) { - func_80B59AD0(this, globalCtx); -} - -void func_80B55408(EnZl3* this) { - Actor* child = this->actor.child; - - if (child != NULL) { - Actor_Kill(child); - } - Actor_Kill(&this->actor); -} - -void func_80B55444(EnZl3* this, GlobalContext* globalCtx) { - s32 temp_v0 = func_80B5396C(this); - - if (temp_v0 >= 0) { - s32 unk_2F0 = this->unk_2F0; - - if (temp_v0 != unk_2F0) { - switch (temp_v0) { - case 0: - func_80B551E0(this); - break; - case 1: - EnZl3_setEyeIndex(this, 3); - func_80B54EF4(this); - break; - case 3: - func_80B55220(this); - break; - case 4: - func_80B55268(this); - break; - case 5: - func_80B552DC(this); - break; - case 6: - func_80B55368(this); - break; - case 7: - func_80B553E8(this, globalCtx); - break; - case 2: - func_80B55408(this); - break; - case 8: - this->unk_328 = 1; - default: - osSyncPrintf("En_Zl3_inFinal_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_2F0 = temp_v0; - } - } -} - -void func_80B55550(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateSkelAnime(this); - func_80B550F0(this); - func_80B55444(this, globalCtx); -} - -void func_80B555A4(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_setEyeIndex(this, 2); - func_80B550F0(this); - func_80B55054(this); - func_80B55444(this, globalCtx); -} - -void func_80B55604(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - func_80B55144(this); - func_80B552A8(this, EnZl3_UpdateSkelAnime(this)); - func_80B55054(this); - func_80B55444(this, globalCtx); -} - -void func_80B5566C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55334(this, EnZl3_UpdateSkelAnime(this)); - func_80B55444(this, globalCtx); -} - -void func_80B556CC(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B553B4(this, EnZl3_UpdateSkelAnime(this)); - func_80B55444(this, globalCtx); -} - -void func_80B5572C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B55444(this, globalCtx); -} - -void func_80B55780(EnZl3* this, GlobalContext* globalCtx) { - osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal2_Init通すよ!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - func_80B54E14(this, &gZelda2Anime2Anim_005A0C, 0, 0.0f, 0); - this->action = 7; - this->drawConfig = 1; - osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal2_Initは通った!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - EnZl3_setMouthIndex(this, 1); - this->actor.flags &= ~ACTOR_FLAG_0; -} - -void func_80B55808(EnZl3* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_PAIN); -} - -void func_80B5582C(EnZl3* this) { - Audio_PlaySoundRandom(&D_80B5A488, NA_SE_VO_Z1_CRY_0, NA_SE_VO_Z1_CRY_1 - NA_SE_VO_Z1_CRY_0 + 1); -} - -void func_80B5585C(EnZl3* this) { - SkelAnime* skelAnime = &this->skelAnime; - - if ((skelAnime->mode == 2) && Animation_OnFrame(skelAnime, 4.0f)) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_PAIN); - } -} - -void func_80B558A8(EnZl3* this) { - s32 pad[4]; - s16 thisRotY = this->actor.world.rot.y; - Vec3f* unk_338 = &this->unk_338; - - *unk_338 = this->unk_32C = this->actor.world.pos; - - unk_338->z += (-1.6074f * Math_CosS(thisRotY)) - (3.1620007f * Math_SinS(thisRotY)); - unk_338->x += (-1.6074f * Math_SinS(thisRotY)) + (3.1620007f * Math_CosS(thisRotY)); - unk_338->y += -0.012199402f; -} - -void func_80B559C4(EnZl3* this) { - Vec3f* thisPos = &this->actor.world.pos; - Vec3f* unk_32C = &this->unk_32C; - Vec3f* unk_338 = &this->unk_338; - f32 temp_f0 = Environment_LerpWeightAccelDecel(Animation_GetLastFrame(&gZelda2Anime2Anim_005248), 0, - (s32)this->skelAnime.curFrame, 3, 3); - - thisPos->x = unk_32C->x + (temp_f0 * (unk_338->x - unk_32C->x)); - thisPos->z = unk_32C->z + (temp_f0 * (unk_338->z - unk_32C->z)); -} - -void func_80B55A58(EnZl3* this, GlobalContext* globalCtx) { - if (globalCtx->activeCamera == MAIN_CAM) { - func_80B537E8(this); - } -} - -void func_80B55A84(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_005A0C, 0, 0.0f, 0); - this->action = 7; -} - -void func_80B55AC4(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_00499C, 2, -8.0f, 0); - this->action = 8; -} - -void func_80B55B04(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_004408, 0, 0.0f, 0); - } -} - -void func_80B55B38(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_006508, 2, -8.0f, 0); - this->action = 9; -} - -void func_80B55B78(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_0061C4, 0, 0.0f, 0); - } -} - -void func_80B55BAC(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_005248, 2, -8.0f, 0); - func_80B558A8(this); - func_80B55808(this); - EnZl3_setMouthIndex(this, 2); - this->action = 10; -} - -void func_80B55C0C(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_0054E0, 0, 0.0f, 0); - this->action = 11; -} - -void func_80B55C4C(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B55C0C(this); - } -} - -void func_80B55C70(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_008684, 2, -8.0f, 0); - this->action = 12; - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; -} - -void func_80B55CCC(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_006F04, 0, 0.0f, 0); - } -} - -void func_80B55D00(EnZl3* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->action = 13; - } else if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4300) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.textId = 0x70D5; - func_8002F2F4(&this->actor, globalCtx); - } else { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; - } -} - -void func_80B55DB0(EnZl3* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; - this->action = 12; - } -} - -void func_80B55E08(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_006AB0, 2, -8.0f, 0); - this->action = 14; -} - -void func_80B55E48(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_008050, 0, 0.0f, 0); - } -} - -void func_80B55E7C(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_007A78, 2, -8.0f, 0); - this->action = 15; -} - -void func_80B55EBC(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_007C84, 0, 0.0f, 0); - } -} - -void func_80B55EF0(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_0082F8, 2, -8.0f, 0); - this->action = 16; - EnZl3_setMouthIndex(this, 0); -} - -void func_80B55F38(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_003FF8, 0, 0.0f, 0); - } -} - -void func_80B55F6C(EnZl3* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->action = 0x12; - } else if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4300) { - BossGanon2* bossGanon2 = func_80B53488(this, globalCtx); - - if ((bossGanon2 != NULL) && (bossGanon2->unk_324 <= (10.0f / 81.0f))) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.textId = 0x7059; - func_8002F2F4(&this->actor, globalCtx); - } - } else { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; - } -} - -void func_80B5604C(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_007664, 2, -8.0f, 0); - this->action = 17; - func_80B5582C(this); -} - -void func_80B56090(EnZl3* this, s32 arg1) { - s32* unk_2F0 = &this->unk_2F0; - - if (func_80B5396C(this) == *unk_2F0) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_003FF8, 0, 0.0f, 0); - this->action = 16; - func_80B53974(this, 7); - this->unk_2F0 = 7; - } - } -} - -void func_80B56108(EnZl3* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; - this->action = 16; - } -} - -void func_80B56160(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_0001D8, 0, 0.0f, 0); - this->action = 19; -} - -void func_80B561A0(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_001110, 2, -8.0f, 0); - this->action = 20; -} - -void func_80B561E0(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_0004F4, 0, 0.0f, 0); - } -} - -void func_80B56214(EnZl3* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - this->action = 21; - } else if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4300) { - BossGanon2* bossGanon2 = func_80B53488(this, globalCtx); - - if (bossGanon2 != NULL) { - if (bossGanon2->unk_324 <= (10.0f / 81.0f)) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.flags |= ACTOR_FLAG_0; - this->actor.textId = 0x7059; - func_8002F2F4(&this->actor, globalCtx); - } - } - } else { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; - } -} - -void func_80B562F4(EnZl3* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); - this->actor.flags &= ~ACTOR_FLAG_0; - this->action = 20; - } -} - -void func_80B5634C(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_002348, 2, -8.0f, 0); - this->action = 22; -} - -void func_80B5638C(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_00210C, 0, 0.0f, 0); - } -} - -void func_80B563C0(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_002E54, 2, -8.0f, 0); - this->action = 23; -} - -void func_80B56400(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_002710, 0, 0.0f, 0); - } -} - -void func_80B56434(EnZl3* this) { - func_80B54E14(this, &gZelda2Anime2Anim_001D8C, 2, -8.0f, 0); - this->action = 24; -} - -void func_80B56474(EnZl3* this, s32 arg1) { - if (arg1 != 0) { - func_80B54E14(this, &gZelda2Anime2Anim_0014DC, 0, 0.0f, 0); - } -} - -void func_80B564A8(EnZl3* this, GlobalContext* globalCtx) { - s32 temp_v0; - s32* val = &D_80B5A494; - - temp_v0 = func_80B5396C(this); - - if (*val > 0) { - *val -= 1; - } else if (*val == 0) { - *val -= 1; - if (temp_v0 == 8) { - func_80B5604C(this); - } - } - - if (temp_v0 >= 0) { - s32 unk_2F0 = this->unk_2F0; - - if (temp_v0 != unk_2F0) { - switch (temp_v0) { - case 0: - func_80B55A84(this); - break; - case 1: - func_80B55AC4(this); - break; - case 2: - func_80B55B38(this); - break; - case 3: - func_80B55BAC(this); - break; - case 4: - func_80B55C70(this); - break; - case 5: - func_80B55E08(this); - break; - case 6: - func_80B55E7C(this); - break; - case 7: - func_80B55EF0(this); - break; - case 8: - *val = 10; - break; - case 9: - func_80B56160(this); - break; - case 10: - func_80B561A0(this); - break; - case 11: - func_80B5634C(this); - break; - case 12: - func_80B563C0(this); - break; - case 13: - func_80B56434(this); - break; - case 14: - Actor_Kill(&this->actor); - break; - default: - osSyncPrintf("En_Zl3_inFinal2_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); - } - this->unk_2F0 = temp_v0; - } - } -} - -void func_80B56658(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B564A8(this, globalCtx); -} - -void func_80B566AC(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55B04(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); -} - -void func_80B5670C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55B78(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); -} - -void func_80B5676C(EnZl3* this, GlobalContext* globalCtx) { - s32 something; - - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - something = EnZl3_UpdateSkelAnime(this); - func_80B559C4(this); - func_80B55C4C(this, something); -} - -void func_80B567CC(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B564A8(this, globalCtx); -} - -void func_80B5682C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B55A58(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55CCC(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); - func_80B55D00(this, globalCtx); -} - -void func_80B568B4(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B537E8(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B55DB0(this, globalCtx); -} - -void func_80B5691C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55E48(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); -} - -void func_80B5697C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55EBC(this, EnZl3_UpdateSkelAnime(this)); - func_80B5585C(this); - func_80B564A8(this, globalCtx); -} - -void func_80B569E4(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B537E8(this); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55F38(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); - func_80B55F6C(this, globalCtx); -} - -void func_80B56A68(EnZl3* this, GlobalContext* globalCtx) { - s32 something; - - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B537E8(this); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - something = EnZl3_UpdateSkelAnime(this); - func_80B564A8(this, globalCtx); - func_80B56090(this, something); -} - -void func_80B56AE0(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B537E8(this); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B55F38(this, EnZl3_UpdateSkelAnime(this)); - func_80B56108(this, globalCtx); -} - -void func_80B56B54(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B564A8(this, globalCtx); -} - -void func_80B56BA8(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B561E0(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); - func_80B56214(this, globalCtx); -} - -void func_80B56C24(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B562F4(this, globalCtx); -} - -void func_80B56C84(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B5638C(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); -} - -void func_80B56CE4(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B56400(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); -} - -void func_80B56D44(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B56474(this, EnZl3_UpdateSkelAnime(this)); - func_80B564A8(this, globalCtx); -} - -void func_80B56DA4(EnZl3* this) { - func_800788CC(NA_SE_EV_ZELDA_POWER); -} - -void func_80B56DC8(EnZl3* this) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_PAIN); -} - -void func_80B56DEC(EnZl3* this) { - SkelAnime* skelAnime = &this->skelAnime; - - if ((skelAnime->mode == 2) && Animation_OnFrame(skelAnime, 9.0f) != 0) { - func_80078914(&this->actor.projectedPos, NA_SE_VO_Z1_OPENDOOR); - } -} - -void func_80B56E38(EnZl3* this, GlobalContext* globalCtx) { - s32 pad[2]; - s32 sfxId; - SkelAnime* sp20 = &this->skelAnime; - - if ((Animation_OnFrame(sp20, 6.0f) || Animation_OnFrame(sp20, 0.0f)) && (this->actor.bgCheckFlags & 1)) { - sfxId = 0x800; - sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - func_80078914(&this->actor.projectedPos, sfxId); - } -} - -void func_80B56EB8(EnZl3* this, GlobalContext* globalCtx) { - Flags_SetSwitch(globalCtx, func_80B54DB4(this)); -} - -s32 func_80B56EE4(EnZl3* this, GlobalContext* globalCtx) { - return Flags_GetSwitch(globalCtx, func_80B54DB4(this)); -} - -void func_80B56F10(EnZl3* this, GlobalContext* globalCtx) { - s32 waypoint; - Path* pathHead = globalCtx->setupPathList; - - if (pathHead != NULL) { - waypoint = func_80B54DC4(this); - pathHead += waypoint; - this->unk_30C = pathHead; - this->unk_310 = pathHead->count; - osSyncPrintf("En_Zl3_Get_path_info レールデータをゲットだぜ = %d!!!!!!!!!!!!!!\n", waypoint); - } else { - osSyncPrintf("En_Zl3_Get_path_info レールデータが無い!!!!!!!!!!!!!!!!!!!!\n"); - } -} - -s32 func_80B56F8C(EnZl3* this, s32 arg1) { - s32 unk_310 = this->unk_310; - - if (unk_310 > arg1) { - return 1; - } - return 0; -} - -Vec3s* func_80B56FAC(EnZl3* this, s32 arg1) { - Vec3s* point; - Path* pathList = this->unk_30C; - - if ((pathList != NULL) && func_80B56F8C(this, arg1)) { - point = &((Vec3s*)SEGMENTED_TO_VIRTUAL(pathList->points))[arg1]; - return point; - } - return NULL; -} - -s32 func_80B57034(EnZl3* this, s32 arg1, s32 arg2) { - Vec3s* vec1 = func_80B56FAC(this, arg1); - Vec3s* vec2 = func_80B56FAC(this, arg2); - - if ((vec2 != NULL) && (vec1 != NULL)) { - f32 xDiff = vec2->x - vec1->x; - f32 zDiff = vec2->z - vec1->z; - - return ((xDiff == 0.0f) && (zDiff == 0.0f)) ? 0 : (s16)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); - } - return 0; -} - -s16 func_80B57104(EnZl3* this, s32 arg1) { - Vec3s* point = func_80B56FAC(this, arg1); - - if (point != NULL) { - f32 xDiff = point->x - this->actor.world.pos.x; - f32 zDiff = point->z - this->actor.world.pos.z; - - if ((xDiff != 0.0f) || (zDiff != 0.0f)) { - return Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI); - } - } - return 0; -} - -s32 func_80B571A8(EnZl3* this) { - s32 pad; - s32 unk_314 = this->unk_314; - s32 pad2; - - if (func_80B56F8C(this, unk_314 + 1) == 0) { - return this->actor.shape.rot.y; - } else { - return func_80B57034(this, unk_314, unk_314 + 1); - } -} - -s32 func_80B571FC(EnZl3* this) { - s32 pad; - s32 unk_314 = this->unk_314; - - if (func_80B56F8C(this, unk_314) == 0) { - return this->actor.shape.rot.y; - } else { - return func_80B57104(this, unk_314); - } -} - -void func_80B57240(EnZl3* this) { - s32 temp_a1 = func_80B571FC(this); - s16* rotY = &this->actor.world.rot.y; - - Math_SmoothStepToS(rotY, temp_a1, 2, 6400, 1000); - this->actor.shape.rot.y = *rotY; -} - -void func_80B57298(EnZl3* this) { - s16* rotY = &this->actor.world.rot.y; - s16 temp_a1 = func_80B571A8(this); - - Math_SmoothStepToS(rotY, temp_a1, 2, 6400, 1000); - this->actor.shape.rot.y = *rotY; -} - -u16 func_80B572F0(GlobalContext* globalCtx) { - s16 sceneNum = globalCtx->sceneNum; - u16 ret; - - if (sceneNum == SCENE_GANON_SONOGO) { - ret = 0x71A8; - } else if (sceneNum == SCENE_GANON_FINAL) { - ret = 0x71A9; - } else { - ret = 0x71AB; - } - return ret; -} - -s32 func_80B57324(EnZl3* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - return 1; - } - return 0; -} - -void func_80B57350(EnZl3* this, GlobalContext* globalCtx) { - s16 temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - - if (ABS(temp_v0) <= 0x4300) { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->actor.textId = func_80B572F0(globalCtx); - func_8002F2F4(&this->actor, globalCtx); - } -} - -s32 func_80B573C8(EnZl3* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - return 1; - } - return 0; -} - -s32 func_80B573FC(EnZl3* this, GlobalContext* globalCtx, f32 arg2) { - Player* player = GET_PLAYER(globalCtx); - f32 playerX = player->actor.world.pos.x; - f32 playerZ = player->actor.world.pos.z; - f32 thisX = this->actor.world.pos.x; - f32 thisZ = this->actor.world.pos.z; - - if (SQ(playerX - thisX) + SQ(playerZ - thisZ) < SQ(arg2)) { - return 1; - } - return 0; -} - -s32 func_80B57458(EnZl3* this, GlobalContext* globalCtx) { - Vec3f* thisPos = &this->actor.world.pos; - f32 thisX = thisPos->x; - f32 thisZ = thisPos->z; - Player* player = GET_PLAYER(globalCtx); - Vec3f* playerPos = &player->actor.world.pos; - s32 pad; - f32 playerX = playerPos->x; - f32 playerZ = playerPos->z; - f32 temp_f12 = playerX - thisX; - f32 temp_f13 = playerZ - thisZ; - s16 temp_v0; - s16 temp_v1 = func_80B571A8(this); - - if (temp_f12 == 0.0f && temp_f13 == 0.0f) { - return 1; - } - - temp_v0 = (s16)(temp_v1 - (s16)(Math_FAtan2F(temp_f12, temp_f13) * (0x8000 / M_PI))); - - if (temp_v0 < 0x1555) { - return 1; - } else if ((temp_v0 < 0x4000) && func_80B573FC(this, globalCtx, 150.0f)) { - return 1; - } else { - return 0; - } -} - -s32 func_80B57564(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B573FC(this, globalCtx, 50.0f) || func_80B57458(this, globalCtx)) { - return 1; - } - return 0; -} - -s32 func_80B575B0(EnZl3* this, GlobalContext* globalCtx) { - return func_80B573FC(this, globalCtx, 150.0f); -} - -s32 func_80B575D0(EnZl3* this, GlobalContext* globalCtx) { - return func_80B573FC(this, globalCtx, 50.0f); -} - -s32 func_80B575F0(EnZl3* this, GlobalContext* globalCtx) { - s16 sceneNum = globalCtx->sceneNum; - - if ((sceneNum == SCENE_GANON_SONOGO) && (func_80B54DB4(this) == 0x26)) { - s32 unk_314 = this->unk_314; - - if (unk_314 == 1) { - return 1; - } - } - return 0; -} - -void func_80B5764C(EnZl3* this, GlobalContext* globalCtx) { - s16 sceneNum = globalCtx->sceneNum; - - if ((sceneNum == SCENE_GANON_SONOGO) && (func_80B54DB4(this) == 0x26)) { - s32 unk_314 = this->unk_314 + 1; - - if ((unk_314 == 1) && !Gameplay_InCsMode(globalCtx)) { - OnePointCutscene_Init(globalCtx, 1000, 40, &this->actor, MAIN_CAM); - } - } -} - -s32 func_80B576C8(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B575F0(this, globalCtx) && (this->unk_3D8 == 0)) { - return 1; - } - return 0; -} - -void func_80B57704(EnZl3* this, GlobalContext* globalCtx) { - s32 unk_3C4 = this->unk_3C4; - - Flags_SetSwitch(globalCtx, unk_3C4); -} - -void func_80B5772C(EnZl3* this, GlobalContext* globalCtx) { - s32 unk_3C4 = this->unk_3C4; - - Flags_UnsetSwitch(globalCtx, unk_3C4); -} - -void func_80B57754(EnZl3* this, GlobalContext* globalCtx) { - if (gSaveContext.unk_13F0 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1); - func_80B56DA4(this); - } -} - -void func_80B577BC(GlobalContext* globalCtx, Vec3f* vec) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - Vec3f* playerPos = &player->actor.world.pos; - f32 posX = vec->x; - f32 posY = vec->y; - f32 posZ = vec->z; - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TEST, posX, posY, posZ, 0, - (Math_FAtan2F(playerPos->x - posX, playerPos->z - posZ) * (0x8000 / M_PI)), 0, 5); -} - -void func_80B57858(GlobalContext* globalCtx) { - func_80B577BC(globalCtx, &D_80B5A498); - func_80B577BC(globalCtx, &D_80B5A4A4); -} - -s32 func_80B57890(EnZl3* this, GlobalContext* globalCtx) { - s8 pad[2]; - u8 curSpawn = globalCtx->curSpawn; - s16 sceneNum = globalCtx->sceneNum; - s32 result = func_80B54DB4(this); - - if (globalCtx) {} // Needed to match, this if can be almost anywhere and it still matches - - if (sceneNum == SCENE_GANON_SONOGO) { - if ((result == 0x24) && (curSpawn == 0)) { - return 1; - } - if ((result == 0x25) && (curSpawn == 2)) { - return 1; - } - if ((result == 0x26) && (curSpawn == 4)) { - return 1; - } - if ((result == 0x27) && (curSpawn == 6)) { - return 1; - } - if ((result == 0x28) && (curSpawn == 6)) { - return 1; - } - } else if (sceneNum == SCENE_GANON_FINAL) { - if ((result == 0x20) && (curSpawn == 0) && Flags_GetSwitch(globalCtx, 0x37)) { - if ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)) { - return 1; - } - } - if ((result == 0x21) && (curSpawn == 2)) { - return 1; - } - if ((result == 0x22) && (curSpawn == 4)) { - return 1; - } - if ((result == 0x23) && (curSpawn == 6)) { - return 1; - } - } else if (sceneNum == SCENE_GANONTIKA_SONOGO) { - if ((result == 0x29) && (curSpawn == 0)) { - return 1; - } - if ((result == 0x2A) && (curSpawn == 0)) { - return 1; - } - } - return 0; -} - -void func_80B57A74(GlobalContext* globalCtx) { - Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; - //! @bug checks for encount2 in ACTORCAT_PROP but encount2 is in ACTORCAT_ENEMY so this condition is never met - while (actorIt != NULL) { - if (actorIt->id == ACTOR_EN_ENCOUNT2) { - ((EnEncount2*)actorIt)->collapseSpawnerInactive = true; - } - actorIt = actorIt->next; - } -} - -void func_80B57AAC(EnZl3* this, s32 arg1, AnimationHeader* arg2) { - if (arg1 != 0) { - func_80B54E14(this, arg2, 0, -8.0f, 0); - } -} - -void func_80B57AE0(EnZl3* this, GlobalContext* globalCtx) { - s32 pad; - s16 shapeRotY = this->actor.shape.rot.y; - s32 pad2; - Vec3f* unk_354 = &this->unk_354; - Vec3f* unk_348 = &this->unk_348; - Vec3s* temp_v0; - f32 xDiff; - f32 zDiff; - - this->unk_344 = 0; - this->unk_314 += 1; - this->unk_360 = 0.0f; - this->unk_364 = 0.0f; - this->unk_368 = 0.0f; - *unk_348 = this->actor.world.pos; - temp_v0 = func_80B56FAC(this, this->unk_314); - - if (temp_v0 != NULL) { - unk_354->x = temp_v0->x; - unk_354->y = temp_v0->y; - unk_354->z = temp_v0->z; - } else { - unk_354->x = unk_348->x + (Math_SinS(shapeRotY) * 200.0f); - unk_354->y = unk_348->y; - unk_354->z = unk_348->z + (Math_CosS(shapeRotY) * 200.0f); - } - - xDiff = unk_354->x - unk_348->x; - zDiff = unk_354->z - unk_348->z; - this->unk_346 = (s32)(sqrtf(SQ(xDiff) + SQ(zDiff)) / (kREG(6) + 8.0f)); -} - -s32 func_80B57C54(EnZl3* this) { - if (this->unk_344 >= this->unk_346) { - return 1; - } - return 0; -} - -s32 func_80B57C7C(EnZl3* this, GlobalContext* globalCtx) { - return 1; -} - -s32 func_80B57C8C(EnZl3* this) { - return !func_80B56F8C(this, this->unk_314 + 2); -} - -void func_80B57CB4(EnZl3* this, GlobalContext* globalCtx) { - Vec3f* unk_348 = &this->unk_348; - Vec3f* unk_354 = &this->unk_354; - Vec3f* thisPos = &this->actor.world.pos; - f32 temp_f0; - - this->unk_344 += 1; - temp_f0 = Environment_LerpWeightAccelDecel(this->unk_346, 0, this->unk_344, 3, 3); - thisPos->x = unk_348->x + (temp_f0 * (unk_354->x - unk_348->x)); - thisPos->y = (unk_348->y + (temp_f0 * (unk_354->y - unk_348->y))) + this->unk_360; - thisPos->z = unk_348->z + (temp_f0 * (unk_354->z - unk_348->z)); -} - -void func_80B57D60(EnZl3* this, GlobalContext* globalCtx) { - func_80B57240(this); -} - -s32 func_80B57D80(EnZl3* this, GlobalContext* globalCtx) { - s32 pad; - s16* sp32 = &this->actor.shape.rot.y; - struct_80034A14_arg1* unk_3F8 = &this->unk_3F8; - Player* player = GET_PLAYER(globalCtx); - s32 unk_314 = this->unk_314; - s16 temp_v0 = func_80B57104(this, unk_314); - s32 pad2; - s16 phi_v1; - - unk_3F8->unk_18.y = player->actor.world.pos.y; - unk_3F8->unk_18.x = (Math_SinS(temp_v0) * this->actor.xzDistToPlayer) + this->actor.world.pos.x; - unk_3F8->unk_18.z = (Math_CosS(temp_v0) * this->actor.xzDistToPlayer) + this->actor.world.pos.z; - unk_3F8->unk_14 = kREG(16) - 16.0f; - func_80034A14(&this->actor, unk_3F8, kREG(17) + 0xC, 4); - - phi_v1 = ABS(temp_v0 - *sp32); - if (phi_v1 <= 0x320) { - *sp32 = temp_v0; - this->actor.world.rot.y = *sp32; - phi_v1 = 0; - } - this->actor.world.rot.y = *sp32; - return phi_v1; -} - -void func_80B57EAC(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B57324(this, globalCtx)) { - this->action = 26; - } else { - func_80B57350(this, globalCtx); - } -} - -void func_80B57EEC(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B573C8(this, globalCtx)) { - this->action = 27; - } -} - -void func_80B57F1C(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B57D80(this, globalCtx) == 0) { - func_80B54E14(this, &gZelda2Anime2Anim_009BE4, 0, -8.0f, 0); - this->action = 34; - this->unk_314 -= 1; - func_80B57AE0(this, globalCtx); - } -} - -s32 func_80B57F84(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B575D0(this, globalCtx) && func_80B57C7C(this, globalCtx) && !Gameplay_InCsMode(globalCtx)) { - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, -8.0f, 0); - this->action = 36; - this->unk_2EC = 0.0f; - func_80B57A74(globalCtx); - return 1; - } - return 0; -} - -void func_80B58014(EnZl3* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s8 invincibilityTimer = player->invincibilityTimer; - - if (func_80B57324(this, globalCtx)) { - func_80B54E14(this, &gZelda2Anime2Anim_003FF8, 0, -11.0f, 0); - this->action = 29; - func_80B538B0(this); - } else if (func_80B57C8C(this) && func_80B57F84(this, globalCtx)) { - OnePointCutscene_Init(globalCtx, 4000, -99, &this->actor, MAIN_CAM); - this->unk_3D0 = 0; - } else if (func_80B576C8(this, globalCtx) && func_80B575B0(this, globalCtx) && !Gameplay_InCsMode(globalCtx)) { - this->action = 0x1F; - this->unk_3CC = 0.0f; - func_80B537E8(this); - this->unk_3D8 = 1; - OnePointCutscene_Init(globalCtx, 4010, -99, &this->actor, MAIN_CAM); - } else if (!func_80B57C8C(this) && !func_80B576C8(this, globalCtx) && func_80B57564(this, globalCtx)) { - func_80B54E14(this, &gZelda2Anime2Anim_009BE4, 0, -8.0f, 0); - func_80B5764C(this, globalCtx); - this->action = 34; - this->unk_3D0 = 0; - func_80B57AE0(this, globalCtx); - } else if ((invincibilityTimer > 0) || (player->fallDistance >= 0x33)) { - func_80B54E14(this, &gZelda2Anime2Anim_007664, 0, -11.0f, 0); - this->action = 30; - func_80B537E8(this); - func_80B56DC8(this); - } else { - func_80B57350(this, globalCtx); - func_80B538B0(this); - } -} - -void func_80B58214(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B573C8(this, globalCtx)) { - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, -11.0f, 0); - this->action = 28; - this->unk_3D0 = 0; - } -} - -void func_80B58268(EnZl3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s8 invincibilityTimer = player->invincibilityTimer; - - if ((invincibilityTimer <= 0) && (player->fallDistance <= 50)) { - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, -11.0f, 0); - this->action = 28; - this->unk_3D0 = 0; - } -} - -void func_80B582C8(EnZl3* this, GlobalContext* globalCtx) { - f32* unk_3CC = &this->unk_3CC; - s32 pad; - - if (*unk_3CC == kREG(14) + 10.0f) { - *unk_3CC += 1.0f; - func_80B54E14(this, &gZelda2Anime2Anim_008050, 0, -12.0f, 0); - func_80B57704(this, globalCtx); - } else if (*unk_3CC == kREG(15) + 20.0f) { - *unk_3CC += 1.0f; - func_80B56DC8(this); - func_80B54E14(this, &gZelda2Anime2Anim_003FF8, 0, -12.0f, 0); - } else if (*unk_3CC == kREG(16) + 30.0f) { - *unk_3CC += 1.0f; - func_80B57858(globalCtx); - } else if (*unk_3CC == kREG(17) + 40.0f) { - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - *unk_3CC += 1.0f; - } else if (*unk_3CC >= ((kREG(17) + 40.0f) + 1.0f)) { - this->action = 32; - *unk_3CC = 0.0f; - } else { - *unk_3CC += 1.0f; - } -} - -void func_80B584B4(EnZl3* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - s8 invincibilityTimer = player->invincibilityTimer; - Actor* nearbyEnTest = Actor_FindNearby(globalCtx, &this->actor, ACTOR_EN_TEST, ACTORCAT_ENEMY, 8000.0f); - - if (D_80B5A4BC == 0) { - if ((nearbyEnTest == NULL) && (!Gameplay_InCsMode(globalCtx))) { - this->action = 33; - OnePointCutscene_Init(globalCtx, 4011, -99, &this->actor, MAIN_CAM); - } else if (invincibilityTimer > 0) { - func_80B54E14(this, &gZelda2Anime2Anim_003FF8, 0, -12.0f, 0); - D_80B5A4BC = 1; - func_80B56DC8(this); - } - } else { - if ((nearbyEnTest == NULL) && (!Gameplay_InCsMode(globalCtx))) { - func_80B54E14(this, &gZelda2Anime2Anim_007664, 0, -12.0f, 0); - D_80B5A4BC = 0; - this->action = 33; - OnePointCutscene_Init(globalCtx, 4011, -99, &this->actor, MAIN_CAM); - } else if (invincibilityTimer <= 0) { - func_80B54E14(this, &gZelda2Anime2Anim_007664, 0, -12.0f, 0); - D_80B5A4BC = 0; - } - } -} - -void func_80B58624(EnZl3* this, GlobalContext* globalCtx) { - s32 pad[4]; - f32* unk_3CC = &this->unk_3CC; - - if (*unk_3CC == (kREG(18) + 10.0f)) { - *unk_3CC += 1.0f; - func_80B54E14(this, &gZelda2Anime2Anim_008050, 0, -12.0f, 0); - func_80B5772C(this, globalCtx); - } else if (*unk_3CC == kREG(19) + 20.0f) { - *unk_3CC += 1.0f; - this->actor.textId = 0x71AC; - Message_StartTextbox(globalCtx, this->actor.textId, NULL); - func_80B54E14(this, &gZelda2Anime2Anim_003FF8, 0, -12.0f, 0); - } else if (*unk_3CC == ((kREG(19) + 20.0f) + 1.0f)) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - *unk_3CC += 1.0f; - func_80B5357C(this, globalCtx); - func_80B5357C(this, globalCtx); - func_80B5357C(this, globalCtx); - func_80B5357C(this, globalCtx); - func_80B5357C(this, globalCtx); - } - } else { - if (*unk_3CC >= kREG(20) + 30.0f) { - this->action = 28; - func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, -12.0f, 0); - *unk_3CC = 0.0f; - } else { - *unk_3CC += 1.0f; - } - } -} - -void func_80B5884C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54E14(this, &gZelda2Anime2Anim_0038C0, 2, -8.0f, 0); - this->action = 37; - this->unk_36C = 1; -} - -void func_80B58898(EnZl3* this, GlobalContext* globalCtx) { - func_80B54E14(this, &gZelda2Anime2Anim_0038C0, 2, -8.0f, 1); - this->action = 38; - this->unk_374 = 1; -} - -void func_80B588E8(EnZl3* this, GlobalContext* globalCtx) { - func_80B54E14(this, &gZelda2Anime2Anim_009BE4, 0, -8.0f, 0); - func_80B57AE0(this, globalCtx); - this->action = 39; -} - -s32 func_80B58938(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B57C54(this)) { - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, -8.0f, 0); - this->action = 28; - this->unk_3D0 = 0; - return 1; - } - return 0; -} - -s32 func_80B5899C(EnZl3* this, GlobalContext* globalCtx) { - if ((this->actor.bgCheckFlags & 1)) { - Player* player = GET_PLAYER(globalCtx); - s8 invincibilityTimer = player->invincibilityTimer; - - if ((invincibilityTimer > 0) || (player->fallDistance >= 0x33)) { - func_80B54E14(this, &gZelda2Anime2Anim_007664, 2, -11.0f, 0); - this->action = 35; - func_80B56DC8(this); - return 1; - } - } - return 0; -} - -void func_80B58A1C(EnZl3* this, GlobalContext* globalCtx) { - if (!func_80B58938(this, globalCtx)) { - func_80B5899C(this, globalCtx); - } -} - -void func_80B58A50(EnZl3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s8 invincibilityTimer = player->invincibilityTimer; - - if ((invincibilityTimer <= 0) && (player->fallDistance <= 50)) { - func_80B54E14(this, &gZelda2Anime2Anim_009BE4, 0, -11.0f, 0); - this->action = 34; - } -} - -void func_80B58AAC(EnZl3* this, GlobalContext* globalCtx) { - f32* unk_2EC = &this->unk_2EC; - - *unk_2EC += 1.0f; - if ((*unk_2EC >= kREG(7) + 24.0f) && (this->unk_36C == 0)) { - func_80B57754(this, globalCtx); - func_80B5884C(this, globalCtx); - } else if ((*unk_2EC >= kREG(8) + 50.0f) && (this->unk_370 == 0)) { - func_80B56EB8(this, globalCtx); - this->unk_370 = 1; - } else if ((*unk_2EC >= kREG(9) + 56.0f) && (this->unk_374 == 0)) { - func_80B58898(this, globalCtx); - } else if (*unk_2EC >= kREG(10) + 82.0f) { - func_80B588E8(this, globalCtx); - } -} - -void func_80B58C08(EnZl3* this, GlobalContext* globalCtx) { - s32 pad[2]; - Vec3f* unk_348 = &this->unk_348; - Vec3f* unk_354 = &this->unk_354; - Vec3f* thisPos = &this->actor.world.pos; - s32 unk_344; - s32 unk_346; - s32 sp28; - f32 temp_f0; - - this->unk_344 += 1; - - unk_344 = this->unk_344; - unk_346 = this->unk_346; - sp28 = unk_346 - kREG(11) - 2; - temp_f0 = Environment_LerpWeightAccelDecel(unk_346, 0, unk_344, 3, 0); - - thisPos->x = unk_348->x + (temp_f0 * (unk_354->x - unk_348->x)); - thisPos->y = (unk_348->y + (temp_f0 * (unk_354->y - unk_348->y))) + this->unk_360; - thisPos->z = unk_348->z + (temp_f0 * (unk_354->z - unk_348->z)); - - if ((unk_344 - sp28) >= 0) { - this->alpha = ((f32)(unk_346 - unk_344) / (kREG(11) + 2)) * 255.0f; - this->drawConfig = 2; - } - - if ((unk_346 - unk_344) <= 0) { - Actor_Kill(&this->actor); - } -} - -void func_80B58D50(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B57EAC(this, globalCtx); -} - -void func_80B58DB0(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B57EEC(this, globalCtx); -} - -void func_80B58E10(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - Actor_SetFocus(&this->actor, 60.0f); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B57F1C(this, globalCtx); -} - -void func_80B58E7C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B53764(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58014(this, globalCtx); - func_80B536B4(this); -} - -void func_80B58EF4(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B538B0(this); - func_80B53764(this, globalCtx); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58214(this, globalCtx); -} - -void func_80B58F6C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B537E8(this); - func_80B536C4(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58268(this, globalCtx); -} - -void func_80B58FDC(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B537E8(this); - func_80B536C4(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B582C8(this, globalCtx); -} - -void func_80B5904C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B537E8(this); - func_80B536C4(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B584B4(this, globalCtx); -} - -void func_80B590BC(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B537E8(this); - func_80B536C4(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58624(this, globalCtx); -} - -void func_80B5912C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B536C4(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - func_80B56E38(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B57CB4(this, globalCtx); - func_80B57D60(this, globalCtx); - func_80B58A1C(this, globalCtx); -} - -void func_80B591BC(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B536C4(this); - func_80B538B0(this); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58A50(this, globalCtx); -} - -void func_80B5922C(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B536C4(this); - func_80B57298(this); - Actor_SetFocus(&this->actor, 60.0f); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58AAC(this, globalCtx); -} - -void func_80B592A8(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B536C4(this); - func_80B57298(this); - Actor_SetFocus(&this->actor, 60.0f); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B57AAC(this, EnZl3_UpdateSkelAnime(this), &gZelda2Anime2Anim_003D20); - func_80B56DEC(this); - func_80B58AAC(this, globalCtx); -} - -void func_80B59340(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B536C4(this); - func_80B57298(this); - Actor_SetFocus(&this->actor, 60.0f); - func_80B533FC(this, globalCtx); - func_80B5366C(this, globalCtx); - EnZl3_UpdateEyes(this); - func_80B57AAC(this, EnZl3_UpdateSkelAnime(this), &gZelda2Anime2Anim_009FBC); - func_80B58AAC(this, globalCtx); -} - -void func_80B593D0(EnZl3* this, GlobalContext* globalCtx) { - func_80B54DE0(this, globalCtx); - func_80B536C4(this); - func_80B57298(this); - func_80B5366C(this, globalCtx); - func_80B56E38(this, globalCtx); - Actor_SetFocus(&this->actor, 60.0f); - EnZl3_UpdateEyes(this); - EnZl3_UpdateSkelAnime(this); - func_80B58C08(this, globalCtx); -} - -s32 func_80B5944C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - if (limbIndex == 14) { - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 7); - EnZl3* this = (EnZl3*)thisx; - Vec3s* vec = &this->unk_3F8.unk_08; - - gSPSegment(gfx[0]++, 0x0C, mtx); - - rot->x += vec->y; - rot->z += vec->x; - Matrix_Push(); - Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); - Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); - Matrix_Push(); - Matrix_Translate(174.0f, -317.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[0], "../z_en_zl3_inEscape.c", 2471); - Matrix_Translate(-410.0f, -184.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[1], "../z_en_zl3_inEscape.c", 2474); - Matrix_Translate(-1019.0f, -26.0f, 0.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[2], "../z_en_zl3_inEscape.c", 2477); - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(40.0f, 264.0f, 386.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[3], "../z_en_zl3_inEscape.c", 2483); - Matrix_Translate(-446.0f, -52.0f, 84.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[4], "../z_en_zl3_inEscape.c", 2486); - Matrix_Pop(); - Matrix_Push(); - Matrix_Translate(40.0f, 264.0f, -386.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[5], "../z_en_zl3_inEscape.c", 2492); - Matrix_Translate(-446.0f, -52.0f, -84.0f, MTXMODE_APPLY); - Matrix_ToMtx(&mtx[6], "../z_en_zl3_inEscape.c", 2495); - Matrix_Pop(); - Matrix_Pop(); - } - return false; -} - -s32 func_80B59698(EnZl3* this, GlobalContext* globalCtx) { - s32 cond = Flags_GetSwitch(globalCtx, 0x37) && - ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); - - if (cond) { - u8 curSpawn = globalCtx->curSpawn; - - if ((func_80B54DB4(this) == 0x20) && (curSpawn == 0) && - ((gSaveContext.timer2Value <= 0) || (gSaveContext.timer2State == 0))) { - return 1; - } - } - return 0; -} - -s32 func_80B59768(EnZl3* this, GlobalContext* globalCtx) { - s32 cond = Flags_GetSwitch(globalCtx, 0x37) && - ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); - - if (cond) { - u8 curSpawn = globalCtx->curSpawn; - - if ((func_80B54DB4(this) == 0x20) && (curSpawn == 0) && (gSaveContext.timer2Value <= 0)) { - return 1; - } - } - return 0; -} - -void func_80B59828(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B59698(this, globalCtx) || (!func_80B56EE4(this, globalCtx) && func_80B57890(this, globalCtx))) { - s16 newRotY; - - func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, 0.0f, 0); - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - func_80B56F10(this, globalCtx); - newRotY = func_80B571A8(this); - this->actor.shape.rot.y = newRotY; - this->actor.world.rot.y = newRotY; - this->unk_3C4 = this->actor.world.rot.z; - this->actor.shape.rot.z = 0; - this->actor.world.rot.z = this->actor.shape.rot.z; - this->action = 28; - this->drawConfig = 1; - } else { - Actor_Kill(&this->actor); - } - - if (func_80B59698(this, globalCtx) != 0) { - func_80088AA0(180); - func_80B53468(); - gSaveContext.healthAccumulator = 320; - Magic_Fill(globalCtx); - if (Flags_GetSwitch(globalCtx, 0x20)) { - Flags_UnsetSwitch(globalCtx, 0x20); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_ZG, -144.0f, 3544.0f, -43.0f, 0, 0x2000, 0, 0x2000); - } - Flags_UnsetSwitch(globalCtx, 0x21); - Flags_UnsetSwitch(globalCtx, 0x22); - Flags_UnsetSwitch(globalCtx, 0x23); - Flags_UnsetSwitch(globalCtx, 0x24); - Flags_UnsetSwitch(globalCtx, 0x25); - Flags_UnsetSwitch(globalCtx, 0x26); - Flags_UnsetSwitch(globalCtx, 0x27); - Flags_UnsetSwitch(globalCtx, 0x28); - Flags_UnsetSwitch(globalCtx, 0x29); - Flags_UnsetSwitch(globalCtx, 0x2A); - } - - if (func_80B54DB4(this) == 0x20) { - s32 cond; - - func_80B54EA4(this, globalCtx); - cond = Flags_GetSwitch(globalCtx, 0x37) && - ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); - if (cond) { - func_80B53614(this, globalCtx); - } - } -} - -void func_80B59A80(EnZl3* this, GlobalContext* globalCtx) { - if (func_80B59768(this, globalCtx)) { - Audio_PlaySoundGeneral(NA_SE_OC_REVENGE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -void func_80B59AD0(EnZl3* this, GlobalContext* globalCtx) { - // todo look into - Actor* thisx = &this->actor; // unused, necessary to use 'this' first to fix regalloc - - Flags_SetSwitch(globalCtx, 0x36); - func_80088AA0(180); - func_80B54EA4(this, globalCtx); - func_80B53614(this, globalCtx); - gSaveContext.eventChkInf[12] &= ~0x80; - func_80B56F10(this, globalCtx); - gSaveContext.healthAccumulator = 320; - Magic_Fill(globalCtx); - this->action = 27; - this->drawConfig = 1; -} - -void func_80B59B6C(EnZl3* this, GlobalContext* globalCtx) { - s32 sp2C = func_80B54DD4(this); - - this->unk_3DC = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_0091D8)); - this->unk_3E0 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_00A598)); - this->unk_3E4 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_00A334)); - this->unk_3F4 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_001110)); - this->unk_3EC = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_002348)); - this->unk_3F0 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_002E54)); - this->unk_3E8 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_001D8C)); - - switch (sp2C) { - case 0: - func_80B54FB4(this, globalCtx); - break; - case 1: - func_80B55780(this, globalCtx); - break; - case 3: - func_80B59828(this, globalCtx); - break; - default: - osSyncPrintf(VT_FGCOL(RED) " En_Oa3 の arg_data がおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - Actor_Kill(&this->actor); - } -} - -void func_80B59DB8(EnZl3* this, GlobalContext* globalCtx) { - s32 pad; - ObjectContext* objCtx = &globalCtx->objectCtx; - s32 objIndex = Object_GetIndex(objCtx, OBJECT_ZL2_ANIME2); - s32 pad2; - - if (objIndex < 0) { - osSyncPrintf(VT_FGCOL(RED) "En_Zl3_main_bankアニメーションのバンクを読めない!!!!!!!!!!!!\n" VT_RST); - return; - } - - if (Object_IsLoaded(objCtx, objIndex)) { - this->unk_318 = objIndex; - func_80B54DE0(this, globalCtx); - func_80B59B6C(this, globalCtx); - } -} - -static EnZl3ActionFunc sActionFuncs[] = { - func_80B59DB8, func_80B55550, func_80B555A4, func_80B55604, func_80B5566C, func_80B556CC, func_80B5572C, - func_80B56658, func_80B566AC, func_80B5670C, func_80B5676C, func_80B567CC, func_80B5682C, func_80B568B4, - func_80B5691C, func_80B5697C, func_80B569E4, func_80B56A68, func_80B56AE0, func_80B56B54, func_80B56BA8, - func_80B56C24, func_80B56C84, func_80B56CE4, func_80B56D44, func_80B58D50, func_80B58DB0, func_80B58E10, - func_80B58E7C, func_80B58EF4, func_80B58F6C, func_80B58FDC, func_80B5904C, func_80B590BC, func_80B5912C, - func_80B591BC, func_80B5922C, func_80B592A8, func_80B59340, func_80B593D0, -}; - -void EnZl3_Update(Actor* thisx, GlobalContext* globalCtx) { - EnZl3* this = (EnZl3*)thisx; - - if (this->action < 0 || this->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[this->action] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sActionFuncs[this->action](this, globalCtx); -} - -void EnZl3_Init(Actor* thisx, GlobalContext* globalCtx) { - EnZl3* this = (EnZl3*)thisx; - ActorShape* shape = &this->actor.shape; - s32 pad; - - osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_ct通すよ!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - ActorShape_Init(shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - shape->shadowAlpha = 0; - func_80B533B0(thisx, globalCtx); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZelda2Skel, NULL, this->jointTable, this->morphTable, 15); - - switch (func_80B54DD4(this)) { - case 1: - gSaveContext.timer2State = 0; - break; - case 3: - func_80B59A80(this, globalCtx); - break; - } - - osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_ctは通った!!!!!!!!!!!!!!!!!!!!!!!!!\n"); -} - -static OverrideLimbDraw sOverrideLimbDrawFuncs[] = { - func_80B5458C, - func_80B5944C, -}; - -s32 EnZl3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, - Gfx** gfx) { - EnZl3* this = (EnZl3*)thisx; - - if (this->unk_308 < 0 || this->unk_308 >= ARRAY_COUNT(sOverrideLimbDrawFuncs) || - sOverrideLimbDrawFuncs[this->unk_308] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画前処理モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return 0; - } - return sOverrideLimbDrawFuncs[this->unk_308](globalCtx, limbIndex, dList, pos, rot, thisx, gfx); -} - -void func_80B59FE8(EnZl3* this, GlobalContext* globalCtx) { -} - -void func_80B59FF4(EnZl3* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeTexIndex = this->eyeTexIndex; - void* eyeTex = sEyeTextures[eyeTexIndex]; - s16 mouthTexIndex = this->mouthTexIndex; - SkelAnime* skelAnime = &this->skelAnime; - void* mouthTex = sMouthTextures[mouthTexIndex]; - s32 pad2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2165); - - func_80093D18(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0x9, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_OPA_DISP++, 0xA, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0xB, &D_80116280[2]); - - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnZl3_OverrideLimbDraw, EnZl3_PostLimbDraw, this, POLY_OPA_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2190); -} - -void func_80B5A1D0(EnZl3* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 eyeTexIndex = this->eyeTexIndex; - void* eyeTex = sEyeTextures[eyeTexIndex]; - s16 mouthTexIndex = this->mouthTexIndex; - SkelAnime* skelAnime = &this->skelAnime; - void* mouthTex = sMouthTextures[mouthTexIndex]; - s32 pad2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2205); - - func_80093D84(globalCtx->state.gfxCtx); - - gSPSegment(POLY_XLU_DISP++, 8, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 9, SEGMENTED_TO_VIRTUAL(eyeTex)); - gSPSegment(POLY_XLU_DISP++, 10, SEGMENTED_TO_VIRTUAL(mouthTex)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - gSPSegment(POLY_XLU_DISP++, 11, &D_80116280[0]); - - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnZl3_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2234); -} - -static EnZl3DrawFunc sDrawFuncs[] = { - func_80B59FE8, - func_80B59FF4, - func_80B5A1D0, -}; - -void EnZl3_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnZl3* this = (EnZl3*)thisx; - - if (this->drawConfig < 0 || this->drawConfig >= 3 || sDrawFuncs[this->drawConfig] == NULL) { - osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); - return; - } - sDrawFuncs[this->drawConfig](this, globalCtx); -} - -const ActorInit En_Zl3_InitVars = { - ACTOR_EN_ZL3, - ACTORCAT_NPC, - FLAGS, - OBJECT_ZL2, - sizeof(EnZl3), - (ActorFunc)EnZl3_Init, - (ActorFunc)EnZl3_Destroy, - (ActorFunc)EnZl3_Update, - (ActorFunc)EnZl3_Draw, -}; diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp new file mode 100644 index 000000000..270f9cc83 --- /dev/null +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp @@ -0,0 +1,2798 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_ZL3_Z_EN_ZL3_C +#include "actor_common.h" +/* + * File: z_en_zl3.c + * Overlay: ovl_En_Zl3 + * Description: Adult Zelda + */ + +#include "z_en_zl3.h" + +#include "vt.h" +#include "overlays/actors/ovl_En_Encount2/z_en_encount2.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "objects/object_zl2/object_zl2.h" +#include "objects/object_zl2_anime2/object_zl2_anime2.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/code_800FCE80.h" +#include "def/code_800FD970.h" +#include "def/graph.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_en_item00.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" +#include "def/z_skelanime.h" + +#define FLAGS ACTOR_FLAG_4 + +void EnZl3_Init(Actor* thisx, GlobalContext* globalCtx); +void EnZl3_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnZl3_Update(Actor* thisx, GlobalContext* globalCtx); +void EnZl3_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B59AD0(EnZl3* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 25, 80, 0, { 0, 0, 0 } }, +}; + +static void* sEyeTextures[] = { gZelda2EyeOpenTex, gZelda2EyeHalfTex, gZelda2EyeShutTex, gZelda2Eye03Tex, + gZelda2Eye04Tex, gZelda2Eye05Tex, gZelda2Eye06Tex, NULL }; + +static void* sMouthTextures[] = { gZelda2MouthSeriousTex, gZelda2MouthHappyTex, gZelda2MouthOpenTex }; + +static s32 D_80B5A468 = 0; + +static Vec3f D_80B5A46C = { 0.0f, 0.0f, 0.0f }; + +static Vec3f D_80B5A478 = { 0.0f, 10.0f, 0.0f }; + +static f32 D_80B5A484 = 0.0f; + +static Vec3f D_80B5A488 = { 0.0f, 0.0f, 0.0f }; + +static s32 D_80B5A494 = -1; + +static Vec3f D_80B5A498 = { 148.0f, 260.0f, -87.0f }; + +static Vec3f D_80B5A4A4 = { -12.0f, 260.0f, -147.0f }; + +static Vec3f D_80B5A4B0 = { 42.0f, 260.0f, 13.0f }; + +static u32 D_80B5A4BC = 0; + +void func_80B533B0(Actor* thisx, GlobalContext* globalCtx) { + EnZl3* pthis = (EnZl3*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinderType1(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); +} + +void func_80B533FC(EnZl3* pthis, GlobalContext* globalCtx) { + ColliderCylinder* collider = &pthis->collider; + s32 pad[4]; + + Collider_UpdateCylinder(&pthis->actor, collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); +} + +void EnZl3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZl3* pthis = (EnZl3*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80B53468(void) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ESCAPE); +} + +BossGanon2* func_80B53488(EnZl3* pthis, GlobalContext* globalCtx) { + if (pthis->ganon == NULL) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].head; + + while (actorIt != NULL) { + if (actorIt->id == ACTOR_BOSS_GANON2) { + pthis->ganon = (BossGanon2*)actorIt; + break; + } + actorIt = actorIt->next; + } + } + return pthis->ganon; +} + +void EnZl3_UpdateEyes(EnZl3* pthis) { + s32 pad[2]; + s16* eyeTexIndex = &pthis->eyeTexIndex; + s16* blinkTimer = &pthis->blinkTimer; + + if (DECR(*blinkTimer) == 0) { + *blinkTimer = Rand_S16Offset(60, 60); + } + *eyeTexIndex = *blinkTimer; + if (*eyeTexIndex >= 3) { + *eyeTexIndex = 0; + } +} + +void EnZl3_setEyeIndex(EnZl3* pthis, s16 index) { + pthis->eyeTexIndex = index; +} + +void EnZl3_setMouthIndex(EnZl3* pthis, s16 index) { + pthis->mouthTexIndex = index; +} + +void func_80B5357C(EnZl3* pthis, GlobalContext* globalCtx) { + Vec3f* thisPos = &pthis->actor.world.pos; + Vec3f sp20; + + sp20.x = thisPos->x + ((Rand_ZeroOne() - 0.5f) * 10.0f); + sp20.y = thisPos->y; + sp20.z = thisPos->z + ((Rand_ZeroOne() - 0.5f) * 10.0f); + Item_DropCollectible(globalCtx, &sp20, 3); +} + +void func_80B53614(EnZl3* pthis, GlobalContext* globalCtx) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_RIVER_SOUND, -442.0f, 4102.0f, -371.0f, 0, 0, 0, 0x12); +} + +void func_80B5366C(EnZl3* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 75.0f, 30.0f, 30.0f, 5); +} + +void func_80B536B4(EnZl3* pthis) { + pthis->actor.bgCheckFlags &= ~0x9; +} + +void func_80B536C4(EnZl3* pthis) { + s32 pad[2]; + Vec3s* vec1 = &pthis->unk_3F8.unk_08; + Vec3s* vec2 = &pthis->unk_3F8.unk_0E; + + Math_SmoothStepToS(&vec1->x, 0, 20, 6200, 100); + Math_SmoothStepToS(&vec1->y, 0, 20, 6200, 100); + Math_SmoothStepToS(&vec2->x, 0, 20, 6200, 100); + Math_SmoothStepToS(&vec2->y, 0, 20, 6200, 100); +} + +void func_80B53764(EnZl3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->unk_3F8.unk_18 = player->actor.world.pos; + pthis->unk_3F8.unk_14 = kREG(16) - 16.0f; + func_80034A14(&pthis->actor, &pthis->unk_3F8, kREG(17) + 0xC, 2); +} + +s32 func_80B537E8(EnZl3* pthis) { + s16 yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + s16* rotY = &pthis->actor.world.rot.y; + s16* unk_3D0 = &pthis->unk_3D0; + s16 retVal; + s16 pad[2]; + + Math_SmoothStepToS(unk_3D0, ABS((s16)(yawTowardsPlayer - *rotY)), 5, 6200, 100); + retVal = Math_SmoothStepToS(rotY, yawTowardsPlayer, 5, *unk_3D0, 100); + pthis->actor.shape.rot.y = *rotY; + return retVal; +} + +void func_80B538B0(EnZl3* pthis) { + s16 yawTowardsPlayer = pthis->actor.yawTowardsPlayer; + s16* rotY = &pthis->actor.world.rot.y; + + if (ABS((s16)(yawTowardsPlayer - *rotY)) >= 0x1556) { + D_80B5A468 = 1; + } + + if (D_80B5A468 != 0) { + if (!func_80B537E8(pthis)) { + D_80B5A468 = 0; + } + } else { + pthis->unk_3D0 = 0; + } +} + +s32 EnZl3_UpdateSkelAnime(EnZl3* pthis) { + return SkelAnime_Update(&pthis->skelAnime); +} + +s32 func_80B5396C(EnZl3* pthis) { + return pthis->unk_3C8; +} + +void func_80B53974(EnZl3* pthis, u8 arg1) { + pthis->unk_3C8 = arg1; +} + +void func_80B53980(EnZl3* thisx, s16 y, s32 idx) { + EnZl3* pthis = (EnZl3*)thisx; // pthis function might take thisx + s32 action = pthis->action; + s16 y2 = y; + s32 yTemp; + f32 curFrame; + f32 unk_3DC; + + if (pthis->unk_2FC != 0) { + SkelAnime* skelAnime = &pthis->skelAnime; + s32 temp25C = pthis->unk_25C[idx]; + s32 temp28C = (s16)(y + pthis->unk_28C[idx]); + s32 temp2BC = y - pthis->unk_2BC[idx]; + + if ((s32)fabsf(temp2BC) > 0x8000) { + if (y2 > 0) { + temp2BC -= 0x10000; + } else { + temp2BC += 0x10000; + } + } + + if ((idx != 0 || action != 4) && (temp2BC != 0)) { + temp25C += (temp2BC - temp25C) / 16; + } + + if (temp25C != 0) { + temp25C -= temp25C / 10; + } + + if ((s16)(temp28C - y) != 0) { + temp25C -= (s16)(temp28C - y) / 50; + } + + temp28C += temp25C; + if (((pthis->unk_25C[idx] * temp25C) <= 0) && (((s16)(temp28C - y) > -0x64) && ((s16)(temp28C - y) < 0x64))) { + temp28C = y; + temp25C = 0; + } + if (idx == 0 && action == 3) { + yTemp = y + -11000; + if (skelAnime->mode == 2) { + curFrame = skelAnime->curFrame; + unk_3DC = pthis->unk_3DC; + yTemp = (s32)((curFrame / unk_3DC) * -11000) + y; + if (0) {}; + if (temp28C >= yTemp) { + temp28C = yTemp; + if (temp25C > 0) { + temp25C /= -2; + } + } + } else { + if (temp28C >= yTemp) { + temp28C = yTemp; + if (temp25C > 0) { + temp25C /= -2; + } + } + } + } + pthis->unk_25C[idx] = temp25C; + pthis->unk_28C[idx] = temp28C - y; + } + pthis->unk_2BC[idx] = y; +} + +void func_80B53B64(EnZl3* pthis, s16 z, s32 idx) { + SkelAnime* skelAnime = &pthis->skelAnime; + s32 action = pthis->action; + s32 phi_a1; + s32 idx25C; + s16 temp_t1; + s32 temp_a0; + s32 phi_v0; + s32 phi_v1; + s32 phi_v1_2; + + if (idx == 2) { + phi_a1 = 15000; + idx25C = 0; + } else if (idx == 5) { + phi_a1 = 13000; + idx25C = 3; + } else if (idx == 8) { + phi_a1 = 12000; + idx25C = 6; + } else if (idx == 11) { + phi_a1 = 0x4000; + idx25C = 9; + } else if (idx == 14) { + phi_a1 = 0x4000; + idx25C = 12; + } else if (idx == 17) { + phi_a1 = 0x4000; + idx25C = 15; + } else { + phi_a1 = 0x4000; + idx25C = 18; + } + + if (pthis->unk_2FC != 0) { + phi_v0 = pthis->unk_25C[idx]; + temp_a0 = (s16)(z + pthis->unk_28C[idx]); + phi_v1 = z - pthis->unk_2BC[idx]; + + if ((s32)fabsf(phi_v1) > 0x8000) { + if (z > 0) { + phi_v1 -= 0x10000; + } else { + phi_v1 += 0x10000; + } + } + + if (idx25C >= 0) { + phi_v1 += ABS(pthis->unk_25C[idx25C]) / 3; + } + + if (idx == 2 && (action == 5 || action == 24)) { + if (phi_v1 != 0) { + phi_v0 -= (phi_v1 - phi_v0) / 10; + } + } else if (idx == 2 && action == 22 && skelAnime->mode == 2) { + if (phi_v1 != 0) { + phi_v0 -= (phi_v1 - phi_v0) / 10; + } + } else if (idx == 2 && (action == 20 || action == 21) && skelAnime->mode == 2) { + if (phi_v1 != 0) { + phi_v0 -= (phi_v1 - phi_v0) / 10; + } + } else { + if (phi_v1 != 0) { + phi_v0 += (phi_v1 - phi_v0) / 16; + } + } + + if (phi_v0 != 0) { + phi_v0 -= phi_v0 / 10; + } + + if ((s16)(temp_a0 - phi_a1) != 0) { + phi_v0 -= (s16)(temp_a0 - phi_a1) / 50; + } + + temp_a0 += phi_v0; + phi_v1 = (s16)(temp_a0 - phi_a1); + + if (((pthis->unk_25C[idx] * phi_v0) <= 0) && (phi_v1 > -100) && (phi_v1 < 100)) { + temp_a0 = phi_a1; + phi_v0 = 0; + } + + if (idx == 2) { + if (action == 4) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3E0 = pthis->unk_3E0; + + phi_v1_2 = (s32)(((unk_3E0 - curFrame) / unk_3E0) * -2000.0f) + phi_a1; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } + } else if (action == 5) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3E4 = pthis->unk_3E4; + + phi_v1_2 = (s32)((curFrame / unk_3E4) * -2000.0f) + phi_a1; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } else { + phi_v1_2 = phi_a1 - 2000; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } + } else if ((action == 20) || (action == 21)) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3F4 = pthis->unk_3F4; + + if (curFrame <= 42.0f) { + phi_v1_2 = phi_a1 - 2000; + } else { + phi_v1_2 = (s32)((((curFrame - 42.0f) * 6200.0f) / (unk_3F4 - 42.0f)) + -2000.0f) + phi_a1; + } + + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } else { + phi_v1_2 = phi_a1 + 4200; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } + } else if (action == 22) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3EC = pthis->unk_3EC; + + phi_v1_2 = (s32)(((curFrame / unk_3EC) * -5200.0f) + 4200.0f) + phi_a1; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } else { + phi_v1_2 = phi_a1 - 2000; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } + } else if (action == 23) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3F0 = pthis->unk_3F0; + + phi_v1_2 = (s32)(((curFrame / unk_3F0) * -7600.0f) + -2000.0f) + phi_a1; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } else { + phi_v1_2 = phi_a1 - 9600; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } + } else if (action == 24) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3E8 = pthis->unk_3E8; + + phi_v1_2 = (s32)(((curFrame / unk_3E8) * 21000.0f) + -9600.0f) + phi_a1; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } else { + phi_v1_2 = phi_a1 + 11400; + if (phi_v1_2 >= temp_a0) { + temp_a0 = phi_v1_2; + if (phi_v0 < 0) { + phi_v0 /= -2; + } + } + } + } + } else if (idx == 11 || idx == 17) { + if (action == 4) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3E0 = pthis->unk_3E0; + + phi_v1_2 = (s32)((curFrame / unk_3E0) * -7000.0f) + phi_a1; + if (temp_a0 >= phi_v1_2) { + temp_a0 = phi_v1_2; + if (phi_v0 > 0) { + phi_v0 /= -2; + } + } + } else { + phi_v1_2 = phi_a1 - 7000; + if (temp_a0 >= phi_v1_2) { + temp_a0 = phi_v1_2; + if (phi_v0 > 0) { + phi_v0 /= -2; + } + } + } + } else if (action == 5) { + if (skelAnime->mode == 2) { + f32 curFrame = skelAnime->curFrame; + f32 unk_3E4 = pthis->unk_3E4; + + phi_v1_2 = (s32)(((unk_3E4 - curFrame) / unk_3E4) * -7000.0f) + phi_a1; + if (temp_a0 >= phi_v1_2) { + temp_a0 = phi_v1_2; + if (phi_v0 > 0) { + phi_v0 /= -2; + } + } + } + } + } + pthis->unk_25C[idx] = phi_v0; + pthis->unk_28C[idx] = temp_a0 - z; + } + pthis->unk_2BC[idx] = z; +} + +void func_80B54360(EnZl3* pthis, s16 arg1, s32 arg2) { + if (pthis->unk_2FC != 0) { + s32 temp_v1 = pthis->unk_28C[arg2] - arg1; + s16 temp_t0 = temp_v1; + s32 temp_t2 = temp_t0; + s32 temp_t3 = pthis->unk_25C[arg2]; + s32 phi_v0 = temp_t3; + s32 index25C; + s32 phi_t5; + + temp_t3 = arg1 - pthis->unk_2BC[arg2]; + + if (arg2 == 1) { + index25C = 0; + phi_t5 = pthis->unk_25C[index25C]; + } else if (arg2 == 4) { + index25C = 3; + phi_t5 = pthis->unk_25C[index25C]; + } else if (arg2 == 7) { + index25C = 6; + phi_t5 = pthis->unk_25C[index25C]; + } else if (arg2 == 10) { + index25C = 9; + phi_t5 = ABS(pthis->unk_25C[index25C]); + } else if (arg2 == 13) { + index25C = 12; + phi_t5 = ABS(pthis->unk_25C[index25C]); + } else if (arg2 == 16) { + index25C = 15; + phi_t5 = -ABS(pthis->unk_25C[index25C]); + } else { + index25C = 18; + phi_t5 = -ABS(pthis->unk_25C[index25C]); + } + + if ((s32)fabsf(temp_t3) > 0x8000) { + if (arg1 > 0) { + temp_t3 -= 0x10000; + } else { + temp_t3 += 0x10000; + } + } + if (index25C >= 0) { + temp_t3 += phi_t5 / 3; + } + + if (temp_t3 != 0) { + phi_v0 += (temp_t3 - phi_v0) / 16; + } + if (phi_v0 != 0) { + phi_v0 -= phi_v0 / 10; + } + if (temp_t0 != 0) { + phi_v0 -= temp_t0 / 50; + } + temp_v1 += phi_v0; + if (((pthis->unk_25C[arg2] * phi_v0) <= 0) && (temp_t2 > -0x64) && (temp_t2 < 0x64)) { + temp_v1 = 0; + phi_v0 = 0; + } + pthis->unk_25C[arg2] = phi_v0; + pthis->unk_28C[arg2] = arg1 + temp_v1; + } + pthis->unk_2BC[arg2] = arg1; +} + +s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + s32 pad[3]; + EnZl3* pthis = (EnZl3*)thisx; + s16* unk_28C = pthis->unk_28C; + Mtx* sp78; + MtxF sp38; + Vec3s sp30; + Vec3s* unk_3F8_unk_08 = &pthis->unk_3F8.unk_08; + Vec3s* unk_3F8_unk_0E = &pthis->unk_3F8.unk_0E; + + if (limbIndex == 14) { + sp78 = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 7); + rot->x += unk_3F8_unk_08->y; + rot->z += unk_3F8_unk_08->x; + gSPSegment((*gfx)++, 0x0C, sp78); + + Matrix_Push(); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(362.0f, -133.0f, 0.0f, MTXMODE_APPLY); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B53980(pthis, sp30.y, 0); + func_80B54360(pthis, sp30.x, 1); + func_80B53B64(pthis, sp30.z, 2); + } + Matrix_RotateZYX(unk_28C[0] + kREG(31), unk_28C[1] + kREG(32), unk_28C[2] + kREG(33), MTXMODE_APPLY); + Matrix_Translate(-188.0f, -184.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[0], "../z_en_zl3.c", 1490); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B53980(pthis, sp30.y, 3); + } + Matrix_RotateZYX(unk_28C[3] + kREG(34), unk_28C[4] + kREG(35), unk_28C[5] + kREG(36), MTXMODE_APPLY); + Matrix_Translate(-410.0f, -184.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[1], "../z_en_zl3.c", 1534); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B54360(pthis, sp30.x, 7); + } + Matrix_RotateZYX(unk_28C[6] + kREG(37), unk_28C[7] + kREG(38), unk_28C[8] + kREG(39), MTXMODE_APPLY); + Matrix_Translate(-1019.0f, -26.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[2], "../z_en_zl3.c", 1554); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(467.0f, 265.0f, 389.0f, MTXMODE_APPLY); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B53980(pthis, sp30.y, 9); + func_80B54360(pthis, sp30.x, 10); + func_80B53B64(pthis, sp30.z, 11); + } + Matrix_RotateZYX(unk_28C[9] + kREG(40), unk_28C[10] + kREG(41), unk_28C[11] + kREG(42), MTXMODE_APPLY); + Matrix_Translate(-427.0f, -1.0f, -3.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[3], "../z_en_zl3.c", 1579); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B53980(pthis, sp30.y, 12); + func_80B54360(pthis, sp30.x, 13); + func_80B53B64(pthis, sp30.z, 14); + } + Matrix_RotateZYX(unk_28C[12] + kREG(43), unk_28C[13] + kREG(44), unk_28C[14] + kREG(45), MTXMODE_APPLY); + Matrix_Translate(-446.0f, -52.0f, 84.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[4], "../z_en_zl3.c", 1598); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(467.0f, 265.0f, -389.0f, MTXMODE_APPLY); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B53980(pthis, sp30.y, 15); + func_80B54360(pthis, sp30.x, 16); + func_80B53B64(pthis, sp30.z, 17); + } + Matrix_RotateZYX(unk_28C[15] + kREG(46), unk_28C[16] + kREG(47), unk_28C[17] + kREG(48), MTXMODE_APPLY); + Matrix_Translate(-427.0f, -1.0f, 3.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[5], "../z_en_zl3.c", 1623); + Matrix_Get(&sp38); + Matrix_MtxFToYXZRotS(&sp38, &sp30, 0); + if (!FrameAdvance_IsEnabled(globalCtx)) { + func_80B53980(pthis, sp30.y, 18); + func_80B54360(pthis, sp30.x, 19); + func_80B53B64(pthis, sp30.z, 20); + } + Matrix_RotateZYX(unk_28C[18] + kREG(49), unk_28C[19] + kREG(50), unk_28C[20] + kREG(51), MTXMODE_APPLY); + Matrix_Translate(-446.0f, -52.0f, -84.0f, MTXMODE_APPLY); + Matrix_ToMtx(&sp78[6], "../z_en_zl3.c", 1642); + Matrix_Pop(); + Matrix_Pop(); + pthis->unk_2FC = 1; + } else if (limbIndex == 7) { + rot->x += unk_3F8_unk_0E->y; + rot->y -= unk_3F8_unk_0E->x; + } + return false; +} + +void EnZl3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { + EnZl3* pthis = (EnZl3*)thisx; + s32 pad; + Vec3f sp34; + s32 pad2; + Vec3f sp24; + Vec3f sp18; + + if (limbIndex == 13) { + sp34 = D_80B5A46C; + Matrix_MultVec3f(&sp34, &pthis->unk_31C); + } else if (limbIndex == 14) { + sp24 = D_80B5A478; + Matrix_MultVec3f(&sp24, &sp18); + pthis->actor.focus.pos.x = sp18.x; + pthis->actor.focus.pos.y = sp18.y; + pthis->actor.focus.pos.z = sp18.z; + pthis->actor.focus.rot.x = pthis->actor.world.rot.x; + pthis->actor.focus.rot.y = pthis->actor.world.rot.y; + pthis->actor.focus.rot.z = pthis->actor.world.rot.z; + } +} + +s32 func_80B54DB4(EnZl3* pthis) { + s32 params = pthis->actor.params >> 8; + + return params & 0xFF; +} + +s32 func_80B54DC4(EnZl3* pthis) { + s32 params = pthis->actor.params >> 4; + + return params & 0xF; +} + +s32 func_80B54DD4(EnZl3* pthis) { + s32 params = pthis->actor.params; + + return params & 0xF; +} + +void func_80B54DE0(EnZl3* pthis, GlobalContext* globalCtx) { + s32 idx = pthis->unk_318; + + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[idx].vromStart.get()); +} + +void func_80B54E14(EnZl3* pthis, AnimationHeader* animation, u8 arg2, f32 transitionRate, s32 arg4) { + f32 frameCount = Animation_GetLastFrame(animation); + f32 playbackSpeed; + f32 unk0; + f32 fc; + + if (arg4 == 0) { + unk0 = 0.0f; + fc = frameCount; + playbackSpeed = 1.0f; + } else { + unk0 = frameCount; + fc = 0.0f; + playbackSpeed = -1.0f; + } + + Animation_Change(&pthis->skelAnime, animation, playbackSpeed, unk0, fc, arg2, transitionRate); +} + +void func_80B54EA4(EnZl3* pthis, GlobalContext* globalCtx) { + f32 posX = pthis->actor.world.pos.x; + f32 posY = pthis->actor.world.pos.y; + f32 posZ = pthis->actor.world.pos.z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_EG, posX, posY, posZ, 0, 0, 0, 0); +} + +void func_80B54EF4(EnZl3* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_PAIN); +} + +void func_80B54F18(EnZl3* pthis, GlobalContext* globalCtx) { + if (pthis->unk_2F8 == 0) { + f32 posX = pthis->actor.world.pos.x; + f32 posY = pthis->actor.world.pos.y + (kREG(5) + -26.0f); + f32 posZ = pthis->actor.world.pos.z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0x4000, + 0, WARP_PURPLE_CRYSTAL); + pthis->unk_2F8 = 1; + } +} + +void func_80B54FB4(EnZl3* pthis, GlobalContext* globalCtx) { + osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal_Init通すよ!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + func_80B54E14(pthis, &gZelda2Anime2Anim_008AD0, 0, 0.0f, 0); + EnZl3_setEyeIndex(pthis, 4); + EnZl3_setMouthIndex(pthis, 2); + pthis->action = 1; + pthis->drawConfig = 1; + func_80B54F18(pthis, globalCtx); + pthis->actor.shape.rot.z = 0; + pthis->unk_3C4 = pthis->actor.world.rot.z; + pthis->actor.world.rot.z = pthis->actor.shape.rot.z; + osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal_Initは通った!!!!!!!!!!!!!!!!!!!!!!!!!\n"); +} + +void func_80B55054(EnZl3* pthis) { + if (pthis->unk_328 != 0) { + Actor* child = pthis->actor.child; + + if (child != NULL) { + f32* temp_v0 = &pthis->unk_2EC; + + if (*temp_v0 < 19.0f) { + ((DoorWarp1*)child)->crystalAlpha = (20.0f - *temp_v0) * 12.75f; + *temp_v0 += 1.0f; + } else { + Actor_Kill(child); + pthis->actor.child = NULL; + } + } + } +} + +void func_80B550F0(EnZl3* pthis) { + Actor* child = pthis->actor.child; + + if (child != NULL) { + child->world.pos.x = pthis->actor.world.pos.x; + child->world.pos.y = pthis->actor.world.pos.y + (kREG(5) + -26.0f); + child->world.pos.z = pthis->actor.world.pos.z; + } +} + +void func_80B55144(EnZl3* pthis) { + f32* fl = &D_80B5A484; + + if (1) {} // necessary to match + + if (*fl < 2.0f) { + *fl += 1.0f; + EnZl3_setEyeIndex(pthis, 2); + } else if (*fl < 4.0f) { + *fl += 1.0f; + EnZl3_setEyeIndex(pthis, 1); + } else { + EnZl3_UpdateEyes(pthis); + } +} + +void func_80B551E0(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_008AD0, 0, 0.0f, 0); + pthis->action = 1; +} + +void func_80B55220(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0091D8, 2, 0.0f, 0); + pthis->action = 2; + EnZl3_setMouthIndex(pthis, 0); +} + +void func_80B55268(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0091D8, 2, 0.0f, 0); + pthis->action = 3; +} + +void func_80B552A8(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0099A0, 0, 0.0f, 0); + } +} + +void func_80B552DC(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_00A598, 2, -8.0f, 0); + func_80B54EF4(pthis); + EnZl3_setMouthIndex(pthis, 2); + pthis->action = 4; + func_80B53468(); +} + +void func_80B55334(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_00AACC, 0, 0.0f, 0); + } +} + +void func_80B55368(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_00A334, 2, -8.0f, 0); + EnZl3_setMouthIndex(pthis, 0); + pthis->action = 5; +} + +void func_80B553B4(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, 0.0f, 0); + } +} + +void func_80B553E8(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B59AD0(pthis, globalCtx); +} + +void func_80B55408(EnZl3* pthis) { + Actor* child = pthis->actor.child; + + if (child != NULL) { + Actor_Kill(child); + } + Actor_Kill(&pthis->actor); +} + +void func_80B55444(EnZl3* pthis, GlobalContext* globalCtx) { + s32 temp_v0 = func_80B5396C(pthis); + + if (temp_v0 >= 0) { + s32 unk_2F0 = pthis->unk_2F0; + + if (temp_v0 != unk_2F0) { + switch (temp_v0) { + case 0: + func_80B551E0(pthis); + break; + case 1: + EnZl3_setEyeIndex(pthis, 3); + func_80B54EF4(pthis); + break; + case 3: + func_80B55220(pthis); + break; + case 4: + func_80B55268(pthis); + break; + case 5: + func_80B552DC(pthis); + break; + case 6: + func_80B55368(pthis); + break; + case 7: + func_80B553E8(pthis, globalCtx); + break; + case 2: + func_80B55408(pthis); + break; + case 8: + pthis->unk_328 = 1; + default: + osSyncPrintf("En_Zl3_inFinal_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_2F0 = temp_v0; + } + } +} + +void func_80B55550(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateSkelAnime(pthis); + func_80B550F0(pthis); + func_80B55444(pthis, globalCtx); +} + +void func_80B555A4(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_setEyeIndex(pthis, 2); + func_80B550F0(pthis); + func_80B55054(pthis); + func_80B55444(pthis, globalCtx); +} + +void func_80B55604(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + func_80B55144(pthis); + func_80B552A8(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B55054(pthis); + func_80B55444(pthis, globalCtx); +} + +void func_80B5566C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55334(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B55444(pthis, globalCtx); +} + +void func_80B556CC(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B553B4(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B55444(pthis, globalCtx); +} + +void func_80B5572C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B55444(pthis, globalCtx); +} + +void func_80B55780(EnZl3* pthis, GlobalContext* globalCtx) { + osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal2_Init通すよ!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + func_80B54E14(pthis, &gZelda2Anime2Anim_005A0C, 0, 0.0f, 0); + pthis->action = 7; + pthis->drawConfig = 1; + osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_inFinal2_Initは通った!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + EnZl3_setMouthIndex(pthis, 1); + pthis->actor.flags &= ~ACTOR_FLAG_0; +} + +void func_80B55808(EnZl3* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_PAIN); +} + +void func_80B5582C(EnZl3* pthis) { + Audio_PlaySoundRandom(&D_80B5A488, NA_SE_VO_Z1_CRY_0, NA_SE_VO_Z1_CRY_1 - NA_SE_VO_Z1_CRY_0 + 1); +} + +void func_80B5585C(EnZl3* pthis) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if ((skelAnime->mode == 2) && Animation_OnFrame(skelAnime, 4.0f)) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_PAIN); + } +} + +void func_80B558A8(EnZl3* pthis) { + s32 pad[4]; + s16 thisRotY = pthis->actor.world.rot.y; + Vec3f* unk_338 = &pthis->unk_338; + + *unk_338 = pthis->unk_32C = pthis->actor.world.pos; + + unk_338->z += (-1.6074f * Math_CosS(thisRotY)) - (3.1620007f * Math_SinS(thisRotY)); + unk_338->x += (-1.6074f * Math_SinS(thisRotY)) + (3.1620007f * Math_CosS(thisRotY)); + unk_338->y += -0.012199402f; +} + +void func_80B559C4(EnZl3* pthis) { + Vec3f* thisPos = &pthis->actor.world.pos; + Vec3f* unk_32C = &pthis->unk_32C; + Vec3f* unk_338 = &pthis->unk_338; + f32 temp_f0 = Environment_LerpWeightAccelDecel(Animation_GetLastFrame(&gZelda2Anime2Anim_005248), 0, + (s32)pthis->skelAnime.curFrame, 3, 3); + + thisPos->x = unk_32C->x + (temp_f0 * (unk_338->x - unk_32C->x)); + thisPos->z = unk_32C->z + (temp_f0 * (unk_338->z - unk_32C->z)); +} + +void func_80B55A58(EnZl3* pthis, GlobalContext* globalCtx) { + if (globalCtx->activeCamera == MAIN_CAM) { + func_80B537E8(pthis); + } +} + +void func_80B55A84(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_005A0C, 0, 0.0f, 0); + pthis->action = 7; +} + +void func_80B55AC4(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_00499C, 2, -8.0f, 0); + pthis->action = 8; +} + +void func_80B55B04(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_004408, 0, 0.0f, 0); + } +} + +void func_80B55B38(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_006508, 2, -8.0f, 0); + pthis->action = 9; +} + +void func_80B55B78(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0061C4, 0, 0.0f, 0); + } +} + +void func_80B55BAC(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_005248, 2, -8.0f, 0); + func_80B558A8(pthis); + func_80B55808(pthis); + EnZl3_setMouthIndex(pthis, 2); + pthis->action = 10; +} + +void func_80B55C0C(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0054E0, 0, 0.0f, 0); + pthis->action = 11; +} + +void func_80B55C4C(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B55C0C(pthis); + } +} + +void func_80B55C70(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_008684, 2, -8.0f, 0); + pthis->action = 12; + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; +} + +void func_80B55CCC(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_006F04, 0, 0.0f, 0); + } +} + +void func_80B55D00(EnZl3* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->action = 13; + } else if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4300) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.textId = 0x70D5; + func_8002F2F4(&pthis->actor, globalCtx); + } else { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } +} + +void func_80B55DB0(EnZl3* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->action = 12; + } +} + +void func_80B55E08(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_006AB0, 2, -8.0f, 0); + pthis->action = 14; +} + +void func_80B55E48(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_008050, 0, 0.0f, 0); + } +} + +void func_80B55E7C(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007A78, 2, -8.0f, 0); + pthis->action = 15; +} + +void func_80B55EBC(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007C84, 0, 0.0f, 0); + } +} + +void func_80B55EF0(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0082F8, 2, -8.0f, 0); + pthis->action = 16; + EnZl3_setMouthIndex(pthis, 0); +} + +void func_80B55F38(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_003FF8, 0, 0.0f, 0); + } +} + +void func_80B55F6C(EnZl3* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->action = 0x12; + } else if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4300) { + BossGanon2* bossGanon2 = func_80B53488(pthis, globalCtx); + + if ((bossGanon2 != NULL) && (bossGanon2->unk_324 <= (10.0f / 81.0f))) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.textId = 0x7059; + func_8002F2F4(&pthis->actor, globalCtx); + } + } else { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } +} + +void func_80B5604C(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007664, 2, -8.0f, 0); + pthis->action = 17; + func_80B5582C(pthis); +} + +void func_80B56090(EnZl3* pthis, s32 arg1) { + s32* unk_2F0 = &pthis->unk_2F0; + + if (func_80B5396C(pthis) == *unk_2F0) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_003FF8, 0, 0.0f, 0); + pthis->action = 16; + func_80B53974(pthis, 7); + pthis->unk_2F0 = 7; + } + } +} + +void func_80B56108(EnZl3* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->action = 16; + } +} + +void func_80B56160(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0001D8, 0, 0.0f, 0); + pthis->action = 19; +} + +void func_80B561A0(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_001110, 2, -8.0f, 0); + pthis->action = 20; +} + +void func_80B561E0(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0004F4, 0, 0.0f, 0); + } +} + +void func_80B56214(EnZl3* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + pthis->action = 21; + } else if (ABS((s16)(pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y)) <= 0x4300) { + BossGanon2* bossGanon2 = func_80B53488(pthis, globalCtx); + + if (bossGanon2 != NULL) { + if (bossGanon2->unk_324 <= (10.0f / 81.0f)) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actor.textId = 0x7059; + func_8002F2F4(&pthis->actor, globalCtx); + } + } + } else { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; + } +} + +void func_80B562F4(EnZl3* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_3); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->action = 20; + } +} + +void func_80B5634C(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_002348, 2, -8.0f, 0); + pthis->action = 22; +} + +void func_80B5638C(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_00210C, 0, 0.0f, 0); + } +} + +void func_80B563C0(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_002E54, 2, -8.0f, 0); + pthis->action = 23; +} + +void func_80B56400(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_002710, 0, 0.0f, 0); + } +} + +void func_80B56434(EnZl3* pthis) { + func_80B54E14(pthis, &gZelda2Anime2Anim_001D8C, 2, -8.0f, 0); + pthis->action = 24; +} + +void func_80B56474(EnZl3* pthis, s32 arg1) { + if (arg1 != 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0014DC, 0, 0.0f, 0); + } +} + +void func_80B564A8(EnZl3* pthis, GlobalContext* globalCtx) { + s32 temp_v0; + s32* val = &D_80B5A494; + + temp_v0 = func_80B5396C(pthis); + + if (*val > 0) { + *val -= 1; + } else if (*val == 0) { + *val -= 1; + if (temp_v0 == 8) { + func_80B5604C(pthis); + } + } + + if (temp_v0 >= 0) { + s32 unk_2F0 = pthis->unk_2F0; + + if (temp_v0 != unk_2F0) { + switch (temp_v0) { + case 0: + func_80B55A84(pthis); + break; + case 1: + func_80B55AC4(pthis); + break; + case 2: + func_80B55B38(pthis); + break; + case 3: + func_80B55BAC(pthis); + break; + case 4: + func_80B55C70(pthis); + break; + case 5: + func_80B55E08(pthis); + break; + case 6: + func_80B55E7C(pthis); + break; + case 7: + func_80B55EF0(pthis); + break; + case 8: + *val = 10; + break; + case 9: + func_80B56160(pthis); + break; + case 10: + func_80B561A0(pthis); + break; + case 11: + func_80B5634C(pthis); + break; + case 12: + func_80B563C0(pthis); + break; + case 13: + func_80B56434(pthis); + break; + case 14: + Actor_Kill(&pthis->actor); + break; + default: + osSyncPrintf("En_Zl3_inFinal2_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); + } + pthis->unk_2F0 = temp_v0; + } + } +} + +void func_80B56658(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B564A8(pthis, globalCtx); +} + +void func_80B566AC(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55B04(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); +} + +void func_80B5670C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55B78(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); +} + +void func_80B5676C(EnZl3* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + something = EnZl3_UpdateSkelAnime(pthis); + func_80B559C4(pthis); + func_80B55C4C(pthis, something); +} + +void func_80B567CC(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B564A8(pthis, globalCtx); +} + +void func_80B5682C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B55A58(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55CCC(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); + func_80B55D00(pthis, globalCtx); +} + +void func_80B568B4(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B537E8(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B55DB0(pthis, globalCtx); +} + +void func_80B5691C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55E48(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); +} + +void func_80B5697C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55EBC(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B5585C(pthis); + func_80B564A8(pthis, globalCtx); +} + +void func_80B569E4(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B537E8(pthis); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55F38(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); + func_80B55F6C(pthis, globalCtx); +} + +void func_80B56A68(EnZl3* pthis, GlobalContext* globalCtx) { + s32 something; + + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B537E8(pthis); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + something = EnZl3_UpdateSkelAnime(pthis); + func_80B564A8(pthis, globalCtx); + func_80B56090(pthis, something); +} + +void func_80B56AE0(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B537E8(pthis); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B55F38(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B56108(pthis, globalCtx); +} + +void func_80B56B54(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B564A8(pthis, globalCtx); +} + +void func_80B56BA8(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B561E0(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); + func_80B56214(pthis, globalCtx); +} + +void func_80B56C24(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B562F4(pthis, globalCtx); +} + +void func_80B56C84(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B5638C(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); +} + +void func_80B56CE4(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B56400(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); +} + +void func_80B56D44(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B56474(pthis, EnZl3_UpdateSkelAnime(pthis)); + func_80B564A8(pthis, globalCtx); +} + +void func_80B56DA4(EnZl3* pthis) { + func_800788CC(NA_SE_EV_ZELDA_POWER); +} + +void func_80B56DC8(EnZl3* pthis) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_PAIN); +} + +void func_80B56DEC(EnZl3* pthis) { + SkelAnime* skelAnime = &pthis->skelAnime; + + if ((skelAnime->mode == 2) && Animation_OnFrame(skelAnime, 9.0f) != 0) { + func_80078914(&pthis->actor.projectedPos, NA_SE_VO_Z1_OPENDOOR); + } +} + +void func_80B56E38(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s32 sfxId; + SkelAnime* sp20 = &pthis->skelAnime; + + if ((Animation_OnFrame(sp20, 6.0f) || Animation_OnFrame(sp20, 0.0f)) && (pthis->actor.bgCheckFlags & 1)) { + sfxId = 0x800; + sfxId += SurfaceType_GetSfx(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId); + func_80078914(&pthis->actor.projectedPos, sfxId); + } +} + +void func_80B56EB8(EnZl3* pthis, GlobalContext* globalCtx) { + Flags_SetSwitch(globalCtx, func_80B54DB4(pthis)); +} + +s32 func_80B56EE4(EnZl3* pthis, GlobalContext* globalCtx) { + return Flags_GetSwitch(globalCtx, func_80B54DB4(pthis)); +} + +void func_80B56F10(EnZl3* pthis, GlobalContext* globalCtx) { + s32 waypoint; + Path* pathHead = globalCtx->setupPathList; + + if (pathHead != NULL) { + waypoint = func_80B54DC4(pthis); + pathHead += waypoint; + pthis->unk_30C = pathHead; + pthis->unk_310 = pathHead->count; + osSyncPrintf("En_Zl3_Get_path_info レールデータをゲットだぜ = %d!!!!!!!!!!!!!!\n", waypoint); + } else { + osSyncPrintf("En_Zl3_Get_path_info レールデータが無い!!!!!!!!!!!!!!!!!!!!\n"); + } +} + +s32 func_80B56F8C(EnZl3* pthis, s32 arg1) { + s32 unk_310 = pthis->unk_310; + + if (unk_310 > arg1) { + return 1; + } + return 0; +} + +Vec3s* func_80B56FAC(EnZl3* pthis, s32 arg1) { + Vec3s* point; + Path* pathList = pthis->unk_30C; + + if ((pathList != NULL) && func_80B56F8C(pthis, arg1)) { + point = &((Vec3s*)SEGMENTED_TO_VIRTUAL(pathList->points))[arg1]; + return point; + } + return NULL; +} + +s32 func_80B57034(EnZl3* pthis, s32 arg1, s32 arg2) { + Vec3s* vec1 = func_80B56FAC(pthis, arg1); + Vec3s* vec2 = func_80B56FAC(pthis, arg2); + + if ((vec2 != NULL) && (vec1 != NULL)) { + f32 xDiff = vec2->x - vec1->x; + f32 zDiff = vec2->z - vec1->z; + + return ((xDiff == 0.0f) && (zDiff == 0.0f)) ? 0 : (s16)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); + } + return 0; +} + +s16 func_80B57104(EnZl3* pthis, s32 arg1) { + Vec3s* point = func_80B56FAC(pthis, arg1); + + if (point != NULL) { + f32 xDiff = point->x - pthis->actor.world.pos.x; + f32 zDiff = point->z - pthis->actor.world.pos.z; + + if ((xDiff != 0.0f) || (zDiff != 0.0f)) { + return Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI); + } + } + return 0; +} + +s32 func_80B571A8(EnZl3* pthis) { + s32 pad; + s32 unk_314 = pthis->unk_314; + s32 pad2; + + if (func_80B56F8C(pthis, unk_314 + 1) == 0) { + return pthis->actor.shape.rot.y; + } else { + return func_80B57034(pthis, unk_314, unk_314 + 1); + } +} + +s32 func_80B571FC(EnZl3* pthis) { + s32 pad; + s32 unk_314 = pthis->unk_314; + + if (func_80B56F8C(pthis, unk_314) == 0) { + return pthis->actor.shape.rot.y; + } else { + return func_80B57104(pthis, unk_314); + } +} + +void func_80B57240(EnZl3* pthis) { + s32 temp_a1 = func_80B571FC(pthis); + s16* rotY = &pthis->actor.world.rot.y; + + Math_SmoothStepToS(rotY, temp_a1, 2, 6400, 1000); + pthis->actor.shape.rot.y = *rotY; +} + +void func_80B57298(EnZl3* pthis) { + s16* rotY = &pthis->actor.world.rot.y; + s16 temp_a1 = func_80B571A8(pthis); + + Math_SmoothStepToS(rotY, temp_a1, 2, 6400, 1000); + pthis->actor.shape.rot.y = *rotY; +} + +u16 func_80B572F0(GlobalContext* globalCtx) { + s16 sceneNum = globalCtx->sceneNum; + u16 ret; + + if (sceneNum == SCENE_GANON_SONOGO) { + ret = 0x71A8; + } else if (sceneNum == SCENE_GANON_FINAL) { + ret = 0x71A9; + } else { + ret = 0x71AB; + } + return ret; +} + +s32 func_80B57324(EnZl3* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + return 1; + } + return 0; +} + +void func_80B57350(EnZl3* pthis, GlobalContext* globalCtx) { + s16 temp_v0 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + + if (ABS(temp_v0) <= 0x4300) { + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + pthis->actor.textId = func_80B572F0(globalCtx); + func_8002F2F4(&pthis->actor, globalCtx); + } +} + +s32 func_80B573C8(EnZl3* pthis, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + return 1; + } + return 0; +} + +s32 func_80B573FC(EnZl3* pthis, GlobalContext* globalCtx, f32 arg2) { + Player* player = GET_PLAYER(globalCtx); + f32 playerX = player->actor.world.pos.x; + f32 playerZ = player->actor.world.pos.z; + f32 thisX = pthis->actor.world.pos.x; + f32 thisZ = pthis->actor.world.pos.z; + + if (SQ(playerX - thisX) + SQ(playerZ - thisZ) < SQ(arg2)) { + return 1; + } + return 0; +} + +s32 func_80B57458(EnZl3* pthis, GlobalContext* globalCtx) { + Vec3f* thisPos = &pthis->actor.world.pos; + f32 thisX = thisPos->x; + f32 thisZ = thisPos->z; + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + s32 pad; + f32 playerX = playerPos->x; + f32 playerZ = playerPos->z; + f32 temp_f12 = playerX - thisX; + f32 temp_f13 = playerZ - thisZ; + s16 temp_v0; + s16 temp_v1 = func_80B571A8(pthis); + + if (temp_f12 == 0.0f && temp_f13 == 0.0f) { + return 1; + } + + temp_v0 = (s16)(temp_v1 - (s16)(Math_FAtan2F(temp_f12, temp_f13) * (0x8000 / M_PI))); + + if (temp_v0 < 0x1555) { + return 1; + } else if ((temp_v0 < 0x4000) && func_80B573FC(pthis, globalCtx, 150.0f)) { + return 1; + } else { + return 0; + } +} + +s32 func_80B57564(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B573FC(pthis, globalCtx, 50.0f) || func_80B57458(pthis, globalCtx)) { + return 1; + } + return 0; +} + +s32 func_80B575B0(EnZl3* pthis, GlobalContext* globalCtx) { + return func_80B573FC(pthis, globalCtx, 150.0f); +} + +s32 func_80B575D0(EnZl3* pthis, GlobalContext* globalCtx) { + return func_80B573FC(pthis, globalCtx, 50.0f); +} + +s32 func_80B575F0(EnZl3* pthis, GlobalContext* globalCtx) { + s16 sceneNum = globalCtx->sceneNum; + + if ((sceneNum == SCENE_GANON_SONOGO) && (func_80B54DB4(pthis) == 0x26)) { + s32 unk_314 = pthis->unk_314; + + if (unk_314 == 1) { + return 1; + } + } + return 0; +} + +void func_80B5764C(EnZl3* pthis, GlobalContext* globalCtx) { + s16 sceneNum = globalCtx->sceneNum; + + if ((sceneNum == SCENE_GANON_SONOGO) && (func_80B54DB4(pthis) == 0x26)) { + s32 unk_314 = pthis->unk_314 + 1; + + if ((unk_314 == 1) && !Gameplay_InCsMode(globalCtx)) { + OnePointCutscene_Init(globalCtx, 1000, 40, &pthis->actor, MAIN_CAM); + } + } +} + +s32 func_80B576C8(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B575F0(pthis, globalCtx) && (pthis->unk_3D8 == 0)) { + return 1; + } + return 0; +} + +void func_80B57704(EnZl3* pthis, GlobalContext* globalCtx) { + s32 unk_3C4 = pthis->unk_3C4; + + Flags_SetSwitch(globalCtx, unk_3C4); +} + +void func_80B5772C(EnZl3* pthis, GlobalContext* globalCtx) { + s32 unk_3C4 = pthis->unk_3C4; + + Flags_UnsetSwitch(globalCtx, unk_3C4); +} + +void func_80B57754(EnZl3* pthis, GlobalContext* globalCtx) { + if (gSaveContext.unk_13F0 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 1); + func_80B56DA4(pthis); + } +} + +void func_80B577BC(GlobalContext* globalCtx, Vec3f* vec) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + f32 posX = vec->x; + f32 posY = vec->y; + f32 posZ = vec->z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TEST, posX, posY, posZ, 0, + (Math_FAtan2F(playerPos->x - posX, playerPos->z - posZ) * (0x8000 / M_PI)), 0, 5); +} + +void func_80B57858(GlobalContext* globalCtx) { + func_80B577BC(globalCtx, &D_80B5A498); + func_80B577BC(globalCtx, &D_80B5A4A4); +} + +s32 func_80B57890(EnZl3* pthis, GlobalContext* globalCtx) { + s8 pad[2]; + u8 curSpawn = globalCtx->curSpawn; + s16 sceneNum = globalCtx->sceneNum; + s32 result = func_80B54DB4(pthis); + + if (globalCtx) {} // Needed to match, pthis if can be almost anywhere and it still matches + + if (sceneNum == SCENE_GANON_SONOGO) { + if ((result == 0x24) && (curSpawn == 0)) { + return 1; + } + if ((result == 0x25) && (curSpawn == 2)) { + return 1; + } + if ((result == 0x26) && (curSpawn == 4)) { + return 1; + } + if ((result == 0x27) && (curSpawn == 6)) { + return 1; + } + if ((result == 0x28) && (curSpawn == 6)) { + return 1; + } + } else if (sceneNum == SCENE_GANON_FINAL) { + if ((result == 0x20) && (curSpawn == 0) && Flags_GetSwitch(globalCtx, 0x37)) { + if ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || + (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)) { + return 1; + } + } + if ((result == 0x21) && (curSpawn == 2)) { + return 1; + } + if ((result == 0x22) && (curSpawn == 4)) { + return 1; + } + if ((result == 0x23) && (curSpawn == 6)) { + return 1; + } + } else if (sceneNum == SCENE_GANONTIKA_SONOGO) { + if ((result == 0x29) && (curSpawn == 0)) { + return 1; + } + if ((result == 0x2A) && (curSpawn == 0)) { + return 1; + } + } + return 0; +} + +void func_80B57A74(GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].head; + //! @bug checks for encount2 in ACTORCAT_PROP but encount2 is in ACTORCAT_ENEMY so pthis condition is never met + while (actorIt != NULL) { + if (actorIt->id == ACTOR_EN_ENCOUNT2) { + ((EnEncount2*)actorIt)->collapseSpawnerInactive = true; + } + actorIt = actorIt->next; + } +} + +void func_80B57AAC(EnZl3* pthis, s32 arg1, AnimationHeader* arg2) { + if (arg1 != 0) { + func_80B54E14(pthis, arg2, 0, -8.0f, 0); + } +} + +void func_80B57AE0(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 shapeRotY = pthis->actor.shape.rot.y; + s32 pad2; + Vec3f* unk_354 = &pthis->unk_354; + Vec3f* unk_348 = &pthis->unk_348; + Vec3s* temp_v0; + f32 xDiff; + f32 zDiff; + + pthis->unk_344 = 0; + pthis->unk_314 += 1; + pthis->unk_360 = 0.0f; + pthis->unk_364 = 0.0f; + pthis->unk_368 = 0.0f; + *unk_348 = pthis->actor.world.pos; + temp_v0 = func_80B56FAC(pthis, pthis->unk_314); + + if (temp_v0 != NULL) { + unk_354->x = temp_v0->x; + unk_354->y = temp_v0->y; + unk_354->z = temp_v0->z; + } else { + unk_354->x = unk_348->x + (Math_SinS(shapeRotY) * 200.0f); + unk_354->y = unk_348->y; + unk_354->z = unk_348->z + (Math_CosS(shapeRotY) * 200.0f); + } + + xDiff = unk_354->x - unk_348->x; + zDiff = unk_354->z - unk_348->z; + pthis->unk_346 = (s32)(sqrtf(SQ(xDiff) + SQ(zDiff)) / (kREG(6) + 8.0f)); +} + +s32 func_80B57C54(EnZl3* pthis) { + if (pthis->unk_344 >= pthis->unk_346) { + return 1; + } + return 0; +} + +s32 func_80B57C7C(EnZl3* pthis, GlobalContext* globalCtx) { + return 1; +} + +s32 func_80B57C8C(EnZl3* pthis) { + return !func_80B56F8C(pthis, pthis->unk_314 + 2); +} + +void func_80B57CB4(EnZl3* pthis, GlobalContext* globalCtx) { + Vec3f* unk_348 = &pthis->unk_348; + Vec3f* unk_354 = &pthis->unk_354; + Vec3f* thisPos = &pthis->actor.world.pos; + f32 temp_f0; + + pthis->unk_344 += 1; + temp_f0 = Environment_LerpWeightAccelDecel(pthis->unk_346, 0, pthis->unk_344, 3, 3); + thisPos->x = unk_348->x + (temp_f0 * (unk_354->x - unk_348->x)); + thisPos->y = (unk_348->y + (temp_f0 * (unk_354->y - unk_348->y))) + pthis->unk_360; + thisPos->z = unk_348->z + (temp_f0 * (unk_354->z - unk_348->z)); +} + +void func_80B57D60(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B57240(pthis); +} + +s32 func_80B57D80(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad; + s16* sp32 = &pthis->actor.shape.rot.y; + struct_80034A14_arg1* unk_3F8 = &pthis->unk_3F8; + Player* player = GET_PLAYER(globalCtx); + s32 unk_314 = pthis->unk_314; + s16 temp_v0 = func_80B57104(pthis, unk_314); + s32 pad2; + s16 phi_v1; + + unk_3F8->unk_18.y = player->actor.world.pos.y; + unk_3F8->unk_18.x = (Math_SinS(temp_v0) * pthis->actor.xzDistToPlayer) + pthis->actor.world.pos.x; + unk_3F8->unk_18.z = (Math_CosS(temp_v0) * pthis->actor.xzDistToPlayer) + pthis->actor.world.pos.z; + unk_3F8->unk_14 = kREG(16) - 16.0f; + func_80034A14(&pthis->actor, unk_3F8, kREG(17) + 0xC, 4); + + phi_v1 = ABS(temp_v0 - *sp32); + if (phi_v1 <= 0x320) { + *sp32 = temp_v0; + pthis->actor.world.rot.y = *sp32; + phi_v1 = 0; + } + pthis->actor.world.rot.y = *sp32; + return phi_v1; +} + +void func_80B57EAC(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B57324(pthis, globalCtx)) { + pthis->action = 26; + } else { + func_80B57350(pthis, globalCtx); + } +} + +void func_80B57EEC(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B573C8(pthis, globalCtx)) { + pthis->action = 27; + } +} + +void func_80B57F1C(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B57D80(pthis, globalCtx) == 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009BE4, 0, -8.0f, 0); + pthis->action = 34; + pthis->unk_314 -= 1; + func_80B57AE0(pthis, globalCtx); + } +} + +s32 func_80B57F84(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B575D0(pthis, globalCtx) && func_80B57C7C(pthis, globalCtx) && !Gameplay_InCsMode(globalCtx)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, -8.0f, 0); + pthis->action = 36; + pthis->unk_2EC = 0.0f; + func_80B57A74(globalCtx); + return 1; + } + return 0; +} + +void func_80B58014(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s8 invincibilityTimer = player->invincibilityTimer; + + if (func_80B57324(pthis, globalCtx)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_003FF8, 0, -11.0f, 0); + pthis->action = 29; + func_80B538B0(pthis); + } else if (func_80B57C8C(pthis) && func_80B57F84(pthis, globalCtx)) { + OnePointCutscene_Init(globalCtx, 4000, -99, &pthis->actor, MAIN_CAM); + pthis->unk_3D0 = 0; + } else if (func_80B576C8(pthis, globalCtx) && func_80B575B0(pthis, globalCtx) && !Gameplay_InCsMode(globalCtx)) { + pthis->action = 0x1F; + pthis->unk_3CC = 0.0f; + func_80B537E8(pthis); + pthis->unk_3D8 = 1; + OnePointCutscene_Init(globalCtx, 4010, -99, &pthis->actor, MAIN_CAM); + } else if (!func_80B57C8C(pthis) && !func_80B576C8(pthis, globalCtx) && func_80B57564(pthis, globalCtx)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009BE4, 0, -8.0f, 0); + func_80B5764C(pthis, globalCtx); + pthis->action = 34; + pthis->unk_3D0 = 0; + func_80B57AE0(pthis, globalCtx); + } else if ((invincibilityTimer > 0) || (player->fallDistance >= 0x33)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007664, 0, -11.0f, 0); + pthis->action = 30; + func_80B537E8(pthis); + func_80B56DC8(pthis); + } else { + func_80B57350(pthis, globalCtx); + func_80B538B0(pthis); + } +} + +void func_80B58214(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B573C8(pthis, globalCtx)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, -11.0f, 0); + pthis->action = 28; + pthis->unk_3D0 = 0; + } +} + +void func_80B58268(EnZl3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s8 invincibilityTimer = player->invincibilityTimer; + + if ((invincibilityTimer <= 0) && (player->fallDistance <= 50)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, -11.0f, 0); + pthis->action = 28; + pthis->unk_3D0 = 0; + } +} + +void func_80B582C8(EnZl3* pthis, GlobalContext* globalCtx) { + f32* unk_3CC = &pthis->unk_3CC; + s32 pad; + + if (*unk_3CC == kREG(14) + 10.0f) { + *unk_3CC += 1.0f; + func_80B54E14(pthis, &gZelda2Anime2Anim_008050, 0, -12.0f, 0); + func_80B57704(pthis, globalCtx); + } else if (*unk_3CC == kREG(15) + 20.0f) { + *unk_3CC += 1.0f; + func_80B56DC8(pthis); + func_80B54E14(pthis, &gZelda2Anime2Anim_003FF8, 0, -12.0f, 0); + } else if (*unk_3CC == kREG(16) + 30.0f) { + *unk_3CC += 1.0f; + func_80B57858(globalCtx); + } else if (*unk_3CC == kREG(17) + 40.0f) { + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + *unk_3CC += 1.0f; + } else if (*unk_3CC >= ((kREG(17) + 40.0f) + 1.0f)) { + pthis->action = 32; + *unk_3CC = 0.0f; + } else { + *unk_3CC += 1.0f; + } +} + +void func_80B584B4(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s8 invincibilityTimer = player->invincibilityTimer; + Actor* nearbyEnTest = Actor_FindNearby(globalCtx, &pthis->actor, ACTOR_EN_TEST, ACTORCAT_ENEMY, 8000.0f); + + if (D_80B5A4BC == 0) { + if ((nearbyEnTest == NULL) && (!Gameplay_InCsMode(globalCtx))) { + pthis->action = 33; + OnePointCutscene_Init(globalCtx, 4011, -99, &pthis->actor, MAIN_CAM); + } else if (invincibilityTimer > 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_003FF8, 0, -12.0f, 0); + D_80B5A4BC = 1; + func_80B56DC8(pthis); + } + } else { + if ((nearbyEnTest == NULL) && (!Gameplay_InCsMode(globalCtx))) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007664, 0, -12.0f, 0); + D_80B5A4BC = 0; + pthis->action = 33; + OnePointCutscene_Init(globalCtx, 4011, -99, &pthis->actor, MAIN_CAM); + } else if (invincibilityTimer <= 0) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007664, 0, -12.0f, 0); + D_80B5A4BC = 0; + } + } +} + +void func_80B58624(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad[4]; + f32* unk_3CC = &pthis->unk_3CC; + + if (*unk_3CC == (kREG(18) + 10.0f)) { + *unk_3CC += 1.0f; + func_80B54E14(pthis, &gZelda2Anime2Anim_008050, 0, -12.0f, 0); + func_80B5772C(pthis, globalCtx); + } else if (*unk_3CC == kREG(19) + 20.0f) { + *unk_3CC += 1.0f; + pthis->actor.textId = 0x71AC; + Message_StartTextbox(globalCtx, pthis->actor.textId, NULL); + func_80B54E14(pthis, &gZelda2Anime2Anim_003FF8, 0, -12.0f, 0); + } else if (*unk_3CC == ((kREG(19) + 20.0f) + 1.0f)) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + *unk_3CC += 1.0f; + func_80B5357C(pthis, globalCtx); + func_80B5357C(pthis, globalCtx); + func_80B5357C(pthis, globalCtx); + func_80B5357C(pthis, globalCtx); + func_80B5357C(pthis, globalCtx); + } + } else { + if (*unk_3CC >= kREG(20) + 30.0f) { + pthis->action = 28; + func_8005B1A4(GET_ACTIVE_CAM(globalCtx)); + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, -12.0f, 0); + *unk_3CC = 0.0f; + } else { + *unk_3CC += 1.0f; + } + } +} + +void func_80B5884C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0038C0, 2, -8.0f, 0); + pthis->action = 37; + pthis->unk_36C = 1; +} + +void func_80B58898(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54E14(pthis, &gZelda2Anime2Anim_0038C0, 2, -8.0f, 1); + pthis->action = 38; + pthis->unk_374 = 1; +} + +void func_80B588E8(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009BE4, 0, -8.0f, 0); + func_80B57AE0(pthis, globalCtx); + pthis->action = 39; +} + +s32 func_80B58938(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B57C54(pthis)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, -8.0f, 0); + pthis->action = 28; + pthis->unk_3D0 = 0; + return 1; + } + return 0; +} + +s32 func_80B5899C(EnZl3* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.bgCheckFlags & 1)) { + Player* player = GET_PLAYER(globalCtx); + s8 invincibilityTimer = player->invincibilityTimer; + + if ((invincibilityTimer > 0) || (player->fallDistance >= 0x33)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_007664, 2, -11.0f, 0); + pthis->action = 35; + func_80B56DC8(pthis); + return 1; + } + } + return 0; +} + +void func_80B58A1C(EnZl3* pthis, GlobalContext* globalCtx) { + if (!func_80B58938(pthis, globalCtx)) { + func_80B5899C(pthis, globalCtx); + } +} + +void func_80B58A50(EnZl3* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s8 invincibilityTimer = player->invincibilityTimer; + + if ((invincibilityTimer <= 0) && (player->fallDistance <= 50)) { + func_80B54E14(pthis, &gZelda2Anime2Anim_009BE4, 0, -11.0f, 0); + pthis->action = 34; + } +} + +void func_80B58AAC(EnZl3* pthis, GlobalContext* globalCtx) { + f32* unk_2EC = &pthis->unk_2EC; + + *unk_2EC += 1.0f; + if ((*unk_2EC >= kREG(7) + 24.0f) && (pthis->unk_36C == 0)) { + func_80B57754(pthis, globalCtx); + func_80B5884C(pthis, globalCtx); + } else if ((*unk_2EC >= kREG(8) + 50.0f) && (pthis->unk_370 == 0)) { + func_80B56EB8(pthis, globalCtx); + pthis->unk_370 = 1; + } else if ((*unk_2EC >= kREG(9) + 56.0f) && (pthis->unk_374 == 0)) { + func_80B58898(pthis, globalCtx); + } else if (*unk_2EC >= kREG(10) + 82.0f) { + func_80B588E8(pthis, globalCtx); + } +} + +void func_80B58C08(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f* unk_348 = &pthis->unk_348; + Vec3f* unk_354 = &pthis->unk_354; + Vec3f* thisPos = &pthis->actor.world.pos; + s32 unk_344; + s32 unk_346; + s32 sp28; + f32 temp_f0; + + pthis->unk_344 += 1; + + unk_344 = pthis->unk_344; + unk_346 = pthis->unk_346; + sp28 = unk_346 - kREG(11) - 2; + temp_f0 = Environment_LerpWeightAccelDecel(unk_346, 0, unk_344, 3, 0); + + thisPos->x = unk_348->x + (temp_f0 * (unk_354->x - unk_348->x)); + thisPos->y = (unk_348->y + (temp_f0 * (unk_354->y - unk_348->y))) + pthis->unk_360; + thisPos->z = unk_348->z + (temp_f0 * (unk_354->z - unk_348->z)); + + if ((unk_344 - sp28) >= 0) { + pthis->alpha = ((f32)(unk_346 - unk_344) / (kREG(11) + 2)) * 255.0f; + pthis->drawConfig = 2; + } + + if ((unk_346 - unk_344) <= 0) { + Actor_Kill(&pthis->actor); + } +} + +void func_80B58D50(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B57EAC(pthis, globalCtx); +} + +void func_80B58DB0(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B57EEC(pthis, globalCtx); +} + +void func_80B58E10(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 60.0f); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B57F1C(pthis, globalCtx); +} + +void func_80B58E7C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B53764(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58014(pthis, globalCtx); + func_80B536B4(pthis); +} + +void func_80B58EF4(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B538B0(pthis); + func_80B53764(pthis, globalCtx); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58214(pthis, globalCtx); +} + +void func_80B58F6C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B537E8(pthis); + func_80B536C4(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58268(pthis, globalCtx); +} + +void func_80B58FDC(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B537E8(pthis); + func_80B536C4(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B582C8(pthis, globalCtx); +} + +void func_80B5904C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B537E8(pthis); + func_80B536C4(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B584B4(pthis, globalCtx); +} + +void func_80B590BC(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B537E8(pthis); + func_80B536C4(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58624(pthis, globalCtx); +} + +void func_80B5912C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B536C4(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + func_80B56E38(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B57CB4(pthis, globalCtx); + func_80B57D60(pthis, globalCtx); + func_80B58A1C(pthis, globalCtx); +} + +void func_80B591BC(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B536C4(pthis); + func_80B538B0(pthis); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58A50(pthis, globalCtx); +} + +void func_80B5922C(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B536C4(pthis); + func_80B57298(pthis); + Actor_SetFocus(&pthis->actor, 60.0f); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58AAC(pthis, globalCtx); +} + +void func_80B592A8(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B536C4(pthis); + func_80B57298(pthis); + Actor_SetFocus(&pthis->actor, 60.0f); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B57AAC(pthis, EnZl3_UpdateSkelAnime(pthis), &gZelda2Anime2Anim_003D20); + func_80B56DEC(pthis); + func_80B58AAC(pthis, globalCtx); +} + +void func_80B59340(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B536C4(pthis); + func_80B57298(pthis); + Actor_SetFocus(&pthis->actor, 60.0f); + func_80B533FC(pthis, globalCtx); + func_80B5366C(pthis, globalCtx); + EnZl3_UpdateEyes(pthis); + func_80B57AAC(pthis, EnZl3_UpdateSkelAnime(pthis), &gZelda2Anime2Anim_009FBC); + func_80B58AAC(pthis, globalCtx); +} + +void func_80B593D0(EnZl3* pthis, GlobalContext* globalCtx) { + func_80B54DE0(pthis, globalCtx); + func_80B536C4(pthis); + func_80B57298(pthis); + func_80B5366C(pthis, globalCtx); + func_80B56E38(pthis, globalCtx); + Actor_SetFocus(&pthis->actor, 60.0f); + EnZl3_UpdateEyes(pthis); + EnZl3_UpdateSkelAnime(pthis); + func_80B58C08(pthis, globalCtx); +} + +s32 func_80B5944C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + if (limbIndex == 14) { + Mtx* mtx = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx) * 7); + EnZl3* pthis = (EnZl3*)thisx; + Vec3s* vec = &pthis->unk_3F8.unk_08; + + gSPSegment(gfx[0]++, 0x0C, mtx); + + rot->x += vec->y; + rot->z += vec->x; + Matrix_Push(); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(174.0f, -317.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[0], "../z_en_zl3_inEscape.c", 2471); + Matrix_Translate(-410.0f, -184.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[1], "../z_en_zl3_inEscape.c", 2474); + Matrix_Translate(-1019.0f, -26.0f, 0.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[2], "../z_en_zl3_inEscape.c", 2477); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(40.0f, 264.0f, 386.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[3], "../z_en_zl3_inEscape.c", 2483); + Matrix_Translate(-446.0f, -52.0f, 84.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[4], "../z_en_zl3_inEscape.c", 2486); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(40.0f, 264.0f, -386.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[5], "../z_en_zl3_inEscape.c", 2492); + Matrix_Translate(-446.0f, -52.0f, -84.0f, MTXMODE_APPLY); + Matrix_ToMtx(&mtx[6], "../z_en_zl3_inEscape.c", 2495); + Matrix_Pop(); + Matrix_Pop(); + } + return false; +} + +s32 func_80B59698(EnZl3* pthis, GlobalContext* globalCtx) { + s32 cond = Flags_GetSwitch(globalCtx, 0x37) && + ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || + (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); + + if (cond) { + u8 curSpawn = globalCtx->curSpawn; + + if ((func_80B54DB4(pthis) == 0x20) && (curSpawn == 0) && + ((gSaveContext.timer2Value <= 0) || (gSaveContext.timer2State == 0))) { + return 1; + } + } + return 0; +} + +s32 func_80B59768(EnZl3* pthis, GlobalContext* globalCtx) { + s32 cond = Flags_GetSwitch(globalCtx, 0x37) && + ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || + (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); + + if (cond) { + u8 curSpawn = globalCtx->curSpawn; + + if ((func_80B54DB4(pthis) == 0x20) && (curSpawn == 0) && (gSaveContext.timer2Value <= 0)) { + return 1; + } + } + return 0; +} + +void func_80B59828(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B59698(pthis, globalCtx) || (!func_80B56EE4(pthis, globalCtx) && func_80B57890(pthis, globalCtx))) { + s16 newRotY; + + func_80B54E14(pthis, &gZelda2Anime2Anim_009FBC, 0, 0.0f, 0); + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; + func_80B56F10(pthis, globalCtx); + newRotY = func_80B571A8(pthis); + pthis->actor.shape.rot.y = newRotY; + pthis->actor.world.rot.y = newRotY; + pthis->unk_3C4 = pthis->actor.world.rot.z; + pthis->actor.shape.rot.z = 0; + pthis->actor.world.rot.z = pthis->actor.shape.rot.z; + pthis->action = 28; + pthis->drawConfig = 1; + } else { + Actor_Kill(&pthis->actor); + } + + if (func_80B59698(pthis, globalCtx) != 0) { + func_80088AA0(180); + func_80B53468(); + gSaveContext.healthAccumulator = 320; + Magic_Fill(globalCtx); + if (Flags_GetSwitch(globalCtx, 0x20)) { + Flags_UnsetSwitch(globalCtx, 0x20); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_ZG, -144.0f, 3544.0f, -43.0f, 0, 0x2000, 0, 0x2000); + } + Flags_UnsetSwitch(globalCtx, 0x21); + Flags_UnsetSwitch(globalCtx, 0x22); + Flags_UnsetSwitch(globalCtx, 0x23); + Flags_UnsetSwitch(globalCtx, 0x24); + Flags_UnsetSwitch(globalCtx, 0x25); + Flags_UnsetSwitch(globalCtx, 0x26); + Flags_UnsetSwitch(globalCtx, 0x27); + Flags_UnsetSwitch(globalCtx, 0x28); + Flags_UnsetSwitch(globalCtx, 0x29); + Flags_UnsetSwitch(globalCtx, 0x2A); + } + + if (func_80B54DB4(pthis) == 0x20) { + s32 cond; + + func_80B54EA4(pthis, globalCtx); + cond = Flags_GetSwitch(globalCtx, 0x37) && + ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || + (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)); + if (cond) { + func_80B53614(pthis, globalCtx); + } + } +} + +void func_80B59A80(EnZl3* pthis, GlobalContext* globalCtx) { + if (func_80B59768(pthis, globalCtx)) { + Audio_PlaySoundGeneral(NA_SE_OC_REVENGE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +void func_80B59AD0(EnZl3* pthis, GlobalContext* globalCtx) { + // todo look into + Actor* thisx = &pthis->actor; // unused, necessary to use 'pthis' first to fix regalloc + + Flags_SetSwitch(globalCtx, 0x36); + func_80088AA0(180); + func_80B54EA4(pthis, globalCtx); + func_80B53614(pthis, globalCtx); + gSaveContext.eventChkInf[12] &= ~0x80; + func_80B56F10(pthis, globalCtx); + gSaveContext.healthAccumulator = 320; + Magic_Fill(globalCtx); + pthis->action = 27; + pthis->drawConfig = 1; +} + +void func_80B59B6C(EnZl3* pthis, GlobalContext* globalCtx) { + s32 sp2C = func_80B54DD4(pthis); + + pthis->unk_3DC = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_0091D8)); + pthis->unk_3E0 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_00A598)); + pthis->unk_3E4 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_00A334)); + pthis->unk_3F4 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_001110)); + pthis->unk_3EC = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_002348)); + pthis->unk_3F0 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_002E54)); + pthis->unk_3E8 = Animation_GetLastFrame(SEGMENTED_TO_VIRTUAL(&gZelda2Anime2Anim_001D8C)); + + switch (sp2C) { + case 0: + func_80B54FB4(pthis, globalCtx); + break; + case 1: + func_80B55780(pthis, globalCtx); + break; + case 3: + func_80B59828(pthis, globalCtx); + break; + default: + osSyncPrintf(VT_FGCOL(RED) " En_Oa3 の arg_data がおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + Actor_Kill(&pthis->actor); + } +} + +void func_80B59DB8(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad; + ObjectContext* objCtx = &globalCtx->objectCtx; + s32 objIndex = Object_GetIndex(objCtx, OBJECT_ZL2_ANIME2); + s32 pad2; + + if (objIndex < 0) { + osSyncPrintf(VT_FGCOL(RED) "En_Zl3_main_bankアニメーションのバンクを読めない!!!!!!!!!!!!\n" VT_RST); + return; + } + + if (Object_IsLoaded(objCtx, objIndex)) { + pthis->unk_318 = objIndex; + func_80B54DE0(pthis, globalCtx); + func_80B59B6C(pthis, globalCtx); + } +} + +static EnZl3ActionFunc sActionFuncs[] = { + func_80B59DB8, func_80B55550, func_80B555A4, func_80B55604, func_80B5566C, func_80B556CC, func_80B5572C, + func_80B56658, func_80B566AC, func_80B5670C, func_80B5676C, func_80B567CC, func_80B5682C, func_80B568B4, + func_80B5691C, func_80B5697C, func_80B569E4, func_80B56A68, func_80B56AE0, func_80B56B54, func_80B56BA8, + func_80B56C24, func_80B56C84, func_80B56CE4, func_80B56D44, func_80B58D50, func_80B58DB0, func_80B58E10, + func_80B58E7C, func_80B58EF4, func_80B58F6C, func_80B58FDC, func_80B5904C, func_80B590BC, func_80B5912C, + func_80B591BC, func_80B5922C, func_80B592A8, func_80B59340, func_80B593D0, +}; + +void EnZl3_Update(Actor* thisx, GlobalContext* globalCtx) { + EnZl3* pthis = (EnZl3*)thisx; + + if (pthis->action < 0 || pthis->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[pthis->action] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sActionFuncs[pthis->action](pthis, globalCtx); +} + +void EnZl3_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZl3* pthis = (EnZl3*)thisx; + ActorShape* shape = &pthis->actor.shape; + s32 pad; + + osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_ct通すよ!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + ActorShape_Init(shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + shape->shadowAlpha = 0; + func_80B533B0(thisx, globalCtx); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gZelda2Skel, NULL, pthis->jointTable, pthis->morphTable, 15); + + switch (func_80B54DD4(pthis)) { + case 1: + gSaveContext.timer2State = 0; + break; + case 3: + func_80B59A80(pthis, globalCtx); + break; + } + + osSyncPrintf("ゼルダ姫のEn_Zl3_Actor_ctは通った!!!!!!!!!!!!!!!!!!!!!!!!!\n"); +} + +static OverrideLimbDraw sOverrideLimbDrawFuncs[] = { + func_80B5458C, + func_80B5944C, +}; + +s32 EnZl3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, + Gfx** gfx) { + EnZl3* pthis = (EnZl3*)thisx; + + if (pthis->unk_308 < 0 || pthis->unk_308 >= ARRAY_COUNT(sOverrideLimbDrawFuncs) || + sOverrideLimbDrawFuncs[pthis->unk_308] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画前処理モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return 0; + } + return sOverrideLimbDrawFuncs[pthis->unk_308](globalCtx, limbIndex, dList, pos, rot, thisx, gfx); +} + +void func_80B59FE8(EnZl3* pthis, GlobalContext* globalCtx) { +} + +void func_80B59FF4(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTex = sEyeTextures[eyeTexIndex]; + s16 mouthTexIndex = pthis->mouthTexIndex; + SkelAnime* skelAnime = &pthis->skelAnime; + void* mouthTex = sMouthTextures[mouthTexIndex]; + s32 pad2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2165); + + func_80093D18(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0x9, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_OPA_DISP++, 0xA, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0xB, &D_80116280[2]); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnZl3_OverrideLimbDraw, EnZl3_PostLimbDraw, pthis, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2190); +} + +void func_80B5A1D0(EnZl3* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 eyeTexIndex = pthis->eyeTexIndex; + void* eyeTex = sEyeTextures[eyeTexIndex]; + s16 mouthTexIndex = pthis->mouthTexIndex; + SkelAnime* skelAnime = &pthis->skelAnime; + void* mouthTex = sMouthTextures[mouthTexIndex]; + s32 pad2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2205); + + func_80093D84(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 8, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 9, SEGMENTED_TO_VIRTUAL(eyeTex)); + gSPSegment(POLY_XLU_DISP++, 10, SEGMENTED_TO_VIRTUAL(mouthTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, pthis->alpha); + gSPSegment(POLY_XLU_DISP++, 11, &D_80116280[0]); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + EnZl3_OverrideLimbDraw, NULL, pthis, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl3.c", 2234); +} + +static EnZl3DrawFunc sDrawFuncs[] = { + func_80B59FE8, + func_80B59FF4, + func_80B5A1D0, +}; + +void EnZl3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZl3* pthis = (EnZl3*)thisx; + + if (pthis->drawConfig < 0 || pthis->drawConfig >= 3 || sDrawFuncs[pthis->drawConfig] == NULL) { + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; + } + sDrawFuncs[pthis->drawConfig](pthis, globalCtx); +} + +ActorInit En_Zl3_InitVars = { + ACTOR_EN_ZL3, + ACTORCAT_NPC, + FLAGS, + OBJECT_ZL2, + sizeof(EnZl3), + (ActorFunc)EnZl3_Init, + (ActorFunc)EnZl3_Destroy, + (ActorFunc)EnZl3_Update, + (ActorFunc)EnZl3_Draw, +}; diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.cpp similarity index 57% rename from src/overlays/actors/ovl_En_Zl4/z_en_zl4.c rename to src/overlays/actors/ovl_En_Zl4/z_en_zl4.cpp index 7d70e6170..bbaa3daa5 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.cpp @@ -70,11 +70,11 @@ void EnZl4_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZl4_Update(Actor* thisx, GlobalContext* globalCtx); void EnZl4_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnZl4_Cutscene(EnZl4* this, GlobalContext* globalCtx); -void EnZl4_Idle(EnZl4* this, GlobalContext* globalCtx); -void EnZl4_TheEnd(EnZl4* this, GlobalContext* globalCtx); +void EnZl4_Cutscene(EnZl4* pthis, GlobalContext* globalCtx); +void EnZl4_Idle(EnZl4* pthis, GlobalContext* globalCtx); +void EnZl4_TheEnd(EnZl4* pthis, GlobalContext* globalCtx); -const ActorInit En_Zl4_InitVars = { +ActorInit En_Zl4_InitVars = { ACTOR_EN_ZL4, ACTORCAT_NPC, FLAGS, @@ -192,7 +192,7 @@ static struct_80034EC0_Entry sAnimationEntries[] = { /* 33 */ /* transition to standing */ { &gChildZeldaAnim_000654, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, }; -#include "z_en_zl4_cutscene_data.c" +#include "z_en_zl4_cutscene_data.cpp" void EnZl4_SetCsCameraAngle(GlobalContext* globalCtx, s16 index) { Camera* activeCam = GET_ACTIVE_CAM(globalCtx); @@ -249,80 +249,80 @@ s16 func_80B5B9B0(GlobalContext* globalCtx, Actor* thisx) { return true; } -void EnZl4_UpdateFace(EnZl4* this) { - if (this->blinkTimer > 0) { - this->blinkTimer--; +void EnZl4_UpdateFace(EnZl4* pthis) { + if (pthis->blinkTimer > 0) { + pthis->blinkTimer--; } else { - this->blinkTimer = 0; + pthis->blinkTimer = 0; } - if (this->blinkTimer <= 2) { - this->leftEyeState = this->rightEyeState = this->blinkTimer; + if (pthis->blinkTimer <= 2) { + pthis->leftEyeState = pthis->rightEyeState = pthis->blinkTimer; } - switch (this->eyeExpression) { + switch (pthis->eyeExpression) { case ZL4_EYES_NEUTRAL: - if (this->blinkTimer == 0) { - this->blinkTimer = Rand_S16Offset(30, 30); + if (pthis->blinkTimer == 0) { + pthis->blinkTimer = Rand_S16Offset(30, 30); } break; case ZL4_EYES_SHUT: - if (this->blinkTimer == 0) { - this->leftEyeState = this->rightEyeState = ZL4_EYE_SHUT; + if (pthis->blinkTimer == 0) { + pthis->leftEyeState = pthis->rightEyeState = ZL4_EYE_SHUT; } break; case ZL4_EYES_LOOK_LEFT: - if (this->blinkTimer == 0) { - this->leftEyeState = ZL4_EYE_LOOK_OUT; - this->rightEyeState = ZL4_EYE_LOOK_IN; + if (pthis->blinkTimer == 0) { + pthis->leftEyeState = ZL4_EYE_LOOK_OUT; + pthis->rightEyeState = ZL4_EYE_LOOK_IN; } break; case ZL4_EYES_LOOK_RIGHT: - if (this->blinkTimer == 0) { - this->leftEyeState = ZL4_EYE_LOOK_IN; - this->rightEyeState = ZL4_EYE_LOOK_OUT; + if (pthis->blinkTimer == 0) { + pthis->leftEyeState = ZL4_EYE_LOOK_IN; + pthis->rightEyeState = ZL4_EYE_LOOK_OUT; } break; case ZL4_EYES_WIDE: - if (this->blinkTimer == 0) { - this->leftEyeState = this->rightEyeState = ZL4_EYE_WIDE; + if (pthis->blinkTimer == 0) { + pthis->leftEyeState = pthis->rightEyeState = ZL4_EYE_WIDE; } break; case ZL4_EYES_SQUINT: - if (this->blinkTimer == 0) { - this->leftEyeState = this->rightEyeState = ZL4_EYE_SQUINT; + if (pthis->blinkTimer == 0) { + pthis->leftEyeState = pthis->rightEyeState = ZL4_EYE_SQUINT; } break; case ZL4_EYES_OPEN: - if (this->blinkTimer >= 3) { - this->blinkTimer = ZL4_EYE_OPEN; + if (pthis->blinkTimer >= 3) { + pthis->blinkTimer = ZL4_EYE_OPEN; } break; } - switch (this->mouthExpression) { + switch (pthis->mouthExpression) { case ZL4_MOUTH_HAPPY: - this->mouthState = 1; + pthis->mouthState = 1; break; case ZL4_MOUTH_WORRIED: - this->mouthState = 2; + pthis->mouthState = 2; break; case ZL4_MOUTH_SURPRISED: - this->mouthState = 3; + pthis->mouthState = 3; break; default: - this->mouthState = 0; + pthis->mouthState = 0; break; } } -void EnZl4_SetMove(EnZl4* this, GlobalContext* globalCtx) { - this->skelAnime.moveFlags |= 1; - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); +void EnZl4_SetMove(EnZl4* pthis, GlobalContext* globalCtx) { + pthis->skelAnime.moveFlags |= 1; + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, 1.0f); } -void func_80B5BB78(EnZl4* this, GlobalContext* globalCtx) { +void func_80B5BB78(EnZl4* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk_1E0.unk_18 = player->actor.world.pos; - func_80034A14(&this->actor, &this->unk_1E0, 2, 2); + pthis->unk_1E0.unk_18 = player->actor.world.pos; + func_80034A14(&pthis->actor, &pthis->unk_1E0, 2, 2); } void EnZl4_GetActionStartPos(CsCmdActorAction* action, Vec3f* vec) { @@ -331,14 +331,14 @@ void EnZl4_GetActionStartPos(CsCmdActorAction* action, Vec3f* vec) { vec->z = action->startPos.z; } -s32 EnZl4_SetupFromLegendCs(EnZl4* this, GlobalContext* globalCtx) { +s32 EnZl4_SetupFromLegendCs(EnZl4* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Actor* playerx = &GET_PLAYER(globalCtx)->actor; s16 rotY; - func_8002DF54(globalCtx, &this->actor, 8); - playerx->world.pos = this->actor.world.pos; - rotY = this->actor.shape.rot.y; + func_8002DF54(globalCtx, &pthis->actor, 8); + playerx->world.pos = pthis->actor.world.pos; + rotY = pthis->actor.shape.rot.y; playerx->world.pos.x += 56.0f * Math_SinS(rotY); playerx->world.pos.z += 56.0f * Math_CosS(rotY); @@ -347,26 +347,26 @@ s32 EnZl4_SetupFromLegendCs(EnZl4* this, GlobalContext* globalCtx) { EnZl4_SetCsCameraMove(globalCtx, 5); ShrinkWindow_SetVal(0x20); Interface_ChangeAlpha(2); - this->talkTimer2 = 0; + pthis->talkTimer2 = 0; return true; } -s32 EnZl4_InMovingAnim(EnZl4* this) { - if ((this->skelAnime.animation == &gChildZeldaAnim_01B874) || - (this->skelAnime.animation == &gChildZeldaAnim_01BCF0) || - (this->skelAnime.animation == &gChildZeldaAnim_0125E4) || - (this->skelAnime.animation == &gChildZeldaAnim_012E58) || - (this->skelAnime.animation == &gChildZeldaAnim_015F14) || - (this->skelAnime.animation == &gChildZeldaAnim_0169B4) || - (this->skelAnime.animation == &gChildZeldaAnim_016D08) || - (this->skelAnime.animation == &gChildZeldaAnim_01805C) || - (this->skelAnime.animation == &gChildZeldaAnim_01A2FC) || - (this->skelAnime.animation == &gChildZeldaAnim_01AAE0) || - (this->skelAnime.animation == &gChildZeldaAnim_01CE08) || - (this->skelAnime.animation == &gChildZeldaAnim_018898) || - (this->skelAnime.animation == &gChildZeldaAnim_01910C) || - (this->skelAnime.animation == &gChildZeldaAnim_00F0A4) || - (this->skelAnime.animation == &gChildZeldaAnim_00F894)) { +s32 EnZl4_InMovingAnim(EnZl4* pthis) { + if ((pthis->skelAnime.animation == &gChildZeldaAnim_01B874) || + (pthis->skelAnime.animation == &gChildZeldaAnim_01BCF0) || + (pthis->skelAnime.animation == &gChildZeldaAnim_0125E4) || + (pthis->skelAnime.animation == &gChildZeldaAnim_012E58) || + (pthis->skelAnime.animation == &gChildZeldaAnim_015F14) || + (pthis->skelAnime.animation == &gChildZeldaAnim_0169B4) || + (pthis->skelAnime.animation == &gChildZeldaAnim_016D08) || + (pthis->skelAnime.animation == &gChildZeldaAnim_01805C) || + (pthis->skelAnime.animation == &gChildZeldaAnim_01A2FC) || + (pthis->skelAnime.animation == &gChildZeldaAnim_01AAE0) || + (pthis->skelAnime.animation == &gChildZeldaAnim_01CE08) || + (pthis->skelAnime.animation == &gChildZeldaAnim_018898) || + (pthis->skelAnime.animation == &gChildZeldaAnim_01910C) || + (pthis->skelAnime.animation == &gChildZeldaAnim_00F0A4) || + (pthis->skelAnime.animation == &gChildZeldaAnim_00F894)) { return true; } return false; @@ -374,83 +374,83 @@ s32 EnZl4_InMovingAnim(EnZl4* this) { void EnZl4_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnZl4* this = (EnZl4*)thisx; + EnZl4* pthis = (EnZl4*)thisx; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gChildZeldaSkel, NULL, this->jointTable, this->morphTable, 18); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_21); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->actor.textId = -1; - this->eyeExpression = this->mouthExpression = ZL4_MOUTH_NEUTRAL; + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gChildZeldaSkel, NULL, pthis->jointTable, pthis->morphTable, 18); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_21); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->actor.textId = -1; + pthis->eyeExpression = pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; if (gSaveContext.sceneSetupIndex >= 4) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_0); - this->actionFunc = EnZl4_TheEnd; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_0); + pthis->actionFunc = EnZl4_TheEnd; } else if (gSaveContext.eventChkInf[4] & 1) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_0); - this->actionFunc = EnZl4_Idle; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_0); + pthis->actionFunc = EnZl4_Idle; } else { if (gSaveContext.entranceIndex != 0x5F0) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_21); - this->csState = ZL4_CS_WAIT; - this->talkState = 0; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_21); + pthis->csState = ZL4_CS_WAIT; + pthis->talkState = 0; } else { - EnZl4_SetupFromLegendCs(this, globalCtx); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_0); - this->csState = ZL4_CS_LEGEND; - this->talkState = 0; + EnZl4_SetupFromLegendCs(pthis, globalCtx); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_0); + pthis->csState = ZL4_CS_LEGEND; + pthis->talkState = 0; } - this->actionFunc = EnZl4_Cutscene; + pthis->actionFunc = EnZl4_Cutscene; } } void EnZl4_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnZl4* this = (EnZl4*)thisx; + EnZl4* pthis = (EnZl4*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -s32 EnZl4_SetNextAnim(EnZl4* this, s32 nextAnim) { - if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { +s32 EnZl4_SetNextAnim(EnZl4* pthis, s32 nextAnim) { + if (!Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { return false; } - func_80034EC0(&this->skelAnime, sAnimationEntries, nextAnim); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, nextAnim); return true; } -void EnZl4_ReverseAnimation(EnZl4* this) { - f32 tempFrame = this->skelAnime.startFrame; +void EnZl4_ReverseAnimation(EnZl4* pthis) { + f32 tempFrame = pthis->skelAnime.startFrame; - this->skelAnime.startFrame = this->skelAnime.endFrame; - this->skelAnime.curFrame = this->skelAnime.endFrame; - this->skelAnime.endFrame = tempFrame; - this->skelAnime.playSpeed = -1.0f; + pthis->skelAnime.startFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.endFrame = tempFrame; + pthis->skelAnime.playSpeed = -1.0f; } -s32 EnZl4_CsWaitForPlayer(EnZl4* this, GlobalContext* globalCtx) { +s32 EnZl4_CsWaitForPlayer(EnZl4* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Actor* playerx = &GET_PLAYER(globalCtx)->actor; s16 rotY; s16 yawDiff; s16 absYawDiff; - if (!Actor_ProcessTalkRequest(&this->actor, globalCtx)) { - yawDiff = (f32)this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (!Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { + yawDiff = (f32)pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; absYawDiff = ABS(yawDiff); - if ((playerx->world.pos.y != this->actor.world.pos.y) || (absYawDiff >= 0x3FFC)) { + if ((playerx->world.pos.y != pthis->actor.world.pos.y) || (absYawDiff >= 0x3FFC)) { return false; } else { - func_8002F2CC(&this->actor, globalCtx, this->collider.dim.radius + 60.0f); + func_8002F2CC(&pthis->actor, globalCtx, pthis->collider.dim.radius + 60.0f); return false; } } - playerx->world.pos = this->actor.world.pos; - rotY = this->actor.shape.rot.y; + playerx->world.pos = pthis->actor.world.pos; + rotY = pthis->actor.shape.rot.y; playerx->world.pos.x += 56.0f * Math_SinS(rotY); playerx->world.pos.z += 56.0f * Math_CosS(rotY); playerx->speedXZ = 0.0f; @@ -458,25 +458,25 @@ s32 EnZl4_CsWaitForPlayer(EnZl4* this, GlobalContext* globalCtx) { return true; } -s32 EnZl4_CsMeetPlayer(EnZl4* this, GlobalContext* globalCtx) { - switch (this->talkState) { +s32 EnZl4_CsMeetPlayer(EnZl4* pthis, GlobalContext* globalCtx) { + switch (pthis->talkState) { case 0: - if (this->skelAnime.curFrame == 50.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_MEET); + if (pthis->skelAnime.curFrame == 50.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_MEET); } - if (!EnZl4_SetNextAnim(this, ZL4_ANIM_4)) { + if (!EnZl4_SetNextAnim(pthis, ZL4_ANIM_4)) { break; } else { Message_StartTextbox(globalCtx, 0x702E, NULL); - this->talkState++; + pthis->talkState++; } break; case 1: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 1); Message_StartTextbox(globalCtx, 0x702F, NULL); - this->talkTimer2 = 0; - this->talkState++; + pthis->talkTimer2 = 0; + pthis->talkState++; } break; case 2: @@ -485,64 +485,64 @@ s32 EnZl4_CsMeetPlayer(EnZl4* this, GlobalContext* globalCtx) { gSaveContext.cutsceneTrigger = 1; EnZl4_SetCsCameraMove(globalCtx, 0); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer2 = 0; - this->talkState++; + pthis->talkTimer2 = 0; + pthis->talkState++; } break; case 3: - this->talkTimer2++; - if (this->talkTimer2 >= 45) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 45) { Message_StartTextbox(globalCtx, 0x70F9, NULL); - this->talkState++; + pthis->talkState++; } break; case 4: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraMove(globalCtx, 1); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer2 = 0; - this->talkState++; + pthis->talkTimer2 = 0; + pthis->talkState++; } break; case 5: - this->talkTimer2++; - if (this->talkTimer2 >= 10) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 10) { Message_StartTextbox(globalCtx, 0x70FA, NULL); - this->talkState++; + pthis->talkState++; } break; case 6: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 2); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_22); - this->mouthExpression = ZL4_MOUTH_NEUTRAL; - this->talkTimer2 = 0; - this->talkState++; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_22); + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; + pthis->talkTimer2 = 0; + pthis->talkState++; Message_StartTextbox(globalCtx, 0x70FB, NULL); } break; } - return (this->talkState == 7) ? 1 : 0; + return (pthis->talkState == 7) ? 1 : 0; } -s32 EnZl4_CsAskStone(EnZl4* this, GlobalContext* globalCtx) { - switch (this->talkState) { +s32 EnZl4_CsAskStone(EnZl4* pthis, GlobalContext* globalCtx) { + switch (pthis->talkState) { case 0: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_25)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_25)) { + pthis->talkState++; } case 1: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 3); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer1 = 40; - this->talkState = 2; + pthis->talkTimer1 = 40; + pthis->talkState = 2; } break; case 2: - if (DECR(this->talkTimer1) == 0) { + if (DECR(pthis->talkTimer1) == 0) { Message_StartTextbox(globalCtx, 0x7030, NULL); - this->talkState++; + pthis->talkState++; } break; case 3: @@ -550,241 +550,241 @@ s32 EnZl4_CsAskStone(EnZl4* this, GlobalContext* globalCtx) { break; } else if (globalCtx->msgCtx.choiceIndex == 0) { EnZl4_SetCsCameraAngle(globalCtx, 4); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_28); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_SQUINT; - this->mouthExpression = ZL4_MOUTH_HAPPY; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_28); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_SQUINT; + pthis->mouthExpression = ZL4_MOUTH_HAPPY; Message_StartTextbox(globalCtx, 0x7032, NULL); - this->talkState = 7; + pthis->talkState = 7; } else { EnZl4_SetCsCameraAngle(globalCtx, 2); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_9); - this->mouthExpression = ZL4_MOUTH_WORRIED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_9); + pthis->mouthExpression = ZL4_MOUTH_WORRIED; Message_StartTextbox(globalCtx, 0x7031, NULL); - this->talkState++; + pthis->talkState++; } break; case 4: - if (this->skelAnime.curFrame == 16.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_QUESTION); + if (pthis->skelAnime.curFrame == 16.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_QUESTION); } - if (EnZl4_SetNextAnim(this, ZL4_ANIM_10)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_10)) { + pthis->talkState++; } case 5: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_9); - this->mouthExpression = ZL4_MOUTH_WORRIED; - EnZl4_ReverseAnimation(this); - this->talkState = 6; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_9); + pthis->mouthExpression = ZL4_MOUTH_WORRIED; + EnZl4_ReverseAnimation(pthis); + pthis->talkState = 6; } break; case 6: - this->mouthExpression = ZL4_MOUTH_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; EnZl4_SetCsCameraAngle(globalCtx, 3); Message_StartTextbox(globalCtx, 0x7030, NULL); - this->talkState = 12; + pthis->talkState = 12; break; case 12: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_25)) { - this->talkState = 13; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_25)) { + pthis->talkState = 13; } case 13: if (!((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx))) { break; } else if (globalCtx->msgCtx.choiceIndex == 0) { EnZl4_SetCsCameraAngle(globalCtx, 4); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_28); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_SQUINT; - this->mouthExpression = ZL4_MOUTH_HAPPY; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_28); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_SQUINT; + pthis->mouthExpression = ZL4_MOUTH_HAPPY; Message_StartTextbox(globalCtx, 0x7032, NULL); - this->talkState = 7; + pthis->talkState = 7; } else { EnZl4_SetCsCameraAngle(globalCtx, 2); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_9); - this->mouthExpression = ZL4_MOUTH_WORRIED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_9); + pthis->mouthExpression = ZL4_MOUTH_WORRIED; Message_StartTextbox(globalCtx, 0x7031, NULL); - this->talkState = 4; + pthis->talkState = 4; } break; case 7: - if (this->skelAnime.curFrame == 17.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_SMILE_0); + if (pthis->skelAnime.curFrame == 17.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_SMILE_0); } - if (EnZl4_SetNextAnim(this, ZL4_ANIM_29)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_29)) { + pthis->talkState++; } case 8: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraMove(globalCtx, 2); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_0); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_NEUTRAL; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_0); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; Message_StartTextbox(globalCtx, 0x70FC, NULL); - this->talkState = 9; + pthis->talkState = 9; } break; case 9: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 5); Message_StartTextbox(globalCtx, 0x70FD, NULL); - this->talkState++; + pthis->talkState++; } break; case 10: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_5); - this->eyeExpression = ZL4_EYES_OPEN; - this->mouthExpression = ZL4_MOUTH_SURPRISED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_5); + pthis->eyeExpression = ZL4_EYES_OPEN; + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; Message_StartTextbox(globalCtx, 0x70FE, NULL); - this->talkState++; + pthis->talkState++; } break; } - return (this->talkState == 11) ? 1 : 0; + return (pthis->talkState == 11) ? 1 : 0; } -s32 EnZl4_CsAskName(EnZl4* this, GlobalContext* globalCtx) { - switch (this->talkState) { +s32 EnZl4_CsAskName(EnZl4* pthis, GlobalContext* globalCtx) { + switch (pthis->talkState) { case 0: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_4)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_4)) { + pthis->talkState++; } break; case 1: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 6); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_1); - this->blinkTimer = 11; - this->eyeExpression = ZL4_EYES_SQUINT; - this->mouthExpression = ZL4_MOUTH_NEUTRAL; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_1); + pthis->blinkTimer = 11; + pthis->eyeExpression = ZL4_EYES_SQUINT; + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; Message_StartTextbox(globalCtx, 0x70FF, NULL); - this->talkState++; + pthis->talkState++; } break; case 2: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_2)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_2)) { + pthis->talkState++; } case 3: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_16); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_16); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState = 4; + pthis->talkState = 4; } break; case 4: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_17)) { + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_17)) { Message_StartTextbox(globalCtx, 0x2073, NULL); - this->talkState++; + pthis->talkState++; } break; case 5: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraMove(globalCtx, 3); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_0); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_0); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer2 = 0; - this->talkState = 6; + pthis->talkTimer2 = 0; + pthis->talkState = 6; } break; case 6: - this->talkTimer2++; - if (this->talkTimer2 >= 15) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 15) { Message_StartTextbox(globalCtx, 0x2074, NULL); - this->talkState++; + pthis->talkState++; } break; case 7: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_6); - this->mouthExpression = ZL4_MOUTH_HAPPY; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_6); + pthis->mouthExpression = ZL4_MOUTH_HAPPY; Message_StartTextbox(globalCtx, 0x2075, NULL); - this->talkState++; + pthis->talkState++; } break; case 8: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_25)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_25)) { + pthis->talkState++; } case 9: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x7033, NULL); - this->talkState = 10; + pthis->talkState = 10; } break; case 10: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { EnZl4_SetCsCameraMove(globalCtx, 4); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_33); - this->mouthExpression = ZL4_MOUTH_NEUTRAL; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_33); + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer2 = 0; - this->talkState = 15; + pthis->talkTimer2 = 0; + pthis->talkState = 15; } else { EnZl4_SetCsCameraAngle(globalCtx, 6); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer1 = 20; - this->talkState++; - this->skelAnime.playSpeed = 0.0f; + pthis->talkTimer1 = 20; + pthis->talkState++; + pthis->skelAnime.playSpeed = 0.0f; } } break; case 11: - if (DECR(this->talkTimer1) == 0) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_11); - this->blinkTimer = 11; - this->eyeExpression = ZL4_EYES_LOOK_RIGHT; - this->mouthExpression = ZL4_MOUTH_WORRIED; + if (DECR(pthis->talkTimer1) == 0) { + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_11); + pthis->blinkTimer = 11; + pthis->eyeExpression = ZL4_EYES_LOOK_RIGHT; + pthis->mouthExpression = ZL4_MOUTH_WORRIED; Message_StartTextbox(globalCtx, 0x7034, NULL); - this->talkState++; + pthis->talkState++; } break; case 12: - if (this->skelAnime.curFrame == 5.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_SIGH_0); + if (pthis->skelAnime.curFrame == 5.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_SIGH_0); } - if (EnZl4_SetNextAnim(this, ZL4_ANIM_12)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_12)) { + pthis->talkState++; } case 13: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_6); - this->blinkTimer = 3; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_HAPPY; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_6); + pthis->blinkTimer = 3; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_HAPPY; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState = 14; + pthis->talkState = 14; } break; case 14: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_25)) { + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_25)) { Message_StartTextbox(globalCtx, 0x7033, NULL); - this->talkState = 10; + pthis->talkState = 10; } break; case 15: - this->talkTimer2++; - if (this->talkTimer2 >= 30) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 30) { Message_StartTextbox(globalCtx, 0x7035, NULL); - this->talkState++; + pthis->talkState++; } break; case 16: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState++; + pthis->talkState++; } case 17: - this->talkTimer2++; - if (this->talkTimer2 == 130) { + pthis->talkTimer2++; + if (pthis->talkTimer2 == 130) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; globalCtx->nextEntranceIndex = 0xA0; gSaveContext.nextCutsceneIndex = 0xFFF7; @@ -793,41 +793,41 @@ s32 EnZl4_CsAskName(EnZl4* this, GlobalContext* globalCtx) { } break; } - if ((this->talkTimer2 == 17) && (this->talkTimer2 > 130)) { + if ((pthis->talkTimer2 == 17) && (pthis->talkTimer2 > 130)) { return true; } return false; } -s32 EnZl4_CsTellLegend(EnZl4* this, GlobalContext* globalCtx) { +s32 EnZl4_CsTellLegend(EnZl4* pthis, GlobalContext* globalCtx) { Camera* activeCam = GET_ACTIVE_CAM(globalCtx); - switch (this->talkState) { + switch (pthis->talkState) { case 0: - this->talkTimer2++; - if (this->talkTimer2 >= 60) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 60) { Message_StartTextbox(globalCtx, 0x7037, NULL); - this->talkState++; + pthis->talkState++; } break; case 1: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 7); Message_StartTextbox(globalCtx, 0x2076, NULL); - this->talkState++; + pthis->talkState++; } break; case 2: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraMove(globalCtx, 6); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState++; + pthis->talkState++; } break; case 3: if (activeCam->animState == 2) { Message_StartTextbox(globalCtx, 0x2077, NULL); - this->talkState++; + pthis->talkState++; } break; case 4: @@ -836,78 +836,78 @@ s32 EnZl4_CsTellLegend(EnZl4* this, GlobalContext* globalCtx) { } else if (globalCtx->msgCtx.choiceIndex == 0) { EnZl4_SetCsCameraAngle(globalCtx, 8); Message_StartTextbox(globalCtx, 0x7005, NULL); - this->talkState = 9; + pthis->talkState = 9; } else { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_5); - this->mouthExpression = ZL4_MOUTH_SURPRISED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_5); + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; Message_StartTextbox(globalCtx, 0x7038, NULL); - this->talkState++; - Audio_PlayActorSound2(&this->actor, NA_SE_VO_Z0_HURRY); + pthis->talkState++; + Audio_PlayActorSound2(&pthis->actor, NA_SE_VO_Z0_HURRY); } break; case 5: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_4)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_4)) { + pthis->talkState++; } case 6: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_33); - this->mouthExpression = ZL4_MOUTH_NEUTRAL; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_33); + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; Message_StartTextbox(globalCtx, 0x7037, NULL); - this->talkState++; + pthis->talkState++; } break; case 7: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x2076, NULL); - this->talkState++; + pthis->talkState++; } break; case 8: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x2077, NULL); - this->talkState = 4; + pthis->talkState = 4; } break; case 9: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_26); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_26); Message_StartTextbox(globalCtx, 0x2078, NULL); - this->talkState++; + pthis->talkState++; } break; case 10: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_27)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_27)) { + pthis->talkState++; } case 11: if (!((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx))) { break; } else if (globalCtx->msgCtx.choiceIndex == 0) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState = 13; + pthis->talkState = 13; } else { Message_StartTextbox(globalCtx, 0x700B, NULL); - this->talkState = 12; + pthis->talkState = 12; } break; case 12: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState = 13; + pthis->talkState = 13; } break; } - return (this->talkState == 13) ? 1 : 0; + return (pthis->talkState == 13) ? 1 : 0; } -s32 EnZl4_CsLookWindow(EnZl4* this, GlobalContext* globalCtx) { - switch (this->talkState) { +s32 EnZl4_CsLookWindow(EnZl4* pthis, GlobalContext* globalCtx) { + switch (pthis->talkState) { case 0: EnZl4_SetCsCameraMove(globalCtx, 7); globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gZeldasCourtyardWindowCs); gSaveContext.cutsceneTrigger = 1; - this->talkState++; + pthis->talkState++; break; case 1: if (globalCtx->csCtx.state != CS_STATE_IDLE) { @@ -917,8 +917,8 @@ s32 EnZl4_CsLookWindow(EnZl4* this, GlobalContext* globalCtx) { } else { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gZeldasCourtyardGanonCs); gSaveContext.cutsceneTrigger = 1; - this->talkState++; - func_8002DF54(globalCtx, &this->actor, 8); + pthis->talkState++; + func_8002DF54(globalCtx, &pthis->actor, 8); } break; case 2: @@ -928,355 +928,355 @@ s32 EnZl4_CsLookWindow(EnZl4* this, GlobalContext* globalCtx) { } } else { func_800AA000(0.0f, 0xA0, 0xA, 0x28); - func_8002DF54(globalCtx, &this->actor, 1); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_30); + func_8002DF54(globalCtx, &pthis->actor, 1); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_30); EnZl4_SetCsCameraAngle(globalCtx, 11); Message_StartTextbox(globalCtx, 0x7039, NULL); - this->talkState++; + pthis->talkState++; } break; case 3: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState++; + pthis->talkState++; } break; } - return (this->talkState == 4) ? 1 : 0; + return (pthis->talkState == 4) ? 1 : 0; } -s32 EnZl4_CsWarnAboutGanon(EnZl4* this, GlobalContext* globalCtx) { +s32 EnZl4_CsWarnAboutGanon(EnZl4* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 rotY; - switch (this->talkState) { + switch (pthis->talkState) { case 0: - player->actor.world.pos = this->actor.world.pos; - rotY = this->actor.shape.rot.y - 0x3FFC; + player->actor.world.pos = pthis->actor.world.pos; + rotY = pthis->actor.shape.rot.y - 0x3FFC; player->actor.world.pos.x += 34.0f * Math_SinS(rotY); player->actor.world.pos.z += 34.0f * Math_CosS(rotY); EnZl4_SetCsCameraMove(globalCtx, 8); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_WIDE; - this->mouthExpression = ZL4_MOUTH_WORRIED; - this->talkTimer2 = 0; - this->talkState++; + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_WIDE; + pthis->mouthExpression = ZL4_MOUTH_WORRIED; + pthis->talkTimer2 = 0; + pthis->talkState++; Message_StartTextbox(globalCtx, 0x2079, NULL); case 1: - this->talkTimer2++; - if (this->talkTimer2 >= 20) { - this->talkState++; + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 20) { + pthis->talkState++; } break; case 2: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraMove(globalCtx, 9); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkTimer2 = 0; - this->talkState++; + pthis->talkTimer2 = 0; + pthis->talkState++; } break; case 3: - this->talkTimer2++; - if (this->talkTimer2 >= 20) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 20) { Message_StartTextbox(globalCtx, 0x207A, NULL); - this->talkState++; + pthis->talkState++; } break; case 4: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 12); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_23); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_SURPRISED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_23); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState++; + pthis->talkState++; } break; case 5: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_24)) { + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_24)) { Message_StartTextbox(globalCtx, 0x207B, NULL); - this->talkState++; + pthis->talkState++; } break; case 6: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x703A, NULL); - this->talkState++; + pthis->talkState++; } break; case 7: if (!((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx))) { break; } else if (globalCtx->msgCtx.choiceIndex == 0) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_31); - this->blinkTimer = 11; - this->eyeExpression = ZL4_EYES_SQUINT; - this->mouthExpression = ZL4_MOUTH_HAPPY; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_31); + pthis->blinkTimer = 11; + pthis->eyeExpression = ZL4_EYES_SQUINT; + pthis->mouthExpression = ZL4_MOUTH_HAPPY; Message_StartTextbox(globalCtx, 0x703B, NULL); - this->talkState = 11; + pthis->talkState = 11; } else { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_13); - this->blinkTimer = 11; - this->eyeExpression = ZL4_EYES_LOOK_LEFT; - this->mouthExpression = ZL4_MOUTH_WORRIED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_13); + pthis->blinkTimer = 11; + pthis->eyeExpression = ZL4_EYES_LOOK_LEFT; + pthis->mouthExpression = ZL4_MOUTH_WORRIED; globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState++; + pthis->talkState++; } break; case 8: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_15)) { - this->blinkTimer = 3; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_SURPRISED; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_15)) { + pthis->blinkTimer = 3; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; Message_StartTextbox(globalCtx, 0x7073, NULL); - this->talkState++; + pthis->talkState++; } break; case 9: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_14); + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_14); globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState++; + pthis->talkState++; } break; case 10: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_24)) { + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_24)) { Message_StartTextbox(globalCtx, 0x703A, NULL); - this->talkState = 7; + pthis->talkState = 7; } break; case 11: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_32)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_32)) { + pthis->talkState++; } case 12: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = MSGMODE_PAUSED; - this->talkState = 13; + pthis->talkState = 13; } break; } - return (this->talkState == 13) ? 1 : 0; + return (pthis->talkState == 13) ? 1 : 0; } -s32 EnZl4_CsMakePlan(EnZl4* this, GlobalContext* globalCtx) { - switch (this->talkState) { +s32 EnZl4_CsMakePlan(EnZl4* pthis, GlobalContext* globalCtx) { + switch (pthis->talkState) { case 0: - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_18); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_WORRIED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_18); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_WORRIED; EnZl4_SetCsCameraMove(globalCtx, 10); - this->talkTimer2 = 0; - this->talkState++; + pthis->talkTimer2 = 0; + pthis->talkState++; case 1: - this->talkTimer2++; - if (this->talkTimer2 >= 10) { + pthis->talkTimer2++; + if (pthis->talkTimer2 >= 10) { Message_StartTextbox(globalCtx, 0x7123, NULL); - this->talkState++; + pthis->talkState++; } break; case 2: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { EnZl4_SetCsCameraAngle(globalCtx, 13); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_19); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_SURPRISED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_19); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; Message_StartTextbox(globalCtx, 0x207C, NULL); - this->talkState++; + pthis->talkState++; } break; case 3: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_20)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_20)) { + pthis->talkState++; } case 4: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x207D, NULL); - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_7); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_NEUTRAL; - this->talkState = 5; - this->unk_20F = this->lastAction = 0; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_7); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_NEUTRAL; + pthis->talkState = 5; + pthis->unk_20F = pthis->lastAction = 0; } break; case 5: - if (EnZl4_SetNextAnim(this, ZL4_ANIM_8)) { - this->talkState++; + if (EnZl4_SetNextAnim(pthis, ZL4_ANIM_8)) { + pthis->talkState++; } case 6: if (!((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx))) { break; } else { Camera_ChangeSetting(GET_ACTIVE_CAM(globalCtx), 1); - this->talkState = 7; - globalCtx->talkWithPlayer(globalCtx, &this->actor); - func_8002F434(&this->actor, globalCtx, GI_LETTER_ZELDA, fabsf(this->actor.xzDistToPlayer) + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); + pthis->talkState = 7; + globalCtx->talkWithPlayer(globalCtx, &pthis->actor); + func_8002F434(&pthis->actor, globalCtx, GI_LETTER_ZELDA, fabsf(pthis->actor.xzDistToPlayer) + 1.0f, + fabsf(pthis->actor.yDistToPlayer) + 1.0f); globalCtx->msgCtx.stateTimer = 4; globalCtx->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } break; case 7: - if (Actor_HasParent(&this->actor, globalCtx)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_0); - this->talkState++; + if (Actor_HasParent(&pthis->actor, globalCtx)) { + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_0); + pthis->talkState++; } else { - func_8002F434(&this->actor, globalCtx, GI_LETTER_ZELDA, fabsf(this->actor.xzDistToPlayer) + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); + func_8002F434(&pthis->actor, globalCtx, GI_LETTER_ZELDA, fabsf(pthis->actor.xzDistToPlayer) + 1.0f, + fabsf(pthis->actor.yDistToPlayer) + 1.0f); } // no break here is required for matching } - return (this->talkState == 8) ? 1 : 0; + return (pthis->talkState == 8) ? 1 : 0; } -void EnZl4_Cutscene(EnZl4* this, GlobalContext* globalCtx) { +void EnZl4_Cutscene(EnZl4* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - switch (this->csState) { + switch (pthis->csState) { case ZL4_CS_WAIT: - if (EnZl4_CsWaitForPlayer(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsWaitForPlayer(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_START: - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_3); - this->blinkTimer = 0; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_SURPRISED; + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_3); + pthis->blinkTimer = 0; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; Audio_PlayFanfare(NA_BGM_APPEAR); EnZl4_SetCsCameraAngle(globalCtx, 0); Interface_ChangeAlpha(2); ShrinkWindow_SetVal(0x20); - this->talkState = 0; - this->csState++; + pthis->talkState = 0; + pthis->csState++; break; case ZL4_CS_MEET: - if (EnZl4_CsMeetPlayer(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsMeetPlayer(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_STONE: - if (EnZl4_CsAskStone(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsAskStone(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_NAMES: - if (EnZl4_CsAskName(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsAskName(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_LEGEND: - if (EnZl4_CsTellLegend(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsTellLegend(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_WINDOW: - if (EnZl4_CsLookWindow(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsLookWindow(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_GANON: - if (EnZl4_CsWarnAboutGanon(this, globalCtx)) { - this->talkState = 0; - this->csState++; + if (EnZl4_CsWarnAboutGanon(pthis, globalCtx)) { + pthis->talkState = 0; + pthis->csState++; } break; case ZL4_CS_PLAN: - if (EnZl4_CsMakePlan(this, globalCtx)) { - func_8002DF54(globalCtx, &this->actor, 7); + if (EnZl4_CsMakePlan(pthis, globalCtx)) { + func_8002DF54(globalCtx, &pthis->actor, 7); gSaveContext.unk_13EE = 0x32; gSaveContext.eventChkInf[4] |= 1; - this->actionFunc = EnZl4_Idle; + pthis->actionFunc = EnZl4_Idle; } break; } - this->unk_1E0.unk_18 = player->actor.world.pos; - func_80034A14(&this->actor, &this->unk_1E0, 2, (this->csState == ZL4_CS_WINDOW) ? 2 : 1); - if (EnZl4_InMovingAnim(this)) { - EnZl4_SetMove(this, globalCtx); + pthis->unk_1E0.unk_18 = player->actor.world.pos; + func_80034A14(&pthis->actor, &pthis->unk_1E0, 2, (pthis->csState == ZL4_CS_WINDOW) ? 2 : 1); + if (EnZl4_InMovingAnim(pthis)) { + EnZl4_SetMove(pthis, globalCtx); } } -void EnZl4_Idle(EnZl4* this, GlobalContext* globalCtx) { - func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, this->collider.dim.radius + 60.0f, EnZl4_GetText, +void EnZl4_Idle(EnZl4* pthis, GlobalContext* globalCtx) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_1E0.unk_00, pthis->collider.dim.radius + 60.0f, EnZl4_GetText, func_80B5B9B0); - func_80B5BB78(this, globalCtx); + func_80B5BB78(pthis, globalCtx); } -void EnZl4_TheEnd(EnZl4* this, GlobalContext* globalCtx) { +void EnZl4_TheEnd(EnZl4* pthis, GlobalContext* globalCtx) { s32 animIndex[] = { ZL4_ANIM_0, ZL4_ANIM_0, ZL4_ANIM_0, ZL4_ANIM_0, ZL4_ANIM_0, ZL4_ANIM_0, ZL4_ANIM_0, ZL4_ANIM_26, ZL4_ANIM_21, ZL4_ANIM_3 }; CsCmdActorAction* npcAction; Vec3f pos; - if (SkelAnime_Update(&this->skelAnime) && (this->skelAnime.animation == &gChildZeldaAnim_010DF8)) { - func_80034EC0(&this->skelAnime, sAnimationEntries, ZL4_ANIM_4); + if (SkelAnime_Update(&pthis->skelAnime) && (pthis->skelAnime.animation == &gChildZeldaAnim_010DF8)) { + func_80034EC0(&pthis->skelAnime, sAnimationEntries, ZL4_ANIM_4); } - if (EnZl4_InMovingAnim(this)) { - EnZl4_SetMove(this, globalCtx); + if (EnZl4_InMovingAnim(pthis)) { + EnZl4_SetMove(pthis, globalCtx); } if (globalCtx->csCtx.frames == 100) { - this->eyeExpression = ZL4_EYES_LOOK_LEFT; + pthis->eyeExpression = ZL4_EYES_LOOK_LEFT; } if (globalCtx->csCtx.frames == 450) { - this->blinkTimer = 3; - this->eyeExpression = ZL4_EYES_NEUTRAL; - this->mouthExpression = ZL4_MOUTH_SURPRISED; + pthis->blinkTimer = 3; + pthis->eyeExpression = ZL4_EYES_NEUTRAL; + pthis->mouthExpression = ZL4_MOUTH_SURPRISED; } npcAction = globalCtx->csCtx.npcActions[0]; if (npcAction != NULL) { EnZl4_GetActionStartPos(npcAction, &pos); - if (this->lastAction == 0) { - this->actor.world.pos = this->actor.home.pos = pos; + if (pthis->lastAction == 0) { + pthis->actor.world.pos = pthis->actor.home.pos = pos; } - if (this->lastAction != npcAction->action) { - func_80034EC0(&this->skelAnime, sAnimationEntries, animIndex[npcAction->action]); - this->lastAction = npcAction->action; + if (pthis->lastAction != npcAction->action) { + func_80034EC0(&pthis->skelAnime, sAnimationEntries, animIndex[npcAction->action]); + pthis->lastAction = npcAction->action; } - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.velocity.z = 0.0f; } } void EnZl4_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - EnZl4* this = (EnZl4*)thisx; + EnZl4* pthis = (EnZl4*)thisx; - if (this->actionFunc != EnZl4_TheEnd) { - SkelAnime_Update(&this->skelAnime); + if (pthis->actionFunc != EnZl4_TheEnd) { + SkelAnime_Update(&pthis->skelAnime); } - EnZl4_UpdateFace(this); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + EnZl4_UpdateFace(pthis); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + pthis->actionFunc(pthis, globalCtx); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } s32 EnZl4_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnZl4* this = (EnZl4*)thisx; + EnZl4* pthis = (EnZl4*)thisx; Vec3s sp1C; if (limbIndex == 17) { - sp1C = this->unk_1E0.unk_08; + sp1C = pthis->unk_1E0.unk_08; Matrix_Translate(900.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateX((sp1C.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((sp1C.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); Matrix_Translate(-900.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 10) { - sp1C = this->unk_1E0.unk_0E; + sp1C = pthis->unk_1E0.unk_0E; Matrix_RotateY((sp1C.y / (f32)0x8000) * M_PI, MTXMODE_APPLY); Matrix_RotateX((sp1C.x / (f32)0x8000) * M_PI, MTXMODE_APPLY); } @@ -1288,15 +1288,15 @@ s32 EnZl4_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnZl4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - EnZl4* this = (EnZl4*)thisx; + EnZl4* pthis = (EnZl4*)thisx; if (limbIndex == 17) { - Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &pthis->actor.focus.pos); } } void EnZl4_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnZl4* this = (EnZl4*)thisx; + EnZl4* pthis = (EnZl4*)thisx; void* mouthTex[] = { gChildZeldaMouthNeutralTex, gChildZeldaMouthHappyTex, gChildZeldaMouthWorriedTex, gChildZeldaMouthSurprisedTex }; void* eyeTex[] = { @@ -1305,11 +1305,11 @@ void EnZl4_Draw(Actor* thisx, GlobalContext* globalCtx) { }; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zl4.c", 2012); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex[this->rightEyeState])); - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex[this->leftEyeState])); - gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex[this->mouthState])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTex[pthis->rightEyeState])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(eyeTex[pthis->leftEyeState])); + gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(mouthTex[pthis->mouthState])); func_80093D18(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnZl4_OverrideLimbDraw, EnZl4_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, + EnZl4_OverrideLimbDraw, EnZl4_PostLimbDraw, pthis); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zl4.c", 2043); } diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4_cutscene_data.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4_cutscene_data.cpp similarity index 100% rename from src/overlays/actors/ovl_En_Zl4/z_en_zl4_cutscene_data.c rename to src/overlays/actors/ovl_En_Zl4/z_en_zl4_cutscene_data.cpp diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.cpp similarity index 60% rename from src/overlays/actors/ovl_En_Zo/z_en_zo.c rename to src/overlays/actors/ovl_En_Zo/z_en_zo.cpp index 9e0908666..cb1534c36 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.cpp @@ -36,19 +36,19 @@ void EnZo_Update(Actor* thisx, GlobalContext* globalCtx); void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx); // Actions -void EnZo_Standing(EnZo* this, GlobalContext* globalCtx); -void EnZo_Submerged(EnZo* this, GlobalContext* globalCtx); -void EnZo_Surface(EnZo* this, GlobalContext* globalCtx); -void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx); -void EnZo_Dive(EnZo* this, GlobalContext* globalCtx); +void EnZo_Standing(EnZo* pthis, GlobalContext* globalCtx); +void EnZo_Submerged(EnZo* pthis, GlobalContext* globalCtx); +void EnZo_Surface(EnZo* pthis, GlobalContext* globalCtx); +void EnZo_TreadWater(EnZo* pthis, GlobalContext* globalCtx); +void EnZo_Dive(EnZo* pthis, GlobalContext* globalCtx); -void EnZo_Ripple(EnZo* this, Vec3f* pos, f32 scale, f32 targetScale, u8 alpha) { +void EnZo_Ripple(EnZo* pthis, Vec3f* pos, f32 scale, f32 targetScale, u8 alpha) { EnZoEffect* effect; Vec3f vec = { 0.0f, 0.0f, 0.0f }; s16 i; - effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + effect = pthis->effects; + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_NONE) { effect->type = ENZO_EFFECT_RIPPLE; effect->pos = *pos; @@ -61,18 +61,18 @@ void EnZo_Ripple(EnZo* this, Vec3f* pos, f32 scale, f32 targetScale, u8 alpha) { } } -void EnZo_Bubble(EnZo* this, Vec3f* pos) { +void EnZo_Bubble(EnZo* pthis, Vec3f* pos) { EnZoEffect* effect; Vec3f vec = { 0.0f, 0.0f, 0.0f }; Vec3f vel = { 0.0f, 1.0f, 0.0f }; s16 i; f32 waterSurface; - effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + effect = pthis->effects; + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (1) {} if (effect->type == ENZO_EFFECT_NONE) { - waterSurface = this->actor.world.pos.y + this->actor.yDistToWater; + waterSurface = pthis->actor.world.pos.y + pthis->actor.yDistToWater; if (!(waterSurface <= pos->y)) { effect->type = ENZO_EFFECT_BUBBLE; effect->pos = *pos; @@ -86,13 +86,13 @@ void EnZo_Bubble(EnZo* this, Vec3f* pos) { } } -void EnZo_Splash(EnZo* this, Vec3f* pos, Vec3f* vel, f32 scale) { +void EnZo_Splash(EnZo* pthis, Vec3f* pos, Vec3f* vel, f32 scale) { EnZoEffect* effect; Vec3f accel = { 0.0f, -1.0f, 0.0f }; s16 i; - effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + effect = pthis->effects; + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (1) {} if (effect->type != ENZO_EFFECT_SPLASH) { effect->type = ENZO_EFFECT_SPLASH; @@ -107,11 +107,11 @@ void EnZo_Splash(EnZo* this, Vec3f* pos, Vec3f* vel, f32 scale) { } } -void EnZo_UpdateRipples(EnZo* this) { - EnZoEffect* effect = this->effects; +void EnZo_UpdateRipples(EnZo* pthis) { + EnZoEffect* effect = pthis->effects; s16 i; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_RIPPLE) { Math_ApproachF(&effect->scale, effect->targetScale, 0.2f, 0.8f); if (effect->color.a > 20) { @@ -128,37 +128,37 @@ void EnZo_UpdateRipples(EnZo* this) { } } -void EnZo_UpdateBubbles(EnZo* this) { +void EnZo_UpdateBubbles(EnZo* pthis) { EnZoEffect* effect; f32 waterSurface; s16 i; - effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + effect = pthis->effects; + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_BUBBLE) { effect->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + effect->vec.x; effect->pos.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + effect->vec.z; effect->pos.y += effect->vel.y; // Bubbles turn into ripples when they reach the surface - waterSurface = this->actor.world.pos.y + this->actor.yDistToWater; + waterSurface = pthis->actor.world.pos.y + pthis->actor.yDistToWater; if (waterSurface <= effect->pos.y) { effect->type = ENZO_EFFECT_NONE; effect->pos.y = waterSurface; - EnZo_Ripple(this, &effect->pos, 0.06f, 0.12f, 200); + EnZo_Ripple(pthis, &effect->pos, 0.06f, 0.12f, 200); } } effect++; } } -void EnZo_UpdateSplashes(EnZo* this) { +void EnZo_UpdateSplashes(EnZo* pthis) { EnZoEffect* effect; f32 waterSurface; s16 i; - effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + effect = pthis->effects; + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_SPLASH) { effect->pos.x += effect->vel.x; effect->pos.y += effect->vel.y; @@ -172,27 +172,27 @@ void EnZo_UpdateSplashes(EnZo* this) { } // Splash particles turn into ripples when they hit the surface - waterSurface = this->actor.world.pos.y + this->actor.yDistToWater; + waterSurface = pthis->actor.world.pos.y + pthis->actor.yDistToWater; if (effect->pos.y < waterSurface) { effect->type = ENZO_EFFECT_NONE; effect->pos.y = waterSurface; - EnZo_Ripple(this, &effect->pos, 0.06f, 0.12f, 200); + EnZo_Ripple(pthis, &effect->pos, 0.06f, 0.12f, 200); } } effect++; } } -void EnZo_DrawRipples(EnZo* this, GlobalContext* globalCtx) { +void EnZo_DrawRipples(EnZo* pthis, GlobalContext* globalCtx) { EnZoEffect* effect; s16 i; u8 setup; - effect = this->effects; + effect = pthis->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 217); setup = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_RIPPLE) { if (!setup) { if (1) {} @@ -214,15 +214,15 @@ void EnZo_DrawRipples(EnZo* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 248); } -void EnZo_DrawBubbles(EnZo* this, GlobalContext* globalCtx) { - EnZoEffect* effect = this->effects; +void EnZo_DrawBubbles(EnZo* pthis, GlobalContext* globalCtx) { + EnZoEffect* effect = pthis->effects; s16 i; u8 setup; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 260); setup = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_BUBBLE) { if (!setup) { if (1) {} @@ -247,16 +247,16 @@ void EnZo_DrawBubbles(EnZo* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 286); } -void EnZo_DrawSplashes(EnZo* this, GlobalContext* globalCtx) { +void EnZo_DrawSplashes(EnZo* pthis, GlobalContext* globalCtx) { EnZoEffect* effect; s16 i; u8 setup; - effect = this->effects; + effect = pthis->effects; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 298); setup = false; func_80093D84(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { if (effect->type == ENZO_EFFECT_SPLASH) { if (!setup) { if (1) {} @@ -280,13 +280,13 @@ void EnZo_DrawSplashes(EnZo* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zo_eff.c", 331); } -void EnZo_TreadWaterRipples(EnZo* this, f32 scale, f32 targetScale, u8 alpha) { +void EnZo_TreadWaterRipples(EnZo* pthis, f32 scale, f32 targetScale, u8 alpha) { Vec3f pos = { 0.0f, 0.0f, 0.0f }; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + this->actor.yDistToWater; - pos.z = this->actor.world.pos.z; - EnZo_Ripple(this, &pos, scale, targetScale, alpha); + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + pos.z = pthis->actor.world.pos.z; + EnZo_Ripple(pthis, &pos, scale, targetScale, alpha); } static ColliderCylinderInit sCylinderInit = { @@ -311,7 +311,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -const ActorInit En_Zo_InitVars = { +ActorInit En_Zo_InitVars = { ACTOR_EN_ZO, ACTORCAT_NPC, FLAGS, @@ -334,7 +334,7 @@ static struct_80034EC0_Entry sAnimations[] = { { &gZoraOpenArmsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, }; -void EnZo_SpawnSplashes(EnZo* this) { +void EnZo_SpawnSplashes(EnZo* pthis) { Vec3f pos; Vec3f vel; s32 i; @@ -349,11 +349,11 @@ void EnZo_SpawnSplashes(EnZo* this) { vel.x = sinf(angle) * speed; vel.z = cosf(angle) * speed; - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.x += vel.x * 6.0f; pos.z += vel.z * 6.0f; - pos.y += this->actor.yDistToWater; - EnZo_Splash(this, &pos, &vel, 0.08f); + pos.y += pthis->actor.yDistToWater; + EnZo_Splash(pthis, &pos, &vel, 0.08f); } } @@ -494,41 +494,41 @@ s16 func_80B61298(GlobalContext* globalCtx, Actor* thisx) { return 1; } -void EnZo_Blink(EnZo* this) { - if (DECR(this->blinkTimer) == 0) { - this->eyeTexture++; - if (this->eyeTexture >= 3) { - this->blinkTimer = Rand_S16Offset(30, 30); - this->eyeTexture = 0; +void EnZo_Blink(EnZo* pthis) { + if (DECR(pthis->blinkTimer) == 0) { + pthis->eyeTexture++; + if (pthis->eyeTexture >= 3) { + pthis->blinkTimer = Rand_S16Offset(30, 30); + pthis->eyeTexture = 0; } } } -void EnZo_Dialog(EnZo* this, GlobalContext* globalCtx) { +void EnZo_Dialog(EnZo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk_194.unk_18 = player->actor.world.pos; - if (this->actionFunc == EnZo_Standing) { + pthis->unk_194.unk_18 = player->actor.world.pos; + if (pthis->actionFunc == EnZo_Standing) { // Look down at link if young, look up if old - this->unk_194.unk_14 = !LINK_IS_ADULT ? 10.0f : -10.0f; + pthis->unk_194.unk_14 = !LINK_IS_ADULT ? 10.0f : -10.0f; } else { - this->unk_194.unk_18.y = this->actor.world.pos.y; + pthis->unk_194.unk_18.y = pthis->actor.world.pos.y; } - func_80034A14(&this->actor, &this->unk_194, 11, this->unk_64C); - if (this->canSpeak == true) { - func_800343CC(globalCtx, &this->actor, &this->unk_194.unk_00, this->dialogRadius, func_80B61024, func_80B61298); + func_80034A14(&pthis->actor, &pthis->unk_194, 11, pthis->unk_64C); + if (pthis->canSpeak == true) { + func_800343CC(globalCtx, &pthis->actor, &pthis->unk_194.unk_00, pthis->dialogRadius, func_80B61024, func_80B61298); } } -s32 EnZo_PlayerInProximity(EnZo* this, GlobalContext* globalCtx) { +s32 EnZo_PlayerInProximity(EnZo* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f surfacePos; f32 yDist; f32 hDist; - surfacePos.x = this->actor.world.pos.x; - surfacePos.y = this->actor.world.pos.y + this->actor.yDistToWater; - surfacePos.z = this->actor.world.pos.z; + surfacePos.x = pthis->actor.world.pos.x; + surfacePos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + surfacePos.z = pthis->actor.world.pos.z; hDist = Math_Vec3f_DistXZ(&surfacePos, &player->actor.world.pos); yDist = fabsf(player->actor.world.pos.y - surfacePos.y); @@ -539,13 +539,13 @@ s32 EnZo_PlayerInProximity(EnZo* this, GlobalContext* globalCtx) { return 0; } -void EnZo_SetAnimation(EnZo* this) { +void EnZo_SetAnimation(EnZo* pthis) { s32 animId = 8; - if (this->skelAnime.animation == &gZoraHandsOnHipsTappingFootAnim || - this->skelAnime.animation == &gZoraOpenArmsAnim) { - if (this->unk_194.unk_00 == 0) { - if (this->actionFunc == EnZo_Standing) { + if (pthis->skelAnime.animation == &gZoraHandsOnHipsTappingFootAnim || + pthis->skelAnime.animation == &gZoraOpenArmsAnim) { + if (pthis->unk_194.unk_00 == 0) { + if (pthis->actionFunc == EnZo_Standing) { animId = 0; } else { animId = 3; @@ -553,260 +553,260 @@ void EnZo_SetAnimation(EnZo* this) { } } - if (this->unk_194.unk_00 != 0 && this->actor.textId == 0x4006 && - this->skelAnime.animation != &gZoraHandsOnHipsTappingFootAnim) { + if (pthis->unk_194.unk_00 != 0 && pthis->actor.textId == 0x4006 && + pthis->skelAnime.animation != &gZoraHandsOnHipsTappingFootAnim) { animId = 6; } - if (this->unk_194.unk_00 != 0 && this->actor.textId == 0x4007 && this->skelAnime.animation != &gZoraOpenArmsAnim) { + if (pthis->unk_194.unk_00 != 0 && pthis->actor.textId == 0x4007 && pthis->skelAnime.animation != &gZoraOpenArmsAnim) { animId = 7; } if (animId != 8) { - func_80034EC0(&this->skelAnime, sAnimations, animId); + func_80034EC0(&pthis->skelAnime, sAnimations, animId); if (animId == 3) { - this->skelAnime.curFrame = this->skelAnime.endFrame; - this->skelAnime.playSpeed = 0.0f; + pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.playSpeed = 0.0f; } } } void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnZo* this = (EnZo*)thisx; + EnZo* pthis = (EnZo*)thisx; - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInit); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gZoraSkel, NULL, pthis->jointTable, pthis->morphTable, 20); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&pthis->actor.colChkInfo, NULL, &sColChkInit); - if (LINK_IS_ADULT && ((this->actor.params & 0x3F) == 8)) { - Actor_Kill(&this->actor); + if (LINK_IS_ADULT && ((pthis->actor.params & 0x3F) == 8)) { + Actor_Kill(&pthis->actor); return; } - func_80034EC0(&this->skelAnime, sAnimations, 2); - Actor_SetScale(&this->actor, 0.01f); - this->actor.targetMode = 6; - this->dialogRadius = this->collider.dim.radius + 30.0f; - this->unk_64C = 1; - this->canSpeak = false; - this->unk_194.unk_00 = 0; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, this->collider.dim.height * 0.5f, this->collider.dim.radius, 0.0f, + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + Actor_SetScale(&pthis->actor, 0.01f); + pthis->actor.targetMode = 6; + pthis->dialogRadius = pthis->collider.dim.radius + 30.0f; + pthis->unk_64C = 1; + pthis->canSpeak = false; + pthis->unk_194.unk_00 = 0; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, pthis->collider.dim.height * 0.5f, pthis->collider.dim.radius, 0.0f, 5); - if (this->actor.yDistToWater < 54.0f || (this->actor.params & 0x3F) == 8) { - this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.shape.shadowScale = 24.0f; - func_80034EC0(&this->skelAnime, sAnimations, 1); - this->canSpeak = true; - this->alpha = 255.0f; - this->actionFunc = EnZo_Standing; + if (pthis->actor.yDistToWater < 54.0f || (pthis->actor.params & 0x3F) == 8) { + pthis->actor.shape.shadowDraw = ActorShadow_DrawCircle; + pthis->actor.shape.shadowScale = 24.0f; + func_80034EC0(&pthis->skelAnime, sAnimations, 1); + pthis->canSpeak = true; + pthis->alpha = 255.0f; + pthis->actionFunc = EnZo_Standing; } else { - this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnZo_Submerged; + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actionFunc = EnZo_Submerged; } } void EnZo_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void EnZo_Standing(EnZo* this, GlobalContext* globalCtx) { +void EnZo_Standing(EnZo* pthis, GlobalContext* globalCtx) { s16 angle; - func_80034F54(globalCtx, this->unk_656, this->unk_67E, 20); - EnZo_SetAnimation(this); - if (this->unk_194.unk_00 != 0) { - this->unk_64C = 4; + func_80034F54(globalCtx, pthis->unk_656, pthis->unk_67E, 20); + EnZo_SetAnimation(pthis); + if (pthis->unk_194.unk_00 != 0) { + pthis->unk_64C = 4; return; } - angle = ABS((s16)((f32)this->actor.yawTowardsPlayer - (f32)this->actor.shape.rot.y)); + angle = ABS((s16)((f32)pthis->actor.yawTowardsPlayer - (f32)pthis->actor.shape.rot.y)); if (angle < 0x4718) { - if (EnZo_PlayerInProximity(this, globalCtx)) { - this->unk_64C = 2; + if (EnZo_PlayerInProximity(pthis, globalCtx)) { + pthis->unk_64C = 2; } else { - this->unk_64C = 1; + pthis->unk_64C = 1; } } else { - this->unk_64C = 1; + pthis->unk_64C = 1; } } -void EnZo_Submerged(EnZo* this, GlobalContext* globalCtx) { - if (EnZo_PlayerInProximity(this, globalCtx)) { - this->actionFunc = EnZo_Surface; - this->actor.velocity.y = 4.0f; +void EnZo_Submerged(EnZo* pthis, GlobalContext* globalCtx) { + if (EnZo_PlayerInProximity(pthis, globalCtx)) { + pthis->actionFunc = EnZo_Surface; + pthis->actor.velocity.y = 4.0f; } } -void EnZo_Surface(EnZo* this, GlobalContext* globalCtx) { - if (this->actor.yDistToWater < 54.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); - EnZo_SpawnSplashes(this); - func_80034EC0(&this->skelAnime, sAnimations, 3); - this->actor.flags |= ACTOR_FLAG_0; - this->actionFunc = EnZo_TreadWater; - this->actor.velocity.y = 0.0f; - this->alpha = 255.0f; - } else if (this->actor.yDistToWater < 80.0f) { - Math_ApproachF(&this->actor.velocity.y, 2.0f, 0.4f, 0.6f); - Math_ApproachF(&this->alpha, 255.0f, 0.3f, 10.0f); +void EnZo_Surface(EnZo* pthis, GlobalContext* globalCtx) { + if (pthis->actor.yDistToWater < 54.0f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_OUT_OF_WATER); + EnZo_SpawnSplashes(pthis); + func_80034EC0(&pthis->skelAnime, sAnimations, 3); + pthis->actor.flags |= ACTOR_FLAG_0; + pthis->actionFunc = EnZo_TreadWater; + pthis->actor.velocity.y = 0.0f; + pthis->alpha = 255.0f; + } else if (pthis->actor.yDistToWater < 80.0f) { + Math_ApproachF(&pthis->actor.velocity.y, 2.0f, 0.4f, 0.6f); + Math_ApproachF(&pthis->alpha, 255.0f, 0.3f, 10.0f); } } -void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx) { - func_80034F54(globalCtx, this->unk_656, this->unk_67E, 20); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->canSpeak = true; - this->unk_64C = 4; - this->skelAnime.playSpeed = 0.0f; +void EnZo_TreadWater(EnZo* pthis, GlobalContext* globalCtx) { + func_80034F54(globalCtx, pthis->unk_656, pthis->unk_67E, 20); + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + pthis->canSpeak = true; + pthis->unk_64C = 4; + pthis->skelAnime.playSpeed = 0.0f; } - EnZo_SetAnimation(this); + EnZo_SetAnimation(pthis); - Math_ApproachF(&this->actor.velocity.y, this->actor.yDistToWater < 54.0f ? -0.6f : 0.6f, 0.3f, 0.2f); - if (this->rippleTimer != 0) { - this->rippleTimer--; - if ((this->rippleTimer == 3) || (this->rippleTimer == 6)) { - EnZo_TreadWaterRipples(this, 0.2f, 1.0f, 200); + Math_ApproachF(&pthis->actor.velocity.y, pthis->actor.yDistToWater < 54.0f ? -0.6f : 0.6f, 0.3f, 0.2f); + if (pthis->rippleTimer != 0) { + pthis->rippleTimer--; + if ((pthis->rippleTimer == 3) || (pthis->rippleTimer == 6)) { + EnZo_TreadWaterRipples(pthis, 0.2f, 1.0f, 200); } } else { - EnZo_TreadWaterRipples(this, 0.2f, 1.0f, 200); - this->rippleTimer = 12; + EnZo_TreadWaterRipples(pthis, 0.2f, 1.0f, 200); + pthis->rippleTimer = 12; } - if (EnZo_PlayerInProximity(this, globalCtx) != 0) { - this->timeToDive = Rand_S16Offset(40, 40); - } else if (DECR(this->timeToDive) == 0) { + if (EnZo_PlayerInProximity(pthis, globalCtx) != 0) { + pthis->timeToDive = Rand_S16Offset(40, 40); + } else if (DECR(pthis->timeToDive) == 0) { f32 startFrame; - func_80034EC0(&this->skelAnime, sAnimations, 4); - this->canSpeak = false; - this->unk_64C = 1; - this->actionFunc = EnZo_Dive; - startFrame = this->skelAnime.startFrame; - this->skelAnime.startFrame = this->skelAnime.endFrame; - this->skelAnime.curFrame = this->skelAnime.endFrame; - this->skelAnime.endFrame = startFrame; - this->skelAnime.playSpeed = -1.0f; + func_80034EC0(&pthis->skelAnime, sAnimations, 4); + pthis->canSpeak = false; + pthis->unk_64C = 1; + pthis->actionFunc = EnZo_Dive; + startFrame = pthis->skelAnime.startFrame; + pthis->skelAnime.startFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.curFrame = pthis->skelAnime.endFrame; + pthis->skelAnime.endFrame = startFrame; + pthis->skelAnime.playSpeed = -1.0f; } } -void EnZo_Dive(EnZo* this, GlobalContext* globalCtx) { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIVE_WATER); - EnZo_SpawnSplashes(this); - this->actor.flags &= ~ACTOR_FLAG_0; - this->actor.velocity.y = -4.0f; - this->skelAnime.playSpeed = 0.0f; +void EnZo_Dive(EnZo* pthis, GlobalContext* globalCtx) { + if (Animation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_DIVE_WATER); + EnZo_SpawnSplashes(pthis); + pthis->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.velocity.y = -4.0f; + pthis->skelAnime.playSpeed = 0.0f; } - if (this->skelAnime.playSpeed > 0.0f) { + if (pthis->skelAnime.playSpeed > 0.0f) { return; } - if (this->actor.yDistToWater > 80.0f || this->actor.bgCheckFlags & 1) { - Math_ApproachF(&this->actor.velocity.y, -1.0f, 0.4f, 0.6f); - Math_ApproachF(&this->alpha, 0.0f, 0.3f, 10.0f); + if (pthis->actor.yDistToWater > 80.0f || pthis->actor.bgCheckFlags & 1) { + Math_ApproachF(&pthis->actor.velocity.y, -1.0f, 0.4f, 0.6f); + Math_ApproachF(&pthis->alpha, 0.0f, 0.3f, 10.0f); } - if ((s16)this->alpha == 0) { - func_80034EC0(&this->skelAnime, sAnimations, 2); - this->actor.world.pos = this->actor.home.pos; - this->alpha = 0.0f; - this->actionFunc = EnZo_Submerged; + if ((s16)pthis->alpha == 0) { + func_80034EC0(&pthis->skelAnime, sAnimations, 2); + pthis->actor.world.pos = pthis->actor.home.pos; + pthis->alpha = 0.0f; + pthis->actionFunc = EnZo_Submerged; } } void EnZo_Update(Actor* thisx, GlobalContext* globalCtx) { - EnZo* this = (EnZo*)thisx; + EnZo* pthis = (EnZo*)thisx; u32 pad; Vec3f pos; - if ((s32)this->alpha != 0) { - SkelAnime_Update(&this->skelAnime); - EnZo_Blink(this); + if ((s32)pthis->alpha != 0) { + SkelAnime_Update(&pthis->skelAnime); + EnZo_Blink(pthis); } Actor_MoveForward(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, this->collider.dim.radius, this->collider.dim.height * 0.25f, 0.0f, 5); - this->actionFunc(this, globalCtx); - EnZo_Dialog(this, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, pthis->collider.dim.radius, pthis->collider.dim.height * 0.25f, 0.0f, 5); + pthis->actionFunc(pthis, globalCtx); + EnZo_Dialog(pthis, globalCtx); // Spawn air bubbles if (globalCtx->state.frames & 8) { - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.y += (Rand_ZeroOne() - 0.5f) * 10.0f + 18.0f; pos.x += (Rand_ZeroOne() - 0.5f) * 28.0f; pos.z += (Rand_ZeroOne() - 0.5f) * 28.0f; - EnZo_Bubble(this, &pos); + EnZo_Bubble(pthis, &pos); } - if ((s32)this->alpha != 0) { - Collider_UpdateCylinder(thisx, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((s32)pthis->alpha != 0) { + Collider_UpdateCylinder(thisx, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - EnZo_UpdateRipples(this); - EnZo_UpdateBubbles(this); - EnZo_UpdateSplashes(this); + EnZo_UpdateRipples(pthis); + EnZo_UpdateBubbles(pthis); + EnZo_UpdateSplashes(pthis); } s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx) { - EnZo* this = (EnZo*)thisx; + EnZo* pthis = (EnZo*)thisx; Vec3s vec; if (limbIndex == 15) { Matrix_Translate(1800.0f, 0.0f, 0.0f, MTXMODE_APPLY); - vec = this->unk_194.unk_08; + vec = pthis->unk_194.unk_08; Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Translate(-1800.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - vec = this->unk_194.unk_0E; + vec = pthis->unk_194.unk_0E; Matrix_RotateX((-vec.y / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY); } if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { - rot->y += (Math_SinS(this->unk_656[limbIndex]) * 200.0f); - rot->z += (Math_CosS(this->unk_67E[limbIndex]) * 200.0f); + rot->y += (Math_SinS(pthis->unk_656[limbIndex]) * 200.0f); + rot->z += (Math_CosS(pthis->unk_67E[limbIndex]) * 200.0f); } return 0; } void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { - EnZo* this = (EnZo*)thisx; + EnZo* pthis = (EnZo*)thisx; Vec3f vec = { 0.0f, 600.0f, 0.0f }; if (limbIndex == 15) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); + Matrix_MultVec3f(&vec, &pthis->actor.focus.pos); } } void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnZo* this = (EnZo*)thisx; + EnZo* pthis = (EnZo*)thisx; void* eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; Matrix_Push(); - EnZo_DrawRipples(this, globalCtx); - EnZo_DrawBubbles(this, globalCtx); - EnZo_DrawSplashes(this, globalCtx); + EnZo_DrawRipples(pthis, globalCtx); + EnZo_DrawBubbles(pthis, globalCtx); + EnZo_DrawSplashes(pthis, globalCtx); Matrix_Pop(); - if ((s32)this->alpha != 0) { + if ((s32)pthis->alpha != 0) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_zo.c", 1008); - if (this->alpha == 255.0f) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexture])); - func_80034BA0(globalCtx, &this->skelAnime, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, thisx, this->alpha); + if (pthis->alpha == 255.0f) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexture])); + func_80034BA0(globalCtx, &pthis->skelAnime, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, thisx, pthis->alpha); } else { - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeTexture])); - func_80034CC4(globalCtx, &this->skelAnime, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, thisx, this->alpha); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[pthis->eyeTexture])); + func_80034CC4(globalCtx, &pthis->skelAnime, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, thisx, pthis->alpha); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_zo.c", 1025); diff --git a/src/overlays/actors/ovl_En_fHG/z_en_fhg.c b/src/overlays/actors/ovl_En_fHG/z_en_fhg.c deleted file mode 100644 index 9054b3639..000000000 --- a/src/overlays/actors/ovl_En_fHG/z_en_fhg.c +++ /dev/null @@ -1,743 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FHG_Z_EN_FHG_C -#include "actor_common.h" -/* - * File: z_en_fhg.c - * Overlay: ovl_En_fHG - * Description: Phantom Ganon's Horse - */ - -#include "z_en_fhg.h" -#include "objects/object_fhg/object_fhg.h" -#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" -#include "overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h" -#include "overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.h" -#include "def/code_800F9280.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_demo.h" -#include "def/z_lib.h" -#include "def/z_play.h" -#include "def/z_rcp.h" -#include "def/z_skelanime.h" -#include "def/z_skin.h" -#include "def/z_skin_awb.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef struct { - /* 0x00 */ Vec3f pos; - /* 0x0C */ s16 yRot; -} EnfHGPainting; // size = 0x10; - -typedef enum { - /* 0 */ INTRO_WAIT, - /* 1 */ INTRO_START, - /* 2 */ INTRO_FENCE, - /* 3 */ INTRO_BACK, - /* 4 */ INTRO_REVEAL, - /* 5 */ INTRO_CUT, - /* 6 */ INTRO_LAUGH, - /* 7 */ INTRO_TITLE, - /* 8 */ INTRO_RETREAT, - /* 9 */ INTRO_FINISH, - /* 15 */ INTRO_READY = 15 -} EnfHGIntroState; - -void EnfHG_Init(Actor* thisx, GlobalContext* globalCtx); -void EnfHG_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnfHG_Update(Actor* thisx, GlobalContext* globalCtx); -void EnfHG_Draw(Actor* thisx, GlobalContext* globalCtx); - -void EnfHG_SetupIntro(EnfHG* this, GlobalContext* globalCtx); -void EnfHG_Intro(EnfHG* this, GlobalContext* globalCtx); -void EnfHG_SetupApproach(EnfHG* this, GlobalContext* globalCtx, s16 paintingIndex); -void EnfHG_Approach(EnfHG* this, GlobalContext* globalCtx); -void EnfHG_Attack(EnfHG* this, GlobalContext* globalCtx); -void EnfHG_Damage(EnfHG* this, GlobalContext* globalCtx); -void EnfHG_Retreat(EnfHG* this, GlobalContext* globalCtx); -void EnfHG_Done(EnfHG* this, GlobalContext* globalCtx); - -void EnfHG_Noop(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin); - -const ActorInit En_fHG_InitVars = { - ACTOR_EN_FHG, - ACTORCAT_BG, - FLAGS, - OBJECT_FHG, - sizeof(EnfHG), - (ActorFunc)EnfHG_Init, - (ActorFunc)EnfHG_Destroy, - (ActorFunc)EnfHG_Update, - (ActorFunc)EnfHG_Draw, -}; - -static EnfHGPainting sPaintings[] = { - { { 0.0f, 60.0f, -315.0f }, 0x0000 }, { { -260.0f, 60.0f, -145.0f }, 0x2AAA }, - { { -260.0f, 60.0f, 165.0f }, 0x5554 }, { { 0.0f, 60.0f, 315.0f }, 0x7FFE }, - { { 260.0f, 60.0f, 155.0f }, 0xAAA8 }, { { 260.0f, 60.0f, -155.0f }, 0xD552 }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_S8(naviEnemyId, 0x1A, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), -}; - -void EnfHG_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - EnfHG* this = (EnfHG*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Flags_SetSwitch(globalCtx, 0x14); - Actor_SetScale(&this->actor, 0.011499999f); - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, -2600.0f, NULL, 20.0f); - this->actor.speedXZ = 0.0f; - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - func_800A663C(globalCtx, &this->skin, &gPhantomHorseSkel, &gPhantomHorseRunningAnim); - - if (this->actor.params >= GND_FAKE_BOSS) { - EnfHG_SetupApproach(this, globalCtx, this->actor.params - GND_FAKE_BOSS); - } else { - EnfHG_SetupIntro(this, globalCtx); - } -} - -void EnfHG_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnfHG* this = (EnfHG*)thisx; - - osSyncPrintf("F DT1\n"); - func_800A6888(globalCtx, &this->skin); - osSyncPrintf("F DT2\n"); -} - -void EnfHG_SetupIntro(EnfHG* this, GlobalContext* globalCtx) { - Animation_PlayLoop(&this->skin.skelAnime, &gPhantomHorseIdleAnim); - this->actionFunc = EnfHG_Intro; - this->actor.world.pos.x = GND_BOSSROOM_CENTER_X; - this->actor.world.pos.y = GND_BOSSROOM_CENTER_Y - 267.0f; - this->actor.world.pos.z = GND_BOSSROOM_CENTER_Z; -} - -void EnfHG_Intro(EnfHG* this, GlobalContext* globalCtx) { - static Vec3f audioVec = { 0.0f, 0.0f, 50.0f }; - s32 pad64; - Player* player = GET_PLAYER(globalCtx); - BossGanondrof* bossGnd = (BossGanondrof*)this->actor.parent; - s32 pad58; - s32 pad54; - - if (this->cutsceneState != INTRO_FINISH) { - SkelAnime_Update(&this->skin.skelAnime); - } - switch (this->cutsceneState) { - case INTRO_WAIT: - if ((fabsf(player->actor.world.pos.x - (GND_BOSSROOM_CENTER_X + 0.0f)) < 150.0f) && - (fabsf(player->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 0.0f)) < 150.0f)) { - this->cutsceneState = INTRO_READY; - } - break; - case INTRO_READY: - if ((fabsf(player->actor.world.pos.x - (GND_BOSSROOM_CENTER_X + 0.0f)) < 100.0f) && - (fabsf(player->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 315.0f)) < 100.0f)) { - this->cutsceneState = INTRO_START; - if (gSaveContext.eventChkInf[7] & 4) { - this->timers[0] = 57; - } - } - break; - case INTRO_START: - if (gSaveContext.eventChkInf[7] & 4) { - if (this->timers[0] == 55) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_SHUTTER, - GND_BOSSROOM_CENTER_X + 0.0f, GND_BOSSROOM_CENTER_Y - 97.0f, - GND_BOSSROOM_CENTER_Z + 308.0f, 0, 0, 0, (SHUTTER_PG_BARS << 6)); - } - if (this->timers[0] == 51) { - Audio_PlayActorSound2(this->actor.child, NA_SE_EV_SPEAR_FENCE); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); - } - if (this->timers[0] == 0) { - EnfHG_SetupApproach(this, globalCtx, Rand_ZeroOne() * 5.99f); - this->bossGndSignal = FHG_START_FIGHT; - } - break; - } - func_80064520(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 8); - this->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, this->cutsceneCamera, CAM_STAT_ACTIVE); - this->cutsceneState = INTRO_FENCE; - this->timers[0] = 60; - this->actor.world.pos.y = GND_BOSSROOM_CENTER_Y - 7.0f; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); - gSaveContext.eventChkInf[7] |= 4; - Flags_SetSwitch(globalCtx, 0x23); - case INTRO_FENCE: - player->actor.world.pos.x = GND_BOSSROOM_CENTER_X + 0.0f; - player->actor.world.pos.y = GND_BOSSROOM_CENTER_Y + 7.0f; - player->actor.world.pos.z = GND_BOSSROOM_CENTER_Z + 155.0f; - player->actor.world.rot.y = player->actor.shape.rot.y = 0; - player->actor.speedXZ = 0.0f; - this->cameraEye.x = GND_BOSSROOM_CENTER_X + 0.0f; - this->cameraEye.y = GND_BOSSROOM_CENTER_Y + 37.0f; - this->cameraEye.z = GND_BOSSROOM_CENTER_Z + 170.0f; - this->cameraAt.x = GND_BOSSROOM_CENTER_X + 0.0f; - this->cameraAt.y = GND_BOSSROOM_CENTER_Y + 47.0f; - this->cameraAt.z = GND_BOSSROOM_CENTER_Z + 315.0f; - if (this->timers[0] == 25) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_SHUTTER, - GND_BOSSROOM_CENTER_X + 0.0f, GND_BOSSROOM_CENTER_Y - 97.0f, - GND_BOSSROOM_CENTER_Z + 308.0f, 0, 0, 0, (SHUTTER_PG_BARS << 6)); - } - if (this->timers[0] == 21) { - Audio_PlayActorSound2(this->actor.child, NA_SE_EV_SPEAR_FENCE); - } - if (this->timers[0] == 0) { - this->cutsceneState = INTRO_BACK; - this->timers[0] = 80; - } - break; - case INTRO_BACK: - if (this->timers[0] == 25) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_HORSE_GROAN); - } - if (this->timers[0] == 20) { - func_8002DF54(globalCtx, &this->actor, 9); - } - if (this->timers[0] == 1) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_OPENING_GANON); - } - Math_ApproachF(&this->cameraEye.x, GND_BOSSROOM_CENTER_X + 40.0f, 0.05f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraEye.y, GND_BOSSROOM_CENTER_Y + 37.0f, 0.05f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraEye.z, GND_BOSSROOM_CENTER_Z + 80.0f, 0.05f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraAt.x, GND_BOSSROOM_CENTER_X - 100.0f, 0.05f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraAt.y, GND_BOSSROOM_CENTER_Y + 47.0f, 0.05f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraAt.z, GND_BOSSROOM_CENTER_Z + 335.0f, 0.05f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, 0.01f); - if (this->timers[0] == 0) { - this->cutsceneState = INTRO_REVEAL; - this->timers[0] = 50; - this->cameraSpeedMod = 0.0f; - } - break; - case INTRO_REVEAL: - Math_ApproachF(&this->cameraEye.x, GND_BOSSROOM_CENTER_X + 70.0f, 0.1f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraEye.y, GND_BOSSROOM_CENTER_Y + 7.0f, 0.1f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraEye.z, GND_BOSSROOM_CENTER_Z + 200.0f, 0.1f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraAt.x, GND_BOSSROOM_CENTER_X - 150.0f, 0.1f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraAt.y, GND_BOSSROOM_CENTER_Y + 107.0f, 0.1f, this->cameraSpeedMod * 20.0f); - Math_ApproachF(&this->cameraAt.z, GND_BOSSROOM_CENTER_Z - 65.0f, 0.1f, this->cameraSpeedMod * 40.0f); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, 0.05f); - if (this->timers[0] == 5) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_SANDDUST); - } - if (this->timers[0] == 0) { - this->cutsceneState = INTRO_CUT; - this->timers[0] = 50; - this->cameraSpeedMod = 0.0f; - } - break; - case INTRO_CUT: - this->cutsceneState = INTRO_LAUGH; - this->cameraEye.x = GND_BOSSROOM_CENTER_X + 50.0f; - this->cameraEye.y = GND_BOSSROOM_CENTER_Y + 17.0f; - this->cameraEye.z = GND_BOSSROOM_CENTER_Z + 110.0f; - this->cameraAt.x = GND_BOSSROOM_CENTER_X - 150.0f; - this->cameraAt.y = GND_BOSSROOM_CENTER_Y + 207.0f; - this->cameraAt.z = GND_BOSSROOM_CENTER_Z - 155.0f; - this->cameraEyeVel.x = fabsf(this->cameraEye.x - (GND_BOSSROOM_CENTER_X + 20.0f)); - this->cameraEyeVel.y = fabsf(this->cameraEye.y - (GND_BOSSROOM_CENTER_Y + 102.0f)); - this->cameraEyeVel.z = fabsf(this->cameraEye.z - (GND_BOSSROOM_CENTER_Z + 25.0f)); - this->cameraAtVel.x = fabsf(this->cameraAt.x - (GND_BOSSROOM_CENTER_X - 150.0f)); - this->cameraAtVel.y = fabsf(this->cameraAt.y - (GND_BOSSROOM_CENTER_Y + 197.0f)); - this->cameraAtVel.z = fabsf(this->cameraAt.z - (GND_BOSSROOM_CENTER_Z - 65.0f)); - this->timers[0] = 250; - case INTRO_LAUGH: - Math_ApproachF(&this->cameraEye.x, GND_BOSSROOM_CENTER_X + 20.0f, 0.05f, - this->cameraSpeedMod * this->cameraEyeVel.x); - Math_ApproachF(&this->cameraEye.y, GND_BOSSROOM_CENTER_Y + 102.0f, 0.05f, - this->cameraSpeedMod * this->cameraEyeVel.y); - Math_ApproachF(&this->cameraEye.z, GND_BOSSROOM_CENTER_Z + 25.0f, 0.05f, - this->cameraSpeedMod * this->cameraEyeVel.z); - Math_ApproachF(&this->cameraAt.x, GND_BOSSROOM_CENTER_X - 150.0f, 0.05f, - this->cameraSpeedMod * this->cameraAtVel.x); - Math_ApproachF(&this->cameraAt.y, GND_BOSSROOM_CENTER_Y + 197.0f, 0.05f, - this->cameraSpeedMod * this->cameraAtVel.y); - Math_ApproachF(&this->cameraAt.z, GND_BOSSROOM_CENTER_Z - 65.0f, 0.05f, - this->cameraSpeedMod * this->cameraAtVel.z); - Math_ApproachF(&this->cameraSpeedMod, 0.01f, 1.0f, 0.001f); - if ((this->timers[0] == 245) || (this->timers[0] == 3)) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &gPhantomHorseRearingAnim, -8.0f); - this->bossGndSignal = FHG_REAR; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_HORSE_NEIGH); - if (this->timers[0] == 3) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_VOICE); - } - } - if (this->timers[0] == 192) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_SANDDUST); - } - if (this->timers[0] == 212) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HORSE_LAND2); - Animation_Change(&this->skin.skelAnime, &gPhantomHorseIdleAnim, 0.3f, 0.0f, 5.0f, ANIMMODE_LOOP_INTERP, - -10.0f); - } - if (this->timers[0] == 90) { - globalCtx->envCtx.unk_BF = 2; - globalCtx->envCtx.unk_D6 = 0x14; - } - if (this->timers[0] == 100) { - this->bossGndSignal = FHG_LIGHTNING; - } - if (this->timers[0] == 60) { - this->bossGndSignal = FHG_RIDE; - } - if (this->timers[0] == 130) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5000FF); - } - if (this->timers[0] == 30) { - bossGnd->work[GND_EYE_STATE] = GND_EYESTATE_BRIGHTEN; - } - if (this->timers[0] == 35) { - func_80078914(&audioVec, NA_SE_EN_FANTOM_EYE); - } - if (this->timers[0] == 130) { - bossGnd->work[GND_EYE_STATE] = GND_EYESTATE_FADE; - func_80078914(&audioVec, NA_SE_EN_FANTOM_ST_LAUGH); - } - if (this->timers[0] == 20) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); - } - if (this->timers[0] == 2) { - this->cameraSpeedMod = 0.0f; - this->cutsceneState = INTRO_TITLE; - this->cameraEyeVel.x = fabsf(this->cameraEye.x - (GND_BOSSROOM_CENTER_X + 180.0f)); - this->cameraEyeVel.y = fabsf(this->cameraEye.y - (GND_BOSSROOM_CENTER_Y + 7.0f)); - this->cameraEyeVel.z = fabsf(this->cameraEye.z - (GND_BOSSROOM_CENTER_Z + 140.0f)); - this->timers[0] = 100; - this->timers[1] = 34; - this->cameraAtVel.x = fabsf(this->cameraAt.x - this->actor.world.pos.x); - this->cameraAtVel.y = fabsf(this->cameraAt.y - ((this->actor.world.pos.y + 70.0f) - 20.0f)); - this->cameraAtVel.z = fabsf(this->cameraAt.z - this->actor.world.pos.z); - } - break; - case INTRO_TITLE: - if (this->timers[1] == 1) { - Animation_Change(&this->skin.skelAnime, &gPhantomHorseIdleAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gPhantomHorseIdleAnim), ANIMMODE_LOOP_INTERP, -3.0f); - } - Math_ApproachF(&this->cameraEye.x, GND_BOSSROOM_CENTER_X + 180.0f, 0.1f, - this->cameraSpeedMod * this->cameraEyeVel.x); - Math_ApproachF(&this->cameraEye.y, GND_BOSSROOM_CENTER_Y + 7.0f, 0.1f, - this->cameraSpeedMod * this->cameraEyeVel.y); - Math_ApproachF(&this->cameraEye.z, this->cameraPanZ + (GND_BOSSROOM_CENTER_Z + 140.0f), 0.1f, - this->cameraSpeedMod * this->cameraEyeVel.z); - Math_ApproachF(&this->cameraPanZ, -100.0f, 0.1f, 1.0f); - Math_ApproachF(&this->cameraAt.x, this->actor.world.pos.x, 0.1f, this->cameraSpeedMod * 10.0f); - Math_ApproachF(&this->cameraAt.y, (this->actor.world.pos.y + 70.0f) - 20.0f, 0.1f, - this->cameraSpeedMod * 10.0f); - Math_ApproachF(&this->cameraAt.z, this->actor.world.pos.z, 0.1f, this->cameraSpeedMod * 10.0f); - Math_ApproachF(&this->actor.world.pos.y, 60.0f, 0.1f, 2.0f); - this->actor.world.pos.y += 2.0f * Math_SinS(this->gallopTimer * 0x5DC); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, 0.05f); - if (this->timers[0] == 75) { - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gPhantomGanonTitleCardTex), 160, 180, 128, 40); - } - if (this->timers[0] == 0) { - this->cutsceneState = INTRO_RETREAT; - this->timers[0] = 200; - this->timers[1] = 23; - this->cameraSpeedMod = 0.0f; - Animation_Change(&this->skin.skelAnime, &gPhantomHorseLeapAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gPhantomHorseLeapAnim), ANIMMODE_ONCE_INTERP, -4.0f); - this->bossGndSignal = FHG_SPUR; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_VOICE); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_HORSE_NEIGH); - } - break; - case INTRO_RETREAT: - if (this->timers[1] == 1) { - Animation_Change(&this->skin.skelAnime, &gPhantomHorseLandAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gPhantomHorseLandAnim), ANIMMODE_ONCE_INTERP, -3.0f); - this->bossGndSignal = FHG_FINISH; - } - if (this->timers[0] == 170) { - func_8002DF54(globalCtx, &this->actor, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_MASIC2); - } - Math_ApproachF(&this->cameraEye.z, this->cameraPanZ + (GND_BOSSROOM_CENTER_Z + 100.0f), 0.1f, - this->cameraSpeedMod * 1.5f); - Math_ApproachF(&this->cameraPanZ, -100.0f, 0.1f, 1.0f); - Math_ApproachF(&this->actor.world.pos.z, GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f, 1.0f, - this->cameraSpeedMod * 10.0f); - Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, 0.05f); - if ((fabsf(this->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f)) < 300.0f) && - !this->spawnedWarp) { - this->spawnedWarp = true; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - GND_BOSSROOM_CENTER_X + 0.0f, this->actor.world.pos.y + 50.0f, - GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f, 0, this->actor.shape.rot.y, 0, - FHGFIRE_WARP_RETREAT); - this->fhgFireKillWarp = true; - } - Math_ApproachF(&this->cameraAt.x, this->actor.world.pos.x, 0.2f, 50.0f); - Math_ApproachF(&this->cameraAt.z, this->actor.world.pos.z, 0.2f, 50.0f); - osSyncPrintf("TIME %d-------------------------------------------------\n", this->timers[0]); - if (fabsf(this->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f)) < 1.0f) { - globalCtx->envCtx.unk_BF = 0; - globalCtx->envCtx.unk_D6 = 0x14; - this->cutsceneState = INTRO_FINISH; - Animation_MorphToLoop(&this->skin.skelAnime, &gPhantomHorseRunningAnim, -3.0f); - this->bossGndSignal = FHG_START_FIGHT; - this->timers[1] = 75; - this->timers[0] = 140; - } - break; - case INTRO_FINISH: - EnfHG_Retreat(this, globalCtx); - Math_ApproachF(&this->cameraEye.z, this->cameraPanZ + (GND_BOSSROOM_CENTER_Z + 100.0f), 0.1f, - this->cameraSpeedMod * 1.5f); - Math_ApproachF(&this->cameraPanZ, -100.0f, 0.1f, 1.0f); - Math_ApproachF(&this->cameraAt.y, (this->actor.world.pos.y + 70.0f) - 20.0f, 0.1f, - this->cameraSpeedMod * 10.0f); - if (this->timers[1] == 0) { - Camera* camera = Gameplay_GetCamera(globalCtx, 0); - - camera->eye = this->cameraEye; - camera->eyeNext = this->cameraEye; - camera->at = this->cameraAt; - func_800C08AC(globalCtx, this->cutsceneCamera, 0); - this->cutsceneCamera = 0; - func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); - this->actionFunc = EnfHG_Retreat; - } - break; - } - if (this->cutsceneCamera != 0) { - Gameplay_CameraSetAtEye(globalCtx, this->cutsceneCamera, &this->cameraAt, &this->cameraEye); - } -} - -void EnfHG_SetupApproach(EnfHG* this, GlobalContext* globalCtx, s16 paintingIndex) { - s16 oppositeIndex[6] = { 3, 4, 5, 0, 1, 2 }; - - Animation_MorphToLoop(&this->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); - this->actionFunc = EnfHG_Approach; - this->curPainting = paintingIndex; - this->targetPainting = oppositeIndex[this->curPainting]; - - osSyncPrintf("KABE NO 1 = %d\n", this->curPainting); - osSyncPrintf("KABE NO 2 = %d\n", this->targetPainting); - - this->actor.world.pos.x = (1.3f * sPaintings[this->curPainting].pos.x) + (GND_BOSSROOM_CENTER_X - 4.0f); - this->actor.world.pos.y = sPaintings[this->curPainting].pos.y + (GND_BOSSROOM_CENTER_Y + 153.0f); - this->actor.world.pos.z = (1.3f * sPaintings[this->curPainting].pos.z) - -(GND_BOSSROOM_CENTER_Z - 10.0f); - this->actor.world.rot.y = sPaintings[this->curPainting].yRot; - - osSyncPrintf("XP1 = %f\n", this->actor.world.pos.x); - osSyncPrintf("ZP1 = %f\n", this->actor.world.pos.z); - - this->inPaintingPos.x = (sPaintings[this->targetPainting].pos.x * 1.3f) + (GND_BOSSROOM_CENTER_X - 4.0f); - this->inPaintingPos.y = sPaintings[this->targetPainting].pos.y + (GND_BOSSROOM_CENTER_Y + 33.0f); - this->inPaintingPos.z = (sPaintings[this->targetPainting].pos.z * 1.3f) - -(GND_BOSSROOM_CENTER_Z - 10.0f); - this->inPaintingVelX = (fabsf(this->inPaintingPos.x - this->actor.world.pos.x) * 2) * 0.01f; - - if (this->inPaintingVelX < 1.0f) { - this->inPaintingVelX = 1.0f; - } - this->inPaintingVelZ = (fabsf(this->inPaintingPos.z - this->actor.world.pos.z) * 2) * 0.01f; - if (this->inPaintingVelZ < 1.0f) { - this->inPaintingVelZ = 1.0f; - } - - this->timers[0] = 100; - this->actor.scale.x = 0.002f; - this->actor.scale.y = 0.002f; - this->actor.scale.z = 0.001f; - this->approachRate = 0.0f; - - this->warpColorFilterR = globalCtx->lightCtx.fogColor[0]; - this->warpColorFilterG = globalCtx->lightCtx.fogColor[1]; - this->warpColorFilterB = globalCtx->lightCtx.fogColor[2]; - this->warpColorFilterUnk1 = 0.0f; - this->warpColorFilterUnk2 = 0.0f; - this->turnRot = 0; - this->turnTarget = 0; - this->spawnedWarp = false; -} - -void EnfHG_Approach(EnfHG* this, GlobalContext* globalCtx) { - osSyncPrintf("STANDBY !!\n"); - osSyncPrintf("XP2 = %f\n", this->actor.world.pos.x); - osSyncPrintf("ZP2 = %f\n", this->actor.world.pos.z); - if (this->actor.params == GND_REAL_BOSS) { - this->hoofSfxPos.x = this->actor.projectedPos.x / (this->actor.scale.x * 100.0f); - this->hoofSfxPos.y = this->actor.projectedPos.y / (this->actor.scale.x * 100.0f); - this->hoofSfxPos.z = this->actor.projectedPos.z / (this->actor.scale.x * 100.0f); - if ((this->gallopTimer % 8) == 0) { - func_80078914(&this->hoofSfxPos, NA_SE_EV_HORSE_RUN); - } - } - SkelAnime_Update(&this->skin.skelAnime); - Math_ApproachF(&this->actor.scale.x, 0.011499999f, 1.0f, this->approachRate); - Math_ApproachF(&this->approachRate, 0.0002f, 1.0f, 0.0000015f); - Math_ApproachF(&this->actor.world.pos.y, 60.0f, 0.1f, 1.0f); - this->actor.scale.y = this->actor.scale.x; - if (this->timers[0] == 0) { - osSyncPrintf("arg_data ------------------------------------>%d\n", this->actor.params); - if (this->actor.params != GND_REAL_BOSS) { - this->timers[0] = 140; - this->actionFunc = EnfHG_Retreat; - Animation_MorphToLoop(&this->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); - this->turnTarget = -0x8000; - } else { - this->actionFunc = EnfHG_Attack; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_HORSE_NEIGH); - this->timers[0] = 40; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - this->actor.world.pos.x, this->actor.world.pos.y + 50.0f, this->actor.world.pos.z, 0, - this->actor.shape.rot.y + 0x8000, 0, FHGFIRE_WARP_EMERGE); - this->fhgFireKillWarp = false; - } - } -} - -void EnfHG_Attack(EnfHG* this, GlobalContext* globalCtx) { - osSyncPrintf("KABE OUT !!\n"); - this->bossGndInPainting = false; - SkelAnime_Update(&this->skin.skelAnime); - if (this->timers[0] != 0) { - Math_ApproachF(&this->actor.scale.z, 0.011499999f, 1.0f, 0.0002f); - if (this->timers[0] == 1) { - this->bossGndSignal = FHG_RAISE_SPEAR; - this->timers[1] = 50; - Animation_MorphToPlayOnce(&this->skin.skelAnime, &gPhantomHorseLeapAnim, 0.0f); - } - Math_ApproachF(&this->warpColorFilterR, 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterG, 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterB, 255.0f, 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterUnk1, -60.0f, 1.0f, 5.0f); - } else { - Math_ApproachF(&this->warpColorFilterR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterG, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterB, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterUnk1, 0.0f, 1.0f, 5.0f); - if (this->timers[1] == 29) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_MASIC2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_VOICE); - } - if (this->hitTimer == 0) { - if (this->timers[1] == 24) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, - this->actor.world.pos.x, (this->actor.world.pos.y + 100.0f) + 25.0f, - this->actor.world.pos.z, 0, 0, 0, FHGFIRE_LIGHTNING_STRIKE); - } - if (this->timers[1] == 45) { - Animation_MorphToLoop(&this->skin.skelAnime, &gPhantomHorseAirAnim, 0.0f); - } - if (this->timers[1] == 38) { - this->bossGndSignal = FHG_LIGHTNING; - } - if (this->timers[1] == 16) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, &gPhantomHorseLandAnim, 0.0f); - this->bossGndSignal = FHG_RESET; - } - } - Math_ApproachF(&this->actor.scale.z, 0.011499999f, 1.0f, 0.002f); - Math_ApproachF(&this->actor.world.pos.x, this->inPaintingPos.x, 1.0f, this->inPaintingVelX); - Math_ApproachF(&this->actor.world.pos.y, 60.0f, 0.1f, 1.0f); - Math_ApproachF(&this->actor.world.pos.z, this->inPaintingPos.z, 1.0f, this->inPaintingVelZ); - } - if (this->hitTimer == 20) { - this->actionFunc = EnfHG_Damage; - this->spawnedWarp = false; - Animation_Change(&this->skin.skelAnime, &gPhantomHorseLandAnim, -1.0f, 0.0f, - Animation_GetLastFrame(&gPhantomHorseLandAnim), ANIMMODE_ONCE, -5.0f); - this->timers[0] = 10; - this->bossGndSignal = FHG_RESET; - this->damageSpeedMod = 1.0f; - } else { - f32 dx = this->actor.world.pos.x - this->inPaintingPos.x; - f32 dz = this->actor.world.pos.z - this->inPaintingPos.z; - f32 dxz = sqrtf(SQ(dx) + SQ(dz)); - - if (dxz < 350.0f) { - this->bossGndInPainting = true; - } - if ((dxz < 300.0f) && !this->spawnedWarp) { - this->spawnedWarp = true; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, this->inPaintingPos.x, - this->actor.world.pos.y + 50.0f, this->inPaintingPos.z, 0, this->actor.shape.rot.y, 0, - FHGFIRE_WARP_RETREAT); - this->fhgFireKillWarp = true; - } - osSyncPrintf("SPD X %f\n", this->inPaintingVelX); - osSyncPrintf("SPD Z %f\n", this->inPaintingVelZ); - osSyncPrintf("X=%f\n", dx); - osSyncPrintf("Z=%f\n", dz); - if (dxz == 0.0f) { - this->timers[0] = 140; - this->actionFunc = EnfHG_Retreat; - Animation_MorphToLoop(&this->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); - this->bossGndSignal = FHG_RIDE; - } - } -} - -void EnfHG_Damage(EnfHG* this, GlobalContext* globalCtx) { - f32 dx; - f32 dz; - f32 dxz2; - - osSyncPrintf("REVISE !!\n"); - SkelAnime_Update(&this->skin.skelAnime); - Math_ApproachF(&this->warpColorFilterR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterG, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterB, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); - Math_ApproachF(&this->warpColorFilterUnk1, 0.0f, 1.0f, 5.0f); - Math_ApproachF(&this->actor.scale.z, 0.011499999f, 1.0f, 0.002f); - if (this->timers[0] != 0) { - Math_ApproachZeroF(&this->damageSpeedMod, 1.0f, 0.1f); - if (this->timers[0] == 1) { - this->targetPainting = this->curPainting; - this->inPaintingPos.x = (sPaintings[this->targetPainting].pos.x * 1.3f) + (GND_BOSSROOM_CENTER_X - 4.0f); - this->inPaintingPos.y = sPaintings[this->targetPainting].pos.y; - this->inPaintingPos.z = (sPaintings[this->targetPainting].pos.z * 1.3f) - -(GND_BOSSROOM_CENTER_Z - 10.0f); - } - } else { - Math_ApproachF(&this->damageSpeedMod, 1.0f, 1.0f, 0.1f); - } - Math_ApproachF(&this->actor.world.pos.x, this->inPaintingPos.x, 1.0f, this->damageSpeedMod * this->inPaintingVelX); - Math_ApproachF(&this->actor.world.pos.y, 60.0f, 0.1f, 1.0f); - Math_ApproachF(&this->actor.world.pos.z, this->inPaintingPos.z, 1.0f, this->damageSpeedMod * this->inPaintingVelZ); - dx = this->actor.world.pos.x - this->inPaintingPos.x; - dz = this->actor.world.pos.z - this->inPaintingPos.z; - dxz2 = sqrtf(SQ(dx) + SQ(dz)); - if ((dxz2 < 300.0f) && (!this->spawnedWarp)) { - this->spawnedWarp = true; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FHG_FIRE, this->inPaintingPos.x, - this->actor.world.pos.y + 50.0f, this->inPaintingPos.z, 0, this->actor.shape.rot.y + 0x8000, - 0, FHGFIRE_WARP_RETREAT); - } - if (dxz2 == 0.0f) { - BossGanondrof* bossGnd = (BossGanondrof*)this->actor.parent; - - this->timers[0] = 140; - this->actionFunc = EnfHG_Retreat; - Animation_MorphToLoop(&this->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); - if (bossGnd->actor.colChkInfo.health > 24) { - this->bossGndSignal = FHG_RIDE; - } else { - bossGnd->flyMode = GND_FLY_NEUTRAL; - } - this->turnTarget = -0x8000; - } -} - -void EnfHG_Retreat(EnfHG* this, GlobalContext* globalCtx) { - osSyncPrintf("KABE IN !!\n"); - if (this->turnTarget != 0) { - Math_ApproachS(&this->turnRot, this->turnTarget, 5, 2000); - } - if (this->actor.params == GND_REAL_BOSS) { - this->hoofSfxPos.x = this->actor.projectedPos.x / (this->actor.scale.x * 100.0f); - this->hoofSfxPos.y = this->actor.projectedPos.y / (this->actor.scale.x * 100.0f); - this->hoofSfxPos.z = this->actor.projectedPos.z / (this->actor.scale.x * 100.0f); - if ((this->gallopTimer % 8) == 0) { - func_80078914(&this->hoofSfxPos, NA_SE_EV_HORSE_RUN); - } - } - SkelAnime_Update(&this->skin.skelAnime); - Math_ApproachF(&this->actor.scale.z, 0.001f, 1.0f, 0.001f); - Math_ApproachF(&this->actor.scale.x, 0.002f, 0.05f, 0.0001f); - Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 1.0f); - this->actor.scale.y = this->actor.scale.x; - if ((this->timers[0] == 80) && (this->actor.params == GND_REAL_BOSS)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FANTOM_LAUGH); - } - if (this->timers[0] == 0) { - BossGanondrof* bossGnd = (BossGanondrof*)this->actor.parent; - s16 paintingIdxReal; - s16 paintingIdxFake; - - if (this->actor.params != GND_REAL_BOSS) { - this->killActor = true; - bossGnd->killActor = true; - } else if (bossGnd->flyMode != GND_FLY_PAINTING) { - this->actionFunc = EnfHG_Done; - this->actor.draw = NULL; - } else { - paintingIdxReal = Rand_ZeroOne() * 5.99f; - EnfHG_SetupApproach(this, globalCtx, paintingIdxReal); - do { - paintingIdxFake = Rand_ZeroOne() * 5.99f; - } while (paintingIdxFake == paintingIdxReal); - osSyncPrintf("ac1 = %x `````````````````````````````````````````````````\n", - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_GANONDROF, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - 0, 0, 0, paintingIdxFake + GND_FAKE_BOSS)); - } - } -} - -void EnfHG_Done(EnfHG* this, GlobalContext* globalCtx) { - this->bossGndInPainting = false; -} - -void EnfHG_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - EnfHG* this = (EnfHG*)thisx; - u8 i; - - if (this->killActor) { - Actor_Kill(&this->actor); - return; - } - this->gallopTimer++; - this->bossGndInPainting = true; - for (i = 0; i < 5; i++) { - if (this->timers[i] != 0) { - this->timers[i]--; - } - } - - this->actionFunc(this, globalCtx); - - if (this->hitTimer != 0) { - this->hitTimer--; - } - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; - this->actor.shape.rot.y = this->actor.world.rot.y; - - this->actor.shape.yOffset = Math_SinS(this->hitTimer * 0x9000) * 700.0f * (this->hitTimer / 20.0f); - this->actor.shape.rot.z = (s16)(Math_SinS(this->hitTimer * 0x7000) * 1500.0f) * (this->hitTimer / 20.0f); -} - -void EnfHG_Noop(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { -} - -void EnfHG_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnfHG* this = (EnfHG*)thisx; - BossGanondrof* bossGnd = (BossGanondrof*)this->actor.parent; - s32 pad; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg.c", 2439); - func_80093D18(globalCtx->state.gfxCtx); - - POLY_OPA_DISP = ((bossGnd->work[GND_INVINC_TIMER] & 4) && (bossGnd->flyMode == GND_FLY_PAINTING)) - ? Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099) - : Gfx_SetFog(POLY_OPA_DISP, (u32)this->warpColorFilterR, (u32)this->warpColorFilterG, - (u32)this->warpColorFilterB, 0, (s32)this->warpColorFilterUnk1 + 995, - (s32)this->warpColorFilterUnk2 + 1000); - func_800A6330(&this->actor, globalCtx, &this->skin, EnfHG_Noop, 0x23); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg.c", 2480); -} diff --git a/src/overlays/actors/ovl_En_fHG/z_en_fhg.cpp b/src/overlays/actors/ovl_En_fHG/z_en_fhg.cpp new file mode 100644 index 000000000..062824e4d --- /dev/null +++ b/src/overlays/actors/ovl_En_fHG/z_en_fhg.cpp @@ -0,0 +1,743 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_EN_FHG_Z_EN_FHG_C +#include "actor_common.h" +/* + * File: z_en_fhg.c + * Overlay: ovl_En_fHG + * Description: Phantom Ganon's Horse + */ + +#include "z_en_fhg.h" +#include "objects/object_fhg/object_fhg.h" +#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" +#include "overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.h" +#include "overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.h" +#include "def/code_800F9280.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_demo.h" +#include "def/z_lib.h" +#include "def/z_play.h" +#include "def/z_rcp.h" +#include "def/z_skelanime.h" +#include "def/z_skin.h" +#include "def/z_skin_awb.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ s16 yRot; +} EnfHGPainting; // size = 0x10; + +typedef enum { + /* 0 */ INTRO_WAIT, + /* 1 */ INTRO_START, + /* 2 */ INTRO_FENCE, + /* 3 */ INTRO_BACK, + /* 4 */ INTRO_REVEAL, + /* 5 */ INTRO_CUT, + /* 6 */ INTRO_LAUGH, + /* 7 */ INTRO_TITLE, + /* 8 */ INTRO_RETREAT, + /* 9 */ INTRO_FINISH, + /* 15 */ INTRO_READY = 15 +} EnfHGIntroState; + +void EnfHG_Init(Actor* thisx, GlobalContext* globalCtx); +void EnfHG_Destroy(Actor* thisx, GlobalContext* globalCtx); +void EnfHG_Update(Actor* thisx, GlobalContext* globalCtx); +void EnfHG_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnfHG_SetupIntro(EnfHG* pthis, GlobalContext* globalCtx); +void EnfHG_Intro(EnfHG* pthis, GlobalContext* globalCtx); +void EnfHG_SetupApproach(EnfHG* pthis, GlobalContext* globalCtx, s16 paintingIndex); +void EnfHG_Approach(EnfHG* pthis, GlobalContext* globalCtx); +void EnfHG_Attack(EnfHG* pthis, GlobalContext* globalCtx); +void EnfHG_Damage(EnfHG* pthis, GlobalContext* globalCtx); +void EnfHG_Retreat(EnfHG* pthis, GlobalContext* globalCtx); +void EnfHG_Done(EnfHG* pthis, GlobalContext* globalCtx); + +void EnfHG_Noop(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin); + +ActorInit En_fHG_InitVars = { + ACTOR_EN_FHG, + ACTORCAT_BG, + FLAGS, + OBJECT_FHG, + sizeof(EnfHG), + (ActorFunc)EnfHG_Init, + (ActorFunc)EnfHG_Destroy, + (ActorFunc)EnfHG_Update, + (ActorFunc)EnfHG_Draw, +}; + +static EnfHGPainting sPaintings[] = { + { { 0.0f, 60.0f, -315.0f }, 0x0000 }, { { -260.0f, 60.0f, -145.0f }, 0x2AAA }, + { { -260.0f, 60.0f, 165.0f }, 0x5554 }, { { 0.0f, 60.0f, 315.0f }, 0x7FFE }, + { { 260.0f, 60.0f, 155.0f }, 0xAAA8 }, { { 260.0f, 60.0f, -155.0f }, 0xD552 }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(naviEnemyId, 0x1A, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), +}; + +void EnfHG_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnfHG* pthis = (EnfHG*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Flags_SetSwitch(globalCtx, 0x14); + Actor_SetScale(&pthis->actor, 0.011499999f); + pthis->actor.gravity = -3.5f; + ActorShape_Init(&pthis->actor.shape, -2600.0f, NULL, 20.0f); + pthis->actor.speedXZ = 0.0f; + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + func_800A663C(globalCtx, &pthis->skin, &gPhantomHorseSkel, &gPhantomHorseRunningAnim); + + if (pthis->actor.params >= GND_FAKE_BOSS) { + EnfHG_SetupApproach(pthis, globalCtx, pthis->actor.params - GND_FAKE_BOSS); + } else { + EnfHG_SetupIntro(pthis, globalCtx); + } +} + +void EnfHG_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnfHG* pthis = (EnfHG*)thisx; + + osSyncPrintf("F DT1\n"); + func_800A6888(globalCtx, &pthis->skin); + osSyncPrintf("F DT2\n"); +} + +void EnfHG_SetupIntro(EnfHG* pthis, GlobalContext* globalCtx) { + Animation_PlayLoop(&pthis->skin.skelAnime, &gPhantomHorseIdleAnim); + pthis->actionFunc = EnfHG_Intro; + pthis->actor.world.pos.x = GND_BOSSROOM_CENTER_X; + pthis->actor.world.pos.y = GND_BOSSROOM_CENTER_Y - 267.0f; + pthis->actor.world.pos.z = GND_BOSSROOM_CENTER_Z; +} + +void EnfHG_Intro(EnfHG* pthis, GlobalContext* globalCtx) { + static Vec3f audioVec = { 0.0f, 0.0f, 50.0f }; + s32 pad64; + Player* player = GET_PLAYER(globalCtx); + BossGanondrof* bossGnd = (BossGanondrof*)pthis->actor.parent; + s32 pad58; + s32 pad54; + + if (pthis->cutsceneState != INTRO_FINISH) { + SkelAnime_Update(&pthis->skin.skelAnime); + } + switch (pthis->cutsceneState) { + case INTRO_WAIT: + if ((fabsf(player->actor.world.pos.x - (GND_BOSSROOM_CENTER_X + 0.0f)) < 150.0f) && + (fabsf(player->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 0.0f)) < 150.0f)) { + pthis->cutsceneState = INTRO_READY; + } + break; + case INTRO_READY: + if ((fabsf(player->actor.world.pos.x - (GND_BOSSROOM_CENTER_X + 0.0f)) < 100.0f) && + (fabsf(player->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 315.0f)) < 100.0f)) { + pthis->cutsceneState = INTRO_START; + if (gSaveContext.eventChkInf[7] & 4) { + pthis->timers[0] = 57; + } + } + break; + case INTRO_START: + if (gSaveContext.eventChkInf[7] & 4) { + if (pthis->timers[0] == 55) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_SHUTTER, + GND_BOSSROOM_CENTER_X + 0.0f, GND_BOSSROOM_CENTER_Y - 97.0f, + GND_BOSSROOM_CENTER_Z + 308.0f, 0, 0, 0, (SHUTTER_PG_BARS << 6)); + } + if (pthis->timers[0] == 51) { + Audio_PlayActorSound2(pthis->actor.child, NA_SE_EV_SPEAR_FENCE); + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + } + if (pthis->timers[0] == 0) { + EnfHG_SetupApproach(pthis, globalCtx, Rand_ZeroOne() * 5.99f); + pthis->bossGndSignal = FHG_START_FIGHT; + } + break; + } + func_80064520(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 8); + pthis->cutsceneCamera = Gameplay_CreateSubCamera(globalCtx); + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + Gameplay_ChangeCameraStatus(globalCtx, pthis->cutsceneCamera, CAM_STAT_ACTIVE); + pthis->cutsceneState = INTRO_FENCE; + pthis->timers[0] = 60; + pthis->actor.world.pos.y = GND_BOSSROOM_CENTER_Y - 7.0f; + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + gSaveContext.eventChkInf[7] |= 4; + Flags_SetSwitch(globalCtx, 0x23); + case INTRO_FENCE: + player->actor.world.pos.x = GND_BOSSROOM_CENTER_X + 0.0f; + player->actor.world.pos.y = GND_BOSSROOM_CENTER_Y + 7.0f; + player->actor.world.pos.z = GND_BOSSROOM_CENTER_Z + 155.0f; + player->actor.world.rot.y = player->actor.shape.rot.y = 0; + player->actor.speedXZ = 0.0f; + pthis->cameraEye.x = GND_BOSSROOM_CENTER_X + 0.0f; + pthis->cameraEye.y = GND_BOSSROOM_CENTER_Y + 37.0f; + pthis->cameraEye.z = GND_BOSSROOM_CENTER_Z + 170.0f; + pthis->cameraAt.x = GND_BOSSROOM_CENTER_X + 0.0f; + pthis->cameraAt.y = GND_BOSSROOM_CENTER_Y + 47.0f; + pthis->cameraAt.z = GND_BOSSROOM_CENTER_Z + 315.0f; + if (pthis->timers[0] == 25) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_DOOR_SHUTTER, + GND_BOSSROOM_CENTER_X + 0.0f, GND_BOSSROOM_CENTER_Y - 97.0f, + GND_BOSSROOM_CENTER_Z + 308.0f, 0, 0, 0, (SHUTTER_PG_BARS << 6)); + } + if (pthis->timers[0] == 21) { + Audio_PlayActorSound2(pthis->actor.child, NA_SE_EV_SPEAR_FENCE); + } + if (pthis->timers[0] == 0) { + pthis->cutsceneState = INTRO_BACK; + pthis->timers[0] = 80; + } + break; + case INTRO_BACK: + if (pthis->timers[0] == 25) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_HORSE_GROAN); + } + if (pthis->timers[0] == 20) { + func_8002DF54(globalCtx, &pthis->actor, 9); + } + if (pthis->timers[0] == 1) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_OPENING_GANON); + } + Math_ApproachF(&pthis->cameraEye.x, GND_BOSSROOM_CENTER_X + 40.0f, 0.05f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraEye.y, GND_BOSSROOM_CENTER_Y + 37.0f, 0.05f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraEye.z, GND_BOSSROOM_CENTER_Z + 80.0f, 0.05f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraAt.x, GND_BOSSROOM_CENTER_X - 100.0f, 0.05f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraAt.y, GND_BOSSROOM_CENTER_Y + 47.0f, 0.05f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraAt.z, GND_BOSSROOM_CENTER_Z + 335.0f, 0.05f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, 0.01f); + if (pthis->timers[0] == 0) { + pthis->cutsceneState = INTRO_REVEAL; + pthis->timers[0] = 50; + pthis->cameraSpeedMod = 0.0f; + } + break; + case INTRO_REVEAL: + Math_ApproachF(&pthis->cameraEye.x, GND_BOSSROOM_CENTER_X + 70.0f, 0.1f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraEye.y, GND_BOSSROOM_CENTER_Y + 7.0f, 0.1f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraEye.z, GND_BOSSROOM_CENTER_Z + 200.0f, 0.1f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraAt.x, GND_BOSSROOM_CENTER_X - 150.0f, 0.1f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraAt.y, GND_BOSSROOM_CENTER_Y + 107.0f, 0.1f, pthis->cameraSpeedMod * 20.0f); + Math_ApproachF(&pthis->cameraAt.z, GND_BOSSROOM_CENTER_Z - 65.0f, 0.1f, pthis->cameraSpeedMod * 40.0f); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, 0.05f); + if (pthis->timers[0] == 5) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_SANDDUST); + } + if (pthis->timers[0] == 0) { + pthis->cutsceneState = INTRO_CUT; + pthis->timers[0] = 50; + pthis->cameraSpeedMod = 0.0f; + } + break; + case INTRO_CUT: + pthis->cutsceneState = INTRO_LAUGH; + pthis->cameraEye.x = GND_BOSSROOM_CENTER_X + 50.0f; + pthis->cameraEye.y = GND_BOSSROOM_CENTER_Y + 17.0f; + pthis->cameraEye.z = GND_BOSSROOM_CENTER_Z + 110.0f; + pthis->cameraAt.x = GND_BOSSROOM_CENTER_X - 150.0f; + pthis->cameraAt.y = GND_BOSSROOM_CENTER_Y + 207.0f; + pthis->cameraAt.z = GND_BOSSROOM_CENTER_Z - 155.0f; + pthis->cameraEyeVel.x = fabsf(pthis->cameraEye.x - (GND_BOSSROOM_CENTER_X + 20.0f)); + pthis->cameraEyeVel.y = fabsf(pthis->cameraEye.y - (GND_BOSSROOM_CENTER_Y + 102.0f)); + pthis->cameraEyeVel.z = fabsf(pthis->cameraEye.z - (GND_BOSSROOM_CENTER_Z + 25.0f)); + pthis->cameraAtVel.x = fabsf(pthis->cameraAt.x - (GND_BOSSROOM_CENTER_X - 150.0f)); + pthis->cameraAtVel.y = fabsf(pthis->cameraAt.y - (GND_BOSSROOM_CENTER_Y + 197.0f)); + pthis->cameraAtVel.z = fabsf(pthis->cameraAt.z - (GND_BOSSROOM_CENTER_Z - 65.0f)); + pthis->timers[0] = 250; + case INTRO_LAUGH: + Math_ApproachF(&pthis->cameraEye.x, GND_BOSSROOM_CENTER_X + 20.0f, 0.05f, + pthis->cameraSpeedMod * pthis->cameraEyeVel.x); + Math_ApproachF(&pthis->cameraEye.y, GND_BOSSROOM_CENTER_Y + 102.0f, 0.05f, + pthis->cameraSpeedMod * pthis->cameraEyeVel.y); + Math_ApproachF(&pthis->cameraEye.z, GND_BOSSROOM_CENTER_Z + 25.0f, 0.05f, + pthis->cameraSpeedMod * pthis->cameraEyeVel.z); + Math_ApproachF(&pthis->cameraAt.x, GND_BOSSROOM_CENTER_X - 150.0f, 0.05f, + pthis->cameraSpeedMod * pthis->cameraAtVel.x); + Math_ApproachF(&pthis->cameraAt.y, GND_BOSSROOM_CENTER_Y + 197.0f, 0.05f, + pthis->cameraSpeedMod * pthis->cameraAtVel.y); + Math_ApproachF(&pthis->cameraAt.z, GND_BOSSROOM_CENTER_Z - 65.0f, 0.05f, + pthis->cameraSpeedMod * pthis->cameraAtVel.z); + Math_ApproachF(&pthis->cameraSpeedMod, 0.01f, 1.0f, 0.001f); + if ((pthis->timers[0] == 245) || (pthis->timers[0] == 3)) { + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &gPhantomHorseRearingAnim, -8.0f); + pthis->bossGndSignal = FHG_REAR; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_HORSE_NEIGH); + if (pthis->timers[0] == 3) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_VOICE); + } + } + if (pthis->timers[0] == 192) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_SANDDUST); + } + if (pthis->timers[0] == 212) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_HORSE_LAND2); + Animation_Change(&pthis->skin.skelAnime, &gPhantomHorseIdleAnim, 0.3f, 0.0f, 5.0f, ANIMMODE_LOOP_INTERP, + -10.0f); + } + if (pthis->timers[0] == 90) { + globalCtx->envCtx.unk_BF = 2; + globalCtx->envCtx.unk_D6 = 0x14; + } + if (pthis->timers[0] == 100) { + pthis->bossGndSignal = FHG_LIGHTNING; + } + if (pthis->timers[0] == 60) { + pthis->bossGndSignal = FHG_RIDE; + } + if (pthis->timers[0] == 130) { + Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5000FF); + } + if (pthis->timers[0] == 30) { + bossGnd->work[GND_EYE_STATE] = GND_EYESTATE_BRIGHTEN; + } + if (pthis->timers[0] == 35) { + func_80078914(&audioVec, NA_SE_EN_FANTOM_EYE); + } + if (pthis->timers[0] == 130) { + bossGnd->work[GND_EYE_STATE] = GND_EYESTATE_FADE; + func_80078914(&audioVec, NA_SE_EN_FANTOM_ST_LAUGH); + } + if (pthis->timers[0] == 20) { + Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + } + if (pthis->timers[0] == 2) { + pthis->cameraSpeedMod = 0.0f; + pthis->cutsceneState = INTRO_TITLE; + pthis->cameraEyeVel.x = fabsf(pthis->cameraEye.x - (GND_BOSSROOM_CENTER_X + 180.0f)); + pthis->cameraEyeVel.y = fabsf(pthis->cameraEye.y - (GND_BOSSROOM_CENTER_Y + 7.0f)); + pthis->cameraEyeVel.z = fabsf(pthis->cameraEye.z - (GND_BOSSROOM_CENTER_Z + 140.0f)); + pthis->timers[0] = 100; + pthis->timers[1] = 34; + pthis->cameraAtVel.x = fabsf(pthis->cameraAt.x - pthis->actor.world.pos.x); + pthis->cameraAtVel.y = fabsf(pthis->cameraAt.y - ((pthis->actor.world.pos.y + 70.0f) - 20.0f)); + pthis->cameraAtVel.z = fabsf(pthis->cameraAt.z - pthis->actor.world.pos.z); + } + break; + case INTRO_TITLE: + if (pthis->timers[1] == 1) { + Animation_Change(&pthis->skin.skelAnime, &gPhantomHorseIdleAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gPhantomHorseIdleAnim), ANIMMODE_LOOP_INTERP, -3.0f); + } + Math_ApproachF(&pthis->cameraEye.x, GND_BOSSROOM_CENTER_X + 180.0f, 0.1f, + pthis->cameraSpeedMod * pthis->cameraEyeVel.x); + Math_ApproachF(&pthis->cameraEye.y, GND_BOSSROOM_CENTER_Y + 7.0f, 0.1f, + pthis->cameraSpeedMod * pthis->cameraEyeVel.y); + Math_ApproachF(&pthis->cameraEye.z, pthis->cameraPanZ + (GND_BOSSROOM_CENTER_Z + 140.0f), 0.1f, + pthis->cameraSpeedMod * pthis->cameraEyeVel.z); + Math_ApproachF(&pthis->cameraPanZ, -100.0f, 0.1f, 1.0f); + Math_ApproachF(&pthis->cameraAt.x, pthis->actor.world.pos.x, 0.1f, pthis->cameraSpeedMod * 10.0f); + Math_ApproachF(&pthis->cameraAt.y, (pthis->actor.world.pos.y + 70.0f) - 20.0f, 0.1f, + pthis->cameraSpeedMod * 10.0f); + Math_ApproachF(&pthis->cameraAt.z, pthis->actor.world.pos.z, 0.1f, pthis->cameraSpeedMod * 10.0f); + Math_ApproachF(&pthis->actor.world.pos.y, 60.0f, 0.1f, 2.0f); + pthis->actor.world.pos.y += 2.0f * Math_SinS(pthis->gallopTimer * 0x5DC); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, 0.05f); + if (pthis->timers[0] == 75) { + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, + SEGMENTED_TO_VIRTUAL(gPhantomGanonTitleCardTex), 160, 180, 128, 40); + } + if (pthis->timers[0] == 0) { + pthis->cutsceneState = INTRO_RETREAT; + pthis->timers[0] = 200; + pthis->timers[1] = 23; + pthis->cameraSpeedMod = 0.0f; + Animation_Change(&pthis->skin.skelAnime, &gPhantomHorseLeapAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gPhantomHorseLeapAnim), ANIMMODE_ONCE_INTERP, -4.0f); + pthis->bossGndSignal = FHG_SPUR; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_VOICE); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_HORSE_NEIGH); + } + break; + case INTRO_RETREAT: + if (pthis->timers[1] == 1) { + Animation_Change(&pthis->skin.skelAnime, &gPhantomHorseLandAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gPhantomHorseLandAnim), ANIMMODE_ONCE_INTERP, -3.0f); + pthis->bossGndSignal = FHG_FINISH; + } + if (pthis->timers[0] == 170) { + func_8002DF54(globalCtx, &pthis->actor, 8); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_MASIC2); + } + Math_ApproachF(&pthis->cameraEye.z, pthis->cameraPanZ + (GND_BOSSROOM_CENTER_Z + 100.0f), 0.1f, + pthis->cameraSpeedMod * 1.5f); + Math_ApproachF(&pthis->cameraPanZ, -100.0f, 0.1f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.z, GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f, 1.0f, + pthis->cameraSpeedMod * 10.0f); + Math_ApproachF(&pthis->cameraSpeedMod, 1.0f, 1.0f, 0.05f); + if ((fabsf(pthis->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f)) < 300.0f) && + !pthis->spawnedWarp) { + pthis->spawnedWarp = true; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + GND_BOSSROOM_CENTER_X + 0.0f, pthis->actor.world.pos.y + 50.0f, + GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f, 0, pthis->actor.shape.rot.y, 0, + FHGFIRE_WARP_RETREAT); + pthis->fhgFireKillWarp = true; + } + Math_ApproachF(&pthis->cameraAt.x, pthis->actor.world.pos.x, 0.2f, 50.0f); + Math_ApproachF(&pthis->cameraAt.z, pthis->actor.world.pos.z, 0.2f, 50.0f); + osSyncPrintf("TIME %d-------------------------------------------------\n", pthis->timers[0]); + if (fabsf(pthis->actor.world.pos.z - (GND_BOSSROOM_CENTER_Z + 400.0f - 0.5f)) < 1.0f) { + globalCtx->envCtx.unk_BF = 0; + globalCtx->envCtx.unk_D6 = 0x14; + pthis->cutsceneState = INTRO_FINISH; + Animation_MorphToLoop(&pthis->skin.skelAnime, &gPhantomHorseRunningAnim, -3.0f); + pthis->bossGndSignal = FHG_START_FIGHT; + pthis->timers[1] = 75; + pthis->timers[0] = 140; + } + break; + case INTRO_FINISH: + EnfHG_Retreat(pthis, globalCtx); + Math_ApproachF(&pthis->cameraEye.z, pthis->cameraPanZ + (GND_BOSSROOM_CENTER_Z + 100.0f), 0.1f, + pthis->cameraSpeedMod * 1.5f); + Math_ApproachF(&pthis->cameraPanZ, -100.0f, 0.1f, 1.0f); + Math_ApproachF(&pthis->cameraAt.y, (pthis->actor.world.pos.y + 70.0f) - 20.0f, 0.1f, + pthis->cameraSpeedMod * 10.0f); + if (pthis->timers[1] == 0) { + Camera* camera = Gameplay_GetCamera(globalCtx, 0); + + camera->eye = pthis->cameraEye; + camera->eyeNext = pthis->cameraEye; + camera->at = pthis->cameraAt; + func_800C08AC(globalCtx, pthis->cutsceneCamera, 0); + pthis->cutsceneCamera = 0; + func_80064534(globalCtx, &globalCtx->csCtx); + func_8002DF54(globalCtx, &pthis->actor, 7); + pthis->actionFunc = EnfHG_Retreat; + } + break; + } + if (pthis->cutsceneCamera != 0) { + Gameplay_CameraSetAtEye(globalCtx, pthis->cutsceneCamera, &pthis->cameraAt, &pthis->cameraEye); + } +} + +void EnfHG_SetupApproach(EnfHG* pthis, GlobalContext* globalCtx, s16 paintingIndex) { + s16 oppositeIndex[6] = { 3, 4, 5, 0, 1, 2 }; + + Animation_MorphToLoop(&pthis->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); + pthis->actionFunc = EnfHG_Approach; + pthis->curPainting = paintingIndex; + pthis->targetPainting = oppositeIndex[pthis->curPainting]; + + osSyncPrintf("KABE NO 1 = %d\n", pthis->curPainting); + osSyncPrintf("KABE NO 2 = %d\n", pthis->targetPainting); + + pthis->actor.world.pos.x = (1.3f * sPaintings[pthis->curPainting].pos.x) + (GND_BOSSROOM_CENTER_X - 4.0f); + pthis->actor.world.pos.y = sPaintings[pthis->curPainting].pos.y + (GND_BOSSROOM_CENTER_Y + 153.0f); + pthis->actor.world.pos.z = (1.3f * sPaintings[pthis->curPainting].pos.z) - -(GND_BOSSROOM_CENTER_Z - 10.0f); + pthis->actor.world.rot.y = sPaintings[pthis->curPainting].yRot; + + osSyncPrintf("XP1 = %f\n", pthis->actor.world.pos.x); + osSyncPrintf("ZP1 = %f\n", pthis->actor.world.pos.z); + + pthis->inPaintingPos.x = (sPaintings[pthis->targetPainting].pos.x * 1.3f) + (GND_BOSSROOM_CENTER_X - 4.0f); + pthis->inPaintingPos.y = sPaintings[pthis->targetPainting].pos.y + (GND_BOSSROOM_CENTER_Y + 33.0f); + pthis->inPaintingPos.z = (sPaintings[pthis->targetPainting].pos.z * 1.3f) - -(GND_BOSSROOM_CENTER_Z - 10.0f); + pthis->inPaintingVelX = (fabsf(pthis->inPaintingPos.x - pthis->actor.world.pos.x) * 2) * 0.01f; + + if (pthis->inPaintingVelX < 1.0f) { + pthis->inPaintingVelX = 1.0f; + } + pthis->inPaintingVelZ = (fabsf(pthis->inPaintingPos.z - pthis->actor.world.pos.z) * 2) * 0.01f; + if (pthis->inPaintingVelZ < 1.0f) { + pthis->inPaintingVelZ = 1.0f; + } + + pthis->timers[0] = 100; + pthis->actor.scale.x = 0.002f; + pthis->actor.scale.y = 0.002f; + pthis->actor.scale.z = 0.001f; + pthis->approachRate = 0.0f; + + pthis->warpColorFilterR = globalCtx->lightCtx.fogColor[0]; + pthis->warpColorFilterG = globalCtx->lightCtx.fogColor[1]; + pthis->warpColorFilterB = globalCtx->lightCtx.fogColor[2]; + pthis->warpColorFilterUnk1 = 0.0f; + pthis->warpColorFilterUnk2 = 0.0f; + pthis->turnRot = 0; + pthis->turnTarget = 0; + pthis->spawnedWarp = false; +} + +void EnfHG_Approach(EnfHG* pthis, GlobalContext* globalCtx) { + osSyncPrintf("STANDBY !!\n"); + osSyncPrintf("XP2 = %f\n", pthis->actor.world.pos.x); + osSyncPrintf("ZP2 = %f\n", pthis->actor.world.pos.z); + if (pthis->actor.params == GND_REAL_BOSS) { + pthis->hoofSfxPos.x = pthis->actor.projectedPos.x / (pthis->actor.scale.x * 100.0f); + pthis->hoofSfxPos.y = pthis->actor.projectedPos.y / (pthis->actor.scale.x * 100.0f); + pthis->hoofSfxPos.z = pthis->actor.projectedPos.z / (pthis->actor.scale.x * 100.0f); + if ((pthis->gallopTimer % 8) == 0) { + func_80078914(&pthis->hoofSfxPos, NA_SE_EV_HORSE_RUN); + } + } + SkelAnime_Update(&pthis->skin.skelAnime); + Math_ApproachF(&pthis->actor.scale.x, 0.011499999f, 1.0f, pthis->approachRate); + Math_ApproachF(&pthis->approachRate, 0.0002f, 1.0f, 0.0000015f); + Math_ApproachF(&pthis->actor.world.pos.y, 60.0f, 0.1f, 1.0f); + pthis->actor.scale.y = pthis->actor.scale.x; + if (pthis->timers[0] == 0) { + osSyncPrintf("arg_data ------------------------------------>%d\n", pthis->actor.params); + if (pthis->actor.params != GND_REAL_BOSS) { + pthis->timers[0] = 140; + pthis->actionFunc = EnfHG_Retreat; + Animation_MorphToLoop(&pthis->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); + pthis->turnTarget = -0x8000; + } else { + pthis->actionFunc = EnfHG_Attack; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_GANON_HORSE_NEIGH); + pthis->timers[0] = 40; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + pthis->actor.world.pos.x, pthis->actor.world.pos.y + 50.0f, pthis->actor.world.pos.z, 0, + pthis->actor.shape.rot.y + 0x8000, 0, FHGFIRE_WARP_EMERGE); + pthis->fhgFireKillWarp = false; + } + } +} + +void EnfHG_Attack(EnfHG* pthis, GlobalContext* globalCtx) { + osSyncPrintf("KABE OUT !!\n"); + pthis->bossGndInPainting = false; + SkelAnime_Update(&pthis->skin.skelAnime); + if (pthis->timers[0] != 0) { + Math_ApproachF(&pthis->actor.scale.z, 0.011499999f, 1.0f, 0.0002f); + if (pthis->timers[0] == 1) { + pthis->bossGndSignal = FHG_RAISE_SPEAR; + pthis->timers[1] = 50; + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &gPhantomHorseLeapAnim, 0.0f); + } + Math_ApproachF(&pthis->warpColorFilterR, 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterG, 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterB, 255.0f, 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterUnk1, -60.0f, 1.0f, 5.0f); + } else { + Math_ApproachF(&pthis->warpColorFilterR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterG, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterB, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterUnk1, 0.0f, 1.0f, 5.0f); + if (pthis->timers[1] == 29) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_MASIC2); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_VOICE); + } + if (pthis->hitTimer == 0) { + if (pthis->timers[1] == 24) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, + pthis->actor.world.pos.x, (pthis->actor.world.pos.y + 100.0f) + 25.0f, + pthis->actor.world.pos.z, 0, 0, 0, FHGFIRE_LIGHTNING_STRIKE); + } + if (pthis->timers[1] == 45) { + Animation_MorphToLoop(&pthis->skin.skelAnime, &gPhantomHorseAirAnim, 0.0f); + } + if (pthis->timers[1] == 38) { + pthis->bossGndSignal = FHG_LIGHTNING; + } + if (pthis->timers[1] == 16) { + Animation_MorphToPlayOnce(&pthis->skin.skelAnime, &gPhantomHorseLandAnim, 0.0f); + pthis->bossGndSignal = FHG_RESET; + } + } + Math_ApproachF(&pthis->actor.scale.z, 0.011499999f, 1.0f, 0.002f); + Math_ApproachF(&pthis->actor.world.pos.x, pthis->inPaintingPos.x, 1.0f, pthis->inPaintingVelX); + Math_ApproachF(&pthis->actor.world.pos.y, 60.0f, 0.1f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->inPaintingPos.z, 1.0f, pthis->inPaintingVelZ); + } + if (pthis->hitTimer == 20) { + pthis->actionFunc = EnfHG_Damage; + pthis->spawnedWarp = false; + Animation_Change(&pthis->skin.skelAnime, &gPhantomHorseLandAnim, -1.0f, 0.0f, + Animation_GetLastFrame(&gPhantomHorseLandAnim), ANIMMODE_ONCE, -5.0f); + pthis->timers[0] = 10; + pthis->bossGndSignal = FHG_RESET; + pthis->damageSpeedMod = 1.0f; + } else { + f32 dx = pthis->actor.world.pos.x - pthis->inPaintingPos.x; + f32 dz = pthis->actor.world.pos.z - pthis->inPaintingPos.z; + f32 dxz = sqrtf(SQ(dx) + SQ(dz)); + + if (dxz < 350.0f) { + pthis->bossGndInPainting = true; + } + if ((dxz < 300.0f) && !pthis->spawnedWarp) { + pthis->spawnedWarp = true; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, pthis->inPaintingPos.x, + pthis->actor.world.pos.y + 50.0f, pthis->inPaintingPos.z, 0, pthis->actor.shape.rot.y, 0, + FHGFIRE_WARP_RETREAT); + pthis->fhgFireKillWarp = true; + } + osSyncPrintf("SPD X %f\n", pthis->inPaintingVelX); + osSyncPrintf("SPD Z %f\n", pthis->inPaintingVelZ); + osSyncPrintf("X=%f\n", dx); + osSyncPrintf("Z=%f\n", dz); + if (dxz == 0.0f) { + pthis->timers[0] = 140; + pthis->actionFunc = EnfHG_Retreat; + Animation_MorphToLoop(&pthis->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); + pthis->bossGndSignal = FHG_RIDE; + } + } +} + +void EnfHG_Damage(EnfHG* pthis, GlobalContext* globalCtx) { + f32 dx; + f32 dz; + f32 dxz2; + + osSyncPrintf("REVISE !!\n"); + SkelAnime_Update(&pthis->skin.skelAnime); + Math_ApproachF(&pthis->warpColorFilterR, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterG, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterB, globalCtx->lightCtx.fogColor[0], 1.0f, 10.0f); + Math_ApproachF(&pthis->warpColorFilterUnk1, 0.0f, 1.0f, 5.0f); + Math_ApproachF(&pthis->actor.scale.z, 0.011499999f, 1.0f, 0.002f); + if (pthis->timers[0] != 0) { + Math_ApproachZeroF(&pthis->damageSpeedMod, 1.0f, 0.1f); + if (pthis->timers[0] == 1) { + pthis->targetPainting = pthis->curPainting; + pthis->inPaintingPos.x = (sPaintings[pthis->targetPainting].pos.x * 1.3f) + (GND_BOSSROOM_CENTER_X - 4.0f); + pthis->inPaintingPos.y = sPaintings[pthis->targetPainting].pos.y; + pthis->inPaintingPos.z = (sPaintings[pthis->targetPainting].pos.z * 1.3f) - -(GND_BOSSROOM_CENTER_Z - 10.0f); + } + } else { + Math_ApproachF(&pthis->damageSpeedMod, 1.0f, 1.0f, 0.1f); + } + Math_ApproachF(&pthis->actor.world.pos.x, pthis->inPaintingPos.x, 1.0f, pthis->damageSpeedMod * pthis->inPaintingVelX); + Math_ApproachF(&pthis->actor.world.pos.y, 60.0f, 0.1f, 1.0f); + Math_ApproachF(&pthis->actor.world.pos.z, pthis->inPaintingPos.z, 1.0f, pthis->damageSpeedMod * pthis->inPaintingVelZ); + dx = pthis->actor.world.pos.x - pthis->inPaintingPos.x; + dz = pthis->actor.world.pos.z - pthis->inPaintingPos.z; + dxz2 = sqrtf(SQ(dx) + SQ(dz)); + if ((dxz2 < 300.0f) && (!pthis->spawnedWarp)) { + pthis->spawnedWarp = true; + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_FHG_FIRE, pthis->inPaintingPos.x, + pthis->actor.world.pos.y + 50.0f, pthis->inPaintingPos.z, 0, pthis->actor.shape.rot.y + 0x8000, + 0, FHGFIRE_WARP_RETREAT); + } + if (dxz2 == 0.0f) { + BossGanondrof* bossGnd = (BossGanondrof*)pthis->actor.parent; + + pthis->timers[0] = 140; + pthis->actionFunc = EnfHG_Retreat; + Animation_MorphToLoop(&pthis->skin.skelAnime, &gPhantomHorseRunningAnim, 0.0f); + if (bossGnd->actor.colChkInfo.health > 24) { + pthis->bossGndSignal = FHG_RIDE; + } else { + bossGnd->flyMode = GND_FLY_NEUTRAL; + } + pthis->turnTarget = -0x8000; + } +} + +void EnfHG_Retreat(EnfHG* pthis, GlobalContext* globalCtx) { + osSyncPrintf("KABE IN !!\n"); + if (pthis->turnTarget != 0) { + Math_ApproachS(&pthis->turnRot, pthis->turnTarget, 5, 2000); + } + if (pthis->actor.params == GND_REAL_BOSS) { + pthis->hoofSfxPos.x = pthis->actor.projectedPos.x / (pthis->actor.scale.x * 100.0f); + pthis->hoofSfxPos.y = pthis->actor.projectedPos.y / (pthis->actor.scale.x * 100.0f); + pthis->hoofSfxPos.z = pthis->actor.projectedPos.z / (pthis->actor.scale.x * 100.0f); + if ((pthis->gallopTimer % 8) == 0) { + func_80078914(&pthis->hoofSfxPos, NA_SE_EV_HORSE_RUN); + } + } + SkelAnime_Update(&pthis->skin.skelAnime); + Math_ApproachF(&pthis->actor.scale.z, 0.001f, 1.0f, 0.001f); + Math_ApproachF(&pthis->actor.scale.x, 0.002f, 0.05f, 0.0001f); + Math_ApproachF(&pthis->actor.world.pos.y, 200.0f, 0.05f, 1.0f); + pthis->actor.scale.y = pthis->actor.scale.x; + if ((pthis->timers[0] == 80) && (pthis->actor.params == GND_REAL_BOSS)) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_FANTOM_LAUGH); + } + if (pthis->timers[0] == 0) { + BossGanondrof* bossGnd = (BossGanondrof*)pthis->actor.parent; + s16 paintingIdxReal; + s16 paintingIdxFake; + + if (pthis->actor.params != GND_REAL_BOSS) { + pthis->killActor = true; + bossGnd->killActor = true; + } else if (bossGnd->flyMode != GND_FLY_PAINTING) { + pthis->actionFunc = EnfHG_Done; + pthis->actor.draw = NULL; + } else { + paintingIdxReal = Rand_ZeroOne() * 5.99f; + EnfHG_SetupApproach(pthis, globalCtx, paintingIdxReal); + do { + paintingIdxFake = Rand_ZeroOne() * 5.99f; + } while (paintingIdxFake == paintingIdxReal); + osSyncPrintf("ac1 = %x `````````````````````````````````````````````````\n", + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_BOSS_GANONDROF, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, + 0, 0, 0, paintingIdxFake + GND_FAKE_BOSS)); + } + } +} + +void EnfHG_Done(EnfHG* pthis, GlobalContext* globalCtx) { + pthis->bossGndInPainting = false; +} + +void EnfHG_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnfHG* pthis = (EnfHG*)thisx; + u8 i; + + if (pthis->killActor) { + Actor_Kill(&pthis->actor); + return; + } + pthis->gallopTimer++; + pthis->bossGndInPainting = true; + for (i = 0; i < 5; i++) { + if (pthis->timers[i] != 0) { + pthis->timers[i]--; + } + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->hitTimer != 0) { + pthis->hitTimer--; + } + + pthis->actor.focus.pos = pthis->actor.world.pos; + pthis->actor.focus.pos.y += 70.0f; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; + + pthis->actor.shape.yOffset = Math_SinS(pthis->hitTimer * 0x9000) * 700.0f * (pthis->hitTimer / 20.0f); + pthis->actor.shape.rot.z = (s16)(Math_SinS(pthis->hitTimer * 0x7000) * 1500.0f) * (pthis->hitTimer / 20.0f); +} + +void EnfHG_Noop(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* skin) { +} + +void EnfHG_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnfHG* pthis = (EnfHG*)thisx; + BossGanondrof* bossGnd = (BossGanondrof*)pthis->actor.parent; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg.c", 2439); + func_80093D18(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = ((bossGnd->work[GND_INVINC_TIMER] & 4) && (bossGnd->flyMode == GND_FLY_PAINTING)) + ? Gfx_SetFog(POLY_OPA_DISP, 255, 50, 0, 0, 900, 1099) + : Gfx_SetFog(POLY_OPA_DISP, (u32)pthis->warpColorFilterR, (u32)pthis->warpColorFilterG, + (u32)pthis->warpColorFilterB, 0, (s32)pthis->warpColorFilterUnk1 + 995, + (s32)pthis->warpColorFilterUnk2 + 1000); + func_800A6330(&pthis->actor, globalCtx, &pthis->skin, EnfHG_Noop, 0x23); + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_fhg.c", 2480); +} diff --git a/src/overlays/actors/ovl_End_Title/z_end_title.c b/src/overlays/actors/ovl_End_Title/z_end_title.cpp similarity index 80% rename from src/overlays/actors/ovl_End_Title/z_end_title.c rename to src/overlays/actors/ovl_End_Title/z_end_title.cpp index 0fd6d1959..d6fbae678 100644 --- a/src/overlays/actors/ovl_End_Title/z_end_title.c +++ b/src/overlays/actors/ovl_End_Title/z_end_title.cpp @@ -19,7 +19,7 @@ void EndTitle_Update(Actor* thisx, GlobalContext* globalCtx); void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx); void EndTitle_DrawNintendoLogo(Actor* thisx, GlobalContext* globalCtx); -const ActorInit End_Title_InitVars = { +ActorInit End_Title_InitVars = { ACTOR_END_TITLE, ACTORCAT_ITEMACTION, FLAGS, @@ -31,16 +31,16 @@ const ActorInit End_Title_InitVars = { (ActorFunc)EndTitle_DrawFull, }; -#include "overlays/ovl_End_Title/ovl_End_Title.c" +#include "overlays/ovl_End_Title/ovl_End_Title.cpp" void EndTitle_Init(Actor* thisx, GlobalContext* globalCtx) { - EndTitle* this = (EndTitle*)thisx; + EndTitle* pthis = (EndTitle*)thisx; - this->endAlpha = 0; - this->tlozAlpha = 0; - this->ootAlpha = 0; - if (this->actor.params == 1) { - this->actor.draw = EndTitle_DrawNintendoLogo; + pthis->endAlpha = 0; + pthis->tlozAlpha = 0; + pthis->ootAlpha = 0; + if (pthis->actor.params == 1) { + pthis->actor.draw = EndTitle_DrawNintendoLogo; } } @@ -53,7 +53,7 @@ void EndTitle_Update(Actor* thisx, GlobalContext* globalCtx) { // Used in the castle courtyard void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) { MtxF* mf; - EndTitle* this = (EndTitle*)thisx; + EndTitle* pthis = (EndTitle*)thisx; s32 frameCount = globalCtx->csCtx.frames; Player* player = GET_PLAYER(globalCtx); @@ -77,14 +77,14 @@ void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_end_title.c", 419); // Draw title cards on the screen - if ((frameCount > 890) && (this->endAlpha < 200)) { - this->endAlpha += 7; + if ((frameCount > 890) && (pthis->endAlpha < 200)) { + pthis->endAlpha += 7; } - if ((frameCount > 810) && (this->tlozAlpha < 200)) { - this->tlozAlpha += 15; + if ((frameCount > 810) && (pthis->tlozAlpha < 200)) { + pthis->tlozAlpha += 15; } - if ((frameCount > 850) && (this->ootAlpha < 200)) { - this->ootAlpha += 15; + if ((frameCount > 850) && (pthis->ootAlpha < 200)) { + pthis->ootAlpha += 15; } OVERLAY_DISP = func_80093F34(OVERLAY_DISP); @@ -95,18 +95,18 @@ void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) { G_TEXTURE_ENABLE | G_CULL_BACK | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); - gDPSetPrimColor(OVERLAY_DISP++, 0x00, 0x80, 0, 0, 0, this->endAlpha); + gDPSetPrimColor(OVERLAY_DISP++, 0x00, 0x80, 0, 0, 0, pthis->endAlpha); gDPLoadTextureTile(OVERLAY_DISP++, sTheEndTex, G_IM_FMT_IA, G_IM_SIZ_8b, 80, 24, 0, 0, 80, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 0, 0, 0, 0); gSPTextureRectangle(OVERLAY_DISP++, 120 << 2, 90 << 2, 200 << 2, 113 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0x00, 0x80, 0, 0, 0, this->tlozAlpha); + gDPSetPrimColor(OVERLAY_DISP++, 0x00, 0x80, 0, 0, 0, pthis->tlozAlpha); gDPLoadTextureTile(OVERLAY_DISP++, sTheLegendOfZeldaTex, G_IM_FMT_IA, G_IM_SIZ_8b, 120, 24, 0, 0, 120, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 0, 0, 0, 0); gSPTextureRectangle(OVERLAY_DISP++, 100 << 2, 160 << 2, 220 << 2, 183 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0x00, 0x80, 0, 0, 0, this->ootAlpha); + gDPSetPrimColor(OVERLAY_DISP++, 0x00, 0x80, 0, 0, 0, pthis->ootAlpha); gDPLoadTextureTile(OVERLAY_DISP++, sOcarinaOfTimeTex, G_IM_FMT_IA, G_IM_SIZ_8b, 112, 16, 0, 0, 112, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 0, 0, 0, 0); gSPTextureRectangle(OVERLAY_DISP++, 104 << 2, 177 << 2, 216 << 2, 192 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, @@ -117,18 +117,18 @@ void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) { // Used in the Temple of Time void EndTitle_DrawNintendoLogo(Actor* thisx, GlobalContext* globalCtx) { - EndTitle* this = (EndTitle*)thisx; + EndTitle* pthis = (EndTitle*)thisx; s32 pad; s32 frames = globalCtx->csCtx.frames; - if ((frames >= 1101) && (this->endAlpha < 255)) { - this->endAlpha += 3; + if ((frames >= 1101) && (pthis->endAlpha < 255)) { + pthis->endAlpha += 3; } OPEN_DISPS(globalCtx->state.gfxCtx, "../z_end_title.c", 594); OVERLAY_DISP = func_80093F34(OVERLAY_DISP); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0x80, 0, 0, 0, this->endAlpha); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0x80, 0, 0, 0, pthis->endAlpha); gSPDisplayList(OVERLAY_DISP++, sPresentedByNintendoDL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_end_title.c", 600); diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.cpp similarity index 77% rename from src/overlays/actors/ovl_Fishing/z_fishing.c rename to src/overlays/actors/ovl_Fishing/z_fishing.cpp index 3efaa3094..68cbf6a2b 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.cpp @@ -144,7 +144,7 @@ typedef struct { #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 -const ActorInit Fishing_InitVars = { +ActorInit Fishing_InitVars = { ACTOR_FISHING, ACTORCAT_NPC, FLAGS, @@ -768,7 +768,7 @@ static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { { FS_PROP_INIT_STOP, { 0 } }, }; -void Fishing_InitPondProps(Fishing* this, GlobalContext* globalCtx) { +void Fishing_InitPondProps(Fishing* pthis, GlobalContext* globalCtx) { FishingProp* prop = &sPondProps[0]; Vec3f colliderPos; s16 i; @@ -840,7 +840,7 @@ static InitChainEntry sInitChain[] = { void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; u16 fishCount; s16 i; @@ -855,14 +855,14 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { if (thisx->params < 100) { D_80B7E074 = 0; - sFishingMain = this; + sFishingMain = pthis; Collider_InitJntSph(globalCtx, &sFishingMain->collider); Collider_SetJntSph(globalCtx, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); thisx->params = 1; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); - Animation_MorphToLoop(&this->skelAnime, &gFishingOwnerAnim, 0.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); + Animation_MorphToLoop(&pthis->skelAnime, &gFishingOwnerAnim, 0.0f); thisx->update = Fishing_UpdateOwner; thisx->draw = Fishing_DrawOwner; @@ -973,7 +973,7 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } } - Fishing_InitPondProps(this, globalCtx); + Fishing_InitPondProps(pthis, globalCtx); Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_KANBAN, 53.0f, -17.0f, 982.0f, 0, 0, 0, ENKANBAN_FISHING); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); @@ -994,41 +994,41 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } } else { if ((thisx->params < 115) || (thisx->params == 200)) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); - Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); + Animation_MorphToLoop(&pthis->skelAnime, &gFishingFishAnim, 0.0f); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, 0); - Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, 0); + Animation_MorphToLoop(&pthis->skelAnime, &gFishingLoachAnim, 0.0f); } - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); if (thisx->params == 200) { - this->unk_158 = 100; + pthis->unk_158 = 100; Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); thisx->targetMode = 0; thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); } else { - this->unk_158 = 10; - this->unk_15A = 10; + pthis->unk_158 = 10; + pthis->unk_15A = 10; - this->unk_150 = sFishInits[thisx->params - 100].unk_00; - this->unk_1A8 = sFishInits[thisx->params - 100].unk_0C; - this->unk_1AC = sFishInits[thisx->params - 100].unk_08; + pthis->unk_150 = sFishInits[thisx->params - 100].unk_00; + pthis->unk_1A8 = sFishInits[thisx->params - 100].unk_0C; + pthis->unk_1AC = sFishInits[thisx->params - 100].unk_08; - this->unk_1AC += Rand_ZeroFloat(4.99999f); + pthis->unk_1AC += Rand_ZeroFloat(4.99999f); - if ((this->unk_1AC >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { - this->unk_1AC += Rand_ZeroFloat(7.99999f); + if ((pthis->unk_1AC >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { + pthis->unk_1AC += Rand_ZeroFloat(7.99999f); } if (KREG(6) != 0) { - this->unk_1AC = KREG(6) + 80.0f; + pthis->unk_1AC = KREG(6) + 80.0f; } if (sLinkAge == 1) { - this->unk_1AC *= 0.73f; + pthis->unk_1AC *= 0.73f; } } } @@ -1036,14 +1036,14 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { void Fishing_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; - SkelAnime_Free(&this->skelAnime, globalCtx); + SkelAnime_Free(&pthis->skelAnime, globalCtx); if (thisx->params == 200) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); } else if (thisx->params == 1) { - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } } @@ -1102,7 +1102,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.3f) { Vec3f pos = effect->pos; pos.y = rippleY; - Fishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 20.0f, 60.0f, 150, 90); + Fishing_SpawnRipple(NULL, (FishingEffect*)globalCtx->specialEffects, &pos, 20.0f, 60.0f, 150, 90); } } } else if (effect->type == FS_EFF_DUST_SPLASH) { @@ -1116,7 +1116,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.5f) { Vec3f pos = effect->pos; pos.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 40.0f, 110.0f, 150, 90); + Fishing_SpawnRipple(NULL, (FishingEffect*)globalCtx->specialEffects, &pos, 40.0f, 110.0f, 150, 90); } } } else if (effect->type == FS_EFF_RAIN_DROP) { @@ -1168,7 +1168,7 @@ void Fishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { if ((effect->timer % 16) == 0) { Vec3f pos = effect->pos; pos.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 30.0f, 300.0f, 150, 90); + Fishing_SpawnRipple(NULL, (FishingEffect*)globalCtx->specialEffects, &pos, 30.0f, 300.0f, 150, 90); } if (effect->unk_2C >= 0) { @@ -1658,7 +1658,7 @@ void Fishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, u Matrix_Push(); if (D_80B7A690 != 0) { - FishingEffect* effect = globalCtx->specialEffects; + FishingEffect* effect = (FishingEffect*)globalCtx->specialEffects; MtxF mf; Matrix_MultVec3f(&sZeroVec, &effect->pos); @@ -2114,7 +2114,7 @@ void Fishing_DrawRod(GlobalContext* globalCtx) { static Vec3f D_80B7AF94 = { 0.0f, 0.0f, 0.0f }; -void Fishing_UpdateLure(Fishing* this, GlobalContext* globalCtx) { +void Fishing_UpdateLure(Fishing* pthis, GlobalContext* globalCtx) { f32 spE4; f32 spE0; s16 phi_v0; @@ -2299,15 +2299,15 @@ void Fishing_UpdateLure(Fishing* this, GlobalContext* globalCtx) { if (spC8 > SQ(920.0f)) { if ((KREG(56) != 0) || (sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { - sp80 = this->actor.world.pos; - this->actor.prevPos = this->actor.world.pos = sLurePos; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x43); - this->actor.world.pos = sp80; + sp80 = pthis->actor.world.pos; + pthis->actor.prevPos = pthis->actor.world.pos = sLurePos; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 15.0f, 30.0f, 30.0f, 0x43); + pthis->actor.world.pos = sp80; - if (this->actor.bgCheckFlags & 0x10) { + if (pthis->actor.bgCheckFlags & 0x10) { D_80B7E0E8.y = -0.5f; } - if (this->actor.bgCheckFlags & 8) { + if (pthis->actor.bgCheckFlags & 8) { if (D_80B7E0E8.y > 0.0f) { D_80B7E0E8.y = 0.0f; } @@ -2362,13 +2362,13 @@ void Fishing_UpdateLure(Fishing* this, GlobalContext* globalCtx) { spA8.x += (sp9C.x * 3.0f); spA8.y = WATER_SURFACE_Y(globalCtx); spA8.z += (sp9C.z * 3.0f); - Fishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &spA8, &sp9C, + Fishing_SpawnDustSplash(NULL, (FishingEffect*)globalCtx->specialEffects, &spA8, &sp9C, Rand_ZeroFloat(0.02f) + 0.025f); } spA8 = sLurePos; spA8.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 100.0f, 800.0f, 150, 90); + Fishing_SpawnRipple(NULL, (FishingEffect*)globalCtx->specialEffects, &spA8, 100.0f, 800.0f, 150, 90); } } else { Math_ApproachZeroF(&D_80B7E148, 1.0f, 0.05f); @@ -2549,18 +2549,18 @@ void Fishing_UpdateLure(Fishing* this, GlobalContext* globalCtx) { } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { if (D_80B7E0B6 == 2) { - sp58 = this->actor.world.pos; - this->actor.prevPos = this->actor.world.pos = sLurePos; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); - this->actor.world.pos = sp58; + sp58 = pthis->actor.world.pos; + pthis->actor.prevPos = pthis->actor.world.pos = sLurePos; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 15.0f, 30.0f, 30.0f, 0x44); + pthis->actor.world.pos = sp58; D_80B7E128.y += -0.5f; if (D_80B7E128.y < -1.0f) { D_80B7E128.y = -1.0f; } - if (sLurePos.y < (this->actor.floorHeight + 5.0f)) { - sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y = this->actor.floorHeight + 5.0f; + if (sLurePos.y < (pthis->actor.floorHeight + 5.0f)) { + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y = pthis->actor.floorHeight + 5.0f; D_80B7E128.y = 0.0f; } else { D_80B7E120 = 1; @@ -2631,14 +2631,14 @@ void Fishing_UpdateLure(Fishing* this, GlobalContext* globalCtx) { if ((D_80B7E0AE & phi_v0) == 0) { spA8 = sLurePos; spA8.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); + Fishing_SpawnRipple(NULL, (FishingEffect*)globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); } } break; case 4: - if (this->unk_157 != 0) { - this->unk_157--; + if (pthis->unk_157 != 0) { + pthis->unk_157--; D_80B7E144 += D_80B7E11C; } @@ -2670,7 +2670,7 @@ void Fishing_UpdateLure(Fishing* this, GlobalContext* globalCtx) { } } -s32 func_80B70A2C(Fishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { +s32 func_80B70A2C(Fishing* pthis, GlobalContext* globalCtx, u8 ignorePosCheck) { s16 i; s16 count; f32 scale; @@ -2679,14 +2679,14 @@ s32 func_80B70A2C(Fishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { f32 speedXZ; f32 angle; - if ((this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !ignorePosCheck) { + if ((pthis->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !ignorePosCheck) { return false; } // Necessary to match - if (this->unk_1AC) {} + if (pthis->unk_1AC) {} - if (this->unk_1AC >= 40.0f) { + if (pthis->unk_1AC >= 40.0f) { count = 40; scale = 1.2f; } else { @@ -2702,26 +2702,26 @@ s32 func_80B70A2C(Fishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { vel.z = cosf(angle) * speedXZ; vel.y = (Rand_ZeroFloat(3.0f) + 3.0f) * scale; - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.x += vel.x * 3.0f; pos.y = WATER_SURFACE_Y(globalCtx); pos.z += vel.z * 3.0f; - Fishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + Fishing_SpawnDustSplash(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &pos, &vel, (Rand_ZeroFloat(0.02f) + 0.025f) * scale); } - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 100.0f, 800.0f, 150, 90); + Fishing_SpawnRipple(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &pos, 100.0f, 800.0f, 150, 90); - this->unk_151 = 30; + pthis->unk_151 = 30; return true; } -void func_80B70CF0(Fishing* this, GlobalContext* globalCtx) { +void func_80B70CF0(Fishing* pthis, GlobalContext* globalCtx) { s16 count; s16 i; f32 scale; @@ -2731,9 +2731,9 @@ void func_80B70CF0(Fishing* this, GlobalContext* globalCtx) { f32 angle; // Necessary to match - if (this->unk_1AC) {} + if (pthis->unk_1AC) {} - if (this->unk_1AC >= 45.0f) { + if (pthis->unk_1AC >= 45.0f) { count = 30; scale = 0.5f; } else { @@ -2749,83 +2749,83 @@ void func_80B70CF0(Fishing* this, GlobalContext* globalCtx) { vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(2.0f) + 2.0f; - pos = this->actor.world.pos; + pos = pthis->actor.world.pos; pos.x += (vel.x * 3.0f); pos.y += (vel.y * 3.0f); pos.z += (vel.z * 3.0f); - Fishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + Fishing_SpawnDustSplash(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &pos, &vel, (Rand_ZeroFloat(0.02f) + 0.025f) * scale); } } -void func_80B70ED4(Fishing* this, Input* input) { +void func_80B70ED4(Fishing* pthis, Input* input) { Vec3f sp34; Vec3f sp28; f32 sp24; - sp34.x = sLurePos.x - this->actor.world.pos.x; - sp34.y = sLurePos.y - this->actor.world.pos.y; - sp34.z = sLurePos.z - this->actor.world.pos.z; + sp34.x = sLurePos.x - pthis->actor.world.pos.x; + sp34.y = sLurePos.y - pthis->actor.world.pos.y; + sp34.z = sLurePos.z - pthis->actor.world.pos.z; sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); - if ((D_80B7A694 == 3) && (this->unk_1A2 == 0) && (D_80B7A68C == 0)) { - Matrix_RotateY((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + if ((D_80B7A694 == 3) && (pthis->unk_1A2 == 0) && (D_80B7A68C == 0)) { + Matrix_RotateY((-pthis->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); Matrix_MultVec3f(&sp34, &sp28); - if ((sp28.z > 0.0f) || (this->unk_1AC < 40.0f)) { - if ((this->unk_158 == 7) && (sp24 < SQ(200.0f))) { - this->unk_158 = 4; - this->unk_1B4 = sLurePos; - this->unk_1B0 = 28672.0f; - this->unk_188 = 5.0f; + if ((sp28.z > 0.0f) || (pthis->unk_1AC < 40.0f)) { + if ((pthis->unk_158 == 7) && (sp24 < SQ(200.0f))) { + pthis->unk_158 = 4; + pthis->unk_1B4 = sLurePos; + pthis->unk_1B0 = 28672.0f; + pthis->unk_188 = 5.0f; } else { if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_80B7E138 > 1.0f)) && (sp24 < SQ(120.0f))) { - this->unk_158 = 2; - this->unk_15E = 0; - this->unk_17A[0] = 0; - this->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; - this->unk_1A8 = sFishInits[this->actor.params - 100].unk_0C; - this->unk_1B0 = 0.0f; + pthis->unk_158 = 2; + pthis->unk_15E = 0; + pthis->unk_17A[0] = 0; + pthis->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; + pthis->unk_1A8 = sFishInits[pthis->actor.params - 100].unk_0C; + pthis->unk_1B0 = 0.0f; } - if ((this->unk_17A[1] == 0) && (sp24 < SQ(70.0f))) { - this->unk_158 = 2; - this->unk_15E = 0; - this->unk_17A[0] = 0; - this->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; - this->unk_1A8 = sFishInits[this->actor.params - 100].unk_0C; - this->unk_1B0 = 0.0f; + if ((pthis->unk_17A[1] == 0) && (sp24 < SQ(70.0f))) { + pthis->unk_158 = 2; + pthis->unk_15E = 0; + pthis->unk_17A[0] = 0; + pthis->unk_17A[2] = (s16)Rand_ZeroFloat(100.0f) + 100; + pthis->unk_1A8 = sFishInits[pthis->actor.params - 100].unk_0C; + pthis->unk_1B0 = 0.0f; } } } - } else if ((D_80B7A694 == 4) && (D_80B7E124 != 0) && (sp24 < SQ(100.0f)) && (this->unk_158 >= 10)) { - this->unk_15A = 0; - this->unk_158 = 1; - this->unk_1A4 = 1000; - this->unk_1A2 = 100; - this->unk_17A[1] = 50; + } else if ((D_80B7A694 == 4) && (D_80B7E124 != 0) && (sp24 < SQ(100.0f)) && (pthis->unk_158 >= 10)) { + pthis->unk_15A = 0; + pthis->unk_158 = 1; + pthis->unk_1A4 = 1000; + pthis->unk_1A2 = 100; + pthis->unk_17A[1] = 50; } - if ((D_80B7E0B6 != 2) && (D_80B7E114 != 0) && (this->unk_1AC > 60.0f) && (sp24 < SQ(30.0f)) && - (this->unk_158 >= 10)) { - this->unk_15A = 0; - this->unk_158 = 1; - this->unk_1A4 = 1000; - this->unk_1A2 = 100; - this->unk_17A[1] = 50; + if ((D_80B7E0B6 != 2) && (D_80B7E114 != 0) && (pthis->unk_1AC > 60.0f) && (sp24 < SQ(30.0f)) && + (pthis->unk_158 >= 10)) { + pthis->unk_15A = 0; + pthis->unk_158 = 1; + pthis->unk_1A4 = 1000; + pthis->unk_1A2 = 100; + pthis->unk_17A[1] = 50; } } -void func_80B71278(Fishing* this, u8 arg1) { +void func_80B71278(Fishing* pthis, u8 arg1) { s16 sfxId; u8 temp; - if (this->unk_150 == 0) { - temp = this->unk_1AC; + if (pthis->unk_150 == 0) { + temp = pthis->unk_1AC; } else { - temp = 2.0f * this->unk_1AC; + temp = 2.0f * pthis->unk_1AC; } if (arg1 == 0) { @@ -2846,49 +2846,49 @@ void func_80B71278(Fishing* this, u8 arg1) { } } - Audio_PlayActorSound2(&this->actor, sfxId); + Audio_PlayActorSound2(&pthis->actor, sfxId); } -void Fishing_HandleAquariumDialog(Fishing* this, GlobalContext* globalCtx) { +void Fishing_HandleAquariumDialog(Fishing* pthis, GlobalContext* globalCtx) { if (sLinkAge == 1) { if ((HIGH_SCORE(HS_FISHING) & 0x7F) != 0) { if (HIGH_SCORE(HS_FISHING) & 0x80) { - this->actor.textId = 0x40B1; + pthis->actor.textId = 0x40B1; } else { - this->actor.textId = 0x4089; + pthis->actor.textId = 0x4089; } } else { - this->actor.textId = 0x40AE; + pthis->actor.textId = 0x40AE; } } else { if ((HIGH_SCORE(HS_FISHING) & 0x7F000000) != 0) { if (HIGH_SCORE(HS_FISHING) & 0x80000000) { - this->actor.textId = 0x40B1; + pthis->actor.textId = 0x40B1; } else { - this->actor.textId = 0x4089; + pthis->actor.textId = 0x4089; } } else { - this->actor.textId = 0x40AE; + pthis->actor.textId = 0x40AE; } } - if (this->unk_1D3 == 0) { - if (this->unk_1D4 == 0) { - this->actor.flags |= ACTOR_FLAG_0; + if (pthis->unk_1D3 == 0) { + if (pthis->unk_1D4 == 0) { + pthis->actor.flags |= ACTOR_FLAG_0; - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { D_80B7A678 = D_80B7E078; - this->unk_1D3 = 1; + pthis->unk_1D3 = 1; } else { - func_8002F2F4(&this->actor, globalCtx); + func_8002F2F4(&pthis->actor, globalCtx); } } else { - this->unk_1D4--; - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->unk_1D4--; + pthis->actor.flags &= ~ACTOR_FLAG_0; } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->unk_1D3 = 0; - this->unk_1D4 = 20; + } else if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + pthis->unk_1D3 = 0; + pthis->unk_1D4 = 20; } } @@ -2913,7 +2913,7 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 spF2; s16 spF0; s16 spEE; - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; GlobalContext* globalCtx = globalCtx2; Player* player = GET_PLAYER(globalCtx); Input* input = &globalCtx->state.input[0]; @@ -2930,101 +2930,101 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { u16 spA2; u8 phi_a1; - this->actor.uncullZoneForward = 700.0f; - this->actor.uncullZoneScale = 50.0f; + pthis->actor.uncullZoneForward = 700.0f; + pthis->actor.uncullZoneScale = 50.0f; - if (this->unk_150 == 0) { + if (pthis->unk_150 == 0) { sp118 = (player->actor.speedXZ * 0.15f) + 0.25f; } else { sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; } - if ((D_80B7E0B0 != 0) || (sCameraId != 0) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_158 != 100))) { - this->actor.flags &= ~ACTOR_FLAG_0; + if ((D_80B7E0B0 != 0) || (sCameraId != 0) || ((player->actor.world.pos.z > 1150.0f) && (pthis->unk_158 != 100))) { + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { - this->actor.flags |= ACTOR_FLAG_0; + pthis->actor.flags |= ACTOR_FLAG_0; if (D_80B7A694 != 0) { if (D_80B7E0B2 == 0) { - this->actor.focus.pos = sLurePos; + pthis->actor.focus.pos = sLurePos; } else if (D_80B7E0B2 == 1) { D_80B7A6CC = 1; D_80B7FED0 = 0.0f; D_80B7E088 = 2; } } - this->actor.focus.pos = this->actor.world.pos; + pthis->actor.focus.pos = pthis->actor.world.pos; } - this->unk_15C++; + pthis->unk_15C++; for (i = 0; i < 4; i++) { - if (this->unk_17A[i] != 0) { - this->unk_17A[i]--; + if (pthis->unk_17A[i] != 0) { + pthis->unk_17A[i]--; } } - if (this->unk_1A4 != 0) { - this->unk_1A4--; + if (pthis->unk_1A4 != 0) { + pthis->unk_1A4--; } - if (this->unk_1A2 != 0) { - this->unk_1A2--; + if (pthis->unk_1A2 != 0) { + pthis->unk_1A2--; } - if (this->unk_1A0 != 0) { - this->unk_1A0--; + if (pthis->unk_1A0 != 0) { + pthis->unk_1A0--; } - if (this->unk_151 != 0) { - this->unk_151--; + if (pthis->unk_151 != 0) { + pthis->unk_151--; } - Math_ApproachF(&this->unk_198, this->unk_190, 1.0f, 0.2f); + Math_ApproachF(&pthis->unk_198, pthis->unk_190, 1.0f, 0.2f); - if (this->unk_158 == 6) { - Math_ApproachF(&this->unk_19C, this->unk_194, 0.2f, 200.0f); + if (pthis->unk_158 == 6) { + Math_ApproachF(&pthis->unk_19C, pthis->unk_194, 0.2f, 200.0f); } else { phi_f0 = 1.0f; phi_f2 = 1.0f; - if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + if (pthis->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { phi_f0 = (KREG(64) * 0.1f) + 1.5f; phi_f2 = 3.0f; } - Math_ApproachF(&this->unk_19C, this->unk_194 * phi_f0, 1.0f, 500.0f * phi_f2); + Math_ApproachF(&pthis->unk_19C, pthis->unk_194 * phi_f0, 1.0f, 500.0f * phi_f2); } - Math_ApproachS(&this->unk_170, 0, 5, 0x1F4); + Math_ApproachS(&pthis->unk_170, 0, 5, 0x1F4); - if (this->unk_150 == 0) { - Actor_SetScale(&this->actor, this->unk_1AC * 15.0f * 0.00001f); + if (pthis->unk_150 == 0) { + Actor_SetScale(&pthis->actor, pthis->unk_1AC * 15.0f * 0.00001f); - this->unk_18C += this->unk_198; + pthis->unk_18C += pthis->unk_198; - temp = cosf(this->unk_18C); - this->unk_16C = this->unk_16E + (s16)(temp * this->unk_19C); + temp = cosf(pthis->unk_18C); + pthis->unk_16C = pthis->unk_16E + (s16)(temp * pthis->unk_19C); - temp = cosf(this->unk_18C + -1.2f); - this->unk_176 = this->unk_16E + (s16)(temp * this->unk_19C * 1.6f); + temp = cosf(pthis->unk_18C + -1.2f); + pthis->unk_176 = pthis->unk_16E + (s16)(temp * pthis->unk_19C * 1.6f); } else { - Actor_SetScale(&this->actor, this->unk_1AC * 65.0f * 0.000001f); + Actor_SetScale(&pthis->actor, pthis->unk_1AC * 65.0f * 0.000001f); - this->actor.scale.x = this->actor.scale.z * 1.1f; - this->actor.scale.y = this->actor.scale.z * 1.1f; + pthis->actor.scale.x = pthis->actor.scale.z * 1.1f; + pthis->actor.scale.y = pthis->actor.scale.z * 1.1f; - this->unk_18C += this->unk_198 * 0.8f; + pthis->unk_18C += pthis->unk_198 * 0.8f; for (i = 0; i < 3; i++) { - temp = cosf(this->unk_18C + (i * 2.1f)); - this->unk_1CC[i] = this->unk_16E + (s16)(temp * this->unk_19C * 2.0f); + temp = cosf(pthis->unk_18C + (i * 2.1f)); + pthis->unk_1CC[i] = pthis->unk_16E + (s16)(temp * pthis->unk_19C * 2.0f); } - temp = cosf(this->unk_18C + 0.4f); - this->unk_16C = (this->unk_19C * temp * 2.0f) * 0.6f; + temp = cosf(pthis->unk_18C + 0.4f); + pthis->unk_16C = (pthis->unk_19C * temp * 2.0f) * 0.6f; } - sp130 = this->unk_1B4.x - this->actor.world.pos.x; - sp12C = this->unk_1B4.y - this->actor.world.pos.y; - sp128 = this->unk_1B4.z - this->actor.world.pos.z; + sp130 = pthis->unk_1B4.x - pthis->actor.world.pos.x; + sp12C = pthis->unk_1B4.y - pthis->actor.world.pos.y; + sp128 = pthis->unk_1B4.z - pthis->actor.world.pos.z; spFC = Math_Atan2S(sp128, sp130); sp124 = sqrtf(SQ(sp130) + SQ(sp128)); @@ -3032,277 +3032,277 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { spFE = Math_Atan2S(sp124, sp12C); sp124 = sqrtf(SQ(sp130) + SQ(sp128) + SQ(sp12C)); - if ((this->unk_1A0 != 0) && (this->unk_158 != 2) && (this->unk_158 != 3) && (this->unk_158 != 4)) { - if ((this->unk_15C & 0x40) != 0) { + if ((pthis->unk_1A0 != 0) && (pthis->unk_158 != 2) && (pthis->unk_158 != 3) && (pthis->unk_158 != 4)) { + if ((pthis->unk_15C & 0x40) != 0) { spFC += 0x4000; } else { spFC -= 0x4000; } - if (((this->unk_15C + 0x20) & 0x40) != 0) { + if (((pthis->unk_15C + 0x20) & 0x40) != 0) { spFE += 0x2000; } else { spFE -= 0x2000; } } - switch (this->unk_158) { + switch (pthis->unk_158) { case 100: - Fishing_HandleAquariumDialog(this, globalCtx); + Fishing_HandleAquariumDialog(pthis, globalCtx); - this->actor.uncullZoneForward = 500.0f; - this->actor.uncullZoneScale = 300.0f; + pthis->actor.uncullZoneForward = 500.0f; + pthis->actor.uncullZoneScale = 300.0f; - Lights_PointNoGlowSetInfo(&this->lightInfo, (s16)this->actor.world.pos.x, - (s16)this->actor.world.pos.y + 20.0f, (s16)this->actor.world.pos.z - 50.0f, 255, + Lights_PointNoGlowSetInfo(&pthis->lightInfo, (s16)pthis->actor.world.pos.x, + (s16)pthis->actor.world.pos.y + 20.0f, (s16)pthis->actor.world.pos.z - 50.0f, 255, 255, 255, 255); - this->unk_1AC = D_80B7E078; + pthis->unk_1AC = D_80B7E078; sp100.y = (f32)Math_SinS(globalCtx->gameplayFrames * 300) * 1; sp100.z = (f32)Math_SinS(globalCtx->gameplayFrames * 230) * 2; - this->actor.world.pos.x = 130.0f; - this->actor.world.pos.y = 55.0f + sp100.y; - this->actor.world.pos.z = 1300.0f + sp100.z; - this->actor.shape.rot.y = -0x8000; + pthis->actor.world.pos.x = 130.0f; + pthis->actor.world.pos.y = 55.0f + sp100.y; + pthis->actor.world.pos.z = 1300.0f + sp100.z; + pthis->actor.shape.rot.y = -0x8000; - if ((this->actor.projectedPos.z < 200.0f) && (this->actor.projectedPos.z > 0.0f)) { + if ((pthis->actor.projectedPos.z < 200.0f) && (pthis->actor.projectedPos.z > 0.0f)) { spC4.x = Rand_CenteredFloat(5.0f) + 130.0f; spC4.y = 40.0f; spC4.z = Rand_CenteredFloat(5.0f) + 1280.0f; - Fishing_SpawnBubble(NULL, globalCtx->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); + Fishing_SpawnBubble(NULL, (FishingEffect*)globalCtx->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); } - Math_ApproachS(&this->unk_172, (Math_SinS(this->unk_15C * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); - Math_ApproachS(&this->unk_174, Math_SinS(this->unk_15C * 0xA00) * 1500.0f, 2, 0x7D0); + Math_ApproachS(&pthis->unk_172, (Math_SinS(pthis->unk_15C * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); + Math_ApproachS(&pthis->unk_174, Math_SinS(pthis->unk_15C * 0xA00) * 1500.0f, 2, 0x7D0); - this->unk_190 = 0.3f; - this->unk_194 = 1000.0f / 3.0f; + pthis->unk_190 = 0.3f; + pthis->unk_194 = 1000.0f / 3.0f; return; case 10: - this->unk_1B4 = this->actor.home.pos; + pthis->unk_1B4 = pthis->actor.home.pos; - Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&pthis->actor.speedXZ, 2.0f, 1.0f, 0.5f); + Math_ApproachF(&pthis->unk_1B0, 4096.0f, 1.0f, 256.0f); if (sp124 < 40.0f) { - this->unk_158 = 11; - this->unk_190 = 0.4f; - this->unk_194 = 500.0f; + pthis->unk_158 = 11; + pthis->unk_190 = 0.4f; + pthis->unk_194 = 500.0f; } - func_80B70ED4(this, input); + func_80B70ED4(pthis, input); - if (this->actor.xzDistToPlayer < (250.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; - this->unk_1A4 = 1000; - this->unk_1A2 = 200; - this->unk_17A[1] = 50; + if (pthis->actor.xzDistToPlayer < (250.0f * sp118)) { + pthis->unk_15A = pthis->unk_158 = 0; + pthis->unk_1A4 = 1000; + pthis->unk_1A2 = 200; + pthis->unk_17A[1] = 50; } break; case 11: - this->unk_1B4 = this->actor.home.pos; + pthis->unk_1B4 = pthis->actor.home.pos; - Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.05f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&pthis->actor.speedXZ, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&pthis->unk_1B0, 0.0f, 1.0f, 256.0f); if (sp124 >= 40.0f) { - this->unk_158 = 10; - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; + pthis->unk_158 = 10; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; } - func_80B70ED4(this, input); + func_80B70ED4(pthis, input); - if (this->actor.xzDistToPlayer < (250.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; - this->unk_1A4 = 1000; - this->unk_1A2 = 200; - this->unk_17A[1] = 50; + if (pthis->actor.xzDistToPlayer < (250.0f * sp118)) { + pthis->unk_15A = pthis->unk_158 = 0; + pthis->unk_1A4 = 1000; + pthis->unk_1A2 = 200; + pthis->unk_17A[1] = 50; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { if ((gSaveContext.dayTime >= 0xC000) && (gSaveContext.dayTime <= 0xC01B)) { - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; + pthis->unk_158 = 7; + pthis->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; } if ((gSaveContext.dayTime >= 0x3AAA) && (gSaveContext.dayTime <= 0x3AC5)) { - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; + pthis->unk_158 = 7; + pthis->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 200; } } if (KREG(15) != 0) { KREG(15) = 0; - this->unk_158 = 7; - this->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 2000; + pthis->unk_158 = 7; + pthis->unk_17A[3] = (s16)Rand_ZeroFloat(150.0f) + 2000; } break; case 0: - Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.05f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + Math_ApproachF(&pthis->actor.speedXZ, 1.0f, 1.0f, 0.05f); + Math_ApproachF(&pthis->unk_1B0, 0.0f, 1.0f, 256.0f); - if (this->unk_17A[0] == 0) { - if (this->unk_1A4 == 0) { - this->unk_158 = this->unk_15A = 10; + if (pthis->unk_17A[0] == 0) { + if (pthis->unk_1A4 == 0) { + pthis->unk_158 = pthis->unk_15A = 10; } else { - this->unk_158 = 1; - this->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 10; - this->unk_1B4.x = Rand_CenteredFloat(300.0f); - this->unk_1B4.y = (WATER_SURFACE_Y(globalCtx) - 50.0f) - Rand_ZeroFloat(50.0f); - this->unk_1B4.z = Rand_CenteredFloat(300.0f); - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; + pthis->unk_158 = 1; + pthis->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 10; + pthis->unk_1B4.x = Rand_CenteredFloat(300.0f); + pthis->unk_1B4.y = (WATER_SURFACE_Y(globalCtx) - 50.0f) - Rand_ZeroFloat(50.0f); + pthis->unk_1B4.z = Rand_CenteredFloat(300.0f); + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; } } if (D_80B7E0B6 == 2) { - func_80B70ED4(this, input); + func_80B70ED4(pthis, input); } else { - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } break; case 1: - if (this->unk_150 == 1) { - this->unk_158 = -1; - this->unk_1A4 = 20000; - this->unk_1A2 = 20000; - this->unk_1B4.x = 0.0f; - this->unk_1B4.y = -140.0f; - this->unk_1B4.z = 0.0f; + if (pthis->unk_150 == 1) { + pthis->unk_158 = -1; + pthis->unk_1A4 = 20000; + pthis->unk_1A2 = 20000; + pthis->unk_1B4.x = 0.0f; + pthis->unk_1B4.y = -140.0f; + pthis->unk_1B4.z = 0.0f; } else { - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + Math_ApproachF(&pthis->unk_1B0, 4096.0f, 1.0f, 256.0f); - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - Math_ApproachF(&this->unk_1B0, 8192.0f, 1.0f, 768.0f); - Math_ApproachF(&this->actor.speedXZ, 4.2f, 1.0f, 0.75); - this->unk_190 = 1.2f; - this->unk_194 = 4000.0f; - this->unk_17A[0] = 20; + if ((pthis->actor.xzDistToPlayer < (250.0f * sp118)) || (pthis->unk_17A[1] != 0)) { + Math_ApproachF(&pthis->unk_1B0, 8192.0f, 1.0f, 768.0f); + Math_ApproachF(&pthis->actor.speedXZ, 4.2f, 1.0f, 0.75); + pthis->unk_190 = 1.2f; + pthis->unk_194 = 4000.0f; + pthis->unk_17A[0] = 20; } else { - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; - Math_ApproachF(&this->actor.speedXZ, 1.5f, 1.0f, 0.1f); + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; + Math_ApproachF(&pthis->actor.speedXZ, 1.5f, 1.0f, 0.1f); } - if ((this->unk_17A[0] == 0) || (sp124 < 50.0f)) { - this->unk_158 = 0; - this->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 3; - this->unk_190 = 1.0f; - this->unk_194 = 500.0f; + if ((pthis->unk_17A[0] == 0) || (sp124 < 50.0f)) { + pthis->unk_158 = 0; + pthis->unk_17A[0] = (s16)Rand_ZeroFloat(30.0f) + 3; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 500.0f; } if (D_80B7E0B6 == 2) { - func_80B70ED4(this, input); + func_80B70ED4(pthis, input); } else { - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } } break; case -1: - Math_ApproachS(&this->unk_166, 0, 0x14, 0x20); + Math_ApproachS(&pthis->unk_166, 0, 0x14, 0x20); - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.75); - this->unk_190 = 1.0f; - this->unk_17A[0] = 20; - this->unk_194 = 4000.0f; - Math_ApproachF(&this->unk_1B0, 4096.0f, 1.0f, 256.0f); + if ((pthis->actor.xzDistToPlayer < (250.0f * sp118)) || (pthis->unk_17A[1] != 0)) { + Math_ApproachF(&pthis->actor.speedXZ, 3.0f, 1.0f, 0.75); + pthis->unk_190 = 1.0f; + pthis->unk_17A[0] = 20; + pthis->unk_194 = 4000.0f; + Math_ApproachF(&pthis->unk_1B0, 4096.0f, 1.0f, 256.0f); if ((globalCtx->gameplayFrames % 32) == 0) { - this->unk_1B4.x = Rand_CenteredFloat(600.0f); - this->unk_1B4.z = Rand_CenteredFloat(600.0f); - this->unk_1B4.y = -120.0f; + pthis->unk_1B4.x = Rand_CenteredFloat(600.0f); + pthis->unk_1B4.z = Rand_CenteredFloat(600.0f); + pthis->unk_1B4.y = -120.0f; } } else if (sp124 > 50.0f) { - this->unk_190 = 0.8f; - this->unk_194 = 1500.0f; - Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.1f); - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + pthis->unk_190 = 0.8f; + pthis->unk_194 = 1500.0f; + Math_ApproachF(&pthis->actor.speedXZ, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&pthis->unk_1B0, 2048.0f, 1.0f, 128.0f); } else { - this->unk_190 = 0.4f; - this->unk_194 = 500.0f; - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.02f); - Math_ApproachF(&this->unk_1B0, 0.0f, 1.0f, 256.0f); + pthis->unk_190 = 0.4f; + pthis->unk_194 = 500.0f; + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 0.02f); + Math_ApproachF(&pthis->unk_1B0, 0.0f, 1.0f, 256.0f); } - if (this->unk_1A4 == 0) { - this->unk_158 = 10; - this->unk_15A = 10; - } else if ((KREG(2) != 0) || (((this->unk_1A4 & 0x7FF) == 0) && (this->unk_1A4 < 15000))) { + if (pthis->unk_1A4 == 0) { + pthis->unk_158 = 10; + pthis->unk_15A = 10; + } else if ((KREG(2) != 0) || (((pthis->unk_1A4 & 0x7FF) == 0) && (pthis->unk_1A4 < 15000))) { KREG(2) = 0; - this->unk_158 = -2; - this->actor.world.rot.x = this->actor.shape.rot.x = 0; - this->unk_1B4.y = WATER_SURFACE_Y(globalCtx) + 10.0f; - this->unk_1B4.x = Rand_ZeroFloat(50.0f); - this->unk_1B4.z = Rand_ZeroFloat(50.0f); + pthis->unk_158 = -2; + pthis->actor.world.rot.x = pthis->actor.shape.rot.x = 0; + pthis->unk_1B4.y = WATER_SURFACE_Y(globalCtx) + 10.0f; + pthis->unk_1B4.x = Rand_ZeroFloat(50.0f); + pthis->unk_1B4.z = Rand_ZeroFloat(50.0f); } - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; break; case -2: - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - this->unk_158 = -1; - this->unk_1B4.y = -120.0f; + if ((pthis->actor.xzDistToPlayer < (250.0f * sp118)) || (pthis->unk_17A[1] != 0)) { + pthis->unk_158 = -1; + pthis->unk_1B4.y = -120.0f; } else { - this->unk_190 = 0.6f; - this->unk_194 = 1000.0f; + pthis->unk_190 = 0.6f; + pthis->unk_194 = 1000.0f; - Math_ApproachS(&this->unk_166, -0x1000, 0x14, 0x100); + Math_ApproachS(&pthis->unk_166, -0x1000, 0x14, 0x100); - if (this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 20.0f)) { - Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.1f); + if (pthis->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 20.0f)) { + Math_ApproachF(&pthis->actor.speedXZ, 0.5f, 1.0f, 0.1f); } else { - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.01f); + Math_ApproachZeroF(&pthis->actor.speedXZ, 1.0f, 0.01f); - if ((this->actor.speedXZ == 0.0f) || - (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f))) { - this->unk_1B4.x = Rand_ZeroFloat(300.0f); - this->unk_1B4.z = Rand_ZeroFloat(300.0f); - this->unk_1B4.y = this->actor.floorHeight + 10.0f; - this->unk_158 = -25; - this->unk_1B0 = 0.0f; + if ((pthis->actor.speedXZ == 0.0f) || + (pthis->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f))) { + pthis->unk_1B4.x = Rand_ZeroFloat(300.0f); + pthis->unk_1B4.z = Rand_ZeroFloat(300.0f); + pthis->unk_1B4.y = pthis->actor.floorHeight + 10.0f; + pthis->unk_158 = -25; + pthis->unk_1B0 = 0.0f; - spB8 = this->fishMouthPos; + spB8 = pthis->fishMouthPos; spB8.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 10.0f, 300.0f, + Fishing_SpawnRipple(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &spB8, 10.0f, 300.0f, 150, 90); - Fishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 30.0f, 400.0f, + Fishing_SpawnRipple(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &spB8, 30.0f, 400.0f, 150, 90); - Audio_PlayActorSound2(&this->actor, NA_SE_PL_CATCH_BOOMERANG); + Audio_PlayActorSound2(&pthis->actor, NA_SE_PL_CATCH_BOOMERANG); break; } } - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); - this->actor.flags &= ~ACTOR_FLAG_0; + Math_ApproachF(&pthis->unk_1B0, 2048.0f, 1.0f, 128.0f); + pthis->actor.flags &= ~ACTOR_FLAG_0; } break; case -25: - if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_17A[1] != 0)) { - this->unk_158 = -1; - this->unk_1B4.y = -120.0f; + if ((pthis->actor.xzDistToPlayer < (250.0f * sp118)) || (pthis->unk_17A[1] != 0)) { + pthis->unk_158 = -1; + pthis->unk_1B4.y = -120.0f; } else { - Math_ApproachS(&this->unk_166, 0x1000, 0x14, 0x6A); + Math_ApproachS(&pthis->unk_166, 0x1000, 0x14, 0x6A); if (sp124 > 40.0f) { - this->unk_190 = 0.7f; - this->unk_194 = 1200.0f; - Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.01f); - Math_ApproachF(&this->unk_1B0, 2048.0f, 1.0f, 128.0f); + pthis->unk_190 = 0.7f; + pthis->unk_194 = 1200.0f; + Math_ApproachF(&pthis->actor.speedXZ, 0.5f, 1.0f, 0.01f); + Math_ApproachF(&pthis->unk_1B0, 2048.0f, 1.0f, 128.0f); } else { - this->unk_158 = -1; + pthis->unk_158 = -1; } } break; case 2: - if (((this->actor.params + D_80B7E118) & 1) != 0) { + if (((pthis->actor.params + D_80B7E118) & 1) != 0) { sp10C.x = 10.0f; } else { sp10C.x = -10.0f; @@ -3312,65 +3312,65 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Matrix_RotateY(sLureRot.y, MTXMODE_NEW); Matrix_MultVec3f(&sp10C, &sp100); - this->unk_1B4.x = sLurePos.x + sp100.x; - this->unk_1B4.z = sLurePos.z + sp100.z; + pthis->unk_1B4.x = sLurePos.x + sp100.x; + pthis->unk_1B4.z = sLurePos.z + sp100.z; if (D_80B7E0B6 == 2) { - this->unk_1B4.y = sLurePos.y; - } else if (this->unk_150 == 0) { - this->unk_1B4.y = sLurePos.y - 15.0f; + pthis->unk_1B4.y = sLurePos.y; + } else if (pthis->unk_150 == 0) { + pthis->unk_1B4.y = sLurePos.y - 15.0f; } else { - this->unk_1B4.y = sLurePos.y - 5.0f; + pthis->unk_1B4.y = sLurePos.y - 5.0f; } - if (this->unk_1B4.y <= this->actor.floorHeight) { - this->unk_1B4.y = this->actor.floorHeight + 3.0f; + if (pthis->unk_1B4.y <= pthis->actor.floorHeight) { + pthis->unk_1B4.y = pthis->actor.floorHeight + 3.0f; } - if ((D_80B7E0B6 != 2) && (this->unk_1B4.y < this->actor.world.pos.y)) { - Math_ApproachF(&this->actor.world.pos.y, this->unk_1B4.y, 0.1f, - (this->actor.world.pos.y - this->unk_1B4.y) * 0.1f); + if ((D_80B7E0B6 != 2) && (pthis->unk_1B4.y < pthis->actor.world.pos.y)) { + Math_ApproachF(&pthis->actor.world.pos.y, pthis->unk_1B4.y, 0.1f, + (pthis->actor.world.pos.y - pthis->unk_1B4.y) * 0.1f); } - Math_ApproachF(&this->unk_1B0, 8192.0f, 1.0f, (KREG(16) * 128) + 384.0f); + Math_ApproachF(&pthis->unk_1B0, 8192.0f, 1.0f, (KREG(16) * 128) + 384.0f); if (CHECK_BTN_ALL(input->press.button, BTN_A)) { - this->unk_1A8 += 0.005f; + pthis->unk_1A8 += 0.005f; } if (D_80B7E120 != 0) { if (D_80B7E120 == 1) { - this->unk_1A8 += 0.01f; + pthis->unk_1A8 += 0.01f; } else { - this->unk_1A8 += 0.05f; + pthis->unk_1A8 += 0.05f; } D_80B7E120 = 0; } if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->unk_1A8 += 0.008f; + pthis->unk_1A8 += 0.008f; } - if (sp124 < ((this->unk_1AC * 0.5f) + 20.0f)) { - if (this->unk_15E == 0) { - this->unk_190 = 1.0f; - this->unk_194 = 500.0f; - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 2; + if (sp124 < ((pthis->unk_1AC * 0.5f) + 20.0f)) { + if (pthis->unk_15E == 0) { + pthis->unk_190 = 1.0f; + pthis->unk_194 = 500.0f; + pthis->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 2; } - Math_ApproachF(&this->actor.speedXZ, -0.2f, 1.0f, 0.1f); - this->unk_15E = 1; + Math_ApproachF(&pthis->actor.speedXZ, -0.2f, 1.0f, 0.1f); + pthis->unk_15E = 1; } else { - if (this->unk_15E != 0) { - this->unk_190 = 1.0f; - this->unk_1B0 = 0.0f; - this->unk_194 = 3000.0f; + if (pthis->unk_15E != 0) { + pthis->unk_190 = 1.0f; + pthis->unk_1B0 = 0.0f; + pthis->unk_194 = 3000.0f; } - Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.15f); - this->unk_15E = 0; + Math_ApproachF(&pthis->actor.speedXZ, 3.0f, 1.0f, 0.15f); + pthis->unk_15E = 0; } - if (this->unk_1AC >= 60.0f) { + if (pthis->unk_1AC >= 60.0f) { multiplier = 0.3f; - } else if (this->unk_1AC >= 45.0f) { + } else if (pthis->unk_1AC >= 45.0f) { multiplier = 0.6f; } else { multiplier = 1.0f; @@ -3391,46 +3391,46 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp11C *= 5.0f; } - if (((this->unk_17A[0] == 1) || (Rand_ZeroOne() < sp11C)) && - ((Rand_ZeroOne() < (this->unk_1A8 * multiplier)) || ((this->unk_150 + 1) == KREG(69)))) { - if (this->unk_150 == 0) { - this->unk_158 = 3; - this->unk_190 = 1.2f; - this->unk_194 = 5000.0f; - this->unk_17A[0] = Rand_ZeroFloat(10.0f); + if (((pthis->unk_17A[0] == 1) || (Rand_ZeroOne() < sp11C)) && + ((Rand_ZeroOne() < (pthis->unk_1A8 * multiplier)) || ((pthis->unk_150 + 1) == KREG(69)))) { + if (pthis->unk_150 == 0) { + pthis->unk_158 = 3; + pthis->unk_190 = 1.2f; + pthis->unk_194 = 5000.0f; + pthis->unk_17A[0] = Rand_ZeroFloat(10.0f); } else { - this->unk_158 = -3; - this->unk_190 = 1.0f; - this->unk_194 = 3000.0f; - this->unk_17A[0] = 40; + pthis->unk_158 = -3; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 3000.0f; + pthis->unk_17A[0] = 40; } if (D_80B7E0B6 == 2) { - this->unk_188 = Rand_ZeroFloat(1.5f) + 3.0f; + pthis->unk_188 = Rand_ZeroFloat(1.5f) + 3.0f; } else { - this->unk_188 = Rand_ZeroFloat(1.5f) + 4.5f; + pthis->unk_188 = Rand_ZeroFloat(1.5f) + 4.5f; } } - if ((D_80B7A694 != 3) || (this->unk_17A[2] == 0) || - (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) > 800.0f)) { - this->unk_158 = this->unk_15A; - this->unk_17A[1] = (s16)Rand_ZeroFloat(30.0f) + 50; - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 5; - this->unk_190 = 1.0f; - this->unk_1B0 = 0.0f; - this->unk_194 = 2000.0f; + if ((D_80B7A694 != 3) || (pthis->unk_17A[2] == 0) || + (sqrtf(SQ(pthis->actor.world.pos.x) + SQ(pthis->actor.world.pos.z)) > 800.0f)) { + pthis->unk_158 = pthis->unk_15A; + pthis->unk_17A[1] = (s16)Rand_ZeroFloat(30.0f) + 50; + pthis->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 5; + pthis->unk_190 = 1.0f; + pthis->unk_1B0 = 0.0f; + pthis->unk_194 = 2000.0f; } - if (this->actor.xzDistToPlayer < (100.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; - this->unk_1A4 = 1000; - this->unk_1A2 = 200; - this->unk_17A[1] = 50; + if (pthis->actor.xzDistToPlayer < (100.0f * sp118)) { + pthis->unk_15A = pthis->unk_158 = 0; + pthis->unk_1A4 = 1000; + pthis->unk_1A2 = 200; + pthis->unk_17A[1] = 50; } break; case 3: - this->unk_151 = 6; + pthis->unk_151 = 6; sp134 = 2; if ((((s16)player->actor.world.pos.x + D_80B7E118) & 1) != 0) { @@ -3444,67 +3444,67 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Matrix_RotateY(sLureRot.y, MTXMODE_NEW); Matrix_MultVec3f(&sp10C, &sp100); - this->unk_1B4.x = sLurePos.x + sp100.x; - this->unk_1B4.z = sLurePos.z + sp100.z; - this->unk_1B4.y = sLurePos.y - 10.0f; - this->unk_1B0 = 4096.0f; - Math_ApproachF(&this->actor.speedXZ, this->unk_188 * 0.8f, 1.0f, 1.0f); + pthis->unk_1B4.x = sLurePos.x + sp100.x; + pthis->unk_1B4.z = sLurePos.z + sp100.z; + pthis->unk_1B4.y = sLurePos.y - 10.0f; + pthis->unk_1B0 = 4096.0f; + Math_ApproachF(&pthis->actor.speedXZ, pthis->unk_188 * 0.8f, 1.0f, 1.0f); if ((D_80B7A694 != 3) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_158 = this->unk_15A; - this->unk_17A[0] = 0; - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; - } else if ((this->unk_17A[0] == 0) || (sp124 < 30.0f)) { - this->unk_158 = 4; - this->unk_1B4 = sLurePos; - this->unk_1B0 = 16384.0f; - this->unk_190 = 1.2f; - this->unk_194 = 5000.0f; - this->unk_17A[0] = 20; + pthis->unk_158 = pthis->unk_15A; + pthis->unk_17A[0] = 0; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; + } else if ((pthis->unk_17A[0] == 0) || (sp124 < 30.0f)) { + pthis->unk_158 = 4; + pthis->unk_1B4 = sLurePos; + pthis->unk_1B0 = 16384.0f; + pthis->unk_190 = 1.2f; + pthis->unk_194 = 5000.0f; + pthis->unk_17A[0] = 20; } break; case 4: - Math_ApproachF(&this->unk_1B0, 16384.0f, 1.0f, 4096.0f); - Math_ApproachS(&this->unk_170, 0x4E20, 4, 0x1388); + Math_ApproachF(&pthis->unk_1B0, 16384.0f, 1.0f, 4096.0f); + Math_ApproachS(&pthis->unk_170, 0x4E20, 4, 0x1388); - this->unk_151 = 50; + pthis->unk_151 = 50; sp134 = 2; - this->unk_1B4 = sLurePos; - Math_ApproachF(&this->actor.speedXZ, this->unk_188, 1.0f, 1.0f); + pthis->unk_1B4 = sLurePos; + Math_ApproachF(&pthis->actor.speedXZ, pthis->unk_188, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (this->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + if ((D_80B7A694 != 3) || (pthis->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_17A[0] = 0; - this->unk_158 = this->unk_15A; - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; + pthis->unk_17A[0] = 0; + pthis->unk_158 = pthis->unk_15A; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; } else if (sp124 < 10.0f) { - if (func_80B70A2C(this, globalCtx, false)) { - func_80B71278(this, 0); + if (func_80B70A2C(pthis, globalCtx, false)) { + func_80B71278(pthis, 0); } - this->unk_158 = 5; - this->unk_190 = 1.2f; - this->unk_194 = 5000.0f; - this->unk_17A[1] = 150; - this->unk_17A[0] = 0; - this->unk_17A[2] = 0; - this->unk_17A[3] = 120; + pthis->unk_158 = 5; + pthis->unk_190 = 1.2f; + pthis->unk_194 = 5000.0f; + pthis->unk_17A[1] = 150; + pthis->unk_17A[0] = 0; + pthis->unk_17A[2] = 0; + pthis->unk_17A[3] = 120; D_80B7A694 = 4; - sFishingHookedFish = this; + sFishingHookedFish = pthis; sFishMouthOffset.y = 500.0f - Rand_ZeroFloat(400.0f); if (D_80B7E0B6 == 2) { - if (this->unk_1AC > 70.0f) { + if (pthis->unk_1AC > 70.0f) { phi_v0 = (s16)Rand_ZeroFloat(20.0f) + 10; - } else if (this->unk_1AC > 60.0f) { + } else if (pthis->unk_1AC > 60.0f) { phi_v0 = (s16)Rand_ZeroFloat(30.0f) + 20; - } else if (this->unk_1AC > 50.0f) { + } else if (pthis->unk_1AC > 50.0f) { phi_v0 = (s16)Rand_ZeroFloat(30.0f) + 30; } else { phi_v0 = (s16)Rand_ZeroFloat(40.0f) + 40; @@ -3513,11 +3513,11 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_80B7E0A4 = phi_v0; func_800A9F6C(0.0f, 60, phi_v0 * 3, 10); } else { - if (this->unk_1AC > 70.0f) { + if (pthis->unk_1AC > 70.0f) { phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 10; - } else if (this->unk_1AC > 60.0f) { + } else if (pthis->unk_1AC > 60.0f) { phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 15; - } else if (this->unk_1AC > 50.0f) { + } else if (pthis->unk_1AC > 50.0f) { phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 17; } else { phi_v0 = (s16)Rand_ZeroFloat(5.0f) + 25; @@ -3534,34 +3534,34 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { break; case -3: - this->unk_151 = 50; - this->unk_1B4 = sLurePos; - Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 1.0f); + pthis->unk_151 = 50; + pthis->unk_1B4 = sLurePos; + Math_ApproachF(&pthis->actor.speedXZ, 2.0f, 1.0f, 1.0f); - if ((D_80B7A694 != 3) || (this->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + if ((D_80B7A694 != 3) || (pthis->unk_17A[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { - this->unk_17A[0] = 0; - this->unk_190 = 1.0f; - this->unk_158 = this->unk_15A; - this->unk_194 = 2000.0f; + pthis->unk_17A[0] = 0; + pthis->unk_190 = 1.0f; + pthis->unk_158 = pthis->unk_15A; + pthis->unk_194 = 2000.0f; } else if (sp124 < 10.0f) { if (sLurePos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_JUMP_OUT_WATER); func_80078884(NA_SE_PL_CATCH_BOOMERANG); } - func_80B70A2C(this, globalCtx, false); - this->unk_158 = 5; - this->unk_190 = 1.2f; - this->unk_194 = 5000.0f; - this->unk_17A[1] = 150; - this->unk_17A[0] = 0; - this->unk_17A[2] = 0; - this->unk_17A[3] = 120; + func_80B70A2C(pthis, globalCtx, false); + pthis->unk_158 = 5; + pthis->unk_190 = 1.2f; + pthis->unk_194 = 5000.0f; + pthis->unk_17A[1] = 150; + pthis->unk_17A[0] = 0; + pthis->unk_17A[2] = 0; + pthis->unk_17A[3] = 120; D_80B7A694 = 4; - sFishingHookedFish = this; + sFishingHookedFish = pthis; if (D_80B7E0B6 == 2) { D_80B7E122 = 30; @@ -3580,15 +3580,15 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { break; case 5: - this->actor.uncullZoneForward = 1200.0f; - this->actor.uncullZoneScale = 200.0f; + pthis->actor.uncullZoneForward = 1200.0f; + pthis->actor.uncullZoneScale = 200.0f; D_80B7E080++; - osSyncPrintf("HIT FISH %dcm\n", (u8)this->unk_1AC); + osSyncPrintf("HIT FISH %dcm\n", (u8)pthis->unk_1AC); - Math_ApproachS(&this->unk_170, 0x2AF8, 4, 0xBB8); - sFishingHookedFish = this; - Math_ApproachS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 0x500); + Math_ApproachS(&pthis->unk_170, 0x2AF8, 4, 0xBB8); + sFishingHookedFish = pthis; + Math_ApproachS(&player->actor.shape.rot.y, pthis->actor.yawTowardsPlayer + 0x8000, 5, 0x500); if (D_80B7E124 == 0) { if ((D_80B7FEA0 < 20) && ((D_80B7E0AE & 3) == 0)) { @@ -3600,24 +3600,24 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if ((D_80B7E122 != 0) && (D_80B7E124 == 0)) { if (((input->rel.stick_y < -50) && (D_80B7A6C8 > -40)) || CHECK_BTN_ALL(input->press.button, BTN_A)) { if (input->rel.stick_y < -50) { - temp_f0 = 40.0f - ((this->unk_1AC - 30.0f) * 1.333333f); + temp_f0 = 40.0f - ((pthis->unk_1AC - 30.0f) * 1.333333f); if (temp_f0 > 0.0f) { - this->unk_152 = temp_f0; - this->unk_154 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - this->unk_156 = 1; + pthis->unk_152 = temp_f0; + pthis->unk_154 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; + pthis->unk_156 = 1; } } - this->unk_198 = 1.7f; - this->unk_19C = 7000.0f; + pthis->unk_198 = 1.7f; + pthis->unk_19C = 7000.0f; D_80B7E124 = 1; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); D_80B7E0A6 = 0; - if (this->unk_150 == 1) { - spA4 = (this->unk_1AC * 3.0f) + 120.0f; + if (pthis->unk_150 == 1) { + spA4 = (pthis->unk_1AC * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1AC) + 120.0f; + spA4 = (2.0f * pthis->unk_1AC) + 120.0f; } if (spA4 > 255.0f) { spA4 = 255.0f; @@ -3630,21 +3630,21 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } } - if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { - if (this->unk_17A[1] > 30) { + if (pthis->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + if (pthis->unk_17A[1] > 30) { phi_v0_2 = 7; } else { phi_v0_2 = 0xF; } - if (((this->unk_15C & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (D_80B7E0A4 == 0)) { - if (this->unk_1AC >= 70.0f) { + if (((pthis->unk_15C & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (D_80B7E0A4 == 0)) { + if (pthis->unk_1AC >= 70.0f) { spA4 = 255.0f; - } else if (this->unk_1AC >= 60.0f) { + } else if (pthis->unk_1AC >= 60.0f) { spA4 = 230.0f; - } else if (this->unk_1AC >= 50.0f) { + } else if (pthis->unk_1AC >= 50.0f) { spA4 = 200.0f; - } else if (this->unk_1AC >= 40.0f) { + } else if (pthis->unk_1AC >= 40.0f) { spA4 = 170.0f; } else { spA4 = 140.0f; @@ -3657,99 +3657,99 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { func_800A9F6C(0.0f, spA4, (s16)Rand_ZeroFloat(5.0f) + 10, 5); } - if (this->unk_17A[1] > 30) { - if (this->unk_17A[0] == 0) { + if (pthis->unk_17A[1] > 30) { + if (pthis->unk_17A[0] == 0) { sp10C.x = 0.0f; sp10C.y = 0.0f; sp10C.z = 200.0f; for (spA2 = 0; spA2 < 100; spA2++) { Matrix_RotateY(Rand_CenteredFloat(3.0f * M_PI / 4.0f) + - (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + (((pthis->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), MTXMODE_NEW); Matrix_MultVec3f(&sp10C, &sp100); - this->unk_1B4.x = this->actor.world.pos.x + sp100.x; - this->unk_1B4.z = this->actor.world.pos.z + sp100.z; + pthis->unk_1B4.x = pthis->actor.world.pos.x + sp100.x; + pthis->unk_1B4.z = pthis->actor.world.pos.z + sp100.z; - if ((SQ(this->unk_1B4.x) + SQ(this->unk_1B4.z)) < SQ(750.0f)) { + if ((SQ(pthis->unk_1B4.x) + SQ(pthis->unk_1B4.z)) < SQ(750.0f)) { break; } } - if ((Rand_ZeroOne() < 0.1f) && (this->unk_17A[3] == 0)) { - if (this->unk_1AC >= 60.0f) { + if ((Rand_ZeroOne() < 0.1f) && (pthis->unk_17A[3] == 0)) { + if (pthis->unk_1AC >= 60.0f) { phi_a1 = 255; - } else if (this->unk_1AC >= 50.0f) { + } else if (pthis->unk_1AC >= 50.0f) { phi_a1 = 200; } else { phi_a1 = 180; } func_800A9F6C(0.0f, phi_a1, 90, 2); - this->unk_17A[0] = 20; - this->unk_17A[1] = 100; - this->unk_17A[2] = 20; - this->unk_17A[3] = 100; - this->unk_1B4.y = 300.0f; + pthis->unk_17A[0] = 20; + pthis->unk_17A[1] = 100; + pthis->unk_17A[2] = 20; + pthis->unk_17A[3] = 100; + pthis->unk_1B4.y = 300.0f; D_80B7E0A4 = 0x28; D_80B7E116 = (s16)Rand_ZeroFloat(30.0f) + 20; } else { - this->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 3; - this->unk_17A[2] = 0; - this->unk_1B4.y = -70.0f - Rand_ZeroFloat(150.0f); + pthis->unk_17A[0] = (s16)Rand_ZeroFloat(10.0f) + 3; + pthis->unk_17A[2] = 0; + pthis->unk_1B4.y = -70.0f - Rand_ZeroFloat(150.0f); } } - if (this->unk_17A[2] != 0) { + if (pthis->unk_17A[2] != 0) { D_80B7E11C = 0.0f; - this->unk_190 = 1.6f; - this->unk_194 = 6000.0f; - Math_ApproachF(&this->actor.speedXZ, 7.5f, 1.0f, 1.0f); - Math_ApproachS(&this->unk_170, 0x4E20, 2, 0xFA0); + pthis->unk_190 = 1.6f; + pthis->unk_194 = 6000.0f; + Math_ApproachF(&pthis->actor.speedXZ, 7.5f, 1.0f, 1.0f); + Math_ApproachS(&pthis->unk_170, 0x4E20, 2, 0xFA0); } else { if ((D_80B7E124 == 0) && (D_80B7E0B6 == 2)) { - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; - Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.2f); + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; + Math_ApproachF(&pthis->actor.speedXZ, 3.0f, 1.0f, 0.2f); } else { - this->unk_190 = 1.4f; - this->unk_194 = 5000.0f; - Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 0.5f); + pthis->unk_190 = 1.4f; + pthis->unk_194 = 5000.0f; + Math_ApproachF(&pthis->actor.speedXZ, 5.0f, 1.0f, 0.5f); } - if (this->unk_150 == 0) { - D_80B7E11C = 1.0f - (this->unk_1AC * 0.00899f); + if (pthis->unk_150 == 0) { + D_80B7E11C = 1.0f - (pthis->unk_1AC * 0.00899f); } else { - D_80B7E11C = 1.0f - (this->unk_1AC * 0.00899f * 1.4f); + D_80B7E11C = 1.0f - (pthis->unk_1AC * 0.00899f * 1.4f); } } } else { - if (((this->unk_17A[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && - (!(this->unk_1AC >= 60.0f) || (D_80B7E080 >= 2000))) { - this->unk_152 = (s16)Rand_ZeroFloat(30.0f) + 15; - this->unk_154 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (((pthis->unk_17A[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && + (!(pthis->unk_1AC >= 60.0f) || (D_80B7E080 >= 2000))) { + pthis->unk_152 = (s16)Rand_ZeroFloat(30.0f) + 15; + pthis->unk_154 = pthis->actor.yawTowardsPlayer - pthis->actor.shape.rot.y; } - this->unk_190 = 1.0f; - this->unk_194 = 4500.0f; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 4500.0f; - if (this->unk_150 == 0) { - D_80B7E11C = 1.3f - (this->unk_1AC * 0.00899f); + if (pthis->unk_150 == 0) { + D_80B7E11C = 1.3f - (pthis->unk_1AC * 0.00899f); } else { - D_80B7E11C = 1.3f - (this->unk_1AC * 0.00899f * 1.4f); + D_80B7E11C = 1.3f - (pthis->unk_1AC * 0.00899f * 1.4f); } - Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + Math_ApproachF(&pthis->actor.speedXZ, 2.0f, 1.0f, 0.5f); - if (this->unk_17A[1] == 0) { - this->unk_152 = 0; + if (pthis->unk_17A[1] == 0) { + pthis->unk_152 = 0; if (D_80B7E080 < 2000) { - this->unk_17A[1] = (s16)Rand_ZeroFloat(50.0f) + 50; + pthis->unk_17A[1] = (s16)Rand_ZeroFloat(50.0f) + 50; } else if (D_80B7E080 < 3000) { - this->unk_17A[1] = (s16)Rand_ZeroFloat(20.0f) + 30; + pthis->unk_17A[1] = (s16)Rand_ZeroFloat(20.0f) + 30; } else { - this->unk_17A[1] = (s16)Rand_ZeroFloat(10.0f) + 25; + pthis->unk_17A[1] = (s16)Rand_ZeroFloat(10.0f) + 25; } } } @@ -3760,7 +3760,7 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (D_80B7E124 || (D_80B7E0B6 != 2)) { - if (this->actor.speedXZ < 3.0f) { + if (pthis->actor.speedXZ < 3.0f) { if ((D_80B7E0AE & 8) != 0) { sp100.x = -0.8f; } else { @@ -3778,18 +3778,18 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachF(&D_80B7A6BC, sp100.x, 0.3f, 0.1f); } - sReelLinePos[LINE_SEG_COUNT - 1] = this->fishMouthPos; + sReelLinePos[LINE_SEG_COUNT - 1] = pthis->fishMouthPos; sp10C.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; sp10C.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; sp10C.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; if ((SQ(sp10C.x) + SQ(sp10C.y) + SQ(sp10C.z)) > SQ(20.0f)) { - Math_ApproachF(&this->actor.world.pos.x, sReelLinePos[LINE_SEG_COUNT - 2].x, 0.2f, - 2.0f * (this->actor.speedXZ * 1.5f)); - Math_ApproachF(&this->actor.world.pos.y, sReelLinePos[LINE_SEG_COUNT - 2].y, 0.2f, - 2.0f * (this->actor.speedXZ * 1.5f) * 5.0f * 0.1f); - Math_ApproachF(&this->actor.world.pos.z, sReelLinePos[LINE_SEG_COUNT - 2].z, 0.2f, - 2.0f * (this->actor.speedXZ * 1.5f)); + Math_ApproachF(&pthis->actor.world.pos.x, sReelLinePos[LINE_SEG_COUNT - 2].x, 0.2f, + 2.0f * (pthis->actor.speedXZ * 1.5f)); + Math_ApproachF(&pthis->actor.world.pos.y, sReelLinePos[LINE_SEG_COUNT - 2].y, 0.2f, + 2.0f * (pthis->actor.speedXZ * 1.5f) * 5.0f * 0.1f); + Math_ApproachF(&pthis->actor.world.pos.z, sReelLinePos[LINE_SEG_COUNT - 2].z, 0.2f, + 2.0f * (pthis->actor.speedXZ * 1.5f)); } if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (input->rel.stick_y < -30)) { @@ -3819,13 +3819,13 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x0A00FF); } - this->unk_158 = this->unk_15A = 0; - this->unk_1A4 = 10000; - this->unk_1A2 = 500; - this->unk_17A[1] = 50; - this->unk_17A[0] = 0; - this->unk_190 = 1.0f; - this->unk_194 = 3000.0f; + pthis->unk_158 = pthis->unk_15A = 0; + pthis->unk_1A4 = 10000; + pthis->unk_1A2 = 500; + pthis->unk_17A[1] = 50; + pthis->unk_17A[0] = 0; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 3000.0f; if (D_80B7A694 == 4) { D_80B7A694 = 3; @@ -3833,10 +3833,10 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_80B7E0A6 = 50; D_80B7E11C = 0.5f; - this->unk_152 = 0; - } else if (this->actor.xzDistToPlayer < (KREG(59) + 50.0f)) { - this->unk_158 = 6; - this->unk_17A[0] = 100; + pthis->unk_152 = 0; + } else if (pthis->actor.xzDistToPlayer < (KREG(59) + 50.0f)) { + pthis->unk_158 = 6; + pthis->unk_17A[0] = 100; player->unk_860 = 3; func_800A9F6C(0.0f, 1, 3, 1); D_80B7E084++; @@ -3844,13 +3844,13 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_80B7A6CC = 100; D_80B7FEC8 = 45.0f; D_80B7A694 = 5; - this->unk_190 = 1.0f; - this->unk_194 = 500.0f; - this->unk_19C = 5000.0f; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 500.0f; + pthis->unk_19C = 5000.0f; - if (this->actor.world.pos.y <= WATER_SURFACE_Y(globalCtx)) { - func_80B71278(this, 1); - func_80B70A2C(this, globalCtx, true); + if (pthis->actor.world.pos.y <= WATER_SURFACE_Y(globalCtx)) { + func_80B71278(pthis, 1); + func_80B70A2C(pthis, globalCtx, true); } goto case_6; } @@ -3858,7 +3858,7 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { case_6: case 6: - Math_ApproachS(&this->unk_170, 0x2AF8, 2, 0xFA0); + Math_ApproachS(&pthis->unk_170, 0x2AF8, 2, 0xFA0); Math_ApproachF(&D_80B7FEC8, 15.0f, 0.05f, 0.75f); sp10C.x = D_80B7FEC8; @@ -3883,12 +3883,12 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sCameraAt.y += 25.0f; } - if (this->unk_17A[0] == 90) { + if (pthis->unk_17A[0] == 90) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HEART_GET | 0x900); D_80B7A67C = 40; - if (this->unk_150 == 0) { - D_80B7A678 = this->unk_1AC; + if (pthis->unk_150 == 0) { + D_80B7A678 = pthis->unk_1AC; if (D_80B7A678 >= 75) { D_80B7E086 = 0x409F; @@ -3898,29 +3898,29 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_80B7E086 = 0x4083; } } else { - D_80B7A678 = 2.0f * this->unk_1AC; + D_80B7A678 = 2.0f * pthis->unk_1AC; D_80B7E086 = 0x4099; } - this->unk_1D5 = 0; + pthis->unk_1D5 = 0; } - this->unk_160 = -0x4000; - this->actor.shape.rot.y = player->actor.shape.rot.y + 0x5000; - this->actor.shape.rot.x = this->actor.shape.rot.z = this->unk_162 = this->unk_164 = this->unk_16E = 0; + pthis->unk_160 = -0x4000; + pthis->actor.shape.rot.y = player->actor.shape.rot.y + 0x5000; + pthis->actor.shape.rot.x = pthis->actor.shape.rot.z = pthis->unk_162 = pthis->unk_164 = pthis->unk_16E = 0; sp10C.x = 4.0f; sp10C.y = -10.0f; sp10C.z = 5.0f; Matrix_MultVec3f(&sp10C, &sp100); - Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); - Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); - Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); + Math_ApproachF(&pthis->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); + Math_ApproachF(&pthis->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); + Math_ApproachF(&pthis->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); D_80B7E144 = 188.0f; - if (this->unk_17A[0] <= 50) { - switch (this->unk_1D5) { + if (pthis->unk_17A[0] <= 50) { + switch (pthis->unk_1D5) { case 0: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) || (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { @@ -3928,26 +3928,26 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Message_CloseTextbox(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { if (D_80B7A670 == 0.0f) { - D_80B7A670 = this->unk_1AC; - D_80B7E07C = this->unk_150; + D_80B7A670 = pthis->unk_1AC; + D_80B7E07C = pthis->unk_150; D_80B7E07E = D_80B7E0B6; - Actor_Kill(&this->actor); - } else if ((this->unk_150 == 0) && (D_80B7E07C == 0) && - ((s16)this->unk_1AC < (s16)D_80B7A670)) { - this->unk_1D5 = 1; - this->unk_17A[0] = 0x3C; + Actor_Kill(&pthis->actor); + } else if ((pthis->unk_150 == 0) && (D_80B7E07C == 0) && + ((s16)pthis->unk_1AC < (s16)D_80B7A670)) { + pthis->unk_1D5 = 1; + pthis->unk_17A[0] = 0x3C; Message_StartTextbox(globalCtx, 0x4098, NULL); } else { f32 temp1 = D_80B7A670; s16 temp2 = D_80B7E07C; - D_80B7A670 = this->unk_1AC; - D_80B7E07C = this->unk_150; + D_80B7A670 = pthis->unk_1AC; + D_80B7E07C = pthis->unk_150; D_80B7E07E = D_80B7E0B6; - this->unk_1AC = temp1; - this->unk_150 = temp2; + pthis->unk_1AC = temp1; + pthis->unk_150 = temp2; } } - if (this->unk_1D5 == 0) { + if (pthis->unk_1D5 == 0) { D_80B7A694 = 0; } } @@ -3961,10 +3961,10 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (globalCtx->msgCtx.choiceIndex != 0) { f32 temp1 = D_80B7A670; s16 temp2 = D_80B7E07C; - D_80B7A670 = this->unk_1AC; + D_80B7A670 = pthis->unk_1AC; D_80B7E07E = D_80B7E0B6; - this->unk_1AC = temp1; - this->unk_150 = temp2; + pthis->unk_1AC = temp1; + pthis->unk_150 = temp2; } D_80B7A694 = 0; } @@ -3974,23 +3974,23 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (D_80B7A694 == 0) { - if (this->actor.update != NULL) { - this->unk_158 = this->unk_15A = 0; - this->unk_1A4 = 10000; - this->unk_1A2 = 500; - this->unk_17A[1] = 50; - this->unk_17A[0] = 0; - this->unk_190 = 1.0f; - this->unk_194 = 2000.0f; - SkelAnime_Free(&this->skelAnime, globalCtx); + if (pthis->actor.update != NULL) { + pthis->unk_158 = pthis->unk_15A = 0; + pthis->unk_1A4 = 10000; + pthis->unk_1A2 = 500; + pthis->unk_17A[1] = 50; + pthis->unk_17A[0] = 0; + pthis->unk_190 = 1.0f; + pthis->unk_194 = 2000.0f; + SkelAnime_Free(&pthis->skelAnime, globalCtx); - if (this->unk_150 == 0) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, 0, 0, 0); - Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); + if (pthis->unk_150 == 0) { + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFishingFishSkel, &gFishingFishAnim, 0, 0, 0); + Animation_MorphToLoop(&pthis->skelAnime, &gFishingFishAnim, 0.0f); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, + SkelAnime_InitFlex(globalCtx, &pthis->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, 0); - Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); + Animation_MorphToLoop(&pthis->skelAnime, &gFishingLoachAnim, 0.0f); } } @@ -4003,73 +4003,73 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { break; case 7: - this->unk_151 = 50; + pthis->unk_151 = 50; sp134 = 5; - this->unk_1B0 = 12288.0f; + pthis->unk_1B0 = 12288.0f; - if (this->actor.params < 104) { - this->unk_1B4 = sGroupFishes[this->actor.params - 100].pos; + if (pthis->actor.params < 104) { + pthis->unk_1B4 = sGroupFishes[pthis->actor.params - 100].pos; D_80B7A898 = 1; - } else if (this->actor.params < 108) { - this->unk_1B4 = sGroupFishes[this->actor.params - 100 + 16].pos; + } else if (pthis->actor.params < 108) { + pthis->unk_1B4 = sGroupFishes[pthis->actor.params - 100 + 16].pos; D_80B7A898 = 2; } else { - this->unk_1B4 = sGroupFishes[this->actor.params - 100 + 32].pos; + pthis->unk_1B4 = sGroupFishes[pthis->actor.params - 100 + 32].pos; D_80B7A898 = 3; } - Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 1.0f); + Math_ApproachF(&pthis->actor.speedXZ, 5.0f, 1.0f, 1.0f); if (sp124 < 20.0f) { - Math_ApproachS(&this->unk_170, 0x4E20, 2, 0xFA0); + Math_ApproachS(&pthis->unk_170, 0x4E20, 2, 0xFA0); - if ((this->unk_17A[2] == 0) && func_80B70A2C(this, globalCtx, false)) { - func_80B71278(this, Rand_ZeroFloat(1.99f)); - this->unk_17A[2] = (s16)Rand_ZeroFloat(20.0f) + 20; + if ((pthis->unk_17A[2] == 0) && func_80B70A2C(pthis, globalCtx, false)) { + func_80B71278(pthis, Rand_ZeroFloat(1.99f)); + pthis->unk_17A[2] = (s16)Rand_ZeroFloat(20.0f) + 20; } } - if (this->unk_17A[3] == 0) { - this->unk_158 = 10; - this->unk_15A = 10; + if (pthis->unk_17A[3] == 0) { + pthis->unk_158 = 10; + pthis->unk_15A = 10; } else { - func_80B70ED4(this, input); - if (this->actor.xzDistToPlayer < (100.0f * sp118)) { - this->unk_15A = this->unk_158 = 0; - this->unk_1A4 = 500; - this->unk_1A2 = 200; - this->unk_17A[1] = 50; + func_80B70ED4(pthis, input); + if (pthis->actor.xzDistToPlayer < (100.0f * sp118)) { + pthis->unk_15A = pthis->unk_158 = 0; + pthis->unk_1A4 = 500; + pthis->unk_1A2 = 200; + pthis->unk_17A[1] = 50; } } break; } - Math_ApproachS(&this->unk_172, (Math_SinS(this->unk_15C * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); + Math_ApproachS(&pthis->unk_172, (Math_SinS(pthis->unk_15C * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); - if (this->unk_158 != 6) { - if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { - this->unk_190 = 1.5f; - this->unk_194 = 5000.0f; + if (pthis->unk_158 != 6) { + if (pthis->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + pthis->unk_190 = 1.5f; + pthis->unk_194 = 5000.0f; - Math_ApproachS(&this->unk_16E, 0, 5, 0x7D0); + Math_ApproachS(&pthis->unk_16E, 0, 5, 0x7D0); spF4 = spF0 = spFA = 3; spF2 = spEE = 0x2000; - this->unk_17A[2] = 0; - this->unk_184 -= 1.0f; + pthis->unk_17A[2] = 0; + pthis->unk_184 -= 1.0f; } else { - Math_ApproachZeroF(&this->unk_184, 1.0f, 2.0f); - if ((this->unk_158 != -1) && (this->unk_158 != -2) && (this->unk_158 != -25)) { - this->unk_166 = 0; + Math_ApproachZeroF(&pthis->unk_184, 1.0f, 2.0f); + if ((pthis->unk_158 != -1) && (pthis->unk_158 != -2) && (pthis->unk_158 != -25)) { + pthis->unk_166 = 0; } - this->unk_168 = this->unk_16A = 0; + pthis->unk_168 = pthis->unk_16A = 0; spF4 = spF0 = spFA = 4; spF2 = spEE = 0x2000; - spF6 = Fishing_SmoothStepToS(&this->actor.world.rot.y, spFC, sp134, this->unk_1B0) * 3.0f; - Math_ApproachS(&this->actor.world.rot.x, spFE, sp134, this->unk_1B0 * 0.5f); + spF6 = Fishing_SmoothStepToS(&pthis->actor.world.rot.y, spFC, sp134, pthis->unk_1B0) * 3.0f; + Math_ApproachS(&pthis->actor.world.rot.x, spFE, sp134, pthis->unk_1B0 * 0.5f); if (spF6 > 0x1F40) { spF6 = 0x1F40; @@ -4077,152 +4077,152 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { spF6 = -0x1F40; } - if (this->actor.speedXZ >= 3.2f) { - Math_ApproachS(&this->unk_16E, spF6, 2, 0x4E20); + if (pthis->actor.speedXZ >= 3.2f) { + Math_ApproachS(&pthis->unk_16E, spF6, 2, 0x4E20); } else { - Math_ApproachS(&this->unk_16E, spF6, 3, 0xBB8); + Math_ApproachS(&pthis->unk_16E, spF6, 3, 0xBB8); } - func_8002D908(&this->actor); + func_8002D908(&pthis->actor); } - func_8002D7EC(&this->actor); + func_8002D7EC(&pthis->actor); - this->actor.world.pos.y += (this->unk_184 * 1.5f); + pthis->actor.world.pos.y += (pthis->unk_184 * 1.5f); if (1) {} - if (this->unk_152 != 0) { - this->unk_168 = this->unk_154; - this->unk_152--; - if (this->unk_156 != 0) { + if (pthis->unk_152 != 0) { + pthis->unk_168 = pthis->unk_154; + pthis->unk_152--; + if (pthis->unk_156 != 0) { spF0 = 5; spEE = 0x4000; } else { spF0 = 10; spEE = 0x800; } - this->unk_166 = -0x500 - this->actor.shape.rot.x; + pthis->unk_166 = -0x500 - pthis->actor.shape.rot.x; spF4 = 5; spF2 = 0x4000; } else { - this->unk_156 = 0; + pthis->unk_156 = 0; } - Math_ApproachS(&this->unk_160, this->unk_166, spF4, spF2); - Math_ApproachS(&this->unk_162, this->unk_168, spF0, spEE); - Math_ApproachS(&this->unk_164, this->unk_16A, spFA, 0x2000); + Math_ApproachS(&pthis->unk_160, pthis->unk_166, spF4, spF2); + Math_ApproachS(&pthis->unk_162, pthis->unk_168, spF0, spEE); + Math_ApproachS(&pthis->unk_164, pthis->unk_16A, spFA, 0x2000); - if (this->actor.speedXZ <= 0.5f) { - Math_ApproachS(&this->actor.shape.rot.x, 0, 10, this->unk_178); - Math_ApproachS(&this->unk_178, 0x500, 1, 0x20); + if (pthis->actor.speedXZ <= 0.5f) { + Math_ApproachS(&pthis->actor.shape.rot.x, 0, 10, pthis->unk_178); + Math_ApproachS(&pthis->unk_178, 0x500, 1, 0x20); } else { - Math_ApproachS(&this->actor.shape.rot.x, -this->actor.world.rot.x, 10, 0x1000); - this->unk_178 = 0; + Math_ApproachS(&pthis->actor.shape.rot.x, -pthis->actor.world.rot.x, 10, 0x1000); + pthis->unk_178 = 0; } - this->actor.shape.rot.y = this->actor.world.rot.y; + pthis->actor.shape.rot.y = pthis->actor.world.rot.y; - if ((this->unk_158 != -1) && (this->unk_158 != -2) && (this->unk_158 != -25)) { - if ((this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) && - (this->actor.prevPos.y <= WATER_SURFACE_Y(globalCtx))) { - func_80B70A2C(this, globalCtx, true); - func_80B71278(this, 1); - this->unk_184 = this->actor.velocity.y; - this->actor.velocity.y = 0.0f; - this->unk_16A = Rand_CenteredFloat(32768.0f); - } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && - (this->actor.prevPos.y >= WATER_SURFACE_Y(globalCtx))) { - if (this->unk_184 < -5.0f) { - this->unk_184 = -5.0f; + if ((pthis->unk_158 != -1) && (pthis->unk_158 != -2) && (pthis->unk_158 != -25)) { + if ((pthis->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) && + (pthis->actor.prevPos.y <= WATER_SURFACE_Y(globalCtx))) { + func_80B70A2C(pthis, globalCtx, true); + func_80B71278(pthis, 1); + pthis->unk_184 = pthis->actor.velocity.y; + pthis->actor.velocity.y = 0.0f; + pthis->unk_16A = Rand_CenteredFloat(32768.0f); + } else if ((pthis->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && + (pthis->actor.prevPos.y >= WATER_SURFACE_Y(globalCtx))) { + if (pthis->unk_184 < -5.0f) { + pthis->unk_184 = -5.0f; } - this->actor.world.rot.x = -0xFA0; - func_80B70A2C(this, globalCtx, true); - this->unk_1D2 = 20; - func_80B71278(this, 0); + pthis->actor.world.rot.x = -0xFA0; + func_80B70A2C(pthis, globalCtx, true); + pthis->unk_1D2 = 20; + func_80B71278(pthis, 0); } } - if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && - (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && ((this->unk_15C & 1) == 0) && - (this->actor.speedXZ > 0.0f)) { - Vec3f pos = this->actor.world.pos; + if ((pthis->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && + (pthis->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && ((pthis->unk_15C & 1) == 0) && + (pthis->actor.speedXZ > 0.0f)) { + Vec3f pos = pthis->actor.world.pos; pos.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 80.0f, 500.0f, 150, 90); + Fishing_SpawnRipple(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &pos, 80.0f, 500.0f, 150, 90); } - if ((this->actor.speedXZ > 0.0f) || (this->unk_158 == 5)) { - f32 velocityY = this->actor.velocity.y; + if ((pthis->actor.speedXZ > 0.0f) || (pthis->unk_158 == 5)) { + f32 velocityY = pthis->actor.velocity.y; - spD8 = this->unk_1AC * 0.1f; + spD8 = pthis->unk_1AC * 0.1f; - this->actor.world.pos.y -= spD8; - this->actor.prevPos.y -= spD8; - this->actor.velocity.y = -1.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x45); - this->actor.world.pos.y += spD8; - this->actor.prevPos.y += spD8; + pthis->actor.world.pos.y -= spD8; + pthis->actor.prevPos.y -= spD8; + pthis->actor.velocity.y = -1.0f; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 30.0f, 30.0f, 100.0f, 0x45); + pthis->actor.world.pos.y += spD8; + pthis->actor.prevPos.y += spD8; - this->actor.velocity.y = velocityY; + pthis->actor.velocity.y = velocityY; - if (this->actor.bgCheckFlags & 8) { - this->unk_1A0 = 20; + if (pthis->actor.bgCheckFlags & 8) { + pthis->unk_1A0 = 20; } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { - this->unk_184 = Rand_ZeroFloat(3.0f) + 3.0f; - this->actor.velocity.x = this->actor.world.pos.x * -0.003f; - this->actor.velocity.z = this->actor.world.pos.z * -0.003f; + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + pthis->unk_184 = Rand_ZeroFloat(3.0f) + 3.0f; + pthis->actor.velocity.x = pthis->actor.world.pos.x * -0.003f; + pthis->actor.velocity.z = pthis->actor.world.pos.z * -0.003f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FISH_LEAP); - func_80B70CF0(this, globalCtx); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FISH_LEAP); + func_80B70CF0(pthis, globalCtx); if (Rand_ZeroOne() < 0.5f) { - this->unk_16A = 0x4000; + pthis->unk_16A = 0x4000; } else { - this->unk_16A = -0x4000; + pthis->unk_16A = -0x4000; } if (Rand_ZeroOne() < 0.5f) { - this->unk_166 = 0; + pthis->unk_166 = 0; } else { - this->unk_166 = (s16)Rand_CenteredFloat(32.0f) + 0x8000; + pthis->unk_166 = (s16)Rand_CenteredFloat(32.0f) + 0x8000; } - this->unk_168 = (s16)Rand_CenteredFloat(16384.0f); - this->unk_190 = 1.0f; - this->unk_194 = 5000.0f; - this->unk_19C = 5000.0f; + pthis->unk_168 = (s16)Rand_CenteredFloat(16384.0f); + pthis->unk_190 = 1.0f; + pthis->unk_194 = 5000.0f; + pthis->unk_19C = 5000.0f; } else { - this->unk_184 = 0.0f; + pthis->unk_184 = 0.0f; - if ((this->unk_158 == 5) && ((this->unk_15C & 1) == 0)) { + if ((pthis->unk_158 == 5) && ((pthis->unk_15C & 1) == 0)) { Vec3f pos; - pos.x = Rand_CenteredFloat(10.0f) + this->actor.world.pos.x; - pos.z = Rand_CenteredFloat(10.0f) + this->actor.world.pos.z; - pos.y = this->actor.floorHeight + 5.0f; - Fishing_SpawnWaterDust(&this->actor.projectedPos, globalCtx->specialEffects, &pos, - (this->unk_1AC * 0.005f) + 0.15f); + pos.x = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.x; + pos.z = Rand_CenteredFloat(10.0f) + pthis->actor.world.pos.z; + pos.y = pthis->actor.floorHeight + 5.0f; + Fishing_SpawnWaterDust(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &pos, + (pthis->unk_1AC * 0.005f) + 0.15f); } } } } } - if (this->unk_1D2 != 0) { + if (pthis->unk_1D2 != 0) { s16 i; Vec3f pos; - f32 range = (this->unk_1AC * 0.075f) + 10.0f; + f32 range = (pthis->unk_1AC * 0.075f) + 10.0f; - this->unk_1D2--; + pthis->unk_1D2--; for (i = 0; i < 2; i++) { - pos.x = Rand_CenteredFloat(range) + this->actor.world.pos.x; - pos.y = Rand_CenteredFloat(range) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(range) + this->actor.world.pos.z; - Fishing_SpawnBubble(&this->actor.projectedPos, globalCtx->specialEffects, &pos, + pos.x = Rand_CenteredFloat(range) + pthis->actor.world.pos.x; + pos.y = Rand_CenteredFloat(range) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(range) + pthis->actor.world.pos.z; + Fishing_SpawnBubble(&pthis->actor.projectedPos, (FishingEffect*)globalCtx->specialEffects, &pos, Rand_ZeroFloat(0.035f) + 0.04f, 0); } } @@ -4230,45 +4230,45 @@ void Fishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s32 Fishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; if (limbIndex == 0xD) { - rot->z -= this->unk_170 - 11000; + rot->z -= pthis->unk_170 - 11000; } else if ((limbIndex == 2) || (limbIndex == 3)) { - rot->y += this->unk_16C; + rot->y += pthis->unk_16C; } else if (limbIndex == 4) { - rot->y += this->unk_176; + rot->y += pthis->unk_176; } else if (limbIndex == 0xE) { - rot->y -= this->unk_172; + rot->y -= pthis->unk_172; } else if (limbIndex == 0xF) { - rot->y += this->unk_172; + rot->y += pthis->unk_172; } else if (limbIndex == 8) { - rot->y += this->unk_174; + rot->y += pthis->unk_174; } else if (limbIndex == 9) { - rot->y -= this->unk_174; + rot->y -= pthis->unk_174; } return 0; } void Fishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; if (limbIndex == 0xD) { - Matrix_MultVec3f(&sFishMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sFishMouthOffset, &pthis->fishMouthPos); } } s32 Fishing_LoachOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; if (limbIndex == 3) { - rot->y += this->unk_1CC[0]; + rot->y += pthis->unk_1CC[0]; } else if (limbIndex == 4) { - rot->y += this->unk_1CC[1]; + rot->y += pthis->unk_1CC[1]; } else if (limbIndex == 5) { - rot->y += this->unk_1CC[2]; + rot->y += pthis->unk_1CC[2]; } return 0; @@ -4276,39 +4276,39 @@ s32 Fishing_LoachOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** void Fishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f sLoachMouthOffset = { 500.0f, 500.0f, 0.0f }; - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; if (limbIndex == 0xB) { - Matrix_MultVec3f(&sLoachMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sLoachMouthOffset, &pthis->fishMouthPos); } } void Fishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(((this->unk_162 + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateX(((this->unk_160 + this->actor.shape.rot.x) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateZ(((this->unk_164 + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(((pthis->unk_162 + pthis->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateX(((pthis->unk_160 + pthis->actor.shape.rot.x) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateZ(((pthis->unk_164 + pthis->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); - if (this->unk_150 == 0) { - Matrix_RotateY((this->unk_16C * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); - Matrix_Translate(0.0f, 0.0f, this->unk_16C * 10.0f * 0.01f, MTXMODE_APPLY); + if (pthis->unk_150 == 0) { + Matrix_RotateY((pthis->unk_16C * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, pthis->unk_16C * 10.0f * 0.01f, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, Fishing_FishOverrideLimbDraw, Fishing_FishPostLimbDraw, this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, Fishing_FishOverrideLimbDraw, Fishing_FishPostLimbDraw, pthis); } else { Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_RotateY(this->unk_16C * (M_PI / 32768), MTXMODE_APPLY); + Matrix_RotateY(pthis->unk_16C * (M_PI / 32768), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); Matrix_RotateY(-(M_PI / 2), MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, Fishing_LoachOverrideLimbDraw, Fishing_LoachPostLimbDraw, - this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, Fishing_LoachOverrideLimbDraw, Fishing_LoachPostLimbDraw, + pthis); } } @@ -4642,7 +4642,7 @@ void Fishing_UpdateGroupFishes(GlobalContext* globalCtx) { ripplePos = fish->pos; ripplePos.y = WATER_SURFACE_Y(globalCtx); - Fishing_SpawnRipple(&fish->projectedPos, globalCtx->specialEffects, &ripplePos, 20.0f, + Fishing_SpawnRipple(&fish->projectedPos, (FishingEffect*)globalCtx->specialEffects, &ripplePos, 20.0f, Rand_ZeroFloat(50.0f) + 100.0f, 150, 90); if (fish->unk_28 < 1.5f) { @@ -4744,38 +4744,38 @@ void Fishing_DrawGroupFishes(GlobalContext* globalCtx) { static u16 D_80B7AFB8[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; -void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { - switch (this->unk_15C) { +void Fishing_HandleOwnerDialog(Fishing* pthis, GlobalContext* globalCtx) { + switch (pthis->unk_15C) { case 0: if (D_80B7E0AC == 0) { if (sLinkAge != 1) { if ((HIGH_SCORE(HS_FISHING) & 0x100) && !(HIGH_SCORE(HS_FISHING) & 0x200)) { - this->actor.textId = 0x4093; + pthis->actor.textId = 0x4093; } else { - this->actor.textId = 0x407B; + pthis->actor.textId = 0x407B; } } else { - this->actor.textId = 0x407B; + pthis->actor.textId = 0x407B; } } else if (D_80B7A68C == 0) { - this->actor.textId = 0x4084; + pthis->actor.textId = 0x4084; } else { - this->actor.textId = 0x4097; + pthis->actor.textId = 0x4097; } - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&pthis->actor, globalCtx)) { if (D_80B7E0AC == 0) { - this->unk_15C = 1; + pthis->unk_15C = 1; if (sLinkAge != 1) { HIGH_SCORE(HS_FISHING) |= 0x200; } else { HIGH_SCORE(HS_FISHING) |= 0x100; } } else { - this->unk_15C = 10; + pthis->unk_15C = 10; } } else { - func_8002F2CC(&this->actor, globalCtx, 100.0f); + func_8002F2CC(&pthis->actor, globalCtx, 100.0f); } break; @@ -4788,20 +4788,20 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (gSaveContext.rupees >= 20) { Rupees_ChangeBy(-20); if (func_800AA148() == 0) { - this->actor.textId = 0x407C; + pthis->actor.textId = 0x407C; } else { - this->actor.textId = 0x407D; + pthis->actor.textId = 0x407D; } - Message_ContinueTextbox(globalCtx, this->actor.textId); - this->unk_15C = 2; + Message_ContinueTextbox(globalCtx, pthis->actor.textId); + pthis->unk_15C = 2; } else { Message_ContinueTextbox(globalCtx, 0x407E); - this->unk_15C = 3; + pthis->unk_15C = 3; } break; case 1: Message_ContinueTextbox(globalCtx, 0x2D); - this->unk_15C = 3; + pthis->unk_15C = 3; break; } } @@ -4811,17 +4811,17 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_CloseTextbox(globalCtx); Message_ContinueTextbox(globalCtx, 0x407F); - this->unk_15C = 4; + pthis->unk_15C = 4; } break; case 3: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_CloseTextbox(globalCtx); - this->unk_15C = 0; + pthis->unk_15C = 0; } if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) { - this->unk_15C = 0; + pthis->unk_15C = 0; } break; @@ -4833,7 +4833,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { case 0: D_80B7A678 = D_80B7E078; Message_ContinueTextbox(globalCtx, 0x4080); - this->unk_15C = 5; + pthis->unk_15C = 5; break; case 1: Message_ContinueTextbox(globalCtx, 0x407F); @@ -4850,7 +4850,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { globalCtx->startPlayerFishing(globalCtx); D_80B7E0AC = 1; D_80B7A684 = 20; - this->unk_15C = 0; + pthis->unk_15C = 0; if ((HIGH_SCORE(HS_FISHING) & 0xFF0000) < 0xFF0000) { HIGH_SCORE(HS_FISHING) += 0x10000; @@ -4868,10 +4868,10 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { Message_ContinueTextbox(globalCtx, 0x40B2); D_80B7A688 = 1; D_80B7A68C = 0; - this->unk_15C = 20; + pthis->unk_15C = 20; break; case 1: - this->unk_15C = 0; + pthis->unk_15C = 0; break; } } @@ -4882,26 +4882,26 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (D_80B7A670 == 0.0f) { - this->actor.textId = 0x408C; - this->unk_15C = 20; + pthis->actor.textId = 0x408C; + pthis->unk_15C = 20; } else if (D_80B7E07C == 0) { D_80B7A678 = D_80B7A670; if ((s16)D_80B7E078 < (s16)D_80B7A670) { if (D_80B7E07E == 2) { - this->actor.textId = 0x40B0; + pthis->actor.textId = 0x40B0; } else { - this->actor.textId = 0x4086; + pthis->actor.textId = 0x4086; } - this->unk_15C = 11; + pthis->unk_15C = 11; } else { - this->actor.textId = 0x408B; - this->unk_15C = 20; + pthis->actor.textId = 0x408B; + pthis->unk_15C = 20; } } else { - this->actor.textId = 0x409B; - this->unk_15C = 11; + pthis->actor.textId = 0x409B; + pthis->unk_15C = 11; } - Message_ContinueTextbox(globalCtx, this->actor.textId); + Message_ContinueTextbox(globalCtx, pthis->actor.textId); break; case 1: if (D_80B7A680 > 36000) { @@ -4932,7 +4932,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { } } } - this->unk_15C = 0; + pthis->unk_15C = 0; break; case 2: if (D_80B7E084 == 0) { @@ -4940,7 +4940,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { } else if (sLinkAge == 1) { Message_ContinueTextbox(globalCtx, 0x4092); } - this->unk_15C = 22; + pthis->unk_15C = 22; break; } } @@ -4977,7 +4977,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (D_80B7E07E == 2) { HIGH_SCORE(HS_FISHING) |= 0x80; - this->unk_15C = 0; + pthis->unk_15C = 0; break; } } else { @@ -4986,7 +4986,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (D_80B7E07E == 2) { HIGH_SCORE(HS_FISHING) |= 0x80000000; - this->unk_15C = 0; + pthis->unk_15C = 0; break; } } @@ -5019,16 +5019,16 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { D_80B7A670 = 0.0f; } - this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); - this->unk_15C = 23; + pthis->actor.parent = NULL; + func_8002F434(&pthis->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + pthis->unk_15C = 23; } break; case 20: if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { Message_CloseTextbox(globalCtx); - this->unk_15C = 0; + pthis->unk_15C = 0; } break; @@ -5038,7 +5038,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - this->unk_15C = 0; + pthis->unk_15C = 0; break; case 1: if (D_80B7E084 == 0) { @@ -5046,7 +5046,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { } else if (sLinkAge == 1) { Message_ContinueTextbox(globalCtx, 0x4092); } - this->unk_15C = 22; + pthis->unk_15C = 22; break; } } @@ -5056,7 +5056,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (globalCtx) {} if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { - this->unk_15C = 0; + pthis->unk_15C = 0; if (D_80B7A68C != 0) { D_80B7A688 = 1; D_80B7A68C = 0; @@ -5068,10 +5068,10 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { case 23: D_80B7A674 = false; - if (Actor_HasParent(&this->actor, globalCtx)) { - this->unk_15C = 24; + if (Actor_HasParent(&pthis->actor, globalCtx)) { + pthis->unk_15C = 24; } else { - func_8002F434(&this->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); + func_8002F434(&pthis->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); } break; @@ -5079,10 +5079,10 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { D_80B7A674 = false; if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { if (D_80B7E07C == 0) { - this->unk_15C = 0; + pthis->unk_15C = 0; } else { Message_StartTextbox(globalCtx, 0x409C, NULL); - this->unk_15C = 20; + pthis->unk_15C = 20; } } break; @@ -5102,7 +5102,7 @@ static Vec3s sSinkingLureLocationPos[] = { void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; Vec3f sp114; Vec3f sp108; Vec3f spFC; @@ -5134,16 +5134,16 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.shape.shadowAlpha = playerShadowAlpha; - SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&pthis->skelAnime); if ((D_80B7A684 != 0) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { - this->actor.flags &= ~ACTOR_FLAG_0; + pthis->actor.flags &= ~ACTOR_FLAG_0; } else { - this->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_5; + pthis->actor.flags |= ACTOR_FLAG_0 | ACTOR_FLAG_5; } - if ((this->actor.xzDistToPlayer < 120.0f) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { - headRotTarget = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; + if ((pthis->actor.xzDistToPlayer < 120.0f) || (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE)) { + headRotTarget = pthis->actor.shape.rot.y - pthis->actor.yawTowardsPlayer; } else { headRotTarget = 0; } @@ -5154,16 +5154,16 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { headRotTarget = -0x2710; } - Math_ApproachS(&this->unk_164, headRotTarget, 3, 0x1388); + Math_ApproachS(&pthis->unk_164, headRotTarget, 3, 0x1388); if (((globalCtx->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { - this->unk_162 = 4; + pthis->unk_162 = 4; } - this->unk_160 = D_80B7AFC4[this->unk_162]; + pthis->unk_160 = D_80B7AFC4[pthis->unk_162]; - if (this->unk_162 != 0) { - this->unk_162--; + if (pthis->unk_162 != 0) { + pthis->unk_162--; } if (D_80B7A684 != 0) { @@ -5201,16 +5201,16 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } } - Fishing_HandleOwnerDialog(this, globalCtx); + Fishing_HandleOwnerDialog(pthis, globalCtx); D_80B7E14C = 0.0015f; D_80B7A680++; if ((D_80B7E0AC != 0) && D_80B7A674) { - Fishing_UpdateLure(this, globalCtx); + Fishing_UpdateLure(pthis, globalCtx); } - Fishing_UpdateEffects(globalCtx->specialEffects, globalCtx); + Fishing_UpdateEffects((FishingEffect*)globalCtx->specialEffects, globalCtx); Fishing_UpdatePondProps(globalCtx); Fishing_UpdateGroupFishes(globalCtx); @@ -5389,7 +5389,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sCameraId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); Gameplay_ChangeCameraStatus(globalCtx, sCameraId, CAM_STAT_ACTIVE); - func_8002DF54(globalCtx, &this->actor, 5); + func_8002DF54(globalCtx, &pthis->actor, 5); camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; @@ -5415,7 +5415,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camera->at = sCameraAt; func_800C08AC(globalCtx, sCameraId, 0); func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); D_80B7A6CC = 0; sCameraId = 0; D_80B7A6D0 = 30; @@ -5431,7 +5431,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sCameraId = Gameplay_CreateSubCamera(globalCtx); Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); Gameplay_ChangeCameraStatus(globalCtx, sCameraId, CAM_STAT_ACTIVE); - func_8002DF54(globalCtx, &this->actor, 5); + func_8002DF54(globalCtx, &pthis->actor, 5); camera = Gameplay_GetCamera(globalCtx, MAIN_CAM); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; @@ -5450,7 +5450,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((D_80B7A6D0 == 0) && Message_ShouldAdvance(globalCtx)) { D_80B7A6CC = 22; D_80B7A6D0 = 40; - func_8002DF54(globalCtx, &this->actor, 0x1C); + func_8002DF54(globalCtx, &pthis->actor, 0x1C); D_80B7FEE4 = 0.0f; } break; @@ -5519,7 +5519,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camera->at = sCameraAt; func_800C08AC(globalCtx, sCameraId, 0); func_80064534(globalCtx, &globalCtx->csCtx); - func_8002DF54(globalCtx, &this->actor, 7); + func_8002DF54(globalCtx, &pthis->actor, 7); D_80B7A6CC = 0; sCameraId = 0; player->unk_860 = -5; @@ -5562,7 +5562,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { pos.x = Rand_CenteredFloat(20.0f) + player->actor.world.pos.x; pos.z = Rand_CenteredFloat(20.0f) + player->actor.world.pos.z; pos.y = player->actor.floorHeight + 5.0f; - Fishing_SpawnWaterDust(NULL, globalCtx->specialEffects, &pos, 0.5f); + Fishing_SpawnWaterDust(NULL, (FishingEffect*)globalCtx->specialEffects, &pos, 0.5f); } if ((player->actor.floorHeight < WATER_SURFACE_Y(globalCtx)) && @@ -5587,7 +5587,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { pos.x += 2.0f * vel.x; pos.y = WATER_SURFACE_Y(globalCtx); pos.z += 2.0f * vel.z; - Fishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &pos, &vel, Rand_ZeroFloat(0.01f) + 0.020000001f); + Fishing_SpawnDustSplash(NULL, (FishingEffect*)globalCtx->specialEffects, &pos, &vel, Rand_ZeroFloat(0.01f) + 0.020000001f); } } @@ -5689,7 +5689,7 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (projectedPos.z < 0.0f) { i--; } else { - Fishing_SpawnRainDrop(globalCtx->specialEffects, &pos, &rot); + Fishing_SpawnRainDrop((FishingEffect*)globalCtx->specialEffects, &pos, &rot); } } } @@ -5712,10 +5712,10 @@ void Fishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { s32 Fishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; if (limbIndex == 8) { // Head - rot->x -= this->unk_164; + rot->x -= pthis->unk_164; } return 0; @@ -5744,7 +5744,7 @@ static void* sFishingOwnerEyeTexs[] = { void Fishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - Fishing* this = (Fishing*)thisx; + Fishing* pthis = (Fishing*)thisx; Input* input = &globalCtx->state.input[0]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_fishing.c", 9156); @@ -5752,17 +5752,17 @@ void Fishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); func_80093D84(globalCtx->state.gfxCtx); - if ((this->actor.projectedPos.z < 1500.0f) && - (fabsf(this->actor.projectedPos.x) < (100.0f + this->actor.projectedPos.z))) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFishingOwnerEyeTexs[this->unk_160])); + if ((pthis->actor.projectedPos.z < 1500.0f) && + (fabsf(pthis->actor.projectedPos.x) < (100.0f + pthis->actor.projectedPos.z))) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFishingOwnerEyeTexs[pthis->unk_160])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, Fishing_OwnerOverrideLimbDraw, Fishing_OwnerPostLimbDraw, - this); + SkelAnime_DrawFlexOpa(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, + pthis->skelAnime.dListCount, Fishing_OwnerOverrideLimbDraw, Fishing_OwnerPostLimbDraw, + pthis); } Fishing_DrawPondProps(globalCtx); - Fishing_DrawEffects(globalCtx->specialEffects, globalCtx); + Fishing_DrawEffects((FishingEffect*)globalCtx->specialEffects, globalCtx); Fishing_DrawGroupFishes(globalCtx); Fishing_DrawStreamSplash(globalCtx); diff --git a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.cpp similarity index 69% rename from src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c rename to src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.cpp index c1b3b4707..86abd26a5 100644 --- a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.cpp @@ -20,9 +20,9 @@ void ItemBHeart_Destroy(Actor* thisx, GlobalContext* globalCtx); void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx); void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B85264(ItemBHeart* this, GlobalContext* globalCtx); +void func_80B85264(ItemBHeart* pthis, GlobalContext* globalCtx); -const ActorInit Item_B_Heart_InitVars = { +ActorInit Item_B_Heart_InitVars = { ACTOR_ITEM_B_HEART, ACTORCAT_MISC, FLAGS, @@ -42,13 +42,13 @@ static InitChainEntry sInitChain[] = { }; void ItemBHeart_Init(Actor* thisx, GlobalContext* globalCtx) { - ItemBHeart* this = (ItemBHeart*)thisx; + ItemBHeart* pthis = (ItemBHeart*)thisx; if (Flags_GetCollectible(globalCtx, 0x1F)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.8f); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.8f); } } @@ -56,33 +56,33 @@ void ItemBHeart_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx) { - ItemBHeart* this = (ItemBHeart*)thisx; + ItemBHeart* pthis = (ItemBHeart*)thisx; - func_80B85264(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (Actor_HasParent(&this->actor, globalCtx)) { + func_80B85264(pthis, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 0.0f, 0.0f, 0.0f, 4); + if (Actor_HasParent(&pthis->actor, globalCtx)) { Flags_SetCollectible(globalCtx, 0x1F); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - func_8002F434(&this->actor, globalCtx, GI_HEART_CONTAINER_2, 30.0f, 40.0f); + func_8002F434(&pthis->actor, globalCtx, GI_HEART_CONTAINER_2, 30.0f, 40.0f); } } -void func_80B85264(ItemBHeart* this, GlobalContext* globalCtx) { +void func_80B85264(ItemBHeart* pthis, GlobalContext* globalCtx) { f32 yOffset; - this->unk_164++; - yOffset = (Math_SinS(this->unk_164 * 0x60C) * 5.0f) + 20.0f; - Math_ApproachF(&this->actor.world.pos.y, this->actor.home.pos.y + yOffset, 0.1f, this->unk_158); - Math_ApproachF(&this->unk_158, 2.0f, 1.0f, 0.1f); - this->actor.shape.rot.y += 0x400; + pthis->unk_164++; + yOffset = (Math_SinS(pthis->unk_164 * 0x60C) * 5.0f) + 20.0f; + Math_ApproachF(&pthis->actor.world.pos.y, pthis->actor.home.pos.y + yOffset, 0.1f, pthis->unk_158); + Math_ApproachF(&pthis->unk_158, 2.0f, 1.0f, 0.1f); + pthis->actor.shape.rot.y += 0x400; - Math_ApproachF(&this->actor.scale.x, 0.4f, 0.1f, 0.01f); - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; + Math_ApproachF(&pthis->actor.scale.x, 0.4f, 0.1f, 0.01f); + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; } void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) { - ItemBHeart* this = (ItemBHeart*)thisx; + ItemBHeart* pthis = (ItemBHeart*)thisx; Actor* actorIt; u8 flag = false; @@ -91,7 +91,7 @@ void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) { actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; while (actorIt != NULL) { - if ((actorIt->id == ACTOR_DOOR_WARP1) && (actorIt->projectedPos.z > this->actor.projectedPos.z)) { + if ((actorIt->id == ACTOR_DOOR_WARP1) && (actorIt->projectedPos.z > pthis->actor.projectedPos.z)) { flag = true; break; } diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c deleted file mode 100644 index f809da699..000000000 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ /dev/null @@ -1,225 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ITEM_ETCETERA_Z_ITEM_ETCETERA_C -#include "actor_common.h" -/* - * File: z_item_etcetera.c - * Overlay: ovl_Item_Etcetera - * Description: Collectible Items - */ - -#include "z_item_etcetera.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_draw.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_scene.h" - -#define FLAGS ACTOR_FLAG_4 - -void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B857D0(ItemEtcetera* this, GlobalContext* globalCtx); -void func_80B85824(ItemEtcetera* this, GlobalContext* globalCtx); -void func_80B858B4(ItemEtcetera* this, GlobalContext* globalCtx); -void ItemEtcetera_SpawnSparkles(ItemEtcetera* this, GlobalContext* globalCtx); -void ItemEtcetera_MoveFireArrowDown(ItemEtcetera* this, GlobalContext* globalCtx); -void func_80B85B28(ItemEtcetera* this, GlobalContext* globalCtx); -void ItemEtcetera_UpdateFireArrow(ItemEtcetera* this, GlobalContext* globalCtx); - -const ActorInit Item_Etcetera_InitVars = { - ACTOR_ITEM_ETCETERA, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ItemEtcetera), - (ActorFunc)ItemEtcetera_Init, - (ActorFunc)ItemEtcetera_Destroy, - (ActorFunc)ItemEtcetera_Update, - NULL, -}; - -static s16 sObjectIds[] = { - OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE_LETTER, OBJECT_GI_SHIELD_2, OBJECT_GI_ARROWCASE, OBJECT_GI_SCALE, - OBJECT_GI_SCALE, OBJECT_GI_KEY, OBJECT_GI_M_ARROW, OBJECT_GI_RUPY, OBJECT_GI_RUPY, - OBJECT_GI_RUPY, OBJECT_GI_RUPY, OBJECT_GI_HEARTS, OBJECT_GI_KEY, -}; - -// Indexes passed to the item table in z_draw.c -static s16 sDrawItemIndexes[] = { - GID_BOTTLE, GID_LETTER_RUTO, GID_SHIELD_HYLIAN, GID_QUIVER_40, GID_SCALE_SILVER, - GID_SCALE_GOLDEN, GID_KEY_SMALL, GID_ARROW_FIRE, GID_RUPEE_GREEN, GID_RUPEE_BLUE, - GID_RUPEE_RED, GID_RUPEE_PURPLE, GID_HEART_PIECE, GID_KEY_SMALL, -}; - -static s16 sGetItemIds[] = { - GI_BOTTLE, GI_LETTER_RUTO, GI_SHIELD_HYLIAN, GI_QUIVER_40, GI_SCALE_SILVER, GI_SCALE_GOLD, GI_KEY_SMALL, - GI_ARROW_FIRE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, -}; - -void ItemEtcetera_SetupAction(ItemEtcetera* this, ItemEtceteraActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { - ItemEtcetera* this = (ItemEtcetera*)thisx; - s32 pad; - s32 type; - s32 objBankIndex; - - type = this->actor.params & 0xFF; - osSyncPrintf("no = %d\n", type); - objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[type]); - osSyncPrintf("bank_ID = %d\n", objBankIndex); - if (objBankIndex < 0) { - ASSERT(0, "0", "../z_item_etcetera.c", 241); - } else { - this->objBankIndex = objBankIndex; - } - this->giDrawId = sDrawItemIndexes[type]; - this->getItemId = sGetItemIds[type]; - this->futureActionFunc = func_80B85824; - this->drawFunc = ItemEtcetera_Draw; - Actor_SetScale(&this->actor, 0.25f); - ItemEtcetera_SetupAction(this, func_80B857D0); - switch (type) { - case ITEM_ETC_LETTER: - Actor_SetScale(&this->actor, 0.5f); - this->futureActionFunc = func_80B858B4; - if (gSaveContext.eventChkInf[3] & 2) { - Actor_Kill(&this->actor); - } - break; - case ITEM_ETC_ARROW_FIRE: - this->futureActionFunc = ItemEtcetera_UpdateFireArrow; - Actor_SetScale(&this->actor, 0.5f); - this->actor.draw = NULL; - this->actor.shape.yOffset = 50.0f; - break; - case ITEM_ETC_RUPEE_GREEN_CHEST_GAME: - case ITEM_ETC_RUPEE_BLUE_CHEST_GAME: - case ITEM_ETC_RUPEE_RED_CHEST_GAME: - case ITEM_ETC_RUPEE_PURPLE_CHEST_GAME: - case ITEM_ETC_HEART_PIECE_CHEST_GAME: - case ITEM_ETC_KEY_SMALL_CHEST_GAME: - Actor_SetScale(&this->actor, 0.5f); - this->futureActionFunc = func_80B85B28; - this->drawFunc = ItemEtcetera_DrawThroughLens; - this->actor.world.pos.y += 15.0f; - break; - } -} - -void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void func_80B857D0(ItemEtcetera* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { - this->actor.objBankIndex = this->objBankIndex; - this->actor.draw = this->drawFunc; - this->actionFunc = this->futureActionFunc; - } -} - -void func_80B85824(ItemEtcetera* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - if ((this->actor.params & 0xFF) == 1) { - gSaveContext.eventChkInf[3] |= 2; - Flags_SetSwitch(globalCtx, 0xB); - } - Actor_Kill(&this->actor); - } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); - } -} - -void func_80B858B4(ItemEtcetera* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - if ((this->actor.params & 0xFF) == 1) { - gSaveContext.eventChkInf[3] |= 2; - Flags_SetSwitch(globalCtx, 0xB); - } - Actor_Kill(&this->actor); - } else { - if (0) {} // Necessary to match - func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); - if ((globalCtx->gameplayFrames & 0xD) == 0) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); - } - } -} - -void ItemEtcetera_SpawnSparkles(ItemEtcetera* this, GlobalContext* globalCtx) { - static Vec3f velocity = { 0.0f, 0.2f, 0.0f }; - static Vec3f accel = { 0.0f, 0.05f, 0.0f }; - static Color_RGBA8 primColor = { 255, 255, 255, 0 }; - static Color_RGBA8 envColor = { 255, 50, 50, 0 }; - Vec3f pos; - - velocity.x = Rand_CenteredFloat(3.0f); - velocity.z = Rand_CenteredFloat(3.0f); - velocity.y = -0.05f; - accel.y = -0.025f; - pos.x = Rand_CenteredFloat(12.0f) + this->actor.world.pos.x; - pos.y = (Rand_ZeroOne() * 6.0f) + this->actor.world.pos.y; - pos.z = Rand_CenteredFloat(12.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 5000, 16); -} - -void ItemEtcetera_MoveFireArrowDown(ItemEtcetera* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); - Actor_MoveForward(&this->actor); - if (!(this->actor.bgCheckFlags & 1)) { - ItemEtcetera_SpawnSparkles(this, globalCtx); - } - this->actor.shape.rot.y += 0x400; - func_80B85824(this, globalCtx); -} - -void func_80B85B28(ItemEtcetera* this, GlobalContext* globalCtx) { - if (Flags_GetTreasure(globalCtx, (this->actor.params >> 8) & 0x1F)) { - Actor_Kill(&this->actor); - } -} - -void ItemEtcetera_UpdateFireArrow(ItemEtcetera* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[0] != NULL)) { - LOG_NUM("(game_play->demo_play.npcdemopnt[0]->dousa)", globalCtx->csCtx.npcActions[0]->action, - "../z_item_etcetera.c", 441); - if (globalCtx->csCtx.npcActions[0]->action == 2) { - this->actor.draw = ItemEtcetera_Draw; - this->actor.gravity = -0.1f; - this->actor.minVelocityY = -4.0f; - this->actionFunc = ItemEtcetera_MoveFireArrowDown; - } - } else { - this->actor.gravity = -0.1f; - this->actor.minVelocityY = -4.0f; - this->actionFunc = ItemEtcetera_MoveFireArrowDown; - } -} - -void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { - ItemEtcetera* this = (ItemEtcetera*)thisx; - this->actionFunc(this, globalCtx); -} - -void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx) { - ItemEtcetera* this = (ItemEtcetera*)thisx; - if (globalCtx->actorCtx.unk_03 != 0) { - func_8002EBCC(&this->actor, globalCtx, 0); - func_8002ED80(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, this->giDrawId); - } -} - -void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx) { - ItemEtcetera* this = (ItemEtcetera*)thisx; - - func_8002EBCC(&this->actor, globalCtx, 0); - func_8002ED80(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, this->giDrawId); -} diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.cpp b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.cpp new file mode 100644 index 000000000..573ae0dcb --- /dev/null +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.cpp @@ -0,0 +1,225 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ITEM_ETCETERA_Z_ITEM_ETCETERA_C +#include "actor_common.h" +/* + * File: z_item_etcetera.c + * Overlay: ovl_Item_Etcetera + * Description: Collectible Items + */ + +#include "z_item_etcetera.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_draw.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_scene.h" + +#define FLAGS ACTOR_FLAG_4 + +void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); +void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); +void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx); +void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B857D0(ItemEtcetera* pthis, GlobalContext* globalCtx); +void func_80B85824(ItemEtcetera* pthis, GlobalContext* globalCtx); +void func_80B858B4(ItemEtcetera* pthis, GlobalContext* globalCtx); +void ItemEtcetera_SpawnSparkles(ItemEtcetera* pthis, GlobalContext* globalCtx); +void ItemEtcetera_MoveFireArrowDown(ItemEtcetera* pthis, GlobalContext* globalCtx); +void func_80B85B28(ItemEtcetera* pthis, GlobalContext* globalCtx); +void ItemEtcetera_UpdateFireArrow(ItemEtcetera* pthis, GlobalContext* globalCtx); + +ActorInit Item_Etcetera_InitVars = { + ACTOR_ITEM_ETCETERA, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ItemEtcetera), + (ActorFunc)ItemEtcetera_Init, + (ActorFunc)ItemEtcetera_Destroy, + (ActorFunc)ItemEtcetera_Update, + NULL, +}; + +static s16 sObjectIds[] = { + OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE_LETTER, OBJECT_GI_SHIELD_2, OBJECT_GI_ARROWCASE, OBJECT_GI_SCALE, + OBJECT_GI_SCALE, OBJECT_GI_KEY, OBJECT_GI_M_ARROW, OBJECT_GI_RUPY, OBJECT_GI_RUPY, + OBJECT_GI_RUPY, OBJECT_GI_RUPY, OBJECT_GI_HEARTS, OBJECT_GI_KEY, +}; + +// Indexes passed to the item table in z_draw.c +static s16 sDrawItemIndexes[] = { + GID_BOTTLE, GID_LETTER_RUTO, GID_SHIELD_HYLIAN, GID_QUIVER_40, GID_SCALE_SILVER, + GID_SCALE_GOLDEN, GID_KEY_SMALL, GID_ARROW_FIRE, GID_RUPEE_GREEN, GID_RUPEE_BLUE, + GID_RUPEE_RED, GID_RUPEE_PURPLE, GID_HEART_PIECE, GID_KEY_SMALL, +}; + +static s16 sGetItemIds[] = { + GI_BOTTLE, GI_LETTER_RUTO, GI_SHIELD_HYLIAN, GI_QUIVER_40, GI_SCALE_SILVER, GI_SCALE_GOLD, GI_KEY_SMALL, + GI_ARROW_FIRE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, +}; + +void ItemEtcetera_SetupAction(ItemEtcetera* pthis, ItemEtceteraActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* pthis = (ItemEtcetera*)thisx; + s32 pad; + s32 type; + s32 objBankIndex; + + type = pthis->actor.params & 0xFF; + osSyncPrintf("no = %d\n", type); + objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[type]); + osSyncPrintf("bank_ID = %d\n", objBankIndex); + if (objBankIndex < 0) { + ASSERT(0, "0", "../z_item_etcetera.c", 241); + } else { + pthis->objBankIndex = objBankIndex; + } + pthis->giDrawId = sDrawItemIndexes[type]; + pthis->getItemId = sGetItemIds[type]; + pthis->futureActionFunc = func_80B85824; + pthis->drawFunc = ItemEtcetera_Draw; + Actor_SetScale(&pthis->actor, 0.25f); + ItemEtcetera_SetupAction(pthis, func_80B857D0); + switch (type) { + case ITEM_ETC_LETTER: + Actor_SetScale(&pthis->actor, 0.5f); + pthis->futureActionFunc = func_80B858B4; + if (gSaveContext.eventChkInf[3] & 2) { + Actor_Kill(&pthis->actor); + } + break; + case ITEM_ETC_ARROW_FIRE: + pthis->futureActionFunc = ItemEtcetera_UpdateFireArrow; + Actor_SetScale(&pthis->actor, 0.5f); + pthis->actor.draw = NULL; + pthis->actor.shape.yOffset = 50.0f; + break; + case ITEM_ETC_RUPEE_GREEN_CHEST_GAME: + case ITEM_ETC_RUPEE_BLUE_CHEST_GAME: + case ITEM_ETC_RUPEE_RED_CHEST_GAME: + case ITEM_ETC_RUPEE_PURPLE_CHEST_GAME: + case ITEM_ETC_HEART_PIECE_CHEST_GAME: + case ITEM_ETC_KEY_SMALL_CHEST_GAME: + Actor_SetScale(&pthis->actor, 0.5f); + pthis->futureActionFunc = func_80B85B28; + pthis->drawFunc = ItemEtcetera_DrawThroughLens; + pthis->actor.world.pos.y += 15.0f; + break; + } +} + +void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80B857D0(ItemEtcetera* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objBankIndex)) { + pthis->actor.objBankIndex = pthis->objBankIndex; + pthis->actor.draw = pthis->drawFunc; + pthis->actionFunc = pthis->futureActionFunc; + } +} + +void func_80B85824(ItemEtcetera* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + if ((pthis->actor.params & 0xFF) == 1) { + gSaveContext.eventChkInf[3] |= 2; + Flags_SetSwitch(globalCtx, 0xB); + } + Actor_Kill(&pthis->actor); + } else { + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 30.0f, 50.0f); + } +} + +void func_80B858B4(ItemEtcetera* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + if ((pthis->actor.params & 0xFF) == 1) { + gSaveContext.eventChkInf[3] |= 2; + Flags_SetSwitch(globalCtx, 0xB); + } + Actor_Kill(&pthis->actor); + } else { + if (0) {} // Necessary to match + func_8002F434(&pthis->actor, globalCtx, pthis->getItemId, 30.0f, 50.0f); + if ((globalCtx->gameplayFrames & 0xD) == 0) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); + } + } +} + +void ItemEtcetera_SpawnSparkles(ItemEtcetera* pthis, GlobalContext* globalCtx) { + static Vec3f velocity = { 0.0f, 0.2f, 0.0f }; + static Vec3f accel = { 0.0f, 0.05f, 0.0f }; + static Color_RGBA8 primColor = { 255, 255, 255, 0 }; + static Color_RGBA8 envColor = { 255, 50, 50, 0 }; + Vec3f pos; + + velocity.x = Rand_CenteredFloat(3.0f); + velocity.z = Rand_CenteredFloat(3.0f); + velocity.y = -0.05f; + accel.y = -0.025f; + pos.x = Rand_CenteredFloat(12.0f) + pthis->actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 6.0f) + pthis->actor.world.pos.y; + pos.z = Rand_CenteredFloat(12.0f) + pthis->actor.world.pos.z; + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 5000, 16); +} + +void ItemEtcetera_MoveFireArrowDown(ItemEtcetera* pthis, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 0.0f, 5); + Actor_MoveForward(&pthis->actor); + if (!(pthis->actor.bgCheckFlags & 1)) { + ItemEtcetera_SpawnSparkles(pthis, globalCtx); + } + pthis->actor.shape.rot.y += 0x400; + func_80B85824(pthis, globalCtx); +} + +void func_80B85B28(ItemEtcetera* pthis, GlobalContext* globalCtx) { + if (Flags_GetTreasure(globalCtx, (pthis->actor.params >> 8) & 0x1F)) { + Actor_Kill(&pthis->actor); + } +} + +void ItemEtcetera_UpdateFireArrow(ItemEtcetera* pthis, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[0] != NULL)) { + LOG_NUM("(game_play->demo_play.npcdemopnt[0]->dousa)", globalCtx->csCtx.npcActions[0]->action, + "../z_item_etcetera.c", 441); + if (globalCtx->csCtx.npcActions[0]->action == 2) { + pthis->actor.draw = ItemEtcetera_Draw; + pthis->actor.gravity = -0.1f; + pthis->actor.minVelocityY = -4.0f; + pthis->actionFunc = ItemEtcetera_MoveFireArrowDown; + } + } else { + pthis->actor.gravity = -0.1f; + pthis->actor.minVelocityY = -4.0f; + pthis->actionFunc = ItemEtcetera_MoveFireArrowDown; + } +} + +void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* pthis = (ItemEtcetera*)thisx; + pthis->actionFunc(pthis, globalCtx); +} + +void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* pthis = (ItemEtcetera*)thisx; + if (globalCtx->actorCtx.unk_03 != 0) { + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); + GetItem_Draw(globalCtx, pthis->giDrawId); + } +} + +void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* pthis = (ItemEtcetera*)thisx; + + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); + GetItem_Draw(globalCtx, pthis->giDrawId); +} diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.cpp similarity index 62% rename from src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c rename to src/overlays/actors/ovl_Item_Inbox/z_item_inbox.cpp index 2b1a38c5d..8645c0aa0 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.cpp @@ -17,9 +17,9 @@ void ItemInbox_Destroy(Actor* thisx, GlobalContext* globalCtx); void ItemInbox_Update(Actor* thisx, GlobalContext* globalCtx); void ItemInbox_Draw(Actor* thisx, GlobalContext* globalCtx); -void ItemInbox_Wait(ItemInbox* this, GlobalContext* globalCtx); +void ItemInbox_Wait(ItemInbox* pthis, GlobalContext* globalCtx); -const ActorInit Item_Inbox_InitVars = { +ActorInit Item_Inbox_InitVars = { ACTOR_ITEM_INBOX, ACTORCAT_NPC, FLAGS, @@ -32,31 +32,31 @@ const ActorInit Item_Inbox_InitVars = { }; void ItemInbox_Init(Actor* thisx, GlobalContext* globalCtx) { - ItemInbox* this = (ItemInbox*)thisx; + ItemInbox* pthis = (ItemInbox*)thisx; - this->actionFunc = ItemInbox_Wait; - Actor_SetScale(&this->actor, 0.2); + pthis->actionFunc = ItemInbox_Wait; + Actor_SetScale(&pthis->actor, 0.2); } void ItemInbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void ItemInbox_Wait(ItemInbox* this, GlobalContext* globalCtx) { - if (Flags_GetTreasure(globalCtx, (this->actor.params >> 8) & 0x1F)) { - Actor_Kill(&this->actor); +void ItemInbox_Wait(ItemInbox* pthis, GlobalContext* globalCtx) { + if (Flags_GetTreasure(globalCtx, (pthis->actor.params >> 8) & 0x1F)) { + Actor_Kill(&pthis->actor); } } void ItemInbox_Update(Actor* thisx, GlobalContext* globalCtx) { - ItemInbox* this = (ItemInbox*)thisx; + ItemInbox* pthis = (ItemInbox*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void ItemInbox_Draw(Actor* thisx, GlobalContext* globalCtx) { - ItemInbox* this = (ItemInbox*)thisx; + ItemInbox* pthis = (ItemInbox*)thisx; - func_8002EBCC(&this->actor, globalCtx, 0); - func_8002ED80(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, this->actor.params & 0xFF); + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); + GetItem_Draw(globalCtx, pthis->actor.params & 0xFF); } diff --git a/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c b/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c deleted file mode 100644 index 8dcfa1503..000000000 --- a/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c +++ /dev/null @@ -1,209 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ITEM_OCARINA_Z_ITEM_OCARINA_C -#include "actor_common.h" -/* - * File: z_item_ocarina.c - * Overlay: ovl_Item_Ocarina - * Description: Ocarina of Time - */ - -#include "z_item_ocarina.h" -#include "scenes/overworld/spot00/spot00_scene.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_draw.h" -#include "def/z_effect_soft_sprite_old_init.h" - -#define FLAGS ACTOR_FLAG_4 - -void ItemOcarina_Init(Actor* thisx, GlobalContext* globalCtx); -void ItemOcarina_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ItemOcarina_Update(Actor* thisx, GlobalContext* globalCtx); -void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ItemOcarina_GetThrown(ItemOcarina* this, GlobalContext* globalCtx); -void ItemOcarina_Fly(ItemOcarina* this, GlobalContext* globalCtx); -void ItemOcarina_WaitInWater(ItemOcarina* this, GlobalContext* globalCtx); -void ItemOcarina_StartSoTCutscene(ItemOcarina* this, GlobalContext* globalCtx); -void func_80B864EC(ItemOcarina* this, GlobalContext* globalCtx); -void func_80B865E0(ItemOcarina* this, GlobalContext* globalCtx); -void ItemOcarina_DoNothing(ItemOcarina* this, GlobalContext* globalCtx); - -const ActorInit Item_Ocarina_InitVars = { - ACTOR_ITEM_OCARINA, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GI_OCARINA, - sizeof(ItemOcarina), - (ActorFunc)ItemOcarina_Init, - (ActorFunc)ItemOcarina_Destroy, - (ActorFunc)ItemOcarina_Update, - (ActorFunc)ItemOcarina_Draw, -}; - -void ItemOcarina_SetupAction(ItemOcarina* this, ItemOcarinaActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void ItemOcarina_Init(Actor* thisx, GlobalContext* globalCtx) { - ItemOcarina* this = (ItemOcarina*)thisx; - s32 params = thisx->params; - - ActorShape_Init(&this->actor.shape, 0, 0, 0); - Actor_SetScale(&this->actor, 0.1f); - - switch (params) { - case 0: - ItemOcarina_SetupAction(this, ItemOcarina_GetThrown); - break; - case 1: - ItemOcarina_SetupAction(this, func_80B865E0); - break; - case 2: - ItemOcarina_SetupAction(this, ItemOcarina_DoNothing); - break; - case 3: - ItemOcarina_SetupAction(this, ItemOcarina_WaitInWater); - if (!(gSaveContext.eventChkInf[8] & 1) || (gSaveContext.eventChkInf[4] & 8)) { - Actor_Kill(thisx); - return; - } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ELF_MSG2, 299.0f, -140.0f, 884.0f, 0, 4, 1, 0x3800); - Actor_SetScale(thisx, 0.2f); - break; - default: - Actor_Kill(thisx); - return; - } - - LOG_NUM("no", params, "../z_item_ocarina.c", 210); - this->spinRotOffset = 0x400; -} - -void ItemOcarina_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void ItemOcarina_Fly(ItemOcarina* this, GlobalContext* globalCtx) { - Vec3f ripplePos; - - func_8002D7EC(&this->actor); - this->actor.shape.rot.x += this->spinRotOffset * 2; - this->actor.shape.rot.y += this->spinRotOffset * 3; - - if (this->actor.minVelocityY < this->actor.velocity.y) { - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } - } - - if (globalCtx->csCtx.frames == 881) { - this->actor.world.pos.x = 250.0f; - this->actor.world.pos.y = 60.0f; - this->actor.world.pos.z = 1075.0f; - this->actor.velocity.x = 1.0f; - this->actor.velocity.y = -5.0f; - this->actor.velocity.z = -7.0f; - } - - if (globalCtx->csCtx.frames == 897) { - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 100, 500, 0); - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, 0, 0, 1, 0); - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.gravity = -0.1f; - this->actor.minVelocityY = -0.5f; - this->spinRotOffset = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER); - } - - // landed in water - if (globalCtx->csCtx.frames == 906) { - ripplePos.x = 274.0f; - ripplePos.y = -60.0f; - ripplePos.z = 907.0f; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 0); - } -} - -void ItemOcarina_GetThrown(ItemOcarina* this, GlobalContext* globalCtx) { - this->actor.gravity = -0.3f; - this->actor.minVelocityY = -5.0f; - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 6.0f; - this->actor.velocity.z = 0.0f; - ItemOcarina_SetupAction(this, ItemOcarina_Fly); -} - -void func_80B864EC(ItemOcarina* this, GlobalContext* globalCtx) { - func_8002D7EC(&this->actor); - this->actor.shape.rot.x += this->spinRotOffset * 2; - this->actor.shape.rot.y += this->spinRotOffset * 3; - - if (this->actor.minVelocityY < this->actor.velocity.y) { - this->actor.velocity.y += this->actor.gravity; - - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } - } - - if (globalCtx->csCtx.frames == 220) { - this->actor.world.pos.x = 144.0f; - this->actor.world.pos.y = 80.0f; - this->actor.world.pos.z = 1686.0f; - this->actor.velocity.x = 1.0f; - this->actor.velocity.y = 2.0f; - this->actor.velocity.z = -7.0f; - this->actor.gravity = -0.15f; - this->actor.minVelocityY = -5.0f; - } -} - -void func_80B865E0(ItemOcarina* this, GlobalContext* globalCtx) { - this->actor.gravity = -0.3f; - this->actor.minVelocityY = -5.0f; - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 4.0f; - this->actor.velocity.z = 6.0f; - ItemOcarina_SetupAction(this, func_80B864EC); -} - -void ItemOcarina_DoNothing(ItemOcarina* this, GlobalContext* globalCtx) { -} - -void ItemOcarina_StartSoTCutscene(ItemOcarina* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gHyruleFieldZeldaSongOfTimeCs); - gSaveContext.cutsceneTrigger = 1; - } -} - -void ItemOcarina_WaitInWater(ItemOcarina* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - gSaveContext.eventChkInf[4] |= 8; - Flags_SetSwitch(globalCtx, 3); - this->actionFunc = ItemOcarina_StartSoTCutscene; - this->actor.draw = NULL; - } else { - func_8002F434(&this->actor, globalCtx, GI_OCARINA_OOT, 30.0f, 50.0f); - - if ((globalCtx->gameplayFrames & 13) == 0) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); - } - } -} - -void ItemOcarina_Update(Actor* thisx, GlobalContext* globalCtx) { - ItemOcarina* this = (ItemOcarina*)thisx; - - this->actionFunc(this, globalCtx); -} - -void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx) { - ItemOcarina* this = (ItemOcarina*)thisx; - - func_8002EBCC(thisx, globalCtx, 0); - func_8002ED80(thisx, globalCtx, 0); - GetItem_Draw(globalCtx, GID_OCARINA_TIME); -} diff --git a/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.cpp b/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.cpp new file mode 100644 index 000000000..147f930f9 --- /dev/null +++ b/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.cpp @@ -0,0 +1,209 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ITEM_OCARINA_Z_ITEM_OCARINA_C +#include "actor_common.h" +/* + * File: z_item_ocarina.c + * Overlay: ovl_Item_Ocarina + * Description: Ocarina of Time + */ + +#include "z_item_ocarina.h" +#include "scenes/overworld/spot00/spot00_scene.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_draw.h" +#include "def/z_effect_soft_sprite_old_init.h" + +#define FLAGS ACTOR_FLAG_4 + +void ItemOcarina_Init(Actor* thisx, GlobalContext* globalCtx); +void ItemOcarina_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ItemOcarina_Update(Actor* thisx, GlobalContext* globalCtx); +void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ItemOcarina_GetThrown(ItemOcarina* pthis, GlobalContext* globalCtx); +void ItemOcarina_Fly(ItemOcarina* pthis, GlobalContext* globalCtx); +void ItemOcarina_WaitInWater(ItemOcarina* pthis, GlobalContext* globalCtx); +void ItemOcarina_StartSoTCutscene(ItemOcarina* pthis, GlobalContext* globalCtx); +void func_80B864EC(ItemOcarina* pthis, GlobalContext* globalCtx); +void func_80B865E0(ItemOcarina* pthis, GlobalContext* globalCtx); +void ItemOcarina_DoNothing(ItemOcarina* pthis, GlobalContext* globalCtx); + +ActorInit Item_Ocarina_InitVars = { + ACTOR_ITEM_OCARINA, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GI_OCARINA, + sizeof(ItemOcarina), + (ActorFunc)ItemOcarina_Init, + (ActorFunc)ItemOcarina_Destroy, + (ActorFunc)ItemOcarina_Update, + (ActorFunc)ItemOcarina_Draw, +}; + +void ItemOcarina_SetupAction(ItemOcarina* pthis, ItemOcarinaActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void ItemOcarina_Init(Actor* thisx, GlobalContext* globalCtx) { + ItemOcarina* pthis = (ItemOcarina*)thisx; + s32 params = thisx->params; + + ActorShape_Init(&pthis->actor.shape, 0, 0, 0); + Actor_SetScale(&pthis->actor, 0.1f); + + switch (params) { + case 0: + ItemOcarina_SetupAction(pthis, ItemOcarina_GetThrown); + break; + case 1: + ItemOcarina_SetupAction(pthis, func_80B865E0); + break; + case 2: + ItemOcarina_SetupAction(pthis, ItemOcarina_DoNothing); + break; + case 3: + ItemOcarina_SetupAction(pthis, ItemOcarina_WaitInWater); + if (!(gSaveContext.eventChkInf[8] & 1) || (gSaveContext.eventChkInf[4] & 8)) { + Actor_Kill(thisx); + return; + } + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ELF_MSG2, 299.0f, -140.0f, 884.0f, 0, 4, 1, 0x3800); + Actor_SetScale(thisx, 0.2f); + break; + default: + Actor_Kill(thisx); + return; + } + + LOG_NUM("no", params, "../z_item_ocarina.c", 210); + pthis->spinRotOffset = 0x400; +} + +void ItemOcarina_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ItemOcarina_Fly(ItemOcarina* pthis, GlobalContext* globalCtx) { + Vec3f ripplePos; + + func_8002D7EC(&pthis->actor); + pthis->actor.shape.rot.x += pthis->spinRotOffset * 2; + pthis->actor.shape.rot.y += pthis->spinRotOffset * 3; + + if (pthis->actor.minVelocityY < pthis->actor.velocity.y) { + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } + } + + if (globalCtx->csCtx.frames == 881) { + pthis->actor.world.pos.x = 250.0f; + pthis->actor.world.pos.y = 60.0f; + pthis->actor.world.pos.z = 1075.0f; + pthis->actor.velocity.x = 1.0f; + pthis->actor.velocity.y = -5.0f; + pthis->actor.velocity.z = -7.0f; + } + + if (globalCtx->csCtx.frames == 897) { + EffectSsGRipple_Spawn(globalCtx, &pthis->actor.world.pos, 100, 500, 0); + EffectSsGSplash_Spawn(globalCtx, &pthis->actor.world.pos, 0, 0, 1, 0); + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.velocity.z = 0.0f; + pthis->actor.gravity = -0.1f; + pthis->actor.minVelocityY = -0.5f; + pthis->spinRotOffset = 0; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_BOMB_DROP_WATER); + } + + // landed in water + if (globalCtx->csCtx.frames == 906) { + ripplePos.x = 274.0f; + ripplePos.y = -60.0f; + ripplePos.z = 907.0f; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 0); + } +} + +void ItemOcarina_GetThrown(ItemOcarina* pthis, GlobalContext* globalCtx) { + pthis->actor.gravity = -0.3f; + pthis->actor.minVelocityY = -5.0f; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 6.0f; + pthis->actor.velocity.z = 0.0f; + ItemOcarina_SetupAction(pthis, ItemOcarina_Fly); +} + +void func_80B864EC(ItemOcarina* pthis, GlobalContext* globalCtx) { + func_8002D7EC(&pthis->actor); + pthis->actor.shape.rot.x += pthis->spinRotOffset * 2; + pthis->actor.shape.rot.y += pthis->spinRotOffset * 3; + + if (pthis->actor.minVelocityY < pthis->actor.velocity.y) { + pthis->actor.velocity.y += pthis->actor.gravity; + + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } + } + + if (globalCtx->csCtx.frames == 220) { + pthis->actor.world.pos.x = 144.0f; + pthis->actor.world.pos.y = 80.0f; + pthis->actor.world.pos.z = 1686.0f; + pthis->actor.velocity.x = 1.0f; + pthis->actor.velocity.y = 2.0f; + pthis->actor.velocity.z = -7.0f; + pthis->actor.gravity = -0.15f; + pthis->actor.minVelocityY = -5.0f; + } +} + +void func_80B865E0(ItemOcarina* pthis, GlobalContext* globalCtx) { + pthis->actor.gravity = -0.3f; + pthis->actor.minVelocityY = -5.0f; + pthis->actor.velocity.x = 0.0f; + pthis->actor.velocity.y = 4.0f; + pthis->actor.velocity.z = 6.0f; + ItemOcarina_SetupAction(pthis, func_80B864EC); +} + +void ItemOcarina_DoNothing(ItemOcarina* pthis, GlobalContext* globalCtx) { +} + +void ItemOcarina_StartSoTCutscene(ItemOcarina* pthis, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&pthis->actor, globalCtx)) { + globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gHyruleFieldZeldaSongOfTimeCs); + gSaveContext.cutsceneTrigger = 1; + } +} + +void ItemOcarina_WaitInWater(ItemOcarina* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + gSaveContext.eventChkInf[4] |= 8; + Flags_SetSwitch(globalCtx, 3); + pthis->actionFunc = ItemOcarina_StartSoTCutscene; + pthis->actor.draw = NULL; + } else { + func_8002F434(&pthis->actor, globalCtx, GI_OCARINA_OOT, 30.0f, 50.0f); + + if ((globalCtx->gameplayFrames & 13) == 0) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); + } + } +} + +void ItemOcarina_Update(Actor* thisx, GlobalContext* globalCtx) { + ItemOcarina* pthis = (ItemOcarina*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx) { + ItemOcarina* pthis = (ItemOcarina*)thisx; + + func_8002EBCC(thisx, globalCtx, 0); + func_8002ED80(thisx, globalCtx, 0); + GetItem_Draw(globalCtx, GID_OCARINA_TIME); +} diff --git a/src/overlays/actors/ovl_Item_Shield/z_item_shield.c b/src/overlays/actors/ovl_Item_Shield/z_item_shield.c deleted file mode 100644 index 366332c10..000000000 --- a/src/overlays/actors/ovl_Item_Shield/z_item_shield.c +++ /dev/null @@ -1,238 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ITEM_SHIELD_Z_ITEM_SHIELD_C -#include "actor_common.h" -/* - * File: z_item_shield.c - * Overlay: ovl_Item_Shield - * Description: Deku Shield - */ - -#include "vt.h" -#include "z_item_shield.h" -#include "objects/object_link_child/object_link_child.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void ItemShield_Init(Actor* thisx, GlobalContext* globalCtx); -void ItemShield_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ItemShield_Update(Actor* thisx, GlobalContext* globalCtx); -void ItemShield_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B86F68(ItemShield* this, GlobalContext* globalCtx); -void func_80B86BC8(ItemShield* this, GlobalContext* globalCtx); - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000004, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 15, 15, 0, { 0, 0, 0 } }, -}; - -const ActorInit Item_Shield_InitVars = { - ACTOR_ITEM_SHIELD, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_LINK_CHILD, - sizeof(ItemShield), - (ActorFunc)ItemShield_Init, - (ActorFunc)ItemShield_Destroy, - (ActorFunc)ItemShield_Update, - (ActorFunc)ItemShield_Draw, -}; - -static Color_RGBA8 unused = { 255, 255, 0, 255 }; -static Color_RGBA8 unused2 = { 255, 0, 0, 255 }; - -void ItemShield_SetupAction(ItemShield* this, ItemShieldActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void ItemShield_Init(Actor* thisx, GlobalContext* globalCtx) { - ItemShield* this = (ItemShield*)thisx; - s32 i; - - this->timer = 0; - this->unk_19C = 0; - - switch (this->actor.params) { - case 0: - ActorShape_Init(&this->actor.shape, 1400.0f, NULL, 0.0f); - this->actor.shape.rot.x = 0x4000; - ItemShield_SetupAction(this, func_80B86BC8); - break; - - case 1: - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - ItemShield_SetupAction(this, func_80B86F68); - this->unk_19C |= 2; - for (i = 0; i < 8; i++) { - this->unk_19E[i] = 1 + 2 * i; - this->unk_1A8[i].x = Rand_CenteredFloat(10.0f); - this->unk_1A8[i].y = Rand_CenteredFloat(10.0f); - this->unk_1A8[i].z = Rand_CenteredFloat(10.0f); - } - break; - } - - Actor_SetScale(&this->actor, 0.01f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - osSyncPrintf(VT_FGCOL(GREEN) "Item_Shild %d \n" VT_RST, this->actor.params); -} - -void ItemShield_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ItemShield* this = (ItemShield*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void func_80B86AC8(ItemShield* this, GlobalContext* globalCtx) { - Actor_MoveForward(&this->actor); - if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - func_8002F434(&this->actor, globalCtx, GI_SHIELD_DEKU, 30.0f, 50.0f); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); - if (this->actor.bgCheckFlags & 1) { - this->timer--; - if (this->timer < 60) { - if (this->timer & 1) { - this->unk_19C |= 2; - } else { - this->unk_19C &= ~2; - } - } - if (this->timer == 0) { - Actor_Kill(&this->actor); - } - } -} - -void func_80B86BC8(ItemShield* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - func_8002F434(&this->actor, globalCtx, GI_SHIELD_DEKU, 30.0f, 50.0f); - if (this->collider.base.acFlags & AC_HIT) { - ItemShield_SetupAction(this, func_80B86AC8); - this->actor.velocity.y = 4.0f; - this->actor.minVelocityY = -4.0f; - this->actor.gravity = -0.8f; - this->actor.speedXZ = 0.0f; - this->timer = 160; - } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void func_80B86CA8(ItemShield* this, GlobalContext* globalCtx) { - static Vec3f D_80B871F4 = { 0.0f, 0.0f, 0.0f }; - static f32 D_80B87200[] = { 0.3f, 0.6f, 0.9f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 0.85f, 0.7f, 0.55f, 0.4f, 0.25f, 0.1f, 0.0f }; - static f32 D_80B87240[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.8f, - 0.6f, 0.4f, 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - s32 i; - s32 temp; - - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); - this->actor.shape.yOffset = ABS(Math_SinS(this->actor.shape.rot.x)) * 1500.0f; - - for (i = 0; i < 8; i++) { - temp = 15 - this->unk_19E[i]; - D_80B871F4.x = this->unk_1A8[i].x; - D_80B871F4.y = this->unk_1A8[i].y + (this->actor.shape.yOffset * 0.01f) + (D_80B87200[temp] * -10.0f * 0.2f); - D_80B871F4.z = this->unk_1A8[i].z; - EffectSsFireTail_SpawnFlame(globalCtx, &this->actor, &D_80B871F4, D_80B87200[temp] * 0.2f, -1, - D_80B87240[temp]); - if (this->unk_19E[i] != 0) { - this->unk_19E[i]--; - } else if (this->timer > 16) { - this->unk_19E[i] = 15; - this->unk_1A8[i].x = Rand_CenteredFloat(15.0f); - this->unk_1A8[i].y = Rand_CenteredFloat(10.0f); - this->unk_1A8[i].z = Rand_CenteredFloat(15.0f); - } - } - if (this->actor.bgCheckFlags & 1) { - this->unk_198 -= this->actor.shape.rot.x >> 1; - this->unk_198 -= this->unk_198 >> 2; - this->actor.shape.rot.x += this->unk_198; - if ((this->timer >= 8) && (this->timer < 24)) { - Actor_SetScale(&this->actor, (this->timer - 8) * 0.000625f); - } - if (this->timer != 0) { - this->timer--; - } else { - Actor_Kill(&this->actor); - } - } -} - -void func_80B86F68(ItemShield* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - MtxF* shield = &player->shieldMf; - - this->actor.world.pos.x = shield->xw; - this->actor.world.pos.y = shield->yw; - this->actor.world.pos.z = shield->zw; - this->unk_19C &= ~2; - - this->actor.shape.rot.y = Math_Atan2S(-shield->zz, -shield->xz); - this->actor.shape.rot.x = Math_Atan2S(-shield->yz, sqrtf(shield->zz * shield->zz + shield->xz * shield->xz)); - - if (ABS(this->actor.shape.rot.x) > 0x4000) { - this->unk_19C |= 1; - } - - ItemShield_SetupAction(this, func_80B86CA8); - - this->actor.velocity.y = 4.0; - this->actor.minVelocityY = -4.0; - this->actor.gravity = -0.8; - this->unk_198 = 0; - this->timer = 70; - this->actor.speedXZ = 0; -} - -void ItemShield_Update(Actor* thisx, GlobalContext* globalCtx) { - ItemShield* this = (ItemShield*)thisx; - - this->actionFunc(this, globalCtx); -} - -void ItemShield_Draw(Actor* thisx, GlobalContext* globalCtx) { - ItemShield* this = (ItemShield*)thisx; - - if (!(this->unk_19C & 2)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_item_shield.c", 457); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_item_shield.c", 460), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gLinkChildDekuShieldDL)); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_item_shield.c", 465); - } -} diff --git a/src/overlays/actors/ovl_Item_Shield/z_item_shield.cpp b/src/overlays/actors/ovl_Item_Shield/z_item_shield.cpp new file mode 100644 index 000000000..840ec4f1e --- /dev/null +++ b/src/overlays/actors/ovl_Item_Shield/z_item_shield.cpp @@ -0,0 +1,238 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_ITEM_SHIELD_Z_ITEM_SHIELD_C +#include "actor_common.h" +/* + * File: z_item_shield.c + * Overlay: ovl_Item_Shield + * Description: Deku Shield + */ + +#include "vt.h" +#include "z_item_shield.h" +#include "objects/object_link_child/object_link_child.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void ItemShield_Init(Actor* thisx, GlobalContext* globalCtx); +void ItemShield_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ItemShield_Update(Actor* thisx, GlobalContext* globalCtx); +void ItemShield_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B86F68(ItemShield* pthis, GlobalContext* globalCtx); +void func_80B86BC8(ItemShield* pthis, GlobalContext* globalCtx); + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000004, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 15, 15, 0, { 0, 0, 0 } }, +}; + +ActorInit Item_Shield_InitVars = { + ACTOR_ITEM_SHIELD, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_LINK_CHILD, + sizeof(ItemShield), + (ActorFunc)ItemShield_Init, + (ActorFunc)ItemShield_Destroy, + (ActorFunc)ItemShield_Update, + (ActorFunc)ItemShield_Draw, +}; + +static Color_RGBA8 unused = { 255, 255, 0, 255 }; +static Color_RGBA8 unused2 = { 255, 0, 0, 255 }; + +void ItemShield_SetupAction(ItemShield* pthis, ItemShieldActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void ItemShield_Init(Actor* thisx, GlobalContext* globalCtx) { + ItemShield* pthis = (ItemShield*)thisx; + s32 i; + + pthis->timer = 0; + pthis->unk_19C = 0; + + switch (pthis->actor.params) { + case 0: + ActorShape_Init(&pthis->actor.shape, 1400.0f, NULL, 0.0f); + pthis->actor.shape.rot.x = 0x4000; + ItemShield_SetupAction(pthis, func_80B86BC8); + break; + + case 1: + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); + ItemShield_SetupAction(pthis, func_80B86F68); + pthis->unk_19C |= 2; + for (i = 0; i < 8; i++) { + pthis->unk_19E[i] = 1 + 2 * i; + pthis->unk_1A8[i].x = Rand_CenteredFloat(10.0f); + pthis->unk_1A8[i].y = Rand_CenteredFloat(10.0f); + pthis->unk_1A8[i].z = Rand_CenteredFloat(10.0f); + } + break; + } + + Actor_SetScale(&pthis->actor, 0.01f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + osSyncPrintf(VT_FGCOL(GREEN) "Item_Shild %d \n" VT_RST, pthis->actor.params); +} + +void ItemShield_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ItemShield* pthis = (ItemShield*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void func_80B86AC8(ItemShield* pthis, GlobalContext* globalCtx) { + Actor_MoveForward(&pthis->actor); + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + func_8002F434(&pthis->actor, globalCtx, GI_SHIELD_DEKU, 30.0f, 50.0f); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 0.0f, 5); + if (pthis->actor.bgCheckFlags & 1) { + pthis->timer--; + if (pthis->timer < 60) { + if (pthis->timer & 1) { + pthis->unk_19C |= 2; + } else { + pthis->unk_19C &= ~2; + } + } + if (pthis->timer == 0) { + Actor_Kill(&pthis->actor); + } + } +} + +void func_80B86BC8(ItemShield* pthis, GlobalContext* globalCtx) { + if (Actor_HasParent(&pthis->actor, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + func_8002F434(&pthis->actor, globalCtx, GI_SHIELD_DEKU, 30.0f, 50.0f); + if (pthis->collider.base.acFlags & AC_HIT) { + ItemShield_SetupAction(pthis, func_80B86AC8); + pthis->actor.velocity.y = 4.0f; + pthis->actor.minVelocityY = -4.0f; + pthis->actor.gravity = -0.8f; + pthis->actor.speedXZ = 0.0f; + pthis->timer = 160; + } else { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void func_80B86CA8(ItemShield* pthis, GlobalContext* globalCtx) { + static Vec3f D_80B871F4 = { 0.0f, 0.0f, 0.0f }; + static f32 D_80B87200[] = { 0.3f, 0.6f, 0.9f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 0.85f, 0.7f, 0.55f, 0.4f, 0.25f, 0.1f, 0.0f }; + static f32 D_80B87240[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.8f, + 0.6f, 0.4f, 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + s32 i; + s32 temp; + + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 10.0f, 10.0f, 0.0f, 5); + pthis->actor.shape.yOffset = ABS(Math_SinS(pthis->actor.shape.rot.x)) * 1500.0f; + + for (i = 0; i < 8; i++) { + temp = 15 - pthis->unk_19E[i]; + D_80B871F4.x = pthis->unk_1A8[i].x; + D_80B871F4.y = pthis->unk_1A8[i].y + (pthis->actor.shape.yOffset * 0.01f) + (D_80B87200[temp] * -10.0f * 0.2f); + D_80B871F4.z = pthis->unk_1A8[i].z; + EffectSsFireTail_SpawnFlame(globalCtx, &pthis->actor, &D_80B871F4, D_80B87200[temp] * 0.2f, -1, + D_80B87240[temp]); + if (pthis->unk_19E[i] != 0) { + pthis->unk_19E[i]--; + } else if (pthis->timer > 16) { + pthis->unk_19E[i] = 15; + pthis->unk_1A8[i].x = Rand_CenteredFloat(15.0f); + pthis->unk_1A8[i].y = Rand_CenteredFloat(10.0f); + pthis->unk_1A8[i].z = Rand_CenteredFloat(15.0f); + } + } + if (pthis->actor.bgCheckFlags & 1) { + pthis->unk_198 -= pthis->actor.shape.rot.x >> 1; + pthis->unk_198 -= pthis->unk_198 >> 2; + pthis->actor.shape.rot.x += pthis->unk_198; + if ((pthis->timer >= 8) && (pthis->timer < 24)) { + Actor_SetScale(&pthis->actor, (pthis->timer - 8) * 0.000625f); + } + if (pthis->timer != 0) { + pthis->timer--; + } else { + Actor_Kill(&pthis->actor); + } + } +} + +void func_80B86F68(ItemShield* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + MtxF* shield = &player->shieldMf; + + pthis->actor.world.pos.x = shield->xw; + pthis->actor.world.pos.y = shield->yw; + pthis->actor.world.pos.z = shield->zw; + pthis->unk_19C &= ~2; + + pthis->actor.shape.rot.y = Math_Atan2S(-shield->zz, -shield->xz); + pthis->actor.shape.rot.x = Math_Atan2S(-shield->yz, sqrtf(shield->zz * shield->zz + shield->xz * shield->xz)); + + if (ABS(pthis->actor.shape.rot.x) > 0x4000) { + pthis->unk_19C |= 1; + } + + ItemShield_SetupAction(pthis, func_80B86CA8); + + pthis->actor.velocity.y = 4.0; + pthis->actor.minVelocityY = -4.0; + pthis->actor.gravity = -0.8; + pthis->unk_198 = 0; + pthis->timer = 70; + pthis->actor.speedXZ = 0; +} + +void ItemShield_Update(Actor* thisx, GlobalContext* globalCtx) { + ItemShield* pthis = (ItemShield*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void ItemShield_Draw(Actor* thisx, GlobalContext* globalCtx) { + ItemShield* pthis = (ItemShield*)thisx; + + if (!(pthis->unk_19C & 2)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_item_shield.c", 457); + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_item_shield.c", 460), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gLinkChildDekuShieldDL)); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_item_shield.c", 465); + } +} diff --git a/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c b/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.cpp similarity index 67% rename from src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c rename to src/overlays/actors/ovl_Magic_Dark/z_magic_dark.cpp index 087b83088..d1390a095 100644 --- a/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c +++ b/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.cpp @@ -27,7 +27,7 @@ void MagicDark_DiamondDraw(Actor* thisx, GlobalContext* globalCtx); void MagicDark_DimLighting(GlobalContext* globalCtx, f32 intensity); -const ActorInit Magic_Dark_InitVars = { +ActorInit Magic_Dark_InitVars = { ACTOR_MAGIC_DARK, ACTORCAT_ITEMACTION, FLAGS, @@ -39,34 +39,34 @@ const ActorInit Magic_Dark_InitVars = { (ActorFunc)MagicDark_OrbDraw, }; -#include "overlays/ovl_Magic_Dark/ovl_Magic_Dark.c" +#include "overlays/ovl_Magic_Dark/ovl_Magic_Dark.cpp" // unused static Color_RGBA8 D_80B88B10[] = { { 50, 100, 150, 200 }, { 255, 200, 150, 100 } }; void MagicDark_Init(Actor* thisx, GlobalContext* globalCtx) { - MagicDark* this = (MagicDark*)thisx; + MagicDark* pthis = (MagicDark*)thisx; Player* player = GET_PLAYER(globalCtx); if (!LINK_IS_ADULT) { - this->scale = 0.4f; + pthis->scale = 0.4f; } else { - this->scale = 0.6f; + pthis->scale = 0.6f; } thisx->world.pos = player->actor.world.pos; - Actor_SetScale(&this->actor, 0.0f); + Actor_SetScale(&pthis->actor, 0.0f); thisx->room = -1; if (gSaveContext.nayrusLoveTimer != 0) { thisx->update = MagicDark_DiamondUpdate; thisx->draw = MagicDark_DiamondDraw; - thisx->scale.x = thisx->scale.z = this->scale * 1.6f; - thisx->scale.y = this->scale * 0.8f; - this->timer = 0; - this->primAlpha = 0; + thisx->scale.x = thisx->scale.z = pthis->scale * 1.6f; + thisx->scale.y = pthis->scale * 0.8f; + pthis->timer = 0; + pthis->primAlpha = 0; } else { - this->timer = 0; + pthis->timer = 0; gSaveContext.nayrusLoveTimer = 0; } } @@ -78,7 +78,7 @@ void MagicDark_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void MagicDark_DiamondUpdate(Actor* thisx, GlobalContext* globalCtx) { - MagicDark* this = (MagicDark*)thisx; + MagicDark* pthis = (MagicDark*)thisx; u8 phi_a0; Player* player = GET_PLAYER(globalCtx); s16 pad; @@ -100,39 +100,39 @@ void MagicDark_DiamondUpdate(Actor* thisx, GlobalContext* globalCtx) { } player->invincibilityTimer = -100; - thisx->scale.x = thisx->scale.z = this->scale; + thisx->scale.x = thisx->scale.z = pthis->scale; - if (this->timer < 20) { - thisx->scale.x = thisx->scale.z = (1.6f - (this->timer * 0.03f)) * this->scale; - thisx->scale.y = ((this->timer * 0.01f) + 0.8f) * this->scale; + if (pthis->timer < 20) { + thisx->scale.x = thisx->scale.z = (1.6f - (pthis->timer * 0.03f)) * pthis->scale; + thisx->scale.y = ((pthis->timer * 0.01f) + 0.8f) * pthis->scale; } else { - thisx->scale.x = thisx->scale.z = this->scale; - thisx->scale.y = this->scale; + thisx->scale.x = thisx->scale.z = pthis->scale; + thisx->scale.y = pthis->scale; } thisx->scale.x *= 1.3f; thisx->scale.z *= 1.3f; - phi_a0 = (this->timer < 20) ? (this->timer * 12) : 255; + phi_a0 = (pthis->timer < 20) ? (pthis->timer * 12) : 255; if (nayrusLoveTimer >= 1180) { - this->primAlpha = 15595 - (nayrusLoveTimer * 13); + pthis->primAlpha = 15595 - (nayrusLoveTimer * 13); if (nayrusLoveTimer & 1) { - this->primAlpha = this->primAlpha >> 1; + pthis->primAlpha = pthis->primAlpha >> 1; } } else if (nayrusLoveTimer >= 1100) { - this->primAlpha = (u8)(nayrusLoveTimer << 7) + 127; + pthis->primAlpha = (u8)(nayrusLoveTimer << 7) + 127; } else { - this->primAlpha = 255; + pthis->primAlpha = 255; } - if (this->primAlpha > phi_a0) { - this->primAlpha = phi_a0; + if (pthis->primAlpha > phi_a0) { + pthis->primAlpha = phi_a0; } thisx->world.rot.y += 0x3E8; thisx->shape.rot.y = thisx->world.rot.y + Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); - this->timer++; + pthis->timer++; gSaveContext.nayrusLoveTimer = nayrusLoveTimer + 1; if (nayrusLoveTimer < 1100) { @@ -177,35 +177,35 @@ void MagicDark_DimLighting(GlobalContext* globalCtx, f32 intensity) { } void MagicDark_OrbUpdate(Actor* thisx, GlobalContext* globalCtx) { - MagicDark* this = (MagicDark*)thisx; + MagicDark* pthis = (MagicDark*)thisx; s32 pad; Player* player = GET_PLAYER(globalCtx); - func_8002F974(&this->actor, NA_SE_PL_MAGIC_SOUL_BALL - SFX_FLAG); - if (this->timer < 35) { - MagicDark_DimLighting(globalCtx, this->timer * (1 / 45.0f)); - Math_SmoothStepToF(&thisx->scale.x, this->scale * (1 / 12.000001f), 0.05f, 0.01f, 0.0001f); - Actor_SetScale(&this->actor, thisx->scale.x); - } else if (this->timer < 55) { - Actor_SetScale(&this->actor, thisx->scale.x * 0.9f); - Math_SmoothStepToF(&this->orbOffset.y, player->bodyPartsPos[0].y, 0.5f, 3.0f, 1.0f); - if (this->timer > 48) { - MagicDark_DimLighting(globalCtx, (54 - this->timer) * 0.2f); + func_8002F974(&pthis->actor, NA_SE_PL_MAGIC_SOUL_BALL - SFX_FLAG); + if (pthis->timer < 35) { + MagicDark_DimLighting(globalCtx, pthis->timer * (1 / 45.0f)); + Math_SmoothStepToF(&thisx->scale.x, pthis->scale * (1 / 12.000001f), 0.05f, 0.01f, 0.0001f); + Actor_SetScale(&pthis->actor, thisx->scale.x); + } else if (pthis->timer < 55) { + Actor_SetScale(&pthis->actor, thisx->scale.x * 0.9f); + Math_SmoothStepToF(&pthis->orbOffset.y, player->bodyPartsPos[0].y, 0.5f, 3.0f, 1.0f); + if (pthis->timer > 48) { + MagicDark_DimLighting(globalCtx, (54 - pthis->timer) * 0.2f); } } else { thisx->update = MagicDark_DiamondUpdate; thisx->draw = MagicDark_DiamondDraw; - thisx->scale.x = thisx->scale.z = this->scale * 1.6f; - thisx->scale.y = this->scale * 0.8f; - this->timer = 0; - this->primAlpha = 0; + thisx->scale.x = thisx->scale.z = pthis->scale * 1.6f; + thisx->scale.y = pthis->scale * 0.8f; + pthis->timer = 0; + pthis->primAlpha = 0; } - this->timer++; + pthis->timer++; } void MagicDark_DiamondDraw(Actor* thisx, GlobalContext* globalCtx) { - MagicDark* this = (MagicDark*)thisx; + MagicDark* pthis = (MagicDark*)thisx; s32 pad; u16 gameplayFrames = globalCtx->gameplayFrames; @@ -217,20 +217,20 @@ void MagicDark_DiamondDraw(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 heightDiff; - this->actor.world.pos.x = player->bodyPartsPos[0].x; - this->actor.world.pos.z = player->bodyPartsPos[0].z; - heightDiff = player->bodyPartsPos[0].y - this->actor.world.pos.y; + pthis->actor.world.pos.x = player->bodyPartsPos[0].x; + pthis->actor.world.pos.z = player->bodyPartsPos[0].z; + heightDiff = player->bodyPartsPos[0].y - pthis->actor.world.pos.y; if (heightDiff < -2.0f) { - this->actor.world.pos.y = player->bodyPartsPos[0].y + 2.0f; + pthis->actor.world.pos.y = player->bodyPartsPos[0].y + 2.0f; } else if (heightDiff > 2.0f) { - this->actor.world.pos.y = player->bodyPartsPos[0].y - 2.0f; + pthis->actor.world.pos.y = player->bodyPartsPos[0].y - 2.0f; } - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(pthis->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_magic_dark.c", 553), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 255, 255, (s32)(this->primAlpha * 0.6f) & 0xFF); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 255, 255, (s32)(pthis->primAlpha * 0.6f) & 0xFF); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); gSPDisplayList(POLY_XLU_DISP++, sDiamondMaterialDL); gSPDisplayList(POLY_XLU_DISP++, @@ -243,30 +243,30 @@ void MagicDark_DiamondDraw(Actor* thisx, GlobalContext* globalCtx) { } void MagicDark_OrbDraw(Actor* thisx, GlobalContext* globalCtx) { - MagicDark* this = (MagicDark*)thisx; + MagicDark* pthis = (MagicDark*)thisx; Vec3f pos; Player* player = GET_PLAYER(globalCtx); s32 pad; f32 sp6C = globalCtx->state.frames & 0x1F; - if (this->timer < 32) { + if (pthis->timer < 32) { pos.x = (player->bodyPartsPos[12].x + player->bodyPartsPos[15].x) * 0.5f; pos.y = (player->bodyPartsPos[12].y + player->bodyPartsPos[15].y) * 0.5f; pos.z = (player->bodyPartsPos[12].z + player->bodyPartsPos[15].z) * 0.5f; - if (this->timer > 20) { - pos.y += (this->timer - 20) * 1.4f; + if (pthis->timer > 20) { + pos.y += (pthis->timer - 20) * 1.4f; } - this->orbOffset = pos; - } else if (this->timer < 130) { - pos = this->orbOffset; + pthis->orbOffset = pos; + } else if (pthis->timer < 130) { + pos = pthis->orbOffset; } else { return; } - pos.x -= (this->actor.scale.x * 300.0f * Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))) * + pos.x -= (pthis->actor.scale.x * 300.0f * Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))) * Math_CosS(Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)))); - pos.y -= (this->actor.scale.x * 300.0f * Math_SinS(Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)))); - pos.z -= (this->actor.scale.x * 300.0f * Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))) * + pos.y -= (pthis->actor.scale.x * 300.0f * Math_SinS(Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)))); + pos.z -= (pthis->actor.scale.x * 300.0f * Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))) * Math_CosS(Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)))); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_magic_dark.c", 619); @@ -275,7 +275,7 @@ void MagicDark_OrbDraw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 255); Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); Matrix_Push(); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_magic_dark.c", 632), diff --git a/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c b/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.cpp similarity index 56% rename from src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c rename to src/overlays/actors/ovl_Magic_Fire/z_magic_fire.cpp index 6df274cbf..a9bb53bef 100644 --- a/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c +++ b/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.cpp @@ -38,7 +38,7 @@ typedef enum { /* 0x04 */ DF_SCREEN_TINT_FINISHED } MagicFireScreenTint; -const ActorInit Magic_Fire_InitVars = { +ActorInit Magic_Fire_InitVars = { ACTOR_MAGIC_FIRE, ACTORCAT_ITEMACTION, FLAGS, @@ -50,7 +50,7 @@ const ActorInit Magic_Fire_InitVars = { (ActorFunc)MagicFire_Draw, }; -#include "overlays/ovl_Magic_Fire/ovl_Magic_Fire.c" +#include "overlays/ovl_Magic_Fire/ovl_Magic_Fire.cpp" static ColliderCylinderInit sCylinderInit = { { @@ -83,20 +83,20 @@ static u8 sVertexIndices[] = { }; void MagicFire_Init(Actor* thisx, GlobalContext* globalCtx) { - MagicFire* this = (MagicFire*)thisx; + MagicFire* pthis = (MagicFire*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->action = 0; - this->screenTintBehaviour = 0; - this->actionTimer = 0; - this->alphaMultiplier = -3.0f; - Actor_SetScale(&this->actor, 0.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - this->actor.update = MagicFire_UpdateBeforeCast; - this->actionTimer = 20; - this->actor.room = -1; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->action = 0; + pthis->screenTintBehaviour = 0; + pthis->actionTimer = 0; + pthis->alphaMultiplier = -3.0f; + Actor_SetScale(&pthis->actor, 0.0f); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->actor.update = MagicFire_UpdateBeforeCast; + pthis->actionTimer = 20; + pthis->actor.room = -1; } void MagicFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -104,139 +104,139 @@ void MagicFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void MagicFire_UpdateBeforeCast(Actor* thisx, GlobalContext* globalCtx) { - MagicFire* this = (MagicFire*)thisx; + MagicFire* pthis = (MagicFire*)thisx; Player* player = GET_PLAYER(globalCtx); if ((globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (globalCtx->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->actionTimer > 0) { - this->actionTimer--; + if (pthis->actionTimer > 0) { + pthis->actionTimer--; } else { - this->actor.update = MagicFire_Update; + pthis->actor.update = MagicFire_Update; func_8002F7DC(&player->actor, NA_SE_PL_MAGIC_FIRE); } - this->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos = player->actor.world.pos; } void MagicFire_Update(Actor* thisx, GlobalContext* globalCtx) { - MagicFire* this = (MagicFire*)thisx; + MagicFire* pthis = (MagicFire*)thisx; Player* player = GET_PLAYER(globalCtx); s32 pad; if (1) {} - this->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos = player->actor.world.pos; if ((globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (globalCtx->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); return; } - if (this->action == DF_ACTION_EXPAND_SLOWLY) { - this->collider.info.toucher.damage = this->actionTimer + 25; - } else if (this->action == DF_ACTION_STOP_EXPANDING) { - this->collider.info.toucher.damage = this->actionTimer; + if (pthis->action == DF_ACTION_EXPAND_SLOWLY) { + pthis->collider.info.toucher.damage = pthis->actionTimer + 25; + } else if (pthis->action == DF_ACTION_STOP_EXPANDING) { + pthis->collider.info.toucher.damage = pthis->actionTimer; } - Collider_UpdateCylinder(&this->actor, &this->collider); - this->collider.dim.radius = (this->actor.scale.x * 325.0f); - this->collider.dim.height = (this->actor.scale.y * 450.0f); - this->collider.dim.yShift = (this->actor.scale.y * -225.0f); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->collider.dim.radius = (pthis->actor.scale.x * 325.0f); + pthis->collider.dim.height = (pthis->actor.scale.y * 450.0f); + pthis->collider.dim.yShift = (pthis->actor.scale.y * -225.0f); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); - switch (this->action) { + switch (pthis->action) { case DF_ACTION_INITIALIZE: - this->actionTimer = 30; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.0f; - this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; - this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - this->alphaMultiplier = 0.0f; - this->scalingSpeed = 0.08f; - this->action++; + pthis->actionTimer = 30; + pthis->actor.scale.x = pthis->actor.scale.y = pthis->actor.scale.z = 0.0f; + pthis->actor.world.rot.x = pthis->actor.world.rot.y = pthis->actor.world.rot.z = 0; + pthis->actor.shape.rot.x = pthis->actor.shape.rot.y = pthis->actor.shape.rot.z = 0; + pthis->alphaMultiplier = 0.0f; + pthis->scalingSpeed = 0.08f; + pthis->action++; break; case DF_ACTION_EXPAND_SLOWLY: // Fire sphere slowly expands out of player for 30 frames - Math_StepToF(&this->alphaMultiplier, 1.0f, 1.0f / 30.0f); - if (this->actionTimer > 0) { - Math_SmoothStepToF(&this->actor.scale.x, 0.4f, this->scalingSpeed, 0.1f, 0.001f); - this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; + Math_StepToF(&pthis->alphaMultiplier, 1.0f, 1.0f / 30.0f); + if (pthis->actionTimer > 0) { + Math_SmoothStepToF(&pthis->actor.scale.x, 0.4f, pthis->scalingSpeed, 0.1f, 0.001f); + pthis->actor.scale.y = pthis->actor.scale.z = pthis->actor.scale.x; } else { - this->actionTimer = 25; - this->action++; + pthis->actionTimer = 25; + pthis->action++; } break; case DF_ACTION_STOP_EXPANDING: // Sphere stops expanding and maintains size for 25 frames - if (this->actionTimer <= 0) { - this->actionTimer = 15; - this->action++; - this->scalingSpeed = 0.05f; + if (pthis->actionTimer <= 0) { + pthis->actionTimer = 15; + pthis->action++; + pthis->scalingSpeed = 0.05f; } break; case DF_ACTION_EXPAND_QUICKLY: // Sphere beings to grow again and quickly expands out until killed - this->alphaMultiplier -= 8.0f / 119.00001f; - this->actor.scale.x += this->scalingSpeed; - this->actor.scale.y += this->scalingSpeed; - this->actor.scale.z += this->scalingSpeed; - if (this->alphaMultiplier <= 0.0f) { - this->action = 0; - Actor_Kill(&this->actor); + pthis->alphaMultiplier -= 8.0f / 119.00001f; + pthis->actor.scale.x += pthis->scalingSpeed; + pthis->actor.scale.y += pthis->scalingSpeed; + pthis->actor.scale.z += pthis->scalingSpeed; + if (pthis->alphaMultiplier <= 0.0f) { + pthis->action = 0; + Actor_Kill(&pthis->actor); } break; } - switch (this->screenTintBehaviour) { + switch (pthis->screenTintBehaviour) { case DF_SCREEN_TINT_NONE: - if (this->screenTintBehaviourTimer <= 0) { - this->screenTintBehaviourTimer = 20; - this->screenTintBehaviour = DF_SCREEN_TINT_FADE_IN; + if (pthis->screenTintBehaviourTimer <= 0) { + pthis->screenTintBehaviourTimer = 20; + pthis->screenTintBehaviour = DF_SCREEN_TINT_FADE_IN; } break; case DF_SCREEN_TINT_FADE_IN: - this->screenTintIntensity = 1.0f - (this->screenTintBehaviourTimer / 20.0f); - if (this->screenTintBehaviourTimer <= 0) { - this->screenTintBehaviourTimer = 45; - this->screenTintBehaviour = DF_SCREEN_TINT_MAINTAIN; + pthis->screenTintIntensity = 1.0f - (pthis->screenTintBehaviourTimer / 20.0f); + if (pthis->screenTintBehaviourTimer <= 0) { + pthis->screenTintBehaviourTimer = 45; + pthis->screenTintBehaviour = DF_SCREEN_TINT_MAINTAIN; } break; case DF_SCREEN_TINT_MAINTAIN: - if (this->screenTintBehaviourTimer <= 0) { - this->screenTintBehaviourTimer = 5; - this->screenTintBehaviour = DF_SCREEN_TINT_FADE_OUT; + if (pthis->screenTintBehaviourTimer <= 0) { + pthis->screenTintBehaviourTimer = 5; + pthis->screenTintBehaviour = DF_SCREEN_TINT_FADE_OUT; } break; case DF_SCREEN_TINT_FADE_OUT: - this->screenTintIntensity = (this->screenTintBehaviourTimer / 5.0f); - if (this->screenTintBehaviourTimer <= 0) { - this->screenTintBehaviour = DF_SCREEN_TINT_FINISHED; + pthis->screenTintIntensity = (pthis->screenTintBehaviourTimer / 5.0f); + if (pthis->screenTintBehaviourTimer <= 0) { + pthis->screenTintBehaviour = DF_SCREEN_TINT_FINISHED; } break; } - if (this->actionTimer > 0) { - this->actionTimer--; + if (pthis->actionTimer > 0) { + pthis->actionTimer--; } - if (this->screenTintBehaviourTimer > 0) { - this->screenTintBehaviourTimer--; + if (pthis->screenTintBehaviourTimer > 0) { + pthis->screenTintBehaviourTimer--; } } void MagicFire_Draw(Actor* thisx, GlobalContext* globalCtx) { - MagicFire* this = (MagicFire*)thisx; + MagicFire* pthis = (MagicFire*)thisx; s32 pad1; u32 gameplayFrames = globalCtx->gameplayFrames; s32 pad2; s32 i; u8 alpha; - if (this->action > 0) { + if (pthis->action > 0) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_magic_fire.c", 682); POLY_XLU_DISP = func_800937C0(POLY_XLU_DISP); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(s32)(60 * this->screenTintIntensity), - (u8)(s32)(20 * this->screenTintIntensity), (u8)(s32)(0 * this->screenTintIntensity), - (u8)(s32)(120 * this->screenTintIntensity)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(s32)(60 * pthis->screenTintIntensity), + (u8)(s32)(20 * pthis->screenTintIntensity), (u8)(s32)(0 * pthis->screenTintIntensity), + (u8)(s32)(120 * pthis->screenTintIntensity)); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); gDPFillRectangle(POLY_XLU_DISP++, 0, 0, 319, 239); func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, 255, 200, 0, (u8)(this->alphaMultiplier * 255)); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, (u8)(this->alphaMultiplier * 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, 255, 200, 0, (u8)(pthis->alphaMultiplier * 255)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, (u8)(pthis->alphaMultiplier * 255)); Matrix_Scale(0.15f, 0.15f, 0.15f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_magic_fire.c", 715), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -256,12 +256,12 @@ void MagicFire_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, sModelDL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_magic_fire.c", 750); - alpha = (s32)(this->alphaMultiplier * 255); + alpha = (s32)(pthis->alphaMultiplier * 255); for (i = 0; i < 36; i++) { sSphereVtx[sVertexIndices[i]].n.a = alpha; } - alpha = (s32)(this->alphaMultiplier * 76); + alpha = (s32)(pthis->alphaMultiplier * 76); for (i = 36; i < 60; i++) { sSphereVtx[sVertexIndices[i]].n.a = alpha; } diff --git a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.cpp similarity index 60% rename from src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c rename to src/overlays/actors/ovl_Magic_Wind/z_magic_wind.cpp index dfbd91431..60f0782de 100644 --- a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c +++ b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.cpp @@ -19,13 +19,13 @@ void MagicWind_Destroy(Actor* thisx, GlobalContext* globalCtx); void MagicWind_Update(Actor* thisx, GlobalContext* globalCtx); void MagicWind_Draw(Actor* thisx, GlobalContext* globalCtx); -void MagicWind_Shrink(MagicWind* this, GlobalContext* globalCtx); -void MagicWind_WaitForTimer(MagicWind* this, GlobalContext* globalCtx); -void MagicWind_FadeOut(MagicWind* this, GlobalContext* globalCtx); -void MagicWind_WaitAtFullSize(MagicWind* this, GlobalContext* globalCtx); -void MagicWind_Grow(MagicWind* this, GlobalContext* globalCtx); +void MagicWind_Shrink(MagicWind* pthis, GlobalContext* globalCtx); +void MagicWind_WaitForTimer(MagicWind* pthis, GlobalContext* globalCtx); +void MagicWind_FadeOut(MagicWind* pthis, GlobalContext* globalCtx); +void MagicWind_WaitAtFullSize(MagicWind* pthis, GlobalContext* globalCtx); +void MagicWind_Grow(MagicWind* pthis, GlobalContext* globalCtx); -const ActorInit Magic_Wind_InitVars = { +ActorInit Magic_Wind_InitVars = { ACTOR_MAGIC_WIND, ACTORCAT_ITEMACTION, FLAGS, @@ -37,34 +37,34 @@ const ActorInit Magic_Wind_InitVars = { (ActorFunc)MagicWind_Draw, }; -#include "overlays/ovl_Magic_Wind/ovl_Magic_Wind.c" +#include "overlays/ovl_Magic_Wind/ovl_Magic_Wind.cpp" static u8 sAlphaUpdVals[] = { 0x00, 0x03, 0x04, 0x07, 0x09, 0x0A, 0x0D, 0x0F, 0x11, 0x12, 0x15, 0x16, 0x19, 0x1B, 0x1C, 0x1F, 0x21, 0x23, }; -void MagicWind_SetupAction(MagicWind* this, MagicWindFunc actionFunc) { - this->actionFunc = actionFunc; +void MagicWind_SetupAction(MagicWind* pthis, MagicWindFunc actionFunc) { + pthis->actionFunc = actionFunc; } void MagicWind_Init(Actor* thisx, GlobalContext* globalCtx) { - MagicWind* this = (MagicWind*)thisx; + MagicWind* pthis = (MagicWind*)thisx; Player* player = GET_PLAYER(globalCtx); - if (SkelCurve_Init(globalCtx, &this->skelCurve, &sSkel, &sAnim) == 0) { + if (SkelCurve_Init(globalCtx, &pthis->skelCurve, &sSkel, &sAnim) == 0) { // "Magic_Wind_Actor_ct (): Construct failed" osSyncPrintf("Magic_Wind_Actor_ct():コンストラクト失敗\n"); } - this->actor.room = -1; - switch (this->actor.params) { + pthis->actor.room = -1; + switch (pthis->actor.params) { case 0: - SkelCurve_SetAnim(&this->skelCurve, &sAnim, 0.0f, 60.0f, 0.0f, 1.0f); - this->timer = 29; - MagicWind_SetupAction(this, MagicWind_WaitForTimer); + SkelCurve_SetAnim(&pthis->skelCurve, &sAnim, 0.0f, 60.0f, 0.0f, 1.0f); + pthis->timer = 29; + MagicWind_SetupAction(pthis, MagicWind_WaitForTimer); break; case 1: - SkelCurve_SetAnim(&this->skelCurve, &sAnim, 60.0f, 0.0f, 60.0f, -1.0f); - MagicWind_SetupAction(this, MagicWind_Shrink); + SkelCurve_SetAnim(&pthis->skelCurve, &sAnim, 60.0f, 0.0f, 60.0f, -1.0f); + MagicWind_SetupAction(pthis, MagicWind_Shrink); // "Means start" LOG_STRING("表示開始", "../z_magic_wind.c", 486); func_8002F7DC(&player->actor, NA_SE_PL_MAGIC_WIND_WARP); @@ -73,8 +73,8 @@ void MagicWind_Init(Actor* thisx, GlobalContext* globalCtx) { } void MagicWind_Destroy(Actor* thisx, GlobalContext* globalCtx) { - MagicWind* this = (MagicWind*)thisx; - SkelCurve_Destroy(globalCtx, &this->skelCurve); + MagicWind* pthis = (MagicWind*)thisx; + SkelCurve_Destroy(globalCtx, &pthis->skelCurve); func_800876C8(globalCtx); // "wipe out" LOG_STRING("消滅", "../z_magic_wind.c", 505); @@ -88,11 +88,11 @@ void MagicWind_UpdateAlpha(f32 alpha) { } } -void MagicWind_WaitForTimer(MagicWind* this, GlobalContext* globalCtx) { +void MagicWind_WaitForTimer(MagicWind* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->timer > 0) { - this->timer--; + if (pthis->timer > 0) { + pthis->timer--; return; } @@ -100,54 +100,54 @@ void MagicWind_WaitForTimer(MagicWind* this, GlobalContext* globalCtx) { LOG_STRING("表示開始", "../z_magic_wind.c", 539); func_8002F7DC(&player->actor, NA_SE_PL_MAGIC_WIND_NORMAL); MagicWind_UpdateAlpha(1.0f); - MagicWind_SetupAction(this, MagicWind_Grow); - SkelCurve_Update(globalCtx, &this->skelCurve); + MagicWind_SetupAction(pthis, MagicWind_Grow); + SkelCurve_Update(globalCtx, &pthis->skelCurve); } -void MagicWind_Grow(MagicWind* this, GlobalContext* globalCtx) { - if (SkelCurve_Update(globalCtx, &this->skelCurve)) { - MagicWind_SetupAction(this, MagicWind_WaitAtFullSize); - this->timer = 50; +void MagicWind_Grow(MagicWind* pthis, GlobalContext* globalCtx) { + if (SkelCurve_Update(globalCtx, &pthis->skelCurve)) { + MagicWind_SetupAction(pthis, MagicWind_WaitAtFullSize); + pthis->timer = 50; } } -void MagicWind_WaitAtFullSize(MagicWind* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; +void MagicWind_WaitAtFullSize(MagicWind* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; } else { - MagicWind_SetupAction(this, MagicWind_FadeOut); - this->timer = 30; + MagicWind_SetupAction(pthis, MagicWind_FadeOut); + pthis->timer = 30; } } -void MagicWind_FadeOut(MagicWind* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - MagicWind_UpdateAlpha((f32)this->timer * (1.0f / 30.0f)); - this->timer--; +void MagicWind_FadeOut(MagicWind* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + MagicWind_UpdateAlpha((f32)pthis->timer * (1.0f / 30.0f)); + pthis->timer--; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void MagicWind_Shrink(MagicWind* this, GlobalContext* globalCtx) { - if (SkelCurve_Update(globalCtx, &this->skelCurve)) { - Actor_Kill(&this->actor); +void MagicWind_Shrink(MagicWind* pthis, GlobalContext* globalCtx) { + if (SkelCurve_Update(globalCtx, &pthis->skelCurve)) { + Actor_Kill(&pthis->actor); } } void MagicWind_Update(Actor* thisx, GlobalContext* globalCtx) { - MagicWind* this = (MagicWind*)thisx; + MagicWind* pthis = (MagicWind*)thisx; if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || globalCtx->msgCtx.msgMode == MSGMODE_SONG_PLAYED) { Actor_Kill(thisx); return; } - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } s32 MagicWind_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) { - MagicWind* this = (MagicWind*)thisx; + MagicWind* pthis = (MagicWind*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_magic_wind.c", 615); @@ -173,13 +173,13 @@ s32 MagicWind_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCur void MagicWind_Draw(Actor* thisx, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - MagicWind* this = (MagicWind*)thisx; + MagicWind* pthis = (MagicWind*)thisx; OPEN_DISPS(gfxCtx, "../z_magic_wind.c", 661); - if (this->actionFunc != MagicWind_WaitForTimer) { + if (pthis->actionFunc != MagicWind_WaitForTimer) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25); - SkelCurve_Draw(thisx, globalCtx, &this->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL); + SkelCurve_Draw(thisx, globalCtx, &pthis->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL); } CLOSE_DISPS(gfxCtx, "../z_magic_wind.c", 673); diff --git a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h index 25b3e7d70..da125dfd4 100644 --- a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h +++ b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h @@ -6,7 +6,7 @@ struct MagicWind; -typedef void (*MagicWindFunc)(struct MagicWind* this, GlobalContext* globalCtx); +typedef void (*MagicWindFunc)(MagicWind* pthis, GlobalContext* globalCtx); typedef struct MagicWind { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.cpp similarity index 69% rename from src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c rename to src/overlays/actors/ovl_Mir_Ray/z_mir_ray.cpp index d830a6b25..f06f40bd7 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.cpp @@ -41,7 +41,7 @@ typedef enum { /* 9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT } MirRayBeamLocations; -const ActorInit Mir_Ray_InitVars = { +ActorInit Mir_Ray_InitVars = { ACTOR_MIR_RAY, ACTORCAT_ITEMACTION, FLAGS, @@ -122,157 +122,157 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -void MirRay_SetupCollider(MirRay* this) { +void MirRay_SetupCollider(MirRay* pthis) { Vec3f colliderOffset; - MirRayDataEntry* dataEntry = &sMirRayData[this->actor.params]; + MirRayDataEntry* dataEntry = &sMirRayData[pthis->actor.params]; - colliderOffset.x = (this->poolPt.x - this->sourcePt.x) * dataEntry->unk_10; - colliderOffset.y = (this->poolPt.y - this->sourcePt.y) * dataEntry->unk_10; - colliderOffset.z = (this->poolPt.z - this->sourcePt.z) * dataEntry->unk_10; - this->colliderSph.elements[0].dim.worldSphere.center.x = colliderOffset.x + this->sourcePt.x; - this->colliderSph.elements[0].dim.worldSphere.center.y = colliderOffset.y + this->sourcePt.y; - this->colliderSph.elements[0].dim.worldSphere.center.z = colliderOffset.z + this->sourcePt.z; - this->colliderSph.elements[0].dim.worldSphere.radius = dataEntry->unk_14 * this->colliderSph.elements->dim.scale; + colliderOffset.x = (pthis->poolPt.x - pthis->sourcePt.x) * dataEntry->unk_10; + colliderOffset.y = (pthis->poolPt.y - pthis->sourcePt.y) * dataEntry->unk_10; + colliderOffset.z = (pthis->poolPt.z - pthis->sourcePt.z) * dataEntry->unk_10; + pthis->colliderSph.elements[0].dim.worldSphere.center.x = colliderOffset.x + pthis->sourcePt.x; + pthis->colliderSph.elements[0].dim.worldSphere.center.y = colliderOffset.y + pthis->sourcePt.y; + pthis->colliderSph.elements[0].dim.worldSphere.center.z = colliderOffset.z + pthis->sourcePt.z; + pthis->colliderSph.elements[0].dim.worldSphere.radius = dataEntry->unk_14 * pthis->colliderSph.elements->dim.scale; } // Set up a light point between source point and reflection point. Reflection point is the pool point (for windows) or // at the player position (for mirrors) -void MirRay_MakeShieldLight(MirRay* this, GlobalContext* globalCtx) { +void MirRay_MakeShieldLight(MirRay* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - MirRayDataEntry* dataEntry = &sMirRayData[this->actor.params]; + MirRayDataEntry* dataEntry = &sMirRayData[pthis->actor.params]; Vec3f reflectionPt; Vec3s lightPt; - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, player->actor.world.pos.x, - player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, this->sourceEndRad, - this->poolEndRad)) { + if (MirRay_CheckInFrustum(&pthis->sourcePt, &pthis->poolPt, player->actor.world.pos.x, + player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, pthis->sourceEndRad, + pthis->poolEndRad)) { if (dataEntry->params & 8) { // Light beams from mirrors - Math_Vec3f_Diff(&player->actor.world.pos, &this->sourcePt, &reflectionPt); + Math_Vec3f_Diff(&player->actor.world.pos, &pthis->sourcePt, &reflectionPt); } else { // Light beams from windows - Math_Vec3f_Diff(&this->poolPt, &this->sourcePt, &reflectionPt); + Math_Vec3f_Diff(&pthis->poolPt, &pthis->sourcePt, &reflectionPt); } - lightPt.x = (dataEntry->unk_18 * reflectionPt.x) + this->sourcePt.x; - lightPt.y = (dataEntry->unk_18 * reflectionPt.y) + this->sourcePt.y; - lightPt.z = (dataEntry->unk_18 * reflectionPt.z) + this->sourcePt.z; + lightPt.x = (dataEntry->unk_18 * reflectionPt.x) + pthis->sourcePt.x; + lightPt.y = (dataEntry->unk_18 * reflectionPt.y) + pthis->sourcePt.y; + lightPt.z = (dataEntry->unk_18 * reflectionPt.z) + pthis->sourcePt.z; // Fade up - Math_StepToS(&this->lightPointRad, dataEntry->lgtPtMaxRad, 6); - Lights_PointNoGlowSetInfo(&this->lightInfo, lightPt.x, lightPt.y, lightPt.z, dataEntry->color.r, - dataEntry->color.g, dataEntry->color.b, this->lightPointRad); + Math_StepToS(&pthis->lightPointRad, dataEntry->lgtPtMaxRad, 6); + Lights_PointNoGlowSetInfo(&pthis->lightInfo, lightPt.x, lightPt.y, lightPt.z, dataEntry->color.r, + dataEntry->color.g, dataEntry->color.b, pthis->lightPointRad); } else { // Fade down - Math_StepToS(&this->lightPointRad, 0, 6); - Lights_PointSetColorAndRadius(&this->lightInfo, dataEntry->color.r, dataEntry->color.g, dataEntry->color.b, - this->lightPointRad); + Math_StepToS(&pthis->lightPointRad, 0, 6); + Lights_PointSetColorAndRadius(&pthis->lightInfo, dataEntry->color.r, dataEntry->color.g, dataEntry->color.b, + pthis->lightPointRad); } } void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - MirRay* this = (MirRay*)thisx; - MirRayDataEntry* dataEntry = &sMirRayData[this->actor.params]; + MirRay* pthis = (MirRay*)thisx; + MirRayDataEntry* dataEntry = &sMirRayData[pthis->actor.params]; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); // "Generation of reflectable light!" osSyncPrintf("反射用 光の発生!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - LOG_NUM("this->actor.arg_data", this->actor.params, "../z_mir_ray.c", 518); + LOG_NUM("pthis->actor.arg_data", pthis->actor.params, "../z_mir_ray.c", 518); - if (this->actor.params >= 0xA) { + if (pthis->actor.params >= 0xA) { // "Reflected light generation failure" LOG_STRING("反射光 発生失敗", "../z_mir_ray.c", 521); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - this->sourcePt.x = dataEntry->sourcePoint.x; - this->sourcePt.y = dataEntry->sourcePoint.y; - this->sourcePt.z = dataEntry->sourcePoint.z; - this->sourceEndRad = dataEntry->sourceEndRadius; + pthis->sourcePt.x = dataEntry->sourcePoint.x; + pthis->sourcePt.y = dataEntry->sourcePoint.y; + pthis->sourcePt.z = dataEntry->sourcePoint.z; + pthis->sourceEndRad = dataEntry->sourceEndRadius; - this->poolPt.x = dataEntry->poolPoint.x; - this->poolPt.y = dataEntry->poolPoint.y; - this->poolPt.z = dataEntry->poolPoint.z; - this->poolEndRad = dataEntry->poolEndRadius; + pthis->poolPt.x = dataEntry->poolPoint.x; + pthis->poolPt.y = dataEntry->poolPoint.y; + pthis->poolPt.z = dataEntry->poolPoint.z; + pthis->poolEndRad = dataEntry->poolEndRadius; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->sourcePt.x, this->sourcePt.y, this->sourcePt.z, 255, 255, 255, + Lights_PointNoGlowSetInfo(&pthis->lightInfo, pthis->sourcePt.x, pthis->sourcePt.y, pthis->sourcePt.z, 255, 255, 255, 100); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); - this->shieldCorners[0].x = -536.0f; - this->shieldCorners[0].y = -939.0f; + pthis->shieldCorners[0].x = -536.0f; + pthis->shieldCorners[0].y = -939.0f; - this->shieldCorners[1].x = -1690.0f; - this->shieldCorners[1].y = 0.0f; + pthis->shieldCorners[1].x = -1690.0f; + pthis->shieldCorners[1].y = 0.0f; - this->shieldCorners[2].x = -536.0f; - this->shieldCorners[2].y = 938.0f; + pthis->shieldCorners[2].x = -536.0f; + pthis->shieldCorners[2].y = 938.0f; - this->shieldCorners[3].x = 921.0f; - this->shieldCorners[3].y = 0.0f; + pthis->shieldCorners[3].x = 921.0f; + pthis->shieldCorners[3].y = 0.0f; - this->shieldCorners[4].x = 758.0f; - this->shieldCorners[4].y = 800.0f; + pthis->shieldCorners[4].x = 758.0f; + pthis->shieldCorners[4].y = 800.0f; - this->shieldCorners[5].x = 758.0f; - this->shieldCorners[5].y = -800.0f; + pthis->shieldCorners[5].x = 758.0f; + pthis->shieldCorners[5].y = -800.0f; if (dataEntry->params & 2) { - Collider_InitJntSph(globalCtx, &this->colliderSph); - Collider_SetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInit, &this->colliderSphItem); + Collider_InitJntSph(globalCtx, &pthis->colliderSph); + Collider_SetJntSph(globalCtx, &pthis->colliderSph, &pthis->actor, &sJntSphInit, &pthis->colliderSphItem); if (!(dataEntry->params & 4)) { // Beams not from mirrors - MirRay_SetupCollider(this); + MirRay_SetupCollider(pthis); } } - Collider_InitQuad(globalCtx, &this->shieldRay); - Collider_SetQuad(globalCtx, &this->shieldRay, &this->actor, &sQuadInit); + Collider_InitQuad(globalCtx, &pthis->shieldRay); + Collider_SetQuad(globalCtx, &pthis->shieldRay, &pthis->actor, &sQuadInit); // Spirit Temple top room mirrors - if ((this->actor.params == 5) || (this->actor.params == 7) || (this->actor.params == 8)) { - this->actor.room = -1; + if ((pthis->actor.params == 5) || (pthis->actor.params == 7) || (pthis->actor.params == 8)) { + pthis->actor.room = -1; } } void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { - MirRay* this = (MirRay*)thisx; + MirRay* pthis = (MirRay*)thisx; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); - if (sMirRayData[this->actor.params].params & 2) { - Collider_DestroyJntSph(globalCtx, &this->colliderSph); + if (sMirRayData[pthis->actor.params].params & 2) { + Collider_DestroyJntSph(globalCtx, &pthis->colliderSph); } - Collider_DestroyQuad(globalCtx, &this->shieldRay); + Collider_DestroyQuad(globalCtx, &pthis->shieldRay); } void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - MirRay* this = (MirRay*)thisx; + MirRay* pthis = (MirRay*)thisx; Player* player = GET_PLAYER(globalCtx); D_80B8E670 = 0; - if (!this->unLit) { - if (sMirRayData[this->actor.params].params & 2) { - if (sMirRayData[this->actor.params].params & 4) { // Beams from mirrors - MirRay_SetupCollider(this); + if (!pthis->unLit) { + if (sMirRayData[pthis->actor.params].params & 2) { + if (sMirRayData[pthis->actor.params].params & 4) { // Beams from mirrors + MirRay_SetupCollider(pthis); } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderSph.base); } - if (this->reflectIntensity > 0.0f) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->shieldRay.base); + if (pthis->reflectIntensity > 0.0f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->shieldRay.base); } - MirRay_MakeShieldLight(this, globalCtx); + MirRay_MakeShieldLight(pthis, globalCtx); - if (this->reflectIntensity > 0.0f) { + if (pthis->reflectIntensity > 0.0f) { func_8002F8F0(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); } } } -void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { +void MirRay_SetIntensity(MirRay* pthis, GlobalContext* globalCtx) { f32 sp4C[3]; f32 temp_f0; f32 temp_f0_2; @@ -281,33 +281,33 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); MtxF* shieldMtx = &player->shieldMf; - this->reflectIntensity = 0.0f; + pthis->reflectIntensity = 0.0f; - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->xw, shieldMtx->yw, shieldMtx->zw, - this->sourceEndRad, this->poolEndRad)) { + if (MirRay_CheckInFrustum(&pthis->sourcePt, &pthis->poolPt, shieldMtx->xw, shieldMtx->yw, shieldMtx->zw, + pthis->sourceEndRad, pthis->poolEndRad)) { temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->xz) + SQ(shieldMtx->yz))); if (temp_f0 == 0.0f) { - this->reflectRange = 1.0f; + pthis->reflectRange = 1.0f; } else { - this->reflectRange = 1.0f / temp_f0; + pthis->reflectRange = 1.0f / temp_f0; } // If light beam is adirectional, always reflect, else only reflect if shield is pointing in correct direction - if (sMirRayData[this->actor.params].params & 1) { - this->reflectIntensity = 1.0f; + if (sMirRayData[pthis->actor.params].params & 1) { + pthis->reflectIntensity = 1.0f; } else { - sp4C[0] = this->poolPt.x - this->sourcePt.x; - sp4C[1] = this->poolPt.y - this->sourcePt.y; - sp4C[2] = this->poolPt.z - this->sourcePt.z; + sp4C[0] = pthis->poolPt.x - pthis->sourcePt.x; + sp4C[1] = pthis->poolPt.y - pthis->sourcePt.y; + sp4C[2] = pthis->poolPt.z - pthis->sourcePt.z; temp_f2_2 = -shieldMtx->xz * sp4C[0] - shieldMtx->yz * sp4C[1] - shieldMtx->zz * sp4C[2]; if (temp_f2_2 < 0.0f) { temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); if ((temp_f0 != 0.0f) && (temp_f0_2 != 0.0f)) { - this->reflectIntensity = -temp_f2_2 / (temp_f0 * temp_f0_2); + pthis->reflectIntensity = -temp_f2_2 / (temp_f0 * temp_f0_2); } } } @@ -316,7 +316,7 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { // Draws six images, one for each corner of the shield, by finding the intersection of a line segment from the corner // perpendicular to the shield with the nearest collision (if any). -void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { +void MirRay_SetupReflectionPolys(MirRay* pthis, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { Player* player = GET_PLAYER(globalCtx); MtxF* shieldMtx; s32 i; @@ -328,19 +328,19 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS shieldMtx = &player->shieldMf; - sp60.x = -((*shieldMtx).xz * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60.y = -((*shieldMtx).yz * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60.z = -((*shieldMtx).zz * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60.x = -((*shieldMtx).xz * pthis->reflectRange) * pthis->reflectIntensity * 400.0f; + sp60.y = -((*shieldMtx).yz * pthis->reflectRange) * pthis->reflectIntensity * 400.0f; + sp60.z = -((*shieldMtx).zz * pthis->reflectRange) * pthis->reflectIntensity * 400.0f; sp60 = sp60; // Need something involving sp60 or the whole function changes for (i = 0; i < 6; i++) { - posA.x = ((*shieldMtx).xw + (this->shieldCorners[i].x * (*shieldMtx).xx)) + - (this->shieldCorners[i].y * (*shieldMtx).xy); - posA.y = ((*shieldMtx).yw + (this->shieldCorners[i].x * (*shieldMtx).yx)) + - (this->shieldCorners[i].y * (*shieldMtx).yy); - posA.z = ((*shieldMtx).zw + (this->shieldCorners[i].x * (*shieldMtx).zx)) + - (this->shieldCorners[i].y * (*shieldMtx).zy); + posA.x = ((*shieldMtx).xw + (pthis->shieldCorners[i].x * (*shieldMtx).xx)) + + (pthis->shieldCorners[i].y * (*shieldMtx).xy); + posA.y = ((*shieldMtx).yw + (pthis->shieldCorners[i].x * (*shieldMtx).yx)) + + (pthis->shieldCorners[i].y * (*shieldMtx).yy); + posA.z = ((*shieldMtx).zw + (pthis->shieldCorners[i].x * (*shieldMtx).zx)) + + (pthis->shieldCorners[i].y * (*shieldMtx).zy); posB.x = sp60.x + posA.x; posB.y = sp60.y + posA.y; posB.z = sp60.z + posA.z; @@ -373,7 +373,7 @@ void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { } // Creates the reflected beam's collider (to interact with objects) and places and orients the shield images -void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { +void MirRay_ReflectedBeam(MirRay* pthis, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { Player* player = GET_PLAYER(globalCtx); s32 i; f32 temp_f0; @@ -392,9 +392,9 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe shieldMtx = &player->shieldMf; - spE8.x = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8.y = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8.z = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8.x = -(shieldMtx->xz * pthis->reflectRange) * pthis->reflectIntensity * 400.0f; + spE8.y = -(shieldMtx->yz * pthis->reflectRange) * pthis->reflectIntensity * 400.0f; + spE8.z = -(shieldMtx->zz * pthis->reflectRange) * pthis->reflectIntensity * 400.0f; vecB.x = shieldMtx->xw; vecB.y = shieldMtx->yw; @@ -412,7 +412,7 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe vecC.y = vecD.y + (shieldMtx->yx * 300.0f); vecC.z = vecD.z + (shieldMtx->zx * 300.0f); - Collider_SetQuadVertices(&this->shieldRay, &vecA, &vecB, &vecC, &vecD); + Collider_SetQuadVertices(&pthis->shieldRay, &vecA, &vecB, &vecC, &vecD); for (i = 0; i < 6; i++) { currentReflection = &reflection[i]; @@ -430,7 +430,7 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); - if (temp_f0 < (this->reflectIntensity * 600.0f)) { + if (temp_f0 < (pthis->reflectIntensity * 600.0f)) { currentReflection->opacity = 200; } else { currentReflection->opacity = (s32)(800.0f - temp_f0); @@ -491,28 +491,28 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe } void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { - MirRay* this = (MirRay*)thisx; + MirRay* pthis = (MirRay*)thisx; Player* player = GET_PLAYER(globalCtx); s32 i; MirRayShieldReflection reflection[6]; s32 temp; - this->reflectIntensity = 0.0f; - if ((D_80B8E670 == 0) && !this->unLit && Player_HasMirrorShieldSetToDraw(globalCtx)) { + pthis->reflectIntensity = 0.0f; + if ((D_80B8E670 == 0) && !pthis->unLit && Player_HasMirrorShieldSetToDraw(globalCtx)) { Matrix_Mult(&player->shieldMf, MTXMODE_NEW); - MirRay_SetIntensity(this, globalCtx); - if (!(this->reflectIntensity <= 0.0f)) { + MirRay_SetIntensity(pthis, globalCtx); + if (!(pthis->reflectIntensity <= 0.0f)) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_mir_ray.c", 966); func_80093D84(globalCtx->state.gfxCtx); - Matrix_Scale(1.0f, 1.0f, this->reflectIntensity * 5.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, pthis->reflectIntensity * 5.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_mir_ray.c", 972), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 150, (s16)(temp = this->reflectIntensity * 100.0f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 150, (s16)(temp = pthis->reflectIntensity * 100.0f)); gSPDisplayList(POLY_XLU_DISP++, gShieldBeamGlowDL); - MirRay_SetupReflectionPolys(this, globalCtx, reflection); + MirRay_SetupReflectionPolys(pthis, globalCtx, reflection); MirRay_RemoveSimilarReflections(reflection); - MirRay_ReflectedBeam(this, globalCtx, reflection); + MirRay_ReflectedBeam(pthis, globalCtx, reflection); if (reflection[0].reflectionPoly == NULL) { reflection[0].opacity = 0; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c deleted file mode 100644 index bf5bc31eb..000000000 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ /dev/null @@ -1,961 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_BEAN_Z_OBJ_BEAN_C -#include "actor_common.h" -/* - * File: z_obj_bean.c - * Overlay: ovl_Obj_Bean - * Description: Bean plant spot - */ - -#include "z_obj_bean.h" -#include "objects/object_mamenoki/object_mamenoki.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/code_8006C3A0.h" -#include "def/code_800FD970.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" - -#define FLAGS ACTOR_FLAG_22 - -void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBean_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjBean_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjBean_WaitForPlayer(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_Fly(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_SetupFly(ObjBean* this); -void ObjBean_WaitForWater(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_SetupWaitForWater(ObjBean* this); -void ObjBean_SetupGrowWaterPhase1(ObjBean* this); -void ObjBean_GrowWaterPhase1(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_GrowWaterPhase2(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_SetupGrowWaterPhase2(ObjBean* this); -void ObjBean_GrowWaterPhase3(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_SetupGrowWaterPhase3(ObjBean* this); -void ObjBean_SetupGrown(ObjBean* this); -void ObjBean_FlattenLeaves(ObjBean* this); -void ObjBean_Grown(ObjBean* this); -void ObjBean_LeavesStill(ObjBean* this); -void ObjBean_SetupShakeLeaves(ObjBean* this); -void ObjBean_ShakeLeaves(ObjBean* this); -void ObjBean_SetupWaitForBean(ObjBean* this); -void ObjBean_WaitForBean(ObjBean* this, GlobalContext* globalCtx); -void func_80B8FE3C(ObjBean* this, GlobalContext* globalCtx); -void func_80B8FE00(ObjBean* this); -void func_80B8FE6C(ObjBean* this); -void func_80B8FEAC(ObjBean* this, GlobalContext* globalCtx); -void func_80B8FF50(ObjBean* this); -void ObjBean_SetupGrowWaterPhase4(ObjBean* this); -void func_80B8FF8C(ObjBean* this, GlobalContext* globalCtx); -void func_80B90050(ObjBean* this, GlobalContext* globalCtx); -void func_80B90010(ObjBean* this); -void func_80B908EC(ObjBean* this); -void func_80B90918(ObjBean* this, GlobalContext* globalCtx); -void func_80B90970(ObjBean* this); -void func_80B909B0(ObjBean* this, GlobalContext* globalCtx); -void func_80B909F8(ObjBean* this); -void func_80B90A34(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_SetupWaitForPlayer(ObjBean* this); -void ObjBean_GrowWaterPhase4(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_GrowWaterPhase5(ObjBean* this, GlobalContext* globalCtx); -void ObjBean_SetupGrowWaterPhase5(ObjBean* this); -void ObjBean_SetupShakeLeavesFast(ObjBean* this); -void ObjBean_ShakeLeavesFast(ObjBean* this); -void ObjBean_Grow(ObjBean* this); -void ObjBean_SetupGrow(ObjBean* this); -void ObjBean_SetupWaitForStepOff(ObjBean* this); -void ObjBean_WaitForStepOff(ObjBean* this, GlobalContext* globalCtx); - -#define BEAN_STATE_DRAW_LEAVES (1 << 0) -#define BEAN_STATE_DRAW_SOIL (1 << 1) -#define BEAN_STATE_DRAW_PLANT (1 << 2) -#define BEAN_STATE_DRAW_STALK (1 << 3) -#define BEAN_STATE_COLLIDER_SET (1 << 4) -#define BEAN_STATE_DYNAPOLY_SET (1 << 5) -#define BEAN_STATE_BEEN_WATERED (1 << 6) -#define BEAN_STATE_PLAYER_ON_TOP (1 << 7) - -static ObjBean* D_80B90E30 = NULL; - -const ActorInit Obj_Bean_InitVars = { - ACTOR_OBJ_BEAN, - ACTORCAT_BG, - FLAGS, - OBJECT_MAMENOKI, - sizeof(ObjBean), - (ActorFunc)ObjBean_Init, - (ActorFunc)ObjBean_Destroy, - (ActorFunc)ObjBean_Update, - (ActorFunc)ObjBean_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_PLAYER, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_NONE, - OCELEM_ON, - }, - { 64, 30, -31, { 0, 0, 0 } }, -}; - -typedef struct { - f32 velocity; - f32 accel; -} BeenSpeedInfo; - -static BeenSpeedInfo sBeanSpeeds[] = { - { 3.0f, 0.3f }, - { 10.0f, 0.5f }, - { 30.0f, 0.5f }, - { 3.0f, 0.3f }, -}; - -static Gfx* sBreakDlists[] = { gCuttableShrubStalkDL, gCuttableShrubTipDL }; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1600, ICHAIN_STOP), -}; - -void ObjBean_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - ObjBean* this = (ObjBean*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); -} - -void ObjBean_InitDynaPoly(ObjBean* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { - s32 pad; - CollisionHeader* colHeader; - s32 pad2; - - colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, moveFlag); - CollisionHeader_GetVirtual(collision, &colHeader); - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_bean.c", 374, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void ObjBean_FindFloor(ObjBean* this, GlobalContext* globalCtx) { - Vec3f vec; - s32 sp20; - - vec.x = this->dyna.actor.world.pos.x; - vec.y = this->dyna.actor.world.pos.y + 29.999998f; - vec.z = this->dyna.actor.world.pos.z; - this->dyna.actor.floorHeight = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp20, &this->dyna.actor, &vec); -} - -void func_80B8EBC8(ObjBean* this) { - this->unk_1B6.x = this->unk_1B6.y = this->unk_1B6.z = 0; - this->unk_1E4 = 0.0f; -} - -void ObjBean_UpdatePosition(ObjBean* this) { - f32 temp_f20; - - this->unk_1B6.x += 0xB6; - this->unk_1B6.y += 0xFB; - this->unk_1B6.z += 0x64; - - Math_StepToF(&this->unk_1E4, 2.0f, 0.1f); - temp_f20 = Math_SinS(this->unk_1B6.x * 3); - this->posOffsetX = (Math_SinS(((this->unk_1B6.y * 3))) + temp_f20) * this->unk_1E4; - temp_f20 = Math_CosS(this->unk_1B6.x * 4); - this->posOffsetZ = (Math_CosS((this->unk_1B6.y * 4)) + temp_f20) * this->unk_1E4; - temp_f20 = Math_SinS(this->unk_1B6.z * 5); - - this->dyna.actor.scale.x = this->dyna.actor.scale.z = - ((Math_SinS((this->unk_1B6.y * 8)) * 0.01f) + (temp_f20 * 0.06f) + 1.07f) * 0.1f; - - this->dyna.actor.scale.y = ((Math_CosS(((this->unk_1B6.z * 10))) * 0.2f) + 1.0f) * 0.1f; - temp_f20 = Math_SinS(this->unk_1B6.x * 3); - this->dyna.actor.shape.rot.y = - (Math_SinS((s16)(this->unk_1B6.z * 2)) * 2100.0f) + ((f32)this->dyna.actor.home.rot.y + (temp_f20 * 1000.0f)); -} - -void func_80B8EDF4(ObjBean* this) { - this->unk_1B6.x = this->unk_1B6.y = this->unk_1B6.z = 0; - - Actor_SetScale(&this->dyna.actor, 0.0f); -} - -void func_80B8EE24(ObjBean* this) { - this->unk_1B6.x += 0x384; - if (this->unk_1B6.x > 0x5FFF) { - this->unk_1B6.x = 0x5FFF; - } - this->unk_1B6.y += 0x258; - if (this->unk_1B6.y > 0x4000) { - this->unk_1B6.y = 0x4000; - } - this->dyna.actor.scale.y = Math_SinS(this->unk_1B6.x) * 0.16970563f; - - this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_SinS(this->unk_1B6.y) * 0.10700001f; - - Math_StepToF(&this->posOffsetX, 0.0f, 0.1f); - Math_StepToF(&this->posOffsetZ, 0.0f, 0.1f); - Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y, 0x64); -} - -void ObjBean_Move(ObjBean* this) { - this->dyna.actor.world.pos.x = this->pathPoints.x + this->posOffsetX; - this->dyna.actor.world.pos.y = this->pathPoints.y; - this->dyna.actor.world.pos.z = this->pathPoints.z + this->posOffsetZ; -} - -void ObjBean_SetDrawMode(ObjBean* this, u8 drawFlag) { - this->stateFlags &= - ~(BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_PLANT | BEAN_STATE_DRAW_STALK | BEAN_STATE_DRAW_SOIL); - this->stateFlags |= drawFlag; -} - -void ObjBean_SetupPathCount(ObjBean* this, GlobalContext* globalCtx) { - this->pathCount = globalCtx->setupPathList[(this->dyna.actor.params >> 8) & 0x1F].count - 1; - this->currentPointIndex = 0; - this->nextPointIndex = 1; -} - -void ObjBean_SetupPath(ObjBean* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[(this->dyna.actor.params >> 8) & 0x1F]; - Math_Vec3s_ToVec3f(&this->pathPoints, SEGMENTED_TO_VIRTUAL(path->points)); -} - -void ObjBean_FollowPath(ObjBean* this, GlobalContext* globalCtx) { - Path* path; - Vec3f acell; - Vec3f pathPointsFloat; - f32 speed; - Vec3s* nextPathPoint; - Vec3s* currentPoint; - Vec3s* sp4C; - Vec3f sp40; - Vec3f sp34; - f32 sp30; - f32 mag; - - Math_StepToF(&this->dyna.actor.speedXZ, sBeanSpeeds[this->unk_1F6].velocity, sBeanSpeeds[this->unk_1F6].accel); - path = &globalCtx->setupPathList[(this->dyna.actor.params >> 8) & 0x1F]; - nextPathPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->nextPointIndex]; - - Math_Vec3s_ToVec3f(&pathPointsFloat, nextPathPoint); - - Math_Vec3f_Diff(&pathPointsFloat, &this->pathPoints, &acell); - mag = Math3D_Vec3fMagnitude(&acell); - speed = CLAMP_MIN(this->dyna.actor.speedXZ, 0.5f); - if (speed > mag) { - currentPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->currentPointIndex]; - - Math_Vec3f_Copy(&this->pathPoints, &pathPointsFloat); - this->currentPointIndex = this->nextPointIndex; - - if (this->pathCount <= this->currentPointIndex) { - this->nextPointIndex = 0; - } else { - this->nextPointIndex++; - } - sp4C = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->nextPointIndex]; - Math_Vec3s_DiffToVec3f(&sp40, nextPathPoint, currentPoint); - Math_Vec3s_DiffToVec3f(&sp34, sp4C, nextPathPoint); - if (Math3D_CosOut(&sp40, &sp34, &sp30)) { - this->dyna.actor.speedXZ = 0.0f; - } else { - this->dyna.actor.speedXZ *= (sp30 + 1.0f) * 0.5f; - } - } else { - Math_Vec3f_Scale(&acell, this->dyna.actor.speedXZ / mag); - this->pathPoints.x += acell.x; - this->pathPoints.y += acell.y; - this->pathPoints.z += acell.z; - } -} - -s32 ObjBean_CheckForHorseTrample(ObjBean* this, GlobalContext* globalCtx) { - Actor* currentActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].head; - - while (currentActor != NULL) { - if ((currentActor->id == ACTOR_EN_HORSE) && - (Math3D_Vec3fDistSq(¤tActor->world.pos, &this->dyna.actor.world.pos) < 10000.0f)) { - return true; - } - currentActor = currentActor->next; - } - - return false; -} - -void ObjBean_Break(ObjBean* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f velocity; - f32 temp_f20; - s16 angle; - s32 scale; - s32 i; - s16 gravity; - s16 arg5; - - angle = 0; - for (i = 0; i < 36; i++) { - angle += 0x4E20; - temp_f20 = Rand_ZeroOne() * 60.0f; - - pos.x = (Math_SinS(angle) * temp_f20) + this->dyna.actor.world.pos.x; - pos.y = this->dyna.actor.world.pos.y; - pos.z = (Math_CosS(angle) * temp_f20) + this->dyna.actor.world.pos.z; - - velocity.x = Math_SinS(angle) * 3.5f; - velocity.y = Rand_ZeroOne() * 13.0f; - velocity.z = Math_CosS(angle) * 3.5f; - - velocity.x += this->dyna.actor.world.pos.x - this->dyna.actor.prevPos.x; - velocity.y += this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y; - velocity.z += this->dyna.actor.world.pos.z - this->dyna.actor.prevPos.z; - - scale = (s32)(Rand_ZeroOne() * 180.0f) + 30; - if (scale < 90) { - if (Rand_ZeroOne() < 0.1f) { - gravity = -80; - arg5 = 96; - } else { - gravity = -80; - arg5 = 64; - } - } else { - gravity = -100; - arg5 = 64; - } - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, gravity, arg5, 40, 3, 0, scale, 0, 0, - (s16)((scale >> 3) + 40), -1, 1, sBreakDlists[i & 1]); - } -} - -void ObjBean_UpdateLeaves(ObjBean* this) { - Math_StepToS(&this->unk_1C2, this->unk_1C4, this->unk_1C6); - Math_StepToS(&this->unk_1C8, this->unk_1CA, this->unk_1CC); - this->unk_1CE += this->unk_1C8; - this->leafRotFactor = 6372.0f - Math_SinS(this->unk_1CE) * (f32)this->unk_1C2; - this->dyna.actor.scale.y = Math_SinS(this->leafRotFactor) * 0.17434467f; - this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_CosS(this->leafRotFactor) * 0.12207746f; -} - -void ObjBean_SetupLeavesStill(ObjBean* this) { - this->transformFunc = ObjBean_LeavesStill; - this->unk_1C0 = Rand_S16Offset(12, 40); - this->unk_1C4 = Rand_S16Offset(0xC8, 0x190); - this->unk_1C6 = 0x14; - this->unk_1CA = Rand_S16Offset(0x64, 0x320); - this->unk_1CC = 0x14; -} - -void ObjBean_LeavesStill(ObjBean* this) { - this->unk_1C0--; - ObjBean_UpdateLeaves(this); - if (this->unk_1C0 < 0) { - ObjBean_SetupShakeLeaves(this); - } -} - -void ObjBean_SetupShakeLeaves(ObjBean* this) { - this->transformFunc = ObjBean_ShakeLeaves; - this->unk_1C0 = Rand_S16Offset(30, 4); - this->unk_1C4 = Rand_S16Offset(0x7D0, 0x3E8); - this->unk_1C6 = 0xC8; - this->unk_1CA = Rand_S16Offset(0x36B0, 0x1770); - this->unk_1CC = 0xFA0; - this->leafRotFactor = 0x18E4; -} - -void ObjBean_ShakeLeaves(ObjBean* this) { - this->unk_1C0 += -1; - if (this->unk_1C0 == 14) { - this->unk_1C4 = Rand_S16Offset(0xC8, 0x190); - this->unk_1CA = Rand_S16Offset(0x64, 0x1F4); - this->unk_1CC = 0x7D0; - } - ObjBean_UpdateLeaves(this); - if (this->unk_1C0 < 0) { - ObjBean_SetupLeavesStill(this); - } -} - -void ObjBean_SetupShakeLeavesFast(ObjBean* this) { - this->transformFunc = ObjBean_ShakeLeavesFast; - this->unk_1C0 = 0x28; - this->unk_1C4 = 0xBB8; - this->unk_1C6 = 0x12C; - this->unk_1CA = 0x3A98; - this->unk_1CC = 0xFA0; - this->leafRotFactor = 0x18E4; -} - -void ObjBean_ShakeLeavesFast(ObjBean* this) { - this->unk_1C0 += -1; - if (Rand_ZeroOne() < 0.1f) { - this->unk_1C4 = Rand_S16Offset(0x898, 0x3E8); - this->unk_1CA = Rand_S16Offset(0x2EE0, 0x1F40); - } - ObjBean_UpdateLeaves(this); - if ((s32)this->unk_1C0 < 0) { - ObjBean_SetupGrow(this); - } -} - -void ObjBean_SetupGrow(ObjBean* this) { - this->transformFunc = ObjBean_Grow; -} - -void ObjBean_Grow(ObjBean* this) { - Math_StepToS(&this->leafRotFactor, 0x33E9, 0x168); - this->dyna.actor.scale.y = Math_SinS(this->leafRotFactor) * 0.17434467f; - this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_CosS(this->leafRotFactor) * 0.12207746f; - ; -} - -void ObjBean_SetupFlattenLeaves(ObjBean* this) { - this->transformFunc = ObjBean_FlattenLeaves; - this->leafRotFactor = 0x33E9; -} - -void ObjBean_FlattenLeaves(ObjBean* this) { - this->leafRotFactor -= 0x960; - this->dyna.actor.scale.y = Math_SinS(this->leafRotFactor) * 0.17434467f; - this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_CosS(this->leafRotFactor) * 0.12207746f; - - if (this->leafRotFactor < 0x18E4) { - ObjBean_SetupGrown(this); - } -} - -void ObjBean_SetupGrown(ObjBean* this) { - this->transformFunc = ObjBean_Grown; - this->unk_1C2 = 0xBB8; - this->unk_1C4 = 0; - this->unk_1C6 = 0xC8; - this->unk_1C8 = 0x3E80; - this->unk_1CA = 0x1F4; - this->unk_1CC = 0; - this->unk_1C0 = 0x10; -} - -void ObjBean_Grown(ObjBean* this) { - this->unk_1C0--; - if (this->unk_1C0 == 6) { - this->unk_1CC = 0x7D0; - } - ObjBean_UpdateLeaves(this); - if (this->unk_1C2 <= 0) { - ObjBean_SetupLeavesStill(this); - } -} - -void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 path; - s32 linkAge; - ObjBean* this = (ObjBean*)thisx; - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (LINK_AGE_IN_YEARS == YEARS_ADULT) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) || (mREG(1) == 1)) { - path = (this->dyna.actor.params >> 8) & 0x1F; - if (path == 0x1F) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "No path data?" - osSyncPrintf("パスデータが無い?(%s %d)(arg_data %xH)\n", "../z_obj_bean.c", 909, - this->dyna.actor.params); - osSyncPrintf(VT_RST); - Actor_Kill(&this->dyna.actor); - return; - } - if (globalCtx->setupPathList[path].count < 3) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "Incorrect number of path data" - osSyncPrintf("パスデータ数が不正(%s %d)(arg_data %xH)\n", "../z_obj_bean.c", 921, - this->dyna.actor.params); - osSyncPrintf(VT_RST); - Actor_Kill(&this->dyna.actor); - return; - } - ObjBean_SetupPathCount(this, globalCtx); - ObjBean_SetupPath(this, globalCtx); - ObjBean_Move(this); - ObjBean_SetupWaitForPlayer(this); - - ObjBean_InitDynaPoly(this, globalCtx, &gMagicBeanPlatformCol, DPM_UNK3); - this->stateFlags |= BEAN_STATE_DYNAPOLY_SET; - ObjBean_InitCollider(&this->dyna.actor, globalCtx); - this->stateFlags |= BEAN_STATE_COLLIDER_SET; - - ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 8.8f); - ObjBean_FindFloor(this, globalCtx); - this->unk_1F6 = this->dyna.actor.home.rot.z & 3; - } else { - Actor_Kill(&this->dyna.actor); - return; - } - } else if ((Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) != 0) || (mREG(1) == 1)) { - ObjBean_SetupWaitForWater(this); - } else { - ObjBean_SetupWaitForBean(this); - } - this->dyna.actor.world.rot.z = this->dyna.actor.home.rot.z = this->dyna.actor.shape.rot.z = 0; - // "Magic bean tree lift" - osSyncPrintf("(魔法の豆の木リフト)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void ObjBean_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjBean* this = (ObjBean*)thisx; - - if (this->stateFlags & BEAN_STATE_DYNAPOLY_SET) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } - if (this->stateFlags & BEAN_STATE_COLLIDER_SET) { - Collider_DestroyCylinder(globalCtx, &this->collider); - } - if (D_80B90E30 == this) { - D_80B90E30 = NULL; - } -} - -void ObjBean_SetupWaitForBean(ObjBean* this) { - this->actionFunc = ObjBean_WaitForBean; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES); - this->dyna.actor.textId = 0x2F; -} - -void ObjBean_WaitForBean(ObjBean* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->dyna.actor, globalCtx)) { - if (func_8002F368(globalCtx) == EXCH_ITEM_BEAN) { - func_80B8FE00(this); - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - } - } else { - func_8002F298(&this->dyna.actor, globalCtx, 40.0f, EXCH_ITEM_BEAN); - } -} - -void func_80B8FE00(ObjBean* this) { - this->actionFunc = func_80B8FE3C; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES); - this->timer = 60; -} - -// Link is looking at the soft soil -void func_80B8FE3C(ObjBean* this, GlobalContext* globalCtx) { - if (this->timer <= 0) { - func_80B8FE6C(this); - } -} - -void func_80B8FE6C(ObjBean* this) { - this->actionFunc = func_80B8FEAC; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); - Actor_SetScale(&this->dyna.actor, 0.01f); -} - -// The leaves are visable and growing -void func_80B8FEAC(ObjBean* this, GlobalContext* globalCtx) { - s32 temp_v1 = true; - - temp_v1 &= Math_StepToF(&this->dyna.actor.scale.y, 0.16672663f, 0.01f); - temp_v1 &= Math_StepToF(&this->dyna.actor.scale.x, 0.03569199f, 0.00113f); - - this->dyna.actor.scale.z = this->dyna.actor.scale.x; - if (temp_v1) { - if (this->timer <= 0) { - func_80B8FF50(this); - } - } else { - this->timer = 1; - } - func_8002F974(&this->dyna.actor, NA_SE_PL_PLANT_GROW_UP - SFX_FLAG); -} - -void func_80B8FF50(ObjBean* this) { - this->actionFunc = func_80B8FF8C; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); - this->unk_1B6.x = 0x33E9; -} - -void func_80B8FF8C(ObjBean* this, GlobalContext* globalCtx) { - this->unk_1B6.x -= 0x960; - this->dyna.actor.scale.y = Math_SinS(this->unk_1B6.x) * 0.17434467f; - this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_CosS(this->unk_1B6.x) * 0.12207746f; - if (this->unk_1B6.x < 0x18E4) { - func_80B90010(this); - } -} - -void func_80B90010(ObjBean* this) { - this->actionFunc = func_80B90050; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); - this->unk_1B6.x = 0; - this->unk_1B6.y = 0xBB8; -} - -// Control is returned to the player and the leaves start to flatten out -void func_80B90050(ObjBean* this, GlobalContext* globalCtx) { - s16 temp_a0; - f32 temp_f2; - - this->unk_1B6.x += 0x3E80; - this->unk_1B6.y += -0xC8; - temp_a0 = 6372.0f - Math_SinS(this->unk_1B6.x) * this->unk_1B6.y; - - this->dyna.actor.scale.y = Math_SinS(temp_a0) * 0.17434467f; - this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_CosS(temp_a0) * 0.12207746f; - if (this->unk_1B6.y < 0) { - ObjBean_SetupWaitForWater(this); - } -} - -void ObjBean_SetupWaitForWater(ObjBean* this) { - this->actionFunc = ObjBean_WaitForWater; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); - Actor_SetScale(&this->dyna.actor, 0.1f); - ObjBean_SetupLeavesStill(this); -} - -void ObjBean_WaitForWater(ObjBean* this, GlobalContext* globalCtx) { - this->transformFunc(this); - - if (!(this->stateFlags & BEAN_STATE_BEEN_WATERED) && Flags_GetEnv(globalCtx, 5) && (D_80B90E30 == NULL) && - (this->dyna.actor.xzDistToPlayer < 50.0f)) { - ObjBean_SetupGrowWaterPhase1(this); - D_80B90E30 = this; - OnePointCutscene_Init(globalCtx, 2210, -99, &this->dyna.actor, MAIN_CAM); - this->dyna.actor.flags |= ACTOR_FLAG_4; - return; - } - - if ((D_80B90E30 == this) && !Flags_GetEnv(globalCtx, 5)) { - D_80B90E30 = NULL; - if (D_80B90E30) {} - } -} - -void ObjBean_SetupGrowWaterPhase1(ObjBean* this) { - this->actionFunc = ObjBean_GrowWaterPhase1; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); - ObjBean_SetupShakeLeavesFast(this); - this->timer = 50; -} - -// Camera moves and leaves move quickly -void ObjBean_GrowWaterPhase1(ObjBean* this, GlobalContext* globalCtx) { - this->transformFunc(this); - if (this->timer <= 0) { - ObjBean_SetupGrowWaterPhase2(this); - } -} - -void ObjBean_SetupGrowWaterPhase2(ObjBean* this) { - this->actionFunc = ObjBean_GrowWaterPhase2; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_SOIL | BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_STALK); - this->stalkSizeMultiplier = 0.0f; -} - -// BeanStalk is visable and is growing -void ObjBean_GrowWaterPhase2(ObjBean* this, GlobalContext* globalCtx) { - this->transformFunc(this); - this->stalkSizeMultiplier += 0.001f; - this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y + (s16)(this->stalkSizeMultiplier * 700000.0f); - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->stalkSizeMultiplier * 800.0f; - if (this->stalkSizeMultiplier >= 0.1f) { // 100 Frames - ObjBean_SetupGrowWaterPhase3(this); - } - func_8002F974(&this->dyna.actor, NA_SE_PL_PLANT_TALLER - SFX_FLAG); -} - -void ObjBean_SetupGrowWaterPhase3(ObjBean* this) { - this->actionFunc = ObjBean_GrowWaterPhase3; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_SOIL | BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_STALK); - this->timer = 60; -} - -// Fully grown and drops items -void ObjBean_GrowWaterPhase3(ObjBean* this, GlobalContext* globalCtx) { - s32 i; - Vec3f itemDropPos; - - this->transformFunc(this); - if (this->timer == 40) { - ObjBean_SetupFlattenLeaves(this); - } else if (this->timer == 30) { - if (!(this->stateFlags & BEAN_STATE_BEEN_WATERED)) { - itemDropPos.x = this->dyna.actor.world.pos.x; - itemDropPos.y = this->dyna.actor.world.pos.y - 25.0f; - itemDropPos.z = this->dyna.actor.world.pos.z; - for (i = 0; i < 3; i++) { - Item_DropCollectible(globalCtx, &itemDropPos, ITEM00_FLEXIBLE); - } - this->stateFlags |= BEAN_STATE_BEEN_WATERED; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - } else if (this->timer <= 0) { - ObjBean_SetupGrowWaterPhase4(this); - } -} - -void ObjBean_SetupGrowWaterPhase4(ObjBean* this) { - this->actionFunc = ObjBean_GrowWaterPhase4; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_SOIL | BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_STALK); - ObjBean_SetupGrow(this); -} - -// Return control back to the player and start to shrink back down -void ObjBean_GrowWaterPhase4(ObjBean* this, GlobalContext* globalCtx) { - this->transformFunc(this); - this->stalkSizeMultiplier -= 0.001f; - this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y + (s16)(this->stalkSizeMultiplier * 700000.0f); - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + (this->stalkSizeMultiplier * 800.0f); - if (this->stalkSizeMultiplier <= 0.0f) { - this->stalkSizeMultiplier = 0.0f; - this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; - ObjBean_SetupGrowWaterPhase5(this); - } -} - -void ObjBean_SetupGrowWaterPhase5(ObjBean* this) { - this->actionFunc = ObjBean_GrowWaterPhase5; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); - this->timer = 30; -} - -void ObjBean_GrowWaterPhase5(ObjBean* this, GlobalContext* globalCtx) { - this->transformFunc(this); - if (this->timer <= 0) { - func_80B8FF50(this); - this->dyna.actor.flags &= ~ACTOR_FLAG_4; - } -} - -void ObjBean_SetupWaitForPlayer(ObjBean* this) { - this->actionFunc = ObjBean_WaitForPlayer; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_PLANT); -} - -void ObjBean_WaitForPlayer(ObjBean* this, GlobalContext* globalCtx) { - if (func_8004356C(&this->dyna)) { // Player is standing on - ObjBean_SetupFly(this); - if (globalCtx->sceneNum == SCENE_SPOT10) { // Lost woods - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_LOST_WOODS); - } else { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_GENERIC); - } - } - ObjBean_UpdatePosition(this); -} - -void ObjBean_SetupFly(ObjBean* this) { - this->actionFunc = ObjBean_Fly; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_PLANT); - this->dyna.actor.speedXZ = 0.0f; - this->dyna.actor.flags |= ACTOR_FLAG_4; // Never stop updating -} - -void ObjBean_Fly(ObjBean* this, GlobalContext* globalCtx) { - Camera* camera; - - ObjBean_FollowPath(this, globalCtx); - if (this->currentPointIndex == this->pathCount) { - ObjBean_SetupPathCount(this, globalCtx); - ObjBean_SetupPath(this, globalCtx); - ObjBean_SetupWaitForStepOff(this); - - this->dyna.actor.flags &= ~ACTOR_FLAG_4; // Never stop updating (disable) - camera = globalCtx->cameraPtrs[MAIN_CAM]; - - if ((camera->setting == CAM_SET_BEAN_LOST_WOODS) || (camera->setting == CAM_SET_BEAN_GENERIC)) { - Camera_ChangeSetting(camera, CAM_SET_NORMAL0); - } - - } else if (func_8004356C(&this->dyna) != 0) { // Player is on top - - func_8002F974(&this->dyna.actor, NA_SE_PL_PLANT_MOVE - SFX_FLAG); - - if (globalCtx->sceneNum == SCENE_SPOT10) { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_LOST_WOODS); - } else { - Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_GENERIC); - } - } else if (this->stateFlags & BEAN_STATE_PLAYER_ON_TOP) { - camera = globalCtx->cameraPtrs[MAIN_CAM]; - - if ((camera->setting == CAM_SET_BEAN_LOST_WOODS) || (camera->setting == CAM_SET_BEAN_GENERIC)) { - Camera_ChangeSetting(camera, CAM_SET_NORMAL0); - } - } - - ObjBean_UpdatePosition(this); -} - -void ObjBean_SetupWaitForStepOff(ObjBean* this) { - this->actionFunc = ObjBean_WaitForStepOff; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_PLANT); -} - -void ObjBean_WaitForStepOff(ObjBean* this, GlobalContext* globalCtx) { - if (!func_80043590(&this->dyna)) { - ObjBean_SetupWaitForPlayer(this); - } - ObjBean_UpdatePosition(this); -} - -void func_80B908EC(ObjBean* this) { - this->actionFunc = func_80B90918; - ObjBean_SetDrawMode(this, 0); -} - -void func_80B90918(ObjBean* this, GlobalContext* globalCtx) { - if (!func_8004356C(&this->dyna)) { - ObjBean_SetupPathCount(this, globalCtx); - ObjBean_SetupPath(this, globalCtx); - ObjBean_Move(this); - func_80B90970(this); - } -} - -void func_80B90970(ObjBean* this) { - this->actionFunc = func_80B909B0; - ObjBean_SetDrawMode(this, 0); - this->timer = 100; - func_80B8EDF4(this); -} - -void func_80B909B0(ObjBean* this, GlobalContext* globalCtx) { - if (ObjBean_CheckForHorseTrample(this, globalCtx)) { - this->timer = 100; - } else if (this->timer <= 0) { - func_80B909F8(this); - } -} - -void func_80B909F8(ObjBean* this) { - this->actionFunc = func_80B90A34; - ObjBean_SetDrawMode(this, BEAN_STATE_DRAW_PLANT); - this->timer = 30; -} - -void func_80B90A34(ObjBean* this, GlobalContext* globalCtx) { - s32 trampled = ObjBean_CheckForHorseTrample(this, globalCtx); - - func_80B8EE24(this); - if (trampled) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } else { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } - if ((this->timer <= 0) && (!trampled)) { - func_80B8EBC8(this); - ObjBean_SetupWaitForPlayer(this); - } -} -void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjBean* this = (ObjBean*)thisx; - - if (this->timer > 0) { - this->timer--; - } - - this->actionFunc(this, globalCtx); - - if (this->stateFlags & BEAN_STATE_DRAW_PLANT) { - ObjBean_Move(this); - if (this->dyna.actor.xzDistToPlayer < 150.0f) { - this->collider.dim.radius = this->dyna.actor.scale.x * 640.0f + 0.5f; - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - - ObjBean_FindFloor(this, globalCtx); - - this->dyna.actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->dyna.actor.shape.shadowScale = this->dyna.actor.scale.x * 88.0f; - - if (ObjBean_CheckForHorseTrample(this, globalCtx)) { - osSyncPrintf(VT_FGCOL(CYAN)); - // "Horse and bean tree lift collision" - osSyncPrintf("馬と豆の木リフト衝突!!!\n"); - osSyncPrintf(VT_RST); - ObjBean_Break(this, globalCtx); - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - func_80B908EC(this); - } - } else { - this->dyna.actor.shape.shadowDraw = NULL; - } - Actor_SetFocus(&this->dyna.actor, 6.0f); - if (this->stateFlags & BEAN_STATE_DYNAPOLY_SET) { - if (func_8004356C(&this->dyna)) { - this->stateFlags |= BEAN_STATE_PLAYER_ON_TOP; - } else { - this->stateFlags &= ~BEAN_STATE_PLAYER_ON_TOP; - } - } -} - -void ObjBean_DrawSoftSoilSpot(ObjBean* this, GlobalContext* globalCtx) { - Matrix_Translate(this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, this->dyna.actor.home.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.home.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, gMagicBeanSoftSoilDL); -} - -void ObjBean_DrawBeanstalk(ObjBean* this, GlobalContext* globalCtx) { - Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_Scale(0.1f, this->stalkSizeMultiplier, 0.1f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, gMagicBeanStemDL); -} - -void ObjBean_Draw(Actor* thisx, GlobalContext* globalCtx) { - ObjBean* this = (ObjBean*)thisx; - - if (this->stateFlags & BEAN_STATE_DRAW_SOIL) { - Gfx_DrawDListOpa(globalCtx, gMagicBeanSeedlingDL); - } - if (this->stateFlags & BEAN_STATE_DRAW_PLANT) { - Gfx_DrawDListOpa(globalCtx, gMagicBeanPlatformDL); - } - if (this->stateFlags & BEAN_STATE_DRAW_LEAVES) { - ObjBean_DrawSoftSoilSpot(this, globalCtx); - } - if (this->stateFlags & BEAN_STATE_DRAW_STALK) { - ObjBean_DrawBeanstalk(this, globalCtx); - } -} diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.cpp b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.cpp new file mode 100644 index 000000000..dc510eee7 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.cpp @@ -0,0 +1,961 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_BEAN_Z_OBJ_BEAN_C +#include "actor_common.h" +/* + * File: z_obj_bean.c + * Overlay: ovl_Obj_Bean + * Description: Bean plant spot + */ + +#include "z_obj_bean.h" +#include "objects/object_mamenoki/object_mamenoki.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/code_8006C3A0.h" +#include "def/code_800FD970.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" + +#define FLAGS ACTOR_FLAG_22 + +void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjBean_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjBean_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjBean_WaitForPlayer(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_Fly(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_SetupFly(ObjBean* pthis); +void ObjBean_WaitForWater(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_SetupWaitForWater(ObjBean* pthis); +void ObjBean_SetupGrowWaterPhase1(ObjBean* pthis); +void ObjBean_GrowWaterPhase1(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_GrowWaterPhase2(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_SetupGrowWaterPhase2(ObjBean* pthis); +void ObjBean_GrowWaterPhase3(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_SetupGrowWaterPhase3(ObjBean* pthis); +void ObjBean_SetupGrown(ObjBean* pthis); +void ObjBean_FlattenLeaves(ObjBean* pthis); +void ObjBean_Grown(ObjBean* pthis); +void ObjBean_LeavesStill(ObjBean* pthis); +void ObjBean_SetupShakeLeaves(ObjBean* pthis); +void ObjBean_ShakeLeaves(ObjBean* pthis); +void ObjBean_SetupWaitForBean(ObjBean* pthis); +void ObjBean_WaitForBean(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B8FE3C(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B8FE00(ObjBean* pthis); +void func_80B8FE6C(ObjBean* pthis); +void func_80B8FEAC(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B8FF50(ObjBean* pthis); +void ObjBean_SetupGrowWaterPhase4(ObjBean* pthis); +void func_80B8FF8C(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B90050(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B90010(ObjBean* pthis); +void func_80B908EC(ObjBean* pthis); +void func_80B90918(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B90970(ObjBean* pthis); +void func_80B909B0(ObjBean* pthis, GlobalContext* globalCtx); +void func_80B909F8(ObjBean* pthis); +void func_80B90A34(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_SetupWaitForPlayer(ObjBean* pthis); +void ObjBean_GrowWaterPhase4(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_GrowWaterPhase5(ObjBean* pthis, GlobalContext* globalCtx); +void ObjBean_SetupGrowWaterPhase5(ObjBean* pthis); +void ObjBean_SetupShakeLeavesFast(ObjBean* pthis); +void ObjBean_ShakeLeavesFast(ObjBean* pthis); +void ObjBean_Grow(ObjBean* pthis); +void ObjBean_SetupGrow(ObjBean* pthis); +void ObjBean_SetupWaitForStepOff(ObjBean* pthis); +void ObjBean_WaitForStepOff(ObjBean* pthis, GlobalContext* globalCtx); + +#define BEAN_STATE_DRAW_LEAVES (1 << 0) +#define BEAN_STATE_DRAW_SOIL (1 << 1) +#define BEAN_STATE_DRAW_PLANT (1 << 2) +#define BEAN_STATE_DRAW_STALK (1 << 3) +#define BEAN_STATE_COLLIDER_SET (1 << 4) +#define BEAN_STATE_DYNAPOLY_SET (1 << 5) +#define BEAN_STATE_BEEN_WATERED (1 << 6) +#define BEAN_STATE_PLAYER_ON_TOP (1 << 7) + +static ObjBean* D_80B90E30 = NULL; + +ActorInit Obj_Bean_InitVars = { + ACTOR_OBJ_BEAN, + ACTORCAT_BG, + FLAGS, + OBJECT_MAMENOKI, + sizeof(ObjBean), + (ActorFunc)ObjBean_Init, + (ActorFunc)ObjBean_Destroy, + (ActorFunc)ObjBean_Update, + (ActorFunc)ObjBean_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 64, 30, -31, { 0, 0, 0 } }, +}; + +typedef struct { + f32 velocity; + f32 accel; +} BeenSpeedInfo; + +static BeenSpeedInfo sBeanSpeeds[] = { + { 3.0f, 0.3f }, + { 10.0f, 0.5f }, + { 30.0f, 0.5f }, + { 3.0f, 0.3f }, +}; + +static Gfx* sBreakDlists[] = { gCuttableShrubStalkDL, gCuttableShrubTipDL }; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1600, ICHAIN_STOP), +}; + +void ObjBean_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + ObjBean* pthis = (ObjBean*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); +} + +void ObjBean_InitDynaPoly(ObjBean* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { + s32 pad; + CollisionHeader* colHeader; + s32 pad2; + + colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, moveFlag); + CollisionHeader_GetVirtual(collision, &colHeader); + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_bean.c", 374, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void ObjBean_FindFloor(ObjBean* pthis, GlobalContext* globalCtx) { + Vec3f vec; + s32 sp20; + + vec.x = pthis->dyna.actor.world.pos.x; + vec.y = pthis->dyna.actor.world.pos.y + 29.999998f; + vec.z = pthis->dyna.actor.world.pos.z; + pthis->dyna.actor.floorHeight = + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, &sp20, &pthis->dyna.actor, &vec); +} + +void func_80B8EBC8(ObjBean* pthis) { + pthis->unk_1B6.x = pthis->unk_1B6.y = pthis->unk_1B6.z = 0; + pthis->unk_1E4 = 0.0f; +} + +void ObjBean_UpdatePosition(ObjBean* pthis) { + f32 temp_f20; + + pthis->unk_1B6.x += 0xB6; + pthis->unk_1B6.y += 0xFB; + pthis->unk_1B6.z += 0x64; + + Math_StepToF(&pthis->unk_1E4, 2.0f, 0.1f); + temp_f20 = Math_SinS(pthis->unk_1B6.x * 3); + pthis->posOffsetX = (Math_SinS(((pthis->unk_1B6.y * 3))) + temp_f20) * pthis->unk_1E4; + temp_f20 = Math_CosS(pthis->unk_1B6.x * 4); + pthis->posOffsetZ = (Math_CosS((pthis->unk_1B6.y * 4)) + temp_f20) * pthis->unk_1E4; + temp_f20 = Math_SinS(pthis->unk_1B6.z * 5); + + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = + ((Math_SinS((pthis->unk_1B6.y * 8)) * 0.01f) + (temp_f20 * 0.06f) + 1.07f) * 0.1f; + + pthis->dyna.actor.scale.y = ((Math_CosS(((pthis->unk_1B6.z * 10))) * 0.2f) + 1.0f) * 0.1f; + temp_f20 = Math_SinS(pthis->unk_1B6.x * 3); + pthis->dyna.actor.shape.rot.y = + (Math_SinS((s16)(pthis->unk_1B6.z * 2)) * 2100.0f) + ((f32)pthis->dyna.actor.home.rot.y + (temp_f20 * 1000.0f)); +} + +void func_80B8EDF4(ObjBean* pthis) { + pthis->unk_1B6.x = pthis->unk_1B6.y = pthis->unk_1B6.z = 0; + + Actor_SetScale(&pthis->dyna.actor, 0.0f); +} + +void func_80B8EE24(ObjBean* pthis) { + pthis->unk_1B6.x += 0x384; + if (pthis->unk_1B6.x > 0x5FFF) { + pthis->unk_1B6.x = 0x5FFF; + } + pthis->unk_1B6.y += 0x258; + if (pthis->unk_1B6.y > 0x4000) { + pthis->unk_1B6.y = 0x4000; + } + pthis->dyna.actor.scale.y = Math_SinS(pthis->unk_1B6.x) * 0.16970563f; + + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = Math_SinS(pthis->unk_1B6.y) * 0.10700001f; + + Math_StepToF(&pthis->posOffsetX, 0.0f, 0.1f); + Math_StepToF(&pthis->posOffsetZ, 0.0f, 0.1f); + Math_ScaledStepToS(&pthis->dyna.actor.shape.rot.y, pthis->dyna.actor.home.rot.y, 0x64); +} + +void ObjBean_Move(ObjBean* pthis) { + pthis->dyna.actor.world.pos.x = pthis->pathPoints.x + pthis->posOffsetX; + pthis->dyna.actor.world.pos.y = pthis->pathPoints.y; + pthis->dyna.actor.world.pos.z = pthis->pathPoints.z + pthis->posOffsetZ; +} + +void ObjBean_SetDrawMode(ObjBean* pthis, u8 drawFlag) { + pthis->stateFlags &= + ~(BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_PLANT | BEAN_STATE_DRAW_STALK | BEAN_STATE_DRAW_SOIL); + pthis->stateFlags |= drawFlag; +} + +void ObjBean_SetupPathCount(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->pathCount = globalCtx->setupPathList[(pthis->dyna.actor.params >> 8) & 0x1F].count - 1; + pthis->currentPointIndex = 0; + pthis->nextPointIndex = 1; +} + +void ObjBean_SetupPath(ObjBean* pthis, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[(pthis->dyna.actor.params >> 8) & 0x1F]; + Math_Vec3s_ToVec3f(&pthis->pathPoints, SEGMENTED_TO_VIRTUAL(path->points)); +} + +void ObjBean_FollowPath(ObjBean* pthis, GlobalContext* globalCtx) { + Path* path; + Vec3f acell; + Vec3f pathPointsFloat; + f32 speed; + Vec3s* nextPathPoint; + Vec3s* currentPoint; + Vec3s* sp4C; + Vec3f sp40; + Vec3f sp34; + f32 sp30; + f32 mag; + + Math_StepToF(&pthis->dyna.actor.speedXZ, sBeanSpeeds[pthis->unk_1F6].velocity, sBeanSpeeds[pthis->unk_1F6].accel); + path = &globalCtx->setupPathList[(pthis->dyna.actor.params >> 8) & 0x1F]; + nextPathPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[pthis->nextPointIndex]; + + Math_Vec3s_ToVec3f(&pathPointsFloat, nextPathPoint); + + Math_Vec3f_Diff(&pathPointsFloat, &pthis->pathPoints, &acell); + mag = Math3D_Vec3fMagnitude(&acell); + speed = CLAMP_MIN(pthis->dyna.actor.speedXZ, 0.5f); + if (speed > mag) { + currentPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[pthis->currentPointIndex]; + + Math_Vec3f_Copy(&pthis->pathPoints, &pathPointsFloat); + pthis->currentPointIndex = pthis->nextPointIndex; + + if (pthis->pathCount <= pthis->currentPointIndex) { + pthis->nextPointIndex = 0; + } else { + pthis->nextPointIndex++; + } + sp4C = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[pthis->nextPointIndex]; + Math_Vec3s_DiffToVec3f(&sp40, nextPathPoint, currentPoint); + Math_Vec3s_DiffToVec3f(&sp34, sp4C, nextPathPoint); + if (Math3D_CosOut(&sp40, &sp34, &sp30)) { + pthis->dyna.actor.speedXZ = 0.0f; + } else { + pthis->dyna.actor.speedXZ *= (sp30 + 1.0f) * 0.5f; + } + } else { + Math_Vec3f_Scale(&acell, pthis->dyna.actor.speedXZ / mag); + pthis->pathPoints.x += acell.x; + pthis->pathPoints.y += acell.y; + pthis->pathPoints.z += acell.z; + } +} + +s32 ObjBean_CheckForHorseTrample(ObjBean* pthis, GlobalContext* globalCtx) { + Actor* currentActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].head; + + while (currentActor != NULL) { + if ((currentActor->id == ACTOR_EN_HORSE) && + (Math3D_Vec3fDistSq(¤tActor->world.pos, &pthis->dyna.actor.world.pos) < 10000.0f)) { + return true; + } + currentActor = currentActor->next; + } + + return false; +} + +void ObjBean_Break(ObjBean* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f velocity; + f32 temp_f20; + s16 angle; + s32 scale; + s32 i; + s16 gravity; + s16 arg5; + + angle = 0; + for (i = 0; i < 36; i++) { + angle += 0x4E20; + temp_f20 = Rand_ZeroOne() * 60.0f; + + pos.x = (Math_SinS(angle) * temp_f20) + pthis->dyna.actor.world.pos.x; + pos.y = pthis->dyna.actor.world.pos.y; + pos.z = (Math_CosS(angle) * temp_f20) + pthis->dyna.actor.world.pos.z; + + velocity.x = Math_SinS(angle) * 3.5f; + velocity.y = Rand_ZeroOne() * 13.0f; + velocity.z = Math_CosS(angle) * 3.5f; + + velocity.x += pthis->dyna.actor.world.pos.x - pthis->dyna.actor.prevPos.x; + velocity.y += pthis->dyna.actor.world.pos.y - pthis->dyna.actor.prevPos.y; + velocity.z += pthis->dyna.actor.world.pos.z - pthis->dyna.actor.prevPos.z; + + scale = (s32)(Rand_ZeroOne() * 180.0f) + 30; + if (scale < 90) { + if (Rand_ZeroOne() < 0.1f) { + gravity = -80; + arg5 = 96; + } else { + gravity = -80; + arg5 = 64; + } + } else { + gravity = -100; + arg5 = 64; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, gravity, arg5, 40, 3, 0, scale, 0, 0, + (s16)((scale >> 3) + 40), -1, 1, sBreakDlists[i & 1]); + } +} + +void ObjBean_UpdateLeaves(ObjBean* pthis) { + Math_StepToS(&pthis->unk_1C2, pthis->unk_1C4, pthis->unk_1C6); + Math_StepToS(&pthis->unk_1C8, pthis->unk_1CA, pthis->unk_1CC); + pthis->unk_1CE += pthis->unk_1C8; + pthis->leafRotFactor = 6372.0f - Math_SinS(pthis->unk_1CE) * (f32)pthis->unk_1C2; + pthis->dyna.actor.scale.y = Math_SinS(pthis->leafRotFactor) * 0.17434467f; + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = Math_CosS(pthis->leafRotFactor) * 0.12207746f; +} + +void ObjBean_SetupLeavesStill(ObjBean* pthis) { + pthis->transformFunc = ObjBean_LeavesStill; + pthis->unk_1C0 = Rand_S16Offset(12, 40); + pthis->unk_1C4 = Rand_S16Offset(0xC8, 0x190); + pthis->unk_1C6 = 0x14; + pthis->unk_1CA = Rand_S16Offset(0x64, 0x320); + pthis->unk_1CC = 0x14; +} + +void ObjBean_LeavesStill(ObjBean* pthis) { + pthis->unk_1C0--; + ObjBean_UpdateLeaves(pthis); + if (pthis->unk_1C0 < 0) { + ObjBean_SetupShakeLeaves(pthis); + } +} + +void ObjBean_SetupShakeLeaves(ObjBean* pthis) { + pthis->transformFunc = ObjBean_ShakeLeaves; + pthis->unk_1C0 = Rand_S16Offset(30, 4); + pthis->unk_1C4 = Rand_S16Offset(0x7D0, 0x3E8); + pthis->unk_1C6 = 0xC8; + pthis->unk_1CA = Rand_S16Offset(0x36B0, 0x1770); + pthis->unk_1CC = 0xFA0; + pthis->leafRotFactor = 0x18E4; +} + +void ObjBean_ShakeLeaves(ObjBean* pthis) { + pthis->unk_1C0 += -1; + if (pthis->unk_1C0 == 14) { + pthis->unk_1C4 = Rand_S16Offset(0xC8, 0x190); + pthis->unk_1CA = Rand_S16Offset(0x64, 0x1F4); + pthis->unk_1CC = 0x7D0; + } + ObjBean_UpdateLeaves(pthis); + if (pthis->unk_1C0 < 0) { + ObjBean_SetupLeavesStill(pthis); + } +} + +void ObjBean_SetupShakeLeavesFast(ObjBean* pthis) { + pthis->transformFunc = ObjBean_ShakeLeavesFast; + pthis->unk_1C0 = 0x28; + pthis->unk_1C4 = 0xBB8; + pthis->unk_1C6 = 0x12C; + pthis->unk_1CA = 0x3A98; + pthis->unk_1CC = 0xFA0; + pthis->leafRotFactor = 0x18E4; +} + +void ObjBean_ShakeLeavesFast(ObjBean* pthis) { + pthis->unk_1C0 += -1; + if (Rand_ZeroOne() < 0.1f) { + pthis->unk_1C4 = Rand_S16Offset(0x898, 0x3E8); + pthis->unk_1CA = Rand_S16Offset(0x2EE0, 0x1F40); + } + ObjBean_UpdateLeaves(pthis); + if ((s32)pthis->unk_1C0 < 0) { + ObjBean_SetupGrow(pthis); + } +} + +void ObjBean_SetupGrow(ObjBean* pthis) { + pthis->transformFunc = ObjBean_Grow; +} + +void ObjBean_Grow(ObjBean* pthis) { + Math_StepToS(&pthis->leafRotFactor, 0x33E9, 0x168); + pthis->dyna.actor.scale.y = Math_SinS(pthis->leafRotFactor) * 0.17434467f; + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = Math_CosS(pthis->leafRotFactor) * 0.12207746f; + ; +} + +void ObjBean_SetupFlattenLeaves(ObjBean* pthis) { + pthis->transformFunc = ObjBean_FlattenLeaves; + pthis->leafRotFactor = 0x33E9; +} + +void ObjBean_FlattenLeaves(ObjBean* pthis) { + pthis->leafRotFactor -= 0x960; + pthis->dyna.actor.scale.y = Math_SinS(pthis->leafRotFactor) * 0.17434467f; + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = Math_CosS(pthis->leafRotFactor) * 0.12207746f; + + if (pthis->leafRotFactor < 0x18E4) { + ObjBean_SetupGrown(pthis); + } +} + +void ObjBean_SetupGrown(ObjBean* pthis) { + pthis->transformFunc = ObjBean_Grown; + pthis->unk_1C2 = 0xBB8; + pthis->unk_1C4 = 0; + pthis->unk_1C6 = 0xC8; + pthis->unk_1C8 = 0x3E80; + pthis->unk_1CA = 0x1F4; + pthis->unk_1CC = 0; + pthis->unk_1C0 = 0x10; +} + +void ObjBean_Grown(ObjBean* pthis) { + pthis->unk_1C0--; + if (pthis->unk_1C0 == 6) { + pthis->unk_1CC = 0x7D0; + } + ObjBean_UpdateLeaves(pthis); + if (pthis->unk_1C2 <= 0) { + ObjBean_SetupLeavesStill(pthis); + } +} + +void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 path; + s32 linkAge; + ObjBean* pthis = (ObjBean*)thisx; + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + if (LINK_AGE_IN_YEARS == YEARS_ADULT) { + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F) || (mREG(1) == 1)) { + path = (pthis->dyna.actor.params >> 8) & 0x1F; + if (path == 0x1F) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "No path data?" + osSyncPrintf("パスデータが無い?(%s %d)(arg_data %xH)\n", "../z_obj_bean.c", 909, + pthis->dyna.actor.params); + osSyncPrintf(VT_RST); + Actor_Kill(&pthis->dyna.actor); + return; + } + if (globalCtx->setupPathList[path].count < 3) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "Incorrect number of path data" + osSyncPrintf("パスデータ数が不正(%s %d)(arg_data %xH)\n", "../z_obj_bean.c", 921, + pthis->dyna.actor.params); + osSyncPrintf(VT_RST); + Actor_Kill(&pthis->dyna.actor); + return; + } + ObjBean_SetupPathCount(pthis, globalCtx); + ObjBean_SetupPath(pthis, globalCtx); + ObjBean_Move(pthis); + ObjBean_SetupWaitForPlayer(pthis); + + ObjBean_InitDynaPoly(pthis, globalCtx, &gMagicBeanPlatformCol, DPM_UNK3); + pthis->stateFlags |= BEAN_STATE_DYNAPOLY_SET; + ObjBean_InitCollider(&pthis->dyna.actor, globalCtx); + pthis->stateFlags |= BEAN_STATE_COLLIDER_SET; + + ActorShape_Init(&pthis->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 8.8f); + ObjBean_FindFloor(pthis, globalCtx); + pthis->unk_1F6 = pthis->dyna.actor.home.rot.z & 3; + } else { + Actor_Kill(&pthis->dyna.actor); + return; + } + } else if ((Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F) != 0) || (mREG(1) == 1)) { + ObjBean_SetupWaitForWater(pthis); + } else { + ObjBean_SetupWaitForBean(pthis); + } + pthis->dyna.actor.world.rot.z = pthis->dyna.actor.home.rot.z = pthis->dyna.actor.shape.rot.z = 0; + // "Magic bean tree lift" + osSyncPrintf("(魔法の豆の木リフト)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void ObjBean_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBean* pthis = (ObjBean*)thisx; + + if (pthis->stateFlags & BEAN_STATE_DYNAPOLY_SET) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } + if (pthis->stateFlags & BEAN_STATE_COLLIDER_SET) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); + } + if (D_80B90E30 == pthis) { + D_80B90E30 = NULL; + } +} + +void ObjBean_SetupWaitForBean(ObjBean* pthis) { + pthis->actionFunc = ObjBean_WaitForBean; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES); + pthis->dyna.actor.textId = 0x2F; +} + +void ObjBean_WaitForBean(ObjBean* pthis, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&pthis->dyna.actor, globalCtx)) { + if (func_8002F368(globalCtx) == EXCH_ITEM_BEAN) { + func_80B8FE00(pthis); + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + } + } else { + func_8002F298(&pthis->dyna.actor, globalCtx, 40.0f, EXCH_ITEM_BEAN); + } +} + +void func_80B8FE00(ObjBean* pthis) { + pthis->actionFunc = func_80B8FE3C; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES); + pthis->timer = 60; +} + +// Link is looking at the soft soil +void func_80B8FE3C(ObjBean* pthis, GlobalContext* globalCtx) { + if (pthis->timer <= 0) { + func_80B8FE6C(pthis); + } +} + +void func_80B8FE6C(ObjBean* pthis) { + pthis->actionFunc = func_80B8FEAC; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); + Actor_SetScale(&pthis->dyna.actor, 0.01f); +} + +// The leaves are visable and growing +void func_80B8FEAC(ObjBean* pthis, GlobalContext* globalCtx) { + s32 temp_v1 = true; + + temp_v1 &= Math_StepToF(&pthis->dyna.actor.scale.y, 0.16672663f, 0.01f); + temp_v1 &= Math_StepToF(&pthis->dyna.actor.scale.x, 0.03569199f, 0.00113f); + + pthis->dyna.actor.scale.z = pthis->dyna.actor.scale.x; + if (temp_v1) { + if (pthis->timer <= 0) { + func_80B8FF50(pthis); + } + } else { + pthis->timer = 1; + } + func_8002F974(&pthis->dyna.actor, NA_SE_PL_PLANT_GROW_UP - SFX_FLAG); +} + +void func_80B8FF50(ObjBean* pthis) { + pthis->actionFunc = func_80B8FF8C; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); + pthis->unk_1B6.x = 0x33E9; +} + +void func_80B8FF8C(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->unk_1B6.x -= 0x960; + pthis->dyna.actor.scale.y = Math_SinS(pthis->unk_1B6.x) * 0.17434467f; + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = Math_CosS(pthis->unk_1B6.x) * 0.12207746f; + if (pthis->unk_1B6.x < 0x18E4) { + func_80B90010(pthis); + } +} + +void func_80B90010(ObjBean* pthis) { + pthis->actionFunc = func_80B90050; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); + pthis->unk_1B6.x = 0; + pthis->unk_1B6.y = 0xBB8; +} + +// Control is returned to the player and the leaves start to flatten out +void func_80B90050(ObjBean* pthis, GlobalContext* globalCtx) { + s16 temp_a0; + f32 temp_f2; + + pthis->unk_1B6.x += 0x3E80; + pthis->unk_1B6.y += -0xC8; + temp_a0 = 6372.0f - Math_SinS(pthis->unk_1B6.x) * pthis->unk_1B6.y; + + pthis->dyna.actor.scale.y = Math_SinS(temp_a0) * 0.17434467f; + pthis->dyna.actor.scale.x = pthis->dyna.actor.scale.z = Math_CosS(temp_a0) * 0.12207746f; + if (pthis->unk_1B6.y < 0) { + ObjBean_SetupWaitForWater(pthis); + } +} + +void ObjBean_SetupWaitForWater(ObjBean* pthis) { + pthis->actionFunc = ObjBean_WaitForWater; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); + Actor_SetScale(&pthis->dyna.actor, 0.1f); + ObjBean_SetupLeavesStill(pthis); +} + +void ObjBean_WaitForWater(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->transformFunc(pthis); + + if (!(pthis->stateFlags & BEAN_STATE_BEEN_WATERED) && Flags_GetEnv(globalCtx, 5) && (D_80B90E30 == NULL) && + (pthis->dyna.actor.xzDistToPlayer < 50.0f)) { + ObjBean_SetupGrowWaterPhase1(pthis); + D_80B90E30 = pthis; + OnePointCutscene_Init(globalCtx, 2210, -99, &pthis->dyna.actor, MAIN_CAM); + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + return; + } + + if ((D_80B90E30 == pthis) && !Flags_GetEnv(globalCtx, 5)) { + D_80B90E30 = NULL; + if (D_80B90E30) {} + } +} + +void ObjBean_SetupGrowWaterPhase1(ObjBean* pthis) { + pthis->actionFunc = ObjBean_GrowWaterPhase1; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); + ObjBean_SetupShakeLeavesFast(pthis); + pthis->timer = 50; +} + +// Camera moves and leaves move quickly +void ObjBean_GrowWaterPhase1(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->transformFunc(pthis); + if (pthis->timer <= 0) { + ObjBean_SetupGrowWaterPhase2(pthis); + } +} + +void ObjBean_SetupGrowWaterPhase2(ObjBean* pthis) { + pthis->actionFunc = ObjBean_GrowWaterPhase2; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_SOIL | BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_STALK); + pthis->stalkSizeMultiplier = 0.0f; +} + +// BeanStalk is visable and is growing +void ObjBean_GrowWaterPhase2(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->transformFunc(pthis); + pthis->stalkSizeMultiplier += 0.001f; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.home.rot.y + (s16)(pthis->stalkSizeMultiplier * 700000.0f); + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + pthis->stalkSizeMultiplier * 800.0f; + if (pthis->stalkSizeMultiplier >= 0.1f) { // 100 Frames + ObjBean_SetupGrowWaterPhase3(pthis); + } + func_8002F974(&pthis->dyna.actor, NA_SE_PL_PLANT_TALLER - SFX_FLAG); +} + +void ObjBean_SetupGrowWaterPhase3(ObjBean* pthis) { + pthis->actionFunc = ObjBean_GrowWaterPhase3; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_SOIL | BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_STALK); + pthis->timer = 60; +} + +// Fully grown and drops items +void ObjBean_GrowWaterPhase3(ObjBean* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f itemDropPos; + + pthis->transformFunc(pthis); + if (pthis->timer == 40) { + ObjBean_SetupFlattenLeaves(pthis); + } else if (pthis->timer == 30) { + if (!(pthis->stateFlags & BEAN_STATE_BEEN_WATERED)) { + itemDropPos.x = pthis->dyna.actor.world.pos.x; + itemDropPos.y = pthis->dyna.actor.world.pos.y - 25.0f; + itemDropPos.z = pthis->dyna.actor.world.pos.z; + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &itemDropPos, ITEM00_FLEXIBLE); + } + pthis->stateFlags |= BEAN_STATE_BEEN_WATERED; + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (pthis->timer <= 0) { + ObjBean_SetupGrowWaterPhase4(pthis); + } +} + +void ObjBean_SetupGrowWaterPhase4(ObjBean* pthis) { + pthis->actionFunc = ObjBean_GrowWaterPhase4; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_SOIL | BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_STALK); + ObjBean_SetupGrow(pthis); +} + +// Return control back to the player and start to shrink back down +void ObjBean_GrowWaterPhase4(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->transformFunc(pthis); + pthis->stalkSizeMultiplier -= 0.001f; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.home.rot.y + (s16)(pthis->stalkSizeMultiplier * 700000.0f); + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + (pthis->stalkSizeMultiplier * 800.0f); + if (pthis->stalkSizeMultiplier <= 0.0f) { + pthis->stalkSizeMultiplier = 0.0f; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.home.rot.y; + ObjBean_SetupGrowWaterPhase5(pthis); + } +} + +void ObjBean_SetupGrowWaterPhase5(ObjBean* pthis) { + pthis->actionFunc = ObjBean_GrowWaterPhase5; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_LEAVES | BEAN_STATE_DRAW_SOIL); + pthis->timer = 30; +} + +void ObjBean_GrowWaterPhase5(ObjBean* pthis, GlobalContext* globalCtx) { + pthis->transformFunc(pthis); + if (pthis->timer <= 0) { + func_80B8FF50(pthis); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; + } +} + +void ObjBean_SetupWaitForPlayer(ObjBean* pthis) { + pthis->actionFunc = ObjBean_WaitForPlayer; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_PLANT); +} + +void ObjBean_WaitForPlayer(ObjBean* pthis, GlobalContext* globalCtx) { + if (func_8004356C(&pthis->dyna)) { // Player is standing on + ObjBean_SetupFly(pthis); + if (globalCtx->sceneNum == SCENE_SPOT10) { // Lost woods + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_LOST_WOODS); + } else { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_GENERIC); + } + } + ObjBean_UpdatePosition(pthis); +} + +void ObjBean_SetupFly(ObjBean* pthis) { + pthis->actionFunc = ObjBean_Fly; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_PLANT); + pthis->dyna.actor.speedXZ = 0.0f; + pthis->dyna.actor.flags |= ACTOR_FLAG_4; // Never stop updating +} + +void ObjBean_Fly(ObjBean* pthis, GlobalContext* globalCtx) { + Camera* camera; + + ObjBean_FollowPath(pthis, globalCtx); + if (pthis->currentPointIndex == pthis->pathCount) { + ObjBean_SetupPathCount(pthis, globalCtx); + ObjBean_SetupPath(pthis, globalCtx); + ObjBean_SetupWaitForStepOff(pthis); + + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; // Never stop updating (disable) + camera = globalCtx->cameraPtrs[MAIN_CAM]; + + if ((camera->setting == CAM_SET_BEAN_LOST_WOODS) || (camera->setting == CAM_SET_BEAN_GENERIC)) { + Camera_ChangeSetting(camera, CAM_SET_NORMAL0); + } + + } else if (func_8004356C(&pthis->dyna) != 0) { // Player is on top + + func_8002F974(&pthis->dyna.actor, NA_SE_PL_PLANT_MOVE - SFX_FLAG); + + if (globalCtx->sceneNum == SCENE_SPOT10) { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_LOST_WOODS); + } else { + Camera_ChangeSetting(globalCtx->cameraPtrs[MAIN_CAM], CAM_SET_BEAN_GENERIC); + } + } else if (pthis->stateFlags & BEAN_STATE_PLAYER_ON_TOP) { + camera = globalCtx->cameraPtrs[MAIN_CAM]; + + if ((camera->setting == CAM_SET_BEAN_LOST_WOODS) || (camera->setting == CAM_SET_BEAN_GENERIC)) { + Camera_ChangeSetting(camera, CAM_SET_NORMAL0); + } + } + + ObjBean_UpdatePosition(pthis); +} + +void ObjBean_SetupWaitForStepOff(ObjBean* pthis) { + pthis->actionFunc = ObjBean_WaitForStepOff; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_PLANT); +} + +void ObjBean_WaitForStepOff(ObjBean* pthis, GlobalContext* globalCtx) { + if (!func_80043590(&pthis->dyna)) { + ObjBean_SetupWaitForPlayer(pthis); + } + ObjBean_UpdatePosition(pthis); +} + +void func_80B908EC(ObjBean* pthis) { + pthis->actionFunc = func_80B90918; + ObjBean_SetDrawMode(pthis, 0); +} + +void func_80B90918(ObjBean* pthis, GlobalContext* globalCtx) { + if (!func_8004356C(&pthis->dyna)) { + ObjBean_SetupPathCount(pthis, globalCtx); + ObjBean_SetupPath(pthis, globalCtx); + ObjBean_Move(pthis); + func_80B90970(pthis); + } +} + +void func_80B90970(ObjBean* pthis) { + pthis->actionFunc = func_80B909B0; + ObjBean_SetDrawMode(pthis, 0); + pthis->timer = 100; + func_80B8EDF4(pthis); +} + +void func_80B909B0(ObjBean* pthis, GlobalContext* globalCtx) { + if (ObjBean_CheckForHorseTrample(pthis, globalCtx)) { + pthis->timer = 100; + } else if (pthis->timer <= 0) { + func_80B909F8(pthis); + } +} + +void func_80B909F8(ObjBean* pthis) { + pthis->actionFunc = func_80B90A34; + ObjBean_SetDrawMode(pthis, BEAN_STATE_DRAW_PLANT); + pthis->timer = 30; +} + +void func_80B90A34(ObjBean* pthis, GlobalContext* globalCtx) { + s32 trampled = ObjBean_CheckForHorseTrample(pthis, globalCtx); + + func_80B8EE24(pthis); + if (trampled) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } else { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } + if ((pthis->timer <= 0) && (!trampled)) { + func_80B8EBC8(pthis); + ObjBean_SetupWaitForPlayer(pthis); + } +} +void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBean* pthis = (ObjBean*)thisx; + + if (pthis->timer > 0) { + pthis->timer--; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->stateFlags & BEAN_STATE_DRAW_PLANT) { + ObjBean_Move(pthis); + if (pthis->dyna.actor.xzDistToPlayer < 150.0f) { + pthis->collider.dim.radius = pthis->dyna.actor.scale.x * 640.0f + 0.5f; + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + + ObjBean_FindFloor(pthis, globalCtx); + + pthis->dyna.actor.shape.shadowDraw = ActorShadow_DrawCircle; + pthis->dyna.actor.shape.shadowScale = pthis->dyna.actor.scale.x * 88.0f; + + if (ObjBean_CheckForHorseTrample(pthis, globalCtx)) { + osSyncPrintf(VT_FGCOL(CYAN)); + // "Horse and bean tree lift collision" + osSyncPrintf("馬と豆の木リフト衝突!!!\n"); + osSyncPrintf(VT_RST); + ObjBean_Break(pthis, globalCtx); + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + func_80B908EC(pthis); + } + } else { + pthis->dyna.actor.shape.shadowDraw = NULL; + } + Actor_SetFocus(&pthis->dyna.actor, 6.0f); + if (pthis->stateFlags & BEAN_STATE_DYNAPOLY_SET) { + if (func_8004356C(&pthis->dyna)) { + pthis->stateFlags |= BEAN_STATE_PLAYER_ON_TOP; + } else { + pthis->stateFlags &= ~BEAN_STATE_PLAYER_ON_TOP; + } + } +} + +void ObjBean_DrawSoftSoilSpot(ObjBean* pthis, GlobalContext* globalCtx) { + Matrix_Translate(pthis->dyna.actor.home.pos.x, pthis->dyna.actor.home.pos.y, pthis->dyna.actor.home.pos.z, + MTXMODE_NEW); + Matrix_RotateY(pthis->dyna.actor.home.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, gMagicBeanSoftSoilDL); +} + +void ObjBean_DrawBeanstalk(ObjBean* pthis, GlobalContext* globalCtx) { + Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(pthis->dyna.actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Scale(0.1f, pthis->stalkSizeMultiplier, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, gMagicBeanStemDL); +} + +void ObjBean_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBean* pthis = (ObjBean*)thisx; + + if (pthis->stateFlags & BEAN_STATE_DRAW_SOIL) { + Gfx_DrawDListOpa(globalCtx, gMagicBeanSeedlingDL); + } + if (pthis->stateFlags & BEAN_STATE_DRAW_PLANT) { + Gfx_DrawDListOpa(globalCtx, gMagicBeanPlatformDL); + } + if (pthis->stateFlags & BEAN_STATE_DRAW_LEAVES) { + ObjBean_DrawSoftSoilSpot(pthis, globalCtx); + } + if (pthis->stateFlags & BEAN_STATE_DRAW_STALK) { + ObjBean_DrawBeanstalk(pthis, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.cpp similarity index 74% rename from src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c rename to src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.cpp index 13aecc1e7..e2b859bfb 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.cpp @@ -18,7 +18,7 @@ void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBlockstop_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Obj_Blockstop_InitVars = { +ActorInit Obj_Blockstop_InitVars = { ACTOR_OBJ_BLOCKSTOP, ACTORCAT_PROP, FLAGS, @@ -31,12 +31,12 @@ const ActorInit Obj_Blockstop_InitVars = { }; void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjBlockstop* this = (ObjBlockstop*)thisx; + ObjBlockstop* pthis = (ObjBlockstop*)thisx; - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - Actor_Kill(&this->actor); + if (Flags_GetSwitch(globalCtx, pthis->actor.params)) { + Actor_Kill(&pthis->actor); } else { - this->actor.world.pos.y++; + pthis->actor.world.pos.y++; } } @@ -44,14 +44,14 @@ void ObjBlockstop_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjBlockstop* this = (ObjBlockstop*)thisx; + ObjBlockstop* pthis = (ObjBlockstop*)thisx; DynaPolyActor* dynaPolyActor; Vec3f sp4C; s32 bgId; s32 pad; - if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &this->actor.home.pos, &this->actor.world.pos, &sp4C, - &this->actor.floorPoly, false, false, true, true, &bgId, &this->actor)) { + if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &pthis->actor.home.pos, &pthis->actor.world.pos, &sp4C, + &pthis->actor.floorPoly, false, false, true, true, &bgId, &pthis->actor)) { dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_OBJ_OSHIHIKI) { @@ -62,8 +62,8 @@ void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } - Flags_SetSwitch(globalCtx, this->actor.params); - Actor_Kill(&this->actor); + Flags_SetSwitch(globalCtx, pthis->actor.params); + Actor_Kill(&pthis->actor); } } } diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.cpp similarity index 71% rename from src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c rename to src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.cpp index 001325af4..d40829e8e 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.cpp @@ -25,9 +25,9 @@ void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjBombiwa_Break(ObjBombiwa* this, GlobalContext* globalCtx); +void ObjBombiwa_Break(ObjBombiwa* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Bombiwa_InitVars = { +ActorInit Obj_Bombiwa_InitVars = { ACTOR_OBJ_BOMBIWA, ACTORCAT_PROP, FLAGS, @@ -73,11 +73,11 @@ static s16 sEffectScales[] = { }; void ObjBombiwa_InitCollision(Actor* thisx, GlobalContext* globalCtx) { - ObjBombiwa* this = (ObjBombiwa*)thisx; + ObjBombiwa* pthis = (ObjBombiwa*)thisx; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); } void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -100,12 +100,12 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - ObjBombiwa* this = (ObjBombiwa*)thisx; + ObjBombiwa* pthis = (ObjBombiwa*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } -void ObjBombiwa_Break(ObjBombiwa* this, GlobalContext* globalCtx) { +void ObjBombiwa_Break(ObjBombiwa* pthis, GlobalContext* globalCtx) { Vec3f pos; Vec3f velocity; Gfx* dlist; @@ -115,9 +115,9 @@ void ObjBombiwa_Break(ObjBombiwa* this, GlobalContext* globalCtx) { dlist = object_bombiwa_DL_0009E0; for (i = 0; i < ARRAY_COUNT(sEffectScales); i++) { - pos.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.x; - pos.y = ((Rand_ZeroOne() * 5.0f) + this->actor.home.pos.y) + 8.0f; - pos.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.z; + pos.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + pthis->actor.home.pos.x; + pos.y = ((Rand_ZeroOne() * 5.0f) + pthis->actor.home.pos.y) + 8.0f; + pos.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + pthis->actor.home.pos.z; velocity.x = (Rand_ZeroOne() - 0.5f) * 15.0f; velocity.y = (Rand_ZeroOne() * 16.0f) + 5.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 15.0f; @@ -126,27 +126,27 @@ void ObjBombiwa_Break(ObjBombiwa* this, GlobalContext* globalCtx) { EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -400, arg5, 10, 2, 0, scale, 1, 0, 80, KAKERA_COLOR_NONE, OBJECT_BOMBIWA, dlist); } - func_80033480(globalCtx, &this->actor.world.pos, 60.0f, 8, 100, 160, 1); + func_80033480(globalCtx, &pthis->actor.world.pos, 60.0f, 8, 100, 160, 1); } void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjBombiwa* this = (ObjBombiwa*)thisx; + ObjBombiwa* pthis = (ObjBombiwa*)thisx; s32 pad; - if ((func_80033684(globalCtx, &this->actor) != NULL) || - ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x40000040))) { - ObjBombiwa_Break(this, globalCtx); - Flags_SetSwitch(globalCtx, this->actor.params & 0x3F); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); - if (((this->actor.params >> 0xF) & 1) != 0) { + if ((func_80033684(globalCtx, &pthis->actor) != NULL) || + ((pthis->collider.base.acFlags & AC_HIT) && (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x40000040))) { + ObjBombiwa_Break(pthis, globalCtx); + Flags_SetSwitch(globalCtx, pthis->actor.params & 0x3F); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + if (((pthis->actor.params >> 0xF) & 1) != 0) { func_80078884(NA_SE_SY_CORRECT_CHIME); } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.xzDistToPlayer < 800.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + pthis->collider.base.acFlags &= ~AC_HIT; + if (pthis->actor.xzDistToPlayer < 800.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } } diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.cpp similarity index 61% rename from src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c rename to src/overlays/actors/ovl_Obj_Comb/z_obj_comb.cpp index 515dd1e45..5ba71f45b 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.cpp @@ -25,12 +25,12 @@ void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjComb_Break(ObjComb* this, GlobalContext* globalCtx); -void ObjComb_ChooseItemDrop(ObjComb* this, GlobalContext* globalCtx); -void ObjComb_SetupWait(ObjComb* this); -void ObjComb_Wait(ObjComb* this, GlobalContext* globalCtx); +void ObjComb_Break(ObjComb* pthis, GlobalContext* globalCtx); +void ObjComb_ChooseItemDrop(ObjComb* pthis, GlobalContext* globalCtx); +void ObjComb_SetupWait(ObjComb* pthis); +void ObjComb_Wait(ObjComb* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Comb_InitVars = { +ActorInit Obj_Comb_InitVars = { ACTOR_OBJ_COMB, ACTORCAT_PROP, FLAGS, @@ -76,7 +76,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -void ObjComb_Break(ObjComb* this, GlobalContext* globalCtx) { +void ObjComb_Break(ObjComb* pthis, GlobalContext* globalCtx) { Vec3f pos1; Vec3f pos; Vec3f velocity; @@ -98,7 +98,7 @@ void ObjComb_Break(ObjComb* this, GlobalContext* globalCtx) { pos1.y = (i - 15) * 0.7f; pos1.z = Math_CosS(angle) * rand1; - Math_Vec3f_Sum(&pos1, &this->actor.world.pos, &pos); + Math_Vec3f_Sum(&pos1, &pthis->actor.world.pos, &pos); velocity.x = (Rand_ZeroOne() - 0.5f) + pos1.x * 0.5f; velocity.y = (Rand_ZeroOne() - 0.5f) + pos1.y * 0.6f; @@ -131,107 +131,107 @@ void ObjComb_Break(ObjComb* this, GlobalContext* globalCtx) { KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_FIELD_KEEP, dlist); } - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y - 10.0f; - pos.z = this->actor.world.pos.z; + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y - 10.0f; + pos.z = pthis->actor.world.pos.z; func_80033480(globalCtx, &pos, 40.0f, 6, 70, 60, 1); } -void ObjComb_ChooseItemDrop(ObjComb* this, GlobalContext* globalCtx) { - s16 params = this->actor.params & 0x1F; +void ObjComb_ChooseItemDrop(ObjComb* pthis, GlobalContext* globalCtx) { + s16 params = pthis->actor.params & 0x1F; if ((params > 0) || (params < 0x1A)) { if (params == 6) { - if (Flags_GetCollectible(globalCtx, (this->actor.params >> 8) & 0x3F)) { + if (Flags_GetCollectible(globalCtx, (pthis->actor.params >> 8) & 0x3F)) { params = -1; } else { - params = (params | (((this->actor.params >> 8) & 0x3F) << 8)); + params = (params | (((pthis->actor.params >> 8) & 0x3F) << 8)); } } else if (Rand_ZeroOne() < 0.5f) { params = -1; } if (params >= 0) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, params); + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, params); } } } void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjComb* this = (ObjComb*)thisx; + ObjComb* pthis = (ObjComb*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); - ObjComb_SetupWait(this); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sJntSphInit, pthis->colliderItems); + ObjComb_SetupWait(pthis); } void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - ObjComb* this = (ObjComb*)thisx; + ObjComb* pthis = (ObjComb*)thisx; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(globalCtx, &pthis->collider); } -void ObjComb_SetupWait(ObjComb* this) { - this->actionFunc = ObjComb_Wait; +void ObjComb_SetupWait(ObjComb* pthis) { + pthis->actionFunc = ObjComb_Wait; } -void ObjComb_Wait(ObjComb* this, GlobalContext* globalCtx) { +void ObjComb_Wait(ObjComb* pthis, GlobalContext* globalCtx) { s32 dmgFlags; - this->unk_1B0 -= 50; - if (this->unk_1B0 < 0) { - this->unk_1B0 = 0; + pthis->unk_1B0 -= 50; + if (pthis->unk_1B0 < 0) { + pthis->unk_1B0 = 0; } - if ((this->collider.base.acFlags & AC_HIT) != 0) { - this->collider.base.acFlags &= ~AC_HIT; - dmgFlags = this->collider.elements[0].info.acHitInfo->toucher.dmgFlags; + if ((pthis->collider.base.acFlags & AC_HIT) != 0) { + pthis->collider.base.acFlags &= ~AC_HIT; + dmgFlags = pthis->collider.elements[0].info.acHitInfo->toucher.dmgFlags; if (dmgFlags & 0x4001F866) { - this->unk_1B0 = 1500; + pthis->unk_1B0 = 1500; } else { - ObjComb_Break(this, globalCtx); - ObjComb_ChooseItemDrop(this, globalCtx); - Actor_Kill(&this->actor); + ObjComb_Break(pthis, globalCtx); + ObjComb_ChooseItemDrop(pthis, globalCtx); + Actor_Kill(&pthis->actor); } } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } - if (this->actor.update != NULL) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (pthis->actor.update != NULL) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjComb* this = (ObjComb*)thisx; + ObjComb* pthis = (ObjComb*)thisx; - this->unk_1B2 += 0x2EE0; - this->actionFunc(this, globalCtx); - this->actor.shape.rot.x = Math_SinS(this->unk_1B2) * this->unk_1B0 + this->actor.home.rot.x; + pthis->unk_1B2 += 0x2EE0; + pthis->actionFunc(pthis, globalCtx); + pthis->actor.shape.rot.x = Math_SinS(pthis->unk_1B2) * pthis->unk_1B0 + pthis->actor.home.rot.x; } void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { - ObjComb* this = (ObjComb*)thisx; + ObjComb* pthis = (ObjComb*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_comb.c", 369); func_80093D18(globalCtx->state.gfxCtx); - Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX(this->actor.shape.rot.x * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(this->actor.shape.rot.z * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_Translate(0, -(this->actor.scale.y * 118.0f), 0, MTXMODE_APPLY); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_Translate(pthis->actor.world.pos.x, pthis->actor.world.pos.y + (118.0f * pthis->actor.scale.y), + pthis->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->actor.shape.rot.x * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateZ(pthis->actor.shape.rot.z * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_Translate(0, -(pthis->actor.scale.y * 118.0f), 0, MTXMODE_APPLY); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_comb.c", 394), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFieldBeehiveDL); - Collider_UpdateSpheres(0, &this->collider); + Collider_UpdateSpheres(0, &pthis->collider); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_comb.c", 402); } diff --git a/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c b/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.cpp similarity index 65% rename from src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c rename to src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.cpp index 0be365ffb..66e33109d 100644 --- a/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c +++ b/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.cpp @@ -21,9 +21,9 @@ void ObjDekujr_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDekujr_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDekujr_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjDekujr_ComeUp(ObjDekujr* this, GlobalContext* globalCtx); +void ObjDekujr_ComeUp(ObjDekujr* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Dekujr_InitVars = { +ActorInit Obj_Dekujr_InitVars = { ACTOR_OBJ_DEKUJR, ACTORCAT_NPC, FLAGS, @@ -48,7 +48,7 @@ static ColliderCylinderInitToActor sCylinderInit = { }; void ObjDekujr_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjDekujr* this = (ObjDekujr*)thisx; + ObjDekujr* pthis = (ObjDekujr*)thisx; s32 pad; if (gSaveContext.cutsceneIndex < 0xFFF0) { @@ -56,19 +56,19 @@ void ObjDekujr_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Kill(thisx); return; } - this->unk_19C = 2; - this->unk_19B = 0; + pthis->unk_19C = 2; + pthis->unk_19B = 0; } else { - this->unk_19C = 0; - this->unk_19B = 1; + pthis->unk_19C = 0; + pthis->unk_19B = 1; } if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST)) { Actor_Kill(thisx); } else { ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(globalCtx, &pthis->collider); sCylinderInit.base.actor = thisx; - Collider_SetCylinderToActor(globalCtx, &this->collider, &sCylinderInit); + Collider_SetCylinderToActor(globalCtx, &pthis->collider, &sCylinderInit); thisx->colChkInfo.mass = MASS_IMMOVABLE; thisx->textId = func_80037C30(globalCtx, 0xF); Actor_SetScale(thisx, 0.4f); @@ -90,7 +90,7 @@ void ObjDekujr_SetFinalPos(CsCmdActorAction* npcAction, Vec3f* finalPos) { finalPos->z = npcAction->endPos.z; } -void ObjDekujr_ComeUp(ObjDekujr* this, GlobalContext* globalCtx) { +void ObjDekujr_ComeUp(ObjDekujr* pthis, GlobalContext* globalCtx) { CsCmdActorAction* csCmdNPCAction; Vec3f initPos; Vec3f finalPos; @@ -99,57 +99,57 @@ void ObjDekujr_ComeUp(ObjDekujr* this, GlobalContext* globalCtx) { f32 gravity; if (globalCtx->csCtx.state == CS_STATE_IDLE) { - this->unk_19C = 2; - this->unk_19B = 0; + pthis->unk_19C = 2; + pthis->unk_19B = 0; } else { if (globalCtx->csCtx.frames == 351) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_COME_UP_DEKU_JR); + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_COME_UP_DEKU_JR); } csCmdNPCAction = globalCtx->csCtx.npcActions[1]; if (csCmdNPCAction != NULL) { ObjDekujr_SetInitialPos(csCmdNPCAction, &initPos); ObjDekujr_SetFinalPos(csCmdNPCAction, &finalPos); - if (this->unk_19C == 0) { - this->actor.world.pos = initPos; - this->unk_19C = 1; + if (pthis->unk_19C == 0) { + pthis->actor.world.pos = initPos; + pthis->unk_19C = 1; } - this->actor.shape.rot.x = csCmdNPCAction->urot.x; - this->actor.shape.rot.y = csCmdNPCAction->urot.y; - this->actor.shape.rot.z = csCmdNPCAction->urot.z; - this->actor.velocity = velocity; + pthis->actor.shape.rot.x = csCmdNPCAction->urot.x; + pthis->actor.shape.rot.y = csCmdNPCAction->urot.y; + pthis->actor.shape.rot.z = csCmdNPCAction->urot.z; + pthis->actor.velocity = velocity; if (csCmdNPCAction->endFrame >= globalCtx->csCtx.frames) { actionLength = csCmdNPCAction->endFrame - csCmdNPCAction->startFrame; - this->actor.velocity.x = (finalPos.x - initPos.x) / actionLength; - gravity = this->actor.gravity; - this->actor.velocity.y = (finalPos.y - initPos.y) / actionLength; - this->actor.velocity.y += gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; + pthis->actor.velocity.x = (finalPos.x - initPos.x) / actionLength; + gravity = pthis->actor.gravity; + pthis->actor.velocity.y = (finalPos.y - initPos.y) / actionLength; + pthis->actor.velocity.y += gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; } - this->actor.velocity.z = (finalPos.z - initPos.z) / actionLength; + pthis->actor.velocity.z = (finalPos.z - initPos.z) / actionLength; } } } } void ObjDekujr_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjDekujr* this = (ObjDekujr*)thisx; + ObjDekujr* pthis = (ObjDekujr*)thisx; s32 pad; - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if ((gSaveContext.cutsceneIndex >= 0xFFF0) && (this->unk_19B == 0)) { - this->unk_19C = 0; - this->unk_19B = 1; + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if ((gSaveContext.cutsceneIndex >= 0xFFF0) && (pthis->unk_19B == 0)) { + pthis->unk_19C = 0; + pthis->unk_19B = 1; } - if (this->unk_19B == 1) { - ObjDekujr_ComeUp(this, globalCtx); - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.world.pos.z += this->actor.velocity.z; + if (pthis->unk_19B == 1) { + ObjDekujr_ComeUp(pthis, globalCtx); + pthis->actor.world.pos.x += pthis->actor.velocity.x; + pthis->actor.world.pos.y += pthis->actor.velocity.y; + pthis->actor.world.pos.z += pthis->actor.velocity.z; } else { - func_80037D98(globalCtx, &this->actor, 0xF, &this->unk_1A0); - Actor_SetFocus(&this->actor, 40.0f); + func_80037D98(globalCtx, &pthis->actor, 0xF, &pthis->unk_1A0); + Actor_SetFocus(&pthis->actor, 40.0f); } } diff --git a/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c b/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.cpp similarity index 54% rename from src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c rename to src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.cpp index 23c8cb097..cec94abc8 100644 --- a/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c +++ b/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.cpp @@ -21,12 +21,12 @@ void ObjElevator_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjElevator_Update(Actor* thisx, GlobalContext* globalCtx); void ObjElevator_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B92C5C(ObjElevator* this); -void func_80B92C80(ObjElevator* this, GlobalContext* globalCtx); -void func_80B92D20(ObjElevator* this); -void func_80B92D44(ObjElevator* this, GlobalContext* globalCtx); +void func_80B92C5C(ObjElevator* pthis); +void func_80B92C80(ObjElevator* pthis, GlobalContext* globalCtx); +void func_80B92D20(ObjElevator* pthis); +void func_80B92D44(ObjElevator* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Elevator_InitVars = { +ActorInit Obj_Elevator_InitVars = { ACTOR_OBJ_ELEVATOR, ACTORCAT_BG, FLAGS, @@ -46,85 +46,85 @@ static InitChainEntry sInitChain[] = { static f32 sScales[] = { 0.1f, 0.05f }; -void ObjElevator_SetupAction(ObjElevator* this, ObjElevatorActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ObjElevator_SetupAction(ObjElevator* pthis, ObjElevatorActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void func_80B92B08(ObjElevator* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { +void func_80B92B08(ObjElevator* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flag) { s16 pad1; CollisionHeader* colHeader = NULL; s16 pad2; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; - DynaPolyActor_Init(&this->dyna, flag); + DynaPolyActor_Init(&pthis->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_elevator.c", 136, thisx->id, thisx->params); } } void ObjElevator_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjElevator* this = (ObjElevator*)thisx; + ObjElevator* pthis = (ObjElevator*)thisx; f32 temp_f0; - func_80B92B08(this, globalCtx, &object_d_elevator_Col_000360, DPM_PLAYER); + func_80B92B08(pthis, globalCtx, &object_d_elevator_Col_000360, DPM_PLAYER); Actor_SetScale(thisx, sScales[thisx->params & 1]); Actor_ProcessInitChain(thisx, sInitChain); temp_f0 = (thisx->params >> 8) & 0xF; - this->unk_16C = temp_f0 + temp_f0; - func_80B92C5C(this); + pthis->unk_16C = temp_f0 + temp_f0; + func_80B92C5C(pthis); osSyncPrintf("(Dungeon Elevator)(arg_data 0x%04x)\n", thisx->params); } void ObjElevator_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjElevator* this = (ObjElevator*)thisx; + ObjElevator* pthis = (ObjElevator*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_80B92C5C(ObjElevator* this) { - ObjElevator_SetupAction(this, func_80B92C80); +void func_80B92C5C(ObjElevator* pthis) { + ObjElevator_SetupAction(pthis, func_80B92C80); } -void func_80B92C80(ObjElevator* this, GlobalContext* globalCtx) { +void func_80B92C80(ObjElevator* pthis, GlobalContext* globalCtx) { f32 sub; - Actor* thisx = &this->dyna.actor; + Actor* thisx = &pthis->dyna.actor; - if ((this->dyna.unk_160 & 2) && !(this->unk_170 & 2)) { + if ((pthis->dyna.unk_160 & 2) && !(pthis->unk_170 & 2)) { sub = thisx->world.pos.y - thisx->home.pos.y; if (fabsf(sub) < 0.1f) { - this->unk_168 = thisx->home.pos.y + ((thisx->params >> 0xC) & 0xF) * 80.0f; + pthis->unk_168 = thisx->home.pos.y + ((thisx->params >> 0xC) & 0xF) * 80.0f; } else { - this->unk_168 = thisx->home.pos.y; + pthis->unk_168 = thisx->home.pos.y; } - func_80B92D20(this); + func_80B92D20(pthis); } } -void func_80B92D20(ObjElevator* this) { - ObjElevator_SetupAction(this, func_80B92D44); +void func_80B92D20(ObjElevator* pthis) { + ObjElevator_SetupAction(pthis, func_80B92D44); } -void func_80B92D44(ObjElevator* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; +void func_80B92D44(ObjElevator* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; - if (fabsf(Math_SmoothStepToF(&thisx->world.pos.y, this->unk_168, 1.0f, this->unk_16C, 0.0f)) < 0.001f) { + if (fabsf(Math_SmoothStepToF(&thisx->world.pos.y, pthis->unk_168, 1.0f, pthis->unk_16C, 0.0f)) < 0.001f) { Audio_PlayActorSound2(thisx, NA_SE_EV_FOOT_SWITCH); - func_80B92C5C(this); + func_80B92C5C(pthis); } else { Audio_PlayActorSound2(thisx, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); } } void ObjElevator_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjElevator* this = (ObjElevator*)thisx; + ObjElevator* pthis = (ObjElevator*)thisx; - if (this->actionFunc) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc) { + pthis->actionFunc(pthis, globalCtx); } - this->unk_170 = this->dyna.unk_160; + pthis->unk_170 = pthis->dyna.unk_160; } void ObjElevator_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.cpp similarity index 51% rename from src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c rename to src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.cpp index 4b5cf076d..75f213f47 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.cpp @@ -24,7 +24,7 @@ void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Obj_Hamishi_InitVars = { +ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, ACTORCAT_PROP, FLAGS, @@ -70,37 +70,37 @@ static InitChainEntry sInitChain[] = { }; void ObjHamishi_InitCollision(Actor* thisx, GlobalContext* globalCtx) { - ObjHamishi* this = (ObjHamishi*)thisx; + ObjHamishi* pthis = (ObjHamishi*)thisx; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); } -void ObjHamishi_Shake(ObjHamishi* this) { - if (this->shakeFrames > 0) { - this->shakeFrames--; - this->shakePosPhase += 5000; - this->shakeRotPhase += 0xE10; +void ObjHamishi_Shake(ObjHamishi* pthis) { + if (pthis->shakeFrames > 0) { + pthis->shakeFrames--; + pthis->shakePosPhase += 5000; + pthis->shakeRotPhase += 0xE10; - Math_StepToF(&this->shakePosSize, 0.0f, 0.15f); - Math_StepToF(&this->shakeRotSize, 0.0f, 40.0f); + Math_StepToF(&pthis->shakePosSize, 0.0f, 0.15f); + Math_StepToF(&pthis->shakeRotSize, 0.0f, 40.0f); - this->actor.world.pos.x = this->actor.home.pos.x + (Math_SinS(this->shakePosPhase * 4) * this->shakePosSize); - this->actor.world.pos.z = this->actor.home.pos.z + (Math_CosS(this->shakePosPhase * 7) * this->shakePosSize); - this->actor.shape.rot.x = - this->actor.home.rot.x + (s16)(Math_SinS(this->shakeRotPhase * 4) * this->shakeRotSize); - this->actor.shape.rot.z = - this->actor.home.rot.z + (s16)(Math_CosS(this->shakeRotPhase * 7) * this->shakeRotSize); + pthis->actor.world.pos.x = pthis->actor.home.pos.x + (Math_SinS(pthis->shakePosPhase * 4) * pthis->shakePosSize); + pthis->actor.world.pos.z = pthis->actor.home.pos.z + (Math_CosS(pthis->shakePosPhase * 7) * pthis->shakePosSize); + pthis->actor.shape.rot.x = + pthis->actor.home.rot.x + (s16)(Math_SinS(pthis->shakeRotPhase * 4) * pthis->shakeRotSize); + pthis->actor.shape.rot.z = + pthis->actor.home.rot.z + (s16)(Math_CosS(pthis->shakeRotPhase * 7) * pthis->shakeRotSize); } else { - Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); - Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); - Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 0xBB8); - Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0xBB8); + Math_StepToF(&pthis->actor.world.pos.x, pthis->actor.home.pos.x, 1.0f); + Math_StepToF(&pthis->actor.world.pos.z, pthis->actor.home.pos.z, 1.0f); + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->actor.home.rot.x, 0xBB8); + Math_ScaledStepToS(&pthis->actor.shape.rot.z, pthis->actor.home.rot.z, 0xBB8); } } -void ObjHamishi_Break(ObjHamishi* this, GlobalContext* globalCtx) { +void ObjHamishi_Break(ObjHamishi* pthis, GlobalContext* globalCtx) { s32 pad; Vec3f velocity; Vec3f pos; @@ -115,9 +115,9 @@ void ObjHamishi_Break(ObjHamishi* this, GlobalContext* globalCtx) { phi_s0 += 20000; temp_f20 = Rand_ZeroOne() * 10.0f; - pos.x = (Math_SinS(phi_s0) * temp_f20) + this->actor.world.pos.x; - pos.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; - pos.z = (Math_CosS(phi_s0) * temp_f20) + this->actor.world.pos.z; + pos.x = (Math_SinS(phi_s0) * temp_f20) + pthis->actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 40.0f) + pthis->actor.world.pos.y + 5.0f; + pos.z = (Math_CosS(phi_s0) * temp_f20) + pthis->actor.world.pos.z; temp_f20 = (Rand_ZeroOne() * 10.0f) + 2.0f; velocity.x = Math_SinS(phi_s0) * temp_f20; @@ -136,69 +136,69 @@ void ObjHamishi_Break(ObjHamishi* this, GlobalContext* globalCtx) { gravity = -320; } - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &this->actor.world.pos, gravity, phi_v0, 30, 5, 0, + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pthis->actor.world.pos, gravity, phi_v0, 30, 5, 0, sEffectScales[i], 3, 0, 70, 1, OBJECT_GAMEPLAY_FIELD_KEEP, gSilverRockFragmentsDL); } - func_80033480(globalCtx, &this->actor.world.pos, 140.0f, 6, 180, 90, 1); - func_80033480(globalCtx, &this->actor.world.pos, 140.0f, 12, 80, 90, 1); + func_80033480(globalCtx, &pthis->actor.world.pos, 140.0f, 6, 180, 90, 1); + func_80033480(globalCtx, &pthis->actor.world.pos, 140.0f, 12, 80, 90, 1); } void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjHamishi* this = (ObjHamishi*)thisx; + ObjHamishi* pthis = (ObjHamishi*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(&pthis->actor, sInitChain); if (globalCtx->csCtx.state != CS_STATE_IDLE) { - this->actor.uncullZoneForward += 1000.0f; + pthis->actor.uncullZoneForward += 1000.0f; } - if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.home.rot.y = Rand_ZeroFloat(65536.0f); + if (pthis->actor.shape.rot.y == 0) { + pthis->actor.shape.rot.y = pthis->actor.world.rot.y = pthis->actor.home.rot.y = Rand_ZeroFloat(65536.0f); } - ObjHamishi_InitCollision(&this->actor, globalCtx); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + ObjHamishi_InitCollision(&pthis->actor, globalCtx); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x3F)) { - Actor_Kill(&this->actor); + if (Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F)) { + Actor_Kill(&pthis->actor); return; } - this->actor.shape.yOffset = 80.0f; + pthis->actor.shape.yOffset = 80.0f; } void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - ObjHamishi* this = (ObjHamishi*)thisx; + ObjHamishi* pthis = (ObjHamishi*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjHamishi* this = (ObjHamishi*)thisx; + ObjHamishi* pthis = (ObjHamishi*)thisx; CollisionCheckContext* colChkCtx = &globalCtx->colChkCtx; - ObjHamishi_Shake(this); + ObjHamishi_Shake(pthis); - if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x40000040)) { - this->collider.base.acFlags &= ~AC_HIT; - this->hitCount++; - if (this->hitCount < 2) { - this->shakeFrames = 15; - this->shakePosSize = 2.0f; - this->shakeRotSize = 400.0f; + if ((pthis->collider.base.acFlags & AC_HIT) && (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x40000040)) { + pthis->collider.base.acFlags &= ~AC_HIT; + pthis->hitCount++; + if (pthis->hitCount < 2) { + pthis->shakeFrames = 15; + pthis->shakePosSize = 2.0f; + pthis->shakeRotSize = 400.0f; } else { - ObjHamishi_Break(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); - Flags_SetSwitch(globalCtx, this->actor.params & 0x3F); - Actor_Kill(&this->actor); + ObjHamishi_Break(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, pthis->actor.params & 0x3F); + Actor_Kill(&pthis->actor); } } else { - this->collider.base.acFlags &= ~AC_HIT; + pthis->collider.base.acFlags &= ~AC_HIT; - if (this->actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, colChkCtx, &this->collider.base); + if (pthis->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, colChkCtx, &pthis->collider.base); + CollisionCheck_SetOC(globalCtx, colChkCtx, &pthis->collider.base); } } } diff --git a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.cpp similarity index 71% rename from src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c rename to src/overlays/actors/ovl_Obj_Hana/z_obj_hana.cpp index 787768592..daa3e78ff 100644 --- a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c +++ b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.cpp @@ -21,7 +21,7 @@ void ObjHana_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHana_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHana_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Obj_Hana_InitVars = { +ActorInit Obj_Hana_InitVars = { ACTOR_OBJ_HANA, ACTORCAT_PROP, FLAGS, @@ -77,40 +77,40 @@ static InitChainEntry sInitChain[] = { }; void ObjHana_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjHana* this = (ObjHana*)thisx; - s16 type = this->actor.params & 3; + ObjHana* pthis = (ObjHana*)thisx; + s16 type = pthis->actor.params & 3; HanaParams* params = &sHanaParams[type]; - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, params->scale); - this->actor.shape.yOffset = params->yOffset; + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetScale(&pthis->actor, params->scale); + pthis->actor.shape.yOffset = params->yOffset; if (params->radius >= 0) { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - this->collider.dim.radius = params->radius; - this->collider.dim.height = params->height; - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->collider.dim.radius = params->radius; + pthis->collider.dim.height = params->height; + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); } if (type == 2 && (gSaveContext.eventChkInf[4] & 1)) { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void ObjHana_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjHana* this = (ObjHana*)thisx; + ObjHana* pthis = (ObjHana*)thisx; - if (sHanaParams[this->actor.params & 3].radius >= 0) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if (sHanaParams[pthis->actor.params & 3].radius >= 0) { + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } void ObjHana_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjHana* this = (ObjHana*)thisx; + ObjHana* pthis = (ObjHana*)thisx; - if (sHanaParams[this->actor.params & 3].radius >= 0 && this->actor.xzDistToPlayer < 400.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (sHanaParams[pthis->actor.params & 3].radius >= 0 && pthis->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.cpp similarity index 53% rename from src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c rename to src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.cpp index 9a6df1a37..1f44df573 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.cpp @@ -22,14 +22,14 @@ void ObjHsblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHsblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHsblock_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B93DF4(ObjHsblock* this, GlobalContext* globalCtx); -void func_80B93E5C(ObjHsblock* this, GlobalContext* globalCtx); +void func_80B93DF4(ObjHsblock* pthis, GlobalContext* globalCtx); +void func_80B93E5C(ObjHsblock* pthis, GlobalContext* globalCtx); -void func_80B93D90(ObjHsblock* this); -void func_80B93DB0(ObjHsblock* this); -void func_80B93E38(ObjHsblock* this); +void func_80B93D90(ObjHsblock* pthis); +void func_80B93DB0(ObjHsblock* pthis); +void func_80B93E38(ObjHsblock* pthis); -const ActorInit Obj_Hsblock_InitVars = { +ActorInit Obj_Hsblock_InitVars = { ACTOR_OBJ_HSBLOCK, ACTORCAT_BG, FLAGS, @@ -56,49 +56,49 @@ static Color_RGB8 sFireTempleColor = { 165, 125, 55 }; static Gfx* sDLists[] = { gHookshotPostDL, gHookshotPostDL, gHookshotTargetDL }; -void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc) { - this->actionFunc = actionFunc; +void ObjHsblock_SetupAction(ObjHsblock* pthis, ObjHsblockActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } -void func_80B93B68(ObjHsblock* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlags) { +void func_80B93B68(ObjHsblock* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlags) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2[2]; - DynaPolyActor_Init(&this->dyna, moveFlags); + DynaPolyActor_Init(&pthis->dyna, moveFlags); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.bgId == BG_ACTOR_MAX) { + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + if (pthis->dyna.bgId == BG_ACTOR_MAX) { osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_hsblock.c", 163, - this->dyna.actor.id, this->dyna.actor.params); + pthis->dyna.actor.id, pthis->dyna.actor.params); } } -void func_80B93BF0(ObjHsblock* this, GlobalContext* globalCtx) { - if ((this->dyna.actor.params >> 5) & 1) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, 1); +void func_80B93BF0(ObjHsblock* pthis, GlobalContext* globalCtx) { + if ((pthis->dyna.actor.params >> 5) & 1) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, + pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, 1); } } void ObjHsblock_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjHsblock* this = (ObjHsblock*)thisx; + ObjHsblock* pthis = (ObjHsblock*)thisx; - func_80B93B68(this, globalCtx, sCollisionHeaders[thisx->params & 3], DPM_UNK); + func_80B93B68(pthis, globalCtx, sCollisionHeaders[thisx->params & 3], DPM_UNK); Actor_ProcessInitChain(thisx, sInitChain); - func_80B93BF0(this, globalCtx); + func_80B93BF0(pthis, globalCtx); switch (thisx->params & 3) { case 0: case 2: - func_80B93D90(this); + func_80B93D90(pthis); break; case 1: if (Flags_GetSwitch(globalCtx, (thisx->params >> 8) & 0x3F)) { - func_80B93D90(this); + func_80B93D90(pthis); } else { - func_80B93DB0(this); + func_80B93DB0(pthis); } } @@ -108,46 +108,46 @@ void ObjHsblock_Init(Actor* thisx, GlobalContext* globalCtx) { } void ObjHsblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjHsblock* this = (ObjHsblock*)thisx; + ObjHsblock* pthis = (ObjHsblock*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void func_80B93D90(ObjHsblock* this) { - ObjHsblock_SetupAction(this, NULL); +void func_80B93D90(ObjHsblock* pthis) { + ObjHsblock_SetupAction(pthis, NULL); } -void func_80B93DB0(ObjHsblock* this) { - this->dyna.actor.flags |= ACTOR_FLAG_4; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 105.0f; - ObjHsblock_SetupAction(this, func_80B93DF4); +void func_80B93DB0(ObjHsblock* pthis) { + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y - 105.0f; + ObjHsblock_SetupAction(pthis, func_80B93DF4); } -void func_80B93DF4(ObjHsblock* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - func_80B93E38(this); +void func_80B93DF4(ObjHsblock* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + func_80B93E38(pthis); } } -void func_80B93E38(ObjHsblock* this) { - ObjHsblock_SetupAction(this, func_80B93E5C); +void func_80B93E38(ObjHsblock* pthis) { + ObjHsblock_SetupAction(pthis, func_80B93E5C); } -void func_80B93E5C(ObjHsblock* this, GlobalContext* globalCtx) { - Math_SmoothStepToF(&this->dyna.actor.velocity.y, 16.0f, 0.1f, 0.8f, 0.0f); - if (fabsf(Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 0.3f, - this->dyna.actor.velocity.y, 0.3f)) < 0.001f) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - func_80B93D90(this); - this->dyna.actor.flags &= ~ACTOR_FLAG_4; +void func_80B93E5C(ObjHsblock* pthis, GlobalContext* globalCtx) { + Math_SmoothStepToF(&pthis->dyna.actor.velocity.y, 16.0f, 0.1f, 0.8f, 0.0f); + if (fabsf(Math_SmoothStepToF(&pthis->dyna.actor.world.pos.y, pthis->dyna.actor.home.pos.y, 0.3f, + pthis->dyna.actor.velocity.y, 0.3f)) < 0.001f) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y; + func_80B93D90(pthis); + pthis->dyna.actor.flags &= ~ACTOR_FLAG_4; } } void ObjHsblock_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjHsblock* this = (ObjHsblock*)thisx; + ObjHsblock* pthis = (ObjHsblock*)thisx; - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); } Actor_SetFocus(thisx, D_80B940C0[thisx->params & 3]); } diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.cpp similarity index 55% rename from src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c rename to src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.cpp index f4907c6b1..61780ef28 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.cpp @@ -24,10 +24,10 @@ void ObjIcePoly_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjIcePoly_Update(Actor* thisx, GlobalContext* globalCtx); void ObjIcePoly_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjIcePoly_Idle(ObjIcePoly* this, GlobalContext* globalCtx); -void ObjIcePoly_Melt(ObjIcePoly* this, GlobalContext* globalCtx); +void ObjIcePoly_Idle(ObjIcePoly* pthis, GlobalContext* globalCtx); +void ObjIcePoly_Melt(ObjIcePoly* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Ice_Poly_InitVars = { +ActorInit Obj_Ice_Poly_InitVars = { ACTOR_OBJ_ICE_POLY, ACTORCAT_PROP, FLAGS, @@ -85,9 +85,9 @@ static Color_RGBA8 sColorWhite = { 250, 250, 250, 255 }; static Color_RGBA8 sColorGray = { 180, 180, 180, 255 }; void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjIcePoly* this = (ObjIcePoly*)thisx; + ObjIcePoly* pthis = (ObjIcePoly*)thisx; - this->unk_151 = (thisx->params >> 8) & 0xFF; + pthis->unk_151 = (thisx->params >> 8) & 0xFF; thisx->params &= 0xFF; if (thisx->params < 0 || thisx->params >= 3) { Actor_Kill(thisx); @@ -95,116 +95,116 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetScale(thisx, sScale[thisx->params]); thisx->world.pos.y = sOffsetY[thisx->params] + thisx->home.pos.y; - Collider_InitCylinder(globalCtx, &this->colliderIce); - Collider_SetCylinder(globalCtx, &this->colliderIce, thisx, &sCylinderInitIce); - Collider_InitCylinder(globalCtx, &this->colliderHard); - Collider_SetCylinder(globalCtx, &this->colliderHard, thisx, &sCylinderInitHard); - Collider_UpdateCylinder(thisx, &this->colliderIce); - Collider_UpdateCylinder(thisx, &this->colliderHard); + Collider_InitCylinder(globalCtx, &pthis->colliderIce); + Collider_SetCylinder(globalCtx, &pthis->colliderIce, thisx, &sCylinderInitIce); + Collider_InitCylinder(globalCtx, &pthis->colliderHard); + Collider_SetCylinder(globalCtx, &pthis->colliderHard, thisx, &sCylinderInitHard); + Collider_UpdateCylinder(thisx, &pthis->colliderIce); + Collider_UpdateCylinder(thisx, &pthis->colliderHard); thisx->colChkInfo.mass = MASS_IMMOVABLE; - this->alpha = 255; - this->colliderIce.dim.radius *= thisx->scale.x; - this->colliderIce.dim.height *= thisx->scale.y; - this->colliderHard.dim.radius *= thisx->scale.x; - this->colliderHard.dim.height *= thisx->scale.y; + pthis->alpha = 255; + pthis->colliderIce.dim.radius *= thisx->scale.x; + pthis->colliderIce.dim.height *= thisx->scale.y; + pthis->colliderHard.dim.radius *= thisx->scale.x; + pthis->colliderHard.dim.height *= thisx->scale.y; Actor_SetFocus(thisx, thisx->scale.y * 30.0f); - this->actionFunc = ObjIcePoly_Idle; + pthis->actionFunc = ObjIcePoly_Idle; } void ObjIcePoly_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - ObjIcePoly* this = (ObjIcePoly*)thisx; + ObjIcePoly* pthis = (ObjIcePoly*)thisx; - if ((this->actor.params >= 0) && (this->actor.params < 3)) { - Collider_DestroyCylinder(globalCtx, &this->colliderIce); - Collider_DestroyCylinder(globalCtx, &this->colliderHard); + if ((pthis->actor.params >= 0) && (pthis->actor.params < 3)) { + Collider_DestroyCylinder(globalCtx, &pthis->colliderIce); + Collider_DestroyCylinder(globalCtx, &pthis->colliderHard); } } -void ObjIcePoly_Idle(ObjIcePoly* this, GlobalContext* globalCtx) { +void ObjIcePoly_Idle(ObjIcePoly* pthis, GlobalContext* globalCtx) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s32 pad; Vec3f pos; - if (this->colliderIce.base.acFlags & AC_HIT) { - this->meltTimer = -this->colliderIce.info.acHitInfo->toucher.damage; - this->actor.focus.rot.y = this->actor.yawTowardsPlayer; - OnePointCutscene_Init(globalCtx, 5120, 40, &this->actor, MAIN_CAM); - this->actionFunc = ObjIcePoly_Melt; - } else if (this->actor.parent != NULL) { - this->actor.parent->freezeTimer = 40; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderIce.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderIce.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderIce.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderHard.base); + if (pthis->colliderIce.base.acFlags & AC_HIT) { + pthis->meltTimer = -pthis->colliderIce.info.acHitInfo->toucher.damage; + pthis->actor.focus.rot.y = pthis->actor.yawTowardsPlayer; + OnePointCutscene_Init(globalCtx, 5120, 40, &pthis->actor, MAIN_CAM); + pthis->actionFunc = ObjIcePoly_Melt; + } else if (pthis->actor.parent != NULL) { + pthis->actor.parent->freezeTimer = 40; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->colliderIce.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderIce.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderIce.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderHard.base); } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } - pos.x = this->actor.world.pos.x + this->actor.scale.x * (Rand_S16Offset(15, 15) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); - pos.y = this->actor.world.pos.y + this->actor.scale.y * Rand_S16Offset(10, 90); - pos.z = this->actor.world.pos.z + this->actor.scale.z * (Rand_S16Offset(15, 15) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); + pos.x = pthis->actor.world.pos.x + pthis->actor.scale.x * (Rand_S16Offset(15, 15) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); + pos.y = pthis->actor.world.pos.y + pthis->actor.scale.y * Rand_S16Offset(10, 90); + pos.z = pthis->actor.world.pos.z + pthis->actor.scale.z * (Rand_S16Offset(15, 15) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); if ((globalCtx->gameplayFrames % 7) == 0) { EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &zeroVec, &zeroVec, &sColorWhite, &sColorGray, 2000, 5); } } -void ObjIcePoly_Melt(ObjIcePoly* this, GlobalContext* globalCtx) { +void ObjIcePoly_Melt(ObjIcePoly* pthis, GlobalContext* globalCtx) { Vec3f accel; Vec3f vel; Vec3f pos; s32 i; accel.x = 0.0f; - accel.y = this->actor.scale.y; + accel.y = pthis->actor.scale.y; accel.z = 0.0f; vel.x = 0.0f; - vel.y = this->actor.scale.y; + vel.y = pthis->actor.scale.y; vel.z = 0.0f; for (i = 0; i < 2; i++) { pos.x = - this->actor.world.pos.x + this->actor.scale.x * (Rand_S16Offset(20, 20) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); - pos.y = this->actor.world.pos.y + this->actor.scale.y * Rand_ZeroOne() * 50.0f; + pthis->actor.world.pos.x + pthis->actor.scale.x * (Rand_S16Offset(20, 20) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); + pos.y = pthis->actor.world.pos.y + pthis->actor.scale.y * Rand_ZeroOne() * 50.0f; pos.z = - this->actor.world.pos.z + this->actor.scale.x * (Rand_S16Offset(20, 20) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); + pthis->actor.world.pos.z + pthis->actor.scale.x * (Rand_S16Offset(20, 20) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); func_8002829C(globalCtx, &pos, &vel, &accel, &sColorWhite, &sColorGray, - Rand_S16Offset(0x15E, 0x64) * this->actor.scale.x, this->actor.scale.x * 20.0f); + Rand_S16Offset(0x15E, 0x64) * pthis->actor.scale.x, pthis->actor.scale.x * 20.0f); } - if (this->meltTimer < 0) { - if (this->actor.parent != NULL) { - this->actor.parent->freezeTimer = 40; + if (pthis->meltTimer < 0) { + if (pthis->actor.parent != NULL) { + pthis->actor.parent->freezeTimer = 40; } - this->meltTimer++; - if (this->meltTimer == 0) { - this->meltTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_MELT); + pthis->meltTimer++; + if (pthis->meltTimer == 0) { + pthis->meltTimer = 40; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_ICE_MELT); } } else { - if (this->meltTimer != 0) { - this->meltTimer--; + if (pthis->meltTimer != 0) { + pthis->meltTimer--; } - this->actor.scale.y = sScale[this->actor.params] * (0.5f + (this->meltTimer * 0.0125f)); - this->alpha -= 6; - if (this->meltTimer == 0) { - Actor_Kill(&this->actor); + pthis->actor.scale.y = sScale[pthis->actor.params] * (0.5f + (pthis->meltTimer * 0.0125f)); + pthis->alpha -= 6; + if (pthis->meltTimer == 0) { + Actor_Kill(&pthis->actor); } } } void ObjIcePoly_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - ObjIcePoly* this = (ObjIcePoly*)thisx; + ObjIcePoly* pthis = (ObjIcePoly*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void ObjIcePoly_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - ObjIcePoly* this = (ObjIcePoly*)thisx; + ObjIcePoly* pthis = (ObjIcePoly*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_ice_poly.c", 421); func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); Matrix_RotateZYX(0x500, 0, -0x500, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_ice_poly.c", 428), @@ -212,7 +212,7 @@ void ObjIcePoly_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->gameplayFrames % 0x100, 0x20, 0x10, 1, 0, (globalCtx->gameplayFrames * 2) % 0x100, 0x40, 0x20)); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, pthis->alpha); gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_ice_poly.c", 444); diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c deleted file mode 100644 index 4f9f54810..000000000 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ /dev/null @@ -1,297 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_KIBAKO_Z_OBJ_KIBAKO_C -#include "actor_common.h" -/* - * File: z_obj_kibako.c - * Overlay: ovl_Obj_Kibako - * Description: Small wooden box - */ - -#include "z_obj_kibako.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_26) - -void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjKibako_SetupIdle(ObjKibako* this); -void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx); -void ObjKibako_SetupHeld(ObjKibako* this); -void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx); -void ObjKibako_SetupThrown(ObjKibako* this); -void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx); - -const ActorInit Obj_Kibako_InitVars = { - ACTOR_OBJ_KIBAKO, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_DANGEON_KEEP, - sizeof(ObjKibako), - (ActorFunc)ObjKibako_Init, - (ActorFunc)ObjKibako_Destroy, - (ActorFunc)ObjKibako_Update, - (ActorFunc)ObjKibako_Draw, -}; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_PLAYER, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000002, 0x00, 0x01 }, - { 0x4FC00748, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 12, 27, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sCCInfoInit = { 0, 12, 60, MASS_HEAVY }; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 60, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx) { - s16 collectible; - - collectible = this->actor.params & 0x1F; - if ((collectible >= 0) && (collectible <= 0x19)) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, - collectible | (((this->actor.params >> 8) & 0x3F) << 8)); - } -} - -void ObjKibako_ApplyGravity(ObjKibako* this) { - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } -} - -void ObjKibako_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - ObjKibako* this = (ObjKibako*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); -} - -void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjKibako* this = (ObjKibako*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.gravity = -1.2f; - this->actor.minVelocityY = -13.0f; - ObjKibako_InitCollider(&this->actor, globalCtx); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sCCInfoInit); - ObjKibako_SetupIdle(this); - // "wooden box" - osSyncPrintf("(dungeon keep 木箱)(arg_data 0x%04x)\n", this->actor.params); -} - -void ObjKibako_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - ObjKibako* this = (ObjKibako*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void ObjKibako_AirBreak(ObjKibako* this, GlobalContext* globalCtx) { - s16 angle; - s32 i; - Vec3f* breakPos = &this->actor.world.pos; - Vec3f pos; - Vec3f velocity; - - for (i = 0, angle = 0; i < 12; i++, angle += 0x4E20) { - f32 sn = Math_SinS(angle); - f32 cs = Math_CosS(angle); - f32 temp_rand; - s16 phi_s0; - - pos.x = sn * 16.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = cs * 16.0f; - velocity.x = pos.x * 0.2f; - velocity.y = (Rand_ZeroOne() * 6.0f) + 2.0f; - velocity.z = pos.z * 0.2f; - pos.x += breakPos->x; - pos.y += breakPos->y; - pos.z += breakPos->z; - temp_rand = Rand_ZeroOne(); - if (temp_rand < 0.1f) { - phi_s0 = 0x60; - } else if (temp_rand < 0.7f) { - phi_s0 = 0x40; - } else { - phi_s0 = 0x20; - } - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, breakPos, -200, phi_s0, 10, 10, 0, - (Rand_ZeroOne() * 30.0f) + 10.0f, 0, 32, 60, KAKERA_COLOR_NONE, - OBJECT_GAMEPLAY_DANGEON_KEEP, gSmallWoodenBoxFragmentDL); - } - func_80033480(globalCtx, &this->actor.world.pos, 40.0f, 3, 50, 140, 1); -} - -void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx) { - s16 angle; - s32 i; - Vec3f* breakPos = &this->actor.world.pos; - Vec3f pos; - Vec3f velocity; - - pos = *breakPos; - pos.y += this->actor.yDistToWater; - EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 500); - - for (i = 0, angle = 0; i < 12; i++, angle += 0x4E20) { - f32 sn = Math_SinS(angle); - f32 cs = Math_CosS(angle); - f32 temp_rand; - s16 phi_s0; - - pos.x = sn * 16.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = cs * 16.0f; - velocity.x = pos.x * 0.18f; - velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; - velocity.z = pos.z * 0.18f; - pos.x += breakPos->x; - pos.y += breakPos->y; - pos.z += breakPos->z; - temp_rand = Rand_ZeroOne(); - phi_s0 = (temp_rand < 0.2f) ? 0x40 : 0x20; - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, breakPos, -180, phi_s0, 30, 30, 0, - (Rand_ZeroOne() * 30.0f) + 10.0f, 0, 32, 70, KAKERA_COLOR_NONE, - OBJECT_GAMEPLAY_DANGEON_KEEP, gSmallWoodenBoxFragmentDL); - } -} - -void ObjKibako_SetupIdle(ObjKibako* this) { - this->actionFunc = ObjKibako_Idle; - this->actor.colChkInfo.mass = MASS_HEAVY; -} - -void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { - s32 pad; - - if (Actor_HasParent(&this->actor, globalCtx)) { - ObjKibako_SetupHeld(this); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 19.0f)) { - ObjKibako_WaterBreak(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - ObjKibako_SpawnCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } else if (this->collider.base.acFlags & AC_HIT) { - ObjKibako_AirBreak(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - ObjKibako_SpawnCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } else { - Actor_MoveForward(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 19.0f, 20.0f, 0.0f, 5); - if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 28.0f)) { - this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; - } - if (this->actor.xzDistToPlayer < 600.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer < 180.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - if (this->actor.xzDistToPlayer < 100.0f) { - func_8002F580(&this->actor, globalCtx); - } - } -} - -void ObjKibako_SetupHeld(ObjKibako* this) { - this->actionFunc = ObjKibako_Held; - this->actor.room = -1; - func_8002F7DC(&this->actor, NA_SE_PL_PULL_UP_WOODBOX); -} - -void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.curRoom.num; - if (fabsf(this->actor.speedXZ) < 0.1f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); - ObjKibako_SetupIdle(this); - this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - } else { - ObjKibako_SetupThrown(this); - ObjKibako_ApplyGravity(this); - func_8002D7EC(&this->actor); - } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 19.0f, 20.0f, 0.0f, 5); - } -} - -void ObjKibako_SetupThrown(ObjKibako* this) { - this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.colChkInfo.mass = 240; - this->actionFunc = ObjKibako_Thrown; -} - -void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; - - if ((this->actor.bgCheckFlags & 0xB) || (this->collider.base.atFlags & AT_HIT)) { - ObjKibako_AirBreak(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - ObjKibako_SpawnCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } else if (this->actor.bgCheckFlags & 0x40) { - ObjKibako_WaterBreak(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - ObjKibako_SpawnCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } else { - ObjKibako_ApplyGravity(this); - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 19.0f, 20.0f, 0.0f, 5); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjKibako* this = (ObjKibako*)thisx; - - this->actionFunc(this, globalCtx); -} - -void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjKibako* this = (ObjKibako*)thisx; - - Gfx_DrawDListOpa(globalCtx, gSmallWoodenBoxDL); -} diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.cpp b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.cpp new file mode 100644 index 000000000..a7ba7904d --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.cpp @@ -0,0 +1,297 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_KIBAKO_Z_OBJ_KIBAKO_C +#include "actor_common.h" +/* + * File: z_obj_kibako.c + * Overlay: ovl_Obj_Kibako + * Description: Small wooden box + */ + +#include "z_obj_kibako.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_26) + +void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjKibako_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjKibako_SetupIdle(ObjKibako* pthis); +void ObjKibako_Idle(ObjKibako* pthis, GlobalContext* globalCtx); +void ObjKibako_SetupHeld(ObjKibako* pthis); +void ObjKibako_Held(ObjKibako* pthis, GlobalContext* globalCtx); +void ObjKibako_SetupThrown(ObjKibako* pthis); +void ObjKibako_Thrown(ObjKibako* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Kibako_InitVars = { + ACTOR_OBJ_KIBAKO, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_DANGEON_KEEP, + sizeof(ObjKibako), + (ActorFunc)ObjKibako_Init, + (ActorFunc)ObjKibako_Destroy, + (ActorFunc)ObjKibako_Update, + (ActorFunc)ObjKibako_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000002, 0x00, 0x01 }, + { 0x4FC00748, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 12, 27, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sCCInfoInit = { 0, 12, 60, MASS_HEAVY }; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 60, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void ObjKibako_SpawnCollectible(ObjKibako* pthis, GlobalContext* globalCtx) { + s16 collectible; + + collectible = pthis->actor.params & 0x1F; + if ((collectible >= 0) && (collectible <= 0x19)) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, + collectible | (((pthis->actor.params >> 8) & 0x3F) << 8)); + } +} + +void ObjKibako_ApplyGravity(ObjKibako* pthis) { + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } +} + +void ObjKibako_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + ObjKibako* pthis = (ObjKibako*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); +} + +void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjKibako* pthis = (ObjKibako*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + pthis->actor.gravity = -1.2f; + pthis->actor.minVelocityY = -13.0f; + ObjKibako_InitCollider(&pthis->actor, globalCtx); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sCCInfoInit); + ObjKibako_SetupIdle(pthis); + // "wooden box" + osSyncPrintf("(dungeon keep 木箱)(arg_data 0x%04x)\n", pthis->actor.params); +} + +void ObjKibako_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjKibako* pthis = (ObjKibako*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void ObjKibako_AirBreak(ObjKibako* pthis, GlobalContext* globalCtx) { + s16 angle; + s32 i; + Vec3f* breakPos = &pthis->actor.world.pos; + Vec3f pos; + Vec3f velocity; + + for (i = 0, angle = 0; i < 12; i++, angle += 0x4E20) { + f32 sn = Math_SinS(angle); + f32 cs = Math_CosS(angle); + f32 temp_rand; + s16 phi_s0; + + pos.x = sn * 16.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = cs * 16.0f; + velocity.x = pos.x * 0.2f; + velocity.y = (Rand_ZeroOne() * 6.0f) + 2.0f; + velocity.z = pos.z * 0.2f; + pos.x += breakPos->x; + pos.y += breakPos->y; + pos.z += breakPos->z; + temp_rand = Rand_ZeroOne(); + if (temp_rand < 0.1f) { + phi_s0 = 0x60; + } else if (temp_rand < 0.7f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, breakPos, -200, phi_s0, 10, 10, 0, + (Rand_ZeroOne() * 30.0f) + 10.0f, 0, 32, 60, KAKERA_COLOR_NONE, + OBJECT_GAMEPLAY_DANGEON_KEEP, gSmallWoodenBoxFragmentDL); + } + func_80033480(globalCtx, &pthis->actor.world.pos, 40.0f, 3, 50, 140, 1); +} + +void ObjKibako_WaterBreak(ObjKibako* pthis, GlobalContext* globalCtx) { + s16 angle; + s32 i; + Vec3f* breakPos = &pthis->actor.world.pos; + Vec3f pos; + Vec3f velocity; + + pos = *breakPos; + pos.y += pthis->actor.yDistToWater; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 500); + + for (i = 0, angle = 0; i < 12; i++, angle += 0x4E20) { + f32 sn = Math_SinS(angle); + f32 cs = Math_CosS(angle); + f32 temp_rand; + s16 phi_s0; + + pos.x = sn * 16.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = cs * 16.0f; + velocity.x = pos.x * 0.18f; + velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + velocity.z = pos.z * 0.18f; + pos.x += breakPos->x; + pos.y += breakPos->y; + pos.z += breakPos->z; + temp_rand = Rand_ZeroOne(); + phi_s0 = (temp_rand < 0.2f) ? 0x40 : 0x20; + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, breakPos, -180, phi_s0, 30, 30, 0, + (Rand_ZeroOne() * 30.0f) + 10.0f, 0, 32, 70, KAKERA_COLOR_NONE, + OBJECT_GAMEPLAY_DANGEON_KEEP, gSmallWoodenBoxFragmentDL); + } +} + +void ObjKibako_SetupIdle(ObjKibako* pthis) { + pthis->actionFunc = ObjKibako_Idle; + pthis->actor.colChkInfo.mass = MASS_HEAVY; +} + +void ObjKibako_Idle(ObjKibako* pthis, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + ObjKibako_SetupHeld(pthis); + } else if ((pthis->actor.bgCheckFlags & 0x20) && (pthis->actor.yDistToWater > 19.0f)) { + ObjKibako_WaterBreak(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako_SpawnCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + } else if (pthis->collider.base.acFlags & AC_HIT) { + ObjKibako_AirBreak(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako_SpawnCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + } else { + Actor_MoveForward(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 19.0f, 20.0f, 0.0f, 5); + if (!(pthis->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (pthis->actor.xzDistToPlayer > 28.0f)) { + pthis->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + if (pthis->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actor.xzDistToPlayer < 180.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + if (pthis->actor.xzDistToPlayer < 100.0f) { + func_8002F580(&pthis->actor, globalCtx); + } + } +} + +void ObjKibako_SetupHeld(ObjKibako* pthis) { + pthis->actionFunc = ObjKibako_Held; + pthis->actor.room = -1; + func_8002F7DC(&pthis->actor, NA_SE_PL_PULL_UP_WOODBOX); +} + +void ObjKibako_Held(ObjKibako* pthis, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + pthis->actor.room = globalCtx->roomCtx.curRoom.num; + if (fabsf(pthis->actor.speedXZ) < 0.1f) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + ObjKibako_SetupIdle(pthis); + pthis->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } else { + ObjKibako_SetupThrown(pthis); + ObjKibako_ApplyGravity(pthis); + func_8002D7EC(&pthis->actor); + } + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 19.0f, 20.0f, 0.0f, 5); + } +} + +void ObjKibako_SetupThrown(ObjKibako* pthis) { + pthis->actor.velocity.x = Math_SinS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.velocity.z = Math_CosS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.colChkInfo.mass = 240; + pthis->actionFunc = ObjKibako_Thrown; +} + +void ObjKibako_Thrown(ObjKibako* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + + if ((pthis->actor.bgCheckFlags & 0xB) || (pthis->collider.base.atFlags & AT_HIT)) { + ObjKibako_AirBreak(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako_SpawnCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + } else if (pthis->actor.bgCheckFlags & 0x40) { + ObjKibako_WaterBreak(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako_SpawnCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + } else { + ObjKibako_ApplyGravity(pthis); + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 19.0f, 20.0f, 0.0f, 5); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjKibako* pthis = (ObjKibako*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjKibako* pthis = (ObjKibako*)thisx; + + Gfx_DrawDListOpa(globalCtx, gSmallWoodenBoxDL); +} diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.cpp similarity index 58% rename from src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c rename to src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.cpp index cacce8880..8b5bace53 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.cpp @@ -26,10 +26,10 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx); void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx); -void ObjKibako2_Kill(ObjKibako2* this, GlobalContext* globalCtx); +void ObjKibako2_Idle(ObjKibako2* pthis, GlobalContext* globalCtx); +void ObjKibako2_Kill(ObjKibako2* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Kibako2_InitVars = { +ActorInit Obj_Kibako2_InitVars = { ACTOR_OBJ_KIBAKO2, ACTORCAT_BG, FLAGS, @@ -69,14 +69,14 @@ static InitChainEntry sInitChain[] = { }; void ObjKibako2_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - ObjKibako2* this = (ObjKibako2*)thisx; + ObjKibako2* pthis = (ObjKibako2*)thisx; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->dyna.actor, &pthis->collider); } -void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { +void ObjKibako2_Break(ObjKibako2* pthis, GlobalContext* globalCtx) { s32 pad[2]; Vec3f* thisPos; Vec3f pos; @@ -84,7 +84,7 @@ void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { s16 angle; s32 i; - thisPos = &this->dyna.actor.world.pos; + thisPos = &pthis->dyna.actor.world.pos; for (i = 0, angle = 0; i < 0x10; i++, angle += 0x4E20) { f32 sn = Math_SinS(angle); f32 cs = Math_CosS(angle); @@ -115,75 +115,75 @@ void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { func_80033480(globalCtx, thisPos, 90.0f, 6, 100, 160, 1); } -void ObjKibako2_SpawnCollectible(ObjKibako2* this, GlobalContext* globalCtx) { +void ObjKibako2_SpawnCollectible(ObjKibako2* pthis, GlobalContext* globalCtx) { s16 itemDropped; s16 collectibleFlagTemp; - collectibleFlagTemp = this->collectibleFlag; - itemDropped = this->dyna.actor.home.rot.x; + collectibleFlagTemp = pthis->collectibleFlag; + itemDropped = pthis->dyna.actor.home.rot.x; if (itemDropped >= 0 && itemDropped < 0x1A) { - Item_DropCollectible(globalCtx, &this->dyna.actor.world.pos, itemDropped | (collectibleFlagTemp << 8)); + Item_DropCollectible(globalCtx, &pthis->dyna.actor.world.pos, itemDropped | (collectibleFlagTemp << 8)); } } void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjKibako2* this = (ObjKibako2*)thisx; + ObjKibako2* pthis = (ObjKibako2*)thisx; s16 pad; CollisionHeader* colHeader = NULL; u32 bgId; - DynaPolyActor_Init(&this->dyna, 0); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&pthis->dyna, 0); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); ObjKibako2_InitCollider(thisx, globalCtx); CollisionHeader_GetVirtual(&gLargeCrateCol, &colHeader); - bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - this->collectibleFlag = this->dyna.actor.home.rot.z & 0x3F; - this->dyna.bgId = bgId; - this->actionFunc = ObjKibako2_Idle; - this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = - this->dyna.actor.world.rot.x = this->dyna.actor.shape.rot.x = 0; + bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + pthis->collectibleFlag = pthis->dyna.actor.home.rot.z & 0x3F; + pthis->dyna.bgId = bgId; + pthis->actionFunc = ObjKibako2_Idle; + pthis->dyna.actor.home.rot.z = pthis->dyna.actor.world.rot.z = pthis->dyna.actor.shape.rot.z = + pthis->dyna.actor.world.rot.x = pthis->dyna.actor.shape.rot.x = 0; // "Wooden box (stationary)" - osSyncPrintf("木箱(据置)(arg %04xH)(item %04xH %d)\n", this->dyna.actor.params, this->collectibleFlag, - this->dyna.actor.home.rot.x); + osSyncPrintf("木箱(据置)(arg %04xH)(item %04xH %d)\n", pthis->dyna.actor.params, pthis->collectibleFlag, + pthis->dyna.actor.home.rot.x); } void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjKibako2* this = (ObjKibako2*)thisx; + ObjKibako2* pthis = (ObjKibako2*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &pthis->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); } -void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) { - if ((this->collider.base.acFlags & AC_HIT) || (this->dyna.actor.home.rot.z != 0) || - func_80033684(globalCtx, &this->dyna.actor) != NULL) { - ObjKibako2_Break(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - this->dyna.actor.flags |= ACTOR_FLAG_4; - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dyna.actor.draw = NULL; - this->actionFunc = ObjKibako2_Kill; - } else if (this->dyna.actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +void ObjKibako2_Idle(ObjKibako2* pthis, GlobalContext* globalCtx) { + if ((pthis->collider.base.acFlags & AC_HIT) || (pthis->dyna.actor.home.rot.z != 0) || + func_80033684(globalCtx, &pthis->dyna.actor) != NULL) { + ObjKibako2_Break(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + pthis->dyna.actor.flags |= ACTOR_FLAG_4; + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + pthis->dyna.actor.draw = NULL; + pthis->actionFunc = ObjKibako2_Kill; + } else if (pthis->dyna.actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } -void ObjKibako2_Kill(ObjKibako2* this, GlobalContext* globalCtx) { - s16 params = this->dyna.actor.params; +void ObjKibako2_Kill(ObjKibako2* pthis, GlobalContext* globalCtx) { + s16 params = pthis->dyna.actor.params; if ((params & 0x8000) == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, this->dyna.actor.shape.rot.y, 0, + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, pthis->dyna.actor.shape.rot.y, 0, params | 0x8000); } - ObjKibako2_SpawnCollectible(this, globalCtx); - Actor_Kill(&this->dyna.actor); + ObjKibako2_SpawnCollectible(pthis, globalCtx); + Actor_Kill(&pthis->dyna.actor); } void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjKibako2* this = (ObjKibako2*)thisx; + ObjKibako2* pthis = (ObjKibako2*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c deleted file mode 100644 index 4bb7fae0d..000000000 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ /dev/null @@ -1,232 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_LIFT_Z_OBJ_LIFT_C -#include "actor_common.h" -/* - * File: z_obj_lift.c - * Overlay: ovl_Obj_Lift - * Description: Square, collapsing platform - */ - -#include "z_obj_lift.h" -#include "objects/object_d_lift/object_d_lift.h" -#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#include "def/code_80043480.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_quake.h" - -#define FLAGS ACTOR_FLAG_4 - -void ObjLift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjLift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjLift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjLift_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80B9651C(ObjLift* this); -void func_80B9664C(ObjLift* this); -void func_80B967C0(ObjLift* this); - -void func_80B96560(ObjLift* this, GlobalContext* globalCtx); -void func_80B96678(ObjLift* this, GlobalContext* globalCtx); -void func_80B96840(ObjLift* this, GlobalContext* globalCtx); - -const ActorInit Obj_Lift_InitVars = { - ACTOR_OBJ_LIFT, - ACTORCAT_BG, - FLAGS, - OBJECT_D_LIFT, - sizeof(ObjLift), - (ActorFunc)ObjLift_Init, - (ActorFunc)ObjLift_Destroy, - (ActorFunc)ObjLift_Update, - (ActorFunc)ObjLift_Draw, -}; - -static s16 sFallTimerDurations[] = { 0, 10, 20, 30, 40, 50, 60 }; - -typedef struct { - /* 0x00 */ s16 x; - /* 0x02 */ s16 z; -} ObjLiftFramgentScale; // size = 0x4 - -static ObjLiftFramgentScale sFragmentScales[] = { - { 120, -120 }, { 120, 0 }, { 120, 120 }, { 0, -120 }, { 0, 0 }, - { 0, 120 }, { -120, -120 }, { -120, 0 }, { -120, 120 }, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 2000, ICHAIN_STOP), -}; - -static f32 sScales[] = { 0.1f, 0.05f }; -static f32 sMaxFallDistances[] = { -18.0f, -9.0f }; - -void ObjLift_SetupAction(ObjLift* this, ObjLiftActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - -void ObjLift_InitDynaPoly(ObjLift* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, flags); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_lift.c", 188, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void func_80B96160(ObjLift* this, GlobalContext* globalCtx) { - Vec3f pos; - Vec3f velocity; - Vec3f* temp_s3; - s32 pad0; - s32 i; - - temp_s3 = &this->dyna.actor.world.pos; - - for (i = 0; i < ARRAY_COUNT(sFragmentScales); i++) { - pos.x = sFragmentScales[i].x * this->dyna.actor.scale.x + temp_s3->x; - pos.y = temp_s3->y; - pos.z = sFragmentScales[i].z * this->dyna.actor.scale.z + temp_s3->z; - velocity.x = sFragmentScales[i].x * this->dyna.actor.scale.x * 0.8f; - velocity.y = Rand_ZeroOne() * 10.0f + 6.0f; - velocity.z = sFragmentScales[i].z * this->dyna.actor.scale.z * 0.8f; - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, temp_s3, -256, (Rand_ZeroOne() < 0.5f) ? 64 : 32, 15, 15, 0, - (Rand_ZeroOne() * 50.0f + 50.0f) * this->dyna.actor.scale.x, 0, 32, 50, KAKERA_COLOR_NONE, - OBJECT_D_LIFT, gCollapsingPlatformDL); - } - - if (((this->dyna.actor.params >> 1) & 1) == 0) { - func_80033480(globalCtx, &this->dyna.actor.world.pos, 120.0f, 12, 120, 100, 1); - } else if (((this->dyna.actor.params >> 1) & 1) == 1) { - func_80033480(globalCtx, &this->dyna.actor.world.pos, 60.0f, 8, 60, 100, 1); - } -} - -void ObjLift_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjLift* this = (ObjLift*)thisx; - - ObjLift_InitDynaPoly(this, globalCtx, &gCollapsingPlatformCol, DPM_PLAYER); - - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 2) & 0x3F)) { - Actor_Kill(&this->dyna.actor); - return; - } - - Actor_SetScale(&this->dyna.actor, sScales[(this->dyna.actor.params >> 1) & 1]); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->unk168.x = Rand_ZeroOne() * 65535.5f; - this->unk168.y = Rand_ZeroOne() * 65535.5f; - this->unk168.z = Rand_ZeroOne() * 65535.5f; - func_80B9651C(this); - osSyncPrintf("(Dungeon Lift)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void ObjLift_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjLift* this = (ObjLift*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void func_80B9651C(ObjLift* this) { - this->timer = sFallTimerDurations[(this->dyna.actor.params >> 8) & 7]; - ObjLift_SetupAction(this, func_80B96560); -} - -void func_80B96560(ObjLift* this, GlobalContext* globalCtx) { - s32 pad; - s32 quakeIndex; - - if (func_8004356C(&this->dyna)) { - if (this->timer <= 0) { - if (((this->dyna.actor.params >> 8) & 7) == 7) { - func_80B967C0(this); - } else { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); - Quake_SetSpeed(quakeIndex, 10000); - Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 20); - func_80B9664C(this); - } - } - } else { - this->timer = sFallTimerDurations[(this->dyna.actor.params >> 8) & 7]; - } -} - -void func_80B9664C(ObjLift* this) { - this->timer = 20; - ObjLift_SetupAction(this, func_80B96678); -} - -void func_80B96678(ObjLift* this, GlobalContext* globalCtx) { - if (this->timer <= 0) { - func_80B967C0(this); - } else { - this->unk168.x += 10000; - this->dyna.actor.world.rot.x = (s16)(Math_SinS(this->unk168.x) * 300.0f) + this->dyna.actor.home.rot.x; - this->dyna.actor.world.rot.z = (s16)(Math_CosS(this->unk168.x) * 300.0f) + this->dyna.actor.home.rot.z; - this->dyna.actor.shape.rot.x = this->dyna.actor.world.rot.x; - this->dyna.actor.shape.rot.z = this->dyna.actor.world.rot.z; - this->unk168.y += 18000; - this->dyna.actor.world.pos.y = Math_SinS(this->unk168.y) + this->dyna.actor.home.pos.y; - this->unk168.z += 18000; - this->dyna.actor.world.pos.x = Math_SinS(this->unk168.z) * 3.0f + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = Math_CosS(this->unk168.z) * 3.0f + this->dyna.actor.home.pos.z; - } - - if ((this->timer & 3) == 3) { - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 16, NA_SE_EV_BLOCK_SHAKE); - } -} - -void func_80B967C0(ObjLift* this) { - ObjLift_SetupAction(this, func_80B96840); - Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); - this->dyna.actor.shape.rot = this->dyna.actor.world.rot = this->dyna.actor.home.rot; -} - -void func_80B96840(ObjLift* this, GlobalContext* globalCtx) { - s32 pad; - s32 bgId; - Vec3f sp2C; - - Actor_MoveForward(&this->dyna.actor); - Math_Vec3f_Copy(&sp2C, &this->dyna.actor.prevPos); - sp2C.y += sMaxFallDistances[(this->dyna.actor.params >> 1) & 1]; - this->dyna.actor.floorHeight = - BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &sp2C); - - if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= - (sMaxFallDistances[(this->dyna.actor.params >> 1) & 1] - 0.001f)) { - func_80B96160(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_BOX_BREAK); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 2) & 0x3F); - Actor_Kill(&this->dyna.actor); - } -} - -void ObjLift_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjLift* this = (ObjLift*)thisx; - - if (this->timer > 0) { - this->timer--; - } - - this->actionFunc(this, globalCtx); -} - -void ObjLift_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gCollapsingPlatformDL); -} diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.cpp b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.cpp new file mode 100644 index 000000000..6389296a3 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.cpp @@ -0,0 +1,232 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_LIFT_Z_OBJ_LIFT_C +#include "actor_common.h" +/* + * File: z_obj_lift.c + * Overlay: ovl_Obj_Lift + * Description: Square, collapsing platform + */ + +#include "z_obj_lift.h" +#include "objects/object_d_lift/object_d_lift.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "def/code_80043480.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_quake.h" + +#define FLAGS ACTOR_FLAG_4 + +void ObjLift_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjLift_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjLift_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjLift_Draw(Actor* thisx, GlobalContext* globalCtx); + +void func_80B9651C(ObjLift* pthis); +void func_80B9664C(ObjLift* pthis); +void func_80B967C0(ObjLift* pthis); + +void func_80B96560(ObjLift* pthis, GlobalContext* globalCtx); +void func_80B96678(ObjLift* pthis, GlobalContext* globalCtx); +void func_80B96840(ObjLift* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Lift_InitVars = { + ACTOR_OBJ_LIFT, + ACTORCAT_BG, + FLAGS, + OBJECT_D_LIFT, + sizeof(ObjLift), + (ActorFunc)ObjLift_Init, + (ActorFunc)ObjLift_Destroy, + (ActorFunc)ObjLift_Update, + (ActorFunc)ObjLift_Draw, +}; + +static s16 sFallTimerDurations[] = { 0, 10, 20, 30, 40, 50, 60 }; + +typedef struct { + /* 0x00 */ s16 x; + /* 0x02 */ s16 z; +} ObjLiftFramgentScale; // size = 0x4 + +static ObjLiftFramgentScale sFragmentScales[] = { + { 120, -120 }, { 120, 0 }, { 120, 120 }, { 0, -120 }, { 0, 0 }, + { 0, 120 }, { -120, -120 }, { -120, 0 }, { -120, 120 }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 2000, ICHAIN_STOP), +}; + +static f32 sScales[] = { 0.1f, 0.05f }; +static f32 sMaxFallDistances[] = { -18.0f, -9.0f }; + +void ObjLift_SetupAction(ObjLift* pthis, ObjLiftActionFunc actionFunc) { + pthis->actionFunc = actionFunc; +} + +void ObjLift_InitDynaPoly(ObjLift* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 flags) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, flags); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_lift.c", 188, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void func_80B96160(ObjLift* pthis, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f velocity; + Vec3f* temp_s3; + s32 pad0; + s32 i; + + temp_s3 = &pthis->dyna.actor.world.pos; + + for (i = 0; i < ARRAY_COUNT(sFragmentScales); i++) { + pos.x = sFragmentScales[i].x * pthis->dyna.actor.scale.x + temp_s3->x; + pos.y = temp_s3->y; + pos.z = sFragmentScales[i].z * pthis->dyna.actor.scale.z + temp_s3->z; + velocity.x = sFragmentScales[i].x * pthis->dyna.actor.scale.x * 0.8f; + velocity.y = Rand_ZeroOne() * 10.0f + 6.0f; + velocity.z = sFragmentScales[i].z * pthis->dyna.actor.scale.z * 0.8f; + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, temp_s3, -256, (Rand_ZeroOne() < 0.5f) ? 64 : 32, 15, 15, 0, + (Rand_ZeroOne() * 50.0f + 50.0f) * pthis->dyna.actor.scale.x, 0, 32, 50, KAKERA_COLOR_NONE, + OBJECT_D_LIFT, gCollapsingPlatformDL); + } + + if (((pthis->dyna.actor.params >> 1) & 1) == 0) { + func_80033480(globalCtx, &pthis->dyna.actor.world.pos, 120.0f, 12, 120, 100, 1); + } else if (((pthis->dyna.actor.params >> 1) & 1) == 1) { + func_80033480(globalCtx, &pthis->dyna.actor.world.pos, 60.0f, 8, 60, 100, 1); + } +} + +void ObjLift_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjLift* pthis = (ObjLift*)thisx; + + ObjLift_InitDynaPoly(pthis, globalCtx, &gCollapsingPlatformCol, DPM_PLAYER); + + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 2) & 0x3F)) { + Actor_Kill(&pthis->dyna.actor); + return; + } + + Actor_SetScale(&pthis->dyna.actor, sScales[(pthis->dyna.actor.params >> 1) & 1]); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->unk168.x = Rand_ZeroOne() * 65535.5f; + pthis->unk168.y = Rand_ZeroOne() * 65535.5f; + pthis->unk168.z = Rand_ZeroOne() * 65535.5f; + func_80B9651C(pthis); + osSyncPrintf("(Dungeon Lift)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void ObjLift_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjLift* pthis = (ObjLift*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void func_80B9651C(ObjLift* pthis) { + pthis->timer = sFallTimerDurations[(pthis->dyna.actor.params >> 8) & 7]; + ObjLift_SetupAction(pthis, func_80B96560); +} + +void func_80B96560(ObjLift* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 quakeIndex; + + if (func_8004356C(&pthis->dyna)) { + if (pthis->timer <= 0) { + if (((pthis->dyna.actor.params >> 8) & 7) == 7) { + func_80B967C0(pthis); + } else { + quakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 1); + Quake_SetSpeed(quakeIndex, 10000); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); + func_80B9664C(pthis); + } + } + } else { + pthis->timer = sFallTimerDurations[(pthis->dyna.actor.params >> 8) & 7]; + } +} + +void func_80B9664C(ObjLift* pthis) { + pthis->timer = 20; + ObjLift_SetupAction(pthis, func_80B96678); +} + +void func_80B96678(ObjLift* pthis, GlobalContext* globalCtx) { + if (pthis->timer <= 0) { + func_80B967C0(pthis); + } else { + pthis->unk168.x += 10000; + pthis->dyna.actor.world.rot.x = (s16)(Math_SinS(pthis->unk168.x) * 300.0f) + pthis->dyna.actor.home.rot.x; + pthis->dyna.actor.world.rot.z = (s16)(Math_CosS(pthis->unk168.x) * 300.0f) + pthis->dyna.actor.home.rot.z; + pthis->dyna.actor.shape.rot.x = pthis->dyna.actor.world.rot.x; + pthis->dyna.actor.shape.rot.z = pthis->dyna.actor.world.rot.z; + pthis->unk168.y += 18000; + pthis->dyna.actor.world.pos.y = Math_SinS(pthis->unk168.y) + pthis->dyna.actor.home.pos.y; + pthis->unk168.z += 18000; + pthis->dyna.actor.world.pos.x = Math_SinS(pthis->unk168.z) * 3.0f + pthis->dyna.actor.home.pos.x; + pthis->dyna.actor.world.pos.z = Math_CosS(pthis->unk168.z) * 3.0f + pthis->dyna.actor.home.pos.z; + } + + if ((pthis->timer & 3) == 3) { + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 16, NA_SE_EV_BLOCK_SHAKE); + } +} + +void func_80B967C0(ObjLift* pthis) { + ObjLift_SetupAction(pthis, func_80B96840); + Math_Vec3f_Copy(&pthis->dyna.actor.world.pos, &pthis->dyna.actor.home.pos); + pthis->dyna.actor.shape.rot = pthis->dyna.actor.world.rot = pthis->dyna.actor.home.rot; +} + +void func_80B96840(ObjLift* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 bgId; + Vec3f sp2C; + + Actor_MoveForward(&pthis->dyna.actor); + Math_Vec3f_Copy(&sp2C, &pthis->dyna.actor.prevPos); + sp2C.y += sMaxFallDistances[(pthis->dyna.actor.params >> 1) & 1]; + pthis->dyna.actor.floorHeight = + BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &pthis->dyna.actor.floorPoly, &bgId, &pthis->dyna.actor, &sp2C); + + if ((pthis->dyna.actor.floorHeight - pthis->dyna.actor.world.pos.y) >= + (sMaxFallDistances[(pthis->dyna.actor.params >> 1) & 1] - 0.001f)) { + func_80B96160(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->dyna.actor.world.pos, 20, NA_SE_EV_BOX_BREAK); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 2) & 0x3F); + Actor_Kill(&pthis->dyna.actor); + } +} + +void ObjLift_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjLift* pthis = (ObjLift*)thisx; + + if (pthis->timer > 0) { + pthis->timer--; + } + + pthis->actionFunc(pthis, globalCtx); +} + +void ObjLift_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gCollapsingPlatformDL); +} diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c deleted file mode 100644 index 3aed98fce..000000000 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ /dev/null @@ -1,511 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_LIGHTSWITCH_Z_OBJ_LIGHTSWITCH_C -#include "actor_common.h" -/* - * File: z_obj_lightswitch.c - * Overlay: ovl_Obj_Lightswitch - * Description: Sun Emblem Trigger (Spirit Temple) - */ - -#include "z_obj_lightswitch.h" -#include "vt.h" -#include "overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h" -#include "objects/object_lightswitch/object_lightswitch.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -typedef enum { - /* 0x00 */ FACE_EYES_CLOSED, - /* 0x01 */ FACE_EYES_OPEN, - /* 0x02 */ FACE_EYES_OPEN_SMILING -} FaceTextureIndex; - -void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjLightswitch_SetupOff(ObjLightswitch* this); -void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx); -void ObjLightswitch_SetupTurnOn(ObjLightswitch* this); -void ObjLightswitch_TurnOn(ObjLightswitch* this, GlobalContext* globalCtx); -void ObjLightswitch_SetupOn(ObjLightswitch* this); -void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx); -void ObjLightswitch_SetupTurnOff(ObjLightswitch* this); -void ObjLightswitch_TurnOff(ObjLightswitch* this, GlobalContext* globalCtx); -void ObjLightswitch_SetupDisappearDelay(ObjLightswitch* this); -void ObjLightswitch_DisappearDelay(ObjLightswitch* this, GlobalContext* globalCtx); -void ObjLightswitch_SetupDisappear(ObjLightswitch* this); -void ObjLightswitch_Disappear(ObjLightswitch* this, GlobalContext* globalCtx); - -const ActorInit Obj_Lightswitch_InitVars = { - ACTOR_OBJ_LIGHTSWITCH, - ACTORCAT_SWITCH, - FLAGS, - OBJECT_LIGHTSWITCH, - sizeof(ObjLightswitch), - (ActorFunc)ObjLightswitch_Init, - (ActorFunc)ObjLightswitch_Destroy, - (ActorFunc)ObjLightswitch_Update, - (ActorFunc)ObjLightswitch_Draw, -}; - -static ColliderJntSphElementInit sColliderJntSphElementInit[] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00200000, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, 0, 0 }, 19 }, 100 }, - }, -}; -static ColliderJntSphInit sColliderJntSphInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - 1, - sColliderJntSphElementInit, -}; - -static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; - -static void* sFaceTextures[] = { object_lightswitch_Tex_000C20, object_lightswitch_Tex_000420, - object_lightswitch_Tex_001420 }; - -static Vec3f D_80B97F68 = { -1707.0f, 843.0f, -180.0f }; -static Vec3f D_80B97F74 = { 0.0f, 0.0f, 0.0f }; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), -}; - -void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) { - s32 pad; - - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems); - func_800D1694(this->actor.world.pos.x, this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Collider_UpdateSpheres(0, &this->collider); -} - -void ObjLightswitch_SetSwitchFlag(ObjLightswitch* this, GlobalContext* globalCtx) { - Actor* thisx = &this->actor; // required - s32 type; - - if (!Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F)) { - type = this->actor.params >> 4 & 3; - - Flags_SetSwitch(globalCtx, this->actor.params >> 8 & 0x3F); - - if (type == OBJLIGHTSWITCH_TYPE_1) { - OnePointCutscene_AttentionSetSfx(globalCtx, thisx, NA_SE_SY_TRE_BOX_APPEAR); - } else if (type == OBJLIGHTSWITCH_TYPE_BURN) { - OnePointCutscene_AttentionSetSfx(globalCtx, thisx, NA_SE_SY_ERROR); - } else { - OnePointCutscene_AttentionSetSfx(globalCtx, thisx, NA_SE_SY_CORRECT_CHIME); - } - } -} - -void ObjLightswitch_ClearSwitchFlag(ObjLightswitch* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F)) { - Flags_UnsetSwitch(globalCtx, this->actor.params >> 8 & 0x3F); - - if ((this->actor.params >> 4 & 3) == OBJLIGHTSWITCH_TYPE_1) { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->actor, NA_SE_SY_TRE_BOX_APPEAR); - } - } -} - -void ObjLightswitch_SpawnDisappearEffects(ObjLightswitch* this, GlobalContext* globalCtx) { - Vec3f pos; - f32 s = Math_SinS(this->actor.shape.rot.y); - f32 c = Math_CosS(this->actor.shape.rot.y); - f32 x; - f32 y; - f32 z; - s32 pad; - - if (this->alpha >= (100 << 6)) { - x = (CLAMP_MAX((1.0f - 1.0f / (255 << 6) * this->alpha) * 400.0f, 60.0f) - 30.0f + 30.0f) * Rand_ZeroOne(); - y = x - 30.0f; - if (x > 30.0f) { - x = 30.0f; - } else { - x = 900.0f - (y * y); - if (x < 100.0f) { - x = 100.0f; - } - x = sqrtf(x); - } - x = 2.0f * (x * (Rand_ZeroOne() - 0.5f)); - z = (30.0f - fabsf(x)) * 0.5f + 10.0f * Rand_ZeroOne(); - pos.x = this->actor.world.pos.x + ((z * s) + (x * c)); - pos.y = this->actor.world.pos.y + y + 10.0f; - pos.z = this->actor.world.pos.z + ((z * c) - (x * s)); - EffectSsDeadDb_Spawn(globalCtx, &pos, &D_80B97F74, &D_80B97F74, 100, 0, 255, 255, 160, 160, 255, 0, 0, 1, 9, - true); - } -} - -void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjLightswitch* this = (ObjLightswitch*)thisx; - s32 switchFlagSet = Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F); - s32 removeSelf = false; - - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetFocus(&this->actor, 0.0f); - if (switchFlagSet) { - if ((this->actor.params >> 4 & 3) == OBJLIGHTSWITCH_TYPE_BURN) { - removeSelf = true; - } else { - ObjLightswitch_SetupOn(this); - } - } else { - ObjLightswitch_SetupOff(this); - } - if ((this->actor.params & 1) == 1) { - if (switchFlagSet) { - Math_Vec3f_Copy(&this->actor.world.pos, &D_80B97F68); - Math_Vec3f_Copy(&this->actor.home.pos, &D_80B97F68); - } - this->actor.shape.rot.x = -0x4000; - this->actor.shape.rot.z = 0; - this->actor.world.rot.x = this->actor.home.rot.x = this->actor.shape.rot.x; - this->actor.world.rot.z = this->actor.home.rot.z = this->actor.shape.rot.z; - this->actor.flags |= ACTOR_FLAG_5; - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_OSHIHIKI, - this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, - this->actor.home.rot.y, 0, (0xFF << 8) | PUSHBLOCK_SMALL_START_ON) == NULL) { - osSyncPrintf(VT_COL(RED, WHITE)); - // "Push-pull block occurrence failure" - osSyncPrintf("押引ブロック発生失敗(%s %d)(arg_data 0x%04x)\n", "../z_obj_lightswitch.c", 452, - this->actor.params); - osSyncPrintf(VT_RST); - removeSelf = true; - } - } - ObjLightswitch_InitCollider(this, globalCtx); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (removeSelf) { - Actor_Kill(&this->actor); - } - // "Light switch" - osSyncPrintf("(光スイッチ)(arg_data 0x%04x)\n", this->actor.params); -} - -void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - ObjLightswitch* this = (ObjLightswitch*)thisx; - - Collider_DestroyJntSph(globalCtx, &this->collider); -} - -void ObjLightswitch_SetupOff(ObjLightswitch* this) { - this->actionFunc = ObjLightswitch_Off; - this->faceTextureIndex = FACE_EYES_CLOSED; - this->color[0] = 155 << 6; - this->color[1] = 125 << 6; - this->color[2] = 255 << 6; - this->alpha = 255 << 6; -} - -void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) { - switch (this->actor.params >> 4 & 3) { - case OBJLIGHTSWITCH_TYPE_STAY_ON: - case OBJLIGHTSWITCH_TYPE_2: - if (this->collider.base.acFlags & AC_HIT) { - ObjLightswitch_SetupTurnOn(this); - ObjLightswitch_SetSwitchFlag(this, globalCtx); - } - break; - case OBJLIGHTSWITCH_TYPE_1: - if ((this->collider.base.acFlags & AC_HIT) && !(this->prevFrameACflags & AC_HIT)) { - ObjLightswitch_SetupTurnOn(this); - ObjLightswitch_SetSwitchFlag(this, globalCtx); - } - break; - case OBJLIGHTSWITCH_TYPE_BURN: - if (this->collider.base.acFlags & AC_HIT) { - ObjLightswitch_SetupDisappearDelay(this); - ObjLightswitch_SetSwitchFlag(this, globalCtx); - } - break; - } -} - -void ObjLightswitch_SetupTurnOn(ObjLightswitch* this) { - this->actionFunc = ObjLightswitch_TurnOn; - this->toggleDelay = 100; - this->timer = 0; - this->faceTextureIndex = FACE_EYES_CLOSED; -} - -void ObjLightswitch_TurnOn(ObjLightswitch* this, GlobalContext* globalCtx) { - if (func_8005B198() == this->actor.category || this->toggleDelay <= 0) { - if (this->timer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_TRIFORCE_FLASH); - } - - this->timer++; - - Math_StepToS(&this->flameRingRotSpeed, -0xAA, 0xA); - this->flameRingRot += this->flameRingRotSpeed; - - this->color[0] = this->timer * (((255 - 155) << 6) / 20) + (155 << 6); - this->color[1] = this->timer * (((255 - 125) << 6) / 20) + (125 << 6); - - if (this->timer >= 20) { - ObjLightswitch_SetupOn(this); - } else if (this->timer == 15) { - this->faceTextureIndex = FACE_EYES_OPEN; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FOOT_SWITCH); - } - } -} - -void ObjLightswitch_SetupOn(ObjLightswitch* this) { - this->actionFunc = ObjLightswitch_On; - this->faceTextureIndex = FACE_EYES_OPEN_SMILING; - - this->color[0] = 255 << 6; - this->color[1] = 255 << 6; - this->color[2] = 255 << 6; - this->alpha = 255 << 6; - - this->flameRingRotSpeed = -0xAA; - this->timer = 0; -} - -void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) { - switch (this->actor.params >> 4 & 3) { - case OBJLIGHTSWITCH_TYPE_STAY_ON: - if (!Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F)) { - ObjLightswitch_SetupTurnOff(this); - } - break; - case OBJLIGHTSWITCH_TYPE_1: - if (this->collider.base.acFlags & AC_HIT && !(this->prevFrameACflags & AC_HIT)) { - ObjLightswitch_SetupTurnOff(this); - ObjLightswitch_ClearSwitchFlag(this, globalCtx); - } - break; - case OBJLIGHTSWITCH_TYPE_2: - if (!(this->collider.base.acFlags & AC_HIT)) { - if (this->timer >= 7) { - ObjLightswitch_SetupTurnOff(this); - ObjLightswitch_ClearSwitchFlag(this, globalCtx); - } else { - this->timer++; - } - } else { - this->timer = 0; - } - break; - } - this->flameRingRot += this->flameRingRotSpeed; -} - -void ObjLightswitch_SetupTurnOff(ObjLightswitch* this) { - this->actionFunc = ObjLightswitch_TurnOff; - this->toggleDelay = 100; - this->timer = 20; - this->faceTextureIndex = FACE_EYES_OPEN; -} - -void ObjLightswitch_TurnOff(ObjLightswitch* this, GlobalContext* globalCtx) { - if ((this->actor.params >> 4 & 3) != OBJLIGHTSWITCH_TYPE_1 || func_8005B198() == this->actor.category || - this->toggleDelay <= 0) { - this->timer--; - - Math_StepToS(&this->flameRingRotSpeed, 0, 0xA); - this->flameRingRot += this->flameRingRotSpeed; - - this->color[0] = this->timer * (((255 - 155) << 6) / 20) + (155 << 6); - this->color[1] = this->timer * (((255 - 125) << 6) / 20) + (125 << 6); - - if (this->timer <= 0) { - ObjLightswitch_SetupOff(this); - } else if (this->timer == 15) { - this->faceTextureIndex = FACE_EYES_CLOSED; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FOOT_SWITCH); - } - } -} - -void ObjLightswitch_SetupDisappearDelay(ObjLightswitch* this) { - this->actionFunc = ObjLightswitch_DisappearDelay; - this->toggleDelay = 100; -} - -void ObjLightswitch_DisappearDelay(ObjLightswitch* this, GlobalContext* globalCtx) { - if (func_8005B198() == this->actor.category || this->toggleDelay <= 0) { - ObjLightswitch_SetupDisappear(this); - } -} - -void ObjLightswitch_SetupDisappear(ObjLightswitch* this) { - this->actionFunc = ObjLightswitch_Disappear; - this->alpha = 255 << 6; -} - -void ObjLightswitch_Disappear(ObjLightswitch* this, GlobalContext* globalCtx) { - this->alpha -= 200; - ObjLightswitch_SpawnDisappearEffects(this, globalCtx); - if (this->alpha < 0) { - Actor_Kill(&this->actor); - } -} - -void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx2) { - ObjLightswitch* this = (ObjLightswitch*)thisx; - GlobalContext* globalCtx = globalCtx2; - - if (this->toggleDelay > 0) { - this->toggleDelay--; - } - - this->actionFunc(this, globalCtx); - - if (this->actor.update != NULL) { - if ((this->actor.params & 1) == 1) { - this->actor.world.pos.x = this->actor.child->world.pos.x; - this->actor.world.pos.y = this->actor.child->world.pos.y + 60.0f; - this->actor.world.pos.z = this->actor.child->world.pos.z; - Actor_SetFocus(&this->actor, 0.0f); - } - - this->prevFrameACflags = this->collider.base.acFlags; - this->collider.base.acFlags &= ~AC_HIT; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void ObjLightswitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { - Actor* child; - Vec3f pos; - Vec3s rot; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 809); - func_80093D18(globalCtx->state.gfxCtx); - - gDPSetEnvColor(POLY_OPA_DISP++, (u8)(this->color[0] >> 6), (u8)(this->color[1] >> 6), (u8)(this->color[2] >> 6), - (u8)(this->alpha >> 6)); - gSPSegment(POLY_OPA_DISP++, 0x09, &D_80116280[2]); - - if ((this->actor.params & 1) == 1) { - child = this->actor.child; - this->actor.world.pos.x = child->world.pos.x; - this->actor.world.pos.y = child->world.pos.y + 60.0f; - this->actor.world.pos.z = child->world.pos.z; - Math_Vec3f_Copy(&pos, &this->actor.world.pos); - func_800D1694(pos.x, pos.y, pos.z, &this->actor.shape.rot); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - } else { - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + this->actor.shape.yOffset * this->actor.scale.y; - pos.z = this->actor.world.pos.z; - } - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 841), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFaceTextures[this->faceTextureIndex])); - gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000260); - - rot.x = this->actor.shape.rot.x; - rot.y = this->actor.shape.rot.y; - rot.z = this->actor.shape.rot.z + this->flameRingRot; - func_800D1694(pos.x, pos.y, pos.z, &rot); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 859), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000398); - - rot.z = this->actor.shape.rot.z - this->flameRingRot; - func_800D1694(pos.x, pos.y, pos.z, &rot); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 873), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000408); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 878); -} - -void ObjLightswitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { - s32 pad; - Vec3f sp68; - Vec3s sp60; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 890); - func_80093D84(globalCtx->state.gfxCtx); - - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->color[0] >> 6), (u8)(this->color[1] >> 6), (u8)(this->color[2] >> 6), - (u8)(this->alpha >> 6)); - gSPSegment(POLY_XLU_DISP++, 0x09, D_80116280); - - sp68.x = this->actor.world.pos.x; - sp68.y = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); - sp68.z = this->actor.world.pos.z; - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 912), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFaceTextures[this->faceTextureIndex])); - gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000260); - - sp60.x = this->actor.shape.rot.x; - sp60.y = this->actor.shape.rot.y; - sp60.z = this->actor.shape.rot.z + this->flameRingRot; - - func_800D1694(sp68.x, sp68.y, sp68.z, &sp60); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 930), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000398); - - sp60.z = this->actor.shape.rot.z - this->flameRingRot; - func_800D1694(sp68.x, sp68.y, sp68.z, &sp60); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 944), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000408); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 949); -} - -void ObjLightswitch_Draw(Actor* thisx, GlobalContext* globalCtx) { - ObjLightswitch* this = (ObjLightswitch*)thisx; - s32 alpha = this->alpha >> 6 & 0xFF; - - if ((this->actor.params & 1) == 1) { - Collider_UpdateSpheres(0, &this->collider); - } - - if ((this->actor.params >> 4 & 3) == OBJLIGHTSWITCH_TYPE_BURN && (alpha > 0 || alpha < 255)) { - ObjLightswitch_DrawXlu(this, globalCtx); - } else { - ObjLightswitch_DrawOpa(this, globalCtx); - } -} diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.cpp b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.cpp new file mode 100644 index 000000000..ee37f70b1 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.cpp @@ -0,0 +1,511 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_LIGHTSWITCH_Z_OBJ_LIGHTSWITCH_C +#include "actor_common.h" +/* + * File: z_obj_lightswitch.c + * Overlay: ovl_Obj_Lightswitch + * Description: Sun Emblem Trigger (Spirit Temple) + */ + +#include "z_obj_lightswitch.h" +#include "vt.h" +#include "overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h" +#include "objects/object_lightswitch/object_lightswitch.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +typedef enum { + /* 0x00 */ FACE_EYES_CLOSED, + /* 0x01 */ FACE_EYES_OPEN, + /* 0x02 */ FACE_EYES_OPEN_SMILING +} FaceTextureIndex; + +void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjLightswitch_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjLightswitch_SetupOff(ObjLightswitch* pthis); +void ObjLightswitch_Off(ObjLightswitch* pthis, GlobalContext* globalCtx); +void ObjLightswitch_SetupTurnOn(ObjLightswitch* pthis); +void ObjLightswitch_TurnOn(ObjLightswitch* pthis, GlobalContext* globalCtx); +void ObjLightswitch_SetupOn(ObjLightswitch* pthis); +void ObjLightswitch_On(ObjLightswitch* pthis, GlobalContext* globalCtx); +void ObjLightswitch_SetupTurnOff(ObjLightswitch* pthis); +void ObjLightswitch_TurnOff(ObjLightswitch* pthis, GlobalContext* globalCtx); +void ObjLightswitch_SetupDisappearDelay(ObjLightswitch* pthis); +void ObjLightswitch_DisappearDelay(ObjLightswitch* pthis, GlobalContext* globalCtx); +void ObjLightswitch_SetupDisappear(ObjLightswitch* pthis); +void ObjLightswitch_Disappear(ObjLightswitch* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Lightswitch_InitVars = { + ACTOR_OBJ_LIGHTSWITCH, + ACTORCAT_SWITCH, + FLAGS, + OBJECT_LIGHTSWITCH, + sizeof(ObjLightswitch), + (ActorFunc)ObjLightswitch_Init, + (ActorFunc)ObjLightswitch_Destroy, + (ActorFunc)ObjLightswitch_Update, + (ActorFunc)ObjLightswitch_Draw, +}; + +static ColliderJntSphElementInit sColliderJntSphElementInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 19 }, 100 }, + }, +}; +static ColliderJntSphInit sColliderJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sColliderJntSphElementInit, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; + +static void* sFaceTextures[] = { object_lightswitch_Tex_000C20, object_lightswitch_Tex_000420, + object_lightswitch_Tex_001420 }; + +static Vec3f D_80B97F68 = { -1707.0f, 843.0f, -180.0f }; +static Vec3f D_80B97F74 = { 0.0f, 0.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), +}; + +void ObjLightswitch_InitCollider(ObjLightswitch* pthis, GlobalContext* globalCtx) { + s32 pad; + + Collider_InitJntSph(globalCtx, &pthis->collider); + Collider_SetJntSph(globalCtx, &pthis->collider, &pthis->actor, &sColliderJntSphInit, pthis->colliderItems); + func_800D1694(pthis->actor.world.pos.x, pthis->actor.world.pos.y + (pthis->actor.shape.yOffset * pthis->actor.scale.y), + pthis->actor.world.pos.z, &pthis->actor.shape.rot); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &pthis->collider); +} + +void ObjLightswitch_SetSwitchFlag(ObjLightswitch* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->actor; // required + s32 type; + + if (!Flags_GetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F)) { + type = pthis->actor.params >> 4 & 3; + + Flags_SetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F); + + if (type == OBJLIGHTSWITCH_TYPE_1) { + OnePointCutscene_AttentionSetSfx(globalCtx, thisx, NA_SE_SY_TRE_BOX_APPEAR); + } else if (type == OBJLIGHTSWITCH_TYPE_BURN) { + OnePointCutscene_AttentionSetSfx(globalCtx, thisx, NA_SE_SY_ERROR); + } else { + OnePointCutscene_AttentionSetSfx(globalCtx, thisx, NA_SE_SY_CORRECT_CHIME); + } + } +} + +void ObjLightswitch_ClearSwitchFlag(ObjLightswitch* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F)) { + Flags_UnsetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F); + + if ((pthis->actor.params >> 4 & 3) == OBJLIGHTSWITCH_TYPE_1) { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->actor, NA_SE_SY_TRE_BOX_APPEAR); + } + } +} + +void ObjLightswitch_SpawnDisappearEffects(ObjLightswitch* pthis, GlobalContext* globalCtx) { + Vec3f pos; + f32 s = Math_SinS(pthis->actor.shape.rot.y); + f32 c = Math_CosS(pthis->actor.shape.rot.y); + f32 x; + f32 y; + f32 z; + s32 pad; + + if (pthis->alpha >= (100 << 6)) { + x = (CLAMP_MAX((1.0f - 1.0f / (255 << 6) * pthis->alpha) * 400.0f, 60.0f) - 30.0f + 30.0f) * Rand_ZeroOne(); + y = x - 30.0f; + if (x > 30.0f) { + x = 30.0f; + } else { + x = 900.0f - (y * y); + if (x < 100.0f) { + x = 100.0f; + } + x = sqrtf(x); + } + x = 2.0f * (x * (Rand_ZeroOne() - 0.5f)); + z = (30.0f - fabsf(x)) * 0.5f + 10.0f * Rand_ZeroOne(); + pos.x = pthis->actor.world.pos.x + ((z * s) + (x * c)); + pos.y = pthis->actor.world.pos.y + y + 10.0f; + pos.z = pthis->actor.world.pos.z + ((z * c) - (x * s)); + EffectSsDeadDb_Spawn(globalCtx, &pos, &D_80B97F74, &D_80B97F74, 100, 0, 255, 255, 160, 160, 255, 0, 0, 1, 9, + true); + } +} + +void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjLightswitch* pthis = (ObjLightswitch*)thisx; + s32 switchFlagSet = Flags_GetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F); + s32 removeSelf = false; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + Actor_SetFocus(&pthis->actor, 0.0f); + if (switchFlagSet) { + if ((pthis->actor.params >> 4 & 3) == OBJLIGHTSWITCH_TYPE_BURN) { + removeSelf = true; + } else { + ObjLightswitch_SetupOn(pthis); + } + } else { + ObjLightswitch_SetupOff(pthis); + } + if ((pthis->actor.params & 1) == 1) { + if (switchFlagSet) { + Math_Vec3f_Copy(&pthis->actor.world.pos, &D_80B97F68); + Math_Vec3f_Copy(&pthis->actor.home.pos, &D_80B97F68); + } + pthis->actor.shape.rot.x = -0x4000; + pthis->actor.shape.rot.z = 0; + pthis->actor.world.rot.x = pthis->actor.home.rot.x = pthis->actor.shape.rot.x; + pthis->actor.world.rot.z = pthis->actor.home.rot.z = pthis->actor.shape.rot.z; + pthis->actor.flags |= ACTOR_FLAG_5; + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_OBJ_OSHIHIKI, + pthis->actor.home.pos.x, pthis->actor.home.pos.y, pthis->actor.home.pos.z, 0, + pthis->actor.home.rot.y, 0, (0xFF << 8) | PUSHBLOCK_SMALL_START_ON) == NULL) { + osSyncPrintf(VT_COL(RED, WHITE)); + // "Push-pull block occurrence failure" + osSyncPrintf("押引ブロック発生失敗(%s %d)(arg_data 0x%04x)\n", "../z_obj_lightswitch.c", 452, + pthis->actor.params); + osSyncPrintf(VT_RST); + removeSelf = true; + } + } + ObjLightswitch_InitCollider(pthis, globalCtx); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, &sColChkInfoInit); + if (removeSelf) { + Actor_Kill(&pthis->actor); + } + // "Light switch" + osSyncPrintf("(光スイッチ)(arg_data 0x%04x)\n", pthis->actor.params); +} + +void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjLightswitch* pthis = (ObjLightswitch*)thisx; + + Collider_DestroyJntSph(globalCtx, &pthis->collider); +} + +void ObjLightswitch_SetupOff(ObjLightswitch* pthis) { + pthis->actionFunc = ObjLightswitch_Off; + pthis->faceTextureIndex = FACE_EYES_CLOSED; + pthis->color[0] = 155 << 6; + pthis->color[1] = 125 << 6; + pthis->color[2] = 255 << 6; + pthis->alpha = 255 << 6; +} + +void ObjLightswitch_Off(ObjLightswitch* pthis, GlobalContext* globalCtx) { + switch (pthis->actor.params >> 4 & 3) { + case OBJLIGHTSWITCH_TYPE_STAY_ON: + case OBJLIGHTSWITCH_TYPE_2: + if (pthis->collider.base.acFlags & AC_HIT) { + ObjLightswitch_SetupTurnOn(pthis); + ObjLightswitch_SetSwitchFlag(pthis, globalCtx); + } + break; + case OBJLIGHTSWITCH_TYPE_1: + if ((pthis->collider.base.acFlags & AC_HIT) && !(pthis->prevFrameACflags & AC_HIT)) { + ObjLightswitch_SetupTurnOn(pthis); + ObjLightswitch_SetSwitchFlag(pthis, globalCtx); + } + break; + case OBJLIGHTSWITCH_TYPE_BURN: + if (pthis->collider.base.acFlags & AC_HIT) { + ObjLightswitch_SetupDisappearDelay(pthis); + ObjLightswitch_SetSwitchFlag(pthis, globalCtx); + } + break; + } +} + +void ObjLightswitch_SetupTurnOn(ObjLightswitch* pthis) { + pthis->actionFunc = ObjLightswitch_TurnOn; + pthis->toggleDelay = 100; + pthis->timer = 0; + pthis->faceTextureIndex = FACE_EYES_CLOSED; +} + +void ObjLightswitch_TurnOn(ObjLightswitch* pthis, GlobalContext* globalCtx) { + if (func_8005B198() == pthis->actor.category || pthis->toggleDelay <= 0) { + if (pthis->timer == 0) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_TRIFORCE_FLASH); + } + + pthis->timer++; + + Math_StepToS(&pthis->flameRingRotSpeed, -0xAA, 0xA); + pthis->flameRingRot += pthis->flameRingRotSpeed; + + pthis->color[0] = pthis->timer * (((255 - 155) << 6) / 20) + (155 << 6); + pthis->color[1] = pthis->timer * (((255 - 125) << 6) / 20) + (125 << 6); + + if (pthis->timer >= 20) { + ObjLightswitch_SetupOn(pthis); + } else if (pthis->timer == 15) { + pthis->faceTextureIndex = FACE_EYES_OPEN; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FOOT_SWITCH); + } + } +} + +void ObjLightswitch_SetupOn(ObjLightswitch* pthis) { + pthis->actionFunc = ObjLightswitch_On; + pthis->faceTextureIndex = FACE_EYES_OPEN_SMILING; + + pthis->color[0] = 255 << 6; + pthis->color[1] = 255 << 6; + pthis->color[2] = 255 << 6; + pthis->alpha = 255 << 6; + + pthis->flameRingRotSpeed = -0xAA; + pthis->timer = 0; +} + +void ObjLightswitch_On(ObjLightswitch* pthis, GlobalContext* globalCtx) { + switch (pthis->actor.params >> 4 & 3) { + case OBJLIGHTSWITCH_TYPE_STAY_ON: + if (!Flags_GetSwitch(globalCtx, pthis->actor.params >> 8 & 0x3F)) { + ObjLightswitch_SetupTurnOff(pthis); + } + break; + case OBJLIGHTSWITCH_TYPE_1: + if (pthis->collider.base.acFlags & AC_HIT && !(pthis->prevFrameACflags & AC_HIT)) { + ObjLightswitch_SetupTurnOff(pthis); + ObjLightswitch_ClearSwitchFlag(pthis, globalCtx); + } + break; + case OBJLIGHTSWITCH_TYPE_2: + if (!(pthis->collider.base.acFlags & AC_HIT)) { + if (pthis->timer >= 7) { + ObjLightswitch_SetupTurnOff(pthis); + ObjLightswitch_ClearSwitchFlag(pthis, globalCtx); + } else { + pthis->timer++; + } + } else { + pthis->timer = 0; + } + break; + } + pthis->flameRingRot += pthis->flameRingRotSpeed; +} + +void ObjLightswitch_SetupTurnOff(ObjLightswitch* pthis) { + pthis->actionFunc = ObjLightswitch_TurnOff; + pthis->toggleDelay = 100; + pthis->timer = 20; + pthis->faceTextureIndex = FACE_EYES_OPEN; +} + +void ObjLightswitch_TurnOff(ObjLightswitch* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.params >> 4 & 3) != OBJLIGHTSWITCH_TYPE_1 || func_8005B198() == pthis->actor.category || + pthis->toggleDelay <= 0) { + pthis->timer--; + + Math_StepToS(&pthis->flameRingRotSpeed, 0, 0xA); + pthis->flameRingRot += pthis->flameRingRotSpeed; + + pthis->color[0] = pthis->timer * (((255 - 155) << 6) / 20) + (155 << 6); + pthis->color[1] = pthis->timer * (((255 - 125) << 6) / 20) + (125 << 6); + + if (pthis->timer <= 0) { + ObjLightswitch_SetupOff(pthis); + } else if (pthis->timer == 15) { + pthis->faceTextureIndex = FACE_EYES_CLOSED; + Audio_PlayActorSound2(&pthis->actor, NA_SE_EV_FOOT_SWITCH); + } + } +} + +void ObjLightswitch_SetupDisappearDelay(ObjLightswitch* pthis) { + pthis->actionFunc = ObjLightswitch_DisappearDelay; + pthis->toggleDelay = 100; +} + +void ObjLightswitch_DisappearDelay(ObjLightswitch* pthis, GlobalContext* globalCtx) { + if (func_8005B198() == pthis->actor.category || pthis->toggleDelay <= 0) { + ObjLightswitch_SetupDisappear(pthis); + } +} + +void ObjLightswitch_SetupDisappear(ObjLightswitch* pthis) { + pthis->actionFunc = ObjLightswitch_Disappear; + pthis->alpha = 255 << 6; +} + +void ObjLightswitch_Disappear(ObjLightswitch* pthis, GlobalContext* globalCtx) { + pthis->alpha -= 200; + ObjLightswitch_SpawnDisappearEffects(pthis, globalCtx); + if (pthis->alpha < 0) { + Actor_Kill(&pthis->actor); + } +} + +void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx2) { + ObjLightswitch* pthis = (ObjLightswitch*)thisx; + GlobalContext* globalCtx = globalCtx2; + + if (pthis->toggleDelay > 0) { + pthis->toggleDelay--; + } + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->actor.update != NULL) { + if ((pthis->actor.params & 1) == 1) { + pthis->actor.world.pos.x = pthis->actor.child->world.pos.x; + pthis->actor.world.pos.y = pthis->actor.child->world.pos.y + 60.0f; + pthis->actor.world.pos.z = pthis->actor.child->world.pos.z; + Actor_SetFocus(&pthis->actor, 0.0f); + } + + pthis->prevFrameACflags = pthis->collider.base.acFlags; + pthis->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void ObjLightswitch_DrawOpa(ObjLightswitch* pthis, GlobalContext* globalCtx) { + Actor* child; + Vec3f pos; + Vec3s rot; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 809); + func_80093D18(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, (u8)(pthis->color[0] >> 6), (u8)(pthis->color[1] >> 6), (u8)(pthis->color[2] >> 6), + (u8)(pthis->alpha >> 6)); + gSPSegment(POLY_OPA_DISP++, 0x09, &D_80116280[2]); + + if ((pthis->actor.params & 1) == 1) { + child = pthis->actor.child; + pthis->actor.world.pos.x = child->world.pos.x; + pthis->actor.world.pos.y = child->world.pos.y + 60.0f; + pthis->actor.world.pos.z = child->world.pos.z; + Math_Vec3f_Copy(&pos, &pthis->actor.world.pos); + func_800D1694(pos.x, pos.y, pos.z, &pthis->actor.shape.rot); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + } else { + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + pthis->actor.shape.yOffset * pthis->actor.scale.y; + pos.z = pthis->actor.world.pos.z; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 841), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFaceTextures[pthis->faceTextureIndex])); + gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000260); + + rot.x = pthis->actor.shape.rot.x; + rot.y = pthis->actor.shape.rot.y; + rot.z = pthis->actor.shape.rot.z + pthis->flameRingRot; + func_800D1694(pos.x, pos.y, pos.z, &rot); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 859), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000398); + + rot.z = pthis->actor.shape.rot.z - pthis->flameRingRot; + func_800D1694(pos.x, pos.y, pos.z, &rot); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 873), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000408); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 878); +} + +void ObjLightswitch_DrawXlu(ObjLightswitch* pthis, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp68; + Vec3s sp60; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 890); + func_80093D84(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(pthis->color[0] >> 6), (u8)(pthis->color[1] >> 6), (u8)(pthis->color[2] >> 6), + (u8)(pthis->alpha >> 6)); + gSPSegment(POLY_XLU_DISP++, 0x09, D_80116280); + + sp68.x = pthis->actor.world.pos.x; + sp68.y = pthis->actor.world.pos.y + (pthis->actor.shape.yOffset * pthis->actor.scale.y); + sp68.z = pthis->actor.world.pos.z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 912), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFaceTextures[pthis->faceTextureIndex])); + gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000260); + + sp60.x = pthis->actor.shape.rot.x; + sp60.y = pthis->actor.shape.rot.y; + sp60.z = pthis->actor.shape.rot.z + pthis->flameRingRot; + + func_800D1694(sp68.x, sp68.y, sp68.z, &sp60); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 930), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000398); + + sp60.z = pthis->actor.shape.rot.z - pthis->flameRingRot; + func_800D1694(sp68.x, sp68.y, sp68.z, &sp60); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 944), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000408); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_lightswitch.c", 949); +} + +void ObjLightswitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjLightswitch* pthis = (ObjLightswitch*)thisx; + s32 alpha = pthis->alpha >> 6 & 0xFF; + + if ((pthis->actor.params & 1) == 1) { + Collider_UpdateSpheres(0, &pthis->collider); + } + + if ((pthis->actor.params >> 4 & 3) == OBJLIGHTSWITCH_TYPE_BURN && (alpha > 0 || alpha < 255)) { + ObjLightswitch_DrawXlu(pthis, globalCtx); + } else { + ObjLightswitch_DrawOpa(pthis, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.cpp similarity index 50% rename from src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c rename to src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.cpp index 7c22a5fd1..8624eccaa 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.cpp @@ -15,10 +15,10 @@ void ObjMakekinsuta_Init(Actor* thisx, GlobalContext* globalCtx); void ObjMakekinsuta_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80B98320(ObjMakekinsuta* this, GlobalContext* globalCtx); -void ObjMakekinsuta_DoNothing(ObjMakekinsuta* this, GlobalContext* globalCtx); +void func_80B98320(ObjMakekinsuta* pthis, GlobalContext* globalCtx); +void ObjMakekinsuta_DoNothing(ObjMakekinsuta* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Makekinsuta_InitVars = { +ActorInit Obj_Makekinsuta_InitVars = { ACTOR_OBJ_MAKEKINSUTA, ACTORCAT_ITEMACTION, FLAGS, @@ -31,41 +31,41 @@ const ActorInit Obj_Makekinsuta_InitVars = { }; void ObjMakekinsuta_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjMakekinsuta* this = (ObjMakekinsuta*)thisx; + ObjMakekinsuta* pthis = (ObjMakekinsuta*)thisx; - if ((this->actor.params & 0x6000) == 0x4000) { + if ((pthis->actor.params & 0x6000) == 0x4000) { osSyncPrintf(VT_FGCOL(BLUE)); // "Gold Star Enemy(arg_data %x)" - osSyncPrintf("金スタ発生敵(arg_data %x)\n", this->actor.params); + osSyncPrintf("金スタ発生敵(arg_data %x)\n", pthis->actor.params); osSyncPrintf(VT_RST); } else { osSyncPrintf(VT_COL(YELLOW, BLACK)); // "Invalid Argument (arg_data %x)(%s %d)" - osSyncPrintf("引数不正 (arg_data %x)(%s %d)\n", this->actor.params, "../z_obj_makekinsuta.c", 119); + osSyncPrintf("引数不正 (arg_data %x)(%s %d)\n", pthis->actor.params, "../z_obj_makekinsuta.c", 119); osSyncPrintf(VT_RST); } - this->actionFunc = func_80B98320; + pthis->actionFunc = func_80B98320; } -void func_80B98320(ObjMakekinsuta* this, GlobalContext* globalCtx) { - if (this->unk_152 != 0) { - if (this->timer >= 60 && !func_8002DEEC(GET_PLAYER(globalCtx))) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, (this->actor.params | 0x8000)); - this->actionFunc = ObjMakekinsuta_DoNothing; +void func_80B98320(ObjMakekinsuta* pthis, GlobalContext* globalCtx) { + if (pthis->unk_152 != 0) { + if (pthis->timer >= 60 && !func_8002DEEC(GET_PLAYER(globalCtx))) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, pthis->actor.shape.rot.y, 0, (pthis->actor.params | 0x8000)); + pthis->actionFunc = ObjMakekinsuta_DoNothing; } else { - this->timer++; + pthis->timer++; } } else { - this->timer = 0; + pthis->timer = 0; } } -void ObjMakekinsuta_DoNothing(ObjMakekinsuta* this, GlobalContext* globalCtx) { +void ObjMakekinsuta_DoNothing(ObjMakekinsuta* pthis, GlobalContext* globalCtx) { } void ObjMakekinsuta_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjMakekinsuta* this = (ObjMakekinsuta*)thisx; + ObjMakekinsuta* pthis = (ObjMakekinsuta*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp similarity index 98% rename from src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c rename to src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp index 7962e9b16..a9e8634a5 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp @@ -18,7 +18,7 @@ void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx); void ObjMakeoshihiki_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Obj_Makeoshihiki_InitVars = { +ActorInit Obj_Makeoshihiki_InitVars = { ACTOR_OBJ_MAKEOSHIHIKI, ACTORCAT_PROP, FLAGS, OBJECT_GAMEPLAY_DANGEON_KEEP, sizeof(ObjMakeoshihiki), (ActorFunc)ObjMakeoshihiki_Init, (ActorFunc)Actor_Noop, (ActorFunc)Actor_Noop, (ActorFunc)ObjMakeoshihiki_Draw, diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c deleted file mode 100644 index 83eead54a..000000000 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ /dev/null @@ -1,421 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_MURE_Z_OBJ_MURE_C -#include "actor_common.h" -/* - * File: z_obj_mure.c - * Overlay: ovl_Obj_Mure - * Description: Spawns Fish, Bug, Butterfly - */ - -#include "z_obj_mure.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx); - -void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx); -void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx); -void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx); - -s32 ObjMure_GetMaxChildSpawns(ObjMure* this); - -const ActorInit Obj_Mure_InitVars = { - ACTOR_OBJ_MURE, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ObjMure), - (ActorFunc)ObjMure_Init, - (ActorFunc)ObjMure_Destroy, - (ActorFunc)ObjMure_Update, - NULL, -}; - -typedef enum { - /* 0 */ OBJMURE_TYPE_GRASS, - /* 1 */ OBJMURE_TYPE_UNDEFINED, - /* 2 */ OBJMURE_TYPE_FISH, - /* 3 */ OBJMURE_TYPE_BUGS, - /* 4 */ OBJMURE_TYPE_BUTTERFLY -} ObjMureType; - -typedef enum { - /* 0 */ OBJMURE_CHILD_STATE_0, - /* 1 */ OBJMURE_CHILD_STATE_1, // Dead - /* 2 */ OBJMURE_CHILD_STATE_2 -} ObjMureChildState; - -static f32 sZClip[] = { 1600.0f, 1600.0f, 1000.0f, 1000.0f, 1000.0f }; - -static s32 sMaxChildSpawns[] = { 12, 9, 8, 0 }; - -static s16 sSpawnActorIds[] = { ACTOR_EN_KUSA, 0, ACTOR_EN_FISH, ACTOR_EN_INSECT, ACTOR_EN_BUTTE }; - -static s16 sSpawnParams[] = { 0, 2, -1, 0, -1 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), -}; - -s32 ObjMure_SetCullingImpl(Actor* thisx, GlobalContext* globalCtx) { - ObjMure* this = (ObjMure*)thisx; - s32 result; - - switch (this->type) { - case OBJMURE_TYPE_FISH: - case OBJMURE_TYPE_BUGS: - case OBJMURE_TYPE_BUTTERFLY: - Actor_ProcessInitChain(&this->actor, sInitChain); - result = true; - break; - default: - // "Error : Culling is not set.(%s %d)(arg_data 0x%04x)" - osSyncPrintf("Error : カリングの設定がされていません。(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 204, - this->actor.params); - return false; - } - return result; -} - -s32 ObjMure_SetCulling(Actor* thisx, GlobalContext* globalCtx) { - if (!ObjMure_SetCullingImpl(thisx, globalCtx)) { - return false; - } - return true; -} - -void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjMure* this = (ObjMure*)thisx; - - this->chNum = (thisx->params >> 0xC) & 0x0F; - this->ptn = (thisx->params >> 8) & 0x07; - this->svNum = (thisx->params >> 5) & 0x03; - this->type = thisx->params & 0x1F; - - if (this->ptn >= 4) { - osSyncPrintf("Error 群れな敵 (%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 237, thisx->params); - Actor_Kill(&this->actor); - return; - } else if (this->type >= 5) { - osSyncPrintf("Error 群れな敵 (%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 245, thisx->params); - Actor_Kill(&this->actor); - return; - } else if (!ObjMure_SetCulling(thisx, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - this->actionFunc = ObjMure_InitialAction; - osSyncPrintf("群れな敵 (arg_data 0x%04x)(chNum(%d) ptn(%d) svNum(%d) type(%d))\n", thisx->params, this->chNum, - this->ptn, this->svNum, this->type); - if (ObjMure_GetMaxChildSpawns(this) <= 0) { - osSyncPrintf("Warning : 個体数が設定されていません(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 268, - thisx->params); - } -} - -void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -s32 ObjMure_GetMaxChildSpawns(ObjMure* this) { - if (this->chNum == 0) { - return sMaxChildSpawns[this->ptn]; - } - return this->chNum; -} - -void ObjMure_GetSpawnPos(Vec3f* outPos, Vec3f* inPos, s32 ptn, s32 idx) { - if (ptn >= 4) { - osSyncPrintf("おかしなの (%s %d)\n", "../z_obj_mure.c", 307); - } - *outPos = *inPos; -} - -void ObjMure_SpawnActors0(ObjMure* this, GlobalContext* globalCtx) { - ActorContext* ac; - s32 i; - Vec3f pos; - s32 pad; - s32 maxChildren = ObjMure_GetMaxChildSpawns(this); - - for (i = 0; i < maxChildren; i++) { - if (this->children[i] != NULL) { - // "Error: I already have a child(%s %d)(arg_data 0x%04x)" - osSyncPrintf("Error : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 333, - this->actor.params); - } - switch (this->childrenStates[i]) { - case OBJMURE_CHILD_STATE_1: - break; - case OBJMURE_CHILD_STATE_2: - ac = &globalCtx->actorCtx; - ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); - this->children[i] = - Actor_Spawn(ac, globalCtx, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type]); - if (this->children[i] != NULL) { - this->children[i]->flags |= ACTOR_FLAG_11; - this->children[i]->room = this->actor.room; - } else { - osSyncPrintf("warning 発生失敗 (%s %d)\n", "../z_obj_mure.c", 359); - } - break; - default: - ac = &globalCtx->actorCtx; - ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); - this->children[i] = - Actor_Spawn(ac, globalCtx, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type]); - if (this->children[i] != NULL) { - this->children[i]->room = this->actor.room; - } else { - osSyncPrintf("warning 発生失敗 (%s %d)\n", "../z_obj_mure.c", 382); - } - break; - } - } -} - -void ObjMure_SpawnActors1(ObjMure* this, GlobalContext* globalCtx) { - ActorContext* ac = (ActorContext*)globalCtx; // fake match - Actor* actor = &this->actor; - Vec3f spawnPos; - s32 maxChildren = ObjMure_GetMaxChildSpawns(this); - s32 i; - - for (i = 0; i < maxChildren; i++) { - if (this->children[i] != NULL) { - osSyncPrintf("Error : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 407, actor->params); - } - ac = &globalCtx->actorCtx; - ObjMure_GetSpawnPos(&spawnPos, &actor->world.pos, this->ptn, i); - this->children[i] = Actor_Spawn(ac, globalCtx, sSpawnActorIds[this->type], spawnPos.x, spawnPos.y, spawnPos.z, - actor->world.rot.x, actor->world.rot.y, actor->world.rot.z, - (this->type == 4 && i == 0) ? 1 : sSpawnParams[this->type]); - if (this->children[i] != NULL) { - this->childrenStates[i] = OBJMURE_CHILD_STATE_0; - this->children[i]->room = actor->room; - } else { - this->childrenStates[i] = OBJMURE_CHILD_STATE_1; - osSyncPrintf("warning 発生失敗 (%s %d)\n", "../z_obj_mure.c", 438); - } - } -} - -void ObjMure_SpawnActors(ObjMure* this, GlobalContext* globalCtx) { - switch (this->svNum) { - case 0: - ObjMure_SpawnActors0(this, globalCtx); - break; - case 1: - ObjMure_SpawnActors1(this, globalCtx); - break; - } -} - -void ObjMure_KillActorsImpl(ObjMure* this, GlobalContext* globalCtx) { - s32 maxChildren = ObjMure_GetMaxChildSpawns(this); - s32 i; - - for (i = 0; i < maxChildren; i++) { - switch (this->childrenStates[i]) { - case OBJMURE_CHILD_STATE_1: - this->children[i] = NULL; - break; - case OBJMURE_CHILD_STATE_2: - if (this->children[i] != NULL) { - Actor_Kill(this->children[i]); - this->children[i] = NULL; - } - break; - default: - if (this->children[i] != NULL) { - if (Actor_HasParent(this->children[i], globalCtx)) { - this->children[i] = NULL; - } else { - Actor_Kill(this->children[i]); - this->children[i] = NULL; - } - } - break; - } - } -} - -void ObjMure_KillActors(ObjMure* this, GlobalContext* globalCtx) { - ObjMure_KillActorsImpl(this, globalCtx); -} - -void ObjMure_CheckChildren(ObjMure* this, GlobalContext* globalCtx) { - s32 maxChildren = ObjMure_GetMaxChildSpawns(this); - s32 i; - - for (i = 0; i < maxChildren; i++) { - if (this->children[i] != NULL) { - if (this->childrenStates[i] == OBJMURE_CHILD_STATE_0) { - if (this->children[i]->update != NULL) { - if (this->children[i]->flags & ACTOR_FLAG_11) { - this->childrenStates[i] = OBJMURE_CHILD_STATE_2; - } - } else { - this->childrenStates[i] = OBJMURE_CHILD_STATE_1; - this->children[i] = NULL; - } - } else if (this->childrenStates[i] == OBJMURE_CHILD_STATE_2 && this->children[i]->update == NULL) { - this->childrenStates[i] = OBJMURE_CHILD_STATE_1; - this->children[i] = NULL; - } - } - } -} - -void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx) { - this->actionFunc = ObjMure_CulledState; -} - -void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx) { - if (fabsf(this->actor.projectedPos.z) < sZClip[this->type]) { - this->actionFunc = ObjMure_ActiveState; - this->actor.flags |= ACTOR_FLAG_4; - ObjMure_SpawnActors(this, globalCtx); - } -} - -void ObjMure_SetFollowTargets(ObjMure* this, f32 randMax) { - s32 index; - s32 maxChildren = ObjMure_GetMaxChildSpawns(this); - s32 i; - - for (i = 0; i < maxChildren; i++) { - if (this->children[i] != NULL) { - this->children[i]->child = NULL; - if (Rand_ZeroOne() <= randMax) { - index = Rand_ZeroOne() * (maxChildren - 0.5f); - if (i != index) { - this->children[i]->child = this->children[index]; - } - } - } - } -} - -/** - * Selects a child that will follow after the player - * `idx1` is the index + 1 of the child that will follow the player. If `idx1` is zero, no actor will follow the player - */ -void ObjMure_SetChildToFollowPlayer(ObjMure* this, s32 idx1) { - s32 maxChildren = ObjMure_GetMaxChildSpawns(this); - s32 i; - s32 i2; - s32 j; - - for (i = 0, i2 = 0; i < maxChildren; i++) { - if (this->children[i] != NULL) { - if (i2 < idx1) { - i2++; - this->children[i]->child = this->children[i]; - for (j = 0; j < maxChildren; j++) { - if (i != j && this->children[j]->child == this->children[i]) { - this->children[j]->child = NULL; - } - } - } else if (this->children[i]->child == this->children[i]) { - this->children[i]->child = NULL; - } - } - } -} - -// Fish, Bugs -void ObjMure_GroupBehavior0(ObjMure* this, GlobalContext* globalCtx) { - if (this->unk_1A4 <= 0) { - if (this->unk_1A6) { - this->unk_1A6 = false; - ObjMure_SetFollowTargets(this, (Rand_ZeroOne() * 0.5f) + 0.1f); - if (this->actor.xzDistToPlayer < 60.0f) { - this->unk_1A4 = (s16)(Rand_ZeroOne() * 5.5f) + 4; - } else { - this->unk_1A4 = (s16)(Rand_ZeroOne() * 40.5f) + 4; - } - } else { - this->unk_1A6 = true; - if (this->actor.xzDistToPlayer < 60.0f) { - this->unk_1A4 = (s16)(Rand_ZeroOne() * 10.5f) + 4; - ObjMure_SetFollowTargets(this, (Rand_ZeroOne() * 0.2f) + 0.8f); - } else { - this->unk_1A4 = (s16)(Rand_ZeroOne() * 10.5f) + 4; - ObjMure_SetFollowTargets(this, (Rand_ZeroOne() * 0.2f) + 0.6f); - } - } - } - if (this->actor.xzDistToPlayer < 120.0f) { - this->unk_1A8++; - } else { - this->unk_1A8 = 0; - } - if (this->unk_1A8 >= 80) { - ObjMure_SetChildToFollowPlayer(this, 1); - } else { - ObjMure_SetChildToFollowPlayer(this, 0); - } -} - -// Butterflies -void ObjMure_GroupBehavior1(ObjMure* this, GlobalContext* globalCtx) { - s32 maxChildren; - s32 i; - - if (this->unk_1A4 <= 0) { - if (this->unk_1A6) { - this->unk_1A6 = false; - ObjMure_SetFollowTargets(this, Rand_ZeroOne() * 0.2f); - if (this->actor.xzDistToPlayer < 60.0f) { - this->unk_1A4 = (s16)(Rand_ZeroOne() * 5.5f) + 4; - } else { - this->unk_1A4 = (s16)(Rand_ZeroOne() * 40.5f) + 4; - } - } else { - this->unk_1A6 = true; - ObjMure_SetFollowTargets(this, Rand_ZeroOne() * 0.7f); - this->unk_1A4 = (s16)(Rand_ZeroOne() * 10.5f) + 4; - } - } - - maxChildren = ObjMure_GetMaxChildSpawns(this); - for (i = 0; i < maxChildren; i++) { - if (this->children[i] != NULL) { - if (this->children[i]->child != NULL && this->children[i]->child->update == NULL) { - this->children[i]->child = NULL; - } - } - } -} - -static ObjMureActionFunc sTypeGroupBehaviorFunc[] = { - NULL, NULL, ObjMure_GroupBehavior0, ObjMure_GroupBehavior0, ObjMure_GroupBehavior1, -}; - -void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx) { - ObjMure_CheckChildren(this, globalCtx); - if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z)) { - this->actionFunc = ObjMure_CulledState; - this->actor.flags &= ~ACTOR_FLAG_4; - ObjMure_KillActors(this, globalCtx); - } else if (sTypeGroupBehaviorFunc[this->type] != NULL) { - sTypeGroupBehaviorFunc[this->type](this, globalCtx); - } -} - -void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjMure* this = (ObjMure*)thisx; - - if (this->unk_1A4 > 0) { - this->unk_1A4--; - } - this->actionFunc(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.cpp b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.cpp new file mode 100644 index 000000000..5eea3856e --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.cpp @@ -0,0 +1,421 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_MURE_Z_OBJ_MURE_C +#include "actor_common.h" +/* + * File: z_obj_mure.c + * Overlay: ovl_Obj_Mure + * Description: Spawns Fish, Bug, Butterfly + */ + +#include "z_obj_mure.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx); + +void ObjMure_InitialAction(ObjMure* pthis, GlobalContext* globalCtx); +void ObjMure_CulledState(ObjMure* pthis, GlobalContext* globalCtx); +void ObjMure_ActiveState(ObjMure* pthis, GlobalContext* globalCtx); + +s32 ObjMure_GetMaxChildSpawns(ObjMure* pthis); + +ActorInit Obj_Mure_InitVars = { + ACTOR_OBJ_MURE, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ObjMure), + (ActorFunc)ObjMure_Init, + (ActorFunc)ObjMure_Destroy, + (ActorFunc)ObjMure_Update, + NULL, +}; + +typedef enum { + /* 0 */ OBJMURE_TYPE_GRASS, + /* 1 */ OBJMURE_TYPE_UNDEFINED, + /* 2 */ OBJMURE_TYPE_FISH, + /* 3 */ OBJMURE_TYPE_BUGS, + /* 4 */ OBJMURE_TYPE_BUTTERFLY +} ObjMureType; + +typedef enum { + /* 0 */ OBJMURE_CHILD_STATE_0, + /* 1 */ OBJMURE_CHILD_STATE_1, // Dead + /* 2 */ OBJMURE_CHILD_STATE_2 +} ObjMureChildState; + +static f32 sZClip[] = { 1600.0f, 1600.0f, 1000.0f, 1000.0f, 1000.0f }; + +static s32 sMaxChildSpawns[] = { 12, 9, 8, 0 }; + +static s16 sSpawnActorIds[] = { ACTOR_EN_KUSA, 0, ACTOR_EN_FISH, ACTOR_EN_INSECT, ACTOR_EN_BUTTE }; + +static s16 sSpawnParams[] = { 0, 2, -1, 0, -1 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), +}; + +s32 ObjMure_SetCullingImpl(Actor* thisx, GlobalContext* globalCtx) { + ObjMure* pthis = (ObjMure*)thisx; + s32 result; + + switch (pthis->type) { + case OBJMURE_TYPE_FISH: + case OBJMURE_TYPE_BUGS: + case OBJMURE_TYPE_BUTTERFLY: + Actor_ProcessInitChain(&pthis->actor, sInitChain); + result = true; + break; + default: + // "Error : Culling is not set.(%s %d)(arg_data 0x%04x)" + osSyncPrintf("Error : カリングの設定がされていません。(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 204, + pthis->actor.params); + return false; + } + return result; +} + +s32 ObjMure_SetCulling(Actor* thisx, GlobalContext* globalCtx) { + if (!ObjMure_SetCullingImpl(thisx, globalCtx)) { + return false; + } + return true; +} + +void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjMure* pthis = (ObjMure*)thisx; + + pthis->chNum = (thisx->params >> 0xC) & 0x0F; + pthis->ptn = (thisx->params >> 8) & 0x07; + pthis->svNum = (thisx->params >> 5) & 0x03; + pthis->type = thisx->params & 0x1F; + + if (pthis->ptn >= 4) { + osSyncPrintf("Error 群れな敵 (%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 237, thisx->params); + Actor_Kill(&pthis->actor); + return; + } else if (pthis->type >= 5) { + osSyncPrintf("Error 群れな敵 (%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 245, thisx->params); + Actor_Kill(&pthis->actor); + return; + } else if (!ObjMure_SetCulling(thisx, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + pthis->actionFunc = ObjMure_InitialAction; + osSyncPrintf("群れな敵 (arg_data 0x%04x)(chNum(%d) ptn(%d) svNum(%d) type(%d))\n", thisx->params, pthis->chNum, + pthis->ptn, pthis->svNum, pthis->type); + if (ObjMure_GetMaxChildSpawns(pthis) <= 0) { + osSyncPrintf("Warning : 個体数が設定されていません(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 268, + thisx->params); + } +} + +void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 ObjMure_GetMaxChildSpawns(ObjMure* pthis) { + if (pthis->chNum == 0) { + return sMaxChildSpawns[pthis->ptn]; + } + return pthis->chNum; +} + +void ObjMure_GetSpawnPos(Vec3f* outPos, Vec3f* inPos, s32 ptn, s32 idx) { + if (ptn >= 4) { + osSyncPrintf("おかしなの (%s %d)\n", "../z_obj_mure.c", 307); + } + *outPos = *inPos; +} + +void ObjMure_SpawnActors0(ObjMure* pthis, GlobalContext* globalCtx) { + ActorContext* ac; + s32 i; + Vec3f pos; + s32 pad; + s32 maxChildren = ObjMure_GetMaxChildSpawns(pthis); + + for (i = 0; i < maxChildren; i++) { + if (pthis->children[i] != NULL) { + // "Error: I already have a child(%s %d)(arg_data 0x%04x)" + osSyncPrintf("Error : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 333, + pthis->actor.params); + } + switch (pthis->childrenStates[i]) { + case OBJMURE_CHILD_STATE_1: + break; + case OBJMURE_CHILD_STATE_2: + ac = &globalCtx->actorCtx; + ObjMure_GetSpawnPos(&pos, &pthis->actor.world.pos, pthis->ptn, i); + pthis->children[i] = + Actor_Spawn(ac, globalCtx, sSpawnActorIds[pthis->type], pos.x, pos.y, pos.z, pthis->actor.world.rot.x, + pthis->actor.world.rot.y, pthis->actor.world.rot.z, sSpawnParams[pthis->type]); + if (pthis->children[i] != NULL) { + pthis->children[i]->flags |= ACTOR_FLAG_11; + pthis->children[i]->room = pthis->actor.room; + } else { + osSyncPrintf("warning 発生失敗 (%s %d)\n", "../z_obj_mure.c", 359); + } + break; + default: + ac = &globalCtx->actorCtx; + ObjMure_GetSpawnPos(&pos, &pthis->actor.world.pos, pthis->ptn, i); + pthis->children[i] = + Actor_Spawn(ac, globalCtx, sSpawnActorIds[pthis->type], pos.x, pos.y, pos.z, pthis->actor.world.rot.x, + pthis->actor.world.rot.y, pthis->actor.world.rot.z, sSpawnParams[pthis->type]); + if (pthis->children[i] != NULL) { + pthis->children[i]->room = pthis->actor.room; + } else { + osSyncPrintf("warning 発生失敗 (%s %d)\n", "../z_obj_mure.c", 382); + } + break; + } + } +} + +void ObjMure_SpawnActors1(ObjMure* pthis, GlobalContext* globalCtx) { + ActorContext* ac = (ActorContext*)globalCtx; // fake match + Actor* actor = &pthis->actor; + Vec3f spawnPos; + s32 maxChildren = ObjMure_GetMaxChildSpawns(pthis); + s32 i; + + for (i = 0; i < maxChildren; i++) { + if (pthis->children[i] != NULL) { + osSyncPrintf("Error : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure.c", 407, actor->params); + } + ac = &globalCtx->actorCtx; + ObjMure_GetSpawnPos(&spawnPos, &actor->world.pos, pthis->ptn, i); + pthis->children[i] = Actor_Spawn(ac, globalCtx, sSpawnActorIds[pthis->type], spawnPos.x, spawnPos.y, spawnPos.z, + actor->world.rot.x, actor->world.rot.y, actor->world.rot.z, + (pthis->type == 4 && i == 0) ? 1 : sSpawnParams[pthis->type]); + if (pthis->children[i] != NULL) { + pthis->childrenStates[i] = OBJMURE_CHILD_STATE_0; + pthis->children[i]->room = actor->room; + } else { + pthis->childrenStates[i] = OBJMURE_CHILD_STATE_1; + osSyncPrintf("warning 発生失敗 (%s %d)\n", "../z_obj_mure.c", 438); + } + } +} + +void ObjMure_SpawnActors(ObjMure* pthis, GlobalContext* globalCtx) { + switch (pthis->svNum) { + case 0: + ObjMure_SpawnActors0(pthis, globalCtx); + break; + case 1: + ObjMure_SpawnActors1(pthis, globalCtx); + break; + } +} + +void ObjMure_KillActorsImpl(ObjMure* pthis, GlobalContext* globalCtx) { + s32 maxChildren = ObjMure_GetMaxChildSpawns(pthis); + s32 i; + + for (i = 0; i < maxChildren; i++) { + switch (pthis->childrenStates[i]) { + case OBJMURE_CHILD_STATE_1: + pthis->children[i] = NULL; + break; + case OBJMURE_CHILD_STATE_2: + if (pthis->children[i] != NULL) { + Actor_Kill(pthis->children[i]); + pthis->children[i] = NULL; + } + break; + default: + if (pthis->children[i] != NULL) { + if (Actor_HasParent(pthis->children[i], globalCtx)) { + pthis->children[i] = NULL; + } else { + Actor_Kill(pthis->children[i]); + pthis->children[i] = NULL; + } + } + break; + } + } +} + +void ObjMure_KillActors(ObjMure* pthis, GlobalContext* globalCtx) { + ObjMure_KillActorsImpl(pthis, globalCtx); +} + +void ObjMure_CheckChildren(ObjMure* pthis, GlobalContext* globalCtx) { + s32 maxChildren = ObjMure_GetMaxChildSpawns(pthis); + s32 i; + + for (i = 0; i < maxChildren; i++) { + if (pthis->children[i] != NULL) { + if (pthis->childrenStates[i] == OBJMURE_CHILD_STATE_0) { + if (pthis->children[i]->update != NULL) { + if (pthis->children[i]->flags & ACTOR_FLAG_11) { + pthis->childrenStates[i] = OBJMURE_CHILD_STATE_2; + } + } else { + pthis->childrenStates[i] = OBJMURE_CHILD_STATE_1; + pthis->children[i] = NULL; + } + } else if (pthis->childrenStates[i] == OBJMURE_CHILD_STATE_2 && pthis->children[i]->update == NULL) { + pthis->childrenStates[i] = OBJMURE_CHILD_STATE_1; + pthis->children[i] = NULL; + } + } + } +} + +void ObjMure_InitialAction(ObjMure* pthis, GlobalContext* globalCtx) { + pthis->actionFunc = ObjMure_CulledState; +} + +void ObjMure_CulledState(ObjMure* pthis, GlobalContext* globalCtx) { + if (fabsf(pthis->actor.projectedPos.z) < sZClip[pthis->type]) { + pthis->actionFunc = ObjMure_ActiveState; + pthis->actor.flags |= ACTOR_FLAG_4; + ObjMure_SpawnActors(pthis, globalCtx); + } +} + +void ObjMure_SetFollowTargets(ObjMure* pthis, f32 randMax) { + s32 index; + s32 maxChildren = ObjMure_GetMaxChildSpawns(pthis); + s32 i; + + for (i = 0; i < maxChildren; i++) { + if (pthis->children[i] != NULL) { + pthis->children[i]->child = NULL; + if (Rand_ZeroOne() <= randMax) { + index = Rand_ZeroOne() * (maxChildren - 0.5f); + if (i != index) { + pthis->children[i]->child = pthis->children[index]; + } + } + } + } +} + +/** + * Selects a child that will follow after the player + * `idx1` is the index + 1 of the child that will follow the player. If `idx1` is zero, no actor will follow the player + */ +void ObjMure_SetChildToFollowPlayer(ObjMure* pthis, s32 idx1) { + s32 maxChildren = ObjMure_GetMaxChildSpawns(pthis); + s32 i; + s32 i2; + s32 j; + + for (i = 0, i2 = 0; i < maxChildren; i++) { + if (pthis->children[i] != NULL) { + if (i2 < idx1) { + i2++; + pthis->children[i]->child = pthis->children[i]; + for (j = 0; j < maxChildren; j++) { + if (i != j && pthis->children[j]->child == pthis->children[i]) { + pthis->children[j]->child = NULL; + } + } + } else if (pthis->children[i]->child == pthis->children[i]) { + pthis->children[i]->child = NULL; + } + } + } +} + +// Fish, Bugs +void ObjMure_GroupBehavior0(ObjMure* pthis, GlobalContext* globalCtx) { + if (pthis->unk_1A4 <= 0) { + if (pthis->unk_1A6) { + pthis->unk_1A6 = false; + ObjMure_SetFollowTargets(pthis, (Rand_ZeroOne() * 0.5f) + 0.1f); + if (pthis->actor.xzDistToPlayer < 60.0f) { + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 5.5f) + 4; + } else { + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 40.5f) + 4; + } + } else { + pthis->unk_1A6 = true; + if (pthis->actor.xzDistToPlayer < 60.0f) { + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 10.5f) + 4; + ObjMure_SetFollowTargets(pthis, (Rand_ZeroOne() * 0.2f) + 0.8f); + } else { + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 10.5f) + 4; + ObjMure_SetFollowTargets(pthis, (Rand_ZeroOne() * 0.2f) + 0.6f); + } + } + } + if (pthis->actor.xzDistToPlayer < 120.0f) { + pthis->unk_1A8++; + } else { + pthis->unk_1A8 = 0; + } + if (pthis->unk_1A8 >= 80) { + ObjMure_SetChildToFollowPlayer(pthis, 1); + } else { + ObjMure_SetChildToFollowPlayer(pthis, 0); + } +} + +// Butterflies +void ObjMure_GroupBehavior1(ObjMure* pthis, GlobalContext* globalCtx) { + s32 maxChildren; + s32 i; + + if (pthis->unk_1A4 <= 0) { + if (pthis->unk_1A6) { + pthis->unk_1A6 = false; + ObjMure_SetFollowTargets(pthis, Rand_ZeroOne() * 0.2f); + if (pthis->actor.xzDistToPlayer < 60.0f) { + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 5.5f) + 4; + } else { + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 40.5f) + 4; + } + } else { + pthis->unk_1A6 = true; + ObjMure_SetFollowTargets(pthis, Rand_ZeroOne() * 0.7f); + pthis->unk_1A4 = (s16)(Rand_ZeroOne() * 10.5f) + 4; + } + } + + maxChildren = ObjMure_GetMaxChildSpawns(pthis); + for (i = 0; i < maxChildren; i++) { + if (pthis->children[i] != NULL) { + if (pthis->children[i]->child != NULL && pthis->children[i]->child->update == NULL) { + pthis->children[i]->child = NULL; + } + } + } +} + +static ObjMureActionFunc sTypeGroupBehaviorFunc[] = { + NULL, NULL, ObjMure_GroupBehavior0, ObjMure_GroupBehavior0, ObjMure_GroupBehavior1, +}; + +void ObjMure_ActiveState(ObjMure* pthis, GlobalContext* globalCtx) { + ObjMure_CheckChildren(pthis, globalCtx); + if (sZClip[pthis->type] + 40.0f <= fabsf(pthis->actor.projectedPos.z)) { + pthis->actionFunc = ObjMure_CulledState; + pthis->actor.flags &= ~ACTOR_FLAG_4; + ObjMure_KillActors(pthis, globalCtx); + } else if (sTypeGroupBehaviorFunc[pthis->type] != NULL) { + sTypeGroupBehaviorFunc[pthis->type](pthis, globalCtx); + } +} + +void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjMure* pthis = (ObjMure*)thisx; + + if (pthis->unk_1A4 > 0) { + pthis->unk_1A4--; + } + pthis->actionFunc(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c deleted file mode 100644 index 7ba112017..000000000 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ /dev/null @@ -1,227 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_MURE2_Z_OBJ_MURE2_C -#include "actor_common.h" -/* - * File: z_obj_mure2.c - * Overlay: ovl_Obj_Mure2 - * Description: Rock/Bush groups - */ - -#include "z_obj_mure2.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -typedef void (*ObjMure2SetPosFunc)(Vec3f* vec, ObjMure2* this); - -typedef struct { - s16 radius; - s16 angle; -} Mure2sScatteredShrubInfo; - -void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx); - -void ObjMure2_SetPosShrubCircle(Vec3f* vec, ObjMure2* this); -void ObjMure2_SetPosShrubScattered(Vec3f* vec, ObjMure2* this); -void ObjMure2_SetPosRockCircle(Vec3f* vec, ObjMure2* this); -void ObjMure2_Wait(ObjMure2* this, GlobalContext* globalCtx); -void func_80B9A668(ObjMure2* this, GlobalContext* globalCtx); -void func_80B9A6F8(ObjMure2* this, GlobalContext* globalCtx); -void ObjMure2_SetupWait(ObjMure2* this); -void func_80B9A658(ObjMure2* this); -void func_80B9A6E8(ObjMure2* this); - -const ActorInit Obj_Mure2_InitVars = { - ACTOR_OBJ_MURE2, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ObjMure2), - (ActorFunc)ObjMure2_Init, - (ActorFunc)Actor_Noop, - (ActorFunc)ObjMure2_Update, - NULL, -}; - -static f32 sDistSquared1[] = { SQ(1600.0f), SQ(1600.0f), SQ(1600.0f) }; - -static f32 sDistSquared2[] = { SQ(1705.0f), SQ(1705.0f), SQ(1705.0f) }; - -static s16 D_80B9A818[] = { 9, 12, 8 }; - -static s16 sActorSpawnIDs[] = { ACTOR_EN_KUSA, ACTOR_EN_KUSA, ACTOR_EN_ISHI }; - -void ObjMure2_SetPosShrubCircle(Vec3f* vec, ObjMure2* this) { - s32 i; - - Math_Vec3f_Copy(vec, &this->actor.world.pos); - for (i = 1; i < D_80B9A818[this->actor.params & 3]; i++) { - Math_Vec3f_Copy(vec + i, &this->actor.world.pos); - (vec + i)->x += (80.0f * Math_SinS((i - 1) * 0x2000)); - (vec + i)->z += (80.0f * Math_CosS((i - 1) * 0x2000)); - } -} - -static Mure2sScatteredShrubInfo sScatteredShrubInfo[] = { - { 40, 0x0666 }, { 40, 0x2CCC }, { 40, 0x5999 }, { 40, 0x8666 }, { 20, 0xC000 }, { 80, 0x1333 }, - { 80, 0x4000 }, { 80, 0x6CCC }, { 80, 0x9333 }, { 80, 0xACCC }, { 80, 0xC666 }, { 60, 0xE000 }, -}; - -void ObjMure2_SetPosShrubScattered(Vec3f* vec, ObjMure2* this) { - s32 i; - - for (i = 0; i < D_80B9A818[this->actor.params & 3]; i++) { - Math_Vec3f_Copy(vec + i, &this->actor.world.pos); - (vec + i)->x += (sScatteredShrubInfo[i].radius * Math_CosS(sScatteredShrubInfo[i].angle)); - (vec + i)->z -= (sScatteredShrubInfo[i].radius * Math_SinS(sScatteredShrubInfo[i].angle)); - } -} - -void ObjMure2_SetPosRockCircle(Vec3f* vec, ObjMure2* this) { - s32 i; - - for (i = 0; i < D_80B9A818[this->actor.params & 3]; i++) { - Math_Vec3f_Copy(vec + i, &this->actor.world.pos); - (vec + i)->x += (80.0f * Math_SinS(i * 0x2000)); - (vec + i)->z += (80.0f * Math_CosS(i * 0x2000)); - } -} - -void ObjMure2_SetActorSpawnParams(s16* params, ObjMure2* this) { - static s16 actorSpawnParams[] = { 0, 0, 0 }; - s16 dropTable = (this->actor.params >> 8) & 0xF; - - if (dropTable >= 13) { - dropTable = 0; - } - *params = actorSpawnParams[this->actor.params & 3] & 0xF0FF; - *params |= (dropTable << 8); -} - -void ObjMure2_SpawnActors(ObjMure2* this, GlobalContext* globalCtx) { - static ObjMure2SetPosFunc setPosFunc[] = { - ObjMure2_SetPosShrubCircle, - ObjMure2_SetPosShrubScattered, - ObjMure2_SetPosRockCircle, - }; - s32 actorNum = this->actor.params & 3; - s32 i; - Vec3f spawnPos[12]; - s16 params; - - setPosFunc[actorNum](spawnPos, this); - ObjMure2_SetActorSpawnParams(¶ms, this); - - for (i = 0; i < D_80B9A818[actorNum]; i++) { - if (this->actorSpawnPtrList[i] != NULL) { - // "Warning : I already have a child (%s %d)(arg_data 0x%04x)" - osSyncPrintf("Warning : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure2.c", 269, - this->actor.params); - continue; - } - - if (((this->currentActorNum >> i) & 1) == 0) { - this->actorSpawnPtrList[i] = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, sActorSpawnIDs[actorNum], spawnPos[i].x, spawnPos[i].y, - spawnPos[i].z, this->actor.world.rot.x, 0, this->actor.world.rot.z, params); - if (this->actorSpawnPtrList[i] != NULL) { - this->actorSpawnPtrList[i]->room = this->actor.room; - } - } - } -} - -void ObjMure2_CleanupAndDie(ObjMure2* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < D_80B9A818[this->actor.params & 3]; i++) { - if (((this->currentActorNum >> i) & 1) == 0) { - if (this->actorSpawnPtrList[i] != NULL) { - if (Actor_HasParent(this->actorSpawnPtrList[i], globalCtx)) { - this->currentActorNum |= (1 << i); - } else { - Actor_Kill(this->actorSpawnPtrList[i]); - } - this->actorSpawnPtrList[i] = NULL; - } - } else { - this->actorSpawnPtrList[i] = NULL; - } - } -} - -void func_80B9A534(ObjMure2* this) { - s32 i; - - for (i = 0; i < D_80B9A818[this->actor.params & 3]; i++) { - if (this->actorSpawnPtrList[i] != NULL && (((this->currentActorNum >> i) & 1) == 0) && - (this->actorSpawnPtrList[i]->update == NULL)) { - this->currentActorNum |= (1 << i); - this->actorSpawnPtrList[i] = NULL; - } - } -} - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 2100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), -}; - -void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjMure2* this = (ObjMure2*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - if (globalCtx->csCtx.state != CS_STATE_IDLE) { - this->actor.uncullZoneForward += 1200.0f; - } - ObjMure2_SetupWait(this); -} - -void ObjMure2_SetupWait(ObjMure2* this) { - this->actionFunc = ObjMure2_Wait; -} - -void ObjMure2_Wait(ObjMure2* this, GlobalContext* globalCtx) { - func_80B9A658(this); -} - -void func_80B9A658(ObjMure2* this) { - this->actionFunc = func_80B9A668; -} - -void func_80B9A668(ObjMure2* this, GlobalContext* globalCtx) { - if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) < - (sDistSquared1[this->actor.params & 3] * this->unk_184)) { - this->actor.flags |= ACTOR_FLAG_4; - ObjMure2_SpawnActors(this, globalCtx); - func_80B9A6E8(this); - } -} - -void func_80B9A6E8(ObjMure2* this) { - this->actionFunc = func_80B9A6F8; -} - -void func_80B9A6F8(ObjMure2* this, GlobalContext* globalCtx) { - func_80B9A534(this); - if ((sDistSquared2[this->actor.params & 3] * this->unk_184) <= - Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z)) { - this->actor.flags &= ~ACTOR_FLAG_4; - ObjMure2_CleanupAndDie(this, globalCtx); - func_80B9A658(this); - } -} - -void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjMure2* this = (ObjMure2*)thisx; - - if (globalCtx->csCtx.state == CS_STATE_IDLE) { - this->unk_184 = 1.0f; - } else { - this->unk_184 = 4.0f; - } - this->actionFunc(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.cpp b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.cpp new file mode 100644 index 000000000..6efcc816e --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.cpp @@ -0,0 +1,227 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_MURE2_Z_OBJ_MURE2_C +#include "actor_common.h" +/* + * File: z_obj_mure2.c + * Overlay: ovl_Obj_Mure2 + * Description: Rock/Bush groups + */ + +#include "z_obj_mure2.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +typedef void (*ObjMure2SetPosFunc)(Vec3f* vec, ObjMure2* pthis); + +typedef struct { + s16 radius; + s16 angle; +} Mure2sScatteredShrubInfo; + +void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx); + +void ObjMure2_SetPosShrubCircle(Vec3f* vec, ObjMure2* pthis); +void ObjMure2_SetPosShrubScattered(Vec3f* vec, ObjMure2* pthis); +void ObjMure2_SetPosRockCircle(Vec3f* vec, ObjMure2* pthis); +void ObjMure2_Wait(ObjMure2* pthis, GlobalContext* globalCtx); +void func_80B9A668(ObjMure2* pthis, GlobalContext* globalCtx); +void func_80B9A6F8(ObjMure2* pthis, GlobalContext* globalCtx); +void ObjMure2_SetupWait(ObjMure2* pthis); +void func_80B9A658(ObjMure2* pthis); +void func_80B9A6E8(ObjMure2* pthis); + +ActorInit Obj_Mure2_InitVars = { + ACTOR_OBJ_MURE2, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ObjMure2), + (ActorFunc)ObjMure2_Init, + (ActorFunc)Actor_Noop, + (ActorFunc)ObjMure2_Update, + NULL, +}; + +static f32 sDistSquared1[] = { SQ(1600.0f), SQ(1600.0f), SQ(1600.0f) }; + +static f32 sDistSquared2[] = { SQ(1705.0f), SQ(1705.0f), SQ(1705.0f) }; + +static s16 D_80B9A818[] = { 9, 12, 8 }; + +static s16 sActorSpawnIDs[] = { ACTOR_EN_KUSA, ACTOR_EN_KUSA, ACTOR_EN_ISHI }; + +void ObjMure2_SetPosShrubCircle(Vec3f* vec, ObjMure2* pthis) { + s32 i; + + Math_Vec3f_Copy(vec, &pthis->actor.world.pos); + for (i = 1; i < D_80B9A818[pthis->actor.params & 3]; i++) { + Math_Vec3f_Copy(vec + i, &pthis->actor.world.pos); + (vec + i)->x += (80.0f * Math_SinS((i - 1) * 0x2000)); + (vec + i)->z += (80.0f * Math_CosS((i - 1) * 0x2000)); + } +} + +static Mure2sScatteredShrubInfo sScatteredShrubInfo[] = { + { 40, 0x0666 }, { 40, 0x2CCC }, { 40, 0x5999 }, { 40, 0x8666 }, { 20, 0xC000 }, { 80, 0x1333 }, + { 80, 0x4000 }, { 80, 0x6CCC }, { 80, 0x9333 }, { 80, 0xACCC }, { 80, 0xC666 }, { 60, 0xE000 }, +}; + +void ObjMure2_SetPosShrubScattered(Vec3f* vec, ObjMure2* pthis) { + s32 i; + + for (i = 0; i < D_80B9A818[pthis->actor.params & 3]; i++) { + Math_Vec3f_Copy(vec + i, &pthis->actor.world.pos); + (vec + i)->x += (sScatteredShrubInfo[i].radius * Math_CosS(sScatteredShrubInfo[i].angle)); + (vec + i)->z -= (sScatteredShrubInfo[i].radius * Math_SinS(sScatteredShrubInfo[i].angle)); + } +} + +void ObjMure2_SetPosRockCircle(Vec3f* vec, ObjMure2* pthis) { + s32 i; + + for (i = 0; i < D_80B9A818[pthis->actor.params & 3]; i++) { + Math_Vec3f_Copy(vec + i, &pthis->actor.world.pos); + (vec + i)->x += (80.0f * Math_SinS(i * 0x2000)); + (vec + i)->z += (80.0f * Math_CosS(i * 0x2000)); + } +} + +void ObjMure2_SetActorSpawnParams(s16* params, ObjMure2* pthis) { + static s16 actorSpawnParams[] = { 0, 0, 0 }; + s16 dropTable = (pthis->actor.params >> 8) & 0xF; + + if (dropTable >= 13) { + dropTable = 0; + } + *params = actorSpawnParams[pthis->actor.params & 3] & 0xF0FF; + *params |= (dropTable << 8); +} + +void ObjMure2_SpawnActors(ObjMure2* pthis, GlobalContext* globalCtx) { + static ObjMure2SetPosFunc setPosFunc[] = { + ObjMure2_SetPosShrubCircle, + ObjMure2_SetPosShrubScattered, + ObjMure2_SetPosRockCircle, + }; + s32 actorNum = pthis->actor.params & 3; + s32 i; + Vec3f spawnPos[12]; + s16 params; + + setPosFunc[actorNum](spawnPos, pthis); + ObjMure2_SetActorSpawnParams(¶ms, pthis); + + for (i = 0; i < D_80B9A818[actorNum]; i++) { + if (pthis->actorSpawnPtrList[i] != NULL) { + // "Warning : I already have a child (%s %d)(arg_data 0x%04x)" + osSyncPrintf("Warning : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure2.c", 269, + pthis->actor.params); + continue; + } + + if (((pthis->currentActorNum >> i) & 1) == 0) { + pthis->actorSpawnPtrList[i] = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, sActorSpawnIDs[actorNum], spawnPos[i].x, spawnPos[i].y, + spawnPos[i].z, pthis->actor.world.rot.x, 0, pthis->actor.world.rot.z, params); + if (pthis->actorSpawnPtrList[i] != NULL) { + pthis->actorSpawnPtrList[i]->room = pthis->actor.room; + } + } + } +} + +void ObjMure2_CleanupAndDie(ObjMure2* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < D_80B9A818[pthis->actor.params & 3]; i++) { + if (((pthis->currentActorNum >> i) & 1) == 0) { + if (pthis->actorSpawnPtrList[i] != NULL) { + if (Actor_HasParent(pthis->actorSpawnPtrList[i], globalCtx)) { + pthis->currentActorNum |= (1 << i); + } else { + Actor_Kill(pthis->actorSpawnPtrList[i]); + } + pthis->actorSpawnPtrList[i] = NULL; + } + } else { + pthis->actorSpawnPtrList[i] = NULL; + } + } +} + +void func_80B9A534(ObjMure2* pthis) { + s32 i; + + for (i = 0; i < D_80B9A818[pthis->actor.params & 3]; i++) { + if (pthis->actorSpawnPtrList[i] != NULL && (((pthis->currentActorNum >> i) & 1) == 0) && + (pthis->actorSpawnPtrList[i]->update == NULL)) { + pthis->currentActorNum |= (1 << i); + pthis->actorSpawnPtrList[i] = NULL; + } + } +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 2100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), +}; + +void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjMure2* pthis = (ObjMure2*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + if (globalCtx->csCtx.state != CS_STATE_IDLE) { + pthis->actor.uncullZoneForward += 1200.0f; + } + ObjMure2_SetupWait(pthis); +} + +void ObjMure2_SetupWait(ObjMure2* pthis) { + pthis->actionFunc = ObjMure2_Wait; +} + +void ObjMure2_Wait(ObjMure2* pthis, GlobalContext* globalCtx) { + func_80B9A658(pthis); +} + +void func_80B9A658(ObjMure2* pthis) { + pthis->actionFunc = func_80B9A668; +} + +void func_80B9A668(ObjMure2* pthis, GlobalContext* globalCtx) { + if (Math3D_Dist1DSq(pthis->actor.projectedPos.x, pthis->actor.projectedPos.z) < + (sDistSquared1[pthis->actor.params & 3] * pthis->unk_184)) { + pthis->actor.flags |= ACTOR_FLAG_4; + ObjMure2_SpawnActors(pthis, globalCtx); + func_80B9A6E8(pthis); + } +} + +void func_80B9A6E8(ObjMure2* pthis) { + pthis->actionFunc = func_80B9A6F8; +} + +void func_80B9A6F8(ObjMure2* pthis, GlobalContext* globalCtx) { + func_80B9A534(pthis); + if ((sDistSquared2[pthis->actor.params & 3] * pthis->unk_184) <= + Math3D_Dist1DSq(pthis->actor.projectedPos.x, pthis->actor.projectedPos.z)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + ObjMure2_CleanupAndDie(pthis, globalCtx); + func_80B9A658(pthis); + } +} + +void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjMure2* pthis = (ObjMure2*)thisx; + + if (globalCtx->csCtx.state == CS_STATE_IDLE) { + pthis->unk_184 = 1.0f; + } else { + pthis->unk_184 = 4.0f; + } + pthis->actionFunc(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c deleted file mode 100644 index 919b2ede9..000000000 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c +++ /dev/null @@ -1,203 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_MURE3_Z_OBJ_MURE3_C -#include "actor_common.h" -/* - * File: z_obj_mure3.c - * Overlay: ovl_Obj_Mure3 - * Description: Tower of Rupees - */ - -#include "z_obj_mure3.h" -#include "def/sys_math3d.h" -#include "def/z_actor.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" - -#define FLAGS 0 - -void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx); - -void func_80B9AF24(ObjMure3* this); -void func_80B9AF34(ObjMure3* this, GlobalContext* globalCtx); -void func_80B9AF54(ObjMure3* this); -void func_80B9AF64(ObjMure3* this, GlobalContext* globalCtx); -void func_80B9AFEC(ObjMure3* this); -void func_80B9AFFC(ObjMure3* this, GlobalContext* globalCtx); - -const ActorInit Obj_Mure3_InitVars = { - ACTOR_OBJ_MURE3, - ACTORCAT_BG, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ObjMure3), - (ActorFunc)ObjMure3_Init, - (ActorFunc)ObjMure3_Destroy, - (ActorFunc)ObjMure3_Update, - NULL, -}; - -static s16 sRupeeCounts[] = { 5, 5, 7, 0 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 1800, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), -}; - -void func_80B9A9D0(ObjMure3* this, GlobalContext* globalCtx) { - s32 i; - Vec3f spawnPos; - - Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos); - for (i = 0; i < 5; i++, spawnPos.y += 20.0f) { - if (!((this->unk_16C >> i) & 1)) { - this->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_BLUE); - if (this->unk_150[i] != NULL) { - this->unk_150[i]->actor.room = this->actor.room; - } - } - } -} - -void func_80B9AA90(ObjMure3* this, GlobalContext* globalCtx) { - s32 i; - Vec3f spawnPos; - f32 sn = Math_SinS(this->actor.world.rot.y); - f32 cos = Math_CosS(this->actor.world.rot.y); - f32 radius; - - spawnPos.y = this->actor.world.pos.y; - - for (i = 0, radius = -40.0f; i < 5; i++, radius += 20.0f) { - if (!((this->unk_16C >> i) & 1)) { - spawnPos.x = this->actor.world.pos.x + (sn * radius); - spawnPos.z = this->actor.world.pos.z + (cos * radius); - this->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_GREEN); - if (this->unk_150[i] != NULL) { - this->unk_150[i]->actor.room = this->actor.room; - } - } - } -} - -void func_80B9ABA0(ObjMure3* this, GlobalContext* globalCtx) { - s32 i; - Vec3f spawnPos; - s16 yRot; - - spawnPos.y = this->actor.world.pos.y; - yRot = this->actor.world.rot.y; - for (i = 0; i < 6; i++) { - if (!((this->unk_16C >> i) & 1)) { - spawnPos.x = (Math_SinS(yRot) * 40.0f) + this->actor.world.pos.x; - spawnPos.z = (Math_CosS(yRot) * 40.0f) + this->actor.world.pos.z; - this->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_GREEN); - if (this->unk_150[i] != NULL) { - this->unk_150[i]->actor.room = this->actor.room; - } - } - yRot += 0x2AAA; - } - if (!((this->unk_16C >> 6) & 1)) { - spawnPos.x = this->actor.world.pos.x; - spawnPos.z = this->actor.world.pos.z; - this->unk_150[6] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_RED); - if (this->unk_150[6] != NULL) { - this->unk_150[6]->actor.room = this->actor.room; - } - } -} - -void func_80B9ACE4(ObjMure3* this, GlobalContext* globalCtx) { - s16 count = sRupeeCounts[(this->actor.params >> 13) & 7]; - s32 i; - - for (i = 0; i < count; i++) { - EnItem00** collectible = &this->unk_150[i]; - - if (!((this->unk_16C >> i) & 1) && (*collectible != NULL)) { - if (Actor_HasParent(&(*collectible)->actor, globalCtx) || ((*collectible)->actor.update == NULL)) { - this->unk_16C |= (1 << i); - } else { - Actor_Kill(&(*collectible)->actor); - } - } - *collectible = NULL; - } -} - -void func_80B9ADCC(ObjMure3* this, GlobalContext* globalCtx) { - s16 count = sRupeeCounts[(this->actor.params >> 13) & 7]; - s32 i; - - for (i = 0; i < count; i++) { - EnItem00** collectible = &this->unk_150[i]; - - if ((*collectible != NULL) && !((this->unk_16C >> i) & 1)) { - if (Actor_HasParent(&(*collectible)->actor, globalCtx)) { - Flags_SetSwitch(globalCtx, this->actor.params & 0x3F); - } - if ((*collectible)->actor.update == NULL) { - this->unk_16C |= (1 << i); - this->unk_150[i] = NULL; - } - } - } -} - -void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjMure3* this = (ObjMure3*)thisx; - - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x3F)) { - Actor_Kill(&this->actor); - return; - } - Actor_ProcessInitChain(&this->actor, sInitChain); - func_80B9AF24(this); -} - -void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx) { -} - -void func_80B9AF24(ObjMure3* this) { - this->actionFunc = func_80B9AF34; -} - -void func_80B9AF34(ObjMure3* this, GlobalContext* globalCtx) { - func_80B9AF54(this); -} - -void func_80B9AF54(ObjMure3* this) { - this->actionFunc = func_80B9AF64; -} - -void func_80B9AF64(ObjMure3* this, GlobalContext* globalCtx) { - static ObjMure3SpawnFunc spawnFuncs[] = { func_80B9A9D0, func_80B9AA90, func_80B9ABA0 }; - - if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1150.0f)) { - this->actor.flags |= ACTOR_FLAG_4; - spawnFuncs[(this->actor.params >> 13) & 7](this, globalCtx); - func_80B9AFEC(this); - } -} - -void func_80B9AFEC(ObjMure3* this) { - this->actionFunc = func_80B9AFFC; -} - -void func_80B9AFFC(ObjMure3* this, GlobalContext* globalCtx) { - func_80B9ADCC(this, globalCtx); - if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) >= SQ(1450.0f)) { - this->actor.flags &= ~ACTOR_FLAG_4; - func_80B9ACE4(this, globalCtx); - func_80B9AF54(this); - } -} - -void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjMure3* this = (ObjMure3*)thisx; - - this->actionFunc(this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.cpp b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.cpp new file mode 100644 index 000000000..de097818b --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.cpp @@ -0,0 +1,203 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_MURE3_Z_OBJ_MURE3_C +#include "actor_common.h" +/* + * File: z_obj_mure3.c + * Overlay: ovl_Obj_Mure3 + * Description: Tower of Rupees + */ + +#include "z_obj_mure3.h" +#include "def/sys_math3d.h" +#include "def/z_actor.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" + +#define FLAGS 0 + +void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx); + +void func_80B9AF24(ObjMure3* pthis); +void func_80B9AF34(ObjMure3* pthis, GlobalContext* globalCtx); +void func_80B9AF54(ObjMure3* pthis); +void func_80B9AF64(ObjMure3* pthis, GlobalContext* globalCtx); +void func_80B9AFEC(ObjMure3* pthis); +void func_80B9AFFC(ObjMure3* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Mure3_InitVars = { + ACTOR_OBJ_MURE3, + ACTORCAT_BG, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ObjMure3), + (ActorFunc)ObjMure3_Init, + (ActorFunc)ObjMure3_Destroy, + (ActorFunc)ObjMure3_Update, + NULL, +}; + +static s16 sRupeeCounts[] = { 5, 5, 7, 0 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 1800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), +}; + +void func_80B9A9D0(ObjMure3* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f spawnPos; + + Math_Vec3f_Copy(&spawnPos, &pthis->actor.world.pos); + for (i = 0; i < 5; i++, spawnPos.y += 20.0f) { + if (!((pthis->unk_16C >> i) & 1)) { + pthis->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_BLUE); + if (pthis->unk_150[i] != NULL) { + pthis->unk_150[i]->actor.room = pthis->actor.room; + } + } + } +} + +void func_80B9AA90(ObjMure3* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f spawnPos; + f32 sn = Math_SinS(pthis->actor.world.rot.y); + f32 cos = Math_CosS(pthis->actor.world.rot.y); + f32 radius; + + spawnPos.y = pthis->actor.world.pos.y; + + for (i = 0, radius = -40.0f; i < 5; i++, radius += 20.0f) { + if (!((pthis->unk_16C >> i) & 1)) { + spawnPos.x = pthis->actor.world.pos.x + (sn * radius); + spawnPos.z = pthis->actor.world.pos.z + (cos * radius); + pthis->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_GREEN); + if (pthis->unk_150[i] != NULL) { + pthis->unk_150[i]->actor.room = pthis->actor.room; + } + } + } +} + +void func_80B9ABA0(ObjMure3* pthis, GlobalContext* globalCtx) { + s32 i; + Vec3f spawnPos; + s16 yRot; + + spawnPos.y = pthis->actor.world.pos.y; + yRot = pthis->actor.world.rot.y; + for (i = 0; i < 6; i++) { + if (!((pthis->unk_16C >> i) & 1)) { + spawnPos.x = (Math_SinS(yRot) * 40.0f) + pthis->actor.world.pos.x; + spawnPos.z = (Math_CosS(yRot) * 40.0f) + pthis->actor.world.pos.z; + pthis->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_GREEN); + if (pthis->unk_150[i] != NULL) { + pthis->unk_150[i]->actor.room = pthis->actor.room; + } + } + yRot += 0x2AAA; + } + if (!((pthis->unk_16C >> 6) & 1)) { + spawnPos.x = pthis->actor.world.pos.x; + spawnPos.z = pthis->actor.world.pos.z; + pthis->unk_150[6] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_RED); + if (pthis->unk_150[6] != NULL) { + pthis->unk_150[6]->actor.room = pthis->actor.room; + } + } +} + +void func_80B9ACE4(ObjMure3* pthis, GlobalContext* globalCtx) { + s16 count = sRupeeCounts[(pthis->actor.params >> 13) & 7]; + s32 i; + + for (i = 0; i < count; i++) { + EnItem00** collectible = &pthis->unk_150[i]; + + if (!((pthis->unk_16C >> i) & 1) && (*collectible != NULL)) { + if (Actor_HasParent(&(*collectible)->actor, globalCtx) || ((*collectible)->actor.update == NULL)) { + pthis->unk_16C |= (1 << i); + } else { + Actor_Kill(&(*collectible)->actor); + } + } + *collectible = NULL; + } +} + +void func_80B9ADCC(ObjMure3* pthis, GlobalContext* globalCtx) { + s16 count = sRupeeCounts[(pthis->actor.params >> 13) & 7]; + s32 i; + + for (i = 0; i < count; i++) { + EnItem00** collectible = &pthis->unk_150[i]; + + if ((*collectible != NULL) && !((pthis->unk_16C >> i) & 1)) { + if (Actor_HasParent(&(*collectible)->actor, globalCtx)) { + Flags_SetSwitch(globalCtx, pthis->actor.params & 0x3F); + } + if ((*collectible)->actor.update == NULL) { + pthis->unk_16C |= (1 << i); + pthis->unk_150[i] = NULL; + } + } + } +} + +void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjMure3* pthis = (ObjMure3*)thisx; + + if (Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F)) { + Actor_Kill(&pthis->actor); + return; + } + Actor_ProcessInitChain(&pthis->actor, sInitChain); + func_80B9AF24(pthis); +} + +void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80B9AF24(ObjMure3* pthis) { + pthis->actionFunc = func_80B9AF34; +} + +void func_80B9AF34(ObjMure3* pthis, GlobalContext* globalCtx) { + func_80B9AF54(pthis); +} + +void func_80B9AF54(ObjMure3* pthis) { + pthis->actionFunc = func_80B9AF64; +} + +void func_80B9AF64(ObjMure3* pthis, GlobalContext* globalCtx) { + static ObjMure3SpawnFunc spawnFuncs[] = { func_80B9A9D0, func_80B9AA90, func_80B9ABA0 }; + + if (Math3D_Dist1DSq(pthis->actor.projectedPos.x, pthis->actor.projectedPos.z) < SQ(1150.0f)) { + pthis->actor.flags |= ACTOR_FLAG_4; + spawnFuncs[(pthis->actor.params >> 13) & 7](pthis, globalCtx); + func_80B9AFEC(pthis); + } +} + +void func_80B9AFEC(ObjMure3* pthis) { + pthis->actionFunc = func_80B9AFFC; +} + +void func_80B9AFFC(ObjMure3* pthis, GlobalContext* globalCtx) { + func_80B9ADCC(pthis, globalCtx); + if (Math3D_Dist1DSq(pthis->actor.projectedPos.x, pthis->actor.projectedPos.z) >= SQ(1450.0f)) { + pthis->actor.flags &= ~ACTOR_FLAG_4; + func_80B9ACE4(pthis, globalCtx); + func_80B9AF54(pthis); + } +} + +void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjMure3* pthis = (ObjMure3*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c deleted file mode 100644 index 3b16edd1d..000000000 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ /dev/null @@ -1,694 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_OSHIHIKI_Z_OBJ_OSHIHIKI_C -#include "actor_common.h" -/* - * File: z_obj_oshihiki.c - * Overlay: ovl_Obj_Oshihiki - * Description: Push Block - */ - -#include "z_obj_oshihiki.h" -#include "overlays/actors/ovl_Obj_Switch/z_obj_switch.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjOshihiki_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjOshihiki_SetupOnScene(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_OnScene(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_SetupOnActor(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_OnActor(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_SetupPush(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_SetupFall(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_Fall(ObjOshihiki* this, GlobalContext* globalCtx); - -const ActorInit Obj_Oshihiki_InitVars = { - ACTOR_OBJ_OSHIHIKI, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_DANGEON_KEEP, - sizeof(ObjOshihiki), - (ActorFunc)ObjOshihiki_Init, - (ActorFunc)ObjOshihiki_Destroy, - (ActorFunc)ObjOshihiki_Update, - (ActorFunc)ObjOshihiki_Draw, -}; - -static f32 sScales[] = { - (1 / 10.0f), (1 / 6.0f), (1 / 5.0f), (1 / 3.0f), (1 / 10.0f), (1 / 6.0f), (1 / 5.0f), (1 / 3.0f), -}; - -static Color_RGB8 sColors[][4] = { - { { 110, 86, 40 }, { 110, 86, 40 }, { 110, 86, 40 }, { 110, 86, 40 } }, // deku tree - { { 106, 120, 110 }, { 104, 80, 20 }, { 0, 0, 0 }, { 0, 0, 0 } }, // dodongos cavern - { { 142, 99, 86 }, { 72, 118, 96 }, { 0, 0, 0 }, { 0, 0, 0 } }, // forest temple - { { 210, 150, 80 }, { 210, 170, 80 }, { 0, 0, 0 }, { 0, 0, 0 } }, // fire temple - { { 102, 144, 182 }, { 176, 167, 100 }, { 100, 167, 100 }, { 117, 97, 96 } }, // water temple - { { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 } }, // spirit temple - { { 135, 125, 95 }, { 135, 125, 95 }, { 135, 125, 95 }, { 135, 125, 95 } }, // shadow temple - { { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 } }, // ganons castle - { { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 } }, // gerudo training grounds -}; - -static s16 sScenes[] = { - SCENE_YDAN, SCENE_DDAN, SCENE_BMORI1, SCENE_HIDAN, SCENE_MIZUSIN, - SCENE_JYASINZOU, SCENE_HAKADAN, SCENE_GANON, SCENE_MEN, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), -}; - -// The vertices and center of the bottom face -static Vec3f sColCheckPoints[5] = { - { 29.99f, 1.01f, -29.99f }, { -29.99f, 1.01f, -29.99f }, { -29.99f, 1.01f, 29.99f }, - { 29.99f, 1.01f, 29.99f }, { 0.0f, 1.01f, 0.0f }, -}; - -static Vec2f sFaceVtx[] = { - { -30.0f, 0.0f }, - { 30.0f, 0.0f }, - { -30.0f, 60.0f }, - { 30.0f, 60.0f }, -}; - -static Vec2f sFaceDirection[] = { - { 1.0f, 1.0f }, - { -1.0f, 1.0f }, - { 1.0f, -1.0f }, - { -1.0f, -1.0f }, -}; - -void ObjOshihiki_InitDynapoly(ObjOshihiki* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, moveFlag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - // "Warning : move BG registration failure" - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 280, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void ObjOshihiki_RotateXZ(Vec3f* out, Vec3f* in, f32 sn, f32 cs) { - out->x = (in->z * sn) + (in->x * cs); - out->y = in->y; - out->z = (in->z * cs) - (in->x * sn); -} - -s32 ObjOshihiki_StrongEnough(ObjOshihiki* this) { - s32 strength; - - if (this->cantMove) { - return 0; - } - strength = Player_GetStrength(); - switch (this->dyna.actor.params & 0xF) { - case PUSHBLOCK_SMALL_START_ON: - case PUSHBLOCK_MEDIUM_START_ON: - case PUSHBLOCK_SMALL_START_OFF: - case PUSHBLOCK_MEDIUM_START_OFF: - return 1; - break; - case PUSHBLOCK_LARGE_START_ON: - case PUSHBLOCK_LARGE_START_OFF: - return strength >= PLAYER_STR_BRACELET; - break; - case PUSHBLOCK_HUGE_START_ON: - case PUSHBLOCK_HUGE_START_OFF: - return strength >= PLAYER_STR_SILVER_G; - break; - } - return 0; -} - -void ObjOshihiki_ResetFloors(ObjOshihiki* this) { - s32 i; - - for (i = 0; i < ARRAY_COUNT(this->floorBgIds); i++) { - this->floorBgIds[i] = BGCHECK_SCENE; - } -} - -ObjOshihiki* ObjOshihiki_GetBlockUnder(ObjOshihiki* this, GlobalContext* globalCtx) { - DynaPolyActor* dynaPolyActor; - - if ((this->floorBgIds[this->highestFloor] != BGCHECK_SCENE) && - (fabsf(this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) < 0.001f)) { - dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->floorBgIds[this->highestFloor]); - if ((dynaPolyActor != NULL) && (dynaPolyActor->actor.id == ACTOR_OBJ_OSHIHIKI)) { - return (ObjOshihiki*)dynaPolyActor; - } - } - return NULL; -} - -void ObjOshihiki_UpdateInitPos(ObjOshihiki* this) { - if (this->dyna.actor.home.pos.x < this->dyna.actor.world.pos.x) { - while ((this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x) >= 20.0f) { - this->dyna.actor.home.pos.x += 20.0f; - } - } else { - while ((this->dyna.actor.home.pos.x - this->dyna.actor.world.pos.x) >= 20.0f) { - this->dyna.actor.home.pos.x -= 20.0f; - } - } - if (this->dyna.actor.home.pos.z < this->dyna.actor.world.pos.z) { - while ((this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z) >= 20.0f) { - this->dyna.actor.home.pos.z += 20.0f; - } - } else { - while ((this->dyna.actor.home.pos.z - this->dyna.actor.world.pos.z) >= 20.0f) { - this->dyna.actor.home.pos.z -= 20.0f; - } - } -} - -s32 ObjOshihiki_NoSwitchPress(ObjOshihiki* this, DynaPolyActor* dyna, GlobalContext* globalCtx) { - s16 dynaSwitchFlag; - - if (dyna == NULL) { - return 1; - } else if (dyna->actor.id == ACTOR_OBJ_SWITCH) { - dynaSwitchFlag = (dyna->actor.params >> 8) & 0x3F; - switch (dyna->actor.params & 0x33) { - case 0x20: // Normal blue switch - if ((dynaSwitchFlag == ((this->dyna.actor.params >> 8) & 0x3F)) && - Flags_GetSwitch(globalCtx, dynaSwitchFlag)) { - return 0; - } - break; - case 0x30: // Inverse blue switch - if ((dynaSwitchFlag == ((this->dyna.actor.params >> 8) & 0x3F)) && - !Flags_GetSwitch(globalCtx, dynaSwitchFlag)) { - return 0; - } - break; - } - } - return 1; -} - -void ObjOshihiki_CheckType(ObjOshihiki* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xF) { - case PUSHBLOCK_SMALL_START_ON: - case PUSHBLOCK_MEDIUM_START_ON: - case PUSHBLOCK_LARGE_START_ON: - case PUSHBLOCK_HUGE_START_ON: - case PUSHBLOCK_SMALL_START_OFF: - case PUSHBLOCK_MEDIUM_START_OFF: - case PUSHBLOCK_LARGE_START_OFF: - case PUSHBLOCK_HUGE_START_OFF: - ObjOshihiki_InitDynapoly(this, globalCtx, &gPushBlockCol, 1); - break; - default: - // "Error : type cannot be determined" - osSyncPrintf("Error : タイプが判別できない(%s %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 444, - this->dyna.actor.params); - break; - } -} - -void ObjOshihiki_SetScale(ObjOshihiki* this, GlobalContext* globalCtx) { - Actor_SetScale(&this->dyna.actor, sScales[this->dyna.actor.params & 0xF]); -} - -void ObjOshihiki_SetTexture(ObjOshihiki* this, GlobalContext* globalCtx) { - switch (this->dyna.actor.params & 0xF) { - case PUSHBLOCK_SMALL_START_ON: - case PUSHBLOCK_MEDIUM_START_ON: - case PUSHBLOCK_SMALL_START_OFF: - case PUSHBLOCK_MEDIUM_START_OFF: - this->texture = gPushBlockSilverTex; - break; - case PUSHBLOCK_LARGE_START_ON: - case PUSHBLOCK_LARGE_START_OFF: - this->texture = gPushBlockBaseTex; - break; - case PUSHBLOCK_HUGE_START_ON: - case PUSHBLOCK_HUGE_START_OFF: - this->texture = gPushBlockGrayTex; - break; - } -} - -void ObjOshihiki_SetColor(ObjOshihiki* this, GlobalContext* globalCtx) { - Color_RGB8* src; - Color_RGB8* color = &this->color; - s16 paramsColorIdx; - s32 i; - - paramsColorIdx = (this->dyna.actor.params >> 6) & 3; - - for (i = 0; i < ARRAY_COUNT(sScenes); i++) { - if (sScenes[i] == globalCtx->sceneNum) { - break; - } - } - - if (i >= ARRAY_COUNT(sColors)) { - // "Error : scene_data_ID cannot be determined" - osSyncPrintf("Error : scene_data_ID が判別できない。(%s %d)\n", "../z_obj_oshihiki.c", 579); - color->r = color->g = color->b = 255; - } else { - src = &sColors[i][paramsColorIdx]; - color->r = src->r; - color->g = src->g; - color->b = src->b; - } -} - -void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - ObjOshihiki* this = (ObjOshihiki*)thisx; - - ObjOshihiki_CheckType(this, globalCtx); - - if ((((this->dyna.actor.params >> 8) & 0xFF) >= 0) && (((this->dyna.actor.params >> 8) & 0xFF) <= 0x3F)) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) { - switch (this->dyna.actor.params & 0xF) { - case PUSHBLOCK_SMALL_START_ON: - case PUSHBLOCK_MEDIUM_START_ON: - case PUSHBLOCK_LARGE_START_ON: - case PUSHBLOCK_HUGE_START_ON: - Actor_Kill(&this->dyna.actor); - return; - } - } else { - switch (this->dyna.actor.params & 0xF) { - case PUSHBLOCK_SMALL_START_OFF: - case PUSHBLOCK_MEDIUM_START_OFF: - case PUSHBLOCK_LARGE_START_OFF: - case PUSHBLOCK_HUGE_START_OFF: - Actor_Kill(&this->dyna.actor); - return; - } - } - } - - ObjOshihiki_SetScale(this, globalCtx); - ObjOshihiki_SetTexture(this, globalCtx); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - ObjOshihiki_SetColor(this, globalCtx); - ObjOshihiki_ResetFloors(this); - ObjOshihiki_SetupOnActor(this, globalCtx); - // "(dungeon keep push-pull block)" - osSyncPrintf("(dungeon keep 押し引きブロック)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void ObjOshihiki_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjOshihiki* this = (ObjOshihiki*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -void ObjOshihiki_SetFloors(ObjOshihiki* this, GlobalContext* globalCtx) { - s32 i; - - for (i = 0; i < 5; i++) { - Vec3f colCheckPoint; - Vec3f colCheckOffset; - CollisionPoly** floorPoly; - s32* floorBgId; - - colCheckOffset.x = sColCheckPoints[i].x * (this->dyna.actor.scale.x * 10.0f); - colCheckOffset.y = sColCheckPoints[i].y * (this->dyna.actor.scale.y * 10.0f); - colCheckOffset.z = sColCheckPoints[i].z * (this->dyna.actor.scale.z * 10.0f); - ObjOshihiki_RotateXZ(&colCheckPoint, &colCheckOffset, this->yawSin, this->yawCos); - colCheckPoint.x += this->dyna.actor.world.pos.x; - colCheckPoint.y += this->dyna.actor.prevPos.y; - colCheckPoint.z += this->dyna.actor.world.pos.z; - - floorPoly = &this->floorPolys[i]; - floorBgId = &this->floorBgIds[i]; - this->floorHeights[i] = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, floorPoly, floorBgId, &this->dyna.actor, - &colCheckPoint, 0.0f); - } -} - -s16 ObjOshihiki_GetHighestFloor(ObjOshihiki* this) { - s16 highestFloor = 0; - s16 temp = 1; - f32 phi_f0 = this->floorHeights[temp]; - - if (phi_f0 > this->floorHeights[highestFloor]) { - highestFloor = temp; - } else if ((this->floorBgIds[temp] == BGCHECK_SCENE) && ((phi_f0 - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp; - } - if (this->floorHeights[temp + 1] > this->floorHeights[highestFloor]) { - highestFloor = temp + 1; - } else if ((this->floorBgIds[temp + 1] == BGCHECK_SCENE) && - ((this->floorHeights[temp + 1] - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp + 1; - } - if (this->floorHeights[temp + 2] > this->floorHeights[highestFloor]) { - highestFloor = temp + 2; - } else if ((this->floorBgIds[temp + 2] == BGCHECK_SCENE) && - ((this->floorHeights[temp + 2] - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp + 2; - } - if (this->floorHeights[temp + 3] > this->floorHeights[highestFloor]) { - highestFloor = temp + 3; - } else if ((this->floorBgIds[temp + 3] == BGCHECK_SCENE) && - ((this->floorHeights[temp + 3] - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp + 3; - } - return highestFloor; -} - -void ObjOshihiki_SetGround(ObjOshihiki* this, GlobalContext* globalCtx) { - ObjOshihiki_ResetFloors(this); - ObjOshihiki_SetFloors(this, globalCtx); - this->highestFloor = ObjOshihiki_GetHighestFloor(this); - this->dyna.actor.floorHeight = this->floorHeights[this->highestFloor]; -} - -s32 ObjOshihiki_CheckFloor(ObjOshihiki* this, GlobalContext* globalCtx) { - ObjOshihiki_SetGround(this, globalCtx); - - if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= -0.001f) { - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - return 1; - } - - return 0; -} - -s32 ObjOshihiki_CheckGround(ObjOshihiki* this, GlobalContext* globalCtx) { - if (this->dyna.actor.world.pos.y <= BGCHECK_Y_MIN + 10.0f) { - // "Warning : Push-pull block fell too much" - osSyncPrintf("Warning : 押し引きブロック落ちすぎた(%s %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 809, - this->dyna.actor.params); - Actor_Kill(&this->dyna.actor); - return 0; - } - if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= -0.001f) { - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - return 1; - } - return 0; -} - -s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, ObjOshihiki* this) { - f32 maxDist = ((direction >= 0.0f) ? 1.0f : -1.0f) * (300.0f * this->dyna.actor.scale.x + 20.0f - 0.5f); - f32 sn = Math_SinS(angle); - f32 cs = Math_CosS(angle); - s32 i; - - for (i = 0; i < 4; i++) { - Vec3f faceVtx; - Vec3f faceVtxNext; - Vec3f posResult; - Vec3f faceVtxOffset; - s32 bgId; - CollisionPoly* outPoly; - - faceVtxOffset.x = (sFaceVtx[i].x * this->dyna.actor.scale.x * 10.0f) + sFaceDirection[i].x; - faceVtxOffset.y = (sFaceVtx[i].y * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].y; - faceVtxOffset.z = 0.0f; - ObjOshihiki_RotateXZ(&faceVtx, &faceVtxOffset, sn, cs); - faceVtx.x += this->dyna.actor.world.pos.x; - faceVtx.y += this->dyna.actor.world.pos.y; - faceVtx.z += this->dyna.actor.world.pos.z; - faceVtxNext.x = faceVtx.x + maxDist * sn; - faceVtxNext.y = faceVtx.y; - faceVtxNext.z = faceVtx.z + maxDist * cs; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, true, false, - false, true, &bgId, &this->dyna.actor, 0.0f)) { - return true; - } - } - return false; -} - -s32 ObjOshihiki_MoveWithBlockUnder(ObjOshihiki* this, GlobalContext* globalCtx) { - s32 pad; - ObjOshihiki* blockUnder = ObjOshihiki_GetBlockUnder(this, globalCtx); - - if ((blockUnder != NULL) && (blockUnder->stateFlags & PUSHBLOCK_SETUP_PUSH) && - !ObjOshihiki_CheckWall(globalCtx, blockUnder->dyna.unk_158, blockUnder->direction, this)) { - this->blockUnder = blockUnder; - } - - if ((this->stateFlags & PUSHBLOCK_MOVE_UNDER) && (this->blockUnder != NULL)) { - if (this->blockUnder->stateFlags & PUSHBLOCK_PUSH) { - this->underDistX = this->blockUnder->dyna.actor.world.pos.x - this->blockUnder->dyna.actor.prevPos.x; - this->underDistZ = this->blockUnder->dyna.actor.world.pos.z - this->blockUnder->dyna.actor.prevPos.z; - this->dyna.actor.world.pos.x += this->underDistX; - this->dyna.actor.world.pos.z += this->underDistZ; - ObjOshihiki_UpdateInitPos(this); - return true; - } else if (!(this->blockUnder->stateFlags & PUSHBLOCK_SETUP_PUSH)) { - this->blockUnder = NULL; - } - } - return false; -} - -void ObjOshihiki_SetupOnScene(ObjOshihiki* this, GlobalContext* globalCtx) { - this->stateFlags |= PUSHBLOCK_SETUP_ON_SCENE; - this->actionFunc = ObjOshihiki_OnScene; - this->dyna.actor.gravity = 0.0f; - this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; -} - -void ObjOshihiki_OnScene(ObjOshihiki* this, GlobalContext* globalCtx) { - s32 pad; - Player* player = GET_PLAYER(globalCtx); - - this->stateFlags |= PUSHBLOCK_ON_SCENE; - if ((this->timer <= 0) && (fabsf(this->dyna.unk_150) > 0.001f)) { - if (ObjOshihiki_StrongEnough(this) && - !ObjOshihiki_CheckWall(globalCtx, this->dyna.unk_158, this->dyna.unk_150, this)) { - this->direction = this->dyna.unk_150; - ObjOshihiki_SetupPush(this, globalCtx); - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } -} - -void ObjOshihiki_SetupOnActor(ObjOshihiki* this, GlobalContext* globalCtx) { - this->stateFlags |= PUSHBLOCK_SETUP_ON_ACTOR; - this->actionFunc = ObjOshihiki_OnActor; - this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; - this->dyna.actor.gravity = -1.0f; -} - -void ObjOshihiki_OnActor(ObjOshihiki* this, GlobalContext* globalCtx) { - s32 bgId; - Player* player = GET_PLAYER(globalCtx); - DynaPolyActor* dynaPolyActor; - - this->stateFlags |= PUSHBLOCK_ON_ACTOR; - Actor_MoveForward(&this->dyna.actor); - - if (ObjOshihiki_CheckFloor(this, globalCtx)) { - bgId = this->floorBgIds[this->highestFloor]; - if (bgId == BGCHECK_SCENE) { - ObjOshihiki_SetupOnScene(this, globalCtx); - } else { - dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); - if (dynaPolyActor != NULL) { - func_800434A8(dynaPolyActor); - func_80043538(dynaPolyActor); - - if ((this->timer <= 0) && (fabsf(this->dyna.unk_150) > 0.001f)) { - if (ObjOshihiki_StrongEnough(this) && ObjOshihiki_NoSwitchPress(this, dynaPolyActor, globalCtx) && - !ObjOshihiki_CheckWall(globalCtx, this->dyna.unk_158, this->dyna.unk_150, this)) { - - this->direction = this->dyna.unk_150; - ObjOshihiki_SetupPush(this, globalCtx); - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } - } else { - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - } - } else { - ObjOshihiki_SetupOnScene(this, globalCtx); - } - } - } else { - bgId = this->floorBgIds[this->highestFloor]; - if (bgId == BGCHECK_SCENE) { - ObjOshihiki_SetupFall(this, globalCtx); - } else { - dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); - - if ((dynaPolyActor != NULL) && (dynaPolyActor->unk_15C & 1)) { - func_800434A8(dynaPolyActor); - func_80043538(dynaPolyActor); - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - } else { - ObjOshihiki_SetupFall(this, globalCtx); - } - } - } -} - -void ObjOshihiki_SetupPush(ObjOshihiki* this, GlobalContext* globalCtx) { - this->stateFlags |= PUSHBLOCK_SETUP_PUSH; - this->actionFunc = ObjOshihiki_Push; - this->dyna.actor.gravity = 0.0f; -} - -void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - Player* player = GET_PLAYER(globalCtx); - f32 pushDistSigned; - s32 stopFlag; - - this->pushSpeed += 0.5f; - this->stateFlags |= PUSHBLOCK_PUSH; - this->pushSpeed = CLAMP_MAX(this->pushSpeed, 2.0f); - stopFlag = Math_StepToF(&this->pushDist, 20.0f, this->pushSpeed); - pushDistSigned = ((this->direction >= 0.0f) ? 1.0f : -1.0f) * this->pushDist; - thisx->world.pos.x = thisx->home.pos.x + (pushDistSigned * this->yawSin); - thisx->world.pos.z = thisx->home.pos.z + (pushDistSigned * this->yawCos); - - if (!ObjOshihiki_CheckFloor(this, globalCtx)) { - thisx->home.pos.x = thisx->world.pos.x; - thisx->home.pos.z = thisx->world.pos.z; - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - this->pushDist = 0.0f; - this->pushSpeed = 0.0f; - ObjOshihiki_SetupFall(this, globalCtx); - } else if (stopFlag) { - player = GET_PLAYER(globalCtx); - if (ObjOshihiki_CheckWall(globalCtx, this->dyna.unk_158, this->dyna.unk_150, this)) { - Audio_PlayActorSound2(thisx, NA_SE_EV_BLOCK_BOUND); - } - - thisx->home.pos.x = thisx->world.pos.x; - thisx->home.pos.z = thisx->world.pos.z; - player->stateFlags2 &= ~0x10; - this->dyna.unk_150 = 0.0f; - this->pushDist = 0.0f; - this->pushSpeed = 0.0f; - this->timer = 10; - if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { - ObjOshihiki_SetupOnScene(this, globalCtx); - } else { - ObjOshihiki_SetupOnActor(this, globalCtx); - } - } - Audio_PlayActorSound2(thisx, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); -} - -void ObjOshihiki_SetupFall(ObjOshihiki* this, GlobalContext* globalCtx) { - this->stateFlags |= PUSHBLOCK_SETUP_FALL; - this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; - this->dyna.actor.gravity = -1.0f; - ObjOshihiki_SetGround(this, globalCtx); - this->actionFunc = ObjOshihiki_Fall; -} - -void ObjOshihiki_Fall(ObjOshihiki* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - this->stateFlags |= PUSHBLOCK_FALL; - if (fabsf(this->dyna.unk_150) > 0.001f) { - this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; - } - Actor_MoveForward(&this->dyna.actor); - if (ObjOshihiki_CheckGround(this, globalCtx)) { - if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { - ObjOshihiki_SetupOnScene(this, globalCtx); - } else { - ObjOshihiki_SetupOnActor(this, globalCtx); - } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Audio_PlayActorSound2(&this->dyna.actor, - SurfaceType_GetSfx(&globalCtx->colCtx, this->floorPolys[this->highestFloor], - this->floorBgIds[this->highestFloor]) + - SFX_FLAG); - } -} - -void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjOshihiki* this = (ObjOshihiki*)thisx; - - this->stateFlags &= - ~(PUSHBLOCK_SETUP_FALL | PUSHBLOCK_FALL | PUSHBLOCK_SETUP_PUSH | PUSHBLOCK_PUSH | PUSHBLOCK_SETUP_ON_ACTOR | - PUSHBLOCK_ON_ACTOR | PUSHBLOCK_SETUP_ON_SCENE | PUSHBLOCK_ON_SCENE); - this->stateFlags |= PUSHBLOCK_MOVE_UNDER; - - if (this->timer > 0) { - this->timer--; - } - - this->dyna.actor.world.rot.y = this->dyna.unk_158; - - this->yawSin = Math_SinS(this->dyna.actor.world.rot.y); - this->yawCos = Math_CosS(this->dyna.actor.world.rot.y); - - if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); - } -} - -void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjOshihiki* this = (ObjOshihiki*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_oshihiki.c", 1289); - if (ObjOshihiki_MoveWithBlockUnder(this, globalCtx)) { - Matrix_Translate(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); - } - this->stateFlags &= ~PUSHBLOCK_MOVE_UNDER; - func_80093D18(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(this->texture)); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_oshihiki.c", 1308), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - switch (globalCtx->sceneNum) { - case SCENE_YDAN: - case SCENE_DDAN: - case SCENE_BMORI1: - case SCENE_HIDAN: - case SCENE_MIZUSIN: - case SCENE_JYASINZOU: - case SCENE_HAKADAN: - case SCENE_MEN: - gDPSetEnvColor(POLY_OPA_DISP++, this->color.r, this->color.g, this->color.b, 255); - break; - default: - gDPSetEnvColor(POLY_OPA_DISP++, mREG(13), mREG(14), mREG(15), 255); - break; - } - - gSPDisplayList(POLY_OPA_DISP++, gPushBlockDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_oshihiki.c", 1334); -} diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.cpp b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.cpp new file mode 100644 index 000000000..a2e827bd8 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.cpp @@ -0,0 +1,694 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_OSHIHIKI_Z_OBJ_OSHIHIKI_C +#include "actor_common.h" +/* + * File: z_obj_oshihiki.c + * Overlay: ovl_Obj_Oshihiki + * Description: Push Block + */ + +#include "z_obj_oshihiki.h" +#include "overlays/actors/ovl_Obj_Switch/z_obj_switch.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjOshihiki_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjOshihiki_SetupOnScene(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_OnScene(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_SetupOnActor(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_OnActor(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_SetupPush(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_Push(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_SetupFall(ObjOshihiki* pthis, GlobalContext* globalCtx); +void ObjOshihiki_Fall(ObjOshihiki* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Oshihiki_InitVars = { + ACTOR_OBJ_OSHIHIKI, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_DANGEON_KEEP, + sizeof(ObjOshihiki), + (ActorFunc)ObjOshihiki_Init, + (ActorFunc)ObjOshihiki_Destroy, + (ActorFunc)ObjOshihiki_Update, + (ActorFunc)ObjOshihiki_Draw, +}; + +static f32 sScales[] = { + (1 / 10.0f), (1 / 6.0f), (1 / 5.0f), (1 / 3.0f), (1 / 10.0f), (1 / 6.0f), (1 / 5.0f), (1 / 3.0f), +}; + +static Color_RGB8 sColors[][4] = { + { { 110, 86, 40 }, { 110, 86, 40 }, { 110, 86, 40 }, { 110, 86, 40 } }, // deku tree + { { 106, 120, 110 }, { 104, 80, 20 }, { 0, 0, 0 }, { 0, 0, 0 } }, // dodongos cavern + { { 142, 99, 86 }, { 72, 118, 96 }, { 0, 0, 0 }, { 0, 0, 0 } }, // forest temple + { { 210, 150, 80 }, { 210, 170, 80 }, { 0, 0, 0 }, { 0, 0, 0 } }, // fire temple + { { 102, 144, 182 }, { 176, 167, 100 }, { 100, 167, 100 }, { 117, 97, 96 } }, // water temple + { { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 } }, // spirit temple + { { 135, 125, 95 }, { 135, 125, 95 }, { 135, 125, 95 }, { 135, 125, 95 } }, // shadow temple + { { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 } }, // ganons castle + { { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 }, { 232, 210, 176 } }, // gerudo training grounds +}; + +static s16 sScenes[] = { + SCENE_YDAN, SCENE_DDAN, SCENE_BMORI1, SCENE_HIDAN, SCENE_MIZUSIN, + SCENE_JYASINZOU, SCENE_HAKADAN, SCENE_GANON, SCENE_MEN, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), +}; + +// The vertices and center of the bottom face +static Vec3f sColCheckPoints[5] = { + { 29.99f, 1.01f, -29.99f }, { -29.99f, 1.01f, -29.99f }, { -29.99f, 1.01f, 29.99f }, + { 29.99f, 1.01f, 29.99f }, { 0.0f, 1.01f, 0.0f }, +}; + +static Vec2f sFaceVtx[] = { + { -30.0f, 0.0f }, + { 30.0f, 0.0f }, + { -30.0f, 60.0f }, + { 30.0f, 60.0f }, +}; + +static Vec2f sFaceDirection[] = { + { 1.0f, 1.0f }, + { -1.0f, 1.0f }, + { 1.0f, -1.0f }, + { -1.0f, -1.0f }, +}; + +void ObjOshihiki_InitDynapoly(ObjOshihiki* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, moveFlag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + // "Warning : move BG registration failure" + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 280, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void ObjOshihiki_RotateXZ(Vec3f* out, Vec3f* in, f32 sn, f32 cs) { + out->x = (in->z * sn) + (in->x * cs); + out->y = in->y; + out->z = (in->z * cs) - (in->x * sn); +} + +s32 ObjOshihiki_StrongEnough(ObjOshihiki* pthis) { + s32 strength; + + if (pthis->cantMove) { + return 0; + } + strength = Player_GetStrength(); + switch (pthis->dyna.actor.params & 0xF) { + case PUSHBLOCK_SMALL_START_ON: + case PUSHBLOCK_MEDIUM_START_ON: + case PUSHBLOCK_SMALL_START_OFF: + case PUSHBLOCK_MEDIUM_START_OFF: + return 1; + break; + case PUSHBLOCK_LARGE_START_ON: + case PUSHBLOCK_LARGE_START_OFF: + return strength >= PLAYER_STR_BRACELET; + break; + case PUSHBLOCK_HUGE_START_ON: + case PUSHBLOCK_HUGE_START_OFF: + return strength >= PLAYER_STR_SILVER_G; + break; + } + return 0; +} + +void ObjOshihiki_ResetFloors(ObjOshihiki* pthis) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(pthis->floorBgIds); i++) { + pthis->floorBgIds[i] = BGCHECK_SCENE; + } +} + +ObjOshihiki* ObjOshihiki_GetBlockUnder(ObjOshihiki* pthis, GlobalContext* globalCtx) { + DynaPolyActor* dynaPolyActor; + + if ((pthis->floorBgIds[pthis->highestFloor] != BGCHECK_SCENE) && + (fabsf(pthis->dyna.actor.floorHeight - pthis->dyna.actor.world.pos.y) < 0.001f)) { + dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->floorBgIds[pthis->highestFloor]); + if ((dynaPolyActor != NULL) && (dynaPolyActor->actor.id == ACTOR_OBJ_OSHIHIKI)) { + return (ObjOshihiki*)dynaPolyActor; + } + } + return NULL; +} + +void ObjOshihiki_UpdateInitPos(ObjOshihiki* pthis) { + if (pthis->dyna.actor.home.pos.x < pthis->dyna.actor.world.pos.x) { + while ((pthis->dyna.actor.world.pos.x - pthis->dyna.actor.home.pos.x) >= 20.0f) { + pthis->dyna.actor.home.pos.x += 20.0f; + } + } else { + while ((pthis->dyna.actor.home.pos.x - pthis->dyna.actor.world.pos.x) >= 20.0f) { + pthis->dyna.actor.home.pos.x -= 20.0f; + } + } + if (pthis->dyna.actor.home.pos.z < pthis->dyna.actor.world.pos.z) { + while ((pthis->dyna.actor.world.pos.z - pthis->dyna.actor.home.pos.z) >= 20.0f) { + pthis->dyna.actor.home.pos.z += 20.0f; + } + } else { + while ((pthis->dyna.actor.home.pos.z - pthis->dyna.actor.world.pos.z) >= 20.0f) { + pthis->dyna.actor.home.pos.z -= 20.0f; + } + } +} + +s32 ObjOshihiki_NoSwitchPress(ObjOshihiki* pthis, DynaPolyActor* dyna, GlobalContext* globalCtx) { + s16 dynaSwitchFlag; + + if (dyna == NULL) { + return 1; + } else if (dyna->actor.id == ACTOR_OBJ_SWITCH) { + dynaSwitchFlag = (dyna->actor.params >> 8) & 0x3F; + switch (dyna->actor.params & 0x33) { + case 0x20: // Normal blue switch + if ((dynaSwitchFlag == ((pthis->dyna.actor.params >> 8) & 0x3F)) && + Flags_GetSwitch(globalCtx, dynaSwitchFlag)) { + return 0; + } + break; + case 0x30: // Inverse blue switch + if ((dynaSwitchFlag == ((pthis->dyna.actor.params >> 8) & 0x3F)) && + !Flags_GetSwitch(globalCtx, dynaSwitchFlag)) { + return 0; + } + break; + } + } + return 1; +} + +void ObjOshihiki_CheckType(ObjOshihiki* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xF) { + case PUSHBLOCK_SMALL_START_ON: + case PUSHBLOCK_MEDIUM_START_ON: + case PUSHBLOCK_LARGE_START_ON: + case PUSHBLOCK_HUGE_START_ON: + case PUSHBLOCK_SMALL_START_OFF: + case PUSHBLOCK_MEDIUM_START_OFF: + case PUSHBLOCK_LARGE_START_OFF: + case PUSHBLOCK_HUGE_START_OFF: + ObjOshihiki_InitDynapoly(pthis, globalCtx, &gPushBlockCol, 1); + break; + default: + // "Error : type cannot be determined" + osSyncPrintf("Error : タイプが判別できない(%s %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 444, + pthis->dyna.actor.params); + break; + } +} + +void ObjOshihiki_SetScale(ObjOshihiki* pthis, GlobalContext* globalCtx) { + Actor_SetScale(&pthis->dyna.actor, sScales[pthis->dyna.actor.params & 0xF]); +} + +void ObjOshihiki_SetTexture(ObjOshihiki* pthis, GlobalContext* globalCtx) { + switch (pthis->dyna.actor.params & 0xF) { + case PUSHBLOCK_SMALL_START_ON: + case PUSHBLOCK_MEDIUM_START_ON: + case PUSHBLOCK_SMALL_START_OFF: + case PUSHBLOCK_MEDIUM_START_OFF: + pthis->texture = gPushBlockSilverTex; + break; + case PUSHBLOCK_LARGE_START_ON: + case PUSHBLOCK_LARGE_START_OFF: + pthis->texture = gPushBlockBaseTex; + break; + case PUSHBLOCK_HUGE_START_ON: + case PUSHBLOCK_HUGE_START_OFF: + pthis->texture = gPushBlockGrayTex; + break; + } +} + +void ObjOshihiki_SetColor(ObjOshihiki* pthis, GlobalContext* globalCtx) { + Color_RGB8* src; + Color_RGB8* color = &pthis->color; + s16 paramsColorIdx; + s32 i; + + paramsColorIdx = (pthis->dyna.actor.params >> 6) & 3; + + for (i = 0; i < ARRAY_COUNT(sScenes); i++) { + if (sScenes[i] == globalCtx->sceneNum) { + break; + } + } + + if (i >= ARRAY_COUNT(sColors)) { + // "Error : scene_data_ID cannot be determined" + osSyncPrintf("Error : scene_data_ID が判別できない。(%s %d)\n", "../z_obj_oshihiki.c", 579); + color->r = color->g = color->b = 255; + } else { + src = &sColors[i][paramsColorIdx]; + color->r = src->r; + color->g = src->g; + color->b = src->b; + } +} + +void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjOshihiki* pthis = (ObjOshihiki*)thisx; + + ObjOshihiki_CheckType(pthis, globalCtx); + + if ((((pthis->dyna.actor.params >> 8) & 0xFF) >= 0) && (((pthis->dyna.actor.params >> 8) & 0xFF) <= 0x3F)) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8) & 0x3F)) { + switch (pthis->dyna.actor.params & 0xF) { + case PUSHBLOCK_SMALL_START_ON: + case PUSHBLOCK_MEDIUM_START_ON: + case PUSHBLOCK_LARGE_START_ON: + case PUSHBLOCK_HUGE_START_ON: + Actor_Kill(&pthis->dyna.actor); + return; + } + } else { + switch (pthis->dyna.actor.params & 0xF) { + case PUSHBLOCK_SMALL_START_OFF: + case PUSHBLOCK_MEDIUM_START_OFF: + case PUSHBLOCK_LARGE_START_OFF: + case PUSHBLOCK_HUGE_START_OFF: + Actor_Kill(&pthis->dyna.actor); + return; + } + } + } + + ObjOshihiki_SetScale(pthis, globalCtx); + ObjOshihiki_SetTexture(pthis, globalCtx); + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + pthis->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + ObjOshihiki_SetColor(pthis, globalCtx); + ObjOshihiki_ResetFloors(pthis); + ObjOshihiki_SetupOnActor(pthis, globalCtx); + // "(dungeon keep push-pull block)" + osSyncPrintf("(dungeon keep 押し引きブロック)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void ObjOshihiki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjOshihiki* pthis = (ObjOshihiki*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +void ObjOshihiki_SetFloors(ObjOshihiki* pthis, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < 5; i++) { + Vec3f colCheckPoint; + Vec3f colCheckOffset; + CollisionPoly** floorPoly; + s32* floorBgId; + + colCheckOffset.x = sColCheckPoints[i].x * (pthis->dyna.actor.scale.x * 10.0f); + colCheckOffset.y = sColCheckPoints[i].y * (pthis->dyna.actor.scale.y * 10.0f); + colCheckOffset.z = sColCheckPoints[i].z * (pthis->dyna.actor.scale.z * 10.0f); + ObjOshihiki_RotateXZ(&colCheckPoint, &colCheckOffset, pthis->yawSin, pthis->yawCos); + colCheckPoint.x += pthis->dyna.actor.world.pos.x; + colCheckPoint.y += pthis->dyna.actor.prevPos.y; + colCheckPoint.z += pthis->dyna.actor.world.pos.z; + + floorPoly = &pthis->floorPolys[i]; + floorBgId = &pthis->floorBgIds[i]; + pthis->floorHeights[i] = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, floorPoly, floorBgId, &pthis->dyna.actor, + &colCheckPoint, 0.0f); + } +} + +s16 ObjOshihiki_GetHighestFloor(ObjOshihiki* pthis) { + s16 highestFloor = 0; + s16 temp = 1; + f32 phi_f0 = pthis->floorHeights[temp]; + + if (phi_f0 > pthis->floorHeights[highestFloor]) { + highestFloor = temp; + } else if ((pthis->floorBgIds[temp] == BGCHECK_SCENE) && ((phi_f0 - pthis->floorHeights[highestFloor]) > -0.001f)) { + highestFloor = temp; + } + if (pthis->floorHeights[temp + 1] > pthis->floorHeights[highestFloor]) { + highestFloor = temp + 1; + } else if ((pthis->floorBgIds[temp + 1] == BGCHECK_SCENE) && + ((pthis->floorHeights[temp + 1] - pthis->floorHeights[highestFloor]) > -0.001f)) { + highestFloor = temp + 1; + } + if (pthis->floorHeights[temp + 2] > pthis->floorHeights[highestFloor]) { + highestFloor = temp + 2; + } else if ((pthis->floorBgIds[temp + 2] == BGCHECK_SCENE) && + ((pthis->floorHeights[temp + 2] - pthis->floorHeights[highestFloor]) > -0.001f)) { + highestFloor = temp + 2; + } + if (pthis->floorHeights[temp + 3] > pthis->floorHeights[highestFloor]) { + highestFloor = temp + 3; + } else if ((pthis->floorBgIds[temp + 3] == BGCHECK_SCENE) && + ((pthis->floorHeights[temp + 3] - pthis->floorHeights[highestFloor]) > -0.001f)) { + highestFloor = temp + 3; + } + return highestFloor; +} + +void ObjOshihiki_SetGround(ObjOshihiki* pthis, GlobalContext* globalCtx) { + ObjOshihiki_ResetFloors(pthis); + ObjOshihiki_SetFloors(pthis, globalCtx); + pthis->highestFloor = ObjOshihiki_GetHighestFloor(pthis); + pthis->dyna.actor.floorHeight = pthis->floorHeights[pthis->highestFloor]; +} + +s32 ObjOshihiki_CheckFloor(ObjOshihiki* pthis, GlobalContext* globalCtx) { + ObjOshihiki_SetGround(pthis, globalCtx); + + if ((pthis->dyna.actor.floorHeight - pthis->dyna.actor.world.pos.y) >= -0.001f) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + return 1; + } + + return 0; +} + +s32 ObjOshihiki_CheckGround(ObjOshihiki* pthis, GlobalContext* globalCtx) { + if (pthis->dyna.actor.world.pos.y <= BGCHECK_Y_MIN + 10.0f) { + // "Warning : Push-pull block fell too much" + osSyncPrintf("Warning : 押し引きブロック落ちすぎた(%s %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 809, + pthis->dyna.actor.params); + Actor_Kill(&pthis->dyna.actor); + return 0; + } + if ((pthis->dyna.actor.floorHeight - pthis->dyna.actor.world.pos.y) >= -0.001f) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + return 1; + } + return 0; +} + +s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, ObjOshihiki* pthis) { + f32 maxDist = ((direction >= 0.0f) ? 1.0f : -1.0f) * (300.0f * pthis->dyna.actor.scale.x + 20.0f - 0.5f); + f32 sn = Math_SinS(angle); + f32 cs = Math_CosS(angle); + s32 i; + + for (i = 0; i < 4; i++) { + Vec3f faceVtx; + Vec3f faceVtxNext; + Vec3f posResult; + Vec3f faceVtxOffset; + s32 bgId; + CollisionPoly* outPoly; + + faceVtxOffset.x = (sFaceVtx[i].x * pthis->dyna.actor.scale.x * 10.0f) + sFaceDirection[i].x; + faceVtxOffset.y = (sFaceVtx[i].y * pthis->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].y; + faceVtxOffset.z = 0.0f; + ObjOshihiki_RotateXZ(&faceVtx, &faceVtxOffset, sn, cs); + faceVtx.x += pthis->dyna.actor.world.pos.x; + faceVtx.y += pthis->dyna.actor.world.pos.y; + faceVtx.z += pthis->dyna.actor.world.pos.z; + faceVtxNext.x = faceVtx.x + maxDist * sn; + faceVtxNext.y = faceVtx.y; + faceVtxNext.z = faceVtx.z + maxDist * cs; + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, true, false, + false, true, &bgId, &pthis->dyna.actor, 0.0f)) { + return true; + } + } + return false; +} + +s32 ObjOshihiki_MoveWithBlockUnder(ObjOshihiki* pthis, GlobalContext* globalCtx) { + s32 pad; + ObjOshihiki* blockUnder = ObjOshihiki_GetBlockUnder(pthis, globalCtx); + + if ((blockUnder != NULL) && (blockUnder->stateFlags & PUSHBLOCK_SETUP_PUSH) && + !ObjOshihiki_CheckWall(globalCtx, blockUnder->dyna.unk_158, blockUnder->direction, pthis)) { + pthis->blockUnder = blockUnder; + } + + if ((pthis->stateFlags & PUSHBLOCK_MOVE_UNDER) && (pthis->blockUnder != NULL)) { + if (pthis->blockUnder->stateFlags & PUSHBLOCK_PUSH) { + pthis->underDistX = pthis->blockUnder->dyna.actor.world.pos.x - pthis->blockUnder->dyna.actor.prevPos.x; + pthis->underDistZ = pthis->blockUnder->dyna.actor.world.pos.z - pthis->blockUnder->dyna.actor.prevPos.z; + pthis->dyna.actor.world.pos.x += pthis->underDistX; + pthis->dyna.actor.world.pos.z += pthis->underDistZ; + ObjOshihiki_UpdateInitPos(pthis); + return true; + } else if (!(pthis->blockUnder->stateFlags & PUSHBLOCK_SETUP_PUSH)) { + pthis->blockUnder = NULL; + } + } + return false; +} + +void ObjOshihiki_SetupOnScene(ObjOshihiki* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= PUSHBLOCK_SETUP_ON_SCENE; + pthis->actionFunc = ObjOshihiki_OnScene; + pthis->dyna.actor.gravity = 0.0f; + pthis->dyna.actor.velocity.x = pthis->dyna.actor.velocity.y = pthis->dyna.actor.velocity.z = 0.0f; +} + +void ObjOshihiki_OnScene(ObjOshihiki* pthis, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + pthis->stateFlags |= PUSHBLOCK_ON_SCENE; + if ((pthis->timer <= 0) && (fabsf(pthis->dyna.unk_150) > 0.001f)) { + if (ObjOshihiki_StrongEnough(pthis) && + !ObjOshihiki_CheckWall(globalCtx, pthis->dyna.unk_158, pthis->dyna.unk_150, pthis)) { + pthis->direction = pthis->dyna.unk_150; + ObjOshihiki_SetupPush(pthis, globalCtx); + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } +} + +void ObjOshihiki_SetupOnActor(ObjOshihiki* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= PUSHBLOCK_SETUP_ON_ACTOR; + pthis->actionFunc = ObjOshihiki_OnActor; + pthis->dyna.actor.velocity.x = pthis->dyna.actor.velocity.y = pthis->dyna.actor.velocity.z = 0.0f; + pthis->dyna.actor.gravity = -1.0f; +} + +void ObjOshihiki_OnActor(ObjOshihiki* pthis, GlobalContext* globalCtx) { + s32 bgId; + Player* player = GET_PLAYER(globalCtx); + DynaPolyActor* dynaPolyActor; + + pthis->stateFlags |= PUSHBLOCK_ON_ACTOR; + Actor_MoveForward(&pthis->dyna.actor); + + if (ObjOshihiki_CheckFloor(pthis, globalCtx)) { + bgId = pthis->floorBgIds[pthis->highestFloor]; + if (bgId == BGCHECK_SCENE) { + ObjOshihiki_SetupOnScene(pthis, globalCtx); + } else { + dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if (dynaPolyActor != NULL) { + func_800434A8(dynaPolyActor); + func_80043538(dynaPolyActor); + + if ((pthis->timer <= 0) && (fabsf(pthis->dyna.unk_150) > 0.001f)) { + if (ObjOshihiki_StrongEnough(pthis) && ObjOshihiki_NoSwitchPress(pthis, dynaPolyActor, globalCtx) && + !ObjOshihiki_CheckWall(globalCtx, pthis->dyna.unk_158, pthis->dyna.unk_150, pthis)) { + + pthis->direction = pthis->dyna.unk_150; + ObjOshihiki_SetupPush(pthis, globalCtx); + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } + } else { + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + } + } else { + ObjOshihiki_SetupOnScene(pthis, globalCtx); + } + } + } else { + bgId = pthis->floorBgIds[pthis->highestFloor]; + if (bgId == BGCHECK_SCENE) { + ObjOshihiki_SetupFall(pthis, globalCtx); + } else { + dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + + if ((dynaPolyActor != NULL) && (dynaPolyActor->unk_15C & 1)) { + func_800434A8(dynaPolyActor); + func_80043538(dynaPolyActor); + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.floorHeight; + } else { + ObjOshihiki_SetupFall(pthis, globalCtx); + } + } + } +} + +void ObjOshihiki_SetupPush(ObjOshihiki* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= PUSHBLOCK_SETUP_PUSH; + pthis->actionFunc = ObjOshihiki_Push; + pthis->dyna.actor.gravity = 0.0f; +} + +void ObjOshihiki_Push(ObjOshihiki* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + Player* player = GET_PLAYER(globalCtx); + f32 pushDistSigned; + s32 stopFlag; + + pthis->pushSpeed += 0.5f; + pthis->stateFlags |= PUSHBLOCK_PUSH; + pthis->pushSpeed = CLAMP_MAX(pthis->pushSpeed, 2.0f); + stopFlag = Math_StepToF(&pthis->pushDist, 20.0f, pthis->pushSpeed); + pushDistSigned = ((pthis->direction >= 0.0f) ? 1.0f : -1.0f) * pthis->pushDist; + thisx->world.pos.x = thisx->home.pos.x + (pushDistSigned * pthis->yawSin); + thisx->world.pos.z = thisx->home.pos.z + (pushDistSigned * pthis->yawCos); + + if (!ObjOshihiki_CheckFloor(pthis, globalCtx)) { + thisx->home.pos.x = thisx->world.pos.x; + thisx->home.pos.z = thisx->world.pos.z; + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + pthis->pushDist = 0.0f; + pthis->pushSpeed = 0.0f; + ObjOshihiki_SetupFall(pthis, globalCtx); + } else if (stopFlag) { + player = GET_PLAYER(globalCtx); + if (ObjOshihiki_CheckWall(globalCtx, pthis->dyna.unk_158, pthis->dyna.unk_150, pthis)) { + Audio_PlayActorSound2(thisx, NA_SE_EV_BLOCK_BOUND); + } + + thisx->home.pos.x = thisx->world.pos.x; + thisx->home.pos.z = thisx->world.pos.z; + player->stateFlags2 &= ~0x10; + pthis->dyna.unk_150 = 0.0f; + pthis->pushDist = 0.0f; + pthis->pushSpeed = 0.0f; + pthis->timer = 10; + if (pthis->floorBgIds[pthis->highestFloor] == BGCHECK_SCENE) { + ObjOshihiki_SetupOnScene(pthis, globalCtx); + } else { + ObjOshihiki_SetupOnActor(pthis, globalCtx); + } + } + Audio_PlayActorSound2(thisx, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); +} + +void ObjOshihiki_SetupFall(ObjOshihiki* pthis, GlobalContext* globalCtx) { + pthis->stateFlags |= PUSHBLOCK_SETUP_FALL; + pthis->dyna.actor.velocity.x = pthis->dyna.actor.velocity.y = pthis->dyna.actor.velocity.z = 0.0f; + pthis->dyna.actor.gravity = -1.0f; + ObjOshihiki_SetGround(pthis, globalCtx); + pthis->actionFunc = ObjOshihiki_Fall; +} + +void ObjOshihiki_Fall(ObjOshihiki* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + pthis->stateFlags |= PUSHBLOCK_FALL; + if (fabsf(pthis->dyna.unk_150) > 0.001f) { + pthis->dyna.unk_150 = 0.0f; + player->stateFlags2 &= ~0x10; + } + Actor_MoveForward(&pthis->dyna.actor); + if (ObjOshihiki_CheckGround(pthis, globalCtx)) { + if (pthis->floorBgIds[pthis->highestFloor] == BGCHECK_SCENE) { + ObjOshihiki_SetupOnScene(pthis, globalCtx); + } else { + ObjOshihiki_SetupOnActor(pthis, globalCtx); + } + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Audio_PlayActorSound2(&pthis->dyna.actor, + SurfaceType_GetSfx(&globalCtx->colCtx, pthis->floorPolys[pthis->highestFloor], + pthis->floorBgIds[pthis->highestFloor]) + + SFX_FLAG); + } +} + +void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjOshihiki* pthis = (ObjOshihiki*)thisx; + + pthis->stateFlags &= + ~(PUSHBLOCK_SETUP_FALL | PUSHBLOCK_FALL | PUSHBLOCK_SETUP_PUSH | PUSHBLOCK_PUSH | PUSHBLOCK_SETUP_ON_ACTOR | + PUSHBLOCK_ON_ACTOR | PUSHBLOCK_SETUP_ON_SCENE | PUSHBLOCK_ON_SCENE); + pthis->stateFlags |= PUSHBLOCK_MOVE_UNDER; + + if (pthis->timer > 0) { + pthis->timer--; + } + + pthis->dyna.actor.world.rot.y = pthis->dyna.unk_158; + + pthis->yawSin = Math_SinS(pthis->dyna.actor.world.rot.y); + pthis->yawCos = Math_CosS(pthis->dyna.actor.world.rot.y); + + if (pthis->actionFunc != NULL) { + pthis->actionFunc(pthis, globalCtx); + } +} + +void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjOshihiki* pthis = (ObjOshihiki*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_oshihiki.c", 1289); + if (ObjOshihiki_MoveWithBlockUnder(pthis, globalCtx)) { + Matrix_Translate(pthis->underDistX * 10.0f, 0.0f, pthis->underDistZ * 10.0f, MTXMODE_APPLY); + } + pthis->stateFlags &= ~PUSHBLOCK_MOVE_UNDER; + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(pthis->texture)); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_oshihiki.c", 1308), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + switch (globalCtx->sceneNum) { + case SCENE_YDAN: + case SCENE_DDAN: + case SCENE_BMORI1: + case SCENE_HIDAN: + case SCENE_MIZUSIN: + case SCENE_JYASINZOU: + case SCENE_HAKADAN: + case SCENE_MEN: + gDPSetEnvColor(POLY_OPA_DISP++, pthis->color.r, pthis->color.g, pthis->color.b, 255); + break; + default: + gDPSetEnvColor(POLY_OPA_DISP++, mREG(13), mREG(14), mREG(15), 255); + break; + } + + gSPDisplayList(POLY_OPA_DISP++, gPushBlockDL); + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_oshihiki.c", 1334); +} diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.cpp similarity index 51% rename from src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c rename to src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.cpp index 0b51d207a..be3014a04 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.cpp @@ -20,10 +20,10 @@ void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx); void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80B9D054(ObjRoomtimer* this, GlobalContext* globalCtx); -void func_80B9D0B0(ObjRoomtimer* this, GlobalContext* globalCtx); +void func_80B9D054(ObjRoomtimer* pthis, GlobalContext* globalCtx); +void func_80B9D0B0(ObjRoomtimer* pthis, GlobalContext* globalCtx); -const ActorInit Obj_Roomtimer_InitVars = { +ActorInit Obj_Roomtimer_InitVars = { ACTOR_OBJ_ROOMTIMER, ACTORCAT_ENEMY, FLAGS, @@ -36,61 +36,61 @@ const ActorInit Obj_Roomtimer_InitVars = { }; void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjRoomtimer* this = (ObjRoomtimer*)thisx; - s16 params = this->actor.params; + ObjRoomtimer* pthis = (ObjRoomtimer*)thisx; + s16 params = pthis->actor.params; - this->switchFlag = (params >> 10) & 0x3F; - this->actor.params = params & 0x3FF; - params = this->actor.params; + pthis->switchFlag = (params >> 10) & 0x3F; + pthis->actor.params = params & 0x3FF; + params = pthis->actor.params; if (params != 0x3FF) { if (params > 600) { - this->actor.params = 600; + pthis->actor.params = 600; } else { - this->actor.params = params; + pthis->actor.params = params; } } - this->actionFunc = func_80B9D054; + pthis->actionFunc = func_80B9D054; } void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjRoomtimer* this = (ObjRoomtimer*)thisx; + ObjRoomtimer* pthis = (ObjRoomtimer*)thisx; - if ((this->actor.params != 0x3FF) && (gSaveContext.timer1Value > 0)) { + if ((pthis->actor.params != 0x3FF) && (gSaveContext.timer1Value > 0)) { gSaveContext.timer1State = 10; } } -void func_80B9D054(ObjRoomtimer* this, GlobalContext* globalCtx) { - if (this->actor.params != 0x3FF) { - func_80088B34(this->actor.params); +void func_80B9D054(ObjRoomtimer* pthis, GlobalContext* globalCtx) { + if (pthis->actor.params != 0x3FF) { + func_80088B34(pthis->actor.params); } - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - this->actionFunc = func_80B9D0B0; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_PROP); + pthis->actionFunc = func_80B9D0B0; } -void func_80B9D0B0(ObjRoomtimer* this, GlobalContext* globalCtx) { - if (Flags_GetTempClear(globalCtx, this->actor.room)) { - if (this->actor.params != 0x3FF) { +void func_80B9D0B0(ObjRoomtimer* pthis, GlobalContext* globalCtx) { + if (Flags_GetTempClear(globalCtx, pthis->actor.room)) { + if (pthis->actor.params != 0x3FF) { gSaveContext.timer1State = 10; } - Flags_SetClear(globalCtx, this->actor.room); - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetClear(globalCtx, pthis->actor.room); + Flags_SetSwitch(globalCtx, pthis->switchFlag); func_80078884(NA_SE_SY_CORRECT_CHIME); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - if ((this->actor.params != 0x3FF) && (gSaveContext.timer1Value == 0)) { + if ((pthis->actor.params != 0x3FF) && (gSaveContext.timer1Value == 0)) { Audio_PlaySoundGeneral(NA_SE_OC_ABYSS, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Gameplay_TriggerVoidOut(globalCtx); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } } void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjRoomtimer* this = (ObjRoomtimer*)thisx; + ObjRoomtimer* pthis = (ObjRoomtimer*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c deleted file mode 100644 index 849f20a7e..000000000 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ /dev/null @@ -1,807 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_SWITCH_Z_OBJ_SWITCH_C -#include "actor_common.h" -/* - * File: z_obj_switch.c - * Overlay: ovl_Obj_Switch - * Description: Switches - */ - -#include "z_obj_switch.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/code_800A9F30.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_lib.h" -#include "def/z_onepointdemo.h" -#include "def/z_player_lib.h" -#include "def/z_rcp.h" - -#define FLAGS ACTOR_FLAG_4 - -// type: (this->dyna.actor.params & 7) -// subtype: (this->dyna.actor.params >> 4 & 7) -// switch flag: (this->dyna.actor.params >> 8 & 0x3F) -// frozen: this->dyna.actor.params >> 7 & 1 - -void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjSwitch_FloorUpInit(ObjSwitch* this); -void ObjSwitch_FloorUp(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_FloorPressInit(ObjSwitch* this); -void ObjSwitch_FloorPress(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_FloorDownInit(ObjSwitch* this); -void ObjSwitch_FloorDown(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_FloorReleaseInit(ObjSwitch* this); -void ObjSwitch_FloorRelease(ObjSwitch* this, GlobalContext* globalCtx); - -void ObjSwitch_EyeFrozenInit(ObjSwitch* this); -void ObjSwitch_EyeInit(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_EyeOpenInit(ObjSwitch* this); -void ObjSwitch_EyeOpen(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_EyeClosingInit(ObjSwitch* this); -void ObjSwitch_EyeClosing(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_EyeClosedInit(ObjSwitch* this); -void ObjSwitch_EyeClosed(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_EyeOpeningInit(ObjSwitch* this); -void ObjSwitch_EyeOpening(ObjSwitch* this, GlobalContext* globalCtx); - -void ObjSwitch_CrystalOffInit(ObjSwitch* this); -void ObjSwitch_CrystalOff(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_CrystalTurnOnInit(ObjSwitch* this); -void ObjSwitch_CrystalTurnOn(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_CrystalOnInit(ObjSwitch* this); -void ObjSwitch_CrystalOn(ObjSwitch* this, GlobalContext* globalCtx); -void ObjSwitch_CrystalTurnOffInit(ObjSwitch* this); -void ObjSwitch_CrystalTurnOff(ObjSwitch* this, GlobalContext* globalCtx); - -const ActorInit Obj_Switch_InitVars = { - ACTOR_OBJ_SWITCH, - ACTORCAT_SWITCH, - FLAGS, - OBJECT_GAMEPLAY_DANGEON_KEEP, - sizeof(ObjSwitch), - (ActorFunc)ObjSwitch_Init, - (ActorFunc)ObjSwitch_Destroy, - (ActorFunc)ObjSwitch_Update, - (ActorFunc)ObjSwitch_Draw, -}; - -static f32 sHeights[] = { 10, 10, 0, 30, 30 }; - -static ColliderTrisElementInit D_80B9EC34[2] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x40000040, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { -20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, 20.0f } } }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x40000040, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, -20.0f } } }, - }, -}; - -static ColliderTrisInit sRustyFloorTrisInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 2, - D_80B9EC34, -}; - -static ColliderTrisElementInit D_80B9ECBC[2] = { - { - { - ELEMTYPE_UNK4, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, - }, - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x0001F824, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, - }, -}; - -static ColliderTrisInit trisColliderEye = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_NONE, - OC2_NONE, - COLSHAPE_TRIS, - }, - 2, - D_80B9ECBC, -}; - -static ColliderJntSphElementInit D_80B9ED44[1] = { - { - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xEFC1FFFE, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 0, { { 0, 300, 0 }, 20 }, 100 }, - }, -}; - -static ColliderJntSphInit sCyrstalJntSphereInit = { - { - COLTYPE_METAL, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - 1, - D_80B9ED44, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 2000, ICHAIN_STOP), -}; - -void ObjSwitch_RotateY(Vec3f* dest, Vec3f* src, s16 angle) { - f32 s = Math_SinS(angle); - f32 c = Math_CosS(angle); - - dest->x = src->z * s + src->x * c; - dest->y = src->y; - dest->z = src->z * c - src->x * s; -} - -void ObjSwitch_InitDynapoly(ObjSwitch* this, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { - s32 pad; - CollisionHeader* colHeader = NULL; - s32 pad2; - - DynaPolyActor_Init(&this->dyna, moveFlag); - CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - if (this->dyna.bgId == BG_ACTOR_MAX) { - // "Warning : move BG registration failure" - osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_switch.c", 531, - this->dyna.actor.id, this->dyna.actor.params); - } -} - -void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderJntSphInit* colliderJntSphInit) { - ColliderJntSph* colliderJntSph = &this->jntSph.col; - - Collider_InitJntSph(globalCtx, colliderJntSph); - Collider_SetJntSph(globalCtx, colliderJntSph, &this->dyna.actor, colliderJntSphInit, this->jntSph.items); - func_800D1694(this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); - Collider_UpdateSpheres(0, colliderJntSph); -} - -void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderTrisInit* colliderTrisInit) { - ColliderTris* colliderTris = &this->tris.col; - s32 i; - s32 j; - Vec3f pos[3]; - - Collider_InitTris(globalCtx, colliderTris); - Collider_SetTris(globalCtx, colliderTris, &this->dyna.actor, colliderTrisInit, this->tris.items); - - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - ObjSwitch_RotateY(&pos[j], &colliderTrisInit->elements[i].dim.vtx[j], this->dyna.actor.home.rot.y); - Math_Vec3f_Sum(&pos[j], &this->dyna.actor.world.pos, &pos[j]); - } - - Collider_SetTrisVertices(colliderTris, i, &pos[0], &pos[1], &pos[2]); - } -} - -Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { - Actor* thisx = &this->dyna.actor; - - return Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_OBJ_ICE_POLY, thisx->world.pos.x, - thisx->world.pos.y, thisx->world.pos.z, thisx->world.rot.x, thisx->world.rot.y, - thisx->world.rot.z, (this->dyna.actor.params >> 8 & 0x3F) << 8); -} - -void ObjSwitch_SetOn(ObjSwitch* this, GlobalContext* globalCtx) { - s32 pad; - s32 subType; - - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - this->cooldownOn = false; - } else { - subType = (this->dyna.actor.params >> 4 & 7); - Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F)); - - if (subType == 0 || subType == 4) { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->dyna.actor, NA_SE_SY_CORRECT_CHIME); - } else { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); - } - - this->cooldownOn = true; - } -} - -void ObjSwitch_SetOff(ObjSwitch* this, GlobalContext* globalCtx) { - this->cooldownOn = false; - - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - Flags_UnsetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F)); - - if ((this->dyna.actor.params >> 4 & 7) == 1) { - OnePointCutscene_AttentionSetSfx(globalCtx, &this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); - this->cooldownOn = true; - } - } -} - -void ObjSwitch_UpdateTwoTexScrollXY(ObjSwitch* this) { - this->x1TexScroll = (this->x1TexScroll - 1) & 0x7F; - this->y1TexScroll = (this->y1TexScroll + 1) & 0x7F; - this->x2TexScroll = (this->x2TexScroll + 1) & 0x7F; - this->y2TexScroll = (this->y2TexScroll - 1) & 0x7F; -} - -void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjSwitch* this = (ObjSwitch*)thisx; - s32 switchFlagSet; - s32 type; - - switchFlagSet = Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F)); - type = (this->dyna.actor.params & 7); - - if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { - ObjSwitch_InitDynapoly(this, globalCtx, &gFloorSwitchCol, DPM_PLAYER); - } - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - - if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; - } - - Actor_SetFocus(&this->dyna.actor, sHeights[type]); - - if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { - ObjSwitch_InitTrisCollider(this, globalCtx, &sRustyFloorTrisInit); - } else if (type == OBJSWITCH_TYPE_EYE) { - ObjSwitch_InitTrisCollider(this, globalCtx, &trisColliderEye); - } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { - ObjSwitch_InitJntSphCollider(this, globalCtx, &sCyrstalJntSphereInit); - } - - if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { - this->dyna.actor.flags |= ACTOR_FLAG_0; - this->dyna.actor.targetMode = 4; - } - - this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - - if ((this->dyna.actor.params >> 7 & 1) && (ObjSwitch_SpawnIce(this, globalCtx) == NULL)) { - osSyncPrintf(VT_FGCOL(RED)); - osSyncPrintf("Error : 氷発生失敗 (%s %d)\n", "../z_obj_switch.c", 732); - osSyncPrintf(VT_RST); - this->dyna.actor.params &= ~0x80; - } - - if (this->dyna.actor.params >> 7 & 1) { - ObjSwitch_EyeFrozenInit(this); - } else if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { - if (switchFlagSet) { - ObjSwitch_FloorDownInit(this); - } else { - ObjSwitch_FloorUpInit(this); - } - } else if (type == OBJSWITCH_TYPE_EYE) { - if (switchFlagSet) { - ObjSwitch_EyeClosedInit(this); - } else { - ObjSwitch_EyeOpenInit(this); - } - } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { - if (switchFlagSet) { - ObjSwitch_CrystalOnInit(this); - } else { - ObjSwitch_CrystalOffInit(this); - } - } - - osSyncPrintf("(Dungeon switch)(arg_data 0x%04x)\n", this->dyna.actor.params); -} - -void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjSwitch* this = (ObjSwitch*)thisx; - - switch ((this->dyna.actor.params & 7)) { - case OBJSWITCH_TYPE_FLOOR: - case OBJSWITCH_TYPE_FLOOR_RUSTY: - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - break; - } - - switch ((this->dyna.actor.params & 7)) { - case OBJSWITCH_TYPE_FLOOR_RUSTY: - case OBJSWITCH_TYPE_EYE: - Collider_DestroyTris(globalCtx, &this->tris.col); - break; - case OBJSWITCH_TYPE_CRYSTAL: - case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: - Collider_DestroyJntSph(globalCtx, &this->jntSph.col); - break; - } -} - -void ObjSwitch_FloorUpInit(ObjSwitch* this) { - this->dyna.actor.scale.y = 33.0f / 200.0f; - this->actionFunc = ObjSwitch_FloorUp; -} - -void ObjSwitch_FloorUp(ObjSwitch* this, GlobalContext* globalCtx) { - if ((this->dyna.actor.params & 7) == OBJSWITCH_TYPE_FLOOR_RUSTY) { - if (this->tris.col.base.acFlags & AC_HIT) { - ObjSwitch_FloorPressInit(this); - ObjSwitch_SetOn(this, globalCtx); - this->tris.col.base.acFlags &= ~AC_HIT; - } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->tris.col.base); - } - } else { - switch ((this->dyna.actor.params >> 4 & 7)) { - case OBJSWITCH_SUBTYPE_FLOOR_0: - if (func_8004356C(&this->dyna)) { - ObjSwitch_FloorPressInit(this); - ObjSwitch_SetOn(this, globalCtx); - } - break; - case OBJSWITCH_SUBTYPE_FLOOR_1: - if ((this->dyna.unk_160 & 2) && !(this->unk_17F & 2)) { - ObjSwitch_FloorPressInit(this); - ObjSwitch_SetOn(this, globalCtx); - } - break; - case OBJSWITCH_SUBTYPE_FLOOR_2: - if (func_800435B4(&this->dyna)) { - ObjSwitch_FloorPressInit(this); - ObjSwitch_SetOn(this, globalCtx); - } - break; - case OBJSWITCH_SUBTYPE_FLOOR_3: - if (func_800435B4(&this->dyna)) { - ObjSwitch_FloorPressInit(this); - ObjSwitch_SetOff(this, globalCtx); - } - break; - } - } -} - -void ObjSwitch_FloorPressInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_FloorPress; - this->cooldownTimer = 100; -} - -void ObjSwitch_FloorPress(ObjSwitch* this, GlobalContext* globalCtx) { - if ((this->dyna.actor.params >> 4 & 7) == OBJSWITCH_SUBTYPE_FLOOR_3 || !this->cooldownOn || - func_8005B198() == this->dyna.actor.category || this->cooldownTimer <= 0) { - this->dyna.actor.scale.y -= 99.0f / 2000.0f; - if (this->dyna.actor.scale.y <= 33.0f / 2000.0f) { - ObjSwitch_FloorDownInit(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); - } - } -} - -void ObjSwitch_FloorDownInit(ObjSwitch* this) { - this->dyna.actor.scale.y = 33.0f / 2000.0f; - this->releaseTimer = 6; - this->actionFunc = ObjSwitch_FloorDown; -} - -void ObjSwitch_FloorDown(ObjSwitch* this, GlobalContext* globalCtx) { - switch ((this->dyna.actor.params >> 4 & 7)) { - case OBJSWITCH_SUBTYPE_FLOOR_0: - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - ObjSwitch_FloorReleaseInit(this); - } - break; - case OBJSWITCH_SUBTYPE_FLOOR_1: - if ((this->dyna.unk_160 & 2) && !(this->unk_17F & 2)) { - ObjSwitch_FloorReleaseInit(this); - ObjSwitch_SetOff(this, globalCtx); - } - break; - case OBJSWITCH_SUBTYPE_FLOOR_2: - case OBJSWITCH_SUBTYPE_FLOOR_3: - if (!func_800435B4(&this->dyna) && !Player_InCsMode(globalCtx)) { - if (this->releaseTimer <= 0) { - ObjSwitch_FloorReleaseInit(this); - if ((this->dyna.actor.params >> 4 & 7) == OBJSWITCH_SUBTYPE_FLOOR_2) { - ObjSwitch_SetOff(this, globalCtx); - } else { - ObjSwitch_SetOn(this, globalCtx); - } - } - } else { - this->releaseTimer = 6; - } - break; - } -} - -void ObjSwitch_FloorReleaseInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_FloorRelease; - this->cooldownTimer = 100; -} - -void ObjSwitch_FloorRelease(ObjSwitch* this, GlobalContext* globalCtx) { - s16 subType = (this->dyna.actor.params >> 4 & 7); - - if (((subType != OBJSWITCH_SUBTYPE_FLOOR_1) && (subType != OBJSWITCH_SUBTYPE_FLOOR_3)) || !this->cooldownOn || - func_8005B198() == this->dyna.actor.category || this->cooldownTimer <= 0) { - this->dyna.actor.scale.y += 99.0f / 2000.0f; - if (this->dyna.actor.scale.y >= 33.0f / 200.0f) { - ObjSwitch_FloorUpInit(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - if (subType == OBJSWITCH_SUBTYPE_FLOOR_1) { - func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); - } - } - } -} - -s32 ObjSwitch_EyeIsHit(ObjSwitch* this) { - Actor* collidingActor; - s16 yawDiff; - - if ((this->tris.col.base.acFlags & AC_HIT) && !(this->unk_17F & 2)) { - collidingActor = this->tris.col.base.ac; - if (collidingActor != NULL) { - yawDiff = collidingActor->world.rot.y - this->dyna.actor.shape.rot.y; - if (ABS(yawDiff) > 0x5000) { - return 1; - } - } - } - return 0; -} - -void ObjSwitch_EyeFrozenInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_EyeInit; -} - -void ObjSwitch_EyeInit(ObjSwitch* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - ObjSwitch_EyeClosedInit(this); - } else { - ObjSwitch_EyeOpenInit(this); - } -} - -void ObjSwitch_EyeOpenInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_EyeOpen; - this->eyeTexIndex = 0; -} - -void ObjSwitch_EyeOpen(ObjSwitch* this, GlobalContext* globalCtx) { - if (ObjSwitch_EyeIsHit(this) || (this->dyna.actor.params >> 7 & 1)) { - ObjSwitch_EyeClosingInit(this); - ObjSwitch_SetOn(this, globalCtx); - this->dyna.actor.params &= ~0x80; - } -} - -void ObjSwitch_EyeClosingInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_EyeClosing; - this->cooldownTimer = 100; -} - -void ObjSwitch_EyeClosing(ObjSwitch* this, GlobalContext* globalCtx) { - if (!this->cooldownOn || func_8005B198() == this->dyna.actor.category || this->cooldownTimer <= 0) { - this->eyeTexIndex++; - if (this->eyeTexIndex >= 3) { - ObjSwitch_EyeClosedInit(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - } - } -} - -void ObjSwitch_EyeClosedInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_EyeClosed; - this->eyeTexIndex = 3; -} - -void ObjSwitch_EyeClosed(ObjSwitch* this, GlobalContext* globalCtx) { - switch ((this->dyna.actor.params >> 4 & 7)) { - case OBJSWITCH_SUBTYPE_EYE_0: - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - ObjSwitch_EyeOpeningInit(this); - this->dyna.actor.params &= ~0x80; - } - break; - case OBJSWITCH_SUBTYPE_EYE_1: - if (ObjSwitch_EyeIsHit(this) || (this->dyna.actor.params >> 7 & 1)) { - ObjSwitch_EyeOpeningInit(this); - ObjSwitch_SetOff(this, globalCtx); - this->dyna.actor.params &= ~0x80; - } - break; - } -} - -void ObjSwitch_EyeOpeningInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_EyeOpening; - this->cooldownTimer = 100; -} - -void ObjSwitch_EyeOpening(ObjSwitch* this, GlobalContext* globalCtx) { - if ((this->dyna.actor.params >> 4 & 7) != OBJSWITCH_SUBTYPE_EYE_1 || !this->cooldownOn || - func_8005B198() == this->dyna.actor.category || this->cooldownTimer <= 0) { - this->eyeTexIndex--; - if (this->eyeTexIndex <= 0) { - ObjSwitch_EyeOpenInit(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); - } - } -} - -void ObjSwitch_CrystalOffInit(ObjSwitch* this) { - this->crystalColor.r = 0; - this->crystalColor.g = 0; - this->crystalColor.b = 0; - this->crystalSubtype1texture = gCrstalSwitchRedTex; - this->actionFunc = ObjSwitch_CrystalOff; -} - -void ObjSwitch_CrystalOff(ObjSwitch* this, GlobalContext* globalCtx) { - switch ((this->dyna.actor.params >> 4 & 7)) { - case OBJSWITCH_SUBTYPE_CRYSTAL_0: - if ((this->jntSph.col.base.acFlags & AC_HIT) && this->disableAcTimer <= 0) { - this->disableAcTimer = 10; - ObjSwitch_SetOn(this, globalCtx); - ObjSwitch_CrystalTurnOnInit(this); - } - break; - case OBJSWITCH_SUBTYPE_CRYSTAL_4: - if (((this->jntSph.col.base.acFlags & AC_HIT) && this->disableAcTimer <= 0) || - Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - this->disableAcTimer = 10; - ObjSwitch_SetOn(this, globalCtx); - ObjSwitch_CrystalTurnOnInit(this); - } - break; - case OBJSWITCH_SUBTYPE_CRYSTAL_1: - if ((this->jntSph.col.base.acFlags & AC_HIT) && !(this->unk_17F & 2) && this->disableAcTimer <= 0) { - this->disableAcTimer = 10; - ObjSwitch_SetOn(this, globalCtx); - ObjSwitch_CrystalTurnOnInit(this); - } - ObjSwitch_UpdateTwoTexScrollXY(this); - break; - } -} - -void ObjSwitch_CrystalTurnOnInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_CrystalTurnOn; - this->cooldownTimer = 100; -} - -void ObjSwitch_CrystalTurnOn(ObjSwitch* this, GlobalContext* globalCtx) { - if (!this->cooldownOn || func_8005B198() == this->dyna.actor.category || this->cooldownTimer <= 0) { - ObjSwitch_CrystalOnInit(this); - if ((this->dyna.actor.params >> 4 & 7) == OBJSWITCH_SUBTYPE_CRYSTAL_1) { - ObjSwitch_UpdateTwoTexScrollXY(this); - } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); - } -} - -void ObjSwitch_CrystalOnInit(ObjSwitch* this) { - this->crystalColor.r = 255; - this->crystalColor.g = 255; - this->crystalColor.b = 255; - this->crystalSubtype1texture = gCrstalSwitchBlueTex; - this->actionFunc = ObjSwitch_CrystalOn; -} - -void ObjSwitch_CrystalOn(ObjSwitch* this, GlobalContext* globalCtx) { - switch ((this->dyna.actor.params >> 4 & 7)) { - case OBJSWITCH_SUBTYPE_CRYSTAL_0: - case OBJSWITCH_SUBTYPE_CRYSTAL_4: - if (!Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8 & 0x3F))) { - ObjSwitch_CrystalTurnOffInit(this); - } - break; - case OBJSWITCH_SUBTYPE_CRYSTAL_1: - if ((this->jntSph.col.base.acFlags & AC_HIT) && !(this->unk_17F & 2) && this->disableAcTimer <= 0) { - this->disableAcTimer = 10; - globalCtx = globalCtx; - ObjSwitch_CrystalTurnOffInit(this); - ObjSwitch_SetOff(this, globalCtx); - } - break; - } - ObjSwitch_UpdateTwoTexScrollXY(this); -} - -void ObjSwitch_CrystalTurnOffInit(ObjSwitch* this) { - this->actionFunc = ObjSwitch_CrystalTurnOff; - this->cooldownTimer = 100; -} - -void ObjSwitch_CrystalTurnOff(ObjSwitch* this, GlobalContext* globalCtx) { - if ((this->dyna.actor.params >> 4 & 7) != OBJSWITCH_SUBTYPE_CRYSTAL_1 || !this->cooldownOn || - func_8005B198() == this->dyna.actor.category || this->cooldownTimer <= 0) { - ObjSwitch_CrystalOffInit(this); - ObjSwitch_UpdateTwoTexScrollXY(this); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); - } -} - -void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjSwitch* this = (ObjSwitch*)thisx; - - if (this->releaseTimer > 0) { - this->releaseTimer--; - } - if (this->cooldownTimer > 0) { - this->cooldownTimer--; - } - - this->actionFunc(this, globalCtx); - - switch ((this->dyna.actor.params & 7)) { - case OBJSWITCH_TYPE_FLOOR: - case OBJSWITCH_TYPE_FLOOR_RUSTY: - this->unk_17F = this->dyna.unk_160; - break; - case OBJSWITCH_TYPE_EYE: - this->unk_17F = this->tris.col.base.acFlags; - this->tris.col.base.acFlags &= ~AC_HIT; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->tris.col.base); - break; - case OBJSWITCH_TYPE_CRYSTAL: - case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: - if (!Player_InCsMode(globalCtx) && this->disableAcTimer > 0) { - this->disableAcTimer--; - } - this->unk_17F = this->jntSph.col.base.acFlags; - this->jntSph.col.base.acFlags &= ~AC_HIT; - if (this->disableAcTimer <= 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->jntSph.col.base); - } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->jntSph.col.base); - break; - } -} - -void ObjSwitch_DrawFloor(ObjSwitch* this, GlobalContext* globalCtx) { - static Gfx* floorSwitchDLists[] = { gFloorSwitch1DL, gFloorSwitch3DL, gFloorSwitch2DL, gFloorSwitch2DL }; - - Gfx_DrawDListOpa(globalCtx, floorSwitchDLists[(this->dyna.actor.params >> 4 & 7)]); -} - -void ObjSwitch_DrawFloorRusty(ObjSwitch* this, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); -} - -void ObjSwitch_DrawEye(ObjSwitch* this, GlobalContext* globalCtx) { - static void* eyeTextures[][4] = { - { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, - { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }, - }; - static Gfx* eyeDlists[] = { gEyeSwitch1DL, gEyeSwitch2DL }; - s32 pad; - s32 subType = (this->dyna.actor.params >> 4 & 7); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1459); - - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1462), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[subType][this->eyeTexIndex])); - gSPDisplayList(POLY_OPA_DISP++, eyeDlists[subType]); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1471); -} - -void ObjSwitch_DrawCrystal(ObjSwitch* this, GlobalContext* globalCtx) { - static Gfx* xluDLists[] = { gCrystalSwitchCoreXluDL, gCrystalSwitchDiamondXluDL, NULL, NULL, - gCrystalSwitchCoreXluDL }; - static Gfx* opaDLists[] = { gCrystalSwitchCoreOpaDL, gCrystalSwitchDiamondOpaDL, NULL, NULL, - gCrystalSwitchCoreOpaDL }; - s32 pad1; - s32 pad2; - s32 subType; - - subType = (this->dyna.actor.params >> 4 & 7); - func_8002ED80(&this->dyna.actor, globalCtx, 0); - - if (1) {} - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1494); - - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1497), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, xluDLists[subType]); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1502); - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1507); - - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1511), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (subType == OBJSWITCH_SUBTYPE_CRYSTAL_1) { - gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(this->crystalSubtype1texture)); - } - - gDPSetEnvColor(POLY_OPA_DISP++, this->crystalColor.r, this->crystalColor.g, this->crystalColor.b, 128); - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->x1TexScroll, this->y1TexScroll, 0x20, 0x20, 1, - this->x2TexScroll, this->y2TexScroll, 0x20, 0x20)); - gSPDisplayList(POLY_OPA_DISP++, opaDLists[subType]); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1533); -} - -static ObjSwitchActionFunc sDrawFuncs[] = { - ObjSwitch_DrawFloor, ObjSwitch_DrawFloorRusty, ObjSwitch_DrawEye, ObjSwitch_DrawCrystal, ObjSwitch_DrawCrystal, -}; - -void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { - ObjSwitch* this = (ObjSwitch*)thisx; - - sDrawFuncs[(this->dyna.actor.params & 7)](this, globalCtx); -} diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.cpp b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.cpp new file mode 100644 index 000000000..56648c009 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.cpp @@ -0,0 +1,807 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_SWITCH_Z_OBJ_SWITCH_C +#include "actor_common.h" +/* + * File: z_obj_switch.c + * Overlay: ovl_Obj_Switch + * Description: Switches + */ + +#include "z_obj_switch.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/code_800A9F30.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_lib.h" +#include "def/z_onepointdemo.h" +#include "def/z_player_lib.h" +#include "def/z_rcp.h" + +#define FLAGS ACTOR_FLAG_4 + +// type: (pthis->dyna.actor.params & 7) +// subtype: (pthis->dyna.actor.params >> 4 & 7) +// switch flag: (pthis->dyna.actor.params >> 8 & 0x3F) +// frozen: pthis->dyna.actor.params >> 7 & 1 + +void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjSwitch_FloorUpInit(ObjSwitch* pthis); +void ObjSwitch_FloorUp(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_FloorPressInit(ObjSwitch* pthis); +void ObjSwitch_FloorPress(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_FloorDownInit(ObjSwitch* pthis); +void ObjSwitch_FloorDown(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_FloorReleaseInit(ObjSwitch* pthis); +void ObjSwitch_FloorRelease(ObjSwitch* pthis, GlobalContext* globalCtx); + +void ObjSwitch_EyeFrozenInit(ObjSwitch* pthis); +void ObjSwitch_EyeInit(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_EyeOpenInit(ObjSwitch* pthis); +void ObjSwitch_EyeOpen(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_EyeClosingInit(ObjSwitch* pthis); +void ObjSwitch_EyeClosing(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_EyeClosedInit(ObjSwitch* pthis); +void ObjSwitch_EyeClosed(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_EyeOpeningInit(ObjSwitch* pthis); +void ObjSwitch_EyeOpening(ObjSwitch* pthis, GlobalContext* globalCtx); + +void ObjSwitch_CrystalOffInit(ObjSwitch* pthis); +void ObjSwitch_CrystalOff(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_CrystalTurnOnInit(ObjSwitch* pthis); +void ObjSwitch_CrystalTurnOn(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_CrystalOnInit(ObjSwitch* pthis); +void ObjSwitch_CrystalOn(ObjSwitch* pthis, GlobalContext* globalCtx); +void ObjSwitch_CrystalTurnOffInit(ObjSwitch* pthis); +void ObjSwitch_CrystalTurnOff(ObjSwitch* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Switch_InitVars = { + ACTOR_OBJ_SWITCH, + ACTORCAT_SWITCH, + FLAGS, + OBJECT_GAMEPLAY_DANGEON_KEEP, + sizeof(ObjSwitch), + (ActorFunc)ObjSwitch_Init, + (ActorFunc)ObjSwitch_Destroy, + (ActorFunc)ObjSwitch_Update, + (ActorFunc)ObjSwitch_Draw, +}; + +static f32 sHeights[] = { 10, 10, 0, 30, 30 }; + +static ColliderTrisElementInit D_80B9EC34[2] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x40000040, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { -20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, 20.0f } } }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x40000040, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, -20.0f } } }, + }, +}; + +static ColliderTrisInit sRustyFloorTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + D_80B9EC34, +}; + +static ColliderTrisElementInit D_80B9ECBC[2] = { + { + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, + }, + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0001F824, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, + }, +}; + +static ColliderTrisInit trisColliderEye = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + D_80B9ECBC, +}; + +static ColliderJntSphElementInit D_80B9ED44[1] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xEFC1FFFE, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 300, 0 }, 20 }, 100 }, + }, +}; + +static ColliderJntSphInit sCyrstalJntSphereInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + D_80B9ED44, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 2000, ICHAIN_STOP), +}; + +void ObjSwitch_RotateY(Vec3f* dest, Vec3f* src, s16 angle) { + f32 s = Math_SinS(angle); + f32 c = Math_CosS(angle); + + dest->x = src->z * s + src->x * c; + dest->y = src->y; + dest->z = src->z * c - src->x * s; +} + +void ObjSwitch_InitDynapoly(ObjSwitch* pthis, GlobalContext* globalCtx, CollisionHeader* collision, s32 moveFlag) { + s32 pad; + CollisionHeader* colHeader = NULL; + s32 pad2; + + DynaPolyActor_Init(&pthis->dyna, moveFlag); + CollisionHeader_GetVirtual(collision, &colHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + if (pthis->dyna.bgId == BG_ACTOR_MAX) { + // "Warning : move BG registration failure" + osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_switch.c", 531, + pthis->dyna.actor.id, pthis->dyna.actor.params); + } +} + +void ObjSwitch_InitJntSphCollider(ObjSwitch* pthis, GlobalContext* globalCtx, ColliderJntSphInit* colliderJntSphInit) { + ColliderJntSph* colliderJntSph = &pthis->jntSph.col; + + Collider_InitJntSph(globalCtx, colliderJntSph); + Collider_SetJntSph(globalCtx, colliderJntSph, &pthis->dyna.actor, colliderJntSphInit, pthis->jntSph.items); + func_800D1694(pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y + pthis->dyna.actor.shape.yOffset * pthis->dyna.actor.scale.y, + pthis->dyna.actor.world.pos.z, &pthis->dyna.actor.shape.rot); + Matrix_Scale(pthis->dyna.actor.scale.x, pthis->dyna.actor.scale.y, pthis->dyna.actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, colliderJntSph); +} + +void ObjSwitch_InitTrisCollider(ObjSwitch* pthis, GlobalContext* globalCtx, ColliderTrisInit* colliderTrisInit) { + ColliderTris* colliderTris = &pthis->tris.col; + s32 i; + s32 j; + Vec3f pos[3]; + + Collider_InitTris(globalCtx, colliderTris); + Collider_SetTris(globalCtx, colliderTris, &pthis->dyna.actor, colliderTrisInit, pthis->tris.items); + + for (i = 0; i < 2; i++) { + for (j = 0; j < 3; j++) { + ObjSwitch_RotateY(&pos[j], &colliderTrisInit->elements[i].dim.vtx[j], pthis->dyna.actor.home.rot.y); + Math_Vec3f_Sum(&pos[j], &pthis->dyna.actor.world.pos, &pos[j]); + } + + Collider_SetTrisVertices(colliderTris, i, &pos[0], &pos[1], &pos[2]); + } +} + +Actor* ObjSwitch_SpawnIce(ObjSwitch* pthis, GlobalContext* globalCtx) { + Actor* thisx = &pthis->dyna.actor; + + return Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_OBJ_ICE_POLY, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, thisx->world.rot.x, thisx->world.rot.y, + thisx->world.rot.z, (pthis->dyna.actor.params >> 8 & 0x3F) << 8); +} + +void ObjSwitch_SetOn(ObjSwitch* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 subType; + + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + pthis->cooldownOn = false; + } else { + subType = (pthis->dyna.actor.params >> 4 & 7); + Flags_SetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F)); + + if (subType == 0 || subType == 4) { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->dyna.actor, NA_SE_SY_CORRECT_CHIME); + } else { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + } + + pthis->cooldownOn = true; + } +} + +void ObjSwitch_SetOff(ObjSwitch* pthis, GlobalContext* globalCtx) { + pthis->cooldownOn = false; + + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + Flags_UnsetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F)); + + if ((pthis->dyna.actor.params >> 4 & 7) == 1) { + OnePointCutscene_AttentionSetSfx(globalCtx, &pthis->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + pthis->cooldownOn = true; + } + } +} + +void ObjSwitch_UpdateTwoTexScrollXY(ObjSwitch* pthis) { + pthis->x1TexScroll = (pthis->x1TexScroll - 1) & 0x7F; + pthis->y1TexScroll = (pthis->y1TexScroll + 1) & 0x7F; + pthis->x2TexScroll = (pthis->x2TexScroll + 1) & 0x7F; + pthis->y2TexScroll = (pthis->y2TexScroll - 1) & 0x7F; +} + +void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* pthis = (ObjSwitch*)thisx; + s32 switchFlagSet; + s32 type; + + switchFlagSet = Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F)); + type = (pthis->dyna.actor.params & 7); + + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + ObjSwitch_InitDynapoly(pthis, globalCtx, &gFloorSwitchCol, DPM_PLAYER); + } + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + pthis->dyna.actor.world.pos.y = pthis->dyna.actor.home.pos.y + 1.0f; + } + + Actor_SetFocus(&pthis->dyna.actor, sHeights[type]); + + if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + ObjSwitch_InitTrisCollider(pthis, globalCtx, &sRustyFloorTrisInit); + } else if (type == OBJSWITCH_TYPE_EYE) { + ObjSwitch_InitTrisCollider(pthis, globalCtx, &trisColliderEye); + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + ObjSwitch_InitJntSphCollider(pthis, globalCtx, &sCyrstalJntSphereInit); + } + + if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + pthis->dyna.actor.flags |= ACTOR_FLAG_0; + pthis->dyna.actor.targetMode = 4; + } + + pthis->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + + if ((pthis->dyna.actor.params >> 7 & 1) && (ObjSwitch_SpawnIce(pthis, globalCtx) == NULL)) { + osSyncPrintf(VT_FGCOL(RED)); + osSyncPrintf("Error : 氷発生失敗 (%s %d)\n", "../z_obj_switch.c", 732); + osSyncPrintf(VT_RST); + pthis->dyna.actor.params &= ~0x80; + } + + if (pthis->dyna.actor.params >> 7 & 1) { + ObjSwitch_EyeFrozenInit(pthis); + } else if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (switchFlagSet) { + ObjSwitch_FloorDownInit(pthis); + } else { + ObjSwitch_FloorUpInit(pthis); + } + } else if (type == OBJSWITCH_TYPE_EYE) { + if (switchFlagSet) { + ObjSwitch_EyeClosedInit(pthis); + } else { + ObjSwitch_EyeOpenInit(pthis); + } + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + if (switchFlagSet) { + ObjSwitch_CrystalOnInit(pthis); + } else { + ObjSwitch_CrystalOffInit(pthis); + } + } + + osSyncPrintf("(Dungeon switch)(arg_data 0x%04x)\n", pthis->dyna.actor.params); +} + +void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* pthis = (ObjSwitch*)thisx; + + switch ((pthis->dyna.actor.params & 7)) { + case OBJSWITCH_TYPE_FLOOR: + case OBJSWITCH_TYPE_FLOOR_RUSTY: + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + break; + } + + switch ((pthis->dyna.actor.params & 7)) { + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_EYE: + Collider_DestroyTris(globalCtx, &pthis->tris.col); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + Collider_DestroyJntSph(globalCtx, &pthis->jntSph.col); + break; + } +} + +void ObjSwitch_FloorUpInit(ObjSwitch* pthis) { + pthis->dyna.actor.scale.y = 33.0f / 200.0f; + pthis->actionFunc = ObjSwitch_FloorUp; +} + +void ObjSwitch_FloorUp(ObjSwitch* pthis, GlobalContext* globalCtx) { + if ((pthis->dyna.actor.params & 7) == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (pthis->tris.col.base.acFlags & AC_HIT) { + ObjSwitch_FloorPressInit(pthis); + ObjSwitch_SetOn(pthis, globalCtx); + pthis->tris.col.base.acFlags &= ~AC_HIT; + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->tris.col.base); + } + } else { + switch ((pthis->dyna.actor.params >> 4 & 7)) { + case OBJSWITCH_SUBTYPE_FLOOR_0: + if (func_8004356C(&pthis->dyna)) { + ObjSwitch_FloorPressInit(pthis); + ObjSwitch_SetOn(pthis, globalCtx); + } + break; + case OBJSWITCH_SUBTYPE_FLOOR_1: + if ((pthis->dyna.unk_160 & 2) && !(pthis->unk_17F & 2)) { + ObjSwitch_FloorPressInit(pthis); + ObjSwitch_SetOn(pthis, globalCtx); + } + break; + case OBJSWITCH_SUBTYPE_FLOOR_2: + if (func_800435B4(&pthis->dyna)) { + ObjSwitch_FloorPressInit(pthis); + ObjSwitch_SetOn(pthis, globalCtx); + } + break; + case OBJSWITCH_SUBTYPE_FLOOR_3: + if (func_800435B4(&pthis->dyna)) { + ObjSwitch_FloorPressInit(pthis); + ObjSwitch_SetOff(pthis, globalCtx); + } + break; + } + } +} + +void ObjSwitch_FloorPressInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_FloorPress; + pthis->cooldownTimer = 100; +} + +void ObjSwitch_FloorPress(ObjSwitch* pthis, GlobalContext* globalCtx) { + if ((pthis->dyna.actor.params >> 4 & 7) == OBJSWITCH_SUBTYPE_FLOOR_3 || !pthis->cooldownOn || + func_8005B198() == pthis->dyna.actor.category || pthis->cooldownTimer <= 0) { + pthis->dyna.actor.scale.y -= 99.0f / 2000.0f; + if (pthis->dyna.actor.scale.y <= 33.0f / 2000.0f) { + ObjSwitch_FloorDownInit(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + } +} + +void ObjSwitch_FloorDownInit(ObjSwitch* pthis) { + pthis->dyna.actor.scale.y = 33.0f / 2000.0f; + pthis->releaseTimer = 6; + pthis->actionFunc = ObjSwitch_FloorDown; +} + +void ObjSwitch_FloorDown(ObjSwitch* pthis, GlobalContext* globalCtx) { + switch ((pthis->dyna.actor.params >> 4 & 7)) { + case OBJSWITCH_SUBTYPE_FLOOR_0: + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + ObjSwitch_FloorReleaseInit(pthis); + } + break; + case OBJSWITCH_SUBTYPE_FLOOR_1: + if ((pthis->dyna.unk_160 & 2) && !(pthis->unk_17F & 2)) { + ObjSwitch_FloorReleaseInit(pthis); + ObjSwitch_SetOff(pthis, globalCtx); + } + break; + case OBJSWITCH_SUBTYPE_FLOOR_2: + case OBJSWITCH_SUBTYPE_FLOOR_3: + if (!func_800435B4(&pthis->dyna) && !Player_InCsMode(globalCtx)) { + if (pthis->releaseTimer <= 0) { + ObjSwitch_FloorReleaseInit(pthis); + if ((pthis->dyna.actor.params >> 4 & 7) == OBJSWITCH_SUBTYPE_FLOOR_2) { + ObjSwitch_SetOff(pthis, globalCtx); + } else { + ObjSwitch_SetOn(pthis, globalCtx); + } + } + } else { + pthis->releaseTimer = 6; + } + break; + } +} + +void ObjSwitch_FloorReleaseInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_FloorRelease; + pthis->cooldownTimer = 100; +} + +void ObjSwitch_FloorRelease(ObjSwitch* pthis, GlobalContext* globalCtx) { + s16 subType = (pthis->dyna.actor.params >> 4 & 7); + + if (((subType != OBJSWITCH_SUBTYPE_FLOOR_1) && (subType != OBJSWITCH_SUBTYPE_FLOOR_3)) || !pthis->cooldownOn || + func_8005B198() == pthis->dyna.actor.category || pthis->cooldownTimer <= 0) { + pthis->dyna.actor.scale.y += 99.0f / 2000.0f; + if (pthis->dyna.actor.scale.y >= 33.0f / 200.0f) { + ObjSwitch_FloorUpInit(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + if (subType == OBJSWITCH_SUBTYPE_FLOOR_1) { + func_800AA000(pthis->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + } + } +} + +s32 ObjSwitch_EyeIsHit(ObjSwitch* pthis) { + Actor* collidingActor; + s16 yawDiff; + + if ((pthis->tris.col.base.acFlags & AC_HIT) && !(pthis->unk_17F & 2)) { + collidingActor = pthis->tris.col.base.ac; + if (collidingActor != NULL) { + yawDiff = collidingActor->world.rot.y - pthis->dyna.actor.shape.rot.y; + if (ABS(yawDiff) > 0x5000) { + return 1; + } + } + } + return 0; +} + +void ObjSwitch_EyeFrozenInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_EyeInit; +} + +void ObjSwitch_EyeInit(ObjSwitch* pthis, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + ObjSwitch_EyeClosedInit(pthis); + } else { + ObjSwitch_EyeOpenInit(pthis); + } +} + +void ObjSwitch_EyeOpenInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_EyeOpen; + pthis->eyeTexIndex = 0; +} + +void ObjSwitch_EyeOpen(ObjSwitch* pthis, GlobalContext* globalCtx) { + if (ObjSwitch_EyeIsHit(pthis) || (pthis->dyna.actor.params >> 7 & 1)) { + ObjSwitch_EyeClosingInit(pthis); + ObjSwitch_SetOn(pthis, globalCtx); + pthis->dyna.actor.params &= ~0x80; + } +} + +void ObjSwitch_EyeClosingInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_EyeClosing; + pthis->cooldownTimer = 100; +} + +void ObjSwitch_EyeClosing(ObjSwitch* pthis, GlobalContext* globalCtx) { + if (!pthis->cooldownOn || func_8005B198() == pthis->dyna.actor.category || pthis->cooldownTimer <= 0) { + pthis->eyeTexIndex++; + if (pthis->eyeTexIndex >= 3) { + ObjSwitch_EyeClosedInit(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } + } +} + +void ObjSwitch_EyeClosedInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_EyeClosed; + pthis->eyeTexIndex = 3; +} + +void ObjSwitch_EyeClosed(ObjSwitch* pthis, GlobalContext* globalCtx) { + switch ((pthis->dyna.actor.params >> 4 & 7)) { + case OBJSWITCH_SUBTYPE_EYE_0: + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + ObjSwitch_EyeOpeningInit(pthis); + pthis->dyna.actor.params &= ~0x80; + } + break; + case OBJSWITCH_SUBTYPE_EYE_1: + if (ObjSwitch_EyeIsHit(pthis) || (pthis->dyna.actor.params >> 7 & 1)) { + ObjSwitch_EyeOpeningInit(pthis); + ObjSwitch_SetOff(pthis, globalCtx); + pthis->dyna.actor.params &= ~0x80; + } + break; + } +} + +void ObjSwitch_EyeOpeningInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_EyeOpening; + pthis->cooldownTimer = 100; +} + +void ObjSwitch_EyeOpening(ObjSwitch* pthis, GlobalContext* globalCtx) { + if ((pthis->dyna.actor.params >> 4 & 7) != OBJSWITCH_SUBTYPE_EYE_1 || !pthis->cooldownOn || + func_8005B198() == pthis->dyna.actor.category || pthis->cooldownTimer <= 0) { + pthis->eyeTexIndex--; + if (pthis->eyeTexIndex <= 0) { + ObjSwitch_EyeOpenInit(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } + } +} + +void ObjSwitch_CrystalOffInit(ObjSwitch* pthis) { + pthis->crystalColor.r = 0; + pthis->crystalColor.g = 0; + pthis->crystalColor.b = 0; + pthis->crystalSubtype1texture = gCrstalSwitchRedTex; + pthis->actionFunc = ObjSwitch_CrystalOff; +} + +void ObjSwitch_CrystalOff(ObjSwitch* pthis, GlobalContext* globalCtx) { + switch ((pthis->dyna.actor.params >> 4 & 7)) { + case OBJSWITCH_SUBTYPE_CRYSTAL_0: + if ((pthis->jntSph.col.base.acFlags & AC_HIT) && pthis->disableAcTimer <= 0) { + pthis->disableAcTimer = 10; + ObjSwitch_SetOn(pthis, globalCtx); + ObjSwitch_CrystalTurnOnInit(pthis); + } + break; + case OBJSWITCH_SUBTYPE_CRYSTAL_4: + if (((pthis->jntSph.col.base.acFlags & AC_HIT) && pthis->disableAcTimer <= 0) || + Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + pthis->disableAcTimer = 10; + ObjSwitch_SetOn(pthis, globalCtx); + ObjSwitch_CrystalTurnOnInit(pthis); + } + break; + case OBJSWITCH_SUBTYPE_CRYSTAL_1: + if ((pthis->jntSph.col.base.acFlags & AC_HIT) && !(pthis->unk_17F & 2) && pthis->disableAcTimer <= 0) { + pthis->disableAcTimer = 10; + ObjSwitch_SetOn(pthis, globalCtx); + ObjSwitch_CrystalTurnOnInit(pthis); + } + ObjSwitch_UpdateTwoTexScrollXY(pthis); + break; + } +} + +void ObjSwitch_CrystalTurnOnInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_CrystalTurnOn; + pthis->cooldownTimer = 100; +} + +void ObjSwitch_CrystalTurnOn(ObjSwitch* pthis, GlobalContext* globalCtx) { + if (!pthis->cooldownOn || func_8005B198() == pthis->dyna.actor.category || pthis->cooldownTimer <= 0) { + ObjSwitch_CrystalOnInit(pthis); + if ((pthis->dyna.actor.params >> 4 & 7) == OBJSWITCH_SUBTYPE_CRYSTAL_1) { + ObjSwitch_UpdateTwoTexScrollXY(pthis); + } + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + } +} + +void ObjSwitch_CrystalOnInit(ObjSwitch* pthis) { + pthis->crystalColor.r = 255; + pthis->crystalColor.g = 255; + pthis->crystalColor.b = 255; + pthis->crystalSubtype1texture = gCrstalSwitchBlueTex; + pthis->actionFunc = ObjSwitch_CrystalOn; +} + +void ObjSwitch_CrystalOn(ObjSwitch* pthis, GlobalContext* globalCtx) { + switch ((pthis->dyna.actor.params >> 4 & 7)) { + case OBJSWITCH_SUBTYPE_CRYSTAL_0: + case OBJSWITCH_SUBTYPE_CRYSTAL_4: + if (!Flags_GetSwitch(globalCtx, (pthis->dyna.actor.params >> 8 & 0x3F))) { + ObjSwitch_CrystalTurnOffInit(pthis); + } + break; + case OBJSWITCH_SUBTYPE_CRYSTAL_1: + if ((pthis->jntSph.col.base.acFlags & AC_HIT) && !(pthis->unk_17F & 2) && pthis->disableAcTimer <= 0) { + pthis->disableAcTimer = 10; + globalCtx = globalCtx; + ObjSwitch_CrystalTurnOffInit(pthis); + ObjSwitch_SetOff(pthis, globalCtx); + } + break; + } + ObjSwitch_UpdateTwoTexScrollXY(pthis); +} + +void ObjSwitch_CrystalTurnOffInit(ObjSwitch* pthis) { + pthis->actionFunc = ObjSwitch_CrystalTurnOff; + pthis->cooldownTimer = 100; +} + +void ObjSwitch_CrystalTurnOff(ObjSwitch* pthis, GlobalContext* globalCtx) { + if ((pthis->dyna.actor.params >> 4 & 7) != OBJSWITCH_SUBTYPE_CRYSTAL_1 || !pthis->cooldownOn || + func_8005B198() == pthis->dyna.actor.category || pthis->cooldownTimer <= 0) { + ObjSwitch_CrystalOffInit(pthis); + ObjSwitch_UpdateTwoTexScrollXY(pthis); + Audio_PlayActorSound2(&pthis->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + } +} + +void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* pthis = (ObjSwitch*)thisx; + + if (pthis->releaseTimer > 0) { + pthis->releaseTimer--; + } + if (pthis->cooldownTimer > 0) { + pthis->cooldownTimer--; + } + + pthis->actionFunc(pthis, globalCtx); + + switch ((pthis->dyna.actor.params & 7)) { + case OBJSWITCH_TYPE_FLOOR: + case OBJSWITCH_TYPE_FLOOR_RUSTY: + pthis->unk_17F = pthis->dyna.unk_160; + break; + case OBJSWITCH_TYPE_EYE: + pthis->unk_17F = pthis->tris.col.base.acFlags; + pthis->tris.col.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->tris.col.base); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + if (!Player_InCsMode(globalCtx) && pthis->disableAcTimer > 0) { + pthis->disableAcTimer--; + } + pthis->unk_17F = pthis->jntSph.col.base.acFlags; + pthis->jntSph.col.base.acFlags &= ~AC_HIT; + if (pthis->disableAcTimer <= 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->jntSph.col.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->jntSph.col.base); + break; + } +} + +void ObjSwitch_DrawFloor(ObjSwitch* pthis, GlobalContext* globalCtx) { + static Gfx* floorSwitchDLists[] = { gFloorSwitch1DL, gFloorSwitch3DL, gFloorSwitch2DL, gFloorSwitch2DL }; + + Gfx_DrawDListOpa(globalCtx, floorSwitchDLists[(pthis->dyna.actor.params >> 4 & 7)]); +} + +void ObjSwitch_DrawFloorRusty(ObjSwitch* pthis, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); +} + +void ObjSwitch_DrawEye(ObjSwitch* pthis, GlobalContext* globalCtx) { + static void* eyeTextures[][4] = { + { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, + { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }, + }; + static Gfx* eyeDlists[] = { gEyeSwitch1DL, gEyeSwitch2DL }; + s32 pad; + s32 subType = (pthis->dyna.actor.params >> 4 & 7); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1459); + + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1462), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[subType][pthis->eyeTexIndex])); + gSPDisplayList(POLY_OPA_DISP++, eyeDlists[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1471); +} + +void ObjSwitch_DrawCrystal(ObjSwitch* pthis, GlobalContext* globalCtx) { + static Gfx* xluDLists[] = { gCrystalSwitchCoreXluDL, gCrystalSwitchDiamondXluDL, NULL, NULL, + gCrystalSwitchCoreXluDL }; + static Gfx* opaDLists[] = { gCrystalSwitchCoreOpaDL, gCrystalSwitchDiamondOpaDL, NULL, NULL, + gCrystalSwitchCoreOpaDL }; + s32 pad1; + s32 pad2; + s32 subType; + + subType = (pthis->dyna.actor.params >> 4 & 7); + func_8002ED80(&pthis->dyna.actor, globalCtx, 0); + + if (1) {} + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1494); + + func_80093D84(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1497), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, xluDLists[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1502); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1507); + + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1511), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (subType == OBJSWITCH_SUBTYPE_CRYSTAL_1) { + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(pthis->crystalSubtype1texture)); + } + + gDPSetEnvColor(POLY_OPA_DISP++, pthis->crystalColor.r, pthis->crystalColor.g, pthis->crystalColor.b, 128); + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->x1TexScroll, pthis->y1TexScroll, 0x20, 0x20, 1, + pthis->x2TexScroll, pthis->y2TexScroll, 0x20, 0x20)); + gSPDisplayList(POLY_OPA_DISP++, opaDLists[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1533); +} + +static ObjSwitchActionFunc sDrawFuncs[] = { + ObjSwitch_DrawFloor, ObjSwitch_DrawFloorRusty, ObjSwitch_DrawEye, ObjSwitch_DrawCrystal, ObjSwitch_DrawCrystal, +}; + +void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* pthis = (ObjSwitch*)thisx; + + sDrawFuncs[(pthis->dyna.actor.params & 7)](pthis, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.cpp similarity index 60% rename from src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c rename to src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.cpp index 3c61c7522..9ea4ba73d 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.cpp @@ -29,7 +29,7 @@ void ObjSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Obj_Syokudai_InitVars = { +ActorInit Obj_Syokudai_InitVars = { ACTOR_OBJ_SYOKUDAI, ACTORCAT_PROP, FLAGS, @@ -93,49 +93,49 @@ static s32 sLitTorchCount; void ObjSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { static u8 sColTypesStand[] = { 0x09, 0x0B, 0x0B }; s32 pad; - ObjSyokudai* this = (ObjSyokudai*)thisx; - s32 torchType = this->actor.params & 0xF000; + ObjSyokudai* pthis = (ObjSyokudai*)thisx; + s32 torchType = pthis->actor.params & 0xF000; - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ActorShape_Init(&pthis->actor.shape, 0.0f, NULL, 0.0f); - Collider_InitCylinder(globalCtx, &this->colliderStand); - Collider_SetCylinder(globalCtx, &this->colliderStand, &this->actor, &sCylInitStand); - this->colliderStand.base.colType = sColTypesStand[this->actor.params >> 0xC]; + Collider_InitCylinder(globalCtx, &pthis->colliderStand); + Collider_SetCylinder(globalCtx, &pthis->colliderStand, &pthis->actor, &sCylInitStand); + pthis->colliderStand.base.colType = sColTypesStand[pthis->actor.params >> 0xC]; - Collider_InitCylinder(globalCtx, &this->colliderFlame); - Collider_SetCylinder(globalCtx, &this->colliderFlame, &this->actor, &sCylInitFlame); + Collider_InitCylinder(globalCtx, &pthis->colliderFlame); + Collider_SetCylinder(globalCtx, &pthis->colliderFlame, &pthis->actor, &sCylInitFlame); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y + 70.0f, - this->actor.world.pos.z, 255, 255, 180, -1); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + Lights_PointGlowSetInfo(&pthis->lightInfo, pthis->actor.world.pos.x, pthis->actor.world.pos.y + 70.0f, + pthis->actor.world.pos.z, 255, 255, 180, -1); + pthis->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo); - if ((this->actor.params & 0x400) || ((torchType != 2) && Flags_GetSwitch(globalCtx, this->actor.params & 0x3F))) { - this->litTimer = -1; + if ((pthis->actor.params & 0x400) || ((torchType != 2) && Flags_GetSwitch(globalCtx, pthis->actor.params & 0x3F))) { + pthis->litTimer = -1; } - this->flameTexScroll = (s32)(Rand_ZeroOne() * 20.0f); + pthis->flameTexScroll = (s32)(Rand_ZeroOne() * 20.0f); sLitTorchCount = 0; - Actor_SetFocus(&this->actor, 60.0f); + Actor_SetFocus(&pthis->actor, 60.0f); } void ObjSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - ObjSyokudai* this = (ObjSyokudai*)thisx; + ObjSyokudai* pthis = (ObjSyokudai*)thisx; - Collider_DestroyCylinder(globalCtx, &this->colliderStand); - Collider_DestroyCylinder(globalCtx, &this->colliderFlame); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + Collider_DestroyCylinder(globalCtx, &pthis->colliderStand); + Collider_DestroyCylinder(globalCtx, &pthis->colliderFlame); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode); } void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - ObjSyokudai* this = (ObjSyokudai*)thisx; - s32 torchCount = (this->actor.params >> 6) & 0xF; - s32 switchFlag = this->actor.params & 0x3F; - s32 torchType = this->actor.params & 0xF000; + ObjSyokudai* pthis = (ObjSyokudai*)thisx; + s32 torchCount = (pthis->actor.params >> 6) & 0xF; + s32 switchFlag = pthis->actor.params & 0x3F; + s32 torchType = pthis->actor.params & 0xF000; s32 litTimeScale; WaterBox* dummy; f32 waterSurface; @@ -153,67 +153,67 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { if (torchCount == 10) { torchCount = 24; } - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, &waterSurface, &dummy) && - ((waterSurface - this->actor.world.pos.y) > 52.0f)) { - this->litTimer = 0; + ((waterSurface - pthis->actor.world.pos.y) > 52.0f)) { + pthis->litTimer = 0; if (torchType == 1) { Flags_UnsetSwitch(globalCtx, switchFlag); if (torchCount != 0) { - this->litTimer = 1; + pthis->litTimer = 1; } } } else { player = GET_PLAYER(globalCtx); interactionType = 0; - if (this->actor.params & 0x400) { - this->litTimer = -1; + if (pthis->actor.params & 0x400) { + pthis->litTimer = -1; } if (torchCount != 0) { if (Flags_GetSwitch(globalCtx, switchFlag)) { - if (this->litTimer == 0) { - this->litTimer = -1; + if (pthis->litTimer == 0) { + pthis->litTimer = -1; if (torchType == 0) { - OnePointCutscene_Attention(globalCtx, &this->actor); + OnePointCutscene_Attention(globalCtx, &pthis->actor); } - } else if (this->litTimer > 0) { - this->litTimer = -1; + } else if (pthis->litTimer > 0) { + pthis->litTimer = -1; } - } else if (this->litTimer < 0) { - this->litTimer = 20; + } else if (pthis->litTimer < 0) { + pthis->litTimer = 20; } } - if (this->colliderFlame.base.acFlags & AC_HIT) { - dmgFlags = this->colliderFlame.info.acHitInfo->toucher.dmgFlags; + if (pthis->colliderFlame.base.acFlags & AC_HIT) { + dmgFlags = pthis->colliderFlame.info.acHitInfo->toucher.dmgFlags; if (dmgFlags & 0x20820) { interactionType = 1; } } else if (player->heldItemActionParam == PLAYER_AP_STICK) { - Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->actor.world.pos, &tipToFlame); + Math_Vec3f_Diff(&player->swordInfo[0].tip, &pthis->actor.world.pos, &tipToFlame); tipToFlame.y -= 67.0f; if ((SQ(tipToFlame.x) + SQ(tipToFlame.y) + SQ(tipToFlame.z)) < SQ(20.0f)) { interactionType = -1; } } if (interactionType != 0) { - if (this->litTimer != 0) { + if (pthis->litTimer != 0) { if (interactionType < 0) { if (player->unk_860 == 0) { player->unk_860 = 210; - Audio_PlaySoundGeneral(NA_SE_EV_FLAME_IGNITION, &this->actor.projectedPos, 4, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EV_FLAME_IGNITION, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else if (player->unk_860 < 200) { player->unk_860 = 200; } } else if (dmgFlags & 0x20) { - arrow = (EnArrow*)this->colliderFlame.base.ac; + arrow = (EnArrow*)pthis->colliderFlame.base.ac; if ((arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { arrow->actor.params = 0; arrow->collider.info.toucher.dmgFlags = 0x800; } } - if ((0 <= this->litTimer) && (this->litTimer < (50 * litTimeScale + 100)) && (torchType != 0)) { - this->litTimer = 50 * litTimeScale + 100; + if ((0 <= pthis->litTimer) && (pthis->litTimer < (50 * litTimeScale + 100)) && (torchType != 0)) { + pthis->litTimer = 50 * litTimeScale + 100; } } else if ((torchType != 0) && (((interactionType > 0) && (dmgFlags & 0x20800)) || ((interactionType < 0) && (player->unk_860 != 0)))) { @@ -222,60 +222,60 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { player->unk_860 = 200; } if (torchCount == 0) { - this->litTimer = -1; + pthis->litTimer = -1; if (torchType != 2) { Flags_SetSwitch(globalCtx, switchFlag); - OnePointCutscene_Attention(globalCtx, &this->actor); + OnePointCutscene_Attention(globalCtx, &pthis->actor); } } else { sLitTorchCount++; if (sLitTorchCount >= torchCount) { Flags_SetSwitch(globalCtx, switchFlag); - OnePointCutscene_Attention(globalCtx, &this->actor); - this->litTimer = -1; + OnePointCutscene_Attention(globalCtx, &pthis->actor); + pthis->litTimer = -1; } else { - this->litTimer = (litTimeScale * 50) + 110; + pthis->litTimer = (litTimeScale * 50) + 110; } } - Audio_PlaySoundGeneral(NA_SE_EV_FLAME_IGNITION, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + Audio_PlaySoundGeneral(NA_SE_EV_FLAME_IGNITION, &pthis->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } } - Collider_UpdateCylinder(&this->actor, &this->colliderStand); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderStand.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderStand.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderStand); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderStand.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderStand.base); - Collider_UpdateCylinder(&this->actor, &this->colliderFlame); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderFlame.base); + Collider_UpdateCylinder(&pthis->actor, &pthis->colliderFlame); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->colliderFlame.base); - if (this->litTimer > 0) { - this->litTimer--; - if ((this->litTimer == 0) && (torchType != 0)) { + if (pthis->litTimer > 0) { + pthis->litTimer--; + if ((pthis->litTimer == 0) && (torchType != 0)) { sLitTorchCount--; } } - if (this->litTimer != 0) { - if ((this->litTimer < 0) || (this->litTimer >= 20)) { + if (pthis->litTimer != 0) { + if ((pthis->litTimer < 0) || (pthis->litTimer >= 20)) { lightRadius = 200; } else { - lightRadius = (this->litTimer * 200.0f) / 20.0f; + lightRadius = (pthis->litTimer * 200.0f) / 20.0f; } brightness = (u8)(Rand_ZeroOne() * 127.0f) + 128; - func_8002F974(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + func_8002F974(&pthis->actor, NA_SE_EV_TORCH - SFX_FLAG); } - Lights_PointSetColorAndRadius(&this->lightInfo, brightness, brightness, 0, lightRadius); - this->flameTexScroll++; + Lights_PointSetColorAndRadius(&pthis->lightInfo, brightness, brightness, 0, lightRadius); + pthis->flameTexScroll++; } void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { static Gfx* displayLists[] = { gGoldenTorchDL, gTimedTorchDL, gWoodenTorchDL }; s32 pad; - ObjSyokudai* this = (ObjSyokudai*)thisx; + ObjSyokudai* pthis = (ObjSyokudai*)thisx; s32 timerMax; - timerMax = (((this->actor.params >> 6) & 0xF) * 50) + 100; + timerMax = (((pthis->actor.params >> 6) & 0xF) * 50) + 100; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_syokudai.c", 707); func_80093D18(globalCtx->state.gfxCtx); @@ -283,15 +283,15 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_syokudai.c", 714), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, displayLists[(u16)this->actor.params >> 0xC]); + gSPDisplayList(POLY_OPA_DISP++, displayLists[(u16)pthis->actor.params >> 0xC]); - if (this->litTimer != 0) { + if (pthis->litTimer != 0) { f32 flameScale = 1.0f; - if (this->litTimer > timerMax) { - flameScale = (timerMax - this->litTimer + 10) / 10.0f; - } else if ((this->litTimer > 0) && (this->litTimer < 20)) { - flameScale = this->litTimer / 20.0f; + if (pthis->litTimer > timerMax) { + flameScale = (timerMax - pthis->litTimer + 10) / 10.0f; + } else if ((pthis->litTimer > 0) && (pthis->litTimer < 20)) { + flameScale = pthis->litTimer / 20.0f; } flameScale *= 0.0027f; @@ -299,14 +299,14 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (this->flameTexScroll * -20) & 0x1FF, 0x20, 0x80)); + (pthis->flameTexScroll * -20) & 0x1FF, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Matrix_Translate(0.0f, 52.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y + 0x8000) * + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - pthis->actor.shape.rot.y + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c deleted file mode 100644 index fe398bf89..000000000 --- a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c +++ /dev/null @@ -1,357 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_TIMEBLOCK_Z_OBJ_TIMEBLOCK_C -#include "actor_common.h" -/* - * File: z_obj_timeblock.c - * Overlay: ovl_Obj_Timeblock - * Description: Song of Time Block - */ - -#include "z_obj_timeblock.h" -#include "objects/object_timeblock/object_timeblock.h" -#include "def/code_80043480.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_25 | ACTOR_FLAG_27) - -void ObjTimeblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTimeblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTimeblock_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTimeblock_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjTimeblock_SetupNormal(ObjTimeblock* this); -void ObjTimeblock_SetupAltBehaviorVisible(ObjTimeblock* this); -void ObjTimeblock_SetupAltBehaviourNotVisible(ObjTimeblock* this); - -s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* this, GlobalContext* globalCtx); -s32 ObjTimeblock_WaitForSong(ObjTimeblock* this, GlobalContext* globalCtx); -void ObjTimeblock_DoNothing(ObjTimeblock* this, GlobalContext* globalCtx); -void ObjTimeblock_Normal(ObjTimeblock* this, GlobalContext* globalCtx); -void ObjTimeblock_AltBehaviorVisible(ObjTimeblock* this, GlobalContext* globalCtx); -void ObjTimeblock_AltBehaviourNotVisible(ObjTimeblock* this, GlobalContext* globalCtx); - -const ActorInit Obj_Timeblock_InitVars = { - ACTOR_OBJ_TIMEBLOCK, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_TIMEBLOCK, - sizeof(ObjTimeblock), - (ActorFunc)ObjTimeblock_Init, - (ActorFunc)ObjTimeblock_Destroy, - (ActorFunc)ObjTimeblock_Update, - (ActorFunc)ObjTimeblock_Draw, -}; - -typedef struct { - /* 0x00 */ f32 scale; - /* 0x04 */ f32 height; - /* 0x08 */ s16 demoEffectParams; -} ObjTimeblockSizeOptions; // size = 0x0C - -static ObjTimeblockSizeOptions sSizeOptions[] = { - { 1.0, 60.0, 0x0018 }, - { 0.60, 40.0, 0x0019 }, -}; - -static f32 sRanges[] = { 60.0, 100.0, 140.0, 180.0, 220.0, 260.0, 300.0, 300.0 }; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), -}; - -static Color_RGB8 sPrimColors[] = { - { 100, 120, 140 }, { 80, 140, 200 }, { 100, 150, 200 }, { 100, 200, 240 }, - { 80, 110, 140 }, { 70, 160, 225 }, { 80, 100, 130 }, { 100, 110, 190 }, -}; - -u32 ObjTimeblock_CalculateIsVisible(ObjTimeblock* this) { - if (!((this->dyna.actor.params >> 10) & 1)) { - if (this->unk_177 == 0) { - return this->unk_175; - } else { - u8 temp = ((this->dyna.actor.params >> 15) & 1) ? true : false; - - if (this->unk_177 == 1) { - return this->unk_174 ^ temp; - } else { - u8 linkIsYoung = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? true : false; - - return this->unk_174 ^ temp ^ linkIsYoung; - } - } - } else { - return (((this->dyna.actor.params >> 15) & 1) ? true : false) ^ this->unk_174; - } -} - -void ObjTimeblock_SpawnDemoEffect(ObjTimeblock* this, GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, - sSizeOptions[(this->dyna.actor.params >> 8) & 1].demoEffectParams); -} - -void ObjTimeblock_ToggleSwitchFlag(GlobalContext* globalCtx, s32 flag) { - if (Flags_GetSwitch(globalCtx, flag)) { - Flags_UnsetSwitch(globalCtx, flag); - } else { - Flags_SetSwitch(globalCtx, flag); - } -} - -void ObjTimeblock_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjTimeblock* this = (ObjTimeblock*)thisx; - s32 pad; - CollisionHeader* colHeader = NULL; - - DynaPolyActor_Init(&this->dyna, DPM_UNK); - this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; - - CollisionHeader_GetVirtual(&gSongOfTimeBlockCol, &colHeader); - - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Actor_SetScale(&this->dyna.actor, sSizeOptions[(this->dyna.actor.params >> 8) & 1].scale); - - if ((this->dyna.actor.params >> 6) & 1) { - this->unk_177 = 0; - } else { - this->unk_177 = ((this->dyna.actor.params & 0x3F) < 0x38) ? 2 : 1; - } - - this->songObserverFunc = ObjTimeblock_WaitForOcarina; - - Actor_SetFocus(&this->dyna.actor, sSizeOptions[(this->dyna.actor.params >> 8) & 1].height); - - this->unk_174 = (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) ? true : false; - this->unk_175 = ((this->dyna.actor.params >> 15) & 1) ? true : false; - this->isVisible = ObjTimeblock_CalculateIsVisible(this); - - if (!((this->dyna.actor.params >> 10) & 1)) { - ObjTimeblock_SetupNormal(this); - } else if (this->isVisible) { - ObjTimeblock_SetupAltBehaviorVisible(this); - } else { - ObjTimeblock_SetupAltBehaviourNotVisible(this); - } - - // "Block of time" - osSyncPrintf("時のブロック ( %04xH save:%d color:%d range:%d move:%d)\n", (u16)this->dyna.actor.params, - this->unk_177, this->dyna.actor.home.rot.z & 7, (this->dyna.actor.params >> 11) & 7, - (this->dyna.actor.params >> 10) & 1); -} - -void ObjTimeblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 pad; - ObjTimeblock* this = (ObjTimeblock*)thisx; - - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -} - -u8 ObjTimeblock_PlayerIsInRange(ObjTimeblock* this, GlobalContext* globalCtx) { - if (this->isVisible && func_80043590(&this->dyna)) { - return false; - } - - if (this->dyna.actor.xzDistToPlayer <= sRanges[(this->dyna.actor.params >> 11) & 7]) { - Vec3f distance; - f32 blockSize; - - func_8002DBD0(&this->dyna.actor, &distance, &GET_PLAYER(globalCtx)->actor.world.pos); - blockSize = this->dyna.actor.scale.x * 50.0f + 6.0f; - // Return true if player's xz position is not inside the block - if (blockSize < fabsf(distance.x) || blockSize < fabsf(distance.z)) { - return true; - } - } - - return false; -} - -s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (ObjTimeblock_PlayerIsInRange(this, globalCtx)) { - if (player->stateFlags2 & 0x1000000) { - func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); - this->songObserverFunc = ObjTimeblock_WaitForSong; - } else { - player->stateFlags2 |= 0x800000; - } - } - return false; -} - -s32 ObjTimeblock_WaitForSong(ObjTimeblock* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - this->songObserverFunc = ObjTimeblock_WaitForOcarina; - } - if (globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME) { - if (this->unk_172 == 254) { - this->songEndTimer = 110; - } else { - this->songEndTimer--; - if (this->songEndTimer == 0) { - return true; - } - } - } - return false; -} - -void ObjTimeblock_SetupDoNothing(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_DoNothing; -} - -void ObjTimeblock_DoNothing(ObjTimeblock* this, GlobalContext* globalCtx) { -} - -void ObjTimeblock_SetupNormal(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_Normal; -} - -void ObjTimeblock_Normal(ObjTimeblock* this, GlobalContext* globalCtx) { - u32 newIsVisible; - - if (this->songObserverFunc(this, globalCtx) && this->demoEffectTimer <= 0) { - ObjTimeblock_SpawnDemoEffect(this, globalCtx); - this->demoEffectTimer = 160; - - // Possibly points the camera to this actor - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - // "◯◯◯◯ Time Block Attention Camera (frame counter %d)\n" - osSyncPrintf("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", globalCtx->state.frames); - - this->demoEffectFirstPartTimer = 12; - - if (this->unk_177 == 0) { - this->dyna.actor.params ^= 0x8000; - } else { - ObjTimeblock_ToggleSwitchFlag(globalCtx, this->dyna.actor.params & 0x3F); - } - } - - this->unk_172 = globalCtx->msgCtx.lastPlayedSong; - if (this->demoEffectFirstPartTimer > 0) { - this->demoEffectFirstPartTimer--; - if (this->demoEffectFirstPartTimer == 0) { - if (this->unk_177 == 0) { - this->unk_175 = ((this->dyna.actor.params >> 15) & 1) ? true : false; - } else { - this->unk_174 = (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) ? true : false; - } - } - } - - newIsVisible = ObjTimeblock_CalculateIsVisible(this); - if (this->unk_177 == 1 && newIsVisible != this->isVisible) { - ObjTimeblock_SetupDoNothing(this); - } - this->isVisible = newIsVisible; - - if (this->demoEffectTimer == 50) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } -} - -void func_80BA06AC(ObjTimeblock* this, GlobalContext* globalCtx) { - s32 switchFlag = this->dyna.actor.params & 0x3F; - - this->unk_172 = globalCtx->msgCtx.lastPlayedSong; - - if (this->demoEffectFirstPartTimer > 0 && --this->demoEffectFirstPartTimer == 0) { - this->unk_174 = (Flags_GetSwitch(globalCtx, switchFlag)) ? true : false; - } - - this->isVisible = ObjTimeblock_CalculateIsVisible(this); - this->unk_176 = (Flags_GetSwitch(globalCtx, switchFlag)) ? true : false; -} - -void ObjTimeblock_SetupAltBehaviorVisible(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_AltBehaviorVisible; -} - -void ObjTimeblock_AltBehaviorVisible(ObjTimeblock* this, GlobalContext* globalCtx) { - if (this->songObserverFunc(this, globalCtx) && this->demoEffectTimer <= 0) { - this->demoEffectFirstPartTimer = 12; - ObjTimeblock_SpawnDemoEffect(this, globalCtx); - this->demoEffectTimer = 160; - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - // "Time Block Attention Camera (frame counter)" - osSyncPrintf("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", globalCtx->state.frames); - ObjTimeblock_ToggleSwitchFlag(globalCtx, this->dyna.actor.params & 0x3F); - } - - func_80BA06AC(this, globalCtx); - - if (this->demoEffectTimer == 50) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } - - if (!this->isVisible && this->demoEffectTimer <= 0) { - ObjTimeblock_SetupAltBehaviourNotVisible(this); - } -} - -void ObjTimeblock_SetupAltBehaviourNotVisible(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_AltBehaviourNotVisible; -} - -void ObjTimeblock_AltBehaviourNotVisible(ObjTimeblock* this, GlobalContext* globalCtx) { - s32 switchFlag = this->dyna.actor.params & 0x3F; - s8 switchFlagIsSet = (Flags_GetSwitch(globalCtx, switchFlag)) ? true : false; - - if (this->unk_176 ^ switchFlagIsSet && switchFlagIsSet ^ (((this->dyna.actor.params >> 15) & 1) ? true : false)) { - if (this->demoEffectTimer <= 0) { - ObjTimeblock_SpawnDemoEffect(this, globalCtx); - this->demoEffectTimer = 160; - } - this->demoEffectFirstPartTimer = 12; - } - - func_80BA06AC(this, globalCtx); - - if (this->isVisible && this->demoEffectTimer <= 0) { - ObjTimeblock_SetupAltBehaviorVisible(this); - } -} - -void ObjTimeblock_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjTimeblock* this = (ObjTimeblock*)thisx; - - this->actionFunc(this, globalCtx); - - if (this->demoEffectTimer > 0) { - this->demoEffectTimer--; - } - - if (this->isVisible) { - func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } else { - func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } -} - -void ObjTimeblock_Draw(Actor* thisx, GlobalContext* globalCtx) { - if (((ObjTimeblock*)thisx)->isVisible) { - Color_RGB8* primColor = &sPrimColors[thisx->home.rot.z & 7]; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 762); - - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 766), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, primColor->r, primColor->g, primColor->b, 255); - gSPDisplayList(POLY_OPA_DISP++, gSongOfTimeBlockDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 772); - } -} diff --git a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp new file mode 100644 index 000000000..21cc37e72 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp @@ -0,0 +1,357 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_TIMEBLOCK_Z_OBJ_TIMEBLOCK_C +#include "actor_common.h" +/* + * File: z_obj_timeblock.c + * Overlay: ovl_Obj_Timeblock + * Description: Song of Time Block + */ + +#include "z_obj_timeblock.h" +#include "objects/object_timeblock/object_timeblock.h" +#include "def/code_80043480.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_25 | ACTOR_FLAG_27) + +void ObjTimeblock_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjTimeblock_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjTimeblock_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjTimeblock_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjTimeblock_SetupNormal(ObjTimeblock* pthis); +void ObjTimeblock_SetupAltBehaviorVisible(ObjTimeblock* pthis); +void ObjTimeblock_SetupAltBehaviourNotVisible(ObjTimeblock* pthis); + +s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* pthis, GlobalContext* globalCtx); +s32 ObjTimeblock_WaitForSong(ObjTimeblock* pthis, GlobalContext* globalCtx); +void ObjTimeblock_DoNothing(ObjTimeblock* pthis, GlobalContext* globalCtx); +void ObjTimeblock_Normal(ObjTimeblock* pthis, GlobalContext* globalCtx); +void ObjTimeblock_AltBehaviorVisible(ObjTimeblock* pthis, GlobalContext* globalCtx); +void ObjTimeblock_AltBehaviourNotVisible(ObjTimeblock* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Timeblock_InitVars = { + ACTOR_OBJ_TIMEBLOCK, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_TIMEBLOCK, + sizeof(ObjTimeblock), + (ActorFunc)ObjTimeblock_Init, + (ActorFunc)ObjTimeblock_Destroy, + (ActorFunc)ObjTimeblock_Update, + (ActorFunc)ObjTimeblock_Draw, +}; + +typedef struct { + /* 0x00 */ f32 scale; + /* 0x04 */ f32 height; + /* 0x08 */ s16 demoEffectParams; +} ObjTimeblockSizeOptions; // size = 0x0C + +static ObjTimeblockSizeOptions sSizeOptions[] = { + { 1.0, 60.0, 0x0018 }, + { 0.60, 40.0, 0x0019 }, +}; + +static f32 sRanges[] = { 60.0, 100.0, 140.0, 180.0, 220.0, 260.0, 300.0, 300.0 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), +}; + +static Color_RGB8 sPrimColors[] = { + { 100, 120, 140 }, { 80, 140, 200 }, { 100, 150, 200 }, { 100, 200, 240 }, + { 80, 110, 140 }, { 70, 160, 225 }, { 80, 100, 130 }, { 100, 110, 190 }, +}; + +u32 ObjTimeblock_CalculateIsVisible(ObjTimeblock* pthis) { + if (!((pthis->dyna.actor.params >> 10) & 1)) { + if (pthis->unk_177 == 0) { + return pthis->unk_175; + } else { + u8 temp = ((pthis->dyna.actor.params >> 15) & 1) ? true : false; + + if (pthis->unk_177 == 1) { + return pthis->unk_174 ^ temp; + } else { + u8 linkIsYoung = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? true : false; + + return pthis->unk_174 ^ temp ^ linkIsYoung; + } + } + } else { + return (((pthis->dyna.actor.params >> 15) & 1) ? true : false) ^ pthis->unk_174; + } +} + +void ObjTimeblock_SpawnDemoEffect(ObjTimeblock* pthis, GlobalContext* globalCtx) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, 0, 0, + sSizeOptions[(pthis->dyna.actor.params >> 8) & 1].demoEffectParams); +} + +void ObjTimeblock_ToggleSwitchFlag(GlobalContext* globalCtx, s32 flag) { + if (Flags_GetSwitch(globalCtx, flag)) { + Flags_UnsetSwitch(globalCtx, flag); + } else { + Flags_SetSwitch(globalCtx, flag); + } +} + +void ObjTimeblock_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjTimeblock* pthis = (ObjTimeblock*)thisx; + s32 pad; + CollisionHeader* colHeader = NULL; + + DynaPolyActor_Init(&pthis->dyna, DPM_UNK); + pthis->dyna.actor.world.rot.z = pthis->dyna.actor.shape.rot.z = 0; + + CollisionHeader_GetVirtual(&gSongOfTimeBlockCol, &colHeader); + + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, colHeader); + + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + Actor_SetScale(&pthis->dyna.actor, sSizeOptions[(pthis->dyna.actor.params >> 8) & 1].scale); + + if ((pthis->dyna.actor.params >> 6) & 1) { + pthis->unk_177 = 0; + } else { + pthis->unk_177 = ((pthis->dyna.actor.params & 0x3F) < 0x38) ? 2 : 1; + } + + pthis->songObserverFunc = ObjTimeblock_WaitForOcarina; + + Actor_SetFocus(&pthis->dyna.actor, sSizeOptions[(pthis->dyna.actor.params >> 8) & 1].height); + + pthis->unk_174 = (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) ? true : false; + pthis->unk_175 = ((pthis->dyna.actor.params >> 15) & 1) ? true : false; + pthis->isVisible = ObjTimeblock_CalculateIsVisible(pthis); + + if (!((pthis->dyna.actor.params >> 10) & 1)) { + ObjTimeblock_SetupNormal(pthis); + } else if (pthis->isVisible) { + ObjTimeblock_SetupAltBehaviorVisible(pthis); + } else { + ObjTimeblock_SetupAltBehaviourNotVisible(pthis); + } + + // "Block of time" + osSyncPrintf("時のブロック ( %04xH save:%d color:%d range:%d move:%d)\n", (u16)pthis->dyna.actor.params, + pthis->unk_177, pthis->dyna.actor.home.rot.z & 7, (pthis->dyna.actor.params >> 11) & 7, + (pthis->dyna.actor.params >> 10) & 1); +} + +void ObjTimeblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjTimeblock* pthis = (ObjTimeblock*)thisx; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); +} + +u8 ObjTimeblock_PlayerIsInRange(ObjTimeblock* pthis, GlobalContext* globalCtx) { + if (pthis->isVisible && func_80043590(&pthis->dyna)) { + return false; + } + + if (pthis->dyna.actor.xzDistToPlayer <= sRanges[(pthis->dyna.actor.params >> 11) & 7]) { + Vec3f distance; + f32 blockSize; + + func_8002DBD0(&pthis->dyna.actor, &distance, &GET_PLAYER(globalCtx)->actor.world.pos); + blockSize = pthis->dyna.actor.scale.x * 50.0f + 6.0f; + // Return true if player's xz position is not inside the block + if (blockSize < fabsf(distance.x) || blockSize < fabsf(distance.z)) { + return true; + } + } + + return false; +} + +s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ObjTimeblock_PlayerIsInRange(pthis, globalCtx)) { + if (player->stateFlags2 & 0x1000000) { + func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); + pthis->songObserverFunc = ObjTimeblock_WaitForSong; + } else { + player->stateFlags2 |= 0x800000; + } + } + return false; +} + +s32 ObjTimeblock_WaitForSong(ObjTimeblock* pthis, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + pthis->songObserverFunc = ObjTimeblock_WaitForOcarina; + } + if (globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME) { + if (pthis->unk_172 == 254) { + pthis->songEndTimer = 110; + } else { + pthis->songEndTimer--; + if (pthis->songEndTimer == 0) { + return true; + } + } + } + return false; +} + +void ObjTimeblock_SetupDoNothing(ObjTimeblock* pthis) { + pthis->actionFunc = ObjTimeblock_DoNothing; +} + +void ObjTimeblock_DoNothing(ObjTimeblock* pthis, GlobalContext* globalCtx) { +} + +void ObjTimeblock_SetupNormal(ObjTimeblock* pthis) { + pthis->actionFunc = ObjTimeblock_Normal; +} + +void ObjTimeblock_Normal(ObjTimeblock* pthis, GlobalContext* globalCtx) { + u32 newIsVisible; + + if (pthis->songObserverFunc(pthis, globalCtx) && pthis->demoEffectTimer <= 0) { + ObjTimeblock_SpawnDemoEffect(pthis, globalCtx); + pthis->demoEffectTimer = 160; + + // Possibly points the camera to pthis actor + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + // "◯◯◯◯ Time Block Attention Camera (frame counter %d)\n" + osSyncPrintf("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", globalCtx->state.frames); + + pthis->demoEffectFirstPartTimer = 12; + + if (pthis->unk_177 == 0) { + pthis->dyna.actor.params ^= 0x8000; + } else { + ObjTimeblock_ToggleSwitchFlag(globalCtx, pthis->dyna.actor.params & 0x3F); + } + } + + pthis->unk_172 = globalCtx->msgCtx.lastPlayedSong; + if (pthis->demoEffectFirstPartTimer > 0) { + pthis->demoEffectFirstPartTimer--; + if (pthis->demoEffectFirstPartTimer == 0) { + if (pthis->unk_177 == 0) { + pthis->unk_175 = ((pthis->dyna.actor.params >> 15) & 1) ? true : false; + } else { + pthis->unk_174 = (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) ? true : false; + } + } + } + + newIsVisible = ObjTimeblock_CalculateIsVisible(pthis); + if (pthis->unk_177 == 1 && newIsVisible != pthis->isVisible) { + ObjTimeblock_SetupDoNothing(pthis); + } + pthis->isVisible = newIsVisible; + + if (pthis->demoEffectTimer == 50) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } +} + +void func_80BA06AC(ObjTimeblock* pthis, GlobalContext* globalCtx) { + s32 switchFlag = pthis->dyna.actor.params & 0x3F; + + pthis->unk_172 = globalCtx->msgCtx.lastPlayedSong; + + if (pthis->demoEffectFirstPartTimer > 0 && --pthis->demoEffectFirstPartTimer == 0) { + pthis->unk_174 = (Flags_GetSwitch(globalCtx, switchFlag)) ? true : false; + } + + pthis->isVisible = ObjTimeblock_CalculateIsVisible(pthis); + pthis->unk_176 = (Flags_GetSwitch(globalCtx, switchFlag)) ? true : false; +} + +void ObjTimeblock_SetupAltBehaviorVisible(ObjTimeblock* pthis) { + pthis->actionFunc = ObjTimeblock_AltBehaviorVisible; +} + +void ObjTimeblock_AltBehaviorVisible(ObjTimeblock* pthis, GlobalContext* globalCtx) { + if (pthis->songObserverFunc(pthis, globalCtx) && pthis->demoEffectTimer <= 0) { + pthis->demoEffectFirstPartTimer = 12; + ObjTimeblock_SpawnDemoEffect(pthis, globalCtx); + pthis->demoEffectTimer = 160; + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + // "Time Block Attention Camera (frame counter)" + osSyncPrintf("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", globalCtx->state.frames); + ObjTimeblock_ToggleSwitchFlag(globalCtx, pthis->dyna.actor.params & 0x3F); + } + + func_80BA06AC(pthis, globalCtx); + + if (pthis->demoEffectTimer == 50) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } + + if (!pthis->isVisible && pthis->demoEffectTimer <= 0) { + ObjTimeblock_SetupAltBehaviourNotVisible(pthis); + } +} + +void ObjTimeblock_SetupAltBehaviourNotVisible(ObjTimeblock* pthis) { + pthis->actionFunc = ObjTimeblock_AltBehaviourNotVisible; +} + +void ObjTimeblock_AltBehaviourNotVisible(ObjTimeblock* pthis, GlobalContext* globalCtx) { + s32 switchFlag = pthis->dyna.actor.params & 0x3F; + s8 switchFlagIsSet = (Flags_GetSwitch(globalCtx, switchFlag)) ? true : false; + + if (pthis->unk_176 ^ switchFlagIsSet && switchFlagIsSet ^ (((pthis->dyna.actor.params >> 15) & 1) ? true : false)) { + if (pthis->demoEffectTimer <= 0) { + ObjTimeblock_SpawnDemoEffect(pthis, globalCtx); + pthis->demoEffectTimer = 160; + } + pthis->demoEffectFirstPartTimer = 12; + } + + func_80BA06AC(pthis, globalCtx); + + if (pthis->isVisible && pthis->demoEffectTimer <= 0) { + ObjTimeblock_SetupAltBehaviorVisible(pthis); + } +} + +void ObjTimeblock_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjTimeblock* pthis = (ObjTimeblock*)thisx; + + pthis->actionFunc(pthis, globalCtx); + + if (pthis->demoEffectTimer > 0) { + pthis->demoEffectTimer--; + } + + if (pthis->isVisible) { + func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } else { + func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } +} + +void ObjTimeblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + if (((ObjTimeblock*)thisx)->isVisible) { + Color_RGB8* primColor = &sPrimColors[thisx->home.rot.z & 7]; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 762); + + func_80093D18(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 766), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, primColor->r, primColor->g, primColor->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gSongOfTimeBlockDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 772); + } +} diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c deleted file mode 100644 index 63568e6a0..000000000 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ /dev/null @@ -1,350 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_TSUBO_Z_OBJ_TSUBO_C -#include "actor_common.h" -/* - * File: z_obj_tsubo.c - * Overlay: ovl_Obj_Tsubo - * Description: Breakable pot - */ - -#include "z_obj_tsubo.h" -#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#include "objects/object_tsubo/object_tsubo.h" -#include "def/code_8006BA00.h" -#include "def/code_800FD970.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_cheap_proc.h" -#include "def/z_collision_check.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_lib.h" -#include "def/z_scene.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) - -void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTsubo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjTsubo_SpawnCollectible(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_ApplyGravity(ObjTsubo* this); -s32 ObjTsubo_SnapToFloor(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_InitCollider(Actor* thisx, GlobalContext* globalCtx); -void ObjTsubo_AirBreak(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_WaterBreak(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_SetupWaitForObject(ObjTsubo* this); -void ObjTsubo_WaitForObject(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_SetupIdle(ObjTsubo* this); -void ObjTsubo_Idle(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_SetupLiftedUp(ObjTsubo* this); -void ObjTsubo_LiftedUp(ObjTsubo* this, GlobalContext* globalCtx); -void ObjTsubo_SetupThrown(ObjTsubo* this); -void ObjTsubo_Thrown(ObjTsubo* this, GlobalContext* globalCtx); - -static s16 D_80BA1B50 = 0; -static s16 D_80BA1B54 = 0; -static s16 D_80BA1B58 = 0; -static s16 D_80BA1B5C = 0; - -const ActorInit Obj_Tsubo_InitVars = { - ACTOR_OBJ_TSUBO, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ObjTsubo), - (ActorFunc)ObjTsubo_Init, - (ActorFunc)ObjTsubo_Destroy, - (ActorFunc)ObjTsubo_Update, - NULL, -}; - -static s16 sObjectIds[] = { OBJECT_GAMEPLAY_DANGEON_KEEP, OBJECT_TSUBO }; - -static Gfx* D_80BA1B84[] = { gPotDL, object_tsubo_DL_0017C0 }; - -static Gfx* D_80BA1B8C[] = { gPotFragmentDL, object_tsubo_DL_001960 }; - -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_HARD, - AT_ON | AT_TYPE_PLAYER, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000002, 0x00, 0x01 }, - { 0x4FC1FFFE, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 9, 26, 0, { 0, 0, 0 } }, -}; - -static CollisionCheckInfoInit sColChkInfoInit[] = { 0, 12, 60, MASS_IMMOVABLE }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 900, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), -}; - -void ObjTsubo_SpawnCollectible(ObjTsubo* this, GlobalContext* globalCtx) { - s16 dropParams = this->actor.params & 0x1F; - - if ((dropParams >= ITEM00_RUPEE_GREEN) && (dropParams <= ITEM00_BOMBS_SPECIAL)) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, - (dropParams | (((this->actor.params >> 9) & 0x3F) << 8))); - } -} - -void ObjTsubo_ApplyGravity(ObjTsubo* this) { - this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { - this->actor.velocity.y = this->actor.minVelocityY; - } -} - -s32 ObjTsubo_SnapToFloor(ObjTsubo* this, GlobalContext* globalCtx) { - CollisionPoly* floorPoly; - Vec3f pos; - s32 bgID; - f32 floorY; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 20.0f; - pos.z = this->actor.world.pos.z; - floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgID, &this->actor, &pos); - if (floorY > BGCHECK_Y_MIN) { - this->actor.world.pos.y = floorY; - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - return true; - } else { - osSyncPrintf("地面に付着失敗\n"); - return false; - } -} - -void ObjTsubo_InitCollider(Actor* thisx, GlobalContext* globalCtx) { - ObjTsubo* this = (ObjTsubo*)thisx; - - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); -} - -void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjTsubo* this = (ObjTsubo*)thisx; - - Actor_ProcessInitChain(&this->actor, sInitChain); - ObjTsubo_InitCollider(&this->actor, globalCtx); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, sColChkInfoInit); - if (!ObjTsubo_SnapToFloor(this, globalCtx)) { - Actor_Kill(&this->actor); - return; - } - this->objTsuboBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[(this->actor.params >> 8) & 1]); - if (this->objTsuboBankIndex < 0) { - osSyncPrintf("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", this->actor.params, "../z_obj_tsubo.c", 410); - Actor_Kill(&this->actor); - } else { - ObjTsubo_SetupWaitForObject(this); - osSyncPrintf("(dungeon keep 壷)(arg_data 0x%04x)\n", this->actor.params); - } -} - -void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - ObjTsubo* this = (ObjTsubo*)thisx; - - Collider_DestroyCylinder(globalCtx, &this->collider); -} - -void ObjTsubo_AirBreak(ObjTsubo* this, GlobalContext* globalCtx) { - s32 pad; - f32 rand; - s16 angle; - Vec3f pos; - Vec3f velocity; - f32 sins; - f32 coss; - s32 arg5; - s32 i; - - for (i = 0, angle = 0; i < 15; i++, angle += 0x4E20) { - sins = Math_SinS(angle); - coss = Math_CosS(angle); - pos.x = sins * 8.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = coss * 8.0f; - velocity.x = pos.x * 0.23f; - velocity.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - velocity.z = pos.z * 0.23f; - Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); - rand = Rand_ZeroOne(); - if (rand < 0.2f) { - arg5 = 96; - } else if (rand < 0.6f) { - arg5 = 64; - } else { - arg5 = 32; - } - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &this->actor.world.pos, -240, arg5, 10, 10, 0, - (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 32, 60, KAKERA_COLOR_NONE, - sObjectIds[(this->actor.params >> 8) & 1], D_80BA1B8C[(this->actor.params >> 8) & 1]); - } - func_80033480(globalCtx, &this->actor.world.pos, 30.0f, 4, 20, 50, 1); -} - -void ObjTsubo_WaterBreak(ObjTsubo* this, GlobalContext* globalCtx) { - s32 pad[2]; - s16 angle; - Vec3f pos = this->actor.world.pos; - Vec3f velocity; - s32 phi_s0; - s32 i; - - pos.y += this->actor.yDistToWater; - EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 400); - for (i = 0, angle = 0; i < 15; i++, angle += 0x4E20) { - f32 sins = Math_SinS(angle); - f32 coss = Math_CosS(angle); - - pos.x = sins * 8.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = coss * 8.0f; - velocity.x = pos.x * 0.2f; - velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; - velocity.z = pos.z * 0.2f; - Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); - phi_s0 = (Rand_ZeroOne() < .2f) ? 64 : 32; - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &this->actor.world.pos, -180, phi_s0, 30, 30, 0, - (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 32, 70, KAKERA_COLOR_NONE, - sObjectIds[(this->actor.params >> 8) & 1], D_80BA1B8C[(this->actor.params >> 8) & 1]); - } -} - -void ObjTsubo_SetupWaitForObject(ObjTsubo* this) { - this->actionFunc = ObjTsubo_WaitForObject; -} - -void ObjTsubo_WaitForObject(ObjTsubo* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objTsuboBankIndex)) { - this->actor.draw = ObjTsubo_Draw; - this->actor.objBankIndex = this->objTsuboBankIndex; - ObjTsubo_SetupIdle(this); - this->actor.flags &= ~ACTOR_FLAG_4; - } -} - -void ObjTsubo_SetupIdle(ObjTsubo* this) { - this->actionFunc = ObjTsubo_Idle; -} - -void ObjTsubo_Idle(ObjTsubo* this, GlobalContext* globalCtx) { - s32 pad; - s16 temp_v0; - s32 phi_v1; - - if (Actor_HasParent(&this->actor, globalCtx)) { - ObjTsubo_SetupLiftedUp(this); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f)) { - ObjTsubo_WaterBreak(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); - ObjTsubo_SpawnCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } else if ((this->collider.base.acFlags & AC_HIT) && - (this->collider.info.acHitInfo->toucher.dmgFlags & 0x4FC1FFFC)) { - ObjTsubo_AirBreak(this, globalCtx); - ObjTsubo_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); - Actor_Kill(&this->actor); - } else { - if (this->actor.xzDistToPlayer < 600.0f) { - Collider_UpdateCylinder(&this->actor, &this->collider); - this->collider.base.acFlags &= ~AC_HIT; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer < 150.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } - if (this->actor.xzDistToPlayer < 100.0f) { - temp_v0 = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; - phi_v1 = ABS(temp_v0); - if (phi_v1 >= 0x5556) { - // GI_NONE in this case allows the player to lift the actor - func_8002F434(&this->actor, globalCtx, GI_NONE, 30.0f, 30.0f); - } - } - } -} - -void ObjTsubo_SetupLiftedUp(ObjTsubo* this) { - this->actionFunc = ObjTsubo_LiftedUp; - this->actor.room = -1; - func_8002F7DC(&this->actor, NA_SE_PL_PULL_UP_POT); - this->actor.flags |= ACTOR_FLAG_4; -} - -void ObjTsubo_LiftedUp(ObjTsubo* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.curRoom.num; - ObjTsubo_SetupThrown(this); - ObjTsubo_ApplyGravity(this); - func_8002D7EC(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 15.0f, 0.0f, 0x85); - } -} - -void ObjTsubo_SetupThrown(ObjTsubo* this) { - this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - this->actor.colChkInfo.mass = 240; - D_80BA1B50 = (Rand_ZeroOne() - 0.7f) * 2800.0f; - D_80BA1B58 = (Rand_ZeroOne() - 0.5f) * 2000.0f; - D_80BA1B54 = 0; - D_80BA1B5C = 0; - this->actionFunc = ObjTsubo_Thrown; -} - -void ObjTsubo_Thrown(ObjTsubo* this, GlobalContext* globalCtx) { - s32 pad[2]; - - if ((this->actor.bgCheckFlags & 0xB) || (this->collider.base.atFlags & AT_HIT)) { - ObjTsubo_AirBreak(this, globalCtx); - ObjTsubo_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); - Actor_Kill(&this->actor); - } else if (this->actor.bgCheckFlags & 0x40) { - ObjTsubo_WaterBreak(this, globalCtx); - ObjTsubo_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); - Actor_Kill(&this->actor); - } else { - ObjTsubo_ApplyGravity(this); - func_8002D7EC(&this->actor); - Math_StepToS(&D_80BA1B54, D_80BA1B50, 0x64); - Math_StepToS(&D_80BA1B5C, D_80BA1B58, 0x64); - this->actor.shape.rot.x += D_80BA1B54; - this->actor.shape.rot.y += D_80BA1B5C; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 15.0f, 0.0f, 0x85); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } -} - -void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjTsubo* this = (ObjTsubo*)thisx; - - this->actionFunc(this, globalCtx); -} - -void ObjTsubo_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, D_80BA1B84[(thisx->params >> 8) & 1]); -} diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.cpp b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.cpp new file mode 100644 index 000000000..96596a40a --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.cpp @@ -0,0 +1,350 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_TSUBO_Z_OBJ_TSUBO_C +#include "actor_common.h" +/* + * File: z_obj_tsubo.c + * Overlay: ovl_Obj_Tsubo + * Description: Breakable pot + */ + +#include "z_obj_tsubo.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_tsubo/object_tsubo.h" +#include "def/code_8006BA00.h" +#include "def/code_800FD970.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_cheap_proc.h" +#include "def/z_collision_check.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_lib.h" +#include "def/z_scene.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) + +void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjTsubo_SpawnCollectible(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_ApplyGravity(ObjTsubo* pthis); +s32 ObjTsubo_SnapToFloor(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_InitCollider(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_AirBreak(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_WaterBreak(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_SetupWaitForObject(ObjTsubo* pthis); +void ObjTsubo_WaitForObject(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_SetupIdle(ObjTsubo* pthis); +void ObjTsubo_Idle(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_SetupLiftedUp(ObjTsubo* pthis); +void ObjTsubo_LiftedUp(ObjTsubo* pthis, GlobalContext* globalCtx); +void ObjTsubo_SetupThrown(ObjTsubo* pthis); +void ObjTsubo_Thrown(ObjTsubo* pthis, GlobalContext* globalCtx); + +static s16 D_80BA1B50 = 0; +static s16 D_80BA1B54 = 0; +static s16 D_80BA1B58 = 0; +static s16 D_80BA1B5C = 0; + +ActorInit Obj_Tsubo_InitVars = { + ACTOR_OBJ_TSUBO, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ObjTsubo), + (ActorFunc)ObjTsubo_Init, + (ActorFunc)ObjTsubo_Destroy, + (ActorFunc)ObjTsubo_Update, + NULL, +}; + +static s16 sObjectIds[] = { OBJECT_GAMEPLAY_DANGEON_KEEP, OBJECT_TSUBO }; + +static Gfx* D_80BA1B84[] = { gPotDL, object_tsubo_DL_0017C0 }; + +static Gfx* D_80BA1B8C[] = { gPotFragmentDL, object_tsubo_DL_001960 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000002, 0x00, 0x01 }, + { 0x4FC1FFFE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 9, 26, 0, { 0, 0, 0 } }, +}; + +static CollisionCheckInfoInit sColChkInfoInit[] = { 0, 12, 60, MASS_IMMOVABLE }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 900, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), +}; + +void ObjTsubo_SpawnCollectible(ObjTsubo* pthis, GlobalContext* globalCtx) { + s16 dropParams = pthis->actor.params & 0x1F; + + if ((dropParams >= ITEM00_RUPEE_GREEN) && (dropParams <= ITEM00_BOMBS_SPECIAL)) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, + (dropParams | (((pthis->actor.params >> 9) & 0x3F) << 8))); + } +} + +void ObjTsubo_ApplyGravity(ObjTsubo* pthis) { + pthis->actor.velocity.y += pthis->actor.gravity; + if (pthis->actor.velocity.y < pthis->actor.minVelocityY) { + pthis->actor.velocity.y = pthis->actor.minVelocityY; + } +} + +s32 ObjTsubo_SnapToFloor(ObjTsubo* pthis, GlobalContext* globalCtx) { + CollisionPoly* floorPoly; + Vec3f pos; + s32 bgID; + f32 floorY; + + pos.x = pthis->actor.world.pos.x; + pos.y = pthis->actor.world.pos.y + 20.0f; + pos.z = pthis->actor.world.pos.z; + floorY = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &floorPoly, &bgID, &pthis->actor, &pos); + if (floorY > BGCHECK_Y_MIN) { + pthis->actor.world.pos.y = floorY; + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); + return true; + } else { + osSyncPrintf("地面に付着失敗\n"); + return false; + } +} + +void ObjTsubo_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + ObjTsubo* pthis = (ObjTsubo*)thisx; + + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); +} + +void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjTsubo* pthis = (ObjTsubo*)thisx; + + Actor_ProcessInitChain(&pthis->actor, sInitChain); + ObjTsubo_InitCollider(&pthis->actor, globalCtx); + CollisionCheck_SetInfo(&pthis->actor.colChkInfo, NULL, sColChkInfoInit); + if (!ObjTsubo_SnapToFloor(pthis, globalCtx)) { + Actor_Kill(&pthis->actor); + return; + } + pthis->objTsuboBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[(pthis->actor.params >> 8) & 1]); + if (pthis->objTsuboBankIndex < 0) { + osSyncPrintf("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", pthis->actor.params, "../z_obj_tsubo.c", 410); + Actor_Kill(&pthis->actor); + } else { + ObjTsubo_SetupWaitForObject(pthis); + osSyncPrintf("(dungeon keep 壷)(arg_data 0x%04x)\n", pthis->actor.params); + } +} + +void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjTsubo* pthis = (ObjTsubo*)thisx; + + Collider_DestroyCylinder(globalCtx, &pthis->collider); +} + +void ObjTsubo_AirBreak(ObjTsubo* pthis, GlobalContext* globalCtx) { + s32 pad; + f32 rand; + s16 angle; + Vec3f pos; + Vec3f velocity; + f32 sins; + f32 coss; + s32 arg5; + s32 i; + + for (i = 0, angle = 0; i < 15; i++, angle += 0x4E20) { + sins = Math_SinS(angle); + coss = Math_CosS(angle); + pos.x = sins * 8.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = coss * 8.0f; + velocity.x = pos.x * 0.23f; + velocity.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + velocity.z = pos.z * 0.23f; + Math_Vec3f_Sum(&pos, &pthis->actor.world.pos, &pos); + rand = Rand_ZeroOne(); + if (rand < 0.2f) { + arg5 = 96; + } else if (rand < 0.6f) { + arg5 = 64; + } else { + arg5 = 32; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pthis->actor.world.pos, -240, arg5, 10, 10, 0, + (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 32, 60, KAKERA_COLOR_NONE, + sObjectIds[(pthis->actor.params >> 8) & 1], D_80BA1B8C[(pthis->actor.params >> 8) & 1]); + } + func_80033480(globalCtx, &pthis->actor.world.pos, 30.0f, 4, 20, 50, 1); +} + +void ObjTsubo_WaterBreak(ObjTsubo* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + s16 angle; + Vec3f pos = pthis->actor.world.pos; + Vec3f velocity; + s32 phi_s0; + s32 i; + + pos.y += pthis->actor.yDistToWater; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 400); + for (i = 0, angle = 0; i < 15; i++, angle += 0x4E20) { + f32 sins = Math_SinS(angle); + f32 coss = Math_CosS(angle); + + pos.x = sins * 8.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = coss * 8.0f; + velocity.x = pos.x * 0.2f; + velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + velocity.z = pos.z * 0.2f; + Math_Vec3f_Sum(&pos, &pthis->actor.world.pos, &pos); + phi_s0 = (Rand_ZeroOne() < .2f) ? 64 : 32; + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pthis->actor.world.pos, -180, phi_s0, 30, 30, 0, + (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 32, 70, KAKERA_COLOR_NONE, + sObjectIds[(pthis->actor.params >> 8) & 1], D_80BA1B8C[(pthis->actor.params >> 8) & 1]); + } +} + +void ObjTsubo_SetupWaitForObject(ObjTsubo* pthis) { + pthis->actionFunc = ObjTsubo_WaitForObject; +} + +void ObjTsubo_WaitForObject(ObjTsubo* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->objTsuboBankIndex)) { + pthis->actor.draw = ObjTsubo_Draw; + pthis->actor.objBankIndex = pthis->objTsuboBankIndex; + ObjTsubo_SetupIdle(pthis); + pthis->actor.flags &= ~ACTOR_FLAG_4; + } +} + +void ObjTsubo_SetupIdle(ObjTsubo* pthis) { + pthis->actionFunc = ObjTsubo_Idle; +} + +void ObjTsubo_Idle(ObjTsubo* pthis, GlobalContext* globalCtx) { + s32 pad; + s16 temp_v0; + s32 phi_v1; + + if (Actor_HasParent(&pthis->actor, globalCtx)) { + ObjTsubo_SetupLiftedUp(pthis); + } else if ((pthis->actor.bgCheckFlags & 0x20) && (pthis->actor.yDistToWater > 15.0f)) { + ObjTsubo_WaterBreak(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + ObjTsubo_SpawnCollectible(pthis, globalCtx); + Actor_Kill(&pthis->actor); + } else if ((pthis->collider.base.acFlags & AC_HIT) && + (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x4FC1FFFC)) { + ObjTsubo_AirBreak(pthis, globalCtx); + ObjTsubo_SpawnCollectible(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + Actor_Kill(&pthis->actor); + } else { + if (pthis->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + pthis->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + if (pthis->actor.xzDistToPlayer < 150.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } + } + if (pthis->actor.xzDistToPlayer < 100.0f) { + temp_v0 = pthis->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; + phi_v1 = ABS(temp_v0); + if (phi_v1 >= 0x5556) { + // GI_NONE in pthis case allows the player to lift the actor + func_8002F434(&pthis->actor, globalCtx, GI_NONE, 30.0f, 30.0f); + } + } + } +} + +void ObjTsubo_SetupLiftedUp(ObjTsubo* pthis) { + pthis->actionFunc = ObjTsubo_LiftedUp; + pthis->actor.room = -1; + func_8002F7DC(&pthis->actor, NA_SE_PL_PULL_UP_POT); + pthis->actor.flags |= ACTOR_FLAG_4; +} + +void ObjTsubo_LiftedUp(ObjTsubo* pthis, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&pthis->actor, globalCtx)) { + pthis->actor.room = globalCtx->roomCtx.curRoom.num; + ObjTsubo_SetupThrown(pthis); + ObjTsubo_ApplyGravity(pthis); + func_8002D7EC(&pthis->actor); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 15.0f, 0.0f, 0x85); + } +} + +void ObjTsubo_SetupThrown(ObjTsubo* pthis) { + pthis->actor.velocity.x = Math_SinS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.velocity.z = Math_CosS(pthis->actor.world.rot.y) * pthis->actor.speedXZ; + pthis->actor.colChkInfo.mass = 240; + D_80BA1B50 = (Rand_ZeroOne() - 0.7f) * 2800.0f; + D_80BA1B58 = (Rand_ZeroOne() - 0.5f) * 2000.0f; + D_80BA1B54 = 0; + D_80BA1B5C = 0; + pthis->actionFunc = ObjTsubo_Thrown; +} + +void ObjTsubo_Thrown(ObjTsubo* pthis, GlobalContext* globalCtx) { + s32 pad[2]; + + if ((pthis->actor.bgCheckFlags & 0xB) || (pthis->collider.base.atFlags & AT_HIT)) { + ObjTsubo_AirBreak(pthis, globalCtx); + ObjTsubo_SpawnCollectible(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + Actor_Kill(&pthis->actor); + } else if (pthis->actor.bgCheckFlags & 0x40) { + ObjTsubo_WaterBreak(pthis, globalCtx); + ObjTsubo_SpawnCollectible(pthis, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &pthis->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + Actor_Kill(&pthis->actor); + } else { + ObjTsubo_ApplyGravity(pthis); + func_8002D7EC(&pthis->actor); + Math_StepToS(&D_80BA1B54, D_80BA1B50, 0x64); + Math_StepToS(&D_80BA1B5C, D_80BA1B58, 0x64); + pthis->actor.shape.rot.x += D_80BA1B54; + pthis->actor.shape.rot.y += D_80BA1B5C; + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 5.0f, 15.0f, 0.0f, 0x85); + Collider_UpdateCylinder(&pthis->actor, &pthis->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); + } +} + +void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjTsubo* pthis = (ObjTsubo*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void ObjTsubo_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80BA1B84[(thisx->params >> 8) & 1]); +} diff --git a/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c b/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c deleted file mode 100644 index 04b62e0ae..000000000 --- a/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c +++ /dev/null @@ -1,330 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_WARP2BLOCK_Z_OBJ_WARP2BLOCK_C -#include "actor_common.h" -/* - * File: z_obj_warp2block.c - * Overlay: ovl_Obj_Warp2Block - * Description: Navi Infospot (Green, Time Block) - */ - -#include "z_obj_warp2block.h" -#include "objects/object_timeblock/object_timeblock.h" -#include "vt.h" -#include "def/code_80043480.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_lib.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_rcp.h" - -#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_25 | ACTOR_FLAG_27) - -void ObjWarp2block_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjWarp2block_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjWarp2block_Spawn(ObjWarp2block* this, GlobalContext* globalCtx); -s32 func_80BA1ECC(ObjWarp2block* this, GlobalContext* globalCtx); -void ObjWarp2block_SwapWithChild(ObjWarp2block* this, GlobalContext* globalCtx); -s32 func_80BA2218(ObjWarp2block* this, GlobalContext* globalCtx); -s32 func_80BA228C(ObjWarp2block* this, GlobalContext* globalCtx); -s32 func_80BA2304(ObjWarp2block* this, GlobalContext* globalCtx); -void ObjWarp2block_SetInactive(ObjWarp2block* this); -void ObjWarp2block_DoNothing(ObjWarp2block* this, GlobalContext* globalCtx); -void func_80BA24E8(ObjWarp2block* this); -void func_80BA24F8(ObjWarp2block* this, GlobalContext* globalCtx); -void func_80BA2600(ObjWarp2block* this); -void func_80BA2610(ObjWarp2block* this, GlobalContext* globalCtx); - -const ActorInit Obj_Warp2block_InitVars = { - ACTOR_OBJ_WARP2BLOCK, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_TIMEBLOCK, - sizeof(ObjWarp2block), - (ActorFunc)ObjWarp2block_Init, - (ActorFunc)ObjWarp2block_Destroy, - (ActorFunc)ObjWarp2block_Update, - (ActorFunc)ObjWarp2block_Draw, -}; - -typedef struct { - /* 0x00 */ f32 scale; - /* 0x04 */ f32 focus; - /* 0x08 */ s16 params; -} Warp2BlockSpawnData; // size = 0x0C - -static Warp2BlockSpawnData sSpawnData[] = { - { 1.0f, 60.0f, 0x0018 }, - { 0.6f, 40.0f, 0x0019 }, -}; - -static f32 sDistances[] = { 60.0f, 100.0f, 140.0f, 180.0f, 220.0f, 260.0f, 300.0f, 300.0f }; - -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), -}; - -static Color_RGB8 sColors[] = { - { 100, 120, 140 }, { 80, 140, 200 }, { 100, 150, 200 }, { 100, 200, 240 }, - { 80, 110, 140 }, { 70, 160, 225 }, { 80, 100, 130 }, { 100, 110, 190 }, -}; - -void ObjWarp2block_Spawn(ObjWarp2block* this, GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, - sSpawnData[(this->dyna.actor.params >> 8) & 1].params); - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.child->world.pos.x, - this->dyna.actor.child->world.pos.y, this->dyna.actor.child->world.pos.z, 0, 0, 0, - sSpawnData[(this->dyna.actor.child->params >> 8) & 1].params); -} - -s32 func_80BA1ECC(ObjWarp2block* this, GlobalContext* globalCtx) { - s32 pad; - Actor* temp_a3; - Player* player; - Vec3f sp20; - f32 temp_f2; - - if (func_80043590(&this->dyna)) { - return 0; - } - - temp_a3 = this->dyna.actor.child; - player = GET_PLAYER(globalCtx); - if ((this->dyna.actor.xzDistToPlayer <= sDistances[(((this->dyna.actor.params >> 0xB) & 7))]) || - (temp_a3->xzDistToPlayer <= sDistances[(((temp_a3->params >> 0xB) & 7))])) { - - func_8002DBD0(&this->dyna.actor, &sp20, &player->actor.world.pos); - temp_f2 = (this->dyna.actor.scale.x * 50.0f) + 6.0f; - - if (!(temp_f2 < fabsf(sp20.x)) && !(temp_f2 < fabsf(sp20.z))) { - return 0; - } - - func_8002DBD0(temp_a3, &sp20, &player->actor.world.pos); - temp_f2 = (temp_a3->scale.x * 50.0f) + 6.0f; - - if (!(temp_f2 < fabsf(sp20.x)) && !(temp_f2 < fabsf(sp20.z))) { - return 0; - } - } else { - return 0; - } - - return 1; -} - -void ObjWarp2block_SwapWithChild(ObjWarp2block* this, GlobalContext* globalCtx) { - Vec3f tempVec; - Vec3s tempRot; - s32 temp; - - Math_Vec3f_Copy(&tempVec, &this->dyna.actor.world.pos); - Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.child->world.pos); - Math_Vec3f_Copy(&this->dyna.actor.child->world.pos, &tempVec); - - temp = this->dyna.actor.world.rot.y; - this->dyna.actor.world.rot.y = this->dyna.actor.child->world.rot.y; - this->dyna.actor.child->world.rot.y = temp; - - temp = this->dyna.actor.shape.rot.y; - this->dyna.actor.shape.rot.y = this->dyna.actor.child->shape.rot.y; - this->dyna.actor.child->shape.rot.y = temp; - - temp = this->dyna.actor.home.rot.z; - this->dyna.actor.home.rot.z = this->dyna.actor.child->home.rot.z; - this->dyna.actor.child->home.rot.z = temp; - - Math_Vec3f_Copy(&tempVec, &this->dyna.actor.scale); - Math_Vec3f_Copy(&this->dyna.actor.scale, &this->dyna.actor.child->scale); - Math_Vec3f_Copy(&this->dyna.actor.child->scale, &tempVec); - - Math_Vec3f_Copy(&tempVec, &this->dyna.actor.focus.pos); - Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.child->focus.pos); - Math_Vec3f_Copy(&this->dyna.actor.child->focus.pos, &tempVec); - - tempRot = this->dyna.actor.focus.rot; - this->dyna.actor.focus.rot = this->dyna.actor.child->focus.rot; - this->dyna.actor.child->focus.rot = tempRot; - - temp = this->dyna.actor.params & 0x7FFF; - this->dyna.actor.params = (this->dyna.actor.params & 0x8000) | (this->dyna.actor.child->params & 0x7FFF); - this->dyna.actor.child->params = (this->dyna.actor.child->params & 0x8000) | (temp & 0x7FFF); - - if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos) < 0.01f) { - Flags_UnsetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - } else { - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - } -} - -s32 func_80BA2218(ObjWarp2block* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - - if (func_80BA1ECC(this, globalCtx)) { - if (player->stateFlags2 & 0x1000000) { - func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); - this->func_168 = func_80BA228C; - } else { - player->stateFlags2 |= 0x800000; - } - } - - return 0; -} - -s32 func_80BA228C(ObjWarp2block* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - this->func_168 = func_80BA2218; - } - - if (globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME) { - if (this->unk_172 == 0xFE) { - this->unk_16E = 0x6E; - } else { - this->unk_16E--; - if (this->unk_16E == 0) { - return 1; - } - } - } - return 0; -} - -s32 func_80BA2304(ObjWarp2block* this, GlobalContext* globalCtx) { - s32 ret = this->func_168(this, globalCtx); - - this->unk_172 = globalCtx->msgCtx.lastPlayedSong; - - return ret; -} - -void ObjWarp2block_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - ObjWarp2block* this = (ObjWarp2block*)thisx; - CollisionHeader* collisionHeader; - - collisionHeader = NULL; - this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - - Actor_SetScale(&this->dyna.actor, sSpawnData[(this->dyna.actor.params >> 8) & 1].scale); - this->func_168 = func_80BA2218; - Actor_SetFocus(&this->dyna.actor, sSpawnData[(this->dyna.actor.params >> 8) & 1].focus); - - if ((this->dyna.actor.params >> 0xF) & 1) { - func_80BA24E8(this); - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - this->dyna.actor.draw = NULL; - } - DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&gSongOfTimeBlockCol, &collisionHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, collisionHeader); - } else { - ObjWarp2block_SetInactive(this); - } - - osSyncPrintf("時のブロック(ワープ2) ( %04xH color:%d range:%d)\n", this->dyna.actor.params & 0xFFFF, - this->dyna.actor.home.rot.z & 7, (this->dyna.actor.params >> 0xB) & 7); -} - -void ObjWarp2block_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ObjWarp2block* this = (ObjWarp2block*)thisx; - if ((this->dyna.actor.params >> 0xF) & 1) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - } -} - -void ObjWarp2block_SetInactive(ObjWarp2block* this) { - this->actionFunc = ObjWarp2block_DoNothing; - this->dyna.actor.draw = NULL; -} - -void ObjWarp2block_DoNothing(ObjWarp2block* this, GlobalContext* globalCtx) { -} - -void func_80BA24E8(ObjWarp2block* this) { - this->actionFunc = func_80BA24F8; -} - -void func_80BA24F8(ObjWarp2block* this, GlobalContext* globalCtx) { - Actor* current = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; - - while (current != NULL) { - if (current->id == ACTOR_OBJ_WARP2BLOCK && !((current->params >> 0xF) & 1) && - ((this->dyna.actor.params & 0x3F) == (current->params & 0x3F))) { - this->dyna.actor.child = current; - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { - ObjWarp2block_SwapWithChild(this, globalCtx); - this->dyna.actor.draw = ObjWarp2block_Draw; - } - func_80BA2600(this); - return; - } - - current = current->next; - } - - this->unk_174++; - if (this->unk_174 > 60) { - osSyncPrintf(VT_COL(RED, WHITE)); - osSyncPrintf("Error : 時のブロック(ワープ2)が対でセットされていません(%s %d)\n", "../z_obj_warp2block.c", 505); - osSyncPrintf(VT_RST); - Actor_Kill(&this->dyna.actor); - } -} - -void func_80BA2600(ObjWarp2block* this) { - this->actionFunc = func_80BA2610; -} - -void func_80BA2610(ObjWarp2block* this, GlobalContext* globalCtx) { - if ((func_80BA2304(this, globalCtx) != 0) && (this->unk_16C <= 0)) { - ObjWarp2block_Spawn(this, globalCtx); - this->unk_16C = 0xA0; - OnePointCutscene_Attention(globalCtx, &this->dyna.actor); - this->unk_170 = 0xC; - } - - if (this->unk_170 > 0) { - this->unk_170--; - if (this->unk_170 == 0) { - ObjWarp2block_SwapWithChild(this, globalCtx); - } - } - if (this->unk_16C == 0x32) { - func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - } -} - -void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjWarp2block* this = (ObjWarp2block*)thisx; - - this->actionFunc(this, globalCtx); - if (this->unk_16C > 0) { - this->unk_16C--; - } -} - -void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx) { - Color_RGB8* sp44; - - sp44 = &sColors[thisx->home.rot.z & 7]; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 584); - func_80093D18(globalCtx->state.gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 588), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp44->r, sp44->g, sp44->b, 255); - gSPDisplayList(POLY_OPA_DISP++, gSongOfTimeBlockDL); - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 594); -} diff --git a/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp b/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp new file mode 100644 index 000000000..7d828bce8 --- /dev/null +++ b/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp @@ -0,0 +1,330 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJ_WARP2BLOCK_Z_OBJ_WARP2BLOCK_C +#include "actor_common.h" +/* + * File: z_obj_warp2block.c + * Overlay: ovl_Obj_Warp2Block + * Description: Navi Infospot (Green, Time Block) + */ + +#include "z_obj_warp2block.h" +#include "objects/object_timeblock/object_timeblock.h" +#include "vt.h" +#include "def/code_80043480.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_lib.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_rcp.h" + +#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_25 | ACTOR_FLAG_27) + +void ObjWarp2block_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjWarp2block_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjWarp2block_Spawn(ObjWarp2block* pthis, GlobalContext* globalCtx); +s32 func_80BA1ECC(ObjWarp2block* pthis, GlobalContext* globalCtx); +void ObjWarp2block_SwapWithChild(ObjWarp2block* pthis, GlobalContext* globalCtx); +s32 func_80BA2218(ObjWarp2block* pthis, GlobalContext* globalCtx); +s32 func_80BA228C(ObjWarp2block* pthis, GlobalContext* globalCtx); +s32 func_80BA2304(ObjWarp2block* pthis, GlobalContext* globalCtx); +void ObjWarp2block_SetInactive(ObjWarp2block* pthis); +void ObjWarp2block_DoNothing(ObjWarp2block* pthis, GlobalContext* globalCtx); +void func_80BA24E8(ObjWarp2block* pthis); +void func_80BA24F8(ObjWarp2block* pthis, GlobalContext* globalCtx); +void func_80BA2600(ObjWarp2block* pthis); +void func_80BA2610(ObjWarp2block* pthis, GlobalContext* globalCtx); + +ActorInit Obj_Warp2block_InitVars = { + ACTOR_OBJ_WARP2BLOCK, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_TIMEBLOCK, + sizeof(ObjWarp2block), + (ActorFunc)ObjWarp2block_Init, + (ActorFunc)ObjWarp2block_Destroy, + (ActorFunc)ObjWarp2block_Update, + (ActorFunc)ObjWarp2block_Draw, +}; + +typedef struct { + /* 0x00 */ f32 scale; + /* 0x04 */ f32 focus; + /* 0x08 */ s16 params; +} Warp2BlockSpawnData; // size = 0x0C + +static Warp2BlockSpawnData sSpawnData[] = { + { 1.0f, 60.0f, 0x0018 }, + { 0.6f, 40.0f, 0x0019 }, +}; + +static f32 sDistances[] = { 60.0f, 100.0f, 140.0f, 180.0f, 220.0f, 260.0f, 300.0f, 300.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP), +}; + +static Color_RGB8 sColors[] = { + { 100, 120, 140 }, { 80, 140, 200 }, { 100, 150, 200 }, { 100, 200, 240 }, + { 80, 110, 140 }, { 70, 160, 225 }, { 80, 100, 130 }, { 100, 110, 190 }, +}; + +void ObjWarp2block_Spawn(ObjWarp2block* pthis, GlobalContext* globalCtx) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->dyna.actor.world.pos.x, + pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, 0, 0, 0, + sSpawnData[(pthis->dyna.actor.params >> 8) & 1].params); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, pthis->dyna.actor.child->world.pos.x, + pthis->dyna.actor.child->world.pos.y, pthis->dyna.actor.child->world.pos.z, 0, 0, 0, + sSpawnData[(pthis->dyna.actor.child->params >> 8) & 1].params); +} + +s32 func_80BA1ECC(ObjWarp2block* pthis, GlobalContext* globalCtx) { + s32 pad; + Actor* temp_a3; + Player* player; + Vec3f sp20; + f32 temp_f2; + + if (func_80043590(&pthis->dyna)) { + return 0; + } + + temp_a3 = pthis->dyna.actor.child; + player = GET_PLAYER(globalCtx); + if ((pthis->dyna.actor.xzDistToPlayer <= sDistances[(((pthis->dyna.actor.params >> 0xB) & 7))]) || + (temp_a3->xzDistToPlayer <= sDistances[(((temp_a3->params >> 0xB) & 7))])) { + + func_8002DBD0(&pthis->dyna.actor, &sp20, &player->actor.world.pos); + temp_f2 = (pthis->dyna.actor.scale.x * 50.0f) + 6.0f; + + if (!(temp_f2 < fabsf(sp20.x)) && !(temp_f2 < fabsf(sp20.z))) { + return 0; + } + + func_8002DBD0(temp_a3, &sp20, &player->actor.world.pos); + temp_f2 = (temp_a3->scale.x * 50.0f) + 6.0f; + + if (!(temp_f2 < fabsf(sp20.x)) && !(temp_f2 < fabsf(sp20.z))) { + return 0; + } + } else { + return 0; + } + + return 1; +} + +void ObjWarp2block_SwapWithChild(ObjWarp2block* pthis, GlobalContext* globalCtx) { + Vec3f tempVec; + Vec3s tempRot; + s32 temp; + + Math_Vec3f_Copy(&tempVec, &pthis->dyna.actor.world.pos); + Math_Vec3f_Copy(&pthis->dyna.actor.world.pos, &pthis->dyna.actor.child->world.pos); + Math_Vec3f_Copy(&pthis->dyna.actor.child->world.pos, &tempVec); + + temp = pthis->dyna.actor.world.rot.y; + pthis->dyna.actor.world.rot.y = pthis->dyna.actor.child->world.rot.y; + pthis->dyna.actor.child->world.rot.y = temp; + + temp = pthis->dyna.actor.shape.rot.y; + pthis->dyna.actor.shape.rot.y = pthis->dyna.actor.child->shape.rot.y; + pthis->dyna.actor.child->shape.rot.y = temp; + + temp = pthis->dyna.actor.home.rot.z; + pthis->dyna.actor.home.rot.z = pthis->dyna.actor.child->home.rot.z; + pthis->dyna.actor.child->home.rot.z = temp; + + Math_Vec3f_Copy(&tempVec, &pthis->dyna.actor.scale); + Math_Vec3f_Copy(&pthis->dyna.actor.scale, &pthis->dyna.actor.child->scale); + Math_Vec3f_Copy(&pthis->dyna.actor.child->scale, &tempVec); + + Math_Vec3f_Copy(&tempVec, &pthis->dyna.actor.focus.pos); + Math_Vec3f_Copy(&pthis->dyna.actor.focus.pos, &pthis->dyna.actor.child->focus.pos); + Math_Vec3f_Copy(&pthis->dyna.actor.child->focus.pos, &tempVec); + + tempRot = pthis->dyna.actor.focus.rot; + pthis->dyna.actor.focus.rot = pthis->dyna.actor.child->focus.rot; + pthis->dyna.actor.child->focus.rot = tempRot; + + temp = pthis->dyna.actor.params & 0x7FFF; + pthis->dyna.actor.params = (pthis->dyna.actor.params & 0x8000) | (pthis->dyna.actor.child->params & 0x7FFF); + pthis->dyna.actor.child->params = (pthis->dyna.actor.child->params & 0x8000) | (temp & 0x7FFF); + + if (Math3D_Vec3fDistSq(&pthis->dyna.actor.world.pos, &pthis->dyna.actor.home.pos) < 0.01f) { + Flags_UnsetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + } else { + Flags_SetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F); + } +} + +s32 func_80BA2218(ObjWarp2block* pthis, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80BA1ECC(pthis, globalCtx)) { + if (player->stateFlags2 & 0x1000000) { + func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); + pthis->func_168 = func_80BA228C; + } else { + player->stateFlags2 |= 0x800000; + } + } + + return 0; +} + +s32 func_80BA228C(ObjWarp2block* pthis, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + pthis->func_168 = func_80BA2218; + } + + if (globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME) { + if (pthis->unk_172 == 0xFE) { + pthis->unk_16E = 0x6E; + } else { + pthis->unk_16E--; + if (pthis->unk_16E == 0) { + return 1; + } + } + } + return 0; +} + +s32 func_80BA2304(ObjWarp2block* pthis, GlobalContext* globalCtx) { + s32 ret = pthis->func_168(pthis, globalCtx); + + pthis->unk_172 = globalCtx->msgCtx.lastPlayedSong; + + return ret; +} + +void ObjWarp2block_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjWarp2block* pthis = (ObjWarp2block*)thisx; + CollisionHeader* collisionHeader; + + collisionHeader = NULL; + pthis->dyna.actor.world.rot.z = pthis->dyna.actor.shape.rot.z = 0; + Actor_ProcessInitChain(&pthis->dyna.actor, sInitChain); + + Actor_SetScale(&pthis->dyna.actor, sSpawnData[(pthis->dyna.actor.params >> 8) & 1].scale); + pthis->func_168 = func_80BA2218; + Actor_SetFocus(&pthis->dyna.actor, sSpawnData[(pthis->dyna.actor.params >> 8) & 1].focus); + + if ((pthis->dyna.actor.params >> 0xF) & 1) { + func_80BA24E8(pthis); + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + pthis->dyna.actor.draw = NULL; + } + DynaPolyActor_Init(&pthis->dyna, 0); + CollisionHeader_GetVirtual(&gSongOfTimeBlockCol, &collisionHeader); + pthis->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &pthis->dyna.actor, collisionHeader); + } else { + ObjWarp2block_SetInactive(pthis); + } + + osSyncPrintf("時のブロック(ワープ2) ( %04xH color:%d range:%d)\n", pthis->dyna.actor.params & 0xFFFF, + pthis->dyna.actor.home.rot.z & 7, (pthis->dyna.actor.params >> 0xB) & 7); +} + +void ObjWarp2block_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjWarp2block* pthis = (ObjWarp2block*)thisx; + if ((pthis->dyna.actor.params >> 0xF) & 1) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, pthis->dyna.bgId); + } +} + +void ObjWarp2block_SetInactive(ObjWarp2block* pthis) { + pthis->actionFunc = ObjWarp2block_DoNothing; + pthis->dyna.actor.draw = NULL; +} + +void ObjWarp2block_DoNothing(ObjWarp2block* pthis, GlobalContext* globalCtx) { +} + +void func_80BA24E8(ObjWarp2block* pthis) { + pthis->actionFunc = func_80BA24F8; +} + +void func_80BA24F8(ObjWarp2block* pthis, GlobalContext* globalCtx) { + Actor* current = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + + while (current != NULL) { + if (current->id == ACTOR_OBJ_WARP2BLOCK && !((current->params >> 0xF) & 1) && + ((pthis->dyna.actor.params & 0x3F) == (current->params & 0x3F))) { + pthis->dyna.actor.child = current; + if (Flags_GetSwitch(globalCtx, pthis->dyna.actor.params & 0x3F)) { + ObjWarp2block_SwapWithChild(pthis, globalCtx); + pthis->dyna.actor.draw = ObjWarp2block_Draw; + } + func_80BA2600(pthis); + return; + } + + current = current->next; + } + + pthis->unk_174++; + if (pthis->unk_174 > 60) { + osSyncPrintf(VT_COL(RED, WHITE)); + osSyncPrintf("Error : 時のブロック(ワープ2)が対でセットされていません(%s %d)\n", "../z_obj_warp2block.c", 505); + osSyncPrintf(VT_RST); + Actor_Kill(&pthis->dyna.actor); + } +} + +void func_80BA2600(ObjWarp2block* pthis) { + pthis->actionFunc = func_80BA2610; +} + +void func_80BA2610(ObjWarp2block* pthis, GlobalContext* globalCtx) { + if ((func_80BA2304(pthis, globalCtx) != 0) && (pthis->unk_16C <= 0)) { + ObjWarp2block_Spawn(pthis, globalCtx); + pthis->unk_16C = 0xA0; + OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); + pthis->unk_170 = 0xC; + } + + if (pthis->unk_170 > 0) { + pthis->unk_170--; + if (pthis->unk_170 == 0) { + ObjWarp2block_SwapWithChild(pthis, globalCtx); + } + } + if (pthis->unk_16C == 0x32) { + func_80078884(NA_SE_SY_TRE_BOX_APPEAR); + } +} + +void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjWarp2block* pthis = (ObjWarp2block*)thisx; + + pthis->actionFunc(pthis, globalCtx); + if (pthis->unk_16C > 0) { + pthis->unk_16C--; + } +} + +void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx) { + Color_RGB8* sp44; + + sp44 = &sColors[thisx->home.rot.z & 7]; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 584); + func_80093D18(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 588), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp44->r, sp44->g, sp44->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gSongOfTimeBlockDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 594); +} diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c deleted file mode 100644 index 3296b4bdd..000000000 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ /dev/null @@ -1,955 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJECT_KANKYO_Z_OBJECT_KANKYO_C -#include "actor_common.h" -/* - * File: z_object_kankyo.c - * Overlay: ovl_Object_Kankyo - * Description: Environmental Effects - */ - -#include "z_object_kankyo.h" -#include "objects/object_demo_kekkai/object_demo_kekkai.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_spot02_objects/object_spot02_objects.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/cosf.h" -#include "def/sinf.h" -#include "def/sys_math3d.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_common_data.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_object_kankyo.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25) - -void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); - -void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc func); -void ObjectKankyo_Fairies(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_SunGraveSparkInit(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_Snow(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_Lightning(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_InitBeams(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_SunGraveSpark(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_WaitForBeamObject(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_Beams(ObjectKankyo* this, GlobalContext* globalCtx); - -void ObjectKankyo_DrawFairies(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_DrawSnow(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_DrawLightning(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_DrawSunGraveSpark(ObjectKankyo* this, GlobalContext* globalCtx); -void ObjectKankyo_DrawBeams(ObjectKankyo* this, GlobalContext* globalCtx); - -Mtx D_01000000; - -static void* sEffLightningTextures[] = { - gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, - gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, -}; - -static void* D_80BA5900[] = { - gEffSunGraveSpark1Tex, gEffSunGraveSpark2Tex, gEffSunGraveSpark3Tex, gEffSunGraveSpark4Tex, - gEffSunGraveSpark5Tex, gEffSunGraveSpark6Tex, gEffSunGraveSpark7Tex, gEffSunGraveSpark8Tex, -}; - -const ActorInit Object_Kankyo_InitVars = { - ACTOR_OBJECT_KANKYO, - ACTORCAT_ITEMACTION, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(ObjectKankyo), - (ActorFunc)ObjectKankyo_Init, - (ActorFunc)ObjectKankyo_Destroy, - (ActorFunc)ObjectKankyo_Update, - (ActorFunc)ObjectKankyo_Draw, -}; - -static u8 sIsSpawned = false; -static s16 sTrailingFairies = 0; - -void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc action) { - this->actionFunc = action; -} - -void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { - ObjectKankyo* this = (ObjectKankyo*)thisx; - s32 pad; - s16 i; - - for (i = 0; i < ARRAY_COUNT(this->effects); i++) { - this->effects[i].state = 0; - } - - this->actor.room = -1; - switch (this->actor.params) { - case 0: - if (!sIsSpawned) { - ObjectKankyo_SetupAction(this, ObjectKankyo_Fairies); - sIsSpawned = true; - } else { - Actor_Kill(&this->actor); - } - break; - - case 3: - if (!sIsSpawned) { - ObjectKankyo_SetupAction(this, ObjectKankyo_Snow); - sIsSpawned = true; - } else { - Actor_Kill(&this->actor); - } - break; - - case 2: - ObjectKankyo_SetupAction(this, ObjectKankyo_Lightning); - break; - - case 4: - this->effects[0].alpha = 0; - this->effects[0].amplitude = 0.0f; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ITEMACTION); - this->requiredObjectLoaded = false; - ObjectKankyo_SetupAction(this, ObjectKankyo_SunGraveSparkInit); - break; - - case 5: - this->effects[0].alpha = 0; - this->effects[0].amplitude = 0.0f; - - for (i = 0; i < 6; i++) { - this->effects[i].size = 0.1f; - } - - // Check which beams are disabled - if (Flags_GetEventChkInf(0xBB)) { - this->effects[0].size = 0.0f; - } - if (Flags_GetEventChkInf(0xBC)) { - this->effects[1].size = 0.0f; - } - if (Flags_GetEventChkInf(0xBD)) { - this->effects[2].size = 0.0f; - } - if (Flags_GetEventChkInf(0xBE)) { - this->effects[3].size = 0.0f; - } - if (Flags_GetEventChkInf(0xBF)) { - this->effects[4].size = 0.0f; - } - if (Flags_GetEventChkInf(0xAD)) { - this->effects[5].size = 0.0f; - } - - if (gSaveContext.cutsceneTrigger != 0) { - if (gSaveContext.entranceIndex == 0x0538) { - this->effects[0].size = 0.1f; - } - if (gSaveContext.entranceIndex == 0x053C) { - this->effects[1].size = 0.1f; - } - if (gSaveContext.entranceIndex == 0x0540) { - this->effects[2].size = 0.1f; - } - if (gSaveContext.entranceIndex == 0x0544) { - this->effects[3].size = 0.1f; - } - if (gSaveContext.entranceIndex == 0x0548) { - this->effects[4].size = 0.1f; - } - if (gSaveContext.entranceIndex == 0x054C) { - this->effects[5].size = 0.1f; - } - } - - this->requiredObjectLoaded = false; - ObjectKankyo_SetupAction(this, ObjectKankyo_InitBeams); - break; - } -} - -void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Actor_Kill(thisx); -} - -void ObjectKankyo_Snow(ObjectKankyo* this, GlobalContext* globalCtx) { -} - -void ObjectKankyo_Fairies(ObjectKankyo* this, GlobalContext* globalCtx) { - static Vec3f sSoundPos = { 0.0f, 0.0f, 0.0f }; - Player* player; - f32 dist; - s32 playerMoved; - f32 dx; - f32 dy; - f32 dz; - f32 viewForwardsX; - f32 viewForwardsY; - f32 viewForwardsZ; - f32 maxDist; - f32 baseX; - f32 baseY; - f32 baseZ; - Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; - Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; - f32 random; - s16 i; - Vec3f viewForwards; - - player = GET_PLAYER(globalCtx); - - if (globalCtx->sceneNum == SCENE_SPOT04 && gSaveContext.sceneSetupIndex == 7) { - dist = Math3D_Vec3f_DistXYZ(&this->prevEyePos, &globalCtx->view.eye); - - this->prevEyePos.x = globalCtx->view.eye.x; - this->prevEyePos.y = globalCtx->view.eye.y; - this->prevEyePos.z = globalCtx->view.eye.z; - - dist /= 30.0f; - if (dist > 1.0f) { - dist = 1.0f; - } - - func_800F436C(&sSoundPos, NA_SE_EV_NAVY_FLY - SFX_FLAG, (0.4f * dist) + 0.6f); - switch (globalCtx->csCtx.frames) { - case 473: - func_800788CC(NA_SE_VO_NA_HELLO_3); - break; - - case 583: - func_800F4524(&D_801333D4, NA_SE_VO_NA_HELLO_2, 32); - break; - - case 763: - func_80078884(NA_SE_EV_NAVY_CRASH - SFX_FLAG); - break; - - case 771: - func_80078884(NA_SE_VO_RT_THROW); - break; - } - } - - if (globalCtx->envCtx.unk_EE[3] < 64 && - (gSaveContext.entranceIndex != 0x00EE || gSaveContext.sceneSetupIndex != 4 || globalCtx->envCtx.unk_EE[3])) { - globalCtx->envCtx.unk_EE[3] += 16; - } - - for (i = 0; i < globalCtx->envCtx.unk_EE[3]; i++) { - // spawn in front of the camera - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; - dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); - - viewForwards.x = dx / dist; - viewForwards.y = dy / dist; - viewForwards.z = dz / dist; - - viewForwardsX = viewForwards.x; - viewForwardsY = viewForwards.y; - viewForwardsZ = viewForwards.z; - - switch (this->effects[i].state) { - case 0: // init - this->effects[i].base.x = globalCtx->view.eye.x + viewForwardsX * 80.0f; - this->effects[i].base.y = globalCtx->view.eye.y + viewForwardsY * 80.0f; - this->effects[i].base.z = globalCtx->view.eye.z + viewForwardsZ * 80.0f; - - this->effects[i].pos.x = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->effects[i].pos.y = 30.0f; - this->effects[i].pos.z = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->effects[i].targetSpeed = Rand_ZeroOne() * 1.6f + 0.5f; - this->effects[i].alpha = 0; - this->effects[i].alphaTimer = Rand_ZeroOne() * 65535.0f; - this->effects[i].size = 0.1f; - this->effects[i].dirPhase.x = Rand_ZeroOne() * 360.0f; - this->effects[i].dirPhase.y = Rand_ZeroOne() * 360.0f; - this->effects[i].dirPhase.z = Rand_ZeroOne() * 360.0f; - this->effects[i].state++; - this->effects[i].timer = 0; - break; - - case 1: // blinking fairies / inactive fairy trails - case 2: // fairy trails - this->effects[i].alphaTimer++; - baseX = globalCtx->view.eye.x + viewForwards.x * 80.0f; - baseY = globalCtx->view.eye.y + viewForwards.y * 80.0f; - baseZ = globalCtx->view.eye.z + viewForwards.z * 80.0f; - - this->effects[i].prevPos.x = this->effects[i].pos.x; - this->effects[i].prevPos.y = this->effects[i].pos.y; - this->effects[i].prevPos.z = this->effects[i].pos.z; - - playerMoved = true; - // y velocity is set to -4 when the player is on the ground - if (player->actor.velocity.x + player->actor.velocity.y + player->actor.velocity.z == -4.0f) { - playerMoved = false; - this->effects[i].timer++; - } else { - this->effects[i].timer = 0; - } - - if (this->effects[i].state == 1) { - // the first 32 fairies are invisible until the player stands still - if (i < 32 && !playerMoved && this->effects[i].timer > 256) { - this->effects[i].timer = 0; - if (Rand_ZeroOne() < 0.5f) { - this->effects[i].angleVel = (s16)(Rand_ZeroOne() * 200.0f) + 200; - } else { - this->effects[i].angleVel = -((s16)(Rand_ZeroOne() * 200.0f) + 200); - } - - this->effects[i].flightRadius = (s16)(Rand_ZeroOne() * 50.0f) + 15; - - // uniformly scales the length and height of the wave that the lead fairy flies in - // lower numbers have a larger amplitude and period - this->effects[i].amplitude = (Rand_ZeroOne() * 10.0f + 10.0f) * 0.01f; - - random = Rand_ZeroOne(); - if (random < 0.2f) { - sTrailingFairies = 1; - } else if (random < 0.2f) { - // unreachable - sTrailingFairies = 3; - } else if (random < 0.4f) { - sTrailingFairies = 7; - } else { - sTrailingFairies = 15; - } - - if ((i & sTrailingFairies) == 0) { - this->effects[i].pos.y = 0.0f; - } - - this->effects[i].state = 2; - this->effects[i].targetSpeed = 0.0f; - } - - Math_SmoothStepToF(&this->effects[i].size, 0.1f, 0.10f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].targetSpeed, 0.5f, 0.2f, 0.02f); - - this->effects[i].pos.x += sinf(this->effects[i].dirPhase.x) * this->effects[i].speed; - this->effects[i].pos.y += sinf(this->effects[i].dirPhase.y) * this->effects[i].speed; - this->effects[i].pos.z += sinf(this->effects[i].dirPhase.z) * this->effects[i].speed; - - switch ((i >> 1) & 3) { - case 0: - this->effects[i].dirPhase.x += 0.008f; - this->effects[i].dirPhase.y += 0.05f * Rand_ZeroOne(); - this->effects[i].dirPhase.z += 0.015f; - break; - - case 1: - this->effects[i].dirPhase.x += 0.01f * Rand_ZeroOne(); - this->effects[i].dirPhase.y += 0.05f * Rand_ZeroOne(); - this->effects[i].dirPhase.z += 0.005f * Rand_ZeroOne(); - break; - - case 2: - this->effects[i].dirPhase.x += 0.01f * Rand_ZeroOne(); - this->effects[i].dirPhase.y += 0.4f * Rand_ZeroOne(); - this->effects[i].dirPhase.z += 0.004f * Rand_ZeroOne(); - break; - - case 3: - this->effects[i].dirPhase.x += 0.01 * Rand_ZeroOne(); - this->effects[i].dirPhase.y += 0.08f * Rand_ZeroOne(); - this->effects[i].dirPhase.z += 0.05f * Rand_ZeroOne(); - break; - } - } else if (this->effects[i].state == 2) { - // scatter when the player moves or after a long enough time - if (playerMoved || this->effects[i].timer > 1280) { - this->effects[i].timer = 0; - this->effects[i].state = 1; - this->effects[i].speed = 1.5f; - this->effects[i].targetSpeed = Rand_ZeroOne() * 1.6f + 0.5f; - } - - if ((i & sTrailingFairies) == 0) { // leader fairy - Math_SmoothStepToF(&this->effects[i].size, 0.25f, 0.1f, 0.001f, 0.00001f); - - // move the center of the flight path to player's position - Math_SmoothStepToF(&this->effects[i].base.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->effects[i].base.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, - 0.2f); - Math_SmoothStepToF(&this->effects[i].base.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); - - // results unused - Math_SmoothStepToF(&this->effects[i].pos.x, - Math_SinS(this->effects[i].angle - 0x8000) * this->effects[i].flightRadius, - 0.5f, 2.0f, 0.2f); - Math_SmoothStepToF(&this->effects[i].pos.z, - Math_CosS(this->effects[i].angle - 0x8000) * this->effects[i].flightRadius, - 0.5f, 2.0f, 0.2f); - - // the lead fairy's y position approximately follows a sine wave with `amplitude` as angular - // frequency and `1 / amplitude` as amplitude - this->effects[i].angle += this->effects[i].angleVel; - this->effects[i].pos.y += sinf(this->effects[i].dirPhase.y); - - this->effects[i].dirPhase.x += 0.2f * Rand_ZeroOne(); - this->effects[i].dirPhase.y += this->effects[i].amplitude; - this->effects[i].dirPhase.z += 0.1f * Rand_ZeroOne(); - - // circle around the player - this->effects[i].pos.x = - Math_SinS(this->effects[i].angle - 0x8000) * this->effects[i].flightRadius; - this->effects[i].pos.z = - Math_CosS(this->effects[i].angle - 0x8000) * this->effects[i].flightRadius; - } else { // trailing fairy - Math_SmoothStepToF(&this->effects[i].size, 0.1f, 0.10f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->effects[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); - - // follow previous fairy, translate their position to be relative to our home - this->effects[i].pos.x = - this->effects[i - 1].prevPos.x + (this->effects[i - 1].base.x - this->effects[i].base.x); - this->effects[i].pos.y = - this->effects[i - 1].prevPos.y + (this->effects[i - 1].base.y - this->effects[i].base.y); - this->effects[i].pos.z = - this->effects[i - 1].prevPos.z + (this->effects[i - 1].base.z - this->effects[i].base.z); - } - } - - if (this->effects[i].state != 2) { - maxDist = 130.0f; - if (this->effects[i].base.x + this->effects[i].pos.x - baseX > maxDist || - this->effects[i].base.x + this->effects[i].pos.x - baseX < -maxDist || - this->effects[i].base.y + this->effects[i].pos.y - baseY > maxDist || - this->effects[i].base.y + this->effects[i].pos.y - baseY < -maxDist || - this->effects[i].base.z + this->effects[i].pos.z - baseZ > maxDist || - this->effects[i].base.z + this->effects[i].pos.z - baseZ < -maxDist) { - - // when a fairy moves off screen, wrap around to the other side - if (this->effects[i].base.x + this->effects[i].pos.x - baseX > maxDist) { - this->effects[i].base.x = baseX - maxDist; - this->effects[i].pos.x = 0.0f; - } - if (this->effects[i].base.x + this->effects[i].pos.x - baseX < -maxDist) { - this->effects[i].base.x = baseX + maxDist; - this->effects[i].pos.x = 0.0f; - } - if (this->effects[i].base.y + this->effects[i].pos.y - baseY > 50.0f) { - this->effects[i].base.y = baseY - 50.0f; - this->effects[i].pos.y = 0.0f; - } - if (this->effects[i].base.y + this->effects[i].pos.y - baseY < -50.0f) { - this->effects[i].base.y = baseY + 50.0f; - this->effects[i].pos.y = 0.0f; - } - if (this->effects[i].base.z + this->effects[i].pos.z - baseZ > maxDist) { - this->effects[i].base.z = baseZ - maxDist; - this->effects[i].pos.z = 0.0f; - } - if (this->effects[i].base.z + this->effects[i].pos.z - baseZ < -maxDist) { - this->effects[i].base.z = baseZ + maxDist; - this->effects[i].pos.z = 0.0f; - } - } - } - break; - - case 3: // reset, never reached - this->effects[i].state = 0; - break; - } - } -} - -void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { - ObjectKankyo* this = (ObjectKankyo*)thisx; - - this->actionFunc(this, globalCtx); -} - -void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { - ObjectKankyo* this = (ObjectKankyo*)thisx; - - switch (this->actor.params) { - case 0: - ObjectKankyo_DrawFairies(this, globalCtx); - break; - - case 2: - ObjectKankyo_DrawLightning(this, globalCtx); - break; - - case 3: - ObjectKankyo_DrawSnow(this, globalCtx); - break; - - case 4: - ObjectKankyo_DrawSunGraveSpark(this, globalCtx); - break; - - case 5: - ObjectKankyo_DrawBeams(this, globalCtx); - break; - } -} - -void ObjectKankyo_DrawFairies(ObjectKankyo* this2, GlobalContext* globalCtx2) { - ObjectKankyo* this = this2; - GlobalContext* globalCtx = globalCtx2; - f32 alphaScale; - Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; - Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; - s16 i; - - if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 807); - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gSun1Tex)); - gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteTextureLoadDL); - - for (i = 0; i < globalCtx->envCtx.unk_EE[3]; i++) { - Matrix_Translate(this->effects[i].base.x + this->effects[i].pos.x, - this->effects[i].base.y + this->effects[i].pos.y, - this->effects[i].base.z + this->effects[i].pos.z, MTXMODE_NEW); - - // scale when fading in or out - alphaScale = this->effects[i].alpha / 50.0f; - if (alphaScale > 1.0f) { - alphaScale = 1.0f; - } - - Matrix_Scale(this->effects[i].size * alphaScale, this->effects[i].size * alphaScale, - this->effects[i].size * alphaScale, MTXMODE_APPLY); - if (i < 32) { - if (this->effects[i].state != 2) { - if (this->effects[i].alpha > 0) { - this->effects[i].alpha--; - } - } else { - if (this->effects[i].alpha < 100) { - this->effects[i].alpha++; - } - } - } else { - if (this->effects[i].state != 2) { - if ((this->effects[i].alphaTimer & 0x1F) < 16) { - if (this->effects[i].alpha < 235) { - this->effects[i].alpha += 20; - } - } else { - if (this->effects[i].alpha > 20) { - this->effects[i].alpha -= 20; - } - } - } else { - // unreachable - if ((this->effects[i].alphaTimer & 0xF) < 8) { - if (this->effects[i].alpha < 255) { - this->effects[i].alpha += 100; - } - } else { - if (this->effects[i].alpha > 10) { - this->effects[i].alpha -= 10; - } - } - } - } - - gDPPipeSync(POLY_XLU_DISP++); - - switch (i & 1) { - case 0: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->effects[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->effects[i].alpha); - break; - - case 1: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->effects[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->effects[i].alpha); - break; - } - - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 913), G_MTX_LOAD); - gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteDL); - } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 922); - } -} - -void ObjectKankyo_DrawSnow(ObjectKankyo* this2, GlobalContext* globalCtx2) { - ObjectKankyo* this = this2; - GlobalContext* globalCtx = globalCtx2; - f32 dist; - f32 dx; - f32 dy; - f32 dz; - f32 maxDist; - f32 temp; - f32 baseX; - f32 baseY; - f32 baseZ; - Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; - Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; - s16 i; - s32 pad; - s32 pad2; - - if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 958); - if (globalCtx->envCtx.unk_EE[2] < globalCtx->envCtx.unk_EE[3]) { - if (globalCtx->state.frames % 16 == 0) { - globalCtx->envCtx.unk_EE[2] += 2; - } - } else if (globalCtx->envCtx.unk_EE[2] > globalCtx->envCtx.unk_EE[3]) { - if (globalCtx->state.frames % 16 == 0) { - globalCtx->envCtx.unk_EE[2] -= 2; - } - } - - for (i = 0; i < globalCtx->envCtx.unk_EE[2]; i++) { - switch (this->effects[i].state) { - case 0: - // spawn in front of the camera - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; - dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); - - // fake - temp = dz / dist; - this->effects[i].base.x = globalCtx->view.eye.x + dx / dist * 80.0f; - this->effects[i].base.y = globalCtx->view.eye.y + dy / dist * 80.0f; - this->effects[i].base.z = globalCtx->view.eye.z + temp * 80.0f; - - this->effects[i].pos.x = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->effects[i].pos.y = 80.0f; - this->effects[i].pos.z = (Rand_ZeroOne() - 0.5f) * 160.0f; - if (this->effects[i].base.y + this->effects[i].pos.y < 50.0f) { - this->effects[i].base.y = 50.0f; - } - this->effects[i].speed = Rand_ZeroOne() * 5.0f + 0.5f; - this->effects[i].dirPhase.x = Rand_ZeroOne() * 360.0f; - this->effects[i].dirPhase.z = Rand_ZeroOne() * 360.0f; - this->effects[i].state++; - break; - - case 1: - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; - dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); - - baseX = globalCtx->view.eye.x + dx / dist * 80.0f; - baseY = globalCtx->view.eye.y + dy / dist * 80.0f; - baseZ = globalCtx->view.eye.z + dz / dist * 80.0f; - - this->effects[i].dirPhase.x += 0.049999997f * Rand_ZeroOne(); - this->effects[i].dirPhase.z += 0.049999997f * Rand_ZeroOne(); - this->effects[i].pos.x += sinf(this->effects[i].dirPhase.x * 0.01f); - this->effects[i].pos.z += cosf(this->effects[i].dirPhase.z * 0.01f); - this->effects[i].pos.y += -this->effects[i].speed; - - if (this->effects[i].base.y + this->effects[i].pos.y < this->actor.world.pos.y || - this->effects[i].base.y + this->effects[i].pos.y < globalCtx->view.eye.y - 150.0f) { - this->effects[i].state++; - } - - maxDist = 80; - if (this->effects[i].base.x + this->effects[i].pos.x - baseX > maxDist || - this->effects[i].base.x + this->effects[i].pos.x - baseX < -maxDist || - this->effects[i].base.y + this->effects[i].pos.y - baseY > maxDist || - this->effects[i].base.y + this->effects[i].pos.y - baseY < -maxDist || - this->effects[i].base.z + this->effects[i].pos.z - baseZ > maxDist || - this->effects[i].base.z + this->effects[i].pos.z - baseZ < -maxDist) { - - // when off screen, wrap around to the other side - if (this->effects[i].base.x + this->effects[i].pos.x - baseX > maxDist) { - this->effects[i].base.x = baseX - maxDist; - this->effects[i].pos.x = 0.0f; - } - if (this->effects[i].base.x + this->effects[i].pos.x - baseX < -maxDist) { - this->effects[i].base.x = baseX + maxDist; - this->effects[i].pos.x = 0.0f; - } - if (this->effects[i].base.z + this->effects[i].pos.z - baseZ > maxDist) { - this->effects[i].base.z = baseZ - maxDist; - this->effects[i].pos.z = 0.0f; - } - if (this->effects[i].base.z + this->effects[i].pos.z - baseZ < -maxDist) { - this->effects[i].base.z = baseZ + maxDist; - this->effects[i].pos.z = 0.0f; - } - } - break; - - case 2: - this->effects[i].state = 0; - break; - } - - if (1) {} - if (1) {} - Matrix_Translate(this->effects[i].base.x + this->effects[i].pos.x, - this->effects[i].base.y + this->effects[i].pos.y, - this->effects[i].base.z + this->effects[i].pos.z, MTXMODE_NEW); - Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); - gDPPipeSync(POLY_XLU_DISP++); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 200, 180); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 180); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1107), - G_MTX_LOAD); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDust5Tex)); - - func_80094C50(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_MODELVIEW | G_MTX_NOPUSH | G_MTX_MUL); - - gDPPipeSync(POLY_XLU_DISP++); - - gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); - - gDPPipeSync(POLY_XLU_DISP++); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1127); - } -} - -void ObjectKankyo_Lightning(ObjectKankyo* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0 && globalCtx->csCtx.npcActions[0] != NULL) { - switch (this->effects[0].state) { - case 0: - this->effects[0].timer = 0; - if (globalCtx->csCtx.npcActions[0]->action == 2) { - this->effects[0].state++; - } - break; - - case 1: - if (++this->effects[0].timer >= 7) { - this->effects[0].state++; - } - break; - - case 2: - if (globalCtx->csCtx.npcActions[0]->action == 1) { - this->effects[0].state = 0; - } - break; - } - } -} - -void ObjectKankyo_DrawLightning(ObjectKankyo* this, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1182); - - if (this->effects[0].state == 1) { - Matrix_Translate(globalCtx->csCtx.npcActions[0]->startPos.x, globalCtx->csCtx.npcActions[0]->startPos.y, - globalCtx->csCtx.npcActions[0]->startPos.z, MTXMODE_NEW); - Matrix_RotateX(DEG_TO_RAD(20.0f), MTXMODE_APPLY); - Matrix_RotateZ(DEG_TO_RAD(20.0f), MTXMODE_APPLY); - Matrix_Scale(2.0f, 5.0f, 2.0f, MTXMODE_APPLY); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 128); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 128); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1213), G_MTX_LOAD); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEffLightningTextures[this->effects[0].timer])); - func_80094C50(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_MODELVIEW | G_MTX_NOPUSH | G_MTX_MUL); - gDPPipeSync(POLY_XLU_DISP++); - gSPDisplayList(POLY_XLU_DISP++, gEffLightningDL); - gDPPipeSync(POLY_XLU_DISP++); - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1233); -} - -void ObjectKankyo_SunGraveSparkInit(ObjectKankyo* this, GlobalContext* globalCtx) { - s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SPOT02_OBJECTS); - - if (objBankIndex < 0) { - ASSERT(0, "0", "../z_object_kankyo.c", 1251); - } else { - this->requiredObjBankIndex = objBankIndex; - } - ObjectKankyo_SetupAction(this, ObjectKankyo_WaitForSunGraveSparkObject); -} - -void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { - this->requiredObjectLoaded = true; - this->effects[0].alpha = 0; - this->actor.objBankIndex = this->requiredObjBankIndex; - this->effects[0].size = 7.0f; - ObjectKankyo_SetupAction(this, ObjectKankyo_SunGraveSpark); - } -} - -void ObjectKankyo_SunGraveSpark(ObjectKankyo* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0) { - if (globalCtx->csCtx.npcActions[1] != NULL && globalCtx->csCtx.npcActions[1]->action == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); - if ((s16)this->effects[0].alpha + 20 > 255) { - this->effects[0].alpha = 255; - } else { - this->effects[0].alpha += 20; - } - Math_SmoothStepToF(&this->effects[0].size, 1.8f, 0.5f, 0.28f, 0.01f); - } - } -} - -void ObjectKankyo_DrawSunGraveSpark(ObjectKankyo* this2, GlobalContext* globalCtx2) { - ObjectKankyo* this = this2; - GlobalContext* globalCtx = globalCtx2; - Vec3f start; - Vec3f end; - f32 weight; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1324); - if (globalCtx->csCtx.state != 0) { - if (globalCtx->csCtx.npcActions[1] != NULL && globalCtx->csCtx.npcActions[1]->action == 2 && - this->requiredObjectLoaded) { - // apparently, light waves with larger amplitudes look brighter, so the name 'amplitude' kind of works here - if (this->effects[0].state == 0) { - this->effects[0].amplitude += 1.0f / 7.0f; - if (this->effects[0].amplitude >= 1.0f) { - this->effects[0].amplitude = 1.0f; - this->effects[0].state++; - } - } else { - this->effects[0].amplitude -= 1.0f / 7.0f; - if (this->effects[0].amplitude <= 0.1f) { - this->effects[0].amplitude = 0.0f; - this->effects[0].state = 0; - } - } - - if (++this->effects[0].timer > 7) { - this->effects[0].timer = 0; - } - - start.x = globalCtx->csCtx.npcActions[1]->startPos.x; - start.y = globalCtx->csCtx.npcActions[1]->startPos.y; - start.z = globalCtx->csCtx.npcActions[1]->startPos.z; - - end.x = globalCtx->csCtx.npcActions[1]->endPos.x; - end.y = globalCtx->csCtx.npcActions[1]->endPos.y; - end.z = globalCtx->csCtx.npcActions[1]->endPos.z; - - weight = Environment_LerpWeight(globalCtx->csCtx.npcActions[1]->endFrame, - globalCtx->csCtx.npcActions[1]->startFrame, globalCtx->csCtx.frames); - Matrix_Translate((end.x - start.x) * weight + start.x, (end.y - start.y) * weight + start.y, - (end.z - start.z) * weight + start.z, MTXMODE_NEW); - Matrix_Scale(this->effects[0].size, this->effects[0].size, this->effects[0].size, MTXMODE_APPLY); - func_80093D84(globalCtx->state.gfxCtx); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(105 * this->effects[0].amplitude) + 150, 255, - (u8)(105 * this->effects[0].amplitude) + 150, this->effects[0].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(155 * this->effects[0].amplitude) + 100, - (u8)(255 * this->effects[0].amplitude), 255 - (u8)(255 * this->effects[0].amplitude), - this->effects[0].alpha); - - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1416), - G_MTX_LOAD); - - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80BA5900[this->effects[0].timer])); - gDPPipeSync(POLY_XLU_DISP++); - - gSPDisplayList(POLY_XLU_DISP++, object_spot02_objects_DL_009620); - gDPPipeSync(POLY_XLU_DISP++); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1432); -} - -void ObjectKankyo_InitBeams(ObjectKankyo* this, GlobalContext* globalCtx) { - s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DEMO_KEKKAI); - - if (objectIndex < 0) { - ASSERT(0, "0", "../z_object_kankyo.c", 1449); - } else { - this->requiredObjBankIndex = objectIndex; - } - ObjectKankyo_SetupAction(this, ObjectKankyo_WaitForBeamObject); -} - -void ObjectKankyo_WaitForBeamObject(ObjectKankyo* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { - this->requiredObjectLoaded = true; - this->actor.objBankIndex = this->requiredObjBankIndex; - ObjectKankyo_SetupAction(this, ObjectKankyo_Beams); - } -} - -void ObjectKankyo_Beams(ObjectKankyo* this, GlobalContext* globalCtx) { - u8 i; - - if (globalCtx->csCtx.state != 0) { - for (i = 0; i < 6; i++) { - if (globalCtx->csCtx.npcActions[i + 1] != NULL && globalCtx->csCtx.npcActions[i + 1]->action == 2) { - if (this->effects[i].size == 0.1f) { - func_800F3F3C(11); - } - Math_ApproachZeroF(&this->effects[i].size, 0.1f, 0.1f); - } - } - } -} - -void ObjectKankyo_DrawBeams(ObjectKankyo* this2, GlobalContext* globalCtx2) { - static Color_RGB8 sBeamPrimColors[] = { - { 255, 255, 170 }, { 170, 255, 255 }, { 255, 170, 255 }, - { 255, 255, 170 }, { 255, 255, 170 }, { 255, 255, 170 }, - }; - static Color_RGB8 sBeamEnvColors[] = { - { 0, 200, 0 }, { 0, 50, 255 }, { 100, 0, 200 }, { 200, 0, 0 }, { 200, 255, 0 }, { 255, 120, 0 }, - }; - ObjectKankyo* this = this2; - GlobalContext* globalCtx = globalCtx2; - s16 i; - f32 beamX[] = { 430.0f, 860.0f, 430.0f, -426.0f, -862.0f, -440.0f }; - f32 beamY[] = { 551.0f, 551.0f, 551.0f, 554.0f, 551.0f, 547.0f }; - f32 beamZ[] = { -96.0f, -840.0f, -1585.0f, -1578.0f, -840.0f, -78.0f }; - f32 beamYaw[] = { 29.9f, 90.0f, 150.0f, 30.0f, 90.0f, -30.1f }; - f32 beamPitch[] = { 103.4f, 103.8f, 103.6f, -103.4f, -103.5f, 103.5f }; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1539); - - if (this->requiredObjectLoaded) { - for (i = 0; i < 6; i++) { - if (this->effects[i].size > 0.001f) { - Matrix_Translate(beamX[i], beamY[i], beamZ[i], MTXMODE_NEW); - Matrix_RotateY(DEG_TO_RAD(beamYaw[i]), MTXMODE_APPLY); - Matrix_RotateX(DEG_TO_RAD(beamPitch[i]), MTXMODE_APPLY); - Matrix_Scale(this->effects[i].size, 0.1f, this->effects[i].size, MTXMODE_APPLY); - func_80093D84(globalCtx->state.gfxCtx); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, sBeamPrimColors[i].r, sBeamPrimColors[i].g, - sBeamPrimColors[i].b, 128); - gDPSetEnvColor(POLY_XLU_DISP++, sBeamEnvColors[i].r, sBeamEnvColors[i].g, sBeamEnvColors[i].b, 128); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1586), - G_MTX_LOAD); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames * 5, - globalCtx->state.frames * 10, 32, 64, 1, globalCtx->state.frames * 5, - globalCtx->state.frames * 10, 32, 64)); - gSPDisplayList(POLY_XLU_DISP++, gDemoKekkaiDL_005FF0); - } - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1607); -} diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.cpp b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.cpp new file mode 100644 index 000000000..fb05f06a9 --- /dev/null +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.cpp @@ -0,0 +1,955 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_OBJECT_KANKYO_Z_OBJECT_KANKYO_C +#include "actor_common.h" +/* + * File: z_object_kankyo.c + * Overlay: ovl_Object_Kankyo + * Description: Environmental Effects + */ + +#include "z_object_kankyo.h" +#include "objects/object_demo_kekkai/object_demo_kekkai.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_spot02_objects/object_spot02_objects.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/cosf.h" +#include "def/sinf.h" +#include "def/sys_math3d.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_common_data.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_object_kankyo.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25) + +void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); +void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); + +void ObjectKankyo_SetupAction(ObjectKankyo* pthis, ObjectKankyoActionFunc func); +void ObjectKankyo_Fairies(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_SunGraveSparkInit(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_Snow(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_Lightning(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_InitBeams(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_SunGraveSpark(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_WaitForBeamObject(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_Beams(ObjectKankyo* pthis, GlobalContext* globalCtx); + +void ObjectKankyo_DrawFairies(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_DrawSnow(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_DrawLightning(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_DrawSunGraveSpark(ObjectKankyo* pthis, GlobalContext* globalCtx); +void ObjectKankyo_DrawBeams(ObjectKankyo* pthis, GlobalContext* globalCtx); + +Mtx D_01000000; + +static void* sEffLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; + +static void* D_80BA5900[] = { + gEffSunGraveSpark1Tex, gEffSunGraveSpark2Tex, gEffSunGraveSpark3Tex, gEffSunGraveSpark4Tex, + gEffSunGraveSpark5Tex, gEffSunGraveSpark6Tex, gEffSunGraveSpark7Tex, gEffSunGraveSpark8Tex, +}; + +ActorInit Object_Kankyo_InitVars = { + ACTOR_OBJECT_KANKYO, + ACTORCAT_ITEMACTION, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(ObjectKankyo), + (ActorFunc)ObjectKankyo_Init, + (ActorFunc)ObjectKankyo_Destroy, + (ActorFunc)ObjectKankyo_Update, + (ActorFunc)ObjectKankyo_Draw, +}; + +static u8 sIsSpawned = false; +static s16 sTrailingFairies = 0; + +void ObjectKankyo_SetupAction(ObjectKankyo* pthis, ObjectKankyoActionFunc action) { + pthis->actionFunc = action; +} + +void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* pthis = (ObjectKankyo*)thisx; + s32 pad; + s16 i; + + for (i = 0; i < ARRAY_COUNT(pthis->effects); i++) { + pthis->effects[i].state = 0; + } + + pthis->actor.room = -1; + switch (pthis->actor.params) { + case 0: + if (!sIsSpawned) { + ObjectKankyo_SetupAction(pthis, ObjectKankyo_Fairies); + sIsSpawned = true; + } else { + Actor_Kill(&pthis->actor); + } + break; + + case 3: + if (!sIsSpawned) { + ObjectKankyo_SetupAction(pthis, ObjectKankyo_Snow); + sIsSpawned = true; + } else { + Actor_Kill(&pthis->actor); + } + break; + + case 2: + ObjectKankyo_SetupAction(pthis, ObjectKankyo_Lightning); + break; + + case 4: + pthis->effects[0].alpha = 0; + pthis->effects[0].amplitude = 0.0f; + Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &pthis->actor, ACTORCAT_ITEMACTION); + pthis->requiredObjectLoaded = false; + ObjectKankyo_SetupAction(pthis, ObjectKankyo_SunGraveSparkInit); + break; + + case 5: + pthis->effects[0].alpha = 0; + pthis->effects[0].amplitude = 0.0f; + + for (i = 0; i < 6; i++) { + pthis->effects[i].size = 0.1f; + } + + // Check which beams are disabled + if (Flags_GetEventChkInf(0xBB)) { + pthis->effects[0].size = 0.0f; + } + if (Flags_GetEventChkInf(0xBC)) { + pthis->effects[1].size = 0.0f; + } + if (Flags_GetEventChkInf(0xBD)) { + pthis->effects[2].size = 0.0f; + } + if (Flags_GetEventChkInf(0xBE)) { + pthis->effects[3].size = 0.0f; + } + if (Flags_GetEventChkInf(0xBF)) { + pthis->effects[4].size = 0.0f; + } + if (Flags_GetEventChkInf(0xAD)) { + pthis->effects[5].size = 0.0f; + } + + if (gSaveContext.cutsceneTrigger != 0) { + if (gSaveContext.entranceIndex == 0x0538) { + pthis->effects[0].size = 0.1f; + } + if (gSaveContext.entranceIndex == 0x053C) { + pthis->effects[1].size = 0.1f; + } + if (gSaveContext.entranceIndex == 0x0540) { + pthis->effects[2].size = 0.1f; + } + if (gSaveContext.entranceIndex == 0x0544) { + pthis->effects[3].size = 0.1f; + } + if (gSaveContext.entranceIndex == 0x0548) { + pthis->effects[4].size = 0.1f; + } + if (gSaveContext.entranceIndex == 0x054C) { + pthis->effects[5].size = 0.1f; + } + } + + pthis->requiredObjectLoaded = false; + ObjectKankyo_SetupAction(pthis, ObjectKankyo_InitBeams); + break; + } +} + +void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Actor_Kill(thisx); +} + +void ObjectKankyo_Snow(ObjectKankyo* pthis, GlobalContext* globalCtx) { +} + +void ObjectKankyo_Fairies(ObjectKankyo* pthis, GlobalContext* globalCtx) { + static Vec3f sSoundPos = { 0.0f, 0.0f, 0.0f }; + Player* player; + f32 dist; + s32 playerMoved; + f32 dx; + f32 dy; + f32 dz; + f32 viewForwardsX; + f32 viewForwardsY; + f32 viewForwardsZ; + f32 maxDist; + f32 baseX; + f32 baseY; + f32 baseZ; + Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; + Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; + f32 random; + s16 i; + Vec3f viewForwards; + + player = GET_PLAYER(globalCtx); + + if (globalCtx->sceneNum == SCENE_SPOT04 && gSaveContext.sceneSetupIndex == 7) { + dist = Math3D_Vec3f_DistXYZ(&pthis->prevEyePos, &globalCtx->view.eye); + + pthis->prevEyePos.x = globalCtx->view.eye.x; + pthis->prevEyePos.y = globalCtx->view.eye.y; + pthis->prevEyePos.z = globalCtx->view.eye.z; + + dist /= 30.0f; + if (dist > 1.0f) { + dist = 1.0f; + } + + func_800F436C(&sSoundPos, NA_SE_EV_NAVY_FLY - SFX_FLAG, (0.4f * dist) + 0.6f); + switch (globalCtx->csCtx.frames) { + case 473: + func_800788CC(NA_SE_VO_NA_HELLO_3); + break; + + case 583: + func_800F4524(&D_801333D4, NA_SE_VO_NA_HELLO_2, 32); + break; + + case 763: + func_80078884(NA_SE_EV_NAVY_CRASH - SFX_FLAG); + break; + + case 771: + func_80078884(NA_SE_VO_RT_THROW); + break; + } + } + + if (globalCtx->envCtx.unk_EE[3] < 64 && + (gSaveContext.entranceIndex != 0x00EE || gSaveContext.sceneSetupIndex != 4 || globalCtx->envCtx.unk_EE[3])) { + globalCtx->envCtx.unk_EE[3] += 16; + } + + for (i = 0; i < globalCtx->envCtx.unk_EE[3]; i++) { + // spawn in front of the camera + dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; + dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); + + viewForwards.x = dx / dist; + viewForwards.y = dy / dist; + viewForwards.z = dz / dist; + + viewForwardsX = viewForwards.x; + viewForwardsY = viewForwards.y; + viewForwardsZ = viewForwards.z; + + switch (pthis->effects[i].state) { + case 0: // init + pthis->effects[i].base.x = globalCtx->view.eye.x + viewForwardsX * 80.0f; + pthis->effects[i].base.y = globalCtx->view.eye.y + viewForwardsY * 80.0f; + pthis->effects[i].base.z = globalCtx->view.eye.z + viewForwardsZ * 80.0f; + + pthis->effects[i].pos.x = (Rand_ZeroOne() - 0.5f) * 160.0f; + pthis->effects[i].pos.y = 30.0f; + pthis->effects[i].pos.z = (Rand_ZeroOne() - 0.5f) * 160.0f; + pthis->effects[i].targetSpeed = Rand_ZeroOne() * 1.6f + 0.5f; + pthis->effects[i].alpha = 0; + pthis->effects[i].alphaTimer = Rand_ZeroOne() * 65535.0f; + pthis->effects[i].size = 0.1f; + pthis->effects[i].dirPhase.x = Rand_ZeroOne() * 360.0f; + pthis->effects[i].dirPhase.y = Rand_ZeroOne() * 360.0f; + pthis->effects[i].dirPhase.z = Rand_ZeroOne() * 360.0f; + pthis->effects[i].state++; + pthis->effects[i].timer = 0; + break; + + case 1: // blinking fairies / inactive fairy trails + case 2: // fairy trails + pthis->effects[i].alphaTimer++; + baseX = globalCtx->view.eye.x + viewForwards.x * 80.0f; + baseY = globalCtx->view.eye.y + viewForwards.y * 80.0f; + baseZ = globalCtx->view.eye.z + viewForwards.z * 80.0f; + + pthis->effects[i].prevPos.x = pthis->effects[i].pos.x; + pthis->effects[i].prevPos.y = pthis->effects[i].pos.y; + pthis->effects[i].prevPos.z = pthis->effects[i].pos.z; + + playerMoved = true; + // y velocity is set to -4 when the player is on the ground + if (player->actor.velocity.x + player->actor.velocity.y + player->actor.velocity.z == -4.0f) { + playerMoved = false; + pthis->effects[i].timer++; + } else { + pthis->effects[i].timer = 0; + } + + if (pthis->effects[i].state == 1) { + // the first 32 fairies are invisible until the player stands still + if (i < 32 && !playerMoved && pthis->effects[i].timer > 256) { + pthis->effects[i].timer = 0; + if (Rand_ZeroOne() < 0.5f) { + pthis->effects[i].angleVel = (s16)(Rand_ZeroOne() * 200.0f) + 200; + } else { + pthis->effects[i].angleVel = -((s16)(Rand_ZeroOne() * 200.0f) + 200); + } + + pthis->effects[i].flightRadius = (s16)(Rand_ZeroOne() * 50.0f) + 15; + + // uniformly scales the length and height of the wave that the lead fairy flies in + // lower numbers have a larger amplitude and period + pthis->effects[i].amplitude = (Rand_ZeroOne() * 10.0f + 10.0f) * 0.01f; + + random = Rand_ZeroOne(); + if (random < 0.2f) { + sTrailingFairies = 1; + } else if (random < 0.2f) { + // unreachable + sTrailingFairies = 3; + } else if (random < 0.4f) { + sTrailingFairies = 7; + } else { + sTrailingFairies = 15; + } + + if ((i & sTrailingFairies) == 0) { + pthis->effects[i].pos.y = 0.0f; + } + + pthis->effects[i].state = 2; + pthis->effects[i].targetSpeed = 0.0f; + } + + Math_SmoothStepToF(&pthis->effects[i].size, 0.1f, 0.10f, 0.001f, 0.00001f); + Math_SmoothStepToF(&pthis->effects[i].speed, pthis->effects[i].targetSpeed, 0.5f, 0.2f, 0.02f); + + pthis->effects[i].pos.x += sinf(pthis->effects[i].dirPhase.x) * pthis->effects[i].speed; + pthis->effects[i].pos.y += sinf(pthis->effects[i].dirPhase.y) * pthis->effects[i].speed; + pthis->effects[i].pos.z += sinf(pthis->effects[i].dirPhase.z) * pthis->effects[i].speed; + + switch ((i >> 1) & 3) { + case 0: + pthis->effects[i].dirPhase.x += 0.008f; + pthis->effects[i].dirPhase.y += 0.05f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.z += 0.015f; + break; + + case 1: + pthis->effects[i].dirPhase.x += 0.01f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.y += 0.05f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.z += 0.005f * Rand_ZeroOne(); + break; + + case 2: + pthis->effects[i].dirPhase.x += 0.01f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.y += 0.4f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.z += 0.004f * Rand_ZeroOne(); + break; + + case 3: + pthis->effects[i].dirPhase.x += 0.01 * Rand_ZeroOne(); + pthis->effects[i].dirPhase.y += 0.08f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.z += 0.05f * Rand_ZeroOne(); + break; + } + } else if (pthis->effects[i].state == 2) { + // scatter when the player moves or after a long enough time + if (playerMoved || pthis->effects[i].timer > 1280) { + pthis->effects[i].timer = 0; + pthis->effects[i].state = 1; + pthis->effects[i].speed = 1.5f; + pthis->effects[i].targetSpeed = Rand_ZeroOne() * 1.6f + 0.5f; + } + + if ((i & sTrailingFairies) == 0) { // leader fairy + Math_SmoothStepToF(&pthis->effects[i].size, 0.25f, 0.1f, 0.001f, 0.00001f); + + // move the center of the flight path to player's position + Math_SmoothStepToF(&pthis->effects[i].base.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&pthis->effects[i].base.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, + 0.2f); + Math_SmoothStepToF(&pthis->effects[i].base.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); + + // results unused + Math_SmoothStepToF(&pthis->effects[i].pos.x, + Math_SinS(pthis->effects[i].angle - 0x8000) * pthis->effects[i].flightRadius, + 0.5f, 2.0f, 0.2f); + Math_SmoothStepToF(&pthis->effects[i].pos.z, + Math_CosS(pthis->effects[i].angle - 0x8000) * pthis->effects[i].flightRadius, + 0.5f, 2.0f, 0.2f); + + // the lead fairy's y position approximately follows a sine wave with `amplitude` as angular + // frequency and `1 / amplitude` as amplitude + pthis->effects[i].angle += pthis->effects[i].angleVel; + pthis->effects[i].pos.y += sinf(pthis->effects[i].dirPhase.y); + + pthis->effects[i].dirPhase.x += 0.2f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.y += pthis->effects[i].amplitude; + pthis->effects[i].dirPhase.z += 0.1f * Rand_ZeroOne(); + + // circle around the player + pthis->effects[i].pos.x = + Math_SinS(pthis->effects[i].angle - 0x8000) * pthis->effects[i].flightRadius; + pthis->effects[i].pos.z = + Math_CosS(pthis->effects[i].angle - 0x8000) * pthis->effects[i].flightRadius; + } else { // trailing fairy + Math_SmoothStepToF(&pthis->effects[i].size, 0.1f, 0.10f, 0.001f, 0.00001f); + Math_SmoothStepToF(&pthis->effects[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); + + // follow previous fairy, translate their position to be relative to our home + pthis->effects[i].pos.x = + pthis->effects[i - 1].prevPos.x + (pthis->effects[i - 1].base.x - pthis->effects[i].base.x); + pthis->effects[i].pos.y = + pthis->effects[i - 1].prevPos.y + (pthis->effects[i - 1].base.y - pthis->effects[i].base.y); + pthis->effects[i].pos.z = + pthis->effects[i - 1].prevPos.z + (pthis->effects[i - 1].base.z - pthis->effects[i].base.z); + } + } + + if (pthis->effects[i].state != 2) { + maxDist = 130.0f; + if (pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX > maxDist || + pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX < -maxDist || + pthis->effects[i].base.y + pthis->effects[i].pos.y - baseY > maxDist || + pthis->effects[i].base.y + pthis->effects[i].pos.y - baseY < -maxDist || + pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ > maxDist || + pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ < -maxDist) { + + // when a fairy moves off screen, wrap around to the other side + if (pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX > maxDist) { + pthis->effects[i].base.x = baseX - maxDist; + pthis->effects[i].pos.x = 0.0f; + } + if (pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX < -maxDist) { + pthis->effects[i].base.x = baseX + maxDist; + pthis->effects[i].pos.x = 0.0f; + } + if (pthis->effects[i].base.y + pthis->effects[i].pos.y - baseY > 50.0f) { + pthis->effects[i].base.y = baseY - 50.0f; + pthis->effects[i].pos.y = 0.0f; + } + if (pthis->effects[i].base.y + pthis->effects[i].pos.y - baseY < -50.0f) { + pthis->effects[i].base.y = baseY + 50.0f; + pthis->effects[i].pos.y = 0.0f; + } + if (pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ > maxDist) { + pthis->effects[i].base.z = baseZ - maxDist; + pthis->effects[i].pos.z = 0.0f; + } + if (pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ < -maxDist) { + pthis->effects[i].base.z = baseZ + maxDist; + pthis->effects[i].pos.z = 0.0f; + } + } + } + break; + + case 3: // reset, never reached + pthis->effects[i].state = 0; + break; + } + } +} + +void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* pthis = (ObjectKankyo*)thisx; + + pthis->actionFunc(pthis, globalCtx); +} + +void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* pthis = (ObjectKankyo*)thisx; + + switch (pthis->actor.params) { + case 0: + ObjectKankyo_DrawFairies(pthis, globalCtx); + break; + + case 2: + ObjectKankyo_DrawLightning(pthis, globalCtx); + break; + + case 3: + ObjectKankyo_DrawSnow(pthis, globalCtx); + break; + + case 4: + ObjectKankyo_DrawSunGraveSpark(pthis, globalCtx); + break; + + case 5: + ObjectKankyo_DrawBeams(pthis, globalCtx); + break; + } +} + +void ObjectKankyo_DrawFairies(ObjectKankyo* pthis2, GlobalContext* globalCtx2) { + ObjectKankyo* pthis = pthis2; + GlobalContext* globalCtx = globalCtx2; + f32 alphaScale; + Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; + Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; + s16 i; + + if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 807); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteTextureLoadDL); + + for (i = 0; i < globalCtx->envCtx.unk_EE[3]; i++) { + Matrix_Translate(pthis->effects[i].base.x + pthis->effects[i].pos.x, + pthis->effects[i].base.y + pthis->effects[i].pos.y, + pthis->effects[i].base.z + pthis->effects[i].pos.z, MTXMODE_NEW); + + // scale when fading in or out + alphaScale = pthis->effects[i].alpha / 50.0f; + if (alphaScale > 1.0f) { + alphaScale = 1.0f; + } + + Matrix_Scale(pthis->effects[i].size * alphaScale, pthis->effects[i].size * alphaScale, + pthis->effects[i].size * alphaScale, MTXMODE_APPLY); + if (i < 32) { + if (pthis->effects[i].state != 2) { + if (pthis->effects[i].alpha > 0) { + pthis->effects[i].alpha--; + } + } else { + if (pthis->effects[i].alpha < 100) { + pthis->effects[i].alpha++; + } + } + } else { + if (pthis->effects[i].state != 2) { + if ((pthis->effects[i].alphaTimer & 0x1F) < 16) { + if (pthis->effects[i].alpha < 235) { + pthis->effects[i].alpha += 20; + } + } else { + if (pthis->effects[i].alpha > 20) { + pthis->effects[i].alpha -= 20; + } + } + } else { + // unreachable + if ((pthis->effects[i].alphaTimer & 0xF) < 8) { + if (pthis->effects[i].alpha < 255) { + pthis->effects[i].alpha += 100; + } + } else { + if (pthis->effects[i].alpha > 10) { + pthis->effects[i].alpha -= 10; + } + } + } + } + + gDPPipeSync(POLY_XLU_DISP++); + + switch (i & 1) { + case 0: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, pthis->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, pthis->effects[i].alpha); + break; + + case 1: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, pthis->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, pthis->effects[i].alpha); + break; + } + + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 913), G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteDL); + } + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 922); + } +} + +void ObjectKankyo_DrawSnow(ObjectKankyo* pthis2, GlobalContext* globalCtx2) { + ObjectKankyo* pthis = pthis2; + GlobalContext* globalCtx = globalCtx2; + f32 dist; + f32 dx; + f32 dy; + f32 dz; + f32 maxDist; + f32 temp; + f32 baseX; + f32 baseY; + f32 baseZ; + Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; + Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; + s16 i; + s32 pad; + s32 pad2; + + if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100)) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 958); + if (globalCtx->envCtx.unk_EE[2] < globalCtx->envCtx.unk_EE[3]) { + if (globalCtx->state.frames % 16 == 0) { + globalCtx->envCtx.unk_EE[2] += 2; + } + } else if (globalCtx->envCtx.unk_EE[2] > globalCtx->envCtx.unk_EE[3]) { + if (globalCtx->state.frames % 16 == 0) { + globalCtx->envCtx.unk_EE[2] -= 2; + } + } + + for (i = 0; i < globalCtx->envCtx.unk_EE[2]; i++) { + switch (pthis->effects[i].state) { + case 0: + // spawn in front of the camera + dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; + dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); + + // fake + temp = dz / dist; + pthis->effects[i].base.x = globalCtx->view.eye.x + dx / dist * 80.0f; + pthis->effects[i].base.y = globalCtx->view.eye.y + dy / dist * 80.0f; + pthis->effects[i].base.z = globalCtx->view.eye.z + temp * 80.0f; + + pthis->effects[i].pos.x = (Rand_ZeroOne() - 0.5f) * 160.0f; + pthis->effects[i].pos.y = 80.0f; + pthis->effects[i].pos.z = (Rand_ZeroOne() - 0.5f) * 160.0f; + if (pthis->effects[i].base.y + pthis->effects[i].pos.y < 50.0f) { + pthis->effects[i].base.y = 50.0f; + } + pthis->effects[i].speed = Rand_ZeroOne() * 5.0f + 0.5f; + pthis->effects[i].dirPhase.x = Rand_ZeroOne() * 360.0f; + pthis->effects[i].dirPhase.z = Rand_ZeroOne() * 360.0f; + pthis->effects[i].state++; + break; + + case 1: + dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; + dy = globalCtx->view.lookAt.y - globalCtx->view.eye.y; + dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); + + baseX = globalCtx->view.eye.x + dx / dist * 80.0f; + baseY = globalCtx->view.eye.y + dy / dist * 80.0f; + baseZ = globalCtx->view.eye.z + dz / dist * 80.0f; + + pthis->effects[i].dirPhase.x += 0.049999997f * Rand_ZeroOne(); + pthis->effects[i].dirPhase.z += 0.049999997f * Rand_ZeroOne(); + pthis->effects[i].pos.x += sinf(pthis->effects[i].dirPhase.x * 0.01f); + pthis->effects[i].pos.z += cosf(pthis->effects[i].dirPhase.z * 0.01f); + pthis->effects[i].pos.y += -pthis->effects[i].speed; + + if (pthis->effects[i].base.y + pthis->effects[i].pos.y < pthis->actor.world.pos.y || + pthis->effects[i].base.y + pthis->effects[i].pos.y < globalCtx->view.eye.y - 150.0f) { + pthis->effects[i].state++; + } + + maxDist = 80; + if (pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX > maxDist || + pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX < -maxDist || + pthis->effects[i].base.y + pthis->effects[i].pos.y - baseY > maxDist || + pthis->effects[i].base.y + pthis->effects[i].pos.y - baseY < -maxDist || + pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ > maxDist || + pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ < -maxDist) { + + // when off screen, wrap around to the other side + if (pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX > maxDist) { + pthis->effects[i].base.x = baseX - maxDist; + pthis->effects[i].pos.x = 0.0f; + } + if (pthis->effects[i].base.x + pthis->effects[i].pos.x - baseX < -maxDist) { + pthis->effects[i].base.x = baseX + maxDist; + pthis->effects[i].pos.x = 0.0f; + } + if (pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ > maxDist) { + pthis->effects[i].base.z = baseZ - maxDist; + pthis->effects[i].pos.z = 0.0f; + } + if (pthis->effects[i].base.z + pthis->effects[i].pos.z - baseZ < -maxDist) { + pthis->effects[i].base.z = baseZ + maxDist; + pthis->effects[i].pos.z = 0.0f; + } + } + break; + + case 2: + pthis->effects[i].state = 0; + break; + } + + if (1) {} + if (1) {} + Matrix_Translate(pthis->effects[i].base.x + pthis->effects[i].pos.x, + pthis->effects[i].base.y + pthis->effects[i].pos.y, + pthis->effects[i].base.z + pthis->effects[i].pos.z, MTXMODE_NEW); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + gDPPipeSync(POLY_XLU_DISP++); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 200, 180); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 180); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1107), + G_MTX_LOAD); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDust5Tex)); + + func_80094C50(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_MODELVIEW | G_MTX_NOPUSH | G_MTX_MUL); + + gDPPipeSync(POLY_XLU_DISP++); + + gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); + + gDPPipeSync(POLY_XLU_DISP++); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1127); + } +} + +void ObjectKankyo_Lightning(ObjectKankyo* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0 && globalCtx->csCtx.npcActions[0] != NULL) { + switch (pthis->effects[0].state) { + case 0: + pthis->effects[0].timer = 0; + if (globalCtx->csCtx.npcActions[0]->action == 2) { + pthis->effects[0].state++; + } + break; + + case 1: + if (++pthis->effects[0].timer >= 7) { + pthis->effects[0].state++; + } + break; + + case 2: + if (globalCtx->csCtx.npcActions[0]->action == 1) { + pthis->effects[0].state = 0; + } + break; + } + } +} + +void ObjectKankyo_DrawLightning(ObjectKankyo* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1182); + + if (pthis->effects[0].state == 1) { + Matrix_Translate(globalCtx->csCtx.npcActions[0]->startPos.x, globalCtx->csCtx.npcActions[0]->startPos.y, + globalCtx->csCtx.npcActions[0]->startPos.z, MTXMODE_NEW); + Matrix_RotateX(DEG_TO_RAD(20.0f), MTXMODE_APPLY); + Matrix_RotateZ(DEG_TO_RAD(20.0f), MTXMODE_APPLY); + Matrix_Scale(2.0f, 5.0f, 2.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 128); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 128); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1213), G_MTX_LOAD); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEffLightningTextures[pthis->effects[0].timer])); + func_80094C50(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_MODELVIEW | G_MTX_NOPUSH | G_MTX_MUL); + gDPPipeSync(POLY_XLU_DISP++); + gSPDisplayList(POLY_XLU_DISP++, gEffLightningDL); + gDPPipeSync(POLY_XLU_DISP++); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1233); +} + +void ObjectKankyo_SunGraveSparkInit(ObjectKankyo* pthis, GlobalContext* globalCtx) { + s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SPOT02_OBJECTS); + + if (objBankIndex < 0) { + ASSERT(0, "0", "../z_object_kankyo.c", 1251); + } else { + pthis->requiredObjBankIndex = objBankIndex; + } + ObjectKankyo_SetupAction(pthis, ObjectKankyo_WaitForSunGraveSparkObject); +} + +void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->requiredObjBankIndex)) { + pthis->requiredObjectLoaded = true; + pthis->effects[0].alpha = 0; + pthis->actor.objBankIndex = pthis->requiredObjBankIndex; + pthis->effects[0].size = 7.0f; + ObjectKankyo_SetupAction(pthis, ObjectKankyo_SunGraveSpark); + } +} + +void ObjectKankyo_SunGraveSpark(ObjectKankyo* pthis, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + if (globalCtx->csCtx.npcActions[1] != NULL && globalCtx->csCtx.npcActions[1]->action == 2) { + Audio_PlayActorSound2(&pthis->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); + if ((s16)pthis->effects[0].alpha + 20 > 255) { + pthis->effects[0].alpha = 255; + } else { + pthis->effects[0].alpha += 20; + } + Math_SmoothStepToF(&pthis->effects[0].size, 1.8f, 0.5f, 0.28f, 0.01f); + } + } +} + +void ObjectKankyo_DrawSunGraveSpark(ObjectKankyo* pthis2, GlobalContext* globalCtx2) { + ObjectKankyo* pthis = pthis2; + GlobalContext* globalCtx = globalCtx2; + Vec3f start; + Vec3f end; + f32 weight; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1324); + if (globalCtx->csCtx.state != 0) { + if (globalCtx->csCtx.npcActions[1] != NULL && globalCtx->csCtx.npcActions[1]->action == 2 && + pthis->requiredObjectLoaded) { + // apparently, light waves with larger amplitudes look brighter, so the name 'amplitude' kind of works here + if (pthis->effects[0].state == 0) { + pthis->effects[0].amplitude += 1.0f / 7.0f; + if (pthis->effects[0].amplitude >= 1.0f) { + pthis->effects[0].amplitude = 1.0f; + pthis->effects[0].state++; + } + } else { + pthis->effects[0].amplitude -= 1.0f / 7.0f; + if (pthis->effects[0].amplitude <= 0.1f) { + pthis->effects[0].amplitude = 0.0f; + pthis->effects[0].state = 0; + } + } + + if (++pthis->effects[0].timer > 7) { + pthis->effects[0].timer = 0; + } + + start.x = globalCtx->csCtx.npcActions[1]->startPos.x; + start.y = globalCtx->csCtx.npcActions[1]->startPos.y; + start.z = globalCtx->csCtx.npcActions[1]->startPos.z; + + end.x = globalCtx->csCtx.npcActions[1]->endPos.x; + end.y = globalCtx->csCtx.npcActions[1]->endPos.y; + end.z = globalCtx->csCtx.npcActions[1]->endPos.z; + + weight = Environment_LerpWeight(globalCtx->csCtx.npcActions[1]->endFrame, + globalCtx->csCtx.npcActions[1]->startFrame, globalCtx->csCtx.frames); + Matrix_Translate((end.x - start.x) * weight + start.x, (end.y - start.y) * weight + start.y, + (end.z - start.z) * weight + start.z, MTXMODE_NEW); + Matrix_Scale(pthis->effects[0].size, pthis->effects[0].size, pthis->effects[0].size, MTXMODE_APPLY); + func_80093D84(globalCtx->state.gfxCtx); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(105 * pthis->effects[0].amplitude) + 150, 255, + (u8)(105 * pthis->effects[0].amplitude) + 150, pthis->effects[0].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(155 * pthis->effects[0].amplitude) + 100, + (u8)(255 * pthis->effects[0].amplitude), 255 - (u8)(255 * pthis->effects[0].amplitude), + pthis->effects[0].alpha); + + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1416), + G_MTX_LOAD); + + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80BA5900[pthis->effects[0].timer])); + gDPPipeSync(POLY_XLU_DISP++); + + gSPDisplayList(POLY_XLU_DISP++, object_spot02_objects_DL_009620); + gDPPipeSync(POLY_XLU_DISP++); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1432); +} + +void ObjectKankyo_InitBeams(ObjectKankyo* pthis, GlobalContext* globalCtx) { + s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DEMO_KEKKAI); + + if (objectIndex < 0) { + ASSERT(0, "0", "../z_object_kankyo.c", 1449); + } else { + pthis->requiredObjBankIndex = objectIndex; + } + ObjectKankyo_SetupAction(pthis, ObjectKankyo_WaitForBeamObject); +} + +void ObjectKankyo_WaitForBeamObject(ObjectKankyo* pthis, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, pthis->requiredObjBankIndex)) { + pthis->requiredObjectLoaded = true; + pthis->actor.objBankIndex = pthis->requiredObjBankIndex; + ObjectKankyo_SetupAction(pthis, ObjectKankyo_Beams); + } +} + +void ObjectKankyo_Beams(ObjectKankyo* pthis, GlobalContext* globalCtx) { + u8 i; + + if (globalCtx->csCtx.state != 0) { + for (i = 0; i < 6; i++) { + if (globalCtx->csCtx.npcActions[i + 1] != NULL && globalCtx->csCtx.npcActions[i + 1]->action == 2) { + if (pthis->effects[i].size == 0.1f) { + func_800F3F3C(11); + } + Math_ApproachZeroF(&pthis->effects[i].size, 0.1f, 0.1f); + } + } + } +} + +void ObjectKankyo_DrawBeams(ObjectKankyo* pthis2, GlobalContext* globalCtx2) { + static Color_RGB8 sBeamPrimColors[] = { + { 255, 255, 170 }, { 170, 255, 255 }, { 255, 170, 255 }, + { 255, 255, 170 }, { 255, 255, 170 }, { 255, 255, 170 }, + }; + static Color_RGB8 sBeamEnvColors[] = { + { 0, 200, 0 }, { 0, 50, 255 }, { 100, 0, 200 }, { 200, 0, 0 }, { 200, 255, 0 }, { 255, 120, 0 }, + }; + ObjectKankyo* pthis = pthis2; + GlobalContext* globalCtx = globalCtx2; + s16 i; + f32 beamX[] = { 430.0f, 860.0f, 430.0f, -426.0f, -862.0f, -440.0f }; + f32 beamY[] = { 551.0f, 551.0f, 551.0f, 554.0f, 551.0f, 547.0f }; + f32 beamZ[] = { -96.0f, -840.0f, -1585.0f, -1578.0f, -840.0f, -78.0f }; + f32 beamYaw[] = { 29.9f, 90.0f, 150.0f, 30.0f, 90.0f, -30.1f }; + f32 beamPitch[] = { 103.4f, 103.8f, 103.6f, -103.4f, -103.5f, 103.5f }; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1539); + + if (pthis->requiredObjectLoaded) { + for (i = 0; i < 6; i++) { + if (pthis->effects[i].size > 0.001f) { + Matrix_Translate(beamX[i], beamY[i], beamZ[i], MTXMODE_NEW); + Matrix_RotateY(DEG_TO_RAD(beamYaw[i]), MTXMODE_APPLY); + Matrix_RotateX(DEG_TO_RAD(beamPitch[i]), MTXMODE_APPLY); + Matrix_Scale(pthis->effects[i].size, 0.1f, pthis->effects[i].size, MTXMODE_APPLY); + func_80093D84(globalCtx->state.gfxCtx); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, sBeamPrimColors[i].r, sBeamPrimColors[i].g, + sBeamPrimColors[i].b, 128); + gDPSetEnvColor(POLY_XLU_DISP++, sBeamEnvColors[i].r, sBeamEnvColors[i].g, sBeamEnvColors[i].b, 128); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1586), + G_MTX_LOAD); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames * 5, + globalCtx->state.frames * 10, 32, 64, 1, globalCtx->state.frames * 5, + globalCtx->state.frames * 10, 32, 64)); + gSPDisplayList(POLY_XLU_DISP++, gDemoKekkaiDL_005FF0); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 1607); +} diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.cpp similarity index 56% rename from src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c rename to src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.cpp index e444bcd64..8314cc06f 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.cpp @@ -26,9 +26,9 @@ void OceffSpot_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffSpot_Update(Actor* thisx, GlobalContext* globalCtx); void OceffSpot_Draw(Actor* thisx, GlobalContext* globalCtx); -void OceffSpot_GrowCylinder(OceffSpot* this, GlobalContext* globalCtx); +void OceffSpot_GrowCylinder(OceffSpot* pthis, GlobalContext* globalCtx); -const ActorInit Oceff_Spot_InitVars = { +ActorInit Oceff_Spot_InitVars = { ACTOR_OCEFF_SPOT, ACTORCAT_ITEMACTION, FLAGS, @@ -40,58 +40,58 @@ const ActorInit Oceff_Spot_InitVars = { (ActorFunc)OceffSpot_Draw, }; -#include "overlays/ovl_Oceff_Spot/ovl_Oceff_Spot.c" +#include "overlays/ovl_Oceff_Spot/ovl_Oceff_Spot.cpp" static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_STOP), }; -void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc) { - this->actionFunc = actionFunc; +void OceffSpot_SetupAction(OceffSpot* pthis, OceffSpotActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void OceffSpot_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - OceffSpot* this = (OceffSpot*)thisx; + OceffSpot* pthis = (OceffSpot*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); - OceffSpot_SetupAction(this, OceffSpot_GrowCylinder); + Actor_ProcessInitChain(&pthis->actor, sInitChain); + OceffSpot_SetupAction(pthis, OceffSpot_GrowCylinder); - Lights_PointNoGlowSetInfo(&this->lightInfo1, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); - this->lightNode1 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo1); + Lights_PointNoGlowSetInfo(&pthis->lightInfo1, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0); + pthis->lightNode1 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo1); - Lights_PointNoGlowSetInfo(&this->lightInfo2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); - this->lightNode2 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo2); + Lights_PointNoGlowSetInfo(&pthis->lightInfo2, pthis->actor.world.pos.x, pthis->actor.world.pos.y, + pthis->actor.world.pos.z, 0, 0, 0, 0); + pthis->lightNode2 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &pthis->lightInfo2); if (YREG(15)) { - this->actor.scale.y = 2.4f; + pthis->actor.scale.y = 2.4f; } else { - this->actor.scale.y = 0.3f; + pthis->actor.scale.y = 0.3f; } - this->unk_174 = 0.0f; + pthis->unk_174 = 0.0f; } void OceffSpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { s32 pad; - OceffSpot* this = (OceffSpot*)thisx; + OceffSpot* pthis = (OceffSpot*)thisx; Player* player = GET_PLAYER(globalCtx); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode1); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode2); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode1); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, pthis->lightNode2); func_800876C8(globalCtx); if ((gSaveContext.nayrusLoveTimer != 0) && (globalCtx->actorCtx.actorLists[ACTORCAT_PLAYER].length != 0)) { player->stateFlags3 |= 0x40; } } -void OceffSpot_End(OceffSpot* this, GlobalContext* globalCtx) { - if (this->unk_174 > 0.0f) { - this->unk_174 -= 0.05f; +void OceffSpot_End(OceffSpot* pthis, GlobalContext* globalCtx) { + if (pthis->unk_174 > 0.0f) { + pthis->unk_174 -= 0.05f; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); if (gTimeIncrement != 400 && globalCtx->msgCtx.unk_E40E == 0 && (gSaveContext.eventInf[0] & 0xF) != 1) { if (globalCtx->msgCtx.ocarinaAction != OCARINA_ACTION_CHECK_NOWARP_DONE || globalCtx->msgCtx.ocarinaMode != OCARINA_MODE_08) { @@ -111,54 +111,54 @@ void OceffSpot_End(OceffSpot* this, GlobalContext* globalCtx) { } } -void OceffSpot_Wait(OceffSpot* this, GlobalContext* globalCtx) { - if (this->timer > 0) { - this->timer--; +void OceffSpot_Wait(OceffSpot* pthis, GlobalContext* globalCtx) { + if (pthis->timer > 0) { + pthis->timer--; } else { - OceffSpot_SetupAction(this, OceffSpot_End); + OceffSpot_SetupAction(pthis, OceffSpot_End); } } -void OceffSpot_GrowCylinder(OceffSpot* this, GlobalContext* globalCtx) { - if (this->unk_174 < 1.0f) { - this->unk_174 += 0.05f; +void OceffSpot_GrowCylinder(OceffSpot* pthis, GlobalContext* globalCtx) { + if (pthis->unk_174 < 1.0f) { + pthis->unk_174 += 0.05f; } else { - OceffSpot_SetupAction(this, OceffSpot_Wait); - this->timer = 60; + OceffSpot_SetupAction(pthis, OceffSpot_Wait); + pthis->timer = 60; } } void OceffSpot_Update(Actor* thisx, GlobalContext* globalCtx) { - OceffSpot* this = (OceffSpot*)thisx; + OceffSpot* pthis = (OceffSpot*)thisx; s32 pad; Player* player = GET_PLAYER(globalCtx); f32 temp; - temp = (1.0f - cosf(this->unk_174 * M_PI)) * 0.5f; - this->actionFunc(this, globalCtx); + temp = (1.0f - cosf(pthis->unk_174 * M_PI)) * 0.5f; + pthis->actionFunc(pthis, globalCtx); - this->actor.scale.z = 0.42f * temp; - this->actor.scale.x = 0.42f * temp; + pthis->actor.scale.z = 0.42f * temp; + pthis->actor.scale.x = 0.42f * temp; - this->actor.world.pos = player->actor.world.pos; - this->actor.world.pos.y += 5.0f; + pthis->actor.world.pos = player->actor.world.pos; + pthis->actor.world.pos.y += 5.0f; - temp = (2.0f - this->unk_174) * this->unk_174; + temp = (2.0f - pthis->unk_174) * pthis->unk_174; Environment_AdjustLights(globalCtx, temp * 0.5F, 880.0f, 0.2f, 0.9f); - Lights_PointNoGlowSetInfo(&this->lightInfo1, (s16)this->actor.world.pos.x, (s16)this->actor.world.pos.y + 55.0f, - (s16)this->actor.world.pos.z, (s32)(255.0f * temp), (s32)(255.0f * temp), + Lights_PointNoGlowSetInfo(&pthis->lightInfo1, (s16)pthis->actor.world.pos.x, (s16)pthis->actor.world.pos.y + 55.0f, + (s16)pthis->actor.world.pos.z, (s32)(255.0f * temp), (s32)(255.0f * temp), (s32)(200.0f * temp), (s16)(100.0f * temp)); - Lights_PointNoGlowSetInfo(&this->lightInfo2, - (s16)this->actor.world.pos.x + Math_SinS(player->actor.shape.rot.y) * 20.0f, - (s16)this->actor.world.pos.y + 20.0f, - (s16)this->actor.world.pos.z + Math_CosS(player->actor.shape.rot.y) * 20.0f, + Lights_PointNoGlowSetInfo(&pthis->lightInfo2, + (s16)pthis->actor.world.pos.x + Math_SinS(player->actor.shape.rot.y) * 20.0f, + (s16)pthis->actor.world.pos.y + 20.0f, + (s16)pthis->actor.world.pos.z + Math_CosS(player->actor.shape.rot.y) * 20.0f, (s32)(255.0f * temp), (s32)(255.0f * temp), (s32)(200.0f * temp), (s16)(100.0f * temp)); } void OceffSpot_Draw(Actor* thisx, GlobalContext* globalCtx) { - OceffSpot* this = (OceffSpot*)thisx; + OceffSpot* pthis = (OceffSpot*)thisx; u32 scroll = globalCtx->state.frames & 0xFFFF; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_oceff_spot.c", 466); diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.cpp similarity index 57% rename from src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c rename to src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.cpp index adfd8dedb..9a01fce75 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.cpp @@ -23,10 +23,10 @@ void OceffStorm_Draw(Actor* thisx, GlobalContext* globalCtx); void OceffStorm_Draw2(Actor* thisx, GlobalContext* globalCtx); -void OceffStorm_DefaultAction(OceffStorm* this, GlobalContext* globalCtx); -void OceffStorm_UnkAction(OceffStorm* this, GlobalContext* globalCtx); +void OceffStorm_DefaultAction(OceffStorm* pthis, GlobalContext* globalCtx); +void OceffStorm_UnkAction(OceffStorm* pthis, GlobalContext* globalCtx); -const ActorInit Oceff_Storm_InitVars = { +ActorInit Oceff_Storm_InitVars = { ACTOR_OCEFF_STORM, ACTORCAT_ITEMACTION, FLAGS, @@ -38,33 +38,33 @@ const ActorInit Oceff_Storm_InitVars = { (ActorFunc)OceffStorm_Draw, }; -void OceffStorm_SetupAction(OceffStorm* this, OceffStormActionFunc actionFunc) { - this->actionFunc = actionFunc; +void OceffStorm_SetupAction(OceffStorm* pthis, OceffStormActionFunc actionFunc) { + pthis->actionFunc = actionFunc; } void OceffStorm_Init(Actor* thisx, GlobalContext* globalCtx) { - OceffStorm* this = (OceffStorm*)thisx; - OceffStorm_SetupAction(this, OceffStorm_DefaultAction); - this->posYOffAdd = 0; - this->counter = 0; - this->primColorAlpha = 0; - this->vtxAlpha = 0; - this->actor.scale.y = 0.0f; - this->actor.scale.z = 0.0f; - this->actor.scale.x = 0.0f; - this->posYOff = this->posYOffAdd; + OceffStorm* pthis = (OceffStorm*)thisx; + OceffStorm_SetupAction(pthis, OceffStorm_DefaultAction); + pthis->posYOffAdd = 0; + pthis->counter = 0; + pthis->primColorAlpha = 0; + pthis->vtxAlpha = 0; + pthis->actor.scale.y = 0.0f; + pthis->actor.scale.z = 0.0f; + pthis->actor.scale.x = 0.0f; + pthis->posYOff = pthis->posYOffAdd; - if (this->actor.params == 1) { - OceffStorm_SetupAction(this, OceffStorm_UnkAction); - this->actor.draw = OceffStorm_Draw2; + if (pthis->actor.params == 1) { + OceffStorm_SetupAction(pthis, OceffStorm_UnkAction); + pthis->actor.draw = OceffStorm_Draw2; } else { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OKARINA_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y - 30.0f, this->actor.world.pos.z, 0, 0, 0, 1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OKARINA_EFFECT, pthis->actor.world.pos.x, + pthis->actor.world.pos.y - 30.0f, pthis->actor.world.pos.z, 0, 0, 0, 1); } } void OceffStorm_Destroy(Actor* thisx, GlobalContext* globalCtx) { - OceffStorm* this = (OceffStorm*)thisx; + OceffStorm* pthis = (OceffStorm*)thisx; Player* player = GET_PLAYER(globalCtx); func_800876C8(globalCtx); @@ -73,66 +73,66 @@ void OceffStorm_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void OceffStorm_DefaultAction(OceffStorm* this, GlobalContext* globalCtx) { - if (this->counter < 20) { - this->primColorAlpha = (s8)(this->counter * 5.0f); - } else if (this->counter > 80) { - this->primColorAlpha = (s8)((100 - this->counter) * 5.0f); +void OceffStorm_DefaultAction(OceffStorm* pthis, GlobalContext* globalCtx) { + if (pthis->counter < 20) { + pthis->primColorAlpha = (s8)(pthis->counter * 5.0f); + } else if (pthis->counter > 80) { + pthis->primColorAlpha = (s8)((100 - pthis->counter) * 5.0f); } else { - this->primColorAlpha = 100; + pthis->primColorAlpha = 100; } - if (this->counter < 10 || this->counter >= 90) { - this->vtxAlpha = 0; + if (pthis->counter < 10 || pthis->counter >= 90) { + pthis->vtxAlpha = 0; } else { - if (this->counter <= 65) { - if (this->vtxAlpha <= 200) { - this->vtxAlpha += 10; + if (pthis->counter <= 65) { + if (pthis->vtxAlpha <= 200) { + pthis->vtxAlpha += 10; } - this->actor.scale.x = this->actor.scale.z = 0.4f; - this->actor.scale.y = 0.3f; - } else if (this->counter > 65) { - this->vtxAlpha = (90 - this->counter) * 10; + pthis->actor.scale.x = pthis->actor.scale.z = 0.4f; + pthis->actor.scale.y = 0.3f; + } else if (pthis->counter > 65) { + pthis->vtxAlpha = (90 - pthis->counter) * 10; } else { - this->vtxAlpha = 255; - this->actor.scale.x = this->actor.scale.z = 0.4f; + pthis->vtxAlpha = 255; + pthis->actor.scale.x = pthis->actor.scale.z = 0.4f; } } - if (this->counter > 60) { - this->actor.world.pos.y += this->posYOff * 0.01f; - this->posYOff += this->posYOffAdd; - this->posYOffAdd += 10; + if (pthis->counter > 60) { + pthis->actor.world.pos.y += pthis->posYOff * 0.01f; + pthis->posYOff += pthis->posYOffAdd; + pthis->posYOffAdd += 10; } - if (this->counter < 100) { - this->counter++; + if (pthis->counter < 100) { + pthis->counter++; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void OceffStorm_UnkAction(OceffStorm* this, GlobalContext* globalCtx) { - if (this->primColorAlpha < 100) { - this->primColorAlpha += 5; +void OceffStorm_UnkAction(OceffStorm* pthis, GlobalContext* globalCtx) { + if (pthis->primColorAlpha < 100) { + pthis->primColorAlpha += 5; } //! @bug Actor_Kill is never called so the actor will stay alive forever } void OceffStorm_Update(Actor* thisx, GlobalContext* globalCtx) { - OceffStorm* this = (OceffStorm*)thisx; + OceffStorm* pthis = (OceffStorm*)thisx; Player* player = GET_PLAYER(globalCtx); - this->actor.world.pos = player->actor.world.pos; - this->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); - this->actionFunc(this, globalCtx); + pthis->actor.world.pos = player->actor.world.pos; + pthis->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + pthis->actionFunc(pthis, globalCtx); } -#include "overlays/ovl_Oceff_Storm/ovl_Oceff_Storm.c" +#include "overlays/ovl_Oceff_Storm/ovl_Oceff_Storm.cpp" void OceffStorm_Draw2(Actor* thisx, GlobalContext* globalCtx) { u32 scroll = globalCtx->state.frames & 0xFFF; - OceffStorm* this = (OceffStorm*)thisx; + OceffStorm* pthis = (OceffStorm*)thisx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_oceff_storm.c", 449); @@ -143,7 +143,7 @@ void OceffStorm_Draw2(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = func_80093F34(POLY_XLU_DISP); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 150, this->primColorAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 150, pthis->primColorAlpha); gSPDisplayList(POLY_XLU_DISP++, sMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, scroll * 8, scroll * 4, 64, 64, 1, scroll * 4, scroll * 4, 64, 64)); @@ -155,7 +155,7 @@ void OceffStorm_Draw2(Actor* thisx, GlobalContext* globalCtx) { void OceffStorm_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 scroll = globalCtx->state.frames & 0xFFF; - OceffStorm* this = (OceffStorm*)thisx; + OceffStorm* pthis = (OceffStorm*)thisx; Vtx* vtxPtr = sCylinderVtx; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_oceff_storm.c", 486); @@ -167,8 +167,8 @@ void OceffStorm_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); - vtxPtr[0].v.cn[3] = vtxPtr[6].v.cn[3] = vtxPtr[16].v.cn[3] = vtxPtr[25].v.cn[3] = this->vtxAlpha >> 1; - vtxPtr[10].v.cn[3] = vtxPtr[22].v.cn[3] = this->vtxAlpha; + vtxPtr[0].v.cn[3] = vtxPtr[6].v.cn[3] = vtxPtr[16].v.cn[3] = vtxPtr[25].v.cn[3] = pthis->vtxAlpha >> 1; + vtxPtr[10].v.cn[3] = vtxPtr[22].v.cn[3] = pthis->vtxAlpha; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_oceff_storm.c", 498), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -180,5 +180,5 @@ void OceffStorm_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_oceff_storm.c", 512); - OceffStorm_Draw2(&this->actor, globalCtx); + OceffStorm_Draw2(&pthis->actor, globalCtx); } diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.cpp similarity index 81% rename from src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c rename to src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.cpp index 859a3e388..1d649a5ac 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.cpp @@ -23,7 +23,7 @@ void OceffWipe_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Oceff_Wipe_InitVars = { +ActorInit Oceff_Wipe_InitVars = { ACTOR_OCEFF_WIPE, ACTORCAT_ITEMACTION, FLAGS, @@ -36,16 +36,16 @@ const ActorInit Oceff_Wipe_InitVars = { }; void OceffWipe_Init(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe* this = (OceffWipe*)thisx; + OceffWipe* pthis = (OceffWipe*)thisx; - Actor_SetScale(&this->actor, 0.1f); - this->timer = 0; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - osSyncPrintf(VT_FGCOL(CYAN) " WIPE arg_data = %d\n" VT_RST, this->actor.params); + Actor_SetScale(&pthis->actor, 0.1f); + pthis->timer = 0; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + osSyncPrintf(VT_FGCOL(CYAN) " WIPE arg_data = %d\n" VT_RST, pthis->actor.params); } void OceffWipe_Destroy(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe* this = (OceffWipe*)thisx; + OceffWipe* pthis = (OceffWipe*)thisx; Player* player = GET_PLAYER(globalCtx); func_800876C8(globalCtx); @@ -55,17 +55,17 @@ void OceffWipe_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void OceffWipe_Update(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe* this = (OceffWipe*)thisx; + OceffWipe* pthis = (OceffWipe*)thisx; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - if (this->timer < 100) { - this->timer++; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (pthis->timer < 100) { + pthis->timer++; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -#include "overlays/ovl_Oceff_Wipe/ovl_Oceff_Wipe.c" +#include "overlays/ovl_Oceff_Wipe/ovl_Oceff_Wipe.cpp" static u8 sAlphaIndices[] = { 0x01, 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x20, 0x12, 0x01, @@ -74,7 +74,7 @@ static u8 sAlphaIndices[] = { void OceffWipe_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 scroll = globalCtx->state.frames & 0xFF; - OceffWipe* this = (OceffWipe*)thisx; + OceffWipe* pthis = (OceffWipe*)thisx; f32 z; s32 pad; u8 alphaTable[3]; @@ -88,16 +88,16 @@ void OceffWipe_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_oceff_wipe.c", 346); - if (this->timer < 32) { - z = Math_SinS(this->timer << 9) * 1400; + if (pthis->timer < 32) { + z = Math_SinS(pthis->timer << 9) * 1400; } else { z = 1400; } - if (this->timer >= 80) { + if (pthis->timer >= 80) { alphaTable[0] = 0; - alphaTable[1] = (0x64 - this->timer) * 8; - alphaTable[2] = (0x64 - this->timer) * 12; + alphaTable[1] = (0x64 - pthis->timer) * 8; + alphaTable[2] = (0x64 - pthis->timer) * 12; } else { alphaTable[0] = 0; alphaTable[1] = 0xA0; @@ -120,7 +120,7 @@ void OceffWipe_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_oceff_wipe.c", 375), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->actor.params != OCEFF_WIPE_ZL) { + if (pthis->actor.params != OCEFF_WIPE_ZL) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 128); } else { diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.cpp similarity index 81% rename from src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c rename to src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.cpp index 437b31846..05dab6d9f 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.cpp @@ -23,7 +23,7 @@ void OceffWipe2_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe2_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe2_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Oceff_Wipe2_InitVars = { +ActorInit Oceff_Wipe2_InitVars = { ACTOR_OCEFF_WIPE2, ACTORCAT_ITEMACTION, FLAGS, @@ -36,16 +36,16 @@ const ActorInit Oceff_Wipe2_InitVars = { }; void OceffWipe2_Init(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe2* this = (OceffWipe2*)thisx; + OceffWipe2* pthis = (OceffWipe2*)thisx; - Actor_SetScale(&this->actor, 0.1f); - this->timer = 0; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - osSyncPrintf(VT_FGCOL(CYAN) " WIPE2 arg_data = %d\n" VT_RST, this->actor.params); + Actor_SetScale(&pthis->actor, 0.1f); + pthis->timer = 0; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + osSyncPrintf(VT_FGCOL(CYAN) " WIPE2 arg_data = %d\n" VT_RST, pthis->actor.params); } void OceffWipe2_Destroy(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe2* this = (OceffWipe2*)thisx; + OceffWipe2* pthis = (OceffWipe2*)thisx; Player* player = GET_PLAYER(globalCtx); func_800876C8(globalCtx); @@ -55,21 +55,21 @@ void OceffWipe2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void OceffWipe2_Update(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe2* this = (OceffWipe2*)thisx; + OceffWipe2* pthis = (OceffWipe2*)thisx; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - if (this->timer < 100) { - this->timer++; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (pthis->timer < 100) { + pthis->timer++; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -#include "overlays/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.c" +#include "overlays/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.cpp" void OceffWipe2_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 scroll = globalCtx->state.frames & 0xFF; - OceffWipe2* this = (OceffWipe2*)thisx; + OceffWipe2* pthis = (OceffWipe2*)thisx; f32 z; u8 alpha; s32 pad[2]; @@ -79,15 +79,15 @@ void OceffWipe2_Draw(Actor* thisx, GlobalContext* globalCtx) { eye = GET_ACTIVE_CAM(globalCtx)->eye; Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(globalCtx)); - if (this->timer < 32) { - z = Math_SinS(this->timer << 9) * 1330; + if (pthis->timer < 32) { + z = Math_SinS(pthis->timer << 9) * 1330; } else { z = 1330; } vtxPtr = sFrustumVtx; - if (this->timer >= 80) { - alpha = 12 * (100 - this->timer); + if (pthis->timer >= 80) { + alpha = 12 * (100 - pthis->timer); } else { alpha = 255; } diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.cpp similarity index 81% rename from src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c rename to src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.cpp index b2738e5c4..b46d4eb81 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.cpp @@ -23,7 +23,7 @@ void OceffWipe3_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe3_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe3_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Oceff_Wipe3_InitVars = { +ActorInit Oceff_Wipe3_InitVars = { ACTOR_OCEFF_WIPE3, ACTORCAT_ITEMACTION, FLAGS, @@ -35,20 +35,20 @@ const ActorInit Oceff_Wipe3_InitVars = { (ActorFunc)OceffWipe3_Draw, }; -#include "overlays/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.c" +#include "overlays/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.cpp" void OceffWipe3_Init(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe3* this = (OceffWipe3*)thisx; + OceffWipe3* pthis = (OceffWipe3*)thisx; - Actor_SetScale(&this->actor, 0.1f); - this->counter = 0; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + Actor_SetScale(&pthis->actor, 0.1f); + pthis->counter = 0; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; // it's actually WIPE3... - osSyncPrintf(VT_FGCOL(CYAN) " WIPE2 arg_data = %d\n" VT_RST, this->actor.params); + osSyncPrintf(VT_FGCOL(CYAN) " WIPE2 arg_data = %d\n" VT_RST, pthis->actor.params); } void OceffWipe3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe3* this = (OceffWipe3*)thisx; + OceffWipe3* pthis = (OceffWipe3*)thisx; Player* player = GET_PLAYER(globalCtx); func_800876C8(globalCtx); @@ -58,19 +58,19 @@ void OceffWipe3_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void OceffWipe3_Update(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe3* this = (OceffWipe3*)thisx; + OceffWipe3* pthis = (OceffWipe3*)thisx; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - if (this->counter < 100) { - this->counter++; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (pthis->counter < 100) { + pthis->counter++; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } void OceffWipe3_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 scroll = globalCtx->state.frames & 0xFFF; - OceffWipe3* this = (OceffWipe3*)thisx; + OceffWipe3* pthis = (OceffWipe3*)thisx; f32 z; u8 alpha; s32 pad[2]; @@ -80,15 +80,15 @@ void OceffWipe3_Draw(Actor* thisx, GlobalContext* globalCtx) { eye = GET_ACTIVE_CAM(globalCtx)->eye; Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(globalCtx)); - if (this->counter < 32) { - z = Math_SinS(this->counter << 9) * 1330; + if (pthis->counter < 32) { + z = Math_SinS(pthis->counter << 9) * 1330; } else { z = 1330; } vtxPtr = sFrustumVtx; - if (this->counter >= 80) { - alpha = 12 * (100 - this->counter); + if (pthis->counter >= 80) { + alpha = 12 * (100 - pthis->counter); } else { alpha = 255; } diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.cpp similarity index 79% rename from src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c rename to src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.cpp index a3fa9171a..fab9cfdf8 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.cpp @@ -22,7 +22,7 @@ void OceffWipe4_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe4_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe4_Draw(Actor* thisx, GlobalContext* globalCtx); -const ActorInit Oceff_Wipe4_InitVars = { +ActorInit Oceff_Wipe4_InitVars = { ACTOR_OCEFF_WIPE4, ACTORCAT_ITEMACTION, FLAGS, @@ -35,36 +35,36 @@ const ActorInit Oceff_Wipe4_InitVars = { }; void OceffWipe4_Init(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe4* this = (OceffWipe4*)thisx; + OceffWipe4* pthis = (OceffWipe4*)thisx; - Actor_SetScale(&this->actor, 0.1f); - this->timer = 0; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - osSyncPrintf(VT_FGCOL(CYAN) " WIPE4 arg_data = %d\n" VT_RST, this->actor.params); + Actor_SetScale(&pthis->actor, 0.1f); + pthis->timer = 0; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + osSyncPrintf(VT_FGCOL(CYAN) " WIPE4 arg_data = %d\n" VT_RST, pthis->actor.params); } void OceffWipe4_Destroy(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe4* this = (OceffWipe4*)thisx; + OceffWipe4* pthis = (OceffWipe4*)thisx; func_800876C8(globalCtx); } void OceffWipe4_Update(Actor* thisx, GlobalContext* globalCtx) { - OceffWipe4* this = (OceffWipe4*)thisx; + OceffWipe4* pthis = (OceffWipe4*)thisx; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; - if (this->timer < 50) { - this->timer++; + pthis->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (pthis->timer < 50) { + pthis->timer++; } else { - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -#include "overlays/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.c" +#include "overlays/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.cpp" void OceffWipe4_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 scroll = globalCtx->state.frames & 0xFFF; - OceffWipe4* this = (OceffWipe4*)thisx; + OceffWipe4* pthis = (OceffWipe4*)thisx; f32 z; u8 alpha; s32 pad[2]; @@ -74,15 +74,15 @@ void OceffWipe4_Draw(Actor* thisx, GlobalContext* globalCtx) { eye = GET_ACTIVE_CAM(globalCtx)->eye; Camera_GetSkyboxOffset(&vec, GET_ACTIVE_CAM(globalCtx)); - if (this->timer < 16) { - z = Math_SinS(this->timer * 1024) * 1330.0f; + if (pthis->timer < 16) { + z = Math_SinS(pthis->timer * 1024) * 1330.0f; } else { z = 1330.0f; } vtxPtr = sFrustumVtx; - if (this->timer >= 30) { - alpha = 12 * (50 - this->timer); + if (pthis->timer >= 30) { + alpha = 12 * (50 - pthis->timer); } else { alpha = 255; } @@ -103,7 +103,7 @@ void OceffWipe4_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_oceff_wipe4.c", 324), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->actor.params == OCEFF_WIPE4_UNUSED) { + if (pthis->actor.params == OCEFF_WIPE4_UNUSED) { gSPDisplayList(POLY_XLU_DISP++, sUnusedMaterialDL); } else { gSPDisplayList(POLY_XLU_DISP++, sMaterialDL); diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.cpp similarity index 59% rename from src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c rename to src/overlays/actors/ovl_Shot_Sun/z_shot_sun.cpp index f6e433cd8..45b414b54 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.cpp @@ -26,12 +26,12 @@ void ShotSun_Init(Actor* thisx, GlobalContext* globalCtx); void ShotSun_Destroy(Actor* thisx, GlobalContext* globalCtx); void ShotSun_Update(Actor* thisx, GlobalContext* globalCtx); -void ShotSun_SpawnFairy(ShotSun* this, GlobalContext* globalCtx); -void ShotSun_TriggerFairy(ShotSun* this, GlobalContext* globalCtx); -void func_80BADF0C(ShotSun* this, GlobalContext* globalCtx); -void ShotSun_UpdateHyliaSun(ShotSun* this, GlobalContext* globalCtx); +void ShotSun_SpawnFairy(ShotSun* pthis, GlobalContext* globalCtx); +void ShotSun_TriggerFairy(ShotSun* pthis, GlobalContext* globalCtx); +void func_80BADF0C(ShotSun* pthis, GlobalContext* globalCtx); +void ShotSun_UpdateHyliaSun(ShotSun* pthis, GlobalContext* globalCtx); -const ActorInit Shot_Sun_InitVars = { +ActorInit Shot_Sun_InitVars = { ACTOR_SHOT_SUN, ACTORCAT_PROP, FLAGS, @@ -64,41 +64,41 @@ static ColliderCylinderInit sCylinderInit = { }; void ShotSun_Init(Actor* thisx, GlobalContext* globalCtx) { - ShotSun* this = (ShotSun*)thisx; + ShotSun* pthis = (ShotSun*)thisx; s32 params; // "Ocarina secret occurrence" - osSyncPrintf("%d ---- オカリナの秘密発生!!!!!!!!!!!!!\n", this->actor.params); - params = this->actor.params & 0xFF; + osSyncPrintf("%d ---- オカリナの秘密発生!!!!!!!!!!!!!\n", pthis->actor.params); + params = pthis->actor.params & 0xFF; if (params == 0x40 || params == 0x41) { - this->unk_1A4 = 0; - this->actor.flags |= ACTOR_FLAG_4; - this->actor.flags |= ACTOR_FLAG_25; - this->actionFunc = func_80BADF0C; - this->actor.flags |= ACTOR_FLAG_27; + pthis->unk_1A4 = 0; + pthis->actor.flags |= ACTOR_FLAG_4; + pthis->actor.flags |= ACTOR_FLAG_25; + pthis->actionFunc = func_80BADF0C; + pthis->actor.flags |= ACTOR_FLAG_27; } else { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actionFunc = ShotSun_UpdateHyliaSun; - this->actor.flags &= ~ACTOR_FLAG_0; + Collider_InitCylinder(globalCtx, &pthis->collider); + Collider_SetCylinder(globalCtx, &pthis->collider, &pthis->actor, &sCylinderInit); + pthis->actionFunc = ShotSun_UpdateHyliaSun; + pthis->actor.flags &= ~ACTOR_FLAG_0; } } void ShotSun_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ShotSun* this = (ShotSun*)thisx; - s32 params = this->actor.params & 0xFF; + ShotSun* pthis = (ShotSun*)thisx; + s32 params = pthis->actor.params & 0xFF; if (params != 0x40 && params != 0x41) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(globalCtx, &pthis->collider); } } -void ShotSun_SpawnFairy(ShotSun* this, GlobalContext* globalCtx) { - s32 params = this->actor.params & 0xFF; +void ShotSun_SpawnFairy(ShotSun* pthis, GlobalContext* globalCtx) { + s32 params = pthis->actor.params & 0xFF; s32 fairyType; - if (this->timer > 0) { - this->timer--; + if (pthis->timer > 0) { + pthis->timer--; } else { switch (params) { case 0x40: @@ -110,66 +110,66 @@ void ShotSun_SpawnFairy(ShotSun* this, GlobalContext* globalCtx) { } //! @bug fairyType may be uninitialized - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.home.pos.x, this->actor.home.pos.y, - this->actor.home.pos.z, 0, 0, 0, fairyType); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pthis->actor.home.pos.x, pthis->actor.home.pos.y, + pthis->actor.home.pos.z, 0, 0, 0, fairyType); - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } } -void ShotSun_TriggerFairy(ShotSun* this, GlobalContext* globalCtx) { - if ((func_8005B198() == this->actor.category) || (this->timer != 0)) { - this->actionFunc = ShotSun_SpawnFairy; - this->timer = 50; +void ShotSun_TriggerFairy(ShotSun* pthis, GlobalContext* globalCtx) { + if ((func_8005B198() == pthis->actor.category) || (pthis->timer != 0)) { + pthis->actionFunc = ShotSun_SpawnFairy; + pthis->timer = 50; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, this->actor.home.pos.x, this->actor.home.pos.y, - this->actor.home.pos.z, 0, 0, 0, 0x11); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, pthis->actor.home.pos.x, pthis->actor.home.pos.y, + pthis->actor.home.pos.z, 0, 0, 0, 0x11); - func_80078914(&this->actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); + func_80078914(&pthis->actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); } } -void func_80BADF0C(ShotSun* this, GlobalContext* globalCtx) { +void func_80BADF0C(ShotSun* pthis, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; - s32 params = this->actor.params & 0xFF; + s32 params = pthis->actor.params & 0xFF; - if (Math3D_Vec3fDistSq(&this->actor.world.pos, &player->actor.world.pos) > 22500.0f) { - this->unk_1A4 = 0; + if (Math3D_Vec3fDistSq(&pthis->actor.world.pos, &player->actor.world.pos) > 22500.0f) { + pthis->unk_1A4 = 0; } else { - if (this->unk_1A4 == 0) { + if (pthis->unk_1A4 == 0) { if (!(player->stateFlags2 & 0x1000000)) { player->stateFlags2 |= 0x800000; return; } else { - this->unk_1A4 = 1; + pthis->unk_1A4 = 1; } } - if (this->unk_1A4 == 1) { + if (pthis->unk_1A4 == 1) { func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); - this->unk_1A4 = 2; - } else if (this->unk_1A4 == 2 && globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + pthis->unk_1A4 = 2; + } else if (pthis->unk_1A4 == 2 && globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { if ((params == 0x40 && globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) || (params == 0x41 && globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS)) { - this->actionFunc = ShotSun_TriggerFairy; - OnePointCutscene_Attention(globalCtx, &this->actor); - this->timer = 0; + pthis->actionFunc = ShotSun_TriggerFairy; + OnePointCutscene_Attention(globalCtx, &pthis->actor); + pthis->timer = 0; } else { - this->unk_1A4 = 0; + pthis->unk_1A4 = 0; } - this->unk_1A4 = 0; + pthis->unk_1A4 = 0; } } } -void ShotSun_UpdateHyliaSun(ShotSun* this, GlobalContext* globalCtx) { +void ShotSun_UpdateHyliaSun(ShotSun* pthis, GlobalContext* globalCtx) { Vec3s cylinderPos; Player* player = GET_PLAYER(globalCtx); EnItem00* collectible; s32 pad; Vec3f spawnPos; - if (this->collider.base.acFlags & AC_HIT) { + if (pthis->collider.base.acFlags & AC_HIT) { func_80078884(NA_SE_SY_CORRECT_CHIME); osSyncPrintf(VT_FGCOL(CYAN) "SHOT_SUN HIT!!!!!!!\n" VT_RST); if (INV_CONTENT(ITEM_ARROW_FIRE) == ITEM_NONE) { @@ -188,23 +188,23 @@ void ShotSun_UpdateHyliaSun(ShotSun* this, GlobalContext* globalCtx) { collectible->actor.speedXZ = 0.0f; } } - Actor_Kill(&this->actor); + Actor_Kill(&pthis->actor); } else { - if (!(this->actor.xzDistToPlayer > 120.0f) && gSaveContext.dayTime >= 0x4555 && gSaveContext.dayTime < 0x5000) { + if (!(pthis->actor.xzDistToPlayer > 120.0f) && gSaveContext.dayTime >= 0x4555 && gSaveContext.dayTime < 0x5000) { cylinderPos.x = player->bodyPartsPos[7].x + globalCtx->envCtx.sunPos.x * (1.0f / 6.0f); cylinderPos.y = player->bodyPartsPos[7].y - 30.0f + globalCtx->envCtx.sunPos.y * (1.0f / 6.0f); cylinderPos.z = player->bodyPartsPos[7].z + globalCtx->envCtx.sunPos.z * (1.0f / 6.0f); - this->hitboxPos = cylinderPos; + pthis->hitboxPos = cylinderPos; - Collider_SetCylinderPosition(&this->collider, &cylinderPos); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Collider_SetCylinderPosition(&pthis->collider, &cylinderPos); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->collider.base); } } } void ShotSun_Update(Actor* thisx, GlobalContext* globalCtx) { - ShotSun* this = (ShotSun*)thisx; + ShotSun* pthis = (ShotSun*)thisx; - this->actionFunc(this, globalCtx); + pthis->actionFunc(pthis, globalCtx); } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c deleted file mode 100644 index 1725c4329..000000000 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ /dev/null @@ -1,14224 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_PLAYER_ACTOR_Z_PLAYER_C -#include "actor_common.h" -#include -#include "z_player.h" -#include "z_scene_table.h" -#include "hack.h" -extern u8 gPlayerModelTypes[][5]; -extern FlexSkeletonHeader* gPlayerSkelHeaders[2]; -extern u8 gPlayerModelTypes[][5]; -extern Gfx* D_80125DE8[]; -extern Gfx* D_80125E08[]; -extern Gfx* D_80125E18[]; -extern Gfx* D_80125EF8[]; -extern Gfx gCullBackDList[]; -extern Gfx gCullFrontDList[]; - -/* - * File: z_player.c - * Overlay: ovl_player_actor - * Description: Link - */ - -#include "ultra64.h" -#include "global.h" - -#include "overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.h" -#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" -#include "overlays/actors/ovl_En_Boom/z_en_boom.h" -#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#include "overlays/actors/ovl_En_Box/z_en_box.h" -#include "overlays/actors/ovl_En_Door/z_en_door.h" -#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#include "overlays/actors/ovl_En_Fish/z_en_fish.h" -#include "overlays/actors/ovl_En_Horse/z_en_horse.h" -#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_link_child/object_link_child.h" -#include "def/code_80043480.h" -#include "def/code_80097A00.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800FD970.h" -#include "def/createmesgqueue.h" -#include "def/graph.h" -#include "def/shrink_window.h" -#include "def/sys_math3d.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_bgcheck.h" -#include "def/z_camera.h" -#include "def/z_collision_check.h" -#include "def/z_common_data.h" -#include "def/z_debug.h" -#include "def/z_effect.h" -#include "def/z_effect_soft_sprite_old_init.h" -#include "def/z_en_item00.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_lifemeter.h" -#include "def/z_malloc.h" -#include "def/z_map_exp.h" -#include "def/z_message_PAL.h" -#include "def/z_onepointdemo.h" -#include "def/z_parameter.h" -#include "def/z_play.h" -#include "def/z_player_lib.h" -#include "def/z_quake.h" -#include "def/z_rcp.h" -#include "def/z_room.h" -#include "def/z_scene.h" -#include "def/z_scene_table.h" -#include "def/z_skelanime.h" -#include "def/z_skin_matrix.h" -#include "def/z_std_dma.h" - -typedef struct { - /* 0x00 */ u8 itemId; - /* 0x01 */ u8 field; // various bit-packed data - /* 0x02 */ s8 gi; // defines the draw id and chest opening animation - /* 0x03 */ u8 textId; - /* 0x04 */ u16 objectId; -} GetItemEntry; // size = 0x06 - -#define GET_ITEM(itemId, objectId, drawId, textId, field, chestAnim) \ - { itemId, field, (chestAnim != 0 ? 1 : -1) * (drawId + 1), textId, objectId } - -#define CHEST_ANIM_SHORT 0 -#define CHEST_ANIM_LONG 1 - -#define GET_ITEM_NONE \ - { ITEM_NONE, 0, 0, 0, 0 } - -typedef enum { - /* 0x00 */ KNOB_ANIM_ADULT_L, - /* 0x01 */ KNOB_ANIM_CHILD_L, - /* 0x02 */ KNOB_ANIM_ADULT_R, - /* 0x03 */ KNOB_ANIM_CHILD_R -} KnobDoorAnim; - -typedef struct { - /* 0x00 */ u8 itemId; - /* 0x02 */ s16 actorId; -} ExplosiveInfo; // size = 0x04 - -typedef struct { - /* 0x00 */ s16 actorId; - /* 0x02 */ u8 itemId; - /* 0x03 */ u8 actionParam; - /* 0x04 */ u8 textId; -} BottleCatchInfo; // size = 0x06 - -typedef struct { - /* 0x00 */ s16 actorId; - /* 0x02 */ s16 actorParams; -} BottleDropInfo; // size = 0x04 - -typedef struct { - /* 0x00 */ s8 damage; - /* 0x01 */ u8 unk_01; - /* 0x02 */ u8 unk_02; - /* 0x03 */ u8 unk_03; - /* 0x04 */ u16 sfxId; -} FallImpactInfo; // size = 0x06 - -typedef struct { - /* 0x00 */ Vec3f pos; - /* 0x0C */ s16 yaw; -} SpecialRespawnInfo; // size = 0x10 - -typedef struct { - /* 0x00 */ u16 sfxId; - /* 0x02 */ s16 field; -} struct_80832924; // size = 0x04 - -typedef struct { - /* 0x00 */ u16 unk_00; - /* 0x02 */ s16 unk_02; -} struct_808551A4; // size = 0x04 - -typedef struct { - /* 0x00 */ LinkAnimationHeader* anim; - /* 0x04 */ u8 unk_04; -} struct_808540F4; // size = 0x08 - -typedef struct { - /* 0x00 */ LinkAnimationHeader* unk_00; - /* 0x04 */ LinkAnimationHeader* unk_04; - /* 0x08 */ u8 unk_08; - /* 0x09 */ u8 unk_09; -} struct_80854554; // size = 0x0C - -typedef struct { - /* 0x00 */ LinkAnimationHeader* unk_00; - /* 0x04 */ LinkAnimationHeader* unk_04; - /* 0x08 */ LinkAnimationHeader* unk_08; - /* 0x0C */ u8 unk_0C; - /* 0x0D */ u8 unk_0D; -} struct_80854190; // size = 0x10 - -typedef struct { - /* 0x00 */ LinkAnimationHeader* anim; - /* 0x04 */ f32 unk_04; - /* 0x04 */ f32 unk_08; -} struct_80854578; // size = 0x0C - -typedef struct { - /* 0x00 */ s8 type; - /* 0x04 */ union { - void* ptr; - void (*func)(GlobalContext*, Player*, CsCmdActorAction*); - }; -} struct_80854B18; // size = 0x08 - -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; - /* 0x04 */ s16 unk_04; - /* 0x06 */ s16 unk_06; - /* 0x08 */ s16 unk_08; -} struct_80858AC8; // size = 0x0A - -void func_80833770(GlobalContext* globalCtx, Player* this); -void func_80833790(GlobalContext* globalCtx, Player* this); -void func_8083379C(GlobalContext* globalCtx, Player* this); -void func_8083377C(GlobalContext* globalCtx, Player* this); -void func_808337D4(GlobalContext* globalCtx, Player* this); -void func_80833910(GlobalContext* globalCtx, Player* this); -void func_80833984(GlobalContext* globalCtx, Player* this); -void func_8083399C(GlobalContext* globalCtx, Player* this, s8 actionParam); -s32 func_8083485C(Player* this, GlobalContext* globalCtx); -s32 func_808349DC(Player* this, GlobalContext* globalCtx); -s32 func_80834A2C(Player* this, GlobalContext* globalCtx); -s32 func_80834B5C(Player* this, GlobalContext* globalCtx); -s32 func_80834C74(Player* this, GlobalContext* globalCtx); -s32 func_8083501C(Player* this, GlobalContext* globalCtx); -s32 func_808351D4(Player* this, GlobalContext* globalCtx); -s32 func_808353D8(Player* this, GlobalContext* globalCtx); -s32 func_80835588(Player* this, GlobalContext* globalCtx); -s32 func_808356E8(Player* this, GlobalContext* globalCtx); -s32 func_80835800(Player* this, GlobalContext* globalCtx); -s32 func_80835884(Player* this, GlobalContext* globalCtx); -s32 func_808358F0(Player* this, GlobalContext* globalCtx); -s32 func_808359FC(Player* this, GlobalContext* globalCtx); -s32 func_80835B60(Player* this, GlobalContext* globalCtx); -s32 func_80835C08(Player* this, GlobalContext* globalCtx); -void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item); -void func_80839F90(Player* this, GlobalContext* globalCtx); -s32 func_80838A14(Player* this, GlobalContext* globalCtx); -s32 func_80839800(Player* this, GlobalContext* globalCtx); -s32 func_8083B040(Player* this, GlobalContext* globalCtx); -s32 func_8083B998(Player* this, GlobalContext* globalCtx); -s32 func_8083B644(Player* this, GlobalContext* globalCtx); -s32 func_8083BDBC(Player* this, GlobalContext* globalCtx); -s32 func_8083C1DC(Player* this, GlobalContext* globalCtx); -s32 func_8083C2B0(Player* this, GlobalContext* globalCtx); -s32 func_8083C544(Player* this, GlobalContext* globalCtx); -s32 func_8083C61C(GlobalContext* globalCtx, Player* this); -void func_8083CA20(GlobalContext* globalCtx, Player* this); -void func_8083CA54(GlobalContext* globalCtx, Player* this); -void func_8083CA9C(GlobalContext* globalCtx, Player* this); -s32 func_8083E0FC(Player* this, GlobalContext* globalCtx); -s32 func_8083E5A8(Player* this, GlobalContext* globalCtx); -s32 func_8083EB44(Player* this, GlobalContext* globalCtx); -s32 func_8083F7BC(Player* this, GlobalContext* globalCtx); -void func_80840450(Player* this, GlobalContext* globalCtx); -void func_808407CC(Player* this, GlobalContext* globalCtx); -void func_80840BC8(Player* this, GlobalContext* globalCtx); -void func_80840DE4(Player* this, GlobalContext* globalCtx); -void func_808414F8(Player* this, GlobalContext* globalCtx); -void func_8084170C(Player* this, GlobalContext* globalCtx); -void func_808417FC(Player* this, GlobalContext* globalCtx); -void func_8084193C(Player* this, GlobalContext* globalCtx); -void func_80841BA8(Player* this, GlobalContext* globalCtx); -void func_80842180(Player* this, GlobalContext* globalCtx); -void func_8084227C(Player* this, GlobalContext* globalCtx); -void func_8084279C(Player* this, GlobalContext* globalCtx); -void func_808423EC(Player* this, GlobalContext* globalCtx); -void func_8084251C(Player* this, GlobalContext* globalCtx); -void func_80843188(Player* this, GlobalContext* globalCtx); -void func_808435C4(Player* this, GlobalContext* globalCtx); -void func_8084370C(Player* this, GlobalContext* globalCtx); -void func_8084377C(Player* this, GlobalContext* globalCtx); -void func_80843954(Player* this, GlobalContext* globalCtx); -void func_80843A38(Player* this, GlobalContext* globalCtx); -void func_80843CEC(Player* this, GlobalContext* globalCtx); -void func_8084411C(Player* this, GlobalContext* globalCtx); -void func_80844708(Player* this, GlobalContext* globalCtx); -void func_80844A44(Player* this, GlobalContext* globalCtx); -void func_80844AF4(Player* this, GlobalContext* globalCtx); -void func_80844E68(Player* this, GlobalContext* globalCtx); -void func_80845000(Player* this, GlobalContext* globalCtx); -void func_80845308(Player* this, GlobalContext* globalCtx); -void func_80845668(Player* this, GlobalContext* globalCtx); -void func_808458D0(Player* this, GlobalContext* globalCtx); -void func_80845CA4(Player* this, GlobalContext* globalCtx); -void func_80845EF8(Player* this, GlobalContext* globalCtx); -void func_80846050(Player* this, GlobalContext* globalCtx); -void func_80846120(Player* this, GlobalContext* globalCtx); -void func_80846260(Player* this, GlobalContext* globalCtx); -void func_80846358(Player* this, GlobalContext* globalCtx); -void func_80846408(Player* this, GlobalContext* globalCtx); -void func_808464B0(Player* this, GlobalContext* globalCtx); -void func_80846578(Player* this, GlobalContext* globalCtx); -void func_80846648(GlobalContext* globalCtx, Player* this); -void func_80846660(GlobalContext* globalCtx, Player* this); -void func_808467D4(GlobalContext* globalCtx, Player* this); -void func_808468A8(GlobalContext* globalCtx, Player* this); -void func_808468E8(GlobalContext* globalCtx, Player* this); -void func_80846978(GlobalContext* globalCtx, Player* this); -void func_808469BC(GlobalContext* globalCtx, Player* this); -void func_80846A68(GlobalContext* globalCtx, Player* this); -void func_8084B1D8(Player* this, GlobalContext* globalCtx); -void func_8084B530(Player* this, GlobalContext* globalCtx); -void func_8084B78C(Player* this, GlobalContext* globalCtx); -void func_8084B898(Player* this, GlobalContext* globalCtx); -void func_8084B9E4(Player* this, GlobalContext* globalCtx); -void func_8084BBE4(Player* this, GlobalContext* globalCtx); -void func_8084BDFC(Player* this, GlobalContext* globalCtx); -void func_8084BF1C(Player* this, GlobalContext* globalCtx); -void Player_UpdateCommon(Player* this, GlobalContext* globalCtx, Input* input); -void func_8084C5F8(Player* this, GlobalContext* globalCtx); -void func_8084C760(Player* this, GlobalContext* globalCtx); -void func_8084C81C(Player* this, GlobalContext* globalCtx); -void func_8084CC98(Player* this, GlobalContext* globalCtx); -void func_8084D3E4(Player* this, GlobalContext* globalCtx); -void func_8084D610(Player* this, GlobalContext* globalCtx); -void func_8084D7C4(Player* this, GlobalContext* globalCtx); -void func_8084D84C(Player* this, GlobalContext* globalCtx); -void func_8084DAB4(Player* this, GlobalContext* globalCtx); -void func_8084DC48(Player* this, GlobalContext* globalCtx); -void func_8084E1EC(Player* this, GlobalContext* globalCtx); -void func_8084E30C(Player* this, GlobalContext* globalCtx); -void func_8084E368(Player* this, GlobalContext* globalCtx); -void func_8084E3C4(Player* this, GlobalContext* globalCtx); -void func_8084E604(Player* this, GlobalContext* globalCtx); -void func_8084E6D4(Player* this, GlobalContext* globalCtx); -void func_8084E9AC(Player* this, GlobalContext* globalCtx); -void func_8084EAC0(Player* this, GlobalContext* globalCtx); -void func_8084ECA4(Player* this, GlobalContext* globalCtx); -void func_8084EED8(Player* this, GlobalContext* globalCtx); -void func_8084EFC0(Player* this, GlobalContext* globalCtx); -void func_8084F104(Player* this, GlobalContext* globalCtx); -void func_8084F390(Player* this, GlobalContext* globalCtx); -void func_8084F608(Player* this, GlobalContext* globalCtx); -void func_8084F698(Player* this, GlobalContext* globalCtx); -void func_8084F710(Player* this, GlobalContext* globalCtx); -void func_8084F88C(Player* this, GlobalContext* globalCtx); -void func_8084F9A0(Player* this, GlobalContext* globalCtx); -void func_8084F9C0(Player* this, GlobalContext* globalCtx); -void func_8084FA54(Player* this, GlobalContext* globalCtx); -void func_8084FB10(Player* this, GlobalContext* globalCtx); -void func_8084FBF4(Player* this, GlobalContext* globalCtx); -s32 func_8084FCAC(Player* this, GlobalContext* globalCtx); -void func_8084FF7C(Player* this); -void func_8085002C(Player* this); -s32 func_80850224(Player* this, GlobalContext* globalCtx); -void func_808502D0(Player* this, GlobalContext* globalCtx); -void func_808505DC(Player* this, GlobalContext* globalCtx); -void func_8085063C(Player* this, GlobalContext* globalCtx); -void func_8085076C(Player* this, GlobalContext* globalCtx); -void func_808507F4(Player* this, GlobalContext* globalCtx); -void func_80850AEC(Player* this, GlobalContext* globalCtx); -void func_80850C68(Player* this, GlobalContext* globalCtx); -void func_80850E84(Player* this, GlobalContext* globalCtx); -void func_80851008(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851030(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851050(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851094(GlobalContext* globalCtx, Player* this, void* anim); -void func_808510B4(GlobalContext* globalCtx, Player* this, void* anim); -void func_808510D4(GlobalContext* globalCtx, Player* this, void* anim); -void func_808510F4(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851114(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851134(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851154(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851174(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851194(GlobalContext* globalCtx, Player* this, void* anim); -void func_808511B4(GlobalContext* globalCtx, Player* this, void* anim); -void func_808511D4(GlobalContext* globalCtx, Player* this, void* anim); -void func_808511FC(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851248(GlobalContext* globalCtx, Player* this, void* anim); -void func_80851294(GlobalContext* globalCtx, Player* this, void* anim); -void func_808512E0(GlobalContext* globalCtx, Player* this, void* arg2); -void func_80851368(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808513BC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808514C0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_8085157C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808515A4(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851688(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851750(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851788(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851828(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808518DC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_8085190C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851998(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808519C0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808519EC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851A50(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851B90(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851BE8(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851CA4(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851D2C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851D80(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851DEC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851E28(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851E64(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851E90(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851ECC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851F84(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80851FB0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852048(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852080(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852174(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808521B8(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808521F4(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852234(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_8085225C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852280(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852358(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852388(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852298(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852328(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852480(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852450(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808524B0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808524D0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852514(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852544(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852554(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852564(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808525C0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852608(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852648(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808526EC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_8085283C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808528C8(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852944(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_808529D0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852C50(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2); -void func_80852E14(Player* this, GlobalContext* globalCtx); -s32 Player_IsDroppingFish(GlobalContext* globalCtx); -s32 Player_StartFishing(GlobalContext* globalCtx); -s32 func_80852F38(GlobalContext* globalCtx, Player* this); -s32 func_80852FFC(GlobalContext* globalCtx, Actor* actor, s32 csMode); -void func_80853080(Player* this, GlobalContext* globalCtx); -s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage); -void func_80853148(GlobalContext* globalCtx, Actor* actor); - -// .bss part 1 -static s32 D_80858AA0; -static s32 D_80858AA4; -static Vec3f D_80858AA8; -static Input* sControlInput; - -// .data - -static u8 D_80853410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - -static PlayerAgeProperties sAgeProperties[] = { - { - 56.0f, - 90.0f, - 1.0f, - 111.0f, - 70.0f, - 79.4f, - 59.0f, - 41.0f, - 19.0f, - 36.0f, - 44.8f, - 56.0f, - 68.0f, - 70.0f, - 18.0f, - 15.0f, - 70.0f, - { 9, 4671, 359 }, - { - { 8, 4694, 380 }, - { 9, 6122, 359 }, - { 8, 4694, 380 }, - { 9, 6122, 359 }, - }, - { - { 9, 6122, 359 }, - { 9, 7693, 380 }, - { 9, 6122, 359 }, - { 9, 7693, 380 }, - }, - { - { 8, 4694, 380 }, - { 9, 6122, 359 }, - }, - { - { -1592, 4694, 380 }, - { -1591, 6122, 359 }, - }, - 0, - 0x80, - &gPlayerAnim_002718, - &gPlayerAnim_002720, - &gPlayerAnim_002838, - &gPlayerAnim_002E70, - &gPlayerAnim_002E78, - { &gPlayerAnim_002E80, &gPlayerAnim_002E88, &gPlayerAnim_002D90, &gPlayerAnim_002D98 }, - { &gPlayerAnim_002D70, &gPlayerAnim_002D78 }, - { &gPlayerAnim_002E50, &gPlayerAnim_002E58 }, - { &gPlayerAnim_002E68, &gPlayerAnim_002E60 }, - }, - { - 40.0f, - 60.0f, - 11.0f / 17.0f, - 71.0f, - 50.0f, - 47.0f, - 39.0f, - 27.0f, - 19.0f, - 22.0f, - 29.6f, - 32.0f, - 48.0f, - 70.0f * (11.0f / 17.0f), - 14.0f, - 12.0f, - 55.0f, - { -24, 3565, 876 }, - { - { -24, 3474, 862 }, - { -24, 4977, 937 }, - { 8, 4694, 380 }, - { 9, 6122, 359 }, - }, - { - { -24, 4977, 937 }, - { -24, 6495, 937 }, - { 9, 6122, 359 }, - { 9, 7693, 380 }, - }, - { - { 8, 4694, 380 }, - { 9, 6122, 359 }, - }, - { - { -1592, 4694, 380 }, - { -1591, 6122, 359 }, - }, - 0x20, - 0, - &gPlayerAnim_002318, - &gPlayerAnim_002360, - &gPlayerAnim_0023A8, - &gPlayerAnim_0023E0, - &gPlayerAnim_0023E8, - { &gPlayerAnim_0023F0, &gPlayerAnim_0023F8, &gPlayerAnim_002D90, &gPlayerAnim_002D98 }, - { &gPlayerAnim_002D70, &gPlayerAnim_002D78 }, - { &gPlayerAnim_0023C0, &gPlayerAnim_0023C8 }, - { &gPlayerAnim_0023D8, &gPlayerAnim_0023D0 }, - }, -}; - -static u32 D_808535D0 = false; -static f32 D_808535D4 = 0.0f; -static s16 D_808535D8 = 0; -static s16 D_808535DC = 0; -static s32 D_808535E0 = 0; -static s32 D_808535E4 = 0; -static f32 D_808535E8 = 1.0f; -static f32 D_808535EC = 1.0f; -static u32 D_808535F0 = 0; -static u32 D_808535F4 = 0; -static s16 D_808535F8 = 0; -static s16 D_808535FC = 0; -static f32 D_80853600 = 0.0f; -static s32 D_80853604 = 0; -static s32 D_80853608 = 0; -static s32 D_8085360C = 0; -static s16 D_80853610 = 0; -static s32 D_80853614 = 0; -static s32 D_80853618 = 0; - -static u16 D_8085361C[] = { - NA_SE_VO_LI_SWEAT, - NA_SE_VO_LI_SNEEZE, - NA_SE_VO_LI_RELAX, - NA_SE_VO_LI_FALL_L, -}; - -static GetItemEntry sGetItemTable[] = { - GET_ITEM(ITEM_BOMBS_5, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMBCHU, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOW, OBJECT_GI_BOW, GID_BOW, 0x31, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SLINGSHOT, OBJECT_GI_PACHINKO, GID_SLINGSHOT, 0x30, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOOMERANG, OBJECT_GI_BOOMERANG, GID_BOOMERANG, 0x35, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_STICK, OBJECT_GI_STICK, GID_STICK, 0x37, 0x0D, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_HOOKSHOT, OBJECT_GI_HOOKSHOT, GID_HOOKSHOT, 0x36, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_LONGSHOT, OBJECT_GI_HOOKSHOT, GID_LONGSHOT, 0x4F, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_LENS, OBJECT_GI_GLASSES, GID_LENS, 0x39, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_LETTER_ZELDA, OBJECT_GI_LETTER, GID_LETTER_ZELDA, 0x69, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_OCARINA_TIME, OBJECT_GI_OCARINA, GID_OCARINA_TIME, 0x3A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_HAMMER, OBJECT_GI_HAMMER, GID_HAMMER, 0x38, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_COJIRO, OBJECT_GI_NIWATORI, GID_COJIRO, 0x02, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x42, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_POTION_RED, OBJECT_GI_LIQUID, GID_POTION_RED, 0x43, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_POTION_GREEN, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0x44, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_POTION_BLUE, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0x45, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x46, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MILK_BOTTLE, OBJECT_GI_MILK, GID_MILK, 0x98, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_LETTER_RUTO, OBJECT_GI_BOTTLE_LETTER, GID_LETTER_RUTO, 0x99, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BEAN, OBJECT_GI_BEAN, GID_BEAN, 0x48, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_MASK_SKULL, OBJECT_GI_SKJ_MASK, GID_MASK_SKULL, 0x10, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_SPOOKY, OBJECT_GI_REDEAD_MASK, GID_MASK_SPOOKY, 0x11, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_CHICKEN, OBJECT_GI_NIWATORI, GID_CHICKEN, 0x48, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_KEATON, OBJECT_GI_KI_TAN_MASK, GID_MASK_KEATON, 0x12, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_BUNNY, OBJECT_GI_RABIT_MASK, GID_MASK_BUNNY, 0x13, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_TRUTH, OBJECT_GI_TRUTH_MASK, GID_MASK_TRUTH, 0x17, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_POCKET_EGG, OBJECT_GI_EGG, GID_EGG, 0x01, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_POCKET_CUCCO, OBJECT_GI_NIWATORI, GID_CHICKEN, 0x48, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_ODD_MUSHROOM, OBJECT_GI_MUSHROOM, GID_ODD_MUSHROOM, 0x03, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_ODD_POTION, OBJECT_GI_POWDER, GID_ODD_POTION, 0x04, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SAW, OBJECT_GI_SAW, GID_SAW, 0x05, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SWORD_BROKEN, OBJECT_GI_BROKENSWORD, GID_SWORD_BROKEN, 0x08, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_PRESCRIPTION, OBJECT_GI_PRESCRIPTION, GID_PRESCRIPTION, 0x09, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_FROG, OBJECT_GI_FROG, GID_FROG, 0x0D, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_EYEDROPS, OBJECT_GI_EYE_LOTION, GID_EYEDROPS, 0x0E, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_CLAIM_CHECK, OBJECT_GI_TICKETSTONE, GID_CLAIM_CHECK, 0x0A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SWORD_KOKIRI, OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, 0xA4, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x4B, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SHIELD_DEKU, OBJECT_GI_SHIELD_1, GID_SHIELD_DEKU, 0x4C, 0xA0, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_SHIELD_HYLIAN, OBJECT_GI_SHIELD_2, GID_SHIELD_HYLIAN, 0x4D, 0xA0, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_SHIELD_MIRROR, OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, 0x4E, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_TUNIC_GORON, OBJECT_GI_CLOTHES, GID_TUNIC_GORON, 0x50, 0xA0, CHEST_ANIM_LONG), - GET_ITEM(ITEM_TUNIC_ZORA, OBJECT_GI_CLOTHES, GID_TUNIC_ZORA, 0x51, 0xA0, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOOTS_IRON, OBJECT_GI_BOOTS_2, GID_BOOTS_IRON, 0x53, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOOTS_HOVER, OBJECT_GI_HOVERBOOTS, GID_BOOTS_HOVER, 0x54, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_QUIVER_40, OBJECT_GI_ARROWCASE, GID_QUIVER_40, 0x56, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_QUIVER_50, OBJECT_GI_ARROWCASE, GID_QUIVER_50, 0x57, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOMB_BAG_20, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, 0x58, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOMB_BAG_30, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, 0x59, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOMB_BAG_40, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, 0x5A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_GAUNTLETS_SILVER, OBJECT_GI_GLOVES, GID_GAUNTLETS_SILVER, 0x5B, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_GAUNTLETS_GOLD, OBJECT_GI_GLOVES, GID_GAUNTLETS_GOLD, 0x5C, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SCALE_SILVER, OBJECT_GI_SCALE, GID_SCALE_SILVER, 0xCD, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SCALE_GOLDEN, OBJECT_GI_SCALE, GID_SCALE_GOLDEN, 0xCE, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_STONE_OF_AGONY, OBJECT_GI_MAP, GID_STONE_OF_AGONY, 0x68, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_GERUDO_CARD, OBJECT_GI_GERUDO, GID_GERUDO_CARD, 0x7B, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_OCARINA_FAIRY, OBJECT_GI_OCARINA_0, GID_OCARINA_FAIRY, 0x3A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SEEDS, OBJECT_GI_SEED, GID_SEEDS, 0xDC, 0x50, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_HEART_CONTAINER, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xC6, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_HEART_PIECE_2, OBJECT_GI_HEARTS, GID_HEART_PIECE, 0xC2, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_KEY_BOSS, OBJECT_GI_BOSSKEY, GID_KEY_BOSS, 0xC7, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_COMPASS, OBJECT_GI_COMPASS, GID_COMPASS, 0x67, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_DUNGEON_MAP, OBJECT_GI_MAP, GID_DUNGEON_MAP, 0x66, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_KEY_SMALL, OBJECT_GI_KEY, GID_KEY_SMALL, 0x60, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_MAGIC_SMALL, OBJECT_GI_MAGICPOT, GID_MAGIC_SMALL, 0x52, 0x6F, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_MAGIC_LARGE, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0x52, 0x6E, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_WALLET_ADULT, OBJECT_GI_PURSE, GID_WALLET_ADULT, 0x5E, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_WALLET_GIANT, OBJECT_GI_PURSE, GID_WALLET_GIANT, 0x5F, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_WEIRD_EGG, OBJECT_GI_EGG, GID_EGG, 0x9A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_HEART, OBJECT_GI_HEART, GID_HEART, 0x55, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_ARROWS_SMALL, OBJECT_GI_ARROW, GID_ARROWS_SMALL, 0xE6, 0x48, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_ARROWS_MEDIUM, OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, 0xE6, 0x49, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_ARROWS_LARGE, OBJECT_GI_ARROW, GID_ARROWS_LARGE, 0xE6, 0x4A, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_GREEN, OBJECT_GI_RUPY, GID_RUPEE_GREEN, 0x6F, 0x00, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_BLUE, OBJECT_GI_RUPY, GID_RUPEE_BLUE, 0xCC, 0x01, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_RED, OBJECT_GI_RUPY, GID_RUPEE_RED, 0xF0, 0x02, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_HEART_CONTAINER, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xC6, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MILK, OBJECT_GI_MILK, GID_MILK, 0x98, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_GORON, OBJECT_GI_GOLONMASK, GID_MASK_GORON, 0x14, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_ZORA, OBJECT_GI_ZORAMASK, GID_MASK_ZORA, 0x15, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_MASK_GERUDO, OBJECT_GI_GERUDOMASK, GID_MASK_GERUDO, 0x16, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BRACELET, OBJECT_GI_BRACELET, GID_BRACELET, 0x79, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_RUPEE_PURPLE, OBJECT_GI_RUPY, GID_RUPEE_PURPLE, 0xF1, 0x14, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_GOLD, OBJECT_GI_RUPY, GID_RUPEE_GOLD, 0xF2, 0x13, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x0C, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_ARROW_FIRE, OBJECT_GI_M_ARROW, GID_ARROW_FIRE, 0x70, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_ARROW_ICE, OBJECT_GI_M_ARROW, GID_ARROW_ICE, 0x71, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_ARROW_LIGHT, OBJECT_GI_M_ARROW, GID_ARROW_LIGHT, 0x72, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_SKULL_TOKEN, OBJECT_GI_SUTARU, GID_SKULL_TOKEN, 0xB4, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_DINS_FIRE, OBJECT_GI_GODDESS, GID_DINS_FIRE, 0xAD, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_FARORES_WIND, OBJECT_GI_GODDESS, GID_FARORES_WIND, 0xAE, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_NAYRUS_LOVE, OBJECT_GI_GODDESS, GID_NAYRUS_LOVE, 0xAF, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BULLET_BAG_30, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG, 0x07, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BULLET_BAG_40, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG, 0x07, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_STICKS_5, OBJECT_GI_STICK, GID_STICK, 0x37, 0x0D, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_STICKS_10, OBJECT_GI_STICK, GID_STICK, 0x37, 0x0D, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_NUTS_10, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMB, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMBS_10, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMBS_20, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMBS_30, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_SEEDS_30, OBJECT_GI_SEED, GID_SEEDS, 0xDC, 0x50, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMBCHUS_5, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BOMBCHUS_20, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_FISH, OBJECT_GI_FISH, GID_FISH, 0x47, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BUG, OBJECT_GI_INSECT, GID_BUG, 0x7A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0x5D, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_POE, OBJECT_GI_GHOST, GID_POE, 0x97, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF9, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_KEY_SMALL, OBJECT_GI_KEY, GID_KEY_SMALL, 0xF3, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_GREEN, OBJECT_GI_RUPY, GID_RUPEE_GREEN, 0xF4, 0x00, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_BLUE, OBJECT_GI_RUPY, GID_RUPEE_BLUE, 0xF5, 0x01, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_RED, OBJECT_GI_RUPY, GID_RUPEE_RED, 0xF6, 0x02, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_RUPEE_PURPLE, OBJECT_GI_RUPY, GID_RUPEE_PURPLE, 0xF7, 0x14, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_HEART_PIECE_2, OBJECT_GI_HEARTS, GID_HEART_PIECE, 0xFA, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_STICK_UPGRADE_20, OBJECT_GI_STICK, GID_STICK, 0x90, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_STICK_UPGRADE_30, OBJECT_GI_STICK, GID_STICK, 0x91, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_NUT_UPGRADE_30, OBJECT_GI_NUTS, GID_NUTS, 0xA7, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_NUT_UPGRADE_40, OBJECT_GI_NUTS, GID_NUTS, 0xA8, 0x80, CHEST_ANIM_SHORT), - GET_ITEM(ITEM_BULLET_BAG_50, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG_50, 0x6C, 0x80, CHEST_ANIM_LONG), - GET_ITEM_NONE, - GET_ITEM_NONE, -}; - -static LinkAnimationHeader* D_80853914[] = { - &gPlayerAnim_003240, &gPlayerAnim_003238, &gPlayerAnim_003238, - &gPlayerAnim_002BE0, &gPlayerAnim_003240, &gPlayerAnim_003240, -}; - -static LinkAnimationHeader* D_8085392C[] = { - &gPlayerAnim_003290, &gPlayerAnim_003268, &gPlayerAnim_003268, - &gPlayerAnim_002BF8, &gPlayerAnim_003290, &gPlayerAnim_003290, -}; - -static LinkAnimationHeader* D_80853944[] = { - &gPlayerAnim_003140, &gPlayerAnim_002B38, &gPlayerAnim_003138, - &gPlayerAnim_002B40, &gPlayerAnim_003140, &gPlayerAnim_003140, -}; - -static LinkAnimationHeader* D_8085395C[] = { - &gPlayerAnim_002E98, &gPlayerAnim_0029E8, &gPlayerAnim_002E98, - &gPlayerAnim_0029F0, &gPlayerAnim_002E98, &gPlayerAnim_002E98, -}; - -static LinkAnimationHeader* D_80853974[] = { - &gPlayerAnim_002FB0, &gPlayerAnim_002FA8, &gPlayerAnim_002FB0, - &gPlayerAnim_002A40, &gPlayerAnim_002FB0, &gPlayerAnim_002FB0, -}; - -static LinkAnimationHeader* D_8085398C[] = { - &gPlayerAnim_003220, &gPlayerAnim_002590, &gPlayerAnim_002590, - &gPlayerAnim_002BC0, &gPlayerAnim_003220, &gPlayerAnim_003220, -}; - -static LinkAnimationHeader* D_808539A4[] = { - &gPlayerAnim_003230, &gPlayerAnim_0025D0, &gPlayerAnim_0025D0, - &gPlayerAnim_002BD0, &gPlayerAnim_003230, &gPlayerAnim_003230, -}; - -static LinkAnimationHeader* D_808539BC[] = { - &gPlayerAnim_002BB0, &gPlayerAnim_0031F8, &gPlayerAnim_0031F8, - &gPlayerAnim_002BB0, &gPlayerAnim_002BB0, &gPlayerAnim_002BB0, -}; - -static LinkAnimationHeader* D_808539D4[] = { - &gPlayerAnim_003088, &gPlayerAnim_002A70, &gPlayerAnim_002A70, - &gPlayerAnim_003088, &gPlayerAnim_003088, &gPlayerAnim_003088, -}; - -static LinkAnimationHeader* D_808539EC[] = { - &gPlayerAnim_002750, &gPlayerAnim_002748, &gPlayerAnim_002748, - &gPlayerAnim_002750, &gPlayerAnim_002750, &gPlayerAnim_002750, -}; - -static LinkAnimationHeader* D_80853A04[] = { - &gPlayerAnim_002330, &gPlayerAnim_002330, &gPlayerAnim_002330, - &gPlayerAnim_002330, &gPlayerAnim_002330, &gPlayerAnim_002330, -}; - -static LinkAnimationHeader* D_80853A1C[] = { - &gPlayerAnim_002760, &gPlayerAnim_002758, &gPlayerAnim_002758, - &gPlayerAnim_002760, &gPlayerAnim_002760, &gPlayerAnim_002760, -}; - -static LinkAnimationHeader* D_80853A34[] = { - &gPlayerAnim_002338, &gPlayerAnim_002338, &gPlayerAnim_002338, - &gPlayerAnim_002338, &gPlayerAnim_002338, &gPlayerAnim_002338, -}; - -static LinkAnimationHeader* D_80853A4C[] = { - &gPlayerAnim_002E08, &gPlayerAnim_002E00, &gPlayerAnim_002E00, - &gPlayerAnim_002E08, &gPlayerAnim_002E08, &gPlayerAnim_002E08, -}; - -static LinkAnimationHeader* D_80853A64[] = { - &gPlayerAnim_003028, &gPlayerAnim_003020, &gPlayerAnim_003020, - &gPlayerAnim_003028, &gPlayerAnim_003028, &gPlayerAnim_003028, -}; - -static LinkAnimationHeader* D_80853A7C[] = { - &gPlayerAnim_003170, &gPlayerAnim_003168, &gPlayerAnim_003168, - &gPlayerAnim_003170, &gPlayerAnim_003170, &gPlayerAnim_003170, -}; - -static LinkAnimationHeader* D_80853A94[] = { - &gPlayerAnim_003038, &gPlayerAnim_003030, &gPlayerAnim_003030, - &gPlayerAnim_002A68, &gPlayerAnim_003038, &gPlayerAnim_003038, -}; - -static LinkAnimationHeader* D_80853AAC[] = { - &gPlayerAnim_002FC0, &gPlayerAnim_002FB8, &gPlayerAnim_002FB8, - &gPlayerAnim_002FC8, &gPlayerAnim_002FC0, &gPlayerAnim_002FC0, -}; - -static LinkAnimationHeader* D_80853AC4[] = { - &gPlayerAnim_003278, &gPlayerAnim_003270, &gPlayerAnim_003270, - &gPlayerAnim_002BE8, &gPlayerAnim_003278, &gPlayerAnim_003278, -}; - -static LinkAnimationHeader* D_80853ADC[] = { - &gPlayerAnim_003288, &gPlayerAnim_003280, &gPlayerAnim_003280, - &gPlayerAnim_002BF0, &gPlayerAnim_003288, &gPlayerAnim_003288, -}; - -static LinkAnimationHeader* D_80853AF4[] = { - &gPlayerAnim_002EB8, &gPlayerAnim_002EA0, &gPlayerAnim_002EA0, - &gPlayerAnim_002EB8, &gPlayerAnim_0026C8, &gPlayerAnim_002EB8, -}; - -static LinkAnimationHeader* D_80853B0C[] = { - &gPlayerAnim_002ED8, &gPlayerAnim_002ED0, &gPlayerAnim_002ED0, - &gPlayerAnim_002ED8, &gPlayerAnim_0026D0, &gPlayerAnim_002ED8, -}; - -static LinkAnimationHeader* D_80853B24[] = { - &gPlayerAnim_002EB0, &gPlayerAnim_002EA8, &gPlayerAnim_002EA8, - &gPlayerAnim_002EB0, &gPlayerAnim_002EB0, &gPlayerAnim_002EB0, -}; - -static LinkAnimationHeader* D_80853B3C[] = { - &gPlayerAnim_003190, &gPlayerAnim_003188, &gPlayerAnim_003188, - &gPlayerAnim_002B68, &gPlayerAnim_003190, &gPlayerAnim_003190, -}; - -static LinkAnimationHeader* D_80853B54[] = { - &gPlayerAnim_003178, &gPlayerAnim_002568, &gPlayerAnim_002568, - &gPlayerAnim_002B58, &gPlayerAnim_003178, &gPlayerAnim_003178, -}; - -static LinkAnimationHeader* D_80853B6C[] = { - &gPlayerAnim_003180, &gPlayerAnim_002570, &gPlayerAnim_002570, - &gPlayerAnim_002B60, &gPlayerAnim_003180, &gPlayerAnim_003180, -}; - -static LinkAnimationHeader* D_80853B84[] = { - &gPlayerAnim_002D60, &gPlayerAnim_002D58, &gPlayerAnim_002D58, - &gPlayerAnim_002D60, &gPlayerAnim_002D60, &gPlayerAnim_002D60, -}; - -static LinkAnimationHeader* D_80853B9C[] = { - &gPlayerAnim_002BB8, &gPlayerAnim_003218, &gPlayerAnim_003218, - &gPlayerAnim_002BB8, &gPlayerAnim_002BB8, &gPlayerAnim_002BB8, -}; - -static LinkAnimationHeader* D_80853BB4[] = { - &gPlayerAnim_002BC8, &gPlayerAnim_003228, &gPlayerAnim_003228, - &gPlayerAnim_002BC8, &gPlayerAnim_002BC8, &gPlayerAnim_002BC8, -}; - -static LinkAnimationHeader* D_80853BCC[] = { - &gPlayerAnim_0031C8, &gPlayerAnim_0031C0, &gPlayerAnim_0031C0, - &gPlayerAnim_0031C8, &gPlayerAnim_0031C8, &gPlayerAnim_0031C8, -}; - -static LinkAnimationHeader* D_80853BE4[] = { - &gPlayerAnim_003118, &gPlayerAnim_003110, &gPlayerAnim_003110, - &gPlayerAnim_003118, &gPlayerAnim_003118, &gPlayerAnim_003118, -}; - -static LinkAnimationHeader* D_80853BFC[] = { - &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, - &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, -}; - -static LinkAnimationHeader* D_80853C14[] = { - &gPlayerAnim_002E30, &gPlayerAnim_002E18, &gPlayerAnim_002E18, - &gPlayerAnim_002E30, &gPlayerAnim_002E30, &gPlayerAnim_002E30, -}; - -static LinkAnimationHeader* D_80853C2C[] = { - &gPlayerAnim_002E40, &gPlayerAnim_002E38, &gPlayerAnim_002E38, - &gPlayerAnim_002E40, &gPlayerAnim_002E40, &gPlayerAnim_002E40, -}; - -static LinkAnimationHeader* D_80853C44[] = { - &gPlayerAnim_002E28, &gPlayerAnim_002E20, &gPlayerAnim_002E20, - &gPlayerAnim_002E28, &gPlayerAnim_002E28, &gPlayerAnim_002E28, -}; - -static LinkAnimationHeader* D_80853C5C[] = { - &gPlayerAnim_0030C8, &gPlayerAnim_0030C0, &gPlayerAnim_0030C0, - &gPlayerAnim_0030C8, &gPlayerAnim_0030C8, &gPlayerAnim_0030C8, -}; - -static LinkAnimationHeader* D_80853C74[] = { - &gPlayerAnim_0030D8, &gPlayerAnim_0030D0, &gPlayerAnim_0030D0, - &gPlayerAnim_0030D8, &gPlayerAnim_0030D8, &gPlayerAnim_0030D8, -}; - -static LinkAnimationHeader* D_80853C8C[] = { - &gPlayerAnim_0030B8, &gPlayerAnim_0030B0, &gPlayerAnim_0030B0, - &gPlayerAnim_0030B8, &gPlayerAnim_0030B8, &gPlayerAnim_0030B8, -}; - -static LinkAnimationHeader* D_80853CA4[] = { - &gPlayerAnim_002F20, &gPlayerAnim_002F18, &gPlayerAnim_002F18, - &gPlayerAnim_002F20, &gPlayerAnim_002F20, &gPlayerAnim_002F20, -}; - -static LinkAnimationHeader* D_80853CBC[] = { - &gPlayerAnim_002FF0, &gPlayerAnim_002FE8, &gPlayerAnim_002FE8, - &gPlayerAnim_002FF0, &gPlayerAnim_002FF0, &gPlayerAnim_002FF0, -}; - -static LinkAnimationHeader* D_80853CD4[] = { - &gPlayerAnim_003010, &gPlayerAnim_003008, &gPlayerAnim_003008, - &gPlayerAnim_003010, &gPlayerAnim_003010, &gPlayerAnim_003010, -}; - -static LinkAnimationHeader* D_80853CEC[] = { - &gPlayerAnim_003000, &gPlayerAnim_002FF8, &gPlayerAnim_002FF8, - &gPlayerAnim_003000, &gPlayerAnim_003000, &gPlayerAnim_003000, -}; - -static LinkAnimationHeader* D_80853D04[] = { - &gPlayerAnim_002EF0, &gPlayerAnim_002EE8, &gPlayerAnim_002EE8, - &gPlayerAnim_002EF8, &gPlayerAnim_002EF0, &gPlayerAnim_002EF0, -}; - -static LinkAnimationHeader* D_80853D1C[] = { - &gPlayerAnim_0031E0, &gPlayerAnim_0031D8, &gPlayerAnim_0031D8, - &gPlayerAnim_0031E8, &gPlayerAnim_0031E0, &gPlayerAnim_0031E0, -}; - -static LinkAnimationHeader* D_80853D34[] = { - &gPlayerAnim_003468, &gPlayerAnim_003438, &gPlayerAnim_003438, - &gPlayerAnim_003468, &gPlayerAnim_003468, &gPlayerAnim_003468, -}; - -static LinkAnimationHeader* D_80853D4C[][3] = { - { &gPlayerAnim_002A28, &gPlayerAnim_002A38, &gPlayerAnim_002A30 }, - { &gPlayerAnim_002950, &gPlayerAnim_002960, &gPlayerAnim_002958 }, - { &gPlayerAnim_0029D0, &gPlayerAnim_0029E0, &gPlayerAnim_0029D8 }, - { &gPlayerAnim_002988, &gPlayerAnim_002998, &gPlayerAnim_002990 }, -}; - -static LinkAnimationHeader* D_80853D7C[][2] = { - { &gPlayerAnim_003248, &gPlayerAnim_003200 }, { &gPlayerAnim_003258, &gPlayerAnim_003210 }, - { &gPlayerAnim_003250, &gPlayerAnim_003208 }, { &gPlayerAnim_003250, &gPlayerAnim_003208 }, - { &gPlayerAnim_003430, &gPlayerAnim_0033F0 }, { &gPlayerAnim_003430, &gPlayerAnim_0033F0 }, - { &gPlayerAnim_003430, &gPlayerAnim_0033F0 }, { &gPlayerAnim_0033F8, &gPlayerAnim_0033D0 }, - { &gPlayerAnim_003400, &gPlayerAnim_0033D8 }, { &gPlayerAnim_003420, &gPlayerAnim_003420 }, - { &gPlayerAnim_003408, &gPlayerAnim_0033E0 }, { &gPlayerAnim_003410, &gPlayerAnim_0033E8 }, - { &gPlayerAnim_003418, &gPlayerAnim_003418 }, { &gPlayerAnim_003428, &gPlayerAnim_003428 } -}; - -static LinkAnimationHeader** AnimHeaderLut[] = { - D_80853914,D_8085392C,D_80853944,D_8085395C,D_80853974,D_8085398C,D_808539A4,D_808539BC, - D_808539D4,D_808539EC,D_80853A04,D_80853A1C,D_80853A34,D_80853A4C,D_80853A64,D_80853A7C, - D_80853A94,D_80853AAC,D_80853AC4,D_80853ADC,D_80853AF4,D_80853B0C,D_80853B24,D_80853B3C, - D_80853B54,D_80853B6C,D_80853B84,D_80853B9C,D_80853BB4,D_80853BCC,D_80853BE4,D_80853BFC, - D_80853C14,D_80853C2C,D_80853C44,D_80853C5C,D_80853C74,D_80853C8C,D_80853CA4,D_80853CBC, - D_80853CD4,D_80853CEC,D_80853D04,D_80853D1C,D_80853D34,D_80853D4C,D_80853D7C, -}; - -static struct_80832924 D_80853DEC[] = { - { NA_SE_VO_LI_SNEEZE, -0x2008 }, -}; - -static struct_80832924 D_80853DF0[] = { - { NA_SE_VO_LI_SWEAT, -0x2012 }, -}; - -static struct_80832924 D_80853DF4[] = { - { NA_SE_VO_LI_BREATH_REST, -0x200D }, -}; - -static struct_80832924 D_80853DF8[] = { - { NA_SE_VO_LI_BREATH_REST, -0x200A }, -}; - -static struct_80832924 D_80853DFC[] = { - { NA_SE_PL_CALM_HIT, 0x82C }, { NA_SE_PL_CALM_HIT, 0x830 }, { NA_SE_PL_CALM_HIT, 0x834 }, - { NA_SE_PL_CALM_HIT, 0x838 }, { NA_SE_PL_CALM_HIT, -0x83C }, -}; - -static struct_80832924 D_80853E10[] = { - { 0, 0x4019 }, { 0, 0x401E }, { 0, 0x402C }, { 0, 0x4030 }, { 0, 0x4034 }, { 0, -0x4038 }, -}; - -static struct_80832924 D_80853E28[] = { - { NA_SE_IT_SHIELD_POSTURE, 0x810 }, - { NA_SE_IT_SHIELD_POSTURE, 0x814 }, - { NA_SE_IT_SHIELD_POSTURE, -0x846 }, -}; - -static struct_80832924 D_80853E34[] = { - { NA_SE_IT_HAMMER_SWING, 0x80A }, - { NA_SE_VO_LI_AUTO_JUMP, 0x200A }, - { NA_SE_IT_SWORD_SWING, 0x816 }, - { NA_SE_VO_LI_SWORD_N, -0x2016 }, -}; - -static struct_80832924 D_80853E44[] = { - { NA_SE_IT_SWORD_SWING, 0x827 }, - { NA_SE_VO_LI_SWORD_N, -0x2027 }, -}; - -static struct_80832924 D_80853E4C[] = { - { NA_SE_VO_LI_RELAX, -0x2014 }, -}; - -static struct_80832924* D_80853E50[] = { - D_80853DEC, D_80853DF0, D_80853DF4, D_80853DF8, D_80853DFC, D_80853E10, - D_80853E28, D_80853E34, D_80853E44, D_80853E4C, NULL, -}; - -static u8 D_80853E7C[] = { - 0, 0, 1, 1, 2, 2, 2, 2, 10, 10, 10, 10, 10, 10, 3, 3, 4, 4, 8, 8, 5, 5, 6, 6, 7, 7, 9, 9, 0, -}; - -// Used to map item IDs to action params -static s8 sItemActionParams[] = { - PLAYER_AP_STICK, - PLAYER_AP_NUT, - PLAYER_AP_BOMB, - PLAYER_AP_BOW, - PLAYER_AP_BOW_FIRE, - PLAYER_AP_DINS_FIRE, - PLAYER_AP_SLINGSHOT, - PLAYER_AP_OCARINA_FAIRY, - PLAYER_AP_OCARINA_TIME, - PLAYER_AP_BOMBCHU, - PLAYER_AP_HOOKSHOT, - PLAYER_AP_LONGSHOT, - PLAYER_AP_BOW_ICE, - PLAYER_AP_FARORES_WIND, - PLAYER_AP_BOOMERANG, - PLAYER_AP_LENS, - PLAYER_AP_BEAN, - PLAYER_AP_HAMMER, - PLAYER_AP_BOW_LIGHT, - PLAYER_AP_NAYRUS_LOVE, - PLAYER_AP_BOTTLE, - PLAYER_AP_BOTTLE_POTION_RED, - PLAYER_AP_BOTTLE_POTION_GREEN, - PLAYER_AP_BOTTLE_POTION_BLUE, - PLAYER_AP_BOTTLE_FAIRY, - PLAYER_AP_BOTTLE_FISH, - PLAYER_AP_BOTTLE_MILK, - PLAYER_AP_BOTTLE_LETTER, - PLAYER_AP_BOTTLE_FIRE, - PLAYER_AP_BOTTLE_BUG, - PLAYER_AP_BOTTLE_BIG_POE, - PLAYER_AP_BOTTLE_MILK_HALF, - PLAYER_AP_BOTTLE_POE, - PLAYER_AP_WEIRD_EGG, - PLAYER_AP_CHICKEN, - PLAYER_AP_LETTER_ZELDA, - PLAYER_AP_MASK_KEATON, - PLAYER_AP_MASK_SKULL, - PLAYER_AP_MASK_SPOOKY, - PLAYER_AP_MASK_BUNNY, - PLAYER_AP_MASK_GORON, - PLAYER_AP_MASK_ZORA, - PLAYER_AP_MASK_GERUDO, - PLAYER_AP_MASK_TRUTH, - PLAYER_AP_SWORD_MASTER, - PLAYER_AP_POCKET_EGG, - PLAYER_AP_POCKET_CUCCO, - PLAYER_AP_COJIRO, - PLAYER_AP_ODD_MUSHROOM, - PLAYER_AP_ODD_POTION, - PLAYER_AP_SAW, - PLAYER_AP_SWORD_BROKEN, - PLAYER_AP_PRESCRIPTION, - PLAYER_AP_FROG, - PLAYER_AP_EYEDROPS, - PLAYER_AP_CLAIM_CHECK, - PLAYER_AP_BOW_FIRE, - PLAYER_AP_BOW_ICE, - PLAYER_AP_BOW_LIGHT, - PLAYER_AP_SWORD_KOKIRI, - PLAYER_AP_SWORD_MASTER, - PLAYER_AP_SWORD_BGS, -}; - -static s32 (*D_80853EDC[])(Player* this, GlobalContext* globalCtx) = { - func_8083485C, func_8083485C, func_8083485C, func_808349DC, func_808349DC, func_808349DC, func_8083485C, - func_8083485C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, - func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_808356E8, func_808356E8, func_80835800, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, - func_8083485C, func_8083485C, func_8083485C, func_8083485C, -}; - -static void (*D_80853FE8[])(GlobalContext* globalCtx, Player* this) = { - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_8083377C, - func_80833790, func_8083379C, func_8083379C, func_8083379C, func_8083379C, func_8083379C, func_8083379C, - func_8083379C, func_8083379C, func_80833910, func_80833910, func_808337D4, func_808337D4, func_80833984, - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, - func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, - func_80833770, func_80833770, func_80833770, func_80833770, -}; - -static struct_808540F4 D_808540F4[] = { - { &gPlayerAnim_002F50, 12 }, { &gPlayerAnim_003080, 6 }, { &gPlayerAnim_002C68, 8 }, { &gPlayerAnim_003090, 8 }, - { &gPlayerAnim_002A20, 8 }, { &gPlayerAnim_002F30, 10 }, { &gPlayerAnim_002C58, 7 }, { &gPlayerAnim_002C60, 11 }, - { &gPlayerAnim_002F50, 12 }, { &gPlayerAnim_003078, 4 }, { &gPlayerAnim_003058, 4 }, { &gPlayerAnim_002F38, 4 }, - { &gPlayerAnim_0024E0, 5 }, { &gPlayerAnim_002F48, 13 }, -}; - -static s8 D_80854164[][6] = { - { 8, -5, -3, -6, 8, 11 }, { 5, 0, -1, 4, 5, 9 }, { 3, 1, 0, 2, 3, 9 }, - { 6, -4, -2, 7, 6, 10 }, { 8, -5, -3, -6, 8, 11 }, { 8, -5, -3, -6, 8, 11 }, -}; - -static ExplosiveInfo sExplosiveInfos[] = { - { ITEM_BOMB, ACTOR_EN_BOM }, - { ITEM_BOMBCHU, ACTOR_EN_BOM_CHU }, -}; - -static struct_80854190 D_80854190[] = { - { &gPlayerAnim_002A80, &gPlayerAnim_002A90, &gPlayerAnim_002A88, 1, 4 }, - { &gPlayerAnim_0028C0, &gPlayerAnim_0028C8, &gPlayerAnim_002498, 1, 4 }, - { &gPlayerAnim_002A98, &gPlayerAnim_002AA0, &gPlayerAnim_002540, 0, 5 }, - { &gPlayerAnim_0028D0, &gPlayerAnim_0028D8, &gPlayerAnim_0024A0, 1, 7 }, - { &gPlayerAnim_002968, &gPlayerAnim_002970, &gPlayerAnim_0024C0, 1, 4 }, - { &gPlayerAnim_002880, &gPlayerAnim_002888, &gPlayerAnim_002478, 0, 5 }, - { &gPlayerAnim_002978, &gPlayerAnim_002980, &gPlayerAnim_0024C8, 2, 8 }, - { &gPlayerAnim_002890, &gPlayerAnim_002898, &gPlayerAnim_002480, 3, 8 }, - { &gPlayerAnim_0029A0, &gPlayerAnim_0029A8, &gPlayerAnim_0024D0, 0, 4 }, - { &gPlayerAnim_0028A0, &gPlayerAnim_0028A8, &gPlayerAnim_002488, 0, 5 }, - { &gPlayerAnim_0029B0, &gPlayerAnim_0029B8, &gPlayerAnim_0024D8, 0, 6 }, - { &gPlayerAnim_0028B0, &gPlayerAnim_0028B8, &gPlayerAnim_002490, 1, 5 }, - { &gPlayerAnim_002AA8, &gPlayerAnim_002AB0, &gPlayerAnim_002548, 0, 3 }, - { &gPlayerAnim_0028E0, &gPlayerAnim_0028E8, &gPlayerAnim_0024A8, 0, 3 }, - { &gPlayerAnim_002AB8, &gPlayerAnim_002AC0, &gPlayerAnim_002550, 1, 9 }, - { &gPlayerAnim_0028F0, &gPlayerAnim_0028F8, &gPlayerAnim_0024B0, 1, 8 }, - { &gPlayerAnim_002A60, &gPlayerAnim_002A50, &gPlayerAnim_002A50, 1, 10 }, - { &gPlayerAnim_002900, &gPlayerAnim_002910, &gPlayerAnim_002910, 1, 11 }, - { &gPlayerAnim_002A50, &gPlayerAnim_002A58, &gPlayerAnim_002A58, 1, 2 }, - { &gPlayerAnim_002910, &gPlayerAnim_002908, &gPlayerAnim_002908, 1, 2 }, - { &gPlayerAnim_002B80, &gPlayerAnim_002B88, &gPlayerAnim_002B88, 1, 5 }, - { &gPlayerAnim_002B70, &gPlayerAnim_002B78, &gPlayerAnim_002B78, 1, 4 }, - { &gPlayerAnim_002C40, &gPlayerAnim_002C50, &gPlayerAnim_002C48, 3, 10 }, - { &gPlayerAnim_002C70, &gPlayerAnim_002C80, &gPlayerAnim_002C78, 2, 11 }, - { &gPlayerAnim_002B28, &gPlayerAnim_002B30, &gPlayerAnim_002560, 0, 12 }, - { &gPlayerAnim_002940, &gPlayerAnim_002948, &gPlayerAnim_0024B8, 0, 15 }, - { &gPlayerAnim_0029C0, &gPlayerAnim_0029C8, &gPlayerAnim_002560, 0, 16 }, - { &gPlayerAnim_0029C0, &gPlayerAnim_0029C8, &gPlayerAnim_0024B8, 0, 16 }, -}; - -static LinkAnimationHeader* D_80854350[] = { - &gPlayerAnim_002AE8, - &gPlayerAnim_002920, -}; - -static LinkAnimationHeader* D_80854358[] = { - &gPlayerAnim_002AE0, - &gPlayerAnim_002920, -}; - -static LinkAnimationHeader* D_80854360[] = { - &gPlayerAnim_002AF0, - &gPlayerAnim_002928, -}; - -static LinkAnimationHeader* D_80854368[] = { - &gPlayerAnim_002AF8, - &gPlayerAnim_002930, -}; - -static LinkAnimationHeader* D_80854370[] = { - &gPlayerAnim_002B00, - &gPlayerAnim_002938, -}; - -static LinkAnimationHeader* D_80854378[] = { - &gPlayerAnim_002AD8, - &gPlayerAnim_002918, -}; - -static u8 D_80854380[2] = { 0x18, 0x19 }; -static u8 D_80854384[2] = { 0x1A, 0x1B }; - -static u16 D_80854388[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; - -static u8 sMagicSpellCosts[] = { 12, 24, 24, 12, 24, 12 }; - -static u16 D_80854398[] = { NA_SE_IT_BOW_DRAW, NA_SE_IT_SLING_DRAW, NA_SE_IT_HOOKSHOT_READY }; - -static u8 sMagicArrowCosts[] = { 4, 4, 8 }; - -static LinkAnimationHeader* D_808543A4[] = { - &gPlayerAnim_0025C0, - &gPlayerAnim_0025C8, -}; - -static LinkAnimationHeader* D_808543AC[] = { - &gPlayerAnim_002580, - &gPlayerAnim_002588, -}; - -static LinkAnimationHeader* D_808543B4[] = { - &gPlayerAnim_002510, - &gPlayerAnim_002518, -}; - -static LinkAnimationHeader* D_808543BC[] = { - &gPlayerAnim_002510, - &gPlayerAnim_002520, -}; - -static LinkAnimationHeader* D_808543C4[] = { - &gPlayerAnim_002EC0, - &gPlayerAnim_002A08, -}; - -static LinkAnimationHeader* D_808543CC[] = { - &gPlayerAnim_0026F0, - &gPlayerAnim_002CC8, -}; - -static LinkAnimationHeader* D_808543D4[] = { - &gPlayerAnim_0026C0, - &gPlayerAnim_002CC0, -}; - -// return type can't be void due to regalloc in func_8084FCAC -s32 func_80832210(Player* this) { - this->actor.speedXZ = 0.0f; - this->linearVelocity = 0.0f; - return 0; -} - -// return type can't be void due to regalloc in func_8083F72C -s32 func_80832224(Player* this) { - func_80832210(this); - this->unk_6AD = 0; - return 0; -} - -s32 func_8083224C(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); - - return CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_8); -} - -void func_80832264(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime, anim); -} - -void func_80832284(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_PlayLoop(globalCtx, &this->skelAnime, anim); -} - -void func_808322A4(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_PlayLoopSetSpeed(globalCtx, &this->skelAnime, anim, 2.0f / 3.0f); -} - -void func_808322D0(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, anim, 2.0f / 3.0f); -} - -void func_808322FC(Player* this) { - this->actor.shape.rot.y += this->skelAnime.jointTable[1].y; - this->skelAnime.jointTable[1].y = 0; -} - -void func_80832318(Player* this) { - this->stateFlags2 &= ~0x20000; - this->swordState = 0; - this->swordInfo[0].active = this->swordInfo[1].active = this->swordInfo[2].active = 0; -} - -void func_80832340(GlobalContext* globalCtx, Player* this) { - Camera* camera; - - if (this->unk_46C != SUBCAM_NONE) { - camera = globalCtx->cameraPtrs[this->unk_46C]; - if ((camera != NULL) && (camera->csId == 1100)) { - OnePointCutscene_EndCutscene(globalCtx, this->unk_46C); - this->unk_46C = SUBCAM_NONE; - } - } - - this->stateFlags2 &= ~0xC00; -} - -void func_808323B4(GlobalContext* globalCtx, Player* this) { - Actor* heldActor = this->heldActor; - - if ((heldActor != NULL) && !Player_HoldsHookshot(this)) { - this->actor.child = NULL; - this->heldActor = NULL; - this->interactRangeActor = NULL; - heldActor->parent = NULL; - this->stateFlags1 &= ~0x800; - } - - if (Player_GetExplosiveHeld(this) >= 0) { - func_8083399C(globalCtx, this, PLAYER_AP_NONE); - this->heldItemId = ITEM_NONE_FE; - } -} - -void func_80832440(GlobalContext* globalCtx, Player* this) { - if ((this->stateFlags1 & 0x800) && (this->heldActor == NULL)) { - if (this->interactRangeActor != NULL) { - if (this->getItemId == GI_NONE) { - this->stateFlags1 &= ~0x800; - this->interactRangeActor = NULL; - } - } else { - this->stateFlags1 &= ~0x800; - } - } - - func_80832318(this); - this->unk_6AD = 0; - - func_80832340(globalCtx, this); - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - - this->stateFlags1 &= ~0x306000; - this->stateFlags2 &= ~0x40090; - - this->actor.shape.rot.x = 0; - this->actor.shape.yOffset = 0.0f; - - this->unk_845 = this->unk_844 = 0; -} - -s32 func_80832528(GlobalContext* globalCtx, Player* this) { - if (this->heldItemActionParam >= PLAYER_AP_FISHING_POLE) { - func_80835F44(globalCtx, this, ITEM_NONE); - return 1; - } else { - return 0; - } -} - -void func_80832564(GlobalContext* globalCtx, Player* this) { - func_80832440(globalCtx, this); - func_808323B4(globalCtx, this); -} - -s32 func_80832594(Player* this, s32 arg1, s32 arg2) { - s16 temp = this->unk_A80 - D_808535D8; - - this->unk_850 += arg1 + (s16)(ABS(temp) * fabsf(D_808535D4) * 2.5415802156203426e-06f); - - if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B)) { - this->unk_850 += 5; - } - - return this->unk_850 > arg2; -} - -void func_80832630(GlobalContext* globalCtx) { - if (globalCtx->actorCtx.freezeFlashTimer == 0) { - globalCtx->actorCtx.freezeFlashTimer = 1; - } -} - -void func_8083264C(Player* this, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { - if (this->actor.category == ACTORCAT_PLAYER) { - func_800AA000(arg4, arg1, arg2, arg3); - } -} - -void func_80832698(Player* this, u16 sfxId) { - if (this->actor.category == ACTORCAT_PLAYER) { - func_8002F7DC(&this->actor, sfxId + this->ageProperties->unk_92); - } else { - func_800F4190(&this->actor.projectedPos, sfxId); - } -} - -void func_808326F0(Player* this) { - u16* entry = &D_8085361C[0]; - s32 i; - - for (i = 0; i < 4; i++) { - Audio_StopSfxById((u16)(*entry + this->ageProperties->unk_92)); - entry++; - } -} - -u16 func_8083275C(Player* this, u16 sfxId) { - return sfxId + this->unk_89E; -} - -void func_80832770(Player* this, u16 sfxId) { - func_8002F7DC(&this->actor, func_8083275C(this, sfxId)); -} - -u16 func_808327A4(Player* this, u16 sfxId) { - return sfxId + this->unk_89E + this->ageProperties->unk_94; -} - -void func_808327C4(Player* this, u16 sfxId) { - func_8002F7DC(&this->actor, func_808327A4(this, sfxId)); -} - -void func_808327F8(Player* this, f32 arg1) { - s32 sfxId; - - if (this->currentBoots == PLAYER_BOOTS_IRON) { - sfxId = NA_SE_PL_WALK_HEAVYBOOTS; - } else { - sfxId = func_808327A4(this, NA_SE_PL_WALK_GROUND); - } - - func_800F4010(&this->actor.projectedPos, sfxId, arg1); -} - -void func_80832854(Player* this) { - s32 sfxId; - - if (this->currentBoots == PLAYER_BOOTS_IRON) { - sfxId = NA_SE_PL_JUMP_HEAVYBOOTS; - } else { - sfxId = func_808327A4(this, NA_SE_PL_JUMP); - } - - func_8002F7DC(&this->actor, sfxId); -} - -void func_808328A0(Player* this) { - s32 sfxId; - - if (this->currentBoots == PLAYER_BOOTS_IRON) { - sfxId = NA_SE_PL_LAND_HEAVYBOOTS; - } else { - sfxId = func_808327A4(this, NA_SE_PL_LAND); - } - - func_8002F7DC(&this->actor, sfxId); -} - -void func_808328EC(Player* this, u16 sfxId) { - func_8002F7DC(&this->actor, sfxId); - this->stateFlags2 |= 8; -} - -void func_80832924(Player* this, struct_80832924* entry) { - s32 data; - s32 flags; - u32 cont; - s32 pad; - - do { - data = ABS(entry->field); - flags = data & 0x7800; - if (LinkAnimation_OnFrame(&this->skelAnime, fabsf(data & 0x7FF))) { - if (flags == 0x800) { - func_8002F7DC(&this->actor, entry->sfxId); - } else if (flags == 0x1000) { - func_80832770(this, entry->sfxId); - } else if (flags == 0x1800) { - func_808327C4(this, entry->sfxId); - } else if (flags == 0x2000) { - func_80832698(this, entry->sfxId); - } else if (flags == 0x2800) { - func_808328A0(this); - } else if (flags == 0x3000) { - func_808327F8(this, 6.0f); - } else if (flags == 0x3800) { - func_80832854(this); - } else if (flags == 0x4000) { - func_808327F8(this, 0.0f); - } else if (flags == 0x4800) { - func_800F4010(&this->actor.projectedPos, this->ageProperties->unk_94 + NA_SE_PL_WALK_LADDER, 0.0f); - } - } - cont = (entry->field >= 0); - entry++; - } while (cont); -} - -void func_80832B0C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, - -6.0f); -} - -void func_80832B78(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), - ANIMMODE_ONCE, -6.0f); -} - -void func_80832BE8(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f); -} - -void func_80832C2C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); -} - -void func_80832C6C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -16.0f); -} - -s32 func_80832CB0(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, anim); - return 1; - } else { - return 0; - } -} - -void func_80832CFC(Player* this) { - this->skelAnime.prevTransl = this->skelAnime.baseTransl; - this->skelAnime.prevRot = this->actor.shape.rot.y; -} - -void func_80832D20(Player* this) { - func_80832CFC(this); - this->skelAnime.prevTransl.x *= this->ageProperties->unk_08; - this->skelAnime.prevTransl.y *= this->ageProperties->unk_08; - this->skelAnime.prevTransl.z *= this->ageProperties->unk_08; -} - -void func_80832DB0(Player* this) { - this->skelAnime.jointTable[1].y = 0; -} - -void func_80832DBC(Player* this) { - if (this->skelAnime.moveFlags != 0) { - func_808322FC(this); - this->skelAnime.jointTable[0].x = this->skelAnime.baseTransl.x; - this->skelAnime.jointTable[0].z = this->skelAnime.baseTransl.z; - if (this->skelAnime.moveFlags & 8) { - if (this->skelAnime.moveFlags & 2) { - this->skelAnime.jointTable[0].y = this->skelAnime.prevTransl.y; - } - } else { - this->skelAnime.jointTable[0].y = this->skelAnime.baseTransl.y; - } - func_80832CFC(this); - this->skelAnime.moveFlags = 0; - } -} - -void func_80832E48(Player* this, s32 flags) { - Vec3f pos; - - this->skelAnime.moveFlags = flags; - this->skelAnime.prevTransl = this->skelAnime.baseTransl; - SkelAnime_UpdateTranslation(&this->skelAnime, &pos, this->actor.shape.rot.y); - - if (flags & 1) { - if (!LINK_IS_ADULT) { - pos.x *= 0.64f; - pos.z *= 0.64f; - } - this->actor.world.pos.x += pos.x * this->actor.scale.x; - this->actor.world.pos.z += pos.z * this->actor.scale.z; - } - - if (flags & 2) { - if (!(flags & 4)) { - pos.y *= this->ageProperties->unk_08; - } - this->actor.world.pos.y += pos.y * this->actor.scale.y; - } - - func_808322FC(this); -} - -void func_80832F54(GlobalContext* globalCtx, Player* this, s32 flags) { - if (flags & 0x200) { - func_80832D20(this); - } else if ((flags & 0x100) || (this->skelAnime.moveFlags != 0)) { - func_80832CFC(this); - } else { - this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.prevRot = this->actor.shape.rot.y; - } - - this->skelAnime.moveFlags = flags; - func_80832210(this); - AnimationContext_DisableQueue(globalCtx); -} - -void func_80832FFC(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, anim, playbackSpeed); - func_80832F54(globalCtx, this, flags); -} - -void func_8083303C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_80832FFC(globalCtx, this, anim, flags, 1.0f); -} - -void func_80833064(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_80832FFC(globalCtx, this, anim, flags, 2.0f / 3.0f); -} - -void func_8083308C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - func_80833064(globalCtx, this, anim, 0x1C); -} - -void func_808330AC(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { - LinkAnimation_PlayLoopSetSpeed(globalCtx, &this->skelAnime, anim, playbackSpeed); - func_80832F54(globalCtx, this, flags); -} - -void func_808330EC(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_808330AC(globalCtx, this, anim, flags, 1.0f); -} - -void func_80833114(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, s32 flags) { - func_808330AC(globalCtx, this, anim, flags, 2.0f / 3.0f); -} - -void func_8083313C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - func_80833114(globalCtx, this, anim, 0x1C); -} - -void func_8083315C(GlobalContext* globalCtx, Player* this) { - s8 phi_v1; - s8 phi_v0; - - this->unk_A7C = D_808535D4; - this->unk_A80 = D_808535D8; - - func_80077D10(&D_808535D4, &D_808535D8, sControlInput); - - D_808535DC = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)) + D_808535D8; - - this->unk_846 = (this->unk_846 + 1) % 4; - - if (D_808535D4 < 55.0f) { - phi_v0 = -1; - phi_v1 = -1; - } else { - phi_v1 = (u16)(D_808535D8 + 0x2000) >> 9; - phi_v0 = (u16)((s16)(D_808535DC - this->actor.shape.rot.y) + 0x2000) >> 14; - } - - this->unk_847[this->unk_846] = phi_v1; - this->unk_84B[this->unk_846] = phi_v0; -} - -void func_8083328C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* linkAnim) { - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, linkAnim, D_808535E8); -} - -s32 func_808332B8(Player* this) { - return (this->stateFlags1 & 0x8000000) && (this->currentBoots != PLAYER_BOOTS_IRON); -} - -s32 func_808332E4(Player* this) { - return (this->stateFlags1 & 0x1000000); -} - -void func_808332F4(Player* this, GlobalContext* globalCtx) { - GetItemEntry* giEntry = &sGetItemTable[this->getItemId - 1]; - - this->unk_862 = ABS(giEntry->gi); -} - -static LinkAnimationHeader* func_80833338(Player* this) { - return D_80853914[this->modelAnimType]; -} - -s32 func_80833350(Player* this) { - LinkAnimationHeader** entry; - s32 i; - - if (func_80833338(this) != this->skelAnime.animation) { - for (i = 0, entry = &D_80853D7C[0][0]; i < 28; i++, entry++) { - if (this->skelAnime.animation == *entry) { - return i + 1; - } - } - return 0; - } - - return -1; -} - -void func_808333FC(Player* this, s32 arg1) { - if (D_80853E7C[arg1] != 0) { - func_80832924(this, D_80853E50[D_80853E7C[arg1] - 1]); - } -} - -LinkAnimationHeader* func_80833438(Player* this) { - if (this->unk_890 != 0) { - return D_8085395C[this->modelAnimType]; - } else if (!(this->stateFlags1 & 0x28000000) && (this->currentBoots == PLAYER_BOOTS_IRON)) { - return D_80853974[this->modelAnimType]; - } else { - return D_80853944[this->modelAnimType]; - } -} - -s32 func_808334B4(Player* this) { - return func_808332E4(this) && (this->unk_834 != 0); -} - -LinkAnimationHeader* func_808334E4(Player* this) { - if (func_808334B4(this)) { - return &gPlayerAnim_002638; - } else { - return D_808539A4[this->modelAnimType]; - } -} - -LinkAnimationHeader* func_80833528(Player* this) { - if (func_808334B4(this)) { - return &gPlayerAnim_002630; - } else { - return D_8085398C[this->modelAnimType]; - } -} - -LinkAnimationHeader* func_8083356C(Player* this) { - if (func_8002DD78(this)) { - return &gPlayerAnim_0026E8; - } else { - return D_80853B3C[this->modelAnimType]; - } -} - -LinkAnimationHeader* func_808335B0(Player* this) { - if (func_808334B4(this)) { - return &gPlayerAnim_002620; - } else { - return D_80853B6C[this->modelAnimType]; - } -} - -LinkAnimationHeader* func_808335F4(Player* this) { - if (func_808334B4(this)) { - return &gPlayerAnim_002618; - } else { - return D_80853B54[this->modelAnimType]; - } -} - -void func_80833638(Player* this, PlayerFunc82C arg1) { - this->func_82C = arg1; - this->unk_836 = 0; - this->unk_830 = 0.0f; - func_808326F0(this); -} - -void func_80833664(GlobalContext* globalCtx, Player* this, s8 actionParam) { - LinkAnimationHeader* current = this->skelAnime.animation; - LinkAnimationHeader** iter = &D_80853914[this->modelAnimType]; - u32 i; - - this->stateFlags1 &= ~0x1000008; - - for (i = 0; i < 45; i++) { - if (current == AnimHeaderLut[i][this->modelAnimType]) { - break; - } - } - - func_8083399C(globalCtx, this, actionParam); - - if (i < 45) { - this->skelAnime.animation = AnimHeaderLut[i][this->modelAnimType]; - } -} - -s8 Player_ItemToActionParam(s32 item) { - if (item >= ITEM_NONE_FE) { - return PLAYER_AP_NONE; - } else if (item == ITEM_LAST_USED) { - return PLAYER_AP_LAST_USED; - } else if (item == ITEM_FISHING_POLE) { - return PLAYER_AP_FISHING_POLE; - } else { - return sItemActionParams[item]; - } -} - -void func_80833770(GlobalContext* globalCtx, Player* this) { -} - -void func_8083377C(GlobalContext* globalCtx, Player* this) { - this->unk_85C = 1.0f; -} - -void func_80833790(GlobalContext* globalCtx, Player* this) { -} - -void func_8083379C(GlobalContext* globalCtx, Player* this) { - this->stateFlags1 |= 8; - - if (this->heldItemActionParam != PLAYER_AP_SLINGSHOT) { - this->unk_860 = -1; - } else { - this->unk_860 = -2; - } -} - -void func_808337D4(GlobalContext* globalCtx, Player* this) { - s32 explosiveType; - ExplosiveInfo* explosiveInfo; - Actor* spawnedActor; - - if (this->stateFlags1 & 0x800) { - func_80832528(globalCtx, this); - return; - } - - explosiveType = Player_GetExplosiveHeld(this); - explosiveInfo = &sExplosiveInfos[explosiveType]; - - spawnedActor = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, explosiveInfo->actorId, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, - this->actor.shape.rot.y, 0, 0); - if (spawnedActor != NULL) { - if ((explosiveType != 0) && (globalCtx->bombchuBowlingStatus != 0)) { - globalCtx->bombchuBowlingStatus--; - if (globalCtx->bombchuBowlingStatus == 0) { - globalCtx->bombchuBowlingStatus = -1; - } - } else { - Inventory_ChangeAmmo(explosiveInfo->itemId, -1); - } - - this->interactRangeActor = spawnedActor; - this->heldActor = spawnedActor; - this->getItemId = GI_NONE; - this->unk_3BC.y = spawnedActor->shape.rot.y - this->actor.shape.rot.y; - this->stateFlags1 |= 0x800; - } -} - -void func_80833910(GlobalContext* globalCtx, Player* this) { - this->stateFlags1 |= 8; - this->unk_860 = -3; - - this->heldActor = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_ARMS_HOOK, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); -} - -void func_80833984(GlobalContext* globalCtx, Player* this) { - this->stateFlags1 |= 0x1000000; -} - -void func_8083399C(GlobalContext* globalCtx, Player* this, s8 actionParam) { - this->unk_860 = 0; - this->unk_85C = 0.0f; - this->unk_858 = 0.0f; - - this->heldItemActionParam = this->itemActionParam = actionParam; - this->modelGroup = this->nextModelGroup; - - this->stateFlags1 &= ~0x1000008; - - D_80853FE8[actionParam](globalCtx, this); - - Player_SetModelGroup(this, this->modelGroup); -} - -void func_80833A20(Player* this, s32 newSwordState) { - u16 itemSfx; - u16 voiceSfx; - - if (this->swordState == 0) { - if ((this->heldItemActionParam == PLAYER_AP_SWORD_BGS) && (gSaveContext.swordHealth > 0.0f)) { - itemSfx = NA_SE_IT_HAMMER_SWING; - } else { - itemSfx = NA_SE_IT_SWORD_SWING; - } - - voiceSfx = NA_SE_VO_LI_SWORD_N; - if (this->heldItemActionParam == PLAYER_AP_HAMMER) { - itemSfx = NA_SE_IT_HAMMER_SWING; - } else if (this->swordAnimation >= 0x18) { - itemSfx = 0; - voiceSfx = NA_SE_VO_LI_SWORD_L; - } else if (this->unk_845 >= 3) { - itemSfx = NA_SE_IT_SWORD_SWING_HARD; - voiceSfx = NA_SE_VO_LI_SWORD_L; - } - - if (itemSfx != 0) { - func_808328EC(this, itemSfx); - } - - if ((this->swordAnimation < 0x10) || (this->swordAnimation >= 0x14)) { - func_80832698(this, voiceSfx); - } - } - - this->swordState = newSwordState; -} - -s32 func_80833B2C(Player* this) { - if (this->stateFlags1 & 0x40030000) { - return 1; - } else { - return 0; - } -} - -s32 func_80833B54(Player* this) { - if ((this->unk_664 != NULL) && CHECK_FLAG_ALL(this->unk_664->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2)) { - this->stateFlags1 |= 0x10; - return 1; - } - - if (this->stateFlags1 & 0x10) { - this->stateFlags1 &= ~0x10; - if (this->linearVelocity == 0.0f) { - this->currentYaw = this->actor.shape.rot.y; - } - } - - return 0; -} - -s32 func_80833BCC(Player* this) { - return func_8008E9C4(this) || func_80833B2C(this); -} - -s32 func_80833C04(Player* this) { - return func_80833B54(this) || func_80833B2C(this); -} - -void func_80833C3C(Player* this) { - this->unk_870 = this->unk_874 = 0.0f; -} - -s32 func_80833C50(Player* this, s32 item) { - if ((item < ITEM_NONE_FE) && (Player_ItemToActionParam(item) == this->itemActionParam)) { - return 1; - } else { - return 0; - } -} - -s32 func_80833C98(s32 item1, s32 actionParam) { - if ((item1 < ITEM_NONE_FE) && (Player_ItemToActionParam(item1) == actionParam)) { - return 1; - } else { - return 0; - } -} - -s32 func_80833CDC(GlobalContext* globalCtx, s32 index) { - if (index >= 4) { - return ITEM_NONE; - } else if (globalCtx->bombchuBowlingStatus != 0) { - return (globalCtx->bombchuBowlingStatus > 0) ? ITEM_BOMBCHU : ITEM_NONE; - } else if (index == 0) { - return B_BTN_ITEM; - } else if (index == 1) { - return C_BTN_ITEM(0); - } else if (index == 2) { - return C_BTN_ITEM(1); - } else { - return C_BTN_ITEM(2); - } -} - -void func_80833DF8(Player* this, GlobalContext* globalCtx) { - s32 maskActionParam; - s32 item; - s32 i; - - if (this->currentMask != PLAYER_MASK_NONE) { - maskActionParam = this->currentMask - 1 + PLAYER_AP_MASK_KEATON; - if (!func_80833C98(C_BTN_ITEM(0), maskActionParam) && !func_80833C98(C_BTN_ITEM(1), maskActionParam) && - !func_80833C98(C_BTN_ITEM(2), maskActionParam)) { - this->currentMask = PLAYER_MASK_NONE; - } - } - - if (!(this->stateFlags1 & 0x20000800) && !func_8008F128(this)) { - if (this->itemActionParam >= PLAYER_AP_FISHING_POLE) { - if (!func_80833C50(this, B_BTN_ITEM) && !func_80833C50(this, C_BTN_ITEM(0)) && - !func_80833C50(this, C_BTN_ITEM(1)) && !func_80833C50(this, C_BTN_ITEM(2))) { - func_80835F44(globalCtx, this, ITEM_NONE); - return; - } - } - - for (i = 0; i < ARRAY_COUNT(D_80854388); i++) { - if (CHECK_BTN_ALL(sControlInput->press.button, D_80854388[i])) { - break; - } - } - - item = func_80833CDC(globalCtx, i); - if (item >= ITEM_NONE_FE) { - for (i = 0; i < ARRAY_COUNT(D_80854388); i++) { - if (CHECK_BTN_ALL(sControlInput->cur.button, D_80854388[i])) { - break; - } - } - - item = func_80833CDC(globalCtx, i); - if ((item < ITEM_NONE_FE) && (Player_ItemToActionParam(item) == this->heldItemActionParam)) { - D_80853618 = true; - } - } else { - this->heldItemButton = i; - func_80835F44(globalCtx, this, item); - } - } -} - -void func_808340DC(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - f32 phi_f2; - f32 phi_f12; - f32 phi_f14; - f32 phi_f0; - s32 sp38; - s8 sp37; - s32 temp; - - sp37 = Player_ItemToActionParam(this->heldItemId); - func_80833638(this, func_80834A2C); - - temp = gPlayerModelTypes[this->nextModelGroup][0]; - sp38 = D_80854164[gPlayerModelTypes[this->modelGroup][0]][temp]; - if ((sp37 == PLAYER_AP_BOTTLE) || (sp37 == PLAYER_AP_BOOMERANG) || - ((sp37 == PLAYER_AP_NONE) && - ((this->heldItemActionParam == PLAYER_AP_BOTTLE) || (this->heldItemActionParam == PLAYER_AP_BOOMERANG)))) { - sp38 = (sp37 == PLAYER_AP_NONE) ? -13 : 13; - } - - this->unk_15A = ABS(sp38); - - anim = D_808540F4[this->unk_15A].anim; - if ((anim == &gPlayerAnim_002F30) && (this->currentShield == PLAYER_SHIELD_NONE)) { - anim = &gPlayerAnim_002F40; - } - - phi_f2 = Animation_GetLastFrame(anim); - phi_f14 = phi_f2; - - if (sp38 >= 0) { - phi_f0 = 1.2f; - phi_f12 = 0.0f; - } else { - phi_f14 = 0.0f; - phi_f0 = -1.2f; - phi_f12 = phi_f2; - } - - if (sp37 != PLAYER_AP_NONE) { - phi_f0 *= 2.0f; - } - - LinkAnimation_Change(globalCtx, &this->skelAnime2, anim, phi_f0, phi_f12, phi_f14, ANIMMODE_ONCE, 0.0f); - - this->stateFlags1 &= ~0x100; -} - -void func_80834298(Player* this, GlobalContext* globalCtx) { - if ((this->actor.category == ACTORCAT_PLAYER) && !(this->stateFlags1 & 0x100) && - ((this->heldItemActionParam == this->itemActionParam) || (this->stateFlags1 & 0x400000)) && - (gSaveContext.health != 0) && (globalCtx->csCtx.state == CS_STATE_IDLE) && (this->csMode == 0) && - (globalCtx->shootingGalleryStatus == 0) && (globalCtx->activeCamera == MAIN_CAM) && - (globalCtx->sceneLoadFlag != 0x14) && (gSaveContext.timer1State != 10)) { - func_80833DF8(this, globalCtx); - } - - if (this->stateFlags1 & 0x100) { - func_808340DC(this, globalCtx); - } -} - -s32 func_80834380(GlobalContext* globalCtx, Player* this, s32* itemPtr, s32* typePtr) { - if (LINK_IS_ADULT) { - *itemPtr = ITEM_BOW; - if (this->stateFlags1 & 0x800000) { - *typePtr = ARROW_NORMAL_HORSE; - } else { - *typePtr = this->heldItemActionParam - 6; - } - } else { - *itemPtr = ITEM_SLINGSHOT; - *typePtr = ARROW_SEED; - } - - if (gSaveContext.minigameState == 1) { - return globalCtx->interfaceCtx.hbaAmmo; - } else if (globalCtx->shootingGalleryStatus != 0) { - return globalCtx->shootingGalleryStatus; - } else { - return AMMO(*itemPtr); - } -} - -s32 func_8083442C(Player* this, GlobalContext* globalCtx) { - s32 item; - s32 arrowType; - s32 magicArrowType; - - if ((this->heldItemActionParam >= PLAYER_AP_BOW_FIRE) && (this->heldItemActionParam <= PLAYER_AP_BOW_0E) && - (gSaveContext.unk_13F0 != 0)) { - func_80078884(NA_SE_SY_ERROR); - } else { - func_80833638(this, func_808351D4); - - this->stateFlags1 |= 0x200; - this->unk_834 = 14; - - if (this->unk_860 >= 0) { - func_8002F7DC(&this->actor, D_80854398[ABS(this->unk_860) - 1]); - - if (!Player_HoldsHookshot(this) && (func_80834380(globalCtx, this, &item, &arrowType) > 0)) { - magicArrowType = arrowType - ARROW_FIRE; - - if (this->unk_860 >= 0) { - if ((magicArrowType >= 0) && (magicArrowType <= 2) && - !func_80087708(globalCtx, sMagicArrowCosts[magicArrowType], 0)) { - arrowType = ARROW_NORMAL; - } - - this->heldActor = Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ARROW, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, arrowType); - } - } - } - - return 1; - } - - return 0; -} - -void func_80834594(GlobalContext* globalCtx, Player* this) { - if (this->heldItemActionParam != PLAYER_AP_NONE) { - if (func_8008F2BC(this, this->heldItemActionParam) >= 0) { - func_808328EC(this, NA_SE_IT_SWORD_PUTAWAY); - } else { - func_808328EC(this, NA_SE_PL_CHANGE_ARMS); - } - } - - func_80835F44(globalCtx, this, this->heldItemId); - - if (func_8008F2BC(this, this->heldItemActionParam) >= 0) { - func_808328EC(this, NA_SE_IT_SWORD_PICKOUT); - } else if (this->heldItemActionParam != PLAYER_AP_NONE) { - func_808328EC(this, NA_SE_PL_CHANGE_ARMS); - } -} - -void func_80834644(GlobalContext* globalCtx, Player* this) { - if (func_80834A2C == this->func_82C) { - func_80834594(globalCtx, this); - } - - func_80833638(this, D_80853EDC[this->heldItemActionParam]); - this->unk_834 = 0; - this->unk_6AC = 0; - func_808323B4(globalCtx, this); - this->stateFlags1 &= ~0x100; -} - -LinkAnimationHeader* func_808346C4(GlobalContext* globalCtx, Player* this) { - func_80833638(this, func_80834B5C); - func_808323B4(globalCtx, this); - - if (this->unk_870 < 0.5f) { - return D_808543A4[Player_HoldsTwoHandedWeapon(this)]; - } else { - return D_808543AC[Player_HoldsTwoHandedWeapon(this)]; - } -} - -s32 func_80834758(GlobalContext* globalCtx, Player* this) { - LinkAnimationHeader* anim; - f32 frame; - - if (!(this->stateFlags1 & 0x20C00000) && (globalCtx->shootingGalleryStatus == 0) && - (this->heldItemActionParam == this->itemActionParam) && (this->currentShield != PLAYER_SHIELD_NONE) && - !Player_IsChildWithHylianShield(this) && func_80833BCC(this) && - CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { - - anim = func_808346C4(globalCtx, this); - frame = Animation_GetLastFrame(anim); - LinkAnimation_Change(globalCtx, &this->skelAnime2, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); - func_8002F7DC(&this->actor, NA_SE_IT_SHIELD_POSTURE); - - return 1; - } else { - return 0; - } -} - -s32 func_8083485C(Player* this, GlobalContext* globalCtx) { - if (func_80834758(globalCtx, this)) { - return 1; - } else { - return 0; - } -} - -void func_80834894(Player* this) { - func_80833638(this, func_80834C74); - - if (this->itemActionParam < 0) { - func_8008EC70(this); - } - - Animation_Reverse(&this->skelAnime2); - func_8002F7DC(&this->actor, NA_SE_IT_SHIELD_REMOVE); -} - -void func_808348EC(GlobalContext* globalCtx, Player* this) { - struct_808540F4* ptr = &D_808540F4[this->unk_15A]; - f32 temp; - - temp = ptr->unk_04; - temp = (this->skelAnime2.playSpeed < 0.0f) ? temp - 1.0f : temp; - - if (LinkAnimation_OnFrame(&this->skelAnime2, temp)) { - func_80834594(globalCtx, this); - } - - func_80833B54(this); -} - -s32 func_8083499C(Player* this, GlobalContext* globalCtx) { - if (this->stateFlags1 & 0x100) { - func_808340DC(this, globalCtx); - } else { - return 0; - } - - return 1; -} - -s32 func_808349DC(Player* this, GlobalContext* globalCtx) { - if (func_80834758(globalCtx, this) || func_8083499C(this, globalCtx)) { - return 1; - } else { - return 0; - } -} - -s32 func_80834A2C(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime2) || - ((Player_ItemToActionParam(this->heldItemId) == this->heldItemActionParam) && - (D_80853614 = (D_80853614 || ((this->modelAnimType != 3) && (globalCtx->shootingGalleryStatus == 0)))))) { - func_80833638(this, D_80853EDC[this->heldItemActionParam]); - this->unk_834 = 0; - this->unk_6AC = 0; - D_80853618 = D_80853614; - return this->func_82C(this, globalCtx); - } - - if (func_80833350(this) != 0) { - func_808348EC(globalCtx, this); - func_80832264(globalCtx, this, func_80833338(this)); - this->unk_6AC = 0; - } else { - func_808348EC(globalCtx, this); - } - - return 1; -} - -s32 func_80834B5C(Player* this, GlobalContext* globalCtx) { - LinkAnimation_Update(globalCtx, &this->skelAnime2); - - if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { - func_80834894(this); - return 1; - } else { - this->stateFlags1 |= 0x400000; - Player_SetModelsForHoldingShield(this); - return 1; - } -} - -s32 func_80834BD4(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - f32 frame; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - anim = func_808346C4(globalCtx, this); - frame = Animation_GetLastFrame(anim); - LinkAnimation_Change(globalCtx, &this->skelAnime2, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); - } - - this->stateFlags1 |= 0x400000; - Player_SetModelsForHoldingShield(this); - - return 1; -} - -s32 func_80834C74(Player* this, GlobalContext* globalCtx) { - D_80853614 = D_80853618; - - if (D_80853614 || LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - func_80833638(this, D_80853EDC[this->heldItemActionParam]); - LinkAnimation_PlayLoop(globalCtx, &this->skelAnime2, D_80853914[this->modelAnimType]); - this->unk_6AC = 0; - this->func_82C(this, globalCtx); - return 0; - } - - return 1; -} - -s32 func_80834D2C(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - - if (this->heldItemActionParam != PLAYER_AP_BOOMERANG) { - if (!func_8083442C(this, globalCtx)) { - return 0; - } - - if (!Player_HoldsHookshot(this)) { - anim = &gPlayerAnim_0026A0; - } else { - anim = &gPlayerAnim_002CA0; - } - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, anim); - } else { - func_80833638(this, func_80835884); - this->unk_834 = 10; - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, &gPlayerAnim_002628); - } - - if (this->stateFlags1 & 0x800000) { - func_80832284(globalCtx, this, &gPlayerAnim_003380); - } else if ((this->actor.bgCheckFlags & 1) && !func_80833B54(this)) { - func_80832284(globalCtx, this, D_80853914[this->modelAnimType]); - } - - return 1; -} - -s32 func_80834E44(GlobalContext* globalCtx) { - return (globalCtx->shootingGalleryStatus > 0) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B); -} - -s32 func_80834E7C(GlobalContext* globalCtx) { - return (globalCtx->shootingGalleryStatus != 0) && - ((globalCtx->shootingGalleryStatus < 0) || - CHECK_BTN_ANY(sControlInput->cur.button, BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)); -} - -s32 func_80834EB8(Player* this, GlobalContext* globalCtx) { - if ((this->unk_6AD == 0) || (this->unk_6AD == 2)) { - if (func_80833BCC(this) || (Camera_CheckValidMode(Gameplay_GetCamera(globalCtx, 0), 7) == 0)) { - return 1; - } - this->unk_6AD = 2; - } - - return 0; -} - -s32 func_80834F2C(Player* this, GlobalContext* globalCtx) { - if ((this->doorType == PLAYER_DOORTYPE_NONE) && !(this->stateFlags1 & 0x2000000)) { - if (D_80853614 || func_80834E44(globalCtx)) { - if (func_80834D2C(this, globalCtx)) { - return func_80834EB8(this, globalCtx); - } - } - } - - return 0; -} - -s32 func_80834FBC(Player* this) { - if (this->actor.child != NULL) { - if (this->heldActor == NULL) { - this->heldActor = this->actor.child; - func_8083264C(this, 255, 10, 250, 0); - func_8002F7DC(&this->actor, NA_SE_IT_HOOKSHOT_RECEIVE); - } - - return 1; - } - - return 0; -} - -s32 func_8083501C(Player* this, GlobalContext* globalCtx) { - if (this->unk_860 >= 0) { - this->unk_860 = -this->unk_860; - } - - if ((!Player_HoldsHookshot(this) || func_80834FBC(this)) && !func_80834758(globalCtx, this) && - !func_80834F2C(this, globalCtx)) { - return 0; - } - - return 1; -} - -s32 func_808350A4(GlobalContext* globalCtx, Player* this) { - s32 item; - s32 arrowType; - - if (this->heldActor != NULL) { - if (!Player_HoldsHookshot(this)) { - func_80834380(globalCtx, this, &item, &arrowType); - - if (gSaveContext.minigameState == 1) { - globalCtx->interfaceCtx.hbaAmmo--; - } else if (globalCtx->shootingGalleryStatus != 0) { - globalCtx->shootingGalleryStatus--; - } else { - Inventory_ChangeAmmo(item, -1); - } - - if (globalCtx->shootingGalleryStatus == 1) { - globalCtx->shootingGalleryStatus = -10; - } - - func_8083264C(this, 150, 10, 150, 0); - } else { - func_8083264C(this, 255, 20, 150, 0); - } - - this->unk_A73 = 4; - this->heldActor->parent = NULL; - this->actor.child = NULL; - this->heldActor = NULL; - - return 1; - } - - return 0; -} - -static u16 D_808543DC[] = { NA_SE_IT_BOW_FLICK, NA_SE_IT_SLING_FLICK }; - -s32 func_808351D4(Player* this, GlobalContext* globalCtx) { - s32 sp2C; - - if (!Player_HoldsHookshot(this)) { - sp2C = 0; - } else { - sp2C = 1; - } - - Math_ScaledStepToS(&this->unk_6C0, 1200, 400); - this->unk_6AE |= 0x100; - - if ((this->unk_836 == 0) && (func_80833350(this) == 0) && (this->skelAnime.animation == &gPlayerAnim_0026E8)) { - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, D_808543CC[sp2C]); - this->unk_836 = -1; - } else if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - LinkAnimation_PlayLoop(globalCtx, &this->skelAnime2, D_808543D4[sp2C]); - this->unk_836 = 1; - } else if (this->unk_836 == 1) { - this->unk_836 = 2; - } - - if (this->unk_834 > 10) { - this->unk_834--; - } - - func_80834EB8(this, globalCtx); - - if ((this->unk_836 > 0) && ((this->unk_860 < 0) || (!D_80853618 && !func_80834E7C(globalCtx)))) { - func_80833638(this, func_808353D8); - if (this->unk_860 >= 0) { - if (sp2C == 0) { - if (!func_808350A4(globalCtx, this)) { - func_8002F7DC(&this->actor, D_808543DC[ABS(this->unk_860) - 1]); - } - } else if (this->actor.bgCheckFlags & 1) { - func_808350A4(globalCtx, this); - } - } - this->unk_834 = 10; - func_80832210(this); - } else { - this->stateFlags1 |= 0x200; - } - - return 1; -} - -s32 func_808353D8(Player* this, GlobalContext* globalCtx) { - LinkAnimation_Update(globalCtx, &this->skelAnime2); - - if (Player_HoldsHookshot(this) && !func_80834FBC(this)) { - return 1; - } - - if (!func_80834758(globalCtx, this) && - (D_80853614 || ((this->unk_860 < 0) && D_80853618) || func_80834E44(globalCtx))) { - this->unk_860 = ABS(this->unk_860); - - if (func_8083442C(this, globalCtx)) { - if (Player_HoldsHookshot(this)) { - this->unk_836 = 1; - } else { - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, &gPlayerAnim_0026B8); - } - } - } else { - if (this->unk_834 != 0) { - this->unk_834--; - } - - if (func_80833BCC(this) || (this->unk_6AD != 0) || (this->stateFlags1 & 0x100000)) { - if (this->unk_834 == 0) { - this->unk_834++; - } - return 1; - } - - if (Player_HoldsHookshot(this)) { - func_80833638(this, func_8083501C); - } else { - func_80833638(this, func_80835588); - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, &gPlayerAnim_0026B0); - } - - this->unk_834 = 0; - } - - return 1; -} - -s32 func_80835588(Player* this, GlobalContext* globalCtx) { - if (!(this->actor.bgCheckFlags & 1) || LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - func_80833638(this, func_8083501C); - } - - return 1; -} - -void func_808355DC(Player* this) { - this->stateFlags1 |= 0x20000; - - if (!(this->skelAnime.moveFlags & 0x80) && (this->actor.bgCheckFlags & 0x200) && (D_80853608 < 0x2000)) { - this->currentYaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; - } - - this->targetYaw = this->actor.shape.rot.y; -} - -s32 func_80835644(GlobalContext* globalCtx, Player* this, Actor* arg2) { - if (arg2 == NULL) { - func_80832564(globalCtx, this); - func_80839F90(this, globalCtx); - return 1; - } - - return 0; -} - -void func_80835688(Player* this, GlobalContext* globalCtx) { - if (!func_80835644(globalCtx, this, this->heldActor)) { - func_80833638(this, func_808356E8); - LinkAnimation_PlayLoop(globalCtx, &this->skelAnime2, &gPlayerAnim_002E10); - } -} - -s32 func_808356E8(Player* this, GlobalContext* globalCtx) { - Actor* heldActor = this->heldActor; - - if (heldActor == NULL) { - func_80834644(globalCtx, this); - } - - if (func_80834758(globalCtx, this)) { - return 1; - } - - if (this->stateFlags1 & 0x800) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - LinkAnimation_PlayLoop(globalCtx, &this->skelAnime2, &gPlayerAnim_002E10); - } - - if ((heldActor->id == ACTOR_EN_NIW) && (this->actor.velocity.y <= 0.0f)) { - this->actor.minVelocityY = -2.0f; - this->actor.gravity = -0.5f; - this->fallStartHeight = this->actor.world.pos.y; - } - - return 1; - } - - return func_8083485C(this, globalCtx); -} - -void func_808357E8(Player* this, Gfx** dLists) { - this->leftHandDLists = &dLists[gSaveContext.linkAge]; -} - -s32 func_80835800(Player* this, GlobalContext* globalCtx) { - if (func_80834758(globalCtx, this)) { - return 1; - } - - if (this->stateFlags1 & 0x2000000) { - func_80833638(this, func_80835B60); - } else if (func_80834F2C(this, globalCtx)) { - return 1; - } - - return 0; -} - -s32 func_80835884(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - func_80833638(this, func_808358F0); - LinkAnimation_PlayLoop(globalCtx, &this->skelAnime2, &gPlayerAnim_002638); - } - - func_80834EB8(this, globalCtx); - - return 1; -} - -s32 func_808358F0(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* animSeg = this->skelAnime.animation; - - if ((func_808334E4(this) == animSeg) || (func_80833528(this) == animSeg) || (func_808335B0(this) == animSeg) || - (func_808335F4(this) == animSeg)) { - AnimationContext_SetCopyAll(globalCtx, this->skelAnime.limbCount, this->skelAnime2.jointTable, - this->skelAnime.jointTable); - } else { - LinkAnimation_Update(globalCtx, &this->skelAnime2); - } - - func_80834EB8(this, globalCtx); - - if (!D_80853618) { - func_80833638(this, func_808359FC); - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, - (this->unk_870 < 0.5f) ? &gPlayerAnim_002608 : &gPlayerAnim_002600); - } - - return 1; -} - -s32 func_808359FC(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - func_80833638(this, func_80835B60); - this->unk_834 = 0; - } else if (LinkAnimation_OnFrame(&this->skelAnime2, 6.0f)) { - f32 posX = (Math_SinS(this->actor.shape.rot.y) * 10.0f) + this->actor.world.pos.x; - f32 posZ = (Math_CosS(this->actor.shape.rot.y) * 10.0f) + this->actor.world.pos.z; - s32 yaw = (this->unk_664 != NULL) ? this->actor.shape.rot.y + 14000 : this->actor.shape.rot.y; - EnBoom* boomerang = - (EnBoom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOOM, posX, this->actor.world.pos.y + 30.0f, - posZ, this->actor.focus.rot.x, yaw, 0, 0); - - this->boomerangActor = &boomerang->actor; - if (boomerang != NULL) { - boomerang->moveTo = this->unk_664; - boomerang->returnTimer = 20; - this->stateFlags1 |= 0x2000000; - if (!func_8008E9C4(this)) { - func_808355DC(this); - } - this->unk_A73 = 4; - func_8002F7DC(&this->actor, NA_SE_IT_BOOMERANG_THROW); - func_80832698(this, NA_SE_VO_LI_SWORD_N); - } - } - - return 1; -} - -s32 func_80835B60(Player* this, GlobalContext* globalCtx) { - if (func_80834758(globalCtx, this)) { - return 1; - } - - if (!(this->stateFlags1 & 0x2000000)) { - func_80833638(this, func_80835C08); - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, &gPlayerAnim_0025F8); - func_808357E8(this, D_80125EF8); - func_8002F7DC(&this->actor, NA_SE_PL_CATCH_BOOMERANG); - func_80832698(this, NA_SE_VO_LI_SWORD_N); - return 1; - } - - return 0; -} - -s32 func_80835C08(Player* this, GlobalContext* globalCtx) { - if (!func_80835800(this, globalCtx) && LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - func_80833638(this, func_80835800); - } - - return 1; -} - -s32 func_80835C58(GlobalContext* globalCtx, Player* this, PlayerFunc674 func, s32 flags) { - if (func == this->func_674) { - return 0; - } - - if (func_8084E3C4 == this->func_674) { - Audio_OcaSetInstrument(0); - this->stateFlags2 &= ~0x3000000; - } else if (func_808507F4 == this->func_674) { - func_80832340(globalCtx, this); - } - - this->func_674 = func; - - if ((this->itemActionParam != this->heldItemActionParam) && (!(flags & 1) || !(this->stateFlags1 & 0x400000))) { - func_8008EC70(this); - } - - if (!(flags & 1) && (!(this->stateFlags1 & 0x800))) { - func_80834644(globalCtx, this); - this->stateFlags1 &= ~0x400000; - } - - func_80832DBC(this); - this->stateFlags1 &= ~0xB4000044; - this->stateFlags2 &= ~0x18080000; - this->stateFlags3 &= ~0x8A; - this->unk_84F = 0; - this->unk_850 = 0; - this->unk_6AC = 0; - func_808326F0(this); - - return 1; -} - -void func_80835DAC(GlobalContext* globalCtx, Player* this, PlayerFunc674 func, s32 flags) { - s32 temp; - - temp = this->skelAnime.moveFlags; - this->skelAnime.moveFlags = 0; - func_80835C58(globalCtx, this, func, flags); - this->skelAnime.moveFlags = temp; -} - -void func_80835DE4(GlobalContext* globalCtx, Player* this, PlayerFunc674 func, s32 flags) { - s32 temp; - - if (this->itemActionParam >= 0) { - temp = this->itemActionParam; - this->itemActionParam = this->heldItemActionParam; - func_80835C58(globalCtx, this, func, flags); - this->itemActionParam = temp; - Player_SetModels(this, Player_ActionToModelGroup(this, this->itemActionParam)); - } -} - -void func_80835E44(GlobalContext* globalCtx, s16 camSetting) { - if (!func_800C0CB8(globalCtx)) { - if (camSetting == CAM_SET_SCENE_TRANSITION) { - Interface_ChangeAlpha(2); - } - } else { - Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), camSetting); - } -} - -void func_80835EA4(GlobalContext* globalCtx, s32 arg1) { - func_80835E44(globalCtx, CAM_SET_TURN_AROUND); - Camera_SetCameraData(Gameplay_GetCamera(globalCtx, 0), 4, 0, 0, arg1, 0, 0); -} - -void func_80835EFC(Player* this) { - if (Player_HoldsHookshot(this)) { - Actor* heldActor = this->heldActor; - - if (heldActor != NULL) { - Actor_Kill(heldActor); - this->actor.child = NULL; - this->heldActor = NULL; - } - } -} - -void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item) { - s8 actionParam; - s32 temp; - s32 nextType; - - actionParam = Player_ItemToActionParam(item); - - if (((this->heldItemActionParam == this->itemActionParam) && - (!(this->stateFlags1 & 0x400000) || (Player_ActionToSword(actionParam) != 0) || - (actionParam == PLAYER_AP_NONE))) || - ((this->itemActionParam < 0) && - ((Player_ActionToSword(actionParam) != 0) || (actionParam == PLAYER_AP_NONE)))) { - - if ((actionParam == PLAYER_AP_NONE) || !(this->stateFlags1 & 0x8000000) || - ((this->actor.bgCheckFlags & 1) && - ((actionParam == PLAYER_AP_HOOKSHOT) || (actionParam == PLAYER_AP_LONGSHOT)))) { - - if ((globalCtx->bombchuBowlingStatus == 0) && - (((actionParam == PLAYER_AP_STICK) && (AMMO(ITEM_STICK) == 0)) || - ((actionParam == PLAYER_AP_BEAN) && (AMMO(ITEM_BEAN) == 0)) || - (temp = Player_ActionToExplosive(this, actionParam), - ((temp >= 0) && ((AMMO(sExplosiveInfos[temp].itemId) == 0) || - (globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].length >= 3)))))) { - func_80078884(NA_SE_SY_ERROR); - return; - } - - if (actionParam == PLAYER_AP_LENS) { - if (func_80087708(globalCtx, 0, 3)) { - if (globalCtx->actorCtx.unk_03 != 0) { - func_800304B0(globalCtx); - } else { - globalCtx->actorCtx.unk_03 = 1; - } - func_80078884((globalCtx->actorCtx.unk_03 != 0) ? NA_SE_SY_GLASSMODE_ON : NA_SE_SY_GLASSMODE_OFF); - } else { - func_80078884(NA_SE_SY_ERROR); - } - return; - } - - if (actionParam == PLAYER_AP_NUT) { - if (AMMO(ITEM_NUT) != 0) { - func_8083C61C(globalCtx, this); - } else { - func_80078884(NA_SE_SY_ERROR); - } - return; - } - - temp = Player_ActionToMagicSpell(this, actionParam); - if (temp >= 0) { - if (((actionParam == PLAYER_AP_FARORES_WIND) && (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 0)) || - ((gSaveContext.unk_13F4 != 0) && (gSaveContext.unk_13F0 == 0) && - (gSaveContext.magic >= sMagicSpellCosts[temp]))) { - this->itemActionParam = actionParam; - this->unk_6AD = 4; - } else { - func_80078884(NA_SE_SY_ERROR); - } - return; - } - - if (actionParam >= PLAYER_AP_MASK_KEATON) { - if (this->currentMask != PLAYER_MASK_NONE) { - this->currentMask = PLAYER_MASK_NONE; - } else { - this->currentMask = actionParam - PLAYER_AP_MASK_KEATON + 1; - } - func_808328EC(this, NA_SE_PL_CHANGE_ARMS); - return; - } - - if (((actionParam >= PLAYER_AP_OCARINA_FAIRY) && (actionParam <= PLAYER_AP_OCARINA_TIME)) || - (actionParam >= PLAYER_AP_BOTTLE_FISH)) { - if (!func_8008E9C4(this) || - ((actionParam >= PLAYER_AP_BOTTLE_POTION_RED) && (actionParam <= PLAYER_AP_BOTTLE_FAIRY))) { - func_8002D53C(globalCtx, &globalCtx->actorCtx.titleCtx); - this->unk_6AD = 4; - this->itemActionParam = actionParam; - } - return; - } - - if ((actionParam != this->heldItemActionParam) || - ((this->heldActor == 0) && (Player_ActionToExplosive(this, actionParam) >= 0))) { - this->nextModelGroup = Player_ActionToModelGroup(this, actionParam); - nextType = gPlayerModelTypes[this->nextModelGroup][0]; - if ((this->heldItemActionParam >= 0) && (Player_ActionToMagicSpell(this, actionParam) < 0) && - (item != this->heldItemId) && (D_80854164[gPlayerModelTypes[this->modelGroup][0]][nextType] != 0)) { - this->heldItemId = item; - this->stateFlags1 |= 0x100; - } else { - func_80835EFC(this); - func_808323B4(globalCtx, this); - func_80833664(globalCtx, this, actionParam); - } - return; - } - - D_80853614 = D_80853618 = true; - } - } -} - -void func_80836448(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - s32 cond = func_808332B8(this); - - func_80832564(globalCtx, this); - - func_80835C58(globalCtx, this, cond ? func_8084E368 : func_80843CEC, 0); - - this->stateFlags1 |= 0x80; - - func_80832264(globalCtx, this, anim); - if (anim == &gPlayerAnim_002878) { - this->skelAnime.endFrame = 84.0f; - } - - func_80832224(this); - func_80832698(this, NA_SE_VO_LI_DOWN); - - if (this->actor.category == ACTORCAT_PLAYER) { - func_800F47BC(); - - if (Inventory_ConsumeFairy(globalCtx)) { - globalCtx->gameOverCtx.state = GAMEOVER_REVIVE_START; - this->unk_84F = 1; - } else { - globalCtx->gameOverCtx.state = GAMEOVER_DEATH_START; - func_800F6AB0(0); - Audio_PlayFanfare(NA_BGM_GAME_OVER); - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - } - - OnePointCutscene_Init(globalCtx, 9806, cond ? 120 : 60, &this->actor, MAIN_CAM); - ShrinkWindow_SetVal(0x20); - } -} - -s32 func_808365C8(Player* this) { - return (!(func_808458D0 == this->func_674) || - ((this->stateFlags1 & 0x100) && - ((this->heldItemId == ITEM_LAST_USED) || (this->heldItemId == ITEM_NONE)))) && - (!(func_80834A2C == this->func_82C) || - (Player_ItemToActionParam(this->heldItemId) == this->heldItemActionParam)); -} - -s32 func_80836670(Player* this, GlobalContext* globalCtx) { - if (!(this->stateFlags1 & 0x800000) && (this->actor.parent != NULL) && Player_HoldsHookshot(this)) { - func_80835C58(globalCtx, this, func_80850AEC, 1); - this->stateFlags3 |= 0x80; - func_80832264(globalCtx, this, &gPlayerAnim_002C90); - func_80832F54(globalCtx, this, 0x9B); - func_80832224(this); - this->currentYaw = this->actor.shape.rot.y; - this->actor.bgCheckFlags &= ~1; - this->hoverBootsTimer = 0; - this->unk_6AE |= 0x43; - func_80832698(this, NA_SE_VO_LI_LASH); - return 1; - } - - if (func_808365C8(this)) { - func_80834298(this, globalCtx); - if (func_8084E604 == this->func_674) { - return 1; - } - } - - if (!this->func_82C(this, globalCtx)) { - return 0; - } - - if (this->unk_830 != 0.0f) { - if ((func_80833350(this) == 0) || (this->linearVelocity != 0.0f)) { - AnimationContext_SetCopyFalse(globalCtx, this->skelAnime.limbCount, this->skelAnime2.jointTable, - this->skelAnime.jointTable, D_80853410); - } - Math_StepToF(&this->unk_830, 0.0f, 0.25f); - AnimationContext_SetInterp(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable, 1.0f - this->unk_830); - } else if ((func_80833350(this) == 0) || (this->linearVelocity != 0.0f)) { - AnimationContext_SetCopyTrue(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable, D_80853410); - } else { - AnimationContext_SetCopyAll(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable); - } - - return 1; -} - -s32 func_80836898(GlobalContext* globalCtx, Player* this, PlayerFuncA74 func) { - this->func_A74 = func; - func_80835C58(globalCtx, this, func_808458D0, 0); - this->stateFlags2 |= 0x40; - return func_80832528(globalCtx, this); -} - -void func_808368EC(Player* this, GlobalContext* globalCtx) { - s16 previousYaw = this->actor.shape.rot.y; - - if (!(this->stateFlags2 & 0x60)) { - if ((this->unk_664 != NULL) && - ((globalCtx->actorCtx.targetCtx.unk_4B != 0) || (this->actor.category != ACTORCAT_PLAYER))) { - Math_ScaledStepToS(&this->actor.shape.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_664->focus.pos), 4000); - } else if ((this->stateFlags1 & 0x20000) && !(this->stateFlags2 & 0x60)) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 4000); - } - } else if (!(this->stateFlags2 & 0x40)) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->currentYaw, 2000); - } - - this->unk_87C = this->actor.shape.rot.y - previousYaw; -} - -s32 func_808369C8(s16* pValue, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5) { - s16 temp1; - s16 temp2; - s16 temp3; - - temp1 = temp2 = arg4 - *pValue; - temp2 = CLAMP(temp2, -arg5, arg5); - *pValue += (s16)(temp1 - temp2); - - Math_ScaledStepToS(pValue, arg1, arg2); - - temp3 = *pValue; - if (*pValue < -arg3) { - *pValue = -arg3; - } else if (*pValue > arg3) { - *pValue = arg3; - } - return temp3 - *pValue; -} - -s32 func_80836AB8(Player* this, s32 arg1) { - s16 sp36; - s16 var; - - var = this->actor.shape.rot.y; - if (arg1 != 0) { - var = this->actor.focus.rot.y; - this->unk_6BC = this->actor.focus.rot.x; - this->unk_6AE |= 0x41; - } else { - func_808369C8(&this->unk_6BC, - func_808369C8(&this->unk_6B6, this->actor.focus.rot.x, 600, 10000, this->actor.focus.rot.x, 0), - 200, 4000, this->unk_6B6, 10000); - sp36 = this->actor.focus.rot.y - var; - func_808369C8(&sp36, 0, 200, 24000, this->unk_6BE, 8000); - var = this->actor.focus.rot.y - sp36; - func_808369C8(&this->unk_6B8, sp36 - this->unk_6BE, 200, 8000, sp36, 8000); - func_808369C8(&this->unk_6BE, sp36, 200, 8000, this->unk_6B8, 8000); - this->unk_6AE |= 0xD9; - } - - return var; -} - -void func_80836BEC(Player* this, GlobalContext* globalCtx) { - s32 sp1C = 0; - s32 zTrigPressed = CHECK_BTN_ALL(sControlInput->cur.button, BTN_Z); - Actor* actorToTarget; - s32 pad; - s32 holdTarget; - s32 cond; - - if (!zTrigPressed) { - this->stateFlags1 &= ~0x40000000; - } - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) || (this->csMode != 0) || (this->stateFlags1 & 0x20000080) || - (this->stateFlags3 & 0x80)) { - this->unk_66C = 0; - } else if (zTrigPressed || (this->stateFlags2 & 0x2000) || (this->unk_684 != NULL)) { - if (this->unk_66C <= 5) { - this->unk_66C = 5; - } else { - this->unk_66C--; - } - } else if (this->stateFlags1 & 0x20000) { - this->unk_66C = 0; - } else if (this->unk_66C != 0) { - this->unk_66C--; - } - - if (this->unk_66C >= 6) { - sp1C = 1; - } - - cond = func_8083224C(globalCtx); - if (cond || (this->unk_66C != 0) || (this->stateFlags1 & 0x2001000)) { - if (!cond) { - if (!(this->stateFlags1 & 0x2000000) && - ((this->heldItemActionParam != PLAYER_AP_FISHING_POLE) || (this->unk_860 == 0)) && - CHECK_BTN_ALL(sControlInput->press.button, BTN_Z)) { - - if (this->actor.category == ACTORCAT_PLAYER) { - actorToTarget = globalCtx->actorCtx.targetCtx.arrowPointedActor; - } else { - actorToTarget = &GET_PLAYER(globalCtx)->actor; - } - - holdTarget = (gSaveContext.zTargetSetting != 0) || (this->actor.category != ACTORCAT_PLAYER); - this->stateFlags1 |= 0x8000; - - if ((actorToTarget != NULL) && !(actorToTarget->flags & ACTOR_FLAG_27)) { - if ((actorToTarget == this->unk_664) && (this->actor.category == ACTORCAT_PLAYER)) { - actorToTarget = globalCtx->actorCtx.targetCtx.unk_94; - } - - if (actorToTarget != this->unk_664) { - if (!holdTarget) { - this->stateFlags2 |= 0x2000; - } - this->unk_664 = actorToTarget; - this->unk_66C = 15; - this->stateFlags2 &= ~0x200002; - } else { - if (!holdTarget) { - func_8008EDF0(this); - } - } - - this->stateFlags1 &= ~0x40000000; - } else { - if (!(this->stateFlags1 & 0x40020000)) { - func_808355DC(this); - } - } - } - - if (this->unk_664 != NULL) { - if ((this->actor.category == ACTORCAT_PLAYER) && (this->unk_664 != this->unk_684) && - func_8002F0C8(this->unk_664, this, sp1C)) { - func_8008EDF0(this); - this->stateFlags1 |= 0x40000000; - } else if (this->unk_664 != NULL) { - this->unk_664->targetPriority = 40; - } - } else if (this->unk_684 != NULL) { - this->unk_664 = this->unk_684; - } - } - - if (this->unk_664 != NULL) { - this->stateFlags1 &= ~0x30000; - if ((this->stateFlags1 & 0x800) || !CHECK_FLAG_ALL(this->unk_664->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2)) { - this->stateFlags1 |= 0x10000; - } - } else { - if (this->stateFlags1 & 0x20000) { - this->stateFlags2 &= ~0x2000; - } else { - func_8008EE08(this); - } - } - } else { - func_8008EE08(this); - } -} - -s32 func_80836FAC(GlobalContext* globalCtx, Player* this, f32* arg2, s16* arg3, f32 arg4) { - f32 temp_f2; - f32 temp_f0; - f32 temp_f14; - f32 temp_f12; - - if ((this->unk_6AD != 0) || (globalCtx->sceneLoadFlag == 0x14) || (this->stateFlags1 & 1)) { - *arg2 = 0.0f; - *arg3 = this->actor.shape.rot.y; - } else { - *arg2 = D_808535D4; - *arg3 = D_808535D8; - - if (arg4 != 0.0f) { - *arg2 -= 20.0f; - if (*arg2 < 0.0f) { - *arg2 = 0.0f; - } else { - temp_f2 = 1.0f - Math_CosS(*arg2 * 450.0f); - *arg2 = ((temp_f2 * temp_f2) * 30.0f) + 7.0f; - } - } else { - *arg2 *= 0.8f; - } - - if (D_808535D4 != 0.0f) { - temp_f0 = Math_SinS(this->unk_898); - temp_f12 = this->unk_880; - temp_f14 = CLAMP(temp_f0, 0.0f, 0.6f); - - if (this->unk_6C4 != 0.0f) { - temp_f12 = temp_f12 - (this->unk_6C4 * 0.008f); - if (temp_f12 < 2.0f) { - temp_f12 = 2.0f; - } - } - - *arg2 = (*arg2 * 0.14f) - (8.0f * temp_f14 * temp_f14); - *arg2 = CLAMP(*arg2, 0.0f, temp_f12); - - return 1; - } - } - - return 0; -} - -s32 func_8083721C(Player* this) { - return Math_StepToF(&this->linearVelocity, 0.0f, REG(43) / 100.0f); -} - -s32 func_80837268(Player* this, f32* arg1, s16* arg2, f32 arg3, GlobalContext* globalCtx) { - if (!func_80836FAC(globalCtx, this, arg1, arg2, arg3)) { - *arg2 = this->actor.shape.rot.y; - - if (this->unk_664 != NULL) { - if ((globalCtx->actorCtx.targetCtx.unk_4B != 0) && !(this->stateFlags2 & 0x40)) { - *arg2 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_664->focus.pos); - return 0; - } - } else if (func_80833B2C(this)) { - *arg2 = this->targetYaw; - } - - return 0; - } else { - *arg2 += Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); - return 1; - } -} - -static s8 D_808543E0[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; -static s8 D_808543E8[] = { 13, 1, 2, 5, 3, 4, 9, 10, 11, 7, 8, -6 }; -static s8 D_808543F4[] = { 13, 1, 2, 3, 4, 9, 10, 11, 8, 7, -6 }; -static s8 D_80854400[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; -static s8 D_80854408[] = { 13, 2, 4, 9, 10, 11, 12, 8, -7 }; -static s8 D_80854414[] = { -7 }; -static s8 D_80854418[] = { 0, 11, 1, 2, 3, 5, 4, 9, 8, 7, -6 }; -static s8 D_80854424[] = { 0, 11, 1, 2, 3, 12, 5, 4, 9, 8, 7, -6 }; -static s8 D_80854430[] = { 13, 1, 2, 3, 12, 5, 4, 9, 10, 11, 8, 7, -6 }; -static s8 D_80854440[] = { 10, 8, -7 }; -static s8 D_80854444[] = { 0, 12, 5, -4 }; - -static s32 (*D_80854448[])(Player* this, GlobalContext* globalCtx) = { - func_8083B998, func_80839800, func_8083E5A8, func_8083E0FC, func_8083B644, func_8083F7BC, func_8083C1DC, - func_80850224, func_8083C544, func_8083EB44, func_8083BDBC, func_8083C2B0, func_80838A14, func_8083B040, -}; - -s32 func_80837348(GlobalContext* globalCtx, Player* this, s8* arg2, s32 arg3) { - s32 i; - - if (!(this->stateFlags1 & 0x20000081)) { - if (arg3 != 0) { - D_808535E0 = func_80836670(this, globalCtx); - if (func_8084E604 == this->func_674) { - return 1; - } - } - - if (func_8008F128(this)) { - this->unk_6AE |= 0x41; - return 1; - } - - if (!(this->stateFlags1 & 0x100) && (func_80834A2C != this->func_82C)) { - while (*arg2 >= 0) { - if (D_80854448[*arg2](this, globalCtx)) { - return 1; - } - arg2++; - } - - if (D_80854448[-(*arg2)](this, globalCtx)) { - return 1; - } - } - } - - return 0; -} - -s32 func_808374A0(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, f32 arg3) { - f32 sp24; - s16 sp22; - - if ((skelAnime->endFrame - arg3) <= skelAnime->curFrame) { - if (func_80837348(globalCtx, this, D_80854418, 1)) { - return 0; - } - - if (func_80837268(this, &sp24, &sp22, 0.018f, globalCtx)) { - return 1; - } - } - - return -1; -} - -void func_80837530(GlobalContext* globalCtx, Player* this, s32 arg2) { - if (arg2 != 0) { - this->unk_858 = 0.0f; - } else { - this->unk_858 = 0.5f; - } - - this->stateFlags1 |= 0x1000; - - if (this->actor.category == ACTORCAT_PLAYER) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_M_THUNDER, this->bodyPartsPos[0].x, - this->bodyPartsPos[0].y, this->bodyPartsPos[0].z, 0, 0, 0, Player_GetSwordHeld(this) | arg2); - } -} - -s32 func_808375D8(Player* this) { - s8 sp3C[4]; - s8* iter; - s8* iter2; - s8 temp1; - s8 temp2; - s32 i; - - if ((this->heldItemActionParam == PLAYER_AP_STICK) || Player_HoldsBrokenKnife(this)) { - return 0; - } - - iter = &this->unk_847[0]; - iter2 = &sp3C[0]; - for (i = 0; i < 4; i++, iter++, iter2++) { - if ((*iter2 = *iter) < 0) { - return 0; - } - *iter2 *= 2; - } - - temp1 = sp3C[0] - sp3C[1]; - if (ABS(temp1) < 10) { - return 0; - } - - iter2 = &sp3C[1]; - for (i = 1; i < 3; i++, iter2++) { - temp2 = *iter2 - *(iter2 + 1); - if ((ABS(temp2) < 10) || (temp2 * temp1 < 0)) { - return 0; - } - } - - return 1; -} - -void func_80837704(GlobalContext* globalCtx, Player* this) { - LinkAnimationHeader* anim; - - if ((this->swordAnimation >= 4) && (this->swordAnimation < 8)) { - anim = D_80854358[Player_HoldsTwoHandedWeapon(this)]; - } else { - anim = D_80854350[Player_HoldsTwoHandedWeapon(this)]; - } - - func_80832318(this); - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, 8.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, - -9.0f); - func_80837530(globalCtx, this, 0x200); -} - -void func_808377DC(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_80844E68, 1); - func_80837704(globalCtx, this); -} - -static s8 D_80854480[] = { 12, 4, 4, 8 }; -static s8 D_80854484[] = { 22, 23, 22, 23 }; - -s32 func_80837818(Player* this) { - s32 sp1C = this->unk_84B[this->unk_846]; - s32 sp18; - - if (this->heldItemActionParam == PLAYER_AP_HAMMER) { - if (sp1C < 0) { - sp1C = 0; - } - sp18 = D_80854484[sp1C]; - this->unk_845 = 0; - } else { - if (func_808375D8(this)) { - sp18 = 24; - } else { - if (sp1C < 0) { - if (func_80833BCC(this)) { - sp18 = 0; - } else { - sp18 = 4; - } - } else { - sp18 = D_80854480[sp1C]; - if (sp18 == 12) { - this->stateFlags2 |= 0x40000000; - if (!func_80833BCC(this)) { - sp18 = 0; - } - } - } - if (this->heldItemActionParam == PLAYER_AP_STICK) { - sp18 = 0; - } - } - if (Player_HoldsTwoHandedWeapon(this)) { - sp18++; - } - } - - return sp18; -} - -void func_80837918(Player* this, s32 quadIndex, u32 flags) { - this->swordQuads[quadIndex].info.toucher.dmgFlags = flags; - - if (flags == 2) { - this->swordQuads[quadIndex].info.toucherFlags = TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_WOOD; - } else { - this->swordQuads[quadIndex].info.toucherFlags = TOUCH_ON | TOUCH_NEAREST; - } -} - -static u32 D_80854488[][2] = { - { 0x00000200, 0x08000000 }, { 0x00000100, 0x02000000 }, { 0x00000400, 0x04000000 }, - { 0x00000002, 0x08000000 }, { 0x00000040, 0x40000000 }, -}; - -void func_80837948(GlobalContext* globalCtx, Player* this, s32 arg2) { - s32 pad; - u32 flags; - s32 temp; - - func_80835C58(globalCtx, this, func_808502D0, 0); - this->unk_844 = 8; - if ((arg2 < 18) || (arg2 >= 20)) { - func_80832318(this); - } - - if ((arg2 != this->swordAnimation) || !(this->unk_845 < 3)) { - this->unk_845 = 0; - } - - this->unk_845++; - if (this->unk_845 >= 3) { - arg2 += 2; - } - - this->swordAnimation = arg2; - - func_808322D0(globalCtx, this, D_80854190[arg2].unk_00); - if ((arg2 != 16) && (arg2 != 17)) { - func_80832F54(globalCtx, this, 0x209); - } - - this->currentYaw = this->actor.shape.rot.y; - - if (Player_HoldsBrokenKnife(this)) { - temp = 1; - } else { - temp = Player_GetSwordHeld(this) - 1; - } - - if ((arg2 >= 16) && (arg2 < 20)) { - flags = D_80854488[temp][1]; - } else { - flags = D_80854488[temp][0]; - } - - func_80837918(this, 0, flags); - func_80837918(this, 1, flags); -} - -void func_80837AE0(Player* this, s32 timer) { - if (this->invincibilityTimer >= 0) { - this->invincibilityTimer = timer; - this->unk_88F = 0; - } -} - -void func_80837AFC(Player* this, s32 timer) { - if (this->invincibilityTimer > timer) { - this->invincibilityTimer = timer; - } - this->unk_88F = 0; -} - -s32 func_80837B18(GlobalContext* globalCtx, Player* this, s32 damage) { - if ((this->invincibilityTimer != 0) || (this->actor.category != ACTORCAT_PLAYER)) { - return 1; - } - - return Health_ChangeBy(globalCtx, damage); -} - -void func_80837B60(Player* this) { - this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - func_80832E48(this, 3); -} - -void func_80837B9C(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084411C, 0); - func_80832284(globalCtx, this, &gPlayerAnim_003040); - this->unk_850 = 1; - if (this->unk_6AD != 3) { - this->unk_6AD = 0; - } -} - -static LinkAnimationHeader* D_808544B0[] = { - &gPlayerAnim_002F80, &gPlayerAnim_002F78, &gPlayerAnim_002DE0, &gPlayerAnim_002DD8, - &gPlayerAnim_002F70, &gPlayerAnim_002528, &gPlayerAnim_002DC8, &gPlayerAnim_0024F0, -}; - -void func_80837C0C(GlobalContext* globalCtx, Player* this, s32 arg2, f32 arg3, f32 arg4, s16 arg5, s32 arg6) { - LinkAnimationHeader* sp2C = NULL; - LinkAnimationHeader** sp28; - - if (this->stateFlags1 & 0x2000) { - func_80837B60(this); - } - - this->unk_890 = 0; - - func_8002F7DC(&this->actor, NA_SE_PL_DAMAGE); - - if (!func_80837B18(globalCtx, this, 0 - this->actor.colChkInfo.damage)) { - this->stateFlags2 &= ~0x80; - if (!(this->actor.bgCheckFlags & 1) && !(this->stateFlags1 & 0x8000000)) { - func_80837B9C(this, globalCtx); - } - return; - } - - func_80837AE0(this, arg6); - - if (arg2 == 3) { - func_80835C58(globalCtx, this, func_8084FB10, 0); - - sp2C = &gPlayerAnim_002FD0; - - func_80832224(this); - func_8083264C(this, 255, 10, 40, 0); - - func_8002F7DC(&this->actor, NA_SE_PL_FREEZE_S); - func_80832698(this, NA_SE_VO_LI_FREEZE); - } else if (arg2 == 4) { - func_80835C58(globalCtx, this, func_8084FBF4, 0); - - func_8083264C(this, 255, 80, 150, 0); - - func_808322A4(globalCtx, this, &gPlayerAnim_002F00); - func_80832224(this); - - this->unk_850 = 20; - } else { - arg5 -= this->actor.shape.rot.y; - if (this->stateFlags1 & 0x8000000) { - func_80835C58(globalCtx, this, func_8084E30C, 0); - func_8083264C(this, 180, 20, 50, 0); - - this->linearVelocity = 4.0f; - this->actor.velocity.y = 0.0f; - - sp2C = &gPlayerAnim_003320; - - func_80832698(this, NA_SE_VO_LI_DAMAGE_S); - } else if ((arg2 == 1) || (arg2 == 2) || !(this->actor.bgCheckFlags & 1) || (this->stateFlags1 & 0x206000)) { - func_80835C58(globalCtx, this, func_8084377C, 0); - - this->stateFlags3 |= 2; - - func_8083264C(this, 255, 20, 150, 0); - func_80832224(this); - - if (arg2 == 2) { - this->unk_850 = 4; - - this->actor.speedXZ = 3.0f; - this->linearVelocity = 3.0f; - this->actor.velocity.y = 6.0f; - - func_80832C2C(globalCtx, this, D_8085395C[this->modelAnimType]); - func_80832698(this, NA_SE_VO_LI_DAMAGE_S); - } else { - this->actor.speedXZ = arg3; - this->linearVelocity = arg3; - this->actor.velocity.y = arg4; - - if (ABS(arg5) > 0x4000) { - sp2C = &gPlayerAnim_002F58; - } else { - sp2C = &gPlayerAnim_002DB0; - } - - if ((this->actor.category != ACTORCAT_PLAYER) && (this->actor.colChkInfo.health == 0)) { - func_80832698(this, NA_SE_VO_BL_DOWN); - } else { - func_80832698(this, NA_SE_VO_LI_FALL_L); - } - } - - this->hoverBootsTimer = 0; - this->actor.bgCheckFlags &= ~1; - } else { - if ((this->linearVelocity > 4.0f) && !func_8008E9C4(this)) { - this->unk_890 = 20; - func_8083264C(this, 120, 20, 10, 0); - func_80832698(this, NA_SE_VO_LI_DAMAGE_S); - return; - } - - sp28 = D_808544B0; - - func_80835C58(globalCtx, this, func_8084370C, 0); - func_80833C3C(this); - - if (this->actor.colChkInfo.damage < 5) { - func_8083264C(this, 120, 20, 10, 0); - } else { - func_8083264C(this, 180, 20, 100, 0); - this->linearVelocity = 23.0f; - sp28 += 4; - } - - if (ABS(arg5) <= 0x4000) { - sp28 += 2; - } - - if (func_8008E9C4(this)) { - sp28 += 1; - } - - sp2C = *sp28; - - func_80832698(this, NA_SE_VO_LI_DAMAGE_S); - } - - this->actor.shape.rot.y += arg5; - this->currentYaw = this->actor.shape.rot.y; - this->actor.world.rot.y = this->actor.shape.rot.y; - if (ABS(arg5) > 0x4000) { - this->actor.shape.rot.y += 0x8000; - } - } - - func_80832564(globalCtx, this); - - this->stateFlags1 |= 0x4000000; - - if (sp2C != NULL) { - func_808322D0(globalCtx, this, sp2C); - } -} - -s32 func_80838144(s32 arg0) { - s32 temp = arg0 - 2; - - if ((temp >= 0) && (temp < 2)) { - return temp; - } else { - return -1; - } -} - -s32 func_8083816C(s32 arg0) { - return (arg0 == 4) || (arg0 == 7) || (arg0 == 12); -} - -void func_8083819C(Player* this, GlobalContext* globalCtx) { - if (this->currentShield == PLAYER_SHIELD_DEKU) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_SHIELD, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1); - Inventory_DeleteEquipment(globalCtx, EQUIP_SHIELD); - Message_StartTextbox(globalCtx, 0x305F, NULL); - } -} - -void func_8083821C(Player* this) { - s32 i; - - // clang-format off - for (i = 0; i < 18; i++) { this->flameTimers[i] = Rand_S16Offset(0, 200); } - // clang-format on - - this->isBurning = true; -} - -void func_80838280(Player* this) { - if (this->actor.colChkInfo.acHitEffect == 1) { - func_8083821C(this); - } - func_80832698(this, NA_SE_VO_LI_FALL_L); -} - -void func_808382BC(Player* this) { - if ((this->invincibilityTimer >= 0) && (this->invincibilityTimer < 20)) { - this->invincibilityTimer = 20; - } -} - -s32 func_808382DC(Player* this, GlobalContext* globalCtx) { - s32 pad; - s32 sp68 = false; - s32 sp64; - - if (this->unk_A86 != 0) { - if (!Player_InBlockingCsMode(globalCtx, this)) { - Player_InflictDamage(globalCtx, -16); - this->unk_A86 = 0; - } - } else { - sp68 = ((Player_GetHeight(this) - 8.0f) < (this->unk_6C4 * this->actor.scale.y)); - - if (sp68 || (this->actor.bgCheckFlags & 0x100) || (D_808535E4 == 9) || (this->stateFlags2 & 0x80000000)) { - func_80832698(this, NA_SE_VO_LI_DAMAGE_S); - - if (sp68) { - Gameplay_TriggerRespawn(globalCtx); - func_800994A0(globalCtx); - } else { - // Special case for getting crushed in Forest Temple's Checkboard Ceiling Hall or Shadow Temple's - // Falling Spike Trap Room, to respawn the player in a specific place - if (((globalCtx->sceneNum == SCENE_BMORI1) && (globalCtx->roomCtx.curRoom.num == 15)) || - ((globalCtx->sceneNum == SCENE_HAKADAN) && (globalCtx->roomCtx.curRoom.num == 10))) { - static SpecialRespawnInfo checkboardCeilingRespawn = { { 1992.0f, 403.0f, -3432.0f }, 0 }; - static SpecialRespawnInfo fallingSpikeTrapRespawn = { { 1200.0f, -1343.0f, 3850.0f }, 0 }; - SpecialRespawnInfo* respawnInfo; - - if (globalCtx->sceneNum == SCENE_BMORI1) { - respawnInfo = &checkboardCeilingRespawn; - } else { - respawnInfo = &fallingSpikeTrapRespawn; - } - - Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_DOWN, 0xDFF); - gSaveContext.respawn[RESPAWN_MODE_DOWN].pos = respawnInfo->pos; - gSaveContext.respawn[RESPAWN_MODE_DOWN].yaw = respawnInfo->yaw; - } - - Gameplay_TriggerVoidOut(globalCtx); - } - - func_80832698(this, NA_SE_VO_LI_TAKEN_AWAY); - globalCtx->unk_11DE9 = 1; - func_80078884(NA_SE_OC_ABYSS); - } else if ((this->unk_8A1 != 0) && ((this->unk_8A1 >= 2) || (this->invincibilityTimer == 0))) { - u8 sp5C[] = { 2, 1, 1 }; - - func_80838280(this); - - if (this->unk_8A1 == 3) { - this->shockTimer = 40; - } - - this->actor.colChkInfo.damage += this->unk_8A0; - func_80837C0C(globalCtx, this, sp5C[this->unk_8A1 - 1], this->unk_8A4, this->unk_8A8, this->unk_8A2, 20); - } else { - sp64 = (this->shieldQuad.base.acFlags & AC_BOUNCED) != 0; - - //! @bug The second set of conditions here seems intended as a way for Link to "block" hits by rolling. - // However, `Collider.atFlags` is a byte so the flag check at the end is incorrect and cannot work. - // Additionally, `Collider.atHit` can never be set while already colliding as AC, so it's also bugged. - // This behavior was later fixed in MM, most likely by removing both the `atHit` and `atFlags` checks. - if (sp64 || ((this->invincibilityTimer < 0) && (this->cylinder.base.acFlags & AC_HIT) && - (this->cylinder.info.atHit != NULL) && (this->cylinder.info.atHit->atFlags & 0x20000000))) { - - func_8083264C(this, 180, 20, 100, 0); - - if (!Player_IsChildWithHylianShield(this)) { - if (this->invincibilityTimer >= 0) { - LinkAnimationHeader* anim; - s32 sp54 = func_80843188 == this->func_674; - - if (!func_808332B8(this)) { - func_80835C58(globalCtx, this, func_808435C4, 0); - } - - if (!(this->unk_84F = sp54)) { - func_80833638(this, func_80834BD4); - - if (this->unk_870 < 0.5f) { - anim = D_808543BC[Player_HoldsTwoHandedWeapon(this)]; - } else { - anim = D_808543B4[Player_HoldsTwoHandedWeapon(this)]; - } - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, anim); - } else { - func_80832264(globalCtx, this, D_808543C4[Player_HoldsTwoHandedWeapon(this)]); - } - } - - if (!(this->stateFlags1 & 0x206000)) { - this->linearVelocity = -18.0f; - this->currentYaw = this->actor.shape.rot.y; - } - } - - if (sp64 && (this->shieldQuad.info.acHitInfo->toucher.effect == 1)) { - func_8083819C(this, globalCtx); - } - - return 0; - } - - if ((this->unk_A87 != 0) || (this->invincibilityTimer > 0) || (this->stateFlags1 & 0x4000000) || - (this->csMode != 0) || (this->swordQuads[0].base.atFlags & AT_HIT) || - (this->swordQuads[1].base.atFlags & AT_HIT)) { - return 0; - } - - if (this->cylinder.base.acFlags & AC_HIT) { - Actor* ac = this->cylinder.base.ac; - s32 sp4C; - - if (ac->flags & ACTOR_FLAG_24) { - func_8002F7DC(&this->actor, NA_SE_PL_BODY_HIT); - } - - if (this->stateFlags1 & 0x8000000) { - sp4C = 0; - } else if (this->actor.colChkInfo.acHitEffect == 2) { - sp4C = 3; - } else if (this->actor.colChkInfo.acHitEffect == 3) { - sp4C = 4; - } else if (this->actor.colChkInfo.acHitEffect == 4) { - sp4C = 1; - } else { - func_80838280(this); - sp4C = 0; - } - - func_80837C0C(globalCtx, this, sp4C, 4.0f, 5.0f, Actor_WorldYawTowardActor(ac, &this->actor), 20); - } else if (this->invincibilityTimer != 0) { - return 0; - } else { - static u8 D_808544F4[] = { 120, 60 }; - s32 sp48 = func_80838144(D_808535E4); - - if (((this->actor.wallPoly != NULL) && - SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.wallPoly, this->actor.wallBgId)) || - ((sp48 >= 0) && - SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) && - (this->unk_A79 >= D_808544F4[sp48])) || - ((sp48 >= 0) && - ((this->currentTunic != PLAYER_TUNIC_GORON) || (this->unk_A79 >= D_808544F4[sp48])))) { - this->unk_A79 = 0; - this->actor.colChkInfo.damage = 4; - func_80837C0C(globalCtx, this, 0, 4.0f, 5.0f, this->actor.shape.rot.y, 20); - } else { - return 0; - } - } - } - } - - return 1; -} - -void func_80838940(Player* this, LinkAnimationHeader* anim, f32 arg2, GlobalContext* globalCtx, u16 sfxId) { - func_80835C58(globalCtx, this, func_8084411C, 1); - - if (anim != NULL) { - func_808322D0(globalCtx, this, anim); - } - - this->actor.velocity.y = arg2 * D_808535E8; - this->hoverBootsTimer = 0; - this->actor.bgCheckFlags &= ~1; - - func_80832854(this); - func_80832698(this, sfxId); - - this->stateFlags1 |= 0x40000; -} - -void func_808389E8(Player* this, LinkAnimationHeader* anim, f32 arg2, GlobalContext* globalCtx) { - func_80838940(this, anim, arg2, globalCtx, NA_SE_VO_LI_SWORD_N); -} - -s32 func_80838A14(Player* this, GlobalContext* globalCtx) { - s32 sp3C; - LinkAnimationHeader* sp38; - f32 sp34; - f32 temp; - f32 sp2C; - f32 sp28; - f32 sp24; - - if (!(this->stateFlags1 & 0x800) && (this->unk_88C >= 2) && - (!(this->stateFlags1 & 0x8000000) || (this->ageProperties->unk_14 > this->wallHeight))) { - sp3C = 0; - - if (func_808332B8(this)) { - if (this->actor.yDistToWater < 50.0f) { - if ((this->unk_88C < 2) || (this->wallHeight > this->ageProperties->unk_10)) { - return 0; - } - } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->unk_88C > 2)) { - return 0; - } - } else if (!(this->actor.bgCheckFlags & 1) || - ((this->ageProperties->unk_14 <= this->wallHeight) && (this->stateFlags1 & 0x8000000))) { - return 0; - } - - if ((this->actor.wallBgId != BGCHECK_SCENE) && (D_808535F0 & 0x40)) { - if (this->unk_88D >= 6) { - this->stateFlags2 |= 4; - if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { - sp3C = 1; - } - } - } else if ((this->unk_88D >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { - sp3C = 1; - } - - if (sp3C != 0) { - func_80835C58(globalCtx, this, func_80845668, 0); - - this->stateFlags1 |= 0x40000; - - sp34 = this->wallHeight; - - if (this->ageProperties->unk_14 <= sp34) { - sp38 = &gPlayerAnim_002D48; - this->linearVelocity = 1.0f; - } else { - sp2C = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); - sp28 = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - sp24 = this->wallDistance + 0.5f; - - this->stateFlags1 |= 0x4000; - - if (func_808332B8(this)) { - sp38 = &gPlayerAnim_0032E8; - sp34 -= (60.0f * this->ageProperties->unk_08); - this->stateFlags1 &= ~0x8000000; - } else if (this->ageProperties->unk_18 <= sp34) { - sp38 = &gPlayerAnim_002D40; - sp34 -= (59.0f * this->ageProperties->unk_08); - } else { - sp38 = &gPlayerAnim_002D38; - sp34 -= (41.0f * this->ageProperties->unk_08); - } - - this->actor.shape.yOffset -= sp34 * 100.0f; - - this->actor.world.pos.x -= sp24 * sp2C; - this->actor.world.pos.y += this->wallHeight; - this->actor.world.pos.z -= sp24 * sp28; - - func_80832224(this); - } - - this->actor.bgCheckFlags |= 1; - - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, sp38, 1.3f); - AnimationContext_DisableQueue(globalCtx); - - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; - - return 1; - } - } else if ((this->actor.bgCheckFlags & 1) && (this->unk_88C == 1) && (this->unk_88D >= 3)) { - temp = (this->wallHeight * 0.08f) + 5.5f; - func_808389E8(this, &gPlayerAnim_002FE0, temp, globalCtx); - this->linearVelocity = 2.5f; - - return 1; - } - - return 0; -} - -void func_80838E70(GlobalContext* globalCtx, Player* this, f32 arg2, s16 arg3) { - func_80835C58(globalCtx, this, func_80845CA4, 0); - func_80832440(globalCtx, this); - - this->unk_84F = 1; - this->unk_850 = 1; - - this->unk_450.x = (Math_SinS(arg3) * arg2) + this->actor.world.pos.x; - this->unk_450.z = (Math_CosS(arg3) * arg2) + this->actor.world.pos.z; - - func_80832264(globalCtx, this, func_80833338(this)); -} - -void func_80838F18(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084D610, 0); - func_80832C6C(globalCtx, this, &gPlayerAnim_003328); -} - -void func_80838F5C(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084F88C, 0); - - this->stateFlags1 |= 0xA0000000; - - Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_FREE0); -} - -s32 func_80838FB8(GlobalContext* globalCtx, Player* this) { - if ((globalCtx->sceneLoadFlag == 0) && (this->stateFlags1 & 0x80000000)) { - func_80838F5C(globalCtx, this); - func_80832284(globalCtx, this, &gPlayerAnim_003040); - func_80832698(this, NA_SE_VO_LI_FALL_S); - func_800788CC(NA_SE_OC_SECRET_WARP_IN); - return 1; - } - - return 0; -} - -s16 D_808544F8[] = { - 0x045B, // DMT from Magic Fairy Fountain - 0x0482, // DMC from Double Defense Fairy Fountain - 0x0340, // Hyrule Castle from Dins Fire Fairy Fountain - 0x044B, // Kakariko from Potion Shop - 0x02A2, // Market (child day) from Potion Shop - 0x0201, // Kakariko from Bazaar - 0x03B8, // Market (child day) from Bazaar - 0x04EE, // Kakariko from House of Skulltulas - 0x03C0, // Back Alley (day) from Bombchu Shop - 0x0463, // Kakariko from Shooting Gallery - 0x01CD, // Market (child day) from Shooting Gallery - 0x0394, // Zoras Fountain from Farores Wind Fairy Fountain - 0x0340, // Hyrule Castle from Dins Fire Fairy Fountain - 0x057C, // Desert Colossus from Nayrus Love Fairy Fountain -}; - -u8 D_80854514[] = { 11, 9, 3, 5, 7, 0 }; - -s32 func_80839034(GlobalContext* globalCtx, Player* this, CollisionPoly* poly, u32 bgId) { - s32 sp3C; - s32 temp; - s32 sp34; - f32 linearVel; - s32 yaw; - - if (this->actor.category == ACTORCAT_PLAYER) { - sp3C = 0; - - if (!(this->stateFlags1 & 0x80) && (globalCtx->sceneLoadFlag == 0) && (this->csMode == 0) && - !(this->stateFlags1 & 1) && - (((poly != NULL) && (sp3C = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, poly, bgId), sp3C != 0)) || - (func_8083816C(D_808535E4) && (this->unk_A7A == 12)))) { - - sp34 = this->unk_A84 - (s32)this->actor.world.pos.y; - - if (!(this->stateFlags1 & 0x28800000) && !(this->actor.bgCheckFlags & 1) && (sp34 < 100) && - (D_80853600 > 100.0f)) { - return 0; - } - - if (sp3C == 0) { - Gameplay_TriggerVoidOut(globalCtx); - func_800994A0(globalCtx); - } else { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[sp3C - 1]; - if (globalCtx->nextEntranceIndex == 0x7FFF) { - gSaveContext.respawnFlag = 2; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; - globalCtx->fadeTransition = 3; - gSaveContext.nextTransition = 3; - } else if (globalCtx->nextEntranceIndex >= 0x7FF9) { - globalCtx->nextEntranceIndex = - D_808544F8[D_80854514[globalCtx->nextEntranceIndex - 0x7FF9] + globalCtx->curSpawn]; - func_800994A0(globalCtx); - } else { - if (SurfaceType_GetSlope(&globalCtx->colCtx, poly, bgId) == 2) { - gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; - Gameplay_TriggerVoidOut(globalCtx); - gSaveContext.respawnFlag = -2; - } - gSaveContext.unk_13C3 = 1; - func_800994A0(globalCtx); - } - globalCtx->sceneLoadFlag = 0x14; - } - - if (!(this->stateFlags1 & 0x20800000) && !(this->stateFlags2 & 0x40000) && !func_808332B8(this) && - (temp = func_80041D4C(&globalCtx->colCtx, poly, bgId), (temp != 10)) && - ((sp34 < 100) || (this->actor.bgCheckFlags & 1))) { - - if (temp == 11) { - func_800788CC(NA_SE_OC_SECRET_HOLE_OUT); - func_800F6964(5); - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - } else { - linearVel = this->linearVelocity; - - if (linearVel < 0.0f) { - this->actor.world.rot.y += 0x8000; - linearVel = -linearVel; - } - - if (linearVel > R_RUN_SPEED_LIMIT / 100.0f) { - gSaveContext.entranceSpeed = R_RUN_SPEED_LIMIT / 100.0f; - } else { - gSaveContext.entranceSpeed = linearVel; - } - - if (D_808535F4 != 0) { - yaw = D_808535FC; - } else { - yaw = this->actor.world.rot.y; - } - func_80838E70(globalCtx, this, 400.0f, yaw); - } - } else { - if (!(this->actor.bgCheckFlags & 1)) { - func_80832210(this); - } - } - - this->stateFlags1 |= 0x20000001; - - func_80835E44(globalCtx, 0x2F); - - return 1; - } else { - if (globalCtx->sceneLoadFlag == 0) { - - if ((this->actor.world.pos.y < -4000.0f) || - (((this->unk_A7A == 5) || (this->unk_A7A == 12)) && - ((D_80853600 < 100.0f) || (this->fallDistance > 400.0f) || - ((globalCtx->sceneNum != SCENE_HAKADAN) && (this->fallDistance > 200.0f)))) || - ((globalCtx->sceneNum == SCENE_GANON_FINAL) && (this->fallDistance > 320.0f))) { - - if (this->actor.bgCheckFlags & 1) { - if (this->unk_A7A == 5) { - Gameplay_TriggerRespawn(globalCtx); - } else { - Gameplay_TriggerVoidOut(globalCtx); - } - globalCtx->fadeTransition = 4; - func_80078884(NA_SE_OC_ABYSS); - } else { - func_80838F5C(globalCtx, this); - this->unk_850 = 9999; - if (this->unk_A7A == 5) { - this->unk_84F = -1; - } else { - this->unk_84F = 1; - } - } - } - - this->unk_A84 = this->actor.world.pos.y; - } - } - } - - return 0; -} - -void func_808395DC(Player* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { - f32 cos = Math_CosS(this->actor.shape.rot.y); - f32 sin = Math_SinS(this->actor.shape.rot.y); - - arg3->x = arg1->x + ((arg2->x * cos) + (arg2->z * sin)); - arg3->y = arg1->y + arg2->y; - arg3->z = arg1->z + ((arg2->z * cos) - (arg2->x * sin)); -} - -Actor* Player_SpawnFairy(GlobalContext* globalCtx, Player* this, Vec3f* arg2, Vec3f* arg3, s32 type) { - Vec3f pos; - - func_808395DC(this, arg2, arg3, &pos); - - return Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pos.x, pos.y, pos.z, 0, 0, 0, type); -} - -f32 func_808396F4(GlobalContext* globalCtx, Player* this, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, s32* arg5) { - func_808395DC(this, &this->actor.world.pos, arg2, arg3); - - return BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, arg4, arg5, arg3); -} - -f32 func_8083973C(GlobalContext* globalCtx, Player* this, Vec3f* arg2, Vec3f* arg3) { - CollisionPoly* sp24; - s32 sp20; - - return func_808396F4(globalCtx, this, arg2, arg3, &sp24, &sp20); -} - -s32 func_80839768(GlobalContext* globalCtx, Player* this, Vec3f* arg2, CollisionPoly** arg3, s32* arg4, Vec3f* arg5) { - Vec3f sp44; - Vec3f sp38; - - sp44.x = this->actor.world.pos.x; - sp44.y = this->actor.world.pos.y + arg2->y; - sp44.z = this->actor.world.pos.z; - - func_808395DC(this, &this->actor.world.pos, arg2, &sp38); - - return BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp44, &sp38, arg5, arg3, true, false, false, true, arg4); -} - -s32 func_80839800(Player* this, GlobalContext* globalCtx) { - DoorShutter* doorShutter; - EnDoor* door; // Can also be DoorKiller* - s32 doorDirection; - f32 sp78; - f32 sp74; - Actor* doorActor; - f32 sp6C; - s32 pad3; - s32 frontRoom; - Actor* attachedActor; - LinkAnimationHeader* sp5C; - CollisionPoly* sp58; - Vec3f sp4C; - - if ((this->doorType != PLAYER_DOORTYPE_NONE) && - (!(this->stateFlags1 & 0x800) || ((this->heldActor != NULL) && (this->heldActor->id == ACTOR_EN_RU1)))) { - if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (func_8084F9A0 == this->func_674)) { - doorActor = this->doorActor; - - if (this->doorType <= PLAYER_DOORTYPE_AJAR) { - doorActor->textId = 0xD0; - func_80853148(globalCtx, doorActor); - return 0; - } - - doorDirection = this->doorDirection; - sp78 = Math_CosS(doorActor->shape.rot.y); - sp74 = Math_SinS(doorActor->shape.rot.y); - - if (this->doorType == PLAYER_DOORTYPE_SLIDING) { - doorShutter = (DoorShutter*)doorActor; - - this->currentYaw = doorShutter->dyna.actor.home.rot.y; - if (doorDirection > 0) { - this->currentYaw -= 0x8000; - } - this->actor.shape.rot.y = this->currentYaw; - - if (this->linearVelocity <= 0.0f) { - this->linearVelocity = 0.1f; - } - - func_80838E70(globalCtx, this, 50.0f, this->actor.shape.rot.y); - - this->unk_84F = 0; - this->unk_447 = this->doorType; - this->stateFlags1 |= 0x20000000; - - this->unk_450.x = this->actor.world.pos.x + ((doorDirection * 20.0f) * sp74); - this->unk_450.z = this->actor.world.pos.z + ((doorDirection * 20.0f) * sp78); - this->unk_45C.x = this->actor.world.pos.x + ((doorDirection * -120.0f) * sp74); - this->unk_45C.z = this->actor.world.pos.z + ((doorDirection * -120.0f) * sp78); - - doorShutter->unk_164 = 1; - func_80832224(this); - - if (this->doorTimer != 0) { - this->unk_850 = 0; - func_80832B0C(globalCtx, this, func_80833338(this)); - this->skelAnime.endFrame = 0.0f; - } else { - this->linearVelocity = 0.1f; - } - - if (doorShutter->dyna.actor.category == ACTORCAT_DOOR) { - this->unk_46A = globalCtx->transiActorCtx.list[(u16)doorShutter->dyna.actor.params >> 10] - .sides[(doorDirection > 0) ? 0 : 1] - .effects; - - func_800304B0(globalCtx); - } - } else { - // This actor can be either EnDoor or DoorKiller. - // Don't try to access any struct vars other than `animStyle` and `playerIsOpening`! These two variables - // are common across the two actors' structs however most other variables are not! - door = (EnDoor*)doorActor; - - door->animStyle = (doorDirection < 0.0f) ? (LINK_IS_ADULT ? KNOB_ANIM_ADULT_L : KNOB_ANIM_CHILD_L) - : (LINK_IS_ADULT ? KNOB_ANIM_ADULT_R : KNOB_ANIM_CHILD_R); - - if (door->animStyle == KNOB_ANIM_ADULT_L) { - sp5C = D_808539EC[this->modelAnimType]; - } else if (door->animStyle == KNOB_ANIM_CHILD_L) { - sp5C = D_80853A04[this->modelAnimType]; - } else if (door->animStyle == KNOB_ANIM_ADULT_R) { - sp5C = D_80853A1C[this->modelAnimType]; - } else { - sp5C = D_80853A34[this->modelAnimType]; - } - - func_80835C58(globalCtx, this, func_80845EF8, 0); - func_80832528(globalCtx, this); - - if (doorDirection < 0) { - this->actor.shape.rot.y = doorActor->shape.rot.y; - } else { - this->actor.shape.rot.y = doorActor->shape.rot.y - 0x8000; - } - - this->currentYaw = this->actor.shape.rot.y; - - sp6C = (doorDirection * 22.0f); - this->actor.world.pos.x = doorActor->world.pos.x + sp6C * sp74; - this->actor.world.pos.z = doorActor->world.pos.z + sp6C * sp78; - - func_8083328C(globalCtx, this, sp5C); - - if (this->doorTimer != 0) { - this->skelAnime.endFrame = 0.0f; - } - - func_80832224(this); - func_80832F54(globalCtx, this, 0x28F); - - if (doorActor->parent != NULL) { - doorDirection = -doorDirection; - } - - door->playerIsOpening = 1; - - if (this->doorType != PLAYER_DOORTYPE_FAKE) { - this->stateFlags1 |= 0x20000000; - func_800304B0(globalCtx); - - if (((doorActor->params >> 7) & 7) == 3) { - sp4C.x = doorActor->world.pos.x - (sp6C * sp74); - sp4C.y = doorActor->world.pos.y + 10.0f; - sp4C.z = doorActor->world.pos.z - (sp6C * sp78); - - BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp58, &sp4C); - - if (func_80839034(globalCtx, this, sp58, BGCHECK_SCENE)) { - gSaveContext.entranceSpeed = 2.0f; - gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN; - } - } else { - Camera_ChangeDoorCam(Gameplay_GetCamera(globalCtx, 0), doorActor, - globalCtx->transiActorCtx.list[(u16)doorActor->params >> 10] - .sides[(doorDirection > 0) ? 0 : 1] - .effects, - 0, 38.0f * D_808535EC, 26.0f * D_808535EC, 10.0f * D_808535EC); - } - } - } - - if ((this->doorType != PLAYER_DOORTYPE_FAKE) && (doorActor->category == ACTORCAT_DOOR)) { - frontRoom = globalCtx->transiActorCtx.list[(u16)doorActor->params >> 10] - .sides[(doorDirection > 0) ? 0 : 1] - .room; - - if ((frontRoom >= 0) && (frontRoom != globalCtx->roomCtx.curRoom.num)) { - func_8009728C(globalCtx, &globalCtx->roomCtx, frontRoom); - } - } - - doorActor->room = globalCtx->roomCtx.curRoom.num; - - if (((attachedActor = doorActor->child) != NULL) || ((attachedActor = doorActor->parent) != NULL)) { - attachedActor->room = globalCtx->roomCtx.curRoom.num; - } - - return 1; - } - } - - return 0; -} - -void func_80839E88(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - - func_80835C58(globalCtx, this, func_80840450, 1); - - if (this->unk_870 < 0.5f) { - anim = func_808334E4(this); - this->unk_870 = 0.0f; - } else { - anim = func_80833528(this); - this->unk_870 = 1.0f; - } - - this->unk_874 = this->unk_870; - func_80832284(globalCtx, this, anim); - this->currentYaw = this->actor.shape.rot.y; -} - -void func_80839F30(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_808407CC, 1); - func_80832B0C(globalCtx, this, func_80833338(this)); - this->currentYaw = this->actor.shape.rot.y; -} - -void func_80839F90(Player* this, GlobalContext* globalCtx) { - if (func_8008E9C4(this)) { - func_80839E88(this, globalCtx); - } else if (func_80833B2C(this)) { - func_80839F30(this, globalCtx); - } else { - func_80853080(this, globalCtx); - } -} - -void func_80839FFC(Player* this, GlobalContext* globalCtx) { - PlayerFunc674 func; - - if (func_8008E9C4(this)) { - func = func_80840450; - } else if (func_80833B2C(this)) { - func = func_808407CC; - } else { - func = func_80840BC8; - } - - func_80835C58(globalCtx, this, func, 1); -} - -void func_8083A060(Player* this, GlobalContext* globalCtx) { - func_80839FFC(this, globalCtx); - if (func_8008E9C4(this)) { - this->unk_850 = 1; - } -} - -void func_8083A098(Player* this, LinkAnimationHeader* anim, GlobalContext* globalCtx) { - func_8083A060(this, globalCtx); - func_8083328C(globalCtx, this, anim); -} - -s32 func_8083A0D4(Player* this) { - return (this->interactRangeActor != NULL) && (this->heldActor == NULL); -} - -void func_8083A0F4(GlobalContext* globalCtx, Player* this) { - if (func_8083A0D4(this)) { - Actor* interactRangeActor = this->interactRangeActor; - s32 interactActorId = interactRangeActor->id; - - if (interactActorId == ACTOR_BG_TOKI_SWD) { - this->interactRangeActor->parent = &this->actor; - func_80835C58(globalCtx, this, func_8084F608, 0); - this->stateFlags1 |= 0x20000000; - } else { - LinkAnimationHeader* anim; - - if (interactActorId == ACTOR_BG_HEAVY_BLOCK) { - func_80835C58(globalCtx, this, func_80846120, 0); - this->stateFlags1 |= 0x20000000; - anim = &gPlayerAnim_002F98; - } else if ((interactActorId == ACTOR_EN_ISHI) && ((interactRangeActor->params & 0xF) == 1)) { - func_80835C58(globalCtx, this, func_80846260, 0); - anim = &gPlayerAnim_0032B0; - } else if (((interactActorId == ACTOR_EN_BOMBF) || (interactActorId == ACTOR_EN_KUSA)) && - (Player_GetStrength() <= PLAYER_STR_NONE)) { - func_80835C58(globalCtx, this, func_80846408, 0); - this->actor.world.pos.x = - (Math_SinS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.x; - this->actor.world.pos.z = - (Math_CosS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.z; - this->currentYaw = this->actor.shape.rot.y = interactRangeActor->yawTowardsPlayer + 0x8000; - anim = &gPlayerAnim_003060; - } else { - func_80835C58(globalCtx, this, func_80846050, 0); - anim = D_80853A4C[this->modelAnimType]; - } - - func_80832264(globalCtx, this, anim); - } - } else { - func_80839F90(this, globalCtx); - this->stateFlags1 &= ~0x800; - } -} - -void func_8083A2F8(GlobalContext* globalCtx, Player* this) { - func_80835DAC(globalCtx, this, func_8084B530, 0); - - this->stateFlags1 |= 0x20000040; - - if (this->actor.textId != 0) { - Message_StartTextbox(globalCtx, this->actor.textId, this->targetActor); - this->unk_664 = this->targetActor; - } -} - -void func_8083A360(GlobalContext* globalCtx, Player* this) { - func_80835DAC(globalCtx, this, func_8084CC98, 0); -} - -void func_8083A388(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084B78C, 0); -} - -void func_8083A3B0(GlobalContext* globalCtx, Player* this) { - s32 sp1C = this->unk_850; - s32 sp18 = this->unk_84F; - - func_80835DAC(globalCtx, this, func_8084BF1C, 0); - this->actor.velocity.y = 0.0f; - - this->unk_850 = sp1C; - this->unk_84F = sp18; -} - -void func_8083A40C(GlobalContext* globalCtx, Player* this) { - func_80835DAC(globalCtx, this, func_8084C760, 0); -} - -void func_8083A434(GlobalContext* globalCtx, Player* this) { - func_80835DAC(globalCtx, this, func_8084E6D4, 0); - - this->stateFlags1 |= 0x20000400; - - if (this->getItemId == GI_HEART_CONTAINER_2) { - this->unk_850 = 20; - } else if (this->getItemId >= 0) { - this->unk_850 = 1; - } else { - this->getItemId = -this->getItemId; - } -} - -s32 func_8083A4A8(Player* this, GlobalContext* globalCtx) { - s16 yawDiff; - LinkAnimationHeader* anim; - f32 temp; - - yawDiff = this->currentYaw - this->actor.shape.rot.y; - - if ((ABS(yawDiff) < 0x1000) && (this->linearVelocity > 4.0f)) { - anim = &gPlayerAnim_003148; - } else { - anim = &gPlayerAnim_002FE0; - } - - if (this->linearVelocity > (IREG(66) / 100.0f)) { - temp = IREG(67) / 100.0f; - } else { - temp = (IREG(68) / 100.0f) + ((IREG(69) * this->linearVelocity) / 1000.0f); - } - - func_80838940(this, anim, temp, globalCtx, NA_SE_VO_LI_AUTO_JUMP); - this->unk_850 = 1; - - return 1; -} - -void func_8083A5C4(GlobalContext* globalCtx, Player* this, CollisionPoly* arg2, f32 arg3, LinkAnimationHeader* arg4) { - f32 sp24 = COLPOLY_GET_NORMAL(arg2->normal.x); - f32 sp20 = COLPOLY_GET_NORMAL(arg2->normal.z); - - func_80835C58(globalCtx, this, func_8084BBE4, 0); - func_80832564(globalCtx, this); - func_80832264(globalCtx, this, arg4); - - this->actor.world.pos.x -= (arg3 + 1.0f) * sp24; - this->actor.world.pos.z -= (arg3 + 1.0f) * sp20; - this->actor.shape.rot.y = this->currentYaw = Math_Atan2S(sp20, sp24); - - func_80832224(this); - func_80832CFC(this); -} - -s32 func_8083A6AC(Player* this, GlobalContext* globalCtx) { - CollisionPoly* sp84; - s32 sp80; - Vec3f sp74; - Vec3f sp68; - f32 temp1; - - if ((this->actor.yDistToWater < -80.0f) && (ABS(this->unk_898) < 2730) && (ABS(this->unk_89A) < 2730)) { - sp74.x = this->actor.prevPos.x - this->actor.world.pos.x; - sp74.z = this->actor.prevPos.z - this->actor.world.pos.z; - - temp1 = sqrtf(SQ(sp74.x) + SQ(sp74.z)); - if (temp1 != 0.0f) { - temp1 = 5.0f / temp1; - } else { - temp1 = 0.0f; - } - - sp74.x = this->actor.prevPos.x + (sp74.x * temp1); - sp74.y = this->actor.world.pos.y; - sp74.z = this->actor.prevPos.z + (sp74.z * temp1); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp68, &sp84, true, false, false, - true, &sp80) && - (ABS(sp84->normal.y) < 600)) { - f32 nx = COLPOLY_GET_NORMAL(sp84->normal.x); - f32 ny = COLPOLY_GET_NORMAL(sp84->normal.y); - f32 nz = COLPOLY_GET_NORMAL(sp84->normal.z); - f32 sp54; - s32 sp50; - - sp54 = Math3D_UDistPlaneToPos(nx, ny, nz, sp84->dist, &this->actor.world.pos); - - sp50 = D_80853604 == 6; - if (!sp50 && (func_80041DB8(&globalCtx->colCtx, sp84, sp80) & 8)) { - sp50 = 1; - } - - func_8083A5C4(globalCtx, this, sp84, sp54, sp50 ? &gPlayerAnim_002D88 : &gPlayerAnim_002F10); - - if (sp50) { - func_80836898(globalCtx, this, func_8083A3B0); - - this->currentYaw += 0x8000; - this->actor.shape.rot.y = this->currentYaw; - - this->stateFlags1 |= 0x200000; - func_80832F54(globalCtx, this, 0x9F); - - this->unk_850 = -1; - this->unk_84F = sp50; - } else { - this->stateFlags1 |= 0x2000; - this->stateFlags1 &= ~0x20000; - } - - func_8002F7DC(&this->actor, NA_SE_PL_SLIPDOWN); - func_80832698(this, NA_SE_VO_LI_HANG); - return 1; - } - } - - return 0; -} - -void func_8083A9B8(Player* this, LinkAnimationHeader* anim, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084BDFC, 0); - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, anim, 1.3f); -} - -static Vec3f D_8085451C = { 0.0f, 0.0f, 100.0f }; - -void func_8083AA10(Player* this, GlobalContext* globalCtx) { - s32 sp5C; - CollisionPoly* sp58; - s32 sp54; - WaterBox* sp50; - Vec3f sp44; - f32 sp40; - f32 sp3C; - - this->fallDistance = this->fallStartHeight - (s32)this->actor.world.pos.y; - - if (!(this->stateFlags1 & 0x28000000) && !(this->actor.bgCheckFlags & 1)) { - if (!func_80838FB8(globalCtx, this)) { - if (D_80853604 == 8) { - this->actor.world.pos.x = this->actor.prevPos.x; - this->actor.world.pos.z = this->actor.prevPos.z; - return; - } - - if (!(this->stateFlags3 & 2) && !(this->skelAnime.moveFlags & 0x80) && (func_8084411C != this->func_674) && - (func_80844A44 != this->func_674)) { - - if ((D_80853604 == 7) || (this->swordState != 0)) { - Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); - func_80832210(this); - return; - } - - if (this->hoverBootsTimer != 0) { - this->actor.velocity.y = 1.0f; - D_80853604 = 9; - return; - } - - sp5C = (s16)(this->currentYaw - this->actor.shape.rot.y); - - func_80835C58(globalCtx, this, func_8084411C, 1); - func_80832440(globalCtx, this); - - this->unk_89E = this->unk_A82; - - if ((this->actor.bgCheckFlags & 4) && !(this->stateFlags1 & 0x8000000) && (D_80853604 != 6) && - (D_80853604 != 9) && (D_80853600 > 20.0f) && (this->swordState == 0) && (ABS(sp5C) < 0x2000) && - (this->linearVelocity > 3.0f)) { - - if ((D_80853604 == 11) && !(this->stateFlags1 & 0x800)) { - - sp40 = func_808396F4(globalCtx, this, &D_8085451C, &sp44, &sp58, &sp54); - sp3C = this->actor.world.pos.y; - - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, sp44.x, sp44.z, &sp3C, &sp50) && - ((sp3C - sp40) > 50.0f)) { - func_808389E8(this, &gPlayerAnim_003158, 6.0f, globalCtx); - func_80835C58(globalCtx, this, func_80844A44, 0); - return; - } - } - - func_8083A4A8(this, globalCtx); - return; - } - - if ((D_80853604 == 9) || (D_80853600 <= this->ageProperties->unk_34) || - !func_8083A6AC(this, globalCtx)) { - func_80832284(globalCtx, this, &gPlayerAnim_003040); - return; - } - } - } - } else { - this->fallStartHeight = this->actor.world.pos.y; - } -} - -s32 func_8083AD4C(GlobalContext* globalCtx, Player* this) { - s32 cameraMode; - - if (this->unk_6AD == 2) { - if (func_8002DD6C(this)) { - if (LINK_IS_ADULT) { - cameraMode = CAM_MODE_BOWARROW; - } else { - cameraMode = CAM_MODE_SLINGSHOT; - } - } else { - cameraMode = CAM_MODE_BOOMERANG; - } - } else { - cameraMode = CAM_MODE_FIRSTPERSON; - } - - return Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), cameraMode); -} - -s32 func_8083ADD4(GlobalContext* globalCtx, Player* this) { - if (this->unk_6AD == 3) { - func_80835C58(globalCtx, this, func_80852E14, 0); - if (this->unk_46A != 0) { - this->stateFlags1 |= 0x20000000; - } - func_80832318(this); - return 1; - } else { - return 0; - } -} - -void func_8083AE40(Player* this, s16 objectId) { - s32 pad; - u32 size; - - if (objectId != 0) { - this->giObjectLoading = true; - //osCreateMesgQueue(&this->giObjectLoadQueue, &this->giObjectLoadMsg, 1); - - size = POINTER_SUB(gObjectTable[objectId].vromEnd, gObjectTable[objectId].vromStart); - - LOG_HEX("size", size, "../z_player.c", 9090); - ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091); - - DmaMgr_SendRequest2(&this->giObjectDmaRequest, this->giObjectSegment, gObjectTable[objectId].vromStart, - size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099); - } -} - -void func_8083AF44(GlobalContext* globalCtx, Player* this, s32 magicSpell) { - func_80835DE4(globalCtx, this, func_808507F4, 0); - - this->unk_84F = magicSpell - 3; - func_80087708(globalCtx, sMagicSpellCosts[magicSpell], 4); - - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, &gPlayerAnim_002D28, 0.83f); - - if (magicSpell == 5) { - this->unk_46C = OnePointCutscene_Init(globalCtx, 1100, -101, NULL, MAIN_CAM); - } else { - func_80835EA4(globalCtx, 10); - } -} - -void func_8083B010(Player* this) { - this->actor.focus.rot.x = this->actor.focus.rot.z = this->unk_6B6 = this->unk_6B8 = this->unk_6BA = this->unk_6BC = - this->unk_6BE = this->unk_6C0 = 0; - - this->actor.focus.rot.y = this->actor.shape.rot.y; -} - -static u8 D_80854528[] = { - GI_LETTER_ZELDA, GI_WEIRD_EGG, GI_CHICKEN, GI_BEAN, GI_POCKET_EGG, GI_POCKET_CUCCO, - GI_COJIRO, GI_ODD_MUSHROOM, GI_ODD_POTION, GI_SAW, GI_SWORD_BROKEN, GI_PRESCRIPTION, - GI_FROG, GI_EYEDROPS, GI_CLAIM_CHECK, GI_MASK_SKULL, GI_MASK_SPOOKY, GI_MASK_KEATON, - GI_MASK_BUNNY, GI_MASK_TRUTH, GI_MASK_GORON, GI_MASK_ZORA, GI_MASK_GERUDO, GI_LETTER_RUTO, - GI_LETTER_RUTO, GI_LETTER_RUTO, GI_LETTER_RUTO, GI_LETTER_RUTO, GI_LETTER_RUTO, -}; - -static LinkAnimationHeader* D_80854548[] = { - &gPlayerAnim_002F88, - &gPlayerAnim_002690, - &gPlayerAnim_003198, -}; - -s32 func_8083B040(Player* this, GlobalContext* globalCtx) { - s32 sp2C; - s32 sp28; - GetItemEntry* giEntry; - Actor* targetActor; - - if ((this->unk_6AD != 0) && - (func_808332B8(this) || (this->actor.bgCheckFlags & 1) || (this->stateFlags1 & 0x800000))) { - - if (!func_8083ADD4(globalCtx, this)) { - if (this->unk_6AD == 4) { - sp2C = Player_ActionToMagicSpell(this, this->itemActionParam); - if (sp2C >= 0) { - if ((sp2C != 3) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { - func_8083AF44(globalCtx, this, sp2C); - } else { - func_80835C58(globalCtx, this, func_8085063C, 1); - this->stateFlags1 |= 0x30000000; - func_80832264(globalCtx, this, func_80833338(this)); - func_80835EA4(globalCtx, 4); - } - - func_80832224(this); - return 1; - } - - sp2C = this->itemActionParam - PLAYER_AP_LETTER_ZELDA; - if ((sp2C >= 0) || - (sp28 = Player_ActionToBottle(this, this->itemActionParam) - 1, - ((sp28 >= 0) && (sp28 < 6) && - ((this->itemActionParam > PLAYER_AP_BOTTLE_POE) || - ((this->targetActor != NULL) && - (((this->itemActionParam == PLAYER_AP_BOTTLE_POE) && (this->exchangeItemId == EXCH_ITEM_POE)) || - (this->exchangeItemId == EXCH_ITEM_BLUE_FIRE))))))) { - - if ((globalCtx->actorCtx.titleCtx.delayTimer == 0) && (globalCtx->actorCtx.titleCtx.alpha == 0)) { - func_80835DE4(globalCtx, this, func_8084F104, 0); - - if (sp2C >= 0) { - giEntry = &sGetItemTable[D_80854528[sp2C] - 1]; - func_8083AE40(this, giEntry->objectId); - } - - this->stateFlags1 |= 0x30000040; - - if (sp2C >= 0) { - sp2C = sp2C + 1; - } else { - sp2C = sp28 + 0x18; - } - - targetActor = this->targetActor; - - if ((targetActor != NULL) && - ((this->exchangeItemId == sp2C) || (this->exchangeItemId == EXCH_ITEM_BLUE_FIRE) || - ((this->exchangeItemId == EXCH_ITEM_POE) && - (this->itemActionParam == PLAYER_AP_BOTTLE_BIG_POE)) || - ((this->exchangeItemId == EXCH_ITEM_BEAN) && - (this->itemActionParam == PLAYER_AP_BOTTLE_BUG))) && - ((this->exchangeItemId != EXCH_ITEM_BEAN) || (this->itemActionParam == PLAYER_AP_BEAN))) { - if (this->exchangeItemId == EXCH_ITEM_BEAN) { - Inventory_ChangeAmmo(ITEM_BEAN, -1); - func_80835DE4(globalCtx, this, func_8084279C, 0); - this->stateFlags1 |= 0x20000000; - this->unk_850 = 0x50; - this->unk_84F = -1; - } - targetActor->flags |= ACTOR_FLAG_8; - this->unk_664 = this->targetActor; - } else if (sp2C == EXCH_ITEM_LETTER_RUTO) { - this->unk_84F = 1; - this->actor.textId = 0x4005; - func_80835EA4(globalCtx, 1); - } else { - this->unk_84F = 2; - this->actor.textId = 0xCF; - func_80835EA4(globalCtx, 4); - } - - this->actor.flags |= ACTOR_FLAG_8; - this->exchangeItemId = sp2C; - - if (this->unk_84F < 0) { - func_80832B0C(globalCtx, this, D_80853C14[this->modelAnimType]); - } else { - func_80832264(globalCtx, this, D_80854548[this->unk_84F]); - } - - func_80832224(this); - } - return 1; - } - - sp2C = Player_ActionToBottle(this, this->itemActionParam); - if (sp2C >= 0) { - if (sp2C == 0xC) { - func_80835DE4(globalCtx, this, func_8084EED8, 0); - func_808322D0(globalCtx, this, &gPlayerAnim_002650); - func_80835EA4(globalCtx, 3); - } else if ((sp2C > 0) && (sp2C < 4)) { - func_80835DE4(globalCtx, this, func_8084EFC0, 0); - func_808322D0(globalCtx, this, &gPlayerAnim_002688); - func_80835EA4(globalCtx, (sp2C == 1) ? 1 : 5); - } else { - func_80835DE4(globalCtx, this, func_8084EAC0, 0); - func_80832B78(globalCtx, this, &gPlayerAnim_002668); - func_80835EA4(globalCtx, 2); - } - } else { - func_80835DE4(globalCtx, this, func_8084E3C4, 0); - func_808322D0(globalCtx, this, &gPlayerAnim_0030A0); - this->stateFlags2 |= 0x8000000; - func_80835EA4(globalCtx, (this->unk_6A8 != NULL) ? 0x5B : 0x5A); - if (this->unk_6A8 != NULL) { - this->stateFlags2 |= 0x2000000; - Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, this->unk_6A8); - } - } - } else if (func_8083AD4C(globalCtx, this)) { - if (!(this->stateFlags1 & 0x800000)) { - func_80835C58(globalCtx, this, func_8084B1D8, 1); - this->unk_850 = 13; - func_8083B010(this); - } - this->stateFlags1 |= 0x100000; - func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); - func_80832210(this); - return 1; - } else { - this->unk_6AD = 0; - func_80078884(NA_SE_SY_ERROR); - return 0; - } - - this->stateFlags1 |= 0x30000000; - } - - func_80832224(this); - return 1; - } - - return 0; -} - -s32 func_8083B644(Player* this, GlobalContext* globalCtx) { - Actor* sp34 = this->targetActor; - Actor* sp30 = this->unk_664; - Actor* sp2C = NULL; - s32 sp28 = 0; - s32 sp24; - - sp24 = (sp30 != NULL) && (CHECK_FLAG_ALL(sp30->flags, ACTOR_FLAG_0 | ACTOR_FLAG_18) || (sp30->naviEnemyId != 0xFF)); - - if (sp24 || (this->naviTextId != 0)) { - sp28 = (this->naviTextId < 0) && ((ABS(this->naviTextId) & 0xFF00) != 0x200); - if (sp28 || !sp24) { - sp2C = this->naviActor; - if (sp28) { - sp30 = NULL; - sp34 = NULL; - } - } else { - sp2C = sp30; - } - } - - if ((sp34 != NULL) || (sp2C != NULL)) { - if ((sp30 == NULL) || (sp30 == sp34) || (sp30 == sp2C)) { - if (!(this->stateFlags1 & 0x800) || - ((this->heldActor != NULL) && (sp28 || (sp34 == this->heldActor) || (sp2C == this->heldActor) || - ((sp34 != NULL) && (sp34->flags & ACTOR_FLAG_16))))) { - if ((this->actor.bgCheckFlags & 1) || (this->stateFlags1 & 0x800000) || - (func_808332B8(this) && !(this->stateFlags2 & 0x400))) { - - if (sp34 != NULL) { - this->stateFlags2 |= 2; - if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (sp34->flags & ACTOR_FLAG_16)) { - sp2C = NULL; - } else if (sp2C == NULL) { - return 0; - } - } - - if (sp2C != NULL) { - if (!sp28) { - this->stateFlags2 |= 0x200000; - } - - if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && !sp28) { - return 0; - } - - sp34 = sp2C; - this->targetActor = NULL; - - if (sp28 || !sp24) { - if (this->naviTextId >= 0) { - sp2C->textId = this->naviTextId; - } else { - sp2C->textId = -this->naviTextId; - } - } else { - if (sp2C->naviEnemyId != 0xFF) { - sp2C->textId = sp2C->naviEnemyId + 0x600; - } - } - } - - this->currentMask = D_80858AA4; - func_80853148(globalCtx, sp34); - return 1; - } - } - } - } - - return 0; -} - -s32 func_8083B8F4(Player* this, GlobalContext* globalCtx) { - if (!(this->stateFlags1 & 0x800800) && Camera_CheckValidMode(Gameplay_GetCamera(globalCtx, 0), 6)) { - if ((this->actor.bgCheckFlags & 1) || - (func_808332B8(this) && (this->actor.yDistToWater < this->ageProperties->unk_2C))) { - this->unk_6AD = 1; - return 1; - } - } - - return 0; -} - -s32 func_8083B998(Player* this, GlobalContext* globalCtx) { - if (this->unk_6AD != 0) { - func_8083B040(this, globalCtx); - return 1; - } - - if ((this->unk_664 != NULL) && - (CHECK_FLAG_ALL(this->unk_664->flags, ACTOR_FLAG_0 | ACTOR_FLAG_18) || (this->unk_664->naviEnemyId != 0xFF))) { - this->stateFlags2 |= 0x200000; - } else if ((this->naviTextId == 0) && !func_8008E9C4(this) && CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && - (YREG(15) != 0x10) && (YREG(15) != 0x20) && !func_8083B8F4(this, globalCtx)) { - func_80078884(NA_SE_SY_ERROR); - } - - return 0; -} - -void func_8083BA90(GlobalContext* globalCtx, Player* this, s32 arg2, f32 xzVelocity, f32 yVelocity) { - func_80837948(globalCtx, this, arg2); - func_80835C58(globalCtx, this, func_80844AF4, 0); - - this->stateFlags3 |= 2; - - this->currentYaw = this->actor.shape.rot.y; - this->linearVelocity = xzVelocity; - this->actor.velocity.y = yVelocity; - - this->actor.bgCheckFlags &= ~1; - this->hoverBootsTimer = 0; - - func_80832854(this); - func_80832698(this, NA_SE_VO_LI_SWORD_L); -} - -s32 func_8083BB20(Player* this) { - if (!(this->stateFlags1 & 0x400000) && (Player_GetSwordHeld(this) != 0)) { - if (D_80853614 || - ((this->actor.category != ACTORCAT_PLAYER) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B))) { - return 1; - } - } - - return 0; -} - -s32 func_8083BBA0(Player* this, GlobalContext* globalCtx) { - if (func_8083BB20(this) && (D_808535E4 != 7)) { - func_8083BA90(globalCtx, this, 17, 3.0f, 4.5f); - return 1; - } - - return 0; -} - -void func_8083BC04(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80844708, 0); - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, D_80853A94[this->modelAnimType], 1.25f * D_808535E8); -} - -s32 func_8083BC7C(Player* this, GlobalContext* globalCtx) { - if ((this->unk_84B[this->unk_846] == 0) && (D_808535E4 != 7)) { - func_8083BC04(this, globalCtx); - return 1; - } - - return 0; -} - -void func_8083BCD0(Player* this, GlobalContext* globalCtx, s32 arg2) { - func_80838940(this, D_80853D4C[arg2][0], !(arg2 & 1) ? 5.8f : 3.5f, globalCtx, NA_SE_VO_LI_SWORD_N); - - if (arg2) {} - - this->unk_850 = 1; - this->unk_84F = arg2; - - this->currentYaw = this->actor.shape.rot.y + (arg2 << 0xE); - this->linearVelocity = !(arg2 & 1) ? 6.0f : 8.5f; - - this->stateFlags2 |= 0x80000; - - func_8002F7DC(&this->actor, ((arg2 << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP); -} - -s32 func_8083BDBC(Player* this, GlobalContext* globalCtx) { - s32 sp2C; - - if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (globalCtx->roomCtx.curRoom.unk_03 != 2) && - (D_808535E4 != 7) && - (SurfaceType_GetSlope(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) != 1)) { - sp2C = this->unk_84B[this->unk_846]; - - if (sp2C <= 0) { - if (func_80833BCC(this)) { - if (this->actor.category != ACTORCAT_PLAYER) { - if (sp2C < 0) { - func_808389E8(this, &gPlayerAnim_002FE0, REG(69) / 100.0f, globalCtx); - } else { - func_8083BC04(this, globalCtx); - } - } else { - if (Player_GetSwordHeld(this) && func_808365C8(this)) { - func_8083BA90(globalCtx, this, 17, 5.0f, 5.0f); - } else { - func_8083BC04(this, globalCtx); - } - } - return 1; - } - } else { - func_8083BCD0(this, globalCtx, sp2C); - return 1; - } - } - - return 0; -} - -void func_8083BF50(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - f32 sp30; - - sp30 = this->unk_868 - 3.0f; - if (sp30 < 0.0f) { - sp30 += 29.0f; - } - - if (sp30 < 14.0f) { - anim = D_80853AC4[this->modelAnimType]; - sp30 = 11.0f - sp30; - if (sp30 < 0.0f) { - sp30 = 1.375f * -sp30; - } - sp30 /= 11.0f; - } else { - anim = D_80853ADC[this->modelAnimType]; - sp30 = 26.0f - sp30; - if (sp30 < 0.0f) { - sp30 = 2 * -sp30; - } - sp30 /= 12.0f; - } - - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, - 4.0f * sp30); - this->currentYaw = this->actor.shape.rot.y; -} - -void func_8083C0B8(Player* this, GlobalContext* globalCtx) { - func_80839FFC(this, globalCtx); - func_8083BF50(this, globalCtx); -} - -void func_8083C0E8(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80840BC8, 1); - func_80832264(globalCtx, this, func_80833338(this)); - this->currentYaw = this->actor.shape.rot.y; -} - -void func_8083C148(Player* this, GlobalContext* globalCtx) { - if (!(this->stateFlags3 & 0x80)) { - func_8083B010(this); - if (this->stateFlags1 & 0x8000000) { - func_80838F18(globalCtx, this); - } else { - func_80839F90(this, globalCtx); - } - if (this->unk_6AD < 4) { - this->unk_6AD = 0; - } - } - - this->stateFlags1 &= ~0x106000; -} - -s32 func_8083C1DC(Player* this, GlobalContext* globalCtx) { - if (!func_80833B54(this) && (D_808535E0 == 0) && !(this->stateFlags1 & 0x800000) && - CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { - if (func_8083BC7C(this, globalCtx)) { - return 1; - } - if ((this->unk_837 == 0) && (this->heldItemActionParam >= PLAYER_AP_SWORD_MASTER)) { - func_80835F44(globalCtx, this, ITEM_NONE); - } else { - this->stateFlags2 ^= 0x100000; - } - } - - return 0; -} - -s32 func_8083C2B0(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - f32 frame; - - if ((globalCtx->shootingGalleryStatus == 0) && (this->currentShield != PLAYER_SHIELD_NONE) && - CHECK_BTN_ALL(sControlInput->cur.button, BTN_R) && - (Player_IsChildWithHylianShield(this) || (!func_80833B2C(this) && (this->unk_664 == NULL)))) { - - func_80832318(this); - func_808323B4(globalCtx, this); - - if (func_80835C58(globalCtx, this, func_80843188, 0)) { - this->stateFlags1 |= 0x400000; - - if (!Player_IsChildWithHylianShield(this)) { - Player_SetModelsForHoldingShield(this); - anim = D_80853AF4[this->modelAnimType]; - } else { - anim = &gPlayerAnim_002400; - } - - if (anim != this->skelAnime.animation) { - if (func_8008E9C4(this)) { - this->unk_86C = 1.0f; - } else { - this->unk_86C = 0.0f; - func_80833C3C(this); - } - this->unk_6BC = this->unk_6BE = this->unk_6C0 = 0; - } - - frame = Animation_GetLastFrame(anim); - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); - - if (Player_IsChildWithHylianShield(this)) { - func_80832F54(globalCtx, this, 4); - } - - func_8002F7DC(&this->actor, NA_SE_IT_SHIELD_POSTURE); - } - - return 1; - } - - return 0; -} - -s32 func_8083C484(Player* this, f32* arg1, s16* arg2) { - s16 yaw = this->currentYaw - *arg2; - - if (ABS(yaw) > 0x6000) { - if (func_8083721C(this)) { - *arg1 = 0.0f; - *arg2 = this->currentYaw; - } else { - return 1; - } - } - - return 0; -} - -void func_8083C50C(Player* this) { - if ((this->unk_844 > 0) && !CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { - this->unk_844 = -this->unk_844; - } -} - -s32 func_8083C544(Player* this, GlobalContext* globalCtx) { - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { - if (!(this->stateFlags1 & 0x400000) && (Player_GetSwordHeld(this) != 0) && (this->unk_844 == 1) && - (this->heldItemActionParam != PLAYER_AP_STICK)) { - if ((this->heldItemActionParam != PLAYER_AP_SWORD_BGS) || (gSaveContext.swordHealth > 0.0f)) { - func_808377DC(globalCtx, this); - return 1; - } - } - } else { - func_8083C50C(this); - } - - return 0; -} - -s32 func_8083C61C(GlobalContext* globalCtx, Player* this) { - if ((globalCtx->roomCtx.curRoom.unk_03 != 2) && (this->actor.bgCheckFlags & 1) && (AMMO(ITEM_NUT) != 0)) { - func_80835C58(globalCtx, this, func_8084E604, 0); - func_80832264(globalCtx, this, &gPlayerAnim_003048); - this->unk_6AD = 0; - return 1; - } - - return 0; -} - -static struct_80854554 D_80854554[] = { - { &gPlayerAnim_002648, &gPlayerAnim_002640, 2, 3 }, - { &gPlayerAnim_002680, &gPlayerAnim_002678, 5, 3 }, -}; - -s32 func_8083C6B8(GlobalContext* globalCtx, Player* this) { - Vec3f sp24; - - if (D_80853614) { - if (Player_GetBottleHeld(this) >= 0) { - func_80835C58(globalCtx, this, func_8084ECA4, 0); - - if (this->actor.yDistToWater > 12.0f) { - this->unk_850 = 1; - } - - func_808322D0(globalCtx, this, D_80854554[this->unk_850].unk_00); - - func_8002F7DC(&this->actor, NA_SE_IT_SWORD_SWING); - func_80832698(this, NA_SE_VO_LI_AUTO_JUMP); - return 1; - } - - if (this->heldItemActionParam == PLAYER_AP_FISHING_POLE) { - sp24 = this->actor.world.pos; - sp24.y += 50.0f; - - if (!(this->actor.bgCheckFlags & 1) || (this->actor.world.pos.z > 1300.0f) || - BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sp24, 20.0f)) { - func_80078884(NA_SE_SY_ERROR); - return 0; - } - - func_80835C58(globalCtx, this, func_80850C68, 0); - this->unk_860 = 1; - func_80832210(this); - func_80832264(globalCtx, this, &gPlayerAnim_002C30); - return 1; - } else { - return 0; - } - } - - return 0; -} - -void func_8083C858(Player* this, GlobalContext* globalCtx) { - PlayerFunc674 func; - - if (func_80833BCC(this)) { - func = func_8084227C; - } else { - func = func_80842180; - } - - func_80835C58(globalCtx, this, func, 1); - func_80832BE8(globalCtx, this, D_80853944[this->modelAnimType]); - - this->unk_89C = 0; - this->unk_864 = this->unk_868 = 0.0f; -} - -void func_8083C8DC(Player* this, GlobalContext* globalCtx, s16 arg2) { - this->actor.shape.rot.y = this->currentYaw = arg2; - func_8083C858(this, globalCtx); -} - -s32 func_8083C910(GlobalContext* globalCtx, Player* this, f32 arg2) { - WaterBox* sp2C; - f32 sp28; - - sp28 = this->actor.world.pos.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp28, - &sp2C) != 0) { - sp28 -= this->actor.world.pos.y; - if (this->ageProperties->unk_24 <= sp28) { - func_80835C58(globalCtx, this, func_8084D7C4, 0); - func_80832C6C(globalCtx, this, &gPlayerAnim_0032F0); - this->stateFlags1 |= 0x28000000; - this->unk_850 = 20; - this->linearVelocity = 2.0f; - Player_SetBootData(globalCtx, this); - return 0; - } - } - - func_80838E70(globalCtx, this, arg2, this->actor.shape.rot.y); - this->stateFlags1 |= 0x20000000; - return 1; -} - -void func_8083CA20(GlobalContext* globalCtx, Player* this) { - if (func_8083C910(globalCtx, this, 180.0f)) { - this->unk_850 = -20; - } -} - -void func_8083CA54(GlobalContext* globalCtx, Player* this) { - this->linearVelocity = 2.0f; - gSaveContext.entranceSpeed = 2.0f; - if (func_8083C910(globalCtx, this, 120.0f)) { - this->unk_850 = -15; - } -} - -void func_8083CA9C(GlobalContext* globalCtx, Player* this) { - if (gSaveContext.entranceSpeed < 0.1f) { - gSaveContext.entranceSpeed = 0.1f; - } - - this->linearVelocity = gSaveContext.entranceSpeed; - - if (func_8083C910(globalCtx, this, 800.0f)) { - this->unk_850 = -80 / this->linearVelocity; - if (this->unk_850 < -20) { - this->unk_850 = -20; - } - } -} - -void func_8083CB2C(Player* this, s16 yaw, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_808414F8, 1); - LinkAnimation_CopyJointToMorph(globalCtx, &this->skelAnime); - this->unk_864 = this->unk_868 = 0.0f; - this->currentYaw = yaw; -} - -void func_8083CB94(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80840DE4, 1); - func_80832BE8(globalCtx, this, D_8085392C[this->modelAnimType]); -} - -void func_8083CBF0(Player* this, s16 yaw, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_808423EC, 1); - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_0024F8, 2.2f, 0.0f, - Animation_GetLastFrame(&gPlayerAnim_0024F8), ANIMMODE_ONCE, -6.0f); - this->linearVelocity = 8.0f; - this->currentYaw = yaw; -} - -void func_8083CC9C(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084193C, 1); - func_80832BE8(globalCtx, this, D_80853B6C[this->modelAnimType]); - this->unk_868 = 0.0f; -} - -void func_8083CD00(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084251C, 1); - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, &gPlayerAnim_0024E8, 2.0f); -} - -void func_8083CD54(GlobalContext* globalCtx, Player* this, s16 yaw) { - this->currentYaw = yaw; - func_80835C58(globalCtx, this, func_80841BA8, 1); - this->unk_87E = 1200; - this->unk_87E *= D_808535E8; - LinkAnimation_Change(globalCtx, &this->skelAnime, D_80853B84[this->modelAnimType], 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, - -6.0f); -} - -void func_8083CE0C(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - - func_80835C58(globalCtx, this, func_80840BC8, 1); - - if (this->unk_870 < 0.5f) { - anim = D_80853BB4[this->modelAnimType]; - } else { - anim = D_80853B9C[this->modelAnimType]; - } - func_80832264(globalCtx, this, anim); - - this->currentYaw = this->actor.shape.rot.y; -} - -void func_8083CEAC(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80840450, 1); - func_80832B0C(globalCtx, this, D_808539BC[this->modelAnimType]); - this->unk_850 = 1; -} - -void func_8083CF10(Player* this, GlobalContext* globalCtx) { - if (this->linearVelocity != 0.0f) { - func_8083C858(this, globalCtx); - } else { - func_8083CE0C(this, globalCtx); - } -} - -void func_8083CF5C(Player* this, GlobalContext* globalCtx) { - if (this->linearVelocity != 0.0f) { - func_8083C858(this, globalCtx); - } else { - func_80839F90(this, globalCtx); - } -} - -s32 func_8083CFA8(GlobalContext* globalCtx, Player* this, f32 arg2, s32 splashScale) { - f32 sp3C = fabsf(arg2); - WaterBox* sp38; - f32 sp34; - Vec3f splashPos; - s32 splashType; - - if (sp3C > 2.0f) { - splashPos.x = this->bodyPartsPos[0].x; - splashPos.z = this->bodyPartsPos[0].z; - sp34 = this->actor.world.pos.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, splashPos.x, splashPos.z, &sp34, &sp38)) { - if ((sp34 - this->actor.world.pos.y) < 100.0f) { - splashType = (sp3C <= 10.0f) ? 0 : 1; - splashPos.y = sp34; - EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, splashType, splashScale); - return 1; - } - } - } - - return 0; -} - -void func_8083D0A8(GlobalContext* globalCtx, Player* this, f32 arg2) { - this->stateFlags1 |= 0x40000; - this->stateFlags1 &= ~0x8000000; - - func_80832340(globalCtx, this); - if (func_8083CFA8(globalCtx, this, arg2, 500)) { - func_8002F7DC(&this->actor, NA_SE_EV_JUMP_OUT_WATER); - } - - Player_SetBootData(globalCtx, this); -} - -s32 func_8083D12C(GlobalContext* globalCtx, Player* this, Input* arg2) { - if (!(this->stateFlags1 & 0x400) && !(this->stateFlags2 & 0x400)) { - if ((arg2 == NULL) || (CHECK_BTN_ALL(arg2->press.button, BTN_A) && (ABS(this->unk_6C2) < 12000) && - (this->currentBoots != PLAYER_BOOTS_IRON))) { - - func_80835C58(globalCtx, this, func_8084DC48, 0); - func_80832264(globalCtx, this, &gPlayerAnim_003308); - - this->unk_6C2 = 0; - this->stateFlags2 |= 0x400; - this->actor.velocity.y = 0.0f; - - if (arg2 != NULL) { - this->stateFlags2 |= 0x800; - func_8002F7DC(&this->actor, NA_SE_PL_DIVE_BUBBLE); - } - - return 1; - } - } - - if ((this->stateFlags1 & 0x400) || (this->stateFlags2 & 0x400)) { - if (this->actor.velocity.y > 0.0f) { - if (this->actor.yDistToWater < this->ageProperties->unk_30) { - - this->stateFlags2 &= ~0x400; - - if (arg2 != NULL) { - func_80835C58(globalCtx, this, func_8084E1EC, 1); - - if (this->stateFlags1 & 0x400) { - this->stateFlags1 |= 0x20000C00; - } - - this->unk_850 = 2; - } - - func_80832340(globalCtx, this); - func_80832B0C(globalCtx, this, (this->stateFlags1 & 0x800) ? &gPlayerAnim_003318 : &gPlayerAnim_003300); - - if (func_8083CFA8(globalCtx, this, this->actor.velocity.y, 500)) { - func_8002F7DC(&this->actor, NA_SE_PL_FACE_UP); - } - - return 1; - } - } - } - - return 0; -} - -void func_8083D330(GlobalContext* globalCtx, Player* this) { - func_80832284(globalCtx, this, &gPlayerAnim_0032F0); - this->unk_6C2 = 16000; - this->unk_850 = 1; -} - -void func_8083D36C(GlobalContext* globalCtx, Player* this) { - if ((this->currentBoots != PLAYER_BOOTS_IRON) || !(this->actor.bgCheckFlags & 1)) { - func_80832564(globalCtx, this); - - if ((this->currentBoots != PLAYER_BOOTS_IRON) && (this->stateFlags2 & 0x400)) { - this->stateFlags2 &= ~0x400; - func_8083D12C(globalCtx, this, 0); - this->unk_84F = 1; - } else if (func_80844A44 == this->func_674) { - func_80835C58(globalCtx, this, func_8084DC48, 0); - func_8083D330(globalCtx, this); - } else { - func_80835C58(globalCtx, this, func_8084D610, 1); - func_80832B0C(globalCtx, this, (this->actor.bgCheckFlags & 1) ? &gPlayerAnim_003330 : &gPlayerAnim_0032E0); - } - } - - if (!(this->stateFlags1 & 0x8000000) || (this->actor.yDistToWater < this->ageProperties->unk_2C)) { - if (func_8083CFA8(globalCtx, this, this->actor.velocity.y, 500)) { - func_8002F7DC(&this->actor, NA_SE_EV_DIVE_INTO_WATER); - - if (this->fallDistance > 800.0f) { - func_80832698(this, NA_SE_VO_LI_CLIMB_END); - } - } - } - - this->stateFlags1 |= 0x8000000; - this->stateFlags2 |= 0x400; - this->stateFlags1 &= ~0xC0000; - this->unk_854 = 0.0f; - - Player_SetBootData(globalCtx, this); -} - -void func_8083D53C(GlobalContext* globalCtx, Player* this) { - if (this->actor.yDistToWater < this->ageProperties->unk_2C) { - Audio_SetBaseFilter(0); - this->unk_840 = 0; - } else { - Audio_SetBaseFilter(0x20); - if (this->unk_840 < 300) { - this->unk_840++; - } - } - - if ((func_80845668 != this->func_674) && (func_8084BDFC != this->func_674)) { - if (this->ageProperties->unk_2C < this->actor.yDistToWater) { - if (!(this->stateFlags1 & 0x8000000) || - (!((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) && - (func_8084E30C != this->func_674) && (func_8084E368 != this->func_674) && - (func_8084D610 != this->func_674) && (func_8084D84C != this->func_674) && - (func_8084DAB4 != this->func_674) && (func_8084DC48 != this->func_674) && - (func_8084E1EC != this->func_674) && (func_8084D7C4 != this->func_674))) { - func_8083D36C(globalCtx, this); - return; - } - } else if ((this->stateFlags1 & 0x8000000) && (this->actor.yDistToWater < this->ageProperties->unk_24)) { - if ((this->skelAnime.moveFlags == 0) && (this->currentBoots != PLAYER_BOOTS_IRON)) { - func_8083CD54(globalCtx, this, this->actor.shape.rot.y); - } - func_8083D0A8(globalCtx, this, this->actor.velocity.y); - } - } -} - -void func_8083D6EC(GlobalContext* globalCtx, Player* this) { - Vec3f ripplePos; - f32 temp1; - f32 temp2; - f32 temp3; - f32 temp4; - - this->actor.minVelocityY = -20.0f; - this->actor.gravity = REG(68) / 100.0f; - - if (func_8083816C(D_808535E4)) { - temp1 = fabsf(this->linearVelocity) * 20.0f; - temp3 = 0.0f; - - if (D_808535E4 == 4) { - if (this->unk_6C4 > 1300.0f) { - temp2 = this->unk_6C4; - } else { - temp2 = 1300.0f; - } - if (this->currentBoots == PLAYER_BOOTS_HOVER) { - temp1 += temp1; - } else if (this->currentBoots == PLAYER_BOOTS_IRON) { - temp1 *= 0.3f; - } - } else { - temp2 = 20000.0f; - if (this->currentBoots != PLAYER_BOOTS_HOVER) { - temp1 += temp1; - } else if ((D_808535E4 == 7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { - temp1 = 0; - } - } - - if (this->currentBoots != PLAYER_BOOTS_HOVER) { - temp3 = (temp2 - this->unk_6C4) * 0.02f; - temp3 = CLAMP(temp3, 0.0f, 300.0f); - if (this->currentBoots == PLAYER_BOOTS_IRON) { - temp3 += temp3; - } - } - - this->unk_6C4 += temp3 - temp1; - this->unk_6C4 = CLAMP(this->unk_6C4, 0.0f, temp2); - - this->actor.gravity -= this->unk_6C4 * 0.004f; - } else { - this->unk_6C4 = 0.0f; - } - - if (this->actor.bgCheckFlags & 0x20) { - if (this->actor.yDistToWater < 50.0f) { - temp4 = fabsf(this->bodyPartsPos[0].x - this->unk_A88.x) + - fabsf(this->bodyPartsPos[0].y - this->unk_A88.y) + fabsf(this->bodyPartsPos[0].z - this->unk_A88.z); - if (temp4 > 4.0f) { - temp4 = 4.0f; - } - this->unk_854 += temp4; - - if (this->unk_854 > 15.0f) { - this->unk_854 = 0.0f; - - ripplePos.x = (Rand_ZeroOne() * 10.0f) + this->actor.world.pos.x; - ripplePos.y = this->actor.world.pos.y + this->actor.yDistToWater; - ripplePos.z = (Rand_ZeroOne() * 10.0f) + this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 0); - - if ((this->linearVelocity > 4.0f) && !func_808332B8(this) && - ((this->actor.world.pos.y + this->actor.yDistToWater) < this->bodyPartsPos[0].y)) { - func_8083CFA8(globalCtx, this, 20.0f, - (fabsf(this->linearVelocity) * 50.0f) + (this->actor.yDistToWater * 5.0f)); - } - } - } - - if (this->actor.yDistToWater > 40.0f) { - s32 numBubbles = 0; - s32 i; - - if ((this->actor.velocity.y > -1.0f) || (this->actor.bgCheckFlags & 1)) { - if (Rand_ZeroOne() < 0.2f) { - numBubbles = 1; - } - } else { - numBubbles = this->actor.velocity.y * -2.0f; - } - - for (i = 0; i < numBubbles; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 20.0f, 10.0f, 20.0f, 0.13f); - } - } - } -} - -s32 func_8083DB98(Player* this, s32 arg1) { - Actor* unk_664 = this->unk_664; - Vec3f sp30; - s16 sp2E; - s16 sp2C; - - sp30.x = this->actor.world.pos.x; - sp30.y = this->bodyPartsPos[7].y + 3.0f; - sp30.z = this->actor.world.pos.z; - sp2E = Math_Vec3f_Pitch(&sp30, &unk_664->focus.pos); - sp2C = Math_Vec3f_Yaw(&sp30, &unk_664->focus.pos); - Math_SmoothStepToS(&this->actor.focus.rot.y, sp2C, 4, 10000, 0); - Math_SmoothStepToS(&this->actor.focus.rot.x, sp2E, 4, 10000, 0); - this->unk_6AE |= 2; - - return func_80836AB8(this, arg1); -} - -static Vec3f D_8085456C = { 0.0f, 100.0f, 40.0f }; - -void func_8083DC54(Player* this, GlobalContext* globalCtx) { - s16 sp46; - s16 temp2; - f32 temp1; - Vec3f sp34; - - if (this->unk_664 != NULL) { - if (func_8002DD78(this) || func_808334B4(this)) { - func_8083DB98(this, 1); - } else { - func_8083DB98(this, 0); - } - return; - } - - if (D_808535E4 == 11) { - Math_SmoothStepToS(&this->actor.focus.rot.x, -20000, 10, 4000, 800); - } else { - sp46 = 0; - temp1 = func_8083973C(globalCtx, this, &D_8085456C, &sp34); - if (temp1 > BGCHECK_Y_MIN) { - temp2 = Math_Atan2S(40.0f, this->actor.world.pos.y - temp1); - sp46 = CLAMP(temp2, -4000, 4000); - } - this->actor.focus.rot.y = this->actor.shape.rot.y; - Math_SmoothStepToS(&this->actor.focus.rot.x, sp46, 14, 4000, 30); - } - - func_80836AB8(this, func_8002DD78(this) || func_808334B4(this)); -} - -void func_8083DDC8(Player* this, GlobalContext* globalCtx) { - s16 temp1; - s16 temp2; - - if (!func_8002DD78(this) && !func_808334B4(this) && (this->linearVelocity > 5.0f)) { - temp1 = this->linearVelocity * 200.0f; - temp2 = (s16)(this->currentYaw - this->actor.shape.rot.y) * this->linearVelocity * 0.1f; - temp1 = CLAMP(temp1, -4000, 4000); - temp2 = CLAMP(-temp2, -4000, 4000); - Math_ScaledStepToS(&this->unk_6BC, temp1, 900); - this->unk_6B6 = -(f32)this->unk_6BC * 0.5f; - Math_ScaledStepToS(&this->unk_6BA, temp2, 300); - Math_ScaledStepToS(&this->unk_6C0, temp2, 200); - this->unk_6AE |= 0x168; - } else { - func_8083DC54(this, globalCtx); - } -} - -void func_8083DF68(Player* this, f32 arg1, s16 arg2) { - Math_AsymStepToF(&this->linearVelocity, arg1, REG(19) / 100.0f, 1.5f); - Math_ScaledStepToS(&this->currentYaw, arg2, REG(27)); -} - -void func_8083DFE0(Player* this, f32* arg1, s16* arg2) { - s16 yawDiff = this->currentYaw - *arg2; - - if (this->swordState == 0) { - this->linearVelocity = CLAMP(this->linearVelocity, -(R_RUN_SPEED_LIMIT / 100.0f), (R_RUN_SPEED_LIMIT / 100.0f)); - } - - if (ABS(yawDiff) > 0x6000) { - if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = *arg2; - } - } else { - Math_AsymStepToF(&this->linearVelocity, *arg1, 0.05f, 0.1f); - Math_ScaledStepToS(&this->currentYaw, *arg2, 200); - } -} - -static struct_80854578 D_80854578[] = { - { &gPlayerAnim_003398, 35.17f, 6.6099997f }, - { &gPlayerAnim_0033A8, -34.16f, 7.91f }, -}; - -s32 func_8083E0FC(Player* this, GlobalContext* globalCtx) { - EnHorse* rideActor = (EnHorse*)this->rideActor; - f32 unk_04; - f32 unk_08; - f32 sp38; - f32 sp34; - s32 temp; - - if ((rideActor != NULL) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { - sp38 = Math_CosS(rideActor->actor.shape.rot.y); - sp34 = Math_SinS(rideActor->actor.shape.rot.y); - - func_80836898(globalCtx, this, func_8083A360); - - this->stateFlags1 |= 0x800000; - this->actor.bgCheckFlags &= ~0x20; - - if (this->mountSide < 0) { - temp = 0; - } else { - temp = 1; - } - - unk_04 = D_80854578[temp].unk_04; - unk_08 = D_80854578[temp].unk_08; - this->actor.world.pos.x = - rideActor->actor.world.pos.x + rideActor->riderPos.x + ((unk_04 * sp38) + (unk_08 * sp34)); - this->actor.world.pos.z = - rideActor->actor.world.pos.z + rideActor->riderPos.z + ((unk_08 * sp38) - (unk_04 * sp34)); - - this->unk_878 = rideActor->actor.world.pos.y - this->actor.world.pos.y; - this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; - - Actor_MountHorse(globalCtx, this, &rideActor->actor); - func_80832264(globalCtx, this, D_80854578[temp].anim); - func_80832F54(globalCtx, this, 0x9B); - this->actor.parent = this->rideActor; - func_80832224(this); - func_800304B0(globalCtx); - return 1; - } - - return 0; -} - -void func_8083E298(CollisionPoly* arg0, Vec3f* arg1, s16* arg2) { - arg1->x = COLPOLY_GET_NORMAL(arg0->normal.x); - arg1->y = COLPOLY_GET_NORMAL(arg0->normal.y); - arg1->z = COLPOLY_GET_NORMAL(arg0->normal.z); - - *arg2 = Math_Atan2S(arg1->z, arg1->x); -} - -static LinkAnimationHeader* D_80854590[] = { - &gPlayerAnim_002EE0, - &gPlayerAnim_0031D0, -}; - -s32 func_8083E318(GlobalContext* globalCtx, Player* this, CollisionPoly* arg2) { - s32 pad; - s16 sp4A; - Vec3f sp3C; - s16 sp3A; - f32 temp1; - f32 temp2; - s16 temp3; - - if (!Player_InBlockingCsMode(globalCtx, this) && (func_8084F390 != this->func_674) && - (SurfaceType_GetSlope(&globalCtx->colCtx, arg2, this->actor.floorBgId) == 1)) { - sp4A = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - func_8083E298(arg2, &sp3C, &sp3A); - temp3 = sp3A - sp4A; - - if (ABS(temp3) > 16000) { - temp1 = (1.0f - sp3C.y) * 40.0f; - temp2 = (temp1 * temp1) * 0.015f; - if (temp2 < 1.2f) { - temp2 = 1.2f; - } - this->windDirection = sp3A; - Math_StepToF(&this->windSpeed, temp1, temp2); - } else { - func_80835C58(globalCtx, this, func_8084F390, 0); - func_80832564(globalCtx, this); - if (D_80853610 >= 0) { - this->unk_84F = 1; - } - func_80832BE8(globalCtx, this, D_80854590[this->unk_84F]); - this->linearVelocity = sqrtf(SQ(this->actor.velocity.x) + SQ(this->actor.velocity.z)); - this->currentYaw = sp4A; - return 1; - } - } - - return 0; -} - -// unknown data (unused) -static s32 D_80854598[] = { - 0xFFDB0871, 0xF8310000, 0x00940470, 0xF3980000, 0xFFB504A9, 0x0C9F0000, 0x08010402, -}; - -void func_8083E4C4(GlobalContext* globalCtx, Player* this, GetItemEntry* giEntry) { - s32 sp1C = giEntry->field & 0x1F; - - if (!(giEntry->field & 0x80)) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, sp1C | 0x8000); - if ((sp1C != 4) && (sp1C != 8) && (sp1C != 9) && (sp1C != 0xA) && (sp1C != 0) && (sp1C != 1) && (sp1C != 2) && - (sp1C != 0x14) && (sp1C != 0x13)) { - Item_Give(globalCtx, giEntry->itemId); - } - } else { - Item_Give(globalCtx, giEntry->itemId); - } - - func_80078884((this->getItemId < 0) ? NA_SE_SY_GET_BOXITEM : NA_SE_SY_GET_ITEM); -} - -s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) { - Actor* interactedActor = NULL; - - if (iREG(67) || (((interactedActor = this->interactRangeActor) != NULL) && - func_8002D53C(globalCtx, &globalCtx->actorCtx.titleCtx))) { - if (iREG(67) || (this->getItemId > GI_NONE)) { - if (iREG(67)) { - this->getItemId = iREG(68); - } - - if (this->getItemId < GI_MAX) { - GetItemEntry* giEntry = &sGetItemTable[this->getItemId - 1]; - - if ((interactedActor != &this->actor) && !iREG(67)) { - interactedActor->parent = &this->actor; - } - - iREG(67) = false; - - if ((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) || (globalCtx->sceneNum == SCENE_BOWLING)) { - func_808323B4(globalCtx, this); - func_8083AE40(this, giEntry->objectId); - - if (!(this->stateFlags2 & 0x400) || (this->currentBoots == PLAYER_BOOTS_IRON)) { - func_80836898(globalCtx, this, func_8083A434); - func_808322D0(globalCtx, this, &gPlayerAnim_002788); - func_80835EA4(globalCtx, 9); - } - - this->stateFlags1 |= 0x20000C00; - func_80832224(this); - return 1; - } - - func_8083E4C4(globalCtx, this, giEntry); - this->getItemId = GI_NONE; - } - } else if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && !(this->stateFlags1 & 0x800) && - !(this->stateFlags2 & 0x400)) { - if (this->getItemId != GI_NONE) { - GetItemEntry* giEntry = &sGetItemTable[-this->getItemId - 1]; - EnBox* chest = (EnBox*)interactedActor; - - if (giEntry->itemId != ITEM_NONE) { - if (((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) && (giEntry->field & 0x40)) || - ((Item_CheckObtainability(giEntry->itemId) != ITEM_NONE) && (giEntry->field & 0x20))) { - this->getItemId = -GI_RUPEE_BLUE; - giEntry = &sGetItemTable[GI_RUPEE_BLUE - 1]; - } - } - - func_80836898(globalCtx, this, func_8083A434); - this->stateFlags1 |= 0x20000C00; - func_8083AE40(this, giEntry->objectId); - this->actor.world.pos.x = - chest->dyna.actor.world.pos.x - (Math_SinS(chest->dyna.actor.shape.rot.y) * 29.4343f); - this->actor.world.pos.z = - chest->dyna.actor.world.pos.z - (Math_CosS(chest->dyna.actor.shape.rot.y) * 29.4343f); - this->currentYaw = this->actor.shape.rot.y = chest->dyna.actor.shape.rot.y; - func_80832224(this); - - if ((giEntry->itemId != ITEM_NONE) && (giEntry->gi >= 0) && - (Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) { - func_808322D0(globalCtx, this, this->ageProperties->unk_98); - func_80832F54(globalCtx, this, 0x28F); - chest->unk_1F4 = 1; - Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_SLOW_CHEST_CS); - } else { - func_80832264(globalCtx, this, &gPlayerAnim_002DF8); - chest->unk_1F4 = -1; - } - - return 1; - } - - if ((this->heldActor == NULL) || Player_HoldsHookshot(this)) { - if ((interactedActor->id == ACTOR_BG_TOKI_SWD) && LINK_IS_ADULT) { - s32 sp24 = this->itemActionParam; - - this->itemActionParam = PLAYER_AP_NONE; - this->modelAnimType = 0; - this->heldItemActionParam = this->itemActionParam; - func_80836898(globalCtx, this, func_8083A0F4); - - if (sp24 == PLAYER_AP_SWORD_MASTER) { - this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_AP_LAST_USED); - func_8083399C(globalCtx, this, PLAYER_AP_LAST_USED); - } else { - func_80835F44(globalCtx, this, ITEM_LAST_USED); - } - } else { - s32 strength = Player_GetStrength(); - - if ((interactedActor->id == ACTOR_EN_ISHI) && ((interactedActor->params & 0xF) == 1) && - (strength < PLAYER_STR_SILVER_G)) { - return 0; - } - - func_80836898(globalCtx, this, func_8083A0F4); - } - - func_80832224(this); - this->stateFlags1 |= 0x800; - return 1; - } - } - } - - return 0; -} - -void func_8083EA94(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80846578, 1); - func_80832264(globalCtx, this, D_80853BCC[this->modelAnimType]); -} - -s32 func_8083EAF0(Player* this, Actor* actor) { - if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_23) && - ((this->linearVelocity < 1.1f) || (actor->id == ACTOR_EN_BOM_CHU))) { - return 0; - } - - return 1; -} - -s32 func_8083EB44(Player* this, GlobalContext* globalCtx) { - if ((this->stateFlags1 & 0x800) && (this->heldActor != NULL) && - CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { - if (!func_80835644(globalCtx, this, this->heldActor)) { - if (!func_8083EAF0(this, this->heldActor)) { - func_80835C58(globalCtx, this, func_808464B0, 1); - func_80832264(globalCtx, this, D_80853BE4[this->modelAnimType]); - } else { - func_8083EA94(this, globalCtx); - } - } - return 1; - } - - return 0; -} - -s32 func_8083EC18(Player* this, GlobalContext* globalCtx, u32 arg2) { - if (this->wallHeight >= 79.0f) { - if (!(this->stateFlags1 & 0x8000000) || (this->currentBoots == PLAYER_BOOTS_IRON) || - (this->actor.yDistToWater < this->ageProperties->unk_2C)) { - s32 sp8C = (arg2 & 8) ? 2 : 0; - - if ((sp8C != 0) || (arg2 & 2) || - func_80041E4C(&globalCtx->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { - f32 phi_f20; - CollisionPoly* sp84 = this->actor.wallPoly; - f32 sp80; - f32 sp7C; - f32 phi_f12; - f32 phi_f14; - - phi_f20 = phi_f12 = 0.0f; - - if (sp8C != 0) { - sp80 = this->actor.world.pos.x; - sp7C = this->actor.world.pos.z; - } else { - Vec3f sp50[3]; - s32 i; - f32 sp48; - Vec3f* sp44 = &sp50[0]; - s32 pad; - - CollisionPoly_GetVerticesByBgId(sp84, this->actor.wallBgId, &globalCtx->colCtx, sp50); - - sp80 = phi_f12 = sp44->x; - sp7C = phi_f14 = sp44->z; - phi_f20 = sp44->y; - for (i = 1; i < 3; i++) { - sp44++; - if (sp80 > sp44->x) { - sp80 = sp44->x; - } else if (phi_f12 < sp44->x) { - phi_f12 = sp44->x; - } - - if (sp7C > sp44->z) { - sp7C = sp44->z; - } else if (phi_f14 < sp44->z) { - phi_f14 = sp44->z; - } - - if (phi_f20 > sp44->y) { - phi_f20 = sp44->y; - } - } - - sp80 = (sp80 + phi_f12) * 0.5f; - sp7C = (sp7C + phi_f14) * 0.5f; - - phi_f12 = ((this->actor.world.pos.x - sp80) * COLPOLY_GET_NORMAL(sp84->normal.z)) - - ((this->actor.world.pos.z - sp7C) * COLPOLY_GET_NORMAL(sp84->normal.x)); - sp48 = this->actor.world.pos.y - phi_f20; - - phi_f20 = ((f32)(s32)((sp48 / 15.000000223517418) + 0.5) * 15.000000223517418) - sp48; - phi_f12 = fabsf(phi_f12); - } - - if (phi_f12 < 8.0f) { - f32 sp3C = COLPOLY_GET_NORMAL(sp84->normal.x); - f32 sp38 = COLPOLY_GET_NORMAL(sp84->normal.z); - f32 sp34 = this->wallDistance; - LinkAnimationHeader* sp30; - - func_80836898(globalCtx, this, func_8083A3B0); - this->stateFlags1 |= 0x200000; - this->stateFlags1 &= ~0x8000000; - - if ((sp8C != 0) || (arg2 & 2)) { - if ((this->unk_84F = sp8C) != 0) { - if (this->actor.bgCheckFlags & 1) { - sp30 = &gPlayerAnim_002D80; - } else { - sp30 = &gPlayerAnim_002D68; - } - sp34 = (this->ageProperties->unk_38 - 1.0f) - sp34; - } else { - sp30 = this->ageProperties->unk_A4; - sp34 = sp34 - 1.0f; - } - this->unk_850 = -2; - this->actor.world.pos.y += phi_f20; - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; - } else { - sp30 = this->ageProperties->unk_A8; - this->unk_850 = -4; - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw; - } - - this->actor.world.pos.x = (sp34 * sp3C) + sp80; - this->actor.world.pos.z = (sp34 * sp38) + sp7C; - func_80832224(this); - Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); - func_80832264(globalCtx, this, sp30); - func_80832F54(globalCtx, this, 0x9F); - - return 1; - } - } - } - } - - return 0; -} - -void func_8083F070(Player* this, LinkAnimationHeader* anim, GlobalContext* globalCtx) { - func_80835DAC(globalCtx, this, func_8084C5F8, 0); - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, anim, (4.0f / 3.0f)); -} - -s32 func_8083F0C8(Player* this, GlobalContext* globalCtx, u32 arg2) { - CollisionPoly* wallPoly; - Vec3f sp50[3]; - f32 sp4C; - f32 phi_f2; - f32 sp44; - f32 phi_f12; - s32 i; - - if (!LINK_IS_ADULT && !(this->stateFlags1 & 0x8000000) && (arg2 & 0x30)) { - wallPoly = this->actor.wallPoly; - CollisionPoly_GetVerticesByBgId(wallPoly, this->actor.wallBgId, &globalCtx->colCtx, sp50); - - sp4C = phi_f2 = sp50[0].x; - sp44 = phi_f12 = sp50[0].z; - for (i = 1; i < 3; i++) { - if (sp4C > sp50[i].x) { - sp4C = sp50[i].x; - } else if (phi_f2 < sp50[i].x) { - phi_f2 = sp50[i].x; - } - - if (sp44 > sp50[i].z) { - sp44 = sp50[i].z; - } else if (phi_f12 < sp50[i].z) { - phi_f12 = sp50[i].z; - } - } - - sp4C = (sp4C + phi_f2) * 0.5f; - sp44 = (sp44 + phi_f12) * 0.5f; - - phi_f2 = ((this->actor.world.pos.x - sp4C) * COLPOLY_GET_NORMAL(wallPoly->normal.z)) - - ((this->actor.world.pos.z - sp44) * COLPOLY_GET_NORMAL(wallPoly->normal.x)); - - if (fabsf(phi_f2) < 8.0f) { - this->stateFlags2 |= 0x10000; - - if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { - f32 sp38 = COLPOLY_GET_NORMAL(wallPoly->normal.x); - f32 sp34 = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 sp30 = this->wallDistance; - - func_80836898(globalCtx, this, func_8083A40C); - this->stateFlags2 |= 0x40000; - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; - this->actor.world.pos.x = sp4C + (sp30 * sp38); - this->actor.world.pos.z = sp44 + (sp30 * sp34); - func_80832224(this); - this->actor.prevPos = this->actor.world.pos; - func_80832264(globalCtx, this, &gPlayerAnim_002708); - func_80832F54(globalCtx, this, 0x9D); - - return 1; - } - } - } - - return 0; -} - -s32 func_8083F360(GlobalContext* globalCtx, Player* this, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { - CollisionPoly* wallPoly; - s32 sp78; - Vec3f sp6C; - Vec3f sp60; - Vec3f sp54; - f32 yawCos; - f32 yawSin; - s32 temp; - f32 temp1; - f32 temp2; - - yawCos = Math_CosS(this->actor.shape.rot.y); - yawSin = Math_SinS(this->actor.shape.rot.y); - - sp6C.x = this->actor.world.pos.x + (arg4 * yawSin); - sp6C.z = this->actor.world.pos.z + (arg4 * yawCos); - sp60.x = this->actor.world.pos.x + (arg3 * yawSin); - sp60.z = this->actor.world.pos.z + (arg3 * yawCos); - sp60.y = sp6C.y = this->actor.world.pos.y + arg1; - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp6C, &sp60, &sp54, &this->actor.wallPoly, true, false, false, - true, &sp78)) { - wallPoly = this->actor.wallPoly; - - this->actor.bgCheckFlags |= 0x200; - this->actor.wallBgId = sp78; - - D_808535F0 = func_80041DB8(&globalCtx->colCtx, wallPoly, sp78); - - temp1 = COLPOLY_GET_NORMAL(wallPoly->normal.x); - temp2 = COLPOLY_GET_NORMAL(wallPoly->normal.z); - temp = Math_Atan2S(-temp2, -temp1); - Math_ScaledStepToS(&this->actor.shape.rot.y, temp, 800); - - this->currentYaw = this->actor.shape.rot.y; - this->actor.world.pos.x = sp54.x - (Math_SinS(this->actor.shape.rot.y) * arg2); - this->actor.world.pos.z = sp54.z - (Math_CosS(this->actor.shape.rot.y) * arg2); - - return 1; - } - - this->actor.bgCheckFlags &= ~0x200; - - return 0; -} - -s32 func_8083F524(GlobalContext* globalCtx, Player* this) { - return func_8083F360(globalCtx, this, 26.0f, this->ageProperties->unk_38 + 5.0f, 30.0f, 0.0f); -} - -s32 func_8083F570(Player* this, GlobalContext* globalCtx) { - s16 temp; - - if ((this->linearVelocity != 0.0f) && (this->actor.bgCheckFlags & 8) && (D_808535F0 & 0x30)) { - - temp = this->actor.shape.rot.y - this->actor.wallYaw; - if (this->linearVelocity < 0.0f) { - temp += 0x8000; - } - - if (ABS(temp) > 0x4000) { - func_80835C58(globalCtx, this, func_8084C81C, 0); - - if (this->linearVelocity > 0.0f) { - this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; - func_80832264(globalCtx, this, &gPlayerAnim_002700); - func_80832F54(globalCtx, this, 0x9D); - OnePointCutscene_Init(globalCtx, 9601, 999, NULL, MAIN_CAM); - } else { - this->actor.shape.rot.y = this->actor.wallYaw; - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_002708, -1.0f, - Animation_GetLastFrame(&gPlayerAnim_002708), 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(globalCtx, this, 0x9D); - OnePointCutscene_Init(globalCtx, 9602, 999, NULL, MAIN_CAM); - } - - this->currentYaw = this->actor.shape.rot.y; - func_80832210(this); - - return 1; - } - } - - return 0; -} - -void func_8083F72C(Player* this, LinkAnimationHeader* anim, GlobalContext* globalCtx) { - if (!func_80836898(globalCtx, this, func_8083A388)) { - func_80835C58(globalCtx, this, func_8084B78C, 0); - } - - func_80832264(globalCtx, this, anim); - func_80832224(this); - - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; -} - -s32 func_8083F7BC(Player* this, GlobalContext* globalCtx) { - DynaPolyActor* wallPolyActor; - - if (!(this->stateFlags1 & 0x800) && (this->actor.bgCheckFlags & 0x200) && (D_80853608 < 0x3000)) { - - if (((this->linearVelocity > 0.0f) && func_8083EC18(this, globalCtx, D_808535F0)) || - func_8083F0C8(this, globalCtx, D_808535F0)) { - return 1; - } - - if (!func_808332B8(this) && ((this->linearVelocity == 0.0f) || !(this->stateFlags2 & 4)) && - (D_808535F0 & 0x40) && (this->actor.bgCheckFlags & 1) && (this->wallHeight >= 39.0f)) { - - this->stateFlags2 |= 1; - - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A)) { - - if ((this->actor.wallBgId != BGCHECK_SCENE) && - ((wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.wallBgId)) != NULL)) { - - if (wallPolyActor->actor.id == ACTOR_BG_HEAVY_BLOCK) { - if (Player_GetStrength() < PLAYER_STR_GOLD_G) { - return 0; - } - - func_80836898(globalCtx, this, func_8083A0F4); - this->stateFlags1 |= 0x800; - this->interactRangeActor = &wallPolyActor->actor; - this->getItemId = GI_NONE; - this->currentYaw = this->actor.wallYaw + 0x8000; - func_80832224(this); - - return 1; - } - - this->unk_3C4 = &wallPolyActor->actor; - } else { - this->unk_3C4 = NULL; - } - - func_8083F72C(this, &gPlayerAnim_0030F8, globalCtx); - - return 1; - } - } - } - - return 0; -} - -s32 func_8083F9D0(GlobalContext* globalCtx, Player* this) { - if ((this->actor.bgCheckFlags & 0x200) && - ((this->stateFlags2 & 0x10) || CHECK_BTN_ALL(sControlInput->cur.button, BTN_A))) { - DynaPolyActor* wallPolyActor = NULL; - - if (this->actor.wallBgId != BGCHECK_SCENE) { - wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.wallBgId); - } - - if (&wallPolyActor->actor == this->unk_3C4) { - if (this->stateFlags2 & 0x10) { - return 1; - } else { - return 0; - } - } - } - - func_80839FFC(this, globalCtx); - func_80832264(globalCtx, this, &gPlayerAnim_003100); - this->stateFlags2 &= ~0x10; - return 1; -} - -void func_8083FAB8(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084B898, 0); - this->stateFlags2 |= 0x10; - func_80832264(globalCtx, this, &gPlayerAnim_0030F0); -} - -void func_8083FB14(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084B9E4, 0); - this->stateFlags2 |= 0x10; - func_80832264(globalCtx, this, D_80853C5C[this->modelAnimType]); -} - -void func_8083FB7C(Player* this, GlobalContext* globalCtx) { - this->stateFlags1 &= ~0x8200000; - func_80837B9C(this, globalCtx); - this->linearVelocity = -0.4f; -} - -s32 func_8083FBC0(Player* this, GlobalContext* globalCtx) { - if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (this->actor.bgCheckFlags & 0x200) && - ((D_808535F0 & 8) || (D_808535F0 & 2) || - func_80041E4C(&globalCtx->colCtx, this->actor.wallPoly, this->actor.wallBgId))) { - return 0; - } - - func_8083FB7C(this, globalCtx); - func_80832698(this, NA_SE_VO_LI_AUTO_JUMP); - return 1; -} - -s32 func_8083FC68(Player* this, f32 arg1, s16 arg2) { - f32 sp1C = (s16)(arg2 - this->actor.shape.rot.y); - f32 temp; - - if (this->unk_664 != NULL) { - func_8083DB98(this, func_8002DD78(this) || func_808334B4(this)); - } - - temp = fabsf(sp1C) / 32768.0f; - - if (arg1 > (((temp * temp) * 50.0f) + 6.0f)) { - return 1; - } else if (arg1 > (((1.0f - temp) * 10.0f) + 6.8f)) { - return -1; - } - - return 0; -} - -s32 func_8083FD78(Player* this, f32* arg1, s16* arg2, GlobalContext* globalCtx) { - s16 sp2E = *arg2 - this->targetYaw; - u16 sp2C = ABS(sp2E); - - if ((func_8002DD78(this) || func_808334B4(this)) && (this->unk_664 == NULL)) { - *arg1 *= Math_SinS(sp2C); - - if (*arg1 != 0.0f) { - *arg2 = (((sp2E >= 0) ? 1 : -1) << 0xE) + this->actor.shape.rot.y; - } else { - *arg2 = this->actor.shape.rot.y; - } - - if (this->unk_664 != NULL) { - func_8083DB98(this, 1); - } else { - Math_SmoothStepToS(&this->actor.focus.rot.x, sControlInput->rel.stick_y * 240.0f, 14, 4000, 30); - func_80836AB8(this, 1); - } - } else { - if (this->unk_664 != NULL) { - return func_8083FC68(this, *arg1, *arg2); - } else { - func_8083DC54(this, globalCtx); - if ((*arg1 != 0.0f) && (sp2C < 6000)) { - return 1; - } else if (*arg1 > Math_SinS((0x4000 - (sp2C >> 1))) * 200.0f) { - return -1; - } - } - } - - return 0; -} - -s32 func_8083FFB8(Player* this, f32* arg1, s16* arg2) { - s16 temp1 = *arg2 - this->actor.shape.rot.y; - u16 temp2 = ABS(temp1); - f32 temp3 = Math_CosS(temp2); - - *arg1 *= temp3; - - if (*arg1 != 0.0f) { - if (temp3 > 0) { - return 1; - } else { - return -1; - } - } - - return 0; -} - -s32 func_80840058(Player* this, f32* arg1, s16* arg2, GlobalContext* globalCtx) { - func_8083DC54(this, globalCtx); - - if ((*arg1 != 0.0f) || (ABS(this->unk_87C) > 400)) { - s16 temp1 = *arg2 - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); - u16 temp2 = (ABS(temp1) - 0x2000) & 0xFFFF; - - if ((temp2 < 0x4000) || (this->unk_87C != 0)) { - return -1; - } else { - return 1; - } - } - - return 0; -} - -void func_80840138(Player* this, f32 arg1, s16 arg2) { - s16 temp = arg2 - this->actor.shape.rot.y; - - if (arg1 > 0.0f) { - if (temp < 0) { - this->unk_874 = 0.0f; - } else { - this->unk_874 = 1.0f; - } - } - - Math_StepToF(&this->unk_870, this->unk_874, 0.3f); -} - -void func_808401B0(GlobalContext* globalCtx, Player* this) { - LinkAnimation_BlendToJoint(globalCtx, &this->skelAnime, func_808334E4(this), this->unk_868, func_80833528(this), - this->unk_868, this->unk_870, this->blendTable); -} - -s32 func_8084021C(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { - f32 temp; - - if ((arg3 == 0.0f) && (arg1 > 0.0f)) { - arg3 = arg2; - } - - temp = (arg0 + arg1) - arg3; - - if (((temp * arg1) >= 0.0f) && (((temp - arg1) * arg1) < 0.0f)) { - return 1; - } - - return 0; -} - -void func_8084029C(Player* this, f32 arg1) { - f32 updateScale = R_UPDATE_RATE * 0.5f; - - arg1 *= updateScale; - if (arg1 < -7.25) { - arg1 = -7.25; - } else if (arg1 > 7.25f) { - arg1 = 7.25f; - } - - if (1) {} - - if ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->actor.bgCheckFlags & 1) && (this->hoverBootsTimer != 0)) { - func_8002F8F0(&this->actor, NA_SE_PL_HOBBERBOOTS_LV - SFX_FLAG); - } else if (func_8084021C(this->unk_868, arg1, 29.0f, 10.0f) || func_8084021C(this->unk_868, arg1, 29.0f, 24.0f)) { - func_808327F8(this, this->linearVelocity); - if (this->linearVelocity > 4.0f) { - this->stateFlags2 |= 8; - } - } - - this->unk_868 += arg1; - - if (this->unk_868 < 0.0f) { - this->unk_868 += 29.0f; - } else if (this->unk_868 >= 29.0f) { - this->unk_868 -= 29.0f; - } -} - -void func_80840450(Player* this, GlobalContext* globalCtx) { - f32 sp44; - s16 sp42; - s32 temp1; - u32 temp2; - s16 temp3; - s32 temp4; - - if (this->stateFlags3 & 8) { - if (Player_GetSwordHeld(this)) { - this->stateFlags2 |= 0x60; - } else { - this->stateFlags3 &= ~8; - } - } - - if (this->unk_850 != 0) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832DBC(this); - func_80832284(globalCtx, this, func_808334E4(this)); - this->unk_850 = 0; - this->stateFlags3 &= ~8; - } - func_80833C3C(this); - } else { - func_808401B0(globalCtx, this); - } - - func_8083721C(this); - - if (!func_80837348(globalCtx, this, D_808543E0, 1)) { - if (!func_80833B54(this) && (!func_80833B2C(this) || (func_80834B5C != this->func_82C))) { - func_8083CF10(this, globalCtx); - return; - } - - func_80837268(this, &sp44, &sp42, 0.0f, globalCtx); - - temp1 = func_8083FC68(this, sp44, sp42); - - if (temp1 > 0) { - func_8083C8DC(this, globalCtx, sp42); - return; - } - - if (temp1 < 0) { - func_8083CBF0(this, sp42, globalCtx); - return; - } - - if (sp44 > 4.0f) { - func_8083CC9C(this, globalCtx); - return; - } - - func_8084029C(this, (this->linearVelocity * 0.3f) + 1.0f); - func_80840138(this, sp44, sp42); - - temp2 = this->unk_868; - if ((temp2 < 6) || ((temp2 - 0xE) < 6)) { - Math_StepToF(&this->linearVelocity, 0.0f, 1.5f); - return; - } - - temp3 = sp42 - this->currentYaw; - temp4 = ABS(temp3); - - if (temp4 > 0x4000) { - if (Math_StepToF(&this->linearVelocity, 0.0f, 1.5f)) { - this->currentYaw = sp42; - } - return; - } - - Math_AsymStepToF(&this->linearVelocity, sp44 * 0.3f, 2.0f, 1.5f); - - if (!(this->stateFlags3 & 8)) { - Math_ScaledStepToS(&this->currentYaw, sp42, temp4 * 0.1f); - } - } -} - -void func_808407CC(Player* this, GlobalContext* globalCtx) { - f32 sp3C; - s16 sp3A; - s32 temp1; - s16 temp2; - s32 temp3; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832DBC(this); - func_80832264(globalCtx, this, func_80833338(this)); - } - - func_8083721C(this); - - if (!func_80837348(globalCtx, this, D_808543E8, 1)) { - if (func_80833B54(this)) { - func_8083CEAC(this, globalCtx); - return; - } - - if (!func_80833B2C(this)) { - func_80835DAC(globalCtx, this, func_80840BC8, 1); - this->currentYaw = this->actor.shape.rot.y; - return; - } - - if (func_80834B5C == this->func_82C) { - func_8083CEAC(this, globalCtx); - return; - } - - func_80837268(this, &sp3C, &sp3A, 0.0f, globalCtx); - - temp1 = func_8083FD78(this, &sp3C, &sp3A, globalCtx); - - if (temp1 > 0) { - func_8083C8DC(this, globalCtx, sp3A); - return; - } - - if (temp1 < 0) { - func_8083CB2C(this, sp3A, globalCtx); - return; - } - - if (sp3C > 4.9f) { - func_8083CC9C(this, globalCtx); - func_80833C3C(this); - return; - } - if (sp3C != 0.0f) { - func_8083CB94(this, globalCtx); - return; - } - - temp2 = sp3A - this->actor.shape.rot.y; - temp3 = ABS(temp2); - - if (temp3 > 800) { - func_8083CD54(globalCtx, this, sp3A); - } - } -} - -void func_808409CC(GlobalContext* globalCtx, Player* this) { - LinkAnimationHeader* anim; - LinkAnimationHeader** animPtr; - s32 heathIsCritical; - s32 sp38; - s32 sp34; - - if ((this->unk_664 != NULL) || - (!(heathIsCritical = HealthMeter_IsCritical()) && ((this->unk_6AC = (this->unk_6AC + 1) & 1) != 0))) { - this->stateFlags2 &= ~0x10000000; - anim = func_80833338(this); - } else { - this->stateFlags2 |= 0x10000000; - if (this->stateFlags1 & 0x800) { - anim = func_80833338(this); - } else { - sp38 = globalCtx->roomCtx.curRoom.unk_02; - if (heathIsCritical) { - if (this->unk_6AC >= 0) { - sp38 = 7; - this->unk_6AC = -1; - } else { - sp38 = 8; - } - } else { - sp34 = Rand_ZeroOne() * 5.0f; - if (sp34 < 4) { - if (((sp34 != 0) && (sp34 != 3)) || - ((this->rightHandType == 10) && ((sp34 == 3) || Player_GetSwordHeld(this)))) { - if ((sp34 == 0) && Player_HoldsTwoHandedWeapon(this)) { - sp34 = 4; - } - sp38 = sp34 + 9; - } - } - } - animPtr = &D_80853D7C[sp38][0]; - if (this->modelAnimType != 1) { - animPtr = &D_80853D7C[sp38][1]; - } - anim = *animPtr; - } - } - - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, (2.0f / 3.0f) * D_808535E8, 0.0f, - Animation_GetLastFrame(anim), ANIMMODE_ONCE, -6.0f); -} - -void func_80840BC8(Player* this, GlobalContext* globalCtx) { - s32 sp44; - s32 sp40; - f32 sp3C; - s16 sp3A; - s16 temp; - - sp44 = func_80833350(this); - sp40 = LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (sp44 > 0) { - func_808333FC(this, sp44 - 1); - } - - if (sp40 != 0) { - if (this->unk_850 != 0) { - if (DECR(this->unk_850) == 0) { - this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; - } - this->skelAnime.jointTable[0].y = (this->skelAnime.jointTable[0].y + ((this->unk_850 & 1) * 0x50)) - 0x28; - } else { - func_80832DBC(this); - func_808409CC(globalCtx, this); - } - } - - func_8083721C(this); - - if (this->unk_850 == 0) { - if (!func_80837348(globalCtx, this, D_80854418, 1)) { - if (func_80833B54(this)) { - func_8083CEAC(this, globalCtx); - return; - } - - if (func_80833B2C(this)) { - func_80839F30(this, globalCtx); - return; - } - - func_80837268(this, &sp3C, &sp3A, 0.018f, globalCtx); - - if (sp3C != 0.0f) { - func_8083C8DC(this, globalCtx, sp3A); - return; - } - - temp = sp3A - this->actor.shape.rot.y; - if (ABS(temp) > 800) { - func_8083CD54(globalCtx, this, sp3A); - return; - } - - Math_ScaledStepToS(&this->actor.shape.rot.y, sp3A, 1200); - this->currentYaw = this->actor.shape.rot.y; - if (func_80833338(this) == this->skelAnime.animation) { - func_8083DC54(this, globalCtx); - } - } - } -} - -void func_80840DE4(Player* this, GlobalContext* globalCtx) { - f32 frames; - f32 coeff; - f32 sp44; - s16 sp42; - s32 temp1; - s16 temp2; - s32 temp3; - s32 direction; - - this->skelAnime.mode = 0; - LinkAnimation_SetUpdateFunction(&this->skelAnime); - - this->skelAnime.animation = func_8083356C(this); - - if (this->skelAnime.animation == &gPlayerAnim_0026E8) { - frames = 24.0f; - coeff = -(MREG(95) / 100.0f); - } else { - frames = 29.0f; - coeff = MREG(95) / 100.0f; - } - - this->skelAnime.animLength = frames; - this->skelAnime.endFrame = frames - 1.0f; - - if ((s16)(this->currentYaw - this->actor.shape.rot.y) >= 0) { - direction = 1; - } else { - direction = -1; - } - - this->skelAnime.playSpeed = direction * (this->linearVelocity * coeff); - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (LinkAnimation_OnFrame(&this->skelAnime, 0.0f) || LinkAnimation_OnFrame(&this->skelAnime, frames * 0.5f)) { - func_808327F8(this, this->linearVelocity); - } - - if (!func_80837348(globalCtx, this, D_808543F4, 1)) { - if (func_80833B54(this)) { - func_8083CEAC(this, globalCtx); - return; - } - - if (!func_80833B2C(this)) { - func_80853080(this, globalCtx); - return; - } - - func_80837268(this, &sp44, &sp42, 0.0f, globalCtx); - temp1 = func_8083FD78(this, &sp44, &sp42, globalCtx); - - if (temp1 > 0) { - func_8083C8DC(this, globalCtx, sp42); - return; - } - - if (temp1 < 0) { - func_8083CB2C(this, sp42, globalCtx); - return; - } - - if (sp44 > 4.9f) { - func_8083CC9C(this, globalCtx); - func_80833C3C(this); - return; - } - - if ((sp44 == 0.0f) && (this->linearVelocity == 0.0f)) { - func_80839F30(this, globalCtx); - return; - } - - temp2 = sp42 - this->currentYaw; - temp3 = ABS(temp2); - - if (temp3 > 0x4000) { - if (Math_StepToF(&this->linearVelocity, 0.0f, 1.5f)) { - this->currentYaw = sp42; - } - return; - } - - Math_AsymStepToF(&this->linearVelocity, sp44 * 0.4f, 1.5f, 1.5f); - Math_ScaledStepToS(&this->currentYaw, sp42, temp3 * 0.1f); - } -} - -void func_80841138(Player* this, GlobalContext* globalCtx) { - f32 temp1; - f32 temp2; - - if (this->unk_864 < 1.0f) { - temp1 = R_UPDATE_RATE * 0.5f; - func_8084029C(this, REG(35) / 1000.0f); - LinkAnimation_LoadToJoint(globalCtx, &this->skelAnime, D_80853BFC[this->modelAnimType], this->unk_868); - this->unk_864 += 1 * temp1; - if (this->unk_864 >= 1.0f) { - this->unk_864 = 1.0f; - } - temp1 = this->unk_864; - } else { - temp2 = this->linearVelocity - (REG(48) / 100.0f); - if (temp2 < 0.0f) { - temp1 = 1.0f; - func_8084029C(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); - LinkAnimation_LoadToJoint(globalCtx, &this->skelAnime, D_80853BFC[this->modelAnimType], this->unk_868); - } else { - temp1 = (REG(37) / 1000.0f) * temp2; - if (temp1 < 1.0f) { - func_8084029C(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); - } else { - temp1 = 1.0f; - func_8084029C(this, 1.2f + ((REG(38) / 1000.0f) * temp2)); - } - LinkAnimation_LoadToMorph(globalCtx, &this->skelAnime, D_80853BFC[this->modelAnimType], this->unk_868); - LinkAnimation_LoadToJoint(globalCtx, &this->skelAnime, &gPlayerAnim_002DD0, - this->unk_868 * (16.0f / 29.0f)); - } - } - - if (temp1 < 1.0f) { - LinkAnimation_InterpJointMorph(globalCtx, &this->skelAnime, 1.0f - temp1); - } -} - -void func_8084140C(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084170C, 1); - func_80832B0C(globalCtx, this, &gPlayerAnim_002DA0); -} - -s32 func_80841458(Player* this, f32* arg1, s16* arg2, GlobalContext* globalCtx) { - if (this->linearVelocity > 6.0f) { - func_8084140C(this, globalCtx); - return 1; - } - - if (*arg1 != 0.0f) { - if (func_8083721C(this)) { - *arg1 = 0.0f; - *arg2 = this->currentYaw; - } else { - return 1; - } - } - - return 0; -} - -void func_808414F8(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - s32 sp2C; - s16 sp2A; - - func_80841138(this, globalCtx); - - if (!func_80837348(globalCtx, this, D_80854400, 1)) { - if (!func_80833C04(this)) { - func_8083C8DC(this, globalCtx, this->currentYaw); - return; - } - - func_80837268(this, &sp34, &sp32, 0.0f, globalCtx); - sp2C = func_8083FD78(this, &sp34, &sp32, globalCtx); - - if (sp2C >= 0) { - if (!func_80841458(this, &sp34, &sp32, globalCtx)) { - if (sp2C != 0) { - func_8083C858(this, globalCtx); - } else if (sp34 > 4.9f) { - func_8083CC9C(this, globalCtx); - } else { - func_8083CB94(this, globalCtx); - } - } - } else { - sp2A = sp32 - this->currentYaw; - - Math_AsymStepToF(&this->linearVelocity, sp34 * 1.5f, 1.5f, 2.0f); - Math_ScaledStepToS(&this->currentYaw, sp32, sp2A * 0.1f); - - if ((sp34 == 0.0f) && (this->linearVelocity == 0.0f)) { - func_80839F30(this, globalCtx); - } - } - } -} - -void func_808416C0(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_808417FC, 1); - func_80832264(globalCtx, this, &gPlayerAnim_002DA8); -} - -void func_8084170C(Player* this, GlobalContext* globalCtx) { - s32 sp34; - f32 sp30; - s16 sp2E; - - sp34 = LinkAnimation_Update(globalCtx, &this->skelAnime); - func_8083721C(this); - - if (!func_80837348(globalCtx, this, D_80854400, 1)) { - func_80837268(this, &sp30, &sp2E, 0.0f, globalCtx); - - if (this->linearVelocity == 0.0f) { - this->currentYaw = this->actor.shape.rot.y; - - if (func_8083FD78(this, &sp30, &sp2E, globalCtx) > 0) { - func_8083C858(this, globalCtx); - } else if ((sp30 != 0.0f) || (sp34 != 0)) { - func_808416C0(this, globalCtx); - } - } - } -} - -void func_808417FC(Player* this, GlobalContext* globalCtx) { - s32 sp1C; - - sp1C = LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (!func_80837348(globalCtx, this, D_80854400, 1)) { - if (sp1C != 0) { - func_80839F30(this, globalCtx); - } - } -} - -void func_80841860(GlobalContext* globalCtx, Player* this) { - f32 frame; - LinkAnimationHeader* sp38 = D_80853B54[this->modelAnimType]; - LinkAnimationHeader* sp34 = D_80853B6C[this->modelAnimType]; - - this->skelAnime.animation = sp38; - - func_8084029C(this, (REG(30) / 1000.0f) + ((REG(32) / 1000.0f) * this->linearVelocity)); - - frame = this->unk_868 * (16.0f / 29.0f); - LinkAnimation_BlendToJoint(globalCtx, &this->skelAnime, sp34, frame, sp38, frame, this->unk_870, this->blendTable); -} - -void func_8084193C(Player* this, GlobalContext* globalCtx) { - f32 sp3C; - s16 sp3A; - s32 temp1; - s16 temp2; - s32 temp3; - - func_80841860(globalCtx, this); - - if (!func_80837348(globalCtx, this, D_80854408, 1)) { - if (!func_80833C04(this)) { - func_8083C858(this, globalCtx); - return; - } - - func_80837268(this, &sp3C, &sp3A, 0.0f, globalCtx); - - if (func_80833B2C(this)) { - temp1 = func_8083FD78(this, &sp3C, &sp3A, globalCtx); - } else { - temp1 = func_8083FC68(this, sp3C, sp3A); - } - - if (temp1 > 0) { - func_8083C858(this, globalCtx); - return; - } - - if (temp1 < 0) { - if (func_80833B2C(this)) { - func_8083CB2C(this, sp3A, globalCtx); - } else { - func_8083CBF0(this, sp3A, globalCtx); - } - return; - } - - if ((this->linearVelocity < 3.6f) && (sp3C < 4.0f)) { - if (!func_8008E9C4(this) && func_80833B2C(this)) { - func_8083CB94(this, globalCtx); - } else { - func_80839F90(this, globalCtx); - } - return; - } - - func_80840138(this, sp3C, sp3A); - - temp2 = sp3A - this->currentYaw; - temp3 = ABS(temp2); - - if (temp3 > 0x4000) { - if (Math_StepToF(&this->linearVelocity, 0.0f, 3.0f) != 0) { - this->currentYaw = sp3A; - } - return; - } - - sp3C *= 0.9f; - Math_AsymStepToF(&this->linearVelocity, sp3C, 2.0f, 3.0f); - Math_ScaledStepToS(&this->currentYaw, sp3A, temp3 * 0.1f); - } -} - -void func_80841BA8(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (Player_HoldsTwoHandedWeapon(this)) { - AnimationContext_SetLoadFrame(globalCtx, func_80833338(this), 0, this->skelAnime.limbCount, - this->skelAnime.morphTable); - AnimationContext_SetCopyTrue(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime.morphTable, D_80853410); - } - - func_80837268(this, &sp34, &sp32, 0.018f, globalCtx); - - if (!func_80837348(globalCtx, this, D_80854414, 1)) { - if (sp34 != 0.0f) { - this->actor.shape.rot.y = sp32; - func_8083C858(this, globalCtx); - } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, sp32, this->unk_87E)) { - func_8083C0E8(this, globalCtx); - } - - this->currentYaw = this->actor.shape.rot.y; - } -} - -void func_80841CC4(Player* this, s32 arg1, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - s16 target; - f32 rate; - - if (ABS(D_80853610) < 3640) { - target = 0; - } else { - target = CLAMP(D_80853610, -10922, 10922); - } - - Math_ScaledStepToS(&this->unk_89C, target, 400); - - if ((this->modelAnimType == 3) || ((this->unk_89C == 0) && (this->unk_6C4 <= 0.0f))) { - if (arg1 == 0) { - LinkAnimation_LoadToJoint(globalCtx, &this->skelAnime, D_8085392C[this->modelAnimType], this->unk_868); - } else { - LinkAnimation_LoadToMorph(globalCtx, &this->skelAnime, D_8085392C[this->modelAnimType], this->unk_868); - } - return; - } - - if (this->unk_89C != 0) { - rate = this->unk_89C / 10922.0f; - } else { - rate = this->unk_6C4 * 0.0006f; - } - - rate *= fabsf(this->linearVelocity) * 0.5f; - - if (rate > 1.0f) { - rate = 1.0f; - } - - if (rate < 0.0f) { - anim = &gPlayerAnim_002E48; - rate = -rate; - } else { - anim = &gPlayerAnim_002E90; - } - - if (arg1 == 0) { - LinkAnimation_BlendToJoint(globalCtx, &this->skelAnime, D_8085392C[this->modelAnimType], this->unk_868, anim, - this->unk_868, rate, this->blendTable); - } else { - LinkAnimation_BlendToMorph(globalCtx, &this->skelAnime, D_8085392C[this->modelAnimType], this->unk_868, anim, - this->unk_868, rate, this->blendTable); - } -} - -void func_80841EE4(Player* this, GlobalContext* globalCtx) { - f32 temp1; - f32 temp2; - - if (this->unk_864 < 1.0f) { - temp1 = R_UPDATE_RATE * 0.5f; - - func_8084029C(this, REG(35) / 1000.0f); - LinkAnimation_LoadToJoint(globalCtx, &this->skelAnime, D_8085392C[this->modelAnimType], this->unk_868); - - this->unk_864 += 1 * temp1; - if (this->unk_864 >= 1.0f) { - this->unk_864 = 1.0f; - } - - temp1 = this->unk_864; - } else { - temp2 = this->linearVelocity - (REG(48) / 100.0f); - - if (temp2 < 0.0f) { - temp1 = 1.0f; - func_8084029C(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); - - func_80841CC4(this, 0, globalCtx); - } else { - temp1 = (REG(37) / 1000.0f) * temp2; - if (temp1 < 1.0f) { - func_8084029C(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); - } else { - temp1 = 1.0f; - func_8084029C(this, 1.2f + ((REG(38) / 1000.0f) * temp2)); - } - - func_80841CC4(this, 1, globalCtx); - - LinkAnimation_LoadToJoint(globalCtx, &this->skelAnime, func_80833438(this), - this->unk_868 * (20.0f / 29.0f)); - } - } - - if (temp1 < 1.0f) { - LinkAnimation_InterpJointMorph(globalCtx, &this->skelAnime, 1.0f - temp1); - } -} - -void func_80842180(Player* this, GlobalContext* globalCtx) { - f32 sp2C; - s16 sp2A; - - this->stateFlags2 |= 0x20; - func_80841EE4(this, globalCtx); - - if (!func_80837348(globalCtx, this, D_80854424, 1)) { - if (func_80833C04(this)) { - func_8083C858(this, globalCtx); - return; - } - - func_80837268(this, &sp2C, &sp2A, 0.018f, globalCtx); - - if (!func_8083C484(this, &sp2C, &sp2A)) { - func_8083DF68(this, sp2C, sp2A); - func_8083DDC8(this, globalCtx); - - if ((this->linearVelocity == 0.0f) && (sp2C == 0.0f)) { - func_8083C0B8(this, globalCtx); - } - } - } -} - -void func_8084227C(Player* this, GlobalContext* globalCtx) { - f32 sp2C; - s16 sp2A; - - this->stateFlags2 |= 0x20; - func_80841EE4(this, globalCtx); - - if (!func_80837348(globalCtx, this, D_80854430, 1)) { - if (!func_80833C04(this)) { - func_8083C858(this, globalCtx); - return; - } - - func_80837268(this, &sp2C, &sp2A, 0.0f, globalCtx); - - if (!func_8083C484(this, &sp2C, &sp2A)) { - if ((func_80833B2C(this) && (sp2C != 0.0f) && (func_8083FD78(this, &sp2C, &sp2A, globalCtx) <= 0)) || - (!func_80833B2C(this) && (func_8083FC68(this, sp2C, sp2A) <= 0))) { - func_80839F90(this, globalCtx); - return; - } - - func_8083DF68(this, sp2C, sp2A); - func_8083DDC8(this, globalCtx); - - if ((this->linearVelocity == 0) && (sp2C == 0)) { - func_80839F90(this, globalCtx); - } - } - } -} - -void func_808423EC(Player* this, GlobalContext* globalCtx) { - s32 sp34; - f32 sp30; - s16 sp2E; - - sp34 = LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (!func_80837348(globalCtx, this, D_80854408, 1)) { - if (!func_80833C04(this)) { - func_8083C858(this, globalCtx); - return; - } - - func_80837268(this, &sp30, &sp2E, 0.0f, globalCtx); - - if ((this->skelAnime.morphWeight == 0.0f) && (this->skelAnime.curFrame > 5.0f)) { - func_8083721C(this); - - if ((this->skelAnime.curFrame > 10.0f) && (func_8083FC68(this, sp30, sp2E) < 0)) { - func_8083CBF0(this, sp2E, globalCtx); - return; - } - - if (sp34 != 0) { - func_8083CD00(this, globalCtx); - } - } - } -} - -void func_8084251C(Player* this, GlobalContext* globalCtx) { - s32 sp34; - f32 sp30; - s16 sp2E; - - sp34 = LinkAnimation_Update(globalCtx, &this->skelAnime); - - func_8083721C(this); - - if (!func_80837348(globalCtx, this, D_80854440, 1)) { - func_80837268(this, &sp30, &sp2E, 0.0f, globalCtx); - - if (this->linearVelocity == 0.0f) { - this->currentYaw = this->actor.shape.rot.y; - - if (func_8083FC68(this, sp30, sp2E) > 0) { - func_8083C858(this, globalCtx); - return; - } - - if ((sp30 != 0.0f) || (sp34 != 0)) { - func_80839F90(this, globalCtx); - } - } - } -} - -void func_8084260C(Vec3f* src, Vec3f* dest, f32 arg2, f32 arg3, f32 arg4) { - dest->x = (Rand_ZeroOne() * arg3) + src->x; - dest->y = (Rand_ZeroOne() * arg4) + (src->y + arg2); - dest->z = (Rand_ZeroOne() * arg3) + src->z; -} - -static Vec3f D_808545B4 = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_808545C0 = { 0.0f, 0.0f, 0.0f }; - -s32 func_8084269C(GlobalContext* globalCtx, Player* this) { - Vec3f sp2C; - - if ((this->unk_89E == 0) || (this->unk_89E == 1)) { - func_8084260C(&this->actor.shape.feetPos[FOOT_LEFT], &sp2C, - this->actor.floorHeight - this->actor.shape.feetPos[FOOT_LEFT].y, 7.0f, 5.0f); - func_800286CC(globalCtx, &sp2C, &D_808545B4, &D_808545C0, 50, 30); - func_8084260C(&this->actor.shape.feetPos[FOOT_RIGHT], &sp2C, - this->actor.floorHeight - this->actor.shape.feetPos[FOOT_RIGHT].y, 7.0f, 5.0f); - func_800286CC(globalCtx, &this->actor.shape.feetPos[FOOT_RIGHT], &D_808545B4, &D_808545C0, 50, 30); - return 1; - } - - return 0; -} - -void func_8084279C(Player* this, GlobalContext* globalCtx) { - func_80832CB0(globalCtx, this, D_80853C2C[this->modelAnimType]); - - if (DECR(this->unk_850) == 0) { - if (!func_8083B040(this, globalCtx)) { - func_8083A098(this, D_80853C44[this->modelAnimType], globalCtx); - } - - this->actor.flags &= ~ACTOR_FLAG_8; - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - } -} - -s32 func_8084285C(Player* this, f32 arg1, f32 arg2, f32 arg3) { - if ((arg1 <= this->skelAnime.curFrame) && (this->skelAnime.curFrame <= arg3)) { - func_80833A20(this, (arg2 <= this->skelAnime.curFrame) ? 1 : -1); - return 1; - } - - func_80832318(this); - return 0; -} - -s32 func_808428D8(Player* this, GlobalContext* globalCtx) { - if (!Player_IsChildWithHylianShield(this) && Player_GetSwordHeld(this) && D_80853614) { - func_80832264(globalCtx, this, &gPlayerAnim_002EC8); - this->unk_84F = 1; - this->swordAnimation = 0xC; - this->currentYaw = this->actor.shape.rot.y + this->unk_6BE; - return 1; - } - - return 0; -} - -s32 func_80842964(Player* this, GlobalContext* globalCtx) { - return func_8083B040(this, globalCtx) || func_8083B644(this, globalCtx) || func_8083E5A8(this, globalCtx); -} - -void func_808429B4(GlobalContext* globalCtx, s32 speed, s32 y, s32 countdown) { - s32 quakeIdx = Quake_Add(Gameplay_GetCamera(globalCtx, 0), 3); - - Quake_SetSpeed(quakeIdx, speed); - Quake_SetQuakeValues(quakeIdx, y, 0, 0, 0); - Quake_SetCountdown(quakeIdx, countdown); -} - -void func_80842A28(GlobalContext* globalCtx, Player* this) { - func_808429B4(globalCtx, 27767, 7, 20); - globalCtx->actorCtx.unk_02 = 4; - func_8083264C(this, 255, 20, 150, 0); - func_8002F7DC(&this->actor, NA_SE_IT_HAMMER_HIT); -} - -void func_80842A88(GlobalContext* globalCtx, Player* this) { - Inventory_ChangeAmmo(ITEM_STICK, -1); - func_80835F44(globalCtx, this, ITEM_NONE); -} - -s32 func_80842AC4(GlobalContext* globalCtx, Player* this) { - if ((this->heldItemActionParam == PLAYER_AP_STICK) && (this->unk_85C > 0.5f)) { - if (AMMO(ITEM_STICK) != 0) { - EffectSsStick_Spawn(globalCtx, &this->bodyPartsPos[15], this->actor.shape.rot.y + 0x8000); - this->unk_85C = 0.5f; - func_80842A88(globalCtx, this); - func_8002F7DC(&this->actor, NA_SE_IT_WOODSTICK_BROKEN); - } - - return 1; - } - - return 0; -} - -s32 func_80842B7C(GlobalContext* globalCtx, Player* this) { - if (this->heldItemActionParam == PLAYER_AP_SWORD_BGS) { - if (!gSaveContext.bgsFlag && (gSaveContext.swordHealth > 0.0f)) { - if ((gSaveContext.swordHealth -= 1.0f) <= 0.0f) { - EffectSsStick_Spawn(globalCtx, &this->bodyPartsPos[15], this->actor.shape.rot.y + 0x8000); - func_800849EC(globalCtx); - func_8002F7DC(&this->actor, NA_SE_IT_MAJIN_SWORD_BROKEN); - } - } - - return 1; - } - - return 0; -} - -void func_80842CF0(GlobalContext* globalCtx, Player* this) { - func_80842AC4(globalCtx, this); - func_80842B7C(globalCtx, this); -} - -static LinkAnimationHeader* D_808545CC[] = { - &gPlayerAnim_002B10, - &gPlayerAnim_002B20, - &gPlayerAnim_002B08, - &gPlayerAnim_002B18, -}; - -void func_80842D20(GlobalContext* globalCtx, Player* this) { - s32 pad; - s32 sp28; - - if (func_80843188 != this->func_674) { - func_80832440(globalCtx, this); - func_80835C58(globalCtx, this, func_808505DC, 0); - - if (func_8008E9C4(this)) { - sp28 = 2; - } else { - sp28 = 0; - } - - func_808322D0(globalCtx, this, D_808545CC[Player_HoldsTwoHandedWeapon(this) + sp28]); - } - - func_8083264C(this, 180, 20, 100, 0); - this->linearVelocity = -18.0f; - func_80842CF0(globalCtx, this); -} - -s32 func_80842DF4(GlobalContext* globalCtx, Player* this) { - f32 phi_f2; - CollisionPoly* sp78; - s32 sp74; - Vec3f sp68; - Vec3f sp5C; - Vec3f sp50; - s32 temp1; - s32 sp48; - - if (this->swordState > 0) { - if (this->swordAnimation < 0x18) { - if (!(this->swordQuads[0].base.atFlags & AT_BOUNCED) && !(this->swordQuads[1].base.atFlags & AT_BOUNCED)) { - if (this->skelAnime.curFrame >= 2.0f) { - - phi_f2 = Math_Vec3f_DistXYZAndStoreDiff(&this->swordInfo[0].tip, &this->swordInfo[0].base, &sp50); - if (phi_f2 != 0.0f) { - phi_f2 = (phi_f2 + 10.0f) / phi_f2; - } - - sp68.x = this->swordInfo[0].tip.x + (sp50.x * phi_f2); - sp68.y = this->swordInfo[0].tip.y + (sp50.y * phi_f2); - sp68.z = this->swordInfo[0].tip.z + (sp50.z * phi_f2); - - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp68, &this->swordInfo[0].tip, &sp5C, &sp78, true, - false, false, true, &sp74) && - !SurfaceType_IsIgnoredByEntities(&globalCtx->colCtx, sp78, sp74) && - (func_80041D4C(&globalCtx->colCtx, sp78, sp74) != 6) && - (func_8002F9EC(globalCtx, &this->actor, sp78, sp74, &sp5C) == 0)) { - - if (this->heldItemActionParam == PLAYER_AP_HAMMER) { - func_80832630(globalCtx); - func_80842A28(globalCtx, this); - func_80842D20(globalCtx, this); - return 1; - } - - if (this->linearVelocity >= 0.0f) { - sp48 = func_80041F10(&globalCtx->colCtx, sp78, sp74); - - if (sp48 == 0xA) { - CollisionCheck_SpawnShieldParticlesWood(globalCtx, &sp5C, &this->actor.projectedPos); - } else { - CollisionCheck_SpawnShieldParticles(globalCtx, &sp5C); - if (sp48 == 0xB) { - func_8002F7DC(&this->actor, NA_SE_IT_WALL_HIT_SOFT); - } else { - func_8002F7DC(&this->actor, NA_SE_IT_WALL_HIT_HARD); - } - } - - func_80842CF0(globalCtx, this); - this->linearVelocity = -14.0f; - func_8083264C(this, 180, 20, 100, 0); - } - } - } - } else { - func_80842D20(globalCtx, this); - func_80832630(globalCtx); - return 1; - } - } - - temp1 = (this->swordQuads[0].base.atFlags & AT_HIT) || (this->swordQuads[1].base.atFlags & AT_HIT); - - if (temp1) { - if (this->swordAnimation < 0x18) { - Actor* at = this->swordQuads[temp1 ? 1 : 0].base.at; - - if ((at != NULL) && (at->id != ACTOR_EN_KANBAN)) { - func_80832630(globalCtx); - } - } - - if ((func_80842AC4(globalCtx, this) == 0) && (this->heldItemActionParam != PLAYER_AP_HAMMER)) { - func_80842B7C(globalCtx, this); - - if (this->actor.colChkInfo.atHitEffect == 1) { - this->actor.colChkInfo.damage = 8; - func_80837C0C(globalCtx, this, 4, 0.0f, 0.0f, this->actor.shape.rot.y, 20); - return 1; - } - } - } - } - - return 0; -} - -void func_80843188(Player* this, GlobalContext* globalCtx) { - f32 sp54; - f32 sp50; - s16 sp4E; - s16 sp4C; - s16 sp4A; - s16 sp48; - s16 sp46; - f32 sp40; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (!Player_IsChildWithHylianShield(this)) { - func_80832284(globalCtx, this, D_80853B0C[this->modelAnimType]); - } - this->unk_850 = 1; - this->unk_84F = 0; - } - - if (!Player_IsChildWithHylianShield(this)) { - this->stateFlags1 |= 0x400000; - func_80836670(this, globalCtx); - this->stateFlags1 &= ~0x400000; - } - - func_8083721C(this); - - if (this->unk_850 != 0) { - sp54 = sControlInput->rel.stick_y * 100; - sp50 = sControlInput->rel.stick_x * -120; - sp4E = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); - - sp40 = Math_CosS(sp4E); - sp4C = (Math_SinS(sp4E) * sp50) + (sp54 * sp40); - sp40 = Math_CosS(sp4E); - sp4A = (sp50 * sp40) - (Math_SinS(sp4E) * sp54); - - if (sp4C > 3500) { - sp4C = 3500; - } - - sp48 = ABS(sp4C - this->actor.focus.rot.x) * 0.25f; - if (sp48 < 100) { - sp48 = 100; - } - - sp46 = ABS(sp4A - this->unk_6BE) * 0.25f; - if (sp46 < 50) { - sp46 = 50; - } - - Math_ScaledStepToS(&this->actor.focus.rot.x, sp4C, sp48); - this->unk_6BC = this->actor.focus.rot.x; - Math_ScaledStepToS(&this->unk_6BE, sp4A, sp46); - - if (this->unk_84F != 0) { - if (!func_80842DF4(globalCtx, this)) { - if (this->skelAnime.curFrame < 2.0f) { - func_80833A20(this, 1); - } - } else { - this->unk_850 = 1; - this->unk_84F = 0; - } - } else if (!func_80842964(this, globalCtx)) { - if (func_8083C2B0(this, globalCtx)) { - func_808428D8(this, globalCtx); - } else { - this->stateFlags1 &= ~0x400000; - func_80832318(this); - - if (Player_IsChildWithHylianShield(this)) { - func_8083A060(this, globalCtx); - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_002400, 1.0f, - Animation_GetLastFrame(&gPlayerAnim_002400), 0.0f, ANIMMODE_ONCE, 0.0f); - func_80832F54(globalCtx, this, 4); - } else { - if (this->itemActionParam < 0) { - func_8008EC70(this); - } - func_8083A098(this, D_80853B24[this->modelAnimType], globalCtx); - } - - func_8002F7DC(&this->actor, NA_SE_IT_SHIELD_REMOVE); - return; - } - } else { - return; - } - } - - this->stateFlags1 |= 0x400000; - Player_SetModelsForHoldingShield(this); - - this->unk_6AE |= 0xC1; -} - -void func_808435C4(Player* this, GlobalContext* globalCtx) { - s32 temp; - LinkAnimationHeader* anim; - f32 frames; - - func_8083721C(this); - - if (this->unk_84F == 0) { - D_808535E0 = func_80836670(this, globalCtx); - if ((func_80834B5C == this->func_82C) || (func_808374A0(globalCtx, this, &this->skelAnime2, 4.0f) > 0)) { - func_80835C58(globalCtx, this, func_80840450, 1); - } - } else { - temp = func_808374A0(globalCtx, this, &this->skelAnime, 4.0f); - if ((temp != 0) && ((temp > 0) || LinkAnimation_Update(globalCtx, &this->skelAnime))) { - func_80835C58(globalCtx, this, func_80843188, 1); - this->stateFlags1 |= 0x400000; - Player_SetModelsForHoldingShield(this); - anim = D_80853AF4[this->modelAnimType]; - frames = Animation_GetLastFrame(anim); - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, 1.0f, frames, frames, ANIMMODE_ONCE, 0.0f); - } - } -} - -void func_8084370C(Player* this, GlobalContext* globalCtx) { - s32 sp1C; - - func_8083721C(this); - - sp1C = func_808374A0(globalCtx, this, &this->skelAnime, 16.0f); - if ((sp1C != 0) && (LinkAnimation_Update(globalCtx, &this->skelAnime) || (sp1C > 0))) { - func_80839F90(this, globalCtx); - } -} - -void func_8084377C(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x60; - - func_808382BC(this); - - if (!(this->stateFlags1 & 0x20000000) && (this->unk_850 == 0) && (this->unk_8A1 != 0)) { - s16 temp = this->actor.shape.rot.y - this->unk_8A2; - - this->currentYaw = this->actor.shape.rot.y = this->unk_8A2; - this->linearVelocity = this->unk_8A4; - - if (ABS(temp) > 0x4000) { - this->actor.shape.rot.y = this->unk_8A2 + 0x8000; - } - - if (this->actor.velocity.y < 0.0f) { - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - } - } - - if (LinkAnimation_Update(globalCtx, &this->skelAnime) && (this->actor.bgCheckFlags & 1)) { - if (this->unk_850 != 0) { - this->unk_850--; - if (this->unk_850 == 0) { - func_80853080(this, globalCtx); - } - } else if ((this->stateFlags1 & 0x20000000) || - (!(this->cylinder.base.acFlags & AC_HIT) && (this->unk_8A1 == 0))) { - if (this->stateFlags1 & 0x20000000) { - this->unk_850++; - } else { - func_80835C58(globalCtx, this, func_80843954, 0); - this->stateFlags1 |= 0x4000000; - } - - func_80832264(globalCtx, this, - (this->currentYaw != this->actor.shape.rot.y) ? &gPlayerAnim_002F60 : &gPlayerAnim_002DB8); - func_80832698(this, NA_SE_VO_LI_FREEZE); - } - } - - if (this->actor.bgCheckFlags & 2) { - func_80832770(this, NA_SE_PL_BOUND); - } -} - -void func_80843954(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x60; - func_808382BC(this); - - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime) && (this->linearVelocity == 0.0f)) { - if (this->stateFlags1 & 0x20000000) { - this->unk_850++; - } else { - func_80835C58(globalCtx, this, func_80843A38, 0); - this->stateFlags1 |= 0x4000000; - } - - func_808322D0(globalCtx, this, - (this->currentYaw != this->actor.shape.rot.y) ? &gPlayerAnim_002F68 : &gPlayerAnim_002DC0); - this->currentYaw = this->actor.shape.rot.y; - } -} - -static struct_80832924 D_808545DC[] = { - { 0, 0x4014 }, - { 0, -0x401E }, -}; - -void func_80843A38(Player* this, GlobalContext* globalCtx) { - s32 sp24; - - this->stateFlags2 |= 0x20; - func_808382BC(this); - - if (this->stateFlags1 & 0x20000000) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - } else { - sp24 = func_808374A0(globalCtx, this, &this->skelAnime, 16.0f); - if ((sp24 != 0) && (LinkAnimation_Update(globalCtx, &this->skelAnime) || (sp24 > 0))) { - func_80839F90(this, globalCtx); - } - } - - func_80832924(this, D_808545DC); -} - -static Vec3f D_808545E4 = { 0.0f, 0.0f, 5.0f }; - -void func_80843AE8(GlobalContext* globalCtx, Player* this) { - if (this->unk_850 != 0) { - if (this->unk_850 > 0) { - this->unk_850--; - if (this->unk_850 == 0) { - if (this->stateFlags1 & 0x8000000) { - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_003328, 1.0f, 0.0f, - Animation_GetLastFrame(&gPlayerAnim_003328), ANIMMODE_ONCE, -16.0f); - } else { - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_002878, 1.0f, 99.0f, - Animation_GetLastFrame(&gPlayerAnim_002878), ANIMMODE_ONCE, 0.0f); - } - gSaveContext.healthAccumulator = 0x140; - this->unk_850 = -1; - } - } else if (gSaveContext.healthAccumulator == 0) { - this->stateFlags1 &= ~0x80; - if (this->stateFlags1 & 0x8000000) { - func_80838F18(globalCtx, this); - } else { - func_80853080(this, globalCtx); - } - this->unk_A87 = 20; - func_80837AFC(this, -20); - func_800F47FC(); - } - } else if (this->unk_84F != 0) { - this->unk_850 = 60; - Player_SpawnFairy(globalCtx, this, &this->actor.world.pos, &D_808545E4, FAIRY_REVIVE_DEATH); - func_8002F7DC(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); - OnePointCutscene_Init(globalCtx, 9908, 125, &this->actor, MAIN_CAM); - } else if (globalCtx->gameOverCtx.state == GAMEOVER_DEATH_WAIT_GROUND) { - globalCtx->gameOverCtx.state = GAMEOVER_DEATH_DELAY_MENU; - } -} - -static struct_80832924 D_808545F0[] = { - { NA_SE_PL_BOUND, 0x103C }, - { 0, 0x408C }, - { 0, 0x40A4 }, - { 0, -0x40AA }, -}; - -void func_80843CEC(Player* this, GlobalContext* globalCtx) { - if (this->currentTunic != PLAYER_TUNIC_GORON) { - if ((globalCtx->roomCtx.curRoom.unk_02 == 3) || (D_808535E4 == 9) || - ((func_80838144(D_808535E4) >= 0) && - !SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { - func_8083821C(this); - } - } - - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->actor.category == ACTORCAT_PLAYER) { - func_80843AE8(globalCtx, this); - } - return; - } - - if (this->skelAnime.animation == &gPlayerAnim_002878) { - func_80832924(this, D_808545F0); - } else if (this->skelAnime.animation == &gPlayerAnim_002F08) { - if (LinkAnimation_OnFrame(&this->skelAnime, 88.0f)) { - func_80832770(this, NA_SE_PL_BOUND); - } - } -} - -void func_80843E14(Player* this, u16 sfxId) { - func_80832698(this, sfxId); - - if ((this->heldActor != NULL) && (this->heldActor->id == ACTOR_EN_RU1)) { - Audio_PlayActorSound2(this->heldActor, NA_SE_VO_RT_FALL); - } -} - -static FallImpactInfo D_80854600[] = { - { -8, 180, 40, 100, NA_SE_VO_LI_LAND_DAMAGE_S }, - { -16, 255, 140, 150, NA_SE_VO_LI_LAND_DAMAGE_S }, -}; - -s32 func_80843E64(GlobalContext* globalCtx, Player* this) { - s32 sp34; - - if ((D_808535E4 == 6) || (D_808535E4 == 9)) { - sp34 = 0; - } else { - sp34 = this->fallDistance; - } - - Math_StepToF(&this->linearVelocity, 0.0f, 1.0f); - - this->stateFlags1 &= ~0xC0000; - - if (sp34 >= 400) { - s32 impactIndex; - FallImpactInfo* impactInfo; - - if (this->fallDistance < 800) { - impactIndex = 0; - } else { - impactIndex = 1; - } - - impactInfo = &D_80854600[impactIndex]; - - if (Player_InflictDamage(globalCtx, impactInfo->damage)) { - return -1; - } - - func_80837AE0(this, 40); - func_808429B4(globalCtx, 32967, 2, 30); - func_8083264C(this, impactInfo->unk_01, impactInfo->unk_02, impactInfo->unk_03, 0); - func_8002F7DC(&this->actor, NA_SE_PL_BODY_HIT); - func_80832698(this, impactInfo->sfxId); - - return impactIndex + 1; - } - - if (sp34 > 200) { - sp34 *= 2; - - if (sp34 > 255) { - sp34 = 255; - } - - func_8083264C(this, (u8)sp34, (u8)(sp34 * 0.1f), (u8)sp34, 0); - - if (D_808535E4 == 6) { - func_80832698(this, NA_SE_VO_LI_CLIMB_END); - } - } - - func_808328A0(this); - - return 0; -} - -void func_8084409C(GlobalContext* globalCtx, Player* this, f32 speedXZ, f32 velocityY) { - Actor* heldActor = this->heldActor; - - if (!func_80835644(globalCtx, this, heldActor)) { - heldActor->world.rot.y = this->actor.shape.rot.y; - heldActor->speedXZ = speedXZ; - heldActor->velocity.y = velocityY; - func_80834644(globalCtx, this); - func_8002F7DC(&this->actor, NA_SE_PL_THROW); - func_80832698(this, NA_SE_VO_LI_SWORD_N); - } -} - -void func_8084411C(Player* this, GlobalContext* globalCtx) { - f32 sp4C; - s16 sp4A; - - if (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 40) { - this->actor.gravity = 0.0f; - } else if (func_8008E9C4(this)) { - this->actor.gravity = -1.2f; - } - - func_80837268(this, &sp4C, &sp4A, 0.0f, globalCtx); - - if (!(this->actor.bgCheckFlags & 1)) { - if (this->stateFlags1 & 0x800) { - Actor* heldActor = this->heldActor; - - if (!func_80835644(globalCtx, this, heldActor) && (heldActor->id == ACTOR_EN_NIW) && - CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { - func_8084409C(globalCtx, this, this->linearVelocity + 2.0f, this->actor.velocity.y + 2.0f); - } - } - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (!(this->stateFlags2 & 0x80000)) { - func_8083DFE0(this, &sp4C, &sp4A); - } - - func_80836670(this, globalCtx); - - if (((this->stateFlags2 & 0x80000) && (this->unk_84F == 2)) || !func_8083BBA0(this, globalCtx)) { - if (this->actor.velocity.y < 0.0f) { - if (this->unk_850 >= 0) { - if ((this->actor.bgCheckFlags & 8) || (this->unk_850 == 0) || (this->fallDistance > 0)) { - if ((D_80853600 > 800.0f) || (this->stateFlags1 & 4)) { - func_80843E14(this, NA_SE_VO_LI_FALL_S); - this->stateFlags1 &= ~4; - } - - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_003020, 1.0f, 0.0f, 0.0f, - ANIMMODE_ONCE, 8.0f); - this->unk_850 = -1; - } - } else { - if ((this->unk_850 == -1) && (this->fallDistance > 120.0f) && (D_80853600 > 280.0f)) { - this->unk_850 = -2; - func_80843E14(this, NA_SE_VO_LI_FALL_L); - } - - if ((this->actor.bgCheckFlags & 0x200) && !(this->stateFlags2 & 0x80000) && - !(this->stateFlags1 & 0x8000800) && (this->linearVelocity > 0.0f)) { - if ((this->wallHeight >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) { - func_8083EC18(this, globalCtx, D_808535F0); - } else if ((this->unk_88C >= 2) && (this->wallHeight < 150.0f) && - (((this->actor.world.pos.y - this->actor.floorHeight) + this->wallHeight) > - (70.0f * this->ageProperties->unk_08))) { - AnimationContext_DisableQueue(globalCtx); - if (this->stateFlags1 & 4) { - func_80832698(this, NA_SE_VO_LI_HOOKSHOT_HANG); - } else { - func_80832698(this, NA_SE_VO_LI_HANG); - } - this->actor.world.pos.y += this->wallHeight; - func_8083A5C4(globalCtx, this, this->actor.wallPoly, this->wallDistance, - D_80853CBC[this->modelAnimType]); - this->actor.shape.rot.y = this->currentYaw += 0x8000; - this->stateFlags1 |= 0x2000; - } - } - } - } - } - } else { - LinkAnimationHeader* anim = D_80853A64[this->modelAnimType]; - s32 sp3C; - - if (this->stateFlags2 & 0x80000) { - if (func_8008E9C4(this)) { - anim = D_80853D4C[this->unk_84F][2]; - } else { - anim = D_80853D4C[this->unk_84F][1]; - } - } else if (this->skelAnime.animation == &gPlayerAnim_003148) { - anim = &gPlayerAnim_003150; - } else if (func_8008E9C4(this)) { - anim = &gPlayerAnim_002538; - func_80833C3C(this); - } else if (this->fallDistance <= 80) { - anim = D_80853A7C[this->modelAnimType]; - } else if ((this->fallDistance < 800) && (this->unk_84B[this->unk_846] == 0) && !(this->stateFlags1 & 0x800)) { - func_8083BC04(this, globalCtx); - return; - } - - sp3C = func_80843E64(globalCtx, this); - - if (sp3C > 0) { - func_8083A098(this, D_80853A64[this->modelAnimType], globalCtx); - this->skelAnime.endFrame = 8.0f; - if (sp3C == 1) { - this->unk_850 = 10; - } else { - this->unk_850 = 20; - } - } else if (sp3C == 0) { - func_8083A098(this, anim, globalCtx); - } - } -} - -static struct_80832924 D_8085460C[] = { - { NA_SE_VO_LI_SWORD_N, 0x2001 }, - { NA_SE_PL_WALK_GROUND, 0x1806 }, - { NA_SE_PL_ROLL, 0x806 }, - { 0, -0x2812 }, -}; - -void func_80844708(Player* this, GlobalContext* globalCtx) { - Actor* cylinderOc; - s32 temp; - s32 sp44; - DynaPolyActor* wallPolyActor; - s32 pad; - f32 sp38; - s16 sp36; - - this->stateFlags2 |= 0x20; - - cylinderOc = NULL; - sp44 = LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (LinkAnimation_OnFrame(&this->skelAnime, 8.0f)) { - func_80837AFC(this, -10); - } - - if (func_80842964(this, globalCtx) == 0) { - if (this->unk_850 != 0) { - Math_StepToF(&this->linearVelocity, 0.0f, 2.0f); - - temp = func_808374A0(globalCtx, this, &this->skelAnime, 5.0f); - if ((temp != 0) && ((temp > 0) || sp44)) { - func_8083A060(this, globalCtx); - } - } else { - if (this->linearVelocity >= 7.0f) { - if (((this->actor.bgCheckFlags & 0x200) && (D_8085360C < 0x2000)) || - ((this->cylinder.base.ocFlags1 & OC1_HIT) && - (cylinderOc = this->cylinder.base.oc, - ((cylinderOc->id == ACTOR_EN_WOOD02) && - (ABS((s16)(this->actor.world.rot.y - cylinderOc->yawTowardsPlayer)) > 0x6000))))) { - - if (cylinderOc != NULL) { - cylinderOc->home.rot.y = 1; - } else if (this->actor.wallBgId != BGCHECK_SCENE) { - wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.wallBgId); - if ((wallPolyActor != NULL) && (wallPolyActor->actor.id == ACTOR_OBJ_KIBAKO2)) { - wallPolyActor->actor.home.rot.z = 1; - } - } - - func_80832264(globalCtx, this, D_80853AAC[this->modelAnimType]); - this->linearVelocity = -this->linearVelocity; - func_808429B4(globalCtx, 33267, 3, 12); - func_8083264C(this, 255, 20, 150, 0); - func_8002F7DC(&this->actor, NA_SE_PL_BODY_HIT); - func_80832698(this, NA_SE_VO_LI_CLIMB_END); - this->unk_850 = 1; - return; - } - } - - if ((this->skelAnime.curFrame < 15.0f) || !func_80850224(this, globalCtx)) { - if (this->skelAnime.curFrame >= 20.0f) { - func_8083A060(this, globalCtx); - return; - } - - func_80837268(this, &sp38, &sp36, 0.018f, globalCtx); - - sp38 *= 1.5f; - if ((sp38 < 3.0f) || (this->unk_84B[this->unk_846] != 0)) { - sp38 = 3.0f; - } - - func_8083DF68(this, sp38, this->actor.shape.rot.y); - - if (func_8084269C(globalCtx, this)) { - func_8002F8F0(&this->actor, NA_SE_PL_ROLL_DUST - SFX_FLAG); - } - - func_80832924(this, D_8085460C); - } - } - } -} - -void func_80844A44(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x20; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, &gPlayerAnim_003160); - } - - Math_StepToF(&this->linearVelocity, 0.0f, 0.05f); - - if (this->actor.bgCheckFlags & 1) { - this->actor.colChkInfo.damage = 0x10; - func_80837C0C(globalCtx, this, 1, 4.0f, 5.0f, this->actor.shape.rot.y, 20); - } -} - -void func_80844AF4(Player* this, GlobalContext* globalCtx) { - f32 sp2C; - s16 sp2A; - - this->stateFlags2 |= 0x20; - - this->actor.gravity = -1.2f; - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (!func_80842DF4(globalCtx, this)) { - func_8084285C(this, 6.0f, 7.0f, 99.0f); - - if (!(this->actor.bgCheckFlags & 1)) { - func_80837268(this, &sp2C, &sp2A, 0.0f, globalCtx); - func_8083DFE0(this, &sp2C, &this->currentYaw); - return; - } - - if (func_80843E64(globalCtx, this) >= 0) { - this->swordAnimation += 2; - func_80837948(globalCtx, this, this->swordAnimation); - this->unk_845 = 3; - func_808328A0(this); - } - } -} - -s32 func_80844BE4(Player* this, GlobalContext* globalCtx) { - s32 temp; - - if (func_8083ADD4(globalCtx, this)) { - this->stateFlags2 |= 0x20000; - } else { - if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { - if ((this->unk_858 >= 0.85f) || func_808375D8(this)) { - temp = D_80854384[Player_HoldsTwoHandedWeapon(this)]; - } else { - temp = D_80854380[Player_HoldsTwoHandedWeapon(this)]; - } - - func_80837948(globalCtx, this, temp); - func_80837AFC(this, -8); - - this->stateFlags2 |= 0x20000; - if (this->unk_84B[this->unk_846] == 0) { - this->stateFlags2 |= 0x40000000; - } - } else { - return 0; - } - } - - return 1; -} - -void func_80844CF8(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80845000, 1); -} - -void func_80844D30(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80845308, 1); -} - -void func_80844D68(Player* this, GlobalContext* globalCtx) { - func_80839FFC(this, globalCtx); - func_80832318(this); - func_80832B0C(globalCtx, this, D_80854368[Player_HoldsTwoHandedWeapon(this)]); - this->currentYaw = this->actor.shape.rot.y; -} - -void func_80844DC8(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80844E68, 1); - this->unk_868 = 0.0f; - func_80832284(globalCtx, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); - this->unk_850 = 1; -} - -void func_80844E3C(Player* this) { - Math_StepToF(&this->unk_858, 1.0f, 0.02f); -} - -void func_80844E68(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - s32 temp; - - this->stateFlags1 |= 0x1000; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832DBC(this); - func_808355DC(this); - this->stateFlags1 &= ~0x20000; - func_80832284(globalCtx, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); - this->unk_850 = -1; - } - - func_8083721C(this); - - if (!func_80842964(this, globalCtx) && (this->unk_850 != 0)) { - func_80844E3C(this); - - if (this->unk_850 < 0) { - if (this->unk_858 >= 0.1f) { - this->unk_845 = 0; - this->unk_850 = 1; - } else if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { - func_80844D68(this, globalCtx); - } - } else if (!func_80844BE4(this, globalCtx)) { - func_80837268(this, &sp34, &sp32, 0.0f, globalCtx); - - temp = func_80840058(this, &sp34, &sp32, globalCtx); - if (temp > 0) { - func_80844CF8(this, globalCtx); - } else if (temp < 0) { - func_80844D30(this, globalCtx); - } - } - } -} - -void func_80845000(Player* this, GlobalContext* globalCtx) { - s16 temp1; - s32 temp2; - f32 sp5C; - f32 sp58; - f32 sp54; - s16 sp52; - s32 temp4; - s16 temp5; - s32 sp44; - - temp1 = this->currentYaw - this->actor.shape.rot.y; - temp2 = ABS(temp1); - - sp5C = fabsf(this->linearVelocity); - sp58 = sp5C * 1.5f; - - this->stateFlags1 |= 0x1000; - - if (sp58 < 1.5f) { - sp58 = 1.5f; - } - - sp58 = ((temp2 < 0x4000) ? -1.0f : 1.0f) * sp58; - - func_8084029C(this, sp58); - - sp58 = CLAMP(sp5C * 0.5f, 0.5f, 1.0f); - - LinkAnimation_BlendToJoint(globalCtx, &this->skelAnime, D_80854360[Player_HoldsTwoHandedWeapon(this)], 0.0f, - D_80854370[Player_HoldsTwoHandedWeapon(this)], this->unk_868 * (21.0f / 29.0f), sp58, - this->blendTable); - - if (!func_80842964(this, globalCtx) && !func_80844BE4(this, globalCtx)) { - func_80844E3C(this); - func_80837268(this, &sp54, &sp52, 0.0f, globalCtx); - - temp4 = func_80840058(this, &sp54, &sp52, globalCtx); - - if (temp4 < 0) { - func_80844D30(this, globalCtx); - return; - } - - if (temp4 == 0) { - sp54 = 0.0f; - sp52 = this->currentYaw; - } - - temp5 = sp52 - this->currentYaw; - sp44 = ABS(temp5); - - if (sp44 > 0x4000) { - if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = sp52; - } - return; - } - - Math_AsymStepToF(&this->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); - Math_ScaledStepToS(&this->currentYaw, sp52, sp44 * 0.1f); - - if ((sp54 == 0.0f) && (this->linearVelocity == 0.0f)) { - func_80844DC8(this, globalCtx); - } - } -} - -void func_80845308(Player* this, GlobalContext* globalCtx) { - f32 sp5C; - f32 sp58; - f32 sp54; - s16 sp52; - s32 temp4; - s16 temp5; - s32 sp44; - - sp5C = fabsf(this->linearVelocity); - - this->stateFlags1 |= 0x1000; - - if (sp5C == 0.0f) { - sp5C = ABS(this->unk_87C) * 0.0015f; - if (sp5C < 400.0f) { - sp5C = 0.0f; - } - func_8084029C(this, ((this->unk_87C >= 0) ? 1 : -1) * sp5C); - } else { - sp58 = sp5C * 1.5f; - if (sp58 < 1.5f) { - sp58 = 1.5f; - } - func_8084029C(this, sp58); - } - - sp58 = CLAMP(sp5C * 0.5f, 0.5f, 1.0f); - - LinkAnimation_BlendToJoint(globalCtx, &this->skelAnime, D_80854360[Player_HoldsTwoHandedWeapon(this)], 0.0f, - D_80854378[Player_HoldsTwoHandedWeapon(this)], this->unk_868 * (21.0f / 29.0f), sp58, - this->blendTable); - - if (!func_80842964(this, globalCtx) && !func_80844BE4(this, globalCtx)) { - func_80844E3C(this); - func_80837268(this, &sp54, &sp52, 0.0f, globalCtx); - - temp4 = func_80840058(this, &sp54, &sp52, globalCtx); - - if (temp4 > 0) { - func_80844CF8(this, globalCtx); - return; - } - - if (temp4 == 0) { - sp54 = 0.0f; - sp52 = this->currentYaw; - } - - temp5 = sp52 - this->currentYaw; - sp44 = ABS(temp5); - - if (sp44 > 0x4000) { - if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = sp52; - } - return; - } - - Math_AsymStepToF(&this->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); - Math_ScaledStepToS(&this->currentYaw, sp52, sp44 * 0.1f); - - if ((sp54 == 0.0f) && (this->linearVelocity == 0.0f) && (sp5C == 0.0f)) { - func_80844DC8(this, globalCtx); - } - } -} - -void func_80845668(Player* this, GlobalContext* globalCtx) { - s32 sp3C; - f32 temp1; - s32 temp2; - f32 temp3; - - this->stateFlags2 |= 0x20; - sp3C = LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (this->skelAnime.animation == &gPlayerAnim_002D48) { - this->linearVelocity = 1.0f; - - if (LinkAnimation_OnFrame(&this->skelAnime, 8.0f)) { - temp1 = this->wallHeight; - - if (temp1 > this->ageProperties->unk_0C) { - temp1 = this->ageProperties->unk_0C; - } - - if (this->stateFlags1 & 0x8000000) { - temp1 *= 0.085f; - } else { - temp1 *= 0.072f; - } - - if (!LINK_IS_ADULT) { - temp1 += 1.0f; - } - - func_80838940(this, NULL, temp1, globalCtx, NA_SE_VO_LI_AUTO_JUMP); - this->unk_850 = -1; - return; - } - } else { - temp2 = func_808374A0(globalCtx, this, &this->skelAnime, 4.0f); - - if (temp2 == 0) { - this->stateFlags1 &= ~0x44000; - return; - } - - if ((sp3C != 0) || (temp2 > 0)) { - func_8083C0E8(this, globalCtx); - this->stateFlags1 &= ~0x44000; - return; - } - - temp3 = 0.0f; - - if (this->skelAnime.animation == &gPlayerAnim_0032E8) { - if (LinkAnimation_OnFrame(&this->skelAnime, 30.0f)) { - func_8083D0A8(globalCtx, this, 10.0f); - } - temp3 = 50.0f; - } else if (this->skelAnime.animation == &gPlayerAnim_002D40) { - temp3 = 30.0f; - } else if (this->skelAnime.animation == &gPlayerAnim_002D38) { - temp3 = 16.0f; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, temp3)) { - func_808328A0(this); - func_80832698(this, NA_SE_VO_LI_CLIMB_END); - } - - if ((this->skelAnime.animation == &gPlayerAnim_002D38) || (this->skelAnime.curFrame > 5.0f)) { - if (this->unk_850 == 0) { - func_80832854(this); - this->unk_850 = 1; - } - Math_StepToF(&this->actor.shape.yOffset, 0.0f, 150.0f); - } - } -} - -void func_808458D0(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x60; - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (((this->stateFlags1 & 0x800) && (this->heldActor != NULL) && (this->getItemId == GI_NONE)) || - !func_80836670(this, globalCtx)) { - this->func_A74(globalCtx, this); - } -} - -s32 func_80845964(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2, f32 arg3, s16 arg4, s32 arg5) { - if ((arg5 != 0) && (this->linearVelocity == 0.0f)) { - return LinkAnimation_Update(globalCtx, &this->skelAnime); - } - - if (arg5 != 2) { - f32 sp34 = R_UPDATE_RATE * 0.5f; - f32 selfDistX = arg2->endPos.x - this->actor.world.pos.x; - f32 selfDistZ = arg2->endPos.z - this->actor.world.pos.z; - f32 sp28 = sqrtf(SQ(selfDistX) + SQ(selfDistZ)) / sp34; - s32 sp24 = (arg2->endFrame - globalCtx->csCtx.frames) + 1; - - arg4 = Math_Atan2S(selfDistZ, selfDistX); - - if (arg5 == 1) { - f32 distX = arg2->endPos.x - arg2->startPos.x; - f32 distZ = arg2->endPos.z - arg2->startPos.z; - s32 temp = (((sqrtf(SQ(distX) + SQ(distZ)) / sp34) / (arg2->endFrame - arg2->startFrame)) / 1.5f) * 4.0f; - - if (temp >= sp24) { - arg4 = this->actor.shape.rot.y; - arg3 = 0.0f; - } else { - arg3 = sp28 / ((sp24 - temp) + 1); - } - } else { - arg3 = sp28 / sp24; - } - } - - this->stateFlags2 |= 0x20; - func_80841EE4(this, globalCtx); - func_8083DF68(this, arg3, arg4); - - if ((arg3 == 0.0f) && (this->linearVelocity == 0.0f)) { - func_8083BF50(this, globalCtx); - } - - return 0; -} - -s32 func_80845BA0(GlobalContext* arg0, Player* arg1, f32* arg2, s32 arg3) { - f32 dx = arg1->unk_450.x - arg1->actor.world.pos.x; - f32 dz = arg1->unk_450.z - arg1->actor.world.pos.z; - s32 sp2C = sqrtf(SQ(dx) + SQ(dz)); - s16 yaw = Math_Vec3f_Yaw(&arg1->actor.world.pos, &arg1->unk_450); - - if (sp2C < arg3) { - *arg2 = 0.0f; - yaw = arg1->actor.shape.rot.y; - } - - if (func_80845964(arg0, arg1, NULL, *arg2, yaw, 2)) { - return 0; - } - - return sp2C; -} - -s32 func_80845C68(GlobalContext* globalCtx, s32 arg1) { - if (arg1 == 0) { - Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_DOWN, 0xDFF); - } - gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 0; - return arg1; -} - -void func_80845CA4(Player* this, GlobalContext* globalCtx) { - f32 sp3C; - s32 temp; - f32 sp34; - s32 sp30; - s32 pad; - - if (!func_8083B040(this, globalCtx)) { - if (this->unk_850 == 0) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (DECR(this->doorTimer) == 0) { - this->linearVelocity = 0.1f; - this->unk_850 = 1; - } - } else if (this->unk_84F == 0) { - sp3C = 5.0f * D_808535E8; - - if (func_80845BA0(globalCtx, this, &sp3C, -1) < 30) { - this->unk_84F = 1; - this->stateFlags1 |= 0x20000000; - - this->unk_450.x = this->unk_45C.x; - this->unk_450.z = this->unk_45C.z; - } - } else { - sp34 = 5.0f; - sp30 = 20; - - if (this->stateFlags1 & 1) { - sp34 = gSaveContext.entranceSpeed; - - if (D_808535F4 != 0) { - this->unk_450.x = (Math_SinS(D_808535FC) * 400.0f) + this->actor.world.pos.x; - this->unk_450.z = (Math_CosS(D_808535FC) * 400.0f) + this->actor.world.pos.z; - } - } else if (this->unk_850 < 0) { - this->unk_850++; - - sp34 = gSaveContext.entranceSpeed; - sp30 = -1; - } - - temp = func_80845BA0(globalCtx, this, &sp34, sp30); - - if ((this->unk_850 == 0) || - ((temp == 0) && (this->linearVelocity == 0.0f) && (Gameplay_GetCamera(globalCtx, 0)->unk_14C & 0x10))) { - - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - func_80845C68(globalCtx, gSaveContext.respawn[RESPAWN_MODE_DOWN].data); - - if (!func_8083B644(this, globalCtx)) { - func_8083CF5C(this, globalCtx); - } - } - } - } - - if (this->stateFlags1 & 0x800) { - func_80836670(this, globalCtx); - } -} - -void func_80845EF8(Player* this, GlobalContext* globalCtx) { - s32 sp2C; - - this->stateFlags2 |= 0x20; - sp2C = LinkAnimation_Update(globalCtx, &this->skelAnime); - - func_80836670(this, globalCtx); - - if (sp2C) { - if (this->unk_850 == 0) { - if (DECR(this->doorTimer) == 0) { - this->unk_850 = 1; - this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; - } - } else { - func_8083C0E8(this, globalCtx); - if (globalCtx->roomCtx.prevRoom.num >= 0) { - func_80097534(globalCtx, &globalCtx->roomCtx); - } - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - Gameplay_SetupRespawnPoint(globalCtx, 0, 0xDFF); - } - return; - } - - if (!(this->stateFlags1 & 0x20000000) && LinkAnimation_OnFrame(&this->skelAnime, 15.0f)) { - globalCtx->func_11D54(this, globalCtx); - } -} - -void func_80846050(Player* this, GlobalContext* globalCtx) { - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80839F90(this, globalCtx); - func_80835688(this, globalCtx); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 4.0f)) { - Actor* interactRangeActor = this->interactRangeActor; - - if (!func_80835644(globalCtx, this, interactRangeActor)) { - this->heldActor = interactRangeActor; - this->actor.child = interactRangeActor; - interactRangeActor->parent = &this->actor; - interactRangeActor->bgCheckFlags &= 0xFF00; - this->unk_3BC.y = interactRangeActor->shape.rot.y - this->actor.shape.rot.y; - } - return; - } - - Math_ScaledStepToS(&this->unk_3BC.y, 0, 4000); -} - -static struct_80832924 D_8085461C[] = { - { NA_SE_VO_LI_SWORD_L, 0x2031 }, - { NA_SE_VO_LI_SWORD_N, -0x20E6 }, -}; - -void func_80846120(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime) && (this->unk_850++ > 20)) { - if (!func_8083B040(this, globalCtx)) { - func_8083A098(this, &gPlayerAnim_002FA0, globalCtx); - } - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 41.0f)) { - BgHeavyBlock* heavyBlock = (BgHeavyBlock*)this->interactRangeActor; - - this->heldActor = &heavyBlock->dyna.actor; - this->actor.child = &heavyBlock->dyna.actor; - heavyBlock->dyna.actor.parent = &this->actor; - func_8002DBD0(&heavyBlock->dyna.actor, &heavyBlock->unk_164, &this->leftHandPos); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 229.0f)) { - Actor* heldActor = this->heldActor; - - heldActor->speedXZ = Math_SinS(heldActor->shape.rot.x) * 40.0f; - heldActor->velocity.y = Math_CosS(heldActor->shape.rot.x) * 40.0f; - heldActor->gravity = -2.0f; - heldActor->minVelocityY = -30.0f; - func_808323B4(globalCtx, this); - return; - } - - func_80832924(this, D_8085461C); -} - -void func_80846260(Player* this, GlobalContext* globalCtx) { - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, &gPlayerAnim_0032C0); - this->unk_850 = 1; - return; - } - - if (this->unk_850 == 0) { - if (LinkAnimation_OnFrame(&this->skelAnime, 27.0f)) { - Actor* interactRangeActor = this->interactRangeActor; - - this->heldActor = interactRangeActor; - this->actor.child = interactRangeActor; - interactRangeActor->parent = &this->actor; - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 25.0f)) { - func_80832698(this, NA_SE_VO_LI_SWORD_L); - return; - } - - } else if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { - func_80835C58(globalCtx, this, func_80846358, 1); - func_80832264(globalCtx, this, &gPlayerAnim_0032B8); - } -} - -void func_80846358(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80839F90(this, globalCtx); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 6.0f)) { - Actor* heldActor = this->heldActor; - - heldActor->world.rot.y = this->actor.shape.rot.y; - heldActor->speedXZ = 10.0f; - heldActor->velocity.y = 20.0f; - func_80834644(globalCtx, this); - func_8002F7DC(&this->actor, NA_SE_PL_THROW); - func_80832698(this, NA_SE_VO_LI_SWORD_N); - } -} - -void func_80846408(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, &gPlayerAnim_003070); - this->unk_850 = 15; - return; - } - - if (this->unk_850 != 0) { - this->unk_850--; - if (this->unk_850 == 0) { - func_8083A098(this, &gPlayerAnim_003068, globalCtx); - this->stateFlags1 &= ~0x800; - func_80832698(this, NA_SE_VO_LI_DAMAGE_S); - } - } -} - -void func_808464B0(Player* this, GlobalContext* globalCtx) { - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80839F90(this, globalCtx); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 4.0f)) { - Actor* heldActor = this->heldActor; - - if (!func_80835644(globalCtx, this, heldActor)) { - heldActor->velocity.y = 0.0f; - heldActor->speedXZ = 0.0f; - func_80834644(globalCtx, this); - if (heldActor->id == ACTOR_EN_BOM_CHU) { - func_8083B8F4(this, globalCtx); - } - } - } -} - -void func_80846578(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime) || - ((this->skelAnime.curFrame >= 8.0f) && func_80837268(this, &sp34, &sp32, 0.018f, globalCtx))) { - func_80839F90(this, globalCtx); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 3.0f)) { - func_8084409C(globalCtx, this, this->linearVelocity + 8.0f, 12.0f); - } -} - -static ColliderCylinderInit D_80854624 = { - { - COLTYPE_HIT5, - AT_NONE, - AC_ON | AC_TYPE_ENEMY, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_PLAYER, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK1, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 12, 60, 0, { 0, 0, 0 } }, -}; - -static ColliderQuadInit D_80854650 = { - { - COLTYPE_NONE, - AT_ON | AT_TYPE_PLAYER, - AC_NONE, - OC1_NONE, - OC2_TYPE_PLAYER, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK2, - { 0x00000100, 0x00, 0x01 }, - { 0xFFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -static ColliderQuadInit D_808546A0 = { - { - COLTYPE_METAL, - AT_ON | AT_TYPE_PLAYER, - AC_ON | AC_HARD | AC_TYPE_ENEMY, - OC1_NONE, - OC2_TYPE_PLAYER, - COLSHAPE_QUAD, - }, - { - ELEMTYPE_UNK2, - { 0x00100000, 0x00, 0x00 }, - { 0xDFCFFFFF, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE, - }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; - -void func_8084663C(Actor* thisx, GlobalContext* globalCtx) { -} - -void func_80846648(GlobalContext* globalCtx, Player* this) { - this->actor.update = func_8084663C; - this->actor.draw = NULL; -} - -void func_80846660(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084F710, 0); - if ((globalCtx->sceneNum == SCENE_SPOT06) && (gSaveContext.sceneSetupIndex >= 4)) { - this->unk_84F = 1; - } - this->stateFlags1 |= 0x20000000; - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_003298, 2.0f / 3.0f, 0.0f, 24.0f, ANIMMODE_ONCE, - 0.0f); - this->actor.world.pos.y += 800.0f; -} - -static u8 D_808546F0[] = { ITEM_SWORD_MASTER, ITEM_SWORD_KOKIRI }; - -void func_80846720(GlobalContext* globalCtx, Player* this, s32 arg2) { - s32 item = D_808546F0[(void)0, gSaveContext.linkAge]; - s32 actionParam = sItemActionParams[item]; - - func_80835EFC(this); - func_808323B4(globalCtx, this); - - this->heldItemId = item; - this->nextModelGroup = Player_ActionToModelGroup(this, actionParam); - - func_8083399C(globalCtx, this, actionParam); - func_80834644(globalCtx, this); - - if (arg2 != 0) { - func_8002F7DC(&this->actor, NA_SE_IT_SWORD_PICKOUT); - } -} - -static Vec3f D_808546F4 = { -1.0f, 69.0f, 20.0f }; - -void func_808467D4(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084E9AC, 0); - this->stateFlags1 |= 0x20000000; - Math_Vec3f_Copy(&this->actor.world.pos, &D_808546F4); - this->currentYaw = this->actor.shape.rot.y = -0x8000; - LinkAnimation_Change(globalCtx, &this->skelAnime, this->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, - ANIMMODE_ONCE, 0.0f); - func_80832F54(globalCtx, this, 0x28F); - if (LINK_IS_ADULT) { - func_80846720(globalCtx, this, 0); - } - this->unk_850 = 20; -} - -void func_808468A8(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084F9A0, 0); - func_80832F54(globalCtx, this, 0x9B); -} - -void func_808468E8(GlobalContext* globalCtx, Player* this) { - func_808389E8(this, &gPlayerAnim_002FE0, 12.0f, globalCtx); - func_80835C58(globalCtx, this, func_8084F9C0, 0); - this->stateFlags1 |= 0x20000000; - this->fallStartHeight = this->actor.world.pos.y; - OnePointCutscene_Init(globalCtx, 5110, 40, &this->actor, MAIN_CAM); -} - -void func_80846978(GlobalContext* globalCtx, Player* this) { - func_80837C0C(globalCtx, this, 1, 2.0f, 2.0f, this->actor.shape.rot.y + 0x8000, 0); -} - -void func_808469BC(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084F698, 0); - this->actor.draw = NULL; - this->stateFlags1 |= 0x20000000; -} - -static s16 D_80854700[] = { ACTOR_MAGIC_WIND, ACTOR_MAGIC_DARK, ACTOR_MAGIC_FIRE }; - -Actor* func_80846A00(GlobalContext* globalCtx, Player* this, s32 arg2) { - return Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_80854700[arg2], this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); -} - -void func_80846A68(GlobalContext* globalCtx, Player* this) { - this->actor.draw = NULL; - func_80835C58(globalCtx, this, func_8085076C, 0); - this->stateFlags1 |= 0x20000000; -} - -static InitChainEntry D_80854708[] = { - ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), -}; - -static EffectBlureInit2 D_8085470C = { - 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 4, - 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, -}; - -static Vec3s D_80854730 = { -57, 3377, 0 }; - -void Player_InitCommon(Player* this, GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader) { - this->ageProperties = &sAgeProperties[gSaveContext.linkAge]; - Actor_ProcessInitChain(&this->actor, D_80854708); - this->swordEffectIndex = TOTAL_EFFECT_COUNT; - this->currentYaw = this->actor.world.rot.y; - func_80834644(globalCtx, this); - - SkelAnime_InitLink(globalCtx, &this->skelAnime, skelHeader, D_80853914[this->modelAnimType], 9, this->jointTable, - this->morphTable, PLAYER_LIMB_MAX); - this->skelAnime.baseTransl = D_80854730; - SkelAnime_InitLink(globalCtx, &this->skelAnime2, skelHeader, func_80833338(this), 9, this->jointTable2, - this->morphTable2, PLAYER_LIMB_MAX); - this->skelAnime2.baseTransl = D_80854730; - - Effect_Add(globalCtx, &this->swordEffectIndex, EFFECT_BLURE2, 0, 0, &D_8085470C); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, this->ageProperties->unk_04); - this->unk_46C = SUBCAM_NONE; - Collider_InitCylinder(globalCtx, &this->cylinder); - Collider_SetCylinder(globalCtx, &this->cylinder, &this->actor, &D_80854624); - Collider_InitQuad(globalCtx, &this->swordQuads[0]); - Collider_SetQuad(globalCtx, &this->swordQuads[0], &this->actor, &D_80854650); - Collider_InitQuad(globalCtx, &this->swordQuads[1]); - Collider_SetQuad(globalCtx, &this->swordQuads[1], &this->actor, &D_80854650); - Collider_InitQuad(globalCtx, &this->shieldQuad); - Collider_SetQuad(globalCtx, &this->shieldQuad, &this->actor, &D_808546A0); -} - -static void (*D_80854738[])(GlobalContext* globalCtx, Player* this) = { - func_80846648, func_808467D4, func_80846660, func_808468A8, func_808468E8, func_808469BC, - func_80846A68, func_80846978, func_8083CA54, func_8083CA54, func_8083CA54, func_8083CA54, - func_8083CA54, func_8083CA20, func_8083CA54, func_8083CA9C, -}; - -static Vec3f D_80854778 = { 0.0f, 50.0f, 0.0f }; - -void Player_Init(Actor* thisx, GlobalContext* globalCtx2) { - Player* this = (Player*)thisx; - GlobalContext* globalCtx = globalCtx2; - SceneTableEntry* scene = globalCtx->loadedScene; - u32 titleFileSize; - s32 initMode; - s32 sp50; - s32 sp4C; - - globalCtx->shootingGalleryStatus = globalCtx->bombchuBowlingStatus = 0; - - globalCtx->playerInit = Player_InitCommon; - globalCtx->playerUpdate = Player_UpdateCommon; - globalCtx->isPlayerDroppingFish = Player_IsDroppingFish; - globalCtx->startPlayerFishing = Player_StartFishing; - globalCtx->grabPlayer = func_80852F38; - globalCtx->startPlayerCutscene = func_80852FFC; - globalCtx->func_11D54 = func_80853080; - globalCtx->damagePlayer = Player_InflictDamage; - globalCtx->talkWithPlayer = func_80853148; - - thisx->room = -1; - this->ageProperties = &sAgeProperties[gSaveContext.linkAge]; - this->itemActionParam = this->heldItemActionParam = -1; - this->heldItemId = ITEM_NONE; - - func_80835F44(globalCtx, this, ITEM_NONE); - Player_SetEquipmentData(globalCtx, this); - this->prevBoots = this->currentBoots; - Player_InitCommon(this, globalCtx, gPlayerSkelHeaders[((void)0, gSaveContext.linkAge)]); - this->giObjectSegment = (void*)(((uintptr_t)ZeldaArena_MallocDebug(0x3008, "../z_player.c", 17175) + 8) & ~0xF); - - sp50 = gSaveContext.respawnFlag; - - if (sp50 != 0) { - if (sp50 == -3) { - thisx->params = gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams; - } else { - if ((sp50 == 1) || (sp50 == -1)) { - this->unk_A86 = -2; - } - - if (sp50 < 0) { - sp4C = 0; - } else { - sp4C = sp50 - 1; - Math_Vec3f_Copy(&thisx->world.pos, &gSaveContext.respawn[sp50 - 1].pos); - Math_Vec3f_Copy(&thisx->home.pos, &thisx->world.pos); - Math_Vec3f_Copy(&thisx->prevPos, &thisx->world.pos); - this->fallStartHeight = thisx->world.pos.y; - this->currentYaw = thisx->shape.rot.y = gSaveContext.respawn[sp4C].yaw; - thisx->params = gSaveContext.respawn[sp4C].playerParams; - } - - globalCtx->actorCtx.flags.tempSwch = gSaveContext.respawn[sp4C].tempSwchFlags & 0xFFFFFF; - globalCtx->actorCtx.flags.tempCollect = gSaveContext.respawn[sp4C].tempCollectFlags; - } - } - - if ((sp50 == 0) || (sp50 < -1)) { - titleFileSize = POINTER_SUB(scene->titleFile.vromEnd, scene->titleFile.vromStart); - if ((titleFileSize != 0) && gSaveContext.showTitleCard) { - if ((gSaveContext.sceneSetupIndex < 4) && - (gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].field & - 0x4000) && - ((globalCtx->sceneNum != SCENE_DDAN) || (gSaveContext.eventChkInf[11] & 1)) && - ((globalCtx->sceneNum != SCENE_NIGHT_SHOP) || (gSaveContext.eventChkInf[2] & 0x20))) { - TitleCard_InitPlaceName(globalCtx, &globalCtx->actorCtx.titleCtx, this->giObjectSegment, 160, 120, 144, - 24, 20); - } - } - gSaveContext.showTitleCard = true; - } - - if (func_80845C68(globalCtx, (sp50 == 2) ? 1 : 0) == 0) { - gSaveContext.respawn[RESPAWN_MODE_DOWN].playerParams = (thisx->params & 0xFF) | 0xD00; - } - - gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 1; - - if (globalCtx->sceneNum <= SCENE_GANONTIKA_SONOGO) { - gSaveContext.infTable[26] |= gBitFlags[globalCtx->sceneNum]; - } - - initMode = (thisx->params & 0xF00) >> 8; - if ((initMode == 5) || (initMode == 6)) { - if (gSaveContext.cutsceneIndex >= 0xFFF0) { - initMode = 13; - } - } - - D_80854738[initMode](globalCtx, this); - - if (initMode != 0) { - if ((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 3)) { - this->naviActor = Player_SpawnFairy(globalCtx, this, &thisx->world.pos, &D_80854778, FAIRY_NAVI); - if (gSaveContext.dogParams != 0) { - gSaveContext.dogParams |= 0x8000; - } - } - } - - if (gSaveContext.nayrusLoveTimer != 0) { - gSaveContext.unk_13F0 = 3; - func_80846A00(globalCtx, this, 1); - this->stateFlags3 &= ~0x40; - } - - if (gSaveContext.entranceSound != 0) { - Audio_PlayActorSound2(&this->actor, ((void)0, gSaveContext.entranceSound)); - gSaveContext.entranceSound = 0; - } - - Map_SavePlayerInitialInfo(globalCtx); - MREG(64) = 0; -} - -void func_808471F4(s16* pValue) { - s16 step; - - step = (ABS(*pValue) * 100.0f) / 1000.0f; - step = CLAMP(step, 400, 4000); - - Math_ScaledStepToS(pValue, 0, step); -} - -void func_80847298(Player* this) { - s16 sp26; - - if (!(this->unk_6AE & 2)) { - sp26 = this->actor.focus.rot.y - this->actor.shape.rot.y; - func_808471F4(&sp26); - this->actor.focus.rot.y = this->actor.shape.rot.y + sp26; - } - - if (!(this->unk_6AE & 1)) { - func_808471F4(&this->actor.focus.rot.x); - } - - if (!(this->unk_6AE & 8)) { - func_808471F4(&this->unk_6B6); - } - - if (!(this->unk_6AE & 0x40)) { - func_808471F4(&this->unk_6BC); - } - - if (!(this->unk_6AE & 4)) { - func_808471F4(&this->actor.focus.rot.z); - } - - if (!(this->unk_6AE & 0x10)) { - func_808471F4(&this->unk_6B8); - } - - if (!(this->unk_6AE & 0x20)) { - func_808471F4(&this->unk_6BA); - } - - if (!(this->unk_6AE & 0x80)) { - if (this->unk_6B0 != 0) { - func_808471F4(&this->unk_6B0); - } else { - func_808471F4(&this->unk_6BE); - } - } - - if (!(this->unk_6AE & 0x100)) { - func_808471F4(&this->unk_6C0); - } - - this->unk_6AE = 0; -} - -static f32 D_80854784[] = { 120.0f, 240.0f, 360.0f }; - -static u8 sDiveDoActions[] = { DO_ACTION_1, DO_ACTION_2, DO_ACTION_3, DO_ACTION_4, - DO_ACTION_5, DO_ACTION_6, DO_ACTION_7, DO_ACTION_8 }; - -void func_808473D4(GlobalContext* globalCtx, Player* this) { - if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) && (this->actor.category == ACTORCAT_PLAYER)) { - Actor* heldActor = this->heldActor; - Actor* interactRangeActor = this->interactRangeActor; - s32 sp24; - s32 sp20 = this->unk_84B[this->unk_846]; - s32 sp1C = func_808332B8(this); - s32 doAction = DO_ACTION_NONE; - - if (!Player_InBlockingCsMode(globalCtx, this)) { - if (this->stateFlags1 & 0x100000) { - doAction = DO_ACTION_RETURN; - } else if ((this->heldItemActionParam == PLAYER_AP_FISHING_POLE) && (this->unk_860 != 0)) { - if (this->unk_860 == 2) { - doAction = DO_ACTION_REEL; - } - } else if ((func_8084E3C4 != this->func_674) && !(this->stateFlags2 & 0x40000)) { - if ((this->doorType != PLAYER_DOORTYPE_NONE) && - (!(this->stateFlags1 & 0x800) || ((heldActor != NULL) && (heldActor->id == ACTOR_EN_RU1)))) { - doAction = DO_ACTION_OPEN; - } else if ((!(this->stateFlags1 & 0x800) || (heldActor == NULL)) && (interactRangeActor != NULL) && - ((!sp1C && (this->getItemId == GI_NONE)) || - ((this->getItemId < 0) && !(this->stateFlags1 & 0x8000000)))) { - if (this->getItemId < 0) { - doAction = DO_ACTION_OPEN; - } else if ((interactRangeActor->id == ACTOR_BG_TOKI_SWD) && LINK_IS_ADULT) { - doAction = DO_ACTION_DROP; - } else { - doAction = DO_ACTION_GRAB; - } - } else if (!sp1C && (this->stateFlags2 & 1)) { - doAction = DO_ACTION_GRAB; - } else if ((this->stateFlags2 & 4) || (!(this->stateFlags1 & 0x800000) && (this->rideActor != NULL))) { - doAction = DO_ACTION_CLIMB; - } else if ((this->stateFlags1 & 0x800000) && !EN_HORSE_CHECK_4((EnHorse*)this->rideActor) && - (func_8084D3E4 != this->func_674)) { - if ((this->stateFlags2 & 2) && (this->targetActor != NULL)) { - if (this->targetActor->category == ACTORCAT_NPC) { - doAction = DO_ACTION_SPEAK; - } else { - doAction = DO_ACTION_CHECK; - } - } else if (!func_8002DD78(this) && !(this->stateFlags1 & 0x100000)) { - doAction = DO_ACTION_FASTER; - } - } else if ((this->stateFlags2 & 2) && (this->targetActor != NULL)) { - if (this->targetActor->category == ACTORCAT_NPC) { - doAction = DO_ACTION_SPEAK; - } else { - doAction = DO_ACTION_CHECK; - } - } else if ((this->stateFlags1 & 0x202000) || - ((this->stateFlags1 & 0x800000) && (this->stateFlags2 & 0x400000))) { - doAction = DO_ACTION_DOWN; - } else if (this->stateFlags2 & 0x10000) { - doAction = DO_ACTION_ENTER; - } else if ((this->stateFlags1 & 0x800) && (this->getItemId == GI_NONE) && (heldActor != NULL)) { - if ((this->actor.bgCheckFlags & 1) || (heldActor->id == ACTOR_EN_NIW)) { - if (func_8083EAF0(this, heldActor) == 0) { - doAction = DO_ACTION_DROP; - } else { - doAction = DO_ACTION_THROW; - } - } - } else if (!(this->stateFlags1 & 0x8000000) && func_8083A0D4(this) && (this->getItemId < GI_MAX)) { - doAction = DO_ACTION_GRAB; - } else if (this->stateFlags2 & 0x800) { - sp24 = (D_80854784[CUR_UPG_VALUE(UPG_SCALE)] - this->actor.yDistToWater) / 40.0f; - sp24 = CLAMP(sp24, 0, 7); - doAction = sDiveDoActions[sp24]; - } else if (sp1C && !(this->stateFlags2 & 0x400)) { - doAction = DO_ACTION_DIVE; - } else if (!sp1C && (!(this->stateFlags1 & 0x400000) || func_80833BCC(this) || - !Player_IsChildWithHylianShield(this))) { - if ((!(this->stateFlags1 & 0x4000) && (sp20 <= 0) && - (func_8008E9C4(this) || - ((D_808535E4 != 7) && - (func_80833B2C(this) || ((globalCtx->roomCtx.curRoom.unk_03 != 2) && - !(this->stateFlags1 & 0x400000) && (sp20 == 0))))))) { - doAction = DO_ACTION_ATTACK; - } else if ((globalCtx->roomCtx.curRoom.unk_03 != 2) && func_80833BCC(this) && (sp20 > 0)) { - doAction = DO_ACTION_JUMP; - } else if ((this->heldItemActionParam >= PLAYER_AP_SWORD_MASTER) || - ((this->stateFlags2 & 0x100000) && - (globalCtx->actorCtx.targetCtx.arrowPointedActor == NULL))) { - doAction = DO_ACTION_PUTAWAY; - } - } - } - } - - if (doAction != DO_ACTION_PUTAWAY) { - this->unk_837 = 20; - } else if (this->unk_837 != 0) { - doAction = DO_ACTION_NONE; - this->unk_837--; - } - - Interface_SetDoAction(globalCtx, doAction); - - if (this->stateFlags2 & 0x200000) { - if (this->unk_664 != NULL) { - Interface_SetNaviCall(globalCtx, 0x1E); - } else { - Interface_SetNaviCall(globalCtx, 0x1D); - } - Interface_SetNaviCall(globalCtx, 0x1E); - } else { - Interface_SetNaviCall(globalCtx, 0x1F); - } - } -} - -s32 func_80847A78(Player* this) { - s32 cond; - - if ((this->currentBoots == PLAYER_BOOTS_HOVER) && (this->hoverBootsTimer != 0)) { - this->hoverBootsTimer--; - } else { - this->hoverBootsTimer = 0; - } - - cond = (this->currentBoots == PLAYER_BOOTS_HOVER) && - ((this->actor.yDistToWater >= 0.0f) || (func_80838144(D_808535E4) >= 0) || func_8083816C(D_808535E4)); - - if (cond && (this->actor.bgCheckFlags & 1) && (this->hoverBootsTimer != 0)) { - this->actor.bgCheckFlags &= ~1; - } - - if (this->actor.bgCheckFlags & 1) { - if (!cond) { - this->hoverBootsTimer = 19; - } - return 0; - } - - D_808535E4 = 0; - this->unk_898 = this->unk_89A = D_80853610 = 0; - - return 1; -} - -static Vec3f D_80854798 = { 0.0f, 18.0f, 0.0f }; - -void func_80847BA0(GlobalContext* globalCtx, Player* this) { - u8 spC7 = 0; - CollisionPoly* spC0; - Vec3f spB4; - f32 spB0; - f32 spAC; - f32 spA8; - u32 spA4; - - D_80853604 = this->unk_A7A; - - if (this->stateFlags2 & 0x40000) { - spB0 = 10.0f; - spAC = 15.0f; - spA8 = 30.0f; - } else { - spB0 = this->ageProperties->unk_38; - spAC = 26.0f; - spA8 = this->ageProperties->unk_00; - } - - if (this->stateFlags1 & 0xA0000000) { - if (this->stateFlags1 & 0x80000000) { - this->actor.bgCheckFlags &= ~1; - spA4 = 0x38; - } else if ((this->stateFlags1 & 1) && ((this->unk_A84 - (s32)this->actor.world.pos.y) >= 100)) { - spA4 = 0x39; - } else if (!(this->stateFlags1 & 1) && - ((func_80845EF8 == this->func_674) || (func_80845CA4 == this->func_674))) { - this->actor.bgCheckFlags &= ~0x208; - spA4 = 0x3C; - } else { - spA4 = 0x3F; - } - } else { - spA4 = 0x3F; - } - - if (this->stateFlags3 & 1) { - spA4 &= ~6; - } - - if (spA4 & 4) { - this->stateFlags3 |= 0x10; - } - - Math_Vec3f_Copy(&spB4, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, spAC, spB0, spA8, spA4); - - if (this->actor.bgCheckFlags & 0x10) { - this->actor.velocity.y = 0.0f; - } - - D_80853600 = this->actor.world.pos.y - this->actor.floorHeight; - D_808535F4 = 0; - - spC0 = this->actor.floorPoly; - - if (spC0 != NULL) { - this->unk_A7A = func_80041EA4(&globalCtx->colCtx, spC0, this->actor.floorBgId); - this->unk_A82 = this->unk_89E; - - if (this->actor.bgCheckFlags & 0x20) { - if (this->actor.yDistToWater < 20.0f) { - this->unk_89E = 4; - } else { - this->unk_89E = 5; - } - } else { - if (this->stateFlags2 & 0x200) { - this->unk_89E = 1; - } else { - this->unk_89E = SurfaceType_GetSfx(&globalCtx->colCtx, spC0, this->actor.floorBgId); - } - } - - if (this->actor.category == ACTORCAT_PLAYER) { - Audio_SetCodeReverb(SurfaceType_GetEcho(&globalCtx->colCtx, spC0, this->actor.floorBgId)); - - if (this->actor.floorBgId == BGCHECK_SCENE) { - func_80074CE8(globalCtx, - SurfaceType_GetLightSettingIndex(&globalCtx->colCtx, spC0, this->actor.floorBgId)); - } else { - func_80043508(&globalCtx->colCtx, this->actor.floorBgId); - } - } - - D_808535F4 = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, spC0, this->actor.floorBgId); - if (D_808535F4 != 0) { - D_808535F8 = SurfaceType_IsConveyor(&globalCtx->colCtx, spC0, this->actor.floorBgId); - if (((D_808535F8 == 0) && (this->actor.yDistToWater > 20.0f) && - (this->currentBoots != PLAYER_BOOTS_IRON)) || - ((D_808535F8 != 0) && (this->actor.bgCheckFlags & 1))) { - D_808535FC = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, spC0, this->actor.floorBgId) << 10; - } else { - D_808535F4 = 0; - } - } - } - - func_80839034(globalCtx, this, spC0, this->actor.floorBgId); - - this->actor.bgCheckFlags &= ~0x200; - - if (this->actor.bgCheckFlags & 8) { - CollisionPoly* spA0; - s32 sp9C; - s16 sp9A; - s32 pad; - - D_80854798.y = 18.0f; - D_80854798.z = this->ageProperties->unk_38 + 10.0f; - - if (!(this->stateFlags2 & 0x40000) && func_80839768(globalCtx, this, &D_80854798, &spA0, &sp9C, &D_80858AA8)) { - this->actor.bgCheckFlags |= 0x200; - if (this->actor.wallPoly != spA0) { - this->actor.wallPoly = spA0; - this->actor.wallBgId = sp9C; - this->actor.wallYaw = Math_Atan2S(spA0->normal.z, spA0->normal.x); - } - } - - sp9A = this->actor.shape.rot.y - (s16)(this->actor.wallYaw + 0x8000); - - D_808535F0 = func_80041DB8(&globalCtx->colCtx, this->actor.wallPoly, this->actor.wallBgId); - - D_80853608 = ABS(sp9A); - - sp9A = this->currentYaw - (s16)(this->actor.wallYaw + 0x8000); - - D_8085360C = ABS(sp9A); - - spB0 = D_8085360C * 0.00008f; - if (!(this->actor.bgCheckFlags & 1) || spB0 >= 1.0f) { - this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; - } else { - spAC = (R_RUN_SPEED_LIMIT / 100.0f * spB0); - this->unk_880 = spAC; - if (spAC < 0.1f) { - this->unk_880 = 0.1f; - } - } - - if ((this->actor.bgCheckFlags & 0x200) && (D_80853608 < 0x3000)) { - CollisionPoly* wallPoly = this->actor.wallPoly; - - if (ABS(wallPoly->normal.y) < 600) { - f32 sp8C = COLPOLY_GET_NORMAL(wallPoly->normal.x); - f32 sp88 = COLPOLY_GET_NORMAL(wallPoly->normal.y); - f32 sp84 = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 wallHeight; - CollisionPoly* sp7C; - CollisionPoly* sp78; - s32 sp74; - Vec3f sp68; - f32 sp64; - f32 sp60; - s32 temp3; - - this->wallDistance = Math3D_UDistPlaneToPos(sp8C, sp88, sp84, wallPoly->dist, &this->actor.world.pos); - - spB0 = this->wallDistance + 10.0f; - sp68.x = this->actor.world.pos.x - (spB0 * sp8C); - sp68.z = this->actor.world.pos.z - (spB0 * sp84); - sp68.y = this->actor.world.pos.y + this->ageProperties->unk_0C; - - sp64 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp7C, &sp68); - wallHeight = sp64 - this->actor.world.pos.y; - this->wallHeight = wallHeight; - - if ((this->wallHeight < 18.0f) || - BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp60, &this->actor.world.pos, - (sp64 - this->actor.world.pos.y) + 20.0f, &sp78, &sp74, &this->actor)) { - this->wallHeight = 399.96002f; - } else { - D_80854798.y = (sp64 + 5.0f) - this->actor.world.pos.y; - - if (func_80839768(globalCtx, this, &D_80854798, &sp78, &sp74, &D_80858AA8) && - (temp3 = this->actor.wallYaw - Math_Atan2S(sp78->normal.z, sp78->normal.x), - ABS(temp3) < 0x4000) && - !func_80041E18(&globalCtx->colCtx, sp78, sp74)) { - this->wallHeight = 399.96002f; - } else if (func_80041DE4(&globalCtx->colCtx, wallPoly, this->actor.wallBgId) == 0) { - if (this->ageProperties->unk_1C <= this->wallHeight) { - if (ABS(sp7C->normal.y) > 28000) { - if (this->ageProperties->unk_14 <= this->wallHeight) { - spC7 = 4; - } else if (this->ageProperties->unk_18 <= this->wallHeight) { - spC7 = 3; - } else { - spC7 = 2; - } - } - } else { - spC7 = 1; - } - } - } - } - } - } else { - this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; - this->unk_88D = 0; - this->wallHeight = 0.0f; - } - - if (spC7 == this->unk_88C) { - if ((this->linearVelocity != 0.0f) && (this->unk_88D < 100)) { - this->unk_88D++; - } - } else { - this->unk_88C = spC7; - this->unk_88D = 0; - } - - if (this->actor.bgCheckFlags & 1) { - D_808535E4 = func_80041D4C(&globalCtx->colCtx, spC0, this->actor.floorBgId); - - if (!func_80847A78(this)) { - f32 sp58; - f32 sp54; - f32 sp50; - f32 sp4C; - s32 pad2; - f32 sp44; - s32 pad3; - - if (this->actor.floorBgId != BGCHECK_SCENE) { - func_800434C8(&globalCtx->colCtx, this->actor.floorBgId); - } - - sp58 = COLPOLY_GET_NORMAL(spC0->normal.x); - sp54 = 1.0f / COLPOLY_GET_NORMAL(spC0->normal.y); - sp50 = COLPOLY_GET_NORMAL(spC0->normal.z); - - sp4C = Math_SinS(this->currentYaw); - sp44 = Math_CosS(this->currentYaw); - - this->unk_898 = Math_Atan2S(1.0f, (-(sp58 * sp4C) - (sp50 * sp44)) * sp54); - this->unk_89A = Math_Atan2S(1.0f, (-(sp58 * sp44) - (sp50 * sp4C)) * sp54); - - sp4C = Math_SinS(this->actor.shape.rot.y); - sp44 = Math_CosS(this->actor.shape.rot.y); - - D_80853610 = Math_Atan2S(1.0f, (-(sp58 * sp4C) - (sp50 * sp44)) * sp54); - - func_8083E318(globalCtx, this, spC0); - } - } else { - func_80847A78(this); - } - - if (this->unk_A7B == D_808535E4) { - this->unk_A79++; - } else { - this->unk_A7B = D_808535E4; - this->unk_A79 = 0; - } -} - -void Player_UpdateCamAndSeqModes(GlobalContext* globalCtx, Player* this) { - u8 seqMode; - s32 pad; - Actor* unk_664; - s32 camMode; - - if (this->actor.category == ACTORCAT_PLAYER) { - seqMode = SEQ_MODE_DEFAULT; - - if (this->csMode != 0) { - Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), CAM_MODE_NORMAL); - } else if (!(this->stateFlags1 & 0x100000)) { - if ((this->actor.parent != NULL) && (this->stateFlags3 & 0x80)) { - camMode = CAM_MODE_HOOKSHOT; - Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, this->actor.parent); - } else if (func_8084377C == this->func_674) { - camMode = CAM_MODE_STILL; - } else if (this->stateFlags2 & 0x100) { - camMode = CAM_MODE_PUSHPULL; - } else if ((unk_664 = this->unk_664) != NULL) { - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_8)) { - camMode = CAM_MODE_TALK; - } else if (this->stateFlags1 & 0x10000) { - if (this->stateFlags1 & 0x2000000) { - camMode = CAM_MODE_FOLLOWBOOMERANG; - } else { - camMode = CAM_MODE_FOLLOWTARGET; - } - } else { - camMode = CAM_MODE_BATTLE; - } - Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, unk_664); - } else if (this->stateFlags1 & 0x1000) { - camMode = CAM_MODE_CHARGE; - } else if (this->stateFlags1 & 0x2000000) { - camMode = CAM_MODE_FOLLOWBOOMERANG; - Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, this->boomerangActor); - } else if (this->stateFlags1 & 0x6000) { - if (func_80833B2C(this)) { - camMode = CAM_MODE_HANGZ; - } else { - camMode = CAM_MODE_HANG; - } - } else if (this->stateFlags1 & 0x40020000) { - if (func_8002DD78(this) || func_808334B4(this)) { - camMode = CAM_MODE_BOWARROWZ; - } else if (this->stateFlags1 & 0x200000) { - camMode = CAM_MODE_CLIMBZ; - } else { - camMode = CAM_MODE_TARGET; - } - } else if (this->stateFlags1 & 0x240000) { - if ((func_80845668 == this->func_674) || (this->stateFlags1 & 0x200000)) { - camMode = CAM_MODE_CLIMB; - } else { - camMode = CAM_MODE_JUMP; - } - } else if (this->stateFlags1 & 0x80000) { - camMode = CAM_MODE_FREEFALL; - } else if ((this->swordState != 0) && (this->swordAnimation >= 0) && (this->swordAnimation < 0x18)) { - camMode = CAM_MODE_STILL; - } else { - camMode = CAM_MODE_NORMAL; - if ((this->linearVelocity == 0.0f) && - (!(this->stateFlags1 & 0x800000) || (this->rideActor->speedXZ == 0.0f))) { - // not moving - seqMode = SEQ_MODE_STILL; - } - } - - Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), camMode); - } else { - // First person mode - seqMode = SEQ_MODE_STILL; - } - - if (globalCtx->actorCtx.targetCtx.bgmEnemy != NULL) { - seqMode = SEQ_MODE_ENEMY; - Audio_SetBgmEnemyVolume(sqrtf(globalCtx->actorCtx.targetCtx.bgmEnemy->xyzDistToPlayerSq)); - } - - if (globalCtx->sceneNum != SCENE_TURIBORI) { - Audio_SetSequenceMode(seqMode); - } - } -} - -static Vec3f D_808547A4 = { 0.0f, 0.5f, 0.0f }; -static Vec3f D_808547B0 = { 0.0f, 0.5f, 0.0f }; - -static Color_RGBA8 D_808547BC = { 255, 255, 100, 255 }; -static Color_RGBA8 D_808547C0 = { 255, 50, 0, 0 }; - -void func_80848A04(GlobalContext* globalCtx, Player* this) { - f32 temp; - - if (this->unk_85C == 0.0f) { - func_80835F44(globalCtx, this, 0xFF); - return; - } - - temp = 1.0f; - if (DECR(this->unk_860) == 0) { - Inventory_ChangeAmmo(ITEM_STICK, -1); - this->unk_860 = 1; - temp = 0.0f; - this->unk_85C = temp; - } else if (this->unk_860 > 200) { - temp = (210 - this->unk_860) / 10.0f; - } else if (this->unk_860 < 20) { - temp = this->unk_860 / 20.0f; - this->unk_85C = temp; - } - - func_8002836C(globalCtx, &this->swordInfo[0].tip, &D_808547A4, &D_808547B0, &D_808547BC, &D_808547C0, temp * 200.0f, - 0, 8); -} - -void func_80848B44(GlobalContext* globalCtx, Player* this) { - Vec3f shockPos; - Vec3f* randBodyPart; - s32 shockScale; - - this->shockTimer--; - this->unk_892 += this->shockTimer; - - if (this->unk_892 > 20) { - shockScale = this->shockTimer * 2; - this->unk_892 -= 20; - - if (shockScale > 40) { - shockScale = 40; - } - - randBodyPart = this->bodyPartsPos + (s32)Rand_ZeroFloat(17.9f); - shockPos.x = (Rand_CenteredFloat(5.0f) + randBodyPart->x) - this->actor.world.pos.x; - shockPos.y = (Rand_CenteredFloat(5.0f) + randBodyPart->y) - this->actor.world.pos.y; - shockPos.z = (Rand_CenteredFloat(5.0f) + randBodyPart->z) - this->actor.world.pos.z; - - EffectSsFhgFlash_SpawnShock(globalCtx, &this->actor, &shockPos, shockScale, FHGFLASH_SHOCK_PLAYER); - func_8002F8F0(&this->actor, NA_SE_PL_SPARK - SFX_FLAG); - } -} - -void func_80848C74(GlobalContext* globalCtx, Player* this) { - s32 spawnedFlame; - u8* timerPtr; - s32 timerStep; - f32 flameScale; - f32 flameIntensity; - s32 dmgCooldown; - s32 i; - s32 sp58; - s32 sp54; - - if (this->currentTunic == PLAYER_TUNIC_GORON) { - sp54 = 20; - } else { - sp54 = (s32)(this->linearVelocity * 0.4f) + 1; - } - - spawnedFlame = false; - timerPtr = this->flameTimers; - - if (this->stateFlags2 & 8) { - sp58 = 100; - } else { - sp58 = 0; - } - - func_8083819C(this, globalCtx); - - for (i = 0; i < 18; i++, timerPtr++) { - timerStep = sp58 + sp54; - - if (*timerPtr <= timerStep) { - *timerPtr = 0; - } else { - spawnedFlame = true; - *timerPtr -= timerStep; - - if (*timerPtr > 20.0f) { - flameIntensity = (*timerPtr - 20.0f) * 0.01f; - flameScale = CLAMP(flameIntensity, 0.19999999f, 0.2f); - } else { - flameScale = *timerPtr * 0.01f; - } - - flameIntensity = (*timerPtr - 25.0f) * 0.02f; - flameIntensity = CLAMP(flameIntensity, 0.0f, 1.0f); - EffectSsFireTail_SpawnFlameOnPlayer(globalCtx, flameScale, i, flameIntensity); - } - } - - if (spawnedFlame) { - func_8002F7DC(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); - - if (globalCtx->sceneNum == SCENE_JYASINBOSS) { - dmgCooldown = 0; - } else { - dmgCooldown = 7; - } - - if ((dmgCooldown & globalCtx->gameplayFrames) == 0) { - Player_InflictDamage(globalCtx, -1); - } - } else { - this->isBurning = false; - } -} - -void func_80848EF8(Player* this) { - if (CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)) { - f32 temp = 200000.0f - (this->unk_6A4 * 5.0f); - - if (temp < 0.0f) { - temp = 0.0f; - } - - this->unk_6A0 += temp; - if (this->unk_6A0 > 4000000.0f) { - this->unk_6A0 = 0.0f; - func_8083264C(this, 120, 20, 10, 0); - } - } -} - -static s8 D_808547C4[] = { - 0, 3, 3, 5, 4, 8, 9, 13, 14, 15, 16, 17, 18, -22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, -35, - 30, 36, 38, -39, -40, -41, 42, 43, 45, 46, 0, 0, 0, 67, 48, 47, -50, 51, -52, -53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, -65, -66, 68, 11, 69, 70, 71, 8, 8, 72, 73, 78, 79, 80, 89, 90, 91, 92, 77, 19, 94, -}; - -static Vec3f D_80854814 = { 0.0f, 0.0f, 200.0f }; - -static f32 D_80854820[] = { 2.0f, 4.0f, 7.0f }; -static f32 D_8085482C[] = { 0.5f, 1.0f, 3.0f }; - -void Player_UpdateCommon(Player* this, GlobalContext* globalCtx, Input* input) { - s32 pad; - - sControlInput = input; - - if (this->unk_A86 < 0) { - this->unk_A86++; - if (this->unk_A86 == 0) { - this->unk_A86 = 1; - func_80078884(NA_SE_OC_REVENGE); - } - } - - Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.home.pos); - - if (this->unk_A73 != 0) { - this->unk_A73--; - } - - if (this->unk_88E != 0) { - this->unk_88E--; - } - - if (this->unk_A87 != 0) { - this->unk_A87--; - } - - if (this->invincibilityTimer < 0) { - this->invincibilityTimer++; - } else if (this->invincibilityTimer > 0) { - this->invincibilityTimer--; - } - - if (this->unk_890 != 0) { - this->unk_890--; - } - - func_808473D4(globalCtx, this); - func_80836BEC(this, globalCtx); - - if ((this->heldItemActionParam == PLAYER_AP_STICK) && (this->unk_860 != 0)) { - func_80848A04(globalCtx, this); - } else if ((this->heldItemActionParam == PLAYER_AP_FISHING_POLE) && (this->unk_860 < 0)) { - this->unk_860++; - } - - if (this->shockTimer != 0) { - func_80848B44(globalCtx, this); - } - - if (this->isBurning) { - func_80848C74(globalCtx, this); - } - - if ((this->stateFlags3 & 0x40) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.unk_13F0 == 0)) { - gSaveContext.unk_13F0 = 3; - func_80846A00(globalCtx, this, 1); - this->stateFlags3 &= ~0x40; - } - - if (this->stateFlags2 & 0x8000) { - if (!(this->actor.bgCheckFlags & 1)) { - func_80832210(this); - Actor_MoveForward(&this->actor); - } - - func_80847BA0(globalCtx, this); - } else { - f32 temp_f0; - f32 phi_f12; - - if (this->currentBoots != this->prevBoots) { - if (this->currentBoots == PLAYER_BOOTS_IRON) { - if (this->stateFlags1 & 0x8000000) { - func_80832340(globalCtx, this); - if (this->ageProperties->unk_2C < this->actor.yDistToWater) { - this->stateFlags2 |= 0x400; - } - } - } else { - if (this->stateFlags1 & 0x8000000) { - if ((this->prevBoots == PLAYER_BOOTS_IRON) || (this->actor.bgCheckFlags & 1)) { - func_8083D36C(globalCtx, this); - this->stateFlags2 &= ~0x400; - } - } - } - - this->prevBoots = this->currentBoots; - } - - if ((this->actor.parent == NULL) && (this->stateFlags1 & 0x800000)) { - this->actor.parent = this->rideActor; - func_8083A360(globalCtx, this); - this->stateFlags1 |= 0x800000; - func_80832264(globalCtx, this, &gPlayerAnim_0033B8); - func_80832F54(globalCtx, this, 0x9B); - this->unk_850 = 99; - } - - if (this->unk_844 == 0) { - this->unk_845 = 0; - } else if (this->unk_844 < 0) { - this->unk_844++; - } else { - this->unk_844--; - } - - Math_ScaledStepToS(&this->unk_6C2, 0, 400); - func_80032CB4(this->unk_3A8, 20, 80, 6); - - this->actor.shape.face = this->unk_3A8[0] + ((globalCtx->gameplayFrames & 32) ? 0 : 3); - - if (this->currentMask == PLAYER_MASK_BUNNY) { - func_8085002C(this); - } - - if (func_8002DD6C(this) != 0) { - func_8084FF7C(this); - } - - if (!(this->skelAnime.moveFlags & 0x80)) { - if (((this->actor.bgCheckFlags & 1) && (D_808535E4 == 5) && (this->currentBoots != PLAYER_BOOTS_IRON)) || - ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->stateFlags1 & 0x28000000))) { - f32 sp70 = this->linearVelocity; - s16 sp6E = this->currentYaw; - s16 yawDiff = this->actor.world.rot.y - sp6E; - s32 pad; - - if ((ABS(yawDiff) > 0x6000) && (this->actor.speedXZ != 0.0f)) { - sp70 = 0.0f; - sp6E += 0x8000; - } - - if (Math_StepToF(&this->actor.speedXZ, sp70, 0.35f) && (sp70 == 0.0f)) { - this->actor.world.rot.y = this->currentYaw; - } - - if (this->linearVelocity != 0.0f) { - s32 phi_v0; - - phi_v0 = (fabsf(this->linearVelocity) * 700.0f) - (fabsf(this->actor.speedXZ) * 100.0f); - phi_v0 = CLAMP(phi_v0, 0, 1350); - - Math_ScaledStepToS(&this->actor.world.rot.y, sp6E, phi_v0); - } - - if ((this->linearVelocity == 0.0f) && (this->actor.speedXZ != 0.0f)) { - func_800F4138(&this->actor.projectedPos, 0xD0, this->actor.speedXZ); - } - } else { - this->actor.speedXZ = this->linearVelocity; - this->actor.world.rot.y = this->currentYaw; - } - - func_8002D868(&this->actor); - - if ((this->windSpeed != 0.0f) && !Player_InCsMode(globalCtx) && !(this->stateFlags1 & 0x206000) && - (func_80845668 != this->func_674) && (func_808507F4 != this->func_674)) { - this->actor.velocity.x += this->windSpeed * Math_SinS(this->windDirection); - this->actor.velocity.z += this->windSpeed * Math_CosS(this->windDirection); - } - - func_8002D7EC(&this->actor); - func_80847BA0(globalCtx, this); - } else { - D_808535E4 = 0; - this->unk_A7A = 0; - - if (!(this->stateFlags1 & 1) && (this->stateFlags1 & 0x800000)) { - EnHorse* rideActor = (EnHorse*)this->rideActor; - CollisionPoly* sp5C; - s32 sp58; - Vec3f sp4C; - - if (!(rideActor->actor.bgCheckFlags & 1)) { - func_808396F4(globalCtx, this, &D_80854814, &sp4C, &sp5C, &sp58); - } else { - sp5C = rideActor->actor.floorPoly; - sp58 = rideActor->actor.floorBgId; - } - - if ((sp5C != NULL) && func_80839034(globalCtx, this, sp5C, sp58)) { - if (DREG(25) != 0) { - DREG(25) = 0; - } else { - AREG(6) = 1; - } - } - } - - D_808535F4 = 0; - this->windSpeed = 0.0f; - } - - if ((D_808535F4 != 0) && (this->currentBoots != PLAYER_BOOTS_IRON)) { - f32 sp48; - - D_808535F4--; - - if (D_808535F8 == 0) { - sp48 = D_80854820[D_808535F4]; - - if (!(this->stateFlags1 & 0x8000000)) { - sp48 *= 0.25f; - } - } else { - sp48 = D_8085482C[D_808535F4]; - } - - Math_StepToF(&this->windSpeed, sp48, sp48 * 0.1f); - - Math_ScaledStepToS(&this->windDirection, D_808535FC, - ((this->stateFlags1 & 0x8000000) ? 400.0f : 800.0f) * sp48); - } else if (this->windSpeed != 0.0f) { - Math_StepToF(&this->windSpeed, 0.0f, (this->stateFlags1 & 0x8000000) ? 0.5f : 1.0f); - } - - if (!Player_InBlockingCsMode(globalCtx, this) && !(this->stateFlags2 & 0x40000)) { - func_8083D53C(globalCtx, this); - - if ((this->actor.category == ACTORCAT_PLAYER) && (gSaveContext.health == 0)) { - if (this->stateFlags1 & 0x206000) { - func_80832440(globalCtx, this); - func_80837B9C(this, globalCtx); - } else if ((this->actor.bgCheckFlags & 1) || (this->stateFlags1 & 0x8000000)) { - func_80836448(globalCtx, this, - func_808332B8(this) ? &gPlayerAnim_003310 - : (this->shockTimer != 0) ? &gPlayerAnim_002F08 - : &gPlayerAnim_002878); - } - } else { - if ((this->actor.parent == NULL) && - ((globalCtx->sceneLoadFlag == 0x14) || (this->unk_A87 != 0) || !func_808382DC(this, globalCtx))) { - func_8083AA10(this, globalCtx); - } else { - this->fallStartHeight = this->actor.world.pos.y; - } - func_80848EF8(this); - } - } - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (this->csMode != 6) && !(this->stateFlags1 & 0x800000) && - !(this->stateFlags2 & 0x80) && (this->actor.category == ACTORCAT_PLAYER)) { - CsCmdActorAction* linkActionCsCmd = globalCtx->csCtx.linkAction; - - if ((linkActionCsCmd != NULL) && (D_808547C4[linkActionCsCmd->action] != 0)) { - func_8002DF54(globalCtx, NULL, 6); - func_80832210(this); - } else if ((this->csMode == 0) && !(this->stateFlags2 & 0x400) && - (globalCtx->csCtx.state != CS_STATE_UNSKIPPABLE_INIT)) { - func_8002DF54(globalCtx, NULL, 0x31); - func_80832210(this); - } - } - - if (this->csMode != 0) { - if ((this->csMode != 7) || !(this->stateFlags1 & 0x4206000)) { - this->unk_6AD = 3; - } else if (func_80852E14 != this->func_674) { - func_80852944(globalCtx, this, NULL); - } - } else { - this->prevCsMode = 0; - } - - func_8083D6EC(globalCtx, this); - - if ((this->unk_664 == NULL) && (this->naviTextId == 0)) { - this->stateFlags2 &= ~0x200002; - } - - this->stateFlags1 &= ~0x401202; - this->stateFlags2 &= ~0x441536D; - this->stateFlags3 &= ~0x10; - - func_80847298(this); - func_8083315C(globalCtx, this); - - if (this->stateFlags1 & 0x8000000) { - D_808535E8 = 0.5f; - } else { - D_808535E8 = 1.0f; - } - - D_808535EC = 1.0f / D_808535E8; - D_80853614 = D_80853618 = 0; - D_80858AA4 = this->currentMask; - - if (!(this->stateFlags3 & 4)) { - this->func_674(this, globalCtx); - } - - Player_UpdateCamAndSeqModes(globalCtx, this); - - if (this->skelAnime.moveFlags & 8) { - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, - (this->skelAnime.moveFlags & 4) ? 1.0f : this->ageProperties->unk_08); - } - - func_808368EC(this, globalCtx); - - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_8)) { - this->targetActorDistance = 0.0f; - } else { - this->targetActor = NULL; - this->targetActorDistance = FLT_MAX; - this->exchangeItemId = EXCH_ITEM_NONE; - } - - if (!(this->stateFlags1 & 0x800)) { - this->interactRangeActor = NULL; - this->getItemDirection = 0x6000; - } - - if (this->actor.parent == NULL) { - this->rideActor = NULL; - } - - this->naviTextId = 0; - - if (!(this->stateFlags2 & 0x2000000)) { - this->unk_6A8 = NULL; - } - - this->stateFlags2 &= ~0x800000; - this->unk_6A4 = FLT_MAX; - - temp_f0 = this->actor.world.pos.y - this->actor.prevPos.y; - - this->doorType = PLAYER_DOORTYPE_NONE; - this->unk_8A1 = 0; - this->unk_684 = NULL; - - phi_f12 = ((this->bodyPartsPos[6].y + this->bodyPartsPos[3].y) * 0.5f) + temp_f0; - temp_f0 += this->bodyPartsPos[7].y + 10.0f; - - this->cylinder.dim.height = temp_f0 - phi_f12; - - if (this->cylinder.dim.height < 0) { - phi_f12 = temp_f0; - this->cylinder.dim.height = -this->cylinder.dim.height; - } - - this->cylinder.dim.yShift = phi_f12 - this->actor.world.pos.y; - - if (this->stateFlags1 & 0x400000) { - this->cylinder.dim.height = this->cylinder.dim.height * 0.8f; - } - - Collider_UpdateCylinder(&this->actor, &this->cylinder); - - if (!(this->stateFlags2 & 0x4000)) { - if (!(this->stateFlags1 & 0x806080)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cylinder.base); - } - - if (!(this->stateFlags1 & 0x4000080) && (this->invincibilityTimer <= 0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder.base); - - if (this->invincibilityTimer < 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->cylinder.base); - } - } - } - - AnimationContext_SetNextQueue(globalCtx); - } - - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - Math_Vec3f_Copy(&this->unk_A88, &this->bodyPartsPos[0]); - - if (this->stateFlags1 & 0x30000080) { - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - } else { - this->actor.colChkInfo.mass = 50; - } - - this->stateFlags3 &= ~4; - - Collider_ResetCylinderAC(globalCtx, &this->cylinder.base); - - Collider_ResetQuadAT(globalCtx, &this->swordQuads[0].base); - Collider_ResetQuadAT(globalCtx, &this->swordQuads[1].base); - - Collider_ResetQuadAC(globalCtx, &this->shieldQuad.base); - Collider_ResetQuadAT(globalCtx, &this->shieldQuad.base); -} - -static Vec3f D_80854838 = { 0.0f, 0.0f, -30.0f }; - -void Player_Update(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f sDogSpawnPos; - Player* this = (Player*)thisx; - s32 dogParams; - s32 pad; - Input sp44; - Actor* dog; - - if (func_8084FCAC(this, globalCtx)) { - if (gSaveContext.dogParams < 0) { - if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG) < 0) { - gSaveContext.dogParams = 0; - } else { - gSaveContext.dogParams &= 0x7FFF; - func_808395DC(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos); - dogParams = gSaveContext.dogParams; - - dog = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, - sDogSpawnPos.z, 0, this->actor.shape.rot.y, 0, dogParams | 0x8000); - if (dog != NULL) { - dog->room = 0; - } - } - } - - if ((this->interactRangeActor != NULL) && (this->interactRangeActor->update == NULL)) { - this->interactRangeActor = NULL; - } - - if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) { - func_808323B4(globalCtx, this); - } - - if (this->stateFlags1 & 0x20000020) { - bzero(&sp44, sizeof(sp44)); - } else { - sp44 = globalCtx->state.input[0]; - if (this->unk_88E != 0) { - sp44.cur.button &= ~(BTN_A | BTN_B | BTN_CUP); - sp44.press.button &= ~(BTN_A | BTN_B | BTN_CUP); - } - } - - Player_UpdateCommon(this, globalCtx, &sp44); - } - - MREG(52) = this->actor.world.pos.x; - MREG(53) = this->actor.world.pos.y; - MREG(54) = this->actor.world.pos.z; - MREG(55) = this->actor.world.rot.y; -} - -static struct_80858AC8 D_80858AC8; -static Vec3s D_80858AD8[25]; - -static Gfx* sMaskDlists[PLAYER_MASK_MAX - 1] = { - gLinkChildKeatonMaskDL, gLinkChildSkullMaskDL, gLinkChildSpookyMaskDL, gLinkChildBunnyHoodDL, - gLinkChildGoronMaskDL, gLinkChildZoraMaskDL, gLinkChildGerudoMaskDL, gLinkChildMaskOfTruthDL, -}; - -static Vec3s D_80854864 = { 0, 0, 0 }; - -void func_8084A0E8(GlobalContext* globalCtx, Player* this, s32 lod, Gfx* cullDList, - OverrideLimbDrawOpa overrideLimbDraw) { - static s32 D_8085486C = 255; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19228); - - gSPSegment(POLY_OPA_DISP++, 0x0C, cullDList); - gSPSegment(POLY_XLU_DISP++, 0x0C, cullDList); - - func_8008F470(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, lod, - this->currentTunic, this->currentBoots, this->actor.shape.face, overrideLimbDraw, func_80090D20, - this); - - if ((overrideLimbDraw == func_80090014) && (this->currentMask != PLAYER_MASK_NONE)) { - Mtx* sp70 = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Mtx)); - - if (this->currentMask == PLAYER_MASK_BUNNY) { - Vec3s sp68; - - gSPSegment(POLY_OPA_DISP++, 0x0B, sp70); - - sp68.x = D_80858AC8.unk_02 + 0x3E2; - sp68.y = D_80858AC8.unk_04 + 0xDBE; - sp68.z = D_80858AC8.unk_00 - 0x348A; - func_800D1694(97.0f, -1203.0f, -240.0f, &sp68); - Matrix_ToMtx(sp70++, "../z_player.c", 19273); - - sp68.x = D_80858AC8.unk_02 - 0x3E2; - sp68.y = -0xDBE - D_80858AC8.unk_04; - sp68.z = D_80858AC8.unk_00 - 0x348A; - func_800D1694(97.0f, -1203.0f, 240.0f, &sp68); - Matrix_ToMtx(sp70, "../z_player.c", 19279); - } - - gSPDisplayList(POLY_OPA_DISP++, sMaskDlists[this->currentMask - 1]); - } - - if ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->actor.bgCheckFlags & 1) && - !(this->stateFlags1 & 0x800000) && (this->hoverBootsTimer != 0)) { - s32 sp5C; - s32 hoverBootsTimer = this->hoverBootsTimer; - - if (this->hoverBootsTimer < 19) { - if (hoverBootsTimer >= 15) { - D_8085486C = (19 - hoverBootsTimer) * 51.0f; - } else if (hoverBootsTimer < 19) { - sp5C = hoverBootsTimer; - - if (sp5C > 9) { - sp5C = 9; - } - - D_8085486C = (-sp5C * 4) + 36; - D_8085486C = D_8085486C * D_8085486C; - D_8085486C = (s32)((Math_CosS(D_8085486C) * 100.0f) + 100.0f) + 55.0f; - D_8085486C = D_8085486C * (sp5C * (1.0f / 9.0f)); - } - - func_800D1694(this->actor.world.pos.x, this->actor.world.pos.y + 2.0f, this->actor.world.pos.z, - &D_80854864); - Matrix_Scale(4.0f, 4.0f, 4.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player.c", 19317), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 32, 1, 0, - (globalCtx->gameplayFrames * -15) % 128, 16, 32)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, D_8085486C); - gDPSetEnvColor(POLY_XLU_DISP++, 120, 90, 30, 128); - gSPDisplayList(POLY_XLU_DISP++, gHoverBootsCircleDL); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19328); -} - -void Player_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - Player* this = (Player*)thisx; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19346); - - if (!(this->stateFlags2 & 0x20000000)) { - OverrideLimbDrawOpa overrideLimbDraw = func_80090014; - s32 lod; - s32 pad; - - if ((this->csMode != 0) || (func_8008E9C4(this) && 0) || (this->actor.projectedPos.z < 160.0f)) { - lod = 0; - } else { - lod = 1; - } - - func_80093C80(globalCtx); - func_80093D84(globalCtx->state.gfxCtx); - - if (this->invincibilityTimer > 0) { - this->unk_88F += CLAMP(50 - this->invincibilityTimer, 8, 40); - POLY_OPA_DISP = - Gfx_SetFog2(POLY_OPA_DISP, 255, 0, 0, 0, 0, 4000 - (s32)(Math_CosS(this->unk_88F * 256) * 2000.0f)); - } - - func_8002EBCC(&this->actor, globalCtx, 0); - func_8002ED80(&this->actor, globalCtx, 0); - - if (this->unk_6AD != 0) { - Vec3f sp7C; - - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &this->actor.focus.pos, &sp7C); - if (sp7C.z < -4.0f) { - overrideLimbDraw = func_800902F0; - } - } else if (this->stateFlags2 & 0x40000) { - if (this->actor.projectedPos.z < 0.0f) { - overrideLimbDraw = func_80090440; - } - } - - if (this->stateFlags2 & 0x4000000) { - f32 sp78 = ((u16)(globalCtx->gameplayFrames * 600) * M_PI) / 0x8000; - f32 sp74 = ((u16)(globalCtx->gameplayFrames * 1000) * M_PI) / 0x8000; - - Matrix_Push(); - this->actor.scale.y = -this->actor.scale.y; - func_800D1694(this->actor.world.pos.x, - (this->actor.floorHeight + (this->actor.floorHeight - this->actor.world.pos.y)) + - (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateX(sp78, MTXMODE_APPLY); - Matrix_RotateY(sp74, MTXMODE_APPLY); - Matrix_Scale(1.1f, 0.95f, 1.05f, MTXMODE_APPLY); - Matrix_RotateY(-sp74, MTXMODE_APPLY); - Matrix_RotateX(-sp78, MTXMODE_APPLY); - func_8084A0E8(globalCtx, this, lod, gCullFrontDList, overrideLimbDraw); - this->actor.scale.y = -this->actor.scale.y; - Matrix_Pop(); - } - - gSPClearGeometryMode(POLY_OPA_DISP++, G_CULL_BOTH); - gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH); - - func_8084A0E8(globalCtx, this, lod, gCullBackDList, overrideLimbDraw); - - if (this->invincibilityTimer > 0) { - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - } - - if (this->stateFlags2 & 0x4000) { - f32 scale = (this->unk_84F >> 1) * 22.0f; - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (0 - globalCtx->gameplayFrames) % 128, 32, 32, 1, - 0, (globalCtx->gameplayFrames * -2) % 128, 32, 32)); - - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player.c", 19459), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, 255); - gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL); - } - - if (this->unk_862 > 0) { - Player_DrawGetItem(globalCtx, this); - } - } - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19473); -} - -void Player_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Player* this = (Player*)thisx; - - Effect_Delete(globalCtx, this->swordEffectIndex); - - Collider_DestroyCylinder(globalCtx, &this->cylinder); - Collider_DestroyQuad(globalCtx, &this->swordQuads[0]); - Collider_DestroyQuad(globalCtx, &this->swordQuads[1]); - Collider_DestroyQuad(globalCtx, &this->shieldQuad); - - func_800876C8(globalCtx); - - gSaveContext.linkAge = globalCtx->linkAgeOnLoad; -} - -s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { - s32 temp1; - s16 temp2; - s16 temp3; - - if (!func_8002DD78(this) && !func_808334B4(this) && (arg2 == 0)) { - temp2 = sControlInput->rel.stick_y * 240.0f; - Math_SmoothStepToS(&this->actor.focus.rot.x, temp2, 14, 4000, 30); - - temp2 = sControlInput->rel.stick_x * -16.0f; - temp2 = CLAMP(temp2, -3000, 3000); - this->actor.focus.rot.y += temp2; - } else { - temp1 = (this->stateFlags1 & 0x800000) ? 3500 : 14000; - temp3 = ((sControlInput->rel.stick_y >= 0) ? 1 : -1) * - (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * 1500.0f); - this->actor.focus.rot.x += temp3; - this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -temp1, temp1); - - temp1 = 19114; - temp2 = this->actor.focus.rot.y - this->actor.shape.rot.y; - temp3 = ((sControlInput->rel.stick_x >= 0) ? 1 : -1) * - (s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) * -1500.0f); - temp2 += temp3; - this->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + this->actor.shape.rot.y; - } - - this->unk_6AE |= 2; - return func_80836AB8(this, (globalCtx->shootingGalleryStatus != 0) || func_8002DD78(this) || func_808334B4(this)) - - arg3; -} - -void func_8084AEEC(Player* this, f32* arg1, f32 arg2, s16 arg3) { - f32 temp1; - f32 temp2; - - temp1 = this->skelAnime.curFrame - 10.0f; - - temp2 = (R_RUN_SPEED_LIMIT / 100.0f) * 0.8f; - if (*arg1 > temp2) { - *arg1 = temp2; - } - - if ((0.0f < temp1) && (temp1 < 10.0f)) { - temp1 *= 6.0f; - } else { - temp1 = 0.0f; - arg2 = 0.0f; - } - - Math_AsymStepToF(arg1, arg2 * 0.8f, temp1, (fabsf(*arg1) * 0.02f) + 0.05f); - Math_ScaledStepToS(&this->currentYaw, arg3, 1600); -} - -void func_8084B000(Player* this) { - f32 phi_f18; - f32 phi_f16; - f32 phi_f14; - f32 yDistToWater; - - phi_f14 = -5.0f; - - phi_f16 = this->ageProperties->unk_28; - if (this->actor.velocity.y < 0.0f) { - phi_f16 += 1.0f; - } - - if (this->actor.yDistToWater < phi_f16) { - if (this->actor.velocity.y <= 0.0f) { - phi_f16 = 0.0f; - } else { - phi_f16 = this->actor.velocity.y * 0.5f; - } - phi_f18 = -0.1f - phi_f16; - } else { - if (!(this->stateFlags1 & 0x80) && (this->currentBoots == PLAYER_BOOTS_IRON) && - (this->actor.velocity.y >= -3.0f)) { - phi_f18 = -0.2f; - } else { - phi_f14 = 2.0f; - if (this->actor.velocity.y >= 0.0f) { - phi_f16 = 0.0f; - } else { - phi_f16 = this->actor.velocity.y * -0.3f; - } - phi_f18 = phi_f16 + 0.1f; - } - - yDistToWater = this->actor.yDistToWater; - if (yDistToWater > 100.0f) { - this->stateFlags2 |= 0x400; - } - } - - this->actor.velocity.y += phi_f18; - - if (((this->actor.velocity.y - phi_f14) * phi_f18) > 0) { - this->actor.velocity.y = phi_f14; - } - - this->actor.gravity = 0.0f; -} - -void func_8084B158(GlobalContext* globalCtx, Player* this, Input* input, f32 arg3) { - f32 temp; - - if ((input != NULL) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_B)) { - temp = 1.0f; - } else { - temp = 0.5f; - } - - temp *= arg3; - - if (temp < 1.0f) { - temp = 1.0f; - } - - this->skelAnime.playSpeed = temp; - LinkAnimation_Update(globalCtx, &this->skelAnime); -} - -void func_8084B1D8(Player* this, GlobalContext* globalCtx) { - if (this->stateFlags1 & 0x8000000) { - func_8084B000(this); - func_8084AEEC(this, &this->linearVelocity, 0, this->actor.shape.rot.y); - } else { - func_8083721C(this); - } - - if ((this->unk_6AD == 2) && (func_8002DD6C(this) || func_808332E4(this))) { - func_80836670(this, globalCtx); - } - - if ((this->csMode != 0) || (this->unk_6AD == 0) || (this->unk_6AD >= 4) || func_80833B54(this) || - (this->unk_664 != NULL) || !func_8083AD4C(globalCtx, this) || - (((this->unk_6AD == 2) && (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_R) || - func_80833B2C(this) || (!func_8002DD78(this) && !func_808334B4(this)))) || - ((this->unk_6AD == 1) && - CHECK_BTN_ANY(sControlInput->press.button, - BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)))) { - func_8083C148(this, globalCtx); - func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); - } else if ((DECR(this->unk_850) == 0) || (this->unk_6AD != 2)) { - if (func_8008F128(this)) { - this->unk_6AE |= 0x43; - } else { - this->actor.shape.rot.y = func_8084ABD8(globalCtx, this, 0, 0); - } - } - - this->currentYaw = this->actor.shape.rot.y; -} - -s32 func_8084B3CC(GlobalContext* globalCtx, Player* this) { - if (globalCtx->shootingGalleryStatus != 0) { - func_80832564(globalCtx, this); - func_80835C58(globalCtx, this, func_8084FA54, 0); - - if (!func_8002DD6C(this) || Player_HoldsHookshot(this)) { - func_80835F44(globalCtx, this, 3); - } - - this->stateFlags1 |= 0x100000; - func_80832264(globalCtx, this, func_80833338(this)); - func_80832210(this); - func_8083B010(this); - return 1; - } - - return 0; -} - -void func_8084B498(Player* this) { - this->itemActionParam = - (INV_CONTENT(ITEM_OCARINA_FAIRY) == ITEM_OCARINA_FAIRY) ? PLAYER_AP_OCARINA_FAIRY : PLAYER_AP_OCARINA_TIME; -} - -s32 func_8084B4D4(GlobalContext* globalCtx, Player* this) { - if (this->stateFlags3 & 0x20) { - this->stateFlags3 &= ~0x20; - func_8084B498(this); - this->unk_6AD = 4; - func_8083B040(this, globalCtx); - return 1; - } - - return 0; -} - -void func_8084B530(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x20; - func_80836670(this, globalCtx); - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actor.flags &= ~ACTOR_FLAG_8; - - if (!CHECK_FLAG_ALL(this->targetActor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2)) { - this->stateFlags2 &= ~0x2000; - } - - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - - if (!func_8084B4D4(globalCtx, this) && !func_8084B3CC(globalCtx, this) && !func_8083ADD4(globalCtx, this)) { - if ((this->targetActor != this->interactRangeActor) || !func_8083E5A8(this, globalCtx)) { - if (this->stateFlags1 & 0x800000) { - s32 sp24 = this->unk_850; - func_8083A360(globalCtx, this); - this->unk_850 = sp24; - } else if (func_808332B8(this)) { - func_80838F18(globalCtx, this); - } else { - func_80853080(this, globalCtx); - } - } - } - - this->unk_88E = 10; - return; - } - - if (this->stateFlags1 & 0x800000) { - func_8084CC98(this, globalCtx); - } else if (func_808332B8(this)) { - func_8084D610(this, globalCtx); - } else if (!func_8008E9C4(this) && LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->skelAnime.moveFlags != 0) { - func_80832DBC(this); - if ((this->targetActor->category == ACTORCAT_NPC) && - (this->heldItemActionParam != PLAYER_AP_FISHING_POLE)) { - func_808322D0(globalCtx, this, &gPlayerAnim_0031A0); - } else { - func_80832284(globalCtx, this, func_80833338(this)); - } - } else { - func_808322A4(globalCtx, this, &gPlayerAnim_0031A8); - } - } - - if (this->unk_664 != NULL) { - this->currentYaw = this->actor.shape.rot.y = func_8083DB98(this, 0); - } -} - -void func_8084B78C(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - s32 temp; - - this->stateFlags2 |= 0x141; - func_8083F524(globalCtx, this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (!func_8083F9D0(globalCtx, this)) { - func_80837268(this, &sp34, &sp32, 0.0f, globalCtx); - temp = func_8083FFB8(this, &sp34, &sp32); - if (temp > 0) { - func_8083FAB8(this, globalCtx); - } else if (temp < 0) { - func_8083FB14(this, globalCtx); - } - } - } -} - -void func_8084B840(GlobalContext* globalCtx, Player* this, f32 arg2) { - if (this->actor.wallBgId != BGCHECK_SCENE) { - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.wallBgId); - - if (dynaPolyActor != NULL) { - func_8002DFA4(dynaPolyActor, arg2, this->actor.world.rot.y); - } - } -} - -static struct_80832924 D_80854870[] = { - { NA_SE_PL_SLIP, 0x1003 }, - { NA_SE_PL_SLIP, -0x1015 }, -}; - -void func_8084B898(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - s32 temp; - - this->stateFlags2 |= 0x141; - - if (func_80832CB0(globalCtx, this, &gPlayerAnim_003108)) { - this->unk_850 = 1; - } else if (this->unk_850 == 0) { - if (LinkAnimation_OnFrame(&this->skelAnime, 11.0f)) { - func_80832698(this, NA_SE_VO_LI_PUSH); - } - } - - func_80832924(this, D_80854870); - func_8083F524(globalCtx, this); - - if (!func_8083F9D0(globalCtx, this)) { - func_80837268(this, &sp34, &sp32, 0.0f, globalCtx); - temp = func_8083FFB8(this, &sp34, &sp32); - if (temp < 0) { - func_8083FB14(this, globalCtx); - } else if (temp == 0) { - func_8083F72C(this, &gPlayerAnim_0030E0, globalCtx); - } else { - this->stateFlags2 |= 0x10; - } - } - - if (this->stateFlags2 & 0x10) { - func_8084B840(globalCtx, this, 2.0f); - this->linearVelocity = 2.0f; - } -} - -static struct_80832924 D_80854878[] = { - { NA_SE_PL_SLIP, 0x1004 }, - { NA_SE_PL_SLIP, -0x1018 }, -}; - -static Vec3f D_80854880 = { 0.0f, 26.0f, -40.0f }; - -void func_8084B9E4(Player* this, GlobalContext* globalCtx) { - LinkAnimationHeader* anim; - f32 sp70; - s16 sp6E; - s32 temp1; - Vec3f sp5C; - f32 temp2; - CollisionPoly* sp54; - s32 sp50; - Vec3f sp44; - Vec3f sp38; - - anim = D_80853C74[this->modelAnimType]; - this->stateFlags2 |= 0x141; - - if (func_80832CB0(globalCtx, this, anim)) { - this->unk_850 = 1; - } else { - if (this->unk_850 == 0) { - if (LinkAnimation_OnFrame(&this->skelAnime, 11.0f)) { - func_80832698(this, NA_SE_VO_LI_PUSH); - } - } else { - func_80832924(this, D_80854878); - } - } - - func_8083F524(globalCtx, this); - - if (!func_8083F9D0(globalCtx, this)) { - func_80837268(this, &sp70, &sp6E, 0.0f, globalCtx); - temp1 = func_8083FFB8(this, &sp70, &sp6E); - if (temp1 > 0) { - func_8083FAB8(this, globalCtx); - } else if (temp1 == 0) { - func_8083F72C(this, D_80853C8C[this->modelAnimType], globalCtx); - } else { - this->stateFlags2 |= 0x10; - } - } - - if (this->stateFlags2 & 0x10) { - temp2 = func_8083973C(globalCtx, this, &D_80854880, &sp5C) - this->actor.world.pos.y; - if (fabsf(temp2) < 20.0f) { - sp44.x = this->actor.world.pos.x; - sp44.z = this->actor.world.pos.z; - sp44.y = sp5C.y; - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp44, &sp5C, &sp38, &sp54, true, false, false, true, - &sp50)) { - func_8084B840(globalCtx, this, -2.0f); - return; - } - } - this->stateFlags2 &= ~0x10; - } -} - -void func_8084BBE4(Player* this, GlobalContext* globalCtx) { - f32 sp3C; - s16 sp3A; - LinkAnimationHeader* anim; - f32 temp; - - this->stateFlags2 |= 0x40; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - // clang-format off - anim = (this->unk_84F > 0) ? &gPlayerAnim_002F28 : D_80853CD4[this->modelAnimType]; func_80832284(globalCtx, this, anim); - // clang-format on - } else if (this->unk_84F == 0) { - if (this->skelAnime.animation == &gPlayerAnim_002F10) { - temp = 11.0f; - } else { - temp = 1.0f; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, temp)) { - func_80832770(this, NA_SE_PL_WALK_GROUND); - if (this->skelAnime.animation == &gPlayerAnim_002F10) { - this->unk_84F = 1; - } else { - this->unk_84F = -1; - } - } - } - - Math_ScaledStepToS(&this->actor.shape.rot.y, this->currentYaw, 0x800); - - if (this->unk_84F != 0) { - func_80837268(this, &sp3C, &sp3A, 0.0f, globalCtx); - if (this->unk_847[this->unk_846] >= 0) { - if (this->unk_84F > 0) { - anim = D_80853CA4[this->modelAnimType]; - } else { - anim = D_80853CEC[this->modelAnimType]; - } - func_8083A9B8(this, anim, globalCtx); - return; - } - - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) || (this->actor.shape.feetFloorFlags != 0)) { - func_80837B60(this); - if (this->unk_84F < 0) { - this->linearVelocity = -0.8f; - } else { - this->linearVelocity = 0.8f; - } - func_80837B9C(this, globalCtx); - this->stateFlags1 &= ~0x6000; - } - } -} - -void func_8084BDFC(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x40; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832E48(this, 1); - func_8083C0E8(this, globalCtx); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, this->skelAnime.endFrame - 6.0f)) { - func_808328A0(this); - } else if (LinkAnimation_OnFrame(&this->skelAnime, this->skelAnime.endFrame - 34.0f)) { - this->stateFlags1 &= ~0x6000; - func_8002F7DC(&this->actor, NA_SE_PL_CLIMB_CLIFF); - func_80832698(this, NA_SE_VO_LI_CLIMB_END); - } -} - -void func_8084BEE4(Player* this) { - func_8002F7DC(&this->actor, (this->unk_84F != 0) ? NA_SE_PL_WALK_WALL : NA_SE_PL_WALK_LADDER); -} - -void func_8084BF1C(Player* this, GlobalContext* globalCtx) { - static Vec3f D_8085488C = { 0.0f, 0.0f, 26.0f }; - s32 sp84; - s32 sp80; - f32 phi_f0; - f32 phi_f2; - Vec3f sp6C; - s32 sp68; - Vec3f sp5C; - f32 temp_f0; - LinkAnimationHeader* anim1; - LinkAnimationHeader* anim2; - - sp84 = sControlInput->rel.stick_y; - sp80 = sControlInput->rel.stick_x; - - this->fallStartHeight = this->actor.world.pos.y; - this->stateFlags2 |= 0x40; - - if ((this->unk_84F != 0) && (ABS(sp84) < ABS(sp80))) { - phi_f0 = ABS(sp80) * 0.0325f; - sp84 = 0; - } else { - phi_f0 = ABS(sp84) * 0.05f; - sp80 = 0; - } - - if (phi_f0 < 1.0f) { - phi_f0 = 1.0f; - } else if (phi_f0 > 3.35f) { - phi_f0 = 3.35f; - } - - if (this->skelAnime.playSpeed >= 0.0f) { - phi_f2 = 1.0f; - } else { - phi_f2 = -1.0f; - } - - this->skelAnime.playSpeed = phi_f2 * phi_f0; - - if (this->unk_850 >= 0) { - if ((this->actor.wallPoly != NULL) && (this->actor.wallBgId != BGCHECK_SCENE)) { - DynaPolyActor* wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.wallBgId); - if (wallPolyActor != NULL) { - Math_Vec3f_Diff(&wallPolyActor->actor.world.pos, &wallPolyActor->actor.prevPos, &sp6C); - Math_Vec3f_Sum(&this->actor.world.pos, &sp6C, &this->actor.world.pos); - } - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 6.0f, this->ageProperties->unk_00, 7); - func_8083F360(globalCtx, this, 26.0f, this->ageProperties->unk_3C, 50.0f, -20.0f); - } - - if ((this->unk_850 < 0) || !func_8083FBC0(this, globalCtx)) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime) != 0) { - if (this->unk_850 < 0) { - this->unk_850 = ABS(this->unk_850) & 1; - return; - } - - if (sp84 != 0) { - sp68 = this->unk_84F + this->unk_850; - - if (sp84 > 0) { - D_8085488C.y = this->ageProperties->unk_40; - temp_f0 = func_8083973C(globalCtx, this, &D_8085488C, &sp5C); - - if (this->actor.world.pos.y < temp_f0) { - if (this->unk_84F != 0) { - this->actor.world.pos.y = temp_f0; - this->stateFlags1 &= ~0x200000; - func_8083A5C4(globalCtx, this, this->actor.wallPoly, this->ageProperties->unk_3C, - &gPlayerAnim_003000); - this->currentYaw += 0x8000; - this->actor.shape.rot.y = this->currentYaw; - func_8083A9B8(this, &gPlayerAnim_003000, globalCtx); - this->stateFlags1 |= 0x4000; - } else { - func_8083F070(this, this->ageProperties->unk_CC[this->unk_850], globalCtx); - } - } else { - this->skelAnime.prevTransl = this->ageProperties->unk_4A[sp68]; - func_80832264(globalCtx, this, this->ageProperties->unk_AC[sp68]); - } - } else { - if ((this->actor.world.pos.y - this->actor.floorHeight) < 15.0f) { - if (this->unk_84F != 0) { - func_8083FB7C(this, globalCtx); - } else { - if (this->unk_850 != 0) { - this->skelAnime.prevTransl = this->ageProperties->unk_44; - } - func_8083F070(this, this->ageProperties->unk_C4[this->unk_850], globalCtx); - this->unk_850 = 1; - } - } else { - sp68 ^= 1; - this->skelAnime.prevTransl = this->ageProperties->unk_62[sp68]; - anim1 = this->ageProperties->unk_AC[sp68]; - LinkAnimation_Change(globalCtx, &this->skelAnime, anim1, -1.0f, Animation_GetLastFrame(anim1), - 0.0f, ANIMMODE_ONCE, 0.0f); - } - } - this->unk_850 ^= 1; - } else { - if ((this->unk_84F != 0) && (sp80 != 0)) { - anim2 = this->ageProperties->unk_BC[this->unk_850]; - - if (sp80 > 0) { - this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->unk_850]; - func_80832264(globalCtx, this, anim2); - } else { - this->skelAnime.prevTransl = this->ageProperties->unk_86[this->unk_850]; - LinkAnimation_Change(globalCtx, &this->skelAnime, anim2, -1.0f, Animation_GetLastFrame(anim2), - 0.0f, ANIMMODE_ONCE, 0.0f); - } - } else { - this->stateFlags2 |= 0x1000; - } - } - - return; - } - } - - if (this->unk_850 < 0) { - if (((this->unk_850 == -2) && - (LinkAnimation_OnFrame(&this->skelAnime, 14.0f) || LinkAnimation_OnFrame(&this->skelAnime, 29.0f))) || - ((this->unk_850 == -4) && - (LinkAnimation_OnFrame(&this->skelAnime, 22.0f) || LinkAnimation_OnFrame(&this->skelAnime, 35.0f) || - LinkAnimation_OnFrame(&this->skelAnime, 49.0f) || LinkAnimation_OnFrame(&this->skelAnime, 55.0f)))) { - func_8084BEE4(this); - } - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, (this->skelAnime.playSpeed > 0.0f) ? 20.0f : 0.0f)) { - func_8084BEE4(this); - } -} - -static f32 D_80854898[] = { 10.0f, 20.0f }; -static f32 D_808548A0[] = { 40.0f, 50.0f }; - -static struct_80832924 D_808548A8[] = { - { NA_SE_PL_WALK_LADDER, 0x80A }, - { NA_SE_PL_WALK_LADDER, 0x814 }, - { NA_SE_PL_WALK_LADDER, -0x81E }, -}; - -void func_8084C5F8(Player* this, GlobalContext* globalCtx) { - s32 temp; - f32* sp38; - CollisionPoly* sp34; - s32 sp30; - Vec3f sp24; - - this->stateFlags2 |= 0x40; - - temp = func_808374A0(globalCtx, this, &this->skelAnime, 4.0f); - - if (temp == 0) { - this->stateFlags1 &= ~0x200000; - return; - } - - if ((temp > 0) || LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083C0E8(this, globalCtx); - this->stateFlags1 &= ~0x200000; - return; - } - - sp38 = D_80854898; - - if (this->unk_850 != 0) { - func_80832924(this, D_808548A8); - sp38 = D_808548A0; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, sp38[0]) || LinkAnimation_OnFrame(&this->skelAnime, sp38[1])) { - sp24.x = this->actor.world.pos.x; - sp24.y = this->actor.world.pos.y + 20.0f; - sp24.z = this->actor.world.pos.z; - if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp34, &sp30, &sp24) != 0.0f) { - this->unk_89E = func_80041F10(&globalCtx->colCtx, sp34, sp30); - func_808328A0(this); - } - } -} - -static struct_80832924 D_808548B4[] = { - { 0, 0x3028 }, { 0, 0x3030 }, { 0, 0x3038 }, { 0, 0x3040 }, { 0, 0x3048 }, - { 0, 0x3050 }, { 0, 0x3058 }, { 0, 0x3060 }, { 0, -0x3068 }, -}; - -void func_8084C760(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x40; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (!(this->stateFlags1 & 1)) { - if (this->skelAnime.moveFlags != 0) { - this->skelAnime.moveFlags = 0; - return; - } - - if (!func_8083F570(this, globalCtx)) { - this->linearVelocity = sControlInput->rel.stick_y * 0.03f; - } - } - return; - } - - func_80832924(this, D_808548B4); -} - -static struct_80832924 D_808548D8[] = { - { 0, 0x300A }, { 0, 0x3012 }, { 0, 0x301A }, { 0, 0x3022 }, { 0, 0x3034 }, - { 0, 0x303C }, { 0, 0x3044 }, { 0, 0x304C }, { 0, -0x3054 }, -}; - -void func_8084C81C(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x40; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083C0E8(this, globalCtx); - this->stateFlags2 &= ~0x40000; - return; - } - - func_80832924(this, D_808548D8); -} - -static Vec3f D_808548FC[] = { - { 40.0f, 0.0f, 0.0f }, - { -40.0f, 0.0f, 0.0f }, -}; - -static Vec3f D_80854914[] = { - { 60.0f, 20.0f, 0.0f }, - { -60.0f, 20.0f, 0.0f }, -}; - -static Vec3f D_8085492C[] = { - { 60.0f, -20.0f, 0.0f }, - { -60.0f, -20.0f, 0.0f }, -}; - -s32 func_8084C89C(GlobalContext* globalCtx, Player* this, s32 arg2, f32* arg3) { - EnHorse* rideActor = (EnHorse*)this->rideActor; - f32 sp50; - f32 sp4C; - Vec3f sp40; - Vec3f sp34; - CollisionPoly* sp30; - s32 sp2C; - - sp50 = rideActor->actor.world.pos.y + 20.0f; - sp4C = rideActor->actor.world.pos.y - 20.0f; - - *arg3 = func_8083973C(globalCtx, this, &D_808548FC[arg2], &sp40); - - return (sp4C < *arg3) && (*arg3 < sp50) && - !func_80839768(globalCtx, this, &D_80854914[arg2], &sp30, &sp2C, &sp34) && - !func_80839768(globalCtx, this, &D_8085492C[arg2], &sp30, &sp2C, &sp34); -} - -s32 func_8084C9BC(Player* this, GlobalContext* globalCtx) { - EnHorse* rideActor = (EnHorse*)this->rideActor; - s32 sp38; - f32 sp34; - - if (this->unk_850 < 0) { - this->unk_850 = 99; - } else { - sp38 = (this->mountSide < 0) ? 0 : 1; - if (!func_8084C89C(globalCtx, this, sp38, &sp34)) { - sp38 ^= 1; - if (!func_8084C89C(globalCtx, this, sp38, &sp34)) { - return 0; - } else { - this->mountSide = -this->mountSide; - } - } - - if ((globalCtx->csCtx.state == CS_STATE_IDLE) && (globalCtx->transitionMode == 0) && - (EN_HORSE_CHECK_1(rideActor) || EN_HORSE_CHECK_4(rideActor))) { - this->stateFlags2 |= 0x400000; - - if (EN_HORSE_CHECK_1(rideActor) || - (EN_HORSE_CHECK_4(rideActor) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A))) { - rideActor->actor.child = NULL; - func_80835DAC(globalCtx, this, func_8084D3E4, 0); - this->unk_878 = sp34 - rideActor->actor.world.pos.y; - func_80832264(globalCtx, this, (this->mountSide < 0) ? &gPlayerAnim_003390 : &gPlayerAnim_0033A0); - return 1; - } - } - } - - return 0; -} - -void func_8084CBF4(Player* this, f32 arg1, f32 arg2) { - f32 temp; - f32 dir; - - if ((this->unk_878 != 0.0f) && (arg2 <= this->skelAnime.curFrame)) { - if (arg1 < fabsf(this->unk_878)) { - if (this->unk_878 >= 0.0f) { - dir = 1; - } else { - dir = -1; - } - temp = dir * arg1; - } else { - temp = this->unk_878; - } - this->actor.world.pos.y += temp; - this->unk_878 -= temp; - } -} - -static LinkAnimationHeader* D_80854944[] = { - &gPlayerAnim_003370, - &gPlayerAnim_003368, - &gPlayerAnim_003380, - &gPlayerAnim_003358, - &gPlayerAnim_003338, - &gPlayerAnim_003348, - &gPlayerAnim_003350, - NULL, - NULL, -}; - -static LinkAnimationHeader* D_80854968[] = { - &gPlayerAnim_003388, - &gPlayerAnim_003388, - &gPlayerAnim_003388, - &gPlayerAnim_003360, - &gPlayerAnim_003340, - &gPlayerAnim_003340, - &gPlayerAnim_003340, - NULL, - NULL, -}; - -static LinkAnimationHeader* D_8085498C[] = { - &gPlayerAnim_0033C8, - &gPlayerAnim_0033B8, - &gPlayerAnim_0033C0, -}; - -static u8 D_80854998[2][2] = { - { 32, 58 }, - { 25, 42 }, -}; - -static Vec3s D_8085499C = { -69, 7146, -266 }; - -static struct_80832924 D_808549A4[] = { - { NA_SE_PL_CALM_HIT, 0x830 }, { NA_SE_PL_CALM_HIT, 0x83A }, { NA_SE_PL_CALM_HIT, 0x844 }, - { NA_SE_PL_CALM_PAT, 0x85C }, { NA_SE_PL_CALM_PAT, 0x86E }, { NA_SE_PL_CALM_PAT, 0x87E }, - { NA_SE_PL_CALM_PAT, 0x884 }, { NA_SE_PL_CALM_PAT, -0x888 }, -}; - -void func_8084CC98(Player* this, GlobalContext* globalCtx) { - EnHorse* rideActor = (EnHorse*)this->rideActor; - u8* arr; - - this->stateFlags2 |= 0x40; - - func_8084CBF4(this, 1.0f, 10.0f); - - if (this->unk_850 == 0) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - this->skelAnime.animation = &gPlayerAnim_0033B8; - this->unk_850 = 99; - return; - } - - arr = D_80854998[(this->mountSide < 0) ? 0 : 1]; - - if (LinkAnimation_OnFrame(&this->skelAnime, arr[0])) { - func_8002F7DC(&this->actor, NA_SE_PL_CLIMB_CLIFF); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, arr[1])) { - func_8002DE74(globalCtx, this); - func_8002F7DC(&this->actor, NA_SE_PL_SIT_ON_HORSE); - return; - } - - return; - } - - func_8002DE74(globalCtx, this); - this->skelAnime.prevTransl = D_8085499C; - - if ((rideActor->animationIdx != this->unk_850) && ((rideActor->animationIdx >= 2) || (this->unk_850 >= 2))) { - if ((this->unk_850 = rideActor->animationIdx) < 2) { - f32 rand = Rand_ZeroOne(); - s32 temp = 0; - - this->unk_850 = 1; - - if (rand < 0.1f) { - temp = 2; - } else if (rand < 0.2f) { - temp = 1; - } - func_80832264(globalCtx, this, D_8085498C[temp]); - } else { - this->skelAnime.animation = D_80854944[this->unk_850 - 2]; - Animation_SetMorph(globalCtx, &this->skelAnime, 8.0f); - if (this->unk_850 < 4) { - func_80834644(globalCtx, this); - this->unk_84F = 0; - } - } - } - - if (this->unk_850 == 1) { - if ((D_808535E0 != 0) || func_8083224C(globalCtx)) { - func_80832264(globalCtx, this, &gPlayerAnim_0033C8); - } else if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - this->unk_850 = 99; - } else if (this->skelAnime.animation == &gPlayerAnim_0033B8) { - func_80832924(this, D_808549A4); - } - } else { - this->skelAnime.curFrame = rideActor->curFrame; - LinkAnimation_AnimateFrame(globalCtx, &this->skelAnime); - } - - AnimationContext_SetCopyAll(globalCtx, this->skelAnime.limbCount, this->skelAnime.morphTable, - this->skelAnime.jointTable); - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) || (this->csMode != 0)) { - if (this->csMode == 7) { - this->csMode = 0; - } - this->unk_6AD = 0; - this->unk_84F = 0; - } else if ((this->unk_850 < 2) || (this->unk_850 >= 4)) { - D_808535E0 = func_80836670(this, globalCtx); - if (D_808535E0 != 0) { - this->unk_84F = 0; - } - } - - this->actor.world.pos.x = rideActor->actor.world.pos.x + rideActor->riderPos.x; - this->actor.world.pos.y = (rideActor->actor.world.pos.y + rideActor->riderPos.y) - 27.0f; - this->actor.world.pos.z = rideActor->actor.world.pos.z + rideActor->riderPos.z; - - this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; - - if ((this->csMode != 0) || - (!func_8083224C(globalCtx) && ((rideActor->actor.speedXZ != 0.0f) || !func_8083B644(this, globalCtx)) && - !func_8083C1DC(this, globalCtx))) { - if (D_808535E0 == 0) { - if (this->unk_84F != 0) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) { - rideActor->stateFlags &= ~ENHORSE_FLAG_8; - this->unk_84F = 0; - } - - if (this->skelAnime2.animation == &gPlayerAnim_0033B0) { - if (LinkAnimation_OnFrame(&this->skelAnime2, 23.0f)) { - func_8002F7DC(&this->actor, NA_SE_IT_LASH); - func_80832698(this, NA_SE_VO_LI_LASH); - } - - AnimationContext_SetCopyAll(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable); - } else { - if (LinkAnimation_OnFrame(&this->skelAnime2, 10.0f)) { - func_8002F7DC(&this->actor, NA_SE_IT_LASH); - func_80832698(this, NA_SE_VO_LI_LASH); - } - - AnimationContext_SetCopyTrue(globalCtx, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime2.jointTable, D_80853410); - } - } else { - LinkAnimationHeader* anim = NULL; - - if (EN_HORSE_CHECK_3(rideActor)) { - anim = &gPlayerAnim_0033B0; - } else if (EN_HORSE_CHECK_2(rideActor)) { - if ((this->unk_850 >= 2) && (this->unk_850 != 99)) { - anim = D_80854968[this->unk_850 - 2]; - } - } - - if (anim != NULL) { - LinkAnimation_PlayOnce(globalCtx, &this->skelAnime2, anim); - this->unk_84F = 1; - } - } - } - - if (this->stateFlags1 & 0x100000) { - if (!func_8083AD4C(globalCtx, this) || CHECK_BTN_ANY(sControlInput->press.button, BTN_A) || - func_80833BCC(this)) { - this->unk_6AD = 0; - this->stateFlags1 &= ~0x100000; - } else { - this->unk_6BE = func_8084ABD8(globalCtx, this, 1, -5000) - this->actor.shape.rot.y; - this->unk_6BE += 5000; - this->unk_6B0 = -5000; - } - return; - } - - if ((this->csMode != 0) || (!func_8084C9BC(this, globalCtx) && !func_8083B040(this, globalCtx))) { - if (this->unk_664 != NULL) { - if (func_8002DD78(this) != 0) { - this->unk_6BE = func_8083DB98(this, 1) - this->actor.shape.rot.y; - this->unk_6BE = CLAMP(this->unk_6BE, -0x4AAA, 0x4AAA); - this->actor.focus.rot.y = this->actor.shape.rot.y + this->unk_6BE; - this->unk_6BE += 5000; - this->unk_6AE |= 0x80; - } else { - func_8083DB98(this, 0); - } - } else { - if (func_8002DD78(this) != 0) { - this->unk_6BE = func_8084ABD8(globalCtx, this, 1, -5000) - this->actor.shape.rot.y; - this->unk_6BE += 5000; - this->unk_6B0 = -5000; - } - } - } - } -} - -static struct_80832924 D_808549C4[] = { - { 0, 0x2800 }, - { NA_SE_PL_GET_OFF_HORSE, 0x80A }, - { NA_SE_PL_SLIPDOWN, -0x819 }, -}; - -void func_8084D3E4(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x40; - func_8084CBF4(this, 1.0f, 10.0f); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - EnHorse* rideActor = (EnHorse*)this->rideActor; - - func_8083C0E8(this, globalCtx); - this->stateFlags1 &= ~0x800000; - this->actor.parent = NULL; - AREG(6) = 0; - - if (Flags_GetEventChkInf(0x18) || (DREG(1) != 0)) { - gSaveContext.horseData.pos.x = rideActor->actor.world.pos.x; - gSaveContext.horseData.pos.y = rideActor->actor.world.pos.y; - gSaveContext.horseData.pos.z = rideActor->actor.world.pos.z; - gSaveContext.horseData.angle = rideActor->actor.shape.rot.y; - } - } else { - Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_NORMAL0); - - if (this->mountSide < 0) { - D_808549C4[0].field = 0x2828; - } else { - D_808549C4[0].field = 0x281D; - } - func_80832924(this, D_808549C4); - } -} - -static struct_80832924 D_808549D0[] = { - { NA_SE_PL_SWIM, -0x800 }, -}; - -void func_8084D530(Player* this, f32* arg1, f32 arg2, s16 arg3) { - func_8084AEEC(this, arg1, arg2, arg3); - func_80832924(this, D_808549D0); -} - -void func_8084D574(GlobalContext* globalCtx, Player* this, s16 arg2) { - func_80835C58(globalCtx, this, func_8084D84C, 0); - this->actor.shape.rot.y = this->currentYaw = arg2; - func_80832C6C(globalCtx, this, &gPlayerAnim_0032F0); -} - -void func_8084D5CC(GlobalContext* globalCtx, Player* this) { - func_80835C58(globalCtx, this, func_8084DAB4, 0); - func_80832C6C(globalCtx, this, &gPlayerAnim_0032F0); -} - -void func_8084D610(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - - func_80832CB0(globalCtx, this, &gPlayerAnim_003328); - func_8084B000(this); - - if (!func_8083224C(globalCtx) && !func_80837348(globalCtx, this, D_80854444, 1) && - !func_8083D12C(globalCtx, this, sControlInput)) { - if (this->unk_6AD != 1) { - this->unk_6AD = 0; - } - - if (this->currentBoots == PLAYER_BOOTS_IRON) { - sp34 = 0.0f; - sp32 = this->actor.shape.rot.y; - - if (this->actor.bgCheckFlags & 1) { - func_8083A098(this, D_80853A7C[this->modelAnimType], globalCtx); - func_808328A0(this); - } - } else { - func_80837268(this, &sp34, &sp32, 0.0f, globalCtx); - - if (sp34 != 0.0f) { - s16 temp = this->actor.shape.rot.y - sp32; - - if ((ABS(temp) > 0x6000) && !Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - return; - } - - if (func_80833C04(this)) { - func_8084D5CC(globalCtx, this); - } else { - func_8084D574(globalCtx, this, sp32); - } - } - } - - func_8084AEEC(this, &this->linearVelocity, sp34, sp32); - } -} - -void func_8084D7C4(Player* this, GlobalContext* globalCtx) { - if (!func_8083B040(this, globalCtx)) { - this->stateFlags2 |= 0x20; - - func_8084B158(globalCtx, this, NULL, this->linearVelocity); - func_8084B000(this); - - if (DECR(this->unk_850) == 0) { - func_80838F18(globalCtx, this); - } - } -} - -void func_8084D84C(Player* this, GlobalContext* globalCtx) { - f32 sp34; - s16 sp32; - s16 temp; - - this->stateFlags2 |= 0x20; - - func_8084B158(globalCtx, this, sControlInput, this->linearVelocity); - func_8084B000(this); - - if (!func_80837348(globalCtx, this, D_80854444, 1) && !func_8083D12C(globalCtx, this, sControlInput)) { - func_80837268(this, &sp34, &sp32, 0.0f, globalCtx); - - temp = this->actor.shape.rot.y - sp32; - if ((sp34 == 0.0f) || (ABS(temp) > 0x6000) || (this->currentBoots == PLAYER_BOOTS_IRON)) { - func_80838F18(globalCtx, this); - } else if (func_80833C04(this)) { - func_8084D5CC(globalCtx, this); - } - - func_8084D530(this, &this->linearVelocity, sp34, sp32); - } -} - -s32 func_8084D980(GlobalContext* globalCtx, Player* this, f32* arg2, s16* arg3) { - LinkAnimationHeader* anim; - s16 temp1; - s32 temp2; - - temp1 = this->currentYaw - *arg3; - - if (ABS(temp1) > 0x6000) { - anim = &gPlayerAnim_003328; - - if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = *arg3; - } else { - *arg2 = 0.0f; - *arg3 = this->currentYaw; - } - } else { - temp2 = func_8083FD78(this, arg2, arg3, globalCtx); - - if (temp2 > 0) { - anim = &gPlayerAnim_0032F0; - } else if (temp2 < 0) { - anim = &gPlayerAnim_0032D8; - } else if ((temp1 = this->actor.shape.rot.y - *arg3) > 0) { - anim = &gPlayerAnim_0032D0; - } else { - anim = &gPlayerAnim_0032C8; - } - } - - if (anim != this->skelAnime.animation) { - func_80832C6C(globalCtx, this, anim); - return 1; - } - - return 0; -} - -void func_8084DAB4(Player* this, GlobalContext* globalCtx) { - f32 sp2C; - s16 sp2A; - - func_8084B158(globalCtx, this, sControlInput, this->linearVelocity); - func_8084B000(this); - - if (!func_80837348(globalCtx, this, D_80854444, 1) && !func_8083D12C(globalCtx, this, sControlInput)) { - func_80837268(this, &sp2C, &sp2A, 0.0f, globalCtx); - - if (sp2C == 0.0f) { - func_80838F18(globalCtx, this); - } else if (!func_80833C04(this)) { - func_8084D574(globalCtx, this, sp2A); - } else { - func_8084D980(globalCtx, this, &sp2C, &sp2A); - } - - func_8084D530(this, &this->linearVelocity, sp2C, sp2A); - } -} - -void func_8084DBC4(GlobalContext* globalCtx, Player* this, f32 arg2) { - f32 sp2C; - s16 sp2A; - - func_80837268(this, &sp2C, &sp2A, 0.0f, globalCtx); - func_8084AEEC(this, &this->linearVelocity, sp2C * 0.5f, sp2A); - func_8084AEEC(this, &this->actor.velocity.y, arg2, this->currentYaw); -} - -void func_8084DC48(Player* this, GlobalContext* globalCtx) { - f32 sp2C; - - this->stateFlags2 |= 0x20; - this->actor.gravity = 0.0f; - func_80836670(this, globalCtx); - - if (!func_8083B040(this, globalCtx)) { - if (this->currentBoots == PLAYER_BOOTS_IRON) { - func_80838F18(globalCtx, this); - return; - } - - if (this->unk_84F == 0) { - if (this->unk_850 == 0) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime) || - ((this->skelAnime.curFrame >= 22.0f) && !CHECK_BTN_ALL(sControlInput->cur.button, BTN_A))) { - func_8083D330(globalCtx, this); - } else if (LinkAnimation_OnFrame(&this->skelAnime, 20.0f) != 0) { - this->actor.velocity.y = -2.0f; - } - - func_8083721C(this); - return; - } - - func_8084B158(globalCtx, this, sControlInput, this->actor.velocity.y); - this->unk_6C2 = 16000; - - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) && !func_8083E5A8(this, globalCtx) && - !(this->actor.bgCheckFlags & 1) && (this->actor.yDistToWater < D_80854784[CUR_UPG_VALUE(UPG_SCALE)])) { - func_8084DBC4(globalCtx, this, -2.0f); - } else { - this->unk_84F++; - func_80832C6C(globalCtx, this, &gPlayerAnim_003328); - } - } else if (this->unk_84F == 1) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_8084B000(this); - - if (this->unk_6C2 < 10000) { - this->unk_84F++; - this->unk_850 = this->actor.yDistToWater; - func_80832C6C(globalCtx, this, &gPlayerAnim_0032F0); - } - } else if (!func_8083D12C(globalCtx, this, sControlInput)) { - sp2C = (this->unk_850 * 0.018f) + 4.0f; - - if (this->stateFlags1 & 0x800) { - sControlInput = NULL; - } - - func_8084B158(globalCtx, this, sControlInput, fabsf(this->actor.velocity.y)); - Math_ScaledStepToS(&this->unk_6C2, -10000, 800); - - if (sp2C > 8.0f) { - sp2C = 8.0f; - } - - func_8084DBC4(globalCtx, this, sp2C); - } - } -} - -void func_8084DF6C(GlobalContext* globalCtx, Player* this) { - this->unk_862 = 0; - this->stateFlags1 &= ~0xC00; - this->getItemId = GI_NONE; - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); -} - -void func_8084DFAC(GlobalContext* globalCtx, Player* this) { - func_8084DF6C(globalCtx, this); - func_808322FC(this); - func_8083C0E8(this, globalCtx); - this->currentYaw = this->actor.shape.rot.y; -} - -s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { - GetItemEntry* giEntry; - s32 temp1; - s32 temp2; - - if (this->getItemId == GI_NONE) { - return 1; - } - - if (this->unk_84F == 0) { - giEntry = &sGetItemTable[this->getItemId - 1]; - this->unk_84F = 1; - - Message_StartTextbox(globalCtx, giEntry->textId, &this->actor); - Item_Give(globalCtx, giEntry->itemId); - - if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_RED)) || - ((this->getItemId >= GI_RUPEE_PURPLE) && (this->getItemId <= GI_RUPEE_GOLD)) || - ((this->getItemId >= GI_RUPEE_GREEN_LOSE) && (this->getItemId <= GI_RUPEE_PURPLE_LOSE)) || - (this->getItemId == GI_HEART)) { - Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - if ((this->getItemId == GI_HEART_CONTAINER_2) || (this->getItemId == GI_HEART_CONTAINER) || - ((this->getItemId == GI_HEART_PIECE) && - ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { - temp1 = NA_BGM_HEART_GET | 0x900; - } else { - temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; - } - Audio_PlayFanfare(temp1); - } - } else { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - if (this->getItemId == GI_GAUNTLETS_SILVER) { - globalCtx->nextEntranceIndex = 0x0123; - globalCtx->sceneLoadFlag = 0x14; - gSaveContext.nextCutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 0xF; - this->stateFlags1 &= ~0x20000000; - func_80852FFC(globalCtx, NULL, 8); - } - this->getItemId = GI_NONE; - } - } - - return 0; -} - -void func_8084E1EC(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x20; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (!(this->stateFlags1 & 0x400) || func_8084DFF4(globalCtx, this)) { - func_8084DF6C(globalCtx, this); - func_80838F18(globalCtx, this); - func_80832340(globalCtx, this); - } - } else { - if ((this->stateFlags1 & 0x400) && LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { - func_808332F4(this, globalCtx); - func_80832340(globalCtx, this); - func_80835EA4(globalCtx, 8); - } else if (LinkAnimation_OnFrame(&this->skelAnime, 5.0f)) { - func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); - } - } - - func_8084B000(this); - func_8084AEEC(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); -} - -void func_8084E30C(Player* this, GlobalContext* globalCtx) { - func_8084B000(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80838F18(globalCtx, this); - } - - func_8084AEEC(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); -} - -void func_8084E368(Player* this, GlobalContext* globalCtx) { - func_8084B000(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80843AE8(globalCtx, this); - } - - func_8084AEEC(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); -} - -static s16 D_808549D4[] = { 0x0600, 0x04F6, 0x0604, 0x01F1, 0x0568, 0x05F4 }; - -void func_8084E3C4(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_808322A4(globalCtx, this, &gPlayerAnim_0030A8); - this->unk_850 = 1; - if (this->stateFlags2 & 0x2800000) { - this->stateFlags2 |= 0x1000000; - } else { - func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); - } - return; - } - - if (this->unk_850 == 0) { - return; - } - - if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - - if ((this->targetActor != NULL) && (this->targetActor == this->unk_6A8)) { - func_80853148(globalCtx, this->targetActor); - } else if (this->naviTextId < 0) { - this->targetActor = this->naviActor; - this->naviActor->textId = -this->naviTextId; - func_80853148(globalCtx, this->targetActor); - } else if (!func_8083B040(this, globalCtx)) { - func_8083A098(this, &gPlayerAnim_003098, globalCtx); - } - - this->stateFlags2 &= ~0x3800000; - this->unk_6A8 = NULL; - } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_02) { - gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex = D_808549D4[globalCtx->msgCtx.lastPlayedSong]; - gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams = 0x5FF; - gSaveContext.respawn[RESPAWN_MODE_RETURN].data = globalCtx->msgCtx.lastPlayedSong; - - this->csMode = 0; - this->stateFlags1 &= ~0x20000000; - - func_80852FFC(globalCtx, NULL, 8); - globalCtx->mainCamera.unk_14C &= ~8; - - this->stateFlags1 |= 0x30000000; - this->stateFlags2 |= 0x8000000; - - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF) == NULL) { - Environment_WarpSongLeave(globalCtx); - } - - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - } -} - -void func_8084E604(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083A098(this, &gPlayerAnim_003050, globalCtx); - } else if (LinkAnimation_OnFrame(&this->skelAnime, 3.0f)) { - Inventory_ChangeAmmo(ITEM_NUT, -1); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, this->bodyPartsPos[15].x, this->bodyPartsPos[15].y, - this->bodyPartsPos[15].z, 4000, this->actor.shape.rot.y, 0, 10); - func_80832698(this, NA_SE_VO_LI_SWORD_N); - } - - func_8083721C(this); -} - -static struct_80832924 D_808549E0[] = { - { 0, 0x3857 }, - { NA_SE_VO_LI_CLIMB_END, 0x2057 }, - { NA_SE_VO_LI_AUTO_JUMP, 0x2045 }, - { 0, -0x287B }, -}; - -void func_8084E6D4(Player* this, GlobalContext* globalCtx) { - s32 cond; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_850 != 0) { - if (this->unk_850 >= 2) { - this->unk_850--; - } - - if (func_8084DFF4(globalCtx, this) && (this->unk_850 == 1)) { - cond = ((this->targetActor != NULL) && (this->exchangeItemId < 0)) || (this->stateFlags3 & 0x20); - - if (cond || (gSaveContext.healthAccumulator == 0)) { - if (cond) { - func_8084DF6C(globalCtx, this); - this->exchangeItemId = EXCH_ITEM_NONE; - - if (func_8084B4D4(globalCtx, this) == 0) { - func_80853148(globalCtx, this->targetActor); - } - } else { - func_8084DFAC(globalCtx, this); - } - } - } - } else { - func_80832DBC(this); - - if (this->getItemId == GI_ICE_TRAP) { - this->stateFlags1 &= ~0xC00; - - if (this->getItemId != GI_ICE_TRAP) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y + 100.0f, this->actor.world.pos.z, 0, 0, 0, 0); - func_8083C0E8(this, globalCtx); - } else { - this->actor.colChkInfo.damage = 0; - func_80837C0C(globalCtx, this, 3, 0.0f, 0.0f, 0, 20); - } - return; - } - - if (this->skelAnime.animation == &gPlayerAnim_002DF8) { - func_808322D0(globalCtx, this, &gPlayerAnim_002788); - } else { - func_808322D0(globalCtx, this, &gPlayerAnim_002780); - } - - this->unk_850 = 2; - func_80835EA4(globalCtx, 9); - } - } else { - if (this->unk_850 == 0) { - if (!LINK_IS_ADULT) { - func_80832924(this, D_808549E0); - } - return; - } - - if (this->skelAnime.animation == &gPlayerAnim_002788) { - Math_ScaledStepToS(&this->actor.shape.rot.y, Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000, 4000); - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 21.0f)) { - func_808332F4(this, globalCtx); - } - } -} - -static struct_80832924 D_808549F0[] = { - { NA_SE_IT_MASTER_SWORD_SWING, -0x83C }, -}; - -void func_8084E988(Player* this) { - func_80832924(this, D_808549F0); -} - -static struct_80832924 D_808549F4[] = { - { NA_SE_VO_LI_AUTO_JUMP, 0x2005 }, - { 0, -0x280F }, -}; - -void func_8084E9AC(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_84F == 0) { - if (DECR(this->unk_850) == 0) { - this->unk_84F = 1; - this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; - } - } else { - func_8083C0E8(this, globalCtx); - } - } else { - if (LINK_IS_ADULT && LinkAnimation_OnFrame(&this->skelAnime, 158.0f)) { - func_80832698(this, NA_SE_VO_LI_SWORD_N); - return; - } - - if (!LINK_IS_ADULT) { - func_80832924(this, D_808549F4); - } else { - func_8084E988(this); - } - } -} - -static u8 D_808549FC[] = { - 0x01, 0x03, 0x02, 0x04, 0x04, -}; - -void func_8084EAC0(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_850 == 0) { - if (this->itemActionParam == PLAYER_AP_BOTTLE_POE) { - s32 rand = Rand_S16Offset(-1, 3); - - if (rand == 0) { - rand = 3; - } - - if ((rand < 0) && (gSaveContext.health <= 0x10)) { - rand = 3; - } - - if (rand < 0) { - Health_ChangeBy(globalCtx, -0x10); - } else { - gSaveContext.healthAccumulator = rand * 0x10; - } - } else { - s32 sp28 = D_808549FC[this->itemActionParam - PLAYER_AP_BOTTLE_POTION_RED]; - - if (sp28 & 1) { - gSaveContext.healthAccumulator = 0x140; - } - - if (sp28 & 2) { - Magic_Fill(globalCtx); - } - - if (sp28 & 4) { - gSaveContext.healthAccumulator = 0x50; - } - } - - func_808322A4(globalCtx, this, &gPlayerAnim_002670); - this->unk_850 = 1; - return; - } - - func_8083C0E8(this, globalCtx); - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - } else if (this->unk_850 == 1) { - if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.unk_13F0 != 9)) { - func_80832B78(globalCtx, this, &gPlayerAnim_002660); - this->unk_850 = 2; - Player_UpdateBottleHeld(globalCtx, this, ITEM_BOTTLE, PLAYER_AP_BOTTLE); - } - func_80832698(this, NA_SE_VO_LI_DRINK - SFX_FLAG); - } else if ((this->unk_850 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 29.0f)) { - func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); - } -} - -static BottleCatchInfo D_80854A04[] = { - { ACTOR_EN_ELF, ITEM_FAIRY, 0x2A, 0x46 }, - { ACTOR_EN_FISH, ITEM_FISH, 0x1F, 0x47 }, - { ACTOR_EN_ICE_HONO, ITEM_BLUE_FIRE, 0x20, 0x5D }, - { ACTOR_EN_INSECT, ITEM_BUG, 0x21, 0x7A }, -}; - -void func_8084ECA4(Player* this, GlobalContext* globalCtx) { - struct_80854554* sp24; - BottleCatchInfo* catchInfo; - s32 temp; - s32 i; - - sp24 = &D_80854554[this->unk_850]; - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_84F != 0) { - if (this->unk_850 == 0) { - Message_StartTextbox(globalCtx, D_80854A04[this->unk_84F - 1].textId, &this->actor); - Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); - this->unk_850 = 1; - } else if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->unk_84F = 0; - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - } - } else { - func_8083C0E8(this, globalCtx); - } - } else { - if (this->unk_84F == 0) { - temp = this->skelAnime.curFrame - sp24->unk_08; - - if (temp >= 0) { - if (sp24->unk_09 >= temp) { - if (this->unk_850 != 0) { - if (temp == 0) { - func_8002F7DC(&this->actor, NA_SE_IT_SCOOP_UP_WATER); - } - } - - if (this->interactRangeActor != NULL) { - catchInfo = &D_80854A04[0]; - for (i = 0; i < 4; i++, catchInfo++) { - if (this->interactRangeActor->id == catchInfo->actorId) { - break; - } - } - - if (i < 4) { - this->unk_84F = i + 1; - this->unk_850 = 0; - this->stateFlags1 |= 0x30000000; - this->interactRangeActor->parent = &this->actor; - Player_UpdateBottleHeld(globalCtx, this, catchInfo->itemId, ABS(catchInfo->actionParam)); - func_808322D0(globalCtx, this, sp24->unk_04); - func_80835EA4(globalCtx, 4); - } - } - } - } - } - } - - if (this->skelAnime.curFrame <= 7.0f) { - this->stateFlags1 |= 2; - } -} - -static Vec3f D_80854A1C = { 0.0f, 0.0f, 5.0f }; - -void func_8084EED8(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083C0E8(this, globalCtx); - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 37.0f)) { - Player_SpawnFairy(globalCtx, this, &this->leftHandPos, &D_80854A1C, FAIRY_REVIVE_BOTTLE); - Player_UpdateBottleHeld(globalCtx, this, ITEM_BOTTLE, PLAYER_AP_BOTTLE); - func_8002F7DC(&this->actor, NA_SE_EV_BOTTLE_CAP_OPEN); - func_8002F7DC(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); - } else if (LinkAnimation_OnFrame(&this->skelAnime, 47.0f)) { - gSaveContext.healthAccumulator = 0x140; - } -} - -static BottleDropInfo D_80854A28[] = { - { ACTOR_EN_FISH, FISH_DROPPED }, - { ACTOR_EN_ICE_HONO, 0 }, - { ACTOR_EN_INSECT, 2 }, -}; - -static struct_80832924 D_80854A34[] = { - { NA_SE_VO_LI_AUTO_JUMP, 0x2026 }, - { NA_SE_EV_BOTTLE_CAP_OPEN, -0x828 }, -}; - -void func_8084EFC0(Player* this, GlobalContext* globalCtx) { - func_8083721C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083C0E8(this, globalCtx); - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - return; - } - - if (LinkAnimation_OnFrame(&this->skelAnime, 76.0f)) { - BottleDropInfo* dropInfo = &D_80854A28[this->itemActionParam - PLAYER_AP_BOTTLE_FISH]; - - Actor_Spawn(&globalCtx->actorCtx, globalCtx, dropInfo->actorId, - (Math_SinS(this->actor.shape.rot.y) * 5.0f) + this->leftHandPos.x, this->leftHandPos.y, - (Math_CosS(this->actor.shape.rot.y) * 5.0f) + this->leftHandPos.z, 0x4000, this->actor.shape.rot.y, - 0, dropInfo->actorParams); - - Player_UpdateBottleHeld(globalCtx, this, ITEM_BOTTLE, PLAYER_AP_BOTTLE); - return; - } - - func_80832924(this, D_80854A34); -} - -static struct_80832924 D_80854A3C[] = { - { NA_SE_PL_PUT_OUT_ITEM, -0x81E }, -}; - -void func_8084F104(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x20; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_850 < 0) { - func_8083C0E8(this, globalCtx); - } else if (this->exchangeItemId == EXCH_ITEM_NONE) { - Actor* targetActor = this->targetActor; - - this->unk_862 = 0; - if (targetActor->textId != 0xFFFF) { - this->actor.flags |= ACTOR_FLAG_8; - } - - func_80853148(globalCtx, targetActor); - } else { - GetItemEntry* giEntry = &sGetItemTable[D_80854528[this->exchangeItemId - 1] - 1]; - - if (this->itemActionParam >= PLAYER_AP_LETTER_ZELDA) { - if (giEntry->gi >= 0) { - this->unk_862 = giEntry->gi; - } else { - this->unk_862 = -giEntry->gi; - } - } - - if (this->unk_850 == 0) { - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - - if ((this->itemActionParam == PLAYER_AP_CHICKEN) || (this->itemActionParam == PLAYER_AP_POCKET_CUCCO)) { - func_8002F7DC(&this->actor, NA_SE_EV_CHICKEN_CRY_M); - } - - this->unk_850 = 1; - } else if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - this->actor.flags &= ~ACTOR_FLAG_8; - this->unk_862 = 0; - - if (this->unk_84F == 1) { - func_80832264(globalCtx, this, &gPlayerAnim_002698); - this->unk_850 = -1; - } else { - func_8083C0E8(this, globalCtx); - } - - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - } - } - } else if (this->unk_850 >= 0) { - func_80832924(this, D_80854A3C); - } - - if ((this->unk_84F == 0) && (this->unk_664 != NULL)) { - this->currentYaw = this->actor.shape.rot.y = func_8083DB98(this, 0); - } -} - -void func_8084F308(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x60; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, &gPlayerAnim_003128); - } - - if (func_80832594(this, 0, 100)) { - func_80839F90(this, globalCtx); - this->stateFlags2 &= ~0x80; - } -} - -void func_8084F390(Player* this, GlobalContext* globalCtx) { - CollisionPoly* floorPoly; - f32 sp50; - f32 sp4C; - f32 sp48; - s16 sp46; - s16 sp44; - Vec3f sp38; - - this->stateFlags2 |= 0x60; - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_8084269C(globalCtx, this); - func_800F4138(&this->actor.projectedPos, NA_SE_PL_SLIP_LEVEL - SFX_FLAG, this->actor.speedXZ); - - if (func_8083B040(this, globalCtx) == 0) { - floorPoly = this->actor.floorPoly; - - if (floorPoly == NULL) { - func_80837B9C(this, globalCtx); - return; - } - - func_8083E298(floorPoly, &sp38, &sp46); - - sp44 = sp46; - if (this->unk_84F != 0) { - sp44 = sp46 + 0x8000; - } - - if (this->linearVelocity < 0) { - sp46 += 0x8000; - } - - sp50 = (1.0f - sp38.y) * 40.0f; - sp50 = CLAMP(sp50, 0, 10.0f); - sp4C = (sp50 * sp50) * 0.015f; - sp48 = sp38.y * 0.01f; - - if (SurfaceType_GetSlope(&globalCtx->colCtx, floorPoly, this->actor.floorBgId) != 1) { - sp50 = 0; - sp48 = sp38.y * 10.0f; - } - - if (sp4C < 1.0f) { - sp4C = 1.0f; - } - - if (Math_AsymStepToF(&this->linearVelocity, sp50, sp4C, sp48) && (sp50 == 0)) { - LinkAnimationHeader* anim; - if (this->unk_84F == 0) { - anim = D_80853D04[this->modelAnimType]; - } else { - anim = D_80853D1C[this->modelAnimType]; - } - func_8083A098(this, anim, globalCtx); - } - - Math_SmoothStepToS(&this->currentYaw, sp46, 10, 4000, 800); - Math_ScaledStepToS(&this->actor.shape.rot.y, sp44, 2000); - } -} - -void func_8084F608(Player* this, GlobalContext* globalCtx) { - if ((DECR(this->unk_850) == 0) && func_8083ADD4(globalCtx, this)) { - func_80852280(globalCtx, this, NULL); - func_80835C58(globalCtx, this, func_80852E14, 0); - func_80852E14(this, globalCtx); - } -} - -void func_8084F698(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_8084F608, 0); - this->unk_850 = 40; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0x10); -} - -void func_8084F710(Player* this, GlobalContext* globalCtx) { - s32 pad; - - if ((this->unk_84F != 0) && (globalCtx->csCtx.frames < 0x131)) { - this->actor.gravity = 0.0f; - this->actor.velocity.y = 0.0f; - } else if (D_80853600 < 150.0f) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_850 == 0) { - if (this->actor.bgCheckFlags & 1) { - this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; - func_808328A0(this); - this->unk_850 = 1; - } - } else { - if ((globalCtx->sceneNum == SCENE_SPOT04) && func_8083ADD4(globalCtx, this)) { - return; - } - func_80853080(this, globalCtx); - } - } - Math_SmoothStepToF(&this->actor.velocity.y, 2.0f, 0.3f, 8.0f, 0.5f); - } - - if ((globalCtx->sceneNum == SCENE_KENJYANOMA) && func_8083ADD4(globalCtx, this)) { - return; - } - - if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.linkAction != NULL)) { - f32 sp28 = this->actor.world.pos.y; - func_808529D0(globalCtx, this, globalCtx->csCtx.linkAction); - this->actor.world.pos.y = sp28; - } -} - -void func_8084F88C(Player* this, GlobalContext* globalCtx) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if ((this->unk_850++ > 8) && (globalCtx->sceneLoadFlag == 0)) { - - if (this->unk_84F != 0) { - if (globalCtx->sceneNum == 9) { - Gameplay_TriggerRespawn(globalCtx); - globalCtx->nextEntranceIndex = 0x0088; - } else if (this->unk_84F < 0) { - Gameplay_TriggerRespawn(globalCtx); - } else { - Gameplay_TriggerVoidOut(globalCtx); - } - - globalCtx->fadeTransition = 4; - func_80078884(NA_SE_OC_ABYSS); - } else { - globalCtx->fadeTransition = 2; - gSaveContext.nextTransition = 2; - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - } - - globalCtx->sceneLoadFlag = 0x14; - } -} - -void func_8084F9A0(Player* this, GlobalContext* globalCtx) { - func_80839800(this, globalCtx); -} - -void func_8084F9C0(Player* this, GlobalContext* globalCtx) { - this->actor.gravity = -1.0f; - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (this->actor.velocity.y < 0.0f) { - func_80837B9C(this, globalCtx); - } else if (this->actor.velocity.y < 6.0f) { - Math_StepToF(&this->linearVelocity, 3.0f, 0.5f); - } -} - -void func_8084FA54(Player* this, GlobalContext* globalCtx) { - this->unk_6AD = 2; - - func_8083AD4C(globalCtx, this); - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_80836670(this, globalCtx); - - this->unk_6BE = func_8084ABD8(globalCtx, this, 1, 0) - this->actor.shape.rot.y; - this->unk_6AE |= 0x80; - - if (globalCtx->shootingGalleryStatus < 0) { - globalCtx->shootingGalleryStatus++; - if (globalCtx->shootingGalleryStatus == 0) { - func_8083C148(this, globalCtx); - } - } -} - -void func_8084FB10(Player* this, GlobalContext* globalCtx) { - if (this->unk_84F >= 0) { - if (this->unk_84F < 6) { - this->unk_84F++; - } - - if (func_80832594(this, 1, 100)) { - this->unk_84F = -1; - EffectSsIcePiece_SpawnBurst(globalCtx, &this->actor.world.pos, this->actor.scale.x); - func_8002F7DC(&this->actor, NA_SE_PL_ICE_BROKEN); - } else { - this->stateFlags2 |= 0x4000; - } - - if ((globalCtx->gameplayFrames % 4) == 0) { - Player_InflictDamage(globalCtx, -1); - } - } else { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80839F90(this, globalCtx); - func_80837AFC(this, -20); - } - } -} - -void func_8084FBF4(Player* this, GlobalContext* globalCtx) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_808382BC(this); - - if (((this->unk_850 % 25) != 0) || func_80837B18(globalCtx, this, -1)) { - if (DECR(this->unk_850) == 0) { - func_80839F90(this, globalCtx); - } - } - - this->shockTimer = 40; - func_8002F8F0(&this->actor, NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG + this->ageProperties->unk_92); -} - -s32 func_8084FCAC(Player* this, GlobalContext* globalCtx) { - sControlInput = &globalCtx->state.input[0]; - - if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_A | BTN_L | BTN_R) && - CHECK_BTN_ALL(sControlInput->press.button, BTN_B)) || - (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) { - - D_808535D0 ^= 1; - - if (D_808535D0) { - Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), CAM_MODE_BOWARROWZ); - } - } - - if (D_808535D0) { - f32 speed; - - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { - speed = 100.0f; - } else { - speed = 20.0f; - } - - func_8006375C(3, 2, "DEBUG MODE"); - - if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_L)) { - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { - this->actor.world.pos.y += speed; - } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A)) { - this->actor.world.pos.y -= speed; - } - - if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP | BTN_DLEFT | BTN_DDOWN | BTN_DRIGHT)) { - s16 angle; - s16 temp; - - angle = temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); - - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DDOWN)) { - angle = temp + 0x8000; - } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DLEFT)) { - angle = temp + 0x4000; - } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DRIGHT)) { - angle = temp - 0x4000; - } - - this->actor.world.pos.x += speed * Math_SinS(angle); - this->actor.world.pos.z += speed * Math_CosS(angle); - } - } - - func_80832210(this); - - this->actor.gravity = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.x = 0.0f; - - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) { - Flags_SetTempClear(globalCtx, globalCtx->roomCtx.curRoom.num); - } - - Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - - return 0; - } - - return 1; -} - -void func_8084FF7C(Player* this) { - this->unk_858 += this->unk_85C; - this->unk_85C -= this->unk_858 * 5.0f; - this->unk_85C *= 0.3f; - - if (ABS(this->unk_85C) < 0.00001f) { - this->unk_85C = 0.0f; - if (ABS(this->unk_858) < 0.00001f) { - this->unk_858 = 0.0f; - } - } -} - -void func_8085002C(Player* this) { - s32 pad; - s16 sp2A; - s16 sp28; - s16 sp26; - - D_80858AC8.unk_06 -= D_80858AC8.unk_06 >> 3; - D_80858AC8.unk_08 -= D_80858AC8.unk_08 >> 3; - D_80858AC8.unk_06 += -D_80858AC8.unk_00 >> 2; - D_80858AC8.unk_08 += -D_80858AC8.unk_02 >> 2; - - sp26 = this->actor.world.rot.y - this->actor.shape.rot.y; - - sp28 = (s32)(this->actor.speedXZ * -200.0f * Math_CosS(sp26) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; - sp2A = (s32)(this->actor.speedXZ * 100.0f * Math_SinS(sp26) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; - - D_80858AC8.unk_06 += sp28 >> 2; - D_80858AC8.unk_08 += sp2A >> 2; - - if (D_80858AC8.unk_06 > 6000) { - D_80858AC8.unk_06 = 6000; - } else if (D_80858AC8.unk_06 < -6000) { - D_80858AC8.unk_06 = -6000; - } - - if (D_80858AC8.unk_08 > 6000) { - D_80858AC8.unk_08 = 6000; - } else if (D_80858AC8.unk_08 < -6000) { - D_80858AC8.unk_08 = -6000; - } - - D_80858AC8.unk_00 += D_80858AC8.unk_06; - D_80858AC8.unk_02 += D_80858AC8.unk_08; - - if (D_80858AC8.unk_00 < 0) { - D_80858AC8.unk_04 = D_80858AC8.unk_00 >> 1; - } else { - D_80858AC8.unk_04 = 0; - } -} - -s32 func_80850224(Player* this, GlobalContext* globalCtx) { - if (func_8083C6B8(globalCtx, this) == 0) { - if (func_8083BB20(this) != 0) { - s32 sp24 = func_80837818(this); - - func_80837948(globalCtx, this, sp24); - - if (sp24 >= 0x18) { - this->stateFlags2 |= 0x20000; - func_80837530(globalCtx, this, 0); - return 1; - } - } else { - return 0; - } - } - - return 1; -} - -static Vec3f D_80854A40 = { 0.0f, 40.0f, 45.0f }; - -void func_808502D0(Player* this, GlobalContext* globalCtx) { - struct_80854190* sp44 = &D_80854190[this->swordAnimation]; - - this->stateFlags2 |= 0x20; - - if (!func_80842DF4(globalCtx, this)) { - func_8084285C(this, 0.0f, sp44->unk_0C, sp44->unk_0D); - - if ((this->stateFlags2 & 0x40000000) && (this->heldItemActionParam != PLAYER_AP_HAMMER) && - LinkAnimation_OnFrame(&this->skelAnime, 0.0f)) { - this->linearVelocity = 15.0f; - this->stateFlags2 &= ~0x40000000; - } - - if (this->linearVelocity > 12.0f) { - func_8084269C(globalCtx, this); - } - - Math_StepToF(&this->linearVelocity, 0.0f, 5.0f); - func_8083C50C(this); - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (!func_80850224(this, globalCtx)) { - u8 sp43 = this->skelAnime.moveFlags; - LinkAnimationHeader* sp3C; - - if (func_8008E9C4(this)) { - sp3C = sp44->unk_08; - } else { - sp3C = sp44->unk_04; - } - - func_80832318(this); - this->skelAnime.moveFlags = 0; - - if ((sp3C == &gPlayerAnim_002908) && (this->modelAnimType != 3)) { - sp3C = &gPlayerAnim_002AC8; - } - - func_8083A098(this, sp3C, globalCtx); - - this->skelAnime.moveFlags = sp43; - this->stateFlags3 |= 8; - } - } else if (this->heldItemActionParam == PLAYER_AP_HAMMER) { - if ((this->swordAnimation == 0x16) || (this->swordAnimation == 0x13)) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f shockwavePos; - f32 sp2C; - - shockwavePos.y = func_8083973C(globalCtx, this, &D_80854A40, &shockwavePos); - sp2C = this->actor.world.pos.y - shockwavePos.y; - - Math_ScaledStepToS(&this->actor.focus.rot.x, Math_Atan2S(45.0f, sp2C), 800); - func_80836AB8(this, 1); - - if ((((this->swordAnimation == 0x16) && LinkAnimation_OnFrame(&this->skelAnime, 7.0f)) || - ((this->swordAnimation == 0x13) && LinkAnimation_OnFrame(&this->skelAnime, 2.0f))) && - (sp2C > -40.0f) && (sp2C < 40.0f)) { - func_80842A28(globalCtx, this); - EffectSsBlast_SpawnWhiteShockwave(globalCtx, &shockwavePos, &zeroVec, &zeroVec); - } - } - } - } -} - -void func_808505DC(Player* this, GlobalContext* globalCtx) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_8083721C(this); - - if (this->skelAnime.curFrame >= 6.0f) { - func_80839FFC(this, globalCtx); - } -} - -void func_8085063C(Player* this, GlobalContext* globalCtx) { - this->stateFlags2 |= 0x20; - - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_80836670(this, globalCtx); - - if (this->unk_850 == 0) { - Message_StartTextbox(globalCtx, 0x3B, &this->actor); - this->unk_850 = 1; - return; - } - - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { - s32 respawnData = gSaveContext.respawn[RESPAWN_MODE_TOP].data; - - if (globalCtx->msgCtx.choiceIndex == 0) { - gSaveContext.respawnFlag = 3; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex; - globalCtx->fadeTransition = 5; - func_80088AF0(globalCtx); - return; - } - - if (globalCtx->msgCtx.choiceIndex == 1) { - gSaveContext.respawn[RESPAWN_MODE_TOP].data = -respawnData; - gSaveContext.fw.set = 0; - func_80078914(&gSaveContext.respawn[RESPAWN_MODE_TOP].pos, NA_SE_PL_MAGIC_WIND_VANISH); - } - - func_80853080(this, globalCtx); - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - } -} - -void func_8085076C(Player* this, GlobalContext* globalCtx) { - s32 respawnData = gSaveContext.respawn[RESPAWN_MODE_TOP].data; - - if (this->unk_850 > 20) { - this->actor.draw = Player_Draw; - this->actor.world.pos.y += 60.0f; - func_80837B9C(this, globalCtx); - return; - } - - if (this->unk_850++ == 20) { - gSaveContext.respawn[RESPAWN_MODE_TOP].data = respawnData + 1; - func_80078914(&gSaveContext.respawn[RESPAWN_MODE_TOP].pos, NA_SE_PL_MAGIC_WIND_WARP); - } -} - -static LinkAnimationHeader* D_80854A58[] = { - &gPlayerAnim_002CF8, - &gPlayerAnim_002CE0, - &gPlayerAnim_002D10, -}; - -static LinkAnimationHeader* D_80854A64[] = { - &gPlayerAnim_002D00, - &gPlayerAnim_002CE8, - &gPlayerAnim_002D18, -}; - -static LinkAnimationHeader* D_80854A70[] = { - &gPlayerAnim_002D08, - &gPlayerAnim_002CF0, - &gPlayerAnim_002D20, -}; - -static u8 D_80854A7C[] = { 70, 10, 10 }; - -static struct_80832924 D_80854A80[] = { - { NA_SE_PL_SKIP, 0x814 }, - { NA_SE_VO_LI_SWORD_N, 0x2014 }, - { 0, -0x301A }, -}; - -static struct_80832924 D_80854A8C[][2] = { - { - { 0, 0x4014 }, - { NA_SE_VO_LI_MAGIC_FROL, -0x201E }, - }, - { - { 0, 0x4014 }, - { NA_SE_VO_LI_MAGIC_NALE, -0x202C }, - }, - { - { NA_SE_VO_LI_MAGIC_ATTACK, 0x2014 }, - { NA_SE_IT_SWORD_SWING_HARD, -0x814 }, - }, -}; - -void func_808507F4(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_84F < 0) { - if ((this->itemActionParam == PLAYER_AP_NAYRUS_LOVE) || (gSaveContext.unk_13F0 == 0)) { - func_80839FFC(this, globalCtx); - func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); - } - } else { - if (this->unk_850 == 0) { - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, D_80854A58[this->unk_84F], 0.83f); - - if (func_80846A00(globalCtx, this, this->unk_84F) != NULL) { - this->stateFlags1 |= 0x30000000; - if ((this->unk_84F != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { - gSaveContext.unk_13F0 = 1; - } - } else { - func_800876C8(globalCtx); - } - } else { - LinkAnimation_PlayLoopSetSpeed(globalCtx, &this->skelAnime, D_80854A64[this->unk_84F], 0.83f); - - if (this->unk_84F == 0) { - this->unk_850 = -10; - } - } - - this->unk_850++; - } - } else { - if (this->unk_850 < 0) { - this->unk_850++; - - if (this->unk_850 == 0) { - gSaveContext.respawn[RESPAWN_MODE_TOP].data = 1; - Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_TOP, 0x6FF); - gSaveContext.fw.set = 1; - gSaveContext.fw.pos.x = gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.x; - gSaveContext.fw.pos.y = gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.y; - gSaveContext.fw.pos.z = gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.z; - gSaveContext.fw.yaw = gSaveContext.respawn[RESPAWN_MODE_DOWN].yaw; - gSaveContext.fw.playerParams = 0x6FF; - gSaveContext.fw.entranceIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex; - gSaveContext.fw.roomIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].roomIndex; - gSaveContext.fw.tempSwchFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags; - gSaveContext.fw.tempCollectFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags; - this->unk_850 = 2; - } - } else if (this->unk_84F >= 0) { - if (this->unk_850 == 0) { - func_80832924(this, D_80854A80); - } else if (this->unk_850 == 1) { - func_80832924(this, D_80854A8C[this->unk_84F]); - if ((this->unk_84F == 2) && LinkAnimation_OnFrame(&this->skelAnime, 30.0f)) { - this->stateFlags1 &= ~0x30000000; - } - } else if (D_80854A7C[this->unk_84F] < this->unk_850++) { - LinkAnimation_PlayOnceSetSpeed(globalCtx, &this->skelAnime, D_80854A70[this->unk_84F], 0.83f); - this->currentYaw = this->actor.shape.rot.y; - this->unk_84F = -1; - } - } - } - - func_8083721C(this); -} - -void func_80850AEC(Player* this, GlobalContext* globalCtx) { - f32 temp; - - this->stateFlags2 |= 0x20; - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, &gPlayerAnim_002C98); - } - - Math_Vec3f_Sum(&this->actor.world.pos, &this->actor.velocity, &this->actor.world.pos); - - if (func_80834FBC(this)) { - Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); - func_80847BA0(globalCtx, this); - - temp = this->actor.world.pos.y - this->actor.floorHeight; - if (temp > 20.0f) { - temp = 20.0f; - } - - this->actor.world.rot.x = this->actor.shape.rot.x = 0; - this->actor.world.pos.y -= temp; - this->linearVelocity = 1.0f; - this->actor.velocity.y = 0.0f; - func_80837B9C(this, globalCtx); - this->stateFlags2 &= ~0x400; - this->actor.bgCheckFlags |= 1; - this->stateFlags1 |= 4; - return; - } - - if ((this->skelAnime.animation != &gPlayerAnim_002C90) || (4.0f <= this->skelAnime.curFrame)) { - this->actor.gravity = 0.0f; - Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 0x800); - func_8083264C(this, 100, 2, 100, 0); - } -} - -void func_80850C68(Player* this, GlobalContext* globalCtx) { - if ((this->unk_850 != 0) && ((this->unk_858 != 0.0f) || (this->unk_85C != 0.0f))) { - f32 updateScale = R_UPDATE_RATE * 0.5f; - - this->skelAnime.curFrame += this->skelAnime.playSpeed * updateScale; - if (this->skelAnime.curFrame >= this->skelAnime.animLength) { - this->skelAnime.curFrame -= this->skelAnime.animLength; - } - - LinkAnimation_BlendToJoint(globalCtx, &this->skelAnime, &gPlayerAnim_002C38, this->skelAnime.curFrame, - (this->unk_858 < 0.0f) ? &gPlayerAnim_002C18 : &gPlayerAnim_002C20, 5.0f, - fabsf(this->unk_858), this->blendTable); - LinkAnimation_BlendToMorph(globalCtx, &this->skelAnime, &gPlayerAnim_002C38, this->skelAnime.curFrame, - (this->unk_85C < 0.0f) ? &gPlayerAnim_002C28 : &gPlayerAnim_002C10, 5.0f, - fabsf(this->unk_85C), D_80858AD8); - LinkAnimation_InterpJointMorph(globalCtx, &this->skelAnime, 0.5f); - } else if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - this->unk_860 = 2; - func_80832284(globalCtx, this, &gPlayerAnim_002C38); - this->unk_850 = 1; - } - - func_8083721C(this); - - if (this->unk_860 == 0) { - func_80853080(this, globalCtx); - } else if (this->unk_860 == 3) { - func_80835C58(globalCtx, this, func_80850E84, 0); - func_80832B0C(globalCtx, this, &gPlayerAnim_002C00); - } -} - -void func_80850E84(Player* this, GlobalContext* globalCtx) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime) && (this->unk_860 == 0)) { - func_8083A098(this, &gPlayerAnim_002C08, globalCtx); - } -} - -static void (*D_80854AA4[])(GlobalContext*, Player*, void*) = { - NULL, func_80851008, func_80851030, func_80851094, func_808510B4, func_808510D4, func_808510F4, - func_80851114, func_80851134, func_80851154, func_80851174, func_808511D4, func_808511FC, func_80851294, - func_80851050, func_80851194, func_808511B4, func_80851248, func_808512E0, -}; - -static struct_80832924 D_80854AF0[] = { - { 0, 0x2822 }, - { NA_SE_PL_CALM_HIT, 0x82D }, - { NA_SE_PL_CALM_HIT, 0x833 }, - { NA_SE_PL_CALM_HIT, -0x840 }, -}; - -static struct_80832924 D_80854B00[] = { - { NA_SE_VO_LI_SURPRISE, 0x2003 }, { 0, 0x300F }, { 0, 0x3018 }, { 0, 0x301E }, { NA_SE_VO_LI_FALL_L, -0x201F }, -}; - -static struct_80832924 D_80854B14[] = { - { 0, -0x300A }, -}; - -static struct_80854B18 D_80854B18[] = { - { 0, NULL }, - { -1, func_808515A4 }, - { 2, &gPlayerAnim_002790 }, - { 0, NULL }, - { 0, NULL }, - { 3, &gPlayerAnim_002740 }, - { 0, NULL }, - { 0, NULL }, - { -1, func_808515A4 }, - { 2, &gPlayerAnim_002778 }, - { -1, func_80851788 }, - { 3, &gPlayerAnim_002860 }, - { -1, func_808518DC }, - { 7, &gPlayerAnim_002348 }, - { 5, &gPlayerAnim_002350 }, - { 5, &gPlayerAnim_002358 }, - { 5, &gPlayerAnim_0023B0 }, - { 7, &gPlayerAnim_0023B8 }, - { -1, func_808519EC }, - { 2, &gPlayerAnim_002728 }, - { 2, &gPlayerAnim_002738 }, - { 0, NULL }, - { -1, func_80851B90 }, - { 3, &gPlayerAnim_0027A8 }, - { 9, &gPlayerAnim_002DB0 }, - { 2, &gPlayerAnim_002DC0 }, - { -1, func_80851D2C }, - { 2, &gPlayerAnim_003098 }, - { 3, &gPlayerAnim_002780 }, - { -1, func_808515A4 }, - { 2, &gPlayerAnim_003088 }, - { 0, NULL }, - { 0, NULL }, - { 5, &gPlayerAnim_002320 }, - { -1, func_80851368 }, - { -1, func_80851E64 }, - { 5, &gPlayerAnim_002328 }, - { 16, &gPlayerAnim_002F90 }, - { -1, func_80851F84 }, - { -1, func_80851E90 }, - { 6, &gPlayerAnim_002410 }, - { 6, &gPlayerAnim_002418 }, - { -1, func_80852080 }, - { 5, &gPlayerAnim_002390 }, - { -1, func_808521F4 }, - { -1, func_8085225C }, - { -1, func_80852280 }, - { 5, &gPlayerAnim_0023A0 }, - { 5, &gPlayerAnim_002368 }, - { -1, func_808515A4 }, - { 5, &gPlayerAnim_002370 }, - { 5, &gPlayerAnim_0027B0 }, - { 5, &gPlayerAnim_0027B8 }, - { 5, &gPlayerAnim_0027C0 }, - { 3, &gPlayerAnim_002768 }, - { 3, &gPlayerAnim_0027D8 }, - { 4, &gPlayerAnim_0027E0 }, - { 3, &gPlayerAnim_002380 }, - { 3, &gPlayerAnim_002828 }, - { 6, &gPlayerAnim_002470 }, - { 6, &gPlayerAnim_0032A8 }, - { 14, &gPlayerAnim_0032A0 }, - { 3, &gPlayerAnim_0032A0 }, - { 5, &gPlayerAnim_002AE8 }, - { 16, &gPlayerAnim_002450 }, - { 15, &gPlayerAnim_002460 }, - { 15, &gPlayerAnim_002458 }, - { 3, &gPlayerAnim_002440 }, - { 3, &gPlayerAnim_002438 }, - { 3, &gPlayerAnim_002C88 }, - { 6, &gPlayerAnim_003450 }, - { 6, &gPlayerAnim_003448 }, - { 6, &gPlayerAnim_003460 }, - { 6, &gPlayerAnim_003440 }, - { 3, &gPlayerAnim_002798 }, - { 3, &gPlayerAnim_002818 }, - { 4, &gPlayerAnim_002848 }, - { 3, &gPlayerAnim_002850 }, - { 3, &gPlayerAnim_0034E0 }, - { 3, &gPlayerAnim_0034D8 }, - { 6, &gPlayerAnim_0034C8 }, - { 3, &gPlayerAnim_003470 }, - { 3, &gPlayerAnim_003478 }, - { 3, &gPlayerAnim_0034C0 }, - { 3, &gPlayerAnim_003480 }, - { 3, &gPlayerAnim_003490 }, - { 3, &gPlayerAnim_003488 }, - { 3, &gPlayerAnim_003498 }, - { 3, &gPlayerAnim_0034B0 }, - { -1, func_808524B0 }, - { 3, &gPlayerAnim_003420 }, - { -1, func_80852544 }, - { -1, func_80852564 }, - { 3, &gPlayerAnim_003250 }, - { -1, func_80852608 }, - { 3, &gPlayerAnim_002810 }, - { 3, &gPlayerAnim_002838 }, - { 3, &gPlayerAnim_002CD0 }, - { 3, &gPlayerAnim_002CD8 }, - { 3, &gPlayerAnim_002868 }, - { 3, &gPlayerAnim_0027E8 }, - { 3, &gPlayerAnim_0027F8 }, - { 3, &gPlayerAnim_002800 }, -}; - -static struct_80854B18 D_80854E50[] = { - { 0, NULL }, - { -1, func_808514C0 }, - { -1, func_8085157C }, - { -1, func_80851998 }, - { -1, func_808519C0 }, - { 11, NULL }, - { -1, func_80852C50 }, - { -1, func_80852944 }, - { -1, func_80851688 }, - { -1, func_80851750 }, - { -1, func_80851828 }, - { -1, func_808521B8 }, - { -1, func_8085190C }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { 18, D_80854AF0 }, - { 11, NULL }, - { -1, func_80851A50 }, - { 12, &gPlayerAnim_002730 }, - { 11, NULL }, - { 0, NULL }, - { -1, func_80851BE8 }, - { 11, NULL }, - { -1, func_80851CA4 }, - { 11, NULL }, - { 17, &gPlayerAnim_0030A8 }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { -1, func_80851D80 }, - { -1, func_80851DEC }, - { -1, func_80851E28 }, - { 18, D_80854B00 }, - { -1, func_808513BC }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { -1, func_80851ECC }, - { -1, func_80851FB0 }, - { -1, func_80852048 }, - { -1, func_80852174 }, - { 13, &gPlayerAnim_002398 }, - { -1, func_80852234 }, - { 0, NULL }, - { 0, NULL }, - { 11, NULL }, - { -1, func_80852450 }, - { -1, func_80851688 }, - { -1, func_80852298 }, - { 13, &gPlayerAnim_0027D0 }, - { -1, func_80852480 }, - { 13, &gPlayerAnim_0027C8 }, - { -1, func_80852328 }, - { 11, NULL }, - { 11, NULL }, - { 12, &gPlayerAnim_002388 }, - { -1, func_80852358 }, - { 11, NULL }, - { 18, D_80854B14 }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { -1, func_80852388 }, - { 17, &gPlayerAnim_002450 }, - { 12, &gPlayerAnim_002448 }, - { 12, &gPlayerAnim_002450 }, - { 11, NULL }, - { -1, func_808526EC }, - { 17, &gPlayerAnim_003468 }, - { -1, func_808526EC }, - { 17, &gPlayerAnim_003468 }, - { 12, &gPlayerAnim_0027A0 }, - { 12, &gPlayerAnim_002820 }, - { 11, NULL }, - { 12, &gPlayerAnim_002858 }, - { 12, &gPlayerAnim_0034D0 }, - { 13, &gPlayerAnim_0034F0 }, - { 12, &gPlayerAnim_0034E8 }, - { 12, &gPlayerAnim_0034A8 }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { -1, func_80852648 }, - { 11, NULL }, - { 12, &gPlayerAnim_0034A0 }, - { -1, func_808524D0 }, - { -1, func_80852514 }, - { -1, func_80852554 }, - { -1, func_808525C0 }, - { 11, NULL }, - { 11, NULL }, - { 11, NULL }, - { -1, func_8085283C }, - { -1, func_808528C8 }, - { -1, func_808528C8 }, - { 12, &gPlayerAnim_002870 }, - { 12, &gPlayerAnim_0027F0 }, - { 12, &gPlayerAnim_002808 }, - { 12, &gPlayerAnim_002450 }, -}; - -void func_80850ED8(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - func_80832DB0(this); - func_80832B0C(globalCtx, this, anim); - func_80832210(this); -} - -void func_80850F1C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - func_80832DB0(this); - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, (2.0f / 3.0f), 0.0f, Animation_GetLastFrame(anim), - ANIMMODE_ONCE, -8.0f); - func_80832210(this); -} - -void func_80850F9C(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim) { - func_80832DB0(this); - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, (2.0f / 3.0f), 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); - func_80832210(this); -} - -void func_80851008(GlobalContext* globalCtx, Player* this, void* anim) { - func_80832210(this); -} - -void func_80851030(GlobalContext* globalCtx, Player* this, void* anim) { - func_80850ED8(globalCtx, this, anim); -} - -void func_80851050(GlobalContext* globalCtx, Player* this, void* anim) { - func_80832DB0(this); - func_80832C2C(globalCtx, this, anim); - func_80832210(this); -} - -void func_80851094(GlobalContext* globalCtx, Player* this, void* anim) { - func_80850F1C(globalCtx, this, anim); -} - -void func_808510B4(GlobalContext* globalCtx, Player* this, void* anim) { - func_80850F9C(globalCtx, this, anim); -} - -void func_808510D4(GlobalContext* globalCtx, Player* this, void* anim) { - func_8083308C(globalCtx, this, anim); -} - -void func_808510F4(GlobalContext* globalCtx, Player* this, void* anim) { - func_8083303C(globalCtx, this, anim, 0x9C); -} - -void func_80851114(GlobalContext* globalCtx, Player* this, void* anim) { - func_8083313C(globalCtx, this, anim); -} - -void func_80851134(GlobalContext* globalCtx, Player* this, void* anim) { - func_808330EC(globalCtx, this, anim, 0x9C); -} - -void func_80851154(GlobalContext* globalCtx, Player* this, void* anim) { - func_80832264(globalCtx, this, anim); -} - -void func_80851174(GlobalContext* globalCtx, Player* this, void* anim) { - func_80832284(globalCtx, this, anim); -} - -void func_80851194(GlobalContext* globalCtx, Player* this, void* anim) { - func_808322D0(globalCtx, this, anim); -} - -void func_808511B4(GlobalContext* globalCtx, Player* this, void* anim) { - func_808322A4(globalCtx, this, anim); -} - -void func_808511D4(GlobalContext* globalCtx, Player* this, void* anim) { - LinkAnimation_Update(globalCtx, &this->skelAnime); -} - -void func_808511FC(GlobalContext* globalCtx, Player* this, void* anim) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80850F9C(globalCtx, this, anim); - this->unk_850 = 1; - } -} - -void func_80851248(GlobalContext* globalCtx, Player* this, void* anim) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832DBC(this); - func_808322A4(globalCtx, this, anim); - } -} - -void func_80851294(GlobalContext* globalCtx, Player* this, void* anim) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083313C(globalCtx, this, anim); - this->unk_850 = 1; - } -} - -void func_808512E0(GlobalContext* globalCtx, Player* this, void* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_80832924(this, arg2); -} - -void func_80851314(Player* this) { - if ((this->unk_448 == NULL) || (this->unk_448->update == NULL)) { - this->unk_448 = NULL; - } - - this->unk_664 = this->unk_448; - - if (this->unk_664 != NULL) { - this->actor.shape.rot.y = func_8083DB98(this, 0); - } -} - -void func_80851368(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->stateFlags1 |= 0x8000000; - this->stateFlags2 |= 0x400; - this->stateFlags1 &= ~0xC0000; - - func_80832284(globalCtx, this, &gPlayerAnim_0032F0); -} - -void func_808513BC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->actor.gravity = 0.0f; - - if (this->unk_84F == 0) { - if (func_8083D12C(globalCtx, this, NULL)) { - this->unk_84F = 1; - } else { - func_8084B158(globalCtx, this, NULL, fabsf(this->actor.velocity.y)); - Math_ScaledStepToS(&this->unk_6C2, -10000, 800); - func_8084AEEC(this, &this->actor.velocity.y, 4.0f, this->currentYaw); - } - return; - } - - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - if (this->unk_84F == 1) { - func_80832C6C(globalCtx, this, &gPlayerAnim_003328); - } else { - func_80832284(globalCtx, this, &gPlayerAnim_003328); - } - } - - func_8084B000(this); - func_8084AEEC(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); -} - -void func_808514C0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80851314(this); - - if (func_808332B8(this)) { - func_808513BC(globalCtx, this, 0); - return; - } - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (func_8008F128(this) || (this->stateFlags1 & 0x800)) { - func_80836670(this, globalCtx); - return; - } - - if ((this->interactRangeActor != NULL) && (this->interactRangeActor->textId == 0xFFFF)) { - func_8083E5A8(this, globalCtx); - } -} - -void func_8085157C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); -} - -void func_808515A4(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimationHeader* anim; - - if (func_808332B8(this)) { - func_80851368(globalCtx, this, 0); - return; - } - - anim = D_80853D34[this->modelAnimType]; - - if ((this->unk_446 == 6) || (this->unk_446 == 0x2E)) { - func_80832264(globalCtx, this, anim); - } else { - func_80832DB0(this); - LinkAnimation_Change(globalCtx, &this->skelAnime, anim, (2.0f / 3.0f), 0.0f, Animation_GetLastFrame(anim), - ANIMMODE_LOOP, -4.0f); - } - - func_80832210(this); -} - -void func_80851688(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (func_8084B3CC(globalCtx, this) == 0) { - if ((this->csMode == 0x31) && (globalCtx->csCtx.state == CS_STATE_IDLE)) { - func_8002DF54(globalCtx, NULL, 7); - return; - } - - if (func_808332B8(this) != 0) { - func_808513BC(globalCtx, this, 0); - return; - } - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (func_8008F128(this) || (this->stateFlags1 & 0x800)) { - func_80836670(this, globalCtx); - } - } -} - -static struct_80832924 D_80855188[] = { - { 0, 0x302A }, - { 0, -0x3030 }, -}; - -void func_80851750(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_80832924(this, D_80855188); -} - -void func_80851788(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->stateFlags1 &= ~0x2000000; - - this->currentYaw = this->actor.shape.rot.y = this->actor.world.rot.y = - Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_450); - - if (this->linearVelocity <= 0.0f) { - this->linearVelocity = 0.1f; - } else if (this->linearVelocity > 2.5f) { - this->linearVelocity = 2.5f; - } -} - -void func_80851828(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - f32 sp1C = 2.5f; - - func_80845BA0(globalCtx, this, &sp1C, 10); - - if (globalCtx->sceneNum == SCENE_BDAN_BOSS) { - if (this->unk_850 == 0) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { - return; - } - } else { - if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { - return; - } - } - } - - this->unk_850++; - if (this->unk_850 > 20) { - this->csMode = 0xB; - } -} - -void func_808518DC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_8083CEAC(this, globalCtx); -} - -void func_8085190C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80851314(this); - - if (this->unk_850 != 0) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80832284(globalCtx, this, func_808334E4(this)); - this->unk_850 = 0; - } - - func_80833C3C(this); - } else { - func_808401B0(globalCtx, this); - } -} - -void func_80851998(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80845964(globalCtx, this, arg2, 0.0f, 0, 0); -} - -void func_808519C0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80845964(globalCtx, this, arg2, 0.0f, 0, 1); -} - -// unused -static LinkAnimationHeader* D_80855190[] = { - &gPlayerAnim_002720, - &gPlayerAnim_002360, -}; - -static Vec3f D_80855198 = { -1.0f, 70.0f, 20.0f }; - -void func_808519EC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - Math_Vec3f_Copy(&this->actor.world.pos, &D_80855198); - this->actor.shape.rot.y = -0x8000; - func_808322D0(globalCtx, this, this->ageProperties->unk_9C); - func_80832F54(globalCtx, this, 0x28F); -} - -static struct_808551A4 D_808551A4[] = { - { NA_SE_IT_SWORD_PUTAWAY_STN, 0 }, - { NA_SE_IT_SWORD_STICK_STN, NA_SE_VO_LI_SWORD_N }, -}; - -static struct_80832924 D_808551AC[] = { - { 0, 0x401D }, - { 0, -0x4027 }, -}; - -void func_80851A50(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - struct_808551A4* sp2C; - Gfx** dLists; - - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if ((LINK_IS_ADULT && LinkAnimation_OnFrame(&this->skelAnime, 70.0f)) || - (!LINK_IS_ADULT && LinkAnimation_OnFrame(&this->skelAnime, 87.0f))) { - sp2C = &D_808551A4[gSaveContext.linkAge]; - this->interactRangeActor->parent = &this->actor; - - if (!LINK_IS_ADULT) { - dLists = D_80125DE8; - } else { - dLists = D_80125E18; - } - this->leftHandDLists = &dLists[gSaveContext.linkAge]; - - func_8002F7DC(&this->actor, sp2C->unk_00); - if (!LINK_IS_ADULT) { - func_80832698(this, sp2C->unk_02); - } - } else if (LINK_IS_ADULT) { - if (LinkAnimation_OnFrame(&this->skelAnime, 66.0f)) { - func_80832698(this, NA_SE_VO_LI_SWORD_L); - } - } else { - func_80832924(this, D_808551AC); - } -} - -void func_80851B90(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_002860, -(2.0f / 3.0f), 12.0f, 12.0f, ANIMMODE_ONCE, - 0.0f); -} - -static struct_80832924 D_808551B4[] = { - { 0, -0x281E }, -}; - -void func_80851BE8(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - - this->unk_850++; - - if (this->unk_850 >= 180) { - if (this->unk_850 == 180) { - LinkAnimation_Change(globalCtx, &this->skelAnime, &gPlayerAnim_003298, (2.0f / 3.0f), 10.0f, - Animation_GetLastFrame(&gPlayerAnim_003298), ANIMMODE_ONCE, -8.0f); - } - func_80832924(this, D_808551B4); - } -} - -void func_80851CA4(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime) && (this->unk_850 == 0) && (this->actor.bgCheckFlags & 1)) { - func_80832264(globalCtx, this, &gPlayerAnim_002DB8); - this->unk_850 = 1; - } - - if (this->unk_850 != 0) { - func_8083721C(this); - } -} - -void func_80851D2C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80850F1C(globalCtx, this, &gPlayerAnim_0030A0); - func_8084B498(this); - Player_SetModels(this, Player_ActionToModelGroup(this, this->itemActionParam)); -} - -static struct_80832924 D_808551B8[] = { - { NA_SE_IT_SWORD_PICKOUT, -0x80C }, -}; - -void func_80851D80(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (LinkAnimation_OnFrame(&this->skelAnime, 6.0f)) { - func_80846720(globalCtx, this, 0); - } else { - func_80832924(this, D_808551B8); - } -} - -void func_80851DEC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - Math_StepToS(&this->actor.shape.face, 0, 1); -} - -void func_80851E28(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - Math_StepToS(&this->actor.shape.face, 2, 1); -} - -void func_80851E64(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80833064(globalCtx, this, &gPlayerAnim_003318, 0x98); -} - -void func_80851E90(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_8083303C(globalCtx, this, &gPlayerAnim_002408, 0x9C); - func_80832698(this, NA_SE_VO_LI_GROAN); -} - -void func_80851ECC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_808330EC(globalCtx, this, &gPlayerAnim_002428, 0x9C); - } -} - -void func_80851F14(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, struct_80832924* arg3) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_808322A4(globalCtx, this, anim); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { - func_80832924(this, arg3); - } -} - -void func_80851F84(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->actor.shape.shadowDraw = NULL; - func_80851134(globalCtx, this, &gPlayerAnim_002420); -} - -static struct_80832924 D_808551BC[] = { - { NA_SE_VO_LI_RELAX, 0x2023 }, - { NA_SE_PL_SLIPDOWN, 0x8EC }, - { NA_SE_PL_SLIPDOWN, -0x900 }, -}; - -void func_80851FB0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_808330EC(globalCtx, this, &gPlayerAnim_002430, 0x9C); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { - func_80832924(this, D_808551BC); - if (LinkAnimation_OnFrame(&this->skelAnime, 240.0f)) { - this->actor.shape.shadowDraw = ActorShadow_DrawFeet; - } - } -} - -static struct_80832924 D_808551C8[] = { - { NA_SE_PL_LAND_LADDER, 0x843 }, - { 0, 0x4854 }, - { 0, 0x485A }, - { 0, -0x4860 }, -}; - -void func_80852048(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_80832924(this, D_808551C8); -} - -void func_80852080(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80833064(globalCtx, this, &gPlayerAnim_002340, 0x9D); - func_80832698(this, NA_SE_VO_LI_FALL_L); -} - -void func_808520BC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - f32 startX = arg2->startPos.x; - f32 startY = arg2->startPos.y; - f32 startZ = arg2->startPos.z; - f32 distX = (arg2->endPos.x - startX); - f32 distY = (arg2->endPos.y - startY); - f32 distZ = (arg2->endPos.z - startZ); - f32 sp4 = (f32)(globalCtx->csCtx.frames - arg2->startFrame) / (f32)(arg2->endFrame - arg2->startFrame); - - this->actor.world.pos.x = distX * sp4 + startX; - this->actor.world.pos.y = distY * sp4 + startY; - this->actor.world.pos.z = distZ * sp4 + startZ; -} - -static struct_80832924 D_808551D8[] = { - { NA_SE_PL_BOUND, 0x1014 }, - { NA_SE_PL_BOUND, -0x101E }, -}; - -void func_80852174(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_808520BC(globalCtx, this, arg2); - LinkAnimation_Update(globalCtx, &this->skelAnime); - func_80832924(this, D_808551D8); -} - -void func_808521B8(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (arg2 != NULL) { - func_808520BC(globalCtx, this, arg2); - } - LinkAnimation_Update(globalCtx, &this->skelAnime); -} - -void func_808521F4(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80832B0C(globalCtx, this, D_80853D34[this->modelAnimType]); - func_80832210(this); -} - -void func_80852234(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); -} - -void func_8085225C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80832F54(globalCtx, this, 0x98); -} - -void func_80852280(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->actor.draw = Player_Draw; -} - -void func_80852298(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8083313C(globalCtx, this, &gPlayerAnim_002378); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { - if (LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { - func_80846720(globalCtx, this, 1); - } - } -} - -static struct_80832924 D_808551E0[] = { - { 0, 0x300A }, - { 0, -0x3018 }, -}; - -void func_80852328(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80851F14(globalCtx, this, &gPlayerAnim_002770, D_808551E0); -} - -static struct_80832924 D_808551E8[] = { - { 0, 0x400F }, - { 0, -0x4023 }, -}; - -void func_80852358(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80851F14(globalCtx, this, &gPlayerAnim_002830, D_808551E8); -} - -void func_80852388(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_808322A4(globalCtx, this, &gPlayerAnim_002468); - this->unk_850 = 1; - } - - if ((this->unk_850 != 0) && (globalCtx->csCtx.frames >= 900)) { - this->rightHandType = 0; - } else { - this->rightHandType = 0xFF; - } -} - -void func_80852414(GlobalContext* globalCtx, Player* this, LinkAnimationHeader* anim, struct_80832924* arg3) { - func_80851294(globalCtx, this, anim); - if (this->unk_850 == 0) { - func_80832924(this, arg3); - } -} - -static struct_80832924 D_808551F0[] = { - { 0, 0x300F }, - { 0, -0x3021 }, -}; - -void func_80852450(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80852414(globalCtx, this, &gPlayerAnim_002378, D_808551F0); -} - -static struct_80832924 D_808551F8[] = { - { NA_SE_PL_KNOCK, -0x84E }, -}; - -void func_80852480(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80852414(globalCtx, this, &gPlayerAnim_0027D0, D_808551F8); -} - -void func_808524B0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80837704(globalCtx, this); -} - -void func_808524D0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - sControlInput->press.button |= BTN_B; - - func_80844E68(this, globalCtx); -} - -void func_80852514(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80844E68(this, globalCtx); -} - -void func_80852544(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { -} - -void func_80852554(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { -} - -void func_80852564(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->stateFlags3 |= 2; - this->linearVelocity = 2.0f; - this->actor.velocity.y = -1.0f; - - func_80832264(globalCtx, this, &gPlayerAnim_002DB0); - func_80832698(this, NA_SE_VO_LI_FALL_L); -} - -static void (*D_808551FC[])(Player* this, GlobalContext* globalCtx) = { - func_8084377C, - func_80843954, - func_80843A38, -}; - -void func_808525C0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - D_808551FC[this->unk_850](this, globalCtx); -} - -void func_80852608(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - func_80846720(globalCtx, this, 0); - func_808322D0(globalCtx, this, &gPlayerAnim_002838); -} - -void func_80852648(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - LinkAnimation_Update(globalCtx, &this->skelAnime); - - if (LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { - this->heldItemActionParam = this->itemActionParam = PLAYER_AP_NONE; - this->heldItemId = ITEM_NONE; - this->modelGroup = this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_AP_NONE); - this->leftHandDLists = D_80125E08; - Inventory_ChangeEquipment(EQUIP_SWORD, 2); - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - Inventory_DeleteEquipment(globalCtx, 0); - } -} - -static LinkAnimationHeader* D_80855208[] = { - &gPlayerAnim_0034B8, - &gPlayerAnim_003458, -}; - -static Vec3s D_80855210[2][2] = { - { { -200, 700, 100 }, { 800, 600, 800 } }, - { { -200, 500, 0 }, { 600, 400, 600 } }, -}; - -void func_808526EC(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - static Color_RGBA8 primColor = { 255, 255, 255, 0 }; - static Color_RGBA8 envColor = { 0, 128, 128, 0 }; - s32 age = gSaveContext.linkAge; - Vec3f sparklePos; - Vec3f sp34; - Vec3s* ptr; - - func_80851294(globalCtx, this, D_80855208[age]); - - if (this->rightHandType != 0xFF) { - this->rightHandType = 0xFF; - return; - } - - ptr = D_80855210[gSaveContext.linkAge]; - - sp34.x = ptr[0].x + Rand_CenteredFloat(ptr[1].x); - sp34.y = ptr[0].y + Rand_CenteredFloat(ptr[1].y); - sp34.z = ptr[0].z + Rand_CenteredFloat(ptr[1].z); - - SkinMatrix_Vec3fMtxFMultXYZ(&this->shieldMf, &sp34, &sparklePos); - - EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &zeroVec, &zeroVec, &primColor, &envColor, 600, -10); -} - -void func_8085283C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_80852944(globalCtx, this, arg2); - } else if (this->unk_850 == 0) { - Item_Give(globalCtx, ITEM_SWORD_MASTER); - func_80846720(globalCtx, this, 0); - } else { - func_8084E988(this); - } -} - -void func_808528C8(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(globalCtx, &this->skelAnime)) { - func_8084285C(this, 0.0f, 99.0f, this->skelAnime.endFrame - 8.0f); - } - - if (this->heldItemActionParam != PLAYER_AP_SWORD_MASTER) { - func_80846720(globalCtx, this, 1); - } -} - -void func_80852944(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - if (func_808332B8(this)) { - func_80838F18(globalCtx, this); - func_80832340(globalCtx, this); - } else { - func_8083C148(this, globalCtx); - if (!func_8083B644(this, globalCtx)) { - func_8083E5A8(this, globalCtx); - } - } - - this->csMode = 0; - this->unk_6AD = 0; -} - -void func_808529D0(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - this->actor.world.pos.x = arg2->startPos.x; - this->actor.world.pos.y = arg2->startPos.y; - if ((globalCtx->sceneNum == SCENE_SPOT04) && !LINK_IS_ADULT) { - this->actor.world.pos.y -= 1.0f; - } - this->actor.world.pos.z = arg2->startPos.z; - this->currentYaw = this->actor.shape.rot.y = arg2->rot.y; -} - -void func_80852A54(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - f32 dx = arg2->startPos.x - (s32)this->actor.world.pos.x; - f32 dy = arg2->startPos.y - (s32)this->actor.world.pos.y; - f32 dz = arg2->startPos.z - (s32)this->actor.world.pos.z; - f32 dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); - s16 yawDiff = arg2->rot.y - this->actor.shape.rot.y; - - if ((this->linearVelocity == 0.0f) && ((dist > 50.0f) || (ABS(yawDiff) > 0x4000))) { - func_808529D0(globalCtx, this, arg2); - } - - this->skelAnime.moveFlags = 0; - func_80832DB0(this); -} - -void func_80852B4C(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2, struct_80854B18* arg3) { - if (arg3->type > 0) { - D_80854AA4[arg3->type](globalCtx, this, arg3->ptr); - } else if (arg3->type < 0) { - arg3->func(globalCtx, this, arg2); - } - - if ((D_80858AA0 & 4) && !(this->skelAnime.moveFlags & 4)) { - this->skelAnime.morphTable[0].y /= this->ageProperties->unk_08; - D_80858AA0 = 0; - } -} - -void func_80852C0C(GlobalContext* globalCtx, Player* this, s32 csMode) { - if ((csMode != 1) && (csMode != 8) && (csMode != 0x31) && (csMode != 7)) { - func_808323B4(globalCtx, this); - } -} - -void func_80852C50(GlobalContext* globalCtx, Player* this, CsCmdActorAction* arg2) { - CsCmdActorAction* linkCsAction = globalCtx->csCtx.linkAction; - s32 pad; - s32 sp24; - - if (globalCtx->csCtx.state == CS_STATE_UNSKIPPABLE_INIT) { - func_8002DF54(globalCtx, NULL, 7); - this->unk_446 = 0; - func_80832210(this); - return; - } - - if (linkCsAction == NULL) { - this->actor.flags &= ~ACTOR_FLAG_UNCULLED; - return; - } - - if (this->unk_446 != linkCsAction->action) { - sp24 = D_808547C4[linkCsAction->action]; - if (sp24 >= 0) { - if ((sp24 == 3) || (sp24 == 4)) { - func_80852A54(globalCtx, this, linkCsAction); - } else { - func_808529D0(globalCtx, this, linkCsAction); - } - } - - D_80858AA0 = this->skelAnime.moveFlags; - - func_80832DBC(this); - osSyncPrintf("TOOL MODE=%d\n", sp24); - func_80852C0C(globalCtx, this, ABS(sp24)); - func_80852B4C(globalCtx, this, linkCsAction, &D_80854B18[ABS(sp24)]); - - this->unk_850 = 0; - this->unk_84F = 0; - this->unk_446 = linkCsAction->action; - } - - sp24 = D_808547C4[this->unk_446]; - func_80852B4C(globalCtx, this, linkCsAction, &D_80854E50[ABS(sp24)]); -} - -void func_80852E14(Player* this, GlobalContext* globalCtx) { - if (this->csMode != this->prevCsMode) { - D_80858AA0 = this->skelAnime.moveFlags; - - func_80832DBC(this); - this->prevCsMode = this->csMode; - osSyncPrintf("DEMO MODE=%d\n", this->csMode); - func_80852C0C(globalCtx, this, this->csMode); - func_80852B4C(globalCtx, this, NULL, &D_80854B18[this->csMode]); - } - - func_80852B4C(globalCtx, this, NULL, &D_80854E50[this->csMode]); -} - -s32 Player_IsDroppingFish(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); - - return (func_8084EFC0 == this->func_674) && (this->itemActionParam == PLAYER_AP_BOTTLE_FISH); -} - -s32 Player_StartFishing(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); - - func_80832564(globalCtx, this); - func_80835F44(globalCtx, this, ITEM_FISHING_POLE); - return 1; -} - -s32 func_80852F38(GlobalContext* globalCtx, Player* this) { - if (!Player_InBlockingCsMode(globalCtx, this) && (this->invincibilityTimer >= 0) && !func_8008F128(this) && - !(this->stateFlags3 & 0x80)) { - func_80832564(globalCtx, this); - func_80835C58(globalCtx, this, func_8084F308, 0); - func_80832264(globalCtx, this, &gPlayerAnim_003120); - this->stateFlags2 |= 0x80; - func_80832224(this); - func_80832698(this, NA_SE_VO_LI_HELD); - return true; - } - - return false; -} - -// Sets up player cutscene -s32 func_80852FFC(GlobalContext* globalCtx, Actor* actor, s32 csMode) { - Player* this = GET_PLAYER(globalCtx); - - if (!Player_InBlockingCsMode(globalCtx, this)) { - func_80832564(globalCtx, this); - func_80835C58(globalCtx, this, func_80852E14, 0); - this->csMode = csMode; - this->unk_448 = actor; - func_80832224(this); - return 1; - } - - return 0; -} - -void func_80853080(Player* this, GlobalContext* globalCtx) { - func_80835C58(globalCtx, this, func_80840BC8, 1); - func_80832B0C(globalCtx, this, func_80833338(this)); - this->currentYaw = this->actor.shape.rot.y; -} - -s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage) { - Player* this = GET_PLAYER(globalCtx); - - if (!Player_InBlockingCsMode(globalCtx, this) && !func_80837B18(globalCtx, this, damage)) { - this->stateFlags2 &= ~0x80; - return 1; - } - - return 0; -} - -// Start talking with the given actor -void func_80853148(GlobalContext* globalCtx, Actor* actor) { - Player* this = GET_PLAYER(globalCtx); - s32 pad; - - if ((this->targetActor != NULL) || (actor == this->naviActor) || - CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_18)) { - actor->flags |= ACTOR_FLAG_8; - } - - this->targetActor = actor; - this->exchangeItemId = EXCH_ITEM_NONE; - - if (actor->textId == 0xFFFF) { - func_8002DF54(globalCtx, actor, 1); - actor->flags |= ACTOR_FLAG_8; - func_80832528(globalCtx, this); - } else { - if (this->actor.flags & ACTOR_FLAG_8) { - this->actor.textId = 0; - } else { - this->actor.flags |= ACTOR_FLAG_8; - this->actor.textId = actor->textId; - } - - if (this->stateFlags1 & 0x800000) { - s32 sp24 = this->unk_850; - - func_80832528(globalCtx, this); - func_8083A2F8(globalCtx, this); - - this->unk_850 = sp24; - } else { - if (func_808332B8(this)) { - func_80836898(globalCtx, this, func_8083A2F8); - func_80832C6C(globalCtx, this, &gPlayerAnim_003328); - } else if ((actor->category != ACTORCAT_NPC) || (this->heldItemActionParam == PLAYER_AP_FISHING_POLE)) { - func_8083A2F8(globalCtx, this); - - if (!func_8008E9C4(this)) { - if ((actor != this->naviActor) && (actor->xzDistToPlayer < 40.0f)) { - func_808322D0(globalCtx, this, &gPlayerAnim_002DF0); - } else { - func_80832284(globalCtx, this, func_80833338(this)); - } - } - } else { - func_80836898(globalCtx, this, func_8083A2F8); - func_808322D0(globalCtx, this, - (actor->xzDistToPlayer < 40.0f) ? &gPlayerAnim_002DF0 : &gPlayerAnim_0031A0); - } - - if (this->skelAnime.animation == &gPlayerAnim_002DF0) { - func_80832F54(globalCtx, this, 0x19); - } - - func_80832224(this); - } - - this->stateFlags1 |= 0x20000040; - } - - if ((this->naviActor == this->targetActor) && ((this->targetActor->textId & 0xFF00) != 0x200)) { - this->naviActor->flags |= ACTOR_FLAG_8; - func_80835EA4(globalCtx, 0xB); - } -} diff --git a/src/overlays/actors/ovl_player_actor/z_player.cpp b/src/overlays/actors/ovl_player_actor/z_player.cpp new file mode 100644 index 000000000..dc92c09f8 --- /dev/null +++ b/src/overlays/actors/ovl_player_actor/z_player.cpp @@ -0,0 +1,14225 @@ +#define INTERNAL_SRC_OVERLAYS_ACTORS_OVL_PLAYER_ACTOR_Z_PLAYER_C +#include "actor_common.h" +#include +#include "z_player.h" +#include "z_scene_table.h" +#include "hack.h" +extern u8 gPlayerModelTypes[][5]; +extern FlexSkeletonHeader* gPlayerSkelHeaders[2]; +extern u8 gPlayerModelTypes[][5]; +extern Gfx* D_80125DE8[]; +extern Gfx* D_80125E08[]; +extern Gfx* D_80125E18[]; +extern Gfx* D_80125EF8[]; +extern Gfx gCullBackDList[]; +extern Gfx gCullFrontDList[]; + +/* + * File: z_player.c + * Overlay: ovl_player_actor + * Description: Link + */ + +#include "ultra64.h" +#include "global.h" + +#include "overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.h" +#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" +#include "overlays/actors/ovl_En_Boom/z_en_boom.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "overlays/actors/ovl_En_Fish/z_en_fish.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" +#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_link_child/object_link_child.h" +#include "def/code_80043480.h" +#include "def/code_80097A00.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800FD970.h" +#include "def/createmesgqueue.h" +#include "def/graph.h" +#include "def/shrink_window.h" +#include "def/sys_math3d.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_bgcheck.h" +#include "def/z_camera.h" +#include "def/z_collision_check.h" +#include "def/z_common_data.h" +#include "def/z_debug.h" +#include "def/z_effect.h" +#include "def/z_effect_soft_sprite_old_init.h" +#include "def/z_en_item00.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_lifemeter.h" +#include "def/z_malloc.h" +#include "def/z_map_exp.h" +#include "def/z_message_PAL.h" +#include "def/z_onepointdemo.h" +#include "def/z_parameter.h" +#include "def/z_play.h" +#include "def/z_player_lib.h" +#include "def/z_quake.h" +#include "def/z_rcp.h" +#include "def/z_room.h" +#include "def/z_scene.h" +#include "def/z_scene_table.h" +#include "def/z_skelanime.h" +#include "def/z_skin_matrix.h" +#include "def/z_std_dma.h" + +typedef struct { + /* 0x00 */ u8 itemId; + /* 0x01 */ u8 field; // various bit-packed data + /* 0x02 */ s8 gi; // defines the draw id and chest opening animation + /* 0x03 */ u8 textId; + /* 0x04 */ u16 objectId; +} GetItemEntry; // size = 0x06 + +#define GET_ITEM(itemId, objectId, drawId, textId, field, chestAnim) \ + { itemId, field, (chestAnim != 0 ? 1 : -1) * (drawId + 1), textId, objectId } + +#define CHEST_ANIM_SHORT 0 +#define CHEST_ANIM_LONG 1 + +#define GET_ITEM_NONE \ + { ITEM_NONE, 0, 0, 0, 0 } + +typedef enum { + /* 0x00 */ KNOB_ANIM_ADULT_L, + /* 0x01 */ KNOB_ANIM_CHILD_L, + /* 0x02 */ KNOB_ANIM_ADULT_R, + /* 0x03 */ KNOB_ANIM_CHILD_R +} KnobDoorAnim; + +typedef struct { + /* 0x00 */ u8 itemId; + /* 0x02 */ s16 actorId; +} ExplosiveInfo; // size = 0x04 + +typedef struct { + /* 0x00 */ s16 actorId; + /* 0x02 */ u8 itemId; + /* 0x03 */ u8 actionParam; + /* 0x04 */ u8 textId; +} BottleCatchInfo; // size = 0x06 + +typedef struct { + /* 0x00 */ s16 actorId; + /* 0x02 */ s16 actorParams; +} BottleDropInfo; // size = 0x04 + +typedef struct { + /* 0x00 */ s8 damage; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x03 */ u8 unk_03; + /* 0x04 */ u16 sfxId; +} FallImpactInfo; // size = 0x06 + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ s16 yaw; +} SpecialRespawnInfo; // size = 0x10 + +typedef struct { + /* 0x00 */ u16 sfxId; + /* 0x02 */ s16 field; +} struct_80832924; // size = 0x04 + +typedef struct { + /* 0x00 */ u16 unk_00; + /* 0x02 */ s16 unk_02; +} struct_808551A4; // size = 0x04 + +typedef struct { + /* 0x00 */ LinkAnimationHeader* anim; + /* 0x04 */ u8 unk_04; +} struct_808540F4; // size = 0x08 + +typedef struct { + /* 0x00 */ LinkAnimationHeader* unk_00; + /* 0x04 */ LinkAnimationHeader* unk_04; + /* 0x08 */ u8 unk_08; + /* 0x09 */ u8 unk_09; +} struct_80854554; // size = 0x0C + +typedef struct { + /* 0x00 */ LinkAnimationHeader* unk_00; + /* 0x04 */ LinkAnimationHeader* unk_04; + /* 0x08 */ LinkAnimationHeader* unk_08; + /* 0x0C */ u8 unk_0C; + /* 0x0D */ u8 unk_0D; +} struct_80854190; // size = 0x10 + +typedef struct { + /* 0x00 */ LinkAnimationHeader* anim; + /* 0x04 */ f32 unk_04; + /* 0x04 */ f32 unk_08; +} struct_80854578; // size = 0x0C + +typedef struct { + /* 0x00 */ s8 type; + /* 0x04 */ union { + void* ptr; + void (*func)(GlobalContext*, Player*, CsCmdActorAction*); + }; +} struct_80854B18; // size = 0x08 + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; +} struct_80858AC8; // size = 0x0A + +void func_80833770(GlobalContext* globalCtx, Player* pthis); +void func_80833790(GlobalContext* globalCtx, Player* pthis); +void func_8083379C(GlobalContext* globalCtx, Player* pthis); +void func_8083377C(GlobalContext* globalCtx, Player* pthis); +void func_808337D4(GlobalContext* globalCtx, Player* pthis); +void func_80833910(GlobalContext* globalCtx, Player* pthis); +void func_80833984(GlobalContext* globalCtx, Player* pthis); +void func_8083399C(GlobalContext* globalCtx, Player* pthis, s8 actionParam); +s32 func_8083485C(Player* pthis, GlobalContext* globalCtx); +s32 func_808349DC(Player* pthis, GlobalContext* globalCtx); +s32 func_80834A2C(Player* pthis, GlobalContext* globalCtx); +s32 func_80834B5C(Player* pthis, GlobalContext* globalCtx); +s32 func_80834C74(Player* pthis, GlobalContext* globalCtx); +s32 func_8083501C(Player* pthis, GlobalContext* globalCtx); +s32 func_808351D4(Player* pthis, GlobalContext* globalCtx); +s32 func_808353D8(Player* pthis, GlobalContext* globalCtx); +s32 func_80835588(Player* pthis, GlobalContext* globalCtx); +s32 func_808356E8(Player* pthis, GlobalContext* globalCtx); +s32 func_80835800(Player* pthis, GlobalContext* globalCtx); +s32 func_80835884(Player* pthis, GlobalContext* globalCtx); +s32 func_808358F0(Player* pthis, GlobalContext* globalCtx); +s32 func_808359FC(Player* pthis, GlobalContext* globalCtx); +s32 func_80835B60(Player* pthis, GlobalContext* globalCtx); +s32 func_80835C08(Player* pthis, GlobalContext* globalCtx); +void func_80835F44(GlobalContext* globalCtx, Player* pthis, s32 item); +void func_80839F90(Player* pthis, GlobalContext* globalCtx); +s32 func_80838A14(Player* pthis, GlobalContext* globalCtx); +s32 func_80839800(Player* pthis, GlobalContext* globalCtx); +s32 func_8083B040(Player* pthis, GlobalContext* globalCtx); +s32 func_8083B998(Player* pthis, GlobalContext* globalCtx); +s32 func_8083B644(Player* pthis, GlobalContext* globalCtx); +s32 func_8083BDBC(Player* pthis, GlobalContext* globalCtx); +s32 func_8083C1DC(Player* pthis, GlobalContext* globalCtx); +s32 func_8083C2B0(Player* pthis, GlobalContext* globalCtx); +s32 func_8083C544(Player* pthis, GlobalContext* globalCtx); +s32 func_8083C61C(GlobalContext* globalCtx, Player* pthis); +void func_8083CA20(GlobalContext* globalCtx, Player* pthis); +void func_8083CA54(GlobalContext* globalCtx, Player* pthis); +void func_8083CA9C(GlobalContext* globalCtx, Player* pthis); +s32 func_8083E0FC(Player* pthis, GlobalContext* globalCtx); +s32 func_8083E5A8(Player* pthis, GlobalContext* globalCtx); +s32 func_8083EB44(Player* pthis, GlobalContext* globalCtx); +s32 func_8083F7BC(Player* pthis, GlobalContext* globalCtx); +void func_80840450(Player* pthis, GlobalContext* globalCtx); +void func_808407CC(Player* pthis, GlobalContext* globalCtx); +void func_80840BC8(Player* pthis, GlobalContext* globalCtx); +void func_80840DE4(Player* pthis, GlobalContext* globalCtx); +void func_808414F8(Player* pthis, GlobalContext* globalCtx); +void func_8084170C(Player* pthis, GlobalContext* globalCtx); +void func_808417FC(Player* pthis, GlobalContext* globalCtx); +void func_8084193C(Player* pthis, GlobalContext* globalCtx); +void func_80841BA8(Player* pthis, GlobalContext* globalCtx); +void func_80842180(Player* pthis, GlobalContext* globalCtx); +void func_8084227C(Player* pthis, GlobalContext* globalCtx); +void func_8084279C(Player* pthis, GlobalContext* globalCtx); +void func_808423EC(Player* pthis, GlobalContext* globalCtx); +void func_8084251C(Player* pthis, GlobalContext* globalCtx); +void func_80843188(Player* pthis, GlobalContext* globalCtx); +void func_808435C4(Player* pthis, GlobalContext* globalCtx); +void func_8084370C(Player* pthis, GlobalContext* globalCtx); +void func_8084377C(Player* pthis, GlobalContext* globalCtx); +void func_80843954(Player* pthis, GlobalContext* globalCtx); +void func_80843A38(Player* pthis, GlobalContext* globalCtx); +void func_80843CEC(Player* pthis, GlobalContext* globalCtx); +void func_8084411C(Player* pthis, GlobalContext* globalCtx); +void func_80844708(Player* pthis, GlobalContext* globalCtx); +void func_80844A44(Player* pthis, GlobalContext* globalCtx); +void func_80844AF4(Player* pthis, GlobalContext* globalCtx); +void func_80844E68(Player* pthis, GlobalContext* globalCtx); +void func_80845000(Player* pthis, GlobalContext* globalCtx); +void func_80845308(Player* pthis, GlobalContext* globalCtx); +void func_80845668(Player* pthis, GlobalContext* globalCtx); +void func_808458D0(Player* pthis, GlobalContext* globalCtx); +void func_80845CA4(Player* pthis, GlobalContext* globalCtx); +void func_80845EF8(Player* pthis, GlobalContext* globalCtx); +void func_80846050(Player* pthis, GlobalContext* globalCtx); +void func_80846120(Player* pthis, GlobalContext* globalCtx); +void func_80846260(Player* pthis, GlobalContext* globalCtx); +void func_80846358(Player* pthis, GlobalContext* globalCtx); +void func_80846408(Player* pthis, GlobalContext* globalCtx); +void func_808464B0(Player* pthis, GlobalContext* globalCtx); +void func_80846578(Player* pthis, GlobalContext* globalCtx); +void func_80846648(GlobalContext* globalCtx, Player* pthis); +void func_80846660(GlobalContext* globalCtx, Player* pthis); +void func_808467D4(GlobalContext* globalCtx, Player* pthis); +void func_808468A8(GlobalContext* globalCtx, Player* pthis); +void func_808468E8(GlobalContext* globalCtx, Player* pthis); +void func_80846978(GlobalContext* globalCtx, Player* pthis); +void func_808469BC(GlobalContext* globalCtx, Player* pthis); +void func_80846A68(GlobalContext* globalCtx, Player* pthis); +void func_8084B1D8(Player* pthis, GlobalContext* globalCtx); +void func_8084B530(Player* pthis, GlobalContext* globalCtx); +void func_8084B78C(Player* pthis, GlobalContext* globalCtx); +void func_8084B898(Player* pthis, GlobalContext* globalCtx); +void func_8084B9E4(Player* pthis, GlobalContext* globalCtx); +void func_8084BBE4(Player* pthis, GlobalContext* globalCtx); +void func_8084BDFC(Player* pthis, GlobalContext* globalCtx); +void func_8084BF1C(Player* pthis, GlobalContext* globalCtx); +void Player_UpdateCommon(Player* pthis, GlobalContext* globalCtx, Input* input); +void func_8084C5F8(Player* pthis, GlobalContext* globalCtx); +void func_8084C760(Player* pthis, GlobalContext* globalCtx); +void func_8084C81C(Player* pthis, GlobalContext* globalCtx); +void func_8084CC98(Player* pthis, GlobalContext* globalCtx); +void func_8084D3E4(Player* pthis, GlobalContext* globalCtx); +void func_8084D610(Player* pthis, GlobalContext* globalCtx); +void func_8084D7C4(Player* pthis, GlobalContext* globalCtx); +void func_8084D84C(Player* pthis, GlobalContext* globalCtx); +void func_8084DAB4(Player* pthis, GlobalContext* globalCtx); +void func_8084DC48(Player* pthis, GlobalContext* globalCtx); +void func_8084E1EC(Player* pthis, GlobalContext* globalCtx); +void func_8084E30C(Player* pthis, GlobalContext* globalCtx); +void func_8084E368(Player* pthis, GlobalContext* globalCtx); +void func_8084E3C4(Player* pthis, GlobalContext* globalCtx); +void func_8084E604(Player* pthis, GlobalContext* globalCtx); +void func_8084E6D4(Player* pthis, GlobalContext* globalCtx); +void func_8084E9AC(Player* pthis, GlobalContext* globalCtx); +void func_8084EAC0(Player* pthis, GlobalContext* globalCtx); +void func_8084ECA4(Player* pthis, GlobalContext* globalCtx); +void func_8084EED8(Player* pthis, GlobalContext* globalCtx); +void func_8084EFC0(Player* pthis, GlobalContext* globalCtx); +void func_8084F104(Player* pthis, GlobalContext* globalCtx); +void func_8084F390(Player* pthis, GlobalContext* globalCtx); +void func_8084F608(Player* pthis, GlobalContext* globalCtx); +void func_8084F698(Player* pthis, GlobalContext* globalCtx); +void func_8084F710(Player* pthis, GlobalContext* globalCtx); +void func_8084F88C(Player* pthis, GlobalContext* globalCtx); +void func_8084F9A0(Player* pthis, GlobalContext* globalCtx); +void func_8084F9C0(Player* pthis, GlobalContext* globalCtx); +void func_8084FA54(Player* pthis, GlobalContext* globalCtx); +void func_8084FB10(Player* pthis, GlobalContext* globalCtx); +void func_8084FBF4(Player* pthis, GlobalContext* globalCtx); +s32 func_8084FCAC(Player* pthis, GlobalContext* globalCtx); +void func_8084FF7C(Player* pthis); +void func_8085002C(Player* pthis); +s32 func_80850224(Player* pthis, GlobalContext* globalCtx); +void func_808502D0(Player* pthis, GlobalContext* globalCtx); +void func_808505DC(Player* pthis, GlobalContext* globalCtx); +void func_8085063C(Player* pthis, GlobalContext* globalCtx); +void func_8085076C(Player* pthis, GlobalContext* globalCtx); +void func_808507F4(Player* pthis, GlobalContext* globalCtx); +void func_80850AEC(Player* pthis, GlobalContext* globalCtx); +void func_80850C68(Player* pthis, GlobalContext* globalCtx); +void func_80850E84(Player* pthis, GlobalContext* globalCtx); +void func_80851008(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851030(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851050(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851094(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808510B4(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808510D4(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808510F4(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851114(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851134(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851154(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851174(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851194(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808511B4(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808511D4(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808511FC(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851248(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_80851294(GlobalContext* globalCtx, Player* pthis, void* anim); +void func_808512E0(GlobalContext* globalCtx, Player* pthis, void* arg2); +void func_80851368(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808513BC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808514C0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_8085157C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808515A4(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851688(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851750(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851788(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851828(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808518DC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_8085190C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851998(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808519C0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808519EC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851A50(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851B90(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851BE8(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851CA4(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851D2C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851D80(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851DEC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851E28(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851E64(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851E90(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851ECC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851F84(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80851FB0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852048(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852080(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852174(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808521B8(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808521F4(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852234(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_8085225C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852280(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852358(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852388(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852298(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852328(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852480(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852450(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808524B0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808524D0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852514(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852544(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852554(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852564(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808525C0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852608(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852648(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808526EC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_8085283C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808528C8(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852944(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_808529D0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852C50(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2); +void func_80852E14(Player* pthis, GlobalContext* globalCtx); +s32 Player_IsDroppingFish(GlobalContext* globalCtx); +s32 Player_StartFishing(GlobalContext* globalCtx); +s32 func_80852F38(GlobalContext* globalCtx, Player* pthis); +s32 func_80852FFC(GlobalContext* globalCtx, Actor* actor, s32 csMode); +void func_80853080(Player* pthis, GlobalContext* globalCtx); +s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage); +void func_80853148(GlobalContext* globalCtx, Actor* actor); + +// .bss part 1 +static s32 D_80858AA0; +static s32 D_80858AA4; +static Vec3f D_80858AA8; +static Input* sControlInput; + +// .data + +static u8 D_80853410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + +static PlayerAgeProperties sAgeProperties[] = { + { + 56.0f, + 90.0f, + 1.0f, + 111.0f, + 70.0f, + 79.4f, + 59.0f, + 41.0f, + 19.0f, + 36.0f, + 44.8f, + 56.0f, + 68.0f, + 70.0f, + 18.0f, + 15.0f, + 70.0f, + { 9, 4671, 359 }, + { + { 8, 4694, 380 }, + { 9, 6122, 359 }, + { 8, 4694, 380 }, + { 9, 6122, 359 }, + }, + { + { 9, 6122, 359 }, + { 9, 7693, 380 }, + { 9, 6122, 359 }, + { 9, 7693, 380 }, + }, + { + { 8, 4694, 380 }, + { 9, 6122, 359 }, + }, + { + { -1592, 4694, 380 }, + { -1591, 6122, 359 }, + }, + 0, + 0x80, + &gPlayerAnim_002718, + &gPlayerAnim_002720, + &gPlayerAnim_002838, + &gPlayerAnim_002E70, + &gPlayerAnim_002E78, + { &gPlayerAnim_002E80, &gPlayerAnim_002E88, &gPlayerAnim_002D90, &gPlayerAnim_002D98 }, + { &gPlayerAnim_002D70, &gPlayerAnim_002D78 }, + { &gPlayerAnim_002E50, &gPlayerAnim_002E58 }, + { &gPlayerAnim_002E68, &gPlayerAnim_002E60 }, + }, + { + 40.0f, + 60.0f, + 11.0f / 17.0f, + 71.0f, + 50.0f, + 47.0f, + 39.0f, + 27.0f, + 19.0f, + 22.0f, + 29.6f, + 32.0f, + 48.0f, + 70.0f * (11.0f / 17.0f), + 14.0f, + 12.0f, + 55.0f, + { -24, 3565, 876 }, + { + { -24, 3474, 862 }, + { -24, 4977, 937 }, + { 8, 4694, 380 }, + { 9, 6122, 359 }, + }, + { + { -24, 4977, 937 }, + { -24, 6495, 937 }, + { 9, 6122, 359 }, + { 9, 7693, 380 }, + }, + { + { 8, 4694, 380 }, + { 9, 6122, 359 }, + }, + { + { -1592, 4694, 380 }, + { -1591, 6122, 359 }, + }, + 0x20, + 0, + &gPlayerAnim_002318, + &gPlayerAnim_002360, + &gPlayerAnim_0023A8, + &gPlayerAnim_0023E0, + &gPlayerAnim_0023E8, + { &gPlayerAnim_0023F0, &gPlayerAnim_0023F8, &gPlayerAnim_002D90, &gPlayerAnim_002D98 }, + { &gPlayerAnim_002D70, &gPlayerAnim_002D78 }, + { &gPlayerAnim_0023C0, &gPlayerAnim_0023C8 }, + { &gPlayerAnim_0023D8, &gPlayerAnim_0023D0 }, + }, +}; + +static u32 D_808535D0 = false; +static f32 D_808535D4 = 0.0f; +static s16 D_808535D8 = 0; +static s16 D_808535DC = 0; +static s32 D_808535E0 = 0; +static s32 D_808535E4 = 0; +static f32 D_808535E8 = 1.0f; +static f32 D_808535EC = 1.0f; +static u32 D_808535F0 = 0; +static u32 D_808535F4 = 0; +static s16 D_808535F8 = 0; +static s16 D_808535FC = 0; +static f32 D_80853600 = 0.0f; +static s32 D_80853604 = 0; +static s32 D_80853608 = 0; +static s32 D_8085360C = 0; +static s16 D_80853610 = 0; +static s32 D_80853614 = 0; +static s32 D_80853618 = 0; + +static u16 D_8085361C[] = { + NA_SE_VO_LI_SWEAT, + NA_SE_VO_LI_SNEEZE, + NA_SE_VO_LI_RELAX, + NA_SE_VO_LI_FALL_L, +}; + +static GetItemEntry sGetItemTable[] = { + GET_ITEM(ITEM_BOMBS_5, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMBCHU, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOW, OBJECT_GI_BOW, GID_BOW, 0x31, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SLINGSHOT, OBJECT_GI_PACHINKO, GID_SLINGSHOT, 0x30, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOOMERANG, OBJECT_GI_BOOMERANG, GID_BOOMERANG, 0x35, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_STICK, OBJECT_GI_STICK, GID_STICK, 0x37, 0x0D, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_HOOKSHOT, OBJECT_GI_HOOKSHOT, GID_HOOKSHOT, 0x36, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_LONGSHOT, OBJECT_GI_HOOKSHOT, GID_LONGSHOT, 0x4F, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_LENS, OBJECT_GI_GLASSES, GID_LENS, 0x39, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_LETTER_ZELDA, OBJECT_GI_LETTER, GID_LETTER_ZELDA, 0x69, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_OCARINA_TIME, OBJECT_GI_OCARINA, GID_OCARINA_TIME, 0x3A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_HAMMER, OBJECT_GI_HAMMER, GID_HAMMER, 0x38, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_COJIRO, OBJECT_GI_NIWATORI, GID_COJIRO, 0x02, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x42, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_POTION_RED, OBJECT_GI_LIQUID, GID_POTION_RED, 0x43, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_POTION_GREEN, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0x44, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_POTION_BLUE, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0x45, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x46, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MILK_BOTTLE, OBJECT_GI_MILK, GID_MILK, 0x98, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_LETTER_RUTO, OBJECT_GI_BOTTLE_LETTER, GID_LETTER_RUTO, 0x99, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BEAN, OBJECT_GI_BEAN, GID_BEAN, 0x48, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_MASK_SKULL, OBJECT_GI_SKJ_MASK, GID_MASK_SKULL, 0x10, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_SPOOKY, OBJECT_GI_REDEAD_MASK, GID_MASK_SPOOKY, 0x11, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_CHICKEN, OBJECT_GI_NIWATORI, GID_CHICKEN, 0x48, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_KEATON, OBJECT_GI_KI_TAN_MASK, GID_MASK_KEATON, 0x12, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_BUNNY, OBJECT_GI_RABIT_MASK, GID_MASK_BUNNY, 0x13, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_TRUTH, OBJECT_GI_TRUTH_MASK, GID_MASK_TRUTH, 0x17, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_POCKET_EGG, OBJECT_GI_EGG, GID_EGG, 0x01, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_POCKET_CUCCO, OBJECT_GI_NIWATORI, GID_CHICKEN, 0x48, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_ODD_MUSHROOM, OBJECT_GI_MUSHROOM, GID_ODD_MUSHROOM, 0x03, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_ODD_POTION, OBJECT_GI_POWDER, GID_ODD_POTION, 0x04, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SAW, OBJECT_GI_SAW, GID_SAW, 0x05, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SWORD_BROKEN, OBJECT_GI_BROKENSWORD, GID_SWORD_BROKEN, 0x08, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_PRESCRIPTION, OBJECT_GI_PRESCRIPTION, GID_PRESCRIPTION, 0x09, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_FROG, OBJECT_GI_FROG, GID_FROG, 0x0D, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_EYEDROPS, OBJECT_GI_EYE_LOTION, GID_EYEDROPS, 0x0E, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_CLAIM_CHECK, OBJECT_GI_TICKETSTONE, GID_CLAIM_CHECK, 0x0A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SWORD_KOKIRI, OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, 0xA4, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x4B, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SHIELD_DEKU, OBJECT_GI_SHIELD_1, GID_SHIELD_DEKU, 0x4C, 0xA0, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_SHIELD_HYLIAN, OBJECT_GI_SHIELD_2, GID_SHIELD_HYLIAN, 0x4D, 0xA0, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_SHIELD_MIRROR, OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, 0x4E, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_TUNIC_GORON, OBJECT_GI_CLOTHES, GID_TUNIC_GORON, 0x50, 0xA0, CHEST_ANIM_LONG), + GET_ITEM(ITEM_TUNIC_ZORA, OBJECT_GI_CLOTHES, GID_TUNIC_ZORA, 0x51, 0xA0, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOOTS_IRON, OBJECT_GI_BOOTS_2, GID_BOOTS_IRON, 0x53, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOOTS_HOVER, OBJECT_GI_HOVERBOOTS, GID_BOOTS_HOVER, 0x54, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_QUIVER_40, OBJECT_GI_ARROWCASE, GID_QUIVER_40, 0x56, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_QUIVER_50, OBJECT_GI_ARROWCASE, GID_QUIVER_50, 0x57, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOMB_BAG_20, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, 0x58, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOMB_BAG_30, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, 0x59, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOMB_BAG_40, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, 0x5A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_GAUNTLETS_SILVER, OBJECT_GI_GLOVES, GID_GAUNTLETS_SILVER, 0x5B, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_GAUNTLETS_GOLD, OBJECT_GI_GLOVES, GID_GAUNTLETS_GOLD, 0x5C, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SCALE_SILVER, OBJECT_GI_SCALE, GID_SCALE_SILVER, 0xCD, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SCALE_GOLDEN, OBJECT_GI_SCALE, GID_SCALE_GOLDEN, 0xCE, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_STONE_OF_AGONY, OBJECT_GI_MAP, GID_STONE_OF_AGONY, 0x68, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_GERUDO_CARD, OBJECT_GI_GERUDO, GID_GERUDO_CARD, 0x7B, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_OCARINA_FAIRY, OBJECT_GI_OCARINA_0, GID_OCARINA_FAIRY, 0x3A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SEEDS, OBJECT_GI_SEED, GID_SEEDS, 0xDC, 0x50, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_HEART_CONTAINER, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xC6, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_HEART_PIECE_2, OBJECT_GI_HEARTS, GID_HEART_PIECE, 0xC2, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_KEY_BOSS, OBJECT_GI_BOSSKEY, GID_KEY_BOSS, 0xC7, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_COMPASS, OBJECT_GI_COMPASS, GID_COMPASS, 0x67, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_DUNGEON_MAP, OBJECT_GI_MAP, GID_DUNGEON_MAP, 0x66, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_KEY_SMALL, OBJECT_GI_KEY, GID_KEY_SMALL, 0x60, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_MAGIC_SMALL, OBJECT_GI_MAGICPOT, GID_MAGIC_SMALL, 0x52, 0x6F, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_MAGIC_LARGE, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0x52, 0x6E, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_WALLET_ADULT, OBJECT_GI_PURSE, GID_WALLET_ADULT, 0x5E, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_WALLET_GIANT, OBJECT_GI_PURSE, GID_WALLET_GIANT, 0x5F, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_WEIRD_EGG, OBJECT_GI_EGG, GID_EGG, 0x9A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_HEART, OBJECT_GI_HEART, GID_HEART, 0x55, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_ARROWS_SMALL, OBJECT_GI_ARROW, GID_ARROWS_SMALL, 0xE6, 0x48, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_ARROWS_MEDIUM, OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, 0xE6, 0x49, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_ARROWS_LARGE, OBJECT_GI_ARROW, GID_ARROWS_LARGE, 0xE6, 0x4A, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_GREEN, OBJECT_GI_RUPY, GID_RUPEE_GREEN, 0x6F, 0x00, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_BLUE, OBJECT_GI_RUPY, GID_RUPEE_BLUE, 0xCC, 0x01, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_RED, OBJECT_GI_RUPY, GID_RUPEE_RED, 0xF0, 0x02, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_HEART_CONTAINER, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xC6, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MILK, OBJECT_GI_MILK, GID_MILK, 0x98, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_GORON, OBJECT_GI_GOLONMASK, GID_MASK_GORON, 0x14, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_ZORA, OBJECT_GI_ZORAMASK, GID_MASK_ZORA, 0x15, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_MASK_GERUDO, OBJECT_GI_GERUDOMASK, GID_MASK_GERUDO, 0x16, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BRACELET, OBJECT_GI_BRACELET, GID_BRACELET, 0x79, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_RUPEE_PURPLE, OBJECT_GI_RUPY, GID_RUPEE_PURPLE, 0xF1, 0x14, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_GOLD, OBJECT_GI_RUPY, GID_RUPEE_GOLD, 0xF2, 0x13, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x0C, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_ARROW_FIRE, OBJECT_GI_M_ARROW, GID_ARROW_FIRE, 0x70, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_ARROW_ICE, OBJECT_GI_M_ARROW, GID_ARROW_ICE, 0x71, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_ARROW_LIGHT, OBJECT_GI_M_ARROW, GID_ARROW_LIGHT, 0x72, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_SKULL_TOKEN, OBJECT_GI_SUTARU, GID_SKULL_TOKEN, 0xB4, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_DINS_FIRE, OBJECT_GI_GODDESS, GID_DINS_FIRE, 0xAD, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_FARORES_WIND, OBJECT_GI_GODDESS, GID_FARORES_WIND, 0xAE, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_NAYRUS_LOVE, OBJECT_GI_GODDESS, GID_NAYRUS_LOVE, 0xAF, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BULLET_BAG_30, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG, 0x07, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BULLET_BAG_40, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG, 0x07, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_STICKS_5, OBJECT_GI_STICK, GID_STICK, 0x37, 0x0D, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_STICKS_10, OBJECT_GI_STICK, GID_STICK, 0x37, 0x0D, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_NUTS_10, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMB, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMBS_10, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMBS_20, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMBS_30, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_SEEDS_30, OBJECT_GI_SEED, GID_SEEDS, 0xDC, 0x50, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMBCHUS_5, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BOMBCHUS_20, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_FISH, OBJECT_GI_FISH, GID_FISH, 0x47, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BUG, OBJECT_GI_INSECT, GID_BUG, 0x7A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0x5D, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_POE, OBJECT_GI_GHOST, GID_POE, 0x97, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF9, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_KEY_SMALL, OBJECT_GI_KEY, GID_KEY_SMALL, 0xF3, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_GREEN, OBJECT_GI_RUPY, GID_RUPEE_GREEN, 0xF4, 0x00, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_BLUE, OBJECT_GI_RUPY, GID_RUPEE_BLUE, 0xF5, 0x01, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_RED, OBJECT_GI_RUPY, GID_RUPEE_RED, 0xF6, 0x02, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_RUPEE_PURPLE, OBJECT_GI_RUPY, GID_RUPEE_PURPLE, 0xF7, 0x14, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_HEART_PIECE_2, OBJECT_GI_HEARTS, GID_HEART_PIECE, 0xFA, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_STICK_UPGRADE_20, OBJECT_GI_STICK, GID_STICK, 0x90, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_STICK_UPGRADE_30, OBJECT_GI_STICK, GID_STICK, 0x91, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_NUT_UPGRADE_30, OBJECT_GI_NUTS, GID_NUTS, 0xA7, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_NUT_UPGRADE_40, OBJECT_GI_NUTS, GID_NUTS, 0xA8, 0x80, CHEST_ANIM_SHORT), + GET_ITEM(ITEM_BULLET_BAG_50, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG_50, 0x6C, 0x80, CHEST_ANIM_LONG), + GET_ITEM_NONE, + GET_ITEM_NONE, +}; + +static LinkAnimationHeader* D_80853914[] = { + &gPlayerAnim_003240, &gPlayerAnim_003238, &gPlayerAnim_003238, + &gPlayerAnim_002BE0, &gPlayerAnim_003240, &gPlayerAnim_003240, +}; + +static LinkAnimationHeader* D_8085392C[] = { + &gPlayerAnim_003290, &gPlayerAnim_003268, &gPlayerAnim_003268, + &gPlayerAnim_002BF8, &gPlayerAnim_003290, &gPlayerAnim_003290, +}; + +static LinkAnimationHeader* D_80853944[] = { + &gPlayerAnim_003140, &gPlayerAnim_002B38, &gPlayerAnim_003138, + &gPlayerAnim_002B40, &gPlayerAnim_003140, &gPlayerAnim_003140, +}; + +static LinkAnimationHeader* D_8085395C[] = { + &gPlayerAnim_002E98, &gPlayerAnim_0029E8, &gPlayerAnim_002E98, + &gPlayerAnim_0029F0, &gPlayerAnim_002E98, &gPlayerAnim_002E98, +}; + +static LinkAnimationHeader* D_80853974[] = { + &gPlayerAnim_002FB0, &gPlayerAnim_002FA8, &gPlayerAnim_002FB0, + &gPlayerAnim_002A40, &gPlayerAnim_002FB0, &gPlayerAnim_002FB0, +}; + +static LinkAnimationHeader* D_8085398C[] = { + &gPlayerAnim_003220, &gPlayerAnim_002590, &gPlayerAnim_002590, + &gPlayerAnim_002BC0, &gPlayerAnim_003220, &gPlayerAnim_003220, +}; + +static LinkAnimationHeader* D_808539A4[] = { + &gPlayerAnim_003230, &gPlayerAnim_0025D0, &gPlayerAnim_0025D0, + &gPlayerAnim_002BD0, &gPlayerAnim_003230, &gPlayerAnim_003230, +}; + +static LinkAnimationHeader* D_808539BC[] = { + &gPlayerAnim_002BB0, &gPlayerAnim_0031F8, &gPlayerAnim_0031F8, + &gPlayerAnim_002BB0, &gPlayerAnim_002BB0, &gPlayerAnim_002BB0, +}; + +static LinkAnimationHeader* D_808539D4[] = { + &gPlayerAnim_003088, &gPlayerAnim_002A70, &gPlayerAnim_002A70, + &gPlayerAnim_003088, &gPlayerAnim_003088, &gPlayerAnim_003088, +}; + +static LinkAnimationHeader* D_808539EC[] = { + &gPlayerAnim_002750, &gPlayerAnim_002748, &gPlayerAnim_002748, + &gPlayerAnim_002750, &gPlayerAnim_002750, &gPlayerAnim_002750, +}; + +static LinkAnimationHeader* D_80853A04[] = { + &gPlayerAnim_002330, &gPlayerAnim_002330, &gPlayerAnim_002330, + &gPlayerAnim_002330, &gPlayerAnim_002330, &gPlayerAnim_002330, +}; + +static LinkAnimationHeader* D_80853A1C[] = { + &gPlayerAnim_002760, &gPlayerAnim_002758, &gPlayerAnim_002758, + &gPlayerAnim_002760, &gPlayerAnim_002760, &gPlayerAnim_002760, +}; + +static LinkAnimationHeader* D_80853A34[] = { + &gPlayerAnim_002338, &gPlayerAnim_002338, &gPlayerAnim_002338, + &gPlayerAnim_002338, &gPlayerAnim_002338, &gPlayerAnim_002338, +}; + +static LinkAnimationHeader* D_80853A4C[] = { + &gPlayerAnim_002E08, &gPlayerAnim_002E00, &gPlayerAnim_002E00, + &gPlayerAnim_002E08, &gPlayerAnim_002E08, &gPlayerAnim_002E08, +}; + +static LinkAnimationHeader* D_80853A64[] = { + &gPlayerAnim_003028, &gPlayerAnim_003020, &gPlayerAnim_003020, + &gPlayerAnim_003028, &gPlayerAnim_003028, &gPlayerAnim_003028, +}; + +static LinkAnimationHeader* D_80853A7C[] = { + &gPlayerAnim_003170, &gPlayerAnim_003168, &gPlayerAnim_003168, + &gPlayerAnim_003170, &gPlayerAnim_003170, &gPlayerAnim_003170, +}; + +static LinkAnimationHeader* D_80853A94[] = { + &gPlayerAnim_003038, &gPlayerAnim_003030, &gPlayerAnim_003030, + &gPlayerAnim_002A68, &gPlayerAnim_003038, &gPlayerAnim_003038, +}; + +static LinkAnimationHeader* D_80853AAC[] = { + &gPlayerAnim_002FC0, &gPlayerAnim_002FB8, &gPlayerAnim_002FB8, + &gPlayerAnim_002FC8, &gPlayerAnim_002FC0, &gPlayerAnim_002FC0, +}; + +static LinkAnimationHeader* D_80853AC4[] = { + &gPlayerAnim_003278, &gPlayerAnim_003270, &gPlayerAnim_003270, + &gPlayerAnim_002BE8, &gPlayerAnim_003278, &gPlayerAnim_003278, +}; + +static LinkAnimationHeader* D_80853ADC[] = { + &gPlayerAnim_003288, &gPlayerAnim_003280, &gPlayerAnim_003280, + &gPlayerAnim_002BF0, &gPlayerAnim_003288, &gPlayerAnim_003288, +}; + +static LinkAnimationHeader* D_80853AF4[] = { + &gPlayerAnim_002EB8, &gPlayerAnim_002EA0, &gPlayerAnim_002EA0, + &gPlayerAnim_002EB8, &gPlayerAnim_0026C8, &gPlayerAnim_002EB8, +}; + +static LinkAnimationHeader* D_80853B0C[] = { + &gPlayerAnim_002ED8, &gPlayerAnim_002ED0, &gPlayerAnim_002ED0, + &gPlayerAnim_002ED8, &gPlayerAnim_0026D0, &gPlayerAnim_002ED8, +}; + +static LinkAnimationHeader* D_80853B24[] = { + &gPlayerAnim_002EB0, &gPlayerAnim_002EA8, &gPlayerAnim_002EA8, + &gPlayerAnim_002EB0, &gPlayerAnim_002EB0, &gPlayerAnim_002EB0, +}; + +static LinkAnimationHeader* D_80853B3C[] = { + &gPlayerAnim_003190, &gPlayerAnim_003188, &gPlayerAnim_003188, + &gPlayerAnim_002B68, &gPlayerAnim_003190, &gPlayerAnim_003190, +}; + +static LinkAnimationHeader* D_80853B54[] = { + &gPlayerAnim_003178, &gPlayerAnim_002568, &gPlayerAnim_002568, + &gPlayerAnim_002B58, &gPlayerAnim_003178, &gPlayerAnim_003178, +}; + +static LinkAnimationHeader* D_80853B6C[] = { + &gPlayerAnim_003180, &gPlayerAnim_002570, &gPlayerAnim_002570, + &gPlayerAnim_002B60, &gPlayerAnim_003180, &gPlayerAnim_003180, +}; + +static LinkAnimationHeader* D_80853B84[] = { + &gPlayerAnim_002D60, &gPlayerAnim_002D58, &gPlayerAnim_002D58, + &gPlayerAnim_002D60, &gPlayerAnim_002D60, &gPlayerAnim_002D60, +}; + +static LinkAnimationHeader* D_80853B9C[] = { + &gPlayerAnim_002BB8, &gPlayerAnim_003218, &gPlayerAnim_003218, + &gPlayerAnim_002BB8, &gPlayerAnim_002BB8, &gPlayerAnim_002BB8, +}; + +static LinkAnimationHeader* D_80853BB4[] = { + &gPlayerAnim_002BC8, &gPlayerAnim_003228, &gPlayerAnim_003228, + &gPlayerAnim_002BC8, &gPlayerAnim_002BC8, &gPlayerAnim_002BC8, +}; + +static LinkAnimationHeader* D_80853BCC[] = { + &gPlayerAnim_0031C8, &gPlayerAnim_0031C0, &gPlayerAnim_0031C0, + &gPlayerAnim_0031C8, &gPlayerAnim_0031C8, &gPlayerAnim_0031C8, +}; + +static LinkAnimationHeader* D_80853BE4[] = { + &gPlayerAnim_003118, &gPlayerAnim_003110, &gPlayerAnim_003110, + &gPlayerAnim_003118, &gPlayerAnim_003118, &gPlayerAnim_003118, +}; + +static LinkAnimationHeader* D_80853BFC[] = { + &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, + &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, &gPlayerAnim_002DE8, +}; + +static LinkAnimationHeader* D_80853C14[] = { + &gPlayerAnim_002E30, &gPlayerAnim_002E18, &gPlayerAnim_002E18, + &gPlayerAnim_002E30, &gPlayerAnim_002E30, &gPlayerAnim_002E30, +}; + +static LinkAnimationHeader* D_80853C2C[] = { + &gPlayerAnim_002E40, &gPlayerAnim_002E38, &gPlayerAnim_002E38, + &gPlayerAnim_002E40, &gPlayerAnim_002E40, &gPlayerAnim_002E40, +}; + +static LinkAnimationHeader* D_80853C44[] = { + &gPlayerAnim_002E28, &gPlayerAnim_002E20, &gPlayerAnim_002E20, + &gPlayerAnim_002E28, &gPlayerAnim_002E28, &gPlayerAnim_002E28, +}; + +static LinkAnimationHeader* D_80853C5C[] = { + &gPlayerAnim_0030C8, &gPlayerAnim_0030C0, &gPlayerAnim_0030C0, + &gPlayerAnim_0030C8, &gPlayerAnim_0030C8, &gPlayerAnim_0030C8, +}; + +static LinkAnimationHeader* D_80853C74[] = { + &gPlayerAnim_0030D8, &gPlayerAnim_0030D0, &gPlayerAnim_0030D0, + &gPlayerAnim_0030D8, &gPlayerAnim_0030D8, &gPlayerAnim_0030D8, +}; + +static LinkAnimationHeader* D_80853C8C[] = { + &gPlayerAnim_0030B8, &gPlayerAnim_0030B0, &gPlayerAnim_0030B0, + &gPlayerAnim_0030B8, &gPlayerAnim_0030B8, &gPlayerAnim_0030B8, +}; + +static LinkAnimationHeader* D_80853CA4[] = { + &gPlayerAnim_002F20, &gPlayerAnim_002F18, &gPlayerAnim_002F18, + &gPlayerAnim_002F20, &gPlayerAnim_002F20, &gPlayerAnim_002F20, +}; + +static LinkAnimationHeader* D_80853CBC[] = { + &gPlayerAnim_002FF0, &gPlayerAnim_002FE8, &gPlayerAnim_002FE8, + &gPlayerAnim_002FF0, &gPlayerAnim_002FF0, &gPlayerAnim_002FF0, +}; + +static LinkAnimationHeader* D_80853CD4[] = { + &gPlayerAnim_003010, &gPlayerAnim_003008, &gPlayerAnim_003008, + &gPlayerAnim_003010, &gPlayerAnim_003010, &gPlayerAnim_003010, +}; + +static LinkAnimationHeader* D_80853CEC[] = { + &gPlayerAnim_003000, &gPlayerAnim_002FF8, &gPlayerAnim_002FF8, + &gPlayerAnim_003000, &gPlayerAnim_003000, &gPlayerAnim_003000, +}; + +static LinkAnimationHeader* D_80853D04[] = { + &gPlayerAnim_002EF0, &gPlayerAnim_002EE8, &gPlayerAnim_002EE8, + &gPlayerAnim_002EF8, &gPlayerAnim_002EF0, &gPlayerAnim_002EF0, +}; + +static LinkAnimationHeader* D_80853D1C[] = { + &gPlayerAnim_0031E0, &gPlayerAnim_0031D8, &gPlayerAnim_0031D8, + &gPlayerAnim_0031E8, &gPlayerAnim_0031E0, &gPlayerAnim_0031E0, +}; + +static LinkAnimationHeader* D_80853D34[] = { + &gPlayerAnim_003468, &gPlayerAnim_003438, &gPlayerAnim_003438, + &gPlayerAnim_003468, &gPlayerAnim_003468, &gPlayerAnim_003468, +}; + +static LinkAnimationHeader* D_80853D4C[][3] = { + { &gPlayerAnim_002A28, &gPlayerAnim_002A38, &gPlayerAnim_002A30 }, + { &gPlayerAnim_002950, &gPlayerAnim_002960, &gPlayerAnim_002958 }, + { &gPlayerAnim_0029D0, &gPlayerAnim_0029E0, &gPlayerAnim_0029D8 }, + { &gPlayerAnim_002988, &gPlayerAnim_002998, &gPlayerAnim_002990 }, +}; + +static LinkAnimationHeader* D_80853D7C[][2] = { + { &gPlayerAnim_003248, &gPlayerAnim_003200 }, { &gPlayerAnim_003258, &gPlayerAnim_003210 }, + { &gPlayerAnim_003250, &gPlayerAnim_003208 }, { &gPlayerAnim_003250, &gPlayerAnim_003208 }, + { &gPlayerAnim_003430, &gPlayerAnim_0033F0 }, { &gPlayerAnim_003430, &gPlayerAnim_0033F0 }, + { &gPlayerAnim_003430, &gPlayerAnim_0033F0 }, { &gPlayerAnim_0033F8, &gPlayerAnim_0033D0 }, + { &gPlayerAnim_003400, &gPlayerAnim_0033D8 }, { &gPlayerAnim_003420, &gPlayerAnim_003420 }, + { &gPlayerAnim_003408, &gPlayerAnim_0033E0 }, { &gPlayerAnim_003410, &gPlayerAnim_0033E8 }, + { &gPlayerAnim_003418, &gPlayerAnim_003418 }, { &gPlayerAnim_003428, &gPlayerAnim_003428 } +}; + +static LinkAnimationHeader** AnimHeaderLut[] = { + D_80853914,D_8085392C,D_80853944,D_8085395C,D_80853974,D_8085398C,D_808539A4,D_808539BC, + D_808539D4,D_808539EC,D_80853A04,D_80853A1C,D_80853A34,D_80853A4C,D_80853A64,D_80853A7C, + D_80853A94,D_80853AAC,D_80853AC4,D_80853ADC,D_80853AF4,D_80853B0C,D_80853B24,D_80853B3C, + D_80853B54,D_80853B6C,D_80853B84,D_80853B9C,D_80853BB4,D_80853BCC,D_80853BE4,D_80853BFC, + D_80853C14,D_80853C2C,D_80853C44,D_80853C5C,D_80853C74,D_80853C8C,D_80853CA4,D_80853CBC, + D_80853CD4,D_80853CEC,D_80853D04,D_80853D1C,D_80853D34, + (LinkAnimationHeader**)D_80853D4C,(LinkAnimationHeader**)D_80853D7C, // are these last two an error? +}; + +static struct_80832924 D_80853DEC[] = { + { NA_SE_VO_LI_SNEEZE, -0x2008 }, +}; + +static struct_80832924 D_80853DF0[] = { + { NA_SE_VO_LI_SWEAT, -0x2012 }, +}; + +static struct_80832924 D_80853DF4[] = { + { NA_SE_VO_LI_BREATH_REST, -0x200D }, +}; + +static struct_80832924 D_80853DF8[] = { + { NA_SE_VO_LI_BREATH_REST, -0x200A }, +}; + +static struct_80832924 D_80853DFC[] = { + { NA_SE_PL_CALM_HIT, 0x82C }, { NA_SE_PL_CALM_HIT, 0x830 }, { NA_SE_PL_CALM_HIT, 0x834 }, + { NA_SE_PL_CALM_HIT, 0x838 }, { NA_SE_PL_CALM_HIT, -0x83C }, +}; + +static struct_80832924 D_80853E10[] = { + { 0, 0x4019 }, { 0, 0x401E }, { 0, 0x402C }, { 0, 0x4030 }, { 0, 0x4034 }, { 0, -0x4038 }, +}; + +static struct_80832924 D_80853E28[] = { + { NA_SE_IT_SHIELD_POSTURE, 0x810 }, + { NA_SE_IT_SHIELD_POSTURE, 0x814 }, + { NA_SE_IT_SHIELD_POSTURE, -0x846 }, +}; + +static struct_80832924 D_80853E34[] = { + { NA_SE_IT_HAMMER_SWING, 0x80A }, + { NA_SE_VO_LI_AUTO_JUMP, 0x200A }, + { NA_SE_IT_SWORD_SWING, 0x816 }, + { NA_SE_VO_LI_SWORD_N, -0x2016 }, +}; + +static struct_80832924 D_80853E44[] = { + { NA_SE_IT_SWORD_SWING, 0x827 }, + { NA_SE_VO_LI_SWORD_N, -0x2027 }, +}; + +static struct_80832924 D_80853E4C[] = { + { NA_SE_VO_LI_RELAX, -0x2014 }, +}; + +static struct_80832924* D_80853E50[] = { + D_80853DEC, D_80853DF0, D_80853DF4, D_80853DF8, D_80853DFC, D_80853E10, + D_80853E28, D_80853E34, D_80853E44, D_80853E4C, NULL, +}; + +static u8 D_80853E7C[] = { + 0, 0, 1, 1, 2, 2, 2, 2, 10, 10, 10, 10, 10, 10, 3, 3, 4, 4, 8, 8, 5, 5, 6, 6, 7, 7, 9, 9, 0, +}; + +// Used to map item IDs to action params +static s8 sItemActionParams[] = { + PLAYER_AP_STICK, + PLAYER_AP_NUT, + PLAYER_AP_BOMB, + PLAYER_AP_BOW, + PLAYER_AP_BOW_FIRE, + PLAYER_AP_DINS_FIRE, + PLAYER_AP_SLINGSHOT, + PLAYER_AP_OCARINA_FAIRY, + PLAYER_AP_OCARINA_TIME, + PLAYER_AP_BOMBCHU, + PLAYER_AP_HOOKSHOT, + PLAYER_AP_LONGSHOT, + PLAYER_AP_BOW_ICE, + PLAYER_AP_FARORES_WIND, + PLAYER_AP_BOOMERANG, + PLAYER_AP_LENS, + PLAYER_AP_BEAN, + PLAYER_AP_HAMMER, + PLAYER_AP_BOW_LIGHT, + PLAYER_AP_NAYRUS_LOVE, + PLAYER_AP_BOTTLE, + PLAYER_AP_BOTTLE_POTION_RED, + PLAYER_AP_BOTTLE_POTION_GREEN, + PLAYER_AP_BOTTLE_POTION_BLUE, + PLAYER_AP_BOTTLE_FAIRY, + PLAYER_AP_BOTTLE_FISH, + PLAYER_AP_BOTTLE_MILK, + PLAYER_AP_BOTTLE_LETTER, + PLAYER_AP_BOTTLE_FIRE, + PLAYER_AP_BOTTLE_BUG, + PLAYER_AP_BOTTLE_BIG_POE, + PLAYER_AP_BOTTLE_MILK_HALF, + PLAYER_AP_BOTTLE_POE, + PLAYER_AP_WEIRD_EGG, + PLAYER_AP_CHICKEN, + PLAYER_AP_LETTER_ZELDA, + PLAYER_AP_MASK_KEATON, + PLAYER_AP_MASK_SKULL, + PLAYER_AP_MASK_SPOOKY, + PLAYER_AP_MASK_BUNNY, + PLAYER_AP_MASK_GORON, + PLAYER_AP_MASK_ZORA, + PLAYER_AP_MASK_GERUDO, + PLAYER_AP_MASK_TRUTH, + PLAYER_AP_SWORD_MASTER, + PLAYER_AP_POCKET_EGG, + PLAYER_AP_POCKET_CUCCO, + PLAYER_AP_COJIRO, + PLAYER_AP_ODD_MUSHROOM, + PLAYER_AP_ODD_POTION, + PLAYER_AP_SAW, + PLAYER_AP_SWORD_BROKEN, + PLAYER_AP_PRESCRIPTION, + PLAYER_AP_FROG, + PLAYER_AP_EYEDROPS, + PLAYER_AP_CLAIM_CHECK, + PLAYER_AP_BOW_FIRE, + PLAYER_AP_BOW_ICE, + PLAYER_AP_BOW_LIGHT, + PLAYER_AP_SWORD_KOKIRI, + PLAYER_AP_SWORD_MASTER, + PLAYER_AP_SWORD_BGS, +}; + +static s32 (*D_80853EDC[])(Player* pthis, GlobalContext* globalCtx) = { + func_8083485C, func_8083485C, func_8083485C, func_808349DC, func_808349DC, func_808349DC, func_8083485C, + func_8083485C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, + func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_808356E8, func_808356E8, func_80835800, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, func_8083485C, + func_8083485C, func_8083485C, func_8083485C, func_8083485C, +}; + +static void (*D_80853FE8[])(GlobalContext* globalCtx, Player* pthis) = { + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_8083377C, + func_80833790, func_8083379C, func_8083379C, func_8083379C, func_8083379C, func_8083379C, func_8083379C, + func_8083379C, func_8083379C, func_80833910, func_80833910, func_808337D4, func_808337D4, func_80833984, + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, + func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, func_80833770, + func_80833770, func_80833770, func_80833770, func_80833770, +}; + +static struct_808540F4 D_808540F4[] = { + { &gPlayerAnim_002F50, 12 }, { &gPlayerAnim_003080, 6 }, { &gPlayerAnim_002C68, 8 }, { &gPlayerAnim_003090, 8 }, + { &gPlayerAnim_002A20, 8 }, { &gPlayerAnim_002F30, 10 }, { &gPlayerAnim_002C58, 7 }, { &gPlayerAnim_002C60, 11 }, + { &gPlayerAnim_002F50, 12 }, { &gPlayerAnim_003078, 4 }, { &gPlayerAnim_003058, 4 }, { &gPlayerAnim_002F38, 4 }, + { &gPlayerAnim_0024E0, 5 }, { &gPlayerAnim_002F48, 13 }, +}; + +static s8 D_80854164[][6] = { + { 8, -5, -3, -6, 8, 11 }, { 5, 0, -1, 4, 5, 9 }, { 3, 1, 0, 2, 3, 9 }, + { 6, -4, -2, 7, 6, 10 }, { 8, -5, -3, -6, 8, 11 }, { 8, -5, -3, -6, 8, 11 }, +}; + +static ExplosiveInfo sExplosiveInfos[] = { + { ITEM_BOMB, ACTOR_EN_BOM }, + { ITEM_BOMBCHU, ACTOR_EN_BOM_CHU }, +}; + +static struct_80854190 D_80854190[] = { + { &gPlayerAnim_002A80, &gPlayerAnim_002A90, &gPlayerAnim_002A88, 1, 4 }, + { &gPlayerAnim_0028C0, &gPlayerAnim_0028C8, &gPlayerAnim_002498, 1, 4 }, + { &gPlayerAnim_002A98, &gPlayerAnim_002AA0, &gPlayerAnim_002540, 0, 5 }, + { &gPlayerAnim_0028D0, &gPlayerAnim_0028D8, &gPlayerAnim_0024A0, 1, 7 }, + { &gPlayerAnim_002968, &gPlayerAnim_002970, &gPlayerAnim_0024C0, 1, 4 }, + { &gPlayerAnim_002880, &gPlayerAnim_002888, &gPlayerAnim_002478, 0, 5 }, + { &gPlayerAnim_002978, &gPlayerAnim_002980, &gPlayerAnim_0024C8, 2, 8 }, + { &gPlayerAnim_002890, &gPlayerAnim_002898, &gPlayerAnim_002480, 3, 8 }, + { &gPlayerAnim_0029A0, &gPlayerAnim_0029A8, &gPlayerAnim_0024D0, 0, 4 }, + { &gPlayerAnim_0028A0, &gPlayerAnim_0028A8, &gPlayerAnim_002488, 0, 5 }, + { &gPlayerAnim_0029B0, &gPlayerAnim_0029B8, &gPlayerAnim_0024D8, 0, 6 }, + { &gPlayerAnim_0028B0, &gPlayerAnim_0028B8, &gPlayerAnim_002490, 1, 5 }, + { &gPlayerAnim_002AA8, &gPlayerAnim_002AB0, &gPlayerAnim_002548, 0, 3 }, + { &gPlayerAnim_0028E0, &gPlayerAnim_0028E8, &gPlayerAnim_0024A8, 0, 3 }, + { &gPlayerAnim_002AB8, &gPlayerAnim_002AC0, &gPlayerAnim_002550, 1, 9 }, + { &gPlayerAnim_0028F0, &gPlayerAnim_0028F8, &gPlayerAnim_0024B0, 1, 8 }, + { &gPlayerAnim_002A60, &gPlayerAnim_002A50, &gPlayerAnim_002A50, 1, 10 }, + { &gPlayerAnim_002900, &gPlayerAnim_002910, &gPlayerAnim_002910, 1, 11 }, + { &gPlayerAnim_002A50, &gPlayerAnim_002A58, &gPlayerAnim_002A58, 1, 2 }, + { &gPlayerAnim_002910, &gPlayerAnim_002908, &gPlayerAnim_002908, 1, 2 }, + { &gPlayerAnim_002B80, &gPlayerAnim_002B88, &gPlayerAnim_002B88, 1, 5 }, + { &gPlayerAnim_002B70, &gPlayerAnim_002B78, &gPlayerAnim_002B78, 1, 4 }, + { &gPlayerAnim_002C40, &gPlayerAnim_002C50, &gPlayerAnim_002C48, 3, 10 }, + { &gPlayerAnim_002C70, &gPlayerAnim_002C80, &gPlayerAnim_002C78, 2, 11 }, + { &gPlayerAnim_002B28, &gPlayerAnim_002B30, &gPlayerAnim_002560, 0, 12 }, + { &gPlayerAnim_002940, &gPlayerAnim_002948, &gPlayerAnim_0024B8, 0, 15 }, + { &gPlayerAnim_0029C0, &gPlayerAnim_0029C8, &gPlayerAnim_002560, 0, 16 }, + { &gPlayerAnim_0029C0, &gPlayerAnim_0029C8, &gPlayerAnim_0024B8, 0, 16 }, +}; + +static LinkAnimationHeader* D_80854350[] = { + &gPlayerAnim_002AE8, + &gPlayerAnim_002920, +}; + +static LinkAnimationHeader* D_80854358[] = { + &gPlayerAnim_002AE0, + &gPlayerAnim_002920, +}; + +static LinkAnimationHeader* D_80854360[] = { + &gPlayerAnim_002AF0, + &gPlayerAnim_002928, +}; + +static LinkAnimationHeader* D_80854368[] = { + &gPlayerAnim_002AF8, + &gPlayerAnim_002930, +}; + +static LinkAnimationHeader* D_80854370[] = { + &gPlayerAnim_002B00, + &gPlayerAnim_002938, +}; + +static LinkAnimationHeader* D_80854378[] = { + &gPlayerAnim_002AD8, + &gPlayerAnim_002918, +}; + +static u8 D_80854380[2] = { 0x18, 0x19 }; +static u8 D_80854384[2] = { 0x1A, 0x1B }; + +static u16 D_80854388[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; + +static u8 sMagicSpellCosts[] = { 12, 24, 24, 12, 24, 12 }; + +static u16 D_80854398[] = { NA_SE_IT_BOW_DRAW, NA_SE_IT_SLING_DRAW, NA_SE_IT_HOOKSHOT_READY }; + +static u8 sMagicArrowCosts[] = { 4, 4, 8 }; + +static LinkAnimationHeader* D_808543A4[] = { + &gPlayerAnim_0025C0, + &gPlayerAnim_0025C8, +}; + +static LinkAnimationHeader* D_808543AC[] = { + &gPlayerAnim_002580, + &gPlayerAnim_002588, +}; + +static LinkAnimationHeader* D_808543B4[] = { + &gPlayerAnim_002510, + &gPlayerAnim_002518, +}; + +static LinkAnimationHeader* D_808543BC[] = { + &gPlayerAnim_002510, + &gPlayerAnim_002520, +}; + +static LinkAnimationHeader* D_808543C4[] = { + &gPlayerAnim_002EC0, + &gPlayerAnim_002A08, +}; + +static LinkAnimationHeader* D_808543CC[] = { + &gPlayerAnim_0026F0, + &gPlayerAnim_002CC8, +}; + +static LinkAnimationHeader* D_808543D4[] = { + &gPlayerAnim_0026C0, + &gPlayerAnim_002CC0, +}; + +// return type can't be void due to regalloc in func_8084FCAC +s32 func_80832210(Player* pthis) { + pthis->actor.speedXZ = 0.0f; + pthis->linearVelocity = 0.0f; + return 0; +} + +// return type can't be void due to regalloc in func_8083F72C +s32 func_80832224(Player* pthis) { + func_80832210(pthis); + pthis->unk_6AD = 0; + return 0; +} + +s32 func_8083224C(GlobalContext* globalCtx) { + Player* pthis = GET_PLAYER(globalCtx); + + return CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_8); +} + +void func_80832264(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime, anim); +} + +void func_80832284(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_PlayLoop(globalCtx, &pthis->skelAnime, anim); +} + +void func_808322A4(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_PlayLoopSetSpeed(globalCtx, &pthis->skelAnime, anim, 2.0f / 3.0f); +} + +void func_808322D0(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, anim, 2.0f / 3.0f); +} + +void func_808322FC(Player* pthis) { + pthis->actor.shape.rot.y += pthis->skelAnime.jointTable[1].y; + pthis->skelAnime.jointTable[1].y = 0; +} + +void func_80832318(Player* pthis) { + pthis->stateFlags2 &= ~0x20000; + pthis->swordState = 0; + pthis->swordInfo[0].active = pthis->swordInfo[1].active = pthis->swordInfo[2].active = 0; +} + +void func_80832340(GlobalContext* globalCtx, Player* pthis) { + Camera* camera; + + if (pthis->unk_46C != SUBCAM_NONE) { + camera = globalCtx->cameraPtrs[pthis->unk_46C]; + if ((camera != NULL) && (camera->csId == 1100)) { + OnePointCutscene_EndCutscene(globalCtx, pthis->unk_46C); + pthis->unk_46C = SUBCAM_NONE; + } + } + + pthis->stateFlags2 &= ~0xC00; +} + +void func_808323B4(GlobalContext* globalCtx, Player* pthis) { + Actor* heldActor = pthis->heldActor; + + if ((heldActor != NULL) && !Player_HoldsHookshot(pthis)) { + pthis->actor.child = NULL; + pthis->heldActor = NULL; + pthis->interactRangeActor = NULL; + heldActor->parent = NULL; + pthis->stateFlags1 &= ~0x800; + } + + if (Player_GetExplosiveHeld(pthis) >= 0) { + func_8083399C(globalCtx, pthis, PLAYER_AP_NONE); + pthis->heldItemId = ITEM_NONE_FE; + } +} + +void func_80832440(GlobalContext* globalCtx, Player* pthis) { + if ((pthis->stateFlags1 & 0x800) && (pthis->heldActor == NULL)) { + if (pthis->interactRangeActor != NULL) { + if (pthis->getItemId == GI_NONE) { + pthis->stateFlags1 &= ~0x800; + pthis->interactRangeActor = NULL; + } + } else { + pthis->stateFlags1 &= ~0x800; + } + } + + func_80832318(pthis); + pthis->unk_6AD = 0; + + func_80832340(globalCtx, pthis); + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + + pthis->stateFlags1 &= ~0x306000; + pthis->stateFlags2 &= ~0x40090; + + pthis->actor.shape.rot.x = 0; + pthis->actor.shape.yOffset = 0.0f; + + pthis->unk_845 = pthis->unk_844 = 0; +} + +s32 func_80832528(GlobalContext* globalCtx, Player* pthis) { + if (pthis->heldItemActionParam >= PLAYER_AP_FISHING_POLE) { + func_80835F44(globalCtx, pthis, ITEM_NONE); + return 1; + } else { + return 0; + } +} + +void func_80832564(GlobalContext* globalCtx, Player* pthis) { + func_80832440(globalCtx, pthis); + func_808323B4(globalCtx, pthis); +} + +s32 func_80832594(Player* pthis, s32 arg1, s32 arg2) { + s16 temp = pthis->unk_A80 - D_808535D8; + + pthis->unk_850 += arg1 + (s16)(ABS(temp) * fabsf(D_808535D4) * 2.5415802156203426e-06f); + + if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B)) { + pthis->unk_850 += 5; + } + + return pthis->unk_850 > arg2; +} + +void func_80832630(GlobalContext* globalCtx) { + if (globalCtx->actorCtx.freezeFlashTimer == 0) { + globalCtx->actorCtx.freezeFlashTimer = 1; + } +} + +void func_8083264C(Player* pthis, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + if (pthis->actor.category == ACTORCAT_PLAYER) { + func_800AA000(arg4, arg1, arg2, arg3); + } +} + +void func_80832698(Player* pthis, u16 sfxId) { + if (pthis->actor.category == ACTORCAT_PLAYER) { + func_8002F7DC(&pthis->actor, sfxId + pthis->ageProperties->unk_92); + } else { + func_800F4190(&pthis->actor.projectedPos, sfxId); + } +} + +void func_808326F0(Player* pthis) { + u16* entry = &D_8085361C[0]; + s32 i; + + for (i = 0; i < 4; i++) { + Audio_StopSfxById((u16)(*entry + pthis->ageProperties->unk_92)); + entry++; + } +} + +u16 func_8083275C(Player* pthis, u16 sfxId) { + return sfxId + pthis->unk_89E; +} + +void func_80832770(Player* pthis, u16 sfxId) { + func_8002F7DC(&pthis->actor, func_8083275C(pthis, sfxId)); +} + +u16 func_808327A4(Player* pthis, u16 sfxId) { + return sfxId + pthis->unk_89E + pthis->ageProperties->unk_94; +} + +void func_808327C4(Player* pthis, u16 sfxId) { + func_8002F7DC(&pthis->actor, func_808327A4(pthis, sfxId)); +} + +void func_808327F8(Player* pthis, f32 arg1) { + s32 sfxId; + + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + sfxId = NA_SE_PL_WALK_HEAVYBOOTS; + } else { + sfxId = func_808327A4(pthis, NA_SE_PL_WALK_GROUND); + } + + func_800F4010(&pthis->actor.projectedPos, sfxId, arg1); +} + +void func_80832854(Player* pthis) { + s32 sfxId; + + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + sfxId = NA_SE_PL_JUMP_HEAVYBOOTS; + } else { + sfxId = func_808327A4(pthis, NA_SE_PL_JUMP); + } + + func_8002F7DC(&pthis->actor, sfxId); +} + +void func_808328A0(Player* pthis) { + s32 sfxId; + + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + sfxId = NA_SE_PL_LAND_HEAVYBOOTS; + } else { + sfxId = func_808327A4(pthis, NA_SE_PL_LAND); + } + + func_8002F7DC(&pthis->actor, sfxId); +} + +void func_808328EC(Player* pthis, u16 sfxId) { + func_8002F7DC(&pthis->actor, sfxId); + pthis->stateFlags2 |= 8; +} + +void func_80832924(Player* pthis, struct_80832924* entry) { + s32 data; + s32 flags; + u32 cont; + s32 pad; + + do { + data = ABS(entry->field); + flags = data & 0x7800; + if (LinkAnimation_OnFrame(&pthis->skelAnime, fabsf(data & 0x7FF))) { + if (flags == 0x800) { + func_8002F7DC(&pthis->actor, entry->sfxId); + } else if (flags == 0x1000) { + func_80832770(pthis, entry->sfxId); + } else if (flags == 0x1800) { + func_808327C4(pthis, entry->sfxId); + } else if (flags == 0x2000) { + func_80832698(pthis, entry->sfxId); + } else if (flags == 0x2800) { + func_808328A0(pthis); + } else if (flags == 0x3000) { + func_808327F8(pthis, 6.0f); + } else if (flags == 0x3800) { + func_80832854(pthis); + } else if (flags == 0x4000) { + func_808327F8(pthis, 0.0f); + } else if (flags == 0x4800) { + func_800F4010(&pthis->actor.projectedPos, pthis->ageProperties->unk_94 + NA_SE_PL_WALK_LADDER, 0.0f); + } + } + cont = (entry->field >= 0); + entry++; + } while (cont); +} + +void func_80832B0C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + -6.0f); +} + +void func_80832B78(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 2.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), + ANIMMODE_ONCE, -6.0f); +} + +void func_80832BE8(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f); +} + +void func_80832C2C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); +} + +void func_80832C6C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -16.0f); +} + +s32 func_80832CB0(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, anim); + return 1; + } else { + return 0; + } +} + +void func_80832CFC(Player* pthis) { + pthis->skelAnime.prevTransl = pthis->skelAnime.baseTransl; + pthis->skelAnime.prevRot = pthis->actor.shape.rot.y; +} + +void func_80832D20(Player* pthis) { + func_80832CFC(pthis); + pthis->skelAnime.prevTransl.x *= pthis->ageProperties->unk_08; + pthis->skelAnime.prevTransl.y *= pthis->ageProperties->unk_08; + pthis->skelAnime.prevTransl.z *= pthis->ageProperties->unk_08; +} + +void func_80832DB0(Player* pthis) { + pthis->skelAnime.jointTable[1].y = 0; +} + +void func_80832DBC(Player* pthis) { + if (pthis->skelAnime.moveFlags != 0) { + func_808322FC(pthis); + pthis->skelAnime.jointTable[0].x = pthis->skelAnime.baseTransl.x; + pthis->skelAnime.jointTable[0].z = pthis->skelAnime.baseTransl.z; + if (pthis->skelAnime.moveFlags & 8) { + if (pthis->skelAnime.moveFlags & 2) { + pthis->skelAnime.jointTable[0].y = pthis->skelAnime.prevTransl.y; + } + } else { + pthis->skelAnime.jointTable[0].y = pthis->skelAnime.baseTransl.y; + } + func_80832CFC(pthis); + pthis->skelAnime.moveFlags = 0; + } +} + +void func_80832E48(Player* pthis, s32 flags) { + Vec3f pos; + + pthis->skelAnime.moveFlags = flags; + pthis->skelAnime.prevTransl = pthis->skelAnime.baseTransl; + SkelAnime_UpdateTranslation(&pthis->skelAnime, &pos, pthis->actor.shape.rot.y); + + if (flags & 1) { + if (!LINK_IS_ADULT) { + pos.x *= 0.64f; + pos.z *= 0.64f; + } + pthis->actor.world.pos.x += pos.x * pthis->actor.scale.x; + pthis->actor.world.pos.z += pos.z * pthis->actor.scale.z; + } + + if (flags & 2) { + if (!(flags & 4)) { + pos.y *= pthis->ageProperties->unk_08; + } + pthis->actor.world.pos.y += pos.y * pthis->actor.scale.y; + } + + func_808322FC(pthis); +} + +void func_80832F54(GlobalContext* globalCtx, Player* pthis, s32 flags) { + if (flags & 0x200) { + func_80832D20(pthis); + } else if ((flags & 0x100) || (pthis->skelAnime.moveFlags != 0)) { + func_80832CFC(pthis); + } else { + pthis->skelAnime.prevTransl = pthis->skelAnime.jointTable[0]; + pthis->skelAnime.prevRot = pthis->actor.shape.rot.y; + } + + pthis->skelAnime.moveFlags = flags; + func_80832210(pthis); + AnimationContext_DisableQueue(globalCtx); +} + +void func_80832FFC(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, anim, playbackSpeed); + func_80832F54(globalCtx, pthis, flags); +} + +void func_8083303C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, s32 flags) { + func_80832FFC(globalCtx, pthis, anim, flags, 1.0f); +} + +void func_80833064(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, s32 flags) { + func_80832FFC(globalCtx, pthis, anim, flags, 2.0f / 3.0f); +} + +void func_8083308C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + func_80833064(globalCtx, pthis, anim, 0x1C); +} + +void func_808330AC(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { + LinkAnimation_PlayLoopSetSpeed(globalCtx, &pthis->skelAnime, anim, playbackSpeed); + func_80832F54(globalCtx, pthis, flags); +} + +void func_808330EC(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, s32 flags) { + func_808330AC(globalCtx, pthis, anim, flags, 1.0f); +} + +void func_80833114(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, s32 flags) { + func_808330AC(globalCtx, pthis, anim, flags, 2.0f / 3.0f); +} + +void func_8083313C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + func_80833114(globalCtx, pthis, anim, 0x1C); +} + +void func_8083315C(GlobalContext* globalCtx, Player* pthis) { + s8 phi_v1; + s8 phi_v0; + + pthis->unk_A7C = D_808535D4; + pthis->unk_A80 = D_808535D8; + + func_80077D10(&D_808535D4, &D_808535D8, sControlInput); + + D_808535DC = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)) + D_808535D8; + + pthis->unk_846 = (pthis->unk_846 + 1) % 4; + + if (D_808535D4 < 55.0f) { + phi_v0 = -1; + phi_v1 = -1; + } else { + phi_v1 = (u16)(D_808535D8 + 0x2000) >> 9; + phi_v0 = (u16)((s16)(D_808535DC - pthis->actor.shape.rot.y) + 0x2000) >> 14; + } + + pthis->unk_847[pthis->unk_846] = phi_v1; + pthis->unk_84B[pthis->unk_846] = phi_v0; +} + +void func_8083328C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* linkAnim) { + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, linkAnim, D_808535E8); +} + +s32 func_808332B8(Player* pthis) { + return (pthis->stateFlags1 & 0x8000000) && (pthis->currentBoots != PLAYER_BOOTS_IRON); +} + +s32 func_808332E4(Player* pthis) { + return (pthis->stateFlags1 & 0x1000000); +} + +void func_808332F4(Player* pthis, GlobalContext* globalCtx) { + GetItemEntry* giEntry = &sGetItemTable[pthis->getItemId - 1]; + + pthis->unk_862 = ABS(giEntry->gi); +} + +static LinkAnimationHeader* func_80833338(Player* pthis) { + return D_80853914[pthis->modelAnimType]; +} + +s32 func_80833350(Player* pthis) { + LinkAnimationHeader** entry; + s32 i; + + if (func_80833338(pthis) != pthis->skelAnime.animation) { + for (i = 0, entry = &D_80853D7C[0][0]; i < 28; i++, entry++) { + if (pthis->skelAnime.animation == *entry) { + return i + 1; + } + } + return 0; + } + + return -1; +} + +void func_808333FC(Player* pthis, s32 arg1) { + if (D_80853E7C[arg1] != 0) { + func_80832924(pthis, D_80853E50[D_80853E7C[arg1] - 1]); + } +} + +LinkAnimationHeader* func_80833438(Player* pthis) { + if (pthis->unk_890 != 0) { + return D_8085395C[pthis->modelAnimType]; + } else if (!(pthis->stateFlags1 & 0x28000000) && (pthis->currentBoots == PLAYER_BOOTS_IRON)) { + return D_80853974[pthis->modelAnimType]; + } else { + return D_80853944[pthis->modelAnimType]; + } +} + +s32 func_808334B4(Player* pthis) { + return func_808332E4(pthis) && (pthis->unk_834 != 0); +} + +LinkAnimationHeader* func_808334E4(Player* pthis) { + if (func_808334B4(pthis)) { + return &gPlayerAnim_002638; + } else { + return D_808539A4[pthis->modelAnimType]; + } +} + +LinkAnimationHeader* func_80833528(Player* pthis) { + if (func_808334B4(pthis)) { + return &gPlayerAnim_002630; + } else { + return D_8085398C[pthis->modelAnimType]; + } +} + +LinkAnimationHeader* func_8083356C(Player* pthis) { + if (func_8002DD78(pthis)) { + return &gPlayerAnim_0026E8; + } else { + return D_80853B3C[pthis->modelAnimType]; + } +} + +LinkAnimationHeader* func_808335B0(Player* pthis) { + if (func_808334B4(pthis)) { + return &gPlayerAnim_002620; + } else { + return D_80853B6C[pthis->modelAnimType]; + } +} + +LinkAnimationHeader* func_808335F4(Player* pthis) { + if (func_808334B4(pthis)) { + return &gPlayerAnim_002618; + } else { + return D_80853B54[pthis->modelAnimType]; + } +} + +void func_80833638(Player* pthis, PlayerFunc82C arg1) { + pthis->func_82C = arg1; + pthis->unk_836 = 0; + pthis->unk_830 = 0.0f; + func_808326F0(pthis); +} + +void func_80833664(GlobalContext* globalCtx, Player* pthis, s8 actionParam) { + LinkAnimationHeader* current = (LinkAnimationHeader*)pthis->skelAnime.animation; + LinkAnimationHeader** iter = &D_80853914[pthis->modelAnimType]; + u32 i; + + pthis->stateFlags1 &= ~0x1000008; + + for (i = 0; i < 45; i++) { + if (current == AnimHeaderLut[i][pthis->modelAnimType]) { + break; + } + } + + func_8083399C(globalCtx, pthis, actionParam); + + if (i < 45) { + pthis->skelAnime.animation = AnimHeaderLut[i][pthis->modelAnimType]; + } +} + +s8 Player_ItemToActionParam(s32 item) { + if (item >= ITEM_NONE_FE) { + return PLAYER_AP_NONE; + } else if (item == ITEM_LAST_USED) { + return PLAYER_AP_LAST_USED; + } else if (item == ITEM_FISHING_POLE) { + return PLAYER_AP_FISHING_POLE; + } else { + return sItemActionParams[item]; + } +} + +void func_80833770(GlobalContext* globalCtx, Player* pthis) { +} + +void func_8083377C(GlobalContext* globalCtx, Player* pthis) { + pthis->unk_85C = 1.0f; +} + +void func_80833790(GlobalContext* globalCtx, Player* pthis) { +} + +void func_8083379C(GlobalContext* globalCtx, Player* pthis) { + pthis->stateFlags1 |= 8; + + if (pthis->heldItemActionParam != PLAYER_AP_SLINGSHOT) { + pthis->unk_860 = -1; + } else { + pthis->unk_860 = -2; + } +} + +void func_808337D4(GlobalContext* globalCtx, Player* pthis) { + s32 explosiveType; + ExplosiveInfo* explosiveInfo; + Actor* spawnedActor; + + if (pthis->stateFlags1 & 0x800) { + func_80832528(globalCtx, pthis); + return; + } + + explosiveType = Player_GetExplosiveHeld(pthis); + explosiveInfo = &sExplosiveInfos[explosiveType]; + + spawnedActor = Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, explosiveInfo->actorId, + pthis->actor.world.pos.x, pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, + pthis->actor.shape.rot.y, 0, 0); + if (spawnedActor != NULL) { + if ((explosiveType != 0) && (globalCtx->bombchuBowlingStatus != 0)) { + globalCtx->bombchuBowlingStatus--; + if (globalCtx->bombchuBowlingStatus == 0) { + globalCtx->bombchuBowlingStatus = -1; + } + } else { + Inventory_ChangeAmmo(explosiveInfo->itemId, -1); + } + + pthis->interactRangeActor = spawnedActor; + pthis->heldActor = spawnedActor; + pthis->getItemId = GI_NONE; + pthis->unk_3BC.y = spawnedActor->shape.rot.y - pthis->actor.shape.rot.y; + pthis->stateFlags1 |= 0x800; + } +} + +void func_80833910(GlobalContext* globalCtx, Player* pthis) { + pthis->stateFlags1 |= 8; + pthis->unk_860 = -3; + + pthis->heldActor = + Actor_SpawnAsChild(&globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_ARMS_HOOK, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, pthis->actor.shape.rot.y, 0, 0); +} + +void func_80833984(GlobalContext* globalCtx, Player* pthis) { + pthis->stateFlags1 |= 0x1000000; +} + +void func_8083399C(GlobalContext* globalCtx, Player* pthis, s8 actionParam) { + pthis->unk_860 = 0; + pthis->unk_85C = 0.0f; + pthis->unk_858 = 0.0f; + + pthis->heldItemActionParam = pthis->itemActionParam = actionParam; + pthis->modelGroup = pthis->nextModelGroup; + + pthis->stateFlags1 &= ~0x1000008; + + D_80853FE8[actionParam](globalCtx, pthis); + + Player_SetModelGroup(pthis, pthis->modelGroup); +} + +void func_80833A20(Player* pthis, s32 newSwordState) { + u16 itemSfx; + u16 voiceSfx; + + if (pthis->swordState == 0) { + if ((pthis->heldItemActionParam == PLAYER_AP_SWORD_BGS) && (gSaveContext.swordHealth > 0.0f)) { + itemSfx = NA_SE_IT_HAMMER_SWING; + } else { + itemSfx = NA_SE_IT_SWORD_SWING; + } + + voiceSfx = NA_SE_VO_LI_SWORD_N; + if (pthis->heldItemActionParam == PLAYER_AP_HAMMER) { + itemSfx = NA_SE_IT_HAMMER_SWING; + } else if (pthis->swordAnimation >= 0x18) { + itemSfx = 0; + voiceSfx = NA_SE_VO_LI_SWORD_L; + } else if (pthis->unk_845 >= 3) { + itemSfx = NA_SE_IT_SWORD_SWING_HARD; + voiceSfx = NA_SE_VO_LI_SWORD_L; + } + + if (itemSfx != 0) { + func_808328EC(pthis, itemSfx); + } + + if ((pthis->swordAnimation < 0x10) || (pthis->swordAnimation >= 0x14)) { + func_80832698(pthis, voiceSfx); + } + } + + pthis->swordState = newSwordState; +} + +s32 func_80833B2C(Player* pthis) { + if (pthis->stateFlags1 & 0x40030000) { + return 1; + } else { + return 0; + } +} + +s32 func_80833B54(Player* pthis) { + if ((pthis->unk_664 != NULL) && CHECK_FLAG_ALL(pthis->unk_664->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2)) { + pthis->stateFlags1 |= 0x10; + return 1; + } + + if (pthis->stateFlags1 & 0x10) { + pthis->stateFlags1 &= ~0x10; + if (pthis->linearVelocity == 0.0f) { + pthis->currentYaw = pthis->actor.shape.rot.y; + } + } + + return 0; +} + +s32 func_80833BCC(Player* pthis) { + return func_8008E9C4(pthis) || func_80833B2C(pthis); +} + +s32 func_80833C04(Player* pthis) { + return func_80833B54(pthis) || func_80833B2C(pthis); +} + +void func_80833C3C(Player* pthis) { + pthis->unk_870 = pthis->unk_874 = 0.0f; +} + +s32 func_80833C50(Player* pthis, s32 item) { + if ((item < ITEM_NONE_FE) && (Player_ItemToActionParam(item) == pthis->itemActionParam)) { + return 1; + } else { + return 0; + } +} + +s32 func_80833C98(s32 item1, s32 actionParam) { + if ((item1 < ITEM_NONE_FE) && (Player_ItemToActionParam(item1) == actionParam)) { + return 1; + } else { + return 0; + } +} + +s32 func_80833CDC(GlobalContext* globalCtx, s32 index) { + if (index >= 4) { + return ITEM_NONE; + } else if (globalCtx->bombchuBowlingStatus != 0) { + return (globalCtx->bombchuBowlingStatus > 0) ? ITEM_BOMBCHU : ITEM_NONE; + } else if (index == 0) { + return B_BTN_ITEM; + } else if (index == 1) { + return C_BTN_ITEM(0); + } else if (index == 2) { + return C_BTN_ITEM(1); + } else { + return C_BTN_ITEM(2); + } +} + +void func_80833DF8(Player* pthis, GlobalContext* globalCtx) { + s32 maskActionParam; + s32 item; + s32 i; + + if (pthis->currentMask != PLAYER_MASK_NONE) { + maskActionParam = pthis->currentMask - 1 + PLAYER_AP_MASK_KEATON; + if (!func_80833C98(C_BTN_ITEM(0), maskActionParam) && !func_80833C98(C_BTN_ITEM(1), maskActionParam) && + !func_80833C98(C_BTN_ITEM(2), maskActionParam)) { + pthis->currentMask = PLAYER_MASK_NONE; + } + } + + if (!(pthis->stateFlags1 & 0x20000800) && !func_8008F128(pthis)) { + if (pthis->itemActionParam >= PLAYER_AP_FISHING_POLE) { + if (!func_80833C50(pthis, B_BTN_ITEM) && !func_80833C50(pthis, C_BTN_ITEM(0)) && + !func_80833C50(pthis, C_BTN_ITEM(1)) && !func_80833C50(pthis, C_BTN_ITEM(2))) { + func_80835F44(globalCtx, pthis, ITEM_NONE); + return; + } + } + + for (i = 0; i < ARRAY_COUNT(D_80854388); i++) { + if (CHECK_BTN_ALL(sControlInput->press.button, D_80854388[i])) { + break; + } + } + + item = func_80833CDC(globalCtx, i); + if (item >= ITEM_NONE_FE) { + for (i = 0; i < ARRAY_COUNT(D_80854388); i++) { + if (CHECK_BTN_ALL(sControlInput->cur.button, D_80854388[i])) { + break; + } + } + + item = func_80833CDC(globalCtx, i); + if ((item < ITEM_NONE_FE) && (Player_ItemToActionParam(item) == pthis->heldItemActionParam)) { + D_80853618 = true; + } + } else { + pthis->heldItemButton = i; + func_80835F44(globalCtx, pthis, item); + } + } +} + +void func_808340DC(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + f32 phi_f2; + f32 phi_f12; + f32 phi_f14; + f32 phi_f0; + s32 sp38; + s8 sp37; + s32 temp; + + sp37 = Player_ItemToActionParam(pthis->heldItemId); + func_80833638(pthis, func_80834A2C); + + temp = gPlayerModelTypes[pthis->nextModelGroup][0]; + sp38 = D_80854164[gPlayerModelTypes[pthis->modelGroup][0]][temp]; + if ((sp37 == PLAYER_AP_BOTTLE) || (sp37 == PLAYER_AP_BOOMERANG) || + ((sp37 == PLAYER_AP_NONE) && + ((pthis->heldItemActionParam == PLAYER_AP_BOTTLE) || (pthis->heldItemActionParam == PLAYER_AP_BOOMERANG)))) { + sp38 = (sp37 == PLAYER_AP_NONE) ? -13 : 13; + } + + pthis->unk_15A = ABS(sp38); + + anim = D_808540F4[pthis->unk_15A].anim; + if ((anim == &gPlayerAnim_002F30) && (pthis->currentShield == PLAYER_SHIELD_NONE)) { + anim = &gPlayerAnim_002F40; + } + + phi_f2 = Animation_GetLastFrame(anim); + phi_f14 = phi_f2; + + if (sp38 >= 0) { + phi_f0 = 1.2f; + phi_f12 = 0.0f; + } else { + phi_f14 = 0.0f; + phi_f0 = -1.2f; + phi_f12 = phi_f2; + } + + if (sp37 != PLAYER_AP_NONE) { + phi_f0 *= 2.0f; + } + + LinkAnimation_Change(globalCtx, &pthis->skelAnime2, anim, phi_f0, phi_f12, phi_f14, ANIMMODE_ONCE, 0.0f); + + pthis->stateFlags1 &= ~0x100; +} + +void func_80834298(Player* pthis, GlobalContext* globalCtx) { + if ((pthis->actor.category == ACTORCAT_PLAYER) && !(pthis->stateFlags1 & 0x100) && + ((pthis->heldItemActionParam == pthis->itemActionParam) || (pthis->stateFlags1 & 0x400000)) && + (gSaveContext.health != 0) && (globalCtx->csCtx.state == CS_STATE_IDLE) && (pthis->csMode == 0) && + (globalCtx->shootingGalleryStatus == 0) && (globalCtx->activeCamera == MAIN_CAM) && + (globalCtx->sceneLoadFlag != 0x14) && (gSaveContext.timer1State != 10)) { + func_80833DF8(pthis, globalCtx); + } + + if (pthis->stateFlags1 & 0x100) { + func_808340DC(pthis, globalCtx); + } +} + +s32 func_80834380(GlobalContext* globalCtx, Player* pthis, s32* itemPtr, s32* typePtr) { + if (LINK_IS_ADULT) { + *itemPtr = ITEM_BOW; + if (pthis->stateFlags1 & 0x800000) { + *typePtr = ARROW_NORMAL_HORSE; + } else { + *typePtr = pthis->heldItemActionParam - 6; + } + } else { + *itemPtr = ITEM_SLINGSHOT; + *typePtr = ARROW_SEED; + } + + if (gSaveContext.minigameState == 1) { + return globalCtx->interfaceCtx.hbaAmmo; + } else if (globalCtx->shootingGalleryStatus != 0) { + return globalCtx->shootingGalleryStatus; + } else { + return AMMO(*itemPtr); + } +} + +s32 func_8083442C(Player* pthis, GlobalContext* globalCtx) { + s32 item; + s32 arrowType; + s32 magicArrowType; + + if ((pthis->heldItemActionParam >= PLAYER_AP_BOW_FIRE) && (pthis->heldItemActionParam <= PLAYER_AP_BOW_0E) && + (gSaveContext.unk_13F0 != 0)) { + func_80078884(NA_SE_SY_ERROR); + } else { + func_80833638(pthis, func_808351D4); + + pthis->stateFlags1 |= 0x200; + pthis->unk_834 = 14; + + if (pthis->unk_860 >= 0) { + func_8002F7DC(&pthis->actor, D_80854398[ABS(pthis->unk_860) - 1]); + + if (!Player_HoldsHookshot(pthis) && (func_80834380(globalCtx, pthis, &item, &arrowType) > 0)) { + magicArrowType = arrowType - ARROW_FIRE; + + if (pthis->unk_860 >= 0) { + if ((magicArrowType >= 0) && (magicArrowType <= 2) && + !func_80087708(globalCtx, sMagicArrowCosts[magicArrowType], 0)) { + arrowType = ARROW_NORMAL; + } + + pthis->heldActor = Actor_SpawnAsChild( + &globalCtx->actorCtx, &pthis->actor, globalCtx, ACTOR_EN_ARROW, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, pthis->actor.shape.rot.y, 0, arrowType); + } + } + } + + return 1; + } + + return 0; +} + +void func_80834594(GlobalContext* globalCtx, Player* pthis) { + if (pthis->heldItemActionParam != PLAYER_AP_NONE) { + if (func_8008F2BC(pthis, pthis->heldItemActionParam) >= 0) { + func_808328EC(pthis, NA_SE_IT_SWORD_PUTAWAY); + } else { + func_808328EC(pthis, NA_SE_PL_CHANGE_ARMS); + } + } + + func_80835F44(globalCtx, pthis, pthis->heldItemId); + + if (func_8008F2BC(pthis, pthis->heldItemActionParam) >= 0) { + func_808328EC(pthis, NA_SE_IT_SWORD_PICKOUT); + } else if (pthis->heldItemActionParam != PLAYER_AP_NONE) { + func_808328EC(pthis, NA_SE_PL_CHANGE_ARMS); + } +} + +void func_80834644(GlobalContext* globalCtx, Player* pthis) { + if (func_80834A2C == pthis->func_82C) { + func_80834594(globalCtx, pthis); + } + + func_80833638(pthis, D_80853EDC[pthis->heldItemActionParam]); + pthis->unk_834 = 0; + pthis->unk_6AC = 0; + func_808323B4(globalCtx, pthis); + pthis->stateFlags1 &= ~0x100; +} + +LinkAnimationHeader* func_808346C4(GlobalContext* globalCtx, Player* pthis) { + func_80833638(pthis, func_80834B5C); + func_808323B4(globalCtx, pthis); + + if (pthis->unk_870 < 0.5f) { + return D_808543A4[Player_HoldsTwoHandedWeapon(pthis)]; + } else { + return D_808543AC[Player_HoldsTwoHandedWeapon(pthis)]; + } +} + +s32 func_80834758(GlobalContext* globalCtx, Player* pthis) { + LinkAnimationHeader* anim; + f32 frame; + + if (!(pthis->stateFlags1 & 0x20C00000) && (globalCtx->shootingGalleryStatus == 0) && + (pthis->heldItemActionParam == pthis->itemActionParam) && (pthis->currentShield != PLAYER_SHIELD_NONE) && + !Player_IsChildWithHylianShield(pthis) && func_80833BCC(pthis) && + CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { + + anim = func_808346C4(globalCtx, pthis); + frame = Animation_GetLastFrame(anim); + LinkAnimation_Change(globalCtx, &pthis->skelAnime2, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); + func_8002F7DC(&pthis->actor, NA_SE_IT_SHIELD_POSTURE); + + return 1; + } else { + return 0; + } +} + +s32 func_8083485C(Player* pthis, GlobalContext* globalCtx) { + if (func_80834758(globalCtx, pthis)) { + return 1; + } else { + return 0; + } +} + +void func_80834894(Player* pthis) { + func_80833638(pthis, func_80834C74); + + if (pthis->itemActionParam < 0) { + func_8008EC70(pthis); + } + + Animation_Reverse(&pthis->skelAnime2); + func_8002F7DC(&pthis->actor, NA_SE_IT_SHIELD_REMOVE); +} + +void func_808348EC(GlobalContext* globalCtx, Player* pthis) { + struct_808540F4* ptr = &D_808540F4[pthis->unk_15A]; + f32 temp; + + temp = ptr->unk_04; + temp = (pthis->skelAnime2.playSpeed < 0.0f) ? temp - 1.0f : temp; + + if (LinkAnimation_OnFrame(&pthis->skelAnime2, temp)) { + func_80834594(globalCtx, pthis); + } + + func_80833B54(pthis); +} + +s32 func_8083499C(Player* pthis, GlobalContext* globalCtx) { + if (pthis->stateFlags1 & 0x100) { + func_808340DC(pthis, globalCtx); + } else { + return 0; + } + + return 1; +} + +s32 func_808349DC(Player* pthis, GlobalContext* globalCtx) { + if (func_80834758(globalCtx, pthis) || func_8083499C(pthis, globalCtx)) { + return 1; + } else { + return 0; + } +} + +s32 func_80834A2C(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2) || + ((Player_ItemToActionParam(pthis->heldItemId) == pthis->heldItemActionParam) && + (D_80853614 = (D_80853614 || ((pthis->modelAnimType != 3) && (globalCtx->shootingGalleryStatus == 0)))))) { + func_80833638(pthis, D_80853EDC[pthis->heldItemActionParam]); + pthis->unk_834 = 0; + pthis->unk_6AC = 0; + D_80853618 = D_80853614; + return pthis->func_82C(pthis, globalCtx); + } + + if (func_80833350(pthis) != 0) { + func_808348EC(globalCtx, pthis); + func_80832264(globalCtx, pthis, func_80833338(pthis)); + pthis->unk_6AC = 0; + } else { + func_808348EC(globalCtx, pthis); + } + + return 1; +} + +s32 func_80834B5C(Player* pthis, GlobalContext* globalCtx) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime2); + + if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { + func_80834894(pthis); + return 1; + } else { + pthis->stateFlags1 |= 0x400000; + Player_SetModelsForHoldingShield(pthis); + return 1; + } +} + +s32 func_80834BD4(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + f32 frame; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + anim = func_808346C4(globalCtx, pthis); + frame = Animation_GetLastFrame(anim); + LinkAnimation_Change(globalCtx, &pthis->skelAnime2, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); + } + + pthis->stateFlags1 |= 0x400000; + Player_SetModelsForHoldingShield(pthis); + + return 1; +} + +s32 func_80834C74(Player* pthis, GlobalContext* globalCtx) { + D_80853614 = D_80853618; + + if (D_80853614 || LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + func_80833638(pthis, D_80853EDC[pthis->heldItemActionParam]); + LinkAnimation_PlayLoop(globalCtx, &pthis->skelAnime2, D_80853914[pthis->modelAnimType]); + pthis->unk_6AC = 0; + pthis->func_82C(pthis, globalCtx); + return 0; + } + + return 1; +} + +s32 func_80834D2C(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + + if (pthis->heldItemActionParam != PLAYER_AP_BOOMERANG) { + if (!func_8083442C(pthis, globalCtx)) { + return 0; + } + + if (!Player_HoldsHookshot(pthis)) { + anim = &gPlayerAnim_0026A0; + } else { + anim = &gPlayerAnim_002CA0; + } + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, anim); + } else { + func_80833638(pthis, func_80835884); + pthis->unk_834 = 10; + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, &gPlayerAnim_002628); + } + + if (pthis->stateFlags1 & 0x800000) { + func_80832284(globalCtx, pthis, &gPlayerAnim_003380); + } else if ((pthis->actor.bgCheckFlags & 1) && !func_80833B54(pthis)) { + func_80832284(globalCtx, pthis, D_80853914[pthis->modelAnimType]); + } + + return 1; +} + +s32 func_80834E44(GlobalContext* globalCtx) { + return (globalCtx->shootingGalleryStatus > 0) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B); +} + +s32 func_80834E7C(GlobalContext* globalCtx) { + return (globalCtx->shootingGalleryStatus != 0) && + ((globalCtx->shootingGalleryStatus < 0) || + CHECK_BTN_ANY(sControlInput->cur.button, BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)); +} + +s32 func_80834EB8(Player* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_6AD == 0) || (pthis->unk_6AD == 2)) { + if (func_80833BCC(pthis) || (Camera_CheckValidMode(Gameplay_GetCamera(globalCtx, 0), 7) == 0)) { + return 1; + } + pthis->unk_6AD = 2; + } + + return 0; +} + +s32 func_80834F2C(Player* pthis, GlobalContext* globalCtx) { + if ((pthis->doorType == PLAYER_DOORTYPE_NONE) && !(pthis->stateFlags1 & 0x2000000)) { + if (D_80853614 || func_80834E44(globalCtx)) { + if (func_80834D2C(pthis, globalCtx)) { + return func_80834EB8(pthis, globalCtx); + } + } + } + + return 0; +} + +s32 func_80834FBC(Player* pthis) { + if (pthis->actor.child != NULL) { + if (pthis->heldActor == NULL) { + pthis->heldActor = pthis->actor.child; + func_8083264C(pthis, 255, 10, 250, 0); + func_8002F7DC(&pthis->actor, NA_SE_IT_HOOKSHOT_RECEIVE); + } + + return 1; + } + + return 0; +} + +s32 func_8083501C(Player* pthis, GlobalContext* globalCtx) { + if (pthis->unk_860 >= 0) { + pthis->unk_860 = -pthis->unk_860; + } + + if ((!Player_HoldsHookshot(pthis) || func_80834FBC(pthis)) && !func_80834758(globalCtx, pthis) && + !func_80834F2C(pthis, globalCtx)) { + return 0; + } + + return 1; +} + +s32 func_808350A4(GlobalContext* globalCtx, Player* pthis) { + s32 item; + s32 arrowType; + + if (pthis->heldActor != NULL) { + if (!Player_HoldsHookshot(pthis)) { + func_80834380(globalCtx, pthis, &item, &arrowType); + + if (gSaveContext.minigameState == 1) { + globalCtx->interfaceCtx.hbaAmmo--; + } else if (globalCtx->shootingGalleryStatus != 0) { + globalCtx->shootingGalleryStatus--; + } else { + Inventory_ChangeAmmo(item, -1); + } + + if (globalCtx->shootingGalleryStatus == 1) { + globalCtx->shootingGalleryStatus = -10; + } + + func_8083264C(pthis, 150, 10, 150, 0); + } else { + func_8083264C(pthis, 255, 20, 150, 0); + } + + pthis->unk_A73 = 4; + pthis->heldActor->parent = NULL; + pthis->actor.child = NULL; + pthis->heldActor = NULL; + + return 1; + } + + return 0; +} + +static u16 D_808543DC[] = { NA_SE_IT_BOW_FLICK, NA_SE_IT_SLING_FLICK }; + +s32 func_808351D4(Player* pthis, GlobalContext* globalCtx) { + s32 sp2C; + + if (!Player_HoldsHookshot(pthis)) { + sp2C = 0; + } else { + sp2C = 1; + } + + Math_ScaledStepToS(&pthis->unk_6C0, 1200, 400); + pthis->unk_6AE |= 0x100; + + if ((pthis->unk_836 == 0) && (func_80833350(pthis) == 0) && (pthis->skelAnime.animation == &gPlayerAnim_0026E8)) { + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, D_808543CC[sp2C]); + pthis->unk_836 = -1; + } else if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + LinkAnimation_PlayLoop(globalCtx, &pthis->skelAnime2, D_808543D4[sp2C]); + pthis->unk_836 = 1; + } else if (pthis->unk_836 == 1) { + pthis->unk_836 = 2; + } + + if (pthis->unk_834 > 10) { + pthis->unk_834--; + } + + func_80834EB8(pthis, globalCtx); + + if ((pthis->unk_836 > 0) && ((pthis->unk_860 < 0) || (!D_80853618 && !func_80834E7C(globalCtx)))) { + func_80833638(pthis, func_808353D8); + if (pthis->unk_860 >= 0) { + if (sp2C == 0) { + if (!func_808350A4(globalCtx, pthis)) { + func_8002F7DC(&pthis->actor, D_808543DC[ABS(pthis->unk_860) - 1]); + } + } else if (pthis->actor.bgCheckFlags & 1) { + func_808350A4(globalCtx, pthis); + } + } + pthis->unk_834 = 10; + func_80832210(pthis); + } else { + pthis->stateFlags1 |= 0x200; + } + + return 1; +} + +s32 func_808353D8(Player* pthis, GlobalContext* globalCtx) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime2); + + if (Player_HoldsHookshot(pthis) && !func_80834FBC(pthis)) { + return 1; + } + + if (!func_80834758(globalCtx, pthis) && + (D_80853614 || ((pthis->unk_860 < 0) && D_80853618) || func_80834E44(globalCtx))) { + pthis->unk_860 = ABS(pthis->unk_860); + + if (func_8083442C(pthis, globalCtx)) { + if (Player_HoldsHookshot(pthis)) { + pthis->unk_836 = 1; + } else { + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, &gPlayerAnim_0026B8); + } + } + } else { + if (pthis->unk_834 != 0) { + pthis->unk_834--; + } + + if (func_80833BCC(pthis) || (pthis->unk_6AD != 0) || (pthis->stateFlags1 & 0x100000)) { + if (pthis->unk_834 == 0) { + pthis->unk_834++; + } + return 1; + } + + if (Player_HoldsHookshot(pthis)) { + func_80833638(pthis, func_8083501C); + } else { + func_80833638(pthis, func_80835588); + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, &gPlayerAnim_0026B0); + } + + pthis->unk_834 = 0; + } + + return 1; +} + +s32 func_80835588(Player* pthis, GlobalContext* globalCtx) { + if (!(pthis->actor.bgCheckFlags & 1) || LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + func_80833638(pthis, func_8083501C); + } + + return 1; +} + +void func_808355DC(Player* pthis) { + pthis->stateFlags1 |= 0x20000; + + if (!(pthis->skelAnime.moveFlags & 0x80) && (pthis->actor.bgCheckFlags & 0x200) && (D_80853608 < 0x2000)) { + pthis->currentYaw = pthis->actor.shape.rot.y = pthis->actor.wallYaw + 0x8000; + } + + pthis->targetYaw = pthis->actor.shape.rot.y; +} + +s32 func_80835644(GlobalContext* globalCtx, Player* pthis, Actor* arg2) { + if (arg2 == NULL) { + func_80832564(globalCtx, pthis); + func_80839F90(pthis, globalCtx); + return 1; + } + + return 0; +} + +void func_80835688(Player* pthis, GlobalContext* globalCtx) { + if (!func_80835644(globalCtx, pthis, pthis->heldActor)) { + func_80833638(pthis, func_808356E8); + LinkAnimation_PlayLoop(globalCtx, &pthis->skelAnime2, &gPlayerAnim_002E10); + } +} + +s32 func_808356E8(Player* pthis, GlobalContext* globalCtx) { + Actor* heldActor = pthis->heldActor; + + if (heldActor == NULL) { + func_80834644(globalCtx, pthis); + } + + if (func_80834758(globalCtx, pthis)) { + return 1; + } + + if (pthis->stateFlags1 & 0x800) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + LinkAnimation_PlayLoop(globalCtx, &pthis->skelAnime2, &gPlayerAnim_002E10); + } + + if ((heldActor->id == ACTOR_EN_NIW) && (pthis->actor.velocity.y <= 0.0f)) { + pthis->actor.minVelocityY = -2.0f; + pthis->actor.gravity = -0.5f; + pthis->fallStartHeight = pthis->actor.world.pos.y; + } + + return 1; + } + + return func_8083485C(pthis, globalCtx); +} + +void func_808357E8(Player* pthis, Gfx** dLists) { + pthis->leftHandDLists = &dLists[gSaveContext.linkAge]; +} + +s32 func_80835800(Player* pthis, GlobalContext* globalCtx) { + if (func_80834758(globalCtx, pthis)) { + return 1; + } + + if (pthis->stateFlags1 & 0x2000000) { + func_80833638(pthis, func_80835B60); + } else if (func_80834F2C(pthis, globalCtx)) { + return 1; + } + + return 0; +} + +s32 func_80835884(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + func_80833638(pthis, func_808358F0); + LinkAnimation_PlayLoop(globalCtx, &pthis->skelAnime2, &gPlayerAnim_002638); + } + + func_80834EB8(pthis, globalCtx); + + return 1; +} + +s32 func_808358F0(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* animSeg = (LinkAnimationHeader*)pthis->skelAnime.animation; + + if ((func_808334E4(pthis) == animSeg) || (func_80833528(pthis) == animSeg) || (func_808335B0(pthis) == animSeg) || + (func_808335F4(pthis) == animSeg)) { + AnimationContext_SetCopyAll(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime2.jointTable, + pthis->skelAnime.jointTable); + } else { + LinkAnimation_Update(globalCtx, &pthis->skelAnime2); + } + + func_80834EB8(pthis, globalCtx); + + if (!D_80853618) { + func_80833638(pthis, func_808359FC); + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, + (pthis->unk_870 < 0.5f) ? &gPlayerAnim_002608 : &gPlayerAnim_002600); + } + + return 1; +} + +s32 func_808359FC(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + func_80833638(pthis, func_80835B60); + pthis->unk_834 = 0; + } else if (LinkAnimation_OnFrame(&pthis->skelAnime2, 6.0f)) { + f32 posX = (Math_SinS(pthis->actor.shape.rot.y) * 10.0f) + pthis->actor.world.pos.x; + f32 posZ = (Math_CosS(pthis->actor.shape.rot.y) * 10.0f) + pthis->actor.world.pos.z; + s32 yaw = (pthis->unk_664 != NULL) ? pthis->actor.shape.rot.y + 14000 : pthis->actor.shape.rot.y; + EnBoom* boomerang = + (EnBoom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOOM, posX, pthis->actor.world.pos.y + 30.0f, + posZ, pthis->actor.focus.rot.x, yaw, 0, 0); + + pthis->boomerangActor = &boomerang->actor; + if (boomerang != NULL) { + boomerang->moveTo = pthis->unk_664; + boomerang->returnTimer = 20; + pthis->stateFlags1 |= 0x2000000; + if (!func_8008E9C4(pthis)) { + func_808355DC(pthis); + } + pthis->unk_A73 = 4; + func_8002F7DC(&pthis->actor, NA_SE_IT_BOOMERANG_THROW); + func_80832698(pthis, NA_SE_VO_LI_SWORD_N); + } + } + + return 1; +} + +s32 func_80835B60(Player* pthis, GlobalContext* globalCtx) { + if (func_80834758(globalCtx, pthis)) { + return 1; + } + + if (!(pthis->stateFlags1 & 0x2000000)) { + func_80833638(pthis, func_80835C08); + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, &gPlayerAnim_0025F8); + func_808357E8(pthis, D_80125EF8); + func_8002F7DC(&pthis->actor, NA_SE_PL_CATCH_BOOMERANG); + func_80832698(pthis, NA_SE_VO_LI_SWORD_N); + return 1; + } + + return 0; +} + +s32 func_80835C08(Player* pthis, GlobalContext* globalCtx) { + if (!func_80835800(pthis, globalCtx) && LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + func_80833638(pthis, func_80835800); + } + + return 1; +} + +s32 func_80835C58(GlobalContext* globalCtx, Player* pthis, PlayerFunc674 func, s32 flags) { + if (func == pthis->func_674) { + return 0; + } + + if (func_8084E3C4 == pthis->func_674) { + Audio_OcaSetInstrument(0); + pthis->stateFlags2 &= ~0x3000000; + } else if (func_808507F4 == pthis->func_674) { + func_80832340(globalCtx, pthis); + } + + pthis->func_674 = func; + + if ((pthis->itemActionParam != pthis->heldItemActionParam) && (!(flags & 1) || !(pthis->stateFlags1 & 0x400000))) { + func_8008EC70(pthis); + } + + if (!(flags & 1) && (!(pthis->stateFlags1 & 0x800))) { + func_80834644(globalCtx, pthis); + pthis->stateFlags1 &= ~0x400000; + } + + func_80832DBC(pthis); + pthis->stateFlags1 &= ~0xB4000044; + pthis->stateFlags2 &= ~0x18080000; + pthis->stateFlags3 &= ~0x8A; + pthis->unk_84F = 0; + pthis->unk_850 = 0; + pthis->unk_6AC = 0; + func_808326F0(pthis); + + return 1; +} + +void func_80835DAC(GlobalContext* globalCtx, Player* pthis, PlayerFunc674 func, s32 flags) { + s32 temp; + + temp = pthis->skelAnime.moveFlags; + pthis->skelAnime.moveFlags = 0; + func_80835C58(globalCtx, pthis, func, flags); + pthis->skelAnime.moveFlags = temp; +} + +void func_80835DE4(GlobalContext* globalCtx, Player* pthis, PlayerFunc674 func, s32 flags) { + s32 temp; + + if (pthis->itemActionParam >= 0) { + temp = pthis->itemActionParam; + pthis->itemActionParam = pthis->heldItemActionParam; + func_80835C58(globalCtx, pthis, func, flags); + pthis->itemActionParam = temp; + Player_SetModels(pthis, Player_ActionToModelGroup(pthis, pthis->itemActionParam)); + } +} + +void func_80835E44(GlobalContext* globalCtx, s16 camSetting) { + if (!func_800C0CB8(globalCtx)) { + if (camSetting == CAM_SET_SCENE_TRANSITION) { + Interface_ChangeAlpha(2); + } + } else { + Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), camSetting); + } +} + +void func_80835EA4(GlobalContext* globalCtx, s32 arg1) { + func_80835E44(globalCtx, CAM_SET_TURN_AROUND); + Camera_SetCameraData(Gameplay_GetCamera(globalCtx, 0), 4, 0, 0, arg1, 0, 0); +} + +void func_80835EFC(Player* pthis) { + if (Player_HoldsHookshot(pthis)) { + Actor* heldActor = pthis->heldActor; + + if (heldActor != NULL) { + Actor_Kill(heldActor); + pthis->actor.child = NULL; + pthis->heldActor = NULL; + } + } +} + +void func_80835F44(GlobalContext* globalCtx, Player* pthis, s32 item) { + s8 actionParam; + s32 temp; + s32 nextType; + + actionParam = Player_ItemToActionParam(item); + + if (((pthis->heldItemActionParam == pthis->itemActionParam) && + (!(pthis->stateFlags1 & 0x400000) || (Player_ActionToSword(actionParam) != 0) || + (actionParam == PLAYER_AP_NONE))) || + ((pthis->itemActionParam < 0) && + ((Player_ActionToSword(actionParam) != 0) || (actionParam == PLAYER_AP_NONE)))) { + + if ((actionParam == PLAYER_AP_NONE) || !(pthis->stateFlags1 & 0x8000000) || + ((pthis->actor.bgCheckFlags & 1) && + ((actionParam == PLAYER_AP_HOOKSHOT) || (actionParam == PLAYER_AP_LONGSHOT)))) { + + if ((globalCtx->bombchuBowlingStatus == 0) && + (((actionParam == PLAYER_AP_STICK) && (AMMO(ITEM_STICK) == 0)) || + ((actionParam == PLAYER_AP_BEAN) && (AMMO(ITEM_BEAN) == 0)) || + (temp = Player_ActionToExplosive(pthis, actionParam), + ((temp >= 0) && ((AMMO(sExplosiveInfos[temp].itemId) == 0) || + (globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].length >= 3)))))) { + func_80078884(NA_SE_SY_ERROR); + return; + } + + if (actionParam == PLAYER_AP_LENS) { + if (func_80087708(globalCtx, 0, 3)) { + if (globalCtx->actorCtx.unk_03 != 0) { + func_800304B0(globalCtx); + } else { + globalCtx->actorCtx.unk_03 = 1; + } + func_80078884((globalCtx->actorCtx.unk_03 != 0) ? NA_SE_SY_GLASSMODE_ON : NA_SE_SY_GLASSMODE_OFF); + } else { + func_80078884(NA_SE_SY_ERROR); + } + return; + } + + if (actionParam == PLAYER_AP_NUT) { + if (AMMO(ITEM_NUT) != 0) { + func_8083C61C(globalCtx, pthis); + } else { + func_80078884(NA_SE_SY_ERROR); + } + return; + } + + temp = Player_ActionToMagicSpell(pthis, actionParam); + if (temp >= 0) { + if (((actionParam == PLAYER_AP_FARORES_WIND) && (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 0)) || + ((gSaveContext.unk_13F4 != 0) && (gSaveContext.unk_13F0 == 0) && + (gSaveContext.magic >= sMagicSpellCosts[temp]))) { + pthis->itemActionParam = actionParam; + pthis->unk_6AD = 4; + } else { + func_80078884(NA_SE_SY_ERROR); + } + return; + } + + if (actionParam >= PLAYER_AP_MASK_KEATON) { + if (pthis->currentMask != PLAYER_MASK_NONE) { + pthis->currentMask = PLAYER_MASK_NONE; + } else { + pthis->currentMask = actionParam - PLAYER_AP_MASK_KEATON + 1; + } + func_808328EC(pthis, NA_SE_PL_CHANGE_ARMS); + return; + } + + if (((actionParam >= PLAYER_AP_OCARINA_FAIRY) && (actionParam <= PLAYER_AP_OCARINA_TIME)) || + (actionParam >= PLAYER_AP_BOTTLE_FISH)) { + if (!func_8008E9C4(pthis) || + ((actionParam >= PLAYER_AP_BOTTLE_POTION_RED) && (actionParam <= PLAYER_AP_BOTTLE_FAIRY))) { + func_8002D53C(globalCtx, &globalCtx->actorCtx.titleCtx); + pthis->unk_6AD = 4; + pthis->itemActionParam = actionParam; + } + return; + } + + if ((actionParam != pthis->heldItemActionParam) || + ((pthis->heldActor == 0) && (Player_ActionToExplosive(pthis, actionParam) >= 0))) { + pthis->nextModelGroup = Player_ActionToModelGroup(pthis, actionParam); + nextType = gPlayerModelTypes[pthis->nextModelGroup][0]; + if ((pthis->heldItemActionParam >= 0) && (Player_ActionToMagicSpell(pthis, actionParam) < 0) && + (item != pthis->heldItemId) && (D_80854164[gPlayerModelTypes[pthis->modelGroup][0]][nextType] != 0)) { + pthis->heldItemId = item; + pthis->stateFlags1 |= 0x100; + } else { + func_80835EFC(pthis); + func_808323B4(globalCtx, pthis); + func_80833664(globalCtx, pthis, actionParam); + } + return; + } + + D_80853614 = D_80853618 = true; + } + } +} + +void func_80836448(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + s32 cond = func_808332B8(pthis); + + func_80832564(globalCtx, pthis); + + func_80835C58(globalCtx, pthis, cond ? func_8084E368 : func_80843CEC, 0); + + pthis->stateFlags1 |= 0x80; + + func_80832264(globalCtx, pthis, anim); + if (anim == &gPlayerAnim_002878) { + pthis->skelAnime.endFrame = 84.0f; + } + + func_80832224(pthis); + func_80832698(pthis, NA_SE_VO_LI_DOWN); + + if (pthis->actor.category == ACTORCAT_PLAYER) { + func_800F47BC(); + + if (Inventory_ConsumeFairy(globalCtx)) { + globalCtx->gameOverCtx.state = GAMEOVER_REVIVE_START; + pthis->unk_84F = 1; + } else { + globalCtx->gameOverCtx.state = GAMEOVER_DEATH_START; + func_800F6AB0(0); + Audio_PlayFanfare(NA_BGM_GAME_OVER); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.natureAmbienceId = 0xFF; + } + + OnePointCutscene_Init(globalCtx, 9806, cond ? 120 : 60, &pthis->actor, MAIN_CAM); + ShrinkWindow_SetVal(0x20); + } +} + +s32 func_808365C8(Player* pthis) { + return (!(func_808458D0 == pthis->func_674) || + ((pthis->stateFlags1 & 0x100) && + ((pthis->heldItemId == ITEM_LAST_USED) || (pthis->heldItemId == ITEM_NONE)))) && + (!(func_80834A2C == pthis->func_82C) || + (Player_ItemToActionParam(pthis->heldItemId) == pthis->heldItemActionParam)); +} + +s32 func_80836670(Player* pthis, GlobalContext* globalCtx) { + if (!(pthis->stateFlags1 & 0x800000) && (pthis->actor.parent != NULL) && Player_HoldsHookshot(pthis)) { + func_80835C58(globalCtx, pthis, func_80850AEC, 1); + pthis->stateFlags3 |= 0x80; + func_80832264(globalCtx, pthis, &gPlayerAnim_002C90); + func_80832F54(globalCtx, pthis, 0x9B); + func_80832224(pthis); + pthis->currentYaw = pthis->actor.shape.rot.y; + pthis->actor.bgCheckFlags &= ~1; + pthis->hoverBootsTimer = 0; + pthis->unk_6AE |= 0x43; + func_80832698(pthis, NA_SE_VO_LI_LASH); + return 1; + } + + if (func_808365C8(pthis)) { + func_80834298(pthis, globalCtx); + if (func_8084E604 == pthis->func_674) { + return 1; + } + } + + if (!pthis->func_82C(pthis, globalCtx)) { + return 0; + } + + if (pthis->unk_830 != 0.0f) { + if ((func_80833350(pthis) == 0) || (pthis->linearVelocity != 0.0f)) { + AnimationContext_SetCopyFalse(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime2.jointTable, + pthis->skelAnime.jointTable, D_80853410); + } + Math_StepToF(&pthis->unk_830, 0.0f, 0.25f); + AnimationContext_SetInterp(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->skelAnime2.jointTable, 1.0f - pthis->unk_830); + } else if ((func_80833350(pthis) == 0) || (pthis->linearVelocity != 0.0f)) { + AnimationContext_SetCopyTrue(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->skelAnime2.jointTable, D_80853410); + } else { + AnimationContext_SetCopyAll(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->skelAnime2.jointTable); + } + + return 1; +} + +s32 func_80836898(GlobalContext* globalCtx, Player* pthis, PlayerFuncA74 func) { + pthis->func_A74 = func; + func_80835C58(globalCtx, pthis, func_808458D0, 0); + pthis->stateFlags2 |= 0x40; + return func_80832528(globalCtx, pthis); +} + +void func_808368EC(Player* pthis, GlobalContext* globalCtx) { + s16 previousYaw = pthis->actor.shape.rot.y; + + if (!(pthis->stateFlags2 & 0x60)) { + if ((pthis->unk_664 != NULL) && + ((globalCtx->actorCtx.targetCtx.unk_4B != 0) || (pthis->actor.category != ACTORCAT_PLAYER))) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, + Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->unk_664->focus.pos), 4000); + } else if ((pthis->stateFlags1 & 0x20000) && !(pthis->stateFlags2 & 0x60)) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->targetYaw, 4000); + } + } else if (!(pthis->stateFlags2 & 0x40)) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->currentYaw, 2000); + } + + pthis->unk_87C = pthis->actor.shape.rot.y - previousYaw; +} + +s32 func_808369C8(s16* pValue, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5) { + s16 temp1; + s16 temp2; + s16 temp3; + + temp1 = temp2 = arg4 - *pValue; + temp2 = CLAMP(temp2, -arg5, arg5); + *pValue += (s16)(temp1 - temp2); + + Math_ScaledStepToS(pValue, arg1, arg2); + + temp3 = *pValue; + if (*pValue < -arg3) { + *pValue = -arg3; + } else if (*pValue > arg3) { + *pValue = arg3; + } + return temp3 - *pValue; +} + +s32 func_80836AB8(Player* pthis, s32 arg1) { + s16 sp36; + s16 var; + + var = pthis->actor.shape.rot.y; + if (arg1 != 0) { + var = pthis->actor.focus.rot.y; + pthis->unk_6BC = pthis->actor.focus.rot.x; + pthis->unk_6AE |= 0x41; + } else { + func_808369C8(&pthis->unk_6BC, + func_808369C8(&pthis->unk_6B6, pthis->actor.focus.rot.x, 600, 10000, pthis->actor.focus.rot.x, 0), + 200, 4000, pthis->unk_6B6, 10000); + sp36 = pthis->actor.focus.rot.y - var; + func_808369C8(&sp36, 0, 200, 24000, pthis->unk_6BE, 8000); + var = pthis->actor.focus.rot.y - sp36; + func_808369C8(&pthis->unk_6B8, sp36 - pthis->unk_6BE, 200, 8000, sp36, 8000); + func_808369C8(&pthis->unk_6BE, sp36, 200, 8000, pthis->unk_6B8, 8000); + pthis->unk_6AE |= 0xD9; + } + + return var; +} + +void func_80836BEC(Player* pthis, GlobalContext* globalCtx) { + s32 sp1C = 0; + s32 zTrigPressed = CHECK_BTN_ALL(sControlInput->cur.button, BTN_Z); + Actor* actorToTarget; + s32 pad; + s32 holdTarget; + s32 cond; + + if (!zTrigPressed) { + pthis->stateFlags1 &= ~0x40000000; + } + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) || (pthis->csMode != 0) || (pthis->stateFlags1 & 0x20000080) || + (pthis->stateFlags3 & 0x80)) { + pthis->unk_66C = 0; + } else if (zTrigPressed || (pthis->stateFlags2 & 0x2000) || (pthis->unk_684 != NULL)) { + if (pthis->unk_66C <= 5) { + pthis->unk_66C = 5; + } else { + pthis->unk_66C--; + } + } else if (pthis->stateFlags1 & 0x20000) { + pthis->unk_66C = 0; + } else if (pthis->unk_66C != 0) { + pthis->unk_66C--; + } + + if (pthis->unk_66C >= 6) { + sp1C = 1; + } + + cond = func_8083224C(globalCtx); + if (cond || (pthis->unk_66C != 0) || (pthis->stateFlags1 & 0x2001000)) { + if (!cond) { + if (!(pthis->stateFlags1 & 0x2000000) && + ((pthis->heldItemActionParam != PLAYER_AP_FISHING_POLE) || (pthis->unk_860 == 0)) && + CHECK_BTN_ALL(sControlInput->press.button, BTN_Z)) { + + if (pthis->actor.category == ACTORCAT_PLAYER) { + actorToTarget = globalCtx->actorCtx.targetCtx.arrowPointedActor; + } else { + actorToTarget = &GET_PLAYER(globalCtx)->actor; + } + + holdTarget = (gSaveContext.zTargetSetting != 0) || (pthis->actor.category != ACTORCAT_PLAYER); + pthis->stateFlags1 |= 0x8000; + + if ((actorToTarget != NULL) && !(actorToTarget->flags & ACTOR_FLAG_27)) { + if ((actorToTarget == pthis->unk_664) && (pthis->actor.category == ACTORCAT_PLAYER)) { + actorToTarget = globalCtx->actorCtx.targetCtx.unk_94; + } + + if (actorToTarget != pthis->unk_664) { + if (!holdTarget) { + pthis->stateFlags2 |= 0x2000; + } + pthis->unk_664 = actorToTarget; + pthis->unk_66C = 15; + pthis->stateFlags2 &= ~0x200002; + } else { + if (!holdTarget) { + func_8008EDF0(pthis); + } + } + + pthis->stateFlags1 &= ~0x40000000; + } else { + if (!(pthis->stateFlags1 & 0x40020000)) { + func_808355DC(pthis); + } + } + } + + if (pthis->unk_664 != NULL) { + if ((pthis->actor.category == ACTORCAT_PLAYER) && (pthis->unk_664 != pthis->unk_684) && + func_8002F0C8(pthis->unk_664, pthis, sp1C)) { + func_8008EDF0(pthis); + pthis->stateFlags1 |= 0x40000000; + } else if (pthis->unk_664 != NULL) { + pthis->unk_664->targetPriority = 40; + } + } else if (pthis->unk_684 != NULL) { + pthis->unk_664 = pthis->unk_684; + } + } + + if (pthis->unk_664 != NULL) { + pthis->stateFlags1 &= ~0x30000; + if ((pthis->stateFlags1 & 0x800) || !CHECK_FLAG_ALL(pthis->unk_664->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2)) { + pthis->stateFlags1 |= 0x10000; + } + } else { + if (pthis->stateFlags1 & 0x20000) { + pthis->stateFlags2 &= ~0x2000; + } else { + func_8008EE08(pthis); + } + } + } else { + func_8008EE08(pthis); + } +} + +s32 func_80836FAC(GlobalContext* globalCtx, Player* pthis, f32* arg2, s16* arg3, f32 arg4) { + f32 temp_f2; + f32 temp_f0; + f32 temp_f14; + f32 temp_f12; + + if ((pthis->unk_6AD != 0) || (globalCtx->sceneLoadFlag == 0x14) || (pthis->stateFlags1 & 1)) { + *arg2 = 0.0f; + *arg3 = pthis->actor.shape.rot.y; + } else { + *arg2 = D_808535D4; + *arg3 = D_808535D8; + + if (arg4 != 0.0f) { + *arg2 -= 20.0f; + if (*arg2 < 0.0f) { + *arg2 = 0.0f; + } else { + temp_f2 = 1.0f - Math_CosS(*arg2 * 450.0f); + *arg2 = ((temp_f2 * temp_f2) * 30.0f) + 7.0f; + } + } else { + *arg2 *= 0.8f; + } + + if (D_808535D4 != 0.0f) { + temp_f0 = Math_SinS(pthis->unk_898); + temp_f12 = pthis->unk_880; + temp_f14 = CLAMP(temp_f0, 0.0f, 0.6f); + + if (pthis->unk_6C4 != 0.0f) { + temp_f12 = temp_f12 - (pthis->unk_6C4 * 0.008f); + if (temp_f12 < 2.0f) { + temp_f12 = 2.0f; + } + } + + *arg2 = (*arg2 * 0.14f) - (8.0f * temp_f14 * temp_f14); + *arg2 = CLAMP(*arg2, 0.0f, temp_f12); + + return 1; + } + } + + return 0; +} + +s32 func_8083721C(Player* pthis) { + return Math_StepToF(&pthis->linearVelocity, 0.0f, REG(43) / 100.0f); +} + +s32 func_80837268(Player* pthis, f32* arg1, s16* arg2, f32 arg3, GlobalContext* globalCtx) { + if (!func_80836FAC(globalCtx, pthis, arg1, arg2, arg3)) { + *arg2 = pthis->actor.shape.rot.y; + + if (pthis->unk_664 != NULL) { + if ((globalCtx->actorCtx.targetCtx.unk_4B != 0) && !(pthis->stateFlags2 & 0x40)) { + *arg2 = Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->unk_664->focus.pos); + return 0; + } + } else if (func_80833B2C(pthis)) { + *arg2 = pthis->targetYaw; + } + + return 0; + } else { + *arg2 += Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); + return 1; + } +} + +static s8 D_808543E0[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; +static s8 D_808543E8[] = { 13, 1, 2, 5, 3, 4, 9, 10, 11, 7, 8, -6 }; +static s8 D_808543F4[] = { 13, 1, 2, 3, 4, 9, 10, 11, 8, 7, -6 }; +static s8 D_80854400[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; +static s8 D_80854408[] = { 13, 2, 4, 9, 10, 11, 12, 8, -7 }; +static s8 D_80854414[] = { -7 }; +static s8 D_80854418[] = { 0, 11, 1, 2, 3, 5, 4, 9, 8, 7, -6 }; +static s8 D_80854424[] = { 0, 11, 1, 2, 3, 12, 5, 4, 9, 8, 7, -6 }; +static s8 D_80854430[] = { 13, 1, 2, 3, 12, 5, 4, 9, 10, 11, 8, 7, -6 }; +static s8 D_80854440[] = { 10, 8, -7 }; +static s8 D_80854444[] = { 0, 12, 5, -4 }; + +static s32 (*D_80854448[])(Player* pthis, GlobalContext* globalCtx) = { + func_8083B998, func_80839800, func_8083E5A8, func_8083E0FC, func_8083B644, func_8083F7BC, func_8083C1DC, + func_80850224, func_8083C544, func_8083EB44, func_8083BDBC, func_8083C2B0, func_80838A14, func_8083B040, +}; + +s32 func_80837348(GlobalContext* globalCtx, Player* pthis, s8* arg2, s32 arg3) { + s32 i; + + if (!(pthis->stateFlags1 & 0x20000081)) { + if (arg3 != 0) { + D_808535E0 = func_80836670(pthis, globalCtx); + if (func_8084E604 == pthis->func_674) { + return 1; + } + } + + if (func_8008F128(pthis)) { + pthis->unk_6AE |= 0x41; + return 1; + } + + if (!(pthis->stateFlags1 & 0x100) && (func_80834A2C != pthis->func_82C)) { + while (*arg2 >= 0) { + if (D_80854448[*arg2](pthis, globalCtx)) { + return 1; + } + arg2++; + } + + if (D_80854448[-(*arg2)](pthis, globalCtx)) { + return 1; + } + } + } + + return 0; +} + +s32 func_808374A0(GlobalContext* globalCtx, Player* pthis, SkelAnime* skelAnime, f32 arg3) { + f32 sp24; + s16 sp22; + + if ((skelAnime->endFrame - arg3) <= skelAnime->curFrame) { + if (func_80837348(globalCtx, pthis, D_80854418, 1)) { + return 0; + } + + if (func_80837268(pthis, &sp24, &sp22, 0.018f, globalCtx)) { + return 1; + } + } + + return -1; +} + +void func_80837530(GlobalContext* globalCtx, Player* pthis, s32 arg2) { + if (arg2 != 0) { + pthis->unk_858 = 0.0f; + } else { + pthis->unk_858 = 0.5f; + } + + pthis->stateFlags1 |= 0x1000; + + if (pthis->actor.category == ACTORCAT_PLAYER) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_M_THUNDER, pthis->bodyPartsPos[0].x, + pthis->bodyPartsPos[0].y, pthis->bodyPartsPos[0].z, 0, 0, 0, Player_GetSwordHeld(pthis) | arg2); + } +} + +s32 func_808375D8(Player* pthis) { + s8 sp3C[4]; + s8* iter; + s8* iter2; + s8 temp1; + s8 temp2; + s32 i; + + if ((pthis->heldItemActionParam == PLAYER_AP_STICK) || Player_HoldsBrokenKnife(pthis)) { + return 0; + } + + iter = &pthis->unk_847[0]; + iter2 = &sp3C[0]; + for (i = 0; i < 4; i++, iter++, iter2++) { + if ((*iter2 = *iter) < 0) { + return 0; + } + *iter2 *= 2; + } + + temp1 = sp3C[0] - sp3C[1]; + if (ABS(temp1) < 10) { + return 0; + } + + iter2 = &sp3C[1]; + for (i = 1; i < 3; i++, iter2++) { + temp2 = *iter2 - *(iter2 + 1); + if ((ABS(temp2) < 10) || (temp2 * temp1 < 0)) { + return 0; + } + } + + return 1; +} + +void func_80837704(GlobalContext* globalCtx, Player* pthis) { + LinkAnimationHeader* anim; + + if ((pthis->swordAnimation >= 4) && (pthis->swordAnimation < 8)) { + anim = D_80854358[Player_HoldsTwoHandedWeapon(pthis)]; + } else { + anim = D_80854350[Player_HoldsTwoHandedWeapon(pthis)]; + } + + func_80832318(pthis); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, 8.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + -9.0f); + func_80837530(globalCtx, pthis, 0x200); +} + +void func_808377DC(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_80844E68, 1); + func_80837704(globalCtx, pthis); +} + +static s8 D_80854480[] = { 12, 4, 4, 8 }; +static s8 D_80854484[] = { 22, 23, 22, 23 }; + +s32 func_80837818(Player* pthis) { + s32 sp1C = pthis->unk_84B[pthis->unk_846]; + s32 sp18; + + if (pthis->heldItemActionParam == PLAYER_AP_HAMMER) { + if (sp1C < 0) { + sp1C = 0; + } + sp18 = D_80854484[sp1C]; + pthis->unk_845 = 0; + } else { + if (func_808375D8(pthis)) { + sp18 = 24; + } else { + if (sp1C < 0) { + if (func_80833BCC(pthis)) { + sp18 = 0; + } else { + sp18 = 4; + } + } else { + sp18 = D_80854480[sp1C]; + if (sp18 == 12) { + pthis->stateFlags2 |= 0x40000000; + if (!func_80833BCC(pthis)) { + sp18 = 0; + } + } + } + if (pthis->heldItemActionParam == PLAYER_AP_STICK) { + sp18 = 0; + } + } + if (Player_HoldsTwoHandedWeapon(pthis)) { + sp18++; + } + } + + return sp18; +} + +void func_80837918(Player* pthis, s32 quadIndex, u32 flags) { + pthis->swordQuads[quadIndex].info.toucher.dmgFlags = flags; + + if (flags == 2) { + pthis->swordQuads[quadIndex].info.toucherFlags = TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_WOOD; + } else { + pthis->swordQuads[quadIndex].info.toucherFlags = TOUCH_ON | TOUCH_NEAREST; + } +} + +static u32 D_80854488[][2] = { + { 0x00000200, 0x08000000 }, { 0x00000100, 0x02000000 }, { 0x00000400, 0x04000000 }, + { 0x00000002, 0x08000000 }, { 0x00000040, 0x40000000 }, +}; + +void func_80837948(GlobalContext* globalCtx, Player* pthis, s32 arg2) { + s32 pad; + u32 flags; + s32 temp; + + func_80835C58(globalCtx, pthis, func_808502D0, 0); + pthis->unk_844 = 8; + if ((arg2 < 18) || (arg2 >= 20)) { + func_80832318(pthis); + } + + if ((arg2 != pthis->swordAnimation) || !(pthis->unk_845 < 3)) { + pthis->unk_845 = 0; + } + + pthis->unk_845++; + if (pthis->unk_845 >= 3) { + arg2 += 2; + } + + pthis->swordAnimation = arg2; + + func_808322D0(globalCtx, pthis, D_80854190[arg2].unk_00); + if ((arg2 != 16) && (arg2 != 17)) { + func_80832F54(globalCtx, pthis, 0x209); + } + + pthis->currentYaw = pthis->actor.shape.rot.y; + + if (Player_HoldsBrokenKnife(pthis)) { + temp = 1; + } else { + temp = Player_GetSwordHeld(pthis) - 1; + } + + if ((arg2 >= 16) && (arg2 < 20)) { + flags = D_80854488[temp][1]; + } else { + flags = D_80854488[temp][0]; + } + + func_80837918(pthis, 0, flags); + func_80837918(pthis, 1, flags); +} + +void func_80837AE0(Player* pthis, s32 timer) { + if (pthis->invincibilityTimer >= 0) { + pthis->invincibilityTimer = timer; + pthis->unk_88F = 0; + } +} + +void func_80837AFC(Player* pthis, s32 timer) { + if (pthis->invincibilityTimer > timer) { + pthis->invincibilityTimer = timer; + } + pthis->unk_88F = 0; +} + +s32 func_80837B18(GlobalContext* globalCtx, Player* pthis, s32 damage) { + if ((pthis->invincibilityTimer != 0) || (pthis->actor.category != ACTORCAT_PLAYER)) { + return 1; + } + + return Health_ChangeBy(globalCtx, damage); +} + +void func_80837B60(Player* pthis) { + pthis->skelAnime.prevTransl = pthis->skelAnime.jointTable[0]; + func_80832E48(pthis, 3); +} + +void func_80837B9C(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084411C, 0); + func_80832284(globalCtx, pthis, &gPlayerAnim_003040); + pthis->unk_850 = 1; + if (pthis->unk_6AD != 3) { + pthis->unk_6AD = 0; + } +} + +static LinkAnimationHeader* D_808544B0[] = { + &gPlayerAnim_002F80, &gPlayerAnim_002F78, &gPlayerAnim_002DE0, &gPlayerAnim_002DD8, + &gPlayerAnim_002F70, &gPlayerAnim_002528, &gPlayerAnim_002DC8, &gPlayerAnim_0024F0, +}; + +void func_80837C0C(GlobalContext* globalCtx, Player* pthis, s32 arg2, f32 arg3, f32 arg4, s16 arg5, s32 arg6) { + LinkAnimationHeader* sp2C = NULL; + LinkAnimationHeader** sp28; + + if (pthis->stateFlags1 & 0x2000) { + func_80837B60(pthis); + } + + pthis->unk_890 = 0; + + func_8002F7DC(&pthis->actor, NA_SE_PL_DAMAGE); + + if (!func_80837B18(globalCtx, pthis, 0 - pthis->actor.colChkInfo.damage)) { + pthis->stateFlags2 &= ~0x80; + if (!(pthis->actor.bgCheckFlags & 1) && !(pthis->stateFlags1 & 0x8000000)) { + func_80837B9C(pthis, globalCtx); + } + return; + } + + func_80837AE0(pthis, arg6); + + if (arg2 == 3) { + func_80835C58(globalCtx, pthis, func_8084FB10, 0); + + sp2C = &gPlayerAnim_002FD0; + + func_80832224(pthis); + func_8083264C(pthis, 255, 10, 40, 0); + + func_8002F7DC(&pthis->actor, NA_SE_PL_FREEZE_S); + func_80832698(pthis, NA_SE_VO_LI_FREEZE); + } else if (arg2 == 4) { + func_80835C58(globalCtx, pthis, func_8084FBF4, 0); + + func_8083264C(pthis, 255, 80, 150, 0); + + func_808322A4(globalCtx, pthis, &gPlayerAnim_002F00); + func_80832224(pthis); + + pthis->unk_850 = 20; + } else { + arg5 -= pthis->actor.shape.rot.y; + if (pthis->stateFlags1 & 0x8000000) { + func_80835C58(globalCtx, pthis, func_8084E30C, 0); + func_8083264C(pthis, 180, 20, 50, 0); + + pthis->linearVelocity = 4.0f; + pthis->actor.velocity.y = 0.0f; + + sp2C = &gPlayerAnim_003320; + + func_80832698(pthis, NA_SE_VO_LI_DAMAGE_S); + } else if ((arg2 == 1) || (arg2 == 2) || !(pthis->actor.bgCheckFlags & 1) || (pthis->stateFlags1 & 0x206000)) { + func_80835C58(globalCtx, pthis, func_8084377C, 0); + + pthis->stateFlags3 |= 2; + + func_8083264C(pthis, 255, 20, 150, 0); + func_80832224(pthis); + + if (arg2 == 2) { + pthis->unk_850 = 4; + + pthis->actor.speedXZ = 3.0f; + pthis->linearVelocity = 3.0f; + pthis->actor.velocity.y = 6.0f; + + func_80832C2C(globalCtx, pthis, D_8085395C[pthis->modelAnimType]); + func_80832698(pthis, NA_SE_VO_LI_DAMAGE_S); + } else { + pthis->actor.speedXZ = arg3; + pthis->linearVelocity = arg3; + pthis->actor.velocity.y = arg4; + + if (ABS(arg5) > 0x4000) { + sp2C = &gPlayerAnim_002F58; + } else { + sp2C = &gPlayerAnim_002DB0; + } + + if ((pthis->actor.category != ACTORCAT_PLAYER) && (pthis->actor.colChkInfo.health == 0)) { + func_80832698(pthis, NA_SE_VO_BL_DOWN); + } else { + func_80832698(pthis, NA_SE_VO_LI_FALL_L); + } + } + + pthis->hoverBootsTimer = 0; + pthis->actor.bgCheckFlags &= ~1; + } else { + if ((pthis->linearVelocity > 4.0f) && !func_8008E9C4(pthis)) { + pthis->unk_890 = 20; + func_8083264C(pthis, 120, 20, 10, 0); + func_80832698(pthis, NA_SE_VO_LI_DAMAGE_S); + return; + } + + sp28 = D_808544B0; + + func_80835C58(globalCtx, pthis, func_8084370C, 0); + func_80833C3C(pthis); + + if (pthis->actor.colChkInfo.damage < 5) { + func_8083264C(pthis, 120, 20, 10, 0); + } else { + func_8083264C(pthis, 180, 20, 100, 0); + pthis->linearVelocity = 23.0f; + sp28 += 4; + } + + if (ABS(arg5) <= 0x4000) { + sp28 += 2; + } + + if (func_8008E9C4(pthis)) { + sp28 += 1; + } + + sp2C = *sp28; + + func_80832698(pthis, NA_SE_VO_LI_DAMAGE_S); + } + + pthis->actor.shape.rot.y += arg5; + pthis->currentYaw = pthis->actor.shape.rot.y; + pthis->actor.world.rot.y = pthis->actor.shape.rot.y; + if (ABS(arg5) > 0x4000) { + pthis->actor.shape.rot.y += 0x8000; + } + } + + func_80832564(globalCtx, pthis); + + pthis->stateFlags1 |= 0x4000000; + + if (sp2C != NULL) { + func_808322D0(globalCtx, pthis, sp2C); + } +} + +s32 func_80838144(s32 arg0) { + s32 temp = arg0 - 2; + + if ((temp >= 0) && (temp < 2)) { + return temp; + } else { + return -1; + } +} + +s32 func_8083816C(s32 arg0) { + return (arg0 == 4) || (arg0 == 7) || (arg0 == 12); +} + +void func_8083819C(Player* pthis, GlobalContext* globalCtx) { + if (pthis->currentShield == PLAYER_SHIELD_DEKU) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_SHIELD, pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 1); + Inventory_DeleteEquipment(globalCtx, EQUIP_SHIELD); + Message_StartTextbox(globalCtx, 0x305F, NULL); + } +} + +void func_8083821C(Player* pthis) { + s32 i; + + // clang-format off + for (i = 0; i < 18; i++) { pthis->flameTimers[i] = Rand_S16Offset(0, 200); } + // clang-format on + + pthis->isBurning = true; +} + +void func_80838280(Player* pthis) { + if (pthis->actor.colChkInfo.acHitEffect == 1) { + func_8083821C(pthis); + } + func_80832698(pthis, NA_SE_VO_LI_FALL_L); +} + +void func_808382BC(Player* pthis) { + if ((pthis->invincibilityTimer >= 0) && (pthis->invincibilityTimer < 20)) { + pthis->invincibilityTimer = 20; + } +} + +s32 func_808382DC(Player* pthis, GlobalContext* globalCtx) { + s32 pad; + s32 sp68 = false; + s32 sp64; + + if (pthis->unk_A86 != 0) { + if (!Player_InBlockingCsMode(globalCtx, pthis)) { + Player_InflictDamage(globalCtx, -16); + pthis->unk_A86 = 0; + } + } else { + sp68 = ((Player_GetHeight(pthis) - 8.0f) < (pthis->unk_6C4 * pthis->actor.scale.y)); + + if (sp68 || (pthis->actor.bgCheckFlags & 0x100) || (D_808535E4 == 9) || (pthis->stateFlags2 & 0x80000000)) { + func_80832698(pthis, NA_SE_VO_LI_DAMAGE_S); + + if (sp68) { + Gameplay_TriggerRespawn(globalCtx); + func_800994A0(globalCtx); + } else { + // Special case for getting crushed in Forest Temple's Checkboard Ceiling Hall or Shadow Temple's + // Falling Spike Trap Room, to respawn the player in a specific place + if (((globalCtx->sceneNum == SCENE_BMORI1) && (globalCtx->roomCtx.curRoom.num == 15)) || + ((globalCtx->sceneNum == SCENE_HAKADAN) && (globalCtx->roomCtx.curRoom.num == 10))) { + static SpecialRespawnInfo checkboardCeilingRespawn = { { 1992.0f, 403.0f, -3432.0f }, 0 }; + static SpecialRespawnInfo fallingSpikeTrapRespawn = { { 1200.0f, -1343.0f, 3850.0f }, 0 }; + SpecialRespawnInfo* respawnInfo; + + if (globalCtx->sceneNum == SCENE_BMORI1) { + respawnInfo = &checkboardCeilingRespawn; + } else { + respawnInfo = &fallingSpikeTrapRespawn; + } + + Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_DOWN, 0xDFF); + gSaveContext.respawn[RESPAWN_MODE_DOWN].pos = respawnInfo->pos; + gSaveContext.respawn[RESPAWN_MODE_DOWN].yaw = respawnInfo->yaw; + } + + Gameplay_TriggerVoidOut(globalCtx); + } + + func_80832698(pthis, NA_SE_VO_LI_TAKEN_AWAY); + globalCtx->unk_11DE9 = 1; + func_80078884(NA_SE_OC_ABYSS); + } else if ((pthis->unk_8A1 != 0) && ((pthis->unk_8A1 >= 2) || (pthis->invincibilityTimer == 0))) { + u8 sp5C[] = { 2, 1, 1 }; + + func_80838280(pthis); + + if (pthis->unk_8A1 == 3) { + pthis->shockTimer = 40; + } + + pthis->actor.colChkInfo.damage += pthis->unk_8A0; + func_80837C0C(globalCtx, pthis, sp5C[pthis->unk_8A1 - 1], pthis->unk_8A4, pthis->unk_8A8, pthis->unk_8A2, 20); + } else { + sp64 = (pthis->shieldQuad.base.acFlags & AC_BOUNCED) != 0; + + //! @bug The second set of conditions here seems intended as a way for Link to "block" hits by rolling. + // However, `Collider.atFlags` is a byte so the flag check at the end is incorrect and cannot work. + // Additionally, `Collider.atHit` can never be set while already colliding as AC, so it's also bugged. + // This behavior was later fixed in MM, most likely by removing both the `atHit` and `atFlags` checks. + if (sp64 || ((pthis->invincibilityTimer < 0) && (pthis->cylinder.base.acFlags & AC_HIT) && + (pthis->cylinder.info.atHit != NULL) && (pthis->cylinder.info.atHit->atFlags & 0x20000000))) { + + func_8083264C(pthis, 180, 20, 100, 0); + + if (!Player_IsChildWithHylianShield(pthis)) { + if (pthis->invincibilityTimer >= 0) { + LinkAnimationHeader* anim; + s32 sp54 = func_80843188 == pthis->func_674; + + if (!func_808332B8(pthis)) { + func_80835C58(globalCtx, pthis, func_808435C4, 0); + } + + if (!(pthis->unk_84F = sp54)) { + func_80833638(pthis, func_80834BD4); + + if (pthis->unk_870 < 0.5f) { + anim = D_808543BC[Player_HoldsTwoHandedWeapon(pthis)]; + } else { + anim = D_808543B4[Player_HoldsTwoHandedWeapon(pthis)]; + } + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, anim); + } else { + func_80832264(globalCtx, pthis, D_808543C4[Player_HoldsTwoHandedWeapon(pthis)]); + } + } + + if (!(pthis->stateFlags1 & 0x206000)) { + pthis->linearVelocity = -18.0f; + pthis->currentYaw = pthis->actor.shape.rot.y; + } + } + + if (sp64 && (pthis->shieldQuad.info.acHitInfo->toucher.effect == 1)) { + func_8083819C(pthis, globalCtx); + } + + return 0; + } + + if ((pthis->unk_A87 != 0) || (pthis->invincibilityTimer > 0) || (pthis->stateFlags1 & 0x4000000) || + (pthis->csMode != 0) || (pthis->swordQuads[0].base.atFlags & AT_HIT) || + (pthis->swordQuads[1].base.atFlags & AT_HIT)) { + return 0; + } + + if (pthis->cylinder.base.acFlags & AC_HIT) { + Actor* ac = pthis->cylinder.base.ac; + s32 sp4C; + + if (ac->flags & ACTOR_FLAG_24) { + func_8002F7DC(&pthis->actor, NA_SE_PL_BODY_HIT); + } + + if (pthis->stateFlags1 & 0x8000000) { + sp4C = 0; + } else if (pthis->actor.colChkInfo.acHitEffect == 2) { + sp4C = 3; + } else if (pthis->actor.colChkInfo.acHitEffect == 3) { + sp4C = 4; + } else if (pthis->actor.colChkInfo.acHitEffect == 4) { + sp4C = 1; + } else { + func_80838280(pthis); + sp4C = 0; + } + + func_80837C0C(globalCtx, pthis, sp4C, 4.0f, 5.0f, Actor_WorldYawTowardActor(ac, &pthis->actor), 20); + } else if (pthis->invincibilityTimer != 0) { + return 0; + } else { + static u8 D_808544F4[] = { 120, 60 }; + s32 sp48 = func_80838144(D_808535E4); + + if (((pthis->actor.wallPoly != NULL) && + SurfaceType_IsWallDamage(&globalCtx->colCtx, pthis->actor.wallPoly, pthis->actor.wallBgId)) || + ((sp48 >= 0) && + SurfaceType_IsWallDamage(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId) && + (pthis->unk_A79 >= D_808544F4[sp48])) || + ((sp48 >= 0) && + ((pthis->currentTunic != PLAYER_TUNIC_GORON) || (pthis->unk_A79 >= D_808544F4[sp48])))) { + pthis->unk_A79 = 0; + pthis->actor.colChkInfo.damage = 4; + func_80837C0C(globalCtx, pthis, 0, 4.0f, 5.0f, pthis->actor.shape.rot.y, 20); + } else { + return 0; + } + } + } + } + + return 1; +} + +void func_80838940(Player* pthis, LinkAnimationHeader* anim, f32 arg2, GlobalContext* globalCtx, u16 sfxId) { + func_80835C58(globalCtx, pthis, func_8084411C, 1); + + if (anim != NULL) { + func_808322D0(globalCtx, pthis, anim); + } + + pthis->actor.velocity.y = arg2 * D_808535E8; + pthis->hoverBootsTimer = 0; + pthis->actor.bgCheckFlags &= ~1; + + func_80832854(pthis); + func_80832698(pthis, sfxId); + + pthis->stateFlags1 |= 0x40000; +} + +void func_808389E8(Player* pthis, LinkAnimationHeader* anim, f32 arg2, GlobalContext* globalCtx) { + func_80838940(pthis, anim, arg2, globalCtx, NA_SE_VO_LI_SWORD_N); +} + +s32 func_80838A14(Player* pthis, GlobalContext* globalCtx) { + s32 sp3C; + LinkAnimationHeader* sp38; + f32 sp34; + f32 temp; + f32 sp2C; + f32 sp28; + f32 sp24; + + if (!(pthis->stateFlags1 & 0x800) && (pthis->unk_88C >= 2) && + (!(pthis->stateFlags1 & 0x8000000) || (pthis->ageProperties->unk_14 > pthis->wallHeight))) { + sp3C = 0; + + if (func_808332B8(pthis)) { + if (pthis->actor.yDistToWater < 50.0f) { + if ((pthis->unk_88C < 2) || (pthis->wallHeight > pthis->ageProperties->unk_10)) { + return 0; + } + } else if ((pthis->currentBoots != PLAYER_BOOTS_IRON) || (pthis->unk_88C > 2)) { + return 0; + } + } else if (!(pthis->actor.bgCheckFlags & 1) || + ((pthis->ageProperties->unk_14 <= pthis->wallHeight) && (pthis->stateFlags1 & 0x8000000))) { + return 0; + } + + if ((pthis->actor.wallBgId != BGCHECK_SCENE) && (D_808535F0 & 0x40)) { + if (pthis->unk_88D >= 6) { + pthis->stateFlags2 |= 4; + if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + sp3C = 1; + } + } + } else if ((pthis->unk_88D >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + sp3C = 1; + } + + if (sp3C != 0) { + func_80835C58(globalCtx, pthis, func_80845668, 0); + + pthis->stateFlags1 |= 0x40000; + + sp34 = pthis->wallHeight; + + if (pthis->ageProperties->unk_14 <= sp34) { + sp38 = &gPlayerAnim_002D48; + pthis->linearVelocity = 1.0f; + } else { + sp2C = COLPOLY_GET_NORMAL(pthis->actor.wallPoly->normal.x); + sp28 = COLPOLY_GET_NORMAL(pthis->actor.wallPoly->normal.z); + sp24 = pthis->wallDistance + 0.5f; + + pthis->stateFlags1 |= 0x4000; + + if (func_808332B8(pthis)) { + sp38 = &gPlayerAnim_0032E8; + sp34 -= (60.0f * pthis->ageProperties->unk_08); + pthis->stateFlags1 &= ~0x8000000; + } else if (pthis->ageProperties->unk_18 <= sp34) { + sp38 = &gPlayerAnim_002D40; + sp34 -= (59.0f * pthis->ageProperties->unk_08); + } else { + sp38 = &gPlayerAnim_002D38; + sp34 -= (41.0f * pthis->ageProperties->unk_08); + } + + pthis->actor.shape.yOffset -= sp34 * 100.0f; + + pthis->actor.world.pos.x -= sp24 * sp2C; + pthis->actor.world.pos.y += pthis->wallHeight; + pthis->actor.world.pos.z -= sp24 * sp28; + + func_80832224(pthis); + } + + pthis->actor.bgCheckFlags |= 1; + + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, sp38, 1.3f); + AnimationContext_DisableQueue(globalCtx); + + pthis->actor.shape.rot.y = pthis->currentYaw = pthis->actor.wallYaw + 0x8000; + + return 1; + } + } else if ((pthis->actor.bgCheckFlags & 1) && (pthis->unk_88C == 1) && (pthis->unk_88D >= 3)) { + temp = (pthis->wallHeight * 0.08f) + 5.5f; + func_808389E8(pthis, &gPlayerAnim_002FE0, temp, globalCtx); + pthis->linearVelocity = 2.5f; + + return 1; + } + + return 0; +} + +void func_80838E70(GlobalContext* globalCtx, Player* pthis, f32 arg2, s16 arg3) { + func_80835C58(globalCtx, pthis, func_80845CA4, 0); + func_80832440(globalCtx, pthis); + + pthis->unk_84F = 1; + pthis->unk_850 = 1; + + pthis->unk_450.x = (Math_SinS(arg3) * arg2) + pthis->actor.world.pos.x; + pthis->unk_450.z = (Math_CosS(arg3) * arg2) + pthis->actor.world.pos.z; + + func_80832264(globalCtx, pthis, func_80833338(pthis)); +} + +void func_80838F18(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084D610, 0); + func_80832C6C(globalCtx, pthis, &gPlayerAnim_003328); +} + +void func_80838F5C(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084F88C, 0); + + pthis->stateFlags1 |= 0xA0000000; + + Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_FREE0); +} + +s32 func_80838FB8(GlobalContext* globalCtx, Player* pthis) { + if ((globalCtx->sceneLoadFlag == 0) && (pthis->stateFlags1 & 0x80000000)) { + func_80838F5C(globalCtx, pthis); + func_80832284(globalCtx, pthis, &gPlayerAnim_003040); + func_80832698(pthis, NA_SE_VO_LI_FALL_S); + func_800788CC(NA_SE_OC_SECRET_WARP_IN); + return 1; + } + + return 0; +} + +s16 D_808544F8[] = { + 0x045B, // DMT from Magic Fairy Fountain + 0x0482, // DMC from Double Defense Fairy Fountain + 0x0340, // Hyrule Castle from Dins Fire Fairy Fountain + 0x044B, // Kakariko from Potion Shop + 0x02A2, // Market (child day) from Potion Shop + 0x0201, // Kakariko from Bazaar + 0x03B8, // Market (child day) from Bazaar + 0x04EE, // Kakariko from House of Skulltulas + 0x03C0, // Back Alley (day) from Bombchu Shop + 0x0463, // Kakariko from Shooting Gallery + 0x01CD, // Market (child day) from Shooting Gallery + 0x0394, // Zoras Fountain from Farores Wind Fairy Fountain + 0x0340, // Hyrule Castle from Dins Fire Fairy Fountain + 0x057C, // Desert Colossus from Nayrus Love Fairy Fountain +}; + +u8 D_80854514[] = { 11, 9, 3, 5, 7, 0 }; + +s32 func_80839034(GlobalContext* globalCtx, Player* pthis, CollisionPoly* poly, u32 bgId) { + s32 sp3C; + s32 temp; + s32 sp34; + f32 linearVel; + s32 yaw; + + if (pthis->actor.category == ACTORCAT_PLAYER) { + sp3C = 0; + + if (!(pthis->stateFlags1 & 0x80) && (globalCtx->sceneLoadFlag == 0) && (pthis->csMode == 0) && + !(pthis->stateFlags1 & 1) && + (((poly != NULL) && (sp3C = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, poly, bgId), sp3C != 0)) || + (func_8083816C(D_808535E4) && (pthis->unk_A7A == 12)))) { + + sp34 = pthis->unk_A84 - (s32)pthis->actor.world.pos.y; + + if (!(pthis->stateFlags1 & 0x28800000) && !(pthis->actor.bgCheckFlags & 1) && (sp34 < 100) && + (D_80853600 > 100.0f)) { + return 0; + } + + if (sp3C == 0) { + Gameplay_TriggerVoidOut(globalCtx); + func_800994A0(globalCtx); + } else { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[sp3C - 1]; + if (globalCtx->nextEntranceIndex == 0x7FFF) { + gSaveContext.respawnFlag = 2; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; + globalCtx->fadeTransition = 3; + gSaveContext.nextTransition = 3; + } else if (globalCtx->nextEntranceIndex >= 0x7FF9) { + globalCtx->nextEntranceIndex = + D_808544F8[D_80854514[globalCtx->nextEntranceIndex - 0x7FF9] + globalCtx->curSpawn]; + func_800994A0(globalCtx); + } else { + if (SurfaceType_GetSlope(&globalCtx->colCtx, poly, bgId) == 2) { + gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; + Gameplay_TriggerVoidOut(globalCtx); + gSaveContext.respawnFlag = -2; + } + gSaveContext.unk_13C3 = 1; + func_800994A0(globalCtx); + } + globalCtx->sceneLoadFlag = 0x14; + } + + if (!(pthis->stateFlags1 & 0x20800000) && !(pthis->stateFlags2 & 0x40000) && !func_808332B8(pthis) && + (temp = func_80041D4C(&globalCtx->colCtx, poly, bgId), (temp != 10)) && + ((sp34 < 100) || (pthis->actor.bgCheckFlags & 1))) { + + if (temp == 11) { + func_800788CC(NA_SE_OC_SECRET_HOLE_OUT); + func_800F6964(5); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.natureAmbienceId = 0xFF; + } else { + linearVel = pthis->linearVelocity; + + if (linearVel < 0.0f) { + pthis->actor.world.rot.y += 0x8000; + linearVel = -linearVel; + } + + if (linearVel > R_RUN_SPEED_LIMIT / 100.0f) { + gSaveContext.entranceSpeed = R_RUN_SPEED_LIMIT / 100.0f; + } else { + gSaveContext.entranceSpeed = linearVel; + } + + if (D_808535F4 != 0) { + yaw = D_808535FC; + } else { + yaw = pthis->actor.world.rot.y; + } + func_80838E70(globalCtx, pthis, 400.0f, yaw); + } + } else { + if (!(pthis->actor.bgCheckFlags & 1)) { + func_80832210(pthis); + } + } + + pthis->stateFlags1 |= 0x20000001; + + func_80835E44(globalCtx, 0x2F); + + return 1; + } else { + if (globalCtx->sceneLoadFlag == 0) { + + if ((pthis->actor.world.pos.y < -4000.0f) || + (((pthis->unk_A7A == 5) || (pthis->unk_A7A == 12)) && + ((D_80853600 < 100.0f) || (pthis->fallDistance > 400.0f) || + ((globalCtx->sceneNum != SCENE_HAKADAN) && (pthis->fallDistance > 200.0f)))) || + ((globalCtx->sceneNum == SCENE_GANON_FINAL) && (pthis->fallDistance > 320.0f))) { + + if (pthis->actor.bgCheckFlags & 1) { + if (pthis->unk_A7A == 5) { + Gameplay_TriggerRespawn(globalCtx); + } else { + Gameplay_TriggerVoidOut(globalCtx); + } + globalCtx->fadeTransition = 4; + func_80078884(NA_SE_OC_ABYSS); + } else { + func_80838F5C(globalCtx, pthis); + pthis->unk_850 = 9999; + if (pthis->unk_A7A == 5) { + pthis->unk_84F = -1; + } else { + pthis->unk_84F = 1; + } + } + } + + pthis->unk_A84 = pthis->actor.world.pos.y; + } + } + } + + return 0; +} + +void func_808395DC(Player* pthis, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { + f32 cos = Math_CosS(pthis->actor.shape.rot.y); + f32 sin = Math_SinS(pthis->actor.shape.rot.y); + + arg3->x = arg1->x + ((arg2->x * cos) + (arg2->z * sin)); + arg3->y = arg1->y + arg2->y; + arg3->z = arg1->z + ((arg2->z * cos) - (arg2->x * sin)); +} + +Actor* Player_SpawnFairy(GlobalContext* globalCtx, Player* pthis, Vec3f* arg2, Vec3f* arg3, s32 type) { + Vec3f pos; + + func_808395DC(pthis, arg2, arg3, &pos); + + return Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, pos.x, pos.y, pos.z, 0, 0, 0, type); +} + +f32 func_808396F4(GlobalContext* globalCtx, Player* pthis, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, s32* arg5) { + func_808395DC(pthis, &pthis->actor.world.pos, arg2, arg3); + + return BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, arg4, arg5, arg3); +} + +f32 func_8083973C(GlobalContext* globalCtx, Player* pthis, Vec3f* arg2, Vec3f* arg3) { + CollisionPoly* sp24; + s32 sp20; + + return func_808396F4(globalCtx, pthis, arg2, arg3, &sp24, &sp20); +} + +s32 func_80839768(GlobalContext* globalCtx, Player* pthis, Vec3f* arg2, CollisionPoly** arg3, s32* arg4, Vec3f* arg5) { + Vec3f sp44; + Vec3f sp38; + + sp44.x = pthis->actor.world.pos.x; + sp44.y = pthis->actor.world.pos.y + arg2->y; + sp44.z = pthis->actor.world.pos.z; + + func_808395DC(pthis, &pthis->actor.world.pos, arg2, &sp38); + + return BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp44, &sp38, arg5, arg3, true, false, false, true, arg4); +} + +s32 func_80839800(Player* pthis, GlobalContext* globalCtx) { + DoorShutter* doorShutter; + EnDoor* door; // Can also be DoorKiller* + s32 doorDirection; + f32 sp78; + f32 sp74; + Actor* doorActor; + f32 sp6C; + s32 pad3; + s32 frontRoom; + Actor* attachedActor; + LinkAnimationHeader* sp5C; + CollisionPoly* sp58; + Vec3f sp4C; + + if ((pthis->doorType != PLAYER_DOORTYPE_NONE) && + (!(pthis->stateFlags1 & 0x800) || ((pthis->heldActor != NULL) && (pthis->heldActor->id == ACTOR_EN_RU1)))) { + if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (func_8084F9A0 == pthis->func_674)) { + doorActor = pthis->doorActor; + + if (pthis->doorType <= PLAYER_DOORTYPE_AJAR) { + doorActor->textId = 0xD0; + func_80853148(globalCtx, doorActor); + return 0; + } + + doorDirection = pthis->doorDirection; + sp78 = Math_CosS(doorActor->shape.rot.y); + sp74 = Math_SinS(doorActor->shape.rot.y); + + if (pthis->doorType == PLAYER_DOORTYPE_SLIDING) { + doorShutter = (DoorShutter*)doorActor; + + pthis->currentYaw = doorShutter->dyna.actor.home.rot.y; + if (doorDirection > 0) { + pthis->currentYaw -= 0x8000; + } + pthis->actor.shape.rot.y = pthis->currentYaw; + + if (pthis->linearVelocity <= 0.0f) { + pthis->linearVelocity = 0.1f; + } + + func_80838E70(globalCtx, pthis, 50.0f, pthis->actor.shape.rot.y); + + pthis->unk_84F = 0; + pthis->unk_447 = pthis->doorType; + pthis->stateFlags1 |= 0x20000000; + + pthis->unk_450.x = pthis->actor.world.pos.x + ((doorDirection * 20.0f) * sp74); + pthis->unk_450.z = pthis->actor.world.pos.z + ((doorDirection * 20.0f) * sp78); + pthis->unk_45C.x = pthis->actor.world.pos.x + ((doorDirection * -120.0f) * sp74); + pthis->unk_45C.z = pthis->actor.world.pos.z + ((doorDirection * -120.0f) * sp78); + + doorShutter->unk_164 = 1; + func_80832224(pthis); + + if (pthis->doorTimer != 0) { + pthis->unk_850 = 0; + func_80832B0C(globalCtx, pthis, func_80833338(pthis)); + pthis->skelAnime.endFrame = 0.0f; + } else { + pthis->linearVelocity = 0.1f; + } + + if (doorShutter->dyna.actor.category == ACTORCAT_DOOR) { + pthis->unk_46A = globalCtx->transiActorCtx.list[(u16)doorShutter->dyna.actor.params >> 10] + .sides[(doorDirection > 0) ? 0 : 1] + .effects; + + func_800304B0(globalCtx); + } + } else { + // This actor can be either EnDoor or DoorKiller. + // Don't try to access any struct vars other than `animStyle` and `playerIsOpening`! These two variables + // are common across the two actors' structs however most other variables are not! + door = (EnDoor*)doorActor; + + door->animStyle = (doorDirection < 0.0f) ? (LINK_IS_ADULT ? KNOB_ANIM_ADULT_L : KNOB_ANIM_CHILD_L) + : (LINK_IS_ADULT ? KNOB_ANIM_ADULT_R : KNOB_ANIM_CHILD_R); + + if (door->animStyle == KNOB_ANIM_ADULT_L) { + sp5C = D_808539EC[pthis->modelAnimType]; + } else if (door->animStyle == KNOB_ANIM_CHILD_L) { + sp5C = D_80853A04[pthis->modelAnimType]; + } else if (door->animStyle == KNOB_ANIM_ADULT_R) { + sp5C = D_80853A1C[pthis->modelAnimType]; + } else { + sp5C = D_80853A34[pthis->modelAnimType]; + } + + func_80835C58(globalCtx, pthis, func_80845EF8, 0); + func_80832528(globalCtx, pthis); + + if (doorDirection < 0) { + pthis->actor.shape.rot.y = doorActor->shape.rot.y; + } else { + pthis->actor.shape.rot.y = doorActor->shape.rot.y - 0x8000; + } + + pthis->currentYaw = pthis->actor.shape.rot.y; + + sp6C = (doorDirection * 22.0f); + pthis->actor.world.pos.x = doorActor->world.pos.x + sp6C * sp74; + pthis->actor.world.pos.z = doorActor->world.pos.z + sp6C * sp78; + + func_8083328C(globalCtx, pthis, sp5C); + + if (pthis->doorTimer != 0) { + pthis->skelAnime.endFrame = 0.0f; + } + + func_80832224(pthis); + func_80832F54(globalCtx, pthis, 0x28F); + + if (doorActor->parent != NULL) { + doorDirection = -doorDirection; + } + + door->playerIsOpening = 1; + + if (pthis->doorType != PLAYER_DOORTYPE_FAKE) { + pthis->stateFlags1 |= 0x20000000; + func_800304B0(globalCtx); + + if (((doorActor->params >> 7) & 7) == 3) { + sp4C.x = doorActor->world.pos.x - (sp6C * sp74); + sp4C.y = doorActor->world.pos.y + 10.0f; + sp4C.z = doorActor->world.pos.z - (sp6C * sp78); + + BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp58, &sp4C); + + if (func_80839034(globalCtx, pthis, sp58, BGCHECK_SCENE)) { + gSaveContext.entranceSpeed = 2.0f; + gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN; + } + } else { + Camera_ChangeDoorCam(Gameplay_GetCamera(globalCtx, 0), doorActor, + globalCtx->transiActorCtx.list[(u16)doorActor->params >> 10] + .sides[(doorDirection > 0) ? 0 : 1] + .effects, + 0, 38.0f * D_808535EC, 26.0f * D_808535EC, 10.0f * D_808535EC); + } + } + } + + if ((pthis->doorType != PLAYER_DOORTYPE_FAKE) && (doorActor->category == ACTORCAT_DOOR)) { + frontRoom = globalCtx->transiActorCtx.list[(u16)doorActor->params >> 10] + .sides[(doorDirection > 0) ? 0 : 1] + .room; + + if ((frontRoom >= 0) && (frontRoom != globalCtx->roomCtx.curRoom.num)) { + func_8009728C(globalCtx, &globalCtx->roomCtx, frontRoom); + } + } + + doorActor->room = globalCtx->roomCtx.curRoom.num; + + if (((attachedActor = doorActor->child) != NULL) || ((attachedActor = doorActor->parent) != NULL)) { + attachedActor->room = globalCtx->roomCtx.curRoom.num; + } + + return 1; + } + } + + return 0; +} + +void func_80839E88(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + + func_80835C58(globalCtx, pthis, func_80840450, 1); + + if (pthis->unk_870 < 0.5f) { + anim = func_808334E4(pthis); + pthis->unk_870 = 0.0f; + } else { + anim = func_80833528(pthis); + pthis->unk_870 = 1.0f; + } + + pthis->unk_874 = pthis->unk_870; + func_80832284(globalCtx, pthis, anim); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +void func_80839F30(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_808407CC, 1); + func_80832B0C(globalCtx, pthis, func_80833338(pthis)); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +void func_80839F90(Player* pthis, GlobalContext* globalCtx) { + if (func_8008E9C4(pthis)) { + func_80839E88(pthis, globalCtx); + } else if (func_80833B2C(pthis)) { + func_80839F30(pthis, globalCtx); + } else { + func_80853080(pthis, globalCtx); + } +} + +void func_80839FFC(Player* pthis, GlobalContext* globalCtx) { + PlayerFunc674 func; + + if (func_8008E9C4(pthis)) { + func = func_80840450; + } else if (func_80833B2C(pthis)) { + func = func_808407CC; + } else { + func = func_80840BC8; + } + + func_80835C58(globalCtx, pthis, func, 1); +} + +void func_8083A060(Player* pthis, GlobalContext* globalCtx) { + func_80839FFC(pthis, globalCtx); + if (func_8008E9C4(pthis)) { + pthis->unk_850 = 1; + } +} + +void func_8083A098(Player* pthis, LinkAnimationHeader* anim, GlobalContext* globalCtx) { + func_8083A060(pthis, globalCtx); + func_8083328C(globalCtx, pthis, anim); +} + +s32 func_8083A0D4(Player* pthis) { + return (pthis->interactRangeActor != NULL) && (pthis->heldActor == NULL); +} + +void func_8083A0F4(GlobalContext* globalCtx, Player* pthis) { + if (func_8083A0D4(pthis)) { + Actor* interactRangeActor = pthis->interactRangeActor; + s32 interactActorId = interactRangeActor->id; + + if (interactActorId == ACTOR_BG_TOKI_SWD) { + pthis->interactRangeActor->parent = &pthis->actor; + func_80835C58(globalCtx, pthis, func_8084F608, 0); + pthis->stateFlags1 |= 0x20000000; + } else { + LinkAnimationHeader* anim; + + if (interactActorId == ACTOR_BG_HEAVY_BLOCK) { + func_80835C58(globalCtx, pthis, func_80846120, 0); + pthis->stateFlags1 |= 0x20000000; + anim = &gPlayerAnim_002F98; + } else if ((interactActorId == ACTOR_EN_ISHI) && ((interactRangeActor->params & 0xF) == 1)) { + func_80835C58(globalCtx, pthis, func_80846260, 0); + anim = &gPlayerAnim_0032B0; + } else if (((interactActorId == ACTOR_EN_BOMBF) || (interactActorId == ACTOR_EN_KUSA)) && + (Player_GetStrength() <= PLAYER_STR_NONE)) { + func_80835C58(globalCtx, pthis, func_80846408, 0); + pthis->actor.world.pos.x = + (Math_SinS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.x; + pthis->actor.world.pos.z = + (Math_CosS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.z; + pthis->currentYaw = pthis->actor.shape.rot.y = interactRangeActor->yawTowardsPlayer + 0x8000; + anim = &gPlayerAnim_003060; + } else { + func_80835C58(globalCtx, pthis, func_80846050, 0); + anim = D_80853A4C[pthis->modelAnimType]; + } + + func_80832264(globalCtx, pthis, anim); + } + } else { + func_80839F90(pthis, globalCtx); + pthis->stateFlags1 &= ~0x800; + } +} + +void func_8083A2F8(GlobalContext* globalCtx, Player* pthis) { + func_80835DAC(globalCtx, pthis, func_8084B530, 0); + + pthis->stateFlags1 |= 0x20000040; + + if (pthis->actor.textId != 0) { + Message_StartTextbox(globalCtx, pthis->actor.textId, pthis->targetActor); + pthis->unk_664 = pthis->targetActor; + } +} + +void func_8083A360(GlobalContext* globalCtx, Player* pthis) { + func_80835DAC(globalCtx, pthis, func_8084CC98, 0); +} + +void func_8083A388(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084B78C, 0); +} + +void func_8083A3B0(GlobalContext* globalCtx, Player* pthis) { + s32 sp1C = pthis->unk_850; + s32 sp18 = pthis->unk_84F; + + func_80835DAC(globalCtx, pthis, func_8084BF1C, 0); + pthis->actor.velocity.y = 0.0f; + + pthis->unk_850 = sp1C; + pthis->unk_84F = sp18; +} + +void func_8083A40C(GlobalContext* globalCtx, Player* pthis) { + func_80835DAC(globalCtx, pthis, func_8084C760, 0); +} + +void func_8083A434(GlobalContext* globalCtx, Player* pthis) { + func_80835DAC(globalCtx, pthis, func_8084E6D4, 0); + + pthis->stateFlags1 |= 0x20000400; + + if (pthis->getItemId == GI_HEART_CONTAINER_2) { + pthis->unk_850 = 20; + } else if (pthis->getItemId >= 0) { + pthis->unk_850 = 1; + } else { + pthis->getItemId = -pthis->getItemId; + } +} + +s32 func_8083A4A8(Player* pthis, GlobalContext* globalCtx) { + s16 yawDiff; + LinkAnimationHeader* anim; + f32 temp; + + yawDiff = pthis->currentYaw - pthis->actor.shape.rot.y; + + if ((ABS(yawDiff) < 0x1000) && (pthis->linearVelocity > 4.0f)) { + anim = &gPlayerAnim_003148; + } else { + anim = &gPlayerAnim_002FE0; + } + + if (pthis->linearVelocity > (IREG(66) / 100.0f)) { + temp = IREG(67) / 100.0f; + } else { + temp = (IREG(68) / 100.0f) + ((IREG(69) * pthis->linearVelocity) / 1000.0f); + } + + func_80838940(pthis, anim, temp, globalCtx, NA_SE_VO_LI_AUTO_JUMP); + pthis->unk_850 = 1; + + return 1; +} + +void func_8083A5C4(GlobalContext* globalCtx, Player* pthis, CollisionPoly* arg2, f32 arg3, LinkAnimationHeader* arg4) { + f32 sp24 = COLPOLY_GET_NORMAL(arg2->normal.x); + f32 sp20 = COLPOLY_GET_NORMAL(arg2->normal.z); + + func_80835C58(globalCtx, pthis, func_8084BBE4, 0); + func_80832564(globalCtx, pthis); + func_80832264(globalCtx, pthis, arg4); + + pthis->actor.world.pos.x -= (arg3 + 1.0f) * sp24; + pthis->actor.world.pos.z -= (arg3 + 1.0f) * sp20; + pthis->actor.shape.rot.y = pthis->currentYaw = Math_Atan2S(sp20, sp24); + + func_80832224(pthis); + func_80832CFC(pthis); +} + +s32 func_8083A6AC(Player* pthis, GlobalContext* globalCtx) { + CollisionPoly* sp84; + s32 sp80; + Vec3f sp74; + Vec3f sp68; + f32 temp1; + + if ((pthis->actor.yDistToWater < -80.0f) && (ABS(pthis->unk_898) < 2730) && (ABS(pthis->unk_89A) < 2730)) { + sp74.x = pthis->actor.prevPos.x - pthis->actor.world.pos.x; + sp74.z = pthis->actor.prevPos.z - pthis->actor.world.pos.z; + + temp1 = sqrtf(SQ(sp74.x) + SQ(sp74.z)); + if (temp1 != 0.0f) { + temp1 = 5.0f / temp1; + } else { + temp1 = 0.0f; + } + + sp74.x = pthis->actor.prevPos.x + (sp74.x * temp1); + sp74.y = pthis->actor.world.pos.y; + sp74.z = pthis->actor.prevPos.z + (sp74.z * temp1); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &pthis->actor.world.pos, &sp74, &sp68, &sp84, true, false, false, + true, &sp80) && + (ABS(sp84->normal.y) < 600)) { + f32 nx = COLPOLY_GET_NORMAL(sp84->normal.x); + f32 ny = COLPOLY_GET_NORMAL(sp84->normal.y); + f32 nz = COLPOLY_GET_NORMAL(sp84->normal.z); + f32 sp54; + s32 sp50; + + sp54 = Math3D_UDistPlaneToPos(nx, ny, nz, sp84->dist, &pthis->actor.world.pos); + + sp50 = D_80853604 == 6; + if (!sp50 && (func_80041DB8(&globalCtx->colCtx, sp84, sp80) & 8)) { + sp50 = 1; + } + + func_8083A5C4(globalCtx, pthis, sp84, sp54, sp50 ? &gPlayerAnim_002D88 : &gPlayerAnim_002F10); + + if (sp50) { + func_80836898(globalCtx, pthis, func_8083A3B0); + + pthis->currentYaw += 0x8000; + pthis->actor.shape.rot.y = pthis->currentYaw; + + pthis->stateFlags1 |= 0x200000; + func_80832F54(globalCtx, pthis, 0x9F); + + pthis->unk_850 = -1; + pthis->unk_84F = sp50; + } else { + pthis->stateFlags1 |= 0x2000; + pthis->stateFlags1 &= ~0x20000; + } + + func_8002F7DC(&pthis->actor, NA_SE_PL_SLIPDOWN); + func_80832698(pthis, NA_SE_VO_LI_HANG); + return 1; + } + } + + return 0; +} + +void func_8083A9B8(Player* pthis, LinkAnimationHeader* anim, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084BDFC, 0); + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, anim, 1.3f); +} + +static Vec3f D_8085451C = { 0.0f, 0.0f, 100.0f }; + +void func_8083AA10(Player* pthis, GlobalContext* globalCtx) { + s32 sp5C; + CollisionPoly* sp58; + s32 sp54; + WaterBox* sp50; + Vec3f sp44; + f32 sp40; + f32 sp3C; + + pthis->fallDistance = pthis->fallStartHeight - (s32)pthis->actor.world.pos.y; + + if (!(pthis->stateFlags1 & 0x28000000) && !(pthis->actor.bgCheckFlags & 1)) { + if (!func_80838FB8(globalCtx, pthis)) { + if (D_80853604 == 8) { + pthis->actor.world.pos.x = pthis->actor.prevPos.x; + pthis->actor.world.pos.z = pthis->actor.prevPos.z; + return; + } + + if (!(pthis->stateFlags3 & 2) && !(pthis->skelAnime.moveFlags & 0x80) && (func_8084411C != pthis->func_674) && + (func_80844A44 != pthis->func_674)) { + + if ((D_80853604 == 7) || (pthis->swordState != 0)) { + Math_Vec3f_Copy(&pthis->actor.world.pos, &pthis->actor.prevPos); + func_80832210(pthis); + return; + } + + if (pthis->hoverBootsTimer != 0) { + pthis->actor.velocity.y = 1.0f; + D_80853604 = 9; + return; + } + + sp5C = (s16)(pthis->currentYaw - pthis->actor.shape.rot.y); + + func_80835C58(globalCtx, pthis, func_8084411C, 1); + func_80832440(globalCtx, pthis); + + pthis->unk_89E = pthis->unk_A82; + + if ((pthis->actor.bgCheckFlags & 4) && !(pthis->stateFlags1 & 0x8000000) && (D_80853604 != 6) && + (D_80853604 != 9) && (D_80853600 > 20.0f) && (pthis->swordState == 0) && (ABS(sp5C) < 0x2000) && + (pthis->linearVelocity > 3.0f)) { + + if ((D_80853604 == 11) && !(pthis->stateFlags1 & 0x800)) { + + sp40 = func_808396F4(globalCtx, pthis, &D_8085451C, &sp44, &sp58, &sp54); + sp3C = pthis->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, sp44.x, sp44.z, &sp3C, &sp50) && + ((sp3C - sp40) > 50.0f)) { + func_808389E8(pthis, &gPlayerAnim_003158, 6.0f, globalCtx); + func_80835C58(globalCtx, pthis, func_80844A44, 0); + return; + } + } + + func_8083A4A8(pthis, globalCtx); + return; + } + + if ((D_80853604 == 9) || (D_80853600 <= pthis->ageProperties->unk_34) || + !func_8083A6AC(pthis, globalCtx)) { + func_80832284(globalCtx, pthis, &gPlayerAnim_003040); + return; + } + } + } + } else { + pthis->fallStartHeight = pthis->actor.world.pos.y; + } +} + +s32 func_8083AD4C(GlobalContext* globalCtx, Player* pthis) { + s32 cameraMode; + + if (pthis->unk_6AD == 2) { + if (func_8002DD6C(pthis)) { + if (LINK_IS_ADULT) { + cameraMode = CAM_MODE_BOWARROW; + } else { + cameraMode = CAM_MODE_SLINGSHOT; + } + } else { + cameraMode = CAM_MODE_BOOMERANG; + } + } else { + cameraMode = CAM_MODE_FIRSTPERSON; + } + + return Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), cameraMode); +} + +s32 func_8083ADD4(GlobalContext* globalCtx, Player* pthis) { + if (pthis->unk_6AD == 3) { + func_80835C58(globalCtx, pthis, func_80852E14, 0); + if (pthis->unk_46A != 0) { + pthis->stateFlags1 |= 0x20000000; + } + func_80832318(pthis); + return 1; + } else { + return 0; + } +} + +void func_8083AE40(Player* pthis, s16 objectId) { + s32 pad; + u32 size; + + if (objectId != 0) { + pthis->giObjectLoading = true; + //osCreateMesgQueue(&pthis->giObjectLoadQueue, &pthis->giObjectLoadMsg, 1); + + size = POINTER_SUB2(gObjectTable[objectId].vromEnd, gObjectTable[objectId].vromStart); + + LOG_HEX("size", size, "../z_player.c", 9090); + ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091); + + DmaMgr_SendRequest2(&pthis->giObjectDmaRequest, pthis->giObjectSegment, gObjectTable[objectId].vromStart, + size, 0, &pthis->giObjectLoadQueue, NULL, "../z_player.c", 9099); + } +} + +void func_8083AF44(GlobalContext* globalCtx, Player* pthis, s32 magicSpell) { + func_80835DE4(globalCtx, pthis, func_808507F4, 0); + + pthis->unk_84F = magicSpell - 3; + func_80087708(globalCtx, sMagicSpellCosts[magicSpell], 4); + + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, &gPlayerAnim_002D28, 0.83f); + + if (magicSpell == 5) { + pthis->unk_46C = OnePointCutscene_Init(globalCtx, 1100, -101, NULL, MAIN_CAM); + } else { + func_80835EA4(globalCtx, 10); + } +} + +void func_8083B010(Player* pthis) { + pthis->actor.focus.rot.x = pthis->actor.focus.rot.z = pthis->unk_6B6 = pthis->unk_6B8 = pthis->unk_6BA = pthis->unk_6BC = + pthis->unk_6BE = pthis->unk_6C0 = 0; + + pthis->actor.focus.rot.y = pthis->actor.shape.rot.y; +} + +static u8 D_80854528[] = { + GI_LETTER_ZELDA, GI_WEIRD_EGG, GI_CHICKEN, GI_BEAN, GI_POCKET_EGG, GI_POCKET_CUCCO, + GI_COJIRO, GI_ODD_MUSHROOM, GI_ODD_POTION, GI_SAW, GI_SWORD_BROKEN, GI_PRESCRIPTION, + GI_FROG, GI_EYEDROPS, GI_CLAIM_CHECK, GI_MASK_SKULL, GI_MASK_SPOOKY, GI_MASK_KEATON, + GI_MASK_BUNNY, GI_MASK_TRUTH, GI_MASK_GORON, GI_MASK_ZORA, GI_MASK_GERUDO, GI_LETTER_RUTO, + GI_LETTER_RUTO, GI_LETTER_RUTO, GI_LETTER_RUTO, GI_LETTER_RUTO, GI_LETTER_RUTO, +}; + +static LinkAnimationHeader* D_80854548[] = { + &gPlayerAnim_002F88, + &gPlayerAnim_002690, + &gPlayerAnim_003198, +}; + +s32 func_8083B040(Player* pthis, GlobalContext* globalCtx) { + s32 sp2C; + s32 sp28; + GetItemEntry* giEntry; + Actor* targetActor; + + if ((pthis->unk_6AD != 0) && + (func_808332B8(pthis) || (pthis->actor.bgCheckFlags & 1) || (pthis->stateFlags1 & 0x800000))) { + + if (!func_8083ADD4(globalCtx, pthis)) { + if (pthis->unk_6AD == 4) { + sp2C = Player_ActionToMagicSpell(pthis, pthis->itemActionParam); + if (sp2C >= 0) { + if ((sp2C != 3) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { + func_8083AF44(globalCtx, pthis, sp2C); + } else { + func_80835C58(globalCtx, pthis, func_8085063C, 1); + pthis->stateFlags1 |= 0x30000000; + func_80832264(globalCtx, pthis, func_80833338(pthis)); + func_80835EA4(globalCtx, 4); + } + + func_80832224(pthis); + return 1; + } + + sp2C = pthis->itemActionParam - PLAYER_AP_LETTER_ZELDA; + if ((sp2C >= 0) || + (sp28 = Player_ActionToBottle(pthis, pthis->itemActionParam) - 1, + ((sp28 >= 0) && (sp28 < 6) && + ((pthis->itemActionParam > PLAYER_AP_BOTTLE_POE) || + ((pthis->targetActor != NULL) && + (((pthis->itemActionParam == PLAYER_AP_BOTTLE_POE) && (pthis->exchangeItemId == EXCH_ITEM_POE)) || + (pthis->exchangeItemId == EXCH_ITEM_BLUE_FIRE))))))) { + + if ((globalCtx->actorCtx.titleCtx.delayTimer == 0) && (globalCtx->actorCtx.titleCtx.alpha == 0)) { + func_80835DE4(globalCtx, pthis, func_8084F104, 0); + + if (sp2C >= 0) { + giEntry = &sGetItemTable[D_80854528[sp2C] - 1]; + func_8083AE40(pthis, giEntry->objectId); + } + + pthis->stateFlags1 |= 0x30000040; + + if (sp2C >= 0) { + sp2C = sp2C + 1; + } else { + sp2C = sp28 + 0x18; + } + + targetActor = pthis->targetActor; + + if ((targetActor != NULL) && + ((pthis->exchangeItemId == sp2C) || (pthis->exchangeItemId == EXCH_ITEM_BLUE_FIRE) || + ((pthis->exchangeItemId == EXCH_ITEM_POE) && + (pthis->itemActionParam == PLAYER_AP_BOTTLE_BIG_POE)) || + ((pthis->exchangeItemId == EXCH_ITEM_BEAN) && + (pthis->itemActionParam == PLAYER_AP_BOTTLE_BUG))) && + ((pthis->exchangeItemId != EXCH_ITEM_BEAN) || (pthis->itemActionParam == PLAYER_AP_BEAN))) { + if (pthis->exchangeItemId == EXCH_ITEM_BEAN) { + Inventory_ChangeAmmo(ITEM_BEAN, -1); + func_80835DE4(globalCtx, pthis, func_8084279C, 0); + pthis->stateFlags1 |= 0x20000000; + pthis->unk_850 = 0x50; + pthis->unk_84F = -1; + } + targetActor->flags |= ACTOR_FLAG_8; + pthis->unk_664 = pthis->targetActor; + } else if (sp2C == EXCH_ITEM_LETTER_RUTO) { + pthis->unk_84F = 1; + pthis->actor.textId = 0x4005; + func_80835EA4(globalCtx, 1); + } else { + pthis->unk_84F = 2; + pthis->actor.textId = 0xCF; + func_80835EA4(globalCtx, 4); + } + + pthis->actor.flags |= ACTOR_FLAG_8; + pthis->exchangeItemId = sp2C; + + if (pthis->unk_84F < 0) { + func_80832B0C(globalCtx, pthis, D_80853C14[pthis->modelAnimType]); + } else { + func_80832264(globalCtx, pthis, D_80854548[pthis->unk_84F]); + } + + func_80832224(pthis); + } + return 1; + } + + sp2C = Player_ActionToBottle(pthis, pthis->itemActionParam); + if (sp2C >= 0) { + if (sp2C == 0xC) { + func_80835DE4(globalCtx, pthis, func_8084EED8, 0); + func_808322D0(globalCtx, pthis, &gPlayerAnim_002650); + func_80835EA4(globalCtx, 3); + } else if ((sp2C > 0) && (sp2C < 4)) { + func_80835DE4(globalCtx, pthis, func_8084EFC0, 0); + func_808322D0(globalCtx, pthis, &gPlayerAnim_002688); + func_80835EA4(globalCtx, (sp2C == 1) ? 1 : 5); + } else { + func_80835DE4(globalCtx, pthis, func_8084EAC0, 0); + func_80832B78(globalCtx, pthis, &gPlayerAnim_002668); + func_80835EA4(globalCtx, 2); + } + } else { + func_80835DE4(globalCtx, pthis, func_8084E3C4, 0); + func_808322D0(globalCtx, pthis, &gPlayerAnim_0030A0); + pthis->stateFlags2 |= 0x8000000; + func_80835EA4(globalCtx, (pthis->unk_6A8 != NULL) ? 0x5B : 0x5A); + if (pthis->unk_6A8 != NULL) { + pthis->stateFlags2 |= 0x2000000; + Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, pthis->unk_6A8); + } + } + } else if (func_8083AD4C(globalCtx, pthis)) { + if (!(pthis->stateFlags1 & 0x800000)) { + func_80835C58(globalCtx, pthis, func_8084B1D8, 1); + pthis->unk_850 = 13; + func_8083B010(pthis); + } + pthis->stateFlags1 |= 0x100000; + func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); + func_80832210(pthis); + return 1; + } else { + pthis->unk_6AD = 0; + func_80078884(NA_SE_SY_ERROR); + return 0; + } + + pthis->stateFlags1 |= 0x30000000; + } + + func_80832224(pthis); + return 1; + } + + return 0; +} + +s32 func_8083B644(Player* pthis, GlobalContext* globalCtx) { + Actor* sp34 = pthis->targetActor; + Actor* sp30 = pthis->unk_664; + Actor* sp2C = NULL; + s32 sp28 = 0; + s32 sp24; + + sp24 = (sp30 != NULL) && (CHECK_FLAG_ALL(sp30->flags, ACTOR_FLAG_0 | ACTOR_FLAG_18) || (sp30->naviEnemyId != 0xFF)); + + if (sp24 || (pthis->naviTextId != 0)) { + sp28 = (pthis->naviTextId < 0) && ((ABS(pthis->naviTextId) & 0xFF00) != 0x200); + if (sp28 || !sp24) { + sp2C = pthis->naviActor; + if (sp28) { + sp30 = NULL; + sp34 = NULL; + } + } else { + sp2C = sp30; + } + } + + if ((sp34 != NULL) || (sp2C != NULL)) { + if ((sp30 == NULL) || (sp30 == sp34) || (sp30 == sp2C)) { + if (!(pthis->stateFlags1 & 0x800) || + ((pthis->heldActor != NULL) && (sp28 || (sp34 == pthis->heldActor) || (sp2C == pthis->heldActor) || + ((sp34 != NULL) && (sp34->flags & ACTOR_FLAG_16))))) { + if ((pthis->actor.bgCheckFlags & 1) || (pthis->stateFlags1 & 0x800000) || + (func_808332B8(pthis) && !(pthis->stateFlags2 & 0x400))) { + + if (sp34 != NULL) { + pthis->stateFlags2 |= 2; + if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (sp34->flags & ACTOR_FLAG_16)) { + sp2C = NULL; + } else if (sp2C == NULL) { + return 0; + } + } + + if (sp2C != NULL) { + if (!sp28) { + pthis->stateFlags2 |= 0x200000; + } + + if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && !sp28) { + return 0; + } + + sp34 = sp2C; + pthis->targetActor = NULL; + + if (sp28 || !sp24) { + if (pthis->naviTextId >= 0) { + sp2C->textId = pthis->naviTextId; + } else { + sp2C->textId = -pthis->naviTextId; + } + } else { + if (sp2C->naviEnemyId != 0xFF) { + sp2C->textId = sp2C->naviEnemyId + 0x600; + } + } + } + + pthis->currentMask = D_80858AA4; + func_80853148(globalCtx, sp34); + return 1; + } + } + } + } + + return 0; +} + +s32 func_8083B8F4(Player* pthis, GlobalContext* globalCtx) { + if (!(pthis->stateFlags1 & 0x800800) && Camera_CheckValidMode(Gameplay_GetCamera(globalCtx, 0), 6)) { + if ((pthis->actor.bgCheckFlags & 1) || + (func_808332B8(pthis) && (pthis->actor.yDistToWater < pthis->ageProperties->unk_2C))) { + pthis->unk_6AD = 1; + return 1; + } + } + + return 0; +} + +s32 func_8083B998(Player* pthis, GlobalContext* globalCtx) { + if (pthis->unk_6AD != 0) { + func_8083B040(pthis, globalCtx); + return 1; + } + + if ((pthis->unk_664 != NULL) && + (CHECK_FLAG_ALL(pthis->unk_664->flags, ACTOR_FLAG_0 | ACTOR_FLAG_18) || (pthis->unk_664->naviEnemyId != 0xFF))) { + pthis->stateFlags2 |= 0x200000; + } else if ((pthis->naviTextId == 0) && !func_8008E9C4(pthis) && CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && + (YREG(15) != 0x10) && (YREG(15) != 0x20) && !func_8083B8F4(pthis, globalCtx)) { + func_80078884(NA_SE_SY_ERROR); + } + + return 0; +} + +void func_8083BA90(GlobalContext* globalCtx, Player* pthis, s32 arg2, f32 xzVelocity, f32 yVelocity) { + func_80837948(globalCtx, pthis, arg2); + func_80835C58(globalCtx, pthis, func_80844AF4, 0); + + pthis->stateFlags3 |= 2; + + pthis->currentYaw = pthis->actor.shape.rot.y; + pthis->linearVelocity = xzVelocity; + pthis->actor.velocity.y = yVelocity; + + pthis->actor.bgCheckFlags &= ~1; + pthis->hoverBootsTimer = 0; + + func_80832854(pthis); + func_80832698(pthis, NA_SE_VO_LI_SWORD_L); +} + +s32 func_8083BB20(Player* pthis) { + if (!(pthis->stateFlags1 & 0x400000) && (Player_GetSwordHeld(pthis) != 0)) { + if (D_80853614 || + ((pthis->actor.category != ACTORCAT_PLAYER) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B))) { + return 1; + } + } + + return 0; +} + +s32 func_8083BBA0(Player* pthis, GlobalContext* globalCtx) { + if (func_8083BB20(pthis) && (D_808535E4 != 7)) { + func_8083BA90(globalCtx, pthis, 17, 3.0f, 4.5f); + return 1; + } + + return 0; +} + +void func_8083BC04(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80844708, 0); + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, D_80853A94[pthis->modelAnimType], 1.25f * D_808535E8); +} + +s32 func_8083BC7C(Player* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_84B[pthis->unk_846] == 0) && (D_808535E4 != 7)) { + func_8083BC04(pthis, globalCtx); + return 1; + } + + return 0; +} + +void func_8083BCD0(Player* pthis, GlobalContext* globalCtx, s32 arg2) { + func_80838940(pthis, D_80853D4C[arg2][0], !(arg2 & 1) ? 5.8f : 3.5f, globalCtx, NA_SE_VO_LI_SWORD_N); + + if (arg2) {} + + pthis->unk_850 = 1; + pthis->unk_84F = arg2; + + pthis->currentYaw = pthis->actor.shape.rot.y + (arg2 << 0xE); + pthis->linearVelocity = !(arg2 & 1) ? 6.0f : 8.5f; + + pthis->stateFlags2 |= 0x80000; + + func_8002F7DC(&pthis->actor, ((arg2 << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP); +} + +s32 func_8083BDBC(Player* pthis, GlobalContext* globalCtx) { + s32 sp2C; + + if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (globalCtx->roomCtx.curRoom.unk_03 != 2) && + (D_808535E4 != 7) && + (SurfaceType_GetSlope(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId) != 1)) { + sp2C = pthis->unk_84B[pthis->unk_846]; + + if (sp2C <= 0) { + if (func_80833BCC(pthis)) { + if (pthis->actor.category != ACTORCAT_PLAYER) { + if (sp2C < 0) { + func_808389E8(pthis, &gPlayerAnim_002FE0, REG(69) / 100.0f, globalCtx); + } else { + func_8083BC04(pthis, globalCtx); + } + } else { + if (Player_GetSwordHeld(pthis) && func_808365C8(pthis)) { + func_8083BA90(globalCtx, pthis, 17, 5.0f, 5.0f); + } else { + func_8083BC04(pthis, globalCtx); + } + } + return 1; + } + } else { + func_8083BCD0(pthis, globalCtx, sp2C); + return 1; + } + } + + return 0; +} + +void func_8083BF50(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + f32 sp30; + + sp30 = pthis->unk_868 - 3.0f; + if (sp30 < 0.0f) { + sp30 += 29.0f; + } + + if (sp30 < 14.0f) { + anim = D_80853AC4[pthis->modelAnimType]; + sp30 = 11.0f - sp30; + if (sp30 < 0.0f) { + sp30 = 1.375f * -sp30; + } + sp30 /= 11.0f; + } else { + anim = D_80853ADC[pthis->modelAnimType]; + sp30 = 26.0f - sp30; + if (sp30 < 0.0f) { + sp30 = 2 * -sp30; + } + sp30 /= 12.0f; + } + + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + 4.0f * sp30); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +void func_8083C0B8(Player* pthis, GlobalContext* globalCtx) { + func_80839FFC(pthis, globalCtx); + func_8083BF50(pthis, globalCtx); +} + +void func_8083C0E8(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80840BC8, 1); + func_80832264(globalCtx, pthis, func_80833338(pthis)); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +void func_8083C148(Player* pthis, GlobalContext* globalCtx) { + if (!(pthis->stateFlags3 & 0x80)) { + func_8083B010(pthis); + if (pthis->stateFlags1 & 0x8000000) { + func_80838F18(globalCtx, pthis); + } else { + func_80839F90(pthis, globalCtx); + } + if (pthis->unk_6AD < 4) { + pthis->unk_6AD = 0; + } + } + + pthis->stateFlags1 &= ~0x106000; +} + +s32 func_8083C1DC(Player* pthis, GlobalContext* globalCtx) { + if (!func_80833B54(pthis) && (D_808535E0 == 0) && !(pthis->stateFlags1 & 0x800000) && + CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + if (func_8083BC7C(pthis, globalCtx)) { + return 1; + } + if ((pthis->unk_837 == 0) && (pthis->heldItemActionParam >= PLAYER_AP_SWORD_MASTER)) { + func_80835F44(globalCtx, pthis, ITEM_NONE); + } else { + pthis->stateFlags2 ^= 0x100000; + } + } + + return 0; +} + +s32 func_8083C2B0(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + f32 frame; + + if ((globalCtx->shootingGalleryStatus == 0) && (pthis->currentShield != PLAYER_SHIELD_NONE) && + CHECK_BTN_ALL(sControlInput->cur.button, BTN_R) && + (Player_IsChildWithHylianShield(pthis) || (!func_80833B2C(pthis) && (pthis->unk_664 == NULL)))) { + + func_80832318(pthis); + func_808323B4(globalCtx, pthis); + + if (func_80835C58(globalCtx, pthis, func_80843188, 0)) { + pthis->stateFlags1 |= 0x400000; + + if (!Player_IsChildWithHylianShield(pthis)) { + Player_SetModelsForHoldingShield(pthis); + anim = D_80853AF4[pthis->modelAnimType]; + } else { + anim = &gPlayerAnim_002400; + } + + if (anim != pthis->skelAnime.animation) { + if (func_8008E9C4(pthis)) { + pthis->unk_86C = 1.0f; + } else { + pthis->unk_86C = 0.0f; + func_80833C3C(pthis); + } + pthis->unk_6BC = pthis->unk_6BE = pthis->unk_6C0 = 0; + } + + frame = Animation_GetLastFrame(anim); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); + + if (Player_IsChildWithHylianShield(pthis)) { + func_80832F54(globalCtx, pthis, 4); + } + + func_8002F7DC(&pthis->actor, NA_SE_IT_SHIELD_POSTURE); + } + + return 1; + } + + return 0; +} + +s32 func_8083C484(Player* pthis, f32* arg1, s16* arg2) { + s16 yaw = pthis->currentYaw - *arg2; + + if (ABS(yaw) > 0x6000) { + if (func_8083721C(pthis)) { + *arg1 = 0.0f; + *arg2 = pthis->currentYaw; + } else { + return 1; + } + } + + return 0; +} + +void func_8083C50C(Player* pthis) { + if ((pthis->unk_844 > 0) && !CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { + pthis->unk_844 = -pthis->unk_844; + } +} + +s32 func_8083C544(Player* pthis, GlobalContext* globalCtx) { + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { + if (!(pthis->stateFlags1 & 0x400000) && (Player_GetSwordHeld(pthis) != 0) && (pthis->unk_844 == 1) && + (pthis->heldItemActionParam != PLAYER_AP_STICK)) { + if ((pthis->heldItemActionParam != PLAYER_AP_SWORD_BGS) || (gSaveContext.swordHealth > 0.0f)) { + func_808377DC(globalCtx, pthis); + return 1; + } + } + } else { + func_8083C50C(pthis); + } + + return 0; +} + +s32 func_8083C61C(GlobalContext* globalCtx, Player* pthis) { + if ((globalCtx->roomCtx.curRoom.unk_03 != 2) && (pthis->actor.bgCheckFlags & 1) && (AMMO(ITEM_NUT) != 0)) { + func_80835C58(globalCtx, pthis, func_8084E604, 0); + func_80832264(globalCtx, pthis, &gPlayerAnim_003048); + pthis->unk_6AD = 0; + return 1; + } + + return 0; +} + +static struct_80854554 D_80854554[] = { + { &gPlayerAnim_002648, &gPlayerAnim_002640, 2, 3 }, + { &gPlayerAnim_002680, &gPlayerAnim_002678, 5, 3 }, +}; + +s32 func_8083C6B8(GlobalContext* globalCtx, Player* pthis) { + Vec3f sp24; + + if (D_80853614) { + if (Player_GetBottleHeld(pthis) >= 0) { + func_80835C58(globalCtx, pthis, func_8084ECA4, 0); + + if (pthis->actor.yDistToWater > 12.0f) { + pthis->unk_850 = 1; + } + + func_808322D0(globalCtx, pthis, D_80854554[pthis->unk_850].unk_00); + + func_8002F7DC(&pthis->actor, NA_SE_IT_SWORD_SWING); + func_80832698(pthis, NA_SE_VO_LI_AUTO_JUMP); + return 1; + } + + if (pthis->heldItemActionParam == PLAYER_AP_FISHING_POLE) { + sp24 = pthis->actor.world.pos; + sp24.y += 50.0f; + + if (!(pthis->actor.bgCheckFlags & 1) || (pthis->actor.world.pos.z > 1300.0f) || + BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sp24, 20.0f)) { + func_80078884(NA_SE_SY_ERROR); + return 0; + } + + func_80835C58(globalCtx, pthis, func_80850C68, 0); + pthis->unk_860 = 1; + func_80832210(pthis); + func_80832264(globalCtx, pthis, &gPlayerAnim_002C30); + return 1; + } else { + return 0; + } + } + + return 0; +} + +void func_8083C858(Player* pthis, GlobalContext* globalCtx) { + PlayerFunc674 func; + + if (func_80833BCC(pthis)) { + func = func_8084227C; + } else { + func = func_80842180; + } + + func_80835C58(globalCtx, pthis, func, 1); + func_80832BE8(globalCtx, pthis, D_80853944[pthis->modelAnimType]); + + pthis->unk_89C = 0; + pthis->unk_864 = pthis->unk_868 = 0.0f; +} + +void func_8083C8DC(Player* pthis, GlobalContext* globalCtx, s16 arg2) { + pthis->actor.shape.rot.y = pthis->currentYaw = arg2; + func_8083C858(pthis, globalCtx); +} + +s32 func_8083C910(GlobalContext* globalCtx, Player* pthis, f32 arg2) { + WaterBox* sp2C; + f32 sp28; + + sp28 = pthis->actor.world.pos.y; + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, pthis->actor.world.pos.x, pthis->actor.world.pos.z, &sp28, + &sp2C) != 0) { + sp28 -= pthis->actor.world.pos.y; + if (pthis->ageProperties->unk_24 <= sp28) { + func_80835C58(globalCtx, pthis, func_8084D7C4, 0); + func_80832C6C(globalCtx, pthis, &gPlayerAnim_0032F0); + pthis->stateFlags1 |= 0x28000000; + pthis->unk_850 = 20; + pthis->linearVelocity = 2.0f; + Player_SetBootData(globalCtx, pthis); + return 0; + } + } + + func_80838E70(globalCtx, pthis, arg2, pthis->actor.shape.rot.y); + pthis->stateFlags1 |= 0x20000000; + return 1; +} + +void func_8083CA20(GlobalContext* globalCtx, Player* pthis) { + if (func_8083C910(globalCtx, pthis, 180.0f)) { + pthis->unk_850 = -20; + } +} + +void func_8083CA54(GlobalContext* globalCtx, Player* pthis) { + pthis->linearVelocity = 2.0f; + gSaveContext.entranceSpeed = 2.0f; + if (func_8083C910(globalCtx, pthis, 120.0f)) { + pthis->unk_850 = -15; + } +} + +void func_8083CA9C(GlobalContext* globalCtx, Player* pthis) { + if (gSaveContext.entranceSpeed < 0.1f) { + gSaveContext.entranceSpeed = 0.1f; + } + + pthis->linearVelocity = gSaveContext.entranceSpeed; + + if (func_8083C910(globalCtx, pthis, 800.0f)) { + pthis->unk_850 = -80 / pthis->linearVelocity; + if (pthis->unk_850 < -20) { + pthis->unk_850 = -20; + } + } +} + +void func_8083CB2C(Player* pthis, s16 yaw, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_808414F8, 1); + LinkAnimation_CopyJointToMorph(globalCtx, &pthis->skelAnime); + pthis->unk_864 = pthis->unk_868 = 0.0f; + pthis->currentYaw = yaw; +} + +void func_8083CB94(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80840DE4, 1); + func_80832BE8(globalCtx, pthis, D_8085392C[pthis->modelAnimType]); +} + +void func_8083CBF0(Player* pthis, s16 yaw, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_808423EC, 1); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_0024F8, 2.2f, 0.0f, + Animation_GetLastFrame(&gPlayerAnim_0024F8), ANIMMODE_ONCE, -6.0f); + pthis->linearVelocity = 8.0f; + pthis->currentYaw = yaw; +} + +void func_8083CC9C(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084193C, 1); + func_80832BE8(globalCtx, pthis, D_80853B6C[pthis->modelAnimType]); + pthis->unk_868 = 0.0f; +} + +void func_8083CD00(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084251C, 1); + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, &gPlayerAnim_0024E8, 2.0f); +} + +void func_8083CD54(GlobalContext* globalCtx, Player* pthis, s16 yaw) { + pthis->currentYaw = yaw; + func_80835C58(globalCtx, pthis, func_80841BA8, 1); + pthis->unk_87E = 1200; + pthis->unk_87E *= D_808535E8; + LinkAnimation_Change(globalCtx, &pthis->skelAnime, D_80853B84[pthis->modelAnimType], 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, + -6.0f); +} + +void func_8083CE0C(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + + func_80835C58(globalCtx, pthis, func_80840BC8, 1); + + if (pthis->unk_870 < 0.5f) { + anim = D_80853BB4[pthis->modelAnimType]; + } else { + anim = D_80853B9C[pthis->modelAnimType]; + } + func_80832264(globalCtx, pthis, anim); + + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +void func_8083CEAC(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80840450, 1); + func_80832B0C(globalCtx, pthis, D_808539BC[pthis->modelAnimType]); + pthis->unk_850 = 1; +} + +void func_8083CF10(Player* pthis, GlobalContext* globalCtx) { + if (pthis->linearVelocity != 0.0f) { + func_8083C858(pthis, globalCtx); + } else { + func_8083CE0C(pthis, globalCtx); + } +} + +void func_8083CF5C(Player* pthis, GlobalContext* globalCtx) { + if (pthis->linearVelocity != 0.0f) { + func_8083C858(pthis, globalCtx); + } else { + func_80839F90(pthis, globalCtx); + } +} + +s32 func_8083CFA8(GlobalContext* globalCtx, Player* pthis, f32 arg2, s32 splashScale) { + f32 sp3C = fabsf(arg2); + WaterBox* sp38; + f32 sp34; + Vec3f splashPos; + s32 splashType; + + if (sp3C > 2.0f) { + splashPos.x = pthis->bodyPartsPos[0].x; + splashPos.z = pthis->bodyPartsPos[0].z; + sp34 = pthis->actor.world.pos.y; + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, splashPos.x, splashPos.z, &sp34, &sp38)) { + if ((sp34 - pthis->actor.world.pos.y) < 100.0f) { + splashType = (sp3C <= 10.0f) ? 0 : 1; + splashPos.y = sp34; + EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, splashType, splashScale); + return 1; + } + } + } + + return 0; +} + +void func_8083D0A8(GlobalContext* globalCtx, Player* pthis, f32 arg2) { + pthis->stateFlags1 |= 0x40000; + pthis->stateFlags1 &= ~0x8000000; + + func_80832340(globalCtx, pthis); + if (func_8083CFA8(globalCtx, pthis, arg2, 500)) { + func_8002F7DC(&pthis->actor, NA_SE_EV_JUMP_OUT_WATER); + } + + Player_SetBootData(globalCtx, pthis); +} + +s32 func_8083D12C(GlobalContext* globalCtx, Player* pthis, Input* arg2) { + if (!(pthis->stateFlags1 & 0x400) && !(pthis->stateFlags2 & 0x400)) { + if ((arg2 == NULL) || (CHECK_BTN_ALL(arg2->press.button, BTN_A) && (ABS(pthis->unk_6C2) < 12000) && + (pthis->currentBoots != PLAYER_BOOTS_IRON))) { + + func_80835C58(globalCtx, pthis, func_8084DC48, 0); + func_80832264(globalCtx, pthis, &gPlayerAnim_003308); + + pthis->unk_6C2 = 0; + pthis->stateFlags2 |= 0x400; + pthis->actor.velocity.y = 0.0f; + + if (arg2 != NULL) { + pthis->stateFlags2 |= 0x800; + func_8002F7DC(&pthis->actor, NA_SE_PL_DIVE_BUBBLE); + } + + return 1; + } + } + + if ((pthis->stateFlags1 & 0x400) || (pthis->stateFlags2 & 0x400)) { + if (pthis->actor.velocity.y > 0.0f) { + if (pthis->actor.yDistToWater < pthis->ageProperties->unk_30) { + + pthis->stateFlags2 &= ~0x400; + + if (arg2 != NULL) { + func_80835C58(globalCtx, pthis, func_8084E1EC, 1); + + if (pthis->stateFlags1 & 0x400) { + pthis->stateFlags1 |= 0x20000C00; + } + + pthis->unk_850 = 2; + } + + func_80832340(globalCtx, pthis); + func_80832B0C(globalCtx, pthis, (pthis->stateFlags1 & 0x800) ? &gPlayerAnim_003318 : &gPlayerAnim_003300); + + if (func_8083CFA8(globalCtx, pthis, pthis->actor.velocity.y, 500)) { + func_8002F7DC(&pthis->actor, NA_SE_PL_FACE_UP); + } + + return 1; + } + } + } + + return 0; +} + +void func_8083D330(GlobalContext* globalCtx, Player* pthis) { + func_80832284(globalCtx, pthis, &gPlayerAnim_0032F0); + pthis->unk_6C2 = 16000; + pthis->unk_850 = 1; +} + +void func_8083D36C(GlobalContext* globalCtx, Player* pthis) { + if ((pthis->currentBoots != PLAYER_BOOTS_IRON) || !(pthis->actor.bgCheckFlags & 1)) { + func_80832564(globalCtx, pthis); + + if ((pthis->currentBoots != PLAYER_BOOTS_IRON) && (pthis->stateFlags2 & 0x400)) { + pthis->stateFlags2 &= ~0x400; + func_8083D12C(globalCtx, pthis, 0); + pthis->unk_84F = 1; + } else if (func_80844A44 == pthis->func_674) { + func_80835C58(globalCtx, pthis, func_8084DC48, 0); + func_8083D330(globalCtx, pthis); + } else { + func_80835C58(globalCtx, pthis, func_8084D610, 1); + func_80832B0C(globalCtx, pthis, (pthis->actor.bgCheckFlags & 1) ? &gPlayerAnim_003330 : &gPlayerAnim_0032E0); + } + } + + if (!(pthis->stateFlags1 & 0x8000000) || (pthis->actor.yDistToWater < pthis->ageProperties->unk_2C)) { + if (func_8083CFA8(globalCtx, pthis, pthis->actor.velocity.y, 500)) { + func_8002F7DC(&pthis->actor, NA_SE_EV_DIVE_INTO_WATER); + + if (pthis->fallDistance > 800.0f) { + func_80832698(pthis, NA_SE_VO_LI_CLIMB_END); + } + } + } + + pthis->stateFlags1 |= 0x8000000; + pthis->stateFlags2 |= 0x400; + pthis->stateFlags1 &= ~0xC0000; + pthis->unk_854 = 0.0f; + + Player_SetBootData(globalCtx, pthis); +} + +void func_8083D53C(GlobalContext* globalCtx, Player* pthis) { + if (pthis->actor.yDistToWater < pthis->ageProperties->unk_2C) { + Audio_SetBaseFilter(0); + pthis->unk_840 = 0; + } else { + Audio_SetBaseFilter(0x20); + if (pthis->unk_840 < 300) { + pthis->unk_840++; + } + } + + if ((func_80845668 != pthis->func_674) && (func_8084BDFC != pthis->func_674)) { + if (pthis->ageProperties->unk_2C < pthis->actor.yDistToWater) { + if (!(pthis->stateFlags1 & 0x8000000) || + (!((pthis->currentBoots == PLAYER_BOOTS_IRON) && (pthis->actor.bgCheckFlags & 1)) && + (func_8084E30C != pthis->func_674) && (func_8084E368 != pthis->func_674) && + (func_8084D610 != pthis->func_674) && (func_8084D84C != pthis->func_674) && + (func_8084DAB4 != pthis->func_674) && (func_8084DC48 != pthis->func_674) && + (func_8084E1EC != pthis->func_674) && (func_8084D7C4 != pthis->func_674))) { + func_8083D36C(globalCtx, pthis); + return; + } + } else if ((pthis->stateFlags1 & 0x8000000) && (pthis->actor.yDistToWater < pthis->ageProperties->unk_24)) { + if ((pthis->skelAnime.moveFlags == 0) && (pthis->currentBoots != PLAYER_BOOTS_IRON)) { + func_8083CD54(globalCtx, pthis, pthis->actor.shape.rot.y); + } + func_8083D0A8(globalCtx, pthis, pthis->actor.velocity.y); + } + } +} + +void func_8083D6EC(GlobalContext* globalCtx, Player* pthis) { + Vec3f ripplePos; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + + pthis->actor.minVelocityY = -20.0f; + pthis->actor.gravity = REG(68) / 100.0f; + + if (func_8083816C(D_808535E4)) { + temp1 = fabsf(pthis->linearVelocity) * 20.0f; + temp3 = 0.0f; + + if (D_808535E4 == 4) { + if (pthis->unk_6C4 > 1300.0f) { + temp2 = pthis->unk_6C4; + } else { + temp2 = 1300.0f; + } + if (pthis->currentBoots == PLAYER_BOOTS_HOVER) { + temp1 += temp1; + } else if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + temp1 *= 0.3f; + } + } else { + temp2 = 20000.0f; + if (pthis->currentBoots != PLAYER_BOOTS_HOVER) { + temp1 += temp1; + } else if ((D_808535E4 == 7) || (pthis->currentBoots == PLAYER_BOOTS_IRON)) { + temp1 = 0; + } + } + + if (pthis->currentBoots != PLAYER_BOOTS_HOVER) { + temp3 = (temp2 - pthis->unk_6C4) * 0.02f; + temp3 = CLAMP(temp3, 0.0f, 300.0f); + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + temp3 += temp3; + } + } + + pthis->unk_6C4 += temp3 - temp1; + pthis->unk_6C4 = CLAMP(pthis->unk_6C4, 0.0f, temp2); + + pthis->actor.gravity -= pthis->unk_6C4 * 0.004f; + } else { + pthis->unk_6C4 = 0.0f; + } + + if (pthis->actor.bgCheckFlags & 0x20) { + if (pthis->actor.yDistToWater < 50.0f) { + temp4 = fabsf(pthis->bodyPartsPos[0].x - pthis->unk_A88.x) + + fabsf(pthis->bodyPartsPos[0].y - pthis->unk_A88.y) + fabsf(pthis->bodyPartsPos[0].z - pthis->unk_A88.z); + if (temp4 > 4.0f) { + temp4 = 4.0f; + } + pthis->unk_854 += temp4; + + if (pthis->unk_854 > 15.0f) { + pthis->unk_854 = 0.0f; + + ripplePos.x = (Rand_ZeroOne() * 10.0f) + pthis->actor.world.pos.x; + ripplePos.y = pthis->actor.world.pos.y + pthis->actor.yDistToWater; + ripplePos.z = (Rand_ZeroOne() * 10.0f) + pthis->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 0); + + if ((pthis->linearVelocity > 4.0f) && !func_808332B8(pthis) && + ((pthis->actor.world.pos.y + pthis->actor.yDistToWater) < pthis->bodyPartsPos[0].y)) { + func_8083CFA8(globalCtx, pthis, 20.0f, + (fabsf(pthis->linearVelocity) * 50.0f) + (pthis->actor.yDistToWater * 5.0f)); + } + } + } + + if (pthis->actor.yDistToWater > 40.0f) { + s32 numBubbles = 0; + s32 i; + + if ((pthis->actor.velocity.y > -1.0f) || (pthis->actor.bgCheckFlags & 1)) { + if (Rand_ZeroOne() < 0.2f) { + numBubbles = 1; + } + } else { + numBubbles = pthis->actor.velocity.y * -2.0f; + } + + for (i = 0; i < numBubbles; i++) { + EffectSsBubble_Spawn(globalCtx, &pthis->actor.world.pos, 20.0f, 10.0f, 20.0f, 0.13f); + } + } + } +} + +s32 func_8083DB98(Player* pthis, s32 arg1) { + Actor* unk_664 = pthis->unk_664; + Vec3f sp30; + s16 sp2E; + s16 sp2C; + + sp30.x = pthis->actor.world.pos.x; + sp30.y = pthis->bodyPartsPos[7].y + 3.0f; + sp30.z = pthis->actor.world.pos.z; + sp2E = Math_Vec3f_Pitch(&sp30, &unk_664->focus.pos); + sp2C = Math_Vec3f_Yaw(&sp30, &unk_664->focus.pos); + Math_SmoothStepToS(&pthis->actor.focus.rot.y, sp2C, 4, 10000, 0); + Math_SmoothStepToS(&pthis->actor.focus.rot.x, sp2E, 4, 10000, 0); + pthis->unk_6AE |= 2; + + return func_80836AB8(pthis, arg1); +} + +static Vec3f D_8085456C = { 0.0f, 100.0f, 40.0f }; + +void func_8083DC54(Player* pthis, GlobalContext* globalCtx) { + s16 sp46; + s16 temp2; + f32 temp1; + Vec3f sp34; + + if (pthis->unk_664 != NULL) { + if (func_8002DD78(pthis) || func_808334B4(pthis)) { + func_8083DB98(pthis, 1); + } else { + func_8083DB98(pthis, 0); + } + return; + } + + if (D_808535E4 == 11) { + Math_SmoothStepToS(&pthis->actor.focus.rot.x, -20000, 10, 4000, 800); + } else { + sp46 = 0; + temp1 = func_8083973C(globalCtx, pthis, &D_8085456C, &sp34); + if (temp1 > BGCHECK_Y_MIN) { + temp2 = Math_Atan2S(40.0f, pthis->actor.world.pos.y - temp1); + sp46 = CLAMP(temp2, -4000, 4000); + } + pthis->actor.focus.rot.y = pthis->actor.shape.rot.y; + Math_SmoothStepToS(&pthis->actor.focus.rot.x, sp46, 14, 4000, 30); + } + + func_80836AB8(pthis, func_8002DD78(pthis) || func_808334B4(pthis)); +} + +void func_8083DDC8(Player* pthis, GlobalContext* globalCtx) { + s16 temp1; + s16 temp2; + + if (!func_8002DD78(pthis) && !func_808334B4(pthis) && (pthis->linearVelocity > 5.0f)) { + temp1 = pthis->linearVelocity * 200.0f; + temp2 = (s16)(pthis->currentYaw - pthis->actor.shape.rot.y) * pthis->linearVelocity * 0.1f; + temp1 = CLAMP(temp1, -4000, 4000); + temp2 = CLAMP(-temp2, -4000, 4000); + Math_ScaledStepToS(&pthis->unk_6BC, temp1, 900); + pthis->unk_6B6 = -(f32)pthis->unk_6BC * 0.5f; + Math_ScaledStepToS(&pthis->unk_6BA, temp2, 300); + Math_ScaledStepToS(&pthis->unk_6C0, temp2, 200); + pthis->unk_6AE |= 0x168; + } else { + func_8083DC54(pthis, globalCtx); + } +} + +void func_8083DF68(Player* pthis, f32 arg1, s16 arg2) { + Math_AsymStepToF(&pthis->linearVelocity, arg1, REG(19) / 100.0f, 1.5f); + Math_ScaledStepToS(&pthis->currentYaw, arg2, REG(27)); +} + +void func_8083DFE0(Player* pthis, f32* arg1, s16* arg2) { + s16 yawDiff = pthis->currentYaw - *arg2; + + if (pthis->swordState == 0) { + pthis->linearVelocity = CLAMP(pthis->linearVelocity, -(R_RUN_SPEED_LIMIT / 100.0f), (R_RUN_SPEED_LIMIT / 100.0f)); + } + + if (ABS(yawDiff) > 0x6000) { + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 1.0f)) { + pthis->currentYaw = *arg2; + } + } else { + Math_AsymStepToF(&pthis->linearVelocity, *arg1, 0.05f, 0.1f); + Math_ScaledStepToS(&pthis->currentYaw, *arg2, 200); + } +} + +static struct_80854578 D_80854578[] = { + { &gPlayerAnim_003398, 35.17f, 6.6099997f }, + { &gPlayerAnim_0033A8, -34.16f, 7.91f }, +}; + +s32 func_8083E0FC(Player* pthis, GlobalContext* globalCtx) { + EnHorse* rideActor = (EnHorse*)pthis->rideActor; + f32 unk_04; + f32 unk_08; + f32 sp38; + f32 sp34; + s32 temp; + + if ((rideActor != NULL) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + sp38 = Math_CosS(rideActor->actor.shape.rot.y); + sp34 = Math_SinS(rideActor->actor.shape.rot.y); + + func_80836898(globalCtx, pthis, func_8083A360); + + pthis->stateFlags1 |= 0x800000; + pthis->actor.bgCheckFlags &= ~0x20; + + if (pthis->mountSide < 0) { + temp = 0; + } else { + temp = 1; + } + + unk_04 = D_80854578[temp].unk_04; + unk_08 = D_80854578[temp].unk_08; + pthis->actor.world.pos.x = + rideActor->actor.world.pos.x + rideActor->riderPos.x + ((unk_04 * sp38) + (unk_08 * sp34)); + pthis->actor.world.pos.z = + rideActor->actor.world.pos.z + rideActor->riderPos.z + ((unk_08 * sp38) - (unk_04 * sp34)); + + pthis->unk_878 = rideActor->actor.world.pos.y - pthis->actor.world.pos.y; + pthis->currentYaw = pthis->actor.shape.rot.y = rideActor->actor.shape.rot.y; + + Actor_MountHorse(globalCtx, pthis, &rideActor->actor); + func_80832264(globalCtx, pthis, D_80854578[temp].anim); + func_80832F54(globalCtx, pthis, 0x9B); + pthis->actor.parent = pthis->rideActor; + func_80832224(pthis); + func_800304B0(globalCtx); + return 1; + } + + return 0; +} + +void func_8083E298(CollisionPoly* arg0, Vec3f* arg1, s16* arg2) { + arg1->x = COLPOLY_GET_NORMAL(arg0->normal.x); + arg1->y = COLPOLY_GET_NORMAL(arg0->normal.y); + arg1->z = COLPOLY_GET_NORMAL(arg0->normal.z); + + *arg2 = Math_Atan2S(arg1->z, arg1->x); +} + +static LinkAnimationHeader* D_80854590[] = { + &gPlayerAnim_002EE0, + &gPlayerAnim_0031D0, +}; + +s32 func_8083E318(GlobalContext* globalCtx, Player* pthis, CollisionPoly* arg2) { + s32 pad; + s16 sp4A; + Vec3f sp3C; + s16 sp3A; + f32 temp1; + f32 temp2; + s16 temp3; + + if (!Player_InBlockingCsMode(globalCtx, pthis) && (func_8084F390 != pthis->func_674) && + (SurfaceType_GetSlope(&globalCtx->colCtx, arg2, pthis->actor.floorBgId) == 1)) { + sp4A = Math_Atan2S(pthis->actor.velocity.z, pthis->actor.velocity.x); + func_8083E298(arg2, &sp3C, &sp3A); + temp3 = sp3A - sp4A; + + if (ABS(temp3) > 16000) { + temp1 = (1.0f - sp3C.y) * 40.0f; + temp2 = (temp1 * temp1) * 0.015f; + if (temp2 < 1.2f) { + temp2 = 1.2f; + } + pthis->windDirection = sp3A; + Math_StepToF(&pthis->windSpeed, temp1, temp2); + } else { + func_80835C58(globalCtx, pthis, func_8084F390, 0); + func_80832564(globalCtx, pthis); + if (D_80853610 >= 0) { + pthis->unk_84F = 1; + } + func_80832BE8(globalCtx, pthis, D_80854590[pthis->unk_84F]); + pthis->linearVelocity = sqrtf(SQ(pthis->actor.velocity.x) + SQ(pthis->actor.velocity.z)); + pthis->currentYaw = sp4A; + return 1; + } + } + + return 0; +} + +// unknown data (unused) +static s32 D_80854598[] = { + 0xFFDB0871, 0xF8310000, 0x00940470, 0xF3980000, 0xFFB504A9, 0x0C9F0000, 0x08010402, +}; + +void func_8083E4C4(GlobalContext* globalCtx, Player* pthis, GetItemEntry* giEntry) { + s32 sp1C = giEntry->field & 0x1F; + + if (!(giEntry->field & 0x80)) { + Item_DropCollectible(globalCtx, &pthis->actor.world.pos, sp1C | 0x8000); + if ((sp1C != 4) && (sp1C != 8) && (sp1C != 9) && (sp1C != 0xA) && (sp1C != 0) && (sp1C != 1) && (sp1C != 2) && + (sp1C != 0x14) && (sp1C != 0x13)) { + Item_Give(globalCtx, giEntry->itemId); + } + } else { + Item_Give(globalCtx, giEntry->itemId); + } + + func_80078884((pthis->getItemId < 0) ? NA_SE_SY_GET_BOXITEM : NA_SE_SY_GET_ITEM); +} + +s32 func_8083E5A8(Player* pthis, GlobalContext* globalCtx) { + Actor* interactedActor = NULL; + + if (iREG(67) || (((interactedActor = pthis->interactRangeActor) != NULL) && + func_8002D53C(globalCtx, &globalCtx->actorCtx.titleCtx))) { + if (iREG(67) || (pthis->getItemId > GI_NONE)) { + if (iREG(67)) { + pthis->getItemId = iREG(68); + } + + if (pthis->getItemId < GI_MAX) { + GetItemEntry* giEntry = &sGetItemTable[pthis->getItemId - 1]; + + if ((interactedActor != &pthis->actor) && !iREG(67)) { + interactedActor->parent = &pthis->actor; + } + + iREG(67) = false; + + if ((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) || (globalCtx->sceneNum == SCENE_BOWLING)) { + func_808323B4(globalCtx, pthis); + func_8083AE40(pthis, giEntry->objectId); + + if (!(pthis->stateFlags2 & 0x400) || (pthis->currentBoots == PLAYER_BOOTS_IRON)) { + func_80836898(globalCtx, pthis, func_8083A434); + func_808322D0(globalCtx, pthis, &gPlayerAnim_002788); + func_80835EA4(globalCtx, 9); + } + + pthis->stateFlags1 |= 0x20000C00; + func_80832224(pthis); + return 1; + } + + func_8083E4C4(globalCtx, pthis, giEntry); + pthis->getItemId = GI_NONE; + } + } else if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && !(pthis->stateFlags1 & 0x800) && + !(pthis->stateFlags2 & 0x400)) { + if (pthis->getItemId != GI_NONE) { + GetItemEntry* giEntry = &sGetItemTable[-pthis->getItemId - 1]; + EnBox* chest = (EnBox*)interactedActor; + + if (giEntry->itemId != ITEM_NONE) { + if (((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) && (giEntry->field & 0x40)) || + ((Item_CheckObtainability(giEntry->itemId) != ITEM_NONE) && (giEntry->field & 0x20))) { + pthis->getItemId = -GI_RUPEE_BLUE; + giEntry = &sGetItemTable[GI_RUPEE_BLUE - 1]; + } + } + + func_80836898(globalCtx, pthis, func_8083A434); + pthis->stateFlags1 |= 0x20000C00; + func_8083AE40(pthis, giEntry->objectId); + pthis->actor.world.pos.x = + chest->dyna.actor.world.pos.x - (Math_SinS(chest->dyna.actor.shape.rot.y) * 29.4343f); + pthis->actor.world.pos.z = + chest->dyna.actor.world.pos.z - (Math_CosS(chest->dyna.actor.shape.rot.y) * 29.4343f); + pthis->currentYaw = pthis->actor.shape.rot.y = chest->dyna.actor.shape.rot.y; + func_80832224(pthis); + + if ((giEntry->itemId != ITEM_NONE) && (giEntry->gi >= 0) && + (Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) { + func_808322D0(globalCtx, pthis, pthis->ageProperties->unk_98); + func_80832F54(globalCtx, pthis, 0x28F); + chest->unk_1F4 = 1; + Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_SLOW_CHEST_CS); + } else { + func_80832264(globalCtx, pthis, &gPlayerAnim_002DF8); + chest->unk_1F4 = -1; + } + + return 1; + } + + if ((pthis->heldActor == NULL) || Player_HoldsHookshot(pthis)) { + if ((interactedActor->id == ACTOR_BG_TOKI_SWD) && LINK_IS_ADULT) { + s32 sp24 = pthis->itemActionParam; + + pthis->itemActionParam = PLAYER_AP_NONE; + pthis->modelAnimType = 0; + pthis->heldItemActionParam = pthis->itemActionParam; + func_80836898(globalCtx, pthis, func_8083A0F4); + + if (sp24 == PLAYER_AP_SWORD_MASTER) { + pthis->nextModelGroup = Player_ActionToModelGroup(pthis, PLAYER_AP_LAST_USED); + func_8083399C(globalCtx, pthis, PLAYER_AP_LAST_USED); + } else { + func_80835F44(globalCtx, pthis, ITEM_LAST_USED); + } + } else { + s32 strength = Player_GetStrength(); + + if ((interactedActor->id == ACTOR_EN_ISHI) && ((interactedActor->params & 0xF) == 1) && + (strength < PLAYER_STR_SILVER_G)) { + return 0; + } + + func_80836898(globalCtx, pthis, func_8083A0F4); + } + + func_80832224(pthis); + pthis->stateFlags1 |= 0x800; + return 1; + } + } + } + + return 0; +} + +void func_8083EA94(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80846578, 1); + func_80832264(globalCtx, pthis, D_80853BCC[pthis->modelAnimType]); +} + +s32 func_8083EAF0(Player* pthis, Actor* actor) { + if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_23) && + ((pthis->linearVelocity < 1.1f) || (actor->id == ACTOR_EN_BOM_CHU))) { + return 0; + } + + return 1; +} + +s32 func_8083EB44(Player* pthis, GlobalContext* globalCtx) { + if ((pthis->stateFlags1 & 0x800) && (pthis->heldActor != NULL) && + CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + if (!func_80835644(globalCtx, pthis, pthis->heldActor)) { + if (!func_8083EAF0(pthis, pthis->heldActor)) { + func_80835C58(globalCtx, pthis, func_808464B0, 1); + func_80832264(globalCtx, pthis, D_80853BE4[pthis->modelAnimType]); + } else { + func_8083EA94(pthis, globalCtx); + } + } + return 1; + } + + return 0; +} + +s32 func_8083EC18(Player* pthis, GlobalContext* globalCtx, u32 arg2) { + if (pthis->wallHeight >= 79.0f) { + if (!(pthis->stateFlags1 & 0x8000000) || (pthis->currentBoots == PLAYER_BOOTS_IRON) || + (pthis->actor.yDistToWater < pthis->ageProperties->unk_2C)) { + s32 sp8C = (arg2 & 8) ? 2 : 0; + + if ((sp8C != 0) || (arg2 & 2) || + func_80041E4C(&globalCtx->colCtx, pthis->actor.wallPoly, pthis->actor.wallBgId)) { + f32 phi_f20; + CollisionPoly* sp84 = pthis->actor.wallPoly; + f32 sp80; + f32 sp7C; + f32 phi_f12; + f32 phi_f14; + + phi_f20 = phi_f12 = 0.0f; + + if (sp8C != 0) { + sp80 = pthis->actor.world.pos.x; + sp7C = pthis->actor.world.pos.z; + } else { + Vec3f sp50[3]; + s32 i; + f32 sp48; + Vec3f* sp44 = &sp50[0]; + s32 pad; + + CollisionPoly_GetVerticesByBgId(sp84, pthis->actor.wallBgId, &globalCtx->colCtx, sp50); + + sp80 = phi_f12 = sp44->x; + sp7C = phi_f14 = sp44->z; + phi_f20 = sp44->y; + for (i = 1; i < 3; i++) { + sp44++; + if (sp80 > sp44->x) { + sp80 = sp44->x; + } else if (phi_f12 < sp44->x) { + phi_f12 = sp44->x; + } + + if (sp7C > sp44->z) { + sp7C = sp44->z; + } else if (phi_f14 < sp44->z) { + phi_f14 = sp44->z; + } + + if (phi_f20 > sp44->y) { + phi_f20 = sp44->y; + } + } + + sp80 = (sp80 + phi_f12) * 0.5f; + sp7C = (sp7C + phi_f14) * 0.5f; + + phi_f12 = ((pthis->actor.world.pos.x - sp80) * COLPOLY_GET_NORMAL(sp84->normal.z)) - + ((pthis->actor.world.pos.z - sp7C) * COLPOLY_GET_NORMAL(sp84->normal.x)); + sp48 = pthis->actor.world.pos.y - phi_f20; + + phi_f20 = ((f32)(s32)((sp48 / 15.000000223517418) + 0.5) * 15.000000223517418) - sp48; + phi_f12 = fabsf(phi_f12); + } + + if (phi_f12 < 8.0f) { + f32 sp3C = COLPOLY_GET_NORMAL(sp84->normal.x); + f32 sp38 = COLPOLY_GET_NORMAL(sp84->normal.z); + f32 sp34 = pthis->wallDistance; + LinkAnimationHeader* sp30; + + func_80836898(globalCtx, pthis, func_8083A3B0); + pthis->stateFlags1 |= 0x200000; + pthis->stateFlags1 &= ~0x8000000; + + if ((sp8C != 0) || (arg2 & 2)) { + if ((pthis->unk_84F = sp8C) != 0) { + if (pthis->actor.bgCheckFlags & 1) { + sp30 = &gPlayerAnim_002D80; + } else { + sp30 = &gPlayerAnim_002D68; + } + sp34 = (pthis->ageProperties->unk_38 - 1.0f) - sp34; + } else { + sp30 = pthis->ageProperties->unk_A4; + sp34 = sp34 - 1.0f; + } + pthis->unk_850 = -2; + pthis->actor.world.pos.y += phi_f20; + pthis->actor.shape.rot.y = pthis->currentYaw = pthis->actor.wallYaw + 0x8000; + } else { + sp30 = pthis->ageProperties->unk_A8; + pthis->unk_850 = -4; + pthis->actor.shape.rot.y = pthis->currentYaw = pthis->actor.wallYaw; + } + + pthis->actor.world.pos.x = (sp34 * sp3C) + sp80; + pthis->actor.world.pos.z = (sp34 * sp38) + sp7C; + func_80832224(pthis); + Math_Vec3f_Copy(&pthis->actor.prevPos, &pthis->actor.world.pos); + func_80832264(globalCtx, pthis, sp30); + func_80832F54(globalCtx, pthis, 0x9F); + + return 1; + } + } + } + } + + return 0; +} + +void func_8083F070(Player* pthis, LinkAnimationHeader* anim, GlobalContext* globalCtx) { + func_80835DAC(globalCtx, pthis, func_8084C5F8, 0); + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, anim, (4.0f / 3.0f)); +} + +s32 func_8083F0C8(Player* pthis, GlobalContext* globalCtx, u32 arg2) { + CollisionPoly* wallPoly; + Vec3f sp50[3]; + f32 sp4C; + f32 phi_f2; + f32 sp44; + f32 phi_f12; + s32 i; + + if (!LINK_IS_ADULT && !(pthis->stateFlags1 & 0x8000000) && (arg2 & 0x30)) { + wallPoly = pthis->actor.wallPoly; + CollisionPoly_GetVerticesByBgId(wallPoly, pthis->actor.wallBgId, &globalCtx->colCtx, sp50); + + sp4C = phi_f2 = sp50[0].x; + sp44 = phi_f12 = sp50[0].z; + for (i = 1; i < 3; i++) { + if (sp4C > sp50[i].x) { + sp4C = sp50[i].x; + } else if (phi_f2 < sp50[i].x) { + phi_f2 = sp50[i].x; + } + + if (sp44 > sp50[i].z) { + sp44 = sp50[i].z; + } else if (phi_f12 < sp50[i].z) { + phi_f12 = sp50[i].z; + } + } + + sp4C = (sp4C + phi_f2) * 0.5f; + sp44 = (sp44 + phi_f12) * 0.5f; + + phi_f2 = ((pthis->actor.world.pos.x - sp4C) * COLPOLY_GET_NORMAL(wallPoly->normal.z)) - + ((pthis->actor.world.pos.z - sp44) * COLPOLY_GET_NORMAL(wallPoly->normal.x)); + + if (fabsf(phi_f2) < 8.0f) { + pthis->stateFlags2 |= 0x10000; + + if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + f32 sp38 = COLPOLY_GET_NORMAL(wallPoly->normal.x); + f32 sp34 = COLPOLY_GET_NORMAL(wallPoly->normal.z); + f32 sp30 = pthis->wallDistance; + + func_80836898(globalCtx, pthis, func_8083A40C); + pthis->stateFlags2 |= 0x40000; + pthis->actor.shape.rot.y = pthis->currentYaw = pthis->actor.wallYaw + 0x8000; + pthis->actor.world.pos.x = sp4C + (sp30 * sp38); + pthis->actor.world.pos.z = sp44 + (sp30 * sp34); + func_80832224(pthis); + pthis->actor.prevPos = pthis->actor.world.pos; + func_80832264(globalCtx, pthis, &gPlayerAnim_002708); + func_80832F54(globalCtx, pthis, 0x9D); + + return 1; + } + } + } + + return 0; +} + +s32 func_8083F360(GlobalContext* globalCtx, Player* pthis, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + CollisionPoly* wallPoly; + s32 sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + f32 yawCos; + f32 yawSin; + s32 temp; + f32 temp1; + f32 temp2; + + yawCos = Math_CosS(pthis->actor.shape.rot.y); + yawSin = Math_SinS(pthis->actor.shape.rot.y); + + sp6C.x = pthis->actor.world.pos.x + (arg4 * yawSin); + sp6C.z = pthis->actor.world.pos.z + (arg4 * yawCos); + sp60.x = pthis->actor.world.pos.x + (arg3 * yawSin); + sp60.z = pthis->actor.world.pos.z + (arg3 * yawCos); + sp60.y = sp6C.y = pthis->actor.world.pos.y + arg1; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp6C, &sp60, &sp54, &pthis->actor.wallPoly, true, false, false, + true, &sp78)) { + wallPoly = pthis->actor.wallPoly; + + pthis->actor.bgCheckFlags |= 0x200; + pthis->actor.wallBgId = sp78; + + D_808535F0 = func_80041DB8(&globalCtx->colCtx, wallPoly, sp78); + + temp1 = COLPOLY_GET_NORMAL(wallPoly->normal.x); + temp2 = COLPOLY_GET_NORMAL(wallPoly->normal.z); + temp = Math_Atan2S(-temp2, -temp1); + Math_ScaledStepToS(&pthis->actor.shape.rot.y, temp, 800); + + pthis->currentYaw = pthis->actor.shape.rot.y; + pthis->actor.world.pos.x = sp54.x - (Math_SinS(pthis->actor.shape.rot.y) * arg2); + pthis->actor.world.pos.z = sp54.z - (Math_CosS(pthis->actor.shape.rot.y) * arg2); + + return 1; + } + + pthis->actor.bgCheckFlags &= ~0x200; + + return 0; +} + +s32 func_8083F524(GlobalContext* globalCtx, Player* pthis) { + return func_8083F360(globalCtx, pthis, 26.0f, pthis->ageProperties->unk_38 + 5.0f, 30.0f, 0.0f); +} + +s32 func_8083F570(Player* pthis, GlobalContext* globalCtx) { + s16 temp; + + if ((pthis->linearVelocity != 0.0f) && (pthis->actor.bgCheckFlags & 8) && (D_808535F0 & 0x30)) { + + temp = pthis->actor.shape.rot.y - pthis->actor.wallYaw; + if (pthis->linearVelocity < 0.0f) { + temp += 0x8000; + } + + if (ABS(temp) > 0x4000) { + func_80835C58(globalCtx, pthis, func_8084C81C, 0); + + if (pthis->linearVelocity > 0.0f) { + pthis->actor.shape.rot.y = pthis->actor.wallYaw + 0x8000; + func_80832264(globalCtx, pthis, &gPlayerAnim_002700); + func_80832F54(globalCtx, pthis, 0x9D); + OnePointCutscene_Init(globalCtx, 9601, 999, NULL, MAIN_CAM); + } else { + pthis->actor.shape.rot.y = pthis->actor.wallYaw; + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_002708, -1.0f, + Animation_GetLastFrame(&gPlayerAnim_002708), 0.0f, ANIMMODE_ONCE, 0.0f); + func_80832F54(globalCtx, pthis, 0x9D); + OnePointCutscene_Init(globalCtx, 9602, 999, NULL, MAIN_CAM); + } + + pthis->currentYaw = pthis->actor.shape.rot.y; + func_80832210(pthis); + + return 1; + } + } + + return 0; +} + +void func_8083F72C(Player* pthis, LinkAnimationHeader* anim, GlobalContext* globalCtx) { + if (!func_80836898(globalCtx, pthis, func_8083A388)) { + func_80835C58(globalCtx, pthis, func_8084B78C, 0); + } + + func_80832264(globalCtx, pthis, anim); + func_80832224(pthis); + + pthis->actor.shape.rot.y = pthis->currentYaw = pthis->actor.wallYaw + 0x8000; +} + +s32 func_8083F7BC(Player* pthis, GlobalContext* globalCtx) { + DynaPolyActor* wallPolyActor; + + if (!(pthis->stateFlags1 & 0x800) && (pthis->actor.bgCheckFlags & 0x200) && (D_80853608 < 0x3000)) { + + if (((pthis->linearVelocity > 0.0f) && func_8083EC18(pthis, globalCtx, D_808535F0)) || + func_8083F0C8(pthis, globalCtx, D_808535F0)) { + return 1; + } + + if (!func_808332B8(pthis) && ((pthis->linearVelocity == 0.0f) || !(pthis->stateFlags2 & 4)) && + (D_808535F0 & 0x40) && (pthis->actor.bgCheckFlags & 1) && (pthis->wallHeight >= 39.0f)) { + + pthis->stateFlags2 |= 1; + + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A)) { + + if ((pthis->actor.wallBgId != BGCHECK_SCENE) && + ((wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.wallBgId)) != NULL)) { + + if (wallPolyActor->actor.id == ACTOR_BG_HEAVY_BLOCK) { + if (Player_GetStrength() < PLAYER_STR_GOLD_G) { + return 0; + } + + func_80836898(globalCtx, pthis, func_8083A0F4); + pthis->stateFlags1 |= 0x800; + pthis->interactRangeActor = &wallPolyActor->actor; + pthis->getItemId = GI_NONE; + pthis->currentYaw = pthis->actor.wallYaw + 0x8000; + func_80832224(pthis); + + return 1; + } + + pthis->unk_3C4 = &wallPolyActor->actor; + } else { + pthis->unk_3C4 = NULL; + } + + func_8083F72C(pthis, &gPlayerAnim_0030F8, globalCtx); + + return 1; + } + } + } + + return 0; +} + +s32 func_8083F9D0(GlobalContext* globalCtx, Player* pthis) { + if ((pthis->actor.bgCheckFlags & 0x200) && + ((pthis->stateFlags2 & 0x10) || CHECK_BTN_ALL(sControlInput->cur.button, BTN_A))) { + DynaPolyActor* wallPolyActor = NULL; + + if (pthis->actor.wallBgId != BGCHECK_SCENE) { + wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.wallBgId); + } + + if (&wallPolyActor->actor == pthis->unk_3C4) { + if (pthis->stateFlags2 & 0x10) { + return 1; + } else { + return 0; + } + } + } + + func_80839FFC(pthis, globalCtx); + func_80832264(globalCtx, pthis, &gPlayerAnim_003100); + pthis->stateFlags2 &= ~0x10; + return 1; +} + +void func_8083FAB8(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084B898, 0); + pthis->stateFlags2 |= 0x10; + func_80832264(globalCtx, pthis, &gPlayerAnim_0030F0); +} + +void func_8083FB14(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084B9E4, 0); + pthis->stateFlags2 |= 0x10; + func_80832264(globalCtx, pthis, D_80853C5C[pthis->modelAnimType]); +} + +void func_8083FB7C(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags1 &= ~0x8200000; + func_80837B9C(pthis, globalCtx); + pthis->linearVelocity = -0.4f; +} + +s32 func_8083FBC0(Player* pthis, GlobalContext* globalCtx) { + if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (pthis->actor.bgCheckFlags & 0x200) && + ((D_808535F0 & 8) || (D_808535F0 & 2) || + func_80041E4C(&globalCtx->colCtx, pthis->actor.wallPoly, pthis->actor.wallBgId))) { + return 0; + } + + func_8083FB7C(pthis, globalCtx); + func_80832698(pthis, NA_SE_VO_LI_AUTO_JUMP); + return 1; +} + +s32 func_8083FC68(Player* pthis, f32 arg1, s16 arg2) { + f32 sp1C = (s16)(arg2 - pthis->actor.shape.rot.y); + f32 temp; + + if (pthis->unk_664 != NULL) { + func_8083DB98(pthis, func_8002DD78(pthis) || func_808334B4(pthis)); + } + + temp = fabsf(sp1C) / 32768.0f; + + if (arg1 > (((temp * temp) * 50.0f) + 6.0f)) { + return 1; + } else if (arg1 > (((1.0f - temp) * 10.0f) + 6.8f)) { + return -1; + } + + return 0; +} + +s32 func_8083FD78(Player* pthis, f32* arg1, s16* arg2, GlobalContext* globalCtx) { + s16 sp2E = *arg2 - pthis->targetYaw; + u16 sp2C = ABS(sp2E); + + if ((func_8002DD78(pthis) || func_808334B4(pthis)) && (pthis->unk_664 == NULL)) { + *arg1 *= Math_SinS(sp2C); + + if (*arg1 != 0.0f) { + *arg2 = (((sp2E >= 0) ? 1 : -1) << 0xE) + pthis->actor.shape.rot.y; + } else { + *arg2 = pthis->actor.shape.rot.y; + } + + if (pthis->unk_664 != NULL) { + func_8083DB98(pthis, 1); + } else { + Math_SmoothStepToS(&pthis->actor.focus.rot.x, sControlInput->rel.stick_y * 240.0f, 14, 4000, 30); + func_80836AB8(pthis, 1); + } + } else { + if (pthis->unk_664 != NULL) { + return func_8083FC68(pthis, *arg1, *arg2); + } else { + func_8083DC54(pthis, globalCtx); + if ((*arg1 != 0.0f) && (sp2C < 6000)) { + return 1; + } else if (*arg1 > Math_SinS((0x4000 - (sp2C >> 1))) * 200.0f) { + return -1; + } + } + } + + return 0; +} + +s32 func_8083FFB8(Player* pthis, f32* arg1, s16* arg2) { + s16 temp1 = *arg2 - pthis->actor.shape.rot.y; + u16 temp2 = ABS(temp1); + f32 temp3 = Math_CosS(temp2); + + *arg1 *= temp3; + + if (*arg1 != 0.0f) { + if (temp3 > 0) { + return 1; + } else { + return -1; + } + } + + return 0; +} + +s32 func_80840058(Player* pthis, f32* arg1, s16* arg2, GlobalContext* globalCtx) { + func_8083DC54(pthis, globalCtx); + + if ((*arg1 != 0.0f) || (ABS(pthis->unk_87C) > 400)) { + s16 temp1 = *arg2 - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); + u16 temp2 = (ABS(temp1) - 0x2000) & 0xFFFF; + + if ((temp2 < 0x4000) || (pthis->unk_87C != 0)) { + return -1; + } else { + return 1; + } + } + + return 0; +} + +void func_80840138(Player* pthis, f32 arg1, s16 arg2) { + s16 temp = arg2 - pthis->actor.shape.rot.y; + + if (arg1 > 0.0f) { + if (temp < 0) { + pthis->unk_874 = 0.0f; + } else { + pthis->unk_874 = 1.0f; + } + } + + Math_StepToF(&pthis->unk_870, pthis->unk_874, 0.3f); +} + +void func_808401B0(GlobalContext* globalCtx, Player* pthis) { + LinkAnimation_BlendToJoint(globalCtx, &pthis->skelAnime, func_808334E4(pthis), pthis->unk_868, func_80833528(pthis), + pthis->unk_868, pthis->unk_870, pthis->blendTable); +} + +s32 func_8084021C(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + f32 temp; + + if ((arg3 == 0.0f) && (arg1 > 0.0f)) { + arg3 = arg2; + } + + temp = (arg0 + arg1) - arg3; + + if (((temp * arg1) >= 0.0f) && (((temp - arg1) * arg1) < 0.0f)) { + return 1; + } + + return 0; +} + +void func_8084029C(Player* pthis, f32 arg1) { + f32 updateScale = R_UPDATE_RATE * 0.5f; + + arg1 *= updateScale; + if (arg1 < -7.25) { + arg1 = -7.25; + } else if (arg1 > 7.25f) { + arg1 = 7.25f; + } + + if (1) {} + + if ((pthis->currentBoots == PLAYER_BOOTS_HOVER) && !(pthis->actor.bgCheckFlags & 1) && (pthis->hoverBootsTimer != 0)) { + func_8002F8F0(&pthis->actor, NA_SE_PL_HOBBERBOOTS_LV - SFX_FLAG); + } else if (func_8084021C(pthis->unk_868, arg1, 29.0f, 10.0f) || func_8084021C(pthis->unk_868, arg1, 29.0f, 24.0f)) { + func_808327F8(pthis, pthis->linearVelocity); + if (pthis->linearVelocity > 4.0f) { + pthis->stateFlags2 |= 8; + } + } + + pthis->unk_868 += arg1; + + if (pthis->unk_868 < 0.0f) { + pthis->unk_868 += 29.0f; + } else if (pthis->unk_868 >= 29.0f) { + pthis->unk_868 -= 29.0f; + } +} + +void func_80840450(Player* pthis, GlobalContext* globalCtx) { + f32 sp44; + s16 sp42; + s32 temp1; + u32 temp2; + s16 temp3; + s32 temp4; + + if (pthis->stateFlags3 & 8) { + if (Player_GetSwordHeld(pthis)) { + pthis->stateFlags2 |= 0x60; + } else { + pthis->stateFlags3 &= ~8; + } + } + + if (pthis->unk_850 != 0) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832DBC(pthis); + func_80832284(globalCtx, pthis, func_808334E4(pthis)); + pthis->unk_850 = 0; + pthis->stateFlags3 &= ~8; + } + func_80833C3C(pthis); + } else { + func_808401B0(globalCtx, pthis); + } + + func_8083721C(pthis); + + if (!func_80837348(globalCtx, pthis, D_808543E0, 1)) { + if (!func_80833B54(pthis) && (!func_80833B2C(pthis) || (func_80834B5C != pthis->func_82C))) { + func_8083CF10(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp44, &sp42, 0.0f, globalCtx); + + temp1 = func_8083FC68(pthis, sp44, sp42); + + if (temp1 > 0) { + func_8083C8DC(pthis, globalCtx, sp42); + return; + } + + if (temp1 < 0) { + func_8083CBF0(pthis, sp42, globalCtx); + return; + } + + if (sp44 > 4.0f) { + func_8083CC9C(pthis, globalCtx); + return; + } + + func_8084029C(pthis, (pthis->linearVelocity * 0.3f) + 1.0f); + func_80840138(pthis, sp44, sp42); + + temp2 = pthis->unk_868; + if ((temp2 < 6) || ((temp2 - 0xE) < 6)) { + Math_StepToF(&pthis->linearVelocity, 0.0f, 1.5f); + return; + } + + temp3 = sp42 - pthis->currentYaw; + temp4 = ABS(temp3); + + if (temp4 > 0x4000) { + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 1.5f)) { + pthis->currentYaw = sp42; + } + return; + } + + Math_AsymStepToF(&pthis->linearVelocity, sp44 * 0.3f, 2.0f, 1.5f); + + if (!(pthis->stateFlags3 & 8)) { + Math_ScaledStepToS(&pthis->currentYaw, sp42, temp4 * 0.1f); + } + } +} + +void func_808407CC(Player* pthis, GlobalContext* globalCtx) { + f32 sp3C; + s16 sp3A; + s32 temp1; + s16 temp2; + s32 temp3; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832DBC(pthis); + func_80832264(globalCtx, pthis, func_80833338(pthis)); + } + + func_8083721C(pthis); + + if (!func_80837348(globalCtx, pthis, D_808543E8, 1)) { + if (func_80833B54(pthis)) { + func_8083CEAC(pthis, globalCtx); + return; + } + + if (!func_80833B2C(pthis)) { + func_80835DAC(globalCtx, pthis, func_80840BC8, 1); + pthis->currentYaw = pthis->actor.shape.rot.y; + return; + } + + if (func_80834B5C == pthis->func_82C) { + func_8083CEAC(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp3C, &sp3A, 0.0f, globalCtx); + + temp1 = func_8083FD78(pthis, &sp3C, &sp3A, globalCtx); + + if (temp1 > 0) { + func_8083C8DC(pthis, globalCtx, sp3A); + return; + } + + if (temp1 < 0) { + func_8083CB2C(pthis, sp3A, globalCtx); + return; + } + + if (sp3C > 4.9f) { + func_8083CC9C(pthis, globalCtx); + func_80833C3C(pthis); + return; + } + if (sp3C != 0.0f) { + func_8083CB94(pthis, globalCtx); + return; + } + + temp2 = sp3A - pthis->actor.shape.rot.y; + temp3 = ABS(temp2); + + if (temp3 > 800) { + func_8083CD54(globalCtx, pthis, sp3A); + } + } +} + +void func_808409CC(GlobalContext* globalCtx, Player* pthis) { + LinkAnimationHeader* anim; + LinkAnimationHeader** animPtr; + s32 heathIsCritical; + s32 sp38; + s32 sp34; + + if ((pthis->unk_664 != NULL) || + (!(heathIsCritical = HealthMeter_IsCritical()) && ((pthis->unk_6AC = (pthis->unk_6AC + 1) & 1) != 0))) { + pthis->stateFlags2 &= ~0x10000000; + anim = func_80833338(pthis); + } else { + pthis->stateFlags2 |= 0x10000000; + if (pthis->stateFlags1 & 0x800) { + anim = func_80833338(pthis); + } else { + sp38 = globalCtx->roomCtx.curRoom.unk_02; + if (heathIsCritical) { + if (pthis->unk_6AC >= 0) { + sp38 = 7; + pthis->unk_6AC = -1; + } else { + sp38 = 8; + } + } else { + sp34 = Rand_ZeroOne() * 5.0f; + if (sp34 < 4) { + if (((sp34 != 0) && (sp34 != 3)) || + ((pthis->rightHandType == 10) && ((sp34 == 3) || Player_GetSwordHeld(pthis)))) { + if ((sp34 == 0) && Player_HoldsTwoHandedWeapon(pthis)) { + sp34 = 4; + } + sp38 = sp34 + 9; + } + } + } + animPtr = &D_80853D7C[sp38][0]; + if (pthis->modelAnimType != 1) { + animPtr = &D_80853D7C[sp38][1]; + } + anim = *animPtr; + } + } + + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, (2.0f / 3.0f) * D_808535E8, 0.0f, + Animation_GetLastFrame(anim), ANIMMODE_ONCE, -6.0f); +} + +void func_80840BC8(Player* pthis, GlobalContext* globalCtx) { + s32 sp44; + s32 sp40; + f32 sp3C; + s16 sp3A; + s16 temp; + + sp44 = func_80833350(pthis); + sp40 = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (sp44 > 0) { + func_808333FC(pthis, sp44 - 1); + } + + if (sp40 != 0) { + if (pthis->unk_850 != 0) { + if (DECR(pthis->unk_850) == 0) { + pthis->skelAnime.endFrame = pthis->skelAnime.animLength - 1.0f; + } + pthis->skelAnime.jointTable[0].y = (pthis->skelAnime.jointTable[0].y + ((pthis->unk_850 & 1) * 0x50)) - 0x28; + } else { + func_80832DBC(pthis); + func_808409CC(globalCtx, pthis); + } + } + + func_8083721C(pthis); + + if (pthis->unk_850 == 0) { + if (!func_80837348(globalCtx, pthis, D_80854418, 1)) { + if (func_80833B54(pthis)) { + func_8083CEAC(pthis, globalCtx); + return; + } + + if (func_80833B2C(pthis)) { + func_80839F30(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp3C, &sp3A, 0.018f, globalCtx); + + if (sp3C != 0.0f) { + func_8083C8DC(pthis, globalCtx, sp3A); + return; + } + + temp = sp3A - pthis->actor.shape.rot.y; + if (ABS(temp) > 800) { + func_8083CD54(globalCtx, pthis, sp3A); + return; + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.y, sp3A, 1200); + pthis->currentYaw = pthis->actor.shape.rot.y; + if (func_80833338(pthis) == pthis->skelAnime.animation) { + func_8083DC54(pthis, globalCtx); + } + } + } +} + +void func_80840DE4(Player* pthis, GlobalContext* globalCtx) { + f32 frames; + f32 coeff; + f32 sp44; + s16 sp42; + s32 temp1; + s16 temp2; + s32 temp3; + s32 direction; + + pthis->skelAnime.mode = 0; + LinkAnimation_SetUpdateFunction(&pthis->skelAnime); + + pthis->skelAnime.animation = func_8083356C(pthis); + + if (pthis->skelAnime.animation == &gPlayerAnim_0026E8) { + frames = 24.0f; + coeff = -(MREG(95) / 100.0f); + } else { + frames = 29.0f; + coeff = MREG(95) / 100.0f; + } + + pthis->skelAnime.animLength = frames; + pthis->skelAnime.endFrame = frames - 1.0f; + + if ((s16)(pthis->currentYaw - pthis->actor.shape.rot.y) >= 0) { + direction = 1; + } else { + direction = -1; + } + + pthis->skelAnime.playSpeed = direction * (pthis->linearVelocity * coeff); + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 0.0f) || LinkAnimation_OnFrame(&pthis->skelAnime, frames * 0.5f)) { + func_808327F8(pthis, pthis->linearVelocity); + } + + if (!func_80837348(globalCtx, pthis, D_808543F4, 1)) { + if (func_80833B54(pthis)) { + func_8083CEAC(pthis, globalCtx); + return; + } + + if (!func_80833B2C(pthis)) { + func_80853080(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp44, &sp42, 0.0f, globalCtx); + temp1 = func_8083FD78(pthis, &sp44, &sp42, globalCtx); + + if (temp1 > 0) { + func_8083C8DC(pthis, globalCtx, sp42); + return; + } + + if (temp1 < 0) { + func_8083CB2C(pthis, sp42, globalCtx); + return; + } + + if (sp44 > 4.9f) { + func_8083CC9C(pthis, globalCtx); + func_80833C3C(pthis); + return; + } + + if ((sp44 == 0.0f) && (pthis->linearVelocity == 0.0f)) { + func_80839F30(pthis, globalCtx); + return; + } + + temp2 = sp42 - pthis->currentYaw; + temp3 = ABS(temp2); + + if (temp3 > 0x4000) { + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 1.5f)) { + pthis->currentYaw = sp42; + } + return; + } + + Math_AsymStepToF(&pthis->linearVelocity, sp44 * 0.4f, 1.5f, 1.5f); + Math_ScaledStepToS(&pthis->currentYaw, sp42, temp3 * 0.1f); + } +} + +void func_80841138(Player* pthis, GlobalContext* globalCtx) { + f32 temp1; + f32 temp2; + + if (pthis->unk_864 < 1.0f) { + temp1 = R_UPDATE_RATE * 0.5f; + func_8084029C(pthis, REG(35) / 1000.0f); + LinkAnimation_LoadToJoint(globalCtx, &pthis->skelAnime, D_80853BFC[pthis->modelAnimType], pthis->unk_868); + pthis->unk_864 += 1 * temp1; + if (pthis->unk_864 >= 1.0f) { + pthis->unk_864 = 1.0f; + } + temp1 = pthis->unk_864; + } else { + temp2 = pthis->linearVelocity - (REG(48) / 100.0f); + if (temp2 < 0.0f) { + temp1 = 1.0f; + func_8084029C(pthis, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * pthis->linearVelocity)); + LinkAnimation_LoadToJoint(globalCtx, &pthis->skelAnime, D_80853BFC[pthis->modelAnimType], pthis->unk_868); + } else { + temp1 = (REG(37) / 1000.0f) * temp2; + if (temp1 < 1.0f) { + func_8084029C(pthis, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * pthis->linearVelocity)); + } else { + temp1 = 1.0f; + func_8084029C(pthis, 1.2f + ((REG(38) / 1000.0f) * temp2)); + } + LinkAnimation_LoadToMorph(globalCtx, &pthis->skelAnime, D_80853BFC[pthis->modelAnimType], pthis->unk_868); + LinkAnimation_LoadToJoint(globalCtx, &pthis->skelAnime, &gPlayerAnim_002DD0, + pthis->unk_868 * (16.0f / 29.0f)); + } + } + + if (temp1 < 1.0f) { + LinkAnimation_InterpJointMorph(globalCtx, &pthis->skelAnime, 1.0f - temp1); + } +} + +void func_8084140C(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084170C, 1); + func_80832B0C(globalCtx, pthis, &gPlayerAnim_002DA0); +} + +s32 func_80841458(Player* pthis, f32* arg1, s16* arg2, GlobalContext* globalCtx) { + if (pthis->linearVelocity > 6.0f) { + func_8084140C(pthis, globalCtx); + return 1; + } + + if (*arg1 != 0.0f) { + if (func_8083721C(pthis)) { + *arg1 = 0.0f; + *arg2 = pthis->currentYaw; + } else { + return 1; + } + } + + return 0; +} + +void func_808414F8(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + s32 sp2C; + s16 sp2A; + + func_80841138(pthis, globalCtx); + + if (!func_80837348(globalCtx, pthis, D_80854400, 1)) { + if (!func_80833C04(pthis)) { + func_8083C8DC(pthis, globalCtx, pthis->currentYaw); + return; + } + + func_80837268(pthis, &sp34, &sp32, 0.0f, globalCtx); + sp2C = func_8083FD78(pthis, &sp34, &sp32, globalCtx); + + if (sp2C >= 0) { + if (!func_80841458(pthis, &sp34, &sp32, globalCtx)) { + if (sp2C != 0) { + func_8083C858(pthis, globalCtx); + } else if (sp34 > 4.9f) { + func_8083CC9C(pthis, globalCtx); + } else { + func_8083CB94(pthis, globalCtx); + } + } + } else { + sp2A = sp32 - pthis->currentYaw; + + Math_AsymStepToF(&pthis->linearVelocity, sp34 * 1.5f, 1.5f, 2.0f); + Math_ScaledStepToS(&pthis->currentYaw, sp32, sp2A * 0.1f); + + if ((sp34 == 0.0f) && (pthis->linearVelocity == 0.0f)) { + func_80839F30(pthis, globalCtx); + } + } + } +} + +void func_808416C0(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_808417FC, 1); + func_80832264(globalCtx, pthis, &gPlayerAnim_002DA8); +} + +void func_8084170C(Player* pthis, GlobalContext* globalCtx) { + s32 sp34; + f32 sp30; + s16 sp2E; + + sp34 = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_8083721C(pthis); + + if (!func_80837348(globalCtx, pthis, D_80854400, 1)) { + func_80837268(pthis, &sp30, &sp2E, 0.0f, globalCtx); + + if (pthis->linearVelocity == 0.0f) { + pthis->currentYaw = pthis->actor.shape.rot.y; + + if (func_8083FD78(pthis, &sp30, &sp2E, globalCtx) > 0) { + func_8083C858(pthis, globalCtx); + } else if ((sp30 != 0.0f) || (sp34 != 0)) { + func_808416C0(pthis, globalCtx); + } + } + } +} + +void func_808417FC(Player* pthis, GlobalContext* globalCtx) { + s32 sp1C; + + sp1C = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (!func_80837348(globalCtx, pthis, D_80854400, 1)) { + if (sp1C != 0) { + func_80839F30(pthis, globalCtx); + } + } +} + +void func_80841860(GlobalContext* globalCtx, Player* pthis) { + f32 frame; + LinkAnimationHeader* sp38 = D_80853B54[pthis->modelAnimType]; + LinkAnimationHeader* sp34 = D_80853B6C[pthis->modelAnimType]; + + pthis->skelAnime.animation = sp38; + + func_8084029C(pthis, (REG(30) / 1000.0f) + ((REG(32) / 1000.0f) * pthis->linearVelocity)); + + frame = pthis->unk_868 * (16.0f / 29.0f); + LinkAnimation_BlendToJoint(globalCtx, &pthis->skelAnime, sp34, frame, sp38, frame, pthis->unk_870, pthis->blendTable); +} + +void func_8084193C(Player* pthis, GlobalContext* globalCtx) { + f32 sp3C; + s16 sp3A; + s32 temp1; + s16 temp2; + s32 temp3; + + func_80841860(globalCtx, pthis); + + if (!func_80837348(globalCtx, pthis, D_80854408, 1)) { + if (!func_80833C04(pthis)) { + func_8083C858(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp3C, &sp3A, 0.0f, globalCtx); + + if (func_80833B2C(pthis)) { + temp1 = func_8083FD78(pthis, &sp3C, &sp3A, globalCtx); + } else { + temp1 = func_8083FC68(pthis, sp3C, sp3A); + } + + if (temp1 > 0) { + func_8083C858(pthis, globalCtx); + return; + } + + if (temp1 < 0) { + if (func_80833B2C(pthis)) { + func_8083CB2C(pthis, sp3A, globalCtx); + } else { + func_8083CBF0(pthis, sp3A, globalCtx); + } + return; + } + + if ((pthis->linearVelocity < 3.6f) && (sp3C < 4.0f)) { + if (!func_8008E9C4(pthis) && func_80833B2C(pthis)) { + func_8083CB94(pthis, globalCtx); + } else { + func_80839F90(pthis, globalCtx); + } + return; + } + + func_80840138(pthis, sp3C, sp3A); + + temp2 = sp3A - pthis->currentYaw; + temp3 = ABS(temp2); + + if (temp3 > 0x4000) { + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 3.0f) != 0) { + pthis->currentYaw = sp3A; + } + return; + } + + sp3C *= 0.9f; + Math_AsymStepToF(&pthis->linearVelocity, sp3C, 2.0f, 3.0f); + Math_ScaledStepToS(&pthis->currentYaw, sp3A, temp3 * 0.1f); + } +} + +void func_80841BA8(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (Player_HoldsTwoHandedWeapon(pthis)) { + AnimationContext_SetLoadFrame(globalCtx, func_80833338(pthis), 0, pthis->skelAnime.limbCount, + pthis->skelAnime.morphTable); + AnimationContext_SetCopyTrue(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->skelAnime.morphTable, D_80853410); + } + + func_80837268(pthis, &sp34, &sp32, 0.018f, globalCtx); + + if (!func_80837348(globalCtx, pthis, D_80854414, 1)) { + if (sp34 != 0.0f) { + pthis->actor.shape.rot.y = sp32; + func_8083C858(pthis, globalCtx); + } else if (Math_ScaledStepToS(&pthis->actor.shape.rot.y, sp32, pthis->unk_87E)) { + func_8083C0E8(pthis, globalCtx); + } + + pthis->currentYaw = pthis->actor.shape.rot.y; + } +} + +void func_80841CC4(Player* pthis, s32 arg1, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + s16 target; + f32 rate; + + if (ABS(D_80853610) < 3640) { + target = 0; + } else { + target = CLAMP(D_80853610, -10922, 10922); + } + + Math_ScaledStepToS(&pthis->unk_89C, target, 400); + + if ((pthis->modelAnimType == 3) || ((pthis->unk_89C == 0) && (pthis->unk_6C4 <= 0.0f))) { + if (arg1 == 0) { + LinkAnimation_LoadToJoint(globalCtx, &pthis->skelAnime, D_8085392C[pthis->modelAnimType], pthis->unk_868); + } else { + LinkAnimation_LoadToMorph(globalCtx, &pthis->skelAnime, D_8085392C[pthis->modelAnimType], pthis->unk_868); + } + return; + } + + if (pthis->unk_89C != 0) { + rate = pthis->unk_89C / 10922.0f; + } else { + rate = pthis->unk_6C4 * 0.0006f; + } + + rate *= fabsf(pthis->linearVelocity) * 0.5f; + + if (rate > 1.0f) { + rate = 1.0f; + } + + if (rate < 0.0f) { + anim = &gPlayerAnim_002E48; + rate = -rate; + } else { + anim = &gPlayerAnim_002E90; + } + + if (arg1 == 0) { + LinkAnimation_BlendToJoint(globalCtx, &pthis->skelAnime, D_8085392C[pthis->modelAnimType], pthis->unk_868, anim, + pthis->unk_868, rate, pthis->blendTable); + } else { + LinkAnimation_BlendToMorph(globalCtx, &pthis->skelAnime, D_8085392C[pthis->modelAnimType], pthis->unk_868, anim, + pthis->unk_868, rate, pthis->blendTable); + } +} + +void func_80841EE4(Player* pthis, GlobalContext* globalCtx) { + f32 temp1; + f32 temp2; + + if (pthis->unk_864 < 1.0f) { + temp1 = R_UPDATE_RATE * 0.5f; + + func_8084029C(pthis, REG(35) / 1000.0f); + LinkAnimation_LoadToJoint(globalCtx, &pthis->skelAnime, D_8085392C[pthis->modelAnimType], pthis->unk_868); + + pthis->unk_864 += 1 * temp1; + if (pthis->unk_864 >= 1.0f) { + pthis->unk_864 = 1.0f; + } + + temp1 = pthis->unk_864; + } else { + temp2 = pthis->linearVelocity - (REG(48) / 100.0f); + + if (temp2 < 0.0f) { + temp1 = 1.0f; + func_8084029C(pthis, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * pthis->linearVelocity)); + + func_80841CC4(pthis, 0, globalCtx); + } else { + temp1 = (REG(37) / 1000.0f) * temp2; + if (temp1 < 1.0f) { + func_8084029C(pthis, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * pthis->linearVelocity)); + } else { + temp1 = 1.0f; + func_8084029C(pthis, 1.2f + ((REG(38) / 1000.0f) * temp2)); + } + + func_80841CC4(pthis, 1, globalCtx); + + LinkAnimation_LoadToJoint(globalCtx, &pthis->skelAnime, func_80833438(pthis), + pthis->unk_868 * (20.0f / 29.0f)); + } + } + + if (temp1 < 1.0f) { + LinkAnimation_InterpJointMorph(globalCtx, &pthis->skelAnime, 1.0f - temp1); + } +} + +void func_80842180(Player* pthis, GlobalContext* globalCtx) { + f32 sp2C; + s16 sp2A; + + pthis->stateFlags2 |= 0x20; + func_80841EE4(pthis, globalCtx); + + if (!func_80837348(globalCtx, pthis, D_80854424, 1)) { + if (func_80833C04(pthis)) { + func_8083C858(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp2C, &sp2A, 0.018f, globalCtx); + + if (!func_8083C484(pthis, &sp2C, &sp2A)) { + func_8083DF68(pthis, sp2C, sp2A); + func_8083DDC8(pthis, globalCtx); + + if ((pthis->linearVelocity == 0.0f) && (sp2C == 0.0f)) { + func_8083C0B8(pthis, globalCtx); + } + } + } +} + +void func_8084227C(Player* pthis, GlobalContext* globalCtx) { + f32 sp2C; + s16 sp2A; + + pthis->stateFlags2 |= 0x20; + func_80841EE4(pthis, globalCtx); + + if (!func_80837348(globalCtx, pthis, D_80854430, 1)) { + if (!func_80833C04(pthis)) { + func_8083C858(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp2C, &sp2A, 0.0f, globalCtx); + + if (!func_8083C484(pthis, &sp2C, &sp2A)) { + if ((func_80833B2C(pthis) && (sp2C != 0.0f) && (func_8083FD78(pthis, &sp2C, &sp2A, globalCtx) <= 0)) || + (!func_80833B2C(pthis) && (func_8083FC68(pthis, sp2C, sp2A) <= 0))) { + func_80839F90(pthis, globalCtx); + return; + } + + func_8083DF68(pthis, sp2C, sp2A); + func_8083DDC8(pthis, globalCtx); + + if ((pthis->linearVelocity == 0) && (sp2C == 0)) { + func_80839F90(pthis, globalCtx); + } + } + } +} + +void func_808423EC(Player* pthis, GlobalContext* globalCtx) { + s32 sp34; + f32 sp30; + s16 sp2E; + + sp34 = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (!func_80837348(globalCtx, pthis, D_80854408, 1)) { + if (!func_80833C04(pthis)) { + func_8083C858(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp30, &sp2E, 0.0f, globalCtx); + + if ((pthis->skelAnime.morphWeight == 0.0f) && (pthis->skelAnime.curFrame > 5.0f)) { + func_8083721C(pthis); + + if ((pthis->skelAnime.curFrame > 10.0f) && (func_8083FC68(pthis, sp30, sp2E) < 0)) { + func_8083CBF0(pthis, sp2E, globalCtx); + return; + } + + if (sp34 != 0) { + func_8083CD00(pthis, globalCtx); + } + } + } +} + +void func_8084251C(Player* pthis, GlobalContext* globalCtx) { + s32 sp34; + f32 sp30; + s16 sp2E; + + sp34 = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + func_8083721C(pthis); + + if (!func_80837348(globalCtx, pthis, D_80854440, 1)) { + func_80837268(pthis, &sp30, &sp2E, 0.0f, globalCtx); + + if (pthis->linearVelocity == 0.0f) { + pthis->currentYaw = pthis->actor.shape.rot.y; + + if (func_8083FC68(pthis, sp30, sp2E) > 0) { + func_8083C858(pthis, globalCtx); + return; + } + + if ((sp30 != 0.0f) || (sp34 != 0)) { + func_80839F90(pthis, globalCtx); + } + } + } +} + +void func_8084260C(Vec3f* src, Vec3f* dest, f32 arg2, f32 arg3, f32 arg4) { + dest->x = (Rand_ZeroOne() * arg3) + src->x; + dest->y = (Rand_ZeroOne() * arg4) + (src->y + arg2); + dest->z = (Rand_ZeroOne() * arg3) + src->z; +} + +static Vec3f D_808545B4 = { 0.0f, 0.0f, 0.0f }; +static Vec3f D_808545C0 = { 0.0f, 0.0f, 0.0f }; + +s32 func_8084269C(GlobalContext* globalCtx, Player* pthis) { + Vec3f sp2C; + + if ((pthis->unk_89E == 0) || (pthis->unk_89E == 1)) { + func_8084260C(&pthis->actor.shape.feetPos[FOOT_LEFT], &sp2C, + pthis->actor.floorHeight - pthis->actor.shape.feetPos[FOOT_LEFT].y, 7.0f, 5.0f); + func_800286CC(globalCtx, &sp2C, &D_808545B4, &D_808545C0, 50, 30); + func_8084260C(&pthis->actor.shape.feetPos[FOOT_RIGHT], &sp2C, + pthis->actor.floorHeight - pthis->actor.shape.feetPos[FOOT_RIGHT].y, 7.0f, 5.0f); + func_800286CC(globalCtx, &pthis->actor.shape.feetPos[FOOT_RIGHT], &D_808545B4, &D_808545C0, 50, 30); + return 1; + } + + return 0; +} + +void func_8084279C(Player* pthis, GlobalContext* globalCtx) { + func_80832CB0(globalCtx, pthis, D_80853C2C[pthis->modelAnimType]); + + if (DECR(pthis->unk_850) == 0) { + if (!func_8083B040(pthis, globalCtx)) { + func_8083A098(pthis, D_80853C44[pthis->modelAnimType], globalCtx); + } + + pthis->actor.flags &= ~ACTOR_FLAG_8; + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + } +} + +s32 func_8084285C(Player* pthis, f32 arg1, f32 arg2, f32 arg3) { + if ((arg1 <= pthis->skelAnime.curFrame) && (pthis->skelAnime.curFrame <= arg3)) { + func_80833A20(pthis, (arg2 <= pthis->skelAnime.curFrame) ? 1 : -1); + return 1; + } + + func_80832318(pthis); + return 0; +} + +s32 func_808428D8(Player* pthis, GlobalContext* globalCtx) { + if (!Player_IsChildWithHylianShield(pthis) && Player_GetSwordHeld(pthis) && D_80853614) { + func_80832264(globalCtx, pthis, &gPlayerAnim_002EC8); + pthis->unk_84F = 1; + pthis->swordAnimation = 0xC; + pthis->currentYaw = pthis->actor.shape.rot.y + pthis->unk_6BE; + return 1; + } + + return 0; +} + +s32 func_80842964(Player* pthis, GlobalContext* globalCtx) { + return func_8083B040(pthis, globalCtx) || func_8083B644(pthis, globalCtx) || func_8083E5A8(pthis, globalCtx); +} + +void func_808429B4(GlobalContext* globalCtx, s32 speed, s32 y, s32 countdown) { + s32 quakeIdx = Quake_Add(Gameplay_GetCamera(globalCtx, 0), 3); + + Quake_SetSpeed(quakeIdx, speed); + Quake_SetQuakeValues(quakeIdx, y, 0, 0, 0); + Quake_SetCountdown(quakeIdx, countdown); +} + +void func_80842A28(GlobalContext* globalCtx, Player* pthis) { + func_808429B4(globalCtx, 27767, 7, 20); + globalCtx->actorCtx.unk_02 = 4; + func_8083264C(pthis, 255, 20, 150, 0); + func_8002F7DC(&pthis->actor, NA_SE_IT_HAMMER_HIT); +} + +void func_80842A88(GlobalContext* globalCtx, Player* pthis) { + Inventory_ChangeAmmo(ITEM_STICK, -1); + func_80835F44(globalCtx, pthis, ITEM_NONE); +} + +s32 func_80842AC4(GlobalContext* globalCtx, Player* pthis) { + if ((pthis->heldItemActionParam == PLAYER_AP_STICK) && (pthis->unk_85C > 0.5f)) { + if (AMMO(ITEM_STICK) != 0) { + EffectSsStick_Spawn(globalCtx, &pthis->bodyPartsPos[15], pthis->actor.shape.rot.y + 0x8000); + pthis->unk_85C = 0.5f; + func_80842A88(globalCtx, pthis); + func_8002F7DC(&pthis->actor, NA_SE_IT_WOODSTICK_BROKEN); + } + + return 1; + } + + return 0; +} + +s32 func_80842B7C(GlobalContext* globalCtx, Player* pthis) { + if (pthis->heldItemActionParam == PLAYER_AP_SWORD_BGS) { + if (!gSaveContext.bgsFlag && (gSaveContext.swordHealth > 0.0f)) { + if ((gSaveContext.swordHealth -= 1.0f) <= 0.0f) { + EffectSsStick_Spawn(globalCtx, &pthis->bodyPartsPos[15], pthis->actor.shape.rot.y + 0x8000); + func_800849EC(globalCtx); + func_8002F7DC(&pthis->actor, NA_SE_IT_MAJIN_SWORD_BROKEN); + } + } + + return 1; + } + + return 0; +} + +void func_80842CF0(GlobalContext* globalCtx, Player* pthis) { + func_80842AC4(globalCtx, pthis); + func_80842B7C(globalCtx, pthis); +} + +static LinkAnimationHeader* D_808545CC[] = { + &gPlayerAnim_002B10, + &gPlayerAnim_002B20, + &gPlayerAnim_002B08, + &gPlayerAnim_002B18, +}; + +void func_80842D20(GlobalContext* globalCtx, Player* pthis) { + s32 pad; + s32 sp28; + + if (func_80843188 != pthis->func_674) { + func_80832440(globalCtx, pthis); + func_80835C58(globalCtx, pthis, func_808505DC, 0); + + if (func_8008E9C4(pthis)) { + sp28 = 2; + } else { + sp28 = 0; + } + + func_808322D0(globalCtx, pthis, D_808545CC[Player_HoldsTwoHandedWeapon(pthis) + sp28]); + } + + func_8083264C(pthis, 180, 20, 100, 0); + pthis->linearVelocity = -18.0f; + func_80842CF0(globalCtx, pthis); +} + +s32 func_80842DF4(GlobalContext* globalCtx, Player* pthis) { + f32 phi_f2; + CollisionPoly* sp78; + s32 sp74; + Vec3f sp68; + Vec3f sp5C; + Vec3f sp50; + s32 temp1; + s32 sp48; + + if (pthis->swordState > 0) { + if (pthis->swordAnimation < 0x18) { + if (!(pthis->swordQuads[0].base.atFlags & AT_BOUNCED) && !(pthis->swordQuads[1].base.atFlags & AT_BOUNCED)) { + if (pthis->skelAnime.curFrame >= 2.0f) { + + phi_f2 = Math_Vec3f_DistXYZAndStoreDiff(&pthis->swordInfo[0].tip, &pthis->swordInfo[0].base, &sp50); + if (phi_f2 != 0.0f) { + phi_f2 = (phi_f2 + 10.0f) / phi_f2; + } + + sp68.x = pthis->swordInfo[0].tip.x + (sp50.x * phi_f2); + sp68.y = pthis->swordInfo[0].tip.y + (sp50.y * phi_f2); + sp68.z = pthis->swordInfo[0].tip.z + (sp50.z * phi_f2); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp68, &pthis->swordInfo[0].tip, &sp5C, &sp78, true, + false, false, true, &sp74) && + !SurfaceType_IsIgnoredByEntities(&globalCtx->colCtx, sp78, sp74) && + (func_80041D4C(&globalCtx->colCtx, sp78, sp74) != 6) && + (func_8002F9EC(globalCtx, &pthis->actor, sp78, sp74, &sp5C) == 0)) { + + if (pthis->heldItemActionParam == PLAYER_AP_HAMMER) { + func_80832630(globalCtx); + func_80842A28(globalCtx, pthis); + func_80842D20(globalCtx, pthis); + return 1; + } + + if (pthis->linearVelocity >= 0.0f) { + sp48 = func_80041F10(&globalCtx->colCtx, sp78, sp74); + + if (sp48 == 0xA) { + CollisionCheck_SpawnShieldParticlesWood(globalCtx, &sp5C, &pthis->actor.projectedPos); + } else { + CollisionCheck_SpawnShieldParticles(globalCtx, &sp5C); + if (sp48 == 0xB) { + func_8002F7DC(&pthis->actor, NA_SE_IT_WALL_HIT_SOFT); + } else { + func_8002F7DC(&pthis->actor, NA_SE_IT_WALL_HIT_HARD); + } + } + + func_80842CF0(globalCtx, pthis); + pthis->linearVelocity = -14.0f; + func_8083264C(pthis, 180, 20, 100, 0); + } + } + } + } else { + func_80842D20(globalCtx, pthis); + func_80832630(globalCtx); + return 1; + } + } + + temp1 = (pthis->swordQuads[0].base.atFlags & AT_HIT) || (pthis->swordQuads[1].base.atFlags & AT_HIT); + + if (temp1) { + if (pthis->swordAnimation < 0x18) { + Actor* at = pthis->swordQuads[temp1 ? 1 : 0].base.at; + + if ((at != NULL) && (at->id != ACTOR_EN_KANBAN)) { + func_80832630(globalCtx); + } + } + + if ((func_80842AC4(globalCtx, pthis) == 0) && (pthis->heldItemActionParam != PLAYER_AP_HAMMER)) { + func_80842B7C(globalCtx, pthis); + + if (pthis->actor.colChkInfo.atHitEffect == 1) { + pthis->actor.colChkInfo.damage = 8; + func_80837C0C(globalCtx, pthis, 4, 0.0f, 0.0f, pthis->actor.shape.rot.y, 20); + return 1; + } + } + } + } + + return 0; +} + +void func_80843188(Player* pthis, GlobalContext* globalCtx) { + f32 sp54; + f32 sp50; + s16 sp4E; + s16 sp4C; + s16 sp4A; + s16 sp48; + s16 sp46; + f32 sp40; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (!Player_IsChildWithHylianShield(pthis)) { + func_80832284(globalCtx, pthis, D_80853B0C[pthis->modelAnimType]); + } + pthis->unk_850 = 1; + pthis->unk_84F = 0; + } + + if (!Player_IsChildWithHylianShield(pthis)) { + pthis->stateFlags1 |= 0x400000; + func_80836670(pthis, globalCtx); + pthis->stateFlags1 &= ~0x400000; + } + + func_8083721C(pthis); + + if (pthis->unk_850 != 0) { + sp54 = sControlInput->rel.stick_y * 100; + sp50 = sControlInput->rel.stick_x * -120; + sp4E = pthis->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); + + sp40 = Math_CosS(sp4E); + sp4C = (Math_SinS(sp4E) * sp50) + (sp54 * sp40); + sp40 = Math_CosS(sp4E); + sp4A = (sp50 * sp40) - (Math_SinS(sp4E) * sp54); + + if (sp4C > 3500) { + sp4C = 3500; + } + + sp48 = ABS(sp4C - pthis->actor.focus.rot.x) * 0.25f; + if (sp48 < 100) { + sp48 = 100; + } + + sp46 = ABS(sp4A - pthis->unk_6BE) * 0.25f; + if (sp46 < 50) { + sp46 = 50; + } + + Math_ScaledStepToS(&pthis->actor.focus.rot.x, sp4C, sp48); + pthis->unk_6BC = pthis->actor.focus.rot.x; + Math_ScaledStepToS(&pthis->unk_6BE, sp4A, sp46); + + if (pthis->unk_84F != 0) { + if (!func_80842DF4(globalCtx, pthis)) { + if (pthis->skelAnime.curFrame < 2.0f) { + func_80833A20(pthis, 1); + } + } else { + pthis->unk_850 = 1; + pthis->unk_84F = 0; + } + } else if (!func_80842964(pthis, globalCtx)) { + if (func_8083C2B0(pthis, globalCtx)) { + func_808428D8(pthis, globalCtx); + } else { + pthis->stateFlags1 &= ~0x400000; + func_80832318(pthis); + + if (Player_IsChildWithHylianShield(pthis)) { + func_8083A060(pthis, globalCtx); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_002400, 1.0f, + Animation_GetLastFrame(&gPlayerAnim_002400), 0.0f, ANIMMODE_ONCE, 0.0f); + func_80832F54(globalCtx, pthis, 4); + } else { + if (pthis->itemActionParam < 0) { + func_8008EC70(pthis); + } + func_8083A098(pthis, D_80853B24[pthis->modelAnimType], globalCtx); + } + + func_8002F7DC(&pthis->actor, NA_SE_IT_SHIELD_REMOVE); + return; + } + } else { + return; + } + } + + pthis->stateFlags1 |= 0x400000; + Player_SetModelsForHoldingShield(pthis); + + pthis->unk_6AE |= 0xC1; +} + +void func_808435C4(Player* pthis, GlobalContext* globalCtx) { + s32 temp; + LinkAnimationHeader* anim; + f32 frames; + + func_8083721C(pthis); + + if (pthis->unk_84F == 0) { + D_808535E0 = func_80836670(pthis, globalCtx); + if ((func_80834B5C == pthis->func_82C) || (func_808374A0(globalCtx, pthis, &pthis->skelAnime2, 4.0f) > 0)) { + func_80835C58(globalCtx, pthis, func_80840450, 1); + } + } else { + temp = func_808374A0(globalCtx, pthis, &pthis->skelAnime, 4.0f); + if ((temp != 0) && ((temp > 0) || LinkAnimation_Update(globalCtx, &pthis->skelAnime))) { + func_80835C58(globalCtx, pthis, func_80843188, 1); + pthis->stateFlags1 |= 0x400000; + Player_SetModelsForHoldingShield(pthis); + anim = D_80853AF4[pthis->modelAnimType]; + frames = Animation_GetLastFrame(anim); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, 1.0f, frames, frames, ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_8084370C(Player* pthis, GlobalContext* globalCtx) { + s32 sp1C; + + func_8083721C(pthis); + + sp1C = func_808374A0(globalCtx, pthis, &pthis->skelAnime, 16.0f); + if ((sp1C != 0) && (LinkAnimation_Update(globalCtx, &pthis->skelAnime) || (sp1C > 0))) { + func_80839F90(pthis, globalCtx); + } +} + +void func_8084377C(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x60; + + func_808382BC(pthis); + + if (!(pthis->stateFlags1 & 0x20000000) && (pthis->unk_850 == 0) && (pthis->unk_8A1 != 0)) { + s16 temp = pthis->actor.shape.rot.y - pthis->unk_8A2; + + pthis->currentYaw = pthis->actor.shape.rot.y = pthis->unk_8A2; + pthis->linearVelocity = pthis->unk_8A4; + + if (ABS(temp) > 0x4000) { + pthis->actor.shape.rot.y = pthis->unk_8A2 + 0x8000; + } + + if (pthis->actor.velocity.y < 0.0f) { + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + } + } + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) && (pthis->actor.bgCheckFlags & 1)) { + if (pthis->unk_850 != 0) { + pthis->unk_850--; + if (pthis->unk_850 == 0) { + func_80853080(pthis, globalCtx); + } + } else if ((pthis->stateFlags1 & 0x20000000) || + (!(pthis->cylinder.base.acFlags & AC_HIT) && (pthis->unk_8A1 == 0))) { + if (pthis->stateFlags1 & 0x20000000) { + pthis->unk_850++; + } else { + func_80835C58(globalCtx, pthis, func_80843954, 0); + pthis->stateFlags1 |= 0x4000000; + } + + func_80832264(globalCtx, pthis, + (pthis->currentYaw != pthis->actor.shape.rot.y) ? &gPlayerAnim_002F60 : &gPlayerAnim_002DB8); + func_80832698(pthis, NA_SE_VO_LI_FREEZE); + } + } + + if (pthis->actor.bgCheckFlags & 2) { + func_80832770(pthis, NA_SE_PL_BOUND); + } +} + +void func_80843954(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x60; + func_808382BC(pthis); + + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) && (pthis->linearVelocity == 0.0f)) { + if (pthis->stateFlags1 & 0x20000000) { + pthis->unk_850++; + } else { + func_80835C58(globalCtx, pthis, func_80843A38, 0); + pthis->stateFlags1 |= 0x4000000; + } + + func_808322D0(globalCtx, pthis, + (pthis->currentYaw != pthis->actor.shape.rot.y) ? &gPlayerAnim_002F68 : &gPlayerAnim_002DC0); + pthis->currentYaw = pthis->actor.shape.rot.y; + } +} + +static struct_80832924 D_808545DC[] = { + { 0, 0x4014 }, + { 0, -0x401E }, +}; + +void func_80843A38(Player* pthis, GlobalContext* globalCtx) { + s32 sp24; + + pthis->stateFlags2 |= 0x20; + func_808382BC(pthis); + + if (pthis->stateFlags1 & 0x20000000) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + } else { + sp24 = func_808374A0(globalCtx, pthis, &pthis->skelAnime, 16.0f); + if ((sp24 != 0) && (LinkAnimation_Update(globalCtx, &pthis->skelAnime) || (sp24 > 0))) { + func_80839F90(pthis, globalCtx); + } + } + + func_80832924(pthis, D_808545DC); +} + +static Vec3f D_808545E4 = { 0.0f, 0.0f, 5.0f }; + +void func_80843AE8(GlobalContext* globalCtx, Player* pthis) { + if (pthis->unk_850 != 0) { + if (pthis->unk_850 > 0) { + pthis->unk_850--; + if (pthis->unk_850 == 0) { + if (pthis->stateFlags1 & 0x8000000) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_003328, 1.0f, 0.0f, + Animation_GetLastFrame(&gPlayerAnim_003328), ANIMMODE_ONCE, -16.0f); + } else { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_002878, 1.0f, 99.0f, + Animation_GetLastFrame(&gPlayerAnim_002878), ANIMMODE_ONCE, 0.0f); + } + gSaveContext.healthAccumulator = 0x140; + pthis->unk_850 = -1; + } + } else if (gSaveContext.healthAccumulator == 0) { + pthis->stateFlags1 &= ~0x80; + if (pthis->stateFlags1 & 0x8000000) { + func_80838F18(globalCtx, pthis); + } else { + func_80853080(pthis, globalCtx); + } + pthis->unk_A87 = 20; + func_80837AFC(pthis, -20); + func_800F47FC(); + } + } else if (pthis->unk_84F != 0) { + pthis->unk_850 = 60; + Player_SpawnFairy(globalCtx, pthis, &pthis->actor.world.pos, &D_808545E4, FAIRY_REVIVE_DEATH); + func_8002F7DC(&pthis->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + OnePointCutscene_Init(globalCtx, 9908, 125, &pthis->actor, MAIN_CAM); + } else if (globalCtx->gameOverCtx.state == GAMEOVER_DEATH_WAIT_GROUND) { + globalCtx->gameOverCtx.state = GAMEOVER_DEATH_DELAY_MENU; + } +} + +static struct_80832924 D_808545F0[] = { + { NA_SE_PL_BOUND, 0x103C }, + { 0, 0x408C }, + { 0, 0x40A4 }, + { 0, -0x40AA }, +}; + +void func_80843CEC(Player* pthis, GlobalContext* globalCtx) { + if (pthis->currentTunic != PLAYER_TUNIC_GORON) { + if ((globalCtx->roomCtx.curRoom.unk_02 == 3) || (D_808535E4 == 9) || + ((func_80838144(D_808535E4) >= 0) && + !SurfaceType_IsWallDamage(&globalCtx->colCtx, pthis->actor.floorPoly, pthis->actor.floorBgId))) { + func_8083821C(pthis); + } + } + + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->actor.category == ACTORCAT_PLAYER) { + func_80843AE8(globalCtx, pthis); + } + return; + } + + if (pthis->skelAnime.animation == &gPlayerAnim_002878) { + func_80832924(pthis, D_808545F0); + } else if (pthis->skelAnime.animation == &gPlayerAnim_002F08) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 88.0f)) { + func_80832770(pthis, NA_SE_PL_BOUND); + } + } +} + +void func_80843E14(Player* pthis, u16 sfxId) { + func_80832698(pthis, sfxId); + + if ((pthis->heldActor != NULL) && (pthis->heldActor->id == ACTOR_EN_RU1)) { + Audio_PlayActorSound2(pthis->heldActor, NA_SE_VO_RT_FALL); + } +} + +static FallImpactInfo D_80854600[] = { + { -8, 180, 40, 100, NA_SE_VO_LI_LAND_DAMAGE_S }, + { -16, 255, 140, 150, NA_SE_VO_LI_LAND_DAMAGE_S }, +}; + +s32 func_80843E64(GlobalContext* globalCtx, Player* pthis) { + s32 sp34; + + if ((D_808535E4 == 6) || (D_808535E4 == 9)) { + sp34 = 0; + } else { + sp34 = pthis->fallDistance; + } + + Math_StepToF(&pthis->linearVelocity, 0.0f, 1.0f); + + pthis->stateFlags1 &= ~0xC0000; + + if (sp34 >= 400) { + s32 impactIndex; + FallImpactInfo* impactInfo; + + if (pthis->fallDistance < 800) { + impactIndex = 0; + } else { + impactIndex = 1; + } + + impactInfo = &D_80854600[impactIndex]; + + if (Player_InflictDamage(globalCtx, impactInfo->damage)) { + return -1; + } + + func_80837AE0(pthis, 40); + func_808429B4(globalCtx, 32967, 2, 30); + func_8083264C(pthis, impactInfo->unk_01, impactInfo->unk_02, impactInfo->unk_03, 0); + func_8002F7DC(&pthis->actor, NA_SE_PL_BODY_HIT); + func_80832698(pthis, impactInfo->sfxId); + + return impactIndex + 1; + } + + if (sp34 > 200) { + sp34 *= 2; + + if (sp34 > 255) { + sp34 = 255; + } + + func_8083264C(pthis, (u8)sp34, (u8)(sp34 * 0.1f), (u8)sp34, 0); + + if (D_808535E4 == 6) { + func_80832698(pthis, NA_SE_VO_LI_CLIMB_END); + } + } + + func_808328A0(pthis); + + return 0; +} + +void func_8084409C(GlobalContext* globalCtx, Player* pthis, f32 speedXZ, f32 velocityY) { + Actor* heldActor = pthis->heldActor; + + if (!func_80835644(globalCtx, pthis, heldActor)) { + heldActor->world.rot.y = pthis->actor.shape.rot.y; + heldActor->speedXZ = speedXZ; + heldActor->velocity.y = velocityY; + func_80834644(globalCtx, pthis); + func_8002F7DC(&pthis->actor, NA_SE_PL_THROW); + func_80832698(pthis, NA_SE_VO_LI_SWORD_N); + } +} + +void func_8084411C(Player* pthis, GlobalContext* globalCtx) { + f32 sp4C; + s16 sp4A; + + if (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 40) { + pthis->actor.gravity = 0.0f; + } else if (func_8008E9C4(pthis)) { + pthis->actor.gravity = -1.2f; + } + + func_80837268(pthis, &sp4C, &sp4A, 0.0f, globalCtx); + + if (!(pthis->actor.bgCheckFlags & 1)) { + if (pthis->stateFlags1 & 0x800) { + Actor* heldActor = pthis->heldActor; + + if (!func_80835644(globalCtx, pthis, heldActor) && (heldActor->id == ACTOR_EN_NIW) && + CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + func_8084409C(globalCtx, pthis, pthis->linearVelocity + 2.0f, pthis->actor.velocity.y + 2.0f); + } + } + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (!(pthis->stateFlags2 & 0x80000)) { + func_8083DFE0(pthis, &sp4C, &sp4A); + } + + func_80836670(pthis, globalCtx); + + if (((pthis->stateFlags2 & 0x80000) && (pthis->unk_84F == 2)) || !func_8083BBA0(pthis, globalCtx)) { + if (pthis->actor.velocity.y < 0.0f) { + if (pthis->unk_850 >= 0) { + if ((pthis->actor.bgCheckFlags & 8) || (pthis->unk_850 == 0) || (pthis->fallDistance > 0)) { + if ((D_80853600 > 800.0f) || (pthis->stateFlags1 & 4)) { + func_80843E14(pthis, NA_SE_VO_LI_FALL_S); + pthis->stateFlags1 &= ~4; + } + + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_003020, 1.0f, 0.0f, 0.0f, + ANIMMODE_ONCE, 8.0f); + pthis->unk_850 = -1; + } + } else { + if ((pthis->unk_850 == -1) && (pthis->fallDistance > 120.0f) && (D_80853600 > 280.0f)) { + pthis->unk_850 = -2; + func_80843E14(pthis, NA_SE_VO_LI_FALL_L); + } + + if ((pthis->actor.bgCheckFlags & 0x200) && !(pthis->stateFlags2 & 0x80000) && + !(pthis->stateFlags1 & 0x8000800) && (pthis->linearVelocity > 0.0f)) { + if ((pthis->wallHeight >= 150.0f) && (pthis->unk_84B[pthis->unk_846] == 0)) { + func_8083EC18(pthis, globalCtx, D_808535F0); + } else if ((pthis->unk_88C >= 2) && (pthis->wallHeight < 150.0f) && + (((pthis->actor.world.pos.y - pthis->actor.floorHeight) + pthis->wallHeight) > + (70.0f * pthis->ageProperties->unk_08))) { + AnimationContext_DisableQueue(globalCtx); + if (pthis->stateFlags1 & 4) { + func_80832698(pthis, NA_SE_VO_LI_HOOKSHOT_HANG); + } else { + func_80832698(pthis, NA_SE_VO_LI_HANG); + } + pthis->actor.world.pos.y += pthis->wallHeight; + func_8083A5C4(globalCtx, pthis, pthis->actor.wallPoly, pthis->wallDistance, + D_80853CBC[pthis->modelAnimType]); + pthis->actor.shape.rot.y = pthis->currentYaw += 0x8000; + pthis->stateFlags1 |= 0x2000; + } + } + } + } + } + } else { + LinkAnimationHeader* anim = D_80853A64[pthis->modelAnimType]; + s32 sp3C; + + if (pthis->stateFlags2 & 0x80000) { + if (func_8008E9C4(pthis)) { + anim = D_80853D4C[pthis->unk_84F][2]; + } else { + anim = D_80853D4C[pthis->unk_84F][1]; + } + } else if (pthis->skelAnime.animation == &gPlayerAnim_003148) { + anim = &gPlayerAnim_003150; + } else if (func_8008E9C4(pthis)) { + anim = &gPlayerAnim_002538; + func_80833C3C(pthis); + } else if (pthis->fallDistance <= 80) { + anim = D_80853A7C[pthis->modelAnimType]; + } else if ((pthis->fallDistance < 800) && (pthis->unk_84B[pthis->unk_846] == 0) && !(pthis->stateFlags1 & 0x800)) { + func_8083BC04(pthis, globalCtx); + return; + } + + sp3C = func_80843E64(globalCtx, pthis); + + if (sp3C > 0) { + func_8083A098(pthis, D_80853A64[pthis->modelAnimType], globalCtx); + pthis->skelAnime.endFrame = 8.0f; + if (sp3C == 1) { + pthis->unk_850 = 10; + } else { + pthis->unk_850 = 20; + } + } else if (sp3C == 0) { + func_8083A098(pthis, anim, globalCtx); + } + } +} + +static struct_80832924 D_8085460C[] = { + { NA_SE_VO_LI_SWORD_N, 0x2001 }, + { NA_SE_PL_WALK_GROUND, 0x1806 }, + { NA_SE_PL_ROLL, 0x806 }, + { 0, -0x2812 }, +}; + +void func_80844708(Player* pthis, GlobalContext* globalCtx) { + Actor* cylinderOc; + s32 temp; + s32 sp44; + DynaPolyActor* wallPolyActor; + s32 pad; + f32 sp38; + s16 sp36; + + pthis->stateFlags2 |= 0x20; + + cylinderOc = NULL; + sp44 = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 8.0f)) { + func_80837AFC(pthis, -10); + } + + if (func_80842964(pthis, globalCtx) == 0) { + if (pthis->unk_850 != 0) { + Math_StepToF(&pthis->linearVelocity, 0.0f, 2.0f); + + temp = func_808374A0(globalCtx, pthis, &pthis->skelAnime, 5.0f); + if ((temp != 0) && ((temp > 0) || sp44)) { + func_8083A060(pthis, globalCtx); + } + } else { + if (pthis->linearVelocity >= 7.0f) { + if (((pthis->actor.bgCheckFlags & 0x200) && (D_8085360C < 0x2000)) || + ((pthis->cylinder.base.ocFlags1 & OC1_HIT) && + (cylinderOc = pthis->cylinder.base.oc, + ((cylinderOc->id == ACTOR_EN_WOOD02) && + (ABS((s16)(pthis->actor.world.rot.y - cylinderOc->yawTowardsPlayer)) > 0x6000))))) { + + if (cylinderOc != NULL) { + cylinderOc->home.rot.y = 1; + } else if (pthis->actor.wallBgId != BGCHECK_SCENE) { + wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.wallBgId); + if ((wallPolyActor != NULL) && (wallPolyActor->actor.id == ACTOR_OBJ_KIBAKO2)) { + wallPolyActor->actor.home.rot.z = 1; + } + } + + func_80832264(globalCtx, pthis, D_80853AAC[pthis->modelAnimType]); + pthis->linearVelocity = -pthis->linearVelocity; + func_808429B4(globalCtx, 33267, 3, 12); + func_8083264C(pthis, 255, 20, 150, 0); + func_8002F7DC(&pthis->actor, NA_SE_PL_BODY_HIT); + func_80832698(pthis, NA_SE_VO_LI_CLIMB_END); + pthis->unk_850 = 1; + return; + } + } + + if ((pthis->skelAnime.curFrame < 15.0f) || !func_80850224(pthis, globalCtx)) { + if (pthis->skelAnime.curFrame >= 20.0f) { + func_8083A060(pthis, globalCtx); + return; + } + + func_80837268(pthis, &sp38, &sp36, 0.018f, globalCtx); + + sp38 *= 1.5f; + if ((sp38 < 3.0f) || (pthis->unk_84B[pthis->unk_846] != 0)) { + sp38 = 3.0f; + } + + func_8083DF68(pthis, sp38, pthis->actor.shape.rot.y); + + if (func_8084269C(globalCtx, pthis)) { + func_8002F8F0(&pthis->actor, NA_SE_PL_ROLL_DUST - SFX_FLAG); + } + + func_80832924(pthis, D_8085460C); + } + } + } +} + +void func_80844A44(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x20; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, &gPlayerAnim_003160); + } + + Math_StepToF(&pthis->linearVelocity, 0.0f, 0.05f); + + if (pthis->actor.bgCheckFlags & 1) { + pthis->actor.colChkInfo.damage = 0x10; + func_80837C0C(globalCtx, pthis, 1, 4.0f, 5.0f, pthis->actor.shape.rot.y, 20); + } +} + +void func_80844AF4(Player* pthis, GlobalContext* globalCtx) { + f32 sp2C; + s16 sp2A; + + pthis->stateFlags2 |= 0x20; + + pthis->actor.gravity = -1.2f; + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (!func_80842DF4(globalCtx, pthis)) { + func_8084285C(pthis, 6.0f, 7.0f, 99.0f); + + if (!(pthis->actor.bgCheckFlags & 1)) { + func_80837268(pthis, &sp2C, &sp2A, 0.0f, globalCtx); + func_8083DFE0(pthis, &sp2C, &pthis->currentYaw); + return; + } + + if (func_80843E64(globalCtx, pthis) >= 0) { + pthis->swordAnimation += 2; + func_80837948(globalCtx, pthis, pthis->swordAnimation); + pthis->unk_845 = 3; + func_808328A0(pthis); + } + } +} + +s32 func_80844BE4(Player* pthis, GlobalContext* globalCtx) { + s32 temp; + + if (func_8083ADD4(globalCtx, pthis)) { + pthis->stateFlags2 |= 0x20000; + } else { + if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { + if ((pthis->unk_858 >= 0.85f) || func_808375D8(pthis)) { + temp = D_80854384[Player_HoldsTwoHandedWeapon(pthis)]; + } else { + temp = D_80854380[Player_HoldsTwoHandedWeapon(pthis)]; + } + + func_80837948(globalCtx, pthis, temp); + func_80837AFC(pthis, -8); + + pthis->stateFlags2 |= 0x20000; + if (pthis->unk_84B[pthis->unk_846] == 0) { + pthis->stateFlags2 |= 0x40000000; + } + } else { + return 0; + } + } + + return 1; +} + +void func_80844CF8(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80845000, 1); +} + +void func_80844D30(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80845308, 1); +} + +void func_80844D68(Player* pthis, GlobalContext* globalCtx) { + func_80839FFC(pthis, globalCtx); + func_80832318(pthis); + func_80832B0C(globalCtx, pthis, D_80854368[Player_HoldsTwoHandedWeapon(pthis)]); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +void func_80844DC8(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80844E68, 1); + pthis->unk_868 = 0.0f; + func_80832284(globalCtx, pthis, D_80854360[Player_HoldsTwoHandedWeapon(pthis)]); + pthis->unk_850 = 1; +} + +void func_80844E3C(Player* pthis) { + Math_StepToF(&pthis->unk_858, 1.0f, 0.02f); +} + +void func_80844E68(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + s32 temp; + + pthis->stateFlags1 |= 0x1000; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832DBC(pthis); + func_808355DC(pthis); + pthis->stateFlags1 &= ~0x20000; + func_80832284(globalCtx, pthis, D_80854360[Player_HoldsTwoHandedWeapon(pthis)]); + pthis->unk_850 = -1; + } + + func_8083721C(pthis); + + if (!func_80842964(pthis, globalCtx) && (pthis->unk_850 != 0)) { + func_80844E3C(pthis); + + if (pthis->unk_850 < 0) { + if (pthis->unk_858 >= 0.1f) { + pthis->unk_845 = 0; + pthis->unk_850 = 1; + } else if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { + func_80844D68(pthis, globalCtx); + } + } else if (!func_80844BE4(pthis, globalCtx)) { + func_80837268(pthis, &sp34, &sp32, 0.0f, globalCtx); + + temp = func_80840058(pthis, &sp34, &sp32, globalCtx); + if (temp > 0) { + func_80844CF8(pthis, globalCtx); + } else if (temp < 0) { + func_80844D30(pthis, globalCtx); + } + } + } +} + +void func_80845000(Player* pthis, GlobalContext* globalCtx) { + s16 temp1; + s32 temp2; + f32 sp5C; + f32 sp58; + f32 sp54; + s16 sp52; + s32 temp4; + s16 temp5; + s32 sp44; + + temp1 = pthis->currentYaw - pthis->actor.shape.rot.y; + temp2 = ABS(temp1); + + sp5C = fabsf(pthis->linearVelocity); + sp58 = sp5C * 1.5f; + + pthis->stateFlags1 |= 0x1000; + + if (sp58 < 1.5f) { + sp58 = 1.5f; + } + + sp58 = ((temp2 < 0x4000) ? -1.0f : 1.0f) * sp58; + + func_8084029C(pthis, sp58); + + sp58 = CLAMP(sp5C * 0.5f, 0.5f, 1.0f); + + LinkAnimation_BlendToJoint(globalCtx, &pthis->skelAnime, D_80854360[Player_HoldsTwoHandedWeapon(pthis)], 0.0f, + D_80854370[Player_HoldsTwoHandedWeapon(pthis)], pthis->unk_868 * (21.0f / 29.0f), sp58, + pthis->blendTable); + + if (!func_80842964(pthis, globalCtx) && !func_80844BE4(pthis, globalCtx)) { + func_80844E3C(pthis); + func_80837268(pthis, &sp54, &sp52, 0.0f, globalCtx); + + temp4 = func_80840058(pthis, &sp54, &sp52, globalCtx); + + if (temp4 < 0) { + func_80844D30(pthis, globalCtx); + return; + } + + if (temp4 == 0) { + sp54 = 0.0f; + sp52 = pthis->currentYaw; + } + + temp5 = sp52 - pthis->currentYaw; + sp44 = ABS(temp5); + + if (sp44 > 0x4000) { + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 1.0f)) { + pthis->currentYaw = sp52; + } + return; + } + + Math_AsymStepToF(&pthis->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); + Math_ScaledStepToS(&pthis->currentYaw, sp52, sp44 * 0.1f); + + if ((sp54 == 0.0f) && (pthis->linearVelocity == 0.0f)) { + func_80844DC8(pthis, globalCtx); + } + } +} + +void func_80845308(Player* pthis, GlobalContext* globalCtx) { + f32 sp5C; + f32 sp58; + f32 sp54; + s16 sp52; + s32 temp4; + s16 temp5; + s32 sp44; + + sp5C = fabsf(pthis->linearVelocity); + + pthis->stateFlags1 |= 0x1000; + + if (sp5C == 0.0f) { + sp5C = ABS(pthis->unk_87C) * 0.0015f; + if (sp5C < 400.0f) { + sp5C = 0.0f; + } + func_8084029C(pthis, ((pthis->unk_87C >= 0) ? 1 : -1) * sp5C); + } else { + sp58 = sp5C * 1.5f; + if (sp58 < 1.5f) { + sp58 = 1.5f; + } + func_8084029C(pthis, sp58); + } + + sp58 = CLAMP(sp5C * 0.5f, 0.5f, 1.0f); + + LinkAnimation_BlendToJoint(globalCtx, &pthis->skelAnime, D_80854360[Player_HoldsTwoHandedWeapon(pthis)], 0.0f, + D_80854378[Player_HoldsTwoHandedWeapon(pthis)], pthis->unk_868 * (21.0f / 29.0f), sp58, + pthis->blendTable); + + if (!func_80842964(pthis, globalCtx) && !func_80844BE4(pthis, globalCtx)) { + func_80844E3C(pthis); + func_80837268(pthis, &sp54, &sp52, 0.0f, globalCtx); + + temp4 = func_80840058(pthis, &sp54, &sp52, globalCtx); + + if (temp4 > 0) { + func_80844CF8(pthis, globalCtx); + return; + } + + if (temp4 == 0) { + sp54 = 0.0f; + sp52 = pthis->currentYaw; + } + + temp5 = sp52 - pthis->currentYaw; + sp44 = ABS(temp5); + + if (sp44 > 0x4000) { + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 1.0f)) { + pthis->currentYaw = sp52; + } + return; + } + + Math_AsymStepToF(&pthis->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); + Math_ScaledStepToS(&pthis->currentYaw, sp52, sp44 * 0.1f); + + if ((sp54 == 0.0f) && (pthis->linearVelocity == 0.0f) && (sp5C == 0.0f)) { + func_80844DC8(pthis, globalCtx); + } + } +} + +void func_80845668(Player* pthis, GlobalContext* globalCtx) { + s32 sp3C; + f32 temp1; + s32 temp2; + f32 temp3; + + pthis->stateFlags2 |= 0x20; + sp3C = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (pthis->skelAnime.animation == &gPlayerAnim_002D48) { + pthis->linearVelocity = 1.0f; + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 8.0f)) { + temp1 = pthis->wallHeight; + + if (temp1 > pthis->ageProperties->unk_0C) { + temp1 = pthis->ageProperties->unk_0C; + } + + if (pthis->stateFlags1 & 0x8000000) { + temp1 *= 0.085f; + } else { + temp1 *= 0.072f; + } + + if (!LINK_IS_ADULT) { + temp1 += 1.0f; + } + + func_80838940(pthis, NULL, temp1, globalCtx, NA_SE_VO_LI_AUTO_JUMP); + pthis->unk_850 = -1; + return; + } + } else { + temp2 = func_808374A0(globalCtx, pthis, &pthis->skelAnime, 4.0f); + + if (temp2 == 0) { + pthis->stateFlags1 &= ~0x44000; + return; + } + + if ((sp3C != 0) || (temp2 > 0)) { + func_8083C0E8(pthis, globalCtx); + pthis->stateFlags1 &= ~0x44000; + return; + } + + temp3 = 0.0f; + + if (pthis->skelAnime.animation == &gPlayerAnim_0032E8) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 30.0f)) { + func_8083D0A8(globalCtx, pthis, 10.0f); + } + temp3 = 50.0f; + } else if (pthis->skelAnime.animation == &gPlayerAnim_002D40) { + temp3 = 30.0f; + } else if (pthis->skelAnime.animation == &gPlayerAnim_002D38) { + temp3 = 16.0f; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, temp3)) { + func_808328A0(pthis); + func_80832698(pthis, NA_SE_VO_LI_CLIMB_END); + } + + if ((pthis->skelAnime.animation == &gPlayerAnim_002D38) || (pthis->skelAnime.curFrame > 5.0f)) { + if (pthis->unk_850 == 0) { + func_80832854(pthis); + pthis->unk_850 = 1; + } + Math_StepToF(&pthis->actor.shape.yOffset, 0.0f, 150.0f); + } + } +} + +void func_808458D0(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x60; + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (((pthis->stateFlags1 & 0x800) && (pthis->heldActor != NULL) && (pthis->getItemId == GI_NONE)) || + !func_80836670(pthis, globalCtx)) { + pthis->func_A74(globalCtx, pthis); + } +} + +s32 func_80845964(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2, f32 arg3, s16 arg4, s32 arg5) { + if ((arg5 != 0) && (pthis->linearVelocity == 0.0f)) { + return LinkAnimation_Update(globalCtx, &pthis->skelAnime); + } + + if (arg5 != 2) { + f32 sp34 = R_UPDATE_RATE * 0.5f; + f32 selfDistX = arg2->endPos.x - pthis->actor.world.pos.x; + f32 selfDistZ = arg2->endPos.z - pthis->actor.world.pos.z; + f32 sp28 = sqrtf(SQ(selfDistX) + SQ(selfDistZ)) / sp34; + s32 sp24 = (arg2->endFrame - globalCtx->csCtx.frames) + 1; + + arg4 = Math_Atan2S(selfDistZ, selfDistX); + + if (arg5 == 1) { + f32 distX = arg2->endPos.x - arg2->startPos.x; + f32 distZ = arg2->endPos.z - arg2->startPos.z; + s32 temp = (((sqrtf(SQ(distX) + SQ(distZ)) / sp34) / (arg2->endFrame - arg2->startFrame)) / 1.5f) * 4.0f; + + if (temp >= sp24) { + arg4 = pthis->actor.shape.rot.y; + arg3 = 0.0f; + } else { + arg3 = sp28 / ((sp24 - temp) + 1); + } + } else { + arg3 = sp28 / sp24; + } + } + + pthis->stateFlags2 |= 0x20; + func_80841EE4(pthis, globalCtx); + func_8083DF68(pthis, arg3, arg4); + + if ((arg3 == 0.0f) && (pthis->linearVelocity == 0.0f)) { + func_8083BF50(pthis, globalCtx); + } + + return 0; +} + +s32 func_80845BA0(GlobalContext* arg0, Player* arg1, f32* arg2, s32 arg3) { + f32 dx = arg1->unk_450.x - arg1->actor.world.pos.x; + f32 dz = arg1->unk_450.z - arg1->actor.world.pos.z; + s32 sp2C = sqrtf(SQ(dx) + SQ(dz)); + s16 yaw = Math_Vec3f_Yaw(&arg1->actor.world.pos, &arg1->unk_450); + + if (sp2C < arg3) { + *arg2 = 0.0f; + yaw = arg1->actor.shape.rot.y; + } + + if (func_80845964(arg0, arg1, NULL, *arg2, yaw, 2)) { + return 0; + } + + return sp2C; +} + +s32 func_80845C68(GlobalContext* globalCtx, s32 arg1) { + if (arg1 == 0) { + Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_DOWN, 0xDFF); + } + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 0; + return arg1; +} + +void func_80845CA4(Player* pthis, GlobalContext* globalCtx) { + f32 sp3C; + s32 temp; + f32 sp34; + s32 sp30; + s32 pad; + + if (!func_8083B040(pthis, globalCtx)) { + if (pthis->unk_850 == 0) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (DECR(pthis->doorTimer) == 0) { + pthis->linearVelocity = 0.1f; + pthis->unk_850 = 1; + } + } else if (pthis->unk_84F == 0) { + sp3C = 5.0f * D_808535E8; + + if (func_80845BA0(globalCtx, pthis, &sp3C, -1) < 30) { + pthis->unk_84F = 1; + pthis->stateFlags1 |= 0x20000000; + + pthis->unk_450.x = pthis->unk_45C.x; + pthis->unk_450.z = pthis->unk_45C.z; + } + } else { + sp34 = 5.0f; + sp30 = 20; + + if (pthis->stateFlags1 & 1) { + sp34 = gSaveContext.entranceSpeed; + + if (D_808535F4 != 0) { + pthis->unk_450.x = (Math_SinS(D_808535FC) * 400.0f) + pthis->actor.world.pos.x; + pthis->unk_450.z = (Math_CosS(D_808535FC) * 400.0f) + pthis->actor.world.pos.z; + } + } else if (pthis->unk_850 < 0) { + pthis->unk_850++; + + sp34 = gSaveContext.entranceSpeed; + sp30 = -1; + } + + temp = func_80845BA0(globalCtx, pthis, &sp34, sp30); + + if ((pthis->unk_850 == 0) || + ((temp == 0) && (pthis->linearVelocity == 0.0f) && (Gameplay_GetCamera(globalCtx, 0)->unk_14C & 0x10))) { + + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + func_80845C68(globalCtx, gSaveContext.respawn[RESPAWN_MODE_DOWN].data); + + if (!func_8083B644(pthis, globalCtx)) { + func_8083CF5C(pthis, globalCtx); + } + } + } + } + + if (pthis->stateFlags1 & 0x800) { + func_80836670(pthis, globalCtx); + } +} + +void func_80845EF8(Player* pthis, GlobalContext* globalCtx) { + s32 sp2C; + + pthis->stateFlags2 |= 0x20; + sp2C = LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + func_80836670(pthis, globalCtx); + + if (sp2C) { + if (pthis->unk_850 == 0) { + if (DECR(pthis->doorTimer) == 0) { + pthis->unk_850 = 1; + pthis->skelAnime.endFrame = pthis->skelAnime.animLength - 1.0f; + } + } else { + func_8083C0E8(pthis, globalCtx); + if (globalCtx->roomCtx.prevRoom.num >= 0) { + func_80097534(globalCtx, &globalCtx->roomCtx); + } + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + Gameplay_SetupRespawnPoint(globalCtx, 0, 0xDFF); + } + return; + } + + if (!(pthis->stateFlags1 & 0x20000000) && LinkAnimation_OnFrame(&pthis->skelAnime, 15.0f)) { + globalCtx->func_11D54(pthis, globalCtx); + } +} + +void func_80846050(Player* pthis, GlobalContext* globalCtx) { + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80839F90(pthis, globalCtx); + func_80835688(pthis, globalCtx); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 4.0f)) { + Actor* interactRangeActor = pthis->interactRangeActor; + + if (!func_80835644(globalCtx, pthis, interactRangeActor)) { + pthis->heldActor = interactRangeActor; + pthis->actor.child = interactRangeActor; + interactRangeActor->parent = &pthis->actor; + interactRangeActor->bgCheckFlags &= 0xFF00; + pthis->unk_3BC.y = interactRangeActor->shape.rot.y - pthis->actor.shape.rot.y; + } + return; + } + + Math_ScaledStepToS(&pthis->unk_3BC.y, 0, 4000); +} + +static struct_80832924 D_8085461C[] = { + { NA_SE_VO_LI_SWORD_L, 0x2031 }, + { NA_SE_VO_LI_SWORD_N, -0x20E6 }, +}; + +void func_80846120(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) && (pthis->unk_850++ > 20)) { + if (!func_8083B040(pthis, globalCtx)) { + func_8083A098(pthis, &gPlayerAnim_002FA0, globalCtx); + } + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 41.0f)) { + BgHeavyBlock* heavyBlock = (BgHeavyBlock*)pthis->interactRangeActor; + + pthis->heldActor = &heavyBlock->dyna.actor; + pthis->actor.child = &heavyBlock->dyna.actor; + heavyBlock->dyna.actor.parent = &pthis->actor; + func_8002DBD0(&heavyBlock->dyna.actor, &heavyBlock->unk_164, &pthis->leftHandPos); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 229.0f)) { + Actor* heldActor = pthis->heldActor; + + heldActor->speedXZ = Math_SinS(heldActor->shape.rot.x) * 40.0f; + heldActor->velocity.y = Math_CosS(heldActor->shape.rot.x) * 40.0f; + heldActor->gravity = -2.0f; + heldActor->minVelocityY = -30.0f; + func_808323B4(globalCtx, pthis); + return; + } + + func_80832924(pthis, D_8085461C); +} + +void func_80846260(Player* pthis, GlobalContext* globalCtx) { + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, &gPlayerAnim_0032C0); + pthis->unk_850 = 1; + return; + } + + if (pthis->unk_850 == 0) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 27.0f)) { + Actor* interactRangeActor = pthis->interactRangeActor; + + pthis->heldActor = interactRangeActor; + pthis->actor.child = interactRangeActor; + interactRangeActor->parent = &pthis->actor; + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 25.0f)) { + func_80832698(pthis, NA_SE_VO_LI_SWORD_L); + return; + } + + } else if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + func_80835C58(globalCtx, pthis, func_80846358, 1); + func_80832264(globalCtx, pthis, &gPlayerAnim_0032B8); + } +} + +void func_80846358(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80839F90(pthis, globalCtx); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 6.0f)) { + Actor* heldActor = pthis->heldActor; + + heldActor->world.rot.y = pthis->actor.shape.rot.y; + heldActor->speedXZ = 10.0f; + heldActor->velocity.y = 20.0f; + func_80834644(globalCtx, pthis); + func_8002F7DC(&pthis->actor, NA_SE_PL_THROW); + func_80832698(pthis, NA_SE_VO_LI_SWORD_N); + } +} + +void func_80846408(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, &gPlayerAnim_003070); + pthis->unk_850 = 15; + return; + } + + if (pthis->unk_850 != 0) { + pthis->unk_850--; + if (pthis->unk_850 == 0) { + func_8083A098(pthis, &gPlayerAnim_003068, globalCtx); + pthis->stateFlags1 &= ~0x800; + func_80832698(pthis, NA_SE_VO_LI_DAMAGE_S); + } + } +} + +void func_808464B0(Player* pthis, GlobalContext* globalCtx) { + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80839F90(pthis, globalCtx); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 4.0f)) { + Actor* heldActor = pthis->heldActor; + + if (!func_80835644(globalCtx, pthis, heldActor)) { + heldActor->velocity.y = 0.0f; + heldActor->speedXZ = 0.0f; + func_80834644(globalCtx, pthis); + if (heldActor->id == ACTOR_EN_BOM_CHU) { + func_8083B8F4(pthis, globalCtx); + } + } + } +} + +void func_80846578(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) || + ((pthis->skelAnime.curFrame >= 8.0f) && func_80837268(pthis, &sp34, &sp32, 0.018f, globalCtx))) { + func_80839F90(pthis, globalCtx); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 3.0f)) { + func_8084409C(globalCtx, pthis, pthis->linearVelocity + 8.0f, 12.0f); + } +} + +static ColliderCylinderInit D_80854624 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 12, 60, 0, { 0, 0, 0 } }, +}; + +static ColliderQuadInit D_80854650 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000100, 0x00, 0x01 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +static ColliderQuadInit D_808546A0 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_ENEMY, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x00 }, + { 0xDFCFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +void func_8084663C(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80846648(GlobalContext* globalCtx, Player* pthis) { + pthis->actor.update = func_8084663C; + pthis->actor.draw = NULL; +} + +void func_80846660(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084F710, 0); + if ((globalCtx->sceneNum == SCENE_SPOT06) && (gSaveContext.sceneSetupIndex >= 4)) { + pthis->unk_84F = 1; + } + pthis->stateFlags1 |= 0x20000000; + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_003298, 2.0f / 3.0f, 0.0f, 24.0f, ANIMMODE_ONCE, + 0.0f); + pthis->actor.world.pos.y += 800.0f; +} + +static u8 D_808546F0[] = { ITEM_SWORD_MASTER, ITEM_SWORD_KOKIRI }; + +void func_80846720(GlobalContext* globalCtx, Player* pthis, s32 arg2) { + s32 item = D_808546F0[(void)0, gSaveContext.linkAge]; + s32 actionParam = sItemActionParams[item]; + + func_80835EFC(pthis); + func_808323B4(globalCtx, pthis); + + pthis->heldItemId = item; + pthis->nextModelGroup = Player_ActionToModelGroup(pthis, actionParam); + + func_8083399C(globalCtx, pthis, actionParam); + func_80834644(globalCtx, pthis); + + if (arg2 != 0) { + func_8002F7DC(&pthis->actor, NA_SE_IT_SWORD_PICKOUT); + } +} + +static Vec3f D_808546F4 = { -1.0f, 69.0f, 20.0f }; + +void func_808467D4(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084E9AC, 0); + pthis->stateFlags1 |= 0x20000000; + Math_Vec3f_Copy(&pthis->actor.world.pos, &D_808546F4); + pthis->currentYaw = pthis->actor.shape.rot.y = -0x8000; + LinkAnimation_Change(globalCtx, &pthis->skelAnime, pthis->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, + ANIMMODE_ONCE, 0.0f); + func_80832F54(globalCtx, pthis, 0x28F); + if (LINK_IS_ADULT) { + func_80846720(globalCtx, pthis, 0); + } + pthis->unk_850 = 20; +} + +void func_808468A8(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084F9A0, 0); + func_80832F54(globalCtx, pthis, 0x9B); +} + +void func_808468E8(GlobalContext* globalCtx, Player* pthis) { + func_808389E8(pthis, &gPlayerAnim_002FE0, 12.0f, globalCtx); + func_80835C58(globalCtx, pthis, func_8084F9C0, 0); + pthis->stateFlags1 |= 0x20000000; + pthis->fallStartHeight = pthis->actor.world.pos.y; + OnePointCutscene_Init(globalCtx, 5110, 40, &pthis->actor, MAIN_CAM); +} + +void func_80846978(GlobalContext* globalCtx, Player* pthis) { + func_80837C0C(globalCtx, pthis, 1, 2.0f, 2.0f, pthis->actor.shape.rot.y + 0x8000, 0); +} + +void func_808469BC(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084F698, 0); + pthis->actor.draw = NULL; + pthis->stateFlags1 |= 0x20000000; +} + +static s16 D_80854700[] = { ACTOR_MAGIC_WIND, ACTOR_MAGIC_DARK, ACTOR_MAGIC_FIRE }; + +Actor* func_80846A00(GlobalContext* globalCtx, Player* pthis, s32 arg2) { + return Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_80854700[arg2], pthis->actor.world.pos.x, + pthis->actor.world.pos.y, pthis->actor.world.pos.z, 0, 0, 0, 0); +} + +void func_80846A68(GlobalContext* globalCtx, Player* pthis) { + pthis->actor.draw = NULL; + func_80835C58(globalCtx, pthis, func_8085076C, 0); + pthis->stateFlags1 |= 0x20000000; +} + +static InitChainEntry D_80854708[] = { + ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), +}; + +static EffectBlureInit2 D_8085470C = { + 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 4, + 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; + +static Vec3s D_80854730 = { -57, 3377, 0 }; + +void Player_InitCommon(Player* pthis, GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader) { + pthis->ageProperties = &sAgeProperties[gSaveContext.linkAge]; + Actor_ProcessInitChain(&pthis->actor, D_80854708); + pthis->swordEffectIndex = TOTAL_EFFECT_COUNT; + pthis->currentYaw = pthis->actor.world.rot.y; + func_80834644(globalCtx, pthis); + + SkelAnime_InitLink(globalCtx, &pthis->skelAnime, skelHeader, D_80853914[pthis->modelAnimType], 9, pthis->jointTable, + pthis->morphTable, PLAYER_LIMB_MAX); + pthis->skelAnime.baseTransl = D_80854730; + SkelAnime_InitLink(globalCtx, &pthis->skelAnime2, skelHeader, func_80833338(pthis), 9, pthis->jointTable2, + pthis->morphTable2, PLAYER_LIMB_MAX); + pthis->skelAnime2.baseTransl = D_80854730; + + Effect_Add(globalCtx, &pthis->swordEffectIndex, EFFECT_BLURE2, 0, 0, &D_8085470C); + ActorShape_Init(&pthis->actor.shape, 0.0f, ActorShadow_DrawFeet, pthis->ageProperties->unk_04); + pthis->unk_46C = SUBCAM_NONE; + Collider_InitCylinder(globalCtx, &pthis->cylinder); + Collider_SetCylinder(globalCtx, &pthis->cylinder, &pthis->actor, &D_80854624); + Collider_InitQuad(globalCtx, &pthis->swordQuads[0]); + Collider_SetQuad(globalCtx, &pthis->swordQuads[0], &pthis->actor, &D_80854650); + Collider_InitQuad(globalCtx, &pthis->swordQuads[1]); + Collider_SetQuad(globalCtx, &pthis->swordQuads[1], &pthis->actor, &D_80854650); + Collider_InitQuad(globalCtx, &pthis->shieldQuad); + Collider_SetQuad(globalCtx, &pthis->shieldQuad, &pthis->actor, &D_808546A0); +} + +static void (*D_80854738[])(GlobalContext* globalCtx, Player* pthis) = { + func_80846648, func_808467D4, func_80846660, func_808468A8, func_808468E8, func_808469BC, + func_80846A68, func_80846978, func_8083CA54, func_8083CA54, func_8083CA54, func_8083CA54, + func_8083CA54, func_8083CA20, func_8083CA54, func_8083CA9C, +}; + +static Vec3f D_80854778 = { 0.0f, 50.0f, 0.0f }; + +void Player_Init(Actor* thisx, GlobalContext* globalCtx2) { + Player* pthis = (Player*)thisx; + GlobalContext* globalCtx = globalCtx2; + SceneTableEntry* scene = globalCtx->loadedScene; + u32 titleFileSize; + s32 initMode; + s32 sp50; + s32 sp4C; + + globalCtx->shootingGalleryStatus = globalCtx->bombchuBowlingStatus = 0; + + globalCtx->playerInit = Player_InitCommon; + globalCtx->playerUpdate = Player_UpdateCommon; + globalCtx->isPlayerDroppingFish = Player_IsDroppingFish; + globalCtx->startPlayerFishing = Player_StartFishing; + globalCtx->grabPlayer = func_80852F38; + globalCtx->startPlayerCutscene = func_80852FFC; + globalCtx->func_11D54 = func_80853080; + globalCtx->damagePlayer = Player_InflictDamage; + globalCtx->talkWithPlayer = func_80853148; + + thisx->room = -1; + pthis->ageProperties = &sAgeProperties[gSaveContext.linkAge]; + pthis->itemActionParam = pthis->heldItemActionParam = -1; + pthis->heldItemId = ITEM_NONE; + + func_80835F44(globalCtx, pthis, ITEM_NONE); + Player_SetEquipmentData(globalCtx, pthis); + pthis->prevBoots = pthis->currentBoots; + Player_InitCommon(pthis, globalCtx, gPlayerSkelHeaders[((void)0, gSaveContext.linkAge)]); + pthis->giObjectSegment = (void*)(((uintptr_t)ZeldaArena_MallocDebug(0x3008, "../z_player.c", 17175) + 8) & ~0xF); + + sp50 = gSaveContext.respawnFlag; + + if (sp50 != 0) { + if (sp50 == -3) { + thisx->params = gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams; + } else { + if ((sp50 == 1) || (sp50 == -1)) { + pthis->unk_A86 = -2; + } + + if (sp50 < 0) { + sp4C = 0; + } else { + sp4C = sp50 - 1; + Math_Vec3f_Copy(&thisx->world.pos, &gSaveContext.respawn[sp50 - 1].pos); + Math_Vec3f_Copy(&thisx->home.pos, &thisx->world.pos); + Math_Vec3f_Copy(&thisx->prevPos, &thisx->world.pos); + pthis->fallStartHeight = thisx->world.pos.y; + pthis->currentYaw = thisx->shape.rot.y = gSaveContext.respawn[sp4C].yaw; + thisx->params = gSaveContext.respawn[sp4C].playerParams; + } + + globalCtx->actorCtx.flags.tempSwch = gSaveContext.respawn[sp4C].tempSwchFlags & 0xFFFFFF; + globalCtx->actorCtx.flags.tempCollect = gSaveContext.respawn[sp4C].tempCollectFlags; + } + } + + if ((sp50 == 0) || (sp50 < -1)) { + titleFileSize = POINTER_SUB2(scene->titleFile.vromEnd, scene->titleFile.vromStart); + if ((titleFileSize != 0) && gSaveContext.showTitleCard) { + if ((gSaveContext.sceneSetupIndex < 4) && + (gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].field & + 0x4000) && + ((globalCtx->sceneNum != SCENE_DDAN) || (gSaveContext.eventChkInf[11] & 1)) && + ((globalCtx->sceneNum != SCENE_NIGHT_SHOP) || (gSaveContext.eventChkInf[2] & 0x20))) { + TitleCard_InitPlaceName(globalCtx, &globalCtx->actorCtx.titleCtx, pthis->giObjectSegment, 160, 120, 144, + 24, 20); + } + } + gSaveContext.showTitleCard = true; + } + + if (func_80845C68(globalCtx, (sp50 == 2) ? 1 : 0) == 0) { + gSaveContext.respawn[RESPAWN_MODE_DOWN].playerParams = (thisx->params & 0xFF) | 0xD00; + } + + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 1; + + if (globalCtx->sceneNum <= SCENE_GANONTIKA_SONOGO) { + gSaveContext.infTable[26] |= gBitFlags[globalCtx->sceneNum]; + } + + initMode = (thisx->params & 0xF00) >> 8; + if ((initMode == 5) || (initMode == 6)) { + if (gSaveContext.cutsceneIndex >= 0xFFF0) { + initMode = 13; + } + } + + D_80854738[initMode](globalCtx, pthis); + + if (initMode != 0) { + if ((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 3)) { + pthis->naviActor = Player_SpawnFairy(globalCtx, pthis, &thisx->world.pos, &D_80854778, FAIRY_NAVI); + if (gSaveContext.dogParams != 0) { + gSaveContext.dogParams |= 0x8000; + } + } + } + + if (gSaveContext.nayrusLoveTimer != 0) { + gSaveContext.unk_13F0 = 3; + func_80846A00(globalCtx, pthis, 1); + pthis->stateFlags3 &= ~0x40; + } + + if (gSaveContext.entranceSound != 0) { + Audio_PlayActorSound2(&pthis->actor, ((void)0, gSaveContext.entranceSound)); + gSaveContext.entranceSound = 0; + } + + Map_SavePlayerInitialInfo(globalCtx); + MREG(64) = 0; +} + +void func_808471F4(s16* pValue) { + s16 step; + + step = (ABS(*pValue) * 100.0f) / 1000.0f; + step = CLAMP(step, 400, 4000); + + Math_ScaledStepToS(pValue, 0, step); +} + +void func_80847298(Player* pthis) { + s16 sp26; + + if (!(pthis->unk_6AE & 2)) { + sp26 = pthis->actor.focus.rot.y - pthis->actor.shape.rot.y; + func_808471F4(&sp26); + pthis->actor.focus.rot.y = pthis->actor.shape.rot.y + sp26; + } + + if (!(pthis->unk_6AE & 1)) { + func_808471F4(&pthis->actor.focus.rot.x); + } + + if (!(pthis->unk_6AE & 8)) { + func_808471F4(&pthis->unk_6B6); + } + + if (!(pthis->unk_6AE & 0x40)) { + func_808471F4(&pthis->unk_6BC); + } + + if (!(pthis->unk_6AE & 4)) { + func_808471F4(&pthis->actor.focus.rot.z); + } + + if (!(pthis->unk_6AE & 0x10)) { + func_808471F4(&pthis->unk_6B8); + } + + if (!(pthis->unk_6AE & 0x20)) { + func_808471F4(&pthis->unk_6BA); + } + + if (!(pthis->unk_6AE & 0x80)) { + if (pthis->unk_6B0 != 0) { + func_808471F4(&pthis->unk_6B0); + } else { + func_808471F4(&pthis->unk_6BE); + } + } + + if (!(pthis->unk_6AE & 0x100)) { + func_808471F4(&pthis->unk_6C0); + } + + pthis->unk_6AE = 0; +} + +static f32 D_80854784[] = { 120.0f, 240.0f, 360.0f }; + +static u8 sDiveDoActions[] = { DO_ACTION_1, DO_ACTION_2, DO_ACTION_3, DO_ACTION_4, + DO_ACTION_5, DO_ACTION_6, DO_ACTION_7, DO_ACTION_8 }; + +void func_808473D4(GlobalContext* globalCtx, Player* pthis) { + if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) && (pthis->actor.category == ACTORCAT_PLAYER)) { + Actor* heldActor = pthis->heldActor; + Actor* interactRangeActor = pthis->interactRangeActor; + s32 sp24; + s32 sp20 = pthis->unk_84B[pthis->unk_846]; + s32 sp1C = func_808332B8(pthis); + s32 doAction = DO_ACTION_NONE; + + if (!Player_InBlockingCsMode(globalCtx, pthis)) { + if (pthis->stateFlags1 & 0x100000) { + doAction = DO_ACTION_RETURN; + } else if ((pthis->heldItemActionParam == PLAYER_AP_FISHING_POLE) && (pthis->unk_860 != 0)) { + if (pthis->unk_860 == 2) { + doAction = DO_ACTION_REEL; + } + } else if ((func_8084E3C4 != pthis->func_674) && !(pthis->stateFlags2 & 0x40000)) { + if ((pthis->doorType != PLAYER_DOORTYPE_NONE) && + (!(pthis->stateFlags1 & 0x800) || ((heldActor != NULL) && (heldActor->id == ACTOR_EN_RU1)))) { + doAction = DO_ACTION_OPEN; + } else if ((!(pthis->stateFlags1 & 0x800) || (heldActor == NULL)) && (interactRangeActor != NULL) && + ((!sp1C && (pthis->getItemId == GI_NONE)) || + ((pthis->getItemId < 0) && !(pthis->stateFlags1 & 0x8000000)))) { + if (pthis->getItemId < 0) { + doAction = DO_ACTION_OPEN; + } else if ((interactRangeActor->id == ACTOR_BG_TOKI_SWD) && LINK_IS_ADULT) { + doAction = DO_ACTION_DROP; + } else { + doAction = DO_ACTION_GRAB; + } + } else if (!sp1C && (pthis->stateFlags2 & 1)) { + doAction = DO_ACTION_GRAB; + } else if ((pthis->stateFlags2 & 4) || (!(pthis->stateFlags1 & 0x800000) && (pthis->rideActor != NULL))) { + doAction = DO_ACTION_CLIMB; + } else if ((pthis->stateFlags1 & 0x800000) && !EN_HORSE_CHECK_4((EnHorse*)pthis->rideActor) && + (func_8084D3E4 != pthis->func_674)) { + if ((pthis->stateFlags2 & 2) && (pthis->targetActor != NULL)) { + if (pthis->targetActor->category == ACTORCAT_NPC) { + doAction = DO_ACTION_SPEAK; + } else { + doAction = DO_ACTION_CHECK; + } + } else if (!func_8002DD78(pthis) && !(pthis->stateFlags1 & 0x100000)) { + doAction = DO_ACTION_FASTER; + } + } else if ((pthis->stateFlags2 & 2) && (pthis->targetActor != NULL)) { + if (pthis->targetActor->category == ACTORCAT_NPC) { + doAction = DO_ACTION_SPEAK; + } else { + doAction = DO_ACTION_CHECK; + } + } else if ((pthis->stateFlags1 & 0x202000) || + ((pthis->stateFlags1 & 0x800000) && (pthis->stateFlags2 & 0x400000))) { + doAction = DO_ACTION_DOWN; + } else if (pthis->stateFlags2 & 0x10000) { + doAction = DO_ACTION_ENTER; + } else if ((pthis->stateFlags1 & 0x800) && (pthis->getItemId == GI_NONE) && (heldActor != NULL)) { + if ((pthis->actor.bgCheckFlags & 1) || (heldActor->id == ACTOR_EN_NIW)) { + if (func_8083EAF0(pthis, heldActor) == 0) { + doAction = DO_ACTION_DROP; + } else { + doAction = DO_ACTION_THROW; + } + } + } else if (!(pthis->stateFlags1 & 0x8000000) && func_8083A0D4(pthis) && (pthis->getItemId < GI_MAX)) { + doAction = DO_ACTION_GRAB; + } else if (pthis->stateFlags2 & 0x800) { + sp24 = (D_80854784[CUR_UPG_VALUE(UPG_SCALE)] - pthis->actor.yDistToWater) / 40.0f; + sp24 = CLAMP(sp24, 0, 7); + doAction = sDiveDoActions[sp24]; + } else if (sp1C && !(pthis->stateFlags2 & 0x400)) { + doAction = DO_ACTION_DIVE; + } else if (!sp1C && (!(pthis->stateFlags1 & 0x400000) || func_80833BCC(pthis) || + !Player_IsChildWithHylianShield(pthis))) { + if ((!(pthis->stateFlags1 & 0x4000) && (sp20 <= 0) && + (func_8008E9C4(pthis) || + ((D_808535E4 != 7) && + (func_80833B2C(pthis) || ((globalCtx->roomCtx.curRoom.unk_03 != 2) && + !(pthis->stateFlags1 & 0x400000) && (sp20 == 0))))))) { + doAction = DO_ACTION_ATTACK; + } else if ((globalCtx->roomCtx.curRoom.unk_03 != 2) && func_80833BCC(pthis) && (sp20 > 0)) { + doAction = DO_ACTION_JUMP; + } else if ((pthis->heldItemActionParam >= PLAYER_AP_SWORD_MASTER) || + ((pthis->stateFlags2 & 0x100000) && + (globalCtx->actorCtx.targetCtx.arrowPointedActor == NULL))) { + doAction = DO_ACTION_PUTAWAY; + } + } + } + } + + if (doAction != DO_ACTION_PUTAWAY) { + pthis->unk_837 = 20; + } else if (pthis->unk_837 != 0) { + doAction = DO_ACTION_NONE; + pthis->unk_837--; + } + + Interface_SetDoAction(globalCtx, doAction); + + if (pthis->stateFlags2 & 0x200000) { + if (pthis->unk_664 != NULL) { + Interface_SetNaviCall(globalCtx, 0x1E); + } else { + Interface_SetNaviCall(globalCtx, 0x1D); + } + Interface_SetNaviCall(globalCtx, 0x1E); + } else { + Interface_SetNaviCall(globalCtx, 0x1F); + } + } +} + +s32 func_80847A78(Player* pthis) { + s32 cond; + + if ((pthis->currentBoots == PLAYER_BOOTS_HOVER) && (pthis->hoverBootsTimer != 0)) { + pthis->hoverBootsTimer--; + } else { + pthis->hoverBootsTimer = 0; + } + + cond = (pthis->currentBoots == PLAYER_BOOTS_HOVER) && + ((pthis->actor.yDistToWater >= 0.0f) || (func_80838144(D_808535E4) >= 0) || func_8083816C(D_808535E4)); + + if (cond && (pthis->actor.bgCheckFlags & 1) && (pthis->hoverBootsTimer != 0)) { + pthis->actor.bgCheckFlags &= ~1; + } + + if (pthis->actor.bgCheckFlags & 1) { + if (!cond) { + pthis->hoverBootsTimer = 19; + } + return 0; + } + + D_808535E4 = 0; + pthis->unk_898 = pthis->unk_89A = D_80853610 = 0; + + return 1; +} + +static Vec3f D_80854798 = { 0.0f, 18.0f, 0.0f }; + +void func_80847BA0(GlobalContext* globalCtx, Player* pthis) { + u8 spC7 = 0; + CollisionPoly* spC0; + Vec3f spB4; + f32 spB0; + f32 spAC; + f32 spA8; + u32 spA4; + + D_80853604 = pthis->unk_A7A; + + if (pthis->stateFlags2 & 0x40000) { + spB0 = 10.0f; + spAC = 15.0f; + spA8 = 30.0f; + } else { + spB0 = pthis->ageProperties->unk_38; + spAC = 26.0f; + spA8 = pthis->ageProperties->unk_00; + } + + if (pthis->stateFlags1 & 0xA0000000) { + if (pthis->stateFlags1 & 0x80000000) { + pthis->actor.bgCheckFlags &= ~1; + spA4 = 0x38; + } else if ((pthis->stateFlags1 & 1) && ((pthis->unk_A84 - (s32)pthis->actor.world.pos.y) >= 100)) { + spA4 = 0x39; + } else if (!(pthis->stateFlags1 & 1) && + ((func_80845EF8 == pthis->func_674) || (func_80845CA4 == pthis->func_674))) { + pthis->actor.bgCheckFlags &= ~0x208; + spA4 = 0x3C; + } else { + spA4 = 0x3F; + } + } else { + spA4 = 0x3F; + } + + if (pthis->stateFlags3 & 1) { + spA4 &= ~6; + } + + if (spA4 & 4) { + pthis->stateFlags3 |= 0x10; + } + + Math_Vec3f_Copy(&spB4, &pthis->actor.world.pos); + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, spAC, spB0, spA8, spA4); + + if (pthis->actor.bgCheckFlags & 0x10) { + pthis->actor.velocity.y = 0.0f; + } + + D_80853600 = pthis->actor.world.pos.y - pthis->actor.floorHeight; + D_808535F4 = 0; + + spC0 = pthis->actor.floorPoly; + + if (spC0 != NULL) { + pthis->unk_A7A = func_80041EA4(&globalCtx->colCtx, spC0, pthis->actor.floorBgId); + pthis->unk_A82 = pthis->unk_89E; + + if (pthis->actor.bgCheckFlags & 0x20) { + if (pthis->actor.yDistToWater < 20.0f) { + pthis->unk_89E = 4; + } else { + pthis->unk_89E = 5; + } + } else { + if (pthis->stateFlags2 & 0x200) { + pthis->unk_89E = 1; + } else { + pthis->unk_89E = SurfaceType_GetSfx(&globalCtx->colCtx, spC0, pthis->actor.floorBgId); + } + } + + if (pthis->actor.category == ACTORCAT_PLAYER) { + Audio_SetCodeReverb(SurfaceType_GetEcho(&globalCtx->colCtx, spC0, pthis->actor.floorBgId)); + + if (pthis->actor.floorBgId == BGCHECK_SCENE) { + func_80074CE8(globalCtx, + SurfaceType_GetLightSettingIndex(&globalCtx->colCtx, spC0, pthis->actor.floorBgId)); + } else { + func_80043508(&globalCtx->colCtx, pthis->actor.floorBgId); + } + } + + D_808535F4 = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, spC0, pthis->actor.floorBgId); + if (D_808535F4 != 0) { + D_808535F8 = SurfaceType_IsConveyor(&globalCtx->colCtx, spC0, pthis->actor.floorBgId); + if (((D_808535F8 == 0) && (pthis->actor.yDistToWater > 20.0f) && + (pthis->currentBoots != PLAYER_BOOTS_IRON)) || + ((D_808535F8 != 0) && (pthis->actor.bgCheckFlags & 1))) { + D_808535FC = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, spC0, pthis->actor.floorBgId) << 10; + } else { + D_808535F4 = 0; + } + } + } + + func_80839034(globalCtx, pthis, spC0, pthis->actor.floorBgId); + + pthis->actor.bgCheckFlags &= ~0x200; + + if (pthis->actor.bgCheckFlags & 8) { + CollisionPoly* spA0; + s32 sp9C; + s16 sp9A; + s32 pad; + + D_80854798.y = 18.0f; + D_80854798.z = pthis->ageProperties->unk_38 + 10.0f; + + if (!(pthis->stateFlags2 & 0x40000) && func_80839768(globalCtx, pthis, &D_80854798, &spA0, &sp9C, &D_80858AA8)) { + pthis->actor.bgCheckFlags |= 0x200; + if (pthis->actor.wallPoly != spA0) { + pthis->actor.wallPoly = spA0; + pthis->actor.wallBgId = sp9C; + pthis->actor.wallYaw = Math_Atan2S(spA0->normal.z, spA0->normal.x); + } + } + + sp9A = pthis->actor.shape.rot.y - (s16)(pthis->actor.wallYaw + 0x8000); + + D_808535F0 = func_80041DB8(&globalCtx->colCtx, pthis->actor.wallPoly, pthis->actor.wallBgId); + + D_80853608 = ABS(sp9A); + + sp9A = pthis->currentYaw - (s16)(pthis->actor.wallYaw + 0x8000); + + D_8085360C = ABS(sp9A); + + spB0 = D_8085360C * 0.00008f; + if (!(pthis->actor.bgCheckFlags & 1) || spB0 >= 1.0f) { + pthis->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; + } else { + spAC = (R_RUN_SPEED_LIMIT / 100.0f * spB0); + pthis->unk_880 = spAC; + if (spAC < 0.1f) { + pthis->unk_880 = 0.1f; + } + } + + if ((pthis->actor.bgCheckFlags & 0x200) && (D_80853608 < 0x3000)) { + CollisionPoly* wallPoly = pthis->actor.wallPoly; + + if (ABS(wallPoly->normal.y) < 600) { + f32 sp8C = COLPOLY_GET_NORMAL(wallPoly->normal.x); + f32 sp88 = COLPOLY_GET_NORMAL(wallPoly->normal.y); + f32 sp84 = COLPOLY_GET_NORMAL(wallPoly->normal.z); + f32 wallHeight; + CollisionPoly* sp7C; + CollisionPoly* sp78; + s32 sp74; + Vec3f sp68; + f32 sp64; + f32 sp60; + s32 temp3; + + pthis->wallDistance = Math3D_UDistPlaneToPos(sp8C, sp88, sp84, wallPoly->dist, &pthis->actor.world.pos); + + spB0 = pthis->wallDistance + 10.0f; + sp68.x = pthis->actor.world.pos.x - (spB0 * sp8C); + sp68.z = pthis->actor.world.pos.z - (spB0 * sp84); + sp68.y = pthis->actor.world.pos.y + pthis->ageProperties->unk_0C; + + sp64 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp7C, &sp68); + wallHeight = sp64 - pthis->actor.world.pos.y; + pthis->wallHeight = wallHeight; + + if ((pthis->wallHeight < 18.0f) || + BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp60, &pthis->actor.world.pos, + (sp64 - pthis->actor.world.pos.y) + 20.0f, &sp78, &sp74, &pthis->actor)) { + pthis->wallHeight = 399.96002f; + } else { + D_80854798.y = (sp64 + 5.0f) - pthis->actor.world.pos.y; + + if (func_80839768(globalCtx, pthis, &D_80854798, &sp78, &sp74, &D_80858AA8) && + (temp3 = pthis->actor.wallYaw - Math_Atan2S(sp78->normal.z, sp78->normal.x), + ABS(temp3) < 0x4000) && + !func_80041E18(&globalCtx->colCtx, sp78, sp74)) { + pthis->wallHeight = 399.96002f; + } else if (func_80041DE4(&globalCtx->colCtx, wallPoly, pthis->actor.wallBgId) == 0) { + if (pthis->ageProperties->unk_1C <= pthis->wallHeight) { + if (ABS(sp7C->normal.y) > 28000) { + if (pthis->ageProperties->unk_14 <= pthis->wallHeight) { + spC7 = 4; + } else if (pthis->ageProperties->unk_18 <= pthis->wallHeight) { + spC7 = 3; + } else { + spC7 = 2; + } + } + } else { + spC7 = 1; + } + } + } + } + } + } else { + pthis->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; + pthis->unk_88D = 0; + pthis->wallHeight = 0.0f; + } + + if (spC7 == pthis->unk_88C) { + if ((pthis->linearVelocity != 0.0f) && (pthis->unk_88D < 100)) { + pthis->unk_88D++; + } + } else { + pthis->unk_88C = spC7; + pthis->unk_88D = 0; + } + + if (pthis->actor.bgCheckFlags & 1) { + D_808535E4 = func_80041D4C(&globalCtx->colCtx, spC0, pthis->actor.floorBgId); + + if (!func_80847A78(pthis)) { + f32 sp58; + f32 sp54; + f32 sp50; + f32 sp4C; + s32 pad2; + f32 sp44; + s32 pad3; + + if (pthis->actor.floorBgId != BGCHECK_SCENE) { + func_800434C8(&globalCtx->colCtx, pthis->actor.floorBgId); + } + + sp58 = COLPOLY_GET_NORMAL(spC0->normal.x); + sp54 = 1.0f / COLPOLY_GET_NORMAL(spC0->normal.y); + sp50 = COLPOLY_GET_NORMAL(spC0->normal.z); + + sp4C = Math_SinS(pthis->currentYaw); + sp44 = Math_CosS(pthis->currentYaw); + + pthis->unk_898 = Math_Atan2S(1.0f, (-(sp58 * sp4C) - (sp50 * sp44)) * sp54); + pthis->unk_89A = Math_Atan2S(1.0f, (-(sp58 * sp44) - (sp50 * sp4C)) * sp54); + + sp4C = Math_SinS(pthis->actor.shape.rot.y); + sp44 = Math_CosS(pthis->actor.shape.rot.y); + + D_80853610 = Math_Atan2S(1.0f, (-(sp58 * sp4C) - (sp50 * sp44)) * sp54); + + func_8083E318(globalCtx, pthis, spC0); + } + } else { + func_80847A78(pthis); + } + + if (pthis->unk_A7B == D_808535E4) { + pthis->unk_A79++; + } else { + pthis->unk_A7B = D_808535E4; + pthis->unk_A79 = 0; + } +} + +void Player_UpdateCamAndSeqModes(GlobalContext* globalCtx, Player* pthis) { + u8 seqMode; + s32 pad; + Actor* unk_664; + s32 camMode; + + if (pthis->actor.category == ACTORCAT_PLAYER) { + seqMode = SEQ_MODE_DEFAULT; + + if (pthis->csMode != 0) { + Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), CAM_MODE_NORMAL); + } else if (!(pthis->stateFlags1 & 0x100000)) { + if ((pthis->actor.parent != NULL) && (pthis->stateFlags3 & 0x80)) { + camMode = CAM_MODE_HOOKSHOT; + Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, pthis->actor.parent); + } else if (func_8084377C == pthis->func_674) { + camMode = CAM_MODE_STILL; + } else if (pthis->stateFlags2 & 0x100) { + camMode = CAM_MODE_PUSHPULL; + } else if ((unk_664 = pthis->unk_664) != NULL) { + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_8)) { + camMode = CAM_MODE_TALK; + } else if (pthis->stateFlags1 & 0x10000) { + if (pthis->stateFlags1 & 0x2000000) { + camMode = CAM_MODE_FOLLOWBOOMERANG; + } else { + camMode = CAM_MODE_FOLLOWTARGET; + } + } else { + camMode = CAM_MODE_BATTLE; + } + Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, unk_664); + } else if (pthis->stateFlags1 & 0x1000) { + camMode = CAM_MODE_CHARGE; + } else if (pthis->stateFlags1 & 0x2000000) { + camMode = CAM_MODE_FOLLOWBOOMERANG; + Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, pthis->boomerangActor); + } else if (pthis->stateFlags1 & 0x6000) { + if (func_80833B2C(pthis)) { + camMode = CAM_MODE_HANGZ; + } else { + camMode = CAM_MODE_HANG; + } + } else if (pthis->stateFlags1 & 0x40020000) { + if (func_8002DD78(pthis) || func_808334B4(pthis)) { + camMode = CAM_MODE_BOWARROWZ; + } else if (pthis->stateFlags1 & 0x200000) { + camMode = CAM_MODE_CLIMBZ; + } else { + camMode = CAM_MODE_TARGET; + } + } else if (pthis->stateFlags1 & 0x240000) { + if ((func_80845668 == pthis->func_674) || (pthis->stateFlags1 & 0x200000)) { + camMode = CAM_MODE_CLIMB; + } else { + camMode = CAM_MODE_JUMP; + } + } else if (pthis->stateFlags1 & 0x80000) { + camMode = CAM_MODE_FREEFALL; + } else if ((pthis->swordState != 0) && (pthis->swordAnimation >= 0) && (pthis->swordAnimation < 0x18)) { + camMode = CAM_MODE_STILL; + } else { + camMode = CAM_MODE_NORMAL; + if ((pthis->linearVelocity == 0.0f) && + (!(pthis->stateFlags1 & 0x800000) || (pthis->rideActor->speedXZ == 0.0f))) { + // not moving + seqMode = SEQ_MODE_STILL; + } + } + + Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), camMode); + } else { + // First person mode + seqMode = SEQ_MODE_STILL; + } + + if (globalCtx->actorCtx.targetCtx.bgmEnemy != NULL) { + seqMode = SEQ_MODE_ENEMY; + Audio_SetBgmEnemyVolume(sqrtf(globalCtx->actorCtx.targetCtx.bgmEnemy->xyzDistToPlayerSq)); + } + + if (globalCtx->sceneNum != SCENE_TURIBORI) { + Audio_SetSequenceMode(seqMode); + } + } +} + +static Vec3f D_808547A4 = { 0.0f, 0.5f, 0.0f }; +static Vec3f D_808547B0 = { 0.0f, 0.5f, 0.0f }; + +static Color_RGBA8 D_808547BC = { 255, 255, 100, 255 }; +static Color_RGBA8 D_808547C0 = { 255, 50, 0, 0 }; + +void func_80848A04(GlobalContext* globalCtx, Player* pthis) { + f32 temp; + + if (pthis->unk_85C == 0.0f) { + func_80835F44(globalCtx, pthis, 0xFF); + return; + } + + temp = 1.0f; + if (DECR(pthis->unk_860) == 0) { + Inventory_ChangeAmmo(ITEM_STICK, -1); + pthis->unk_860 = 1; + temp = 0.0f; + pthis->unk_85C = temp; + } else if (pthis->unk_860 > 200) { + temp = (210 - pthis->unk_860) / 10.0f; + } else if (pthis->unk_860 < 20) { + temp = pthis->unk_860 / 20.0f; + pthis->unk_85C = temp; + } + + func_8002836C(globalCtx, &pthis->swordInfo[0].tip, &D_808547A4, &D_808547B0, &D_808547BC, &D_808547C0, temp * 200.0f, + 0, 8); +} + +void func_80848B44(GlobalContext* globalCtx, Player* pthis) { + Vec3f shockPos; + Vec3f* randBodyPart; + s32 shockScale; + + pthis->shockTimer--; + pthis->unk_892 += pthis->shockTimer; + + if (pthis->unk_892 > 20) { + shockScale = pthis->shockTimer * 2; + pthis->unk_892 -= 20; + + if (shockScale > 40) { + shockScale = 40; + } + + randBodyPart = pthis->bodyPartsPos + (s32)Rand_ZeroFloat(17.9f); + shockPos.x = (Rand_CenteredFloat(5.0f) + randBodyPart->x) - pthis->actor.world.pos.x; + shockPos.y = (Rand_CenteredFloat(5.0f) + randBodyPart->y) - pthis->actor.world.pos.y; + shockPos.z = (Rand_CenteredFloat(5.0f) + randBodyPart->z) - pthis->actor.world.pos.z; + + EffectSsFhgFlash_SpawnShock(globalCtx, &pthis->actor, &shockPos, shockScale, FHGFLASH_SHOCK_PLAYER); + func_8002F8F0(&pthis->actor, NA_SE_PL_SPARK - SFX_FLAG); + } +} + +void func_80848C74(GlobalContext* globalCtx, Player* pthis) { + s32 spawnedFlame; + u8* timerPtr; + s32 timerStep; + f32 flameScale; + f32 flameIntensity; + s32 dmgCooldown; + s32 i; + s32 sp58; + s32 sp54; + + if (pthis->currentTunic == PLAYER_TUNIC_GORON) { + sp54 = 20; + } else { + sp54 = (s32)(pthis->linearVelocity * 0.4f) + 1; + } + + spawnedFlame = false; + timerPtr = pthis->flameTimers; + + if (pthis->stateFlags2 & 8) { + sp58 = 100; + } else { + sp58 = 0; + } + + func_8083819C(pthis, globalCtx); + + for (i = 0; i < 18; i++, timerPtr++) { + timerStep = sp58 + sp54; + + if (*timerPtr <= timerStep) { + *timerPtr = 0; + } else { + spawnedFlame = true; + *timerPtr -= timerStep; + + if (*timerPtr > 20.0f) { + flameIntensity = (*timerPtr - 20.0f) * 0.01f; + flameScale = CLAMP(flameIntensity, 0.19999999f, 0.2f); + } else { + flameScale = *timerPtr * 0.01f; + } + + flameIntensity = (*timerPtr - 25.0f) * 0.02f; + flameIntensity = CLAMP(flameIntensity, 0.0f, 1.0f); + EffectSsFireTail_SpawnFlameOnPlayer(globalCtx, flameScale, i, flameIntensity); + } + } + + if (spawnedFlame) { + func_8002F7DC(&pthis->actor, NA_SE_EV_TORCH - SFX_FLAG); + + if (globalCtx->sceneNum == SCENE_JYASINBOSS) { + dmgCooldown = 0; + } else { + dmgCooldown = 7; + } + + if ((dmgCooldown & globalCtx->gameplayFrames) == 0) { + Player_InflictDamage(globalCtx, -1); + } + } else { + pthis->isBurning = false; + } +} + +void func_80848EF8(Player* pthis) { + if (CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)) { + f32 temp = 200000.0f - (pthis->unk_6A4 * 5.0f); + + if (temp < 0.0f) { + temp = 0.0f; + } + + pthis->unk_6A0 += temp; + if (pthis->unk_6A0 > 4000000.0f) { + pthis->unk_6A0 = 0.0f; + func_8083264C(pthis, 120, 20, 10, 0); + } + } +} + +static s8 D_808547C4[] = { + 0, 3, 3, 5, 4, 8, 9, 13, 14, 15, 16, 17, 18, -22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, -35, + 30, 36, 38, -39, -40, -41, 42, 43, 45, 46, 0, 0, 0, 67, 48, 47, -50, 51, -52, -53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, -65, -66, 68, 11, 69, 70, 71, 8, 8, 72, 73, 78, 79, 80, 89, 90, 91, 92, 77, 19, 94, +}; + +static Vec3f D_80854814 = { 0.0f, 0.0f, 200.0f }; + +static f32 D_80854820[] = { 2.0f, 4.0f, 7.0f }; +static f32 D_8085482C[] = { 0.5f, 1.0f, 3.0f }; + +void Player_UpdateCommon(Player* pthis, GlobalContext* globalCtx, Input* input) { + s32 pad; + + sControlInput = input; + + if (pthis->unk_A86 < 0) { + pthis->unk_A86++; + if (pthis->unk_A86 == 0) { + pthis->unk_A86 = 1; + func_80078884(NA_SE_OC_REVENGE); + } + } + + Math_Vec3f_Copy(&pthis->actor.prevPos, &pthis->actor.home.pos); + + if (pthis->unk_A73 != 0) { + pthis->unk_A73--; + } + + if (pthis->unk_88E != 0) { + pthis->unk_88E--; + } + + if (pthis->unk_A87 != 0) { + pthis->unk_A87--; + } + + if (pthis->invincibilityTimer < 0) { + pthis->invincibilityTimer++; + } else if (pthis->invincibilityTimer > 0) { + pthis->invincibilityTimer--; + } + + if (pthis->unk_890 != 0) { + pthis->unk_890--; + } + + func_808473D4(globalCtx, pthis); + func_80836BEC(pthis, globalCtx); + + if ((pthis->heldItemActionParam == PLAYER_AP_STICK) && (pthis->unk_860 != 0)) { + func_80848A04(globalCtx, pthis); + } else if ((pthis->heldItemActionParam == PLAYER_AP_FISHING_POLE) && (pthis->unk_860 < 0)) { + pthis->unk_860++; + } + + if (pthis->shockTimer != 0) { + func_80848B44(globalCtx, pthis); + } + + if (pthis->isBurning) { + func_80848C74(globalCtx, pthis); + } + + if ((pthis->stateFlags3 & 0x40) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.unk_13F0 == 0)) { + gSaveContext.unk_13F0 = 3; + func_80846A00(globalCtx, pthis, 1); + pthis->stateFlags3 &= ~0x40; + } + + if (pthis->stateFlags2 & 0x8000) { + if (!(pthis->actor.bgCheckFlags & 1)) { + func_80832210(pthis); + Actor_MoveForward(&pthis->actor); + } + + func_80847BA0(globalCtx, pthis); + } else { + f32 temp_f0; + f32 phi_f12; + + if (pthis->currentBoots != pthis->prevBoots) { + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + if (pthis->stateFlags1 & 0x8000000) { + func_80832340(globalCtx, pthis); + if (pthis->ageProperties->unk_2C < pthis->actor.yDistToWater) { + pthis->stateFlags2 |= 0x400; + } + } + } else { + if (pthis->stateFlags1 & 0x8000000) { + if ((pthis->prevBoots == PLAYER_BOOTS_IRON) || (pthis->actor.bgCheckFlags & 1)) { + func_8083D36C(globalCtx, pthis); + pthis->stateFlags2 &= ~0x400; + } + } + } + + pthis->prevBoots = pthis->currentBoots; + } + + if ((pthis->actor.parent == NULL) && (pthis->stateFlags1 & 0x800000)) { + pthis->actor.parent = pthis->rideActor; + func_8083A360(globalCtx, pthis); + pthis->stateFlags1 |= 0x800000; + func_80832264(globalCtx, pthis, &gPlayerAnim_0033B8); + func_80832F54(globalCtx, pthis, 0x9B); + pthis->unk_850 = 99; + } + + if (pthis->unk_844 == 0) { + pthis->unk_845 = 0; + } else if (pthis->unk_844 < 0) { + pthis->unk_844++; + } else { + pthis->unk_844--; + } + + Math_ScaledStepToS(&pthis->unk_6C2, 0, 400); + func_80032CB4(pthis->unk_3A8, 20, 80, 6); + + pthis->actor.shape.face = pthis->unk_3A8[0] + ((globalCtx->gameplayFrames & 32) ? 0 : 3); + + if (pthis->currentMask == PLAYER_MASK_BUNNY) { + func_8085002C(pthis); + } + + if (func_8002DD6C(pthis) != 0) { + func_8084FF7C(pthis); + } + + if (!(pthis->skelAnime.moveFlags & 0x80)) { + if (((pthis->actor.bgCheckFlags & 1) && (D_808535E4 == 5) && (pthis->currentBoots != PLAYER_BOOTS_IRON)) || + ((pthis->currentBoots == PLAYER_BOOTS_HOVER) && !(pthis->stateFlags1 & 0x28000000))) { + f32 sp70 = pthis->linearVelocity; + s16 sp6E = pthis->currentYaw; + s16 yawDiff = pthis->actor.world.rot.y - sp6E; + s32 pad; + + if ((ABS(yawDiff) > 0x6000) && (pthis->actor.speedXZ != 0.0f)) { + sp70 = 0.0f; + sp6E += 0x8000; + } + + if (Math_StepToF(&pthis->actor.speedXZ, sp70, 0.35f) && (sp70 == 0.0f)) { + pthis->actor.world.rot.y = pthis->currentYaw; + } + + if (pthis->linearVelocity != 0.0f) { + s32 phi_v0; + + phi_v0 = (fabsf(pthis->linearVelocity) * 700.0f) - (fabsf(pthis->actor.speedXZ) * 100.0f); + phi_v0 = CLAMP(phi_v0, 0, 1350); + + Math_ScaledStepToS(&pthis->actor.world.rot.y, sp6E, phi_v0); + } + + if ((pthis->linearVelocity == 0.0f) && (pthis->actor.speedXZ != 0.0f)) { + func_800F4138(&pthis->actor.projectedPos, 0xD0, pthis->actor.speedXZ); + } + } else { + pthis->actor.speedXZ = pthis->linearVelocity; + pthis->actor.world.rot.y = pthis->currentYaw; + } + + func_8002D868(&pthis->actor); + + if ((pthis->windSpeed != 0.0f) && !Player_InCsMode(globalCtx) && !(pthis->stateFlags1 & 0x206000) && + (func_80845668 != pthis->func_674) && (func_808507F4 != pthis->func_674)) { + pthis->actor.velocity.x += pthis->windSpeed * Math_SinS(pthis->windDirection); + pthis->actor.velocity.z += pthis->windSpeed * Math_CosS(pthis->windDirection); + } + + func_8002D7EC(&pthis->actor); + func_80847BA0(globalCtx, pthis); + } else { + D_808535E4 = 0; + pthis->unk_A7A = 0; + + if (!(pthis->stateFlags1 & 1) && (pthis->stateFlags1 & 0x800000)) { + EnHorse* rideActor = (EnHorse*)pthis->rideActor; + CollisionPoly* sp5C; + s32 sp58; + Vec3f sp4C; + + if (!(rideActor->actor.bgCheckFlags & 1)) { + func_808396F4(globalCtx, pthis, &D_80854814, &sp4C, &sp5C, &sp58); + } else { + sp5C = rideActor->actor.floorPoly; + sp58 = rideActor->actor.floorBgId; + } + + if ((sp5C != NULL) && func_80839034(globalCtx, pthis, sp5C, sp58)) { + if (DREG(25) != 0) { + DREG(25) = 0; + } else { + AREG(6) = 1; + } + } + } + + D_808535F4 = 0; + pthis->windSpeed = 0.0f; + } + + if ((D_808535F4 != 0) && (pthis->currentBoots != PLAYER_BOOTS_IRON)) { + f32 sp48; + + D_808535F4--; + + if (D_808535F8 == 0) { + sp48 = D_80854820[D_808535F4]; + + if (!(pthis->stateFlags1 & 0x8000000)) { + sp48 *= 0.25f; + } + } else { + sp48 = D_8085482C[D_808535F4]; + } + + Math_StepToF(&pthis->windSpeed, sp48, sp48 * 0.1f); + + Math_ScaledStepToS(&pthis->windDirection, D_808535FC, + ((pthis->stateFlags1 & 0x8000000) ? 400.0f : 800.0f) * sp48); + } else if (pthis->windSpeed != 0.0f) { + Math_StepToF(&pthis->windSpeed, 0.0f, (pthis->stateFlags1 & 0x8000000) ? 0.5f : 1.0f); + } + + if (!Player_InBlockingCsMode(globalCtx, pthis) && !(pthis->stateFlags2 & 0x40000)) { + func_8083D53C(globalCtx, pthis); + + if ((pthis->actor.category == ACTORCAT_PLAYER) && (gSaveContext.health == 0)) { + if (pthis->stateFlags1 & 0x206000) { + func_80832440(globalCtx, pthis); + func_80837B9C(pthis, globalCtx); + } else if ((pthis->actor.bgCheckFlags & 1) || (pthis->stateFlags1 & 0x8000000)) { + func_80836448(globalCtx, pthis, + func_808332B8(pthis) ? &gPlayerAnim_003310 + : (pthis->shockTimer != 0) ? &gPlayerAnim_002F08 + : &gPlayerAnim_002878); + } + } else { + if ((pthis->actor.parent == NULL) && + ((globalCtx->sceneLoadFlag == 0x14) || (pthis->unk_A87 != 0) || !func_808382DC(pthis, globalCtx))) { + func_8083AA10(pthis, globalCtx); + } else { + pthis->fallStartHeight = pthis->actor.world.pos.y; + } + func_80848EF8(pthis); + } + } + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (pthis->csMode != 6) && !(pthis->stateFlags1 & 0x800000) && + !(pthis->stateFlags2 & 0x80) && (pthis->actor.category == ACTORCAT_PLAYER)) { + CsCmdActorAction* linkActionCsCmd = globalCtx->csCtx.linkAction; + + if ((linkActionCsCmd != NULL) && (D_808547C4[linkActionCsCmd->action] != 0)) { + func_8002DF54(globalCtx, NULL, 6); + func_80832210(pthis); + } else if ((pthis->csMode == 0) && !(pthis->stateFlags2 & 0x400) && + (globalCtx->csCtx.state != CS_STATE_UNSKIPPABLE_INIT)) { + func_8002DF54(globalCtx, NULL, 0x31); + func_80832210(pthis); + } + } + + if (pthis->csMode != 0) { + if ((pthis->csMode != 7) || !(pthis->stateFlags1 & 0x4206000)) { + pthis->unk_6AD = 3; + } else if (func_80852E14 != pthis->func_674) { + func_80852944(globalCtx, pthis, NULL); + } + } else { + pthis->prevCsMode = 0; + } + + func_8083D6EC(globalCtx, pthis); + + if ((pthis->unk_664 == NULL) && (pthis->naviTextId == 0)) { + pthis->stateFlags2 &= ~0x200002; + } + + pthis->stateFlags1 &= ~0x401202; + pthis->stateFlags2 &= ~0x441536D; + pthis->stateFlags3 &= ~0x10; + + func_80847298(pthis); + func_8083315C(globalCtx, pthis); + + if (pthis->stateFlags1 & 0x8000000) { + D_808535E8 = 0.5f; + } else { + D_808535E8 = 1.0f; + } + + D_808535EC = 1.0f / D_808535E8; + D_80853614 = D_80853618 = 0; + D_80858AA4 = pthis->currentMask; + + if (!(pthis->stateFlags3 & 4)) { + pthis->func_674(pthis, globalCtx); + } + + Player_UpdateCamAndSeqModes(globalCtx, pthis); + + if (pthis->skelAnime.moveFlags & 8) { + AnimationContext_SetMoveActor(globalCtx, &pthis->actor, &pthis->skelAnime, + (pthis->skelAnime.moveFlags & 4) ? 1.0f : pthis->ageProperties->unk_08); + } + + func_808368EC(pthis, globalCtx); + + if (CHECK_FLAG_ALL(pthis->actor.flags, ACTOR_FLAG_8)) { + pthis->targetActorDistance = 0.0f; + } else { + pthis->targetActor = NULL; + pthis->targetActorDistance = FLT_MAX; + pthis->exchangeItemId = EXCH_ITEM_NONE; + } + + if (!(pthis->stateFlags1 & 0x800)) { + pthis->interactRangeActor = NULL; + pthis->getItemDirection = 0x6000; + } + + if (pthis->actor.parent == NULL) { + pthis->rideActor = NULL; + } + + pthis->naviTextId = 0; + + if (!(pthis->stateFlags2 & 0x2000000)) { + pthis->unk_6A8 = NULL; + } + + pthis->stateFlags2 &= ~0x800000; + pthis->unk_6A4 = FLT_MAX; + + temp_f0 = pthis->actor.world.pos.y - pthis->actor.prevPos.y; + + pthis->doorType = PLAYER_DOORTYPE_NONE; + pthis->unk_8A1 = 0; + pthis->unk_684 = NULL; + + phi_f12 = ((pthis->bodyPartsPos[6].y + pthis->bodyPartsPos[3].y) * 0.5f) + temp_f0; + temp_f0 += pthis->bodyPartsPos[7].y + 10.0f; + + pthis->cylinder.dim.height = temp_f0 - phi_f12; + + if (pthis->cylinder.dim.height < 0) { + phi_f12 = temp_f0; + pthis->cylinder.dim.height = -pthis->cylinder.dim.height; + } + + pthis->cylinder.dim.yShift = phi_f12 - pthis->actor.world.pos.y; + + if (pthis->stateFlags1 & 0x400000) { + pthis->cylinder.dim.height = pthis->cylinder.dim.height * 0.8f; + } + + Collider_UpdateCylinder(&pthis->actor, &pthis->cylinder); + + if (!(pthis->stateFlags2 & 0x4000)) { + if (!(pthis->stateFlags1 & 0x806080)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder.base); + } + + if (!(pthis->stateFlags1 & 0x4000080) && (pthis->invincibilityTimer <= 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder.base); + + if (pthis->invincibilityTimer < 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &pthis->cylinder.base); + } + } + } + + AnimationContext_SetNextQueue(globalCtx); + } + + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); + Math_Vec3f_Copy(&pthis->unk_A88, &pthis->bodyPartsPos[0]); + + if (pthis->stateFlags1 & 0x30000080) { + pthis->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + pthis->actor.colChkInfo.mass = 50; + } + + pthis->stateFlags3 &= ~4; + + Collider_ResetCylinderAC(globalCtx, &pthis->cylinder.base); + + Collider_ResetQuadAT(globalCtx, &pthis->swordQuads[0].base); + Collider_ResetQuadAT(globalCtx, &pthis->swordQuads[1].base); + + Collider_ResetQuadAC(globalCtx, &pthis->shieldQuad.base); + Collider_ResetQuadAT(globalCtx, &pthis->shieldQuad.base); +} + +static Vec3f D_80854838 = { 0.0f, 0.0f, -30.0f }; + +void Player_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f sDogSpawnPos; + Player* pthis = (Player*)thisx; + s32 dogParams; + s32 pad; + Input sp44; + Actor* dog; + + if (func_8084FCAC(pthis, globalCtx)) { + if (gSaveContext.dogParams < 0) { + if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG) < 0) { + gSaveContext.dogParams = 0; + } else { + gSaveContext.dogParams &= 0x7FFF; + func_808395DC(pthis, &pthis->actor.world.pos, &D_80854838, &sDogSpawnPos); + dogParams = gSaveContext.dogParams; + + dog = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, + sDogSpawnPos.z, 0, pthis->actor.shape.rot.y, 0, dogParams | 0x8000); + if (dog != NULL) { + dog->room = 0; + } + } + } + + if ((pthis->interactRangeActor != NULL) && (pthis->interactRangeActor->update == NULL)) { + pthis->interactRangeActor = NULL; + } + + if ((pthis->heldActor != NULL) && (pthis->heldActor->update == NULL)) { + func_808323B4(globalCtx, pthis); + } + + if (pthis->stateFlags1 & 0x20000020) { + bzero(&sp44, sizeof(sp44)); + } else { + sp44 = globalCtx->state.input[0]; + if (pthis->unk_88E != 0) { + sp44.cur.button &= ~(BTN_A | BTN_B | BTN_CUP); + sp44.press.button &= ~(BTN_A | BTN_B | BTN_CUP); + } + } + + Player_UpdateCommon(pthis, globalCtx, &sp44); + } + + MREG(52) = pthis->actor.world.pos.x; + MREG(53) = pthis->actor.world.pos.y; + MREG(54) = pthis->actor.world.pos.z; + MREG(55) = pthis->actor.world.rot.y; +} + +static struct_80858AC8 D_80858AC8; +static Vec3s D_80858AD8[25]; + +static Gfx* sMaskDlists[PLAYER_MASK_MAX - 1] = { + gLinkChildKeatonMaskDL, gLinkChildSkullMaskDL, gLinkChildSpookyMaskDL, gLinkChildBunnyHoodDL, + gLinkChildGoronMaskDL, gLinkChildZoraMaskDL, gLinkChildGerudoMaskDL, gLinkChildMaskOfTruthDL, +}; + +static Vec3s D_80854864 = { 0, 0, 0 }; + +void func_8084A0E8(GlobalContext* globalCtx, Player* pthis, s32 lod, Gfx* cullDList, + OverrideLimbDrawOpa overrideLimbDraw) { + static s32 D_8085486C = 255; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19228); + + gSPSegment(POLY_OPA_DISP++, 0x0C, cullDList); + gSPSegment(POLY_XLU_DISP++, 0x0C, cullDList); + + func_8008F470(globalCtx, pthis->skelAnime.skeleton, pthis->skelAnime.jointTable, pthis->skelAnime.dListCount, lod, + pthis->currentTunic, pthis->currentBoots, pthis->actor.shape.face, overrideLimbDraw, func_80090D20, + pthis); + + if ((overrideLimbDraw == func_80090014) && (pthis->currentMask != PLAYER_MASK_NONE)) { + Mtx* sp70 = (Mtx*)Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Mtx)); + + if (pthis->currentMask == PLAYER_MASK_BUNNY) { + Vec3s sp68; + + gSPSegment(POLY_OPA_DISP++, 0x0B, sp70); + + sp68.x = D_80858AC8.unk_02 + 0x3E2; + sp68.y = D_80858AC8.unk_04 + 0xDBE; + sp68.z = D_80858AC8.unk_00 - 0x348A; + func_800D1694(97.0f, -1203.0f, -240.0f, &sp68); + Matrix_ToMtx(sp70++, "../z_player.c", 19273); + + sp68.x = D_80858AC8.unk_02 - 0x3E2; + sp68.y = -0xDBE - D_80858AC8.unk_04; + sp68.z = D_80858AC8.unk_00 - 0x348A; + func_800D1694(97.0f, -1203.0f, 240.0f, &sp68); + Matrix_ToMtx(sp70, "../z_player.c", 19279); + } + + gSPDisplayList(POLY_OPA_DISP++, sMaskDlists[pthis->currentMask - 1]); + } + + if ((pthis->currentBoots == PLAYER_BOOTS_HOVER) && !(pthis->actor.bgCheckFlags & 1) && + !(pthis->stateFlags1 & 0x800000) && (pthis->hoverBootsTimer != 0)) { + s32 sp5C; + s32 hoverBootsTimer = pthis->hoverBootsTimer; + + if (pthis->hoverBootsTimer < 19) { + if (hoverBootsTimer >= 15) { + D_8085486C = (19 - hoverBootsTimer) * 51.0f; + } else if (hoverBootsTimer < 19) { + sp5C = hoverBootsTimer; + + if (sp5C > 9) { + sp5C = 9; + } + + D_8085486C = (-sp5C * 4) + 36; + D_8085486C = D_8085486C * D_8085486C; + D_8085486C = (s32)((Math_CosS(D_8085486C) * 100.0f) + 100.0f) + 55.0f; + D_8085486C = D_8085486C * (sp5C * (1.0f / 9.0f)); + } + + func_800D1694(pthis->actor.world.pos.x, pthis->actor.world.pos.y + 2.0f, pthis->actor.world.pos.z, + &D_80854864); + Matrix_Scale(4.0f, 4.0f, 4.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player.c", 19317), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 32, 1, 0, + (globalCtx->gameplayFrames * -15) % 128, 16, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, D_8085486C); + gDPSetEnvColor(POLY_XLU_DISP++, 120, 90, 30, 128); + gSPDisplayList(POLY_XLU_DISP++, gHoverBootsCircleDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19328); +} + +void Player_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Player* pthis = (Player*)thisx; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19346); + + if (!(pthis->stateFlags2 & 0x20000000)) { + OverrideLimbDrawOpa overrideLimbDraw = func_80090014; + s32 lod; + s32 pad; + + if ((pthis->csMode != 0) || (func_8008E9C4(pthis) && 0) || (pthis->actor.projectedPos.z < 160.0f)) { + lod = 0; + } else { + lod = 1; + } + + func_80093C80(globalCtx); + func_80093D84(globalCtx->state.gfxCtx); + + if (pthis->invincibilityTimer > 0) { + pthis->unk_88F += CLAMP(50 - pthis->invincibilityTimer, 8, 40); + POLY_OPA_DISP = + Gfx_SetFog2(POLY_OPA_DISP, 255, 0, 0, 0, 0, 4000 - (s32)(Math_CosS(pthis->unk_88F * 256) * 2000.0f)); + } + + func_8002EBCC(&pthis->actor, globalCtx, 0); + func_8002ED80(&pthis->actor, globalCtx, 0); + + if (pthis->unk_6AD != 0) { + Vec3f sp7C; + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &pthis->actor.focus.pos, &sp7C); + if (sp7C.z < -4.0f) { + overrideLimbDraw = func_800902F0; + } + } else if (pthis->stateFlags2 & 0x40000) { + if (pthis->actor.projectedPos.z < 0.0f) { + overrideLimbDraw = func_80090440; + } + } + + if (pthis->stateFlags2 & 0x4000000) { + f32 sp78 = ((u16)(globalCtx->gameplayFrames * 600) * M_PI) / 0x8000; + f32 sp74 = ((u16)(globalCtx->gameplayFrames * 1000) * M_PI) / 0x8000; + + Matrix_Push(); + pthis->actor.scale.y = -pthis->actor.scale.y; + func_800D1694(pthis->actor.world.pos.x, + (pthis->actor.floorHeight + (pthis->actor.floorHeight - pthis->actor.world.pos.y)) + + (pthis->actor.shape.yOffset * pthis->actor.scale.y), + pthis->actor.world.pos.z, &pthis->actor.shape.rot); + Matrix_Scale(pthis->actor.scale.x, pthis->actor.scale.y, pthis->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateX(sp78, MTXMODE_APPLY); + Matrix_RotateY(sp74, MTXMODE_APPLY); + Matrix_Scale(1.1f, 0.95f, 1.05f, MTXMODE_APPLY); + Matrix_RotateY(-sp74, MTXMODE_APPLY); + Matrix_RotateX(-sp78, MTXMODE_APPLY); + func_8084A0E8(globalCtx, pthis, lod, gCullFrontDList, overrideLimbDraw); + pthis->actor.scale.y = -pthis->actor.scale.y; + Matrix_Pop(); + } + + gSPClearGeometryMode(POLY_OPA_DISP++, G_CULL_BOTH); + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH); + + func_8084A0E8(globalCtx, pthis, lod, gCullBackDList, overrideLimbDraw); + + if (pthis->invincibilityTimer > 0) { + POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + } + + if (pthis->stateFlags2 & 0x4000) { + f32 scale = (pthis->unk_84F >> 1) * 22.0f; + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (0 - globalCtx->gameplayFrames) % 128, 32, 32, 1, + 0, (globalCtx->gameplayFrames * -2) % 128, 32, 32)); + + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player.c", 19459), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, 255); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL); + } + + if (pthis->unk_862 > 0) { + Player_DrawGetItem(globalCtx, pthis); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player.c", 19473); +} + +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Player* pthis = (Player*)thisx; + + Effect_Delete(globalCtx, pthis->swordEffectIndex); + + Collider_DestroyCylinder(globalCtx, &pthis->cylinder); + Collider_DestroyQuad(globalCtx, &pthis->swordQuads[0]); + Collider_DestroyQuad(globalCtx, &pthis->swordQuads[1]); + Collider_DestroyQuad(globalCtx, &pthis->shieldQuad); + + func_800876C8(globalCtx); + + gSaveContext.linkAge = globalCtx->linkAgeOnLoad; +} + +s16 func_8084ABD8(GlobalContext* globalCtx, Player* pthis, s32 arg2, s16 arg3) { + s32 temp1; + s16 temp2; + s16 temp3; + + if (!func_8002DD78(pthis) && !func_808334B4(pthis) && (arg2 == 0)) { + temp2 = sControlInput->rel.stick_y * 240.0f; + Math_SmoothStepToS(&pthis->actor.focus.rot.x, temp2, 14, 4000, 30); + + temp2 = sControlInput->rel.stick_x * -16.0f; + temp2 = CLAMP(temp2, -3000, 3000); + pthis->actor.focus.rot.y += temp2; + } else { + temp1 = (pthis->stateFlags1 & 0x800000) ? 3500 : 14000; + temp3 = ((sControlInput->rel.stick_y >= 0) ? 1 : -1) * + (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * 1500.0f); + pthis->actor.focus.rot.x += temp3; + pthis->actor.focus.rot.x = CLAMP(pthis->actor.focus.rot.x, -temp1, temp1); + + temp1 = 19114; + temp2 = pthis->actor.focus.rot.y - pthis->actor.shape.rot.y; + temp3 = ((sControlInput->rel.stick_x >= 0) ? 1 : -1) * + (s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) * -1500.0f); + temp2 += temp3; + pthis->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + pthis->actor.shape.rot.y; + } + + pthis->unk_6AE |= 2; + return func_80836AB8(pthis, (globalCtx->shootingGalleryStatus != 0) || func_8002DD78(pthis) || func_808334B4(pthis)) - + arg3; +} + +void func_8084AEEC(Player* pthis, f32* arg1, f32 arg2, s16 arg3) { + f32 temp1; + f32 temp2; + + temp1 = pthis->skelAnime.curFrame - 10.0f; + + temp2 = (R_RUN_SPEED_LIMIT / 100.0f) * 0.8f; + if (*arg1 > temp2) { + *arg1 = temp2; + } + + if ((0.0f < temp1) && (temp1 < 10.0f)) { + temp1 *= 6.0f; + } else { + temp1 = 0.0f; + arg2 = 0.0f; + } + + Math_AsymStepToF(arg1, arg2 * 0.8f, temp1, (fabsf(*arg1) * 0.02f) + 0.05f); + Math_ScaledStepToS(&pthis->currentYaw, arg3, 1600); +} + +void func_8084B000(Player* pthis) { + f32 phi_f18; + f32 phi_f16; + f32 phi_f14; + f32 yDistToWater; + + phi_f14 = -5.0f; + + phi_f16 = pthis->ageProperties->unk_28; + if (pthis->actor.velocity.y < 0.0f) { + phi_f16 += 1.0f; + } + + if (pthis->actor.yDistToWater < phi_f16) { + if (pthis->actor.velocity.y <= 0.0f) { + phi_f16 = 0.0f; + } else { + phi_f16 = pthis->actor.velocity.y * 0.5f; + } + phi_f18 = -0.1f - phi_f16; + } else { + if (!(pthis->stateFlags1 & 0x80) && (pthis->currentBoots == PLAYER_BOOTS_IRON) && + (pthis->actor.velocity.y >= -3.0f)) { + phi_f18 = -0.2f; + } else { + phi_f14 = 2.0f; + if (pthis->actor.velocity.y >= 0.0f) { + phi_f16 = 0.0f; + } else { + phi_f16 = pthis->actor.velocity.y * -0.3f; + } + phi_f18 = phi_f16 + 0.1f; + } + + yDistToWater = pthis->actor.yDistToWater; + if (yDistToWater > 100.0f) { + pthis->stateFlags2 |= 0x400; + } + } + + pthis->actor.velocity.y += phi_f18; + + if (((pthis->actor.velocity.y - phi_f14) * phi_f18) > 0) { + pthis->actor.velocity.y = phi_f14; + } + + pthis->actor.gravity = 0.0f; +} + +void func_8084B158(GlobalContext* globalCtx, Player* pthis, Input* input, f32 arg3) { + f32 temp; + + if ((input != NULL) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_B)) { + temp = 1.0f; + } else { + temp = 0.5f; + } + + temp *= arg3; + + if (temp < 1.0f) { + temp = 1.0f; + } + + pthis->skelAnime.playSpeed = temp; + LinkAnimation_Update(globalCtx, &pthis->skelAnime); +} + +void func_8084B1D8(Player* pthis, GlobalContext* globalCtx) { + if (pthis->stateFlags1 & 0x8000000) { + func_8084B000(pthis); + func_8084AEEC(pthis, &pthis->linearVelocity, 0, pthis->actor.shape.rot.y); + } else { + func_8083721C(pthis); + } + + if ((pthis->unk_6AD == 2) && (func_8002DD6C(pthis) || func_808332E4(pthis))) { + func_80836670(pthis, globalCtx); + } + + if ((pthis->csMode != 0) || (pthis->unk_6AD == 0) || (pthis->unk_6AD >= 4) || func_80833B54(pthis) || + (pthis->unk_664 != NULL) || !func_8083AD4C(globalCtx, pthis) || + (((pthis->unk_6AD == 2) && (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_R) || + func_80833B2C(pthis) || (!func_8002DD78(pthis) && !func_808334B4(pthis)))) || + ((pthis->unk_6AD == 1) && + CHECK_BTN_ANY(sControlInput->press.button, + BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)))) { + func_8083C148(pthis, globalCtx); + func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); + } else if ((DECR(pthis->unk_850) == 0) || (pthis->unk_6AD != 2)) { + if (func_8008F128(pthis)) { + pthis->unk_6AE |= 0x43; + } else { + pthis->actor.shape.rot.y = func_8084ABD8(globalCtx, pthis, 0, 0); + } + } + + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +s32 func_8084B3CC(GlobalContext* globalCtx, Player* pthis) { + if (globalCtx->shootingGalleryStatus != 0) { + func_80832564(globalCtx, pthis); + func_80835C58(globalCtx, pthis, func_8084FA54, 0); + + if (!func_8002DD6C(pthis) || Player_HoldsHookshot(pthis)) { + func_80835F44(globalCtx, pthis, 3); + } + + pthis->stateFlags1 |= 0x100000; + func_80832264(globalCtx, pthis, func_80833338(pthis)); + func_80832210(pthis); + func_8083B010(pthis); + return 1; + } + + return 0; +} + +void func_8084B498(Player* pthis) { + pthis->itemActionParam = + (INV_CONTENT(ITEM_OCARINA_FAIRY) == ITEM_OCARINA_FAIRY) ? PLAYER_AP_OCARINA_FAIRY : PLAYER_AP_OCARINA_TIME; +} + +s32 func_8084B4D4(GlobalContext* globalCtx, Player* pthis) { + if (pthis->stateFlags3 & 0x20) { + pthis->stateFlags3 &= ~0x20; + func_8084B498(pthis); + pthis->unk_6AD = 4; + func_8083B040(pthis, globalCtx); + return 1; + } + + return 0; +} + +void func_8084B530(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x20; + func_80836670(pthis, globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actor.flags &= ~ACTOR_FLAG_8; + + if (!CHECK_FLAG_ALL(pthis->targetActor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2)) { + pthis->stateFlags2 &= ~0x2000; + } + + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + + if (!func_8084B4D4(globalCtx, pthis) && !func_8084B3CC(globalCtx, pthis) && !func_8083ADD4(globalCtx, pthis)) { + if ((pthis->targetActor != pthis->interactRangeActor) || !func_8083E5A8(pthis, globalCtx)) { + if (pthis->stateFlags1 & 0x800000) { + s32 sp24 = pthis->unk_850; + func_8083A360(globalCtx, pthis); + pthis->unk_850 = sp24; + } else if (func_808332B8(pthis)) { + func_80838F18(globalCtx, pthis); + } else { + func_80853080(pthis, globalCtx); + } + } + } + + pthis->unk_88E = 10; + return; + } + + if (pthis->stateFlags1 & 0x800000) { + func_8084CC98(pthis, globalCtx); + } else if (func_808332B8(pthis)) { + func_8084D610(pthis, globalCtx); + } else if (!func_8008E9C4(pthis) && LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->skelAnime.moveFlags != 0) { + func_80832DBC(pthis); + if ((pthis->targetActor->category == ACTORCAT_NPC) && + (pthis->heldItemActionParam != PLAYER_AP_FISHING_POLE)) { + func_808322D0(globalCtx, pthis, &gPlayerAnim_0031A0); + } else { + func_80832284(globalCtx, pthis, func_80833338(pthis)); + } + } else { + func_808322A4(globalCtx, pthis, &gPlayerAnim_0031A8); + } + } + + if (pthis->unk_664 != NULL) { + pthis->currentYaw = pthis->actor.shape.rot.y = func_8083DB98(pthis, 0); + } +} + +void func_8084B78C(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + s32 temp; + + pthis->stateFlags2 |= 0x141; + func_8083F524(globalCtx, pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (!func_8083F9D0(globalCtx, pthis)) { + func_80837268(pthis, &sp34, &sp32, 0.0f, globalCtx); + temp = func_8083FFB8(pthis, &sp34, &sp32); + if (temp > 0) { + func_8083FAB8(pthis, globalCtx); + } else if (temp < 0) { + func_8083FB14(pthis, globalCtx); + } + } + } +} + +void func_8084B840(GlobalContext* globalCtx, Player* pthis, f32 arg2) { + if (pthis->actor.wallBgId != BGCHECK_SCENE) { + DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.wallBgId); + + if (dynaPolyActor != NULL) { + func_8002DFA4(dynaPolyActor, arg2, pthis->actor.world.rot.y); + } + } +} + +static struct_80832924 D_80854870[] = { + { NA_SE_PL_SLIP, 0x1003 }, + { NA_SE_PL_SLIP, -0x1015 }, +}; + +void func_8084B898(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + s32 temp; + + pthis->stateFlags2 |= 0x141; + + if (func_80832CB0(globalCtx, pthis, &gPlayerAnim_003108)) { + pthis->unk_850 = 1; + } else if (pthis->unk_850 == 0) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 11.0f)) { + func_80832698(pthis, NA_SE_VO_LI_PUSH); + } + } + + func_80832924(pthis, D_80854870); + func_8083F524(globalCtx, pthis); + + if (!func_8083F9D0(globalCtx, pthis)) { + func_80837268(pthis, &sp34, &sp32, 0.0f, globalCtx); + temp = func_8083FFB8(pthis, &sp34, &sp32); + if (temp < 0) { + func_8083FB14(pthis, globalCtx); + } else if (temp == 0) { + func_8083F72C(pthis, &gPlayerAnim_0030E0, globalCtx); + } else { + pthis->stateFlags2 |= 0x10; + } + } + + if (pthis->stateFlags2 & 0x10) { + func_8084B840(globalCtx, pthis, 2.0f); + pthis->linearVelocity = 2.0f; + } +} + +static struct_80832924 D_80854878[] = { + { NA_SE_PL_SLIP, 0x1004 }, + { NA_SE_PL_SLIP, -0x1018 }, +}; + +static Vec3f D_80854880 = { 0.0f, 26.0f, -40.0f }; + +void func_8084B9E4(Player* pthis, GlobalContext* globalCtx) { + LinkAnimationHeader* anim; + f32 sp70; + s16 sp6E; + s32 temp1; + Vec3f sp5C; + f32 temp2; + CollisionPoly* sp54; + s32 sp50; + Vec3f sp44; + Vec3f sp38; + + anim = D_80853C74[pthis->modelAnimType]; + pthis->stateFlags2 |= 0x141; + + if (func_80832CB0(globalCtx, pthis, anim)) { + pthis->unk_850 = 1; + } else { + if (pthis->unk_850 == 0) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 11.0f)) { + func_80832698(pthis, NA_SE_VO_LI_PUSH); + } + } else { + func_80832924(pthis, D_80854878); + } + } + + func_8083F524(globalCtx, pthis); + + if (!func_8083F9D0(globalCtx, pthis)) { + func_80837268(pthis, &sp70, &sp6E, 0.0f, globalCtx); + temp1 = func_8083FFB8(pthis, &sp70, &sp6E); + if (temp1 > 0) { + func_8083FAB8(pthis, globalCtx); + } else if (temp1 == 0) { + func_8083F72C(pthis, D_80853C8C[pthis->modelAnimType], globalCtx); + } else { + pthis->stateFlags2 |= 0x10; + } + } + + if (pthis->stateFlags2 & 0x10) { + temp2 = func_8083973C(globalCtx, pthis, &D_80854880, &sp5C) - pthis->actor.world.pos.y; + if (fabsf(temp2) < 20.0f) { + sp44.x = pthis->actor.world.pos.x; + sp44.z = pthis->actor.world.pos.z; + sp44.y = sp5C.y; + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp44, &sp5C, &sp38, &sp54, true, false, false, true, + &sp50)) { + func_8084B840(globalCtx, pthis, -2.0f); + return; + } + } + pthis->stateFlags2 &= ~0x10; + } +} + +void func_8084BBE4(Player* pthis, GlobalContext* globalCtx) { + f32 sp3C; + s16 sp3A; + LinkAnimationHeader* anim; + f32 temp; + + pthis->stateFlags2 |= 0x40; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + // clang-format off + anim = (pthis->unk_84F > 0) ? &gPlayerAnim_002F28 : D_80853CD4[pthis->modelAnimType]; func_80832284(globalCtx, pthis, anim); + // clang-format on + } else if (pthis->unk_84F == 0) { + if (pthis->skelAnime.animation == &gPlayerAnim_002F10) { + temp = 11.0f; + } else { + temp = 1.0f; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, temp)) { + func_80832770(pthis, NA_SE_PL_WALK_GROUND); + if (pthis->skelAnime.animation == &gPlayerAnim_002F10) { + pthis->unk_84F = 1; + } else { + pthis->unk_84F = -1; + } + } + } + + Math_ScaledStepToS(&pthis->actor.shape.rot.y, pthis->currentYaw, 0x800); + + if (pthis->unk_84F != 0) { + func_80837268(pthis, &sp3C, &sp3A, 0.0f, globalCtx); + if (pthis->unk_847[pthis->unk_846] >= 0) { + if (pthis->unk_84F > 0) { + anim = D_80853CA4[pthis->modelAnimType]; + } else { + anim = D_80853CEC[pthis->modelAnimType]; + } + func_8083A9B8(pthis, anim, globalCtx); + return; + } + + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) || (pthis->actor.shape.feetFloorFlags != 0)) { + func_80837B60(pthis); + if (pthis->unk_84F < 0) { + pthis->linearVelocity = -0.8f; + } else { + pthis->linearVelocity = 0.8f; + } + func_80837B9C(pthis, globalCtx); + pthis->stateFlags1 &= ~0x6000; + } + } +} + +void func_8084BDFC(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x40; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832E48(pthis, 1); + func_8083C0E8(pthis, globalCtx); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame - 6.0f)) { + func_808328A0(pthis); + } else if (LinkAnimation_OnFrame(&pthis->skelAnime, pthis->skelAnime.endFrame - 34.0f)) { + pthis->stateFlags1 &= ~0x6000; + func_8002F7DC(&pthis->actor, NA_SE_PL_CLIMB_CLIFF); + func_80832698(pthis, NA_SE_VO_LI_CLIMB_END); + } +} + +void func_8084BEE4(Player* pthis) { + func_8002F7DC(&pthis->actor, (pthis->unk_84F != 0) ? NA_SE_PL_WALK_WALL : NA_SE_PL_WALK_LADDER); +} + +void func_8084BF1C(Player* pthis, GlobalContext* globalCtx) { + static Vec3f D_8085488C = { 0.0f, 0.0f, 26.0f }; + s32 sp84; + s32 sp80; + f32 phi_f0; + f32 phi_f2; + Vec3f sp6C; + s32 sp68; + Vec3f sp5C; + f32 temp_f0; + LinkAnimationHeader* anim1; + LinkAnimationHeader* anim2; + + sp84 = sControlInput->rel.stick_y; + sp80 = sControlInput->rel.stick_x; + + pthis->fallStartHeight = pthis->actor.world.pos.y; + pthis->stateFlags2 |= 0x40; + + if ((pthis->unk_84F != 0) && (ABS(sp84) < ABS(sp80))) { + phi_f0 = ABS(sp80) * 0.0325f; + sp84 = 0; + } else { + phi_f0 = ABS(sp84) * 0.05f; + sp80 = 0; + } + + if (phi_f0 < 1.0f) { + phi_f0 = 1.0f; + } else if (phi_f0 > 3.35f) { + phi_f0 = 3.35f; + } + + if (pthis->skelAnime.playSpeed >= 0.0f) { + phi_f2 = 1.0f; + } else { + phi_f2 = -1.0f; + } + + pthis->skelAnime.playSpeed = phi_f2 * phi_f0; + + if (pthis->unk_850 >= 0) { + if ((pthis->actor.wallPoly != NULL) && (pthis->actor.wallBgId != BGCHECK_SCENE)) { + DynaPolyActor* wallPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, pthis->actor.wallBgId); + if (wallPolyActor != NULL) { + Math_Vec3f_Diff(&wallPolyActor->actor.world.pos, &wallPolyActor->actor.prevPos, &sp6C); + Math_Vec3f_Sum(&pthis->actor.world.pos, &sp6C, &pthis->actor.world.pos); + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &pthis->actor, 26.0f, 6.0f, pthis->ageProperties->unk_00, 7); + func_8083F360(globalCtx, pthis, 26.0f, pthis->ageProperties->unk_3C, 50.0f, -20.0f); + } + + if ((pthis->unk_850 < 0) || !func_8083FBC0(pthis, globalCtx)) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) != 0) { + if (pthis->unk_850 < 0) { + pthis->unk_850 = ABS(pthis->unk_850) & 1; + return; + } + + if (sp84 != 0) { + sp68 = pthis->unk_84F + pthis->unk_850; + + if (sp84 > 0) { + D_8085488C.y = pthis->ageProperties->unk_40; + temp_f0 = func_8083973C(globalCtx, pthis, &D_8085488C, &sp5C); + + if (pthis->actor.world.pos.y < temp_f0) { + if (pthis->unk_84F != 0) { + pthis->actor.world.pos.y = temp_f0; + pthis->stateFlags1 &= ~0x200000; + func_8083A5C4(globalCtx, pthis, pthis->actor.wallPoly, pthis->ageProperties->unk_3C, + &gPlayerAnim_003000); + pthis->currentYaw += 0x8000; + pthis->actor.shape.rot.y = pthis->currentYaw; + func_8083A9B8(pthis, &gPlayerAnim_003000, globalCtx); + pthis->stateFlags1 |= 0x4000; + } else { + func_8083F070(pthis, pthis->ageProperties->unk_CC[pthis->unk_850], globalCtx); + } + } else { + pthis->skelAnime.prevTransl = pthis->ageProperties->unk_4A[sp68]; + func_80832264(globalCtx, pthis, pthis->ageProperties->unk_AC[sp68]); + } + } else { + if ((pthis->actor.world.pos.y - pthis->actor.floorHeight) < 15.0f) { + if (pthis->unk_84F != 0) { + func_8083FB7C(pthis, globalCtx); + } else { + if (pthis->unk_850 != 0) { + pthis->skelAnime.prevTransl = pthis->ageProperties->unk_44; + } + func_8083F070(pthis, pthis->ageProperties->unk_C4[pthis->unk_850], globalCtx); + pthis->unk_850 = 1; + } + } else { + sp68 ^= 1; + pthis->skelAnime.prevTransl = pthis->ageProperties->unk_62[sp68]; + anim1 = pthis->ageProperties->unk_AC[sp68]; + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim1, -1.0f, Animation_GetLastFrame(anim1), + 0.0f, ANIMMODE_ONCE, 0.0f); + } + } + pthis->unk_850 ^= 1; + } else { + if ((pthis->unk_84F != 0) && (sp80 != 0)) { + anim2 = pthis->ageProperties->unk_BC[pthis->unk_850]; + + if (sp80 > 0) { + pthis->skelAnime.prevTransl = pthis->ageProperties->unk_7A[pthis->unk_850]; + func_80832264(globalCtx, pthis, anim2); + } else { + pthis->skelAnime.prevTransl = pthis->ageProperties->unk_86[pthis->unk_850]; + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim2, -1.0f, Animation_GetLastFrame(anim2), + 0.0f, ANIMMODE_ONCE, 0.0f); + } + } else { + pthis->stateFlags2 |= 0x1000; + } + } + + return; + } + } + + if (pthis->unk_850 < 0) { + if (((pthis->unk_850 == -2) && + (LinkAnimation_OnFrame(&pthis->skelAnime, 14.0f) || LinkAnimation_OnFrame(&pthis->skelAnime, 29.0f))) || + ((pthis->unk_850 == -4) && + (LinkAnimation_OnFrame(&pthis->skelAnime, 22.0f) || LinkAnimation_OnFrame(&pthis->skelAnime, 35.0f) || + LinkAnimation_OnFrame(&pthis->skelAnime, 49.0f) || LinkAnimation_OnFrame(&pthis->skelAnime, 55.0f)))) { + func_8084BEE4(pthis); + } + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, (pthis->skelAnime.playSpeed > 0.0f) ? 20.0f : 0.0f)) { + func_8084BEE4(pthis); + } +} + +static f32 D_80854898[] = { 10.0f, 20.0f }; +static f32 D_808548A0[] = { 40.0f, 50.0f }; + +static struct_80832924 D_808548A8[] = { + { NA_SE_PL_WALK_LADDER, 0x80A }, + { NA_SE_PL_WALK_LADDER, 0x814 }, + { NA_SE_PL_WALK_LADDER, -0x81E }, +}; + +void func_8084C5F8(Player* pthis, GlobalContext* globalCtx) { + s32 temp; + f32* sp38; + CollisionPoly* sp34; + s32 sp30; + Vec3f sp24; + + pthis->stateFlags2 |= 0x40; + + temp = func_808374A0(globalCtx, pthis, &pthis->skelAnime, 4.0f); + + if (temp == 0) { + pthis->stateFlags1 &= ~0x200000; + return; + } + + if ((temp > 0) || LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083C0E8(pthis, globalCtx); + pthis->stateFlags1 &= ~0x200000; + return; + } + + sp38 = D_80854898; + + if (pthis->unk_850 != 0) { + func_80832924(pthis, D_808548A8); + sp38 = D_808548A0; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, sp38[0]) || LinkAnimation_OnFrame(&pthis->skelAnime, sp38[1])) { + sp24.x = pthis->actor.world.pos.x; + sp24.y = pthis->actor.world.pos.y + 20.0f; + sp24.z = pthis->actor.world.pos.z; + if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp34, &sp30, &sp24) != 0.0f) { + pthis->unk_89E = func_80041F10(&globalCtx->colCtx, sp34, sp30); + func_808328A0(pthis); + } + } +} + +static struct_80832924 D_808548B4[] = { + { 0, 0x3028 }, { 0, 0x3030 }, { 0, 0x3038 }, { 0, 0x3040 }, { 0, 0x3048 }, + { 0, 0x3050 }, { 0, 0x3058 }, { 0, 0x3060 }, { 0, -0x3068 }, +}; + +void func_8084C760(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x40; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (!(pthis->stateFlags1 & 1)) { + if (pthis->skelAnime.moveFlags != 0) { + pthis->skelAnime.moveFlags = 0; + return; + } + + if (!func_8083F570(pthis, globalCtx)) { + pthis->linearVelocity = sControlInput->rel.stick_y * 0.03f; + } + } + return; + } + + func_80832924(pthis, D_808548B4); +} + +static struct_80832924 D_808548D8[] = { + { 0, 0x300A }, { 0, 0x3012 }, { 0, 0x301A }, { 0, 0x3022 }, { 0, 0x3034 }, + { 0, 0x303C }, { 0, 0x3044 }, { 0, 0x304C }, { 0, -0x3054 }, +}; + +void func_8084C81C(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x40; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083C0E8(pthis, globalCtx); + pthis->stateFlags2 &= ~0x40000; + return; + } + + func_80832924(pthis, D_808548D8); +} + +static Vec3f D_808548FC[] = { + { 40.0f, 0.0f, 0.0f }, + { -40.0f, 0.0f, 0.0f }, +}; + +static Vec3f D_80854914[] = { + { 60.0f, 20.0f, 0.0f }, + { -60.0f, 20.0f, 0.0f }, +}; + +static Vec3f D_8085492C[] = { + { 60.0f, -20.0f, 0.0f }, + { -60.0f, -20.0f, 0.0f }, +}; + +s32 func_8084C89C(GlobalContext* globalCtx, Player* pthis, s32 arg2, f32* arg3) { + EnHorse* rideActor = (EnHorse*)pthis->rideActor; + f32 sp50; + f32 sp4C; + Vec3f sp40; + Vec3f sp34; + CollisionPoly* sp30; + s32 sp2C; + + sp50 = rideActor->actor.world.pos.y + 20.0f; + sp4C = rideActor->actor.world.pos.y - 20.0f; + + *arg3 = func_8083973C(globalCtx, pthis, &D_808548FC[arg2], &sp40); + + return (sp4C < *arg3) && (*arg3 < sp50) && + !func_80839768(globalCtx, pthis, &D_80854914[arg2], &sp30, &sp2C, &sp34) && + !func_80839768(globalCtx, pthis, &D_8085492C[arg2], &sp30, &sp2C, &sp34); +} + +s32 func_8084C9BC(Player* pthis, GlobalContext* globalCtx) { + EnHorse* rideActor = (EnHorse*)pthis->rideActor; + s32 sp38; + f32 sp34; + + if (pthis->unk_850 < 0) { + pthis->unk_850 = 99; + } else { + sp38 = (pthis->mountSide < 0) ? 0 : 1; + if (!func_8084C89C(globalCtx, pthis, sp38, &sp34)) { + sp38 ^= 1; + if (!func_8084C89C(globalCtx, pthis, sp38, &sp34)) { + return 0; + } else { + pthis->mountSide = -pthis->mountSide; + } + } + + if ((globalCtx->csCtx.state == CS_STATE_IDLE) && (globalCtx->transitionMode == 0) && + (EN_HORSE_CHECK_1(rideActor) || EN_HORSE_CHECK_4(rideActor))) { + pthis->stateFlags2 |= 0x400000; + + if (EN_HORSE_CHECK_1(rideActor) || + (EN_HORSE_CHECK_4(rideActor) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A))) { + rideActor->actor.child = NULL; + func_80835DAC(globalCtx, pthis, func_8084D3E4, 0); + pthis->unk_878 = sp34 - rideActor->actor.world.pos.y; + func_80832264(globalCtx, pthis, (pthis->mountSide < 0) ? &gPlayerAnim_003390 : &gPlayerAnim_0033A0); + return 1; + } + } + } + + return 0; +} + +void func_8084CBF4(Player* pthis, f32 arg1, f32 arg2) { + f32 temp; + f32 dir; + + if ((pthis->unk_878 != 0.0f) && (arg2 <= pthis->skelAnime.curFrame)) { + if (arg1 < fabsf(pthis->unk_878)) { + if (pthis->unk_878 >= 0.0f) { + dir = 1; + } else { + dir = -1; + } + temp = dir * arg1; + } else { + temp = pthis->unk_878; + } + pthis->actor.world.pos.y += temp; + pthis->unk_878 -= temp; + } +} + +static LinkAnimationHeader* D_80854944[] = { + &gPlayerAnim_003370, + &gPlayerAnim_003368, + &gPlayerAnim_003380, + &gPlayerAnim_003358, + &gPlayerAnim_003338, + &gPlayerAnim_003348, + &gPlayerAnim_003350, + NULL, + NULL, +}; + +static LinkAnimationHeader* D_80854968[] = { + &gPlayerAnim_003388, + &gPlayerAnim_003388, + &gPlayerAnim_003388, + &gPlayerAnim_003360, + &gPlayerAnim_003340, + &gPlayerAnim_003340, + &gPlayerAnim_003340, + NULL, + NULL, +}; + +static LinkAnimationHeader* D_8085498C[] = { + &gPlayerAnim_0033C8, + &gPlayerAnim_0033B8, + &gPlayerAnim_0033C0, +}; + +static u8 D_80854998[2][2] = { + { 32, 58 }, + { 25, 42 }, +}; + +static Vec3s D_8085499C = { -69, 7146, -266 }; + +static struct_80832924 D_808549A4[] = { + { NA_SE_PL_CALM_HIT, 0x830 }, { NA_SE_PL_CALM_HIT, 0x83A }, { NA_SE_PL_CALM_HIT, 0x844 }, + { NA_SE_PL_CALM_PAT, 0x85C }, { NA_SE_PL_CALM_PAT, 0x86E }, { NA_SE_PL_CALM_PAT, 0x87E }, + { NA_SE_PL_CALM_PAT, 0x884 }, { NA_SE_PL_CALM_PAT, -0x888 }, +}; + +void func_8084CC98(Player* pthis, GlobalContext* globalCtx) { + EnHorse* rideActor = (EnHorse*)pthis->rideActor; + u8* arr; + + pthis->stateFlags2 |= 0x40; + + func_8084CBF4(pthis, 1.0f, 10.0f); + + if (pthis->unk_850 == 0) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + pthis->skelAnime.animation = &gPlayerAnim_0033B8; + pthis->unk_850 = 99; + return; + } + + arr = D_80854998[(pthis->mountSide < 0) ? 0 : 1]; + + if (LinkAnimation_OnFrame(&pthis->skelAnime, arr[0])) { + func_8002F7DC(&pthis->actor, NA_SE_PL_CLIMB_CLIFF); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, arr[1])) { + func_8002DE74(globalCtx, pthis); + func_8002F7DC(&pthis->actor, NA_SE_PL_SIT_ON_HORSE); + return; + } + + return; + } + + func_8002DE74(globalCtx, pthis); + pthis->skelAnime.prevTransl = D_8085499C; + + if ((rideActor->animationIdx != pthis->unk_850) && ((rideActor->animationIdx >= 2) || (pthis->unk_850 >= 2))) { + if ((pthis->unk_850 = rideActor->animationIdx) < 2) { + f32 rand = Rand_ZeroOne(); + s32 temp = 0; + + pthis->unk_850 = 1; + + if (rand < 0.1f) { + temp = 2; + } else if (rand < 0.2f) { + temp = 1; + } + func_80832264(globalCtx, pthis, D_8085498C[temp]); + } else { + pthis->skelAnime.animation = D_80854944[pthis->unk_850 - 2]; + Animation_SetMorph(globalCtx, &pthis->skelAnime, 8.0f); + if (pthis->unk_850 < 4) { + func_80834644(globalCtx, pthis); + pthis->unk_84F = 0; + } + } + } + + if (pthis->unk_850 == 1) { + if ((D_808535E0 != 0) || func_8083224C(globalCtx)) { + func_80832264(globalCtx, pthis, &gPlayerAnim_0033C8); + } else if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + pthis->unk_850 = 99; + } else if (pthis->skelAnime.animation == &gPlayerAnim_0033B8) { + func_80832924(pthis, D_808549A4); + } + } else { + pthis->skelAnime.curFrame = rideActor->curFrame; + LinkAnimation_AnimateFrame(globalCtx, &pthis->skelAnime); + } + + AnimationContext_SetCopyAll(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.morphTable, + pthis->skelAnime.jointTable); + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) || (pthis->csMode != 0)) { + if (pthis->csMode == 7) { + pthis->csMode = 0; + } + pthis->unk_6AD = 0; + pthis->unk_84F = 0; + } else if ((pthis->unk_850 < 2) || (pthis->unk_850 >= 4)) { + D_808535E0 = func_80836670(pthis, globalCtx); + if (D_808535E0 != 0) { + pthis->unk_84F = 0; + } + } + + pthis->actor.world.pos.x = rideActor->actor.world.pos.x + rideActor->riderPos.x; + pthis->actor.world.pos.y = (rideActor->actor.world.pos.y + rideActor->riderPos.y) - 27.0f; + pthis->actor.world.pos.z = rideActor->actor.world.pos.z + rideActor->riderPos.z; + + pthis->currentYaw = pthis->actor.shape.rot.y = rideActor->actor.shape.rot.y; + + if ((pthis->csMode != 0) || + (!func_8083224C(globalCtx) && ((rideActor->actor.speedXZ != 0.0f) || !func_8083B644(pthis, globalCtx)) && + !func_8083C1DC(pthis, globalCtx))) { + if (D_808535E0 == 0) { + if (pthis->unk_84F != 0) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime2)) { + rideActor->stateFlags &= ~ENHORSE_FLAG_8; + pthis->unk_84F = 0; + } + + if (pthis->skelAnime2.animation == &gPlayerAnim_0033B0) { + if (LinkAnimation_OnFrame(&pthis->skelAnime2, 23.0f)) { + func_8002F7DC(&pthis->actor, NA_SE_IT_LASH); + func_80832698(pthis, NA_SE_VO_LI_LASH); + } + + AnimationContext_SetCopyAll(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->skelAnime2.jointTable); + } else { + if (LinkAnimation_OnFrame(&pthis->skelAnime2, 10.0f)) { + func_8002F7DC(&pthis->actor, NA_SE_IT_LASH); + func_80832698(pthis, NA_SE_VO_LI_LASH); + } + + AnimationContext_SetCopyTrue(globalCtx, pthis->skelAnime.limbCount, pthis->skelAnime.jointTable, + pthis->skelAnime2.jointTable, D_80853410); + } + } else { + LinkAnimationHeader* anim = NULL; + + if (EN_HORSE_CHECK_3(rideActor)) { + anim = &gPlayerAnim_0033B0; + } else if (EN_HORSE_CHECK_2(rideActor)) { + if ((pthis->unk_850 >= 2) && (pthis->unk_850 != 99)) { + anim = D_80854968[pthis->unk_850 - 2]; + } + } + + if (anim != NULL) { + LinkAnimation_PlayOnce(globalCtx, &pthis->skelAnime2, anim); + pthis->unk_84F = 1; + } + } + } + + if (pthis->stateFlags1 & 0x100000) { + if (!func_8083AD4C(globalCtx, pthis) || CHECK_BTN_ANY(sControlInput->press.button, BTN_A) || + func_80833BCC(pthis)) { + pthis->unk_6AD = 0; + pthis->stateFlags1 &= ~0x100000; + } else { + pthis->unk_6BE = func_8084ABD8(globalCtx, pthis, 1, -5000) - pthis->actor.shape.rot.y; + pthis->unk_6BE += 5000; + pthis->unk_6B0 = -5000; + } + return; + } + + if ((pthis->csMode != 0) || (!func_8084C9BC(pthis, globalCtx) && !func_8083B040(pthis, globalCtx))) { + if (pthis->unk_664 != NULL) { + if (func_8002DD78(pthis) != 0) { + pthis->unk_6BE = func_8083DB98(pthis, 1) - pthis->actor.shape.rot.y; + pthis->unk_6BE = CLAMP(pthis->unk_6BE, -0x4AAA, 0x4AAA); + pthis->actor.focus.rot.y = pthis->actor.shape.rot.y + pthis->unk_6BE; + pthis->unk_6BE += 5000; + pthis->unk_6AE |= 0x80; + } else { + func_8083DB98(pthis, 0); + } + } else { + if (func_8002DD78(pthis) != 0) { + pthis->unk_6BE = func_8084ABD8(globalCtx, pthis, 1, -5000) - pthis->actor.shape.rot.y; + pthis->unk_6BE += 5000; + pthis->unk_6B0 = -5000; + } + } + } + } +} + +static struct_80832924 D_808549C4[] = { + { 0, 0x2800 }, + { NA_SE_PL_GET_OFF_HORSE, 0x80A }, + { NA_SE_PL_SLIPDOWN, -0x819 }, +}; + +void func_8084D3E4(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x40; + func_8084CBF4(pthis, 1.0f, 10.0f); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + EnHorse* rideActor = (EnHorse*)pthis->rideActor; + + func_8083C0E8(pthis, globalCtx); + pthis->stateFlags1 &= ~0x800000; + pthis->actor.parent = NULL; + AREG(6) = 0; + + if (Flags_GetEventChkInf(0x18) || (DREG(1) != 0)) { + gSaveContext.horseData.pos.x = rideActor->actor.world.pos.x; + gSaveContext.horseData.pos.y = rideActor->actor.world.pos.y; + gSaveContext.horseData.pos.z = rideActor->actor.world.pos.z; + gSaveContext.horseData.angle = rideActor->actor.shape.rot.y; + } + } else { + Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_NORMAL0); + + if (pthis->mountSide < 0) { + D_808549C4[0].field = 0x2828; + } else { + D_808549C4[0].field = 0x281D; + } + func_80832924(pthis, D_808549C4); + } +} + +static struct_80832924 D_808549D0[] = { + { NA_SE_PL_SWIM, -0x800 }, +}; + +void func_8084D530(Player* pthis, f32* arg1, f32 arg2, s16 arg3) { + func_8084AEEC(pthis, arg1, arg2, arg3); + func_80832924(pthis, D_808549D0); +} + +void func_8084D574(GlobalContext* globalCtx, Player* pthis, s16 arg2) { + func_80835C58(globalCtx, pthis, func_8084D84C, 0); + pthis->actor.shape.rot.y = pthis->currentYaw = arg2; + func_80832C6C(globalCtx, pthis, &gPlayerAnim_0032F0); +} + +void func_8084D5CC(GlobalContext* globalCtx, Player* pthis) { + func_80835C58(globalCtx, pthis, func_8084DAB4, 0); + func_80832C6C(globalCtx, pthis, &gPlayerAnim_0032F0); +} + +void func_8084D610(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + + func_80832CB0(globalCtx, pthis, &gPlayerAnim_003328); + func_8084B000(pthis); + + if (!func_8083224C(globalCtx) && !func_80837348(globalCtx, pthis, D_80854444, 1) && + !func_8083D12C(globalCtx, pthis, sControlInput)) { + if (pthis->unk_6AD != 1) { + pthis->unk_6AD = 0; + } + + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + sp34 = 0.0f; + sp32 = pthis->actor.shape.rot.y; + + if (pthis->actor.bgCheckFlags & 1) { + func_8083A098(pthis, D_80853A7C[pthis->modelAnimType], globalCtx); + func_808328A0(pthis); + } + } else { + func_80837268(pthis, &sp34, &sp32, 0.0f, globalCtx); + + if (sp34 != 0.0f) { + s16 temp = pthis->actor.shape.rot.y - sp32; + + if ((ABS(temp) > 0x6000) && !Math_StepToF(&pthis->linearVelocity, 0.0f, 1.0f)) { + return; + } + + if (func_80833C04(pthis)) { + func_8084D5CC(globalCtx, pthis); + } else { + func_8084D574(globalCtx, pthis, sp32); + } + } + } + + func_8084AEEC(pthis, &pthis->linearVelocity, sp34, sp32); + } +} + +void func_8084D7C4(Player* pthis, GlobalContext* globalCtx) { + if (!func_8083B040(pthis, globalCtx)) { + pthis->stateFlags2 |= 0x20; + + func_8084B158(globalCtx, pthis, NULL, pthis->linearVelocity); + func_8084B000(pthis); + + if (DECR(pthis->unk_850) == 0) { + func_80838F18(globalCtx, pthis); + } + } +} + +void func_8084D84C(Player* pthis, GlobalContext* globalCtx) { + f32 sp34; + s16 sp32; + s16 temp; + + pthis->stateFlags2 |= 0x20; + + func_8084B158(globalCtx, pthis, sControlInput, pthis->linearVelocity); + func_8084B000(pthis); + + if (!func_80837348(globalCtx, pthis, D_80854444, 1) && !func_8083D12C(globalCtx, pthis, sControlInput)) { + func_80837268(pthis, &sp34, &sp32, 0.0f, globalCtx); + + temp = pthis->actor.shape.rot.y - sp32; + if ((sp34 == 0.0f) || (ABS(temp) > 0x6000) || (pthis->currentBoots == PLAYER_BOOTS_IRON)) { + func_80838F18(globalCtx, pthis); + } else if (func_80833C04(pthis)) { + func_8084D5CC(globalCtx, pthis); + } + + func_8084D530(pthis, &pthis->linearVelocity, sp34, sp32); + } +} + +s32 func_8084D980(GlobalContext* globalCtx, Player* pthis, f32* arg2, s16* arg3) { + LinkAnimationHeader* anim; + s16 temp1; + s32 temp2; + + temp1 = pthis->currentYaw - *arg3; + + if (ABS(temp1) > 0x6000) { + anim = &gPlayerAnim_003328; + + if (Math_StepToF(&pthis->linearVelocity, 0.0f, 1.0f)) { + pthis->currentYaw = *arg3; + } else { + *arg2 = 0.0f; + *arg3 = pthis->currentYaw; + } + } else { + temp2 = func_8083FD78(pthis, arg2, arg3, globalCtx); + + if (temp2 > 0) { + anim = &gPlayerAnim_0032F0; + } else if (temp2 < 0) { + anim = &gPlayerAnim_0032D8; + } else if ((temp1 = pthis->actor.shape.rot.y - *arg3) > 0) { + anim = &gPlayerAnim_0032D0; + } else { + anim = &gPlayerAnim_0032C8; + } + } + + if (anim != pthis->skelAnime.animation) { + func_80832C6C(globalCtx, pthis, anim); + return 1; + } + + return 0; +} + +void func_8084DAB4(Player* pthis, GlobalContext* globalCtx) { + f32 sp2C; + s16 sp2A; + + func_8084B158(globalCtx, pthis, sControlInput, pthis->linearVelocity); + func_8084B000(pthis); + + if (!func_80837348(globalCtx, pthis, D_80854444, 1) && !func_8083D12C(globalCtx, pthis, sControlInput)) { + func_80837268(pthis, &sp2C, &sp2A, 0.0f, globalCtx); + + if (sp2C == 0.0f) { + func_80838F18(globalCtx, pthis); + } else if (!func_80833C04(pthis)) { + func_8084D574(globalCtx, pthis, sp2A); + } else { + func_8084D980(globalCtx, pthis, &sp2C, &sp2A); + } + + func_8084D530(pthis, &pthis->linearVelocity, sp2C, sp2A); + } +} + +void func_8084DBC4(GlobalContext* globalCtx, Player* pthis, f32 arg2) { + f32 sp2C; + s16 sp2A; + + func_80837268(pthis, &sp2C, &sp2A, 0.0f, globalCtx); + func_8084AEEC(pthis, &pthis->linearVelocity, sp2C * 0.5f, sp2A); + func_8084AEEC(pthis, &pthis->actor.velocity.y, arg2, pthis->currentYaw); +} + +void func_8084DC48(Player* pthis, GlobalContext* globalCtx) { + f32 sp2C; + + pthis->stateFlags2 |= 0x20; + pthis->actor.gravity = 0.0f; + func_80836670(pthis, globalCtx); + + if (!func_8083B040(pthis, globalCtx)) { + if (pthis->currentBoots == PLAYER_BOOTS_IRON) { + func_80838F18(globalCtx, pthis); + return; + } + + if (pthis->unk_84F == 0) { + if (pthis->unk_850 == 0) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) || + ((pthis->skelAnime.curFrame >= 22.0f) && !CHECK_BTN_ALL(sControlInput->cur.button, BTN_A))) { + func_8083D330(globalCtx, pthis); + } else if (LinkAnimation_OnFrame(&pthis->skelAnime, 20.0f) != 0) { + pthis->actor.velocity.y = -2.0f; + } + + func_8083721C(pthis); + return; + } + + func_8084B158(globalCtx, pthis, sControlInput, pthis->actor.velocity.y); + pthis->unk_6C2 = 16000; + + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) && !func_8083E5A8(pthis, globalCtx) && + !(pthis->actor.bgCheckFlags & 1) && (pthis->actor.yDistToWater < D_80854784[CUR_UPG_VALUE(UPG_SCALE)])) { + func_8084DBC4(globalCtx, pthis, -2.0f); + } else { + pthis->unk_84F++; + func_80832C6C(globalCtx, pthis, &gPlayerAnim_003328); + } + } else if (pthis->unk_84F == 1) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_8084B000(pthis); + + if (pthis->unk_6C2 < 10000) { + pthis->unk_84F++; + pthis->unk_850 = pthis->actor.yDistToWater; + func_80832C6C(globalCtx, pthis, &gPlayerAnim_0032F0); + } + } else if (!func_8083D12C(globalCtx, pthis, sControlInput)) { + sp2C = (pthis->unk_850 * 0.018f) + 4.0f; + + if (pthis->stateFlags1 & 0x800) { + sControlInput = NULL; + } + + func_8084B158(globalCtx, pthis, sControlInput, fabsf(pthis->actor.velocity.y)); + Math_ScaledStepToS(&pthis->unk_6C2, -10000, 800); + + if (sp2C > 8.0f) { + sp2C = 8.0f; + } + + func_8084DBC4(globalCtx, pthis, sp2C); + } + } +} + +void func_8084DF6C(GlobalContext* globalCtx, Player* pthis) { + pthis->unk_862 = 0; + pthis->stateFlags1 &= ~0xC00; + pthis->getItemId = GI_NONE; + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); +} + +void func_8084DFAC(GlobalContext* globalCtx, Player* pthis) { + func_8084DF6C(globalCtx, pthis); + func_808322FC(pthis); + func_8083C0E8(pthis, globalCtx); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +s32 func_8084DFF4(GlobalContext* globalCtx, Player* pthis) { + GetItemEntry* giEntry; + s32 temp1; + s32 temp2; + + if (pthis->getItemId == GI_NONE) { + return 1; + } + + if (pthis->unk_84F == 0) { + giEntry = &sGetItemTable[pthis->getItemId - 1]; + pthis->unk_84F = 1; + + Message_StartTextbox(globalCtx, giEntry->textId, &pthis->actor); + Item_Give(globalCtx, giEntry->itemId); + + if (((pthis->getItemId >= GI_RUPEE_GREEN) && (pthis->getItemId <= GI_RUPEE_RED)) || + ((pthis->getItemId >= GI_RUPEE_PURPLE) && (pthis->getItemId <= GI_RUPEE_GOLD)) || + ((pthis->getItemId >= GI_RUPEE_GREEN_LOSE) && (pthis->getItemId <= GI_RUPEE_PURPLE_LOSE)) || + (pthis->getItemId == GI_HEART)) { + Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + if ((pthis->getItemId == GI_HEART_CONTAINER_2) || (pthis->getItemId == GI_HEART_CONTAINER) || + ((pthis->getItemId == GI_HEART_PIECE) && + ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { + temp1 = NA_BGM_HEART_GET | 0x900; + } else { + temp1 = temp2 = (pthis->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; + } + Audio_PlayFanfare(temp1); + } + } else { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + if (pthis->getItemId == GI_GAUNTLETS_SILVER) { + globalCtx->nextEntranceIndex = 0x0123; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.nextCutsceneIndex = 0xFFF1; + globalCtx->fadeTransition = 0xF; + pthis->stateFlags1 &= ~0x20000000; + func_80852FFC(globalCtx, NULL, 8); + } + pthis->getItemId = GI_NONE; + } + } + + return 0; +} + +void func_8084E1EC(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x20; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (!(pthis->stateFlags1 & 0x400) || func_8084DFF4(globalCtx, pthis)) { + func_8084DF6C(globalCtx, pthis); + func_80838F18(globalCtx, pthis); + func_80832340(globalCtx, pthis); + } + } else { + if ((pthis->stateFlags1 & 0x400) && LinkAnimation_OnFrame(&pthis->skelAnime, 10.0f)) { + func_808332F4(pthis, globalCtx); + func_80832340(globalCtx, pthis); + func_80835EA4(globalCtx, 8); + } else if (LinkAnimation_OnFrame(&pthis->skelAnime, 5.0f)) { + func_80832698(pthis, NA_SE_VO_LI_BREATH_DRINK); + } + } + + func_8084B000(pthis); + func_8084AEEC(pthis, &pthis->linearVelocity, 0.0f, pthis->actor.shape.rot.y); +} + +void func_8084E30C(Player* pthis, GlobalContext* globalCtx) { + func_8084B000(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80838F18(globalCtx, pthis); + } + + func_8084AEEC(pthis, &pthis->linearVelocity, 0.0f, pthis->actor.shape.rot.y); +} + +void func_8084E368(Player* pthis, GlobalContext* globalCtx) { + func_8084B000(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80843AE8(globalCtx, pthis); + } + + func_8084AEEC(pthis, &pthis->linearVelocity, 0.0f, pthis->actor.shape.rot.y); +} + +static s16 D_808549D4[] = { 0x0600, 0x04F6, 0x0604, 0x01F1, 0x0568, 0x05F4 }; + +void func_8084E3C4(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_808322A4(globalCtx, pthis, &gPlayerAnim_0030A8); + pthis->unk_850 = 1; + if (pthis->stateFlags2 & 0x2800000) { + pthis->stateFlags2 |= 0x1000000; + } else { + func_8010BD58(globalCtx, OCARINA_ACTION_FREE_PLAY); + } + return; + } + + if (pthis->unk_850 == 0) { + return; + } + + if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) { + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + + if ((pthis->targetActor != NULL) && (pthis->targetActor == pthis->unk_6A8)) { + func_80853148(globalCtx, pthis->targetActor); + } else if (pthis->naviTextId < 0) { + pthis->targetActor = pthis->naviActor; + pthis->naviActor->textId = -pthis->naviTextId; + func_80853148(globalCtx, pthis->targetActor); + } else if (!func_8083B040(pthis, globalCtx)) { + func_8083A098(pthis, &gPlayerAnim_003098, globalCtx); + } + + pthis->stateFlags2 &= ~0x3800000; + pthis->unk_6A8 = NULL; + } else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_02) { + gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex = D_808549D4[globalCtx->msgCtx.lastPlayedSong]; + gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams = 0x5FF; + gSaveContext.respawn[RESPAWN_MODE_RETURN].data = globalCtx->msgCtx.lastPlayedSong; + + pthis->csMode = 0; + pthis->stateFlags1 &= ~0x20000000; + + func_80852FFC(globalCtx, NULL, 8); + globalCtx->mainCamera.unk_14C &= ~8; + + pthis->stateFlags1 |= 0x30000000; + pthis->stateFlags2 |= 0x8000000; + + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF) == NULL) { + Environment_WarpSongLeave(globalCtx); + } + + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.natureAmbienceId = 0xFF; + } +} + +void func_8084E604(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083A098(pthis, &gPlayerAnim_003050, globalCtx); + } else if (LinkAnimation_OnFrame(&pthis->skelAnime, 3.0f)) { + Inventory_ChangeAmmo(ITEM_NUT, -1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ARROW, pthis->bodyPartsPos[15].x, pthis->bodyPartsPos[15].y, + pthis->bodyPartsPos[15].z, 4000, pthis->actor.shape.rot.y, 0, 10); + func_80832698(pthis, NA_SE_VO_LI_SWORD_N); + } + + func_8083721C(pthis); +} + +static struct_80832924 D_808549E0[] = { + { 0, 0x3857 }, + { NA_SE_VO_LI_CLIMB_END, 0x2057 }, + { NA_SE_VO_LI_AUTO_JUMP, 0x2045 }, + { 0, -0x287B }, +}; + +void func_8084E6D4(Player* pthis, GlobalContext* globalCtx) { + s32 cond; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_850 != 0) { + if (pthis->unk_850 >= 2) { + pthis->unk_850--; + } + + if (func_8084DFF4(globalCtx, pthis) && (pthis->unk_850 == 1)) { + cond = ((pthis->targetActor != NULL) && (pthis->exchangeItemId < 0)) || (pthis->stateFlags3 & 0x20); + + if (cond || (gSaveContext.healthAccumulator == 0)) { + if (cond) { + func_8084DF6C(globalCtx, pthis); + pthis->exchangeItemId = EXCH_ITEM_NONE; + + if (func_8084B4D4(globalCtx, pthis) == 0) { + func_80853148(globalCtx, pthis->targetActor); + } + } else { + func_8084DFAC(globalCtx, pthis); + } + } + } + } else { + func_80832DBC(pthis); + + if (pthis->getItemId == GI_ICE_TRAP) { + pthis->stateFlags1 &= ~0xC00; + + if (pthis->getItemId != GI_ICE_TRAP) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, pthis->actor.world.pos.x, + pthis->actor.world.pos.y + 100.0f, pthis->actor.world.pos.z, 0, 0, 0, 0); + func_8083C0E8(pthis, globalCtx); + } else { + pthis->actor.colChkInfo.damage = 0; + func_80837C0C(globalCtx, pthis, 3, 0.0f, 0.0f, 0, 20); + } + return; + } + + if (pthis->skelAnime.animation == &gPlayerAnim_002DF8) { + func_808322D0(globalCtx, pthis, &gPlayerAnim_002788); + } else { + func_808322D0(globalCtx, pthis, &gPlayerAnim_002780); + } + + pthis->unk_850 = 2; + func_80835EA4(globalCtx, 9); + } + } else { + if (pthis->unk_850 == 0) { + if (!LINK_IS_ADULT) { + func_80832924(pthis, D_808549E0); + } + return; + } + + if (pthis->skelAnime.animation == &gPlayerAnim_002788) { + Math_ScaledStepToS(&pthis->actor.shape.rot.y, Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000, 4000); + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 21.0f)) { + func_808332F4(pthis, globalCtx); + } + } +} + +static struct_80832924 D_808549F0[] = { + { NA_SE_IT_MASTER_SWORD_SWING, -0x83C }, +}; + +void func_8084E988(Player* pthis) { + func_80832924(pthis, D_808549F0); +} + +static struct_80832924 D_808549F4[] = { + { NA_SE_VO_LI_AUTO_JUMP, 0x2005 }, + { 0, -0x280F }, +}; + +void func_8084E9AC(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_84F == 0) { + if (DECR(pthis->unk_850) == 0) { + pthis->unk_84F = 1; + pthis->skelAnime.endFrame = pthis->skelAnime.animLength - 1.0f; + } + } else { + func_8083C0E8(pthis, globalCtx); + } + } else { + if (LINK_IS_ADULT && LinkAnimation_OnFrame(&pthis->skelAnime, 158.0f)) { + func_80832698(pthis, NA_SE_VO_LI_SWORD_N); + return; + } + + if (!LINK_IS_ADULT) { + func_80832924(pthis, D_808549F4); + } else { + func_8084E988(pthis); + } + } +} + +static u8 D_808549FC[] = { + 0x01, 0x03, 0x02, 0x04, 0x04, +}; + +void func_8084EAC0(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_850 == 0) { + if (pthis->itemActionParam == PLAYER_AP_BOTTLE_POE) { + s32 rand = Rand_S16Offset(-1, 3); + + if (rand == 0) { + rand = 3; + } + + if ((rand < 0) && (gSaveContext.health <= 0x10)) { + rand = 3; + } + + if (rand < 0) { + Health_ChangeBy(globalCtx, -0x10); + } else { + gSaveContext.healthAccumulator = rand * 0x10; + } + } else { + s32 sp28 = D_808549FC[pthis->itemActionParam - PLAYER_AP_BOTTLE_POTION_RED]; + + if (sp28 & 1) { + gSaveContext.healthAccumulator = 0x140; + } + + if (sp28 & 2) { + Magic_Fill(globalCtx); + } + + if (sp28 & 4) { + gSaveContext.healthAccumulator = 0x50; + } + } + + func_808322A4(globalCtx, pthis, &gPlayerAnim_002670); + pthis->unk_850 = 1; + return; + } + + func_8083C0E8(pthis, globalCtx); + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + } else if (pthis->unk_850 == 1) { + if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.unk_13F0 != 9)) { + func_80832B78(globalCtx, pthis, &gPlayerAnim_002660); + pthis->unk_850 = 2; + Player_UpdateBottleHeld(globalCtx, pthis, ITEM_BOTTLE, PLAYER_AP_BOTTLE); + } + func_80832698(pthis, NA_SE_VO_LI_DRINK - SFX_FLAG); + } else if ((pthis->unk_850 == 2) && LinkAnimation_OnFrame(&pthis->skelAnime, 29.0f)) { + func_80832698(pthis, NA_SE_VO_LI_BREATH_DRINK); + } +} + +static BottleCatchInfo D_80854A04[] = { + { ACTOR_EN_ELF, ITEM_FAIRY, 0x2A, 0x46 }, + { ACTOR_EN_FISH, ITEM_FISH, 0x1F, 0x47 }, + { ACTOR_EN_ICE_HONO, ITEM_BLUE_FIRE, 0x20, 0x5D }, + { ACTOR_EN_INSECT, ITEM_BUG, 0x21, 0x7A }, +}; + +void func_8084ECA4(Player* pthis, GlobalContext* globalCtx) { + struct_80854554* sp24; + BottleCatchInfo* catchInfo; + s32 temp; + s32 i; + + sp24 = &D_80854554[pthis->unk_850]; + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_84F != 0) { + if (pthis->unk_850 == 0) { + Message_StartTextbox(globalCtx, D_80854A04[pthis->unk_84F - 1].textId, &pthis->actor); + Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); + pthis->unk_850 = 1; + } else if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->unk_84F = 0; + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + } + } else { + func_8083C0E8(pthis, globalCtx); + } + } else { + if (pthis->unk_84F == 0) { + temp = pthis->skelAnime.curFrame - sp24->unk_08; + + if (temp >= 0) { + if (sp24->unk_09 >= temp) { + if (pthis->unk_850 != 0) { + if (temp == 0) { + func_8002F7DC(&pthis->actor, NA_SE_IT_SCOOP_UP_WATER); + } + } + + if (pthis->interactRangeActor != NULL) { + catchInfo = &D_80854A04[0]; + for (i = 0; i < 4; i++, catchInfo++) { + if (pthis->interactRangeActor->id == catchInfo->actorId) { + break; + } + } + + if (i < 4) { + pthis->unk_84F = i + 1; + pthis->unk_850 = 0; + pthis->stateFlags1 |= 0x30000000; + pthis->interactRangeActor->parent = &pthis->actor; + Player_UpdateBottleHeld(globalCtx, pthis, catchInfo->itemId, ABS(catchInfo->actionParam)); + func_808322D0(globalCtx, pthis, sp24->unk_04); + func_80835EA4(globalCtx, 4); + } + } + } + } + } + } + + if (pthis->skelAnime.curFrame <= 7.0f) { + pthis->stateFlags1 |= 2; + } +} + +static Vec3f D_80854A1C = { 0.0f, 0.0f, 5.0f }; + +void func_8084EED8(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083C0E8(pthis, globalCtx); + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 37.0f)) { + Player_SpawnFairy(globalCtx, pthis, &pthis->leftHandPos, &D_80854A1C, FAIRY_REVIVE_BOTTLE); + Player_UpdateBottleHeld(globalCtx, pthis, ITEM_BOTTLE, PLAYER_AP_BOTTLE); + func_8002F7DC(&pthis->actor, NA_SE_EV_BOTTLE_CAP_OPEN); + func_8002F7DC(&pthis->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + } else if (LinkAnimation_OnFrame(&pthis->skelAnime, 47.0f)) { + gSaveContext.healthAccumulator = 0x140; + } +} + +static BottleDropInfo D_80854A28[] = { + { ACTOR_EN_FISH, FISH_DROPPED }, + { ACTOR_EN_ICE_HONO, 0 }, + { ACTOR_EN_INSECT, 2 }, +}; + +static struct_80832924 D_80854A34[] = { + { NA_SE_VO_LI_AUTO_JUMP, 0x2026 }, + { NA_SE_EV_BOTTLE_CAP_OPEN, -0x828 }, +}; + +void func_8084EFC0(Player* pthis, GlobalContext* globalCtx) { + func_8083721C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083C0E8(pthis, globalCtx); + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + return; + } + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 76.0f)) { + BottleDropInfo* dropInfo = &D_80854A28[pthis->itemActionParam - PLAYER_AP_BOTTLE_FISH]; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, dropInfo->actorId, + (Math_SinS(pthis->actor.shape.rot.y) * 5.0f) + pthis->leftHandPos.x, pthis->leftHandPos.y, + (Math_CosS(pthis->actor.shape.rot.y) * 5.0f) + pthis->leftHandPos.z, 0x4000, pthis->actor.shape.rot.y, + 0, dropInfo->actorParams); + + Player_UpdateBottleHeld(globalCtx, pthis, ITEM_BOTTLE, PLAYER_AP_BOTTLE); + return; + } + + func_80832924(pthis, D_80854A34); +} + +static struct_80832924 D_80854A3C[] = { + { NA_SE_PL_PUT_OUT_ITEM, -0x81E }, +}; + +void func_8084F104(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x20; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_850 < 0) { + func_8083C0E8(pthis, globalCtx); + } else if (pthis->exchangeItemId == EXCH_ITEM_NONE) { + Actor* targetActor = pthis->targetActor; + + pthis->unk_862 = 0; + if (targetActor->textId != 0xFFFF) { + pthis->actor.flags |= ACTOR_FLAG_8; + } + + func_80853148(globalCtx, targetActor); + } else { + GetItemEntry* giEntry = &sGetItemTable[D_80854528[pthis->exchangeItemId - 1] - 1]; + + if (pthis->itemActionParam >= PLAYER_AP_LETTER_ZELDA) { + if (giEntry->gi >= 0) { + pthis->unk_862 = giEntry->gi; + } else { + pthis->unk_862 = -giEntry->gi; + } + } + + if (pthis->unk_850 == 0) { + Message_StartTextbox(globalCtx, pthis->actor.textId, &pthis->actor); + + if ((pthis->itemActionParam == PLAYER_AP_CHICKEN) || (pthis->itemActionParam == PLAYER_AP_POCKET_CUCCO)) { + func_8002F7DC(&pthis->actor, NA_SE_EV_CHICKEN_CRY_M); + } + + pthis->unk_850 = 1; + } else if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + pthis->actor.flags &= ~ACTOR_FLAG_8; + pthis->unk_862 = 0; + + if (pthis->unk_84F == 1) { + func_80832264(globalCtx, pthis, &gPlayerAnim_002698); + pthis->unk_850 = -1; + } else { + func_8083C0E8(pthis, globalCtx); + } + + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + } + } + } else if (pthis->unk_850 >= 0) { + func_80832924(pthis, D_80854A3C); + } + + if ((pthis->unk_84F == 0) && (pthis->unk_664 != NULL)) { + pthis->currentYaw = pthis->actor.shape.rot.y = func_8083DB98(pthis, 0); + } +} + +void func_8084F308(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x60; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, &gPlayerAnim_003128); + } + + if (func_80832594(pthis, 0, 100)) { + func_80839F90(pthis, globalCtx); + pthis->stateFlags2 &= ~0x80; + } +} + +void func_8084F390(Player* pthis, GlobalContext* globalCtx) { + CollisionPoly* floorPoly; + f32 sp50; + f32 sp4C; + f32 sp48; + s16 sp46; + s16 sp44; + Vec3f sp38; + + pthis->stateFlags2 |= 0x60; + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_8084269C(globalCtx, pthis); + func_800F4138(&pthis->actor.projectedPos, NA_SE_PL_SLIP_LEVEL - SFX_FLAG, pthis->actor.speedXZ); + + if (func_8083B040(pthis, globalCtx) == 0) { + floorPoly = pthis->actor.floorPoly; + + if (floorPoly == NULL) { + func_80837B9C(pthis, globalCtx); + return; + } + + func_8083E298(floorPoly, &sp38, &sp46); + + sp44 = sp46; + if (pthis->unk_84F != 0) { + sp44 = sp46 + 0x8000; + } + + if (pthis->linearVelocity < 0) { + sp46 += 0x8000; + } + + sp50 = (1.0f - sp38.y) * 40.0f; + sp50 = CLAMP(sp50, 0, 10.0f); + sp4C = (sp50 * sp50) * 0.015f; + sp48 = sp38.y * 0.01f; + + if (SurfaceType_GetSlope(&globalCtx->colCtx, floorPoly, pthis->actor.floorBgId) != 1) { + sp50 = 0; + sp48 = sp38.y * 10.0f; + } + + if (sp4C < 1.0f) { + sp4C = 1.0f; + } + + if (Math_AsymStepToF(&pthis->linearVelocity, sp50, sp4C, sp48) && (sp50 == 0)) { + LinkAnimationHeader* anim; + if (pthis->unk_84F == 0) { + anim = D_80853D04[pthis->modelAnimType]; + } else { + anim = D_80853D1C[pthis->modelAnimType]; + } + func_8083A098(pthis, anim, globalCtx); + } + + Math_SmoothStepToS(&pthis->currentYaw, sp46, 10, 4000, 800); + Math_ScaledStepToS(&pthis->actor.shape.rot.y, sp44, 2000); + } +} + +void func_8084F608(Player* pthis, GlobalContext* globalCtx) { + if ((DECR(pthis->unk_850) == 0) && func_8083ADD4(globalCtx, pthis)) { + func_80852280(globalCtx, pthis, NULL); + func_80835C58(globalCtx, pthis, func_80852E14, 0); + func_80852E14(pthis, globalCtx); + } +} + +void func_8084F698(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_8084F608, 0); + pthis->unk_850 = 40; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0x10); +} + +void func_8084F710(Player* pthis, GlobalContext* globalCtx) { + s32 pad; + + if ((pthis->unk_84F != 0) && (globalCtx->csCtx.frames < 0x131)) { + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.y = 0.0f; + } else if (D_80853600 < 150.0f) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_850 == 0) { + if (pthis->actor.bgCheckFlags & 1) { + pthis->skelAnime.endFrame = pthis->skelAnime.animLength - 1.0f; + func_808328A0(pthis); + pthis->unk_850 = 1; + } + } else { + if ((globalCtx->sceneNum == SCENE_SPOT04) && func_8083ADD4(globalCtx, pthis)) { + return; + } + func_80853080(pthis, globalCtx); + } + } + Math_SmoothStepToF(&pthis->actor.velocity.y, 2.0f, 0.3f, 8.0f, 0.5f); + } + + if ((globalCtx->sceneNum == SCENE_KENJYANOMA) && func_8083ADD4(globalCtx, pthis)) { + return; + } + + if ((globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.linkAction != NULL)) { + f32 sp28 = pthis->actor.world.pos.y; + func_808529D0(globalCtx, pthis, globalCtx->csCtx.linkAction); + pthis->actor.world.pos.y = sp28; + } +} + +void func_8084F88C(Player* pthis, GlobalContext* globalCtx) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if ((pthis->unk_850++ > 8) && (globalCtx->sceneLoadFlag == 0)) { + + if (pthis->unk_84F != 0) { + if (globalCtx->sceneNum == 9) { + Gameplay_TriggerRespawn(globalCtx); + globalCtx->nextEntranceIndex = 0x0088; + } else if (pthis->unk_84F < 0) { + Gameplay_TriggerRespawn(globalCtx); + } else { + Gameplay_TriggerVoidOut(globalCtx); + } + + globalCtx->fadeTransition = 4; + func_80078884(NA_SE_OC_ABYSS); + } else { + globalCtx->fadeTransition = 2; + gSaveContext.nextTransition = 2; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.natureAmbienceId = 0xFF; + } + + globalCtx->sceneLoadFlag = 0x14; + } +} + +void func_8084F9A0(Player* pthis, GlobalContext* globalCtx) { + func_80839800(pthis, globalCtx); +} + +void func_8084F9C0(Player* pthis, GlobalContext* globalCtx) { + pthis->actor.gravity = -1.0f; + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (pthis->actor.velocity.y < 0.0f) { + func_80837B9C(pthis, globalCtx); + } else if (pthis->actor.velocity.y < 6.0f) { + Math_StepToF(&pthis->linearVelocity, 3.0f, 0.5f); + } +} + +void func_8084FA54(Player* pthis, GlobalContext* globalCtx) { + pthis->unk_6AD = 2; + + func_8083AD4C(globalCtx, pthis); + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_80836670(pthis, globalCtx); + + pthis->unk_6BE = func_8084ABD8(globalCtx, pthis, 1, 0) - pthis->actor.shape.rot.y; + pthis->unk_6AE |= 0x80; + + if (globalCtx->shootingGalleryStatus < 0) { + globalCtx->shootingGalleryStatus++; + if (globalCtx->shootingGalleryStatus == 0) { + func_8083C148(pthis, globalCtx); + } + } +} + +void func_8084FB10(Player* pthis, GlobalContext* globalCtx) { + if (pthis->unk_84F >= 0) { + if (pthis->unk_84F < 6) { + pthis->unk_84F++; + } + + if (func_80832594(pthis, 1, 100)) { + pthis->unk_84F = -1; + EffectSsIcePiece_SpawnBurst(globalCtx, &pthis->actor.world.pos, pthis->actor.scale.x); + func_8002F7DC(&pthis->actor, NA_SE_PL_ICE_BROKEN); + } else { + pthis->stateFlags2 |= 0x4000; + } + + if ((globalCtx->gameplayFrames % 4) == 0) { + Player_InflictDamage(globalCtx, -1); + } + } else { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80839F90(pthis, globalCtx); + func_80837AFC(pthis, -20); + } + } +} + +void func_8084FBF4(Player* pthis, GlobalContext* globalCtx) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_808382BC(pthis); + + if (((pthis->unk_850 % 25) != 0) || func_80837B18(globalCtx, pthis, -1)) { + if (DECR(pthis->unk_850) == 0) { + func_80839F90(pthis, globalCtx); + } + } + + pthis->shockTimer = 40; + func_8002F8F0(&pthis->actor, NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG + pthis->ageProperties->unk_92); +} + +s32 func_8084FCAC(Player* pthis, GlobalContext* globalCtx) { + sControlInput = &globalCtx->state.input[0]; + + if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_A | BTN_L | BTN_R) && + CHECK_BTN_ALL(sControlInput->press.button, BTN_B)) || + (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) { + + D_808535D0 ^= 1; + + if (D_808535D0) { + Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), CAM_MODE_BOWARROWZ); + } + } + + if (D_808535D0) { + f32 speed; + + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { + speed = 100.0f; + } else { + speed = 20.0f; + } + + func_8006375C(3, 2, "DEBUG MODE"); + + if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { + pthis->actor.world.pos.y += speed; + } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A)) { + pthis->actor.world.pos.y -= speed; + } + + if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP | BTN_DLEFT | BTN_DDOWN | BTN_DRIGHT)) { + s16 angle; + s16 temp; + + angle = temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); + + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DDOWN)) { + angle = temp + 0x8000; + } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DLEFT)) { + angle = temp + 0x4000; + } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DRIGHT)) { + angle = temp - 0x4000; + } + + pthis->actor.world.pos.x += speed * Math_SinS(angle); + pthis->actor.world.pos.z += speed * Math_CosS(angle); + } + } + + func_80832210(pthis); + + pthis->actor.gravity = 0.0f; + pthis->actor.velocity.z = 0.0f; + pthis->actor.velocity.y = 0.0f; + pthis->actor.velocity.x = 0.0f; + + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) { + Flags_SetTempClear(globalCtx, globalCtx->roomCtx.curRoom.num); + } + + Math_Vec3f_Copy(&pthis->actor.home.pos, &pthis->actor.world.pos); + + return 0; + } + + return 1; +} + +void func_8084FF7C(Player* pthis) { + pthis->unk_858 += pthis->unk_85C; + pthis->unk_85C -= pthis->unk_858 * 5.0f; + pthis->unk_85C *= 0.3f; + + if (ABS(pthis->unk_85C) < 0.00001f) { + pthis->unk_85C = 0.0f; + if (ABS(pthis->unk_858) < 0.00001f) { + pthis->unk_858 = 0.0f; + } + } +} + +void func_8085002C(Player* pthis) { + s32 pad; + s16 sp2A; + s16 sp28; + s16 sp26; + + D_80858AC8.unk_06 -= D_80858AC8.unk_06 >> 3; + D_80858AC8.unk_08 -= D_80858AC8.unk_08 >> 3; + D_80858AC8.unk_06 += -D_80858AC8.unk_00 >> 2; + D_80858AC8.unk_08 += -D_80858AC8.unk_02 >> 2; + + sp26 = pthis->actor.world.rot.y - pthis->actor.shape.rot.y; + + sp28 = (s32)(pthis->actor.speedXZ * -200.0f * Math_CosS(sp26) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; + sp2A = (s32)(pthis->actor.speedXZ * 100.0f * Math_SinS(sp26) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; + + D_80858AC8.unk_06 += sp28 >> 2; + D_80858AC8.unk_08 += sp2A >> 2; + + if (D_80858AC8.unk_06 > 6000) { + D_80858AC8.unk_06 = 6000; + } else if (D_80858AC8.unk_06 < -6000) { + D_80858AC8.unk_06 = -6000; + } + + if (D_80858AC8.unk_08 > 6000) { + D_80858AC8.unk_08 = 6000; + } else if (D_80858AC8.unk_08 < -6000) { + D_80858AC8.unk_08 = -6000; + } + + D_80858AC8.unk_00 += D_80858AC8.unk_06; + D_80858AC8.unk_02 += D_80858AC8.unk_08; + + if (D_80858AC8.unk_00 < 0) { + D_80858AC8.unk_04 = D_80858AC8.unk_00 >> 1; + } else { + D_80858AC8.unk_04 = 0; + } +} + +s32 func_80850224(Player* pthis, GlobalContext* globalCtx) { + if (func_8083C6B8(globalCtx, pthis) == 0) { + if (func_8083BB20(pthis) != 0) { + s32 sp24 = func_80837818(pthis); + + func_80837948(globalCtx, pthis, sp24); + + if (sp24 >= 0x18) { + pthis->stateFlags2 |= 0x20000; + func_80837530(globalCtx, pthis, 0); + return 1; + } + } else { + return 0; + } + } + + return 1; +} + +static Vec3f D_80854A40 = { 0.0f, 40.0f, 45.0f }; + +void func_808502D0(Player* pthis, GlobalContext* globalCtx) { + struct_80854190* sp44 = &D_80854190[pthis->swordAnimation]; + + pthis->stateFlags2 |= 0x20; + + if (!func_80842DF4(globalCtx, pthis)) { + func_8084285C(pthis, 0.0f, sp44->unk_0C, sp44->unk_0D); + + if ((pthis->stateFlags2 & 0x40000000) && (pthis->heldItemActionParam != PLAYER_AP_HAMMER) && + LinkAnimation_OnFrame(&pthis->skelAnime, 0.0f)) { + pthis->linearVelocity = 15.0f; + pthis->stateFlags2 &= ~0x40000000; + } + + if (pthis->linearVelocity > 12.0f) { + func_8084269C(globalCtx, pthis); + } + + Math_StepToF(&pthis->linearVelocity, 0.0f, 5.0f); + func_8083C50C(pthis); + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (!func_80850224(pthis, globalCtx)) { + u8 sp43 = pthis->skelAnime.moveFlags; + LinkAnimationHeader* sp3C; + + if (func_8008E9C4(pthis)) { + sp3C = sp44->unk_08; + } else { + sp3C = sp44->unk_04; + } + + func_80832318(pthis); + pthis->skelAnime.moveFlags = 0; + + if ((sp3C == &gPlayerAnim_002908) && (pthis->modelAnimType != 3)) { + sp3C = &gPlayerAnim_002AC8; + } + + func_8083A098(pthis, sp3C, globalCtx); + + pthis->skelAnime.moveFlags = sp43; + pthis->stateFlags3 |= 8; + } + } else if (pthis->heldItemActionParam == PLAYER_AP_HAMMER) { + if ((pthis->swordAnimation == 0x16) || (pthis->swordAnimation == 0x13)) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f shockwavePos; + f32 sp2C; + + shockwavePos.y = func_8083973C(globalCtx, pthis, &D_80854A40, &shockwavePos); + sp2C = pthis->actor.world.pos.y - shockwavePos.y; + + Math_ScaledStepToS(&pthis->actor.focus.rot.x, Math_Atan2S(45.0f, sp2C), 800); + func_80836AB8(pthis, 1); + + if ((((pthis->swordAnimation == 0x16) && LinkAnimation_OnFrame(&pthis->skelAnime, 7.0f)) || + ((pthis->swordAnimation == 0x13) && LinkAnimation_OnFrame(&pthis->skelAnime, 2.0f))) && + (sp2C > -40.0f) && (sp2C < 40.0f)) { + func_80842A28(globalCtx, pthis); + EffectSsBlast_SpawnWhiteShockwave(globalCtx, &shockwavePos, &zeroVec, &zeroVec); + } + } + } + } +} + +void func_808505DC(Player* pthis, GlobalContext* globalCtx) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_8083721C(pthis); + + if (pthis->skelAnime.curFrame >= 6.0f) { + func_80839FFC(pthis, globalCtx); + } +} + +void func_8085063C(Player* pthis, GlobalContext* globalCtx) { + pthis->stateFlags2 |= 0x20; + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_80836670(pthis, globalCtx); + + if (pthis->unk_850 == 0) { + Message_StartTextbox(globalCtx, 0x3B, &pthis->actor); + pthis->unk_850 = 1; + return; + } + + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { + s32 respawnData = gSaveContext.respawn[RESPAWN_MODE_TOP].data; + + if (globalCtx->msgCtx.choiceIndex == 0) { + gSaveContext.respawnFlag = 3; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex; + globalCtx->fadeTransition = 5; + func_80088AF0(globalCtx); + return; + } + + if (globalCtx->msgCtx.choiceIndex == 1) { + gSaveContext.respawn[RESPAWN_MODE_TOP].data = -respawnData; + gSaveContext.fw.set = 0; + func_80078914(&gSaveContext.respawn[RESPAWN_MODE_TOP].pos, NA_SE_PL_MAGIC_WIND_VANISH); + } + + func_80853080(pthis, globalCtx); + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + } +} + +void func_8085076C(Player* pthis, GlobalContext* globalCtx) { + s32 respawnData = gSaveContext.respawn[RESPAWN_MODE_TOP].data; + + if (pthis->unk_850 > 20) { + pthis->actor.draw = Player_Draw; + pthis->actor.world.pos.y += 60.0f; + func_80837B9C(pthis, globalCtx); + return; + } + + if (pthis->unk_850++ == 20) { + gSaveContext.respawn[RESPAWN_MODE_TOP].data = respawnData + 1; + func_80078914(&gSaveContext.respawn[RESPAWN_MODE_TOP].pos, NA_SE_PL_MAGIC_WIND_WARP); + } +} + +static LinkAnimationHeader* D_80854A58[] = { + &gPlayerAnim_002CF8, + &gPlayerAnim_002CE0, + &gPlayerAnim_002D10, +}; + +static LinkAnimationHeader* D_80854A64[] = { + &gPlayerAnim_002D00, + &gPlayerAnim_002CE8, + &gPlayerAnim_002D18, +}; + +static LinkAnimationHeader* D_80854A70[] = { + &gPlayerAnim_002D08, + &gPlayerAnim_002CF0, + &gPlayerAnim_002D20, +}; + +static u8 D_80854A7C[] = { 70, 10, 10 }; + +static struct_80832924 D_80854A80[] = { + { NA_SE_PL_SKIP, 0x814 }, + { NA_SE_VO_LI_SWORD_N, 0x2014 }, + { 0, -0x301A }, +}; + +static struct_80832924 D_80854A8C[][2] = { + { + { 0, 0x4014 }, + { NA_SE_VO_LI_MAGIC_FROL, -0x201E }, + }, + { + { 0, 0x4014 }, + { NA_SE_VO_LI_MAGIC_NALE, -0x202C }, + }, + { + { NA_SE_VO_LI_MAGIC_ATTACK, 0x2014 }, + { NA_SE_IT_SWORD_SWING_HARD, -0x814 }, + }, +}; + +void func_808507F4(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_84F < 0) { + if ((pthis->itemActionParam == PLAYER_AP_NAYRUS_LOVE) || (gSaveContext.unk_13F0 == 0)) { + func_80839FFC(pthis, globalCtx); + func_8005B1A4(Gameplay_GetCamera(globalCtx, 0)); + } + } else { + if (pthis->unk_850 == 0) { + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, D_80854A58[pthis->unk_84F], 0.83f); + + if (func_80846A00(globalCtx, pthis, pthis->unk_84F) != NULL) { + pthis->stateFlags1 |= 0x30000000; + if ((pthis->unk_84F != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { + gSaveContext.unk_13F0 = 1; + } + } else { + func_800876C8(globalCtx); + } + } else { + LinkAnimation_PlayLoopSetSpeed(globalCtx, &pthis->skelAnime, D_80854A64[pthis->unk_84F], 0.83f); + + if (pthis->unk_84F == 0) { + pthis->unk_850 = -10; + } + } + + pthis->unk_850++; + } + } else { + if (pthis->unk_850 < 0) { + pthis->unk_850++; + + if (pthis->unk_850 == 0) { + gSaveContext.respawn[RESPAWN_MODE_TOP].data = 1; + Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_TOP, 0x6FF); + gSaveContext.fw.set = 1; + gSaveContext.fw.pos.x = gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.x; + gSaveContext.fw.pos.y = gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.y; + gSaveContext.fw.pos.z = gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.z; + gSaveContext.fw.yaw = gSaveContext.respawn[RESPAWN_MODE_DOWN].yaw; + gSaveContext.fw.playerParams = 0x6FF; + gSaveContext.fw.entranceIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex; + gSaveContext.fw.roomIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].roomIndex; + gSaveContext.fw.tempSwchFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags; + gSaveContext.fw.tempCollectFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags; + pthis->unk_850 = 2; + } + } else if (pthis->unk_84F >= 0) { + if (pthis->unk_850 == 0) { + func_80832924(pthis, D_80854A80); + } else if (pthis->unk_850 == 1) { + func_80832924(pthis, D_80854A8C[pthis->unk_84F]); + if ((pthis->unk_84F == 2) && LinkAnimation_OnFrame(&pthis->skelAnime, 30.0f)) { + pthis->stateFlags1 &= ~0x30000000; + } + } else if (D_80854A7C[pthis->unk_84F] < pthis->unk_850++) { + LinkAnimation_PlayOnceSetSpeed(globalCtx, &pthis->skelAnime, D_80854A70[pthis->unk_84F], 0.83f); + pthis->currentYaw = pthis->actor.shape.rot.y; + pthis->unk_84F = -1; + } + } + } + + func_8083721C(pthis); +} + +void func_80850AEC(Player* pthis, GlobalContext* globalCtx) { + f32 temp; + + pthis->stateFlags2 |= 0x20; + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, &gPlayerAnim_002C98); + } + + Math_Vec3f_Sum(&pthis->actor.world.pos, &pthis->actor.velocity, &pthis->actor.world.pos); + + if (func_80834FBC(pthis)) { + Math_Vec3f_Copy(&pthis->actor.prevPos, &pthis->actor.world.pos); + func_80847BA0(globalCtx, pthis); + + temp = pthis->actor.world.pos.y - pthis->actor.floorHeight; + if (temp > 20.0f) { + temp = 20.0f; + } + + pthis->actor.world.rot.x = pthis->actor.shape.rot.x = 0; + pthis->actor.world.pos.y -= temp; + pthis->linearVelocity = 1.0f; + pthis->actor.velocity.y = 0.0f; + func_80837B9C(pthis, globalCtx); + pthis->stateFlags2 &= ~0x400; + pthis->actor.bgCheckFlags |= 1; + pthis->stateFlags1 |= 4; + return; + } + + if ((pthis->skelAnime.animation != &gPlayerAnim_002C90) || (4.0f <= pthis->skelAnime.curFrame)) { + pthis->actor.gravity = 0.0f; + Math_ScaledStepToS(&pthis->actor.shape.rot.x, pthis->actor.world.rot.x, 0x800); + func_8083264C(pthis, 100, 2, 100, 0); + } +} + +void func_80850C68(Player* pthis, GlobalContext* globalCtx) { + if ((pthis->unk_850 != 0) && ((pthis->unk_858 != 0.0f) || (pthis->unk_85C != 0.0f))) { + f32 updateScale = R_UPDATE_RATE * 0.5f; + + pthis->skelAnime.curFrame += pthis->skelAnime.playSpeed * updateScale; + if (pthis->skelAnime.curFrame >= pthis->skelAnime.animLength) { + pthis->skelAnime.curFrame -= pthis->skelAnime.animLength; + } + + LinkAnimation_BlendToJoint(globalCtx, &pthis->skelAnime, &gPlayerAnim_002C38, pthis->skelAnime.curFrame, + (pthis->unk_858 < 0.0f) ? &gPlayerAnim_002C18 : &gPlayerAnim_002C20, 5.0f, + fabsf(pthis->unk_858), pthis->blendTable); + LinkAnimation_BlendToMorph(globalCtx, &pthis->skelAnime, &gPlayerAnim_002C38, pthis->skelAnime.curFrame, + (pthis->unk_85C < 0.0f) ? &gPlayerAnim_002C28 : &gPlayerAnim_002C10, 5.0f, + fabsf(pthis->unk_85C), D_80858AD8); + LinkAnimation_InterpJointMorph(globalCtx, &pthis->skelAnime, 0.5f); + } else if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + pthis->unk_860 = 2; + func_80832284(globalCtx, pthis, &gPlayerAnim_002C38); + pthis->unk_850 = 1; + } + + func_8083721C(pthis); + + if (pthis->unk_860 == 0) { + func_80853080(pthis, globalCtx); + } else if (pthis->unk_860 == 3) { + func_80835C58(globalCtx, pthis, func_80850E84, 0); + func_80832B0C(globalCtx, pthis, &gPlayerAnim_002C00); + } +} + +void func_80850E84(Player* pthis, GlobalContext* globalCtx) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) && (pthis->unk_860 == 0)) { + func_8083A098(pthis, &gPlayerAnim_002C08, globalCtx); + } +} + +static void (*D_80854AA4[])(GlobalContext*, Player*, void*) = { + NULL, func_80851008, func_80851030, func_80851094, func_808510B4, func_808510D4, func_808510F4, + func_80851114, func_80851134, func_80851154, func_80851174, func_808511D4, func_808511FC, func_80851294, + func_80851050, func_80851194, func_808511B4, func_80851248, func_808512E0, +}; + +static struct_80832924 D_80854AF0[] = { + { 0, 0x2822 }, + { NA_SE_PL_CALM_HIT, 0x82D }, + { NA_SE_PL_CALM_HIT, 0x833 }, + { NA_SE_PL_CALM_HIT, -0x840 }, +}; + +static struct_80832924 D_80854B00[] = { + { NA_SE_VO_LI_SURPRISE, 0x2003 }, { 0, 0x300F }, { 0, 0x3018 }, { 0, 0x301E }, { NA_SE_VO_LI_FALL_L, -0x201F }, +}; + +static struct_80832924 D_80854B14[] = { + { 0, -0x300A }, +}; + +static struct_80854B18 D_80854B18[] = { + { 0, NULL }, + { -1, func_808515A4 }, + { 2, &gPlayerAnim_002790 }, + { 0, NULL }, + { 0, NULL }, + { 3, &gPlayerAnim_002740 }, + { 0, NULL }, + { 0, NULL }, + { -1, func_808515A4 }, + { 2, &gPlayerAnim_002778 }, + { -1, func_80851788 }, + { 3, &gPlayerAnim_002860 }, + { -1, func_808518DC }, + { 7, &gPlayerAnim_002348 }, + { 5, &gPlayerAnim_002350 }, + { 5, &gPlayerAnim_002358 }, + { 5, &gPlayerAnim_0023B0 }, + { 7, &gPlayerAnim_0023B8 }, + { -1, func_808519EC }, + { 2, &gPlayerAnim_002728 }, + { 2, &gPlayerAnim_002738 }, + { 0, NULL }, + { -1, func_80851B90 }, + { 3, &gPlayerAnim_0027A8 }, + { 9, &gPlayerAnim_002DB0 }, + { 2, &gPlayerAnim_002DC0 }, + { -1, func_80851D2C }, + { 2, &gPlayerAnim_003098 }, + { 3, &gPlayerAnim_002780 }, + { -1, func_808515A4 }, + { 2, &gPlayerAnim_003088 }, + { 0, NULL }, + { 0, NULL }, + { 5, &gPlayerAnim_002320 }, + { -1, func_80851368 }, + { -1, func_80851E64 }, + { 5, &gPlayerAnim_002328 }, + { 16, &gPlayerAnim_002F90 }, + { -1, func_80851F84 }, + { -1, func_80851E90 }, + { 6, &gPlayerAnim_002410 }, + { 6, &gPlayerAnim_002418 }, + { -1, func_80852080 }, + { 5, &gPlayerAnim_002390 }, + { -1, func_808521F4 }, + { -1, func_8085225C }, + { -1, func_80852280 }, + { 5, &gPlayerAnim_0023A0 }, + { 5, &gPlayerAnim_002368 }, + { -1, func_808515A4 }, + { 5, &gPlayerAnim_002370 }, + { 5, &gPlayerAnim_0027B0 }, + { 5, &gPlayerAnim_0027B8 }, + { 5, &gPlayerAnim_0027C0 }, + { 3, &gPlayerAnim_002768 }, + { 3, &gPlayerAnim_0027D8 }, + { 4, &gPlayerAnim_0027E0 }, + { 3, &gPlayerAnim_002380 }, + { 3, &gPlayerAnim_002828 }, + { 6, &gPlayerAnim_002470 }, + { 6, &gPlayerAnim_0032A8 }, + { 14, &gPlayerAnim_0032A0 }, + { 3, &gPlayerAnim_0032A0 }, + { 5, &gPlayerAnim_002AE8 }, + { 16, &gPlayerAnim_002450 }, + { 15, &gPlayerAnim_002460 }, + { 15, &gPlayerAnim_002458 }, + { 3, &gPlayerAnim_002440 }, + { 3, &gPlayerAnim_002438 }, + { 3, &gPlayerAnim_002C88 }, + { 6, &gPlayerAnim_003450 }, + { 6, &gPlayerAnim_003448 }, + { 6, &gPlayerAnim_003460 }, + { 6, &gPlayerAnim_003440 }, + { 3, &gPlayerAnim_002798 }, + { 3, &gPlayerAnim_002818 }, + { 4, &gPlayerAnim_002848 }, + { 3, &gPlayerAnim_002850 }, + { 3, &gPlayerAnim_0034E0 }, + { 3, &gPlayerAnim_0034D8 }, + { 6, &gPlayerAnim_0034C8 }, + { 3, &gPlayerAnim_003470 }, + { 3, &gPlayerAnim_003478 }, + { 3, &gPlayerAnim_0034C0 }, + { 3, &gPlayerAnim_003480 }, + { 3, &gPlayerAnim_003490 }, + { 3, &gPlayerAnim_003488 }, + { 3, &gPlayerAnim_003498 }, + { 3, &gPlayerAnim_0034B0 }, + { -1, func_808524B0 }, + { 3, &gPlayerAnim_003420 }, + { -1, func_80852544 }, + { -1, func_80852564 }, + { 3, &gPlayerAnim_003250 }, + { -1, func_80852608 }, + { 3, &gPlayerAnim_002810 }, + { 3, &gPlayerAnim_002838 }, + { 3, &gPlayerAnim_002CD0 }, + { 3, &gPlayerAnim_002CD8 }, + { 3, &gPlayerAnim_002868 }, + { 3, &gPlayerAnim_0027E8 }, + { 3, &gPlayerAnim_0027F8 }, + { 3, &gPlayerAnim_002800 }, +}; + +static struct_80854B18 D_80854E50[] = { + { 0, NULL }, + { -1, func_808514C0 }, + { -1, func_8085157C }, + { -1, func_80851998 }, + { -1, func_808519C0 }, + { 11, NULL }, + { -1, func_80852C50 }, + { -1, func_80852944 }, + { -1, func_80851688 }, + { -1, func_80851750 }, + { -1, func_80851828 }, + { -1, func_808521B8 }, + { -1, func_8085190C }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { 18, D_80854AF0 }, + { 11, NULL }, + { -1, func_80851A50 }, + { 12, &gPlayerAnim_002730 }, + { 11, NULL }, + { 0, NULL }, + { -1, func_80851BE8 }, + { 11, NULL }, + { -1, func_80851CA4 }, + { 11, NULL }, + { 17, &gPlayerAnim_0030A8 }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { -1, func_80851D80 }, + { -1, func_80851DEC }, + { -1, func_80851E28 }, + { 18, D_80854B00 }, + { -1, func_808513BC }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { -1, func_80851ECC }, + { -1, func_80851FB0 }, + { -1, func_80852048 }, + { -1, func_80852174 }, + { 13, &gPlayerAnim_002398 }, + { -1, func_80852234 }, + { 0, NULL }, + { 0, NULL }, + { 11, NULL }, + { -1, func_80852450 }, + { -1, func_80851688 }, + { -1, func_80852298 }, + { 13, &gPlayerAnim_0027D0 }, + { -1, func_80852480 }, + { 13, &gPlayerAnim_0027C8 }, + { -1, func_80852328 }, + { 11, NULL }, + { 11, NULL }, + { 12, &gPlayerAnim_002388 }, + { -1, func_80852358 }, + { 11, NULL }, + { 18, D_80854B14 }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { -1, func_80852388 }, + { 17, &gPlayerAnim_002450 }, + { 12, &gPlayerAnim_002448 }, + { 12, &gPlayerAnim_002450 }, + { 11, NULL }, + { -1, func_808526EC }, + { 17, &gPlayerAnim_003468 }, + { -1, func_808526EC }, + { 17, &gPlayerAnim_003468 }, + { 12, &gPlayerAnim_0027A0 }, + { 12, &gPlayerAnim_002820 }, + { 11, NULL }, + { 12, &gPlayerAnim_002858 }, + { 12, &gPlayerAnim_0034D0 }, + { 13, &gPlayerAnim_0034F0 }, + { 12, &gPlayerAnim_0034E8 }, + { 12, &gPlayerAnim_0034A8 }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { -1, func_80852648 }, + { 11, NULL }, + { 12, &gPlayerAnim_0034A0 }, + { -1, func_808524D0 }, + { -1, func_80852514 }, + { -1, func_80852554 }, + { -1, func_808525C0 }, + { 11, NULL }, + { 11, NULL }, + { 11, NULL }, + { -1, func_8085283C }, + { -1, func_808528C8 }, + { -1, func_808528C8 }, + { 12, &gPlayerAnim_002870 }, + { 12, &gPlayerAnim_0027F0 }, + { 12, &gPlayerAnim_002808 }, + { 12, &gPlayerAnim_002450 }, +}; + +void func_80850ED8(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + func_80832DB0(pthis); + func_80832B0C(globalCtx, pthis, anim); + func_80832210(pthis); +} + +void func_80850F1C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + func_80832DB0(pthis); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, (2.0f / 3.0f), 0.0f, Animation_GetLastFrame(anim), + ANIMMODE_ONCE, -8.0f); + func_80832210(pthis); +} + +void func_80850F9C(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim) { + func_80832DB0(pthis); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, (2.0f / 3.0f), 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); + func_80832210(pthis); +} + +void func_80851008(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80832210(pthis); +} + +void func_80851030(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80850ED8(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_80851050(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80832DB0(pthis); + func_80832C2C(globalCtx, pthis, (LinkAnimationHeader*)anim); + func_80832210(pthis); +} + +void func_80851094(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80850F1C(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_808510B4(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80850F9C(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_808510D4(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_8083308C(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_808510F4(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_8083303C(globalCtx, pthis, (LinkAnimationHeader*)anim, 0x9C); +} + +void func_80851114(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_8083313C(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_80851134(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_808330EC(globalCtx, pthis, (LinkAnimationHeader*)anim, 0x9C); +} + +void func_80851154(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80832264(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_80851174(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_80832284(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_80851194(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_808322D0(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_808511B4(GlobalContext* globalCtx, Player* pthis, void* anim) { + func_808322A4(globalCtx, pthis, (LinkAnimationHeader*)anim); +} + +void func_808511D4(GlobalContext* globalCtx, Player* pthis, void* anim) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); +} + +void func_808511FC(GlobalContext* globalCtx, Player* pthis, void* anim) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80850F9C(globalCtx, pthis, (LinkAnimationHeader*)anim); + pthis->unk_850 = 1; + } +} + +void func_80851248(GlobalContext* globalCtx, Player* pthis, void* anim) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832DBC(pthis); + func_808322A4(globalCtx, pthis, (LinkAnimationHeader*)anim); + } +} + +void func_80851294(GlobalContext* globalCtx, Player* pthis, void* anim) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083313C(globalCtx, pthis, (LinkAnimationHeader*)anim); + pthis->unk_850 = 1; + } +} + +void func_808512E0(GlobalContext* globalCtx, Player* pthis, void* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_80832924(pthis, (struct_80832924*)arg2); +} + +void func_80851314(Player* pthis) { + if ((pthis->unk_448 == NULL) || (pthis->unk_448->update == NULL)) { + pthis->unk_448 = NULL; + } + + pthis->unk_664 = pthis->unk_448; + + if (pthis->unk_664 != NULL) { + pthis->actor.shape.rot.y = func_8083DB98(pthis, 0); + } +} + +void func_80851368(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->stateFlags1 |= 0x8000000; + pthis->stateFlags2 |= 0x400; + pthis->stateFlags1 &= ~0xC0000; + + func_80832284(globalCtx, pthis, &gPlayerAnim_0032F0); +} + +void func_808513BC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->actor.gravity = 0.0f; + + if (pthis->unk_84F == 0) { + if (func_8083D12C(globalCtx, pthis, NULL)) { + pthis->unk_84F = 1; + } else { + func_8084B158(globalCtx, pthis, NULL, fabsf(pthis->actor.velocity.y)); + Math_ScaledStepToS(&pthis->unk_6C2, -10000, 800); + func_8084AEEC(pthis, &pthis->actor.velocity.y, 4.0f, pthis->currentYaw); + } + return; + } + + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + if (pthis->unk_84F == 1) { + func_80832C6C(globalCtx, pthis, &gPlayerAnim_003328); + } else { + func_80832284(globalCtx, pthis, &gPlayerAnim_003328); + } + } + + func_8084B000(pthis); + func_8084AEEC(pthis, &pthis->linearVelocity, 0.0f, pthis->actor.shape.rot.y); +} + +void func_808514C0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80851314(pthis); + + if (func_808332B8(pthis)) { + func_808513BC(globalCtx, pthis, 0); + return; + } + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (func_8008F128(pthis) || (pthis->stateFlags1 & 0x800)) { + func_80836670(pthis, globalCtx); + return; + } + + if ((pthis->interactRangeActor != NULL) && (pthis->interactRangeActor->textId == 0xFFFF)) { + func_8083E5A8(pthis, globalCtx); + } +} + +void func_8085157C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); +} + +void func_808515A4(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimationHeader* anim; + + if (func_808332B8(pthis)) { + func_80851368(globalCtx, pthis, 0); + return; + } + + anim = D_80853D34[pthis->modelAnimType]; + + if ((pthis->unk_446 == 6) || (pthis->unk_446 == 0x2E)) { + func_80832264(globalCtx, pthis, anim); + } else { + func_80832DB0(pthis); + LinkAnimation_Change(globalCtx, &pthis->skelAnime, anim, (2.0f / 3.0f), 0.0f, Animation_GetLastFrame(anim), + ANIMMODE_LOOP, -4.0f); + } + + func_80832210(pthis); +} + +void func_80851688(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (func_8084B3CC(globalCtx, pthis) == 0) { + if ((pthis->csMode == 0x31) && (globalCtx->csCtx.state == CS_STATE_IDLE)) { + func_8002DF54(globalCtx, NULL, 7); + return; + } + + if (func_808332B8(pthis) != 0) { + func_808513BC(globalCtx, pthis, 0); + return; + } + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (func_8008F128(pthis) || (pthis->stateFlags1 & 0x800)) { + func_80836670(pthis, globalCtx); + } + } +} + +static struct_80832924 D_80855188[] = { + { 0, 0x302A }, + { 0, -0x3030 }, +}; + +void func_80851750(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_80832924(pthis, D_80855188); +} + +void func_80851788(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->stateFlags1 &= ~0x2000000; + + pthis->currentYaw = pthis->actor.shape.rot.y = pthis->actor.world.rot.y = + Math_Vec3f_Yaw(&pthis->actor.world.pos, &pthis->unk_450); + + if (pthis->linearVelocity <= 0.0f) { + pthis->linearVelocity = 0.1f; + } else if (pthis->linearVelocity > 2.5f) { + pthis->linearVelocity = 2.5f; + } +} + +void func_80851828(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + f32 sp1C = 2.5f; + + func_80845BA0(globalCtx, pthis, &sp1C, 10); + + if (globalCtx->sceneNum == SCENE_BDAN_BOSS) { + if (pthis->unk_850 == 0) { + if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE) { + return; + } + } else { + if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_NONE) { + return; + } + } + } + + pthis->unk_850++; + if (pthis->unk_850 > 20) { + pthis->csMode = 0xB; + } +} + +void func_808518DC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_8083CEAC(pthis, globalCtx); +} + +void func_8085190C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80851314(pthis); + + if (pthis->unk_850 != 0) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80832284(globalCtx, pthis, func_808334E4(pthis)); + pthis->unk_850 = 0; + } + + func_80833C3C(pthis); + } else { + func_808401B0(globalCtx, pthis); + } +} + +void func_80851998(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80845964(globalCtx, pthis, arg2, 0.0f, 0, 0); +} + +void func_808519C0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80845964(globalCtx, pthis, arg2, 0.0f, 0, 1); +} + +// unused +static LinkAnimationHeader* D_80855190[] = { + &gPlayerAnim_002720, + &gPlayerAnim_002360, +}; + +static Vec3f D_80855198 = { -1.0f, 70.0f, 20.0f }; + +void func_808519EC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + Math_Vec3f_Copy(&pthis->actor.world.pos, &D_80855198); + pthis->actor.shape.rot.y = -0x8000; + func_808322D0(globalCtx, pthis, pthis->ageProperties->unk_9C); + func_80832F54(globalCtx, pthis, 0x28F); +} + +static struct_808551A4 D_808551A4[] = { + { NA_SE_IT_SWORD_PUTAWAY_STN, 0 }, + { NA_SE_IT_SWORD_STICK_STN, NA_SE_VO_LI_SWORD_N }, +}; + +static struct_80832924 D_808551AC[] = { + { 0, 0x401D }, + { 0, -0x4027 }, +}; + +void func_80851A50(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + struct_808551A4* sp2C; + Gfx** dLists; + + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if ((LINK_IS_ADULT && LinkAnimation_OnFrame(&pthis->skelAnime, 70.0f)) || + (!LINK_IS_ADULT && LinkAnimation_OnFrame(&pthis->skelAnime, 87.0f))) { + sp2C = &D_808551A4[gSaveContext.linkAge]; + pthis->interactRangeActor->parent = &pthis->actor; + + if (!LINK_IS_ADULT) { + dLists = D_80125DE8; + } else { + dLists = D_80125E18; + } + pthis->leftHandDLists = &dLists[gSaveContext.linkAge]; + + func_8002F7DC(&pthis->actor, sp2C->unk_00); + if (!LINK_IS_ADULT) { + func_80832698(pthis, sp2C->unk_02); + } + } else if (LINK_IS_ADULT) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 66.0f)) { + func_80832698(pthis, NA_SE_VO_LI_SWORD_L); + } + } else { + func_80832924(pthis, D_808551AC); + } +} + +void func_80851B90(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_002860, -(2.0f / 3.0f), 12.0f, 12.0f, ANIMMODE_ONCE, + 0.0f); +} + +static struct_80832924 D_808551B4[] = { + { 0, -0x281E }, +}; + +void func_80851BE8(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + pthis->unk_850++; + + if (pthis->unk_850 >= 180) { + if (pthis->unk_850 == 180) { + LinkAnimation_Change(globalCtx, &pthis->skelAnime, &gPlayerAnim_003298, (2.0f / 3.0f), 10.0f, + Animation_GetLastFrame(&gPlayerAnim_003298), ANIMMODE_ONCE, -8.0f); + } + func_80832924(pthis, D_808551B4); + } +} + +void func_80851CA4(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime) && (pthis->unk_850 == 0) && (pthis->actor.bgCheckFlags & 1)) { + func_80832264(globalCtx, pthis, &gPlayerAnim_002DB8); + pthis->unk_850 = 1; + } + + if (pthis->unk_850 != 0) { + func_8083721C(pthis); + } +} + +void func_80851D2C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80850F1C(globalCtx, pthis, &gPlayerAnim_0030A0); + func_8084B498(pthis); + Player_SetModels(pthis, Player_ActionToModelGroup(pthis, pthis->itemActionParam)); +} + +static struct_80832924 D_808551B8[] = { + { NA_SE_IT_SWORD_PICKOUT, -0x80C }, +}; + +void func_80851D80(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 6.0f)) { + func_80846720(globalCtx, pthis, 0); + } else { + func_80832924(pthis, D_808551B8); + } +} + +void func_80851DEC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + Math_StepToS(&pthis->actor.shape.face, 0, 1); +} + +void func_80851E28(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + Math_StepToS(&pthis->actor.shape.face, 2, 1); +} + +void func_80851E64(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80833064(globalCtx, pthis, &gPlayerAnim_003318, 0x98); +} + +void func_80851E90(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_8083303C(globalCtx, pthis, &gPlayerAnim_002408, 0x9C); + func_80832698(pthis, NA_SE_VO_LI_GROAN); +} + +void func_80851ECC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_808330EC(globalCtx, pthis, &gPlayerAnim_002428, 0x9C); + } +} + +void func_80851F14(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, struct_80832924* arg3) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_808322A4(globalCtx, pthis, anim); + pthis->unk_850 = 1; + } else if (pthis->unk_850 == 0) { + func_80832924(pthis, arg3); + } +} + +void func_80851F84(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->actor.shape.shadowDraw = NULL; + func_80851134(globalCtx, pthis, &gPlayerAnim_002420); +} + +static struct_80832924 D_808551BC[] = { + { NA_SE_VO_LI_RELAX, 0x2023 }, + { NA_SE_PL_SLIPDOWN, 0x8EC }, + { NA_SE_PL_SLIPDOWN, -0x900 }, +}; + +void func_80851FB0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_808330EC(globalCtx, pthis, &gPlayerAnim_002430, 0x9C); + pthis->unk_850 = 1; + } else if (pthis->unk_850 == 0) { + func_80832924(pthis, D_808551BC); + if (LinkAnimation_OnFrame(&pthis->skelAnime, 240.0f)) { + pthis->actor.shape.shadowDraw = ActorShadow_DrawFeet; + } + } +} + +static struct_80832924 D_808551C8[] = { + { NA_SE_PL_LAND_LADDER, 0x843 }, + { 0, 0x4854 }, + { 0, 0x485A }, + { 0, -0x4860 }, +}; + +void func_80852048(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_80832924(pthis, D_808551C8); +} + +void func_80852080(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80833064(globalCtx, pthis, &gPlayerAnim_002340, 0x9D); + func_80832698(pthis, NA_SE_VO_LI_FALL_L); +} + +void func_808520BC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + f32 startX = arg2->startPos.x; + f32 startY = arg2->startPos.y; + f32 startZ = arg2->startPos.z; + f32 distX = (arg2->endPos.x - startX); + f32 distY = (arg2->endPos.y - startY); + f32 distZ = (arg2->endPos.z - startZ); + f32 sp4 = (f32)(globalCtx->csCtx.frames - arg2->startFrame) / (f32)(arg2->endFrame - arg2->startFrame); + + pthis->actor.world.pos.x = distX * sp4 + startX; + pthis->actor.world.pos.y = distY * sp4 + startY; + pthis->actor.world.pos.z = distZ * sp4 + startZ; +} + +static struct_80832924 D_808551D8[] = { + { NA_SE_PL_BOUND, 0x1014 }, + { NA_SE_PL_BOUND, -0x101E }, +}; + +void func_80852174(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_808520BC(globalCtx, pthis, arg2); + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + func_80832924(pthis, D_808551D8); +} + +void func_808521B8(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (arg2 != NULL) { + func_808520BC(globalCtx, pthis, arg2); + } + LinkAnimation_Update(globalCtx, &pthis->skelAnime); +} + +void func_808521F4(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80832B0C(globalCtx, pthis, D_80853D34[pthis->modelAnimType]); + func_80832210(pthis); +} + +void func_80852234(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); +} + +void func_8085225C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80832F54(globalCtx, pthis, 0x98); +} + +void func_80852280(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->actor.draw = Player_Draw; +} + +void func_80852298(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8083313C(globalCtx, pthis, &gPlayerAnim_002378); + pthis->unk_850 = 1; + } else if (pthis->unk_850 == 0) { + if (LinkAnimation_OnFrame(&pthis->skelAnime, 10.0f)) { + func_80846720(globalCtx, pthis, 1); + } + } +} + +static struct_80832924 D_808551E0[] = { + { 0, 0x300A }, + { 0, -0x3018 }, +}; + +void func_80852328(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80851F14(globalCtx, pthis, &gPlayerAnim_002770, D_808551E0); +} + +static struct_80832924 D_808551E8[] = { + { 0, 0x400F }, + { 0, -0x4023 }, +}; + +void func_80852358(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80851F14(globalCtx, pthis, &gPlayerAnim_002830, D_808551E8); +} + +void func_80852388(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_808322A4(globalCtx, pthis, &gPlayerAnim_002468); + pthis->unk_850 = 1; + } + + if ((pthis->unk_850 != 0) && (globalCtx->csCtx.frames >= 900)) { + pthis->rightHandType = 0; + } else { + pthis->rightHandType = 0xFF; + } +} + +void func_80852414(GlobalContext* globalCtx, Player* pthis, LinkAnimationHeader* anim, struct_80832924* arg3) { + func_80851294(globalCtx, pthis, anim); + if (pthis->unk_850 == 0) { + func_80832924(pthis, arg3); + } +} + +static struct_80832924 D_808551F0[] = { + { 0, 0x300F }, + { 0, -0x3021 }, +}; + +void func_80852450(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80852414(globalCtx, pthis, &gPlayerAnim_002378, D_808551F0); +} + +static struct_80832924 D_808551F8[] = { + { NA_SE_PL_KNOCK, -0x84E }, +}; + +void func_80852480(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80852414(globalCtx, pthis, &gPlayerAnim_0027D0, D_808551F8); +} + +void func_808524B0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80837704(globalCtx, pthis); +} + +void func_808524D0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + sControlInput->press.button |= BTN_B; + + func_80844E68(pthis, globalCtx); +} + +void func_80852514(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80844E68(pthis, globalCtx); +} + +void func_80852544(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { +} + +void func_80852554(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { +} + +void func_80852564(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->stateFlags3 |= 2; + pthis->linearVelocity = 2.0f; + pthis->actor.velocity.y = -1.0f; + + func_80832264(globalCtx, pthis, &gPlayerAnim_002DB0); + func_80832698(pthis, NA_SE_VO_LI_FALL_L); +} + +static void (*D_808551FC[])(Player* pthis, GlobalContext* globalCtx) = { + func_8084377C, + func_80843954, + func_80843A38, +}; + +void func_808525C0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + D_808551FC[pthis->unk_850](pthis, globalCtx); +} + +void func_80852608(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + func_80846720(globalCtx, pthis, 0); + func_808322D0(globalCtx, pthis, &gPlayerAnim_002838); +} + +void func_80852648(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + LinkAnimation_Update(globalCtx, &pthis->skelAnime); + + if (LinkAnimation_OnFrame(&pthis->skelAnime, 10.0f)) { + pthis->heldItemActionParam = pthis->itemActionParam = PLAYER_AP_NONE; + pthis->heldItemId = ITEM_NONE; + pthis->modelGroup = pthis->nextModelGroup = Player_ActionToModelGroup(pthis, PLAYER_AP_NONE); + pthis->leftHandDLists = D_80125E08; + Inventory_ChangeEquipment(EQUIP_SWORD, 2); + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + Inventory_DeleteEquipment(globalCtx, 0); + } +} + +static LinkAnimationHeader* D_80855208[] = { + &gPlayerAnim_0034B8, + &gPlayerAnim_003458, +}; + +static Vec3s D_80855210[2][2] = { + { { -200, 700, 100 }, { 800, 600, 800 } }, + { { -200, 500, 0 }, { 600, 400, 600 } }, +}; + +void func_808526EC(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 primColor = { 255, 255, 255, 0 }; + static Color_RGBA8 envColor = { 0, 128, 128, 0 }; + s32 age = gSaveContext.linkAge; + Vec3f sparklePos; + Vec3f sp34; + Vec3s* ptr; + + func_80851294(globalCtx, pthis, D_80855208[age]); + + if (pthis->rightHandType != 0xFF) { + pthis->rightHandType = 0xFF; + return; + } + + ptr = D_80855210[gSaveContext.linkAge]; + + sp34.x = ptr[0].x + Rand_CenteredFloat(ptr[1].x); + sp34.y = ptr[0].y + Rand_CenteredFloat(ptr[1].y); + sp34.z = ptr[0].z + Rand_CenteredFloat(ptr[1].z); + + SkinMatrix_Vec3fMtxFMultXYZ(&pthis->shieldMf, &sp34, &sparklePos); + + EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &zeroVec, &zeroVec, &primColor, &envColor, 600, -10); +} + +void func_8085283C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_80852944(globalCtx, pthis, arg2); + } else if (pthis->unk_850 == 0) { + Item_Give(globalCtx, ITEM_SWORD_MASTER); + func_80846720(globalCtx, pthis, 0); + } else { + func_8084E988(pthis); + } +} + +void func_808528C8(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (LinkAnimation_Update(globalCtx, &pthis->skelAnime)) { + func_8084285C(pthis, 0.0f, 99.0f, pthis->skelAnime.endFrame - 8.0f); + } + + if (pthis->heldItemActionParam != PLAYER_AP_SWORD_MASTER) { + func_80846720(globalCtx, pthis, 1); + } +} + +void func_80852944(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + if (func_808332B8(pthis)) { + func_80838F18(globalCtx, pthis); + func_80832340(globalCtx, pthis); + } else { + func_8083C148(pthis, globalCtx); + if (!func_8083B644(pthis, globalCtx)) { + func_8083E5A8(pthis, globalCtx); + } + } + + pthis->csMode = 0; + pthis->unk_6AD = 0; +} + +void func_808529D0(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + pthis->actor.world.pos.x = arg2->startPos.x; + pthis->actor.world.pos.y = arg2->startPos.y; + if ((globalCtx->sceneNum == SCENE_SPOT04) && !LINK_IS_ADULT) { + pthis->actor.world.pos.y -= 1.0f; + } + pthis->actor.world.pos.z = arg2->startPos.z; + pthis->currentYaw = pthis->actor.shape.rot.y = arg2->rot.y; +} + +void func_80852A54(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + f32 dx = arg2->startPos.x - (s32)pthis->actor.world.pos.x; + f32 dy = arg2->startPos.y - (s32)pthis->actor.world.pos.y; + f32 dz = arg2->startPos.z - (s32)pthis->actor.world.pos.z; + f32 dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); + s16 yawDiff = arg2->rot.y - pthis->actor.shape.rot.y; + + if ((pthis->linearVelocity == 0.0f) && ((dist > 50.0f) || (ABS(yawDiff) > 0x4000))) { + func_808529D0(globalCtx, pthis, arg2); + } + + pthis->skelAnime.moveFlags = 0; + func_80832DB0(pthis); +} + +void func_80852B4C(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2, struct_80854B18* arg3) { + if (arg3->type > 0) { + D_80854AA4[arg3->type](globalCtx, pthis, arg3->ptr); + } else if (arg3->type < 0) { + arg3->func(globalCtx, pthis, arg2); + } + + if ((D_80858AA0 & 4) && !(pthis->skelAnime.moveFlags & 4)) { + pthis->skelAnime.morphTable[0].y /= pthis->ageProperties->unk_08; + D_80858AA0 = 0; + } +} + +void func_80852C0C(GlobalContext* globalCtx, Player* pthis, s32 csMode) { + if ((csMode != 1) && (csMode != 8) && (csMode != 0x31) && (csMode != 7)) { + func_808323B4(globalCtx, pthis); + } +} + +void func_80852C50(GlobalContext* globalCtx, Player* pthis, CsCmdActorAction* arg2) { + CsCmdActorAction* linkCsAction = globalCtx->csCtx.linkAction; + s32 pad; + s32 sp24; + + if (globalCtx->csCtx.state == CS_STATE_UNSKIPPABLE_INIT) { + func_8002DF54(globalCtx, NULL, 7); + pthis->unk_446 = 0; + func_80832210(pthis); + return; + } + + if (linkCsAction == NULL) { + pthis->actor.flags &= ~ACTOR_FLAG_UNCULLED; + return; + } + + if (pthis->unk_446 != linkCsAction->action) { + sp24 = D_808547C4[linkCsAction->action]; + if (sp24 >= 0) { + if ((sp24 == 3) || (sp24 == 4)) { + func_80852A54(globalCtx, pthis, linkCsAction); + } else { + func_808529D0(globalCtx, pthis, linkCsAction); + } + } + + D_80858AA0 = pthis->skelAnime.moveFlags; + + func_80832DBC(pthis); + osSyncPrintf("TOOL MODE=%d\n", sp24); + func_80852C0C(globalCtx, pthis, ABS(sp24)); + func_80852B4C(globalCtx, pthis, linkCsAction, &D_80854B18[ABS(sp24)]); + + pthis->unk_850 = 0; + pthis->unk_84F = 0; + pthis->unk_446 = linkCsAction->action; + } + + sp24 = D_808547C4[pthis->unk_446]; + func_80852B4C(globalCtx, pthis, linkCsAction, &D_80854E50[ABS(sp24)]); +} + +void func_80852E14(Player* pthis, GlobalContext* globalCtx) { + if (pthis->csMode != pthis->prevCsMode) { + D_80858AA0 = pthis->skelAnime.moveFlags; + + func_80832DBC(pthis); + pthis->prevCsMode = pthis->csMode; + osSyncPrintf("DEMO MODE=%d\n", pthis->csMode); + func_80852C0C(globalCtx, pthis, pthis->csMode); + func_80852B4C(globalCtx, pthis, NULL, &D_80854B18[pthis->csMode]); + } + + func_80852B4C(globalCtx, pthis, NULL, &D_80854E50[pthis->csMode]); +} + +s32 Player_IsDroppingFish(GlobalContext* globalCtx) { + Player* pthis = GET_PLAYER(globalCtx); + + return (func_8084EFC0 == pthis->func_674) && (pthis->itemActionParam == PLAYER_AP_BOTTLE_FISH); +} + +s32 Player_StartFishing(GlobalContext* globalCtx) { + Player* pthis = GET_PLAYER(globalCtx); + + func_80832564(globalCtx, pthis); + func_80835F44(globalCtx, pthis, ITEM_FISHING_POLE); + return 1; +} + +s32 func_80852F38(GlobalContext* globalCtx, Player* pthis) { + if (!Player_InBlockingCsMode(globalCtx, pthis) && (pthis->invincibilityTimer >= 0) && !func_8008F128(pthis) && + !(pthis->stateFlags3 & 0x80)) { + func_80832564(globalCtx, pthis); + func_80835C58(globalCtx, pthis, func_8084F308, 0); + func_80832264(globalCtx, pthis, &gPlayerAnim_003120); + pthis->stateFlags2 |= 0x80; + func_80832224(pthis); + func_80832698(pthis, NA_SE_VO_LI_HELD); + return true; + } + + return false; +} + +// Sets up player cutscene +s32 func_80852FFC(GlobalContext* globalCtx, Actor* actor, s32 csMode) { + Player* pthis = GET_PLAYER(globalCtx); + + if (!Player_InBlockingCsMode(globalCtx, pthis)) { + func_80832564(globalCtx, pthis); + func_80835C58(globalCtx, pthis, func_80852E14, 0); + pthis->csMode = csMode; + pthis->unk_448 = actor; + func_80832224(pthis); + return 1; + } + + return 0; +} + +void func_80853080(Player* pthis, GlobalContext* globalCtx) { + func_80835C58(globalCtx, pthis, func_80840BC8, 1); + func_80832B0C(globalCtx, pthis, func_80833338(pthis)); + pthis->currentYaw = pthis->actor.shape.rot.y; +} + +s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage) { + Player* pthis = GET_PLAYER(globalCtx); + + if (!Player_InBlockingCsMode(globalCtx, pthis) && !func_80837B18(globalCtx, pthis, damage)) { + pthis->stateFlags2 &= ~0x80; + return 1; + } + + return 0; +} + +// Start talking with the given actor +void func_80853148(GlobalContext* globalCtx, Actor* actor) { + Player* pthis = GET_PLAYER(globalCtx); + s32 pad; + + if ((pthis->targetActor != NULL) || (actor == pthis->naviActor) || + CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_18)) { + actor->flags |= ACTOR_FLAG_8; + } + + pthis->targetActor = actor; + pthis->exchangeItemId = EXCH_ITEM_NONE; + + if (actor->textId == 0xFFFF) { + func_8002DF54(globalCtx, actor, 1); + actor->flags |= ACTOR_FLAG_8; + func_80832528(globalCtx, pthis); + } else { + if (pthis->actor.flags & ACTOR_FLAG_8) { + pthis->actor.textId = 0; + } else { + pthis->actor.flags |= ACTOR_FLAG_8; + pthis->actor.textId = actor->textId; + } + + if (pthis->stateFlags1 & 0x800000) { + s32 sp24 = pthis->unk_850; + + func_80832528(globalCtx, pthis); + func_8083A2F8(globalCtx, pthis); + + pthis->unk_850 = sp24; + } else { + if (func_808332B8(pthis)) { + func_80836898(globalCtx, pthis, func_8083A2F8); + func_80832C6C(globalCtx, pthis, &gPlayerAnim_003328); + } else if ((actor->category != ACTORCAT_NPC) || (pthis->heldItemActionParam == PLAYER_AP_FISHING_POLE)) { + func_8083A2F8(globalCtx, pthis); + + if (!func_8008E9C4(pthis)) { + if ((actor != pthis->naviActor) && (actor->xzDistToPlayer < 40.0f)) { + func_808322D0(globalCtx, pthis, &gPlayerAnim_002DF0); + } else { + func_80832284(globalCtx, pthis, func_80833338(pthis)); + } + } + } else { + func_80836898(globalCtx, pthis, func_8083A2F8); + func_808322D0(globalCtx, pthis, + (actor->xzDistToPlayer < 40.0f) ? &gPlayerAnim_002DF0 : &gPlayerAnim_0031A0); + } + + if (pthis->skelAnime.animation == &gPlayerAnim_002DF0) { + func_80832F54(globalCtx, pthis, 0x19); + } + + func_80832224(pthis); + } + + pthis->stateFlags1 |= 0x20000040; + } + + if ((pthis->naviActor == pthis->targetActor) && ((pthis->targetActor->textId & 0xFF00) != 0x200)) { + pthis->naviActor->flags |= ACTOR_FLAG_8; + func_80835EA4(globalCtx, 0xB); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.cpp similarity index 52% rename from src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c rename to src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.cpp index b61c8f7db..f6ebad513 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.cpp @@ -26,42 +26,42 @@ #define rScaleStep regs[10] #define rScaleStepDecay regs[11] -u32 EffectSsBlast_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBlast_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBlast_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsBlast_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsBlast_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsBlast_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Blast_InitVars = { EFFECT_SS_BLAST, EffectSsBlast_Init, }; -u32 EffectSsBlast_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsBlast_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsBlastParams* initParams = (EffectSsBlastParams*)initParamsx; - this->pos = initParams->pos; - this->pos.y += 5.0f; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffShockwaveDL); - this->life = initParams->life; - this->draw = EffectSsBlast_Draw; - this->update = EffectSsBlast_Update; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rEnvColorA = initParams->envColor.a; - this->rAlphaTarget = initParams->primColor.a / initParams->life; - this->rScale = initParams->scale; - this->rScaleStep = initParams->scaleStep; - this->rScaleStepDecay = initParams->sclaeStepDecay; + pthis->pos = initParams->pos; + pthis->pos.y += 5.0f; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffShockwaveDL); + pthis->life = initParams->life; + pthis->draw = EffectSsBlast_Draw; + pthis->update = EffectSsBlast_Update; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rEnvColorA = initParams->envColor.a; + pthis->rAlphaTarget = initParams->primColor.a / initParams->life; + pthis->rScale = initParams->scale; + pthis->rScaleStep = initParams->scaleStep; + pthis->rScaleStepDecay = initParams->sclaeStepDecay; return 1; } -void EffectSsBlast_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBlast_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; MtxF mf; s32 pad; @@ -69,26 +69,26 @@ void EffectSsBlast_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx, "../z_eff_ss_blast.c", 170); - radius = this->rScale * 0.0025f; + radius = pthis->rScale * 0.0025f; func_80093D84(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - func_800BFCB8(globalCtx, &mf, &this->pos); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + func_800BFCB8(globalCtx, &mf, &pthis->pos); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, pthis->rPrimColorA); Matrix_Put(&mf); Matrix_Scale(radius, radius, radius, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_blast.c", 199), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_ss_blast.c", 204); } -void EffectSsBlast_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - Math_StepToS(&this->rPrimColorA, 0, this->rAlphaTarget); - this->rScale += this->rScaleStep; +void EffectSsBlast_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + Math_StepToS((s16*)&pthis->rPrimColorA, 0, pthis->rAlphaTarget); + pthis->rScale += pthis->rScaleStep; - if (this->rScaleStep != 0) { - this->rScaleStep -= this->rScaleStepDecay; + if (pthis->rScaleStep != 0) { + pthis->rScaleStep -= pthis->rScaleStepDecay; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c b/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.cpp similarity index 69% rename from src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c rename to src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.cpp index 6b46e2581..3cc2aedf8 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb/z_eff_ss_bomb.cpp @@ -17,32 +17,32 @@ #define rScale regs[0] #define rTexIdx regs[1] -u32 EffectSsBomb_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBomb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBomb_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsBomb_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsBomb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsBomb_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Bomb_InitVars = { EFFECT_SS_BOMB, EffectSsBomb_Init, }; -u32 EffectSsBomb_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsBomb_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsBombInitParams* initParams = (EffectSsBombInitParams*)initParamsx; - Math_Vec3f_Copy(&this->pos, &initParams->pos); - Math_Vec3f_Copy(&this->velocity, &initParams->velocity); - Math_Vec3f_Copy(&this->accel, &initParams->accel); - this->gfx = SEGMENTED_TO_VIRTUAL(gEffBombExplosion1DL); - this->life = 20; - this->draw = EffectSsBomb_Draw; - this->update = EffectSsBomb_Update; - this->rScale = 100; - this->rTexIdx = 0; + Math_Vec3f_Copy(&pthis->pos, &initParams->pos); + Math_Vec3f_Copy(&pthis->velocity, &initParams->velocity); + Math_Vec3f_Copy(&pthis->accel, &initParams->accel); + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffBombExplosion1DL); + pthis->life = 20; + pthis->draw = EffectSsBomb_Draw; + pthis->update = EffectSsBomb_Update; + pthis->rScale = 100; + pthis->rTexIdx = 0; return 1; } -void EffectSsBomb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBomb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { static void* explosionTextures[] = { gEffBombExplosion1Tex, gEffBombExplosion2Tex, @@ -63,9 +63,9 @@ void EffectSsBomb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx, "../z_eff_ss_bomb.c", 168); - scale = this->rScale / 100.0f; + scale = pthis->rScale / 100.0f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); @@ -76,27 +76,27 @@ void EffectSsBomb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(explosionTextures[this->rTexIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(explosionTextures[pthis->rTexIdx])); gDPPipeSync(POLY_XLU_DISP++); func_80094C50(gfxCtx); - color = this->life * 12.75f; + color = pthis->life * 12.75f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color, color, color, color); gDPPipeSync(POLY_XLU_DISP++); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); gDPPipeSync(POLY_XLU_DISP++); } CLOSE_DISPS(gfxCtx, "../z_eff_ss_bomb.c", 214); } -void EffectSsBomb_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if ((this->life < 21) && (this->life > 16)) { - this->rTexIdx = (20 - this->life); +void EffectSsBomb_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if ((pthis->life < 21) && (pthis->life > 16)) { + pthis->rTexIdx = (20 - pthis->life); } else { - this->rScale += 0; - this->rTexIdx = 3; + pthis->rScale += 0; + pthis->rTexIdx = 3; } - this->accel.x = ((Rand_ZeroOne() * 0.4f) - 0.2f); - this->accel.z = ((Rand_ZeroOne() * 0.4f) - 0.2f); + pthis->accel.x = ((Rand_ZeroOne() * 0.4f) - 0.2f); + pthis->accel.z = ((Rand_ZeroOne() * 0.4f) - 0.2f); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.cpp similarity index 59% rename from src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c rename to src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.cpp index 28d70407a..420d094a9 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.cpp @@ -26,10 +26,10 @@ #define rScaleStep regs[9] #define rDepth regs[10] -u32 EffectSsBomb2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBomb2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsBomb2_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsBomb2_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Bomb2_InitVars = { EFFECT_SS_BOMB2, @@ -41,32 +41,32 @@ static EffectSsDrawFunc sDrawFuncs[] = { EffectSsBomb2_DrawLayered, }; -u32 EffectSsBomb2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsBomb2_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsBomb2InitParams* initParams = (EffectSsBomb2InitParams*)initParamsx; - Math_Vec3f_Copy(&this->pos, &initParams->pos); - Math_Vec3f_Copy(&this->velocity, &initParams->velocity); - Math_Vec3f_Copy(&this->accel, &initParams->accel); - this->gfx = SEGMENTED_TO_VIRTUAL(gEffBombExplosion1DL); - this->life = 24; - this->update = EffectSsBomb2_Update; - this->draw = sDrawFuncs[initParams->drawMode]; - this->rScale = initParams->scale; - this->rScaleStep = initParams->scaleStep; - this->rPrimColorR = 255; - this->rPrimColorG = 255; - this->rPrimColorB = 255; - this->rPrimColorA = 255; - this->rEnvColorR = 0; - this->rEnvColorG = 0; - this->rEnvColorB = 200; + Math_Vec3f_Copy(&pthis->pos, &initParams->pos); + Math_Vec3f_Copy(&pthis->velocity, &initParams->velocity); + Math_Vec3f_Copy(&pthis->accel, &initParams->accel); + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffBombExplosion1DL); + pthis->life = 24; + pthis->update = EffectSsBomb2_Update; + pthis->draw = sDrawFuncs[initParams->drawMode]; + pthis->rScale = initParams->scale; + pthis->rScaleStep = initParams->scaleStep; + pthis->rPrimColorR = 255; + pthis->rPrimColorG = 255; + pthis->rPrimColorB = 255; + pthis->rPrimColorA = 255; + pthis->rEnvColorR = 0; + pthis->rEnvColorG = 0; + pthis->rEnvColorB = 200; return 1; } // unused in the original game. looks like EffectSsBomb but with color -void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { static void* textures[] = { gEffBombExplosion1Tex, gEffBombExplosion2Tex, gEffBombExplosion3Tex, gEffBombExplosion4Tex, gEffBombExplosion5Tex, gEffBombExplosion6Tex, gEffBombExplosion7Tex, gEffBombExplosion8Tex, @@ -82,8 +82,8 @@ void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* this) OPEN_DISPS(gfxCtx, "../z_eff_ss_bomb2.c", 298); - scale = this->rScale * 0.01f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + scale = pthis->rScale * 0.01f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); @@ -93,11 +93,11 @@ void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* this) if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80094BC4(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[this->rTexIdx])); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[pthis->rTexIdx])); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } if (1) {} @@ -106,7 +106,7 @@ void EffectSsBomb2_DrawFade(GlobalContext* globalCtx, u32 index, EffectSs* this) CLOSE_DISPS(gfxCtx, "../z_eff_ss_bomb2.c", 345); } -void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { static void* textures[] = { gEffBombExplosion1Tex, gEffBombExplosion2Tex, gEffBombExplosion3Tex, gEffBombExplosion4Tex, gEffBombExplosion5Tex, gEffBombExplosion6Tex, gEffBombExplosion7Tex, gEffBombExplosion8Tex, @@ -127,9 +127,9 @@ void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* th OPEN_DISPS(gfxCtx, "../z_eff_ss_bomb2.c", 386); - depth = this->rDepth; - scale = this->rScale * 0.01f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + depth = pthis->rDepth; + scale = pthis->rScale * 0.01f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); @@ -143,10 +143,10 @@ void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* th if (mtx2 != NULL) { func_80094BC4(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[this->rTexIdx])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(textures[pthis->rTexIdx])); gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion2DL); gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); @@ -155,7 +155,7 @@ void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* th for (i = 1; i >= 0; i--) { Matrix_Translate(0.0f, 0.0f, depth, MTXMODE_APPLY); - Matrix_RotateZ((this->life * 0.02f) + 180.0f, MTXMODE_APPLY); + Matrix_RotateZ((pthis->life * 0.02f) + 180.0f, MTXMODE_APPLY); Matrix_Scale(layer2Scale, layer2Scale, layer2Scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_eff_ss_bomb2.c", 448), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -171,35 +171,35 @@ void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* th CLOSE_DISPS(gfxCtx, "../z_eff_ss_bomb2.c", 456); } -void EffectSsBomb2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBomb2_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 divisor; - this->rTexIdx = (23 - this->life) / 3; - this->rScale += this->rScaleStep; + pthis->rTexIdx = (23 - pthis->life) / 3; + pthis->rScale += pthis->rScaleStep; - if (this->rScaleStep == 30) { - this->rDepth += 4.0f; + if (pthis->rScaleStep == 30) { + pthis->rDepth += 4.0f; } else { - this->rDepth += 2.0f; + pthis->rDepth += 2.0f; } - if ((this->life < 23) && (this->life > 13)) { - divisor = this->life - 13; - this->rPrimColorR = func_80027DD4(this->rPrimColorR, 255, divisor); - this->rPrimColorG = func_80027DD4(this->rPrimColorG, 255, divisor); - this->rPrimColorB = func_80027DD4(this->rPrimColorB, 150, divisor); - this->rPrimColorA = func_80027DD4(this->rPrimColorA, 255, divisor); - this->rEnvColorR = func_80027DD4(this->rEnvColorR, 150, divisor); - this->rEnvColorG = func_80027DD4(this->rEnvColorG, 0, divisor); - this->rEnvColorB = func_80027DD4(this->rEnvColorB, 0, divisor); - } else if ((this->life < 14) && (this->life > -1)) { - divisor = this->life + 1; - this->rPrimColorR = func_80027DD4(this->rPrimColorR, 50, divisor); - this->rPrimColorG = func_80027DD4(this->rPrimColorG, 50, divisor); - this->rPrimColorB = func_80027DD4(this->rPrimColorB, 50, divisor); - this->rPrimColorA = func_80027DD4(this->rPrimColorA, 150, divisor); - this->rEnvColorR = func_80027DD4(this->rEnvColorR, 10, divisor); - this->rEnvColorG = func_80027DD4(this->rEnvColorG, 10, divisor); - this->rEnvColorB = func_80027DD4(this->rEnvColorB, 10, divisor); + if ((pthis->life < 23) && (pthis->life > 13)) { + divisor = pthis->life - 13; + pthis->rPrimColorR = func_80027DD4(pthis->rPrimColorR, 255, divisor); + pthis->rPrimColorG = func_80027DD4(pthis->rPrimColorG, 255, divisor); + pthis->rPrimColorB = func_80027DD4(pthis->rPrimColorB, 150, divisor); + pthis->rPrimColorA = func_80027DD4(pthis->rPrimColorA, 255, divisor); + pthis->rEnvColorR = func_80027DD4(pthis->rEnvColorR, 150, divisor); + pthis->rEnvColorG = func_80027DD4(pthis->rEnvColorG, 0, divisor); + pthis->rEnvColorB = func_80027DD4(pthis->rEnvColorB, 0, divisor); + } else if ((pthis->life < 14) && (pthis->life > -1)) { + divisor = pthis->life + 1; + pthis->rPrimColorR = func_80027DD4(pthis->rPrimColorR, 50, divisor); + pthis->rPrimColorG = func_80027DD4(pthis->rPrimColorG, 50, divisor); + pthis->rPrimColorB = func_80027DD4(pthis->rPrimColorB, 50, divisor); + pthis->rPrimColorA = func_80027DD4(pthis->rPrimColorA, 150, divisor); + pthis->rEnvColorR = func_80027DD4(pthis->rEnvColorR, 10, divisor); + pthis->rEnvColorG = func_80027DD4(pthis->rEnvColorG, 10, divisor); + pthis->rEnvColorB = func_80027DD4(pthis->rEnvColorB, 10, divisor); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.cpp similarity index 56% rename from src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c rename to src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.cpp index 23025d749..4ff86cabf 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.cpp @@ -17,76 +17,76 @@ #define rScale regs[0] -u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, EffectSsBubble_Init, }; -u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; //! @bug Rand_ZeroOne in the macro means a random number is generated for both parts of the macro. - // In the base game this works out because both addresses are segment 4, but it may break if + // In the base game pthis works out because both addresses are segment 4, but it may break if // the addresses were changed to refer to different segments - this->gfx = SEGMENTED_TO_VIRTUAL(Rand_ZeroOne() < 0.5f ? gEffBubble1Tex : gEffBubble2Tex); - this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.x; - this->pos.y = (((Rand_ZeroOne() - 0.5f) * initParams->yPosRandScale) + initParams->yPosOffset) + initParams->pos.y; - this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.z; - Math_Vec3f_Copy(&this->vec, &this->pos); - this->life = 1; - this->rScale = (((Rand_ZeroOne() * 0.5f) + 1.0f) * initParams->scale) * 100; - this->draw = EffectSsBubble_Draw; - this->update = EffectSsBubble_Update; + pthis->gfx = SEGMENTED_TO_VIRTUAL(Rand_ZeroOne() < 0.5f ? gEffBubble1Tex : gEffBubble2Tex); + pthis->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.x; + pthis->pos.y = (((Rand_ZeroOne() - 0.5f) * initParams->yPosRandScale) + initParams->yPosOffset) + initParams->pos.y; + pthis->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.z; + Math_Vec3f_Copy(&pthis->vec, &pthis->pos); + pthis->life = 1; + pthis->rScale = (((Rand_ZeroOne() * 0.5f) + 1.0f) * initParams->scale) * 100; + pthis->draw = EffectSsBubble_Draw; + pthis->update = EffectSsBubble_Update; return 1; } -void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - f32 scale = this->rScale / 100.0f; + f32 scale = pthis->rScale / 100.0f; OPEN_DISPS(gfxCtx, "../z_eff_ss_bubble.c", 154); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_bubble.c", 167), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D18(gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); - gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPSegment(POLY_OPA_DISP++, 0x08, pthis->gfx); gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gEffBubbleDL)); CLOSE_DISPS(gfxCtx, "../z_eff_ss_bubble.c", 179); } -void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { WaterBox* waterBox; f32 waterSurfaceY; Vec3f ripplePos; - waterSurfaceY = this->pos.y; + waterSurfaceY = pthis->pos.y; // kill bubble if it's out of range of a water box - if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { - this->life = -1; + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, pthis->pos.x, pthis->pos.z, &waterSurfaceY, &waterBox)) { + pthis->life = -1; return; } - if (waterSurfaceY < this->pos.y) { - ripplePos.x = this->pos.x; + if (waterSurfaceY < pthis->pos.y) { + ripplePos.x = pthis->pos.x; ripplePos.y = waterSurfaceY; - ripplePos.z = this->pos.z; + ripplePos.z = pthis->pos.z; EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 80, 0); - this->life = -1; + pthis->life = -1; } else { - this->life++; - this->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + this->vec.x; - this->accel.y = (Rand_ZeroOne() - 0.3f) * 0.2f; - this->pos.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + this->vec.z; + pthis->life++; + pthis->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + pthis->vec.x; + pthis->accel.y = (Rand_ZeroOne() - 0.3f) * 0.2f; + pthis->pos.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + pthis->vec.z; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.cpp similarity index 56% rename from src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c rename to src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.cpp index eba3cdc72..c6c3a3b28 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.cpp @@ -24,37 +24,37 @@ #define rObjBankIdx regs[10] #define rYAccelStep regs[11] // has no effect due to how it's implemented -u32 EffectSsDFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsDFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsDFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_D_Fire_InitVars = { EFFECT_SS_D_FIRE, EffectSsDFire_Init, }; -u32 EffectSsDFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsDFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsDFireInitParams* initParams = (EffectSsDFireInitParams*)initParamsx; s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DODONGO); if (objBankIndex >= 0) { - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->gfx = SEGMENTED_TO_VIRTUAL(gDodongoFireDL); - this->life = initParams->life; - this->rScale = initParams->scale; - this->rScaleStep = initParams->scaleStep; - this->rYAccelStep = 0; - this->rObjBankIdx = objBankIndex; - this->draw = EffectSsDFire_Draw; - this->update = EffectSsDFire_Update; - this->rTexIdx = ((s16)(globalCtx->state.frames % 4) ^ 3); - this->rPrimColorR = 255; - this->rPrimColorG = 255; - this->rPrimColorB = 50; - this->rPrimColorA = initParams->alpha; - this->rFadeDelay = initParams->fadeDelay; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gDodongoFireDL); + pthis->life = initParams->life; + pthis->rScale = initParams->scale; + pthis->rScaleStep = initParams->scaleStep; + pthis->rYAccelStep = 0; + pthis->rObjBankIdx = objBankIndex; + pthis->draw = EffectSsDFire_Draw; + pthis->update = EffectSsDFire_Update; + pthis->rTexIdx = ((s16)(globalCtx->state.frames % 4) ^ 3); + pthis->rPrimColorR = 255; + pthis->rPrimColorG = 255; + pthis->rPrimColorB = 50; + pthis->rPrimColorA = initParams->alpha; + pthis->rFadeDelay = initParams->fadeDelay; return 1; } @@ -64,7 +64,7 @@ u32 EffectSsDFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void static void* sTextures[] = { gDodongoFire0Tex, gDodongoFire1Tex, gDodongoFire2Tex, gDodongoFire3Tex }; -void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; MtxF mfTrans; MtxF mfScale; @@ -75,15 +75,15 @@ void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { Mtx* mtx; f32 scale; - object = gObjectTable[this->rObjBankIdx].vromStart; + object = gObjectTable[pthis->rObjBankIdx].vromStart.buffer(); OPEN_DISPS(gfxCtx, "../z_eff_ss_d_fire.c", 276); if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_DODONGO) > -1) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); - scale = this->rScale / 100.0f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + scale = pthis->rScale / 100.0f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); @@ -94,39 +94,39 @@ void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80094BC4(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIdx])); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[pthis->rTexIdx])); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } } CLOSE_DISPS(gfxCtx, "../z_eff_ss_d_fire.c", 330); } -void EffectSsDFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rTexIdx++; - this->rTexIdx &= 3; - this->rScale += this->rScaleStep; +void EffectSsDFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rTexIdx++; + pthis->rTexIdx &= 3; + pthis->rScale += pthis->rScaleStep; - if (this->rFadeDelay >= this->life) { - this->rPrimColorA -= 5; - if (this->rPrimColorA < 0) { - this->rPrimColorA = 0; + if (pthis->rFadeDelay >= pthis->life) { + pthis->rPrimColorA -= 5; + if (pthis->rPrimColorA < 0) { + pthis->rPrimColorA = 0; } } else { - this->rPrimColorA += 15; - if (this->rPrimColorA > 255) { - this->rPrimColorA = 255; + pthis->rPrimColorA += 15; + if (pthis->rPrimColorA > 255) { + pthis->rPrimColorA = 255; } } - if (this->accel.y < 0.0f) { - this->accel.y += this->rYAccelStep * 0.01f; + if (pthis->accel.y < 0.0f) { + pthis->accel.y += pthis->rYAccelStep * 0.01f; } - if (this->life <= 0) { - this->rYAccelStep += 0; + if (pthis->life <= 0) { + pthis->rYAccelStep += 0; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.cpp similarity index 50% rename from src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c rename to src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.cpp index 007aa960c..a58dede99 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.cpp @@ -26,38 +26,38 @@ #define rPlaySound regs[10] #define rReg11 regs[11] -u32 EffectSsDeadDb_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDeadDb_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsDeadDb_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsDeadDb_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Dead_Db_InitVars = { EFFECT_SS_DEAD_DB, EffectSsDeadDb_Init, }; -u32 EffectSsDeadDb_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsDeadDb_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsDeadDbInitParams* initParams = (EffectSsDeadDbInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffEnemyDeathFlameDL); - this->life = initParams->unk_34; - this->flags = 4; - this->rScaleStep = initParams->scaleStep; - this->rReg11 = initParams->unk_34; - this->draw = EffectSsDeadDb_Draw; - this->update = EffectSsDeadDb_Update; - this->rScale = initParams->scale; - this->rTextIdx = 0; - this->rPlaySound = initParams->playSound; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffEnemyDeathFlameDL); + pthis->life = initParams->unk_34; + pthis->flags = 4; + pthis->rScaleStep = initParams->scaleStep; + pthis->rReg11 = initParams->unk_34; + pthis->draw = EffectSsDeadDb_Draw; + pthis->update = EffectSsDeadDb_Update; + pthis->rScale = initParams->scale; + pthis->rTextIdx = 0; + pthis->rPlaySound = initParams->playSound; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; return 1; } @@ -68,7 +68,7 @@ static void* sTextures[] = { gEffEnemyDeathFlame9Tex, gEffEnemyDeathFlame10Tex, }; -void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; MtxF mfTrans; MtxF mfScale; @@ -78,9 +78,9 @@ void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx, "../z_eff_ss_dead_db.c", 201); - scale = this->rScale * 0.01f; + scale = pthis->rScale * 0.01f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, scale); SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); @@ -89,55 +89,55 @@ void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80094BC4(gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTextIdx])); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[pthis->rTextIdx])); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } CLOSE_DISPS(gfxCtx, "../z_eff_ss_dead_db.c", 247); } -void EffectSsDeadDb_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsDeadDb_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { f32 w; f32 pad; - this->rTextIdx = (f32)((this->rReg11 - this->life) * 9) / this->rReg11; - this->rScale += this->rScaleStep; + pthis->rTextIdx = (f32)((pthis->rReg11 - pthis->life) * 9) / pthis->rReg11; + pthis->rScale += pthis->rScaleStep; - this->rPrimColorR -= 10; - if (this->rPrimColorR < 0) { - this->rPrimColorR = 0; + pthis->rPrimColorR -= 10; + if (pthis->rPrimColorR < 0) { + pthis->rPrimColorR = 0; } - this->rPrimColorG -= 10; - if (this->rPrimColorG < 0) { - this->rPrimColorG = 0; + pthis->rPrimColorG -= 10; + if (pthis->rPrimColorG < 0) { + pthis->rPrimColorG = 0; } - this->rPrimColorB -= 10; - if (this->rPrimColorB < 0) { - this->rPrimColorB = 0; + pthis->rPrimColorB -= 10; + if (pthis->rPrimColorB < 0) { + pthis->rPrimColorB = 0; } - this->rEnvColorR -= 10; - if (this->rEnvColorR < 0) { - this->rEnvColorR = 0; + pthis->rEnvColorR -= 10; + if (pthis->rEnvColorR < 0) { + pthis->rEnvColorR = 0; } - this->rEnvColorG -= 10; - if (this->rEnvColorG < 0) { - this->rEnvColorG = 0; + pthis->rEnvColorG -= 10; + if (pthis->rEnvColorG < 0) { + pthis->rEnvColorG = 0; } - this->rEnvColorB -= 10; - if (this->rEnvColorB < 0) { - this->rEnvColorB = 0; + pthis->rEnvColorB -= 10; + if (pthis->rEnvColorB < 0) { + pthis->rEnvColorB = 0; } - if (this->rPlaySound && (this->rTextIdx == 1)) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &this->vec, &w); - Audio_PlaySoundGeneral(NA_SE_EN_EXTINCT, &this->vec, 4, &D_801333E0, &D_801333E0, &D_801333E8); + if (pthis->rPlaySound && (pthis->rTextIdx == 1)) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->pos, &pthis->vec, &w); + Audio_PlaySoundGeneral(NA_SE_EN_EXTINCT, &pthis->vec, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c deleted file mode 100644 index 49646ebbf..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c +++ /dev/null @@ -1,151 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_DEAD_DD_Z_EFF_SS_DEAD_DD_C -#include "actor_common.h" -#include "z_kankyo.h" -/* - * File: z_eff_ss_dead_dd.c - * Overlay: ovl_Effect_Ss_Dead_Dd - * Description: - */ - -#include "z_eff_ss_dead_dd.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_object_kankyo.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define rScale regs[0] -#define rPrimColorR regs[2] -#define rPrimColorG regs[3] -#define rPrimColorB regs[4] -#define rAlpha regs[5] -#define rEnvColorR regs[6] -#define rEnvColorG regs[7] -#define rEnvColorB regs[8] -#define rScaleStep regs[9] -#define rAlphaStep regs[10] -#define rAlphaMode regs[11] // if mode is 0 alpha decreases over time, otherwise it increases - -u32 EffectSsDeadDd_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadDd_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDeadDd_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); - -EffectSsInit Effect_Ss_Dead_Dd_InitVars = { - EFFECT_SS_DEAD_DD, - EffectSsDeadDd_Init, -}; - -u32 EffectSsDeadDd_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - s32 i; - EffectSsDeadDdInitParams* initParams = (EffectSsDeadDdInitParams*)initParamsx; - - if (initParams->type == 0) { - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = initParams->life; - this->rScaleStep = initParams->scaleStep; - this->rAlphaMode = initParams->alphaStep; - - if (initParams->alphaStep != 0) { - this->rAlphaStep = initParams->alphaStep; - } else { - this->rAlphaStep = initParams->alpha / initParams->life; - } - - this->draw = EffectSsDeadDd_Draw; - this->update = EffectSsDeadDd_Update; - this->rScale = initParams->scale; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rAlpha = initParams->alpha; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - - } else if (initParams->type == 1) { - this->life = initParams->life; - this->rScaleStep = initParams->scaleStep; - this->rAlphaMode = 0; - this->rAlphaStep = 155 / initParams->life; - this->rScale = initParams->scale; - this->rPrimColorR = 255; - this->rPrimColorG = 255; - this->rPrimColorB = 155; - this->rAlpha = 155; - this->rEnvColorR = 250; - this->rEnvColorG = 180; - this->rEnvColorB = 0; - this->draw = EffectSsDeadDd_Draw; - this->update = EffectSsDeadDd_Update; - - for (i = initParams->randIter; i > 0; i--) { - this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.x; - this->pos.y = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.y; - this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.z; - this->accel.x = this->velocity.x = (Rand_ZeroOne() - 0.5f) * 2.0f; - this->accel.y = this->velocity.y = (Rand_ZeroOne() - 0.5f) * 2.0f; - this->accel.z = this->velocity.z = (Rand_ZeroOne() - 0.5f) * 2.0f; - } - } else { - osSyncPrintf("Effect_SS_Dd_disp_mode():mode_swが変です。\n"); - return 0; - } - - return 1; -} - -void EffectSsDeadDd_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - MtxF mfTrans; - MtxF mfScale; - MtxF mfResult; - Mtx* mtx; - f32 scale; - - OPEN_DISPS(gfxCtx, "../z_eff_ss_dead_dd.c", 214); - - scale = this->rScale * 0.01f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); - SkinMatrix_SetScale(&mfScale, scale, scale, scale); - SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); - - mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); - - if (mtx != NULL) { - func_80094BC4(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rAlpha); - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, - PRIMITIVE, 0); - gSPDisplayList(POLY_XLU_DISP++, gLensFlareCircleDL); - } - - CLOSE_DISPS(gfxCtx, "../z_eff_ss_dead_dd.c", 259); -} - -void EffectSsDeadDd_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - - this->rScale += this->rScaleStep; - - if (this->rScale < 0) { - this->rScale = 0; - } - - if (this->rAlphaMode != 0) { - this->rAlpha += this->rAlphaStep; - if (this->rAlpha > 255) { - this->rAlpha = 255; - } - } else { - if (this->rAlpha < this->rAlphaStep) { - this->rAlpha = 0; - } else { - this->rAlpha -= this->rAlphaStep; - } - } -} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.cpp b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.cpp new file mode 100644 index 000000000..75a473908 --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.cpp @@ -0,0 +1,151 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_DEAD_DD_Z_EFF_SS_DEAD_DD_C +#include "actor_common.h" +#include "z_kankyo.h" +/* + * File: z_eff_ss_dead_dd.c + * Overlay: ovl_Effect_Ss_Dead_Dd + * Description: + */ + +#include "z_eff_ss_dead_dd.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_object_kankyo.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define rScale regs[0] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rAlpha regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rScaleStep regs[9] +#define rAlphaStep regs[10] +#define rAlphaMode regs[11] // if mode is 0 alpha decreases over time, otherwise it increases + +u32 EffectSsDeadDd_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDeadDd_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsDeadDd_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +EffectSsInit Effect_Ss_Dead_Dd_InitVars = { + EFFECT_SS_DEAD_DD, + EffectSsDeadDd_Init, +}; + +u32 EffectSsDeadDd_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + s32 i; + EffectSsDeadDdInitParams* initParams = (EffectSsDeadDdInitParams*)initParamsx; + + if (initParams->type == 0) { + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = initParams->life; + pthis->rScaleStep = initParams->scaleStep; + pthis->rAlphaMode = initParams->alphaStep; + + if (initParams->alphaStep != 0) { + pthis->rAlphaStep = initParams->alphaStep; + } else { + pthis->rAlphaStep = initParams->alpha / initParams->life; + } + + pthis->draw = EffectSsDeadDd_Draw; + pthis->update = EffectSsDeadDd_Update; + pthis->rScale = initParams->scale; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rAlpha = initParams->alpha; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + + } else if (initParams->type == 1) { + pthis->life = initParams->life; + pthis->rScaleStep = initParams->scaleStep; + pthis->rAlphaMode = 0; + pthis->rAlphaStep = 155 / initParams->life; + pthis->rScale = initParams->scale; + pthis->rPrimColorR = 255; + pthis->rPrimColorG = 255; + pthis->rPrimColorB = 155; + pthis->rAlpha = 155; + pthis->rEnvColorR = 250; + pthis->rEnvColorG = 180; + pthis->rEnvColorB = 0; + pthis->draw = EffectSsDeadDd_Draw; + pthis->update = EffectSsDeadDd_Update; + + for (i = initParams->randIter; i > 0; i--) { + pthis->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.x; + pthis->pos.y = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.y; + pthis->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.z; + pthis->accel.x = pthis->velocity.x = (Rand_ZeroOne() - 0.5f) * 2.0f; + pthis->accel.y = pthis->velocity.y = (Rand_ZeroOne() - 0.5f) * 2.0f; + pthis->accel.z = pthis->velocity.z = (Rand_ZeroOne() - 0.5f) * 2.0f; + } + } else { + osSyncPrintf("Effect_SS_Dd_disp_mode():mode_swが変です。\n"); + return 0; + } + + return 1; +} + +void EffectSsDeadDd_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(gfxCtx, "../z_eff_ss_dead_dd.c", 214); + + scale = pthis->rScale * 0.01f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, scale); + SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + func_80094BC4(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, pthis->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rAlpha); + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + gSPDisplayList(POLY_XLU_DISP++, gLensFlareCircleDL); + } + + CLOSE_DISPS(gfxCtx, "../z_eff_ss_dead_dd.c", 259); +} + +void EffectSsDeadDd_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + + pthis->rScale += pthis->rScaleStep; + + if (pthis->rScale < 0) { + pthis->rScale = 0; + } + + if (pthis->rAlphaMode != 0) { + pthis->rAlpha += pthis->rAlphaStep; + if (pthis->rAlpha > 255) { + pthis->rAlpha = 255; + } + } else { + if (pthis->rAlpha < pthis->rAlphaStep) { + pthis->rAlpha = 0; + } else { + pthis->rAlpha -= pthis->rAlphaStep; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.cpp similarity index 56% rename from src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c rename to src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.cpp index 2ddf03d64..a7e9d59af 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.cpp @@ -22,35 +22,35 @@ #define rAlphaStep regs[10] #define rHalfOfLife regs[11] -u32 EffectSsDeadDs_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDeadDs_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsDeadDs_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsDeadDs_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Dead_Ds_InitVars = { EFFECT_SS_DEAD_DS, EffectSsDeadDs_Init, }; -u32 EffectSsDeadDs_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsDeadDs_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsDeadDsInitParams* initParams = (EffectSsDeadDsInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = initParams->life; - this->rScaleStep = initParams->scaleStep; - this->rHalfOfLife = initParams->life / 2; - this->rAlphaStep = initParams->alpha / this->rHalfOfLife; - this->draw = EffectSsDeadDs_Draw; - this->update = EffectSsDeadDs_Update; - this->rScale = initParams->scale; - this->rAlpha = initParams->alpha; - this->rTimer = 0; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = initParams->life; + pthis->rScaleStep = initParams->scaleStep; + pthis->rHalfOfLife = initParams->life / 2; + pthis->rAlphaStep = initParams->alpha / pthis->rHalfOfLife; + pthis->draw = EffectSsDeadDs_Draw; + pthis->update = EffectSsDeadDs_Update; + pthis->rScale = initParams->scale; + pthis->rAlpha = initParams->alpha; + pthis->rTimer = 0; return 1; } -void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 pad; f32 scale; s32 pad1; @@ -62,46 +62,46 @@ void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead_ds.c", 157); - scale = this->rScale * 0.01f; + scale = pthis->rScale * 0.01f; func_80094BC4(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, this->rAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, pthis->rAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); - pos = this->pos; + pos = pthis->pos; - if (this->rTimer == 0) { + if (pthis->rTimer == 0) { Vec3s rpy; Vec3f sp44; - sp44.x = pos.x - this->velocity.x; - sp44.y = pos.y - this->velocity.y; - sp44.z = pos.z - this->velocity.z; + sp44.x = pos.x - pthis->velocity.x; + sp44.y = pos.y - pthis->velocity.y; + sp44.z = pos.z - pthis->velocity.z; - if (BgCheck_EntitySphVsWall1(&globalCtx->colCtx, &this->pos, &pos, &sp44, 1.5f, &floorPoly, 1.0f)) { - func_80038A28(floorPoly, this->pos.x, this->pos.y, this->pos.z, &mf); + if (BgCheck_EntitySphVsWall1(&globalCtx->colCtx, &pthis->pos, &pos, &sp44, 1.5f, &floorPoly, 1.0f)) { + func_80038A28(floorPoly, pthis->pos.x, pthis->pos.y, pthis->pos.z, &mf); Matrix_Put(&mf); } else { pos.y++; temp = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &floorPoly, &pos); if (floorPoly != NULL) { - func_80038A28(floorPoly, this->pos.x, temp + 1.5f, this->pos.z, &mf); + func_80038A28(floorPoly, pthis->pos.x, temp + 1.5f, pthis->pos.z, &mf); Matrix_Put(&mf); } else { - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Get(&mf); } } Matrix_MtxFToZYXRotS(&mf, &rpy, 0); - this->rRoll = rpy.x; - this->rPitch = rpy.y; - this->rYaw = rpy.z; - this->pos.y = mf.yw; - this->rTimer++; + pthis->rRoll = rpy.x; + pthis->rPitch = rpy.y; + pthis->rYaw = rpy.z; + pthis->pos.y = mf.yw; + pthis->rTimer++; } - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateZYX(this->rRoll, this->rPitch, this->rYaw, MTXMODE_APPLY); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); + Matrix_RotateZYX(pthis->rRoll, pthis->rPitch, pthis->rYaw, MTXMODE_APPLY); Matrix_RotateX(1.57f, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_eff_ss_dead_ds.c", 246), @@ -113,17 +113,17 @@ void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead_ds.c", 255); } -void EffectSsDeadDs_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if (this->life < this->rHalfOfLife) { +void EffectSsDeadDs_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if (pthis->life < pthis->rHalfOfLife) { - this->rScale += this->rScaleStep; - if (this->rScale < 0) { - this->rScale = 0; + pthis->rScale += pthis->rScaleStep; + if (pthis->rScale < 0) { + pthis->rScale = 0; } - this->rAlpha -= this->rAlphaStep; - if (this->rAlpha < 0) { - this->rAlpha = 0; + pthis->rAlpha -= pthis->rAlphaStep; + if (pthis->rAlpha < 0) { + pthis->rAlpha = 0; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.cpp similarity index 62% rename from src/overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.c rename to src/overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.cpp index 76e82affc..ec2780546 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.cpp @@ -12,35 +12,35 @@ #define rSfxId regs[10] #define rRepeatMode regs[11] // sound is replayed every update. unused in the original game -u32 EffectSsDeadSound_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadSound_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsDeadSound_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDeadSound_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Dead_Sound_InitVars = { EFFECT_SS_DEAD_SOUND, EffectSsDeadSound_Init, }; -u32 EffectSsDeadSound_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsDeadSound_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsDeadSoundInitParams* initParams = (EffectSsDeadSoundInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->flags = 2; - this->life = initParams->life; - this->draw = NULL; - this->update = EffectSsDeadSound_Update; - this->rRepeatMode = initParams->repeatMode; - this->rSfxId = initParams->sfxId; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->flags = 2; + pthis->life = initParams->life; + pthis->draw = NULL; + pthis->update = EffectSsDeadSound_Update; + pthis->rRepeatMode = initParams->repeatMode; + pthis->rSfxId = initParams->sfxId; osSyncPrintf("コンストラクター3\n"); // "constructor 3" return 1; } -void EffectSsDeadSound_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - switch (this->rRepeatMode) { +void EffectSsDeadSound_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + switch (pthis->rRepeatMode) { case DEADSOUND_REPEAT_MODE_OFF: - this->rRepeatMode--; // decrement to 0 so sound only plays once + pthis->rRepeatMode--; // decrement to 0 so sound only plays once break; case DEADSOUND_REPEAT_MODE_ON: break; @@ -48,5 +48,5 @@ void EffectSsDeadSound_Update(GlobalContext* globalCtx, u32 index, EffectSs* thi return; } - Audio_PlaySoundGeneral(this->rSfxId, &this->pos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Audio_PlaySoundGeneral(pthis->rSfxId, &pthis->pos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c deleted file mode 100644 index 793bdb058..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c +++ /dev/null @@ -1,112 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_DT_BUBBLE_Z_EFF_SS_DT_BUBBLE_C -#include "actor_common.h" -/* - * File: z_eff_ss_dt_bubble.c - * Overlay: ovl_Effect_Ss_Dt_Bubble - * Description: Bubbles (a random mix of translucent and opaque) - */ - -#include "z_eff_ss_dt_bubble.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_rcp.h" - -#define rPrimColorR regs[0] -#define rPrimColorG regs[1] -#define rPrimColorB regs[2] -#define rPrimColorA regs[3] -#define rEnvColorR regs[4] -#define rEnvColorG regs[5] -#define rEnvColorB regs[6] -#define rEnvColorA regs[7] -#define rRandXZ regs[8] -#define rScale regs[9] -#define rLifespan regs[10] - -u32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); - -static Color_RGBA8 sPrimColors[] = { { 255, 255, 100, 255 }, { 150, 255, 255, 255 }, { 100, 255, 255, 255 } }; -static Color_RGBA8 sEnvColors[] = { { 170, 0, 0, 255 }, { 0, 100, 0, 255 }, { 0, 0, 255, 255 } }; - -EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { - EFFECT_SS_DT_BUBBLE, - EffectSsDtBubble_Init, -}; - -u32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsDtBubbleInitParams* initParams = (EffectSsDtBubbleInitParams*)initParamsx; - - //! @bug Rand_ZeroOne in the macro means a random number is generated for both parts of the macro. - // In the base game this works out because both addresses are segment 4, but it may break if - // the addresses were changed to refer to different segments - this->gfx = SEGMENTED_TO_VIRTUAL(Rand_ZeroOne() < 0.5f ? gEffBubble1Tex : gEffBubble2Tex); - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = initParams->life; - - if (!initParams->customColor) { - this->rPrimColorR = sPrimColors[initParams->colorProfile].r; - this->rPrimColorG = sPrimColors[initParams->colorProfile].g; - this->rPrimColorB = sPrimColors[initParams->colorProfile].b; - this->rPrimColorA = sPrimColors[initParams->colorProfile].a; - this->rEnvColorR = sEnvColors[initParams->colorProfile].r; - this->rEnvColorG = sEnvColors[initParams->colorProfile].g; - this->rEnvColorB = sEnvColors[initParams->colorProfile].b; - this->rEnvColorA = sEnvColors[initParams->colorProfile].a; - } else { - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rEnvColorA = initParams->envColor.a; - } - - this->rRandXZ = initParams->randXZ; - this->rScale = initParams->scale; - this->rLifespan = initParams->life; - this->draw = EffectSsDtBubble_Draw; - this->update = EffectSsDtBubble_Update; - - return 1; -} - -void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - f32 scale; - - OPEN_DISPS(gfxCtx, "../z_eff_ss_dt_bubble.c", 201); - - scale = this->rScale * 0.004f; - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_dt_bubble.c", 213), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_80093C14(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - (this->rPrimColorA * this->life) / this->rLifespan); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, - (this->rEnvColorA * this->life) / this->rLifespan); - gSPSegment(POLY_XLU_DISP++, 0x08, this->gfx); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffBubbleDL)); - - CLOSE_DISPS(gfxCtx, "../z_eff_ss_dt_bubble.c", 236); -} - -void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - f32 rand; - - if (this->rRandXZ == 1) { - rand = Rand_ZeroOne(); - this->pos.x += (rand * 2.0f) - 1.0f; - - rand = Rand_ZeroOne(); - this->pos.z += (rand * 2.0f) - 1.0f; - } -} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.cpp b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.cpp new file mode 100644 index 000000000..ac74255ed --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.cpp @@ -0,0 +1,112 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_DT_BUBBLE_Z_EFF_SS_DT_BUBBLE_C +#include "actor_common.h" +/* + * File: z_eff_ss_dt_bubble.c + * Overlay: ovl_Effect_Ss_Dt_Bubble + * Description: Bubbles (a random mix of translucent and opaque) + */ + +#include "z_eff_ss_dt_bubble.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_rcp.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rRandXZ regs[8] +#define rScale regs[9] +#define rLifespan regs[10] + +u32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +static Color_RGBA8 sPrimColors[] = { { 255, 255, 100, 255 }, { 150, 255, 255, 255 }, { 100, 255, 255, 255 } }; +static Color_RGBA8 sEnvColors[] = { { 170, 0, 0, 255 }, { 0, 100, 0, 255 }, { 0, 0, 255, 255 } }; + +EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { + EFFECT_SS_DT_BUBBLE, + EffectSsDtBubble_Init, +}; + +u32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + EffectSsDtBubbleInitParams* initParams = (EffectSsDtBubbleInitParams*)initParamsx; + + //! @bug Rand_ZeroOne in the macro means a random number is generated for both parts of the macro. + // In the base game pthis works out because both addresses are segment 4, but it may break if + // the addresses were changed to refer to different segments + pthis->gfx = SEGMENTED_TO_VIRTUAL(Rand_ZeroOne() < 0.5f ? gEffBubble1Tex : gEffBubble2Tex); + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = initParams->life; + + if (!initParams->customColor) { + pthis->rPrimColorR = sPrimColors[initParams->colorProfile].r; + pthis->rPrimColorG = sPrimColors[initParams->colorProfile].g; + pthis->rPrimColorB = sPrimColors[initParams->colorProfile].b; + pthis->rPrimColorA = sPrimColors[initParams->colorProfile].a; + pthis->rEnvColorR = sEnvColors[initParams->colorProfile].r; + pthis->rEnvColorG = sEnvColors[initParams->colorProfile].g; + pthis->rEnvColorB = sEnvColors[initParams->colorProfile].b; + pthis->rEnvColorA = sEnvColors[initParams->colorProfile].a; + } else { + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rEnvColorA = initParams->envColor.a; + } + + pthis->rRandXZ = initParams->randXZ; + pthis->rScale = initParams->scale; + pthis->rLifespan = initParams->life; + pthis->draw = EffectSsDtBubble_Draw; + pthis->update = EffectSsDtBubble_Update; + + return 1; +} + +void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale; + + OPEN_DISPS(gfxCtx, "../z_eff_ss_dt_bubble.c", 201); + + scale = pthis->rScale * 0.004f; + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_dt_bubble.c", 213), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_80093C14(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + (pthis->rPrimColorA * pthis->life) / pthis->rLifespan); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, + (pthis->rEnvColorA * pthis->life) / pthis->rLifespan); + gSPSegment(POLY_XLU_DISP++, 0x08, pthis->gfx); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffBubbleDL)); + + CLOSE_DISPS(gfxCtx, "../z_eff_ss_dt_bubble.c", 236); +} + +void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + f32 rand; + + if (pthis->rRandXZ == 1) { + rand = Rand_ZeroOne(); + pthis->pos.x += (rand * 2.0f) - 1.0f; + + rand = Rand_ZeroOne(); + pthis->pos.z += (rand * 2.0f) - 1.0f; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c deleted file mode 100644 index 1f3c20bce..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c +++ /dev/null @@ -1,196 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_DUST_Z_EFF_SS_DUST_C -#include "actor_common.h" -/* - * File: z_eff_ss_dust.c - * Overlay: ovl_Effect_Ss_Dust - * Description: Dust Particle Effect - */ - -#include "z_eff_ss_dust.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define rPrimColorR regs[0] -#define rPrimColorG regs[1] -#define rPrimColorB regs[2] -#define rPrimColorA regs[3] -#define rEnvColorR regs[4] -#define rEnvColorG regs[5] -#define rEnvColorB regs[6] -#define rEnvColorA regs[7] -#define rTexIdx regs[8] // this reg is also used to set specific colors in the fire update function -#define rScale regs[9] -#define rScaleStep regs[10] -#define rDrawFlags regs[11] -#define rLifespan regs[12] - -u32 EffectSsDust_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDust_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBlast_UpdateFire(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDust_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); - -EffectSsInit Effect_Ss_Dust_InitVars = { - EFFECT_SS_DUST, - EffectSsDust_Init, -}; - -static EffectSsUpdateFunc sUpdateFuncs[] = { - EffectSsDust_Update, - EffectSsBlast_UpdateFire, -}; - -u32 EffectSsDust_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - s32 randColorOffset; - EffectSsDustInitParams* initParams = (EffectSsDustInitParams*)initParamsx; - - Math_Vec3f_Copy(&this->pos, &initParams->pos); - Math_Vec3f_Copy(&this->velocity, &initParams->velocity); - Math_Vec3f_Copy(&this->accel, &initParams->accel); - this->gfx = SEGMENTED_TO_VIRTUAL(gEffDustDL); - this->life = initParams->life; - this->update = sUpdateFuncs[initParams->updateMode]; - this->draw = EffectSsDust_Draw; - - if (initParams->drawFlags & 4) { - randColorOffset = Rand_ZeroOne() * 20.0f - 10.0f; - this->rPrimColorR = initParams->primColor.r + randColorOffset; - this->rPrimColorG = initParams->primColor.g + randColorOffset; - this->rPrimColorB = initParams->primColor.b + randColorOffset; - this->rEnvColorR = initParams->envColor.r + randColorOffset; - this->rEnvColorG = initParams->envColor.g + randColorOffset; - this->rEnvColorB = initParams->envColor.b + randColorOffset; - } else { - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - } - - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorA = initParams->envColor.a; - this->rTexIdx = 0; - this->rScale = initParams->scale; - this->rScaleStep = initParams->scaleStep; - this->rLifespan = initParams->life; - this->rDrawFlags = initParams->drawFlags; - - return 1; -} - -void EffectSsDust_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - static void* dustTextures[] = { - gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, - }; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - MtxF mfTrans; - MtxF mfScale; - MtxF mfResult; - MtxF mfTrans11DA0; - s32 pad; - Mtx* mtx; - f32 scale; - - OPEN_DISPS(gfxCtx, "../z_eff_ss_dust.c", 321); - - scale = this->rScale * 0.0025f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); - SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); - gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); - - if (mtx != NULL) { - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTextures[this->rTexIdx])); - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gDPPipeSync(POLY_XLU_DISP++); - - if (this->rDrawFlags & 1) { - gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, - COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED); - gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); - gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - } else if (this->rDrawFlags & 2) { - gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); - gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - } else { - gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); - } - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); - } - - CLOSE_DISPS(gfxCtx, "../z_eff_ss_dust.c", 389); -} - -void EffectSsDust_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; - this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; - - if ((this->life <= this->rLifespan) && (this->life >= (this->rLifespan - 7))) { - if (this->rLifespan >= 5) { - this->rTexIdx = this->rLifespan - this->life; - } else { - this->rTexIdx = ((this->rLifespan - this->life) * (8 / this->rLifespan)); - } - } else { - this->rTexIdx = 7; - } - - this->rScale += this->rScaleStep; -} - -// this update mode is unused in the original game -void EffectSsBlast_UpdateFire(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; - this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; - - switch (this->rTexIdx) { - case 0: - this->rPrimColorR = 255; - this->rPrimColorG = 150; - this->rPrimColorB = 0; - this->rEnvColorR = 150; - this->rEnvColorG = 50; - this->rEnvColorB = 0; - break; - case 1: - this->rPrimColorR = 200; - this->rPrimColorG = 50; - this->rPrimColorB = 0; - this->rEnvColorR = 100; - this->rEnvColorG = 0; - this->rEnvColorB = 0; - break; - case 2: - this->rPrimColorR = 50; - this->rPrimColorG = 0; - this->rPrimColorB = 0; - this->rEnvColorR = 0; - this->rEnvColorG = 0; - this->rEnvColorB = 0; - break; - case 3: - this->rPrimColorR = 50; - this->rEnvColorR = this->rPrimColorG = this->rEnvColorG = this->rPrimColorB = this->rEnvColorB = 0; - break; - } - - if (this->rTexIdx < 7) { - this->rTexIdx++; - } - - this->rScale += this->rScaleStep; -} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.cpp b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.cpp new file mode 100644 index 000000000..31d0c5f71 --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.cpp @@ -0,0 +1,196 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_DUST_Z_EFF_SS_DUST_C +#include "actor_common.h" +/* + * File: z_eff_ss_dust.c + * Overlay: ovl_Effect_Ss_Dust + * Description: Dust Particle Effect + */ + +#include "z_eff_ss_dust.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rTexIdx regs[8] // pthis reg is also used to set specific colors in the fire update function +#define rScale regs[9] +#define rScaleStep regs[10] +#define rDrawFlags regs[11] +#define rLifespan regs[12] + +u32 EffectSsDust_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsDust_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsBlast_UpdateFire(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsDust_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +EffectSsInit Effect_Ss_Dust_InitVars = { + EFFECT_SS_DUST, + EffectSsDust_Init, +}; + +static EffectSsUpdateFunc sUpdateFuncs[] = { + EffectSsDust_Update, + EffectSsBlast_UpdateFire, +}; + +u32 EffectSsDust_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + s32 randColorOffset; + EffectSsDustInitParams* initParams = (EffectSsDustInitParams*)initParamsx; + + Math_Vec3f_Copy(&pthis->pos, &initParams->pos); + Math_Vec3f_Copy(&pthis->velocity, &initParams->velocity); + Math_Vec3f_Copy(&pthis->accel, &initParams->accel); + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffDustDL); + pthis->life = initParams->life; + pthis->update = sUpdateFuncs[initParams->updateMode]; + pthis->draw = EffectSsDust_Draw; + + if (initParams->drawFlags & 4) { + randColorOffset = Rand_ZeroOne() * 20.0f - 10.0f; + pthis->rPrimColorR = initParams->primColor.r + randColorOffset; + pthis->rPrimColorG = initParams->primColor.g + randColorOffset; + pthis->rPrimColorB = initParams->primColor.b + randColorOffset; + pthis->rEnvColorR = initParams->envColor.r + randColorOffset; + pthis->rEnvColorG = initParams->envColor.g + randColorOffset; + pthis->rEnvColorB = initParams->envColor.b + randColorOffset; + } else { + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + } + + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorA = initParams->envColor.a; + pthis->rTexIdx = 0; + pthis->rScale = initParams->scale; + pthis->rScaleStep = initParams->scaleStep; + pthis->rLifespan = initParams->life; + pthis->rDrawFlags = initParams->drawFlags; + + return 1; +} + +void EffectSsDust_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + static void* dustTextures[] = { + gDust1Tex, gDust2Tex, gDust3Tex, gDust4Tex, gDust5Tex, gDust6Tex, gDust7Tex, gDust8Tex, + }; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTrans11DA0; + s32 pad; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(gfxCtx, "../z_eff_ss_dust.c", 321); + + scale = pthis->rScale * 0.0025f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); + SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTextures[pthis->rTexIdx])); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gDPPipeSync(POLY_XLU_DISP++); + + if (pthis->rDrawFlags & 1) { + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, + COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } else if (pthis->rDrawFlags & 2) { + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } else { + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + } + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); + } + + CLOSE_DISPS(gfxCtx, "../z_eff_ss_dust.c", 389); +} + +void EffectSsDust_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + pthis->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + + if ((pthis->life <= pthis->rLifespan) && (pthis->life >= (pthis->rLifespan - 7))) { + if (pthis->rLifespan >= 5) { + pthis->rTexIdx = pthis->rLifespan - pthis->life; + } else { + pthis->rTexIdx = ((pthis->rLifespan - pthis->life) * (8 / pthis->rLifespan)); + } + } else { + pthis->rTexIdx = 7; + } + + pthis->rScale += pthis->rScaleStep; +} + +// pthis update mode is unused in the original game +void EffectSsBlast_UpdateFire(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + pthis->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + + switch (pthis->rTexIdx) { + case 0: + pthis->rPrimColorR = 255; + pthis->rPrimColorG = 150; + pthis->rPrimColorB = 0; + pthis->rEnvColorR = 150; + pthis->rEnvColorG = 50; + pthis->rEnvColorB = 0; + break; + case 1: + pthis->rPrimColorR = 200; + pthis->rPrimColorG = 50; + pthis->rPrimColorB = 0; + pthis->rEnvColorR = 100; + pthis->rEnvColorG = 0; + pthis->rEnvColorB = 0; + break; + case 2: + pthis->rPrimColorR = 50; + pthis->rPrimColorG = 0; + pthis->rPrimColorB = 0; + pthis->rEnvColorR = 0; + pthis->rEnvColorG = 0; + pthis->rEnvColorB = 0; + break; + case 3: + pthis->rPrimColorR = 50; + pthis->rEnvColorR = pthis->rPrimColorG = pthis->rEnvColorG = pthis->rPrimColorB = pthis->rEnvColorB = 0; + break; + } + + if (pthis->rTexIdx < 7) { + pthis->rTexIdx++; + } + + pthis->rScale += pthis->rScaleStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.cpp similarity index 53% rename from src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c rename to src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.cpp index dd3870321..d3c38fb0e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.cpp @@ -25,52 +25,52 @@ #define rFlags regs[8] #define rScroll regs[9] -u32 EffectSsEnFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsEnFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsEnFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsEnFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_En_Fire_InitVars = { EFFECT_SS_EN_FIRE, EffectSsEnFire_Init, }; -u32 EffectSsEnFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsEnFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsEnFireInitParams* initParams = (EffectSsEnFireInitParams*)initParamsx; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - this->pos = initParams->pos; - this->velocity = this->accel = zeroVec; - this->life = 20; - this->rLifespan = this->life; - this->actor = initParams->actor; - this->rScroll = Rand_ZeroOne() * 20.0f; - this->draw = EffectSsEnFire_Draw; - this->update = EffectSsEnFire_Update; - this->rUnused = -15; + pthis->pos = initParams->pos; + pthis->velocity = pthis->accel = zeroVec; + pthis->life = 20; + pthis->rLifespan = pthis->life; + pthis->actor = initParams->actor; + pthis->rScroll = Rand_ZeroOne() * 20.0f; + pthis->draw = EffectSsEnFire_Draw; + pthis->update = EffectSsEnFire_Update; + pthis->rUnused = -15; if (initParams->bodyPart < 0) { - this->rYaw = Math_Vec3f_Yaw(&initParams->actor->world.pos, &initParams->pos) - initParams->actor->shape.rot.y; - this->rPitch = + pthis->rYaw = Math_Vec3f_Yaw(&initParams->actor->world.pos, &initParams->pos) - initParams->actor->shape.rot.y; + pthis->rPitch = Math_Vec3f_Pitch(&initParams->actor->world.pos, &initParams->pos) - initParams->actor->shape.rot.x; - this->vec.z = Math_Vec3f_DistXYZ(&initParams->pos, &initParams->actor->world.pos); + pthis->vec.z = Math_Vec3f_DistXYZ(&initParams->pos, &initParams->actor->world.pos); } - this->rScaleMax = initParams->scale; + pthis->rScaleMax = initParams->scale; if ((initParams->unk_12 & 0x8000) != 0) { - this->rScale = initParams->scale; + pthis->rScale = initParams->scale; } else { - this->rScale = 0; + pthis->rScale = 0; } - this->rReg6 = initParams->unk_12 & 0x7FFF; - this->rBodyPart = initParams->bodyPart; - this->rFlags = initParams->flags; + pthis->rReg6 = initParams->unk_12 & 0x7FFF; + pthis->rBodyPart = initParams->bodyPart; + pthis->rFlags = initParams->flags; return 1; } -void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; f32 scale; s16 camYaw; @@ -79,16 +79,16 @@ void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx, "../z_eff_en_fire.c", 169); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); camYaw = (Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000); Matrix_RotateY(camYaw * (M_PI / 0x8000), MTXMODE_APPLY); - scale = Math_SinS(this->life * 0x333) * (this->rScale * 0.00005f); + scale = Math_SinS(pthis->life * 0x333) * (pthis->rScale * 0.00005f); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_eff_en_fire.c", 180), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - redGreen = this->life - 5; + redGreen = pthis->life - 5; if (redGreen < 0) { redGreen = 0; @@ -98,10 +98,10 @@ void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { gDPSetEnvColor(POLY_XLU_DISP++, redGreen * 12.7f, 0, 0, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0x0, 0x80, redGreen * 12.7f, redGreen * 12.7f, 0, 255); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->rScroll * -0x14) & 0x1FF, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (pthis->rScroll * -0x14) & 0x1FF, 0x20, 0x80)); - if (((this->rFlags & 0x7FFF) != 0) || (this->life < 18)) { + if (((pthis->rFlags & 0x7FFF) != 0) || (pthis->life < 18)) { gSPDisplayList(POLY_XLU_DISP++, gEffFire2DL); } else { gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); @@ -120,38 +120,38 @@ typedef struct { /* 0x14C */ Vec3s firePos[10]; } FireActorS; -void EffectSsEnFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsEnFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { - this->rScroll++; + pthis->rScroll++; - if (this->actor != NULL) { - if (this->actor->colorFilterTimer >= 22) { - this->life++; + if (pthis->actor != NULL) { + if (pthis->actor->colorFilterTimer >= 22) { + pthis->life++; } - if (this->actor->update != NULL) { - Math_SmoothStepToS(&this->rScale, this->rScaleMax, 1, this->rScaleMax >> 3, 0); + if (pthis->actor->update != NULL) { + Math_SmoothStepToS((s16*)&pthis->rScale, pthis->rScaleMax, 1, pthis->rScaleMax >> 3, 0); - if (this->rBodyPart < 0) { - Matrix_Translate(this->actor->world.pos.x, this->actor->world.pos.y, this->actor->world.pos.z, + if (pthis->rBodyPart < 0) { + Matrix_Translate(pthis->actor->world.pos.x, pthis->actor->world.pos.y, pthis->actor->world.pos.z, MTXMODE_NEW); - Matrix_RotateY((this->rYaw + this->actor->shape.rot.y) * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX((this->rPitch + this->actor->shape.rot.x) * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultVec3f(&this->vec, &this->pos); + Matrix_RotateY((pthis->rYaw + pthis->actor->shape.rot.y) * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX((pthis->rPitch + pthis->actor->shape.rot.x) * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&pthis->vec, &pthis->pos); } else { - if ((this->rFlags & 0x8000)) { - this->pos.x = ((FireActorS*)this->actor)->firePos[this->rBodyPart].x; - this->pos.y = ((FireActorS*)this->actor)->firePos[this->rBodyPart].y; - this->pos.z = ((FireActorS*)this->actor)->firePos[this->rBodyPart].z; + if ((pthis->rFlags & 0x8000)) { + pthis->pos.x = ((FireActorS*)pthis->actor)->firePos[pthis->rBodyPart].x; + pthis->pos.y = ((FireActorS*)pthis->actor)->firePos[pthis->rBodyPart].y; + pthis->pos.z = ((FireActorS*)pthis->actor)->firePos[pthis->rBodyPart].z; } else { - this->pos.x = ((FireActorF*)this->actor)->firePos[this->rBodyPart].x; - this->pos.y = ((FireActorF*)this->actor)->firePos[this->rBodyPart].y; - this->pos.z = ((FireActorF*)this->actor)->firePos[this->rBodyPart].z; + pthis->pos.x = ((FireActorF*)pthis->actor)->firePos[pthis->rBodyPart].x; + pthis->pos.y = ((FireActorF*)pthis->actor)->firePos[pthis->rBodyPart].y; + pthis->pos.z = ((FireActorF*)pthis->actor)->firePos[pthis->rBodyPart].z; } } - } else if (this->rReg6 != 0) { - this->life = 0; + } else if (pthis->rReg6 != 0) { + pthis->life = 0; } else { - this->actor = NULL; + pthis->actor = NULL; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c deleted file mode 100644 index 2a6e3294c..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c +++ /dev/null @@ -1,173 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_EN_ICE_Z_EFF_SS_EN_ICE_C -#include "actor_common.h" -/* - * File: z_eff_ss_en_ice.c - * Overlay: ovl_Effect_Ss_En_Ice - * Description: Ice clumps - */ - -#include "z_eff_ss_en_ice.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_math_atan.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" - -#define rLifespan regs[0] -#define rYaw regs[1] -#define rPitch regs[2] -#define rRotSpeed regs[3] -#define rPrimColorR regs[4] -#define rPrimColorG regs[5] -#define rPrimColorB regs[6] -#define rPrimColorA regs[7] -#define rEnvColorR regs[8] -#define rEnvColorG regs[9] -#define rEnvColorB regs[10] -#define rAlphaMode regs[11] -#define rScale regs[12] - -u32 EffectSsEnIce_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsEnIce_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsEnIce_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsEnIce_UpdateFlying(GlobalContext* globalCtx, u32 index, EffectSs* this); - -EffectSsInit Effect_Ss_En_Ice_InitVars = { - EFFECT_SS_EN_ICE, - EffectSsEnIce_Init, -}; - -u32 EffectSsEnIce_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsEnIceInitParams* initParams = (EffectSsEnIceInitParams*)initParamsx; - - if (initParams->type == 0) { - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - - this->pos = initParams->pos; - this->vec.x = this->pos.x - initParams->actor->world.pos.x; - this->vec.y = this->pos.y - initParams->actor->world.pos.y; - this->vec.z = this->pos.z - initParams->actor->world.pos.z; - this->velocity = zeroVec; - this->accel = zeroVec; - this->life = 10; - this->actor = initParams->actor; - this->draw = EffectSsEnIce_Draw; - this->update = EffectSsEnIce_UpdateFlying; - this->rScale = initParams->scale * 100.0f; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rAlphaMode = 1; - this->rPitch = Rand_CenteredFloat(65536.0f); - } else if (initParams->type == 1) { - this->pos = initParams->pos; - this->vec = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = initParams->life; - this->draw = EffectSsEnIce_Draw; - this->update = EffectSsEnIce_Update; - this->rLifespan = initParams->life; - this->rScale = initParams->scale * 100.0f; - this->rYaw = Math_Atan2S(initParams->velocity.z, initParams->velocity.x); - this->rPitch = 0; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rAlphaMode = 0; - } else { - osSyncPrintf("Effect_Ss_En_Ice_ct():pid->mode_swがエラーです。\n"); - return 0; - } - - return 1; -} - -void EffectSsEnIce_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad; - f32 scale; - Vec3f hiliteLightDir; - u32 gameplayFrames; - f32 alpha; - - scale = this->rScale * 0.01f; - gameplayFrames = globalCtx->gameplayFrames; - - OPEN_DISPS(gfxCtx, "../z_eff_en_ice.c", 235); - - if (this->rAlphaMode != 0) { - alpha = this->life * 12; - } else { - if ((this->rLifespan > 0) && (this->life < (this->rLifespan >> 1))) { - alpha = ((this->life * 2.0f) / this->rLifespan); - alpha *= 255.0f; - } else { - alpha = 255.0f; - } - } - - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_RotateY(this->rYaw * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX(this->rPitch * (M_PI / 0x8000), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_en_ice.c", 261), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - hiliteLightDir.x = 89.8f; - hiliteLightDir.y = 0.0f; - hiliteLightDir.z = 89.8f; - - func_80093D84(globalCtx->state.gfxCtx); - func_8002EB44(&this->pos, &globalCtx->view.eye, &hiliteLightDir, globalCtx->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 0x20, 0x10, 1, 0, - (gameplayFrames * 2) & 0xFF, 0x40, 0x20)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, (u32)alpha); - gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2DL); - - CLOSE_DISPS(gfxCtx, "../z_eff_en_ice.c", 294); -} - -void EffectSsEnIce_UpdateFlying(GlobalContext* globalCtx, u32 index, EffectSs* this) { - s16 rand; - - if ((this->actor != NULL) && (this->actor->update != NULL)) { - if ((this->life >= 9) && (this->actor->colorFilterTimer != 0) && (!(this->actor->colorFilterParams & 0xC000))) { - this->pos.x = this->actor->world.pos.x + this->vec.x; - this->pos.y = this->actor->world.pos.y + this->vec.y; - this->pos.z = this->actor->world.pos.z + this->vec.z; - this->life++; - } else if (this->life == 9) { - this->accel.x = Math_SinS(Math_Vec3f_Yaw(&this->actor->world.pos, &this->pos)) * (Rand_ZeroOne() + 1.0f); - this->accel.z = Math_CosS(Math_Vec3f_Yaw(&this->actor->world.pos, &this->pos)) * (Rand_ZeroOne() + 1.0f); - this->accel.y = -1.5f; - this->velocity.y = 5.0f; - } - } else { - if (this->life >= 9) { - rand = Rand_CenteredFloat(65535.0f); - this->accel.x = Math_SinS(rand) * (Rand_ZeroOne() + 1.0f); - this->accel.z = Math_CosS(rand) * (Rand_ZeroOne() + 1.0f); - this->life = 8; - this->accel.y = -1.5f; - this->velocity.y = 5.0f; - } - } -} - -void EffectSsEnIce_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rPitch += this->rRotSpeed; // rRotSpeed is not initialized so this does nothing -} diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.cpp b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.cpp new file mode 100644 index 000000000..391e70d6a --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.cpp @@ -0,0 +1,173 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_EN_ICE_Z_EFF_SS_EN_ICE_C +#include "actor_common.h" +/* + * File: z_eff_ss_en_ice.c + * Overlay: ovl_Effect_Ss_En_Ice + * Description: Ice clumps + */ + +#include "z_eff_ss_en_ice.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_math_atan.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" + +#define rLifespan regs[0] +#define rYaw regs[1] +#define rPitch regs[2] +#define rRotSpeed regs[3] +#define rPrimColorR regs[4] +#define rPrimColorG regs[5] +#define rPrimColorB regs[6] +#define rPrimColorA regs[7] +#define rEnvColorR regs[8] +#define rEnvColorG regs[9] +#define rEnvColorB regs[10] +#define rAlphaMode regs[11] +#define rScale regs[12] + +u32 EffectSsEnIce_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsEnIce_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsEnIce_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsEnIce_UpdateFlying(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +EffectSsInit Effect_Ss_En_Ice_InitVars = { + EFFECT_SS_EN_ICE, + EffectSsEnIce_Init, +}; + +u32 EffectSsEnIce_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + EffectSsEnIceInitParams* initParams = (EffectSsEnIceInitParams*)initParamsx; + + if (initParams->type == 0) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + pthis->pos = initParams->pos; + pthis->vec.x = pthis->pos.x - initParams->actor->world.pos.x; + pthis->vec.y = pthis->pos.y - initParams->actor->world.pos.y; + pthis->vec.z = pthis->pos.z - initParams->actor->world.pos.z; + pthis->velocity = zeroVec; + pthis->accel = zeroVec; + pthis->life = 10; + pthis->actor = initParams->actor; + pthis->draw = EffectSsEnIce_Draw; + pthis->update = EffectSsEnIce_UpdateFlying; + pthis->rScale = initParams->scale * 100.0f; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rAlphaMode = 1; + pthis->rPitch = Rand_CenteredFloat(65536.0f); + } else if (initParams->type == 1) { + pthis->pos = initParams->pos; + pthis->vec = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = initParams->life; + pthis->draw = EffectSsEnIce_Draw; + pthis->update = EffectSsEnIce_Update; + pthis->rLifespan = initParams->life; + pthis->rScale = initParams->scale * 100.0f; + pthis->rYaw = Math_Atan2S(initParams->velocity.z, initParams->velocity.x); + pthis->rPitch = 0; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rAlphaMode = 0; + } else { + osSyncPrintf("Effect_Ss_En_Ice_ct():pid->mode_swがエラーです。\n"); + return 0; + } + + return 1; +} + +void EffectSsEnIce_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + f32 scale; + Vec3f hiliteLightDir; + u32 gameplayFrames; + f32 alpha; + + scale = pthis->rScale * 0.01f; + gameplayFrames = globalCtx->gameplayFrames; + + OPEN_DISPS(gfxCtx, "../z_eff_en_ice.c", 235); + + if (pthis->rAlphaMode != 0) { + alpha = pthis->life * 12; + } else { + if ((pthis->rLifespan > 0) && (pthis->life < (pthis->rLifespan >> 1))) { + alpha = ((pthis->life * 2.0f) / pthis->rLifespan); + alpha *= 255.0f; + } else { + alpha = 255.0f; + } + } + + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateY(pthis->rYaw * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->rPitch * (M_PI / 0x8000), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_en_ice.c", 261), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + hiliteLightDir.x = 89.8f; + hiliteLightDir.y = 0.0f; + hiliteLightDir.z = 89.8f; + + func_80093D84(globalCtx->state.gfxCtx); + func_8002EB44(&pthis->pos, &globalCtx->view.eye, &hiliteLightDir, globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 0x20, 0x10, 1, 0, + (gameplayFrames * 2) & 0xFF, 0x40, 0x20)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, (u32)alpha); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2DL); + + CLOSE_DISPS(gfxCtx, "../z_eff_en_ice.c", 294); +} + +void EffectSsEnIce_UpdateFlying(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + s16 rand; + + if ((pthis->actor != NULL) && (pthis->actor->update != NULL)) { + if ((pthis->life >= 9) && (pthis->actor->colorFilterTimer != 0) && (!(pthis->actor->colorFilterParams & 0xC000))) { + pthis->pos.x = pthis->actor->world.pos.x + pthis->vec.x; + pthis->pos.y = pthis->actor->world.pos.y + pthis->vec.y; + pthis->pos.z = pthis->actor->world.pos.z + pthis->vec.z; + pthis->life++; + } else if (pthis->life == 9) { + pthis->accel.x = Math_SinS(Math_Vec3f_Yaw(&pthis->actor->world.pos, &pthis->pos)) * (Rand_ZeroOne() + 1.0f); + pthis->accel.z = Math_CosS(Math_Vec3f_Yaw(&pthis->actor->world.pos, &pthis->pos)) * (Rand_ZeroOne() + 1.0f); + pthis->accel.y = -1.5f; + pthis->velocity.y = 5.0f; + } + } else { + if (pthis->life >= 9) { + rand = Rand_CenteredFloat(65535.0f); + pthis->accel.x = Math_SinS(rand) * (Rand_ZeroOne() + 1.0f); + pthis->accel.z = Math_CosS(rand) * (Rand_ZeroOne() + 1.0f); + pthis->life = 8; + pthis->accel.y = -1.5f; + pthis->velocity.y = 5.0f; + } + } +} + +void EffectSsEnIce_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rPitch += pthis->rRotSpeed; // rRotSpeed is not initialized so pthis does nothing +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.cpp similarity index 69% rename from src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c rename to src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.cpp index 8ddf72624..f1fcaf38d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.cpp @@ -17,9 +17,9 @@ #define rScoreIdx regs[2] #define rScale regs[3] -u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); static s16 sScores[] = { 30, 60, 100 }; @@ -28,7 +28,7 @@ EffectSsInit Effect_Ss_Extra_InitVars = { EffectSsExtra_Init, }; -u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsExtraInitParams* initParams = (EffectSsExtraInitParams*)initParamsx; s32 pad; s32 objBankIndex; @@ -38,17 +38,17 @@ u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void if ((objBankIndex >= 0) && Object_IsLoaded(&globalCtx->objectCtx, objBankIndex)) { oldSeg6 = gSegments[6]; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIndex].vromStart); - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->draw = EffectSsExtra_Draw; - this->update = EffectSsExtra_Update; - this->life = 50; - this->rScoreIdx = initParams->scoreIdx; - this->rScale = initParams->scale; - this->rTimer = 5; - this->rObjBankIdx = objBankIndex; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIndex].vromStart.get()); + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->draw = EffectSsExtra_Draw; + pthis->update = EffectSsExtra_Update; + pthis->life = 50; + pthis->rScoreIdx = initParams->scoreIdx; + pthis->rScale = initParams->scale; + pthis->rTimer = 5; + pthis->rObjBankIdx = objBankIndex; gSegments[6] = oldSeg6; return 1; @@ -63,35 +63,35 @@ static void* sTextures[] = { object_yabusame_point_Tex_000900, }; -void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 pad; - f32 scale = this->rScale / 100.0f; - void* object = gObjectTable[this->rObjBankIdx].vromStart; + f32 scale = pthis->rScale / 100.0f; + void* object = gObjectTable[pthis->rObjBankIdx].vromStart.buffer(); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_extra.c", 168); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); func_80093D84(globalCtx->state.gfxCtx); func_800D1FD4(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_eff_ss_extra.c", 186), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rScoreIdx])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[pthis->rScoreIdx])); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_yabusame_point_DL_000DC0)); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_extra.c", 194); } -void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if (this->rTimer != 0) { - this->rTimer -= 1; +void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if (pthis->rTimer != 0) { + pthis->rTimer -= 1; } else { - this->velocity.y = 0.0f; + pthis->velocity.y = 0.0f; } - if (this->rTimer == 1) { - globalCtx->interfaceCtx.unk_23C = sScores[this->rScoreIdx]; + if (pthis->rTimer == 1) { + globalCtx->interfaceCtx.unk_23C = sScores[pthis->rScoreIdx]; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Fcircle/z_eff_ss_fcircle.c b/src/overlays/effects/ovl_Effect_Ss_Fcircle/z_eff_ss_fcircle.cpp similarity index 55% rename from src/overlays/effects/ovl_Effect_Ss_Fcircle/z_eff_ss_fcircle.c rename to src/overlays/effects/ovl_Effect_Ss_Fcircle/z_eff_ss_fcircle.cpp index bafe6062c..a7aa75f5e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fcircle/z_eff_ss_fcircle.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fcircle/z_eff_ss_fcircle.cpp @@ -18,36 +18,36 @@ #define rYaw regs[10] #define rScale regs[11] -u32 EffectSsFcircle_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsFcircle_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFcircle_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsFcircle_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsFcircle_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsFcircle_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Fcircle_InitVars = { EFFECT_SS_FCIRCLE, EffectSsFcircle_Init, }; -u32 EffectSsFcircle_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsFcircle_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsFcircleInitParams* initParams = (EffectSsFcircleInitParams*)initParamsx; - this->pos = initParams->pos; - this->actor = initParams->actor; - this->vec.x = initParams->pos.x - initParams->actor->world.pos.x; - this->vec.y = initParams->pos.y - initParams->actor->world.pos.y; - this->vec.z = initParams->pos.z - initParams->actor->world.pos.z; - this->gfx = gEffFireCircleDL; - this->life = 20; - this->draw = EffectSsFcircle_Draw; - this->update = EffectSsFcircle_Update; - this->rUnused = 255; - this->rRadius = initParams->radius; - this->rHeight = initParams->height; - this->rYaw = initParams->actor->shape.rot.y; + pthis->pos = initParams->pos; + pthis->actor = initParams->actor; + pthis->vec.x = initParams->pos.x - initParams->actor->world.pos.x; + pthis->vec.y = initParams->pos.y - initParams->actor->world.pos.y; + pthis->vec.z = initParams->pos.z - initParams->actor->world.pos.z; + pthis->gfx = gEffFireCircleDL; + pthis->life = 20; + pthis->draw = EffectSsFcircle_Draw; + pthis->update = EffectSsFcircle_Update; + pthis->rUnused = 255; + pthis->rRadius = initParams->radius; + pthis->rHeight = initParams->height; + pthis->rYaw = initParams->actor->shape.rot.y; return 1; } -void EffectSsFcircle_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsFcircle_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; f32 yScale; @@ -56,45 +56,45 @@ void EffectSsFcircle_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx, "../z_eff_fcircle.c", 149); - scale = (this->rScale * (0.5f + (this->life * 0.025f))) * 0.01f; - yScale = (this->rHeight * 0.001f) * scale; - xzScale = (this->rRadius * 0.001f) * scale; + scale = (pthis->rScale * (0.5f + (pthis->life * 0.025f))) * 0.01f; + yScale = (pthis->rHeight * 0.001f) * scale; + xzScale = (pthis->rRadius * 0.001f) * scale; - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(xzScale, yScale, xzScale, MTXMODE_APPLY); - Matrix_RotateY(this->rYaw * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->rYaw * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_fcircle.c", 163), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, 0, 32, 64, 1, 0, ((globalCtx->gameplayFrames) * -0xF) % 256, 32, 64)); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, (this->life * 12.75f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, (pthis->life * 12.75f)); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_fcircle.c", 186); } -void EffectSsFcircle_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - Actor* actor = this->actor; +void EffectSsFcircle_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + Actor* actor = pthis->actor; if (actor != NULL) { if (actor->update != NULL) { - this->pos.x = actor->world.pos.x + this->vec.x; - this->pos.y = actor->world.pos.y + this->vec.y; - this->pos.z = actor->world.pos.z + this->vec.z; - this->rYaw = actor->shape.rot.y; + pthis->pos.x = actor->world.pos.x + pthis->vec.x; + pthis->pos.y = actor->world.pos.y + pthis->vec.y; + pthis->pos.z = actor->world.pos.z + pthis->vec.z; + pthis->rYaw = actor->shape.rot.y; if (actor->colorFilterTimer > 20) { - this->life = 20; + pthis->life = 20; } else { - this->life = actor->colorFilterTimer; + pthis->life = actor->colorFilterTimer; } - Math_StepToS(&this->rScale, 100, 20); + Math_StepToS((s16*)&pthis->rScale, 100, 20); } else { - this->actor = NULL; + pthis->actor = NULL; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.cpp similarity index 68% rename from src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c rename to src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.cpp index d8f921ac2..01db8a6cd 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.cpp @@ -21,21 +21,21 @@ #define rParam regs[4] #define rScale regs[8] -u32 EffectSsFhgFlash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsFhgFlash_DrawLightBall(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFhgFlash_UpdateLightBall(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFhgFlash_DrawShock(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFhgFlash_UpdateShock(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsFhgFlash_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsFhgFlash_DrawLightBall(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsFhgFlash_UpdateLightBall(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsFhgFlash_DrawShock(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsFhgFlash_UpdateShock(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Fhg_Flash_InitVars = { EFFECT_SS_FHG_FLASH, EffectSsFhgFlash_Init, }; -static UNK_TYPE D_809A5178[258]; -static Gfx D_809A5100[15]; +extern UNK_TYPE D_809A5178[258]; +extern Gfx D_809A5100[15]; -u32 EffectSsFhgFlash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsFhgFlash_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsFhgFlashInitParams* initParams = (EffectSsFhgFlashInitParams*)initParamsx; s32 pad; s32 objBankIdx; @@ -47,40 +47,40 @@ u32 EffectSsFhgFlash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, v objBankIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FHG); if ((objBankIdx > -1) && Object_IsLoaded(&globalCtx->objectCtx, objBankIdx)) { - oldSeg6 = gSegments[6]; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIdx].vromStart); - this->rObjBankIdx = objBankIdx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->rParam = initParams->param; - this->life = 100; - this->rScale = initParams->scale; - this->rAlpha = 255; - this->draw = EffectSsFhgFlash_DrawLightBall; - this->update = EffectSsFhgFlash_UpdateLightBall; - this->gfx = SEGMENTED_TO_VIRTUAL(gPhantomEnergyBallDL); - gSegments[6] = oldSeg6; + oldSeg6 = (void*)gSegments[6]; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIdx].vromStart.get()); + pthis->rObjBankIdx = objBankIdx; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->rParam = initParams->param; + pthis->life = 100; + pthis->rScale = initParams->scale; + pthis->rAlpha = 255; + pthis->draw = EffectSsFhgFlash_DrawLightBall; + pthis->update = EffectSsFhgFlash_UpdateLightBall; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gPhantomEnergyBallDL); + gSegments[6] = (uintptr_t)oldSeg6; } else { osSyncPrintf("Effect_Ss_Fhg_Flash_ct():pffd->modeエラー\n"); return 0; } } else { - this->actor = initParams->actor; - this->velocity = this->accel = zeroVec; - this->life = (s16)(Rand_ZeroOne() * 10.0f) + 111; - this->rScale = (s16)Rand_ZeroFloat(initParams->scale) + initParams->scale; - this->rAlpha = 255; - this->draw = EffectSsFhgFlash_DrawShock; - this->update = EffectSsFhgFlash_UpdateShock; - this->rParam = initParams->param; + pthis->actor = initParams->actor; + pthis->velocity = pthis->accel = zeroVec; + pthis->life = (s16)(Rand_ZeroOne() * 10.0f) + 111; + pthis->rScale = (s16)Rand_ZeroFloat(initParams->scale) + initParams->scale; + pthis->rAlpha = 255; + pthis->draw = EffectSsFhgFlash_DrawShock; + pthis->update = EffectSsFhgFlash_UpdateShock; + pthis->rParam = initParams->param; if (initParams->param != FHGFLASH_SHOCK_NO_ACTOR) { - this->pos = sp34; - this->gfx = SEGMENTED_TO_VIRTUAL(D_809A5100); + pthis->pos = sp34; + pthis->gfx = SEGMENTED_TO_VIRTUAL(D_809A5100); } else { - this->pos = initParams->pos; - this->gfx = SEGMENTED_TO_VIRTUAL(D_809A5100); + pthis->pos = initParams->pos; + pthis->gfx = SEGMENTED_TO_VIRTUAL(D_809A5100); } } return 1; @@ -91,49 +91,49 @@ static Color_RGB8 sColors[] = { { 255, 0, 255 }, { 255, 150, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, }; -void EffectSsFhgFlash_DrawLightBall(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsFhgFlash_DrawLightBall(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; f32 scale; void* object; - scale = this->rScale / 100.0f; - object = gObjectTable[this->rObjBankIdx].vromStart; + scale = pthis->rScale / 100.0f; + object = gObjectTable[pthis->rObjBankIdx].vromStart.buffer(); OPEN_DISPS(gfxCtx, "../z_eff_fhg_flash.c", 268); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, sColors[this->rParam].r, sColors[this->rParam].g, sColors[this->rParam].b, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, pthis->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, sColors[pthis->rParam].r, sColors[pthis->rParam].g, sColors[pthis->rParam].b, 0); gDPPipeSync(POLY_XLU_DISP++); func_800D1FD4(&globalCtx->billboardMtxF); - Matrix_RotateZ((this->rXZRot / 32768.0f) * 3.1416f, MTXMODE_APPLY); + Matrix_RotateZ((pthis->rXZRot / 32768.0f) * 3.1416f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_fhg_flash.c", 326), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_fhg_flash.c", 330); } -void EffectSsFhgFlash_DrawShock(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsFhgFlash_DrawShock(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; f32 scale; - scale = this->rScale / 100.0f; + scale = pthis->rScale / 100.0f; OPEN_DISPS(gfxCtx, "../z_eff_fhg_flash.c", 346); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - if (this->rParam != FHGFLASH_SHOCK_NO_ACTOR) { + if (pthis->rParam != FHGFLASH_SHOCK_NO_ACTOR) { func_80094044(globalCtx->state.gfxCtx); - Matrix_RotateX((this->rXZRot / 32768.0f) * 1.1416f, MTXMODE_APPLY); + Matrix_RotateX((pthis->rXZRot / 32768.0f) * 1.1416f, MTXMODE_APPLY); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_DECAL2); } else { func_80093D84(globalCtx->state.gfxCtx); @@ -142,68 +142,68 @@ void EffectSsFhgFlash_DrawShock(GlobalContext* globalCtx, u32 index, EffectSs* t } gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, pthis->rAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 155, 0); - Matrix_RotateZ((this->rXZRot / 32768.0f) * 3.1416f, MTXMODE_APPLY); + Matrix_RotateZ((pthis->rXZRot / 32768.0f) * 3.1416f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_fhg_flash.c", 395), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_fhg_flash.c", 399); } -void EffectSsFhgFlash_UpdateLightBall(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsFhgFlash_UpdateLightBall(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s16 rand = (Rand_ZeroOne() * 20000.0f); - this->rXZRot = (this->rXZRot + rand) + 0x4000; + pthis->rXZRot = (pthis->rXZRot + rand) + 0x4000; - if (this->rScale > 0) { - this->rScale -= 10; + if (pthis->rScale > 0) { + pthis->rScale -= 10; - if (this->rScale <= 0) { - this->rScale = 0; - this->life = 0; + if (pthis->rScale <= 0) { + pthis->rScale = 0; + pthis->life = 0; } } - if (this->rAlpha > 0) { - this->rAlpha -= 10; + if (pthis->rAlpha > 0) { + pthis->rAlpha -= 10; - if (this->rAlpha <= 0) { - this->rAlpha = 0; + if (pthis->rAlpha <= 0) { + pthis->rAlpha = 0; } } } -void EffectSsFhgFlash_UpdateShock(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsFhgFlash_UpdateShock(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s16 randBodypart; Player* player; BossGanondrof* phantomGanon; s16 rand; rand = (Rand_ZeroOne() * 20000.0f); - this->rXZRot = (this->rXZRot + rand) + 0x4000; + pthis->rXZRot = (pthis->rXZRot + rand) + 0x4000; - if (this->rParam == FHGFLASH_SHOCK_PLAYER) { + if (pthis->rParam == FHGFLASH_SHOCK_PLAYER) { player = GET_PLAYER(globalCtx); randBodypart = Rand_ZeroFloat(17.9f); - this->pos.x = player->bodyPartsPos[randBodypart].x + Rand_CenteredFloat(10.0f); - this->pos.y = player->bodyPartsPos[randBodypart].y + Rand_CenteredFloat(15.0f); - this->pos.z = player->bodyPartsPos[randBodypart].z + Rand_CenteredFloat(10.0f); - } else if (this->rParam == FHGFLASH_SHOCK_PG) { - phantomGanon = (BossGanondrof*)this->actor; + pthis->pos.x = player->bodyPartsPos[randBodypart].x + Rand_CenteredFloat(10.0f); + pthis->pos.y = player->bodyPartsPos[randBodypart].y + Rand_CenteredFloat(15.0f); + pthis->pos.z = player->bodyPartsPos[randBodypart].z + Rand_CenteredFloat(10.0f); + } else if (pthis->rParam == FHGFLASH_SHOCK_PG) { + phantomGanon = (BossGanondrof*)pthis->actor; randBodypart = Rand_ZeroFloat(23.9f); - this->pos.x = phantomGanon->bodyPartsPos[randBodypart].x + Rand_CenteredFloat(15.0f); - this->pos.y = phantomGanon->bodyPartsPos[randBodypart].y + Rand_CenteredFloat(20.0f); - this->pos.z = phantomGanon->bodyPartsPos[randBodypart].z + Rand_CenteredFloat(15.0f); + pthis->pos.x = phantomGanon->bodyPartsPos[randBodypart].x + Rand_CenteredFloat(15.0f); + pthis->pos.y = phantomGanon->bodyPartsPos[randBodypart].y + Rand_CenteredFloat(20.0f); + pthis->pos.z = phantomGanon->bodyPartsPos[randBodypart].z + Rand_CenteredFloat(15.0f); } - if (this->life < 100) { - this->rAlpha -= 50; + if (pthis->life < 100) { + pthis->rAlpha -= 50; - if (this->rAlpha < 0) { - this->rAlpha = 0; - this->life = 0; + if (pthis->rAlpha < 0) { + pthis->rAlpha = 0; + pthis->life = 0; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.cpp similarity index 54% rename from src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c rename to src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.cpp index 956df2e92..11e23b037 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.cpp @@ -27,51 +27,51 @@ #define rBodyPart regs[11] #define rType regs[12] -u32 EffectSsFireTail_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFireTail_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsFireTail_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsFireTail_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Fire_Tail_InitVars = { EFFECT_SS_FIRE_TAIL, EffectSsFireTail_Init, }; -u32 EffectSsFireTail_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsFireTail_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsFireTailInitParams* initParams = (EffectSsFireTailInitParams*)initParamsx; - this->pos = initParams->pos; - this->vec = initParams->unk_14; - this->velocity.x = 0.0f; - this->velocity.y = 0.0f; - this->velocity.z = 0.0f; - this->accel.x = 0.0f; - this->accel.y = 0.0f; - this->accel.z = 0.0f; - this->life = initParams->life; - this->actor = initParams->actor; - this->draw = EffectSsFireTail_Draw; - this->update = EffectSsFireTail_Update; - this->rScale = initParams->scale * 1000.0f; - this->rLifespan = initParams->life; - this->rReg2 = -0xA; - this->rReg3 = -0xF; + pthis->pos = initParams->pos; + pthis->vec = initParams->unk_14; + pthis->velocity.x = 0.0f; + pthis->velocity.y = 0.0f; + pthis->velocity.z = 0.0f; + pthis->accel.x = 0.0f; + pthis->accel.y = 0.0f; + pthis->accel.z = 0.0f; + pthis->life = initParams->life; + pthis->actor = initParams->actor; + pthis->draw = EffectSsFireTail_Draw; + pthis->update = EffectSsFireTail_Update; + pthis->rScale = initParams->scale * 1000.0f; + pthis->rLifespan = initParams->life; + pthis->rReg2 = -0xA; + pthis->rReg3 = -0xF; if (initParams->unk_20 == 0) { initParams->unk_20 = 1; } - this->rReg10 = initParams->unk_20; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rBodyPart = initParams->bodyPart; - this->rType = initParams->type; + pthis->rReg10 = initParams->unk_20; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rBodyPart = initParams->bodyPart; + pthis->rType = initParams->type; return 1; } -void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; s16 yaw; @@ -84,40 +84,40 @@ void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) scale.x = scale.y = scale.z = 0.0f; - if (this->actor != NULL) { + if (pthis->actor != NULL) { - this->vec = this->actor->velocity; + pthis->vec = pthis->actor->velocity; - if (this->rBodyPart < 0) { - Matrix_Translate(this->pos.x + this->actor->world.pos.x, this->pos.y + this->actor->world.pos.y, - this->pos.z + this->actor->world.pos.z, MTXMODE_NEW); + if (pthis->rBodyPart < 0) { + Matrix_Translate(pthis->pos.x + pthis->actor->world.pos.x, pthis->pos.y + pthis->actor->world.pos.y, + pthis->pos.z + pthis->actor->world.pos.z, MTXMODE_NEW); } else { Player* player = GET_PLAYER(globalCtx); - s16 bodyPart = this->rBodyPart; + s16 bodyPart = pthis->rBodyPart; - this->pos.x = + pthis->pos.x = player->bodyPartsPos[bodyPart].x - (Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))) * 5.0f); - this->pos.y = player->bodyPartsPos[bodyPart].y; - this->pos.z = + pthis->pos.y = player->bodyPartsPos[bodyPart].y; + pthis->pos.z = player->bodyPartsPos[bodyPart].z - (Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))) * 5.0f); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); } } else { - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); } - yaw = Math_Vec3f_Yaw(&scale, &this->vec) - Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + yaw = Math_Vec3f_Yaw(&scale, &pthis->vec) - Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); temp1 = fabsf(Math_CosS(yaw)); temp2 = Math_SinS(yaw); - dist = Math_Vec3f_DistXZ(&scale, &this->vec) / (this->rReg10 * 0.1f); + dist = Math_Vec3f_DistXZ(&scale, &pthis->vec) / (pthis->rReg10 * 0.1f); Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateZ(temp2 * this->rReg2 * dist * (M_PI / 180.0f), MTXMODE_APPLY); - temp2 = 1.0f - ((f32)(this->life + 1) / this->rLifespan); + Matrix_RotateZ(temp2 * pthis->rReg2 * dist * (M_PI / 180.0f), MTXMODE_APPLY); + temp2 = 1.0f - ((f32)(pthis->life + 1) / pthis->rLifespan); temp2 = 1.0f - SQ(temp2); - scale.x = scale.y = scale.z = temp2 * (this->rScale * 0.000010000001f); + scale.x = scale.y = scale.z = temp2 * (pthis->rScale * 0.000010000001f); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); - temp1 = (this->rReg3 * 0.01f * temp1 * dist) + 1.0f; + temp1 = (pthis->rReg3 * 0.01f * temp1 * dist) + 1.0f; if (temp1 < 0.1f) { temp1 = 0.1f; @@ -128,13 +128,13 @@ void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_eff_fire_tail.c", 238), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D84(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, 0); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (globalCtx->state.frames * -0x14) & 0x1FF, 32, 128)); - if (this->rType != 0) { + if (pthis->rType != 0) { gSPDisplayList(POLY_XLU_DISP++, gEffFire2DL); } else { gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); @@ -143,6 +143,6 @@ void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) CLOSE_DISPS(gfxCtx, "../z_eff_fire_tail.c", 273); } -void EffectSsFireTail_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rScale *= 0.9f; +void EffectSsFireTail_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rScale *= 0.9f; } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.cpp similarity index 57% rename from src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c rename to src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.cpp index f48cdf3ca..d8f25c252 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.cpp @@ -10,51 +10,51 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "def/z_effect_soft_sprite_old_init.h" -u32 EffectSsGFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsGFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_G_Fire_InitVars = { EFFECT_SS_G_FIRE, EffectSsGFire_Init, }; -u32 EffectSsGFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsGFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsGFireInitParams* initParams = (EffectSsGFireInitParams*)initParamsx; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - this->velocity = this->accel = zeroVec; - this->pos = initParams->pos; - this->draw = EffectSsGFire_Draw; - this->update = EffectSsGFire_Update; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffFireFootprintDL); - this->life = 8; - this->flags = 0; - this->rgScale = 200; - this->rgTexIdx = 0; - this->rgTexIdxStep = 50; - this->rgPrimColorR = 255; - this->rgPrimColorG = 220; - this->rgPrimColorB = 80; - this->rgPrimColorA = 255; - this->rgEnvColorR = 130; - this->rgEnvColorG = 30; - this->rgEnvColorB = 0; - this->rgEnvColorA = 0; + pthis->velocity = pthis->accel = zeroVec; + pthis->pos = initParams->pos; + pthis->draw = EffectSsGFire_Draw; + pthis->update = EffectSsGFire_Update; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffFireFootprintDL); + pthis->life = 8; + pthis->flags = 0; + pthis->rgScale = 200; + pthis->rgTexIdx = 0; + pthis->rgTexIdxStep = 50; + pthis->rgPrimColorR = 255; + pthis->rgPrimColorG = 220; + pthis->rgPrimColorB = 80; + pthis->rgPrimColorA = 255; + pthis->rgEnvColorR = 130; + pthis->rgEnvColorG = 30; + pthis->rgEnvColorB = 0; + pthis->rgEnvColorA = 0; return 1; } -void EffectSsGFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsGFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { void* fireFootprintTextures[] = { gEffFireFootprint1Tex, gEffFireFootprint2Tex, gEffFireFootprint3Tex, gEffFireFootprint4Tex, gEffFireFootprint5Tex, gEffFireFootprint6Tex, gEffFireFootprint7Tex, gEffFireFootprint8Tex, }; - s16 texIdx = (this->rgTexIdx / 100) % 7; + s16 texIdx = (pthis->rgTexIdx / 100) % 7; - EffectSs_DrawGEffect(globalCtx, this, fireFootprintTextures[texIdx]); + EffectSs_DrawGEffect(globalCtx, pthis, fireFootprintTextures[texIdx]); } -void EffectSsGFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rgTexIdx += this->rgTexIdxStep; +void EffectSsGFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rgTexIdx += pthis->rgTexIdxStep; } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Magma/z_eff_ss_g_magma.c b/src/overlays/effects/ovl_Effect_Ss_G_Magma/z_eff_ss_g_magma.cpp similarity index 58% rename from src/overlays/effects/ovl_Effect_Ss_G_Magma/z_eff_ss_g_magma.c rename to src/overlays/effects/ovl_Effect_Ss_G_Magma/z_eff_ss_g_magma.cpp index c2b9451e5..bb26ecaca 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Magma/z_eff_ss_g_magma.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Magma/z_eff_ss_g_magma.cpp @@ -11,36 +11,36 @@ #include "def/code_800FD970.h" #include "def/z_effect_soft_sprite_old_init.h" -u32 EffectSsGMagma_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGMagma_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGMagma_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGMagma_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsGMagma_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGMagma_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_G_Magma_InitVars = { EFFECT_SS_G_MAGMA, EffectSsGMagma_Init, }; -u32 EffectSsGMagma_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsGMagma_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsGMagmaInitParams* initParams = (EffectSsGMagmaInitParams*)initParamsx; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - this->velocity = this->accel = zeroVec; - this->pos = initParams->pos; - this->draw = EffectSsGMagma_Draw; - this->update = EffectSsGMagma_Update; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffMagmaBubbleDL); - this->life = 16; - this->rgScale = (s16)(Rand_ZeroOne() * 100.0f) + 200; - this->rgTexIdx = 0; - this->rgTexIdxStep = 50; - this->rgPrimColorR = 255; - this->rgPrimColorG = 255; - this->rgPrimColorB = 0; - this->rgPrimColorA = 255; - this->rgEnvColorR = 255; - this->rgEnvColorG = 0; - this->rgEnvColorB = 0; - this->rgEnvColorA = 0; + pthis->velocity = pthis->accel = zeroVec; + pthis->pos = initParams->pos; + pthis->draw = EffectSsGMagma_Draw; + pthis->update = EffectSsGMagma_Update; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffMagmaBubbleDL); + pthis->life = 16; + pthis->rgScale = (s16)(Rand_ZeroOne() * 100.0f) + 200; + pthis->rgTexIdx = 0; + pthis->rgTexIdxStep = 50; + pthis->rgPrimColorR = 255; + pthis->rgPrimColorG = 255; + pthis->rgPrimColorB = 0; + pthis->rgPrimColorA = 255; + pthis->rgEnvColorR = 255; + pthis->rgEnvColorG = 0; + pthis->rgEnvColorB = 0; + pthis->rgEnvColorA = 0; return 1; } @@ -50,16 +50,16 @@ static void* sTextures[] = { gEffMagmaBubble5Tex, gEffMagmaBubble6Tex, gEffMagmaBubble7Tex, gEffMagmaBubble8Tex, }; -void EffectSsGMagma_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - s16 texIdx = this->rgTexIdx / 100; +void EffectSsGMagma_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + s16 texIdx = pthis->rgTexIdx / 100; if (texIdx > 7) { texIdx = 7; } - EffectSs_DrawGEffect(globalCtx, this, sTextures[texIdx]); + EffectSs_DrawGEffect(globalCtx, pthis, sTextures[texIdx]); } -void EffectSsGMagma_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rgTexIdx += this->rgTexIdxStep; +void EffectSsGMagma_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rgTexIdx += pthis->rgTexIdxStep; } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.cpp similarity index 57% rename from src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c rename to src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.cpp index 3686c4699..cd30c6e3e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.cpp @@ -25,9 +25,9 @@ #define rObjBankIdx regs[10] #define rScale regs[11] -u32 EffectSsGMagma2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGMagma2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGMagma2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGMagma2_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsGMagma2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGMagma2_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); static void* sTextures[] = { object_kingdodongo_Tex_02E4E0, object_kingdodongo_Tex_02E8E0, object_kingdodongo_Tex_02ECE0, @@ -42,7 +42,7 @@ EffectSsInit Effect_Ss_G_Magma2_InitVars = { EffectSsGMagma2_Init, }; -u32 EffectSsGMagma2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsGMagma2_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_KINGDODONGO); s32 pad; @@ -50,25 +50,25 @@ u32 EffectSsGMagma2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, vo Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; EffectSsGMagma2InitParams* initParams = (EffectSsGMagma2InitParams*)initParamsx; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIndex].vromStart); - this->rObjBankIdx = objBankIndex; - this->pos = initParams->pos; - this->velocity = zeroVec; - this->accel = zeroVec; - this->life = 100; - this->draw = EffectSsGMagma2_Draw; - this->update = EffectSsGMagma2_Update; - this->gfx = SEGMENTED_TO_VIRTUAL(object_kingdodongo_DL_025A90); - this->rTexIdx = 0; - this->rDrawMode = initParams->drawMode; - this->rUpdateRate = initParams->updateRate; - this->rScale = initParams->scale; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorA = initParams->envColor.a; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIndex].vromStart.get()); + pthis->rObjBankIdx = objBankIndex; + pthis->pos = initParams->pos; + pthis->velocity = zeroVec; + pthis->accel = zeroVec; + pthis->life = 100; + pthis->draw = EffectSsGMagma2_Draw; + pthis->update = EffectSsGMagma2_Update; + pthis->gfx = SEGMENTED_TO_VIRTUAL(object_kingdodongo_DL_025A90); + pthis->rTexIdx = 0; + pthis->rDrawMode = initParams->drawMode; + pthis->rUpdateRate = initParams->updateRate; + pthis->rScale = initParams->scale; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorA = initParams->envColor.a; return 1; } @@ -76,60 +76,60 @@ u32 EffectSsGMagma2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, vo return 0; } -void EffectSsGMagma2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsGMagma2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; f32 scale; void* object; - scale = this->rScale / 100.0f; - object = gObjectTable[this->rObjBankIdx].vromStart; + scale = pthis->rScale / 100.0f; + object = gObjectTable[pthis->rObjBankIdx].vromStart.buffer(); OPEN_DISPS(gfxCtx, "../z_eff_ss_g_magma2.c", 261); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_g_magma2.c", 282), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->rDrawMode == 0) { + if (pthis->rDrawMode == 0) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x3D); } else { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, 0, this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, 0, this->rEnvColorA); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[this->rTexIdx])); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, 0, pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, 0, pthis->rEnvColorA); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[pthis->rTexIdx])); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_ss_g_magma2.c", 311); } -void EffectSsGMagma2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rTimer += this->rUpdateRate; +void EffectSsGMagma2_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rTimer += pthis->rUpdateRate; - if (this->rTimer >= 10) { - this->rTimer -= 10; - this->rTexIdx++; + if (pthis->rTimer >= 10) { + pthis->rTimer -= 10; + pthis->rTexIdx++; - if (this->rTexIdx >= 10) { - this->life = 0; + if (pthis->rTexIdx >= 10) { + pthis->life = 0; } - if (this->rDrawMode == 0) { - this->rPrimColorG -= 26; + if (pthis->rDrawMode == 0) { + pthis->rPrimColorG -= 26; - if (this->rPrimColorG <= 0) { - this->rPrimColorG = 0; + if (pthis->rPrimColorG <= 0) { + pthis->rPrimColorG = 0; } - this->rEnvColorR -= 26; + pthis->rEnvColorR -= 26; - if (this->rEnvColorR <= 0) { - this->rEnvColorR = 0; + if (pthis->rEnvColorR <= 0) { + pthis->rEnvColorR = 0; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.cpp similarity index 54% rename from src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c rename to src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.cpp index fbde9a092..bb28e692c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.cpp @@ -27,46 +27,46 @@ #define rEnvColorA regs[10] #define rLifespan regs[11] -u32 EffectSsGRipple_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGRipple_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGRipple_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGRipple_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsGRipple_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGRipple_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_G_Ripple_InitVars = { EFFECT_SS_G_RIPPLE, EffectSsGRipple_Init, }; -u32 EffectSsGRipple_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsGRipple_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { s32 pad; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; WaterBox* waterBox; EffectSsGRippleInitParams* initParams = (EffectSsGRippleInitParams*)initParamsx; waterBox = NULL; - this->velocity = this->accel = zeroVec; - this->pos = initParams->pos; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffWaterRippleDL); - this->life = initParams->life + 20; - this->flags = 0; - this->draw = EffectSsGRipple_Draw; - this->update = EffectSsGRipple_Update; - this->rRadius = initParams->radius; - this->rRadiusMax = initParams->radiusMax; - this->rLifespan = initParams->life; - this->rPrimColorR = 255; - this->rPrimColorG = 255; - this->rPrimColorB = 255; - this->rPrimColorA = 255; - this->rEnvColorR = 255; - this->rEnvColorG = 255; - this->rEnvColorB = 255; - this->rEnvColorA = 255; - this->rWaterBoxNum = WaterBox_GetSurface2(globalCtx, &globalCtx->colCtx, &initParams->pos, 3.0f, &waterBox); + pthis->velocity = pthis->accel = zeroVec; + pthis->pos = initParams->pos; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffWaterRippleDL); + pthis->life = initParams->life + 20; + pthis->flags = 0; + pthis->draw = EffectSsGRipple_Draw; + pthis->update = EffectSsGRipple_Update; + pthis->rRadius = initParams->radius; + pthis->rRadiusMax = initParams->radiusMax; + pthis->rLifespan = initParams->life; + pthis->rPrimColorR = 255; + pthis->rPrimColorG = 255; + pthis->rPrimColorB = 255; + pthis->rPrimColorA = 255; + pthis->rEnvColorR = 255; + pthis->rEnvColorG = 255; + pthis->rEnvColorB = 255; + pthis->rEnvColorA = 255; + pthis->rWaterBoxNum = WaterBox_GetSurface2(globalCtx, &globalCtx->colCtx, &initParams->pos, 3.0f, &waterBox); return 1; } -void EffectSsGRipple_DrawRipple(GlobalContext* globalCtx, EffectSs* this, void* segment) { +void EffectSsGRipple_DrawRipple(GlobalContext* globalCtx, EffectSs* pthis, void* segment) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; f32 radius; s32 pad; @@ -80,15 +80,15 @@ void EffectSsGRipple_DrawRipple(GlobalContext* globalCtx, EffectSs* this, void* if (globalCtx) {} - radius = this->rRadius * 0.0025f; + radius = pthis->rRadius * 0.0025f; - if ((this->rWaterBoxNum != -1) && (this->rWaterBoxNum < globalCtx->colCtx.colHeader->numWaterBoxes)) { - yPos = (this->rWaterBoxNum + globalCtx->colCtx.colHeader->waterBoxes)->ySurface; + if ((pthis->rWaterBoxNum != -1) && (pthis->rWaterBoxNum < globalCtx->colCtx.colHeader->numWaterBoxes)) { + yPos = (pthis->rWaterBoxNum + globalCtx->colCtx.colHeader->waterBoxes)->ySurface; } else { - yPos = this->pos.y; + yPos = pthis->pos.y; } - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, yPos, this->pos.z); + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, yPos, pthis->pos.z); SkinMatrix_SetScale(&mfScale, radius, radius, radius); SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); @@ -97,40 +97,40 @@ void EffectSsGRipple_DrawRipple(GlobalContext* globalCtx, EffectSs* this, void* if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80094BC4(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } CLOSE_DISPS(gfxCtx, "../z_eff_ss_g_ripple.c", 247); } -void EffectSsGRipple_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if (this->rLifespan == 0) { - EffectSsGRipple_DrawRipple(globalCtx, this, gEffWaterRippleTex); +void EffectSsGRipple_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if (pthis->rLifespan == 0) { + EffectSsGRipple_DrawRipple(globalCtx, pthis, gEffWaterRippleTex); } } -void EffectSsGRipple_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsGRipple_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { f32 radius; f32 primAlpha; f32 envAlpha; - if (DECR(this->rLifespan) == 0) { - radius = this->rRadius; - Math_SmoothStepToF(&radius, this->rRadiusMax, 0.2f, 30.0f, 1.0f); - this->rRadius = radius; + if (DECR(pthis->rLifespan) == 0) { + radius = pthis->rRadius; + Math_SmoothStepToF(&radius, pthis->rRadiusMax, 0.2f, 30.0f, 1.0f); + pthis->rRadius = radius; - primAlpha = this->rPrimColorA; - envAlpha = this->rEnvColorA; + primAlpha = pthis->rPrimColorA; + envAlpha = pthis->rEnvColorA; Math_SmoothStepToF(&primAlpha, 0.0f, 0.2f, 15.0f, 7.0f); Math_SmoothStepToF(&envAlpha, 0.0f, 0.2f, 15.0f, 7.0f); - this->rPrimColorA = primAlpha; - this->rEnvColorA = envAlpha; + pthis->rPrimColorA = primAlpha; + pthis->rEnvColorA = envAlpha; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c deleted file mode 100644 index 1032d9b37..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c +++ /dev/null @@ -1,150 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_G_SPK_Z_EFF_SS_G_SPK_C -#include "actor_common.h" -/* - * File: z_eff_ss_g_spk.c - * Overlay: ovl_Effect_Ss_G_Spk - * Description: Sparks - */ - -#include "z_eff_ss_g_spk.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define rPrimColorR regs[0] -#define rPrimColorG regs[1] -#define rPrimColorB regs[2] -#define rPrimColorA regs[3] -#define rEnvColorR regs[4] -#define rEnvColorG regs[5] -#define rEnvColorB regs[6] -#define rEnvColorA regs[7] -#define rTexIdx regs[8] -#define rScale regs[9] -#define rScaleStep regs[10] - -u32 EffectSsGSpk_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGSpk_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGSpk_UpdateNoAccel(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGSpk_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); - -EffectSsInit Effect_Ss_G_Spk_InitVars = { - EFFECT_SS_G_SPK, - EffectSsGSpk_Init, -}; - -u32 EffectSsGSpk_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsGSpkInitParams* initParams = (EffectSsGSpkInitParams*)initParamsx; - - Math_Vec3f_Copy(&this->pos, &initParams->pos); - Math_Vec3f_Copy(&this->velocity, &initParams->velocity); - Math_Vec3f_Copy(&this->accel, &initParams->accel); - this->gfx = SEGMENTED_TO_VIRTUAL(gEffSparkDL); - - if (initParams->updateMode == 0) { - this->life = 10; - this->vec.x = initParams->pos.x - initParams->actor->world.pos.x; - this->vec.y = initParams->pos.y - initParams->actor->world.pos.y; - this->vec.z = initParams->pos.z - initParams->actor->world.pos.z; - this->update = EffectSsGSpk_Update; - } else { - this->life = 5; - this->update = EffectSsGSpk_UpdateNoAccel; - } - - this->draw = EffectSsGSpk_Draw; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rEnvColorA = initParams->envColor.a; - this->rTexIdx = 0; - this->rScale = initParams->scale; - this->rScaleStep = initParams->scaleStep; - this->actor = initParams->actor; - - return 1; -} - -void EffectSsGSpk_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - static void* sparkTextures[] = { - gEffSpark1Tex, - gEffSpark2Tex, - gEffSpark3Tex, - gEffSpark4Tex, - }; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - MtxF mfTrans; - MtxF mfScale; - MtxF mfResult; - MtxF mfTrans11DA0; - Mtx* mtx; - f32 scale; - s32 pad; - - OPEN_DISPS(gfxCtx, "../z_eff_ss_g_spk.c", 208); - - scale = this->rScale * 0.0025f; - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); - SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); - - mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); - - if (mtx != NULL) { - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sparkTextures[this->rTexIdx])); - func_80094BC4(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); - } - - if (1) {} - if (1) {} - - CLOSE_DISPS(gfxCtx, "../z_eff_ss_g_spk.c", 255); -} - -void EffectSsGSpk_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - - this->accel.x = (Rand_ZeroOne() - 0.5f) * 3.0f; - this->accel.z = (Rand_ZeroOne() - 0.5f) * 3.0f; - - if (this->actor != NULL) { - if ((this->actor->category == ACTORCAT_EXPLOSIVE) && (this->actor->update != NULL)) { - this->pos.x = this->actor->world.pos.x + this->vec.x; - this->pos.y = this->actor->world.pos.y + this->vec.y; - this->pos.z = this->actor->world.pos.z + this->vec.z; - } - } - - this->vec.x += this->accel.x; - this->vec.z += this->accel.z; - - this->rTexIdx++; - this->rTexIdx &= 3; - this->rScale += this->rScaleStep; -} - -// this update mode is unused in the original game -// with this update mode, the sparks dont move randomly in the xz plane, appearing to be on top of each other -void EffectSsGSpk_UpdateNoAccel(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if (this->actor != NULL) { - if ((this->actor->category == ACTORCAT_EXPLOSIVE) && (this->actor->update != NULL)) { - this->pos.x += (Math_SinS(this->actor->world.rot.y) * this->actor->speedXZ); - this->pos.z += (Math_CosS(this->actor->world.rot.y) * this->actor->speedXZ); - } - } - - this->rTexIdx++; - this->rTexIdx &= 3; - this->rScale += this->rScaleStep; -} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.cpp b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.cpp new file mode 100644 index 000000000..64001f79a --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.cpp @@ -0,0 +1,150 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_G_SPK_Z_EFF_SS_G_SPK_C +#include "actor_common.h" +/* + * File: z_eff_ss_g_spk.c + * Overlay: ovl_Effect_Ss_G_Spk + * Description: Sparks + */ + +#include "z_eff_ss_g_spk.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rTexIdx regs[8] +#define rScale regs[9] +#define rScaleStep regs[10] + +u32 EffectSsGSpk_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsGSpk_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGSpk_UpdateNoAccel(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGSpk_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +EffectSsInit Effect_Ss_G_Spk_InitVars = { + EFFECT_SS_G_SPK, + EffectSsGSpk_Init, +}; + +u32 EffectSsGSpk_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + EffectSsGSpkInitParams* initParams = (EffectSsGSpkInitParams*)initParamsx; + + Math_Vec3f_Copy(&pthis->pos, &initParams->pos); + Math_Vec3f_Copy(&pthis->velocity, &initParams->velocity); + Math_Vec3f_Copy(&pthis->accel, &initParams->accel); + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffSparkDL); + + if (initParams->updateMode == 0) { + pthis->life = 10; + pthis->vec.x = initParams->pos.x - initParams->actor->world.pos.x; + pthis->vec.y = initParams->pos.y - initParams->actor->world.pos.y; + pthis->vec.z = initParams->pos.z - initParams->actor->world.pos.z; + pthis->update = EffectSsGSpk_Update; + } else { + pthis->life = 5; + pthis->update = EffectSsGSpk_UpdateNoAccel; + } + + pthis->draw = EffectSsGSpk_Draw; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rEnvColorA = initParams->envColor.a; + pthis->rTexIdx = 0; + pthis->rScale = initParams->scale; + pthis->rScaleStep = initParams->scaleStep; + pthis->actor = initParams->actor; + + return 1; +} + +void EffectSsGSpk_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + static void* sparkTextures[] = { + gEffSpark1Tex, + gEffSpark2Tex, + gEffSpark3Tex, + gEffSpark4Tex, + }; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTrans11DA0; + Mtx* mtx; + f32 scale; + s32 pad; + + OPEN_DISPS(gfxCtx, "../z_eff_ss_g_spk.c", 208); + + scale = pthis->rScale * 0.0025f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); + SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sparkTextures[pthis->rTexIdx])); + func_80094BC4(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); + } + + if (1) {} + if (1) {} + + CLOSE_DISPS(gfxCtx, "../z_eff_ss_g_spk.c", 255); +} + +void EffectSsGSpk_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + + pthis->accel.x = (Rand_ZeroOne() - 0.5f) * 3.0f; + pthis->accel.z = (Rand_ZeroOne() - 0.5f) * 3.0f; + + if (pthis->actor != NULL) { + if ((pthis->actor->category == ACTORCAT_EXPLOSIVE) && (pthis->actor->update != NULL)) { + pthis->pos.x = pthis->actor->world.pos.x + pthis->vec.x; + pthis->pos.y = pthis->actor->world.pos.y + pthis->vec.y; + pthis->pos.z = pthis->actor->world.pos.z + pthis->vec.z; + } + } + + pthis->vec.x += pthis->accel.x; + pthis->vec.z += pthis->accel.z; + + pthis->rTexIdx++; + pthis->rTexIdx &= 3; + pthis->rScale += pthis->rScaleStep; +} + +// pthis update mode is unused in the original game +// with pthis update mode, the sparks dont move randomly in the xz plane, appearing to be on top of each other +void EffectSsGSpk_UpdateNoAccel(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if (pthis->actor != NULL) { + if ((pthis->actor->category == ACTORCAT_EXPLOSIVE) && (pthis->actor->update != NULL)) { + pthis->pos.x += (Math_SinS(pthis->actor->world.rot.y) * pthis->actor->speedXZ); + pthis->pos.z += (Math_CosS(pthis->actor->world.rot.y) * pthis->actor->speedXZ); + } + } + + pthis->rTexIdx++; + pthis->rTexIdx &= 3; + pthis->rScale += pthis->rScaleStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c deleted file mode 100644 index d1b40e77f..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c +++ /dev/null @@ -1,142 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_G_SPLASH_Z_EFF_SS_G_SPLASH_C -#include "actor_common.h" -/* - * File: z_eff_ss_g_splash.c - * Overlay: ovl_Effect_Ss_G_Splash - * Description: Splash - */ - -#include "z_eff_ss_g_splash.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/z_effect_soft_sprite_old_init.h" - -//! @bug the reuse of regs[11] means that EffectSs_DrawGEffect will treat the type as an object bank index -// this ends up having no effect because the texture provided does not use segment 6 -#define rType regs[11] - -u32 EffectSsGSplash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParams); -void EffectSsGSplash_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGSplash_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); - -EffectSsInit Effect_Ss_G_Splash_InitVars = { - EFFECT_SS_G_SPLASH, - EffectSsGSplash_Init, -}; - -u32 EffectSsGSplash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsGSplashInitParams* initParams = (EffectSsGSplashInitParams*)initParamsx; - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - - this->velocity = this->accel = zeroVec; - this->pos = initParams->pos; - this->draw = EffectSsGSplash_Draw; - this->update = EffectSsGSplash_Update; - - if (initParams->scale == 0) { - initParams->scale = 600; - } - - this->gfx = SEGMENTED_TO_VIRTUAL(gEffWaterSplashDL); - this->life = 8; - this->rgScale = initParams->scale; - this->rgTexIdx = 0; - this->rgTexIdxStep = 100; - - if (initParams->customColor) { - this->rgPrimColorR = initParams->primColor.r; - this->rgPrimColorG = initParams->primColor.g; - this->rgPrimColorB = initParams->primColor.b; - this->rgPrimColorA = initParams->primColor.a; - this->rgEnvColorR = initParams->envColor.r; - this->rgEnvColorG = initParams->envColor.g; - this->rgEnvColorB = initParams->envColor.b; - this->rgEnvColorA = initParams->envColor.a; - this->rType = initParams->type; - } else { - switch (initParams->type) { - case 0: - this->rgPrimColorR = 255; - this->rgPrimColorG = 255; - this->rgPrimColorB = 255; - this->rgPrimColorA = 200; - this->rgEnvColorR = 255; - this->rgEnvColorG = 255; - this->rgEnvColorB = 255; - this->rgEnvColorA = 200; - this->rType = 0; - break; - case 1: - this->rgPrimColorR = 255; - this->rgPrimColorG = 255; - this->rgPrimColorB = 255; - this->rgPrimColorA = 255; - this->rgEnvColorR = 255; - this->rgEnvColorG = 255; - this->rgEnvColorB = 255; - this->rgEnvColorA = 255; - this->rType = 1; - break; - case 2: - this->rgPrimColorR = 255; - this->rgPrimColorG = 255; - this->rgPrimColorB = 255; - this->rgPrimColorA = 200; - this->rgEnvColorR = 255; - this->rgEnvColorG = 255; - this->rgEnvColorB = 255; - this->rgEnvColorA = 200; - this->rType = 2; - break; - } - } - return 1; -} - -void EffectSsGSplash_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - static void* waterSplashTextures[] = { - gEffWaterSplash1Tex, gEffWaterSplash2Tex, gEffWaterSplash3Tex, gEffWaterSplash4Tex, - gEffWaterSplash5Tex, gEffWaterSplash6Tex, gEffWaterSplash7Tex, gEffWaterSplash8Tex, - }; - s16 texIdx; - - switch (this->rType) { - case 0: - texIdx = this->rgTexIdx / 100; - if (texIdx > 7) { - texIdx = 7; - } - EffectSs_DrawGEffect(globalCtx, this, waterSplashTextures[texIdx]); - break; - - case 1: - texIdx = this->rgTexIdx / 100; - if (texIdx > 7) { - texIdx = 7; - } - EffectSs_DrawGEffect(globalCtx, this, waterSplashTextures[texIdx]); - break; - - case 2: - texIdx = this->rgTexIdx / 100; - if (texIdx > 7) { - texIdx = 7; - } - EffectSs_DrawGEffect(globalCtx, this, waterSplashTextures[texIdx]); - break; - - default: - break; - } -} - -void EffectSsGSplash_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - Vec3f newSplashPos; - - if ((this->rType == 1) && (this->life == 5)) { - newSplashPos = this->pos; - newSplashPos.y += ((this->rgScale * 20) * 0.002f); - EffectSsGSplash_Spawn(globalCtx, &newSplashPos, 0, 0, 2, this->rgScale / 2); - } - - this->rgTexIdx += this->rgTexIdxStep; -} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.cpp b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.cpp new file mode 100644 index 000000000..04804b959 --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.cpp @@ -0,0 +1,142 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_G_SPLASH_Z_EFF_SS_G_SPLASH_C +#include "actor_common.h" +/* + * File: z_eff_ss_g_splash.c + * Overlay: ovl_Effect_Ss_G_Splash + * Description: Splash + */ + +#include "z_eff_ss_g_splash.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/z_effect_soft_sprite_old_init.h" + +//! @bug the reuse of regs[11] means that EffectSs_DrawGEffect will treat the type as an object bank index +// pthis ends up having no effect because the texture provided does not use segment 6 +#define rType regs[11] + +u32 EffectSsGSplash_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParams); +void EffectSsGSplash_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsGSplash_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +EffectSsInit Effect_Ss_G_Splash_InitVars = { + EFFECT_SS_G_SPLASH, + EffectSsGSplash_Init, +}; + +u32 EffectSsGSplash_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + EffectSsGSplashInitParams* initParams = (EffectSsGSplashInitParams*)initParamsx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + pthis->velocity = pthis->accel = zeroVec; + pthis->pos = initParams->pos; + pthis->draw = EffectSsGSplash_Draw; + pthis->update = EffectSsGSplash_Update; + + if (initParams->scale == 0) { + initParams->scale = 600; + } + + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffWaterSplashDL); + pthis->life = 8; + pthis->rgScale = initParams->scale; + pthis->rgTexIdx = 0; + pthis->rgTexIdxStep = 100; + + if (initParams->customColor) { + pthis->rgPrimColorR = initParams->primColor.r; + pthis->rgPrimColorG = initParams->primColor.g; + pthis->rgPrimColorB = initParams->primColor.b; + pthis->rgPrimColorA = initParams->primColor.a; + pthis->rgEnvColorR = initParams->envColor.r; + pthis->rgEnvColorG = initParams->envColor.g; + pthis->rgEnvColorB = initParams->envColor.b; + pthis->rgEnvColorA = initParams->envColor.a; + pthis->rType = initParams->type; + } else { + switch (initParams->type) { + case 0: + pthis->rgPrimColorR = 255; + pthis->rgPrimColorG = 255; + pthis->rgPrimColorB = 255; + pthis->rgPrimColorA = 200; + pthis->rgEnvColorR = 255; + pthis->rgEnvColorG = 255; + pthis->rgEnvColorB = 255; + pthis->rgEnvColorA = 200; + pthis->rType = 0; + break; + case 1: + pthis->rgPrimColorR = 255; + pthis->rgPrimColorG = 255; + pthis->rgPrimColorB = 255; + pthis->rgPrimColorA = 255; + pthis->rgEnvColorR = 255; + pthis->rgEnvColorG = 255; + pthis->rgEnvColorB = 255; + pthis->rgEnvColorA = 255; + pthis->rType = 1; + break; + case 2: + pthis->rgPrimColorR = 255; + pthis->rgPrimColorG = 255; + pthis->rgPrimColorB = 255; + pthis->rgPrimColorA = 200; + pthis->rgEnvColorR = 255; + pthis->rgEnvColorG = 255; + pthis->rgEnvColorB = 255; + pthis->rgEnvColorA = 200; + pthis->rType = 2; + break; + } + } + return 1; +} + +void EffectSsGSplash_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + static void* waterSplashTextures[] = { + gEffWaterSplash1Tex, gEffWaterSplash2Tex, gEffWaterSplash3Tex, gEffWaterSplash4Tex, + gEffWaterSplash5Tex, gEffWaterSplash6Tex, gEffWaterSplash7Tex, gEffWaterSplash8Tex, + }; + s16 texIdx; + + switch (pthis->rType) { + case 0: + texIdx = pthis->rgTexIdx / 100; + if (texIdx > 7) { + texIdx = 7; + } + EffectSs_DrawGEffect(globalCtx, pthis, waterSplashTextures[texIdx]); + break; + + case 1: + texIdx = pthis->rgTexIdx / 100; + if (texIdx > 7) { + texIdx = 7; + } + EffectSs_DrawGEffect(globalCtx, pthis, waterSplashTextures[texIdx]); + break; + + case 2: + texIdx = pthis->rgTexIdx / 100; + if (texIdx > 7) { + texIdx = 7; + } + EffectSs_DrawGEffect(globalCtx, pthis, waterSplashTextures[texIdx]); + break; + + default: + break; + } +} + +void EffectSsGSplash_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + Vec3f newSplashPos; + + if ((pthis->rType == 1) && (pthis->life == 5)) { + newSplashPos = pthis->pos; + newSplashPos.y += ((pthis->rgScale * 20) * 0.002f); + EffectSsGSplash_Spawn(globalCtx, &newSplashPos, 0, 0, 2, pthis->rgScale / 2); + } + + pthis->rgTexIdx += pthis->rgTexIdxStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.cpp similarity index 50% rename from src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c rename to src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.cpp index a80531fc7..1a178ec81 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.cpp @@ -21,95 +21,95 @@ #define rObjBankIdx regs[5] #define rMinLife regs[6] -u32 EffectSsHahen_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsHahen_DrawGray(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsHahen_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsHahen_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsHahen_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsHahen_DrawGray(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsHahen_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsHahen_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Hahen_InitVars = { EFFECT_SS_HAHEN, EffectSsHahen_Init, }; -void EffectSsHahen_CheckForObject(EffectSs* this, GlobalContext* globalCtx) { - if (((this->rObjBankIdx = Object_GetIndex(&globalCtx->objectCtx, this->rObjId)) < 0) || - !Object_IsLoaded(&globalCtx->objectCtx, this->rObjBankIdx)) { - this->life = -1; - this->draw = NULL; +void EffectSsHahen_CheckForObject(EffectSs* pthis, GlobalContext* globalCtx) { + if (((pthis->rObjBankIdx = Object_GetIndex(&globalCtx->objectCtx, pthis->rObjId)) < 0) || + !Object_IsLoaded(&globalCtx->objectCtx, pthis->rObjBankIdx)) { + pthis->life = -1; + pthis->draw = NULL; } } -u32 EffectSsHahen_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsHahen_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsHahenInitParams* initParams = (EffectSsHahenInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = 200; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = 200; if (initParams->dList != NULL) { - this->gfx = initParams->dList; - this->rObjId = initParams->objId; - EffectSsHahen_CheckForObject(this, globalCtx); + pthis->gfx = initParams->dList; + pthis->rObjId = initParams->objId; + EffectSsHahen_CheckForObject(pthis, globalCtx); } else { - this->gfx = SEGMENTED_TO_VIRTUAL(gEffFragments1DL); - this->rObjId = -1; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffFragments1DL); + pthis->rObjId = -1; } - if ((this->rObjId == OBJECT_HAKA_OBJECTS) && (this->gfx == gEffFragments2DL)) { - this->draw = EffectSsHahen_DrawGray; + if ((pthis->rObjId == OBJECT_HAKA_OBJECTS) && (pthis->gfx == gEffFragments2DL)) { + pthis->draw = EffectSsHahen_DrawGray; } else { - this->draw = EffectSsHahen_Draw; + pthis->draw = EffectSsHahen_Draw; } - this->update = EffectSsHahen_Update; - this->rUnused = initParams->unused; - this->rScale = initParams->scale; - this->rPitch = Rand_ZeroOne() * 314.0f; - this->rYaw = Rand_ZeroOne() * 314.0f; - this->rMinLife = 200 - initParams->life; + pthis->update = EffectSsHahen_Update; + pthis->rUnused = initParams->unused; + pthis->rScale = initParams->scale; + pthis->rPitch = Rand_ZeroOne() * 314.0f; + pthis->rYaw = Rand_ZeroOne() * 314.0f; + pthis->rMinLife = 200 - initParams->life; return 1; } -void EffectSsHahen_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsHahen_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; - f32 scale = this->rScale * 0.001f; + f32 scale = pthis->rScale * 0.001f; OPEN_DISPS(gfxCtx, "../z_eff_hahen.c", 208); - if (this->rObjId != -1) { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->rObjBankIdx].vromStart); + if (pthis->rObjId != -1) { + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->rObjBankIdx].vromStart.get()); } - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->rYaw * 0.01f, MTXMODE_APPLY); - Matrix_RotateX(this->rPitch * 0.01f, MTXMODE_APPLY); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->rYaw * 0.01f, MTXMODE_APPLY); + Matrix_RotateX(pthis->rPitch * 0.01f, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_hahen.c", 228), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D18(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_hahen.c", 236); } -// in the original game this function is hardcoded to be used only by the skull pots in Shadow Temple -void EffectSsHahen_DrawGray(GlobalContext* globalCtx, u32 index, EffectSs* this) { +// in the original game pthis function is hardcoded to be used only by the skull pots in Shadow Temple +void EffectSsHahen_DrawGray(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; - f32 scale = this->rScale * 0.001f; + f32 scale = pthis->rScale * 0.001f; OPEN_DISPS(gfxCtx, "../z_eff_hahen.c", 253); - if (this->rObjId != -1) { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->rObjBankIdx].vromStart); + if (pthis->rObjId != -1) { + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->rObjBankIdx].vromStart.get()); } - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->rYaw * 0.01f, MTXMODE_APPLY); - Matrix_RotateX(this->rPitch * 0.01f, MTXMODE_APPLY); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->rYaw * 0.01f, MTXMODE_APPLY); + Matrix_RotateX(pthis->rPitch * 0.01f, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_hahen.c", 271), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -117,22 +117,22 @@ void EffectSsHahen_DrawGray(GlobalContext* globalCtx, u32 index, EffectSs* this) gDPSetCombineLERP(POLY_OPA_DISP++, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0x0, 0x01, 100, 100, 120, 255); - gSPDisplayList(POLY_OPA_DISP++, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_hahen.c", 288); } -void EffectSsHahen_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsHahen_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { Player* player = GET_PLAYER(globalCtx); - this->rPitch += 55; - this->rYaw += 10; + pthis->rPitch += 55; + pthis->rYaw += 10; - if ((this->pos.y <= player->actor.floorHeight) && (this->life < this->rMinLife)) { - this->life = 0; + if ((pthis->pos.y <= player->actor.floorHeight) && (pthis->life < pthis->rMinLife)) { + pthis->life = 0; } - if (this->rObjId != -1) { - EffectSsHahen_CheckForObject(this, globalCtx); + if (pthis->rObjId != -1) { + EffectSsHahen_CheckForObject(pthis, globalCtx); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c b/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.cpp similarity index 61% rename from src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c rename to src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.cpp index 5517bb11d..8fc8a9226 100644 --- a/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.c +++ b/src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.cpp @@ -23,9 +23,9 @@ #define rEnvColorB regs[7] #define rScale regs[8] -u32 EffectSsHitMark_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsHitMark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsHitMark_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsHitMark_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsHitMark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsHitMark_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); static Color_RGB8 sColors[] = { { 255, 255, 255 }, { 255, 255, 0 }, { 255, 255, 255 }, { 255, 0, 0 }, { 255, 200, 100 }, { 200, 150, 0 }, @@ -47,35 +47,35 @@ EffectSsInit Effect_Ss_HitMark_InitVars = { EffectSsHitMark_Init, }; -u32 EffectSsHitMark_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsHitMark_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { s32 colorIdx; EffectSsHitMarkInitParams* initParams = (EffectSsHitMarkInitParams*)initParamsx; - this->pos = initParams->pos; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffHitMarkDL); + pthis->pos = initParams->pos; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffHitMarkDL); if (initParams->type == EFFECT_HITMARK_DUST) { - this->life = 16; + pthis->life = 16; } else { - this->life = 8; + pthis->life = 8; } - this->draw = EffectSsHitMark_Draw; - this->update = EffectSsHitMark_Update; + pthis->draw = EffectSsHitMark_Draw; + pthis->update = EffectSsHitMark_Update; colorIdx = initParams->type * 4; - this->rTexIdx = 0; - this->rType = initParams->type; - this->rPrimColorR = sColors[colorIdx].r; - this->rPrimColorG = sColors[colorIdx].g; - this->rPrimColorB = sColors[colorIdx].b; - this->rEnvColorR = sColors[colorIdx + 1].r; - this->rEnvColorG = sColors[colorIdx + 1].g; - this->rEnvColorB = sColors[colorIdx + 1].b; - this->rScale = initParams->scale; + pthis->rTexIdx = 0; + pthis->rType = initParams->type; + pthis->rPrimColorR = sColors[colorIdx].r; + pthis->rPrimColorG = sColors[colorIdx].g; + pthis->rPrimColorB = sColors[colorIdx].b; + pthis->rEnvColorR = sColors[colorIdx + 1].r; + pthis->rEnvColorG = sColors[colorIdx + 1].g; + pthis->rEnvColorB = sColors[colorIdx + 1].b; + pthis->rScale = initParams->scale; return 1; } -void EffectSsHitMark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsHitMark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; MtxF mfTrans; MtxF mfScale; @@ -87,8 +87,8 @@ void EffectSsHitMark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx, "../z_eff_ss_hitmark.c", 297); - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); - scale = this->rScale / 100.0f; + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); + scale = pthis->rScale / 100.0f; SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); @@ -98,31 +98,31 @@ void EffectSsHitMark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[(this->rType * 8) + (this->rTexIdx)])); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sTextures[(pthis->rType * 8) + (pthis->rTexIdx)])); func_80094C50(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, 0); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } CLOSE_DISPS(gfxCtx, "../z_eff_ss_hitmark.c", 341); } -void EffectSsHitMark_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsHitMark_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 colorIdx; - if (this->rType == EFFECT_HITMARK_DUST) { - this->rTexIdx = (15 - this->life) / 2; + if (pthis->rType == EFFECT_HITMARK_DUST) { + pthis->rTexIdx = (15 - pthis->life) / 2; } else { - this->rTexIdx = 7 - this->life; + pthis->rTexIdx = 7 - pthis->life; } - if (this->rTexIdx != 0) { - colorIdx = this->rType * 4 + 2; - this->rPrimColorR = func_80027DD4(this->rPrimColorR, sColors[colorIdx].r, this->life + 1); - this->rPrimColorG = func_80027DD4(this->rPrimColorG, sColors[colorIdx].g, this->life + 1); - this->rPrimColorB = func_80027DD4(this->rPrimColorB, sColors[colorIdx].b, this->life + 1); - this->rEnvColorR = func_80027DD4(this->rEnvColorR, sColors[colorIdx + 1].r, this->life + 1); - this->rEnvColorG = func_80027DD4(this->rEnvColorG, sColors[colorIdx + 1].g, this->life + 1); - this->rEnvColorB = func_80027DD4(this->rEnvColorB, sColors[colorIdx + 1].b, this->life + 1); + if (pthis->rTexIdx != 0) { + colorIdx = pthis->rType * 4 + 2; + pthis->rPrimColorR = func_80027DD4(pthis->rPrimColorR, sColors[colorIdx].r, pthis->life + 1); + pthis->rPrimColorG = func_80027DD4(pthis->rPrimColorG, sColors[colorIdx].g, pthis->life + 1); + pthis->rPrimColorB = func_80027DD4(pthis->rPrimColorB, sColors[colorIdx].b, pthis->life + 1); + pthis->rEnvColorR = func_80027DD4(pthis->rEnvColorR, sColors[colorIdx + 1].r, pthis->life + 1); + pthis->rEnvColorG = func_80027DD4(pthis->rEnvColorG, sColors[colorIdx + 1].g, pthis->life + 1); + pthis->rEnvColorB = func_80027DD4(pthis->rEnvColorB, sColors[colorIdx + 1].b, pthis->life + 1); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.cpp similarity index 63% rename from src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c rename to src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.cpp index b795f37c4..1d3d38e8c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.cpp @@ -19,63 +19,63 @@ #define rRotSpeed regs[3] #define rScale regs[4] -u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; -u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsIcePieceInitParams* initParams = (EffectSsIcePieceInitParams*)initParamsx; - this->pos = initParams->pos; - this->vec = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = initParams->life; - this->draw = EffectSsIcePiece_Draw; - this->update = EffectSsIcePiece_Update; - this->rLifespan = initParams->life; - this->rScale = initParams->scale * 100.0f; - this->rYaw = Math_Atan2S(initParams->velocity.z, initParams->velocity.x); - this->rPitch = 0; - this->rRotSpeed = + pthis->pos = initParams->pos; + pthis->vec = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = initParams->life; + pthis->draw = EffectSsIcePiece_Draw; + pthis->update = EffectSsIcePiece_Update; + pthis->rLifespan = initParams->life; + pthis->rScale = initParams->scale * 100.0f; + pthis->rYaw = Math_Atan2S(initParams->velocity.z, initParams->velocity.x); + pthis->rPitch = 0; + pthis->rRotSpeed = ((fabsf(initParams->velocity.x) + fabsf(initParams->velocity.y)) * 100.0f) * (Rand_ZeroFloat(1.0f) + 0.5f); return 1; } -void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; f32 scale; u32 frames; f32 alpha; - scale = this->rScale * 0.01f; + scale = pthis->rScale * 0.01f; frames = globalCtx->state.frames; OPEN_DISPS(gfxCtx, "../z_eff_ice_piece.c", 161); - if ((this->rLifespan > 0) && (this->life < (this->rLifespan >> 1))) { - alpha = ((this->life * 2.0f) / this->rLifespan); + if ((pthis->rLifespan > 0) && (pthis->life < (pthis->rLifespan >> 1))) { + alpha = ((pthis->life * 2.0f) / pthis->rLifespan); alpha *= 255.0f; } else { alpha = 255.0f; } - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_RotateY(this->rYaw * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_RotateX(this->rPitch * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY(pthis->rYaw * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateX(pthis->rPitch * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ice_piece.c", 185), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D84(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (s32)alpha & 0xFF); - func_8003435C(&this->pos, globalCtx); + func_8003435C(&pthis->pos, globalCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (1 * frames) % 256, 0x20, 0x10, 1, 0, (2 * frames) % 256, 0x40, 0x20)); @@ -84,9 +84,9 @@ void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) CLOSE_DISPS(gfxCtx, "../z_eff_ice_piece.c", 209); } -void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rPitch += this->rRotSpeed; - this->velocity.x = this->velocity.x * 0.85f; - this->velocity.y = this->velocity.y * 0.85f; - this->velocity.z = this->velocity.z * 0.85f; +void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rPitch += pthis->rRotSpeed; + pthis->velocity.x = pthis->velocity.x * 0.85f; + pthis->velocity.y = pthis->velocity.y * 0.85f; + pthis->velocity.z = pthis->velocity.z * 0.85f; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.cpp similarity index 69% rename from src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c rename to src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.cpp index 79b80d00f..06c7150bb 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.cpp @@ -17,16 +17,16 @@ #define rAlpha regs[1] #define rScale regs[2] -u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { EFFECT_SS_ICE_SMOKE, EffectSsIceSmoke_Init, }; -u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsIceSmokeInitParams* initParams = (EffectSsIceSmokeInitParams*)initParamsx; s32 pad; s32 objBankIdx; @@ -35,18 +35,18 @@ u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, v objBankIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FZ); if ((objBankIdx > -1) && Object_IsLoaded(&globalCtx->objectCtx, objBankIdx)) { - oldSeg6 = gSegments[6]; - gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIdx].vromStart); - Math_Vec3f_Copy(&this->pos, &initParams->pos); - Math_Vec3f_Copy(&this->velocity, &initParams->velocity); - Math_Vec3f_Copy(&this->accel, &initParams->accel); - this->rObjBankIdx = objBankIdx; - this->rAlpha = 0; - this->rScale = initParams->scale; - this->life = 50; - this->draw = EffectSsIceSmoke_Draw; - this->update = EffectSsIceSmoke_Update; - gSegments[6] = oldSeg6; + oldSeg6 = (void*)gSegments[6]; + gSegments[6] = VIRTUAL_TO_PHYSICAL(gObjectTable[objBankIdx].vromStart.get()); + Math_Vec3f_Copy(&pthis->pos, &initParams->pos); + Math_Vec3f_Copy(&pthis->velocity, &initParams->velocity); + Math_Vec3f_Copy(&pthis->accel, &initParams->accel); + pthis->rObjBankIdx = objBankIdx; + pthis->rAlpha = 0; + pthis->rScale = initParams->scale; + pthis->life = 50; + pthis->draw = EffectSsIceSmoke_Draw; + pthis->update = EffectSsIceSmoke_Update; + gSegments[6] = (uintptr_t)oldSeg6; return 1; } @@ -56,14 +56,14 @@ u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, v return 0; } -void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 pad; void* object; Mtx* mtx; f32 scale; s32 objBankIdx; - object = gObjectTable[this->rObjBankIdx].vromStart; + object = gObjectTable[pthis->rObjBankIdx].vromStart.buffer(); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_ice_smoke.c", 155); @@ -72,17 +72,17 @@ void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) if ((objBankIdx > -1) && Object_IsLoaded(&globalCtx->objectCtx, objBankIdx)) { gDPPipeSync(POLY_XLU_DISP++); func_80093D84(globalCtx->state.gfxCtx); - gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSegments[6] = (uintptr_t)VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamStartDL)); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, this->rAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, pthis->rAlpha); gSPSegment( POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->life * 3, this->life * 15, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, pthis->life * 3, pthis->life * 15, 32, 64, 1, 0, 0, 32, 32)); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); func_800D1FD4(&globalCtx->billboardMtxF); - scale = this->rScale * 0.0001f; + scale = pthis->rScale * 0.0001f; Matrix_Scale(scale, scale, 1.0f, MTXMODE_APPLY); mtx = Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_eff_ss_ice_smoke.c", 196); @@ -92,22 +92,22 @@ void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamDL)); } } else { - this->life = -1; + pthis->life = -1; } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_ice_smoke.c", 210); } -void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 objBankIdx; objBankIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FZ); if ((objBankIdx > -1) && Object_IsLoaded(&globalCtx->objectCtx, objBankIdx)) { - if (this->rAlpha < 100) { - this->rAlpha += 10; + if (pthis->rAlpha < 100) { + pthis->rAlpha += 10; } } else { - this->life = -1; + pthis->life = -1; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.cpp similarity index 62% rename from src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c rename to src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.cpp index 150bd7257..2819e0a66 100644 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.cpp @@ -19,55 +19,55 @@ #define rXZScale regs[5] #define rScaleMax regs[6] -u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_K_Fire_InitVars = { EFFECT_SS_K_FIRE, EffectSsKFire_Init, }; -u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsKFireInitParams* initParams = (EffectSsKFireInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = 100; - this->rScaleMax = initParams->scaleMax; - this->rAlpha = 255; - this->rScroll = (s16)Rand_ZeroFloat(5.0f) - 0x19; - this->rType = initParams->type; - this->draw = EffectSsKFire_Draw; - this->update = EffectSsKFire_Update; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = 100; + pthis->rScaleMax = initParams->scaleMax; + pthis->rAlpha = 255; + pthis->rScroll = (s16)Rand_ZeroFloat(5.0f) - 0x19; + pthis->rType = initParams->type; + pthis->draw = EffectSsKFire_Draw; + pthis->update = EffectSsKFire_Update; return 1; } -void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; f32 xzScale; f32 yScale; - xzScale = this->rXZScale / 10000.0f; - yScale = this->rYScale / 10000.0f; + xzScale = pthis->rXZScale / 10000.0f; + yScale = pthis->rYScale / 10000.0f; OPEN_DISPS(gfxCtx, "../z_eff_k_fire.c", 152); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(xzScale, yScale, xzScale, MTXMODE_APPLY); func_80093D84(globalCtx->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - globalCtx->state.frames * this->rScroll, 0x20, 0x80)); + globalCtx->state.frames * pthis->rScroll, 0x20, 0x80)); - if (this->rType >= 100) { - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, this->rAlpha); + if (pthis->rType >= 100) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, pthis->rAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, this->rAlpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, pthis->rAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); } @@ -87,29 +87,29 @@ void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx, "../z_eff_k_fire.c", 220); } -void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if (this->rXZScale < this->rScaleMax) { - this->rXZScale += 4; - this->rYScale += 4; +void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if (pthis->rXZScale < pthis->rScaleMax) { + pthis->rXZScale += 4; + pthis->rYScale += 4; - if (this->rXZScale > this->rScaleMax) { - this->rXZScale = this->rScaleMax; + if (pthis->rXZScale > pthis->rScaleMax) { + pthis->rXZScale = pthis->rScaleMax; - if (this->rType != 3) { - this->rYScale = this->rScaleMax; + if (pthis->rType != 3) { + pthis->rYScale = pthis->rScaleMax; } } } else { - if (this->rAlpha > 0) { - this->rAlpha -= 10; - if (this->rAlpha <= 0) { - this->rAlpha = 0; - this->life = 0; + if (pthis->rAlpha > 0) { + pthis->rAlpha -= 10; + if (pthis->rAlpha <= 0) { + pthis->rAlpha = 0; + pthis->life = 0; } } } - if (this->rType == 3) { - this->rYScale++; + if (pthis->rType == 3) { + pthis->rYScale++; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c deleted file mode 100644 index 585c4ae0b..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ /dev/null @@ -1,429 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_KAKERA_Z_EFF_SS_KAKERA_C -#include "actor_common.h" -/* - * File: z_eff_ss_kakera.c - * Overlay: ovl_Effect_Ss_Kakera - * Description: Fragments. Appearance is determined by the supplied display list. - */ - -#include "z_eff_ss_kakera.h" -#include "def/code_800FD970.h" -#include "def/logutils.h" -#include "def/sys_matrix.h" -#include "def/z_bgcheck.h" -#include "def/z_rcp.h" -#include "def/z_scene.h" - -#define rReg0 regs[0] -#define rGravity regs[1] -#define rPitch regs[2] -#define rYaw regs[3] -#define rReg4 regs[4] -#define rReg5 regs[5] -#define rReg6 regs[6] -#define rScale regs[7] -#define rReg8 regs[8] -#define rReg9 regs[9] -#define rObjId regs[10] -#define rObjBankIdx regs[11] -#define rColorIdx regs[12] - -u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); - -void func_809A9BA8(EffectSs* this, GlobalContext* globalCtx); - -EffectSsInit Effect_Ss_Kakera_InitVars = { - EFFECT_SS_KAKERA, - EffectSsKakera_Init, -}; - -u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsKakeraInitParams* initParams = (EffectSsKakeraInitParams*)initParamsx; - s32 objId; - - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->life = initParams->life; - this->priority = 101; - - if (initParams->dList != NULL) { - this->gfx = initParams->dList; - objId = initParams->objId; - - if (objId == OBJECT_GAMEPLAY_KEEP || objId == OBJECT_GAMEPLAY_FIELD_KEEP || - objId == OBJECT_GAMEPLAY_DANGEON_KEEP) { - this->rObjId = KAKERA_OBJECT_DEFAULT; - } else { - this->rObjId = initParams->objId; - func_809A9BA8(this, globalCtx); - } - - } else { - osSyncPrintf("shape_modelがNULL\n"); - LogUtils_HungupThread("../z_eff_kakera.c", 178); - } - - this->draw = EffectSsKakera_Draw; - this->update = EffectSsKakera_Update; - this->vec = initParams->unk_18; - this->rReg0 = initParams->unk_2C; - this->rGravity = initParams->gravity; - this->rPitch = Rand_ZeroOne() * 32767.0f; - this->rYaw = Rand_ZeroOne() * 32767.0f; - this->rReg4 = initParams->unk_26; - this->rReg5 = initParams->unk_28; - this->rReg6 = initParams->unk_2A; - this->rScale = initParams->scale; - this->rReg8 = initParams->unk_30; - this->rReg9 = initParams->unk_32; - this->rColorIdx = initParams->colorIdx; - - return 1; -} - -f32 func_809A9818(f32 arg0, f32 arg1) { - f32 temp_f2; - - if (arg1 < 0.0f) { - osSyncPrintf("範囲がマイナス!!(randomD_sectionUniformity)\n"); - } - - temp_f2 = Rand_ZeroOne() * arg1; - return ((temp_f2 * 2.0f) - arg1) + arg0; -} - -void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - static Color_RGB8 colors[] = { { 255, 255, 255 }, { 235, 170, 130 } }; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad; - f32 scale; - s32 colorIdx; - - scale = this->rScale / 256.0f; - colorIdx = this->rColorIdx; - - OPEN_DISPS(gfxCtx, "../z_eff_kakera.c", 241); - - if (this->rObjId != KAKERA_OBJECT_DEFAULT) { - if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, gObjectTable[this->rObjBankIdx].vromStart); - } else { - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->rObjBankIdx].vromStart); - } - } - - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->rYaw * 0.01f, MTXMODE_APPLY); - Matrix_RotateX(this->rPitch * 0.01f, MTXMODE_APPLY); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - - if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_kakera.c", 268), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_80093D84(globalCtx->state.gfxCtx); - - if (colorIdx >= 0) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, colors[colorIdx].r, colors[colorIdx].g, colors[colorIdx].b, 255); - } - - gSPDisplayList(POLY_XLU_DISP++, this->gfx); - } else { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_kakera.c", 286), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_80093D18(globalCtx->state.gfxCtx); - - if (colorIdx >= 0) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, colors[colorIdx].r, colors[colorIdx].g, colors[colorIdx].b, 255); - } - - gSPDisplayList(POLY_OPA_DISP++, this->gfx); - } - - CLOSE_DISPS(gfxCtx, "../z_eff_kakera.c", 302); -} - -void func_809A9BA8(EffectSs* this, GlobalContext* globalCtx) { - this->rObjBankIdx = Object_GetIndex(&globalCtx->objectCtx, this->rObjId); - - if ((this->rObjBankIdx < 0) || !Object_IsLoaded(&globalCtx->objectCtx, this->rObjBankIdx)) { - this->life = 0; - this->draw = NULL; - } -} - -void func_809A9C10(EffectSs* this) { - f32 temp_f14; - f32 temp_f12; - f32 temp_f16; - f32 temp_f2; - f32 temp_f18; - f32 temp_f20; - f32 temp_f0; - - temp_f18 = this->rReg5 / 1024.0f; - temp_f20 = this->rReg6 / 1024.0f; - temp_f14 = (this->rReg9 / 1024.0f) * 4.0f; - - temp_f2 = this->velocity.x - func_809A9818(0.0f, temp_f14); - temp_f16 = this->velocity.y - func_809A9818(0.0f, temp_f14); - temp_f12 = this->velocity.z - func_809A9818(0.0f, temp_f14); - - if (temp_f2 > 0.0f) { - this->velocity.x -= ((temp_f2 * temp_f18) + (SQ(temp_f2) * temp_f20)); - } else { - this->velocity.x -= ((temp_f2 * temp_f18) - (SQ(temp_f2) * temp_f20)); - } - - if (temp_f16 > 0.0f) { - temp_f0 = temp_f16 * temp_f18; - temp_f2 = SQ(temp_f16) * temp_f20; - this->velocity.y -= (temp_f0 + temp_f2); - } else { - temp_f0 = temp_f16 * temp_f18; - temp_f2 = SQ(temp_f16) * temp_f20; - this->velocity.y -= (temp_f0 - temp_f2); - } - - if (temp_f12 > 0.0f) { - this->velocity.z -= (temp_f0 + temp_f2); - } else { - this->velocity.z -= (temp_f0 - temp_f2); - } -} - -void func_809A9DC0(EffectSs* this) { - this->accel.x = this->accel.y = this->accel.z = 0.0f; -} - -f32 func_809A9DD8(f32 arg0, s32 arg1) { - return 1.0f; -} - -static f32 D_809AA530[] = { - 1.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, -}; - -f32 func_809A9DEC(f32 arg0, s32 arg1) { - if (D_809AA530[arg1] < arg0) { - return D_809AA530[arg1] / arg0; - } else { - return 1.0f; - } -} - -f32 func_809A9E28(f32 arg0, s32 arg1) { - f32 temp = SQ(arg0); - - if (D_809AA530[arg1] < temp) { - return D_809AA530[arg1] / temp; - } else { - return 1.0f; - } -} - -f32 func_809A9E68(f32 arg0, s32 arg1) { - return func_809A9E28(arg0, arg1); -} - -s32 func_809A9E88(EffectSs* this, Vec3f* diff, f32 dist) { - static f32 D_809AA558[] = { 0.05f, 1.0f }; - s32 temp_v0; - f32 phi_f0; - - temp_v0 = this->rReg0 & 3; - - if (temp_v0 != 0) { - - if (dist > 1.0f) { - phi_f0 = 1.0f / dist; - } else { - phi_f0 = 1.0f; - } - - this->accel.x += ((D_809AA558[temp_v0 - 1] * diff->z) * phi_f0); - this->accel.z -= ((D_809AA558[temp_v0 - 1] * diff->x) * phi_f0); - } - - return 1; -} - -s32 func_809A9F10(EffectSs* this, Vec3f* diff, f32 dist) { - static f32 D_809AA560[] = { 4.0f, 0.1f, 0.3f, 0.9f, -0.1f, -0.3f, -0.9f }; - s32 temp_v0; - - temp_v0 = (this->rReg0 >> 2) & 7; - - if (temp_v0 != 0) { - this->accel.y += D_809AA560[temp_v0]; - } - - return 1; -} - -s32 func_809A9F4C(EffectSs* this, Vec3f* diff, f32 dist) { - static f32 D_809AA57C[] = { 0.1f, 1.0f, 6.0f }; - s32 temp_v0; - f32 phi_f0; - - temp_v0 = (this->rReg0 >> 5) & 3; - - if (temp_v0 != 0) { - - if (dist > 1.0f) { - phi_f0 = 1.0f / dist; - } else { - phi_f0 = 1.0f; - } - - this->accel.x -= ((diff->x * D_809AA57C[temp_v0 - 1]) * phi_f0); - this->accel.z -= ((diff->z * D_809AA57C[temp_v0 - 1]) * phi_f0); - } - - return 1; -} - -s32 func_809A9FD8(EffectSs* this, Vec3f* diff, f32 dist) { - static f32 (*D_809AA588[])(f32 dist, s32 arg1) = { - func_809A9DD8, func_809A9DEC, func_809A9DEC, func_809A9DEC, func_809A9E28, - func_809A9E28, func_809A9E28, func_809A9E68, func_809A9E68, func_809A9E68, - }; - f32 temp_f0; - s32 temp_a1; - - temp_a1 = (this->rReg0 >> 7) & 0xF; - temp_f0 = D_809AA588[temp_a1](dist, temp_a1); - temp_f0 = func_809A9818(temp_f0, (this->rReg9 * temp_f0) / 1024.0f); - - this->accel.x *= temp_f0; - this->accel.y *= temp_f0; - this->accel.z *= temp_f0; - - this->accel.x += temp_f0 * 0.01f; - this->accel.y += temp_f0 * 0.01f; - this->accel.z += temp_f0 * 0.01f; - - return 1; -} - -s32 func_809AA0B8(EffectSs* this, Vec3f* diff, f32 dist) { - this->accel.y += this->rGravity / 256.0f; - - return 1; -} - -s32 func_809AA0EC(EffectSs* this) { - Vec3f diff; - f32 dist; - - func_809A9DC0(this); - - diff.x = this->pos.x - this->vec.x; - diff.y = this->pos.y - this->vec.y; - diff.z = this->pos.z - this->vec.z; - - dist = sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)); - - if (dist > 1000.0f) { - return 0; - } - - if (this->rReg0 != 0) { - if (!func_809A9E88(this, &diff, dist)) { - return false; - } - - if (!func_809A9F10(this, &diff, dist)) { - return false; - } - - if (!func_809A9F4C(this, &diff, dist)) { - return false; - } - - if (!func_809A9FD8(this, &diff, dist)) { - return false; - } - } - - if (!func_809AA0B8(this, &diff, dist)) { - return false; - } - - return true; -} - -void func_809AA230(EffectSs* this, GlobalContext* globalCtx) { - static f32 D_809AA5B0[] = { 10.0f, 20.0f, 40.0f }; - Player* player = GET_PLAYER(globalCtx); - - if (this->rReg8 == 0) { - if ((((this->rReg4 >> 4) & 1) * 0x10) == 0x10) { - if (this->pos.y <= (player->actor.floorHeight - ((this->rReg4 >> 2) & 3))) { - this->rReg9 = 0; - this->rReg0 = 0; - this->rReg4 &= ~0x60; - this->accel.x = this->accel.y = this->accel.z = 0.0f; - this->velocity.x = this->velocity.y = this->velocity.z = 0.0f; - this->rReg5 = this->rReg9; - this->rGravity = this->rReg9; - } - } else { - if (this->pos.y <= ((player->actor.floorHeight - ((this->rReg4 >> 2) & 3)) - 600.0f)) { - this->life = 0; - } - } - } else { - switch (this->rReg4 & 3) { - case 0: - this->rReg8 = 0; - break; - case 1: - if (this->velocity.y < 0.0f) { - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_809AA5B0[(this->rReg4 >> 2) & 3])) { - this->velocity.x *= func_809A9818(0.9f, 0.2f); - this->velocity.y *= -0.8f; - this->velocity.z *= func_809A9818(0.9f, 0.2f); - - if (this->rReg8 > 0) { - this->rReg8 -= 1; - } - } - } - break; - case 2: - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_809AA5B0[(this->rReg4 >> 2) & 3])) {} - break; - } - } -} - -void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - switch (((this->rReg4 >> 5) & 3) << 5) { - case 0x20: - this->rPitch += 0xB; - this->rYaw += 3; - break; - case 0x40: - this->rPitch += 0x41; - this->rYaw += 0xB; - break; - case 0x60: - this->rPitch += 0x9B; - this->rYaw += 0x1F; - break; - } - - func_809A9C10(this); - - if (!func_809AA0EC(this)) { - this->life = 0; - } - - func_809AA230(this, globalCtx); - - if (this->rObjId != KAKERA_OBJECT_DEFAULT) { - func_809A9BA8(this, globalCtx); - } -} diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.cpp b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.cpp new file mode 100644 index 000000000..ece750af4 --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.cpp @@ -0,0 +1,429 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_KAKERA_Z_EFF_SS_KAKERA_C +#include "actor_common.h" +/* + * File: z_eff_ss_kakera.c + * Overlay: ovl_Effect_Ss_Kakera + * Description: Fragments. Appearance is determined by the supplied display list. + */ + +#include "z_eff_ss_kakera.h" +#include "def/code_800FD970.h" +#include "def/logutils.h" +#include "def/sys_matrix.h" +#include "def/z_bgcheck.h" +#include "def/z_rcp.h" +#include "def/z_scene.h" + +#define rReg0 regs[0] +#define rGravity regs[1] +#define rPitch regs[2] +#define rYaw regs[3] +#define rReg4 regs[4] +#define rReg5 regs[5] +#define rReg6 regs[6] +#define rScale regs[7] +#define rReg8 regs[8] +#define rReg9 regs[9] +#define rObjId regs[10] +#define rObjBankIdx regs[11] +#define rColorIdx regs[12] + +u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +void func_809A9BA8(EffectSs* pthis, GlobalContext* globalCtx); + +EffectSsInit Effect_Ss_Kakera_InitVars = { + EFFECT_SS_KAKERA, + EffectSsKakera_Init, +}; + +u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + EffectSsKakeraInitParams* initParams = (EffectSsKakeraInitParams*)initParamsx; + s32 objId; + + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->life = initParams->life; + pthis->priority = 101; + + if (initParams->dList != NULL) { + pthis->gfx = initParams->dList; + objId = initParams->objId; + + if (objId == OBJECT_GAMEPLAY_KEEP || objId == OBJECT_GAMEPLAY_FIELD_KEEP || + objId == OBJECT_GAMEPLAY_DANGEON_KEEP) { + pthis->rObjId = KAKERA_OBJECT_DEFAULT; + } else { + pthis->rObjId = initParams->objId; + func_809A9BA8(pthis, globalCtx); + } + + } else { + osSyncPrintf("shape_modelがNULL\n"); + LogUtils_HungupThread("../z_eff_kakera.c", 178); + } + + pthis->draw = EffectSsKakera_Draw; + pthis->update = EffectSsKakera_Update; + pthis->vec = initParams->unk_18; + pthis->rReg0 = initParams->unk_2C; + pthis->rGravity = initParams->gravity; + pthis->rPitch = Rand_ZeroOne() * 32767.0f; + pthis->rYaw = Rand_ZeroOne() * 32767.0f; + pthis->rReg4 = initParams->unk_26; + pthis->rReg5 = initParams->unk_28; + pthis->rReg6 = initParams->unk_2A; + pthis->rScale = initParams->scale; + pthis->rReg8 = initParams->unk_30; + pthis->rReg9 = initParams->unk_32; + pthis->rColorIdx = initParams->colorIdx; + + return 1; +} + +f32 func_809A9818(f32 arg0, f32 arg1) { + f32 temp_f2; + + if (arg1 < 0.0f) { + osSyncPrintf("範囲がマイナス!!(randomD_sectionUniformity)\n"); + } + + temp_f2 = Rand_ZeroOne() * arg1; + return ((temp_f2 * 2.0f) - arg1) + arg0; +} + +void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + static Color_RGB8 colors[] = { { 255, 255, 255 }, { 235, 170, 130 } }; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + f32 scale; + s32 colorIdx; + + scale = pthis->rScale / 256.0f; + colorIdx = pthis->rColorIdx; + + OPEN_DISPS(gfxCtx, "../z_eff_kakera.c", 241); + + if (pthis->rObjId != KAKERA_OBJECT_DEFAULT) { + if ((((pthis->rReg4 >> 7) & 1) << 7) == 0x80) { + gSPSegment(POLY_XLU_DISP++, 0x06, gObjectTable[pthis->rObjBankIdx].vromStart.get()); + } else { + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->rObjBankIdx].vromStart.get()); + } + } + + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); + Matrix_RotateY(pthis->rYaw * 0.01f, MTXMODE_APPLY); + Matrix_RotateX(pthis->rPitch * 0.01f, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + if ((((pthis->rReg4 >> 7) & 1) << 7) == 0x80) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_kakera.c", 268), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_80093D84(globalCtx->state.gfxCtx); + + if (colorIdx >= 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, colors[colorIdx].r, colors[colorIdx].g, colors[colorIdx].b, 255); + } + + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_kakera.c", 286), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_80093D18(globalCtx->state.gfxCtx); + + if (colorIdx >= 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, colors[colorIdx].r, colors[colorIdx].g, colors[colorIdx].b, 255); + } + + gSPDisplayList(POLY_OPA_DISP++, pthis->gfx); + } + + CLOSE_DISPS(gfxCtx, "../z_eff_kakera.c", 302); +} + +void func_809A9BA8(EffectSs* pthis, GlobalContext* globalCtx) { + pthis->rObjBankIdx = Object_GetIndex(&globalCtx->objectCtx, pthis->rObjId); + + if ((pthis->rObjBankIdx < 0) || !Object_IsLoaded(&globalCtx->objectCtx, pthis->rObjBankIdx)) { + pthis->life = 0; + pthis->draw = NULL; + } +} + +void func_809A9C10(EffectSs* pthis) { + f32 temp_f14; + f32 temp_f12; + f32 temp_f16; + f32 temp_f2; + f32 temp_f18; + f32 temp_f20; + f32 temp_f0; + + temp_f18 = pthis->rReg5 / 1024.0f; + temp_f20 = pthis->rReg6 / 1024.0f; + temp_f14 = (pthis->rReg9 / 1024.0f) * 4.0f; + + temp_f2 = pthis->velocity.x - func_809A9818(0.0f, temp_f14); + temp_f16 = pthis->velocity.y - func_809A9818(0.0f, temp_f14); + temp_f12 = pthis->velocity.z - func_809A9818(0.0f, temp_f14); + + if (temp_f2 > 0.0f) { + pthis->velocity.x -= ((temp_f2 * temp_f18) + (SQ(temp_f2) * temp_f20)); + } else { + pthis->velocity.x -= ((temp_f2 * temp_f18) - (SQ(temp_f2) * temp_f20)); + } + + if (temp_f16 > 0.0f) { + temp_f0 = temp_f16 * temp_f18; + temp_f2 = SQ(temp_f16) * temp_f20; + pthis->velocity.y -= (temp_f0 + temp_f2); + } else { + temp_f0 = temp_f16 * temp_f18; + temp_f2 = SQ(temp_f16) * temp_f20; + pthis->velocity.y -= (temp_f0 - temp_f2); + } + + if (temp_f12 > 0.0f) { + pthis->velocity.z -= (temp_f0 + temp_f2); + } else { + pthis->velocity.z -= (temp_f0 - temp_f2); + } +} + +void func_809A9DC0(EffectSs* pthis) { + pthis->accel.x = pthis->accel.y = pthis->accel.z = 0.0f; +} + +f32 func_809A9DD8(f32 arg0, s32 arg1) { + return 1.0f; +} + +static f32 D_809AA530[] = { + 1.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, +}; + +f32 func_809A9DEC(f32 arg0, s32 arg1) { + if (D_809AA530[arg1] < arg0) { + return D_809AA530[arg1] / arg0; + } else { + return 1.0f; + } +} + +f32 func_809A9E28(f32 arg0, s32 arg1) { + f32 temp = SQ(arg0); + + if (D_809AA530[arg1] < temp) { + return D_809AA530[arg1] / temp; + } else { + return 1.0f; + } +} + +f32 func_809A9E68(f32 arg0, s32 arg1) { + return func_809A9E28(arg0, arg1); +} + +s32 func_809A9E88(EffectSs* pthis, Vec3f* diff, f32 dist) { + static f32 D_809AA558[] = { 0.05f, 1.0f }; + s32 temp_v0; + f32 phi_f0; + + temp_v0 = pthis->rReg0 & 3; + + if (temp_v0 != 0) { + + if (dist > 1.0f) { + phi_f0 = 1.0f / dist; + } else { + phi_f0 = 1.0f; + } + + pthis->accel.x += ((D_809AA558[temp_v0 - 1] * diff->z) * phi_f0); + pthis->accel.z -= ((D_809AA558[temp_v0 - 1] * diff->x) * phi_f0); + } + + return 1; +} + +s32 func_809A9F10(EffectSs* pthis, Vec3f* diff, f32 dist) { + static f32 D_809AA560[] = { 4.0f, 0.1f, 0.3f, 0.9f, -0.1f, -0.3f, -0.9f }; + s32 temp_v0; + + temp_v0 = (pthis->rReg0 >> 2) & 7; + + if (temp_v0 != 0) { + pthis->accel.y += D_809AA560[temp_v0]; + } + + return 1; +} + +s32 func_809A9F4C(EffectSs* pthis, Vec3f* diff, f32 dist) { + static f32 D_809AA57C[] = { 0.1f, 1.0f, 6.0f }; + s32 temp_v0; + f32 phi_f0; + + temp_v0 = (pthis->rReg0 >> 5) & 3; + + if (temp_v0 != 0) { + + if (dist > 1.0f) { + phi_f0 = 1.0f / dist; + } else { + phi_f0 = 1.0f; + } + + pthis->accel.x -= ((diff->x * D_809AA57C[temp_v0 - 1]) * phi_f0); + pthis->accel.z -= ((diff->z * D_809AA57C[temp_v0 - 1]) * phi_f0); + } + + return 1; +} + +s32 func_809A9FD8(EffectSs* pthis, Vec3f* diff, f32 dist) { + static f32 (*D_809AA588[])(f32 dist, s32 arg1) = { + func_809A9DD8, func_809A9DEC, func_809A9DEC, func_809A9DEC, func_809A9E28, + func_809A9E28, func_809A9E28, func_809A9E68, func_809A9E68, func_809A9E68, + }; + f32 temp_f0; + s32 temp_a1; + + temp_a1 = (pthis->rReg0 >> 7) & 0xF; + temp_f0 = D_809AA588[temp_a1](dist, temp_a1); + temp_f0 = func_809A9818(temp_f0, (pthis->rReg9 * temp_f0) / 1024.0f); + + pthis->accel.x *= temp_f0; + pthis->accel.y *= temp_f0; + pthis->accel.z *= temp_f0; + + pthis->accel.x += temp_f0 * 0.01f; + pthis->accel.y += temp_f0 * 0.01f; + pthis->accel.z += temp_f0 * 0.01f; + + return 1; +} + +s32 func_809AA0B8(EffectSs* pthis, Vec3f* diff, f32 dist) { + pthis->accel.y += pthis->rGravity / 256.0f; + + return 1; +} + +s32 func_809AA0EC(EffectSs* pthis) { + Vec3f diff; + f32 dist; + + func_809A9DC0(pthis); + + diff.x = pthis->pos.x - pthis->vec.x; + diff.y = pthis->pos.y - pthis->vec.y; + diff.z = pthis->pos.z - pthis->vec.z; + + dist = sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)); + + if (dist > 1000.0f) { + return 0; + } + + if (pthis->rReg0 != 0) { + if (!func_809A9E88(pthis, &diff, dist)) { + return false; + } + + if (!func_809A9F10(pthis, &diff, dist)) { + return false; + } + + if (!func_809A9F4C(pthis, &diff, dist)) { + return false; + } + + if (!func_809A9FD8(pthis, &diff, dist)) { + return false; + } + } + + if (!func_809AA0B8(pthis, &diff, dist)) { + return false; + } + + return true; +} + +void func_809AA230(EffectSs* pthis, GlobalContext* globalCtx) { + static f32 D_809AA5B0[] = { 10.0f, 20.0f, 40.0f }; + Player* player = GET_PLAYER(globalCtx); + + if (pthis->rReg8 == 0) { + if ((((pthis->rReg4 >> 4) & 1) * 0x10) == 0x10) { + if (pthis->pos.y <= (player->actor.floorHeight - ((pthis->rReg4 >> 2) & 3))) { + pthis->rReg9 = 0; + pthis->rReg0 = 0; + pthis->rReg4 &= ~0x60; + pthis->accel.x = pthis->accel.y = pthis->accel.z = 0.0f; + pthis->velocity.x = pthis->velocity.y = pthis->velocity.z = 0.0f; + pthis->rReg5 = pthis->rReg9; + pthis->rGravity = pthis->rReg9; + } + } else { + if (pthis->pos.y <= ((player->actor.floorHeight - ((pthis->rReg4 >> 2) & 3)) - 600.0f)) { + pthis->life = 0; + } + } + } else { + switch (pthis->rReg4 & 3) { + case 0: + pthis->rReg8 = 0; + break; + case 1: + if (pthis->velocity.y < 0.0f) { + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &pthis->pos, D_809AA5B0[(pthis->rReg4 >> 2) & 3])) { + pthis->velocity.x *= func_809A9818(0.9f, 0.2f); + pthis->velocity.y *= -0.8f; + pthis->velocity.z *= func_809A9818(0.9f, 0.2f); + + if (pthis->rReg8 > 0) { + pthis->rReg8 -= 1; + } + } + } + break; + case 2: + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &pthis->pos, D_809AA5B0[(pthis->rReg4 >> 2) & 3])) {} + break; + } + } +} + +void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + switch (((pthis->rReg4 >> 5) & 3) << 5) { + case 0x20: + pthis->rPitch += 0xB; + pthis->rYaw += 3; + break; + case 0x40: + pthis->rPitch += 0x41; + pthis->rYaw += 0xB; + break; + case 0x60: + pthis->rPitch += 0x9B; + pthis->rYaw += 0x1F; + break; + } + + func_809A9C10(pthis); + + if (!func_809AA0EC(pthis)) { + pthis->life = 0; + } + + func_809AA230(pthis, globalCtx); + + if (pthis->rObjId != KAKERA_OBJECT_DEFAULT) { + func_809A9BA8(pthis, globalCtx); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c b/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c deleted file mode 100644 index c7ee5279f..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.c +++ /dev/null @@ -1,160 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_KIRAKIRA_Z_EFF_SS_KIRAKIRA_C -#include "actor_common.h" -/* - * File: z_eff_ss_kirakira.c - * Overlay: ovl_Effect_Ss_KiraKira - * Description: Sparkles - */ - -#include "z_eff_ss_kirakira.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "def/code_800FD970.h" -#include "def/sys_matrix.h" -#include "def/z_actor.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_skin_matrix.h" - -#define rRotSpeed regs[0] -#define rYaw regs[1] -#define rPrimColorR regs[2] -#define rPrimColorG regs[3] -#define rPrimColorB regs[4] -#define rPrimColorA regs[5] -#define rEnvColorR regs[6] -#define rEnvColorG regs[7] -#define rEnvColorB regs[8] -#define rEnvColorA regs[9] -#define rAlphaStep regs[10] -#define rScale regs[11] -#define rLifespan regs[12] - -u32 EffectSsKiraKira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsKiraKira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_809AABF0(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_809AACAC(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_809AAD6C(GlobalContext* globalCtx, u32 index, EffectSs* this); - -EffectSsInit Effect_Ss_KiraKira_InitVars = { - EFFECT_SS_KIRAKIRA, - EffectSsKiraKira_Init, -}; - -u32 EffectSsKiraKira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsKiraKiraInitParams* initParams = (EffectSsKiraKiraInitParams*)initParamsx; - - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - - if ((this->life = initParams->life) < 0) { - this->life = -this->life; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffSparklesDL); - this->update = func_809AAD6C; - this->rEnvColorA = initParams->scale; - this->rScale = 0; - } else { - this->gfx = SEGMENTED_TO_VIRTUAL(gEffSparklesDL); - - if (initParams->updateMode == 0) { - this->update = func_809AABF0; - } else { - this->update = func_809AACAC; - } - - this->rEnvColorA = initParams->envColor.a; - this->rScale = initParams->scale; - } - - this->draw = EffectSsKiraKira_Draw; - this->rRotSpeed = initParams->rotSpeed; - this->rYaw = initParams->yaw; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rAlphaStep = initParams->alphaStep; - this->rLifespan = initParams->life; - - return 1; -} - -void EffectSsKiraKira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx; - f32 scale; - s32 pad; - MtxF mfTrans; - MtxF mfRotY; - MtxF mfScale; - MtxF mfTrans11DA0; - MtxF mfTrans11DA0RotY; - MtxF mfResult; - Mtx* mtx; - - scale = this->rScale / 10000.0f; - gfxCtx = globalCtx->state.gfxCtx; - - OPEN_DISPS(gfxCtx, "../z_eff_ss_kirakira.c", 257); - - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); - SkinMatrix_SetRotateZYX(&mfRotY, 0, 0, this->rYaw); - SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfRotY, &mfTrans11DA0RotY); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0RotY, &mfScale, &mfResult); - gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); - - if (mtx != NULL) { - gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_80093C14(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - (((s8)((55.0f / this->rLifespan) * this->life) + 200))); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); - } - - CLOSE_DISPS(gfxCtx, "../z_eff_ss_kirakira.c", 301); -} - -void func_809AABF0(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; - this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; - this->rEnvColorA += this->rAlphaStep; - - if (this->rEnvColorA < 0) { - this->rEnvColorA = 0; - this->rAlphaStep = -this->rAlphaStep; - } else if (this->rEnvColorA > 255) { - this->rEnvColorA = 255; - this->rAlphaStep = -this->rAlphaStep; - } - - this->rYaw += this->rRotSpeed; -} - -void func_809AACAC(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->velocity.x *= 0.95f; - this->velocity.z *= 0.95f; - this->accel.x = Rand_CenteredFloat(0.2f); - this->accel.z = Rand_CenteredFloat(0.2f); - this->rEnvColorA += this->rAlphaStep; - - if (this->rEnvColorA < 0) { - this->rEnvColorA = 0; - this->rAlphaStep = -this->rAlphaStep; - } else if (this->rEnvColorA > 255) { - this->rEnvColorA = 255; - this->rAlphaStep = -this->rAlphaStep; - } - - this->rYaw += this->rRotSpeed; -} - -void func_809AAD6C(GlobalContext* globalCtx, u32 index, EffectSs* this) { - this->rScale = this->rEnvColorA * Math_SinS((32768.0f / this->rLifespan) * this->life); -} diff --git a/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.cpp b/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.cpp new file mode 100644 index 000000000..d48f0c4f4 --- /dev/null +++ b/src/overlays/effects/ovl_Effect_Ss_KiraKira/z_eff_ss_kirakira.cpp @@ -0,0 +1,160 @@ +#define INTERNAL_SRC_OVERLAYS_EFFECTS_OVL_EFFECT_SS_KIRAKIRA_Z_EFF_SS_KIRAKIRA_C +#include "actor_common.h" +/* + * File: z_eff_ss_kirakira.c + * Overlay: ovl_Effect_Ss_KiraKira + * Description: Sparkles + */ + +#include "z_eff_ss_kirakira.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "def/code_800FD970.h" +#include "def/sys_matrix.h" +#include "def/z_actor.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_skin_matrix.h" + +#define rRotSpeed regs[0] +#define rYaw regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rPrimColorA regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rEnvColorA regs[9] +#define rAlphaStep regs[10] +#define rScale regs[11] +#define rLifespan regs[12] + +u32 EffectSsKiraKira_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsKiraKira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void func_809AABF0(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void func_809AACAC(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void func_809AAD6C(GlobalContext* globalCtx, u32 index, EffectSs* pthis); + +EffectSsInit Effect_Ss_KiraKira_InitVars = { + EFFECT_SS_KIRAKIRA, + EffectSsKiraKira_Init, +}; + +u32 EffectSsKiraKira_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { + EffectSsKiraKiraInitParams* initParams = (EffectSsKiraKiraInitParams*)initParamsx; + + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + + if ((pthis->life = initParams->life) < 0) { + pthis->life = -pthis->life; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffSparklesDL); + pthis->update = func_809AAD6C; + pthis->rEnvColorA = initParams->scale; + pthis->rScale = 0; + } else { + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffSparklesDL); + + if (initParams->updateMode == 0) { + pthis->update = func_809AABF0; + } else { + pthis->update = func_809AACAC; + } + + pthis->rEnvColorA = initParams->envColor.a; + pthis->rScale = initParams->scale; + } + + pthis->draw = EffectSsKiraKira_Draw; + pthis->rRotSpeed = initParams->rotSpeed; + pthis->rYaw = initParams->yaw; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rAlphaStep = initParams->alphaStep; + pthis->rLifespan = initParams->life; + + return 1; +} + +void EffectSsKiraKira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + GraphicsContext* gfxCtx; + f32 scale; + s32 pad; + MtxF mfTrans; + MtxF mfRotY; + MtxF mfScale; + MtxF mfTrans11DA0; + MtxF mfTrans11DA0RotY; + MtxF mfResult; + Mtx* mtx; + + scale = pthis->rScale / 10000.0f; + gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_eff_ss_kirakira.c", 257); + + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); + SkinMatrix_SetRotateZYX(&mfRotY, 0, 0, pthis->rYaw); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); + SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfRotY, &mfTrans11DA0RotY); + SkinMatrix_MtxFMtxFMult(&mfTrans11DA0RotY, &mfScale, &mfResult); + gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_80093C14(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + (((s8)((55.0f / pthis->rLifespan) * pthis->life) + 200))); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); + } + + CLOSE_DISPS(gfxCtx, "../z_eff_ss_kirakira.c", 301); +} + +void func_809AABF0(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + pthis->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + pthis->rEnvColorA += pthis->rAlphaStep; + + if (pthis->rEnvColorA < 0) { + pthis->rEnvColorA = 0; + pthis->rAlphaStep = -pthis->rAlphaStep; + } else if (pthis->rEnvColorA > 255) { + pthis->rEnvColorA = 255; + pthis->rAlphaStep = -pthis->rAlphaStep; + } + + pthis->rYaw += pthis->rRotSpeed; +} + +void func_809AACAC(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->velocity.x *= 0.95f; + pthis->velocity.z *= 0.95f; + pthis->accel.x = Rand_CenteredFloat(0.2f); + pthis->accel.z = Rand_CenteredFloat(0.2f); + pthis->rEnvColorA += pthis->rAlphaStep; + + if (pthis->rEnvColorA < 0) { + pthis->rEnvColorA = 0; + pthis->rAlphaStep = -pthis->rAlphaStep; + } else if (pthis->rEnvColorA > 255) { + pthis->rEnvColorA = 255; + pthis->rAlphaStep = -pthis->rAlphaStep; + } + + pthis->rYaw += pthis->rRotSpeed; +} + +void func_809AAD6C(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + pthis->rScale = pthis->rEnvColorA * Math_SinS((32768.0f / pthis->rLifespan) * pthis->life); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.cpp similarity index 58% rename from src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c rename to src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.cpp index e76a718a2..db518a60e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.cpp @@ -29,44 +29,44 @@ #define rYaw regs[10] #define rLifespan regs[11] -u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Lightning_InitVars = { EFFECT_SS_LIGHTNING, EffectSsLightning_Init, }; -u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsLightningInitParams* initParams = (EffectSsLightningInitParams*)initParamsx; - this->pos = initParams->pos; - this->gfx = SEGMENTED_TO_VIRTUAL(gEffLightningDL); - this->life = initParams->life; - this->draw = EffectSsLightning_Draw; - this->update = EffectSsLightning_Update; - this->rPrimColorR = initParams->primColor.r; - this->rPrimColorG = initParams->primColor.g; - this->rPrimColorB = initParams->primColor.b; - this->rPrimColorA = initParams->primColor.a; - this->rEnvColorR = initParams->envColor.r; - this->rEnvColorG = initParams->envColor.g; - this->rEnvColorB = initParams->envColor.b; - this->rEnvColorA = initParams->envColor.a; - this->rNumBolts = initParams->numBolts; - this->rScale = initParams->scale; - this->rYaw = initParams->yaw; - this->rLifespan = initParams->life; + pthis->pos = initParams->pos; + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffLightningDL); + pthis->life = initParams->life; + pthis->draw = EffectSsLightning_Draw; + pthis->update = EffectSsLightning_Update; + pthis->rPrimColorR = initParams->primColor.r; + pthis->rPrimColorG = initParams->primColor.g; + pthis->rPrimColorB = initParams->primColor.b; + pthis->rPrimColorA = initParams->primColor.a; + pthis->rEnvColorR = initParams->envColor.r; + pthis->rEnvColorG = initParams->envColor.g; + pthis->rEnvColorB = initParams->envColor.b; + pthis->rEnvColorA = initParams->envColor.a; + pthis->rNumBolts = initParams->numBolts; + pthis->rScale = initParams->scale; + pthis->rYaw = initParams->yaw; + pthis->rLifespan = initParams->life; return 1; } -void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s16 yaw, EffectSs* this) { +void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s16 yaw, EffectSs* pthis) { EffectSs newLightning; EffectSs_Delete(&newLightning); - newLightning = *this; + newLightning = *pthis; newLightning.pos = *pos; newLightning.rNumBolts--; newLightning.rYaw = yaw; @@ -75,7 +75,7 @@ void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s16 ya EffectSs_Insert(globalCtx, &newLightning); } -void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { static void* lightningTextures[] = { gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, @@ -94,17 +94,17 @@ void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) OPEN_DISPS(gfxCtx, "../z_eff_ss_lightning.c", 233); - yScale = this->rScale * 0.01f; - texIdx = this->rLifespan - this->life; + yScale = pthis->rScale * 0.01f; + texIdx = pthis->rLifespan - pthis->life; if (texIdx > 7) { texIdx = 7; } - SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetTranslate(&mfTrans, pthis->pos.x, pthis->pos.y, pthis->pos.z); xzScale = yScale * 0.6f; SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale); - SkinMatrix_SetRotateZYX(&mfRotate, this->vec.x, this->vec.y, this->rYaw); + SkinMatrix_SetRotateZYX(&mfRotate, pthis->vec.x, pthis->vec.y, pthis->rYaw); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfRotate, &mfTrans11DA0Rotate); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0Rotate, &mfScale, &mfResult); @@ -117,36 +117,36 @@ void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80094C50(gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(lightningTextures[texIdx])); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, - this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, + pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, pthis->gfx); } CLOSE_DISPS(gfxCtx, "../z_eff_ss_lightning.c", 281); } -void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 pad; Vec3f pos; s16 yaw; f32 scale; - if ((this->rNumBolts != 0) && ((this->life + 1) == this->rLifespan)) { + if ((pthis->rNumBolts != 0) && ((pthis->life + 1) == pthis->rLifespan)) { - yaw = this->rYaw + (((Rand_ZeroOne() < 0.5f) ? -1 : 1) * ((s16)((Rand_ZeroOne() * 3640.0f)) + 0xE38)); + yaw = pthis->rYaw + (((Rand_ZeroOne() < 0.5f) ? -1 : 1) * ((s16)((Rand_ZeroOne() * 3640.0f)) + 0xE38)); - scale = (this->rScale * 0.01f) * 80.0f; - pos.y = this->pos.y + (Math_SinS(this->rYaw - 0x4000) * scale); + scale = (pthis->rScale * 0.01f) * 80.0f; + pos.y = pthis->pos.y + (Math_SinS(pthis->rYaw - 0x4000) * scale); - scale = Math_CosS(this->rYaw - 0x4000) * scale; - pos.x = this->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); - pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + scale = Math_CosS(pthis->rYaw - 0x4000) * scale; + pos.x = pthis->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + pos.z = pthis->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); - EffectSsLightning_NewLightning(globalCtx, &pos, yaw, this); + EffectSsLightning_NewLightning(globalCtx, &pos, yaw, pthis); if (Rand_ZeroOne() < 0.1f) { - EffectSsLightning_NewLightning(globalCtx, &pos, (this->rYaw * 2) - yaw, this); + EffectSsLightning_NewLightning(globalCtx, &pos, (pthis->rYaw * 2) - yaw, pthis); } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.cpp similarity index 51% rename from src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c rename to src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.cpp index 6eea2c653..47c78a292 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.cpp @@ -27,102 +27,102 @@ #define rDirection regs[9] #define rScale regs[10] -u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; -u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsSibukiInitParams* initParams = (EffectSsSibukiInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; if (KREG(2) != 0) { - this->gfx = SEGMENTED_TO_VIRTUAL(gEffBubble2Tex); + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffBubble2Tex); } else { - this->gfx = SEGMENTED_TO_VIRTUAL(gEffBubble1Tex); + pthis->gfx = SEGMENTED_TO_VIRTUAL(gEffBubble1Tex); } - this->life = ((s16)((Rand_ZeroOne() * (500.0f + KREG(64))) * 0.01f)) + KREG(65) + 10; - this->rMoveDelay = initParams->moveDelay + 1; - this->draw = EffectSsSibuki_Draw; - this->update = EffectSsSibuki_Update; - this->rDirection = initParams->direction; - this->rScale = initParams->scale; - this->rPrimColorR = 100; - this->rPrimColorG = 100; - this->rPrimColorB = 100; - this->rPrimColorA = 100; - this->rEnvColorR = 255; - this->rEnvColorG = 255; - this->rEnvColorB = 255; - this->rEnvColorA = 255; + pthis->life = ((s16)((Rand_ZeroOne() * (500.0f + KREG(64))) * 0.01f)) + KREG(65) + 10; + pthis->rMoveDelay = initParams->moveDelay + 1; + pthis->draw = EffectSsSibuki_Draw; + pthis->update = EffectSsSibuki_Update; + pthis->rDirection = initParams->direction; + pthis->rScale = initParams->scale; + pthis->rPrimColorR = 100; + pthis->rPrimColorG = 100; + pthis->rPrimColorB = 100; + pthis->rPrimColorA = 100; + pthis->rEnvColorR = 255; + pthis->rEnvColorG = 255; + pthis->rEnvColorB = 255; + pthis->rEnvColorA = 255; return 1; } -void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - f32 scale = this->rScale / 100.0f; + f32 scale = pthis->rScale / 100.0f; OPEN_DISPS(gfxCtx, "../z_eff_ss_sibuki.c", 163); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_sibuki.c", 176), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D18(gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); - gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, pthis->rPrimColorA); + gDPSetEnvColor(POLY_OPA_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + gSPSegment(POLY_OPA_DISP++, 0x08, pthis->gfx); gSPDisplayList(POLY_OPA_DISP++, SEGMENTED_TO_VIRTUAL(gEffBubbleDL)); CLOSE_DISPS(gfxCtx, "../z_eff_ss_sibuki.c", 198); } -void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 pad[3]; f32 xzVelScale; s16 yaw; Player* player = GET_PLAYER(globalCtx); - if (this->pos.y <= player->actor.floorHeight) { - this->life = 0; + if (pthis->pos.y <= player->actor.floorHeight) { + pthis->life = 0; } - if (this->rMoveDelay != 0) { - this->rMoveDelay--; + if (pthis->rMoveDelay != 0) { + pthis->rMoveDelay--; - if (this->rMoveDelay == 0) { + if (pthis->rMoveDelay == 0) { yaw = Camera_GetInputDirYaw(Gameplay_GetCamera(globalCtx, 0)); xzVelScale = ((200.0f + KREG(20)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(23) + 20.0f)); - if (this->rDirection != 0) { + if (pthis->rDirection != 0) { xzVelScale *= -1.0f; } - this->velocity.x = Math_CosS(yaw) * xzVelScale; - this->velocity.z = -Math_SinS(yaw) * xzVelScale; + pthis->velocity.x = Math_CosS(yaw) * xzVelScale; + pthis->velocity.z = -Math_SinS(yaw) * xzVelScale; - this->velocity.y = ((700.0f + KREG(21)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(24) + 20.0f)); - this->accel.y = ((-100.0f + KREG(22)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * KREG(25)); + pthis->velocity.y = ((700.0f + KREG(21)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(24) + 20.0f)); + pthis->accel.y = ((-100.0f + KREG(22)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * KREG(25)); if (KREG(3) != 0) { - this->velocity.x *= (KREG(3) * 0.01f); - this->velocity.y *= (KREG(3) * 0.01f); - this->velocity.z *= (KREG(3) * 0.01f); - this->accel.y *= (KREG(4) * 0.01f); + pthis->velocity.x *= (KREG(3) * 0.01f); + pthis->velocity.y *= (KREG(3) * 0.01f); + pthis->velocity.z *= (KREG(3) * 0.01f); + pthis->accel.y *= (KREG(4) * 0.01f); } } } else { - if (this->rScale != 0) { - this->rScale = (this->rScale - KREG(26)) - 3; + if (pthis->rScale != 0) { + pthis->rScale = (pthis->rScale - KREG(26)) - 3; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.cpp similarity index 64% rename from src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c rename to src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.cpp index 13501cd23..e3d77940a 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki2/z_eff_ss_sibuki2.cpp @@ -22,64 +22,64 @@ #define rTexIdx regs[8] #define rScale regs[9] -u32 EffectSsSibuki2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsSibuki2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsSibuki2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsSibuki2_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsSibuki2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsSibuki2_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Sibuki2_InitVars = { EFFECT_SS_SIBUKI2, EffectSsSibuki2_Init, }; -u32 EffectSsSibuki2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsSibuki2_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsSibuki2InitParams* initParams = (EffectSsSibuki2InitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->life = 10; - this->draw = EffectSsSibuki2_Draw; - this->update = EffectSsSibuki2_Update; - this->rScale = initParams->scale; - this->rPrimColorR = 255; - this->rPrimColorG = 255; - this->rPrimColorB = 255; - this->rPrimColorA = 255; - this->rEnvColorR = 100; - this->rEnvColorG = 100; - this->rEnvColorB = 100; - this->rEnvColorA = 255; - this->rTexIdx = 0; + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->life = 10; + pthis->draw = EffectSsSibuki2_Draw; + pthis->update = EffectSsSibuki2_Update; + pthis->rScale = initParams->scale; + pthis->rPrimColorR = 255; + pthis->rPrimColorG = 255; + pthis->rPrimColorB = 255; + pthis->rPrimColorA = 255; + pthis->rEnvColorR = 100; + pthis->rEnvColorG = 100; + pthis->rEnvColorB = 100; + pthis->rEnvColorA = 255; + pthis->rTexIdx = 0; return 1; } -void EffectSsSibuki2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsSibuki2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { static void* bubbleTextures[] = { gEffUnusedBubbles1Tex, gEffUnusedBubbles1Tex, gEffUnusedBubbles2Tex, gEffUnusedBubbles3Tex, gEffUnusedBubbles4Tex, gEffUnusedBubbles5Tex, gEffUnusedBubbles6Tex, gEffUnusedBubbles7Tex, gEffUnusedBubbles8Tex, }; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - f32 scale = this->rScale / 100.0f; + f32 scale = pthis->rScale / 100.0f; OPEN_DISPS(gfxCtx, "../z_eff_ss_sibuki2.c", 158); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_sibuki2.c", 171), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D18(gfxCtx); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); - gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(bubbleTextures[this->rTexIdx])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, pthis->rPrimColorR, pthis->rPrimColorG, pthis->rPrimColorB, pthis->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, pthis->rEnvColorR, pthis->rEnvColorG, pthis->rEnvColorB, pthis->rEnvColorA); + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(bubbleTextures[pthis->rTexIdx])); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffUnusedBubblesDL)); CLOSE_DISPS(gfxCtx, "../z_eff_ss_sibuki2.c", 198); } -void EffectSsSibuki2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if (this->rTexIdx < 8) { - this->rTexIdx++; +void EffectSsSibuki2_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if (pthis->rTexIdx < 8) { + pthis->rTexIdx++; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.cpp similarity index 57% rename from src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c rename to src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.cpp index 5ec62f21e..407338145 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.cpp @@ -11,28 +11,28 @@ #define rUnused regs[1] -u32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = { EFFECT_SS_SOLDER_SRCH_BALL, EffectSsSolderSrchBall_Init, }; -u32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsSolderSrchBallInitParams* initParams = (EffectSsSolderSrchBallInitParams*)initParamsx; - this->pos = initParams->pos; - this->velocity = initParams->velocity; - this->accel = initParams->accel; - this->update = EffectSsSolderSrchBall_Update; - this->life = 100; - this->rUnused = initParams->unused; - this->actor = initParams->linkDetected; // actor field was incorrectly used as a pointer to something else + pthis->pos = initParams->pos; + pthis->velocity = initParams->velocity; + pthis->accel = initParams->accel; + pthis->update = EffectSsSolderSrchBall_Update; + pthis->life = 100; + pthis->rUnused = initParams->unused; + pthis->actor = (Actor*)initParams->linkDetected; // actor field was incorrectly used as a pointer to something else return 1; } -void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { s32 pad; f32 playerPosDiffX; f32 playerPosDiffY; @@ -40,19 +40,19 @@ void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs s16* linkDetected; Player* player = GET_PLAYER(globalCtx); - linkDetected = this->actor; + linkDetected = (s16*)pthis->actor; - playerPosDiffX = player->actor.world.pos.x - this->pos.x; - playerPosDiffY = player->actor.world.pos.y - this->pos.y; - playerPosDiffZ = player->actor.world.pos.z - this->pos.z; + playerPosDiffX = player->actor.world.pos.x - pthis->pos.x; + playerPosDiffY = player->actor.world.pos.y - pthis->pos.y; + playerPosDiffZ = player->actor.world.pos.z - pthis->pos.z; - if (!BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, 30.0f)) { + if (!BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &pthis->pos, 30.0f)) { if (sqrtf(SQ(playerPosDiffX) + SQ(playerPosDiffY) + SQ(playerPosDiffZ)) < 70.0f) { *linkDetected = true; } } else { - if (this->life > 1) { - this->life = 1; + if (pthis->life > 1) { + pthis->life = 1; } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.cpp similarity index 68% rename from src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c rename to src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.cpp index c514a4ad1..162468565 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.cpp @@ -20,9 +20,9 @@ extern Gfx gCullBackDList[]; #define rObjBankIdx regs[0] #define rYaw regs[1] -u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Stick_InitVars = { EFFECT_SS_STICK, @@ -34,7 +34,7 @@ typedef struct { /* 0x04 */ Gfx* displayList; } StickDrawInfo; -u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { StickDrawInfo drawInfo[] = { { OBJECT_LINK_BOY, gLinkAdultBrokenGiantsKnifeBladeDL }, // adult, broken sword { OBJECT_LINK_CHILD, gLinkChildLinkDekuStickDL }, // child, broken stick @@ -42,46 +42,46 @@ u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void StickDrawInfo* ageInfoEntry = gSaveContext.linkAge + drawInfo; EffectSsStickInitParams* initParams = (EffectSsStickInitParams*)initParamsx; - this->rObjBankIdx = Object_GetIndex(&globalCtx->objectCtx, ageInfoEntry->objectID); - this->gfx = ageInfoEntry->displayList; - this->vec = this->pos = initParams->pos; - this->rYaw = initParams->yaw; - this->velocity.x = Math_SinS(initParams->yaw) * 6.0f; - this->velocity.z = Math_CosS(initParams->yaw) * 6.0f; - this->life = 20; - this->draw = EffectSsStick_Draw; - this->update = EffectSsStick_Update; - this->velocity.y = 26.0f; - this->accel.y = -4.0f; + pthis->rObjBankIdx = Object_GetIndex(&globalCtx->objectCtx, ageInfoEntry->objectID); + pthis->gfx = ageInfoEntry->displayList; + pthis->vec = pthis->pos = initParams->pos; + pthis->rYaw = initParams->yaw; + pthis->velocity.x = Math_SinS(initParams->yaw) * 6.0f; + pthis->velocity.z = Math_CosS(initParams->yaw) * 6.0f; + pthis->life = 20; + pthis->draw = EffectSsStick_Draw; + pthis->update = EffectSsStick_Update; + pthis->velocity.y = 26.0f; + pthis->accel.y = -4.0f; return 1; } -void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s32 pad; OPEN_DISPS(gfxCtx, "../z_eff_ss_stick.c", 153); - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); if (!LINK_IS_ADULT) { Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_RotateZYX(0, this->rYaw, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, pthis->rYaw, 0, MTXMODE_APPLY); } else { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - Matrix_RotateZYX(0, this->rYaw, globalCtx->state.frames * 10000, MTXMODE_APPLY); + Matrix_RotateZYX(0, pthis->rYaw, globalCtx->state.frames * 10000, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_stick.c", 176), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_80093D18(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[this->rObjBankIdx].vromStart); + gSPSegment(POLY_OPA_DISP++, 0x06, gObjectTable[pthis->rObjBankIdx].vromStart.get()); gSPSegment(POLY_OPA_DISP++, 0x0C, gCullBackDList); - gSPDisplayList(POLY_OPA_DISP++, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, pthis->gfx); CLOSE_DISPS(gfxCtx, "../z_eff_ss_stick.c", 188); } -void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.cpp similarity index 83% rename from src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c rename to src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.cpp index a4cd6670d..7db97842c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.cpp @@ -14,9 +14,9 @@ #define rReg0 regs[0] -u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx); +void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis); +void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis); EffectSsInit Effect_Ss_Stone1_InitVars = { EFFECT_SS_STONE1, @@ -40,32 +40,32 @@ static EffStoneDrawInfo sDrawInfo[] = { { gUnknownEffStone1Tex, { 255, 255, 255, 255 }, { 0, 255, 255, 255 } }, }; -u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* pthis, void* initParamsx) { EffectSsStone1InitParams* initParams = (EffectSsStone1InitParams*)initParamsx; Vec3f pos = initParams->pos; - this->pos = pos; - this->vec = pos; - this->life = 8; - this->rReg0 = initParams->unk_C; - this->draw = EffectSsStone1_Draw; - this->update = EffectSsStone1_Update; + pthis->pos = pos; + pthis->vec = pos; + pthis->life = 8; + pthis->rReg0 = initParams->unk_C; + pthis->draw = EffectSsStone1_Draw; + pthis->update = EffectSsStone1_Update; return 1; } -void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EffStoneDrawInfo* drawParams = &sDrawInfo[this->life]; + EffStoneDrawInfo* drawParams = &sDrawInfo[pthis->life]; Vec3f mfVec; f32 mfW; f32 scale; OPEN_DISPS(gfxCtx, "../z_eff_ss_stone1.c", 154); - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pthis->pos, &mfVec, &mfW); scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f; - Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(pthis->pos.x, pthis->pos.y, pthis->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_ss_stone1.c", 168), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -79,8 +79,8 @@ void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx, "../z_eff_ss_stone1.c", 183); } -void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - if ((this->life == 6) && (this->rReg0 != 0)) { +void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* pthis) { + if ((pthis->life == 6) && (pthis->rReg0 != 0)) { iREG(50) = 0; } } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c deleted file mode 100644 index 070db0c9f..000000000 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ /dev/null @@ -1,1926 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_FILE_CHOOSE_Z_FILE_CHOOSE_C -#include "actor_common.h" -#include "z_kankyo.h" -#include "z_player.h" -#include "z_play.h" -#include "z_file_choose.h" -#include "z_select.h" -#include "file_choose.h" -#include "segment_symbols.h" -#include "textures/title_static/title_static.h" -#include "textures/parameter_static/parameter_static.h" -#include "def/code_80069420.h" -#include "def/code_80097A00.h" -#include "def/code_800A9F30.h" -#include "def/code_800EC960.h" -#include "def/code_800F7260.h" -#include "def/code_800F9280.h" -#include "def/game.h" -#include "def/graph.h" -#include "def/shrink_window.h" -#include "def/sys_matrix.h" -#include "def/z_common_data.h" -#include "def/z_file_choose.h" -#include "def/z_kanfont.h" -#include "def/z_kankyo.h" -#include "def/z_lib.h" -#include "def/z_rcp.h" -#include "def/z_sram.h" -#include "def/z_ss_sram.h" -#include "def/z_std_dma.h" -#include "def/z_view.h" -#include "def/z_vr_box.h" -#include "def/z_vr_box_draw.h" -#include "def/z_play.h" // FORCE - -extern u16 gSramSlotOffsets[]; - -static s16 sUnused = 106; - -static s16 sScreenFillAlpha = 255; - -static Gfx sScreenFillSetupDL[] = { - gsDPPipeSync(), - gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | - G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), - gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_1PRIMITIVE, - G_AC_NONE | G_ZS_PIXEL | G_RM_CLD_SURF | G_RM_CLD_SURF2), - gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), - gsSPEndDisplayList(), -}; - -static s16 sFileInfoBoxPartWidths[] = { 36, 36, 36, 36, 24 }; - -static s16 sWindowContentColors[2][3] = { - { 100, 150, 255 }, // blue - { 100, 100, 100 }, // gray -}; - -void FileChoose_SetView(FileChooseContext* this, f32 eyeX, f32 eyeY, f32 eyeZ) { - Vec3f eye; - Vec3f lookAt; - Vec3f up; - - lookAt.x = lookAt.y = lookAt.z = 0.0f; - up.x = up.z = 0.0f; - - eye.x = eyeX; - eye.y = eyeY; - eye.z = eyeZ; - - up.y = 1.0f; - - func_800AA358(&this->view, &eye, &lookAt, &up); - func_800AAA50(&this->view, 0x7F); -} - -Gfx* FileChoose_QuadTextureIA8(Gfx* gfx, void* texture, s16 width, s16 height, s16 point) { - gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - - gSP1Quadrangle(gfx++, point, point + 2, point + 3, point + 1, 0); - - return gfx; -} - -void FileChoose_InitModeUpdate(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - if (this->menuMode == FS_MENU_MODE_INIT) { - this->menuMode = FS_MENU_MODE_CONFIG; - this->configMode = CM_FADE_IN_START; - this->nextTitleLabel = FS_TITLE_OPEN_FILE; - osSyncPrintf("SRAM Start-Load >>>>> "); - Sram_VerifyAndLoadAllSaves(this, &this->sramCtx); - osSyncPrintf("Done!!!\n"); - } -} - -void FileChoose_InitModeDraw(GameState* thisx) { -} - -/** - * Fade in the menu window and title label. - * If a file is occupied fade in the name, name box, and connector. - * Fade in the copy erase and options button according to the window alpha. - */ -void FileChoose_FadeInMenuElements(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - - this->titleAlpha[0] += VREG(1); - this->windowAlpha += VREG(2); - - for (i = 0; i < 3; i++) { - this->fileButtonAlpha[i] = this->windowAlpha; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->windowAlpha; - this->connectorAlpha[i] += VREG(1); - if (this->connectorAlpha[i] >= 255) { - this->connectorAlpha[i] = 255; - } - } - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->optionButtonAlpha = this->windowAlpha; -} - -/** - * Converts a numerical value to ones-tens-hundreds digits - */ -void FileChoose_SplitNumber(u16 value, s16* hundreds, s16* tens, s16* ones) { - *hundreds = 0; - *tens = 0; - *ones = value; - - while (true) { - if ((*ones - 100) < 0) { - break; - } - (*hundreds)++; - *ones -= 100; - } - - while (true) { - if ((*ones - 10) < 0) { - break; - } - (*tens)++; - *ones -= 10; - } -} - -/** - * Reduce the alpha of the black screen fill to create a fade in effect. - * Additionally, slide the window from the right to the center of the screen. - * Update function for `CM_FADE_IN_START` - */ -void FileChoose_StartFadeIn(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - FileChoose_FadeInMenuElements(&this->state); - sScreenFillAlpha -= 40; - this->windowPosX -= 20; - - if (this->windowPosX <= -94) { - this->windowPosX = -94; - this->configMode = CM_FADE_IN_END; - sScreenFillAlpha = 0; - } -} - -/** - * Finish fading in the remaining menu elements. - * Fade in the controls text at the bottom of the screen. - * Update function for `CM_FADE_IN_END` - */ -void FileChoose_FinishFadeIn(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->controlsAlpha += VREG(1); - FileChoose_FadeInMenuElements(&this->state); - - if (this->titleAlpha[0] >= 255) { - this->titleAlpha[0] = 255; - this->controlsAlpha = 255; - this->windowAlpha = 200; - this->configMode = CM_MAIN_MENU; - } -} - -/** - * Update the cursor and wait for the player to select a button to change menus accordingly. - * If an empty file is selected, enter the name entry config mode. - * If an occupied file is selected, enter the `Select` menu mode. - * If copy, erase, or options is selected, set config mode accordingly. - * Lastly, set any warning labels if appropriate. - * Update function for `CM_MAIN_MENU` - */ -void FileChoose_UpdateMainMenu(GameState* thisx) { - static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - Input* input = &this->state.input[0]; - - if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) { - if (this->buttonIndex <= FS_BTN_MAIN_FILE_3) { - osSyncPrintf("REGCK_ALL[%x]=%x,%x,%x,%x,%x,%x\n", this->buttonIndex, - GET_NEWF(sramCtx, this->buttonIndex, 0), GET_NEWF(sramCtx, this->buttonIndex, 1), - GET_NEWF(sramCtx, this->buttonIndex, 2), GET_NEWF(sramCtx, this->buttonIndex, 3), - GET_NEWF(sramCtx, this->buttonIndex, 4), GET_NEWF(sramCtx, this->buttonIndex, 5)); - - if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->configMode = CM_ROTATE_TO_NAME_ENTRY; - this->kbdButton = FS_KBD_BTN_NONE; - this->charPage = FS_CHAR_PAGE_ENG; - this->kbdX = 0; - this->kbdY = 0; - this->charIndex = 0; - this->charBgAlpha = 0; - this->newFileNameCharCount = 0; - this->nameEntryBoxPosX = 120; - this->nameEntryBoxAlpha = 0; - MemCopy(&this->fileNames[this->buttonIndex][0], &emptyName, 8); - } else if (this->n64ddFlags[this->buttonIndex] == this->n64ddFlag) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->actionTimer = 8; - this->selectMode = SM_FADE_MAIN_TO_SELECT; - this->selectedFileIndex = this->buttonIndex; - this->menuMode = FS_MENU_MODE_SELECT; - this->nextTitleLabel = FS_TITLE_OPEN_FILE; - } else if (!this->n64ddFlags[this->buttonIndex]) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } else { - if (this->warningLabel == FS_WARNING_NONE) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->prevConfigMode = this->configMode; - - if (this->buttonIndex == FS_BTN_MAIN_COPY) { - this->configMode = CM_SETUP_COPY_SOURCE; - this->nextTitleLabel = FS_TITLE_COPY_FROM; - } else if (this->buttonIndex == FS_BTN_MAIN_ERASE) { - this->configMode = CM_SETUP_ERASE_SELECT; - this->nextTitleLabel = FS_TITLE_ERASE_FILE; - } else { - this->configMode = CM_MAIN_TO_OPTIONS; - this->kbdButton = 0; - this->kbdX = 0; - this->kbdY = 0; - this->charBgAlpha = 0; - this->newFileNameCharCount = 0; - this->nameEntryBoxPosX = 120; - } - - this->actionTimer = 8; - } else { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } - } else { - if (ABS(this->stickRelY) > 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - - if (this->stickRelY > 30) { - this->buttonIndex--; - if (this->buttonIndex < FS_BTN_MAIN_FILE_1) { - this->buttonIndex = FS_BTN_MAIN_OPTIONS; - } - } else { - this->buttonIndex++; - if (this->buttonIndex > FS_BTN_MAIN_OPTIONS) { - this->buttonIndex = FS_BTN_MAIN_FILE_1; - } - } - } - - if (this->buttonIndex == FS_BTN_MAIN_COPY) { - if (!SLOT_OCCUPIED(sramCtx, 0) && !SLOT_OCCUPIED(sramCtx, 1) && !SLOT_OCCUPIED(sramCtx, 2)) { - this->warningButtonIndex = this->buttonIndex; - this->warningLabel = FS_WARNING_NO_FILE_COPY; - this->emptyFileTextAlpha = 255; - } else if (SLOT_OCCUPIED(sramCtx, 0) && SLOT_OCCUPIED(sramCtx, 1) && SLOT_OCCUPIED(sramCtx, 2)) { - this->warningButtonIndex = this->buttonIndex; - this->warningLabel = FS_WARNING_NO_EMPTY_FILES; - this->emptyFileTextAlpha = 255; - } else { - this->warningLabel = FS_WARNING_NONE; - } - } else if (this->buttonIndex == FS_BTN_MAIN_ERASE) { - if (!SLOT_OCCUPIED(sramCtx, 0) && !SLOT_OCCUPIED(sramCtx, 1) && !SLOT_OCCUPIED(sramCtx, 2)) { - this->warningButtonIndex = this->buttonIndex; - this->warningLabel = FS_WARNING_NO_FILE_ERASE; - this->emptyFileTextAlpha = 255; - } else { - this->warningLabel = FS_WARNING_NONE; - } - } else { - this->warningLabel = FS_WARNING_NONE; - } - } -} - -/** - * Update function for `CM_UNUSED_31` - */ -void FileChoose_UnusedCM31(GameState* thisx) { -} - -/** - * Delay the next config mode from running until `XREG(73)` reaches 254. - * Because the timer increments by 2, the delay is 127 frames (assuming the value was not changed by reg editor). - * Unused in the final game, was possibly used for debugging. - * Update function for `CM_UNUSED_DELAY` - */ -void FileChoose_UnusedCMDelay(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - XREG(73) += 2; - - if (XREG(73) == 254) { - this->configMode = this->nextConfigMode; - XREG(73) = 0; - } -} - -/** - * Rotate the window from the main menu to the name entry menu. - * Update function for `CM_ROTATE_TO_NAME_ENTRY` - */ -void FileChoose_RotateToNameEntry(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->windowRot += VREG(16); - - if (this->windowRot >= 314.0f) { - this->windowRot = 314.0f; - this->configMode = CM_START_NAME_ENTRY; - } -} - -/** - * Rotate the window from the main menu to the options menu. - * Update function for `CM_MAIN_TO_OPTIONS` - */ -void FileChoose_RotateToOptions(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->windowRot += VREG(16); - - if (this->windowRot >= 314.0f) { - this->windowRot = 314.0f; - this->configMode = CM_START_OPTIONS; - } -} - -/** - * Rotate the window from the options menu to the main menu. - * Update function for `CM_NAME_ENTRY_TO_MAIN` and `CM_OPTIONS_TO_MAIN` - */ -void FileChoose_RotateToMain(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->windowRot += VREG(16); - - if (this->windowRot >= 628.0f) { - this->windowRot = 0.0f; - this->configMode = CM_MAIN_MENU; - } -} - -static void (*gConfigModeUpdateFuncs[])(GameState*) = { - FileChoose_StartFadeIn, FileChoose_FinishFadeIn, - FileChoose_UpdateMainMenu, FileChoose_SetupCopySource, - FileChoose_SelectCopySource, FileChoose_SetupCopyDest1, - FileChoose_SetupCopyDest2, FileChoose_SelectCopyDest, - FileChoose_ExitToCopySource1, FileChoose_ExitToCopySource2, - FileChoose_SetupCopyConfirm1, FileChoose_SetupCopyConfirm2, - FileChoose_CopyConfirm, FileChoose_ReturnToCopyDest, - FileChoose_CopyAnim1, FileChoose_CopyAnim2, - FileChoose_CopyAnim3, FileChoose_CopyAnim4, - FileChoose_CopyAnim5, FileChoose_ExitCopyToMain, - FileChoose_SetupEraseSelect, FileChoose_EraseSelect, - FileChoose_SetupEraseConfirm1, FileChoose_SetupEraseConfirm2, - FileChoose_EraseConfirm, FileChoose_ExitToEraseSelect1, - FileChoose_ExitToEraseSelect2, FileChoose_EraseAnim1, - FileChoose_EraseAnim2, FileChoose_EraseAnim3, - FileChoose_ExitEraseToMain, FileChoose_UnusedCM31, - FileChoose_RotateToNameEntry, FileChoose_UpdateKeyboardCursor, - FileChoose_StartNameEntry, FileChoose_RotateToMain, - FileChoose_RotateToOptions, FileChoose_UpdateOptionsMenu, - FileChoose_StartOptions, FileChoose_RotateToMain, - FileChoose_UnusedCMDelay, -}; - -/** - * Updates the alpha of the cursor to make it pulsate. - * On the debug rom, this function also handles switching languages with controller 3. - */ -void FileChoose_PulsateCursor(GameState* thisx) { - static s16 cursorAlphaTargets[] = { 70, 200 }; - FileChooseContext* this = (FileChooseContext*)thisx; - s16 alphaStep; - SramContext* sramCtx = &this->sramCtx; - Input* debugInput = &this->state.input[2]; - - if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) { - sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_ENG; -#ifdef N64_VERSION - *((u8*)0x80000002) = LANGUAGE_ENG; -#endif - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE); - osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], - sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], - sramCtx->readBuff[SRAM_HEADER_MAGIC]); - - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); - osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], - sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], - sramCtx->readBuff[SRAM_HEADER_MAGIC]); - } else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DUP)) { - sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_GER; -#ifdef N64_VERSION - *((u8*)0x80000002) = LANGUAGE_GER; -#endif - - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE); - osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], - sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], - sramCtx->readBuff[SRAM_HEADER_MAGIC]); - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); - osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], - sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], - sramCtx->readBuff[SRAM_HEADER_MAGIC]); - } else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DRIGHT)) { - sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_FRA; -#ifdef N64_VERSION - *((u8*)0x80000002) = LANGUAGE_FRA; -#endif - - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE); - osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], - sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], - sramCtx->readBuff[SRAM_HEADER_MAGIC]); - - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); - osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], - sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], - sramCtx->readBuff[SRAM_HEADER_MAGIC]); - } - - alphaStep = ABS(this->highlightColor[3] - cursorAlphaTargets[this->highlightPulseDir]) / XREG(35); - - if (this->highlightColor[3] >= cursorAlphaTargets[this->highlightPulseDir]) { - this->highlightColor[3] -= alphaStep; - } else { - this->highlightColor[3] += alphaStep; - } - - XREG(35)--; - - if (XREG(35) == 0) { - this->highlightColor[3] = cursorAlphaTargets[this->highlightPulseDir]; - XREG(35) = XREG(36 + this->highlightPulseDir); - this->highlightPulseDir ^= 1; - } -} - -void FileChoose_ConfigModeUpdate(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - gConfigModeUpdateFuncs[this->configMode](&this->state); -} - -void FileChoose_SetWindowVtx(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 i; - s16 j; - s16 x; - s16 tmp; - s16 tmp2; - s16 tmp3; - - this->windowVtx = Graph_Alloc(this->state.gfxCtx, sizeof(Vtx) * 80); - tmp = this->windowPosX - 90; - - for (x = 0, i = 0; i < 4; i++) { - tmp += 0x40; - tmp2 = (i == 3) ? 0x30 : 0x40; - - for (j = 0, tmp3 = 0x50; j < 5; j++, x += 4, tmp3 -= 0x20) { - this->windowVtx[x].v.ob[0] = this->windowVtx[x + 2].v.ob[0] = tmp; - - this->windowVtx[x + 1].v.ob[0] = this->windowVtx[x + 3].v.ob[0] = tmp + tmp2; - - this->windowVtx[x].v.ob[1] = this->windowVtx[x + 1].v.ob[1] = tmp3; - - this->windowVtx[x + 2].v.ob[1] = this->windowVtx[x + 3].v.ob[1] = tmp3 - 0x20; - - this->windowVtx[x].v.ob[2] = this->windowVtx[x + 1].v.ob[2] = this->windowVtx[x + 2].v.ob[2] = - this->windowVtx[x + 3].v.ob[2] = 0; - - this->windowVtx[x].v.flag = this->windowVtx[x + 1].v.flag = this->windowVtx[x + 2].v.flag = - this->windowVtx[x + 3].v.flag = 0; - - this->windowVtx[x].v.tc[0] = this->windowVtx[x].v.tc[1] = this->windowVtx[x + 1].v.tc[1] = - this->windowVtx[x + 2].v.tc[0] = 0; - - this->windowVtx[x + 1].v.tc[0] = this->windowVtx[x + 3].v.tc[0] = tmp2 * 0x20; - - this->windowVtx[x + 2].v.tc[1] = this->windowVtx[x + 3].v.tc[1] = 0x400; - - this->windowVtx[x].v.cn[0] = this->windowVtx[x + 2].v.cn[0] = this->windowVtx[x].v.cn[1] = - this->windowVtx[x + 2].v.cn[1] = this->windowVtx[x].v.cn[2] = this->windowVtx[x + 2].v.cn[2] = - this->windowVtx[x + 1].v.cn[0] = this->windowVtx[x + 3].v.cn[0] = this->windowVtx[x + 1].v.cn[1] = - this->windowVtx[x + 3].v.cn[1] = this->windowVtx[x + 1].v.cn[2] = - this->windowVtx[x + 3].v.cn[2] = this->windowVtx[x].v.cn[3] = - this->windowVtx[x + 2].v.cn[3] = this->windowVtx[x + 1].v.cn[3] = - this->windowVtx[x + 3].v.cn[3] = 255; - } - } -} - -static s16 D_80812818[] = { 0x001A, 0x000A, 0x000A, 0x000A }; -static s16 D_80812820[] = { 0x0020, 0x000C, 0x000C, 0x000C }; -static s16 D_80812828[] = { 0x0010, 0x000C, 0x000C, 0x000C }; -static s16 D_80812830[] = { 0x0040, 0x0054, 0x0068, 0x0274, 0x0278, 0x027C }; -static s16 D_8081283C[] = { 0x0040, 0x0054, 0x0068, 0x0278 }; -static s16 D_80812844[] = { 0x0274, 0x0278 }; -static s16 D_80812848[] = { 0x0274, 0x0278 }; - -void FileChoose_SetWindowContentVtx(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 phi_t2; - s16 phi_t0; - s16 phi_t5; - s16 phi_a1; - s16 phi_ra; - s16 temp_t1; - SramContext* sramCtx = &this->sramCtx; - - this->windowContentVtx = Graph_Alloc(this->state.gfxCtx, 0x288 * sizeof(Vtx)); - - for (phi_t2 = 0; phi_t2 < 0x288; phi_t2 += 4) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = 0x12C; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0x10; - - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = 0; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x10; - - this->windowContentVtx[phi_t2].v.ob[2] = this->windowContentVtx[phi_t2 + 1].v.ob[2] = - this->windowContentVtx[phi_t2 + 2].v.ob[2] = this->windowContentVtx[phi_t2 + 3].v.ob[2] = 0; - - this->windowContentVtx[phi_t2].v.flag = this->windowContentVtx[phi_t2 + 1].v.flag = - this->windowContentVtx[phi_t2 + 2].v.flag = this->windowContentVtx[phi_t2 + 3].v.flag = 0; - - this->windowContentVtx[phi_t2].v.tc[0] = this->windowContentVtx[phi_t2].v.tc[1] = - this->windowContentVtx[phi_t2 + 1].v.tc[1] = this->windowContentVtx[phi_t2 + 2].v.tc[0] = 0; - - this->windowContentVtx[phi_t2 + 1].v.tc[0] = this->windowContentVtx[phi_t2 + 2].v.tc[1] = - this->windowContentVtx[phi_t2 + 3].v.tc[0] = this->windowContentVtx[phi_t2 + 3].v.tc[1] = 0x200; - - this->windowContentVtx[phi_t2].v.cn[0] = this->windowContentVtx[phi_t2 + 1].v.cn[0] = - this->windowContentVtx[phi_t2 + 2].v.cn[0] = this->windowContentVtx[phi_t2 + 3].v.cn[0] = - this->windowContentVtx[phi_t2].v.cn[1] = this->windowContentVtx[phi_t2 + 1].v.cn[1] = - this->windowContentVtx[phi_t2 + 2].v.cn[1] = this->windowContentVtx[phi_t2 + 3].v.cn[1] = - this->windowContentVtx[phi_t2].v.cn[2] = this->windowContentVtx[phi_t2 + 1].v.cn[2] = - this->windowContentVtx[phi_t2 + 2].v.cn[2] = this->windowContentVtx[phi_t2 + 3].v.cn[2] = - this->windowContentVtx[phi_t2].v.cn[3] = this->windowContentVtx[phi_t2 + 1].v.cn[3] = - this->windowContentVtx[phi_t2 + 2].v.cn[3] = - this->windowContentVtx[phi_t2 + 3].v.cn[3] = 0xFF; - } - - this->windowContentVtx[0].v.ob[0] = this->windowContentVtx[2].v.ob[0] = this->windowPosX; - this->windowContentVtx[1].v.ob[0] = this->windowContentVtx[3].v.ob[0] = this->windowContentVtx[0].v.ob[0] + 0x80; - this->windowContentVtx[0].v.ob[1] = this->windowContentVtx[1].v.ob[1] = 0x48; - this->windowContentVtx[2].v.ob[1] = this->windowContentVtx[3].v.ob[1] = this->windowContentVtx[0].v.ob[1] - 0x10; - this->windowContentVtx[1].v.tc[0] = this->windowContentVtx[3].v.tc[0] = 0x1000; - - for (phi_a1 = 0, phi_t2 = 4; phi_a1 < 3; phi_a1++) { - phi_t0 = this->windowPosX - 6; - - for (phi_t5 = 0; phi_t5 < 5; phi_t5++, phi_t2 += 4) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + sFileInfoBoxPartWidths[phi_t5]; - - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = - this->fileNamesY[phi_a1] + 0x2C; - - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x38; - - this->windowContentVtx[phi_t2 + 1].v.tc[0] = this->windowContentVtx[phi_t2 + 3].v.tc[0] = - sFileInfoBoxPartWidths[phi_t5] << 5; - this->windowContentVtx[phi_t2 + 2].v.tc[1] = this->windowContentVtx[phi_t2 + 3].v.tc[1] = 0x700; - phi_t0 += sFileInfoBoxPartWidths[phi_t5]; - } - } - - phi_t0 = this->windowPosX - 6; - phi_ra = 0x2C; - - for (phi_t5 = 0; phi_t5 < 3; phi_t5++, phi_t2 += 20, phi_ra -= 0x10) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0x40; - - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = - this->buttonYOffsets[phi_t5] + phi_ra; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x10; - - this->windowContentVtx[phi_t2 + 1].v.tc[0] = this->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x800; - - this->windowContentVtx[phi_t2 + 4].v.ob[0] = this->windowContentVtx[phi_t2 + 6].v.ob[0] = phi_t0 + 0x40; - - this->windowContentVtx[phi_t2 + 5].v.ob[0] = this->windowContentVtx[phi_t2 + 7].v.ob[0] = - this->windowContentVtx[phi_t2 + 4].v.ob[0] + 0x6C; - - this->windowContentVtx[phi_t2 + 4].v.ob[1] = this->windowContentVtx[phi_t2 + 5].v.ob[1] = - this->buttonYOffsets[phi_t5] + phi_ra; - - this->windowContentVtx[phi_t2 + 6].v.ob[1] = this->windowContentVtx[phi_t2 + 7].v.ob[1] = - this->windowContentVtx[phi_t2 + 4].v.ob[1] - 0x10; - - this->windowContentVtx[phi_t2 + 5].v.tc[0] = this->windowContentVtx[phi_t2 + 7].v.tc[0] = 0xD80; - - if ((this->configMode == CM_COPY_ANIM_2) && (phi_t5 == this->copyDestFileIndex)) { - temp_t1 = this->fileNamesY[phi_t5] + 0x2C; - } else if (((this->configMode == CM_COPY_ANIM_3) || (this->configMode == CM_COPY_ANIM_4)) && - (phi_t5 == this->copyDestFileIndex)) { - temp_t1 = this->buttonYOffsets[phi_t5] + phi_ra; - } else { - temp_t1 = phi_ra + this->buttonYOffsets[phi_t5] + this->fileNamesY[phi_t5]; - } - - this->windowContentVtx[phi_t2 + 8].v.ob[0] = this->windowContentVtx[phi_t2 + 10].v.ob[0] = phi_t0 + 0xA8; - - this->windowContentVtx[phi_t2 + 9].v.ob[0] = this->windowContentVtx[phi_t2 + 11].v.ob[0] = - this->windowContentVtx[phi_t2 + 8].v.ob[0] + 0x2C; - - this->windowContentVtx[phi_t2 + 8].v.ob[1] = this->windowContentVtx[phi_t2 + 9].v.ob[1] = temp_t1; - this->windowContentVtx[phi_t2 + 10].v.ob[1] = this->windowContentVtx[phi_t2 + 11].v.ob[1] = - this->windowContentVtx[phi_t2 + 8].v.ob[1] - 0x10; - - this->windowContentVtx[phi_t2 + 9].v.tc[0] = this->windowContentVtx[phi_t2 + 11].v.tc[0] = 0x580; - this->windowContentVtx[phi_t2 + 12].v.ob[0] = this->windowContentVtx[phi_t2 + 14].v.ob[0] = phi_t0 + 0x34; - this->windowContentVtx[phi_t2 + 13].v.ob[0] = this->windowContentVtx[phi_t2 + 15].v.ob[0] = - this->windowContentVtx[phi_t2 + 12].v.ob[0] + 0x18; - - this->windowContentVtx[phi_t2 + 12].v.ob[1] = this->windowContentVtx[phi_t2 + 13].v.ob[1] = - this->buttonYOffsets[phi_t5] + phi_ra; - - this->windowContentVtx[phi_t2 + 14].v.ob[1] = this->windowContentVtx[phi_t2 + 15].v.ob[1] = - this->windowContentVtx[phi_t2 + 12].v.ob[1] - 0x10; - - this->windowContentVtx[phi_t2 + 13].v.tc[0] = this->windowContentVtx[phi_t2 + 15].v.tc[0] = 0x300; - this->windowContentVtx[phi_t2 + 16].v.ob[0] = this->windowContentVtx[phi_t2 + 18].v.ob[0] = phi_t0 + 0x9C; - this->windowContentVtx[phi_t2 + 17].v.ob[0] = this->windowContentVtx[phi_t2 + 19].v.ob[0] = - this->windowContentVtx[phi_t2 + 16].v.ob[0] + 0x18; - - this->windowContentVtx[phi_t2 + 16].v.ob[1] = this->windowContentVtx[phi_t2 + 17].v.ob[1] = - this->buttonYOffsets[phi_t5] + phi_ra; - - this->windowContentVtx[phi_t2 + 18].v.ob[1] = this->windowContentVtx[phi_t2 + 19].v.ob[1] = - this->windowContentVtx[phi_t2 + 16].v.ob[1] - 0x10; - - this->windowContentVtx[phi_t2 + 17].v.tc[0] = this->windowContentVtx[phi_t2 + 19].v.tc[0] = 0x300; - } - - phi_ra = 0x2C; - - for (phi_t5 = 0; phi_t5 < 3; phi_t5++, phi_ra -= WREG(38)) { - if (SLOT_OCCUPIED(sramCtx, phi_t5)) { - phi_t0 = this->windowPosX - WREG(39); - - if ((this->configMode == 0xF) && (phi_t5 == this->copyDestFileIndex)) { - temp_t1 = this->fileNamesY[phi_t5] + 0x2C; - } else if (((this->configMode == CM_COPY_ANIM_3) || (this->configMode == CM_COPY_ANIM_4)) && - (phi_t5 == this->copyDestFileIndex)) { - temp_t1 = this->buttonYOffsets[phi_t5] + phi_ra; - } else { - temp_t1 = phi_ra + this->buttonYOffsets[phi_t5] + this->fileNamesY[phi_t5]; - } - - temp_t1 += 2; - - for (phi_a1 = 0; phi_a1 < 8; phi_a1++, phi_t2 += 4, phi_t0 += WREG(40)) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = - WREG(41) + phi_t0 + 0x40; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + WREG(42); - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1 - 3; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - WREG(43); - } - - phi_t0 = this->windowPosX - 14; - temp_t1 -= 0x16; - - for (phi_a1 = 0; phi_a1 < 4; phi_a1++, phi_t2 += 4) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + D_80812820[phi_a1]; - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - D_80812828[phi_a1]; - phi_t0 += D_80812818[phi_a1]; - } - - this->windowContentVtx[phi_t2 - 15].v.tc[0] = this->windowContentVtx[phi_t2 - 13].v.tc[0] = 0x400; - - phi_t0 = this->windowPosX + 63; - temp_t1 += 4; - - for (phi_a1 = 0; phi_a1 < 20; phi_a1++, phi_t2 += 4, phi_t0 += 9) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0xA; - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0xA; - - if (phi_a1 == 9) { - phi_t0 = this->windowPosX + 54; - temp_t1 -= 8; - } - } - - phi_t0 = this->windowPosX + 4; - temp_t1 -= 0xA; - - for (phi_a1 = 0; phi_a1 < 10; phi_a1++, phi_t2 += 4, phi_t0 += 0x10) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0x10; - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x10; - } - } else { - phi_t2 += 0xA8; - } - } - - phi_t0 = this->windowPosX - 6; - phi_ra = -0xC; - - for (phi_t5 = 0; phi_t5 < 2; phi_t5++, phi_t2 += 4, phi_ra -= 0x10) { - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0x40; - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = - this->buttonYOffsets[phi_t5 + 3] + phi_ra; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x10; - this->windowContentVtx[phi_t2 + 1].v.tc[0] = this->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x800; - } - - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0x40; - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = - this->buttonYOffsets[5] - 0x34; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x10; - this->windowContentVtx[phi_t2 + 1].v.tc[0] = this->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x800; - - phi_t2 += 4; - - if (((this->menuMode == FS_MENU_MODE_CONFIG) && (this->configMode >= CM_MAIN_MENU)) || - ((this->menuMode == FS_MENU_MODE_SELECT) && (this->selectMode == SM_CONFIRM_FILE))) { - if (this->menuMode == FS_MENU_MODE_CONFIG) { - if ((this->configMode == CM_SELECT_COPY_SOURCE) || (this->configMode == CM_SELECT_COPY_DEST) || - (this->configMode == CM_ERASE_SELECT)) { - phi_t5 = D_8081283C[this->buttonIndex]; - } else if ((this->configMode == CM_ERASE_CONFIRM) || (this->configMode == CM_COPY_CONFIRM)) { - phi_t5 = D_80812844[this->buttonIndex]; - } else { - phi_t5 = D_80812830[this->buttonIndex]; - } - } else { - phi_t5 = D_80812848[this->confirmButtonIndex]; - } - - this->windowContentVtx[phi_t2].v.ob[0] = this->windowContentVtx[phi_t2 + 2].v.ob[0] = this->windowPosX - 0xA; - this->windowContentVtx[phi_t2 + 1].v.ob[0] = this->windowContentVtx[phi_t2 + 3].v.ob[0] = - this->windowContentVtx[phi_t2].v.ob[0] + 0x48; - this->windowContentVtx[phi_t2].v.ob[1] = this->windowContentVtx[phi_t2 + 1].v.ob[1] = - this->windowContentVtx[phi_t5].v.ob[1] + 4; - this->windowContentVtx[phi_t2 + 2].v.ob[1] = this->windowContentVtx[phi_t2 + 3].v.ob[1] = - this->windowContentVtx[phi_t2].v.ob[1] - 0x18; - this->windowContentVtx[phi_t2 + 1].v.tc[0] = this->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x900; - this->windowContentVtx[phi_t2 + 2].v.tc[1] = this->windowContentVtx[phi_t2 + 3].v.tc[1] = 0x300; - } - - this->windowContentVtx[phi_t2 + 4].v.ob[0] = this->windowContentVtx[phi_t2 + 6].v.ob[0] = this->windowPosX + 0x3A; - this->windowContentVtx[phi_t2 + 5].v.ob[0] = this->windowContentVtx[phi_t2 + 7].v.ob[0] = - this->windowContentVtx[phi_t2 + 4].v.ob[0] + 0x80; - this->windowContentVtx[phi_t2 + 4].v.ob[1] = this->windowContentVtx[phi_t2 + 5].v.ob[1] = - this->windowContentVtx[D_80812830[this->warningButtonIndex]].v.ob[1]; - this->windowContentVtx[phi_t2 + 6].v.ob[1] = this->windowContentVtx[phi_t2 + 7].v.ob[1] = - this->windowContentVtx[phi_t2 + 4].v.ob[1] - 0x10; - this->windowContentVtx[phi_t2 + 5].v.tc[0] = this->windowContentVtx[phi_t2 + 7].v.tc[0] = 0x1000; -} - -static u16 D_8081284C[] = { 0x007C, 0x0124, 0x01CC }; - -static void* sQuestItemTextures[] = { - gFileSelKokiriEmeraldTex, gFileSelGoronRubyTex, gFileSelZoraSapphireTex, - gFileSelForestMedallionTex, gFileSelFireMedallionTex, gFileSelWaterMedallionTex, - gFileSelSpiritMedallionTex, gFileSelShadowMedallionTex, gFileSelLightMedallionTex, -}; - -static s16 sQuestItemRed[] = { 255, 255, 255, 0, 255, 0, 255, 200, 200 }; -static s16 sQuestItemGreen[] = { 255, 255, 255, 255, 60, 100, 130, 50, 200 }; -static s16 sQuestItemBlue[] = { 255, 255, 255, 0, 0, 255, 0, 255, 0 }; -static s16 sQuestItemFlags[] = { 0x0012, 0x0013, 0x0014, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005 }; -static s16 sNamePrimColors[2][3] = { { 255, 255, 255 }, { 100, 100, 100 } }; -static void* sHeartTextures[] = { gHeartFullTex, gDefenseHeartFullTex }; -static s16 sHeartPrimColors[2][3] = { { 255, 70, 50 }, { 200, 0, 0 } }; -static s16 sHeartEnvColors[2][3] = { { 50, 40, 60 }, { 255, 255, 255 } }; - -void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { - FileChooseContext* this = (FileChooseContext*)thisx; - Font* sp54 = &this->font; - s32 heartType; - s16 i; - s16 vtxOffset; - s16 j; - s16 deathCountSplit[3]; - - if (1) {} - - OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1709); - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, - PRIMITIVE, 0); - - // draw file name - if (this->nameAlpha[fileIndex] != 0) { - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex]], 32, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sNamePrimColors[isActive][0], sNamePrimColors[isActive][1], - sNamePrimColors[isActive][2], this->nameAlpha[fileIndex]); - - for (i = 0, vtxOffset = 0; vtxOffset < 0x20; i++, vtxOffset += 4) { - FileChoose_DrawCharacter(this->state.gfxCtx, - sp54->fontBuf + this->fileNames[fileIndex][i] * FONT_CHAR_TEX_SIZE, vtxOffset); - } - } - - if ((fileIndex == this->selectedFileIndex) || (fileIndex == this->copyDestFileIndex)) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, - PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 255, 255, 255, this->fileInfoAlpha[fileIndex]); - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex]] + 0x24, 12, 0); - - FileChoose_SplitNumber(this->deaths[fileIndex], &deathCountSplit[0], &deathCountSplit[1], &deathCountSplit[2]); - - // draw death count - for (i = 0, vtxOffset = 0; i < 3; i++, vtxOffset += 4) { - FileChoose_DrawCharacter(this->state.gfxCtx, sp54->fontBuf + deathCountSplit[i] * FONT_CHAR_TEX_SIZE, - vtxOffset); - } - - gDPPipeSync(POLY_OPA_DISP++); - - heartType = (this->defense[fileIndex] == 0) ? 0 : 1; - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sHeartPrimColors[heartType][0], sHeartPrimColors[heartType][1], - sHeartPrimColors[heartType][2], this->fileInfoAlpha[fileIndex]); - gDPSetEnvColor(POLY_OPA_DISP++, sHeartEnvColors[heartType][0], sHeartEnvColors[heartType][1], - sHeartEnvColors[heartType][2], 255); - - i = this->healthCapacities[fileIndex] / 0x10; - - // draw hearts - for (vtxOffset = 0, j = 0; j < i; j++, vtxOffset += 4) { - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x30, 4, 0); - - POLY_OPA_DISP = FileChoose_QuadTextureIA8(POLY_OPA_DISP, sHeartTextures[heartType], 0x10, 0x10, 0); - } - - gDPPipeSync(POLY_OPA_DISP++); - - // draw quest items - for (vtxOffset = 0, j = 0; j < 9; j++, vtxOffset += 4) { - if (this->questItems[fileIndex] & gBitFlags[sQuestItemFlags[j]]) { - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x80, 4, 0); - gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sQuestItemRed[j], sQuestItemGreen[j], sQuestItemBlue[j], - this->fileInfoAlpha[fileIndex]); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - if (j < 3) { - gDPLoadTextureBlock(POLY_OPA_DISP++, sQuestItemTextures[j], G_IM_FMT_RGBA, G_IM_SIZ_32b, 16, 16, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); - - } else { - POLY_OPA_DISP = FileChoose_QuadTextureIA8(POLY_OPA_DISP, sQuestItemTextures[j], 0x10, 0x10, 0); - } - } - } - } - - CLOSE_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1797); -} - -static void* sFileInfoBoxTextures[] = { - gFileSelFileInfoBox1Tex, gFileSelFileInfoBox2Tex, gFileSelFileInfoBox3Tex, - gFileSelFileInfoBox4Tex, gFileSelFileInfoBox5Tex, -}; - -static void* sTitleLabels[3][9] = { - { gFileSelPleaseSelectAFileENGTex, gFileSelOpenThisFileENGTex, gFileSelCopyWhichFileENGTex, - gFileSelCopyToWhichFileENGTex, gFileSelAreYouSureENGTex, gFileSelFileCopiedENGTex, gFileSelEraseWhichFileENGTex, - gFileSelAreYouSure2ENGTex, gFileSelFileErasedENGTex }, - { gFileSelPleaseSelectAFileGERTex, gFileSelOpenThisFileGERTex, gFileSelWhichFile1GERTex, - gFileSelCopyToWhichFileGERTex, gFileSelAreYouSureGERTex, gFileSelFileCopiedGERTex, gFileSelWhichFile2GERTex, - gFileSelAreYouSure2GERTex, gFileSelFileErasedGERTex }, - { gFileSelPleaseSelectAFileFRATex, gFileSelOpenThisFileFRATex, gFileSelCopyWhichFileFRATex, - gFileSelCopyToWhichFileFRATex, gFileSelAreYouSureFRATex, gFileSelFileCopiedFRATex, gFileSelEraseWhichFileFRATex, - gFileSelAreYouSure2FRATex, gFileSelFileErasedFRATex } -}; - -static void* sWarningLabels[3][5] = { - { gFileSelNoFileToCopyENGTex, gFileSelNoFileToEraseENGTex, gFileSelNoEmptyFileENGTex, gFileSelFileEmptyENGTex, - gFileSelFileInUseENGTex }, - { gFileSelNoFileToCopyGERTex, gFileSelNoFileToEraseGERTex, gFileSelNoEmptyFileGERTex, gFileSelFileEmptyGERTex, - gFileSelFileInUseGERTex }, - { gFileSelNoFileToCopyFRATex, gFileSelNoFileToEraseFRATex, gFileSelNoEmptyFileFRATex, gFileSelFileEmptyFRATex, - gFileSelFileInUseFRATex }, -}; - -static void* sFileButtonTextures[3][3] = { - { gFileSelFile1ButtonENGTex, gFileSelFile2ButtonENGTex, gFileSelFile3ButtonENGTex }, - { gFileSelFile1ButtonGERTex, gFileSelFile2ButtonGERTex, gFileSelFile3ButtonGERTex }, - { gFileSelFile1ButtonFRATex, gFileSelFile2ButtonFRATex, gFileSelFile3ButtonFRATex }, -}; - -static void* sActionButtonTextures[3][4] = { - { gFileSelCopyButtonENGTex, gFileSelEraseButtonENGTex, gFileSelYesButtonENGTex, gFileSelQuitButtonENGTex }, - { gFileSelCopyButtonGERTex, gFileSelEraseButtonGERTex, gFileSelYesButtonGERTex, gFileSelQuitButtonGERTex }, - { gFileSelCopyButtonFRATex, gFileSelEraseButtonFRATex, gFileSelYesButtonFRATex, gFileSelQuitButtonFRATex }, -}; - -static void* sOptionsButtonTextures[] = { - gFileSelOptionsButtonENGTex, - gFileSelOptionsButtonGERTex, - gFileSelOptionsButtonENGTex, -}; - -/** - * Draw most window contents including buttons, labels, and icons. - * Does not include anything from the keyboard and settings windows. - */ -void FileChoose_DrawWindowContents(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 fileIndex; - s16 temp; - s16 i; - s16 quadVtxIndex; - s16 isActive; - s16 pad; - - OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1940); - - // draw title label - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, - ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[0]); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - gSPVertex(POLY_OPA_DISP++, this->windowContentVtx, 4, 0); - gDPLoadTextureBlock(POLY_OPA_DISP++, sTitleLabels[gSaveContext.language][this->titleLabel], G_IM_FMT_IA, - G_IM_SIZ_8b, 128, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); - - // draw next title label - gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[1]); - gDPLoadTextureBlock(POLY_OPA_DISP++, sTitleLabels[gSaveContext.language][this->nextTitleLabel], G_IM_FMT_IA, - G_IM_SIZ_8b, 128, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); - - temp = 4; - - gDPPipeSync(POLY_OPA_DISP++); - - // draw file info box (large box when a file is selected) - for (fileIndex = 0; fileIndex < 3; fileIndex++, temp += 20) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->fileInfoAlpha[fileIndex]); - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[temp], 20, 0); - - for (quadVtxIndex = 0, i = 0; i < 5; i++, quadVtxIndex += 4) { - gDPLoadTextureBlock(POLY_OPA_DISP++, sFileInfoBoxTextures[i], G_IM_FMT_IA, G_IM_SIZ_16b, - sFileInfoBoxPartWidths[i], 56, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, quadVtxIndex, quadVtxIndex + 2, quadVtxIndex + 3, quadVtxIndex + 1, 0); - } - } - - for (i = 0; i < 3; i++, temp += 20) { - // draw file button - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[temp], 20, 0); - - isActive = ((this->n64ddFlag == this->n64ddFlags[i]) || (this->nameBoxAlpha[i] == 0)) ? 0 : 1; - - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], - sWindowContentColors[isActive][2], this->fileButtonAlpha[i]); - gDPLoadTextureBlock(POLY_OPA_DISP++, sFileButtonTextures[gSaveContext.language][i], G_IM_FMT_IA, G_IM_SIZ_16b, - 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, - G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); - - // draw file name box - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], - sWindowContentColors[isActive][2], this->nameBoxAlpha[i]); - gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelNameBoxTex, G_IM_FMT_IA, G_IM_SIZ_16b, 108, 16, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 4, 6, 7, 5, 0); - - // draw disk label for 64DD - if (this->n64ddFlags[i]) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], - sWindowContentColors[isActive][2], this->nameAlpha[i]); - gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelDISKButtonTex, G_IM_FMT_IA, G_IM_SIZ_16b, 44, 16, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, - G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 8, 10, 11, 9, 0); - } - - // draw connectors - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], - sWindowContentColors[isActive][2], this->connectorAlpha[i]); - gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelConnectorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 24, 16, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 12, 14, 15, 13, 0); - - if (this->n64ddFlags[i]) { - gSP1Quadrangle(POLY_OPA_DISP++, 16, 18, 19, 17, 0); - } - } - - // draw file info - for (fileIndex = 0; fileIndex < 3; fileIndex++) { - isActive = ((this->n64ddFlag == this->n64ddFlags[fileIndex]) || (this->nameBoxAlpha[fileIndex] == 0)) ? 0 : 1; - FileChoose_DrawFileInfo(&this->state, fileIndex, isActive); - } - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, - ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[0x274], 20, 0); - - // draw primary action buttons (copy/erase) - for (quadVtxIndex = 0, i = 0; i < 2; i++, quadVtxIndex += 4) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->actionButtonAlpha[i]); - gDPLoadTextureBlock(POLY_OPA_DISP++, sActionButtonTextures[gSaveContext.language][i], G_IM_FMT_IA, G_IM_SIZ_16b, - 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, - G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, quadVtxIndex, quadVtxIndex + 2, quadVtxIndex + 3, quadVtxIndex + 1, 0); - } - - gDPPipeSync(POLY_OPA_DISP++); - - // draw confirm buttons (yes/quit) - for (quadVtxIndex = 0, i = 0; i < 2; i++, quadVtxIndex += 4) { - temp = this->confirmButtonTexIndices[i]; - - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->confirmButtonAlpha[i]); - gDPLoadTextureBlock(POLY_OPA_DISP++, sActionButtonTextures[gSaveContext.language][temp], G_IM_FMT_IA, - G_IM_SIZ_16b, 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, quadVtxIndex, quadVtxIndex + 2, quadVtxIndex + 3, quadVtxIndex + 1, 0); - } - - // draw options button - gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->optionButtonAlpha); - gDPLoadTextureBlock(POLY_OPA_DISP++, sOptionsButtonTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_16b, 64, - 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, - G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 8, 10, 11, 9, 0); - - // draw highlight over currently selected button - if (((this->menuMode == FS_MENU_MODE_CONFIG) && - ((this->configMode == CM_MAIN_MENU) || (this->configMode == CM_SELECT_COPY_SOURCE) || - (this->configMode == CM_SELECT_COPY_DEST) || (this->configMode == CM_COPY_CONFIRM) || - (this->configMode == CM_ERASE_SELECT) || (this->configMode == CM_ERASE_CONFIRM))) || - ((this->menuMode == FS_MENU_MODE_SELECT) && (this->selectMode == SM_CONFIRM_FILE))) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, - PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->highlightColor[0], this->highlightColor[1], - this->highlightColor[2], this->highlightColor[3]); - gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelBigButtonHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 72, 24, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 12, 14, 15, 13, 0); - } - - // draw warning labels - if (this->warningLabel > FS_WARNING_NONE) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->emptyFileTextAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - gDPLoadTextureBlock(POLY_OPA_DISP++, sWarningLabels[gSaveContext.language][this->warningLabel], G_IM_FMT_IA, - G_IM_SIZ_8b, 128, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, 16, 18, 19, 17, 0); - } - - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); - - CLOSE_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2198); -} - -void FileChoose_ConfigModeDraw(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - f32 eyeX; - f32 eyeY; - f32 eyeZ; - - OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2218); - gDPPipeSync(POLY_OPA_DISP++); - - eyeX = 1000.0f * Math_CosS(ZREG(11)) - 1000.0f * Math_SinS(ZREG(11)); - eyeY = ZREG(13); - eyeZ = 1000.0f * Math_SinS(ZREG(11)) + 1000.0f * Math_CosS(ZREG(11)); - - FileChoose_SetView(this, eyeX, eyeY, eyeZ); - SkyboxDraw_Draw(&this->skyboxCtx, this->state.gfxCtx, 1, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ); - gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); - ZREG(11) += ZREG(10); - Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx); - gDPPipeSync(POLY_OPA_DISP++); - func_800949A8(this->state.gfxCtx); - FileChoose_SetView(this, 0.0f, 0.0f, 64.0f); - FileChoose_SetWindowVtx(&this->state); - FileChoose_SetWindowContentVtx(&this->state); - - if ((this->configMode != CM_NAME_ENTRY) && (this->configMode != CM_START_NAME_ENTRY)) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->windowAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); - Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); - - if (this->windowRot != 0) { - Matrix_RotateX(this->windowRot / 100.0f, MTXMODE_APPLY); - } - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_choose.c", 2282), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[0], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[32], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[64], 16, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); - - gDPPipeSync(POLY_OPA_DISP++); - - FileChoose_DrawWindowContents(&this->state); - } - - // draw name entry menu - if ((this->configMode >= CM_ROTATE_TO_NAME_ENTRY) && (this->configMode <= CM_NAME_ENTRY_TO_MAIN)) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->windowAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); - Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); - Matrix_RotateX((this->windowRot - 314.0f) / 100.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_choose.c", 2316), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[0], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[32], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[64], 16, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); - - gDPPipeSync(POLY_OPA_DISP++); - - FileChoose_DrawNameEntry(&this->state); - } - - // draw options menu - if ((this->configMode >= CM_MAIN_TO_OPTIONS) && (this->configMode <= CM_OPTIONS_TO_MAIN)) { - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->windowAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); - Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); - Matrix_RotateX((this->windowRot - 314.0f) / 100.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_choose.c", 2337), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[0], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[32], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[64], 16, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); - - gDPPipeSync(POLY_OPA_DISP++); - - FileChoose_DrawOptions(&this->state); - } - - gDPPipeSync(POLY_OPA_DISP++); - FileChoose_SetView(this, 0.0f, 0.0f, 64.0f); - - CLOSE_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2352); -} - -/** - * Fade out the main menu elements to transition to select mode. - * Update function for `SM_FADE_MAIN_TO_SELECT` - */ -void FileChoose_FadeMainToSelect(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - - for (i = 0; i < 3; i++) { - if (i != this->buttonIndex) { - this->fileButtonAlpha[i] -= 25; - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->optionButtonAlpha = this->fileButtonAlpha[i]; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameAlpha[i] = this->nameBoxAlpha[i] = this->fileButtonAlpha[i]; - this->connectorAlpha[i] -= 31; - } - } - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->actionTimer = 8; - this->selectMode++; - this->confirmButtonIndex = FS_BTN_CONFIRM_YES; - } -} - -/** - * Moves the selected file to the top of the window. - * Update function for `SM_MOVE_FILE_TO_TOP` - */ -void FileChoose_MoveSelectedFileToTop(GameState* thisx) { - static s16 fileYOffsets[] = { 0, 16, 32 }; // amount to move by to reach the top of the screen - FileChooseContext* this = (FileChooseContext*)thisx; - s16 yStep; - - yStep = ABS(this->buttonYOffsets[this->buttonIndex] - fileYOffsets[this->buttonIndex]) / this->actionTimer; - this->buttonYOffsets[this->buttonIndex] += yStep; - this->actionTimer--; - - if ((this->actionTimer == 0) || (this->buttonYOffsets[this->buttonIndex] == fileYOffsets[this->buttonIndex])) { - this->buttonYOffsets[FS_BTN_SELECT_YES] = this->buttonYOffsets[FS_BTN_SELECT_QUIT] = -24; - this->actionTimer = 8; - this->selectMode++; - } -} - -/** - * Fade in the file info for the selected file. - * Update function for `SM_FADE_IN_FILE_INFO` - */ -void FileChoose_FadeInFileInfo(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->fileInfoAlpha[this->buttonIndex] += 25; - this->nameBoxAlpha[this->buttonIndex] -= 50; - - if (this->nameBoxAlpha[this->buttonIndex] <= 0) { - this->nameBoxAlpha[this->buttonIndex] = 0; - } - - this->actionTimer--; - - if (this->actionTimer == 0) { - this->fileInfoAlpha[this->buttonIndex] = 200; - this->actionTimer = 8; - this->selectMode++; - } - - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] = this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = - this->fileInfoAlpha[this->buttonIndex]; -} - -/** - * Update the cursor and handle the option that the player picks for confirming the selected file. - * Update function for `SM_CONFIRM_FILE` - */ -void FileChoose_ConfirmFile(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Input* input = &this->state.input[0]; - - if (CHECK_BTN_ALL(input->press.button, BTN_START) || (CHECK_BTN_ALL(input->press.button, BTN_A))) { - if (this->confirmButtonIndex == FS_BTN_CONFIRM_YES) { - func_800AA000(300.0f, 180, 20, 100); - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->selectMode = SM_FADE_OUT; - func_800F6964(0xF); - } else { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->selectMode++; - } - } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->selectMode++; - } else if (ABS(this->stickRelY) >= 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->confirmButtonIndex ^= 1; - } -} - -/** - * Fade out the file info for the selected file before returning to the main menu. - * Update function for `SM_FADE_OUT_FILE_INFO` - */ -void FileChoose_FadeOutFileInfo(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->fileInfoAlpha[this->buttonIndex] -= 25; - this->nameBoxAlpha[this->buttonIndex] += 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->buttonYOffsets[FS_BTN_SELECT_YES] = this->buttonYOffsets[FS_BTN_SELECT_QUIT] = 0; - this->nameBoxAlpha[this->buttonIndex] = 200; - this->fileInfoAlpha[this->buttonIndex] = 0; - this->nextTitleLabel = FS_TITLE_SELECT_FILE; - this->actionTimer = 8; - this->selectMode++; - } - - this->confirmButtonAlpha[0] = this->confirmButtonAlpha[1] = this->fileInfoAlpha[this->buttonIndex]; -} - -/** - * Move the selected file back to the slot position then go to config mode for the main menu. - * Update function for `SM_MOVE_FILE_TO_SLOT` - */ -void FileChoose_MoveSelectedFileToSlot(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 yStep; - s16 i; - - yStep = ABS(this->buttonYOffsets[this->buttonIndex]) / this->actionTimer; - this->buttonYOffsets[this->buttonIndex] -= yStep; - - if (this->buttonYOffsets[this->buttonIndex] <= 0) { - this->buttonYOffsets[this->buttonIndex] = 0; - } - - for (i = 0; i < 3; i++) { - if (i != this->buttonIndex) { - this->fileButtonAlpha[i] += 25; - - if (this->fileButtonAlpha[i] >= 200) { - this->fileButtonAlpha[i] = 200; - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->optionButtonAlpha = this->fileButtonAlpha[i]; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - this->connectorAlpha[i] += 31; - } - } - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->titleLabel = this->nextTitleLabel; - this->actionTimer = 8; - this->menuMode = FS_MENU_MODE_CONFIG; - this->configMode = CM_MAIN_MENU; - this->nextConfigMode = CM_MAIN_MENU; - this->selectMode = SM_FADE_MAIN_TO_SELECT; - } -} - -/** - * Fill the screen with black to fade out. - * Update function for `SM_FADE_OUT` - */ -void FileChoose_FadeOut(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - sScreenFillAlpha += VREG(10); - - if (sScreenFillAlpha >= 255) { - sScreenFillAlpha = 255; - this->selectMode++; - } -} - -/** - * Load the save for the appropriate file and start the game. - * Note: On Debug ROM, File 1 will go to Map Select. - * Update function for `SM_LOAD_GAME` - */ -void FileChoose_LoadGame(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - u16 swordEquipMask; - s32 pad; - - if (this->buttonIndex == FS_BTN_SELECT_FILE_1) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - gSaveContext.fileNum = this->buttonIndex; - Sram_OpenSave(&this->sramCtx); - gSaveContext.gameMode = 0; - SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext); - this->state.running = false; - } else { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - gSaveContext.fileNum = this->buttonIndex; - Sram_OpenSave(&this->sramCtx); - gSaveContext.gameMode = 0; - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); - this->state.running = false; - } - - gSaveContext.respawn[0].entranceIndex = -1; - gSaveContext.respawnFlag = 0; - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - gSaveContext.showTitleCard = true; - gSaveContext.dogParams = 0; - gSaveContext.timer1State = 0; - gSaveContext.timer2State = 0; - gSaveContext.eventInf[0] = 0; - gSaveContext.eventInf[1] = 0; - gSaveContext.eventInf[2] = 0; - gSaveContext.eventInf[3] = 0; - gSaveContext.unk_13EE = 0x32; - gSaveContext.nayrusLoveTimer = 0; - gSaveContext.healthAccumulator = 0; - gSaveContext.unk_13F0 = 0; - gSaveContext.unk_13F2 = 0; - gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; - gSaveContext.skyboxTime = 0; - gSaveContext.nextTransition = 0xFF; - gSaveContext.nextCutsceneIndex = 0xFFEF; - gSaveContext.cutsceneTrigger = 0; - gSaveContext.chamberCutsceneNum = 0; - gSaveContext.nextDayTime = 0xFFFF; - gSaveContext.unk_13C3 = 0; - - gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = - gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; - - gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = - gSaveContext.unk_13F4 = 0; - - gSaveContext.unk_13F6 = gSaveContext.magic; - gSaveContext.magic = 0; - gSaveContext.magicLevel = gSaveContext.magic; - - if (1) {} - - osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("Z_MAGIC_NOW_NOW=%d MAGIC_NOW=%d\n", ((void)0, gSaveContext.unk_13F6), gSaveContext.magic); - osSyncPrintf(VT_RST); - - gSaveContext.naviTimer = 0; - - if ((gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI) && - (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_MASTER) && - (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_BGS) && - (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { - - gSaveContext.equips.buttonItems[0] = ITEM_NONE; - swordEquipMask = gEquipMasks[EQUIP_SWORD] & gSaveContext.equips.equipment; - gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_SWORD]; - if(swordEquipMask != 0) { - gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << gEquipShifts[EQUIP_SWORD]); - } - } -} - -static void (*gSelectModeUpdateFuncs[])(GameState*) = { - FileChoose_FadeMainToSelect, FileChoose_MoveSelectedFileToTop, FileChoose_FadeInFileInfo, FileChoose_ConfirmFile, - FileChoose_FadeOutFileInfo, FileChoose_MoveSelectedFileToSlot, FileChoose_FadeOut, FileChoose_LoadGame, -}; - -void FileChoose_SelectModeUpdate(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - gSelectModeUpdateFuncs[this->selectMode](&this->state); -} - -void FileChoose_SelectModeDraw(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - f32 eyeX; - f32 eyeY; - f32 eyeZ; - - OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2753); - - gDPPipeSync(POLY_OPA_DISP++); - - eyeX = 1000.0f * Math_CosS(ZREG(11)) - 1000.0f * Math_SinS(ZREG(11)); - eyeY = ZREG(13); - eyeZ = 1000.0f * Math_SinS(ZREG(11)) + 1000.0f * Math_CosS(ZREG(11)); - - FileChoose_SetView(this, eyeX, eyeY, eyeZ); - SkyboxDraw_Draw(&this->skyboxCtx, this->state.gfxCtx, 1, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ); - gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); - ZREG(11) += ZREG(10); - Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx); - gDPPipeSync(POLY_OPA_DISP++); - func_800949A8(this->state.gfxCtx); - FileChoose_SetView(this, 0.0f, 0.0f, 64.0f); - FileChoose_SetWindowVtx(&this->state); - FileChoose_SetWindowContentVtx(&this->state); - - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->windowAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); - Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); - Matrix_RotateX(this->windowRot / 100.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_choose.c", 2810), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[0], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[32], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[64], 16, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); - - FileChoose_DrawWindowContents(&this->state); - gDPPipeSync(POLY_OPA_DISP++); - FileChoose_SetView(this, 0.0f, 0.0f, 64.0f); - - CLOSE_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2834); -} - -static void (*gFileSelectDrawFuncs[])(GameState*) = { - FileChoose_InitModeDraw, - FileChoose_ConfigModeDraw, - FileChoose_SelectModeDraw, -}; - -static void (*gFileSelectUpdateFuncs[])(GameState*) = { - FileChoose_InitModeUpdate, - FileChoose_ConfigModeUpdate, - FileChoose_SelectModeUpdate, -}; - -void FileChoose_Main(GameState* thisx) { - static void* controlsTextures[] = { - gFileSelControlsENGTex, - gFileSelControlsGERTex, - gFileSelControlsFRATex, - }; - FileChooseContext* this = (FileChooseContext*)thisx; - Input* input = &this->state.input[0]; - - OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2898); - - this->n64ddFlag = 0; - - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); - gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); - gSPSegment(POLY_OPA_DISP++, 0x02, this->parameterSegment); - - Gfx_ClearDisplay(this->state.gfxCtx, 0, 0, 0); - - this->stickRelX = input->rel.stick_x; - this->stickRelY = input->rel.stick_y; - - if (this->stickRelX < -30) { - if (this->stickXDir == -1) { - this->inputTimerX--; - if (this->inputTimerX < 0) { - this->inputTimerX = 2; - } else { - this->stickRelX = 0; - } - } else { - this->inputTimerX = 10; - this->stickXDir = -1; - } - } else if (this->stickRelX > 30) { - if (this->stickXDir == 1) { - this->inputTimerX--; - if (this->inputTimerX < 0) { - this->inputTimerX = 2; - } else { - this->stickRelX = 0; - } - } else { - this->inputTimerX = 10; - this->stickXDir = 1; - } - } else { - this->stickXDir = 0; - } - - if (this->stickRelY < -30) { - if (this->stickYDir == -1) { - this->inputTimerY -= 1; - if (this->inputTimerY < 0) { - this->inputTimerY = 2; - } else { - this->stickRelY = 0; - } - } else { - this->inputTimerY = 10; - this->stickYDir = -1; - } - } else if (this->stickRelY > 30) { - if (this->stickYDir == 1) { - this->inputTimerY -= 1; - if (this->inputTimerY < 0) { - this->inputTimerY = 2; - } else { - this->stickRelY = 0; - } - } else { - this->inputTimerY = 10; - this->stickYDir = 1; - } - } else { - this->stickYDir = 0; - } - - this->emptyFileTextAlpha = 0; - - FileChoose_PulsateCursor(&this->state); - gFileSelectUpdateFuncs[this->menuMode](&this->state); - gFileSelectDrawFuncs[this->menuMode](&this->state); - - // do not draw controls text in the options menu - if ((this->configMode <= CM_NAME_ENTRY_TO_MAIN) || (this->configMode >= CM_UNUSED_DELAY)) { - func_800944C4(this->state.gfxCtx); - - gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 255, this->controlsAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - gDPLoadTextureBlock(POLY_OPA_DISP++, controlsTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_8b, 144, 16, - 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, - G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(POLY_OPA_DISP++, 0x0168, 0x0330, 0x03A8, 0x0370, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400); - } - - gDPPipeSync(POLY_OPA_DISP++); - gSPDisplayList(POLY_OPA_DISP++, sScreenFillSetupDL); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, sScreenFillAlpha); - gDPFillRectangle(POLY_OPA_DISP++, 0, 0, gScreenWidth - 1, gScreenHeight - 1); - - CLOSE_DISPS(this->state.gfxCtx, "../z_file_choose.c", 3035); -} - -void FileChoose_InitContext(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - EnvironmentContext* envCtx = &this->envCtx; - SramContext* sramCtx = &this->sramCtx; - - Sram_Alloc(&this->state, sramCtx); - - ZREG(7) = 32; - ZREG(8) = 22; - ZREG(9) = 20; - ZREG(10) = -10; - ZREG(11) = 0; - ZREG(12) = 1000; - ZREG(13) = -700; - ZREG(14) = 164; - ZREG(15) = 104; - ZREG(16) = 160; - ZREG(17) = 100; - ZREG(18) = 162; - ZREG(19) = 152; - ZREG(20) = 214; - - XREG(13) = 580; - XREG(14) = 400; - XREG(35) = 20; - XREG(36) = 20; - XREG(37) = 20; - XREG(43) = 8; - XREG(44) = -78; - XREG(45) = 0; - XREG(46) = 0; - XREG(47) = 0; - XREG(48) = 0; - XREG(49) = 3; - XREG(50) = 8; - XREG(51) = 8; - XREG(52) = 10; - XREG(73) = 0; - - VREG(0) = 14; - VREG(1) = 5; - VREG(2) = 4; - VREG(4) = 1; - VREG(5) = 6; - VREG(6) = 2; - VREG(7) = 6; - VREG(8) = 80; - - sScreenFillAlpha = 255; - - VREG(10) = 10; - VREG(11) = 30; - VREG(12) = -100; - VREG(13) = -85; - VREG(14) = 4; - VREG(16) = 25; - VREG(17) = 1; - VREG(18) = 1; - VREG(20) = 92; - VREG(21) = 171; - VREG(22) = 11; - VREG(23) = 10; - VREG(24) = 26; - VREG(25) = 2; - VREG(26) = 1; - VREG(27) = 0; - VREG(28) = 0; - VREG(29) = 160; - VREG(30) = 64; - VREG(31) = 154; - VREG(32) = 152; - VREG(33) = 106; - - WREG(38) = 16; - WREG(39) = 9; - WREG(40) = 10; - WREG(41) = 14; - WREG(42) = 11; - WREG(43) = 12; - - this->menuMode = FS_MENU_MODE_INIT; - - this->buttonIndex = this->selectMode = this->selectedFileIndex = this->copyDestFileIndex = - this->confirmButtonIndex = 0; - - this->confirmButtonTexIndices[0] = 2; - this->confirmButtonTexIndices[1] = 3; - this->titleLabel = FS_TITLE_SELECT_FILE; - this->nextTitleLabel = FS_TITLE_OPEN_FILE; - this->highlightPulseDir = 1; - this->unk_1CAAC = 0xC; - this->highlightColor[0] = 155; - this->highlightColor[1] = 255; - this->highlightColor[2] = 255; - this->highlightColor[3] = 70; - this->configMode = CM_FADE_IN_START; - this->windowRot = 0.0f; - this->stickXDir = this->inputTimerX = 0; - this->stickYDir = this->inputTimerY = 0; - this->kbdX = this->kbdY = this->charIndex = 0; - this->kbdButton = FS_KBD_BTN_NONE; - - this->windowColor[0] = 100; - this->windowColor[1] = 150; - this->windowColor[2] = 255; - - this->windowAlpha = this->titleAlpha[0] = this->titleAlpha[1] = this->fileButtonAlpha[0] = - this->fileButtonAlpha[1] = this->fileButtonAlpha[2] = this->nameBoxAlpha[0] = this->nameBoxAlpha[1] = - this->nameBoxAlpha[2] = this->nameAlpha[0] = this->nameAlpha[1] = this->nameAlpha[2] = - this->connectorAlpha[0] = this->connectorAlpha[1] = this->connectorAlpha[2] = this->fileInfoAlpha[0] = - this->fileInfoAlpha[1] = this->fileInfoAlpha[2] = this->actionButtonAlpha[FS_BTN_ACTION_COPY] = - this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] = - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = this->optionButtonAlpha = - this->nameEntryBoxAlpha = this->controlsAlpha = this->emptyFileTextAlpha = 0; - - this->windowPosX = 6; - this->actionTimer = 8; - this->warningLabel = FS_WARNING_NONE; - - this->warningButtonIndex = this->buttonYOffsets[0] = this->buttonYOffsets[1] = this->buttonYOffsets[2] = - this->buttonYOffsets[3] = this->buttonYOffsets[4] = this->buttonYOffsets[5] = this->fileNamesY[0] = - this->fileNamesY[1] = this->fileNamesY[2] = 0; - - this->unk_1CAD6[0] = 0; - this->unk_1CAD6[1] = 3; - this->unk_1CAD6[2] = 6; - this->unk_1CAD6[3] = 8; - this->unk_1CAD6[4] = 10; - - ShrinkWindow_SetVal(0); - - gSaveContext.skyboxTime = 0; - gSaveContext.dayTime = 0; - - Skybox_Init(&this->state, &this->skyboxCtx, SKYBOX_NORMAL_SKY); - - gTimeIncrement = 10; - - envCtx->unk_19 = 0; - envCtx->unk_1A = 0; - envCtx->unk_21 = 0; - envCtx->unk_22 = 0; - envCtx->skyboxDmaState = SKYBOX_DMA_INACTIVE; - envCtx->skybox1Index = 99; - envCtx->skybox2Index = 99; - envCtx->unk_1F = 0; - envCtx->unk_20 = 0; - envCtx->unk_BD = 0; - envCtx->unk_17 = 2; - envCtx->skyboxDisabled = 0; - envCtx->skyboxBlend = 0; - envCtx->unk_84 = 0.0f; - envCtx->unk_88 = 0.0f; - - Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx); - - gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = - gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; - - this->n64ddFlags[0] = this->n64ddFlags[1] = this->n64ddFlags[2] = this->defense[0] = this->defense[1] = - this->defense[2] = 0; - - SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); - - gSaveContext.language = sramCtx->readBuff[SRAM_HEADER_LANGUAGE]; - - if (gSaveContext.language >= LANGUAGE_MAX) { - sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_ENG; - } -} - -void FileChoose_Destroy(GameState* thisx) { -} -#include -void FileChoose_Init(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - u32 size = POINTER_SUB(_title_staticSegmentRomEnd, _title_staticSegmentRomStart); - s32 pad; - - SREG(30) = 1; - osSyncPrintf("SIZE=%x\n", size); - - this->staticSegment = GameState_Alloc(&this->state, size, "../z_file_choose.c", 3392); - ASSERT(this->staticSegment != NULL, "this->staticSegment != NULL", "../z_file_choose.c", 3393); - //DmaMgr_SendRequest1(this->staticSegment, (u32)_title_staticSegmentRomStart, size, "../z_file_choose.c", 3394); - - size = POINTER_SUB(_parameter_staticSegmentRomEnd, _parameter_staticSegmentRomStart); - this->parameterSegment = GameState_Alloc(&this->state, size, "../z_file_choose.c", 3398); - ASSERT(this->parameterSegment != NULL, "this->parameterSegment != NULL", "../z_file_choose.c", 3399); - //DmaMgr_SendRequest1(this->parameterSegment, (u32)_parameter_staticSegmentRomStart, size, "../z_file_choose.c", - // 3400); - - Matrix_Init(&this->state); - View_Init(&this->view, this->state.gfxCtx); - this->state.main = FileChoose_Main; - this->state.destroy = FileChoose_Destroy; - FileChoose_InitContext(&this->state); - Font_LoadOrderedFont(&this->font); - Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); - func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); -} diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.cpp b/src/overlays/gamestates/ovl_file_choose/z_file_choose.cpp new file mode 100644 index 000000000..744c64bdb --- /dev/null +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.cpp @@ -0,0 +1,1927 @@ +#define INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_FILE_CHOOSE_Z_FILE_CHOOSE_C +#include "actor_common.h" +#include "z_kankyo.h" +#include "z_player.h" +#include "z_play.h" +#include "z_file_choose.h" +#include "z_select.h" +#include "file_choose.h" +#include +#include "segment_symbols.h" +#include "textures/title_static/title_static.h" +#include "textures/parameter_static/parameter_static.h" +#include "def/code_80069420.h" +#include "def/code_80097A00.h" +#include "def/code_800A9F30.h" +#include "def/code_800EC960.h" +#include "def/code_800F7260.h" +#include "def/code_800F9280.h" +#include "def/game.h" +#include "def/graph.h" +#include "def/shrink_window.h" +#include "def/sys_matrix.h" +#include "def/z_common_data.h" +#include "def/z_file_choose.h" +#include "def/z_kanfont.h" +#include "def/z_kankyo.h" +#include "def/z_lib.h" +#include "def/z_rcp.h" +#include "def/z_sram.h" +#include "def/z_ss_sram.h" +#include "def/z_std_dma.h" +#include "def/z_view.h" +#include "def/z_vr_box.h" +#include "def/z_vr_box_draw.h" +#include "def/z_play.h" // FORCE + +extern u16 gSramSlotOffsets[]; + +static s16 sUnused = 106; + +static s16 sScreenFillAlpha = 255; + +static Gfx sScreenFillSetupDL[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_CLD_SURF | G_RM_CLD_SURF2), + gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), + gsSPEndDisplayList(), +}; + +static s16 sFileInfoBoxPartWidths[] = { 36, 36, 36, 36, 24 }; + +static s16 sWindowContentColors[2][3] = { + { 100, 150, 255 }, // blue + { 100, 100, 100 }, // gray +}; + +void FileChoose_SetView(FileChooseContext* pthis, f32 eyeX, f32 eyeY, f32 eyeZ) { + Vec3f eye; + Vec3f lookAt; + Vec3f up; + + lookAt.x = lookAt.y = lookAt.z = 0.0f; + up.x = up.z = 0.0f; + + eye.x = eyeX; + eye.y = eyeY; + eye.z = eyeZ; + + up.y = 1.0f; + + func_800AA358(&pthis->view, &eye, &lookAt, &up); + func_800AAA50(&pthis->view, 0x7F); +} + +Gfx* FileChoose_QuadTextureIA8(Gfx* gfx, void* texture, s16 width, s16 height, s16 point) { + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(gfx++, point, point + 2, point + 3, point + 1, 0); + + return gfx; +} + +void FileChoose_InitModeUpdate(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + if (pthis->menuMode == FS_MENU_MODE_INIT) { + pthis->menuMode = FS_MENU_MODE_CONFIG; + pthis->configMode = CM_FADE_IN_START; + pthis->nextTitleLabel = FS_TITLE_OPEN_FILE; + osSyncPrintf("SRAM Start-Load >>>>> "); + Sram_VerifyAndLoadAllSaves(pthis, &pthis->sramCtx); + osSyncPrintf("Done!!!\n"); + } +} + +void FileChoose_InitModeDraw(GameState* thisx) { +} + +/** + * Fade in the menu window and title label. + * If a file is occupied fade in the name, name box, and connector. + * Fade in the copy erase and options button according to the window alpha. + */ +void FileChoose_FadeInMenuElements(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + + pthis->titleAlpha[0] += VREG(1); + pthis->windowAlpha += VREG(2); + + for (i = 0; i < 3; i++) { + pthis->fileButtonAlpha[i] = pthis->windowAlpha; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->windowAlpha; + pthis->connectorAlpha[i] += VREG(1); + if (pthis->connectorAlpha[i] >= 255) { + pthis->connectorAlpha[i] = 255; + } + } + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->optionButtonAlpha = pthis->windowAlpha; +} + +/** + * Converts a numerical value to ones-tens-hundreds digits + */ +void FileChoose_SplitNumber(u16 value, s16* hundreds, s16* tens, s16* ones) { + *hundreds = 0; + *tens = 0; + *ones = value; + + while (true) { + if ((*ones - 100) < 0) { + break; + } + (*hundreds)++; + *ones -= 100; + } + + while (true) { + if ((*ones - 10) < 0) { + break; + } + (*tens)++; + *ones -= 10; + } +} + +/** + * Reduce the alpha of the black screen fill to create a fade in effect. + * Additionally, slide the window from the right to the center of the screen. + * Update function for `CM_FADE_IN_START` + */ +void FileChoose_StartFadeIn(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + FileChoose_FadeInMenuElements(&pthis->state); + sScreenFillAlpha -= 40; + pthis->windowPosX -= 20; + + if (pthis->windowPosX <= -94) { + pthis->windowPosX = -94; + pthis->configMode = CM_FADE_IN_END; + sScreenFillAlpha = 0; + } +} + +/** + * Finish fading in the remaining menu elements. + * Fade in the controls text at the bottom of the screen. + * Update function for `CM_FADE_IN_END` + */ +void FileChoose_FinishFadeIn(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->controlsAlpha += VREG(1); + FileChoose_FadeInMenuElements(&pthis->state); + + if (pthis->titleAlpha[0] >= 255) { + pthis->titleAlpha[0] = 255; + pthis->controlsAlpha = 255; + pthis->windowAlpha = 200; + pthis->configMode = CM_MAIN_MENU; + } +} + +/** + * Update the cursor and wait for the player to select a button to change menus accordingly. + * If an empty file is selected, enter the name entry config mode. + * If an occupied file is selected, enter the `Select` menu mode. + * If copy, erase, or options is selected, set config mode accordingly. + * Lastly, set any warning labels if appropriate. + * Update function for `CM_MAIN_MENU` + */ +void FileChoose_UpdateMainMenu(GameState* thisx) { + static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + Input* input = &pthis->state.input[0]; + + if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (pthis->buttonIndex <= FS_BTN_MAIN_FILE_3) { + osSyncPrintf("REGCK_ALL[%x]=%x,%x,%x,%x,%x,%x\n", pthis->buttonIndex, + GET_NEWF(sramCtx, pthis->buttonIndex, 0), GET_NEWF(sramCtx, pthis->buttonIndex, 1), + GET_NEWF(sramCtx, pthis->buttonIndex, 2), GET_NEWF(sramCtx, pthis->buttonIndex, 3), + GET_NEWF(sramCtx, pthis->buttonIndex, 4), GET_NEWF(sramCtx, pthis->buttonIndex, 5)); + + if (!SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->configMode = CM_ROTATE_TO_NAME_ENTRY; + pthis->kbdButton = FS_KBD_BTN_NONE; + pthis->charPage = FS_CHAR_PAGE_ENG; + pthis->kbdX = 0; + pthis->kbdY = 0; + pthis->charIndex = 0; + pthis->charBgAlpha = 0; + pthis->newFileNameCharCount = 0; + pthis->nameEntryBoxPosX = 120; + pthis->nameEntryBoxAlpha = 0; + MemCopy(&pthis->fileNames[pthis->buttonIndex][0], &emptyName, 8); + } else if (pthis->n64ddFlags[pthis->buttonIndex] == pthis->n64ddFlag) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->actionTimer = 8; + pthis->selectMode = SM_FADE_MAIN_TO_SELECT; + pthis->selectedFileIndex = pthis->buttonIndex; + pthis->menuMode = FS_MENU_MODE_SELECT; + pthis->nextTitleLabel = FS_TITLE_OPEN_FILE; + } else if (!pthis->n64ddFlags[pthis->buttonIndex]) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else { + if (pthis->warningLabel == FS_WARNING_NONE) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->prevConfigMode = pthis->configMode; + + if (pthis->buttonIndex == FS_BTN_MAIN_COPY) { + pthis->configMode = CM_SETUP_COPY_SOURCE; + pthis->nextTitleLabel = FS_TITLE_COPY_FROM; + } else if (pthis->buttonIndex == FS_BTN_MAIN_ERASE) { + pthis->configMode = CM_SETUP_ERASE_SELECT; + pthis->nextTitleLabel = FS_TITLE_ERASE_FILE; + } else { + pthis->configMode = CM_MAIN_TO_OPTIONS; + pthis->kbdButton = 0; + pthis->kbdX = 0; + pthis->kbdY = 0; + pthis->charBgAlpha = 0; + pthis->newFileNameCharCount = 0; + pthis->nameEntryBoxPosX = 120; + } + + pthis->actionTimer = 8; + } else { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + } else { + if (ABS(pthis->stickRelY) > 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + if (pthis->stickRelY > 30) { + pthis->buttonIndex--; + if (pthis->buttonIndex < FS_BTN_MAIN_FILE_1) { + pthis->buttonIndex = FS_BTN_MAIN_OPTIONS; + } + } else { + pthis->buttonIndex++; + if (pthis->buttonIndex > FS_BTN_MAIN_OPTIONS) { + pthis->buttonIndex = FS_BTN_MAIN_FILE_1; + } + } + } + + if (pthis->buttonIndex == FS_BTN_MAIN_COPY) { + if (!SLOT_OCCUPIED(sramCtx, 0) && !SLOT_OCCUPIED(sramCtx, 1) && !SLOT_OCCUPIED(sramCtx, 2)) { + pthis->warningButtonIndex = pthis->buttonIndex; + pthis->warningLabel = FS_WARNING_NO_FILE_COPY; + pthis->emptyFileTextAlpha = 255; + } else if (SLOT_OCCUPIED(sramCtx, 0) && SLOT_OCCUPIED(sramCtx, 1) && SLOT_OCCUPIED(sramCtx, 2)) { + pthis->warningButtonIndex = pthis->buttonIndex; + pthis->warningLabel = FS_WARNING_NO_EMPTY_FILES; + pthis->emptyFileTextAlpha = 255; + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } else if (pthis->buttonIndex == FS_BTN_MAIN_ERASE) { + if (!SLOT_OCCUPIED(sramCtx, 0) && !SLOT_OCCUPIED(sramCtx, 1) && !SLOT_OCCUPIED(sramCtx, 2)) { + pthis->warningButtonIndex = pthis->buttonIndex; + pthis->warningLabel = FS_WARNING_NO_FILE_ERASE; + pthis->emptyFileTextAlpha = 255; + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } +} + +/** + * Update function for `CM_UNUSED_31` + */ +void FileChoose_UnusedCM31(GameState* thisx) { +} + +/** + * Delay the next config mode from running until `XREG(73)` reaches 254. + * Because the timer increments by 2, the delay is 127 frames (assuming the value was not changed by reg editor). + * Unused in the final game, was possibly used for debugging. + * Update function for `CM_UNUSED_DELAY` + */ +void FileChoose_UnusedCMDelay(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + XREG(73) += 2; + + if (XREG(73) == 254) { + pthis->configMode = pthis->nextConfigMode; + XREG(73) = 0; + } +} + +/** + * Rotate the window from the main menu to the name entry menu. + * Update function for `CM_ROTATE_TO_NAME_ENTRY` + */ +void FileChoose_RotateToNameEntry(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->windowRot += VREG(16); + + if (pthis->windowRot >= 314.0f) { + pthis->windowRot = 314.0f; + pthis->configMode = CM_START_NAME_ENTRY; + } +} + +/** + * Rotate the window from the main menu to the options menu. + * Update function for `CM_MAIN_TO_OPTIONS` + */ +void FileChoose_RotateToOptions(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->windowRot += VREG(16); + + if (pthis->windowRot >= 314.0f) { + pthis->windowRot = 314.0f; + pthis->configMode = CM_START_OPTIONS; + } +} + +/** + * Rotate the window from the options menu to the main menu. + * Update function for `CM_NAME_ENTRY_TO_MAIN` and `CM_OPTIONS_TO_MAIN` + */ +void FileChoose_RotateToMain(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->windowRot += VREG(16); + + if (pthis->windowRot >= 628.0f) { + pthis->windowRot = 0.0f; + pthis->configMode = CM_MAIN_MENU; + } +} + +static void (*gConfigModeUpdateFuncs[])(GameState*) = { + FileChoose_StartFadeIn, FileChoose_FinishFadeIn, + FileChoose_UpdateMainMenu, FileChoose_SetupCopySource, + FileChoose_SelectCopySource, FileChoose_SetupCopyDest1, + FileChoose_SetupCopyDest2, FileChoose_SelectCopyDest, + FileChoose_ExitToCopySource1, FileChoose_ExitToCopySource2, + FileChoose_SetupCopyConfirm1, FileChoose_SetupCopyConfirm2, + FileChoose_CopyConfirm, FileChoose_ReturnToCopyDest, + FileChoose_CopyAnim1, FileChoose_CopyAnim2, + FileChoose_CopyAnim3, FileChoose_CopyAnim4, + FileChoose_CopyAnim5, FileChoose_ExitCopyToMain, + FileChoose_SetupEraseSelect, FileChoose_EraseSelect, + FileChoose_SetupEraseConfirm1, FileChoose_SetupEraseConfirm2, + FileChoose_EraseConfirm, FileChoose_ExitToEraseSelect1, + FileChoose_ExitToEraseSelect2, FileChoose_EraseAnim1, + FileChoose_EraseAnim2, FileChoose_EraseAnim3, + FileChoose_ExitEraseToMain, FileChoose_UnusedCM31, + FileChoose_RotateToNameEntry, FileChoose_UpdateKeyboardCursor, + FileChoose_StartNameEntry, FileChoose_RotateToMain, + FileChoose_RotateToOptions, FileChoose_UpdateOptionsMenu, + FileChoose_StartOptions, FileChoose_RotateToMain, + FileChoose_UnusedCMDelay, +}; + +/** + * Updates the alpha of the cursor to make it pulsate. + * On the debug rom, pthis function also handles switching languages with controller 3. + */ +void FileChoose_PulsateCursor(GameState* thisx) { + static s16 cursorAlphaTargets[] = { 70, 200 }; + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 alphaStep; + SramContext* sramCtx = &pthis->sramCtx; + Input* debugInput = &pthis->state.input[2]; + + if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) { + sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_ENG; +#ifdef N64_VERSION + *((u8*)0x80000002) = LANGUAGE_ENG; +#endif + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE); + osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], + sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], + sramCtx->readBuff[SRAM_HEADER_MAGIC]); + + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); + osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], + sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], + sramCtx->readBuff[SRAM_HEADER_MAGIC]); + } else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DUP)) { + sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_GER; +#ifdef N64_VERSION + *((u8*)0x80000002) = LANGUAGE_GER; +#endif + + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE); + osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], + sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], + sramCtx->readBuff[SRAM_HEADER_MAGIC]); + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); + osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], + sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], + sramCtx->readBuff[SRAM_HEADER_MAGIC]); + } else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DRIGHT)) { + sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_FRA; +#ifdef N64_VERSION + *((u8*)0x80000002) = LANGUAGE_FRA; +#endif + + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE); + osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], + sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], + sramCtx->readBuff[SRAM_HEADER_MAGIC]); + + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); + osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND], + sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE], + sramCtx->readBuff[SRAM_HEADER_MAGIC]); + } + + alphaStep = ABS(pthis->highlightColor[3] - cursorAlphaTargets[pthis->highlightPulseDir]) / XREG(35); + + if (pthis->highlightColor[3] >= cursorAlphaTargets[pthis->highlightPulseDir]) { + pthis->highlightColor[3] -= alphaStep; + } else { + pthis->highlightColor[3] += alphaStep; + } + + XREG(35)--; + + if (XREG(35) == 0) { + pthis->highlightColor[3] = cursorAlphaTargets[pthis->highlightPulseDir]; + XREG(35) = XREG(36 + pthis->highlightPulseDir); + pthis->highlightPulseDir ^= 1; + } +} + +void FileChoose_ConfigModeUpdate(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + gConfigModeUpdateFuncs[pthis->configMode](&pthis->state); +} + +void FileChoose_SetWindowVtx(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 i; + s16 j; + s16 x; + s16 tmp; + s16 tmp2; + s16 tmp3; + + pthis->windowVtx = (Vtx*)Graph_Alloc(pthis->state.gfxCtx, sizeof(Vtx) * 80); + tmp = pthis->windowPosX - 90; + + for (x = 0, i = 0; i < 4; i++) { + tmp += 0x40; + tmp2 = (i == 3) ? 0x30 : 0x40; + + for (j = 0, tmp3 = 0x50; j < 5; j++, x += 4, tmp3 -= 0x20) { + pthis->windowVtx[x].v.ob[0] = pthis->windowVtx[x + 2].v.ob[0] = tmp; + + pthis->windowVtx[x + 1].v.ob[0] = pthis->windowVtx[x + 3].v.ob[0] = tmp + tmp2; + + pthis->windowVtx[x].v.ob[1] = pthis->windowVtx[x + 1].v.ob[1] = tmp3; + + pthis->windowVtx[x + 2].v.ob[1] = pthis->windowVtx[x + 3].v.ob[1] = tmp3 - 0x20; + + pthis->windowVtx[x].v.ob[2] = pthis->windowVtx[x + 1].v.ob[2] = pthis->windowVtx[x + 2].v.ob[2] = + pthis->windowVtx[x + 3].v.ob[2] = 0; + + pthis->windowVtx[x].v.flag = pthis->windowVtx[x + 1].v.flag = pthis->windowVtx[x + 2].v.flag = + pthis->windowVtx[x + 3].v.flag = 0; + + pthis->windowVtx[x].v.tc[0] = pthis->windowVtx[x].v.tc[1] = pthis->windowVtx[x + 1].v.tc[1] = + pthis->windowVtx[x + 2].v.tc[0] = 0; + + pthis->windowVtx[x + 1].v.tc[0] = pthis->windowVtx[x + 3].v.tc[0] = tmp2 * 0x20; + + pthis->windowVtx[x + 2].v.tc[1] = pthis->windowVtx[x + 3].v.tc[1] = 0x400; + + pthis->windowVtx[x].v.cn[0] = pthis->windowVtx[x + 2].v.cn[0] = pthis->windowVtx[x].v.cn[1] = + pthis->windowVtx[x + 2].v.cn[1] = pthis->windowVtx[x].v.cn[2] = pthis->windowVtx[x + 2].v.cn[2] = + pthis->windowVtx[x + 1].v.cn[0] = pthis->windowVtx[x + 3].v.cn[0] = pthis->windowVtx[x + 1].v.cn[1] = + pthis->windowVtx[x + 3].v.cn[1] = pthis->windowVtx[x + 1].v.cn[2] = + pthis->windowVtx[x + 3].v.cn[2] = pthis->windowVtx[x].v.cn[3] = + pthis->windowVtx[x + 2].v.cn[3] = pthis->windowVtx[x + 1].v.cn[3] = + pthis->windowVtx[x + 3].v.cn[3] = 255; + } + } +} + +static s16 D_80812818[] = { 0x001A, 0x000A, 0x000A, 0x000A }; +static s16 D_80812820[] = { 0x0020, 0x000C, 0x000C, 0x000C }; +static s16 D_80812828[] = { 0x0010, 0x000C, 0x000C, 0x000C }; +static s16 D_80812830[] = { 0x0040, 0x0054, 0x0068, 0x0274, 0x0278, 0x027C }; +static s16 D_8081283C[] = { 0x0040, 0x0054, 0x0068, 0x0278 }; +static s16 D_80812844[] = { 0x0274, 0x0278 }; +static s16 D_80812848[] = { 0x0274, 0x0278 }; + +void FileChoose_SetWindowContentVtx(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 phi_t2; + s16 phi_t0; + s16 phi_t5; + s16 phi_a1; + s16 phi_ra; + s16 temp_t1; + SramContext* sramCtx = &pthis->sramCtx; + + pthis->windowContentVtx = (Vtx*)Graph_Alloc(pthis->state.gfxCtx, 0x288 * sizeof(Vtx)); + + for (phi_t2 = 0; phi_t2 < 0x288; phi_t2 += 4) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = 0x12C; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0x10; + + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = 0; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x10; + + pthis->windowContentVtx[phi_t2].v.ob[2] = pthis->windowContentVtx[phi_t2 + 1].v.ob[2] = + pthis->windowContentVtx[phi_t2 + 2].v.ob[2] = pthis->windowContentVtx[phi_t2 + 3].v.ob[2] = 0; + + pthis->windowContentVtx[phi_t2].v.flag = pthis->windowContentVtx[phi_t2 + 1].v.flag = + pthis->windowContentVtx[phi_t2 + 2].v.flag = pthis->windowContentVtx[phi_t2 + 3].v.flag = 0; + + pthis->windowContentVtx[phi_t2].v.tc[0] = pthis->windowContentVtx[phi_t2].v.tc[1] = + pthis->windowContentVtx[phi_t2 + 1].v.tc[1] = pthis->windowContentVtx[phi_t2 + 2].v.tc[0] = 0; + + pthis->windowContentVtx[phi_t2 + 1].v.tc[0] = pthis->windowContentVtx[phi_t2 + 2].v.tc[1] = + pthis->windowContentVtx[phi_t2 + 3].v.tc[0] = pthis->windowContentVtx[phi_t2 + 3].v.tc[1] = 0x200; + + pthis->windowContentVtx[phi_t2].v.cn[0] = pthis->windowContentVtx[phi_t2 + 1].v.cn[0] = + pthis->windowContentVtx[phi_t2 + 2].v.cn[0] = pthis->windowContentVtx[phi_t2 + 3].v.cn[0] = + pthis->windowContentVtx[phi_t2].v.cn[1] = pthis->windowContentVtx[phi_t2 + 1].v.cn[1] = + pthis->windowContentVtx[phi_t2 + 2].v.cn[1] = pthis->windowContentVtx[phi_t2 + 3].v.cn[1] = + pthis->windowContentVtx[phi_t2].v.cn[2] = pthis->windowContentVtx[phi_t2 + 1].v.cn[2] = + pthis->windowContentVtx[phi_t2 + 2].v.cn[2] = pthis->windowContentVtx[phi_t2 + 3].v.cn[2] = + pthis->windowContentVtx[phi_t2].v.cn[3] = pthis->windowContentVtx[phi_t2 + 1].v.cn[3] = + pthis->windowContentVtx[phi_t2 + 2].v.cn[3] = + pthis->windowContentVtx[phi_t2 + 3].v.cn[3] = 0xFF; + } + + pthis->windowContentVtx[0].v.ob[0] = pthis->windowContentVtx[2].v.ob[0] = pthis->windowPosX; + pthis->windowContentVtx[1].v.ob[0] = pthis->windowContentVtx[3].v.ob[0] = pthis->windowContentVtx[0].v.ob[0] + 0x80; + pthis->windowContentVtx[0].v.ob[1] = pthis->windowContentVtx[1].v.ob[1] = 0x48; + pthis->windowContentVtx[2].v.ob[1] = pthis->windowContentVtx[3].v.ob[1] = pthis->windowContentVtx[0].v.ob[1] - 0x10; + pthis->windowContentVtx[1].v.tc[0] = pthis->windowContentVtx[3].v.tc[0] = 0x1000; + + for (phi_a1 = 0, phi_t2 = 4; phi_a1 < 3; phi_a1++) { + phi_t0 = pthis->windowPosX - 6; + + for (phi_t5 = 0; phi_t5 < 5; phi_t5++, phi_t2 += 4) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + sFileInfoBoxPartWidths[phi_t5]; + + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = + pthis->fileNamesY[phi_a1] + 0x2C; + + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x38; + + pthis->windowContentVtx[phi_t2 + 1].v.tc[0] = pthis->windowContentVtx[phi_t2 + 3].v.tc[0] = + sFileInfoBoxPartWidths[phi_t5] << 5; + pthis->windowContentVtx[phi_t2 + 2].v.tc[1] = pthis->windowContentVtx[phi_t2 + 3].v.tc[1] = 0x700; + phi_t0 += sFileInfoBoxPartWidths[phi_t5]; + } + } + + phi_t0 = pthis->windowPosX - 6; + phi_ra = 0x2C; + + for (phi_t5 = 0; phi_t5 < 3; phi_t5++, phi_t2 += 20, phi_ra -= 0x10) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0x40; + + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = + pthis->buttonYOffsets[phi_t5] + phi_ra; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x10; + + pthis->windowContentVtx[phi_t2 + 1].v.tc[0] = pthis->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x800; + + pthis->windowContentVtx[phi_t2 + 4].v.ob[0] = pthis->windowContentVtx[phi_t2 + 6].v.ob[0] = phi_t0 + 0x40; + + pthis->windowContentVtx[phi_t2 + 5].v.ob[0] = pthis->windowContentVtx[phi_t2 + 7].v.ob[0] = + pthis->windowContentVtx[phi_t2 + 4].v.ob[0] + 0x6C; + + pthis->windowContentVtx[phi_t2 + 4].v.ob[1] = pthis->windowContentVtx[phi_t2 + 5].v.ob[1] = + pthis->buttonYOffsets[phi_t5] + phi_ra; + + pthis->windowContentVtx[phi_t2 + 6].v.ob[1] = pthis->windowContentVtx[phi_t2 + 7].v.ob[1] = + pthis->windowContentVtx[phi_t2 + 4].v.ob[1] - 0x10; + + pthis->windowContentVtx[phi_t2 + 5].v.tc[0] = pthis->windowContentVtx[phi_t2 + 7].v.tc[0] = 0xD80; + + if ((pthis->configMode == CM_COPY_ANIM_2) && (phi_t5 == pthis->copyDestFileIndex)) { + temp_t1 = pthis->fileNamesY[phi_t5] + 0x2C; + } else if (((pthis->configMode == CM_COPY_ANIM_3) || (pthis->configMode == CM_COPY_ANIM_4)) && + (phi_t5 == pthis->copyDestFileIndex)) { + temp_t1 = pthis->buttonYOffsets[phi_t5] + phi_ra; + } else { + temp_t1 = phi_ra + pthis->buttonYOffsets[phi_t5] + pthis->fileNamesY[phi_t5]; + } + + pthis->windowContentVtx[phi_t2 + 8].v.ob[0] = pthis->windowContentVtx[phi_t2 + 10].v.ob[0] = phi_t0 + 0xA8; + + pthis->windowContentVtx[phi_t2 + 9].v.ob[0] = pthis->windowContentVtx[phi_t2 + 11].v.ob[0] = + pthis->windowContentVtx[phi_t2 + 8].v.ob[0] + 0x2C; + + pthis->windowContentVtx[phi_t2 + 8].v.ob[1] = pthis->windowContentVtx[phi_t2 + 9].v.ob[1] = temp_t1; + pthis->windowContentVtx[phi_t2 + 10].v.ob[1] = pthis->windowContentVtx[phi_t2 + 11].v.ob[1] = + pthis->windowContentVtx[phi_t2 + 8].v.ob[1] - 0x10; + + pthis->windowContentVtx[phi_t2 + 9].v.tc[0] = pthis->windowContentVtx[phi_t2 + 11].v.tc[0] = 0x580; + pthis->windowContentVtx[phi_t2 + 12].v.ob[0] = pthis->windowContentVtx[phi_t2 + 14].v.ob[0] = phi_t0 + 0x34; + pthis->windowContentVtx[phi_t2 + 13].v.ob[0] = pthis->windowContentVtx[phi_t2 + 15].v.ob[0] = + pthis->windowContentVtx[phi_t2 + 12].v.ob[0] + 0x18; + + pthis->windowContentVtx[phi_t2 + 12].v.ob[1] = pthis->windowContentVtx[phi_t2 + 13].v.ob[1] = + pthis->buttonYOffsets[phi_t5] + phi_ra; + + pthis->windowContentVtx[phi_t2 + 14].v.ob[1] = pthis->windowContentVtx[phi_t2 + 15].v.ob[1] = + pthis->windowContentVtx[phi_t2 + 12].v.ob[1] - 0x10; + + pthis->windowContentVtx[phi_t2 + 13].v.tc[0] = pthis->windowContentVtx[phi_t2 + 15].v.tc[0] = 0x300; + pthis->windowContentVtx[phi_t2 + 16].v.ob[0] = pthis->windowContentVtx[phi_t2 + 18].v.ob[0] = phi_t0 + 0x9C; + pthis->windowContentVtx[phi_t2 + 17].v.ob[0] = pthis->windowContentVtx[phi_t2 + 19].v.ob[0] = + pthis->windowContentVtx[phi_t2 + 16].v.ob[0] + 0x18; + + pthis->windowContentVtx[phi_t2 + 16].v.ob[1] = pthis->windowContentVtx[phi_t2 + 17].v.ob[1] = + pthis->buttonYOffsets[phi_t5] + phi_ra; + + pthis->windowContentVtx[phi_t2 + 18].v.ob[1] = pthis->windowContentVtx[phi_t2 + 19].v.ob[1] = + pthis->windowContentVtx[phi_t2 + 16].v.ob[1] - 0x10; + + pthis->windowContentVtx[phi_t2 + 17].v.tc[0] = pthis->windowContentVtx[phi_t2 + 19].v.tc[0] = 0x300; + } + + phi_ra = 0x2C; + + for (phi_t5 = 0; phi_t5 < 3; phi_t5++, phi_ra -= WREG(38)) { + if (SLOT_OCCUPIED(sramCtx, phi_t5)) { + phi_t0 = pthis->windowPosX - WREG(39); + + if ((pthis->configMode == 0xF) && (phi_t5 == pthis->copyDestFileIndex)) { + temp_t1 = pthis->fileNamesY[phi_t5] + 0x2C; + } else if (((pthis->configMode == CM_COPY_ANIM_3) || (pthis->configMode == CM_COPY_ANIM_4)) && + (phi_t5 == pthis->copyDestFileIndex)) { + temp_t1 = pthis->buttonYOffsets[phi_t5] + phi_ra; + } else { + temp_t1 = phi_ra + pthis->buttonYOffsets[phi_t5] + pthis->fileNamesY[phi_t5]; + } + + temp_t1 += 2; + + for (phi_a1 = 0; phi_a1 < 8; phi_a1++, phi_t2 += 4, phi_t0 += WREG(40)) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = + WREG(41) + phi_t0 + 0x40; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + WREG(42); + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1 - 3; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - WREG(43); + } + + phi_t0 = pthis->windowPosX - 14; + temp_t1 -= 0x16; + + for (phi_a1 = 0; phi_a1 < 4; phi_a1++, phi_t2 += 4) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + D_80812820[phi_a1]; + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - D_80812828[phi_a1]; + phi_t0 += D_80812818[phi_a1]; + } + + pthis->windowContentVtx[phi_t2 - 15].v.tc[0] = pthis->windowContentVtx[phi_t2 - 13].v.tc[0] = 0x400; + + phi_t0 = pthis->windowPosX + 63; + temp_t1 += 4; + + for (phi_a1 = 0; phi_a1 < 20; phi_a1++, phi_t2 += 4, phi_t0 += 9) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0xA; + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0xA; + + if (phi_a1 == 9) { + phi_t0 = pthis->windowPosX + 54; + temp_t1 -= 8; + } + } + + phi_t0 = pthis->windowPosX + 4; + temp_t1 -= 0xA; + + for (phi_a1 = 0; phi_a1 < 10; phi_a1++, phi_t2 += 4, phi_t0 += 0x10) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0x10; + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = temp_t1; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x10; + } + } else { + phi_t2 += 0xA8; + } + } + + phi_t0 = pthis->windowPosX - 6; + phi_ra = -0xC; + + for (phi_t5 = 0; phi_t5 < 2; phi_t5++, phi_t2 += 4, phi_ra -= 0x10) { + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0x40; + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = + pthis->buttonYOffsets[phi_t5 + 3] + phi_ra; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x10; + pthis->windowContentVtx[phi_t2 + 1].v.tc[0] = pthis->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x800; + } + + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = phi_t0; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0x40; + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = + pthis->buttonYOffsets[5] - 0x34; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x10; + pthis->windowContentVtx[phi_t2 + 1].v.tc[0] = pthis->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x800; + + phi_t2 += 4; + + if (((pthis->menuMode == FS_MENU_MODE_CONFIG) && (pthis->configMode >= CM_MAIN_MENU)) || + ((pthis->menuMode == FS_MENU_MODE_SELECT) && (pthis->selectMode == SM_CONFIRM_FILE))) { + if (pthis->menuMode == FS_MENU_MODE_CONFIG) { + if ((pthis->configMode == CM_SELECT_COPY_SOURCE) || (pthis->configMode == CM_SELECT_COPY_DEST) || + (pthis->configMode == CM_ERASE_SELECT)) { + phi_t5 = D_8081283C[pthis->buttonIndex]; + } else if ((pthis->configMode == CM_ERASE_CONFIRM) || (pthis->configMode == CM_COPY_CONFIRM)) { + phi_t5 = D_80812844[pthis->buttonIndex]; + } else { + phi_t5 = D_80812830[pthis->buttonIndex]; + } + } else { + phi_t5 = D_80812848[pthis->confirmButtonIndex]; + } + + pthis->windowContentVtx[phi_t2].v.ob[0] = pthis->windowContentVtx[phi_t2 + 2].v.ob[0] = pthis->windowPosX - 0xA; + pthis->windowContentVtx[phi_t2 + 1].v.ob[0] = pthis->windowContentVtx[phi_t2 + 3].v.ob[0] = + pthis->windowContentVtx[phi_t2].v.ob[0] + 0x48; + pthis->windowContentVtx[phi_t2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 1].v.ob[1] = + pthis->windowContentVtx[phi_t5].v.ob[1] + 4; + pthis->windowContentVtx[phi_t2 + 2].v.ob[1] = pthis->windowContentVtx[phi_t2 + 3].v.ob[1] = + pthis->windowContentVtx[phi_t2].v.ob[1] - 0x18; + pthis->windowContentVtx[phi_t2 + 1].v.tc[0] = pthis->windowContentVtx[phi_t2 + 3].v.tc[0] = 0x900; + pthis->windowContentVtx[phi_t2 + 2].v.tc[1] = pthis->windowContentVtx[phi_t2 + 3].v.tc[1] = 0x300; + } + + pthis->windowContentVtx[phi_t2 + 4].v.ob[0] = pthis->windowContentVtx[phi_t2 + 6].v.ob[0] = pthis->windowPosX + 0x3A; + pthis->windowContentVtx[phi_t2 + 5].v.ob[0] = pthis->windowContentVtx[phi_t2 + 7].v.ob[0] = + pthis->windowContentVtx[phi_t2 + 4].v.ob[0] + 0x80; + pthis->windowContentVtx[phi_t2 + 4].v.ob[1] = pthis->windowContentVtx[phi_t2 + 5].v.ob[1] = + pthis->windowContentVtx[D_80812830[pthis->warningButtonIndex]].v.ob[1]; + pthis->windowContentVtx[phi_t2 + 6].v.ob[1] = pthis->windowContentVtx[phi_t2 + 7].v.ob[1] = + pthis->windowContentVtx[phi_t2 + 4].v.ob[1] - 0x10; + pthis->windowContentVtx[phi_t2 + 5].v.tc[0] = pthis->windowContentVtx[phi_t2 + 7].v.tc[0] = 0x1000; +} + +static u16 D_8081284C[] = { 0x007C, 0x0124, 0x01CC }; + +static void* sQuestItemTextures[] = { + gFileSelKokiriEmeraldTex, gFileSelGoronRubyTex, gFileSelZoraSapphireTex, + gFileSelForestMedallionTex, gFileSelFireMedallionTex, gFileSelWaterMedallionTex, + gFileSelSpiritMedallionTex, gFileSelShadowMedallionTex, gFileSelLightMedallionTex, +}; + +static s16 sQuestItemRed[] = { 255, 255, 255, 0, 255, 0, 255, 200, 200 }; +static s16 sQuestItemGreen[] = { 255, 255, 255, 255, 60, 100, 130, 50, 200 }; +static s16 sQuestItemBlue[] = { 255, 255, 255, 0, 0, 255, 0, 255, 0 }; +static s16 sQuestItemFlags[] = { 0x0012, 0x0013, 0x0014, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005 }; +static s16 sNamePrimColors[2][3] = { { 255, 255, 255 }, { 100, 100, 100 } }; +static void* sHeartTextures[] = { gHeartFullTex, gDefenseHeartFullTex }; +static s16 sHeartPrimColors[2][3] = { { 255, 70, 50 }, { 200, 0, 0 } }; +static s16 sHeartEnvColors[2][3] = { { 50, 40, 60 }, { 255, 255, 255 } }; + +void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + Font* sp54 = &pthis->font; + s32 heartType; + s16 i; + s16 vtxOffset; + s16 j; + s16 deathCountSplit[3]; + + if (1) {} + + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 1709); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + // draw file name + if (pthis->nameAlpha[fileIndex] != 0) { + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[D_8081284C[fileIndex]], 32, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sNamePrimColors[isActive][0], sNamePrimColors[isActive][1], + sNamePrimColors[isActive][2], pthis->nameAlpha[fileIndex]); + + for (i = 0, vtxOffset = 0; vtxOffset < 0x20; i++, vtxOffset += 4) { + FileChoose_DrawCharacter(pthis->state.gfxCtx, + sp54->fontBuf + pthis->fileNames[fileIndex][i] * FONT_CHAR_TEX_SIZE, vtxOffset); + } + } + + if ((fileIndex == pthis->selectedFileIndex) || (fileIndex == pthis->copyDestFileIndex)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, + PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 255, 255, 255, pthis->fileInfoAlpha[fileIndex]); + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[D_8081284C[fileIndex]] + 0x24, 12, 0); + + FileChoose_SplitNumber(pthis->deaths[fileIndex], &deathCountSplit[0], &deathCountSplit[1], &deathCountSplit[2]); + + // draw death count + for (i = 0, vtxOffset = 0; i < 3; i++, vtxOffset += 4) { + FileChoose_DrawCharacter(pthis->state.gfxCtx, sp54->fontBuf + deathCountSplit[i] * FONT_CHAR_TEX_SIZE, + vtxOffset); + } + + gDPPipeSync(POLY_OPA_DISP++); + + heartType = (pthis->defense[fileIndex] == 0) ? 0 : 1; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sHeartPrimColors[heartType][0], sHeartPrimColors[heartType][1], + sHeartPrimColors[heartType][2], pthis->fileInfoAlpha[fileIndex]); + gDPSetEnvColor(POLY_OPA_DISP++, sHeartEnvColors[heartType][0], sHeartEnvColors[heartType][1], + sHeartEnvColors[heartType][2], 255); + + i = pthis->healthCapacities[fileIndex] / 0x10; + + // draw hearts + for (vtxOffset = 0, j = 0; j < i; j++, vtxOffset += 4) { + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x30, 4, 0); + + POLY_OPA_DISP = FileChoose_QuadTextureIA8(POLY_OPA_DISP, sHeartTextures[heartType], 0x10, 0x10, 0); + } + + gDPPipeSync(POLY_OPA_DISP++); + + // draw quest items + for (vtxOffset = 0, j = 0; j < 9; j++, vtxOffset += 4) { + if (pthis->questItems[fileIndex] & gBitFlags[sQuestItemFlags[j]]) { + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x80, 4, 0); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sQuestItemRed[j], sQuestItemGreen[j], sQuestItemBlue[j], + pthis->fileInfoAlpha[fileIndex]); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + if (j < 3) { + gDPLoadTextureBlock(POLY_OPA_DISP++, sQuestItemTextures[j], G_IM_FMT_RGBA, G_IM_SIZ_32b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + } else { + POLY_OPA_DISP = FileChoose_QuadTextureIA8(POLY_OPA_DISP, sQuestItemTextures[j], 0x10, 0x10, 0); + } + } + } + } + + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 1797); +} + +static void* sFileInfoBoxTextures[] = { + gFileSelFileInfoBox1Tex, gFileSelFileInfoBox2Tex, gFileSelFileInfoBox3Tex, + gFileSelFileInfoBox4Tex, gFileSelFileInfoBox5Tex, +}; + +static void* sTitleLabels[3][9] = { + { gFileSelPleaseSelectAFileENGTex, gFileSelOpenThisFileENGTex, gFileSelCopyWhichFileENGTex, + gFileSelCopyToWhichFileENGTex, gFileSelAreYouSureENGTex, gFileSelFileCopiedENGTex, gFileSelEraseWhichFileENGTex, + gFileSelAreYouSure2ENGTex, gFileSelFileErasedENGTex }, + { gFileSelPleaseSelectAFileGERTex, gFileSelOpenThisFileGERTex, gFileSelWhichFile1GERTex, + gFileSelCopyToWhichFileGERTex, gFileSelAreYouSureGERTex, gFileSelFileCopiedGERTex, gFileSelWhichFile2GERTex, + gFileSelAreYouSure2GERTex, gFileSelFileErasedGERTex }, + { gFileSelPleaseSelectAFileFRATex, gFileSelOpenThisFileFRATex, gFileSelCopyWhichFileFRATex, + gFileSelCopyToWhichFileFRATex, gFileSelAreYouSureFRATex, gFileSelFileCopiedFRATex, gFileSelEraseWhichFileFRATex, + gFileSelAreYouSure2FRATex, gFileSelFileErasedFRATex } +}; + +static void* sWarningLabels[3][5] = { + { gFileSelNoFileToCopyENGTex, gFileSelNoFileToEraseENGTex, gFileSelNoEmptyFileENGTex, gFileSelFileEmptyENGTex, + gFileSelFileInUseENGTex }, + { gFileSelNoFileToCopyGERTex, gFileSelNoFileToEraseGERTex, gFileSelNoEmptyFileGERTex, gFileSelFileEmptyGERTex, + gFileSelFileInUseGERTex }, + { gFileSelNoFileToCopyFRATex, gFileSelNoFileToEraseFRATex, gFileSelNoEmptyFileFRATex, gFileSelFileEmptyFRATex, + gFileSelFileInUseFRATex }, +}; + +static void* sFileButtonTextures[3][3] = { + { gFileSelFile1ButtonENGTex, gFileSelFile2ButtonENGTex, gFileSelFile3ButtonENGTex }, + { gFileSelFile1ButtonGERTex, gFileSelFile2ButtonGERTex, gFileSelFile3ButtonGERTex }, + { gFileSelFile1ButtonFRATex, gFileSelFile2ButtonFRATex, gFileSelFile3ButtonFRATex }, +}; + +static void* sActionButtonTextures[3][4] = { + { gFileSelCopyButtonENGTex, gFileSelEraseButtonENGTex, gFileSelYesButtonENGTex, gFileSelQuitButtonENGTex }, + { gFileSelCopyButtonGERTex, gFileSelEraseButtonGERTex, gFileSelYesButtonGERTex, gFileSelQuitButtonGERTex }, + { gFileSelCopyButtonFRATex, gFileSelEraseButtonFRATex, gFileSelYesButtonFRATex, gFileSelQuitButtonFRATex }, +}; + +static void* sOptionsButtonTextures[] = { + gFileSelOptionsButtonENGTex, + gFileSelOptionsButtonGERTex, + gFileSelOptionsButtonENGTex, +}; + +/** + * Draw most window contents including buttons, labels, and icons. + * Does not include anything from the keyboard and settings windows. + */ +void FileChoose_DrawWindowContents(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 fileIndex; + s16 temp; + s16 i; + s16 quadVtxIndex; + s16 isActive; + s16 pad; + + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 1940); + + // draw title label + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->titleAlpha[0]); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + gSPVertex(POLY_OPA_DISP++, pthis->windowContentVtx, 4, 0); + gDPLoadTextureBlock(POLY_OPA_DISP++, sTitleLabels[gSaveContext.language][pthis->titleLabel], G_IM_FMT_IA, + G_IM_SIZ_8b, 128, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + // draw next title label + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->titleAlpha[1]); + gDPLoadTextureBlock(POLY_OPA_DISP++, sTitleLabels[gSaveContext.language][pthis->nextTitleLabel], G_IM_FMT_IA, + G_IM_SIZ_8b, 128, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + temp = 4; + + gDPPipeSync(POLY_OPA_DISP++); + + // draw file info box (large box when a file is selected) + for (fileIndex = 0; fileIndex < 3; fileIndex++, temp += 20) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->fileInfoAlpha[fileIndex]); + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[temp], 20, 0); + + for (quadVtxIndex = 0, i = 0; i < 5; i++, quadVtxIndex += 4) { + gDPLoadTextureBlock(POLY_OPA_DISP++, sFileInfoBoxTextures[i], G_IM_FMT_IA, G_IM_SIZ_16b, + sFileInfoBoxPartWidths[i], 56, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, quadVtxIndex, quadVtxIndex + 2, quadVtxIndex + 3, quadVtxIndex + 1, 0); + } + } + + for (i = 0; i < 3; i++, temp += 20) { + // draw file button + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[temp], 20, 0); + + isActive = ((pthis->n64ddFlag == pthis->n64ddFlags[i]) || (pthis->nameBoxAlpha[i] == 0)) ? 0 : 1; + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], + sWindowContentColors[isActive][2], pthis->fileButtonAlpha[i]); + gDPLoadTextureBlock(POLY_OPA_DISP++, sFileButtonTextures[gSaveContext.language][i], G_IM_FMT_IA, G_IM_SIZ_16b, + 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + // draw file name box + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], + sWindowContentColors[isActive][2], pthis->nameBoxAlpha[i]); + gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelNameBoxTex, G_IM_FMT_IA, G_IM_SIZ_16b, 108, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 4, 6, 7, 5, 0); + + // draw disk label for 64DD + if (pthis->n64ddFlags[i]) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], + sWindowContentColors[isActive][2], pthis->nameAlpha[i]); + gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelDISKButtonTex, G_IM_FMT_IA, G_IM_SIZ_16b, 44, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 8, 10, 11, 9, 0); + } + + // draw connectors + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], + sWindowContentColors[isActive][2], pthis->connectorAlpha[i]); + gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelConnectorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 24, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 12, 14, 15, 13, 0); + + if (pthis->n64ddFlags[i]) { + gSP1Quadrangle(POLY_OPA_DISP++, 16, 18, 19, 17, 0); + } + } + + // draw file info + for (fileIndex = 0; fileIndex < 3; fileIndex++) { + isActive = ((pthis->n64ddFlag == pthis->n64ddFlags[fileIndex]) || (pthis->nameBoxAlpha[fileIndex] == 0)) ? 0 : 1; + FileChoose_DrawFileInfo(&pthis->state, fileIndex, isActive); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + gSPVertex(POLY_OPA_DISP++, &pthis->windowContentVtx[0x274], 20, 0); + + // draw primary action buttons (copy/erase) + for (quadVtxIndex = 0, i = 0; i < 2; i++, quadVtxIndex += 4) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->actionButtonAlpha[i]); + gDPLoadTextureBlock(POLY_OPA_DISP++, sActionButtonTextures[gSaveContext.language][i], G_IM_FMT_IA, G_IM_SIZ_16b, + 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, quadVtxIndex, quadVtxIndex + 2, quadVtxIndex + 3, quadVtxIndex + 1, 0); + } + + gDPPipeSync(POLY_OPA_DISP++); + + // draw confirm buttons (yes/quit) + for (quadVtxIndex = 0, i = 0; i < 2; i++, quadVtxIndex += 4) { + temp = pthis->confirmButtonTexIndices[i]; + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->confirmButtonAlpha[i]); + gDPLoadTextureBlock(POLY_OPA_DISP++, sActionButtonTextures[gSaveContext.language][temp], G_IM_FMT_IA, + G_IM_SIZ_16b, 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, quadVtxIndex, quadVtxIndex + 2, quadVtxIndex + 3, quadVtxIndex + 1, 0); + } + + // draw options button + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->optionButtonAlpha); + gDPLoadTextureBlock(POLY_OPA_DISP++, sOptionsButtonTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_16b, 64, + 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 8, 10, 11, 9, 0); + + // draw highlight over currently selected button + if (((pthis->menuMode == FS_MENU_MODE_CONFIG) && + ((pthis->configMode == CM_MAIN_MENU) || (pthis->configMode == CM_SELECT_COPY_SOURCE) || + (pthis->configMode == CM_SELECT_COPY_DEST) || (pthis->configMode == CM_COPY_CONFIRM) || + (pthis->configMode == CM_ERASE_SELECT) || (pthis->configMode == CM_ERASE_CONFIRM))) || + ((pthis->menuMode == FS_MENU_MODE_SELECT) && (pthis->selectMode == SM_CONFIRM_FILE))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, + PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->highlightColor[0], pthis->highlightColor[1], + pthis->highlightColor[2], pthis->highlightColor[3]); + gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelBigButtonHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 72, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 12, 14, 15, 13, 0); + } + + // draw warning labels + if (pthis->warningLabel > FS_WARNING_NONE) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->emptyFileTextAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + gDPLoadTextureBlock(POLY_OPA_DISP++, sWarningLabels[gSaveContext.language][pthis->warningLabel], G_IM_FMT_IA, + G_IM_SIZ_8b, 128, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSP1Quadrangle(POLY_OPA_DISP++, 16, 18, 19, 17, 0); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); + + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 2198); +} + +void FileChoose_ConfigModeDraw(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + f32 eyeX; + f32 eyeY; + f32 eyeZ; + + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 2218); + gDPPipeSync(POLY_OPA_DISP++); + + eyeX = 1000.0f * Math_CosS(ZREG(11)) - 1000.0f * Math_SinS(ZREG(11)); + eyeY = ZREG(13); + eyeZ = 1000.0f * Math_SinS(ZREG(11)) + 1000.0f * Math_CosS(ZREG(11)); + + FileChoose_SetView(pthis, eyeX, eyeY, eyeZ); + SkyboxDraw_Draw(&pthis->skyboxCtx, pthis->state.gfxCtx, 1, pthis->envCtx.skyboxBlend, eyeX, eyeY, eyeZ); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); + ZREG(11) += ZREG(10); + Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &pthis->envCtx, &pthis->skyboxCtx); + gDPPipeSync(POLY_OPA_DISP++); + func_800949A8(pthis->state.gfxCtx); + FileChoose_SetView(pthis, 0.0f, 0.0f, 64.0f); + FileChoose_SetWindowVtx(&pthis->state); + FileChoose_SetWindowContentVtx(&pthis->state); + + if ((pthis->configMode != CM_NAME_ENTRY) && (pthis->configMode != CM_START_NAME_ENTRY)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->windowAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + + if (pthis->windowRot != 0) { + Matrix_RotateX(pthis->windowRot / 100.0f, MTXMODE_APPLY); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_choose.c", 2282), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[0], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[32], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[64], 16, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); + + gDPPipeSync(POLY_OPA_DISP++); + + FileChoose_DrawWindowContents(&pthis->state); + } + + // draw name entry menu + if ((pthis->configMode >= CM_ROTATE_TO_NAME_ENTRY) && (pthis->configMode <= CM_NAME_ENTRY_TO_MAIN)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->windowAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX((pthis->windowRot - 314.0f) / 100.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_choose.c", 2316), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[0], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[32], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[64], 16, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); + + gDPPipeSync(POLY_OPA_DISP++); + + FileChoose_DrawNameEntry(&pthis->state); + } + + // draw options menu + if ((pthis->configMode >= CM_MAIN_TO_OPTIONS) && (pthis->configMode <= CM_OPTIONS_TO_MAIN)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->windowAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX((pthis->windowRot - 314.0f) / 100.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_choose.c", 2337), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[0], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[32], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[64], 16, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); + + gDPPipeSync(POLY_OPA_DISP++); + + FileChoose_DrawOptions(&pthis->state); + } + + gDPPipeSync(POLY_OPA_DISP++); + FileChoose_SetView(pthis, 0.0f, 0.0f, 64.0f); + + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 2352); +} + +/** + * Fade out the main menu elements to transition to select mode. + * Update function for `SM_FADE_MAIN_TO_SELECT` + */ +void FileChoose_FadeMainToSelect(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + + for (i = 0; i < 3; i++) { + if (i != pthis->buttonIndex) { + pthis->fileButtonAlpha[i] -= 25; + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->optionButtonAlpha = pthis->fileButtonAlpha[i]; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameAlpha[i] = pthis->nameBoxAlpha[i] = pthis->fileButtonAlpha[i]; + pthis->connectorAlpha[i] -= 31; + } + } + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->actionTimer = 8; + pthis->selectMode++; + pthis->confirmButtonIndex = FS_BTN_CONFIRM_YES; + } +} + +/** + * Moves the selected file to the top of the window. + * Update function for `SM_MOVE_FILE_TO_TOP` + */ +void FileChoose_MoveSelectedFileToTop(GameState* thisx) { + static s16 fileYOffsets[] = { 0, 16, 32 }; // amount to move by to reach the top of the screen + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 yStep; + + yStep = ABS(pthis->buttonYOffsets[pthis->buttonIndex] - fileYOffsets[pthis->buttonIndex]) / pthis->actionTimer; + pthis->buttonYOffsets[pthis->buttonIndex] += yStep; + pthis->actionTimer--; + + if ((pthis->actionTimer == 0) || (pthis->buttonYOffsets[pthis->buttonIndex] == fileYOffsets[pthis->buttonIndex])) { + pthis->buttonYOffsets[FS_BTN_SELECT_YES] = pthis->buttonYOffsets[FS_BTN_SELECT_QUIT] = -24; + pthis->actionTimer = 8; + pthis->selectMode++; + } +} + +/** + * Fade in the file info for the selected file. + * Update function for `SM_FADE_IN_FILE_INFO` + */ +void FileChoose_FadeInFileInfo(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->fileInfoAlpha[pthis->buttonIndex] += 25; + pthis->nameBoxAlpha[pthis->buttonIndex] -= 50; + + if (pthis->nameBoxAlpha[pthis->buttonIndex] <= 0) { + pthis->nameBoxAlpha[pthis->buttonIndex] = 0; + } + + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->fileInfoAlpha[pthis->buttonIndex] = 200; + pthis->actionTimer = 8; + pthis->selectMode++; + } + + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] = pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = + pthis->fileInfoAlpha[pthis->buttonIndex]; +} + +/** + * Update the cursor and handle the option that the player picks for confirming the selected file. + * Update function for `SM_CONFIRM_FILE` + */ +void FileChoose_ConfirmFile(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + Input* input = &pthis->state.input[0]; + + if (CHECK_BTN_ALL(input->press.button, BTN_START) || (CHECK_BTN_ALL(input->press.button, BTN_A))) { + if (pthis->confirmButtonIndex == FS_BTN_CONFIRM_YES) { + func_800AA000(300.0f, 180, 20, 100); + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->selectMode = SM_FADE_OUT; + func_800F6964(0xF); + } else { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->selectMode++; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->selectMode++; + } else if (ABS(pthis->stickRelY) >= 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->confirmButtonIndex ^= 1; + } +} + +/** + * Fade out the file info for the selected file before returning to the main menu. + * Update function for `SM_FADE_OUT_FILE_INFO` + */ +void FileChoose_FadeOutFileInfo(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->fileInfoAlpha[pthis->buttonIndex] -= 25; + pthis->nameBoxAlpha[pthis->buttonIndex] += 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->buttonYOffsets[FS_BTN_SELECT_YES] = pthis->buttonYOffsets[FS_BTN_SELECT_QUIT] = 0; + pthis->nameBoxAlpha[pthis->buttonIndex] = 200; + pthis->fileInfoAlpha[pthis->buttonIndex] = 0; + pthis->nextTitleLabel = FS_TITLE_SELECT_FILE; + pthis->actionTimer = 8; + pthis->selectMode++; + } + + pthis->confirmButtonAlpha[0] = pthis->confirmButtonAlpha[1] = pthis->fileInfoAlpha[pthis->buttonIndex]; +} + +/** + * Move the selected file back to the slot position then go to config mode for the main menu. + * Update function for `SM_MOVE_FILE_TO_SLOT` + */ +void FileChoose_MoveSelectedFileToSlot(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 yStep; + s16 i; + + yStep = ABS(pthis->buttonYOffsets[pthis->buttonIndex]) / pthis->actionTimer; + pthis->buttonYOffsets[pthis->buttonIndex] -= yStep; + + if (pthis->buttonYOffsets[pthis->buttonIndex] <= 0) { + pthis->buttonYOffsets[pthis->buttonIndex] = 0; + } + + for (i = 0; i < 3; i++) { + if (i != pthis->buttonIndex) { + pthis->fileButtonAlpha[i] += 25; + + if (pthis->fileButtonAlpha[i] >= 200) { + pthis->fileButtonAlpha[i] = 200; + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->optionButtonAlpha = pthis->fileButtonAlpha[i]; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + pthis->connectorAlpha[i] += 31; + } + } + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->actionTimer = 8; + pthis->menuMode = FS_MENU_MODE_CONFIG; + pthis->configMode = CM_MAIN_MENU; + pthis->nextConfigMode = CM_MAIN_MENU; + pthis->selectMode = SM_FADE_MAIN_TO_SELECT; + } +} + +/** + * Fill the screen with black to fade out. + * Update function for `SM_FADE_OUT` + */ +void FileChoose_FadeOut(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + sScreenFillAlpha += VREG(10); + + if (sScreenFillAlpha >= 255) { + sScreenFillAlpha = 255; + pthis->selectMode++; + } +} + +/** + * Load the save for the appropriate file and start the game. + * Note: On Debug ROM, File 1 will go to Map Select. + * Update function for `SM_LOAD_GAME` + */ +void FileChoose_LoadGame(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + u16 swordEquipMask; + s32 pad; + + if (pthis->buttonIndex == FS_BTN_SELECT_FILE_1) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSaveContext.fileNum = pthis->buttonIndex; + Sram_OpenSave(&pthis->sramCtx); + gSaveContext.gameMode = 0; + SET_NEXT_GAMESTATE(&pthis->state, Select_Init, SelectContext); + pthis->state.running = false; + } else { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSaveContext.fileNum = pthis->buttonIndex; + Sram_OpenSave(&pthis->sramCtx); + gSaveContext.gameMode = 0; + SET_NEXT_GAMESTATE(&pthis->state, Gameplay_Init, GlobalContext); + pthis->state.running = false; + } + + gSaveContext.respawn[0].entranceIndex = -1; + gSaveContext.respawnFlag = 0; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.natureAmbienceId = 0xFF; + gSaveContext.showTitleCard = true; + gSaveContext.dogParams = 0; + gSaveContext.timer1State = 0; + gSaveContext.timer2State = 0; + gSaveContext.eventInf[0] = 0; + gSaveContext.eventInf[1] = 0; + gSaveContext.eventInf[2] = 0; + gSaveContext.eventInf[3] = 0; + gSaveContext.unk_13EE = 0x32; + gSaveContext.nayrusLoveTimer = 0; + gSaveContext.healthAccumulator = 0; + gSaveContext.unk_13F0 = 0; + gSaveContext.unk_13F2 = 0; + gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; + gSaveContext.skyboxTime = 0; + gSaveContext.nextTransition = 0xFF; + gSaveContext.nextCutsceneIndex = 0xFFEF; + gSaveContext.cutsceneTrigger = 0; + gSaveContext.chamberCutsceneNum = 0; + gSaveContext.nextDayTime = 0xFFFF; + gSaveContext.unk_13C3 = 0; + + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + + gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = + gSaveContext.unk_13F4 = 0; + + gSaveContext.unk_13F6 = gSaveContext.magic; + gSaveContext.magic = 0; + gSaveContext.magicLevel = gSaveContext.magic; + + if (1) {} + + osSyncPrintf(VT_FGCOL(GREEN)); + osSyncPrintf("Z_MAGIC_NOW_NOW=%d MAGIC_NOW=%d\n", ((void)0, gSaveContext.unk_13F6), gSaveContext.magic); + osSyncPrintf(VT_RST); + + gSaveContext.naviTimer = 0; + + if ((gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI) && + (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_MASTER) && + (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_BGS) && + (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { + + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + swordEquipMask = gEquipMasks[EQUIP_SWORD] & gSaveContext.equips.equipment; + gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_SWORD]; + if(swordEquipMask != 0) { + gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << gEquipShifts[EQUIP_SWORD]); + } + } +} + +static void (*gSelectModeUpdateFuncs[])(GameState*) = { + FileChoose_FadeMainToSelect, FileChoose_MoveSelectedFileToTop, FileChoose_FadeInFileInfo, FileChoose_ConfirmFile, + FileChoose_FadeOutFileInfo, FileChoose_MoveSelectedFileToSlot, FileChoose_FadeOut, FileChoose_LoadGame, +}; + +void FileChoose_SelectModeUpdate(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + gSelectModeUpdateFuncs[pthis->selectMode](&pthis->state); +} + +void FileChoose_SelectModeDraw(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + f32 eyeX; + f32 eyeY; + f32 eyeZ; + + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 2753); + + gDPPipeSync(POLY_OPA_DISP++); + + eyeX = 1000.0f * Math_CosS(ZREG(11)) - 1000.0f * Math_SinS(ZREG(11)); + eyeY = ZREG(13); + eyeZ = 1000.0f * Math_SinS(ZREG(11)) + 1000.0f * Math_CosS(ZREG(11)); + + FileChoose_SetView(pthis, eyeX, eyeY, eyeZ); + SkyboxDraw_Draw(&pthis->skyboxCtx, pthis->state.gfxCtx, 1, pthis->envCtx.skyboxBlend, eyeX, eyeY, eyeZ); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); + ZREG(11) += ZREG(10); + Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &pthis->envCtx, &pthis->skyboxCtx); + gDPPipeSync(POLY_OPA_DISP++); + func_800949A8(pthis->state.gfxCtx); + FileChoose_SetView(pthis, 0.0f, 0.0f, 64.0f); + FileChoose_SetWindowVtx(&pthis->state); + FileChoose_SetWindowContentVtx(&pthis->state); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->windowAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(pthis->windowRot / 100.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_choose.c", 2810), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[0], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[32], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); + + gSPVertex(POLY_OPA_DISP++, &pthis->windowVtx[64], 16, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); + + FileChoose_DrawWindowContents(&pthis->state); + gDPPipeSync(POLY_OPA_DISP++); + FileChoose_SetView(pthis, 0.0f, 0.0f, 64.0f); + + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 2834); +} + +static void (*gFileSelectDrawFuncs[])(GameState*) = { + FileChoose_InitModeDraw, + FileChoose_ConfigModeDraw, + FileChoose_SelectModeDraw, +}; + +static void (*gFileSelectUpdateFuncs[])(GameState*) = { + FileChoose_InitModeUpdate, + FileChoose_ConfigModeUpdate, + FileChoose_SelectModeUpdate, +}; + +void FileChoose_Main(GameState* thisx) { + static void* controlsTextures[] = { + gFileSelControlsENGTex, + gFileSelControlsGERTex, + gFileSelControlsFRATex, + }; + FileChooseContext* pthis = (FileChooseContext*)thisx; + Input* input = &pthis->state.input[0]; + + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 2898); + + pthis->n64ddFlag = 0; + + gSPSegment(POLY_OPA_DISP++, 0x00, NULL); + gSPSegment(POLY_OPA_DISP++, 0x01, pthis->staticSegment); + gSPSegment(POLY_OPA_DISP++, 0x02, pthis->parameterSegment); + + Gfx_ClearDisplay(pthis->state.gfxCtx, 0, 0, 0); + + pthis->stickRelX = input->rel.stick_x; + pthis->stickRelY = input->rel.stick_y; + + if (pthis->stickRelX < -30) { + if (pthis->stickXDir == -1) { + pthis->inputTimerX--; + if (pthis->inputTimerX < 0) { + pthis->inputTimerX = 2; + } else { + pthis->stickRelX = 0; + } + } else { + pthis->inputTimerX = 10; + pthis->stickXDir = -1; + } + } else if (pthis->stickRelX > 30) { + if (pthis->stickXDir == 1) { + pthis->inputTimerX--; + if (pthis->inputTimerX < 0) { + pthis->inputTimerX = 2; + } else { + pthis->stickRelX = 0; + } + } else { + pthis->inputTimerX = 10; + pthis->stickXDir = 1; + } + } else { + pthis->stickXDir = 0; + } + + if (pthis->stickRelY < -30) { + if (pthis->stickYDir == -1) { + pthis->inputTimerY -= 1; + if (pthis->inputTimerY < 0) { + pthis->inputTimerY = 2; + } else { + pthis->stickRelY = 0; + } + } else { + pthis->inputTimerY = 10; + pthis->stickYDir = -1; + } + } else if (pthis->stickRelY > 30) { + if (pthis->stickYDir == 1) { + pthis->inputTimerY -= 1; + if (pthis->inputTimerY < 0) { + pthis->inputTimerY = 2; + } else { + pthis->stickRelY = 0; + } + } else { + pthis->inputTimerY = 10; + pthis->stickYDir = 1; + } + } else { + pthis->stickYDir = 0; + } + + pthis->emptyFileTextAlpha = 0; + + FileChoose_PulsateCursor(&pthis->state); + gFileSelectUpdateFuncs[pthis->menuMode](&pthis->state); + gFileSelectDrawFuncs[pthis->menuMode](&pthis->state); + + // do not draw controls text in the options menu + if ((pthis->configMode <= CM_NAME_ENTRY_TO_MAIN) || (pthis->configMode >= CM_UNUSED_DELAY)) { + func_800944C4(pthis->state.gfxCtx); + + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 255, pthis->controlsAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + gDPLoadTextureBlock(POLY_OPA_DISP++, controlsTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_8b, 144, 16, + 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(POLY_OPA_DISP++, 0x0168, 0x0330, 0x03A8, 0x0370, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400); + } + + gDPPipeSync(POLY_OPA_DISP++); + gSPDisplayList(POLY_OPA_DISP++, sScreenFillSetupDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, sScreenFillAlpha); + gDPFillRectangle(POLY_OPA_DISP++, 0, 0, gScreenWidth - 1, gScreenHeight - 1); + + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_choose.c", 3035); +} + +void FileChoose_InitContext(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + EnvironmentContext* envCtx = &pthis->envCtx; + SramContext* sramCtx = &pthis->sramCtx; + + Sram_Alloc(&pthis->state, sramCtx); + + ZREG(7) = 32; + ZREG(8) = 22; + ZREG(9) = 20; + ZREG(10) = -10; + ZREG(11) = 0; + ZREG(12) = 1000; + ZREG(13) = -700; + ZREG(14) = 164; + ZREG(15) = 104; + ZREG(16) = 160; + ZREG(17) = 100; + ZREG(18) = 162; + ZREG(19) = 152; + ZREG(20) = 214; + + XREG(13) = 580; + XREG(14) = 400; + XREG(35) = 20; + XREG(36) = 20; + XREG(37) = 20; + XREG(43) = 8; + XREG(44) = -78; + XREG(45) = 0; + XREG(46) = 0; + XREG(47) = 0; + XREG(48) = 0; + XREG(49) = 3; + XREG(50) = 8; + XREG(51) = 8; + XREG(52) = 10; + XREG(73) = 0; + + VREG(0) = 14; + VREG(1) = 5; + VREG(2) = 4; + VREG(4) = 1; + VREG(5) = 6; + VREG(6) = 2; + VREG(7) = 6; + VREG(8) = 80; + + sScreenFillAlpha = 255; + + VREG(10) = 10; + VREG(11) = 30; + VREG(12) = -100; + VREG(13) = -85; + VREG(14) = 4; + VREG(16) = 25; + VREG(17) = 1; + VREG(18) = 1; + VREG(20) = 92; + VREG(21) = 171; + VREG(22) = 11; + VREG(23) = 10; + VREG(24) = 26; + VREG(25) = 2; + VREG(26) = 1; + VREG(27) = 0; + VREG(28) = 0; + VREG(29) = 160; + VREG(30) = 64; + VREG(31) = 154; + VREG(32) = 152; + VREG(33) = 106; + + WREG(38) = 16; + WREG(39) = 9; + WREG(40) = 10; + WREG(41) = 14; + WREG(42) = 11; + WREG(43) = 12; + + pthis->menuMode = FS_MENU_MODE_INIT; + + pthis->buttonIndex = pthis->selectMode = pthis->selectedFileIndex = pthis->copyDestFileIndex = + pthis->confirmButtonIndex = 0; + + pthis->confirmButtonTexIndices[0] = 2; + pthis->confirmButtonTexIndices[1] = 3; + pthis->titleLabel = FS_TITLE_SELECT_FILE; + pthis->nextTitleLabel = FS_TITLE_OPEN_FILE; + pthis->highlightPulseDir = 1; + pthis->unk_1CAAC = 0xC; + pthis->highlightColor[0] = 155; + pthis->highlightColor[1] = 255; + pthis->highlightColor[2] = 255; + pthis->highlightColor[3] = 70; + pthis->configMode = CM_FADE_IN_START; + pthis->windowRot = 0.0f; + pthis->stickXDir = pthis->inputTimerX = 0; + pthis->stickYDir = pthis->inputTimerY = 0; + pthis->kbdX = pthis->kbdY = pthis->charIndex = 0; + pthis->kbdButton = FS_KBD_BTN_NONE; + + pthis->windowColor[0] = 100; + pthis->windowColor[1] = 150; + pthis->windowColor[2] = 255; + + pthis->windowAlpha = pthis->titleAlpha[0] = pthis->titleAlpha[1] = pthis->fileButtonAlpha[0] = + pthis->fileButtonAlpha[1] = pthis->fileButtonAlpha[2] = pthis->nameBoxAlpha[0] = pthis->nameBoxAlpha[1] = + pthis->nameBoxAlpha[2] = pthis->nameAlpha[0] = pthis->nameAlpha[1] = pthis->nameAlpha[2] = + pthis->connectorAlpha[0] = pthis->connectorAlpha[1] = pthis->connectorAlpha[2] = pthis->fileInfoAlpha[0] = + pthis->fileInfoAlpha[1] = pthis->fileInfoAlpha[2] = pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = + pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] = + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = pthis->optionButtonAlpha = + pthis->nameEntryBoxAlpha = pthis->controlsAlpha = pthis->emptyFileTextAlpha = 0; + + pthis->windowPosX = 6; + pthis->actionTimer = 8; + pthis->warningLabel = FS_WARNING_NONE; + + pthis->warningButtonIndex = pthis->buttonYOffsets[0] = pthis->buttonYOffsets[1] = pthis->buttonYOffsets[2] = + pthis->buttonYOffsets[3] = pthis->buttonYOffsets[4] = pthis->buttonYOffsets[5] = pthis->fileNamesY[0] = + pthis->fileNamesY[1] = pthis->fileNamesY[2] = 0; + + pthis->unk_1CAD6[0] = 0; + pthis->unk_1CAD6[1] = 3; + pthis->unk_1CAD6[2] = 6; + pthis->unk_1CAD6[3] = 8; + pthis->unk_1CAD6[4] = 10; + + ShrinkWindow_SetVal(0); + + gSaveContext.skyboxTime = 0; + gSaveContext.dayTime = 0; + + Skybox_Init(&pthis->state, &pthis->skyboxCtx, SKYBOX_NORMAL_SKY); + + gTimeIncrement = 10; + + envCtx->unk_19 = 0; + envCtx->unk_1A = 0; + envCtx->unk_21 = 0; + envCtx->unk_22 = 0; + envCtx->skyboxDmaState = SKYBOX_DMA_INACTIVE; + envCtx->skybox1Index = 99; + envCtx->skybox2Index = 99; + envCtx->unk_1F = 0; + envCtx->unk_20 = 0; + envCtx->unk_BD = 0; + envCtx->unk_17 = 2; + envCtx->skyboxDisabled = 0; + envCtx->skyboxBlend = 0; + envCtx->unk_84 = 0.0f; + envCtx->unk_88 = 0.0f; + + Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &pthis->envCtx, &pthis->skyboxCtx); + + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + + pthis->n64ddFlags[0] = pthis->n64ddFlags[1] = pthis->n64ddFlags[2] = pthis->defense[0] = pthis->defense[1] = + pthis->defense[2] = 0; + + SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); + + gSaveContext.language = sramCtx->readBuff[SRAM_HEADER_LANGUAGE]; + + if (gSaveContext.language >= LANGUAGE_MAX) { + sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_ENG; + } +} + +void FileChoose_Destroy(GameState* thisx) { +} + +void FileChoose_Init(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + u32 size = POINTER_SUB(_title_staticSegmentRomEnd, _title_staticSegmentRomStart); + s32 pad; + + SREG(30) = 1; + osSyncPrintf("SIZE=%x\n", size); + + pthis->staticSegment = (u8*)GameState_Alloc(&pthis->state, size, "../z_file_choose.c", 3392); + ASSERT(pthis->staticSegment != NULL, "pthis->staticSegment != NULL", "../z_file_choose.c", 3393); + //DmaMgr_SendRequest1(pthis->staticSegment, (u32)_title_staticSegmentRomStart, size, "../z_file_choose.c", 3394); + + size = POINTER_SUB(_parameter_staticSegmentRomEnd, _parameter_staticSegmentRomStart); + pthis->parameterSegment = (u8*)GameState_Alloc(&pthis->state, size, "../z_file_choose.c", 3398); + ASSERT(pthis->parameterSegment != NULL, "pthis->parameterSegment != NULL", "../z_file_choose.c", 3399); + //DmaMgr_SendRequest1(pthis->parameterSegment, (u32)_parameter_staticSegmentRomStart, size, "../z_file_choose.c", + // 3400); + + Matrix_Init(&pthis->state); + View_Init(&pthis->view, pthis->state.gfxCtx); + pthis->state.main = FileChoose_Main; + pthis->state.destroy = FileChoose_Destroy; + FileChoose_InitContext(&pthis->state); + Font_LoadOrderedFont(&pthis->font); + Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); + func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); +} diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c b/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c deleted file mode 100644 index 1def7280c..000000000 --- a/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c +++ /dev/null @@ -1,1082 +0,0 @@ -#define INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_FILE_CHOOSE_Z_FILE_COPY_ERASE_C -#include "actor_common.h" -#include "file_choose.h" -#include "z_file_choose.h" -#include "def/code_800A9F30.h" -#include "def/code_800F7260.h" -#include "def/z_common_data.h" -#include "def/z_sram.h" - -extern u16 gSramSlotOffsets[]; - -// when choosing a file to copy or erase, the 6 main menu buttons are placed at these offsets -static s16 sChooseFileYOffsets[] = { -48, -48, -48, -24, -24, 0 }; - -static s16 D_8081248C[3][3] = { - { 0, -48, -48 }, - { -64, 16, -48 }, - { -64, -64, 32 }, -}; - -static s16 sEraseDelayTimer = 15; - -/** - * Move buttons into place for the select source screen and fade in the proper labels. - * Update function for `CM_SETUP_COPY_SOURCE` - */ -void FileChoose_SetupCopySource(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 yStep; - s16 i; - - for (i = 0; i < 5; i++) { - yStep = (ABS(this->buttonYOffsets[i] - sChooseFileYOffsets[i])) / this->actionTimer; - - if (this->buttonYOffsets[i] >= sChooseFileYOffsets[i]) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] -= 25; - this->actionButtonAlpha[FS_BTN_ACTION_ERASE] -= 25; - this->optionButtonAlpha -= 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] += 25; - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->actionTimer = 8; - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->optionButtonAlpha = 0; - - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 200; - this->titleLabel = this->nextTitleLabel; - - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->buttonIndex = FS_BTN_COPY_QUIT; - this->configMode++; - } -} - -/** - * Allow the player to select a file to copy or exit back to the main menu. - * Update function for `CM_SELECT_COPY_SOURCE` - */ -void FileChoose_SelectCopySource(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - Input* input = &this->state.input[0]; - - if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || - CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionTimer = 8; - this->buttonIndex = FS_BTN_MAIN_COPY; - this->nextTitleLabel = FS_TITLE_SELECT_FILE; - this->configMode = CM_COPY_RETURN_MAIN; - this->warningLabel = FS_WARNING_NONE; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { - if (SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - this->actionTimer = 8; - this->selectedFileIndex = this->buttonIndex; - this->configMode = CM_SETUP_COPY_DEST_1; - this->nextTitleLabel = FS_TITLE_COPY_TO; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } else { - if (ABS(this->stickRelY) >= 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - - if (this->stickRelY >= 30) { - this->buttonIndex--; - - if (this->buttonIndex < FS_BTN_COPY_FILE_1) { - this->buttonIndex = FS_BTN_COPY_QUIT; - } - } else { - this->buttonIndex++; - - if (this->buttonIndex > FS_BTN_COPY_QUIT) { - this->buttonIndex = FS_BTN_COPY_FILE_1; - } - } - } - - if (this->buttonIndex != FS_BTN_COPY_QUIT) { - if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - this->warningLabel = FS_WARNING_FILE_EMPTY; - this->warningButtonIndex = this->buttonIndex; - this->emptyFileTextAlpha = 255; - } else { - this->warningLabel = FS_WARNING_NONE; - } - } - } -} - -/** - * Move the menu buttons into place for the copy destination selection and switch titles. - * Update function for `CM_SETUP_COPY_DEST_1` - */ -void FileChoose_SetupCopyDest1(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 yStep; - s16 i; - - for (i = 0; i < 3; i++) { - yStep = ABS(this->buttonYOffsets[i] - D_8081248C[this->buttonIndex][i]) / this->actionTimer; - - if (D_8081248C[this->buttonIndex][i] >= this->buttonYOffsets[i]) { - this->buttonYOffsets[i] += yStep; - } else { - this->buttonYOffsets[i] -= yStep; - } - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->nameBoxAlpha[this->buttonIndex] -= 25; - - this->actionTimer--; - if (this->actionTimer == 0) { - this->buttonYOffsets[this->buttonIndex] = D_8081248C[this->buttonIndex][this->buttonIndex]; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->actionTimer = 8; - this->configMode++; - } -} - -/** - * Show the file info of the file selected to copy from. - * Update function for `CM_SETUP_COPY_DEST_2` - */ -void FileChoose_SetupCopyDest2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->nameBoxAlpha[this->buttonIndex] -= 25; - this->fileInfoAlpha[this->buttonIndex] += 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->nameBoxAlpha[this->buttonIndex] = 0; - this->fileInfoAlpha[this->buttonIndex] = 200; - this->buttonIndex = FS_BTN_COPY_QUIT; - this->actionTimer = 8; - this->configMode = CM_SELECT_COPY_DEST; - } -} - -/** - * Allow the player to select a slot to copy to or exit to the copy select screen. - * Update function for `CM_SELECT_COPY_DEST` - */ -void FileChoose_SelectCopyDest(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - Input* input = &this->state.input[0]; - - if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || - CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->buttonIndex = this->selectedFileIndex; - this->nextTitleLabel = FS_TITLE_COPY_FROM; - this->actionTimer = 8; - this->configMode = CM_EXIT_TO_COPY_SOURCE_1; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { - if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - this->copyDestFileIndex = this->buttonIndex; - this->nextTitleLabel = FS_TITLE_COPY_CONFIRM; - this->actionTimer = 8; - this->configMode = CM_SETUP_COPY_CONFIRM_1; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } else { - - if (ABS(this->stickRelY) >= 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - - if (this->stickRelY >= 30) { - this->buttonIndex--; - - if ((this->buttonIndex == this->selectedFileIndex)) { - this->buttonIndex--; - - if (this->buttonIndex < FS_BTN_COPY_FILE_1) { - this->buttonIndex = FS_BTN_COPY_QUIT; - } - } else { - if (this->buttonIndex < FS_BTN_COPY_FILE_1) { - this->buttonIndex = FS_BTN_COPY_QUIT; - } - } - } else { - this->buttonIndex++; - - if (this->buttonIndex > FS_BTN_COPY_QUIT) { - this->buttonIndex = FS_BTN_COPY_FILE_1; - } - - if (this->buttonIndex == this->selectedFileIndex) { - this->buttonIndex++; - } - } - } - - if (this->buttonIndex != FS_BTN_COPY_QUIT) { - if (SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - this->warningLabel = FS_WARNING_FILE_IN_USE; - this->warningButtonIndex = this->buttonIndex; - this->emptyFileTextAlpha = 255; - } else { - this->warningLabel = FS_WARNING_NONE; - } - } - } -} - -/** - * Fade out file info, bring back the name box, and get ready to return to copy source screen. - * Update function for `CM_EXIT_TO_COPY_SOURCE_1` - */ -void FileChoose_ExitToCopySource1(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->fileInfoAlpha[this->buttonIndex] -= 25; - this->nameBoxAlpha[this->buttonIndex] += 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->nextTitleLabel = FS_TITLE_COPY_FROM; - this->nameBoxAlpha[this->buttonIndex] = 200; - this->fileInfoAlpha[this->buttonIndex] = 0; - this->actionTimer = 8; - this->configMode++; - } -} - -/** - * Move the buttons back into place and return to copy source select. - * Update function for `CM_EXIT_TO_COPY_SOURCE_2` - */ -void FileChoose_ExitToCopySource2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - for (i = 0; i < 3; i++) { - yStep = ABS(this->buttonYOffsets[i] - sChooseFileYOffsets[i]) / this->actionTimer; - - if (this->buttonYOffsets[i] >= sChooseFileYOffsets[i]) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->buttonIndex = 3; - this->configMode = CM_SELECT_COPY_SOURCE; - } -} - -/** - * Rearrange buttons on the screen to prepare for copy confirmation. - * Update function for `CM_SETUP_COPY_CONFIRM_1` - */ -void FileChoose_SetupCopyConfirm1(GameState* thisx) { - static s16 D_808124A4[] = { -56, -40, -24, 0 }; - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - - for (i = 0; i < 3; i++) { - if ((i != this->copyDestFileIndex) && (i != this->selectedFileIndex)) { - this->fileButtonAlpha[i] -= 25; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->connectorAlpha[i] -= 31; - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - } - } else { - if (this->copyDestFileIndex == i) { - yStep = ABS(this->buttonYOffsets[i] - D_808124A4[i]) / this->actionTimer; - this->buttonYOffsets[i] += yStep; - - if (this->buttonYOffsets[i] >= D_808124A4[i]) { - this->buttonYOffsets[i] = D_808124A4[i]; - } - } - } - } - - this->actionTimer--; - - if (this->actionTimer == 0) { - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->actionTimer = 8; - this->configMode++; - } -} - -/** - * Fade in the 'Yes' button before allowing the player to decide. - * Update function for `CM_SETUP_COPY_CONFIRM_2` - */ -void FileChoose_SetupCopyConfirm2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] += 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->configMode = CM_COPY_CONFIRM; - this->buttonIndex = FS_BTN_CONFIRM_QUIT; - } -} - -/** - * Allow the player to confirm the copy, or quit back to the destination select. - * If yes is selected, the actual copy occurs in this function before moving on to the animation. - * Update function for `CM_COPY_CONFIRM` - */ -void FileChoose_CopyConfirm(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - Input* input = &this->state.input[0]; - u16 dayTime; - - if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || - CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionTimer = 8; - this->nextTitleLabel = FS_TITLE_COPY_TO; - this->configMode = CM_RETURN_TO_COPY_DEST; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { - dayTime = gSaveContext.dayTime; - Sram_CopySave(this, sramCtx); - gSaveContext.dayTime = dayTime; - this->fileInfoAlpha[this->copyDestFileIndex] = this->nameAlpha[this->copyDestFileIndex] = 0; - this->nextTitleLabel = FS_TITLE_COPY_COMPLETE; - this->actionTimer = 8; - this->configMode = CM_COPY_ANIM_1; - func_800AA000(300.0f, 0xB4, 0x14, 0x64); - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (ABS(this->stickRelY) >= 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->buttonIndex ^= 1; - } -} - -/** - * Move buttons back in place and return to copy destination select. - * Update function for `CM_RETURN_TO_COPY_DEST` - */ -void FileChoose_ReturnToCopyDest(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; - - for (i = 0; i < 3; i++) { - if ((i != this->copyDestFileIndex) && (i != this->selectedFileIndex)) { - this->fileButtonAlpha[i] += 25; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - this->connectorAlpha[i] += 31; - } - } - - yStep = ABS(this->buttonYOffsets[i] - D_8081248C[this->selectedFileIndex][i]) / this->actionTimer; - - if (D_8081248C[this->selectedFileIndex][i] >= this->buttonYOffsets[i]) { - this->buttonYOffsets[i] += yStep; - } else { - this->buttonYOffsets[i] -= yStep; - } - } - - this->actionTimer--; - - if (this->actionTimer == 0) { - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->actionTimer = 8; - this->buttonIndex = FS_BTN_COPY_QUIT; - this->configMode = CM_SELECT_COPY_DEST; - } -} - -/** - * Hide title - * Update function for `CM_COPY_ANIM_1` - */ -void FileChoose_CopyAnim1(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->titleAlpha[0] -= 31; - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->titleAlpha[0] = 0; - this->actionTimer = 8; - this->configMode++; - osSyncPrintf("connect_alpha=%d decision_alpha[%d]=%d\n", this->connectorAlpha[this->copyDestFileIndex], - this->copyDestFileIndex, this->fileInfoAlpha[this->copyDestFileIndex]); - } -} - -/** - * Move a copy of the file window down and fade in the file info. - * Update function for `CM_COPY_ANIM_2` - */ -void FileChoose_CopyAnim2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 yStep; - - this->fileInfoAlpha[this->copyDestFileIndex] += 25; - this->nameAlpha[this->copyDestFileIndex] += 25; - this->titleAlpha[1] += 31; - yStep = ABS(this->fileNamesY[this->copyDestFileIndex] + 56) / this->actionTimer; - this->fileNamesY[this->copyDestFileIndex] -= yStep; - - if (this->fileNamesY[this->copyDestFileIndex] <= -56) { - this->fileNamesY[this->copyDestFileIndex] = -56; - } - - this->actionTimer--; - - if (this->actionTimer == 0) { - this->actionTimer = 90; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->configMode++; - } -} - -/** - * Play sound to indicate that the copy has completed. Wait for a timer or for - * the player to press a button before moving on. - * Update function for `CM_COPY_ANIM_3` - */ -void FileChoose_CopyAnim3(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Input* input = &this->state.input[0]; - - if (this->actionTimer == 75) { - this->connectorAlpha[this->copyDestFileIndex] = 255; - Audio_PlaySoundGeneral(NA_SE_EV_DIAMOND_SWITCH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - - this->actionTimer--; - - if (this->actionTimer < 74) { - if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_B | BTN_START) || (this->actionTimer == 0)) { - this->actionTimer = 8; - this->nextTitleLabel = FS_TITLE_SELECT_FILE; - this->configMode++; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } -} - -/** - * Fade out the info boxes for both files and bring in their name boxes. Fade out title. - * Update function for `CM_COPY_ANIM_4` - */ -void FileChoose_CopyAnim4(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->fileInfoAlpha[this->selectedFileIndex] -= 25; - this->fileInfoAlpha[this->copyDestFileIndex] -= 25; - this->nameBoxAlpha[this->selectedFileIndex] += 25; - this->nameBoxAlpha[this->copyDestFileIndex] += 25; - this->titleAlpha[0] -= 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->fileNamesY[this->copyDestFileIndex] = this->buttonYOffsets[3] = 0; - this->actionTimer = 8; - this->titleAlpha[0] = 0; - this->configMode++; - } -} - -/** - * Restore all buttons and labels back to their original place and go back to the main menu. - * Update function for `CM_COPY_ANIM_5` - */ -void FileChoose_CopyAnim5(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - for (i = 0; i < 5; i++) { - yStep = ABS(this->buttonYOffsets[i]) / this->actionTimer; - - if (this->buttonYOffsets[i] >= 0) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - for (i = 0; i < 3; i++) { - if (i != this->buttonIndex) { - this->fileButtonAlpha[i] += 25; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - this->connectorAlpha[i] += 31; - } - } - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] += 25; - this->actionButtonAlpha[FS_BTN_ACTION_ERASE] += 25; - this->optionButtonAlpha += 25; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - for (i = 0; i < 3; i++) { - this->connectorAlpha[i] = 0; - this->fileButtonAlpha[i] = 200; - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->connectorAlpha[i]; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->connectorAlpha[i] = 255; - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - } - } - - this->fileNamesY[this->selectedFileIndex] = 0; - this->highlightColor[3] = 70; - this->highlightPulseDir = 1; - XREG(35) = XREG(36); - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->configMode = CM_MAIN_MENU; - } -} - -/** - * Exit from the copy source screen to the main menu. Return all buttons and labels to their original place. - * Update function for `CM_COPY_RETURN_MAIN` - */ -void FileChoose_ExitCopyToMain(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 i; - s16 yStep; - - for (i = 0; i < 5; i++) { - yStep = ABS(this->buttonYOffsets[i]) / this->actionTimer; - - if (this->buttonYOffsets[i] >= 0) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] += 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 25; - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = 200; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 0; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->configMode = CM_MAIN_MENU; - } - - this->optionButtonAlpha = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->actionButtonAlpha[FS_BTN_ACTION_COPY]; -} - -/** - * Move buttons into place for the erase select screen and fade in the proper labels. - * Update function for `CM_SETUP_ERASE_SELECT` - */ -void FileChoose_SetupEraseSelect(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 i; - s16 yStep; - - for (i = 0; i < 5; i++) { - yStep = ABS(this->buttonYOffsets[i] - sChooseFileYOffsets[i]) / this->actionTimer; - - if (this->buttonYOffsets[i] >= sChooseFileYOffsets[i]) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] -= 50; - this->actionButtonAlpha[FS_BTN_ACTION_ERASE] -= 50; - this->optionButtonAlpha -= 50; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] += 25; - - if (this->actionButtonAlpha[FS_BTN_ACTION_COPY] <= 0) { - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->optionButtonAlpha = 0; - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->highlightColor[3] = 70; - this->highlightPulseDir = 1; - XREG(35) = XREG(36); - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->optionButtonAlpha = 0; - this->confirmButtonAlpha[1] = 200; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->buttonIndex = FS_BTN_ERASE_QUIT; - this->configMode++; - } -} - -/** - * Allow the player to select a file to erase or exit back to the main menu. - * Update function for `CM_ERASE_SELECT` - */ -void FileChoose_EraseSelect(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - Input* input = &this->state.input[0]; - - if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || - CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->buttonIndex = FS_BTN_MAIN_ERASE; - this->actionTimer = 8; - this->nextTitleLabel = FS_TITLE_SELECT_FILE; - this->configMode = CM_EXIT_ERASE_TO_MAIN; - this->warningLabel = FS_WARNING_NONE; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { - if (SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - this->actionTimer = 8; - this->selectedFileIndex = this->buttonIndex; - this->configMode = CM_SETUP_ERASE_CONFIRM_1; - this->nextTitleLabel = FS_TITLE_ERASE_CONFIRM; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } else { - if (ABS(this->stickRelY) >= 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - - if (this->stickRelY >= 30) { - this->buttonIndex--; - if (this->buttonIndex < FS_BTN_ERASE_FILE_1) { - this->buttonIndex = FS_BTN_ERASE_QUIT; - } - } else { - this->buttonIndex++; - if (this->buttonIndex > FS_BTN_ERASE_QUIT) { - this->buttonIndex = FS_BTN_ERASE_FILE_1; - } - } - } - - if (this->buttonIndex != FS_BTN_ERASE_QUIT) { - if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) { - this->warningLabel = FS_WARNING_FILE_EMPTY; - this->warningButtonIndex = this->buttonIndex; - this->emptyFileTextAlpha = 255; - } else { - this->warningLabel = FS_WARNING_NONE; - } - } else { - this->warningLabel = FS_WARNING_NONE; - } - } -} - -/** - * ... - * Update function for `CM_SETUP_ERASE_CONFIRM_1` - */ -void FileChoose_SetupEraseConfirm1(GameState* thisx) { - static s16 D_808124AC[] = { 0, 16, 32 }; - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - for (i = 0; i < 3; i++) { - if (i != this->buttonIndex) { - this->fileButtonAlpha[i] -= 25; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->connectorAlpha[i] -= 31; - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - } - } else { - this->nameBoxAlpha[i] -= 25; - } - } - this->titleAlpha[0] -= 15; - this->titleAlpha[1] += 15; - - yStep = ABS(this->buttonYOffsets[this->buttonIndex] - D_808124AC[this->buttonIndex]) / this->actionTimer; - - if (this->buttonYOffsets[this->buttonIndex] >= D_808124AC[this->buttonIndex]) { - this->buttonYOffsets[this->buttonIndex] -= yStep; - } else { - this->buttonYOffsets[this->buttonIndex] += yStep; - } - - this->actionTimer--; - - if (this->actionTimer == 0) { - for (i = 0; i < 3; i++) { - if (i != this->buttonIndex) { - this->fileButtonAlpha[i] = 0; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->connectorAlpha[i] = 0; - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i] = 0; - } - } else { - this->nameBoxAlpha[i] = 0; - } - } - - this->buttonYOffsets[this->buttonIndex] = D_808124AC[this->buttonIndex]; - this->actionTimer = 8; - this->configMode++; - } -} - -/** - * Show the file info of the file selected to erase. - * Update function for `CM_SETUP_ERASE_CONFIRM_2` - */ -void FileChoose_SetupEraseConfirm2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] += 25; - this->titleAlpha[0] -= 15; - this->titleAlpha[1] += 15; - this->fileInfoAlpha[this->buttonIndex] += 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->actionTimer = 8; - this->titleLabel = this->nextTitleLabel; - this->fileInfoAlpha[this->buttonIndex] = this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] = 200; - this->buttonIndex = FS_BTN_ERASE_FILE_2; - this->configMode = CM_ERASE_CONFIRM; - } -} - -/** - * Allow the player to confirm their chioce to erase or return back to erase select. - * Update function for `CM_ERASE_CONFIRM` - */ -void FileChoose_EraseConfirm(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Input* input = &this->state.input[0]; - - if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || - CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->buttonIndex = this->selectedFileIndex; - this->nextTitleLabel = FS_TITLE_ERASE_FILE; - this->configMode = CM_EXIT_TO_ERASE_SELECT_1; - this->actionTimer = 8; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { - this->n64ddFlags[this->selectedFileIndex] = this->connectorAlpha[this->selectedFileIndex] = 0; - Audio_PlaySoundGeneral(NA_SE_EV_DIAMOND_SWITCH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->actionTimer = 8; - this->configMode = CM_ERASE_ANIM_1; - this->nextTitleLabel = FS_TITLE_ERASE_COMPLETE; - func_800AA000(200.0f, 0xFF, 0x14, 0x96); - sEraseDelayTimer = 15; - } else if (ABS(this->stickRelY) >= 30) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->buttonIndex ^= 1; - } -} - -/** - * Fade out file info, bring back the name box, and get ready to return to erase select screen. - * Update function for `CM_EXIT_TO_ERASE_SELECT_1` - */ -void FileChoose_ExitToEraseSelect1(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - this->fileInfoAlpha[this->buttonIndex] -= 25; - this->nameBoxAlpha[this->buttonIndex] += 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->actionTimer = 8; - this->fileInfoAlpha[this->buttonIndex] = 0; - this->configMode++; - } -} - -/** - * Move the buttons back into place and return to erase select. - * Update function for `CM_EXIT_TO_ERASE_SELECT_2` - */ -void FileChoose_ExitToEraseSelect2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - yStep = ABS(this->buttonYOffsets[this->buttonIndex] - sChooseFileYOffsets[this->buttonIndex]) / this->actionTimer; - - if (this->buttonYOffsets[this->buttonIndex] >= sChooseFileYOffsets[this->buttonIndex]) { - this->buttonYOffsets[this->buttonIndex] -= yStep; - } else { - this->buttonYOffsets[this->buttonIndex] += yStep; - } - - for (i = 0; i < 3; i++) { - if (i != this->buttonIndex) { - this->fileButtonAlpha[i] += 25; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - this->connectorAlpha[i] += 31; - } - } - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->buttonYOffsets[this->buttonIndex] = sChooseFileYOffsets[this->buttonIndex]; - this->actionTimer = 8; - this->buttonIndex = FS_BTN_ERASE_QUIT; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->configMode = CM_ERASE_SELECT; - } -} - -/** - * Wait for an initial delay, then start fading out the selected file. - * The actual file deletion occurs in this function - * Update function for `CM_ERASE_ANIM_1` - */ -void FileChoose_EraseAnim1(GameState* thisx) { - static s16 D_80813800; - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - - if (sEraseDelayTimer == 0) { - if (this->actionTimer == 8) { - D_80813800 = 1; - } - - if (this->actionTimer != 0) { - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->fileInfoAlpha[this->selectedFileIndex] -= 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 25; - } - - this->fileNamesY[this->selectedFileIndex] -= D_80813800; - this->actionTimer--; - D_80813800 += 2; - - if (this->actionTimer == 0) { - Sram_EraseSave(this, sramCtx); - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = this->connectorAlpha[this->selectedFileIndex] = 0; - - // probably a fake match, there should be a better chained assignment - this->confirmButtonAlpha[0] = this->confirmButtonAlpha[1] = 0; - if (1) {} - this->fileInfoAlpha[this->selectedFileIndex] = this->nameBoxAlpha[this->selectedFileIndex] = - this->confirmButtonAlpha[1]; - - this->configMode++; - this->actionTimer = 90; - } - } else { - sEraseDelayTimer--; - - if (sEraseDelayTimer == 0) { - Audio_PlaySoundGeneral(NA_SE_OC_ABYSS, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } - } -} - -/** - * Wait for a delay timer or for the palyer to press a button before returning to the main menu. - * Update function for `CM_ERASE_ANIM_2` - */ -void FileChoose_EraseAnim2(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Input* input = &this->state.input[0]; - - if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_B | BTN_START) || (--this->actionTimer == 0)) { - this->buttonYOffsets[3] = 0; - this->actionTimer = 8; - this->nextTitleLabel = FS_TITLE_SELECT_FILE; - this->configMode++; - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } -} - -/** - * Exit from the erase animation to the main menu. Return all buttons and labels to their original place. - * Update function for `CM_ERASE_ANIM_3` - */ -void FileChoose_EraseAnim3(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - s16 i; - s16 yStep; - - for (i = 0; i < 5; i++) { - yStep = ABS(this->buttonYOffsets[i]) / this->actionTimer; - - if (this->buttonYOffsets[i] >= 0) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - for (i = 0; i < 3; i++) { - this->fileButtonAlpha[i] += 25; - - if (SLOT_OCCUPIED(sramCtx, i)) { - this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i]; - this->connectorAlpha[i] += 31; - } - } - - if (this->fileButtonAlpha[this->selectedFileIndex] >= 200) { - this->fileButtonAlpha[this->selectedFileIndex] = 200; - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->fileNamesY[this->selectedFileIndex] = 0; - this->highlightColor[3] = 70; - this->highlightPulseDir = 1; - XREG(35) = XREG(36); - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = 200; - this->confirmButtonAlpha[0] = this->confirmButtonAlpha[1] = 0; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->configMode = CM_MAIN_MENU; - } - - this->optionButtonAlpha = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->actionButtonAlpha[FS_BTN_ACTION_COPY]; -} - -/** - * Exit from the erase select screen to the main menu. Return all buttons and labels to their original place. - * Update function for `CM_EXIT_ERASE_TO_MAIN` - */ -void FileChoose_ExitEraseToMain(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - s16 i; - s16 yStep; - - for (i = 0; i < 5; i++) { - yStep = ABS(this->buttonYOffsets[i]) / this->actionTimer; - - if (this->buttonYOffsets[i] >= 0) { - this->buttonYOffsets[i] -= yStep; - } else { - this->buttonYOffsets[i] += yStep; - } - } - - this->actionButtonAlpha[FS_BTN_ACTION_COPY] += 25; - this->actionButtonAlpha[FS_BTN_ACTION_ERASE] += 25; - this->optionButtonAlpha += 25; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 50; - - if (this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] <= 0) { - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 0; - } - - this->titleAlpha[0] -= 31; - this->titleAlpha[1] += 31; - this->actionTimer--; - - if (this->actionTimer == 0) { - this->highlightColor[3] = 70; - this->highlightPulseDir = 1; - XREG(35) = XREG(36); - this->actionButtonAlpha[FS_BTN_ACTION_COPY] = 200; - this->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 0; - this->titleLabel = this->nextTitleLabel; - this->titleAlpha[0] = 255; - this->titleAlpha[1] = 0; - this->configMode = CM_MAIN_MENU; - } - - this->optionButtonAlpha = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] = - this->actionButtonAlpha[FS_BTN_ACTION_COPY]; -} diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.cpp b/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.cpp new file mode 100644 index 000000000..05299df13 --- /dev/null +++ b/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.cpp @@ -0,0 +1,1082 @@ +#define INTERNAL_SRC_OVERLAYS_GAMESTATES_OVL_FILE_CHOOSE_Z_FILE_COPY_ERASE_C +#include "actor_common.h" +#include "file_choose.h" +#include "z_file_choose.h" +#include "def/code_800A9F30.h" +#include "def/code_800F7260.h" +#include "def/z_common_data.h" +#include "def/z_sram.h" + +extern u16 gSramSlotOffsets[]; + +// when choosing a file to copy or erase, the 6 main menu buttons are placed at these offsets +static s16 sChooseFileYOffsets[] = { -48, -48, -48, -24, -24, 0 }; + +static s16 D_8081248C[3][3] = { + { 0, -48, -48 }, + { -64, 16, -48 }, + { -64, -64, 32 }, +}; + +static s16 sEraseDelayTimer = 15; + +/** + * Move buttons into place for the select source screen and fade in the proper labels. + * Update function for `CM_SETUP_COPY_SOURCE` + */ +void FileChoose_SetupCopySource(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 yStep; + s16 i; + + for (i = 0; i < 5; i++) { + yStep = (ABS(pthis->buttonYOffsets[i] - sChooseFileYOffsets[i])) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= sChooseFileYOffsets[i]) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] -= 25; + pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] -= 25; + pthis->optionButtonAlpha -= 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] += 25; + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->actionTimer = 8; + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->optionButtonAlpha = 0; + + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 200; + pthis->titleLabel = pthis->nextTitleLabel; + + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->buttonIndex = FS_BTN_COPY_QUIT; + pthis->configMode++; + } +} + +/** + * Allow the player to select a file to copy or exit back to the main menu. + * Update function for `CM_SELECT_COPY_SOURCE` + */ +void FileChoose_SelectCopySource(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + Input* input = &pthis->state.input[0]; + + if (((pthis->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || + CHECK_BTN_ALL(input->press.button, BTN_B)) { + pthis->actionTimer = 8; + pthis->buttonIndex = FS_BTN_MAIN_COPY; + pthis->nextTitleLabel = FS_TITLE_SELECT_FILE; + pthis->configMode = CM_COPY_RETURN_MAIN; + pthis->warningLabel = FS_WARNING_NONE; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { + if (SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + pthis->actionTimer = 8; + pthis->selectedFileIndex = pthis->buttonIndex; + pthis->configMode = CM_SETUP_COPY_DEST_1; + pthis->nextTitleLabel = FS_TITLE_COPY_TO; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else { + if (ABS(pthis->stickRelY) >= 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + if (pthis->stickRelY >= 30) { + pthis->buttonIndex--; + + if (pthis->buttonIndex < FS_BTN_COPY_FILE_1) { + pthis->buttonIndex = FS_BTN_COPY_QUIT; + } + } else { + pthis->buttonIndex++; + + if (pthis->buttonIndex > FS_BTN_COPY_QUIT) { + pthis->buttonIndex = FS_BTN_COPY_FILE_1; + } + } + } + + if (pthis->buttonIndex != FS_BTN_COPY_QUIT) { + if (!SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + pthis->warningLabel = FS_WARNING_FILE_EMPTY; + pthis->warningButtonIndex = pthis->buttonIndex; + pthis->emptyFileTextAlpha = 255; + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } + } +} + +/** + * Move the menu buttons into place for the copy destination selection and switch titles. + * Update function for `CM_SETUP_COPY_DEST_1` + */ +void FileChoose_SetupCopyDest1(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 yStep; + s16 i; + + for (i = 0; i < 3; i++) { + yStep = ABS(pthis->buttonYOffsets[i] - D_8081248C[pthis->buttonIndex][i]) / pthis->actionTimer; + + if (D_8081248C[pthis->buttonIndex][i] >= pthis->buttonYOffsets[i]) { + pthis->buttonYOffsets[i] += yStep; + } else { + pthis->buttonYOffsets[i] -= yStep; + } + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->nameBoxAlpha[pthis->buttonIndex] -= 25; + + pthis->actionTimer--; + if (pthis->actionTimer == 0) { + pthis->buttonYOffsets[pthis->buttonIndex] = D_8081248C[pthis->buttonIndex][pthis->buttonIndex]; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->actionTimer = 8; + pthis->configMode++; + } +} + +/** + * Show the file info of the file selected to copy from. + * Update function for `CM_SETUP_COPY_DEST_2` + */ +void FileChoose_SetupCopyDest2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->nameBoxAlpha[pthis->buttonIndex] -= 25; + pthis->fileInfoAlpha[pthis->buttonIndex] += 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->nameBoxAlpha[pthis->buttonIndex] = 0; + pthis->fileInfoAlpha[pthis->buttonIndex] = 200; + pthis->buttonIndex = FS_BTN_COPY_QUIT; + pthis->actionTimer = 8; + pthis->configMode = CM_SELECT_COPY_DEST; + } +} + +/** + * Allow the player to select a slot to copy to or exit to the copy select screen. + * Update function for `CM_SELECT_COPY_DEST` + */ +void FileChoose_SelectCopyDest(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + Input* input = &pthis->state.input[0]; + + if (((pthis->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || + CHECK_BTN_ALL(input->press.button, BTN_B)) { + pthis->buttonIndex = pthis->selectedFileIndex; + pthis->nextTitleLabel = FS_TITLE_COPY_FROM; + pthis->actionTimer = 8; + pthis->configMode = CM_EXIT_TO_COPY_SOURCE_1; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { + if (!SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + pthis->copyDestFileIndex = pthis->buttonIndex; + pthis->nextTitleLabel = FS_TITLE_COPY_CONFIRM; + pthis->actionTimer = 8; + pthis->configMode = CM_SETUP_COPY_CONFIRM_1; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else { + + if (ABS(pthis->stickRelY) >= 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + if (pthis->stickRelY >= 30) { + pthis->buttonIndex--; + + if ((pthis->buttonIndex == pthis->selectedFileIndex)) { + pthis->buttonIndex--; + + if (pthis->buttonIndex < FS_BTN_COPY_FILE_1) { + pthis->buttonIndex = FS_BTN_COPY_QUIT; + } + } else { + if (pthis->buttonIndex < FS_BTN_COPY_FILE_1) { + pthis->buttonIndex = FS_BTN_COPY_QUIT; + } + } + } else { + pthis->buttonIndex++; + + if (pthis->buttonIndex > FS_BTN_COPY_QUIT) { + pthis->buttonIndex = FS_BTN_COPY_FILE_1; + } + + if (pthis->buttonIndex == pthis->selectedFileIndex) { + pthis->buttonIndex++; + } + } + } + + if (pthis->buttonIndex != FS_BTN_COPY_QUIT) { + if (SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + pthis->warningLabel = FS_WARNING_FILE_IN_USE; + pthis->warningButtonIndex = pthis->buttonIndex; + pthis->emptyFileTextAlpha = 255; + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } + } +} + +/** + * Fade out file info, bring back the name box, and get ready to return to copy source screen. + * Update function for `CM_EXIT_TO_COPY_SOURCE_1` + */ +void FileChoose_ExitToCopySource1(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->fileInfoAlpha[pthis->buttonIndex] -= 25; + pthis->nameBoxAlpha[pthis->buttonIndex] += 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->nextTitleLabel = FS_TITLE_COPY_FROM; + pthis->nameBoxAlpha[pthis->buttonIndex] = 200; + pthis->fileInfoAlpha[pthis->buttonIndex] = 0; + pthis->actionTimer = 8; + pthis->configMode++; + } +} + +/** + * Move the buttons back into place and return to copy source select. + * Update function for `CM_EXIT_TO_COPY_SOURCE_2` + */ +void FileChoose_ExitToCopySource2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + for (i = 0; i < 3; i++) { + yStep = ABS(pthis->buttonYOffsets[i] - sChooseFileYOffsets[i]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= sChooseFileYOffsets[i]) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->buttonIndex = 3; + pthis->configMode = CM_SELECT_COPY_SOURCE; + } +} + +/** + * Rearrange buttons on the screen to prepare for copy confirmation. + * Update function for `CM_SETUP_COPY_CONFIRM_1` + */ +void FileChoose_SetupCopyConfirm1(GameState* thisx) { + static s16 D_808124A4[] = { -56, -40, -24, 0 }; + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + + for (i = 0; i < 3; i++) { + if ((i != pthis->copyDestFileIndex) && (i != pthis->selectedFileIndex)) { + pthis->fileButtonAlpha[i] -= 25; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->connectorAlpha[i] -= 31; + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + } + } else { + if (pthis->copyDestFileIndex == i) { + yStep = ABS(pthis->buttonYOffsets[i] - D_808124A4[i]) / pthis->actionTimer; + pthis->buttonYOffsets[i] += yStep; + + if (pthis->buttonYOffsets[i] >= D_808124A4[i]) { + pthis->buttonYOffsets[i] = D_808124A4[i]; + } + } + } + } + + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->actionTimer = 8; + pthis->configMode++; + } +} + +/** + * Fade in the 'Yes' button before allowing the player to decide. + * Update function for `CM_SETUP_COPY_CONFIRM_2` + */ +void FileChoose_SetupCopyConfirm2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] += 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->configMode = CM_COPY_CONFIRM; + pthis->buttonIndex = FS_BTN_CONFIRM_QUIT; + } +} + +/** + * Allow the player to confirm the copy, or quit back to the destination select. + * If yes is selected, the actual copy occurs in pthis function before moving on to the animation. + * Update function for `CM_COPY_CONFIRM` + */ +void FileChoose_CopyConfirm(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + Input* input = &pthis->state.input[0]; + u16 dayTime; + + if (((pthis->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || + CHECK_BTN_ALL(input->press.button, BTN_B)) { + pthis->actionTimer = 8; + pthis->nextTitleLabel = FS_TITLE_COPY_TO; + pthis->configMode = CM_RETURN_TO_COPY_DEST; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { + dayTime = gSaveContext.dayTime; + Sram_CopySave(pthis, sramCtx); + gSaveContext.dayTime = dayTime; + pthis->fileInfoAlpha[pthis->copyDestFileIndex] = pthis->nameAlpha[pthis->copyDestFileIndex] = 0; + pthis->nextTitleLabel = FS_TITLE_COPY_COMPLETE; + pthis->actionTimer = 8; + pthis->configMode = CM_COPY_ANIM_1; + func_800AA000(300.0f, 0xB4, 0x14, 0x64); + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (ABS(pthis->stickRelY) >= 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->buttonIndex ^= 1; + } +} + +/** + * Move buttons back in place and return to copy destination select. + * Update function for `CM_RETURN_TO_COPY_DEST` + */ +void FileChoose_ReturnToCopyDest(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; + + for (i = 0; i < 3; i++) { + if ((i != pthis->copyDestFileIndex) && (i != pthis->selectedFileIndex)) { + pthis->fileButtonAlpha[i] += 25; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + pthis->connectorAlpha[i] += 31; + } + } + + yStep = ABS(pthis->buttonYOffsets[i] - D_8081248C[pthis->selectedFileIndex][i]) / pthis->actionTimer; + + if (D_8081248C[pthis->selectedFileIndex][i] >= pthis->buttonYOffsets[i]) { + pthis->buttonYOffsets[i] += yStep; + } else { + pthis->buttonYOffsets[i] -= yStep; + } + } + + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->actionTimer = 8; + pthis->buttonIndex = FS_BTN_COPY_QUIT; + pthis->configMode = CM_SELECT_COPY_DEST; + } +} + +/** + * Hide title + * Update function for `CM_COPY_ANIM_1` + */ +void FileChoose_CopyAnim1(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->titleAlpha[0] -= 31; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->titleAlpha[0] = 0; + pthis->actionTimer = 8; + pthis->configMode++; + osSyncPrintf("connect_alpha=%d decision_alpha[%d]=%d\n", pthis->connectorAlpha[pthis->copyDestFileIndex], + pthis->copyDestFileIndex, pthis->fileInfoAlpha[pthis->copyDestFileIndex]); + } +} + +/** + * Move a copy of the file window down and fade in the file info. + * Update function for `CM_COPY_ANIM_2` + */ +void FileChoose_CopyAnim2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 yStep; + + pthis->fileInfoAlpha[pthis->copyDestFileIndex] += 25; + pthis->nameAlpha[pthis->copyDestFileIndex] += 25; + pthis->titleAlpha[1] += 31; + yStep = ABS(pthis->fileNamesY[pthis->copyDestFileIndex] + 56) / pthis->actionTimer; + pthis->fileNamesY[pthis->copyDestFileIndex] -= yStep; + + if (pthis->fileNamesY[pthis->copyDestFileIndex] <= -56) { + pthis->fileNamesY[pthis->copyDestFileIndex] = -56; + } + + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->actionTimer = 90; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->configMode++; + } +} + +/** + * Play sound to indicate that the copy has completed. Wait for a timer or for + * the player to press a button before moving on. + * Update function for `CM_COPY_ANIM_3` + */ +void FileChoose_CopyAnim3(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + Input* input = &pthis->state.input[0]; + + if (pthis->actionTimer == 75) { + pthis->connectorAlpha[pthis->copyDestFileIndex] = 255; + Audio_PlaySoundGeneral(NA_SE_EV_DIAMOND_SWITCH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + pthis->actionTimer--; + + if (pthis->actionTimer < 74) { + if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_B | BTN_START) || (pthis->actionTimer == 0)) { + pthis->actionTimer = 8; + pthis->nextTitleLabel = FS_TITLE_SELECT_FILE; + pthis->configMode++; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } +} + +/** + * Fade out the info boxes for both files and bring in their name boxes. Fade out title. + * Update function for `CM_COPY_ANIM_4` + */ +void FileChoose_CopyAnim4(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->fileInfoAlpha[pthis->selectedFileIndex] -= 25; + pthis->fileInfoAlpha[pthis->copyDestFileIndex] -= 25; + pthis->nameBoxAlpha[pthis->selectedFileIndex] += 25; + pthis->nameBoxAlpha[pthis->copyDestFileIndex] += 25; + pthis->titleAlpha[0] -= 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->fileNamesY[pthis->copyDestFileIndex] = pthis->buttonYOffsets[3] = 0; + pthis->actionTimer = 8; + pthis->titleAlpha[0] = 0; + pthis->configMode++; + } +} + +/** + * Restore all buttons and labels back to their original place and go back to the main menu. + * Update function for `CM_COPY_ANIM_5` + */ +void FileChoose_CopyAnim5(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + for (i = 0; i < 5; i++) { + yStep = ABS(pthis->buttonYOffsets[i]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= 0) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + for (i = 0; i < 3; i++) { + if (i != pthis->buttonIndex) { + pthis->fileButtonAlpha[i] += 25; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + pthis->connectorAlpha[i] += 31; + } + } + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] += 25; + pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] += 25; + pthis->optionButtonAlpha += 25; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + for (i = 0; i < 3; i++) { + pthis->connectorAlpha[i] = 0; + pthis->fileButtonAlpha[i] = 200; + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->connectorAlpha[i]; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->connectorAlpha[i] = 255; + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + } + } + + pthis->fileNamesY[pthis->selectedFileIndex] = 0; + pthis->highlightColor[3] = 70; + pthis->highlightPulseDir = 1; + XREG(35) = XREG(36); + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->configMode = CM_MAIN_MENU; + } +} + +/** + * Exit from the copy source screen to the main menu. Return all buttons and labels to their original place. + * Update function for `CM_COPY_RETURN_MAIN` + */ +void FileChoose_ExitCopyToMain(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 i; + s16 yStep; + + for (i = 0; i < 5; i++) { + yStep = ABS(pthis->buttonYOffsets[i]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= 0) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] += 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 25; + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = 200; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 0; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->configMode = CM_MAIN_MENU; + } + + pthis->optionButtonAlpha = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY]; +} + +/** + * Move buttons into place for the erase select screen and fade in the proper labels. + * Update function for `CM_SETUP_ERASE_SELECT` + */ +void FileChoose_SetupEraseSelect(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 i; + s16 yStep; + + for (i = 0; i < 5; i++) { + yStep = ABS(pthis->buttonYOffsets[i] - sChooseFileYOffsets[i]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= sChooseFileYOffsets[i]) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] -= 50; + pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] -= 50; + pthis->optionButtonAlpha -= 50; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] += 25; + + if (pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] <= 0) { + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->optionButtonAlpha = 0; + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->highlightColor[3] = 70; + pthis->highlightPulseDir = 1; + XREG(35) = XREG(36); + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->optionButtonAlpha = 0; + pthis->confirmButtonAlpha[1] = 200; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->buttonIndex = FS_BTN_ERASE_QUIT; + pthis->configMode++; + } +} + +/** + * Allow the player to select a file to erase or exit back to the main menu. + * Update function for `CM_ERASE_SELECT` + */ +void FileChoose_EraseSelect(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + Input* input = &pthis->state.input[0]; + + if (((pthis->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || + CHECK_BTN_ALL(input->press.button, BTN_B)) { + pthis->buttonIndex = FS_BTN_MAIN_ERASE; + pthis->actionTimer = 8; + pthis->nextTitleLabel = FS_TITLE_SELECT_FILE; + pthis->configMode = CM_EXIT_ERASE_TO_MAIN; + pthis->warningLabel = FS_WARNING_NONE; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { + if (SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + pthis->actionTimer = 8; + pthis->selectedFileIndex = pthis->buttonIndex; + pthis->configMode = CM_SETUP_ERASE_CONFIRM_1; + pthis->nextTitleLabel = FS_TITLE_ERASE_CONFIRM; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else { + if (ABS(pthis->stickRelY) >= 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + if (pthis->stickRelY >= 30) { + pthis->buttonIndex--; + if (pthis->buttonIndex < FS_BTN_ERASE_FILE_1) { + pthis->buttonIndex = FS_BTN_ERASE_QUIT; + } + } else { + pthis->buttonIndex++; + if (pthis->buttonIndex > FS_BTN_ERASE_QUIT) { + pthis->buttonIndex = FS_BTN_ERASE_FILE_1; + } + } + } + + if (pthis->buttonIndex != FS_BTN_ERASE_QUIT) { + if (!SLOT_OCCUPIED(sramCtx, pthis->buttonIndex)) { + pthis->warningLabel = FS_WARNING_FILE_EMPTY; + pthis->warningButtonIndex = pthis->buttonIndex; + pthis->emptyFileTextAlpha = 255; + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } else { + pthis->warningLabel = FS_WARNING_NONE; + } + } +} + +/** + * ... + * Update function for `CM_SETUP_ERASE_CONFIRM_1` + */ +void FileChoose_SetupEraseConfirm1(GameState* thisx) { + static s16 D_808124AC[] = { 0, 16, 32 }; + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + for (i = 0; i < 3; i++) { + if (i != pthis->buttonIndex) { + pthis->fileButtonAlpha[i] -= 25; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->connectorAlpha[i] -= 31; + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + } + } else { + pthis->nameBoxAlpha[i] -= 25; + } + } + pthis->titleAlpha[0] -= 15; + pthis->titleAlpha[1] += 15; + + yStep = ABS(pthis->buttonYOffsets[pthis->buttonIndex] - D_808124AC[pthis->buttonIndex]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[pthis->buttonIndex] >= D_808124AC[pthis->buttonIndex]) { + pthis->buttonYOffsets[pthis->buttonIndex] -= yStep; + } else { + pthis->buttonYOffsets[pthis->buttonIndex] += yStep; + } + + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + for (i = 0; i < 3; i++) { + if (i != pthis->buttonIndex) { + pthis->fileButtonAlpha[i] = 0; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->connectorAlpha[i] = 0; + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i] = 0; + } + } else { + pthis->nameBoxAlpha[i] = 0; + } + } + + pthis->buttonYOffsets[pthis->buttonIndex] = D_808124AC[pthis->buttonIndex]; + pthis->actionTimer = 8; + pthis->configMode++; + } +} + +/** + * Show the file info of the file selected to erase. + * Update function for `CM_SETUP_ERASE_CONFIRM_2` + */ +void FileChoose_SetupEraseConfirm2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] += 25; + pthis->titleAlpha[0] -= 15; + pthis->titleAlpha[1] += 15; + pthis->fileInfoAlpha[pthis->buttonIndex] += 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->actionTimer = 8; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->fileInfoAlpha[pthis->buttonIndex] = pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] = 200; + pthis->buttonIndex = FS_BTN_ERASE_FILE_2; + pthis->configMode = CM_ERASE_CONFIRM; + } +} + +/** + * Allow the player to confirm their chioce to erase or return back to erase select. + * Update function for `CM_ERASE_CONFIRM` + */ +void FileChoose_EraseConfirm(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + Input* input = &pthis->state.input[0]; + + if (((pthis->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || + CHECK_BTN_ALL(input->press.button, BTN_B)) { + pthis->buttonIndex = pthis->selectedFileIndex; + pthis->nextTitleLabel = FS_TITLE_ERASE_FILE; + pthis->configMode = CM_EXIT_TO_ERASE_SELECT_1; + pthis->actionTimer = 8; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) { + pthis->n64ddFlags[pthis->selectedFileIndex] = pthis->connectorAlpha[pthis->selectedFileIndex] = 0; + Audio_PlaySoundGeneral(NA_SE_EV_DIAMOND_SWITCH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->actionTimer = 8; + pthis->configMode = CM_ERASE_ANIM_1; + pthis->nextTitleLabel = FS_TITLE_ERASE_COMPLETE; + func_800AA000(200.0f, 0xFF, 0x14, 0x96); + sEraseDelayTimer = 15; + } else if (ABS(pthis->stickRelY) >= 30) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pthis->buttonIndex ^= 1; + } +} + +/** + * Fade out file info, bring back the name box, and get ready to return to erase select screen. + * Update function for `CM_EXIT_TO_ERASE_SELECT_1` + */ +void FileChoose_ExitToEraseSelect1(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + + pthis->fileInfoAlpha[pthis->buttonIndex] -= 25; + pthis->nameBoxAlpha[pthis->buttonIndex] += 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->actionTimer = 8; + pthis->fileInfoAlpha[pthis->buttonIndex] = 0; + pthis->configMode++; + } +} + +/** + * Move the buttons back into place and return to erase select. + * Update function for `CM_EXIT_TO_ERASE_SELECT_2` + */ +void FileChoose_ExitToEraseSelect2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + yStep = ABS(pthis->buttonYOffsets[pthis->buttonIndex] - sChooseFileYOffsets[pthis->buttonIndex]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[pthis->buttonIndex] >= sChooseFileYOffsets[pthis->buttonIndex]) { + pthis->buttonYOffsets[pthis->buttonIndex] -= yStep; + } else { + pthis->buttonYOffsets[pthis->buttonIndex] += yStep; + } + + for (i = 0; i < 3; i++) { + if (i != pthis->buttonIndex) { + pthis->fileButtonAlpha[i] += 25; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + pthis->connectorAlpha[i] += 31; + } + } + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->buttonYOffsets[pthis->buttonIndex] = sChooseFileYOffsets[pthis->buttonIndex]; + pthis->actionTimer = 8; + pthis->buttonIndex = FS_BTN_ERASE_QUIT; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->configMode = CM_ERASE_SELECT; + } +} + +/** + * Wait for an initial delay, then start fading out the selected file. + * The actual file deletion occurs in pthis function + * Update function for `CM_ERASE_ANIM_1` + */ +void FileChoose_EraseAnim1(GameState* thisx) { + static s16 D_80813800; + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + + if (sEraseDelayTimer == 0) { + if (pthis->actionTimer == 8) { + D_80813800 = 1; + } + + if (pthis->actionTimer != 0) { + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->fileInfoAlpha[pthis->selectedFileIndex] -= 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_YES] -= 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 25; + } + + pthis->fileNamesY[pthis->selectedFileIndex] -= D_80813800; + pthis->actionTimer--; + D_80813800 += 2; + + if (pthis->actionTimer == 0) { + Sram_EraseSave(pthis, sramCtx); + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = pthis->connectorAlpha[pthis->selectedFileIndex] = 0; + + // probably a fake match, there should be a better chained assignment + pthis->confirmButtonAlpha[0] = pthis->confirmButtonAlpha[1] = 0; + if (1) {} + pthis->fileInfoAlpha[pthis->selectedFileIndex] = pthis->nameBoxAlpha[pthis->selectedFileIndex] = + pthis->confirmButtonAlpha[1]; + + pthis->configMode++; + pthis->actionTimer = 90; + } + } else { + sEraseDelayTimer--; + + if (sEraseDelayTimer == 0) { + Audio_PlaySoundGeneral(NA_SE_OC_ABYSS, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } +} + +/** + * Wait for a delay timer or for the palyer to press a button before returning to the main menu. + * Update function for `CM_ERASE_ANIM_2` + */ +void FileChoose_EraseAnim2(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + Input* input = &pthis->state.input[0]; + + if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_B | BTN_START) || (--pthis->actionTimer == 0)) { + pthis->buttonYOffsets[3] = 0; + pthis->actionTimer = 8; + pthis->nextTitleLabel = FS_TITLE_SELECT_FILE; + pthis->configMode++; + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } +} + +/** + * Exit from the erase animation to the main menu. Return all buttons and labels to their original place. + * Update function for `CM_ERASE_ANIM_3` + */ +void FileChoose_EraseAnim3(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + s16 i; + s16 yStep; + + for (i = 0; i < 5; i++) { + yStep = ABS(pthis->buttonYOffsets[i]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= 0) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + for (i = 0; i < 3; i++) { + pthis->fileButtonAlpha[i] += 25; + + if (SLOT_OCCUPIED(sramCtx, i)) { + pthis->nameBoxAlpha[i] = pthis->nameAlpha[i] = pthis->fileButtonAlpha[i]; + pthis->connectorAlpha[i] += 31; + } + } + + if (pthis->fileButtonAlpha[pthis->selectedFileIndex] >= 200) { + pthis->fileButtonAlpha[pthis->selectedFileIndex] = 200; + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->fileNamesY[pthis->selectedFileIndex] = 0; + pthis->highlightColor[3] = 70; + pthis->highlightPulseDir = 1; + XREG(35) = XREG(36); + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = 200; + pthis->confirmButtonAlpha[0] = pthis->confirmButtonAlpha[1] = 0; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->configMode = CM_MAIN_MENU; + } + + pthis->optionButtonAlpha = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY]; +} + +/** + * Exit from the erase select screen to the main menu. Return all buttons and labels to their original place. + * Update function for `CM_EXIT_ERASE_TO_MAIN` + */ +void FileChoose_ExitEraseToMain(GameState* thisx) { + FileChooseContext* pthis = (FileChooseContext*)thisx; + s16 i; + s16 yStep; + + for (i = 0; i < 5; i++) { + yStep = ABS(pthis->buttonYOffsets[i]) / pthis->actionTimer; + + if (pthis->buttonYOffsets[i] >= 0) { + pthis->buttonYOffsets[i] -= yStep; + } else { + pthis->buttonYOffsets[i] += yStep; + } + } + + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] += 25; + pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] += 25; + pthis->optionButtonAlpha += 25; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] -= 50; + + if (pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] <= 0) { + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 0; + } + + pthis->titleAlpha[0] -= 31; + pthis->titleAlpha[1] += 31; + pthis->actionTimer--; + + if (pthis->actionTimer == 0) { + pthis->highlightColor[3] = 70; + pthis->highlightPulseDir = 1; + XREG(35) = XREG(36); + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY] = 200; + pthis->confirmButtonAlpha[FS_BTN_CONFIRM_QUIT] = 0; + pthis->titleLabel = pthis->nextTitleLabel; + pthis->titleAlpha[0] = 255; + pthis->titleAlpha[1] = 0; + pthis->configMode = CM_MAIN_MENU; + } + + pthis->optionButtonAlpha = pthis->actionButtonAlpha[FS_BTN_ACTION_ERASE] = + pthis->actionButtonAlpha[FS_BTN_ACTION_COPY]; +} diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.cpp similarity index 57% rename from src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c rename to src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.cpp index 52ff3665e..b043e00a3 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.cpp @@ -40,7 +40,7 @@ void FileChoose_DrawCharacter(GraphicsContext* gfxCtx, void* texture, s16 vtx) { } void FileChoose_SetKeyboardVtx(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; + FileChooseContext* pthis = (FileChooseContext*)thisx; s16 val; s16 phi_t2; s16 phi_t0; @@ -49,7 +49,7 @@ void FileChoose_SetKeyboardVtx(GameState* thisx) { s16 phi_t1; s16 phi_s2; - this->keyboardVtx = Graph_Alloc(this->state.gfxCtx, sizeof(Vtx) * 4 * 5 * 13); + pthis->keyboardVtx = (Vtx*)Graph_Alloc(pthis->state.gfxCtx, sizeof(Vtx) * 4 * 5 * 13); phi_s1 = 0x26; @@ -60,35 +60,35 @@ void FileChoose_SetKeyboardVtx(GameState* thisx) { /* Avoid Overflow in final loop */ phi_t2 = phi_t2 & 0x3F; - this->keyboardVtx[phi_t3].v.ob[0] = this->keyboardVtx[phi_t3 + 2].v.ob[0] = D_80812544[phi_t2] + phi_t0; + pthis->keyboardVtx[phi_t3].v.ob[0] = pthis->keyboardVtx[phi_t3 + 2].v.ob[0] = D_80812544[phi_t2] + phi_t0; - this->keyboardVtx[phi_t3 + 1].v.ob[0] = this->keyboardVtx[phi_t3 + 3].v.ob[0] = + pthis->keyboardVtx[phi_t3 + 1].v.ob[0] = pthis->keyboardVtx[phi_t3 + 3].v.ob[0] = D_80812544[phi_t2] + phi_t0 + 12; - this->keyboardVtx[phi_t3].v.ob[1] = this->keyboardVtx[phi_t3 + 1].v.ob[1] = phi_s1; + pthis->keyboardVtx[phi_t3].v.ob[1] = pthis->keyboardVtx[phi_t3 + 1].v.ob[1] = phi_s1; - this->keyboardVtx[phi_t3 + 2].v.ob[1] = this->keyboardVtx[phi_t3 + 3].v.ob[1] = phi_s1 - 12; + pthis->keyboardVtx[phi_t3 + 2].v.ob[1] = pthis->keyboardVtx[phi_t3 + 3].v.ob[1] = phi_s1 - 12; - this->keyboardVtx[phi_t3].v.ob[2] = this->keyboardVtx[phi_t3 + 1].v.ob[2] = - this->keyboardVtx[phi_t3 + 2].v.ob[2] = this->keyboardVtx[phi_t3 + 3].v.ob[2] = 0; + pthis->keyboardVtx[phi_t3].v.ob[2] = pthis->keyboardVtx[phi_t3 + 1].v.ob[2] = + pthis->keyboardVtx[phi_t3 + 2].v.ob[2] = pthis->keyboardVtx[phi_t3 + 3].v.ob[2] = 0; - this->keyboardVtx[phi_t3].v.flag = this->keyboardVtx[phi_t3 + 1].v.flag = - this->keyboardVtx[phi_t3 + 2].v.flag = this->keyboardVtx[phi_t3 + 3].v.flag = 0; + pthis->keyboardVtx[phi_t3].v.flag = pthis->keyboardVtx[phi_t3 + 1].v.flag = + pthis->keyboardVtx[phi_t3 + 2].v.flag = pthis->keyboardVtx[phi_t3 + 3].v.flag = 0; - this->keyboardVtx[phi_t3].v.tc[0] = this->keyboardVtx[phi_t3].v.tc[1] = - this->keyboardVtx[phi_t3 + 1].v.tc[1] = this->keyboardVtx[phi_t3 + 2].v.tc[0] = 0; + pthis->keyboardVtx[phi_t3].v.tc[0] = pthis->keyboardVtx[phi_t3].v.tc[1] = + pthis->keyboardVtx[phi_t3 + 1].v.tc[1] = pthis->keyboardVtx[phi_t3 + 2].v.tc[0] = 0; - this->keyboardVtx[phi_t3 + 1].v.tc[0] = this->keyboardVtx[phi_t3 + 2].v.tc[1] = - this->keyboardVtx[phi_t3 + 3].v.tc[0] = this->keyboardVtx[phi_t3 + 3].v.tc[1] = 0x200; + pthis->keyboardVtx[phi_t3 + 1].v.tc[0] = pthis->keyboardVtx[phi_t3 + 2].v.tc[1] = + pthis->keyboardVtx[phi_t3 + 3].v.tc[0] = pthis->keyboardVtx[phi_t3 + 3].v.tc[1] = 0x200; - this->keyboardVtx[phi_t3].v.cn[0] = this->keyboardVtx[phi_t3 + 1].v.cn[0] = - this->keyboardVtx[phi_t3 + 2].v.cn[0] = this->keyboardVtx[phi_t3 + 3].v.cn[0] = - this->keyboardVtx[phi_t3].v.cn[1] = this->keyboardVtx[phi_t3 + 1].v.cn[1] = - this->keyboardVtx[phi_t3 + 2].v.cn[1] = this->keyboardVtx[phi_t3 + 3].v.cn[1] = - this->keyboardVtx[phi_t3].v.cn[2] = this->keyboardVtx[phi_t3 + 1].v.cn[2] = - this->keyboardVtx[phi_t3 + 2].v.cn[2] = this->keyboardVtx[phi_t3 + 3].v.cn[2] = - this->keyboardVtx[phi_t3].v.cn[3] = this->keyboardVtx[phi_t3 + 1].v.cn[3] = - this->keyboardVtx[phi_t3 + 2].v.cn[3] = this->keyboardVtx[phi_t3 + 3].v.cn[3] = + pthis->keyboardVtx[phi_t3].v.cn[0] = pthis->keyboardVtx[phi_t3 + 1].v.cn[0] = + pthis->keyboardVtx[phi_t3 + 2].v.cn[0] = pthis->keyboardVtx[phi_t3 + 3].v.cn[0] = + pthis->keyboardVtx[phi_t3].v.cn[1] = pthis->keyboardVtx[phi_t3 + 1].v.cn[1] = + pthis->keyboardVtx[phi_t3 + 2].v.cn[1] = pthis->keyboardVtx[phi_t3 + 3].v.cn[1] = + pthis->keyboardVtx[phi_t3].v.cn[2] = pthis->keyboardVtx[phi_t3 + 1].v.cn[2] = + pthis->keyboardVtx[phi_t3 + 2].v.cn[2] = pthis->keyboardVtx[phi_t3 + 3].v.cn[2] = + pthis->keyboardVtx[phi_t3].v.cn[3] = pthis->keyboardVtx[phi_t3 + 1].v.cn[3] = + pthis->keyboardVtx[phi_t3 + 2].v.cn[3] = pthis->keyboardVtx[phi_t3 + 3].v.cn[3] = 255; phi_t0 += 0x10; @@ -121,8 +121,8 @@ static s16 D_80812604[] = { * This includes the cursor highlight, the name entry plate and characters, and the buttons. */ void FileChoose_SetNameEntryVtx(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Font* font = &this->font; + FileChooseContext* pthis = (FileChooseContext*)thisx; + Font* font = &pthis->font; s16 phi_s0; s16 phi_t1; u8 temp; @@ -131,12 +131,12 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) { if (1) {} if (1) {} - OPEN_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 205); + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 205); gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); gSPVertex(POLY_OPA_DISP++, D_80811BB0, 24, 0); gDPLoadTextureBlock(POLY_OPA_DISP++, sNameLabelTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_8b, 56, 16, 0, @@ -147,7 +147,7 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) { phi_s0 = 0x10; for (phi_t1 = 0; phi_t1 < 2; phi_t1++, phi_s0 += 4) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], 255); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); gDPLoadTextureBlock(POLY_OPA_DISP++, sBackspaceEndTextures[gSaveContext.language][phi_t1], G_IM_FMT_IA, G_IM_SIZ_16b, sBackspaceEndWidths[phi_t1], 16, 0, G_TX_NOMIRROR | G_TX_WRAP, @@ -155,63 +155,63 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) { gSP1Quadrangle(POLY_OPA_DISP++, phi_s0, phi_s0 + 2, phi_s0 + 3, phi_s0 + 1, 0); } - this->nameEntryVtx = Graph_Alloc(this->state.gfxCtx, 44 * sizeof(Vtx)); + pthis->nameEntryVtx = (Vtx*)Graph_Alloc(pthis->state.gfxCtx, 44 * sizeof(Vtx)); for (phi_s0 = 0, phi_t1 = 0; phi_t1 < 44; phi_t1 += 4, phi_s0++) { if ((phi_s0 > 0) && (phi_s0 < 9)) { - temp = this->fileNames[this->buttonIndex][phi_s0 - 1]; + temp = pthis->fileNames[pthis->buttonIndex][phi_s0 - 1]; - this->nameEntryVtx[phi_t1].v.ob[0] = this->nameEntryVtx[phi_t1 + 2].v.ob[0] = - D_808125EC[phi_s0] + this->nameEntryBoxPosX + D_808124C0[temp]; + pthis->nameEntryVtx[phi_t1].v.ob[0] = pthis->nameEntryVtx[phi_t1 + 2].v.ob[0] = + D_808125EC[phi_s0] + pthis->nameEntryBoxPosX + D_808124C0[temp]; - this->nameEntryVtx[phi_t1 + 1].v.ob[0] = this->nameEntryVtx[phi_t1 + 3].v.ob[0] = - this->nameEntryVtx[phi_t1].v.ob[0] + 0xA; + pthis->nameEntryVtx[phi_t1 + 1].v.ob[0] = pthis->nameEntryVtx[phi_t1 + 3].v.ob[0] = + pthis->nameEntryVtx[phi_t1].v.ob[0] + 0xA; } else { - this->nameEntryVtx[phi_t1].v.ob[0] = this->nameEntryVtx[phi_t1 + 2].v.ob[0] = - D_808125EC[phi_s0] + this->nameEntryBoxPosX; + pthis->nameEntryVtx[phi_t1].v.ob[0] = pthis->nameEntryVtx[phi_t1 + 2].v.ob[0] = + D_808125EC[phi_s0] + pthis->nameEntryBoxPosX; - this->nameEntryVtx[phi_t1 + 1].v.ob[0] = this->nameEntryVtx[phi_t1 + 3].v.ob[0] = - this->nameEntryVtx[phi_t1].v.ob[0] + 0xA; + pthis->nameEntryVtx[phi_t1 + 1].v.ob[0] = pthis->nameEntryVtx[phi_t1 + 3].v.ob[0] = + pthis->nameEntryVtx[phi_t1].v.ob[0] + 0xA; } - this->nameEntryVtx[phi_t1].v.ob[1] = this->nameEntryVtx[phi_t1 + 1].v.ob[1] = D_80812604[phi_s0]; + pthis->nameEntryVtx[phi_t1].v.ob[1] = pthis->nameEntryVtx[phi_t1 + 1].v.ob[1] = D_80812604[phi_s0]; - this->nameEntryVtx[phi_t1 + 2].v.ob[1] = this->nameEntryVtx[phi_t1 + 3].v.ob[1] = - this->nameEntryVtx[phi_t1].v.ob[1] - 0xA; + pthis->nameEntryVtx[phi_t1 + 2].v.ob[1] = pthis->nameEntryVtx[phi_t1 + 3].v.ob[1] = + pthis->nameEntryVtx[phi_t1].v.ob[1] - 0xA; - this->nameEntryVtx[phi_t1].v.ob[2] = this->nameEntryVtx[phi_t1 + 1].v.ob[2] = - this->nameEntryVtx[phi_t1 + 2].v.ob[2] = this->nameEntryVtx[phi_t1 + 3].v.ob[2] = 0; + pthis->nameEntryVtx[phi_t1].v.ob[2] = pthis->nameEntryVtx[phi_t1 + 1].v.ob[2] = + pthis->nameEntryVtx[phi_t1 + 2].v.ob[2] = pthis->nameEntryVtx[phi_t1 + 3].v.ob[2] = 0; - this->nameEntryVtx[phi_t1].v.flag = this->nameEntryVtx[phi_t1 + 1].v.flag = - this->nameEntryVtx[phi_t1 + 2].v.flag = this->nameEntryVtx[phi_t1 + 3].v.flag = 0; + pthis->nameEntryVtx[phi_t1].v.flag = pthis->nameEntryVtx[phi_t1 + 1].v.flag = + pthis->nameEntryVtx[phi_t1 + 2].v.flag = pthis->nameEntryVtx[phi_t1 + 3].v.flag = 0; - this->nameEntryVtx[phi_t1].v.tc[0] = this->nameEntryVtx[phi_t1].v.tc[1] = - this->nameEntryVtx[phi_t1 + 1].v.tc[1] = this->nameEntryVtx[phi_t1 + 2].v.tc[0] = 0; + pthis->nameEntryVtx[phi_t1].v.tc[0] = pthis->nameEntryVtx[phi_t1].v.tc[1] = + pthis->nameEntryVtx[phi_t1 + 1].v.tc[1] = pthis->nameEntryVtx[phi_t1 + 2].v.tc[0] = 0; - this->nameEntryVtx[phi_t1 + 1].v.tc[0] = this->nameEntryVtx[phi_t1 + 2].v.tc[1] = - this->nameEntryVtx[phi_t1 + 3].v.tc[0] = this->nameEntryVtx[phi_t1 + 3].v.tc[1] = 0x200; + pthis->nameEntryVtx[phi_t1 + 1].v.tc[0] = pthis->nameEntryVtx[phi_t1 + 2].v.tc[1] = + pthis->nameEntryVtx[phi_t1 + 3].v.tc[0] = pthis->nameEntryVtx[phi_t1 + 3].v.tc[1] = 0x200; - this->nameEntryVtx[phi_t1].v.cn[0] = this->nameEntryVtx[phi_t1 + 1].v.cn[0] = - this->nameEntryVtx[phi_t1 + 2].v.cn[0] = this->nameEntryVtx[phi_t1 + 3].v.cn[0] = - this->nameEntryVtx[phi_t1].v.cn[1] = this->nameEntryVtx[phi_t1 + 1].v.cn[1] = - this->nameEntryVtx[phi_t1 + 2].v.cn[1] = this->nameEntryVtx[phi_t1 + 3].v.cn[1] = - this->nameEntryVtx[phi_t1].v.cn[2] = this->nameEntryVtx[phi_t1 + 1].v.cn[2] = - this->nameEntryVtx[phi_t1 + 2].v.cn[2] = this->nameEntryVtx[phi_t1 + 3].v.cn[2] = - this->nameEntryVtx[phi_t1].v.cn[3] = this->nameEntryVtx[phi_t1 + 1].v.cn[3] = - this->nameEntryVtx[phi_t1 + 2].v.cn[3] = this->nameEntryVtx[phi_t1 + 3].v.cn[3] = + pthis->nameEntryVtx[phi_t1].v.cn[0] = pthis->nameEntryVtx[phi_t1 + 1].v.cn[0] = + pthis->nameEntryVtx[phi_t1 + 2].v.cn[0] = pthis->nameEntryVtx[phi_t1 + 3].v.cn[0] = + pthis->nameEntryVtx[phi_t1].v.cn[1] = pthis->nameEntryVtx[phi_t1 + 1].v.cn[1] = + pthis->nameEntryVtx[phi_t1 + 2].v.cn[1] = pthis->nameEntryVtx[phi_t1 + 3].v.cn[1] = + pthis->nameEntryVtx[phi_t1].v.cn[2] = pthis->nameEntryVtx[phi_t1 + 1].v.cn[2] = + pthis->nameEntryVtx[phi_t1 + 2].v.cn[2] = pthis->nameEntryVtx[phi_t1 + 3].v.cn[2] = + pthis->nameEntryVtx[phi_t1].v.cn[3] = pthis->nameEntryVtx[phi_t1 + 1].v.cn[3] = + pthis->nameEntryVtx[phi_t1 + 2].v.cn[3] = pthis->nameEntryVtx[phi_t1 + 3].v.cn[3] = 0xFF; } - this->nameEntryVtx[1].v.ob[0] = this->nameEntryVtx[3].v.ob[0] = this->nameEntryVtx[0].v.ob[0] + 0x6C; - this->nameEntryVtx[2].v.ob[1] = this->nameEntryVtx[3].v.ob[1] = this->nameEntryVtx[0].v.ob[1] - 0x10; - this->nameEntryVtx[1].v.tc[0] = this->nameEntryVtx[3].v.tc[0] = 0xD80; + pthis->nameEntryVtx[1].v.ob[0] = pthis->nameEntryVtx[3].v.ob[0] = pthis->nameEntryVtx[0].v.ob[0] + 0x6C; + pthis->nameEntryVtx[2].v.ob[1] = pthis->nameEntryVtx[3].v.ob[1] = pthis->nameEntryVtx[0].v.ob[1] - 0x10; + pthis->nameEntryVtx[1].v.tc[0] = pthis->nameEntryVtx[3].v.tc[0] = 0xD80; gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->nameEntryBoxAlpha); - gSPVertex(POLY_OPA_DISP++, this->nameEntryVtx, 4, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->windowColor[0], pthis->windowColor[1], pthis->windowColor[2], + pthis->nameEntryBoxAlpha); + gSPVertex(POLY_OPA_DISP++, pthis->nameEntryVtx, 4, 0); gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelNameBoxTex, G_IM_FMT_IA, G_IM_SIZ_16b, 108, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -219,130 +219,130 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - gSPVertex(POLY_OPA_DISP++, this->nameEntryVtx + 4, 32, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->nameEntryBoxAlpha); + gSPVertex(POLY_OPA_DISP++, pthis->nameEntryVtx + 4, 32, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->nameEntryBoxAlpha); for (phi_v0 = 0, phi_s0 = 0; phi_s0 < 0x20; phi_s0 += 4, phi_v0++) { - FileChoose_DrawCharacter(this->state.gfxCtx, - font->fontBuf + this->fileNames[this->buttonIndex][phi_v0] * FONT_CHAR_TEX_SIZE, + FileChoose_DrawCharacter(pthis->state.gfxCtx, + font->fontBuf + pthis->fileNames[pthis->buttonIndex][phi_v0] * FONT_CHAR_TEX_SIZE, phi_s0); } - this->nameEntryVtx[0x25].v.tc[0] = this->nameEntryVtx[0x26].v.tc[1] = this->nameEntryVtx[0x27].v.tc[0] = - this->nameEntryVtx[0x27].v.tc[1] = this->nameEntryVtx[0x29].v.tc[0] = this->nameEntryVtx[0x2A].v.tc[1] = - this->nameEntryVtx[0x2B].v.tc[0] = this->nameEntryVtx[0x2B].v.tc[1] = 0x300; + pthis->nameEntryVtx[0x25].v.tc[0] = pthis->nameEntryVtx[0x26].v.tc[1] = pthis->nameEntryVtx[0x27].v.tc[0] = + pthis->nameEntryVtx[0x27].v.tc[1] = pthis->nameEntryVtx[0x29].v.tc[0] = pthis->nameEntryVtx[0x2A].v.tc[1] = + pthis->nameEntryVtx[0x2B].v.tc[0] = pthis->nameEntryVtx[0x2B].v.tc[1] = 0x300; - if ((this->kbdButton == 0) || (this->kbdButton == 1) || (this->kbdButton == 4)) { - this->nameEntryVtx[0x29].v.tc[0] = this->nameEntryVtx[0x2B].v.tc[0] = 0x700; - } else if ((this->kbdButton == 2) || (this->kbdButton == 3)) { - this->nameEntryVtx[0x29].v.tc[0] = this->nameEntryVtx[0x2B].v.tc[0] = 0x500; + if ((pthis->kbdButton == 0) || (pthis->kbdButton == 1) || (pthis->kbdButton == 4)) { + pthis->nameEntryVtx[0x29].v.tc[0] = pthis->nameEntryVtx[0x2B].v.tc[0] = 0x700; + } else if ((pthis->kbdButton == 2) || (pthis->kbdButton == 3)) { + pthis->nameEntryVtx[0x29].v.tc[0] = pthis->nameEntryVtx[0x2B].v.tc[0] = 0x500; } - CLOSE_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 307); + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 307); } void FileChoose_DrawKeyboard(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Font* font = &this->font; + FileChooseContext* pthis = (FileChooseContext*)thisx; + Font* font = &pthis->font; s16 i = 0; s16 tmp; s16 vtx = 0; - OPEN_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 324); + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 324); - func_800949A8(this->state.gfxCtx); + func_800949A8(pthis->state.gfxCtx); gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_XLU_SURF2); gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); - gDPSetPrimColor(POLY_OPA_DISP++, 0, this->charBgAlpha, 255, 255, 255, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, pthis->charBgAlpha, 255, 255, 255, 255); while (vtx < 0x100) { - gSPVertex(POLY_OPA_DISP++, &this->keyboardVtx[vtx], 32, 0); + gSPVertex(POLY_OPA_DISP++, &pthis->keyboardVtx[vtx], 32, 0); for (tmp = 0; tmp < 32; i++, tmp += 4) { - FileChoose_DrawCharacter(this->state.gfxCtx, font->fontBuf + D_808123F0[i] * FONT_CHAR_TEX_SIZE, tmp); + FileChoose_DrawCharacter(pthis->state.gfxCtx, font->fontBuf + D_808123F0[i] * FONT_CHAR_TEX_SIZE, tmp); } vtx += 32; } - gSPVertex(POLY_OPA_DISP++, &this->keyboardVtx[0x100], 4, 0); - FileChoose_DrawCharacter(this->state.gfxCtx, font->fontBuf + D_808123F0[i] * FONT_CHAR_TEX_SIZE, 0); + gSPVertex(POLY_OPA_DISP++, &pthis->keyboardVtx[0x100], 4, 0); + FileChoose_DrawCharacter(pthis->state.gfxCtx, font->fontBuf + D_808123F0[i] * FONT_CHAR_TEX_SIZE, 0); - CLOSE_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 347); + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 347); } void FileChoose_DrawNameEntry(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - Font* font = &this->font; - Input* input = &this->state.input[0]; + FileChooseContext* pthis = (FileChooseContext*)thisx; + Font* font = &pthis->font; + Input* input = &pthis->state.input[0]; s16 i; s16 tmp; u16 dayTime; s16 validName; - OPEN_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 368); + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 368); - FileChoose_SetKeyboardVtx(&this->state); - FileChoose_SetNameEntryVtx(&this->state); - FileChoose_PulsateCursor(&this->state); + FileChoose_SetKeyboardVtx(&pthis->state); + FileChoose_SetNameEntryVtx(&pthis->state); + FileChoose_PulsateCursor(&pthis->state); - tmp = (this->newFileNameCharCount * 4) + 4; - this->nameEntryVtx[36].v.ob[0] = this->nameEntryVtx[38].v.ob[0] = this->nameEntryVtx[tmp].v.ob[0] - 6; - this->nameEntryVtx[37].v.ob[0] = this->nameEntryVtx[39].v.ob[0] = this->nameEntryVtx[36].v.ob[0] + 24; - this->nameEntryVtx[36].v.ob[1] = this->nameEntryVtx[37].v.ob[1] = this->nameEntryVtx[tmp].v.ob[1] + 7; - this->nameEntryVtx[38].v.ob[1] = this->nameEntryVtx[39].v.ob[1] = this->nameEntryVtx[36].v.ob[1] - 24; + tmp = (pthis->newFileNameCharCount * 4) + 4; + pthis->nameEntryVtx[36].v.ob[0] = pthis->nameEntryVtx[38].v.ob[0] = pthis->nameEntryVtx[tmp].v.ob[0] - 6; + pthis->nameEntryVtx[37].v.ob[0] = pthis->nameEntryVtx[39].v.ob[0] = pthis->nameEntryVtx[36].v.ob[0] + 24; + pthis->nameEntryVtx[36].v.ob[1] = pthis->nameEntryVtx[37].v.ob[1] = pthis->nameEntryVtx[tmp].v.ob[1] + 7; + pthis->nameEntryVtx[38].v.ob[1] = pthis->nameEntryVtx[39].v.ob[1] = pthis->nameEntryVtx[36].v.ob[1] - 24; - if ((this->kbdButton == FS_KBD_BTN_HIRA) || (this->kbdButton == FS_KBD_BTN_KATA) || - (this->kbdButton == FS_KBD_BTN_END)) { - if (this->kbdX != this->kbdButton) { - osSyncPrintf("014 xpos=%d contents=%d\n", this->kbdX, this->kbdButton); + if ((pthis->kbdButton == FS_KBD_BTN_HIRA) || (pthis->kbdButton == FS_KBD_BTN_KATA) || + (pthis->kbdButton == FS_KBD_BTN_END)) { + if (pthis->kbdX != pthis->kbdButton) { + osSyncPrintf("014 xpos=%d contents=%d\n", pthis->kbdX, pthis->kbdButton); } - this->nameEntryVtx[40].v.ob[0] = this->nameEntryVtx[42].v.ob[0] = D_80811BB0[(this->kbdX + 1) * 4].v.ob[0] - 4; - this->nameEntryVtx[41].v.ob[0] = this->nameEntryVtx[43].v.ob[0] = this->nameEntryVtx[40].v.ob[0] + 52; - this->nameEntryVtx[40].v.ob[1] = this->nameEntryVtx[41].v.ob[1] = D_80811BB0[(this->kbdX + 1) * 4].v.ob[1] + 4; + pthis->nameEntryVtx[40].v.ob[0] = pthis->nameEntryVtx[42].v.ob[0] = D_80811BB0[(pthis->kbdX + 1) * 4].v.ob[0] - 4; + pthis->nameEntryVtx[41].v.ob[0] = pthis->nameEntryVtx[43].v.ob[0] = pthis->nameEntryVtx[40].v.ob[0] + 52; + pthis->nameEntryVtx[40].v.ob[1] = pthis->nameEntryVtx[41].v.ob[1] = D_80811BB0[(pthis->kbdX + 1) * 4].v.ob[1] + 4; - } else if ((this->kbdButton == FS_KBD_BTN_ENG) || (this->kbdButton == FS_KBD_BTN_BACKSPACE)) { - if (this->kbdX != this->kbdButton) { - osSyncPrintf("23 xpos=%d contents=%d\n", this->kbdX, this->kbdButton); + } else if ((pthis->kbdButton == FS_KBD_BTN_ENG) || (pthis->kbdButton == FS_KBD_BTN_BACKSPACE)) { + if (pthis->kbdX != pthis->kbdButton) { + osSyncPrintf("23 xpos=%d contents=%d\n", pthis->kbdX, pthis->kbdButton); } - this->nameEntryVtx[40].v.ob[0] = this->nameEntryVtx[42].v.ob[0] = D_80811BB0[(this->kbdX + 1) * 4].v.ob[0] - 4; - this->nameEntryVtx[41].v.ob[0] = this->nameEntryVtx[43].v.ob[0] = this->nameEntryVtx[40].v.ob[0] + 40; - this->nameEntryVtx[40].v.ob[1] = this->nameEntryVtx[41].v.ob[1] = D_80811BB0[(this->kbdX + 1) * 4].v.ob[1] + 4; + pthis->nameEntryVtx[40].v.ob[0] = pthis->nameEntryVtx[42].v.ob[0] = D_80811BB0[(pthis->kbdX + 1) * 4].v.ob[0] - 4; + pthis->nameEntryVtx[41].v.ob[0] = pthis->nameEntryVtx[43].v.ob[0] = pthis->nameEntryVtx[40].v.ob[0] + 40; + pthis->nameEntryVtx[40].v.ob[1] = pthis->nameEntryVtx[41].v.ob[1] = D_80811BB0[(pthis->kbdX + 1) * 4].v.ob[1] + 4; } else { - if (this->charIndex >= 65) { - osSyncPrintf("mjp=%d xpos=%d ypos=%d name_contents=%d\n", this->charIndex, this->kbdX, this->kbdY, - this->kbdButton); + if (pthis->charIndex >= 65) { + osSyncPrintf("mjp=%d xpos=%d ypos=%d name_contents=%d\n", pthis->charIndex, pthis->kbdX, pthis->kbdY, + pthis->kbdButton); } - this->nameEntryVtx[40].v.ob[0] = this->nameEntryVtx[42].v.ob[0] = - this->keyboardVtx[this->charIndex * 4].v.ob[0] - D_80812544[this->charIndex] - 6; - this->nameEntryVtx[41].v.ob[0] = this->nameEntryVtx[43].v.ob[0] = this->nameEntryVtx[40].v.ob[0] + 24; - this->nameEntryVtx[40].v.ob[1] = this->nameEntryVtx[41].v.ob[1] = - this->keyboardVtx[this->charIndex * 4].v.ob[1] + 6; + pthis->nameEntryVtx[40].v.ob[0] = pthis->nameEntryVtx[42].v.ob[0] = + pthis->keyboardVtx[pthis->charIndex * 4].v.ob[0] - D_80812544[pthis->charIndex] - 6; + pthis->nameEntryVtx[41].v.ob[0] = pthis->nameEntryVtx[43].v.ob[0] = pthis->nameEntryVtx[40].v.ob[0] + 24; + pthis->nameEntryVtx[40].v.ob[1] = pthis->nameEntryVtx[41].v.ob[1] = + pthis->keyboardVtx[pthis->charIndex * 4].v.ob[1] + 6; } - this->nameEntryVtx[42].v.ob[1] = this->nameEntryVtx[43].v.ob[1] = this->nameEntryVtx[40].v.ob[1] - 24; + pthis->nameEntryVtx[42].v.ob[1] = pthis->nameEntryVtx[43].v.ob[1] = pthis->nameEntryVtx[40].v.ob[1] - 24; - gSPVertex(POLY_OPA_DISP++, &this->nameEntryVtx[36], 8, 0); + gSPVertex(POLY_OPA_DISP++, &pthis->nameEntryVtx[36], 8, 0); gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->highlightColor[0], this->highlightColor[1], this->highlightColor[2], - this->highlightColor[3]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pthis->highlightColor[0], pthis->highlightColor[1], pthis->highlightColor[2], + pthis->highlightColor[3]); gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelCharHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 24, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); - if ((this->kbdButton == FS_KBD_BTN_HIRA) || (this->kbdButton == FS_KBD_BTN_KATA) || - (this->kbdButton == FS_KBD_BTN_END)) { + if ((pthis->kbdButton == FS_KBD_BTN_HIRA) || (pthis->kbdButton == FS_KBD_BTN_KATA) || + (pthis->kbdButton == FS_KBD_BTN_END)) { gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelMediumButtonHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 56, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - } else if ((this->kbdButton == FS_KBD_BTN_ENG) || (this->kbdButton == FS_KBD_BTN_BACKSPACE)) { + } else if ((pthis->kbdButton == FS_KBD_BTN_ENG) || (pthis->kbdButton == FS_KBD_BTN_BACKSPACE)) { gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelSmallButtonHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 40, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -350,94 +350,94 @@ void FileChoose_DrawNameEntry(GameState* thisx) { gSP1Quadrangle(POLY_OPA_DISP++, 4, 6, 7, 5, 0); - FileChoose_DrawKeyboard(&this->state); + FileChoose_DrawKeyboard(&pthis->state); gDPPipeSync(POLY_OPA_DISP++); - func_800949A8(this->state.gfxCtx); + func_800949A8(pthis->state.gfxCtx); gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - if (this->configMode == CM_NAME_ENTRY) { + if (pthis->configMode == CM_NAME_ENTRY) { if (CHECK_BTN_ALL(input->press.button, BTN_START)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); // place cursor on END button - this->kbdY = 5; - this->kbdX = 4; + pthis->kbdY = 5; + pthis->kbdX = 4; } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - if ((this->newFileNameCharCount == 7) && (this->fileNames[this->buttonIndex][7] != 0x3E)) { - for (i = this->newFileNameCharCount; i < 7; i++) { - this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1]; + if ((pthis->newFileNameCharCount == 7) && (pthis->fileNames[pthis->buttonIndex][7] != 0x3E)) { + for (i = pthis->newFileNameCharCount; i < 7; i++) { + pthis->fileNames[pthis->buttonIndex][i] = pthis->fileNames[pthis->buttonIndex][i + 1]; } - this->fileNames[this->buttonIndex][i] = 0x3E; + pthis->fileNames[pthis->buttonIndex][i] = 0x3E; Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - this->newFileNameCharCount--; + pthis->newFileNameCharCount--; - if (this->newFileNameCharCount < 0) { - this->newFileNameCharCount = 0; - this->configMode = CM_NAME_ENTRY_TO_MAIN; + if (pthis->newFileNameCharCount < 0) { + pthis->newFileNameCharCount = 0; + pthis->configMode = CM_NAME_ENTRY_TO_MAIN; } else { - for (i = this->newFileNameCharCount; i < 7; i++) { - this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1]; + for (i = pthis->newFileNameCharCount; i < 7; i++) { + pthis->fileNames[pthis->buttonIndex][i] = pthis->fileNames[pthis->buttonIndex][i + 1]; } - this->fileNames[this->buttonIndex][i] = 0x3E; + pthis->fileNames[pthis->buttonIndex][i] = 0x3E; Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } } } else { - if (this->charPage <= FS_CHAR_PAGE_ENG) { - if (this->kbdY != 5) { + if (pthis->charPage <= FS_CHAR_PAGE_ENG) { + if (pthis->kbdY != 5) { // draw the character the cursor is hovering over in yellow gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); - gSPVertex(POLY_OPA_DISP++, &this->keyboardVtx[this->charIndex * 4], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pthis->keyboardVtx[pthis->charIndex * 4], 4, 0); - FileChoose_DrawCharacter(this->state.gfxCtx, - font->fontBuf + D_808123F0[this->charIndex] * FONT_CHAR_TEX_SIZE, 0); + FileChoose_DrawCharacter(pthis->state.gfxCtx, + font->fontBuf + D_808123F0[pthis->charIndex] * FONT_CHAR_TEX_SIZE, 0); if (CHECK_BTN_ALL(input->press.button, BTN_A)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->fileNames[this->buttonIndex][this->newFileNameCharCount] = D_808123F0[this->charIndex]; - this->newFileNameCharCount++; + pthis->fileNames[pthis->buttonIndex][pthis->newFileNameCharCount] = D_808123F0[pthis->charIndex]; + pthis->newFileNameCharCount++; - if (this->newFileNameCharCount > 7) { - this->newFileNameCharCount = 7; + if (pthis->newFileNameCharCount > 7) { + pthis->newFileNameCharCount = 7; } } - } else if (CHECK_BTN_ALL(input->press.button, BTN_A) && (this->charPage != this->kbdButton)) { - if (this->kbdButton == FS_KBD_BTN_BACKSPACE) { - if ((this->newFileNameCharCount == 7) && (this->fileNames[this->buttonIndex][7] != 0x3E)) { - for (i = this->newFileNameCharCount; i < 7; i++) { - this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1]; + } else if (CHECK_BTN_ALL(input->press.button, BTN_A) && (pthis->charPage != pthis->kbdButton)) { + if (pthis->kbdButton == FS_KBD_BTN_BACKSPACE) { + if ((pthis->newFileNameCharCount == 7) && (pthis->fileNames[pthis->buttonIndex][7] != 0x3E)) { + for (i = pthis->newFileNameCharCount; i < 7; i++) { + pthis->fileNames[pthis->buttonIndex][i] = pthis->fileNames[pthis->buttonIndex][i + 1]; } - this->fileNames[this->buttonIndex][i] = 0x3E; + pthis->fileNames[pthis->buttonIndex][i] = 0x3E; Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - this->newFileNameCharCount--; + pthis->newFileNameCharCount--; - if (this->newFileNameCharCount < 0) { - this->newFileNameCharCount = 0; + if (pthis->newFileNameCharCount < 0) { + pthis->newFileNameCharCount = 0; } - for (i = this->newFileNameCharCount; i < 7; i++) { - this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1]; + for (i = pthis->newFileNameCharCount; i < 7; i++) { + pthis->fileNames[pthis->buttonIndex][i] = pthis->fileNames[pthis->buttonIndex][i + 1]; } - this->fileNames[this->buttonIndex][i] = 0x3E; + pthis->fileNames[pthis->buttonIndex][i] = 0x3E; Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - } else if (this->kbdButton == FS_KBD_BTN_END) { + } else if (pthis->kbdButton == FS_KBD_BTN_END) { validName = false; for (i = 0; i < 8; i++) { - if (this->fileNames[this->buttonIndex][i] != 0x3E) { + if (pthis->fileNames[pthis->buttonIndex][i] != 0x3E) { validName = true; break; } @@ -446,13 +446,13 @@ void FileChoose_DrawNameEntry(GameState* thisx) { if (validName) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - gSaveContext.fileNum = this->buttonIndex; + gSaveContext.fileNum = pthis->buttonIndex; dayTime = ((void)0, gSaveContext.dayTime); - Sram_InitSave(this, &this->sramCtx); + Sram_InitSave(pthis, &pthis->sramCtx); gSaveContext.dayTime = dayTime; - this->configMode = CM_NAME_ENTRY_TO_MAIN; - this->nameBoxAlpha[this->buttonIndex] = this->nameAlpha[this->buttonIndex] = 200; - this->connectorAlpha[this->buttonIndex] = 255; + pthis->configMode = CM_NAME_ENTRY_TO_MAIN; + pthis->nameBoxAlpha[pthis->buttonIndex] = pthis->nameAlpha[pthis->buttonIndex] = 200; + pthis->connectorAlpha[pthis->buttonIndex] = 255; func_800AA000(300.0f, 0xB4, 0x14, 0x64); } else { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, @@ -463,17 +463,17 @@ void FileChoose_DrawNameEntry(GameState* thisx) { if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->newFileNameCharCount++; + pthis->newFileNameCharCount++; - if (this->newFileNameCharCount > 7) { - this->newFileNameCharCount = 7; + if (pthis->newFileNameCharCount > 7) { + pthis->newFileNameCharCount = 7; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->newFileNameCharCount--; + pthis->newFileNameCharCount--; - if (this->newFileNameCharCount < 0) { - this->newFileNameCharCount = 0; + if (pthis->newFileNameCharCount < 0) { + pthis->newFileNameCharCount = 0; } } } @@ -483,7 +483,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); - CLOSE_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 550); + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 550); } /** @@ -492,23 +492,23 @@ void FileChoose_DrawNameEntry(GameState* thisx) { * Update function for `CM_START_NAME_ENTRY` */ void FileChoose_StartNameEntry(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; + FileChooseContext* pthis = (FileChooseContext*)thisx; - this->nameEntryBoxAlpha += 25; + pthis->nameEntryBoxAlpha += 25; - if (this->nameEntryBoxAlpha >= 255) { - this->nameEntryBoxAlpha = 255; + if (pthis->nameEntryBoxAlpha >= 255) { + pthis->nameEntryBoxAlpha = 255; } - this->nameEntryBoxPosX -= 30; + pthis->nameEntryBoxPosX -= 30; - if (this->nameEntryBoxPosX <= 0) { - this->nameEntryBoxPosX = 0; - this->nameEntryBoxAlpha = 255; - this->kbdX = 0; - this->kbdY = 0; - this->kbdButton = 99; - this->configMode = CM_NAME_ENTRY; + if (pthis->nameEntryBoxPosX <= 0) { + pthis->nameEntryBoxPosX = 0; + pthis->nameEntryBoxAlpha = 255; + pthis->kbdX = 0; + pthis->kbdY = 0; + pthis->kbdButton = 99; + pthis->configMode = CM_NAME_ENTRY; } } @@ -519,138 +519,138 @@ void FileChoose_StartNameEntry(GameState* thisx) { * Update function for `CM_NAME_ENTRY` */ void FileChoose_UpdateKeyboardCursor(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; + FileChooseContext* pthis = (FileChooseContext*)thisx; s16 prevKbdX; - this->kbdButton = 99; + pthis->kbdButton = 99; - if (this->kbdY != 5) { - if (this->stickRelX < -30) { + if (pthis->kbdY != 5) { + if (pthis->stickRelX < -30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->charIndex--; - this->kbdX--; - if (this->kbdX < 0) { - this->kbdX = 12; - this->charIndex = (this->kbdY * 13) + this->kbdX; + pthis->charIndex--; + pthis->kbdX--; + if (pthis->kbdX < 0) { + pthis->kbdX = 12; + pthis->charIndex = (pthis->kbdY * 13) + pthis->kbdX; } - } else if (this->stickRelX > 30) { + } else if (pthis->stickRelX > 30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->charIndex++; - this->kbdX++; - if (this->kbdX > 12) { - this->kbdX = 0; - this->charIndex = (this->kbdY * 13) + this->kbdX; + pthis->charIndex++; + pthis->kbdX++; + if (pthis->kbdX > 12) { + pthis->kbdX = 0; + pthis->charIndex = (pthis->kbdY * 13) + pthis->kbdX; } } } else { - if (this->stickRelX < -30) { + if (pthis->stickRelX < -30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->kbdX--; - if (this->kbdX < 3) { - this->kbdX = 4; + pthis->kbdX--; + if (pthis->kbdX < 3) { + pthis->kbdX = 4; } - } else if (this->stickRelX > 30) { + } else if (pthis->stickRelX > 30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->kbdX++; - if (this->kbdX > 4) { - this->kbdX = 3; + pthis->kbdX++; + if (pthis->kbdX > 4) { + pthis->kbdX = 3; } } } - if (this->stickRelY > 30) { + if (pthis->stickRelY > 30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->kbdY--; + pthis->kbdY--; - if (this->kbdY < 0) { + if (pthis->kbdY < 0) { // dont go to bottom row - if (this->kbdX < 8) { - this->kbdY = 4; - this->charIndex = (s32)(this->kbdX + 52); + if (pthis->kbdX < 8) { + pthis->kbdY = 4; + pthis->charIndex = (s32)(pthis->kbdX + 52); } else { - this->kbdY = 5; - this->charIndex += 52; - prevKbdX = this->kbdX; + pthis->kbdY = 5; + pthis->charIndex += 52; + prevKbdX = pthis->kbdX; - if (this->kbdX < 10) { - this->kbdX = 3; - } else if (this->kbdX < 13) { - this->kbdX = 4; + if (pthis->kbdX < 10) { + pthis->kbdX = 3; + } else if (pthis->kbdX < 13) { + pthis->kbdX = 4; } - this->unk_1CAD6[this->kbdX] = prevKbdX; + pthis->unk_1CAD6[pthis->kbdX] = prevKbdX; } } else { - this->charIndex -= 13; + pthis->charIndex -= 13; - if (this->kbdY == 4) { - this->charIndex = 52; - this->kbdX = this->unk_1CAD6[this->kbdX]; - this->charIndex += this->kbdX; + if (pthis->kbdY == 4) { + pthis->charIndex = 52; + pthis->kbdX = pthis->unk_1CAD6[pthis->kbdX]; + pthis->charIndex += pthis->kbdX; } } - } else if (this->stickRelY < -30) { + } else if (pthis->stickRelY < -30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->kbdY++; + pthis->kbdY++; - if (this->kbdY > 5) { - this->kbdY = 0; - this->kbdX = this->unk_1CAD6[this->kbdX]; - this->charIndex = this->kbdX; + if (pthis->kbdY > 5) { + pthis->kbdY = 0; + pthis->kbdX = pthis->unk_1CAD6[pthis->kbdX]; + pthis->charIndex = pthis->kbdX; } else { - this->charIndex += 13; + pthis->charIndex += 13; - if (this->kbdY == 5) { - if (this->kbdX < 8) { - this->kbdY = 0; - this->charIndex = this->kbdX; + if (pthis->kbdY == 5) { + if (pthis->kbdX < 8) { + pthis->kbdY = 0; + pthis->charIndex = pthis->kbdX; } else { - prevKbdX = this->kbdX; + prevKbdX = pthis->kbdX; - if (this->kbdX < 3) { - this->kbdX = 0; - } else if (this->kbdX < 6) { - this->kbdX = 1; - } else if (this->kbdX < 8) { - this->kbdX = 2; - } else if (this->kbdX < 10) { - this->kbdX = 3; - } else if (this->kbdX < 13) { - this->kbdX = 4; + if (pthis->kbdX < 3) { + pthis->kbdX = 0; + } else if (pthis->kbdX < 6) { + pthis->kbdX = 1; + } else if (pthis->kbdX < 8) { + pthis->kbdX = 2; + } else if (pthis->kbdX < 10) { + pthis->kbdX = 3; + } else if (pthis->kbdX < 13) { + pthis->kbdX = 4; } - this->unk_1CAD6[this->kbdX] = prevKbdX; + pthis->unk_1CAD6[pthis->kbdX] = prevKbdX; } } } } - if (this->kbdY == 5) { - this->kbdButton = this->kbdX; + if (pthis->kbdY == 5) { + pthis->kbdButton = pthis->kbdX; } } /** * This function is mostly a copy paste of `FileChoose_StartNameEntry`. * The name entry box fades and slides in even though it is not visible. - * After this is complete, change to the options config mode. + * After pthis is complete, change to the options config mode. * Update function for `CM_START_OPTIONS` */ void FileChoose_StartOptions(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; + FileChooseContext* pthis = (FileChooseContext*)thisx; - this->nameEntryBoxAlpha += 25; + pthis->nameEntryBoxAlpha += 25; - if (this->nameEntryBoxAlpha >= 255) { - this->nameEntryBoxAlpha = 255; + if (pthis->nameEntryBoxAlpha >= 255) { + pthis->nameEntryBoxAlpha = 255; } - this->nameEntryBoxPosX -= 30; + pthis->nameEntryBoxPosX -= 30; - if (this->nameEntryBoxPosX <= 0) { - this->nameEntryBoxPosX = 0; - this->nameEntryBoxAlpha = 255; - this->configMode = CM_OPTIONS_MENU; + if (pthis->nameEntryBoxPosX <= 0) { + pthis->nameEntryBoxPosX = 0; + pthis->nameEntryBoxAlpha = 255; + pthis->configMode = CM_OPTIONS_MENU; } } @@ -663,13 +663,13 @@ static u8 sSelectedSetting; * Update function for `CM_OPTIONS_MENU` */ void FileChoose_UpdateOptionsMenu(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - SramContext* sramCtx = &this->sramCtx; - Input* input = &this->state.input[0]; + FileChooseContext* pthis = (FileChooseContext*)thisx; + SramContext* sramCtx = &pthis->sramCtx; + Input* input = &pthis->state.input[0]; if (CHECK_BTN_ALL(input->press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->configMode = CM_OPTIONS_TO_MAIN; + pthis->configMode = CM_OPTIONS_TO_MAIN; sramCtx->readBuff[0] = gSaveContext.audioSetting; sramCtx->readBuff[1] = gSaveContext.zTargetSetting; osSyncPrintf("SAVE"); @@ -686,7 +686,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) { return; } - if (this->stickRelX < -30) { + if (pthis->stickRelX < -30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (sSelectedSetting == FS_SETTING_AUDIO) { @@ -699,7 +699,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) { } else { gSaveContext.zTargetSetting ^= 1; } - } else if (this->stickRelX > 30) { + } else if (pthis->stickRelX > 30) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (sSelectedSetting == FS_SETTING_AUDIO) { @@ -713,7 +713,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) { } } - if ((this->stickRelY < -30) || (this->stickRelY > 30)) { + if ((pthis->stickRelY < -30) || (pthis->stickRelY > 30)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); sSelectedSetting ^= 1; } else if (CHECK_BTN_ALL(input->press.button, BTN_A)) { @@ -804,7 +804,7 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { { 0, 0, 0 }, { 0, 150, 150 }, }; - FileChooseContext* this = (FileChooseContext*)thisx; + FileChooseContext* pthis = (FileChooseContext*)thisx; s16 cursorRed; s16 cursorGreen; s16 cursorBlue; @@ -812,7 +812,7 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { s16 j; s16 vtx; - OPEN_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 848); + OPEN_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 848); cursorRed = ABS(cursorPrimRed - cursorPrimColors[cursorPulseDir][0]) / cursorFlashTimer; cursorGreen = ABS(cursorPrimGreen - cursorPrimColors[cursorPulseDir][1]) / cursorFlashTimer; @@ -883,7 +883,7 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); for (i = 0, vtx = 0; i < 4; i++, vtx += 4) { @@ -905,14 +905,14 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { if (i == gSaveContext.audioSetting) { if (sSelectedSetting == FS_SETTING_AUDIO) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, cursorPrimRed, cursorPrimGreen, cursorPrimBlue, - this->titleAlpha[0]); + pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, cursorEnvRed, cursorEnvGreen, cursorEnvBlue, 255); } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); } } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 120, 120, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 120, 120, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); } @@ -929,14 +929,14 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { if (i == (gSaveContext.zTargetSetting + 4)) { if (sSelectedSetting != FS_SETTING_AUDIO) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, cursorPrimRed, cursorPrimGreen, cursorPrimBlue, - this->titleAlpha[0]); + pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, cursorEnvRed, cursorEnvGreen, cursorEnvBlue, 0xFF); } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); } } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 120, 120, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 120, 120, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); } @@ -953,14 +953,14 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gFileSelBrightnessCheckTex, G_IM_FMT_IA, 96, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 55, 55, 55, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 55, 55, 55, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 40, 40, 40, 255); gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); vtx += 4; gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 30, 30, 30, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 30, 30, 30, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); @@ -968,7 +968,7 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { // blue divider lines gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 255, 255, this->titleAlpha[0]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 255, 255, pthis->titleAlpha[0]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gFileSelOptionsDividerTex, G_IM_FMT_IA, 256, 2, 0, @@ -977,7 +977,7 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { Matrix_Push(); Matrix_Translate(0.0f, 0.1f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_nameset_PAL.c", 1009), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 1009), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(POLY_OPA_DISP++, gOptionsDividerTopVtx, 4, 0); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); @@ -985,7 +985,7 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { Matrix_Push(); Matrix_Translate(0.0f, 0.2f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_nameset_PAL.c", 1021), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 1021), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(POLY_OPA_DISP++, gOptionsDividerMiddleVtx, 4, 0); @@ -994,13 +994,13 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { Matrix_Push(); Matrix_Translate(0.0f, 0.4f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_file_nameset_PAL.c", 1033), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 1033), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(POLY_OPA_DISP++, gOptionsDividerBottomVtx, 4, 0); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); Matrix_Pop(); - CLOSE_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 1040); + CLOSE_DISPS(pthis->state.gfxCtx, "../z_file_nameset_PAL.c", 1040); } void FileChoose_DrawOptions(GameState* thisx) { diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_data.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_data.cpp similarity index 90% rename from src/overlays/gamestates/ovl_file_choose/z_file_nameset_data.c rename to src/overlays/gamestates/ovl_file_choose/z_file_nameset_data.cpp index 4d8b86625..1249ba425 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_data.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_data.cpp @@ -1,7 +1,7 @@ #include "actor_common.h" #include "file_choose.h" -#include "assets/overlays/ovl_File_Choose/ovl_file_choose.c" +#include "assets/overlays/ovl_File_Choose/ovl_file_choose.cpp" s16 D_808123F0[] = { 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.cpp similarity index 76% rename from src/overlays/gamestates/ovl_opening/z_opening.c rename to src/overlays/gamestates/ovl_opening/z_opening.cpp index 518027662..3c67ae86b 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.cpp @@ -21,7 +21,7 @@ #define USE_INTRO_CS #define CHILD_GAMEPLAY -void Opening_SetupTitleScreen(OpeningContext* this) { +void Opening_SetupTitleScreen(OpeningContext* pthis) { #ifndef USE_INTRO_CS Sram_InitDebugSave(); gSaveContext.gameMode = 0; @@ -54,40 +54,40 @@ void Opening_SetupTitleScreen(OpeningContext* this) { #else gSaveContext.linkAge = 0; #endif - this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); + pthis->state.running = false; + SET_NEXT_GAMESTATE(&pthis->state, Gameplay_Init, GlobalContext); #else gSaveContext.gameMode = 1; - this->state.running = false; + pthis->state.running = false; gSaveContext.linkAge = 0; Sram_InitDebugSave(); gSaveContext.cutsceneIndex = 0xFFF3; gSaveContext.sceneSetupIndex = 7; //gSaveContext.sceneSetupIndex = 0xC; - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); + SET_NEXT_GAMESTATE(&pthis->state, Gameplay_Init, GlobalContext); #endif } -void func_80803C5C(OpeningContext* this) { +void func_80803C5C(OpeningContext* pthis) { } void Opening_Main(GameState* thisx) { - OpeningContext* this = (OpeningContext*)thisx; + OpeningContext* pthis = (OpeningContext*)thisx; - Gfx_ClearDisplay(this->state.gfxCtx, 0, 0, 0); - Opening_SetupTitleScreen(this); - func_80803C5C(this); + Gfx_ClearDisplay(pthis->state.gfxCtx, 0, 0, 0); + Opening_SetupTitleScreen(pthis); + func_80803C5C(pthis); } void Opening_Destroy(GameState* thisx) { } void Opening_Init(GameState* thisx) { - OpeningContext* this = (OpeningContext*)thisx; + OpeningContext* pthis = (OpeningContext*)thisx; R_UPDATE_RATE = 1; - Matrix_Init(&this->state); - View_Init(&this->view, this->state.gfxCtx); - this->state.main = Opening_Main; - this->state.destroy = Opening_Destroy; + Matrix_Init(&pthis->state); + View_Init(&pthis->view, pthis->state.gfxCtx); + pthis->state.main = Opening_Main; + pthis->state.destroy = Opening_Destroy; } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.cpp similarity index 79% rename from src/overlays/gamestates/ovl_select/z_select.c rename to src/overlays/gamestates/ovl_select/z_select.cpp index 2b309a74b..71b3fd06a 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.cpp @@ -5,6 +5,7 @@ #include "z_kankyo.h" #include "z_player.h" #include "gfxprint.h" +#include /* * File: z_select.c * Overlay: ovl_select @@ -31,12 +32,12 @@ #include "def/z_view.h" #include "def/z_play.h" // FORCE -void Select_LoadTitle(SelectContext* this) { - this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Title_Init, TitleContext); +void Select_LoadTitle(SelectContext* pthis, s32 entranceIndex) { + pthis->state.running = false; + SET_NEXT_GAMESTATE(&pthis->state, Title_Init, TitleContext); } -void Select_LoadGame(SelectContext* this, s32 entranceIndex) { +void Select_LoadGame(SelectContext* pthis, s32 entranceIndex) { osSyncPrintf(VT_FGCOL(BLUE)); osSyncPrintf("\n\n\nFILE_NO=%x\n\n\n", gSaveContext.fileNum); osSyncPrintf(VT_RST); @@ -58,8 +59,8 @@ void Select_LoadGame(SelectContext* this, s32 entranceIndex) { gSaveContext.natureAmbienceId = 0xFF; gSaveContext.showTitleCard = true; gWeatherMode = 0; - this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); + pthis->state.running = false; + SET_NEXT_GAMESTATE(&pthis->state, Gameplay_Init, GlobalContext); } // "Translation" (Actual name) @@ -315,19 +316,19 @@ static SceneSelectEntry sScenes[] = { // "125: Hyrule Garden Game 2" (Early Hyrule Garden Game) { "125: Early Hyrule Garden Game", Select_LoadGame, 0x0076 }, // "title" (Title Screen) - { "title", (void*)Select_LoadTitle, 0x0000 }, + { "title", Select_LoadTitle, 0x0000 }, }; -void Select_UpdateMenu(SelectContext* this) { - Input* input = &this->state.input[0]; +void Select_UpdateMenu(SelectContext* pthis) { + Input* input = &pthis->state.input[0]; s32 pad; SceneSelectEntry* selectedScene; - if (this->verticalInputAccumulator == 0) { + if (pthis->verticalInputAccumulator == 0) { if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START)) { - selectedScene = &this->scenes[this->currentScene]; + selectedScene = &pthis->scenes[pthis->currentScene]; if (selectedScene->loadFunc != NULL) { - selectedScene->loadFunc(this, selectedScene->entranceIndex); + selectedScene->loadFunc(pthis, selectedScene->entranceIndex); } } @@ -403,118 +404,118 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { - if (this->lockUp == true) { - this->timerUp = 0; + if (pthis->lockUp == true) { + pthis->timerUp = 0; } - if (this->timerUp == 0) { - this->timerUp = 20; - this->lockUp = true; + if (pthis->timerUp == 0) { + pthis->timerUp = 20; + pthis->lockUp = true; Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->verticalInput = R_UPDATE_RATE; + pthis->verticalInput = R_UPDATE_RATE; } } - if (CHECK_BTN_ALL(input->cur.button, BTN_CUP) && this->timerUp == 0) { + if (CHECK_BTN_ALL(input->cur.button, BTN_CUP) && pthis->timerUp == 0) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->verticalInput = R_UPDATE_RATE * 3; + pthis->verticalInput = R_UPDATE_RATE * 3; } if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { - if (this->lockDown == true) { - this->timerDown = 0; + if (pthis->lockDown == true) { + pthis->timerDown = 0; } - if (this->timerDown == 0) { - this->timerDown = 20; - this->lockDown = true; + if (pthis->timerDown == 0) { + pthis->timerDown = 20; + pthis->lockDown = true; Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->verticalInput = -R_UPDATE_RATE; + pthis->verticalInput = -R_UPDATE_RATE; } } - if (CHECK_BTN_ALL(input->cur.button, BTN_CDOWN) && (this->timerDown == 0)) { + if (CHECK_BTN_ALL(input->cur.button, BTN_CDOWN) && (pthis->timerDown == 0)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->verticalInput = -R_UPDATE_RATE * 3; + pthis->verticalInput = -R_UPDATE_RATE * 3; } if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT) || CHECK_BTN_ALL(input->cur.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->verticalInput = R_UPDATE_RATE; + pthis->verticalInput = R_UPDATE_RATE; } if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT) || CHECK_BTN_ALL(input->cur.button, BTN_CRIGHT)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->verticalInput = -R_UPDATE_RATE; + pthis->verticalInput = -R_UPDATE_RATE; } } if (CHECK_BTN_ALL(input->press.button, BTN_L)) { - this->pageDownIndex++; - this->pageDownIndex = - (this->pageDownIndex + ARRAY_COUNT(this->pageDownStops)) % ARRAY_COUNT(this->pageDownStops); - this->currentScene = this->topDisplayedScene = this->pageDownStops[this->pageDownIndex]; + pthis->pageDownIndex++; + pthis->pageDownIndex = + (pthis->pageDownIndex + ARRAY_COUNT(pthis->pageDownStops)) % ARRAY_COUNT(pthis->pageDownStops); + pthis->currentScene = pthis->topDisplayedScene = pthis->pageDownStops[pthis->pageDownIndex]; } - this->verticalInputAccumulator += this->verticalInput; + pthis->verticalInputAccumulator += pthis->verticalInput; - if (this->verticalInputAccumulator < -7) { - this->verticalInput = 0; - this->verticalInputAccumulator = 0; + if (pthis->verticalInputAccumulator < -7) { + pthis->verticalInput = 0; + pthis->verticalInputAccumulator = 0; - this->currentScene++; - this->currentScene = (this->currentScene + this->count) % this->count; + pthis->currentScene++; + pthis->currentScene = (pthis->currentScene + pthis->count) % pthis->count; - if (this->currentScene == ((this->topDisplayedScene + this->count + 19) % this->count)) { - this->topDisplayedScene++; - this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + if (pthis->currentScene == ((pthis->topDisplayedScene + pthis->count + 19) % pthis->count)) { + pthis->topDisplayedScene++; + pthis->topDisplayedScene = (pthis->topDisplayedScene + pthis->count) % pthis->count; } } - if (this->verticalInputAccumulator > 7) { - this->verticalInput = 0; - this->verticalInputAccumulator = 0; + if (pthis->verticalInputAccumulator > 7) { + pthis->verticalInput = 0; + pthis->verticalInputAccumulator = 0; - if (this->currentScene == this->topDisplayedScene) { - this->topDisplayedScene -= 2; - this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + if (pthis->currentScene == pthis->topDisplayedScene) { + pthis->topDisplayedScene -= 2; + pthis->topDisplayedScene = (pthis->topDisplayedScene + pthis->count) % pthis->count; } - this->currentScene--; - this->currentScene = (this->currentScene + this->count) % this->count; + pthis->currentScene--; + pthis->currentScene = (pthis->currentScene + pthis->count) % pthis->count; - if (this->currentScene == ((this->topDisplayedScene + this->count) % this->count)) { - this->topDisplayedScene--; - this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + if (pthis->currentScene == ((pthis->topDisplayedScene + pthis->count) % pthis->count)) { + pthis->topDisplayedScene--; + pthis->topDisplayedScene = (pthis->topDisplayedScene + pthis->count) % pthis->count; } } - this->currentScene = (this->currentScene + this->count) % this->count; - this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + pthis->currentScene = (pthis->currentScene + pthis->count) % pthis->count; + pthis->topDisplayedScene = (pthis->topDisplayedScene + pthis->count) % pthis->count; - dREG(80) = this->currentScene; - dREG(81) = this->topDisplayedScene; - dREG(82) = this->pageDownIndex; + dREG(80) = pthis->currentScene; + dREG(81) = pthis->topDisplayedScene; + dREG(82) = pthis->pageDownIndex; - if (this->timerUp != 0) { - this->timerUp--; + if (pthis->timerUp != 0) { + pthis->timerUp--; } - if (this->timerUp == 0) { - this->lockUp = false; + if (pthis->timerUp == 0) { + pthis->lockUp = false; } - if (this->timerDown != 0) { - this->timerDown--; + if (pthis->timerDown != 0) { + pthis->timerDown--; } - if (this->timerDown == 0) { - this->lockDown = false; + if (pthis->timerDown == 0) { + pthis->lockDown = false; } } -void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { +void Select_PrintMenu(SelectContext* pthis, GfxPrint* printer) { s32 scene; s32 i; - char* name; + const char* name; GfxPrint_SetColor(printer, 255, 155, 150, 255); GfxPrint_SetPos(printer, 12, 2); @@ -524,14 +525,14 @@ void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { for (i = 0; i < 20; i++) { GfxPrint_SetPos(printer, 9, i + 4); - scene = (this->topDisplayedScene + i + this->count) % this->count; - if (scene == this->currentScene) { + scene = (pthis->topDisplayedScene + i + pthis->count) % pthis->count; + if (scene == pthis->currentScene) { GfxPrint_SetColor(printer, 255, 20, 20, 255); } else { GfxPrint_SetColor(printer, 200, 200, 55, 255); } - name = this->scenes[scene].name; + name = pthis->scenes[scene].name; if (name == NULL) { name = "**Null**"; } @@ -567,7 +568,7 @@ static const char* sLoadingMessages[] = { "Don't worry, don't worry. Take a break, take a break.", }; -void Select_PrintLoadingMessage(SelectContext* this, GfxPrint* printer) { +void Select_PrintLoadingMessage(SelectContext* pthis, GfxPrint* printer) { s32 randomMsg; GfxPrint_SetPos(printer, 10, 15); @@ -581,14 +582,14 @@ static const char* sAgeLabels[] = { "5(Young)", }; -void Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 age) { +void Select_PrintAgeSetting(SelectContext* pthis, GfxPrint* printer, s32 age) { GfxPrint_SetPos(printer, 4, 26); GfxPrint_SetColor(printer, 255, 255, 55, 255); GfxPrint_Printf(printer, "Age:%s", sAgeLabels[age]); } -void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csIndex) { - char* label = NULL; +void Select_PrintCutsceneSetting(SelectContext* pthis, GfxPrint* printer, u16 csIndex) { + const char* label = NULL; GfxPrint_SetPos(printer, 4, 25); GfxPrint_SetColor(printer, 255, 255, 55, 255); @@ -639,76 +640,76 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI GfxPrint_Printf(printer, "Stage:" GFXP_KATAKANA "%s", label); } -void Select_DrawMenu(SelectContext* this) { - GraphicsContext* gfxCtx = this->state.gfxCtx; +void Select_DrawMenu(SelectContext* pthis) { + GraphicsContext* gfxCtx = pthis->state.gfxCtx; GfxPrint* printer; OPEN_DISPS(gfxCtx, "../z_select.c", 930); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); Gfx_ClearDisplay(gfxCtx, 0, 0, 0); - SET_FULLSCREEN_VIEWPORT(&this->view); - func_800AAA50(&this->view, 0xF); + SET_FULLSCREEN_VIEWPORT(&pthis->view); + func_800AAA50(&pthis->view, 0xF); func_80094140(gfxCtx); - printer = alloca(sizeof(GfxPrint)); + printer = (GfxPrint*)alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); GfxPrint_Open(printer, POLY_OPA_DISP); - Select_PrintMenu(this, printer); - Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.linkAge)); - Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.cutsceneIndex)); + Select_PrintMenu(pthis, printer); + Select_PrintAgeSetting(pthis, printer, ((void)0, gSaveContext.linkAge)); + Select_PrintCutsceneSetting(pthis, printer, ((void)0, gSaveContext.cutsceneIndex)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); CLOSE_DISPS(gfxCtx, "../z_select.c", 966); } -void Select_DrawLoadingScreen(SelectContext* this) { - GraphicsContext* gfxCtx = this->state.gfxCtx; +void Select_DrawLoadingScreen(SelectContext* pthis) { + GraphicsContext* gfxCtx = pthis->state.gfxCtx; GfxPrint* printer; OPEN_DISPS(gfxCtx, "../z_select.c", 977); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); Gfx_ClearDisplay(gfxCtx, 0, 0, 0); - SET_FULLSCREEN_VIEWPORT(&this->view); - func_800AAA50(&this->view, 0xF); + SET_FULLSCREEN_VIEWPORT(&pthis->view); + func_800AAA50(&pthis->view, 0xF); func_80094140(gfxCtx); - printer = alloca(sizeof(GfxPrint)); + printer = (GfxPrint*)alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); GfxPrint_Open(printer, POLY_OPA_DISP); - Select_PrintLoadingMessage(this, printer); + Select_PrintLoadingMessage(pthis, printer); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); CLOSE_DISPS(gfxCtx, "../z_select.c", 1006); } -void Select_Draw(SelectContext* this) { - GraphicsContext* gfxCtx = this->state.gfxCtx; +void Select_Draw(SelectContext* pthis) { + GraphicsContext* gfxCtx = pthis->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_select.c", 1013); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); Gfx_ClearDisplay(gfxCtx, 0, 0, 0); - SET_FULLSCREEN_VIEWPORT(&this->view); - func_800AAA50(&this->view, 0xF); + SET_FULLSCREEN_VIEWPORT(&pthis->view); + func_800AAA50(&pthis->view, 0xF); - if (!this->state.running) { - Select_DrawLoadingScreen(this); + if (!pthis->state.running) { + Select_DrawLoadingScreen(pthis); } else { - Select_DrawMenu(this); + Select_DrawMenu(pthis); } CLOSE_DISPS(gfxCtx, "../z_select.c", 1037); } void Select_Main(GameState* thisx) { - SelectContext* this = (SelectContext*)thisx; + SelectContext* pthis = (SelectContext*)thisx; - Select_UpdateMenu(this); - Select_Draw(this); + Select_UpdateMenu(pthis); + Select_Draw(pthis); } void Select_Destroy(GameState* thisx) { @@ -718,46 +719,46 @@ void Select_Destroy(GameState* thisx) { } void Select_Init(GameState* thisx) { - SelectContext* this = (SelectContext*)thisx; + SelectContext* pthis = (SelectContext*)thisx; u32 size; s32 pad; - this->state.main = Select_Main; - this->state.destroy = Select_Destroy; - this->scenes = sScenes; - this->topDisplayedScene = 0; - this->currentScene = 0; - this->pageDownStops[0] = 0; // Hyrule Field - this->pageDownStops[1] = 19; // Temple Of Time - this->pageDownStops[2] = 37; // Treasure Chest Game - this->pageDownStops[3] = 51; // Gravekeeper's Hut - this->pageDownStops[4] = 59; // Zora Shop - this->pageDownStops[5] = 73; // Bottom of the Well - this->pageDownStops[6] = 91; // Escaping Ganon's Tower 3 - this->pageDownIndex = 0; - this->opt = 0; - this->count = ARRAY_COUNT(sScenes); - View_Init(&this->view, this->state.gfxCtx); - this->view.flags = (0x08 | 0x02); - this->verticalInputAccumulator = 0; - this->verticalInput = 0; - this->timerUp = 0; - this->timerDown = 0; - this->lockUp = 0; - this->lockDown = 0; - this->unk_234 = 0; + pthis->state.main = Select_Main; + pthis->state.destroy = Select_Destroy; + pthis->scenes = sScenes; + pthis->topDisplayedScene = 0; + pthis->currentScene = 0; + pthis->pageDownStops[0] = 0; // Hyrule Field + pthis->pageDownStops[1] = 19; // Temple Of Time + pthis->pageDownStops[2] = 37; // Treasure Chest Game + pthis->pageDownStops[3] = 51; // Gravekeeper's Hut + pthis->pageDownStops[4] = 59; // Zora Shop + pthis->pageDownStops[5] = 73; // Bottom of the Well + pthis->pageDownStops[6] = 91; // Escaping Ganon's Tower 3 + pthis->pageDownIndex = 0; + pthis->opt = 0; + pthis->count = ARRAY_COUNT(sScenes); + View_Init(&pthis->view, pthis->state.gfxCtx); + pthis->view.flags = (0x08 | 0x02); + pthis->verticalInputAccumulator = 0; + pthis->verticalInput = 0; + pthis->timerUp = 0; + pthis->timerDown = 0; + pthis->lockUp = 0; + pthis->lockDown = 0; + pthis->unk_234 = 0; size = POINTER_SUB(_z_select_staticSegmentRomEnd, _z_select_staticSegmentRomStart); - if ((dREG(80) >= 0) && (dREG(80) < this->count)) { - this->currentScene = dREG(80); - this->topDisplayedScene = dREG(81); - this->pageDownIndex = dREG(82); + if ((dREG(80) >= 0) && (dREG(80) < pthis->count)) { + pthis->currentScene = dREG(80); + pthis->topDisplayedScene = dREG(81); + pthis->pageDownIndex = dREG(82); } R_UPDATE_RATE = 1; - this->staticSegment = GameState_Alloc(&this->state, size, "../z_select.c", 1114); - DmaMgr_SendRequest1(this->staticSegment, _z_select_staticSegmentRomStart, size, "../z_select.c", 1115); + pthis->staticSegment = (u8*)GameState_Alloc(&pthis->state, size, "../z_select.c", 1114); + DmaMgr_SendRequest1(pthis->staticSegment, _z_select_staticSegmentRomStart, size, "../z_select.c", 1115); gSaveContext.cutsceneIndex = 0x8000; gSaveContext.linkAge = 1; } diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.cpp similarity index 60% rename from src/overlays/gamestates/ovl_title/z_title.c rename to src/overlays/gamestates/ovl_title/z_title.cpp index 986f306cc..3080d17a6 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.cpp @@ -2,15 +2,17 @@ #include "actor_common.h" #include "z_title.h" #include "z_opening.h" +#include /* * File: z_title.c * Overlay: ovl_title * Description: Displays the Nintendo Logo */ -extern u8 gBuildTeam[]; -extern u8 gBuildDate[]; -extern u8 gBuildTime[]; +const char gBuildTeam[] = "Open Ocarina Team"; +const char gBuildDate[] = __DATE__; +const char gBuildTime[] = __TIME__; +const char gBuildMakeOption[] = ""; #include "global.h" #include "segment_symbols.h" @@ -36,7 +38,7 @@ void Title_PrintBuildInfo(Gfx** gfxp) { g = *gfxp; g = func_8009411C(g); - printer = alloca(sizeof(GfxPrint)); + printer = (GfxPrint*)alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); GfxPrint_Open(printer, g); GfxPrint_SetColor(printer, 255, 155, 255, 255); @@ -52,40 +54,40 @@ void Title_PrintBuildInfo(Gfx** gfxp) { *gfxp = g; } -// Note: In other rom versions this function also updates unk_1D4, coverAlpha, addAlpha, visibleDuration to calculate +// Note: In other rom versions pthis function also updates unk_1D4, coverAlpha, addAlpha, visibleDuration to calculate // the fade-in/fade-out + the duration of the n64 logo animation -void Title_Calc(TitleContext* this) { - Input* input = &this->state.input[0]; +void Title_Calc(TitleContext* pthis) { + Input* input = &pthis->state.input[0]; if (CHECK_BTN_ALL(input->press.button, BTN_START)) { - this->exit = true; + pthis->exit = true; } - if (this->coverAlpha == 0 && this->visibleDuration != 0) { - this->visibleDuration--; - this->unk_1D4--; - if (this->unk_1D4 == 0) { - this->unk_1D4 = 0x190; + if (pthis->coverAlpha == 0 && pthis->visibleDuration != 0) { + pthis->visibleDuration--; + pthis->unk_1D4--; + if (pthis->unk_1D4 == 0) { + pthis->unk_1D4 = 0x190; } } else { - this->coverAlpha += this->addAlpha; + pthis->coverAlpha += pthis->addAlpha; - if (this->coverAlpha <= 0) { - this->coverAlpha = 0; - this->addAlpha = 3; - } else if (this->coverAlpha >= 0xFF) { - this->coverAlpha = 0xFF; - this->exit = true; + if (pthis->coverAlpha <= 0) { + pthis->coverAlpha = 0; + pthis->addAlpha = 3; + } else if (pthis->coverAlpha >= 0xFF) { + pthis->coverAlpha = 0xFF; + pthis->exit = true; } } - this->uls = this->ult & 0x7F; - this->ult++; - //this->exit = true; + pthis->uls = pthis->ult & 0x7F; + pthis->ult++; + //pthis->exit = true; } -void Title_SetupView(TitleContext* this, f32 x, f32 y, f32 z) { - View* view = &this->view; +void Title_SetupView(TitleContext* pthis, f32 x, f32 y, f32 z) { + View* view = &pthis->view; Vec3f eye; Vec3f lookAt; Vec3f up; @@ -102,7 +104,7 @@ void Title_SetupView(TitleContext* this, f32 x, f32 y, f32 z) { func_800AAA50(view, 0xF); } -void Title_Draw(TitleContext* this) { +void Title_Draw(TitleContext* pthis) { static s16 sTitleRotY = 0; static Lights1 sTitleLights = gdSPDefLights1(0x64, 0x64, 0x64, 0xFF, 0xFF, 0xFF, 0x45, 0x45, 0x45); @@ -114,7 +116,7 @@ void Title_Draw(TitleContext* this) { Vec3f v2; s32 pad2[2]; - OPEN_DISPS(this->state.gfxCtx, "../z_title.c", 395); + OPEN_DISPS(pthis->state.gfxCtx, "../z_title.c", 395); v3.x = 69; v3.y = 69; @@ -126,17 +128,17 @@ void Title_Draw(TitleContext* this) { v1.z = 0; v2.z = 1119.0837; - func_8002EABC(&v1, &v2, &v3, this->state.gfxCtx); + func_8002EABC(&v1, &v2, &v3, pthis->state.gfxCtx); gSPSetLights1(POLY_OPA_DISP++, sTitleLights); - Title_SetupView(this, 0, 150.0, 300.0); - func_80093D18(this->state.gfxCtx); + Title_SetupView(pthis, 0, 150.0, 300.0); + func_80093D18(pthis->state.gfxCtx); Matrix_Translate(-53.0, -5.0, 0, MTXMODE_NEW); Matrix_Scale(1.0, 1.0, 1.0, MTXMODE_APPLY); Matrix_RotateZYX(0, sTitleRotY, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx, "../z_title.c", 424), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(pthis->state.gfxCtx, "../z_title.c", 424), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoDL); - func_800944C4(this->state.gfxCtx); + func_800944C4(pthis->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF2, G_RM_OPA_CI | CVG_DST_WRAP); @@ -153,27 +155,27 @@ void Title_Draw(TitleContext* this) { G_IM_SIZ_8b, 192, 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPSetTileSize(POLY_OPA_DISP++, 1, this->uls, (this->ult & 0x7F) - idx * 4, 0, 0); + gDPSetTileSize(POLY_OPA_DISP++, 1, pthis->uls, (pthis->ult & 0x7F) - idx * 4, 0, 0); gSPTextureRectangle(POLY_OPA_DISP++, 388, y << 2, 1156, (y + 2) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } - Environment_FillScreen(this->state.gfxCtx, 0, 0, 0, (s16)this->coverAlpha, FILL_SCREEN_XLU); + Environment_FillScreen(pthis->state.gfxCtx, 0, 0, 0, (s16)pthis->coverAlpha, FILL_SCREEN_XLU); sTitleRotY += 300; - CLOSE_DISPS(this->state.gfxCtx, "../z_title.c", 483); + CLOSE_DISPS(pthis->state.gfxCtx, "../z_title.c", 483); } void Title_Main(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; + TitleContext* pthis = (TitleContext*)thisx; - OPEN_DISPS(this->state.gfxCtx, "../z_title.c", 494); + OPEN_DISPS(pthis->state.gfxCtx, "../z_title.c", 494); gSPSegment(POLY_OPA_DISP++, 0, NULL); - gSPSegment(POLY_OPA_DISP++, 1, this->staticSegment); - Gfx_ClearDisplay(this->state.gfxCtx, 0, 0, 0); - Title_Calc(this); - Title_Draw(this); + gSPSegment(POLY_OPA_DISP++, 1, pthis->staticSegment); + Gfx_ClearDisplay(pthis->state.gfxCtx, 0, 0, 0); + Title_Calc(pthis); + Title_Draw(pthis); if (gIsCtrlr2Valid || 1) { Gfx* gfx = POLY_OPA_DISP; @@ -183,41 +185,41 @@ void Title_Main(GameState* thisx) { POLY_OPA_DISP = gfx; } - if (this->exit) { + if (pthis->exit) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = 0xFF; gSaveContext.gameMode = 1; - this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext); + pthis->state.running = false; + SET_NEXT_GAMESTATE(&pthis->state, Opening_Init, OpeningContext); } - CLOSE_DISPS(this->state.gfxCtx, "../z_title.c", 541); + CLOSE_DISPS(pthis->state.gfxCtx, "../z_title.c", 541); } void Title_Destroy(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; + TitleContext* pthis = (TitleContext*)thisx; - Sram_InitSram(&this->state, &this->sramCtx); + Sram_InitSram(&pthis->state, &pthis->sramCtx); } void Title_Init(GameState* thisx) { size_t size = POINTER_SUB(_nintendo_rogo_staticSegmentRomEnd, _nintendo_rogo_staticSegmentRomStart); - TitleContext* this = (TitleContext*)thisx; + TitleContext* pthis = (TitleContext*)thisx; - //this->staticSegment = GameState_Alloc(&this->state, size, "../z_title.c", 611); + //pthis->staticSegment = GameState_Alloc(&pthis->state, size, "../z_title.c", 611); osSyncPrintf("z_title.c\n"); - this->staticSegment = _nintendo_rogo_staticSegmentRomStart; + pthis->staticSegment = _nintendo_rogo_staticSegmentRomStart; R_UPDATE_RATE = 1; - Matrix_Init(&this->state); - View_Init(&this->view, this->state.gfxCtx); - this->state.main = Title_Main; - this->state.destroy = Title_Destroy; - this->exit = false; + Matrix_Init(&pthis->state); + View_Init(&pthis->view, pthis->state.gfxCtx); + pthis->state.main = Title_Main; + pthis->state.destroy = Title_Destroy; + pthis->exit = false; gSaveContext.fileNum = 0xFF; - Sram_Alloc(&this->state, &this->sramCtx); - this->ult = 0; - this->unk_1D4 = 0x14; - this->coverAlpha = 255; - this->addAlpha = -3; - this->visibleDuration = 0x3C; + Sram_Alloc(&pthis->state, &pthis->sramCtx); + pthis->ult = 0; + pthis->unk_1D4 = 0x14; + pthis->coverAlpha = 255; + pthis->addAlpha = -3; + pthis->visibleDuration = 0x3C; } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.cpp diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.cpp diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.cpp similarity index 99% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.cpp index b2a5099d7..0233749fc 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.cpp @@ -42,7 +42,7 @@ void KaleidoScope_DrawEquipmentImage(GlobalContext* globalCtx, void* source, u32 gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - curTexture = source; + curTexture = (u8*)source; remainingSize = width * height * 2; textureHeight = 4096 / (width * 2); textureSize = width * textureHeight * 2; @@ -584,8 +584,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { } if ((pauseCtx->unk_1E4 == 7) && (sEquipTimer == 9)) { - //! @bug: This function shouldn't take any arguments - KaleidoScope_ProcessPlayerPreRender(globalCtx); + KaleidoScope_ProcessPlayerPreRender(); } gSPSegment(POLY_OPA_DISP++, 0x07, pauseCtx->playerSegment); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.cpp diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.cpp diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.cpp diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.cpp similarity index 98% rename from src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c rename to src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.cpp index ee7b7118f..e2ae7f15d 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.cpp @@ -276,7 +276,7 @@ void KaleidoScope_SetupGrayIcons() { s16 i; for (i = 0; i < ARRAY_COUNTU(gItemAgeReqs); i++) { if (gItemAgeReqs[i] != 9) { - KaleidoScope_GrayOutTextureRGBA32(SEGMENTED_TO_VIRTUAL(gItemIcons[i]), SEGMENTED_TO_VIRTUAL(gItemIconsGray[i]), 32*32); + KaleidoScope_GrayOutTextureRGBA32((u32*)SEGMENTED_TO_VIRTUAL(gItemIcons[i]), (u32*)SEGMENTED_TO_VIRTUAL(gItemIconsGray[i]), 32*32); } } } @@ -667,8 +667,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1173), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, - sSelectItemTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, (void**)sSelectItemTexs[gSaveContext.language]); // TODO CHECK KaleidoScope_DrawItemSelect(globalCtx); } @@ -685,8 +684,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1196), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->equipPageVtx, - sEquipmentTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->equipPageVtx, (void**)sEquipmentTexs[gSaveContext.language]); KaleidoScope_DrawEquipment(globalCtx); } @@ -704,8 +702,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1220), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, - sQuestStatusTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, (void**)sQuestStatusTexs[gSaveContext.language]); KaleidoScope_DrawQuestStatus(globalCtx, gfxCtx); } @@ -723,8 +720,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1243), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = - KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, (void**)sMapTexs[gSaveContext.language]); if (sInDungeonScene) { KaleidoScope_DrawDungeonMap(globalCtx, gfxCtx); @@ -752,8 +748,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1281), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, - sSelectItemTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, (void**)sSelectItemTexs[gSaveContext.language]); KaleidoScope_DrawItemSelect(globalCtx); break; @@ -767,8 +762,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1303), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = - KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, (void**)sMapTexs[gSaveContext.language]); if (sInDungeonScene) { KaleidoScope_DrawDungeonMap(globalCtx, gfxCtx); @@ -799,8 +793,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1343), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, - sQuestStatusTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, (void**)sQuestStatusTexs[gSaveContext.language]); KaleidoScope_DrawQuestStatus(globalCtx, gfxCtx); @@ -818,8 +811,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1367), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->equipPageVtx, - sEquipmentTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->equipPageVtx, (void**)sEquipmentTexs[gSaveContext.language]); KaleidoScope_DrawEquipment(globalCtx); @@ -872,8 +864,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { if ((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11)) { POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sGameOverTexs); } else { - POLY_OPA_DISP = - KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sSaveTexs[gSaveContext.language]); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, (void**)sSaveTexs[gSaveContext.language]); } gSPVertex(POLY_OPA_DISP++, &pauseCtx->saveVtx[60], 32, 0); @@ -1834,14 +1825,14 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx pauseCtx->offsetY = 80; } - pauseCtx->itemPageVtx = Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); + pauseCtx->itemPageVtx = (Vtx*)Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); func_80823A0C(globalCtx, pauseCtx->itemPageVtx, 0, 0); - pauseCtx->equipPageVtx = Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); + pauseCtx->equipPageVtx = (Vtx*)Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); func_80823A0C(globalCtx, pauseCtx->equipPageVtx, 1, 0); if (!sInDungeonScene) { - pauseCtx->mapPageVtx = Graph_Alloc(gfxCtx, 248 * sizeof(Vtx)); + pauseCtx->mapPageVtx = (Vtx*)Graph_Alloc(gfxCtx, 248 * sizeof(Vtx)); phi_t3 = func_80823A0C(globalCtx, pauseCtx->mapPageVtx, 4, 32); for (phi_t2 = 0, phi_t5 = 58; phi_t2 < 15; phi_t2++, phi_t3 += 4, phi_t5 -= 9) { @@ -1887,11 +1878,11 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx pauseCtx->mapPageVtx[phi_t3 - 2].v.tc[1] = pauseCtx->mapPageVtx[phi_t3 - 1].v.tc[1] = 0x40; } else { - pauseCtx->mapPageVtx = Graph_Alloc(gfxCtx, 128 * sizeof(Vtx)); + pauseCtx->mapPageVtx = (Vtx*)Graph_Alloc(gfxCtx, 128 * sizeof(Vtx)); func_80823A0C(globalCtx, pauseCtx->mapPageVtx, 2, 17); } - pauseCtx->questPageVtx = Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); + pauseCtx->questPageVtx = (Vtx*)Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); func_80823A0C(globalCtx, pauseCtx->questPageVtx, 3, 0); for (phi_t2 = 0; phi_t2 < 20; phi_t2++) { @@ -1916,7 +1907,7 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx pauseCtx->cursorVtx[17].v.tc[0] = pauseCtx->cursorVtx[18].v.tc[1] = pauseCtx->cursorVtx[19].v.tc[0] = pauseCtx->cursorVtx[19].v.tc[1] = 0x400; - pauseCtx->itemVtx = Graph_Alloc(gfxCtx, 164 * sizeof(Vtx)); + pauseCtx->itemVtx = (Vtx*)Graph_Alloc(gfxCtx, 164 * sizeof(Vtx)); for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t4 < 4; phi_t4++, phi_t5 -= 32) { for (phi_t1 = -96, phi_t3 = 0; phi_t3 < 6; phi_t3++, phi_t2 += 4, phi_t1 += 32) { @@ -2057,7 +2048,7 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx } } - pauseCtx->equipVtx = Graph_Alloc(gfxCtx, 112 * sizeof(Vtx)); + pauseCtx->equipVtx = (Vtx*)Graph_Alloc(gfxCtx, 112 * sizeof(Vtx)); for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t2 < 4; phi_t2++, phi_t5 -= 32) { for (phi_t3 = 0; phi_t3 < 4; phi_t3++, phi_t4 += 4) { @@ -2185,7 +2176,7 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx phi_t4 += 4; } - pauseCtx->questVtx = Graph_Alloc(gfxCtx, 188 * sizeof(Vtx)); + pauseCtx->questVtx = (Vtx*)Graph_Alloc(gfxCtx, 188 * sizeof(Vtx)); for (phi_t4 = 0, phi_t3 = 0; phi_t3 < 47; phi_t3++, phi_t4 += 4) { phi_t2_2 = D_8082B1F8[phi_t3]; @@ -2254,9 +2245,9 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx pauseCtx->questVtx[phi_t4 + 2].v.cn[3] = pauseCtx->questVtx[phi_t4 + 3].v.cn[3] = pauseCtx->alpha; } - pauseCtx->infoPanelVtx = Graph_Alloc(gfxCtx, 28 * sizeof(Vtx)); + pauseCtx->infoPanelVtx = (Vtx*)Graph_Alloc(gfxCtx, 28 * sizeof(Vtx)); - pauseCtx->saveVtx = Graph_Alloc(gfxCtx, 80 * sizeof(Vtx)); + pauseCtx->saveVtx = (Vtx*)Graph_Alloc(gfxCtx, 80 * sizeof(Vtx)); func_80823A0C(globalCtx, pauseCtx->saveVtx, 5, 5); } @@ -2545,8 +2536,8 @@ void KaleidoScope_LoadDungeonMap(GlobalContext* globalCtx) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; s32 pad; - interfaceCtx->mapSegment1 = map_48x85_static_lut[R_MAP_TEX_INDEX]; - interfaceCtx->mapSegment2 = map_48x85_static_lut[R_MAP_TEX_INDEX + 1]; + interfaceCtx->mapSegment1 = (u8*)map_48x85_static_lut[R_MAP_TEX_INDEX]; + interfaceCtx->mapSegment2 = (u8*)map_48x85_static_lut[R_MAP_TEX_INDEX + 1]; } void KaleidoScope_UpdateDungeonMap(GlobalContext* globalCtx) { @@ -2622,12 +2613,12 @@ void KaleidoScope_Update(GlobalContext* globalCtx) { pauseCtx->unk_204 = -314.0f; - pauseCtx->playerSegment = (void*)(((uintptr_t)globalCtx->objectCtx.spaceStart + 0x30) & ~0x3F); + pauseCtx->playerSegment = (u8*)(((uintptr_t)globalCtx->objectCtx.spaceStart + 0x30) & ~0x3F); size1 = func_80091738(globalCtx, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime); osSyncPrintf("プレイヤー size1=%x\n", size1); - pauseCtx->iconItemSegment = (void*)(((uintptr_t)pauseCtx->playerSegment + size1 + 0xF) & ~0xF); + pauseCtx->iconItemSegment = (u8*)(((uintptr_t)pauseCtx->playerSegment + size1 + 0xF) & ~0xF); size0 = gMagicArrowEquipEffectTex - gDekuStickIconTex; osSyncPrintf("icon_item size0=%x\n", size0); @@ -2635,7 +2626,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx) { "../z_kaleido_scope_PAL.c", 3662); - gSegments[8] = VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); + gSegments[8] = (uintptr_t)VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); //On N64 the textures of the icons are manipulated in RAM every time the pause menu opens. //This is fine since they are loaded again from ROM. @@ -2656,14 +2647,14 @@ void KaleidoScope_Update(GlobalContext* globalCtx) { } - pauseCtx->iconItem24Segment = (void*)(((uintptr_t)pauseCtx->iconItemSegment + size0 + 0xF) & ~0xF); + pauseCtx->iconItem24Segment = (u8*)(((uintptr_t)pauseCtx->iconItemSegment + size0 + 0xF) & ~0xF); size = 20 * 0x900; osSyncPrintf("icon_item24 size=%x\n", size); DmaMgr_SendRequest1(pauseCtx->iconItem24Segment, icon_item_24_static_lut[0], size, "../z_kaleido_scope_PAL.c", 3675); - pauseCtx->iconItemAltSegment = (void*)(((uintptr_t)pauseCtx->iconItem24Segment + size + 0xF) & ~0xF); + pauseCtx->iconItemAltSegment = (u8*)(((uintptr_t)pauseCtx->iconItem24Segment + size + 0xF) & ~0xF); switch (globalCtx->sceneNum) { case SCENE_YDAN: @@ -2706,7 +2697,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx) { break; } - pauseCtx->iconItemLangSegment = (void*)(((uintptr_t)pauseCtx->iconItemAltSegment + size2 + 0xF) & ~0xF); + pauseCtx->iconItemLangSegment = (u8*)(((uintptr_t)pauseCtx->iconItemAltSegment + size2 + 0xF) & ~0xF); if (gSaveContext.language == LANGUAGE_ENG) { size = POINTER_SUB(_icon_item_nes_staticSegmentRomEnd, _icon_item_nes_staticSegmentRomStart); @@ -2728,7 +2719,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx) { pauseCtx->iconItemLangSegment = _icon_item_fra_staticSegmentRomStart; } - pauseCtx->nameSegment = (void*)(((uintptr_t)pauseCtx->iconItemLangSegment + size + 0xF) & ~0xF); + pauseCtx->nameSegment = (u8*)(((uintptr_t)pauseCtx->iconItemLangSegment + size + 0xF) & ~0xF); //pauseCtx->nameSegment = NULL; osSyncPrintf("サイズ=%x\n", size2 + size1 + size0 + size); @@ -2741,7 +2732,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx) { DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, map_name_static_lut[((void)0, gSaveContext.worldMapArea) + 36] , // 0x9000 = 36 0xA00, "../z_kaleido_scope_PAL.c", 3776); - pauseCtx->uknSegment = map_name_static_lut[((void)0, gSaveContext.worldMapArea) + 36]; + pauseCtx->uknSegment = (u8*)map_name_static_lut[((void)0, gSaveContext.worldMapArea) + 36]; } else if (gSaveContext.language == LANGUAGE_GER) { DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, diff --git a/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c b/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c rename to src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.cpp diff --git a/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.c b/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.cpp similarity index 100% rename from src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.c rename to src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.cpp diff --git a/src/overlays/misc/ovl_map_mark_data/z_map_mark_data.c b/src/overlays/misc/ovl_map_mark_data/z_map_mark_data.cpp similarity index 100% rename from src/overlays/misc/ovl_map_mark_data/z_map_mark_data.c rename to src/overlays/misc/ovl_map_mark_data/z_map_mark_data.cpp diff --git a/src/port/code_800F9280.c b/src/port/code_800F9280.c deleted file mode 100644 index 8b15f4902..000000000 --- a/src/port/code_800F9280.c +++ /dev/null @@ -1 +0,0 @@ -#include "assets/code_800F9280.h" diff --git a/src/port/code_800F9280.cpp b/src/port/code_800F9280.cpp new file mode 100644 index 000000000..b4c59a8dd --- /dev/null +++ b/src/port/code_800F9280.cpp @@ -0,0 +1 @@ +//#include "assets/code_800F9280.h" diff --git a/src/port/controller/keyboard.cpp b/src/port/controller/keyboard.cpp index c29ec6256..736d000e8 100644 --- a/src/port/controller/keyboard.cpp +++ b/src/port/controller/keyboard.cpp @@ -19,9 +19,9 @@ extern "C" { void set_fullscreen(bool value); - u8 Get_Language(); - void Set_Language(u8 language_id); } +u8 Get_Language(); +void Set_Language(u8 language_id); #ifdef ENABLE_JSON bool saveJson(rapidjson::Document& doc, const std::string& jsonFilePath) diff --git a/src/port/main.c b/src/port/main.cpp similarity index 93% rename from src/port/main.c rename to src/port/main.cpp index dee8abc3d..e8954babf 100644 --- a/src/port/main.c +++ b/src/port/main.cpp @@ -21,16 +21,9 @@ PreNmiBuff* gAppNmiBufferPtr; SchedContext gSchedContext; PadMgr gPadMgr; uintptr_t gSegments[NUM_SEGMENTS]; -u32 osTvType = OS_TV_NTSC; -s32 gScreenWidth = SCREEN_WIDTH; -s32 gScreenHeight = SCREEN_HEIGHT; -#ifndef USE_NATIVE_MALLOC -u32 gSystemHeapSize = 0; -#endif AudioMgr gAudioMgr; -unk_D_8016E750 D_8016E750[4]; u8 osAppNmiBuffer[0x40]; UNK_TYPE D_06000000; u32 osResetType = 0; @@ -44,7 +37,7 @@ u32 osRomBase; u32 osMemSize = 0x800000; -void (*D_801755D0)(void) = NULL; +//void (*D_801755D0)(void) = NULL; void xxxDebugDisplay_Init(void) { @@ -147,8 +140,6 @@ int main() { osSyncPrintf("mainproc execution start\n"); // "Start running" - gScreenWidth = SCREEN_WIDTH; - gScreenHeight = SCREEN_HEIGHT; gAppNmiBufferPtr = (PreNmiBuff*)osAppNmiBuffer; //PreNmiBuff_Init(gAppNmiBufferPtr); //Fault_Init(); diff --git a/src/port/pc_main.cpp b/src/port/pc_main.cpp index d5213b841..3093895e4 100644 --- a/src/port/pc_main.cpp +++ b/src/port/pc_main.cpp @@ -7,16 +7,15 @@ static std::unique_ptr gWindow; //#define _WINGDI_ -extern "C" { + #include "global.h" #include "ultra64/vi.h" //#include "sched.h" #include "gfx.h" #include "def/graph.h" - extern OSViMode osViModeNtscLan1; - u64 frameRateDivisor(); - bool isRunning(); -} +extern OSViMode osViModeNtscLan1; + +u64 frameRateDivisor(); /*struct OSViMode { @@ -80,14 +79,7 @@ extern "C" { #include "n64-fast3d-engine/gfx_sdl.h" } #elif defined(USE_GLIDEN64) -extern "C" { -void gfx_init(const char* romName, OSViMode* viMode); -void gfx_shutdown(); -bool gfx_start_frame(); -void gfx_end_frame(); -void gfx_run(OSTask_t* task, u32 sz); -void gfx_fbe_enable(int enable); -} +#include "gfxapi.h" #endif #if defined(USE_CF3D) @@ -249,17 +241,19 @@ bool verifyIntegrity() return hasRom && hasPak; } +void main_func(); + extern "C" { - void main_func(void); + void hid_init(); void hid_update(); } extern void* gAudioBuffer; extern u32 gAudioBufferSize; -extern "C" { - void AudioMgr_HandleRetraceNULL(); -} + +void AudioMgr_HandleRetraceNULL(); + void audio_thread() { @@ -435,15 +429,15 @@ extern "C" { { gWindow->set_fullscreen(value, false); } - - bool isRunning() - { - return g_isRunning; - } - - void quit() - { - g_isRunning = false; - } +} + +bool isRunning() +{ + return g_isRunning; +} + +void quit() +{ + g_isRunning = false; } diff --git a/src/port/player/players.cpp b/src/port/player/players.cpp index 1c25719f1..39e40d845 100644 --- a/src/port/player/players.cpp +++ b/src/port/player/players.cpp @@ -2,12 +2,10 @@ #include "players.h" #include "../controller/controllers.h" -extern "C" { #include "z64.h"; #include "padmgr.h" - extern PadMgr gPadMgr; -} +extern PadMgr gPadMgr; extern "C" { void hid_init() { diff --git a/src/port/rsp.c b/src/port/rsp.cpp similarity index 100% rename from src/port/rsp.c rename to src/port/rsp.cpp diff --git a/src/port/rsp_boot.c b/src/port/rsp_boot.cpp similarity index 100% rename from src/port/rsp_boot.c rename to src/port/rsp_boot.cpp diff --git a/src/port/ultra_reimplementation.cpp b/src/port/ultra_reimplementation.cpp index 0bd57c4c8..429e15fc7 100644 --- a/src/port/ultra_reimplementation.cpp +++ b/src/port/ultra_reimplementation.cpp @@ -3,7 +3,6 @@ //#include //#include "global.h" -extern "C" { #include "global.h" #include "vt.h" //#include "ultra64/message.h" @@ -22,12 +21,9 @@ extern OSViMode osViModeNtscLan1; OSViMode gViConfigMode; -s8 D_80009430 = 1; -u8 gViConfigAdditionalScanLines = 0; -u32 gViConfigFeatures = OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF; -f32 gViConfigXScale = 1.0; -f32 gViConfigYScale = 1.0; -} +s8 D_80009430 = 1; +u8 gViConfigAdditionalScanLines = 0; + typedef u32 OSEvent; typedef void* OSMesg; @@ -44,15 +40,12 @@ typedef s32 OSPri; #define UNUSED -#define OS_CLOCK_RATE 62500000LL +#define OS_CLOCK_RATE 62500000LL u64 osClockRate = OS_CLOCK_RATE; -extern "C" -{ - u32 osGetCount(void); - s32 osAiSetNextBuffer(void* buf, u32 size); - s32 osAiSetFrequency(u32 frequency); -} +u32 osGetCount(void); +s32 osAiSetNextBuffer(void* buf, u32 size); +s32 osAiSetFrequency(u32 frequency); s32 osPiStartDma(struct OSIoMesg* mb, UNUSED s32 priority, UNUSED s32 direction, uintptr_t devAddr, void* vAddr, size_t nbytes, struct OSMesgQueue* mq) { @@ -77,8 +70,9 @@ s32 osJamMesg(UNUSED OSMesgQueue* mq, UNUSED OSMesg msg, UNUSED s32 flag) #ifdef _MSC_VER #include -OSTime osGetTime(void) { - return GetTickCount64(); +OSTime osGetTime(void) +{ + return GetTickCount64(); } #else OSTime osGetTime(void) @@ -110,97 +104,95 @@ s32 osEepromProbe(UNUSED OSMesgQueue* mq) return 1; } -#define OS_READ 0 // device -> RDRAM -#define OS_WRITE 1 // device <- RDRAM +#define OS_READ 0 // device -> RDRAM +#define OS_WRITE 1 // device <- RDRAM #define SRAM_SIZE 0x8000 -extern "C" { - void SsSram_ReadWrite(u32 address, void* buffer, size_t nbytes, s32 direction) +void SsSram_ReadWrite(u32 address, void* buffer, size_t nbytes, s32 direction) +{ + if(address < 0xA8000000) { - if(address < 0xA8000000) + return; + } + + address -= 0xA8000000; + + static u8 content[SRAM_SIZE] = {0}; + + if(direction == OS_READ) + { + s32 ret = -1; + +#if defined(__SWITCH__) && !defined(_MSC_VER) && !defined(BUILD_NRO) + mountSaveData(); + + FILE* fp = fopen("sv:/oot.sav", "rb"); + if(fp == NULL) + { + fp = fopen("sdmc:/oot.sav", "rb"); + + if(fp == NULL) + { + unmountSaveData(); + return -1; + } + } + + if(fread(content, 1, SRAM_SIZE, fp) == SRAM_SIZE) + { + memcpy(buffer, content + address, nbytes); + ret = 0; + } + fclose(fp); + unmountSaveData(); +#else + FILE* fp = nullptr; + + if(fopen_s(&fp, "oot.sav", "rb") != 0) + { + return; + } + if(fread(content, 1, SRAM_SIZE, fp) == SRAM_SIZE) + { + memcpy(buffer, content + address, nbytes); + ret = 0; + } + fclose(fp); +#endif + } + else if(direction == OS_WRITE) + { + memcpy(content + address, buffer, nbytes); + +#if defined(__SWITCH__) && !defined(_MSC_VER) && !defined(BUILD_NRO) + mountSaveData(); + FILE* fp = fopen("sv:/oot.sav", "wb"); + + if(fp == NULL) + { + fp = fopen("sdmc:/oot.sav", "wb"); + + if(fp == NULL) + { + return -1; + } + } + + s32 ret = fwrite(content, 1, SRAM_SIZE, fp) == SRAM_SIZE ? 0 : -1; + fclose(fp); + commitSave(); + unmountSaveData(); +#else + FILE* fp = nullptr; + + if(fopen_s(&fp, "oot.sav", "wb") != 0) { return; } - address -= 0xA8000000; - - static u8 content[SRAM_SIZE] = { 0 }; - - if(direction == OS_READ) - { - s32 ret = -1; - -#if defined(__SWITCH__) && !defined(_MSC_VER) && !defined(BUILD_NRO) - mountSaveData(); - - FILE* fp = fopen("sv:/oot.sav", "rb"); - if(fp == NULL) - { - fp = fopen("sdmc:/oot.sav", "rb"); - - if(fp == NULL) - { - unmountSaveData(); - return -1; - } - } - - if(fread(content, 1, SRAM_SIZE, fp) == SRAM_SIZE) - { - memcpy(buffer, content + address, nbytes); - ret = 0; - } - fclose(fp); - unmountSaveData(); -#else - FILE* fp = nullptr; - - if(fopen_s(&fp, "oot.sav", "rb") != 0) - { - return; - } - if(fread(content, 1, SRAM_SIZE, fp) == SRAM_SIZE) - { - memcpy(buffer, content + address, nbytes); - ret = 0; - } - fclose(fp); + s32 ret = fwrite(content, 1, SRAM_SIZE, fp) == SRAM_SIZE ? 0 : -1; + fclose(fp); #endif - } - else if(direction == OS_WRITE) - { - memcpy(content + address, buffer, nbytes); - -#if defined(__SWITCH__) && !defined(_MSC_VER) && !defined(BUILD_NRO) - mountSaveData(); - FILE* fp = fopen("sv:/oot.sav", "wb"); - - if(fp == NULL) - { - fp = fopen("sdmc:/oot.sav", "wb"); - - if(fp == NULL) - { - return -1; - } - } - - s32 ret = fwrite(content, 1, SRAM_SIZE, fp) == SRAM_SIZE ? 0 : -1; - fclose(fp); - commitSave(); - unmountSaveData(); -#else - FILE* fp = nullptr; - - if(fopen_s(&fp, "oot.sav", "wb") != 0) - { - return; - } - - s32 ret = fwrite(content, 1, SRAM_SIZE, fp) == SRAM_SIZE ? 0 : -1; - fclose(fp); -#endif - } } } @@ -232,9 +224,9 @@ s32 osEepromLongRead(UNUSED OSMesgQueue* mq, u8 address, u8* buffer, int nbytes) fclose(fp); unmountSaveData(); #else - FILE* fp = nullptr; + FILE* fp = nullptr; - if (fopen_s(&fp, "oot.sav", "rb") != 0) + if(fopen_s(&fp, "oot.sav", "rb") != 0) { return -1; } @@ -276,9 +268,9 @@ s32 osEepromLongWrite(UNUSED OSMesgQueue* mq, u8 address, u8* buffer, int nbytes commitSave(); unmountSaveData(); #else - FILE* fp = nullptr; + FILE* fp = nullptr; - if (fopen_s(&fp, "oot.sav", "wb") != 0) + if(fopen_s(&fp, "oot.sav", "wb") != 0) { return -1; } @@ -289,18 +281,21 @@ s32 osEepromLongWrite(UNUSED OSMesgQueue* mq, u8 address, u8* buffer, int nbytes return ret; } -u32 bcmp(void* s1, void* s2, u32 size) { - const u8* _s1 = (const u8*)s1; - const u8* _s2 = (const u8*)s2; +u32 bcmp(void* s1, void* s2, u32 size) +{ + const u8* _s1 = (const u8*)s1; + const u8* _s2 = (const u8*)s2; - while (size > 0) { - if (*_s1++ != *_s2++) { - return 1; - } - size--; - } + while(size > 0) + { + if(*_s1++ != *_s2++) + { + return 1; + } + size--; + } - return 0; + return 0; } #include @@ -308,72 +303,91 @@ u32 bcmp(void* s1, void* s2, u32 size) { #include #include -std::wstring utf8_to_utf16(const std::string& utf8) { - std::vector unicode; - size_t i = 0; - while (i < utf8.size()) { - unsigned long uni; - size_t todo; - bool error = false; - unsigned char ch = utf8[i++]; - if (ch <= 0x7F) { - uni = ch; - todo = 0; - } else if (ch <= 0xBF) { - throw std::logic_error("not a UTF-8 string"); - } else if (ch <= 0xDF) { - uni = ch & 0x1F; - todo = 1; - } else if (ch <= 0xEF) { - uni = ch & 0x0F; - todo = 2; - } else if (ch <= 0xF7) { - uni = ch & 0x07; - todo = 3; - } else { - throw std::logic_error("not a UTF-8 string"); - } - for (size_t j = 0; j < todo; ++j) { - if (i == utf8.size()) - throw std::logic_error("not a UTF-8 string"); - unsigned char ch = utf8[i++]; - if (ch < 0x80 || ch > 0xBF) - throw std::logic_error("not a UTF-8 string"); - uni <<= 6; - uni += ch & 0x3F; - } - if (uni >= 0xD800 && uni <= 0xDFFF) - throw std::logic_error("not a UTF-8 string"); - if (uni > 0x10FFFF) - throw std::logic_error("not a UTF-8 string"); - unicode.push_back(uni); - } - std::wstring utf16; - for (size_t i = 0; i < unicode.size(); ++i) { - unsigned long uni = unicode[i]; - if (uni <= 0xFFFF) { - utf16 += (wchar_t)uni; - } else { - uni -= 0x10000; - utf16 += (wchar_t)((uni >> 10) + 0xD800); - utf16 += (wchar_t)((uni & 0x3FF) + 0xDC00); - } - } - return utf16; +std::wstring utf8_to_utf16(const std::string& utf8) +{ + std::vector unicode; + size_t i = 0; + while(i < utf8.size()) + { + unsigned long uni; + size_t todo; + bool error = false; + unsigned char ch = utf8[i++]; + if(ch <= 0x7F) + { + uni = ch; + todo = 0; + } + else if(ch <= 0xBF) + { + throw std::logic_error("not a UTF-8 string"); + } + else if(ch <= 0xDF) + { + uni = ch & 0x1F; + todo = 1; + } + else if(ch <= 0xEF) + { + uni = ch & 0x0F; + todo = 2; + } + else if(ch <= 0xF7) + { + uni = ch & 0x07; + todo = 3; + } + else + { + throw std::logic_error("not a UTF-8 string"); + } + for(size_t j = 0; j < todo; ++j) + { + if(i == utf8.size()) + throw std::logic_error("not a UTF-8 string"); + unsigned char ch = utf8[i++]; + if(ch < 0x80 || ch > 0xBF) + throw std::logic_error("not a UTF-8 string"); + uni <<= 6; + uni += ch & 0x3F; + } + if(uni >= 0xD800 && uni <= 0xDFFF) + throw std::logic_error("not a UTF-8 string"); + if(uni > 0x10FFFF) + throw std::logic_error("not a UTF-8 string"); + unicode.push_back(uni); + } + std::wstring utf16; + for(size_t i = 0; i < unicode.size(); ++i) + { + unsigned long uni = unicode[i]; + if(uni <= 0xFFFF) + { + utf16 += (wchar_t)uni; + } + else + { + uni -= 0x10000; + utf16 += (wchar_t)((uni >> 10) + 0xD800); + utf16 += (wchar_t)((uni & 0x3FF) + 0xDC00); + } + } + return utf16; } static char buffer[0x10000]; -void osSyncPrintf(const char* fmt, ...) { - memset(buffer, 0, sizeof(buffer)); - va_list arg; - int done; - va_start(arg, fmt); - vsprintf(buffer, fmt, arg); - va_end(arg); +void osSyncPrintf(const char* fmt, ...) +{ + memset(buffer, 0, sizeof(buffer)); + va_list arg; + int done; + va_start(arg, fmt); + vsprintf(buffer, fmt, arg); + va_end(arg); auto s = utf8_to_utf16(buffer); - //OutputDebugStringA(buffer); + // OutputDebugStringA(buffer); OutputDebugString(s.c_str()); } @@ -384,41 +398,39 @@ void osSyncPrintf(const char* fmt, ...) { static_assert(sizeof(Color_RGB8) == 3, "incorrect Color_RGB8 size"); -extern "C" { - s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize) +s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize) +{ + auto decoder = std::make_unique((const u8*)data, SCREEN_WIDTH * SCREEN_HEIGHT * 2); + + if(decoder->GetResult() != Jpeg::Decoder::OK) { - auto decoder = std::make_unique((const u8*)data, SCREEN_WIDTH * SCREEN_HEIGHT * 2); - - if(decoder->GetResult() != Jpeg::Decoder::OK) - { - return 1; - } - - Color_RGB8* p = (Color_RGB8*)decoder->GetImage(); - u64 sz = decoder->GetImageSize() / sizeof(Color_RGB8); - u16* out = (u16*)zbuffer; - - for(u64 i = 0; i < sz; i++, p++, out++) - { - u8 r = p->r / 8; - u8 g = p->g / 8; - u8 b = p->b / 8; - *out = BE16((r << 11) + (g << 6) + (b << 1) + 1); - //*out = BE16(1); - } - - return 0; + return 1; } + + Color_RGB8* p = (Color_RGB8*)decoder->GetImage(); + u64 sz = decoder->GetImageSize() / sizeof(Color_RGB8); + u16* out = (u16*)zbuffer; + + for(u64 i = 0; i < sz; i++, p++, out++) + { + u8 r = p->r / 8; + u8 g = p->g / 8; + u8 b = p->b / 8; + *out = BE16((r << 11) + (g << 6) + (b << 1) + 1); + //*out = BE16(1); + } + + return 0; } #include "ultra64/rcp.h" -void* gAudioBuffer = nullptr; +void* gAudioBuffer = nullptr; u32 gAudioBufferSize = 0; s32 osAiSetNextBuffer(void* buf, u32 size) { - static u8 D_80130500 = false; + static u8 D_80130500 = false; uintptr_t bufAdjusted = (uintptr_t)buf; s32 status; @@ -444,20 +456,20 @@ s32 osAiSetNextBuffer(void* buf, u32 size) // OS_K0_TO_PHYSICAL replaces osVirtualToPhysical, this replacement // assumes that only KSEG0 addresses are given - //HW_REG(AI_DRAM_ADDR_REG, uintptr_t) = bufAdjusted; - //HW_REG(AI_LEN_REG, u32) = size; - gAudioBuffer = (void*)bufAdjusted; + // HW_REG(AI_DRAM_ADDR_REG, uintptr_t) = bufAdjusted; + // HW_REG(AI_LEN_REG, u32) = size; + gAudioBuffer = (void*)bufAdjusted; gAudioBufferSize = size; return 0; } -extern "C" s32 osViClock; +extern s32 osViClock; s32 osAiSetFrequency(u32 frequency) { u8 bitrate; f32 dacRateF = ((f32)osViClock / frequency) + 0.5f; - u32 dacRate = dacRateF; + u32 dacRate = dacRateF; if(dacRate < 132) { @@ -471,7 +483,7 @@ s32 osAiSetFrequency(u32 frequency) bitrate = 16; } - //HW_REG(AI_DACRATE_REG, u32) = dacRate - 1; - //HW_REG(AI_BITRATE_REG, u32) = bitrate - 1; + // HW_REG(AI_DACRATE_REG, u32) = dacRate - 1; + // HW_REG(AI_BITRATE_REG, u32) = bitrate - 1; return osViClock / (s32)dacRate; } diff --git a/src/port/window/sdl/window_sdl2.cpp b/src/port/window/sdl/window_sdl2.cpp index 3862072c3..ed1c6978e 100644 --- a/src/port/window/sdl/window_sdl2.cpp +++ b/src/port/window/sdl/window_sdl2.cpp @@ -14,10 +14,9 @@ #include #include -extern "C" -{ - void quit(); -} + +void quit(); + namespace platform::window { diff --git a/src/port/window/window.cpp b/src/port/window/window.cpp index 690c17831..878bb7dd3 100644 --- a/src/port/window/window.cpp +++ b/src/port/window/window.cpp @@ -1,8 +1,6 @@ #include "../window.h" #include -extern "C" { #include "z64.h" -} namespace platform::window { diff --git a/tools/ZAPD/ZAPD/Declaration.cpp b/tools/ZAPD/ZAPD/Declaration.cpp index bb5429603..fc19c7a70 100644 --- a/tools/ZAPD/ZAPD/Declaration.cpp +++ b/tools/ZAPD/ZAPD/Declaration.cpp @@ -210,15 +210,15 @@ std::string Declaration::GetStaticForwardDeclarationStr() const if (arrayItemCntStr != "") { - return StringHelper::Sprintf("static %s %s[%s];\n", STR(varType), STR(varName), + return StringHelper::Sprintf("extern %s %s[%s];\n", STR(varType), STR(varName), STR(arrayItemCntStr)); } else { - return StringHelper::Sprintf("static %s %s[%i];\n", STR(varType), STR(varName), + return StringHelper::Sprintf("extern %s %s[%i];\n", STR(varType), STR(varName), arrayItemCnt); } } - return StringHelper::Sprintf("static %s %s;\n", STR(varType), STR(varName)); + return StringHelper::Sprintf("extern %s %s;\n", STR(varType), STR(varName)); } diff --git a/tools/gen_headers.py b/tools/gen_headers.py index 0c9405e4f..cba0f4aca 100644 --- a/tools/gen_headers.py +++ b/tools/gen_headers.py @@ -9,6 +9,8 @@ import json skipWords = ['extern', 'volatile'] newPath = 'include/def/' +cpp = True + def writeFile(path, buffer): try: with open(path, 'r', encoding="UTF-8") as f: @@ -58,12 +60,23 @@ for path in Path('include/').rglob('*.h'): if match: for m in match: structs[str(m)] = 1 + + + match = re.findall(r'struct\s*\{[^\}]*\}\s*([A-Z0-9_]+)\s*;', buffer, flags = re.I | re.S) + + if match: + for m in match: + structs[str(m)] = 1 + + match = re.findall(r'struct\s*([A-Z0-9_]+)\s*\{[^\}]*\}', buffer, flags = re.I | re.S) + + if match: + for m in match: + structs[str(m)] = 1 x = list(structs.keys()) x.sort() -#print(x) saveJson('structs.json', x) -#exit(0) with open('oldfuncs.h', 'r') as f: buffer = f.read() @@ -96,7 +109,7 @@ for line in buffer.split('\n'): b = 'void' args.append(b) - if cleanType(b) in structs: + if not cpp and cleanType(b) in structs: args2.append('struct ' + b) else: args2.append(b) @@ -115,7 +128,7 @@ for line in buffer.split('\n'): prototypeNew = '%s(%s)%s' % (left, ', '.join(args2), right) - if cleanType(prototypeNew) in structs: + if not cpp and cleanType(prototypeNew) in structs: prototypeNew = 'struct ' + prototypeNew @@ -144,12 +157,26 @@ for path in Path('src/').rglob('*.c'): continue paths.append(str(path)) +for path in Path('src/').rglob('*.cpp'): + path = str(path) + + if '/port/' in path.replace('\\', '/'): + continue + paths.append(str(path)) + for path in Path('assets/').rglob('*.c'): path = str(path) if '/port/' in path.replace('\\', '/'): continue paths.append(str(path)) + +for path in Path('assets/').rglob('*.cpp'): + path = str(path) + + if '/port/' in path.replace('\\', '/'): + continue + paths.append(str(path)) saveJson('symbols_paths.json', paths) @@ -267,6 +294,7 @@ for symbol, params in var_symbols.items(): #print(fileMap) #print(var_symbols) + ''' for c_file, items in fileMap.items(): buffer = '#pragma once\n\n' @@ -293,22 +321,45 @@ for symbol, params in symbols.items(): fileMap[f][0].append(params) +saveJson('file_map.json', fileMap) refs = {} def getDefName(name): return 'INTERNAL_' + re.sub('[^A-Za-z0-9]+', '_', name).upper() for c_file, items in fileMap.items(): - buffer = '#pragma once' + buffer = '#pragma once\n' - - fileName = os.path.basename(c_file)[0:-2] + '.h' + bits = os.path.basename(c_file).split('.') + bits[-1] = 'h' + fileName = '.'.join(bits) items[0].sort(key=lambda x: x['symbol']) items[1].sort(key=lambda x: x['symbol']) + ats = {} + + for param in items[0]: # functions + for at in param["argTypes"]: + ats[cleanType(at)] = 1 + ats[cleanType(param["type"])] = 1 + + for param in items[1]: # variables + ats[cleanType(param["type"])] = 1 + + ctsa = ats.keys() + sd = [] + for at in ctsa: + ct = at + if ct in structs and ct not in ('Mtx'): + sd.append('struct %s;' % ct) + + if len(sd) > 0: + buffer += '\n'.join(sd) + '\n' + + if len(items[1]) > 0: - buffer += '\n\n' + buffer += '\n' for param in items[1]: buffer += '%s\n' % param['prototype'] @@ -321,10 +372,12 @@ for c_file, items in fileMap.items(): if len(items[0]) > 0: - buffer += '\n#ifdef ' + getDefName(c_file) + '\n' + buffer += '\n' + if not cpp: + buffer += '#ifdef ' + getDefName(c_file) + '\n' for param in items[0]: - buffer += '%s\n' % param['prototypeOrig'] + buffer += '%s\n' % param['prototypeOrig'].replace('this', 'pthis') for r in param['refs']: if r not in refs: @@ -332,13 +385,14 @@ for c_file, items in fileMap.items(): if fileName not in refs[r]: refs[r].append(fileName) - - buffer += '#else\n' - - for param in items[0]: - buffer += '%s\n' % param['prototype'] + + if not cpp: + buffer += '#else\n' - buffer += '#endif\n' + for param in items[0]: + buffer += '%s\n' % param['prototype'] + + buffer += '#endif\n' writeFile(os.path.join(newPath, fileName), buffer) diff --git a/tools/remove_typedef.py b/tools/remove_typedef.py index 2ff6ffa6e..9cf193d83 100644 --- a/tools/remove_typedef.py +++ b/tools/remove_typedef.py @@ -15,13 +15,19 @@ dir = 'include/' structs = {} for path in Path(dir).rglob('*.h'): x = str(path).replace('\\', '/') - if 'ultra64' in x: - continue + #if 'ultra64' in x: + # continue #print(x) with open(x, 'r', encoding="UTF-8") as f: buffer = f.read().replace('\r', '') - buffer = re.sub(r'typedef \s*struct\s*(\{[^\}]*\})\s*([A-Z0-9_]+)\s*;', r'struct \2 \1;', buffer, flags = re.I | re.S) + buffer = re.sub(r'typedef \s*struct\s*(\{[^\}]*\n\})\s*([A-Z0-9_]+)\s*;', r'struct \2 \1;', buffer, flags = re.I | re.S) + buffer = re.sub(r'typedef \s*union\s*(\{[^\}]*\n\})\s*([A-Z0-9_]+)\s*;', r'union \2 \1;', buffer, flags = re.I | re.S) + buffer = re.sub(r'typedef \s*enum\s*(\{[^\}]*\n\})\s*([A-Z0-9_]+)\s*;', r'enum \2 \1;', buffer, flags = re.I | re.S) + + buffer = re.sub(r'typedef \s*struct\s*([A-Za-z0-9_]*)\s*(\{[^\}]*\n\})\s*([A-Z0-9_]+)\s*;', r'struct \3 \2;', buffer, flags = re.I | re.S) + + buffer = buffer.replace('struct Gfx*', 'Gfx*') match = re.search(r'struct\s+([A-Za-z0-9_]+)[^A-Za-z0-9_]', buffer) @@ -29,7 +35,7 @@ for path in Path(dir).rglob('*.h'): structs[match.group(1)] = 1 writeFile(x, buffer) - +exit(0) files = [] for path in Path(dir).rglob('*.h'): x = str(path).replace('\\', '/') @@ -48,7 +54,6 @@ for path in Path('src').rglob('*.c'): files.append(x) for x in files: - print('checking ' + x) with open(x, 'r', encoding="UTF-8") as f: buffer = f.read().replace('\r', '') buffer2 = buffer diff --git a/variables_old.txt b/variables_old.txt index 4dbdf368f..014f934db 100644 --- a/variables_old.txt +++ b/variables_old.txt @@ -12,7 +12,9 @@ extern u32 gDmaMgrDmaBuffSize; extern vu8 gViConfigUseDefault; extern u8 gViConfigAdditionalScanLines; extern u32 gViConfigFeatures; +extern void* gItemIconsCurrent[86]; extern f32 gViConfigXScale; +extern void* gItemIconsGray[86][32*32]; extern f32 gViConfigYScale; extern OSPiHandle* gCartHandle; extern u32 __osPiAccessQueueEnabled; diff --git a/vs/OOT.vcxproj b/vs/OOT.vcxproj index 31fc932de..6fdb322f9 100644 --- a/vs/OOT.vcxproj +++ b/vs/OOT.vcxproj @@ -23,7 +23,7 @@ Win32Proj {787282e8-e1bf-4dbd-b3b5-26ce47f0a8b1} OOT - $(LatestTargetPlatformVersion) + 10.0 @@ -108,7 +108,7 @@ false WIN32;ENABLE_MOUSE;USE_NATIVE_MALLOC;_CONSOLE;_LANGUAGE_C;ENABLE_OPENGL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest 4146 true MultiThreadedDebug @@ -178,1756 +178,1751 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TurnOffAllWarnings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - + true true - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1935,15 +1930,15 @@ - + - - + + diff --git a/vs/OOT.vcxproj.filters b/vs/OOT.vcxproj.filters index ba360dc36..0f4214e7c 100644 --- a/vs/OOT.vcxproj.filters +++ b/vs/OOT.vcxproj.filters @@ -111,5068 +111,5068 @@ - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\actors - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\effects - + Source Files\overlays\gamestates - + Source Files\overlays\gamestates - + Source Files\overlays\gamestates - + Source Files\overlays\gamestates - + Source Files\overlays\gamestates - + Source Files\overlays\gamestates - + Source Files\overlays\gamestates - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\overlays\misc - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\os - + Source Files\libultra\rmon - + Source Files\libultra\rmon - + Source Files\libultra\rmon - + Source Files\libultra\rmon - + Source Files\elf_message - + Source Files\elf_message - + Source Files\dmadata - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\code - + Source Files\buffers - + Source Files\buffers - + Source Files\buffers - + Source Files\boot - + Source Files\boot - + Source Files\boot - + Source Files\boot - + Source Files\boot - + Source Files\boot - + Source Files\port - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\textures - + Source Files\assets\misc - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\objects - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\scenes - + Source Files\assets\text - + Source Files\assets\text - + Source Files\assets\text - + Source Files\assets\text - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\libultra\gu - + Source Files\port - + Source Files\port - + Source Files\port - + Source Files\buffers